aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bin/chflags/Makefile11
-rw-r--r--bin/chflags/chflags.1138
-rw-r--r--bin/chflags/chflags.c185
-rw-r--r--contrib/binutils/bfd/VERSION1
-rw-r--r--contrib/binutils/bfd/doc/bfd.texi585
-rw-r--r--contrib/binutils/gas/conf.in127
-rw-r--r--contrib/binutils/gas/config/i386coff.mt1
-rw-r--r--contrib/binutils/gas/config/sco5.mt1
-rwxr-xr-xcontrib/binutils/install.sh247
-rw-r--r--contrib/gcc/ORDERS3757
-rw-r--r--contrib/gcc/README.ACORN18
-rw-r--r--contrib/gcc/README.ALTOS55
-rw-r--r--contrib/gcc/README.APOLLO112
-rw-r--r--contrib/gcc/README.FRESCO17
-rw-r--r--contrib/gcc/README.NS32K130
-rw-r--r--contrib/gcc/README.RS6000111
-rw-r--r--contrib/gcc/README.X11447
-rw-r--r--contrib/gcc/alloca.c504
-rw-r--r--contrib/gcc/bc-emit.c992
-rw-r--r--contrib/gcc/bc-emit.h133
-rw-r--r--contrib/gcc/bc-optab.c789
-rw-r--r--contrib/gcc/bc-optab.h75
-rw-r--r--contrib/gcc/bc-typecd.def21
-rw-r--r--contrib/gcc/bc-typecd.h54
-rw-r--r--contrib/gcc/bi-arity.c80
-rw-r--r--contrib/gcc/bi-defs.h48
-rw-r--r--contrib/gcc/bi-lexer.c167
-rw-r--r--contrib/gcc/bi-opcode.c78
-rw-r--r--contrib/gcc/bi-opname.c59
-rw-r--r--contrib/gcc/bi-parser.y169
-rw-r--r--contrib/gcc/bi-reverse.c61
-rw-r--r--contrib/gcc/bi-run.h159
-rw-r--r--contrib/gcc/bytecode.def322
-rw-r--r--contrib/gcc/bytecode.h81
-rw-r--r--contrib/gcc/bytetypes.h35
-rwxr-xr-xcontrib/gcc/config.sub976
-rw-r--r--contrib/gcc/config/alpha/alpha.c4638
-rw-r--r--contrib/gcc/config/alpha/gdb-osf12.h26
-rw-r--r--contrib/gcc/config/alpha/gdb-osf2.h26
-rw-r--r--contrib/gcc/config/alpha/gdb.h26
-rw-r--r--contrib/gcc/config/alpha/osf2.h32
-rw-r--r--contrib/gcc/config/alpha/x-alpha1
-rw-r--r--contrib/gcc/config/alpha/xm-alpha.h18
-rw-r--r--contrib/gcc/config/i386/go32.h96
-rw-r--r--contrib/gcc/config/i386/i386iscgas.h67
-rw-r--r--contrib/gcc/config/i386/next.c7
-rw-r--r--contrib/gcc/config/i386/sysv4gdb.h7
-rw-r--r--contrib/gcc/config/i386/t-iscscodbx2
-rw-r--r--contrib/gcc/config/i386/x-freebsd4
-rw-r--r--contrib/gcc/config/i386/xm-netbsd.h4
-rw-r--r--contrib/gcc/config/sparc/aout.h26
-rw-r--r--contrib/gcc/config/sparc/bsd.h7
-rw-r--r--contrib/gcc/config/sparc/elf.h58
-rw-r--r--contrib/gcc/config/sparc/gmon-sol2.c425
-rw-r--r--contrib/gcc/config/sparc/hal.h33
-rw-r--r--contrib/gcc/config/sparc/lb1spc.asm784
-rw-r--r--contrib/gcc/config/sparc/lb1spl.asm246
-rw-r--r--contrib/gcc/config/sparc/linux-aout.h130
-rw-r--r--contrib/gcc/config/sparc/linux.h259
-rw-r--r--contrib/gcc/config/sparc/linux64.h366
-rw-r--r--contrib/gcc/config/sparc/lite.h38
-rw-r--r--contrib/gcc/config/sparc/litecoff.h113
-rw-r--r--contrib/gcc/config/sparc/lynx-ng.h41
-rw-r--r--contrib/gcc/config/sparc/lynx.h53
-rw-r--r--contrib/gcc/config/sparc/netbsd.h46
-rw-r--r--contrib/gcc/config/sparc/openbsd.h68
-rw-r--r--contrib/gcc/config/sparc/pbd.h156
-rw-r--r--contrib/gcc/config/sparc/rtems.h35
-rw-r--r--contrib/gcc/config/sparc/sol2-c1.asm110
-rw-r--r--contrib/gcc/config/sparc/sol2-ci.asm68
-rw-r--r--contrib/gcc/config/sparc/sol2-cn.asm54
-rw-r--r--contrib/gcc/config/sparc/sol2-g1.asm88
-rw-r--r--contrib/gcc/config/sparc/sol2-sld-64.h363
-rw-r--r--contrib/gcc/config/sparc/sol2-sld.h11
-rw-r--r--contrib/gcc/config/sparc/sol2.h236
-rw-r--r--contrib/gcc/config/sparc/sp64-aout.h38
-rw-r--r--contrib/gcc/config/sparc/sp64-elf.h158
-rw-r--r--contrib/gcc/config/sparc/sparc.c7843
-rw-r--r--contrib/gcc/config/sparc/sparc.h3309
-rw-r--r--contrib/gcc/config/sparc/sparc.md8236
-rw-r--r--contrib/gcc/config/sparc/splet.h69
-rw-r--r--contrib/gcc/config/sparc/sun4gas.h27
-rw-r--r--contrib/gcc/config/sparc/sun4o3.h29
-rw-r--r--contrib/gcc/config/sparc/sunos4.h49
-rw-r--r--contrib/gcc/config/sparc/sysv4.h216
-rw-r--r--contrib/gcc/config/sparc/t-elf39
-rw-r--r--contrib/gcc/config/sparc/t-halos2
-rw-r--r--contrib/gcc/config/sparc/t-linux6421
-rw-r--r--contrib/gcc/config/sparc/t-sol230
-rw-r--r--contrib/gcc/config/sparc/t-sol2-648
-rw-r--r--contrib/gcc/config/sparc/t-sp642
-rw-r--r--contrib/gcc/config/sparc/t-sparcbare26
-rw-r--r--contrib/gcc/config/sparc/t-sparclite24
-rw-r--r--contrib/gcc/config/sparc/t-splet22
-rw-r--r--contrib/gcc/config/sparc/t-sunos407
-rw-r--r--contrib/gcc/config/sparc/t-sunos4116
-rw-r--r--contrib/gcc/config/sparc/t-vxsparc17
-rw-r--r--contrib/gcc/config/sparc/vxsim.h131
-rw-r--r--contrib/gcc/config/sparc/vxsparc.h61
-rw-r--r--contrib/gcc/config/sparc/x-sysv42
-rw-r--r--contrib/gcc/config/sparc/xm-linux.h26
-rw-r--r--contrib/gcc/config/sparc/xm-lynx.h39
-rw-r--r--contrib/gcc/config/sparc/xm-openbsd.h23
-rw-r--r--contrib/gcc/config/sparc/xm-pbd.h10
-rw-r--r--contrib/gcc/config/sparc/xm-sol2.h4
-rw-r--r--contrib/gcc/config/sparc/xm-sp64.h27
-rw-r--r--contrib/gcc/config/sparc/xm-sparc.h49
-rw-r--r--contrib/gcc/config/sparc/xm-sysv4-64.h27
-rw-r--r--contrib/gcc/config/sparc/xm-sysv4.h48
-rw-r--r--contrib/gcc/config/x-netbsd6
-rw-r--r--contrib/gcc/config/xm-netbsd.h26
-rw-r--r--contrib/gcc/config/xm-siglist.h6
-rw-r--r--contrib/gcc/cp/class.h117
-rw-r--r--contrib/gcc/cp/edsel.c928
-rw-r--r--contrib/gcc/cp/g++.c582
-rw-r--r--contrib/gcc/cp/gc.c1550
-rw-r--r--contrib/gcc/cp/gpcompare.texi236
-rw-r--r--contrib/gcc/cp/reno.texi752
-rw-r--r--contrib/gcc/cp/templates.texi235
-rw-r--r--contrib/gcc/cp/tree.def116
-rwxr-xr-xcontrib/gcc/fixinc.dgux185
-rw-r--r--contrib/gcc/fixinc.ptx257
-rwxr-xr-xcontrib/gcc/fixinc.sco427
-rwxr-xr-xcontrib/gcc/fixinc.svr41726
-rw-r--r--contrib/gcc/fixinc.winnt232
-rwxr-xr-xcontrib/gcc/install.sh238
-rw-r--r--contrib/gcc/modemap.def31
-rw-r--r--contrib/gcc/objc-act.c8268
-rw-r--r--contrib/gcc/objc-act.h117
-rw-r--r--contrib/gcc/objc-tree.def37
-rw-r--r--contrib/gcc/objc/Makefile100
-rw-r--r--contrib/gcc/objc/NXConstStr.h44
-rw-r--r--contrib/gcc/objc/NXConstStr.m42
-rw-r--r--contrib/gcc/objc/Object.h124
-rw-r--r--contrib/gcc/objc/Object.m387
-rw-r--r--contrib/gcc/objc/Protocol.h58
-rw-r--r--contrib/gcc/objc/Protocol.m128
-rw-r--r--contrib/gcc/objc/archive.c1651
-rw-r--r--contrib/gcc/objc/class.c358
-rw-r--r--contrib/gcc/objc/encoding.c554
-rw-r--r--contrib/gcc/objc/hash.c283
-rw-r--r--contrib/gcc/objc/hash.h206
-rw-r--r--contrib/gcc/objc/init.c834
-rw-r--r--contrib/gcc/objc/list.h150
-rw-r--r--contrib/gcc/objc/makefile.dos56
-rw-r--r--contrib/gcc/objc/misc.c152
-rw-r--r--contrib/gcc/objc/objc-api.h584
-rw-r--r--contrib/gcc/objc/objc.h157
-rw-r--r--contrib/gcc/objc/objects.c92
-rw-r--r--contrib/gcc/objc/runtime.h88
-rw-r--r--contrib/gcc/objc/sarray.c522
-rw-r--r--contrib/gcc/objc/sarray.h237
-rw-r--r--contrib/gcc/objc/selector.c458
-rw-r--r--contrib/gcc/objc/sendmsg.c653
-rw-r--r--contrib/gcc/objc/typedstream.h132
-rw-r--r--contrib/gdb/gdb/ser-ocd.c209
-rw-r--r--contrib/groff/src/devices/grotty/grotty.man212
-rw-r--r--contrib/groff/src/libs/libgroff/illegal.cc22
-rw-r--r--contrib/groff/src/preproc/eqn/neqn.sh19
-rw-r--r--contrib/groff/src/roff/groff/groff.man434
-rw-r--r--contrib/groff/src/roff/nroff/nroff.man107
-rwxr-xr-xcontrib/groff/src/roff/nroff/nroff.sh77
-rw-r--r--contrib/libpam/modules/pam_nologin/Makefile86
-rw-r--r--contrib/libreadline/doc/readline.31204
-rw-r--r--contrib/nvi/catalog/ru_RU.KOI8-R267
-rw-r--r--contrib/nvi/catalog/ru_RU.KOI8-R.base214
-rw-r--r--contrib/nvi/catalog/ru_RU.KOI8-R.check169
-rw-r--r--contrib/nvi/catalog/ru_RU.KOI8-R.owner1
-rw-r--r--contrib/telnet/arpa/telnet.h341
-rw-r--r--contrib/telnet/libtelnet/auth-proto.h108
-rw-r--r--contrib/telnet/libtelnet/auth.c684
-rw-r--r--contrib/telnet/libtelnet/auth.h87
-rw-r--r--contrib/telnet/libtelnet/enc-proto.h128
-rw-r--r--contrib/telnet/libtelnet/enc_des.c722
-rw-r--r--contrib/telnet/libtelnet/encrypt.c1023
-rw-r--r--contrib/telnet/libtelnet/encrypt.h114
-rw-r--r--contrib/telnet/libtelnet/genget.c104
-rw-r--r--contrib/telnet/libtelnet/getent.c68
-rw-r--r--contrib/telnet/libtelnet/kerberos.c552
-rw-r--r--contrib/telnet/libtelnet/kerberos5.c764
-rw-r--r--contrib/telnet/libtelnet/key-proto.h71
-rw-r--r--contrib/telnet/libtelnet/krb4encpwd.c447
-rw-r--r--contrib/telnet/libtelnet/misc-proto.h79
-rw-r--r--contrib/telnet/libtelnet/misc.c98
-rw-r--r--contrib/telnet/libtelnet/misc.h42
-rw-r--r--contrib/telnet/libtelnet/pk.c267
-rw-r--r--contrib/telnet/libtelnet/pk.h41
-rw-r--r--contrib/telnet/libtelnet/read_password.c145
-rw-r--r--contrib/telnet/libtelnet/rsaencpwd.c492
-rw-r--r--contrib/telnet/libtelnet/spx.c587
-rw-r--r--contrib/telnet/libtelnet/sra.c478
-rw-r--r--contrib/telnet/telnet/authenc.c111
-rw-r--r--contrib/telnet/telnet/commands.c3239
-rw-r--r--contrib/telnet/telnet/defines.h61
-rw-r--r--contrib/telnet/telnet/externs.h502
-rw-r--r--contrib/telnet/telnet/fdset.h49
-rw-r--r--contrib/telnet/telnet/general.h45
-rw-r--r--contrib/telnet/telnet/main.c389
-rw-r--r--contrib/telnet/telnet/network.c178
-rw-r--r--contrib/telnet/telnet/ring.c364
-rw-r--r--contrib/telnet/telnet/ring.h105
-rw-r--r--contrib/telnet/telnet/sys_bsd.c1221
-rw-r--r--contrib/telnet/telnet/telnet.11384
-rw-r--r--contrib/telnet/telnet/telnet.c2662
-rw-r--r--contrib/telnet/telnet/terminal.c244
-rw-r--r--contrib/telnet/telnet/tn3270.c411
-rw-r--r--contrib/telnet/telnet/types.h52
-rw-r--r--contrib/telnet/telnet/utilities.c946
-rw-r--r--contrib/telnet/telnetd/authenc.c94
-rw-r--r--contrib/telnet/telnetd/defs.h296
-rw-r--r--contrib/telnet/telnetd/ext.h242
-rw-r--r--contrib/telnet/telnetd/global.c52
-rw-r--r--contrib/telnet/telnetd/pathnames.h55
-rw-r--r--contrib/telnet/telnetd/slc.c495
-rw-r--r--contrib/telnet/telnetd/state.c1619
-rw-r--r--contrib/telnet/telnetd/sys_term.c2333
-rw-r--r--contrib/telnet/telnetd/telnetd.8615
-rw-r--r--contrib/telnet/telnetd/telnetd.c1634
-rw-r--r--contrib/telnet/telnetd/telnetd.h49
-rw-r--r--contrib/telnet/telnetd/termstat.c677
-rw-r--r--contrib/telnet/telnetd/utility.c1246
-rw-r--r--etc/defaults/pccard.conf954
-rw-r--r--etc/disktab224
-rw-r--r--etc/etc.amd64/rc.amd64225
-rw-r--r--etc/etc.amd64/ttys305
-rw-r--r--etc/mtree/BSD.x11-4.dist292
-rw-r--r--etc/network.subr633
-rw-r--r--etc/rc.d/atm1193
-rw-r--r--etc/rc.d/atm2193
-rw-r--r--etc/rc.d/atm2.sh193
-rw-r--r--etc/rc.d/atm3193
-rw-r--r--etc/rc.d/atm3.sh193
-rw-r--r--etc/rc.d/diskless43
-rw-r--r--etc/rc.d/initdiskless101
-rw-r--r--etc/rc.d/isdnd62
-rw-r--r--etc/rc.d/netoptions633
-rw-r--r--etc/rc.d/network1633
-rw-r--r--etc/rc.d/network2633
-rw-r--r--etc/rc.d/network3633
-rw-r--r--etc/rc.d/network_ipv6329
-rw-r--r--etc/rc.d/pccard27
-rw-r--r--etc/rc.d/resolv43
-rw-r--r--etc/rc.d/routing633
-rw-r--r--etc/rc.d/serial127
-rw-r--r--etc/rc.d/sysctl16
-rw-r--r--etc/rc.d/tmp43
-rw-r--r--etc/rc.d/var43
-rw-r--r--etc/rc.initdiskless101
-rw-r--r--gnu/usr.bin/binutils/gdb/kvm-fbsd.c974
-rw-r--r--gnu/usr.bin/binutils/libopcodes/Makefile.amd646
-rw-r--r--gnu/usr.bin/cvs/cvs/prepend_args.c86
-rw-r--r--gnu/usr.bin/cvs/cvs/prepend_args.h26
-rw-r--r--gnu/usr.bin/cvs/lib/config.h.proto279
-rw-r--r--gnu/usr.bin/gdb/doc/inc-hist.diff24
-rw-r--r--gnu/usr.bin/groff/font/Makefile.dev33
-rw-r--r--gnu/usr.bin/groff/font/Makefile.tty55
-rw-r--r--gnu/usr.bin/groff/font/devkoi8-r/R.proto299
-rw-r--r--gnu/usr.bin/groff/src/include/defs.h9
-rw-r--r--include/_ctype.h187
-rw-r--r--include/elf-hints.h53
-rw-r--r--kerberos5/lib/libtelnet/Makefile26
-rw-r--r--kerberos5/libexec/kadmind/Makefile48
-rw-r--r--kerberos5/libexec/kpasswdd/Makefile36
-rw-r--r--kerberos5/libexec/telnetd/Makefile23
-rw-r--r--kerberos5/usr.bin/kadmin/Makefile51
-rw-r--r--kerberos5/usr.bin/kdestroy/Makefile27
-rw-r--r--kerberos5/usr.bin/kinit/Makefile27
-rw-r--r--kerberos5/usr.bin/klist/Makefile27
-rw-r--r--kerberos5/usr.bin/kpasswd/Makefile26
-rw-r--r--kerberos5/usr.bin/telnet/Makefile19
-rw-r--r--kerberos5/usr.sbin/kstash/Makefile27
-rw-r--r--lib/csu/amd64/Makefile27
-rw-r--r--lib/csu/amd64/crt1.c102
-rw-r--r--lib/csu/amd64/crti.S38
-rw-r--r--lib/csu/amd64/crtn.S32
-rw-r--r--lib/csu/common/crtbegin.c59
-rw-r--r--lib/libc/amd64/SYS.h98
-rw-r--r--lib/libc/amd64/gen/Makefile.inc5
-rw-r--r--lib/libc/amd64/gen/_setjmp.S89
-rw-r--r--lib/libc/amd64/gen/frexp.c67
-rw-r--r--lib/libc/amd64/gen/infinity.c9
-rw-r--r--lib/libc/amd64/gen/isinf.c68
-rw-r--r--lib/libc/amd64/gen/ldexp.c74
-rw-r--r--lib/libc/amd64/gen/setjmp.S116
-rw-r--r--lib/libc/amd64/gen/sigsetjmp.S127
-rw-r--r--lib/libc/amd64/net/Makefile.inc4
-rw-r--r--lib/libc/amd64/net/htonl.S53
-rw-r--r--lib/libc/amd64/net/htons.S51
-rw-r--r--lib/libc/amd64/net/ntohl.S53
-rw-r--r--lib/libc/amd64/net/ntohs.S51
-rw-r--r--lib/libc/amd64/sys/Makefile.inc28
-rw-r--r--lib/libc/amd64/sys/brk.S91
-rw-r--r--lib/libc/amd64/sys/cerror.S70
-rw-r--r--lib/libc/amd64/sys/exect.S56
-rw-r--r--lib/libc/amd64/sys/pipe.S51
-rw-r--r--lib/libc/amd64/sys/ptrace.S62
-rw-r--r--lib/libc/amd64/sys/reboot.S47
-rw-r--r--lib/libc/amd64/sys/sbrk.S95
-rw-r--r--lib/libc/amd64/sys/setlogin.S59
-rw-r--r--lib/libc/amd64/sys/sigreturn.S52
-rw-r--r--lib/libc/amd64/sys/vfork.S72
-rw-r--r--lib/libc/gen/__xuname.c125
-rw-r--r--lib/libc/gen/fts-compat.c1114
-rw-r--r--lib/libc/gen/fts-compat.h128
-rw-r--r--lib/libc/gen/pw_scan.c174
-rw-r--r--lib/libc/gen/pw_scan.h40
-rw-r--r--lib/libc/gen/sem_destroy.383
-rw-r--r--lib/libc/gen/sem_getvalue.377
-rw-r--r--lib/libc/gen/sem_init.3100
-rw-r--r--lib/libc/gen/sem_open.380
-rw-r--r--lib/libc/gen/sem_post.371
-rw-r--r--lib/libc/gen/sem_wait.392
-rw-r--r--lib/libc/gen/setflagsbyname.378
-rw-r--r--lib/libc/gen/setflagsbyname.c154
-rw-r--r--lib/libc/gen/setproctitle.3101
-rw-r--r--lib/libc/gen/setproctitle.c162
-rw-r--r--lib/libc/gen/strtofflags.378
-rw-r--r--lib/libc/gen/strtofflags.c154
-rw-r--r--lib/libc/locale/euc.5242
-rw-r--r--lib/libc/locale/utf2.588
-rw-r--r--lib/libc/posix1e/Makefile38
-rw-r--r--lib/libc/posix1e/acl.3180
-rw-r--r--lib/libc/posix1e/acl_delete.3124
-rw-r--r--lib/libc/posix1e/acl_delete.c57
-rw-r--r--lib/libc/posix1e/acl_dup.3105
-rw-r--r--lib/libc/posix1e/acl_free.389
-rw-r--r--lib/libc/posix1e/acl_free.c43
-rw-r--r--lib/libc/posix1e/acl_from_text.3125
-rw-r--r--lib/libc/posix1e/acl_from_text.c246
-rw-r--r--lib/libc/posix1e/acl_get.3138
-rw-r--r--lib/libc/posix1e/acl_get.c97
-rw-r--r--lib/libc/posix1e/acl_init.3104
-rw-r--r--lib/libc/posix1e/acl_init.c67
-rw-r--r--lib/libc/posix1e/acl_set.3131
-rw-r--r--lib/libc/posix1e/acl_set.c88
-rw-r--r--lib/libc/posix1e/acl_support.c409
-rw-r--r--lib/libc/posix1e/acl_support.h46
-rw-r--r--lib/libc/posix1e/acl_to_text.3130
-rw-r--r--lib/libc/posix1e/acl_to_text.c233
-rw-r--r--lib/libc/posix1e/acl_valid.3144
-rw-r--r--lib/libc/posix1e/acl_valid.c97
-rw-r--r--lib/libc/posix1e/posix1e.3101
-rw-r--r--lib/libc/stdlib/strtoll.c138
-rw-r--r--lib/libc/stdlib/strtoull.c116
-rw-r--r--lib/libc_r/arch/amd64/_atomic_lock.S45
-rw-r--r--lib/libkse/Makefile45
-rw-r--r--lib/libkse/sys/Makefile.inc6
-rw-r--r--lib/libkse/sys/thr_error.c51
-rw-r--r--lib/libkse/test/Makefile8
-rw-r--r--lib/libkse/thread/Makefile.inc127
-rw-r--r--lib/libkse/thread/thr_aio_suspend.c51
-rw-r--r--lib/libkse/thread/thr_attr_destroy.c61
-rw-r--r--lib/libkse/thread/thr_attr_getdetachstate.c58
-rw-r--r--lib/libkse/thread/thr_attr_getinheritsched.c51
-rw-r--r--lib/libkse/thread/thr_attr_getschedparam.c51
-rw-r--r--lib/libkse/thread/thr_attr_getschedpolicy.c51
-rw-r--r--lib/libkse/thread/thr_attr_getscope.c54
-rw-r--r--lib/libkse/thread/thr_attr_getstackaddr.c53
-rw-r--r--lib/libkse/thread/thr_attr_getstacksize.c53
-rw-r--r--lib/libkse/thread/thr_attr_init.c60
-rw-r--r--lib/libkse/thread/thr_attr_setcreatesuspend_np.c52
-rw-r--r--lib/libkse/thread/thr_attr_setdetachstate.c61
-rw-r--r--lib/libkse/thread/thr_attr_setinheritsched.c51
-rw-r--r--lib/libkse/thread/thr_attr_setschedparam.c51
-rw-r--r--lib/libkse/thread/thr_attr_setschedpolicy.c52
-rw-r--r--lib/libkse/thread/thr_attr_setscope.c63
-rw-r--r--lib/libkse/thread/thr_attr_setstackaddr.c54
-rw-r--r--lib/libkse/thread/thr_attr_setstacksize.c54
-rw-r--r--lib/libkse/thread/thr_cancel.c202
-rw-r--r--lib/libkse/thread/thr_clean.c69
-rw-r--r--lib/libkse/thread/thr_close.c114
-rw-r--r--lib/libkse/thread/thr_cond.c639
-rw-r--r--lib/libkse/thread/thr_condattr_destroy.c52
-rw-r--r--lib/libkse/thread/thr_condattr_init.c58
-rw-r--r--lib/libkse/thread/thr_creat.c48
-rw-r--r--lib/libkse/thread/thr_create.c348
-rw-r--r--lib/libkse/thread/thr_detach.c82
-rw-r--r--lib/libkse/thread/thr_equal.c44
-rw-r--r--lib/libkse/thread/thr_exit.c242
-rw-r--r--lib/libkse/thread/thr_fcntl.c170
-rw-r--r--lib/libkse/thread/thr_find_thread.c100
-rw-r--r--lib/libkse/thread/thr_fork.c225
-rw-r--r--lib/libkse/thread/thr_fsync.c62
-rw-r--r--lib/libkse/thread/thr_getprio.c56
-rw-r--r--lib/libkse/thread/thr_getschedparam.c58
-rw-r--r--lib/libkse/thread/thr_info.c311
-rw-r--r--lib/libkse/thread/thr_init.c390
-rw-r--r--lib/libkse/thread/thr_join.c125
-rw-r--r--lib/libkse/thread/thr_kern.c1173
-rw-r--r--lib/libkse/thread/thr_kill.c74
-rw-r--r--lib/libkse/thread/thr_mattr_init.c58
-rw-r--r--lib/libkse/thread/thr_mattr_kind_np.c79
-rw-r--r--lib/libkse/thread/thr_msync.c42
-rw-r--r--lib/libkse/thread/thr_multi_np.c46
-rw-r--r--lib/libkse/thread/thr_mutex.c1404
-rw-r--r--lib/libkse/thread/thr_mutex_prioceiling.c110
-rw-r--r--lib/libkse/thread/thr_mutex_protocol.c69
-rw-r--r--lib/libkse/thread/thr_mutexattr_destroy.c53
-rw-r--r--lib/libkse/thread/thr_nanosleep.c134
-rw-r--r--lib/libkse/thread/thr_once.c51
-rw-r--r--lib/libkse/thread/thr_open.c96
-rw-r--r--lib/libkse/thread/thr_pause.c48
-rw-r--r--lib/libkse/thread/thr_poll.c101
-rw-r--r--lib/libkse/thread/thr_priority_queue.c335
-rw-r--r--lib/libkse/thread/thr_private.h1254
-rw-r--r--lib/libkse/thread/thr_read.c110
-rw-r--r--lib/libkse/thread/thr_readv.c95
-rw-r--r--lib/libkse/thread/thr_resume_np.c67
-rw-r--r--lib/libkse/thread/thr_rwlock.c335
-rw-r--r--lib/libkse/thread/thr_rwlockattr.c95
-rw-r--r--lib/libkse/thread/thr_select.c208
-rw-r--r--lib/libkse/thread/thr_self.c44
-rw-r--r--lib/libkse/thread/thr_sem.c244
-rw-r--r--lib/libkse/thread/thr_seterrno.c61
-rw-r--r--lib/libkse/thread/thr_setprio.c52
-rw-r--r--lib/libkse/thread/thr_setschedparam.c114
-rw-r--r--lib/libkse/thread/thr_sig.c759
-rw-r--r--lib/libkse/thread/thr_sigaction.c110
-rw-r--r--lib/libkse/thread/thr_sigmask.c93
-rw-r--r--lib/libkse/thread/thr_sigpending.c58
-rw-r--r--lib/libkse/thread/thr_sigprocmask.c94
-rw-r--r--lib/libkse/thread/thr_sigsuspend.c82
-rw-r--r--lib/libkse/thread/thr_sigwait.c150
-rw-r--r--lib/libkse/thread/thr_single_np.c45
-rw-r--r--lib/libkse/thread/thr_sleep.c48
-rw-r--r--lib/libkse/thread/thr_spec.c200
-rw-r--r--lib/libkse/thread/thr_spinlock.c106
-rw-r--r--lib/libkse/thread/thr_suspend_np.c72
-rw-r--r--lib/libkse/thread/thr_switch_np.c70
-rw-r--r--lib/libkse/thread/thr_system.c48
-rw-r--r--lib/libkse/thread/thr_tcdrain.c48
-rw-r--r--lib/libkse/thread/thr_vfork.c9
-rw-r--r--lib/libkse/thread/thr_wait.c47
-rw-r--r--lib/libkse/thread/thr_wait4.c69
-rw-r--r--lib/libkse/thread/thr_waitpid.c49
-rw-r--r--lib/libkse/thread/thr_write.c146
-rw-r--r--lib/libkse/thread/thr_writev.c205
-rw-r--r--lib/libkse/thread/thr_yield.c64
-rw-r--r--lib/libkvm/kvm_amd64.c198
-rw-r--r--lib/libopie/config.h379
-rw-r--r--lib/libpam/libpam/security/pam_mod_misc.h48
-rw-r--r--lib/libpam/modules/pam_login_access/login.access.556
-rw-r--r--lib/libpam/modules/pam_login_access/login_access.c239
-rw-r--r--lib/libpam/modules/pam_ssh/pam_ssh.c489
-rw-r--r--lib/libpthread/Makefile45
-rw-r--r--lib/libpthread/arch/alpha/alpha/_atomic_lock.S45
-rw-r--r--lib/libpthread/arch/i386/i386/_atomic_lock.S45
-rw-r--r--lib/libpthread/man/Makefile.inc55
-rw-r--r--lib/libpthread/man/pthread_cancel.378
-rw-r--r--lib/libpthread/man/pthread_cleanup_pop.363
-rw-r--r--lib/libpthread/man/pthread_cleanup_push.365
-rw-r--r--lib/libpthread/man/pthread_cond_broadcast.370
-rw-r--r--lib/libpthread/man/pthread_cond_destroy.374
-rw-r--r--lib/libpthread/man/pthread_cond_init.379
-rw-r--r--lib/libpthread/man/pthread_cond_signal.370
-rw-r--r--lib/libpthread/man/pthread_cond_timedwait.389
-rw-r--r--lib/libpthread/man/pthread_cond_wait.382
-rw-r--r--lib/libpthread/man/pthread_create.3121
-rw-r--r--lib/libpthread/man/pthread_detach.389
-rw-r--r--lib/libpthread/man/pthread_equal.368
-rw-r--r--lib/libpthread/man/pthread_exit.3105
-rw-r--r--lib/libpthread/man/pthread_getspecific.382
-rw-r--r--lib/libpthread/man/pthread_join.3105
-rw-r--r--lib/libpthread/man/pthread_key_create.3107
-rw-r--r--lib/libpthread/man/pthread_key_delete.398
-rw-r--r--lib/libpthread/man/pthread_mutex_destroy.372
-rw-r--r--lib/libpthread/man/pthread_mutex_init.377
-rw-r--r--lib/libpthread/man/pthread_mutex_lock.374
-rw-r--r--lib/libpthread/man/pthread_mutex_trylock.375
-rw-r--r--lib/libpthread/man/pthread_mutex_unlock.374
-rw-r--r--lib/libpthread/man/pthread_once.3106
-rw-r--r--lib/libpthread/man/pthread_rwlock_destroy.380
-rw-r--r--lib/libpthread/man/pthread_rwlock_init.399
-rw-r--r--lib/libpthread/man/pthread_rwlock_rdlock.3122
-rw-r--r--lib/libpthread/man/pthread_rwlock_unlock.379
-rw-r--r--lib/libpthread/man/pthread_rwlock_wrlock.3102
-rw-r--r--lib/libpthread/man/pthread_rwlockattr_destroy.368
-rw-r--r--lib/libpthread/man/pthread_rwlockattr_getpshared.380
-rw-r--r--lib/libpthread/man/pthread_rwlockattr_init.367
-rw-r--r--lib/libpthread/man/pthread_rwlockattr_setpshared.386
-rw-r--r--lib/libpthread/man/pthread_self.361
-rw-r--r--lib/libpthread/man/pthread_setspecific.395
-rw-r--r--lib/libpthread/man/pthread_testcancel.3197
-rw-r--r--lib/libpthread/man/sem_destroy.383
-rw-r--r--lib/libpthread/man/sem_getvalue.377
-rw-r--r--lib/libpthread/man/sem_init.3100
-rw-r--r--lib/libpthread/man/sem_open.380
-rw-r--r--lib/libpthread/man/sem_post.371
-rw-r--r--lib/libpthread/man/sem_wait.392
-rw-r--r--lib/libpthread/sys/Makefile.inc6
-rw-r--r--lib/libpthread/sys/thr_error.c51
-rw-r--r--lib/libpthread/test/Makefile8
-rw-r--r--lib/libpthread/thread/Makefile.inc127
-rw-r--r--lib/libpthread/thread/thr_aio_suspend.c51
-rw-r--r--lib/libpthread/thread/thr_attr_destroy.c61
-rw-r--r--lib/libpthread/thread/thr_attr_getdetachstate.c58
-rw-r--r--lib/libpthread/thread/thr_attr_getinheritsched.c51
-rw-r--r--lib/libpthread/thread/thr_attr_getschedparam.c51
-rw-r--r--lib/libpthread/thread/thr_attr_getschedpolicy.c51
-rw-r--r--lib/libpthread/thread/thr_attr_getscope.c54
-rw-r--r--lib/libpthread/thread/thr_attr_getstackaddr.c53
-rw-r--r--lib/libpthread/thread/thr_attr_getstacksize.c53
-rw-r--r--lib/libpthread/thread/thr_attr_init.c60
-rw-r--r--lib/libpthread/thread/thr_attr_setcreatesuspend_np.c52
-rw-r--r--lib/libpthread/thread/thr_attr_setdetachstate.c61
-rw-r--r--lib/libpthread/thread/thr_attr_setinheritsched.c51
-rw-r--r--lib/libpthread/thread/thr_attr_setschedparam.c51
-rw-r--r--lib/libpthread/thread/thr_attr_setschedpolicy.c52
-rw-r--r--lib/libpthread/thread/thr_attr_setscope.c63
-rw-r--r--lib/libpthread/thread/thr_attr_setstackaddr.c54
-rw-r--r--lib/libpthread/thread/thr_attr_setstacksize.c54
-rw-r--r--lib/libpthread/thread/thr_cancel.c202
-rw-r--r--lib/libpthread/thread/thr_clean.c69
-rw-r--r--lib/libpthread/thread/thr_close.c114
-rw-r--r--lib/libpthread/thread/thr_cond.c639
-rw-r--r--lib/libpthread/thread/thr_condattr_destroy.c52
-rw-r--r--lib/libpthread/thread/thr_condattr_init.c58
-rw-r--r--lib/libpthread/thread/thr_creat.c48
-rw-r--r--lib/libpthread/thread/thr_create.c348
-rw-r--r--lib/libpthread/thread/thr_detach.c82
-rw-r--r--lib/libpthread/thread/thr_equal.c44
-rw-r--r--lib/libpthread/thread/thr_exit.c242
-rw-r--r--lib/libpthread/thread/thr_fcntl.c170
-rw-r--r--lib/libpthread/thread/thr_find_thread.c100
-rw-r--r--lib/libpthread/thread/thr_fork.c225
-rw-r--r--lib/libpthread/thread/thr_fsync.c62
-rw-r--r--lib/libpthread/thread/thr_gc.c252
-rw-r--r--lib/libpthread/thread/thr_getprio.c56
-rw-r--r--lib/libpthread/thread/thr_getschedparam.c58
-rw-r--r--lib/libpthread/thread/thr_info.c311
-rw-r--r--lib/libpthread/thread/thr_init.c390
-rw-r--r--lib/libpthread/thread/thr_join.c125
-rw-r--r--lib/libpthread/thread/thr_kern.c1173
-rw-r--r--lib/libpthread/thread/thr_kill.c74
-rw-r--r--lib/libpthread/thread/thr_mattr_init.c58
-rw-r--r--lib/libpthread/thread/thr_mattr_kind_np.c79
-rw-r--r--lib/libpthread/thread/thr_msync.c42
-rw-r--r--lib/libpthread/thread/thr_multi_np.c46
-rw-r--r--lib/libpthread/thread/thr_mutex.c1404
-rw-r--r--lib/libpthread/thread/thr_mutex_prioceiling.c110
-rw-r--r--lib/libpthread/thread/thr_mutex_protocol.c69
-rw-r--r--lib/libpthread/thread/thr_mutexattr_destroy.c53
-rw-r--r--lib/libpthread/thread/thr_nanosleep.c134
-rw-r--r--lib/libpthread/thread/thr_once.c51
-rw-r--r--lib/libpthread/thread/thr_open.c96
-rw-r--r--lib/libpthread/thread/thr_pause.c48
-rw-r--r--lib/libpthread/thread/thr_poll.c101
-rw-r--r--lib/libpthread/thread/thr_priority_queue.c335
-rw-r--r--lib/libpthread/thread/thr_private.h1254
-rw-r--r--lib/libpthread/thread/thr_read.c110
-rw-r--r--lib/libpthread/thread/thr_readv.c95
-rw-r--r--lib/libpthread/thread/thr_resume_np.c67
-rw-r--r--lib/libpthread/thread/thr_rwlock.c335
-rw-r--r--lib/libpthread/thread/thr_rwlockattr.c95
-rw-r--r--lib/libpthread/thread/thr_select.c208
-rw-r--r--lib/libpthread/thread/thr_self.c44
-rw-r--r--lib/libpthread/thread/thr_sem.c244
-rw-r--r--lib/libpthread/thread/thr_seterrno.c61
-rw-r--r--lib/libpthread/thread/thr_setprio.c52
-rw-r--r--lib/libpthread/thread/thr_setschedparam.c114
-rw-r--r--lib/libpthread/thread/thr_sig.c759
-rw-r--r--lib/libpthread/thread/thr_sigaction.c110
-rw-r--r--lib/libpthread/thread/thr_sigmask.c93
-rw-r--r--lib/libpthread/thread/thr_sigpending.c58
-rw-r--r--lib/libpthread/thread/thr_sigprocmask.c94
-rw-r--r--lib/libpthread/thread/thr_sigsuspend.c82
-rw-r--r--lib/libpthread/thread/thr_sigwait.c150
-rw-r--r--lib/libpthread/thread/thr_single_np.c45
-rw-r--r--lib/libpthread/thread/thr_sleep.c48
-rw-r--r--lib/libpthread/thread/thr_spec.c200
-rw-r--r--lib/libpthread/thread/thr_spinlock.c106
-rw-r--r--lib/libpthread/thread/thr_suspend_np.c72
-rw-r--r--lib/libpthread/thread/thr_switch_np.c70
-rw-r--r--lib/libpthread/thread/thr_system.c48
-rw-r--r--lib/libpthread/thread/thr_tcdrain.c48
-rw-r--r--lib/libpthread/thread/thr_vfork.c9
-rw-r--r--lib/libpthread/thread/thr_wait.c47
-rw-r--r--lib/libpthread/thread/thr_wait4.c69
-rw-r--r--lib/libpthread/thread/thr_waitpid.c49
-rw-r--r--lib/libpthread/thread/thr_write.c146
-rw-r--r--lib/libpthread/thread/thr_writev.c205
-rw-r--r--lib/libpthread/thread/thr_yield.c64
-rw-r--r--lib/libstand/gzipfs.c318
-rw-r--r--lib/libutil/pw_util.c262
-rw-r--r--lib/msun/bsdsrc/b_exp.c203
-rw-r--r--lib/msun/bsdsrc/b_log.c486
-rw-r--r--lib/msun/bsdsrc/b_tgamma.c336
-rw-r--r--lib/msun/bsdsrc/mathimpl.h98
-rw-r--r--lib/ncurses/form/Makefile20
-rw-r--r--lib/ncurses/menu/Makefile19
-rw-r--r--lib/ncurses/ncurses/Makefile534
-rw-r--r--lib/ncurses/ncurses/ncurses_cfg.h129
-rw-r--r--lib/ncurses/ncurses/pathnames.h38
-rw-r--r--lib/ncurses/ncurses/termcap.c265
-rw-r--r--lib/ncurses/panel/Makefile16
-rw-r--r--libexec/rtld-elf/alpha/lockdflt.c89
-rw-r--r--libexec/rtld-elf/amd64/Makefile.inc5
-rw-r--r--libexec/rtld-elf/amd64/elf_rtld.x131
-rw-r--r--libexec/rtld-elf/amd64/lockdflt.c89
-rw-r--r--libexec/rtld-elf/amd64/reloc.c248
-rw-r--r--libexec/rtld-elf/amd64/rtld_machdep.h44
-rw-r--r--libexec/rtld-elf/amd64/rtld_start.S88
-rw-r--r--libexec/rtld-elf/i386/lockdflt.c89
-rwxr-xr-xrelease/alpha/dokern.sh47
-rw-r--r--release/alpha/fixit_crunch.conf38
-rwxr-xr-xrelease/amd64/dokern.sh47
-rwxr-xr-xrelease/i386/dokern.sh47
-rwxr-xr-xrelease/pc98/dokern.sh47
-rw-r--r--release/picobsd/build/write_mfs_in_kernel.c96
-rwxr-xr-xrelease/scripts/base-install.sh13
-rw-r--r--sbin/bsdlabel/Makefile8
-rw-r--r--sbin/bsdlabel/bsdlabel.5543
-rw-r--r--sbin/bsdlabel/bsdlabel.8577
-rw-r--r--sbin/bsdlabel/bsdlabel.c1462
-rw-r--r--sbin/bsdlabel/dkcksum.c57
-rw-r--r--sbin/bsdlabel/pathnames.h40
-rw-r--r--sbin/camcontrol/util.c503
-rw-r--r--sbin/cxconfig/Makefile4
-rw-r--r--sbin/cxconfig/cxconfig.8324
-rw-r--r--sbin/cxconfig/cxconfig.c749
-rw-r--r--sbin/fdisk/Makefile6
-rw-r--r--sbin/fdisk/fdisk.8437
-rw-r--r--sbin/fdisk/fdisk.c1345
-rw-r--r--sbin/fsck_ffs/Makefile10
-rw-r--r--sbin/fsck_ffs/SMM.doc/0.t150
-rw-r--r--sbin/fsck_ffs/SMM.doc/1.t83
-rw-r--r--sbin/fsck_ffs/SMM.doc/2.t265
-rw-r--r--sbin/fsck_ffs/SMM.doc/3.t452
-rw-r--r--sbin/fsck_ffs/SMM.doc/4.t1424
-rw-r--r--sbin/fsck_ffs/SMM.doc/Makefile7
-rw-r--r--sbin/fsck_ffs/dir.c769
-rw-r--r--sbin/fsck_ffs/fsck.h302
-rw-r--r--sbin/fsck_ffs/fsck_ffs.8321
-rw-r--r--sbin/fsck_ffs/inode.c666
-rw-r--r--sbin/fsck_ffs/main.c417
-rw-r--r--sbin/fsck_ffs/pass1.c406
-rw-r--r--sbin/fsck_ffs/pass1b.c107
-rw-r--r--sbin/fsck_ffs/pass2.c486
-rw-r--r--sbin/fsck_ffs/pass3.c118
-rw-r--r--sbin/fsck_ffs/pass4.c145
-rw-r--r--sbin/fsck_ffs/pass5.c361
-rw-r--r--sbin/fsck_ffs/preen.c332
-rw-r--r--sbin/fsck_ffs/setup.c513
-rw-r--r--sbin/fsck_ffs/utilities.c683
-rw-r--r--sbin/fsck_ifs/Makefile10
-rw-r--r--sbin/fsck_ifs/dir.c769
-rw-r--r--sbin/fsck_ifs/fsck.h302
-rw-r--r--sbin/fsck_ifs/fsck_ifs.8321
-rw-r--r--sbin/fsck_ifs/inode.c666
-rw-r--r--sbin/fsck_ifs/main.c417
-rw-r--r--sbin/fsck_ifs/pass1.c406
-rw-r--r--sbin/fsck_ifs/pass1b.c107
-rw-r--r--sbin/fsck_ifs/pass2.c486
-rw-r--r--sbin/fsck_ifs/pass3.c118
-rw-r--r--sbin/fsck_ifs/pass4.c145
-rw-r--r--sbin/fsck_ifs/pass5.c361
-rw-r--r--sbin/fsck_ifs/preen.c332
-rw-r--r--sbin/fsck_ifs/setup.c513
-rw-r--r--sbin/fsck_ifs/utilities.c683
-rw-r--r--sbin/mount_ifs/Makefile9
-rw-r--r--sbin/mount_ifs/extern.h34
-rw-r--r--sbin/mount_ifs/getmntopts.3180
-rw-r--r--sbin/mount_ifs/getmntopts.c147
-rw-r--r--sbin/mount_ifs/mntopts.h93
-rw-r--r--sbin/mount_ifs/mount.8381
-rw-r--r--sbin/mount_ifs/mount.c745
-rw-r--r--sbin/mount_ifs/mount_ufs.c154
-rw-r--r--sbin/mount_ifs/pathnames.h38
-rw-r--r--sbin/mount_ifs/vfslist.c96
-rw-r--r--sbin/mount_msdosfs/Makefile23
-rw-r--r--sbin/mount_msdosfs/iso22dos58
-rw-r--r--sbin/mount_msdosfs/koi2dos58
-rw-r--r--sbin/mount_msdosfs/mount_msdosfs.8215
-rw-r--r--sbin/mount_msdosfs/mount_msdosfs.c339
-rw-r--r--sbin/mount_nullfs/Makefile11
-rw-r--r--sbin/mount_nullfs/mount_nullfs.8245
-rw-r--r--sbin/mount_nullfs/mount_nullfs.c148
-rw-r--r--sbin/mount_portalfs/Makefile13
-rw-r--r--sbin/mount_portalfs/activate.c214
-rw-r--r--sbin/mount_portalfs/conf.c340
-rw-r--r--sbin/mount_portalfs/mount_portalfs.8152
-rw-r--r--sbin/mount_portalfs/mount_portalfs.c295
-rw-r--r--sbin/mount_portalfs/pathnames.h44
-rw-r--r--sbin/mount_portalfs/portal.conf7
-rw-r--r--sbin/mount_portalfs/portald.h84
-rw-r--r--sbin/mount_portalfs/pt_conf.c55
-rw-r--r--sbin/mount_portalfs/pt_exec.c60
-rw-r--r--sbin/mount_portalfs/pt_file.c109
-rw-r--r--sbin/mount_portalfs/pt_tcp.c167
-rw-r--r--sbin/mount_portalfs/pt_tcplisten.c206
-rw-r--r--sbin/mount_umapfs/Makefile11
-rw-r--r--sbin/mount_umapfs/mount_umapfs.8140
-rw-r--r--sbin/mount_umapfs/mount_umapfs.c250
-rw-r--r--sbin/mount_umapfs/sample.group.mapfile2
-rw-r--r--sbin/mount_umapfs/sample.user.mapfile3
-rw-r--r--sbin/mount_umapfs/umap_manual175
-rw-r--r--sbin/mount_unionfs/Makefile11
-rw-r--r--sbin/mount_unionfs/mount_unionfs.8212
-rw-r--r--sbin/mount_unionfs/mount_unionfs.c160
-rw-r--r--sbin/nextboot/Makefile9
-rw-r--r--sbin/nextboot/nextboot.8115
-rw-r--r--sbin/nextboot/nextboot.c202
-rw-r--r--sbin/quotacheck/preen.c332
-rw-r--r--sbin/setkey/Makefile56
-rw-r--r--sbin/setkey/parse.y787
-rw-r--r--sbin/setkey/sample.cf219
-rw-r--r--sbin/setkey/scriptdump.pl54
-rw-r--r--sbin/setkey/setkey.8552
-rw-r--r--sbin/setkey/setkey.c566
-rw-r--r--sbin/setkey/test-pfkey.c480
-rw-r--r--sbin/setkey/test-policy.c161
-rw-r--r--sbin/setkey/token.l322
-rw-r--r--sbin/setkey/vchar.h35
-rw-r--r--secure/lib/libcrypto/opensslconf-amd64.h144
-rw-r--r--secure/usr.sbin/sendmail/Makefile50
-rw-r--r--share/colldef/cs_CZ.ISO8859-2.src52
-rw-r--r--share/colldef/de_DE.ISO8859-1.src39
-rw-r--r--share/colldef/de_DE.ISO8859-15.src39
-rw-r--r--share/colldef/de_DE.ISO_8859-15.src39
-rw-r--r--share/colldef/es_ES.ISO8859-1.src38
-rw-r--r--share/colldef/es_ES.ISO8859-15.src38
-rw-r--r--share/colldef/es_ES.ISO_8859-15.src38
-rw-r--r--share/colldef/is_IS.ISO8859-1.src38
-rw-r--r--share/colldef/is_IS.ISO8859-15.src38
-rw-r--r--share/colldef/is_IS.ISO_8859-15.src38
-rw-r--r--share/colldef/la_LN.ISO8859-1.src38
-rw-r--r--share/colldef/la_LN.ISO8859-15.src38
-rw-r--r--share/colldef/la_LN.ISO8859-2.src36
-rw-r--r--share/colldef/la_LN.ISO8859-4.src36
-rw-r--r--share/colldef/la_LN.ISO_8859-15.src38
-rw-r--r--share/colldef/lt_LT.ISO8859-4.src36
-rw-r--r--share/colldef/map.ISO_8859-15174
-rw-r--r--share/colldef/ru_RU.ISO8859-5.src37
-rw-r--r--share/colldef/ru_RU.ISO_8859-5.src37
-rw-r--r--share/colldef/sv_SE.ISO8859-1.src40
-rw-r--r--share/colldef/sv_SE.ISO8859-15.src40
-rw-r--r--share/colldef/sv_SE.ISO_8859-15.src40
-rw-r--r--share/examples/etc/make.conf227
-rw-r--r--share/examples/pppd/ppp.deny.sample17
-rw-r--r--share/examples/pppd/ppp.shells.sample13
-rw-r--r--share/man/man3/pthread_cancel.378
-rw-r--r--share/man/man3/pthread_cleanup_pop.363
-rw-r--r--share/man/man3/pthread_cleanup_push.365
-rw-r--r--share/man/man3/pthread_cond_broadcast.370
-rw-r--r--share/man/man3/pthread_cond_destroy.374
-rw-r--r--share/man/man3/pthread_cond_init.379
-rw-r--r--share/man/man3/pthread_cond_signal.370
-rw-r--r--share/man/man3/pthread_cond_timedwait.389
-rw-r--r--share/man/man3/pthread_cond_wait.382
-rw-r--r--share/man/man3/pthread_create.3121
-rw-r--r--share/man/man3/pthread_detach.389
-rw-r--r--share/man/man3/pthread_equal.368
-rw-r--r--share/man/man3/pthread_exit.3105
-rw-r--r--share/man/man3/pthread_getspecific.382
-rw-r--r--share/man/man3/pthread_join.3105
-rw-r--r--share/man/man3/pthread_key_create.3107
-rw-r--r--share/man/man3/pthread_key_delete.398
-rw-r--r--share/man/man3/pthread_mutex_destroy.372
-rw-r--r--share/man/man3/pthread_mutex_init.377
-rw-r--r--share/man/man3/pthread_mutex_lock.374
-rw-r--r--share/man/man3/pthread_mutex_trylock.375
-rw-r--r--share/man/man3/pthread_mutex_unlock.374
-rw-r--r--share/man/man3/pthread_once.3106
-rw-r--r--share/man/man3/pthread_rwlock_destroy.380
-rw-r--r--share/man/man3/pthread_rwlock_init.399
-rw-r--r--share/man/man3/pthread_rwlock_rdlock.3122
-rw-r--r--share/man/man3/pthread_rwlock_unlock.379
-rw-r--r--share/man/man3/pthread_rwlock_wrlock.3102
-rw-r--r--share/man/man3/pthread_rwlockattr_destroy.368
-rw-r--r--share/man/man3/pthread_rwlockattr_getpshared.380
-rw-r--r--share/man/man3/pthread_rwlockattr_init.367
-rw-r--r--share/man/man3/pthread_rwlockattr_setpshared.386
-rw-r--r--share/man/man3/pthread_self.361
-rw-r--r--share/man/man3/pthread_setspecific.395
-rw-r--r--share/man/man3/pthread_testcancel.3197
-rw-r--r--share/man/man4/bktr.4194
-rw-r--r--share/man/man4/cy.4221
-rw-r--r--share/man/man4/ed.4196
-rw-r--r--share/man/man4/ef.4103
-rw-r--r--share/man/man4/en.463
-rw-r--r--share/man/man4/netgraph.41056
-rw-r--r--share/man/man4/ng_UI.491
-rw-r--r--share/man/man4/ng_async.4169
-rw-r--r--share/man/man4/ng_bpf.4154
-rw-r--r--share/man/man4/ng_cisco.4171
-rw-r--r--share/man/man4/ng_echo.473
-rw-r--r--share/man/man4/ng_ether.4114
-rw-r--r--share/man/man4/ng_frame_relay.498
-rw-r--r--share/man/man4/ng_hole.473
-rw-r--r--share/man/man4/ng_iface.4134
-rw-r--r--share/man/man4/ng_ksocket.4187
-rw-r--r--share/man/man4/ng_lmi.4135
-rw-r--r--share/man/man4/ng_ppp.4386
-rw-r--r--share/man/man4/ng_pppoe.4404
-rw-r--r--share/man/man4/ng_pptpgre.4141
-rw-r--r--share/man/man4/ng_rfc1490.4114
-rw-r--r--share/man/man4/ng_socket.4178
-rw-r--r--share/man/man4/ng_tee.4124
-rw-r--r--share/man/man4/ng_tty.4139
-rw-r--r--share/man/man4/ng_vjc.4223
-rw-r--r--share/man/man4/snd_csa.463
-rw-r--r--share/man/man4/snd_gusc.474
-rw-r--r--share/man/man4/snd_sbc.477
-rw-r--r--share/man/man4/spkr.4237
-rw-r--r--share/man/man4/sym.4270
-rw-r--r--share/man/man4/tx.492
-rw-r--r--share/man/man5/fdescfs.5150
-rw-r--r--share/man/man8/yp.8535
-rw-r--r--share/man/man9/VOP_VPTOFH.961
-rw-r--r--share/me/orig_me.7318
-rw-r--r--share/mklocale/ja_JP.eucJP.src158
-rw-r--r--share/mklocale/ko_KR.eucKR.src119
-rw-r--r--share/mklocale/la_LN.ISO8859-1.src39
-rw-r--r--share/mklocale/la_LN.ISO8859-15.src47
-rw-r--r--share/mklocale/la_LN.ISO8859-2.src79
-rw-r--r--share/mklocale/la_LN.ISO8859-4.src79
-rw-r--r--share/mklocale/la_LN.ISO_8859-15.src47
-rw-r--r--share/mklocale/la_LN.US-ASCII.src28
-rw-r--r--share/mklocale/ru_RU.CP866.src42
-rw-r--r--share/mklocale/ru_RU.ISO8859-5.src186
-rw-r--r--share/mklocale/ru_RU.ISO_8859-5.src186
-rw-r--r--share/mklocale/ru_RU.KOI8-R.src39
-rw-r--r--share/mklocale/zh_CN.eucCN.src167
-rw-r--r--share/syscons/keymaps/pl_PL.ISO8859-2.kbd115
-rw-r--r--share/syscons/keymaps/uk.cp850-ctrl.kbd113
-rw-r--r--share/syscons/keymaps/uk.iso-ctrl.kbd113
-rw-r--r--share/timedef/cs_CZ.ISO8859-2.src104
-rw-r--r--share/timedef/da_DK.ISO8859-1.src101
-rw-r--r--share/timedef/de_AT.ISO8859-1.src101
-rw-r--r--share/timedef/de_DE.ISO8859-1.src101
-rw-r--r--share/timedef/en_GB.ISO8859-1.src101
-rw-r--r--share/timedef/en_US.ISO8859-1.src101
-rw-r--r--share/timedef/es_ES.ISO8859-1.src101
-rw-r--r--share/timedef/fi_FI.ISO8859-1.src100
-rw-r--r--share/timedef/fr_FR.ISO8859-1.src101
-rw-r--r--share/timedef/hr_HR.ISO8859-2.src101
-rw-r--r--share/timedef/hu_HU.ISO8859-2.src101
-rw-r--r--share/timedef/is_IS.ISO8859-1.src101
-rw-r--r--share/timedef/it_IT.ISO8859-1.src101
-rw-r--r--share/timedef/ja_JP.eucJP.src109
-rw-r--r--share/timedef/ko_KR.eucKR.src112
-rw-r--r--share/timedef/la_LN.ISO8859-1.src103
-rw-r--r--share/timedef/lt_LT.ISO8859-4.src100
-rw-r--r--share/timedef/nl_NL.ISO8859-1.src101
-rw-r--r--share/timedef/no_NO.ISO8859-1.src101
-rw-r--r--share/timedef/pl_PL.ISO8859-2.src98
-rw-r--r--share/timedef/pt_PT.ISO8859-1.src102
-rw-r--r--share/timedef/ru_RU.CP866.src101
-rw-r--r--share/timedef/ru_RU.ISO8859-5.src101
-rw-r--r--share/timedef/ru_RU.ISO_8859-5.src101
-rw-r--r--share/timedef/ru_RU.KOI8-R.src101
-rw-r--r--share/timedef/sl_SI.ISO8859-2.src101
-rw-r--r--share/timedef/sv_SE.ISO8859-1.src100
-rw-r--r--share/timedef/zh_CN.eucCN.src101
-rw-r--r--sys/alpha/conf/NOTES162
-rw-r--r--sys/alpha/include/_limits.h96
-rw-r--r--sys/alpha/linux/Makefile13
-rw-r--r--sys/alpha/linux/linux.h416
-rw-r--r--sys/alpha/linux/linux_dummy.c114
-rw-r--r--sys/alpha/linux/linux_genassym.c13
-rw-r--r--sys/alpha/linux/linux_ioctl.h437
-rw-r--r--sys/alpha/linux/linux_sysvec.c511
-rw-r--r--sys/alpha/linux/syscalls.master286
-rw-r--r--sys/amd64/Makefile39
-rw-r--r--sys/amd64/amd64/amd64-gdbstub.c617
-rw-r--r--sys/amd64/amd64/amd64_mem.c588
-rw-r--r--sys/amd64/amd64/apic_vector.S1061
-rw-r--r--sys/amd64/amd64/atomic.c47
-rw-r--r--sys/amd64/amd64/autoconf.c326
-rw-r--r--sys/amd64/amd64/bios.c627
-rw-r--r--sys/amd64/amd64/busdma_machdep.c663
-rw-r--r--sys/amd64/amd64/cpu_switch.S578
-rw-r--r--sys/amd64/amd64/db_disasm.c1406
-rw-r--r--sys/amd64/amd64/db_interface.c321
-rw-r--r--sys/amd64/amd64/db_trace.c338
-rw-r--r--sys/amd64/amd64/elf_machdep.c120
-rw-r--r--sys/amd64/amd64/exception.S363
-rw-r--r--sys/amd64/amd64/exception.s363
-rw-r--r--sys/amd64/amd64/fpu.c928
-rw-r--r--sys/amd64/amd64/genassym.c212
-rw-r--r--sys/amd64/amd64/identcpu.c993
-rw-r--r--sys/amd64/amd64/initcpu.c762
-rw-r--r--sys/amd64/amd64/legacy.c434
-rw-r--r--sys/amd64/amd64/locore.S1014
-rw-r--r--sys/amd64/amd64/locore.s1014
-rw-r--r--sys/amd64/amd64/machdep.c2445
-rw-r--r--sys/amd64/amd64/mem.c562
-rw-r--r--sys/amd64/amd64/mp_machdep.c2739
-rw-r--r--sys/amd64/amd64/mpboot.S317
-rw-r--r--sys/amd64/amd64/mptable.c2739
-rw-r--r--sys/amd64/amd64/nexus.c434
-rw-r--r--sys/amd64/amd64/pmap.c3514
-rw-r--r--sys/amd64/amd64/prof_machdep.c355
-rw-r--r--sys/amd64/amd64/support.S1653
-rw-r--r--sys/amd64/amd64/support.s1653
-rw-r--r--sys/amd64/amd64/swtch.s578
-rw-r--r--sys/amd64/amd64/sys_machdep.c502
-rw-r--r--sys/amd64/amd64/trap.c1152
-rw-r--r--sys/amd64/amd64/tsc.c1230
-rw-r--r--sys/amd64/amd64/vm_machdep.c648
-rw-r--r--sys/amd64/conf/GENERIC229
-rw-r--r--sys/amd64/include/apicreg.h466
-rw-r--r--sys/amd64/include/asm.h171
-rw-r--r--sys/amd64/include/asmacros.h141
-rw-r--r--sys/amd64/include/atomic.h151
-rw-r--r--sys/amd64/include/bus.h1291
-rw-r--r--sys/amd64/include/bus_amd64.h1291
-rw-r--r--sys/amd64/include/bus_at386.h1291
-rw-r--r--sys/amd64/include/bus_dma.h1291
-rw-r--r--sys/amd64/include/bus_memio.h31
-rw-r--r--sys/amd64/include/bus_pio.h31
-rw-r--r--sys/amd64/include/clock.h51
-rw-r--r--sys/amd64/include/cpu.h139
-rw-r--r--sys/amd64/include/cpufunc.h551
-rw-r--r--sys/amd64/include/cputypes.h72
-rw-r--r--sys/amd64/include/db_machdep.h91
-rw-r--r--sys/amd64/include/elf.h133
-rw-r--r--sys/amd64/include/exec.h42
-rw-r--r--sys/amd64/include/float.h72
-rw-r--r--sys/amd64/include/floatingpoint.h121
-rw-r--r--sys/amd64/include/fpu.h120
-rw-r--r--sys/amd64/include/frame.h163
-rw-r--r--sys/amd64/include/ieeefp.h101
-rw-r--r--sys/amd64/include/md_var.h101
-rw-r--r--sys/amd64/include/mptable.h2739
-rw-r--r--sys/amd64/include/npx.h120
-rw-r--r--sys/amd64/include/pc/bios.h209
-rw-r--r--sys/amd64/include/pc/display.h45
-rw-r--r--sys/amd64/include/pcb.h101
-rw-r--r--sys/amd64/include/pcb_ext.h64
-rw-r--r--sys/amd64/include/pci_cfgreg.h48
-rw-r--r--sys/amd64/include/pcpu.h94
-rw-r--r--sys/amd64/include/pmap.h267
-rw-r--r--sys/amd64/include/proc.h49
-rw-r--r--sys/amd64/include/profile.h162
-rw-r--r--sys/amd64/include/psl.h88
-rw-r--r--sys/amd64/include/ptrace.h55
-rw-r--r--sys/amd64/include/reg.h146
-rw-r--r--sys/amd64/include/reloc.h53
-rw-r--r--sys/amd64/include/resource.h44
-rw-r--r--sys/amd64/include/segments.h264
-rw-r--r--sys/amd64/include/setjmp.h46
-rw-r--r--sys/amd64/include/sigframe.h94
-rw-r--r--sys/amd64/include/signal.h126
-rw-r--r--sys/amd64/include/smp.h188
-rw-r--r--sys/amd64/include/specialreg.h342
-rw-r--r--sys/amd64/include/sysarch.h81
-rw-r--r--sys/amd64/include/trap.h107
-rw-r--r--sys/amd64/include/tss.h91
-rw-r--r--sys/amd64/include/ucontext.h65
-rw-r--r--sys/amd64/include/varargs.h67
-rw-r--r--sys/amd64/include/vmparam.h144
-rw-r--r--sys/amd64/isa/atpic_vector.S224
-rw-r--r--sys/amd64/isa/clock.c1230
-rw-r--r--sys/amd64/isa/icu.h157
-rw-r--r--sys/amd64/isa/icu_ipl.S168
-rw-r--r--sys/amd64/isa/icu_ipl.s168
-rw-r--r--sys/amd64/isa/icu_vector.S224
-rw-r--r--sys/amd64/isa/icu_vector.s224
-rw-r--r--sys/amd64/isa/intr_machdep.c850
-rw-r--r--sys/amd64/isa/intr_machdep.h213
-rw-r--r--sys/amd64/isa/isa.c159
-rw-r--r--sys/amd64/isa/isa.h200
-rw-r--r--sys/amd64/isa/isa_dma.c497
-rw-r--r--sys/amd64/isa/isa_dma.h51
-rw-r--r--sys/amd64/isa/nmi.c850
-rw-r--r--sys/amd64/isa/npx.c928
-rw-r--r--sys/amd64/isa/timerreg.h110
-rw-r--r--sys/amd64/isa/vector.S113
-rw-r--r--sys/amd64/isa/vector.s113
-rw-r--r--sys/amd64/pci/pci_bus.c544
-rw-r--r--sys/amd64/pci/pci_cfgreg.c544
-rw-r--r--sys/boot/common/loader.8753
-rw-r--r--sys/boot/i386/boot2/boot1.S259
-rw-r--r--sys/boot/i386/boot2/sio.S80
-rw-r--r--sys/boot/i386/btx/btx/btx.S1050
-rw-r--r--sys/boot/i386/btx/btxldr/btxldr.S386
-rw-r--r--sys/boot/i386/cdboot/Makefile23
-rw-r--r--sys/boot/i386/cdboot/cdboot.s259
-rw-r--r--sys/boot/i386/gptboot/Makefile81
-rw-r--r--sys/boot/i386/gptboot/gptboot.c812
-rw-r--r--sys/boot/i386/libi386/bootinfo32.c334
-rw-r--r--sys/boot/i386/libi386/bootinfo64.c334
-rw-r--r--sys/boot/i386/libi386/elf32_freebsd.c90
-rw-r--r--sys/boot/i386/libi386/elf64_freebsd.c90
-rw-r--r--sys/boot/ofw/libofw/devicename.c236
-rw-r--r--sys/boot/ofw/libofw/ofw_console.c165
-rw-r--r--sys/boot/ofw/libofw/ofw_copy.c57
-rw-r--r--sys/boot/ofw/libofw/ofw_module.c48
-rw-r--r--sys/boot/pc98/btx/btx/btx.S1154
-rw-r--r--sys/boot/pc98/btx/btxldr/btxldr.S459
-rw-r--r--sys/boot/powerpc/loader/conf.c99
-rw-r--r--sys/boot/powerpc/ofw/conf.c99
-rw-r--r--sys/compat/linux/linux_file.c893
-rw-r--r--sys/compat/linux/linux_ioctl.c1529
-rw-r--r--sys/compat/linux/linux_ioctl.h437
-rw-r--r--sys/compat/linux/linux_ipc.c490
-rw-r--r--sys/compat/linux/linux_mib.c231
-rw-r--r--sys/compat/linux/linux_mib.h43
-rw-r--r--sys/compat/linux/linux_misc.c1461
-rw-r--r--sys/compat/linux/linux_signal.c555
-rw-r--r--sys/compat/linux/linux_socket.c874
-rw-r--r--sys/compat/linux/linux_stats.c379
-rw-r--r--sys/compat/linux/linux_util.c185
-rw-r--r--sys/compat/linux/linux_util.h101
-rw-r--r--sys/compat/netbsd/dvcfg.h64
-rw-r--r--sys/compat/svr4/Makefile15
-rw-r--r--sys/compat/svr4/imgact_svr4.c235
-rw-r--r--sys/compat/svr4/svr4.h53
-rw-r--r--sys/compat/svr4/svr4_acl.h46
-rw-r--r--sys/compat/svr4/svr4_dirent.h53
-rw-r--r--sys/compat/svr4/svr4_errno.h172
-rw-r--r--sys/compat/svr4/svr4_exec.h70
-rw-r--r--sys/compat/svr4/svr4_fcntl.c716
-rw-r--r--sys/compat/svr4/svr4_fcntl.h134
-rw-r--r--sys/compat/svr4/svr4_filio.c228
-rw-r--r--sys/compat/svr4/svr4_filio.h45
-rw-r--r--sys/compat/svr4/svr4_fuser.h97
-rw-r--r--sys/compat/svr4/svr4_hrt.h87
-rw-r--r--sys/compat/svr4/svr4_ioctl.c161
-rw-r--r--sys/compat/svr4/svr4_ioctl.h62
-rw-r--r--sys/compat/svr4/svr4_ipc.c822
-rw-r--r--sys/compat/svr4/svr4_ipc.h176
-rw-r--r--sys/compat/svr4/svr4_misc.c1656
-rw-r--r--sys/compat/svr4/svr4_mman.h47
-rw-r--r--sys/compat/svr4/svr4_proto.h473
-rw-r--r--sys/compat/svr4/svr4_resource.c314
-rw-r--r--sys/compat/svr4/svr4_resource.h109
-rw-r--r--sys/compat/svr4/svr4_siginfo.h111
-rw-r--r--sys/compat/svr4/svr4_signal.c666
-rw-r--r--sys/compat/svr4/svr4_signal.h141
-rw-r--r--sys/compat/svr4/svr4_socket.c183
-rw-r--r--sys/compat/svr4/svr4_socket.h55
-rw-r--r--sys/compat/svr4/svr4_sockio.c165
-rw-r--r--sys/compat/svr4/svr4_sockio.h93
-rw-r--r--sys/compat/svr4/svr4_sockmod.h83
-rw-r--r--sys/compat/svr4/svr4_stat.c776
-rw-r--r--sys/compat/svr4/svr4_stat.h105
-rw-r--r--sys/compat/svr4/svr4_statvfs.h72
-rw-r--r--sys/compat/svr4/svr4_stream.c2258
-rw-r--r--sys/compat/svr4/svr4_stropts.h175
-rw-r--r--sys/compat/svr4/svr4_syscall.h145
-rw-r--r--sys/compat/svr4/svr4_syscallnames.c264
-rw-r--r--sys/compat/svr4/svr4_sysconfig.h62
-rw-r--r--sys/compat/svr4/svr4_sysent.c274
-rw-r--r--sys/compat/svr4/svr4_systeminfo.h50
-rw-r--r--sys/compat/svr4/svr4_sysvec.c406
-rw-r--r--sys/compat/svr4/svr4_termios.c607
-rw-r--r--sys/compat/svr4/svr4_termios.h224
-rw-r--r--sys/compat/svr4/svr4_time.h41
-rw-r--r--sys/compat/svr4/svr4_timod.h87
-rw-r--r--sys/compat/svr4/svr4_ttold.c366
-rw-r--r--sys/compat/svr4/svr4_ttold.h122
-rw-r--r--sys/compat/svr4/svr4_types.h81
-rw-r--r--sys/compat/svr4/svr4_ucontext.h74
-rw-r--r--sys/compat/svr4/svr4_ulimit.h41
-rw-r--r--sys/compat/svr4/svr4_ustat.h43
-rw-r--r--sys/compat/svr4/svr4_util.h87
-rw-r--r--sys/compat/svr4/svr4_utsname.h44
-rw-r--r--sys/compat/svr4/svr4_wait.h56
-rw-r--r--sys/compat/svr4/syscalls.conf12
-rw-r--r--sys/compat/svr4/syscalls.master366
-rw-r--r--sys/conf/Makefile.powerpc251
-rw-r--r--sys/conf/NOTES2414
-rw-r--r--sys/conf/kern.mk40
-rw-r--r--sys/conf/kmod.mk317
-rw-r--r--sys/conf/ldscript.amd64129
-rw-r--r--sys/conf/ldscript.powerpc132
-rw-r--r--sys/dev/aic7xxx/aic7xxx_93cx6.c176
-rw-r--r--sys/dev/aic7xxx/aic7xxx_93cx6.h91
-rw-r--r--sys/dev/aic7xxx/aicasm/Makefile31
-rw-r--r--sys/dev/aic7xxx/aicasm/aicasm.c720
-rw-r--r--sys/dev/aic7xxx/aicasm/aicasm.h67
-rw-r--r--sys/dev/aic7xxx/aicasm/aicasm_gram.y1410
-rw-r--r--sys/dev/aic7xxx/aicasm/aicasm_scan.l283
-rw-r--r--sys/dev/aic7xxx/aicasm/aicasm_symbol.c472
-rw-r--r--sys/dev/aic7xxx/aicasm/aicasm_symbol.h161
-rw-r--r--sys/dev/amd/amd.c2439
-rw-r--r--sys/dev/amd/amd.h579
-rw-r--r--sys/dev/ar/if_ar.c2390
-rw-r--r--sys/dev/ar/if_ar.h22
-rw-r--r--sys/dev/ar/if_ar_isa.c2390
-rw-r--r--sys/dev/ar/if_ar_pci.c117
-rw-r--r--sys/dev/ar/if_arregs.h170
-rw-r--r--sys/dev/atkbdc/atkbd.c1409
-rw-r--r--sys/dev/atkbdc/atkbd_atkbdc.c123
-rw-r--r--sys/dev/atkbdc/atkbd_isa.c123
-rw-r--r--sys/dev/atkbdc/atkbdc.c1017
-rw-r--r--sys/dev/atkbdc/atkbdc_isa.c267
-rw-r--r--sys/dev/atkbdc/atkbdc_subr.c267
-rw-r--r--sys/dev/atkbdc/atkbdcreg.h247
-rw-r--r--sys/dev/atkbdc/atkbdreg.h47
-rw-r--r--sys/dev/atkbdc/psm.c2444
-rw-r--r--sys/dev/bktr/ioctl_bt848.h282
-rw-r--r--sys/dev/bktr/ioctl_meteor.h187
-rw-r--r--sys/dev/cs/if_cs.c1388
-rw-r--r--sys/dev/cs/if_csreg.h542
-rw-r--r--sys/dev/cy/cy.c2885
-rw-r--r--sys/dev/cy/cy_isa.c2885
-rw-r--r--sys/dev/cy/cy_pci.c154
-rw-r--r--sys/dev/cy/cyreg.h75
-rw-r--r--sys/dev/dc/dcphy.c541
-rw-r--r--sys/dev/dc/if_dc.c2937
-rw-r--r--sys/dev/dc/if_dcreg.h914
-rw-r--r--sys/dev/dc/pnphy.c311
-rw-r--r--sys/dev/de/dc21040reg.h609
-rw-r--r--sys/dev/de/if_de.c5334
-rw-r--r--sys/dev/de/if_devar.h942
-rw-r--r--sys/dev/dgb/dgb.c2199
-rw-r--r--sys/dev/dgb/dgbios.h175
-rw-r--r--sys/dev/dgb/dgfep.h516
-rw-r--r--sys/dev/dgb/dgm.c2002
-rw-r--r--sys/dev/dgb/dgmbios.h2509
-rw-r--r--sys/dev/dgb/dgmfep.h1954
-rw-r--r--sys/dev/dgb/dgmreg.h422
-rw-r--r--sys/dev/dgb/dgreg.h424
-rw-r--r--sys/dev/en/if_en_pci.c439
-rw-r--r--sys/dev/fb/splash_bmp.c582
-rw-r--r--sys/dev/fb/splash_pcx.c261
-rw-r--r--sys/dev/fdc/fdc.c2390
-rw-r--r--sys/dev/fdc/fdcreg.h74
-rw-r--r--sys/dev/fe/if_fe.c4206
-rw-r--r--sys/dev/fe/if_fereg.h118
-rw-r--r--sys/dev/fe/mb86960.h338
-rw-r--r--sys/dev/fxp/if_fxp.c1997
-rw-r--r--sys/dev/fxp/if_fxpreg.h423
-rw-r--r--sys/dev/fxp/if_fxpvar.h101
-rw-r--r--sys/dev/ic/cd1400.h203
-rw-r--r--sys/dev/ic/cd180.h196
-rw-r--r--sys/dev/ic/esp.h76
-rw-r--r--sys/dev/ic/i8237.h12
-rw-r--r--sys/dev/ic/i82586.h332
-rw-r--r--sys/dev/ic/nec765.h142
-rw-r--r--sys/dev/ic/ns16550.h64
-rw-r--r--sys/dev/iicbus/iic.h47
-rw-r--r--sys/dev/isp/isp_pci.c1769
-rw-r--r--sys/dev/joy/joy.c275
-rw-r--r--sys/dev/lnc/if_lnc.c2022
-rw-r--r--sys/dev/lnc/if_lnc_pci.c100
-rw-r--r--sys/dev/lnc/if_lncreg.h172
-rw-r--r--sys/dev/lnc/if_lncvar.h215
-rw-r--r--sys/dev/mc146818/mc146818reg.h186
-rw-r--r--sys/dev/mcd/mcd.c1833
-rw-r--r--sys/dev/mcd/mcdreg.h226
-rw-r--r--sys/dev/mse/mse.c768
-rw-r--r--sys/dev/pcf/pcf.c634
-rw-r--r--sys/dev/pci/pci.c1468
-rw-r--r--sys/dev/pci/pci_if.m44
-rw-r--r--sys/dev/pci/pcireg.h260
-rw-r--r--sys/dev/pci/pcivar.h327
-rw-r--r--sys/dev/ppbus/lptio.h24
-rw-r--r--sys/dev/ppc/ppc.c2009
-rw-r--r--sys/dev/ppc/ppcreg.h238
-rw-r--r--sys/dev/ray/if_ray.c3640
-rw-r--r--sys/dev/ray/if_raymib.h673
-rw-r--r--sys/dev/ray/if_rayreg.h466
-rw-r--r--sys/dev/rc/rc.c1453
-rw-r--r--sys/dev/rc/rcreg.h72
-rw-r--r--sys/dev/rp/rp.c1985
-rw-r--r--sys/dev/rp/rpreg.h1043
-rw-r--r--sys/dev/rp/rpvar.h90
-rw-r--r--sys/dev/scd/scd.c1552
-rw-r--r--sys/dev/scd/scdreg.h151
-rw-r--r--sys/dev/sf/if_sf.c1492
-rw-r--r--sys/dev/sf/if_sfreg.h1054
-rw-r--r--sys/dev/sio/sio.c3144
-rw-r--r--sys/dev/sio/sioreg.h128
-rw-r--r--sys/dev/sk/if_sk.c1983
-rw-r--r--sys/dev/sk/if_skreg.h1172
-rw-r--r--sys/dev/sk/xmaciireg.h393
-rw-r--r--sys/dev/smbus/smb.h64
-rw-r--r--sys/dev/snp/snp.c523
-rw-r--r--sys/dev/sound/isa/sb16.c1204
-rw-r--r--sys/dev/sound/isa/sb8.c1204
-rw-r--r--sys/dev/speaker/speaker.h30
-rw-r--r--sys/dev/speaker/spkr.c596
-rw-r--r--sys/dev/sr/if_sr.c3552
-rw-r--r--sys/dev/sr/if_sr.h22
-rw-r--r--sys/dev/sr/if_sr_isa.c3552
-rw-r--r--sys/dev/sr/if_sr_pci.c129
-rw-r--r--sys/dev/sr/if_srregs.h123
-rw-r--r--sys/dev/syscons/apm/apm_saver.c91
-rw-r--r--sys/dev/syscons/blank/blank_saver.c69
-rw-r--r--sys/dev/syscons/daemon/daemon_saver.c393
-rw-r--r--sys/dev/syscons/fade/fade_saver.c105
-rw-r--r--sys/dev/syscons/fire/fire_saver.c136
-rw-r--r--sys/dev/syscons/green/green_saver.c69
-rw-r--r--sys/dev/syscons/logo/logo.c352
-rw-r--r--sys/dev/syscons/logo/logo_saver.c157
-rw-r--r--sys/dev/syscons/rain/rain_saver.c131
-rw-r--r--sys/dev/syscons/scgfbrndr.c824
-rw-r--r--sys/dev/syscons/snake/snake_saver.c148
-rw-r--r--sys/dev/syscons/star/star_saver.c135
-rw-r--r--sys/dev/syscons/warp/warp_saver.c139
-rw-r--r--sys/dev/ti/if_ti.c2510
-rw-r--r--sys/dev/ti/if_tireg.h1184
-rw-r--r--sys/dev/ti/ti_fw.h4487
-rw-r--r--sys/dev/ti/ti_fw2.h4189
-rw-r--r--sys/dev/tx/if_tx.c2069
-rw-r--r--sys/dev/tx/if_txreg.h419
-rw-r--r--sys/dev/tx/if_txvar.h419
-rw-r--r--sys/dev/usb/ohci_pci.c283
-rw-r--r--sys/dev/usb/uhci_pci.c324
-rw-r--r--sys/dev/vr/if_vr.c1663
-rw-r--r--sys/dev/vr/if_vrreg.h510
-rw-r--r--sys/dev/wi/if_wavelan_ieee.h321
-rw-r--r--sys/dev/wi/if_wi.c1599
-rw-r--r--sys/dev/wi/if_wireg.h636
-rw-r--r--sys/dev/wl/if_wl.c2673
-rw-r--r--sys/dev/wl/if_wl.h120
-rw-r--r--sys/fs/cd9660/TODO43
-rw-r--r--sys/fs/cd9660/TODO.hibler14
-rw-r--r--sys/fs/cd9660/cd9660_bmap.c105
-rw-r--r--sys/fs/cd9660/cd9660_lookup.c421
-rw-r--r--sys/fs/cd9660/cd9660_mount.h53
-rw-r--r--sys/fs/cd9660/cd9660_node.c428
-rw-r--r--sys/fs/cd9660/cd9660_node.h126
-rw-r--r--sys/fs/cd9660/cd9660_rrip.c726
-rw-r--r--sys/fs/cd9660/cd9660_rrip.h141
-rw-r--r--sys/fs/cd9660/cd9660_util.c175
-rw-r--r--sys/fs/cd9660/cd9660_vfsops.c898
-rw-r--r--sys/fs/cd9660/cd9660_vnops.c930
-rw-r--r--sys/fs/cd9660/iso.h357
-rw-r--r--sys/fs/cd9660/iso_rrip.h86
-rw-r--r--sys/fs/coda/README60
-rw-r--r--sys/fs/coda/TODO17
-rw-r--r--sys/fs/coda/cnode.h208
-rw-r--r--sys/fs/coda/coda.h761
-rw-r--r--sys/fs/coda/coda_fbsd.c190
-rw-r--r--sys/fs/coda/coda_io.h59
-rw-r--r--sys/fs/coda/coda_kernel.h66
-rw-r--r--sys/fs/coda/coda_namecache.c765
-rw-r--r--sys/fs/coda/coda_namecache.h194
-rw-r--r--sys/fs/coda/coda_opstats.h127
-rw-r--r--sys/fs/coda/coda_pioctl.h70
-rw-r--r--sys/fs/coda/coda_psdev.c679
-rw-r--r--sys/fs/coda/coda_psdev.h39
-rw-r--r--sys/fs/coda/coda_subr.c573
-rw-r--r--sys/fs/coda/coda_subr.h45
-rw-r--r--sys/fs/coda/coda_venus.c661
-rw-r--r--sys/fs/coda/coda_venus.h133
-rw-r--r--sys/fs/coda/coda_vfsops.c542
-rw-r--r--sys/fs/coda/coda_vfsops.h63
-rw-r--r--sys/fs/coda/coda_vnops.c1957
-rw-r--r--sys/fs/coda/coda_vnops.h89
-rw-r--r--sys/fs/deadfs/dead_vnops.c296
-rw-r--r--sys/fs/fdescfs/fdesc.h79
-rw-r--r--sys/fs/fdescfs/fdesc_vfsops.c234
-rw-r--r--sys/fs/fdescfs/fdesc_vnops.c874
-rw-r--r--sys/fs/fifofs/fifo.h44
-rw-r--r--sys/fs/fifofs/fifo_vnops.c536
-rw-r--r--sys/fs/msdosfs/bootsect.h113
-rw-r--r--sys/fs/msdosfs/bpb.h209
-rw-r--r--sys/fs/msdosfs/denode.h286
-rw-r--r--sys/fs/msdosfs/direntry.h143
-rw-r--r--sys/fs/msdosfs/fat.h108
-rw-r--r--sys/fs/msdosfs/msdosfs_conv.c1041
-rw-r--r--sys/fs/msdosfs/msdosfs_denode.c712
-rw-r--r--sys/fs/msdosfs/msdosfs_fat.c1101
-rw-r--r--sys/fs/msdosfs/msdosfs_lookup.c1085
-rw-r--r--sys/fs/msdosfs/msdosfs_vfsops.c986
-rw-r--r--sys/fs/msdosfs/msdosfs_vnops.c1977
-rw-r--r--sys/fs/msdosfs/msdosfsmount.h245
-rw-r--r--sys/fs/ntfs/ntfs.h336
-rw-r--r--sys/fs/ntfs/ntfs_compr.c119
-rw-r--r--sys/fs/ntfs/ntfs_compr.h35
-rw-r--r--sys/fs/ntfs/ntfs_ihash.c130
-rw-r--r--sys/fs/ntfs/ntfs_ihash.h36
-rw-r--r--sys/fs/ntfs/ntfs_inode.h120
-rw-r--r--sys/fs/ntfs/ntfs_subr.c1995
-rw-r--r--sys/fs/ntfs/ntfs_subr.h109
-rw-r--r--sys/fs/ntfs/ntfs_vfsops.c1056
-rw-r--r--sys/fs/ntfs/ntfs_vfsops.h44
-rw-r--r--sys/fs/ntfs/ntfs_vnops.c977
-rw-r--r--sys/fs/ntfs/ntfsmount.h41
-rw-r--r--sys/fs/nullfs/null.h76
-rw-r--r--sys/fs/nullfs/null_subr.c301
-rw-r--r--sys/fs/nullfs/null_vfsops.c450
-rw-r--r--sys/fs/nullfs/null_vnops.c610
-rw-r--r--sys/fs/nwfs/nwfs.h83
-rw-r--r--sys/fs/nwfs/nwfs_io.c633
-rw-r--r--sys/fs/nwfs/nwfs_ioctl.c97
-rw-r--r--sys/fs/nwfs/nwfs_mount.h80
-rw-r--r--sys/fs/nwfs/nwfs_node.c316
-rw-r--r--sys/fs/nwfs/nwfs_node.h103
-rw-r--r--sys/fs/nwfs/nwfs_subr.c666
-rw-r--r--sys/fs/nwfs/nwfs_subr.h96
-rw-r--r--sys/fs/nwfs/nwfs_vfsops.c522
-rw-r--r--sys/fs/nwfs/nwfs_vnops.c1098
-rw-r--r--sys/fs/portalfs/portal.h71
-rw-r--r--sys/fs/portalfs/portal_vfsops.c263
-rw-r--r--sys/fs/portalfs/portal_vnops.c606
-rw-r--r--sys/fs/procfs/README113
-rw-r--r--sys/fs/procfs/procfs.h162
-rw-r--r--sys/fs/procfs/procfs_ctl.c314
-rw-r--r--sys/fs/procfs/procfs_dbregs.c100
-rw-r--r--sys/fs/procfs/procfs_fpregs.c97
-rw-r--r--sys/fs/procfs/procfs_map.c184
-rw-r--r--sys/fs/procfs/procfs_mem.c316
-rw-r--r--sys/fs/procfs/procfs_note.c67
-rw-r--r--sys/fs/procfs/procfs_regs.c98
-rw-r--r--sys/fs/procfs/procfs_rlimit.c128
-rw-r--r--sys/fs/procfs/procfs_status.c229
-rw-r--r--sys/fs/procfs/procfs_subr.c402
-rw-r--r--sys/fs/procfs/procfs_type.c85
-rw-r--r--sys/fs/procfs/procfs_vfsops.c179
-rw-r--r--sys/fs/procfs/procfs_vnops.c1010
-rw-r--r--sys/fs/specfs/spec_vnops.c781
-rw-r--r--sys/fs/umapfs/umap.h91
-rw-r--r--sys/fs/umapfs/umap_subr.c404
-rw-r--r--sys/fs/umapfs/umap_vfsops.c466
-rw-r--r--sys/fs/umapfs/umap_vnops.c518
-rw-r--r--sys/fs/unionfs/union.h155
-rw-r--r--sys/fs/unionfs/union_subr.c1373
-rw-r--r--sys/fs/unionfs/union_vfsops.c509
-rw-r--r--sys/fs/unionfs/union_vnops.c1981
-rw-r--r--sys/geom/geom_ccd.c1730
-rw-r--r--sys/gnu/ext2fs/ext2_bmap.c320
-rw-r--r--sys/gnu/ext2fs/ext2_ihash.c159
-rw-r--r--sys/gnu/ext2fs/ext2_mount.h130
-rw-r--r--sys/gnu/ext2fs/inode.h161
-rw-r--r--sys/gnu/fs/ext2fs/COPYRIGHT.INFO35
-rw-r--r--sys/gnu/fs/ext2fs/ext2_alloc.c555
-rw-r--r--sys/gnu/fs/ext2fs/ext2_balloc.c313
-rw-r--r--sys/gnu/fs/ext2fs/ext2_bmap.c320
-rw-r--r--sys/gnu/fs/ext2fs/ext2_extern.h105
-rw-r--r--sys/gnu/fs/ext2fs/ext2_fs.h572
-rw-r--r--sys/gnu/fs/ext2fs/ext2_fs_sb.h81
-rw-r--r--sys/gnu/fs/ext2fs/ext2_inode.c493
-rw-r--r--sys/gnu/fs/ext2fs/ext2_inode_cnv.c160
-rw-r--r--sys/gnu/fs/ext2fs/ext2_linux_balloc.c582
-rw-r--r--sys/gnu/fs/ext2fs/ext2_linux_ialloc.c511
-rw-r--r--sys/gnu/fs/ext2fs/ext2_lookup.c1069
-rw-r--r--sys/gnu/fs/ext2fs/ext2_mount.h130
-rw-r--r--sys/gnu/fs/ext2fs/ext2_readwrite.c297
-rw-r--r--sys/gnu/fs/ext2fs/ext2_subr.c127
-rw-r--r--sys/gnu/fs/ext2fs/ext2_vfsops.c1197
-rw-r--r--sys/gnu/fs/ext2fs/ext2_vnops.c1213
-rw-r--r--sys/gnu/fs/ext2fs/fs.h183
-rw-r--r--sys/gnu/fs/ext2fs/i386-bitops.h162
-rw-r--r--sys/gnu/fs/ext2fs/inode.h161
-rw-r--r--sys/i386/bios/apm.c1358
-rw-r--r--sys/i386/bios/apm.h43
-rw-r--r--sys/i386/conf/NOTES2414
-rw-r--r--sys/i386/i386/apic_vector.s1061
-rw-r--r--sys/i386/i386/legacy.c434
-rw-r--r--sys/i386/i386/mptable.c2739
-rw-r--r--sys/i386/i386/tsc.c1230
-rw-r--r--sys/i386/include/_limits.h93
-rw-r--r--sys/i386/include/apicreg.h466
-rw-r--r--sys/i386/include/bus_at386.h1291
-rw-r--r--sys/i386/include/bus_dma.h1291
-rw-r--r--sys/i386/include/bus_pc98.h1291
-rw-r--r--sys/i386/include/mptable.h2739
-rw-r--r--sys/i386/include/pci_cfgreg.h48
-rw-r--r--sys/i386/include/pcpu.h94
-rw-r--r--sys/i386/isa/atpic_vector.s224
-rw-r--r--sys/i386/isa/nmi.c850
-rw-r--r--sys/i386/pci/pci_bus.c544
-rw-r--r--sys/i386/pci/pci_cfgreg.c544
-rw-r--r--sys/i386/pci/pci_pir.c544
-rw-r--r--sys/i4b/include/i4b_cause.h148
-rw-r--r--sys/i4b/include/i4b_debug.h276
-rw-r--r--sys/i4b/include/i4b_ioctl.h672
-rw-r--r--sys/i4b/include/i4b_rbch_ioctl.h55
-rw-r--r--sys/i4b/include/i4b_tel_ioctl.h81
-rw-r--r--sys/i4b/include/i4b_trace.h93
-rw-r--r--sys/isa/atrtc.c1230
-rw-r--r--sys/kern/kern_random.c378
-rw-r--r--sys/kern/kern_tc.c1004
-rw-r--r--sys/kern/ksched.c264
-rw-r--r--sys/kern/link_elf_obj.c985
-rw-r--r--sys/kern/p1003_1b.c260
-rw-r--r--sys/kern/posix4_mib.c98
-rw-r--r--sys/kern/subr_acl_posix1e.c277
-rw-r--r--sys/kern/subr_clist.c696
-rw-r--r--sys/kern/subr_disklabel.c408
-rw-r--r--sys/kern/subr_param.c176
-rw-r--r--sys/kern/subr_smp.c2739
-rw-r--r--sys/kern/subr_trap.c1152
-rw-r--r--sys/kern/uipc_sockbuf.c1006
-rw-r--r--sys/kern/vfs_acl.c277
-rw-r--r--sys/kern/vfs_export.c2974
-rw-r--r--sys/kern/vfs_extattr.c3564
-rw-r--r--sys/kern/vfs_mount.c366
-rw-r--r--sys/libkern/fnmatch.c231
-rw-r--r--sys/libkern/strlcat.c71
-rw-r--r--sys/libkern/strlcpy.c68
-rw-r--r--sys/libkern/strsep.c80
-rw-r--r--sys/modules/fdescfs/Makefile10
-rw-r--r--sys/modules/msdosfs/Makefile10
-rw-r--r--sys/modules/netgraph/UI/ng_UI.491
-rw-r--r--sys/modules/netgraph/async/ng_async.4169
-rw-r--r--sys/modules/netgraph/bpf/ng_bpf.4154
-rw-r--r--sys/modules/netgraph/cisco/ng_cisco.4171
-rw-r--r--sys/modules/netgraph/echo/ng_echo.473
-rw-r--r--sys/modules/netgraph/frame_relay/ng_frame_relay.498
-rw-r--r--sys/modules/netgraph/hole/ng_hole.473
-rw-r--r--sys/modules/netgraph/iface/ng_iface.4134
-rw-r--r--sys/modules/netgraph/ksocket/ng_ksocket.4187
-rw-r--r--sys/modules/netgraph/lmi/ng_lmi.4135
-rw-r--r--sys/modules/netgraph/ppp/ng_ppp.4386
-rw-r--r--sys/modules/netgraph/pppoe/ng_pppoe.4404
-rw-r--r--sys/modules/netgraph/pptpgre/ng_pptpgre.4141
-rw-r--r--sys/modules/netgraph/rfc1490/ng_rfc1490.4114
-rw-r--r--sys/modules/netgraph/socket/ng_socket.4178
-rw-r--r--sys/modules/netgraph/tee/ng_tee.4124
-rw-r--r--sys/modules/netgraph/tty/ng_tty.4139
-rw-r--r--sys/modules/netgraph/vjc/ng_vjc.4223
-rw-r--r--sys/modules/nfsclient/Makefile18
-rw-r--r--sys/modules/nfsserver/Makefile18
-rw-r--r--sys/modules/portalfs/Makefile9
-rw-r--r--sys/modules/unionfs/Makefile9
-rw-r--r--sys/net/fddi.h87
-rw-r--r--sys/netatalk/ddp_pcb.c585
-rw-r--r--sys/netinet/libalias/HISTORY134
-rw-r--r--sys/netinet/libalias/Makefile12
-rw-r--r--sys/netinet/libalias/alias.c1335
-rw-r--r--sys/netinet/libalias/alias.h166
-rw-r--r--sys/netinet/libalias/alias_cuseeme.c120
-rw-r--r--sys/netinet/libalias/alias_db.c2394
-rw-r--r--sys/netinet/libalias/alias_ftp.c231
-rw-r--r--sys/netinet/libalias/alias_irc.c318
-rw-r--r--sys/netinet/libalias/alias_local.h172
-rw-r--r--sys/netinet/libalias/alias_nbt.c711
-rw-r--r--sys/netinet/libalias/alias_proxy.c807
-rw-r--r--sys/netinet/libalias/alias_util.c141
-rw-r--r--sys/netinet/libalias/libalias.3890
-rw-r--r--sys/netinet/tcp_reass.c2782
-rw-r--r--sys/netinet/tcp_timewait.c1303
-rw-r--r--sys/nfs/nfs_common.c2229
-rw-r--r--sys/nfs/nfs_common.h564
-rw-r--r--sys/nfsclient/bootp_subr.c1257
-rw-r--r--sys/nfsclient/krpc.h31
-rw-r--r--sys/nfsclient/krpc_subr.c481
-rw-r--r--sys/nfsclient/nfs.h727
-rw-r--r--sys/nfsclient/nfs_bio.c1593
-rw-r--r--sys/nfsclient/nfs_nfsiod.c1187
-rw-r--r--sys/nfsclient/nfs_node.c402
-rw-r--r--sys/nfsclient/nfs_socket.c2284
-rw-r--r--sys/nfsclient/nfs_subs.c2229
-rw-r--r--sys/nfsclient/nfs_vfsops.c1090
-rw-r--r--sys/nfsclient/nfs_vnops.c3372
-rw-r--r--sys/nfsclient/nfsargs.h727
-rw-r--r--sys/nfsclient/nfsdiskless.h124
-rw-r--r--sys/nfsclient/nfsm_subs.h564
-rw-r--r--sys/nfsclient/nfsmount.h106
-rw-r--r--sys/nfsclient/nfsnode.h210
-rw-r--r--sys/nfsclient/nfsstats.h727
-rw-r--r--sys/nfsserver/nfs.h727
-rw-r--r--sys/nfsserver/nfs_serv.c4068
-rw-r--r--sys/nfsserver/nfs_srvcache.c353
-rw-r--r--sys/nfsserver/nfs_srvsock.c2284
-rw-r--r--sys/nfsserver/nfs_srvsubs.c2229
-rw-r--r--sys/nfsserver/nfs_syscalls.c1187
-rw-r--r--sys/nfsserver/nfsm_subs.h564
-rw-r--r--sys/nfsserver/nfsproto.h439
-rw-r--r--sys/nfsserver/nfsrvcache.h91
-rw-r--r--sys/nfsserver/nfsrvstats.h727
-rw-r--r--sys/pc98/cbus/30line.h125
-rw-r--r--sys/pc98/cbus/cbus.h183
-rw-r--r--sys/pc98/cbus/cbus_dma.c568
-rw-r--r--sys/pc98/cbus/clock.c1572
-rw-r--r--sys/pc98/cbus/fdc.c2814
-rw-r--r--sys/pc98/cbus/fdcreg.h104
-rw-r--r--sys/pc98/cbus/gdc.c1081
-rw-r--r--sys/pc98/cbus/olpt.c1438
-rw-r--r--sys/pc98/cbus/pckbd.c931
-rw-r--r--sys/pc98/cbus/pcrtc.c1572
-rw-r--r--sys/pc98/cbus/ppc.c2065
-rw-r--r--sys/pc98/cbus/ppcreg.h246
-rw-r--r--sys/pc98/cbus/sc_machdep.h61
-rw-r--r--sys/pc98/cbus/scgdcrndr.c203
-rw-r--r--sys/pc98/cbus/scterm-sck.c1095
-rw-r--r--sys/pc98/cbus/scvtb.c409
-rw-r--r--sys/pc98/cbus/sio.c5162
-rw-r--r--sys/pc98/cbus/syscons_cbus.c217
-rw-r--r--sys/pc98/conf/GENERIC313
-rw-r--r--sys/pc98/pc98/atapi.h294
-rw-r--r--sys/pc98/pc98/machdep.c2676
-rw-r--r--sys/pc98/pc98/wd_cd.c1479
-rw-r--r--sys/pc98/pc98/wfd.c727
-rw-r--r--sys/pc98/pc98/wst.c774
-rw-r--r--sys/pccard/pcic_pci.c273
-rw-r--r--sys/pccard/pcic_pci.h71
-rw-r--r--sys/powerpc/aim/vm_machdep.c489
-rw-r--r--sys/powerpc/include/_limits.h93
-rw-r--r--sys/powerpc/include/bootinfo.h86
-rw-r--r--sys/powerpc/include/clock.h25
-rw-r--r--sys/powerpc/include/limits.h93
-rw-r--r--sys/powerpc/include/md_var.h69
-rw-r--r--sys/powerpc/include/ptrace.h55
-rw-r--r--sys/powerpc/include/resource.h44
-rw-r--r--sys/powerpc/include/sigframe.h45
-rw-r--r--sys/powerpc/powerpc/elf_machdep.c123
-rw-r--r--sys/powerpc/powerpc/genassym.c156
-rw-r--r--sys/powerpc/powerpc/procfs_machdep.c152
-rw-r--r--sys/powerpc/powerpc/vm_machdep.c489
-rw-r--r--sys/rpc/types.h62
-rw-r--r--sys/sys/_sigset.h300
-rw-r--r--sys/sys/bio.h517
-rw-r--r--sys/sys/bitstring.h143
-rw-r--r--sys/sys/bus_dma.h1291
-rw-r--r--sys/sys/diskmbr.h467
-rw-r--r--sys/sys/diskpc98.h467
-rw-r--r--sys/sys/fdcio.h125
-rw-r--r--sys/sys/ioctl_bt848.h282
-rw-r--r--sys/sys/ioctl_meteor.h187
-rw-r--r--sys/sys/linedisc.h291
-rw-r--r--sys/sys/lockmgr.h214
-rw-r--r--sys/sys/mdioctl.h79
-rw-r--r--sys/sys/mouse.h295
-rw-r--r--sys/sys/posix4.h116
-rw-r--r--sys/sys/random.h90
-rw-r--r--sys/sys/selinfo.h57
-rw-r--r--sys/sys/semaphore.h72
-rw-r--r--sys/sys/smp.h188
-rw-r--r--sys/sys/timetc.h306
-rw-r--r--sys/tools/devlist2h.awk147
-rw-r--r--sys/tools/miidevs2h.awk147
-rw-r--r--sys/tools/pccarddevs2h.awk226
-rw-r--r--sys/tools/usbdevs2h.awk236
-rw-r--r--sys/tools/vnode_if.awk354
-rw-r--r--tools/regression/usr.bin/sed/hanoi.sed102
-rw-r--r--tools/regression/usr.bin/sed/math.sed163
-rw-r--r--tools/regression/usr.bin/sed/multitest.t552
-rw-r--r--tools/regression/usr.bin/sed/sed.test552
-rw-r--r--usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.all17
-rw-r--r--usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.feiertag42
-rw-r--r--usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.geschichte197
-rw-r--r--usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.kirche32
-rw-r--r--usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.literatur36
-rw-r--r--usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.musik25
-rw-r--r--usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.wissenschaft19
-rw-r--r--usr.bin/calendar/calendars/hr_HR.ISO8859-2/calendar.all12
-rw-r--r--usr.bin/calendar/calendars/hr_HR.ISO8859-2/calendar.praznici37
-rw-r--r--usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.all15
-rw-r--r--usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.common24
-rw-r--r--usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.msk16
-rw-r--r--usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.orthodox34
-rw-r--r--usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.pagan42
-rw-r--r--usr.bin/ee/nls/de_DE.ISO8859-1/ee.msg182
-rw-r--r--usr.bin/ee/nls/en_US.US-ASCII/ee.msg182
-rw-r--r--usr.bin/ee/nls/fr_FR.ISO8859-1/ee.msg182
-rw-r--r--usr.bin/ee/nls/pl_PL.ISO8859-2/ee.msg184
-rw-r--r--usr.bin/gcore/aoutcore.c342
-rw-r--r--usr.bin/gprof/amd64.c11
-rw-r--r--usr.bin/gprof/amd64.h44
-rw-r--r--usr.bin/m4/TEST/ack.m42
-rw-r--r--usr.bin/m4/TEST/hanoi.m42
-rw-r--r--usr.bin/m4/TEST/hash.m42
-rw-r--r--usr.bin/m4/TEST/sqroot.m42
-rw-r--r--usr.bin/m4/TEST/string.m42
-rw-r--r--usr.bin/m4/TEST/test.m42
-rw-r--r--usr.bin/m4/pathnames.h7
-rw-r--r--usr.bin/makewhatis/makewhatis.local.880
-rw-r--r--usr.bin/truss/amd64-fbsd32.c311
-rw-r--r--usr.bin/truss/amd64-linux32.c252
-rw-r--r--usr.bin/window/mystring.h65
-rw-r--r--usr.sbin/mount_nwfs/Makefile15
-rw-r--r--usr.sbin/mount_nwfs/mount_nwfs.8224
-rw-r--r--usr.sbin/mount_nwfs/mount_nwfs.c358
-rw-r--r--usr.sbin/mount_portalfs/Makefile13
-rw-r--r--usr.sbin/mount_portalfs/activate.c214
-rw-r--r--usr.sbin/mount_portalfs/conf.c340
-rw-r--r--usr.sbin/mount_portalfs/mount_portalfs.8152
-rw-r--r--usr.sbin/mount_portalfs/mount_portalfs.c295
-rw-r--r--usr.sbin/mount_portalfs/pathnames.h44
-rw-r--r--usr.sbin/mount_portalfs/portal.conf7
-rw-r--r--usr.sbin/mount_portalfs/portald.h84
-rw-r--r--usr.sbin/mount_portalfs/pt_conf.c55
-rw-r--r--usr.sbin/mount_portalfs/pt_exec.c60
-rw-r--r--usr.sbin/mount_portalfs/pt_file.c109
-rw-r--r--usr.sbin/mount_portalfs/pt_tcp.c167
-rw-r--r--usr.sbin/mount_portalfs/pt_tcplisten.c206
-rw-r--r--usr.sbin/mountd/Makefile9
-rw-r--r--usr.sbin/mountd/exports.5297
-rw-r--r--usr.sbin/mountd/mountd.8147
-rw-r--r--usr.sbin/mountd/mountd.c2136
-rw-r--r--usr.sbin/mountd/netgroup.5194
-rw-r--r--usr.sbin/mountd/pathnames.h39
-rw-r--r--usr.sbin/nfsd/Makefile17
-rw-r--r--usr.sbin/nfsd/nfsd.8165
-rw-r--r--usr.sbin/nfsd/nfsd.c713
-rw-r--r--usr.sbin/nologin/Makefile12
-rw-r--r--usr.sbin/nologin/nologin.566
-rw-r--r--usr.sbin/nologin/nologin.856
-rw-r--r--usr.sbin/nologin/nologin.sh39
-rw-r--r--usr.sbin/ppp/README.nat352
-rw-r--r--usr.sbin/ppp/ppp.8.m44886
-rw-r--r--usr.sbin/sade/Makefile87
-rw-r--r--usr.sbin/sade/command.c179
-rw-r--r--usr.sbin/sade/config.c880
-rw-r--r--usr.sbin/sade/devices.c560
-rw-r--r--usr.sbin/sade/disks.c774
-rw-r--r--usr.sbin/sade/dispatch.c434
-rw-r--r--usr.sbin/sade/dmenu.c316
-rw-r--r--usr.sbin/sade/globals.c73
-rw-r--r--usr.sbin/sade/help/partition.hlp118
-rw-r--r--usr.sbin/sade/help/slice.hlp59
-rw-r--r--usr.sbin/sade/install.c1140
-rw-r--r--usr.sbin/sade/keymap.c95
-rw-r--r--usr.sbin/sade/label.c1298
-rw-r--r--usr.sbin/sade/list.h60
-rw-r--r--usr.sbin/sade/main.c145
-rw-r--r--usr.sbin/sade/menus.c1630
-rw-r--r--usr.sbin/sade/misc.c484
-rw-r--r--usr.sbin/sade/msg.c328
-rw-r--r--usr.sbin/sade/rtermcap.c15
-rw-r--r--usr.sbin/sade/sade.8861
-rw-r--r--usr.sbin/sade/sade.h752
-rw-r--r--usr.sbin/sade/system.c413
-rw-r--r--usr.sbin/sade/termcap.c135
-rw-r--r--usr.sbin/sade/variable.c227
-rw-r--r--usr.sbin/sade/wizard.c183
-rw-r--r--usr.sbin/sysinstall/Makefile87
-rw-r--r--usr.sbin/sysinstall/anonFTP.c314
-rw-r--r--usr.sbin/sysinstall/cdrom.c185
-rw-r--r--usr.sbin/sysinstall/command.c179
-rw-r--r--usr.sbin/sysinstall/config.c880
-rw-r--r--usr.sbin/sysinstall/dev2c.sh80
-rw-r--r--usr.sbin/sysinstall/devices.c560
-rw-r--r--usr.sbin/sysinstall/dhcp.c156
-rw-r--r--usr.sbin/sysinstall/disks.c774
-rw-r--r--usr.sbin/sysinstall/dispatch.c434
-rw-r--r--usr.sbin/sysinstall/dist.c947
-rw-r--r--usr.sbin/sysinstall/dist.h127
-rw-r--r--usr.sbin/sysinstall/dmenu.c316
-rw-r--r--usr.sbin/sysinstall/doc.c125
-rw-r--r--usr.sbin/sysinstall/dos.c94
-rw-r--r--usr.sbin/sysinstall/floppy.c155
-rw-r--r--usr.sbin/sysinstall/ftp.c253
-rw-r--r--usr.sbin/sysinstall/globals.c73
-rw-r--r--usr.sbin/sysinstall/help/anonftp.hlp19
-rw-r--r--usr.sbin/sysinstall/help/configure.hlp10
-rw-r--r--usr.sbin/sysinstall/help/distributions.hlp63
-rw-r--r--usr.sbin/sysinstall/help/drives.hlp92
-rw-r--r--usr.sbin/sysinstall/help/fixit.hlp7
-rw-r--r--usr.sbin/sysinstall/help/html.hlp19
-rw-r--r--usr.sbin/sysinstall/help/media.hlp51
-rw-r--r--usr.sbin/sysinstall/help/network_device.hlp58
-rw-r--r--usr.sbin/sysinstall/help/options.hlp124
-rw-r--r--usr.sbin/sysinstall/help/partition.hlp118
-rw-r--r--usr.sbin/sysinstall/help/register.hlp76
-rw-r--r--usr.sbin/sysinstall/help/shortcuts.hlp114
-rw-r--r--usr.sbin/sysinstall/help/slice.hlp59
-rw-r--r--usr.sbin/sysinstall/help/tcp.hlp34
-rw-r--r--usr.sbin/sysinstall/help/usage.hlp68
-rw-r--r--usr.sbin/sysinstall/help/usermgmt.hlp89
-rw-r--r--usr.sbin/sysinstall/http.c180
-rw-r--r--usr.sbin/sysinstall/index.c756
-rw-r--r--usr.sbin/sysinstall/install.c1140
-rw-r--r--usr.sbin/sysinstall/install.cfg96
-rw-r--r--usr.sbin/sysinstall/installUpgrade.c492
-rw-r--r--usr.sbin/sysinstall/keymap.c95
-rw-r--r--usr.sbin/sysinstall/kget.c125
-rw-r--r--usr.sbin/sysinstall/label.c1298
-rw-r--r--usr.sbin/sysinstall/list.h60
-rw-r--r--usr.sbin/sysinstall/main.c145
-rw-r--r--usr.sbin/sysinstall/media.c834
-rw-r--r--usr.sbin/sysinstall/menus.c1630
-rw-r--r--usr.sbin/sysinstall/misc.c484
-rw-r--r--usr.sbin/sysinstall/mouse.c83
-rw-r--r--usr.sbin/sysinstall/msg.c328
-rw-r--r--usr.sbin/sysinstall/network.c353
-rw-r--r--usr.sbin/sysinstall/nfs.c96
-rw-r--r--usr.sbin/sysinstall/options.c312
-rw-r--r--usr.sbin/sysinstall/package.c251
-rw-r--r--usr.sbin/sysinstall/pccard.c174
-rw-r--r--usr.sbin/sysinstall/rtermcap.c15
-rw-r--r--usr.sbin/sysinstall/sysinstall.8861
-rw-r--r--usr.sbin/sysinstall/sysinstall.h752
-rw-r--r--usr.sbin/sysinstall/system.c413
-rw-r--r--usr.sbin/sysinstall/tape.c125
-rw-r--r--usr.sbin/sysinstall/tcpip.c488
-rw-r--r--usr.sbin/sysinstall/termcap.c135
-rw-r--r--usr.sbin/sysinstall/ufs.c49
-rw-r--r--usr.sbin/sysinstall/user.c727
-rw-r--r--usr.sbin/sysinstall/variable.c227
-rw-r--r--usr.sbin/sysinstall/wizard.c183
1680 files changed, 4120 insertions, 631516 deletions
diff --git a/bin/chflags/Makefile b/bin/chflags/Makefile
deleted file mode 100644
index b545bfa90f2c..000000000000
--- a/bin/chflags/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# @(#)Makefile 8.1 (Berkeley) 6/6/93
-# $FreeBSD$
-
-NOSHARED?=yes
-
-PROG= chflags
-CFLAGS+=-Wall
-.PATH: ${.CURDIR}/../../lib/libc/gen
-SRCS= chflags.c setflags.c
-
-.include <bsd.prog.mk>
diff --git a/bin/chflags/chflags.1 b/bin/chflags/chflags.1
deleted file mode 100644
index a76f8c2b6ffe..000000000000
--- a/bin/chflags/chflags.1
+++ /dev/null
@@ -1,138 +0,0 @@
-.\" Copyright (c) 1989, 1990, 1993, 1994
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" This code is derived from software contributed to Berkeley by
-.\" the Institute of Electrical and Electronics Engineers, Inc.
-.\"
-.\" 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 the University of
-.\" California, Berkeley and its contributors.
-.\" 4. 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.
-.\"
-.\" @(#)chflags.1 8.4 (Berkeley) 5/2/95
-.\" $FreeBSD$
-.\"
-.Dd May 2, 1995
-.Dt CHFLAGS 1
-.Os
-.Sh NAME
-.Nm chflags
-.Nd change file flags
-.Sh SYNOPSIS
-.Nm chflags
-.Oo
-.Fl R
-.Op Fl H | Fl L | Fl P
-.Oc
-.Ar flags
-.Ar
-.Sh DESCRIPTION
-The
-.Nm
-utility modifies the file flags of the listed files
-as specified by the
-.Ar flags
-operand.
-.Pp
-The options are as follows:
-.Bl -tag -width indent
-.It Fl H
-If the
-.Fl R
-option is specified, symbolic links on the command line are followed.
-(Symbolic links encountered in the tree traversal are not followed.)
-.It Fl L
-If the
-.Fl R
-option is specified, all symbolic links are followed.
-.It Fl P
-If the
-.Fl R
-option is specified, no symbolic links are followed.
-.It Fl R
-Change the file flags for the file hierarchies rooted
-in the files instead of just the files themselves.
-.El
-.Pp
-Flags are a comma separated list of keywords.
-The following keywords are currently defined:
-.Bd -literal -offset indent compact
-arch set the archived flag (super-user only)
-opaque set the opaque flag (owner or super-user only)
-nodump set the nodump flag (owner or super-user only)
-sappnd set the system append-only flag (super-user only)
-schg set the system immutable flag (super-user only)
-sunlnk set the system undeletable flag (super-user only)
-uappnd set the user append-only flag (owner or super-user only)
-uchg set the user immutable flag (owner or super-user only)
-uunlnk set the user undeletable flag (owner or super-user only)
-archived, sappend, schange, simmutable, uappend, uchange, uimmutable,
-sunlink, uunlink
- aliases for the above
-.Ed
-.Pp
-Putting the letters
-.Dq no
-before an option causes the flag to be turned off.
-For example:
-.Bd -literal -offset indent compact
-nouchg the immutable bit should be cleared
-.Ed
-.Pp
-Symbolic links do not have flags, so unless the
-.Fl H
-or
-.Fl L
-option is set,
-.Nm
-on a symbolic link always succeeds and has no effect.
-The
-.Fl H ,
-.Fl L
-and
-.Fl P
-options are ignored unless the
-.Fl R
-option is specified.
-In addition, these options override each other and the
-command's actions are determined by the last one specified.
-.Pp
-You can use "ls -lo" to see the flags of existing files.
-.Sh DIAGNOSTICS
-The
-.Nm
-utility exits 0 on success, and >0 if an error occurs.
-.Sh SEE ALSO
-.Xr ls 1 ,
-.Xr chflags 2 ,
-.Xr stat 2 ,
-.Xr fts 3 ,
-.Xr symlink 7
-.Sh HISTORY
-The
-.Nm
-command first appeared in
-.Bx 4.4 .
diff --git a/bin/chflags/chflags.c b/bin/chflags/chflags.c
deleted file mode 100644
index 784243e10268..000000000000
--- a/bin/chflags/chflags.c
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Copyright (c) 1992, 1993, 1994
- * 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-static const char copyright[] =
-"@(#) Copyright (c) 1992, 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)chflags.c 8.5 (Berkeley) 4/1/94";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include <err.h>
-#include <errno.h>
-#include <fts.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-extern u_long setflags __P((char **, u_long *, u_long *));
-
-void usage __P((void));
-
-int
-main(argc, argv)
- int argc;
- char *argv[];
-{
- FTS *ftsp;
- FTSENT *p;
- u_long clear, set;
- long val;
- int Hflag, Lflag, Pflag, Rflag, ch, fts_options, oct, rval;
- char *flags, *ep;
-
- Hflag = Lflag = Pflag = Rflag = 0;
- while ((ch = getopt(argc, argv, "HLPR")) != -1)
- switch (ch) {
- case 'H':
- Hflag = 1;
- Lflag = Pflag = 0;
- break;
- case 'L':
- Lflag = 1;
- Hflag = Pflag = 0;
- break;
- case 'P':
- Pflag = 1;
- Hflag = Lflag = 0;
- break;
- case 'R':
- Rflag = 1;
- break;
- case '?':
- default:
- usage();
- }
- argv += optind;
- argc -= optind;
-
- if (argc < 2)
- usage();
-
- fts_options = FTS_PHYSICAL;
- if (Rflag) {
- if (Hflag)
- fts_options |= FTS_COMFOLLOW;
- if (Lflag) {
- fts_options &= ~FTS_PHYSICAL;
- fts_options |= FTS_LOGICAL;
- }
- }
-
- flags = *argv;
- if (*flags >= '0' && *flags <= '7') {
- errno = 0;
- val = strtol(flags, &ep, 8);
- if (val < 0)
- errno = ERANGE;
- if (errno)
- err(1, "invalid flags: %s", flags);
- if (*ep)
- errx(1, "invalid flags: %s", flags);
- set = val;
- oct = 1;
- } else {
- if (setflags(&flags, &set, &clear))
- errx(1, "invalid flag: %s", flags);
- clear = ~clear;
- oct = 0;
- }
-
- if ((ftsp = fts_open(++argv, fts_options , 0)) == NULL)
- err(1, NULL);
-
- for (rval = 0; (p = fts_read(ftsp)) != NULL;) {
- switch (p->fts_info) {
- case FTS_D:
- if (Rflag) /* Change it at FTS_DP. */
- continue;
- fts_set(ftsp, p, FTS_SKIP);
- break;
- case FTS_DNR: /* Warn, chflag, continue. */
- warnx("%s: %s", p->fts_path, strerror(p->fts_errno));
- rval = 1;
- break;
- case FTS_ERR: /* Warn, continue. */
- case FTS_NS:
- warnx("%s: %s", p->fts_path, strerror(p->fts_errno));
- rval = 1;
- continue;
- case FTS_SL: /* Ignore. */
- case FTS_SLNONE:
- /*
- * The only symlinks that end up here are ones that
- * don't point to anything and ones that we found
- * doing a physical walk.
- */
- continue;
- default:
- break;
- }
- if (oct) {
- if (!chflags(p->fts_accpath, set))
- continue;
- } else {
- p->fts_statp->st_flags |= set;
- p->fts_statp->st_flags &= clear;
- if (!chflags(p->fts_accpath, p->fts_statp->st_flags))
- continue;
- }
- warn("%s", p->fts_path);
- rval = 1;
- }
- if (errno)
- err(1, "fts_read");
- exit(rval);
-}
-
-void
-usage()
-{
- (void)fprintf(stderr,
- "usage: chflags [-R [-H | -L | -P]] flags file ...\n");
- exit(1);
-}
diff --git a/contrib/binutils/bfd/VERSION b/contrib/binutils/bfd/VERSION
deleted file mode 100644
index dbe590065479..000000000000
--- a/contrib/binutils/bfd/VERSION
+++ /dev/null
@@ -1 +0,0 @@
-2.8.1
diff --git a/contrib/binutils/bfd/doc/bfd.texi b/contrib/binutils/bfd/doc/bfd.texi
deleted file mode 100644
index ea0ca9e56dc9..000000000000
--- a/contrib/binutils/bfd/doc/bfd.texi
+++ /dev/null
@@ -1,585 +0,0 @@
-@section @code{typedef bfd}
-A BFD has type @code{bfd}; objects of this type are the
-cornerstone of any application using BFD. Using BFD
-consists of making references though the BFD and to data in the BFD.
-
-Here is the structure that defines the type @code{bfd}. It
-contains the major data about the file and pointers
-to the rest of the data.
-@*
-.
-@example
-struct _bfd
-@{
- /* The filename the application opened the BFD with. */
- CONST char *filename;
-
- /* A pointer to the target jump table. */
- const struct bfd_target *xvec;
-
- /* To avoid dragging too many header files into every file that
- includes `@code{bfd.h}', IOSTREAM has been declared as a "char
- *", and MTIME as a "long". Their correct types, to which they
- are cast when used, are "FILE *" and "time_t". The iostream
- is the result of an fopen on the filename. However, if the
- BFD_IN_MEMORY flag is set, then iostream is actually a pointer
- to a bfd_in_memory struct. */
- PTR iostream;
-
- /* Is the file descriptor being cached? That is, can it be closed as
- needed, and re-opened when accessed later? */
-
- boolean cacheable;
-
- /* Marks whether there was a default target specified when the
- BFD was opened. This is used to select which matching algorithm
- to use to choose the back end. */
-
- boolean target_defaulted;
-
- /* The caching routines use these to maintain a
- least-recently-used list of BFDs */
-
- struct _bfd *lru_prev, *lru_next;
-
- /* When a file is closed by the caching routines, BFD retains
- state information on the file here: */
-
- file_ptr where;
-
- /* and here: (``once'' means at least once) */
-
- boolean opened_once;
-
- /* Set if we have a locally maintained mtime value, rather than
- getting it from the file each time: */
-
- boolean mtime_set;
-
- /* File modified time, if mtime_set is true: */
-
- long mtime;
-
- /* Reserved for an unimplemented file locking extension.*/
-
- int ifd;
-
- /* The format which belongs to the BFD. (object, core, etc.) */
-
- bfd_format format;
-
- /* The direction the BFD was opened with*/
-
- enum bfd_direction @{no_direction = 0,
- read_direction = 1,
- write_direction = 2,
- both_direction = 3@} direction;
-
- /* Format_specific flags*/
-
- flagword flags;
-
- /* Currently my_archive is tested before adding origin to
- anything. I believe that this can become always an add of
- origin, with origin set to 0 for non archive files. */
-
- file_ptr origin;
-
- /* Remember when output has begun, to stop strange things
- from happening. */
- boolean output_has_begun;
-
- /* Pointer to linked list of sections*/
- struct sec *sections;
-
- /* The number of sections */
- unsigned int section_count;
-
- /* Stuff only useful for object files:
- The start address. */
- bfd_vma start_address;
-
- /* Used for input and output*/
- unsigned int symcount;
-
- /* Symbol table for output BFD (with symcount entries) */
- struct symbol_cache_entry **outsymbols;
-
- /* Pointer to structure which contains architecture information*/
- const struct bfd_arch_info *arch_info;
-
- /* Stuff only useful for archives:*/
- PTR arelt_data;
- struct _bfd *my_archive; /* The containing archive BFD. */
- struct _bfd *next; /* The next BFD in the archive. */
- struct _bfd *archive_head; /* The first BFD in the archive. */
- boolean has_armap;
-
- /* A chain of BFD structures involved in a link. */
- struct _bfd *link_next;
-
- /* A field used by _bfd_generic_link_add_archive_symbols. This will
- be used only for archive elements. */
- int archive_pass;
-
- /* Used by the back end to hold private data. */
-
- union
- @{
- struct aout_data_struct *aout_data;
- struct artdata *aout_ar_data;
- struct _oasys_data *oasys_obj_data;
- struct _oasys_ar_data *oasys_ar_data;
- struct coff_tdata *coff_obj_data;
- struct pe_tdata *pe_obj_data;
- struct xcoff_tdata *xcoff_obj_data;
- struct ecoff_tdata *ecoff_obj_data;
- struct ieee_data_struct *ieee_data;
- struct ieee_ar_data_struct *ieee_ar_data;
- struct srec_data_struct *srec_data;
- struct ihex_data_struct *ihex_data;
- struct tekhex_data_struct *tekhex_data;
- struct elf_obj_tdata *elf_obj_data;
- struct nlm_obj_tdata *nlm_obj_data;
- struct bout_data_struct *bout_data;
- struct sun_core_struct *sun_core_data;
- struct trad_core_struct *trad_core_data;
- struct som_data_struct *som_data;
- struct hpux_core_struct *hpux_core_data;
- struct hppabsd_core_struct *hppabsd_core_data;
- struct sgi_core_struct *sgi_core_data;
- struct lynx_core_struct *lynx_core_data;
- struct osf_core_struct *osf_core_data;
- struct cisco_core_struct *cisco_core_data;
- struct versados_data_struct *versados_data;
- struct netbsd_core_struct *netbsd_core_data;
- PTR any;
- @} tdata;
-
- /* Used by the application to hold private data*/
- PTR usrdata;
-
- /* Where all the allocated stuff under this BFD goes. This is a
- struct objalloc *, but we use PTR to avoid requiring the inclusion of
- objalloc.h. */
- PTR memory;
-@};
-
-@end example
-@section Error reporting
-Most BFD functions return nonzero on success (check their
-individual documentation for precise semantics). On an error,
-they call @code{bfd_set_error} to set an error condition that callers
-can check by calling @code{bfd_get_error}.
-If that returns @code{bfd_error_system_call}, then check
-@code{errno}.
-
-The easiest way to report a BFD error to the user is to
-use @code{bfd_perror}.
-@*
-@subsection Type @code{bfd_error_type}
-The values returned by @code{bfd_get_error} are defined by the
-enumerated type @code{bfd_error_type}.
-@*
-.
-@example
-typedef enum bfd_error
-@{
- bfd_error_no_error = 0,
- bfd_error_system_call,
- bfd_error_invalid_target,
- bfd_error_wrong_format,
- bfd_error_invalid_operation,
- bfd_error_no_memory,
- bfd_error_no_symbols,
- bfd_error_no_armap,
- bfd_error_no_more_archived_files,
- bfd_error_malformed_archive,
- bfd_error_file_not_recognized,
- bfd_error_file_ambiguously_recognized,
- bfd_error_no_contents,
- bfd_error_nonrepresentable_section,
- bfd_error_no_debug_section,
- bfd_error_bad_value,
- bfd_error_file_truncated,
- bfd_error_file_too_big,
- bfd_error_invalid_error_code
-@} bfd_error_type;
-
-@end example
-@findex bfd_get_error
-@subsubsection @code{bfd_get_error}
-@strong{Synopsis}
-@example
-bfd_error_type bfd_get_error (void);
-@end example
-@strong{Description}@*
-Return the current BFD error condition.
-@*
-@findex bfd_set_error
-@subsubsection @code{bfd_set_error}
-@strong{Synopsis}
-@example
-void bfd_set_error (bfd_error_type error_tag);
-@end example
-@strong{Description}@*
-Set the BFD error condition to be @var{error_tag}.
-@*
-@findex bfd_errmsg
-@subsubsection @code{bfd_errmsg}
-@strong{Synopsis}
-@example
-CONST char *bfd_errmsg (bfd_error_type error_tag);
-@end example
-@strong{Description}@*
-Return a string describing the error @var{error_tag}, or
-the system error if @var{error_tag} is @code{bfd_error_system_call}.
-@*
-@findex bfd_perror
-@subsubsection @code{bfd_perror}
-@strong{Synopsis}
-@example
-void bfd_perror (CONST char *message);
-@end example
-@strong{Description}@*
-Print to the standard error stream a string describing the
-last BFD error that occurred, or the last system error if
-the last BFD error was a system call failure. If @var{message}
-is non-NULL and non-empty, the error string printed is preceded
-by @var{message}, a colon, and a space. It is followed by a newline.
-@*
-@subsection BFD error handler
-Some BFD functions want to print messages describing the
-problem. They call a BFD error handler function. This
-function may be overriden by the program.
-
-The BFD error handler acts like printf.
-@*
-.
-@example
-typedef void (*bfd_error_handler_type) PARAMS ((const char *, ...));
-
-@end example
-@findex bfd_set_error_handler
-@subsubsection @code{bfd_set_error_handler}
-@strong{Synopsis}
-@example
-bfd_error_handler_type bfd_set_error_handler (bfd_error_handler_type);
-@end example
-@strong{Description}@*
-Set the BFD error handler function. Returns the previous
-function.
-@*
-@findex bfd_set_error_program_name
-@subsubsection @code{bfd_set_error_program_name}
-@strong{Synopsis}
-@example
-void bfd_set_error_program_name (const char *);
-@end example
-@strong{Description}@*
-Set the program name to use when printing a BFD error. This
-is printed before the error message followed by a colon and
-space. The string must not be changed after it is passed to
-this function.
-@*
-@section Symbols
-
-@*
-@findex bfd_get_reloc_upper_bound
-@subsubsection @code{bfd_get_reloc_upper_bound}
-@strong{Synopsis}
-@example
-long bfd_get_reloc_upper_bound(bfd *abfd, asection *sect);
-@end example
-@strong{Description}@*
-Return the number of bytes required to store the
-relocation information associated with section @var{sect}
-attached to bfd @var{abfd}. If an error occurs, return -1.
-@*
-@findex bfd_canonicalize_reloc
-@subsubsection @code{bfd_canonicalize_reloc}
-@strong{Synopsis}
-@example
-long bfd_canonicalize_reloc
- (bfd *abfd,
- asection *sec,
- arelent **loc,
- asymbol **syms);
-@end example
-@strong{Description}@*
-Call the back end associated with the open BFD
-@var{abfd} and translate the external form of the relocation
-information attached to @var{sec} into the internal canonical
-form. Place the table into memory at @var{loc}, which has
-been preallocated, usually by a call to
-@code{bfd_get_reloc_upper_bound}. Returns the number of relocs, or
--1 on error.
-
-The @var{syms} table is also needed for horrible internal magic
-reasons.
-@*
-@findex bfd_set_reloc
-@subsubsection @code{bfd_set_reloc}
-@strong{Synopsis}
-@example
-void bfd_set_reloc
- (bfd *abfd, asection *sec, arelent **rel, unsigned int count)
-@end example
-@strong{Description}@*
-Set the relocation pointer and count within
-section @var{sec} to the values @var{rel} and @var{count}.
-The argument @var{abfd} is ignored.
-@*
-@findex bfd_set_file_flags
-@subsubsection @code{bfd_set_file_flags}
-@strong{Synopsis}
-@example
-boolean bfd_set_file_flags(bfd *abfd, flagword flags);
-@end example
-@strong{Description}@*
-Set the flag word in the BFD @var{abfd} to the value @var{flags}.
-
-Possible errors are:
-@itemize @bullet
-
-@item
-@code{bfd_error_wrong_format} - The target bfd was not of object format.
-@item
-@code{bfd_error_invalid_operation} - The target bfd was open for reading.
-@item
-@code{bfd_error_invalid_operation} -
-The flag word contained a bit which was not applicable to the
-type of file. E.g., an attempt was made to set the @code{D_PAGED} bit
-on a BFD format which does not support demand paging.
-@end itemize
-@*
-@findex bfd_set_start_address
-@subsubsection @code{bfd_set_start_address}
-@strong{Synopsis}
-@example
-boolean bfd_set_start_address(bfd *abfd, bfd_vma vma);
-@end example
-@strong{Description}@*
-Make @var{vma} the entry point of output BFD @var{abfd}.
-@*
-@strong{Returns}@*
-Returns @code{true} on success, @code{false} otherwise.
-@*
-@findex bfd_get_mtime
-@subsubsection @code{bfd_get_mtime}
-@strong{Synopsis}
-@example
-long bfd_get_mtime(bfd *abfd);
-@end example
-@strong{Description}@*
-Return the file modification time (as read from the file system, or
-from the archive header for archive members).
-@*
-@findex bfd_get_size
-@subsubsection @code{bfd_get_size}
-@strong{Synopsis}
-@example
-long bfd_get_size(bfd *abfd);
-@end example
-@strong{Description}@*
-Return the file size (as read from file system) for the file
-associated with BFD @var{abfd}.
-
-The initial motivation for, and use of, this routine is not
-so we can get the exact size of the object the BFD applies to, since
-that might not be generally possible (archive members for example).
-It would be ideal if someone could eventually modify
-it so that such results were guaranteed.
-
-Instead, we want to ask questions like "is this NNN byte sized
-object I'm about to try read from file offset YYY reasonable?"
-As as example of where we might do this, some object formats
-use string tables for which the first @code{sizeof(long)} bytes of the
-table contain the size of the table itself, including the size bytes.
-If an application tries to read what it thinks is one of these
-string tables, without some way to validate the size, and for
-some reason the size is wrong (byte swapping error, wrong location
-for the string table, etc.), the only clue is likely to be a read
-error when it tries to read the table, or a "virtual memory
-exhausted" error when it tries to allocate 15 bazillon bytes
-of space for the 15 bazillon byte table it is about to read.
-This function at least allows us to answer the quesion, "is the
-size reasonable?".
-@*
-@findex bfd_get_gp_size
-@subsubsection @code{bfd_get_gp_size}
-@strong{Synopsis}
-@example
-int bfd_get_gp_size(bfd *abfd);
-@end example
-@strong{Description}@*
-Return the maximum size of objects to be optimized using the GP
-register under MIPS ECOFF. This is typically set by the @code{-G}
-argument to the compiler, assembler or linker.
-@*
-@findex bfd_set_gp_size
-@subsubsection @code{bfd_set_gp_size}
-@strong{Synopsis}
-@example
-void bfd_set_gp_size(bfd *abfd, int i);
-@end example
-@strong{Description}@*
-Set the maximum size of objects to be optimized using the GP
-register under ECOFF or MIPS ELF. This is typically set by
-the @code{-G} argument to the compiler, assembler or linker.
-@*
-@findex bfd_scan_vma
-@subsubsection @code{bfd_scan_vma}
-@strong{Synopsis}
-@example
-bfd_vma bfd_scan_vma(CONST char *string, CONST char **end, int base);
-@end example
-@strong{Description}@*
-Convert, like @code{strtoul}, a numerical expression
-@var{string} into a @code{bfd_vma} integer, and return that integer.
-(Though without as many bells and whistles as @code{strtoul}.)
-The expression is assumed to be unsigned (i.e., positive).
-If given a @var{base}, it is used as the base for conversion.
-A base of 0 causes the function to interpret the string
-in hex if a leading "0x" or "0X" is found, otherwise
-in octal if a leading zero is found, otherwise in decimal.
-
-Overflow is not detected.
-@*
-@findex bfd_copy_private_bfd_data
-@subsubsection @code{bfd_copy_private_bfd_data}
-@strong{Synopsis}
-@example
-boolean bfd_copy_private_bfd_data(bfd *ibfd, bfd *obfd);
-@end example
-@strong{Description}@*
-Copy private BFD information from the BFD @var{ibfd} to the
-the BFD @var{obfd}. Return @code{true} on success, @code{false} on error.
-Possible error returns are:
-
-@itemize @bullet
-
-@item
-@code{bfd_error_no_memory} -
-Not enough memory exists to create private data for @var{obfd}.
-@end itemize
-@example
-#define bfd_copy_private_bfd_data(ibfd, obfd) \
- BFD_SEND (obfd, _bfd_copy_private_bfd_data, \
- (ibfd, obfd))
-@end example
-@*
-@findex bfd_merge_private_bfd_data
-@subsubsection @code{bfd_merge_private_bfd_data}
-@strong{Synopsis}
-@example
-boolean bfd_merge_private_bfd_data(bfd *ibfd, bfd *obfd);
-@end example
-@strong{Description}@*
-Merge private BFD information from the BFD @var{ibfd} to the
-the output file BFD @var{obfd} when linking. Return @code{true}
-on success, @code{false} on error. Possible error returns are:
-
-@itemize @bullet
-
-@item
-@code{bfd_error_no_memory} -
-Not enough memory exists to create private data for @var{obfd}.
-@end itemize
-@example
-#define bfd_merge_private_bfd_data(ibfd, obfd) \
- BFD_SEND (obfd, _bfd_merge_private_bfd_data, \
- (ibfd, obfd))
-@end example
-@*
-@findex bfd_set_private_flags
-@subsubsection @code{bfd_set_private_flags}
-@strong{Synopsis}
-@example
-boolean bfd_set_private_flags(bfd *abfd, flagword flags);
-@end example
-@strong{Description}@*
-Set private BFD flag information in the BFD @var{abfd}.
-Return @code{true} on success, @code{false} on error. Possible error
-returns are:
-
-@itemize @bullet
-
-@item
-@code{bfd_error_no_memory} -
-Not enough memory exists to create private data for @var{obfd}.
-@end itemize
-@example
-#define bfd_set_private_flags(abfd, flags) \
- BFD_SEND (abfd, _bfd_set_private_flags, \
- (abfd, flags))
-@end example
-@*
-@findex stuff
-@subsubsection @code{stuff}
-@strong{Description}@*
-Stuff which should be documented:
-@example
-#define bfd_sizeof_headers(abfd, reloc) \
- BFD_SEND (abfd, _bfd_sizeof_headers, (abfd, reloc))
-
-#define bfd_find_nearest_line(abfd, sec, syms, off, file, func, line) \
- BFD_SEND (abfd, _bfd_find_nearest_line, (abfd, sec, syms, off, file, func, line))
-
- /* Do these three do anything useful at all, for any back end? */
-#define bfd_debug_info_start(abfd) \
- BFD_SEND (abfd, _bfd_debug_info_start, (abfd))
-
-#define bfd_debug_info_end(abfd) \
- BFD_SEND (abfd, _bfd_debug_info_end, (abfd))
-
-#define bfd_debug_info_accumulate(abfd, section) \
- BFD_SEND (abfd, _bfd_debug_info_accumulate, (abfd, section))
-
-
-#define bfd_stat_arch_elt(abfd, stat) \
- BFD_SEND (abfd, _bfd_stat_arch_elt,(abfd, stat))
-
-#define bfd_update_armap_timestamp(abfd) \
- BFD_SEND (abfd, _bfd_update_armap_timestamp, (abfd))
-
-#define bfd_set_arch_mach(abfd, arch, mach)\
- BFD_SEND ( abfd, _bfd_set_arch_mach, (abfd, arch, mach))
-
-#define bfd_relax_section(abfd, section, link_info, again) \
- BFD_SEND (abfd, _bfd_relax_section, (abfd, section, link_info, again))
-
-#define bfd_link_hash_table_create(abfd) \
- BFD_SEND (abfd, _bfd_link_hash_table_create, (abfd))
-
-#define bfd_link_add_symbols(abfd, info) \
- BFD_SEND (abfd, _bfd_link_add_symbols, (abfd, info))
-
-#define bfd_final_link(abfd, info) \
- BFD_SEND (abfd, _bfd_final_link, (abfd, info))
-
-#define bfd_free_cached_info(abfd) \
- BFD_SEND (abfd, _bfd_free_cached_info, (abfd))
-
-#define bfd_get_dynamic_symtab_upper_bound(abfd) \
- BFD_SEND (abfd, _bfd_get_dynamic_symtab_upper_bound, (abfd))
-
-#define bfd_print_private_bfd_data(abfd, file)\
- BFD_SEND (abfd, _bfd_print_private_bfd_data, (abfd, file))
-
-#define bfd_canonicalize_dynamic_symtab(abfd, asymbols) \
- BFD_SEND (abfd, _bfd_canonicalize_dynamic_symtab, (abfd, asymbols))
-
-#define bfd_get_dynamic_reloc_upper_bound(abfd) \
- BFD_SEND (abfd, _bfd_get_dynamic_reloc_upper_bound, (abfd))
-
-#define bfd_canonicalize_dynamic_reloc(abfd, arels, asyms) \
- BFD_SEND (abfd, _bfd_canonicalize_dynamic_reloc, (abfd, arels, asyms))
-
-extern bfd_byte *bfd_get_relocated_section_contents
- PARAMS ((bfd *, struct bfd_link_info *,
- struct bfd_link_order *, bfd_byte *,
- boolean, asymbol **));
-
-@end example
-@*
diff --git a/contrib/binutils/gas/conf.in b/contrib/binutils/gas/conf.in
deleted file mode 100644
index d56807cd88d5..000000000000
--- a/contrib/binutils/gas/conf.in
+++ /dev/null
@@ -1,127 +0,0 @@
-/* conf.in. Generated automatically from configure.in by autoheader. */
-
-/* Define if using alloca.c. */
-#undef C_ALLOCA
-
-/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
- This function is required for alloca.c support on those systems. */
-#undef CRAY_STACKSEG_END
-
-/* Define if you have alloca, as a function or macro. */
-#undef HAVE_ALLOCA
-
-/* Define if you have <alloca.h> and it should be used (not on Ultrix). */
-#undef HAVE_ALLOCA_H
-
-/* Define as __inline if that's what the C compiler calls it. */
-#undef inline
-
-/* If using the C implementation of alloca, define if you know the
- direction of stack growth for your system; otherwise it will be
- automatically deduced at run-time.
- STACK_DIRECTION > 0 => grows toward higher addresses
- STACK_DIRECTION < 0 => grows toward lower addresses
- STACK_DIRECTION = 0 => direction of growth unknown
- */
-#undef STACK_DIRECTION
-
-/* Should gas use high-level BFD interfaces? */
-#undef BFD_ASSEMBLER
-
-/* Some assert/preprocessor combinations are incapable of handling
- certain kinds of constructs in the argument of assert. For example,
- quoted strings (if requoting isn't done right) or newlines. */
-#undef BROKEN_ASSERT
-
-/* If we aren't doing cross-assembling, some operations can be optimized,
- since byte orders and value sizes don't need to be adjusted. */
-#undef CROSS_COMPILE
-
-/* Some gas code wants to know these parameters. */
-#undef TARGET_ALIAS
-#undef TARGET_CPU
-#undef TARGET_CANONICAL
-#undef TARGET_OS
-#undef TARGET_VENDOR
-
-/* Sometimes the system header files don't declare strstr. */
-#undef NEED_DECLARATION_STRSTR
-
-/* Sometimes the system header files don't declare malloc and realloc. */
-#undef NEED_DECLARATION_MALLOC
-
-/* Sometimes the system header files don't declare free. */
-#undef NEED_DECLARATION_FREE
-
-/* Sometimes the system header files don't declare sbrk. */
-#undef NEED_DECLARATION_SBRK
-
-/* Sometimes errno.h doesn't declare errno itself. */
-#undef NEED_DECLARATION_ERRNO
-
-#undef MANY_SEGMENTS
-
-/* Needed only for sparc configuration. */
-#undef SPARC_V9
-#undef SPARC_ARCH64
-
-/* Defined if using CGEN. */
-#undef USING_CGEN
-
-/* Needed only for some configurations that can produce multiple output
- formats. */
-#undef DEFAULT_EMULATION
-#undef EMULATIONS
-#undef USE_EMULATIONS
-#undef OBJ_MAYBE_AOUT
-#undef OBJ_MAYBE_BOUT
-#undef OBJ_MAYBE_COFF
-#undef OBJ_MAYBE_ECOFF
-#undef OBJ_MAYBE_ELF
-#undef OBJ_MAYBE_GENERIC
-#undef OBJ_MAYBE_HP300
-#undef OBJ_MAYBE_IEEE
-#undef OBJ_MAYBE_SOM
-#undef OBJ_MAYBE_VMS
-
-/* Used for some of the COFF configurations, when the COFF code needs
- to select something based on the CPU type before it knows it... */
-#undef I386COFF
-#undef M68KCOFF
-#undef M88KCOFF
-
-/* Define if you have the remove function. */
-#undef HAVE_REMOVE
-
-/* Define if you have the sbrk function. */
-#undef HAVE_SBRK
-
-/* Define if you have the unlink function. */
-#undef HAVE_UNLINK
-
-/* Define if you have the <errno.h> header file. */
-#undef HAVE_ERRNO_H
-
-/* Define if you have the <memory.h> header file. */
-#undef HAVE_MEMORY_H
-
-/* Define if you have the <stdarg.h> header file. */
-#undef HAVE_STDARG_H
-
-/* Define if you have the <stdlib.h> header file. */
-#undef HAVE_STDLIB_H
-
-/* Define if you have the <string.h> header file. */
-#undef HAVE_STRING_H
-
-/* Define if you have the <strings.h> header file. */
-#undef HAVE_STRINGS_H
-
-/* Define if you have the <sys/types.h> header file. */
-#undef HAVE_SYS_TYPES_H
-
-/* Define if you have the <unistd.h> header file. */
-#undef HAVE_UNISTD_H
-
-/* Define if you have the <varargs.h> header file. */
-#undef HAVE_VARARGS_H
diff --git a/contrib/binutils/gas/config/i386coff.mt b/contrib/binutils/gas/config/i386coff.mt
deleted file mode 100644
index efda83365181..000000000000
--- a/contrib/binutils/gas/config/i386coff.mt
+++ /dev/null
@@ -1 +0,0 @@
-TDEFINES=-DI386COFF
diff --git a/contrib/binutils/gas/config/sco5.mt b/contrib/binutils/gas/config/sco5.mt
deleted file mode 100644
index 8879320c4e1e..000000000000
--- a/contrib/binutils/gas/config/sco5.mt
+++ /dev/null
@@ -1 +0,0 @@
-TDEFINES=-DSCO_ELF
diff --git a/contrib/binutils/install.sh b/contrib/binutils/install.sh
deleted file mode 100755
index 4b883b386de2..000000000000
--- a/contrib/binutils/install.sh
+++ /dev/null
@@ -1,247 +0,0 @@
-#!/bin/sh
-#
-# install - install a program, script, or datafile
-# This comes from X11R5 (mit/util/scripts/install.sh).
-#
-# Copyright 1991 by the Massachusetts Institute of Technology
-#
-# Permission to use, copy, modify, distribute, and sell this software and its
-# documentation for any purpose is hereby granted without fee, provided that
-# the above copyright notice appear in all copies and that both that
-# copyright notice and this permission notice appear in supporting
-# documentation, and that the name of M.I.T. not be used in advertising or
-# publicity pertaining to distribution of the software without specific,
-# written prior permission. M.I.T. makes no representations about the
-# suitability of this software for any purpose. It is provided "as is"
-# without express or implied warranty.
-#
-# This script is compatible with the BSD install script, but was written
-# from scratch.
-#
-
-
-# set DOITPROG to echo to test this script
-
-# Don't use :- since 4.3BSD and earlier shells don't like it.
-doit="${DOITPROG-}"
-
-
-# put in absolute paths if you don't have them in your path; or use env. vars.
-
-mvprog="${MVPROG-mv}"
-cpprog="${CPPROG-cp}"
-chmodprog="${CHMODPROG-chmod}"
-chownprog="${CHOWNPROG-chown}"
-chgrpprog="${CHGRPPROG-chgrp}"
-stripprog="${STRIPPROG-strip}"
-rmprog="${RMPROG-rm}"
-mkdirprog="${MKDIRPROG-mkdir}"
-
-transformbasename=""
-transform_arg=""
-instcmd="$mvprog"
-chmodcmd="$chmodprog 0755"
-chowncmd=""
-chgrpcmd=""
-stripcmd=""
-rmcmd="$rmprog -f"
-mvcmd="$mvprog"
-src=""
-dst=""
-dir_arg=""
-
-while [ x"$1" != x ]; do
- case $1 in
- -c) instcmd="$cpprog"
- shift
- continue;;
-
- -d) dir_arg=true
- shift
- continue;;
-
- -m) chmodcmd="$chmodprog $2"
- shift
- shift
- continue;;
-
- -o) chowncmd="$chownprog $2"
- shift
- shift
- continue;;
-
- -g) chgrpcmd="$chgrpprog $2"
- shift
- shift
- continue;;
-
- -s) stripcmd="$stripprog"
- shift
- continue;;
-
- -t=*) transformarg=`echo $1 | sed 's/-t=//'`
- shift
- continue;;
-
- -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
- shift
- continue;;
-
- *) if [ x"$src" = x ]
- then
- src=$1
- else
- # this colon is to work around a 386BSD /bin/sh bug
- :
- dst=$1
- fi
- shift
- continue;;
- esac
-done
-
-if [ x"$src" = x ]
-then
- echo "install: no input file specified"
- exit 1
-else
- true
-fi
-
-if [ x"$dir_arg" != x ]; then
- dst=$src
- src=""
-
- if [ -d $dst ]; then
- instcmd=:
- chmodcmd=""
- else
- instcmd=mkdir
- fi
-else
-
-# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
-# might cause directories to be created, which would be especially bad
-# if $src (and thus $dsttmp) contains '*'.
-
- if [ -f $src -o -d $src ]
- then
- true
- else
- echo "install: $src does not exist"
- exit 1
- fi
-
- if [ x"$dst" = x ]
- then
- echo "install: no destination specified"
- exit 1
- else
- true
- fi
-
-# If destination is a directory, append the input filename; if your system
-# does not like double slashes in filenames, you may need to add some logic
-
- if [ -d $dst ]
- then
- dst="$dst"/`basename $src`
- else
- true
- fi
-fi
-
-## this sed command emulates the dirname command
-dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
-
-# Make sure that the destination directory exists.
-# this part is taken from Noah Friedman's mkinstalldirs script
-
-# Skip lots of stat calls in the usual case.
-if [ ! -d "$dstdir" ]; then
-defaultIFS='
-'
-IFS="${IFS-${defaultIFS}}"
-
-oIFS="${IFS}"
-# Some sh's can't handle IFS=/ for some reason.
-IFS='%'
-set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
-IFS="${oIFS}"
-
-pathcomp=''
-
-while [ $# -ne 0 ] ; do
- pathcomp="${pathcomp}${1}"
- shift
-
- if [ ! -d "${pathcomp}" ] ;
- then
- $mkdirprog "${pathcomp}"
- else
- true
- fi
-
- pathcomp="${pathcomp}/"
-done
-fi
-
-if [ x"$dir_arg" != x ]
-then
- $doit $instcmd $dst &&
-
- if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
- if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
- if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
- if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
-else
-
-# If we're going to rename the final executable, determine the name now.
-
- if [ x"$transformarg" = x ]
- then
- dstfile=`basename $dst`
- else
- dstfile=`basename $dst $transformbasename |
- sed $transformarg`$transformbasename
- fi
-
-# don't allow the sed command to completely eliminate the filename
-
- if [ x"$dstfile" = x ]
- then
- dstfile=`basename $dst`
- else
- true
- fi
-
-# Make a temp file name in the proper directory.
-
- dsttmp=$dstdir/#inst.$$#
-
-# Move or copy the file name to the temp name
-
- $doit $instcmd $src $dsttmp &&
-
- trap "rm -f ${dsttmp}" 0 &&
-
-# and set any options; do chmod last to preserve setuid bits
-
-# If any of these fail, we abort the whole thing. If we want to
-# ignore errors from any of these, just make sure not to ignore
-# errors from the above "$doit $instcmd $src $dsttmp" command.
-
- if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
- if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
- if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
- if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
-
-# Now rename the file to the real destination.
-
- $doit $rmcmd -f $dstdir/$dstfile &&
- $doit $mvcmd $dsttmp $dstdir/$dstfile
-
-fi &&
-
-
-exit 0
diff --git a/contrib/gcc/ORDERS b/contrib/gcc/ORDERS
deleted file mode 100644
index 665c26df4caf..000000000000
--- a/contrib/gcc/ORDERS
+++ /dev/null
@@ -1,3757 +0,0 @@
-The actual order form follows the descriptions of media contents.
-
-Most of this file is excerpted from the draft of the June 1995 GNU's Bulletin.
-The Order Form itself is accurate, but the information in the other articles
-is not completely updated. You can ask gnu@prep.ai.mit.edu for the complete
-June, 1995 Order From to get up-to-date information.
-
-Please send suggestions for improvements to gnu@prep.ai.mit.edu or the postal
-address at the end of the order form. Thank You.
-
----------------------------------------------------------------------
-
-
-FSF Order Form with Descriptions preliminary, June 1995
-
-
-
-Free Software Foundation, Inc. Telephone: +1-617-542-5942
-59 Temple Place - Suite 330 Fax: (including Japan) +1-617-542-2652
-Boston, MA 02111-1307 Free Dial Fax (in Japan):
-USA 0031-13-2473 (KDD)
-Electronic mail: `gnu@prep.ai.mit.edu' 0066-3382-0158 (IDC)
-
-
-There are some sections (e.g. ``Forthcoming GNUs'' and ``How to Get GNU
-Software'') which are not in this Order Form file. If you wish to see them,
-ask gnu@prep.ai.mit.edu for the complete June, 1995 GNU's Bulletin.
-
-
-Table of Contents
------------------
-
- Donations Translate Into Free Software
- Cygnus Matches Donations!
- Free Software Redistributors Donate
- Help from Free Software Companies
- (not included) Major Changes in GNU Software and Documentation (not
- included as it was not done when this file was assembled).
- GNU Documentation
- GNU Software (not completely up to date)
- Program/Package Cross Reference (not completely up to date)
- Tapes
- Languages Tape (version numbers not completely up to date)
- Lisps and Emacs Tape (version numbers not completely up to date)
- Utilities Tape (version numbers not completely up to date)
- Scheme Tape
- X11 Tapes
- Berkeley 4.4BSD-Lite Tape
- VMS Emacs and VMS Compiler Tapes
- CD-ROMs
- Pricing of the GNU CD-ROMs
- MS-DOS CD-ROM
- Debian GNU/Linux CD-ROM
- Compiler Tools Binaries CD-ROM
- Source Code CD-ROMs
- June 1995 Source Code CD-ROM (version numbers not completely up
- to date)
- May 1994 Source Code CD-ROM
- November 1993 Source Code CD-ROM
- MS-DOS Diskettes
- DJGPP Diskettes (version numbers not completely up to date)
- Emacs Diskettes (version numbers not completely up to date)
- Selected Utilities Diskettes (not completely up to date)
- Windows Diskette
- Tape & CD-ROM Subscription Service
- The Deluxe Distribution
- FSF T-shirt
- Free Software Foundation Order Form
-
-
-
-Donations Translate Into Free Software
-**************************************
-
-If you appreciate Emacs, GNU CC, Ghostscript, and other free software, you
-may wish to help us make sure there is more in the future--remember,
-*donations translate into more free software!*
-
-Your donation to us is tax-deductible in the United States. We gladly accept
-*any* currency, although the U.S. dollar is the most convenient.
-m{No Value For "ergegrafkludge"} If your employer has a matching gifts
-program for charitable donations, please arrange to: add the FSF to the list
-of organizations for your employer's matching gifts program; and have your
-donation matched (note *Note Cygnus Matches Donations!::), if you do not
-know, please ask your personnel department. Circle amount you are donating,
-cut out this form, and send it with your donation to:
- Free Software Foundation
- 59 Temple Place -- Suite 330
- Boston, MA 02111-1307
- USA
-
- $500 $250 $100 $50 other $________
-
- Other currency:________
-
-
-You can charge a donation to any of Carte Blanche, Diner's Club, JCB,
-Mastercard, Visa, or American Express. Charges may also be faxed to
-+1-617-492-9057. Individuals in Japan who are unable to place international
-calls may use the "free dial" numbers: 0031-13-2473 (KDD) and
-0066-3382-0158 (IDC).
-
- Card type: __________________ Expiration Date: _____________
-
- Account Number: _____________________________________________
-
- Cardholder's Signature: _____________________________________
-
- Name: _______________________________________________________
-
- Street Address: _____________________________________________
-
- City/State/Province: ________________________________________
-
- Zip Code/Postal Code/Country: _______________________________
-
-
-
-Cygnus Matches Donations!
-*************************
-
-To encourage cash donations to the Free Software Foundation, Cygnus Support
-will continue to contribute corporate funds to FSF to accompany gifts by its
-employees, and by its customers and their employees.
-
-Donations payable to the Free Software Foundation should be sent by eligible
-persons to Cygnus Support, which will add its gifts and forward the total to
-the FSF each quarter. The FSF will provide the contributor with a receipt to
-recognize the contribution (which is tax-deductible on U.S. tax returns).
-For more information, please contact Cygnus:
- Cygnus Support
- 1937 Landings Drive
- Mountain View, CA 94043
- USA
-
- Telephone: 415-903-1400
- +1-800-Cygnus1 (-294-6871)
- Fax: 415-903-0122
- Electronic-Mail: `info@cygnus.com'
- FTP: `ftp.cygnus.com'
- WWW: `http://www.cygnus.com/'
-
-
-
-Free Software Redistributors Donate
-***********************************
-
-by Richard Stallman
-
-The Sun Users Group Deutschland and ASCII Corporation (Japan) have added
-donations to the FSF to the price of their next CD-ROM of GNU software.
-Potential purchasers will know precisely how much of the price is for the FSF
-and how much is for the redistributor.
-
-Austin Code Works, a redistributor of free software, is supporting free
-software development by giving the FSF 20% of the selling price for the GNU
-software packages they produce and sell. The producers of the SNOW 2.1 CD
-added the words "Includes $5 donation to the FSF" to the front of their CD.
-Walnut Creek CDROM and Info Magic, two more free software redistributors, are
-also giving us a percentage of their selling price. CQ Publishing made a
-large donation from the sales of their book about GAWK in Japanese.
-
-In the long run, the success of free software depends on how much new free
-software people develop. Free software distribution offers an opportunity to
-raise funds for such development in an ethical way. These redistributors
-have made use of the opportunity. Many others let it go to waste.
-
-You can help promote free software development by convincing for-a-fee
-redistributors to contribute--either by doing development themselves, or by
-donating to development organizations (the FSF and others).
-
-The way to convince distributors to contribute is to demand and expect this
-of them. This means choosing among distributors partly by how much they give
-to free software development. Then you can show distributors they must
-compete to be the one who gives the most.
-
-To make this work, you must insist on numbers that you can compare, such as,
-"We will give ten dollars to the Foobar project for each disk sold." A vague
-commitment, such as "A portion of the profits is donated," doesn't give you a
-basis for comparison. Even a precise fraction "of the profits from this
-disk" is not very meaningful, since creative accounting and unrelated
-business decisions can greatly alter what fraction of the sales price counts
-as profit.
-
-Also, press developers for firm information about what kind of development
-they do or support. Some kinds make much more long-term difference than
-others. For example, maintaining a separate version of a GNU program
-contributes very little; maintaining a program on behalf of the GNU Project
-contributes much. Easy new ports contribute little, since someone else would
-surely do them; difficult ports such as adding a new CPU to the GNU compiler
-contribute more; major new features and programs contribute the most.
-
-By establishing the idea that supporting further development is "the proper
-thing to do" when distributing free software for a fee, we can assure a
-steady flow of resources for making more free software.
-
-
-
-Help from Free Software Companies
-*********************************
-
-When choosing a free software business, ask those you are considering how
-much they do to assist free software development, e.g., by contributing money
-to free software development or by writing free software improvements
-themselves for general use. By basing your decision partially on this
-factor, you can help encourage those who profit from free software to
-contribute to its growth.
-
-These free software support companies regularly donate a part of their income
-to the Free Software Foundation to support the development of new GNU
-programs. Listing them here is our way of thanking them. Wingnut has made a
-pledge to donate 10% of their income to the FSF, and has also purchased
-several Deluxe Distribution packages in Japan. (Wingnut is SRA's special GNU
-support group). Also see *Note Cygnus Matches Donations!::.
-
- Wingnut Project
- Software Research Associates, Inc.
- 1-1-1 Hirakawa-cho, Chiyoda-ku
- Tokyo 102, Japan
-
- Phone: (+81-3)3234-2611
- Fax: (+81-3)3942-5174
- E-mail: `info-wingnut@sra.co.jp'
-
-
-
-GNU Documentation
-*****************
-
-GNU is dedicated to having quality, easy-to-use online and printed
-documentation. GNU manuals are intended to explain underlying concepts,
-describe how to use all the features of each program, and give examples of
-command use. GNU manuals are distributed as Texinfo source files, which
-yield both typeset hardcopy via the TeX document formatting system, and online
-hypertext display via the menu-driven Info system. Source for these manuals
-comes with our software; here we list the manuals that we publish as printed
-books as well; see the *note Free Software Foundation Order Form::..
-
-Most GNU manuals are bound as soft cover books with "lay-flat" bindings.
-This allows you to open them so they lie flat on a table without creasing the
-binding. These books have an inner cloth spine and an outer cardboard cover
-that will not break or crease as an ordinary paperback will. Currently, the
-`GDB', `Emacs', `Emacs Lisp Reference', `GAWK', `Make', `Bison', and `Texinfo'
-manuals have this binding. The other GNU manuals also lie flat when opened,
-using a GBC or Wire-O binding. All of our manuals are 7in by 9.25in except
-the 8.5in by 11in `Calc' manual.
-
-The edition number of the manual and version number of the program listed
-after each manual's name were current at the time this Bulletin was published.
-
-`Debugging with GDB' (Edition 4.12 for Version 4.14) tells how to use the GNU
-Debugger, run your program under debugger control, examine and alter data,
-modify a program's flow of control, and use GDB through GNU Emacs.
-
-The `Emacs Manual' (11th Edition for Version 19.29) describes editing with
-GNU Emacs. It explains advanced features, including outline mode and regular
-expression search; how to use special modes for programming in languages like
-C++ and TeX; how to use the `tags' utility; how to compile and correct code;
-how to make your own keybindings; and other elementary customizations.
-
-`Programming in Emacs Lisp, An Introduction' (Edition 1.03 for Version 19.29)
-is an elementary introduction to programming in Emacs Lisp. It is written
-for people who are not necessarily interested in programming, but who do want
-to customize or extend their computing environment. It tells how to write
-programs that find files; switchbuffers; use searches, conditionals, loops,
-and recursion; how to write Emacs initialization files; and how to run the
-Emacs Lisp debuggers. If you read the text in GNU Emacs under Info mode, you
-can run the sample programs directly.
-
-The `GNU Emacs Lisp Reference Manual' (Edition 2.4 for Version 19.29) covers
-this programming language in depth, including data types, control structures,
-functions, macros, syntax tables, searching/matching, modes, windows,
-keymaps, byte compilation, and the operating system interface.
-
-The `GAWK Manual' (Edition 0.16 for Version 2.16) tells how to use the GNU
-implementation of `awk'. It is written for those who have never used `awk'
-and describes the features of this powerful string and record manipulation
-language.
-
-The `Make Manual' (Edition 0.46 for Version 3.72) describes GNU `make', a
-program used to rebuild parts of other programs. The manual tells how to
-write "makefiles", which specify how a program is to be compiled and how its
-files depend on each other. Included are an introductory chapter for novice
-users and a section about automatically generated dependencies.
-
-The `Flex Manual' (Edition 1.03 for Version 2.3.7) teaches you to write a
-lexical scanner definition for the `flex' program to create a C++ or C-coded
-scanner that recognizes the patterns defined. You need no prior knowledge of
-scanners.
-
-The `Bison Manual' (December 1993 Edition for Version 1.23) teaches you how
-to write context-free grammars for the Bison program that convert into
-C-coded parsers. You need no prior knowledge of parser generators.
-
-`Using and Porting GNU CC' (September 1994 Edition for Version 2.6) tells how
-to run, install, and port the GNU C Compiler to new systems. It lists new
-features and incompatibilities of GCC, but people not familiar with C will
-still need a good reference on the C programming language. It also covers
-G++.
-
-The `Texinfo Manual' (Edition 2.20 for Version 3) explains the markup
-language used to generate both the online Info documentation and typeset
-hardcopies. It tells you how to make tables, lists, chapters, nodes,
-indexes, cross references, how to use Texinfo mode in GNU Emacs, and how to
-catch mistakes. This second edition describes over 50 new commands.
-
-The `Termcap Manual' (2nd Edition for Version 1.2), often described as "twice
-as much as you ever wanted to know about termcap," details the format of the
-termcap database, the definitions of terminal capabilities, and the process
-of interrogating a terminal description. This manual is primarily for
-programmers.
-
-The `C Library Reference Manual' (Edition 0.06 for Version 1.09) describes
-most of the facilities of the GNU C library, including both what Unix calls
-"library functions" and "system calls." We are doing limited copier runs of
-this manual until it becomes more stable. Please send corrections and
-improvements to `bug-glibc-manual@prep.ai.mit.edu'.
-
-The `Emacs Calc Manual' (Edition 2.02 for Version 2.02) is both a tutorial
-and a reference manual. It tells how to do ordinary arithmetic, how to use
-Calc for algebra, calculus, and other forms of mathematics, and how to extend
-Calc.
-
-
-
-GNU Software - (NOT COMPLETELY UP TO DATE)
-************
-
-All our software is available via FTP; see *Note How to Get GNU Software::.
-In addition, we offer software on various media and printed documentation:
-
- * *Note CD-ROMs::.
-
- * *Note Tapes::.
-
- * *Note MS-DOS Diskettes::.
-
- * *Note Documentation::, which includes manuals and reference cards.
-
-We welcome all bug reports sent to the appropriate electronic mailing list
-(*note Free Software Support::.).
-
-In the articles describing the contents of each medium, the version number
-listed after each program name was current when we published this Bulletin.
-When you order a distribution tape, diskette or newer CD-ROM, some of the
-programs may be newer, and therefore the version number higher.
-
-Key to cross reference:
-
-
- BinCD
- Binaries CD-ROM
-
- DjgppD
- Djgpp Diskettes
-
- DosCD
- MS-DOS CD-ROM
-
- EmcsD
- Emacs Diskettes
-
- LspEmcT
- Lisps/Emacs Tape
-
- LangT
- Languages Tape
-
- LiteT
- 4.4BSD-Lite Tape
-
- SchmT
- Scheme Tape
-
- SrcCD
- Source CD-ROM
-
- UtilD
- Selected Utilities Diskettes
-
- UtilT
- Utilities Tape
-
- VMSCompT
- VMS Compiler Tape
-
- VMSEmcsT
- VMS Emacs Tape
-
- WdwsD
- Windows Diskette
-
- X11OptT
- X11 Optional Tape
-
- X11ReqT
- X11 Required Tape
-
-
-
-Configuring GNU Software:
-
-We are using a uniform scheme for configuring GNU software packages in order
-to compile them. It uses the `Autoconf' program (see item below). The goal
-is to have all GNU software support the same alternatives for naming machine
-and system types. When the GNU system is complete it will be possible to
-configure and build the entire system at once, eliminating the need to
-separately configure each individual package. The configuration scheme lets
-you specify both the host and target system to build cross-compilation tools.
-
-
-
-GNU software currently available:
-
-(For new features and coming programs, see *Note Forthcoming GNUs::.)
-
- * `acm' (SrcCD, UtilT)
-
- `acm' is a LAN-oriented, multiplayer aerial combat simulation that runs
- under the X Window System. Players engage in air to air combat against
- one another using heat seeking missiles and cannons. We are working on
- more accurate simulation of real airplane flight characteristics.
-
- * Autoconf (SrcCD, UtilT)
-
- Autoconf produces shell scripts which automatically configure source code
- packages. These scripts adapt the packages to many kinds of Unix-like
- systems without manual user intervention. Autoconf creates a script for
- a package from a template file which lists the operating system features
- which the package can use, in the form of `m4' macro calls. Autoconf
- requires GNU `m4' to operate, but the resulting configure scripts it
- generates do not.
-
- Most GNU programs now use Autoconf-generated configure scripts.
-
- * BASH (SrcCD, UtilT)
-
- The GNU shell, BASH (Bourne Again SHell), is compatible with the Unix
- `sh' and offers many extensions found in `csh' and `ksh'. BASH has job
- control, `csh'-style command history, and command-line editing (with
- Emacs and `vi' modes built-in, and the ability to rebind keys) via the
- readline library. BASH conforms to the POSIX 1003.2 shell specification.
-
- * `bc' (DjgppD, DosCD, SrcCD, UtilT)
-
- `bc' is an interactive algebraic language with arbitrary precision
- numbers. GNU `bc' follows the POSIX.2-1992 standard, with several
- extensions including multi-character variable names, an `else'
- statement, and full Boolean expressions. The RPN calculator `dc' is now
- distributed as part of the same package, but GNU `bc' is not implemented
- as a `dc' preprocessor.
-
- * BFD (BinCD, DjggpD, DosCD, LangT, SrcCD)
-
- The Binary File Descriptor library allows a program which operates on
- object files (e.g., `ld' or GDB) to support many different formats in a
- clean way. BFD provides a portable interface, so that only BFD needs to
- know the details of a particular format. One result is that all
- programs using BFD will support formats such as a.out, COFF, and ELF.
- BFD comes with source for Texinfo documentation (not yet published on
- paper). Presently BFD is not distributed separately; it is included
- with packages that use it.
-
- * Binutils (BinCD, DjgppD, DosCD, LangT, SrcCD)
-
- Binutils includes the programs: `ar', `c++filt', `demangle', `gas',
- `gprof', `ld', `nlmconv', `nm', `objcopy', `objdump', `ranlib', `size',
- `strings', and `strip'.
-
- Binutils Version 2 uses the BFD library. The GNU linker `ld' emits
- source-line numbered error messages for multiply-defined symbols and
- undefined references. It interprets a superset of the AT&T Linker
- Command Language, which gives general control over where segments are
- placed in memory. `nlmconv' converts object files into Novell NetWare
- Loadable Modules. `objdump' can disassemble code for a29k, ALPHA,
- H8/300, H8/500, HP-PA, i386, i960, m68k, m88k, MIPS, SH, SPARC, & Z8000
- processors, and can display other data (e.g., symbols & relocations)
- from any file format understood by BFD.
-
- * Bison (BinCD, DjgppD, DosCD, LangT, SrcCD, VMSCompT)
-
- Bison is an upwardly compatible replacement for the parser generator
- `yacc'. Texinfo source for the `Bison Manual' and reference card are
- included. *Note Documentation::.
-
- We recently decided to change the policy for using the parsers that
- Bison generates. It is now permitted to use Bison-generated parsers in
- non-free programs. *Note GNUs Flashes::.
-
- * GNU C Library (BinCD, LangT, SrcCD)
-
- The GNU C library supports ANSI C-1989, POSIX 1003.1-1990 and most of the
- functions in POSIX 1003.2-1992. It is upwardly compatible with 4.4BSD
- and includes many System V functions, plus GNU extensions.
-
- The C Library will perform many functions of the Unix system calls in
- the Hurd. Mike Haertel has written a fast `malloc' which wastes less
- memory than the old GNU version. The GNU regular-expression functions
- (`regex' and `rx') now nearly conform to the POSIX 1003.2 standard.
-
- GNU `stdio' lets you define new kinds of streams, just by writing a few
- C functions. The `fmemopen' function uses this to open a stream on a
- string, which can grow as necessary. You can define your own `printf'
- formats to use a C function you have written. For example, you can
- safely use format strings from user input to implement a `printf'-like
- function for another programming language. Extended `getopt' functions
- are already used to parse options, including long options, in many GNU
- utilities.
-
- The C Library runs on Sun-3 (SunOS 4.1), Sun-4 (SunOS 4.1 or Solaris 2),
- HP 9000/300 (4.3BSD), SONY News 800 (NewsOS 3 or 4), MIPS DECstation
- (Ultrix 4), DEC Alpha (OSF/1), i386/i486 (System V, SVR4, BSD, SCO 3.2 &
- SCO ODT 2.0), Sequent Symmetry i386 (Dynix 3) & SGI (Irix 4). Texinfo
- source for the `GNU C Library Reference Manual' is included (*note
- Documentation::.); the manual is now being updated.
-
- * GNU C++ Library (BinCD, DjgppD, DosCD, LangT, SrcCD)
-
- The GNU C++ library (libg++) contains an extensive collection of C++
- `forest' classes, an IOStream library for input/output routines, and
- support tools for use with G++. Supported classes include: Obstacks,
- multiple-precision Integers and Rationals, Complex numbers, arbitrary
- length Strings, BitSets and BitStrings. Version 2.6.2 includes the
- initial release of the libstdc++ library. This implements library
- facilities defined by the forthcoming ANSI/ISO C++ standard, including
- the Standard Template Library.
-
- * Calc (LspEmcT, SrcCD)
-
- Calc (written by Dave Gillespie in Emacs Lisp) is an extensible, advanced
- desk calculator & mathematical tool that runs as part of GNU Emacs. You
- can use Calc just as a simple four-function calculator, but it has many
- more features including: choice of algebraic or RPN (stack-based) entry;
- logarithmic, trigonometric & financial functions; arbitrary precision;
- complex numbers; vectors; matrices; dates; times; infinities; sets;
- algebraic simplification; differentiation & integration. It outputs to
- `gnuplot' & comes with source for a reference card & a Manual. *Note
- Documentation::.
-
- * GNU Chess (SrcCD, UtilT, WdwsD)
-
- GNU Chess lets the computer play a full game of chess with you. It runs
- on most platforms & has dumb terminal, "curses" & X terminal interfaces.
- The X terminal interface is based on the `xboard' program.
- m{No Value For "ergegrafkludge"} GNU Chess implements many specialized
- features including the null move heuristic, a hash table with aging, the
- history heuristic (another form of the earlier killer heuristic),
- caching of static evaluations, & a database which lets it play the first
- several moves of the game quickly. Recent improvements include better
- heuristics, faster evaluation, thinking on opponent's time, a perfect
- King and Pawn vs King endgame routine, Swedish & German language
- support, support for more book formats, a rudimentary Bobby Fischer
- clock, & bug fixes. It is primarily supported by Stuart Cracraft, Chua
- Kong Sian, & Tim Mann on behalf of the FSF.
-
- * CLISP (LspEmcT, SrcCD)
-
- CLISP is a Common Lisp implementation by Bruno Haible and Michael Stoll.
- It mostly supports the Lisp described by `Common LISP: The Language (2nd
- edition)' and the ANSI Common Lisp standard. CLISP includes an
- interpreter, a byte-compiler, a large subset of CLOS, a foreign language
- interface and, for some machines, a screen editor. The user interface
- language (English, German, French) is chooseable at run time. Major
- packages that run in CLISP include CLX & Garnet. CLISP needs only 2 MB
- of memory & runs on many microcomputers (including MS-DOS systems, OS/2,
- the Atari ST, Amiga 500-4000, Acorn RISC PC) & Unix-like systems
- (GNU/Linux, Sun4, SVR4, SGI, HP-UX, DEC Alpha, NeXTstep & others).
-
- * GNU Common Lisp (LspEmcT, SrcCD)
-
- GNU Common Lisp (GCL) has a compiler and interpreter for Common Lisp. It
- used to be known as Kyoto Common Lisp. It is very portable and extremely
- efficient on a wide class of applications. It compares favorably in
- performance with commercial Lisps on several large theorem-prover and
- symbolic algebra systems. It supports the CLtL1 specification but is
- moving towards the proposed ANSI definition. GCL compiles to C and
- then uses the native optimizing C compilers (e.g., GCC). A function
- with a fixed number of args and one value turns into a C function of the
- same number of args, returning one value, so GCL is maximally efficient
- on such calls. It has a conservative garbage collector which allows
- great freedom for the C compiler to put Lisp values in arbitrary
- registers. It has a source level Lisp debugger for interpreted code,
- with display of source code in an Emacs window. Ita profiling tools
- (based on the C profiling tools) count function calls and the time spent
- in each function. CLX works with GCL.
-
- There is now a builtin interface with the TK widget system. It runs in
- a separate process so that users may monitor progress on lisp
- computations, or interact with running computations via a windowing
- interface.
-
- There is also an Xlib interface via C (xgcl-2). PCL runs with GCL (see
- PCL item later in this article). *Note Forthcoming GNUs::, for plans for
- about GCL, or for recent developments. GCL version 2.0 is released
- under the GNU Library General Public License.
-
- * `cpio' (DjgppD, DosCD, SrcCD, UtilD, UtilT)
-
- `cpio' is an alternative archive program with all the features of SVR4
- `cpio', including support for the final POSIX 1003.1 `ustar' standard.
- `mt', a program to position magnetic tapes, is included with `cpio'.
-
- * CVS (SrcCD, UtilT)
-
- CVS, the Concurrent Version System, manages software revision and release
- control in a multi-developer, multi-directory, multi-group environment.
- It works best in conjunction with RCS versions 4 and above, but will
- parse older RCS formats with the loss of CVS's fancier features. See
- Berliner, Brian, "CVS-II: Parallelizing Software Development,"
- `Proceedings of the Winter 1990 USENIX Association Conference'. To find
- out how to get a copy of this report, contact `office@usenix.org'.
-
- * DejaGnu (LangT, SrcCD)
-
- DejaGnu is a framework for testing other programs that provides a single
- front end for all tests. The framework's flexibility and consistency
- makes it easy to write tests for any program. DejaGnu comes with
- `expect', which runs scripts to conduct dialogs with programs.
-
- * Diffutils (DjgppD, DosCD, SrcCD, UtilD, UtilT)
-
- GNU `diff' compares files showing line-by-line changes in several
- flexible formats. It is much faster than traditional Unix versions. The
- Diffutils package contains `diff', `diff3', `sdiff', and `cmp'.
-
- Recent Diffutils improvements include more consistent handling of
- character sets, and a new `diff' option to do all input/output in
- binary; this is useful on some non-Posix hosts.
-
- Plans for the Diffutils package include support for internationalization
- (e.g., error messages in Chinese), and for some non-Unix PC environments.
-
- * DJGPP (BinCD, DjgppD, DosCD)
-
- DJ Delorie has ported GCC/G++ 2.6.0 (see the GCC item in this section)
- to the i386 MS-DOS platform. The DJGPP package also contains a 32-bit
- 80386 DOS extender with symbolic debugger; development libraries; and
- ports of Bison, `flex', GAS, and the GNU Binutils. Full source code is
- provided. It requires at least 5MB of hard disk space to install and
- 512K of RAM to use. It supports SVGA (up to 1024x768), XMS & VDISK
- memory allocation, `himem.sys', VCPI (e.g., QEMM, DESQview, & 386MAX),
- and DPMI (e.g., Windows 3.x, OS/2, QEMM, & QDPMI). Ask
- `djgpp-request@sun.soe.clarkson.edu' to join a DJGPP users mailing list.
-
- * `dld' (LangT, SrcCD)
-
- `dld' is a dynamic linker written by W. Wilson Ho. Linking your program
- with the `dld' library allows you to dynamically load object files into
- the running binary. Currently supported are VAX (Ultrix), Sun 3 (SunOS
- 3.4 & 4.0), SPARC (SunOS 4.0), Sequent Symmetry (Dynix), & Atari ST.
-
- * `doschk' (DjgppD, DosCD, SrcCD, UtilT)
-
- This program is intended as a utility to help software developers ensure
- that their source file names are distinguishable on System V platforms
- with 14-character filenames and on MS-DOS with 8+3 character filenames.
-
- * `ecc' (SrcCD, UtilT)
-
- `ecc' is a Reed-Solomon error correction checking program, which can
- correct three byte errors in a block of 255 bytes and detect more severe
- errors. Contact `paulf@Stanford.EDU' for more information.
-
- * `ed' (SrcCD, UtilT)
-
- Ed is the standard text editor.
-
- * Elib (LspEmcT, SrcCD)
-
- Elib is a small library of Emacs Lisp functions, including routines for
- using AVL trees and doubly-linked lists.
-
- * GNU Emacs
-
- In 1975, Richard Stallman developed the first Emacs, an extensible,
- customizable real-time display editor and computing environment. GNU
- Emacs is his second implementation. It offers true Lisp--smoothly
- integrated into the editor--for writing extensions, and provides an
- interface to the X Window System. It also runs on MS-DOS and Windows
- NT. In addition to its powerful native command set, Emacs has
- extensions which emulate the editors vi and EDT (DEC's VMS editor).
- Emacs has many other features which make it a full computing support
- environment. Our long term plan is now to move it in the direction of a
- WYSIWYG word processor and make it easy for beginners to use. Source
- for the `GNU Emacs Manual', `Programming in Emacs Lisp, An
- Introduction', the `GNU Emacs Lisp Reference Manual', and a reference
- card come with the software. *Note Documentation::.
-
- * GNU Emacs 18 (EmcsD, LspEmcT, SrcCD, VMSEmcsT)
-
- GNU Emacs 18.59 is the last release of version 18 from the FSF. We are
- no longer maintaining it. It runs on many Unix systems. In hardware
- order: Alliant FX/80 & FX/2800, Altos 3068, Amdahl (UTS), Apollo, AT&T
- (3Bs & 7300 PC), DG Aviion, Bull DPX/2 (2nn & 3nn) CCI 5/32 & 6/32,
- Celerity, Convex, Digital (DECstation 3100 & 5000 (PMAXes), Mips, VAX
- (BSD, SysV & VMS)), Motorola Delta 147 & 187, Dual, Elxsi 6400, Encore
- (DPC, APC & XPC), Gould, HP (9000 series 200, 300, 700 & 800, but not
- 500), HLH Orion (original & 1/05), IBM (RS/6000 (AIX), RT/PC (4.2 & AIX)
- & PS/2 (AIX (386 only))), ISI (Optimum V, 80386), Intel 860 & 80386
- (BSD, Esix, SVR3, SVR4, SCO, ISC, IX, AIX & others), Iris (2500, 2500
- Turbo & 4D), Masscomp, MIPS, National Semiconductor 32000, NeXT (Mach),
- NCR Tower 32 (SVR2 & SVR3), Nixdorf Targon 31, Nu (TI & LMI), pfa50,
- Plexus, Prime EXL, Pyramid (original & MIPS), Sequent (Balance &
- Symmetry), SONY News (m68k & MIPS), Stride (system release 2), all Suns
- including 386i (all SunOS & some Solaris vers.), Tadpole, Tahoe, Tandem
- Integrity S2, Tektronix (16000 & 4300), Triton 88, Ustation E30 (SS5E),
- Whitechapel (MG1) & Wicat.
-
- In operating system order: AIX (RS/6000, RT/PC, 386-PS/2), BSD (vers.
- 4.1, 4.2, 4.3), DomainOS, Esix (386), HP-UX (HP 9000 series 200, 300,
- 700, 800 but not 500), ISC (386), IX (386), Mach, Microport, NewsOS
- (Sony m68k & MIPS) SCO (386), SVR0 (Vax, AT&T 3Bs), SVR2, SVR3, SVR4,
- Solaris 2.0, SunOS, UTS (Amdahl), Ultrix (vers. 3.0, 4,1), Uniplus 5.2
- (Dual machines), VMS (vers. 4.0, 4.2, 4.4, 5.5) & Xenix (386).
-
- * GNU Emacs 19 (DosCD, EmacsD, LspEmcT, SrcCD)
-
- Emacs 19 works with character-only terminals as well as with the X
- Window System (with or without the X toolkit); New features in Emacs 19
- include: multiple X windows ("frames" to Emacs), with either a separate
- X window for the minibuffer or a minibuffer attached to each X window;
- property lists associated with regions of text in a buffer; multiple
- fonts and colors defined by those properties; simplified and improved
- processing of function keys, mouse clicks and mouse movement; X
- selection processing, including clipboard selections; hooks to be run if
- point or mouse moves outside a certain range; menu bars and popup menus
- defined by keymaps; scrollbars; before and after change hooks;
- source-level debugging of Emacs Lisp programs; European character sets
- support; floating point numbers; improved buffer allocation, including
- returning storage to the system when a buffer is killed; interfacing
- with the X resource manager; GNU configuration scheme support; good RCS
- support; & many updated libraries.
-
- Recent features include support for Motif widgets as well as the Athena
- widgets, displaying multiple views of an outline at the same time,
- version control support for CVS and for multiple branches, ability to
- open frames on more than one X display from a single Emacs job,
- operation on MS-DOS and MS Windows, commands to edit text properties,
- text properties for formatting text, the ability to save text properties
- in files, & GNU-standard long named command line options.
-
- Emacs 19.29 is believed to work on, in hardware order: Acorn Risc
- machine (RISCiX); Alliant FX/2800 (BSD); Alpha (OSF/1); Apollo
- (DomainOS); Bull DPX/2 2nn & 3nn (SysV.3) & sps7 (SysV.2); Clipper;
- Convex (BSD); Cubix QBx (SysV); Data General Aviion (DGUX); DEC MIPS
- (Ultrix 4.2 & OSF/1, not VMS); Elxsi 6400 (SysV); Gould Power Node & NP1
- (4.2 & 4.3BSD); Harris Night Hawk 1200 and 3000, 4000 and 5000 (cxux);
- Honeywell XPS100 (SysV); HP 9000 series 200, 300, 700, 800 (but not 500)
- (4.3BSD or HP-UX 7, 8, 9); Intel i386, i486 and Pentium (386BSD, AIX,
- BSDI/386, FreeBSD, Esix, GNU/Linux, ISC, MS-DOS (*note MS-DOS
- Diskettes::. & *Note MS-DOS CD-ROM::), NetBSD, SCO3.2v4, SysV, Xenix,
- WindowsNT); IBM RS6000 (AIX 3.2); IBM RT/PC (AIX or BSD); Motorola Delta
- 147 & 187 (SysV.3, SysV.4, & m88kbcs); National Semiconductor 32K
- (Genix); NeXT (BSD or Mach 2 w/ NeXTStep 3.0); Paragon (OSF/1); Prime
- EXL (SysV); Pyramid (BSD); Sequent Symmetry (BSD, ptx); Siemens RM400
- and RM600 (SysV); SGI Iris 4D (Irix 4.x & 5.x); Sony News/RISC (NewsOS);
- Stardent i860 (SysV); Sun 3 & 4, SPARC 1, 1+, 2, 10 & Classic (SunOS
- 4.0, 4.1, Solaris 2.0-2.3); Tadpole 68k (SysV); Tektronix XD88 (SysV.3)
- & 4300 (BSD); & Titan P2 & P3 (SysV).
-
- In operating system order: AIX (i386, RS6000, RT/PC); 4.1, 4.2, 4.3BSD
- (i386, i860, Convex, Gould Power Node & NP1, HP9000 series 300, NeXT,
- Pyramid, Symmetry, Tektronix 4300, RT/PC); DG/UX (Aviion);
- DomainOS(Apollo); Esix (i386); FreeBSD (i386); Genix (ns32k); GNU/Linux
- (i386); HP-UX 7, 8, 9 (HP 9000 series 200, 300, 700, 800, but not 500);
- Irix 4 & 5 (Iris 4D); ISC (i386); Mach 2 & 3 (i386, NeXT); MS-DOS (*note
- MS-DOS Diskettes::. & *Note MS-DOS CD-ROM::); NetBSD (i386, HP9000
- series 300); OSF/1 (Alpha, Paragon); RISCiX (Acorn); SCO 3.2v4 (i386);
- SysV (Cubix QBx, Elxsi 6400, Honeywell XPS100, Intel i386, Prime EXL,
- Siemens RM400 and RM600, Stardent, Tadpole 68k, Titan P2 & P3); SysV.2
- (Bull sps7); SysV.3 (Bull DPX/2 2nn & 3nn, Motorola Delta 147 & 187,
- Tektronix XD88); SysV.4 (Motorola Delta 147 & 187, Stardent i860);
- Solaris 2 (SPARC 1, 1+, 2, 10, Classic); SunOS 4.0, 4.1 (Sun 3 & 4,
- SPARC 1, 1+, 2, 10 & Classic); Ultrix 4.2 (DEC MIPS); Windows NT; &
- Xenix (i386).
-
- Other configurations supported by Emacs 18 should work with few changes
- in Emacs 19; as users tell us more about their experiences with different
- systems, we will augment the list. Also see *Note Forthcoming GNUs::.
-
- * `es' (SrcCD, UtilT)
-
- `es' is an extensible shell based on `rc' with first class functions,
- lexical scope, exceptions, and rich return values (i.e., functions can
- return values other than just numbers). `es''s extensibility comes from
- the ability to modify and extend the shell's builtin services, such as
- path searching and redirection. Like `rc', it is great for both
- interactive use and for scripting, particularly since its quoting rules
- are much less baroque than the C or Bourne shells.
-
- * `f2c' (LangT, SrcCD)
-
- `f2c' converts Fortran-77 source files into C or C++, which can be
- compiled with GCC. You can get bug fixes by FTP from site
- `netlib.att.com' or by email from `netlib@research.att.com'. The fixes
- are summarized in the file `/netlib/f2c/changes.Z'. *Note Forthcoming
- GNUs::, for information about GNU Fortran.
-
- * Fileutils (DjgppD, DosCD, SrcCD, UtilD, UtilT)
-
- The fileutils work on files: `chgrp', `chmod', `chown', `cp', `dd', `df',
- `dir', `du', `install', `ln', `ls', `mkdir', `mkfifo', `mknod', `mv',
- `mvdir', `rm', `rmdir', `sync', `touch', & `vdir'. Only some of these
- are on the *Note Selected Utilities Diskettes::.
-
- * Findutils (DjgppD, DosCD, SrcCD, UtilD, UtilT)
-
- `find' is frequently used both interactively and in shell scripts to
- find files which match certain criteria and perform arbitrary operations
- on them. Also included are `xargs', which applies a command to a list
- of files, and `locate', which scans a database for file names that match
- a pattern.
-
- * Finger (SrcCD, UtilT)
-
- GNU Finger has more features than other finger programs. For sites with
- many hosts, a single host may be designated as the finger "server" host,
- and other hosts at that site configured as finger "clients". The server
- host collects information about who is logged in to the clients. To
- finger a user at a GNU Finger site, a query to any its client hosts gets
- useful information. GNU Finger supports many customization features,
- including user output filters, and site programmable output for special
- target names.
-
- * `flex' (DjgppD, DosCD, LangT, SrcCD, UtilD)
-
- `flex' is a replacement for the `lex' scanner generator. `flex' was
- written by Vern Paxson of the Lawrence Berkeley Laboratory and generates
- far more efficient scanners than `lex' does. Source for the `Flex
- Manual' and reference card are included. *Note Documentation::.
-
- * FlexFAX (UtilT)
-
- FlexFAX is now called HylaFAX. For more information, *Note GNU
- Software::.
-
- * Fontutils (SrcCD, UtilT)
-
- The fontutils create fonts for use with Ghostscript or TeX, starting
- with a scanned type image and converting the bitmaps to outlines. They
- also contain general conversion programs and other utilities.
-
- Fontutils programs include: `bpltobzr', `bzrto', `charspace',
- `fontconvert', `gsrenderfont', `imageto', `imgrotate', `limn', and
- `xbfe'.
-
- * GAWK (DjgppD, DosCD, LangT, SrcCD)
-
- GAWK is upwardly compatible with the latest POSIX specification of
- `awk'. It also provides several useful extensions not found in other
- `awk' implementations. Texinfo source for the `GAWK Manual' comes with
- the software. *Note Documentation::.
-
- * GCC (BinCD, DjgppD, DosCD, LangT, SrcCD, VMSCompT)
-
- Version 2 of the GNU C Compiler supports multiple languages; the source
- file name suffix or a compiler option selects the language. The GNU C
- Compiler distribution includes support for C, C++ and Objective-C.
- Support for Objective-C was donated by NeXT. The runtime support needed
- to run Objective-C programs is now distributed with GCC (this does not
- include any Objective-C classes aside from `object'). As much as
- possible, G++ is kept compatible with the evolving draft ANSI standard,
- but not with `cfront' (AT&T's compiler), which has been diverging from
- ANSI.
-
- The GNU C Compiler is a fairly portable optimizing compiler which
- performs automatic register allocation, common sub-expression
- elimination, invariant code motion from loops, induction variable
- optimizations, constant propagation and copy propagation, delayed
- popping of function call arguments, tail recursion elimination,
- integration of inline functions and frame pointer elimination,
- instruction scheduling, loop unrolling, filling of delay slots, leaf
- function optimization, optimized multiplication by constants, a certain
- amount of common subexpression elimination (CSE) between basic blocks
- (though not all of the supported machine descriptions provide for
- scheduling or delay slots), a feature for assigning attributes to
- instructions, and many local optimizations that are automatically
- deduced from the machine description. Position-independent code is
- supported on the 68k, i386, i486, Pentium, Hitachi Slt, Hitachi H8/300,
- Clipper, 88k, SPARC & SPARClite.
-
- GCC can open-code most arithmetic on 64-bit values (type `long long
- int'). It supports extended floating point (type `long double') on the
- 68k; other machines will follow.
-
- GCC supports full ANSI C, traditional C & GNU C extensions (including:
- nested functions support, nonlocal gotos & taking the address of a
- label).
-
- GCC can generate a.out, COFF, ELF & OSF-Rose files when used with a
- suitable assembler. It can produce debugging information in these
- formats: BSD stabs, COFF, ECOFF, ECOFF with stabs & DWARF.
-
- GCC generates code for many CPUs, including: a29k, Alpha, ARM, AT&T
- DSP1610, Convex cN, Clipper, Elxsi, Fujitsu Gmicro, H8/300, HP-PA (1.0
- and 1.1) i370, i386, i486, Pentium, i860, i960, m68k, m68020, m68030,
- m68040, m88k, MIL-STD-1750a, MIPS, ns32k, PDP-11, Pyramid, ROMP, RS6000,
- SH, SPARC, SPARClite, VAX, & we32k.
-
- Operating systems supported include: AIX, ACIS, AOS, BSD, Clix, Ctix,
- DG/UX, Dynix, Genix, GNU, HP-UX, ISC, Irix, GNU/Linux, Luna, LynxOS,
- Mach, Minix, NetBSD, NewsOS, OSF, OSF-Rose, RISCOS, SCO, Solaris 2,
- SunOS 4, SysV, Ultrix, Unos, VMS & Windows/NT.
-
- Using the configuration scheme for GCC, building a cross-compiler is as
- easy as building a native compiler.
-
- We no longer maintain version 1 of GCC, G++, or libg++.
-
- Texinfo source for the `Using and Porting GNU CC' manual, is included
- with GCC. *Note Forthcoming GNUs::, for plans for later releases of
- GCC.
-
- * GDB (BinCD, DjgppD, DosCD, LangT, SrcCD)
-
- GDB, the GNU DeBugger, is a source-level debugger which supports C, C++,
- and Fortran.
-
- GDB can debug both C and C++ programs, and will work with executables
- produced by many different compilers; however, C++ debugging will have
- some limitations if you do not use GCC.
-
- GDB has a command line user interface; GNU Emacs comes with a GDB mode,
- and `xxgdb' provides an X interface (but it is not distributed or
- maintained by the FSF; FTP it from `ftp.x.org' in the
- `/contrib/utilities' directory).
-
- Executable files and symbol tables are read via the BFD library, which
- allows a single copy of GDB to debug programs with multiple object file
- formats (e.g., a.out, COFF, ELF). Other features include a rich command
- language, remote debugging over serial lines or TCP/IP, and watchpoints
- (breakpoints triggered when the value of an expression changes).
-
- GDB defines a standard interface for simulators, and the included
- simulator library includes simulators for the Zilog Z8001/2, Hitachi
- H8/300, H8/500 & Super-H.
-
- GDB can perform cross-debugging. To say that GDB "targets" a platform
- means that it can perform native or cross-debugging for it. To say that
- GDB can "host" a given platform means that it can be built on it, but
- cannot necessarily debug native programs. GDB can:
-
- * "target" & "host": Amiga 3000 (Amix), DEC Alpha (OSF/1), DECstation
- 3100 & 5000 (Ultrix), HP 9000/300 (BSD, HP-UX), HP 9000/700 (HP-UX),
- i386 (BSD, FreeBSD, GNU/Linux, LynxOS, NetBSD, SCO), IBM RS/6000
- (AIX, LynxOS), Motorola Delta m88k (System V, CX/UX), PC532
- (NetBSD), Motorola m68k MVME-167 (LynxOS), NCR 3000 (SVR4), SGI
- (Irix V3, V4, V5), SONY News (NewsOS 3.x), SPARC (SunOS 4.1,
- Solaris, NetBSD, LynxOS) Sun-3 (SunOS 4.1), & Ultracomputer (a29k
- running Sym1).
-
- * "target", but not "host": AMD 29000 (COFF & a.out), Hitachi H8/300,
- Hitachi SH, i386 (a.out, COFF, OS/9000) i960 (Nindy, VxWorks),
- m68k/m68332 (a.out, COFF, VxWorks), MIPS (IDT ecoff, ELF), Fujitsu
- SPARClite (a.out, COFF), & Z8000.
-
- * "host", but not "target": IBM RT/PC (AIX), and HP/Apollo 68k (BSD).
-
- GDB can use the symbol tables emitted by the vendor-supplied compilers of
- most MIPS-based machines, including DEC. (These tables are in a format
- which almost nobody else uses.) Source for the manual
- `Debugging with GDB' and a reference card are included. *Note
- Documentation::.
-
- * `gdbm' (LangT, SrcCD, UtilD)
-
- `gdbm' is the GNU replacement for the traditional `dbm' and `ndbm'
- libraries. It implements a database using quick lookup by hashing.
- `gdbm' does not ordinarily make sparse files (unlike its Unix and BSD
- counterparts).
-
- * Ghostscript (DjgppD, DosCD, SrcCD, UtilT)
-
- GNU Ghostscript is the GNU release of Ghostscript, which is an
- interpreter for the Postscript graphics language (*note Forthcoming
- GNUs::., for news on future plans).
-
- The current version of GNU Ghostscript is 2.6.2. Features include the
- ability to use the fonts provided by the platform on which Ghostscript
- runs (X Window System and Microsoft Windows), resulting in much
- better-looking screen displays; improved text file printing (like
- `enscript'); a utility to extract the text from a Postscript language
- document; a much more reliable (and faster) Microsoft Windows
- implementation; support for Microsoft C/C++ 7.0; drivers for many new
- printers, including the SPARCprinter, and for TIFF/F (fax) file format;
- many more Postscript Level 2 facilities, including most of the color
- space facilities (but not patterns), and the ability to switch between
- Level 1 and Level 2 dynamically. Version 2.6.2 adds a LaserJet 4 driver
- and several important bug fixes to version 2.6.1.
-
- Ghostscript executes commands in the Postscript language by writing
- directly to a printer, drawing on an X window, or writing to a file for
- later printing (or to a bitmap file that you can manipulate with other
- graphics programs).
-
- Ghostscript includes a C-callable graphics library (for client programs
- that do not want to deal with the Postscript language). It also supports
- IBM PCs and compatibles with EGA, VGA, or SuperVGA graphics (but please
- do *not* ask the FSF staff any questions about this; we do not use PCs).
-
- * Ghostview (SrcCD, UtilT)
-
- Tim Theisen, `ghostview@cs.wisc.edu', has created Ghostview, a previewer
- for multi-page files with an X11 user interface. Ghostview and
- Ghostscript function as two cooperating programs; Ghostview creates a
- viewing window and Ghostscript draws in it.
-
- * `gmp' (LangT, SrcCD)
-
- GNU mp is a library for arbitrary precision arithmetic on signed integers
- and rational numbers. It has a rich set of functions with a regular
- interface.
-
- * GNATS (SrcCD, UtilT)
-
- GNATS (GNats: A Tracking System, not to be confused with GNAT, The GNU
- Ada Translator) is a bug-tracking system. It is based upon the paradigm
- of a central site or organization which receives problem reports and
- negotiates their resolution by electronic mail. Although it has been
- used primarily as a software bug-tracking system so far, it is
- sufficiently generalized so that it could be used for handling system
- administration issues, project management or any number of other
- applications.
-
- * `gnuplot' (SrcCD, UtilT, WdwsD)
-
- `gnuplot' is an interactive program for plotting mathematical
- expressions and data. It handles both curves (2 dimensions) and surfaces
- (3 dimensions). Curiously, the program was neither written nor named for
- the GNU Project; the name is a coincidence. Various GNU programs use
- `gnuplot' to produce graphical output.
-
- * GnuGo (SrcCD, UtilT)
-
- GnuGo plays the game of Go (Wei-Chi); it is not yet very sophisticated.
-
- * `gperf' (LangT, SrcCD)
-
- `gperf' generates perfect hash tables. There are two implementations of
- `gperf', written in C and C++. Both produce hash functions in either C
- or C++.
-
- * GNU Graphics (SrcCD, UtilT)
-
- GNU Graphics is a system which produces x-y plots from ASCII or binary
- data. It supports output in Postscript, Tektronix 4010 compatible and
- Unix device-independent "plot" formats as well as a previewer for the X
- Window System. Features include a `spline' interpolation program;
- examples of shell scripts using `graph' and `plot'; and a statistics
- toolkit; and output in TekniCAD TDA and ln03 file formats. Email bugs or
- questions to Rich Murphey, `Rich@lamprey.utmb.edu'.
-
- * grep (DjgppD, DosCD, SrcCD, UtilD, UtilT)
-
- This package has GNU `grep', `egrep', and `fgrep' which find lines that
- match inputed patterns. They are much faster than the traditional Unix
- versions.
-
- * Groff (DjgppD, DosCD, SrcCD, UtilT)
-
- Groff is a document formatting system based on an implementation of
- device-independent troff, which also includes implementations of `eqn',
- `nroff', `pic', `refer', `tbl', `troff', and the `man', `ms', and `mm'
- macros, as well as drivers for Postscript, TeX `dvi' format, and
- typewriter-like devices.
-
- Groff's `mm' macro package is almost compatible with the DWB `mm' macros
- and has several extensions. Also included is a modified version of the
- Berkeley `me' macros and an enhanced version of the X11 `xditview'
- previewer. Written in C++, these programs can be compiled with GNU C++
- Version 2.5 or later. A driver for the LaserJet 4 series of printers is
- currently in test.
-
- Groff users are encouraged to contribute enhancements. Most needed are
- complete Texinfo documentation, a `grap' emulation (a `pic' preprocessor
- for typesetting graphs), a page-makeup postprocessor similar to `pm'
- (see `Computing Systems', Vol. 2, No. 2; ask `office@usenix.org' how to
- get a copy) and an ASCII output class for `pic' so that `pic' can be
- integrated with Texinfo. Questions and bug reports from users who have
- read the documentation provided with groff can be sent to
- `bug-groff@prep.ai.mit.edu'.
-
- * `gzip' (DjgppD, DosCD, LangT, LspEmcT, SrcCD, UtilT)
-
- Some of the contents of our tape and FTP distributions are compressed.
- We have software on our tapes and FTP sites to uncompress these files.
- Due to patent troubles with `compress', we use another compression
- program, `gzip'. (Such prohibitions on software development are fought
- by the League for Programming Freedom, *note What Is the LPF::., for
- details.) `gzip' can expand LZW-compressed files but uses another,
- unpatented algorithm for compression which generally produces better
- results. It also expands files compressed with System V's `pack'
- program.
-
- * `hello' (DjgppD, DosCD, SrcCD, UtilT)
-
- The GNU `hello' program produces a familiar, friendly greeting. It
- allows non-programmers to use a classic computer science tool which would
- otherwise be unavailable to them. Because it is protected by the GNU
- General Public License, users are free to share and change it.
-
- Like any truly useful program, `hello' contains a built-in mail reader.
-
- * `hp2xx' (SrcCD, UtilT)
-
- GNU `hp2xx' reads HP-GL files, decomposes all drawing commands into
- elementary vectors, and converts them into a variety of vector and raster
- output formats. It is also an HP-GL previewer. Currently supported
- vector formats include encapsulated Postscript, Uniplex RGIP, Metafont
- and various special TeX-related formats, and simplified HP-GL (line
- drawing only) for imports. Raster formats supported include IMG, PBM,
- PCX, & HP-PCL (including Deskjet & DJ5xxC support). Previewers work
- under X11 (Unix), OS/2 (PM & full screen), MS-DOS (SVGA, VGA, & HGC).
-
- * HylaFAX (UtilT)
-
- HylaFAX is a facsimile system for Unix systems. It supports sending,
- receiving, and polled retrieval of facsimile, as well as transparent
- shared data use of the modem. Information is also available on the
- World Wide Web at URL: `http://www.vix.com/hylafax/'.
-
- * `indent' (DjgppD, DosCD, SrcCD, UtilD, UtilT)
-
- GNU `indent' is a revision of the BSD version. By default, it formats C
- source according to the GNU coding standards. The BSD default, K&R and
- other formats are available as options. It is also possible to define
- your own format. GNU `indent' is more robust and provides more
- functionality than other versions, e.g., it handles C++ comments.
-
- * Ispell (DjgppD, DosCD, SrcCD, UtilT)
-
- Ispell is an interactive spell checker that suggests "near misses" as
- replacements for unrecognized words. System & user-maintained
- dictionaries for multiple languages can be used. Standalone & GNU Emacs
- interfaces are available. Previously, the GNU Project had its own
- version of ispell ("Ispell 4.0"), but has dropped it for a parallel
- branch that has had more development ("Ispell 3.1"). (Version 3 was an
- earlier release from the original Ispell author, but others have since
- made it more sophisticated.)
-
- * JACAL *Not available from the FSF*
-
- JACAL is a symbolic mathematics system for the manipulation and
- simplification of equations and single and multiple-valued algebraic
- expressions constructed of numbers, variables, radicals, differential
- operators, and algebraic and holonomic functions. Vectors, matrices,
- and tensors of these objects are also supported.
-
- JACAL was written in Scheme by Aubrey Jaffer. It comes with SCM, an IEEE
- P1178 and R4RS compliant version of Scheme written in C. SCM runs on
- Amiga, Atari-ST, MS-DOS, OS/2, NOS/VE, Unicos, VMS, Unix, and similar
- systems. SLIB is a portable Scheme library used by JACAL.
- m{No Value For "ergegrafkludge"} The FSF is not distributing JACAL on
- any media. To receive an IBM PC floppy disk with the source and
- executable files, send $99.00 to:
- Aubrey Jaffer
- 84 Pleasant Street
- Wakefield, MA 01880-1846
- USA
-
- * `less' (SrcCD, UtilD, UtilT)
-
- `less' is a display paginator similar to `more' and `pg' but with
- various features (such as the ability to scroll backwards) that most
- pagers lack.
-
- * `m4' (DjgppD, DosCD, SrcCD, UtilD, UtilT)
-
- GNU `m4' is an implementation of the traditional Unix macro processor.
- It is mostly SVR4 compatible, although it has some extensions (for
- example, handling more than 9 positional parameters to macros). `m4'
- also has built-in functions for including files, running shell commands,
- doing arithmetic, etc.
-
- * `make' (BinCD, DjgppD, DosCD, LangT, LspEmcT, SrcCD, UtilD,
- UtilT)
-
- GNU `make' supports POSIX 1003.2 and has all but a few obscure features
- of the BSD and System V versions of `make', as well as many of our own
- extensions. GNU extensions include long options, parallel compilation,
- flexible implicit pattern rules, conditional execution and powerful text
- manipulation functions. Texinfo source for the `Make Manual' comes with
- the program. *Note Documentation::.
-
- GNU `make' is on several of our tapes because some system vendors supply
- no `make' utility at all, and some native `make' programs lack the
- `VPATH' feature essential for using the GNU configure system to its full
- extent. The GNU `make' sources have a shell script to build `make'
- itself on such systems.
-
- MS-DOS binaries for `make' are available with the DJGPP distribution.
-
- * MandelSpawn (SrcCD, UtilT)
-
- A parallel Mandelbrot generation program for the X Window System.
-
- * mtools (SrcCD, UtilT)
-
- mtools is a set of public domain programs to allow Unix systems to read,
- write and manipulate files on an MS-DOS file system (usually a diskette).
-
- * MULE (EmcsD, DosCD, SrcCD)
-
- MULE is a MULtilingual Enhancement to GNU Emacs. It can handle many
- character sets at once including Japanese, Chinese, Korean, Vietnamese,
- Thai, Greek, the ISO Latin-1 through Latin-8 character sets, Ukrainian,
- Arabic, Hebrew, Russian, and other Cyrillic alphabets. A text buffer in
- MULE can contain a mixture of characters from these languages. To input
- any of these characters, you can use various input methods provided by
- MULE itself. In addition, if you use MULE under some terminal emulators
- (kterm, cxterm, or exterm), you can use its input methods. MULE is
- being merged into GNU Emacs. *Note GNU and Other Free Software in
- Japan::, for more information about MULE.
-
- * NetHack (SrcCD, UtilT)
-
- NetHack is a display-oriented adventure game similar to Rogue. Both
- ASCII and X displays are supported.
-
- * NIH Class Library (LangT, SrcCD)
-
- The NIH Class Library (formerly known as "OOPS", Object-Oriented Program
- Support) is a portable collection of C++ classes, similar to those in
- Smalltalk-80, which has been developed by Keith Gorlen of the National
- Institutes of Health (NIH), using the C++ programming language.
-
- * `nvi' (SrcCD, UtilT)
-
- `nvi' is a free implementation of the `vi'/`ex' Unix editor. It has
- most of the functionality of the original `vi'/`ex', except "open" mode
- & the `lisp' option, which will be added. Enhancements over `vi'/`ex'
- include split screens with multiple buffers, handling 8-bit data,
- infinite file & line lengths, tag stacks, infinite undo & extended
- regular expressions. It runs under GNU/Linux, BSD, NetBSD, FreeBSD,
- BSDI, AIX, HP-UX, DGUX, IRIX, PSF, PTX, Solaris, SunOS, Ultrix, Unixware
- & should port easily to many other systems.
-
- * GNU Objective-C Library (LangT, SrcCD)
-
- The GNU Objective-C Class Library (`libobjects') is a library of
- general-purpose, non-graphical Objective-C objects written by Andrew
- McCallum and other volunteers. It includes collection classes for
- maintaining groups of objects and C types, streams for I/O to various
- destinations, coders for formatting objects and C types to streams, ports
- for network packet transmission, distributed objects (remote object
- messaging), string classes, pseudo-random number generators, and time
- handling facilities. The package will also include the foundation
- classes for the GNUStep project; over 50 of these classes have already
- been implemented. The library is known to work on i386, i486, Pentium,
- m68k, SPARC, MIPS, & RS6000. Send queries and bug reports to
- `mccallum@gnu.ai.mit.edu'.
-
- * `OBST' (LangT, SrcCD)
-
- `OBST' is a persistent object management system with bindings to C++.
- `OBST' supports incremental loading of methods. Its graphical tools
- require the X Window System. It features a hands-on tutorial including
- sample programs. It compiles with g++ and should install easily on most
- Unix platforms.
-
- * Octave (LangT, SrcCD)
-
- Octave is a high-level language similar to MATLAB that is primarily
- intended for numerical computations. It provides a convenient command
- line interface for solving linear and nonlinear problems numerically.
- m{No Value For "ergegrafkludge"} Octave does arithmetic for real and
- complex scalars and matrices, solves sets of nonlinear algebraic
- equations, integrates systems of ordinary differential and
- differential-algebraic equations, and integrates functions over finite
- and infinite intervals. Two- and three-dimensional plotting is
- available using `gnuplot'. Send queries and bug reports to:
- `bug-octave@che.utexas.edu'. Source is included for a 220+ page
- Texinfo manual, which is not yet published by the FSF.
-
- * Oleo (SrcCD, UtilT)
-
- Oleo is a spreadsheet program (better for you than the more expensive
- spreadsheets). It supports the X Window System and character-based
- terminals, and can output Embedded Postscript renditions of spreadsheets.
- Keybindings should be familiar to Emacs users and are configurable.
- Under X and in Postscript output, Oleo supports multiple, variable width
- fonts. *Note Forthcoming GNUs::, for the plans for later releases of
- Oleo.
-
- * `p2c' (LangT, SrcCD)
-
- `p2c' is a Pascal-to-C translator written by Dave Gillespie. It
- recognizes many Pascal dialects including Turbo, HP, VAX, and ISO, and
- produces readable, maintainable, portable C.
-
- * `patch' (DjgppD, DosCD, SrcCD, UtilT)
-
- `patch' is our version of Larry Wall's program to take `diff''s output
- and apply those differences to an original file to generate the modified
- version.
-
- * PCL (LspEmcT, SrcCD)
-
- PCL is a free implementation of a large subset of CLOS, the Common Lisp
- Object System. It runs under both GCL and CLISP, mentioned above.
-
- * `perl' (LangT, SrcCD)
-
- Larry Wall's `perl' combines the features and capabilities of `sed',
- `awk', `sh' and C, as well as interfaces to the Unix system calls and
- many C library routines.
-
- * `ptx' (SrcCD, UtilD, UtilT)
-
- GNU `ptx' is our version of the traditional permuted index generator.
- It handles multiple input files at once, produces TeX compatible output,
- & outputs readable "KWIC" (KeyWords In Context) indexes. It does not
- yet handle input files that do not fit in memory all at once.
-
- * `rc' (SrcCD, UtilT)
-
- `rc' is a shell that features a C-like syntax (much more so than `csh')
- and far cleaner quoting rules than the C or Bourne shells. It's
- intended to be used interactively, but is also great for writing
- scripts. It inspired the shell `es'.
-
- * RCS (SrcCD, UtilD, UtilT)
-
- RCS, the Revision Control System, is used for version control &
- management of software projects. When used with GNU `diff', RCS can
- handle binary files (executables, object files, 8-bit data, etc). Also
- see the item about CVS in this section.
-
- * `recode' (SrcCD, UtilT)
-
- GNU `recode' converts files between character sets and usages. When
- exact transliterations are not possible, it may get rid of the offending
- characters or fall back on approximations. This program recognizes or
- produces nearly 150 different character sets and is able to
- transliterate files between almost any pair. Most RFC 1345 character
- sets are supported.
-
- * regex (LangT, SrcCD)
-
- The GNU regular expression library supports POSIX.2, except for
- internationalization features. It is included in many GNU programs which
- do regular expression matching and available separately. An alternative
- regular expression package, `rx', comes with `sed'; it has the potential
- to be faster than `regex' in most cases, but still needs work.
-
- * Scheme (SchmT, SrcCD)
-
- For information about Scheme, see *Note Scheme Tape::.
-
- * `screen' (SrcCD, UtilT)
-
- `screen' is a terminal multiplexer that runs several separate "screens"
- (ttys) on a single character-based terminal. Each virtual terminal
- emulates a DEC VT100 plus several ISO 6429 (ECMA 48, ANSI X3.64) and ISO
- 2022 functions. Arbitrary keyboard input translation is also supported.
- `screen' sessions can be detached and resumed later on a different
- terminal type. Output in detached sessions is saved for later viewing.
-
- * `sed' (DjgppD, DosCD, SrcCD, UtilD, UtilT)
-
- `sed' is a stream-oriented version of `ed'. GNU `sed' comes with the
- `rx' library, a faster version of `regex' (*note Forthcoming GNUs::.).
-
- * Sharutils (SrcCD, UtilT)
-
- `shar' makes so-called shell archives out of many files, preparing them
- for transmission by electronic mail services, while `unshar' helps
- unpack these shell archives after reception. `uuencode' prepares a file
- for transmission over an electronic channel which ignores or otherwise
- mangles the high order bit of bytes, while `uudecode' does the converse
- transformation.
-
- * Shellutils (DjgppD, DosCD, SrcCD, UtilT)
-
- Use shellutils interactively or in shell scripts: `basename', `date',
- `dirname', `echo', `env', `expr', `false', `groups', `hostname', `id',
- `logname', `nice', `nohup', `pathchk', `printenv', `printf', `pwd',
- `sleep', `stty', `su', `tee', `test', `true', `tty', `uname', `users',
- `who', `whoami', and `yes'.
-
- * GNU Shogi (SrcCD, UtilT)
-
- Shogi is a Japanese game similar to Chess; a major difference is that
- captured pieces can be returned into play. GNU Shogi is a variant of
- GNU Chess; GNU Shogi implements the same features as GNU Chess and uses
- similar heuristics. As a new feature, sequences of partial board
- patterns can be introduced in order to help the program play toward
- specific opening patterns. There are both character and X display
- interfaces. GNU Shogi is primarily supported by Matthias Mutz on
- behalf of the FSF.
-
- * Smalltalk (LangT, SrcCD)
-
- GNU Smalltalk is an interpreted object-oriented programming language
- system written in highly portable C. It has been successfully ported to
- many Unix and some other platforms, including DOS (but these non-Unix
- ports are not available from the FSF). Current features include a
- binary image save capability, the ability to invoke user-written C code
- and pass parameters to it, a GNU Emacs editing mode, a version of the X
- protocol invocable from Smalltalk, optional byte-code compilation
- tracing and byte-code execution tracing, and automatically loaded
- per-user initialization files. It implements all of the classes and
- protocol in the Smalltalk-80 book "Smalltalk-80: The Language", except
- for the graphic user interface (`GUI') related classes.
-
- *Note Forthcoming GNUs::, for plans for later releases of Smalltalk.
-
- * Superopt (LangT, SrcCD)
-
- Superopt is a function sequence generator that uses an exhaustive
- generate-and-test approach to find the shortest instruction sequence for
- a given function. You provide a function as input, a CPU to generate
- code for, and how many instructions you can accept. Its application in
- GCC is described in the `ACM SIGPLAN PLDI'92' proceedings. Superopt
- supports: SPARC, m68k, m68020, m88k, IBM RS/6000, AMD 29000, Intel
- 80x86, Pyramid, DEC Alpha, & HP-PA.
-
- * `tar' (SrcCD, UtilT)
-
- GNU `tar' includes multivolume support, the ability to archive sparse
- files, automatic archive compression/decompression, remote archives and
- special features that allow `tar' to be used for incremental and full
- backups. Unfortunately, GNU `tar' implements an early draft of the
- POSIX 1003.1 `ustar' standard which is different from the final
- standard. Adding support for the new changes in a backward-compatible
- fashion is not trivial.
-
- * Termcap Library (SrcCD, UtilT)
-
- The GNU Termcap library is a drop-in replacement for `libtermcap.a' on
- any system. It does not place an arbitrary limit on the size of Termcap
- entries, unlike most other Termcap libraries. Included is source for the
- `Termcap Manual' in Texinfo format. *Note Documentation::.
-
- * TeX (SrcCD)
-
- TeX is a document formatting system that handles complicated
- typesetting, including mathematics. It is GNU's standard text formatter.
-
- You can obtain TeX from the University of Washington, which maintains and
- supports a tape distribution of TeX for Unix systems. The core material
- consists of Karl Berry's `web2c' TeX package, the sources for which are
- available via anonymous ftp; retrieval instructions are in
- `pub/tex/unixtex.ftp' on `ftp.cs.umb.edu'. If you receive any
- installation support from the University of Washington, please consider
- sending them a donation.
-
- To order a full distribution written in `tar' on either a 1/4inch
- 4-track QIC-24 cartridge or a 4mm DAT cartridge, send $210.00 to:
-
- Pierre A. MacKay
- Department of Classics
- DH-10, Denny Hall 218
- University of Washington
- Seattle, WA 98195
- USA
-
- Electronic-Mail: `mackay@cs.washington.edu'
- Telephone: +1-206-543-2268
-
- Please make checks payable to the University of Washington. Do not
- specify any other payee. That causes accounting difficulties. Checks
- must be in U.S. dollars, drawn on a U.S. bank. Prepaid orders are the
- only orders that can now be handled. Overseas sites: please add to the
- base cost $20.00 for shipment via air parcel post, or $30.00 for
- shipment via courier. Please check with the above for current prices
- and formats.
-
- * Texinfo (DjgppD, DosCD, LangT, LspEmcT, SrcCD, UtilD, UtilT)
-
- Texinfo is a set of utilities which generate both printed manuals and
- online hypertext documentation (called "Info"). There are also programs
- for reading online Info documents. Version 3 has both GNU Emacs Lisp
- and standalone programs written in C or shell script. Texinfo mode for
- GNU Emacs enables easy editing and updating of Texinfo files. Programs
- provided include `makeinfo', `info', `texi2dvi', `texindex', `tex2patch',
- and `fixfonts'. Source for the `Texinfo Manual' is included. *Note
- Documentation::.
-
- * Textutils (DjgppD, DosCD, SrcCD, UtilT)
-
- The Textutils programs manipulate textual data. They include: `cat',
- `cksum', `comm', `csplit', `cut', `expand', `fmt', `fold', `head',
- `join', `nl', `od', `paste', `pr', `sort', `split', `sum', `tac', `tail',
- `tr', `unexpand', `uniq', and `wc'.
-
- * Tile Forth (LangT, SrcCD)
-
- Tile Forth is a 32-bit implementation of the Forth-83 standard written
- in C, allowing it to be easily ported to new systems, and extended with
- "any" C-function (graphics, windowing, etc). Many Forth libraries with
- full documentation are available including ones for top-down parsing,
- multi-threads, and object oriented programming.
-
- * `time' (SrcCD, UtilT)
-
- `time' is used to report statistics (usually from a shell) about the
- amount of user, system and real time used by a process. On some systems
- it also reports memory usage, page faults, and other statistics.
-
- * `tput' (SrcCD, UtilT)
-
- `tput' is a portable way for shell scripts to use special terminal
- capabilities. Our `tput' uses the Termcap database, instead of Terminfo
- as most others do.
-
- * UUCP (SrcCD, UtilT)
-
- This version of UUCP was written by Ian Lance Taylor, and is GNU's
- standard UUCP system. It supports the `f', `g' and `v' (in all window
- and packet sizes), `G', `t', `e', Zmodem and two new bidirectional (`i'
- and `j') protocols. If you have a Berkeley sockets library, it can make
- TCP connections. If you have TLI libraries, it can make TLI
- connections. Source is included for a Texinfo manual, which is not yet
- published by the FSF.
-
- * `wdiff' (DjgppD, DosCD, SrcCD, UtilT)
-
- `wdiff' is a front-end to GNU `diff'. It compares two files, finding
- the words deleted or added to the first to make the second. It has many
- output formats and works well with terminals and pagers. `wdiff' is
- very useful when two texts differ only by a few words and paragraphs
- have been refilled.
-
- * `Ygl' (SrcCD, UtilT)
-
- `Ygl' emulates SGI's GL (Graphics Language) library under X11. It runs
- under GNU/Linux with XFree, AIX 3.2, ConvexOS, HP-UX 7.0/8.0/9.0, SunOS
- and many others.
-
-
-
-Program/Package Cross Reference - (NOT COMPLETELY UP TO DATE)
-*******************************
-
-Here is a list of what package each GNU program or library is in. You can
-anonymously FTP a full list in the file `/pub/gnu/ProgramIndex' from a GNU
-FTP host (*note How to Get GNU Software::. for a list).
-
- * a2p perl
- * a2x xopt
- * ac bsd44
- * accton bsd44
- * acl bsd44
- * acm acm
- * acms acm
- * addftinfo Groff
- * adventure bsd44
- * afm2tfm TeX
- * amd bsd44
- * ansitape bsd44
- * AnswerGarden xopt
- * apply bsd44
- * appres xreq
- * apropos bsd44
- * ar Binutils
- * arithmetic bsd44
- * arp bsd44
- * atc bsd44
- * autoconf Autoconf
- * autoheader Autoconf
- * autoreconf Autoconf
- * autoscan Autoconf
- * autoupdate Autoconf
- * auto_box xopt
- * auto_box xreq
-
- * b2m Emacs
- * backgammon bsd44
- * bad144 bsd44
- * badsect bsd44
- * banner bsd44
- * basename Shellutils
- * bash BASH
- * battlestar bsd44
- * bc bc
- * bcd bsd44
- * bdes bsd44
- * bdftops Ghostscript
- * beach_ball xopt
- * beach_ball xreq
- * beach_ball2 xopt
- * bibtex TeX
- * biff bsd44
- * bison Bison
- * bitmap xreq
- * boggle bsd44
- * bpltobzr Fontutils
- * bugfiler bsd44
- * build ispell
- * bzrto Fontutils
-
- * c++ GCC
- * c++filt Binutils
- * c2ph perl
- * ca100 xopt
- * caeser bsd44
- * cal bsd44
- * calendar bsd44
- * canfield bsd44
- * cat Textutils
- * cbars wdiff
- * cc GCC
- * cc1 GCC
- * cc1obj GCC
- * cc1plus GCC
- * cccp GCC
- * charspace Fontutils
- * checknr bsd44
- * chess bsd44
- * chflags bsd44
- * chgrp Fileutils
- * ching bsd44
- * chmod Fileutils
- * chown Fileutils
- * chpass bsd44
- * chroot bsd44
- * ci RCS
- * cksum Textutils
- * clisp CLISP
- * clri bsd44
- * cmail xboard
- * cmmf TeX
- * cmodext xopt
- * cmp Diffutils
- * co RCS
- * col bsd44
- * colcrt bsd44
- * colrm bsd44
- * column bsd44
- * comm Textutils
- * compress bsd44
- * comsat bsd44
- * connectd bsd44
- * cp Fileutils
- * cpicker xopt
- * cpio cpio
- * cpp GCC
- * cppstdin perl
- * cribbage bsd44
- * crock xopt
- * csh bsd44
- * csplit Textutils
- * ctags Emacs
- * ctwm xopt
- * cu UUCP
- * cut Textutils
- * cvs CVS
- * cvscheck CVS
- * cvtmail Emacs
- * cxterm xopt
-
- * d Fileutils
- * date Shellutils
- * dc bc
- * dd Fileutils
- * delatex TeX
- * demangle Binutils
- * descend CVS
- * detex TeX
- * df Fileutils
- * diff Diffutils
- * diff3 Diffutils
- * digest-doc Emacs
- * dipress bsd44
- * dir Fileutils
- * dirname Shellutils
- * dish xopt
- * disklabel bsd44
- * diskpart bsd44
- * dld dld
- * dm bsd44
- * dmesg bsd44
- * doschk doschk
- * dox xopt
- * du Fileutils
- * dump bsd44
- * dumpfs bsd44
- * dvi2tty TeX
- * dvicopy TeX
- * dvips TeX
- * dvitype TeX
-
- * ecc ecc
- * echo Shellutils
- * ed ed
- * edit-pr GNATS
- * editres xreq
- * edquota bsd44
- * eeprom bsd44
- * egrep grep
- * emacs Emacs
- * emacsclient Emacs
- * emacsserver Emacs
- * emacstool Emacs
- * emu xopt
- * env Shellutils
- * eqn Groff
- * error bsd44
- * es es
- * esdebug es
- * etags Emacs
- * ex nvi
- * expand Textutils
- * expect DejaGnu
- * expr Shellutils
- * exterm xopt
-
- * f2c f2c
- * factor bsd44
- * fakemail Emacs
- * false Shellutils
- * fastboot bsd44
- * fax2ps HylaFAX
- * faxalter HylaFAX
- * faxanswer HylaFAX
- * faxcover HylaFAX
- * faxd HylaFAX
- * faxd.recv HylaFAX
- * faxmail HylaFAX
- * faxquit HylaFAX
- * faxrcvd HylaFAX
- * faxrm HylaFAX
- * faxstat HylaFAX
- * fc f2c
- * fdraw xopt
- * fgrep grep
- * file bsd44
- * find Findutils
- * find2perl perl
- * finger finger
- * fingerd finger
- * fish bsd44
- * fixfonts Texinfo
- * fixinc.svr4 GCC
- * fixincludes GCC
- * flex flex
- * fmt bsd44
- * fold Textutils
- * font2c Ghostscript
- * fontconvert Fontutils
- * forth Tile Forth
- * forthicon Tile Forth
- * forthtool Tile Forth
- * fortune bsd44
- * fpr bsd44
- * freq ispell
- * freqtbl ispell
- * from bsd44
- * fsck bsd44
- * fsplit bsd44
- * fstat bsd44
- * ftp bsd44
- * ftpd bsd44
-
- * g++ GCC
- * gas Binutils
- * gawk Gawk
- * gcc GCC
- * gcore bsd44
- * gdb GDB
- * genclass libg++
- * getty bsd44
- * gftodvi TeX
- * gftopk TeX
- * gftype TeX
- * ghostview Ghostview
- * gnats GNATS
- * gnuchess Chess
- * gnuchessc Chess
- * gnuchessn Chess
- * gnuchessr Chess
- * gnuchessx Chess
- * gnupdisp Shogi
- * gnuplot gnuplot
- * gnuplot_x11 gnuplot
- * gnushogi Shogi
- * gnushogir Shogi
- * gnushogix Shogi
- * go GnuGo
- * gpc xopt
- * gpc xreq
- * gperf gperf
- * gperf libg++
- * gprof Binutils
- * graph Graphics
- * grep grep
- * grodvi Groff
- * groff Groff
- * grops Groff
- * grotty Groff
- * groups Shellutils
- * gs Ghostscript
- * gsbj Ghostscript
- * gsdj Ghostscript
- * gslj Ghostscript
- * gslp Ghostscript
- * gsnd Ghostscript
- * gsrenderfont Fontutils
- * gunzip gzip
- * gwm xopt
- * gzexe gzip
- * gzip gzip
-
- * h2ph perl
- * h2pl perl
- * hack bsd44
- * hangman bsd44
- * head Textutils
- * hello hello
- * hexdump bsd44
- * hexl Emacs
- * hostname Shellutils
- * hp2xx hp2xx
- * hterm xopt
-
- * i18nOlwmV2 xopt
- * i2mif xopt
- * ico xopt
- * ico xreq
- * id Shellutils
- * ident RCS
- * ifconfig bsd44
- * ifnames Autoconf
- * ImageMagick xopt
- * imageto Fontutils
- * iman xopt
- * imgrotate Fontutils
- * indent indent
- * indxbib Groff
- * inetd bsd44
- * info Texinfo
- * inimf TeX
- * init bsd44
- * initex TeX
- * inn bsd44
- * install Fileutils
- * iostat bsd44
- * ispell ispell
- * ixterm xopt
- * ixx xopt
-
- * join Textutils
- * jot bsd44
- * jove bsd44
-
- * kdestroy bsd44
- * kdump bsd44
- * kermit bsd44
- * kgames xopt
- * kgmon bsd44
- * kill bsd44
- * kinit bsd44
- * kinput2 xopt
- * klist bsd44
- * kpasswdd bsd44
- * ksrvtgt bsd44
- * kterm xopt
- * ktrace bsd44
-
- * lam bsd44
- * larn bsd44
- * lasergnu gnuplot
- * last bsd44
- * lastcomm bsd44
- * latex TeX
- * lclock xopt
- * ld Binutils
- * leave bsd44
- * less less
- * lesskey less
- * libbfd.a Binutils
- * libbfd.a GAS
- * libbfd.a GDB
- * libbzr.a Fontutils
- * libc.a C Library
- * libcompat.a bsd44
- * libcurses.a bsd44
- * libcurses.a nvi
- * libedit.a bsd44
- * libF77.a f2c
- * libg++.a libg++
- * libgdbm.a gdbm
- * libgf.a Fontutils
- * libgmp.a gmp
- * libI77.a f2c
- * libkvm.a bsd44
- * libm.a bsd44
- * libnihcl.a NIHCL
- * libnihclmi.a NIHCL
- * libnihclvec.a NIHCL
- * libnls.a xreq
- * liboctave.a Octave
- * liboldX.a xreq
- * libpbm.a Fontutils
- * libPEXt.a xopt
- * libpk.a Fontutils
- * libresolv.a bsd44
- * librpc.a bsd44
- * libtcl.a DejaGnu
- * libtelnet.a bsd44
- * libterm.a bsd44
- * libtermcap.a Termcap
- * libtfm.a Fontutils
- * libutil.a bsd44
- * libWc.a xopt
- * libwidgets.a Fontutils
- * libX.a xreq
- * libXau.a xreq
- * libXaw.a xreq
- * libXcp.a xopt
- * libXcu.a xopt
- * libXdmcp.a xreq
- * libXmp.a xopt
- * libXmu.a xreq
- * libXO.a xopt
- * libXop.a xopt
- * libXp.a xopt
- * libXpex.a xopt
- * libXt.a xopt
- * libXt.a xreq
- * libXwchar.a xopt
- * liby.a bsd44
- * libYgl.a Ygl
- * limn Fontutils
- * listres xopt
- * listres xreq
- * lkbib Groff
- * ln Fileutils
- * locate Findutils
- * lock bsd44
- * logger bsd44
- * login bsd44
- * logname Shellutils
- * look ispell
- * lookbib Groff
- * lorder bsd44
- * lpr bsd44
- * ls Fileutils
-
- * m4 m4
- * mail bsd44
- * make Make
- * make-docfile Emacs
- * make-path Emacs
- * makeindex TeX
- * makeinfo Texinfo
- * MakeTeXPK TeX
- * man bsd44
- * man-macros Groff
- * mattrib mtools
- * maze xopt
- * maze xreq
- * mazewar xopt
- * mcd mtools
- * mcopy mtools
- * mdel mtools
- * mdir mtools
- * me-macros Groff
- * merge RCS
- * mesg bsd44
- * mf TeX
- * mformat mtools
- * mft TeX
- * mgdiff xopt
- * mh bsd44
- * mille bsd44
- * mkdep bsd44
- * mkdir Fileutils
- * mkfifo Fileutils
- * mklocale bsd44
- * mkmanifest mtools
- * mkmf bsd44
- * mkmodules CVS
- * mknod Fileutils
- * mkstr bsd44
- * mlabel mtools
- * mm-macros Groff
- * mmd mtools
- * monop bsd44
- * more bsd44
- * morse bsd44
- * mount bsd44
- * mountd bsd44
- * movemail Emacs
- * mprof bsd44
- * mrd mtools
- * mread mtools
- * mren mtools
- * ms-macros Groff
- * msgs bsd44
- * mt cpio
- * mterm xopt
- * mtree bsd44
- * mtype mtools
- * mule MULE
- * muncher xopt
- * mv Fileutils
- * mvdir Fileutils
- * mwrite mtools
-
- * nethack Nethack
- * netstat bsd44
- * newfs bsd44
- * nfsd bsd44
- * nfsiod bsd44
- * nfsstat bsd44
- * nice Shellutils
- * nl Textutils
- * nlmconv Binutils
- * nm Binutils
- * nohup Shellutils
- * notify HylaFAX
- * nroff Groff
- * number bsd44
-
- * objc GCC
- * objcopy Binutils
- * objdump Binutils
- * objective-c GCC
- * obst-boot OBST
- * obst-CC OBST
- * obst-cct OBST
- * obst-cgc OBST
- * obst-cmp OBST
- * obst-cnt OBST
- * obst-cpcnt OBST
- * obst-csz OBST
- * obst-dir OBST
- * obst-dmp OBST
- * obst-gen OBST
- * obst-gsh OBST
- * obst-init OBST
- * obst-scp OBST
- * obst-sil OBST
- * obst-stf OBST
- * oclock xreq
- * octave Octave
- * od Textutils
- * oleo Oleo
- * ora-examples xopt
-
- * p2c p2c
- * pagesize bsd44
- * palette xopt
- * pascal bsd44
- * passwd bsd44
- * paste Textutils
- * patch patch
- * patgen TeX
- * pathalias bsd44
- * pathchk Shellutils
- * pax bsd44
- * pbmplus xopt
- * perl perl
- * pfbtops Groff
- * phantasia bsd44
- * pic Groff
- * pig bsd44
- * ping bsd44
- * pixedit xopt
- * pixmap xopt
- * pktogf TeX
- * pktype TeX
- * plaid xopt
- * plot2fig Graphics
- * plot2plot Graphics
- * plot2ps Graphics
- * plot2tek Graphics
- * pltotf TeX
- * pollrcvd HylaFAX
- * pom bsd44
- * pooltype TeX
- * portmap bsd44
- * ppt bsd44
- * pr Textutils
- * pr-addr GNATS
- * pr-edit GNATS
- * primes bsd44
- * printenv Shellutils
- * printf Shellutils
- * protoize GCC
- * ps bsd44
- * ps2ascii Ghostscript
- * ps2epsi Ghostscript
- * ps2fax HylaFAX
- * psbb Groff
- * pstat bsd44
- * psycho xopt
- * ptx ptx
- * pubdic+ xopt
- * puzzle xopt
- * puzzle xreq
- * pwd Shellutils
- * pyramid xopt
-
- * query-pr GNATS
- * quiz bsd44
- * quot bsd44
- * quota bsd44
- * quotacheck bsd44
- * quotaon bsd44
-
- * rain bsd44
- * random bsd44
- * ranlib Binutils
- * rbootd bsd44
- * rc rc
- * rcp bsd44
- * rcs RCS
- * rcs-to-cvs CVS
- * rcs2log Emacs
- * rcsdiff RCS
- * rcsfreeze RCS
- * rcsmerge RCS
- * rdist bsd44
- * reboot bsd44
- * recode recode
- * recvstats HylaFAX
- * refer Groff
- * renice bsd44
- * repquota bsd44
- * restore bsd44
- * rev bsd44
- * rexecd bsd44
- * rlog RCS
- * rlogin bsd44
- * rlogind bsd44
- * rm Fileutils
- * rmail bsd44
- * rmdir Fileutils
- * rmt cpio
- * rmt tar
- * robots bsd44
- * rogue bsd44
- * route bsd44
- * routed bsd44
- * rr xopt
- * rs bsd44
- * rsh bsd44
- * rshd bsd44
- * runtest DejaGnu
- * runtest.exp DejaGnu
- * ruptime bsd44
- * rwho bsd44
- * rwhod bsd44
-
- * s2p perl
- * sail bsd44
- * savecore bsd44
- * sc bsd44
- * sccs bsd44
- * sccs2rcs CVS
- * scdisp xopt
- * screen screen
- * script bsd44
- * scsiformat bsd44
- * sctext xopt
- * sdiff Diffutils
- * sed sed
- * send-pr GNATS
- * sendfax HylaFAX
- * sendmail bsd44
- * sgi2fax HylaFAX
- * sh bsd44
- * shar Sharutils
- * shinbun xopt
- * shogi Shogi
- * showfont xopt
- * showmount bsd44
- * shutdown bsd44
- * size Binutils
- * sj3 xopt
- * sjxa xopt
- * slattach bsd44
- * sleep Shellutils
- * sliplogin bsd44
- * snake bsd44
- * snftobdf xopt
- * soelim Groff
- * sort Textutils
- * sos2obst OBST
- * spider xopt
- * split Textutils
- * startslip bsd44
- * stf OBST
- * strings Binutils
- * strip Binutils
- * stty Shellutils
- * su Shellutils
- * sum Textutils
- * superopt Superopt
- * swapon bsd44
- * sync bsd44
- * sysctl bsd44
- * syslogd bsd44
- * systat bsd44
-
- * tac Textutils
- * tail Textutils
- * taintperl perl
- * talk bsd44
- * talkd bsd44
- * tangle TeX
- * tar tar
- * tbl Groff
- * tcl DejaGnu
- * tclsh DejaGnu
- * tcopy bsd44
- * tcp Emacs
- * tee Shellutils
- * tek2plot Graphics
- * telnet bsd44
- * telnetd bsd44
- * test Shellutils
- * test-g++ DejaGnu
- * test-tool DejaGnu
- * tetris bsd44
- * tex TeX
- * tex3patch Texinfo
- * texi2dvi Texinfo
- * texindex Texinfo
- * texspell TeX
- * textfmt HylaFAX
- * tfmtodit Groff
- * tftopl TeX
- * tftp bsd44
- * tftpd bsd44
- * tgrind TeX
- * time time
- * timed bsd44
- * timer Emacs
- * timex xopt
- * tip bsd44
- * tkpostage xopt
- * tn3270 bsd44
- * touch Fileutils
- * tput tput
- * tr Textutils
- * traceroute bsd44
- * transcript HylaFAX
- * transfig xopt
- * trek bsd44
- * trn3 bsd44
- * troff Groff
- * trpt bsd44
- * trsp bsd44
- * true Shellutils
- * tset bsd44
- * tsort bsd44
- * tty Shellutils
- * tunefs bsd44
- * tvtwm xopt
- * twm xreq
-
- * ul bsd44
- * umount bsd44
- * uname Shellutils
- * uncompress gzip
- * unexpand Textutils
- * unifdef bsd44
- * uniq Textutils
- * unprotoize GCC
- * unshar Sharutils
- * unvis bsd44
- * update bsd44
- * updatedb Findutils
- * users Shellutils
- * uuchk UUCP
- * uucico UUCP
- * uuconv UUCP
- * uucp UUCP
- * uucpd bsd44
- * uudecode Sharutils
- * uudir UUCP
- * uuencode Sharutils
- * uulog UUCP
- * uuname UUCP
- * uupick UUCP
- * uurate UUCP
- * uusched UUCP
- * uustat UUCP
- * uuto UUCP
- * uux UUCP
- * uuxqt UUCP
-
- * v Fileutils
- * vacation bsd44
- * vandal xopt
- * vcdiff Emacs
- * vdir Fileutils
- * vftovp TeX
- * vgrind bsd44
- * vi nvi
- * viewres xopt
- * viewres xreq
- * vine xopt
- * vipw bsd44
- * virmf TeX
- * virtex TeX
- * vis bsd44
- * vmstat bsd44
- * vptovf TeX
-
- * w bsd44
- * wakeup Emacs
- * wall bsd44
- * wargames bsd44
- * wc Textutils
- * wdiff wdiff
- * weave TeX
- * what bsd44
- * whatis bsd44
- * whereis bsd44
- * who Shellutils
- * whoami Shellutils
- * whois bsd44
- * window bsd44
- * winterp xopt
- * wish DejaGnu
- * worm bsd44
- * worms bsd44
- * write bsd44
- * wump bsd44
-
- * x11perf xreq
- * x2p perl
- * xalarm xopt
- * xancur xopt
- * xargs Findutils
- * xauth xreq
- * xbfe Fontutils
- * xbiff xopt
- * xbiff xreq
- * xboard xboard
- * xboing xopt
- * xbuffy3 xopt
- * xcalc xopt
- * xcalc xreq
- * xcalendar xopt
- * xcdplayer xopt
- * xcell xopt
- * xclipboard xreq
- * xclock xreq
- * xcmdmenu xopt
- * xcms xopt
- * xcmsdb xreq
- * xcmstest xreq
- * xco xopt
- * xcolorize xopt
- * xcolors xopt
- * xconsole xreq
- * xcrtca xopt
- * xdaliclock xopt
- * xdiary xopt
- * xditview Groff
- * xditview xopt
- * xditview xreq
- * xdm xreq
- * xdpyinfo xreq
- * xdu xopt
- * xdvi TeX
- * xdvi xopt
- * xdvorak xopt
- * xearth xopt
- * xed xopt
- * xedit xopt
- * xedit xreq
- * xev xopt
- * xev xreq
- * xexit xopt
- * xeyes xopt
- * xeyes xreq
- * xfd xreq
- * xfed xopt
- * xfedor xopt
- * xfeoak xopt
- * xferstats HylaFAX
- * xfig xopt
- * xfontsel xopt
- * xfontsel xreq
- * xforecast xopt
- * xgas xopt
- * xgas xreq
- * xgc xopt
- * xgc xreq
- * xhearts xopt
- * xhelp xopt
- * xhost xreq
- * xinit xreq
- * xkeycaps xopt
- * xkill xreq
- * xlax xopt
- * xlayout xopt
- * xlbiff xopt
- * xless xopt
- * xload xopt
- * xload xreq
- * xlogin xopt
- * xlogo xreq
- * xlsatoms xreq
- * xlsclients xreq
- * xlsfonts xreq
- * xmag xreq
- * xmail xopt
- * xmailbox xopt
- * xmailwatcher xopt
- * xman xopt
- * xman xreq
- * xmandel xopt
- * xmessage xopt
- * xmeter xopt
- * xmh xreq
- * xmh-icons xopt
- * xmh.editor xopt
- * xmodmap xreq
- * xmon xopt
- * xmove xopt
- * xmphone xopt
- * xpd xopt
- * xphoon xopt
- * xpipeman xopt
- * xplot Graphics
- * xpostit xopt
- * xpr xopt
- * xpr xreq
- * xprompt xopt
- * xproof xopt
- * xprop xreq
- * xpserv xopt
- * xrdb xreq
- * xrefresh xreq
- * xrsh xopt
- * xrubik xopt
- * xrunclient xopt
- * xscope xopt
- * xscreensaver xopt
- * xsession xopt
- * xset xreq
- * xsetroot xreq
- * xshogi xshogi
- * xstdcmap xreq
- * xstr bsd44
- * xtalk xopt
- * xterm xreq
- * xterm_color xopt
- * xtetris xopt
- * xTeXcad.13 xopt
- * xtiff xopt
- * xtree xopt
- * xtv xopt
- * xwd xreq
- * xwininfo xreq
- * xwud xreq
-
- * yacc bsd44
- * yes Shellutils
- * youbin xopt
- * yow Emacs
-
- * zcat gzip
- * zcmp gzip
- * zdiff gzip
- * zforce gzip
- * zgrep gzip
- * zmore gzip
- * znew gzip
-
- * [ Shellutils
-
-
-
-Tapes
-*****
-
-We offer Unix source code on tapes in `tar' format on these media:
-
- * 4mm DAT cartridges
-
- * 8mm Exabyte cartridges
-
- * Sun DC300XLP QIC-24 1/4in cartridges (readable on some other systems)
-
- * Hewlett-Packard 16-track DC600HC 1/4in cartridges
-
- * IBM RS/6000 QIC-150 1/4in cartridges (readable on some other systems)
-
- * 1600bpi 9-track 1/2in reel tape
-
-The contents of the reel and various cartridge tapes for Unix systems are the
-same (except for the RS/6000 Emacs tape, which also has executables for
-Emacs); only the media are different. For pricing information, see the *note
-Free Software Foundation Order Form::.. Source code for the manuals and
-reference cards is included (*note Documentation::.).
-
-Some of the files on the tapes may be compressed with `gzip' to make them
-fit. Refer to the top-level `README' file at the beginning of each tape for
-instructions on uncompressing them. `uncompress' and `unpack' *do not work*!
-
-
-
-Languages Tape - (VERSION NUMBERS NOT COMPLETELY UP TO DATE)
---------------
-
-This tape contains programming tools: compilers, interpreters, and related
-programs (parsers, conversion programs, debuggers, etc.).
-
- * Binutils 2.5.2
- * Bison 1.22
- * C Library 1.09
- * DejaGnu 1.2
- * dld 3.2.3
- * ecc 1.2.1
- * f2c 1994.11.03
- * flex 2.4.7
- * Gawk 2.15.5
- * GCC/G++/Objective-C 2.7.0
- * GDB 4.13
- * gdbm 1.7.3
- * gmp 1.3.2
- * gperf 2.1a
- * gzip 1.2.4
- * indent 1.9.1
- * libg++ 2.6.1
- * libobjects 0.1.0
- * Make 3.72.1
- * NIHCL 3.0
- * OBST 3.4
- * Octave 1.0
- * p2c 1.20
- * perl 4.036
- * perl 5.000
- * regex 0.12
- * rx 0.05
- * Smalltalk 1.1.1
- * Superopt 2.3
- * Texinfo 3.1
- * Tile Forth 2.1
-
-
-
-Lisps and Emacs Tape - (VERSION NUMBERS NOT COMPLETELY UP TO DATE)
---------------------
-
-This tape has Common Lisp systems and libraries, GNU Emacs, assorted
-extensions that work with GNU Emacs, and a few other important utilities.
-
- * Calc 2.02c
- * CLISP 1994.10.26
- * Common Lisp 1.1
- * elib 0.06
- * Emacs 18.59
- * Emacs 19.29
- * GNU Emacs Lisp Reference Manaul, Ed. 2.3
- * gzip 1.2.4
- * Make 3.72.1
- * MULE 2.1
- * PCL 1993.03.18
- * Texinfo 3.1
-
-
-
-Utilities Tape - (VERSION NUMBERS NOT COMPLETELY UP TO DATE)
---------------
-
-This tape consists mostly of smaller utilities and miscellaneous applications.
-
- * acm 4.6
- * Autoconf 1.11
- * Autoconf 2.1
- * BASH 1.14.2
- * bc 1.03
- * Chess 4.0.73
- * cpio 2.3
- * CVS 1.3
- * dc 0.2
- * Diffutils 2.7
- * doschk 1.1
- * ed 0.2
- * es 0.84
- * Fileutils 3.12
- * Findutils 4.1
- * finger 1.37
- * HylaFAX 2.2.2.1
- * Fontutils 0.6
- * Ghostscript 2.6.1
- * Ghostview 1.5
- * GNATS 3.2
- * GnuGo 1.1
- * gnuplot 3.5
- * Graphics 0.17
- * grep 2.0
- * Groff 1.09
- * gzip 1.2.4
- * hello 1.3
- * hp2xx 3.1.4
- * ispell 3.1.13
- * m4 1.3
- * Make 3.72.1
- * mkisofs 1.01
- * mm 1.07
- * mtools 2.0.7
- * Nethack 3.1.3
- * nvi 1.34
- * Oleo 1.6
- * patch 2.1
- * ptx 0.4
- * rc 1.4
- * RCS 5.6.0.1
- * recode 3.4
- * saoimage 1.08
- * screen 3.5.2
- * screen 3.6.0
- * sed 1.18 & 2.05
- * Sharutils 4.1
- * Shellutils 1.12
- * Shogi 1.2.02
- * tar 1.11.2
- * Termcap 1.2
- * Texinfo 3.1
- * Textutils 1.11
- * time 1.6
- * tput 1.0
- * UUCP 1.05
- * wdiff 0.04
- * xboard 3.1.1
- * xshogi 1.2.02
- * Ygl 2.9
-
-
-
-Scheme Tape
------------
-
-Scheme is a simplified, lexically-scoped dialect of Lisp. It was designed at
-MIT and other universities to teach students the art of programming, and to
-research new parallel programming constructs and compilation techniques.
-
-This tape now contains MIT Scheme 7.3, which conforms to the "Revised^4
-Report On the Algorithmic Language Scheme" (MIT AI Lab Memo 848b), for which
-TeX source is included. It is written partly in C, but is presently hard to
-bootstrap. Binaries that can be used to bootstrap Scheme are available for:
-
- * HP 9000 series 300, 400, 700 & 800 running HP-UX 7.0 or 8.0
-
- * NeXT running NeXT OS 1.0 or 2.0
-
- * Sun-3 or Sun-4 running SunOS 4.1
-
- * DECstation 3100/5100 running Ultrix 4.0
-
- * Sony NeWS-3250 running NEWS OS 5.01
-
- * Vax running 4.3BSD
-
-If your system is not on this list and you don't enjoy the bootstrap
-challenge, see the JACAL item in *Note GNU Software::.
-
-
-
-X11 Tapes
----------
-
-The two X11 tapes contain Version 11, Release 6 of the X Window System. The
-first tape contains all of the core software, documentation and some
-contributed clients. We call this the "required" X tape since it is
-necessary for running X or running GNU Emacs under X. The second, "optional"
-tape contains contributed libraries and other toolkits, the Andrew User
-Interface System, games, and other programs.
-
-The X11 Required tape also contains all fixes and patches released to date.
-We update this tape as new fixes and patches are released for programs on
-both tapes. *Note Tape & CD-ROM Subscription Service::.
-
-We will distribute X11R5 on tape until X11R6 is stable, and on the *Note
-November 1993 Source Code CD-ROM::, while supplies last.
-
-
-
-Berkeley 4.4BSD-Lite Tape
--------------------------
-
-The "4.4BSD-Lite" release is the last from the Computer Systems Research
-Group at the University of California at Berkeley. It has most of the BSD
-software system, except for a few files that remain proprietary. It is much
-more complete than the previous "Net2" release.
-
-
-
-VMS Emacs and VMS Compiler Tapes
---------------------------------
-
-We offer two VMS tapes. One has just GNU Emacs 18.59 (none of the other
-software on the *Note Lisps/Emacs Tape::, is included). The other has GCC
-2.3.3, Bison 1.19 (to compile GCC), GAS 1.38 (to assemble GCC's output) and
-some library and include files (none of the other software on the *Note
-Languages Tape::, is included). We are not aware of a GDB port for VMS.
-Both VMS tapes have DEC VAX executables from which you can bootstrap, as the
-DEC VMS C compiler cannot compile GCC. We do not have executables for DEC
-Alpha VMS systems. Please do not ask us to devote effort to VMS support,
-because it is peripheral to the GNU Project.
-
-
-
-CD-ROMs
-*******
-
-We offer these CD-ROMs:
-
- * *Note MS-DOS CD-ROM::, expected in September 1995.
-
- * *Note Debian GNU/Linux CD-ROM::, expected in late fall 1995.
-
- * *Note Compiler Tools Binaries CD-ROM::.
-
- * *Note June 1995 Source Code CD-ROM::.
-
- * *Note May 1994 Source Code CD-ROM::.
-
- * *Note November 1993 Source Code CD-ROM::.
-
-Our CD-ROMs are in ISO 9660 format & can be mounted as a read-only file
-system on most computers. If your driver supports it you can mount each
-CD-ROM with "Rock Ridge" extensions (the MS-DOS CD-ROM is only in ISO 9660
-format) & it will look just like an ordinary Unix file system, rather than
-one full of truncated & otherwise mangled names that fit vanilla ISO 9660.
-
-You can build most of the software without copying the sources off the CD.
-You only need enough disk space for object files and intermediate build
-targets.
-
-
-
-Pricing of the GNU CD-ROMs
---------------------------
-
-If a business or organization is ultimately paying, the June 1995 Source CD
-costs $240. It costs $60 if you, an individual, are paying out of your own
-pocket. The December 1994 Compiler Tools Binaries CD-ROM costs $220 for a
-business or organization, and $55 for an individual.
-
-
-
-What do the individual and company prices mean?
-
-The software on our disk is free; anyone can copy it and anyone can run it.
-What we charge for is the physical disk and the service of distribution.
-
-We charge two different prices depending on who is buying. When a company or
-other organization buys the June 1995 Source CD-ROM, we charge $240. When an
-individual buys the same disk, we charge just $60.
-
-This distinction is not a matter of who is allowed to use the software. In
-either case, once you have a copy, you can distribute as many copies as you
-wish, and there's no restriction on who can have or run them. The price
-distinction is entirely a matter of what kind of entity pays for the CD.
-
-You, the reader, are certainly an individual, not a company. If you are
-buying a disk "in person", then you are probably doing so as an individual.
-But if you expect to be reimbursed by your employer, then the disk is really
-for the company; so please pay the company price and get reimbursed for it.
-We won't try to check up on you--we use the honor system--so please cooperate.
-
-Buying CDs at the company price is very helpful for GNU; just 140 Source CDs
-at that price supports an FSF programmer or tech writer for a year.
-
-
-
-Why is there an individual price?
-
-In the past, our distribution tapes have been ordered mainly by companies.
-The CD at the price of $240 provides them with all of our software for a much
-lower price than they would previously have paid for six different tapes. To
-lower the price more would cut into the FSF's funds very badly, and decrease
-the software development we can do.
-
-However, for individuals, $240 is too high a price; hardly anyone could
-afford that. So we decided to make CDs available to individuals at the lower
-price of $60.
-
-
-
-Is there a maximum price?
-
-Our stated prices are minimum prices. Feel free to pay a higher price if you
-wish to support GNU development more. The sky's the limit; we will accept as
-high a price as you can offer. Or simply give a donation (tax-deductible in
-the U.S.) to the Free Software Foundation, a tax-exempt public charity.
-
-
-
-MS-DOS CD-ROM
--------------
-
-We expect to release our first CD-ROM for MS-DOS in September, 1995. Contact
-either address on page 1 for more information at that time. The MS-DOS CD
-will be packaged inside a book describing its contents. It will have all the
-sources and executables on the MS-DOS Diskettes. For details and version
-numbers, *note MS-DOS Diskettes::..
-
-
-
-Debian GNU/Linux CD-ROM
------------------------
-
-The FSF expects to ship a CD-ROM with Debian GNU/Linux on it in the late fall
-1995. This CD will be packaged inside a book describing its contents.
-m{No Value For "ergegrafkludge"} Debian GNU/Linux is a complete operating
-system for x86 machines, available in both source code and binary form. It
-is a GNU/Linux system--that is to say, a variant GNU system which uses Linux
-as the kernel. (All the systems now available which use the Linux kernel are
-GNU/Linux systems.)
-
-Debian is being developed by Ian Murdock and the Debian Association in
-conjunction with the Free Software Foundation. We are distributing it as an
-interim measure until the GNU kernel (the Hurd) is ready for users.
-
-Debian GNU/Linux is available for FTP at `ftp.cps.cmich.edu' in file
-`/pub/debian'. For more information about the Debian Project and how to get
-involved, see `/pub/gnu/GNUinfo/DEBIAN' on a GNU FTP host (*note How to Get
-GNU Software::. for a list).
-
-
-
-December 1994 Compiler Tools Binaries CD-ROM
---------------------------------------------
-
-We are now offering a CD-ROM that contains executables for GNU compiler tools
-for some systems which lack a compiler. This enables the people who use
-these systems to compile GNU and other free software without having to buy a
-proprietary compiler. You can also use the GNU compilation system to compile
-your own C/C++/Objective-C programs.
-
-We hope to have more systems on each update of this CD. If you can help
-build binaries for new systems (especially those that don't come with a C
-compiler), or have one to suggest, please contact us at the addresses on page
-1.
-
-These packages:
-
- *DJGPP 1.12.m2 from GCC 2.6.0
- *GCC/G++/Objective-C 2.6.2
- *GNU C Library 1.09
- *GDB 4.13
- *Binutils 2.5.2
- *Bison 1.22
- *Emacs 19.26 (MS-DOS only)
- *Flex 2.4.7
- *Make 3.72.1
- *libg++ 2.6.1
-
-On these platforms:
-
- *`i386-msdos'
- *`hppa1.1-hp-hpux9'
- *`sparc-sun-solaris2'
- *`sparc-sun-sunos4.1'
-
-
-
-Source Code CD-ROMs
--------------------
-
-We have several versions of our Source Code CD-ROMs available:
-
- * *Note June 1995 Source Code CD-ROM::.
-
- * *Note May 1994 Source Code CD-ROM::.
-
- * *Note November 1993 Source Code CD-ROM::.
-
-The older Source Code CDs will be available while supplies last at a reduced
-price; see the *note Free Software Foundation Order Form::..
-
-All of the Source Code CDs also contain Texinfo source for the GNU manuals
-listed in *Note Documentation::.
-
-The VMS tapes' contents are *not* included. Many programs that are only on
-MS-DOS diskettes and not on the tapes are also *not* included. The contents
-of the MIT Scheme & X11 Optional tapes are *not* on the November 1993 & May
-1994 Source CDs. *Note Tapes:: & *Note MS-DOS Diskettes::.
-
-There are no precompiled programs on these Source CDs. You will need a C
-compiler (programs which need some other interpreter or compiler normally
-provide the C source for a bootstrapping program). We ship C compiler
-binaries for some systems on the *Note Compiler Tools Binaries CD-ROM::.
-
-
-
-June 1995 Source Code CD-ROM - (VERSION NUMBERS NOT COMPLETELY UP TO DATE)
-............................
-
-We now have the sixth edition of our Source CD. This CD has Edition X.X for
-version 19 of the `GNU Emacs Lisp Reference Manual' & some additional
-software; not all FSF distributed software is included (*note Source Code
-CD-ROMs::.). It contains the following packages:
- *XXXXX UPDATE THIS LIST XXXXX*
- *acm 4.5
- *Autoconf 1.10
- *BASH 1.13.5
- *bc 1.02
- *Binutils 2.3
- *Bison 1.22
- *C Library 1.08
- *Calc 2.02c
- *Chess 4.0.69
- *CLISP 1994.01.08
- *Common Lisp 1.0
- *cpio 2.3
- *CVS 1.3
- *dc 0.2
- *DejaGnu 1.2
- *Diffutils 2.6
- *dld 3.2.3
- *doschk 1.1
- *ecc 1.2.1
- *ed 0.1
- *elib 0.06
- *Emacs 18.59
- *Emacs 19.23
- *es 0.84
- *f2c 1994.04.14
- *Fileutils 3.9
- *find 3.8
- *finger 1.37
- *flex 2.4.6
- *Fontutils 0.6
- *GAS 1.36.utah
- *GAS 2.2
- *Gawk 2.15.4
- *GCC 2.5.8
- *GDB 4.12
- *gdbm 1.7.1
- *Ghostscript 2.6.1
- *Ghostview 1.5
- *Ghostview for Windows 1.0
- *gmp 1.3.2
- *GNATS 3.2
- *GnuGo 1.1
- *gnuplot 3.5
- *gperf 2.1a
- *Graphics 0.17
- *grep 2.0
- *Groff 1.09
- *gzip 1.2.4
- *hello 1.3
- *hp2xx 3.1.4
- *indent 1.9.1
- *ispell 4.0
- *libg++ 2.5.3
- *m4 1.1
- *Make 3.71
- *MandelSpawn 0.07
- *mtools 2.0.7
- *MULE 1.0
- *NetFax 3.2.1
- *Nethack 3.1.3
- *NIHCL 3.0
- *nvi 1.11
- *Octave 1.0
- *Oleo 1.5
- *p2c 1.20
- *patch 2.1
- *PCL 1993.03.18
- *perl 4.036
- *ptx 0.3
- *rc 1.4
- *RCS 5.6.0.1
- *recode 3.3
- *regex 0.12
- *screen 3.5.2
- *sed 2.05
- *shellutils 1.9.4
- *Shogi 1.1.02
- *Smalltalk 1.1.1
- *Superopt 2.3
- *tar 1.11.2
- *Termcap 1.2
- *TeX 3.1
- *Texinfo 3.1
- *Textutils 1.9.1
- *Tile Forth 2.1
- *time 1.6
- *tput 1.0
- *UUCP 1.05
- *uuencode 1.0
- *wdiff 0.04
- *X11R6
- *xboard 3.0.9
- *xshogi 1.2.02
-
-
-
-May 1994 Source Code CD-ROM
-...........................
-
-We still have the fourth edition of our Source CD, at a reduced price. This
-CD has Edition 2.3 for version 19 of the `GNU Emacs Lisp Reference Manual' &
-some additional software; not all FSF distributed software is included (*note
-Source Code CD-ROMs::.). It contains these packages:
- *acm 4.5
- *Autoconf 1.10
- *BASH 1.13.5
- *bc 1.02
- *Binutils 2.3
- *Bison 1.22
- *C Library 1.08
- *Calc 2.02c
- *Chess 4.0.69
- *CLISP 1994.01.08
- *Common Lisp 1.0
- *cpio 2.3
- *CVS 1.3
- *dc 0.2
- *DejaGnu 1.2
- *Diffutils 2.6
- *dld 3.2.3
- *doschk 1.1
- *ecc 1.2.1
- *ed 0.1
- *elib 0.06
- *Emacs 18.59
- *Emacs 19.23
- *es 0.84
- *f2c 1994.04.14
- *Fileutils 3.9
- *find 3.8
- *finger 1.37
- *flex 2.4.6
- *Fontutils 0.6
- *GAS 1.36.utah
- *GAS 2.2
- *Gawk 2.15.4
- *GCC 2.5.8
- *GDB 4.12
- *gdbm 1.7.1
- *Ghostscript 2.6.1
- *Ghostview 1.5
- *Ghostview for Windows 1.0
- *gmp 1.3.2
- *GNATS 3.2
- *GnuGo 1.1
- *gnuplot 3.5
- *gperf 2.1a
- *Graphics 0.17
- *grep 2.0
- *Groff 1.09
- *gzip 1.2.4
- *hello 1.3
- *hp2xx 3.1.4
- *indent 1.9.1
- *ispell 4.0
- *libg++ 2.5.3
- *m4 1.1
- *Make 3.71
- *MandelSpawn 0.07
- *mtools 2.0.7
- *MULE 1.0
- *NetFax 3.2.1
- *Nethack 3.1.3
- *NIHCL 3.0
- *nvi 1.11
- *Octave 1.0
- *Oleo 1.5
- *p2c 1.20
- *patch 2.1
- *PCL 1993.03.18
- *perl 4.036
- *ptx 0.3
- *rc 1.4
- *RCS 5.6.0.1
- *recode 3.3
- *regex 0.12
- *screen 3.5.2
- *sed 2.05
- *shellutils 1.9.4
- *Shogi 1.1.02
- *Smalltalk 1.1.1
- *Superopt 2.3
- *tar 1.11.2
- *Termcap 1.2
- *TeX 3.1
- *Texinfo 3.1
- *Textutils 1.9.1
- *Tile Forth 2.1
- *time 1.6
- *tput 1.0
- *UUCP 1.05
- *uuencode 1.0
- *wdiff 0.04
- *X11R6
- *xboard 3.0.9
- *xshogi 1.2.02
-
-
-
-November 1993 Source Code CD-ROM
-................................
-
-We still have the third edition of our Source CD, at a reduced price. It
-contains X11R5, as we feel that people should have a choice between X11R5 and
-X11R6 until the latter is stable. This CD has Edition 2.2 for version 19 of
-the `GNU Emacs Lisp Reference Manual' & some additional software; not all FSF
-distributed software is included (*note Source Code CD-ROMs::.). It contains
-the following packages:
- *acm 3.1
- *Autoconf 1.7
- *BASH 1.13.4
- *bc 1.02
- *Binutils 1.9 2.3
- *Bison 1.22
- *C Library 1.06.7
- *Calc 2.02b
- *Chess 4.0p62
- *CLISP 93.11.08
- *cpio 2.3
- *CVS 1.3
- *dc 0.2
- *DejaGnu 1.0.1
- *Diffutils 2.6
- *dld 3.2.3
- *doschk 1.1
- *ecc 1.2.1
- *elib 0.06
- *Emacs 18.59
- *Emacs 19.21
- *es 0.84
- *f2c 1993.04.28
- *Fileutils 3.9
- *find 3.8
- *finger 1.37
- *flex 2.3.8
- *Fontutils 0.6
- *GAS 1.36.utah
- *GAS 1.38.1
- *GAS 2.2
- *Gawk 2.15.3
- *GCC 2.5.4
- *GDB 4.11
- *gdbm 1.7.1
- *Ghostscript 2.6.1
- *Ghostview 1.5
- *Ghostview for Windows 1.0
- *gmp 1.3.2
- *GNATS 3.01
- *GnuGo 1.1
- *gnuplot 3.5
- *gperf 2.1a
- *Graphics 0.17
- *grep 2.0
- *Groff 1.08
- *gzip 1.2.4
- *hello 1.3
- *hp2xx 3.1.3a
- *indent 1.8
- *Ispell 4.0
- *less 177
- *libg++ 2.5.1
- *m4 1.1
- *Make 3.69.1
- *MandelSpawn 0.06
- *mtools 2.0.7
- *MULE 1.0
- *NetFax 3.2.1
- *Nethack 3.1.3
- *NIHCL 3.0
- *Oleo 1.5
- *p2c 1.20
- *patch 2.1
- *PCL 93.03.18
- *perl 4.036
- *ptx 0.3
- *rc 1.4
- *RCS 5.6.0.1
- *recode 3.2.4
- *regex 0.12
- *screen 3.5.2
- *sed 1.18 2.03
- *Shellutils 1.9.1
- *Shogi 1.1p02
- *Smalltalk 1.1.1
- *Superopt 2.3
- *tar 1.11.2
- *Termcap 1.2
- *TeX 3.1
- *Texinfo 3.1
- *Tile Forth 2.1
- *time 1.6
- *time 1.6
- *tput 1.0
- *UUCP 1.04
- *uuencode 1.0
- *wdiff 0.04
- *X11R5
-
-
-
-
-MS-DOS Diskettes
-****************
-
-The FSF distributes some of the GNU software ported to MS-DOS, on 3.5inch
-1.44MB diskettes. These disks have both sources and executables.
-
-
-
-DJGPP Diskettes - (VERSION NUMBERS NOT COMPLETELY UP TO DATE)
----------------
-
-We offer DJGPP on 30 diskettes. For further details, see *Note GNU
-Software::. The DJGPP diskettes contain the following:
-
- * bc 1.03
- * Binutils 2.4
- * Bison 1.22
- * cpio 2.3
- * Diffutils 2.6
- * doschk 1.1
- * Fileutils 3.9
- * Findutils 3.8
- * GAS 2.4
- * Gawk 2.15.5
- * GCC 2.6.0
- * GDB 4.12
- * Ghostscript 2.6.1
- * Ghostview for Windows 1.0
- * Groff 1.09
- * gzip 1.24
- * hello 1.3
- * indent 1.9
- * ispell 4.0
- * m4 1.2
- * Make 3.71
- * patch 2.1
- * sed 1.18
- * shellutils 1.9
- * Texinfo 3.1
- * texutils 1.9
- * wdiff 0.04
-
-
-
-Emacs Diskettes - (VERSION NUMBERS NOT COMPLETELY UP TO DATE)
----------------
-
-Two versions of GNU Emacs are included on the Emacs diskettes we distribute:
-GNU Emacs version 19.29 handles 8-bit character sets; the other, MULE version
-2.1, handles 16-bit character sets including Kanji.
-
-
-
-Selected Utilities Diskettes - (NOT COMPLETELY UP TO DATE)
-----------------------------
-
-The GNUish MS-DOS Project ported GNU software to PC compatibles. Though the
-GNUish Project is no longer active, users still ask for these ports that were
-done several years ago. You can anonymous FTP files
-`/pub/gnu/MicrosPorts/MSDOS*' from `prep.ai.mit.edu' to find out how to
-access these ports over the Internet. We offer these programs on five
-diskettes. In general, this software will run on 8086 and 80286-based 16-bit
-machines; an 80386 is not required. Some of these utilities are necessarily
-missing features. Included are: `cpio', `diff', `find', `flex', `gdbm',
-`grep', `indent', `less', `m4', `make', `ptx', RCS, `sed', `shar', `sort', &
-Texinfo.
-
-
-
-Windows Diskette
-----------------
-
-We offer GNU Chess and `gnuplot' for Microsoft Windows on a single diskette.
-
-
-
-Tape & CD-ROM Subscription Service
-**********************************
-
-If you do not have net access, our subscription service enables you to stay
-current with the latest GNU developments. For a one-time cost equivalent to
-three tapes or CD-ROMs (plus shipping in some cases), we will ship you four
-new versions of the tape of your choice or the Source Code CD-ROM. The tapes
-are sent each quarter; the CD-ROMs are sent as they are issued (which is
-between two and four times a year.)
-
-Regularly, we will send you a new version of an Lisps/Emacs, Languages,
-Utilities, or X Window System (X11R6) Required tape or the Source CD-ROM.
-The MIT Scheme and X Window System Optional tapes are not changed often
-enough to warrant quarterly updates. We do not yet know if we will be
-offering subscriptions to the Compiler Tools Binaries or our new CD-ROMs.
-
-Since Emacs 19 is on the Lisps/Emacs Tape and the Source CD-ROM, a
-subscription to either is an easy way to keep current with Emacs 19 as it
-evolves.
-
-A subscription is an easy way to keep up with the regular bug fixes to the X
-Window System. We update the X11R6 Required tape as fixes and patches are
-issued throughout the year. Each new edition of the *Note Source Code
-CD-ROMs::, also has updated sources for the X Window System.
-
-Please note: In two cases, you must pay 4 times the normal shipping required
-for a single order when you pay for each subscription. If you're in Alaska,
-Hawaii, or Puerto Rico you must add $20.00 for shipping for each
-subscription. If you're outside of U.S., Canada, and Puerto Rico, you have
-to add $80.00 for each subscription. See "Unix and VMS Software" & "Shipping
-Instructions" on the *note Free Software Foundation Order Form::..
-
-
-
-The Deluxe Distribution
-***********************
-
-The Free Software Foundation has been asked repeatedly to create a package
-that provides executables for all of our software. Normally we offer only
-sources. In addition to providing binaries with the source code, the Deluxe
-Distribution includes a complete set of our printed manuals and reference
-cards.
-
-The FSF Deluxe Distribution contains the binaries and sources to hundreds of
-different programs including GNU Emacs, the GNU C Compiler, the GNU Debugger,
-the complete X Window System, and all the GNU utilities.
-
-We will make a Deluxe Distribution for any machine, with any operating
-system. We will send someone to your office to do the compilation, if we
-can't find a suitable machine close to us! However, we can only compile the
-programs that already support your chosen machine and system - porting is a
-separate matter (if you wish to commission a port, see the GNU Service
-Directory, details in *Note Free Software Support::). Compiling all these
-programs take time; a Deluxe Distribution for an unusual machine will take
-longer to produce then one for a common machine. Please contact the FSF
-office if you have any questions.
-
-We supply the software in one of these tape formats in Unix `tar' format:
-1600 or 6250bpi 1/2in reel, Sun DC300XLP 1/4in cartridge - QIC24,
-Hewlett-Packard 16-track DC600HC 1/4in cartridge, IBM RS/6000 1/4in cartridge
-- QIC 150, Exabyte 8mm cartridge, or DAT 4mm cartridge. If your computer
-cannot read any of these, please contact us to see if we can handle your
-format.
-
-The manuals included are one each of the `Bison', `Calc', `Gawk', `GNU C
-Compiler', `GNU C Library', `GDB', `Flex', `GNU Emacs Lisp Reference',
-`Programming in Emacs Lisp: An Introduction', `Make', `Texinfo', & `Termcap'
-manuals; six copies of the `GNU Emacs' manual; and a packet of ten reference
-cards each for GNU Emacs, Bison, Calc, Flex, & GDB. Every Deluxe
-Distribution also includes a copy of the latest editions of our CD-ROMs
-(including the MS-DOS CD & the Debian GNU/Linux CD when they are available)
-that contain sources of our software & compiler tool binaries for some
-systems. The MS-DOS CD is in ISO 9660 format. The other CDs are in ISO 9660
-format with Rock Ridge extensions.
-
-The price of the Deluxe Distribution is $5000 (shipping included). These
-sales provide enormous financial assistance to help the FSF develop more free
-software. To order, please fill out the "Deluxe Distribution" section on the
-*note Free Software Foundation Order Form::. and send it to:
-
- Free Software Foundation, Inc.
- 59 Temple Place -- Suite 330
- Boston, MA 02111--1307
- USA
-
- Telephone: +1-617-542-5942
- Fax (including Japan): +1-617-542-2652
- Free Dial Fax (in Japan):
- 0031-13-2473 (KDD)
- 0066-3382-0158 (IDC)
- Electronic mail: gnu@prep.ai.mit.edu
-
-
-
-FSF T-shirt
-***********
-
-Our latest T-shirt has artwork by Berkeley, CA artist Etienne Suvasa. The
-front has the ever-popular picture of GNArnold from the `Flex Manual', while
-the back has the Preamble to the GNU General Public License.
-
-They are available in two colors, Natural & Black. Natural is an off-white,
-unbleached, undyed, environment-friendly cotton, printed with black ink, & is
-great for tye-dyeing or displaying as is. Black is printed with white ink &
-is perfect for late night hacking. All shirts are thick 100% cotton, & are
-available in sizes M, L, XL & XXL. This shirt makes a great gift for your
-favorite hacker!
-
-The previous version of the T-shirt will be available while supplies last,
-but please contact the FSF to see if we have what you would like before
-ordering.
-
-
-
-Free Software Foundation Order Form
-***********************************
-
-All items are distributed with permission to copy and to redistribute.
-Texinfo source for each manual and source for each reference card is on
-the appropriate tape, diskette, or CD-ROM; the prices for these magnetic
-media do not include printed documentation. All items are provided on
-an ``as is'' basis, with no warranty of any kind. Please allow six
-weeks for delivery (though it won't usually take that long).
-
-
- PRICE AND CONTENTS MAY CHANGE WITHOUT NOTICE AFTER January 31, 1996.
-
-
-
-Unix and VMS Software
----------------------
-
-These tapes in the formats indicated (*note Tapes::., for contents):
-
- Please circle the dollar amount for each tape you order.
-
- Reel to Sun (1) HP IBM (2) Exabyte DAT
- reel RS/6000
- Unix tar Unix tar Unix tar Unix tar Unix tar Unix tar
- 9-track QIC-24 16-track QIC-150
- 1600 bpi DC300XLP DC600HC DC600A
- 1/2" reel 1/4" c.t. 1/4" c.t. 1/4" c.t. 8mm c.t. 4mm c.t.
-
- (c.t. = cartridge tape)
-
-Lisps/Emacs $200 $210 $230 $215 (3) $205 $225
-Languages $200 $210 $230 $215 $205 $225
-Utilities $200 $210 $230 $215 $205 $225
-4.4BSD-Lite $200 $210 $230 $215 $205 $225
-Scheme $200 $210 $230 $215 $205 $225
-X11R5-Required $200 $210 $230 $215 $205 $225
-X11R5-Optional $200 $210 $230 $215 $205 $225
-X11R6-Required $200 $210 $230 $215 $205 $225
-X11R6-Optional $200 $210 $230 $215 $205 $225
-
- (1) Sun tapes can be read on some other Unix systems.
- (2) IBM RS/6000 tapes can be read on some other Unix systems.
- (3) The IBM Emacs tape also has binaries for GNU Emacs.
-
-
-Subscriptions, 4 updates for one year (*note Tape & CD-ROM Subscription Service::.):
-
-Emacs $600 $630 $690 $645 $615 $675
-Languages $600 $630 $690 $645 $615 $675
-Utilities $600 $630 $690 $645 $615 $675
-X11R6-Required $600 $630 $690 $645 $615 $675
-
- Subtotal $ ______ Please put total of the above circled amounts here.
-
-
-These 1600 bpi reel-to-reel 9 track 1/2" tapes, in VMS BACKUP format (aka
-interchange format) (*note VMS Emacs and VMS Compiler Tapes::.):
-
-____ @ $195 = $ ______ VMS Emacs, GNU Emacs source & executables only.
-
-____ @ $195 = $ ______ VMS Compiler, GCC, GAS, and Bison source and
- executables only.
-
-
-FSF Deluxe Distribution (*note Deluxe Distribution::.):
-......................................................
-
-
-____ @ $5000 = $ ______ The Deluxe Distribution, with manuals, etc.
-
-Machine: _____________________________________________________________________
-
-Operating system: ____________________________________________________________
-
-Media type: __________________________________________________________________
-
-
-
-CD-ROMs, in ISO 9660 format (*note CD-ROMs::.):
-..............................................
-
-
-GNU Source Code CD-ROM, Version 6 with X11R6 (*note June 1995 Source Code CD-ROM::.):
-
-____ @ $240 = $ ______ for corporations and other organizations.
-
-____ @ $ 60 = $ ______ for individuals.
-
-
-
-GNU Compiler Tools Binaries CD-ROM, Version 2, December 1994 Edition
-(*note Compiler Tools Binaries CD-ROM::.):
-
-____ @ $220 = $ ______ for corporations and other organizations.
-
-____ @ $55 = $ ______ for individuals.
-
-
-
-Debian GNU/Linux Book with CD-ROM - expected late fall 1995 (*note Debian GNU/Linux CD-ROM::.):
-
-____ @ $200 = $ ______ for corporations and other organizations.
-
-____ @ $50 = $ ______ for individuals.
-
-
-Subscriptions, next 4 updates, of the Source Code CD-ROM, in ISO 9660 format
-(*note Tape & CD-ROM Subscription Service::.):
-
-____ @ $720 = $ ______ for corporations and other organizations.
-
-____ @ $180 = $ ______ for individuals.
-
-
-
-MS-DOS Software
----------------
-
-MS-DOS Book with CD-ROM - expected September 1995 (*note MS-DOS CD-ROM::.):
-
-____ @ $180 = $ ______ for corporations and other organizations.
-
-____ @ $45 = $ ______ for individuals.
-
-
-
-The following sources and executables for MS-DOS, on 3.5" 1.44MB diskettes
-(*note MS-DOS Diskettes::.):
-
-____ @ $ 90 = $ ______ Emacs diskettes, GNU Emacs, for 80386 and up.
-
-____ @ $ 80 = $ ______ DJGPP diskettes, GCC version 2, for 80386 and up
- (also on the *note Compiler Tools Binaries CD-ROM::. and *note MS-DOS CD-ROM::..)
-____ @ $ 85 = $ ______ Selected Utilities diskettes, 8086 and up.
-
-____ @ $ 40 = $ ______ Windows diskette, GNU Chess and gnuplot for
- Microsoft Windows.
-
-
-Manuals
--------
-
-These manuals (*note Documentation::.). Please call for bulk purchase
-discounts.
-
-____ @ $300 = $ ______ One copy each of the following 13 manuals.
-
-____ @ $ 25 = $ ______ GNU Emacs version manual, with a reference card.
-
-____ @ $ 50 = $ ______ GNU Emacs Lisp Reference manual, in two volumes.
-
-____ @ $ 50 = $ ______ Using and Porting GNU CC.
-
-____ @ $ 50 = $ ______ GNU C Library Reference Manual.
-
-____ @ $ 50 = $ ______ GNU Emacs Calc manual, with a reference card.
-
-____ @ $ 20 = $ ______ Programming in Emacs Lisp, An Introduction
-
-____ @ $ 20 = $ ______ Debugging with GDB, with a reference card.
-
-____ @ $ 20 = $ ______ Gawk manual.
-
-____ @ $ 20 = $ ______ Make manual.
-
-____ @ $ 20 = $ ______ Bison manual, with a reference card.
-
-____ @ $ 20 = $ ______ Flex manual, with a reference card.
-
-____ @ $ 20 = $ ______ Texinfo manual.
-
-____ @ $ 15 = $ ______ Termcap manual.
-
-
-
-Reference Cards
----------------
-
-The following reference cards, in packets of ten. For single copies please
-call.
-
-____ @ $ 10 = $ ______ GNU Emacs version 19 reference cards.
-
-____ @ $ 10 = $ ______ GNU Emacs Calc reference cards.
-
-____ @ $ 10 = $ ______ GDB reference cards.
-
-____ @ $ 10 = $ ______ Bison reference cards.
-
-____ @ $ 10 = $ ______ Flex reference cards.
-
-
-
-T-shirts
---------
-
-GNU/FSF T-shirts, thick 100% cotton (*note FSF T-shirt::.):
-
-____ @ $ 15 = $ ______ Size M ____ natural ____ black.
-
-____ @ $ 15 = $ ______ Size L ____ natural ____ black.
-
-____ @ $ 15 = $ ______ Size XL ____ natural ____ black.
-
-____ @ $ 15 = $ ______ Size XXL ____ natural ____ black.
-
-
-
-Older Items
------------
-
-Older items are only available while supplies last.
-
-____ @ $ 5 = $ ______ GNU Emacs version 18 reference cards, in packets
- of ten.
-
-Please fill in the number of each older CD-ROM you order:
-
- for for
- corporations individuals:
- and other
- organizations:
-
-GNU Compiler Tools Binaries CD-ROM
- December 1993 Edition (Version 1) ____________ ____________
-
-
-GNU Source Code CD-ROM
- May 1994 edition with X11R6 ____________ ____________
-
-GNU Source Code CD-ROM
- November 1993 edition with X11R5 ____________ ____________
-
-GNU Source Code CD-ROM
- May 1993 edition with X11R5 ____________ ____________
-
-GNU Source Code CD-ROM
- October 1992 edition with X11R5 ____________ ____________
-
-
-Please put the total count and cost of the above older CD-ROMs here:
-
-____ @ $ 80 = $ ______ for corporations and other organizations.
-
-____ @ $ 20 = $ ______ for individuals.
-
- ======
-
- Subtotal $ ______
-
-
-
-Tax and Shipping Costs
-----------------------
-
- + $ ______ In Massachusetts: add 5% sales tax, or give tax
- exempt number.
- + $ ______ In Alaska, Hawaii, or Puerto Rico for shipping:
- for GNU Emacs Lisp Reference and GNU Emacs Calc
- manuals, add $5 *each*. For *each* tape or
- CD-ROM subscription, add $20. For all other
- items, add $5 base charge, then $1 per item except
- reference cards; i.e.,
- shipping for all other items = $5 + ($1 * i).
- + $ ______ Outside of U.S., Canada, and Puerto Rico for
- shipping: Add $20 base charge; then add $80 more
- for *each* tape or CD-ROM subscription; and then
- add $10 more for *each* manual in the order;
- i.e., shipping for all other items
- = $20 + ($80 * s) + ($10 * m).
- + $ ______ Optional (tax-deductible in the U.S.) donation.
- ------ We suggest 5% if paying by credit card.
-
- TOTAL $ ______ We pay for shipping via UPS ground transportation in
- the contiguous 48 states and Canada. For very
- large orders, ask about actual shipping costs for
- that order.
-
-
-
-Shipping Information
---------------------
-
-Name: ________________________________________________________________________
-
-Mail Stop/Dept. Name: ________________________________________________________
-
-Organization: ________________________________________________________________
-
-Street Address: ______________________________________________________________
-
-City/State/Province: _________________________________________________________
-
-Zip Code/Postal Code/Country: ________________________________________________
-
-Telephone number in case of a problem with your order.
-For international orders, please include a FAX number. _______________________
-
-
-------------------------------------------------------------------------------
-| |
-| Orders filled only upon receipt of check, money order or credit card |
-| order in U.S. dollars. Unpaid orders will be returned to the sender. |
-| We do not have the staff to handle the billing of unpaid orders. Please |
-| help keep our lives simple by including your payment with your order. |
-| |
-------------------------------------------------------------------------------
-
-
-For orders from outside the U.S.:
----------------------------------
-
-You are responsible for paying all duties, tariffs, and taxes. If you
-refuse to pay the charges, the shipper will return or abandon the order.
-
-
- ---------------------------------------------------------------------------
- | |
- | Please make checks payable to the ``Free Software Foundation''. |
- | |
- ---------------------------------------------------------------------------
-
-
-For Credit Card Orders:
------------------------
-
-The Free Software Foundation takes these credit cards: Carte Blanche,
-Diner's Club, JCB, Mastercard, Visa, or American Express. Please note that
-we are charged about 5% of an order's total amount in credit card
-processing fees. Please consider paying by check instead, or adding on a
-5% donation to make up the difference. To place a credit card order,
-please give us this information:
-
-
-Card type: ___________________________________________________________________
-
-Account Number: ______________________________________________________________
-
-Expiration Date: _____________________________________________________________
-
-Cardholder's Signature: ______________________________________________________
-
-
-
-------------------------------------------------------------------------------
-| |
-| If you wish to pay by wire transfer, or you are a reseller, please |
-| call or write us for details. |
-| |
-------------------------------------------------------------------------------
-
-
- Please mail orders to: Free Software Foundation
- 59 Temple Place -- Suite 330
- Boston, MA 02111
- +1-617-542-5942
- FAX (including Japan): +1-617-542-2652
- Free Dial FAX numbers in Japan:
-PRICES AND CONTENTS MAY CHANGE 0031-13-2473 (KDD)
-WITHOUT NOTICE AFTER January 31, 1996. 0066-3382-0158 (IDC)
-
-Version: June 1995 ASCII Bull to June 1995 Src CD/GNU 19.29/GCC 2.7.0
-
----------------------------------------------------------------------
-local variables:
-mode: text
-fill-column: 78
-end:
diff --git a/contrib/gcc/README.ACORN b/contrib/gcc/README.ACORN
deleted file mode 100644
index 769dba74a334..000000000000
--- a/contrib/gcc/README.ACORN
+++ /dev/null
@@ -1,18 +0,0 @@
-Specifying the -g flag to GCC on a RISC iX machine requires upgrading the
-standard assembler distributed with both RISC iX 1.1 and RISC iX 1.2 with a
-replacement that is available from Acorn. This version of the assembler is
-also an order of magnitude faster when assembling to an NFS mounted
-file-system.
-
-Users of RISC iX 1.2 and above can obtain a copy of the assembler from the
-following places:
-
-1) Via ftp from acorn.acorn.co.uk, directory pub/riscix.
-
-2) From Acorn Customer Services.
-
-3) From Granada Microcare.
-
-Users of versions of RISC iX prior 1.2 should contact Acorn Customer Services;
-the assembler available on the net will not work with these versions due to
-changes in the shared libraries and system call numbers.
diff --git a/contrib/gcc/README.ALTOS b/contrib/gcc/README.ALTOS
deleted file mode 100644
index c0a1a04145fd..000000000000
--- a/contrib/gcc/README.ALTOS
+++ /dev/null
@@ -1,55 +0,0 @@
-Since COFF-encapsulation is obsolete, this may not be needed anymore.
-
-Return-Path: <jkp@sauna.hut.fi>
-Date: Mon, 10 Apr 89 10:13:45 +0300
-From: Jyrki Kuoppala <jkp@sauna.hut.fi>
-Sender: jkp@sauna.hut.fi
-To: info-gcc@prep.ai.mit.edu
-Subject: Kernel fix needed for Altos 3068 to get coff-encapsulation working right
-Organization: Helsinki University of Technology, Finland.
-
-Here's a description how to fix a kernel bug in Altos 3068 and get
-gcc-compiled programs working.
-
-Author: Jyrki Kuoppala (jkp@cs.hut.fi)
-Last modified: Mon Apr 10 09:28:40 1989
-
-There's a bug in the Altos 3068 kernel that causes gcc-compiled
-programs to fail in certain situations when the machine has a heavy
-load and also in some other situations. The bug exists at least in
-SVR 2.2 1.0gT1 and SVR 2.2 1.0e.
-
-If you have source code to your system, apply the following change to
-os/exec.c (function gethead):
-
-Change the lines containing
-
- u.u_exdata.ux_tstart = sizeof(struct naout) +
- sizeof(struct filhd) + (ep->ef.nscns * sizeof(struct scnhdr));
-
-to
-
- u.u_exdata.ux_tstart = u.u_exdata.ux_txtorg;
-
-If you only have binary, use sdb to find out the address of the
-previous lines (on our system it's gethead+0x140) and use your
-favourite binary editor to change the bytes '3036 0162 fffc 0002 0280
-0000' to '23f9 01fb f4ca 01fb f4c2 6016'. This may or may not work in
-your case, depending on the version of the operating system and the
-phase of the moon.
-
-Here's what is just before gethead+0x140 to ease finding out the right place:
-
-0x9224 (gethead+0x122): 23f9 01fb f4ca 01fb f4ce mov.l &0x1fbf4ca.L,&0
-x1fbf4ce.L []
-0x922e (gethead+0x12c): 23f9 01fb f4c6 01fb f4ca mov.l &0x1fbf4c6.L,&0
-x1fbf4ca.L []
-0x9238 (gethead+0x136): 23f9 01fb f4c2 01fb f4c6 mov.l &0x1fbf4c2.L,&0
-x1fbf4c6.L []
-
-Good luck !
-
-//Jyrki
-
-jkp@cs.hut.fi
-
diff --git a/contrib/gcc/README.APOLLO b/contrib/gcc/README.APOLLO
deleted file mode 100644
index ca02de142840..000000000000
--- a/contrib/gcc/README.APOLLO
+++ /dev/null
@@ -1,112 +0,0 @@
-README.apollo
-
-Building GCC 2.0 for 680x0 based Apollo systems requires the GNU
-assembler (GAS) version 1.38.1, with John Vasta's patches applied.
-
-If you haven't done so yet, get `gas-1.38.1.tar.Z' from your favourite
-GNU distribution site. Furthermore, get `apollo-gas-1.38.1.diffs'
-from `labrea.stanford.edu:/pub/gnu', apply the patches, compile and
-install gas (under the name as). This should go through without any
-problems.
-
-After switching into the BSD environment, you can configure GCC 2.0
-with the command
-
-% ./configure m68k-apollo-bsd
-
-The Apollo's `/usr/include/setjmp.h' uses a nonstandard `#options()'
-construct. You should create a local copy of this file and remove
-these constructs from the declarations of SIGSETJMP and SIGLONGJMP.
-
-The Apollo's `/usr/include/sys/types.h' (BSD Version) doesn't allow
-to test for the definition of `size_t'. This should be fixed by
-
- #ifndef _SIZE_T
- #define _SIZE_T
- typedef long size_t;
- #endif
-
-The script `patch-apollo-includes' fixes these two problems, but does
-_not_ pretend to be a full fledged `fixincludes' for this system.
-
-If you now follow the standard GCC installation instructions, building
-GCC 2.0 (including G++ 2.0) should proceed without any problems.
-
-NB: Debugging is not yet supported for the Apollo. If someone wants
- to do a _big_ favour to the Apollo users, he/she should consider
- porting the Binary File Description library (BFD) to the Apollo.
- This library can be found in the gdb-4.x distributions or in the
- binutils-1.9x distributions.
-
-
-
-
-#!/bin/sh
-# patch-apollo-includes -- fix some (but not all!) Apollo brain damage.
-
-FILES_TO_PATCH='sys/types.h setjmp.h'
-
-mkdir sys
-
-for i in $FILES_TO_PATCH;
-do
- cp /bsd4.3/usr/include/$i ./$i
-done
-
-patch -b -apollo <<'EOP'
-*** /bsd4.3/usr/include/sys/types.h Fri Apr 8 20:29:06 1988
---- sys/types.h Wed Feb 26 21:17:57 1992
-***************
-*** 38,44 ****
---- 38,47 ----
- typedef char * caddr_t;
- typedef u_long ino_t;
- typedef long swblk_t;
-+ #ifndef _SIZE_T
-+ #define _SIZE_T
- typedef long size_t;
-+ #endif
- typedef long time_t;
- typedef long dev_t;
- typedef long off_t;
-*** /bsd4.3/usr/include/setjmp.h Fri Feb 3 21:40:21 1989
---- setjmp.h Sun Feb 23 19:06:55 1992
-***************
-*** 24,30 ****
---- 24,39 ----
- #endif
-
-
-+ #ifdef __GNUC__
- #ifdef _PROTOTYPES
-+ extern int sigsetjmp (sigjmp_buf env, int savemask);
-+ extern void siglongjmp (sigjmp_buf env, int val);
-+ #else
-+ extern int sigsetjmp();
-+ extern void siglongjmp();
-+ #endif /* _PROTOTYPES */
-+ #else /* not __GNUC__ */
-+ #ifdef _PROTOTYPES
- extern int sigsetjmp(
- sigjmp_buf env,
- int savemask
-***************
-*** 37,43 ****
- extern int sigsetjmp() #options(abnormal);
- extern void siglongjmp() #options(noreturn);
- #endif /* _PROTOTYPES */
-!
- #undef _PROTOTYPES
-
- #ifdef __cplusplus
---- 46,52 ----
- extern int sigsetjmp() #options(abnormal);
- extern void siglongjmp() #options(noreturn);
- #endif /* _PROTOTYPES */
-! #endif /* not __GNUC__ */
- #undef _PROTOTYPES
-
- #ifdef __cplusplus
-EOP
-
-exit 0
diff --git a/contrib/gcc/README.FRESCO b/contrib/gcc/README.FRESCO
deleted file mode 100644
index 334e78023a98..000000000000
--- a/contrib/gcc/README.FRESCO
+++ /dev/null
@@ -1,17 +0,0 @@
-Compiling Fresco with g++
------------------------------
-
-Fresco is an evolving interface and toolkit for object-oriented
-graphics. A preliminary version (written in C++) was released
-with x11r6.
-
-Previous versions of Fresco have not compiled using g++,
-partly because of the use of true and false as identifiers.
-(They are now reserved words in g++, as required by the
-ANSI/ISO draft standard for C++.)
-
-If you get x11r6 with public patch #5 or a later version
-of Fresco, these problems should now be fixed.
-
-See http://www.faslab.com/fresco/HomePage.html for information
-on Fresco, including how to get the latest version.
diff --git a/contrib/gcc/README.NS32K b/contrib/gcc/README.NS32K
deleted file mode 100644
index 93c5beaef54a..000000000000
--- a/contrib/gcc/README.NS32K
+++ /dev/null
@@ -1,130 +0,0 @@
-This file describes the implementation notes of the GNU C Compiler for
-the National Semiconductor 32032 chip (and 32000 family).
-
-The 32032 machine description and configuration file for this compiler
-is, for NS32000 family machine, primarily machine independent.
-However, since this release still depends on vendor-supplied
-assemblers and linkers, the compiler must obey the existing
-conventions of the actual machine to which this compiler is targeted.
-In this case, the actual machine which this compiler was targeted to
-is a Sequent Balance 8000, running DYNIX 2.1.
-
-The assembler for DYNIX 2.1 (and DYNIX 3.0, alas) does not cope with
-the full generality of the addressing mode REGISTER RELATIVE.
-Specifically, it generates incorrect code for operands of the
-following form:
-
- sym(rn)
-
-Where `rn' is one of the general registers. Correct code is generated
-for operands of the form
-
- sym(pn)
-
-where `pn' is one of the special processor registers (sb, fp, or sp).
-
-An equivalent operand can be generated by the form
-
- sym[rn:b]
-
-although this addressing mode is about twice as slow on the 32032.
-
-The more efficient addressing mode is controlled by defining the
-constant SEQUENT_ADDRESS_BUG to 0. It is currently defined to be 1.
-
-Another bug in the assembler makes it impossible to compute with
-explicit addresses. In order to compute with a symbolic address, it
-is necessary to load that address into a register using the "addr"
-instruction. For example, it is not possible to say
-
- cmpd _p,@_x
-
-Rather one must say
-
- addr _x,rn
- cmpd _p,rn
-
-
-The ns32032 chip has a number of known bugs. Any attempt to make the
-compiler unaware of these deficiencies will surely bring disaster.
-The current list of know bugs are as follows (list provided by Richard
-Stallman):
-
-1) instructions with two overlapping operands in memory
-(unlikely in C code, perhaps impossible).
-
-2) floating point conversion instructions with constant
-operands (these may never happen, but I'm not certain).
-
-3) operands crossing a page boundary. These can be prevented
-by setting the flag in tm.h that requires strict alignment.
-
-4) Scaled indexing in an insn following an insn that has a read-write
-operand in memory. This can be prevented by placing a no-op in
-between. I, Michael Tiemann, do not understand what exactly is meant
-by `read-write operand in memory'. If this is referring to the special
-TOS mode, for example "addd 5,tos" then one need not fear, since this
-will never be generated. However, is this includes "addd 5,-4(fp)"
-then there is room for disaster. The Sequent compiler does not insert
-a no-op for code involving the latter, and I have been informed that
-Sequent is aware of this list of bugs, so I must assume that it is not
-a problem.
-
-5) The 32032 cannot shift by 32 bits. It shifts modulo the word size
-of the operand. Therefore, for 32-bit operations, 32-bit shifts are
-interpreted as zero bit shifts. 32-bit shifts have been removed from
-the compiler, but future hackers must be careful not to reintroduce
-them.
-
-6) The ns32032 is a very slow chip; however, some instructions are
-still very much slower than one might expect. For example, it is
-almost always faster to double a quantity by adding it to itself than
-by shifting it by one, even if that quantity is deep in memory. The
-MOVM instruction has a 20-cycle setup time, after which it moves data
-at about the speed that normal moves would. It is also faster to use
-address generation instructions than shift instructions for left
-shifts less than 4. I do not claim that I generate optimal code for all
-given patterns, but where I did escape from National's "clean
-architecture", I did so because the timing specification from the data
-book says that I will win if I do. I suppose this is called the
-"performance gap".
-
-
-Signed bitfield extraction has not been implemented. It is not
-provided by the NS32032, and while it is most certainly possible to do
-better than the standard shift-left/shift-right sequence, it is also
-quite hairy. Also, since signed bitfields do not yet exist in C, this
-omission seems relatively harmless.
-
-
-Zero extractions could be better implemented if it were possible in
-GCC to provide sized zero extractions: i.e. a byte zero extraction
-would be allowed to yield a byte result. The current implementation
-of GCC manifests 68000-ist thinking, where bitfields are extracted
-into a register, and automatically sign/zero extended to fill the
-register. See comments in ns32k.md around the "extzv" insn for more
-details.
-
-
-It should be noted that while the NS32000 family was designed to
-provide odd-aligned addressing capability for multi-byte data (also
-provided by the 68020, but not by the 68000 or 68010), many machines
-do not opt to take advantage of this. For example, on the sequent,
-although there is no advantage to long-word aligning word data, shorts
-must be int-aligned in structs. This is an example of another
-machine-specific machine dependency.
-
-
-Because the ns32032 is has a coherent byte-order/bit-order
-architecture, many instructions which would be different for
-68000-style machines, fold into the same instruction for the 32032.
-The classic case is push effective address, where it does not matter
-whether one is pushing a long, word, or byte address. They all will
-push the same address.
-
-
-The macro FUNCTION_VALUE_REGNO_P is probably not sufficient, what is
-needed is FUNCTION_VALUE_P, which also takes a MODE parameter. In
-this way it will be possible to determine more exactly whether a
-register is really a function value register, or just one that happens
-to look right.
diff --git a/contrib/gcc/README.RS6000 b/contrib/gcc/README.RS6000
deleted file mode 100644
index d29604f968ac..000000000000
--- a/contrib/gcc/README.RS6000
+++ /dev/null
@@ -1,111 +0,0 @@
- AIX 3.1 and 3.2 assembler problems
-
-Specifying the -g flag to GCC on the RS/6000 requires upgrading the
-standard AIX assembler distributed with AIX 3.1 and versions of AIX
-3.2 earlier than 3.2.4 with a replacement that is available from IBM.
-Note that Makefile.in specifies the -g when compiling libgcc2.c.
-
-You can test for the presence of a fixed assembler by entering the following:
- % as -u < /dev/null
-If the command exits normally, the assembler fix already is installed.
-If the assembler complains that "-u" is an unknown flag, you need to order
-the fix.
-
-If you are running AIX 3.1 (lslpp -h bos.obj output reports
-03.01.0005.XXXX where the 0005 can be any higher number and the XXXX
-can be any value), call IBM Support at 800-237-5511 and ask for
-shipment of AIX/6000 fix PTF U403044 for APAR IX22829 (.extern foo
-conflicts with defining foo).
-
-If you are running AIX 3.2 but not 3.2.4 or later (lslpp -h bos.obj
-output reports 03.02.0000.0000), a newer update to the assembler fix
-is available. Ask for shipment of AIX/6000 fix PTF U416277 for
-IX32992 (.global prevents detection of duplicate symbol).
-
-If you are running AIX 3.2.4 or later, you already have the new
-assembler.
-
-Any customer can order and get the replacement assembler, and install it on
-one or more machines. It is available on diskette from IBM Customer Support
-and from the IBM Internet fix anonymous ftp server (FixDist) at
-aix.boulder.ibm.com (198.17.57.66).
-
-If you contact IBM Customer Support, they may also ask you for your customer
-number. If you do not know it, you will still be able to get the fix, but
-you will have to be persistent. IBM has corresponding support organizations
-outside of North America. Call your IBM branch office and ask them to put
-you in touch with the department that handles fixes for AIX/6000. If that
-doesn't work, ask for the department that handles software defect support
-for AIX/6000 and ask for the APAR fix.
-
-If you use the GNU assembler instead of the system supplied assembler, you need
-an assembler modified after October 16th, 1995 in order to build the GNU C
-compiler. This is because the GNU C compiler wants to build a variant of its
-library, libgcc.a with the -mcpu=common switch to support building programs
-that can run on either the Power or PowerPC machines.
-
-
- AIX NLS problems
-
-AIX on the RS/6000 provides support (NLS) for environments outside of
-the United States. Compilers and assemblers use NLS to support
-locale-specific representations of various objects including
-floating-point numbers ("." vs "," for separating decimal fractions).
-There have been problems reported where the library linked with GCC does
-not produce the same floating-point formats that the assembler accepts.
-If you have this problem, set the LANG environment variable to "C" or
-"En_US".
-
-
- AIX 3.2.5 XLC-1.3 problems
-
-XLC version 1.3.0.0 distributed with AIX 3.2.5 will miscompile jump.c when
-building the stage1 compiler during the bootstrap process. This will cause
-GCC to crash and the bootstrap to fail later while compiling libgcc2.c. XLC
-version 1.3.0.1 or later fixes this problem. XLC-1.3.0.19 also cannot
-bootstrap GCC so please avoid that release as well. You can obtain
-XLC-1.3.0.24 by requesting PTF 432238 from IBM, or just ask for the latest
-release of XLC-1.3.
-
-There also have been reports of problems bootstrapping GCC with some older
-releases of xlc-1.2.1, including xlc-1.2.1.8. Newer releases of xlc-1.2.1
-do not exhibit this problem: xlc-1.2.1.28 is known to bootstrap properly.
-
-
- AIX 3.2 common-mode support
-
-AIX common-mode providing transparent support of both the POWER and PowerPC
-architectures is usable in AIX 3.2.3 and above but an export file and
-support for hidden export via libc.a will not exist until AIX 4.1. libgcc.a
-also must be compiled in common-mode. Note that executables generated for
-the POWER (RIOS1 and RSC) architecture will run directly on systems using
-the MPC601 chip. Common-mode only improves the performance of a single
-executable run on both POWER and PowerPC architecture platforms by not using
-POWER- or PowerPC-specific instructions and eliminating the need to trap to
-emulation (for POWER instructions run on PowerPC).
-
-To link a common-mode application prior to AIX 4.1 and run it on a system at
-AIX level 3.2.3 or above, use the text between the "<>" as an export file
-(e.g. milli.exp)
-
-<><><><><><><><><><><>
-#!
-__mulh 0x3100
-__mull 0x3180
-__divss 0x3200
-__divus 0x3280
-__quoss 0x3300
-__quous 0x3380
-<><><><><><><><><><><>
-
-and then link with -Wl,-bI:milli.exp.
-
-
- AIX 4.1 binder
-
-Due to changes in the way that GCC invokes the binder (linker) for AIX 4.1,
-the link step now may produce warnings of duplicate symbols which were not
-reported before. The assembly files generated by GCC for AIX always have
-included multiple symbol definitions for certain global variable and
-function declarations in the original program. The warnings should not
-prevent the linker from producing a correct library or runnable executable.
diff --git a/contrib/gcc/README.X11 b/contrib/gcc/README.X11
deleted file mode 100644
index 359dd5f96030..000000000000
--- a/contrib/gcc/README.X11
+++ /dev/null
@@ -1,447 +0,0 @@
-[This file contains two alternative recipes for compiling X11 with GCC.
-The first alternative puts libgcc.a into the shared X library; the second
-does not. Neither alternative works on all kinds of systems.
-It may be that when using GCC 2.4, both alternatives work okay on
-relatively recent Sparc systems. The first alternative is likely
-not to work on a Sun 3 without hardware floating point.]
-
-How to compile X11R5 (patch level 11) with GCC version 2:
-
-The patches include support for building the shared libraries with GCC
-2 on the Sparc and 68k machines. This version includes the necessary
-parts of libgcc.a in the shared library for X, in case functions in
-that library need it. Thus the default behavior is now to build
-everything, including the libraries, with gcc.
-
-If you build the shared library this way, it may not work with
-executables made with older versions of GCC (2.3.3 and earlier).
-If that happens, relink those executables with the latest GCC.
-IF YOU THINK YOU MIGHT COMPILE X FOR SOLARIS 2, then you really don't
-need this patch: get /contrib/R5.SunOS5.patch.tar.Z from
-export.lcs.mit.edu instead. It has everything you need to do the
-build for Solaris 2, sets you up to everything with GCC, and is
-backward compatible with Sunos 4.*. Get the the README
-(/contrib/R5.SunOS5.patch.README at export) for more info.
-
-If you see undefined symbols _dlopen, _dlsym, or _dlclose when linking
-with -lX11, compile and link against the file mit/util/misc/dlsym.c in
-the MIT X11R5 distribution. Alternatively, do dynamic linking
-by using a non-GNU ld.
-
-mit/config/Imake.tmpl -- Do not set -fstrength-reduce if we have GCC 2.
-If -fstrength-reduce (or any other -f option) is a major win, then it
-will most likely be turned on by -O2 optimization.
-
-mit/config/sunLib.rules -- If HasGcc and GccVersion > 1 are true, then
-use gcc -fpic to generate PIC code. Make sure that gcc does not use
-gas (the GNU assembler) when compiling PIC code; gas does not assemble
-it correctly.
-
-***If you have gas installed where gcc uses it by default, you might have
-to add -B/bin/ to the PositionIndependentCFlags.***
-
-mit/config/site.def -- Define GccVersion to be 2.
-
-mit/config/sun.cf -- When compiling with GCC 2, use -O2 optimization.
-
-mit/config/sunLib.rules -- When compiling with GCC 2, use -fpic for
-position independent code generation.
-
-mit/rgb/Imakefile -- No longer need to compile some modules with
-cc on the Sparc since GCC 2 produces proper -fpcc-struct-return code.
-
-mit/server/os/Imakefile -- Likewise.
-
-mit/server/ddx/sun/Imakefile -- When compiling with GCC 2, some modules
-should be compiled with -fvolatile.
-
-mit/clients/twm/Imakefile -- Fix bad decls of malloc, realloc in gram.c.
-
-mit/lib/X/Imakefile -- Make libgcc.a a required lib for libX11.so
-
-*** mit/clients/twm/Imakefile Mon May 17 22:05:22 1993
---- new/clients/twm/Imakefile Mon May 17 22:28:46 1993
-***************
-*** 32,41 ****
---- 32,48 ----
- ComplexProgramTarget(twm)
- InstallNonExecFile(system.twmrc,$(TWMDIR))
-
-+ #if HasGcc && GccVersion > 1 && defined (SunArchitecture)
- gram.h gram.c: gram.y
- yacc $(YFLAGS) gram.y
-+ sed -e 's/^extern char \*malloc(), \*realloc();//g' y.tab.c >gram.c
-+ $(MV) y.tab.h gram.h
-+ #else
-+ gram.h gram.c: gram.y
-+ yacc $(YFLAGS) gram.y
- $(MV) y.tab.c gram.c
- $(MV) y.tab.h gram.h
-+ #endif
-
- clean::
- $(RM) y.tab.h y.tab.c lex.yy.c gram.h gram.c lex.c deftwmrc.c
-*** mit/config/Imake.tmpl Mon May 17 22:02:57 1993
---- new/config/Imake.tmpl Mon May 17 22:15:06 1993
-***************
-*** 500,506 ****
---- 500,510 ----
- #endif
- #ifndef CcCmd
- #if HasGcc
-+ #if GccVersion > 1
-+ #define CcCmd gcc -fpcc-struct-return
-+ #else
- #define CcCmd gcc -fstrength-reduce -fpcc-struct-return
-+ #endif
- #else
- #define CcCmd cc
- #endif
-*** mit/config/site.def Mon May 17 22:02:44 1993
---- new/config/site.def Mon May 17 22:22:28 1993
-***************
-*** 25,31 ****
-
- #ifdef BeforeVendorCF
-
-! /* #define HasGcc YES */
-
- #endif /* BeforeVendorCF */
-
---- 25,33 ----
-
- #ifdef BeforeVendorCF
-
-! #define HasGcc YES
-! /* GccVersion > 1 implies building shared libraries with gcc */
-! #define GccVersion 2
-
- #endif /* BeforeVendorCF */
-
-*** mit/config/sun.cf Mon May 17 22:03:02 1993
---- new/config/sun.cf Mon May 17 22:24:55 1993
-***************
-*** 41,49 ****
---- 41,55 ----
-
- #if HasGcc
-
-+ #if GccVersion > 1
-+ #define OptimizedCDebugFlags -O2
-+ #else
-+ #define OptimizedCDebugFlags -O
- #define SharedLibraryCcCmd cc
- #define ExtraLoadFlags -B/usr/bin/
- #define AllocateLocalDefines /**/
-+ #endif
-+
-
- .c.o:
- $(CC) -c $(CFLAGS) $*.c
-*** mit/config/sunLib.rules Mon May 17 22:02:46 1993
---- new/config/sunLib.rules Mon May 17 22:19:06 1993
-***************
-*** 23,29 ****
---- 23,33 ----
- #define SharedLibraryLoadFlags -assert pure-text
- #endif
- #ifndef PositionIndependentCFlags
-+ #if defined(HasGcc) && GccVersion > 1
-+ #define PositionIndependentCFlags -fpic
-+ #else
- #define PositionIndependentCFlags -pic
-+ #endif
- #endif
-
- /*
-*** mit/lib/X/Imakefile Mon May 17 22:05:03 1993
---- new/lib/X/Imakefile Mon May 17 22:32:26 1993
-***************
-*** 9,14 ****
---- 9,31 ----
- #define MotifBC NO
- #endif
-
-+ #if defined(SunArchitecture)
-+ #if SystemV4
-+ #if HasGcc
-+ REQUIREDLIBS= -lgcc -lc
-+ #else
-+ REQUIREDLIBS= -lc
-+ #endif
-+ #else
-+ #if HasGcc && GccVersion > 1
-+ XCOMM Hack to fix gcc 2 ``-nostdlib'' deficiency on SunOS 4.x
-+ REQUIREDLIBS= `gcc -v 2>&1 | awk '{print $$4}' | sed -e 's/specs$$/libgcc.a/'`
-+ #else
-+ REQUIREDLIBS=
-+ #endif
-+ #endif
-+ #endif
-+
- #ifndef BuildXimp
- #define BuildXimp NO
- #endif
-*** mit/rgb/Imakefile Mon May 17 22:05:31 1993
---- new/rgb/Imakefile Mon May 17 22:25:30 1993
-***************
-*** 17,23 ****
- #if !(defined(SGIArchitecture) || SystemV4)
- DBMLIB = -ldbm
- #endif
-! #if defined(SparcArchitecture) && HasGcc
- CC = cc
- CCOPTIONS = /**/
- EXTRA_LOAD_FLAGS = /**/
---- 17,23 ----
- #if !(defined(SGIArchitecture) || SystemV4)
- DBMLIB = -ldbm
- #endif
-! #if defined(SparcArchitecture) && HasGcc && GccVersion <= 1
- CC = cc
- CCOPTIONS = /**/
- EXTRA_LOAD_FLAGS = /**/
-*** mit/server/ddx/sun/Imakefile Mon May 17 22:05:57 1993
---- new/server/ddx/sun/Imakefile Mon May 17 22:27:23 1993
-***************
-*** 43,48 ****
---- 43,53 ----
- LinkFile(sunGX.o,sunGX.o.dist)
- #endif
-
-+ #if HasGcc && GccVersion > 1
-+ SpecialObjectRule(sunCG2C.o,sunCG2C.c,-fvolatile)
-+ SpecialObjectRule(sunCG2M.o,sunCG2M.c,-fvolatile)
-+ #endif
-+
- sunInitExtMono.o: $(ICONFIGFILES)
- ObjectFromSpecialSource(sunInitExtMono,../mi/miinitext,-UPEXEXT)
- ObjectFromSpecialSource(sunInitMono,sunInit,-DMONO_ONLY)
-*** mit/server/os/Imakefile Mon May 17 22:05:46 1993
---- new/server/os/Imakefile Mon May 17 22:26:02 1993
-***************
-*** 132,138 ****
- SpecialObjectRule(osinit.o,$(ICONFIGFILES),$(ADM_DEFINES))
- SpecialObjectRule(WaitFor.o,$(ICONFIGFILES),$(EXT_DEFINES))
- SpecialObjectRule(fonttype.o,$(ICONFIGFILES),$(FONT_DEFINES))
-! #if defined(SparcArchitecture) && HasGcc
- oscolor.o: $(ICONFIGFILES)
- $(RM) $@
- cc -c $(DBM_DEFINES) $(CDEBUGFLAGS) $(ALLDEFINES) $*.c
---- 132,138 ----
- SpecialObjectRule(osinit.o,$(ICONFIGFILES),$(ADM_DEFINES))
- SpecialObjectRule(WaitFor.o,$(ICONFIGFILES),$(EXT_DEFINES))
- SpecialObjectRule(fonttype.o,$(ICONFIGFILES),$(FONT_DEFINES))
-! #if defined(SparcArchitecture) && HasGcc && GccVersion <= 1
- oscolor.o: $(ICONFIGFILES)
- $(RM) $@
- cc -c $(DBM_DEFINES) $(CDEBUGFLAGS) $(ALLDEFINES) $*.c
-
-
-[This is the older version]
-
-How to compile X11R5 (patch level 11) with GCC version 2:
-
-The patches include support for building the shared libraries with GCC 2 on
-the Sparc and 68k machines.
-
-NOTE: Such shared libraries built with GCC version 2.3 DID NOT WORK
-with executables previously linked using Sun CC! This is because
-neither those executables nor the gcc-compiled shared libraries contain
-libgcc.a. The shared libraries did work with executables linked using
-GCC (running the Sun linker, of course) because GCC tells the linker to
-link in libgcc.a. Because of these limitations the default behavior is
-to NOT build the shared libraries with gcc.
-
-Changes in GCC 2.4 seem to have eliminated the problem, and such a
-shared library now seems work with all executables. If you want the
-gcc-compiled shared libraries turn on "Gcc2BuildLibs" in site.def. If
-you try this, please tell bug-gcc@prep.ai.mit.edu whether it works.
-
-Sun forgot to include a static version of libdl.a with some versions
-of SunOS (4.1 mainly). If you see undefined symbols _dlopen, _dlsym,
-or _dlclose when linking with -lX11, compile and link against the file
-mit/util/misc/dlsym.c in the MIT X11R5 distribution.
-
-mit/config/Imake.tmpl -- Do not set -fstrength-reduce if we have GCC 2. If
--fstrength-reduce (or any other -f option) is a major win, then it will
-most likely be turned on by -O2 optimization.
-
-mit/config/sunLib.rules -- If HasGcc2 and Gcc2BuildLibs are defined, then
-use gcc -fpic to generate PIC code. Make sure that gcc does not use gas (the
-GNU assembler) when compiling PIC code; gas does not assemble it correctly.
-If you have gas installed where gcc uses it by default, you might have to add
--B/bin/ to the PositionIndependentCFlags.
-
-mit/config/site.def -- Define HasGcc2 to be YES.
-
-mit/config/sun.cf -- When compiling with GCC 2, use -O2 optimization.
-
-mit/rgb/Imakefile -- No longer need to compile some modules with
-cc on the Sparc since GCC 2 produces proper -fpcc-struct-return code.
-
-mit/server/os/Imakefile -- Likewise.
-
-mit/clients/twm/Imakefile -- fix bad decls of malloc, realloc in gram.c.
-
-*** mit/config/Imake.tmpl.ORIG Tue Dec 31 11:07:56 1991
---- mit/config/Imake.tmpl Tue Dec 31 12:30:47 1991
-***************
-*** 499,508 ****
---- 499,512 ----
- #define HasGcc NO
- #endif
- #ifndef CcCmd
-+ #if HasGcc2
-+ #define CcCmd gcc -fpcc-struct-return
-+ #else
- #if HasGcc
- #define CcCmd gcc -fstrength-reduce -fpcc-struct-return
- #else
- #define CcCmd cc
-+ #endif
- #endif
- #endif
- #if HasFortran
-*** mit/config/sunLib.rules.ORIG Tue Dec 31 11:11:24 1991
---- mit/config/sunLib.rules Tue May 5 12:26:12 1992
-***************
-*** 23,30 ****
---- 23,34 ----
- #define SharedLibraryLoadFlags -assert pure-text
- #endif
- #ifndef PositionIndependentCFlags
-+ #if defined(HasGcc2) && defined (Gcc2BuildLibs)
-+ #define PositionIndependentCFlags -fpic
-+ #else
- #define PositionIndependentCFlags -pic
- #endif
-+ #endif
-
- /*
- * InstallSharedLibrary - generate rules to install the shared library.
-*** mit/config/site.def.ORIG Tue Dec 31 11:13:49 1991
---- mit/config/site.def Tue Dec 31 12:02:59 1991
-***************
-*** 25,31 ****
-
- #ifdef BeforeVendorCF
-
-! /* #define HasGcc YES */
-
- #endif /* BeforeVendorCF */
-
---- 25,33 ----
-
- #ifdef BeforeVendorCF
-
-! #define HasGcc YES
-! #define HasGcc2 YES
-! /* #define Gcc2BuildLibs YES */
-
- #endif /* BeforeVendorCF */
-
-*** mit/config/sun.cf.ORIG Tue Dec 31 11:13:57 1991
---- mit/config/sun.cf Tue May 5 12:29:50 1992
-***************
-*** 34,42 ****
---- 41,61 ----
-
- #if HasGcc
-
-+ #if defined(HasGcc2)
-+ #define OptimizedCDebugFlags -O2
-+ /* Leave Alone XXX */
-+ #else
-+ #define OptimizedCDebugFlags -O
- #define SharedLibraryCcCmd cc
- #define ExtraLoadFlags -B/usr/bin/
- #define AllocateLocalDefines /**/
-+ #endif
-+
-+ #if !defined(Gcc2BuildLibs)
-+ #define SharedLibraryCcCmd cc
-+ #define ExtraLoadFlags -B/usr/bin/
-+ #define AllocateLocalDefines /**/
-+ #endif
-
- .c.o:
- $(CC) -c $(CFLAGS) $*.c
-*** mit/rgb/Imakefile.ORIG Wed Jan 15 16:43:18 1992
---- mit/rgb/Imakefile Thu Jan 2 13:34:09 1992
-***************
-*** 17,23 ****
- #if !(defined(SGIArchitecture) || SystemV4)
- DBMLIB = -ldbm
- #endif
-! #if defined(SparcArchitecture) && HasGcc
- CC = cc
- CCOPTIONS = /**/
- EXTRA_LOAD_FLAGS = /**/
---- 17,23 ----
- #if !(defined(SGIArchitecture) || SystemV4)
- DBMLIB = -ldbm
- #endif
-! #if defined(SparcArchitecture) && HasGcc && !defined(HasGcc2)
- CC = cc
- CCOPTIONS = /**/
- EXTRA_LOAD_FLAGS = /**/
-*** mit/server/os/Imakefile.ORIG Wed Jan 15 16:46:23 1992
---- mit/server/os/Imakefile Wed Jan 15 16:46:48 1992
-***************
-*** 132,138 ****
- SpecialObjectRule(osinit.o,$(ICONFIGFILES),$(ADM_DEFINES))
- SpecialObjectRule(WaitFor.o,$(ICONFIGFILES),$(EXT_DEFINES))
- SpecialObjectRule(fonttype.o,$(ICONFIGFILES),$(FONT_DEFINES))
-! #if defined(SparcArchitecture) && HasGcc
- oscolor.o: $(ICONFIGFILES)
- $(RM) $@
- cc -c $(DBM_DEFINES) $(CDEBUGFLAGS) $(ALLDEFINES) $*.c
---- 132,138 ----
- SpecialObjectRule(osinit.o,$(ICONFIGFILES),$(ADM_DEFINES))
- SpecialObjectRule(WaitFor.o,$(ICONFIGFILES),$(EXT_DEFINES))
- SpecialObjectRule(fonttype.o,$(ICONFIGFILES),$(FONT_DEFINES))
-! #if defined(SparcArchitecture) && HasGcc && !defined(HasGcc2)
- oscolor.o: $(ICONFIGFILES)
- $(RM) $@
- cc -c $(DBM_DEFINES) $(CDEBUGFLAGS) $(ALLDEFINES) $*.c
-*** 1.1 1992/09/08 19:52:07
---- mit/server/ddx/sun/Imakefile 1992/09/08 21:10:22
-***************
-*** 43,48 ****
---- 43,53 ----
- LinkFile(sunGX.o,sunGX.o.dist)
- #endif
-
-+ #if HasGcc2
-+ SpecialObjectRule(sunCG2C.o,sunCG2C.c,-fvolatile)
-+ SpecialObjectRule(sunCG2M.o,sunCG2M.c,-fvolatile)
-+ #endif
-+
- sunInitExtMono.o: $(ICONFIGFILES)
- ObjectFromSpecialSource(sunInitExtMono,../mi/miinitext,-UPEXEXT)
- ObjectFromSpecialSource(sunInitMono,sunInit,-DMONO_ONLY)
-
-*** /tmp/RCSAa24446 Tue Sep 15 12:23:32 1992
---- mit/clients/twm/Imakefile Thu Aug 13 18:18:07 1992
-***************
-*** 32,41 ****
---- 32,48 ----
- ComplexProgramTarget(twm)
- InstallNonExecFile(system.twmrc,$(TWMDIR))
-
-+ #if HasGcc2 && defined (SunArchitecture)
- gram.h gram.c: gram.y
- yacc $(YFLAGS) gram.y
-+ sed -e 's/^extern char \*malloc(), \*realloc();//g' y.tab.c >gram.c
-+ $(MV) y.tab.h gram.h
-+ #else
-+ gram.h gram.c: gram.y
-+ yacc $(YFLAGS) gram.y
- $(MV) y.tab.c gram.c
- $(MV) y.tab.h gram.h
-+ #endif
-
- clean::
- $(RM) y.tab.h y.tab.c lex.yy.c gram.h gram.c lex.c deftwmrc.c
-
diff --git a/contrib/gcc/alloca.c b/contrib/gcc/alloca.c
deleted file mode 100644
index 8f98b73dbb90..000000000000
--- a/contrib/gcc/alloca.c
+++ /dev/null
@@ -1,504 +0,0 @@
-/* alloca.c -- allocate automatically reclaimed memory
- (Mostly) portable public-domain implementation -- D A Gwyn
-
- This implementation of the PWB library alloca function,
- which is used to allocate space off the run-time stack so
- that it is automatically reclaimed upon procedure exit,
- was inspired by discussions with J. Q. Johnson of Cornell.
- J.Otto Tennant <jot@cray.com> contributed the Cray support.
-
- There are some preprocessor constants that can
- be defined when compiling for your specific system, for
- improved efficiency; however, the defaults should be okay.
-
- The general concept of this implementation is to keep
- track of all alloca-allocated blocks, and reclaim any
- that are found to be deeper in the stack than the current
- invocation. This heuristic does not reclaim storage as
- soon as it becomes invalid, but it will do so eventually.
-
- As a special case, alloca(0) reclaims storage without
- allocating any. It is a good idea to use alloca(0) in
- your main control loop, etc. to force garbage collection. */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-
-#ifdef emacs
-#include "blockinput.h"
-#endif
-
-/* If compiling with GCC 2, this file's not needed. */
-#if !defined (__GNUC__) || __GNUC__ < 2
-
-/* If someone has defined alloca as a macro,
- there must be some other way alloca is supposed to work. */
-#ifndef alloca
-
-#ifdef emacs
-#ifdef static
-/* actually, only want this if static is defined as ""
- -- this is for usg, in which emacs must undefine static
- in order to make unexec workable
- */
-#ifndef STACK_DIRECTION
-you
-lose
--- must know STACK_DIRECTION at compile-time
-#endif /* STACK_DIRECTION undefined */
-#endif /* static */
-#endif /* emacs */
-
-/* If your stack is a linked list of frames, you have to
- provide an "address metric" ADDRESS_FUNCTION macro. */
-
-#if defined (CRAY) && defined (CRAY_STACKSEG_END)
-long i00afunc ();
-#define ADDRESS_FUNCTION(arg) (char *) i00afunc (&(arg))
-#else
-#define ADDRESS_FUNCTION(arg) &(arg)
-#endif
-
-#if __STDC__
-typedef void *pointer;
-#else
-typedef char *pointer;
-#endif
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-/* Different portions of Emacs need to call different versions of
- malloc. The Emacs executable needs alloca to call xmalloc, because
- ordinary malloc isn't protected from input signals. On the other
- hand, the utilities in lib-src need alloca to call malloc; some of
- them are very simple, and don't have an xmalloc routine.
-
- Non-Emacs programs expect this to call use xmalloc.
-
- Callers below should use malloc. */
-
-#ifndef emacs
-#define malloc xmalloc
-#endif
-extern pointer malloc ();
-
-/* Define STACK_DIRECTION if you know the direction of stack
- growth for your system; otherwise it will be automatically
- deduced at run-time.
-
- STACK_DIRECTION > 0 => grows toward higher addresses
- STACK_DIRECTION < 0 => grows toward lower addresses
- STACK_DIRECTION = 0 => direction of growth unknown */
-
-#ifndef STACK_DIRECTION
-#define STACK_DIRECTION 0 /* Direction unknown. */
-#endif
-
-#if STACK_DIRECTION != 0
-
-#define STACK_DIR STACK_DIRECTION /* Known at compile-time. */
-
-#else /* STACK_DIRECTION == 0; need run-time code. */
-
-static int stack_dir; /* 1 or -1 once known. */
-#define STACK_DIR stack_dir
-
-static void
-find_stack_direction ()
-{
- static char *addr = NULL; /* Address of first `dummy', once known. */
- auto char dummy; /* To get stack address. */
-
- if (addr == NULL)
- { /* Initial entry. */
- addr = ADDRESS_FUNCTION (dummy);
-
- find_stack_direction (); /* Recurse once. */
- }
- else
- {
- /* Second entry. */
- if (ADDRESS_FUNCTION (dummy) > addr)
- stack_dir = 1; /* Stack grew upward. */
- else
- stack_dir = -1; /* Stack grew downward. */
- }
-}
-
-#endif /* STACK_DIRECTION == 0 */
-
-/* An "alloca header" is used to:
- (a) chain together all alloca'ed blocks;
- (b) keep track of stack depth.
-
- It is very important that sizeof(header) agree with malloc
- alignment chunk size. The following default should work okay. */
-
-#ifndef ALIGN_SIZE
-#define ALIGN_SIZE sizeof(double)
-#endif
-
-typedef union hdr
-{
- char align[ALIGN_SIZE]; /* To force sizeof(header). */
- struct
- {
- union hdr *next; /* For chaining headers. */
- char *deep; /* For stack depth measure. */
- } h;
-} header;
-
-static header *last_alloca_header = NULL; /* -> last alloca header. */
-
-/* Return a pointer to at least SIZE bytes of storage,
- which will be automatically reclaimed upon exit from
- the procedure that called alloca. Originally, this space
- was supposed to be taken from the current stack frame of the
- caller, but that method cannot be made to work for some
- implementations of C, for example under Gould's UTX/32. */
-
-pointer
-alloca (size)
- unsigned size;
-{
- auto char probe; /* Probes stack depth: */
- register char *depth = ADDRESS_FUNCTION (probe);
-
-#if STACK_DIRECTION == 0
- if (STACK_DIR == 0) /* Unknown growth direction. */
- find_stack_direction ();
-#endif
-
- /* Reclaim garbage, defined as all alloca'd storage that
- was allocated from deeper in the stack than currently. */
-
- {
- register header *hp; /* Traverses linked list. */
-
-#ifdef emacs
- BLOCK_INPUT;
-#endif
-
- for (hp = last_alloca_header; hp != NULL;)
- if ((STACK_DIR > 0 && hp->h.deep > depth)
- || (STACK_DIR < 0 && hp->h.deep < depth))
- {
- register header *np = hp->h.next;
-
- free ((pointer) hp); /* Collect garbage. */
-
- hp = np; /* -> next header. */
- }
- else
- break; /* Rest are not deeper. */
-
- last_alloca_header = hp; /* -> last valid storage. */
-
-#ifdef emacs
- UNBLOCK_INPUT;
-#endif
- }
-
- if (size == 0)
- return NULL; /* No allocation required. */
-
- /* Allocate combined header + user data storage. */
-
- {
- register pointer new = malloc (sizeof (header) + size);
- /* Address of header. */
-
- if (new == 0)
- abort();
-
- ((header *) new)->h.next = last_alloca_header;
- ((header *) new)->h.deep = depth;
-
- last_alloca_header = (header *) new;
-
- /* User storage begins just after header. */
-
- return (pointer) ((char *) new + sizeof (header));
- }
-}
-
-#if defined (CRAY) && defined (CRAY_STACKSEG_END)
-
-#ifdef DEBUG_I00AFUNC
-#include <stdio.h>
-#endif
-
-#ifndef CRAY_STACK
-#define CRAY_STACK
-#ifndef CRAY2
-/* Stack structures for CRAY-1, CRAY X-MP, and CRAY Y-MP */
-struct stack_control_header
- {
- long shgrow:32; /* Number of times stack has grown. */
- long shaseg:32; /* Size of increments to stack. */
- long shhwm:32; /* High water mark of stack. */
- long shsize:32; /* Current size of stack (all segments). */
- };
-
-/* The stack segment linkage control information occurs at
- the high-address end of a stack segment. (The stack
- grows from low addresses to high addresses.) The initial
- part of the stack segment linkage control information is
- 0200 (octal) words. This provides for register storage
- for the routine which overflows the stack. */
-
-struct stack_segment_linkage
- {
- long ss[0200]; /* 0200 overflow words. */
- long sssize:32; /* Number of words in this segment. */
- long ssbase:32; /* Offset to stack base. */
- long:32;
- long sspseg:32; /* Offset to linkage control of previous
- segment of stack. */
- long:32;
- long sstcpt:32; /* Pointer to task common address block. */
- long sscsnm; /* Private control structure number for
- microtasking. */
- long ssusr1; /* Reserved for user. */
- long ssusr2; /* Reserved for user. */
- long sstpid; /* Process ID for pid based multi-tasking. */
- long ssgvup; /* Pointer to multitasking thread giveup. */
- long sscray[7]; /* Reserved for Cray Research. */
- long ssa0;
- long ssa1;
- long ssa2;
- long ssa3;
- long ssa4;
- long ssa5;
- long ssa6;
- long ssa7;
- long sss0;
- long sss1;
- long sss2;
- long sss3;
- long sss4;
- long sss5;
- long sss6;
- long sss7;
- };
-
-#else /* CRAY2 */
-/* The following structure defines the vector of words
- returned by the STKSTAT library routine. */
-struct stk_stat
- {
- long now; /* Current total stack size. */
- long maxc; /* Amount of contiguous space which would
- be required to satisfy the maximum
- stack demand to date. */
- long high_water; /* Stack high-water mark. */
- long overflows; /* Number of stack overflow ($STKOFEN) calls. */
- long hits; /* Number of internal buffer hits. */
- long extends; /* Number of block extensions. */
- long stko_mallocs; /* Block allocations by $STKOFEN. */
- long underflows; /* Number of stack underflow calls ($STKRETN). */
- long stko_free; /* Number of deallocations by $STKRETN. */
- long stkm_free; /* Number of deallocations by $STKMRET. */
- long segments; /* Current number of stack segments. */
- long maxs; /* Maximum number of stack segments so far. */
- long pad_size; /* Stack pad size. */
- long current_address; /* Current stack segment address. */
- long current_size; /* Current stack segment size. This
- number is actually corrupted by STKSTAT to
- include the fifteen word trailer area. */
- long initial_address; /* Address of initial segment. */
- long initial_size; /* Size of initial segment. */
- };
-
-/* The following structure describes the data structure which trails
- any stack segment. I think that the description in 'asdef' is
- out of date. I only describe the parts that I am sure about. */
-
-struct stk_trailer
- {
- long this_address; /* Address of this block. */
- long this_size; /* Size of this block (does not include
- this trailer). */
- long unknown2;
- long unknown3;
- long link; /* Address of trailer block of previous
- segment. */
- long unknown5;
- long unknown6;
- long unknown7;
- long unknown8;
- long unknown9;
- long unknown10;
- long unknown11;
- long unknown12;
- long unknown13;
- long unknown14;
- };
-
-#endif /* CRAY2 */
-#endif /* not CRAY_STACK */
-
-#ifdef CRAY2
-/* Determine a "stack measure" for an arbitrary ADDRESS.
- I doubt that "lint" will like this much. */
-
-static long
-i00afunc (long *address)
-{
- struct stk_stat status;
- struct stk_trailer *trailer;
- long *block, size;
- long result = 0;
-
- /* We want to iterate through all of the segments. The first
- step is to get the stack status structure. We could do this
- more quickly and more directly, perhaps, by referencing the
- $LM00 common block, but I know that this works. */
-
- STKSTAT (&status);
-
- /* Set up the iteration. */
-
- trailer = (struct stk_trailer *) (status.current_address
- + status.current_size
- - 15);
-
- /* There must be at least one stack segment. Therefore it is
- a fatal error if "trailer" is null. */
-
- if (trailer == 0)
- abort ();
-
- /* Discard segments that do not contain our argument address. */
-
- while (trailer != 0)
- {
- block = (long *) trailer->this_address;
- size = trailer->this_size;
- if (block == 0 || size == 0)
- abort ();
- trailer = (struct stk_trailer *) trailer->link;
- if ((block <= address) && (address < (block + size)))
- break;
- }
-
- /* Set the result to the offset in this segment and add the sizes
- of all predecessor segments. */
-
- result = address - block;
-
- if (trailer == 0)
- {
- return result;
- }
-
- do
- {
- if (trailer->this_size <= 0)
- abort ();
- result += trailer->this_size;
- trailer = (struct stk_trailer *) trailer->link;
- }
- while (trailer != 0);
-
- /* We are done. Note that if you present a bogus address (one
- not in any segment), you will get a different number back, formed
- from subtracting the address of the first block. This is probably
- not what you want. */
-
- return (result);
-}
-
-#else /* not CRAY2 */
-/* Stack address function for a CRAY-1, CRAY X-MP, or CRAY Y-MP.
- Determine the number of the cell within the stack,
- given the address of the cell. The purpose of this
- routine is to linearize, in some sense, stack addresses
- for alloca. */
-
-static long
-i00afunc (long address)
-{
- long stkl = 0;
-
- long size, pseg, this_segment, stack;
- long result = 0;
-
- struct stack_segment_linkage *ssptr;
-
- /* Register B67 contains the address of the end of the
- current stack segment. If you (as a subprogram) store
- your registers on the stack and find that you are past
- the contents of B67, you have overflowed the segment.
-
- B67 also points to the stack segment linkage control
- area, which is what we are really interested in. */
-
- stkl = CRAY_STACKSEG_END ();
- ssptr = (struct stack_segment_linkage *) stkl;
-
- /* If one subtracts 'size' from the end of the segment,
- one has the address of the first word of the segment.
-
- If this is not the first segment, 'pseg' will be
- nonzero. */
-
- pseg = ssptr->sspseg;
- size = ssptr->sssize;
-
- this_segment = stkl - size;
-
- /* It is possible that calling this routine itself caused
- a stack overflow. Discard stack segments which do not
- contain the target address. */
-
- while (!(this_segment <= address && address <= stkl))
- {
-#ifdef DEBUG_I00AFUNC
- fprintf (stderr, "%011o %011o %011o\n", this_segment, address, stkl);
-#endif
- if (pseg == 0)
- break;
- stkl = stkl - pseg;
- ssptr = (struct stack_segment_linkage *) stkl;
- size = ssptr->sssize;
- pseg = ssptr->sspseg;
- this_segment = stkl - size;
- }
-
- result = address - this_segment;
-
- /* If you subtract pseg from the current end of the stack,
- you get the address of the previous stack segment's end.
- This seems a little convoluted to me, but I'll bet you save
- a cycle somewhere. */
-
- while (pseg != 0)
- {
-#ifdef DEBUG_I00AFUNC
- fprintf (stderr, "%011o %011o\n", pseg, size);
-#endif
- stkl = stkl - pseg;
- ssptr = (struct stack_segment_linkage *) stkl;
- size = ssptr->sssize;
- pseg = ssptr->sspseg;
- result += size;
- }
- return (result);
-}
-
-#endif /* not CRAY2 */
-#endif /* CRAY */
-
-#endif /* no alloca */
-#endif /* not GCC version 2 */
diff --git a/contrib/gcc/bc-emit.c b/contrib/gcc/bc-emit.c
deleted file mode 100644
index 9a7c0f981b62..000000000000
--- a/contrib/gcc/bc-emit.c
+++ /dev/null
@@ -1,992 +0,0 @@
-/* Output bytecodes for GNU C-compiler.
- Copyright (C) 1993, 1994 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-
-#include "config.h"
-#ifdef __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-#include "machmode.h"
-#include "rtl.h"
-#include "real.h"
-#include "obstack.h"
-#include "bytecode.h"
-#ifdef __GNUC__
-#include "bytetypes.h"
-#endif
-#include "bc-emit.h"
-#include "bc-opcode.h"
-#include "bc-typecd.h"
-#include "bi-run.h"
-
-#include <stdio.h>
-
-extern char *xmalloc (), *xrealloc ();
-extern void free ();
-
-extern struct obstack *rtl_obstack;
-
-/* Indexed by mode class, gives the narrowest mode for each class. */
-
-extern enum machine_mode class_narrowest_mode[(int) MAX_MODE_CLASS];
-
-/* Commonly used modes. */
-/* Mode whose width is BITS_PER_UNIT */
-extern enum machine_mode byte_mode;
-
-/* Mode whose width is BITS_PER_WORD */
-extern enum machine_mode word_mode;
-
-/* Vector indexed by opcode giving info about the args for each opcode. */
-static struct arityvec arityvec[] = {
-#include "bc-arity.h"
-};
-
-/* How to print a symbol name for the assembler. */
-static void
-prsym (file, s)
- FILE *file;
- char *s;
-{
- if (*s == '*')
- fprintf (file, "%s", s + 1);
- else
-
-#ifdef NAMES_HAVE_UNDERSCORES
- fprintf (file, "_%s", s);
-#else
- fprintf (file, "%s", s);
-#endif
-
-}
-
-/* Maintain a bucket hash table for symbol names. */
-
-#define HASH_BITS 32
-#define HASH_SIZE 509
-
-static struct bc_sym *hashtab[HASH_SIZE];
-
-static unsigned int
-hash (name)
- char *name;
-{
- unsigned int hash = 0;
-
- while (*name)
- {
- hash = hash << 3 | hash >> HASH_BITS - 3;
- hash += *name++;
- }
-
- return hash % HASH_SIZE;
-}
-
-
-/* Look up the named symbol, creating it if it doesn't exist. */
-struct bc_sym *
-sym_lookup (name)
- char *name;
-{
- int i;
- struct bc_sym *s;
-
- i = hash (name);
- for (s = hashtab[i]; s; s = s->next)
- if (!strcmp (s->name, name))
- return s;
-
- s = (struct bc_sym *) xmalloc (sizeof (struct bc_sym));
- s->name = xmalloc (strlen (name) + 1);
- strcpy (s->name, name);
- s->defined = s->global = s->common = 0;
- s->val = 0;
- s->next = hashtab[i];
- hashtab[i] = s;
- return s;
-}
-
-
-/* Write out .globl and common symbols to the named file. */
-static void
-bc_sym_write (file)
- FILE *file;
-{
- int i;
- struct bc_sym *s;
-
- for (i = 0; i < HASH_SIZE; ++i)
- for (s = hashtab[i]; s; s = s->next)
- {
- if (s->global)
- {
- fprintf (file, "\n\t.globl ");
- prsym (file, s->name);
- putc ('\n', file);
- if (s->common)
- {
- fprintf (file, "\n\t.comm ");
- prsym (file, s->name);
- fprintf (file, ", %lu\n", s->val);
- }
- }
- else if (s->common)
- {
- fprintf (file, "\n\t.lcomm ");
- prsym (file, s->name);
- fprintf (file, ", %lu\n", s->val);
- }
- }
-}
-
-
-
-
-/* Create and initialize a new segment. */
-static struct bc_seg *
-seg_create ()
-{
- struct bc_seg *result;
-
- result = (struct bc_seg *) xmalloc (sizeof (struct bc_seg));
- result->alloc = 256;
- result->data = xmalloc (result->alloc);
- result->size = 0;
- result->syms = 0;
- result->relocs = 0;
- return result;
-}
-
-
-/* Advance the segment index to the next alignment boundary. */
-static void
-seg_align (seg, log)
- struct bc_seg *seg;
- int log;
-{
- unsigned int oldsize = seg->size;
-
- seg->size = seg->size + (1 << log) - 1 & ~((1 << log) - 1);
- if (seg->size > seg->alloc)
- {
- while (seg->size > seg->alloc)
- seg->alloc *= 2;
- seg->data = xrealloc (seg->data, seg->alloc);
- }
- bzero (seg->data + oldsize, seg->size - oldsize);
-}
-
-
-/* Append the given data to the given segment. */
-static void
-seg_data (seg, data, size)
- struct bc_seg *seg;
- char *data;
- unsigned int size;
-{
- if (seg->size + size > seg->alloc)
- {
- while (seg->size + size > seg->alloc)
- seg->alloc *= 2;
- seg->data = xrealloc (seg->data, seg->alloc);
- }
-
- bcopy (data, seg->data + seg->size, size);
- seg->size += size;
-}
-
-
-/* Append a zero-filled skip to the given segment. */
-static void
-seg_skip (seg, size)
- struct bc_seg *seg;
- unsigned int size;
-{
- if (seg->size + size > seg->alloc)
- {
- while (seg->size + size > seg->alloc)
- seg->alloc *= 2;
- seg->data = xrealloc (seg->data, seg->alloc);
- }
-
- memset (seg->data + seg->size, 0, size);
- seg->size += size;
-}
-
-
-/* Define the given name as the current offset in the given segment. It
- is an error if the name is already defined. Return 0 or 1 indicating
- failure or success respectively. */
-static int
-seg_defsym (seg, name)
- struct bc_seg *seg;
- char *name;
-{
- struct bc_sym *sym;
- struct bc_segsym *segsym;
-
- sym = sym_lookup (name);
- if (sym->defined)
- return 0;
-
- sym->defined = 1;
- sym->val = seg->size;
- segsym = (struct bc_segsym *) xmalloc (sizeof (struct bc_segsym));
- segsym->sym = sym;
- segsym->next = seg->syms;
- seg->syms = segsym;
- return 1;
-}
-
-
-/* Generate in seg's data a reference to the given sym, adjusted by
- the given offset. */
-static void
-seg_refsym (seg, name, offset)
- struct bc_seg *seg;
- char *name;
- int offset;
-{
- struct bc_sym *sym;
- struct bc_segreloc *segreloc;
-
- sym = sym_lookup (name);
- segreloc = (struct bc_segreloc *) xmalloc (sizeof (struct bc_segreloc));
- segreloc->offset = seg->size;
- segreloc->sym = sym;
- segreloc->next = seg->relocs;
- seg->relocs = segreloc;
- seg_data (seg, (char *) &offset, sizeof offset);
-}
-
-
-/* Concatenate the contents of given segments into the first argument. */
-static void
-seg_concat (result, seg)
- struct bc_seg *result, *seg;
-{
- unsigned int fix;
- struct bc_segsym *segsym;
- struct bc_segreloc *segreloc;
-
- seg_align (result, MACHINE_SEG_ALIGN);
- fix = result->size;
- seg_data (result, seg->data, seg->size);
- free (seg->data);
-
- /* Go through the symbols and relocs of SEG, adjusting their offsets
- for their new location in RESULT. */
- if (seg->syms)
- {
- segsym = seg->syms;
- do
- segsym->sym->val += fix;
- while (segsym->next && (segsym = segsym->next));
- segsym->next = result->syms;
- result->syms = seg->syms;
- }
- if (seg->relocs)
- {
- segreloc = seg->relocs;
- do
- segreloc->offset += fix;
- while (segreloc->next && (segreloc = segreloc->next));
- segreloc->next = result->relocs;
- result->relocs = seg->relocs;
- }
-
- free ((char *) seg);
-}
-
-/* Write a segment to a file. */
-static void
-bc_seg_write (seg, file)
- struct bc_seg *seg;
- FILE *file;
-{
- struct bc_segsym *segsym, *nsegsym, *psegsym;
- struct bc_segreloc *segreloc, *nsegreloc, *psegreloc;
- int i, offset, flag;
-
- /* Reverse the list of symbols. */
- for (psegsym = 0, segsym = seg->syms; segsym; segsym = nsegsym)
- {
- nsegsym = segsym->next;
- segsym->next = psegsym;
- psegsym = segsym;
- }
- seg->syms = psegsym;
-
- /* Reverse the list of relocs. */
- for (psegreloc = 0, segreloc = seg->relocs; segreloc; segreloc = nsegreloc)
- {
- nsegreloc = segreloc->next;
- segreloc->next = psegreloc;
- psegreloc = segreloc;
- }
- seg->relocs = psegreloc;
-
- /* Output each byte of the segment. */
- for (i = 0, segsym = seg->syms, segreloc = seg->relocs; i < seg->size; ++i)
- {
- while (segsym && segsym->sym->val == i)
- {
- if (i % 8 != 0)
- putc ('\n', file);
-
- BC_WRITE_SEGSYM (segsym, file);
- segsym = segsym->next;
- flag = 1;
- }
- if (segreloc && segreloc->offset == i)
- {
- if (i % 8 != 0)
- putc ('\n', file);
-
- bcopy (seg->data + i, (char *) &offset, sizeof (int));
- i += sizeof (int) - 1;
-
- BC_WRITE_RELOC_ENTRY (segreloc, file, offset);
- segreloc = segreloc->next;
- flag = 1;
- }
- else
- {
- if (i % 8 == 0 || flag)
- BC_START_BYTECODE_LINE (file);
-
- BC_WRITE_BYTECODE (i % 8 == 0 || flag ? ' ' : ',',
- seg->data[i] & 0xFF,
- file);
- flag = 0;
- if (i % 8 == 7)
- putc ('\n', file);
- }
- }
-
- /* Paranoia check--we should have visited all syms and relocs during
- the output pass. */
-
- if (segsym || segreloc)
- abort ();
-}
-
-
-
-/* Text and data segments of the object file in making. */
-static struct bc_seg *bc_text_seg;
-static struct bc_seg *bc_data_seg;
-
-/* Called before anything else in this module. */
-void
-bc_initialize ()
-{
- int min_class_size[(int) MAX_MODE_CLASS];
- enum machine_mode mode;
- int i;
-
- bc_init_mode_to_code_map ();
-
- bc_text_seg = seg_create ();
- bc_data_seg = seg_create ();
-
- dconst0 = REAL_VALUE_ATOF ("0", DFmode);
- dconst1 = REAL_VALUE_ATOF ("1", DFmode);
- dconst2 = REAL_VALUE_ATOF ("2", DFmode);
- dconstm1 = REAL_VALUE_ATOF ("-1", DFmode);
-
- /* Find the narrowest mode for each class and compute the word and byte
- modes. */
-
- for (i = 0; i < (int) MAX_MODE_CLASS; i++)
- min_class_size[i] = 1000;
-
- for (mode = VOIDmode; (int) mode < (int) MAX_MACHINE_MODE;
- mode = (enum machine_mode) ((int) mode + 1))
- {
- if (GET_MODE_SIZE (mode) < min_class_size[(int) GET_MODE_CLASS (mode)])
- {
- class_narrowest_mode[(int) GET_MODE_CLASS (mode)] = mode;
- min_class_size[(int) GET_MODE_CLASS (mode)] = GET_MODE_SIZE (mode);
- }
- if (GET_MODE_CLASS (mode) == MODE_INT
- && GET_MODE_BITSIZE (mode) == BITS_PER_UNIT)
- byte_mode = mode;
-
- if (GET_MODE_CLASS (mode) == MODE_INT
- && GET_MODE_BITSIZE (mode) == BITS_PER_WORD)
- word_mode = mode;
- }
-}
-
-
-/* External addresses referenced in a function. Rather than trying to
- work relocatable address directly into bytecoded functions (which would
- require us to provide hairy location info and possibly obey alignment
- rules imposed by the architecture) we build an auxiliary table of
- pointer constants, and encode just offsets into this table into the
- actual bytecode. */
-static struct bc_seg *ptrconsts;
-
-/* Trampoline code for the function entry. */
-struct bc_seg *trampoline;
-
-/* Actual byte code of the function. */
-struct bc_seg *bytecode;
-
-/* List of labels defined in the function. */
-struct bc_label *labels;
-
-/* List of label references in the function. */
-struct bc_labelref *labelrefs;
-
-
-/* Add symbol to pointer table. Return offset into table where
- pointer was stored. The offset usually goes into the bytecode
- stream as a constP literal. */
-int
-bc_define_pointer (p)
- char *p;
-{
- int offset = ptrconsts->size;
-
- seg_refsym (ptrconsts, p, 0);
- return offset;
-}
-
-
-/* Begin a bytecoded function. */
-int
-bc_begin_function (name)
- char *name;
-{
- ptrconsts = seg_create ();
- trampoline = seg_create ();
- bytecode = seg_create ();
- return seg_defsym (trampoline, name);
-}
-
-
-/* Force alignment in inline bytecode. */
-void
-bc_align_bytecode (align)
- int align;
-{
- seg_align (bytecode, align);
-}
-
-
-/* Emit data inline into bytecode. */
-void
-bc_emit_bytecode_const (data, size)
- char *data;
- unsigned int size;
-{
- if (bytecode)
- seg_data (bytecode, data, size);
-}
-
-
-/* Create a new "bytecode label", to have its value defined later.
- Bytecode labels have nothing to do with the object file symbol table,
- and are purely local to a given bytecoded function. */
-struct bc_label *
-bc_get_bytecode_label ()
-{
- struct bc_label *result;
-
- result = (struct bc_label *) xmalloc (sizeof (struct bc_label));
- result->defined = 0;
- result->next = labels;
- result->uid = 0;
- labels = result;
- return result;
-}
-
-
-/* Define the given label with the current location counter. */
-int
-bc_emit_bytecode_labeldef (label)
- struct bc_label *label;
-{
- extern int bc_new_uid ();
-
- if (!label || label->defined)
- return 0;
-
- label->offset = bytecode->size;
- label->defined = 1;
- label->uid = bc_new_uid ();
-
-#ifdef DEBUG_PRINT_CODE
- fprintf (stderr, "$%lx:\n", label);
-#endif
-
- return 1;
-}
-
-
-/* Generate a location-relative reference to the given bytecode label.
- It need not be defined yet; label references will be backpatched later. */
-void
-bc_emit_bytecode_labelref (label)
- struct bc_label *label;
-{
- struct bc_labelref *labelref;
- static int zero;
-
- labelref = (struct bc_labelref *) xmalloc (sizeof (struct bc_labelref));
- labelref->label = label;
- labelref->offset = bytecode->size;
- labelref->next = labelrefs;
- labelrefs = labelref;
-
-#ifdef DEBUG_PRINT_CODE
- fprintf (stderr, " $%lx", label);
-#endif
-
- seg_data (bytecode, (char *) &zero, sizeof zero);
-}
-
-
-/* Emit a reference to an external address; generate the reference in the
- ptrconst area, and emit an offset in the bytecode. */
-void
-bc_emit_code_labelref (name, offset)
- char *name;
- int offset;
-{
- int ptroff;
-
- ptroff = ptrconsts->size / sizeof (char *);
- seg_data (bytecode, (char *) &ptroff, sizeof ptroff);
- seg_refsym (ptrconsts, name, offset);
-
-#ifdef DEBUG_PRINT_CODE
- fprintf (stderr, " [external <%x> %s]", ptroff, name);
-#endif
-}
-
-
-/* Backpatch label references in the byte code, and concatenate the bytecode
- and pointer constant segments to the cumulative text for the object file.
- Return a label name for the pointer constants region. */
-char *
-bc_end_function ()
-{
- int addr;
- struct bc_label *label, *next;
- struct bc_labelref *ref, *nextref;
- char ptrconsts_label[20];
- static int nlab;
-
- /* Backpatch bytecode label references. */
- for (ref = labelrefs; ref; ref = ref->next)
- if (ref->label->defined)
- {
- addr = ref->label->offset;
- bcopy ((char *) &addr, bytecode->data + ref->offset, sizeof addr);
- }
-
- /* Free the chains of labelrefs and labeldefs. */
- for (ref = labelrefs; ref; ref = nextref)
- {
- nextref = ref->next;
- free ((char *) ref);
- }
-
- for (label = labels; label; label = next)
- {
- next = label->next;
- free ((char *) label);
- }
-
- seg_concat (trampoline, bytecode);
- seg_align (trampoline, MACHINE_SEG_ALIGN);
- sprintf (ptrconsts_label, "*LP%d", nlab++);
- seg_defsym (trampoline, ptrconsts_label);
- seg_concat (trampoline, ptrconsts);
- seg_concat (bc_text_seg, trampoline);
-
- labels = 0;
- labelrefs = 0;
- trampoline = 0;
- bytecode = 0;
- ptrconsts = 0;
-
- return sym_lookup (ptrconsts_label)->name;
-}
-
-/* Force alignment in const data. */
-void
-bc_align_const (align)
- int align;
-{
- seg_align (bc_text_seg, align);
-}
-
-/* Emit const data. */
-void
-bc_emit_const (data, size)
- char *data;
- unsigned int size;
-{
- seg_data (bc_text_seg, data, size);
-}
-
-/* Emit a zero-filled constant skip. */
-void
-bc_emit_const_skip (size)
- unsigned int size;
-{
- seg_skip (bc_text_seg, size);
-}
-
-/* Emit a label definition in const data. */
-int
-bc_emit_const_labeldef (name)
- char *name;
-{
- return seg_defsym (bc_text_seg, name);
-}
-
-/* Emit a label reference in const data. */
-void
-bc_emit_const_labelref (name, offset)
- char *name;
- int offset;
-{
- seg_refsym (bc_text_seg, name, offset);
-}
-
-/* Force alignment in data. */
-void
-bc_align_data (align)
- int align;
-{
- seg_align (bc_data_seg, align);
-}
-
-/* Emit data. */
-void
-bc_emit_data (data, size)
- char *data;
- unsigned int size;
-{
- seg_data (bc_data_seg, data, size);
-}
-
-/* Emit a zero-filled data skip. */
-void
-bc_emit_data_skip (size)
- unsigned int size;
-{
- seg_skip (bc_data_seg, size);
-}
-
-/* Emit label definition in data. */
-int
-bc_emit_data_labeldef (name)
- char *name;
-{
- return seg_defsym (bc_data_seg, name);
-}
-
-/* Emit label reference in data. */
-void
-bc_emit_data_labelref (name, offset)
- char *name;
- int offset;
-{
- seg_refsym (bc_data_seg, name, offset);
-}
-
-/* Emit a common block of the given name and size. Note that
- when the .o file is actually written non-global "common"
- blocks will have to be turned into space in the data section. */
-int
-bc_emit_common (name, size)
- char *name;
- unsigned int size;
-{
- struct bc_sym *sym;
-
- sym = sym_lookup (name);
- if (sym->defined)
- return 0;
-
- sym->defined = 1;
- sym->common = 1;
- sym->val = size;
- return 1;
-}
-
-/* Globalize the given label. */
-void
-bc_globalize_label (name)
- char *name;
-{
- struct bc_sym *sym;
-
- sym = sym_lookup (name);
- sym->global = 1;
-}
-
-static enum { in_text, in_data } section = in_text;
-
-void
-bc_text ()
-{
- section = in_text;
-}
-
-void
-bc_data ()
-{
- section = in_data;
-}
-
-void
-bc_align (align)
- int align;
-{
- if (section == in_text)
- bc_align_const (align);
- else
- bc_align_data (align);
-}
-
-void
-bc_emit (data, size)
- char *data;
- unsigned int size;
-{
- if (section == in_text)
- bc_emit_const (data, size);
- else
- bc_emit_data (data, size);
-}
-
-void
-bc_emit_skip (size)
- unsigned int size;
-{
- if (section == in_text)
- bc_emit_const_skip (size);
- else
- bc_emit_data_skip (size);
-}
-
-int
-bc_emit_labeldef (name)
- char *name;
-{
- if (section == in_text)
- return bc_emit_const_labeldef (name);
- else
- return bc_emit_data_labeldef (name);
-}
-
-void
-bc_emit_labelref (name, offset)
- char *name;
- int offset;
-{
- if (section == in_text)
- bc_emit_const_labelref (name, offset);
- else
- bc_emit_data_labelref (name, offset);
-}
-
-void
-bc_write_file (file)
- FILE *file;
-{
- BC_WRITE_FILE (file);
-}
-
-
-/* Allocate a new bytecode rtx.
- If you supply a null BC_LABEL, we generate one. */
-
-rtx
-bc_gen_rtx (label, offset, bc_label)
- char *label;
- int offset;
- struct bc_label *bc_label;
-{
- rtx r;
-
- if (bc_label == 0)
- bc_label = (struct bc_label *) xmalloc (sizeof (struct bc_label));
-
- r = gen_rtx (CODE_LABEL, VOIDmode, label, bc_label);
- bc_label->offset = offset;
-
- return r;
-}
-
-
-/* Print bytecode rtx */
-void
-bc_print_rtl (fp, r)
- FILE *fp;
- rtx r;
-{
-#if 0 /* This needs to get fixed to really work again. */
- /* BC_WRITE_RTL has a definition
- that doesn't even make sense for this use. */
- BC_WRITE_RTL (r, fp);
-#endif
-}
-
-
-/* Emit a bytecode, keeping a running tally of the stack depth. */
-void
-bc_emit_bytecode (bytecode)
- enum bytecode_opcode bytecode;
-{
- char byte;
- static int prev_lineno = -1;
-
- byte = (char) bytecode;
-
-#ifdef BCDEBUG_PRINT_CODE
- if (lineno != prev_lineno)
- {
- fprintf (stderr, "<line %d>\n", lineno);
- prev_lineno = lineno;
- }
-
- fputs (opcode_name[(unsigned int) bytecode], stderr);
-#endif
-
- /* Due to errors we are often requested to output bytecodes that
- will cause an interpreter stack undeflow when executed. Instead of
- dumping core on such occasions, we omit the bytecode. Erroneous code
- should not be executed, regardless. This makes life much easier, since
- we don't have to deceive ourselves about the known stack depth. */
-
- bc_emit_bytecode_const (&byte, 1);
-
- if ((stack_depth -= arityvec[(int) bytecode].ninputs) >= 0)
- {
- if ((stack_depth += arityvec[(int) bytecode].noutputs) > max_stack_depth)
- max_stack_depth = stack_depth;
- }
-
-#ifdef VALIDATE_STACK_FOR_BC
- VALIDATE_STACK_FOR_BC ();
-#endif
-}
-
-
-#ifdef BCDEBUG_PRINT_CODE
-#define PRLIT(TYPE, PTR) fprintf (stderr, " [%x]", *(TYPE *) PTR)
-#else
-#define PRLIT(X,Y)
-#endif
-
-/* Emit a complete bytecode instruction, expecting the correct number
- of literal values in the call. First argument is the instruction, the
- remaining arguments are literals of size HOST_WIDE_INT or smaller. */
-void
-bc_emit_instruction VPROTO((enum bytecode_opcode opcode, ...))
-{
-#ifndef __STDC__
- enum bytecode_opcode opcode;
-#endif
- va_list arguments;
- int nliteral, instruction;
-
- VA_START (arguments, opcode);
-
-#ifndef __STDC__
- opcode = va_arg (arguments, enum bytecode_opcode);
-#endif
-
- /* Emit instruction bytecode */
- bc_emit_bytecode (opcode);
- instruction = (int) opcode;
-
- /* Loop literals and emit as bytecode constants */
- for (nliteral = 0; nliteral < arityvec[instruction].nliterals; nliteral++)
- {
- switch (arityvec[instruction].literals[nliteral])
- {
-/* This conditional is a kludge, but it's necessary
- because TYPE might be long long. */
-#ifdef __GNUC__
- /* Expand definitions into case statements */
-#define DEFTYPECODE(CODE, NAME, MODE, TYPE) \
- case CODE: \
- { \
- TYPE temp = va_arg (arguments, TYPE); \
- bc_emit_bytecode_const ((void *) &temp, sizeof temp); \
- PRLIT (TYPE, &temp); } \
- break;
-
-#include "bc-typecd.def"
-
-#undef DEFTYPECODE
-#endif /* __GNUC__ */
-
- default:
- abort ();
- }
- }
-
-#ifdef BCDEBUG_PRINT_CODE
- fputc ('\n', stderr);
-#endif
-}
-
-/* Emit the machine-code interface trampoline at the beginning of a byte
- coded function. The argument is a label name of the interpreter
- bytecode callinfo structure; the return value is a label name for
- the beginning of the actual bytecode. */
-char *
-bc_emit_trampoline (callinfo)
- char *callinfo;
-{
- char mylab[20];
- static int n;
-
- sprintf (mylab, "*LB%d", n++);
-
- BC_EMIT_TRAMPOLINE (trampoline, callinfo);
-
- seg_defsym (bytecode, mylab);
- return sym_lookup (mylab)->name;
-}
-
-
-/* Simple strdup */
-char *
-bc_xstrdup (str)
- char *str;
-{
- char *tmp = xmalloc (strlen (str) + 1);
-
- strcpy (tmp, str);
- return tmp;
-}
diff --git a/contrib/gcc/bc-emit.h b/contrib/gcc/bc-emit.h
deleted file mode 100644
index c00da5b35393..000000000000
--- a/contrib/gcc/bc-emit.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/* bc-emit.h - declare entry points for producing object files of bytecodes. */
-
-/* Internal format of symbol table for the object file. */
-struct bc_sym
-{
- /* Private copy separately malloc'd. */
- char *name;
-
- /* Symbol has a defined value. */
- unsigned int defined:1;
-
- /* Symbol has been globalized. */
- unsigned int global:1;
-
- /* Symbol is common. */
- unsigned int common:1;
-
- /* Value if defined. */
- unsigned long int val;
-
- /* Used in internal symbol table structure. */
- struct bc_sym *next;
-};
-
-
-/* List of symbols defined in a particular segment. */
-struct bc_segsym
-{
- struct bc_sym *sym;
- struct bc_segsym *next;
-};
-
-
-/* List of relocations needed in a particular segment. */
-struct bc_segreloc
-{
- /* Offset of datum to be relocated. */
- unsigned int offset;
-
- /* Symbol to be relocated by. */
- struct bc_sym *sym;
-
- struct bc_segreloc *next;
-};
-
-
-/* Segment of an object file. */
-struct bc_seg
-{
- /* Size allocated to contents. */
- unsigned int alloc;
-
- /* Pointer to base of contents. */
- char *data;
-
- /* Actual size of contents. */
- unsigned int size;
-
- /* List of symbols defined in this segment. */
- struct bc_segsym *syms;
-
- /* List of relocations for this segment. */
- struct bc_segreloc *relocs;
-};
-
-
-/* Anonymous bytecode label within a single function. */
-struct bc_label
-{
- /* Offset of label from start of segment. */
- unsigned int offset;
-
- /* True when offset is valid. */
- unsigned int defined:1;
-
- /* Unique bytecode ID, used to determine innermost
- block containment */
- int uid;
-
- /* Next node in list */
- struct bc_label *next;
-};
-
-
-/* Reference to a bc_label; a list of all such references is kept for
- the function, then when it is finished they are backpatched to
- contain the correct values. */
-
-struct bc_labelref
-{
- /* Label referenced. */
- struct bc_label *label;
-
- /* Code offset of reference. */
- unsigned int offset;
-
- /* Next labelref in list */
- struct bc_labelref *next;
-};
-
-
-
-extern void bc_initialize();
-extern int bc_begin_function();
-extern char *bc_emit_trampoline();
-extern void bc_emit_bytecode();
-extern void bc_emit_bytecode_const();
-extern struct bc_label *bc_get_bytecode_label();
-extern int bc_emit_bytecode_labeldef();
-extern void bc_emit_bytecode_labelref();
-extern void bc_emit_code_labelref();
-extern char *bc_end_function();
-extern void bc_align_const();
-extern void bc_emit_const();
-extern void bc_emit_const_skip();
-extern int bc_emit_const_labeldef();
-extern void bc_emit_const_labelref();
-extern void bc_align_data();
-extern void bc_emit_data();
-extern void bc_emit_data_skip();
-extern int bc_emit_data_labeldef();
-extern void bc_emit_data_labelref();
-extern int bc_define_pointer ();
-extern int bc_emit_common();
-extern void bc_globalize_label();
-extern void bc_text();
-extern void bc_data();
-extern void bc_align();
-extern void bc_emit();
-extern void bc_emit_skip();
-extern int bc_emit_labeldef();
-extern void bc_emit_labelref();
-extern void bc_write_file();
diff --git a/contrib/gcc/bc-optab.c b/contrib/gcc/bc-optab.c
deleted file mode 100644
index b7ff48652377..000000000000
--- a/contrib/gcc/bc-optab.c
+++ /dev/null
@@ -1,789 +0,0 @@
-/* Bytecode conversion definitions for GNU C-compiler.
- Copyright (C) 1993, 1994 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-
-#include "config.h"
-#include "tree.h"
-#include "rtl.h"
-#include "machmode.h"
-#include "obstack.h"
-#include "bytecode.h"
-#include "bc-typecd.h"
-#include "bc-opcode.h"
-#include "bc-optab.h"
-
-#define obstack_chunk_alloc xmalloc
-#define obstack_chunk_free free
-
-extern char *xmalloc ();
-extern void free ();
-
-/* Table relating interpreter typecodes to machine modes. */
-#define GET_TYPECODE_MODE(CODE) (typecode_mode[((int) CODE)])
-enum machine_mode typecode_mode[] = {
-#define DEFTYPECODE(CODE, NAME, MODE, TYPE) MODE,
-#include "bc-typecd.def"
-#undef DEFTYPECODE
-};
-
-/* Machine mode to type code map */
-static enum typecode signed_mode_to_code_map[MAX_MACHINE_MODE+1];
-static enum typecode unsigned_mode_to_code_map[MAX_MACHINE_MODE+1];
-
-#define GET_TYPECODE_SIZE(CODE) GET_MODE_SIZE (GET_TYPECODE_MODE (CODE))
-
-#define BIG_ARBITRARY_NUMBER 100000
-
-/* Table of recipes for conversions among scalar types, to be filled
- in as needed at run time. */
-static struct conversion_recipe
-{
- unsigned char *opcodes; /* Bytecodes to emit in order. */
- int nopcodes; /* Count of bytecodes. */
- int cost; /* A rather arbitrary cost function. */
-} conversion_recipe[NUM_TYPECODES][NUM_TYPECODES];
-
-/* Binary operator tables. */
-struct binary_operator optab_plus_expr[] = {
- { addSI, SIcode, SIcode, SIcode },
- { addDI, DIcode, DIcode, DIcode },
- { addSF, SFcode, SFcode, SFcode },
- { addDF, DFcode, DFcode, DFcode },
- { addXF, XFcode, XFcode, XFcode },
- { addPSI, Pcode, Pcode, SIcode },
- { -1, -1, -1, -1 },
-};
-
-struct binary_operator optab_minus_expr[] = {
- { subSI, SIcode, SIcode, SIcode },
- { subDI, DIcode, DIcode, DIcode },
- { subSF, SFcode, SFcode, SFcode },
- { subDF, DFcode, DFcode, DFcode },
- { subXF, XFcode, XFcode, XFcode },
- { subPP, SIcode, Pcode, Pcode },
- { -1, -1, -1, -1 },
-};
-
-/* The ordering of the tables for multiplicative operators
- is such that unsigned operations will be preferred to signed
- operations when one argument is unsigned. */
-
-struct binary_operator optab_mult_expr[] = {
- { mulSU, SUcode, SUcode, SUcode },
- { mulDU, DUcode, DUcode, DUcode },
- { mulSI, SIcode, SIcode, SIcode },
- { mulDI, DIcode, DIcode, DIcode },
- { mulSF, SFcode, SFcode, SFcode },
- { mulDF, DFcode, DFcode, DFcode },
- { mulXF, XFcode, XFcode, XFcode },
- { -1, -1, -1, -1 },
-};
-
-struct binary_operator optab_trunc_div_expr[] = {
- { divSU, SUcode, SUcode, SUcode },
- { divDU, DUcode, DUcode, DUcode },
- { divSI, SIcode, SIcode, SIcode },
- { divDI, DIcode, DIcode, DIcode },
- { -1, -1, -1, -1 },
-};
-
-struct binary_operator optab_trunc_mod_expr[] = {
- { modSU, SUcode, SUcode, SUcode },
- { modDU, DUcode, DUcode, DUcode },
- { modSI, SIcode, SIcode, SIcode },
- { modDI, DIcode, DIcode, DIcode },
- { -1, -1, -1, -1 },
-};
-
-struct binary_operator optab_rdiv_expr[] = {
- { divSF, SFcode, SFcode, SFcode },
- { divDF, DFcode, DFcode, DFcode },
- { divXF, XFcode, XFcode, XFcode },
- { -1, -1, -1, -1 },
-};
-
-struct binary_operator optab_bit_and_expr[] = {
- { andSI, SIcode, SIcode, SIcode },
- { andDI, DIcode, DIcode, DIcode },
- { -1, -1, -1, -1 },
-};
-
-struct binary_operator optab_bit_ior_expr[] = {
- { iorSI, SIcode, SIcode, SIcode },
- { iorDI, DIcode, DIcode, DIcode },
- { -1, -1, -1, -1 },
-};
-
-struct binary_operator optab_bit_xor_expr[] = {
- { xorSI, SIcode, SIcode, SIcode },
- { xorDI, DIcode, DIcode, DIcode },
- { -1, -1, -1, -1 },
-};
-
-struct binary_operator optab_lshift_expr[] = {
- { lshiftSI, SIcode, SIcode, SIcode },
- { lshiftSU, SUcode, SUcode, SIcode },
- { lshiftDI, DIcode, DIcode, SIcode },
- { lshiftDU, DUcode, DUcode, SIcode },
- { -1, -1, -1, -1 },
-};
-
-struct binary_operator optab_rshift_expr[] = {
- { rshiftSI, SIcode, SIcode, SIcode },
- { rshiftSU, SUcode, SUcode, SIcode },
- { rshiftDI, DIcode, DIcode, SIcode },
- { rshiftDU, DUcode, DUcode, SIcode },
- { -1, -1, -1, -1 },
-};
-
-struct binary_operator optab_truth_and_expr[] = {
- { andSI, SIcode, Tcode, Tcode },
- { -1, -1, -1, -1 },
-};
-
-struct binary_operator optab_truth_or_expr[] = {
- { iorSI, SIcode, Tcode, Tcode },
- { -1, -1, -1, -1 },
-};
-
-struct binary_operator optab_lt_expr[] = {
- { ltSI, Tcode, SIcode, SIcode },
- { ltSU, Tcode, SUcode, SUcode },
- { ltDI, Tcode, DIcode, DIcode },
- { ltDU, Tcode, DUcode, DUcode },
- { ltSF, Tcode, SFcode, SFcode },
- { ltDF, Tcode, DFcode, DFcode },
- { ltXF, Tcode, XFcode, XFcode },
- { ltP, Tcode, Pcode, Pcode },
- { -1, -1, -1, -1 },
-};
-
-struct binary_operator optab_le_expr[] = {
- { leSI, Tcode, SIcode, SIcode },
- { leSU, Tcode, SUcode, SUcode },
- { leDI, Tcode, DIcode, DIcode },
- { leDU, Tcode, DUcode, DUcode },
- { leSF, Tcode, SFcode, SFcode },
- { leDF, Tcode, DFcode, DFcode },
- { leXF, Tcode, XFcode, XFcode },
- { leP, Tcode, Pcode, Pcode },
- { -1, -1, -1, -1 },
-};
-
-struct binary_operator optab_ge_expr[] = {
- { geSI, Tcode, SIcode, SIcode },
- { geSU, Tcode, SUcode, SUcode },
- { geDI, Tcode, DIcode, DIcode },
- { geDU, Tcode, DUcode, DUcode },
- { geSF, Tcode, SFcode, SFcode },
- { geDF, Tcode, DFcode, DFcode },
- { geXF, Tcode, XFcode, XFcode },
- { geP, Tcode, Pcode, Pcode },
- { -1, -1, -1, -1 },
-};
-
-struct binary_operator optab_gt_expr[] = {
- { gtSI, Tcode, SIcode, SIcode },
- { gtSU, Tcode, SUcode, SUcode },
- { gtDI, Tcode, DIcode, DIcode },
- { gtDU, Tcode, DUcode, DUcode },
- { gtSF, Tcode, SFcode, SFcode },
- { gtDF, Tcode, DFcode, DFcode },
- { gtXF, Tcode, XFcode, XFcode },
- { gtP, Tcode, Pcode, Pcode },
- { -1, -1, -1, -1 },
-};
-
-struct binary_operator optab_eq_expr[] = {
- { eqSI, Tcode, SIcode, SIcode },
- { eqDI, Tcode, DIcode, DIcode },
- { eqSF, Tcode, SFcode, SFcode },
- { eqDF, Tcode, DFcode, DFcode },
- { eqXF, Tcode, XFcode, XFcode },
- { eqP, Tcode, Pcode, Pcode },
- { -1, -1, -1, -1 },
-};
-
-struct binary_operator optab_ne_expr[] = {
- { neSI, Tcode, SIcode, SIcode },
- { neDI, Tcode, DIcode, DIcode },
- { neSF, Tcode, SFcode, SFcode },
- { neDF, Tcode, DFcode, DFcode },
- { neXF, Tcode, XFcode, XFcode },
- { neP, Tcode, Pcode, Pcode },
- { -1, -1, -1, -1 },
-};
-
-/* Unary operator tables. */
-struct unary_operator optab_negate_expr[] = {
- { negSI, SIcode, SIcode },
- { negDI, DIcode, DIcode },
- { negSF, SFcode, SFcode },
- { negDF, DFcode, DFcode },
- { negXF, XFcode, XFcode },
- { -1, -1, -1 },
-};
-
-struct unary_operator optab_bit_not_expr[] = {
- { notSI, SIcode, SIcode },
- { notDI, DIcode, DIcode },
- { -1, -1, -1 },
-};
-
-struct unary_operator optab_truth_not_expr[] = {
- { notT, SIcode, SIcode },
- { -1, -1, -1 },
-};
-
-/* Increment operator tables. */
-struct increment_operator optab_predecrement_expr[] = {
- { predecQI, QIcode },
- { predecQI, QUcode },
- { predecHI, HIcode },
- { predecHI, HUcode },
- { predecSI, SIcode },
- { predecSI, SUcode },
- { predecDI, DIcode },
- { predecDI, DUcode },
- { predecP, Pcode },
- { predecSF, SFcode },
- { predecDF, DFcode },
- { predecXF, XFcode },
- { -1, -1 },
-};
-
-struct increment_operator optab_preincrement_expr[] = {
- { preincQI, QIcode },
- { preincQI, QUcode },
- { preincHI, HIcode },
- { preincHI, HUcode },
- { preincSI, SIcode },
- { preincSI, SUcode },
- { preincDI, DIcode },
- { preincDI, DUcode },
- { preincP, Pcode },
- { preincSF, SFcode },
- { preincDF, DFcode },
- { preincXF, XFcode },
- { -1, -1 },
-};
-
-struct increment_operator optab_postdecrement_expr[] = {
- { postdecQI, QIcode },
- { postdecQI, QUcode },
- { postdecHI, HIcode },
- { postdecHI, HUcode },
- { postdecSI, SIcode },
- { postdecSI, SUcode },
- { postdecDI, DIcode },
- { postdecDI, DUcode },
- { postdecP, Pcode },
- { postdecSF, SFcode },
- { postdecDF, DFcode },
- { postdecXF, XFcode },
- { -1, -1 },
-};
-
-struct increment_operator optab_postincrement_expr[] = {
- { postincQI, QIcode },
- { postincQI, QUcode },
- { postincHI, HIcode },
- { postincHI, HUcode },
- { postincSI, SIcode },
- { postincSI, SUcode },
- { postincDI, DIcode },
- { postincDI, DUcode },
- { postincP, Pcode },
- { postincSF, SFcode },
- { postincDF, DFcode },
- { postincXF, XFcode },
- { -1, -1 },
-};
-
-/* Table of conversions supported by the interpreter. */
-static struct conversion_info
-{
- enum bytecode_opcode opcode; /* here indicates the conversion needs no opcode. */
- enum typecode from;
- enum typecode to;
- int cost; /* 1 for no-op conversions, 2 for widening conversions,
- 4 for int/float conversions, 8 for narrowing conversions. */
-} conversion_info[] = {
- { -1, QIcode, QUcode, 1 },
- { -1, HIcode, HUcode, 1 },
- { -1, SIcode, SUcode, 1 },
- { -1, DIcode, DUcode, 1 },
- { -1, QUcode, QIcode, 1 },
- { -1, HUcode, HIcode, 1 },
- { -1, SUcode, SIcode, 1 },
- { -1, DUcode, DIcode, 1 },
- { -1, Tcode, SIcode, 1 },
- { convertQIHI, QIcode, HIcode, 2 },
- { convertQUHU, QUcode, HUcode, 2 },
- { convertQUSU, QUcode, SUcode, 2 },
- { convertHISI, HIcode, SIcode, 2 },
- { convertHUSU, HUcode, SUcode, 2 },
- { convertSIDI, SIcode, DIcode, 2 },
- { convertSUDU, SUcode, DUcode, 2 },
- { convertSFDF, SFcode, DFcode, 2 },
- { convertDFXF, DFcode, XFcode, 2 },
- { convertHIQI, HIcode, QIcode, 8 },
- { convertSIQI, SIcode, QIcode, 8 },
- { convertSIHI, SIcode, HIcode, 8 },
- { convertSUQU, SUcode, QUcode, 8 },
- { convertDISI, DIcode, SIcode, 8 },
- { convertDFSF, DFcode, SFcode, 8 },
- { convertXFDF, XFcode, DFcode, 8 },
- { convertPSI, Pcode, SIcode, 2 },
- { convertSIP, SIcode, Pcode, 2 },
- { convertSIT, SIcode, Tcode, 2 },
- { convertDIT, DIcode, Tcode, 2 },
- { convertSFT, SFcode, Tcode, 2 },
- { convertDFT, DFcode, Tcode, 2 },
- { convertXFT, XFcode, Tcode, 2 },
- { convertQISI, QIcode, SIcode, 2 },
- { convertPT, Pcode, Tcode, 2 },
- { convertSISF, SIcode, SFcode, 4 },
- { convertSIDF, SIcode, DFcode, 4 },
- { convertSIXF, SIcode, XFcode, 4 },
- { convertSUSF, SUcode, SFcode, 4 },
- { convertSUDF, SUcode, DFcode, 4 },
- { convertSUXF, SUcode, XFcode, 4 },
- { convertDISF, DIcode, SFcode, 4 },
- { convertDIDF, DIcode, DFcode, 4 },
- { convertDIXF, DIcode, XFcode, 4 },
- { convertDUSF, DUcode, SFcode, 4 },
- { convertDUDF, DUcode, DFcode, 4 },
- { convertDUXF, DUcode, XFcode, 4 },
- { convertSFSI, SFcode, SIcode, 4 },
- { convertDFSI, DFcode, SIcode, 4 },
- { convertXFSI, XFcode, SIcode, 4 },
- { convertSFSU, SFcode, SUcode, 4 },
- { convertDFSU, DFcode, SUcode, 4 },
- { convertXFSU, XFcode, SUcode, 4 },
- { convertSFDI, SFcode, DIcode, 4 },
- { convertDFDI, DFcode, DIcode, 4 },
- { convertXFDI, XFcode, DIcode, 4 },
- { convertSFDU, SFcode, DUcode, 4 },
- { convertDFDU, DFcode, DUcode, 4 },
- { convertXFDU, XFcode, DUcode, 4 },
- { convertSIQI, SIcode, QIcode, 8 },
-};
-
-#define NUM_CONVERSIONS (sizeof conversion_info / sizeof (struct conversion_info))
-
-/* List form of a conversion recipe. */
-struct conversion_list
-{
- enum bytecode_opcode opcode;
- enum typecode to;
- int cost;
- struct conversion_list *prev;
-};
-
-/* Determine if it is "reasonable" to add a given conversion to
- a given list of conversions. The following criteria define
- "reasonable" conversion lists:
- * No typecode appears more than once in the sequence (no loops).
- * At most one conversion from integer to float or vice versa is present.
- * Either sign extensions or zero extensions may be present, but not both.
- * No widening conversions occur after a signed/unsigned conversion.
- * The sequence of sizes must be strict nonincreasing or nondecreasing. */
-static int
-conversion_reasonable_p (conversion, list)
- struct conversion_info *conversion;
- struct conversion_list *list;
-{
- struct conversion_list *curr;
- int curr_size, prev_size;
- int has_int_float, has_float_int;
- int has_sign_extend, has_zero_extend;
- int has_signed_unsigned, has_unsigned_signed;
-
- has_int_float = 0;
- has_float_int = 0;
- has_sign_extend = 0;
- has_zero_extend = 0;
- has_signed_unsigned = 0;
- has_unsigned_signed = 0;
-
- /* Make sure the destination typecode doesn't already appear in
- the list. */
- for (curr = list; curr; curr = curr->prev)
- if (conversion->to == curr->to)
- return 0;
-
- /* Check for certain kinds of conversions. */
- if (TYPECODE_INTEGER_P (conversion->from)
- && TYPECODE_FLOAT_P (conversion->to))
- has_int_float = 1;
- if (TYPECODE_FLOAT_P (conversion->from)
- && TYPECODE_INTEGER_P (conversion->to))
- has_float_int = 1;
- if (TYPECODE_SIGNED_P (conversion->from)
- && TYPECODE_SIGNED_P (conversion->to)
- && GET_TYPECODE_SIZE (conversion->from)
- < GET_TYPECODE_SIZE (conversion->to))
- has_sign_extend = 1;
- if (TYPECODE_UNSIGNED_P (conversion->from)
- && TYPECODE_UNSIGNED_P (conversion->to)
- && GET_TYPECODE_SIZE (conversion->from)
- < GET_TYPECODE_SIZE (conversion->to))
- has_zero_extend = 1;
-
- for (curr = list; curr && curr->prev; curr = curr->prev)
- {
- if (TYPECODE_INTEGER_P (curr->prev->to)
- && TYPECODE_FLOAT_P (curr->to))
- has_int_float = 1;
- if (TYPECODE_FLOAT_P (curr->prev->to)
- && TYPECODE_INTEGER_P (curr->to))
- has_float_int = 1;
- if (TYPECODE_SIGNED_P (curr->prev->to)
- && TYPECODE_SIGNED_P (curr->to)
- && GET_TYPECODE_SIZE (curr->prev->to)
- < GET_TYPECODE_SIZE (curr->to))
- has_sign_extend = 1;
- if (TYPECODE_UNSIGNED_P (curr->prev->to)
- && TYPECODE_UNSIGNED_P (curr->to)
- && GET_TYPECODE_SIZE (curr->prev->to)
- < GET_TYPECODE_SIZE (curr->to))
- has_zero_extend = 1;
- if (TYPECODE_SIGNED_P (curr->prev->to)
- && TYPECODE_UNSIGNED_P (curr->to))
- has_signed_unsigned = 1;
- if (TYPECODE_UNSIGNED_P (curr->prev->to)
- && TYPECODE_SIGNED_P (curr->to))
- has_unsigned_signed = 1;
- }
-
- if (TYPECODE_INTEGER_P (conversion->from)
- && TYPECODE_INTEGER_P (conversion->to)
- && GET_TYPECODE_SIZE (conversion->to)
- > GET_TYPECODE_SIZE (conversion->from)
- && (has_signed_unsigned || has_unsigned_signed))
- return 0;
-
- if (has_float_int && has_int_float || has_sign_extend && has_zero_extend)
- return 0;
-
- /* Make sure the sequence of destination typecode sizes is
- strictly nondecreasing or strictly nonincreasing. */
- prev_size = GET_TYPECODE_SIZE (conversion->to);
- for (curr = list; curr; curr = curr->prev)
- {
- curr_size = GET_TYPECODE_SIZE (curr->to);
- if (curr_size != prev_size)
- break;
- }
- if (!curr)
- return 1;
-
- if (curr_size < prev_size)
- for (prev_size = curr_size; curr; curr = curr->prev)
- {
- curr_size = GET_TYPECODE_SIZE (curr->to);
- if (curr_size > prev_size)
- return 0;
- prev_size = curr_size;
- }
- else
- for (prev_size = curr_size; curr; curr = curr->prev)
- {
- curr_size = GET_TYPECODE_SIZE (curr->to);
- if (curr_size < prev_size)
- return 0;
- prev_size = curr_size;
- }
- return 1;
-}
-
-
-/* Exhaustively search all reasonable conversions to find one to
- convert the given types. */
-static struct conversion_recipe
-deduce_conversion (from, to)
- enum typecode from, to;
-{
- struct rl
- {
- struct conversion_list *list;
- struct rl *next;
- } *prev, curr, *good, *temp;
- struct conversion_list *conv, *best;
- int i, cost, bestcost;
- struct conversion_recipe result;
- struct obstack recipe_obstack;
-
-
- obstack_init (&recipe_obstack);
- curr.next = (struct rl *) obstack_alloc (&recipe_obstack, sizeof (struct rl));
- curr.next->list =
- (struct conversion_list *) obstack_alloc (&recipe_obstack,
- sizeof (struct conversion_list));
- curr.next->list->opcode = -1;
- curr.next->list->to = from;
- curr.next->list->cost = 0;
- curr.next->list->prev = 0;
- curr.next->next = 0;
- good = 0;
-
- while (curr.next)
- {
- /* Remove successful conversions from further consideration. */
- for (prev = &curr; prev; prev = prev->next)
- if (prev->next && prev->next->list->to == to)
- {
- temp = prev->next->next;
- prev->next->next = good;
- good = prev->next;
- prev->next = temp;
- }
-
- /* Go through each of the pending conversion chains, trying
- all possible candidate conversions on them. */
- for (prev = curr.next, curr.next = 0; prev; prev = prev->next)
- for (i = 0; i < NUM_CONVERSIONS; ++i)
- if (conversion_info[i].from == prev->list->to
- && conversion_reasonable_p (&conversion_info[i], prev->list))
- {
- temp = (struct rl *) obstack_alloc (&recipe_obstack,
- sizeof (struct rl));
- temp->list = (struct conversion_list *)
- obstack_alloc (&recipe_obstack,
- sizeof (struct conversion_list));
- temp->list->opcode = conversion_info[i].opcode;
- temp->list->to = conversion_info[i].to;
- temp->list->cost = conversion_info[i].cost;
- temp->list->prev = prev->list;
- temp->next = curr.next;
- curr.next = temp;
- }
- }
-
- bestcost = BIG_ARBITRARY_NUMBER;
- best = 0;
- for (temp = good; temp; temp = temp->next)
- {
- for (conv = temp->list, cost = 0; conv; conv = conv->prev)
- cost += conv->cost;
- if (cost < bestcost)
- {
- bestcost = cost;
- best = temp->list;
- }
- }
-
- if (!best)
- abort ();
-
- for (i = 0, conv = best; conv; conv = conv->prev)
- if (conv->opcode != -1)
- ++i;
-
- result.opcodes = (unsigned char *) xmalloc (i);
- result.nopcodes = i;
- for (conv = best; conv; conv = conv->prev)
- if (conv->opcode != -1)
- result.opcodes[--i] = conv->opcode;
- result.cost = bestcost;
- obstack_free (&recipe_obstack, 0);
- return result;
-}
-
-#define DEDUCE_CONVERSION(FROM, TO) \
- (conversion_recipe[(int) FROM][(int) TO].opcodes ? 0 \
- : (conversion_recipe[(int) FROM][(int) TO] \
- = deduce_conversion (FROM, TO), 0))
-
-
-/* Emit a conversion between the given scalar types. */
-void
-emit_typecode_conversion (from, to)
- enum typecode from, to;
-{
- int i;
-
- DEDUCE_CONVERSION (from, to);
- for (i = 0; i < conversion_recipe[(int) from][(int) to].nopcodes; ++i)
- bc_emit_instruction (conversion_recipe[(int) from][(int) to].opcodes[i]);
-}
-
-
-/* Initialize mode_to_code_map[] */
-void
-bc_init_mode_to_code_map ()
-{
- int mode;
-
- for (mode = 0; mode < MAX_MACHINE_MODE + 1; mode++)
- {
- signed_mode_to_code_map[mode] =
- unsigned_mode_to_code_map[mode] =
- LAST_AND_UNUSED_TYPECODE;
- }
-
-#define DEF_MODEMAP(SYM, CODE, UCODE, CONST, LOAD, STORE) \
- { signed_mode_to_code_map[(int) SYM] = CODE; \
- unsigned_mode_to_code_map[(int) SYM] = UCODE; }
-#include "modemap.def"
-#undef DEF_MODEMAP
-
- /* Initialize opcode maps for const, load, and store */
- bc_init_mode_to_opcode_maps ();
-}
-
-/* Given a machine mode return the preferred typecode. */
-enum typecode
-preferred_typecode (mode, unsignedp)
- enum machine_mode mode;
- int unsignedp;
-{
- enum typecode code = (unsignedp
- ? unsigned_mode_to_code_map
- : signed_mode_to_code_map) [MIN ((int) mode,
- (int) MAX_MACHINE_MODE)];
-
- if (code == LAST_AND_UNUSED_TYPECODE)
- abort ();
-
- return code;
-}
-
-
-/* Expand a conversion between the given types. */
-void
-bc_expand_conversion (from, to)
- tree from, to;
-{
- enum typecode fcode, tcode;
-
- fcode = preferred_typecode (TYPE_MODE (from), TREE_UNSIGNED (from));
- tcode = preferred_typecode (TYPE_MODE (to), TREE_UNSIGNED (to));
-
- emit_typecode_conversion (fcode, tcode);
-}
-
-/* Expand a conversion of the given type to a truth value. */
-void
-bc_expand_truth_conversion (from)
- tree from;
-{
- enum typecode fcode;
-
- fcode = preferred_typecode (TYPE_MODE (from), TREE_UNSIGNED (from));
- emit_typecode_conversion (fcode, Tcode);
-}
-
-/* Emit an appropriate binary operation. */
-void
-bc_expand_binary_operation (optab, resulttype, arg0, arg1)
- struct binary_operator optab[];
- tree resulttype, arg0, arg1;
-{
- int i, besti, cost, bestcost;
- enum typecode resultcode, arg0code, arg1code;
-
- resultcode = preferred_typecode (TYPE_MODE (resulttype), TREE_UNSIGNED (resulttype));
- arg0code = preferred_typecode (TYPE_MODE (TREE_TYPE (arg0)), TREE_UNSIGNED (resulttype));
- arg1code = preferred_typecode (TYPE_MODE (TREE_TYPE (arg1)), TREE_UNSIGNED (resulttype));
-
- besti = -1;
- bestcost = BIG_ARBITRARY_NUMBER;
-
- for (i = 0; optab[i].opcode != -1; ++i)
- {
- cost = 0;
- DEDUCE_CONVERSION (arg0code, optab[i].arg0);
- cost += conversion_recipe[(int) arg0code][(int) optab[i].arg0].cost;
- DEDUCE_CONVERSION (arg1code, optab[i].arg1);
- cost += conversion_recipe[(int) arg1code][(int) optab[i].arg1].cost;
- if (cost < bestcost)
- {
- besti = i;
- bestcost = cost;
- }
- }
-
- if (besti == -1)
- abort ();
-
- expand_expr (arg1, 0, VOIDmode, 0);
- emit_typecode_conversion (arg1code, optab[besti].arg1);
- expand_expr (arg0, 0, VOIDmode, 0);
- emit_typecode_conversion (arg0code, optab[besti].arg0);
- bc_emit_instruction (optab[besti].opcode);
- emit_typecode_conversion (optab[besti].result, resultcode);
-}
-
-/* Emit an appropriate unary operation. */
-void
-bc_expand_unary_operation (optab, resulttype, arg0)
- struct unary_operator optab[];
- tree resulttype, arg0;
-{
- int i, besti, cost, bestcost;
- enum typecode resultcode, arg0code;
-
- resultcode = preferred_typecode (TYPE_MODE (resulttype), TREE_UNSIGNED (resulttype));
- arg0code = preferred_typecode (TYPE_MODE (TREE_TYPE (arg0)), TREE_UNSIGNED (TREE_TYPE (arg0)));
-
- besti = -1;
- bestcost = BIG_ARBITRARY_NUMBER;
-
- for (i = 0; optab[i].opcode != -1; ++i)
- {
- DEDUCE_CONVERSION (arg0code, optab[i].arg0);
- cost = conversion_recipe[(int) arg0code][(int) optab[i].arg0].cost;
- if (cost < bestcost)
- {
- besti = i;
- bestcost = cost;
- }
- }
-
- if (besti == -1)
- abort ();
-
- expand_expr (arg0, 0, VOIDmode, 0);
- emit_typecode_conversion (arg0code, optab[besti].arg0);
- bc_emit_instruction (optab[besti].opcode);
- emit_typecode_conversion (optab[besti].result, resultcode);
-}
-
-
-/* Emit an appropriate increment. */
-void
-bc_expand_increment (optab, type)
- struct increment_operator optab[];
- tree type;
-{
- enum typecode code;
- int i;
-
- code = preferred_typecode (TYPE_MODE (type), TREE_UNSIGNED (type));
- for (i = 0; (int) optab[i].opcode >= 0; ++i)
- if (code == optab[i].arg)
- {
- bc_emit_instruction (optab[i].opcode);
- return;
- }
- abort ();
-}
diff --git a/contrib/gcc/bc-optab.h b/contrib/gcc/bc-optab.h
deleted file mode 100644
index 6ad0b8592f65..000000000000
--- a/contrib/gcc/bc-optab.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/* Bytecode token definitions for GNU C-compiler.
- Copyright (C) 1993 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-
-extern void bc_expand_conversion ();
-extern void bc_expand_truth_conversion ();
-extern void bc_expand_binary_operation ();
-extern void bc_expand_unary_operation ();
-
-struct binary_operator
-{
- enum bytecode_opcode opcode;
- enum typecode result;
- enum typecode arg0;
- enum typecode arg1;
-};
-
-extern struct binary_operator optab_plus_expr[];
-extern struct binary_operator optab_minus_expr[];
-extern struct binary_operator optab_mult_expr[];
-extern struct binary_operator optab_trunc_div_expr[];
-extern struct binary_operator optab_trunc_mod_expr[];
-extern struct binary_operator optab_rdiv_expr[];
-extern struct binary_operator optab_bit_and_expr[];
-extern struct binary_operator optab_bit_ior_expr[];
-extern struct binary_operator optab_bit_xor_expr[];
-extern struct binary_operator optab_lshift_expr[];
-extern struct binary_operator optab_rshift_expr[];
-extern struct binary_operator optab_truth_and_expr[];
-extern struct binary_operator optab_truth_or_expr[];
-extern struct binary_operator optab_lt_expr[];
-extern struct binary_operator optab_le_expr[];
-extern struct binary_operator optab_ge_expr[];
-extern struct binary_operator optab_gt_expr[];
-extern struct binary_operator optab_eq_expr[];
-extern struct binary_operator optab_ne_expr[];
-
-struct unary_operator
-{
- enum bytecode_opcode opcode;
- enum typecode result;
- enum typecode arg0;
-};
-
-extern struct unary_operator optab_negate_expr[];
-extern struct unary_operator optab_bit_not_expr[];
-extern struct unary_operator optab_truth_not_expr[];
-
-struct increment_operator
-{
- enum bytecode_opcode opcode;
- enum typecode arg;
-};
-
-extern struct increment_operator optab_predecrement_expr[];
-extern struct increment_operator optab_preincrement_expr[];
-extern struct increment_operator optab_postdecrement_expr[];
-extern struct increment_operator optab_postincrement_expr[];
diff --git a/contrib/gcc/bc-typecd.def b/contrib/gcc/bc-typecd.def
deleted file mode 100644
index fd92cdd92822..000000000000
--- a/contrib/gcc/bc-typecd.def
+++ /dev/null
@@ -1,21 +0,0 @@
-/* Typecodes used by the interpreter and their related
- machine modes and types.
-
- The last argument is used for retrieving the given
- type from a varargs list. Due to a bug in varargs,
- the type has to be the generic machine type of
- larger. */
-
-DEFTYPECODE (QIcode, "QI", QImode, SItype)
-DEFTYPECODE (QUcode, "QU", QImode, SUtype)
-DEFTYPECODE (HIcode, "HI", HImode, SItype)
-DEFTYPECODE (HUcode, "HU", HImode, SUtype)
-DEFTYPECODE (SIcode, "SI", SImode, SItype)
-DEFTYPECODE (SUcode, "SU", SImode, SUtype)
-DEFTYPECODE (DIcode, "DI", DImode, DItype)
-DEFTYPECODE (DUcode, "DU", DImode, DUtype)
-DEFTYPECODE (SFcode, "SF", SFmode, SFtype)
-DEFTYPECODE (DFcode, "DF", DFmode, DFtype)
-DEFTYPECODE (XFcode, "XF", XFmode, XFtype)
-DEFTYPECODE (Pcode, "P", PSImode, Ptype)
-DEFTYPECODE (Tcode, "T", SImode, SItype)
diff --git a/contrib/gcc/bc-typecd.h b/contrib/gcc/bc-typecd.h
deleted file mode 100644
index 2dcea0e08f51..000000000000
--- a/contrib/gcc/bc-typecd.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Typecode definitions for Bytecode Interpreter.
- Copyright (C) 1993 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-#ifndef TYPECODE_H
-#define TYPECODE_H
-
-enum typecode
-{
-#define DEFTYPECODE(CODE, NAME, MACHMODE, TYPE) CODE,
-#include "bc-typecd.def"
-#undef DEFTYPECODE
-
- LAST_AND_UNUSED_TYPECODE
-};
-
-/* Determine if a given type is integer. */
-#define TYPECODE_INTEGER_P(TYPECODE) ((int) (TYPECODE) < (int) SFcode)
-
-/* Determine if a given type is unsigned. */
-#define TYPECODE_UNSIGNED_P(TYPECODE) \
- (TYPECODE_INTEGER_P(TYPECODE) && (int) (TYPECODE) & 1)
-
-/* Determine if a given type is signed. */
-#define TYPECODE_SIGNED_P(TYPECODE) \
- (TYPECODE_INTEGER_P(TYPECODE) && !((int) (TYPECODE) & 1))
-
-/* Determine if a given type is floating. */
-#define TYPECODE_FLOAT_P(TYPECODE) \
- ((int) (TYPECODE) < (int) Pcode && !TYPECODE_INTEGER_P(TYPECODE))
-
-/* Determine if the given type is arithmetic. */
-#define TYPECODE_ARITH_P(TYPECODE) \
- (TYPECODE_INTEGER_P(TYPECODE) || TYPECODE_FLOAT_P(TYPECODE))
-
-#define NUM_TYPECODES ((int) LAST_AND_UNUSED_TYPECODE)
-
-#endif
diff --git a/contrib/gcc/bi-arity.c b/contrib/gcc/bi-arity.c
deleted file mode 100644
index da3607fbf5de..000000000000
--- a/contrib/gcc/bi-arity.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/* Bytecode Interpreter utility to generate arity table.
- Copyright (C) 1993 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-
-#include <stdio.h>
-#include "hconfig.h"
-#include "bi-defs.h"
-
-int
-length (n)
- struct node *n;
-{
- int k;
-
- for (k = 0; n; n = n->next)
- ++k;
- return k;
-}
-
-int
-main ()
-{
- struct def *d;
- struct variation *v;
- struct node *n;
-
- yyparse ();
- reverse ();
-
- for (d = defs; d; d = d->next)
- for (v = d->variations; v; v = v->next)
- {
- printf ("{ %d, %d, %d, {", length (v->inputs),
- length (v->outputs), length (v->literals));
- for (n = v->literals; n; n = n->next)
- printf ("(char) %scode, ", n->text);
- if (v->literals == 0)
- printf ("0");
- printf ("}},\n");
- }
-
- fflush (stdout);
- exit (ferror (stdout) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE);
- /* NOTREACHED */
- return 0;
-}
-
-/* Safely allocate NBYTES bytes of memory. Returns pointer to block of
- memory. */
-char *
-xmalloc (nbytes)
- int nbytes;
-{
- char *tmp = (char *) malloc (nbytes);
-
- if (!tmp)
- {
- fprintf (stderr, "can't allocate %d bytes (out of virtual memory)\n", nbytes);
- exit (FATAL_EXIT_CODE);
- }
-
- return tmp;
-}
diff --git a/contrib/gcc/bi-defs.h b/contrib/gcc/bi-defs.h
deleted file mode 100644
index 868312a847db..000000000000
--- a/contrib/gcc/bi-defs.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/* Definitions for Bytecode Interpreter.
- Copyright (C) 1993 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-
-struct node
-{
- char *text;
- struct node *next;
-};
-
-struct variation
-{
- char *name;
- int code;
- struct node *inputs;
- struct node *outputs;
- struct node *literals;
- struct variation *next;
-};
-
-struct def
-{
- char *basename;
- char *template;
- struct variation *variations;
- struct def *next;
-};
-
-extern struct def *defs;
-extern int ndefs;
-extern void reverse();
diff --git a/contrib/gcc/bi-lexer.c b/contrib/gcc/bi-lexer.c
deleted file mode 100644
index 6601c52c05b6..000000000000
--- a/contrib/gcc/bi-lexer.c
+++ /dev/null
@@ -1,167 +0,0 @@
-/* Lexer for scanner of bytecode definition file.
- Copyright (C) 1993, 1995 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-#include <stdio.h>
-#include "hconfig.h"
-#include "bi-parser.h"
-
-
-/* Safely allocate NBYTES bytes of memory. Returns pointer to block of
- memory. */
-
-static char *
-xmalloc (nbytes)
- int nbytes;
-{
- char *tmp = (char *) malloc (nbytes);
-
- if (!tmp)
- {
- fprintf (stderr, "can't allocate %d bytes (out of virtual memory)\n", nbytes);
- exit (FATAL_EXIT_CODE);
- }
-
- return tmp;
-}
-
-
-/* Safely reallocate BLOCK so its size becomes NBYTES.
- The block returned may be different from the one supplied. */
-
-static char *
-xrealloc (block, nbytes)
- char *block;
- int nbytes;
-{
- char *tmp = (block
- ? (char *) realloc (block, nbytes)
- : (char *) malloc (nbytes));
-
- if (!tmp)
- {
- fprintf (stderr, "can't reallocate %d bytes (out of virtual memory)\n", nbytes);
- exit (FATAL_EXIT_CODE);
- }
-
- return tmp;
-}
-
-
-/* Scan for string token on standard input. A string is, for our
- purposes here, a sequence of characters that starts with the regexp
- ``[^ #\t\n(),]'' and is then followed by the regexp ``[^#(),]*''. Any
- character is accepted if preceded by a backslash, "\\". It is assumed
- that the first character has already been checked by the main loop. */
-
-static char *
-scan_string ()
-{
- char *buffer = NULL;
- char *point = NULL;
- int buffer_size = 0;
- int c;
-
- while ((c = getc (stdin)) != EOF
- && c != '#' && c != '(' && c != ')' && c != ',')
- {
- /* Extend buffer, if necessary (minus two so there's room for the NUL
- trailer as well as another character if this one is a backslash). */
- if (!buffer_size || (point - buffer >= buffer_size-2))
- {
- int previous_point_index = point - buffer;
-
- buffer_size = (!buffer_size ? 32 : buffer_size * 2);
- if (!buffer)
- buffer = xmalloc (buffer_size);
- else
- buffer = xrealloc (buffer, buffer_size);
-
- point = buffer + previous_point_index;
- }
- *point++ = c & 0xff;
-
- if (c == '\\')
- {
- c = getc (stdin);
-
- /* Catch special case: backslash at end of file */
- if (c == EOF)
- break;
-
- *point++ = c;
- }
- }
- *point = 0;
-
- if (c != EOF)
- ungetc (c, stdin);
-
- return buffer;
-}
-
-
-int
-yylex ()
-{
- int c;
- char *token;
-
-
- /* First char determines what token we're looking at */
- for (;;)
- {
- c = getc (stdin);
-
- switch (c)
- {
- case EOF:
- return 0;
-
- case ' ':
- case '\t':
- case '\n':
- /* Ignore whitespace */
- continue;
-
- case '#':
- /* Comments advance to next line */
- while ((c = getc (stdin)) != '\n' && c != EOF);
- continue;
-
- default:
- if (c != '(' && c != ')' && c != '\\' && c != ',')
- {
- ungetc (c, stdin);
- yylval.string = scan_string ();
-
- /* Check if string is "define_operator"; if so, return
- a DEFOP token instead. */
- if (!strcmp (yylval.string, "define_operator"))
- {
- free (yylval.string);
- yylval.string = 0;
- return DEFOP;
- }
- return STRING;
- }
- return c & 0xff;
- }
- }
-}
diff --git a/contrib/gcc/bi-opcode.c b/contrib/gcc/bi-opcode.c
deleted file mode 100644
index 6b1ebe4a69e7..000000000000
--- a/contrib/gcc/bi-opcode.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/* Utility to generate opcode list from bytecode definition.
- Copyright (C) 1993, 1994 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-#include <stdio.h>
-#include "hconfig.h"
-#include "bi-defs.h"
-
-int
-main(argc, argv)
- int argc;
- char **argv;
-{
- struct def *d;
- struct variation *v;
- int i;
-
- yyparse();
- reverse();
-
-
- printf ("/* This file is automatically generated from bytecode.def,\n");
- printf ("do not make any changes here. Instead edit bytecode.def. */\n\n");
- printf ("enum bytecode_opcode\n{");
-
- i = 0;
- for (d = defs; d; d = d->next)
- for (v = d->variations; v; v = v->next)
- {
- printf (" %s%s,\n", d->basename, v->name);
- ++i;
- }
-
- puts (" LAST_AND_UNUSED_OPCODE\n};");
-
- if (i > 256)
- fprintf (stderr, "%s: warning, number of opcodes is %d\n", *argv, i);
- else
- fprintf (stderr, "(Number of opcodes is %d)\n", i);
-
- fflush (stdout);
- exit (ferror (stdout) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE);
- /* NOTREACHED */
- return 0;
-}
-
-/* Safely allocate NBYTES bytes of memory. Returns pointer to block of
- memory. */
-char *
-xmalloc (nbytes)
- int nbytes;
-{
- char *tmp = (char *) malloc (nbytes);
-
- if (!tmp)
- {
- fprintf (stderr, "can't allocate %d bytes (out of virtual memory)\n", nbytes);
- exit (FATAL_EXIT_CODE);
- }
-
- return tmp;
-}
diff --git a/contrib/gcc/bi-opname.c b/contrib/gcc/bi-opname.c
deleted file mode 100644
index 1862e7120fb0..000000000000
--- a/contrib/gcc/bi-opname.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/* Utility to generate opcode name list from bytecode definition file.
- Copyright (C) 1993 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-#include <stdio.h>
-#include "hconfig.h"
-#include "bi-defs.h"
-
-int
-main()
-{
- struct def *d;
- struct variation *v;
-
- yyparse();
- reverse();
-
- for (d = defs; d; d = d->next)
- for (v = d->variations; v; v = v->next)
- printf("\"%s%s\",\n", d->basename, v->name);
-
- fflush (stdout);
- exit (ferror (stdout) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE);
- /* NOTREACHED */
- return 0;
-}
-
-/* Safely allocate NBYTES bytes of memory. Returns pointer to block of
- memory. */
-char *
-xmalloc (nbytes)
- int nbytes;
-{
- char *tmp = (char *) malloc (nbytes);
-
- if (!tmp)
- {
- fprintf (stderr, "can't allocate %d bytes (out of virtual memory)\n", nbytes);
- exit (FATAL_EXIT_CODE);
- }
-
- return tmp;
-}
diff --git a/contrib/gcc/bi-parser.y b/contrib/gcc/bi-parser.y
deleted file mode 100644
index 0a03d0f05ada..000000000000
--- a/contrib/gcc/bi-parser.y
+++ /dev/null
@@ -1,169 +0,0 @@
-/* Bytecode definition file parser.
- Copyright (C) 1993 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-
-%{
-
-#include <stdio.h>
-#include "hconfig.h"
-#include "bi-defs.h"
-
-extern char yytext[];
-extern int yyleng;
-
-
-/* Chain of all defs built by the parser. */
-struct def *defs;
-int ndefs;
-
-static struct node *makenode ();
-static struct variation *makevar ();
-static struct def *makedef ();
-
-void yyerror ();
-
-%}
-
-%union
-{
- char *string;
- struct def *def;
- struct variation *variation;
- struct node *node;
-}
-
-%token <string> DEFOP STRING
-%type <string> opt_string
-%type <def> defs def
-%type <variation> variations variation
-%type <node> list items item
-
-%%
-
-top:
- defs
- { defs = $1; }
- ;
-
-defs:
- def
- | defs def
- { $2->next = $1; $$ = $2; }
- ;
-
-def:
- DEFOP '(' STRING ',' opt_string ',' '(' variations ')' ')'
- { $$ = makedef ($3, $5, $8); }
- ;
-
-variations:
- variation
- | variations ',' variation
- { $3->next = $1; $$ = $3; }
- ;
-
-variation:
- '(' opt_string ')'
- { $$ = makevar ($2, (struct node *) NULL, (struct node *) NULL, (struct node *) NULL); }
- | '(' opt_string ',' list ')'
- { $$ = makevar ($2, $4, (struct node *) NULL, (struct node *) NULL); }
- | '(' opt_string ',' list ',' list ')'
- { $$ = makevar ($2, $4, $6, (struct node *) NULL); }
- | '(' opt_string ',' list ',' list ',' list ')'
- { $$ = makevar ($2, $4, $6, $8); }
- ;
-
-opt_string:
- /* empty */ { $$ = ""; }
- | STRING { $$ = $1; }
- ;
-
-list:
- '(' items ')'
- { $$ = $2; }
- | /* empty */
- { $$ = NULL; }
- ;
-
-items:
- item
- /* Note right recursion. */
- | item ',' items
- { $1->next = $3; $$ = $1; }
- ;
-
-item:
- STRING
- { $$ = makenode ($1); }
- ;
-
-%%
-
-static struct node *
-makenode (s)
- char *s;
-{
- struct node *n;
-
- n = (struct node *) malloc (sizeof (struct node));
- n->text = s;
- n->next = NULL;
- return n;
-}
-
-static struct variation *
-makevar (name, inputs, outputs, literals)
- char *name;
- struct node *inputs, *outputs, *literals;
-{
- struct variation *v;
-
- v = (struct variation *) malloc (sizeof (struct variation));
- v->name = name;
- v->code = ndefs++;
- v->inputs = inputs;
- v->outputs = outputs;
- v->literals = literals;
- v->next = NULL;
- return v;
-}
-
-static struct def *
-makedef (name, template, vars)
- char *name, *template;
- struct variation *vars;
-{
- struct def *d;
-
- d = (struct def *) malloc (sizeof (struct def));
- d->basename = name;
- d->template = template;
- d->variations = vars;
- d->next = NULL;
- return d;
-}
-
-void
-yyerror (s)
- char *s;
-{
- fprintf (stderr, "syntax error in input\n");
- exit (FATAL_EXIT_CODE);
-}
diff --git a/contrib/gcc/bi-reverse.c b/contrib/gcc/bi-reverse.c
deleted file mode 100644
index 6a84f827e73a..000000000000
--- a/contrib/gcc/bi-reverse.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/* Reverse order of definitions obtained from bytecode definition file.
- Copyright (C) 1993 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-
-#include "hconfig.h"
-#include "bi-defs.h"
-
-void
-reverse()
-{
- struct def *dp, *d, *dn;
- struct variation *vp, *v, *vn;
-
- dp = defs;
- if (dp)
- {
- vp = dp->variations;
- if (vp)
- {
- for (v = vp->next, vp->next = 0; v; vp = v, v = vn)
- {
- vn = v->next;
- v->next = vp;
- }
- dp->variations = vp;
- }
- for (d = dp->next, dp->next = 0; d; dp = d, d = dn)
- {
- vp = d->variations;
- if (vp)
- {
- for (v = vp->next, vp->next = 0; v; vp = v, v = vn)
- {
- vn = v->next;
- v->next = vp;
- }
- d->variations = vp;
- }
- dn = d->next;
- d->next = dp;
- }
- defs = dp;
- }
-}
diff --git a/contrib/gcc/bi-run.h b/contrib/gcc/bi-run.h
deleted file mode 100644
index dc9192f78b87..000000000000
--- a/contrib/gcc/bi-run.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/* Definitions for Bytecode Interpreter.
- Copyright (C) 1993, 1994 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-#define MAXLITERALS 5
-
-struct arityvec
-{
- char ninputs;
- char noutputs;
- char nliterals;
- char literals[MAXLITERALS];
-};
-
-struct argtype
-{
- int modealign; /* Argument mode:alignment */
- int size; /* Argument size, in bytes */
-};
-
-struct callinfo
-{
- int nargs; /* Number of arguments in call */
- struct argtype retvaltype; /* Type of return value */
- struct argtype argtypes[1]; /* Argument types */
-};
-
-/* Structure describing a bytecode function. If this changes, we also
- need to change expand_function_end () in bc-trans.c */
-struct bytecode
-{
- int stacksize; /* Depth required of evaluation stack. */
- int localsize; /* Size in bytes of local variables. */
- unsigned char *pc0; /* Initial program counter. */
- void **ptrlit; /* Vector of (relocatable) pointer literals. */
- struct callinfo *callinfo; /* Vector of procedure call type info. */
-};
-
-
-#define INTERP_BPC 8 /* Bits per char */
-#define INTERP_BPI \
- (sizeof (int) * INTERP_BPC) /* Bits per int */
-
-
-#ifndef min
-#define min(L, R) ((L) < (R) ? (L) : (R))
-#endif
-
-
-/* bit field operations. */
-
-/* Low (high) mask: int with low (high) N bits set */
-
-#define LM(N) ((1 << (N)) - 1)
-#define HM(N) ((~LM (INTERP_BPI - (N))))
-
-
-/* Sign-extend SIZE low bits of VALUE to integer (typeof VALUE)
- Signed bitfields are loaded from memory by the sxloadBI instruction,
- which first retrieves the bitfield with XFIELD and then sign extends
- it to an SItype. */
-
-#define EXTEND(SIZE, VALUE) \
- ({ SUtype value = (SUtype) (VALUE); \
- (value & (1 << ((SIZE) - 1)) ? value | ~LM (SIZE) : value); })
-
-
-/* Given OFFSET:SIZE for a bitfield, calculate:
-
- [1] BYTE_OFFSET = the byte offset of the bit field.
- [2] BIT_OFFSET = the bit offset of the bit field (less than INTERP_BPC).
- [3] NBYTES = the number of integral bytes in the bit field.
- [4] TRAILING_BITS= the number of trailing bits (less than INTERP_BPC).
-
-
- , , , , , (memory bytes)
- ---------------- (bitfield)
- | | || | | (divisions)
- ^ ^ ^ ^
- | | | |__ [4] (bits)
- | | |_________ [3] (bytes)
- | |_________________ [2] (bits)
- |___________________________ [1] (bytes)
-
-
- The above applies to BYTE_LOW_ENDIAN machines. In BYTE_BIG_ENDIAN machines, the
- bit numbering is reversed (i.e. bit 0 is the sign bit).
-
- (All right, so I drew this to keep my tongue in cheek while writing the code below,
- not because I'm into ASCII art.) */
-
-
-#define BI_PARAMS(OFFSET, SIZE, BYTE_OFFSET, BIT_OFFSET, NBYTES, TRAILING_BITS) \
- { BYTE_OFFSET = (OFFSET) / (INTERP_BPC); \
- BIT_OFFSET = (OFFSET) % (INTERP_BPC); \
- NBYTES = ((SIZE) - (INTERP_BPC - (BIT_OFFSET))) / INTERP_BPC; \
- if ((NBYTES) < 0 || ((NBYTES) > 64)) \
- NBYTES = 0; \
- if ((SIZE) + (BIT_OFFSET) <= INTERP_BPC) \
- TRAILING_BITS = 0; \
- else \
- TRAILING_BITS = ((SIZE) - (INTERP_BPC - (BIT_OFFSET))) % INTERP_BPC; }
-
-
-/* SHIFT_IN_BITS retrieves NBITS bits from SOURCE and shifts into
- DEST. The bit field starts OFFSET bits into SOURCE.
-
- OR_IN_BITS copies the NBITS low bits from VALUE into a the bitfield in
- DEST offset by OFFSET bits. */
-
-
-#define SHIFT_IN_BITS(DEST, SOURCE, OFFSET, NBITS) \
- (DEST = ((DEST) << (NBITS)) \
- | (LM ((NBITS)) \
- & ((SOURCE) \
- >> (BYTES_BIG_ENDIAN \
- ? (INTERP_BPC - (OFFSET) - (NBITS)) \
- : (OFFSET)))))
-
-#define OR_IN_BITS(DEST, VALUE, OFFSET, NBITS) \
- (DEST = ((DEST) & ~(LM ((NBITS)) \
- << (BIG_ENDIAN \
- ? (INTERP_BPC - (OFFSET) - (NBITS)) \
- : (OFFSET))) \
- | (((VALUE) & LM ((NBITS))) \
- << (BIG_ENDIAN \
- ? (INTERP_BPC - (OFFSET) - (NBITS)) \
- : (OFFSET)))))
-
-/* Procedure call; arguments are a pointer to the function to be called,
- a pointer to a place to store the return value, a pointer to a vector
- describing the type of procedure call, and the interpreter's stack pointer,
- which will point to the first of the arguments at this point. */
-
-#define CALL(FUNC, CALLDESC, RETVAL, SP) __call(FUNC, CALLDESC, RETVAL, SP)
-
-
-/* Procedure return; arguments are a pointer to the calldesc for this
- function, and a pointer to the place where the value to be returned
- may be found. Generally the MACHARGS above contain a machine dependent
- cookie that is used to determine where to jump to. */
-
-#define PROCRET(CALLDESC, RETVAL) return
diff --git a/contrib/gcc/bytecode.def b/contrib/gcc/bytecode.def
deleted file mode 100644
index 5b24df70ed67..000000000000
--- a/contrib/gcc/bytecode.def
+++ /dev/null
@@ -1,322 +0,0 @@
-# -*- C -*-
-# bytecode.def - definitions of bytecodes for the stack machine.
-
-# The production of the bytecode interpreter and compiler is
-# heavily automated by using this file creatively.
-
-# Various elementary data types are understood by the bytecode interpreter.
-# Q[IU] - quarter word (byte) signed and unsigned integers (char).
-# H[IU] - half word signed and unsigned integers (short int, maybe int).
-# S[IU] - single word signed and unsigned integers (maybe int, long int).
-# D[IU] - double word signed and unsigned integers (long long int).
-# SF - single precision floating point (float).
-# DF - double precision floating point (double).
-# XF - extended precision floating point (long double).
-# P - pointer type for address arithmetic and other purposes.
-
-# The bytecode specification consists of a series of define_operator
-# forms, that are parsed by preprocessors to automatically build
-# various switch statements.
-# define_operator(name,
-# <C prototype code for implementing the operator>,
-# <list of variations>)
-# The <C prototype> is self explanatory.
-# The <list of variations> consists of a (parenthesized list) of
-# variation items, each of which is in itself a list. A variation
-# item consists of a name suffix, the types of the input arguments
-# expected on the stack (shallowest item first) and (optionally) the
-# types of the output arguments (similarly ordered). Finally, the
-# types of the literal arguments (if any) may appear.
-
-# Substitution in the C prototype code is as follows:
-# Substitution happens only after a dollar sign. To get a literal
-# dollar sign (why would you ever want one anyway?) use $$.
-# $R1 means "result 1" $TR1 means "type name of result one"
-# $S1 means "source 1" and similarly with $TS1.
-# $L1 means "literal (inline) argument 1" and $TL1 means type thereof.
-#
-
-# Notice that the number following $R doesn't affect the push order;
-# it's used only for clarity and orthogonality, although it's checked
-# to make sure it doesn't exceed the number of outputs. A $R reference
-# results in a push, and represents the result lvalue. E.g.
-
-# $R1 = 2\, $R2 = 17
-# will expand to:
-# INTERP_PUSH($TR1) = 2, INTERP_PUSH($TR2) = 17
-#
-
-# Opcode 0 should never happen.
-define_operator(neverneverland, abort\(\), (()))
-
-# Stack manipulations.
-define_operator(drop, 0, ((, (SI))))
-define_operator(duplicate, 0, ((, (SI), (SI, SI))))
-define_operator(over, 0, ((, (SI), (SI, SI))))
-
-# Adjust stack pointer
-
-define_operator(setstack, 0, ((SI,,,(SI))))
-define_operator(adjstack, 0, ((SI,,,(SI))))
-
-# Constants, loads, and stores.
-define_operator(const,
- $R1 = $L1,
- ((QI,, (QI), (QI)), (HI,, (HI), (HI)),
- (SI,, (SI), (SI)), (DI,, (DI), (DI)),
- (SF,, (SF), (SF)), (DF,, (DF), (DF)),
- (XF,, (XF), (XF)), (P,, (P), (P))))
-define_operator(load,
- $R1 = *\($TR1 *\) $S1,
- ((QI, (P), (QI)), (HI, (P), (HI)),
- (SI, (P), (SI)), (DI, (P), (DI)),
- (SF, (P), (SF)), (DF, (P), (DF)),
- (XF, (P), (XF)), (P, (P), (P))))
-define_operator(store,
- *\($TS2 *\) $S1 = $S2,
- ((QI, (P, QI)), (HI, (P, HI)),
- (SI, (P, SI)), (DI, (P, DI)),
- (SF, (P, SF)), (DF, (P, DF)),
- (XF, (P, XF)), (P, (P, P)),
- (BLK, (SI, BLK, BLK))))
-
-# Clear memory block
-
-define_operator(clear, $S1 + $S2, ((BLK, (SI, BLK))))
-
-
-# Advance pointer by SI constant
-
-define_operator(addconst, $R1 = $S1, ((PSI, (P), (P), (SI))))
-
-
-# newlocalSI is used for creating variable-sized storage during function
-# initialization.
-
-# Create local space, return pointer to block
-
-define_operator(newlocal, $R1 = $S1, ((SI, (SI), (P))))
-
-
-# Push the address of a local variable.
-define_operator(local, $R1 = locals + $L1, ((P,, (P), (SI))))
-
-# Push the address of an argument variable.
-define_operator(arg, $R1 = args + $L1, ((P,, (P), (SI))))
-
-# Arithmetic conversions.
-define_operator(convert,
- $R1 = \($TR1\) $S1,
- (# Signed integral promotions (sign extensions).
- (QIHI, (QI), (HI)), (HISI, (HI), (SI)), (SIDI, (SI), (DI)),
- (QISI, (QI), (SI)),
- # Unsigned integral promotions (zero extensions).
- (QUHU, (QU), (HU)), (HUSU, (HU), (SU)), (SUDU, (SU), (DU)),
- (QUSU, (QU), (SU)),
- # Floating promotions.
- (SFDF, (SF), (DF)), (DFXF, (DF), (XF)),
- # Integral truncation.
- (HIQI, (HI), (QI)), (SIHI, (SI), (HI)), (DISI, (DI), (SI)),
- (SIQI, (SI), (QI)),
- # Unsigned truncation.
- (SUQU, (SU), (QU)),
- # Floating truncation.
- (DFSF, (DF), (SF)), (XFDF, (XF), (DF)),
- # Integral conversions to floating types.
- (SISF, (SI), (SF)), (SIDF, (SI), (DF)), (SIXF, (SI), (XF)),
- (SUSF, (SU), (SF)), (SUDF, (SU), (DF)), (SUXF, (SU), (XF)),
- (DISF, (DI), (SF)), (DIDF, (DI), (DF)), (DIXF, (DI), (XF)),
- (DUSF, (DU), (SF)), (DUDF, (DU), (DF)), (DUXF, (DU), (XF)),
- # Floating conversions to integral types.
- (SFSI, (SF), (SI)), (DFSI, (DF), (SI)), (XFSI, (XF), (SI)),
- (SFSU, (SF), (SU)), (DFSU, (DF), (SU)), (XFSU, (XF), (SU)),
- (SFDI, (SF), (DI)), (DFDI, (DF), (DI)), (XFDI, (XF), (DI)),
- (SFDU, (SF), (DU)), (DFDU, (DF), (DU)), (XFDU, (XF), (DU)),
- # Pointer/integer conversions.
- (PSI, (P), (SI)), (SIP, (SI), (P))))
-
-# Truth value conversion. These are necessary because conversions of, e.g.,
-# floating types to integers may not function correctly for large values.
-define_operator(convert,
- $R1 = !!$S1,
- ((SIT, (SI), (T)), (DIT, (DI), (T)),
- (SFT, (SF), (T)), (DFT, (DF), (T)),
- (XFT, (XF), (T)), (PT, (P), (T))))
-
-# Bit field load/store.
-
-# Load and zero-extend bitfield
-
-define_operator(zxload, $R1 = $S1, ((BI, (SU, SU, P), (SU))))
-
-# Load and sign-extend bitfield
-
-define_operator(sxload, $R1 = $S1, ((BI, (SU, SU, P), (SI))))
-
-# Store integer in bitfield
-
-define_operator(sstore, $R1 = $S1, ((BI, (SU, SU, P, SI))))
-
-
-# Binary operations.
-define_operator(add,
- $R1 = $S1 + $S2,
- ((SI, (SI, SI), (SI)), (DI, (DI, DI), (DI)),
- (SF, (SF, SF), (SF)), (DF, (DF, DF), (DF)),
- (XF, (XF, XF), (XF)),
- (PSI, (P, SI), (P))))
-define_operator(sub,
- $R1 = $S1 - $S2,
- ((SI, (SI, SI), (SI)), (DI, (DI, DI), (DI)),
- (SF, (SF, SF), (SF)), (DF, (DF, DF), (DF)),
- (XF, (XF, XF), (XF)),
- (PP, (P, P), (SI))))
-define_operator(mul,
- $R1 = $S1 * $S2,
- ((SI, (SI, SI), (SI)), (DI, (DI, DI), (DI)),
- (SU, (SU, SU), (SU)), (DU, (DU, DU), (DU)),
- (SF, (SF, SF), (SF)), (DF, (DF, DF), (DF)),
- (XF, (XF, XF), (XF))))
-define_operator(div,
- $R1 = $S1 / $S2,
- ((SI, (SI, SI), (SI)), (DI, (DI, DI), (DI)),
- (SU, (SU, SU), (SU)), (DU, (DU, DU), (DU)),
- (SF, (SF, SF), (SF)), (DF, (DF, DF), (DF)),
- (XF, (XF, XF), (XF))))
-define_operator(mod,
- $R1 = $S1 % $S2,
- ((SI, (SI, SI), (SI)), (DI, (DI, DI), (DI)),
- (SU, (SU, SU), (SU)), (DU, (DU, DU), (DU))))
-define_operator(and,
- $R1 = $S1 & $S2,
- ((SI, (SI, SI), (SI)), (DI, (DI, DI), (DI))))
-define_operator(ior,
- $R1 = $S1 | $S2,
- ((SI, (SI, SI), (SI)), (DI, (DI, DI), (DI))))
-define_operator(xor,
- $R1 = $S1 ^ $S2,
- ((SI, (SI, SI), (SI)), (DI, (DI, DI), (DI))))
-define_operator(lshift,
- $R1 = $S1 << $S2,
- ((SI, (SI, SI), (SI)), (SU, (SU, SI), (SU)),
- (DI, (DI, SI), (DI)), (DU, (DU, SI), (DU))))
-define_operator(rshift,
- $R1 = $S1 >> $S2,
- ((SI, (SI, SI), (SI)), (SU, (SU, SI), (SU)),
- (DI, (DI, SI), (DI)), (DU, (DU, SI), (DU))))
-define_operator(lt,
- $R1 = $S1 < $S2,
- ((SI, (SI, SI), (T)), (SU, (SU, SU), (T)),
- (DI, (DI, DI), (T)), (DU, (DU, DU), (T)),
- (SF, (SF, SF), (T)), (DF, (DF, DF), (T)),
- (XF, (XF, XF), (T)), (P, (P, P), (T))))
-define_operator(le,
- $R1 = $S1 <= $S2,
- ((SI, (SI, SI), (T)), (SU, (SU, SU), (T)),
- (DI, (DI, DI), (T)), (DU, (DU, DU), (T)),
- (SF, (SF, SF), (T)), (DF, (DF, DF), (T)),
- (XF, (XF, XF), (T)), (P, (P, P), (T))))
-define_operator(ge,
- $R1 = $S1 >= $S2,
- ((SI, (SI, SI), (T)), (SU, (SU, SU), (T)),
- (DI, (DI, DI), (T)), (DU, (DU, DU), (T)),
- (SF, (SF, SF), (T)), (DF, (DF, DF), (T)),
- (XF, (XF, XF), (T)), (P, (P, P), (T))))
-define_operator(gt,
- $R1 = $S1 > $S2,
- ((SI, (SI, SI), (T)), (SU, (SU, SU), (T)),
- (DI, (DI, DI), (T)), (DU, (DU, DU), (T)),
- (SF, (SF, SF), (T)), (DF, (DF, DF), (T)),
- (XF, (XF, XF), (T)), (P, (P, P), (T))))
-define_operator(eq,
- $R1 = $S1 == $S2,
- ((SI, (SI, SI), (T)), (DI, (DI, DI), (T)),
- (SF, (SF, SF), (T)), (DF, (DF, DF), (T)),
- (XF, (XF, XF), (T)), (P, (P, P), (T))))
-define_operator(ne,
- $R1 = $S1 != $S2,
- ((SI, (SI, SI), (T)), (DI, (DI, DI), (T)),
- (SF, (SF, SF), (T)), (DF, (DF, DF), (T)),
- (XF, (XF, XF), (T)), (P, (P, P), (T))))
-
-# Unary operations.
-define_operator(neg,
- $R1 = -$S1,
- ((SI, (SI), (SI)), (DI, (DI), (DI)),
- (SF, (SF), (SF)), (DF, (DF), (DF)),
- (XF, (XF), (XF))))
-define_operator(not,
- $R1 = ~$S1,
- ((SI, (SI), (SI)), (DI, (DI), (DI))))
-define_operator(not,
- $R1 = !$S1,
- ((T, (SI), (SI))))
-
-# Increment operations.
-define_operator(predec,
- $R1 = *\($TR1 *\) $S1 -= $S2,
- ((QI, (P, QI), (QI)), (HI, (P, HI), (HI)),
- (SI, (P, SI), (SI)), (DI, (P, DI), (DI)),
- (P, (P, SI), (P)), (SF, (P, SF), (SF)),
- (DF, (P, DF), (DF)), (XF, (P, XF), (XF)),
- (BI, (SU, SU, P, SI), (SI))))
-
-define_operator(preinc,
- $R1 = *\($TR1 *\) $S1 += $S2,
- ((QI, (P, QI), (QI)), (HI, (P, HI), (HI)),
- (SI, (P, SI), (SI)), (DI, (P, DI), (DI)),
- (P, (P, SI), (P)), (SF, (P, SF), (SF)),
- (DF, (P, DF), (DF)), (XF, (P, XF), (XF)),
- (BI, (SU, SU, P, SI), (SI))))
-
-define_operator(postdec,
- $R1 = *\($TR1 *\) $S1\, *\($TR1 *\) $S1 -= $S2,
- ((QI, (P, QI), (QI)), (HI, (P, HI), (HI)),
- (SI, (P, SI), (SI)), (DI, (P, DI), (DI)),
- (P, (P, SI), (P)), (SF, (P, SF), (SF)),
- (DF, (P, DF), (DF)), (XF, (P, XF), (XF)),
- (BI, (SU, SU, P, SI), (SI))))
-
-define_operator(postinc,
- $R1 = *\($TR1 *\) $S1\, *\($TR1 *\) $S1 += $S2,
- ((QI, (P, QI), (QI)), (HI, (P, HI), (HI)),
- (SI, (P, SI), (SI)), (DI, (P, DI), (DI)),
- (P, (P, SI), (P)), (SF, (P, SF), (SF)),
- (DF, (P, DF), (DF)), (XF, (P, XF), (XF)),
- (BI, (SU, SU, P, SI), (SI))))
-
-# Jumps.
-define_operator(xjumpif, if \($S1\) pc = code->pc0 + $L1, ((, (T),, (SI))))
-define_operator(xjumpifnot, if \(! $S1\) pc = code->pc0 + $L1, ((, (T),, (SI))))
-define_operator(jump, pc = code->pc0 + $L1, ((,,,(SI))))
-
-# This is for GCC2. It jumps to the address on the stack.
-define_operator(jump, pc = \(void *\) $S1, ((P,,)))
-
-# Switches. In order to (eventually) support ranges we provide four different
-# varieties of switches. Arguments are the switch index from the stack, the
-# bytecode offset of the switch table, the size of the switch table, and
-# the default label.
-define_operator(caseSI, CASESI\($S1\, $L1\, $L2\, $L3\), ((, (SI),, (SI, SI, SI))))
-define_operator(caseSU, CASESU\($S1\, $L1\, $L2\, $L3\), ((, (SU),, (SI, SI, SI))))
-define_operator(caseDI, CASEDI\($S1\, $L1\, $L2\, $L3\), ((, (DI),, (SI, SI, SI))))
-define_operator(caseDU, CASEDU\($S1\, $L1\, $L2\, $L3\), ((, (DU),, (SI, SI, SI))))
-
-# Procedure call.
-# Stack arguments are (deepest first):
-# procedure arguments in reverse order.
-# pointer to the place to hold the return value.
-# address of the call description vector.
-# pointer to the procedure to be called.
-define_operator(call, CALL\($S1\, $S2\, $S3\, sp\), ((, (P, P, P))))
-
-# Procedure return.
-# Pushes on interpreter stack:
-# value of retptr (pointer to return value storage slot)
-define_operator(return, $R1 = retptr, ((P,,(P))))
-
-# Really return.
-define_operator(ret, return, (()))
-
-# Print an obnoxious line number.
-define_operator(linenote, fprintf\(stderr\, "%d\\n"\, $L1\), ((,,,(SI))))
diff --git a/contrib/gcc/bytecode.h b/contrib/gcc/bytecode.h
deleted file mode 100644
index f2233aa880d3..000000000000
--- a/contrib/gcc/bytecode.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/* Bytecode definitions for GNU C-compiler.
- Copyright (C) 1993, 1994 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-
-extern int output_bytecode;
-extern int stack_depth;
-extern int max_stack_depth;
-
-/* Emit DI constant according to target machine word ordering */
-
-#define bc_emit_bytecode_DI_const(CST) \
-{ int opcode; \
- opcode = (WORDS_BIG_ENDIAN \
- ? TREE_INT_CST_HIGH (CST) \
- : TREE_INT_CST_LOW (CST)); \
- bc_emit_bytecode_const ((char *) &opcode, sizeof opcode); \
- opcode = (WORDS_BIG_ENDIAN \
- ? TREE_INT_CST_LOW (CST) \
- : TREE_INT_CST_HIGH (CST)); \
- bc_emit_bytecode_const ((char *) &opcode, sizeof opcode); \
-}
-
-extern void bc_expand_expr ();
-extern void bc_output_data_constructor ();
-extern void bc_store_field ();
-extern void bc_load_bit_field ();
-extern void bc_store_bit_field ();
-extern void bc_push_offset_and_size ();
-extern void bc_init_mode_to_code_map ();
-
-/* These are just stubs, so the compiler will compile for targets
- that aren't yet supported by the bytecode generator. */
-
-#ifndef TARGET_SUPPORTS_BYTECODE
-
-#define MACHINE_SEG_ALIGN 1
-#define INT_ALIGN 1
-#define PTR_ALIGN 1
-#define NAMES_HAVE_UNDERSCORES
-#define BC_NOP (0)
-#define BC_GLOBALIZE_LABEL(FP, NAME) BC_NOP
-#define BC_OUTPUT_COMMON(FP, NAME, SIZE, ROUNDED) BC_NOP
-#define BC_OUTPUT_LOCAL(FP, NAME, SIZE, ROUNDED) BC_NOP
-#define BC_OUTPUT_ALIGN(FP, ALIGN) BC_NOP
-#define BC_OUTPUT_LABEL(FP, NAME) BC_NOP
-#define BC_OUTPUT_SKIP(FP, SIZE) BC_NOP
-#define BC_OUTPUT_LABELREF(FP, NAME) BC_NOP
-#define BC_OUTPUT_FLOAT(FP, VAL) BC_NOP
-#define BC_OUTPUT_DOUBLE(FP, VAL) BC_NOP
-#define BC_OUTPUT_BYTE(FP, VAL) BC_NOP
-#define BC_OUTPUT_FILE ASM_OUTPUT_FILE
-#define BC_OUTPUT_ASCII ASM_OUTPUT_ASCII
-#define BC_OUTPUT_IDENT ASM_OUTPUT_IDENT
-#define BCXSTR(RTX) ((RTX)->bc_label)
-#define BC_WRITE_FILE(FP) BC_NOP
-#define BC_WRITE_SEGSYM(SEGSYM, FP) BC_NOP
-#define BC_WRITE_RELOC_ENTRY(SEGRELOC, FP, OFFSET) BC_NOP
-#define BC_START_BYTECODE_LINE(FP) BC_NOP
-#define BC_WRITE_BYTECODE(SEP, VAL, FP) BC_NOP
-#define BC_WRITE_RTL(R, FP) BC_NOP
-#define BC_EMIT_TRAMPOLINE(TRAMPSEG, CALLINFO) BC_NOP
-#define VALIDATE_STACK BC_NOP
-
-#endif /* !TARGET_SUPPORTS_BYTECODE */
diff --git a/contrib/gcc/bytetypes.h b/contrib/gcc/bytetypes.h
deleted file mode 100644
index f91566900c66..000000000000
--- a/contrib/gcc/bytetypes.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* These should come from genemit */
-
-/* Use __signed__ in case compiling with -traditional. */
-
-typedef __signed__ char QItype;
-typedef unsigned char QUtype;
-typedef __signed__ short int HItype;
-typedef unsigned short int HUtype;
-typedef __signed__ long int SItype;
-typedef unsigned long int SUtype;
-typedef __signed__ long long int DItype;
-typedef unsigned long long int DUtype;
-typedef float SFtype;
-typedef double DFtype;
-typedef long double XFtype;
-typedef char *Ptype;
-typedef int Ttype;
-
-
-typedef union stacktype
-{
- QItype QIval;
- QUtype QUval;
- HItype HIval;
- HUtype HUval;
- SItype SIval;
- SUtype SUval;
- DItype DIval;
- DUtype DUval;
- SFtype SFval;
- DFtype DFval;
- XFtype XFval;
- Ptype Pval;
- Ttype Tval;
-} stacktype;
diff --git a/contrib/gcc/config.sub b/contrib/gcc/config.sub
deleted file mode 100755
index b491c9f5ce05..000000000000
--- a/contrib/gcc/config.sub
+++ /dev/null
@@ -1,976 +0,0 @@
-#! /bin/sh
-# Configuration validation subroutine script, version 1.1.
-# Copyright (C) 1991, 92-97, 1998 Free Software Foundation, Inc.
-# This file is (in principle) common to ALL GNU software.
-# The presence of a machine in this file suggests that SOME GNU software
-# can handle that machine. It does not imply ALL GNU software can.
-#
-# This file is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-# Configuration subroutine to validate and canonicalize a configuration type.
-# Supply the specified configuration type as an argument.
-# If it is invalid, we print an error message on stderr and exit with code 1.
-# Otherwise, we print the canonical config type on stdout and succeed.
-
-# This file is supposed to be the same for all GNU packages
-# and recognize all the CPU types, system types and aliases
-# that are meaningful with *any* GNU software.
-# Each package is responsible for reporting which valid configurations
-# it does not support. The user should be able to distinguish
-# a failure to support a valid configuration from a meaningless
-# configuration.
-
-# The goal of this file is to map all the various variations of a given
-# machine specification into a single specification in the form:
-# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
-# or in some cases, the newer four-part form:
-# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
-# It is wrong to echo any other type of specification.
-
-if [ x$1 = x ]
-then
- echo Configuration name missing. 1>&2
- echo "Usage: $0 CPU-MFR-OPSYS" 1>&2
- echo "or $0 ALIAS" 1>&2
- echo where ALIAS is a recognized configuration type. 1>&2
- exit 1
-fi
-
-# First pass through any local machine types.
-case $1 in
- *local*)
- echo $1
- exit 0
- ;;
- *)
- ;;
-esac
-
-# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
-# Here we must recognize all the valid KERNEL-OS combinations.
-maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
-case $maybe_os in
- linux-gnu*)
- os=-$maybe_os
- basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
- ;;
- *)
- basic_machine=`echo $1 | sed 's/-[^-]*$//'`
- if [ $basic_machine != $1 ]
- then os=`echo $1 | sed 's/.*-/-/'`
- else os=; fi
- ;;
-esac
-
-### Let's recognize common machines as not being operating systems so
-### that things like config.sub decstation-3100 work. We also
-### recognize some manufacturers as not being operating systems, so we
-### can provide default operating systems below.
-case $os in
- -sun*os*)
- # Prevent following clause from handling this invalid input.
- ;;
- -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
- -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
- -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
- -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
- -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
- -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
- -apple)
- os=
- basic_machine=$1
- ;;
- -hiux*)
- os=-hiuxwe2
- ;;
- -sco5)
- os=-sco3.2v5
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -sco4)
- os=-sco3.2v4
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -sco3.2.[4-9]*)
- os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -sco3.2v[4-9]*)
- # Don't forget version if it is 3.2v4 or newer.
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -sco*)
- os=-sco3.2v2
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -isc)
- os=-isc2.2
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -clix*)
- basic_machine=clipper-intergraph
- ;;
- -isc*)
- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
- ;;
- -lynx*)
- os=-lynxos
- ;;
- -ptx*)
- basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
- ;;
- -windowsnt*)
- os=`echo $os | sed -e 's/windowsnt/winnt/'`
- ;;
- -psos*)
- os=-psos
- ;;
-esac
-
-# Decode aliases for certain CPU-COMPANY combinations.
-case $basic_machine in
- # Recognize the basic CPU types without company name.
- # Some are omitted here because they have special meanings below.
- tahoe | i860 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \
- | arme[lb] | pyramid | mn10200 | mn10300 \
- | tron | a29k | 580 | i960 | h8300 | hppa | hppa1.0 | hppa1.1 \
- | alpha | alphaev5 | alphaev56 | we32k | ns16k | clipper \
- | i370 | sh | powerpc | powerpcle | 1750a | dsp16xx | pdp11 \
- | mips64 | mipsel | mips64el | mips64orion | mips64orionel \
- | mipstx39 | mipstx39el \
- | sparc | sparclet | sparclite | sparc64 | v850)
- basic_machine=$basic_machine-unknown
- ;;
- thumb | thumbel)
- basic_machine=$basic_machine-unknown
- ;;
- # We use `pc' rather than `unknown'
- # because (1) that's what they normally are, and
- # (2) the word "unknown" tends to confuse beginning users.
- i[34567]86)
- basic_machine=$basic_machine-pc
- ;;
- # Object if more than one company name word.
- *-*-*)
- echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
- exit 1
- ;;
- # Recognize the basic CPU types with company name.
- vax-* | tahoe-* | i[34567]86-* | i860-* | m32r-* | m68k-* | m68000-* \
- | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | arm-* | c[123]* \
- | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \
- | power-* | none-* | 580-* | cray2-* | h8300-* | i960-* \
- | xmp-* | ymp-* | hppa-* | hppa1.0-* | hppa1.1-* \
- | alpha-* | alphaev5-* | alphaev56-* | we32k-* | cydra-* \
- | ns16k-* | pn-* | np1-* | xps100-* | clipper-* | orion-* \
- | sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \
- | sparc64-* | mips64-* | mipsel-* \
- | mips64el-* | mips64orion-* | mips64orionel-* \
- | mipstx39-* | mipstx39el-* \
- | f301-*)
- ;;
- # Recognize the various machine names and aliases which stand
- # for a CPU type and a company and sometimes even an OS.
- 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
- basic_machine=m68000-att
- ;;
- 3b*)
- basic_machine=we32k-att
- ;;
- alliant | fx80)
- basic_machine=fx80-alliant
- ;;
- altos | altos3068)
- basic_machine=m68k-altos
- ;;
- am29k)
- basic_machine=a29k-none
- os=-bsd
- ;;
- amdahl)
- basic_machine=580-amdahl
- os=-sysv
- ;;
- amiga | amiga-*)
- basic_machine=m68k-cbm
- ;;
- amigaos | amigados)
- basic_machine=m68k-cbm
- os=-amigaos
- ;;
- amigaunix | amix)
- basic_machine=m68k-cbm
- os=-sysv4
- ;;
- apollo68)
- basic_machine=m68k-apollo
- os=-sysv
- ;;
- aux)
- basic_machine=m68k-apple
- os=-aux
- ;;
- balance)
- basic_machine=ns32k-sequent
- os=-dynix
- ;;
- convex-c1)
- basic_machine=c1-convex
- os=-bsd
- ;;
- convex-c2)
- basic_machine=c2-convex
- os=-bsd
- ;;
- convex-c32)
- basic_machine=c32-convex
- os=-bsd
- ;;
- convex-c34)
- basic_machine=c34-convex
- os=-bsd
- ;;
- convex-c38)
- basic_machine=c38-convex
- os=-bsd
- ;;
- cray | ymp)
- basic_machine=ymp-cray
- os=-unicos
- ;;
- cray2)
- basic_machine=cray2-cray
- os=-unicos
- ;;
- [ctj]90-cray)
- basic_machine=c90-cray
- os=-unicos
- ;;
- crds | unos)
- basic_machine=m68k-crds
- ;;
- da30 | da30-*)
- basic_machine=m68k-da30
- ;;
- decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
- basic_machine=mips-dec
- ;;
- delta | 3300 | motorola-3300 | motorola-delta \
- | 3300-motorola | delta-motorola)
- basic_machine=m68k-motorola
- ;;
- delta88)
- basic_machine=m88k-motorola
- os=-sysv3
- ;;
- dpx20 | dpx20-*)
- basic_machine=rs6000-bull
- os=-bosx
- ;;
- dpx2* | dpx2*-bull)
- basic_machine=m68k-bull
- os=-sysv3
- ;;
- ebmon29k)
- basic_machine=a29k-amd
- os=-ebmon
- ;;
- elxsi)
- basic_machine=elxsi-elxsi
- os=-bsd
- ;;
- encore | umax | mmax)
- basic_machine=ns32k-encore
- ;;
- fx2800)
- basic_machine=i860-alliant
- ;;
- genix)
- basic_machine=ns32k-ns
- ;;
- gmicro)
- basic_machine=tron-gmicro
- os=-sysv
- ;;
- h3050r* | hiux*)
- basic_machine=hppa1.1-hitachi
- os=-hiuxwe2
- ;;
- h8300hms)
- basic_machine=h8300-hitachi
- os=-hms
- ;;
- harris)
- basic_machine=m88k-harris
- os=-sysv3
- ;;
- hp300-*)
- basic_machine=m68k-hp
- ;;
- hp300bsd)
- basic_machine=m68k-hp
- os=-bsd
- ;;
- hp300hpux)
- basic_machine=m68k-hp
- os=-hpux
- ;;
- hp9k2[0-9][0-9] | hp9k31[0-9])
- basic_machine=m68000-hp
- ;;
- hp9k3[2-9][0-9])
- basic_machine=m68k-hp
- ;;
- hp9k6[0-9][0-9] | hp6[0-9][0-9] )
- basic_machine=hppa1.0-hp
- ;;
- hp9k7[0-79][0-9] | hp7[0-79][0-9] )
- basic_machine=hppa1.1-hp
- ;;
- hp9k78[0-9] | hp78[0-9] )
- # FIXME: really hppa2.0-hp
- basic_machine=hppa1.1-hp
- ;;
- hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | \
- hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893 )
- # FIXME: really hppa2.0-hp
- basic_machine=hppa1.1-hp
- ;;
- hp9k8[0-9][13679] | hp8[0-9][13679] )
- basic_machine=hppa1.1-hp
- ;;
- hp9k8[0-9][0-9] | hp8[0-9][0-9])
- basic_machine=hppa1.0-hp
- ;;
- hppa-next)
- os=-nextstep3
- ;;
- i370-ibm* | ibm*)
- basic_machine=i370-ibm
- os=-mvs
- ;;
-# I'm not sure what "Sysv32" means. Should this be sysv3.2?
- i[34567]86v32)
- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
- os=-sysv32
- ;;
- i[34567]86v4*)
- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
- os=-sysv4
- ;;
- i[34567]86v)
- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
- os=-sysv
- ;;
- i[34567]86sol2)
- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
- os=-solaris2
- ;;
- iris | iris4d)
- basic_machine=mips-sgi
- case $os in
- -irix*)
- ;;
- *)
- os=-irix4
- ;;
- esac
- ;;
- isi68 | isi)
- basic_machine=m68k-isi
- os=-sysv
- ;;
- m88k-omron*)
- basic_machine=m88k-omron
- ;;
- magnum | m3230)
- basic_machine=mips-mips
- os=-sysv
- ;;
- merlin)
- basic_machine=ns32k-utek
- os=-sysv
- ;;
- miniframe)
- basic_machine=m68000-convergent
- ;;
- mipsel*-linux*)
- basic_machine=mipsel-unknown
- os=-linux-gnu
- ;;
- mips*-linux*)
- basic_machine=mips-unknown
- os=-linux-gnu
- ;;
- mips3*-*)
- basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
- ;;
- mips3*)
- basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
- ;;
- ncr3000)
- basic_machine=i486-ncr
- os=-sysv4
- ;;
- news | news700 | news800 | news900)
- basic_machine=m68k-sony
- os=-newsos
- ;;
- news1000)
- basic_machine=m68030-sony
- os=-newsos
- ;;
- news-3600 | risc-news)
- basic_machine=mips-sony
- os=-newsos
- ;;
- next | m*-next )
- basic_machine=m68k-next
- case $os in
- -nextstep* )
- ;;
- -ns2*)
- os=-nextstep2
- ;;
- *)
- os=-nextstep3
- ;;
- esac
- ;;
- nh3000)
- basic_machine=m68k-harris
- os=-cxux
- ;;
- nh[45]000)
- basic_machine=m88k-harris
- os=-cxux
- ;;
- nindy960)
- basic_machine=i960-intel
- os=-nindy
- ;;
- np1)
- basic_machine=np1-gould
- ;;
- pa-hitachi)
- basic_machine=hppa1.1-hitachi
- os=-hiuxwe2
- ;;
- paragon)
- basic_machine=i860-intel
- os=-osf
- ;;
- pbd)
- basic_machine=sparc-tti
- ;;
- pbb)
- basic_machine=m68k-tti
- ;;
- pc532 | pc532-*)
- basic_machine=ns32k-pc532
- ;;
- pentium | p5 | k5 | nexen)
- basic_machine=i586-pc
- ;;
- pentiumpro | p6 | k6 | 6x86)
- basic_machine=i686-pc
- ;;
- pentiumii | pentium2)
- basic_machine=i786-pc
- ;;
- pentium-* | p5-* | k5-* | nexen-*)
- basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- pentiumpro-* | p6-* | k6-* | 6x86-*)
- basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- pentiumii-* | pentium2-*)
- basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- pn)
- basic_machine=pn-gould
- ;;
- power) basic_machine=rs6000-ibm
- ;;
- ppc) basic_machine=powerpc-unknown
- ;;
- ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- ppcle | powerpclittle | ppc-le | powerpc-little)
- basic_machine=powerpcle-unknown
- ;;
- ppcle-* | powerpclittle-*)
- basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
- ;;
- ps2)
- basic_machine=i386-ibm
- ;;
- rm[46]00)
- basic_machine=mips-siemens
- ;;
- rtpc | rtpc-*)
- basic_machine=romp-ibm
- ;;
- sequent)
- basic_machine=i386-sequent
- ;;
- sh)
- basic_machine=sh-hitachi
- os=-hms
- ;;
- sps7)
- basic_machine=m68k-bull
- os=-sysv2
- ;;
- spur)
- basic_machine=spur-unknown
- ;;
- sun2)
- basic_machine=m68000-sun
- ;;
- sun2os3)
- basic_machine=m68000-sun
- os=-sunos3
- ;;
- sun2os4)
- basic_machine=m68000-sun
- os=-sunos4
- ;;
- sun3os3)
- basic_machine=m68k-sun
- os=-sunos3
- ;;
- sun3os4)
- basic_machine=m68k-sun
- os=-sunos4
- ;;
- sun4os3)
- basic_machine=sparc-sun
- os=-sunos3
- ;;
- sun4os4)
- basic_machine=sparc-sun
- os=-sunos4
- ;;
- sun4sol2)
- basic_machine=sparc-sun
- os=-solaris2
- ;;
- sun3 | sun3-*)
- basic_machine=m68k-sun
- ;;
- sun4)
- basic_machine=sparc-sun
- ;;
- sun386 | sun386i | roadrunner)
- basic_machine=i386-sun
- ;;
- symmetry)
- basic_machine=i386-sequent
- os=-dynix
- ;;
- tx39)
- basic_machine=mipstx39-unknown
- ;;
- tx39el)
- basic_machine=mipstx39el-unknown
- ;;
- tower | tower-32)
- basic_machine=m68k-ncr
- ;;
- udi29k)
- basic_machine=a29k-amd
- os=-udi
- ;;
- ultra3)
- basic_machine=a29k-nyu
- os=-sym1
- ;;
- vaxv)
- basic_machine=vax-dec
- os=-sysv
- ;;
- vms)
- basic_machine=vax-dec
- os=-vms
- ;;
- vpp*|vx|vx-*)
- basic_machine=f301-fujitsu
- ;;
- vxworks960)
- basic_machine=i960-wrs
- os=-vxworks
- ;;
- vxworks68)
- basic_machine=m68k-wrs
- os=-vxworks
- ;;
- vxworks29k)
- basic_machine=a29k-wrs
- os=-vxworks
- ;;
- xmp)
- basic_machine=xmp-cray
- os=-unicos
- ;;
- xps | xps100)
- basic_machine=xps100-honeywell
- ;;
- none)
- basic_machine=none-none
- os=-none
- ;;
-
-# Here we handle the default manufacturer of certain CPU types. It is in
-# some cases the only manufacturer, in others, it is the most popular.
- mips)
- if [ x$os = x-linux-gnu ]; then
- basic_machine=mips-unknown
- else
- basic_machine=mips-mips
- fi
- ;;
- romp)
- basic_machine=romp-ibm
- ;;
- rs6000)
- basic_machine=rs6000-ibm
- ;;
- vax)
- basic_machine=vax-dec
- ;;
- pdp11)
- basic_machine=pdp11-dec
- ;;
- we32k)
- basic_machine=we32k-att
- ;;
- sparc)
- basic_machine=sparc-sun
- ;;
- cydra)
- basic_machine=cydra-cydrome
- ;;
- orion)
- basic_machine=orion-highlevel
- ;;
- orion105)
- basic_machine=clipper-highlevel
- ;;
- *)
- echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
- exit 1
- ;;
-esac
-
-# Here we canonicalize certain aliases for manufacturers.
-case $basic_machine in
- *-digital*)
- basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
- ;;
- *-commodore*)
- basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
- ;;
- *)
- ;;
-esac
-
-# Decode manufacturer-specific aliases for certain operating systems.
-
-if [ x"$os" != x"" ]
-then
-case $os in
- # First match some system type aliases
- # that might get confused with valid system types.
- # -solaris* is a basic system type, with this one exception.
- -solaris1 | -solaris1.*)
- os=`echo $os | sed -e 's|solaris1|sunos4|'`
- ;;
- -solaris)
- os=-solaris2
- ;;
- -svr4*)
- os=-sysv4
- ;;
- -unixware*)
- os=-sysv4.2uw
- ;;
- -gnu/linux*)
- os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
- ;;
- # First accept the basic system types.
- # The portable systems comes first.
- # Each alternative MUST END IN A *, to match a version number.
- # -sysv* is not here because it comes later, after sysvr4.
- -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
- | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
- | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
- | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
- | -aos* \
- | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
- | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
- | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \
- | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* \
- | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
- | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
- | -cygwin32* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
- | -mingw32* | -linux-gnu* | -uxpv* | -beos* )
- # Remember, each alternative MUST END IN *, to match a version number.
- ;;
- -linux*)
- os=`echo $os | sed -e 's|linux|linux-gnu|'`
- ;;
- -sunos5*)
- os=`echo $os | sed -e 's|sunos5|solaris2|'`
- ;;
- -sunos6*)
- os=`echo $os | sed -e 's|sunos6|solaris3|'`
- ;;
- -osfrose*)
- os=-osfrose
- ;;
- -osf*)
- os=-osf
- ;;
- -utek*)
- os=-bsd
- ;;
- -dynix*)
- os=-bsd
- ;;
- -acis*)
- os=-aos
- ;;
- -ctix* | -uts*)
- os=-sysv
- ;;
- -ns2 )
- os=-nextstep2
- ;;
- # Preserve the version number of sinix5.
- -sinix5.*)
- os=`echo $os | sed -e 's|sinix|sysv|'`
- ;;
- -sinix*)
- os=-sysv4
- ;;
- -triton*)
- os=-sysv3
- ;;
- -oss*)
- os=-sysv3
- ;;
- -svr4)
- os=-sysv4
- ;;
- -svr3)
- os=-sysv3
- ;;
- -sysvr4)
- os=-sysv4
- ;;
- # This must come after -sysvr4.
- -sysv*)
- ;;
- -xenix)
- os=-xenix
- ;;
- -none)
- ;;
- *)
- # Get rid of the `-' at the beginning of $os.
- os=`echo $os | sed 's/[^-]*-//'`
- echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
- exit 1
- ;;
-esac
-else
-
-# Here we handle the default operating systems that come with various machines.
-# The value should be what the vendor currently ships out the door with their
-# machine or put another way, the most popular os provided with the machine.
-
-# Note that if you're going to try to match "-MANUFACTURER" here (say,
-# "-sun"), then you have to tell the case statement up towards the top
-# that MANUFACTURER isn't an operating system. Otherwise, code above
-# will signal an error saying that MANUFACTURER isn't an operating
-# system, and we'll never get to this point.
-
-case $basic_machine in
- *-acorn)
- os=-riscix1.2
- ;;
- arm*-semi)
- os=-aout
- ;;
- pdp11-*)
- os=-none
- ;;
- *-dec | vax-*)
- os=-ultrix4.2
- ;;
- m68*-apollo)
- os=-domain
- ;;
- i386-sun)
- os=-sunos4.0.2
- ;;
- m68000-sun)
- os=-sunos3
- # This also exists in the configure program, but was not the
- # default.
- # os=-sunos4
- ;;
- *-tti) # must be before sparc entry or we get the wrong os.
- os=-sysv3
- ;;
- sparc-* | *-sun)
- os=-sunos4.1.1
- ;;
- *-ibm)
- os=-aix
- ;;
- *-hp)
- os=-hpux
- ;;
- *-hitachi)
- os=-hiux
- ;;
- i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
- os=-sysv
- ;;
- *-cbm)
- os=-amigaos
- ;;
- *-dg)
- os=-dgux
- ;;
- *-dolphin)
- os=-sysv3
- ;;
- m68k-ccur)
- os=-rtu
- ;;
- m88k-omron*)
- os=-luna
- ;;
- *-next )
- os=-nextstep
- ;;
- *-sequent)
- os=-ptx
- ;;
- *-crds)
- os=-unos
- ;;
- *-ns)
- os=-genix
- ;;
- i370-*)
- os=-mvs
- ;;
- *-next)
- os=-nextstep3
- ;;
- *-gould)
- os=-sysv
- ;;
- *-highlevel)
- os=-bsd
- ;;
- *-encore)
- os=-bsd
- ;;
- *-sgi)
- os=-irix
- ;;
- *-siemens)
- os=-sysv4
- ;;
- *-masscomp)
- os=-rtu
- ;;
- f301-fujitsu)
- os=-uxpv
- ;;
- *-be)
- os=-beos
- ;;
- *)
- os=-none
- ;;
-esac
-fi
-
-# Here we handle the case where we know the os, and the CPU type, but not the
-# manufacturer. We pick the logical manufacturer.
-vendor=unknown
-case $basic_machine in
- *-unknown)
- case $os in
- -riscix*)
- vendor=acorn
- ;;
- -sunos*)
- vendor=sun
- ;;
- -aix*)
- vendor=ibm
- ;;
- -hpux*)
- vendor=hp
- ;;
- -hiux*)
- vendor=hitachi
- ;;
- -unos*)
- vendor=crds
- ;;
- -dgux*)
- vendor=dg
- ;;
- -luna*)
- vendor=omron
- ;;
- -genix*)
- vendor=ns
- ;;
- -mvs*)
- vendor=ibm
- ;;
- -ptx*)
- vendor=sequent
- ;;
- -vxsim* | -vxworks*)
- vendor=wrs
- ;;
- -aux*)
- vendor=apple
- ;;
- -beos*)
- vendor=be
- ;;
- esac
- basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
- ;;
-esac
-
-echo $basic_machine$os
diff --git a/contrib/gcc/config/alpha/alpha.c b/contrib/gcc/config/alpha/alpha.c
index f7428c354779..2d62693d76bd 100644
--- a/contrib/gcc/config/alpha/alpha.c
+++ b/contrib/gcc/config/alpha/alpha.c
@@ -1,5 +1,5 @@
/* Subroutines used for code generation on the DEC Alpha.
- Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+ Copyright (C) 1992, 93-98, 1999 Free Software Foundation, Inc.
Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
This file is part of GNU CC.
@@ -20,8 +20,8 @@ the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#include <stdio.h>
#include "config.h"
+#include "system.h"
#include "rtl.h"
#include "regs.h"
#include "hard-reg-set.h"
@@ -34,9 +34,44 @@ Boston, MA 02111-1307, USA. */
#include "flags.h"
#include "recog.h"
#include "reload.h"
+#include "tree.h"
#include "expr.h"
#include "obstack.h"
-#include "tree.h"
+#include "except.h"
+#include "function.h"
+#include "toplev.h"
+
+/* External data. */
+extern char *version_string;
+extern int rtx_equal_function_value_matters;
+
+/* Specify which cpu to schedule for. */
+
+enum processor_type alpha_cpu;
+static const char * const alpha_cpu_name[] =
+{
+ "ev4", "ev5", "ev6"
+};
+
+/* Specify how accurate floating-point traps need to be. */
+
+enum alpha_trap_precision alpha_tp;
+
+/* Specify the floating-point rounding mode. */
+
+enum alpha_fp_rounding_mode alpha_fprm;
+
+/* Specify which things cause traps. */
+
+enum alpha_fp_trap_mode alpha_fptm;
+
+/* Strings decoded into the above options. */
+
+const char *alpha_cpu_string; /* -mcpu= */
+const char *alpha_tp_string; /* -mtrap-precision=[p|s|i] */
+const char *alpha_fprm_string; /* -mfp-rounding-mode=[n|m|c|d] */
+const char *alpha_fptm_string; /* -mfp-trap-mode=[n|u|su|sui] */
+const char *alpha_mlat_string; /* -mmemory-latency= */
/* Save information from a "cmpxx" operation until the branch or scc is
emitted. */
@@ -44,26 +79,238 @@ Boston, MA 02111-1307, USA. */
rtx alpha_compare_op0, alpha_compare_op1;
int alpha_compare_fp_p;
-/* Save the name of the current function as used by the assembler. This
- is used by the epilogue. */
+/* Define the information needed to modify the epilogue for EH. */
-char *alpha_function_name;
+rtx alpha_eh_epilogue_sp_ofs;
/* Non-zero if inside of a function, because the Alpha asm can't
handle .files inside of functions. */
static int inside_function = FALSE;
-/* Nonzero if the current function needs gp. */
+/* If non-null, this rtx holds the return address for the function. */
-int alpha_function_needs_gp;
+static rtx alpha_return_addr_rtx;
-extern char *version_string;
-extern int rtx_equal_function_value_matters;
+/* The number of cycles of latency we should assume on memory reads. */
+
+int alpha_memory_latency = 3;
+
+/* Whether the function needs the GP. */
+
+static int alpha_function_needs_gp;
+
+/* The alias set for prologue/epilogue register save/restore. */
+
+static int alpha_sr_alias_set;
/* Declarations of static functions. */
-static void alpha_set_memflags_1 PROTO((rtx, int, int, int));
-static void add_long_const PROTO((FILE *, HOST_WIDE_INT, int, int, int));
+static void alpha_set_memflags_1
+ PROTO((rtx, int, int, int));
+static rtx alpha_emit_set_const_1
+ PROTO((rtx, enum machine_mode, HOST_WIDE_INT, int));
+static void alpha_expand_unaligned_load_words
+ PROTO((rtx *out_regs, rtx smem, HOST_WIDE_INT words, HOST_WIDE_INT ofs));
+static void alpha_expand_unaligned_store_words
+ PROTO((rtx *out_regs, rtx smem, HOST_WIDE_INT words, HOST_WIDE_INT ofs));
+static void alpha_sa_mask
+ PROTO((unsigned long *imaskP, unsigned long *fmaskP));
+static int alpha_does_function_need_gp
+ PROTO((void));
+
+
+/* Get the number of args of a function in one of two ways. */
+#ifdef OPEN_VMS
+#define NUM_ARGS current_function_args_info.num_args
+#else
+#define NUM_ARGS current_function_args_info
+#endif
+
+#define REG_PV 27
+#define REG_RA 26
+
+/* Parse target option strings. */
+
+void
+override_options ()
+{
+ alpha_tp = ALPHA_TP_PROG;
+ alpha_fprm = ALPHA_FPRM_NORM;
+ alpha_fptm = ALPHA_FPTM_N;
+
+ if (TARGET_IEEE)
+ {
+ alpha_tp = ALPHA_TP_INSN;
+ alpha_fptm = ALPHA_FPTM_SU;
+ }
+
+ if (TARGET_IEEE_WITH_INEXACT)
+ {
+ alpha_tp = ALPHA_TP_INSN;
+ alpha_fptm = ALPHA_FPTM_SUI;
+ }
+
+ if (alpha_tp_string)
+ {
+ if (! strcmp (alpha_tp_string, "p"))
+ alpha_tp = ALPHA_TP_PROG;
+ else if (! strcmp (alpha_tp_string, "f"))
+ alpha_tp = ALPHA_TP_FUNC;
+ else if (! strcmp (alpha_tp_string, "i"))
+ alpha_tp = ALPHA_TP_INSN;
+ else
+ error ("bad value `%s' for -mtrap-precision switch", alpha_tp_string);
+ }
+
+ if (alpha_fprm_string)
+ {
+ if (! strcmp (alpha_fprm_string, "n"))
+ alpha_fprm = ALPHA_FPRM_NORM;
+ else if (! strcmp (alpha_fprm_string, "m"))
+ alpha_fprm = ALPHA_FPRM_MINF;
+ else if (! strcmp (alpha_fprm_string, "c"))
+ alpha_fprm = ALPHA_FPRM_CHOP;
+ else if (! strcmp (alpha_fprm_string,"d"))
+ alpha_fprm = ALPHA_FPRM_DYN;
+ else
+ error ("bad value `%s' for -mfp-rounding-mode switch",
+ alpha_fprm_string);
+ }
+
+ if (alpha_fptm_string)
+ {
+ if (strcmp (alpha_fptm_string, "n") == 0)
+ alpha_fptm = ALPHA_FPTM_N;
+ else if (strcmp (alpha_fptm_string, "u") == 0)
+ alpha_fptm = ALPHA_FPTM_U;
+ else if (strcmp (alpha_fptm_string, "su") == 0)
+ alpha_fptm = ALPHA_FPTM_SU;
+ else if (strcmp (alpha_fptm_string, "sui") == 0)
+ alpha_fptm = ALPHA_FPTM_SUI;
+ else
+ error ("bad value `%s' for -mfp-trap-mode switch", alpha_fptm_string);
+ }
+
+ alpha_cpu
+ = TARGET_CPU_DEFAULT & MASK_CPU_EV6 ? PROCESSOR_EV6
+ : (TARGET_CPU_DEFAULT & MASK_CPU_EV5 ? PROCESSOR_EV5 : PROCESSOR_EV4);
+
+ if (alpha_cpu_string)
+ {
+ if (! strcmp (alpha_cpu_string, "ev4")
+ || ! strcmp (alpha_cpu_string, "21064"))
+ {
+ alpha_cpu = PROCESSOR_EV4;
+ target_flags &= ~ (MASK_BWX | MASK_MAX | MASK_FIX | MASK_CIX);
+ }
+ else if (! strcmp (alpha_cpu_string, "ev5")
+ || ! strcmp (alpha_cpu_string, "21164"))
+ {
+ alpha_cpu = PROCESSOR_EV5;
+ target_flags &= ~ (MASK_BWX | MASK_MAX | MASK_FIX | MASK_CIX);
+ }
+ else if (! strcmp (alpha_cpu_string, "ev56")
+ || ! strcmp (alpha_cpu_string, "21164a"))
+ {
+ alpha_cpu = PROCESSOR_EV5;
+ target_flags |= MASK_BWX;
+ target_flags &= ~ (MASK_MAX | MASK_FIX | MASK_CIX);
+ }
+ else if (! strcmp (alpha_cpu_string, "pca56")
+ || ! strcmp (alpha_cpu_string, "21164PC")
+ || ! strcmp (alpha_cpu_string, "21164pc"))
+ {
+ alpha_cpu = PROCESSOR_EV5;
+ target_flags |= MASK_BWX | MASK_MAX;
+ target_flags &= ~ (MASK_FIX | MASK_CIX);
+ }
+ else if (! strcmp (alpha_cpu_string, "ev6")
+ || ! strcmp (alpha_cpu_string, "21264"))
+ {
+ alpha_cpu = PROCESSOR_EV6;
+ target_flags |= MASK_BWX | MASK_MAX | MASK_FIX;
+ target_flags &= ~ (MASK_CIX);
+ }
+ else
+ error ("bad value `%s' for -mcpu switch", alpha_cpu_string);
+ }
+
+ /* Do some sanity checks on the above options. */
+
+ if ((alpha_fptm == ALPHA_FPTM_SU || alpha_fptm == ALPHA_FPTM_SUI)
+ && alpha_tp != ALPHA_TP_INSN && alpha_cpu != PROCESSOR_EV6)
+ {
+ warning ("fp software completion requires -mtrap-precision=i");
+ alpha_tp = ALPHA_TP_INSN;
+ }
+
+ if (TARGET_FLOAT_VAX)
+ {
+ if (alpha_fprm == ALPHA_FPRM_MINF || alpha_fprm == ALPHA_FPRM_DYN)
+ {
+ warning ("rounding mode not supported for VAX floats");
+ alpha_fprm = ALPHA_FPRM_NORM;
+ }
+ if (alpha_fptm == ALPHA_FPTM_SUI)
+ {
+ warning ("trap mode not supported for VAX floats");
+ alpha_fptm = ALPHA_FPTM_SU;
+ }
+ }
+
+ {
+ char *end;
+ int lat;
+
+ if (!alpha_mlat_string)
+ alpha_mlat_string = "L1";
+
+ if (ISDIGIT ((unsigned char)alpha_mlat_string[0])
+ && (lat = strtol (alpha_mlat_string, &end, 10), *end == '\0'))
+ ;
+ else if ((alpha_mlat_string[0] == 'L' || alpha_mlat_string[0] == 'l')
+ && ISDIGIT ((unsigned char)alpha_mlat_string[1])
+ && alpha_mlat_string[2] == '\0')
+ {
+ static int const cache_latency[][4] =
+ {
+ { 3, 30, -1 }, /* ev4 -- Bcache is a guess */
+ { 2, 12, 38 }, /* ev5 -- Bcache from PC164 LMbench numbers */
+ { 3, 13, -1 }, /* ev6 -- Ho hum, doesn't exist yet */
+ };
+
+ lat = alpha_mlat_string[1] - '0';
+ if (lat < 0 || lat > 3 || cache_latency[alpha_cpu][lat-1] == -1)
+ {
+ warning ("L%d cache latency unknown for %s",
+ lat, alpha_cpu_name[alpha_cpu]);
+ lat = 3;
+ }
+ else
+ lat = cache_latency[alpha_cpu][lat-1];
+ }
+ else if (! strcmp (alpha_mlat_string, "main"))
+ {
+ /* Most current memories have about 370ns latency. This is
+ a reasonable guess for a fast cpu. */
+ lat = 150;
+ }
+ else
+ {
+ warning ("bad value `%s' for -mmemory-latency", alpha_mlat_string);
+ lat = 3;
+ }
+
+ alpha_memory_latency = lat;
+ }
+
+ /* Default the definition of "small data" to 8 bytes. */
+ if (!g_switch_set)
+ g_switch_value = 8;
+
+ /* Acquire a unique set number for our register saves and restores. */
+ alpha_sr_alias_set = new_alias_set ();
+}
/* Returns 1 if VALUE is a mask that contains full bytes of zero or ones. */
@@ -123,10 +370,10 @@ reg_or_8bit_operand (op, mode)
int
cint8_operand (op, mode)
register rtx op;
- enum machine_mode mode;
+ enum machine_mode mode ATTRIBUTE_UNUSED;
{
- return (GET_CODE (op) == CONST_INT
- && (unsigned HOST_WIDE_INT) INTVAL (op) < 0x100);
+ return ((GET_CODE (op) == CONST_INT
+ && (unsigned HOST_WIDE_INT) INTVAL (op) < 0x100));
}
/* Return 1 if the operand is a valid second operand to an add insn. */
@@ -137,9 +384,9 @@ add_operand (op, mode)
enum machine_mode mode;
{
if (GET_CODE (op) == CONST_INT)
+ /* Constraints I, J, O and P are covered by K. */
return (CONST_OK_FOR_LETTER_P (INTVAL (op), 'K')
- || CONST_OK_FOR_LETTER_P (INTVAL (op), 'L')
- || CONST_OK_FOR_LETTER_P (INTVAL (op), 'O'));
+ || CONST_OK_FOR_LETTER_P (INTVAL (op), 'L'));
return register_operand (op, mode);
}
@@ -153,8 +400,8 @@ sext_add_operand (op, mode)
enum machine_mode mode;
{
if (GET_CODE (op) == CONST_INT)
- return ((unsigned HOST_WIDE_INT) INTVAL (op) < 255
- || (unsigned HOST_WIDE_INT) (- INTVAL (op)) < 255);
+ return (CONST_OK_FOR_LETTER_P (INTVAL (op), 'I')
+ || CONST_OK_FOR_LETTER_P (INTVAL (op), 'O'));
return register_operand (op, mode);
}
@@ -164,7 +411,7 @@ sext_add_operand (op, mode)
int
const48_operand (op, mode)
register rtx op;
- enum machine_mode mode;
+ enum machine_mode mode ATTRIBUTE_UNUSED;
{
return (GET_CODE (op) == CONST_INT
&& (INTVAL (op) == 4 || INTVAL (op) == 8));
@@ -209,10 +456,11 @@ or_operand (op, mode)
int
mode_width_operand (op, mode)
register rtx op;
- enum machine_mode mode;
+ enum machine_mode mode ATTRIBUTE_UNUSED;
{
return (GET_CODE (op) == CONST_INT
- && (INTVAL (op) == 8 || INTVAL (op) == 16 || INTVAL (op) == 32));
+ && (INTVAL (op) == 8 || INTVAL (op) == 16
+ || INTVAL (op) == 32 || INTVAL (op) == 64));
}
/* Return 1 if OP is a constant that is the width of an integral machine mode
@@ -221,18 +469,24 @@ mode_width_operand (op, mode)
int
mode_mask_operand (op, mode)
register rtx op;
- enum machine_mode mode;
+ enum machine_mode mode ATTRIBUTE_UNUSED;
{
#if HOST_BITS_PER_WIDE_INT == 32
if (GET_CODE (op) == CONST_DOUBLE)
- return CONST_DOUBLE_HIGH (op) == 0 && CONST_DOUBLE_LOW (op) == -1;
+ return (CONST_DOUBLE_LOW (op) == -1
+ && (CONST_DOUBLE_HIGH (op) == -1
+ || CONST_DOUBLE_HIGH (op) == 0));
+#else
+ if (GET_CODE (op) == CONST_DOUBLE)
+ return (CONST_DOUBLE_LOW (op) == -1 && CONST_DOUBLE_HIGH (op) == 0);
#endif
return (GET_CODE (op) == CONST_INT
&& (INTVAL (op) == 0xff
|| INTVAL (op) == 0xffff
+ || INTVAL (op) == (HOST_WIDE_INT)0xffffffff
#if HOST_BITS_PER_WIDE_INT == 64
- || INTVAL (op) == 0xffffffff
+ || INTVAL (op) == -1
#endif
));
}
@@ -242,7 +496,7 @@ mode_mask_operand (op, mode)
int
mul8_operand (op, mode)
register rtx op;
- enum machine_mode mode;
+ enum machine_mode mode ATTRIBUTE_UNUSED;
{
return (GET_CODE (op) == CONST_INT
&& (unsigned HOST_WIDE_INT) INTVAL (op) < 64
@@ -270,6 +524,18 @@ reg_or_fp0_operand (op, mode)
return fp0_operand (op, mode) || register_operand (op, mode);
}
+/* Return 1 if OP is a hard floating-point register. */
+
+int
+hard_fp_register_operand (op, mode)
+ register rtx op;
+ enum machine_mode mode;
+{
+ return ((GET_CODE (op) == REG && REGNO_REG_CLASS (REGNO (op)) == FLOAT_REGS)
+ || (GET_CODE (op) == SUBREG
+ && hard_fp_register_operand (SUBREG_REG (op), mode)));
+}
+
/* Return 1 if OP is a register or a constant integer. */
@@ -278,7 +544,8 @@ reg_or_cint_operand (op, mode)
register rtx op;
enum machine_mode mode;
{
- return GET_CODE (op) == CONST_INT || register_operand (op, mode);
+ return (GET_CODE (op) == CONST_INT
+ || register_operand (op, mode));
}
/* Return 1 if OP is something that can be reloaded into a register;
@@ -294,12 +561,15 @@ some_operand (op, mode)
switch (GET_CODE (op))
{
- case REG: case MEM: case CONST_DOUBLE:
- case CONST_INT: case LABEL_REF: case SYMBOL_REF: case CONST:
+ case REG: case MEM: case CONST_DOUBLE: case CONST_INT: case LABEL_REF:
+ case SYMBOL_REF: case CONST:
return 1;
case SUBREG:
return some_operand (SUBREG_REG (op), VOIDmode);
+
+ default:
+ break;
}
return 0;
@@ -323,7 +593,7 @@ input_operand (op, mode)
case LABEL_REF:
case SYMBOL_REF:
case CONST:
- /* This handles both the Windows/NT and OSF cases. */
+ /* This handles both the Windows/NT and OSF cases. */
return mode == ptr_mode || mode == DImode;
case REG:
@@ -334,13 +604,20 @@ input_operand (op, mode)
return 1;
/* ... fall through ... */
case MEM:
- return mode != HImode && mode != QImode && general_operand (op, mode);
+ return ((TARGET_BWX || (mode != HImode && mode != QImode))
+ && general_operand (op, mode));
case CONST_DOUBLE:
return GET_MODE_CLASS (mode) == MODE_FLOAT && op == CONST0_RTX (mode);
case CONST_INT:
return mode == QImode || mode == HImode || add_operand (op, mode);
+
+ case CONSTANT_P_RTX:
+ return 1;
+
+ default:
+ break;
}
return 0;
@@ -352,7 +629,7 @@ input_operand (op, mode)
int
current_file_function_operand (op, mode)
rtx op;
- enum machine_mode mode;
+ enum machine_mode mode ATTRIBUTE_UNUSED;
{
return (GET_CODE (op) == SYMBOL_REF
&& ! profile_flag && ! profile_block_flag
@@ -370,7 +647,9 @@ call_operand (op, mode)
if (mode != Pmode)
return 0;
- return (GET_CODE (op) == SYMBOL_REF || GET_CODE (op) == REG);
+ return (GET_CODE (op) == SYMBOL_REF
+ || (GET_CODE (op) == REG
+ && (TARGET_OPEN_VMS || TARGET_WINDOWS_NT || REGNO (op) == 27)));
}
/* Return 1 if OP is a valid Alpha comparison operator. Here we know which
@@ -390,17 +669,37 @@ alpha_comparison_operator (op, mode)
|| (mode == DImode && (code == LEU || code == LTU)));
}
+/* Return 1 if OP is a valid Alpha swapped comparison operator. */
+
+int
+alpha_swapped_comparison_operator (op, mode)
+ register rtx op;
+ enum machine_mode mode;
+{
+ enum rtx_code code = GET_CODE (op);
+
+ if (mode != GET_MODE (op) || GET_RTX_CLASS (code) != '<')
+ return 0;
+
+ code = swap_condition (code);
+ return (code == EQ || code == LE || code == LT
+ || (mode == DImode && (code == LEU || code == LTU)));
+}
+
/* Return 1 if OP is a signed comparison operation. */
int
signed_comparison_operator (op, mode)
register rtx op;
- enum machine_mode mode;
+ enum machine_mode mode ATTRIBUTE_UNUSED;
{
switch (GET_CODE (op))
{
case EQ: case NE: case LE: case LT: case GE: case GT:
return 1;
+
+ default:
+ break;
}
return 0;
@@ -411,12 +710,15 @@ signed_comparison_operator (op, mode)
int
divmod_operator (op, mode)
register rtx op;
- enum machine_mode mode;
+ enum machine_mode mode ATTRIBUTE_UNUSED;
{
switch (GET_CODE (op))
{
case DIV: case MOD: case UDIV: case UMOD:
return 1;
+
+ default:
+ break;
}
return 0;
@@ -426,43 +728,49 @@ divmod_operator (op, mode)
a constant. It must be a valid address. This means that we can do
this as an aligned reference plus some offset.
- Take into account what reload will do.
-
- We could say that out-of-range stack slots are alignable, but that would
- complicate get_aligned_mem and it isn't worth the trouble since few
- functions have large stack space. */
+ Take into account what reload will do. */
int
aligned_memory_operand (op, mode)
register rtx op;
enum machine_mode mode;
{
- if (GET_CODE (op) == SUBREG)
+ rtx base;
+
+ if (reload_in_progress)
{
- if (GET_MODE (op) != mode)
- return 0;
- op = SUBREG_REG (op);
- mode = GET_MODE (op);
+ rtx tmp = op;
+ if (GET_CODE (tmp) == SUBREG)
+ tmp = SUBREG_REG (tmp);
+ if (GET_CODE (tmp) == REG
+ && REGNO (tmp) >= FIRST_PSEUDO_REGISTER)
+ {
+ op = reg_equiv_memory_loc[REGNO (tmp)];
+ if (op == 0)
+ return 0;
+ }
}
- if (reload_in_progress && GET_CODE (op) == REG
- && REGNO (op) >= FIRST_PSEUDO_REGISTER)
- op = reg_equiv_mem[REGNO (op)];
-
- if (GET_CODE (op) != MEM || GET_MODE (op) != mode
- || ! memory_address_p (mode, XEXP (op, 0)))
+ if (GET_CODE (op) != MEM
+ || GET_MODE (op) != mode)
return 0;
-
op = XEXP (op, 0);
- if (GET_CODE (op) == PLUS)
- op = XEXP (op, 0);
+ /* LEGITIMIZE_RELOAD_ADDRESS creates (plus (plus reg const_hi) const_lo)
+ sorts of constructs. Dig for the real base register. */
+ if (reload_in_progress
+ && GET_CODE (op) == PLUS
+ && GET_CODE (XEXP (op, 0)) == PLUS)
+ base = XEXP (XEXP (op, 0), 0);
+ else
+ {
+ if (! memory_address_p (mode, op))
+ return 0;
+ base = (GET_CODE (op) == PLUS ? XEXP (op, 0) : op);
+ }
- return (GET_CODE (op) == REG
- && (REGNO (op) == STACK_POINTER_REGNUM
- || op == hard_frame_pointer_rtx
- || (REGNO (op) >= FIRST_VIRTUAL_REGISTER
- && REGNO (op) <= LAST_VIRTUAL_REGISTER)));
+ return (GET_CODE (base) == REG
+ && REGNO_POINTER_ALIGN (REGNO (base)) >= 4);
}
/* Similar, but return 1 if OP is a MEM which is not alignable. */
@@ -472,34 +780,52 @@ unaligned_memory_operand (op, mode)
register rtx op;
enum machine_mode mode;
{
- if (GET_CODE (op) == SUBREG)
+ rtx base;
+
+ if (reload_in_progress)
{
- if (GET_MODE (op) != mode)
- return 0;
- op = SUBREG_REG (op);
- mode = GET_MODE (op);
+ rtx tmp = op;
+ if (GET_CODE (tmp) == SUBREG)
+ tmp = SUBREG_REG (tmp);
+ if (GET_CODE (tmp) == REG
+ && REGNO (tmp) >= FIRST_PSEUDO_REGISTER)
+ {
+ op = reg_equiv_memory_loc[REGNO (tmp)];
+ if (op == 0)
+ return 0;
+ }
}
- if (reload_in_progress && GET_CODE (op) == REG
- && REGNO (op) >= FIRST_PSEUDO_REGISTER)
- op = reg_equiv_mem[REGNO (op)];
-
- if (GET_CODE (op) != MEM || GET_MODE (op) != mode)
+ if (GET_CODE (op) != MEM
+ || GET_MODE (op) != mode)
return 0;
-
op = XEXP (op, 0);
- if (! memory_address_p (mode, op))
- return 1;
+ /* LEGITIMIZE_RELOAD_ADDRESS creates (plus (plus reg const_hi) const_lo)
+ sorts of constructs. Dig for the real base register. */
+ if (reload_in_progress
+ && GET_CODE (op) == PLUS
+ && GET_CODE (XEXP (op, 0)) == PLUS)
+ base = XEXP (XEXP (op, 0), 0);
+ else
+ {
+ if (! memory_address_p (mode, op))
+ return 0;
+ base = (GET_CODE (op) == PLUS ? XEXP (op, 0) : op);
+ }
+
+ return (GET_CODE (base) == REG
+ && REGNO_POINTER_ALIGN (REGNO (base)) < 4);
+}
- if (GET_CODE (op) == PLUS)
- op = XEXP (op, 0);
+/* Return 1 if OP is either a register or an unaligned memory location. */
- return (GET_CODE (op) != REG
- || (REGNO (op) != STACK_POINTER_REGNUM
- && op != hard_frame_pointer_rtx
- && (REGNO (op) < FIRST_VIRTUAL_REGISTER
- || REGNO (op) > LAST_VIRTUAL_REGISTER)));
+int
+reg_or_unaligned_mem_operand (op, mode)
+ rtx op;
+ enum machine_mode mode;
+{
+ return register_operand (op, mode) || unaligned_memory_operand (op, mode);
}
/* Return 1 if OP is any memory location. During reload a pseudo matches. */
@@ -507,7 +833,7 @@ unaligned_memory_operand (op, mode)
int
any_memory_operand (op, mode)
register rtx op;
- enum machine_mode mode;
+ enum machine_mode mode ATTRIBUTE_UNUSED;
{
return (GET_CODE (op) == MEM
|| (GET_CODE (op) == SUBREG && GET_CODE (SUBREG_REG (op)) == REG)
@@ -518,9 +844,89 @@ any_memory_operand (op, mode)
&& REGNO (SUBREG_REG (op)) >= FIRST_PSEUDO_REGISTER));
}
+/* Returns 1 if OP is not an eliminable register.
+
+ This exists to cure a pathological abort in the s8addq (et al) patterns,
+
+ long foo () { long t; bar(); return (long) &t * 26107; }
+
+ which run afoul of a hack in reload to cure a (presumably) similar
+ problem with lea-type instructions on other targets. But there is
+ one of us and many of them, so work around the problem by selectively
+ preventing combine from making the optimization. */
+
+int
+reg_not_elim_operand (op, mode)
+ register rtx op;
+ enum machine_mode mode;
+{
+ rtx inner = op;
+ if (GET_CODE (op) == SUBREG)
+ inner = SUBREG_REG (op);
+ if (inner == frame_pointer_rtx || inner == arg_pointer_rtx)
+ return 0;
+
+ return register_operand (op, mode);
+}
+
+/* Return 1 is OP is a memory location that is not a reference (using
+ an AND) to an unaligned location. Take into account what reload
+ will do. */
+
+int
+normal_memory_operand (op, mode)
+ register rtx op;
+ enum machine_mode mode ATTRIBUTE_UNUSED;
+{
+ if (reload_in_progress)
+ {
+ rtx tmp = op;
+ if (GET_CODE (tmp) == SUBREG)
+ tmp = SUBREG_REG (tmp);
+ if (GET_CODE (tmp) == REG
+ && REGNO (tmp) >= FIRST_PSEUDO_REGISTER)
+ {
+ op = reg_equiv_memory_loc[REGNO (tmp)];
+
+ /* This may not have been assigned an equivalent address if it will
+ be eliminated. In that case, it doesn't matter what we do. */
+ if (op == 0)
+ return 1;
+ }
+ }
+
+ return GET_CODE (op) == MEM && GET_CODE (XEXP (op, 0)) != AND;
+}
+
+/* Accept a register, but not a subreg of any kind. This allows us to
+ avoid pathological cases in reload wrt data movement common in
+ int->fp conversion. */
+
+int
+reg_no_subreg_operand (op, mode)
+ register rtx op;
+ enum machine_mode mode;
+{
+ if (GET_CODE (op) == SUBREG)
+ return 0;
+ return register_operand (op, mode);
+}
+
+/* Return 1 if this function can directly return via $26. */
+
+int
+direct_return ()
+{
+ return (! TARGET_OPEN_VMS && reload_completed && alpha_sa_size () == 0
+ && get_frame_size () == 0
+ && current_function_outgoing_args_size == 0
+ && current_function_pretend_args_size == 0);
+}
+
/* REF is an alignable memory location. Place an aligned SImode
reference into *PALIGNED_MEM and the number of bits to shift into
- *PBITNUM. */
+ *PBITNUM. SCRATCH is a free register for use in reloading out
+ of range stack slots. */
void
get_aligned_mem (ref, paligned_mem, pbitnum)
@@ -530,67 +936,67 @@ get_aligned_mem (ref, paligned_mem, pbitnum)
rtx base;
HOST_WIDE_INT offset = 0;
- if (GET_CODE (ref) == SUBREG)
- {
- offset = SUBREG_WORD (ref) * UNITS_PER_WORD;
- if (BYTES_BIG_ENDIAN)
- offset -= (MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (ref)))
- - MIN (UNITS_PER_WORD,
- GET_MODE_SIZE (GET_MODE (SUBREG_REG (ref)))));
- ref = SUBREG_REG (ref);
- }
+ if (GET_CODE (ref) != MEM)
+ abort ();
- if (GET_CODE (ref) == REG)
- ref = reg_equiv_mem[REGNO (ref)];
+ if (reload_in_progress
+ && ! memory_address_p (GET_MODE (ref), XEXP (ref, 0)))
+ {
+ base = find_replacement (&XEXP (ref, 0));
- if (reload_in_progress)
- base = find_replacement (&XEXP (ref, 0));
+ if (! memory_address_p (GET_MODE (ref), base))
+ abort ();
+ }
else
- base = XEXP (ref, 0);
+ {
+ base = XEXP (ref, 0);
+ }
if (GET_CODE (base) == PLUS)
offset += INTVAL (XEXP (base, 1)), base = XEXP (base, 0);
- *paligned_mem = gen_rtx (MEM, SImode,
- plus_constant (base, offset & ~3));
- MEM_IN_STRUCT_P (*paligned_mem) = MEM_IN_STRUCT_P (ref);
- MEM_VOLATILE_P (*paligned_mem) = MEM_VOLATILE_P (ref);
+ *paligned_mem = gen_rtx_MEM (SImode, plus_constant (base, offset & ~3));
+ MEM_COPY_ATTRIBUTES (*paligned_mem, ref);
RTX_UNCHANGING_P (*paligned_mem) = RTX_UNCHANGING_P (ref);
+ /* Sadly, we cannot use alias sets here because we may overlap other
+ data in a different alias set. */
+ /* MEM_ALIAS_SET (*paligned_mem) = MEM_ALIAS_SET (ref); */
+
*pbitnum = GEN_INT ((offset & 3) * 8);
}
-/* Similar, but just get the address. Handle the two reload cases. */
+/* Similar, but just get the address. Handle the two reload cases.
+ Add EXTRA_OFFSET to the address we return. */
rtx
-get_unaligned_address (ref)
+get_unaligned_address (ref, extra_offset)
rtx ref;
+ int extra_offset;
{
rtx base;
HOST_WIDE_INT offset = 0;
- if (GET_CODE (ref) == SUBREG)
- {
- offset = SUBREG_WORD (ref) * UNITS_PER_WORD;
- if (BYTES_BIG_ENDIAN)
- offset -= (MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (ref)))
- - MIN (UNITS_PER_WORD,
- GET_MODE_SIZE (GET_MODE (SUBREG_REG (ref)))));
- ref = SUBREG_REG (ref);
- }
+ if (GET_CODE (ref) != MEM)
+ abort ();
- if (GET_CODE (ref) == REG)
- ref = reg_equiv_mem[REGNO (ref)];
+ if (reload_in_progress
+ && ! memory_address_p (GET_MODE (ref), XEXP (ref, 0)))
+ {
+ base = find_replacement (&XEXP (ref, 0));
- if (reload_in_progress)
- base = find_replacement (&XEXP (ref, 0));
+ if (! memory_address_p (GET_MODE (ref), base))
+ abort ();
+ }
else
- base = XEXP (ref, 0);
+ {
+ base = XEXP (ref, 0);
+ }
if (GET_CODE (base) == PLUS)
offset += INTVAL (XEXP (base, 1)), base = XEXP (base, 0);
- return plus_constant (base, offset);
+ return plus_constant (base, offset + extra_offset);
}
/* Subfunction of the following function. Update the flags of any MEM
@@ -628,6 +1034,15 @@ alpha_set_memflags_1 (x, in_struct_p, volatile_p, unchanging_p)
MEM_IN_STRUCT_P (x) = in_struct_p;
MEM_VOLATILE_P (x) = volatile_p;
RTX_UNCHANGING_P (x) = unchanging_p;
+ /* Sadly, we cannot use alias sets because the extra aliasing
+ produced by the AND interferes. Given that two-byte quantities
+ are the only thing we would be able to differentiate anyway,
+ there does not seem to be any point in convoluting the early
+ out of the alias check. */
+ /* MEM_ALIAS_SET (x) = alias_set; */
+ break;
+
+ default:
break;
}
}
@@ -643,14 +1058,19 @@ alpha_set_memflags (insn, ref)
rtx insn;
rtx ref;
{
- /* Note that it is always safe to get these flags, though they won't
- be what we think if REF is not a MEM. */
- int in_struct_p = MEM_IN_STRUCT_P (ref);
- int volatile_p = MEM_VOLATILE_P (ref);
- int unchanging_p = RTX_UNCHANGING_P (ref);
+ int in_struct_p, volatile_p, unchanging_p;
- if (GET_CODE (ref) != MEM
- || (! in_struct_p && ! volatile_p && ! unchanging_p))
+ if (GET_CODE (ref) != MEM)
+ return;
+
+ in_struct_p = MEM_IN_STRUCT_P (ref);
+ volatile_p = MEM_VOLATILE_P (ref);
+ unchanging_p = RTX_UNCHANGING_P (ref);
+
+ /* This is only called from alpha.md, after having had something
+ generated from one of the insn patterns. So if everything is
+ zero, the pattern is already up-to-date. */
+ if (! in_struct_p && ! volatile_p && ! unchanging_p)
return;
alpha_set_memflags_1 (insn, in_struct_p, volatile_p, unchanging_p);
@@ -669,6 +1089,26 @@ alpha_emit_set_const (target, mode, c, n)
HOST_WIDE_INT c;
int n;
{
+ rtx pat;
+ int i;
+
+ /* Try 1 insn, then 2, then up to N. */
+ for (i = 1; i <= n; i++)
+ if ((pat = alpha_emit_set_const_1 (target, mode, c, i)) != 0)
+ return pat;
+
+ return 0;
+}
+
+/* Internal routine for the above to check for N or below insns. */
+
+static rtx
+alpha_emit_set_const_1 (target, mode, c, n)
+ rtx target;
+ enum machine_mode mode;
+ HOST_WIDE_INT c;
+ int n;
+{
HOST_WIDE_INT new = c;
int i, bits;
/* Use a pseudo if highly optimizing and still generating RTL. */
@@ -688,12 +1128,10 @@ alpha_emit_set_const (target, mode, c, n)
/* If this is a sign-extended 32-bit constant, we can do this in at most
three insns, so do it if we have enough insns left. We always have
- a sign-extended 32-bit constant when compiling on a narrow machine.
- Note that we cannot handle the constant 0x80000000. */
+ a sign-extended 32-bit constant when compiling on a narrow machine. */
- if ((HOST_BITS_PER_WIDE_INT != 64
- || c >> 31 == -1 || c >> 31 == 0)
- && c != 0x80000000U)
+ if (HOST_BITS_PER_WIDE_INT != 64
+ || c >> 31 == -1 || c >> 31 == 0)
{
HOST_WIDE_INT low = (c & 0xffff) - 2 * (c & 0x8000);
HOST_WIDE_INT tmp1 = c - low;
@@ -712,13 +1150,19 @@ alpha_emit_set_const (target, mode, c, n)
}
if (c == low || (low == 0 && extra == 0))
- return copy_to_suggested_reg (GEN_INT (c), target, mode);
- else if (n >= 2 + (extra != 0)
- /* We can't do this when SImode if HIGH required adjustment.
- This is because the code relies on an implicit overflow
- which is invisible to the RTL. We can thus get incorrect
- code if the two ldah instructions are combined. */
- && ! (mode == SImode && extra != 0))
+ {
+ /* We used to use copy_to_suggested_reg (GEN_INT (c), target, mode)
+ but that meant that we can't handle INT_MIN on 32-bit machines
+ (like NT/Alpha), because we recurse indefinitely through
+ emit_move_insn to gen_movdi. So instead, since we know exactly
+ what we want, create it explicitly. */
+
+ if (target == NULL)
+ target = gen_reg_rtx (mode);
+ emit_insn (gen_rtx_SET (VOIDmode, target, GEN_INT (c)));
+ return target;
+ }
+ else if (n >= 2 + (extra != 0))
{
temp = copy_to_suggested_reg (GEN_INT (low), subtarget, mode);
@@ -784,7 +1228,7 @@ alpha_emit_set_const (target, mode, c, n)
for (; bits > 0; bits--)
if ((temp = (alpha_emit_set_const
(subtarget, mode,
- (unsigned HOST_WIDE_INT) c >> bits, i))) != 0
+ (unsigned HOST_WIDE_INT) (c >> bits), i))) != 0
|| ((temp = (alpha_emit_set_const
(subtarget, mode,
((unsigned HOST_WIDE_INT) c) >> bits, i)))
@@ -795,9 +1239,11 @@ alpha_emit_set_const (target, mode, c, n)
/* Now try high-order zero bits. Here we try the shifted-in bits as
all zero and all ones. Be careful to avoid shifting outside the
mode and to avoid shifting outside the host wide int size. */
+ /* On narrow hosts, don't shift a 1 into the high bit, since we'll
+ confuse the recursive call and set all of the high 32 bits. */
if ((bits = (MIN (HOST_BITS_PER_WIDE_INT, GET_MODE_SIZE (mode) * 8)
- - floor_log2 (c) - 1)) > 0)
+ - floor_log2 (c) - 1 - (HOST_BITS_PER_WIDE_INT < 64))) > 0)
for (; bits > 0; bits--)
if ((temp = alpha_emit_set_const (subtarget, mode,
c << bits, i)) != 0
@@ -829,6 +1275,1132 @@ alpha_emit_set_const (target, mode, c, n)
return 0;
}
+
+/* Having failed to find a 3 insn sequence in alpha_emit_set_const,
+ fall back to a straight forward decomposition. We do this to avoid
+ exponential run times encountered when looking for longer sequences
+ with alpha_emit_set_const. */
+
+rtx
+alpha_emit_set_long_const (target, c1, c2)
+ rtx target;
+ HOST_WIDE_INT c1, c2;
+{
+ HOST_WIDE_INT d1, d2, d3, d4;
+
+ /* Decompose the entire word */
+#if HOST_BITS_PER_WIDE_INT >= 64
+ if (c2 != -(c1 < 0))
+ abort ();
+ d1 = ((c1 & 0xffff) ^ 0x8000) - 0x8000;
+ c1 -= d1;
+ d2 = ((c1 & 0xffffffff) ^ 0x80000000) - 0x80000000;
+ c1 = (c1 - d2) >> 32;
+ d3 = ((c1 & 0xffff) ^ 0x8000) - 0x8000;
+ c1 -= d3;
+ d4 = ((c1 & 0xffffffff) ^ 0x80000000) - 0x80000000;
+ if (c1 != d4)
+ abort ();
+#else
+ d1 = ((c1 & 0xffff) ^ 0x8000) - 0x8000;
+ c1 -= d1;
+ d2 = ((c1 & 0xffffffff) ^ 0x80000000) - 0x80000000;
+ if (c1 != d2)
+ abort ();
+ c2 += (d2 < 0);
+ d3 = ((c2 & 0xffff) ^ 0x8000) - 0x8000;
+ c2 -= d3;
+ d4 = ((c2 & 0xffffffff) ^ 0x80000000) - 0x80000000;
+ if (c2 != d4)
+ abort ();
+#endif
+
+ /* Construct the high word */
+ if (d4)
+ {
+ emit_move_insn (target, GEN_INT (d4));
+ if (d3)
+ emit_move_insn (target, gen_rtx_PLUS (DImode, target, GEN_INT (d3)));
+ }
+ else
+ emit_move_insn (target, GEN_INT (d3));
+
+ /* Shift it into place */
+ emit_move_insn (target, gen_rtx_ASHIFT (DImode, target, GEN_INT (32)));
+
+ /* Add in the low bits. */
+ if (d2)
+ emit_move_insn (target, gen_rtx_PLUS (DImode, target, GEN_INT (d2)));
+ if (d1)
+ emit_move_insn (target, gen_rtx_PLUS (DImode, target, GEN_INT (d1)));
+
+ return target;
+}
+
+/* Generate the comparison for a conditional branch. */
+
+rtx
+alpha_emit_conditional_branch (code)
+ enum rtx_code code;
+{
+ enum rtx_code cmp_code, branch_code;
+ enum machine_mode cmp_mode, branch_mode = VOIDmode;
+ rtx op0 = alpha_compare_op0, op1 = alpha_compare_op1;
+ rtx tem;
+
+ /* The general case: fold the comparison code to the types of compares
+ that we have, choosing the branch as necessary. */
+ switch (code)
+ {
+ case EQ: case LE: case LT: case LEU: case LTU:
+ /* We have these compares: */
+ cmp_code = code, branch_code = NE;
+ break;
+
+ case NE:
+ /* This must be reversed. */
+ cmp_code = EQ, branch_code = EQ;
+ break;
+
+ case GE: case GT: case GEU: case GTU:
+ /* For FP, we swap them, for INT, we reverse them. */
+ if (alpha_compare_fp_p)
+ {
+ cmp_code = swap_condition (code);
+ branch_code = NE;
+ tem = op0, op0 = op1, op1 = tem;
+ }
+ else
+ {
+ cmp_code = reverse_condition (code);
+ branch_code = EQ;
+ }
+ break;
+
+ default:
+ abort ();
+ }
+
+ if (alpha_compare_fp_p)
+ {
+ cmp_mode = DFmode;
+ if (flag_fast_math)
+ {
+ /* When we are not as concerned about non-finite values, and we
+ are comparing against zero, we can branch directly. */
+ if (op1 == CONST0_RTX (DFmode))
+ cmp_code = NIL, branch_code = code;
+ else if (op0 == CONST0_RTX (DFmode))
+ {
+ /* Undo the swap we probably did just above. */
+ tem = op0, op0 = op1, op1 = tem;
+ branch_code = swap_condition (cmp_code);
+ cmp_code = NIL;
+ }
+ }
+ else
+ {
+ /* ??? We mark the the branch mode to be CCmode to prevent the
+ compare and branch from being combined, since the compare
+ insn follows IEEE rules that the branch does not. */
+ branch_mode = CCmode;
+ }
+ }
+ else
+ {
+ cmp_mode = DImode;
+
+ /* The following optimizations are only for signed compares. */
+ if (code != LEU && code != LTU && code != GEU && code != GTU)
+ {
+ /* Whee. Compare and branch against 0 directly. */
+ if (op1 == const0_rtx)
+ cmp_code = NIL, branch_code = code;
+
+ /* We want to use cmpcc/bcc when we can, since there is a zero delay
+ bypass between logicals and br/cmov on EV5. But we don't want to
+ force valid immediate constants into registers needlessly. */
+ else if (GET_CODE (op1) == CONST_INT)
+ {
+ HOST_WIDE_INT v = INTVAL (op1), n = -v;
+
+ if (! CONST_OK_FOR_LETTER_P (v, 'I')
+ && (CONST_OK_FOR_LETTER_P (n, 'K')
+ || CONST_OK_FOR_LETTER_P (n, 'L')))
+ {
+ cmp_code = PLUS, branch_code = code;
+ op1 = GEN_INT (n);
+ }
+ }
+ }
+ }
+
+ /* Force op0 into a register. */
+ if (GET_CODE (op0) != REG)
+ op0 = force_reg (cmp_mode, op0);
+
+ /* Emit an initial compare instruction, if necessary. */
+ tem = op0;
+ if (cmp_code != NIL)
+ {
+ tem = gen_reg_rtx (cmp_mode);
+ emit_move_insn (tem, gen_rtx_fmt_ee (cmp_code, cmp_mode, op0, op1));
+ }
+
+ /* Return the branch comparison. */
+ return gen_rtx_fmt_ee (branch_code, branch_mode, tem, CONST0_RTX (cmp_mode));
+}
+
+
+/* Rewrite a comparison against zero CMP of the form
+ (CODE (cc0) (const_int 0)) so it can be written validly in
+ a conditional move (if_then_else CMP ...).
+ If both of the operands that set cc0 are non-zero we must emit
+ an insn to perform the compare (it can't be done within
+ the conditional move). */
+rtx
+alpha_emit_conditional_move (cmp, mode)
+ rtx cmp;
+ enum machine_mode mode;
+{
+ enum rtx_code code = GET_CODE (cmp);
+ enum rtx_code cmov_code = NE;
+ rtx op0 = alpha_compare_op0;
+ rtx op1 = alpha_compare_op1;
+ enum machine_mode cmp_mode
+ = (GET_MODE (op0) == VOIDmode ? DImode : GET_MODE (op0));
+ enum machine_mode cmp_op_mode = alpha_compare_fp_p ? DFmode : DImode;
+ enum machine_mode cmov_mode = VOIDmode;
+ rtx tem;
+
+ if (alpha_compare_fp_p != FLOAT_MODE_P (mode))
+ return 0;
+
+ /* We may be able to use a conditional move directly.
+ This avoids emitting spurious compares. */
+ if (signed_comparison_operator (cmp, cmp_op_mode)
+ && (!alpha_compare_fp_p || flag_fast_math)
+ && (op0 == CONST0_RTX (cmp_mode) || op1 == CONST0_RTX (cmp_mode)))
+ return gen_rtx_fmt_ee (code, VOIDmode, op0, op1);
+
+ /* We can't put the comparison insides a conditional move;
+ emit a compare instruction and put that inside the
+ conditional move. Make sure we emit only comparisons we have;
+ swap or reverse as necessary. */
+
+ switch (code)
+ {
+ case EQ: case LE: case LT: case LEU: case LTU:
+ /* We have these compares: */
+ break;
+
+ case NE:
+ /* This must be reversed. */
+ code = reverse_condition (code);
+ cmov_code = EQ;
+ break;
+
+ case GE: case GT: case GEU: case GTU:
+ /* These must be swapped. Make sure the new first operand is in
+ a register. */
+ code = swap_condition (code);
+ tem = op0, op0 = op1, op1 = tem;
+ op0 = force_reg (cmp_mode, op0);
+ break;
+
+ default:
+ abort ();
+ }
+
+ /* ??? We mark the branch mode to be CCmode to prevent the compare
+ and cmov from being combined, since the compare insn follows IEEE
+ rules that the cmov does not. */
+ if (alpha_compare_fp_p && !flag_fast_math)
+ cmov_mode = CCmode;
+
+ tem = gen_reg_rtx (cmp_op_mode);
+ emit_move_insn (tem, gen_rtx_fmt_ee (code, cmp_op_mode, op0, op1));
+ return gen_rtx_fmt_ee (cmov_code, cmov_mode, tem, CONST0_RTX (cmp_op_mode));
+}
+
+/* Use ext[wlq][lh] as the Architecture Handbook describes for extracting
+ unaligned data:
+
+ unsigned: signed:
+ word: ldq_u r1,X(r11) ldq_u r1,X(r11)
+ ldq_u r2,X+1(r11) ldq_u r2,X+1(r11)
+ lda r3,X(r11) lda r3,X+2(r11)
+ extwl r1,r3,r1 extql r1,r3,r1
+ extwh r2,r3,r2 extqh r2,r3,r2
+ or r1.r2.r1 or r1,r2,r1
+ sra r1,48,r1
+
+ long: ldq_u r1,X(r11) ldq_u r1,X(r11)
+ ldq_u r2,X+3(r11) ldq_u r2,X+3(r11)
+ lda r3,X(r11) lda r3,X(r11)
+ extll r1,r3,r1 extll r1,r3,r1
+ extlh r2,r3,r2 extlh r2,r3,r2
+ or r1.r2.r1 addl r1,r2,r1
+
+ quad: ldq_u r1,X(r11)
+ ldq_u r2,X+7(r11)
+ lda r3,X(r11)
+ extql r1,r3,r1
+ extqh r2,r3,r2
+ or r1.r2.r1
+*/
+
+void
+alpha_expand_unaligned_load (tgt, mem, size, ofs, sign)
+ rtx tgt, mem;
+ HOST_WIDE_INT size, ofs;
+ int sign;
+{
+ rtx meml, memh, addr, extl, exth;
+ enum machine_mode mode;
+
+ meml = gen_reg_rtx (DImode);
+ memh = gen_reg_rtx (DImode);
+ addr = gen_reg_rtx (DImode);
+ extl = gen_reg_rtx (DImode);
+ exth = gen_reg_rtx (DImode);
+
+ emit_move_insn (meml,
+ change_address (mem, DImode,
+ gen_rtx_AND (DImode,
+ plus_constant (XEXP (mem, 0),
+ ofs),
+ GEN_INT (-8))));
+
+ emit_move_insn (memh,
+ change_address (mem, DImode,
+ gen_rtx_AND (DImode,
+ plus_constant (XEXP (mem, 0),
+ ofs + size - 1),
+ GEN_INT (-8))));
+
+ if (sign && size == 2)
+ {
+ emit_move_insn (addr, plus_constant (XEXP (mem, 0), ofs+2));
+
+ emit_insn (gen_extxl (extl, meml, GEN_INT (64), addr));
+ emit_insn (gen_extqh (exth, memh, addr));
+
+ /* We must use tgt here for the target. Alpha-vms port fails if we use
+ addr for the target, because addr is marked as a pointer and combine
+ knows that pointers are always sign-extended 32 bit values. */
+ addr = expand_binop (DImode, ior_optab, extl, exth, tgt, 1, OPTAB_WIDEN);
+ addr = expand_binop (DImode, ashr_optab, addr, GEN_INT (48),
+ addr, 1, OPTAB_WIDEN);
+ }
+ else
+ {
+ emit_move_insn (addr, plus_constant (XEXP (mem, 0), ofs));
+ emit_insn (gen_extxl (extl, meml, GEN_INT (size*8), addr));
+ switch (size)
+ {
+ case 2:
+ emit_insn (gen_extwh (exth, memh, addr));
+ mode = HImode;
+ break;
+
+ case 4:
+ emit_insn (gen_extlh (exth, memh, addr));
+ mode = SImode;
+ break;
+
+ case 8:
+ emit_insn (gen_extqh (exth, memh, addr));
+ mode = DImode;
+ break;
+ default:
+ abort();
+ }
+
+ addr = expand_binop (mode, ior_optab, gen_lowpart (mode, extl),
+ gen_lowpart (mode, exth), gen_lowpart (mode, tgt),
+ sign, OPTAB_WIDEN);
+ }
+
+ if (addr != tgt)
+ emit_move_insn (tgt, gen_lowpart(GET_MODE (tgt), addr));
+}
+
+/* Similarly, use ins and msk instructions to perform unaligned stores. */
+
+void
+alpha_expand_unaligned_store (dst, src, size, ofs)
+ rtx dst, src;
+ HOST_WIDE_INT size, ofs;
+{
+ rtx dstl, dsth, addr, insl, insh, meml, memh;
+
+ dstl = gen_reg_rtx (DImode);
+ dsth = gen_reg_rtx (DImode);
+ insl = gen_reg_rtx (DImode);
+ insh = gen_reg_rtx (DImode);
+
+ meml = change_address (dst, DImode,
+ gen_rtx_AND (DImode,
+ plus_constant (XEXP (dst, 0), ofs),
+ GEN_INT (-8)));
+ memh = change_address (dst, DImode,
+ gen_rtx_AND (DImode,
+ plus_constant (XEXP (dst, 0),
+ ofs+size-1),
+ GEN_INT (-8)));
+
+ emit_move_insn (dsth, memh);
+ emit_move_insn (dstl, meml);
+ addr = copy_addr_to_reg (plus_constant (XEXP (dst, 0), ofs));
+
+ if (src != const0_rtx)
+ {
+ emit_insn (gen_insxh (insh, gen_lowpart (DImode, src),
+ GEN_INT (size*8), addr));
+
+ switch (size)
+ {
+ case 2:
+ emit_insn (gen_inswl (insl, gen_lowpart (HImode, src), addr));
+ break;
+ case 4:
+ emit_insn (gen_insll (insl, gen_lowpart (SImode, src), addr));
+ break;
+ case 8:
+ emit_insn (gen_insql (insl, src, addr));
+ break;
+ }
+ }
+
+ emit_insn (gen_mskxh (dsth, dsth, GEN_INT (size*8), addr));
+
+ switch (size)
+ {
+ case 2:
+ emit_insn (gen_mskxl (dstl, dstl, GEN_INT (0xffff), addr));
+ break;
+ case 4:
+ emit_insn (gen_mskxl (dstl, dstl, GEN_INT (0xffffffff), addr));
+ break;
+ case 8:
+ {
+#if HOST_BITS_PER_WIDE_INT == 32
+ rtx msk = immed_double_const (0xffffffff, 0xffffffff, DImode);
+#else
+ rtx msk = immed_double_const (0xffffffffffffffff, 0, DImode);
+#endif
+ emit_insn (gen_mskxl (dstl, dstl, msk, addr));
+ }
+ break;
+ }
+
+ if (src != const0_rtx)
+ {
+ dsth = expand_binop (DImode, ior_optab, insh, dsth, dsth, 0, OPTAB_WIDEN);
+ dstl = expand_binop (DImode, ior_optab, insl, dstl, dstl, 0, OPTAB_WIDEN);
+ }
+
+ /* Must store high before low for degenerate case of aligned. */
+ emit_move_insn (memh, dsth);
+ emit_move_insn (meml, dstl);
+}
+
+/* The block move code tries to maximize speed by separating loads and
+ stores at the expense of register pressure: we load all of the data
+ before we store it back out. There are two secondary effects worth
+ mentioning, that this speeds copying to/from aligned and unaligned
+ buffers, and that it makes the code significantly easier to write. */
+
+#define MAX_MOVE_WORDS 8
+
+/* Load an integral number of consecutive unaligned quadwords. */
+
+static void
+alpha_expand_unaligned_load_words (out_regs, smem, words, ofs)
+ rtx *out_regs;
+ rtx smem;
+ HOST_WIDE_INT words, ofs;
+{
+ rtx const im8 = GEN_INT (-8);
+ rtx const i64 = GEN_INT (64);
+ rtx ext_tmps[MAX_MOVE_WORDS], data_regs[MAX_MOVE_WORDS+1];
+ rtx sreg, areg;
+ HOST_WIDE_INT i;
+
+ /* Generate all the tmp registers we need. */
+ for (i = 0; i < words; ++i)
+ {
+ data_regs[i] = out_regs[i];
+ ext_tmps[i] = gen_reg_rtx (DImode);
+ }
+ data_regs[words] = gen_reg_rtx (DImode);
+
+ if (ofs != 0)
+ smem = change_address (smem, GET_MODE (smem),
+ plus_constant (XEXP (smem, 0), ofs));
+
+ /* Load up all of the source data. */
+ for (i = 0; i < words; ++i)
+ {
+ emit_move_insn (data_regs[i],
+ change_address (smem, DImode,
+ gen_rtx_AND (DImode,
+ plus_constant (XEXP(smem,0),
+ 8*i),
+ im8)));
+ }
+ emit_move_insn (data_regs[words],
+ change_address (smem, DImode,
+ gen_rtx_AND (DImode,
+ plus_constant (XEXP(smem,0),
+ 8*words - 1),
+ im8)));
+
+ /* Extract the half-word fragments. Unfortunately DEC decided to make
+ extxh with offset zero a noop instead of zeroing the register, so
+ we must take care of that edge condition ourselves with cmov. */
+
+ sreg = copy_addr_to_reg (XEXP (smem, 0));
+ areg = expand_binop (DImode, and_optab, sreg, GEN_INT (7), NULL,
+ 1, OPTAB_WIDEN);
+ for (i = 0; i < words; ++i)
+ {
+ emit_insn (gen_extxl (data_regs[i], data_regs[i], i64, sreg));
+
+ emit_insn (gen_extqh (ext_tmps[i], data_regs[i+1], sreg));
+ emit_insn (gen_rtx_SET (VOIDmode, ext_tmps[i],
+ gen_rtx_IF_THEN_ELSE (DImode,
+ gen_rtx_EQ (DImode, areg,
+ const0_rtx),
+ const0_rtx, ext_tmps[i])));
+ }
+
+ /* Merge the half-words into whole words. */
+ for (i = 0; i < words; ++i)
+ {
+ out_regs[i] = expand_binop (DImode, ior_optab, data_regs[i],
+ ext_tmps[i], data_regs[i], 1, OPTAB_WIDEN);
+ }
+}
+
+/* Store an integral number of consecutive unaligned quadwords. DATA_REGS
+ may be NULL to store zeros. */
+
+static void
+alpha_expand_unaligned_store_words (data_regs, dmem, words, ofs)
+ rtx *data_regs;
+ rtx dmem;
+ HOST_WIDE_INT words, ofs;
+{
+ rtx const im8 = GEN_INT (-8);
+ rtx const i64 = GEN_INT (64);
+#if HOST_BITS_PER_WIDE_INT == 32
+ rtx const im1 = immed_double_const (0xffffffff, 0xffffffff, DImode);
+#else
+ rtx const im1 = immed_double_const (0xffffffffffffffff, 0, DImode);
+#endif
+ rtx ins_tmps[MAX_MOVE_WORDS];
+ rtx st_tmp_1, st_tmp_2, dreg;
+ rtx st_addr_1, st_addr_2;
+ HOST_WIDE_INT i;
+
+ /* Generate all the tmp registers we need. */
+ if (data_regs != NULL)
+ for (i = 0; i < words; ++i)
+ ins_tmps[i] = gen_reg_rtx(DImode);
+ st_tmp_1 = gen_reg_rtx(DImode);
+ st_tmp_2 = gen_reg_rtx(DImode);
+
+ if (ofs != 0)
+ dmem = change_address (dmem, GET_MODE (dmem),
+ plus_constant (XEXP (dmem, 0), ofs));
+
+
+ st_addr_2 = change_address (dmem, DImode,
+ gen_rtx_AND (DImode,
+ plus_constant (XEXP(dmem,0),
+ words*8 - 1),
+ im8));
+ st_addr_1 = change_address (dmem, DImode,
+ gen_rtx_AND (DImode,
+ XEXP (dmem, 0),
+ im8));
+
+ /* Load up the destination end bits. */
+ emit_move_insn (st_tmp_2, st_addr_2);
+ emit_move_insn (st_tmp_1, st_addr_1);
+
+ /* Shift the input data into place. */
+ dreg = copy_addr_to_reg (XEXP (dmem, 0));
+ if (data_regs != NULL)
+ {
+ for (i = words-1; i >= 0; --i)
+ {
+ emit_insn (gen_insxh (ins_tmps[i], data_regs[i], i64, dreg));
+ emit_insn (gen_insql (data_regs[i], data_regs[i], dreg));
+ }
+ for (i = words-1; i > 0; --i)
+ {
+ ins_tmps[i-1] = expand_binop (DImode, ior_optab, data_regs[i],
+ ins_tmps[i-1], ins_tmps[i-1], 1,
+ OPTAB_WIDEN);
+ }
+ }
+
+ /* Split and merge the ends with the destination data. */
+ emit_insn (gen_mskxh (st_tmp_2, st_tmp_2, i64, dreg));
+ emit_insn (gen_mskxl (st_tmp_1, st_tmp_1, im1, dreg));
+
+ if (data_regs != NULL)
+ {
+ st_tmp_2 = expand_binop (DImode, ior_optab, st_tmp_2, ins_tmps[words-1],
+ st_tmp_2, 1, OPTAB_WIDEN);
+ st_tmp_1 = expand_binop (DImode, ior_optab, st_tmp_1, data_regs[0],
+ st_tmp_1, 1, OPTAB_WIDEN);
+ }
+
+ /* Store it all. */
+ emit_move_insn (st_addr_2, st_tmp_2);
+ for (i = words-1; i > 0; --i)
+ {
+ emit_move_insn (change_address (dmem, DImode,
+ gen_rtx_AND (DImode,
+ plus_constant(XEXP (dmem,0),
+ i*8),
+ im8)),
+ data_regs ? ins_tmps[i-1] : const0_rtx);
+ }
+ emit_move_insn (st_addr_1, st_tmp_1);
+}
+
+
+/* Expand string/block move operations.
+
+ operands[0] is the pointer to the destination.
+ operands[1] is the pointer to the source.
+ operands[2] is the number of bytes to move.
+ operands[3] is the alignment. */
+
+int
+alpha_expand_block_move (operands)
+ rtx operands[];
+{
+ rtx bytes_rtx = operands[2];
+ rtx align_rtx = operands[3];
+ HOST_WIDE_INT orig_bytes = INTVAL (bytes_rtx);
+ HOST_WIDE_INT bytes = orig_bytes;
+ HOST_WIDE_INT src_align = INTVAL (align_rtx);
+ HOST_WIDE_INT dst_align = src_align;
+ rtx orig_src = operands[1];
+ rtx orig_dst = operands[0];
+ rtx data_regs[2*MAX_MOVE_WORDS+16];
+ rtx tmp;
+ int i, words, ofs, nregs = 0;
+
+ if (bytes <= 0)
+ return 1;
+ if (bytes > MAX_MOVE_WORDS*8)
+ return 0;
+
+ /* Look for additional alignment information from recorded register info. */
+
+ tmp = XEXP (orig_src, 0);
+ if (GET_CODE (tmp) == REG)
+ {
+ if (REGNO_POINTER_ALIGN (REGNO (tmp)) > src_align)
+ src_align = REGNO_POINTER_ALIGN (REGNO (tmp));
+ }
+ else if (GET_CODE (tmp) == PLUS
+ && GET_CODE (XEXP (tmp, 0)) == REG
+ && GET_CODE (XEXP (tmp, 1)) == CONST_INT)
+ {
+ HOST_WIDE_INT c = INTVAL (XEXP (tmp, 1));
+ int a = REGNO_POINTER_ALIGN (REGNO (XEXP (tmp, 0)));
+
+ if (a > src_align)
+ {
+ if (a >= 8 && c % 8 == 0)
+ src_align = 8;
+ else if (a >= 4 && c % 4 == 0)
+ src_align = 4;
+ else if (a >= 2 && c % 2 == 0)
+ src_align = 2;
+ }
+ }
+
+ tmp = XEXP (orig_dst, 0);
+ if (GET_CODE (tmp) == REG)
+ {
+ if (REGNO_POINTER_ALIGN (REGNO (tmp)) > dst_align)
+ dst_align = REGNO_POINTER_ALIGN (REGNO (tmp));
+ }
+ else if (GET_CODE (tmp) == PLUS
+ && GET_CODE (XEXP (tmp, 0)) == REG
+ && GET_CODE (XEXP (tmp, 1)) == CONST_INT)
+ {
+ HOST_WIDE_INT c = INTVAL (XEXP (tmp, 1));
+ int a = REGNO_POINTER_ALIGN (REGNO (XEXP (tmp, 0)));
+
+ if (a > dst_align)
+ {
+ if (a >= 8 && c % 8 == 0)
+ dst_align = 8;
+ else if (a >= 4 && c % 4 == 0)
+ dst_align = 4;
+ else if (a >= 2 && c % 2 == 0)
+ dst_align = 2;
+ }
+ }
+
+ /*
+ * Load the entire block into registers.
+ */
+
+ if (GET_CODE (XEXP (orig_src, 0)) == ADDRESSOF)
+ {
+ enum machine_mode mode;
+ tmp = XEXP (XEXP (orig_src, 0), 0);
+
+ /* Don't use the existing register if we're reading more than
+ is held in the register. Nor if there is not a mode that
+ handles the exact size. */
+ mode = mode_for_size (bytes * BITS_PER_UNIT, MODE_INT, 1);
+ if (mode != BLKmode
+ && GET_MODE_SIZE (GET_MODE (tmp)) >= bytes)
+ {
+ if (mode == TImode)
+ {
+ data_regs[nregs] = gen_lowpart (DImode, tmp);
+ data_regs[nregs+1] = gen_highpart (DImode, tmp);
+ nregs += 2;
+ }
+ else
+ data_regs[nregs++] = gen_lowpart (mode, tmp);
+ goto src_done;
+ }
+
+ /* No appropriate mode; fall back on memory. */
+ orig_src = change_address (orig_src, GET_MODE (orig_src),
+ copy_addr_to_reg (XEXP (orig_src, 0)));
+ }
+
+ ofs = 0;
+ if (src_align >= 8 && bytes >= 8)
+ {
+ words = bytes / 8;
+
+ for (i = 0; i < words; ++i)
+ data_regs[nregs+i] = gen_reg_rtx(DImode);
+
+ for (i = 0; i < words; ++i)
+ {
+ emit_move_insn (data_regs[nregs+i],
+ change_address (orig_src, DImode,
+ plus_constant (XEXP (orig_src, 0),
+ ofs + i*8)));
+ }
+
+ nregs += words;
+ bytes -= words * 8;
+ ofs += words * 8;
+ }
+ if (src_align >= 4 && bytes >= 4)
+ {
+ words = bytes / 4;
+
+ for (i = 0; i < words; ++i)
+ data_regs[nregs+i] = gen_reg_rtx(SImode);
+
+ for (i = 0; i < words; ++i)
+ {
+ emit_move_insn (data_regs[nregs+i],
+ change_address (orig_src, SImode,
+ plus_constant (XEXP (orig_src, 0),
+ ofs + i*4)));
+ }
+
+ nregs += words;
+ bytes -= words * 4;
+ ofs += words * 4;
+ }
+ if (bytes >= 16)
+ {
+ words = bytes / 8;
+
+ for (i = 0; i < words+1; ++i)
+ data_regs[nregs+i] = gen_reg_rtx(DImode);
+
+ alpha_expand_unaligned_load_words (data_regs + nregs, orig_src,
+ words, ofs);
+
+ nregs += words;
+ bytes -= words * 8;
+ ofs += words * 8;
+ }
+ if (!TARGET_BWX && bytes >= 8)
+ {
+ data_regs[nregs++] = tmp = gen_reg_rtx (DImode);
+ alpha_expand_unaligned_load (tmp, orig_src, 8, ofs, 0);
+ bytes -= 8;
+ ofs += 8;
+ }
+ if (!TARGET_BWX && bytes >= 4)
+ {
+ data_regs[nregs++] = tmp = gen_reg_rtx (SImode);
+ alpha_expand_unaligned_load (tmp, orig_src, 4, ofs, 0);
+ bytes -= 4;
+ ofs += 4;
+ }
+ if (bytes >= 2)
+ {
+ if (src_align >= 2)
+ {
+ do {
+ data_regs[nregs++] = tmp = gen_reg_rtx (HImode);
+ emit_move_insn (tmp,
+ change_address (orig_src, HImode,
+ plus_constant (XEXP (orig_src, 0),
+ ofs)));
+ bytes -= 2;
+ ofs += 2;
+ } while (bytes >= 2);
+ }
+ else if (!TARGET_BWX)
+ {
+ data_regs[nregs++] = tmp = gen_reg_rtx (HImode);
+ alpha_expand_unaligned_load (tmp, orig_src, 2, ofs, 0);
+ bytes -= 2;
+ ofs += 2;
+ }
+ }
+ while (bytes > 0)
+ {
+ data_regs[nregs++] = tmp = gen_reg_rtx (QImode);
+ emit_move_insn (tmp,
+ change_address (orig_src, QImode,
+ plus_constant (XEXP (orig_src, 0),
+ ofs)));
+ bytes -= 1;
+ ofs += 1;
+ }
+ src_done:
+
+ if (nregs > (int)(sizeof(data_regs)/sizeof(*data_regs)))
+ abort();
+
+ /*
+ * Now save it back out again.
+ */
+
+ i = 0, ofs = 0;
+
+ if (GET_CODE (XEXP (orig_dst, 0)) == ADDRESSOF)
+ {
+ enum machine_mode mode;
+ tmp = XEXP (XEXP (orig_dst, 0), 0);
+
+ mode = mode_for_size (orig_bytes * BITS_PER_UNIT, MODE_INT, 1);
+ if (GET_MODE (tmp) == mode)
+ {
+ if (nregs == 1)
+ {
+ emit_move_insn (tmp, data_regs[0]);
+ i = 1;
+ goto dst_done;
+ }
+ else if (nregs == 2 && mode == TImode)
+ {
+ /* Undo the subregging done above when copying between
+ two TImode registers. */
+ if (GET_CODE (data_regs[0]) == SUBREG
+ && GET_MODE (SUBREG_REG (data_regs[0])) == TImode)
+ {
+ emit_move_insn (tmp, SUBREG_REG (data_regs[0]));
+ }
+ else
+ {
+ rtx seq;
+
+ start_sequence ();
+ emit_move_insn (gen_lowpart (DImode, tmp), data_regs[0]);
+ emit_move_insn (gen_highpart (DImode, tmp), data_regs[1]);
+ seq = get_insns ();
+ end_sequence ();
+
+ emit_no_conflict_block (seq, tmp, data_regs[0],
+ data_regs[1], NULL_RTX);
+ }
+
+ i = 2;
+ goto dst_done;
+ }
+ }
+
+ /* ??? If nregs > 1, consider reconstructing the word in regs. */
+ /* ??? Optimize mode < dst_mode with strict_low_part. */
+
+ /* No appropriate mode; fall back on memory. We can speed things
+ up by recognizing extra alignment information. */
+ orig_dst = change_address (orig_dst, GET_MODE (orig_dst),
+ copy_addr_to_reg (XEXP (orig_dst, 0)));
+ dst_align = GET_MODE_SIZE (GET_MODE (tmp));
+ }
+
+ /* Write out the data in whatever chunks reading the source allowed. */
+ if (dst_align >= 8)
+ {
+ while (i < nregs && GET_MODE (data_regs[i]) == DImode)
+ {
+ emit_move_insn (change_address (orig_dst, DImode,
+ plus_constant (XEXP (orig_dst, 0),
+ ofs)),
+ data_regs[i]);
+ ofs += 8;
+ i++;
+ }
+ }
+ if (dst_align >= 4)
+ {
+ /* If the source has remaining DImode regs, write them out in
+ two pieces. */
+ while (i < nregs && GET_MODE (data_regs[i]) == DImode)
+ {
+ tmp = expand_binop (DImode, lshr_optab, data_regs[i], GEN_INT (32),
+ NULL_RTX, 1, OPTAB_WIDEN);
+
+ emit_move_insn (change_address (orig_dst, SImode,
+ plus_constant (XEXP (orig_dst, 0),
+ ofs)),
+ gen_lowpart (SImode, data_regs[i]));
+ emit_move_insn (change_address (orig_dst, SImode,
+ plus_constant (XEXP (orig_dst, 0),
+ ofs+4)),
+ gen_lowpart (SImode, tmp));
+ ofs += 8;
+ i++;
+ }
+
+ while (i < nregs && GET_MODE (data_regs[i]) == SImode)
+ {
+ emit_move_insn (change_address(orig_dst, SImode,
+ plus_constant (XEXP (orig_dst, 0),
+ ofs)),
+ data_regs[i]);
+ ofs += 4;
+ i++;
+ }
+ }
+ if (i < nregs && GET_MODE (data_regs[i]) == DImode)
+ {
+ /* Write out a remaining block of words using unaligned methods. */
+
+ for (words = 1; i+words < nregs ; ++words)
+ if (GET_MODE (data_regs[i+words]) != DImode)
+ break;
+
+ if (words == 1)
+ alpha_expand_unaligned_store (orig_dst, data_regs[i], 8, ofs);
+ else
+ alpha_expand_unaligned_store_words (data_regs+i, orig_dst, words, ofs);
+
+ i += words;
+ ofs += words * 8;
+ }
+
+ /* Due to the above, this won't be aligned. */
+ /* ??? If we have more than one of these, consider constructing full
+ words in registers and using alpha_expand_unaligned_store_words. */
+ while (i < nregs && GET_MODE (data_regs[i]) == SImode)
+ {
+ alpha_expand_unaligned_store (orig_dst, data_regs[i], 4, ofs);
+ ofs += 4;
+ i++;
+ }
+
+ if (dst_align >= 2)
+ while (i < nregs && GET_MODE (data_regs[i]) == HImode)
+ {
+ emit_move_insn (change_address (orig_dst, HImode,
+ plus_constant (XEXP (orig_dst, 0),
+ ofs)),
+ data_regs[i]);
+ i++;
+ ofs += 2;
+ }
+ else
+ while (i < nregs && GET_MODE (data_regs[i]) == HImode)
+ {
+ alpha_expand_unaligned_store (orig_dst, data_regs[i], 2, ofs);
+ i++;
+ ofs += 2;
+ }
+ while (i < nregs && GET_MODE (data_regs[i]) == QImode)
+ {
+ emit_move_insn (change_address (orig_dst, QImode,
+ plus_constant (XEXP (orig_dst, 0),
+ ofs)),
+ data_regs[i]);
+ i++;
+ ofs += 1;
+ }
+ dst_done:
+
+ if (i != nregs)
+ abort();
+
+ return 1;
+}
+
+int
+alpha_expand_block_clear (operands)
+ rtx operands[];
+{
+ rtx bytes_rtx = operands[1];
+ rtx align_rtx = operands[2];
+ HOST_WIDE_INT bytes = INTVAL (bytes_rtx);
+ HOST_WIDE_INT align = INTVAL (align_rtx);
+ rtx orig_dst = operands[0];
+ rtx tmp;
+ HOST_WIDE_INT i, words, ofs = 0;
+
+ if (bytes <= 0)
+ return 1;
+ if (bytes > MAX_MOVE_WORDS*8)
+ return 0;
+
+ /* Look for stricter alignment. */
+
+ tmp = XEXP (orig_dst, 0);
+ if (GET_CODE (tmp) == REG)
+ {
+ if (REGNO_POINTER_ALIGN (REGNO (tmp)) > align)
+ align = REGNO_POINTER_ALIGN (REGNO (tmp));
+ }
+ else if (GET_CODE (tmp) == PLUS
+ && GET_CODE (XEXP (tmp, 0)) == REG
+ && GET_CODE (XEXP (tmp, 1)) == CONST_INT)
+ {
+ HOST_WIDE_INT c = INTVAL (XEXP (tmp, 1));
+ int a = REGNO_POINTER_ALIGN (REGNO (XEXP (tmp, 0)));
+
+ if (a > align)
+ {
+ if (a >= 8 && c % 8 == 0)
+ align = 8;
+ else if (a >= 4 && c % 4 == 0)
+ align = 4;
+ else if (a >= 2 && c % 2 == 0)
+ align = 2;
+ }
+ }
+ else if (GET_CODE (tmp) == ADDRESSOF)
+ {
+ enum machine_mode mode;
+
+ mode = mode_for_size (bytes * BITS_PER_UNIT, MODE_INT, 1);
+ if (GET_MODE (XEXP (tmp, 0)) == mode)
+ {
+ emit_move_insn (XEXP (tmp, 0), const0_rtx);
+ return 1;
+ }
+
+ /* No appropriate mode; fall back on memory. */
+ orig_dst = change_address (orig_dst, GET_MODE (orig_dst),
+ copy_addr_to_reg (tmp));
+ align = GET_MODE_SIZE (GET_MODE (XEXP (tmp, 0)));
+ }
+
+ /* Handle a block of contiguous words first. */
+
+ if (align >= 8 && bytes >= 8)
+ {
+ words = bytes / 8;
+
+ for (i = 0; i < words; ++i)
+ {
+ emit_move_insn (change_address(orig_dst, DImode,
+ plus_constant (XEXP (orig_dst, 0),
+ ofs + i*8)),
+ const0_rtx);
+ }
+
+ bytes -= words * 8;
+ ofs += words * 8;
+ }
+ if (align >= 4 && bytes >= 4)
+ {
+ words = bytes / 4;
+
+ for (i = 0; i < words; ++i)
+ {
+ emit_move_insn (change_address (orig_dst, SImode,
+ plus_constant (XEXP (orig_dst, 0),
+ ofs + i*4)),
+ const0_rtx);
+ }
+
+ bytes -= words * 4;
+ ofs += words * 4;
+ }
+ if (bytes >= 16)
+ {
+ words = bytes / 8;
+
+ alpha_expand_unaligned_store_words (NULL, orig_dst, words, ofs);
+
+ bytes -= words * 8;
+ ofs += words * 8;
+ }
+
+ /* Next clean up any trailing pieces. We know from the contiguous
+ block move that there are no aligned SImode or DImode hunks left. */
+
+ if (!TARGET_BWX && bytes >= 8)
+ {
+ alpha_expand_unaligned_store (orig_dst, const0_rtx, 8, ofs);
+ bytes -= 8;
+ ofs += 8;
+ }
+ if (!TARGET_BWX && bytes >= 4)
+ {
+ alpha_expand_unaligned_store (orig_dst, const0_rtx, 4, ofs);
+ bytes -= 4;
+ ofs += 4;
+ }
+ if (bytes >= 2)
+ {
+ if (align >= 2)
+ {
+ do {
+ emit_move_insn (change_address (orig_dst, HImode,
+ plus_constant (XEXP (orig_dst, 0),
+ ofs)),
+ const0_rtx);
+ bytes -= 2;
+ ofs += 2;
+ } while (bytes >= 2);
+ }
+ else if (!TARGET_BWX)
+ {
+ alpha_expand_unaligned_store (orig_dst, const0_rtx, 2, ofs);
+ bytes -= 2;
+ ofs += 2;
+ }
+ }
+ while (bytes > 0)
+ {
+ emit_move_insn (change_address (orig_dst, QImode,
+ plus_constant (XEXP (orig_dst, 0),
+ ofs)),
+ const0_rtx);
+ bytes -= 1;
+ ofs += 1;
+ }
+
+ return 1;
+}
+
/* Adjust the cost of a scheduling dependency. Return the new cost of
a dependency LINK or INSN on DEP_INSN. COST is the current cost. */
@@ -840,7 +2412,8 @@ alpha_adjust_cost (insn, link, dep_insn, cost)
rtx dep_insn;
int cost;
{
- rtx set;
+ rtx set, set_src;
+ enum attr_type insn_type, dep_insn_type;
/* If the dependence is an anti-dependence, there is no cost. For an
output dependence, there is sometimes a cost, but it doesn't seem
@@ -849,60 +2422,225 @@ alpha_adjust_cost (insn, link, dep_insn, cost)
if (REG_NOTE_KIND (link) != 0)
return 0;
- /* If INSN is a store insn and DEP_INSN is setting the data being stored,
- we can sometimes lower the cost. */
+ /* If we can't recognize the insns, we can't really do anything. */
+ if (recog_memoized (insn) < 0 || recog_memoized (dep_insn) < 0)
+ return cost;
- if (recog_memoized (insn) >= 0 && get_attr_type (insn) == TYPE_ST
- && (set = single_set (dep_insn)) != 0
- && GET_CODE (PATTERN (insn)) == SET
- && rtx_equal_p (SET_DEST (set), SET_SRC (PATTERN (insn))))
- switch (get_attr_type (dep_insn))
- {
- case TYPE_LD:
- /* No savings here. */
- return cost;
-
- case TYPE_IMULL:
- case TYPE_IMULQ:
- /* In these cases, we save one cycle. */
- return cost - 2;
-
- default:
- /* In all other cases, we save two cycles. */
- return MAX (0, cost - 4);
- }
+ insn_type = get_attr_type (insn);
+ dep_insn_type = get_attr_type (dep_insn);
- /* Another case that needs adjustment is an arithmetic or logical
- operation. It's cost is usually one cycle, but we default it to
- two in the MD file. The only case that it is actually two is
- for the address in loads and stores. */
+ /* Bring in the user-defined memory latency. */
+ if (dep_insn_type == TYPE_ILD
+ || dep_insn_type == TYPE_FLD
+ || dep_insn_type == TYPE_LDSYM)
+ cost += alpha_memory_latency-1;
- if (recog_memoized (dep_insn) >= 0
- && get_attr_type (dep_insn) == TYPE_IADDLOG)
- switch (get_attr_type (insn))
- {
- case TYPE_LD:
- case TYPE_ST:
- return cost;
+ switch (alpha_cpu)
+ {
+ case PROCESSOR_EV4:
+ /* On EV4, if INSN is a store insn and DEP_INSN is setting the data
+ being stored, we can sometimes lower the cost. */
+
+ if ((insn_type == TYPE_IST || insn_type == TYPE_FST)
+ && (set = single_set (dep_insn)) != 0
+ && GET_CODE (PATTERN (insn)) == SET
+ && rtx_equal_p (SET_DEST (set), SET_SRC (PATTERN (insn))))
+ {
+ switch (dep_insn_type)
+ {
+ case TYPE_ILD:
+ case TYPE_FLD:
+ /* No savings here. */
+ return cost;
+
+ case TYPE_IMUL:
+ /* In these cases, we save one cycle. */
+ return cost - 1;
+
+ default:
+ /* In all other cases, we save two cycles. */
+ return MAX (0, cost - 2);
+ }
+ }
- default:
- return 2;
- }
+ /* Another case that needs adjustment is an arithmetic or logical
+ operation. It's cost is usually one cycle, but we default it to
+ two in the MD file. The only case that it is actually two is
+ for the address in loads, stores, and jumps. */
- /* The final case is when a compare feeds into an integer branch. The cost
- is only one cycle in that case. */
+ if (dep_insn_type == TYPE_IADD || dep_insn_type == TYPE_ILOG)
+ {
+ switch (insn_type)
+ {
+ case TYPE_ILD:
+ case TYPE_IST:
+ case TYPE_FLD:
+ case TYPE_FST:
+ case TYPE_JSR:
+ return cost;
+ default:
+ return 1;
+ }
+ }
- if (recog_memoized (dep_insn) >= 0
- && get_attr_type (dep_insn) == TYPE_ICMP
- && recog_memoized (insn) >= 0
- && get_attr_type (insn) == TYPE_IBR)
- return 2;
+ /* The final case is when a compare feeds into an integer branch;
+ the cost is only one cycle in that case. */
- /* Otherwise, return the default cost. */
+ if (dep_insn_type == TYPE_ICMP && insn_type == TYPE_IBR)
+ return 1;
+ break;
+
+ case PROCESSOR_EV5:
+ /* And the lord DEC saith: "A special bypass provides an effective
+ latency of 0 cycles for an ICMP or ILOG insn producing the test
+ operand of an IBR or ICMOV insn." */
+
+ if ((dep_insn_type == TYPE_ICMP || dep_insn_type == TYPE_ILOG)
+ && (set = single_set (dep_insn)) != 0)
+ {
+ /* A branch only has one input. This must be it. */
+ if (insn_type == TYPE_IBR)
+ return 0;
+ /* A conditional move has three, make sure it is the test. */
+ if (insn_type == TYPE_ICMOV
+ && GET_CODE (set_src = PATTERN (insn)) == SET
+ && GET_CODE (set_src = SET_SRC (set_src)) == IF_THEN_ELSE
+ && rtx_equal_p (SET_DEST (set), XEXP (set_src, 0)))
+ return 0;
+ }
+
+ /* "The multiplier is unable to receive data from IEU bypass paths.
+ The instruction issues at the expected time, but its latency is
+ increased by the time it takes for the input data to become
+ available to the multiplier" -- which happens in pipeline stage
+ six, when results are comitted to the register file. */
+
+ if (insn_type == TYPE_IMUL)
+ {
+ switch (dep_insn_type)
+ {
+ /* These insns produce their results in pipeline stage five. */
+ case TYPE_ILD:
+ case TYPE_ICMOV:
+ case TYPE_IMUL:
+ case TYPE_MVI:
+ return cost + 1;
+
+ /* Other integer insns produce results in pipeline stage four. */
+ default:
+ return cost + 2;
+ }
+ }
+ break;
+ case PROCESSOR_EV6:
+ /* There is additional latency to move the result of (most) FP
+ operations anywhere but the FP register file. */
+
+ if ((insn_type == TYPE_FST || insn_type == TYPE_FTOI)
+ && (dep_insn_type == TYPE_FADD ||
+ dep_insn_type == TYPE_FMUL ||
+ dep_insn_type == TYPE_FCMOV))
+ return cost + 2;
+
+ break;
+ }
+
+ /* Otherwise, return the default cost. */
return cost;
}
+/* Functions to save and restore alpha_return_addr_rtx. */
+
+struct machine_function
+{
+ rtx ra_rtx;
+};
+
+static void
+alpha_save_machine_status (p)
+ struct function *p;
+{
+ struct machine_function *machine =
+ (struct machine_function *) xmalloc (sizeof (struct machine_function));
+
+ p->machine = machine;
+ machine->ra_rtx = alpha_return_addr_rtx;
+}
+
+static void
+alpha_restore_machine_status (p)
+ struct function *p;
+{
+ struct machine_function *machine = p->machine;
+
+ alpha_return_addr_rtx = machine->ra_rtx;
+
+ free (machine);
+ p->machine = (struct machine_function *)0;
+}
+
+/* Do anything needed before RTL is emitted for each function. */
+
+void
+alpha_init_expanders ()
+{
+ alpha_return_addr_rtx = NULL_RTX;
+ alpha_eh_epilogue_sp_ofs = NULL_RTX;
+
+ /* Arrange to save and restore machine status around nested functions. */
+ save_machine_status = alpha_save_machine_status;
+ restore_machine_status = alpha_restore_machine_status;
+}
+
+/* Start the ball rolling with RETURN_ADDR_RTX. */
+
+rtx
+alpha_return_addr (count, frame)
+ int count;
+ rtx frame ATTRIBUTE_UNUSED;
+{
+ rtx init;
+
+ if (count != 0)
+ return const0_rtx;
+
+ if (alpha_return_addr_rtx)
+ return alpha_return_addr_rtx;
+
+ /* No rtx yet. Invent one, and initialize it from $26 in the prologue. */
+ alpha_return_addr_rtx = gen_reg_rtx (Pmode);
+ init = gen_rtx_SET (VOIDmode, alpha_return_addr_rtx,
+ gen_rtx_REG (Pmode, REG_RA));
+
+ /* Emit the insn to the prologue with the other argument copies. */
+ push_topmost_sequence ();
+ emit_insn_after (init, get_insns ());
+ pop_topmost_sequence ();
+
+ return alpha_return_addr_rtx;
+}
+
+static int
+alpha_ra_ever_killed ()
+{
+ rtx top;
+
+#ifdef ASM_OUTPUT_MI_THUNK
+ if (current_function_is_thunk)
+ return 0;
+#endif
+ if (!alpha_return_addr_rtx)
+ return regs_ever_live[REG_RA];
+
+ push_topmost_sequence ();
+ top = get_insns ();
+ pop_topmost_sequence ();
+
+ return reg_set_between_p (gen_rtx_REG (Pmode, REG_RA), top, NULL_RTX);
+}
+
+
/* Print an operand. Recognize special options, documented below. */
void
@@ -915,6 +2653,115 @@ print_operand (file, x, code)
switch (code)
{
+ case '&':
+ /* Generates fp-rounding mode suffix: nothing for normal, 'c' for
+ chopped, 'm' for minus-infinity, and 'd' for dynamic rounding
+ mode. alpha_fprm controls which suffix is generated. */
+ switch (alpha_fprm)
+ {
+ case ALPHA_FPRM_NORM:
+ break;
+ case ALPHA_FPRM_MINF:
+ fputc ('m', file);
+ break;
+ case ALPHA_FPRM_CHOP:
+ fputc ('c', file);
+ break;
+ case ALPHA_FPRM_DYN:
+ fputc ('d', file);
+ break;
+ }
+ break;
+
+ case '\'':
+ /* Generates trap-mode suffix for instructions that accept the su
+ suffix only (cmpt et al). */
+ if (alpha_tp == ALPHA_TP_INSN)
+ fputs ("su", file);
+ break;
+
+ case '`':
+ /* Generates trap-mode suffix for instructions that accept the
+ v and sv suffix. The only instruction that needs this is cvtql. */
+ switch (alpha_fptm)
+ {
+ case ALPHA_FPTM_N:
+ break;
+ case ALPHA_FPTM_U:
+ fputs ("v", file);
+ break;
+ case ALPHA_FPTM_SU:
+ case ALPHA_FPTM_SUI:
+ fputs ("sv", file);
+ break;
+ }
+ break;
+
+ case '(':
+ /* Generates trap-mode suffix for instructions that accept the
+ v, sv, and svi suffix. The only instruction that needs this
+ is cvttq. */
+ switch (alpha_fptm)
+ {
+ case ALPHA_FPTM_N:
+ break;
+ case ALPHA_FPTM_U:
+ fputs ("v", file);
+ break;
+ case ALPHA_FPTM_SU:
+ fputs ("sv", file);
+ break;
+ case ALPHA_FPTM_SUI:
+ fputs ("svi", file);
+ break;
+ }
+ break;
+
+ case ')':
+ /* Generates trap-mode suffix for instructions that accept the u, su,
+ and sui suffix. This is the bulk of the IEEE floating point
+ instructions (addt et al). */
+ switch (alpha_fptm)
+ {
+ case ALPHA_FPTM_N:
+ break;
+ case ALPHA_FPTM_U:
+ fputc ('u', file);
+ break;
+ case ALPHA_FPTM_SU:
+ fputs ("su", file);
+ break;
+ case ALPHA_FPTM_SUI:
+ fputs ("sui", file);
+ break;
+ }
+ break;
+
+ case '+':
+ /* Generates trap-mode suffix for instructions that accept the sui
+ suffix (cvtqt and cvtqs). */
+ switch (alpha_fptm)
+ {
+ case ALPHA_FPTM_N:
+ case ALPHA_FPTM_U:
+ case ALPHA_FPTM_SU: /* cvtqt/cvtqs can't cause underflow */
+ break;
+ case ALPHA_FPTM_SUI:
+ fputs ("sui", file);
+ break;
+ }
+ break;
+
+ case ',':
+ /* Generates single precision instruction suffix. */
+ fprintf (file, "%c", (TARGET_FLOAT_VAX ? 'f' : 's'));
+ break;
+
+ case '-':
+ /* Generates double precision instruction suffix. */
+ fprintf (file, "%c", (TARGET_FLOAT_VAX ? 'g' : 't'));
+ break;
+
case 'r':
/* If this operand is the constant zero, write it as "$31". */
if (GET_CODE (x) == REG)
@@ -942,7 +2789,7 @@ print_operand (file, x, code)
if (GET_CODE (x) != CONST_INT)
output_operand_lossage ("invalid %%N value");
- fprintf (file, "%ld", ~ INTVAL (x));
+ fprintf (file, HOST_WIDE_INT_PRINT_DEC, ~ INTVAL (x));
break;
case 'P':
@@ -950,7 +2797,7 @@ print_operand (file, x, code)
if (GET_CODE (x) != CONST_INT)
output_operand_lossage ("invalid %%P value");
- fprintf (file, "%ld", (HOST_WIDE_INT) 1 << INTVAL (x));
+ fprintf (file, HOST_WIDE_INT_PRINT_DEC, (HOST_WIDE_INT) 1 << INTVAL (x));
break;
case 'h':
@@ -958,7 +2805,7 @@ print_operand (file, x, code)
if (GET_CODE (x) != CONST_INT)
output_operand_lossage ("invalid %%h value");
- fprintf (file, "%ld", INTVAL (x) >> 16);
+ fprintf (file, HOST_WIDE_INT_PRINT_DEC, INTVAL (x) >> 16);
break;
case 'L':
@@ -966,7 +2813,8 @@ print_operand (file, x, code)
if (GET_CODE (x) != CONST_INT)
output_operand_lossage ("invalid %%L value");
- fprintf (file, "%ld", (INTVAL (x) & 0xffff) - 2 * (INTVAL (x) & 0x8000));
+ fprintf (file, HOST_WIDE_INT_PRINT_DEC,
+ (INTVAL (x) & 0xffff) - 2 * (INTVAL (x) & 0x8000));
break;
case 'm':
@@ -988,7 +2836,7 @@ print_operand (file, x, code)
if (value & 0xff)
mask |= (1 << (i + sizeof (int)));
- fprintf (file, "%ld", mask & 0xff);
+ fprintf (file, HOST_WIDE_INT_PRINT_DEC, mask & 0xff);
}
else if (GET_CODE (x) == CONST_INT)
@@ -999,20 +2847,24 @@ print_operand (file, x, code)
if (value & 0xff)
mask |= (1 << i);
- fprintf (file, "%ld", mask);
+ fprintf (file, HOST_WIDE_INT_PRINT_DEC, mask);
}
else
output_operand_lossage ("invalid %%m value");
break;
case 'M':
- /* 'b', 'w', or 'l' as the value of the constant. */
+ /* 'b', 'w', 'l', or 'q' as the value of the constant. */
if (GET_CODE (x) != CONST_INT
- || (INTVAL (x) != 8 && INTVAL (x) != 16 && INTVAL (x) != 32))
+ || (INTVAL (x) != 8 && INTVAL (x) != 16
+ && INTVAL (x) != 32 && INTVAL (x) != 64))
output_operand_lossage ("invalid %%M value");
fprintf (file, "%s",
- INTVAL (x) == 8 ? "b" : INTVAL (x) == 16 ? "w" : "l");
+ (INTVAL (x) == 8 ? "b"
+ : INTVAL (x) == 16 ? "w"
+ : INTVAL (x) == 32 ? "l"
+ : "q"));
break;
case 'U':
@@ -1021,14 +2873,24 @@ print_operand (file, x, code)
fprintf (file, "b");
else if (GET_CODE (x) == CONST_INT && INTVAL (x) == 0xffff)
fprintf (file, "w");
+ else if (GET_CODE (x) == CONST_INT && INTVAL (x) == 0xffffffff)
+ fprintf (file, "l");
#if HOST_BITS_PER_WIDE_INT == 32
else if (GET_CODE (x) == CONST_DOUBLE
&& CONST_DOUBLE_HIGH (x) == 0
&& CONST_DOUBLE_LOW (x) == -1)
fprintf (file, "l");
+ else if (GET_CODE (x) == CONST_DOUBLE
+ && CONST_DOUBLE_HIGH (x) == -1
+ && CONST_DOUBLE_LOW (x) == -1)
+ fprintf (file, "q");
#else
- else if (GET_CODE (x) == CONST_INT && INTVAL (x) == 0xffffffff)
- fprintf (file, "l");
+ else if (GET_CODE (x) == CONST_INT && INTVAL (x) == -1)
+ fprintf (file, "q");
+ else if (GET_CODE (x) == CONST_DOUBLE
+ && CONST_DOUBLE_HIGH (x) == 0
+ && CONST_DOUBLE_LOW (x) == -1)
+ fprintf (file, "q");
#endif
else
output_operand_lossage ("invalid %%U value");
@@ -1041,7 +2903,7 @@ print_operand (file, x, code)
&& (INTVAL (x) & 7) != 8)
output_operand_lossage ("invalid %%s value");
- fprintf (file, "%ld", INTVAL (x) / 8);
+ fprintf (file, HOST_WIDE_INT_PRINT_DEC, INTVAL (x) / 8);
break;
case 'S':
@@ -1052,46 +2914,31 @@ print_operand (file, x, code)
&& (INTVAL (x) & 7) != 8)
output_operand_lossage ("invalid %%s value");
- fprintf (file, "%ld", (64 - INTVAL (x)) / 8);
+ fprintf (file, HOST_WIDE_INT_PRINT_DEC, (64 - INTVAL (x)) / 8);
break;
- case 'C':
+ case 'C': case 'D': case 'c': case 'd':
/* Write out comparison name. */
- if (GET_RTX_CLASS (GET_CODE (x)) != '<')
- output_operand_lossage ("invalid %%C value");
-
- if (GET_CODE (x) == LEU)
- fprintf (file, "ule");
- else if (GET_CODE (x) == LTU)
- fprintf (file, "ult");
- else
- fprintf (file, "%s", GET_RTX_NAME (GET_CODE (x)));
- break;
-
- case 'D':
- /* Similar, but write reversed code. We can't get an unsigned code
- here. */
- if (GET_RTX_CLASS (GET_CODE (x)) != '<')
- output_operand_lossage ("invalid %%D value");
-
- fprintf (file, "%s", GET_RTX_NAME (reverse_condition (GET_CODE (x))));
- break;
-
- case 'c':
- /* Similar to `c', but swap. We can't get unsigned here either. */
- if (GET_RTX_CLASS (GET_CODE (x)) != '<')
- output_operand_lossage ("invalid %%D value");
-
- fprintf (file, "%s", GET_RTX_NAME (swap_condition (GET_CODE (x))));
- break;
-
- case 'd':
- /* Similar, but reverse and swap. We can't get unsigned here either. */
- if (GET_RTX_CLASS (GET_CODE (x)) != '<')
- output_operand_lossage ("invalid %%D value");
-
- fprintf (file, "%s",
- GET_RTX_NAME (swap_condition (reverse_condition ((GET_CODE (x))))));
+ {
+ enum rtx_code c = GET_CODE (x);
+
+ if (GET_RTX_CLASS (c) != '<')
+ output_operand_lossage ("invalid %%C value");
+
+ if (code == 'D')
+ c = reverse_condition (c);
+ else if (code == 'c')
+ c = swap_condition (c);
+ else if (code == 'd')
+ c = swap_condition (reverse_condition (c));
+
+ if (c == LEU)
+ fprintf (file, "ule");
+ else if (c == LTU)
+ fprintf (file, "ult");
+ else
+ fprintf (file, "%s", GET_RTX_NAME (c));
+ }
break;
case 'E':
@@ -1135,6 +2982,100 @@ print_operand (file, x, code)
output_operand_lossage ("invalid %%xn code");
}
}
+
+void
+print_operand_address (file, addr)
+ FILE *file;
+ rtx addr;
+{
+ int basereg = 31;
+ HOST_WIDE_INT offset = 0;
+
+ if (GET_CODE (addr) == AND)
+ addr = XEXP (addr, 0);
+
+ if (GET_CODE (addr) == PLUS
+ && GET_CODE (XEXP (addr, 1)) == CONST_INT)
+ {
+ offset = INTVAL (XEXP (addr, 1));
+ addr = XEXP (addr, 0);
+ }
+ if (GET_CODE (addr) == REG)
+ basereg = REGNO (addr);
+ else if (GET_CODE (addr) == SUBREG
+ && GET_CODE (SUBREG_REG (addr)) == REG)
+ basereg = REGNO (SUBREG_REG (addr)) + SUBREG_WORD (addr);
+ else if (GET_CODE (addr) == CONST_INT)
+ offset = INTVAL (addr);
+ else
+ abort ();
+
+ fprintf (file, HOST_WIDE_INT_PRINT_DEC, offset);
+ fprintf (file, "($%d)", basereg);
+}
+
+/* Emit RTL insns to initialize the variable parts of a trampoline at
+ TRAMP. FNADDR is an RTX for the address of the function's pure
+ code. CXT is an RTX for the static chain value for the function.
+
+ The three offset parameters are for the individual template's
+ layout. A JMPOFS < 0 indicates that the trampoline does not
+ contain instructions at all.
+
+ We assume here that a function will be called many more times than
+ its address is taken (e.g., it might be passed to qsort), so we
+ take the trouble to initialize the "hint" field in the JMP insn.
+ Note that the hint field is PC (new) + 4 * bits 13:0. */
+
+void
+alpha_initialize_trampoline (tramp, fnaddr, cxt, fnofs, cxtofs, jmpofs)
+ rtx tramp, fnaddr, cxt;
+ int fnofs, cxtofs, jmpofs;
+{
+ rtx temp, temp1, addr;
+ /* VMS really uses DImode pointers in memory at this point. */
+ enum machine_mode mode = TARGET_OPEN_VMS ? Pmode : ptr_mode;
+
+#ifdef POINTERS_EXTEND_UNSIGNED
+ fnaddr = convert_memory_address (mode, fnaddr);
+ cxt = convert_memory_address (mode, cxt);
+#endif
+
+ /* Store function address and CXT. */
+ addr = memory_address (mode, plus_constant (tramp, fnofs));
+ emit_move_insn (gen_rtx (MEM, mode, addr), fnaddr);
+ addr = memory_address (mode, plus_constant (tramp, cxtofs));
+ emit_move_insn (gen_rtx (MEM, mode, addr), cxt);
+
+ /* This has been disabled since the hint only has a 32k range, and in
+ no existing OS is the stack within 32k of the text segment. */
+ if (0 && jmpofs >= 0)
+ {
+ /* Compute hint value. */
+ temp = force_operand (plus_constant (tramp, jmpofs+4), NULL_RTX);
+ temp = expand_binop (DImode, sub_optab, fnaddr, temp, temp, 1,
+ OPTAB_WIDEN);
+ temp = expand_shift (RSHIFT_EXPR, Pmode, temp,
+ build_int_2 (2, 0), NULL_RTX, 1);
+ temp = expand_and (gen_lowpart (SImode, temp), GEN_INT (0x3fff), 0);
+
+ /* Merge in the hint. */
+ addr = memory_address (SImode, plus_constant (tramp, jmpofs));
+ temp1 = force_reg (SImode, gen_rtx (MEM, SImode, addr));
+ temp1 = expand_and (temp1, GEN_INT (0xffffc000), NULL_RTX);
+ temp1 = expand_binop (SImode, ior_optab, temp1, temp, temp1, 1,
+ OPTAB_WIDEN);
+ emit_move_insn (gen_rtx (MEM, SImode, addr), temp1);
+ }
+
+#ifdef TRANSFER_FROM_TRAMPOLINE
+ emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "__enable_execute_stack"),
+ 0, VOIDmode, 1, addr, Pmode);
+#endif
+
+ if (jmpofs >= 0)
+ emit_insn (gen_imb ());
+}
/* Do what is necessary for `va_start'. The argument is ignored;
We look at the current function to determine if stdarg or varargs
@@ -1143,9 +3084,9 @@ print_operand (file, x, code)
struct rtx_def *
alpha_builtin_saveregs (arglist)
- tree arglist;
+ tree arglist ATTRIBUTE_UNUSED;
{
- rtx block, addr, argsize;
+ rtx block, addr, dest, argsize;
tree fntype = TREE_TYPE (current_function_decl);
int stdarg = (TYPE_ARG_TYPES (fntype) != 0
&& (TREE_VALUE (tree_last (TYPE_ARG_TYPES (fntype)))
@@ -1153,11 +3094,11 @@ alpha_builtin_saveregs (arglist)
/* Compute the current position into the args, taking into account
both registers and memory. Both of these are already included in
- current_function_args_info. */
+ NUM_ARGS. */
- argsize = GEN_INT (current_function_args_info * UNITS_PER_WORD);
+ argsize = GEN_INT (NUM_ARGS * UNITS_PER_WORD);
- /* SETUP_INCOMING_VARARGS moves the starting address base up by 48,
+ /* For Unix, SETUP_INCOMING_VARARGS moves the starting address base up by 48,
storing fp arg registers in the first 48 bytes, and the integer arg
registers in the next 48 bytes. This is only done, however, if any
integer registers need to be stored.
@@ -1166,35 +3107,71 @@ alpha_builtin_saveregs (arglist)
order to account for the integer arg registers which are counted in
argsize above, but which are not actually stored on the stack. */
- addr = (current_function_args_info <= 5 + stdarg
- ? plus_constant (virtual_incoming_args_rtx, 6 * UNITS_PER_WORD)
- : plus_constant (virtual_incoming_args_rtx, - (6 * UNITS_PER_WORD)));
-
- addr = force_operand (addr, NULL_RTX);
+ if (TARGET_OPEN_VMS)
+ addr = plus_constant (virtual_incoming_args_rtx,
+ NUM_ARGS <= 5 + stdarg
+ ? UNITS_PER_WORD : - 6 * UNITS_PER_WORD);
+ else
+ addr = (NUM_ARGS <= 5 + stdarg
+ ? plus_constant (virtual_incoming_args_rtx,
+ 6 * UNITS_PER_WORD)
+ : plus_constant (virtual_incoming_args_rtx,
+ - (6 * UNITS_PER_WORD)));
- /* Allocate the va_list constructor */
- block = assign_stack_local (BLKmode, 2 * UNITS_PER_WORD, BITS_PER_WORD);
- RTX_UNCHANGING_P (block) = 1;
- RTX_UNCHANGING_P (XEXP (block, 0)) = 1;
+ /* For VMS, we include the argsize, while on Unix, it's handled as
+ a separate field. */
+ if (TARGET_OPEN_VMS)
+ addr = plus_constant (addr, INTVAL (argsize));
- /* Store the address of the first integer register in the __base member. */
+ addr = force_operand (addr, NULL_RTX);
#ifdef POINTERS_EXTEND_UNSIGNED
addr = convert_memory_address (ptr_mode, addr);
#endif
- emit_move_insn (change_address (block, ptr_mode, XEXP (block, 0)), addr);
-
- /* Store the argsize as the __va_offset member. */
- emit_move_insn (change_address (block, TYPE_MODE (integer_type_node),
- plus_constant (XEXP (block, 0),
- POINTER_SIZE/BITS_PER_UNIT)),
- argsize);
-
- /* Return the address of the va_list constructor, but don't put it in a
- register. Doing so would fail when not optimizing and produce worse
- code when optimizing. */
- return XEXP (block, 0);
+ if (TARGET_OPEN_VMS)
+ return addr;
+ else
+ {
+ /* Allocate the va_list constructor */
+ block = assign_stack_local (BLKmode, 2 * UNITS_PER_WORD, BITS_PER_WORD);
+ RTX_UNCHANGING_P (block) = 1;
+ RTX_UNCHANGING_P (XEXP (block, 0)) = 1;
+
+ /* Store the address of the first integer register in the __base
+ member. */
+
+ dest = change_address (block, ptr_mode, XEXP (block, 0));
+ emit_move_insn (dest, addr);
+
+ if (current_function_check_memory_usage)
+ emit_library_call (chkr_set_right_libfunc, 1, VOIDmode, 3,
+ dest, ptr_mode,
+ GEN_INT (GET_MODE_SIZE (ptr_mode)),
+ TYPE_MODE (sizetype),
+ GEN_INT (MEMORY_USE_RW),
+ TYPE_MODE (integer_type_node));
+
+ /* Store the argsize as the __va_offset member. */
+ dest = change_address (block, TYPE_MODE (integer_type_node),
+ plus_constant (XEXP (block, 0),
+ POINTER_SIZE/BITS_PER_UNIT));
+ emit_move_insn (dest, argsize);
+
+ if (current_function_check_memory_usage)
+ emit_library_call (chkr_set_right_libfunc, 1, VOIDmode, 3,
+ dest, ptr_mode,
+ GEN_INT (GET_MODE_SIZE
+ (TYPE_MODE (integer_type_node))),
+ TYPE_MODE (sizetype),
+ GEN_INT (MEMORY_USE_RW),
+ TYPE_MODE (integer_type_node));
+
+ /* Return the address of the va_list constructor, but don't put it in a
+ register. Doing so would fail when not optimizing and produce worse
+ code when optimizing. */
+ return XEXP (block, 0);
+ }
}
/* This page contains routines that are used to determine what the function
@@ -1202,195 +3179,293 @@ alpha_builtin_saveregs (arglist)
/* Compute the size of the save area in the stack. */
+/* These variables are used for communication between the following functions.
+ They indicate various things about the current function being compiled
+ that are used to tell what kind of prologue, epilogue and procedure
+ descriptior to generate. */
+
+/* Nonzero if we need a stack procedure. */
+static int vms_is_stack_procedure;
+
+/* Register number (either FP or SP) that is used to unwind the frame. */
+static int vms_unwind_regno;
+
+/* Register number used to save FP. We need not have one for RA since
+ we don't modify it for register procedures. This is only defined
+ for register frame procedures. */
+static int vms_save_fp_regno;
+
+/* Register number used to reference objects off our PV. */
+static int vms_base_regno;
+
+/* Compute register masks for saved registers. */
+
+static void
+alpha_sa_mask (imaskP, fmaskP)
+ unsigned long *imaskP;
+ unsigned long *fmaskP;
+{
+ unsigned long imask = 0;
+ unsigned long fmask = 0;
+ int i;
+
+#ifdef ASM_OUTPUT_MI_THUNK
+ if (!current_function_is_thunk)
+#endif
+ {
+ if (TARGET_OPEN_VMS && vms_is_stack_procedure)
+ imask |= (1L << HARD_FRAME_POINTER_REGNUM);
+
+ /* One for every register we have to save. */
+ for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
+ if (! fixed_regs[i] && ! call_used_regs[i]
+ && regs_ever_live[i] && i != REG_RA)
+ {
+ if (i < 32)
+ imask |= (1L << i);
+ else
+ fmask |= (1L << (i - 32));
+ }
+
+ if (imask || fmask || alpha_ra_ever_killed ())
+ imask |= (1L << REG_RA);
+ }
+
+ *imaskP = imask;
+ *fmaskP = fmask;
+}
+
int
alpha_sa_size ()
{
- int size = 0;
+ int sa_size = 0;
int i;
- for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
- if (! fixed_regs[i] && ! call_used_regs[i] && regs_ever_live[i])
- size++;
+#ifdef ASM_OUTPUT_MI_THUNK
+ if (current_function_is_thunk)
+ sa_size = 0;
+ else
+#endif
+ {
+ /* One for every register we have to save. */
+ for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
+ if (! fixed_regs[i] && ! call_used_regs[i]
+ && regs_ever_live[i] && i != REG_RA)
+ sa_size++;
+ }
- /* If some registers were saved but not reg 26, reg 26 must also
- be saved, so leave space for it. */
- if (size != 0 && ! regs_ever_live[26])
- size++;
+ if (TARGET_OPEN_VMS)
+ {
+ /* Start by assuming we can use a register procedure if we don't
+ make any calls (REG_RA not used) or need to save any
+ registers and a stack procedure if we do. */
+ vms_is_stack_procedure = sa_size != 0 || alpha_ra_ever_killed ();
+
+ /* Decide whether to refer to objects off our PV via FP or PV.
+ If we need FP for something else or if we receive a nonlocal
+ goto (which expects PV to contain the value), we must use PV.
+ Otherwise, start by assuming we can use FP. */
+ vms_base_regno = (frame_pointer_needed
+ || current_function_has_nonlocal_label
+ || vms_is_stack_procedure
+ || current_function_outgoing_args_size
+ ? REG_PV : HARD_FRAME_POINTER_REGNUM);
+
+ /* If we want to copy PV into FP, we need to find some register
+ in which to save FP. */
+
+ vms_save_fp_regno = -1;
+ if (vms_base_regno == HARD_FRAME_POINTER_REGNUM)
+ for (i = 0; i < 32; i++)
+ if (! fixed_regs[i] && call_used_regs[i] && ! regs_ever_live[i])
+ vms_save_fp_regno = i;
+
+ if (vms_save_fp_regno == -1)
+ vms_base_regno = REG_PV, vms_is_stack_procedure = 1;
+
+ /* Stack unwinding should be done via FP unless we use it for PV. */
+ vms_unwind_regno = (vms_base_regno == REG_PV
+ ? HARD_FRAME_POINTER_REGNUM : STACK_POINTER_REGNUM);
+
+ /* If this is a stack procedure, allow space for saving FP and RA. */
+ if (vms_is_stack_procedure)
+ sa_size += 2;
+ }
+ else
+ {
+ /* If some registers were saved but not RA, RA must also be saved,
+ so leave space for it. */
+ if (sa_size != 0 || alpha_ra_ever_killed ())
+ sa_size++;
+
+ /* Our size must be even (multiple of 16 bytes). */
+ if (sa_size & 1)
+ sa_size++;
+ }
- /* Our size must be even (multiple of 16 bytes). */
- if (size & 1)
- size ++;
+ return sa_size * 8;
+}
- return size * 8;
+int
+alpha_pv_save_size ()
+{
+ alpha_sa_size ();
+ return vms_is_stack_procedure ? 8 : 0;
}
-/* Return 1 if this function can directly return via $26. */
+int
+alpha_using_fp ()
+{
+ alpha_sa_size ();
+ return vms_unwind_regno == HARD_FRAME_POINTER_REGNUM;
+}
int
-direct_return ()
+vms_valid_decl_attribute_p (decl, attributes, identifier, args)
+ tree decl ATTRIBUTE_UNUSED;
+ tree attributes ATTRIBUTE_UNUSED;
+ tree identifier;
+ tree args;
{
- return (reload_completed && alpha_sa_size () == 0
- && get_frame_size () == 0
- && current_function_outgoing_args_size == 0
- && current_function_pretend_args_size == 0);
+ if (is_attribute_p ("overlaid", identifier))
+ return (args == NULL_TREE);
+ return 0;
+}
+
+static int
+alpha_does_function_need_gp ()
+{
+ rtx insn;
+
+ /* We never need a GP for Windows/NT or VMS. */
+ if (TARGET_WINDOWS_NT || TARGET_OPEN_VMS)
+ return 0;
+
+#ifdef TARGET_PROFILING_NEEDS_GP
+ if (profile_flag)
+ return 1;
+#endif
+
+#ifdef ASM_OUTPUT_MI_THUNK
+ if (current_function_is_thunk)
+ return 1;
+#endif
+
+ /* If we need a GP (we have a LDSYM insn or a CALL_INSN), load it first.
+ Even if we are a static function, we still need to do this in case
+ our address is taken and passed to something like qsort. */
+
+ push_topmost_sequence ();
+ insn = get_insns ();
+ pop_topmost_sequence ();
+
+ for (; insn; insn = NEXT_INSN (insn))
+ if (GET_RTX_CLASS (GET_CODE (insn)) == 'i'
+ && GET_CODE (PATTERN (insn)) != USE
+ && GET_CODE (PATTERN (insn)) != CLOBBER)
+ {
+ enum attr_type type = get_attr_type (insn);
+ if (type == TYPE_LDSYM || type == TYPE_JSR)
+ return 1;
+ }
+
+ return 0;
}
/* Write a version stamp. Don't write anything if we are running as a
cross-compiler. Otherwise, use the versions in /usr/include/stamp.h. */
-#if !defined(CROSS_COMPILE) && !defined(_WIN32) && \
- !defined(__NetBSD__) && !defined(__FreeBSD__)
+#ifdef HAVE_STAMP_H
#include <stamp.h>
#endif
void
alpha_write_verstamp (file)
- FILE *file;
+ FILE *file ATTRIBUTE_UNUSED;
{
#ifdef MS_STAMP
fprintf (file, "\t.verstamp %d %d\n", MS_STAMP, LS_STAMP);
#endif
}
-/* Write code to add constant C to register number IN_REG (possibly 31)
- and put the result into OUT_REG. Use TEMP_REG as a scratch register;
- usually this will be OUT_REG, but should not be if OUT_REG is
- STACK_POINTER_REGNUM, since it must be updated in a single instruction.
- Write the code to FILE. */
+/* Helper function to set RTX_FRAME_RELATED_P on instructions, including
+ sequences. */
-static void
-add_long_const (file, c, in_reg, out_reg, temp_reg)
- FILE *file;
- HOST_WIDE_INT c;
- int in_reg, out_reg, temp_reg;
+static rtx
+set_frame_related_p ()
{
- HOST_WIDE_INT low = (c & 0xffff) - 2 * (c & 0x8000);
- HOST_WIDE_INT tmp1 = c - low;
- HOST_WIDE_INT high = ((tmp1 >> 16) & 0xffff) - 2 * ((tmp1 >> 16) & 0x8000);
- HOST_WIDE_INT extra = 0;
+ rtx seq = gen_sequence ();
+ end_sequence ();
- /* We don't have code to write out constants larger than 32 bits. */
-#if HOST_BITS_PER_LONG_INT == 64
- if ((unsigned HOST_WIDE_INT) c >> 32 != 0)
- abort ();
-#endif
-
- /* If HIGH will be interpreted as negative, we must adjust it to do two
- ldha insns. Note that we will never be building a negative constant
- here. */
-
- if (high & 0x8000)
+ if (GET_CODE (seq) == SEQUENCE)
{
- extra = 0x4000;
- tmp1 -= 0x40000000;
- high = ((tmp1 >> 16) & 0xffff) - 2 * ((tmp1 >> 16) & 0x8000);
+ int i = XVECLEN (seq, 0);
+ while (--i >= 0)
+ RTX_FRAME_RELATED_P (XVECEXP (seq, 0, i)) = 1;
+ return emit_insn (seq);
}
-
- if (low != 0)
- {
- int result_reg = (extra == 0 && high == 0) ? out_reg : temp_reg;
-
- if (low >= 0 && low < 255)
- fprintf (file, "\taddq $%d,%d,$%d\n", in_reg, low, result_reg);
- else
- fprintf (file, "\tlda $%d,%d($%d)\n", result_reg, low, in_reg);
-
- in_reg = result_reg;
- }
-
- if (extra)
+ else
{
- int result_reg = (high == 0) ? out_reg : temp_reg;
-
- fprintf (file, "\tldah $%d,%d($%d)\n", result_reg, extra, in_reg);
- in_reg = result_reg;
+ seq = emit_insn (seq);
+ RTX_FRAME_RELATED_P (seq) = 1;
+ return seq;
}
-
- if (high)
- fprintf (file, "\tldah $%d,%d($%d)\n", out_reg, high, in_reg);
}
+#define FRP(exp) (start_sequence (), exp, set_frame_related_p ())
+
/* Write function prologue. */
-void
-output_prolog (file, size)
- FILE *file;
- int size;
-{
- HOST_WIDE_INT out_args_size
- = ALPHA_ROUND (current_function_outgoing_args_size);
- HOST_WIDE_INT sa_size = alpha_sa_size ();
- HOST_WIDE_INT frame_size
- = (out_args_size + sa_size
- + ALPHA_ROUND (size + current_function_pretend_args_size));
- HOST_WIDE_INT reg_offset = out_args_size;
- HOST_WIDE_INT start_reg_offset = reg_offset;
- HOST_WIDE_INT actual_start_reg_offset = start_reg_offset;
- int int_reg_save_area_size = 0;
- rtx insn;
- unsigned reg_mask = 0;
- int i;
+/* On vms we have two kinds of functions:
- /* Ecoff can handle multiple .file directives, so put out file and lineno.
- We have to do that before the .ent directive as we cannot switch
- files within procedures with native ecoff because line numbers are
- linked to procedure descriptors.
- Outputting the lineno helps debugging of one line functions as they
- would otherwise get no line number at all. Please note that we would
- like to put out last_linenum from final.c, but it is not accessible. */
+ - stack frame (PROC_STACK)
+ these are 'normal' functions with local vars and which are
+ calling other functions
+ - register frame (PROC_REGISTER)
+ keeps all data in registers, needs no stack
- if (write_symbols == SDB_DEBUG)
- {
- ASM_OUTPUT_SOURCE_FILENAME (file,
- DECL_SOURCE_FILE (current_function_decl));
- if (debug_info_level != DINFO_LEVEL_TERSE)
- ASM_OUTPUT_SOURCE_LINE (file,
- DECL_SOURCE_LINE (current_function_decl));
- }
+ We must pass this to the assembler so it can generate the
+ proper pdsc (procedure descriptor)
+ This is done with the '.pdesc' command.
- /* The assembly language programmer's guide states that the second argument
- to the .ent directive, the lex_level, is ignored by the assembler,
- so we might as well omit it. */
-
- fprintf (file, "\t.ent ");
- assemble_name (file, alpha_function_name);
- fprintf (file, "\n");
- ASM_OUTPUT_LABEL (file, alpha_function_name);
- inside_function = TRUE;
+ On not-vms, we don't really differentiate between the two, as we can
+ simply allocate stack without saving registers. */
- /* Set up offsets to alpha virtual arg/local debugging pointer. */
+void
+alpha_expand_prologue ()
+{
+ /* Registers to save. */
+ unsigned long imask = 0;
+ unsigned long fmask = 0;
+ /* Stack space needed for pushing registers clobbered by us. */
+ HOST_WIDE_INT sa_size;
+ /* Complete stack size needed. */
+ HOST_WIDE_INT frame_size;
+ /* Offset from base reg to register save area. */
+ HOST_WIDE_INT reg_offset;
+ rtx sa_reg, mem;
+ int i;
- alpha_auto_offset = -frame_size + current_function_pretend_args_size;
- alpha_arg_offset = -frame_size + 48;
+ sa_size = alpha_sa_size ();
- /* If we need a GP (we have a LDSYM insn or a CALL_INSN), load it first.
- Even if we are a static function, we still need to do this in case
- our address is taken and passed to something like qsort.
-
- We never need a GP for Windows/NT. */
-
- alpha_function_needs_gp = 0;
- for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
- if ((GET_CODE (insn) == CALL_INSN)
- || (GET_RTX_CLASS (GET_CODE (insn)) == 'i'
- && GET_CODE (PATTERN (insn)) != USE
- && GET_CODE (PATTERN (insn)) != CLOBBER
- && (get_attr_type (insn) == TYPE_LDSYM
- || get_attr_type (insn) == TYPE_ISUBR)))
- {
- alpha_function_needs_gp = 1;
- break;
- }
+ frame_size = get_frame_size ();
+ if (TARGET_OPEN_VMS)
+ frame_size = ALPHA_ROUND (sa_size
+ + (vms_is_stack_procedure ? 8 : 0)
+ + frame_size
+ + current_function_pretend_args_size);
+ else
+ frame_size = (ALPHA_ROUND (current_function_outgoing_args_size)
+ + sa_size
+ + ALPHA_ROUND (frame_size
+ + current_function_pretend_args_size));
- if (WINDOWS_NT == 0)
- {
- if (alpha_function_needs_gp)
- fprintf (file, "\tldgp $29,0($27)\n");
+ if (TARGET_OPEN_VMS)
+ reg_offset = 8;
+ else
+ reg_offset = ALPHA_ROUND (current_function_outgoing_args_size);
- /* Put a label after the GP load so we can enter the function at it. */
- assemble_name (file, alpha_function_name);
- fprintf (file, "..ng:\n");
- }
+ alpha_sa_mask (&imask, &fmask);
/* Adjust the stack by the frame size. If the frame size is > 4096
bytes, we need to be sure we probe somewhere in the first and last
@@ -1401,28 +3476,30 @@ output_prolog (file, size)
Note that we are only allowed to adjust sp once in the prologue. */
- if (frame_size < 32768)
+ if (frame_size <= 32768)
{
if (frame_size > 4096)
{
int probed = 4096;
- fprintf (file, "\tstq $31,-%d($30)\n", probed);
-
- while (probed + 8192 < frame_size)
- fprintf (file, "\tstq $31,-%d($30)\n", probed += 8192);
+ do
+ emit_insn (gen_probe_stack (GEN_INT (-probed)));
+ while ((probed += 8192) < frame_size);
/* We only have to do this probe if we aren't saving registers. */
if (sa_size == 0 && probed + 4096 < frame_size)
- fprintf (file, "\tstq $31,-%d($30)\n", frame_size);
+ emit_insn (gen_probe_stack (GEN_INT (-frame_size)));
}
if (frame_size != 0)
- fprintf (file, "\tlda $30,-%d($30)\n", frame_size);
+ {
+ FRP (emit_insn (gen_adddi3 (stack_pointer_rtx, stack_pointer_rtx,
+ GEN_INT (-frame_size))));
+ }
}
else
{
- /* Here we generate code to set R4 to SP + 4096 and set R5 to the
+ /* Here we generate code to set R22 to SP + 4096 and set R23 to the
number of 8192 byte blocks to probe. We then probe each block
in the loop and then set SP to the proper location. If the
amount remaining is > 4096, we have to do one more probe if we
@@ -1430,182 +3507,588 @@ output_prolog (file, size)
HOST_WIDE_INT blocks = (frame_size + 4096) / 8192;
HOST_WIDE_INT leftover = frame_size + 4096 - blocks * 8192;
+ rtx ptr = gen_rtx_REG (DImode, 22);
+ rtx count = gen_rtx_REG (DImode, 23);
+ rtx seq;
- add_long_const (file, blocks, 31, 5, 5);
+ emit_move_insn (count, GEN_INT (blocks));
+ emit_insn (gen_adddi3 (ptr, stack_pointer_rtx, GEN_INT (4096)));
- fprintf (file, "\tlda $4,4096($30)\n");
+ /* Because of the difficulty in emitting a new basic block this
+ late in the compilation, generate the loop as a single insn. */
+ emit_insn (gen_prologue_stack_probe_loop (count, ptr));
- assemble_name (file, alpha_function_name);
- fprintf (file, "..sc:\n");
+ if (leftover > 4096 && sa_size == 0)
+ {
+ rtx last = gen_rtx_MEM (DImode, plus_constant (ptr, -leftover));
+ MEM_VOLATILE_P (last) = 1;
+ emit_move_insn (last, const0_rtx);
+ }
- fprintf (file, "\tstq $31,-8192($4)\n");
- fprintf (file, "\tsubq $5,1,$5\n");
- fprintf (file, "\tlda $4,-8192($4)\n");
+ if (TARGET_WINDOWS_NT)
+ {
+ /* For NT stack unwind (done by 'reverse execution'), it's
+ not OK to take the result of a loop, even though the value
+ is already in ptr, so we reload it via a single operation
+ and subtract it to sp.
+
+ Yes, that's correct -- we have to reload the whole constant
+ into a temporary via ldah+lda then subtract from sp. To
+ ensure we get ldah+lda, we use a special pattern. */
+
+ HOST_WIDE_INT lo, hi;
+ lo = ((frame_size & 0xffff) ^ 0x8000) - 0x8000;
+ hi = frame_size - lo;
+
+ emit_move_insn (ptr, GEN_INT (hi));
+ emit_insn (gen_nt_lda (ptr, GEN_INT (lo)));
+ seq = emit_insn (gen_subdi3 (stack_pointer_rtx, stack_pointer_rtx,
+ ptr));
+ }
+ else
+ {
+ seq = emit_insn (gen_adddi3 (stack_pointer_rtx, ptr,
+ GEN_INT (-leftover)));
+ }
- fprintf (file, "\tbne $5,");
- assemble_name (file, alpha_function_name);
- fprintf (file, "..sc\n");
+ /* This alternative is special, because the DWARF code cannot
+ possibly intuit through the loop above. So we invent this
+ note it looks at instead. */
+ RTX_FRAME_RELATED_P (seq) = 1;
+ REG_NOTES (seq)
+ = gen_rtx_EXPR_LIST (REG_FRAME_RELATED_EXPR,
+ gen_rtx_SET (VOIDmode, stack_pointer_rtx,
+ gen_rtx_PLUS (Pmode, stack_pointer_rtx,
+ GEN_INT (-frame_size))),
+ REG_NOTES (seq));
+ }
- if (leftover > 4096 && sa_size == 0)
- fprintf (file, "\tstq $31,-%d($4)\n", leftover);
+ /* Cope with very large offsets to the register save area. */
+ sa_reg = stack_pointer_rtx;
+ if (reg_offset + sa_size > 0x8000)
+ {
+ int low = ((reg_offset & 0xffff) ^ 0x8000) - 0x8000;
+ HOST_WIDE_INT bias;
- fprintf (file, "\tlda $30,-%d($4)\n", leftover);
- }
+ if (low + sa_size <= 0x8000)
+ bias = reg_offset - low, reg_offset = low;
+ else
+ bias = reg_offset, reg_offset = 0;
- /* Describe our frame. */
- fprintf (file, "\t.frame $%d,%d,$26,%d\n",
- (frame_pointer_needed
- ? HARD_FRAME_POINTER_REGNUM : STACK_POINTER_REGNUM),
- frame_size, current_function_pretend_args_size);
+ sa_reg = gen_rtx_REG (DImode, 24);
+ FRP (emit_insn (gen_adddi3 (sa_reg, stack_pointer_rtx, GEN_INT (bias))));
+ }
- /* Save register 26 if any other register needs to be saved. */
- if (sa_size != 0)
+ /* Save regs in stack order. Beginning with VMS PV. */
+ if (TARGET_OPEN_VMS && vms_is_stack_procedure)
+ {
+ mem = gen_rtx_MEM (DImode, stack_pointer_rtx);
+ MEM_ALIAS_SET (mem) = alpha_sr_alias_set;
+ FRP (emit_move_insn (mem, gen_rtx_REG (DImode, REG_PV)));
+ }
+
+ /* Save register RA next. */
+ if (imask & (1L << REG_RA))
{
- reg_mask |= 1 << 26;
- fprintf (file, "\tstq $26,%d($30)\n", reg_offset);
+ mem = gen_rtx_MEM (DImode, plus_constant (sa_reg, reg_offset));
+ MEM_ALIAS_SET (mem) = alpha_sr_alias_set;
+ FRP (emit_move_insn (mem, gen_rtx_REG (DImode, REG_RA)));
+ imask &= ~(1L << REG_RA);
reg_offset += 8;
- int_reg_save_area_size += 8;
}
- /* Now save any other used integer registers required to be saved. */
+ /* Now save any other registers required to be saved. */
for (i = 0; i < 32; i++)
- if (! fixed_regs[i] && ! call_used_regs[i] && regs_ever_live[i] && i != 26)
+ if (imask & (1L << i))
{
- reg_mask |= 1 << i;
- fprintf (file, "\tstq $%d,%d($30)\n", i, reg_offset);
+ mem = gen_rtx_MEM (DImode, plus_constant (sa_reg, reg_offset));
+ MEM_ALIAS_SET (mem) = alpha_sr_alias_set;
+ FRP (emit_move_insn (mem, gen_rtx_REG (DImode, i)));
reg_offset += 8;
- int_reg_save_area_size += 8;
}
- /* Print the register mask and do floating-point saves. */
- if (reg_mask)
- fprintf (file, "\t.mask 0x%x,%d\n", reg_mask,
- actual_start_reg_offset - frame_size);
-
- start_reg_offset = reg_offset;
- reg_mask = 0;
-
for (i = 0; i < 32; i++)
- if (! fixed_regs[i + 32] && ! call_used_regs[i + 32]
- && regs_ever_live[i + 32])
+ if (fmask & (1L << i))
{
- reg_mask |= 1 << i;
- fprintf (file, "\tstt $f%d,%d($30)\n", i, reg_offset);
+ mem = gen_rtx_MEM (DFmode, plus_constant (sa_reg, reg_offset));
+ MEM_ALIAS_SET (mem) = alpha_sr_alias_set;
+ FRP (emit_move_insn (mem, gen_rtx_REG (DFmode, i+32)));
reg_offset += 8;
}
- /* Print the floating-point mask, if we've saved any fp register. */
- if (reg_mask)
- fprintf (file, "\t.fmask 0x%x,%d\n", reg_mask,
- actual_start_reg_offset - frame_size + int_reg_save_area_size);
+ if (TARGET_OPEN_VMS)
+ {
+ if (!vms_is_stack_procedure)
+ {
+ /* Register frame procedures fave the fp. */
+ FRP (emit_move_insn (gen_rtx_REG (DImode, vms_save_fp_regno),
+ hard_frame_pointer_rtx));
+ }
+
+ if (vms_base_regno != REG_PV)
+ FRP (emit_move_insn (gen_rtx_REG (DImode, vms_base_regno),
+ gen_rtx_REG (DImode, REG_PV)));
+
+ if (vms_unwind_regno == HARD_FRAME_POINTER_REGNUM)
+ {
+ FRP (emit_move_insn (hard_frame_pointer_rtx, stack_pointer_rtx));
+ }
+
+ /* If we have to allocate space for outgoing args, do it now. */
+ if (current_function_outgoing_args_size != 0)
+ {
+ FRP (emit_move_insn (stack_pointer_rtx,
+ plus_constant (hard_frame_pointer_rtx,
+ - ALPHA_ROUND (current_function_outgoing_args_size))));
+ }
+ }
+ else
+ {
+ /* If we need a frame pointer, set it from the stack pointer. */
+ if (frame_pointer_needed)
+ {
+ if (TARGET_CAN_FAULT_IN_PROLOGUE)
+ FRP (emit_move_insn (hard_frame_pointer_rtx, stack_pointer_rtx));
+ else
+ {
+ /* This must always be the last instruction in the
+ prologue, thus we emit a special move + clobber. */
+ FRP (emit_insn (gen_init_fp (hard_frame_pointer_rtx,
+ stack_pointer_rtx, sa_reg)));
+ }
+ }
+ }
- /* If we need a frame pointer, set it from the stack pointer. Note that
- this must always be the last instruction in the prologue. */
- if (frame_pointer_needed)
- fprintf (file, "\tbis $30,$30,$15\n");
+ /* The ABIs for VMS and OSF/1 say that while we can schedule insns into
+ the prologue, for exception handling reasons, we cannot do this for
+ any insn that might fault. We could prevent this for mems with a
+ (clobber:BLK (scratch)), but this doesn't work for fp insns. So we
+ have to prevent all such scheduling with a blockage.
- /* End the prologue and say if we used gp. */
- fprintf (file, "\t.prologue %d\n", alpha_function_needs_gp);
+ Linux, on the other hand, never bothered to implement OSF/1's
+ exception handling, and so doesn't care about such things. Anyone
+ planning to use dwarf2 frame-unwind info can also omit the blockage. */
+
+ if (! TARGET_CAN_FAULT_IN_PROLOGUE)
+ emit_insn (gen_blockage ());
}
-/* Write function epilogue. */
+/* Output the textual info surrounding the prologue. */
void
-output_epilog (file, size)
+alpha_start_function (file, fnname, decl)
FILE *file;
- int size;
-{
- rtx insn = get_last_insn ();
- HOST_WIDE_INT out_args_size
- = ALPHA_ROUND (current_function_outgoing_args_size);
- HOST_WIDE_INT sa_size = alpha_sa_size ();
- HOST_WIDE_INT frame_size
- = (out_args_size + sa_size
- + ALPHA_ROUND (size + current_function_pretend_args_size));
- HOST_WIDE_INT reg_offset = out_args_size;
- HOST_WIDE_INT frame_size_from_reg_save = frame_size - reg_offset;
- int restore_fp
- = frame_pointer_needed && regs_ever_live[HARD_FRAME_POINTER_REGNUM];
+ char *fnname;
+ tree decl ATTRIBUTE_UNUSED;
+{
+ unsigned long imask = 0;
+ unsigned long fmask = 0;
+ /* Stack space needed for pushing registers clobbered by us. */
+ HOST_WIDE_INT sa_size;
+ /* Complete stack size needed. */
+ HOST_WIDE_INT frame_size;
+ /* Offset from base reg to register save area. */
+ HOST_WIDE_INT reg_offset;
+ char *entry_label = (char *) alloca (strlen (fnname) + 6);
int i;
- /* If the last insn was a BARRIER, we don't have to write anything except
- the .end pseudo-op. */
- if (GET_CODE (insn) == NOTE)
- insn = prev_nonnote_insn (insn);
- if (insn == 0 || GET_CODE (insn) != BARRIER)
+ sa_size = alpha_sa_size ();
+
+ frame_size = get_frame_size ();
+ if (TARGET_OPEN_VMS)
+ frame_size = ALPHA_ROUND (sa_size
+ + (vms_is_stack_procedure ? 8 : 0)
+ + frame_size
+ + current_function_pretend_args_size);
+ else
+ frame_size = (ALPHA_ROUND (current_function_outgoing_args_size)
+ + sa_size
+ + ALPHA_ROUND (frame_size
+ + current_function_pretend_args_size));
+
+ if (TARGET_OPEN_VMS)
+ reg_offset = 8;
+ else
+ reg_offset = ALPHA_ROUND (current_function_outgoing_args_size);
+
+ alpha_sa_mask (&imask, &fmask);
+
+ /* Ecoff can handle multiple .file directives, so put out file and lineno.
+ We have to do that before the .ent directive as we cannot switch
+ files within procedures with native ecoff because line numbers are
+ linked to procedure descriptors.
+ Outputting the lineno helps debugging of one line functions as they
+ would otherwise get no line number at all. Please note that we would
+ like to put out last_linenum from final.c, but it is not accessible. */
+
+ if (write_symbols == SDB_DEBUG)
+ {
+ ASM_OUTPUT_SOURCE_FILENAME (file,
+ DECL_SOURCE_FILE (current_function_decl));
+ if (debug_info_level != DINFO_LEVEL_TERSE)
+ ASM_OUTPUT_SOURCE_LINE (file,
+ DECL_SOURCE_LINE (current_function_decl));
+ }
+
+ /* Issue function start and label. */
+ if (TARGET_OPEN_VMS || !flag_inhibit_size_directive)
{
- int fp_offset = 0;
+ fputs ("\t.ent ", file);
+ assemble_name (file, fnname);
+ putc ('\n', file);
+ }
+
+ strcpy (entry_label, fnname);
+ if (TARGET_OPEN_VMS)
+ strcat (entry_label, "..en");
+ ASM_OUTPUT_LABEL (file, entry_label);
+ inside_function = TRUE;
+
+ if (TARGET_OPEN_VMS)
+ fprintf (file, "\t.base $%d\n", vms_base_regno);
+
+ if (!TARGET_OPEN_VMS && TARGET_IEEE_CONFORMANT
+ && !flag_inhibit_size_directive)
+ {
+ /* Set flags in procedure descriptor to request IEEE-conformant
+ math-library routines. The value we set it to is PDSC_EXC_IEEE
+ (/usr/include/pdsc.h). */
+ fputs ("\t.eflag 48\n", file);
+ }
+
+ /* Set up offsets to alpha virtual arg/local debugging pointer. */
+ alpha_auto_offset = -frame_size + current_function_pretend_args_size;
+ alpha_arg_offset = -frame_size + 48;
+
+ /* Describe our frame. If the frame size is larger than an integer,
+ print it as zero to avoid an assembler error. We won't be
+ properly describing such a frame, but that's the best we can do. */
+ if (TARGET_OPEN_VMS)
+ {
+ fprintf (file, "\t.frame $%d,", vms_unwind_regno);
+ fprintf (file, HOST_WIDE_INT_PRINT_DEC,
+ frame_size >= (1l << 31) ? 0 : frame_size);
+ fputs (",$26,", file);
+ fprintf (file, HOST_WIDE_INT_PRINT_DEC, reg_offset);
+ fputs ("\n", file);
+ }
+ else if (!flag_inhibit_size_directive)
+ {
+ fprintf (file, "\t.frame $%d,",
+ (frame_pointer_needed
+ ? HARD_FRAME_POINTER_REGNUM : STACK_POINTER_REGNUM));
+ fprintf (file, HOST_WIDE_INT_PRINT_DEC,
+ frame_size >= (1l << 31) ? 0 : frame_size);
+ fprintf (file, ",$26,%d\n", current_function_pretend_args_size);
+ }
+
+ /* Describe which registers were spilled. */
+ if (TARGET_OPEN_VMS)
+ {
+ if (imask)
+ /* ??? Does VMS care if mask contains ra? The old code did'nt
+ set it, so I don't here. */
+ fprintf (file, "\t.mask 0x%lx,0\n", imask & ~(1L << REG_RA));
+ if (fmask)
+ fprintf (file, "\t.fmask 0x%lx,0\n", fmask);
+ if (!vms_is_stack_procedure)
+ fprintf (file, "\t.fp_save $%d\n", vms_save_fp_regno);
+ }
+ else if (!flag_inhibit_size_directive)
+ {
+ if (imask)
+ {
+ fprintf (file, "\t.mask 0x%lx,", imask);
+ fprintf (file, HOST_WIDE_INT_PRINT_DEC,
+ frame_size >= (1l << 31) ? 0 : reg_offset - frame_size);
+ putc ('\n', file);
+
+ for (i = 0; i < 32; ++i)
+ if (imask & (1L << i))
+ reg_offset += 8;
+ }
+
+ if (fmask)
+ {
+ fprintf (file, "\t.fmask 0x%lx,", fmask);
+ fprintf (file, HOST_WIDE_INT_PRINT_DEC,
+ frame_size >= (1l << 31) ? 0 : reg_offset - frame_size);
+ putc ('\n', file);
+ }
+ }
+
+ /* Emit GP related things. It is rather unfortunate about the alignment
+ issues surrounding a CODE_LABEL that forces us to do the label in
+ plain text. */
+ if (!TARGET_OPEN_VMS && !TARGET_WINDOWS_NT)
+ {
+ alpha_function_needs_gp = alpha_does_function_need_gp ();
+ if (alpha_function_needs_gp)
+ fputs ("\tldgp $29,0($27)\n", file);
+ putc ('$', file);
+ assemble_name (file, fnname);
+ fputs ("..ng:\n", file);
+ }
+
+#ifdef OPEN_VMS
+ /* Ifdef'ed cause readonly_section and link_section are only
+ available then. */
+ readonly_section ();
+ fprintf (file, "\t.align 3\n");
+ assemble_name (file, fnname); fputs ("..na:\n", file);
+ fputs ("\t.ascii \"", file);
+ assemble_name (file, fnname);
+ fputs ("\\0\"\n", file);
+
+ link_section ();
+ fprintf (file, "\t.align 3\n");
+ fputs ("\t.name ", file);
+ assemble_name (file, fnname);
+ fputs ("..na\n", file);
+ ASM_OUTPUT_LABEL (file, fnname);
+ fprintf (file, "\t.pdesc ");
+ assemble_name (file, fnname);
+ fprintf (file, "..en,%s\n", vms_is_stack_procedure ? "stack" : "reg");
+ alpha_need_linkage (fnname, 1);
+ text_section ();
+#endif
+}
+
+/* Emit the .prologue note at the scheduled end of the prologue. */
+
+void
+output_end_prologue (file)
+ FILE *file;
+{
+ if (TARGET_OPEN_VMS)
+ fputs ("\t.prologue\n", file);
+ else if (TARGET_WINDOWS_NT)
+ fputs ("\t.prologue 0\n", file);
+ else if (!flag_inhibit_size_directive)
+ fprintf (file, "\t.prologue %d\n", alpha_function_needs_gp);
+}
+
+/* Write function epilogue. */
+
+/* ??? At some point we will want to support full unwind, and so will
+ need to mark the epilogue as well. At the moment, we just confuse
+ dwarf2out. */
+#undef FRP
+#define FRP(exp) exp
+
+void
+alpha_expand_epilogue ()
+{
+ /* Registers to save. */
+ unsigned long imask = 0;
+ unsigned long fmask = 0;
+ /* Stack space needed for pushing registers clobbered by us. */
+ HOST_WIDE_INT sa_size;
+ /* Complete stack size needed. */
+ HOST_WIDE_INT frame_size;
+ /* Offset from base reg to register save area. */
+ HOST_WIDE_INT reg_offset;
+ int fp_is_frame_pointer, fp_offset;
+ rtx sa_reg, sa_reg_exp = NULL;
+ rtx sp_adj1, sp_adj2, mem;
+ int i;
+
+ sa_size = alpha_sa_size ();
+
+ frame_size = get_frame_size ();
+ if (TARGET_OPEN_VMS)
+ frame_size = ALPHA_ROUND (sa_size
+ + (vms_is_stack_procedure ? 8 : 0)
+ + frame_size
+ + current_function_pretend_args_size);
+ else
+ frame_size = (ALPHA_ROUND (current_function_outgoing_args_size)
+ + sa_size
+ + ALPHA_ROUND (frame_size
+ + current_function_pretend_args_size));
+
+ if (TARGET_OPEN_VMS)
+ reg_offset = 8;
+ else
+ reg_offset = ALPHA_ROUND (current_function_outgoing_args_size);
+
+ alpha_sa_mask (&imask, &fmask);
+
+ fp_is_frame_pointer = ((TARGET_OPEN_VMS && vms_is_stack_procedure)
+ || (!TARGET_OPEN_VMS && frame_pointer_needed));
+
+ if (sa_size)
+ {
/* If we have a frame pointer, restore SP from it. */
- if (frame_pointer_needed)
- fprintf (file, "\tbis $15,$15,$30\n");
+ if ((TARGET_OPEN_VMS
+ && vms_unwind_regno == HARD_FRAME_POINTER_REGNUM)
+ || (!TARGET_OPEN_VMS && frame_pointer_needed))
+ {
+ FRP (emit_move_insn (stack_pointer_rtx, hard_frame_pointer_rtx));
+ }
- /* Restore all the registers, starting with the return address
- register. */
- if (sa_size != 0)
+ /* Cope with very large offsets to the register save area. */
+ sa_reg = stack_pointer_rtx;
+ if (reg_offset + sa_size > 0x8000)
{
- fprintf (file, "\tldq $26,%d($30)\n", reg_offset);
- reg_offset += 8;
+ int low = ((reg_offset & 0xffff) ^ 0x8000) - 0x8000;
+ HOST_WIDE_INT bias;
+
+ if (low + sa_size <= 0x8000)
+ bias = reg_offset - low, reg_offset = low;
+ else
+ bias = reg_offset, reg_offset = 0;
+
+ sa_reg = gen_rtx_REG (DImode, 22);
+ sa_reg_exp = plus_constant (stack_pointer_rtx, bias);
+
+ FRP (emit_move_insn (sa_reg, sa_reg_exp));
}
+
+ /* Restore registers in order, excepting a true frame pointer. */
- /* Now restore any other used integer registers that that we saved,
- except for FP if it is being used as FP, since it must be
- restored last. */
+ if (! alpha_eh_epilogue_sp_ofs)
+ {
+ mem = gen_rtx_MEM (DImode, plus_constant(sa_reg, reg_offset));
+ MEM_ALIAS_SET (mem) = alpha_sr_alias_set;
+ FRP (emit_move_insn (gen_rtx_REG (DImode, REG_RA), mem));
+ }
+ reg_offset += 8;
+ imask &= ~(1L << REG_RA);
- for (i = 0; i < 32; i++)
- if (! fixed_regs[i] && ! call_used_regs[i] && regs_ever_live[i]
- && i != 26)
+ for (i = 0; i < 32; ++i)
+ if (imask & (1L << i))
{
- if (i == HARD_FRAME_POINTER_REGNUM && frame_pointer_needed)
+ if (i == HARD_FRAME_POINTER_REGNUM && fp_is_frame_pointer)
fp_offset = reg_offset;
else
- fprintf (file, "\tldq $%d,%d($30)\n", i, reg_offset);
+ {
+ mem = gen_rtx_MEM (DImode, plus_constant(sa_reg, reg_offset));
+ MEM_ALIAS_SET (mem) = alpha_sr_alias_set;
+ FRP (emit_move_insn (gen_rtx_REG (DImode, i), mem));
+ }
reg_offset += 8;
}
- for (i = 0; i < 32; i++)
- if (! fixed_regs[i + 32] && ! call_used_regs[i + 32]
- && regs_ever_live[i + 32])
+ for (i = 0; i < 32; ++i)
+ if (fmask & (1L << i))
{
- fprintf (file, "\tldt $f%d,%d($30)\n", i, reg_offset);
+ mem = gen_rtx_MEM (DFmode, plus_constant(sa_reg, reg_offset));
+ MEM_ALIAS_SET (mem) = alpha_sr_alias_set;
+ FRP (emit_move_insn (gen_rtx_REG (DFmode, i+32), mem));
reg_offset += 8;
}
+ }
+
+ if (frame_size || alpha_eh_epilogue_sp_ofs)
+ {
+ sp_adj1 = stack_pointer_rtx;
+
+ if (alpha_eh_epilogue_sp_ofs)
+ {
+ sp_adj1 = gen_rtx_REG (DImode, 23);
+ emit_move_insn (sp_adj1,
+ gen_rtx_PLUS (Pmode, stack_pointer_rtx,
+ alpha_eh_epilogue_sp_ofs));
+ }
- /* If the stack size is large and we have a frame pointer, compute the
- size of the stack into a register because the old FP restore, stack
- pointer adjust, and return are required to be consecutive
- instructions. */
- if (frame_size > 32767 && restore_fp)
- add_long_const (file, frame_size, 31, 1, 1);
-
- /* If we needed a frame pointer and we have to restore it, do it
- now. This must be done in one instruction immediately
- before the SP update. */
- if (restore_fp && fp_offset)
- fprintf (file, "\tldq $15,%d($30)\n", fp_offset);
-
- /* Now update the stack pointer, if needed. Only one instruction must
- modify the stack pointer. It must be the last instruction in the
- sequence and must be an ADDQ or LDA instruction. If the frame
- pointer was loaded above, we may only put one instruction here. */
-
- if (frame_size > 32768 && restore_fp)
- fprintf (file, "\taddq $1,$30,$30\n");
+ /* If the stack size is large, begin computation into a temporary
+ register so as not to interfere with a potential fp restore,
+ which must be consecutive with an SP restore. */
+ if (frame_size < 32768)
+ sp_adj2 = GEN_INT (frame_size);
+ else if (frame_size < 0x40007fffL)
+ {
+ int low = ((frame_size & 0xffff) ^ 0x8000) - 0x8000;
+
+ sp_adj2 = plus_constant (sp_adj1, frame_size - low);
+ if (sa_reg_exp && rtx_equal_p (sa_reg_exp, sp_adj2))
+ sp_adj1 = sa_reg;
+ else
+ {
+ sp_adj1 = gen_rtx_REG (DImode, 23);
+ FRP (emit_move_insn (sp_adj1, sp_adj2));
+ }
+ sp_adj2 = GEN_INT (low);
+ }
else
- add_long_const (file, frame_size, 30, 30, 1);
+ {
+ rtx tmp = gen_rtx_REG (DImode, 23);
+ FRP (sp_adj2 = alpha_emit_set_const (tmp, DImode, frame_size, 3));
+ if (!sp_adj2)
+ {
+ /* We can't drop new things to memory this late, afaik,
+ so build it up by pieces. */
+ FRP (sp_adj2 = alpha_emit_set_long_const (tmp, frame_size,
+ -(frame_size < 0)));
+ if (!sp_adj2)
+ abort ();
+ }
+ }
+
+ /* From now on, things must be in order. So emit blockages. */
- /* Finally return to the caller. */
- fprintf (file, "\tret $31,($26),1\n");
+ /* Restore the frame pointer. */
+ if (fp_is_frame_pointer)
+ {
+ emit_insn (gen_blockage ());
+ mem = gen_rtx_MEM (DImode, plus_constant(sa_reg, fp_offset));
+ MEM_ALIAS_SET (mem) = alpha_sr_alias_set;
+ FRP (emit_move_insn (hard_frame_pointer_rtx, mem));
+ }
+ else if (TARGET_OPEN_VMS)
+ {
+ emit_insn (gen_blockage ());
+ FRP (emit_move_insn (hard_frame_pointer_rtx,
+ gen_rtx_REG (DImode, vms_save_fp_regno)));
+ }
+
+ /* Restore the stack pointer. */
+ emit_insn (gen_blockage ());
+ FRP (emit_move_insn (stack_pointer_rtx,
+ gen_rtx_PLUS (DImode, sp_adj1, sp_adj2)));
+ }
+ else
+ {
+ if (TARGET_OPEN_VMS && !vms_is_stack_procedure)
+ {
+ emit_insn (gen_blockage ());
+ FRP (emit_move_insn (hard_frame_pointer_rtx,
+ gen_rtx_REG (DImode, vms_save_fp_regno)));
+ }
}
+ /* Return. */
+ emit_jump_insn (gen_return_internal ());
+}
+
+/* Output the rest of the textual info surrounding the epilogue. */
+
+void
+alpha_end_function (file, fnname, decl)
+ FILE *file;
+ char *fnname;
+ tree decl ATTRIBUTE_UNUSED;
+{
/* End the function. */
- fprintf (file, "\t.end ");
- assemble_name (file, alpha_function_name);
- fprintf (file, "\n");
+ if (!flag_inhibit_size_directive)
+ {
+ fputs ("\t.end ", file);
+ assemble_name (file, fnname);
+ putc ('\n', file);
+ }
inside_function = FALSE;
- /* Show that we know this function if it is called again. */
- SYMBOL_REF_FLAG (XEXP (DECL_RTL (current_function_decl), 0)) = 1;
+ /* Show that we know this function if it is called again.
+
+ Don't do this for global functions in object files destined for a
+ shared library because the function may be overridden by the application
+ or other libraries. Similarly, don't do this for weak functions. */
+
+ if (!DECL_WEAK (current_function_decl)
+ && (!flag_pic || !TREE_PUBLIC (current_function_decl)))
+ SYMBOL_REF_FLAG (XEXP (DECL_RTL (current_function_decl), 0)) = 1;
}
/* Debugging support. */
@@ -1627,7 +4110,7 @@ static int num_source_filenames = 0;
/* Name of the file containing the current function. */
-static char *current_function_file = "";
+static const char *current_function_file = "";
/* Offsets to alpha virtual arg/local debugging pointers. */
@@ -1656,7 +4139,7 @@ alpha_output_filename (stream, name)
fprintf (stream, "\t#@stabs\n");
}
- else if (!TARGET_GAS && write_symbols == DBX_DEBUG)
+ else if (write_symbols == DBX_DEBUG)
{
ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext", 0);
fprintf (stream, "%s ", ASM_STABS_OP);
@@ -1665,7 +4148,7 @@ alpha_output_filename (stream, name)
}
else if (name != current_function_file
- && strcmp (name, current_function_file) != 0)
+ && strcmp (name, current_function_file) != 0)
{
if (inside_function && ! TARGET_GAS)
fprintf (stream, "\t#.file\t%d ", num_source_filenames);
@@ -1688,7 +4171,7 @@ alpha_output_lineno (stream, line)
FILE *stream;
int line;
{
- if (! TARGET_GAS && write_symbols == DBX_DEBUG)
+ if (write_symbols == DBX_DEBUG)
{
/* mips-tfile doesn't understand .stabd directives. */
++sym_lineno;
@@ -1698,3 +4181,1100 @@ alpha_output_lineno (stream, line)
else
fprintf (stream, "\n\t.loc\t%d %d\n", num_source_filenames, line);
}
+
+/* Structure to show the current status of registers and memory. */
+
+struct shadow_summary
+{
+ struct {
+ unsigned long i : 31; /* Mask of int regs */
+ unsigned long fp : 31; /* Mask of fp regs */
+ unsigned long mem : 1; /* mem == imem | fpmem */
+ } used, defd;
+};
+
+static void summarize_insn PROTO((rtx, struct shadow_summary *, int));
+static void alpha_handle_trap_shadows PROTO((rtx));
+
+/* Summary the effects of expression X on the machine. Update SUM, a pointer
+ to the summary structure. SET is nonzero if the insn is setting the
+ object, otherwise zero. */
+
+static void
+summarize_insn (x, sum, set)
+ rtx x;
+ struct shadow_summary *sum;
+ int set;
+{
+ char *format_ptr;
+ int i, j;
+
+ if (x == 0)
+ return;
+
+ switch (GET_CODE (x))
+ {
+ /* ??? Note that this case would be incorrect if the Alpha had a
+ ZERO_EXTRACT in SET_DEST. */
+ case SET:
+ summarize_insn (SET_SRC (x), sum, 0);
+ summarize_insn (SET_DEST (x), sum, 1);
+ break;
+
+ case CLOBBER:
+ summarize_insn (XEXP (x, 0), sum, 1);
+ break;
+
+ case USE:
+ summarize_insn (XEXP (x, 0), sum, 0);
+ break;
+
+ case ASM_OPERANDS:
+ for (i = ASM_OPERANDS_INPUT_LENGTH (x) - 1; i >= 0; i--)
+ summarize_insn (ASM_OPERANDS_INPUT (x, i), sum, 0);
+ break;
+
+ case PARALLEL:
+ for (i = XVECLEN (x, 0) - 1; i >= 0; i--)
+ summarize_insn (XVECEXP (x, 0, i), sum, 0);
+ break;
+
+ case SUBREG:
+ summarize_insn (SUBREG_REG (x), sum, 0);
+ break;
+
+ case REG:
+ {
+ int regno = REGNO (x);
+ unsigned long mask = 1UL << (regno % 32);
+
+ if (regno == 31 || regno == 63)
+ break;
+
+ if (set)
+ {
+ if (regno < 32)
+ sum->defd.i |= mask;
+ else
+ sum->defd.fp |= mask;
+ }
+ else
+ {
+ if (regno < 32)
+ sum->used.i |= mask;
+ else
+ sum->used.fp |= mask;
+ }
+ }
+ break;
+
+ case MEM:
+ if (set)
+ sum->defd.mem = 1;
+ else
+ sum->used.mem = 1;
+
+ /* Find the regs used in memory address computation: */
+ summarize_insn (XEXP (x, 0), sum, 0);
+ break;
+
+ case CONST_INT: case CONST_DOUBLE:
+ case SYMBOL_REF: case LABEL_REF: case CONST:
+ break;
+
+ /* Handle common unary and binary ops for efficiency. */
+ case COMPARE: case PLUS: case MINUS: case MULT: case DIV:
+ case MOD: case UDIV: case UMOD: case AND: case IOR:
+ case XOR: case ASHIFT: case ROTATE: case ASHIFTRT: case LSHIFTRT:
+ case ROTATERT: case SMIN: case SMAX: case UMIN: case UMAX:
+ case NE: case EQ: case GE: case GT: case LE:
+ case LT: case GEU: case GTU: case LEU: case LTU:
+ summarize_insn (XEXP (x, 0), sum, 0);
+ summarize_insn (XEXP (x, 1), sum, 0);
+ break;
+
+ case NEG: case NOT: case SIGN_EXTEND: case ZERO_EXTEND:
+ case TRUNCATE: case FLOAT_EXTEND: case FLOAT_TRUNCATE: case FLOAT:
+ case FIX: case UNSIGNED_FLOAT: case UNSIGNED_FIX: case ABS:
+ case SQRT: case FFS:
+ summarize_insn (XEXP (x, 0), sum, 0);
+ break;
+
+ default:
+ format_ptr = GET_RTX_FORMAT (GET_CODE (x));
+ for (i = GET_RTX_LENGTH (GET_CODE (x)) - 1; i >= 0; i--)
+ switch (format_ptr[i])
+ {
+ case 'e':
+ summarize_insn (XEXP (x, i), sum, 0);
+ break;
+
+ case 'E':
+ for (j = XVECLEN (x, i) - 1; j >= 0; j--)
+ summarize_insn (XVECEXP (x, i, j), sum, 0);
+ break;
+
+ case 'i':
+ break;
+
+ default:
+ abort ();
+ }
+ }
+}
+
+/* Ensure a sufficient number of `trapb' insns are in the code when
+ the user requests code with a trap precision of functions or
+ instructions.
+
+ In naive mode, when the user requests a trap-precision of
+ "instruction", a trapb is needed after every instruction that may
+ generate a trap. This ensures that the code is resumption safe but
+ it is also slow.
+
+ When optimizations are turned on, we delay issuing a trapb as long
+ as possible. In this context, a trap shadow is the sequence of
+ instructions that starts with a (potentially) trap generating
+ instruction and extends to the next trapb or call_pal instruction
+ (but GCC never generates call_pal by itself). We can delay (and
+ therefore sometimes omit) a trapb subject to the following
+ conditions:
+
+ (a) On entry to the trap shadow, if any Alpha register or memory
+ location contains a value that is used as an operand value by some
+ instruction in the trap shadow (live on entry), then no instruction
+ in the trap shadow may modify the register or memory location.
+
+ (b) Within the trap shadow, the computation of the base register
+ for a memory load or store instruction may not involve using the
+ result of an instruction that might generate an UNPREDICTABLE
+ result.
+
+ (c) Within the trap shadow, no register may be used more than once
+ as a destination register. (This is to make life easier for the
+ trap-handler.)
+
+ (d) The trap shadow may not include any branch instructions. */
+
+static void
+alpha_handle_trap_shadows (insns)
+ rtx insns;
+{
+ struct shadow_summary shadow;
+ int trap_pending, exception_nesting;
+ rtx i, n;
+
+ trap_pending = 0;
+ exception_nesting = 0;
+ shadow.used.i = 0;
+ shadow.used.fp = 0;
+ shadow.used.mem = 0;
+ shadow.defd = shadow.used;
+
+ for (i = insns; i ; i = NEXT_INSN (i))
+ {
+ if (GET_CODE (i) == NOTE)
+ {
+ switch (NOTE_LINE_NUMBER (i))
+ {
+ case NOTE_INSN_EH_REGION_BEG:
+ exception_nesting++;
+ if (trap_pending)
+ goto close_shadow;
+ break;
+
+ case NOTE_INSN_EH_REGION_END:
+ exception_nesting--;
+ if (trap_pending)
+ goto close_shadow;
+ break;
+
+ case NOTE_INSN_EPILOGUE_BEG:
+ if (trap_pending && alpha_tp >= ALPHA_TP_FUNC)
+ goto close_shadow;
+ break;
+ }
+ }
+ else if (trap_pending)
+ {
+ if (alpha_tp == ALPHA_TP_FUNC)
+ {
+ if (GET_CODE (i) == JUMP_INSN
+ && GET_CODE (PATTERN (i)) == RETURN)
+ goto close_shadow;
+ }
+ else if (alpha_tp == ALPHA_TP_INSN)
+ {
+ if (optimize > 0)
+ {
+ struct shadow_summary sum;
+
+ sum.used.i = 0;
+ sum.used.fp = 0;
+ sum.used.mem = 0;
+ sum.defd = sum.used;
+
+ switch (GET_CODE (i))
+ {
+ case INSN:
+ /* Annoyingly, get_attr_trap will abort on these. */
+ if (GET_CODE (PATTERN (i)) == USE
+ || GET_CODE (PATTERN (i)) == CLOBBER)
+ break;
+
+ summarize_insn (PATTERN (i), &sum, 0);
+
+ if ((sum.defd.i & shadow.defd.i)
+ || (sum.defd.fp & shadow.defd.fp))
+ {
+ /* (c) would be violated */
+ goto close_shadow;
+ }
+
+ /* Combine shadow with summary of current insn: */
+ shadow.used.i |= sum.used.i;
+ shadow.used.fp |= sum.used.fp;
+ shadow.used.mem |= sum.used.mem;
+ shadow.defd.i |= sum.defd.i;
+ shadow.defd.fp |= sum.defd.fp;
+ shadow.defd.mem |= sum.defd.mem;
+
+ if ((sum.defd.i & shadow.used.i)
+ || (sum.defd.fp & shadow.used.fp)
+ || (sum.defd.mem & shadow.used.mem))
+ {
+ /* (a) would be violated (also takes care of (b)) */
+ if (get_attr_trap (i) == TRAP_YES
+ && ((sum.defd.i & sum.used.i)
+ || (sum.defd.fp & sum.used.fp)))
+ abort ();
+
+ goto close_shadow;
+ }
+ break;
+
+ case JUMP_INSN:
+ case CALL_INSN:
+ case CODE_LABEL:
+ goto close_shadow;
+
+ default:
+ abort ();
+ }
+ }
+ else
+ {
+ close_shadow:
+ n = emit_insn_before (gen_trapb (), i);
+ PUT_MODE (n, TImode);
+ PUT_MODE (i, TImode);
+ trap_pending = 0;
+ shadow.used.i = 0;
+ shadow.used.fp = 0;
+ shadow.used.mem = 0;
+ shadow.defd = shadow.used;
+ }
+ }
+ }
+
+ if ((exception_nesting > 0 || alpha_tp >= ALPHA_TP_FUNC)
+ && GET_CODE (i) == INSN
+ && GET_CODE (PATTERN (i)) != USE
+ && GET_CODE (PATTERN (i)) != CLOBBER
+ && get_attr_trap (i) == TRAP_YES)
+ {
+ if (optimize && !trap_pending)
+ summarize_insn (PATTERN (i), &shadow, 0);
+ trap_pending = 1;
+ }
+ }
+}
+
+#ifdef HAIFA
+/* Alpha can only issue instruction groups simultaneously if they are
+ suitibly aligned. This is very processor-specific. */
+
+enum alphaev4_pipe {
+ EV4_STOP = 0,
+ EV4_IB0 = 1,
+ EV4_IB1 = 2,
+ EV4_IBX = 4
+};
+
+enum alphaev5_pipe {
+ EV5_STOP = 0,
+ EV5_NONE = 1,
+ EV5_E01 = 2,
+ EV5_E0 = 4,
+ EV5_E1 = 8,
+ EV5_FAM = 16,
+ EV5_FA = 32,
+ EV5_FM = 64
+};
+
+static enum alphaev4_pipe alphaev4_insn_pipe PROTO((rtx));
+static enum alphaev5_pipe alphaev5_insn_pipe PROTO((rtx));
+static rtx alphaev4_next_group PROTO((rtx, int*, int*));
+static rtx alphaev5_next_group PROTO((rtx, int*, int*));
+static rtx alphaev4_next_nop PROTO((int*));
+static rtx alphaev5_next_nop PROTO((int*));
+
+static void alpha_align_insns
+ PROTO((rtx, int, rtx (*)(rtx, int*, int*), rtx (*)(int*), int));
+
+static enum alphaev4_pipe
+alphaev4_insn_pipe (insn)
+ rtx insn;
+{
+ if (recog_memoized (insn) < 0)
+ return EV4_STOP;
+ if (get_attr_length (insn) != 4)
+ return EV4_STOP;
+
+ switch (get_attr_type (insn))
+ {
+ case TYPE_ILD:
+ case TYPE_FLD:
+ return EV4_IBX;
+
+ case TYPE_LDSYM:
+ case TYPE_IADD:
+ case TYPE_ILOG:
+ case TYPE_ICMOV:
+ case TYPE_ICMP:
+ case TYPE_IST:
+ case TYPE_FST:
+ case TYPE_SHIFT:
+ case TYPE_IMUL:
+ case TYPE_FBR:
+ return EV4_IB0;
+
+ case TYPE_MISC:
+ case TYPE_IBR:
+ case TYPE_JSR:
+ case TYPE_FCPYS:
+ case TYPE_FCMOV:
+ case TYPE_FADD:
+ case TYPE_FDIV:
+ case TYPE_FMUL:
+ return EV4_IB1;
+
+ default:
+ abort();
+ }
+}
+
+static enum alphaev5_pipe
+alphaev5_insn_pipe (insn)
+ rtx insn;
+{
+ if (recog_memoized (insn) < 0)
+ return EV5_STOP;
+ if (get_attr_length (insn) != 4)
+ return EV5_STOP;
+
+ switch (get_attr_type (insn))
+ {
+ case TYPE_ILD:
+ case TYPE_FLD:
+ case TYPE_LDSYM:
+ case TYPE_IADD:
+ case TYPE_ILOG:
+ case TYPE_ICMOV:
+ case TYPE_ICMP:
+ return EV5_E01;
+
+ case TYPE_IST:
+ case TYPE_FST:
+ case TYPE_SHIFT:
+ case TYPE_IMUL:
+ case TYPE_MISC:
+ case TYPE_MVI:
+ return EV5_E0;
+
+ case TYPE_IBR:
+ case TYPE_JSR:
+ return EV5_E1;
+
+ case TYPE_FCPYS:
+ return EV5_FAM;
+
+ case TYPE_FBR:
+ case TYPE_FCMOV:
+ case TYPE_FADD:
+ case TYPE_FDIV:
+ return EV5_FA;
+
+ case TYPE_FMUL:
+ return EV5_FM;
+
+ default:
+ abort();
+ }
+}
+
+/* IN_USE is a mask of the slots currently filled within the insn group.
+ The mask bits come from alphaev4_pipe above. If EV4_IBX is set, then
+ the insn in EV4_IB0 can be swapped by the hardware into EV4_IB1.
+
+ LEN is, of course, the length of the group in bytes. */
+
+static rtx
+alphaev4_next_group (insn, pin_use, plen)
+ rtx insn;
+ int *pin_use, *plen;
+{
+ int len, in_use;
+
+ len = in_use = 0;
+
+ if (GET_RTX_CLASS (GET_CODE (insn)) != 'i'
+ || GET_CODE (PATTERN (insn)) == CLOBBER
+ || GET_CODE (PATTERN (insn)) == USE)
+ goto next_and_done;
+
+ while (1)
+ {
+ enum alphaev4_pipe pipe;
+
+ pipe = alphaev4_insn_pipe (insn);
+ switch (pipe)
+ {
+ case EV4_STOP:
+ /* Force complex instructions to start new groups. */
+ if (in_use)
+ goto done;
+
+ /* If this is a completely unrecognized insn, its an asm.
+ We don't know how long it is, so record length as -1 to
+ signal a needed realignment. */
+ if (recog_memoized (insn) < 0)
+ len = -1;
+ else
+ len = get_attr_length (insn);
+ goto next_and_done;
+
+ case EV4_IBX:
+ if (in_use & EV4_IB0)
+ {
+ if (in_use & EV4_IB1)
+ goto done;
+ in_use |= EV4_IB1;
+ }
+ else
+ in_use |= EV4_IB0 | EV4_IBX;
+ break;
+
+ case EV4_IB0:
+ if (in_use & EV4_IB0)
+ {
+ if (!(in_use & EV4_IBX) || (in_use & EV4_IB1))
+ goto done;
+ in_use |= EV4_IB1;
+ }
+ in_use |= EV4_IB0;
+ break;
+
+ case EV4_IB1:
+ if (in_use & EV4_IB1)
+ goto done;
+ in_use |= EV4_IB1;
+ break;
+
+ default:
+ abort();
+ }
+ len += 4;
+
+ /* Haifa doesn't do well scheduling branches. */
+ if (GET_CODE (insn) == JUMP_INSN)
+ goto next_and_done;
+
+ next:
+ insn = next_nonnote_insn (insn);
+
+ if (!insn || GET_RTX_CLASS (GET_CODE (insn)) != 'i')
+ goto done;
+
+ /* Let Haifa tell us where it thinks insn group boundaries are. */
+ if (GET_MODE (insn) == TImode)
+ goto done;
+
+ if (GET_CODE (insn) == CLOBBER || GET_CODE (insn) == USE)
+ goto next;
+ }
+
+ next_and_done:
+ insn = next_nonnote_insn (insn);
+
+ done:
+ *plen = len;
+ *pin_use = in_use;
+ return insn;
+}
+
+/* IN_USE is a mask of the slots currently filled within the insn group.
+ The mask bits come from alphaev5_pipe above. If EV5_E01 is set, then
+ the insn in EV5_E0 can be swapped by the hardware into EV5_E1.
+
+ LEN is, of course, the length of the group in bytes. */
+
+static rtx
+alphaev5_next_group (insn, pin_use, plen)
+ rtx insn;
+ int *pin_use, *plen;
+{
+ int len, in_use;
+
+ len = in_use = 0;
+
+ if (GET_RTX_CLASS (GET_CODE (insn)) != 'i'
+ || GET_CODE (PATTERN (insn)) == CLOBBER
+ || GET_CODE (PATTERN (insn)) == USE)
+ goto next_and_done;
+
+ while (1)
+ {
+ enum alphaev5_pipe pipe;
+
+ pipe = alphaev5_insn_pipe (insn);
+ switch (pipe)
+ {
+ case EV5_STOP:
+ /* Force complex instructions to start new groups. */
+ if (in_use)
+ goto done;
+
+ /* If this is a completely unrecognized insn, its an asm.
+ We don't know how long it is, so record length as -1 to
+ signal a needed realignment. */
+ if (recog_memoized (insn) < 0)
+ len = -1;
+ else
+ len = get_attr_length (insn);
+ goto next_and_done;
+
+ /* ??? Most of the places below, we would like to abort, as
+ it would indicate an error either in Haifa, or in the
+ scheduling description. Unfortunately, Haifa never
+ schedules the last instruction of the BB, so we don't
+ have an accurate TI bit to go off. */
+ case EV5_E01:
+ if (in_use & EV5_E0)
+ {
+ if (in_use & EV5_E1)
+ goto done;
+ in_use |= EV5_E1;
+ }
+ else
+ in_use |= EV5_E0 | EV5_E01;
+ break;
+
+ case EV5_E0:
+ if (in_use & EV5_E0)
+ {
+ if (!(in_use & EV5_E01) || (in_use & EV5_E1))
+ goto done;
+ in_use |= EV5_E1;
+ }
+ in_use |= EV5_E0;
+ break;
+
+ case EV5_E1:
+ if (in_use & EV5_E1)
+ goto done;
+ in_use |= EV5_E1;
+ break;
+
+ case EV5_FAM:
+ if (in_use & EV5_FA)
+ {
+ if (in_use & EV5_FM)
+ goto done;
+ in_use |= EV5_FM;
+ }
+ else
+ in_use |= EV5_FA | EV5_FAM;
+ break;
+
+ case EV5_FA:
+ if (in_use & EV5_FA)
+ goto done;
+ in_use |= EV5_FA;
+ break;
+
+ case EV5_FM:
+ if (in_use & EV5_FM)
+ goto done;
+ in_use |= EV5_FM;
+ break;
+
+ case EV5_NONE:
+ break;
+
+ default:
+ abort();
+ }
+ len += 4;
+
+ /* Haifa doesn't do well scheduling branches. */
+ /* ??? If this is predicted not-taken, slotting continues, except
+ that no more IBR, FBR, or JSR insns may be slotted. */
+ if (GET_CODE (insn) == JUMP_INSN)
+ goto next_and_done;
+
+ next:
+ insn = next_nonnote_insn (insn);
+
+ if (!insn || GET_RTX_CLASS (GET_CODE (insn)) != 'i')
+ goto done;
+
+ /* Let Haifa tell us where it thinks insn group boundaries are. */
+ if (GET_MODE (insn) == TImode)
+ goto done;
+
+ if (GET_CODE (insn) == CLOBBER || GET_CODE (insn) == USE)
+ goto next;
+ }
+
+ next_and_done:
+ insn = next_nonnote_insn (insn);
+
+ done:
+ *plen = len;
+ *pin_use = in_use;
+ return insn;
+}
+
+static rtx
+alphaev4_next_nop (pin_use)
+ int *pin_use;
+{
+ int in_use = *pin_use;
+ rtx nop;
+
+ if (!(in_use & EV4_IB0))
+ {
+ in_use |= EV4_IB0;
+ nop = gen_nop ();
+ }
+ else if ((in_use & (EV4_IBX|EV4_IB1)) == EV4_IBX)
+ {
+ in_use |= EV4_IB1;
+ nop = gen_nop ();
+ }
+ else if (TARGET_FP && !(in_use & EV4_IB1))
+ {
+ in_use |= EV4_IB1;
+ nop = gen_fnop ();
+ }
+ else
+ nop = gen_unop ();
+
+ *pin_use = in_use;
+ return nop;
+}
+
+static rtx
+alphaev5_next_nop (pin_use)
+ int *pin_use;
+{
+ int in_use = *pin_use;
+ rtx nop;
+
+ if (!(in_use & EV5_E1))
+ {
+ in_use |= EV5_E1;
+ nop = gen_nop ();
+ }
+ else if (TARGET_FP && !(in_use & EV5_FA))
+ {
+ in_use |= EV5_FA;
+ nop = gen_fnop ();
+ }
+ else if (TARGET_FP && !(in_use & EV5_FM))
+ {
+ in_use |= EV5_FM;
+ nop = gen_fnop ();
+ }
+ else
+ nop = gen_unop ();
+
+ *pin_use = in_use;
+ return nop;
+}
+
+/* The instruction group alignment main loop. */
+
+static void
+alpha_align_insns (insns, max_align, next_group, next_nop, gp_in_use)
+ rtx insns;
+ int max_align;
+ rtx (*next_group) PROTO((rtx, int*, int*));
+ rtx (*next_nop) PROTO((int*));
+ int gp_in_use;
+{
+ /* ALIGN is the known alignment for the insn group. */
+ int align;
+ /* OFS is the offset of the current insn in the insn group. */
+ int ofs;
+ int prev_in_use, in_use, len;
+ rtx i, next;
+
+ /* Let shorten branches care for assigning alignments to code labels. */
+ shorten_branches (insns);
+
+ align = (FUNCTION_BOUNDARY/BITS_PER_UNIT < max_align
+ ? FUNCTION_BOUNDARY/BITS_PER_UNIT : max_align);
+
+ /* Account for the initial GP load, which happens before the scheduled
+ prologue we emitted as RTL. */
+ ofs = prev_in_use = 0;
+ if (alpha_does_function_need_gp())
+ {
+ ofs = 8 & (align - 1);
+ prev_in_use = gp_in_use;
+ }
+
+ i = insns;
+ if (GET_CODE (i) == NOTE)
+ i = next_nonnote_insn (i);
+
+ while (i)
+ {
+ next = (*next_group)(i, &in_use, &len);
+
+ /* When we see a label, resync alignment etc. */
+ if (GET_CODE (i) == CODE_LABEL)
+ {
+ int new_align = 1 << label_to_alignment (i);
+ if (new_align >= align)
+ {
+ align = new_align < max_align ? new_align : max_align;
+ ofs = 0;
+ }
+ else if (ofs & (new_align-1))
+ ofs = (ofs | (new_align-1)) + 1;
+ if (len != 0)
+ abort();
+ }
+
+ /* Handle complex instructions special. */
+ else if (in_use == 0)
+ {
+ /* Asms will have length < 0. This is a signal that we have
+ lost alignment knowledge. Assume, however, that the asm
+ will not mis-align instructions. */
+ if (len < 0)
+ {
+ ofs = 0;
+ align = 4;
+ len = 0;
+ }
+ }
+
+ /* If the known alignment is smaller than the recognized insn group,
+ realign the output. */
+ else if (align < len)
+ {
+ int new_log_align = len > 8 ? 4 : 3;
+ rtx where;
+
+ where = prev_nonnote_insn (i);
+ if (!where || GET_CODE (where) != CODE_LABEL)
+ where = i;
+
+ emit_insn_before (gen_realign (GEN_INT (new_log_align)), where);
+ align = 1 << new_log_align;
+ ofs = 0;
+ }
+
+ /* If the group won't fit in the same INT16 as the previous,
+ we need to add padding to keep the group together. Rather
+ than simply leaving the insn filling to the assembler, we
+ can make use of the knowledge of what sorts of instructions
+ were issued in the previous group to make sure that all of
+ the added nops are really free. */
+ else if (ofs + len > align)
+ {
+ int nop_count = (align - ofs) / 4;
+ rtx where;
+
+ /* Insert nops before labels and branches to truely merge the
+ execution of the nops with the previous instruction group. */
+ where = prev_nonnote_insn (i);
+ if (where)
+ {
+ if (GET_CODE (where) == CODE_LABEL)
+ {
+ rtx where2 = prev_nonnote_insn (where);
+ if (where2 && GET_CODE (where2) == JUMP_INSN)
+ where = where2;
+ }
+ else if (GET_CODE (where) != JUMP_INSN)
+ where = i;
+ }
+ else
+ where = i;
+
+ do
+ emit_insn_before ((*next_nop)(&prev_in_use), where);
+ while (--nop_count);
+ ofs = 0;
+ }
+
+ ofs = (ofs + len) & (align - 1);
+ prev_in_use = in_use;
+ i = next;
+ }
+}
+#endif /* HAIFA */
+
+/* Machine dependant reorg pass. */
+
+void
+alpha_reorg (insns)
+ rtx insns;
+{
+ if (alpha_tp != ALPHA_TP_PROG || flag_exceptions)
+ alpha_handle_trap_shadows (insns);
+
+#ifdef HAIFA
+ /* Due to the number of extra trapb insns, don't bother fixing up
+ alignment when trap precision is instruction. Moreover, we can
+ only do our job when sched2 is run and Haifa is our scheduler. */
+ if (optimize && !optimize_size
+ && alpha_tp != ALPHA_TP_INSN
+ && flag_schedule_insns_after_reload)
+ {
+ if (alpha_cpu == PROCESSOR_EV4)
+ alpha_align_insns (insns, 8, alphaev4_next_group,
+ alphaev4_next_nop, EV4_IB0);
+ else if (alpha_cpu == PROCESSOR_EV5)
+ alpha_align_insns (insns, 16, alphaev5_next_group,
+ alphaev5_next_nop, EV5_E01 | EV5_E0);
+ }
+#endif
+}
+
+
+/* Check a floating-point value for validity for a particular machine mode. */
+
+static char * const float_strings[] =
+{
+ /* These are for FLOAT_VAX. */
+ "1.70141173319264430e+38", /* 2^127 (2^24 - 1) / 2^24 */
+ "-1.70141173319264430e+38",
+ "2.93873587705571877e-39", /* 2^-128 */
+ "-2.93873587705571877e-39",
+ /* These are for the default broken IEEE mode, which traps
+ on infinity or denormal numbers. */
+ "3.402823466385288598117e+38", /* 2^128 (1 - 2^-24) */
+ "-3.402823466385288598117e+38",
+ "1.1754943508222875079687e-38", /* 2^-126 */
+ "-1.1754943508222875079687e-38",
+};
+
+static REAL_VALUE_TYPE float_values[8];
+static int inited_float_values = 0;
+
+int
+check_float_value (mode, d, overflow)
+ enum machine_mode mode;
+ REAL_VALUE_TYPE *d;
+ int overflow ATTRIBUTE_UNUSED;
+{
+
+ if (TARGET_IEEE || TARGET_IEEE_CONFORMANT || TARGET_IEEE_WITH_INEXACT)
+ return 0;
+
+ if (inited_float_values == 0)
+ {
+ int i;
+ for (i = 0; i < 8; i++)
+ float_values[i] = REAL_VALUE_ATOF (float_strings[i], DFmode);
+
+ inited_float_values = 1;
+ }
+
+ if (mode == SFmode)
+ {
+ REAL_VALUE_TYPE r;
+ REAL_VALUE_TYPE *fvptr;
+
+ if (TARGET_FLOAT_VAX)
+ fvptr = &float_values[0];
+ else
+ fvptr = &float_values[4];
+
+ bcopy ((char *) d, (char *) &r, sizeof (REAL_VALUE_TYPE));
+ if (REAL_VALUES_LESS (fvptr[0], r))
+ {
+ bcopy ((char *) &fvptr[0], (char *) d,
+ sizeof (REAL_VALUE_TYPE));
+ return 1;
+ }
+ else if (REAL_VALUES_LESS (r, fvptr[1]))
+ {
+ bcopy ((char *) &fvptr[1], (char *) d,
+ sizeof (REAL_VALUE_TYPE));
+ return 1;
+ }
+ else if (REAL_VALUES_LESS (dconst0, r)
+ && REAL_VALUES_LESS (r, fvptr[2]))
+ {
+ bcopy ((char *) &dconst0, (char *) d, sizeof (REAL_VALUE_TYPE));
+ return 1;
+ }
+ else if (REAL_VALUES_LESS (r, dconst0)
+ && REAL_VALUES_LESS (fvptr[3], r))
+ {
+ bcopy ((char *) &dconst0, (char *) d, sizeof (REAL_VALUE_TYPE));
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+#if OPEN_VMS
+
+/* Return the VMS argument type corresponding to MODE. */
+
+enum avms_arg_type
+alpha_arg_type (mode)
+ enum machine_mode mode;
+{
+ switch (mode)
+ {
+ case SFmode:
+ return TARGET_FLOAT_VAX ? FF : FS;
+ case DFmode:
+ return TARGET_FLOAT_VAX ? FD : FT;
+ default:
+ return I64;
+ }
+}
+
+/* Return an rtx for an integer representing the VMS Argument Information
+ register value. */
+
+struct rtx_def *
+alpha_arg_info_reg_val (cum)
+ CUMULATIVE_ARGS cum;
+{
+ unsigned HOST_WIDE_INT regval = cum.num_args;
+ int i;
+
+ for (i = 0; i < 6; i++)
+ regval |= ((int) cum.atypes[i]) << (i * 3 + 8);
+
+ return GEN_INT (regval);
+}
+
+/* Structure to collect function names for final output
+ in link section. */
+
+enum links_kind {KIND_UNUSED, KIND_LOCAL, KIND_EXTERN};
+
+
+struct alpha_links {
+ struct alpha_links *next;
+ char *name;
+ enum links_kind kind;
+};
+
+static struct alpha_links *alpha_links_base = 0;
+
+/* Make (or fake) .linkage entry for function call.
+
+ IS_LOCAL is 0 if name is used in call, 1 if name is used in definition. */
+
+void
+alpha_need_linkage (name, is_local)
+ char *name;
+ int is_local;
+{
+ rtx x;
+ struct alpha_links *lptr, *nptr;
+
+ if (name[0] == '*')
+ name++;
+
+ /* Is this name already defined ? */
+
+ for (lptr = alpha_links_base; lptr; lptr = lptr->next)
+ if (strcmp (lptr->name, name) == 0)
+ {
+ if (is_local)
+ {
+ /* Defined here but external assumed. */
+ if (lptr->kind == KIND_EXTERN)
+ lptr->kind = KIND_LOCAL;
+ }
+ else
+ {
+ /* Used here but unused assumed. */
+ if (lptr->kind == KIND_UNUSED)
+ lptr->kind = KIND_LOCAL;
+ }
+ return;
+ }
+
+ nptr = (struct alpha_links *) xmalloc (sizeof (struct alpha_links));
+ nptr->next = alpha_links_base;
+ nptr->name = xstrdup (name);
+
+ /* Assume external if no definition. */
+ nptr->kind = (is_local ? KIND_UNUSED : KIND_EXTERN);
+
+ /* Ensure we have an IDENTIFIER so assemble_name can mark is used. */
+ get_identifier (name);
+
+ alpha_links_base = nptr;
+
+ return;
+}
+
+
+void
+alpha_write_linkage (stream)
+ FILE *stream;
+{
+ struct alpha_links *lptr, *nptr;
+
+ readonly_section ();
+
+ fprintf (stream, "\t.align 3\n");
+
+ for (lptr = alpha_links_base; lptr; lptr = nptr)
+ {
+ nptr = lptr->next;
+
+ if (lptr->kind == KIND_UNUSED
+ || ! TREE_SYMBOL_REFERENCED (get_identifier (lptr->name)))
+ continue;
+
+ fprintf (stream, "$%s..lk:\n", lptr->name);
+ if (lptr->kind == KIND_LOCAL)
+ {
+ /* Local and used, build linkage pair. */
+ fprintf (stream, "\t.quad %s..en\n", lptr->name);
+ fprintf (stream, "\t.quad %s\n", lptr->name);
+ }
+ else
+ /* External and used, request linkage pair. */
+ fprintf (stream, "\t.linkage %s\n", lptr->name);
+ }
+}
+
+#else
+
+void
+alpha_need_linkage (name, is_local)
+ char *name ATTRIBUTE_UNUSED;
+ int is_local ATTRIBUTE_UNUSED;
+{
+}
+
+#endif /* OPEN_VMS */
diff --git a/contrib/gcc/config/alpha/gdb-osf12.h b/contrib/gcc/config/alpha/gdb-osf12.h
deleted file mode 100644
index 98c289714017..000000000000
--- a/contrib/gcc/config/alpha/gdb-osf12.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/* Definitions of target machine for GNU compiler, for DEC Alpha, using
- encapsulated stabs and OSF V1.2.
- Copyright (C) 1994 Free Software Foundation, Inc.
- Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-#include "alpha/osf12.h"
-
-#undef PREFERRED_DEBUGGING_TYPE
-#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
diff --git a/contrib/gcc/config/alpha/gdb-osf2.h b/contrib/gcc/config/alpha/gdb-osf2.h
deleted file mode 100644
index 5ddb7981b34d..000000000000
--- a/contrib/gcc/config/alpha/gdb-osf2.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/* Definitions of target machine for GNU compiler, for DEC Alpha, using
- encapsulated stabs.
- Copyright (C) 1992, 1993 Free Software Foundation, Inc.
- Contributed by Peter Schauer (pes@regent.e-technik.tu-muenchen.de).
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-#include "alpha/osf2.h"
-
-#undef PREFERRED_DEBUGGING_TYPE
-#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
diff --git a/contrib/gcc/config/alpha/gdb.h b/contrib/gcc/config/alpha/gdb.h
deleted file mode 100644
index ecdbe40a9a45..000000000000
--- a/contrib/gcc/config/alpha/gdb.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/* Definitions of target machine for GNU compiler, for DEC Alpha, using
- encapsulated stabs.
- Copyright (C) 1992, 1993 Free Software Foundation, Inc.
- Contributed by Peter Schauer (pes@regent.e-technik.tu-muenchen.de).
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-#include "alpha/alpha.h"
-
-#undef PREFERRED_DEBUGGING_TYPE
-#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
diff --git a/contrib/gcc/config/alpha/osf2.h b/contrib/gcc/config/alpha/osf2.h
deleted file mode 100644
index 169af5a01c97..000000000000
--- a/contrib/gcc/config/alpha/osf2.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Definitions of target machine for GNU compiler, for DEC Alpha.
- Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
- Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-
-#include "alpha/alpha.h"
-
-/* In OSF 2.0, the size of wchar_t was changed from short unsigned
- to unsigned int. */
-
-#undef WCHAR_TYPE
-#define WCHAR_TYPE "unsigned int"
-
-#undef WCHAR_TYPE_SIZE
-#define WCHAR_TYPE_SIZE 32
diff --git a/contrib/gcc/config/alpha/x-alpha b/contrib/gcc/config/alpha/x-alpha
index 991974797980..9686ab96472a 100644
--- a/contrib/gcc/config/alpha/x-alpha
+++ b/contrib/gcc/config/alpha/x-alpha
@@ -1 +1,2 @@
CLIB=-lmld
+EXTRA_HEADERS = $(srcdir)/config/alpha/va_list.h
diff --git a/contrib/gcc/config/alpha/xm-alpha.h b/contrib/gcc/config/alpha/xm-alpha.h
index 642e1cf1a6e0..c04844fdacde 100644
--- a/contrib/gcc/config/alpha/xm-alpha.h
+++ b/contrib/gcc/config/alpha/xm-alpha.h
@@ -41,12 +41,18 @@ Boston, MA 02111-1307, USA. */
#define SUCCESS_EXIT_CODE 0
#define FATAL_EXIT_CODE 33
-/* If not compiled with GNU C, use the builtin alloca. */
-#if !defined(__GNUC__) && !defined(_WIN32)
+/* If compiled with GNU C, use the builtin alloca. */
+#ifndef alloca
+#if defined(__GNUC__) && !defined(USE_C_ALLOCA)
+#define alloca __builtin_alloca
+#else
+#if !defined(_WIN32) && !defined(USE_C_ALLOCA) && !defined(OPEN_VMS) && !defined(__INTERIX)
#include <alloca.h>
#else
extern void *alloca ();
#endif
+#endif
+#endif
/* The host compiler has problems with enum bitfields since it makes
them signed so we can't fit all our codes in. */
@@ -65,14 +71,6 @@ extern void *malloc (), *realloc (), *calloc ();
#include "string.h"
#endif
-/* OSF/1 has vprintf. */
-
-#define HAVE_VPRINTF
-
-/* OSF/1 has putenv. */
-
-#define HAVE_PUTENV
-
/* OSF/1 is POSIX.1 compliant. */
#define POSIX
diff --git a/contrib/gcc/config/i386/go32.h b/contrib/gcc/config/i386/go32.h
deleted file mode 100644
index dd03cc8a75d1..000000000000
--- a/contrib/gcc/config/i386/go32.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/* Configuration for an i386 running MS-DOS with djgpp/go32. */
-
-#include "dbxcoff.h"
-
-/* Don't assume anything about the header files. */
-#define NO_IMPLICIT_EXTERN_C
-
-#define HANDLE_SYSV_PRAGMA
-
-#define YES_UNDERSCORES
-
-#include "i386/gas.h"
-
-#ifdef CPP_PREDEFINES
-#undef CPP_PREDEFINES
-#endif
-#define CPP_PREDEFINES "-Dunix -Di386 -DGO32 -DMSDOS \
- -Asystem(unix) -Asystem(msdos) -Acpu(i386) -Amachine(i386)"
-
-#undef EXTRA_SECTIONS
-#define EXTRA_SECTIONS in_ctor, in_dtor
-
-#undef EXTRA_SECTION_FUNCTIONS
-#define EXTRA_SECTION_FUNCTIONS \
- CTOR_SECTION_FUNCTION \
- DTOR_SECTION_FUNCTION
-
-#define CTOR_SECTION_FUNCTION \
-void \
-ctor_section () \
-{ \
- if (in_section != in_ctor) \
- { \
- fprintf (asm_out_file, "\t.section .ctor\n"); \
- in_section = in_ctor; \
- } \
-}
-
-#define DTOR_SECTION_FUNCTION \
-void \
-dtor_section () \
-{ \
- if (in_section != in_dtor) \
- { \
- fprintf (asm_out_file, "\t.section .dtor\n"); \
- in_section = in_dtor; \
- } \
-}
-
-#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
- do { \
- ctor_section (); \
- fprintf (FILE, "%s\t", ASM_LONG); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
-/* Allow (eg) __attribute__((section "locked")) to work */
-#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC)\
- do { \
- fprintf (FILE, "\t.section %s\n", NAME); \
- } while (0)
-
-#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
- do { \
- dtor_section (); \
- fprintf (FILE, "%s\t", ASM_LONG); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
-/* Output at beginning of assembler file. */
-/* The .file command should always begin the output. */
-/* Use the main_input_filename instead of dump_base_name */
-
-#undef ASM_FILE_START
-#define ASM_FILE_START(FILE) \
- do { \
- output_file_directive (FILE, main_input_filename); \
- } while (0)
-
-/* This is how to output an assembler line
- that says to advance the location counter
- to a multiple of 2**LOG bytes. */
-
-#undef ASM_OUTPUT_ALIGN
-#define ASM_OUTPUT_ALIGN(FILE,LOG) \
- if ((LOG) != 0) fprintf ((FILE), "\t.p2align %d\n", LOG)
-
-/* djgpp has atexit (). */
-#undef HAVE_ATEXIT
-#define HAVE_ATEXIT
-
-/* djgpp automatically calls its own version of __main, so don't define one
- in libgcc, nor call one in main(). */
-#define HAS_INIT_SECTION
diff --git a/contrib/gcc/config/i386/i386iscgas.h b/contrib/gcc/config/i386/i386iscgas.h
deleted file mode 100644
index 526fe374e481..000000000000
--- a/contrib/gcc/config/i386/i386iscgas.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* Definitions for Intel 386 running Interactive Unix System V,
- producing stabs-in-coff output (using a slightly modified gas).
- Specifically, this is for recent versions that support POSIX;
- for version 2.0.2, use configuration option i386-sysv instead. */
-
-/* Underscores are not used on ISC systems (probably not on any COFF
- system), despite the comments in i386/gas.h. If this is not defined,
- enquire (for example) will fail to link. --karl@cs.umb.edu */
-#define NO_UNDERSCORES
-
-/* Mostly like other gas-using systems. */
-#include "i386/gas.h"
-
-/* But with ISC-specific additions. */
-#include "i386/isc.h"
-
-/* We do not want to output SDB debugging information. */
-
-#undef SDB_DEBUGGING_INFO
-
-/* We want to output DBX debugging information. */
-
-#define DBX_DEBUGGING_INFO
-
-
-/* The function `dbxout_init' in dbxout.c omits the first character of
- `ltext_label_name' when outputting the main source directory and main
- source filename. I don't understand why, but rather than making a
- system-independent change there, I override dbxout.c's defaults.
- Perhaps it would be better to use ".Ltext0" instead of
- `ltext_label_name', but we've already generated the label, so we just
- use it here. --karl@cs.umb.edu */
-#define DBX_OUTPUT_MAIN_SOURCE_DIRECTORY(asmfile, cwd) \
- do { fprintf (asmfile, "%s ", ASM_STABS_OP); \
- output_quoted_string (asmfile, cwd); \
- fprintf (asmfile, ",%d,0,0,%s\n", N_SO, ltext_label_name); \
- } while (0)
-#define DBX_OUTPUT_MAIN_SOURCE_FILENAME(asmfile, input_file_name) \
- fprintf (asmfile, "%s ", ASM_STABS_OP); \
- output_quoted_string (input_file_name); \
- fprintf (asmfile, ",%d,0,0,%s\n", N_SO, ltext_label_name); \
- text_section (); \
- ASM_OUTPUT_INTERNAL_LABEL (asmfile, "Ltext", 0)
-
-
-/* Because we don't include `svr3.h', we haven't yet defined SIZE_TYPE
- and PTRDIFF_TYPE. ISC's definitions don't match GCC's defaults, so: */
-
-#undef SIZE_TYPE
-#define SIZE_TYPE "unsigned int"
-
-#undef PTRDIFF_TYPE
-#define PTRDIFF_TYPE "int"
-
-
-/* But we can't use crtbegin.o and crtend.o, because gas 1.38.1 doesn't
- grok .section. The definitions here are otherwise identical to those
- in i386/isc.h. */
-#undef STARTFILE_SPEC
-#define STARTFILE_SPEC \
- "%{!shlib:%{posix:%{pg:mcrtp1.o%s}%{!pg:%{p:mcrtp1.o%s}%{!p:crtp1.o%s}}}\
- %{!posix:%{pg:mcrt1.o%s}%{!pg:%{p:mcrt1.o%s}%{!p:crt1.o%s}}\
- %{p:-L/lib/libp} %{pg:-L/lib/libp}}}\
- %{shlib:%{posix:crtp1.o%s}%{!posix:crt1.o%s}}"
-
-#undef ENDFILE_SPEC
-#define ENDFILE_SPEC "crtn.o%s"
diff --git a/contrib/gcc/config/i386/next.c b/contrib/gcc/config/i386/next.c
deleted file mode 100644
index f249647ab595..000000000000
--- a/contrib/gcc/config/i386/next.c
+++ /dev/null
@@ -1,7 +0,0 @@
-/* next.c: Functions for NeXT as target machine for GNU C compiler. */
-
-/* Note that the include below means that we can't debug routines in
- i386.c when running on a COFF system. */
-
-#include "i386/i386.c"
-#include "nextstep.c"
diff --git a/contrib/gcc/config/i386/sysv4gdb.h b/contrib/gcc/config/i386/sysv4gdb.h
deleted file mode 100644
index dd1e8f256f35..000000000000
--- a/contrib/gcc/config/i386/sysv4gdb.h
+++ /dev/null
@@ -1,7 +0,0 @@
-/* Target definitions for GNU compiler for Intel 80386 running System V.4
- with gas and gdb. */
-
-/* Use stabs instead of DWARF debug format. */
-#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
-
-#include "i386/sysv4.h"
diff --git a/contrib/gcc/config/i386/t-iscscodbx b/contrib/gcc/config/i386/t-iscscodbx
deleted file mode 100644
index 928a7589f8c9..000000000000
--- a/contrib/gcc/config/i386/t-iscscodbx
+++ /dev/null
@@ -1,2 +0,0 @@
-# The one that comes with the system is POSIX-compliant.
-LIMITS_H =
diff --git a/contrib/gcc/config/i386/x-freebsd b/contrib/gcc/config/i386/x-freebsd
deleted file mode 100644
index 47640c0a2c0d..000000000000
--- a/contrib/gcc/config/i386/x-freebsd
+++ /dev/null
@@ -1,4 +0,0 @@
-# Don't run fixproto
-STMP_FIXPROTO =
-# Use only native include files
-USER_H =
diff --git a/contrib/gcc/config/i386/xm-netbsd.h b/contrib/gcc/config/i386/xm-netbsd.h
deleted file mode 100644
index 3a9f32419907..000000000000
--- a/contrib/gcc/config/i386/xm-netbsd.h
+++ /dev/null
@@ -1,4 +0,0 @@
-/* Configuration for GCC for Intel i386 running NetBSD as host. */
-
-#include <i386/xm-i386.h>
-#include <xm-netbsd.h>
diff --git a/contrib/gcc/config/sparc/aout.h b/contrib/gcc/config/sparc/aout.h
deleted file mode 100644
index 478d710f82fd..000000000000
--- a/contrib/gcc/config/sparc/aout.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/* Definitions of target machine for GNU compiler, for SPARC using a.out.
- Copyright (C) 1994, 1996 Free Software Foundation, Inc.
- Contributed by Michael Tiemann (tiemann@cygnus.com).
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-#include "sparc/sparc.h" /* SPARC definitions */
-#include "aoutos.h" /* A.out definitions */
-
-#undef CPP_PREDEFINES
-#define CPP_PREDEFINES "-Dsparc -Acpu(sparc) -Amachine(sparc)"
diff --git a/contrib/gcc/config/sparc/bsd.h b/contrib/gcc/config/sparc/bsd.h
deleted file mode 100644
index 761abe2671b8..000000000000
--- a/contrib/gcc/config/sparc/bsd.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#include "sparc/sparc.h"
-
-#undef LIB_SPEC
-#define LIB_SPEC "%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}"
-
-#undef STARTFILE_SPEC
-#define STARTFILE_SPEC "%{pg:gcrt0.o%s}%{!pg:%{p:gcrt0.o%s}%{!p:crt0.o%s}}"
diff --git a/contrib/gcc/config/sparc/elf.h b/contrib/gcc/config/sparc/elf.h
deleted file mode 100644
index 635238f5b1f2..000000000000
--- a/contrib/gcc/config/sparc/elf.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* Definitions of target machine for GNU compiler,
- for SPARC running in an embedded environment using the ELF file format.
- Copyright (C) 1997 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-#include "sol2.h"
-
-#undef CPP_PREDEFINES
-#define CPP_PREDEFINES "-Dsparc -D__elf__ -Acpu(sparc) -Amachine(sparc)"
-
-#undef STARTFILE_SPEC
-#define STARTFILE_SPEC "crt0.o%s crti.o%s crtbegin.o%s"
-
-#undef ENDFILE_SPEC
-#define ENDFILE_SPEC "crtend.o%s crtn.o%s"
-
-/* Use the default. */
-#undef LINK_SPEC
-
-/* Don't set the target flags, this is done by the linker script */
-#undef LIB_SPEC
-#define LIB_SPEC ""
-
-/* FIXME: until fixed */
-#undef LONG_DOUBLE_TYPE_SIZE
-#define LONG_DOUBLE_TYPE_SIZE 64
-
-/* This solaris2 define does not apply. */
-#undef STDC_0_IN_SYSTEM_HEADERS
-
-/* We don't want to use the Solaris2 specific long long int conversion
- routines. */
-#undef INIT_SUBTARGET_OPTABS
-#define INIT_SUBTARGET_OPTABS
-
-/* ??? We haven't added Solaris2 equivalent 64 bit library routines to
- lb1sp*.asm, so we need to avoid using them. */
-#undef MULDI3_LIBCALL
-#undef DIVDI3_LIBCALL
-#undef UDIVDI3_LIBCALL
-#undef MODDI3_LIBCALL
-#undef UMODDI3_LIBCALL
diff --git a/contrib/gcc/config/sparc/gmon-sol2.c b/contrib/gcc/config/sparc/gmon-sol2.c
deleted file mode 100644
index a6abcabcc51f..000000000000
--- a/contrib/gcc/config/sparc/gmon-sol2.c
+++ /dev/null
@@ -1,425 +0,0 @@
-/*-
- * 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. 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, Berkeley and its contributors.
- * 4. 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.
- */
-
-/* Mangled into a form that works on Sparc Solaris 2 by Mark Eichin
- * for Cygnus Support, July 1992.
- */
-
-#include "config.h"
-#include "system.h"
-
-#if 0
-#include "sparc/gmon.h"
-#else
-struct phdr {
- char *lpc;
- char *hpc;
- int ncnt;
-};
-#define HISTFRACTION 2
-#define HISTCOUNTER unsigned short
-#define HASHFRACTION 1
-#define ARCDENSITY 2
-#define MINARCS 50
-struct tostruct {
- char *selfpc;
- long count;
- unsigned short link;
-};
-struct rawarc {
- unsigned long raw_frompc;
- unsigned long raw_selfpc;
- long raw_count;
-};
-#define ROUNDDOWN(x,y) (((x)/(y))*(y))
-#define ROUNDUP(x,y) ((((x)+(y)-1)/(y))*(y))
-
-#endif
-
-/* extern mcount() asm ("mcount"); */
-/*extern*/ char *minbrk /* asm ("minbrk") */;
-
- /*
- * froms is actually a bunch of unsigned shorts indexing tos
- */
-static int profiling = 3;
-static unsigned short *froms;
-static struct tostruct *tos = 0;
-static long tolimit = 0;
-static char *s_lowpc = 0;
-static char *s_highpc = 0;
-static unsigned long s_textsize = 0;
-
-static int ssiz;
-static char *sbuf;
-static int s_scale;
- /* see profil(2) where this is describe (incorrectly) */
-#define SCALE_1_TO_1 0x10000L
-
-#define MSG "No space for profiling buffer(s)\n"
-
-static void moncontrol PROTO ((int));
-extern void monstartup PROTO ((char *, char *));
-extern void _mcleanup PROTO ((void));
-
-void monstartup(lowpc, highpc)
- char *lowpc;
- char *highpc;
-{
- int monsize;
- char *buffer;
- register int o;
-
- /*
- * round lowpc and highpc to multiples of the density we're using
- * so the rest of the scaling (here and in gprof) stays in ints.
- */
- lowpc = (char *)
- ROUNDDOWN((unsigned)lowpc, HISTFRACTION*sizeof(HISTCOUNTER));
- s_lowpc = lowpc;
- highpc = (char *)
- ROUNDUP((unsigned)highpc, HISTFRACTION*sizeof(HISTCOUNTER));
- s_highpc = highpc;
- s_textsize = highpc - lowpc;
- monsize = (s_textsize / HISTFRACTION) + sizeof(struct phdr);
- buffer = sbrk( monsize );
- if ( buffer == (char *) -1 ) {
- write( 2 , MSG , sizeof(MSG) );
- return;
- }
- froms = (unsigned short *) sbrk( s_textsize / HASHFRACTION );
- if ( froms == (unsigned short *) -1 ) {
- write( 2 , MSG , sizeof(MSG) );
- froms = 0;
- return;
- }
- tolimit = s_textsize * ARCDENSITY / 100;
- if ( tolimit < MINARCS ) {
- tolimit = MINARCS;
- } else if ( tolimit > 65534 ) {
- tolimit = 65534;
- }
- tos = (struct tostruct *) sbrk( tolimit * sizeof( struct tostruct ) );
- if ( tos == (struct tostruct *) -1 ) {
- write( 2 , MSG , sizeof(MSG) );
- froms = 0;
- tos = 0;
- return;
- }
- minbrk = sbrk(0);
- tos[0].link = 0;
- sbuf = buffer;
- ssiz = monsize;
- ( (struct phdr *) buffer ) -> lpc = lowpc;
- ( (struct phdr *) buffer ) -> hpc = highpc;
- ( (struct phdr *) buffer ) -> ncnt = ssiz;
- monsize -= sizeof(struct phdr);
- if ( monsize <= 0 )
- return;
- o = highpc - lowpc;
- if( monsize < o )
-#ifndef hp300
- s_scale = ( (float) monsize / o ) * SCALE_1_TO_1;
-#else /* avoid floating point */
- {
- int quot = o / monsize;
-
- if (quot >= 0x10000)
- s_scale = 1;
- else if (quot >= 0x100)
- s_scale = 0x10000 / quot;
- else if (o >= 0x800000)
- s_scale = 0x1000000 / (o / (monsize >> 8));
- else
- s_scale = 0x1000000 / ((o << 8) / monsize);
- }
-#endif
- else
- s_scale = SCALE_1_TO_1;
- moncontrol(1);
-}
-
-void
-_mcleanup()
-{
- int fd;
- int fromindex;
- int endfrom;
- char *frompc;
- int toindex;
- struct rawarc rawarc;
- char *profdir;
- const char *proffile;
- char *progname;
- char buf[PATH_MAX];
- extern char **___Argv;
-
- moncontrol(0);
-
- if ((profdir = getenv("PROFDIR")) != NULL) {
- /* If PROFDIR contains a null value, no profiling output is produced */
- if (*profdir == '\0') {
- return;
- }
-
- progname=strrchr(___Argv[0], '/');
- if (progname == NULL)
- progname=___Argv[0];
- else
- progname++;
-
- sprintf(buf, "%s/%ld.%s", profdir, getpid(), progname);
- proffile = buf;
- } else {
- proffile = "gmon.out";
- }
-
- fd = creat( proffile, 0666 );
- if ( fd < 0 ) {
- perror( proffile );
- return;
- }
-# ifdef DEBUG
- fprintf( stderr , "[mcleanup] sbuf 0x%x ssiz %d\n" , sbuf , ssiz );
-# endif DEBUG
- write( fd , sbuf , ssiz );
- endfrom = s_textsize / (HASHFRACTION * sizeof(*froms));
- for ( fromindex = 0 ; fromindex < endfrom ; fromindex++ ) {
- if ( froms[fromindex] == 0 ) {
- continue;
- }
- frompc = s_lowpc + (fromindex * HASHFRACTION * sizeof(*froms));
- for (toindex=froms[fromindex]; toindex!=0; toindex=tos[toindex].link) {
-# ifdef DEBUG
- fprintf( stderr ,
- "[mcleanup] frompc 0x%x selfpc 0x%x count %d\n" ,
- frompc , tos[toindex].selfpc , tos[toindex].count );
-# endif DEBUG
- rawarc.raw_frompc = (unsigned long) frompc;
- rawarc.raw_selfpc = (unsigned long) tos[toindex].selfpc;
- rawarc.raw_count = tos[toindex].count;
- write( fd , &rawarc , sizeof rawarc );
- }
- }
- close( fd );
-}
-
-/*
- * The Sparc stack frame is only held together by the frame pointers
- * in the register windows. According to the SVR4 SPARC ABI
- * Supplement, Low Level System Information/Operating System
- * Interface/Software Trap Types, a type 3 trap will flush all of the
- * register windows to the stack, which will make it possible to walk
- * the frames and find the return addresses.
- * However, it seems awfully expensive to incur a trap (system
- * call) for every function call. It turns out that "call" simply puts
- * the return address in %o7 expecting the "save" in the procedure to
- * shift it into %i7; this means that before the "save" occurs, %o7
- * contains the address of the call to mcount, and %i7 still contains
- * the caller above that. The asm mcount here simply saves those
- * registers in argument registers and branches to internal_mcount,
- * simulating a call with arguments.
- * Kludges:
- * 1) the branch to internal_mcount is hard coded; it should be
- * possible to tell asm to use the assembler-name of a symbol.
- * 2) in theory, the function calling mcount could have saved %i7
- * somewhere and reused the register; in practice, I *think* this will
- * break longjmp (and maybe the debugger) but I'm not certain. (I take
- * some comfort in the knowledge that it will break the native mcount
- * as well.)
- * 3) if builtin_return_address worked, this could be portable.
- * However, it would really have to be optimized for arguments of 0
- * and 1 and do something like what we have here in order to avoid the
- * trap per function call performance hit.
- * 4) the atexit and monsetup calls prevent this from simply
- * being a leaf routine that doesn't do a "save" (and would thus have
- * access to %o7 and %i7 directly) but the call to write() at the end
- * would have also prevented this.
- *
- * -- [eichin:19920702.1107EST]
- */
-
-static void internal_mcount PROTO((char *, unsigned short *)) ATTRIBUTE_UNUSED;
-
-/* i7 == last ret, -> frompcindex */
-/* o7 == current ret, -> selfpc */
-/* Solaris 2 libraries use _mcount. */
-asm(".global _mcount; _mcount: mov %i7,%o1; mov %o7,%o0;b,a internal_mcount");
-/* This is for compatibility with old versions of gcc which used mcount. */
-asm(".global mcount; mcount: mov %i7,%o1; mov %o7,%o0;b,a internal_mcount");
-
-static void internal_mcount(selfpc, frompcindex)
- register char *selfpc;
- register unsigned short *frompcindex;
-{
- register struct tostruct *top;
- register struct tostruct *prevtop;
- register long toindex;
- static char already_setup;
-
- /*
- * find the return address for mcount,
- * and the return address for mcount's caller.
- */
-
- if(!already_setup) {
- extern char etext[];
- already_setup = 1;
- monstartup(0, (char *)etext);
-#ifdef USE_ONEXIT
- on_exit(_mcleanup, 0);
-#else
- atexit(_mcleanup);
-#endif
- }
- /*
- * check that we are profiling
- * and that we aren't recursively invoked.
- */
- if (profiling) {
- goto out;
- }
- profiling++;
- /*
- * check that frompcindex is a reasonable pc value.
- * for example: signal catchers get called from the stack,
- * not from text space. too bad.
- */
- frompcindex = (unsigned short *)((long)frompcindex - (long)s_lowpc);
- if ((unsigned long)frompcindex > s_textsize) {
- goto done;
- }
- frompcindex =
- &froms[((long)frompcindex) / (HASHFRACTION * sizeof(*froms))];
- toindex = *frompcindex;
- if (toindex == 0) {
- /*
- * first time traversing this arc
- */
- toindex = ++tos[0].link;
- if (toindex >= tolimit) {
- goto overflow;
- }
- *frompcindex = toindex;
- top = &tos[toindex];
- top->selfpc = selfpc;
- top->count = 1;
- top->link = 0;
- goto done;
- }
- top = &tos[toindex];
- if (top->selfpc == selfpc) {
- /*
- * arc at front of chain; usual case.
- */
- top->count++;
- goto done;
- }
- /*
- * have to go looking down chain for it.
- * top points to what we are looking at,
- * prevtop points to previous top.
- * we know it is not at the head of the chain.
- */
- for (; /* goto done */; ) {
- if (top->link == 0) {
- /*
- * top is end of the chain and none of the chain
- * had top->selfpc == selfpc.
- * so we allocate a new tostruct
- * and link it to the head of the chain.
- */
- toindex = ++tos[0].link;
- if (toindex >= tolimit) {
- goto overflow;
- }
- top = &tos[toindex];
- top->selfpc = selfpc;
- top->count = 1;
- top->link = *frompcindex;
- *frompcindex = toindex;
- goto done;
- }
- /*
- * otherwise, check the next arc on the chain.
- */
- prevtop = top;
- top = &tos[top->link];
- if (top->selfpc == selfpc) {
- /*
- * there it is.
- * increment its count
- * move it to the head of the chain.
- */
- top->count++;
- toindex = prevtop->link;
- prevtop->link = top->link;
- top->link = *frompcindex;
- *frompcindex = toindex;
- goto done;
- }
-
- }
-done:
- profiling--;
- /* and fall through */
-out:
- return; /* normal return restores saved registers */
-
-overflow:
- profiling++; /* halt further profiling */
-# define TOLIMIT "mcount: tos overflow\n"
- write(2, TOLIMIT, sizeof(TOLIMIT));
- goto out;
-}
-
-/*
- * Control profiling
- * profiling is what mcount checks to see if
- * all the data structures are ready.
- */
-static void moncontrol(mode)
- int mode;
-{
- if (mode) {
- /* start */
- profil((unsigned short *)(sbuf + sizeof(struct phdr)),
- ssiz - sizeof(struct phdr),
- (int)s_lowpc, s_scale);
- profiling = 0;
- } else {
- /* stop */
- profil((unsigned short *)0, 0, 0, 0);
- profiling = 3;
- }
-}
diff --git a/contrib/gcc/config/sparc/hal.h b/contrib/gcc/config/sparc/hal.h
deleted file mode 100644
index 0222b819e0eb..000000000000
--- a/contrib/gcc/config/sparc/hal.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Definitions of target machine for GNU compiler, for HAL
- SPARC running Solaris 2 HALOS
- Copyright 1998 Free Software Foundation, Inc.
- Contributed by Carol LePage (carolo@hal.com)
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-/* Need different command line for assembler */
-
-#undef ASM_SPEC
-#define ASM_SPEC \
- "%{V} %{v:%{!V:-V}} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Wa,*:%*} -e1 \
- %{fpic:-K PIC} %{fPIC:-K PIC}"
-
-/* Need DWARF for debuggers. */
-
-#undef PREFERRED_DEBUGGING_TYPE
-#define PREFERRED_DEBUGGING_TYPE DWARF_DEBUG
diff --git a/contrib/gcc/config/sparc/lb1spc.asm b/contrib/gcc/config/sparc/lb1spc.asm
deleted file mode 100644
index 831f33a988fb..000000000000
--- a/contrib/gcc/config/sparc/lb1spc.asm
+++ /dev/null
@@ -1,784 +0,0 @@
-/* This is an assembly language implementation of libgcc1.c for the sparc
- processor.
-
- These routines are derived from the Sparc Architecture Manual, version 8,
- slightly edited to match the desired calling convention, and also to
- optimize them for our purposes. */
-
-#ifdef L_mulsi3
-.text
- .align 4
- .global .umul
- .proc 4
-.umul:
- or %o0, %o1, %o4 ! logical or of multiplier and multiplicand
- mov %o0, %y ! multiplier to Y register
- andncc %o4, 0xfff, %o5 ! mask out lower 12 bits
- be mul_shortway ! can do it the short way
- andcc %g0, %g0, %o4 ! zero the partial product and clear NV cc
- !
- ! long multiply
- !
- mulscc %o4, %o1, %o4 ! first iteration of 33
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4 ! 32nd iteration
- mulscc %o4, %g0, %o4 ! last iteration only shifts
- ! the upper 32 bits of product are wrong, but we do not care
- retl
- rd %y, %o0
- !
- ! short multiply
- !
-mul_shortway:
- mulscc %o4, %o1, %o4 ! first iteration of 13
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4
- mulscc %o4, %o1, %o4 ! 12th iteration
- mulscc %o4, %g0, %o4 ! last iteration only shifts
- rd %y, %o5
- sll %o4, 12, %o4 ! left shift partial product by 12 bits
- srl %o5, 20, %o5 ! right shift partial product by 20 bits
- retl
- or %o5, %o4, %o0 ! merge for true product
-#endif
-
-#ifdef L_divsi3
-/*
- * Division and remainder, from Appendix E of the Sparc Version 8
- * Architecture Manual, with fixes from Gordon Irlam.
- */
-
-/*
- * Input: dividend and divisor in %o0 and %o1 respectively.
- *
- * m4 parameters:
- * .div name of function to generate
- * div div=div => %o0 / %o1; div=rem => %o0 % %o1
- * true true=true => signed; true=false => unsigned
- *
- * Algorithm parameters:
- * N how many bits per iteration we try to get (4)
- * WORDSIZE total number of bits (32)
- *
- * Derived constants:
- * TOPBITS number of bits in the top decade of a number
- *
- * Important variables:
- * Q the partial quotient under development (initially 0)
- * R the remainder so far, initially the dividend
- * ITER number of main division loop iterations required;
- * equal to ceil(log2(quotient) / N). Note that this
- * is the log base (2^N) of the quotient.
- * V the current comparand, initially divisor*2^(ITER*N-1)
- *
- * Cost:
- * Current estimate for non-large dividend is
- * ceil(log2(quotient) / N) * (10 + 7N/2) + C
- * A large dividend is one greater than 2^(31-TOPBITS) and takes a
- * different path, as the upper bits of the quotient must be developed
- * one bit at a time.
- */
- .global .udiv
- .align 4
- .proc 4
- .text
-.udiv:
- b ready_to_divide
- mov 0, %g3 ! result is always positive
-
- .global .div
- .align 4
- .proc 4
- .text
-.div:
- ! compute sign of result; if neither is negative, no problem
- orcc %o1, %o0, %g0 ! either negative?
- bge ready_to_divide ! no, go do the divide
- xor %o1, %o0, %g3 ! compute sign in any case
- tst %o1
- bge 1f
- tst %o0
- ! %o1 is definitely negative; %o0 might also be negative
- bge ready_to_divide ! if %o0 not negative...
- sub %g0, %o1, %o1 ! in any case, make %o1 nonneg
-1: ! %o0 is negative, %o1 is nonnegative
- sub %g0, %o0, %o0 ! make %o0 nonnegative
-
-
-ready_to_divide:
-
- ! Ready to divide. Compute size of quotient; scale comparand.
- orcc %o1, %g0, %o5
- bne 1f
- mov %o0, %o3
-
- ! Divide by zero trap. If it returns, return 0 (about as
- ! wrong as possible, but that is what SunOS does...).
- ta 0x2 ! ST_DIV0
- retl
- clr %o0
-
-1:
- cmp %o3, %o5 ! if %o1 exceeds %o0, done
- blu got_result ! (and algorithm fails otherwise)
- clr %o2
- sethi %hi(1 << (32 - 4 - 1)), %g1
- cmp %o3, %g1
- blu not_really_big
- clr %o4
-
- ! Here the dividend is >= 2**(31-N) or so. We must be careful here,
- ! as our usual N-at-a-shot divide step will cause overflow and havoc.
- ! The number of bits in the result here is N*ITER+SC, where SC <= N.
- ! Compute ITER in an unorthodox manner: know we need to shift V into
- ! the top decade: so do not even bother to compare to R.
- 1:
- cmp %o5, %g1
- bgeu 3f
- mov 1, %g2
- sll %o5, 4, %o5
- b 1b
- add %o4, 1, %o4
-
- ! Now compute %g2.
- 2: addcc %o5, %o5, %o5
- bcc not_too_big
- add %g2, 1, %g2
-
- ! We get here if the %o1 overflowed while shifting.
- ! This means that %o3 has the high-order bit set.
- ! Restore %o5 and subtract from %o3.
- sll %g1, 4, %g1 ! high order bit
- srl %o5, 1, %o5 ! rest of %o5
- add %o5, %g1, %o5
- b do_single_div
- sub %g2, 1, %g2
-
- not_too_big:
- 3: cmp %o5, %o3
- blu 2b
- nop
- be do_single_div
- nop
- /* NB: these are commented out in the V8-Sparc manual as well */
- /* (I do not understand this) */
- ! %o5 > %o3: went too far: back up 1 step
- ! srl %o5, 1, %o5
- ! dec %g2
- ! do single-bit divide steps
- !
- ! We have to be careful here. We know that %o3 >= %o5, so we can do the
- ! first divide step without thinking. BUT, the others are conditional,
- ! and are only done if %o3 >= 0. Because both %o3 and %o5 may have the high-
- ! order bit set in the first step, just falling into the regular
- ! division loop will mess up the first time around.
- ! So we unroll slightly...
- do_single_div:
- subcc %g2, 1, %g2
- bl end_regular_divide
- nop
- sub %o3, %o5, %o3
- mov 1, %o2
- b end_single_divloop
- nop
- single_divloop:
- sll %o2, 1, %o2
- bl 1f
- srl %o5, 1, %o5
- ! %o3 >= 0
- sub %o3, %o5, %o3
- b 2f
- add %o2, 1, %o2
- 1: ! %o3 < 0
- add %o3, %o5, %o3
- sub %o2, 1, %o2
- 2:
- end_single_divloop:
- subcc %g2, 1, %g2
- bge single_divloop
- tst %o3
- b,a end_regular_divide
-
-not_really_big:
-1:
- sll %o5, 4, %o5
- cmp %o5, %o3
- bleu 1b
- addcc %o4, 1, %o4
- be got_result
- sub %o4, 1, %o4
-
- tst %o3 ! set up for initial iteration
-divloop:
- sll %o2, 4, %o2
- ! depth 1, accumulated bits 0
- bl L1.16
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 2, accumulated bits 1
- bl L2.17
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 3, accumulated bits 3
- bl L3.19
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 4, accumulated bits 7
- bl L4.23
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (7*2+1), %o2
-
-L4.23:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (7*2-1), %o2
-
-
-L3.19:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 4, accumulated bits 5
- bl L4.21
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (5*2+1), %o2
-
-L4.21:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (5*2-1), %o2
-
-L2.17:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 3, accumulated bits 1
- bl L3.17
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 4, accumulated bits 3
- bl L4.19
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (3*2+1), %o2
-
-L4.19:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (3*2-1), %o2
-
-L3.17:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 4, accumulated bits 1
- bl L4.17
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (1*2+1), %o2
-
-L4.17:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (1*2-1), %o2
-
-L1.16:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 2, accumulated bits -1
- bl L2.15
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 3, accumulated bits -1
- bl L3.15
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 4, accumulated bits -1
- bl L4.15
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (-1*2+1), %o2
-
-L4.15:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (-1*2-1), %o2
-
-L3.15:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 4, accumulated bits -3
- bl L4.13
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (-3*2+1), %o2
-
-L4.13:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (-3*2-1), %o2
-
-L2.15:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 3, accumulated bits -3
- bl L3.13
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 4, accumulated bits -5
- bl L4.11
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (-5*2+1), %o2
-
-L4.11:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (-5*2-1), %o2
-
-L3.13:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 4, accumulated bits -7
- bl L4.9
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (-7*2+1), %o2
-
-L4.9:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (-7*2-1), %o2
-
- 9:
-end_regular_divide:
- subcc %o4, 1, %o4
- bge divloop
- tst %o3
- bl,a got_result
- ! non-restoring fixup here (one instruction only!)
- sub %o2, 1, %o2
-
-
-got_result:
- ! check to see if answer should be < 0
- tst %g3
- bl,a 1f
- sub %g0, %o2, %o2
-1:
- retl
- mov %o2, %o0
-#endif
-
-#ifdef L_modsi3
-/* This implementation was taken from glibc:
- *
- * Input: dividend and divisor in %o0 and %o1 respectively.
- *
- * Algorithm parameters:
- * N how many bits per iteration we try to get (4)
- * WORDSIZE total number of bits (32)
- *
- * Derived constants:
- * TOPBITS number of bits in the top decade of a number
- *
- * Important variables:
- * Q the partial quotient under development (initially 0)
- * R the remainder so far, initially the dividend
- * ITER number of main division loop iterations required;
- * equal to ceil(log2(quotient) / N). Note that this
- * is the log base (2^N) of the quotient.
- * V the current comparand, initially divisor*2^(ITER*N-1)
- *
- * Cost:
- * Current estimate for non-large dividend is
- * ceil(log2(quotient) / N) * (10 + 7N/2) + C
- * A large dividend is one greater than 2^(31-TOPBITS) and takes a
- * different path, as the upper bits of the quotient must be developed
- * one bit at a time.
- */
-.text
- .align 4
- .global .urem
- .proc 4
-.urem:
- b divide
- mov 0, %g3 ! result always positive
-
- .align 4
- .global .rem
- .proc 4
-.rem:
- ! compute sign of result; if neither is negative, no problem
- orcc %o1, %o0, %g0 ! either negative?
- bge 2f ! no, go do the divide
- mov %o0, %g3 ! sign of remainder matches %o0
- tst %o1
- bge 1f
- tst %o0
- ! %o1 is definitely negative; %o0 might also be negative
- bge 2f ! if %o0 not negative...
- sub %g0, %o1, %o1 ! in any case, make %o1 nonneg
-1: ! %o0 is negative, %o1 is nonnegative
- sub %g0, %o0, %o0 ! make %o0 nonnegative
-2:
-
- ! Ready to divide. Compute size of quotient; scale comparand.
-divide:
- orcc %o1, %g0, %o5
- bne 1f
- mov %o0, %o3
-
- ! Divide by zero trap. If it returns, return 0 (about as
- ! wrong as possible, but that is what SunOS does...).
- ta 0x2 !ST_DIV0
- retl
- clr %o0
-
-1:
- cmp %o3, %o5 ! if %o1 exceeds %o0, done
- blu got_result ! (and algorithm fails otherwise)
- clr %o2
- sethi %hi(1 << (32 - 4 - 1)), %g1
- cmp %o3, %g1
- blu not_really_big
- clr %o4
-
- ! Here the dividend is >= 2**(31-N) or so. We must be careful here,
- ! as our usual N-at-a-shot divide step will cause overflow and havoc.
- ! The number of bits in the result here is N*ITER+SC, where SC <= N.
- ! Compute ITER in an unorthodox manner: know we need to shift V into
- ! the top decade: so do not even bother to compare to R.
- 1:
- cmp %o5, %g1
- bgeu 3f
- mov 1, %g2
- sll %o5, 4, %o5
- b 1b
- add %o4, 1, %o4
-
- ! Now compute %g2.
- 2: addcc %o5, %o5, %o5
- bcc not_too_big
- add %g2, 1, %g2
-
- ! We get here if the %o1 overflowed while shifting.
- ! This means that %o3 has the high-order bit set.
- ! Restore %o5 and subtract from %o3.
- sll %g1, 4, %g1 ! high order bit
- srl %o5, 1, %o5 ! rest of %o5
- add %o5, %g1, %o5
- b do_single_div
- sub %g2, 1, %g2
-
- not_too_big:
- 3: cmp %o5, %o3
- blu 2b
- nop
- be do_single_div
- nop
- /* NB: these are commented out in the V8-Sparc manual as well */
- /* (I do not understand this) */
- ! %o5 > %o3: went too far: back up 1 step
- ! srl %o5, 1, %o5
- ! dec %g2
- ! do single-bit divide steps
- !
- ! We have to be careful here. We know that %o3 >= %o5, so we can do the
- ! first divide step without thinking. BUT, the others are conditional,
- ! and are only done if %o3 >= 0. Because both %o3 and %o5 may have the high-
- ! order bit set in the first step, just falling into the regular
- ! division loop will mess up the first time around.
- ! So we unroll slightly...
- do_single_div:
- subcc %g2, 1, %g2
- bl end_regular_divide
- nop
- sub %o3, %o5, %o3
- mov 1, %o2
- b end_single_divloop
- nop
- single_divloop:
- sll %o2, 1, %o2
- bl 1f
- srl %o5, 1, %o5
- ! %o3 >= 0
- sub %o3, %o5, %o3
- b 2f
- add %o2, 1, %o2
- 1: ! %o3 < 0
- add %o3, %o5, %o3
- sub %o2, 1, %o2
- 2:
- end_single_divloop:
- subcc %g2, 1, %g2
- bge single_divloop
- tst %o3
- b,a end_regular_divide
-
-not_really_big:
-1:
- sll %o5, 4, %o5
- cmp %o5, %o3
- bleu 1b
- addcc %o4, 1, %o4
- be got_result
- sub %o4, 1, %o4
-
- tst %o3 ! set up for initial iteration
-divloop:
- sll %o2, 4, %o2
- ! depth 1, accumulated bits 0
- bl L1.16
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 2, accumulated bits 1
- bl L2.17
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 3, accumulated bits 3
- bl L3.19
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 4, accumulated bits 7
- bl L4.23
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (7*2+1), %o2
-L4.23:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (7*2-1), %o2
-
-L3.19:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 4, accumulated bits 5
- bl L4.21
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (5*2+1), %o2
-
-L4.21:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (5*2-1), %o2
-
-L2.17:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 3, accumulated bits 1
- bl L3.17
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 4, accumulated bits 3
- bl L4.19
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (3*2+1), %o2
-
-L4.19:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (3*2-1), %o2
-
-L3.17:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 4, accumulated bits 1
- bl L4.17
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (1*2+1), %o2
-
-L4.17:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (1*2-1), %o2
-
-L1.16:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 2, accumulated bits -1
- bl L2.15
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 3, accumulated bits -1
- bl L3.15
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 4, accumulated bits -1
- bl L4.15
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (-1*2+1), %o2
-
-L4.15:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (-1*2-1), %o2
-
-L3.15:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 4, accumulated bits -3
- bl L4.13
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (-3*2+1), %o2
-
-L4.13:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (-3*2-1), %o2
-
-L2.15:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 3, accumulated bits -3
- bl L3.13
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- ! depth 4, accumulated bits -5
- bl L4.11
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (-5*2+1), %o2
-
-L4.11:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (-5*2-1), %o2
-
-L3.13:
- ! remainder is negative
- addcc %o3,%o5,%o3
- ! depth 4, accumulated bits -7
- bl L4.9
- srl %o5,1,%o5
- ! remainder is positive
- subcc %o3,%o5,%o3
- b 9f
- add %o2, (-7*2+1), %o2
-
-L4.9:
- ! remainder is negative
- addcc %o3,%o5,%o3
- b 9f
- add %o2, (-7*2-1), %o2
-
- 9:
-end_regular_divide:
- subcc %o4, 1, %o4
- bge divloop
- tst %o3
- bl,a got_result
- ! non-restoring fixup here (one instruction only!)
- add %o3, %o1, %o3
-
-got_result:
- ! check to see if answer should be < 0
- tst %g3
- bl,a 1f
- sub %g0, %o3, %o3
-1:
- retl
- mov %o3, %o0
-
-#endif
-
diff --git a/contrib/gcc/config/sparc/lb1spl.asm b/contrib/gcc/config/sparc/lb1spl.asm
deleted file mode 100644
index 4c8bc30b83d5..000000000000
--- a/contrib/gcc/config/sparc/lb1spl.asm
+++ /dev/null
@@ -1,246 +0,0 @@
-/* This is an assembly language implementation of libgcc1.c for the sparclite
- processor.
-
- These routines are all from the Sparclite User's Guide, slightly edited
- to match the desired calling convention, and also to optimize them. */
-
-#ifdef L_udivsi3
-.text
- .align 4
- .global .udiv
- .proc 04
-.udiv:
- wr %g0,%g0,%y ! Not a delayed write for sparclite
- tst %g0
- divscc %o0,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- retl
- divscc %g1,%o1,%o0
-#endif
-
-#ifdef L_umodsi3
-.text
- .align 4
- .global .urem
- .proc 04
-.urem:
- wr %g0,%g0,%y ! Not a delayed write for sparclite
- tst %g0
- divscc %o0,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- divscc %g1,%o1,%g1
- bl 1f
- rd %y,%o0
- retl
- nop
-1: retl
- add %o0,%o1,%o0
-#endif
-
-#ifdef L_divsi3
-.text
- .align 4
- .global .div
- .proc 04
-! ??? This routine could be made faster if was optimized, and if it was
-! rewritten to only calculate the quotient.
-.div:
- wr %g0,%g0,%y ! Not a delayed write for sparclite
- mov %o1,%o4
- tst %o1
- bl,a 1f
- sub %g0,%o4,%o4
-1: tst %o0
- bl,a 2f
- mov -1,%y
-2: divscc %o0,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- be 6f
- mov %y,%o3
- bg 4f
- addcc %o3,%o4,%g0
- be,a 6f
- mov %g0,%o3
- tst %o0
- bl 5f
- tst %g1
- ba 5f
- add %o3,%o4,%o3
-4: subcc %o3,%o4,%g0
- be,a 6f
- mov %g0,%o3
- tst %o0
- bge 5f
- tst %g1
- sub %o3,%o4,%o3
-5: bl,a 6f
- add %g1,1,%g1
-6: tst %o1
- bl,a 7f
- sub %g0,%g1,%g1
-7: retl
- mov %g1,%o0 ! Quotient is in %g1.
-#endif
-
-#ifdef L_modsi3
-.text
- .align 4
- .global .rem
- .proc 04
-! ??? This routine could be made faster if was optimized, and if it was
-! rewritten to only calculate the remainder.
-.rem:
- wr %g0,%g0,%y ! Not a delayed write for sparclite
- mov %o1,%o4
- tst %o1
- bl,a 1f
- sub %g0,%o4,%o4
-1: tst %o0
- bl,a 2f
- mov -1,%y
-2: divscc %o0,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- divscc %g1,%o4,%g1
- be 6f
- mov %y,%o3
- bg 4f
- addcc %o3,%o4,%g0
- be,a 6f
- mov %g0,%o3
- tst %o0
- bl 5f
- tst %g1
- ba 5f
- add %o3,%o4,%o3
-4: subcc %o3,%o4,%g0
- be,a 6f
- mov %g0,%o3
- tst %o0
- bge 5f
- tst %g1
- sub %o3,%o4,%o3
-5: bl,a 6f
- add %g1,1,%g1
-6: tst %o1
- bl,a 7f
- sub %g0,%g1,%g1
-7: retl
- mov %o3,%o0 ! Remainder is in %o3.
-#endif
diff --git a/contrib/gcc/config/sparc/linux-aout.h b/contrib/gcc/config/sparc/linux-aout.h
deleted file mode 100644
index 76d7653eaae6..000000000000
--- a/contrib/gcc/config/sparc/linux-aout.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/* Definitions for SPARC running Linux-based GNU systems with a.out.
- Copyright (C) 1996, 1997 Free Software Foundation, Inc.
- Contributed by Eddie C. Dost (ecd@skynet.be)
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-#include <aoutos.h>
-#include <sparc/sparc.h>
-
-/* Don't assume anything about the header files. */
-#define NO_IMPLICIT_EXTERN_C
-
-#undef HAVE_ATEXIT
-#define HAVE_ATEXIT
-
-/* GNU/Linux uses ctype from glibc.a. I am not sure how complete it is.
- For now, we play safe. It may change later. */
-
-#if 0
-#undef MULTIBYTE_CHARS
-#define MULTIBYTE_CHARS 1
-#endif
-
-/* We need that too. */
-#define HANDLE_SYSV_PRAGMA
-
-#undef MD_EXEC_PREFIX
-#undef MD_STARTFILE_PREFIX
-
-/* Output at beginning of assembler file. */
-/* The .file command should always begin the output. */
-#undef ASM_FILE_START
-#define ASM_FILE_START(FILE) \
- do { \
- output_file_directive (FILE, main_input_filename); \
- fprintf (FILE, "\t.version\t\"01.01\"\n"); \
- } while (0)
-
-#undef STARTFILE_SPEC
-#define STARTFILE_SPEC "%{pg:gcrt0.o%s} %{!pg:%{p:gcrt0.o%s} %{!p:crt0.o%s}} %{static:-static}"
-
-#undef TARGET_VERSION
-#define TARGET_VERSION fprintf (stderr, " (sparc GNU/Linux with a.out)");
-
-#undef SIZE_TYPE
-#define SIZE_TYPE "unsigned int"
-
-#undef PTRDIFF_TYPE
-#define PTRDIFF_TYPE "int"
-
-#undef WCHAR_TYPE
-#define WCHAR_TYPE "long int"
-
-#undef WCHAR_TYPE_SIZE
-#define WCHAR_TYPE_SIZE BITS_PER_WORD
-
-#undef CPP_PREDEFINES
-#define CPP_PREDEFINES "-Dunix -Dsparc -Dlinux -Asystem(unix) -Asystem(posix)"
-
-#undef CPP_SUBTARGET_SPEC
-#define CPP_SUBTARGET_SPEC \
-"%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE}"
-
-/* Don't default to pcc-struct-return, because gcc is the only compiler,
- and we want to retain compatibility with older gcc versions. */
-#define DEFAULT_PCC_STRUCT_RETURN 0
-
-#undef LIB_SPEC
-
-#if 1
-/* We no longer link with libc_p.a or libg.a by default. If you
- want to profile or debug the GNU/Linux C library, please add
- -lc_p or -ggdb to LDFLAGS at the link time, respectively. */
-#define LIB_SPEC \
-"%{mieee-fp:-lieee} %{p:-lgmon} %{pg:-lgmon} %{!ggdb:-lc} %{ggdb:-lg}"
-#else
-#define LIB_SPEC \
-"%{mieee-fp:-lieee} %{p:-lgmon -lc_p} %{pg:-lgmon -lc_p} \
- %{!p:%{!pg:%{!g*:-lc} %{g*:-lg -static}}}"
-#endif
-
-#undef LINK_SPEC
-#define LINK_SPEC "-m sparclinux"
-
-/* The sun bundled assembler doesn't accept -Yd, (and neither does gas).
- It's safe to pass -s always, even if -g is not used. */
-#undef ASM_SPEC
-#define ASM_SPEC \
- "%{V} %{v:%{!V:-V}} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s %{fpic:-K PIC} %{fPIC:-K PIC}"
-
-#if 0
-/* Define for support of TFmode long double and REAL_ARITHMETIC.
- Sparc ABI says that long double is 4 words. GNU/Linux does not support
- long double yet. */
-#define LONG_DOUBLE_TYPE_SIZE 128
-#endif
-
-/* Override MACHINE_STATE_{SAVE,RESTORE} because we have special
- traps available which can get and set the condition codes
- reliably. */
-#undef MACHINE_STATE_SAVE
-#define MACHINE_STATE_SAVE(ID) \
- unsigned long int ms_flags, ms_saveret; \
- asm volatile("ta 0x20\n\t" \
- "mov %%g1, %0\n\t" \
- "mov %%g2, %1\n\t" \
- : "=r" (ms_flags), "=r" (ms_saveret));
-
-#undef MACHINE_STATE_RESTORE
-#define MACHINE_STATE_RESTORE(ID) \
- asm volatile("mov %0, %%g1\n\t" \
- "mov %1, %%g2\n\t" \
- "ta 0x21\n\t" \
- : /* no outputs */ \
- : "r" (ms_flags), "r" (ms_saveret));
diff --git a/contrib/gcc/config/sparc/linux.h b/contrib/gcc/config/sparc/linux.h
deleted file mode 100644
index d967b01ebe33..000000000000
--- a/contrib/gcc/config/sparc/linux.h
+++ /dev/null
@@ -1,259 +0,0 @@
-/* Definitions for SPARC running Linux-based GNU systems with ELF.
- Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
- Contributed by Eddie C. Dost (ecd@skynet.be)
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-#define LINUX_DEFAULT_ELF
-
-/* Don't assume anything about the header files. */
-#define NO_IMPLICIT_EXTERN_C
-
-#undef HAVE_ATEXIT
-#define HAVE_ATEXIT
-
-/* GNU/Linux uses ctype from glibc.a. I am not sure how complete it is.
- For now, we play safe. It may change later. */
-
-#if 0
-#undef MULTIBYTE_CHARS
-#define MULTIBYTE_CHARS 1
-#endif
-
-#ifndef USE_GNULIBC_1
-#undef DEFAULT_VTABLE_THUNKS
-#define DEFAULT_VTABLE_THUNKS 1
-#endif
-
-/* Use stabs instead of DWARF debug format. */
-#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
-
-#include <sparc/sysv4.h>
-
-#undef MD_EXEC_PREFIX
-#undef MD_STARTFILE_PREFIX
-
-/* Output at beginning of assembler file. */
-/* The .file command should always begin the output. */
-#undef ASM_FILE_START
-#define ASM_FILE_START(FILE) \
- do { \
- output_file_directive (FILE, main_input_filename); \
- fprintf (FILE, "\t.version\t\"01.01\"\n"); \
- } while (0)
-
-/* Provide a STARTFILE_SPEC appropriate for GNU/Linux. Here we add
- the GNU/Linux magical crtbegin.o file (see crtstuff.c) which
- provides part of the support for getting C++ file-scope static
- object constructed before entering `main'. */
-
-#undef STARTFILE_SPEC
-#define STARTFILE_SPEC \
- "%{!shared: \
- %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\
- crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
-
-/* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on
- the GNU/Linux magical crtend.o file (see crtstuff.c) which
- provides part of the support for getting C++ file-scope static
- object constructed before entering `main', followed by a normal
- GNU/Linux "finalizer" file, `crtn.o'. */
-
-#undef ENDFILE_SPEC
-#define ENDFILE_SPEC \
- "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
-
-/* This is for -profile to use -lc_p instead of -lc. */
-#undef CC1_SPEC
-#define CC1_SPEC "%{profile:-p} \
-%{sun4:} %{target:} \
-%{mcypress:-mcpu=cypress} \
-%{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
-%{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
-"
-
-#undef TARGET_VERSION
-#define TARGET_VERSION fprintf (stderr, " (sparc GNU/Linux with ELF)");
-
-#undef SIZE_TYPE
-#define SIZE_TYPE "unsigned int"
-
-#undef PTRDIFF_TYPE
-#define PTRDIFF_TYPE "int"
-
-#undef WCHAR_TYPE
-#define WCHAR_TYPE "long int"
-
-#undef WCHAR_TYPE_SIZE
-#define WCHAR_TYPE_SIZE BITS_PER_WORD
-
-#undef CPP_PREDEFINES
-#define CPP_PREDEFINES "-D__ELF__ -Dunix -D__sparc__ -Dlinux -Asystem(unix) -Asystem(posix)"
-
-#undef CPP_SUBTARGET_SPEC
-#ifdef USE_GNULIBC_1
-#define CPP_SUBTARGET_SPEC \
-"%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE}"
-#else
-#define CPP_SUBTARGET_SPEC \
-"%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
-#endif
-
-#undef LIB_SPEC
-/* We no longer link with libc_p.a or libg.a by default. If you
- want to profile or debug the GNU/Linux C library, please add
- -lc_p or -ggdb to LDFLAGS at the link time, respectively. */
-#if 1
-#ifdef USE_GNULIBC_1
-#define LIB_SPEC \
- "%{!shared: %{p:-lgmon} %{pg:-lgmon} %{profile:-lgmon -lc_p} \
- %{!profile:%{!ggdb:-lc} %{ggdb:-lg}}}"
-#else
-#define LIB_SPEC \
- "%{shared: -lc} \
- %{!shared: %{mieee-fp:-lieee} %{pthread:-lpthread} \
- %{profile:-lc_p} %{!profile: -lc}}"
-#endif
-#else
-#define LIB_SPEC \
- "%{!shared: \
- %{mieee-fp:-lieee} %{p:-lgmon -lc_p} %{pg:-lgmon -lc_p} \
- %{!p:%{!pg:%{!g*:-lc} %{g*:-lg}}}}"
-#endif
-
-/* Provide a LINK_SPEC appropriate for GNU/Linux. Here we provide support
- for the special GCC options -static and -shared, which allow us to
- link things in one of these three modes by applying the appropriate
- combinations of options at link-time. We like to support here for
- as many of the other GNU linker options as possible. But I don't
- have the time to search for those flags. I am sure how to add
- support for -soname shared_object_name. H.J.
-
- I took out %{v:%{!V:-V}}. It is too much :-(. They can use
- -Wl,-V.
-
- When the -shared link option is used a final link is not being
- done. */
-
-/* If ELF is the default format, we should not use /lib/elf. */
-
-#undef LINK_SPEC
-#ifdef USE_GNULIBC_1
-#ifndef LINUX_DEFAULT_ELF
-#define LINK_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
- %{!shared: \
- %{!ibcs: \
- %{!static: \
- %{rdynamic:-export-dynamic} \
- %{!dynamic-linker:-dynamic-linker /lib/elf/ld-linux.so.1} \
- %{!rpath:-rpath /lib/elf/}} %{static:-static}}}"
-#else
-#define LINK_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
- %{!shared: \
- %{!ibcs: \
- %{!static: \
- %{rdynamic:-export-dynamic} \
- %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.1}} \
- %{static:-static}}}"
-#endif
-#else
-#define LINK_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
- %{!shared: \
- %{!ibcs: \
- %{!static: \
- %{rdynamic:-export-dynamic} \
- %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
- %{static:-static}}}"
-#endif
-
-/* The sun bundled assembler doesn't accept -Yd, (and neither does gas).
- It's safe to pass -s always, even if -g is not used. */
-#undef ASM_SPEC
-#define ASM_SPEC \
- "%{V} %{v:%{!V:-V}} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s %{fpic:-K PIC} %{fPIC:-K PIC}"
-
-/* Same as sparc.h */
-#undef DBX_REGISTER_NUMBER
-#define DBX_REGISTER_NUMBER(REGNO) (REGNO)
-
-/* We use stabs-in-elf for debugging, because that is what the native
- toolchain uses. XXX */
-#undef PREFERRED_DEBUGGING_TYPE
-#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
-
-#undef ASM_OUTPUT_ALIGNED_LOCAL
-#define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
-do { \
- fputs ("\t.local\t", (FILE)); \
- assemble_name ((FILE), (NAME)); \
- putc ('\n', (FILE)); \
- ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN); \
-} while (0)
-
-#undef COMMON_ASM_OP
-#define COMMON_ASM_OP "\t.common"
-
-/* This is how to output a definition of an internal numbered label where
- PREFIX is the class of label and NUM is the number within the class. */
-
-#undef ASM_OUTPUT_INTERNAL_LABEL
-#define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \
- fprintf (FILE, ".L%s%d:\n", PREFIX, NUM)
-
-/* This is how to output a reference to an internal numbered label where
- PREFIX is the class of label and NUM is the number within the class. */
-
-#undef ASM_OUTPUT_INTERNAL_LABELREF
-#define ASM_OUTPUT_INTERNAL_LABELREF(FILE,PREFIX,NUM) \
- fprintf (FILE, ".L%s%d", PREFIX, NUM)
-
-/* This is how to store into the string LABEL
- the symbol_ref name of an internal numbered label where
- PREFIX is the class of label and NUM is the number within the class.
- This is suitable for output with `assemble_name'. */
-
-#undef ASM_GENERATE_INTERNAL_LABEL
-#define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
- sprintf (LABEL, "*.L%s%d", PREFIX, NUM)
-
-
-#if 0
-/* Define for support of TFmode long double and REAL_ARITHMETIC.
- Sparc ABI says that long double is 4 words. GNU/Linux does not support
- long double yet. */
-#define LONG_DOUBLE_TYPE_SIZE 128
-#endif
-
-/* Override MACHINE_STATE_{SAVE,RESTORE} because we have special
- traps available which can get and set the condition codes
- reliably. */
-#undef MACHINE_STATE_SAVE
-#define MACHINE_STATE_SAVE(ID) \
- unsigned long int ms_flags, ms_saveret; \
- asm volatile("ta 0x20\n\t" \
- "mov %%g1, %0\n\t" \
- "mov %%g2, %1\n\t" \
- : "=r" (ms_flags), "=r" (ms_saveret));
-
-#undef MACHINE_STATE_RESTORE
-#define MACHINE_STATE_RESTORE(ID) \
- asm volatile("mov %0, %%g1\n\t" \
- "mov %1, %%g2\n\t" \
- "ta 0x21\n\t" \
- : /* no outputs */ \
- : "r" (ms_flags), "r" (ms_saveret));
diff --git a/contrib/gcc/config/sparc/linux64.h b/contrib/gcc/config/sparc/linux64.h
deleted file mode 100644
index 705b5ca33a04..000000000000
--- a/contrib/gcc/config/sparc/linux64.h
+++ /dev/null
@@ -1,366 +0,0 @@
-/* Definitions for 64-bit SPARC running Linux-based GNU systems with ELF.
- Copyright 1996, 1997, 1998 Free Software Foundation, Inc.
- Contributed by David S. Miller (davem@caip.rutgers.edu)
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-#define SPARC_BI_ARCH
-
-#define LINUX_DEFAULT_ELF
-
-/* Don't assume anything about the header files. */
-#define NO_IMPLICIT_EXTERN_C
-
-#undef HAVE_ATEXIT
-#define HAVE_ATEXIT
-
-#include <sparc/sysv4.h>
-
-#undef MD_EXEC_PREFIX
-#undef MD_STARTFILE_PREFIX
-
-#if TARGET_CPU_DEFAULT == TARGET_CPU_v9 || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
-/* A 64 bit v9 compiler with stack-bias,
- in a Medium/Low code model environment. */
-
-#undef TARGET_DEFAULT
-#define TARGET_DEFAULT \
- (MASK_V9 + MASK_PTR64 + MASK_64BIT /* + MASK_HARD_QUAD */ \
- + MASK_STACK_BIAS + MASK_APP_REGS + MASK_EPILOGUE + MASK_FPU)
-#endif
-
-/* Output at beginning of assembler file. */
-/* The .file command should always begin the output. */
-#undef ASM_FILE_START
-#define ASM_FILE_START(FILE) \
- do { \
- output_file_directive (FILE, main_input_filename); \
- fprintf (FILE, "\t.version\t\"01.01\"\n"); \
- } while (0)
-
-#undef ASM_CPU_DEFAULT_SPEC
-#define ASM_CPU_DEFAULT_SPEC "-Av9a"
-
-/* Provide a STARTFILE_SPEC appropriate for GNU/Linux. Here we add
- the GNU/Linux magical crtbegin.o file (see crtstuff.c) which
- provides part of the support for getting C++ file-scope static
- object constructed before entering `main'. */
-
-#undef STARTFILE_SPEC
-
-#define STARTFILE_SPEC32 \
- "%{!shared: \
- %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}}\
- crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
-
-#define STARTFILE_SPEC64 \
- "%{!shared: \
- %{pg:/usr/lib64/gcrt1.o%s} %{!pg:%{p:/usr/lib64/gcrt1.o%s} %{!p:/usr/lib64/crt1.o%s}}}\
- /usr/lib64/crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
-
-#ifdef SPARC_BI_ARCH
-
-#if DEFAULT_ARCH32_P
-#define STARTFILE_SPEC "\
-%{m32:" STARTFILE_SPEC32 "} \
-%{m64:" STARTFILE_SPEC64 "} \
-%{!m32:%{!m64:" STARTFILE_SPEC32 "}}"
-#else
-#define STARTFILE_SPEC "\
-%{m32:" STARTFILE_SPEC32 "} \
-%{m64:" STARTFILE_SPEC64 "} \
-%{!m32:%{!m64:" STARTFILE_SPEC64 "}}"
-#endif
-
-#else
-
-#define STARTFILE_SPEC STARTFILE_SPEC64
-
-#endif
-
-/* Provide a ENDFILE_SPEC appropriate for GNU/Linux. Here we tack on
- the GNU/Linux magical crtend.o file (see crtstuff.c) which
- provides part of the support for getting C++ file-scope static
- object constructed before entering `main', followed by a normal
- GNU/Linux "finalizer" file, `crtn.o'. */
-
-#undef ENDFILE_SPEC
-
-#define ENDFILE_SPEC32 \
- "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
-
-#define ENDFILE_SPEC64 \
- "%{!shared:crtend.o%s} %{shared:crtendS.o%s} /usr/lib64/crtn.o%s"
-
-#ifdef SPARC_BI_ARCH
-
-#if DEFAULT_ARCH32_P
-#define ENDFILE_SPEC "\
-%{m32:" ENDFILE_SPEC32 "} \
-%{m64:" ENDFILE_SPEC64 "} \
-%{!m32:%{!m64:" ENDFILE_SPEC32 "}}"
-#else
-#define ENDFILE_SPEC "\
-%{m32:" ENDFILE_SPEC32 "} \
-%{m64:" ENDFILE_SPEC64 "} \
-%{!m32:%{!m64:" ENDFILE_SPEC64 "}}"
-#endif
-
-#else
-
-#define ENDFILE_SPEC ENDFILE_SPEC64
-
-#endif
-
-#undef TARGET_VERSION
-#define TARGET_VERSION fprintf (stderr, " (sparc64 GNU/Linux with ELF)");
-
-/* The default code model. */
-#undef SPARC_DEFAULT_CMODEL
-#define SPARC_DEFAULT_CMODEL CM_MEDLOW
-
-#undef WCHAR_TYPE
-#define WCHAR_TYPE "long int"
-
-#undef WCHAR_TYPE_SIZE
-#define WCHAR_TYPE_SIZE BITS_PER_WORD
-
-#undef LONG_DOUBLE_TYPE_SIZE
-#define LONG_DOUBLE_TYPE_SIZE 128
-
-#undef CPP_PREDEFINES
-#define CPP_PREDEFINES "-D__ELF__ -Dunix -D_LONGLONG -D__sparc__ -Dlinux -Asystem(unix) -Asystem(posix)"
-
-#undef CPP_SUBTARGET_SPEC
-#define CPP_SUBTARGET_SPEC "\
-%{fPIC:-D__PIC__ -D__pic__} \
-%{fpic:-D__PIC__ -D__pic__} \
-%{posix:-D_POSIX_SOURCE} \
-%{pthread:-D_REENTRANT} \
-"
-
-#undef LIB_SPEC
-#define LIB_SPEC \
- "%{shared: -lc} \
- %{!shared: %{mieee-fp:-lieee} %{pthread:-lpthread} \
- %{profile:-lc_p} %{!profile: -lc}}"
-
-/* Provide a LINK_SPEC appropriate for GNU/Linux. Here we provide support
- for the special GCC options -static and -shared, which allow us to
- link things in one of these three modes by applying the appropriate
- combinations of options at link-time. We like to support here for
- as many of the other GNU linker options as possible. But I don't
- have the time to search for those flags. I am sure how to add
- support for -soname shared_object_name. H.J.
-
- I took out %{v:%{!V:-V}}. It is too much :-(. They can use
- -Wl,-V.
-
- When the -shared link option is used a final link is not being
- done. */
-
-/* If ELF is the default format, we should not use /lib/elf. */
-
-#ifdef SPARC_BI_ARCH
-
-#undef SUBTARGET_EXTRA_SPECS
-#define SUBTARGET_EXTRA_SPECS \
- { "link_arch32", LINK_ARCH32_SPEC }, \
- { "link_arch64", LINK_ARCH64_SPEC }, \
- { "link_arch_default", LINK_ARCH_DEFAULT_SPEC }, \
- { "link_arch", LINK_ARCH_SPEC },
-
-#define LINK_ARCH32_SPEC "-m elf32_sparc -Y P,/usr/lib %{shared:-shared} \
- %{!shared: \
- %{!ibcs: \
- %{!static: \
- %{rdynamic:-export-dynamic} \
- %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
- %{static:-static}}} \
-"
-
-#define LINK_ARCH64_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \
- %{!shared: \
- %{!ibcs: \
- %{!static: \
- %{rdynamic:-export-dynamic} \
- %{!dynamic-linker:-dynamic-linker /lib64/ld-linux.so.2}} \
- %{static:-static}}} \
-"
-
-#define LINK_ARCH_SPEC "\
-%{m32:%(link_arch32)} \
-%{m64:%(link_arch64)} \
-%{!m32:%{!m64:%(link_arch_default)}} \
-"
-
-#define LINK_ARCH_DEFAULT_SPEC \
-(DEFAULT_ARCH32_P ? LINK_ARCH32_SPEC : LINK_ARCH64_SPEC)
-
-#undef LINK_SPEC
-#define LINK_SPEC "\
-%(link_arch) \
-%{mlittle-endian:-EL} \
-"
-
-#undef CC1_SPEC
-#if DEFAULT_ARCH32_P
-#define CC1_SPEC "\
-%{sun4:} %{target:} \
-%{mcypress:-mcpu=cypress} \
-%{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
-%{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
-%{m64:-mptr64 -mcpu=ultrasparc -mstack-bias} \
-"
-#else
-#define CC1_SPEC "\
-%{sun4:} %{target:} \
-%{mcypress:-mcpu=cypress} \
-%{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
-%{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
-%{m32:-mptr32 -mcpu=cypress -mno-stack-bias} \
-"
-#endif
-
-#if DEFAULT_ARCH32_P
-#define MULTILIB_DEFAULTS { "m32" }
-#else
-#define MULTILIB_DEFAULTS { "m64" }
-#endif
-
-#else /* !SPARC_BI_ARCH */
-
-#undef LINK_SPEC
-#define LINK_ARCH_SPEC "-m elf64_sparc -Y P,/usr/lib64 %{shared:-shared} \
- %{!shared: \
- %{!ibcs: \
- %{!static: \
- %{rdynamic:-export-dynamic} \
- %{!dynamic-linker:-dynamic-linker /lib64/ld-linux.so.2}} \
- %{static:-static}}} \
-%{mlittle-endian:-EL} \
-"
-
-#endif /* !SPARC_BI_ARCH */
-
-/* The sun bundled assembler doesn't accept -Yd, (and neither does gas).
- It's safe to pass -s always, even if -g is not used. */
-#undef ASM_SPEC
-#define ASM_SPEC "\
-%{V} \
-%{v:%{!V:-V}} \
-%{!Qn:-Qy} \
-%{n} \
-%{T} \
-%{Ym,*} \
-%{Wa,*:%*} \
--s %{fpic:-K PIC} %{fPIC:-K PIC} \
-%{mlittle-endian:-EL} \
-%(asm_cpu) %(asm_arch) \
-"
-
-/* Same as sparc.h */
-#undef DBX_REGISTER_NUMBER
-#define DBX_REGISTER_NUMBER(REGNO) (REGNO)
-
-/* System V Release 4 uses DWARF debugging info. Buf DWARF1 doesn't do
- 64-bit anything, so we use DWARF2. */
-
-#undef DWARF2_DEBUGGING_INFO
-#undef DWARF_DEBUGGING_INFO
-#undef DBX_DEBUGGING_INFO
-#define DWARF2_DEBUGGING_INFO
-#define DBX_DEBUGGING_INFO
-
-#undef PREFERRED_DEBUGGING_TYPE
-#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
-
-#undef ASM_OUTPUT_ALIGNED_LOCAL
-#define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
-do { \
- fputs ("\t.local\t", (FILE)); \
- assemble_name ((FILE), (NAME)); \
- putc ('\n', (FILE)); \
- ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN); \
-} while (0)
-
-#undef COMMON_ASM_OP
-#define COMMON_ASM_OP "\t.common"
-
-/* This is how to output a definition of an internal numbered label where
- PREFIX is the class of label and NUM is the number within the class. */
-
-#undef ASM_OUTPUT_INTERNAL_LABEL
-#define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \
- fprintf (FILE, ".L%s%d:\n", PREFIX, NUM)
-
-/* This is how to output a reference to an internal numbered label where
- PREFIX is the class of label and NUM is the number within the class. */
-
-#undef ASM_OUTPUT_INTERNAL_LABELREF
-#define ASM_OUTPUT_INTERNAL_LABELREF(FILE,PREFIX,NUM) \
- fprintf (FILE, ".L%s%d", PREFIX, NUM)
-
-/* This is how to store into the string LABEL
- the symbol_ref name of an internal numbered label where
- PREFIX is the class of label and NUM is the number within the class.
- This is suitable for output with `assemble_name'. */
-
-#undef ASM_GENERATE_INTERNAL_LABEL
-#define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
- sprintf (LABEL, "*.L%s%d", PREFIX, NUM)
-
-/* Stabs doesn't use this, and it confuses a simulator. */
-/* ??? Need to see what DWARF needs, if anything. */
-#undef ASM_IDENTIFY_GCC
-#define ASM_IDENTIFY_GCC(FILE)
-
-/* Define the names of various pseudo-ops used by the Sparc/svr4 assembler.
- ??? If ints are 64 bits then UNALIGNED_INT_ASM_OP (defined elsewhere) is
- misnamed. These should all refer to explicit sizes (half/word/xword?),
- anything other than short/int/long/etc. */
-
-#define UNALIGNED_DOUBLE_INT_ASM_OP ".uaxword"
-
-/* DWARF bits. */
-
-/* Follow Irix 6 and not the Dwarf2 draft in using 64-bit offsets.
- Obviously the Dwarf2 folks havn't tried to actually build systems
- with their spec. On a 64-bit system, only 64-bit relocs become
- RELATIVE relocations. */
-
-/* #define DWARF_OFFSET_SIZE PTR_SIZE */
-
-/* Override MACHINE_STATE_{SAVE,RESTORE} because we have special
- traps available which can get and set the condition codes
- reliably. */
-#undef MACHINE_STATE_SAVE
-#define MACHINE_STATE_SAVE(ID) \
- unsigned long int ms_flags, ms_saveret; \
- asm volatile("ta 0x20\n\t" \
- "mov %%g1, %0\n\t" \
- "mov %%g2, %1\n\t" \
- : "=r" (ms_flags), "=r" (ms_saveret));
-
-#undef MACHINE_STATE_RESTORE
-#define MACHINE_STATE_RESTORE(ID) \
- asm volatile("mov %0, %%g1\n\t" \
- "mov %1, %%g2\n\t" \
- "ta 0x21\n\t" \
- : /* no outputs */ \
- : "r" (ms_flags), "r" (ms_saveret));
diff --git a/contrib/gcc/config/sparc/lite.h b/contrib/gcc/config/sparc/lite.h
deleted file mode 100644
index 55c232ac7798..000000000000
--- a/contrib/gcc/config/sparc/lite.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Definitions of target machine for GNU compiler, for SPARClite w/o FPU.
- Copyright (C) 1993, 1996 Free Software Foundation, Inc.
- Contributed by Jim Wilson (wilson@cygnus.com).
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-#include "sparc/sparc.h"
-
-#undef CPP_PREDEFINES
-#define CPP_PREDEFINES "-Dsparc -Dsparclite -Acpu(sparc) -Amachine(sparc)"
-
-#undef TARGET_VERSION
-#define TARGET_VERSION fprintf (stderr, " (sparclite)");
-
-/* Enable app-regs and epilogue options. Do not enable the fpu. */
-
-#undef TARGET_DEFAULT
-#define TARGET_DEFAULT (MASK_APP_REGS + MASK_EPILOGUE)
-
-/* US Software GOFAST library support. */
-#include "gofast.h"
-#undef INIT_SUBTARGET_OPTABS
-#define INIT_SUBTARGET_OPTABS INIT_GOFAST_OPTABS
diff --git a/contrib/gcc/config/sparc/litecoff.h b/contrib/gcc/config/sparc/litecoff.h
deleted file mode 100644
index bd89e1b46865..000000000000
--- a/contrib/gcc/config/sparc/litecoff.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/* Definitions of target machine for GNU compiler, for SPARClite w/o FPU, COFF.
- Copyright (C) 1994, 1996 Free Software Foundation, Inc.
- Written by Ken Raeburn (raeburn@cygnus.com).
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-#include "sparc/lite.h"
-
-#undef ASM_OUTPUT_IDENT
-
-#undef SELECT_SECTION
-#undef SELECT_RTX_SECTION
-#define BSS_SECTION_ASM_OP ".section\t\".bss\""
-
-#include "svr3.h"
-
-#undef CPP_PREDEFINES
-#define CPP_PREDEFINES "-Dsparc -Dsparclite -Acpu(sparc) -Amachine(sparc)"
-
-/* Default to stabs in COFF. */
-
-#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
-
-#include "dbxcoff.h"
-
-/* Support the ctors and dtors sections for g++. */
-
-#undef INIT_SECTION_ASM_OP
-
-/* Support the ctors and dtors sections for g++. */
-
-#undef CTORS_SECTION_ASM_OP
-#define CTORS_SECTION_ASM_OP ".section\t.ctors,\"x\""
-#undef DTORS_SECTION_ASM_OP
-#define DTORS_SECTION_ASM_OP ".section\t.dtors,\"x\""
-
-/* A list of other sections which the compiler might be "in" at any
- given time. */
-
-#undef EXTRA_SECTIONS
-#define EXTRA_SECTIONS in_const, in_ctors, in_dtors
-
-/* A list of extra section function definitions. */
-
-#undef EXTRA_SECTION_FUNCTIONS
-#define EXTRA_SECTION_FUNCTIONS \
- CONST_SECTION_FUNCTION \
- CTORS_SECTION_FUNCTION \
- DTORS_SECTION_FUNCTION
-
-#define CTORS_SECTION_FUNCTION \
-void \
-ctors_section () \
-{ \
- if (in_section != in_ctors) \
- { \
- fprintf (asm_out_file, "%s\n", CTORS_SECTION_ASM_OP); \
- in_section = in_ctors; \
- } \
-}
-
-#define DTORS_SECTION_FUNCTION \
-void \
-dtors_section () \
-{ \
- if (in_section != in_dtors) \
- { \
- fprintf (asm_out_file, "%s\n", DTORS_SECTION_ASM_OP); \
- in_section = in_dtors; \
- } \
-}
-
-#define INT_ASM_OP ".long"
-
-/* A C statement (sans semicolon) to output an element in the table of
- global constructors. */
-#undef ASM_OUTPUT_CONSTRUCTOR
-#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
- do { \
- ctors_section (); \
- fprintf (FILE, "\t%s\t ", INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
-/* A C statement (sans semicolon) to output an element in the table of
- global destructors. */
-#undef ASM_OUTPUT_DESTRUCTOR
-#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
- do { \
- dtors_section (); \
- fprintf (FILE, "\t%s\t ", INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
-#undef DO_GLOBAL_CTORS_BODY
-#undef DO_GLOBAL_DTORS_BODY
diff --git a/contrib/gcc/config/sparc/lynx-ng.h b/contrib/gcc/config/sparc/lynx-ng.h
deleted file mode 100644
index 9e9f82cf10b6..000000000000
--- a/contrib/gcc/config/sparc/lynx-ng.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* Definitions for SPARC running LynxOS, using Lynx's old as and ld.
- Copyright (C) 1993, 1995 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-#include <sparc/sparc.h>
-#include <lynx-ng.h>
-
-/* ??? Must redefine to get sparclite and v8 defines. Can this be done
- differently? */
-
-#undef CPP_SPEC
-#define CPP_SPEC "%{mthreads:-D_MULTITHREADED} \
- %{mposix:-D_POSIX_SOURCE} \
- %{msystem-v:-I/usr/include_v} \
- %(cpp_cpu)"
-
-/* Names to predefine in the preprocessor for this target machine. */
-
-#undef CPP_PREDEFINES
-#define CPP_PREDEFINES "-Dunix -Dsparc -DLynx -DIBITS32 -Asystem(unix) -Asystem(lynx) -Acpu(sparc) -Amachine(sparc)"
-
-/* Provide required defaults for linker switches. */
-
-#undef LINK_SPEC
-#define LINK_SPEC "-e __main -T 0 %{msystem-v:-V} %{mcoff:-k}"
diff --git a/contrib/gcc/config/sparc/lynx.h b/contrib/gcc/config/sparc/lynx.h
deleted file mode 100644
index 99b319a0df22..000000000000
--- a/contrib/gcc/config/sparc/lynx.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* Definitions for SPARC running LynxOS.
- Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-#include <sparc/sparc.h>
-
-#undef ASM_OUTPUT_IDENT
-#undef SELECT_SECTION
-#undef SELECT_RTX_SECTION
-
-#define BSS_SECTION_ASM_OP ".section\t\".bss\""
-
-#include <lynx.h>
-
-/* ??? Must redefine to get sparclite and v8 defines. Can this be done
- differently? */
-
-#undef CPP_SPEC
-#define CPP_SPEC "%{mthreads:-D_MULTITHREADED} \
- %{mposix:-D_POSIX_SOURCE} \
- %{msystem-v:-I/usr/include_v} \
- %(cpp_cpu)"
-
-/* Names to predefine in the preprocessor for this target machine. */
-
-#undef CPP_PREDEFINES
-#define CPP_PREDEFINES "-Dunix -Dsparc -DSPARC -DLynx -DLYNX -DIBITS32 -Asystem(unix) -Asystem(lynx) -Acpu(sparc) -Amachine(sparc)"
-
-#undef LINK_SPEC
-
-/* Sparc version of libc.a has references to libm.a (printf calls pow for
- instance), so we must always link both. */
-
-#undef LIB_SPEC
-#define LIB_SPEC "%{mthreads:-L/lib/thread/} \
- %{msystem-v:-lc_v -lm_v -lc_v} \
- %{!msystem-v:%{mposix:-lc_p} -lc -lm -lc}"
diff --git a/contrib/gcc/config/sparc/netbsd.h b/contrib/gcc/config/sparc/netbsd.h
deleted file mode 100644
index a512f41e1553..000000000000
--- a/contrib/gcc/config/sparc/netbsd.h
+++ /dev/null
@@ -1,46 +0,0 @@
-#include <sparc/sparc.h>
-
-/* Get generic NetBSD definitions. */
-
-#include <netbsd.h>
-
-/* Names to predefine in the preprocessor for this target machine. */
-
-#undef CPP_PREDEFINES
-#define CPP_PREDEFINES "-Dunix -Dsparc -D__NetBSD__ -Asystem(unix) -Asystem(NetBSD) -Acpu(sparc) -Amachine(sparc)"
-
-/* Make gcc agree with <machine/ansi.h> */
-
-#undef SIZE_TYPE
-#define SIZE_TYPE "unsigned int"
-
-#undef PTRDIFF_TYPE
-#define PTRDIFF_TYPE "int"
-
-#undef WCHAR_TYPE
-#define WCHAR_TYPE "int"
-
-#undef WCHAR_UNSIGNED
-#define WCHAR_UNSIGNED 0
-
-#undef WCHAR_TYPE_SIZE
-#define WCHAR_TYPE_SIZE 32
-
-/* This is BSD, so it wants DBX format. */
-
-#define DBX_DEBUGGING_INFO
-
-/* This is the char to use for continuation (in case we need to turn
- continuation back on). */
-
-#define DBX_CONTIN_CHAR '?'
-
-/* Don't default to pcc-struct-return, because gcc is the only compiler, and
- we want to retain compatibility with older gcc versions. */
-#undef DEFAULT_PCC_STRUCT_RETURN
-#define DEFAULT_PCC_STRUCT_RETURN 0
-
-/* Until they use ELF or something that handles dwarf2 unwinds
- and initialization stuff better. */
-#define DWARF2_UNWIND_INFO 0
-
diff --git a/contrib/gcc/config/sparc/openbsd.h b/contrib/gcc/config/sparc/openbsd.h
deleted file mode 100644
index 19ece975e99e..000000000000
--- a/contrib/gcc/config/sparc/openbsd.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* Configuration file for sparc OpenBSD target.
- Copyright (C) 1999 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-#include <sparc/sparc.h>
-
-/* Get generic OpenBSD definitions. */
-#define OBSD_OLD_GAS
-#include <openbsd.h>
-
-/* Run-time target specifications. */
-#define CPP_PREDEFINES "-D__unix__ -D__sparc__ -D__OpenBSD__ -Asystem(unix) -Asystem(OpenBSD) -Acpu(sparc) -Amachine(sparc)"
-
-/* Layout of source language data types */
-
-/* This must agree with <machine/ansi.h> */
-#undef SIZE_TYPE
-#define SIZE_TYPE "unsigned int"
-
-#undef PTRDIFF_TYPE
-#define PTRDIFF_TYPE "int"
-
-#undef WCHAR_TYPE
-#define WCHAR_TYPE "int"
-
-#undef WCHAR_TYPE_SIZE
-#define WCHAR_TYPE_SIZE 32
-
-/* Specific options for DBX Output. */
-
-/* This is BSD, so it wants DBX format. */
-#define DBX_DEBUGGING_INFO
-
-/* This is the char to use for continuation */
-#define DBX_CONTIN_CHAR '?'
-
-/* Stack & calling: aggregate returns. */
-
-/* Don't default to pcc-struct-return, because gcc is the only compiler, and
- we want to retain compatibility with older gcc versions. */
-#undef DEFAULT_PCC_STRUCT_RETURN
-#define DEFAULT_PCC_STRUCT_RETURN 0
-
-/* Assembler format: exception region output. */
-
-/* All configurations that don't use elf must be explicit about not using
- dwarf unwind information. egcs doesn't try too hard to check internal
- configuration files... */
-#define DWARF2_UNWIND_INFO 0
-
-/* Default sparc.h does already define ASM_OUTPUT_MI_THUNK */
-
diff --git a/contrib/gcc/config/sparc/pbd.h b/contrib/gcc/config/sparc/pbd.h
deleted file mode 100644
index b70fdcb259b5..000000000000
--- a/contrib/gcc/config/sparc/pbd.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/* Definitions of target machine for GNU compiler, Citicorp/TTI Unicom PBD
- version (using GAS and COFF (encapsulated is unacceptable) )
- Copyright (C) 1990, 1996 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-#include "sparc/sparc.h"
-
-/* Names to predefine in the preprocessor for this target machine. */
-
-#undef CPP_PREDEFINES
-#define CPP_PREDEFINES "-Dsparc -DUnicomPBD -Dunix -D__GCC_NEW_VARARGS__ -Asystem(unix) -Acpu(sparc) -Amachine(sparc)"
-
-/* We want DBX format for use with gdb under COFF. */
-
-#define DBX_DEBUGGING_INFO
-
-/* Generate calls to memcpy, memcmp and memset. */
-
-#define TARGET_MEM_FUNCTIONS
-
-/* we use /lib/libp/lib* when profiling */
-
-#undef LIB_SPEC
-#define LIB_SPEC "%{p:-L/usr/lib/libp} %{pg:-L/usr/lib/libp} -lc"
-
-
-/* Use crt1.o as a startup file and crtn.o as a closing file. */
-/*
- * The loader directive file gcc.ifile defines how to merge the constructor
- * sections into the data section. Also, since gas only puts out those
- * sections in response to N_SETT stabs, and does not (yet) have a
- * ".sections" directive, gcc.ifile also defines the list symbols
- * __DTOR_LIST__ and __CTOR_LIST__.
- *
- * Finally, we must explicitly specify the file from libgcc.a that defines
- * exit(), otherwise if the user specifies (for example) "-lc_s" on the
- * command line, the wrong exit() will be used and global destructors will
- * not get called .
- */
-
-#define STARTFILE_SPEC \
-"%{!r: gcc.ifile%s} %{pg:gcrt1.o%s}%{!pg:%{p:mcrt1.o%s}%{!p:crt1.o%s}} \
-%{!r:_exit.o%s}"
-
-#define ENDFILE_SPEC "crtn.o%s"
-
-/* cpp has to support a #sccs directive for the /usr/include files */
-
-#define SCCS_DIRECTIVE
-
-/* LINK_SPEC is needed only for SunOS 4. */
-
-#undef LINK_SPEC
-
-/* Although the gas we use can create .ctor and .dtor sections from N_SETT
- stabs, it does not support section directives, so we need to have the loader
- define the lists.
- */
-#define CTOR_LISTS_DEFINED_EXTERNALLY
-
-/* similar to default, but allows for the table defined by ld with gcc.ifile.
- nptrs is always 0. So we need to instead check that __DTOR_LIST__[1] != 0.
- The old check is left in so that the same macro can be used if and when
- a future version of gas does support section directives. */
-
-#define DO_GLOBAL_DTORS_BODY {int nptrs = *(int *)__DTOR_LIST__; int i; \
- if (nptrs == -1 || (__DTOR_LIST__[0] == 0 && __DTOR_LIST__[1] != 0)) \
- for (nptrs = 0; __DTOR_LIST__[nptrs + 1] != 0; nptrs++); \
- for (i = nptrs; i >= 1; i--) \
- __DTOR_LIST__[i] (); }
-
-/*
- * Here is an example gcc.ifile. I've tested it on PBD sparc
- * systems. The NEXT(0x200000) works on just about all 386 and m68k systems,
- * but can be reduced to any power of 2 that is >= NBPS (0x40000 on a pbd).
-
- SECTIONS {
- .text BIND(0x41000200) BLOCK (0x200) :
- { *(.init) *(.text) vfork = fork; *(.fini) }
-
- GROUP BIND( NEXT(0x200000) + ADDR(.text) + SIZEOF(.text)):
- { .data : { __CTOR_LIST__ = . ; . += 4; *(.ctor) . += 4 ;
- __DTOR_LIST__ = . ; . += 4; *(.dtor) . += 4 ; }
- .bss : { }
- }
- }
- */
-
-/* The prefix to add to user-visible assembler symbols. */
-
-#undef USER_LABEL_PREFIX
-#define USER_LABEL_PREFIX ""
-
-/* fixes: */
-/*
- * Internal labels are prefixed with a period.
- */
-
-/* This is how to store into the string LABEL
- the symbol_ref name of an internal numbered label where
- PREFIX is the class of label and NUM is the number within the class.
- This is suitable for output with `assemble_name'. */
-
-#undef ASM_GENERATE_INTERNAL_LABEL
-
-#define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
- sprintf (LABEL, "*.%s%d", PREFIX, NUM)
-
-
-/* This is how to output an internal numbered label where
- PREFIX is the class of label and NUM is the number within the class. */
-
-#undef ASM_OUTPUT_INTERNAL_LABEL
-#define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \
- fprintf (FILE, ".%s%d:\n", PREFIX, NUM)
-
-/* This is how to output an element of a case-vector that is relative. */
-
-#undef ASM_OUTPUT_ADDR_DIFF_ELT
-#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
- fprintf (FILE, "\t.word .L%d-.L%d\n", VALUE, REL)
-
-/* This is how to output an element of a case-vector that is absolute.
- (The 68000 does not use such vectors,
- but we must define this macro anyway.) */
-
-#undef ASM_OUTPUT_ADDR_VEC_ELT
-#define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
- fprintf (FILE, "\t.word .L%d\n", VALUE)
-
-/* This is needed for SunOS 4.0, and should not hurt for 3.2
- versions either. */
-#undef ASM_OUTPUT_SOURCE_LINE(file, line)
-#define ASM_OUTPUT_SOURCE_LINE(file, line) \
- { static int sym_lineno = 1; \
- fprintf (file, ".stabn 68,0,%d,.LM%d\n.LM%d:\n", \
- line, sym_lineno, sym_lineno); \
- sym_lineno += 1; }
-
-#define ASM_INT_OP ".long "
diff --git a/contrib/gcc/config/sparc/rtems.h b/contrib/gcc/config/sparc/rtems.h
deleted file mode 100644
index 1ab0a4216fd9..000000000000
--- a/contrib/gcc/config/sparc/rtems.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Definitions for rtems targeting a SPARC using a.out.
- Copyright (C) 1996, 1997 Free Software Foundation, Inc.
- Contributed by Joel Sherrill (joel@OARcorp.com).
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-#include "sparc/aout.h"
-
-/* Specify predefined symbols in preprocessor. */
-
-#undef CPP_PREDEFINES
-#define CPP_PREDEFINES "-Dsparc -D__GCC_NEW_VARARGS__ -Drtems -D__rtems__ \
- -Asystem(rtems) -Acpu(sparc) -Amachine(sparc)"
-
-/* Generate calls to memcpy, memcmp and memset. */
-#ifndef TARGET_MEM_FUNCTIONS
-#define TARGET_MEM_FUNCTIONS
-#endif
-
-/* end of sparc/rtems.h */
diff --git a/contrib/gcc/config/sparc/sol2-c1.asm b/contrib/gcc/config/sparc/sol2-c1.asm
deleted file mode 100644
index 894a8c34c084..000000000000
--- a/contrib/gcc/config/sparc/sol2-c1.asm
+++ /dev/null
@@ -1,110 +0,0 @@
-! crt1.s for sparc & sparcv9 (SunOS 5)
-
-! Copyright (C) 1992 Free Software Foundation, Inc.
-! Written By David Vinayak Henkel-Wallace, June 1992
-!
-! This file is free software; you can redistribute it and/or modify it
-! under the terms of the GNU General Public License as published by the
-! Free Software Foundation; either version 2, or (at your option) any
-! later version.
-!
-! In addition to the permissions in the GNU General Public License, the
-! Free Software Foundation gives you unlimited permission to link the
-! compiled version of this file with other programs, and to distribute
-! those programs without any restriction coming from the use of this
-! file. (The General Public License restrictions do apply in other
-! respects; for example, they cover modification of the file, and
-! distribution when not linked into another program.)
-!
-! This file is distributed in the hope that it will be useful, but
-! WITHOUT ANY WARRANTY; without even the implied warranty of
-! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-! General Public License for more details.
-!
-! You should have received a copy of the GNU General Public License
-! along with this program; see the file COPYING. If not, write to
-! the Free Software Foundation, 59 Temple Place - Suite 330,
-! Boston, MA 02111-1307, USA.
-!
-! As a special exception, if you link this library with files
-! compiled with GCC to produce an executable, this does not cause
-! the resulting executable to be covered by the GNU General Public License.
-! This exception does not however invalidate any other reasons why
-! the executable file might be covered by the GNU General Public License.
-!
-
-! This file takes control of the process from the kernel, as specified
-! in section 3 of the SVr4 ABI.
-! This file is the first thing linked into any executable.
-
-#ifdef __sparcv9
-#define CPTRSIZE 8
-#define CPTRSHIFT 3
-#define STACK_BIAS 2047
-#define ldn ldx
-#define stn stx
-#define setn(s, scratch, dst) setx s, scratch, dst
-#else
-#define CPTRSIZE 4
-#define CPTRSHIFT 2
-#define STACK_BIAS 0
-#define ldn ld
-#define stn st
-#define setn(s, scratch, dst) set s, dst
-#endif
-
- .section ".text"
- .proc 022
- .global _start
-
-_start:
- mov 0, %fp ! Mark bottom frame pointer
- ldn [%sp + (16 * CPTRSIZE) + STACK_BIAS], %l0 ! argc
- add %sp, (17 * CPTRSIZE) + STACK_BIAS, %l1 ! argv
-
- ! Leave some room for a call. Sun leaves 32 octets (to sit on
- ! a cache line?) so we do too.
-#ifdef __sparcv9
- sub %sp, 48, %sp
-#else
- sub %sp, 32, %sp
-#endif
-
- ! %g1 may contain a function to be registered w/atexit
- orcc %g0, %g1, %g0
-#ifdef __sparcv9
- be %xcc, .nope
-#else
- be .nope
-#endif
- mov %g1, %o0
- call atexit
- nop
-.nope:
- ! Now make sure constructors and destructors are handled.
- setn(_fini, %o1, %o0)
- call atexit, 1
- nop
- call _init, 0
- nop
-
- ! We ignore the auxiliary vector; there is no defined way to
- ! access those data anyway. Instead, go straight to main:
- mov %l0, %o0 ! argc
- mov %l1, %o1 ! argv
- ! Skip argc words past argv, to env:
- sll %l0, CPTRSHIFT, %o2
- add %o2, CPTRSIZE, %o2
- add %l1, %o2, %o2 ! env
- setn(_environ, %o4, %o3)
- stn %o2, [%o3] ! *_environ
- call main, 4
- nop
- call exit, 0
- nop
- call _exit, 0
- nop
- ! We should never get here.
-
- .type _start,#function
- .size _start,.-_start
diff --git a/contrib/gcc/config/sparc/sol2-ci.asm b/contrib/gcc/config/sparc/sol2-ci.asm
deleted file mode 100644
index 3dc793c0c89c..000000000000
--- a/contrib/gcc/config/sparc/sol2-ci.asm
+++ /dev/null
@@ -1,68 +0,0 @@
-! crti.s for solaris 2.0.
-
-! Copyright (C) 1992 Free Software Foundation, Inc.
-! Written By David Vinayak Henkel-Wallace, June 1992
-!
-! This file is free software; you can redistribute it and/or modify it
-! under the terms of the GNU General Public License as published by the
-! Free Software Foundation; either version 2, or (at your option) any
-! later version.
-!
-! In addition to the permissions in the GNU General Public License, the
-! Free Software Foundation gives you unlimited permission to link the
-! compiled version of this file with other programs, and to distribute
-! those programs without any restriction coming from the use of this
-! file. (The General Public License restrictions do apply in other
-! respects; for example, they cover modification of the file, and
-! distribution when not linked into another program.)
-!
-! This file is distributed in the hope that it will be useful, but
-! WITHOUT ANY WARRANTY; without even the implied warranty of
-! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-! General Public License for more details.
-!
-! You should have received a copy of the GNU General Public License
-! along with this program; see the file COPYING. If not, write to
-! the Free Software Foundation, 59 Temple Place - Suite 330,
-! Boston, MA 02111-1307, USA.
-!
-! As a special exception, if you link this library with files
-! compiled with GCC to produce an executable, this does not cause
-! the resulting executable to be covered by the GNU General Public License.
-! This exception does not however invalidate any other reasons why
-! the executable file might be covered by the GNU General Public License.
-!
-
-! This file just make a stack frame for the contents of the .fini and
-! .init sections. Users may put any desired instructions in those
-! sections.
-
-! This file is linked in before the Values-Xx.o files and also before
-! crtbegin, with which perhaps it should be merged.
-
- .file "crti.s"
-
- .section ".init"
- .proc 022
- .global _init
- .type _init,#function
- .align 4
-_init:
-#ifdef __sparcv9
- save %sp, -176, %sp
-#else
- save %sp, -96, %sp
-#endif
-
-
- .section ".fini"
- .proc 022
- .global _fini
- .type _fini,#function
- .align 4
-_fini:
-#ifdef __sparcv9
- save %sp, -176, %sp
-#else
- save %sp, -96, %sp
-#endif
diff --git a/contrib/gcc/config/sparc/sol2-cn.asm b/contrib/gcc/config/sparc/sol2-cn.asm
deleted file mode 100644
index 49e070f34f4c..000000000000
--- a/contrib/gcc/config/sparc/sol2-cn.asm
+++ /dev/null
@@ -1,54 +0,0 @@
-! crtn.s for solaris 2.0.
-
-! Copyright (C) 1992 Free Software Foundation, Inc.
-! Written By David Vinayak Henkel-Wallace, June 1992
-!
-! This file is free software; you can redistribute it and/or modify it
-! under the terms of the GNU General Public License as published by the
-! Free Software Foundation; either version 2, or (at your option) any
-! later version.
-!
-! In addition to the permissions in the GNU General Public License, the
-! Free Software Foundation gives you unlimited permission to link the
-! compiled version of this file with other programs, and to distribute
-! those programs without any restriction coming from the use of this
-! file. (The General Public License restrictions do apply in other
-! respects; for example, they cover modification of the file, and
-! distribution when not linked into another program.)
-!
-! This file is distributed in the hope that it will be useful, but
-! WITHOUT ANY WARRANTY; without even the implied warranty of
-! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-! General Public License for more details.
-!
-! You should have received a copy of the GNU General Public License
-! along with this program; see the file COPYING. If not, write to
-! the Free Software Foundation, 59 Temple Place - Suite 330,
-! Boston, MA 02111-1307, USA.
-!
-! As a special exception, if you link this library with files
-! compiled with GCC to produce an executable, this does not cause
-! the resulting executable to be covered by the GNU General Public License.
-! This exception does not however invalidate any other reasons why
-! the executable file might be covered by the GNU General Public License.
-!
-
-! This file just makes sure that the .fini and .init sections do in
-! fact return. Users may put any desired instructions in those sections.
-! This file is the last thing linked into any executable.
-
- .file "crtn.s"
-
- .section ".init"
- .align 4
-
- ret
- restore
-
- .section ".fini"
- .align 4
-
- ret
- restore
-
-! Th-th-th-that is all folks!
diff --git a/contrib/gcc/config/sparc/sol2-g1.asm b/contrib/gcc/config/sparc/sol2-g1.asm
deleted file mode 100644
index b9d878856f8d..000000000000
--- a/contrib/gcc/config/sparc/sol2-g1.asm
+++ /dev/null
@@ -1,88 +0,0 @@
-! gcrt1.s for solaris 2.0.
-
-! Copyright (C) 1992 Free Software Foundation, Inc.
-! Written By David Vinayak Henkel-Wallace, June 1992
-!
-! This file is free software; you can redistribute it and/or modify it
-! under the terms of the GNU General Public License as published by the
-! Free Software Foundation; either version 2, or (at your option) any
-! later version.
-!
-! In addition to the permissions in the GNU General Public License, the
-! Free Software Foundation gives you unlimited permission to link the
-! compiled version of this file with other programs, and to distribute
-! those programs without any restriction coming from the use of this
-! file. (The General Public License restrictions do apply in other
-! respects; for example, they cover modification of the file, and
-! distribution when not linked into another program.)
-!
-! This file is distributed in the hope that it will be useful, but
-! WITHOUT ANY WARRANTY; without even the implied warranty of
-! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-! General Public License for more details.
-!
-! You should have received a copy of the GNU General Public License
-! along with this program; see the file COPYING. If not, write to
-! the Free Software Foundation, 59 Temple Place - Suite 330,
-! Boston, MA 02111-1307, USA.
-!
-! As a special exception, if you link this library with files
-! compiled with GCC to produce an executable, this does not cause
-! the resulting executable to be covered by the GNU General Public License.
-! This exception does not however invalidate any other reasons why
-! the executable file might be covered by the GNU General Public License.
-!
-
-! This file takes control of the process from the kernel, as specified
-! in section 3 of the SVr4 ABI.
-! This file is the first thing linked into any executable.
-
- .section ".text"
- .proc 022
- .global _start
-
-_start:
- mov 0, %fp ! Mark bottom frame pointer
- ld [%sp + 64], %l0 ! argc
- add %sp, 68, %l1 ! argv
-
- ! Leave some room for a call. Sun leaves 32 octets (to sit on
- ! a cache line?) so we do too.
- sub %sp, 32, %sp
-
- ! %g1 may contain a function to be registered w/atexit
- orcc %g0, %g1, %g0
- be .nope
- mov %g1, %o0
- call atexit
- nop
-.nope:
- ! Now make sure constructors and destructors are handled.
- set _fini, %o0
- call atexit, 1
- nop
- call _init, 0
- nop
-
- ! We ignore the auxiliary vector; there's no defined way to
- ! access those data anyway. Instead, go straight to main:
- mov %l0, %o0 ! argc
- mov %l1, %o1 ! argv
- set ___Argv, %o3
- st %o1, [%o3] ! *___Argv
- ! Skip argc words past argv, to env:
- sll %l0, 2, %o2
- add %o2, 4, %o2
- add %l1, %o2, %o2 ! env
- set _environ, %o3
- st %o2, [%o3] ! *_environ
- call main, 4
- nop
- call exit, 0
- nop
- call _exit, 0
- nop
- ! We should never get here.
-
- .type _start,#function
- .size _start,.-_start
diff --git a/contrib/gcc/config/sparc/sol2-sld-64.h b/contrib/gcc/config/sparc/sol2-sld-64.h
deleted file mode 100644
index c2518d8def0b..000000000000
--- a/contrib/gcc/config/sparc/sol2-sld-64.h
+++ /dev/null
@@ -1,363 +0,0 @@
-/* Definitions of target machine for GNU compiler, for 64-bit SPARC
- running Solaris 2 using the system linker. */
-
-#define SPARC_BI_ARCH
-
-#include "sparc/sol2.h"
-
-/* At least up through Solaris 2.6,
- the system linker does not work with DWARF or DWARF2,
- since it does not have working support for relocations
- to unaligned data. */
-
-#define LINKER_DOES_NOT_WORK_WITH_DWARF2
-
-/* A 64 bit v9 compiler with stack-bias */
-
-#if TARGET_CPU_DEFAULT == TARGET_CPU_v9 || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
-#undef TARGET_DEFAULT
-#define TARGET_DEFAULT \
- (MASK_V9 + MASK_PTR64 + MASK_64BIT /* + MASK_HARD_QUAD */ + \
- MASK_STACK_BIAS + MASK_APP_REGS + MASK_EPILOGUE + MASK_FPU)
-#endif
-
-/* The default code model. */
-#undef SPARC_DEFAULT_CMODEL
-#define SPARC_DEFAULT_CMODEL CM_MEDANY
-
-#undef LONG_DOUBLE_TYPE_SIZE
-#define LONG_DOUBLE_TYPE_SIZE 128
-
-#undef ASM_CPU32_DEFAULT_SPEC
-#define ASM_CPU32_DEFAULT_SPEC ""
-#undef ASM_CPU64_DEFAULT_SPEC
-#define ASM_CPU64_DEFAULT_SPEC "-xarch=v9"
-
-#if TARGET_CPU_DEFAULT == TARGET_CPU_v9
-#undef CPP_CPU64_DEFAULT_SPEC
-#define CPP_CPU64_DEFAULT_SPEC ""
-#undef ASM_CPU32_DEFAULT_SPEC
-#define ASM_CPU32_DEFAULT_SPEC "-xarch=v8plus"
-#endif
-#if TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
-#undef CPP_CPU64_DEFAULT_SPEC
-#define CPP_CPU64_DEFAULT_SPEC ""
-#undef ASM_CPU32_DEFAULT_SPEC
-#define ASM_CPU32_DEFAULT_SPEC "-xarch=v8plusa"
-#undef ASM_CPU64_DEFAULT_SPEC
-#define ASM_CPU64_DEFAULT_SPEC "-xarch=v9a"
-#endif
-
-/* The sun bundled assembler doesn't accept -Yd, (and neither does gas).
- It's safe to pass -s always, even if -g is not used. */
-#undef ASM_SPEC
-#define ASM_SPEC "\
-%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s \
-%{fpic:-K PIC} %{fPIC:-K PIC} \
-%(asm_cpu)\
-"
-
-#if DEFAULT_ARCH32_P
-#define DEF_ARCH32_SPEC(__str) "%{!m64:" __str "}"
-#define DEF_ARCH64_SPEC(__str) "%{m64:" __str "}"
-#else
-#define DEF_ARCH32_SPEC(__str) "%{m32:" __str "}"
-#define DEF_ARCH64_SPEC(__str) "%{!m32:" __str "}"
-#endif
-
-#undef CPP_CPU_SPEC
-#define CPP_CPU_SPEC "\
-%{mcypress:} \
-%{msparclite:-D__sparclite__} \
-%{mf930:-D__sparclite__} %{mf934:-D__sparclite__} \
-%{mv8:" DEF_ARCH32_SPEC("-D__sparcv8") "} \
-%{msupersparc:-D__supersparc__ " DEF_ARCH32_SPEC("-D__sparcv8") "} \
-%{mcpu=sparclet:-D__sparclet__} %{mcpu=tsc701:-D__sparclet__} \
-%{mcpu=sparclite:-D__sparclite__} \
-%{mcpu=f930:-D__sparclite__} %{mcpu=f934:-D__sparclite__} \
-%{mcpu=v8:" DEF_ARCH32_SPEC("-D__sparcv8") "} \
-%{mcpu=supersparc:-D__supersparc__ " DEF_ARCH32_SPEC("-D__sparcv8") "} \
-%{mcpu=v9:" DEF_ARCH32_SPEC("-D__sparcv8") "} \
-%{mcpu=ultrasparc:" DEF_ARCH32_SPEC("-D__sparcv8") "} \
-%{!mcpu*:%{!mcypress:%{!msparclite:%{!mf930:%{!mf934:%{!mv8:%{!msupersparc:%(cpp_cpu_default)}}}}}}} \
-"
-
-#undef ASM_CPU_SPEC
-#define ASM_CPU_SPEC "\
-%{mcpu=ultrasparc:" DEF_ARCH32_SPEC("-xarch=v8plusa") DEF_ARCH64_SPEC("-xarch=v9a") "} \
-%{mcpu=v9:" DEF_ARCH32_SPEC("-xarch=v8plus") DEF_ARCH64_SPEC("-xarch=v9") "} \
-%{!mcpu=ultrasparc:%{!mcpu=v9:%{mcpu*:" DEF_ARCH32_SPEC("-xarch=v8") DEF_ARCH64_SPEC("-xarch=v9") "}}} \
-%{!mcpu*:%(asm_cpu_default)} \
-"
-
-#define STARTFILE_SPEC32 "\
-%{ansi:values-Xc.o%s} \
-%{!ansi: \
- %{traditional:values-Xt.o%s} \
- %{!traditional:values-Xa.o%s}}"
-
-#define STARTFILE_SPEC64 "\
-%{ansi:/usr/lib/sparcv9/values-Xc.o%s} \
-%{!ansi: \
- %{traditional:/usr/lib/sparcv9/values-Xt.o%s} \
- %{!traditional:/usr/lib/sparcv9/values-Xa.o%s}}"
-
-#ifdef SPARC_BI_ARCH
-
-#if DEFAULT_ARCH32_P
-#define STARTFILE_ARCH_SPEC "\
-%{m32:" STARTFILE_SPEC32 "} \
-%{m64:" STARTFILE_SPEC64 "} \
-%{!m32:%{!m64:" STARTFILE_SPEC32 "}}"
-#else
-#define STARTFILE_ARCH_SPEC "\
-%{m32:" STARTFILE_SPEC32 "} \
-%{m64:" STARTFILE_SPEC64 "} \
-%{!m32:%{!m64:" STARTFILE_SPEC64 "}}"
-#endif
-
-#else /* !SPARC_BI_ARCH */
-
-/* In this case we define MD_STARTFILE_PREFIX to /usr/lib/sparcv9/ */
-#define STARTFILE_ARCH_SPEC STARTFILE_SPEC32
-
-#endif /* !SPARC_BI_ARCH */
-
-#undef STARTFILE_SPEC
-#define STARTFILE_SPEC "%{!shared: \
- %{!symbolic: \
- %{p:mcrt1.o%s} \
- %{!p: \
- %{pg:gcrt1.o%s gmon.o%s} \
- %{!pg:crt1.o%s}}}} \
- crti.o%s" STARTFILE_ARCH_SPEC " \
- crtbegin.o%s"
-
-#ifdef SPARC_BI_ARCH
-
-#undef CPP_CPU_DEFAULT_SPEC
-#define CPP_CPU_DEFAULT_SPEC \
-(DEFAULT_ARCH32_P ? "\
-%{m64:" CPP_CPU64_DEFAULT_SPEC "} \
-%{!m64:" CPP_CPU32_DEFAULT_SPEC "} \
-" : "\
-%{m32:" CPP_CPU32_DEFAULT_SPEC "} \
-%{!m32:" CPP_CPU64_DEFAULT_SPEC "} \
-")
-
-#undef ASM_CPU_DEFAULT_SPEC
-#define ASM_CPU_DEFAULT_SPEC \
-(DEFAULT_ARCH32_P ? "\
-%{m64:" ASM_CPU64_DEFAULT_SPEC "} \
-%{!m64:" ASM_CPU32_DEFAULT_SPEC "} \
-" : "\
-%{m32:" ASM_CPU32_DEFAULT_SPEC "} \
-%{!m32:" ASM_CPU64_DEFAULT_SPEC "} \
-")
-
-#undef CPP_ARCH32_SPEC
-#define CPP_ARCH32_SPEC "-D__SIZE_TYPE__=unsigned\\ int -D__PTRDIFF_TYPE__=int \
--D__GCC_NEW_VARARGS__ -Acpu(sparc) -Amachine(sparc)"
-#undef CPP_ARCH64_SPEC
-#define CPP_ARCH64_SPEC "-D__SIZE_TYPE__=long\\ unsigned\\ int -D__PTRDIFF_TYPE__=long\\ int \
--D__arch64__ -Acpu(sparc64) -Amachine(sparcv9) -D__sparcv9"
-
-#undef CPP_ARCH_SPEC
-#define CPP_ARCH_SPEC "\
-%{m32:%(cpp_arch32)} \
-%{m64:%(cpp_arch64)} \
-%{!m32:%{!m64:%(cpp_arch_default)}} \
-"
-
-#undef ASM_ARCH_SPEC
-#define ASM_ARCH_SPEC ""
-
-#undef ASM_ARCH32_SPEC
-#define ASM_ARCH32_SPEC ""
-
-#undef ASM_ARCH64_SPEC
-#define ASM_ARCH64_SPEC ""
-
-#undef ASM_ARCH_DEFAULT_SPEC
-#define ASM_ARCH_DEFAULT_SPEC ""
-
-#undef SUBTARGET_EXTRA_SPECS
-#define SUBTARGET_EXTRA_SPECS \
- { "link_arch32", LINK_ARCH32_SPEC }, \
- { "link_arch64", LINK_ARCH64_SPEC }, \
- { "link_arch_default", LINK_ARCH_DEFAULT_SPEC }, \
- { "link_arch", LINK_ARCH_SPEC },
-
-/* This should be the same as in svr4.h, except with -R added. */
-#define LINK_ARCH32_SPEC \
- "%{G:-G} \
- %{YP,*} \
- %{R*} \
- %{compat-bsd: \
- %{!YP,*:%{p:-Y P,/usr/ucblib:/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
- %{pg:-Y P,/usr/ucblib:/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
- %{!p:%{!pg:-Y P,/usr/ucblib:/usr/ccs/lib:/usr/lib}}} \
- -R /usr/ucblib} \
- %{!compat-bsd: \
- %{!YP,*:%{p:-Y P,/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
- %{pg:-Y P,/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
- %{!p:%{!pg:-Y P,/usr/ccs/lib:/usr/lib}}}}"
-
-#define LINK_ARCH64_SPEC \
- "%{mcmodel=medlow:-M /usr/lib/ld/sparcv9/map.below4G} \
- %{G:-G} \
- %{YP,*} \
- %{R*} \
- %{compat-bsd: \
- %{!YP,*:%{p:-Y P,/usr/ucblib/sparcv9:/usr/lib/libp/sparcv9:/usr/lib/sparcv9} \
- %{pg:-Y P,/usr/ucblib/sparcv9:/usr/lib/libp/sparcv9:/usr/lib/sparcv9} \
- %{!p:%{!pg:-Y P,/usr/ucblib/sparcv9:/usr/lib/sparcv9}}} \
- -R /usr/ucblib} \
- %{!compat-bsd: \
- %{!YP,*:%{p:-Y P,/usr/lib/libp/sparcv9:/usr/lib/sparcv9} \
- %{pg:-Y P,/usr/lib/libp/sparcv9:/usr/lib/sparcv9} \
- %{!p:%{!pg:-Y P,/usr/lib/sparcv9}}}}"
-
-#define LINK_ARCH_SPEC "\
-%{m32:%(link_arch32)} \
-%{m64:%(link_arch64)} \
-%{!m32:%{!m64:%(link_arch_default)}} \
-"
-
-#define LINK_ARCH_DEFAULT_SPEC \
-(DEFAULT_ARCH32_P ? LINK_ARCH32_SPEC : LINK_ARCH64_SPEC)
-
-#undef LINK_SPEC
-#define LINK_SPEC \
- "%{h*} %{v:-V} \
- %{b} %{Wl,*:%*} \
- %{static:-dn -Bstatic} \
- %{shared:-G -dy %{!mimpure-text:-z text}} \
- %{symbolic:-Bsymbolic -G -dy -z text} \
- %(link_arch) \
- %{Qy:} %{!Qn:-Qy}"
-
-#undef CC1_SPEC
-#if DEFAULT_ARCH32_P
-#define CC1_SPEC "\
-%{sun4:} %{target:} \
-%{mcypress:-mcpu=cypress} \
-%{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
-%{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
-%{m64:-mptr64 -mcpu=v9 -mstack-bias -mno-v8plus} \
-"
-#else
-#define CC1_SPEC "\
-%{sun4:} %{target:} \
-%{mcypress:-mcpu=cypress} \
-%{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
-%{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
-%{m32:-mptr32 -mcpu=cypress -mno-stack-bias} \
-%{mv8plus:-m32 -mptr32 -mcpu=cypress -mno-stack-bias} \
-"
-#endif
-
-#if DEFAULT_ARCH32_P
-#define MULTILIB_DEFAULTS { "m32" }
-#else
-#define MULTILIB_DEFAULTS { "m64" }
-#endif
-
-#else /* !SPARC_BI_ARCH */
-
-/*
- * This should be the same as in sol2-sld.h, except with "/sparcv9"
- * appended to the paths and /usr/ccs/lib is no longer necessary
- */
-#undef LINK_SPEC
-#define LINK_SPEC \
- "%{h*} %{v:-V} \
- %{b} %{Wl,*:%*} \
- %{static:-dn -Bstatic} \
- %{shared:-G -dy %{!mimpure-text:-z text}} \
- %{symbolic:-Bsymbolic -G -dy -z text} \
- %{mcmodel=medlow:-M /usr/lib/ld/sparcv9/map.below4G} \
- %{G:-G} \
- %{YP,*} \
- %{R*} \
- %{compat-bsd: \
- %{!YP,*:%{p:-Y P,/usr/ucblib/sparcv9:/usr/lib/libp/sparcv9:/usr/lib/sparcv9} \
- %{pg:-Y P,/usr/ucblib/sparcv9:/usr/lib/libp/sparcv9:/usr/lib/sparcv9} \
- %{!p:%{!pg:-Y P,/usr/ucblib/sparcv9:/usr/lib/sparcv9}}} \
- -R /usr/ucblib} \
- %{!compat-bsd: \
- %{!YP,*:%{p:-Y P,/usr/lib/libp/sparcv9:/usr/lib/sparcv9} \
- %{pg:-Y P,/usr/lib/libp/sparcv9:/usr/lib/sparcv9} \
- %{!p:%{!pg:-Y P,/usr/lib/sparcv9}}}} \
- %{Qy:} %{!Qn:-Qy}"
-
-#undef MD_STARTFILE_PREFIX
-#define MD_STARTFILE_PREFIX "/usr/lib/sparcv9/"
-
-#endif /* ! SPARC_BI_ARCH */
-
-/*
- * Attempt to turn on access permissions for the stack.
- *
- * This code must be defined when compiling gcc but not when compiling
- * libgcc2.a, unless we're generating code for 64 bits SPARC
- *
- * _SC_STACK_PROT is only defined for post 2.6, but we want this code
- * to run always. 2.6 can change the stack protection but has no way to
- * query it.
- *
- */
-
-#define TRANSFER_FROM_TRAMPOLINE \
-static int need_enable_exec_stack; \
- \
-static void check_enabling(void) __attribute__ ((constructor)); \
-static void check_enabling(void) \
-{ \
- extern long sysconf(int); \
- \
- int prot = (int) sysconf(515 /*_SC_STACK_PROT */); \
- if (prot != 7) \
- need_enable_exec_stack = 1; \
-} \
- \
-void \
-__enable_execute_stack (addr) \
- void *addr; \
-{ \
- if (!need_enable_exec_stack) \
- return; \
- else { \
- long size = getpagesize (); \
- long mask = ~(size-1); \
- char *page = (char *) (((long) addr) & mask); \
- char *end = (char *) ((((long) (addr + TRAMPOLINE_SIZE)) & mask) + size); \
- \
- /* 7 is PROT_READ | PROT_WRITE | PROT_EXEC */ \
- if (mprotect (page, end - page, 7) < 0) \
- perror ("mprotect of trampoline code"); \
- } \
-}
-
-/* A C statement (sans semicolon) to output an element in the table of
- global constructors. */
-#undef ASM_OUTPUT_CONSTRUCTOR
-#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME) \
- do { \
- ctors_section (); \
- fprintf (FILE, "\t%s\t ", TARGET_ARCH64 ? ASM_LONGLONG : INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
-/* A C statement (sans semicolon) to output an element in the table of
- global destructors. */
-#undef ASM_OUTPUT_DESTRUCTOR
-#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME) \
- do { \
- dtors_section (); \
- fprintf (FILE, "\t%s\t ", TARGET_ARCH64 ? ASM_LONGLONG : INT_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, "\n"); \
- } while (0)
-
diff --git a/contrib/gcc/config/sparc/sol2-sld.h b/contrib/gcc/config/sparc/sol2-sld.h
deleted file mode 100644
index a82498791b90..000000000000
--- a/contrib/gcc/config/sparc/sol2-sld.h
+++ /dev/null
@@ -1,11 +0,0 @@
-/* Definitions of target machine for GNU compiler, for SPARC running Solaris 2
- using the system linker. */
-
-#include "sparc/sol2.h"
-
-/* At least up through Solaris 2.6,
- the system linker does not work with DWARF or DWARF2,
- since it does not have working support for relocations
- to unaligned data. */
-
-#define LINKER_DOES_NOT_WORK_WITH_DWARF2
diff --git a/contrib/gcc/config/sparc/sol2.h b/contrib/gcc/config/sparc/sol2.h
deleted file mode 100644
index 9274f9d9108e..000000000000
--- a/contrib/gcc/config/sparc/sol2.h
+++ /dev/null
@@ -1,236 +0,0 @@
-/* Definitions of target machine for GNU compiler, for SPARC running Solaris 2
- Copyright 1992, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
- Contributed by Ron Guilmette (rfg@netcom.com).
- Additional changes by David V. Henkel-Wallace (gumby@cygnus.com).
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-/* Supposedly the same as vanilla sparc svr4, except for the stuff below: */
-#include "sparc/sysv4.h"
-
-#undef CPP_PREDEFINES
-#define CPP_PREDEFINES \
-"-Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4 \
--Asystem(unix) -Asystem(svr4)"
-
-#undef CPP_SUBTARGET_SPEC
-#define CPP_SUBTARGET_SPEC "\
-%{pthreads:-D_REENTRANT -D_PTHREADS} \
-%{!pthreads:%{threads:-D_REENTRANT -D_SOLARIS_THREADS}} \
-%{compat-bsd:-iwithprefixbefore ucbinclude -I/usr/ucbinclude} \
-"
-
-/* The sun bundled assembler doesn't accept -Yd, (and neither does gas).
- It's safe to pass -s always, even if -g is not used. */
-#undef ASM_SPEC
-#define ASM_SPEC "\
-%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s \
-%{fpic:-K PIC} %{fPIC:-K PIC} \
-%(asm_cpu) \
-"
-
-/* This is here rather than in sparc.h because it's not known what
- other assemblers will accept. */
-#if TARGET_CPU_DEFAULT == TARGET_CPU_v9
-#undef ASM_CPU_DEFAULT_SPEC
-#define ASM_CPU_DEFAULT_SPEC "-xarch=v8plus"
-#endif
-#if TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
-#undef ASM_CPU_DEFAULT_SPEC
-#define ASM_CPU_DEFAULT_SPEC "-xarch=v8plusa"
-#endif
-#undef ASM_CPU_SPEC
-#define ASM_CPU_SPEC "\
-%{mcpu=v8plus:-xarch=v8plus} \
-%{mcpu=ultrasparc:-xarch=v8plusa} \
-%{!mcpu*:%(asm_cpu_default)} \
-"
-
-/* However it appears that Solaris 2.0 uses the same reg numbering as
- the old BSD-style system did. */
-
-#undef DBX_REGISTER_NUMBER
-/* Same as sparc.h */
-#define DBX_REGISTER_NUMBER(REGNO) \
- (TARGET_FLAT && REGNO == FRAME_POINTER_REGNUM ? 31 : REGNO)
-
-/* We use stabs-in-elf for debugging, because that is what the native
- toolchain uses. */
-#undef PREFERRED_DEBUGGING_TYPE
-#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
-
-/* The Solaris 2 assembler uses .skip, not .zero, so put this back. */
-#undef ASM_OUTPUT_SKIP
-#define ASM_OUTPUT_SKIP(FILE,SIZE) \
- fprintf (FILE, "\t.skip %u\n", (SIZE))
-
-/* Use .uahalf/.uaword so packed structure members don't generate
- assembler errors when using the native assembler. */
-#undef ASM_SHORT
-#define ASM_SHORT ".uahalf"
-#undef ASM_LONG
-#define ASM_LONG ".uaword"
-
-/* This is how to output a definition of an internal numbered label where
- PREFIX is the class of label and NUM is the number within the class. */
-
-#undef ASM_OUTPUT_INTERNAL_LABEL
-#define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \
- fprintf (FILE, ".L%s%d:\n", PREFIX, NUM)
-
-/* This is how to output a reference to an internal numbered label where
- PREFIX is the class of label and NUM is the number within the class. */
-
-#undef ASM_OUTPUT_INTERNAL_LABELREF
-#define ASM_OUTPUT_INTERNAL_LABELREF(FILE,PREFIX,NUM) \
- fprintf (FILE, ".L%s%d", PREFIX, NUM)
-
-/* This is how to store into the string LABEL
- the symbol_ref name of an internal numbered label where
- PREFIX is the class of label and NUM is the number within the class.
- This is suitable for output with `assemble_name'. */
-
-#undef ASM_GENERATE_INTERNAL_LABEL
-#define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
- sprintf ((LABEL), "*.L%s%ld", (PREFIX), (long)(NUM))
-
-
-/* We don't use the standard svr4 STARTFILE_SPEC because it's wrong for us.
- We don't use the standard LIB_SPEC only because we don't yet support c++ */
-
-#undef STARTFILE_SPEC
-#define STARTFILE_SPEC "%{!shared: \
- %{!symbolic: \
- %{p:mcrt1.o%s} \
- %{!p: \
- %{pg:gcrt1.o%s gmon.o%s} \
- %{!pg:crt1.o%s}}}} \
- crti.o%s \
- %{ansi:values-Xc.o%s} \
- %{!ansi: \
- %{traditional:values-Xt.o%s} \
- %{!traditional:values-Xa.o%s}} \
- crtbegin.o%s"
-
-/* ??? Note: in order for -compat-bsd to work fully,
- we must somehow arrange to fixincludes /usr/ucbinclude
- and put the result in $(libsubdir)/ucbinclude. */
-
-#undef LIB_SPEC
-#define LIB_SPEC \
- "%{compat-bsd:-lucb -lsocket -lnsl -lelf -laio} \
- %{!shared:\
- %{!symbolic:\
- %{pthreads:-lpthread} \
- %{!pthreads:%{threads:-lthread}} \
- -lc}}"
-
-#undef ENDFILE_SPEC
-#define ENDFILE_SPEC "crtend.o%s crtn.o%s"
-
-/* This should be the same as in svr4.h, except with -R added. */
-#undef LINK_SPEC
-#define LINK_SPEC \
- "%{h*} %{v:-V} \
- %{b} %{Wl,*:%*} \
- %{static:-dn -Bstatic} \
- %{shared:-G -dy %{!mimpure-text:-z text}} \
- %{symbolic:-Bsymbolic -G -dy -z text} \
- %{G:-G} \
- %{YP,*} \
- %{R*} \
- %{compat-bsd: \
- %{!YP,*:%{p:-Y P,/usr/ucblib:/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
- %{pg:-Y P,/usr/ucblib:/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
- %{!p:%{!pg:-Y P,/usr/ucblib:/usr/ccs/lib:/usr/lib}}} \
- -R /usr/ucblib} \
- %{!compat-bsd: \
- %{!YP,*:%{p:-Y P,/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
- %{pg:-Y P,/usr/ccs/lib/libp:/usr/lib/libp:/usr/ccs/lib:/usr/lib} \
- %{!p:%{!pg:-Y P,/usr/ccs/lib:/usr/lib}}}} \
- %{Qy:} %{!Qn:-Qy}"
-
-/* This defines which switch letters take arguments.
- It is as in svr4.h but with -R added. */
-
-#undef SWITCH_TAKES_ARG
-#define SWITCH_TAKES_ARG(CHAR) \
- (DEFAULT_SWITCH_TAKES_ARG(CHAR) \
- || (CHAR) == 'R' \
- || (CHAR) == 'h' \
- || (CHAR) == 'x' \
- || (CHAR) == 'z')
-
-/* ??? This does not work in SunOS 4.x, so it is not enabled in sparc.h.
- Instead, it is enabled here, because it does work under Solaris. */
-/* Define for support of TFmode long double and REAL_ARITHMETIC.
- Sparc ABI says that long double is 4 words. */
-#define LONG_DOUBLE_TYPE_SIZE 128
-
-/* But indicate that it isn't supported by the hardware. */
-#define WIDEST_HARDWARE_FP_SIZE 64
-
-#define STDC_0_IN_SYSTEM_HEADERS
-
-#define MULDI3_LIBCALL "__mul64"
-#define DIVDI3_LIBCALL "__div64"
-#define UDIVDI3_LIBCALL "__udiv64"
-#define MODDI3_LIBCALL "__rem64"
-#define UMODDI3_LIBCALL "__urem64"
-
-#undef INIT_SUBTARGET_OPTABS
-#define INIT_SUBTARGET_OPTABS \
- fixsfdi_libfunc = gen_rtx_SYMBOL_REF (Pmode, \
- TARGET_ARCH64 ? "__ftol" : "__ftoll"); \
- fixunssfdi_libfunc = gen_rtx_SYMBOL_REF (Pmode, \
- TARGET_ARCH64 ? "__ftoul" : "__ftoull"); \
- fixdfdi_libfunc = gen_rtx_SYMBOL_REF (Pmode, \
- TARGET_ARCH64 ? "__dtol" : "__dtoll"); \
- fixunsdfdi_libfunc = gen_rtx_SYMBOL_REF (Pmode, \
- TARGET_ARCH64 ? "__dtoul" : "__dtoull")
-
-/* No weird SPARC variants on Solaris */
-#undef TARGET_LIVE_G0
-#define TARGET_LIVE_G0 0
-#undef TARGET_BROKEN_SAVERESTORE
-#define TARGET_BROKEN_SAVERESTORE 0
-
-/* Solaris allows 64 bit out and global registers in 32 bit mode.
- sparc_override_options will disable V8+ if not generating V9 code. */
-#undef TARGET_DEFAULT
-#define TARGET_DEFAULT (MASK_APP_REGS + MASK_EPILOGUE + MASK_FPU + MASK_V8PLUS)
-
-/* Override MACHINE_STATE_{SAVE,RESTORE} because we have special
- traps available which can get and set the condition codes
- reliably. */
-#undef MACHINE_STATE_SAVE
-#define MACHINE_STATE_SAVE(ID) \
- unsigned long int ms_flags, ms_saveret; \
- asm volatile("ta 0x20\n\t" \
- "mov %%g1, %0\n\t" \
- "mov %%g2, %1\n\t" \
- : "=r" (ms_flags), "=r" (ms_saveret));
-
-#undef MACHINE_STATE_RESTORE
-#define MACHINE_STATE_RESTORE(ID) \
- asm volatile("mov %0, %%g1\n\t" \
- "mov %1, %%g2\n\t" \
- "ta 0x21\n\t" \
- : /* no outputs */ \
- : "r" (ms_flags), "r" (ms_saveret));
-
diff --git a/contrib/gcc/config/sparc/sp64-aout.h b/contrib/gcc/config/sparc/sp64-aout.h
deleted file mode 100644
index e3056dfbc54e..000000000000
--- a/contrib/gcc/config/sparc/sp64-aout.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Definitions of target machine for GNU compiler, for SPARC64, a.out.
- Copyright (C) 1994, 1996, 1997, 1998 Free Software Foundation, Inc.
- Contributed by Doug Evans, dje@cygnus.com.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-#include "sparc/sparc.h"
-#include "aoutos.h"
-
-#undef TARGET_VERSION
-#define TARGET_VERSION fprintf (stderr, " (sparc64-aout)")
-
-#undef TARGET_DEFAULT
-#define TARGET_DEFAULT \
- (MASK_V9 + MASK_PTR64 + MASK_64BIT + MASK_HARD_QUAD \
- + MASK_APP_REGS + MASK_EPILOGUE + MASK_FPU + MASK_STACK_BIAS)
-
-/* The only code model supported is Medium/Low. */
-#undef SPARC_DEFAULT_CMODEL
-#define SPARC_DEFAULT_CMODEL CM_MEDLOW
-
-#undef CPP_PREDEFINES
-#define CPP_PREDEFINES "-Dsparc -Acpu(sparc) -Amachine(sparc)"
diff --git a/contrib/gcc/config/sparc/sp64-elf.h b/contrib/gcc/config/sparc/sp64-elf.h
deleted file mode 100644
index 4fd81c55c470..000000000000
--- a/contrib/gcc/config/sparc/sp64-elf.h
+++ /dev/null
@@ -1,158 +0,0 @@
-/* Definitions of target machine for GNU compiler, for SPARC64, ELF.
- Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
- Contributed by Doug Evans, dje@cygnus.com.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-/* ??? We're taking the scheme of including another file and then overriding
- the values we don't like a bit too far here. The alternative is to more or
- less duplicate all of svr4.h, sparc/sysv4.h, and sparc/sol2.h here
- (suitably cleaned up). */
-
-#include "sparc/sol2.h"
-
-#undef TARGET_VERSION
-#define TARGET_VERSION fprintf (stderr, " (sparc64-elf)")
-
-/* A 64 bit v9 compiler in a Medium/Anywhere code model environment. */
-
-#undef TARGET_DEFAULT
-#define TARGET_DEFAULT \
-(MASK_V9 + MASK_PTR64 + MASK_64BIT + MASK_HARD_QUAD \
- + MASK_APP_REGS + MASK_EPILOGUE + MASK_FPU + MASK_STACK_BIAS)
-
-#undef SPARC_DEFAULT_CMODEL
-#define SPARC_DEFAULT_CMODEL CM_EMBMEDANY
-
-#undef CPP_PREDEFINES
-#define CPP_PREDEFINES "-Dsparc -D__ELF__ -Acpu(sparc) -Amachine(sparc)"
-
-/* __svr4__ is used by the C library (FIXME) */
-#undef CPP_SUBTARGET_SPEC
-#define CPP_SUBTARGET_SPEC "-D__svr4__"
-
-#undef MD_EXEC_PREFIX
-#undef MD_STARTFILE_PREFIX
-
-#undef ASM_SPEC
-#define ASM_SPEC "\
-%{v:-V} -s %{fpic:-K PIC} %{fPIC:-K PIC} \
-%{mlittle-endian:-EL} \
-%(asm_cpu) %(asm_arch) \
-"
-
-/* This is taken from sol2.h. */
-#undef LINK_SPEC
-#define LINK_SPEC "\
-%{v:-V} \
-%{mlittle-endian:-EL} \
-"
-
-/* We need something a little simpler for the embedded environment.
- Profiling doesn't really work yet so we just copy the default. */
-#undef STARTFILE_SPEC
-#define STARTFILE_SPEC "\
-%{!shared:%{pg:gcrt0.o%s}%{!pg:%{p:mcrt0.o%s}%{!p:crt0.o%s}}} \
-crtbegin.o%s \
-"
-
-#undef ENDFILE_SPEC
-#define ENDFILE_SPEC "crtend.o%s"
-
-/* Use the default (for now). */
-#undef LIB_SPEC
-
-/* V9 chips can handle either endianness. */
-#undef SUBTARGET_SWITCHES
-#define SUBTARGET_SWITCHES \
-{"big-endian", -MASK_LITTLE_ENDIAN, "Generate code for big endian" }, \
-{"little-endian", MASK_LITTLE_ENDIAN, "Generate code for little endian" },
-
-#undef BYTES_BIG_ENDIAN
-#define BYTES_BIG_ENDIAN (! TARGET_LITTLE_ENDIAN)
-
-#undef WORDS_BIG_ENDIAN
-#define WORDS_BIG_ENDIAN (! TARGET_LITTLE_ENDIAN)
-
-/* ??? This should be 32 bits for v9 but what can we do? */
-#undef WCHAR_TYPE
-#define WCHAR_TYPE "short unsigned int"
-
-#undef WCHAR_TYPE_SIZE
-#define WCHAR_TYPE_SIZE 16
-
-#undef LONG_DOUBLE_TYPE_SIZE
-#define LONG_DOUBLE_TYPE_SIZE 128
-
-/* The medium/anywhere code model practically requires us to put jump tables
- in the text section as gcc is unable to distinguish LABEL_REF's of jump
- tables from other label refs (when we need to). */
-/* But we now defer the tables to the end of the function, so we make
- this 0 to not confuse the branch shortening code. */
-#undef JUMP_TABLES_IN_TEXT_SECTION
-#define JUMP_TABLES_IN_TEXT_SECTION 0
-
-/* System V Release 4 uses DWARF debugging info.
- GDB doesn't support 64 bit stabs yet and the desired debug format is DWARF
- anyway so it is the default. */
-
-#define DWARF_DEBUGGING_INFO
-#define DWARF2_DEBUGGING_INFO
-#define DBX_DEBUGGING_INFO
-
-#undef PREFERRED_DEBUGGING_TYPE
-#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
-
-/* Stabs doesn't use this, and it confuses a simulator. */
-/* ??? Need to see what DWARF needs, if anything. */
-#undef ASM_IDENTIFY_GCC
-#define ASM_IDENTIFY_GCC(FILE)
-
-/* Define the names of various pseudo-ops used by the Sparc/svr4 assembler.
- ??? If ints are 64 bits then UNALIGNED_INT_ASM_OP (defined elsewhere) is
- misnamed. These should all refer to explicit sizes (half/word/xword?),
- anything other than short/int/long/etc. */
-
-#define UNALIGNED_LONGLONG_ASM_OP ".uaxword"
-
-/* DWARF stuff. */
-
-#define ASM_OUTPUT_DWARF_ADDR(FILE, LABEL) \
-do { \
- fprintf ((FILE), "\t%s\t", UNALIGNED_LONGLONG_ASM_OP); \
- assemble_name ((FILE), (LABEL)); \
- fprintf ((FILE), "\n"); \
-} while (0)
-
-#define ASM_OUTPUT_DWARF_ADDR_CONST(FILE, RTX) \
-do { \
- fprintf ((FILE), "\t%s\t", UNALIGNED_LONGLONG_ASM_OP); \
- output_addr_const ((FILE), (RTX)); \
- fputc ('\n', (FILE)); \
-} while (0)
-
-#define ASM_OUTPUT_DWARF2_ADDR_CONST(FILE, ADDR) \
- fprintf ((FILE), "\t%s\t%s", UNALIGNED_LONGLONG_ASM_OP, (ADDR))
-
-/* ??? Not sure if this should be 4 or 8 bytes. 4 works for now. */
-#define ASM_OUTPUT_DWARF_REF(FILE, LABEL) \
-do { \
- fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
- assemble_name ((FILE), (LABEL)); \
- fprintf ((FILE), "\n"); \
-} while (0)
diff --git a/contrib/gcc/config/sparc/sparc.c b/contrib/gcc/config/sparc/sparc.c
deleted file mode 100644
index 45862a77bc73..000000000000
--- a/contrib/gcc/config/sparc/sparc.c
+++ /dev/null
@@ -1,7843 +0,0 @@
-/* Subroutines for insn-output.c for Sun SPARC.
- Copyright (C) 1987, 88, 89, 92-98, 1999 Free Software Foundation, Inc.
- Contributed by Michael Tiemann (tiemann@cygnus.com)
- 64 bit SPARC V9 support by Michael Tiemann, Jim Wilson, and Doug Evans,
- at Cygnus Support.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-#include "config.h"
-#include "system.h"
-#include "tree.h"
-#include "rtl.h"
-#include "regs.h"
-#include "hard-reg-set.h"
-#include "real.h"
-#include "insn-config.h"
-#include "conditions.h"
-#include "insn-flags.h"
-#include "output.h"
-#include "insn-attr.h"
-#include "flags.h"
-#include "expr.h"
-#include "recog.h"
-#include "toplev.h"
-
-/* 1 if the caller has placed an "unimp" insn immediately after the call.
- This is used in v8 code when calling a function that returns a structure.
- v9 doesn't have this. Be careful to have this test be the same as that
- used on the call. */
-
-#define SKIP_CALLERS_UNIMP_P \
-(!TARGET_ARCH64 && current_function_returns_struct \
- && ! integer_zerop (DECL_SIZE (DECL_RESULT (current_function_decl))) \
- && (TREE_CODE (DECL_SIZE (DECL_RESULT (current_function_decl))) \
- == INTEGER_CST))
-
-/* Global variables for machine-dependent things. */
-
-/* Size of frame. Need to know this to emit return insns from leaf procedures.
- ACTUAL_FSIZE is set by compute_frame_size() which is called during the
- reload pass. This is important as the value is later used in insn
- scheduling (to see what can go in a delay slot).
- APPARENT_FSIZE is the size of the stack less the register save area and less
- the outgoing argument area. It is used when saving call preserved regs. */
-static int apparent_fsize;
-static int actual_fsize;
-
-/* Save the operands last given to a compare for use when we
- generate a scc or bcc insn. */
-
-rtx sparc_compare_op0, sparc_compare_op1;
-
-/* We may need an epilogue if we spill too many registers.
- If this is non-zero, then we branch here for the epilogue. */
-static rtx leaf_label;
-
-#ifdef LEAF_REGISTERS
-
-/* Vector to say how input registers are mapped to output
- registers. FRAME_POINTER_REGNUM cannot be remapped by
- this function to eliminate it. You must use -fomit-frame-pointer
- to get that. */
-char leaf_reg_remap[] =
-{ 0, 1, 2, 3, 4, 5, 6, 7,
- -1, -1, -1, -1, -1, -1, 14, -1,
- -1, -1, -1, -1, -1, -1, -1, -1,
- 8, 9, 10, 11, 12, 13, -1, 15,
-
- 32, 33, 34, 35, 36, 37, 38, 39,
- 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55,
- 56, 57, 58, 59, 60, 61, 62, 63,
- 64, 65, 66, 67, 68, 69, 70, 71,
- 72, 73, 74, 75, 76, 77, 78, 79,
- 80, 81, 82, 83, 84, 85, 86, 87,
- 88, 89, 90, 91, 92, 93, 94, 95,
- 96, 97, 98, 99, 100};
-
-#endif
-
-/* Name of where we pretend to think the frame pointer points.
- Normally, this is "%fp", but if we are in a leaf procedure,
- this is "%sp+something". We record "something" separately as it may be
- too big for reg+constant addressing. */
-
-static const char *frame_base_name;
-static int frame_base_offset;
-
-static rtx pic_setup_code PROTO((void));
-static void sparc_init_modes PROTO((void));
-static int save_regs PROTO((FILE *, int, int, const char *,
- int, int, int));
-static int restore_regs PROTO((FILE *, int, int, const char *, int, int));
-static void build_big_number PROTO((FILE *, int, const char *));
-static int function_arg_slotno PROTO((const CUMULATIVE_ARGS *,
- enum machine_mode, tree, int, int,
- int *, int *));
-
-static int supersparc_adjust_cost PROTO((rtx, rtx, rtx, int));
-static int hypersparc_adjust_cost PROTO((rtx, rtx, rtx, int));
-static int ultrasparc_adjust_cost PROTO((rtx, rtx, rtx, int));
-
-static void sparc_output_addr_vec PROTO((rtx));
-static void sparc_output_addr_diff_vec PROTO((rtx));
-static void sparc_output_deferred_case_vectors PROTO((void));
-
-
-#ifdef DWARF2_DEBUGGING_INFO
-extern char *dwarf2out_cfi_label ();
-#endif
-
-/* Option handling. */
-
-/* Code model option as passed by user. */
-const char *sparc_cmodel_string;
-/* Parsed value. */
-enum cmodel sparc_cmodel;
-
-/* Record alignment options as passed by user. */
-const char *sparc_align_loops_string;
-const char *sparc_align_jumps_string;
-const char *sparc_align_funcs_string;
-
-/* Parsed values, as a power of two. */
-int sparc_align_loops;
-int sparc_align_jumps;
-int sparc_align_funcs;
-
-struct sparc_cpu_select sparc_select[] =
-{
- /* switch name, tune arch */
- { (char *)0, "default", 1, 1 },
- { (char *)0, "-mcpu=", 1, 1 },
- { (char *)0, "-mtune=", 1, 0 },
- { 0, 0, 0, 0 }
-};
-
-/* CPU type. This is set from TARGET_CPU_DEFAULT and -m{cpu,tune}=xxx. */
-enum processor_type sparc_cpu;
-
-/* Validate and override various options, and do some machine dependent
- initialization. */
-
-void
-sparc_override_options ()
-{
- static struct code_model {
- const char *name;
- int value;
- } cmodels[] = {
- { "32", CM_32 },
- { "medlow", CM_MEDLOW },
- { "medmid", CM_MEDMID },
- { "medany", CM_MEDANY },
- { "embmedany", CM_EMBMEDANY },
- { 0, 0 }
- };
- struct code_model *cmodel;
- /* Map TARGET_CPU_DEFAULT to value for -m{arch,tune}=. */
- static struct cpu_default {
- int cpu;
- const char *name;
- } cpu_default[] = {
- /* There must be one entry here for each TARGET_CPU value. */
- { TARGET_CPU_sparc, "cypress" },
- { TARGET_CPU_sparclet, "tsc701" },
- { TARGET_CPU_sparclite, "f930" },
- { TARGET_CPU_v8, "v8" },
- { TARGET_CPU_hypersparc, "hypersparc" },
- { TARGET_CPU_sparclite86x, "sparclite86x" },
- { TARGET_CPU_supersparc, "supersparc" },
- { TARGET_CPU_v9, "v9" },
- { TARGET_CPU_ultrasparc, "ultrasparc" },
- { 0, 0 }
- };
- struct cpu_default *def;
- /* Table of values for -m{cpu,tune}=. */
- static struct cpu_table {
- const char *name;
- enum processor_type processor;
- int disable;
- int enable;
- } cpu_table[] = {
- { "v7", PROCESSOR_V7, MASK_ISA, 0 },
- { "cypress", PROCESSOR_CYPRESS, MASK_ISA, 0 },
- { "v8", PROCESSOR_V8, MASK_ISA, MASK_V8 },
- /* TI TMS390Z55 supersparc */
- { "supersparc", PROCESSOR_SUPERSPARC, MASK_ISA, MASK_V8 },
- { "sparclite", PROCESSOR_SPARCLITE, MASK_ISA, MASK_SPARCLITE },
- /* The Fujitsu MB86930 is the original sparclite chip, with no fpu.
- The Fujitsu MB86934 is the recent sparclite chip, with an fpu. */
- { "f930", PROCESSOR_F930, MASK_ISA|MASK_FPU, MASK_SPARCLITE },
- { "f934", PROCESSOR_F934, MASK_ISA, MASK_SPARCLITE|MASK_FPU },
- { "hypersparc", PROCESSOR_HYPERSPARC, MASK_ISA, MASK_V8|MASK_FPU },
- { "sparclite86x", PROCESSOR_SPARCLITE86X, MASK_ISA|MASK_FPU, MASK_V8 },
- { "sparclet", PROCESSOR_SPARCLET, MASK_ISA, MASK_SPARCLET },
- /* TEMIC sparclet */
- { "tsc701", PROCESSOR_TSC701, MASK_ISA, MASK_SPARCLET },
- { "v9", PROCESSOR_V9, MASK_ISA, MASK_V9 },
- /* TI ultrasparc */
- { "ultrasparc", PROCESSOR_ULTRASPARC, MASK_ISA, MASK_V9 },
- { 0, 0, 0, 0 }
- };
- struct cpu_table *cpu;
- struct sparc_cpu_select *sel;
- int fpu;
-
-#ifndef SPARC_BI_ARCH
- /* Check for unsupported architecture size. */
- if (! TARGET_64BIT != DEFAULT_ARCH32_P)
- {
- error ("%s is not supported by this configuration",
- DEFAULT_ARCH32_P ? "-m64" : "-m32");
- }
-#endif
-
- /* At the moment we don't allow different pointer size and architecture */
- if (! TARGET_64BIT != ! TARGET_PTR64)
- {
- error ("-mptr%d not allowed on -m%d",
- TARGET_PTR64 ? 64 : 32, TARGET_64BIT ? 64 : 32);
- if (TARGET_64BIT)
- target_flags |= MASK_PTR64;
- else
- target_flags &= ~MASK_PTR64;
- }
-
- /* Code model selection. */
- sparc_cmodel = SPARC_DEFAULT_CMODEL;
-
-#ifdef SPARC_BI_ARCH
- if (TARGET_ARCH32)
- sparc_cmodel = CM_32;
-#endif
-
- if (sparc_cmodel_string != NULL)
- {
- if (TARGET_ARCH64)
- {
- for (cmodel = &cmodels[0]; cmodel->name; cmodel++)
- if (strcmp (sparc_cmodel_string, cmodel->name) == 0)
- break;
- if (cmodel->name == NULL)
- error ("bad value (%s) for -mcmodel= switch", sparc_cmodel_string);
- else
- sparc_cmodel = cmodel->value;
- }
- else
- error ("-mcmodel= is not supported on 32 bit systems");
- }
-
- fpu = TARGET_FPU; /* save current -mfpu status */
-
- /* Set the default CPU. */
- for (def = &cpu_default[0]; def->name; ++def)
- if (def->cpu == TARGET_CPU_DEFAULT)
- break;
- if (! def->name)
- abort ();
- sparc_select[0].string = def->name;
-
- for (sel = &sparc_select[0]; sel->name; ++sel)
- {
- if (sel->string)
- {
- for (cpu = &cpu_table[0]; cpu->name; ++cpu)
- if (! strcmp (sel->string, cpu->name))
- {
- if (sel->set_tune_p)
- sparc_cpu = cpu->processor;
-
- if (sel->set_arch_p)
- {
- target_flags &= ~cpu->disable;
- target_flags |= cpu->enable;
- }
- break;
- }
-
- if (! cpu->name)
- error ("bad value (%s) for %s switch", sel->string, sel->name);
- }
- }
-
- /* If -mfpu or -mno-fpu was explicitly used, don't override with
- the processor default. */
- if (TARGET_FPU_SET)
- target_flags = (target_flags & ~MASK_FPU) | fpu;
-
- /* Use the deprecated v8 insns for sparc64 in 32 bit mode. */
- if (TARGET_V9 && TARGET_ARCH32)
- target_flags |= MASK_DEPRECATED_V8_INSNS;
-
- /* V8PLUS requires V9, makes no sense in 64 bit mode. */
- if (! TARGET_V9 || TARGET_ARCH64)
- target_flags &= ~MASK_V8PLUS;
-
- /* Don't use stack biasing in 32 bit mode. */
- if (TARGET_ARCH32)
- target_flags &= ~MASK_STACK_BIAS;
-
- /* Don't allow -mvis if FPU is disabled. */
- if (! TARGET_FPU)
- target_flags &= ~MASK_VIS;
-
- /* Validate -malign-loops= value, or provide default. */
- if (sparc_align_loops_string)
- {
- sparc_align_loops = exact_log2 (atoi (sparc_align_loops_string));
- if (sparc_align_loops < 2 || sparc_align_loops > 7)
- fatal ("-malign-loops=%s is not between 4 and 128 or is not a power of two",
- sparc_align_loops_string);
- }
- else
- {
- /* ??? This relies on ASM_OUTPUT_ALIGN to not emit the alignment if
- its 0. This sounds a bit kludgey. */
- sparc_align_loops = 0;
- }
-
- /* Validate -malign-jumps= value, or provide default. */
- if (sparc_align_jumps_string)
- {
- sparc_align_jumps = exact_log2 (atoi (sparc_align_jumps_string));
- if (sparc_align_jumps < 2 || sparc_align_loops > 7)
- fatal ("-malign-jumps=%s is not between 4 and 128 or is not a power of two",
- sparc_align_jumps_string);
- }
- else
- {
- /* ??? This relies on ASM_OUTPUT_ALIGN to not emit the alignment if
- its 0. This sounds a bit kludgey. */
- sparc_align_jumps = 0;
- }
-
- /* Validate -malign-functions= value, or provide default. */
- if (sparc_align_funcs_string)
- {
- sparc_align_funcs = exact_log2 (atoi (sparc_align_funcs_string));
- if (sparc_align_funcs < 2 || sparc_align_loops > 7)
- fatal ("-malign-functions=%s is not between 4 and 128 or is not a power of two",
- sparc_align_funcs_string);
- }
- else
- sparc_align_funcs = DEFAULT_SPARC_ALIGN_FUNCS;
-
- /* Validate PCC_STRUCT_RETURN. */
- if (flag_pcc_struct_return == DEFAULT_PCC_STRUCT_RETURN)
- flag_pcc_struct_return = (TARGET_ARCH64 ? 0 : 1);
-
- /* Do various machine dependent initializations. */
- sparc_init_modes ();
-
- if ((profile_flag || profile_block_flag)
- && sparc_cmodel != CM_MEDLOW)
- {
- error ("profiling does not support code models other than medlow");
- }
-}
-
-/* Miscellaneous utilities. */
-
-/* Nonzero if CODE, a comparison, is suitable for use in v9 conditional move
- or branch on register contents instructions. */
-
-int
-v9_regcmp_p (code)
- enum rtx_code code;
-{
- return (code == EQ || code == NE || code == GE || code == LT
- || code == LE || code == GT);
-}
-
-
-/* Operand constraints. */
-
-/* Return non-zero only if OP is a register of mode MODE,
- or const0_rtx. Don't allow const0_rtx if TARGET_LIVE_G0 because
- %g0 may contain anything. */
-
-int
-reg_or_0_operand (op, mode)
- rtx op;
- enum machine_mode mode;
-{
- if (register_operand (op, mode))
- return 1;
- if (TARGET_LIVE_G0)
- return 0;
- if (op == const0_rtx)
- return 1;
- if (GET_MODE (op) == VOIDmode && GET_CODE (op) == CONST_DOUBLE
- && CONST_DOUBLE_HIGH (op) == 0
- && CONST_DOUBLE_LOW (op) == 0)
- return 1;
- if (GET_MODE_CLASS (GET_MODE (op)) == MODE_FLOAT
- && GET_CODE (op) == CONST_DOUBLE
- && fp_zero_operand (op))
- return 1;
- return 0;
-}
-
-/* Nonzero if OP is a floating point value with value 0.0. */
-
-int
-fp_zero_operand (op)
- rtx op;
-{
- REAL_VALUE_TYPE r;
-
- REAL_VALUE_FROM_CONST_DOUBLE (r, op);
- return (REAL_VALUES_EQUAL (r, dconst0) && ! REAL_VALUE_MINUS_ZERO (r));
-}
-
-/* Nonzero if OP is an integer register. */
-
-int
-intreg_operand (op, mode)
- rtx op;
- enum machine_mode mode ATTRIBUTE_UNUSED;
-{
- return (register_operand (op, SImode)
- || (TARGET_ARCH64 && register_operand (op, DImode)));
-}
-
-/* Nonzero if OP is a floating point condition code register. */
-
-int
-fcc_reg_operand (op, mode)
- rtx op;
- enum machine_mode mode;
-{
- /* This can happen when recog is called from combine. Op may be a MEM.
- Fail instead of calling abort in this case. */
- if (GET_CODE (op) != REG)
- return 0;
-
- if (mode != VOIDmode && mode != GET_MODE (op))
- return 0;
- if (mode == VOIDmode
- && (GET_MODE (op) != CCFPmode && GET_MODE (op) != CCFPEmode))
- return 0;
-
-#if 0 /* ??? ==> 1 when %fcc0-3 are pseudos first. See gen_compare_reg(). */
- if (reg_renumber == 0)
- return REGNO (op) >= FIRST_PSEUDO_REGISTER;
- return REGNO_OK_FOR_CCFP_P (REGNO (op));
-#else
- return (unsigned) REGNO (op) - SPARC_FIRST_V9_FCC_REG < 4;
-#endif
-}
-
-/* Nonzero if OP is an integer or floating point condition code register. */
-
-int
-icc_or_fcc_reg_operand (op, mode)
- rtx op;
- enum machine_mode mode;
-{
- if (GET_CODE (op) == REG && REGNO (op) == SPARC_ICC_REG)
- {
- if (mode != VOIDmode && mode != GET_MODE (op))
- return 0;
- if (mode == VOIDmode
- && GET_MODE (op) != CCmode && GET_MODE (op) != CCXmode)
- return 0;
- return 1;
- }
-
- return fcc_reg_operand (op, mode);
-}
-
-/* Nonzero if OP can appear as the dest of a RESTORE insn. */
-int
-restore_operand (op, mode)
- rtx op;
- enum machine_mode mode;
-{
- return (GET_CODE (op) == REG && GET_MODE (op) == mode
- && (REGNO (op) < 8 || (REGNO (op) >= 24 && REGNO (op) < 32)));
-}
-
-/* Call insn on SPARC can take a PC-relative constant address, or any regular
- memory address. */
-
-int
-call_operand (op, mode)
- rtx op;
- enum machine_mode mode;
-{
- if (GET_CODE (op) != MEM)
- abort ();
- op = XEXP (op, 0);
- return (symbolic_operand (op, mode) || memory_address_p (Pmode, op));
-}
-
-int
-call_operand_address (op, mode)
- rtx op;
- enum machine_mode mode;
-{
- return (symbolic_operand (op, mode) || memory_address_p (Pmode, op));
-}
-
-/* Returns 1 if OP is either a symbol reference or a sum of a symbol
- reference and a constant. */
-
-int
-symbolic_operand (op, mode)
- register rtx op;
- enum machine_mode mode;
-{
- switch (GET_CODE (op))
- {
- case SYMBOL_REF:
- case LABEL_REF:
- return 1;
-
- case CONST:
- op = XEXP (op, 0);
- return ((GET_CODE (XEXP (op, 0)) == SYMBOL_REF
- || GET_CODE (XEXP (op, 0)) == LABEL_REF)
- && GET_CODE (XEXP (op, 1)) == CONST_INT);
-
- /* ??? This clause seems to be irrelevant. */
- case CONST_DOUBLE:
- return GET_MODE (op) == mode;
-
- default:
- return 0;
- }
-}
-
-/* Return truth value of statement that OP is a symbolic memory
- operand of mode MODE. */
-
-int
-symbolic_memory_operand (op, mode)
- rtx op;
- enum machine_mode mode ATTRIBUTE_UNUSED;
-{
- if (GET_CODE (op) == SUBREG)
- op = SUBREG_REG (op);
- if (GET_CODE (op) != MEM)
- return 0;
- op = XEXP (op, 0);
- return (GET_CODE (op) == SYMBOL_REF || GET_CODE (op) == CONST
- || GET_CODE (op) == HIGH || GET_CODE (op) == LABEL_REF);
-}
-
-/* Return truth value of statement that OP is a LABEL_REF of mode MODE. */
-
-int
-label_ref_operand (op, mode)
- rtx op;
- enum machine_mode mode;
-{
- if (GET_CODE (op) != LABEL_REF)
- return 0;
- if (GET_MODE (op) != mode)
- return 0;
- return 1;
-}
-
-/* Return 1 if the operand is an argument used in generating pic references
- in either the medium/low or medium/anywhere code models of sparc64. */
-
-int
-sp64_medium_pic_operand (op, mode)
- rtx op;
- enum machine_mode mode ATTRIBUTE_UNUSED;
-{
- /* Check for (const (minus (symbol_ref:GOT)
- (const (minus (label) (pc))))). */
- if (GET_CODE (op) != CONST)
- return 0;
- op = XEXP (op, 0);
- if (GET_CODE (op) != MINUS)
- return 0;
- if (GET_CODE (XEXP (op, 0)) != SYMBOL_REF)
- return 0;
- /* ??? Ensure symbol is GOT. */
- if (GET_CODE (XEXP (op, 1)) != CONST)
- return 0;
- if (GET_CODE (XEXP (XEXP (op, 1), 0)) != MINUS)
- return 0;
- return 1;
-}
-
-/* Return 1 if the operand is a data segment reference. This includes
- the readonly data segment, or in other words anything but the text segment.
- This is needed in the medium/anywhere code model on v9. These values
- are accessed with EMBMEDANY_BASE_REG. */
-
-int
-data_segment_operand (op, mode)
- rtx op;
- enum machine_mode mode ATTRIBUTE_UNUSED;
-{
- switch (GET_CODE (op))
- {
- case SYMBOL_REF :
- return ! SYMBOL_REF_FLAG (op);
- case PLUS :
- /* Assume canonical format of symbol + constant.
- Fall through. */
- case CONST :
- return data_segment_operand (XEXP (op, 0));
- default :
- return 0;
- }
-}
-
-/* Return 1 if the operand is a text segment reference.
- This is needed in the medium/anywhere code model on v9. */
-
-int
-text_segment_operand (op, mode)
- rtx op;
- enum machine_mode mode ATTRIBUTE_UNUSED;
-{
- switch (GET_CODE (op))
- {
- case LABEL_REF :
- return 1;
- case SYMBOL_REF :
- return SYMBOL_REF_FLAG (op);
- case PLUS :
- /* Assume canonical format of symbol + constant.
- Fall through. */
- case CONST :
- return text_segment_operand (XEXP (op, 0));
- default :
- return 0;
- }
-}
-
-/* Return 1 if the operand is either a register or a memory operand that is
- not symbolic. */
-
-int
-reg_or_nonsymb_mem_operand (op, mode)
- register rtx op;
- enum machine_mode mode;
-{
- if (register_operand (op, mode))
- return 1;
-
- if (memory_operand (op, mode) && ! symbolic_memory_operand (op, mode))
- return 1;
-
- return 0;
-}
-
-int
-splittable_symbolic_memory_operand (op, mode)
- rtx op;
- enum machine_mode mode ATTRIBUTE_UNUSED;
-{
- if (GET_CODE (op) != MEM)
- return 0;
- if (! symbolic_operand (XEXP (op, 0), Pmode))
- return 0;
- return 1;
-}
-
-int
-splittable_immediate_memory_operand (op, mode)
- rtx op;
- enum machine_mode mode ATTRIBUTE_UNUSED;
-{
- if (GET_CODE (op) != MEM)
- return 0;
- if (! immediate_operand (XEXP (op, 0), Pmode))
- return 0;
- return 1;
-}
-
-/* Return truth value of whether OP is EQ or NE. */
-
-int
-eq_or_neq (op, mode)
- rtx op;
- enum machine_mode mode ATTRIBUTE_UNUSED;
-{
- return (GET_CODE (op) == EQ || GET_CODE (op) == NE);
-}
-
-/* Return 1 if this is a comparison operator, but not an EQ, NE, GEU,
- or LTU for non-floating-point. We handle those specially. */
-
-int
-normal_comp_operator (op, mode)
- rtx op;
- enum machine_mode mode ATTRIBUTE_UNUSED;
-{
- enum rtx_code code = GET_CODE (op);
-
- if (GET_RTX_CLASS (code) != '<')
- return 0;
-
- if (GET_MODE (XEXP (op, 0)) == CCFPmode
- || GET_MODE (XEXP (op, 0)) == CCFPEmode)
- return 1;
-
- return (code != NE && code != EQ && code != GEU && code != LTU);
-}
-
-/* Return 1 if this is a comparison operator. This allows the use of
- MATCH_OPERATOR to recognize all the branch insns. */
-
-int
-noov_compare_op (op, mode)
- register rtx op;
- enum machine_mode mode ATTRIBUTE_UNUSED;
-{
- enum rtx_code code = GET_CODE (op);
-
- if (GET_RTX_CLASS (code) != '<')
- return 0;
-
- if (GET_MODE (XEXP (op, 0)) == CC_NOOVmode)
- /* These are the only branches which work with CC_NOOVmode. */
- return (code == EQ || code == NE || code == GE || code == LT);
- return 1;
-}
-
-/* Nonzero if OP is a comparison operator suitable for use in v9
- conditional move or branch on register contents instructions. */
-
-int
-v9_regcmp_op (op, mode)
- register rtx op;
- enum machine_mode mode ATTRIBUTE_UNUSED;
-{
- enum rtx_code code = GET_CODE (op);
-
- if (GET_RTX_CLASS (code) != '<')
- return 0;
-
- return v9_regcmp_p (code);
-}
-
-/* Return 1 if this is a SIGN_EXTEND or ZERO_EXTEND operation. */
-
-int
-extend_op (op, mode)
- rtx op;
- enum machine_mode mode ATTRIBUTE_UNUSED;
-{
- return GET_CODE (op) == SIGN_EXTEND || GET_CODE (op) == ZERO_EXTEND;
-}
-
-/* Return nonzero if OP is an operator of mode MODE which can set
- the condition codes explicitly. We do not include PLUS and MINUS
- because these require CC_NOOVmode, which we handle explicitly. */
-
-int
-cc_arithop (op, mode)
- rtx op;
- enum machine_mode mode ATTRIBUTE_UNUSED;
-{
- if (GET_CODE (op) == AND
- || GET_CODE (op) == IOR
- || GET_CODE (op) == XOR)
- return 1;
-
- return 0;
-}
-
-/* Return nonzero if OP is an operator of mode MODE which can bitwise
- complement its second operand and set the condition codes explicitly. */
-
-int
-cc_arithopn (op, mode)
- rtx op;
- enum machine_mode mode ATTRIBUTE_UNUSED;
-{
- /* XOR is not here because combine canonicalizes (xor (not ...) ...)
- and (xor ... (not ...)) to (not (xor ...)). */
- return (GET_CODE (op) == AND
- || GET_CODE (op) == IOR);
-}
-
-/* Return true if OP is a register, or is a CONST_INT that can fit in a
- signed 13 bit immediate field. This is an acceptable SImode operand for
- most 3 address instructions. */
-
-int
-arith_operand (op, mode)
- rtx op;
- enum machine_mode mode;
-{
- int val;
- if (register_operand (op, mode))
- return 1;
- if (GET_CODE (op) != CONST_INT)
- return 0;
- val = INTVAL (op) & 0xffffffff;
- return SPARC_SIMM13_P (val);
-}
-
-/* Return true if OP is a constant 4096 */
-
-int
-arith_4096_operand (op, mode)
- rtx op;
- enum machine_mode mode ATTRIBUTE_UNUSED;
-{
- int val;
- if (GET_CODE (op) != CONST_INT)
- return 0;
- val = INTVAL (op) & 0xffffffff;
- return val == 4096;
-}
-
-/* Return true if OP is suitable as second operand for add/sub */
-
-int
-arith_add_operand (op, mode)
- rtx op;
- enum machine_mode mode;
-{
- return arith_operand (op, mode) || arith_4096_operand (op, mode);
-}
-
-/* Return true if OP is a CONST_INT or a CONST_DOUBLE which can fit in the
- immediate field of OR and XOR instructions. Used for 64-bit
- constant formation patterns. */
-int
-const64_operand (op, mode)
- rtx op;
- enum machine_mode mode ATTRIBUTE_UNUSED;
-{
- return ((GET_CODE (op) == CONST_INT
- && SPARC_SIMM13_P (INTVAL (op)))
-#if HOST_BITS_PER_WIDE_INT != 64
- || (GET_CODE (op) == CONST_DOUBLE
- && SPARC_SIMM13_P (CONST_DOUBLE_LOW (op))
- && (CONST_DOUBLE_HIGH (op) ==
- ((CONST_DOUBLE_LOW (op) & 0x80000000) != 0 ?
- (HOST_WIDE_INT)0xffffffff : 0)))
-#endif
- );
-}
-
-/* The same, but only for sethi instructions. */
-int
-const64_high_operand (op, mode)
- rtx op;
- enum machine_mode mode ATTRIBUTE_UNUSED;
-{
- return ((GET_CODE (op) == CONST_INT
- && (INTVAL (op) & 0xfffffc00) != 0
- && SPARC_SETHI_P (INTVAL (op))
-#if HOST_BITS_PER_WIDE_INT != 64
- /* Must be positive on non-64bit host else the
- optimizer is fooled into thinking that sethi
- sign extends, even though it does not. */
- && INTVAL (op) >= 0
-#endif
- )
- || (GET_CODE (op) == CONST_DOUBLE
- && CONST_DOUBLE_HIGH (op) == 0
- && (CONST_DOUBLE_LOW (op) & 0xfffffc00) != 0
- && SPARC_SETHI_P (CONST_DOUBLE_LOW (op))));
-}
-
-/* Return true if OP is a register, or is a CONST_INT that can fit in a
- signed 11 bit immediate field. This is an acceptable SImode operand for
- the movcc instructions. */
-
-int
-arith11_operand (op, mode)
- rtx op;
- enum machine_mode mode;
-{
- return (register_operand (op, mode)
- || (GET_CODE (op) == CONST_INT && SPARC_SIMM11_P (INTVAL (op))));
-}
-
-/* Return true if OP is a register, or is a CONST_INT that can fit in a
- signed 10 bit immediate field. This is an acceptable SImode operand for
- the movrcc instructions. */
-
-int
-arith10_operand (op, mode)
- rtx op;
- enum machine_mode mode;
-{
- return (register_operand (op, mode)
- || (GET_CODE (op) == CONST_INT && SPARC_SIMM10_P (INTVAL (op))));
-}
-
-/* Return true if OP is a register, is a CONST_INT that fits in a 13 bit
- immediate field, or is a CONST_DOUBLE whose both parts fit in a 13 bit
- immediate field.
- v9: Return true if OP is a register, or is a CONST_INT or CONST_DOUBLE that
- can fit in a 13 bit immediate field. This is an acceptable DImode operand
- for most 3 address instructions. */
-
-int
-arith_double_operand (op, mode)
- rtx op;
- enum machine_mode mode;
-{
- return (register_operand (op, mode)
- || (GET_CODE (op) == CONST_INT && SMALL_INT (op))
- || (! TARGET_ARCH64
- && GET_CODE (op) == CONST_DOUBLE
- && (unsigned HOST_WIDE_INT) (CONST_DOUBLE_LOW (op) + 0x1000) < 0x2000
- && (unsigned HOST_WIDE_INT) (CONST_DOUBLE_HIGH (op) + 0x1000) < 0x2000)
- || (TARGET_ARCH64
- && GET_CODE (op) == CONST_DOUBLE
- && (unsigned HOST_WIDE_INT) (CONST_DOUBLE_LOW (op) + 0x1000) < 0x2000
- && ((CONST_DOUBLE_HIGH (op) == -1
- && (CONST_DOUBLE_LOW (op) & 0x1000) == 0x1000)
- || (CONST_DOUBLE_HIGH (op) == 0
- && (CONST_DOUBLE_LOW (op) & 0x1000) == 0))));
-}
-
-/* Return true if OP is a constant 4096 for DImode on ARCH64 */
-
-int
-arith_double_4096_operand (op, mode)
- rtx op;
- enum machine_mode mode ATTRIBUTE_UNUSED;
-{
- return (TARGET_ARCH64 &&
- ((GET_CODE (op) == CONST_INT && INTVAL (op) == 4096) ||
- (GET_CODE (op) == CONST_DOUBLE &&
- CONST_DOUBLE_LOW (op) == 4096 &&
- CONST_DOUBLE_HIGH (op) == 0)));
-}
-
-/* Return true if OP is suitable as second operand for add/sub in DImode */
-
-int
-arith_double_add_operand (op, mode)
- rtx op;
- enum machine_mode mode;
-{
- return arith_double_operand (op, mode) || arith_double_4096_operand (op, mode);
-}
-
-/* Return true if OP is a register, or is a CONST_INT or CONST_DOUBLE that
- can fit in an 11 bit immediate field. This is an acceptable DImode
- operand for the movcc instructions. */
-/* ??? Replace with arith11_operand? */
-
-int
-arith11_double_operand (op, mode)
- rtx op;
- enum machine_mode mode;
-{
- return (register_operand (op, mode)
- || (GET_CODE (op) == CONST_DOUBLE
- && (GET_MODE (op) == mode || GET_MODE (op) == VOIDmode)
- && (unsigned HOST_WIDE_INT) (CONST_DOUBLE_LOW (op) + 0x400) < 0x800
- && ((CONST_DOUBLE_HIGH (op) == -1
- && (CONST_DOUBLE_LOW (op) & 0x400) == 0x400)
- || (CONST_DOUBLE_HIGH (op) == 0
- && (CONST_DOUBLE_LOW (op) & 0x400) == 0)))
- || (GET_CODE (op) == CONST_INT
- && (GET_MODE (op) == mode || GET_MODE (op) == VOIDmode)
- && (unsigned HOST_WIDE_INT) (INTVAL (op) + 0x400) < 0x800));
-}
-
-/* Return true if OP is a register, or is a CONST_INT or CONST_DOUBLE that
- can fit in an 10 bit immediate field. This is an acceptable DImode
- operand for the movrcc instructions. */
-/* ??? Replace with arith10_operand? */
-
-int
-arith10_double_operand (op, mode)
- rtx op;
- enum machine_mode mode;
-{
- return (register_operand (op, mode)
- || (GET_CODE (op) == CONST_DOUBLE
- && (GET_MODE (op) == mode || GET_MODE (op) == VOIDmode)
- && (unsigned) (CONST_DOUBLE_LOW (op) + 0x200) < 0x400
- && ((CONST_DOUBLE_HIGH (op) == -1
- && (CONST_DOUBLE_LOW (op) & 0x200) == 0x200)
- || (CONST_DOUBLE_HIGH (op) == 0
- && (CONST_DOUBLE_LOW (op) & 0x200) == 0)))
- || (GET_CODE (op) == CONST_INT
- && (GET_MODE (op) == mode || GET_MODE (op) == VOIDmode)
- && (unsigned HOST_WIDE_INT) (INTVAL (op) + 0x200) < 0x400));
-}
-
-/* Return truth value of whether OP is a integer which fits the
- range constraining immediate operands in most three-address insns,
- which have a 13 bit immediate field. */
-
-int
-small_int (op, mode)
- rtx op;
- enum machine_mode mode ATTRIBUTE_UNUSED;
-{
- return (GET_CODE (op) == CONST_INT && SMALL_INT (op));
-}
-
-int
-small_int_or_double (op, mode)
- rtx op;
- enum machine_mode mode ATTRIBUTE_UNUSED;
-{
- return ((GET_CODE (op) == CONST_INT && SMALL_INT (op))
- || (GET_CODE (op) == CONST_DOUBLE
- && CONST_DOUBLE_HIGH (op) == 0
- && SPARC_SIMM13_P (CONST_DOUBLE_LOW (op))));
-}
-
-/* Recognize operand values for the umul instruction. That instruction sign
- extends immediate values just like all other sparc instructions, but
- interprets the extended result as an unsigned number. */
-
-int
-uns_small_int (op, mode)
- rtx op;
- enum machine_mode mode ATTRIBUTE_UNUSED;
-{
-#if HOST_BITS_PER_WIDE_INT > 32
- /* All allowed constants will fit a CONST_INT. */
- return (GET_CODE (op) == CONST_INT
- && ((INTVAL (op) >= 0 && INTVAL (op) < 0x1000)
- || (INTVAL (op) >= 0xFFFFF000
- && INTVAL (op) < 0x100000000)));
-#else
- return ((GET_CODE (op) == CONST_INT && (unsigned) INTVAL (op) < 0x1000)
- || (GET_CODE (op) == CONST_DOUBLE
- && CONST_DOUBLE_HIGH (op) == 0
- && (unsigned) CONST_DOUBLE_LOW (op) - 0xFFFFF000 < 0x1000));
-#endif
-}
-
-int
-uns_arith_operand (op, mode)
- rtx op;
- enum machine_mode mode;
-{
- return register_operand (op, mode) || uns_small_int (op, mode);
-}
-
-/* Return truth value of statement that OP is a call-clobbered register. */
-int
-clobbered_register (op, mode)
- rtx op;
- enum machine_mode mode ATTRIBUTE_UNUSED;
-{
- return (GET_CODE (op) == REG && call_used_regs[REGNO (op)]);
-}
-
-/* Return 1 if OP is const0_rtx, used for TARGET_LIVE_G0 insns. */
-
-int
-zero_operand (op, mode)
- rtx op;
- enum machine_mode mode ATTRIBUTE_UNUSED;
-{
- return op == const0_rtx;
-}
-
-/* Return 1 if OP is a valid operand for the source of a move insn. */
-
-int
-input_operand (op, mode)
- rtx op;
- enum machine_mode mode;
-{
- /* If both modes are non-void they must be the same. */
- if (mode != VOIDmode && GET_MODE (op) != VOIDmode && mode != GET_MODE (op))
- return 0;
-
- /* Only a tiny bit of handling for CONSTANT_P_RTX is necessary. */
- if (GET_CODE (op) == CONST && GET_CODE (XEXP (op, 0)) == CONSTANT_P_RTX)
- return 1;
-
- /* Allow any one instruction integer constant, and all CONST_INT
- variants when we are working in DImode and !arch64. */
- if (GET_MODE_CLASS (mode) == MODE_INT
- && ((GET_CODE (op) == CONST_INT
- && ((SPARC_SETHI_P (INTVAL (op))
- && (! TARGET_ARCH64
- || (INTVAL (op) >= 0)
- || mode == SImode))
- || SPARC_SIMM13_P (INTVAL (op))
- || (mode == DImode
- && ! TARGET_ARCH64)))
- || (TARGET_ARCH64
- && GET_CODE (op) == CONST_DOUBLE
- && ((CONST_DOUBLE_HIGH (op) == 0
- && SPARC_SETHI_P (CONST_DOUBLE_LOW (op)))
- ||
-#if HOST_BITS_PER_WIDE_INT == 64
- (CONST_DOUBLE_HIGH (op) == 0
- && SPARC_SIMM13_P (CONST_DOUBLE_LOW (op)))
-#else
- (SPARC_SIMM13_P (CONST_DOUBLE_LOW (op))
- && (((CONST_DOUBLE_LOW (op) & 0x80000000) == 0
- && CONST_DOUBLE_HIGH (op) == 0)
- || (CONST_DOUBLE_HIGH (op) == -1)))
-#endif
- ))))
- return 1;
-
- /* If !arch64 and this is a DImode const, allow it so that
- the splits can be generated. */
- if (! TARGET_ARCH64
- && mode == DImode
- && GET_CODE (op) == CONST_DOUBLE)
- return 1;
-
- if (register_operand (op, mode))
- return 1;
-
- /* If this is a SUBREG, look inside so that we handle
- paradoxical ones. */
- if (GET_CODE (op) == SUBREG)
- op = SUBREG_REG (op);
-
- /* Check for valid MEM forms. */
- if (GET_CODE (op) == MEM)
- {
- rtx inside = XEXP (op, 0);
-
- if (GET_CODE (inside) == LO_SUM)
- {
- /* We can't allow these because all of the splits
- (eventually as they trickle down into DFmode
- splits) require offsettable memory references. */
- if (! TARGET_V9
- && GET_MODE (op) == TFmode)
- return 0;
-
- return (register_operand (XEXP (inside, 0), Pmode)
- && CONSTANT_P (XEXP (inside, 1)));
- }
- return memory_address_p (mode, inside);
- }
-
- return 0;
-}
-
-
-/* We know it can't be done in one insn when we get here,
- the movsi expander guarentees this. */
-void
-sparc_emit_set_const32 (op0, op1)
- rtx op0;
- rtx op1;
-{
- enum machine_mode mode = GET_MODE (op0);
- rtx temp;
-
- if (GET_CODE (op1) == CONST_INT)
- {
- HOST_WIDE_INT value = INTVAL (op1);
-
- if (SPARC_SETHI_P (value)
- || SPARC_SIMM13_P (value))
- abort ();
- }
-
- /* Full 2-insn decomposition is needed. */
- if (reload_in_progress || reload_completed)
- temp = op0;
- else
- temp = gen_reg_rtx (mode);
-
- if (GET_CODE (op1) == CONST_INT)
- {
- /* Emit them as real moves instead of a HIGH/LO_SUM,
- this way CSE can see everything and reuse intermediate
- values if it wants. */
- if (TARGET_ARCH64
- && HOST_BITS_PER_WIDE_INT != 64
- && (INTVAL (op1) & 0x80000000) != 0)
- {
- emit_insn (gen_rtx_SET (VOIDmode,
- temp,
- gen_rtx_CONST_DOUBLE (VOIDmode, const0_rtx,
- INTVAL (op1) & 0xfffffc00, 0)));
- }
- else
- {
- emit_insn (gen_rtx_SET (VOIDmode,
- temp,
- GEN_INT (INTVAL (op1) & 0xfffffc00)));
- }
- emit_insn (gen_rtx_SET (VOIDmode,
- op0,
- gen_rtx_IOR (mode,
- temp,
- GEN_INT (INTVAL (op1) & 0x3ff))));
- }
- else
- {
- /* A symbol, emit in the traditional way. */
- emit_insn (gen_rtx_SET (VOIDmode,
- temp,
- gen_rtx_HIGH (mode,
- op1)));
- emit_insn (gen_rtx_SET (VOIDmode,
- op0,
- gen_rtx_LO_SUM (mode,
- temp,
- op1)));
-
- }
-}
-
-
-/* Sparc-v9 code-model support. */
-void
-sparc_emit_set_symbolic_const64 (op0, op1, temp1)
- rtx op0;
- rtx op1;
- rtx temp1;
-{
- switch (sparc_cmodel)
- {
- case CM_MEDLOW:
- /* The range spanned by all instructions in the object is less
- than 2^31 bytes (2GB) and the distance from any instruction
- to the location of the label _GLOBAL_OFFSET_TABLE_ is less
- than 2^31 bytes (2GB).
-
- The executable must be in the low 4TB of the virtual address
- space.
-
- sethi %hi(symbol), %temp
- or %temp, %lo(symbol), %reg */
- emit_insn (gen_rtx_SET (VOIDmode, temp1, gen_rtx_HIGH (DImode, op1)));
- emit_insn (gen_rtx_SET (VOIDmode, op0, gen_rtx_LO_SUM (DImode, temp1, op1)));
- break;
-
- case CM_MEDMID:
- /* The range spanned by all instructions in the object is less
- than 2^31 bytes (2GB) and the distance from any instruction
- to the location of the label _GLOBAL_OFFSET_TABLE_ is less
- than 2^31 bytes (2GB).
-
- The executable must be in the low 16TB of the virtual address
- space.
-
- sethi %h44(symbol), %temp1
- or %temp1, %m44(symbol), %temp2
- sllx %temp2, 12, %temp3
- or %temp3, %l44(symbol), %reg */
- emit_insn (gen_seth44 (op0, op1));
- emit_insn (gen_setm44 (op0, op0, op1));
- emit_insn (gen_rtx_SET (VOIDmode, temp1,
- gen_rtx_ASHIFT (DImode, op0, GEN_INT (12))));
- emit_insn (gen_setl44 (op0, temp1, op1));
- break;
-
- case CM_MEDANY:
- /* The range spanned by all instructions in the object is less
- than 2^31 bytes (2GB) and the distance from any instruction
- to the location of the label _GLOBAL_OFFSET_TABLE_ is less
- than 2^31 bytes (2GB).
-
- The executable can be placed anywhere in the virtual address
- space.
-
- sethi %hh(symbol), %temp1
- sethi %lm(symbol), %temp2
- or %temp1, %hm(symbol), %temp3
- or %temp2, %lo(symbol), %temp4
- sllx %temp3, 32, %temp5
- or %temp4, %temp5, %reg */
-
- /* Getting this right wrt. reloading is really tricky.
- We _MUST_ have a seperate temporary at this point,
- if we don't barf immediately instead of generating
- incorrect code. */
- if (temp1 == op0)
- abort ();
-
- emit_insn (gen_sethh (op0, op1));
- emit_insn (gen_setlm (temp1, op1));
- emit_insn (gen_sethm (op0, op0, op1));
- emit_insn (gen_rtx_SET (VOIDmode, op0,
- gen_rtx_ASHIFT (DImode, op0, GEN_INT (32))));
- emit_insn (gen_rtx_SET (VOIDmode, op0,
- gen_rtx_PLUS (DImode, op0, temp1)));
- emit_insn (gen_setlo (op0, op0, op1));
- break;
-
- case CM_EMBMEDANY:
- /* Old old old backwards compatibility kruft here.
- Essentially it is MEDLOW with a fixed 64-bit
- virtual base added to all data segment addresses.
- Text-segment stuff is computed like MEDANY, we can't
- reuse the code above because the relocation knobs
- look different.
-
- Data segment: sethi %hi(symbol), %temp1
- or %temp1, %lo(symbol), %temp2
- add %temp2, EMBMEDANY_BASE_REG, %reg
-
- Text segment: sethi %uhi(symbol), %temp1
- sethi %hi(symbol), %temp2
- or %temp1, %ulo(symbol), %temp3
- or %temp2, %lo(symbol), %temp4
- sllx %temp3, 32, %temp5
- or %temp4, %temp5, %reg */
- if (data_segment_operand (op1, GET_MODE (op1)))
- {
- emit_insn (gen_embmedany_sethi (temp1, op1));
- emit_insn (gen_embmedany_brsum (op0, temp1));
- emit_insn (gen_embmedany_losum (op0, op0, op1));
- }
- else
- {
- /* Getting this right wrt. reloading is really tricky.
- We _MUST_ have a seperate temporary at this point,
- so we barf immediately instead of generating
- incorrect code. */
- if (temp1 == op0)
- abort ();
-
- emit_insn (gen_embmedany_textuhi (op0, op1));
- emit_insn (gen_embmedany_texthi (temp1, op1));
- emit_insn (gen_embmedany_textulo (op0, op0, op1));
- emit_insn (gen_rtx_SET (VOIDmode, op0,
- gen_rtx_ASHIFT (DImode, op0, GEN_INT (32))));
- emit_insn (gen_rtx_SET (VOIDmode, op0,
- gen_rtx_PLUS (DImode, op0, temp1)));
- emit_insn (gen_embmedany_textlo (op0, op0, op1));
- }
- break;
-
- default:
- abort();
- }
-}
-
-/* These avoid problems when cross compiling. If we do not
- go through all this hair then the optimizer will see
- invalid REG_EQUAL notes or in some cases none at all. */
-static void sparc_emit_set_safe_HIGH64 PROTO ((rtx, HOST_WIDE_INT));
-static rtx gen_safe_SET64 PROTO ((rtx, HOST_WIDE_INT));
-static rtx gen_safe_OR64 PROTO ((rtx, HOST_WIDE_INT));
-static rtx gen_safe_XOR64 PROTO ((rtx, HOST_WIDE_INT));
-
-#if HOST_BITS_PER_WIDE_INT == 64
-#define GEN_HIGHINT64(__x) GEN_INT ((__x) & 0xfffffc00)
-#define GEN_INT64(__x) GEN_INT (__x)
-#else
-#define GEN_HIGHINT64(__x) \
- gen_rtx_CONST_DOUBLE (VOIDmode, const0_rtx, \
- (__x) & 0xfffffc00, 0)
-#define GEN_INT64(__x) \
- gen_rtx_CONST_DOUBLE (VOIDmode, const0_rtx, \
- (__x) & 0xffffffff, \
- ((__x) & 0x80000000 \
- ? 0xffffffff : 0))
-#endif
-
-/* The optimizer is not to assume anything about exactly
- which bits are set for a HIGH, they are unspecified.
- Unfortunately this leads to many missed optimizations
- during CSE. We mask out the non-HIGH bits, and matches
- a plain movdi, to alleviate this problem. */
-static void
-sparc_emit_set_safe_HIGH64 (dest, val)
- rtx dest;
- HOST_WIDE_INT val;
-{
- emit_insn (gen_rtx_SET (VOIDmode, dest, GEN_HIGHINT64 (val)));
-}
-
-static rtx
-gen_safe_SET64 (dest, val)
- rtx dest;
- HOST_WIDE_INT val;
-{
- return gen_rtx_SET (VOIDmode, dest, GEN_INT64 (val));
-}
-
-static rtx
-gen_safe_OR64 (src, val)
- rtx src;
- HOST_WIDE_INT val;
-{
- return gen_rtx_IOR (DImode, src, GEN_INT64 (val));
-}
-
-static rtx
-gen_safe_XOR64 (src, val)
- rtx src;
- HOST_WIDE_INT val;
-{
- return gen_rtx_XOR (DImode, src, GEN_INT64 (val));
-}
-
-/* Worker routines for 64-bit constant formation on arch64.
- One of the key things to be doing in these emissions is
- to create as many temp REGs as possible. This makes it
- possible for half-built constants to be used later when
- such values are similar to something required later on.
- Without doing this, the optimizer cannot see such
- opportunities. */
-
-static void sparc_emit_set_const64_quick1
- PROTO((rtx, rtx, unsigned HOST_WIDE_INT, int));
-
-static void
-sparc_emit_set_const64_quick1 (op0, temp, low_bits, is_neg)
- rtx op0;
- rtx temp;
- unsigned HOST_WIDE_INT low_bits;
- int is_neg;
-{
- unsigned HOST_WIDE_INT high_bits;
-
- if (is_neg)
- high_bits = (~low_bits) & 0xffffffff;
- else
- high_bits = low_bits;
-
- sparc_emit_set_safe_HIGH64 (temp, high_bits);
- if (!is_neg)
- {
- emit_insn (gen_rtx_SET (VOIDmode, op0,
- gen_safe_OR64 (temp, (high_bits & 0x3ff))));
- }
- else
- {
- /* If we are XOR'ing with -1, then we should emit a one's complement
- instead. This way the combiner will notice logical operations
- such as ANDN later on and substitute. */
- if ((low_bits & 0x3ff) == 0x3ff)
- {
- emit_insn (gen_rtx_SET (VOIDmode, op0,
- gen_rtx_NOT (DImode, temp)));
- }
- else
- {
- emit_insn (gen_rtx_SET (VOIDmode, op0,
- gen_safe_XOR64 (temp,
- (-0x400 | (low_bits & 0x3ff)))));
- }
- }
-}
-
-static void sparc_emit_set_const64_quick2
- PROTO((rtx, rtx, unsigned HOST_WIDE_INT,
- unsigned HOST_WIDE_INT, int));
-
-static void
-sparc_emit_set_const64_quick2 (op0, temp, high_bits, low_immediate, shift_count)
- rtx op0;
- rtx temp;
- unsigned HOST_WIDE_INT high_bits;
- unsigned HOST_WIDE_INT low_immediate;
- int shift_count;
-{
- rtx temp2 = op0;
-
- if ((high_bits & 0xfffffc00) != 0)
- {
- sparc_emit_set_safe_HIGH64 (temp, high_bits);
- if ((high_bits & ~0xfffffc00) != 0)
- emit_insn (gen_rtx_SET (VOIDmode, op0,
- gen_safe_OR64 (temp, (high_bits & 0x3ff))));
- else
- temp2 = temp;
- }
- else
- {
- emit_insn (gen_safe_SET64 (temp, high_bits));
- temp2 = temp;
- }
-
- /* Now shift it up into place. */
- emit_insn (gen_rtx_SET (VOIDmode, op0,
- gen_rtx_ASHIFT (DImode, temp2,
- GEN_INT (shift_count))));
-
- /* If there is a low immediate part piece, finish up by
- putting that in as well. */
- if (low_immediate != 0)
- emit_insn (gen_rtx_SET (VOIDmode, op0,
- gen_safe_OR64 (op0, low_immediate)));
-}
-
-static void sparc_emit_set_const64_longway
- PROTO((rtx, rtx, unsigned HOST_WIDE_INT, unsigned HOST_WIDE_INT));
-
-/* Full 64-bit constant decomposition. Even though this is the
- 'worst' case, we still optimize a few things away. */
-static void
-sparc_emit_set_const64_longway (op0, temp, high_bits, low_bits)
- rtx op0;
- rtx temp;
- unsigned HOST_WIDE_INT high_bits;
- unsigned HOST_WIDE_INT low_bits;
-{
- rtx sub_temp;
-
- if (reload_in_progress || reload_completed)
- sub_temp = op0;
- else
- sub_temp = gen_reg_rtx (DImode);
-
- if ((high_bits & 0xfffffc00) != 0)
- {
- sparc_emit_set_safe_HIGH64 (temp, high_bits);
- if ((high_bits & ~0xfffffc00) != 0)
- emit_insn (gen_rtx_SET (VOIDmode,
- sub_temp,
- gen_safe_OR64 (temp, (high_bits & 0x3ff))));
- else
- sub_temp = temp;
- }
- else
- {
- emit_insn (gen_safe_SET64 (temp, high_bits));
- sub_temp = temp;
- }
-
- if (!reload_in_progress && !reload_completed)
- {
- rtx temp2 = gen_reg_rtx (DImode);
- rtx temp3 = gen_reg_rtx (DImode);
- rtx temp4 = gen_reg_rtx (DImode);
-
- emit_insn (gen_rtx_SET (VOIDmode, temp4,
- gen_rtx_ASHIFT (DImode, sub_temp,
- GEN_INT (32))));
-
- sparc_emit_set_safe_HIGH64 (temp2, low_bits);
- if ((low_bits & ~0xfffffc00) != 0)
- {
- emit_insn (gen_rtx_SET (VOIDmode, temp3,
- gen_safe_OR64 (temp2, (low_bits & 0x3ff))));
- emit_insn (gen_rtx_SET (VOIDmode, op0,
- gen_rtx_PLUS (DImode, temp4, temp3)));
- }
- else
- {
- emit_insn (gen_rtx_SET (VOIDmode, op0,
- gen_rtx_PLUS (DImode, temp4, temp2)));
- }
- }
- else
- {
- rtx low1 = GEN_INT ((low_bits >> (32 - 12)) & 0xfff);
- rtx low2 = GEN_INT ((low_bits >> (32 - 12 - 12)) & 0xfff);
- rtx low3 = GEN_INT ((low_bits >> (32 - 12 - 12 - 8)) & 0x0ff);
- int to_shift = 12;
-
- /* We are in the middle of reload, so this is really
- painful. However we do still make an attempt to
- avoid emitting truly stupid code. */
- if (low1 != const0_rtx)
- {
- emit_insn (gen_rtx_SET (VOIDmode, op0,
- gen_rtx_ASHIFT (DImode, sub_temp,
- GEN_INT (to_shift))));
- emit_insn (gen_rtx_SET (VOIDmode, op0,
- gen_rtx_IOR (DImode, op0, low1)));
- sub_temp = op0;
- to_shift = 12;
- }
- else
- {
- to_shift += 12;
- }
- if (low2 != const0_rtx)
- {
- emit_insn (gen_rtx_SET (VOIDmode, op0,
- gen_rtx_ASHIFT (DImode, sub_temp,
- GEN_INT (to_shift))));
- emit_insn (gen_rtx_SET (VOIDmode, op0,
- gen_rtx_IOR (DImode, op0, low2)));
- sub_temp = op0;
- to_shift = 8;
- }
- else
- {
- to_shift += 8;
- }
- emit_insn (gen_rtx_SET (VOIDmode, op0,
- gen_rtx_ASHIFT (DImode, sub_temp,
- GEN_INT (to_shift))));
- if (low3 != const0_rtx)
- emit_insn (gen_rtx_SET (VOIDmode, op0,
- gen_rtx_IOR (DImode, op0, low3)));
- /* phew... */
- }
-}
-
-/* Analyze a 64-bit constant for certain properties. */
-static void analyze_64bit_constant
- PROTO((unsigned HOST_WIDE_INT,
- unsigned HOST_WIDE_INT,
- int *, int *, int *));
-
-static void
-analyze_64bit_constant (high_bits, low_bits, hbsp, lbsp, abbasp)
- unsigned HOST_WIDE_INT high_bits, low_bits;
- int *hbsp, *lbsp, *abbasp;
-{
- int lowest_bit_set, highest_bit_set, all_bits_between_are_set;
- int i;
-
- lowest_bit_set = highest_bit_set = -1;
- i = 0;
- do
- {
- if ((lowest_bit_set == -1)
- && ((low_bits >> i) & 1))
- lowest_bit_set = i;
- if ((highest_bit_set == -1)
- && ((high_bits >> (32 - i - 1)) & 1))
- highest_bit_set = (64 - i - 1);
- }
- while (++i < 32
- && ((highest_bit_set == -1)
- || (lowest_bit_set == -1)));
- if (i == 32)
- {
- i = 0;
- do
- {
- if ((lowest_bit_set == -1)
- && ((high_bits >> i) & 1))
- lowest_bit_set = i + 32;
- if ((highest_bit_set == -1)
- && ((low_bits >> (32 - i - 1)) & 1))
- highest_bit_set = 32 - i - 1;
- }
- while (++i < 32
- && ((highest_bit_set == -1)
- || (lowest_bit_set == -1)));
- }
- /* If there are no bits set this should have gone out
- as one instruction! */
- if (lowest_bit_set == -1
- || highest_bit_set == -1)
- abort ();
- all_bits_between_are_set = 1;
- for (i = lowest_bit_set; i <= highest_bit_set; i++)
- {
- if (i < 32)
- {
- if ((low_bits & (1 << i)) != 0)
- continue;
- }
- else
- {
- if ((high_bits & (1 << (i - 32))) != 0)
- continue;
- }
- all_bits_between_are_set = 0;
- break;
- }
- *hbsp = highest_bit_set;
- *lbsp = lowest_bit_set;
- *abbasp = all_bits_between_are_set;
-}
-
-static int const64_is_2insns
- PROTO((unsigned HOST_WIDE_INT, unsigned HOST_WIDE_INT));
-
-static int
-const64_is_2insns (high_bits, low_bits)
- unsigned HOST_WIDE_INT high_bits, low_bits;
-{
- int highest_bit_set, lowest_bit_set, all_bits_between_are_set;
-
- if (high_bits == 0
- || high_bits == 0xffffffff)
- return 1;
-
- analyze_64bit_constant (high_bits, low_bits,
- &highest_bit_set, &lowest_bit_set,
- &all_bits_between_are_set);
-
- if ((highest_bit_set == 63
- || lowest_bit_set == 0)
- && all_bits_between_are_set != 0)
- return 1;
-
- if ((highest_bit_set - lowest_bit_set) < 21)
- return 1;
-
- return 0;
-}
-
-static unsigned HOST_WIDE_INT create_simple_focus_bits
- PROTO((unsigned HOST_WIDE_INT, unsigned HOST_WIDE_INT,
- int, int));
-
-static unsigned HOST_WIDE_INT
-create_simple_focus_bits (high_bits, low_bits, lowest_bit_set, shift)
- unsigned HOST_WIDE_INT high_bits, low_bits;
- int lowest_bit_set, shift;
-{
- HOST_WIDE_INT hi, lo;
-
- if (lowest_bit_set < 32)
- {
- lo = (low_bits >> lowest_bit_set) << shift;
- hi = ((high_bits << (32 - lowest_bit_set)) << shift);
- }
- else
- {
- lo = 0;
- hi = ((high_bits >> (lowest_bit_set - 32)) << shift);
- }
- if (hi & lo)
- abort ();
- return (hi | lo);
-}
-
-/* Here we are sure to be arch64 and this is an integer constant
- being loaded into a register. Emit the most efficient
- insn sequence possible. Detection of all the 1-insn cases
- has been done already. */
-void
-sparc_emit_set_const64 (op0, op1)
- rtx op0;
- rtx op1;
-{
- unsigned HOST_WIDE_INT high_bits, low_bits;
- int lowest_bit_set, highest_bit_set;
- int all_bits_between_are_set;
- rtx temp;
-
- /* Sanity check that we know what we are working with. */
- if (! TARGET_ARCH64
- || GET_CODE (op0) != REG
- || (REGNO (op0) >= SPARC_FIRST_FP_REG
- && REGNO (op0) <= SPARC_LAST_V9_FP_REG))
- abort ();
-
- if (reload_in_progress || reload_completed)
- temp = op0;
- else
- temp = gen_reg_rtx (DImode);
-
- if (GET_CODE (op1) != CONST_DOUBLE
- && GET_CODE (op1) != CONST_INT)
- {
- sparc_emit_set_symbolic_const64 (op0, op1, temp);
- return;
- }
-
- if (GET_CODE (op1) == CONST_DOUBLE)
- {
-#if HOST_BITS_PER_WIDE_INT == 64
- high_bits = (CONST_DOUBLE_LOW (op1) >> 32) & 0xffffffff;
- low_bits = CONST_DOUBLE_LOW (op1) & 0xffffffff;
-#else
- high_bits = CONST_DOUBLE_HIGH (op1);
- low_bits = CONST_DOUBLE_LOW (op1);
-#endif
- }
- else
- {
-#if HOST_BITS_PER_WIDE_INT == 64
- high_bits = ((INTVAL (op1) >> 32) & 0xffffffff);
- low_bits = (INTVAL (op1) & 0xffffffff);
-#else
- high_bits = ((INTVAL (op1) < 0) ?
- 0xffffffff :
- 0x00000000);
- low_bits = INTVAL (op1);
-#endif
- }
-
- /* low_bits bits 0 --> 31
- high_bits bits 32 --> 63 */
-
- analyze_64bit_constant (high_bits, low_bits,
- &highest_bit_set, &lowest_bit_set,
- &all_bits_between_are_set);
-
- /* First try for a 2-insn sequence. */
-
- /* These situations are preferred because the optimizer can
- * do more things with them:
- * 1) mov -1, %reg
- * sllx %reg, shift, %reg
- * 2) mov -1, %reg
- * srlx %reg, shift, %reg
- * 3) mov some_small_const, %reg
- * sllx %reg, shift, %reg
- */
- if (((highest_bit_set == 63
- || lowest_bit_set == 0)
- && all_bits_between_are_set != 0)
- || ((highest_bit_set - lowest_bit_set) < 12))
- {
- HOST_WIDE_INT the_const = -1;
- int shift = lowest_bit_set;
-
- if ((highest_bit_set != 63
- && lowest_bit_set != 0)
- || all_bits_between_are_set == 0)
- {
- the_const =
- create_simple_focus_bits (high_bits, low_bits,
- lowest_bit_set, 0);
- }
- else if (lowest_bit_set == 0)
- shift = -(63 - highest_bit_set);
-
- if (! SPARC_SIMM13_P (the_const))
- abort ();
-
- emit_insn (gen_safe_SET64 (temp, the_const));
- if (shift > 0)
- emit_insn (gen_rtx_SET (VOIDmode,
- op0,
- gen_rtx_ASHIFT (DImode,
- temp,
- GEN_INT (shift))));
- else if (shift < 0)
- emit_insn (gen_rtx_SET (VOIDmode,
- op0,
- gen_rtx_LSHIFTRT (DImode,
- temp,
- GEN_INT (-shift))));
- else
- abort ();
- return;
- }
-
- /* Now a range of 22 or less bits set somewhere.
- * 1) sethi %hi(focus_bits), %reg
- * sllx %reg, shift, %reg
- * 2) sethi %hi(focus_bits), %reg
- * srlx %reg, shift, %reg
- */
- if ((highest_bit_set - lowest_bit_set) < 21)
- {
- unsigned HOST_WIDE_INT focus_bits =
- create_simple_focus_bits (high_bits, low_bits,
- lowest_bit_set, 10);
-
- if (! SPARC_SETHI_P (focus_bits))
- abort ();
-
- sparc_emit_set_safe_HIGH64 (temp, focus_bits);
-
- /* If lowest_bit_set == 10 then a sethi alone could have done it. */
- if (lowest_bit_set < 10)
- emit_insn (gen_rtx_SET (VOIDmode,
- op0,
- gen_rtx_LSHIFTRT (DImode, temp,
- GEN_INT (10 - lowest_bit_set))));
- else if (lowest_bit_set > 10)
- emit_insn (gen_rtx_SET (VOIDmode,
- op0,
- gen_rtx_ASHIFT (DImode, temp,
- GEN_INT (lowest_bit_set - 10))));
- else
- abort ();
- return;
- }
-
- /* 1) sethi %hi(low_bits), %reg
- * or %reg, %lo(low_bits), %reg
- * 2) sethi %hi(~low_bits), %reg
- * xor %reg, %lo(-0x400 | (low_bits & 0x3ff)), %reg
- */
- if (high_bits == 0
- || high_bits == 0xffffffff)
- {
- sparc_emit_set_const64_quick1 (op0, temp, low_bits,
- (high_bits == 0xffffffff));
- return;
- }
-
- /* Now, try 3-insn sequences. */
-
- /* 1) sethi %hi(high_bits), %reg
- * or %reg, %lo(high_bits), %reg
- * sllx %reg, 32, %reg
- */
- if (low_bits == 0)
- {
- sparc_emit_set_const64_quick2 (op0, temp, high_bits, 0, 32);
- return;
- }
-
- /* We may be able to do something quick
- when the constant is negated, so try that. */
- if (const64_is_2insns ((~high_bits) & 0xffffffff,
- (~low_bits) & 0xfffffc00))
- {
- /* NOTE: The trailing bits get XOR'd so we need the
- non-negated bits, not the negated ones. */
- unsigned HOST_WIDE_INT trailing_bits = low_bits & 0x3ff;
-
- if ((((~high_bits) & 0xffffffff) == 0
- && ((~low_bits) & 0x80000000) == 0)
- || (((~high_bits) & 0xffffffff) == 0xffffffff
- && ((~low_bits) & 0x80000000) != 0))
- {
- int fast_int = (~low_bits & 0xffffffff);
-
- if ((SPARC_SETHI_P (fast_int)
- && (~high_bits & 0xffffffff) == 0)
- || SPARC_SIMM13_P (fast_int))
- emit_insn (gen_safe_SET64 (temp, fast_int));
- else
- sparc_emit_set_const64 (temp, GEN_INT64 (fast_int));
- }
- else
- {
- rtx negated_const;
-#if HOST_BITS_PER_WIDE_INT == 64
- negated_const = GEN_INT (((~low_bits) & 0xfffffc00) |
- (((HOST_WIDE_INT)((~high_bits) & 0xffffffff))<<32));
-#else
- negated_const = gen_rtx_CONST_DOUBLE (DImode, const0_rtx,
- (~low_bits) & 0xfffffc00,
- (~high_bits) & 0xffffffff);
-#endif
- sparc_emit_set_const64 (temp, negated_const);
- }
-
- /* If we are XOR'ing with -1, then we should emit a one's complement
- instead. This way the combiner will notice logical operations
- such as ANDN later on and substitute. */
- if (trailing_bits == 0x3ff)
- {
- emit_insn (gen_rtx_SET (VOIDmode, op0,
- gen_rtx_NOT (DImode, temp)));
- }
- else
- {
- emit_insn (gen_rtx_SET (VOIDmode,
- op0,
- gen_safe_XOR64 (temp,
- (-0x400 | trailing_bits))));
- }
- return;
- }
-
- /* 1) sethi %hi(xxx), %reg
- * or %reg, %lo(xxx), %reg
- * sllx %reg, yyy, %reg
- *
- * ??? This is just a generalized version of the low_bits==0
- * thing above, FIXME...
- */
- if ((highest_bit_set - lowest_bit_set) < 32)
- {
- unsigned HOST_WIDE_INT focus_bits =
- create_simple_focus_bits (high_bits, low_bits,
- lowest_bit_set, 0);
-
- /* We can't get here in this state. */
- if (highest_bit_set < 32
- || lowest_bit_set >= 32)
- abort ();
-
- /* So what we know is that the set bits straddle the
- middle of the 64-bit word. */
- sparc_emit_set_const64_quick2 (op0, temp,
- focus_bits, 0,
- lowest_bit_set);
- return;
- }
-
- /* 1) sethi %hi(high_bits), %reg
- * or %reg, %lo(high_bits), %reg
- * sllx %reg, 32, %reg
- * or %reg, low_bits, %reg
- */
- if (SPARC_SIMM13_P(low_bits)
- && ((int)low_bits > 0))
- {
- sparc_emit_set_const64_quick2 (op0, temp, high_bits, low_bits, 32);
- return;
- }
-
- /* The easiest way when all else fails, is full decomposition. */
-#if 0
- printf ("sparc_emit_set_const64: Hard constant [%08lx%08lx] neg[%08lx%08lx]\n",
- high_bits, low_bits, ~high_bits, ~low_bits);
-#endif
- sparc_emit_set_const64_longway (op0, temp, high_bits, low_bits);
-}
-
-/* X and Y are two things to compare using CODE. Emit the compare insn and
- return the rtx for the cc reg in the proper mode. */
-
-rtx
-gen_compare_reg (code, x, y)
- enum rtx_code code;
- rtx x, y;
-{
- enum machine_mode mode = SELECT_CC_MODE (code, x, y);
- rtx cc_reg;
-
- /* ??? We don't have movcc patterns so we cannot generate pseudo regs for the
- fcc regs (cse can't tell they're really call clobbered regs and will
- remove a duplicate comparison even if there is an intervening function
- call - it will then try to reload the cc reg via an int reg which is why
- we need the movcc patterns). It is possible to provide the movcc
- patterns by using the ldxfsr/stxfsr v9 insns. I tried it: you need two
- registers (say %g1,%g5) and it takes about 6 insns. A better fix would be
- to tell cse that CCFPE mode registers (even pseudos) are call
- clobbered. */
-
- /* ??? This is an experiment. Rather than making changes to cse which may
- or may not be easy/clean, we do our own cse. This is possible because
- we will generate hard registers. Cse knows they're call clobbered (it
- doesn't know the same thing about pseudos). If we guess wrong, no big
- deal, but if we win, great! */
-
- if (TARGET_V9 && GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT)
-#if 1 /* experiment */
- {
- int reg;
- /* We cycle through the registers to ensure they're all exercised. */
- static int next_fcc_reg = 0;
- /* Previous x,y for each fcc reg. */
- static rtx prev_args[4][2];
-
- /* Scan prev_args for x,y. */
- for (reg = 0; reg < 4; reg++)
- if (prev_args[reg][0] == x && prev_args[reg][1] == y)
- break;
- if (reg == 4)
- {
- reg = next_fcc_reg;
- prev_args[reg][0] = x;
- prev_args[reg][1] = y;
- next_fcc_reg = (next_fcc_reg + 1) & 3;
- }
- cc_reg = gen_rtx_REG (mode, reg + SPARC_FIRST_V9_FCC_REG);
- }
-#else
- cc_reg = gen_reg_rtx (mode);
-#endif /* ! experiment */
- else if (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT)
- cc_reg = gen_rtx_REG (mode, SPARC_FCC_REG);
- else
- cc_reg = gen_rtx_REG (mode, SPARC_ICC_REG);
-
- emit_insn (gen_rtx_SET (VOIDmode, cc_reg,
- gen_rtx_COMPARE (mode, x, y)));
-
- return cc_reg;
-}
-
-/* This function is used for v9 only.
- CODE is the code for an Scc's comparison.
- OPERANDS[0] is the target of the Scc insn.
- OPERANDS[1] is the value we compare against const0_rtx (which hasn't
- been generated yet).
-
- This function is needed to turn
-
- (set (reg:SI 110)
- (gt (reg:CCX 100 %icc)
- (const_int 0)))
- into
- (set (reg:SI 110)
- (gt:DI (reg:CCX 100 %icc)
- (const_int 0)))
-
- IE: The instruction recognizer needs to see the mode of the comparison to
- find the right instruction. We could use "gt:DI" right in the
- define_expand, but leaving it out allows us to handle DI, SI, etc.
-
- We refer to the global sparc compare operands sparc_compare_op0 and
- sparc_compare_op1. */
-
-int
-gen_v9_scc (compare_code, operands)
- enum rtx_code compare_code;
- register rtx *operands;
-{
- rtx temp, op0, op1;
-
- if (! TARGET_ARCH64
- && (GET_MODE (sparc_compare_op0) == DImode
- || GET_MODE (operands[0]) == DImode))
- return 0;
-
- /* Handle the case where operands[0] == sparc_compare_op0.
- We "early clobber" the result. */
- if (REGNO (operands[0]) == REGNO (sparc_compare_op0))
- {
- op0 = gen_reg_rtx (GET_MODE (sparc_compare_op0));
- emit_move_insn (op0, sparc_compare_op0);
- }
- else
- op0 = sparc_compare_op0;
- /* For consistency in the following. */
- op1 = sparc_compare_op1;
-
- /* Try to use the movrCC insns. */
- if (TARGET_ARCH64
- && GET_MODE_CLASS (GET_MODE (op0)) == MODE_INT
- && op1 == const0_rtx
- && v9_regcmp_p (compare_code))
- {
- /* Special case for op0 != 0. This can be done with one instruction if
- operands[0] == sparc_compare_op0. We don't assume they are equal
- now though. */
-
- if (compare_code == NE
- && GET_MODE (operands[0]) == DImode
- && GET_MODE (op0) == DImode)
- {
- emit_insn (gen_rtx_SET (VOIDmode, operands[0], op0));
- emit_insn (gen_rtx_SET (VOIDmode, operands[0],
- gen_rtx_IF_THEN_ELSE (DImode,
- gen_rtx_fmt_ee (compare_code, DImode,
- op0, const0_rtx),
- const1_rtx,
- operands[0])));
- return 1;
- }
-
- emit_insn (gen_rtx_SET (VOIDmode, operands[0], const0_rtx));
- if (GET_MODE (op0) != DImode)
- {
- temp = gen_reg_rtx (DImode);
- convert_move (temp, op0, 0);
- }
- else
- temp = op0;
- emit_insn (gen_rtx_SET (VOIDmode, operands[0],
- gen_rtx_IF_THEN_ELSE (GET_MODE (operands[0]),
- gen_rtx_fmt_ee (compare_code, DImode,
- temp, const0_rtx),
- const1_rtx,
- operands[0])));
- return 1;
- }
- else
- {
- operands[1] = gen_compare_reg (compare_code, op0, op1);
-
- switch (GET_MODE (operands[1]))
- {
- case CCmode :
- case CCXmode :
- case CCFPEmode :
- case CCFPmode :
- break;
- default :
- abort ();
- }
- emit_insn (gen_rtx_SET (VOIDmode, operands[0], const0_rtx));
- emit_insn (gen_rtx_SET (VOIDmode, operands[0],
- gen_rtx_IF_THEN_ELSE (GET_MODE (operands[0]),
- gen_rtx_fmt_ee (compare_code,
- GET_MODE (operands[1]),
- operands[1], const0_rtx),
- const1_rtx, operands[0])));
- return 1;
- }
-}
-
-/* Emit a conditional jump insn for the v9 architecture using comparison code
- CODE and jump target LABEL.
- This function exists to take advantage of the v9 brxx insns. */
-
-void
-emit_v9_brxx_insn (code, op0, label)
- enum rtx_code code;
- rtx op0, label;
-{
- emit_jump_insn (gen_rtx_SET (VOIDmode,
- pc_rtx,
- gen_rtx_IF_THEN_ELSE (VOIDmode,
- gen_rtx_fmt_ee (code, GET_MODE (op0),
- op0, const0_rtx),
- gen_rtx_LABEL_REF (VOIDmode, label),
- pc_rtx)));
-}
-
-/* Return nonzero if a return peephole merging return with
- setting of output register is ok. */
-int
-leaf_return_peephole_ok ()
-{
- return (actual_fsize == 0);
-}
-
-/* Return nonzero if TRIAL can go into the function epilogue's
- delay slot. SLOT is the slot we are trying to fill. */
-
-int
-eligible_for_epilogue_delay (trial, slot)
- rtx trial;
- int slot;
-{
- rtx pat, src;
-
- if (slot >= 1)
- return 0;
-
- if (GET_CODE (trial) != INSN || GET_CODE (PATTERN (trial)) != SET)
- return 0;
-
- if (get_attr_length (trial) != 1)
- return 0;
-
- /* If %g0 is live, there are lots of things we can't handle.
- Rather than trying to find them all now, let's punt and only
- optimize things as necessary. */
- if (TARGET_LIVE_G0)
- return 0;
-
- /* In the case of a true leaf function, anything can go into the delay slot.
- A delay slot only exists however if the frame size is zero, otherwise
- we will put an insn to adjust the stack after the return. */
- if (current_function_uses_only_leaf_regs)
- {
- if (leaf_return_peephole_ok ())
- return ((get_attr_in_uncond_branch_delay (trial)
- == IN_BRANCH_DELAY_TRUE));
- return 0;
- }
-
- /* If only trivial `restore' insns work, nothing can go in the
- delay slot. */
- else if (TARGET_BROKEN_SAVERESTORE)
- return 0;
-
- pat = PATTERN (trial);
-
- /* Otherwise, only operations which can be done in tandem with
- a `restore' insn can go into the delay slot. */
- if (GET_CODE (SET_DEST (pat)) != REG
- || REGNO (SET_DEST (pat)) >= 32
- || REGNO (SET_DEST (pat)) < 24)
- return 0;
-
- /* The set of insns matched here must agree precisely with the set of
- patterns paired with a RETURN in sparc.md. */
-
- src = SET_SRC (pat);
-
- /* This matches "*return_[qhs]i" or even "*return_di" on TARGET_ARCH64. */
- if (arith_operand (src, GET_MODE (src)))
- {
- if (TARGET_ARCH64)
- return GET_MODE_SIZE (GET_MODE (src)) <= GET_MODE_SIZE (DImode);
- else
- return GET_MODE_SIZE (GET_MODE (src)) <= GET_MODE_SIZE (SImode);
- }
-
- /* This matches "*return_di". */
- else if (arith_double_operand (src, GET_MODE (src)))
- return GET_MODE_SIZE (GET_MODE (src)) <= GET_MODE_SIZE (DImode);
-
- /* This matches "*return_sf_no_fpu". */
- else if (! TARGET_FPU && restore_operand (SET_DEST (pat), SFmode)
- && register_operand (src, SFmode))
- return 1;
-
- /* This matches "*return_addsi". */
- else if (GET_CODE (src) == PLUS
- && arith_operand (XEXP (src, 0), SImode)
- && arith_operand (XEXP (src, 1), SImode)
- && (register_operand (XEXP (src, 0), SImode)
- || register_operand (XEXP (src, 1), SImode)))
- return 1;
-
- /* This matches "*return_adddi". */
- else if (GET_CODE (src) == PLUS
- && arith_double_operand (XEXP (src, 0), DImode)
- && arith_double_operand (XEXP (src, 1), DImode)
- && (register_operand (XEXP (src, 0), DImode)
- || register_operand (XEXP (src, 1), DImode)))
- return 1;
-
- return 0;
-}
-
-static int
-check_return_regs (x)
- rtx x;
-{
- switch (GET_CODE (x))
- {
- case REG:
- return IN_OR_GLOBAL_P (x);
-
- case CONST_INT:
- case CONST_DOUBLE:
- case CONST:
- case SYMBOL_REF:
- case LABEL_REF:
- return 1;
-
- case SET:
- case IOR:
- case AND:
- case XOR:
- case PLUS:
- case MINUS:
- if (check_return_regs (XEXP (x, 1)) == 0)
- return 0;
- case NOT:
- case NEG:
- case MEM:
- return check_return_regs (XEXP (x, 0));
-
- default:
- return 0;
- }
-
-}
-
-/* Return 1 if TRIAL references only in and global registers. */
-int
-eligible_for_return_delay (trial)
- rtx trial;
-{
- if (GET_CODE (PATTERN (trial)) != SET)
- return 0;
-
- return check_return_regs (PATTERN (trial));
-}
-
-int
-short_branch (uid1, uid2)
- int uid1, uid2;
-{
- unsigned int delta = insn_addresses[uid1] - insn_addresses[uid2];
- if (delta + 1024 < 2048)
- return 1;
- /* warning ("long branch, distance %d", delta); */
- return 0;
-}
-
-/* Return non-zero if REG is not used after INSN.
- We assume REG is a reload reg, and therefore does
- not live past labels or calls or jumps. */
-int
-reg_unused_after (reg, insn)
- rtx reg;
- rtx insn;
-{
- enum rtx_code code, prev_code = UNKNOWN;
-
- while ((insn = NEXT_INSN (insn)))
- {
- if (prev_code == CALL_INSN && call_used_regs[REGNO (reg)])
- return 1;
-
- code = GET_CODE (insn);
- if (GET_CODE (insn) == CODE_LABEL)
- return 1;
-
- if (GET_RTX_CLASS (code) == 'i')
- {
- rtx set = single_set (insn);
- int in_src = set && reg_overlap_mentioned_p (reg, SET_SRC (set));
- if (set && in_src)
- return 0;
- if (set && reg_overlap_mentioned_p (reg, SET_DEST (set)))
- return 1;
- if (set == 0 && reg_overlap_mentioned_p (reg, PATTERN (insn)))
- return 0;
- }
- prev_code = code;
- }
- return 1;
-}
-
-/* The table we use to reference PIC data. */
-static rtx global_offset_table;
-
-/* The function we use to get at it. */
-static rtx get_pc_symbol;
-static char get_pc_symbol_name[256];
-
-/* Ensure that we are not using patterns that are not OK with PIC. */
-
-int
-check_pic (i)
- int i;
-{
- switch (flag_pic)
- {
- case 1:
- if (GET_CODE (recog_operand[i]) == SYMBOL_REF
- || (GET_CODE (recog_operand[i]) == CONST
- && ! (GET_CODE (XEXP (recog_operand[i], 0)) == MINUS
- && (XEXP (XEXP (recog_operand[i], 0), 0)
- == global_offset_table)
- && (GET_CODE (XEXP (XEXP (recog_operand[i], 0), 1))
- == CONST))))
- abort ();
- case 2:
- default:
- return 1;
- }
-}
-
-/* Return true if X is an address which needs a temporary register when
- reloaded while generating PIC code. */
-
-int
-pic_address_needs_scratch (x)
- rtx x;
-{
- /* An address which is a symbolic plus a non SMALL_INT needs a temp reg. */
- if (GET_CODE (x) == CONST && GET_CODE (XEXP (x, 0)) == PLUS
- && GET_CODE (XEXP (XEXP (x, 0), 0)) == SYMBOL_REF
- && GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT
- && ! SMALL_INT (XEXP (XEXP (x, 0), 1)))
- return 1;
-
- return 0;
-}
-
-/* Legitimize PIC addresses. If the address is already position-independent,
- we return ORIG. Newly generated position-independent addresses go into a
- reg. This is REG if non zero, otherwise we allocate register(s) as
- necessary. */
-
-rtx
-legitimize_pic_address (orig, mode, reg)
- rtx orig;
- enum machine_mode mode ATTRIBUTE_UNUSED;
- rtx reg;
-{
- if (GET_CODE (orig) == SYMBOL_REF)
- {
- rtx pic_ref, address;
- rtx insn;
-
- if (reg == 0)
- {
- if (reload_in_progress || reload_completed)
- abort ();
- else
- reg = gen_reg_rtx (Pmode);
- }
-
- if (flag_pic == 2)
- {
- /* If not during reload, allocate another temp reg here for loading
- in the address, so that these instructions can be optimized
- properly. */
- rtx temp_reg = ((reload_in_progress || reload_completed)
- ? reg : gen_reg_rtx (Pmode));
-
- /* Must put the SYMBOL_REF inside an UNSPEC here so that cse
- won't get confused into thinking that these two instructions
- are loading in the true address of the symbol. If in the
- future a PIC rtx exists, that should be used instead. */
- if (Pmode == SImode)
- {
- emit_insn (gen_movsi_high_pic (temp_reg, orig));
- emit_insn (gen_movsi_lo_sum_pic (temp_reg, temp_reg, orig));
- }
- else
- {
- emit_insn (gen_movdi_high_pic (temp_reg, orig));
- emit_insn (gen_movdi_lo_sum_pic (temp_reg, temp_reg, orig));
- }
- address = temp_reg;
- }
- else
- address = orig;
-
- pic_ref = gen_rtx_MEM (Pmode,
- gen_rtx_PLUS (Pmode,
- pic_offset_table_rtx, address));
- current_function_uses_pic_offset_table = 1;
- RTX_UNCHANGING_P (pic_ref) = 1;
- insn = emit_move_insn (reg, pic_ref);
- /* Put a REG_EQUAL note on this insn, so that it can be optimized
- by loop. */
- REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_EQUAL, orig,
- REG_NOTES (insn));
- return reg;
- }
- else if (GET_CODE (orig) == CONST)
- {
- rtx base, offset;
-
- if (GET_CODE (XEXP (orig, 0)) == PLUS
- && XEXP (XEXP (orig, 0), 0) == pic_offset_table_rtx)
- return orig;
-
- if (reg == 0)
- {
- if (reload_in_progress || reload_completed)
- abort ();
- else
- reg = gen_reg_rtx (Pmode);
- }
-
- if (GET_CODE (XEXP (orig, 0)) == PLUS)
- {
- base = legitimize_pic_address (XEXP (XEXP (orig, 0), 0), Pmode, reg);
- offset = legitimize_pic_address (XEXP (XEXP (orig, 0), 1), Pmode,
- base == reg ? 0 : reg);
- }
- else
- abort ();
-
- if (GET_CODE (offset) == CONST_INT)
- {
- if (SMALL_INT (offset))
- return plus_constant_for_output (base, INTVAL (offset));
- else if (! reload_in_progress && ! reload_completed)
- offset = force_reg (Pmode, offset);
- else
- /* If we reach here, then something is seriously wrong. */
- abort ();
- }
- return gen_rtx_PLUS (Pmode, base, offset);
- }
- else if (GET_CODE (orig) == LABEL_REF)
- /* ??? Why do we do this? */
- /* Now movsi_pic_label_ref uses it, but we ought to be checking that
- the register is live instead, in case it is eliminated. */
- current_function_uses_pic_offset_table = 1;
-
- return orig;
-}
-
-/* Return the RTX for insns to set the PIC register. */
-
-static rtx
-pic_setup_code ()
-{
- rtx seq;
-
- start_sequence ();
- emit_insn (gen_get_pc (pic_offset_table_rtx, global_offset_table,
- get_pc_symbol));
- seq = gen_sequence ();
- end_sequence ();
-
- return seq;
-}
-
-/* Emit special PIC prologues and epilogues. */
-
-void
-finalize_pic ()
-{
- /* Labels to get the PC in the prologue of this function. */
- int orig_flag_pic = flag_pic;
- rtx insn;
-
- if (current_function_uses_pic_offset_table == 0)
- return;
-
- if (! flag_pic)
- abort ();
-
- /* If we havn't emitted the special get_pc helper function, do so now. */
- if (get_pc_symbol_name[0] == 0)
- {
- int align;
-
- ASM_GENERATE_INTERNAL_LABEL (get_pc_symbol_name, "LGETPC", 0);
- text_section ();
-
- align = floor_log2 (FUNCTION_BOUNDARY / BITS_PER_UNIT);
- if (align > 0)
- ASM_OUTPUT_ALIGN (asm_out_file, align);
- ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LGETPC", 0);
- fputs ("\tretl\n\tadd %o7,%l7,%l7\n", asm_out_file);
- }
-
- /* Initialize every time through, since we can't easily
- know this to be permanent. */
- global_offset_table = gen_rtx_SYMBOL_REF (Pmode, "_GLOBAL_OFFSET_TABLE_");
- get_pc_symbol = gen_rtx_SYMBOL_REF (Pmode, get_pc_symbol_name);
- flag_pic = 0;
-
- emit_insn_after (pic_setup_code (), get_insns ());
-
- /* Insert the code in each nonlocal goto receiver.
- If you make changes here or to the nonlocal_goto_receiver
- pattern, make sure the unspec_volatile numbers still
- match. */
- for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
- if (GET_CODE (insn) == INSN && GET_CODE (PATTERN (insn)) == UNSPEC_VOLATILE
- && XINT (PATTERN (insn), 1) == 5)
- emit_insn_after (pic_setup_code (), insn);
-
- flag_pic = orig_flag_pic;
-
- /* Need to emit this whether or not we obey regdecls,
- since setjmp/longjmp can cause life info to screw up.
- ??? In the case where we don't obey regdecls, this is not sufficient
- since we may not fall out the bottom. */
- emit_insn (gen_rtx_USE (VOIDmode, pic_offset_table_rtx));
-}
-
-/* Return 1 if RTX is a MEM which is known to be aligned to at
- least an 8 byte boundary. */
-
-int
-mem_min_alignment (mem, desired)
- rtx mem;
- int desired;
-{
- rtx addr, base, offset;
-
- /* If it's not a MEM we can't accept it. */
- if (GET_CODE (mem) != MEM)
- return 0;
-
- addr = XEXP (mem, 0);
- base = offset = NULL_RTX;
- if (GET_CODE (addr) == PLUS)
- {
- if (GET_CODE (XEXP (addr, 0)) == REG)
- {
- base = XEXP (addr, 0);
-
- /* What we are saying here is that if the base
- REG is aligned properly, the compiler will make
- sure any REG based index upon it will be so
- as well. */
- if (GET_CODE (XEXP (addr, 1)) == CONST_INT)
- offset = XEXP (addr, 1);
- else
- offset = const0_rtx;
- }
- }
- else if (GET_CODE (addr) == REG)
- {
- base = addr;
- offset = const0_rtx;
- }
-
- if (base != NULL_RTX)
- {
- int regno = REGNO (base);
-
- if (regno != FRAME_POINTER_REGNUM
- && regno != STACK_POINTER_REGNUM)
- {
- /* Check if the compiler has recorded some information
- about the alignment of the base REG. If reload has
- completed, we already matched with proper alignments. */
- if (((regno_pointer_align != NULL
- && REGNO_POINTER_ALIGN (regno) >= desired)
- || reload_completed)
- && ((INTVAL (offset) & (desired - 1)) == 0))
- return 1;
- }
- else
- {
- if (((INTVAL (offset) - SPARC_STACK_BIAS) & (desired - 1)) == 0)
- return 1;
- }
- }
- else if (! TARGET_UNALIGNED_DOUBLES
- || CONSTANT_P (addr)
- || GET_CODE (addr) == LO_SUM)
- {
- /* Anything else we know is properly aligned unless TARGET_UNALIGNED_DOUBLES
- is true, in which case we can only assume that an access is aligned if
- it is to a constant address, or the address involves a LO_SUM. */
- return 1;
- }
-
- /* An obviously unaligned address. */
- return 0;
-}
-
-
-/* Vectors to keep interesting information about registers where it can easily
- be got. We use to use the actual mode value as the bit number, but there
- are more than 32 modes now. Instead we use two tables: one indexed by
- hard register number, and one indexed by mode. */
-
-/* The purpose of sparc_mode_class is to shrink the range of modes so that
- they all fit (as bit numbers) in a 32 bit word (again). Each real mode is
- mapped into one sparc_mode_class mode. */
-
-enum sparc_mode_class {
- S_MODE, D_MODE, T_MODE, O_MODE,
- SF_MODE, DF_MODE, TF_MODE, OF_MODE,
- CC_MODE, CCFP_MODE
-};
-
-/* Modes for single-word and smaller quantities. */
-#define S_MODES ((1 << (int) S_MODE) | (1 << (int) SF_MODE))
-
-/* Modes for double-word and smaller quantities. */
-#define D_MODES (S_MODES | (1 << (int) D_MODE) | (1 << DF_MODE))
-
-/* Modes for quad-word and smaller quantities. */
-#define T_MODES (D_MODES | (1 << (int) T_MODE) | (1 << (int) TF_MODE))
-
-/* Modes for single-float quantities. We must allow any single word or
- smaller quantity. This is because the fix/float conversion instructions
- take integer inputs/outputs from the float registers. */
-#define SF_MODES (S_MODES)
-
-/* Modes for double-float and smaller quantities. */
-#define DF_MODES (S_MODES | D_MODES)
-
-#define DF_MODES64 DF_MODES
-
-/* Modes for double-float only quantities. */
-#define DF_ONLY_MODES ((1 << (int) DF_MODE) | (1 << (int) D_MODE))
-
-/* Modes for double-float and larger quantities. */
-#define DF_UP_MODES (DF_ONLY_MODES | TF_ONLY_MODES)
-
-/* Modes for quad-float only quantities. */
-#define TF_ONLY_MODES (1 << (int) TF_MODE)
-
-/* Modes for quad-float and smaller quantities. */
-#define TF_MODES (DF_MODES | TF_ONLY_MODES)
-
-#define TF_MODES64 (DF_MODES64 | TF_ONLY_MODES)
-
-/* Modes for condition codes. */
-#define CC_MODES (1 << (int) CC_MODE)
-#define CCFP_MODES (1 << (int) CCFP_MODE)
-
-/* Value is 1 if register/mode pair is acceptable on sparc.
- The funny mixture of D and T modes is because integer operations
- do not specially operate on tetra quantities, so non-quad-aligned
- registers can hold quadword quantities (except %o4 and %i4 because
- they cross fixed registers). */
-
-/* This points to either the 32 bit or the 64 bit version. */
-int *hard_regno_mode_classes;
-
-static int hard_32bit_mode_classes[] = {
- S_MODES, S_MODES, T_MODES, S_MODES, T_MODES, S_MODES, D_MODES, S_MODES,
- T_MODES, S_MODES, T_MODES, S_MODES, D_MODES, S_MODES, D_MODES, S_MODES,
- T_MODES, S_MODES, T_MODES, S_MODES, T_MODES, S_MODES, D_MODES, S_MODES,
- T_MODES, S_MODES, T_MODES, S_MODES, D_MODES, S_MODES, D_MODES, S_MODES,
-
- TF_MODES, SF_MODES, DF_MODES, SF_MODES, TF_MODES, SF_MODES, DF_MODES, SF_MODES,
- TF_MODES, SF_MODES, DF_MODES, SF_MODES, TF_MODES, SF_MODES, DF_MODES, SF_MODES,
- TF_MODES, SF_MODES, DF_MODES, SF_MODES, TF_MODES, SF_MODES, DF_MODES, SF_MODES,
- TF_MODES, SF_MODES, DF_MODES, SF_MODES, TF_MODES, SF_MODES, DF_MODES, SF_MODES,
-
- /* FP regs f32 to f63. Only the even numbered registers actually exist,
- and none can hold SFmode/SImode values. */
- DF_UP_MODES, 0, DF_ONLY_MODES, 0, DF_UP_MODES, 0, DF_ONLY_MODES, 0,
- DF_UP_MODES, 0, DF_ONLY_MODES, 0, DF_UP_MODES, 0, DF_ONLY_MODES, 0,
- DF_UP_MODES, 0, DF_ONLY_MODES, 0, DF_UP_MODES, 0, DF_ONLY_MODES, 0,
- DF_UP_MODES, 0, DF_ONLY_MODES, 0, DF_UP_MODES, 0, DF_ONLY_MODES, 0,
-
- /* %fcc[0123] */
- CCFP_MODES, CCFP_MODES, CCFP_MODES, CCFP_MODES,
-
- /* %icc */
- CC_MODES
-};
-
-static int hard_64bit_mode_classes[] = {
- D_MODES, D_MODES, T_MODES, D_MODES, T_MODES, D_MODES, T_MODES, D_MODES,
- T_MODES, D_MODES, T_MODES, D_MODES, T_MODES, D_MODES, T_MODES, D_MODES,
- T_MODES, D_MODES, T_MODES, D_MODES, T_MODES, D_MODES, T_MODES, D_MODES,
- T_MODES, D_MODES, T_MODES, D_MODES, T_MODES, D_MODES, T_MODES, D_MODES,
-
- TF_MODES64, SF_MODES, DF_MODES64, SF_MODES, TF_MODES64, SF_MODES, DF_MODES64, SF_MODES,
- TF_MODES64, SF_MODES, DF_MODES64, SF_MODES, TF_MODES64, SF_MODES, DF_MODES64, SF_MODES,
- TF_MODES64, SF_MODES, DF_MODES64, SF_MODES, TF_MODES64, SF_MODES, DF_MODES64, SF_MODES,
- TF_MODES64, SF_MODES, DF_MODES64, SF_MODES, TF_MODES64, SF_MODES, DF_MODES64, SF_MODES,
-
- /* FP regs f32 to f63. Only the even numbered registers actually exist,
- and none can hold SFmode/SImode values. */
- DF_UP_MODES, 0, DF_ONLY_MODES, 0, DF_UP_MODES, 0, DF_ONLY_MODES, 0,
- DF_UP_MODES, 0, DF_ONLY_MODES, 0, DF_UP_MODES, 0, DF_ONLY_MODES, 0,
- DF_UP_MODES, 0, DF_ONLY_MODES, 0, DF_UP_MODES, 0, DF_ONLY_MODES, 0,
- DF_UP_MODES, 0, DF_ONLY_MODES, 0, DF_UP_MODES, 0, DF_ONLY_MODES, 0,
-
- /* %fcc[0123] */
- CCFP_MODES, CCFP_MODES, CCFP_MODES, CCFP_MODES,
-
- /* %icc */
- CC_MODES
-};
-
-int sparc_mode_class [NUM_MACHINE_MODES];
-
-enum reg_class sparc_regno_reg_class[FIRST_PSEUDO_REGISTER];
-
-static void
-sparc_init_modes ()
-{
- int i;
-
- for (i = 0; i < NUM_MACHINE_MODES; i++)
- {
- switch (GET_MODE_CLASS (i))
- {
- case MODE_INT:
- case MODE_PARTIAL_INT:
- case MODE_COMPLEX_INT:
- if (GET_MODE_SIZE (i) <= 4)
- sparc_mode_class[i] = 1 << (int) S_MODE;
- else if (GET_MODE_SIZE (i) == 8)
- sparc_mode_class[i] = 1 << (int) D_MODE;
- else if (GET_MODE_SIZE (i) == 16)
- sparc_mode_class[i] = 1 << (int) T_MODE;
- else if (GET_MODE_SIZE (i) == 32)
- sparc_mode_class[i] = 1 << (int) O_MODE;
- else
- sparc_mode_class[i] = 0;
- break;
- case MODE_FLOAT:
- case MODE_COMPLEX_FLOAT:
- if (GET_MODE_SIZE (i) <= 4)
- sparc_mode_class[i] = 1 << (int) SF_MODE;
- else if (GET_MODE_SIZE (i) == 8)
- sparc_mode_class[i] = 1 << (int) DF_MODE;
- else if (GET_MODE_SIZE (i) == 16)
- sparc_mode_class[i] = 1 << (int) TF_MODE;
- else if (GET_MODE_SIZE (i) == 32)
- sparc_mode_class[i] = 1 << (int) OF_MODE;
- else
- sparc_mode_class[i] = 0;
- break;
- case MODE_CC:
- default:
- /* mode_class hasn't been initialized yet for EXTRA_CC_MODES, so
- we must explicitly check for them here. */
- if (i == (int) CCFPmode || i == (int) CCFPEmode)
- sparc_mode_class[i] = 1 << (int) CCFP_MODE;
- else if (i == (int) CCmode || i == (int) CC_NOOVmode
- || i == (int) CCXmode || i == (int) CCX_NOOVmode)
- sparc_mode_class[i] = 1 << (int) CC_MODE;
- else
- sparc_mode_class[i] = 0;
- break;
- }
- }
-
- if (TARGET_ARCH64)
- hard_regno_mode_classes = hard_64bit_mode_classes;
- else
- hard_regno_mode_classes = hard_32bit_mode_classes;
-
- /* Initialize the array used by REGNO_REG_CLASS. */
- for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
- {
- if (i < 16 && TARGET_V8PLUS)
- sparc_regno_reg_class[i] = I64_REGS;
- else if (i < 32)
- sparc_regno_reg_class[i] = GENERAL_REGS;
- else if (i < 64)
- sparc_regno_reg_class[i] = FP_REGS;
- else if (i < 96)
- sparc_regno_reg_class[i] = EXTRA_FP_REGS;
- else if (i < 100)
- sparc_regno_reg_class[i] = FPCC_REGS;
- else
- sparc_regno_reg_class[i] = NO_REGS;
- }
-}
-
-/* Save non call used registers from LOW to HIGH at BASE+OFFSET.
- N_REGS is the number of 4-byte regs saved thus far. This applies even to
- v9 int regs as it simplifies the code. */
-
-static int
-save_regs (file, low, high, base, offset, n_regs, real_offset)
- FILE *file;
- int low, high;
- const char *base;
- int offset;
- int n_regs;
- int real_offset;
-{
- int i;
-
- if (TARGET_ARCH64 && high <= 32)
- {
- for (i = low; i < high; i++)
- {
- if (regs_ever_live[i] && ! call_used_regs[i])
- {
- fprintf (file, "\tstx\t%s, [%s+%d]\n",
- reg_names[i], base, offset + 4 * n_regs);
- if (dwarf2out_do_frame ())
- dwarf2out_reg_save ("", i, real_offset + 4 * n_regs);
- n_regs += 2;
- }
- }
- }
- else
- {
- for (i = low; i < high; i += 2)
- {
- if (regs_ever_live[i] && ! call_used_regs[i])
- {
- if (regs_ever_live[i+1] && ! call_used_regs[i+1])
- {
- fprintf (file, "\tstd\t%s, [%s+%d]\n",
- reg_names[i], base, offset + 4 * n_regs);
- if (dwarf2out_do_frame ())
- {
- char *l = dwarf2out_cfi_label ();
- dwarf2out_reg_save (l, i, real_offset + 4 * n_regs);
- dwarf2out_reg_save (l, i+1, real_offset + 4 * n_regs + 4);
- }
- n_regs += 2;
- }
- else
- {
- fprintf (file, "\tst\t%s, [%s+%d]\n",
- reg_names[i], base, offset + 4 * n_regs);
- if (dwarf2out_do_frame ())
- dwarf2out_reg_save ("", i, real_offset + 4 * n_regs);
- n_regs += 2;
- }
- }
- else
- {
- if (regs_ever_live[i+1] && ! call_used_regs[i+1])
- {
- fprintf (file, "\tst\t%s, [%s+%d]\n",
- reg_names[i+1], base, offset + 4 * n_regs + 4);
- if (dwarf2out_do_frame ())
- dwarf2out_reg_save ("", i + 1, real_offset + 4 * n_regs + 4);
- n_regs += 2;
- }
- }
- }
- }
- return n_regs;
-}
-
-/* Restore non call used registers from LOW to HIGH at BASE+OFFSET.
-
- N_REGS is the number of 4-byte regs saved thus far. This applies even to
- v9 int regs as it simplifies the code. */
-
-static int
-restore_regs (file, low, high, base, offset, n_regs)
- FILE *file;
- int low, high;
- const char *base;
- int offset;
- int n_regs;
-{
- int i;
-
- if (TARGET_ARCH64 && high <= 32)
- {
- for (i = low; i < high; i++)
- {
- if (regs_ever_live[i] && ! call_used_regs[i])
- fprintf (file, "\tldx\t[%s+%d], %s\n",
- base, offset + 4 * n_regs, reg_names[i]),
- n_regs += 2;
- }
- }
- else
- {
- for (i = low; i < high; i += 2)
- {
- if (regs_ever_live[i] && ! call_used_regs[i])
- if (regs_ever_live[i+1] && ! call_used_regs[i+1])
- fprintf (file, "\tldd\t[%s+%d], %s\n",
- base, offset + 4 * n_regs, reg_names[i]),
- n_regs += 2;
- else
- fprintf (file, "\tld\t[%s+%d],%s\n",
- base, offset + 4 * n_regs, reg_names[i]),
- n_regs += 2;
- else if (regs_ever_live[i+1] && ! call_used_regs[i+1])
- fprintf (file, "\tld\t[%s+%d],%s\n",
- base, offset + 4 * n_regs + 4, reg_names[i+1]),
- n_regs += 2;
- }
- }
- return n_regs;
-}
-
-/* Static variables we want to share between prologue and epilogue. */
-
-/* Number of live general or floating point registers needed to be saved
- (as 4-byte quantities). This is only done if TARGET_EPILOGUE. */
-static int num_gfregs;
-
-/* Compute the frame size required by the function. This function is called
- during the reload pass and also by output_function_prologue(). */
-
-int
-compute_frame_size (size, leaf_function)
- int size;
- int leaf_function;
-{
- int n_regs = 0, i;
- int outgoing_args_size = (current_function_outgoing_args_size
- + REG_PARM_STACK_SPACE (current_function_decl));
-
- if (TARGET_EPILOGUE)
- {
- /* N_REGS is the number of 4-byte regs saved thus far. This applies
- even to v9 int regs to be consistent with save_regs/restore_regs. */
-
- if (TARGET_ARCH64)
- {
- for (i = 0; i < 8; i++)
- if (regs_ever_live[i] && ! call_used_regs[i])
- n_regs += 2;
- }
- else
- {
- for (i = 0; i < 8; i += 2)
- if ((regs_ever_live[i] && ! call_used_regs[i])
- || (regs_ever_live[i+1] && ! call_used_regs[i+1]))
- n_regs += 2;
- }
-
- for (i = 32; i < (TARGET_V9 ? 96 : 64); i += 2)
- if ((regs_ever_live[i] && ! call_used_regs[i])
- || (regs_ever_live[i+1] && ! call_used_regs[i+1]))
- n_regs += 2;
- }
-
- /* Set up values for use in `function_epilogue'. */
- num_gfregs = n_regs;
-
- if (leaf_function && n_regs == 0
- && size == 0 && current_function_outgoing_args_size == 0)
- {
- actual_fsize = apparent_fsize = 0;
- }
- else
- {
- /* We subtract STARTING_FRAME_OFFSET, remember it's negative.
- The stack bias (if any) is taken out to undo its effects. */
- apparent_fsize = (size - STARTING_FRAME_OFFSET + SPARC_STACK_BIAS + 7) & -8;
- apparent_fsize += n_regs * 4;
- actual_fsize = apparent_fsize + ((outgoing_args_size + 7) & -8);
- }
-
- /* Make sure nothing can clobber our register windows.
- If a SAVE must be done, or there is a stack-local variable,
- the register window area must be allocated.
- ??? For v8 we apparently need an additional 8 bytes of reserved space. */
- if (leaf_function == 0 || size > 0)
- actual_fsize += (16 * UNITS_PER_WORD) + (TARGET_ARCH64 ? 0 : 8);
-
- return SPARC_STACK_ALIGN (actual_fsize);
-}
-
-/* Build a (32 bit) big number in a register. */
-/* ??? We may be able to use the set macro here too. */
-
-static void
-build_big_number (file, num, reg)
- FILE *file;
- int num;
- const char *reg;
-{
- if (num >= 0 || ! TARGET_ARCH64)
- {
- fprintf (file, "\tsethi\t%%hi(%d), %s\n", num, reg);
- if ((num & 0x3ff) != 0)
- fprintf (file, "\tor\t%s, %%lo(%d), %s\n", reg, num, reg);
- }
- else /* num < 0 && TARGET_ARCH64 */
- {
- /* Sethi does not sign extend, so we must use a little trickery
- to use it for negative numbers. Invert the constant before
- loading it in, then use xor immediate to invert the loaded bits
- (along with the upper 32 bits) to the desired constant. This
- works because the sethi and immediate fields overlap. */
- int asize = num;
- int inv = ~asize;
- int low = -0x400 + (asize & 0x3FF);
-
- fprintf (file, "\tsethi\t%%hi(%d), %s\n\txor\t%s, %d, %s\n",
- inv, reg, reg, low, reg);
- }
-}
-
-/* Output code for the function prologue. */
-
-void
-output_function_prologue (file, size, leaf_function)
- FILE *file;
- int size;
- int leaf_function;
-{
- /* Need to use actual_fsize, since we are also allocating
- space for our callee (and our own register save area). */
- actual_fsize = compute_frame_size (size, leaf_function);
-
- if (leaf_function)
- {
- frame_base_name = "%sp";
- frame_base_offset = actual_fsize + SPARC_STACK_BIAS;
- }
- else
- {
- frame_base_name = "%fp";
- frame_base_offset = SPARC_STACK_BIAS;
- }
-
- /* This is only for the human reader. */
- fprintf (file, "\t%s#PROLOGUE# 0\n", ASM_COMMENT_START);
-
- if (actual_fsize == 0)
- /* do nothing. */ ;
- else if (! leaf_function && ! TARGET_BROKEN_SAVERESTORE)
- {
- if (actual_fsize <= 4096)
- fprintf (file, "\tsave\t%%sp, -%d, %%sp\n", actual_fsize);
- else if (actual_fsize <= 8192)
- {
- fprintf (file, "\tsave\t%%sp, -4096, %%sp\n");
- fprintf (file, "\tadd\t%%sp, -%d, %%sp\n", actual_fsize - 4096);
- }
- else
- {
- build_big_number (file, -actual_fsize, "%g1");
- fprintf (file, "\tsave\t%%sp, %%g1, %%sp\n");
- }
- }
- else if (! leaf_function && TARGET_BROKEN_SAVERESTORE)
- {
- /* We assume the environment will properly handle or otherwise avoid
- trouble associated with an interrupt occurring after the `save' or
- trap occurring during it. */
- fprintf (file, "\tsave\n");
-
- if (actual_fsize <= 4096)
- fprintf (file, "\tadd\t%%fp, -%d, %%sp\n", actual_fsize);
- else if (actual_fsize <= 8192)
- {
- fprintf (file, "\tadd\t%%fp, -4096, %%sp\n");
- fprintf (file, "\tadd\t%%fp, -%d, %%sp\n", actual_fsize - 4096);
- }
- else
- {
- build_big_number (file, -actual_fsize, "%g1");
- fprintf (file, "\tadd\t%%fp, %%g1, %%sp\n");
- }
- }
- else /* leaf function */
- {
- if (actual_fsize <= 4096)
- fprintf (file, "\tadd\t%%sp, -%d, %%sp\n", actual_fsize);
- else if (actual_fsize <= 8192)
- {
- fprintf (file, "\tadd\t%%sp, -4096, %%sp\n");
- fprintf (file, "\tadd\t%%sp, -%d, %%sp\n", actual_fsize - 4096);
- }
- else
- {
- build_big_number (file, -actual_fsize, "%g1");
- fprintf (file, "\tadd\t%%sp, %%g1, %%sp\n");
- }
- }
-
- if (dwarf2out_do_frame () && actual_fsize)
- {
- char *label = dwarf2out_cfi_label ();
-
- /* The canonical frame address refers to the top of the frame. */
- dwarf2out_def_cfa (label, (leaf_function ? STACK_POINTER_REGNUM
- : FRAME_POINTER_REGNUM),
- frame_base_offset);
-
- if (! leaf_function)
- {
- /* Note the register window save. This tells the unwinder that
- it needs to restore the window registers from the previous
- frame's window save area at 0(cfa). */
- dwarf2out_window_save (label);
-
- /* The return address (-8) is now in %i7. */
- dwarf2out_return_reg (label, 31);
- }
- }
-
- /* If doing anything with PIC, do it now. */
- if (! flag_pic)
- fprintf (file, "\t%s#PROLOGUE# 1\n", ASM_COMMENT_START);
-
- /* Call saved registers are saved just above the outgoing argument area. */
- if (num_gfregs)
- {
- int offset, real_offset, n_regs;
- const char *base;
-
- real_offset = -apparent_fsize;
- offset = -apparent_fsize + frame_base_offset;
- if (offset < -4096 || offset + num_gfregs * 4 > 4096)
- {
- /* ??? This might be optimized a little as %g1 might already have a
- value close enough that a single add insn will do. */
- /* ??? Although, all of this is probably only a temporary fix
- because if %g1 can hold a function result, then
- output_function_epilogue will lose (the result will get
- clobbered). */
- build_big_number (file, offset, "%g1");
- fprintf (file, "\tadd\t%s, %%g1, %%g1\n", frame_base_name);
- base = "%g1";
- offset = 0;
- }
- else
- {
- base = frame_base_name;
- }
-
- n_regs = 0;
- if (TARGET_EPILOGUE && ! leaf_function)
- /* ??? Originally saved regs 0-15 here. */
- n_regs = save_regs (file, 0, 8, base, offset, 0, real_offset);
- else if (leaf_function)
- /* ??? Originally saved regs 0-31 here. */
- n_regs = save_regs (file, 0, 8, base, offset, 0, real_offset);
- if (TARGET_EPILOGUE)
- save_regs (file, 32, TARGET_V9 ? 96 : 64, base, offset, n_regs,
- real_offset);
- }
-
- leaf_label = 0;
- if (leaf_function && actual_fsize != 0)
- {
- /* warning ("leaf procedure with frame size %d", actual_fsize); */
- if (! TARGET_EPILOGUE)
- leaf_label = gen_label_rtx ();
- }
-}
-
-/* Output code for the function epilogue. */
-
-void
-output_function_epilogue (file, size, leaf_function)
- FILE *file;
- int size ATTRIBUTE_UNUSED;
- int leaf_function;
-{
- const char *ret;
-
- if (leaf_label)
- {
- emit_label_after (leaf_label, get_last_insn ());
- final_scan_insn (get_last_insn (), file, 0, 0, 1);
- }
-
-#ifdef FUNCTION_BLOCK_PROFILER_EXIT
- else if (profile_block_flag == 2)
- {
- FUNCTION_BLOCK_PROFILER_EXIT(file);
- }
-#endif
-
- else if (current_function_epilogue_delay_list == 0)
- {
- /* If code does not drop into the epilogue, we need
- do nothing except output pending case vectors. */
- rtx insn = get_last_insn ();
- if (GET_CODE (insn) == NOTE)
- insn = prev_nonnote_insn (insn);
- if (insn && GET_CODE (insn) == BARRIER)
- goto output_vectors;
- }
-
- /* Restore any call saved registers. */
- if (num_gfregs)
- {
- int offset, n_regs;
- const char *base;
-
- offset = -apparent_fsize + frame_base_offset;
- if (offset < -4096 || offset + num_gfregs * 4 > 4096 - 8 /*double*/)
- {
- build_big_number (file, offset, "%g1");
- fprintf (file, "\tadd\t%s, %%g1, %%g1\n", frame_base_name);
- base = "%g1";
- offset = 0;
- }
- else
- {
- base = frame_base_name;
- }
-
- n_regs = 0;
- if (TARGET_EPILOGUE && ! leaf_function)
- /* ??? Originally saved regs 0-15 here. */
- n_regs = restore_regs (file, 0, 8, base, offset, 0);
- else if (leaf_function)
- /* ??? Originally saved regs 0-31 here. */
- n_regs = restore_regs (file, 0, 8, base, offset, 0);
- if (TARGET_EPILOGUE)
- restore_regs (file, 32, TARGET_V9 ? 96 : 64, base, offset, n_regs);
- }
-
- /* Work out how to skip the caller's unimp instruction if required. */
- if (leaf_function)
- ret = (SKIP_CALLERS_UNIMP_P ? "jmp\t%o7+12" : "retl");
- else
- ret = (SKIP_CALLERS_UNIMP_P ? "jmp\t%i7+12" : "ret");
-
- if (TARGET_EPILOGUE || leaf_label)
- {
- int old_target_epilogue = TARGET_EPILOGUE;
- target_flags &= ~old_target_epilogue;
-
- if (! leaf_function)
- {
- /* If we wound up with things in our delay slot, flush them here. */
- if (current_function_epilogue_delay_list)
- {
- rtx insn = emit_jump_insn_after (gen_rtx_RETURN (VOIDmode),
- get_last_insn ());
- PATTERN (insn) = gen_rtx_PARALLEL (VOIDmode,
- gen_rtvec (2,
- PATTERN (XEXP (current_function_epilogue_delay_list, 0)),
- PATTERN (insn)));
- final_scan_insn (insn, file, 1, 0, 1);
- }
- else if (TARGET_V9 && ! SKIP_CALLERS_UNIMP_P)
- fputs ("\treturn\t%i7+8\n\tnop\n", file);
- else
- fprintf (file, "\t%s\n\trestore\n", ret);
- }
- /* All of the following cases are for leaf functions. */
- else if (current_function_epilogue_delay_list)
- {
- /* eligible_for_epilogue_delay_slot ensures that if this is a
- leaf function, then we will only have insn in the delay slot
- if the frame size is zero, thus no adjust for the stack is
- needed here. */
- if (actual_fsize != 0)
- abort ();
- fprintf (file, "\t%s\n", ret);
- final_scan_insn (XEXP (current_function_epilogue_delay_list, 0),
- file, 1, 0, 1);
- }
- /* Output 'nop' instead of 'sub %sp,-0,%sp' when no frame, so as to
- avoid generating confusing assembly language output. */
- else if (actual_fsize == 0)
- fprintf (file, "\t%s\n\tnop\n", ret);
- else if (actual_fsize <= 4096)
- fprintf (file, "\t%s\n\tsub\t%%sp, -%d, %%sp\n", ret, actual_fsize);
- else if (actual_fsize <= 8192)
- fprintf (file, "\tsub\t%%sp, -4096, %%sp\n\t%s\n\tsub\t%%sp, -%d, %%sp\n",
- ret, actual_fsize - 4096);
- else if ((actual_fsize & 0x3ff) == 0)
- fprintf (file, "\tsethi\t%%hi(%d), %%g1\n\t%s\n\tadd\t%%sp, %%g1, %%sp\n",
- actual_fsize, ret);
- else
- fprintf (file, "\tsethi\t%%hi(%d), %%g1\n\tor\t%%g1, %%lo(%d), %%g1\n\t%s\n\tadd\t%%sp, %%g1, %%sp\n",
- actual_fsize, actual_fsize, ret);
- target_flags |= old_target_epilogue;
- }
-
- output_vectors:
- sparc_output_deferred_case_vectors ();
-}
-
-/* Functions for handling argument passing.
-
- For v8 the first six args are normally in registers and the rest are
- pushed. Any arg that starts within the first 6 words is at least
- partially passed in a register unless its data type forbids.
-
- For v9, the argument registers are laid out as an array of 16 elements
- and arguments are added sequentially. The first 6 int args and up to the
- first 16 fp args (depending on size) are passed in regs.
-
- Slot Stack Integral Float Float in structure Double Long Double
- ---- ----- -------- ----- ------------------ ------ -----------
- 15 [SP+248] %f31 %f30,%f31 %d30
- 14 [SP+240] %f29 %f28,%f29 %d28 %q28
- 13 [SP+232] %f27 %f26,%f27 %d26
- 12 [SP+224] %f25 %f24,%f25 %d24 %q24
- 11 [SP+216] %f23 %f22,%f23 %d22
- 10 [SP+208] %f21 %f20,%f21 %d20 %q20
- 9 [SP+200] %f19 %f18,%f19 %d18
- 8 [SP+192] %f17 %f16,%f17 %d16 %q16
- 7 [SP+184] %f15 %f14,%f15 %d14
- 6 [SP+176] %f13 %f12,%f13 %d12 %q12
- 5 [SP+168] %o5 %f11 %f10,%f11 %d10
- 4 [SP+160] %o4 %f9 %f8,%f9 %d8 %q8
- 3 [SP+152] %o3 %f7 %f6,%f7 %d6
- 2 [SP+144] %o2 %f5 %f4,%f5 %d4 %q4
- 1 [SP+136] %o1 %f3 %f2,%f3 %d2
- 0 [SP+128] %o0 %f1 %f0,%f1 %d0 %q0
-
- Here SP = %sp if -mno-stack-bias or %sp+stack_bias otherwise.
-
- Integral arguments are always passed as 64 bit quantities appropriately
- extended.
-
- Passing of floating point values is handled as follows.
- If a prototype is in scope:
- If the value is in a named argument (i.e. not a stdarg function or a
- value not part of the `...') then the value is passed in the appropriate
- fp reg.
- If the value is part of the `...' and is passed in one of the first 6
- slots then the value is passed in the appropriate int reg.
- If the value is part of the `...' and is not passed in one of the first 6
- slots then the value is passed in memory.
- If a prototype is not in scope:
- If the value is one of the first 6 arguments the value is passed in the
- appropriate integer reg and the appropriate fp reg.
- If the value is not one of the first 6 arguments the value is passed in
- the appropriate fp reg and in memory.
- */
-
-/* Maximum number of int regs for args. */
-#define SPARC_INT_ARG_MAX 6
-/* Maximum number of fp regs for args. */
-#define SPARC_FP_ARG_MAX 16
-
-#define ROUND_ADVANCE(SIZE) (((SIZE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
-
-/* Handle the INIT_CUMULATIVE_ARGS macro.
- Initialize a variable CUM of type CUMULATIVE_ARGS
- for a call to a function whose data type is FNTYPE.
- For a library call, FNTYPE is 0. */
-
-void
-init_cumulative_args (cum, fntype, libname, indirect)
- CUMULATIVE_ARGS *cum;
- tree fntype;
- tree libname ATTRIBUTE_UNUSED;
- int indirect ATTRIBUTE_UNUSED;
-{
- cum->words = 0;
- cum->prototype_p = fntype && TYPE_ARG_TYPES (fntype);
- cum->libcall_p = fntype == 0;
-}
-
-/* Compute the slot number to pass an argument in.
- Returns the slot number or -1 if passing on the stack.
-
- CUM is a variable of type CUMULATIVE_ARGS which gives info about
- the preceding args and about the function being called.
- MODE is the argument's machine mode.
- TYPE is the data type of the argument (as a tree).
- This is null for libcalls where that information may
- not be available.
- NAMED is nonzero if this argument is a named parameter
- (otherwise it is an extra parameter matching an ellipsis).
- INCOMING_P is zero for FUNCTION_ARG, nonzero for FUNCTION_INCOMING_ARG.
- *PREGNO records the register number to use if scalar type.
- *PPADDING records the amount of padding needed in words. */
-
-static int
-function_arg_slotno (cum, mode, type, named, incoming_p, pregno, ppadding)
- const CUMULATIVE_ARGS *cum;
- enum machine_mode mode;
- tree type;
- int named;
- int incoming_p;
- int *pregno;
- int *ppadding;
-{
- int regbase = (incoming_p
- ? SPARC_INCOMING_INT_ARG_FIRST
- : SPARC_OUTGOING_INT_ARG_FIRST);
- int slotno = cum->words;
- int regno;
-
- *ppadding = 0;
-
- if (type != 0 && TREE_ADDRESSABLE (type))
- return -1;
- if (TARGET_ARCH32
- && type != 0 && mode == BLKmode
- && TYPE_ALIGN (type) % PARM_BOUNDARY != 0)
- return -1;
-
- switch (mode)
- {
- case VOIDmode :
- /* MODE is VOIDmode when generating the actual call.
- See emit_call_1. */
- return -1;
-
- case QImode : case CQImode :
- case HImode : case CHImode :
- case SImode : case CSImode :
- case DImode : case CDImode :
- if (slotno >= SPARC_INT_ARG_MAX)
- return -1;
- regno = regbase + slotno;
- break;
-
- case SFmode : case SCmode :
- case DFmode : case DCmode :
- case TFmode : case TCmode :
- if (TARGET_ARCH32)
- {
- if (slotno >= SPARC_INT_ARG_MAX)
- return -1;
- regno = regbase + slotno;
- }
- else
- {
- if ((mode == TFmode || mode == TCmode)
- && (slotno & 1) != 0)
- slotno++, *ppadding = 1;
- if (TARGET_FPU && named)
- {
- if (slotno >= SPARC_FP_ARG_MAX)
- return -1;
- regno = SPARC_FP_ARG_FIRST + slotno * 2;
- if (mode == SFmode)
- regno++;
- }
- else
- {
- if (slotno >= SPARC_INT_ARG_MAX)
- return -1;
- regno = regbase + slotno;
- }
- }
- break;
-
- case BLKmode :
- /* For sparc64, objects requiring 16 byte alignment get it. */
- if (TARGET_ARCH64)
- {
- if (type && TYPE_ALIGN (type) == 128 && (slotno & 1) != 0)
- slotno++, *ppadding = 1;
- }
-
- if (TARGET_ARCH32
- || (type && TREE_CODE (type) == UNION_TYPE))
- {
- if (slotno >= SPARC_INT_ARG_MAX)
- return -1;
- regno = regbase + slotno;
- }
- else
- {
- tree field;
- int intregs_p = 0, fpregs_p = 0;
- /* The ABI obviously doesn't specify how packed
- structures are passed. These are defined to be passed
- in int regs if possible, otherwise memory. */
- int packed_p = 0;
-
- /* First see what kinds of registers we need. */
- for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
- {
- if (TREE_CODE (field) == FIELD_DECL)
- {
- if (TREE_CODE (TREE_TYPE (field)) == REAL_TYPE
- && TARGET_FPU)
- fpregs_p = 1;
- else
- intregs_p = 1;
- if (DECL_PACKED (field))
- packed_p = 1;
- }
- }
- if (packed_p || !named)
- fpregs_p = 0, intregs_p = 1;
-
- /* If all arg slots are filled, then must pass on stack. */
- if (fpregs_p && slotno >= SPARC_FP_ARG_MAX)
- return -1;
- /* If there are only int args and all int arg slots are filled,
- then must pass on stack. */
- if (!fpregs_p && intregs_p && slotno >= SPARC_INT_ARG_MAX)
- return -1;
- /* Note that even if all int arg slots are filled, fp members may
- still be passed in regs if such regs are available.
- *PREGNO isn't set because there may be more than one, it's up
- to the caller to compute them. */
- return slotno;
- }
- break;
-
- default :
- abort ();
- }
-
- *pregno = regno;
- return slotno;
-}
-
-/* Handle recursive register counting for structure field layout. */
-
-struct function_arg_record_value_parms
-{
- rtx ret;
- int slotno, named, regbase;
- int nregs, intoffset;
-};
-
-static void function_arg_record_value_3
- PROTO((int, struct function_arg_record_value_parms *));
-static void function_arg_record_value_2
- PROTO((tree, int, struct function_arg_record_value_parms *));
-static rtx function_arg_record_value
- PROTO((tree, enum machine_mode, int, int, int));
-
-static void
-function_arg_record_value_1 (type, startbitpos, parms)
- tree type;
- int startbitpos;
- struct function_arg_record_value_parms *parms;
-{
- tree field;
-
- /* The ABI obviously doesn't specify how packed structures are
- passed. These are defined to be passed in int regs if possible,
- otherwise memory. */
- int packed_p = 0;
-
- /* We need to compute how many registers are needed so we can
- allocate the PARALLEL but before we can do that we need to know
- whether there are any packed fields. If there are, int regs are
- used regardless of whether there are fp values present. */
- for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
- {
- if (TREE_CODE (field) == FIELD_DECL && DECL_PACKED (field))
- {
- packed_p = 1;
- break;
- }
- }
-
- /* Compute how many registers we need. */
- for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
- {
- if (TREE_CODE (field) == FIELD_DECL)
- {
- int bitpos = startbitpos;
- if (DECL_FIELD_BITPOS (field))
- bitpos += TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field));
- /* ??? FIXME: else assume zero offset. */
-
- if (TREE_CODE (TREE_TYPE (field)) == RECORD_TYPE)
- {
- function_arg_record_value_1 (TREE_TYPE (field), bitpos, parms);
- }
- else if (TREE_CODE (TREE_TYPE (field)) == REAL_TYPE
- && TARGET_FPU
- && ! packed_p
- && parms->named)
- {
- if (parms->intoffset != -1)
- {
- int intslots, this_slotno;
-
- intslots = (bitpos - parms->intoffset + BITS_PER_WORD - 1)
- / BITS_PER_WORD;
- this_slotno = parms->slotno + parms->intoffset
- / BITS_PER_WORD;
-
- intslots = MIN (intslots, SPARC_INT_ARG_MAX - this_slotno);
- intslots = MAX (intslots, 0);
- parms->nregs += intslots;
- parms->intoffset = -1;
- }
-
- /* There's no need to check this_slotno < SPARC_FP_ARG MAX.
- If it wasn't true we wouldn't be here. */
- parms->nregs += 1;
- }
- else
- {
- if (parms->intoffset == -1)
- parms->intoffset = bitpos;
- }
- }
- }
-}
-
-/* Handle recursive structure field register assignment. */
-
-static void
-function_arg_record_value_3 (bitpos, parms)
- int bitpos;
- struct function_arg_record_value_parms *parms;
-{
- enum machine_mode mode;
- int regno, this_slotno, intslots, intoffset;
- rtx reg;
-
- if (parms->intoffset == -1)
- return;
- intoffset = parms->intoffset;
- parms->intoffset = -1;
-
- intslots = (bitpos - intoffset + BITS_PER_WORD - 1) / BITS_PER_WORD;
- this_slotno = parms->slotno + intoffset / BITS_PER_WORD;
-
- intslots = MIN (intslots, SPARC_INT_ARG_MAX - this_slotno);
- if (intslots <= 0)
- return;
-
- /* If this is the trailing part of a word, only load that much into
- the register. Otherwise load the whole register. Note that in
- the latter case we may pick up unwanted bits. It's not a problem
- at the moment but may wish to revisit. */
-
- if (intoffset % BITS_PER_WORD != 0)
- {
- mode = mode_for_size (BITS_PER_WORD - intoffset%BITS_PER_WORD,
- MODE_INT, 0);
- }
- else
- mode = word_mode;
-
- intoffset /= BITS_PER_UNIT;
- do
- {
- regno = parms->regbase + this_slotno;
- reg = gen_rtx_REG (mode, regno);
- XVECEXP (parms->ret, 0, parms->nregs)
- = gen_rtx_EXPR_LIST (VOIDmode, reg, GEN_INT (intoffset));
-
- this_slotno += 1;
- intoffset = (intoffset | (UNITS_PER_WORD-1)) + 1;
- parms->nregs += 1;
- intslots -= 1;
- }
- while (intslots > 0);
-}
-
-static void
-function_arg_record_value_2 (type, startbitpos, parms)
- tree type;
- int startbitpos;
- struct function_arg_record_value_parms *parms;
-{
- tree field;
- int packed_p = 0;
-
- for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
- {
- if (TREE_CODE (field) == FIELD_DECL && DECL_PACKED (field))
- {
- packed_p = 1;
- break;
- }
- }
-
- for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
- {
- if (TREE_CODE (field) == FIELD_DECL)
- {
- int bitpos = startbitpos;
- if (DECL_FIELD_BITPOS (field))
- bitpos += TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field));
- /* ??? FIXME: else assume zero offset. */
-
- if (TREE_CODE (TREE_TYPE (field)) == RECORD_TYPE)
- {
- function_arg_record_value_2 (TREE_TYPE (field), bitpos, parms);
- }
- else if (TREE_CODE (TREE_TYPE (field)) == REAL_TYPE
- && TARGET_FPU
- && ! packed_p
- && parms->named)
- {
- int this_slotno = parms->slotno + bitpos / BITS_PER_WORD;
- rtx reg;
-
- function_arg_record_value_3 (bitpos, parms);
-
- reg = gen_rtx_REG (DECL_MODE (field),
- (SPARC_FP_ARG_FIRST + this_slotno * 2
- + (DECL_MODE (field) == SFmode
- && (bitpos & 32) != 0)));
- XVECEXP (parms->ret, 0, parms->nregs)
- = gen_rtx_EXPR_LIST (VOIDmode, reg,
- GEN_INT (bitpos / BITS_PER_UNIT));
- parms->nregs += 1;
- }
- else
- {
- if (parms->intoffset == -1)
- parms->intoffset = bitpos;
- }
- }
- }
-}
-
-static rtx
-function_arg_record_value (type, mode, slotno, named, regbase)
- tree type;
- enum machine_mode mode;
- int slotno, named, regbase;
-{
- HOST_WIDE_INT typesize = int_size_in_bytes (type);
- struct function_arg_record_value_parms parms;
- int nregs;
-
- parms.ret = NULL_RTX;
- parms.slotno = slotno;
- parms.named = named;
- parms.regbase = regbase;
-
- /* Compute how many registers we need. */
- parms.nregs = 0;
- parms.intoffset = 0;
- function_arg_record_value_1 (type, 0, &parms);
-
- if (parms.intoffset != -1)
- {
- int intslots, this_slotno;
-
- intslots = (typesize*BITS_PER_UNIT - parms.intoffset + BITS_PER_WORD - 1)
- / BITS_PER_WORD;
- this_slotno = slotno + parms.intoffset / BITS_PER_WORD;
-
- intslots = MIN (intslots, SPARC_INT_ARG_MAX - this_slotno);
- intslots = MAX (intslots, 0);
-
- parms.nregs += intslots;
- }
- nregs = parms.nregs;
-
- /* Allocate the vector and handle some annoying special cases. */
- if (nregs == 0)
- {
- /* ??? Empty structure has no value? Duh? */
- if (typesize <= 0)
- {
- /* Though there's nothing really to store, return a word register
- anyway so the rest of gcc doesn't go nuts. Returning a PARALLEL
- leads to breakage due to the fact that there are zero bytes to
- load. */
- return gen_rtx_REG (mode, regbase);
- }
- else
- {
- /* ??? C++ has structures with no fields, and yet a size. Give up
- for now and pass everything back in integer registers. */
- nregs = (typesize + UNITS_PER_WORD - 1) / UNITS_PER_WORD;
- }
- if (nregs + slotno > SPARC_INT_ARG_MAX)
- nregs = SPARC_INT_ARG_MAX - slotno;
- }
- if (nregs == 0)
- abort ();
-
- parms.ret = gen_rtx_PARALLEL (mode, rtvec_alloc (nregs));
-
- /* Fill in the entries. */
- parms.nregs = 0;
- parms.intoffset = 0;
- function_arg_record_value_2 (type, 0, &parms);
- function_arg_record_value_3 (typesize * BITS_PER_UNIT, &parms);
-
- if (parms.nregs != nregs)
- abort ();
-
- return parms.ret;
-}
-
-/* Handle the FUNCTION_ARG macro.
- Determine where to put an argument to a function.
- Value is zero to push the argument on the stack,
- or a hard register in which to store the argument.
-
- CUM is a variable of type CUMULATIVE_ARGS which gives info about
- the preceding args and about the function being called.
- MODE is the argument's machine mode.
- TYPE is the data type of the argument (as a tree).
- This is null for libcalls where that information may
- not be available.
- NAMED is nonzero if this argument is a named parameter
- (otherwise it is an extra parameter matching an ellipsis).
- INCOMING_P is zero for FUNCTION_ARG, nonzero for FUNCTION_INCOMING_ARG. */
-
-rtx
-function_arg (cum, mode, type, named, incoming_p)
- const CUMULATIVE_ARGS *cum;
- enum machine_mode mode;
- tree type;
- int named;
- int incoming_p;
-{
- int regbase = (incoming_p
- ? SPARC_INCOMING_INT_ARG_FIRST
- : SPARC_OUTGOING_INT_ARG_FIRST);
- int slotno, regno, padding;
- rtx reg;
-
- slotno = function_arg_slotno (cum, mode, type, named, incoming_p,
- &regno, &padding);
-
- if (slotno == -1)
- return 0;
-
- if (TARGET_ARCH32)
- {
- reg = gen_rtx_REG (mode, regno);
- return reg;
- }
-
- /* v9 fp args in reg slots beyond the int reg slots get passed in regs
- but also have the slot allocated for them.
- If no prototype is in scope fp values in register slots get passed
- in two places, either fp regs and int regs or fp regs and memory. */
- if ((GET_MODE_CLASS (mode) == MODE_FLOAT
- || GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT)
- && SPARC_FP_REG_P (regno))
- {
- reg = gen_rtx_REG (mode, regno);
- if (cum->prototype_p || cum->libcall_p)
- {
- /* "* 2" because fp reg numbers are recorded in 4 byte
- quantities. */
-#if 0
- /* ??? This will cause the value to be passed in the fp reg and
- in the stack. When a prototype exists we want to pass the
- value in the reg but reserve space on the stack. That's an
- optimization, and is deferred [for a bit]. */
- if ((regno - SPARC_FP_ARG_FIRST) >= SPARC_INT_ARG_MAX * 2)
- return gen_rtx_PARALLEL (mode,
- gen_rtvec (2,
- gen_rtx_EXPR_LIST (VOIDmode,
- NULL_RTX, const0_rtx),
- gen_rtx_EXPR_LIST (VOIDmode,
- reg, const0_rtx)));
- else
-#else
- /* ??? It seems that passing back a register even when past
- the area declared by REG_PARM_STACK_SPACE will allocate
- space appropriately, and will not copy the data onto the
- stack, exactly as we desire.
-
- This is due to locate_and_pad_parm being called in
- expand_call whenever reg_parm_stack_space > 0, which
- while benefical to our example here, would seem to be
- in error from what had been intended. Ho hum... -- r~ */
-#endif
- return reg;
- }
- else
- {
- rtx v0, v1;
-
- if ((regno - SPARC_FP_ARG_FIRST) < SPARC_INT_ARG_MAX * 2)
- {
- int intreg;
-
- /* On incoming, we don't need to know that the value
- is passed in %f0 and %i0, and it confuses other parts
- causing needless spillage even on the simplest cases. */
- if (incoming_p)
- return reg;
-
- intreg = (SPARC_OUTGOING_INT_ARG_FIRST
- + (regno - SPARC_FP_ARG_FIRST) / 2);
-
- v0 = gen_rtx_EXPR_LIST (VOIDmode, reg, const0_rtx);
- v1 = gen_rtx_EXPR_LIST (VOIDmode, gen_rtx_REG (mode, intreg),
- const0_rtx);
- return gen_rtx_PARALLEL (mode, gen_rtvec (2, v0, v1));
- }
- else
- {
- v0 = gen_rtx_EXPR_LIST (VOIDmode, NULL_RTX, const0_rtx);
- v1 = gen_rtx_EXPR_LIST (VOIDmode, reg, const0_rtx);
- return gen_rtx_PARALLEL (mode, gen_rtvec (2, v0, v1));
- }
- }
- }
- else if (type && TREE_CODE (type) == RECORD_TYPE)
- {
- /* Structures up to 16 bytes in size are passed in arg slots on the
- stack and are promoted to registers where possible. */
-
- if (int_size_in_bytes (type) > 16)
- abort (); /* shouldn't get here */
-
- return function_arg_record_value (type, mode, slotno, named, regbase);
- }
- else if (type && TREE_CODE (type) == UNION_TYPE)
- {
- enum machine_mode mode;
- int bytes = int_size_in_bytes (type);
-
- if (bytes > 16)
- abort ();
-
- mode = mode_for_size (bytes * BITS_PER_UNIT, MODE_INT, 0);
- reg = gen_rtx_REG (mode, regno);
- }
- else
- {
- /* Scalar or complex int. */
- reg = gen_rtx_REG (mode, regno);
- }
-
- return reg;
-}
-
-/* Handle the FUNCTION_ARG_PARTIAL_NREGS macro.
- For an arg passed partly in registers and partly in memory,
- this is the number of registers used.
- For args passed entirely in registers or entirely in memory, zero.
-
- Any arg that starts in the first 6 regs but won't entirely fit in them
- needs partial registers on v8. On v9, structures with integer
- values in arg slots 5,6 will be passed in %o5 and SP+176, and complex fp
- values that begin in the last fp reg [where "last fp reg" varies with the
- mode] will be split between that reg and memory. */
-
-int
-function_arg_partial_nregs (cum, mode, type, named)
- const CUMULATIVE_ARGS *cum;
- enum machine_mode mode;
- tree type;
- int named;
-{
- int slotno, regno, padding;
-
- /* We pass 0 for incoming_p here, it doesn't matter. */
- slotno = function_arg_slotno (cum, mode, type, named, 0, &regno, &padding);
-
- if (slotno == -1)
- return 0;
-
- if (TARGET_ARCH32)
- {
- if ((slotno + (mode == BLKmode
- ? ROUND_ADVANCE (int_size_in_bytes (type))
- : ROUND_ADVANCE (GET_MODE_SIZE (mode))))
- > NPARM_REGS (SImode))
- return NPARM_REGS (SImode) - slotno;
- return 0;
- }
- else
- {
- if (type && AGGREGATE_TYPE_P (type))
- {
- int size = int_size_in_bytes (type);
- int align = TYPE_ALIGN (type);
-
- if (align == 16)
- slotno += slotno & 1;
- if (size > 8 && size <= 16
- && slotno == SPARC_INT_ARG_MAX - 1)
- return 1;
- }
- else if (GET_MODE_CLASS (mode) == MODE_COMPLEX_INT
- || (GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT
- && ! TARGET_FPU))
- {
- if (GET_MODE_ALIGNMENT (mode) == 128)
- {
- slotno += slotno & 1;
- if (slotno == SPARC_INT_ARG_MAX - 2)
- return 1;
- }
- else
- {
- if (slotno == SPARC_INT_ARG_MAX - 1)
- return 1;
- }
- }
- else if (GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT)
- {
- if (GET_MODE_ALIGNMENT (mode) == 128)
- slotno += slotno & 1;
- if ((slotno + GET_MODE_SIZE (mode) / UNITS_PER_WORD)
- > SPARC_FP_ARG_MAX)
- return 1;
- }
- return 0;
- }
-}
-
-/* Handle the FUNCTION_ARG_PASS_BY_REFERENCE macro.
- !v9: The SPARC ABI stipulates passing struct arguments (of any size) and
- quad-precision floats by invisible reference.
- v9: Aggregates greater than 16 bytes are passed by reference.
- For Pascal, also pass arrays by reference. */
-
-int
-function_arg_pass_by_reference (cum, mode, type, named)
- const CUMULATIVE_ARGS *cum ATTRIBUTE_UNUSED;
- enum machine_mode mode;
- tree type;
- int named ATTRIBUTE_UNUSED;
-{
- if (TARGET_ARCH32)
- {
- return ((type && AGGREGATE_TYPE_P (type))
- || mode == TFmode || mode == TCmode);
- }
- else
- {
- return ((type && TREE_CODE (type) == ARRAY_TYPE)
- /* Consider complex values as aggregates, so care for TCmode. */
- || GET_MODE_SIZE (mode) > 16
- || (type && AGGREGATE_TYPE_P (type)
- && int_size_in_bytes (type) > 16));
- }
-}
-
-/* Handle the FUNCTION_ARG_ADVANCE macro.
- Update the data in CUM to advance over an argument
- of mode MODE and data type TYPE.
- TYPE is null for libcalls where that information may not be available. */
-
-void
-function_arg_advance (cum, mode, type, named)
- CUMULATIVE_ARGS *cum;
- enum machine_mode mode;
- tree type;
- int named;
-{
- int slotno, regno, padding;
-
- /* We pass 0 for incoming_p here, it doesn't matter. */
- slotno = function_arg_slotno (cum, mode, type, named, 0, &regno, &padding);
-
- /* If register required leading padding, add it. */
- if (slotno != -1)
- cum->words += padding;
-
- if (TARGET_ARCH32)
- {
- cum->words += (mode != BLKmode
- ? ROUND_ADVANCE (GET_MODE_SIZE (mode))
- : ROUND_ADVANCE (int_size_in_bytes (type)));
- }
- else
- {
- if (type && AGGREGATE_TYPE_P (type))
- {
- int size = int_size_in_bytes (type);
-
- if (size <= 8)
- ++cum->words;
- else if (size <= 16)
- cum->words += 2;
- else /* passed by reference */
- ++cum->words;
- }
- else if (GET_MODE_CLASS (mode) == MODE_COMPLEX_INT)
- {
- cum->words += 2;
- }
- else if (GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT)
- {
- cum->words += GET_MODE_SIZE (mode) / UNITS_PER_WORD;
- }
- else
- {
- cum->words += (mode != BLKmode
- ? ROUND_ADVANCE (GET_MODE_SIZE (mode))
- : ROUND_ADVANCE (int_size_in_bytes (type)));
- }
- }
-}
-
-/* Handle the FUNCTION_ARG_PADDING macro.
- For the 64 bit ABI structs are always stored left shifted in their
- argument slot. */
-
-enum direction
-function_arg_padding (mode, type)
- enum machine_mode mode;
- tree type;
-{
- if (TARGET_ARCH64 && type != 0 && AGGREGATE_TYPE_P (type))
- return upward;
-
- /* This is the default definition. */
- return (! BYTES_BIG_ENDIAN
- ? upward
- : ((mode == BLKmode
- ? (type && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST
- && int_size_in_bytes (type) < (PARM_BOUNDARY / BITS_PER_UNIT))
- : GET_MODE_BITSIZE (mode) < PARM_BOUNDARY)
- ? downward : upward));
-}
-
-/* Handle FUNCTION_VALUE, FUNCTION_OUTGOING_VALUE, and LIBCALL_VALUE macros.
- For v9, function return values are subject to the same rules as arguments,
- except that up to 32-bytes may be returned in registers. */
-
-rtx
-function_value (type, mode, incoming_p)
- tree type;
- enum machine_mode mode;
- int incoming_p;
-{
- int regno;
- int regbase = (incoming_p
- ? SPARC_OUTGOING_INT_ARG_FIRST
- : SPARC_INCOMING_INT_ARG_FIRST);
-
- if (TARGET_ARCH64 && type)
- {
- if (TREE_CODE (type) == RECORD_TYPE)
- {
- /* Structures up to 32 bytes in size are passed in registers,
- promoted to fp registers where possible. */
-
- if (int_size_in_bytes (type) > 32)
- abort (); /* shouldn't get here */
-
- return function_arg_record_value (type, mode, 0, 1, regbase);
- }
- else if (TREE_CODE (type) == UNION_TYPE)
- {
- int bytes = int_size_in_bytes (type);
-
- if (bytes > 32)
- abort ();
-
- mode = mode_for_size (bytes * BITS_PER_UNIT, MODE_INT, 0);
- }
- }
-
- if (TARGET_ARCH64
- && GET_MODE_CLASS (mode) == MODE_INT
- && GET_MODE_SIZE (mode) < UNITS_PER_WORD
- && type && TREE_CODE (type) != UNION_TYPE)
- mode = DImode;
-
- if (incoming_p)
- regno = BASE_RETURN_VALUE_REG (mode);
- else
- regno = BASE_OUTGOING_VALUE_REG (mode);
-
- return gen_rtx_REG (mode, regno);
-}
-
-/* Do what is necessary for `va_start'. The argument is ignored.
-
- We look at the current function to determine if stdarg or varargs
- is used and return the address of the first unnamed parameter. */
-
-rtx
-sparc_builtin_saveregs (arglist)
- tree arglist ATTRIBUTE_UNUSED;
-{
- int first_reg = current_function_args_info.words;
- rtx address;
- int regno;
-
- for (regno = first_reg; regno < NPARM_REGS (word_mode); regno++)
- emit_move_insn (gen_rtx_MEM (word_mode,
- gen_rtx_PLUS (Pmode,
- frame_pointer_rtx,
- GEN_INT (STACK_POINTER_OFFSET
- + UNITS_PER_WORD * regno))),
- gen_rtx_REG (word_mode,
- BASE_INCOMING_ARG_REG (word_mode) + regno));
-
- address = gen_rtx_PLUS (Pmode,
- frame_pointer_rtx,
- GEN_INT (STACK_POINTER_OFFSET
- + UNITS_PER_WORD * first_reg));
-
- if (current_function_check_memory_usage
- && first_reg < NPARM_REGS (word_mode))
- emit_library_call (chkr_set_right_libfunc, 1, VOIDmode, 3,
- address, ptr_mode,
- GEN_INT (UNITS_PER_WORD
- * (NPARM_REGS (word_mode) - first_reg)),
- TYPE_MODE (sizetype), GEN_INT (MEMORY_USE_RW),
- TYPE_MODE (integer_type_node));
-
- return address;
-}
-
-/* Return the string to output a conditional branch to LABEL, which is
- the operand number of the label. OP is the conditional expression.
- XEXP (OP, 0) is assumed to be a condition code register (integer or
- floating point) and its mode specifies what kind of comparison we made.
-
- REVERSED is non-zero if we should reverse the sense of the comparison.
-
- ANNUL is non-zero if we should generate an annulling branch.
-
- NOOP is non-zero if we have to follow this branch by a noop.
-
- INSN, if set, is the insn. */
-
-char *
-output_cbranch (op, label, reversed, annul, noop, insn)
- rtx op;
- int label;
- int reversed, annul, noop;
- rtx insn;
-{
- static char string[32];
- enum rtx_code code = GET_CODE (op);
- rtx cc_reg = XEXP (op, 0);
- enum machine_mode mode = GET_MODE (cc_reg);
- static char v8_labelno[] = "%lX";
- static char v9_icc_labelno[] = "%%icc, %lX";
- static char v9_xcc_labelno[] = "%%xcc, %lX";
- static char v9_fcc_labelno[] = "%%fccX, %lY";
- char *labelno;
- int labeloff, spaces = 8;
-
- /* ??? !v9: FP branches cannot be preceded by another floating point insn.
- Because there is currently no concept of pre-delay slots, we can fix
- this only by always emitting a nop before a floating point branch. */
-
- if ((mode == CCFPmode || mode == CCFPEmode) && ! TARGET_V9)
- strcpy (string, "nop\n\t");
- else
- string[0] = '\0';
-
- /* If not floating-point or if EQ or NE, we can just reverse the code. */
- if (reversed
- && ((mode != CCFPmode && mode != CCFPEmode) || code == EQ || code == NE))
- code = reverse_condition (code), reversed = 0;
-
- /* Start by writing the branch condition. */
- switch (code)
- {
- case NE:
- if (mode == CCFPmode || mode == CCFPEmode)
- {
- strcat (string, "fbne");
- spaces -= 4;
- }
- else
- {
- strcpy (string, "bne");
- spaces -= 3;
- }
- break;
-
- case EQ:
- if (mode == CCFPmode || mode == CCFPEmode)
- {
- strcat (string, "fbe");
- spaces -= 3;
- }
- else
- {
- strcpy (string, "be");
- spaces -= 2;
- }
- break;
-
- case GE:
- if (mode == CCFPmode || mode == CCFPEmode)
- {
- if (reversed)
- strcat (string, "fbul");
- else
- strcat (string, "fbge");
- spaces -= 4;
- }
- else if (mode == CC_NOOVmode)
- {
- strcpy (string, "bpos");
- spaces -= 4;
- }
- else
- {
- strcpy (string, "bge");
- spaces -= 3;
- }
- break;
-
- case GT:
- if (mode == CCFPmode || mode == CCFPEmode)
- {
- if (reversed)
- {
- strcat (string, "fbule");
- spaces -= 5;
- }
- else
- {
- strcat (string, "fbg");
- spaces -= 3;
- }
- }
- else
- {
- strcpy (string, "bg");
- spaces -= 2;
- }
- break;
-
- case LE:
- if (mode == CCFPmode || mode == CCFPEmode)
- {
- if (reversed)
- strcat (string, "fbug");
- else
- strcat (string, "fble");
- spaces -= 4;
- }
- else
- {
- strcpy (string, "ble");
- spaces -= 3;
- }
- break;
-
- case LT:
- if (mode == CCFPmode || mode == CCFPEmode)
- {
- if (reversed)
- {
- strcat (string, "fbuge");
- spaces -= 5;
- }
- else
- {
- strcat (string, "fbl");
- spaces -= 3;
- }
- }
- else if (mode == CC_NOOVmode)
- {
- strcpy (string, "bneg");
- spaces -= 4;
- }
- else
- {
- strcpy (string, "bl");
- spaces -= 2;
- }
- break;
-
- case GEU:
- strcpy (string, "bgeu");
- spaces -= 4;
- break;
-
- case GTU:
- strcpy (string, "bgu");
- spaces -= 3;
- break;
-
- case LEU:
- strcpy (string, "bleu");
- spaces -= 4;
- break;
-
- case LTU:
- strcpy (string, "blu");
- spaces -= 3;
- break;
-
- default:
- abort ();
- }
-
- /* Now add the annulling, the label, and a possible noop. */
- if (annul)
- {
- strcat (string, ",a");
- spaces -= 2;
- }
-
- if (! TARGET_V9)
- {
- labeloff = 2;
- labelno = v8_labelno;
- }
- else
- {
- rtx note;
-
- if (insn && (note = find_reg_note (insn, REG_BR_PRED, NULL_RTX)))
- {
- strcat (string,
- INTVAL (XEXP (note, 0)) & ATTR_FLAG_likely ? ",pt" : ",pn");
- spaces -= 3;
- }
-
- labeloff = 9;
- if (mode == CCFPmode || mode == CCFPEmode)
- {
- labeloff = 10;
- labelno = v9_fcc_labelno;
- /* Set the char indicating the number of the fcc reg to use. */
- labelno[5] = REGNO (cc_reg) - SPARC_FIRST_V9_FCC_REG + '0';
- }
- else if (mode == CCXmode || mode == CCX_NOOVmode)
- labelno = v9_xcc_labelno;
- else
- labelno = v9_icc_labelno;
- }
- /* Set the char indicating the number of the operand containing the
- label_ref. */
- labelno[labeloff] = label + '0';
- if (spaces > 0)
- strcat (string, "\t");
- else
- strcat (string, " ");
- strcat (string, labelno);
-
- if (noop)
- strcat (string, "\n\tnop");
-
- return string;
-}
-
-/* Return the string to output a conditional branch to LABEL, testing
- register REG. LABEL is the operand number of the label; REG is the
- operand number of the reg. OP is the conditional expression. The mode
- of REG says what kind of comparison we made.
-
- REVERSED is non-zero if we should reverse the sense of the comparison.
-
- ANNUL is non-zero if we should generate an annulling branch.
-
- NOOP is non-zero if we have to follow this branch by a noop. */
-
-char *
-output_v9branch (op, reg, label, reversed, annul, noop, insn)
- rtx op;
- int reg, label;
- int reversed, annul, noop;
- rtx insn;
-{
- static char string[20];
- enum rtx_code code = GET_CODE (op);
- enum machine_mode mode = GET_MODE (XEXP (op, 0));
- static char labelno[] = "%X, %lX";
- rtx note;
- int spaces = 8;
-
- /* If not floating-point or if EQ or NE, we can just reverse the code. */
- if (reversed)
- code = reverse_condition (code), reversed = 0;
-
- /* Only 64 bit versions of these instructions exist. */
- if (mode != DImode)
- abort ();
-
- /* Start by writing the branch condition. */
-
- switch (code)
- {
- case NE:
- strcpy (string, "brnz");
- spaces -= 4;
- break;
-
- case EQ:
- strcpy (string, "brz");
- spaces -= 3;
- break;
-
- case GE:
- strcpy (string, "brgez");
- spaces -= 5;
- break;
-
- case LT:
- strcpy (string, "brlz");
- spaces -= 4;
- break;
-
- case LE:
- strcpy (string, "brlez");
- spaces -= 5;
- break;
-
- case GT:
- strcpy (string, "brgz");
- spaces -= 4;
- break;
-
- default:
- abort ();
- }
-
- /* Now add the annulling, reg, label, and nop. */
- if (annul)
- {
- strcat (string, ",a");
- spaces -= 2;
- }
-
- if (insn && (note = find_reg_note (insn, REG_BR_PRED, NULL_RTX)))
- {
- strcat (string,
- INTVAL (XEXP (note, 0)) & ATTR_FLAG_likely ? ",pt" : ",pn");
- spaces -= 3;
- }
-
- labelno[1] = reg + '0';
- labelno[6] = label + '0';
- if (spaces > 0)
- strcat (string, "\t");
- else
- strcat (string, " ");
- strcat (string, labelno);
-
- if (noop)
- strcat (string, "\n\tnop");
-
- return string;
-}
-
-/* Renumber registers in delay slot. Replace registers instead of
- renumbering because they may be shared.
-
- This does not handle instructions other than move. */
-
-static void
-epilogue_renumber (where)
- rtx *where;
-{
- rtx x = *where;
- enum rtx_code code = GET_CODE (x);
-
- switch (code)
- {
- case MEM:
- *where = x = copy_rtx (x);
- epilogue_renumber (&XEXP (x, 0));
- return;
-
- case REG:
- {
- int regno = REGNO (x);
- if (regno > 8 && regno < 24)
- abort ();
- if (regno >= 24 && regno < 32)
- *where = gen_rtx_REG (GET_MODE (x), regno - 16);
- return;
- }
- case CONST_INT:
- case CONST_DOUBLE:
- case CONST:
- case SYMBOL_REF:
- case LABEL_REF:
- return;
-
- case IOR:
- case AND:
- case XOR:
- case PLUS:
- case MINUS:
- epilogue_renumber (&XEXP (x, 1));
- case NEG:
- case NOT:
- epilogue_renumber (&XEXP (x, 0));
- return;
-
- default:
- debug_rtx (*where);
- abort ();
- }
-}
-
-/* Output assembler code to return from a function. */
-
-const char *
-output_return (operands)
- rtx *operands;
-{
- rtx delay = final_sequence ? XVECEXP (final_sequence, 0, 1) : 0;
-
- if (leaf_label)
- {
- operands[0] = leaf_label;
- return "b%* %l0%(";
- }
- else if (current_function_uses_only_leaf_regs)
- {
- /* No delay slot in a leaf function. */
- if (delay)
- abort ();
-
- /* If we didn't allocate a frame pointer for the current function,
- the stack pointer might have been adjusted. Output code to
- restore it now. */
-
- operands[0] = GEN_INT (actual_fsize);
-
- /* Use sub of negated value in first two cases instead of add to
- allow actual_fsize == 4096. */
-
- if (actual_fsize <= 4096)
- {
- if (SKIP_CALLERS_UNIMP_P)
- return "jmp\t%%o7+12\n\tsub\t%%sp, -%0, %%sp";
- else
- return "retl\n\tsub\t%%sp, -%0, %%sp";
- }
- else if (actual_fsize <= 8192)
- {
- operands[0] = GEN_INT (actual_fsize - 4096);
- if (SKIP_CALLERS_UNIMP_P)
- return "sub\t%%sp, -4096, %%sp\n\tjmp\t%%o7+12\n\tsub\t%%sp, -%0, %%sp";
- else
- return "sub\t%%sp, -4096, %%sp\n\tretl\n\tsub\t%%sp, -%0, %%sp";
- }
- else if (SKIP_CALLERS_UNIMP_P)
- {
- if ((actual_fsize & 0x3ff) != 0)
- return "sethi\t%%hi(%a0), %%g1\n\tor\t%%g1, %%lo(%a0), %%g1\n\tjmp\t%%o7+12\n\tadd\t%%sp, %%g1, %%sp";
- else
- return "sethi\t%%hi(%a0), %%g1\n\tjmp\t%%o7+12\n\tadd\t%%sp, %%g1, %%sp";
- }
- else
- {
- if ((actual_fsize & 0x3ff) != 0)
- return "sethi %%hi(%a0),%%g1\n\tor %%g1,%%lo(%a0),%%g1\n\tretl\n\tadd %%sp,%%g1,%%sp";
- else
- return "sethi %%hi(%a0),%%g1\n\tretl\n\tadd %%sp,%%g1,%%sp";
- }
- }
- else if (TARGET_V9)
- {
- if (delay)
- {
- epilogue_renumber (&SET_DEST (PATTERN (delay)));
- epilogue_renumber (&SET_SRC (PATTERN (delay)));
- }
- if (SKIP_CALLERS_UNIMP_P)
- return "return\t%%i7+12%#";
- else
- return "return\t%%i7+8%#";
- }
- else
- {
- if (delay)
- abort ();
- if (SKIP_CALLERS_UNIMP_P)
- return "jmp\t%%i7+12\n\trestore";
- else
- return "ret\n\trestore";
- }
-}
-
-/* Leaf functions and non-leaf functions have different needs. */
-
-static int
-reg_leaf_alloc_order[] = REG_LEAF_ALLOC_ORDER;
-
-static int
-reg_nonleaf_alloc_order[] = REG_ALLOC_ORDER;
-
-static int *reg_alloc_orders[] = {
- reg_leaf_alloc_order,
- reg_nonleaf_alloc_order};
-
-void
-order_regs_for_local_alloc ()
-{
- static int last_order_nonleaf = 1;
-
- if (regs_ever_live[15] != last_order_nonleaf)
- {
- last_order_nonleaf = !last_order_nonleaf;
- bcopy ((char *) reg_alloc_orders[last_order_nonleaf],
- (char *) reg_alloc_order, FIRST_PSEUDO_REGISTER * sizeof (int));
- }
-}
-
-/* Return 1 if REG and MEM are legitimate enough to allow the various
- mem<-->reg splits to be run. */
-
-int
-sparc_splitdi_legitimate (reg, mem)
- rtx reg;
- rtx mem;
-{
- /* Punt if we are here by mistake. */
- if (! reload_completed)
- abort ();
-
- /* We must have an offsettable memory reference. */
- if (! offsettable_memref_p (mem))
- return 0;
-
- /* If we have legitimate args for ldd/std, we do not want
- the split to happen. */
- if ((REGNO (reg) % 2) == 0
- && mem_min_alignment (mem, 8))
- return 0;
-
- /* Success. */
- return 1;
-}
-
-/* Return 1 if x and y are some kind of REG and they refer to
- different hard registers. This test is guarenteed to be
- run after reload. */
-
-int
-sparc_absnegfloat_split_legitimate (x, y)
- rtx x, y;
-{
- if (GET_CODE (x) == SUBREG)
- x = alter_subreg (x);
- if (GET_CODE (x) != REG)
- return 0;
- if (GET_CODE (y) == SUBREG)
- y = alter_subreg (y);
- if (GET_CODE (y) != REG)
- return 0;
- if (REGNO (x) == REGNO (y))
- return 0;
- return 1;
-}
-
-/* Return 1 if REGNO (reg1) is even and REGNO (reg1) == REGNO (reg2) - 1.
- This makes them candidates for using ldd and std insns.
-
- Note reg1 and reg2 *must* be hard registers. */
-
-int
-registers_ok_for_ldd_peep (reg1, reg2)
- rtx reg1, reg2;
-{
- /* We might have been passed a SUBREG. */
- if (GET_CODE (reg1) != REG || GET_CODE (reg2) != REG)
- return 0;
-
- if (REGNO (reg1) % 2 != 0)
- return 0;
-
- /* Integer ldd is deprecated in SPARC V9 */
- if (TARGET_V9 && REGNO (reg1) < 32)
- return 0;
-
- return (REGNO (reg1) == REGNO (reg2) - 1);
-}
-
-/* Return 1 if addr1 and addr2 are suitable for use in an ldd or
- std insn.
-
- This can only happen when addr1 and addr2 are consecutive memory
- locations (addr1 + 4 == addr2). addr1 must also be aligned on a
- 64 bit boundary (addr1 % 8 == 0).
-
- We know %sp and %fp are kept aligned on a 64 bit boundary. Other
- registers are assumed to *never* be properly aligned and are
- rejected.
-
- Knowing %sp and %fp are kept aligned on a 64 bit boundary, we
- need only check that the offset for addr1 % 8 == 0. */
-
-int
-addrs_ok_for_ldd_peep (addr1, addr2)
- rtx addr1, addr2;
-{
- int reg1, offset1;
-
- /* Extract a register number and offset (if used) from the first addr. */
- if (GET_CODE (addr1) == PLUS)
- {
- /* If not a REG, return zero. */
- if (GET_CODE (XEXP (addr1, 0)) != REG)
- return 0;
- else
- {
- reg1 = REGNO (XEXP (addr1, 0));
- /* The offset must be constant! */
- if (GET_CODE (XEXP (addr1, 1)) != CONST_INT)
- return 0;
- offset1 = INTVAL (XEXP (addr1, 1));
- }
- }
- else if (GET_CODE (addr1) != REG)
- return 0;
- else
- {
- reg1 = REGNO (addr1);
- /* This was a simple (mem (reg)) expression. Offset is 0. */
- offset1 = 0;
- }
-
- /* Make sure the second address is a (mem (plus (reg) (const_int). */
- if (GET_CODE (addr2) != PLUS)
- return 0;
-
- if (GET_CODE (XEXP (addr2, 0)) != REG
- || GET_CODE (XEXP (addr2, 1)) != CONST_INT)
- return 0;
-
- /* Only %fp and %sp are allowed. Additionally both addresses must
- use the same register. */
- if (reg1 != FRAME_POINTER_REGNUM && reg1 != STACK_POINTER_REGNUM)
- return 0;
-
- if (reg1 != REGNO (XEXP (addr2, 0)))
- return 0;
-
- /* The first offset must be evenly divisible by 8 to ensure the
- address is 64 bit aligned. */
- if (offset1 % 8 != 0)
- return 0;
-
- /* The offset for the second addr must be 4 more than the first addr. */
- if (INTVAL (XEXP (addr2, 1)) != offset1 + 4)
- return 0;
-
- /* All the tests passed. addr1 and addr2 are valid for ldd and std
- instructions. */
- return 1;
-}
-
-/* Return 1 if reg is a pseudo, or is the first register in
- a hard register pair. This makes it a candidate for use in
- ldd and std insns. */
-
-int
-register_ok_for_ldd (reg)
- rtx reg;
-{
- /* We might have been passed a SUBREG. */
- if (GET_CODE (reg) != REG)
- return 0;
-
- if (REGNO (reg) < FIRST_PSEUDO_REGISTER)
- return (REGNO (reg) % 2 == 0);
- else
- return 1;
-}
-
-/* Print operand X (an rtx) in assembler syntax to file FILE.
- CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified.
- For `%' followed by punctuation, CODE is the punctuation and X is null. */
-
-void
-print_operand (file, x, code)
- FILE *file;
- rtx x;
- int code;
-{
- switch (code)
- {
- case '#':
- /* Output a 'nop' if there's nothing for the delay slot. */
- if (dbr_sequence_length () == 0)
- fputs ("\n\t nop", file);
- return;
- case '*':
- /* Output an annul flag if there's nothing for the delay slot and we
- are optimizing. This is always used with '(' below. */
- /* Sun OS 4.1.1 dbx can't handle an annulled unconditional branch;
- this is a dbx bug. So, we only do this when optimizing. */
- /* On UltraSPARC, a branch in a delay slot causes a pipeline flush.
- Always emit a nop in case the next instruction is a branch. */
- if (dbr_sequence_length () == 0
- && (optimize && (int)sparc_cpu < PROCESSOR_V9))
- fputs (",a", file);
- return;
- case '(':
- /* Output a 'nop' if there's nothing for the delay slot and we are
- not optimizing. This is always used with '*' above. */
- if (dbr_sequence_length () == 0
- && ! (optimize && (int)sparc_cpu < PROCESSOR_V9))
- fputs ("\n\t nop", file);
- return;
- case '_':
- /* Output the Embedded Medium/Anywhere code model base register. */
- fputs (EMBMEDANY_BASE_REG, file);
- return;
- case '@':
- /* Print out what we are using as the frame pointer. This might
- be %fp, or might be %sp+offset. */
- /* ??? What if offset is too big? Perhaps the caller knows it isn't? */
- fprintf (file, "%s+%d", frame_base_name, frame_base_offset);
- return;
- case 'Y':
- /* Adjust the operand to take into account a RESTORE operation. */
- if (GET_CODE (x) == CONST_INT)
- break;
- else if (GET_CODE (x) != REG)
- output_operand_lossage ("Invalid %%Y operand");
- else if (REGNO (x) < 8)
- fputs (reg_names[REGNO (x)], file);
- else if (REGNO (x) >= 24 && REGNO (x) < 32)
- fputs (reg_names[REGNO (x)-16], file);
- else
- output_operand_lossage ("Invalid %%Y operand");
- return;
- case 'L':
- /* Print out the low order register name of a register pair. */
- if (WORDS_BIG_ENDIAN)
- fputs (reg_names[REGNO (x)+1], file);
- else
- fputs (reg_names[REGNO (x)], file);
- return;
- case 'H':
- /* Print out the high order register name of a register pair. */
- if (WORDS_BIG_ENDIAN)
- fputs (reg_names[REGNO (x)], file);
- else
- fputs (reg_names[REGNO (x)+1], file);
- return;
- case 'R':
- /* Print out the second register name of a register pair or quad.
- I.e., R (%o0) => %o1. */
- fputs (reg_names[REGNO (x)+1], file);
- return;
- case 'S':
- /* Print out the third register name of a register quad.
- I.e., S (%o0) => %o2. */
- fputs (reg_names[REGNO (x)+2], file);
- return;
- case 'T':
- /* Print out the fourth register name of a register quad.
- I.e., T (%o0) => %o3. */
- fputs (reg_names[REGNO (x)+3], file);
- return;
- case 'x':
- /* Print a condition code register. */
- if (REGNO (x) == SPARC_ICC_REG)
- {
- /* We don't handle CC[X]_NOOVmode because they're not supposed
- to occur here. */
- if (GET_MODE (x) == CCmode)
- fputs ("%icc", file);
- else if (GET_MODE (x) == CCXmode)
- fputs ("%xcc", file);
- else
- abort ();
- }
- else
- /* %fccN register */
- fputs (reg_names[REGNO (x)], file);
- return;
- case 'm':
- /* Print the operand's address only. */
- output_address (XEXP (x, 0));
- return;
- case 'r':
- /* In this case we need a register. Use %g0 if the
- operand is const0_rtx. */
- if (x == const0_rtx
- || (GET_MODE (x) != VOIDmode && x == CONST0_RTX (GET_MODE (x))))
- {
- fputs ("%g0", file);
- return;
- }
- else
- break;
-
- case 'A':
- switch (GET_CODE (x))
- {
- case IOR: fputs ("or", file); break;
- case AND: fputs ("and", file); break;
- case XOR: fputs ("xor", file); break;
- default: output_operand_lossage ("Invalid %%A operand");
- }
- return;
-
- case 'B':
- switch (GET_CODE (x))
- {
- case IOR: fputs ("orn", file); break;
- case AND: fputs ("andn", file); break;
- case XOR: fputs ("xnor", file); break;
- default: output_operand_lossage ("Invalid %%B operand");
- }
- return;
-
- /* These are used by the conditional move instructions. */
- case 'c' :
- case 'C':
- {
- enum rtx_code rc = (code == 'c'
- ? reverse_condition (GET_CODE (x))
- : GET_CODE (x));
- switch (rc)
- {
- case NE: fputs ("ne", file); break;
- case EQ: fputs ("e", file); break;
- case GE: fputs ("ge", file); break;
- case GT: fputs ("g", file); break;
- case LE: fputs ("le", file); break;
- case LT: fputs ("l", file); break;
- case GEU: fputs ("geu", file); break;
- case GTU: fputs ("gu", file); break;
- case LEU: fputs ("leu", file); break;
- case LTU: fputs ("lu", file); break;
- default: output_operand_lossage (code == 'c'
- ? "Invalid %%c operand"
- : "Invalid %%C operand");
- }
- return;
- }
-
- /* These are used by the movr instruction pattern. */
- case 'd':
- case 'D':
- {
- enum rtx_code rc = (code == 'd'
- ? reverse_condition (GET_CODE (x))
- : GET_CODE (x));
- switch (rc)
- {
- case NE: fputs ("ne", file); break;
- case EQ: fputs ("e", file); break;
- case GE: fputs ("gez", file); break;
- case LT: fputs ("lz", file); break;
- case LE: fputs ("lez", file); break;
- case GT: fputs ("gz", file); break;
- default: output_operand_lossage (code == 'd'
- ? "Invalid %%d operand"
- : "Invalid %%D operand");
- }
- return;
- }
-
- case 'b':
- {
- /* Print a sign-extended character. */
- int i = INTVAL (x) & 0xff;
- if (i & 0x80)
- i |= 0xffffff00;
- fprintf (file, "%d", i);
- return;
- }
-
- case 'f':
- /* Operand must be a MEM; write its address. */
- if (GET_CODE (x) != MEM)
- output_operand_lossage ("Invalid %%f operand");
- output_address (XEXP (x, 0));
- return;
-
- case 0:
- /* Do nothing special. */
- break;
-
- default:
- /* Undocumented flag. */
- output_operand_lossage ("invalid operand output code");
- }
-
- if (GET_CODE (x) == REG)
- fputs (reg_names[REGNO (x)], file);
- else if (GET_CODE (x) == MEM)
- {
- fputc ('[', file);
- /* Poor Sun assembler doesn't understand absolute addressing. */
- if (CONSTANT_P (XEXP (x, 0))
- && ! TARGET_LIVE_G0)
- fputs ("%g0+", file);
- output_address (XEXP (x, 0));
- fputc (']', file);
- }
- else if (GET_CODE (x) == HIGH)
- {
- fputs ("%hi(", file);
- output_addr_const (file, XEXP (x, 0));
- fputc (')', file);
- }
- else if (GET_CODE (x) == LO_SUM)
- {
- print_operand (file, XEXP (x, 0), 0);
- if (TARGET_CM_MEDMID)
- fputs ("+%l44(", file);
- else
- fputs ("+%lo(", file);
- output_addr_const (file, XEXP (x, 1));
- fputc (')', file);
- }
- else if (GET_CODE (x) == CONST_DOUBLE
- && (GET_MODE (x) == VOIDmode
- || GET_MODE_CLASS (GET_MODE (x)) == MODE_INT))
- {
- if (CONST_DOUBLE_HIGH (x) == 0)
- fprintf (file, "%u", CONST_DOUBLE_LOW (x));
- else if (CONST_DOUBLE_HIGH (x) == -1
- && CONST_DOUBLE_LOW (x) < 0)
- fprintf (file, "%d", CONST_DOUBLE_LOW (x));
- else
- output_operand_lossage ("long long constant not a valid immediate operand");
- }
- else if (GET_CODE (x) == CONST_DOUBLE)
- output_operand_lossage ("floating point constant not a valid immediate operand");
- else { output_addr_const (file, x); }
-}
-
-/* This function outputs assembler code for VALUE to FILE, where VALUE is
- a 64 bit (DImode) value. */
-
-/* ??? If there is a 64 bit counterpart to .word that the assembler
- understands, then using that would simply this code greatly. */
-/* ??? We only output .xword's for symbols and only then in environments
- where the assembler can handle them. */
-
-void
-output_double_int (file, value)
- FILE *file;
- rtx value;
-{
- if (GET_CODE (value) == CONST_INT)
- {
- /* ??? This has endianness issues. */
-#if HOST_BITS_PER_WIDE_INT == 64
- HOST_WIDE_INT xword = INTVAL (value);
- HOST_WIDE_INT high, low;
-
- high = (xword >> 32) & 0xffffffff;
- low = xword & 0xffffffff;
- ASM_OUTPUT_INT (file, GEN_INT (high));
- ASM_OUTPUT_INT (file, GEN_INT (low));
-#else
- if (INTVAL (value) < 0)
- ASM_OUTPUT_INT (file, constm1_rtx);
- else
- ASM_OUTPUT_INT (file, const0_rtx);
- ASM_OUTPUT_INT (file, value);
-#endif
- }
- else if (GET_CODE (value) == CONST_DOUBLE)
- {
- ASM_OUTPUT_INT (file, GEN_INT (CONST_DOUBLE_HIGH (value)));
- ASM_OUTPUT_INT (file, GEN_INT (CONST_DOUBLE_LOW (value)));
- }
- else if (GET_CODE (value) == SYMBOL_REF
- || GET_CODE (value) == CONST
- || GET_CODE (value) == PLUS
- || (TARGET_ARCH64 &&
- (GET_CODE (value) == LABEL_REF
- || GET_CODE (value) == CODE_LABEL
- || GET_CODE (value) == MINUS)))
- {
- if (! TARGET_V9)
- {
- ASM_OUTPUT_INT (file, const0_rtx);
- ASM_OUTPUT_INT (file, value);
- }
- else
- {
- fprintf (file, "\t%s\t", ASM_LONGLONG);
- output_addr_const (file, value);
- fprintf (file, "\n");
- }
- }
- else
- abort ();
-}
-
-/* Return the value of a code used in the .proc pseudo-op that says
- what kind of result this function returns. For non-C types, we pick
- the closest C type. */
-
-#ifndef CHAR_TYPE_SIZE
-#define CHAR_TYPE_SIZE BITS_PER_UNIT
-#endif
-
-#ifndef SHORT_TYPE_SIZE
-#define SHORT_TYPE_SIZE (BITS_PER_UNIT * 2)
-#endif
-
-#ifndef INT_TYPE_SIZE
-#define INT_TYPE_SIZE BITS_PER_WORD
-#endif
-
-#ifndef LONG_TYPE_SIZE
-#define LONG_TYPE_SIZE BITS_PER_WORD
-#endif
-
-#ifndef LONG_LONG_TYPE_SIZE
-#define LONG_LONG_TYPE_SIZE (BITS_PER_WORD * 2)
-#endif
-
-#ifndef FLOAT_TYPE_SIZE
-#define FLOAT_TYPE_SIZE BITS_PER_WORD
-#endif
-
-#ifndef DOUBLE_TYPE_SIZE
-#define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
-#endif
-
-#ifndef LONG_DOUBLE_TYPE_SIZE
-#define LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
-#endif
-
-unsigned long
-sparc_type_code (type)
- register tree type;
-{
- register unsigned long qualifiers = 0;
- register unsigned shift;
-
- /* Only the first 30 bits of the qualifier are valid. We must refrain from
- setting more, since some assemblers will give an error for this. Also,
- we must be careful to avoid shifts of 32 bits or more to avoid getting
- unpredictable results. */
-
- for (shift = 6; shift < 30; shift += 2, type = TREE_TYPE (type))
- {
- switch (TREE_CODE (type))
- {
- case ERROR_MARK:
- return qualifiers;
-
- case ARRAY_TYPE:
- qualifiers |= (3 << shift);
- break;
-
- case FUNCTION_TYPE:
- case METHOD_TYPE:
- qualifiers |= (2 << shift);
- break;
-
- case POINTER_TYPE:
- case REFERENCE_TYPE:
- case OFFSET_TYPE:
- qualifiers |= (1 << shift);
- break;
-
- case RECORD_TYPE:
- return (qualifiers | 8);
-
- case UNION_TYPE:
- case QUAL_UNION_TYPE:
- return (qualifiers | 9);
-
- case ENUMERAL_TYPE:
- return (qualifiers | 10);
-
- case VOID_TYPE:
- return (qualifiers | 16);
-
- case INTEGER_TYPE:
- /* If this is a range type, consider it to be the underlying
- type. */
- if (TREE_TYPE (type) != 0)
- break;
-
- /* Carefully distinguish all the standard types of C,
- without messing up if the language is not C. We do this by
- testing TYPE_PRECISION and TREE_UNSIGNED. The old code used to
- look at both the names and the above fields, but that's redundant.
- Any type whose size is between two C types will be considered
- to be the wider of the two types. Also, we do not have a
- special code to use for "long long", so anything wider than
- long is treated the same. Note that we can't distinguish
- between "int" and "long" in this code if they are the same
- size, but that's fine, since neither can the assembler. */
-
- if (TYPE_PRECISION (type) <= CHAR_TYPE_SIZE)
- return (qualifiers | (TREE_UNSIGNED (type) ? 12 : 2));
-
- else if (TYPE_PRECISION (type) <= SHORT_TYPE_SIZE)
- return (qualifiers | (TREE_UNSIGNED (type) ? 13 : 3));
-
- else if (TYPE_PRECISION (type) <= INT_TYPE_SIZE)
- return (qualifiers | (TREE_UNSIGNED (type) ? 14 : 4));
-
- else
- return (qualifiers | (TREE_UNSIGNED (type) ? 15 : 5));
-
- case REAL_TYPE:
- /* If this is a range type, consider it to be the underlying
- type. */
- if (TREE_TYPE (type) != 0)
- break;
-
- /* Carefully distinguish all the standard types of C,
- without messing up if the language is not C. */
-
- if (TYPE_PRECISION (type) == FLOAT_TYPE_SIZE)
- return (qualifiers | 6);
-
- else
- return (qualifiers | 7);
-
- case COMPLEX_TYPE: /* GNU Fortran COMPLEX type. */
- /* ??? We need to distinguish between double and float complex types,
- but I don't know how yet because I can't reach this code from
- existing front-ends. */
- return (qualifiers | 7); /* Who knows? */
-
- case CHAR_TYPE: /* GNU Pascal CHAR type. Not used in C. */
- case BOOLEAN_TYPE: /* GNU Fortran BOOLEAN type. */
- case FILE_TYPE: /* GNU Pascal FILE type. */
- case SET_TYPE: /* GNU Pascal SET type. */
- case LANG_TYPE: /* ? */
- return qualifiers;
-
- default:
- abort (); /* Not a type! */
- }
- }
-
- return qualifiers;
-}
-
-/* Nested function support. */
-
-/* Emit RTL insns to initialize the variable parts of a trampoline.
- FNADDR is an RTX for the address of the function's pure code.
- CXT is an RTX for the static chain value for the function.
-
- This takes 16 insns: 2 shifts & 2 ands (to split up addresses), 4 sethi
- (to load in opcodes), 4 iors (to merge address and opcodes), and 4 writes
- (to store insns). This is a bit excessive. Perhaps a different
- mechanism would be better here.
-
- Emit enough FLUSH insns to synchronize the data and instruction caches. */
-
-void
-sparc_initialize_trampoline (tramp, fnaddr, cxt)
- rtx tramp, fnaddr, cxt;
-{
- /* SPARC 32 bit trampoline:
-
- sethi %hi(fn), %g1
- sethi %hi(static), %g2
- jmp %g1+%lo(fn)
- or %g2, %lo(static), %g2
-
- SETHI i,r = 00rr rrr1 00ii iiii iiii iiii iiii iiii
- JMPL r+i,d = 10dd ddd1 1100 0rrr rr1i iiii iiii iiii
- */
-#ifdef TRANSFER_FROM_TRAMPOLINE
- emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "__enable_execute_stack"),
- 0, VOIDmode, 1, tramp, Pmode);
-#endif
-
- emit_move_insn (gen_rtx_MEM (SImode, plus_constant (tramp, 0)),
- expand_binop (SImode, ior_optab,
- expand_shift (RSHIFT_EXPR, SImode, fnaddr,
- size_int (10), 0, 1),
- GEN_INT (0x03000000),
- NULL_RTX, 1, OPTAB_DIRECT));
-
- emit_move_insn (gen_rtx_MEM (SImode, plus_constant (tramp, 4)),
- expand_binop (SImode, ior_optab,
- expand_shift (RSHIFT_EXPR, SImode, cxt,
- size_int (10), 0, 1),
- GEN_INT (0x05000000),
- NULL_RTX, 1, OPTAB_DIRECT));
-
- emit_move_insn (gen_rtx_MEM (SImode, plus_constant (tramp, 8)),
- expand_binop (SImode, ior_optab,
- expand_and (fnaddr, GEN_INT (0x3ff), NULL_RTX),
- GEN_INT (0x81c06000),
- NULL_RTX, 1, OPTAB_DIRECT));
-
- emit_move_insn (gen_rtx_MEM (SImode, plus_constant (tramp, 12)),
- expand_binop (SImode, ior_optab,
- expand_and (cxt, GEN_INT (0x3ff), NULL_RTX),
- GEN_INT (0x8410a000),
- NULL_RTX, 1, OPTAB_DIRECT));
-
- emit_insn (gen_flush (validize_mem (gen_rtx_MEM (SImode, tramp))));
- /* On UltraSPARC a flush flushes an entire cache line. The trampoline is
- aligned on a 16 byte boundary so one flush clears it all. */
- if (sparc_cpu != PROCESSOR_ULTRASPARC)
- emit_insn (gen_flush (validize_mem (gen_rtx_MEM (SImode,
- plus_constant (tramp, 8)))));
-}
-
-/* The 64 bit version is simpler because it makes more sense to load the
- values as "immediate" data out of the trampoline. It's also easier since
- we can read the PC without clobbering a register. */
-
-void
-sparc64_initialize_trampoline (tramp, fnaddr, cxt)
- rtx tramp, fnaddr, cxt;
-{
-#ifdef TRANSFER_FROM_TRAMPOLINE
- emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "__enable_execute_stack"),
- 0, VOIDmode, 1, tramp, Pmode);
-#endif
-
- /*
- rd %pc, %g1
- ldx [%g1+24], %g5
- jmp %g5
- ldx [%g1+16], %g5
- +16 bytes data
- */
-
- emit_move_insn (gen_rtx_MEM (SImode, tramp),
- GEN_INT (0x83414000));
- emit_move_insn (gen_rtx_MEM (SImode, plus_constant (tramp, 4)),
- GEN_INT (0xca586018));
- emit_move_insn (gen_rtx_MEM (SImode, plus_constant (tramp, 8)),
- GEN_INT (0x81c14000));
- emit_move_insn (gen_rtx_MEM (SImode, plus_constant (tramp, 12)),
- GEN_INT (0xca586010));
- emit_move_insn (gen_rtx_MEM (DImode, plus_constant (tramp, 16)), cxt);
- emit_move_insn (gen_rtx_MEM (DImode, plus_constant (tramp, 24)), fnaddr);
- emit_insn (gen_flush (validize_mem (gen_rtx_MEM (DImode, tramp))));
-
- if (sparc_cpu != PROCESSOR_ULTRASPARC)
- emit_insn (gen_flush (validize_mem (gen_rtx_MEM (DImode, plus_constant (tramp, 8)))));
-}
-
-/* Subroutines to support a flat (single) register window calling
- convention. */
-
-/* Single-register window sparc stack frames look like:
-
- Before call After call
- +-----------------------+ +-----------------------+
- high | | | |
- mem | caller's temps. | | caller's temps. |
- | | | |
- +-----------------------+ +-----------------------+
- | | | |
- | arguments on stack. | | arguments on stack. |
- | | | |
- +-----------------------+FP+92->+-----------------------+
- | 6 words to save | | 6 words to save |
- | arguments passed | | arguments passed |
- | in registers, even | | in registers, even |
- | if not passed. | | if not passed. |
- SP+68->+-----------------------+FP+68->+-----------------------+
- | 1 word struct addr | | 1 word struct addr |
- +-----------------------+FP+64->+-----------------------+
- | | | |
- | 16 word reg save area | | 16 word reg save area |
- | | | |
- SP->+-----------------------+ FP->+-----------------------+
- | 4 word area for |
- | fp/alu reg moves |
- FP-16->+-----------------------+
- | |
- | local variables |
- | |
- +-----------------------+
- | |
- | fp register save |
- | |
- +-----------------------+
- | |
- | gp register save |
- | |
- +-----------------------+
- | |
- | alloca allocations |
- | |
- +-----------------------+
- | |
- | arguments on stack |
- | |
- SP+92->+-----------------------+
- | 6 words to save |
- | arguments passed |
- | in registers, even |
- low | if not passed. |
- memory SP+68->+-----------------------+
- | 1 word struct addr |
- SP+64->+-----------------------+
- | |
- I 16 word reg save area |
- | |
- SP->+-----------------------+ */
-
-/* Structure to be filled in by sparc_flat_compute_frame_size with register
- save masks, and offsets for the current function. */
-
-struct sparc_frame_info
-{
- unsigned long total_size; /* # bytes that the entire frame takes up. */
- unsigned long var_size; /* # bytes that variables take up. */
- unsigned long args_size; /* # bytes that outgoing arguments take up. */
- unsigned long extra_size; /* # bytes of extra gunk. */
- unsigned int gp_reg_size; /* # bytes needed to store gp regs. */
- unsigned int fp_reg_size; /* # bytes needed to store fp regs. */
- unsigned long gmask; /* Mask of saved gp registers. */
- unsigned long fmask; /* Mask of saved fp registers. */
- unsigned long reg_offset; /* Offset from new sp to store regs. */
- int initialized; /* Nonzero if frame size already calculated. */
-};
-
-/* Current frame information calculated by sparc_flat_compute_frame_size. */
-struct sparc_frame_info current_frame_info;
-
-/* Zero structure to initialize current_frame_info. */
-struct sparc_frame_info zero_frame_info;
-
-/* Tell prologue and epilogue if register REGNO should be saved / restored. */
-
-#define RETURN_ADDR_REGNUM 15
-#define FRAME_POINTER_MASK (1 << (FRAME_POINTER_REGNUM))
-#define RETURN_ADDR_MASK (1 << (RETURN_ADDR_REGNUM))
-
-#define MUST_SAVE_REGISTER(regno) \
- ((regs_ever_live[regno] && !call_used_regs[regno]) \
- || (regno == FRAME_POINTER_REGNUM && frame_pointer_needed) \
- || (regno == RETURN_ADDR_REGNUM && regs_ever_live[RETURN_ADDR_REGNUM]))
-
-/* Return the bytes needed to compute the frame pointer from the current
- stack pointer. */
-
-unsigned long
-sparc_flat_compute_frame_size (size)
- int size; /* # of var. bytes allocated. */
-{
- int regno;
- unsigned long total_size; /* # bytes that the entire frame takes up. */
- unsigned long var_size; /* # bytes that variables take up. */
- unsigned long args_size; /* # bytes that outgoing arguments take up. */
- unsigned long extra_size; /* # extra bytes. */
- unsigned int gp_reg_size; /* # bytes needed to store gp regs. */
- unsigned int fp_reg_size; /* # bytes needed to store fp regs. */
- unsigned long gmask; /* Mask of saved gp registers. */
- unsigned long fmask; /* Mask of saved fp registers. */
- unsigned long reg_offset; /* Offset to register save area. */
- int need_aligned_p; /* 1 if need the save area 8 byte aligned. */
-
- /* This is the size of the 16 word reg save area, 1 word struct addr
- area, and 4 word fp/alu register copy area. */
- extra_size = -STARTING_FRAME_OFFSET + FIRST_PARM_OFFSET(0);
- var_size = size;
- gp_reg_size = 0;
- fp_reg_size = 0;
- gmask = 0;
- fmask = 0;
- reg_offset = 0;
- need_aligned_p = 0;
-
- args_size = 0;
- if (!leaf_function_p ())
- {
- /* Also include the size needed for the 6 parameter registers. */
- args_size = current_function_outgoing_args_size + 24;
- }
- total_size = var_size + args_size;
-
- /* Calculate space needed for gp registers. */
- for (regno = 1; regno <= 31; regno++)
- {
- if (MUST_SAVE_REGISTER (regno))
- {
- /* If we need to save two regs in a row, ensure there's room to bump
- up the address to align it to a doubleword boundary. */
- if ((regno & 0x1) == 0 && MUST_SAVE_REGISTER (regno+1))
- {
- if (gp_reg_size % 8 != 0)
- gp_reg_size += 4;
- gp_reg_size += 2 * UNITS_PER_WORD;
- gmask |= 3 << regno;
- regno++;
- need_aligned_p = 1;
- }
- else
- {
- gp_reg_size += UNITS_PER_WORD;
- gmask |= 1 << regno;
- }
- }
- }
-
- /* Calculate space needed for fp registers. */
- for (regno = 32; regno <= 63; regno++)
- {
- if (regs_ever_live[regno] && !call_used_regs[regno])
- {
- fp_reg_size += UNITS_PER_WORD;
- fmask |= 1 << (regno - 32);
- }
- }
-
- if (gmask || fmask)
- {
- int n;
- reg_offset = FIRST_PARM_OFFSET(0) + args_size;
- /* Ensure save area is 8 byte aligned if we need it. */
- n = reg_offset % 8;
- if (need_aligned_p && n != 0)
- {
- total_size += 8 - n;
- reg_offset += 8 - n;
- }
- total_size += gp_reg_size + fp_reg_size;
- }
-
- /* If we must allocate a stack frame at all, we must also allocate
- room for register window spillage, so as to be binary compatible
- with libraries and operating systems that do not use -mflat. */
- if (total_size > 0)
- total_size += extra_size;
- else
- extra_size = 0;
-
- total_size = SPARC_STACK_ALIGN (total_size);
-
- /* Save other computed information. */
- current_frame_info.total_size = total_size;
- current_frame_info.var_size = var_size;
- current_frame_info.args_size = args_size;
- current_frame_info.extra_size = extra_size;
- current_frame_info.gp_reg_size = gp_reg_size;
- current_frame_info.fp_reg_size = fp_reg_size;
- current_frame_info.gmask = gmask;
- current_frame_info.fmask = fmask;
- current_frame_info.reg_offset = reg_offset;
- current_frame_info.initialized = reload_completed;
-
- /* Ok, we're done. */
- return total_size;
-}
-
-/* Save/restore registers in GMASK and FMASK at register BASE_REG plus offset
- OFFSET.
-
- BASE_REG must be 8 byte aligned. This allows us to test OFFSET for
- appropriate alignment and use DOUBLEWORD_OP when we can. We assume
- [BASE_REG+OFFSET] will always be a valid address.
-
- WORD_OP is either "st" for save, "ld" for restore.
- DOUBLEWORD_OP is either "std" for save, "ldd" for restore. */
-
-void
-sparc_flat_save_restore (file, base_reg, offset, gmask, fmask, word_op,
- doubleword_op, base_offset)
- FILE *file;
- char *base_reg;
- unsigned int offset;
- unsigned long gmask;
- unsigned long fmask;
- char *word_op;
- char *doubleword_op;
- unsigned long base_offset;
-{
- int regno;
-
- if (gmask == 0 && fmask == 0)
- return;
-
- /* Save registers starting from high to low. We've already saved the
- previous frame pointer and previous return address for the debugger's
- sake. The debugger allows us to not need a nop in the epilog if at least
- one register is reloaded in addition to return address. */
-
- if (gmask)
- {
- for (regno = 1; regno <= 31; regno++)
- {
- if ((gmask & (1L << regno)) != 0)
- {
- if ((regno & 0x1) == 0 && ((gmask & (1L << (regno+1))) != 0))
- {
- /* We can save two registers in a row. If we're not at a
- double word boundary, move to one.
- sparc_flat_compute_frame_size ensures there's room to do
- this. */
- if (offset % 8 != 0)
- offset += UNITS_PER_WORD;
-
- if (word_op[0] == 's')
- {
- fprintf (file, "\t%s\t%s, [%s+%d]\n",
- doubleword_op, reg_names[regno],
- base_reg, offset);
- if (dwarf2out_do_frame ())
- {
- char *l = dwarf2out_cfi_label ();
- dwarf2out_reg_save (l, regno, offset + base_offset);
- dwarf2out_reg_save
- (l, regno+1, offset+base_offset + UNITS_PER_WORD);
- }
- }
- else
- fprintf (file, "\t%s\t[%s+%d], %s\n",
- doubleword_op, base_reg, offset,
- reg_names[regno]);
-
- offset += 2 * UNITS_PER_WORD;
- regno++;
- }
- else
- {
- if (word_op[0] == 's')
- {
- fprintf (file, "\t%s\t%s, [%s+%d]\n",
- word_op, reg_names[regno],
- base_reg, offset);
- if (dwarf2out_do_frame ())
- dwarf2out_reg_save ("", regno, offset + base_offset);
- }
- else
- fprintf (file, "\t%s\t[%s+%d], %s\n",
- word_op, base_reg, offset, reg_names[regno]);
-
- offset += UNITS_PER_WORD;
- }
- }
- }
- }
-
- if (fmask)
- {
- for (regno = 32; regno <= 63; regno++)
- {
- if ((fmask & (1L << (regno - 32))) != 0)
- {
- if (word_op[0] == 's')
- {
- fprintf (file, "\t%s\t%s, [%s+%d]\n",
- word_op, reg_names[regno],
- base_reg, offset);
- if (dwarf2out_do_frame ())
- dwarf2out_reg_save ("", regno, offset + base_offset);
- }
- else
- fprintf (file, "\t%s\t[%s+%d], %s\n",
- word_op, base_reg, offset, reg_names[regno]);
-
- offset += UNITS_PER_WORD;
- }
- }
- }
-}
-
-/* Set up the stack and frame (if desired) for the function. */
-
-void
-sparc_flat_output_function_prologue (file, size)
- FILE *file;
- int size;
-{
- char *sp_str = reg_names[STACK_POINTER_REGNUM];
- unsigned long gmask = current_frame_info.gmask;
-
- /* This is only for the human reader. */
- fprintf (file, "\t%s#PROLOGUE# 0\n", ASM_COMMENT_START);
- fprintf (file, "\t%s# vars= %ld, regs= %d/%d, args= %d, extra= %ld\n",
- ASM_COMMENT_START,
- current_frame_info.var_size,
- current_frame_info.gp_reg_size / 4,
- current_frame_info.fp_reg_size / 4,
- current_function_outgoing_args_size,
- current_frame_info.extra_size);
-
- size = SPARC_STACK_ALIGN (size);
- size = (! current_frame_info.initialized
- ? sparc_flat_compute_frame_size (size)
- : current_frame_info.total_size);
-
- /* These cases shouldn't happen. Catch them now. */
- if (size == 0 && (gmask || current_frame_info.fmask))
- abort ();
-
- /* Allocate our stack frame by decrementing %sp.
- At present, the only algorithm gdb can use to determine if this is a
- flat frame is if we always set %i7 if we set %sp. This can be optimized
- in the future by putting in some sort of debugging information that says
- this is a `flat' function. However, there is still the case of debugging
- code without such debugging information (including cases where most fns
- have such info, but there is one that doesn't). So, always do this now
- so we don't get a lot of code out there that gdb can't handle.
- If the frame pointer isn't needn't then that's ok - gdb won't be able to
- distinguish us from a non-flat function but there won't (and shouldn't)
- be any differences anyway. The return pc is saved (if necessary) right
- after %i7 so gdb won't have to look too far to find it. */
- if (size > 0)
- {
- unsigned int reg_offset = current_frame_info.reg_offset;
- char *fp_str = reg_names[FRAME_POINTER_REGNUM];
- const char *t1_str = "%g1";
-
- /* Things get a little tricky if local variables take up more than ~4096
- bytes and outgoing arguments take up more than ~4096 bytes. When that
- happens, the register save area can't be accessed from either end of
- the frame. Handle this by decrementing %sp to the start of the gp
- register save area, save the regs, update %i7, and then set %sp to its
- final value. Given that we only have one scratch register to play
- with it is the cheapest solution, and it helps gdb out as it won't
- slow down recognition of flat functions.
- Don't change the order of insns emitted here without checking with
- the gdb folk first. */
-
- /* Is the entire register save area offsettable from %sp? */
- if (reg_offset < 4096 - 64 * UNITS_PER_WORD)
- {
- if (size <= 4096)
- {
- fprintf (file, "\tadd\t%s, %d, %s\n",
- sp_str, -size, sp_str);
- if (gmask & FRAME_POINTER_MASK)
- {
- fprintf (file, "\tst\t%s, [%s+%d]\n",
- fp_str, sp_str, reg_offset);
- fprintf (file, "\tsub\t%s, %d, %s\t%s# set up frame pointer\n",
- sp_str, -size, fp_str, ASM_COMMENT_START);
- reg_offset += 4;
- }
- }
- else
- {
- fprintf (file, "\tset\t%d, %s\n\tsub\t%s, %s, %s\n",
- size, t1_str, sp_str, t1_str, sp_str);
- if (gmask & FRAME_POINTER_MASK)
- {
- fprintf (file, "\tst\t%s, [%s+%d]\n",
- fp_str, sp_str, reg_offset);
- fprintf (file, "\tadd\t%s, %s, %s\t%s# set up frame pointer\n",
- sp_str, t1_str, fp_str, ASM_COMMENT_START);
- reg_offset += 4;
- }
- }
- if (dwarf2out_do_frame ())
- {
- char *l = dwarf2out_cfi_label ();
- if (gmask & FRAME_POINTER_MASK)
- {
- dwarf2out_reg_save (l, FRAME_POINTER_REGNUM,
- reg_offset - 4 - size);
- dwarf2out_def_cfa (l, FRAME_POINTER_REGNUM, 0);
- }
- else
- dwarf2out_def_cfa (l, STACK_POINTER_REGNUM, size);
- }
- if (gmask & RETURN_ADDR_MASK)
- {
- fprintf (file, "\tst\t%s, [%s+%d]\n",
- reg_names[RETURN_ADDR_REGNUM], sp_str, reg_offset);
- if (dwarf2out_do_frame ())
- dwarf2out_return_save ("", reg_offset - size);
- reg_offset += 4;
- }
- sparc_flat_save_restore (file, sp_str, reg_offset,
- gmask & ~(FRAME_POINTER_MASK | RETURN_ADDR_MASK),
- current_frame_info.fmask,
- "st", "std", -size);
- }
- else
- {
- /* Subtract %sp in two steps, but make sure there is always a
- 64 byte register save area, and %sp is properly aligned. */
- /* Amount to decrement %sp by, the first time. */
- unsigned int size1 = ((size - reg_offset + 64) + 15) & -16;
- /* Offset to register save area from %sp. */
- unsigned int offset = size1 - (size - reg_offset);
-
- if (size1 <= 4096)
- {
- fprintf (file, "\tadd\t%s, %d, %s\n",
- sp_str, -size1, sp_str);
- if (gmask & FRAME_POINTER_MASK)
- {
- fprintf (file, "\tst\t%s, [%s+%d]\n\tsub\t%s, %d, %s\t%s# set up frame pointer\n",
- fp_str, sp_str, offset, sp_str, -size1, fp_str,
- ASM_COMMENT_START);
- offset += 4;
- }
- }
- else
- {
- fprintf (file, "\tset\t%d, %s\n\tsub\t%s, %s, %s\n",
- size1, t1_str, sp_str, t1_str, sp_str);
- if (gmask & FRAME_POINTER_MASK)
- {
- fprintf (file, "\tst\t%s, [%s+%d]\n\tadd\t%s, %s, %s\t%s# set up frame pointer\n",
- fp_str, sp_str, offset, sp_str, t1_str, fp_str,
- ASM_COMMENT_START);
- offset += 4;
- }
- }
- if (dwarf2out_do_frame ())
- {
- char *l = dwarf2out_cfi_label ();
- if (gmask & FRAME_POINTER_MASK)
- {
- dwarf2out_reg_save (l, FRAME_POINTER_REGNUM,
- offset - 4 - size1);
- dwarf2out_def_cfa (l, FRAME_POINTER_REGNUM, 0);
- }
- else
- dwarf2out_def_cfa (l, STACK_POINTER_REGNUM, size1);
- }
- if (gmask & RETURN_ADDR_MASK)
- {
- fprintf (file, "\tst\t%s, [%s+%d]\n",
- reg_names[RETURN_ADDR_REGNUM], sp_str, offset);
- if (dwarf2out_do_frame ())
- /* offset - size1 == reg_offset - size
- if reg_offset were updated above like offset. */
- dwarf2out_return_save ("", offset - size1);
- offset += 4;
- }
- sparc_flat_save_restore (file, sp_str, offset,
- gmask & ~(FRAME_POINTER_MASK | RETURN_ADDR_MASK),
- current_frame_info.fmask,
- "st", "std", -size1);
- fprintf (file, "\tset\t%d, %s\n\tsub\t%s, %s, %s\n",
- size - size1, t1_str, sp_str, t1_str, sp_str);
- if (dwarf2out_do_frame ())
- if (! (gmask & FRAME_POINTER_MASK))
- dwarf2out_def_cfa ("", STACK_POINTER_REGNUM, size);
- }
- }
-
- fprintf (file, "\t%s#PROLOGUE# 1\n", ASM_COMMENT_START);
-}
-
-/* Do any necessary cleanup after a function to restore stack, frame,
- and regs. */
-
-void
-sparc_flat_output_function_epilogue (file, size)
- FILE *file;
- int size;
-{
- rtx epilogue_delay = current_function_epilogue_delay_list;
- int noepilogue = FALSE;
-
- /* This is only for the human reader. */
- fprintf (file, "\t%s#EPILOGUE#\n", ASM_COMMENT_START);
-
- /* The epilogue does not depend on any registers, but the stack
- registers, so we assume that if we have 1 pending nop, it can be
- ignored, and 2 it must be filled (2 nops occur for integer
- multiply and divide). */
-
- size = SPARC_STACK_ALIGN (size);
- size = (!current_frame_info.initialized
- ? sparc_flat_compute_frame_size (size)
- : current_frame_info.total_size);
-
- if (size == 0 && epilogue_delay == 0)
- {
- rtx insn = get_last_insn ();
-
- /* If the last insn was a BARRIER, we don't have to write any code
- because a jump (aka return) was put there. */
- if (GET_CODE (insn) == NOTE)
- insn = prev_nonnote_insn (insn);
- if (insn && GET_CODE (insn) == BARRIER)
- noepilogue = TRUE;
- }
-
- if (!noepilogue)
- {
- unsigned int reg_offset = current_frame_info.reg_offset;
- unsigned int size1;
- char *sp_str = reg_names[STACK_POINTER_REGNUM];
- char *fp_str = reg_names[FRAME_POINTER_REGNUM];
- const char *t1_str = "%g1";
-
- /* In the reload sequence, we don't need to fill the load delay
- slots for most of the loads, also see if we can fill the final
- delay slot if not otherwise filled by the reload sequence. */
-
- if (size > 4095)
- fprintf (file, "\tset\t%d, %s\n", size, t1_str);
-
- if (frame_pointer_needed)
- {
- if (size > 4095)
- fprintf (file,"\tsub\t%s, %s, %s\t\t%s# sp not trusted here\n",
- fp_str, t1_str, sp_str, ASM_COMMENT_START);
- else
- fprintf (file,"\tsub\t%s, %d, %s\t\t%s# sp not trusted here\n",
- fp_str, size, sp_str, ASM_COMMENT_START);
- }
-
- /* Is the entire register save area offsettable from %sp? */
- if (reg_offset < 4096 - 64 * UNITS_PER_WORD)
- {
- size1 = 0;
- }
- else
- {
- /* Restore %sp in two steps, but make sure there is always a
- 64 byte register save area, and %sp is properly aligned. */
- /* Amount to increment %sp by, the first time. */
- size1 = ((reg_offset - 64 - 16) + 15) & -16;
- /* Offset to register save area from %sp. */
- reg_offset = size1 - reg_offset;
-
- fprintf (file, "\tset\t%d, %s\n\tadd\t%s, %s, %s\n",
- size1, t1_str, sp_str, t1_str, sp_str);
- }
-
- /* We must restore the frame pointer and return address reg first
- because they are treated specially by the prologue output code. */
- if (current_frame_info.gmask & FRAME_POINTER_MASK)
- {
- fprintf (file, "\tld\t[%s+%d], %s\n",
- sp_str, reg_offset, fp_str);
- reg_offset += 4;
- }
- if (current_frame_info.gmask & RETURN_ADDR_MASK)
- {
- fprintf (file, "\tld\t[%s+%d], %s\n",
- sp_str, reg_offset, reg_names[RETURN_ADDR_REGNUM]);
- reg_offset += 4;
- }
-
- /* Restore any remaining saved registers. */
- sparc_flat_save_restore (file, sp_str, reg_offset,
- current_frame_info.gmask & ~(FRAME_POINTER_MASK | RETURN_ADDR_MASK),
- current_frame_info.fmask,
- "ld", "ldd", 0);
-
- /* If we had to increment %sp in two steps, record it so the second
- restoration in the epilogue finishes up. */
- if (size1 > 0)
- {
- size -= size1;
- if (size > 4095)
- fprintf (file, "\tset\t%d, %s\n",
- size, t1_str);
- }
-
- if (current_function_returns_struct)
- fprintf (file, "\tjmp\t%%o7+12\n");
- else
- fprintf (file, "\tretl\n");
-
- /* If the only register saved is the return address, we need a
- nop, unless we have an instruction to put into it. Otherwise
- we don't since reloading multiple registers doesn't reference
- the register being loaded. */
-
- if (epilogue_delay)
- {
- if (size)
- abort ();
- final_scan_insn (XEXP (epilogue_delay, 0), file, 1, -2, 1);
- }
-
- else if (size > 4095)
- fprintf (file, "\tadd\t%s, %s, %s\n", sp_str, t1_str, sp_str);
-
- else if (size > 0)
- fprintf (file, "\tadd\t%s, %d, %s\n", sp_str, size, sp_str);
-
- else
- fprintf (file, "\tnop\n");
- }
-
- /* Reset state info for each function. */
- current_frame_info = zero_frame_info;
-
- sparc_output_deferred_case_vectors ();
-}
-
-/* Define the number of delay slots needed for the function epilogue.
-
- On the sparc, we need a slot if either no stack has been allocated,
- or the only register saved is the return register. */
-
-int
-sparc_flat_epilogue_delay_slots ()
-{
- if (!current_frame_info.initialized)
- (void) sparc_flat_compute_frame_size (get_frame_size ());
-
- if (current_frame_info.total_size == 0)
- return 1;
-
- return 0;
-}
-
-/* Return true is TRIAL is a valid insn for the epilogue delay slot.
- Any single length instruction which doesn't reference the stack or frame
- pointer is OK. */
-
-int
-sparc_flat_eligible_for_epilogue_delay (trial, slot)
- rtx trial;
- int slot ATTRIBUTE_UNUSED;
-{
- rtx pat = PATTERN (trial);
-
- if (get_attr_length (trial) != 1)
- return 0;
-
- /* If %g0 is live, there are lots of things we can't handle.
- Rather than trying to find them all now, let's punt and only
- optimize things as necessary. */
- if (TARGET_LIVE_G0)
- return 0;
-
- if (! reg_mentioned_p (stack_pointer_rtx, pat)
- && ! reg_mentioned_p (frame_pointer_rtx, pat))
- return 1;
-
- return 0;
-}
-
-/* Adjust the cost of a scheduling dependency. Return the new cost of
- a dependency LINK or INSN on DEP_INSN. COST is the current cost. */
-
-static int
-supersparc_adjust_cost (insn, link, dep_insn, cost)
- rtx insn;
- rtx link;
- rtx dep_insn;
- int cost;
-{
- enum attr_type insn_type;
-
- if (! recog_memoized (insn))
- return 0;
-
- insn_type = get_attr_type (insn);
-
- if (REG_NOTE_KIND (link) == 0)
- {
- /* Data dependency; DEP_INSN writes a register that INSN reads some
- cycles later. */
-
- /* if a load, then the dependence must be on the memory address;
- add an extra "cycle". Note that the cost could be two cycles
- if the reg was written late in an instruction group; we ca not tell
- here. */
- if (insn_type == TYPE_LOAD || insn_type == TYPE_FPLOAD)
- return cost + 3;
-
- /* Get the delay only if the address of the store is the dependence. */
- if (insn_type == TYPE_STORE || insn_type == TYPE_FPSTORE)
- {
- rtx pat = PATTERN(insn);
- rtx dep_pat = PATTERN (dep_insn);
-
- if (GET_CODE (pat) != SET || GET_CODE (dep_pat) != SET)
- return cost; /* This should not happen! */
-
- /* The dependency between the two instructions was on the data that
- is being stored. Assume that this implies that the address of the
- store is not dependent. */
- if (rtx_equal_p (SET_DEST (dep_pat), SET_SRC (pat)))
- return cost;
-
- return cost + 3; /* An approximation. */
- }
-
- /* A shift instruction cannot receive its data from an instruction
- in the same cycle; add a one cycle penalty. */
- if (insn_type == TYPE_SHIFT)
- return cost + 3; /* Split before cascade into shift. */
- }
- else
- {
- /* Anti- or output- dependency; DEP_INSN reads/writes a register that
- INSN writes some cycles later. */
-
- /* These are only significant for the fpu unit; writing a fp reg before
- the fpu has finished with it stalls the processor. */
-
- /* Reusing an integer register causes no problems. */
- if (insn_type == TYPE_IALU || insn_type == TYPE_SHIFT)
- return 0;
- }
-
- return cost;
-}
-
-static int
-hypersparc_adjust_cost (insn, link, dep_insn, cost)
- rtx insn;
- rtx link;
- rtx dep_insn;
- int cost;
-{
- enum attr_type insn_type, dep_type;
- rtx pat = PATTERN(insn);
- rtx dep_pat = PATTERN (dep_insn);
-
- if (recog_memoized (insn) < 0 || recog_memoized (dep_insn) < 0)
- return cost;
-
- insn_type = get_attr_type (insn);
- dep_type = get_attr_type (dep_insn);
-
- switch (REG_NOTE_KIND (link))
- {
- case 0:
- /* Data dependency; DEP_INSN writes a register that INSN reads some
- cycles later. */
-
- switch (insn_type)
- {
- case TYPE_STORE:
- case TYPE_FPSTORE:
- /* Get the delay iff the address of the store is the dependence. */
- if (GET_CODE (pat) != SET || GET_CODE (dep_pat) != SET)
- return cost;
-
- if (rtx_equal_p (SET_DEST (dep_pat), SET_SRC (pat)))
- return cost;
- return cost + 3;
-
- case TYPE_LOAD:
- case TYPE_SLOAD:
- case TYPE_FPLOAD:
- /* If a load, then the dependence must be on the memory address. If
- the addresses aren't equal, then it might be a false dependency */
- if (dep_type == TYPE_STORE || dep_type == TYPE_FPSTORE)
- {
- if (GET_CODE (pat) != SET || GET_CODE (dep_pat) != SET
- || GET_CODE (SET_DEST (dep_pat)) != MEM
- || GET_CODE (SET_SRC (pat)) != MEM
- || ! rtx_equal_p (XEXP (SET_DEST (dep_pat), 0),
- XEXP (SET_SRC (pat), 0)))
- return cost + 2;
-
- return cost + 8;
- }
- break;
-
- case TYPE_BRANCH:
- /* Compare to branch latency is 0. There is no benefit from
- separating compare and branch. */
- if (dep_type == TYPE_COMPARE)
- return 0;
- /* Floating point compare to branch latency is less than
- compare to conditional move. */
- if (dep_type == TYPE_FPCMP)
- return cost - 1;
- break;
- default:
- break;
- }
- break;
-
- case REG_DEP_ANTI:
- /* Anti-dependencies only penalize the fpu unit. */
- if (insn_type == TYPE_IALU || insn_type == TYPE_SHIFT)
- return 0;
- break;
-
- default:
- break;
- }
-
- return cost;
-}
-
-static int
-ultrasparc_adjust_cost (insn, link, dep_insn, cost)
- rtx insn;
- rtx link;
- rtx dep_insn;
- int cost;
-{
- enum attr_type insn_type, dep_type;
- rtx pat = PATTERN(insn);
- rtx dep_pat = PATTERN (dep_insn);
-
- if (recog_memoized (insn) < 0 || recog_memoized (dep_insn) < 0)
- return cost;
-
- insn_type = get_attr_type (insn);
- dep_type = get_attr_type (dep_insn);
-
- /* Nothing issues in parallel with integer multiplies, so
- mark as zero cost since the scheduler can not do anything
- about it. */
- if (insn_type == TYPE_IMUL)
- return 0;
-
-#define SLOW_FP(dep_type) \
-(dep_type == TYPE_FPSQRT || dep_type == TYPE_FPDIVS || dep_type == TYPE_FPDIVD)
-
- switch (REG_NOTE_KIND (link))
- {
- case 0:
- /* Data dependency; DEP_INSN writes a register that INSN reads some
- cycles later. */
-
- if (dep_type == TYPE_CMOVE)
- {
- /* Instructions that read the result of conditional moves cannot
- be in the same group or the following group. */
- return cost + 1;
- }
-
- switch (insn_type)
- {
- /* UltraSPARC can dual issue a store and an instruction setting
- the value stored, except for divide and square root. */
- case TYPE_FPSTORE:
- if (! SLOW_FP (dep_type))
- return 0;
- return cost;
-
- case TYPE_STORE:
- if (GET_CODE (pat) != SET || GET_CODE (dep_pat) != SET)
- return cost;
-
- if (rtx_equal_p (SET_DEST (dep_pat), SET_SRC (pat)))
- /* The dependency between the two instructions is on the data
- that is being stored. Assume that the address of the store
- is not also dependent. */
- return 0;
- return cost;
-
- case TYPE_LOAD:
- case TYPE_SLOAD:
- case TYPE_FPLOAD:
- /* A load does not return data until at least 11 cycles after
- a store to the same location. 3 cycles are accounted for
- in the load latency; add the other 8 here. */
- if (dep_type == TYPE_STORE || dep_type == TYPE_FPSTORE)
- {
- /* If the addresses are not equal this may be a false
- dependency because pointer aliasing could not be
- determined. Add only 2 cycles in that case. 2 is
- an arbitrary compromise between 8, which would cause
- the scheduler to generate worse code elsewhere to
- compensate for a dependency which might not really
- exist, and 0. */
- if (GET_CODE (pat) != SET || GET_CODE (dep_pat) != SET
- || GET_CODE (SET_SRC (pat)) != MEM
- || GET_CODE (SET_DEST (dep_pat)) != MEM
- || ! rtx_equal_p (XEXP (SET_SRC (pat), 0),
- XEXP (SET_DEST (dep_pat), 0)))
- return cost + 2;
-
- return cost + 8;
- }
- return cost;
-
- case TYPE_BRANCH:
- /* Compare to branch latency is 0. There is no benefit from
- separating compare and branch. */
- if (dep_type == TYPE_COMPARE)
- return 0;
- /* Floating point compare to branch latency is less than
- compare to conditional move. */
- if (dep_type == TYPE_FPCMP)
- return cost - 1;
- return cost;
-
- case TYPE_FPCMOVE:
- /* FMOVR class instructions can not issue in the same cycle
- or the cycle after an instruction which writes any
- integer register. Model this as cost 2 for dependent
- instructions. */
- if ((dep_type == TYPE_IALU || dep_type == TYPE_UNARY
- || dep_type == TYPE_BINARY)
- && cost < 2)
- return 2;
- /* Otherwise check as for integer conditional moves. */
-
- case TYPE_CMOVE:
- /* Conditional moves involving integer registers wait until
- 3 cycles after loads return data. The interlock applies
- to all loads, not just dependent loads, but that is hard
- to model. */
- if (dep_type == TYPE_LOAD || dep_type == TYPE_SLOAD)
- return cost + 3;
- return cost;
-
- default:
- break;
- }
- break;
-
- case REG_DEP_ANTI:
- /* Divide and square root lock destination registers for full latency. */
- if (! SLOW_FP (dep_type))
- return 0;
- break;
-
- case REG_DEP_OUTPUT:
- /* IEU and FPU instruction that have the same destination
- register cannot be grouped together. */
- return cost + 1;
-
- default:
- break;
- }
-
- /* Other costs not accounted for:
- - Single precision floating point loads lock the other half of
- the even/odd register pair.
- - Several hazards associated with ldd/std are ignored because these
- instructions are rarely generated for V9.
- - The floating point pipeline can not have both a single and double
- precision operation active at the same time. Format conversions
- and graphics instructions are given honorary double precision status.
- - call and jmpl are always the first instruction in a group. */
-
- return cost;
-
-#undef SLOW_FP
-}
-
-int
-sparc_adjust_cost(insn, link, dep, cost)
- rtx insn;
- rtx link;
- rtx dep;
- int cost;
-{
- switch (sparc_cpu)
- {
- case PROCESSOR_SUPERSPARC:
- cost = supersparc_adjust_cost (insn, link, dep, cost);
- break;
- case PROCESSOR_HYPERSPARC:
- case PROCESSOR_SPARCLITE86X:
- cost = hypersparc_adjust_cost (insn, link, dep, cost);
- break;
- case PROCESSOR_ULTRASPARC:
- cost = ultrasparc_adjust_cost (insn, link, dep, cost);
- break;
- default:
- break;
- }
- return cost;
-}
-
-/* This describes the state of the UltraSPARC pipeline during
- instruction scheduling. */
-
-#define TMASK(__x) ((unsigned)1 << ((int)(__x)))
-#define UMASK(__x) ((unsigned)1 << ((int)(__x)))
-
-enum ultra_code { NONE=0, /* no insn at all */
- IEU0, /* shifts and conditional moves */
- IEU1, /* condition code setting insns, calls+jumps */
- IEUN, /* all other single cycle ieu insns */
- LSU, /* loads and stores */
- CTI, /* branches */
- FPM, /* FPU pipeline 1, multiplies and divides */
- FPA, /* FPU pipeline 2, all other operations */
- SINGLE, /* single issue instructions */
- NUM_ULTRA_CODES };
-
-static const char *ultra_code_names[NUM_ULTRA_CODES] = {
- "NONE", "IEU0", "IEU1", "IEUN", "LSU", "CTI",
- "FPM", "FPA", "SINGLE" };
-
-struct ultrasparc_pipeline_state {
- /* The insns in this group. */
- rtx group[4];
-
- /* The code for each insn. */
- enum ultra_code codes[4];
-
- /* Which insns in this group have been committed by the
- scheduler. This is how we determine how many more
- can issue this cycle. */
- char commit[4];
-
- /* How many insns in this group. */
- char group_size;
-
- /* Mask of free slots still in this group. */
- char free_slot_mask;
-
- /* The slotter uses the following to determine what other
- insn types can still make their way into this group. */
- char contents [NUM_ULTRA_CODES];
- char num_ieu_insns;
-};
-
-#define ULTRA_NUM_HIST 8
-static struct ultrasparc_pipeline_state ultra_pipe_hist[ULTRA_NUM_HIST];
-static int ultra_cur_hist;
-static int ultra_cycles_elapsed;
-
-#define ultra_pipe (ultra_pipe_hist[ultra_cur_hist])
-
-/* Given TYPE_MASK compute the ultra_code it has. */
-static enum ultra_code
-ultra_code_from_mask (type_mask)
- int type_mask;
-{
- if (type_mask & (TMASK (TYPE_SHIFT) | TMASK (TYPE_CMOVE)))
- return IEU0;
- else if (type_mask & (TMASK (TYPE_COMPARE) |
- TMASK (TYPE_CALL) |
- TMASK (TYPE_UNCOND_BRANCH)))
- return IEU1;
- else if (type_mask & (TMASK (TYPE_IALU) | TMASK (TYPE_BINARY) |
- TMASK (TYPE_MOVE) | TMASK (TYPE_UNARY)))
- return IEUN;
- else if (type_mask & (TMASK (TYPE_LOAD) | TMASK (TYPE_SLOAD) |
- TMASK (TYPE_STORE) | TMASK (TYPE_FPLOAD) |
- TMASK (TYPE_FPSTORE)))
- return LSU;
- else if (type_mask & (TMASK (TYPE_FPMUL) | TMASK (TYPE_FPDIVS) |
- TMASK (TYPE_FPDIVD) | TMASK (TYPE_FPSQRT)))
- return FPM;
- else if (type_mask & (TMASK (TYPE_FPMOVE) | TMASK (TYPE_FPCMOVE) |
- TMASK (TYPE_FP) | TMASK (TYPE_FPCMP)))
- return FPA;
- else if (type_mask & TMASK (TYPE_BRANCH))
- return CTI;
-
- return SINGLE;
-}
-
-/* Check INSN (a conditional move) and make sure that it's
- results are available at this cycle. Return 1 if the
- results are in fact ready. */
-static int
-ultra_cmove_results_ready_p (insn)
- rtx insn;
-{
- struct ultrasparc_pipeline_state *up;
- int entry, slot;
-
- /* If this got dispatched in the previous
- group, the results are not ready. */
- entry = (ultra_cur_hist - 1) % (ULTRA_NUM_HIST - 1);
- up = &ultra_pipe_hist[entry];
- slot = 4;
- while (--slot >= 0)
- if (up->group[slot] == insn)
- return 0;
-
- return 1;
-}
-
-/* Walk backwards in pipeline history looking for FPU
- operations which use a mode different than FPMODE and
- will create a stall if an insn using FPMODE were to be
- dispatched this cycle. */
-static int
-ultra_fpmode_conflict_exists (fpmode)
- enum machine_mode fpmode;
-{
- int hist_ent;
- int hist_lim;
-
- hist_ent = (ultra_cur_hist - 1) % (ULTRA_NUM_HIST - 1);
- if (ultra_cycles_elapsed < 4)
- hist_lim = ultra_cycles_elapsed;
- else
- hist_lim = 4;
- while (hist_lim > 0)
- {
- struct ultrasparc_pipeline_state *up = &ultra_pipe_hist[hist_ent];
- int slot = 4;
-
- while (--slot >= 0)
- {
- rtx insn = up->group[slot];
- enum machine_mode this_mode;
- rtx pat;
-
- if (! insn
- || GET_CODE (insn) != INSN
- || (pat = PATTERN (insn)) == 0
- || GET_CODE (pat) != SET)
- continue;
-
- this_mode = GET_MODE (SET_DEST (pat));
- if ((this_mode != SFmode
- && this_mode != DFmode)
- || this_mode == fpmode)
- continue;
-
- /* If it is not FMOV, FABS, FNEG, FDIV, or FSQRT then
- we will get a stall. Loads and stores are independant
- of these rules. */
- if (GET_CODE (SET_SRC (pat)) != ABS
- && GET_CODE (SET_SRC (pat)) != NEG
- && ((TMASK (get_attr_type (insn)) &
- (TMASK (TYPE_FPDIVS) | TMASK (TYPE_FPDIVD) |
- TMASK (TYPE_FPMOVE) | TMASK (TYPE_FPSQRT) |
- TMASK (TYPE_LOAD) | TMASK (TYPE_STORE))) == 0))
- return 1;
- }
- hist_lim--;
- hist_ent = (hist_ent - 1) % (ULTRA_NUM_HIST - 1);
- }
-
- /* No conflicts, safe to dispatch. */
- return 0;
-}
-
-/* Find an instruction in LIST which has one of the
- type attributes enumerated in TYPE_MASK. START
- says where to begin the search.
-
- NOTE: This scheme depends upon the fact that we
- have less than 32 distinct type attributes. */
-
-static int ultra_types_avail;
-
-static rtx *
-ultra_find_type (type_mask, list, start)
- int type_mask;
- rtx *list;
- int start;
-{
- int i;
-
- /* Short circuit if no such insn exists in the ready
- at the moment. */
- if ((type_mask & ultra_types_avail) == 0)
- return 0;
-
- for (i = start; i >= 0; i--)
- {
- rtx insn = list[i];
-
- if (recog_memoized (insn) >= 0
- && (TMASK(get_attr_type (insn)) & type_mask))
- {
- enum machine_mode fpmode = SFmode;
- rtx pat = 0;
- int slot;
- int check_depend = 0;
- int check_fpmode_conflict = 0;
-
- if (GET_CODE (insn) == INSN
- && (pat = PATTERN(insn)) != 0
- && GET_CODE (pat) == SET
- && !(type_mask & (TMASK (TYPE_STORE) |
- TMASK (TYPE_FPSTORE))))
- {
- check_depend = 1;
- if (GET_MODE (SET_DEST (pat)) == SFmode
- || GET_MODE (SET_DEST (pat)) == DFmode)
- {
- fpmode = GET_MODE (SET_DEST (pat));
- check_fpmode_conflict = 1;
- }
- }
-
- slot = 4;
- while(--slot >= 0)
- {
- rtx slot_insn = ultra_pipe.group[slot];
- rtx slot_pat;
-
- /* Already issued, bad dependency, or FPU
- mode conflict. */
- if (slot_insn != 0
- && (slot_pat = PATTERN (slot_insn)) != 0
- && ((insn == slot_insn)
- || (check_depend == 1
- && GET_CODE (slot_insn) == INSN
- && GET_CODE (slot_pat) == SET
- && ((GET_CODE (SET_DEST (slot_pat)) == REG
- && GET_CODE (SET_SRC (pat)) == REG
- && REGNO (SET_DEST (slot_pat)) ==
- REGNO (SET_SRC (pat)))
- || (GET_CODE (SET_DEST (slot_pat)) == SUBREG
- && GET_CODE (SET_SRC (pat)) == SUBREG
- && REGNO (SUBREG_REG (SET_DEST (slot_pat))) ==
- REGNO (SUBREG_REG (SET_SRC (pat)))
- && SUBREG_WORD (SET_DEST (slot_pat)) ==
- SUBREG_WORD (SET_SRC (pat)))))
- || (check_fpmode_conflict == 1
- && GET_CODE (slot_insn) == INSN
- && GET_CODE (slot_pat) == SET
- && (GET_MODE (SET_DEST (slot_pat)) == SFmode
- || GET_MODE (SET_DEST (slot_pat)) == DFmode)
- && GET_MODE (SET_DEST (slot_pat)) != fpmode)))
- goto next;
- }
-
- /* Check for peculiar result availability and dispatch
- interference situations. */
- if (pat != 0
- && ultra_cycles_elapsed > 0)
- {
- rtx link;
-
- for (link = LOG_LINKS (insn); link; link = XEXP (link, 1))
- {
- rtx link_insn = XEXP (link, 0);
- if (GET_CODE (link_insn) == INSN
- && recog_memoized (link_insn) >= 0
- && (TMASK (get_attr_type (link_insn)) &
- (TMASK (TYPE_CMOVE) | TMASK (TYPE_FPCMOVE)))
- && ! ultra_cmove_results_ready_p (link_insn))
- goto next;
- }
-
- if (check_fpmode_conflict
- && ultra_fpmode_conflict_exists (fpmode))
- goto next;
- }
-
- return &list[i];
- }
- next:
- ;
- }
- return 0;
-}
-
-static void
-ultra_build_types_avail (ready, n_ready)
- rtx *ready;
- int n_ready;
-{
- int i = n_ready - 1;
-
- ultra_types_avail = 0;
- while(i >= 0)
- {
- rtx insn = ready[i];
-
- if (recog_memoized (insn) >= 0)
- ultra_types_avail |= TMASK (get_attr_type (insn));
-
- i -= 1;
- }
-}
-
-/* Place insn pointed to my IP into the pipeline.
- Make element THIS of READY be that insn if it
- is not already. TYPE indicates the pipeline class
- this insn falls into. */
-static void
-ultra_schedule_insn (ip, ready, this, type)
- rtx *ip;
- rtx *ready;
- int this;
- enum ultra_code type;
-{
- int pipe_slot;
- char mask = ultra_pipe.free_slot_mask;
-
- /* Obtain free slot. */
- for (pipe_slot = 0; pipe_slot < 4; pipe_slot++)
- if ((mask & (1 << pipe_slot)) != 0)
- break;
- if (pipe_slot == 4)
- abort ();
-
- /* In it goes, and it hasn't been committed yet. */
- ultra_pipe.group[pipe_slot] = *ip;
- ultra_pipe.codes[pipe_slot] = type;
- ultra_pipe.contents[type] = 1;
- if (UMASK (type) &
- (UMASK (IEUN) | UMASK (IEU0) | UMASK (IEU1)))
- ultra_pipe.num_ieu_insns += 1;
-
- ultra_pipe.free_slot_mask = (mask & ~(1 << pipe_slot));
- ultra_pipe.group_size += 1;
- ultra_pipe.commit[pipe_slot] = 0;
-
- /* Update ready list. */
- if (ip != &ready[this])
- {
- rtx temp = *ip;
-
- *ip = ready[this];
- ready[this] = temp;
- }
-}
-
-/* Advance to the next pipeline group. */
-static void
-ultra_flush_pipeline ()
-{
- ultra_cur_hist = (ultra_cur_hist + 1) % (ULTRA_NUM_HIST - 1);
- ultra_cycles_elapsed += 1;
- bzero ((char *) &ultra_pipe, sizeof ultra_pipe);
- ultra_pipe.free_slot_mask = 0xf;
-}
-
-static int ultra_reorder_called_this_block;
-
-/* Init our data structures for this current block. */
-void
-ultrasparc_sched_init (dump, sched_verbose)
- FILE *dump ATTRIBUTE_UNUSED;
- int sched_verbose ATTRIBUTE_UNUSED;
-{
- bzero ((char *) ultra_pipe_hist, sizeof ultra_pipe_hist);
- ultra_cur_hist = 0;
- ultra_cycles_elapsed = 0;
- ultra_reorder_called_this_block = 0;
- ultra_pipe.free_slot_mask = 0xf;
-}
-
-/* INSN has been scheduled, update pipeline commit state
- and return how many instructions are still to be
- scheduled in this group. */
-int
-ultrasparc_variable_issue (insn)
- rtx insn;
-{
- struct ultrasparc_pipeline_state *up = &ultra_pipe;
- int i, left_to_fire;
-
- left_to_fire = 0;
- for (i = 0; i < 4; i++)
- {
- if (up->group[i] == 0)
- continue;
-
- if (up->group[i] == insn)
- {
- up->commit[i] = 1;
- }
- else if (! up->commit[i])
- left_to_fire++;
- }
-
- return left_to_fire;
-}
-
-/* In actual_hazard_this_instance, we may have yanked some
- instructions from the ready list due to conflict cost
- adjustments. If so, and such an insn was in our pipeline
- group, remove it and update state. */
-static void
-ultra_rescan_pipeline_state (ready, n_ready)
- rtx *ready;
- int n_ready;
-{
- struct ultrasparc_pipeline_state *up = &ultra_pipe;
- int i;
-
- for (i = 0; i < 4; i++)
- {
- rtx insn = up->group[i];
- int j;
-
- if (! insn)
- continue;
-
- /* If it has been committed, then it was removed from
- the ready list because it was actually scheduled,
- and that is not the case we are searching for here. */
- if (up->commit[i] != 0)
- continue;
-
- for (j = n_ready - 1; j >= 0; j--)
- if (ready[j] == insn)
- break;
-
- /* If we didn't find it, toss it. */
- if (j < 0)
- {
- enum ultra_code ucode = up->codes[i];
-
- up->group[i] = 0;
- up->codes[i] = NONE;
- up->contents[ucode] = 0;
- if (UMASK (ucode) &
- (UMASK (IEUN) | UMASK (IEU0) | UMASK (IEU1)))
- up->num_ieu_insns -= 1;
-
- up->free_slot_mask |= (1 << i);
- up->group_size -= 1;
- up->commit[i] = 0;
- }
- }
-}
-
-void
-ultrasparc_sched_reorder (dump, sched_verbose, ready, n_ready)
- FILE *dump;
- int sched_verbose;
- rtx *ready;
- int n_ready;
-{
- struct ultrasparc_pipeline_state *up = &ultra_pipe;
- int i, this_insn;
-
- /* We get called once unnecessarily per block of insns
- scheduled. */
- if (ultra_reorder_called_this_block == 0)
- {
- ultra_reorder_called_this_block = 1;
- return;
- }
-
- if (sched_verbose)
- {
- int n;
-
- fprintf (dump, "\n;;\tUltraSPARC Looking at [");
- for (n = n_ready - 1; n >= 0; n--)
- {
- rtx insn = ready[n];
- enum ultra_code ucode;
-
- if (recog_memoized (insn) < 0)
- continue;
- ucode = ultra_code_from_mask (TMASK (get_attr_type (insn)));
- if (n != 0)
- fprintf (dump, "%s(%d) ",
- ultra_code_names[ucode],
- INSN_UID (insn));
- else
- fprintf (dump, "%s(%d)",
- ultra_code_names[ucode],
- INSN_UID (insn));
- }
- fprintf (dump, "]\n");
- }
-
- this_insn = n_ready - 1;
-
- /* Skip over junk we don't understand. */
- while ((this_insn >= 0)
- && recog_memoized (ready[this_insn]) < 0)
- this_insn--;
-
- ultra_build_types_avail (ready, this_insn + 1);
-
- while (this_insn >= 0) {
- int old_group_size = up->group_size;
-
- if (up->group_size != 0)
- {
- int num_committed;
-
- num_committed = (up->commit[0] + up->commit[1] +
- up->commit[2] + up->commit[3]);
- /* If nothing has been commited from our group, or all of
- them have. Clear out the (current cycle's) pipeline
- state and start afresh. */
- if (num_committed == 0
- || num_committed == up->group_size)
- {
- ultra_flush_pipeline ();
- up = &ultra_pipe;
- old_group_size = 0;
- }
- else
- {
- /* OK, some ready list insns got requeued and thus removed
- from the ready list. Account for this fact. */
- ultra_rescan_pipeline_state (ready, n_ready);
-
- /* Something "changed", make this look like a newly
- formed group so the code at the end of the loop
- knows that progress was in fact made. */
- if (up->group_size != old_group_size)
- old_group_size = 0;
- }
- }
-
- if (up->group_size == 0)
- {
- /* If the pipeline is (still) empty and we have any single
- group insns, get them out now as this is a good time. */
- rtx *ip = ultra_find_type ((TMASK (TYPE_RETURN) | TMASK (TYPE_ADDRESS) |
- TMASK (TYPE_IMUL) | TMASK (TYPE_CMOVE) |
- TMASK (TYPE_MULTI) | TMASK (TYPE_MISC)),
- ready, this_insn);
- if (ip)
- {
- ultra_schedule_insn (ip, ready, this_insn, SINGLE);
- break;
- }
-
- /* If we are not in the process of emptying out the pipe, try to
- obtain an instruction which must be the first in it's group. */
- ip = ultra_find_type ((TMASK (TYPE_CALL) |
- TMASK (TYPE_CALL_NO_DELAY_SLOT) |
- TMASK (TYPE_UNCOND_BRANCH)),
- ready, this_insn);
- if (ip)
- {
- ultra_schedule_insn (ip, ready, this_insn, IEU1);
- this_insn--;
- }
- else if ((ip = ultra_find_type ((TMASK (TYPE_FPDIVS) |
- TMASK (TYPE_FPDIVD) |
- TMASK (TYPE_FPSQRT)),
- ready, this_insn)) != 0)
- {
- ultra_schedule_insn (ip, ready, this_insn, FPM);
- this_insn--;
- }
- }
-
- /* Try to fill the integer pipeline. First, look for an IEU0 specific
- operation. We can't do more IEU operations if the first 3 slots are
- all full or we have dispatched two IEU insns already. */
- if ((up->free_slot_mask & 0x7) != 0
- && up->num_ieu_insns < 2
- && up->contents[IEU0] == 0
- && up->contents[IEUN] == 0)
- {
- rtx *ip = ultra_find_type (TMASK(TYPE_SHIFT), ready, this_insn);
- if (ip)
- {
- ultra_schedule_insn (ip, ready, this_insn, IEU0);
- this_insn--;
- }
- }
-
- /* If we can, try to find an IEU1 specific or an unnamed
- IEU instruction. */
- if ((up->free_slot_mask & 0x7) != 0
- && up->num_ieu_insns < 2)
- {
- rtx *ip = ultra_find_type ((TMASK (TYPE_IALU) | TMASK (TYPE_BINARY) |
- TMASK (TYPE_MOVE) | TMASK (TYPE_UNARY) |
- (up->contents[IEU1] == 0 ? TMASK (TYPE_COMPARE) : 0)),
- ready, this_insn);
- if (ip)
- {
- rtx insn = *ip;
-
- ultra_schedule_insn (ip, ready, this_insn,
- (!up->contents[IEU1]
- && get_attr_type (insn) == TYPE_COMPARE)
- ? IEU1 : IEUN);
- this_insn--;
- }
- }
-
- /* If only one IEU insn has been found, try to find another unnamed
- IEU operation or an IEU1 specific one. */
- if ((up->free_slot_mask & 0x7) != 0
- && up->num_ieu_insns < 2)
- {
- rtx *ip;
- int tmask = (TMASK (TYPE_IALU) | TMASK (TYPE_BINARY) |
- TMASK (TYPE_MOVE) | TMASK (TYPE_UNARY));
-
- if (!up->contents[IEU1])
- tmask |= TMASK (TYPE_COMPARE);
- ip = ultra_find_type (tmask, ready, this_insn);
- if (ip)
- {
- rtx insn = *ip;
-
- ultra_schedule_insn (ip, ready, this_insn,
- (!up->contents[IEU1]
- && get_attr_type (insn) == TYPE_COMPARE)
- ? IEU1 : IEUN);
- this_insn--;
- }
- }
-
- /* Try for a load or store, but such an insn can only be issued
- if it is within' one of the first 3 slots. */
- if ((up->free_slot_mask & 0x7) != 0
- && up->contents[LSU] == 0)
- {
- rtx *ip = ultra_find_type ((TMASK (TYPE_LOAD) | TMASK (TYPE_SLOAD) |
- TMASK (TYPE_STORE) | TMASK (TYPE_FPLOAD) |
- TMASK (TYPE_FPSTORE)), ready, this_insn);
- if (ip)
- {
- ultra_schedule_insn (ip, ready, this_insn, LSU);
- this_insn--;
- }
- }
-
- /* Now find FPU operations, first FPM class. But not divisions or
- square-roots because those will break the group up. Unlike all
- the previous types, these can go in any slot. */
- if (up->free_slot_mask != 0
- && up->contents[FPM] == 0)
- {
- rtx *ip = ultra_find_type (TMASK (TYPE_FPMUL), ready, this_insn);
- if (ip)
- {
- ultra_schedule_insn (ip, ready, this_insn, FPM);
- this_insn--;
- }
- }
-
- /* Continue on with FPA class if we have not filled the group already. */
- if (up->free_slot_mask != 0
- && up->contents[FPA] == 0)
- {
- rtx *ip = ultra_find_type ((TMASK (TYPE_FPMOVE) | TMASK (TYPE_FPCMOVE) |
- TMASK (TYPE_FP) | TMASK (TYPE_FPCMP)),
- ready, this_insn);
- if (ip)
- {
- ultra_schedule_insn (ip, ready, this_insn, FPA);
- this_insn--;
- }
- }
-
- /* Finally, maybe stick a branch in here. */
- if (up->free_slot_mask != 0
- && up->contents[CTI] == 0)
- {
- rtx *ip = ultra_find_type (TMASK (TYPE_BRANCH), ready, this_insn);
-
- /* Try to slip in a branch only if it is one of the
- next 2 in the ready list. */
- if (ip && ((&ready[this_insn] - ip) < 2))
- {
- ultra_schedule_insn (ip, ready, this_insn, CTI);
- this_insn--;
- }
- }
-
- up->group_size = 0;
- for (i = 0; i < 4; i++)
- if ((up->free_slot_mask & (1 << i)) == 0)
- up->group_size++;
-
- /* See if we made any progress... */
- if (old_group_size != up->group_size)
- break;
-
- /* Clean out the (current cycle's) pipeline state
- and try once more. If we placed no instructions
- into the pipeline at all, it means a real hard
- conflict exists with some earlier issued instruction
- so we must advance to the next cycle to clear it up. */
- if (up->group_size == 0)
- {
- ultra_flush_pipeline ();
- up = &ultra_pipe;
- }
- else
- {
- bzero ((char *) &ultra_pipe, sizeof ultra_pipe);
- ultra_pipe.free_slot_mask = 0xf;
- }
- }
-
- if (sched_verbose)
- {
- int n, gsize;
-
- fprintf (dump, ";;\tUltraSPARC Launched [");
- gsize = up->group_size;
- for (n = 0; n < 4; n++)
- {
- rtx insn = up->group[n];
-
- if (! insn)
- continue;
-
- gsize -= 1;
- if (gsize != 0)
- fprintf (dump, "%s(%d) ",
- ultra_code_names[up->codes[n]],
- INSN_UID (insn));
- else
- fprintf (dump, "%s(%d)",
- ultra_code_names[up->codes[n]],
- INSN_UID (insn));
- }
- fprintf (dump, "]\n");
- }
-}
-
-int
-sparc_issue_rate ()
-{
- switch (sparc_cpu)
- {
- default:
- return 1;
- case PROCESSOR_V9:
- /* Assume V9 processors are capable of at least dual-issue. */
- return 2;
- case PROCESSOR_SUPERSPARC:
- return 3;
- case PROCESSOR_HYPERSPARC:
- case PROCESSOR_SPARCLITE86X:
- return 2;
- case PROCESSOR_ULTRASPARC:
- return 4;
- }
-}
-
-static int
-set_extends(x, insn)
- rtx x, insn;
-{
- register rtx pat = PATTERN (insn);
-
- switch (GET_CODE (SET_SRC (pat)))
- {
- /* Load and some shift instructions zero extend. */
- case MEM:
- case ZERO_EXTEND:
- /* sethi clears the high bits */
- case HIGH:
- /* LO_SUM is used with sethi. sethi cleared the high
- bits and the values used with lo_sum are positive */
- case LO_SUM:
- /* Store flag stores 0 or 1 */
- case LT: case LTU:
- case GT: case GTU:
- case LE: case LEU:
- case GE: case GEU:
- case EQ:
- case NE:
- return 1;
- case AND:
- {
- rtx op1 = XEXP (SET_SRC (pat), 1);
- if (GET_CODE (op1) == CONST_INT)
- return INTVAL (op1) >= 0;
- if (GET_CODE (XEXP (SET_SRC (pat), 0)) == REG
- && sparc_check_64 (XEXP (SET_SRC (pat), 0), insn) == 1)
- return 1;
- if (GET_CODE (op1) == REG
- && sparc_check_64 ((op1), insn) == 1)
- return 1;
- }
- case ASHIFT:
- case LSHIFTRT:
- return GET_MODE (SET_SRC (pat)) == SImode;
- /* Positive integers leave the high bits zero. */
- case CONST_DOUBLE:
- return ! (CONST_DOUBLE_LOW (x) & 0x80000000);
- case CONST_INT:
- return ! (INTVAL (x) & 0x80000000);
- case ASHIFTRT:
- case SIGN_EXTEND:
- return - (GET_MODE (SET_SRC (pat)) == SImode);
- default:
- return 0;
- }
-}
-
-/* We _ought_ to have only one kind per function, but... */
-static rtx sparc_addr_diff_list;
-static rtx sparc_addr_list;
-
-void
-sparc_defer_case_vector (lab, vec, diff)
- rtx lab, vec;
- int diff;
-{
- vec = gen_rtx_EXPR_LIST (VOIDmode, lab, vec);
- if (diff)
- sparc_addr_diff_list
- = gen_rtx_EXPR_LIST (VOIDmode, vec, sparc_addr_diff_list);
- else
- sparc_addr_list = gen_rtx_EXPR_LIST (VOIDmode, vec, sparc_addr_list);
-}
-
-static void
-sparc_output_addr_vec (vec)
- rtx vec;
-{
- rtx lab = XEXP (vec, 0), body = XEXP (vec, 1);
- int idx, vlen = XVECLEN (body, 0);
-
-#ifdef ASM_OUTPUT_ADDR_VEC_START
- ASM_OUTPUT_ADDR_VEC_START (asm_out_file);
-#endif
-
-#ifdef ASM_OUTPUT_CASE_LABEL
- ASM_OUTPUT_CASE_LABEL (asm_out_file, "L", CODE_LABEL_NUMBER (lab),
- NEXT_INSN (lab));
-#else
- ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L", CODE_LABEL_NUMBER (lab));
-#endif
-
- for (idx = 0; idx < vlen; idx++)
- {
- ASM_OUTPUT_ADDR_VEC_ELT
- (asm_out_file, CODE_LABEL_NUMBER (XEXP (XVECEXP (body, 0, idx), 0)));
- }
-
-#ifdef ASM_OUTPUT_ADDR_VEC_END
- ASM_OUTPUT_ADDR_VEC_END (asm_out_file);
-#endif
-}
-
-static void
-sparc_output_addr_diff_vec (vec)
- rtx vec;
-{
- rtx lab = XEXP (vec, 0), body = XEXP (vec, 1);
- rtx base = XEXP (XEXP (body, 0), 0);
- int idx, vlen = XVECLEN (body, 1);
-
-#ifdef ASM_OUTPUT_ADDR_VEC_START
- ASM_OUTPUT_ADDR_VEC_START (asm_out_file);
-#endif
-
-#ifdef ASM_OUTPUT_CASE_LABEL
- ASM_OUTPUT_CASE_LABEL (asm_out_file, "L", CODE_LABEL_NUMBER (lab),
- NEXT_INSN (lab));
-#else
- ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "L", CODE_LABEL_NUMBER (lab));
-#endif
-
- for (idx = 0; idx < vlen; idx++)
- {
- ASM_OUTPUT_ADDR_DIFF_ELT
- (asm_out_file,
- body,
- CODE_LABEL_NUMBER (XEXP (XVECEXP (body, 1, idx), 0)),
- CODE_LABEL_NUMBER (base));
- }
-
-#ifdef ASM_OUTPUT_ADDR_VEC_END
- ASM_OUTPUT_ADDR_VEC_END (asm_out_file);
-#endif
-}
-
-static void
-sparc_output_deferred_case_vectors ()
-{
- rtx t;
- int align;
-
- if (sparc_addr_list == NULL_RTX
- && sparc_addr_diff_list == NULL_RTX)
- return;
-
- /* Align to cache line in the function's code section. */
- function_section (current_function_decl);
-
- align = floor_log2 (FUNCTION_BOUNDARY / BITS_PER_UNIT);
- if (align > 0)
- ASM_OUTPUT_ALIGN (asm_out_file, align);
-
- for (t = sparc_addr_list; t ; t = XEXP (t, 1))
- sparc_output_addr_vec (XEXP (t, 0));
- for (t = sparc_addr_diff_list; t ; t = XEXP (t, 1))
- sparc_output_addr_diff_vec (XEXP (t, 0));
-
- sparc_addr_list = sparc_addr_diff_list = NULL_RTX;
-}
-
-/* Return 0 if the high 32 bits of X (the low word of X, if DImode) are
- unknown. Return 1 if the high bits are zero, -1 if the register is
- sign extended. */
-int
-sparc_check_64 (x, insn)
- rtx x, insn;
-{
- /* If a register is set only once it is safe to ignore insns this
- code does not know how to handle. The loop will either recognize
- the single set and return the correct value or fail to recognize
- it and return 0. */
- int set_once = 0;
-
- if (GET_CODE (x) == REG
- && flag_expensive_optimizations
- && REG_N_SETS (REGNO (x)) == 1)
- set_once = 1;
-
- if (insn == 0)
- {
- if (set_once)
- insn = get_last_insn_anywhere ();
- else
- return 0;
- }
-
- while ((insn = PREV_INSN (insn)))
- {
- switch (GET_CODE (insn))
- {
- case JUMP_INSN:
- case NOTE:
- break;
- case CODE_LABEL:
- case CALL_INSN:
- default:
- if (! set_once)
- return 0;
- break;
- case INSN:
- {
- rtx pat = PATTERN (insn);
- if (GET_CODE (pat) != SET)
- return 0;
- if (rtx_equal_p (x, SET_DEST (pat)))
- return set_extends (x, insn);
- if (reg_overlap_mentioned_p (SET_DEST (pat), x))
- return 0;
- }
- }
- }
- return 0;
-}
-
-char *
-sparc_v8plus_shift (operands, insn, opcode)
- rtx *operands;
- rtx insn;
- char *opcode;
-{
- static char asm_code[60];
-
- if (GET_CODE (operands[3]) == SCRATCH)
- operands[3] = operands[0];
- if (GET_CODE (operands[1]) == CONST_INT)
- {
- output_asm_insn ("mov %1,%3", operands);
- }
- else
- {
- output_asm_insn ("sllx %H1,32,%3", operands);
- if (sparc_check_64 (operands[1], insn) <= 0)
- output_asm_insn ("srl %L1,0,%L1", operands);
- output_asm_insn ("or %L1,%3,%3", operands);
- }
-
- strcpy(asm_code, opcode);
- if (which_alternative != 2)
- return strcat (asm_code, " %0,%2,%L0\n\tsrlx %L0,32,%H0");
- else
- return strcat (asm_code, " %3,%2,%3\n\tsrlx %3,32,%H0\n\tmov %3,%L0");
-}
-
-
-/* Return 1 if DEST and SRC reference only global and in registers. */
-
-int
-sparc_return_peephole_ok (dest, src)
- rtx dest, src;
-{
- if (! TARGET_V9)
- return 0;
- if (current_function_uses_only_leaf_regs)
- return 0;
- if (GET_CODE (src) != CONST_INT
- && (GET_CODE (src) != REG || ! IN_OR_GLOBAL_P (src)))
- return 0;
- return IN_OR_GLOBAL_P (dest);
-}
-
-/* Output assembler code to FILE to increment profiler label # LABELNO
- for profiling a function entry.
-
- 32 bit sparc uses %g2 as the STATIC_CHAIN_REGNUM which gets clobbered
- during profiling so we need to save/restore it around the call to mcount.
- We're guaranteed that a save has just been done, and we use the space
- allocated for intreg/fpreg value passing. */
-
-void
-sparc_function_profiler (file, labelno)
- FILE *file;
- int labelno;
-{
- char buf[32];
- ASM_GENERATE_INTERNAL_LABEL (buf, "LP", labelno);
-
- if (! TARGET_ARCH64)
- fputs ("\tst\t%g2,[%fp-4]\n", file);
-
- fputs ("\tsethi\t%hi(", file);
- assemble_name (file, buf);
- fputs ("),%o0\n", file);
-
- fputs ("\tcall\t", file);
- assemble_name (file, MCOUNT_FUNCTION);
- putc ('\n', file);
-
- fputs ("\t or\t%o0,%lo(", file);
- assemble_name (file, buf);
- fputs ("),%o0\n", file);
-
- if (! TARGET_ARCH64)
- fputs ("\tld\t[%fp-4],%g2\n", file);
-}
-
-
-/* The following macro shall output assembler code to FILE
- to initialize basic-block profiling.
-
- If profile_block_flag == 2
-
- Output code to call the subroutine `__bb_init_trace_func'
- and pass two parameters to it. The first parameter is
- the address of a block allocated in the object module.
- The second parameter is the number of the first basic block
- of the function.
-
- The name of the block is a local symbol made with this statement:
-
- ASM_GENERATE_INTERNAL_LABEL (BUFFER, "LPBX", 0);
-
- Of course, since you are writing the definition of
- `ASM_GENERATE_INTERNAL_LABEL' as well as that of this macro, you
- can take a short cut in the definition of this macro and use the
- name that you know will result.
-
- The number of the first basic block of the function is
- passed to the macro in BLOCK_OR_LABEL.
-
- If described in a virtual assembler language the code to be
- output looks like:
-
- parameter1 <- LPBX0
- parameter2 <- BLOCK_OR_LABEL
- call __bb_init_trace_func
-
- else if profile_block_flag != 0
-
- Output code to call the subroutine `__bb_init_func'
- and pass one single parameter to it, which is the same
- as the first parameter to `__bb_init_trace_func'.
-
- The first word of this parameter is a flag which will be nonzero if
- the object module has already been initialized. So test this word
- first, and do not call `__bb_init_func' if the flag is nonzero.
- Note: When profile_block_flag == 2 the test need not be done
- but `__bb_init_trace_func' *must* be called.
-
- BLOCK_OR_LABEL may be used to generate a label number as a
- branch destination in case `__bb_init_func' will not be called.
-
- If described in a virtual assembler language the code to be
- output looks like:
-
- cmp (LPBX0),0
- jne local_label
- parameter1 <- LPBX0
- call __bb_init_func
- local_label:
-
-*/
-
-void
-sparc_function_block_profiler(file, block_or_label)
- FILE *file;
- int block_or_label;
-{
- char LPBX[32];
- ASM_GENERATE_INTERNAL_LABEL (LPBX, "LPBX", 0);
-
- if (profile_block_flag == 2)
- {
- fputs ("\tsethi\t%hi(", file);
- assemble_name (file, LPBX);
- fputs ("),%o0\n", file);
-
- fprintf (file, "\tsethi\t%%hi(%d),%%o1\n", block_or_label);
-
- fputs ("\tor\t%o0,%lo(", file);
- assemble_name (file, LPBX);
- fputs ("),%o0\n", file);
-
- fprintf (file, "\tcall\t%s__bb_init_trace_func\n", user_label_prefix);
-
- fprintf (file, "\t or\t%%o1,%%lo(%d),%%o1\n", block_or_label);
- }
- else if (profile_block_flag != 0)
- {
- char LPBY[32];
- ASM_GENERATE_INTERNAL_LABEL (LPBY, "LPBY", block_or_label);
-
- fputs ("\tsethi\t%hi(", file);
- assemble_name (file, LPBX);
- fputs ("),%o0\n", file);
-
- fputs ("\tld\t[%lo(", file);
- assemble_name (file, LPBX);
- fputs (")+%o0],%o1\n", file);
-
- fputs ("\ttst\t%o1\n", file);
-
- if (TARGET_V9)
- {
- fputs ("\tbne,pn\t%icc,", file);
- assemble_name (file, LPBY);
- putc ('\n', file);
- }
- else
- {
- fputs ("\tbne\t", file);
- assemble_name (file, LPBY);
- putc ('\n', file);
- }
-
- fputs ("\t or\t%o0,%lo(", file);
- assemble_name (file, LPBX);
- fputs ("),%o0\n", file);
-
- fprintf (file, "\tcall\t%s__bb_init_func\n\t nop\n", user_label_prefix);
-
- ASM_OUTPUT_INTERNAL_LABEL (file, "LPBY", block_or_label);
- }
-}
-
-/* The following macro shall output assembler code to FILE
- to increment a counter associated with basic block number BLOCKNO.
-
- If profile_block_flag == 2
-
- Output code to initialize the global structure `__bb' and
- call the function `__bb_trace_func' which will increment the
- counter.
-
- `__bb' consists of two words. In the first word the number
- of the basic block has to be stored. In the second word
- the address of a block allocated in the object module
- has to be stored.
-
- The basic block number is given by BLOCKNO.
-
- The address of the block is given by the label created with
-
- ASM_GENERATE_INTERNAL_LABEL (BUFFER, "LPBX", 0);
-
- by FUNCTION_BLOCK_PROFILER.
-
- Of course, since you are writing the definition of
- `ASM_GENERATE_INTERNAL_LABEL' as well as that of this macro, you
- can take a short cut in the definition of this macro and use the
- name that you know will result.
-
- If described in a virtual assembler language the code to be
- output looks like:
-
- move BLOCKNO -> (__bb)
- move LPBX0 -> (__bb+4)
- call __bb_trace_func
-
- Note that function `__bb_trace_func' must not change the
- machine state, especially the flag register. To grant
- this, you must output code to save and restore registers
- either in this macro or in the macros MACHINE_STATE_SAVE
- and MACHINE_STATE_RESTORE. The last two macros will be
- used in the function `__bb_trace_func', so you must make
- sure that the function prologue does not change any
- register prior to saving it with MACHINE_STATE_SAVE.
-
- else if profile_block_flag != 0
-
- Output code to increment the counter directly.
- Basic blocks are numbered separately from zero within each
- compiled object module. The count associated with block number
- BLOCKNO is at index BLOCKNO in an array of words; the name of
- this array is a local symbol made with this statement:
-
- ASM_GENERATE_INTERNAL_LABEL (BUFFER, "LPBX", 2);
-
- Of course, since you are writing the definition of
- `ASM_GENERATE_INTERNAL_LABEL' as well as that of this macro, you
- can take a short cut in the definition of this macro and use the
- name that you know will result.
-
- If described in a virtual assembler language, the code to be
- output looks like:
-
- inc (LPBX2+4*BLOCKNO)
-
-*/
-
-void
-sparc_block_profiler(file, blockno)
- FILE *file;
- int blockno;
-{
- char LPBX[32];
-
- if (profile_block_flag == 2)
- {
- ASM_GENERATE_INTERNAL_LABEL (LPBX, "LPBX", 0);
-
- fprintf (file, "\tsethi\t%%hi(%s__bb),%%g1\n", user_label_prefix);
- fprintf (file, "\tsethi\t%%hi(%d),%%g2\n", blockno);
- fprintf (file, "\tor\t%%g1,%%lo(%s__bb),%%g1\n", user_label_prefix);
- fprintf (file, "\tor\t%%g2,%%lo(%d),%%g2\n", blockno);
-
- fputs ("\tst\t%g2,[%g1]\n", file);
-
- fputs ("\tsethi\t%hi(", file);
- assemble_name (file, LPBX);
- fputs ("),%g2\n", file);
-
- fputs ("\tor\t%g2,%lo(", file);
- assemble_name (file, LPBX);
- fputs ("),%g2\n", file);
-
- fputs ("\tst\t%g2,[%g1+4]\n", file);
- fputs ("\tmov\t%o7,%g2\n", file);
-
- fprintf (file, "\tcall\t%s__bb_trace_func\n\t nop\n", user_label_prefix);
-
- fputs ("\tmov\t%g2,%o7\n", file);
- }
- else if (profile_block_flag != 0)
- {
- ASM_GENERATE_INTERNAL_LABEL (LPBX, "LPBX", 2);
-
- fputs ("\tsethi\t%hi(", file);
- assemble_name (file, LPBX);
- fprintf (file, "+%d),%%g1\n", blockno*4);
-
- fputs ("\tld\t[%g1+%lo(", file);
- assemble_name (file, LPBX);
- fprintf (file, "+%d)],%%g2\n", blockno*4);
-
- fputs ("\tadd\t%g2,1,%g2\n", file);
-
- fputs ("\tst\t%g2,[%g1+%lo(", file);
- assemble_name (file, LPBX);
- fprintf (file, "+%d)]\n", blockno*4);
- }
-}
-
-/* The following macro shall output assembler code to FILE
- to indicate a return from function during basic-block profiling.
-
- If profile_block_flag == 2:
-
- Output assembler code to call function `__bb_trace_ret'.
-
- Note that function `__bb_trace_ret' must not change the
- machine state, especially the flag register. To grant
- this, you must output code to save and restore registers
- either in this macro or in the macros MACHINE_STATE_SAVE_RET
- and MACHINE_STATE_RESTORE_RET. The last two macros will be
- used in the function `__bb_trace_ret', so you must make
- sure that the function prologue does not change any
- register prior to saving it with MACHINE_STATE_SAVE_RET.
-
- else if profile_block_flag != 0:
-
- The macro will not be used, so it need not distinguish
- these cases.
-*/
-
-void
-sparc_function_block_profiler_exit(file)
- FILE *file;
-{
- if (profile_block_flag == 2)
- fprintf (file, "\tcall\t%s__bb_trace_ret\n\t nop\n", user_label_prefix);
- else
- abort ();
-}
diff --git a/contrib/gcc/config/sparc/sparc.h b/contrib/gcc/config/sparc/sparc.h
deleted file mode 100644
index ad11d74afc14..000000000000
--- a/contrib/gcc/config/sparc/sparc.h
+++ /dev/null
@@ -1,3309 +0,0 @@
-/* Definitions of target machine for GNU compiler, for Sun SPARC.
- Copyright (C) 1987, 88, 89, 92, 94-98, 1999 Free Software Foundation, Inc.
- Contributed by Michael Tiemann (tiemann@cygnus.com).
- 64 bit SPARC V9 support by Michael Tiemann, Jim Wilson, and Doug Evans,
- at Cygnus Support.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-/* Note that some other tm.h files include this one and then override
- whatever definitions are necessary. */
-
-/* Specify this in a cover file to provide bi-architecture (32/64) support. */
-/* #define SPARC_BI_ARCH */
-
-/* Macro used later in this file to determine default architecture. */
-#define DEFAULT_ARCH32_P ((TARGET_DEFAULT & MASK_64BIT) == 0)
-
-/* TARGET_ARCH{32,64} are the main macros to decide which of the two
- architectures to compile for. We allow targets to choose compile time or
- runtime selection. */
-#ifdef SPARC_BI_ARCH
-#ifdef IN_LIBGCC2
-#if defined(__sparcv9) || defined(__sparcv_v9) || defined(__arch64__)
-#define TARGET_ARCH32 0
-#else
-#define TARGET_ARCH32 1
-#endif /* V9 sparc */
-#else
-#define TARGET_ARCH32 (! TARGET_64BIT)
-#endif /* IN_LIBGCC2 */
-#else
-#define TARGET_ARCH32 (DEFAULT_ARCH32_P)
-#endif /* SPARC_BI_ARCH */
-#define TARGET_ARCH64 (! TARGET_ARCH32)
-
-/* Code model selection.
- -mcmodel is used to select the v9 code model.
- Different code models aren't supported for v8 code.
-
- TARGET_CM_32: 32 bit address space, top 32 bits = 0,
- pointers are 32 bits. Note that this isn't intended
- to imply a v8 abi.
-
- TARGET_CM_MEDLOW: 32 bit address space, top 32 bits = 0,
- avoid generating %uhi and %ulo terms,
- pointers are 64 bits.
-
- TARGET_CM_MEDMID: 64 bit address space.
- The executable must be in the low 16 TB of memory.
- This corresponds to the low 44 bits, and the %[hml]44
- relocs are used. The text segment has a maximum size
- of 31 bits.
-
- TARGET_CM_MEDANY: 64 bit address space.
- The text and data segments have a maximum size of 31
- bits and may be located anywhere. The maximum offset
- from any instruction to the label _GLOBAL_OFFSET_TABLE_
- is 31 bits.
-
- TARGET_CM_EMBMEDANY: 64 bit address space.
- The text and data segments have a maximum size of 31 bits
- and may be located anywhere. Register %g4 contains
- the start address of the data segment.
-*/
-
-enum cmodel {
- CM_32,
- CM_MEDLOW,
- CM_MEDMID,
- CM_MEDANY,
- CM_EMBMEDANY
-};
-
-/* Value of -mcmodel specified by user. */
-extern const char *sparc_cmodel_string;
-/* One of CM_FOO. */
-extern enum cmodel sparc_cmodel;
-
-/* V9 code model selection. */
-#define TARGET_CM_MEDLOW (sparc_cmodel == CM_MEDLOW)
-#define TARGET_CM_MEDMID (sparc_cmodel == CM_MEDMID)
-#define TARGET_CM_MEDANY (sparc_cmodel == CM_MEDANY)
-#define TARGET_CM_EMBMEDANY (sparc_cmodel == CM_EMBMEDANY)
-
-#define SPARC_DEFAULT_CMODEL CM_MEDLOW
-
-/* This is call-clobbered in the normal ABI, but is reserved in the
- home grown (aka upward compatible) embedded ABI. */
-#define EMBMEDANY_BASE_REG "%g4"
-
-/* Values of TARGET_CPU_DEFAULT, set via -D in the Makefile,
- and specified by the user via --with-cpu=foo.
- This specifies the cpu implementation, not the architecture size. */
-/* Note that TARGET_CPU_v9 is assumed to start the list of 64-bit
- capable cpu's. */
-#define TARGET_CPU_sparc 0
-#define TARGET_CPU_v7 0 /* alias for previous */
-#define TARGET_CPU_sparclet 1
-#define TARGET_CPU_sparclite 2
-#define TARGET_CPU_v8 3 /* generic v8 implementation */
-#define TARGET_CPU_supersparc 4
-#define TARGET_CPU_hypersparc 5
-#define TARGET_CPU_sparc86x 6
-#define TARGET_CPU_sparclite86x 6
-#define TARGET_CPU_v9 7 /* generic v9 implementation */
-#define TARGET_CPU_sparcv9 7 /* alias */
-#define TARGET_CPU_sparc64 7 /* alias */
-#define TARGET_CPU_ultrasparc 8
-
-#if TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
- || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
-
-#define CPP_CPU32_DEFAULT_SPEC ""
-#define ASM_CPU32_DEFAULT_SPEC ""
-
-#if TARGET_CPU_DEFAULT == TARGET_CPU_v9
-/* ??? What does Sun's CC pass? */
-#define CPP_CPU64_DEFAULT_SPEC "-D__sparc_v9__"
-/* ??? It's not clear how other assemblers will handle this, so by default
- use GAS. Sun's Solaris assembler recognizes -xarch=v8plus, but this case
- is handled in sol2.h. */
-#define ASM_CPU64_DEFAULT_SPEC "-Av9"
-#endif
-#if TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
-#define CPP_CPU64_DEFAULT_SPEC "-D__sparc_v9__"
-#define ASM_CPU64_DEFAULT_SPEC "-Av9a"
-#endif
-
-#else
-
-#define CPP_CPU64_DEFAULT_SPEC ""
-#define ASM_CPU64_DEFAULT_SPEC ""
-
-#if TARGET_CPU_DEFAULT == TARGET_CPU_sparc \
- || TARGET_CPU_DEFAULT == TARGET_CPU_v8
-#define CPP_CPU32_DEFAULT_SPEC ""
-#define ASM_CPU32_DEFAULT_SPEC ""
-#endif
-
-#if TARGET_CPU_DEFAULT == TARGET_CPU_sparclet
-#define CPP_CPU32_DEFAULT_SPEC "-D__sparclet__"
-#define ASM_CPU32_DEFAULT_SPEC "-Asparclet"
-#endif
-
-#if TARGET_CPU_DEFAULT == TARGET_CPU_sparclite
-#define CPP_CPU32_DEFAULT_SPEC "-D__sparclite__"
-#define ASM_CPU32_DEFAULT_SPEC "-Asparclite"
-#endif
-
-#if TARGET_CPU_DEFAULT == TARGET_CPU_supersparc
-#define CPP_CPU32_DEFAULT_SPEC "-D__supersparc__ -D__sparc_v8__"
-#define ASM_CPU32_DEFAULT_SPEC ""
-#endif
-
-#if TARGET_CPU_DEFAULT == TARGET_CPU_hypersparc
-#define CPP_CPU32_DEFAULT_SPEC "-D__hypersparc__ -D__sparc_v8__"
-#define ASM_CPU32_DEFAULT_SPEC ""
-#endif
-
-#if TARGET_CPU_DEFAULT == TARGET_CPU_sparclite86x
-#define CPP_CPU32_DEFAULT_SPEC "-D__sparclite86x__ -D__sparc_v8__"
-#define ASM_CPU32_DEFAULT_SPEC "-Av8"
-#endif
-
-#endif
-
-#if !defined(CPP_CPU32_DEFAULT_SPEC) || !defined(CPP_CPU64_DEFAULT_SPEC)
-Unrecognized value in TARGET_CPU_DEFAULT.
-#endif
-
-#ifdef SPARC_BI_ARCH
-
-#define CPP_CPU_DEFAULT_SPEC \
-(DEFAULT_ARCH32_P ? "\
-%{m64:" CPP_CPU64_DEFAULT_SPEC "} \
-%{!m64:" CPP_CPU32_DEFAULT_SPEC "} \
-" : "\
-%{m32:" CPP_CPU32_DEFAULT_SPEC "} \
-%{!m32:" CPP_CPU64_DEFAULT_SPEC "} \
-")
-#define ASM_CPU_DEFAULT_SPEC \
-(DEFAULT_ARCH32_P ? "\
-%{m64:" ASM_CPU64_DEFAULT_SPEC "} \
-%{!m64:" ASM_CPU32_DEFAULT_SPEC "} \
-" : "\
-%{m32:" ASM_CPU32_DEFAULT_SPEC "} \
-%{!m32:" ASM_CPU64_DEFAULT_SPEC "} \
-")
-
-#else /* !SPARC_BI_ARCH */
-
-#define CPP_CPU_DEFAULT_SPEC (DEFAULT_ARCH32_P ? CPP_CPU32_DEFAULT_SPEC : CPP_CPU64_DEFAULT_SPEC)
-#define ASM_CPU_DEFAULT_SPEC (DEFAULT_ARCH32_P ? ASM_CPU32_DEFAULT_SPEC : ASM_CPU64_DEFAULT_SPEC)
-
-#endif /* !SPARC_BI_ARCH */
-
-/* Names to predefine in the preprocessor for this target machine.
- ??? It would be nice to not include any subtarget specific values here,
- however there's no way to portably provide subtarget values to
- CPP_PREFINES. Also, -D values in CPP_SUBTARGET_SPEC don't get turned into
- foo, __foo and __foo__. */
-
-#define CPP_PREDEFINES "-Dsparc -Dsun -Dunix -Asystem(unix) -Asystem(bsd)"
-
-/* Define macros to distinguish architectures. */
-
-/* Common CPP definitions used by CPP_SPEC amongst the various targets
- for handling -mcpu=xxx switches. */
-#define CPP_CPU_SPEC "\
-%{mcypress:} \
-%{msparclite:-D__sparclite__} \
-%{mf930:-D__sparclite__} %{mf934:-D__sparclite__} \
-%{mv8:-D__sparc_v8__} \
-%{msupersparc:-D__supersparc__ -D__sparc_v8__} \
-%{mcpu=sparclet:-D__sparclet__} %{mcpu=tsc701:-D__sparclet__} \
-%{mcpu=sparclite:-D__sparclite__} \
-%{mcpu=f930:-D__sparclite__} %{mcpu=f934:-D__sparclite__} \
-%{mcpu=v8:-D__sparc_v8__} \
-%{mcpu=supersparc:-D__supersparc__ -D__sparc_v8__} \
-%{mcpu=hypersparc:-D__hypersparc__ -D__sparc_v8__} \
-%{mcpu=sparclite86x:-D__sparclite86x__ -D__sparc_v8__} \
-%{mcpu=v9:-D__sparc_v9__} \
-%{mcpu=ultrasparc:-D__sparc_v9__} \
-%{!mcpu*:%{!mcypress:%{!msparclite:%{!mf930:%{!mf934:%{!mv8:%{!msupersparc:%(cpp_cpu_default)}}}}}}} \
-"
-
-/* ??? The GCC_NEW_VARARGS macro is now obsolete, because gcc always uses
- the right varags.h file when bootstrapping. */
-/* ??? It's not clear what value we want to use for -Acpu/machine for
- sparc64 in 32 bit environments, so for now we only use `sparc64' in
- 64 bit environments. */
-
-#ifdef SPARC_BI_ARCH
-
-#define CPP_ARCH32_SPEC "-D__SIZE_TYPE__=unsigned\\ int -D__PTRDIFF_TYPE__=int \
--D__GCC_NEW_VARARGS__ -Acpu(sparc) -Amachine(sparc)"
-#define CPP_ARCH64_SPEC "-D__SIZE_TYPE__=long\\ unsigned\\ int -D__PTRDIFF_TYPE__=long\\ int \
--D__arch64__ -Acpu(sparc64) -Amachine(sparc64)"
-
-#else
-
-#define CPP_ARCH32_SPEC "-D__GCC_NEW_VARARGS__ -Acpu(sparc) -Amachine(sparc)"
-#define CPP_ARCH64_SPEC "-D__arch64__ -Acpu(sparc64) -Amachine(sparc64)"
-
-#endif
-
-#define CPP_ARCH_DEFAULT_SPEC \
-(DEFAULT_ARCH32_P ? CPP_ARCH32_SPEC : CPP_ARCH64_SPEC)
-
-#define CPP_ARCH_SPEC "\
-%{m32:%(cpp_arch32)} \
-%{m64:%(cpp_arch64)} \
-%{!m32:%{!m64:%(cpp_arch_default)}} \
-"
-
-/* Macros to distinguish endianness. */
-#define CPP_ENDIAN_SPEC "\
-%{mlittle-endian:-D__LITTLE_ENDIAN__} \
-%{mlittle-endian-data:-D__LITTLE_ENDIAN_DATA__}"
-
-/* Macros to distinguish the particular subtarget. */
-#define CPP_SUBTARGET_SPEC ""
-
-#define CPP_SPEC "%(cpp_cpu) %(cpp_arch) %(cpp_endian) %(cpp_subtarget)"
-
-/* Prevent error on `-sun4' and `-target sun4' options. */
-/* This used to translate -dalign to -malign, but that is no good
- because it can't turn off the usual meaning of making debugging dumps. */
-/* Translate old style -m<cpu> into new style -mcpu=<cpu>.
- ??? Delete support for -m<cpu> for 2.9. */
-
-#define CC1_SPEC "\
-%{sun4:} %{target:} \
-%{mcypress:-mcpu=cypress} \
-%{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
-%{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
-"
-
-/* Override in target specific files. */
-#define ASM_CPU_SPEC "\
-%{mcpu=sparclet:-Asparclet} %{mcpu=tsc701:-Asparclet} \
-%{msparclite:-Asparclite} \
-%{mf930:-Asparclite} %{mf934:-Asparclite} \
-%{mcpu=sparclite:-Asparclite} \
-%{mcpu=f930:-Asparclite} %{mcpu=f934:-Asparclite} \
-%{mv8plus:-Av8plus} \
-%{mcpu=v9:-Av9} \
-%{mcpu=ultrasparc:%{!mv8plus:-Av9a}} \
-%{!mcpu*:%{!mcypress:%{!msparclite:%{!mf930:%{!mf934:%{!mv8:%{!msupersparc:%(asm_cpu_default)}}}}}}} \
-"
-
-/* Word size selection, among other things.
- This is what GAS uses. Add %(asm_arch) to ASM_SPEC to enable. */
-
-#define ASM_ARCH32_SPEC "-32"
-#define ASM_ARCH64_SPEC "-64"
-#define ASM_ARCH_DEFAULT_SPEC \
-(DEFAULT_ARCH32_P ? ASM_ARCH32_SPEC : ASM_ARCH64_SPEC)
-
-#define ASM_ARCH_SPEC "\
-%{m32:%(asm_arch32)} \
-%{m64:%(asm_arch64)} \
-%{!m32:%{!m64:%(asm_arch_default)}} \
-"
-
-/* Special flags to the Sun-4 assembler when using pipe for input. */
-
-#define ASM_SPEC "\
-%| %{R} %{!pg:%{!p:%{fpic:-k} %{fPIC:-k}}} %{keep-local-as-symbols:-L} \
-%(asm_cpu) \
-"
-
-#define LIB_SPEC "%{!shared:%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p} %{g:-lg}}"
-
-/* Provide required defaults for linker -e and -d switches. */
-
-#define LINK_SPEC \
- "%{!shared:%{!nostdlib:%{!r*:%{!e*:-e start}}} -dc -dp} %{static:-Bstatic} \
- %{assert*} %{shared:%{!mimpure-text:-assert pure-text}}"
-
-/* This macro defines names of additional specifications to put in the specs
- that can be used in various specifications like CC1_SPEC. Its definition
- is an initializer with a subgrouping for each command option.
-
- Each subgrouping contains a string constant, that defines the
- specification name, and a string constant that used by the GNU CC driver
- program.
-
- Do not define this macro if it does not need to do anything. */
-
-#define EXTRA_SPECS \
- { "cpp_cpu", CPP_CPU_SPEC }, \
- { "cpp_cpu_default", CPP_CPU_DEFAULT_SPEC }, \
- { "cpp_arch32", CPP_ARCH32_SPEC }, \
- { "cpp_arch64", CPP_ARCH64_SPEC }, \
- { "cpp_arch_default", CPP_ARCH_DEFAULT_SPEC },\
- { "cpp_arch", CPP_ARCH_SPEC }, \
- { "cpp_endian", CPP_ENDIAN_SPEC }, \
- { "cpp_subtarget", CPP_SUBTARGET_SPEC }, \
- { "asm_cpu", ASM_CPU_SPEC }, \
- { "asm_cpu_default", ASM_CPU_DEFAULT_SPEC }, \
- { "asm_arch32", ASM_ARCH32_SPEC }, \
- { "asm_arch64", ASM_ARCH64_SPEC }, \
- { "asm_arch_default", ASM_ARCH_DEFAULT_SPEC },\
- { "asm_arch", ASM_ARCH_SPEC }, \
- SUBTARGET_EXTRA_SPECS
-
-#define SUBTARGET_EXTRA_SPECS
-
-#ifdef SPARC_BI_ARCH
-#define NO_BUILTIN_PTRDIFF_TYPE
-#define NO_BUILTIN_SIZE_TYPE
-#endif
-#define PTRDIFF_TYPE (TARGET_ARCH64 ? "long int" : "int")
-#define SIZE_TYPE (TARGET_ARCH64 ? "long unsigned int" : "unsigned int")
-
-/* ??? This should be 32 bits for v9 but what can we do? */
-#define WCHAR_TYPE "short unsigned int"
-#define WCHAR_TYPE_SIZE 16
-#define MAX_WCHAR_TYPE_SIZE 16
-
-/* Show we can debug even without a frame pointer. */
-#define CAN_DEBUG_WITHOUT_FP
-
-/* To make profiling work with -f{pic,PIC}, we need to emit the profiling
- code into the rtl. Also, if we are profiling, we cannot eliminate
- the frame pointer (because the return address will get smashed). */
-
-void sparc_override_options ();
-
-#define OVERRIDE_OPTIONS \
- do { \
- if (profile_flag || profile_block_flag || profile_arc_flag) \
- { \
- if (flag_pic) \
- { \
- const char *pic_string = (flag_pic == 1) ? "-fpic" : "-fPIC";\
- warning ("%s and profiling conflict: disabling %s", \
- pic_string, pic_string); \
- flag_pic = 0; \
- } \
- flag_omit_frame_pointer = 0; \
- } \
- sparc_override_options (); \
- SUBTARGET_OVERRIDE_OPTIONS; \
- } while (0)
-
-/* This is meant to be redefined in the host dependent files. */
-#define SUBTARGET_OVERRIDE_OPTIONS
-
-/* These compiler options take an argument. We ignore -target for now. */
-
-#define WORD_SWITCH_TAKES_ARG(STR) \
- (DEFAULT_WORD_SWITCH_TAKES_ARG (STR) \
- || !strcmp (STR, "target") || !strcmp (STR, "assert"))
-
-/* Print subsidiary information on the compiler version in use. */
-
-#define TARGET_VERSION fprintf (stderr, " (sparc)");
-
-/* Generate DBX debugging information. */
-
-#define DBX_DEBUGGING_INFO
-
-/* Run-time compilation parameters selecting different hardware subsets. */
-
-extern int target_flags;
-
-/* Nonzero if we should generate code to use the fpu. */
-#define MASK_FPU 1
-#define TARGET_FPU (target_flags & MASK_FPU)
-
-/* Nonzero if we should use FUNCTION_EPILOGUE. Otherwise, we
- use fast return insns, but lose some generality. */
-#define MASK_EPILOGUE 2
-#define TARGET_EPILOGUE (target_flags & MASK_EPILOGUE)
-
-/* Nonzero if we should assume that double pointers might be unaligned.
- This can happen when linking gcc compiled code with other compilers,
- because the ABI only guarantees 4 byte alignment. */
-#define MASK_UNALIGNED_DOUBLES 4
-#define TARGET_UNALIGNED_DOUBLES (target_flags & MASK_UNALIGNED_DOUBLES)
-
-/* Nonzero means that we should generate code for a v8 sparc. */
-#define MASK_V8 0x8
-#define TARGET_V8 (target_flags & MASK_V8)
-
-/* Nonzero means that we should generate code for a sparclite.
- This enables the sparclite specific instructions, but does not affect
- whether FPU instructions are emitted. */
-#define MASK_SPARCLITE 0x10
-#define TARGET_SPARCLITE (target_flags & MASK_SPARCLITE)
-
-/* Nonzero if we're compiling for the sparclet. */
-#define MASK_SPARCLET 0x20
-#define TARGET_SPARCLET (target_flags & MASK_SPARCLET)
-
-/* Nonzero if we're compiling for v9 sparc.
- Note that v9's can run in 32 bit mode so this doesn't necessarily mean
- the word size is 64. */
-#define MASK_V9 0x40
-#define TARGET_V9 (target_flags & MASK_V9)
-
-/* Non-zero to generate code that uses the instructions deprecated in
- the v9 architecture. This option only applies to v9 systems. */
-/* ??? This isn't user selectable yet. It's used to enable such insns
- on 32 bit v9 systems and for the moment they're permanently disabled
- on 64 bit v9 systems. */
-#define MASK_DEPRECATED_V8_INSNS 0x80
-#define TARGET_DEPRECATED_V8_INSNS (target_flags & MASK_DEPRECATED_V8_INSNS)
-
-/* Mask of all CPU selection flags. */
-#define MASK_ISA \
-(MASK_V8 + MASK_SPARCLITE + MASK_SPARCLET + MASK_V9 + MASK_DEPRECATED_V8_INSNS)
-
-/* Non-zero means don't pass `-assert pure-text' to the linker. */
-#define MASK_IMPURE_TEXT 0x100
-#define TARGET_IMPURE_TEXT (target_flags & MASK_IMPURE_TEXT)
-
-/* Nonzero means that we should generate code using a flat register window
- model, i.e. no save/restore instructions are generated, which is
- compatible with normal sparc code.
- The frame pointer is %i7 instead of %fp. */
-#define MASK_FLAT 0x200
-#define TARGET_FLAT (target_flags & MASK_FLAT)
-
-/* Nonzero means use the registers that the Sparc ABI reserves for
- application software. This must be the default to coincide with the
- setting in FIXED_REGISTERS. */
-#define MASK_APP_REGS 0x400
-#define TARGET_APP_REGS (target_flags & MASK_APP_REGS)
-
-/* Option to select how quad word floating point is implemented.
- When TARGET_HARD_QUAD is true, we use the hardware quad instructions.
- Otherwise, we use the SPARC ABI quad library functions. */
-#define MASK_HARD_QUAD 0x800
-#define TARGET_HARD_QUAD (target_flags & MASK_HARD_QUAD)
-
-/* Non-zero on little-endian machines. */
-/* ??? Little endian support currently only exists for sparclet-aout and
- sparc64-elf configurations. May eventually want to expand the support
- to all targets, but for now it's kept local to only those two. */
-#define MASK_LITTLE_ENDIAN 0x1000
-#define TARGET_LITTLE_ENDIAN (target_flags & MASK_LITTLE_ENDIAN)
-
-/* 0x2000, 0x4000 are unused */
-
-/* Nonzero if pointers are 64 bits.
- At the moment it must follow architecture size flag. */
-#define MASK_PTR64 0x8000
-#define TARGET_PTR64 (target_flags & MASK_PTR64)
-
-/* Nonzero if generating code to run in a 64 bit environment.
- This is intended to only be used by TARGET_ARCH{32,64} as they are the
- mechanism used to control compile time or run time selection. */
-#define MASK_64BIT 0x10000
-#define TARGET_64BIT (target_flags & MASK_64BIT)
-
-/* 0x20000,0x40000 unused */
-
-/* Non-zero means use a stack bias of 2047. Stack offsets are obtained by
- adding 2047 to %sp. This option is for v9 only and is the default. */
-#define MASK_STACK_BIAS 0x80000
-#define TARGET_STACK_BIAS (target_flags & MASK_STACK_BIAS)
-
-/* Non-zero means %g0 is a normal register.
- We still clobber it as necessary, but we can't rely on it always having
- a zero value.
- We don't bother to support this in true 64 bit mode. */
-#define MASK_LIVE_G0 0x100000
-#define TARGET_LIVE_G0 (target_flags & MASK_LIVE_G0)
-
-/* Non-zero means the cpu has broken `save' and `restore' insns, only
- the trivial versions work (save %g0,%g0,%g0; restore %g0,%g0,%g0).
- We assume the environment will properly handle or otherwise avoid
- trouble associated with an interrupt occurring after the `save' or trap
- occurring during it. */
-#define MASK_BROKEN_SAVERESTORE 0x200000
-#define TARGET_BROKEN_SAVERESTORE (target_flags & MASK_BROKEN_SAVERESTORE)
-
-/* Non-zero means -m{,no-}fpu was passed on the command line. */
-#define MASK_FPU_SET 0x400000
-#define TARGET_FPU_SET (target_flags & MASK_FPU_SET)
-
-/* Use the UltraSPARC Visual Instruction Set extensions. */
-#define MASK_VIS 0x1000000
-#define TARGET_VIS (target_flags & MASK_VIS)
-
-/* Compile for Solaris V8+. 32 bit Solaris preserves the high bits of
- the current out and global registers. Linux saves the high bits on
- context switches but not signals. */
-#define MASK_V8PLUS 0x2000000
-#define TARGET_V8PLUS (target_flags & MASK_V8PLUS)
-
-/* TARGET_HARD_MUL: Use hardware multiply instructions but not %y.
- TARGET_HARD_MUL32: Use hardware multiply instructions with rd %y
- to get high 32 bits. False in V8+ or V9 because multiply stores
- a 64 bit result in a register. */
-
-#define TARGET_HARD_MUL32 \
- ((TARGET_V8 || TARGET_SPARCLITE \
- || TARGET_SPARCLET || TARGET_DEPRECATED_V8_INSNS) \
- && ! TARGET_V8PLUS)
-
-#define TARGET_HARD_MUL \
- (TARGET_V8 || TARGET_SPARCLITE || TARGET_SPARCLET \
- || TARGET_DEPRECATED_V8_INSNS || TARGET_V8PLUS)
-
-
-/* Macro to define tables used to set the flags.
- This is a list in braces of pairs in braces,
- each pair being { "NAME", VALUE }
- where VALUE is the bits to set or minus the bits to clear.
- An empty string NAME is used to identify the default VALUE. */
-
-#define TARGET_SWITCHES \
- { {"fpu", MASK_FPU | MASK_FPU_SET, "Use hardware fp" }, \
- {"no-fpu", -MASK_FPU, "Do not use hardware fp" }, \
- {"no-fpu", MASK_FPU_SET, "Do not use hardware fp" }, \
- {"hard-float", MASK_FPU | MASK_FPU_SET, "Use hardware fp" }, \
- {"soft-float", -MASK_FPU, "Do not use hardware fp" }, \
- {"soft-float", MASK_FPU_SET, "Do not use hardware fp" }, \
- {"epilogue", MASK_EPILOGUE, "Use FUNCTION_EPILOGUE" }, \
- {"no-epilogue", -MASK_EPILOGUE, "Do not use FUNCTION_EPILOGUE" }, \
- {"unaligned-doubles", MASK_UNALIGNED_DOUBLES, "Assume possible double misalignment" },\
- {"no-unaligned-doubles", -MASK_UNALIGNED_DOUBLES, "Assume all doubles are aligned" }, \
- {"impure-text", MASK_IMPURE_TEXT, "Pass -assert pure-text to linker" }, \
- {"no-impure-text", -MASK_IMPURE_TEXT, "Do not pass -assert pure-text to linker" }, \
- {"flat", MASK_FLAT, "Use flat register window model" }, \
- {"no-flat", -MASK_FLAT, "Do not use flat register window model" }, \
- {"app-regs", MASK_APP_REGS, "Use ABI reserved registers" }, \
- {"no-app-regs", -MASK_APP_REGS, "Do not use ABI reserved registers" }, \
- {"hard-quad-float", MASK_HARD_QUAD, "Use hardware quad fp instructions" }, \
- {"soft-quad-float", -MASK_HARD_QUAD, "Do not use hardware quad fp instructions" }, \
- {"v8plus", MASK_V8PLUS, "Compile for v8plus ABI" }, \
- {"no-v8plus", -MASK_V8PLUS, "Do not compile for v8plus ABI" }, \
- {"vis", MASK_VIS, "Utilize Visual Instruction Set" }, \
- {"no-vis", -MASK_VIS, "Do not utilize Visual Instruction Set" }, \
- /* ??? These are deprecated, coerced to -mcpu=. Delete in 2.9. */ \
- {"cypress", 0, "Optimize for Cypress processors" }, \
- {"sparclite", 0, "Optimize for SparcLite processors" }, \
- {"f930", 0, "Optimize for F930 processors" }, \
- {"f934", 0, "Optimize for F934 processors" }, \
- {"v8", 0, "Use V8 Sparc ISA" }, \
- {"supersparc", 0, "Optimize for SuperSparc processors" }, \
- /* End of deprecated options. */ \
- {"ptr64", MASK_PTR64, "Pointers are 64-bit" }, \
- {"ptr32", -MASK_PTR64, "Pointers are 32-bit" }, \
- {"32", -MASK_64BIT, "Use 32-bit ABI" }, \
- {"64", MASK_64BIT, "Use 64-bit ABI" }, \
- {"stack-bias", MASK_STACK_BIAS, "Use stack bias" }, \
- {"no-stack-bias", -MASK_STACK_BIAS, "Do not use stack bias" }, \
- SUBTARGET_SWITCHES \
- { "", TARGET_DEFAULT, ""}}
-
-/* MASK_APP_REGS must always be the default because that's what
- FIXED_REGISTERS is set to and -ffixed- is processed before
- CONDITIONAL_REGISTER_USAGE is called (where we process -mno-app-regs). */
-#define TARGET_DEFAULT (MASK_APP_REGS + MASK_EPILOGUE + MASK_FPU)
-
-/* This is meant to be redefined in target specific files. */
-#define SUBTARGET_SWITCHES
-
-/* Processor type.
- These must match the values for the cpu attribute in sparc.md. */
-enum processor_type {
- PROCESSOR_V7,
- PROCESSOR_CYPRESS,
- PROCESSOR_V8,
- PROCESSOR_SUPERSPARC,
- PROCESSOR_SPARCLITE,
- PROCESSOR_F930,
- PROCESSOR_F934,
- PROCESSOR_HYPERSPARC,
- PROCESSOR_SPARCLITE86X,
- PROCESSOR_SPARCLET,
- PROCESSOR_TSC701,
- PROCESSOR_V9,
- PROCESSOR_ULTRASPARC
-};
-
-/* This is set from -m{cpu,tune}=xxx. */
-extern enum processor_type sparc_cpu;
-
-/* Recast the cpu class to be the cpu attribute.
- Every file includes us, but not every file includes insn-attr.h. */
-#define sparc_cpu_attr ((enum attr_cpu) sparc_cpu)
-
-/* This macro is similar to `TARGET_SWITCHES' but defines names of
- command options that have values. Its definition is an
- initializer with a subgrouping for each command option.
-
- Each subgrouping contains a string constant, that defines the
- fixed part of the option name, and the address of a variable.
- The variable, type `char *', is set to the variable part of the
- given option if the fixed part matches. The actual option name
- is made by appending `-m' to the specified name.
-
- Here is an example which defines `-mshort-data-NUMBER'. If the
- given option is `-mshort-data-512', the variable `m88k_short_data'
- will be set to the string `"512"'.
-
- extern char *m88k_short_data;
- #define TARGET_OPTIONS { { "short-data-", &m88k_short_data } } */
-
-#define TARGET_OPTIONS \
-{ \
- { "cpu=", &sparc_select[1].string, "Use features of and schedule code for given CPU" }, \
- { "tune=", &sparc_select[2].string, "Schedule code for given CPU" }, \
- { "cmodel=", &sparc_cmodel_string, "Use given Sparc code model" }, \
- { "align-loops=", &sparc_align_loops_string, "Loop code aligned to this power of 2" }, \
- { "align-jumps=", &sparc_align_jumps_string, "Jump targets are aligned to this power of 2" }, \
- { "align-functions=", &sparc_align_funcs_string, "Function starts are aligned to this power of 2" }, \
- SUBTARGET_OPTIONS \
-}
-
-/* This is meant to be redefined in target specific files. */
-#define SUBTARGET_OPTIONS
-
-/* sparc_select[0] is reserved for the default cpu. */
-struct sparc_cpu_select
-{
- const char *string;
- const char *name;
- int set_tune_p;
- int set_arch_p;
-};
-
-extern struct sparc_cpu_select sparc_select[];
-
-/* Variables to record values the user passes. */
-extern const char *sparc_align_loops_string;
-extern const char *sparc_align_jumps_string;
-extern const char *sparc_align_funcs_string;
-/* Parsed values as a power of two. */
-extern int sparc_align_loops;
-extern int sparc_align_jumps;
-extern int sparc_align_funcs;
-
-#define DEFAULT_SPARC_ALIGN_FUNCS \
-(sparc_cpu == PROCESSOR_ULTRASPARC ? 5 : 2)
-
-/* target machine storage layout */
-
-/* Define for cross-compilation to a sparc target with no TFmode from a host
- with a different float format (e.g. VAX). */
-#define REAL_ARITHMETIC
-
-/* Define this if most significant bit is lowest numbered
- in instructions that operate on numbered bit-fields. */
-#define BITS_BIG_ENDIAN 1
-
-/* Define this if most significant byte of a word is the lowest numbered. */
-#define BYTES_BIG_ENDIAN 1
-
-/* Define this if most significant word of a multiword number is the lowest
- numbered. */
-#define WORDS_BIG_ENDIAN 1
-
-/* Define this to set the endianness to use in libgcc2.c, which can
- not depend on target_flags. */
-#if defined (__LITTLE_ENDIAN__) || defined(__LITTLE_ENDIAN_DATA__)
-#define LIBGCC2_WORDS_BIG_ENDIAN 0
-#else
-#define LIBGCC2_WORDS_BIG_ENDIAN 1
-#endif
-
-/* number of bits in an addressable storage unit */
-#define BITS_PER_UNIT 8
-
-/* Width in bits of a "word", which is the contents of a machine register.
- Note that this is not necessarily the width of data type `int';
- if using 16-bit ints on a 68000, this would still be 32.
- But on a machine with 16-bit registers, this would be 16. */
-#define BITS_PER_WORD (TARGET_ARCH64 ? 64 : 32)
-#define MAX_BITS_PER_WORD 64
-
-/* Width of a word, in units (bytes). */
-#define UNITS_PER_WORD (TARGET_ARCH64 ? 8 : 4)
-#define MIN_UNITS_PER_WORD 4
-
-/* Now define the sizes of the C data types. */
-
-#define SHORT_TYPE_SIZE 16
-#define INT_TYPE_SIZE 32
-#define LONG_TYPE_SIZE (TARGET_ARCH64 ? 64 : 32)
-#define LONG_LONG_TYPE_SIZE 64
-#define FLOAT_TYPE_SIZE 32
-#define DOUBLE_TYPE_SIZE 64
-
-#if defined (SPARC_BI_ARCH)
-#define MAX_LONG_TYPE_SIZE 64
-#endif
-
-#if 0
-/* ??? This does not work in SunOS 4.x, so it is not enabled here.
- Instead, it is enabled in sol2.h, because it does work under Solaris. */
-/* Define for support of TFmode long double and REAL_ARITHMETIC.
- Sparc ABI says that long double is 4 words. */
-#define LONG_DOUBLE_TYPE_SIZE 128
-#endif
-
-/* Width in bits of a pointer.
- See also the macro `Pmode' defined below. */
-#define POINTER_SIZE (TARGET_PTR64 ? 64 : 32)
-
-/* A macro to update MODE and UNSIGNEDP when an object whose type
- is TYPE and which has the specified mode and signedness is to be
- stored in a register. This macro is only called when TYPE is a
- scalar type. */
-#define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
-if (TARGET_ARCH64 \
- && GET_MODE_CLASS (MODE) == MODE_INT \
- && GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \
-{ \
- (MODE) = DImode; \
-}
-
-/* Define this macro if the promotion described by PROMOTE_MODE
- should also be done for outgoing function arguments. */
-/* This is only needed for TARGET_ARCH64, but since PROMOTE_MODE is a no-op
- for TARGET_ARCH32 this is ok. Otherwise we'd need to add a runtime test
- for this value. */
-#define PROMOTE_FUNCTION_ARGS
-
-/* Define this macro if the promotion described by PROMOTE_MODE
- should also be done for the return value of functions.
- If this macro is defined, FUNCTION_VALUE must perform the same
- promotions done by PROMOTE_MODE. */
-/* This is only needed for TARGET_ARCH64, but since PROMOTE_MODE is a no-op
- for TARGET_ARCH32 this is ok. Otherwise we'd need to add a runtime test
- for this value. */
-#define PROMOTE_FUNCTION_RETURN
-
-/* Allocation boundary (in *bits*) for storing arguments in argument list. */
-#define PARM_BOUNDARY (TARGET_ARCH64 ? 64 : 32)
-
-/* Boundary (in *bits*) on which stack pointer should be aligned. */
-#define STACK_BOUNDARY (TARGET_ARCH64 ? 128 : 64)
-
-/* ALIGN FRAMES on double word boundaries */
-
-#define SPARC_STACK_ALIGN(LOC) \
- (TARGET_ARCH64 ? (((LOC)+15) & ~15) : (((LOC)+7) & ~7))
-
-/* Allocation boundary (in *bits*) for the code of a function. */
-#define FUNCTION_BOUNDARY (1 << (sparc_align_funcs + 3))
-
-/* Alignment of field after `int : 0' in a structure. */
-#define EMPTY_FIELD_BOUNDARY (TARGET_ARCH64 ? 64 : 32)
-
-/* Every structure's size must be a multiple of this. */
-#define STRUCTURE_SIZE_BOUNDARY 8
-
-/* A bitfield declared as `int' forces `int' alignment for the struct. */
-#define PCC_BITFIELD_TYPE_MATTERS 1
-
-/* No data type wants to be aligned rounder than this. */
-#define BIGGEST_ALIGNMENT (TARGET_ARCH64 ? 128 : 64)
-
-/* The best alignment to use in cases where we have a choice. */
-#define FASTEST_ALIGNMENT 64
-
-/* Make strings word-aligned so strcpy from constants will be faster. */
-#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
- ((TREE_CODE (EXP) == STRING_CST \
- && (ALIGN) < FASTEST_ALIGNMENT) \
- ? FASTEST_ALIGNMENT : (ALIGN))
-
-/* Make arrays of chars word-aligned for the same reasons. */
-#define DATA_ALIGNMENT(TYPE, ALIGN) \
- (TREE_CODE (TYPE) == ARRAY_TYPE \
- && TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
- && (ALIGN) < FASTEST_ALIGNMENT ? FASTEST_ALIGNMENT : (ALIGN))
-
-/* Set this nonzero if move instructions will actually fail to work
- when given unaligned data. */
-#define STRICT_ALIGNMENT 1
-
-/* Things that must be doubleword aligned cannot go in the text section,
- because the linker fails to align the text section enough!
- Put them in the data section. This macro is only used in this file. */
-#define MAX_TEXT_ALIGN 32
-
-/* This forces all variables and constants to the data section when PIC.
- This is because the SunOS 4 shared library scheme thinks everything in
- text is a function, and patches the address to point to a loader stub. */
-/* This is defined to zero for every system which doesn't use the a.out object
- file format. */
-#ifndef SUNOS4_SHARED_LIBRARIES
-#define SUNOS4_SHARED_LIBRARIES 0
-#endif
-
-/* This is defined differently for v9 in a cover file. */
-#define SELECT_SECTION(T,RELOC) \
-{ \
- if (TREE_CODE (T) == VAR_DECL) \
- { \
- if (TREE_READONLY (T) && ! TREE_SIDE_EFFECTS (T) \
- && DECL_INITIAL (T) \
- && (DECL_INITIAL (T) == error_mark_node \
- || TREE_CONSTANT (DECL_INITIAL (T))) \
- && DECL_ALIGN (T) <= MAX_TEXT_ALIGN \
- && ! (flag_pic && ((RELOC) || SUNOS4_SHARED_LIBRARIES))) \
- text_section (); \
- else \
- data_section (); \
- } \
- else if (TREE_CODE (T) == CONSTRUCTOR) \
- { \
- if (flag_pic && ((RELOC) || SUNOS4_SHARED_LIBRARIES)) \
- data_section (); \
- } \
- else if (TREE_CODE_CLASS (TREE_CODE (T)) == 'c') \
- { \
- if ((TREE_CODE (T) == STRING_CST && flag_writable_strings) \
- || TYPE_ALIGN (TREE_TYPE (T)) > MAX_TEXT_ALIGN \
- || (flag_pic && ((RELOC) || SUNOS4_SHARED_LIBRARIES))) \
- data_section (); \
- else \
- text_section (); \
- } \
-}
-
-/* Use text section for a constant
- unless we need more alignment than that offers. */
-/* This is defined differently for v9 in a cover file. */
-#define SELECT_RTX_SECTION(MODE, X) \
-{ \
- if (GET_MODE_BITSIZE (MODE) <= MAX_TEXT_ALIGN \
- && ! (flag_pic && (symbolic_operand (X) || SUNOS4_SHARED_LIBRARIES))) \
- text_section (); \
- else \
- data_section (); \
-}
-
-/* Standard register usage. */
-
-/* Number of actual hardware registers.
- The hardware registers are assigned numbers for the compiler
- from 0 to just below FIRST_PSEUDO_REGISTER.
- All registers that the compiler knows about must be given numbers,
- even those that are not normally considered general registers.
-
- SPARC has 32 integer registers and 32 floating point registers.
- 64 bit SPARC has 32 additional fp regs, but the odd numbered ones are not
- accessible. We still account for them to simplify register computations
- (eg: in CLASS_MAX_NREGS). There are also 4 fp condition code registers, so
- 32+32+32+4 == 100.
- Register 100 is used as the integer condition code register. */
-
-#define FIRST_PSEUDO_REGISTER 101
-
-#define SPARC_FIRST_FP_REG 32
-/* Additional V9 fp regs. */
-#define SPARC_FIRST_V9_FP_REG 64
-#define SPARC_LAST_V9_FP_REG 95
-/* V9 %fcc[0123]. V8 uses (figuratively) %fcc0. */
-#define SPARC_FIRST_V9_FCC_REG 96
-#define SPARC_LAST_V9_FCC_REG 99
-/* V8 fcc reg. */
-#define SPARC_FCC_REG 96
-/* Integer CC reg. We don't distinguish %icc from %xcc. */
-#define SPARC_ICC_REG 100
-
-/* Nonzero if REGNO is an fp reg. */
-#define SPARC_FP_REG_P(REGNO) \
-((REGNO) >= SPARC_FIRST_FP_REG && (REGNO) <= SPARC_LAST_V9_FP_REG)
-
-/* Argument passing regs. */
-#define SPARC_OUTGOING_INT_ARG_FIRST 8
-#define SPARC_INCOMING_INT_ARG_FIRST (TARGET_FLAT ? 8 : 24)
-#define SPARC_FP_ARG_FIRST 32
-
-/* 1 for registers that have pervasive standard uses
- and are not available for the register allocator.
-
- On non-v9 systems:
- g1 is free to use as temporary.
- g2-g4 are reserved for applications. Gcc normally uses them as
- temporaries, but this can be disabled via the -mno-app-regs option.
- g5 through g7 are reserved for the operating system.
-
- On v9 systems:
- g1,g5 are free to use as temporaries, and are free to use between calls
- if the call is to an external function via the PLT.
- g4 is free to use as a temporary in the non-embedded case.
- g4 is reserved in the embedded case.
- g2-g3 are reserved for applications. Gcc normally uses them as
- temporaries, but this can be disabled via the -mno-app-regs option.
- g6-g7 are reserved for the operating system (or application in
- embedded case).
- ??? Register 1 is used as a temporary by the 64 bit sethi pattern, so must
- currently be a fixed register until this pattern is rewritten.
- Register 1 is also used when restoring call-preserved registers in large
- stack frames.
-
- Registers fixed in arch32 and not arch64 (or vice-versa) are marked in
- CONDITIONAL_REGISTER_USAGE in order to properly handle -ffixed-.
-*/
-
-#define FIXED_REGISTERS \
- {1, 0, 0, 0, 0, 0, 1, 1, \
- 0, 0, 0, 0, 0, 0, 1, 0, \
- 0, 0, 0, 0, 0, 0, 0, 0, \
- 0, 0, 0, 0, 0, 0, 1, 1, \
- \
- 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}
-
-/* 1 for registers not available across function calls.
- These must include the FIXED_REGISTERS and also any
- registers that can be used without being saved.
- The latter must include the registers where values are returned
- and the register where structure-value addresses are passed.
- Aside from that, you can include as many other registers as you like. */
-
-#define CALL_USED_REGISTERS \
- {1, 1, 1, 1, 1, 1, 1, 1, \
- 1, 1, 1, 1, 1, 1, 1, 1, \
- 0, 0, 0, 0, 0, 0, 0, 0, \
- 0, 0, 0, 0, 0, 0, 1, 1, \
- \
- 1, 1, 1, 1, 1, 1, 1, 1, \
- 1, 1, 1, 1, 1, 1, 1, 1, \
- 1, 1, 1, 1, 1, 1, 1, 1, \
- 1, 1, 1, 1, 1, 1, 1, 1, \
- \
- 1, 1, 1, 1, 1, 1, 1, 1, \
- 1, 1, 1, 1, 1, 1, 1, 1, \
- 1, 1, 1, 1, 1, 1, 1, 1, \
- 1, 1, 1, 1, 1, 1, 1, 1, \
- \
- 1, 1, 1, 1, 1}
-
-/* If !TARGET_FPU, then make the fp registers and fp cc regs fixed so that
- they won't be allocated. */
-
-#define CONDITIONAL_REGISTER_USAGE \
-do \
- { \
- if (flag_pic) \
- { \
- fixed_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \
- call_used_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \
- } \
- if (TARGET_ARCH32) \
- { \
- fixed_regs[5] = 1; \
- } \
- if (TARGET_LIVE_G0) \
- fixed_regs[0] = 0; \
- if (! TARGET_V9) \
- { \
- int regno; \
- for (regno = SPARC_FIRST_V9_FP_REG; \
- regno <= SPARC_LAST_V9_FP_REG; \
- regno++) \
- fixed_regs[regno] = 1; \
- /* %fcc0 is used by v8 and v9. */ \
- for (regno = SPARC_FIRST_V9_FCC_REG + 1; \
- regno <= SPARC_LAST_V9_FCC_REG; \
- regno++) \
- fixed_regs[regno] = 1; \
- } \
- if (! TARGET_FPU) \
- { \
- int regno; \
- for (regno = 32; regno < SPARC_LAST_V9_FCC_REG; regno++) \
- fixed_regs[regno] = 1; \
- } \
- /* Don't unfix g2-g4 if they were fixed with -ffixed-. */ \
- fixed_regs[2] |= ! TARGET_APP_REGS; \
- fixed_regs[3] |= ! TARGET_APP_REGS; \
- fixed_regs[4] |= ! TARGET_APP_REGS || TARGET_CM_EMBMEDANY; \
- if (TARGET_FLAT) \
- { \
- /* Let the compiler believe the frame pointer is still \
- %fp, but output it as %i7. */ \
- fixed_regs[31] = 1; \
- reg_names[FRAME_POINTER_REGNUM] = "%i7"; \
- /* ??? This is a hack to disable leaf functions. */ \
- global_regs[7] = 1; \
- } \
- if (profile_block_flag) \
- { \
- /* %g1 and %g2 must be fixed, because BLOCK_PROFILER \
- uses them. */ \
- fixed_regs[1] = 1; \
- fixed_regs[2] = 1; \
- } \
- } \
-while (0)
-
-/* Return number of consecutive hard regs needed starting at reg REGNO
- to hold something of mode MODE.
- This is ordinarily the length in words of a value of mode MODE
- but can be less for certain modes in special long registers.
-
- On SPARC, ordinary registers hold 32 bits worth;
- this means both integer and floating point registers.
- On v9, integer regs hold 64 bits worth; floating point regs hold
- 32 bits worth (this includes the new fp regs as even the odd ones are
- included in the hard register count). */
-
-#define HARD_REGNO_NREGS(REGNO, MODE) \
- (TARGET_ARCH64 \
- ? ((REGNO) < 32 \
- ? (GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD \
- : (GET_MODE_SIZE (MODE) + 3) / 4) \
- : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
-
-/* A subreg in 64 bit mode will have the wrong offset for a floating point
- register. The least significant part is at offset 1, compared to 0 for
- integer registers. This only applies when FMODE is a larger mode.
- We also need to handle a special case of TF-->DF conversions. */
-#define ALTER_HARD_SUBREG(TMODE, WORD, FMODE, REGNO) \
- (TARGET_ARCH64 \
- && (REGNO) >= SPARC_FIRST_FP_REG \
- && (REGNO) <= SPARC_LAST_V9_FP_REG \
- && (TMODE) == SImode \
- && !((FMODE) == QImode || (FMODE) == HImode) \
- ? ((REGNO) + 1) \
- : ((TMODE) == DFmode && (FMODE) == TFmode) \
- ? ((REGNO) + ((WORD) * 2)) \
- : ((REGNO) + (WORD)))
-
-/* Value is 1 if hard register REGNO can hold a value of machine-mode MODE.
- See sparc.c for how we initialize this. */
-extern int *hard_regno_mode_classes;
-extern int sparc_mode_class[];
-#define HARD_REGNO_MODE_OK(REGNO, MODE) \
- ((hard_regno_mode_classes[REGNO] & sparc_mode_class[MODE]) != 0)
-
-/* Value is 1 if it is a good idea to tie two pseudo registers
- when one has mode MODE1 and one has mode MODE2.
- If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
- for any hard reg, then this must be 0 for correct output.
-
- For V9: SFmode can't be combined with other float modes, because they can't
- be allocated to the %d registers. Also, DFmode won't fit in odd %f
- registers, but SFmode will. */
-#define MODES_TIEABLE_P(MODE1, MODE2) \
- ((MODE1) == (MODE2) \
- || (GET_MODE_CLASS (MODE1) == GET_MODE_CLASS (MODE2) \
- && (! TARGET_V9 \
- || (GET_MODE_CLASS (MODE1) != MODE_FLOAT \
- || (MODE1 != SFmode && MODE2 != SFmode)))))
-
-/* Specify the registers used for certain standard purposes.
- The values of these macros are register numbers. */
-
-/* SPARC pc isn't overloaded on a register that the compiler knows about. */
-/* #define PC_REGNUM */
-
-/* Register to use for pushing function arguments. */
-#define STACK_POINTER_REGNUM 14
-
-/* Actual top-of-stack address is 92/176 greater than the contents of the
- stack pointer register for !v9/v9. That is:
- - !v9: 64 bytes for the in and local registers, 4 bytes for structure return
- address, and 6*4 bytes for the 6 register parameters.
- - v9: 128 bytes for the in and local registers + 6*8 bytes for the integer
- parameter regs. */
-#define STACK_POINTER_OFFSET FIRST_PARM_OFFSET(0)
-
-/* The stack bias (amount by which the hardware register is offset by). */
-#define SPARC_STACK_BIAS ((TARGET_ARCH64 && TARGET_STACK_BIAS) ? 2047 : 0)
-
-/* Is stack biased? */
-#define STACK_BIAS SPARC_STACK_BIAS
-
-/* Base register for access to local variables of the function. */
-#define FRAME_POINTER_REGNUM 30
-
-#if 0
-/* Register that is used for the return address for the flat model. */
-#define RETURN_ADDR_REGNUM 15
-#endif
-
-/* Value should be nonzero if functions must have frame pointers.
- Zero means the frame pointer need not be set up (and parms
- may be accessed via the stack pointer) in functions that seem suitable.
- This is computed in `reload', in reload1.c.
- Used in flow.c, global.c, and reload1.c.
-
- Being a non-leaf function does not mean a frame pointer is needed in the
- flat window model. However, the debugger won't be able to backtrace through
- us with out it. */
-#define FRAME_POINTER_REQUIRED \
- (TARGET_FLAT ? (current_function_calls_alloca || current_function_varargs \
- || !leaf_function_p ()) \
- : ! (leaf_function_p () && only_leaf_regs_used ()))
-
-/* C statement to store the difference between the frame pointer
- and the stack pointer values immediately after the function prologue.
-
- Note, we always pretend that this is a leaf function because if
- it's not, there's no point in trying to eliminate the
- frame pointer. If it is a leaf function, we guessed right! */
-#define INITIAL_FRAME_POINTER_OFFSET(VAR) \
- ((VAR) = (TARGET_FLAT ? sparc_flat_compute_frame_size (get_frame_size ()) \
- : compute_frame_size (get_frame_size (), 1)))
-
-/* Base register for access to arguments of the function. */
-#define ARG_POINTER_REGNUM FRAME_POINTER_REGNUM
-
-/* Register in which static-chain is passed to a function. This must
- not be a register used by the prologue. */
-#define STATIC_CHAIN_REGNUM (TARGET_ARCH64 ? 5 : 2)
-
-/* Register which holds offset table for position-independent
- data references. */
-
-#define PIC_OFFSET_TABLE_REGNUM 23
-
-#define FINALIZE_PIC finalize_pic ()
-
-/* Pick a default value we can notice from override_options:
- !v9: Default is on.
- v9: Default is off. */
-
-#define DEFAULT_PCC_STRUCT_RETURN -1
-
-/* Sparc ABI says that quad-precision floats and all structures are returned
- in memory.
- For v9: unions <= 32 bytes in size are returned in int regs,
- structures up to 32 bytes are returned in int and fp regs. */
-
-#define RETURN_IN_MEMORY(TYPE) \
-(TARGET_ARCH32 \
- ? (TYPE_MODE (TYPE) == BLKmode \
- || TYPE_MODE (TYPE) == TFmode \
- || TYPE_MODE (TYPE) == TCmode) \
- : (TYPE_MODE (TYPE) == BLKmode \
- && int_size_in_bytes (TYPE) > 32))
-
-/* Functions which return large structures get the address
- to place the wanted value at offset 64 from the frame.
- Must reserve 64 bytes for the in and local registers.
- v9: Functions which return large structures get the address to place the
- wanted value from an invisible first argument. */
-/* Used only in other #defines in this file. */
-#define STRUCT_VALUE_OFFSET 64
-
-#define STRUCT_VALUE \
- (TARGET_ARCH64 \
- ? 0 \
- : gen_rtx_MEM (Pmode, \
- gen_rtx_PLUS (Pmode, stack_pointer_rtx, \
- GEN_INT (STRUCT_VALUE_OFFSET))))
-#define STRUCT_VALUE_INCOMING \
- (TARGET_ARCH64 \
- ? 0 \
- : gen_rtx_MEM (Pmode, \
- gen_rtx_PLUS (Pmode, frame_pointer_rtx, \
- GEN_INT (STRUCT_VALUE_OFFSET))))
-
-/* Define the classes of registers for register constraints in the
- machine description. Also define ranges of constants.
-
- One of the classes must always be named ALL_REGS and include all hard regs.
- If there is more than one class, another class must be named NO_REGS
- and contain no registers.
-
- The name GENERAL_REGS must be the name of a class (or an alias for
- another name such as ALL_REGS). This is the class of registers
- that is allowed by "g" or "r" in a register constraint.
- Also, registers outside this class are allocated only when
- instructions express preferences for them.
-
- The classes must be numbered in nondecreasing order; that is,
- a larger-numbered class must never be contained completely
- in a smaller-numbered class.
-
- For any two classes, it is very desirable that there be another
- class that represents their union. */
-
-/* The SPARC has various kinds of registers: general, floating point,
- and condition codes [well, it has others as well, but none that we
- care directly about].
-
- For v9 we must distinguish between the upper and lower floating point
- registers because the upper ones can't hold SFmode values.
- HARD_REGNO_MODE_OK won't help here because reload assumes that register(s)
- satisfying a group need for a class will also satisfy a single need for
- that class. EXTRA_FP_REGS is a bit of a misnomer as it covers all 64 fp
- regs.
-
- It is important that one class contains all the general and all the standard
- fp regs. Otherwise find_reg() won't properly allocate int regs for moves,
- because reg_class_record() will bias the selection in favor of fp regs,
- because reg_class_subunion[GENERAL_REGS][FP_REGS] will yield FP_REGS,
- because FP_REGS > GENERAL_REGS.
-
- It is also important that one class contain all the general and all the
- fp regs. Otherwise when spilling a DFmode reg, it may be from EXTRA_FP_REGS
- but find_reloads() may use class GENERAL_OR_FP_REGS. This will cause
- allocate_reload_reg() to bypass it causing an abort because the compiler
- thinks it doesn't have a spill reg when in fact it does.
-
- v9 also has 4 floating point condition code registers. Since we don't
- have a class that is the union of FPCC_REGS with either of the others,
- it is important that it appear first. Otherwise the compiler will die
- trying to compile _fixunsdfsi because fix_truncdfsi2 won't match its
- constraints.
-
- It is important that SPARC_ICC_REG have class NO_REGS. Otherwise combine
- may try to use it to hold an SImode value. See register_operand.
- ??? Should %fcc[0123] be handled similarly?
-*/
-
-enum reg_class { NO_REGS, FPCC_REGS, I64_REGS, GENERAL_REGS, FP_REGS,
- EXTRA_FP_REGS, GENERAL_OR_FP_REGS, GENERAL_OR_EXTRA_FP_REGS,
- ALL_REGS, LIM_REG_CLASSES };
-
-#define N_REG_CLASSES (int) LIM_REG_CLASSES
-
-/* Give names of register classes as strings for dump file. */
-
-#define REG_CLASS_NAMES \
- { "NO_REGS", "FPCC_REGS", "I64_REGS", "GENERAL_REGS", "FP_REGS", \
- "EXTRA_FP_REGS", "GENERAL_OR_FP_REGS", "GENERAL_OR_EXTRA_FP_REGS", \
- "ALL_REGS" }
-
-/* Define which registers fit in which classes.
- This is an initializer for a vector of HARD_REG_SET
- of length N_REG_CLASSES. */
-
-#define REG_CLASS_CONTENTS \
- {{0, 0, 0, 0}, {0, 0, 0, 0xf}, {0xffff, 0, 0, 0}, \
- {-1, 0, 0, 0}, {0, -1, 0, 0}, {0, -1, -1, 0}, \
- {-1, -1, 0, 0}, {-1, -1, -1, 0}, {-1, -1, -1, 0x1f}}
-
-/* The same information, inverted:
- Return the class number of the smallest class containing
- reg number REGNO. This could be a conditional expression
- or could index an array. */
-
-extern enum reg_class sparc_regno_reg_class[];
-
-#define REGNO_REG_CLASS(REGNO) sparc_regno_reg_class[(REGNO)]
-
-/* This is the order in which to allocate registers normally.
-
- We put %f0/%f1 last among the float registers, so as to make it more
- likely that a pseudo-register which dies in the float return register
- will get allocated to the float return register, thus saving a move
- instruction at the end of the function. */
-
-#define REG_ALLOC_ORDER \
-{ 8, 9, 10, 11, 12, 13, 2, 3, \
- 15, 16, 17, 18, 19, 20, 21, 22, \
- 23, 24, 25, 26, 27, 28, 29, 31, \
- 34, 35, 36, 37, 38, 39, /* %f2-%f7 */ \
- 40, 41, 42, 43, 44, 45, 46, 47, /* %f8-%f15 */ \
- 48, 49, 50, 51, 52, 53, 54, 55, /* %f16-%f23 */ \
- 56, 57, 58, 59, 60, 61, 62, 63, /* %f24-%f31 */ \
- 64, 65, 66, 67, 68, 69, 70, 71, /* %f32-%f39 */ \
- 72, 73, 74, 75, 76, 77, 78, 79, /* %f40-%f47 */ \
- 80, 81, 82, 83, 84, 85, 86, 87, /* %f48-%f55 */ \
- 88, 89, 90, 91, 92, 93, 94, 95, /* %f56-%f63 */ \
- 32, 33, /* %f0,%f1 */ \
- 96, 97, 98, 99, 100, /* %fcc0-3, %icc */ \
- 1, 4, 5, 6, 7, 0, 14, 30}
-
-/* This is the order in which to allocate registers for
- leaf functions. If all registers can fit in the "i" registers,
- then we have the possibility of having a leaf function. */
-
-#define REG_LEAF_ALLOC_ORDER \
-{ 2, 3, 24, 25, 26, 27, 28, 29, \
- 15, 8, 9, 10, 11, 12, 13, \
- 16, 17, 18, 19, 20, 21, 22, 23, \
- 34, 35, 36, 37, 38, 39, \
- 40, 41, 42, 43, 44, 45, 46, 47, \
- 48, 49, 50, 51, 52, 53, 54, 55, \
- 56, 57, 58, 59, 60, 61, 62, 63, \
- 64, 65, 66, 67, 68, 69, 70, 71, \
- 72, 73, 74, 75, 76, 77, 78, 79, \
- 80, 81, 82, 83, 84, 85, 86, 87, \
- 88, 89, 90, 91, 92, 93, 94, 95, \
- 32, 33, \
- 96, 97, 98, 99, 100, \
- 1, 4, 5, 6, 7, 0, 14, 30, 31}
-
-#define ORDER_REGS_FOR_LOCAL_ALLOC order_regs_for_local_alloc ()
-
-/* ??? %g7 is not a leaf register to effectively #undef LEAF_REGISTERS when
- -mflat is used. Function only_leaf_regs_used will return 0 if a global
- register is used and is not permitted in a leaf function. We make %g7
- a global reg if -mflat and voila. Since %g7 is a system register and is
- fixed it won't be used by gcc anyway. */
-
-#define LEAF_REGISTERS \
-{ 1, 1, 1, 1, 1, 1, 1, 0, \
- 0, 0, 0, 0, 0, 0, 1, 0, \
- 0, 0, 0, 0, 0, 0, 0, 0, \
- 1, 1, 1, 1, 1, 1, 0, 1, \
- 1, 1, 1, 1, 1, 1, 1, 1, \
- 1, 1, 1, 1, 1, 1, 1, 1, \
- 1, 1, 1, 1, 1, 1, 1, 1, \
- 1, 1, 1, 1, 1, 1, 1, 1, \
- 1, 1, 1, 1, 1, 1, 1, 1, \
- 1, 1, 1, 1, 1, 1, 1, 1, \
- 1, 1, 1, 1, 1, 1, 1, 1, \
- 1, 1, 1, 1, 1, 1, 1, 1, \
- 1, 1, 1, 1, 1}
-
-extern char leaf_reg_remap[];
-#define LEAF_REG_REMAP(REGNO) (leaf_reg_remap[REGNO])
-
-/* The class value for index registers, and the one for base regs. */
-#define INDEX_REG_CLASS GENERAL_REGS
-#define BASE_REG_CLASS GENERAL_REGS
-
-/* Local macro to handle the two v9 classes of FP regs. */
-#define FP_REG_CLASS_P(CLASS) ((CLASS) == FP_REGS || (CLASS) == EXTRA_FP_REGS)
-
-/* Get reg_class from a letter such as appears in the machine description.
- In the not-v9 case, coerce v9's 'e' class to 'f', so we can use 'e' in the
- .md file for v8 and v9.
- 'd' and 'b' are used for single and double precision VIS operations,
- if TARGET_VIS.
- 'h' is used for V8+ 64 bit global and out registers. */
-
-#define REG_CLASS_FROM_LETTER(C) \
-(TARGET_V9 \
- ? ((C) == 'f' ? FP_REGS \
- : (C) == 'e' ? EXTRA_FP_REGS \
- : (C) == 'c' ? FPCC_REGS \
- : ((C) == 'd' && TARGET_VIS) ? FP_REGS\
- : ((C) == 'b' && TARGET_VIS) ? EXTRA_FP_REGS\
- : ((C) == 'h' && TARGET_V8PLUS) ? I64_REGS\
- : NO_REGS) \
- : ((C) == 'f' ? FP_REGS \
- : (C) == 'e' ? FP_REGS \
- : (C) == 'c' ? FPCC_REGS \
- : NO_REGS))
-
-/* The letters I, J, K, L and M in a register constraint string
- can be used to stand for particular ranges of immediate operands.
- This macro defines what the ranges are.
- C is the letter, and VALUE is a constant value.
- Return 1 if VALUE is in the range specified by C.
-
- `I' is used for the range of constants an insn can actually contain.
- `J' is used for the range which is just zero (since that is R0).
- `K' is used for constants which can be loaded with a single sethi insn.
- `L' is used for the range of constants supported by the movcc insns.
- `M' is used for the range of constants supported by the movrcc insns. */
-
-#define SPARC_SIMM10_P(X) ((unsigned HOST_WIDE_INT) (X) + 0x200 < 0x400)
-#define SPARC_SIMM11_P(X) ((unsigned HOST_WIDE_INT) (X) + 0x400 < 0x800)
-#define SPARC_SIMM13_P(X) ((unsigned HOST_WIDE_INT) (X) + 0x1000 < 0x2000)
-/* 10 and 11 bit immediates are only used for a few specific insns.
- SMALL_INT is used throughout the port so we continue to use it. */
-#define SMALL_INT(X) (SPARC_SIMM13_P (INTVAL (X)))
-/* 13 bit immediate, considering only the low 32 bits */
-#define SMALL_INT32(X) (SPARC_SIMM13_P ((int)INTVAL (X) & 0xffffffff))
-#define SPARC_SETHI_P(X) \
-(((unsigned HOST_WIDE_INT) (X) & ~(unsigned HOST_WIDE_INT) 0xfffffc00) == 0)
-
-#define CONST_OK_FOR_LETTER_P(VALUE, C) \
- ((C) == 'I' ? SPARC_SIMM13_P (VALUE) \
- : (C) == 'J' ? (VALUE) == 0 \
- : (C) == 'K' ? SPARC_SETHI_P (VALUE) \
- : (C) == 'L' ? SPARC_SIMM11_P (VALUE) \
- : (C) == 'M' ? SPARC_SIMM10_P (VALUE) \
- : 0)
-
-/* Similar, but for floating constants, and defining letters G and H.
- Here VALUE is the CONST_DOUBLE rtx itself. */
-
-#define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \
- ((C) == 'G' ? fp_zero_operand (VALUE) \
- : (C) == 'H' ? arith_double_operand (VALUE, DImode) \
- : 0)
-
-/* Given an rtx X being reloaded into a reg required to be
- in class CLASS, return the class of reg to actually use.
- In general this is just CLASS; but on some machines
- in some cases it is preferable to use a more restrictive class. */
-/* - We can't load constants into FP registers. We can't load any FP
- constant if an 'E' constraint fails to match it.
- - Try and reload integer constants (symbolic or otherwise) back into
- registers directly, rather than having them dumped to memory. */
-
-#define PREFERRED_RELOAD_CLASS(X,CLASS) \
- (CONSTANT_P (X) \
- ? ((FP_REG_CLASS_P (CLASS) \
- || (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT \
- && (HOST_FLOAT_FORMAT != IEEE_FLOAT_FORMAT \
- || HOST_BITS_PER_INT != BITS_PER_WORD))) \
- ? NO_REGS \
- : (!FP_REG_CLASS_P (CLASS) \
- && GET_MODE_CLASS (GET_MODE (X)) == MODE_INT) \
- ? GENERAL_REGS \
- : (CLASS)) \
- : (CLASS))
-
-/* Return the register class of a scratch register needed to load IN into
- a register of class CLASS in MODE.
-
- We need a temporary when loading/storing a HImode/QImode value
- between memory and the FPU registers. This can happen when combine puts
- a paradoxical subreg in a float/fix conversion insn. */
-
-#define SECONDARY_INPUT_RELOAD_CLASS(CLASS, MODE, IN) \
- ((FP_REG_CLASS_P (CLASS) \
- && ((MODE) == HImode || (MODE) == QImode) \
- && (GET_CODE (IN) == MEM \
- || ((GET_CODE (IN) == REG || GET_CODE (IN) == SUBREG) \
- && true_regnum (IN) == -1))) \
- ? GENERAL_REGS \
- : (((TARGET_CM_MEDANY \
- && symbolic_operand ((IN), (MODE))) \
- || (TARGET_CM_EMBMEDANY \
- && text_segment_operand ((IN), (MODE)))) \
- && !flag_pic) \
- ? GENERAL_REGS \
- : NO_REGS)
-
-#define SECONDARY_OUTPUT_RELOAD_CLASS(CLASS, MODE, IN) \
- ((FP_REG_CLASS_P (CLASS) \
- && ((MODE) == HImode || (MODE) == QImode) \
- && (GET_CODE (IN) == MEM \
- || ((GET_CODE (IN) == REG || GET_CODE (IN) == SUBREG) \
- && true_regnum (IN) == -1))) \
- ? GENERAL_REGS \
- : (((TARGET_CM_MEDANY \
- && symbolic_operand ((IN), (MODE))) \
- || (TARGET_CM_EMBMEDANY \
- && text_segment_operand ((IN), (MODE)))) \
- && !flag_pic) \
- ? GENERAL_REGS \
- : NO_REGS)
-
-/* On SPARC it is not possible to directly move data between
- GENERAL_REGS and FP_REGS. */
-#define SECONDARY_MEMORY_NEEDED(CLASS1, CLASS2, MODE) \
- (FP_REG_CLASS_P (CLASS1) != FP_REG_CLASS_P (CLASS2))
-
-/* Return the stack location to use for secondary memory needed reloads.
- We want to use the reserved location just below the frame pointer.
- However, we must ensure that there is a frame, so use assign_stack_local
- if the frame size is zero. */
-#define SECONDARY_MEMORY_NEEDED_RTX(MODE) \
- (get_frame_size () == 0 \
- ? assign_stack_local (MODE, GET_MODE_SIZE (MODE), 0) \
- : gen_rtx_MEM (MODE, gen_rtx_PLUS (Pmode, frame_pointer_rtx, \
- GEN_INT (STARTING_FRAME_OFFSET))))
-
-/* Get_secondary_mem widens its argument to BITS_PER_WORD which loses on v9
- because the movsi and movsf patterns don't handle r/f moves.
- For v8 we copy the default definition. */
-#define SECONDARY_MEMORY_NEEDED_MODE(MODE) \
- (TARGET_ARCH64 \
- ? (GET_MODE_BITSIZE (MODE) < 32 \
- ? mode_for_size (32, GET_MODE_CLASS (MODE), 0) \
- : MODE) \
- : (GET_MODE_BITSIZE (MODE) < BITS_PER_WORD \
- ? mode_for_size (BITS_PER_WORD, GET_MODE_CLASS (MODE), 0) \
- : MODE))
-
-/* Return the maximum number of consecutive registers
- needed to represent mode MODE in a register of class CLASS. */
-/* On SPARC, this is the size of MODE in words. */
-#define CLASS_MAX_NREGS(CLASS, MODE) \
- (FP_REG_CLASS_P (CLASS) ? (GET_MODE_SIZE (MODE) + 3) / 4 \
- : (GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
-
-/* Stack layout; function entry, exit and calling. */
-
-/* Define the number of register that can hold parameters.
- This macro is only used in other macro definitions below and in sparc.c.
- MODE is the mode of the argument.
- !v9: All args are passed in %o0-%o5.
- v9: %o0-%o5 and %f0-%f31 are cumulatively used to pass values.
- See the description in sparc.c. */
-#define NPARM_REGS(MODE) \
-(TARGET_ARCH64 \
- ? (GET_MODE_CLASS (MODE) == MODE_FLOAT ? 32 : 6) \
- : 6)
-
-/* Define this if pushing a word on the stack
- makes the stack pointer a smaller address. */
-#define STACK_GROWS_DOWNWARD
-
-/* Define this if the nominal address of the stack frame
- is at the high-address end of the local variables;
- that is, each additional local variable allocated
- goes at a more negative offset in the frame. */
-#define FRAME_GROWS_DOWNWARD
-
-/* Offset within stack frame to start allocating local variables at.
- If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
- first local allocated. Otherwise, it is the offset to the BEGINNING
- of the first local allocated. */
-/* This allows space for one TFmode floating point value. */
-#define STARTING_FRAME_OFFSET \
- (TARGET_ARCH64 ? (SPARC_STACK_BIAS - 16) \
- : (-SPARC_STACK_ALIGN (LONG_DOUBLE_TYPE_SIZE / BITS_PER_UNIT)))
-
-/* If we generate an insn to push BYTES bytes,
- this says how many the stack pointer really advances by.
- On SPARC, don't define this because there are no push insns. */
-/* #define PUSH_ROUNDING(BYTES) */
-
-/* Offset of first parameter from the argument pointer register value.
- !v9: This is 64 for the ins and locals, plus 4 for the struct-return reg
- even if this function isn't going to use it.
- v9: This is 128 for the ins and locals. */
-#define FIRST_PARM_OFFSET(FNDECL) \
- (TARGET_ARCH64 ? (SPARC_STACK_BIAS + 16 * UNITS_PER_WORD) \
- : (STRUCT_VALUE_OFFSET + UNITS_PER_WORD))
-
-/* Offset from the argument pointer register value to the CFA. */
-
-#define ARG_POINTER_CFA_OFFSET SPARC_STACK_BIAS
-
-/* When a parameter is passed in a register, stack space is still
- allocated for it.
- !v9: All 6 possible integer registers have backing store allocated.
- v9: Only space for the arguments passed is allocated. */
-/* ??? Ideally, we'd use zero here (as the minimum), but zero has special
- meaning to the backend. Further, we need to be able to detect if a
- varargs/unprototyped function is called, as they may want to spill more
- registers than we've provided space. Ugly, ugly. So for now we retain
- all 6 slots even for v9. */
-#define REG_PARM_STACK_SPACE(DECL) (6 * UNITS_PER_WORD)
-
-/* Keep the stack pointer constant throughout the function.
- This is both an optimization and a necessity: longjmp
- doesn't behave itself when the stack pointer moves within
- the function! */
-#define ACCUMULATE_OUTGOING_ARGS
-
-/* Value is the number of bytes of arguments automatically
- popped when returning from a subroutine call.
- FUNDECL is the declaration node of the function (as a tree),
- FUNTYPE is the data type of the function (as a tree),
- or for a library call it is an identifier node for the subroutine name.
- SIZE is the number of bytes of arguments passed on the stack. */
-
-#define RETURN_POPS_ARGS(FUNDECL,FUNTYPE,SIZE) 0
-
-/* Some subroutine macros specific to this machine.
- When !TARGET_FPU, put float return values in the general registers,
- since we don't have any fp registers. */
-#define BASE_RETURN_VALUE_REG(MODE) \
- (TARGET_ARCH64 \
- ? (TARGET_FPU && FLOAT_MODE_P (MODE) ? 32 : 8) \
- : (((MODE) == SFmode || (MODE) == DFmode) && TARGET_FPU ? 32 : 8))
-
-#define BASE_OUTGOING_VALUE_REG(MODE) \
- (TARGET_ARCH64 \
- ? (TARGET_FPU && FLOAT_MODE_P (MODE) ? 32 \
- : TARGET_FLAT ? 8 : 24) \
- : (((MODE) == SFmode || (MODE) == DFmode) && TARGET_FPU ? 32 \
- : (TARGET_FLAT ? 8 : 24)))
-
-#define BASE_PASSING_ARG_REG(MODE) \
- (TARGET_ARCH64 \
- ? (TARGET_FPU && FLOAT_MODE_P (MODE) ? 32 : 8) \
- : 8)
-
-/* ??? FIXME -- seems wrong for v9 structure passing... */
-#define BASE_INCOMING_ARG_REG(MODE) \
- (TARGET_ARCH64 \
- ? (TARGET_FPU && FLOAT_MODE_P (MODE) ? 32 \
- : TARGET_FLAT ? 8 : 24) \
- : (TARGET_FLAT ? 8 : 24))
-
-/* Define this macro if the target machine has "register windows". This
- C expression returns the register number as seen by the called function
- corresponding to register number OUT as seen by the calling function.
- Return OUT if register number OUT is not an outbound register. */
-
-#define INCOMING_REGNO(OUT) \
- ((TARGET_FLAT || (OUT) < 8 || (OUT) > 15) ? (OUT) : (OUT) + 16)
-
-/* Define this macro if the target machine has "register windows". This
- C expression returns the register number as seen by the calling function
- corresponding to register number IN as seen by the called function.
- Return IN if register number IN is not an inbound register. */
-
-#define OUTGOING_REGNO(IN) \
- ((TARGET_FLAT || (IN) < 24 || (IN) > 31) ? (IN) : (IN) - 16)
-
-/* Define how to find the value returned by a function.
- VALTYPE is the data type of the value (as a tree).
- If the precise function being called is known, FUNC is its FUNCTION_DECL;
- otherwise, FUNC is 0. */
-
-/* On SPARC the value is found in the first "output" register. */
-
-extern struct rtx_def *function_value ();
-#define FUNCTION_VALUE(VALTYPE, FUNC) \
- function_value ((VALTYPE), TYPE_MODE (VALTYPE), 1)
-
-/* But the called function leaves it in the first "input" register. */
-
-#define FUNCTION_OUTGOING_VALUE(VALTYPE, FUNC) \
- function_value ((VALTYPE), TYPE_MODE (VALTYPE), 0)
-
-/* Define how to find the value returned by a library function
- assuming the value has mode MODE. */
-
-#define LIBCALL_VALUE(MODE) \
- function_value (NULL_TREE, (MODE), 1)
-
-/* 1 if N is a possible register number for a function value
- as seen by the caller.
- On SPARC, the first "output" reg is used for integer values,
- and the first floating point register is used for floating point values. */
-
-#define FUNCTION_VALUE_REGNO_P(N) ((N) == 8 || (N) == 32)
-
-/* Define the size of space to allocate for the return value of an
- untyped_call. */
-
-#define APPLY_RESULT_SIZE 16
-
-/* 1 if N is a possible register number for function argument passing.
- On SPARC, these are the "output" registers. v9 also uses %f0-%f31. */
-
-#define FUNCTION_ARG_REGNO_P(N) \
-(TARGET_ARCH64 \
- ? (((N) >= 8 && (N) <= 13) || ((N) >= 32 && (N) <= 63)) \
- : ((N) >= 8 && (N) <= 13))
-
-/* Define a data type for recording info about an argument list
- during the scan of that argument list. This data type should
- hold all necessary information about the function itself
- and about the args processed so far, enough to enable macros
- such as FUNCTION_ARG to determine where the next arg should go.
-
- On SPARC (!v9), this is a single integer, which is a number of words
- of arguments scanned so far (including the invisible argument,
- if any, which holds the structure-value-address).
- Thus 7 or more means all following args should go on the stack.
-
- For v9, we also need to know whether a prototype is present. */
-
-struct sparc_args {
- int words; /* number of words passed so far */
- int prototype_p; /* non-zero if a prototype is present */
- int libcall_p; /* non-zero if a library call */
-};
-#define CUMULATIVE_ARGS struct sparc_args
-
-/* Initialize a variable CUM of type CUMULATIVE_ARGS
- for a call to a function whose data type is FNTYPE.
- For a library call, FNTYPE is 0. */
-
-extern void init_cumulative_args ();
-#define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT) \
-init_cumulative_args (& (CUM), (FNTYPE), (LIBNAME), (INDIRECT));
-
-/* Update the data in CUM to advance over an argument
- of mode MODE and data type TYPE.
- TYPE is null for libcalls where that information may not be available. */
-
-extern void function_arg_advance ();
-#define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
-function_arg_advance (& (CUM), (MODE), (TYPE), (NAMED))
-
-/* Determine where to put an argument to a function.
- Value is zero to push the argument on the stack,
- or a hard register in which to store the argument.
-
- MODE is the argument's machine mode.
- TYPE is the data type of the argument (as a tree).
- This is null for libcalls where that information may
- not be available.
- CUM is a variable of type CUMULATIVE_ARGS which gives info about
- the preceding args and about the function being called.
- NAMED is nonzero if this argument is a named parameter
- (otherwise it is an extra parameter matching an ellipsis). */
-
-extern struct rtx_def *function_arg ();
-#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
-function_arg (& (CUM), (MODE), (TYPE), (NAMED), 0)
-
-/* Define where a function finds its arguments.
- This is different from FUNCTION_ARG because of register windows. */
-
-#define FUNCTION_INCOMING_ARG(CUM, MODE, TYPE, NAMED) \
-function_arg (& (CUM), (MODE), (TYPE), (NAMED), 1)
-
-/* For an arg passed partly in registers and partly in memory,
- this is the number of registers used.
- For args passed entirely in registers or entirely in memory, zero. */
-
-extern int function_arg_partial_nregs ();
-#define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \
-function_arg_partial_nregs (& (CUM), (MODE), (TYPE), (NAMED))
-
-/* A C expression that indicates when an argument must be passed by reference.
- If nonzero for an argument, a copy of that argument is made in memory and a
- pointer to the argument is passed instead of the argument itself.
- The pointer is passed in whatever way is appropriate for passing a pointer
- to that type. */
-
-extern int function_arg_pass_by_reference ();
-#define FUNCTION_ARG_PASS_BY_REFERENCE(CUM, MODE, TYPE, NAMED) \
-function_arg_pass_by_reference (& (CUM), (MODE), (TYPE), (NAMED))
-
-/* If defined, a C expression which determines whether, and in which direction,
- to pad out an argument with extra space. The value should be of type
- `enum direction': either `upward' to pad above the argument,
- `downward' to pad below, or `none' to inhibit padding. */
-
-#define FUNCTION_ARG_PADDING(MODE, TYPE) \
-function_arg_padding ((MODE), (TYPE))
-
-/* If defined, a C expression that gives the alignment boundary, in bits,
- of an argument with the specified mode and type. If it is not defined,
- PARM_BOUNDARY is used for all arguments.
- For sparc64, objects requiring 16 byte alignment are passed that way. */
-
-#define FUNCTION_ARG_BOUNDARY(MODE, TYPE) \
-((TARGET_ARCH64 \
- && (GET_MODE_ALIGNMENT (MODE) == 128 \
- || ((TYPE) && TYPE_ALIGN (TYPE) == 128))) \
- ? 128 : PARM_BOUNDARY)
-
-/* Define the information needed to generate branch and scc insns. This is
- stored from the compare operation. Note that we can't use "rtx" here
- since it hasn't been defined! */
-
-extern struct rtx_def *sparc_compare_op0, *sparc_compare_op1;
-
-/* Define the function that build the compare insn for scc and bcc. */
-
-extern struct rtx_def *gen_compare_reg ();
-
-/* This function handles all v9 scc insns */
-
-extern int gen_v9_scc ();
-
-/* Generate the special assembly code needed to tell the assembler whatever
- it might need to know about the return value of a function.
-
- For Sparc assemblers, we need to output a .proc pseudo-op which conveys
- information to the assembler relating to peephole optimization (done in
- the assembler). */
-
-#define ASM_DECLARE_RESULT(FILE, RESULT) \
- fprintf ((FILE), "\t.proc\t0%lo\n", sparc_type_code (TREE_TYPE (RESULT)))
-
-/* Output the label for a function definition. */
-
-#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
-do { \
- ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \
- ASM_OUTPUT_LABEL (FILE, NAME); \
-} while (0)
-
-/* This macro generates the assembly code for function entry.
- FILE is a stdio stream to output the code to.
- SIZE is an int: how many units of temporary storage to allocate.
- Refer to the array `regs_ever_live' to determine which registers
- to save; `regs_ever_live[I]' is nonzero if register number I
- is ever used in the function. This macro is responsible for
- knowing which registers should not be saved even if used. */
-
-/* On SPARC, move-double insns between fpu and cpu need an 8-byte block
- of memory. If any fpu reg is used in the function, we allocate
- such a block here, at the bottom of the frame, just in case it's needed.
-
- If this function is a leaf procedure, then we may choose not
- to do a "save" insn. The decision about whether or not
- to do this is made in regclass.c. */
-
-#define FUNCTION_PROLOGUE(FILE, SIZE) \
- (TARGET_FLAT ? sparc_flat_output_function_prologue (FILE, (int)SIZE) \
- : output_function_prologue (FILE, (int)SIZE, \
- current_function_uses_only_leaf_regs))
-
-/* Output assembler code to FILE to increment profiler label # LABELNO
- for profiling a function entry. */
-
-#define FUNCTION_PROFILER(FILE, LABELNO) \
- sparc_function_profiler(FILE, LABELNO)
-
-/* Set the name of the mcount function for the system. */
-
-#define MCOUNT_FUNCTION "*mcount"
-
-/* The following macro shall output assembler code to FILE
- to initialize basic-block profiling. */
-
-#define FUNCTION_BLOCK_PROFILER(FILE, BLOCK_OR_LABEL) \
- sparc_function_block_profiler(FILE, BLOCK_OR_LABEL)
-
-/* The following macro shall output assembler code to FILE
- to increment a counter associated with basic block number BLOCKNO. */
-
-#define BLOCK_PROFILER(FILE, BLOCKNO) \
- sparc_block_profiler (FILE, BLOCKNO)
-
-/* The following macro shall output assembler code to FILE
- to indicate a return from function during basic-block profiling. */
-
-#define FUNCTION_BLOCK_PROFILER_EXIT(FILE) \
- sparc_function_block_profiler_exit(FILE)
-
-/* The function `__bb_trace_func' is called in every basic block
- and is not allowed to change the machine state. Saving (restoring)
- the state can either be done in the BLOCK_PROFILER macro,
- before calling function (rsp. after returning from function)
- `__bb_trace_func', or it can be done inside the function by
- defining the macros:
-
- MACHINE_STATE_SAVE(ID)
- MACHINE_STATE_RESTORE(ID)
-
- In the latter case care must be taken, that the prologue code
- of function `__bb_trace_func' does not already change the
- state prior to saving it with MACHINE_STATE_SAVE.
-
- The parameter `ID' is a string identifying a unique macro use.
-
- On sparc it is sufficient to save the psw register to memory.
- Unfortunately the psw register can be read in supervisor mode only,
- so we read only the condition codes by using branch instructions
- and hope that this is enough. */
-
-#define MACHINE_STATE_SAVE(ID) \
- int ms_flags, ms_saveret; \
- asm volatile( \
- "mov %%g0,%0\n\
- be,a LFLGNZ"ID"\n\
- or %0,4,%0\n\
-LFLGNZ"ID":\n\
- bcs,a LFLGNC"ID"\n\
- or %0,1,%0\n\
-LFLGNC"ID":\n\
- bvs,a LFLGNV"ID"\n\
- or %0,2,%0\n\
-LFLGNV"ID":\n\
- bneg,a LFLGNN"ID"\n\
- or %0,8,%0\n\
-LFLGNN"ID":\n\
- mov %%g2,%1" \
- : "=r"(ms_flags), "=r"(ms_saveret));
-
-/* On sparc MACHINE_STATE_RESTORE restores the psw register from memory.
- The psw register can be written in supervisor mode only,
- which is true even for simple condition codes.
- We use some combination of instructions to produce the
- proper condition codes, but some flag combinations can not
- be generated in this way. If this happens an unimplemented
- instruction will be executed to abort the program. */
-
-#define MACHINE_STATE_RESTORE(ID) \
-{ extern char flgtab[] __asm__("LFLGTAB"ID); \
- int scratch; \
- asm volatile ( \
- "jmpl %2+%1,%%g0\n\
- ! Do part of VC in the delay slot here, as it needs 3 insns.\n\
- addcc 2,%3,%%g0\n\
-LFLGTAB" ID ":\n\
- ! 0\n\
- ba LFLGRET"ID"\n\
- orcc 1,%%g0,%%g0\n\
- ! C\n\
- ba LFLGRET"ID"\n\
- addcc 2,%3,%%g0\n\
- ! V\n\
- unimp\n\
- nop\n\
- ! VC\n\
- ba LFLGRET"ID"\n\
- addxcc %4,%4,%0\n\
- ! Z\n\
- ba LFLGRET"ID"\n\
- subcc %%g0,%%g0,%%g0\n\
- ! ZC\n\
- ba LFLGRET"ID"\n\
- addcc 1,%3,%0\n\
- ! ZVC\n\
- ba LFLGRET"ID"\n\
- addcc %4,%4,%0\n\
- ! N\n\
- ba LFLGRET"ID"\n\
- orcc %%g0,-1,%%g0\n\
- ! NC\n\
- ba LFLGRET"ID"\n\
- addcc %%g0,%3,%%g0\n\
- ! NV\n\
- unimp\n\
- nop\n\
- ! NVC\n\
- unimp\n\
- nop\n\
- ! NZ\n\
- unimp\n\
- nop\n\
- ! NZC\n\
- unimp\n\
- nop\n\
- ! NZV\n\
- unimp\n\
- nop\n\
- ! NZVC\n\
- unimp\n\
- nop\n\
-LFLGRET"ID":\n\
- mov %5,%%g2" \
- : "=r"(scratch) \
- : "r"(ms_flags*8), "r"(flgtab), "r"(-1), \
- "r"(0x80000000), "r"(ms_saveret) \
- : "cc", "%g2"); }
-
-/* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
- the stack pointer does not matter. The value is tested only in
- functions that have frame pointers.
- No definition is equivalent to always zero. */
-
-extern int current_function_calls_alloca;
-extern int current_function_outgoing_args_size;
-
-#define EXIT_IGNORE_STACK \
- (get_frame_size () != 0 \
- || current_function_calls_alloca || current_function_outgoing_args_size)
-
-/* This macro generates the assembly code for function exit,
- on machines that need it. If FUNCTION_EPILOGUE is not defined
- then individual return instructions are generated for each
- return statement. Args are same as for FUNCTION_PROLOGUE.
-
- The function epilogue should not depend on the current stack pointer!
- It should use the frame pointer only. This is mandatory because
- of alloca; we also take advantage of it to omit stack adjustments
- before returning. */
-
-/* This declaration is needed due to traditional/ANSI
- incompatibilities which cannot be #ifdefed away
- because they occur inside of macros. Sigh. */
-extern union tree_node *current_function_decl;
-
-#define FUNCTION_EPILOGUE(FILE, SIZE) \
- (TARGET_FLAT ? sparc_flat_output_function_epilogue (FILE, (int)SIZE) \
- : output_function_epilogue (FILE, (int)SIZE, \
- current_function_uses_only_leaf_regs))
-
-#define DELAY_SLOTS_FOR_EPILOGUE \
- (TARGET_FLAT ? sparc_flat_epilogue_delay_slots () : 1)
-#define ELIGIBLE_FOR_EPILOGUE_DELAY(trial, slots_filled) \
- (TARGET_FLAT ? sparc_flat_eligible_for_epilogue_delay (trial, slots_filled) \
- : eligible_for_epilogue_delay (trial, slots_filled))
-
-/* Define registers used by the epilogue and return instruction. */
-#define EPILOGUE_USES(REGNO) \
- (!TARGET_FLAT && REGNO == 31)
-
-/* Length in units of the trampoline for entering a nested function. */
-
-#define TRAMPOLINE_SIZE (TARGET_ARCH64 ? 32 : 16)
-
-#define TRAMPOLINE_ALIGNMENT 128 /* 16 bytes */
-
-/* Emit RTL insns to initialize the variable parts of a trampoline.
- FNADDR is an RTX for the address of the function's pure code.
- CXT is an RTX for the static chain value for the function. */
-
-void sparc_initialize_trampoline ();
-void sparc64_initialize_trampoline ();
-#define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \
- if (TARGET_ARCH64) \
- sparc64_initialize_trampoline (TRAMP, FNADDR, CXT); \
- else \
- sparc_initialize_trampoline (TRAMP, FNADDR, CXT)
-
-/* Generate necessary RTL for __builtin_saveregs().
- ARGLIST is the argument list; see expr.c. */
-
-extern struct rtx_def *sparc_builtin_saveregs ();
-#define EXPAND_BUILTIN_SAVEREGS(ARGLIST) sparc_builtin_saveregs (ARGLIST)
-
-/* Define this macro if the location where a function argument is passed
- depends on whether or not it is a named argument.
-
- This macro controls how the NAMED argument to FUNCTION_ARG
- is set for varargs and stdarg functions. With this macro defined,
- the NAMED argument is always true for named arguments, and false for
- unnamed arguments. If this is not defined, but SETUP_INCOMING_VARARGS
- is defined, then all arguments are treated as named. Otherwise, all named
- arguments except the last are treated as named.
- For the v9 we want NAMED to mean what it says it means. */
-
-#define STRICT_ARGUMENT_NAMING TARGET_V9
-
-/* Generate RTL to flush the register windows so as to make arbitrary frames
- available. */
-#define SETUP_FRAME_ADDRESSES() \
- emit_insn (gen_flush_register_windows ())
-
-/* Given an rtx for the address of a frame,
- return an rtx for the address of the word in the frame
- that holds the dynamic chain--the previous frame's address.
- ??? -mflat support? */
-#define DYNAMIC_CHAIN_ADDRESS(frame) \
- gen_rtx_PLUS (Pmode, frame, GEN_INT (14 * UNITS_PER_WORD))
-
-/* The return address isn't on the stack, it is in a register, so we can't
- access it from the current frame pointer. We can access it from the
- previous frame pointer though by reading a value from the register window
- save area. */
-#define RETURN_ADDR_IN_PREVIOUS_FRAME
-
-/* This is the offset of the return address to the true next instruction to be
- executed for the current function. */
-#define RETURN_ADDR_OFFSET \
- (8 + 4 * (! TARGET_ARCH64 && current_function_returns_struct))
-
-/* The current return address is in %i7. The return address of anything
- farther back is in the register window save area at [%fp+60]. */
-/* ??? This ignores the fact that the actual return address is +8 for normal
- returns, and +12 for structure returns. */
-#define RETURN_ADDR_RTX(count, frame) \
- ((count == -1) \
- ? gen_rtx_REG (Pmode, 31) \
- : gen_rtx_MEM (Pmode, \
- memory_address (Pmode, plus_constant (frame, 15 * UNITS_PER_WORD))))
-
-/* Before the prologue, the return address is %o7 + 8. OK, sometimes it's
- +12, but always using +8 is close enough for frame unwind purposes.
- Actually, just using %o7 is close enough for unwinding, but %o7+8
- is something you can return to. */
-#define INCOMING_RETURN_ADDR_RTX \
- gen_rtx_PLUS (word_mode, gen_rtx_REG (word_mode, 15), GEN_INT (8))
-
-/* The offset from the incoming value of %sp to the top of the stack frame
- for the current function. On sparc64, we have to account for the stack
- bias if present. */
-#define INCOMING_FRAME_SP_OFFSET SPARC_STACK_BIAS
-
-#define DOESNT_NEED_UNWINDER (! TARGET_FLAT)
-
-/* Addressing modes, and classification of registers for them. */
-
-/* #define HAVE_POST_INCREMENT 0 */
-/* #define HAVE_POST_DECREMENT 0 */
-
-/* #define HAVE_PRE_DECREMENT 0 */
-/* #define HAVE_PRE_INCREMENT 0 */
-
-/* Macros to check register numbers against specific register classes. */
-
-/* These assume that REGNO is a hard or pseudo reg number.
- They give nonzero only if REGNO is a hard reg of the suitable class
- or a pseudo reg currently allocated to a suitable hard reg.
- Since they use reg_renumber, they are safe only once reg_renumber
- has been allocated, which happens in local-alloc.c. */
-
-#define REGNO_OK_FOR_INDEX_P(REGNO) \
-((REGNO) < 32 || (unsigned) reg_renumber[REGNO] < (unsigned)32)
-#define REGNO_OK_FOR_BASE_P(REGNO) \
-((REGNO) < 32 || (unsigned) reg_renumber[REGNO] < (unsigned)32)
-#define REGNO_OK_FOR_FP_P(REGNO) \
- (((unsigned) (REGNO) - 32 < (TARGET_V9 ? (unsigned)64 : (unsigned)32)) \
- || ((unsigned) reg_renumber[REGNO] - 32 < (TARGET_V9 ? (unsigned)64 : (unsigned)32)))
-#define REGNO_OK_FOR_CCFP_P(REGNO) \
- (TARGET_V9 \
- && (((unsigned) (REGNO) - 96 < (unsigned)4) \
- || ((unsigned) reg_renumber[REGNO] - 96 < (unsigned)4)))
-
-/* Now macros that check whether X is a register and also,
- strictly, whether it is in a specified class.
-
- These macros are specific to the SPARC, and may be used only
- in code for printing assembler insns and in conditions for
- define_optimization. */
-
-/* 1 if X is an fp register. */
-
-#define FP_REG_P(X) (REG_P (X) && REGNO_OK_FOR_FP_P (REGNO (X)))
-
-/* Is X, a REG, an in or global register? i.e. is regno 0..7 or 24..31 */
-#define IN_OR_GLOBAL_P(X) (REGNO (X) < 8 || (REGNO (X) >= 24 && REGNO (X) <= 31))
-
-/* Maximum number of registers that can appear in a valid memory address. */
-
-#define MAX_REGS_PER_ADDRESS 2
-
-/* Recognize any constant value that is a valid address.
- When PIC, we do not accept an address that would require a scratch reg
- to load into a register. */
-
-#define CONSTANT_ADDRESS_P(X) \
- (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \
- || GET_CODE (X) == CONST_INT || GET_CODE (X) == HIGH \
- || (GET_CODE (X) == CONST \
- && ! (flag_pic && pic_address_needs_scratch (X))))
-
-/* Define this, so that when PIC, reload won't try to reload invalid
- addresses which require two reload registers. */
-
-#define LEGITIMATE_PIC_OPERAND_P(X) (! pic_address_needs_scratch (X))
-
-/* Nonzero if the constant value X is a legitimate general operand.
- Anything can be made to work except floating point constants.
- If TARGET_VIS, 0.0 can be made to work as well. */
-
-#define LEGITIMATE_CONSTANT_P(X) \
- (GET_CODE (X) != CONST_DOUBLE || GET_MODE (X) == VOIDmode || \
- (TARGET_VIS && (GET_MODE (X) == SFmode || GET_MODE (X) == DFmode) && \
- fp_zero_operand (X)))
-
-/* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
- and check its validity for a certain class.
- We have two alternate definitions for each of them.
- The usual definition accepts all pseudo regs; the other rejects
- them unless they have been allocated suitable hard regs.
- The symbol REG_OK_STRICT causes the latter definition to be used.
-
- Most source files want to accept pseudo regs in the hope that
- they will get allocated to the class that the insn wants them to be in.
- Source files for reload pass need to be strict.
- After reload, it makes no difference, since pseudo regs have
- been eliminated by then. */
-
-/* Optional extra constraints for this machine.
-
- 'T' handles memory addresses where the alignment is known to
- be at least 8 bytes.
-
- `U' handles all pseudo registers or a hard even numbered
- integer register, needed for ldd/std instructions. */
-
-#ifndef REG_OK_STRICT
-
-/* Nonzero if X is a hard reg that can be used as an index
- or if it is a pseudo reg. */
-#define REG_OK_FOR_INDEX_P(X) \
- (((unsigned) REGNO (X)) - 32 >= (FIRST_PSEUDO_REGISTER - 32))
-/* Nonzero if X is a hard reg that can be used as a base reg
- or if it is a pseudo reg. */
-#define REG_OK_FOR_BASE_P(X) \
- (((unsigned) REGNO (X)) - 32 >= (FIRST_PSEUDO_REGISTER - 32))
-
-/* 'T', 'U' are for aligned memory loads which aren't needed for v9. */
-
-#define EXTRA_CONSTRAINT(OP, C) \
- ((! TARGET_ARCH64 && (C) == 'T') \
- ? (mem_min_alignment (OP, 8)) \
- : ((! TARGET_ARCH64 && (C) == 'U') \
- ? (register_ok_for_ldd (OP)) \
- : 0))
-
-#else
-
-/* Nonzero if X is a hard reg that can be used as an index. */
-#define REG_OK_FOR_INDEX_P(X) REGNO_OK_FOR_INDEX_P (REGNO (X))
-/* Nonzero if X is a hard reg that can be used as a base reg. */
-#define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P (REGNO (X))
-
-#define EXTRA_CONSTRAINT(OP, C) \
- ((! TARGET_ARCH64 && (C) == 'T') \
- ? mem_min_alignment (OP, 8) && strict_memory_address_p (Pmode, XEXP (OP, 0)) \
- : ((! TARGET_ARCH64 && (C) == 'U') \
- ? (GET_CODE (OP) == REG \
- && (REGNO (OP) < FIRST_PSEUDO_REGISTER \
- || reg_renumber[REGNO (OP)] >= 0) \
- && register_ok_for_ldd (OP)) \
- : 0))
-#endif
-
-/* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
- that is a valid memory address for an instruction.
- The MODE argument is the machine mode for the MEM expression
- that wants to use this address.
-
- On SPARC, the actual legitimate addresses must be REG+REG or REG+SMALLINT
- ordinarily. This changes a bit when generating PIC.
-
- If you change this, execute "rm explow.o recog.o reload.o". */
-
-#define RTX_OK_FOR_BASE_P(X) \
- ((GET_CODE (X) == REG && REG_OK_FOR_BASE_P (X)) \
- || (GET_CODE (X) == SUBREG \
- && GET_CODE (SUBREG_REG (X)) == REG \
- && REG_OK_FOR_BASE_P (SUBREG_REG (X))))
-
-#define RTX_OK_FOR_INDEX_P(X) \
- ((GET_CODE (X) == REG && REG_OK_FOR_INDEX_P (X)) \
- || (GET_CODE (X) == SUBREG \
- && GET_CODE (SUBREG_REG (X)) == REG \
- && REG_OK_FOR_INDEX_P (SUBREG_REG (X))))
-
-#define RTX_OK_FOR_OFFSET_P(X) \
- (GET_CODE (X) == CONST_INT && INTVAL (X) >= -0x1000 && INTVAL (X) < 0x1000)
-
-#define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \
-{ if (RTX_OK_FOR_BASE_P (X)) \
- goto ADDR; \
- else if (GET_CODE (X) == PLUS) \
- { \
- register rtx op0 = XEXP (X, 0); \
- register rtx op1 = XEXP (X, 1); \
- if (flag_pic && op0 == pic_offset_table_rtx) \
- { \
- if (RTX_OK_FOR_BASE_P (op1)) \
- goto ADDR; \
- else if (flag_pic == 1 \
- && GET_CODE (op1) != REG \
- && GET_CODE (op1) != LO_SUM \
- && GET_CODE (op1) != MEM \
- && (GET_CODE (op1) != CONST_INT \
- || SMALL_INT (op1))) \
- goto ADDR; \
- } \
- else if (RTX_OK_FOR_BASE_P (op0)) \
- { \
- if ((RTX_OK_FOR_INDEX_P (op1) \
- /* We prohibit REG + REG for TFmode when \
- there are no instructions which accept \
- REG+REG instructions. We do this \
- because REG+REG is not an offsetable \
- address. If we get the situation \
- in reload where source and destination \
- of a movtf pattern are both MEMs with \
- REG+REG address, then only one of them \
- gets converted to an offsetable \
- address. */ \
- && (MODE != TFmode \
- || (TARGET_FPU && TARGET_ARCH64 \
- && TARGET_V9 \
- && TARGET_HARD_QUAD))) \
- || RTX_OK_FOR_OFFSET_P (op1)) \
- goto ADDR; \
- } \
- else if (RTX_OK_FOR_BASE_P (op1)) \
- { \
- if ((RTX_OK_FOR_INDEX_P (op0) \
- /* See the previous comment. */ \
- && (MODE != TFmode \
- || (TARGET_FPU && TARGET_ARCH64 \
- && TARGET_V9 \
- && TARGET_HARD_QUAD))) \
- || RTX_OK_FOR_OFFSET_P (op0)) \
- goto ADDR; \
- } \
- } \
- else if (GET_CODE (X) == LO_SUM) \
- { \
- register rtx op0 = XEXP (X, 0); \
- register rtx op1 = XEXP (X, 1); \
- if (RTX_OK_FOR_BASE_P (op0) \
- && CONSTANT_P (op1) \
- /* We can't allow TFmode, because an offset \
- greater than or equal to the alignment (8) \
- may cause the LO_SUM to overflow if !v9. */\
- && (MODE != TFmode || TARGET_V9)) \
- goto ADDR; \
- } \
- else if (GET_CODE (X) == CONST_INT && SMALL_INT (X)) \
- goto ADDR; \
-}
-
-/* Try machine-dependent ways of modifying an illegitimate address
- to be legitimate. If we find one, return the new, valid address.
- This macro is used in only one place: `memory_address' in explow.c.
-
- OLDX is the address as it was before break_out_memory_refs was called.
- In some cases it is useful to look at this to decide what needs to be done.
-
- MODE and WIN are passed so that this macro can use
- GO_IF_LEGITIMATE_ADDRESS.
-
- It is always safe for this macro to do nothing. It exists to recognize
- opportunities to optimize the output. */
-
-/* On SPARC, change REG+N into REG+REG, and REG+(X*Y) into REG+REG. */
-extern struct rtx_def *legitimize_pic_address ();
-#define LEGITIMIZE_ADDRESS(X,OLDX,MODE,WIN) \
-{ rtx sparc_x = (X); \
- if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 0)) == MULT) \
- (X) = gen_rtx_PLUS (Pmode, XEXP (X, 1), \
- force_operand (XEXP (X, 0), NULL_RTX)); \
- if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 1)) == MULT) \
- (X) = gen_rtx_PLUS (Pmode, XEXP (X, 0), \
- force_operand (XEXP (X, 1), NULL_RTX)); \
- if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 0)) == PLUS) \
- (X) = gen_rtx_PLUS (Pmode, force_operand (XEXP (X, 0), NULL_RTX),\
- XEXP (X, 1)); \
- if (GET_CODE (X) == PLUS && GET_CODE (XEXP (X, 1)) == PLUS) \
- (X) = gen_rtx_PLUS (Pmode, XEXP (X, 0), \
- force_operand (XEXP (X, 1), NULL_RTX)); \
- if (sparc_x != (X) && memory_address_p (MODE, X)) \
- goto WIN; \
- if (flag_pic) (X) = legitimize_pic_address (X, MODE, 0); \
- else if (GET_CODE (X) == PLUS && CONSTANT_ADDRESS_P (XEXP (X, 1))) \
- (X) = gen_rtx_PLUS (Pmode, XEXP (X, 0), \
- copy_to_mode_reg (Pmode, XEXP (X, 1))); \
- else if (GET_CODE (X) == PLUS && CONSTANT_ADDRESS_P (XEXP (X, 0))) \
- (X) = gen_rtx_PLUS (Pmode, XEXP (X, 1), \
- copy_to_mode_reg (Pmode, XEXP (X, 0))); \
- else if (GET_CODE (X) == SYMBOL_REF || GET_CODE (X) == CONST \
- || GET_CODE (X) == LABEL_REF) \
- (X) = copy_to_suggested_reg (X, NULL_RTX, Pmode); \
- if (memory_address_p (MODE, X)) \
- goto WIN; }
-
-/* Try a machine-dependent way of reloading an illegitimate address
- operand. If we find one, push the reload and jump to WIN. This
- macro is used in only one place: `find_reloads_address' in reload.c.
-
- For Sparc 32, we wish to handle addresses by splitting them into
- HIGH+LO_SUM pairs, retaining the LO_SUM in the memory reference.
- This cuts the number of extra insns by one.
-
- Do nothing when generating PIC code and the address is a
- symbolic operand or requires a scratch register. */
-
-#define LEGITIMIZE_RELOAD_ADDRESS(X,MODE,OPNUM,TYPE,IND_LEVELS,WIN) \
-do { \
- /* Decompose SImode constants into hi+lo_sum. We do have to \
- rerecognize what we produce, so be careful. */ \
- if (CONSTANT_P (X) \
- && (MODE != TFmode || TARGET_V9) \
- && GET_MODE (X) == SImode \
- && GET_CODE (X) != LO_SUM && GET_CODE (X) != HIGH \
- && ! (flag_pic \
- && (symbolic_operand (X, Pmode) \
- || pic_address_needs_scratch (X)))) \
- { \
- X = gen_rtx_LO_SUM (GET_MODE (X), \
- gen_rtx_HIGH (GET_MODE (X), X), X); \
- push_reload (XEXP (X, 0), NULL_RTX, &XEXP (X, 0), NULL_PTR, \
- BASE_REG_CLASS, GET_MODE (X), VOIDmode, 0, 0, \
- OPNUM, TYPE); \
- goto WIN; \
- } \
- /* ??? 64-bit reloads. */ \
-} while (0)
-
-/* Go to LABEL if ADDR (a legitimate address expression)
- has an effect that depends on the machine mode it is used for.
- On the SPARC this is never true. */
-
-#define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL)
-
-/* If we are referencing a function make the SYMBOL_REF special.
- In the Embedded Medium/Anywhere code model, %g4 points to the data segment
- so we must not add it to function addresses. */
-
-#define ENCODE_SECTION_INFO(DECL) \
- do { \
- if (TARGET_CM_EMBMEDANY && TREE_CODE (DECL) == FUNCTION_DECL) \
- SYMBOL_REF_FLAG (XEXP (DECL_RTL (DECL), 0)) = 1; \
- } while (0)
-
-/* Specify the machine mode that this machine uses
- for the index in the tablejump instruction. */
-/* If we ever implement any of the full models (such as CM_FULLANY),
- this has to be DImode in that case */
-#ifdef HAVE_GAS_SUBSECTION_ORDERING
-#define CASE_VECTOR_MODE \
-(! TARGET_PTR64 ? SImode : flag_pic ? SImode : TARGET_CM_MEDLOW ? SImode : DImode)
-#else
-/* If assembler does not have working .subsection -1, we use DImode for pic, as otherwise
- we have to sign extend which slows things down. */
-#define CASE_VECTOR_MODE \
-(! TARGET_PTR64 ? SImode : flag_pic ? DImode : TARGET_CM_MEDLOW ? SImode : DImode)
-#endif
-
-/* Define as C expression which evaluates to nonzero if the tablejump
- instruction expects the table to contain offsets from the address of the
- table.
- Do not define this if the table should contain absolute addresses. */
-/* #define CASE_VECTOR_PC_RELATIVE 1 */
-
-/* Specify the tree operation to be used to convert reals to integers. */
-#define IMPLICIT_FIX_EXPR FIX_ROUND_EXPR
-
-/* This is the kind of divide that is easiest to do in the general case. */
-#define EASY_DIV_EXPR TRUNC_DIV_EXPR
-
-/* Define this as 1 if `char' should by default be signed; else as 0. */
-#define DEFAULT_SIGNED_CHAR 1
-
-/* Max number of bytes we can move from memory to memory
- in one reasonably fast instruction. */
-#define MOVE_MAX 8
-
-#if 0 /* Sun 4 has matherr, so this is no good. */
-/* This is the value of the error code EDOM for this machine,
- used by the sqrt instruction. */
-#define TARGET_EDOM 33
-
-/* This is how to refer to the variable errno. */
-#define GEN_ERRNO_RTX \
- gen_rtx_MEM (SImode, gen_rtx_SYMBOL_REF (Pmode, "errno"))
-#endif /* 0 */
-
-/* Define if operations between registers always perform the operation
- on the full register even if a narrower mode is specified. */
-#define WORD_REGISTER_OPERATIONS
-
-/* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD
- will either zero-extend or sign-extend. The value of this macro should
- be the code that says which one of the two operations is implicitly
- done, NIL if none. */
-#define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
-
-/* Nonzero if access to memory by bytes is slow and undesirable.
- For RISC chips, it means that access to memory by bytes is no
- better than access by words when possible, so grab a whole word
- and maybe make use of that. */
-#define SLOW_BYTE_ACCESS 1
-
-/* We assume that the store-condition-codes instructions store 0 for false
- and some other value for true. This is the value stored for true. */
-
-#define STORE_FLAG_VALUE 1
-
-/* When a prototype says `char' or `short', really pass an `int'. */
-#define PROMOTE_PROTOTYPES
-
-/* Define this to be nonzero if shift instructions ignore all but the low-order
- few bits. */
-#define SHIFT_COUNT_TRUNCATED 1
-
-/* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
- is done just by pretending it is already truncated. */
-#define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
-
-/* Specify the machine mode that pointers have.
- After generation of rtl, the compiler makes no further distinction
- between pointers and any other objects of this machine mode. */
-#define Pmode (TARGET_PTR64 ? DImode : SImode)
-
-/* Generate calls to memcpy, memcmp and memset. */
-#define TARGET_MEM_FUNCTIONS
-
-/* Add any extra modes needed to represent the condition code.
-
- On the Sparc, we have a "no-overflow" mode which is used when an add or
- subtract insn is used to set the condition code. Different branches are
- used in this case for some operations.
-
- We also have two modes to indicate that the relevant condition code is
- in the floating-point condition code register. One for comparisons which
- will generate an exception if the result is unordered (CCFPEmode) and
- one for comparisons which will never trap (CCFPmode).
-
- CCXmode and CCX_NOOVmode are only used by v9. */
-
-#define EXTRA_CC_MODES CCXmode, CC_NOOVmode, CCX_NOOVmode, CCFPmode, CCFPEmode
-
-/* Define the names for the modes specified above. */
-
-#define EXTRA_CC_NAMES "CCX", "CC_NOOV", "CCX_NOOV", "CCFP", "CCFPE"
-
-/* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE,
- return the mode to be used for the comparison. For floating-point,
- CCFP[E]mode is used. CC_NOOVmode should be used when the first operand is a
- PLUS, MINUS, NEG, or ASHIFT. CCmode should be used when no special
- processing is needed. */
-#define SELECT_CC_MODE(OP,X,Y) \
- (GET_MODE_CLASS (GET_MODE (X)) == MODE_FLOAT \
- ? ((OP == EQ || OP == NE) ? CCFPmode : CCFPEmode) \
- : ((GET_CODE (X) == PLUS || GET_CODE (X) == MINUS \
- || GET_CODE (X) == NEG || GET_CODE (X) == ASHIFT) \
- ? (TARGET_ARCH64 && GET_MODE (X) == DImode ? CCX_NOOVmode : CC_NOOVmode) \
- : ((TARGET_ARCH64 || TARGET_V8PLUS) && GET_MODE (X) == DImode ? CCXmode : CCmode)))
-
-/* Return non-zero if SELECT_CC_MODE will never return MODE for a
- floating point inequality comparison. */
-
-#define REVERSIBLE_CC_MODE(MODE) ((MODE) != CCFPEmode)
-
-/* A function address in a call instruction
- is a byte address (for indexing purposes)
- so give the MEM rtx a byte's mode. */
-#define FUNCTION_MODE SImode
-
-/* Define this if addresses of constant functions
- shouldn't be put through pseudo regs where they can be cse'd.
- Desirable on machines where ordinary constants are expensive
- but a CALL with constant address is cheap. */
-#define NO_FUNCTION_CSE
-
-/* alloca should avoid clobbering the old register save area. */
-#define SETJMP_VIA_SAVE_AREA
-
-/* Define subroutines to call to handle multiply and divide.
- Use the subroutines that Sun's library provides.
- The `*' prevents an underscore from being prepended by the compiler. */
-
-#define DIVSI3_LIBCALL "*.div"
-#define UDIVSI3_LIBCALL "*.udiv"
-#define MODSI3_LIBCALL "*.rem"
-#define UMODSI3_LIBCALL "*.urem"
-/* .umul is a little faster than .mul. */
-#define MULSI3_LIBCALL "*.umul"
-
-/* Define library calls for quad FP operations. These are all part of the
- SPARC ABI.
- ??? ARCH64 still does not work as the _Qp_* routines take pointers. */
-#define ADDTF3_LIBCALL (TARGET_ARCH64 ? "_Qp_add" : "_Q_add")
-#define SUBTF3_LIBCALL (TARGET_ARCH64 ? "_Qp_sub" : "_Q_sub")
-#define NEGTF2_LIBCALL (TARGET_ARCH64 ? "_Qp_neg" : "_Q_neg")
-#define MULTF3_LIBCALL (TARGET_ARCH64 ? "_Qp_mul" : "_Q_mul")
-#define DIVTF3_LIBCALL (TARGET_ARCH64 ? "_Qp_div" : "_Q_div")
-#define FLOATSITF2_LIBCALL (TARGET_ARCH64 ? "_Qp_itoq" : "_Q_itoq")
-#define FIX_TRUNCTFSI2_LIBCALL (TARGET_ARCH64 ? "_Qp_qtoi" : "_Q_qtoi")
-#define FIXUNS_TRUNCTFSI2_LIBCALL (TARGET_ARCH64 ? "_Qp_qtoui" : "_Q_qtou")
-#define EXTENDSFTF2_LIBCALL (TARGET_ARCH64 ? "_Qp_stoq" : "_Q_stoq")
-#define TRUNCTFSF2_LIBCALL (TARGET_ARCH64 ? "_Qp_qtos" : "_Q_qtos")
-#define EXTENDDFTF2_LIBCALL (TARGET_ARCH64 ? "_Qp_dtoq" : "_Q_dtoq")
-#define TRUNCTFDF2_LIBCALL (TARGET_ARCH64 ? "_Qp_qtod" : "_Q_qtod")
-#define EQTF2_LIBCALL (TARGET_ARCH64 ? "_Qp_feq" : "_Q_feq")
-#define NETF2_LIBCALL (TARGET_ARCH64 ? "_Qp_fne" : "_Q_fne")
-#define GTTF2_LIBCALL (TARGET_ARCH64 ? "_Qp_fgt" : "_Q_fgt")
-#define GETF2_LIBCALL (TARGET_ARCH64 ? "_Qp_fge" : "_Q_fge")
-#define LTTF2_LIBCALL (TARGET_ARCH64 ? "_Qp_flt" : "_Q_flt")
-#define LETF2_LIBCALL (TARGET_ARCH64 ? "_Qp_fle" : "_Q_fle")
-
-/* We can define the TFmode sqrt optab only if TARGET_FPU. This is because
- with soft-float, the SFmode and DFmode sqrt instructions will be absent,
- and the compiler will notice and try to use the TFmode sqrt instruction
- for calls to the builtin function sqrt, but this fails. */
-#define INIT_TARGET_OPTABS \
- do { \
- add_optab->handlers[(int) TFmode].libfunc \
- = gen_rtx_SYMBOL_REF (Pmode, ADDTF3_LIBCALL); \
- sub_optab->handlers[(int) TFmode].libfunc \
- = gen_rtx_SYMBOL_REF (Pmode, SUBTF3_LIBCALL); \
- neg_optab->handlers[(int) TFmode].libfunc \
- = gen_rtx_SYMBOL_REF (Pmode, NEGTF2_LIBCALL); \
- smul_optab->handlers[(int) TFmode].libfunc \
- = gen_rtx_SYMBOL_REF (Pmode, MULTF3_LIBCALL); \
- flodiv_optab->handlers[(int) TFmode].libfunc \
- = gen_rtx_SYMBOL_REF (Pmode, DIVTF3_LIBCALL); \
- eqtf2_libfunc = gen_rtx_SYMBOL_REF (Pmode, EQTF2_LIBCALL); \
- netf2_libfunc = gen_rtx_SYMBOL_REF (Pmode, NETF2_LIBCALL); \
- gttf2_libfunc = gen_rtx_SYMBOL_REF (Pmode, GTTF2_LIBCALL); \
- getf2_libfunc = gen_rtx_SYMBOL_REF (Pmode, GETF2_LIBCALL); \
- lttf2_libfunc = gen_rtx_SYMBOL_REF (Pmode, LTTF2_LIBCALL); \
- letf2_libfunc = gen_rtx_SYMBOL_REF (Pmode, LETF2_LIBCALL); \
- trunctfsf2_libfunc = gen_rtx_SYMBOL_REF (Pmode, TRUNCTFSF2_LIBCALL); \
- trunctfdf2_libfunc = gen_rtx_SYMBOL_REF (Pmode, TRUNCTFDF2_LIBCALL); \
- extendsftf2_libfunc = gen_rtx_SYMBOL_REF (Pmode, EXTENDSFTF2_LIBCALL); \
- extenddftf2_libfunc = gen_rtx_SYMBOL_REF (Pmode, EXTENDDFTF2_LIBCALL); \
- floatsitf_libfunc = gen_rtx_SYMBOL_REF (Pmode, FLOATSITF2_LIBCALL); \
- fixtfsi_libfunc = gen_rtx_SYMBOL_REF (Pmode, FIX_TRUNCTFSI2_LIBCALL); \
- fixunstfsi_libfunc \
- = gen_rtx_SYMBOL_REF (Pmode, FIXUNS_TRUNCTFSI2_LIBCALL); \
- if (TARGET_FPU) \
- sqrt_optab->handlers[(int) TFmode].libfunc \
- = gen_rtx_SYMBOL_REF (Pmode, "_Q_sqrt"); \
- INIT_SUBTARGET_OPTABS; \
- } while (0)
-
-/* This is meant to be redefined in the host dependent files */
-#define INIT_SUBTARGET_OPTABS
-
-/* Compute the cost of computing a constant rtl expression RTX
- whose rtx-code is CODE. The body of this macro is a portion
- of a switch statement. If the code is computed here,
- return it with a return statement. Otherwise, break from the switch. */
-
-#define CONST_COSTS(RTX,CODE,OUTER_CODE) \
- case CONST_INT: \
- if (INTVAL (RTX) < 0x1000 && INTVAL (RTX) >= -0x1000) \
- return 0; \
- case HIGH: \
- return 2; \
- case CONST: \
- case LABEL_REF: \
- case SYMBOL_REF: \
- return 4; \
- case CONST_DOUBLE: \
- if (GET_MODE (RTX) == DImode) \
- if ((XINT (RTX, 3) == 0 \
- && (unsigned) XINT (RTX, 2) < 0x1000) \
- || (XINT (RTX, 3) == -1 \
- && XINT (RTX, 2) < 0 \
- && XINT (RTX, 2) >= -0x1000)) \
- return 0; \
- return 8;
-
-#define ADDRESS_COST(RTX) 1
-
-/* Compute extra cost of moving data between one register class
- and another. */
-#define GENERAL_OR_I64(C) ((C) == GENERAL_REGS || (C) == I64_REGS)
-#define REGISTER_MOVE_COST(CLASS1, CLASS2) \
- (((FP_REG_CLASS_P (CLASS1) && GENERAL_OR_I64 (CLASS2)) \
- || (GENERAL_OR_I64 (CLASS1) && FP_REG_CLASS_P (CLASS2)) \
- || (CLASS1) == FPCC_REGS || (CLASS2) == FPCC_REGS) \
- ? (sparc_cpu == PROCESSOR_ULTRASPARC ? 12 : 6) : 2)
-
-/* Provide the costs of a rtl expression. This is in the body of a
- switch on CODE. The purpose for the cost of MULT is to encourage
- `synth_mult' to find a synthetic multiply when reasonable.
-
- If we need more than 12 insns to do a multiply, then go out-of-line,
- since the call overhead will be < 10% of the cost of the multiply. */
-
-#define RTX_COSTS(X,CODE,OUTER_CODE) \
- case MULT: \
- if (sparc_cpu == PROCESSOR_ULTRASPARC) \
- return (GET_MODE (X) == DImode ? \
- COSTS_N_INSNS (34) : COSTS_N_INSNS (19)); \
- return TARGET_HARD_MUL ? COSTS_N_INSNS (5) : COSTS_N_INSNS (25); \
- case DIV: \
- case UDIV: \
- case MOD: \
- case UMOD: \
- if (sparc_cpu == PROCESSOR_ULTRASPARC) \
- return (GET_MODE (X) == DImode ? \
- COSTS_N_INSNS (68) : COSTS_N_INSNS (37)); \
- return COSTS_N_INSNS (25); \
- /* Make FLOAT and FIX more expensive than CONST_DOUBLE,\
- so that cse will favor the latter. */ \
- case FLOAT: \
- case FIX: \
- return 19;
-
-#define ISSUE_RATE sparc_issue_rate()
-
-/* Adjust the cost of dependencies. */
-#define ADJUST_COST(INSN,LINK,DEP,COST) \
- sparc_adjust_cost(INSN, LINK, DEP, COST)
-
-extern void ultrasparc_sched_reorder ();
-extern void ultrasparc_sched_init ();
-extern int ultrasparc_variable_issue ();
-
-#define MD_SCHED_INIT(DUMP, SCHED_VERBOSE) \
- if (sparc_cpu == PROCESSOR_ULTRASPARC) \
- ultrasparc_sched_init (DUMP, SCHED_VERBOSE)
-
-#define MD_SCHED_REORDER(DUMP, SCHED_VERBOSE, READY, N_READY) \
- if (sparc_cpu == PROCESSOR_ULTRASPARC) \
- ultrasparc_sched_reorder (DUMP, SCHED_VERBOSE, READY, N_READY)
-
-#define MD_SCHED_VARIABLE_ISSUE(DUMP, SCHED_VERBOSE, INSN, CAN_ISSUE_MORE) \
- if (sparc_cpu == PROCESSOR_ULTRASPARC) \
- (CAN_ISSUE_MORE) = ultrasparc_variable_issue (INSN); \
- else \
- (CAN_ISSUE_MORE)--
-
-/* Conditional branches with empty delay slots have a length of two. */
-#define ADJUST_INSN_LENGTH(INSN, LENGTH) \
- if (GET_CODE (INSN) == CALL_INSN \
- || (GET_CODE (INSN) == JUMP_INSN && ! simplejump_p (insn))) \
- LENGTH += 1; else
-
-/* Control the assembler format that we output. */
-
-/* Output at beginning of assembler file. */
-
-#define ASM_FILE_START(file)
-
-/* A C string constant describing how to begin a comment in the target
- assembler language. The compiler assumes that the comment will end at
- the end of the line. */
-
-#define ASM_COMMENT_START "!"
-
-/* Output to assembler file text saying following lines
- may contain character constants, extra white space, comments, etc. */
-
-#define ASM_APP_ON ""
-
-/* Output to assembler file text saying following lines
- no longer contain unusual constructs. */
-
-#define ASM_APP_OFF ""
-
-/* ??? Try to make the style consistent here (_OP?). */
-
-#define ASM_LONGLONG ".xword"
-#define ASM_LONG ".word"
-#define ASM_SHORT ".half"
-#define ASM_BYTE_OP ".byte"
-#define ASM_FLOAT ".single"
-#define ASM_DOUBLE ".double"
-#define ASM_LONGDOUBLE ".xxx" /* ??? Not known (or used yet). */
-
-/* Output before read-only data. */
-
-#define TEXT_SECTION_ASM_OP ".text"
-
-/* Output before writable data. */
-
-#define DATA_SECTION_ASM_OP ".data"
-
-/* How to refer to registers in assembler output.
- This sequence is indexed by compiler's hard-register-number (see above). */
-
-#define REGISTER_NAMES \
-{"%g0", "%g1", "%g2", "%g3", "%g4", "%g5", "%g6", "%g7", \
- "%o0", "%o1", "%o2", "%o3", "%o4", "%o5", "%sp", "%o7", \
- "%l0", "%l1", "%l2", "%l3", "%l4", "%l5", "%l6", "%l7", \
- "%i0", "%i1", "%i2", "%i3", "%i4", "%i5", "%fp", "%i7", \
- "%f0", "%f1", "%f2", "%f3", "%f4", "%f5", "%f6", "%f7", \
- "%f8", "%f9", "%f10", "%f11", "%f12", "%f13", "%f14", "%f15", \
- "%f16", "%f17", "%f18", "%f19", "%f20", "%f21", "%f22", "%f23", \
- "%f24", "%f25", "%f26", "%f27", "%f28", "%f29", "%f30", "%f31", \
- "%f32", "%f33", "%f34", "%f35", "%f36", "%f37", "%f38", "%f39", \
- "%f40", "%f41", "%f42", "%f43", "%f44", "%f45", "%f46", "%f47", \
- "%f48", "%f49", "%f50", "%f51", "%f52", "%f53", "%f54", "%f55", \
- "%f56", "%f57", "%f58", "%f59", "%f60", "%f61", "%f62", "%f63", \
- "%fcc0", "%fcc1", "%fcc2", "%fcc3", "%icc"}
-
-/* Define additional names for use in asm clobbers and asm declarations. */
-
-#define ADDITIONAL_REGISTER_NAMES \
-{{"ccr", SPARC_ICC_REG}, {"cc", SPARC_ICC_REG}}
-
-/* How to renumber registers for dbx and gdb. In the flat model, the frame
- pointer is really %i7. */
-
-#define DBX_REGISTER_NUMBER(REGNO) \
- (TARGET_FLAT && REGNO == FRAME_POINTER_REGNUM ? 31 : REGNO)
-
-/* On Sun 4, this limit is 2048. We use 1000 to be safe, since the length
- can run past this up to a continuation point. Once we used 1500, but
- a single entry in C++ can run more than 500 bytes, due to the length of
- mangled symbol names. dbxout.c should really be fixed to do
- continuations when they are actually needed instead of trying to
- guess... */
-#define DBX_CONTIN_LENGTH 1000
-
-/* This is how to output a note to DBX telling it the line number
- to which the following sequence of instructions corresponds.
-
- This is needed for SunOS 4.0, and should not hurt for 3.2
- versions either. */
-#define ASM_OUTPUT_SOURCE_LINE(file, line) \
- { static int sym_lineno = 1; \
- fprintf (file, ".stabn 68,0,%d,LM%d\nLM%d:\n", \
- line, sym_lineno, sym_lineno); \
- sym_lineno += 1; }
-
-/* This is how to output the definition of a user-level label named NAME,
- such as the label on a static function or variable NAME. */
-
-#define ASM_OUTPUT_LABEL(FILE,NAME) \
- do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
-
-/* This is how to output a command to make the user-level label named NAME
- defined for reference from other files. */
-
-#define ASM_GLOBALIZE_LABEL(FILE,NAME) \
- do { fputs ("\t.global ", FILE); assemble_name (FILE, NAME); fputs ("\n", FILE);} while (0)
-
-/* The prefix to add to user-visible assembler symbols. */
-
-#define USER_LABEL_PREFIX "_"
-
-/* This is how to output a definition of an internal numbered label where
- PREFIX is the class of label and NUM is the number within the class. */
-
-#define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \
- fprintf (FILE, "%s%d:\n", PREFIX, NUM)
-
-/* This is how to store into the string LABEL
- the symbol_ref name of an internal numbered label where
- PREFIX is the class of label and NUM is the number within the class.
- This is suitable for output with `assemble_name'. */
-
-#define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
- sprintf ((LABEL), "*%s%ld", (PREFIX), (long)(NUM))
-
-/* This is how to output an assembler line defining a `float' constant.
- We always have to use a .long pseudo-op to do this because the native
- SVR4 ELF assembler is buggy and it generates incorrect values when we
- try to use the .float pseudo-op instead. */
-
-#define ASM_OUTPUT_FLOAT(FILE,VALUE) \
- { \
- long t; \
- char str[30]; \
- REAL_VALUE_TO_TARGET_SINGLE ((VALUE), t); \
- REAL_VALUE_TO_DECIMAL ((VALUE), "%.20e", str); \
- fprintf (FILE, "\t%s\t0x%lx %s ~%s\n", ASM_LONG, t, \
- ASM_COMMENT_START, str); \
- } \
-
-/* This is how to output an assembler line defining a `double' constant.
- We always have to use a .long pseudo-op to do this because the native
- SVR4 ELF assembler is buggy and it generates incorrect values when we
- try to use the .float pseudo-op instead. */
-
-#define ASM_OUTPUT_DOUBLE(FILE,VALUE) \
- { \
- long t[2]; \
- char str[30]; \
- REAL_VALUE_TO_TARGET_DOUBLE ((VALUE), t); \
- REAL_VALUE_TO_DECIMAL ((VALUE), "%.20e", str); \
- fprintf (FILE, "\t%s\t0x%lx %s ~%s\n", ASM_LONG, t[0], \
- ASM_COMMENT_START, str); \
- fprintf (FILE, "\t%s\t0x%lx\n", ASM_LONG, t[1]); \
- }
-
-/* This is how to output an assembler line defining a `long double'
- constant. */
-
-#define ASM_OUTPUT_LONG_DOUBLE(FILE,VALUE) \
- { \
- long t[4]; \
- char str[30]; \
- REAL_VALUE_TO_TARGET_LONG_DOUBLE ((VALUE), t); \
- REAL_VALUE_TO_DECIMAL ((VALUE), "%.20e", str); \
- fprintf (FILE, "\t%s\t0x%lx %s ~%s\n", ASM_LONG, t[0], \
- ASM_COMMENT_START, str); \
- fprintf (FILE, "\t%s\t0x%lx\n", ASM_LONG, t[1]); \
- fprintf (FILE, "\t%s\t0x%lx\n", ASM_LONG, t[2]); \
- fprintf (FILE, "\t%s\t0x%lx\n", ASM_LONG, t[3]); \
- }
-
-/* This is how to output an assembler line defining an `int' constant. */
-
-#define ASM_OUTPUT_INT(FILE,VALUE) \
-( fprintf (FILE, "\t%s\t", ASM_LONG), \
- output_addr_const (FILE, (VALUE)), \
- fprintf (FILE, "\n"))
-
-/* This is how to output an assembler line defining a DImode constant. */
-#define ASM_OUTPUT_DOUBLE_INT(FILE,VALUE) \
- output_double_int (FILE, VALUE)
-
-/* Likewise for `char' and `short' constants. */
-
-#define ASM_OUTPUT_SHORT(FILE,VALUE) \
-( fprintf (FILE, "\t%s\t", ASM_SHORT), \
- output_addr_const (FILE, (VALUE)), \
- fprintf (FILE, "\n"))
-
-#define ASM_OUTPUT_CHAR(FILE,VALUE) \
-( fprintf (FILE, "\t%s\t", ASM_BYTE_OP), \
- output_addr_const (FILE, (VALUE)), \
- fprintf (FILE, "\n"))
-
-/* This is how to output an assembler line for a numeric constant byte. */
-
-#define ASM_OUTPUT_BYTE(FILE,VALUE) \
- fprintf (FILE, "\t%s\t0x%x\n", ASM_BYTE_OP, (VALUE))
-
-/* This is how we hook in and defer the case-vector until the end of
- the function. */
-extern void sparc_defer_case_vector ();
-
-#define ASM_OUTPUT_ADDR_VEC(LAB,VEC) \
- sparc_defer_case_vector ((LAB),(VEC), 0)
-
-#define ASM_OUTPUT_ADDR_DIFF_VEC(LAB,VEC) \
- sparc_defer_case_vector ((LAB),(VEC), 1)
-
-/* This is how to output an element of a case-vector that is absolute. */
-
-#define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
-do { \
- char label[30]; \
- ASM_GENERATE_INTERNAL_LABEL (label, "L", VALUE); \
- if (CASE_VECTOR_MODE == SImode) \
- fprintf (FILE, "\t.word\t"); \
- else \
- fprintf (FILE, "\t.xword\t"); \
- assemble_name (FILE, label); \
- fputc ('\n', FILE); \
-} while (0)
-
-/* This is how to output an element of a case-vector that is relative.
- (SPARC uses such vectors only when generating PIC.) */
-
-#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
-do { \
- char label[30]; \
- ASM_GENERATE_INTERNAL_LABEL (label, "L", (VALUE)); \
- if (CASE_VECTOR_MODE == SImode) \
- fprintf (FILE, "\t.word\t"); \
- else \
- fprintf (FILE, "\t.xword\t"); \
- assemble_name (FILE, label); \
- ASM_GENERATE_INTERNAL_LABEL (label, "L", (REL)); \
- fputc ('-', FILE); \
- assemble_name (FILE, label); \
- fputc ('\n', FILE); \
-} while (0)
-
-/* This is what to output before and after case-vector (both
- relative and absolute). If .subsection -1 works, we put case-vectors
- at the beginning of the current section. */
-
-#ifdef HAVE_GAS_SUBSECTION_ORDERING
-
-#define ASM_OUTPUT_ADDR_VEC_START(FILE) \
- fprintf(FILE, "\t.subsection\t-1\n")
-
-#define ASM_OUTPUT_ADDR_VEC_END(FILE) \
- fprintf(FILE, "\t.previous\n")
-
-#endif
-
-/* This is how to output an assembler line
- that says to advance the location counter
- to a multiple of 2**LOG bytes. */
-
-#define ASM_OUTPUT_ALIGN(FILE,LOG) \
- if ((LOG) != 0) \
- fprintf (FILE, "\t.align %d\n", (1<<(LOG)))
-
-#define LABEL_ALIGN_AFTER_BARRIER(LABEL) (sparc_align_jumps)
-
-#define LOOP_ALIGN(LABEL) (sparc_align_loops)
-
-#define ASM_OUTPUT_SKIP(FILE,SIZE) \
- fprintf (FILE, "\t.skip %u\n", (SIZE))
-
-/* This says how to output an assembler line
- to define a global common symbol. */
-
-#define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \
-( fputs ("\t.common ", (FILE)), \
- assemble_name ((FILE), (NAME)), \
- fprintf ((FILE), ",%u,\"bss\"\n", (SIZE)))
-
-/* This says how to output an assembler line to define a local common
- symbol. */
-
-#define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGNED) \
-( fputs ("\t.reserve ", (FILE)), \
- assemble_name ((FILE), (NAME)), \
- fprintf ((FILE), ",%u,\"bss\",%u\n", \
- (SIZE), ((ALIGNED) / BITS_PER_UNIT)))
-
-/* A C statement (sans semicolon) to output to the stdio stream
- FILE the assembler definition of uninitialized global DECL named
- NAME whose size is SIZE bytes and alignment is ALIGN bytes.
- Try to use asm_output_aligned_bss to implement this macro. */
-
-#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
- do { \
- fputs (".globl ", (FILE)); \
- assemble_name ((FILE), (NAME)); \
- fputs ("\n", (FILE)); \
- ASM_OUTPUT_ALIGNED_LOCAL (FILE, NAME, SIZE, ALIGN); \
- } while (0)
-
-/* Store in OUTPUT a string (made with alloca) containing
- an assembler-name for a local static variable named NAME.
- LABELNO is an integer which is different for each call. */
-
-#define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \
-( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10), \
- sprintf ((OUTPUT), "%s.%d", (NAME), (LABELNO)))
-
-#define IDENT_ASM_OP ".ident"
-
-/* Output #ident as a .ident. */
-
-#define ASM_OUTPUT_IDENT(FILE, NAME) \
- fprintf (FILE, "\t%s\t\"%s\"\n", IDENT_ASM_OP, NAME);
-
-/* Output code to add DELTA to the first argument, and then jump to FUNCTION.
- Used for C++ multiple inheritance. */
-#define ASM_OUTPUT_MI_THUNK(FILE, THUNK_FNDECL, DELTA, FUNCTION) \
-do { \
- int big_delta = (DELTA) >= 4096 || (DELTA) < -4096; \
- if (big_delta) \
- fprintf (FILE, "\tset %d,%%g1\n\tadd %%o0,%%g1,%%o0\n", (DELTA)); \
- /* Don't use the jmp solution unless we know the target is local to \
- the application or shared object. \
- XXX: Wimp out and don't actually check anything except if this is \
- an embedded target where we assume there are no shared libs. */ \
- if (!TARGET_CM_EMBMEDANY || flag_pic) \
- { \
- if (! big_delta) \
- fprintf (FILE, "\tadd %%o0,%d,%%o0\n", DELTA); \
- fprintf (FILE, "\tmov %%o7,%%g1\n"); \
- fprintf (FILE, "\tcall "); \
- assemble_name (FILE, XSTR (XEXP (DECL_RTL (FUNCTION), 0), 0)); \
- fprintf (FILE, ",0\n"); \
- } \
- else if (TARGET_CM_EMBMEDANY) \
- { \
- fprintf (FILE, "\tsetx "); \
- assemble_name (FILE, XSTR (XEXP (DECL_RTL (FUNCTION), 0), 0)); \
- fprintf (FILE, ",%%g5,%%g1\n\tjmp %%g1\n"); \
- } \
- else \
- { \
- fprintf (FILE, "\tsethi %%hi("); \
- assemble_name (FILE, XSTR (XEXP (DECL_RTL (FUNCTION), 0), 0)); \
- fprintf (FILE, "),%%g1\n\tjmp %%g1+%%lo("); \
- assemble_name (FILE, XSTR (XEXP (DECL_RTL (FUNCTION), 0), 0)); \
- fprintf (FILE, ")\n"); \
- } \
- if (!TARGET_CM_EMBMEDANY || flag_pic) \
- fprintf (FILE, "\tmov %%g1,%%o7\n"); \
- else if (big_delta) \
- fprintf (FILE, "\tnop\n"); \
- else \
- fprintf (FILE, "\tadd %%o0,%d,%%o0\n", DELTA); \
-} while (0)
-
-/* Define the parentheses used to group arithmetic operations
- in assembler code. */
-
-#define ASM_OPEN_PAREN "("
-#define ASM_CLOSE_PAREN ")"
-
-/* Define results of standard character escape sequences. */
-#define TARGET_BELL 007
-#define TARGET_BS 010
-#define TARGET_TAB 011
-#define TARGET_NEWLINE 012
-#define TARGET_VT 013
-#define TARGET_FF 014
-#define TARGET_CR 015
-
-#define PRINT_OPERAND_PUNCT_VALID_P(CHAR) \
- ((CHAR) == '#' || (CHAR) == '*' || (CHAR) == '^' || (CHAR) == '(' || (CHAR) == '_')
-
-/* Print operand X (an rtx) in assembler syntax to file FILE.
- CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified.
- For `%' followed by punctuation, CODE is the punctuation and X is null. */
-
-#define PRINT_OPERAND(FILE, X, CODE) print_operand (FILE, X, CODE)
-
-/* Print a memory address as an operand to reference that memory location. */
-
-#define PRINT_OPERAND_ADDRESS(FILE, ADDR) \
-{ register rtx base, index = 0; \
- int offset = 0; \
- register rtx addr = ADDR; \
- if (GET_CODE (addr) == REG) \
- fputs (reg_names[REGNO (addr)], FILE); \
- else if (GET_CODE (addr) == PLUS) \
- { \
- if (GET_CODE (XEXP (addr, 0)) == CONST_INT) \
- offset = INTVAL (XEXP (addr, 0)), base = XEXP (addr, 1);\
- else if (GET_CODE (XEXP (addr, 1)) == CONST_INT) \
- offset = INTVAL (XEXP (addr, 1)), base = XEXP (addr, 0);\
- else \
- base = XEXP (addr, 0), index = XEXP (addr, 1); \
- fputs (reg_names[REGNO (base)], FILE); \
- if (index == 0) \
- fprintf (FILE, "%+d", offset); \
- else if (GET_CODE (index) == REG) \
- fprintf (FILE, "+%s", reg_names[REGNO (index)]); \
- else if (GET_CODE (index) == SYMBOL_REF \
- || GET_CODE (index) == CONST) \
- fputc ('+', FILE), output_addr_const (FILE, index); \
- else abort (); \
- } \
- else if (GET_CODE (addr) == MINUS \
- && GET_CODE (XEXP (addr, 1)) == LABEL_REF) \
- { \
- output_addr_const (FILE, XEXP (addr, 0)); \
- fputs ("-(", FILE); \
- output_addr_const (FILE, XEXP (addr, 1)); \
- fputs ("-.)", FILE); \
- } \
- else if (GET_CODE (addr) == LO_SUM) \
- { \
- output_operand (XEXP (addr, 0), 0); \
- if (TARGET_CM_MEDMID) \
- fputs ("+%l44(", FILE); \
- else \
- fputs ("+%lo(", FILE); \
- output_address (XEXP (addr, 1)); \
- fputc (')', FILE); \
- } \
- else if (flag_pic && GET_CODE (addr) == CONST \
- && GET_CODE (XEXP (addr, 0)) == MINUS \
- && GET_CODE (XEXP (XEXP (addr, 0), 1)) == CONST \
- && GET_CODE (XEXP (XEXP (XEXP (addr, 0), 1), 0)) == MINUS \
- && XEXP (XEXP (XEXP (XEXP (addr, 0), 1), 0), 1) == pc_rtx) \
- { \
- addr = XEXP (addr, 0); \
- output_addr_const (FILE, XEXP (addr, 0)); \
- /* Group the args of the second CONST in parenthesis. */ \
- fputs ("-(", FILE); \
- /* Skip past the second CONST--it does nothing for us. */\
- output_addr_const (FILE, XEXP (XEXP (addr, 1), 0)); \
- /* Close the parenthesis. */ \
- fputc (')', FILE); \
- } \
- else \
- { \
- output_addr_const (FILE, addr); \
- } \
-}
-
-/* Define the codes that are matched by predicates in sparc.c. */
-
-#define PREDICATE_CODES \
-{"reg_or_0_operand", {SUBREG, REG, CONST_INT, CONST_DOUBLE}}, \
-{"fp_zero_operand", {CONST_DOUBLE}}, \
-{"intreg_operand", {SUBREG, REG}}, \
-{"fcc_reg_operand", {REG}}, \
-{"icc_or_fcc_reg_operand", {REG}}, \
-{"restore_operand", {REG}}, \
-{"call_operand", {MEM}}, \
-{"call_operand_address", {SYMBOL_REF, LABEL_REF, CONST, CONST_DOUBLE, \
- ADDRESSOF, SUBREG, REG, PLUS, LO_SUM, CONST_INT}}, \
-{"symbolic_operand", {SYMBOL_REF, LABEL_REF, CONST, CONST_DOUBLE}}, \
-{"symbolic_memory_operand", {SUBREG, MEM}}, \
-{"label_ref_operand", {LABEL_REF}}, \
-{"sp64_medium_pic_operand", {CONST}}, \
-{"data_segment_operand", {SYMBOL_REF, PLUS, CONST}}, \
-{"text_segment_operand", {LABEL_REF, SYMBOL_REF, PLUS, CONST}}, \
-{"reg_or_nonsymb_mem_operand", {SUBREG, REG, MEM}}, \
-{"splittable_symbolic_memory_operand", {MEM}}, \
-{"splittable_immediate_memory_operand", {MEM}}, \
-{"eq_or_neq", {EQ, NE}}, \
-{"normal_comp_operator", {GE, GT, LE, LT, GTU, LEU}}, \
-{"noov_compare_op", {NE, EQ, GE, GT, LE, LT, GEU, GTU, LEU, LTU}}, \
-{"v9_regcmp_op", {EQ, NE, GE, LT, LE, GT}}, \
-{"extend_op", {SIGN_EXTEND, ZERO_EXTEND}}, \
-{"cc_arithop", {AND, IOR, XOR}}, \
-{"cc_arithopn", {AND, IOR}}, \
-{"arith_operand", {SUBREG, REG, CONST_INT}}, \
-{"arith_add_operand", {SUBREG, REG, CONST_INT}}, \
-{"arith11_operand", {SUBREG, REG, CONST_INT}}, \
-{"arith10_operand", {SUBREG, REG, CONST_INT}}, \
-{"arith_double_operand", {SUBREG, REG, CONST_INT, CONST_DOUBLE}}, \
-{"arith_double_add_operand", {SUBREG, REG, CONST_INT, CONST_DOUBLE}}, \
-{"arith11_double_operand", {SUBREG, REG, CONST_INT, CONST_DOUBLE}}, \
-{"arith10_double_operand", {SUBREG, REG, CONST_INT, CONST_DOUBLE}}, \
-{"small_int", {CONST_INT}}, \
-{"small_int_or_double", {CONST_INT, CONST_DOUBLE}}, \
-{"uns_small_int", {CONST_INT}}, \
-{"uns_arith_operand", {SUBREG, REG, CONST_INT}}, \
-{"clobbered_register", {REG}}, \
-{"input_operand", {SUBREG, REG, CONST_INT, MEM, CONST}}, \
-{"zero_operand", {CONST_INT}}, \
-{"const64_operand", {CONST_INT, CONST_DOUBLE}}, \
-{"const64_high_operand", {CONST_INT, CONST_DOUBLE}},
-
-/* The number of Pmode words for the setjmp buffer. */
-#define JMP_BUF_SIZE 12
-
-#define DONT_ACCESS_GBLS_AFTER_EPILOGUE (flag_pic)
-
-/* Declare functions defined in sparc.c and used in templates. */
-
-extern void sparc_emit_set_const32 ();
-extern void sparc_emit_set_const64 ();
-extern void sparc_emit_set_symbolic_const64 ();
-extern int sparc_splitdi_legitimate ();
-extern int sparc_absnegfloat_split_legitimate ();
-
-extern char *output_cbranch ();
-extern const char *output_return ();
-extern char *output_v9branch ();
-
-extern void emit_v9_brxx_insn ();
-extern void finalize_pic ();
-extern void order_regs_for_local_alloc ();
-extern void output_double_int ();
-extern void output_function_epilogue ();
-extern void output_function_prologue ();
-extern void print_operand ();
-extern void sparc_flat_output_function_epilogue ();
-extern void sparc_flat_output_function_prologue ();
-
-extern int addrs_ok_for_ldd_peep ();
-extern int arith10_double_operand ();
-extern int arith10_operand ();
-extern int arith11_double_operand ();
-extern int arith11_operand ();
-extern int arith_double_operand ();
-extern int arith_double_4096_operand ();
-extern int arith_double_add_operand ();
-extern int arith_operand ();
-extern int arith_4096_operand ();
-extern int arith_add_operand ();
-extern int call_operand_address ();
-extern int input_operand ();
-extern int zero_operand ();
-extern int const64_operand ();
-extern int const64_high_operand ();
-extern int cc_arithop ();
-extern int cc_arithopn ();
-extern int check_pic ();
-extern int compute_frame_size ();
-extern int data_segment_operand ();
-extern int eligible_for_epilogue_delay ();
-extern int eligible_for_return_delay ();
-extern int emit_move_sequence ();
-extern int extend_op ();
-extern int fcc_reg_operand ();
-extern int fp_zero_operand ();
-extern int icc_or_fcc_reg_operand ();
-extern int label_ref_operand ();
-extern int mem_min_alignment ();
-extern int noov_compare_op ();
-extern int pic_address_needs_scratch ();
-extern int reg_or_0_operand ();
-extern int reg_or_nonsymb_mem_operand ();
-extern int reg_unused_after ();
-extern int register_ok_for_ldd ();
-extern int registers_ok_for_ldd_peep ();
-extern int restore_operand ();
-extern int short_branch ();
-extern int small_int ();
-extern int small_int_or_double ();
-extern int sp64_medium_pic_operand ();
-extern int sparc_flat_eligible_for_epilogue_delay ();
-extern int sparc_flat_epilogue_delay_slots ();
-extern int sparc_issue_rate ();
-extern int splittable_immediate_memory_operand ();
-extern int splittable_symbolic_memory_operand ();
-extern int sparc_adjust_cost ();
-extern int symbolic_memory_operand ();
-extern int symbolic_operand ();
-extern int text_segment_operand ();
-extern int uns_small_int ();
-extern int v9_regcmp_op ();
-extern int v9_regcmp_p ();
-
-extern unsigned long sparc_flat_compute_frame_size ();
-extern unsigned long sparc_type_code ();
-
-extern void sparc_function_profiler ();
-extern void sparc_function_block_profiler ();
-extern void sparc_block_profiler ();
-extern void sparc_function_block_profiler_exit ();
-
-extern char *sparc_v8plus_shift ();
-
-#ifdef __STDC__
-/* Function used for V8+ code generation. Returns 1 if the high
- 32 bits of REG are 0 before INSN. */
-extern int sparc_check_64 (struct rtx_def *, struct rtx_def *);
-extern int sparc_return_peephole_ok (struct rtx_def *, struct rtx_def *);
-extern int compute_frame_size (int, int);
-#endif
-
-/* Defined in flags.h, but insn-emit.c does not include flags.h. */
-
-extern int flag_pic;
diff --git a/contrib/gcc/config/sparc/sparc.md b/contrib/gcc/config/sparc/sparc.md
deleted file mode 100644
index aafb7a63ea41..000000000000
--- a/contrib/gcc/config/sparc/sparc.md
+++ /dev/null
@@ -1,8236 +0,0 @@
-;;- Machine description for SPARC chip for GNU C compiler
-;; Copyright (C) 1987, 88, 89, 92-98, 1999 Free Software Foundation, Inc.
-;; Contributed by Michael Tiemann (tiemann@cygnus.com)
-;; 64 bit SPARC V9 support by Michael Tiemann, Jim Wilson, and Doug Evans,
-;; at Cygnus Support.
-
-;; This file is part of GNU CC.
-
-;; GNU CC is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
-
-;; GNU CC is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU CC; see the file COPYING. If not, write to
-;; the Free Software Foundation, 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
-
-;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
-
-;; Uses of UNSPEC and UNSPEC_VOLATILE in this file:
-;;
-;; UNSPEC: 0 movsi_{lo_sum,high}_pic
-;; pic_lo_sum_di
-;; pic_sethi_di
-;; 1 update_return
-;; 2 get_pc
-;; 5 movsi_{,lo_sum_,high_}pic_label_ref
-;; 6 seth44
-;; 7 setm44
-;; 8 setl44
-;; 9 sethh
-;; 10 setlm
-;; 11 embmedany_sethi, embmedany_brsum
-;; 12 movsf_const_high
-;; 13 embmedany_textuhi
-;; 14 embmedany_texthi
-;; 15 embmedany_textulo
-;; 16 embmedany_textlo
-;; 17 movsf_const_lo
-;; 18 sethm
-;; 19 setlo
-;;
-;; UNSPEC_VOLATILE: 0 blockage
-;; 1 flush_register_windows
-;; 2 goto_handler_and_restore
-;; 3 goto_handler_and_restore_v9*
-;; 4 flush
-;; 5 nonlocal_goto_receiver
-;;
-
-;; The upper 32 fp regs on the v9 can't hold SFmode values. To deal with this
-;; a second register class, EXTRA_FP_REGS, exists for the v9 chip. The name
-;; is a bit of a misnomer as it covers all 64 fp regs. The corresponding
-;; constraint letter is 'e'. To avoid any confusion, 'e' is used instead of
-;; 'f' for all DF/TFmode values, including those that are specific to the v8.
-;;
-;; -mlive-g0 is *not* supported for TARGET_ARCH64, so we don't bother to
-;; test TARGET_LIVE_G0 if we have TARGET_ARCH64.
-
-;; Attribute for cpu type.
-;; These must match the values for enum processor_type in sparc.h.
-(define_attr "cpu" "v7,cypress,v8,supersparc,sparclite,f930,f934,hypersparc,sparclite86x,sparclet,tsc701,v9,ultrasparc"
- (const (symbol_ref "sparc_cpu_attr")))
-
-;; Attribute for the instruction set.
-;; At present we only need to distinguish v9/!v9, but for clarity we
-;; test TARGET_V8 too.
-(define_attr "isa" "v6,v8,v9,sparclet"
- (const
- (cond [(symbol_ref "TARGET_V9") (const_string "v9")
- (symbol_ref "TARGET_V8") (const_string "v8")
- (symbol_ref "TARGET_SPARCLET") (const_string "sparclet")]
- (const_string "v6"))))
-
-;; Architecture size.
-(define_attr "arch" "arch32bit,arch64bit"
- (const
- (cond [(symbol_ref "TARGET_ARCH64") (const_string "arch64bit")]
- (const_string "arch32bit"))))
-
-;; Whether -mlive-g0 is in effect.
-(define_attr "live_g0" "no,yes"
- (const
- (cond [(symbol_ref "TARGET_LIVE_G0") (const_string "yes")]
- (const_string "no"))))
-
-;; Insn type. Used to default other attribute values.
-
-;; type "unary" insns have one input operand (1) and one output operand (0)
-;; type "binary" insns have two input operands (1,2) and one output (0)
-;; type "compare" insns have one or two input operands (0,1) and no output
-;; type "call_no_delay_slot" is a call followed by an unimp instruction.
-
-(define_attr "type"
- "move,unary,binary,compare,load,sload,store,ialu,shift,uncond_branch,branch,call,call_no_delay_slot,return,address,imul,fpload,fpstore,fp,fpmove,fpcmove,fpcmp,fpmul,fpdivs,fpdivd,fpsqrt,cmove,multi,misc"
- (const_string "binary"))
-
-;; Set true if insn uses call-clobbered intermediate register.
-(define_attr "use_clobbered" "false,true"
- (if_then_else (and (eq_attr "type" "address")
- (match_operand 0 "clobbered_register" ""))
- (const_string "true")
- (const_string "false")))
-
-;; Length (in # of insns).
-(define_attr "length" ""
- (cond [(eq_attr "type" "load,sload,fpload")
- (if_then_else (match_operand 1 "symbolic_memory_operand" "")
- (const_int 2) (const_int 1))
-
- (eq_attr "type" "store,fpstore")
- (if_then_else (match_operand 0 "symbolic_memory_operand" "")
- (const_int 2) (const_int 1))
-
- (eq_attr "type" "address") (const_int 2)
-
- (eq_attr "type" "binary")
- (if_then_else (ior (match_operand 2 "arith_operand" "")
- (match_operand 2 "arith_double_operand" ""))
- (const_int 1) (const_int 3))
-
- (eq_attr "type" "multi") (const_int 2)
-
- (eq_attr "type" "move,unary")
- (if_then_else (ior (match_operand 1 "arith_operand" "")
- (match_operand 1 "arith_double_operand" ""))
- (const_int 1) (const_int 2))]
-
- (const_int 1)))
-
-(define_asm_attributes
- [(set_attr "length" "1")
- (set_attr "type" "multi")])
-
-;; Attributes for instruction and branch scheduling
-
-(define_attr "in_call_delay" "false,true"
- (cond [(eq_attr "type" "uncond_branch,branch,call,call_no_delay_slot,return,multi")
- (const_string "false")
- (eq_attr "type" "load,fpload,store,fpstore")
- (if_then_else (eq_attr "length" "1")
- (const_string "true")
- (const_string "false"))
- (eq_attr "type" "address")
- (if_then_else (eq_attr "use_clobbered" "false")
- (const_string "true")
- (const_string "false"))]
- (if_then_else (eq_attr "length" "1")
- (const_string "true")
- (const_string "false"))))
-
-(define_delay (eq_attr "type" "call")
- [(eq_attr "in_call_delay" "true") (nil) (nil)])
-
-(define_attr "leaf_function" "false,true"
- (const (symbol_ref "current_function_uses_only_leaf_regs")))
-
-(define_attr "in_return_delay" "false,true"
- (if_then_else (and (and (and (eq_attr "type" "move,load,sload,store,binary,ialu")
- (eq_attr "length" "1"))
- (eq_attr "leaf_function" "false"))
- (match_insn "eligible_for_return_delay"))
- (const_string "true")
- (const_string "false")))
-
-(define_delay (and (eq_attr "type" "return")
- (eq_attr "isa" "v9"))
- [(eq_attr "in_return_delay" "true") (nil) (nil)])
-
-;; ??? Should implement the notion of predelay slots for floating point
-;; branches. This would allow us to remove the nop always inserted before
-;; a floating point branch.
-
-;; ??? It is OK for fill_simple_delay_slots to put load/store instructions
-;; in a delay slot, but it is not OK for fill_eager_delay_slots to do so.
-;; This is because doing so will add several pipeline stalls to the path
-;; that the load/store did not come from. Unfortunately, there is no way
-;; to prevent fill_eager_delay_slots from using load/store without completely
-;; disabling them. For the SPEC benchmark set, this is a serious lose,
-;; because it prevents us from moving back the final store of inner loops.
-
-(define_attr "in_branch_delay" "false,true"
- (if_then_else (and (eq_attr "type" "!uncond_branch,branch,call,call_no_delay_slot,multi")
- (eq_attr "length" "1"))
- (const_string "true")
- (const_string "false")))
-
-(define_attr "in_uncond_branch_delay" "false,true"
- (if_then_else (and (eq_attr "type" "!uncond_branch,branch,call,call_no_delay_slot,multi")
- (eq_attr "length" "1"))
- (const_string "true")
- (const_string "false")))
-
-(define_attr "in_annul_branch_delay" "false,true"
- (if_then_else (and (eq_attr "type" "!uncond_branch,branch,call,call_no_delay_slot,multi")
- (eq_attr "length" "1"))
- (const_string "true")
- (const_string "false")))
-
-(define_delay (eq_attr "type" "branch")
- [(eq_attr "in_branch_delay" "true")
- (nil) (eq_attr "in_annul_branch_delay" "true")])
-
-(define_delay (eq_attr "type" "uncond_branch")
- [(eq_attr "in_uncond_branch_delay" "true")
- (nil) (nil)])
-
-;; Function units of the SPARC
-
-;; (define_function_unit {name} {num-units} {n-users} {test}
-;; {ready-delay} {issue-delay} [{conflict-list}])
-
-;; The integer ALU.
-;; (Noted only for documentation; units that take one cycle do not need to
-;; be specified.)
-
-;; On the sparclite, integer multiply takes 1, 3, or 5 cycles depending on
-;; the inputs.
-
-;; (define_function_unit "alu" 1 0
-;; (eq_attr "type" "unary,binary,move,address") 1 0)
-
-;; ---- cypress CY7C602 scheduling:
-;; Memory with load-delay of 1 (i.e., 2 cycle load).
-
-(define_function_unit "memory" 1 0
- (and (eq_attr "cpu" "cypress")
- (eq_attr "type" "load,sload,fpload"))
- 2 2)
-
-;; SPARC has two floating-point units: the FP ALU,
-;; and the FP MUL/DIV/SQRT unit.
-;; Instruction timings on the CY7C602 are as follows
-;; FABSs 4
-;; FADDs/d 5/5
-;; FCMPs/d 4/4
-;; FDIVs/d 23/37
-;; FMOVs 4
-;; FMULs/d 5/7
-;; FNEGs 4
-;; FSQRTs/d 34/63
-;; FSUBs/d 5/5
-;; FdTOi/s 5/5
-;; FsTOi/d 5/5
-;; FiTOs/d 9/5
-
-;; The CY7C602 can only support 2 fp isnsn simultaneously.
-;; More insns cause the chip to stall.
-
-(define_function_unit "fp_alu" 1 0
- (and (eq_attr "cpu" "cypress")
- (eq_attr "type" "fp,fpmove"))
- 5 5)
-
-(define_function_unit "fp_mds" 1 0
- (and (eq_attr "cpu" "cypress")
- (eq_attr "type" "fpmul"))
- 7 7)
-
-(define_function_unit "fp_mds" 1 0
- (and (eq_attr "cpu" "cypress")
- (eq_attr "type" "fpdivs,fpdivd"))
- 37 37)
-
-(define_function_unit "fp_mds" 1 0
- (and (eq_attr "cpu" "cypress")
- (eq_attr "type" "fpsqrt"))
- 63 63)
-
-;; ----- The TMS390Z55 scheduling
-;; The Supersparc can issue 1 - 3 insns per cycle: up to two integer,
-;; one ld/st, one fp.
-;; Memory delivers its result in one cycle to IU, zero cycles to FP
-
-(define_function_unit "memory" 1 0
- (and (eq_attr "cpu" "supersparc")
- (eq_attr "type" "load,sload"))
- 1 1)
-
-(define_function_unit "memory" 1 0
- (and (eq_attr "cpu" "supersparc")
- (eq_attr "type" "fpload"))
- 0 1)
-
-(define_function_unit "memory" 1 0
- (and (eq_attr "cpu" "supersparc")
- (eq_attr "type" "store,fpstore"))
- 1 1)
-
-(define_function_unit "shift" 1 0
- (and (eq_attr "cpu" "supersparc")
- (eq_attr "type" "shift"))
- 1 1)
-
-;; There are only two write ports to the integer register file
-;; A store also uses a write port
-
-(define_function_unit "iwport" 2 0
- (and (eq_attr "cpu" "supersparc")
- (eq_attr "type" "load,sload,store,shift,ialu"))
- 1 1)
-
-;; Timings; throughput/latency
-;; FADD 1/3 add/sub, format conv, compar, abs, neg
-;; FMUL 1/3
-;; FDIVs 4/6
-;; FDIVd 7/9
-;; FSQRTs 6/8
-;; FSQRTd 10/12
-;; IMUL 4/4
-
-(define_function_unit "fp_alu" 1 0
- (and (eq_attr "cpu" "supersparc")
- (eq_attr "type" "fp,fpmove,fpcmp"))
- 3 1)
-
-(define_function_unit "fp_mds" 1 0
- (and (eq_attr "cpu" "supersparc")
- (eq_attr "type" "fpmul"))
- 3 1)
-
-(define_function_unit "fp_mds" 1 0
- (and (eq_attr "cpu" "supersparc")
- (eq_attr "type" "fpdivs"))
- 6 4)
-
-(define_function_unit "fp_mds" 1 0
- (and (eq_attr "cpu" "supersparc")
- (eq_attr "type" "fpdivd"))
- 9 7)
-
-(define_function_unit "fp_mds" 1 0
- (and (eq_attr "cpu" "supersparc")
- (eq_attr "type" "fpsqrt"))
- 12 10)
-
-(define_function_unit "fp_mds" 1 0
- (and (eq_attr "cpu" "supersparc")
- (eq_attr "type" "imul"))
- 4 4)
-
-;; ----- hypersparc/sparclite86x scheduling
-;; The Hypersparc can issue 1 - 2 insns per cycle. The dual issue cases are:
-;; L-Ld/St I-Int F-Float B-Branch LI/LF/LB/II/IF/IB/FF/FB
-;; II/FF case is only when loading a 32 bit hi/lo constant
-;; Single issue insns include call, jmpl, u/smul, u/sdiv, lda, sta, fcmp
-;; Memory delivers its result in one cycle to IU
-
-(define_function_unit "memory" 1 0
- (and (ior (eq_attr "cpu" "hypersparc") (eq_attr "cpu" "sparclite86x"))
- (eq_attr "type" "load,sload,fpload"))
- 1 1)
-
-(define_function_unit "memory" 1 0
- (and (ior (eq_attr "cpu" "hypersparc") (eq_attr "cpu" "sparclite86x"))
- (eq_attr "type" "store,fpstore"))
- 2 1)
-
-(define_function_unit "fp_alu" 1 0
- (and (ior (eq_attr "cpu" "hypersparc") (eq_attr "cpu" "sparclite86x"))
- (eq_attr "type" "fp,fpmove,fpcmp"))
- 1 1)
-
-(define_function_unit "fp_mds" 1 0
- (and (ior (eq_attr "cpu" "hypersparc") (eq_attr "cpu" "sparclite86x"))
- (eq_attr "type" "fpmul"))
- 1 1)
-
-(define_function_unit "fp_mds" 1 0
- (and (ior (eq_attr "cpu" "hypersparc") (eq_attr "cpu" "sparclite86x"))
- (eq_attr "type" "fpdivs"))
- 8 6)
-
-(define_function_unit "fp_mds" 1 0
- (and (ior (eq_attr "cpu" "hypersparc") (eq_attr "cpu" "sparclite86x"))
- (eq_attr "type" "fpdivd"))
- 12 10)
-
-(define_function_unit "fp_mds" 1 0
- (and (ior (eq_attr "cpu" "hypersparc") (eq_attr "cpu" "sparclite86x"))
- (eq_attr "type" "fpsqrt"))
- 17 15)
-
-(define_function_unit "fp_mds" 1 0
- (and (ior (eq_attr "cpu" "hypersparc") (eq_attr "cpu" "sparclite86x"))
- (eq_attr "type" "imul"))
- 17 15)
-
-;; ----- sparclet tsc701 scheduling
-;; The tsc701 issues 1 insn per cycle.
-;; Results may be written back out of order.
-
-;; Loads take 2 extra cycles to complete and 4 can be buffered at a time.
-
-(define_function_unit "tsc701_load" 4 1
- (and (eq_attr "cpu" "tsc701")
- (eq_attr "type" "load,sload"))
- 3 1)
-
-;; Stores take 2(?) extra cycles to complete.
-;; It is desirable to not have any memory operation in the following 2 cycles.
-;; (??? or 2 memory ops in the case of std).
-
-(define_function_unit "tsc701_store" 1 0
- (and (eq_attr "cpu" "tsc701")
- (eq_attr "type" "store"))
- 3 3
- [(eq_attr "type" "load,sload,store")])
-
-;; The multiply unit has a latency of 5.
-(define_function_unit "tsc701_mul" 1 0
- (and (eq_attr "cpu" "tsc701")
- (eq_attr "type" "imul"))
- 5 5)
-
-;; ----- The UltraSPARC-1 scheduling
-;; UltraSPARC has two integer units. Shift instructions can only execute
-;; on IE0. Condition code setting instructions, call, and jmpl (including
-;; the ret and retl pseudo-instructions) can only execute on IE1.
-;; Branch on register uses IE1, but branch on condition code does not.
-;; Conditional moves take 2 cycles. No other instruction can issue in the
-;; same cycle as a conditional move.
-;; Multiply and divide take many cycles during which no other instructions
-;; can issue.
-;; Memory delivers its result in two cycles (except for signed loads,
-;; which take one cycle more). One memory instruction can be issued per
-;; cycle.
-
-(define_function_unit "memory" 1 0
- (and (eq_attr "cpu" "ultrasparc")
- (eq_attr "type" "load,fpload"))
- 2 1)
-
-(define_function_unit "memory" 1 0
- (and (eq_attr "cpu" "ultrasparc")
- (eq_attr "type" "sload"))
- 3 1)
-
-(define_function_unit "memory" 1 0
- (and (eq_attr "cpu" "ultrasparc")
- (eq_attr "type" "store,fpstore"))
- 1 1)
-
-(define_function_unit "ieuN" 2 0
- (and (eq_attr "cpu" "ultrasparc")
- (eq_attr "type" "ialu,binary,move,unary,shift,compare,call,call_no_delay_slot,uncond_branch"))
- 1 1)
-
-(define_function_unit "ieu0" 1 0
- (and (eq_attr "cpu" "ultrasparc")
- (eq_attr "type" "shift"))
- 1 1)
-
-(define_function_unit "ieu0" 1 0
- (and (eq_attr "cpu" "ultrasparc")
- (eq_attr "type" "cmove"))
- 2 1)
-
-(define_function_unit "ieu1" 1 0
- (and (eq_attr "cpu" "ultrasparc")
- (eq_attr "type" "compare,call,call_no_delay_slot,uncond_branch"))
- 1 1)
-
-(define_function_unit "cti" 1 0
- (and (eq_attr "cpu" "ultrasparc")
- (eq_attr "type" "branch"))
- 1 1)
-
-;; Timings; throughput/latency
-;; FMOV 1/1 fmov, fabs, fneg
-;; FMOVcc 1/2
-;; FADD 1/4 add/sub, format conv, compar
-;; FMUL 1/4
-;; FDIVs 12/12
-;; FDIVd 22/22
-;; FSQRTs 12/12
-;; FSQRTd 22/22
-;; FCMP takes 1 cycle to branch, 2 cycles to conditional move.
-;;
-;; ??? This is really bogus because the timings really depend upon
-;; who uses the result. We should record who the user is with
-;; more descriptive 'type' attribute names and account for these
-;; issues in ultrasparc_adjust_cost.
-
-(define_function_unit "fadd" 1 0
- (and (eq_attr "cpu" "ultrasparc")
- (eq_attr "type" "fpmove"))
- 1 1)
-
-(define_function_unit "fadd" 1 0
- (and (eq_attr "cpu" "ultrasparc")
- (eq_attr "type" "fpcmove"))
- 2 1)
-
-(define_function_unit "fadd" 1 0
- (and (eq_attr "cpu" "ultrasparc")
- (eq_attr "type" "fp"))
- 4 1)
-
-(define_function_unit "fadd" 1 0
- (and (eq_attr "cpu" "ultrasparc")
- (eq_attr "type" "fpcmp"))
- 2 1)
-
-(define_function_unit "fmul" 1 0
- (and (eq_attr "cpu" "ultrasparc")
- (eq_attr "type" "fpmul"))
- 4 1)
-
-(define_function_unit "fadd" 1 0
- (and (eq_attr "cpu" "ultrasparc")
- (eq_attr "type" "fpcmove"))
- 2 1)
-
-(define_function_unit "fmul" 1 0
- (and (eq_attr "cpu" "ultrasparc")
- (eq_attr "type" "fpdivs"))
- 12 12)
-
-(define_function_unit "fmul" 1 0
- (and (eq_attr "cpu" "ultrasparc")
- (eq_attr "type" "fpdivd"))
- 22 22)
-
-(define_function_unit "fmul" 1 0
- (and (eq_attr "cpu" "ultrasparc")
- (eq_attr "type" "fpsqrt"))
- 12 12)
-
-;; Compare instructions.
-;; This controls RTL generation and register allocation.
-
-;; We generate RTL for comparisons and branches by having the cmpxx
-;; patterns store away the operands. Then, the scc and bcc patterns
-;; emit RTL for both the compare and the branch.
-;;
-;; We do this because we want to generate different code for an sne and
-;; seq insn. In those cases, if the second operand of the compare is not
-;; const0_rtx, we want to compute the xor of the two operands and test
-;; it against zero.
-;;
-;; We start with the DEFINE_EXPANDs, then the DEFINE_INSNs to match
-;; the patterns. Finally, we have the DEFINE_SPLITs for some of the scc
-;; insns that actually require more than one machine instruction.
-
-;; Put cmpsi first among compare insns so it matches two CONST_INT operands.
-
-(define_expand "cmpsi"
- [(set (reg:CC 100)
- (compare:CC (match_operand:SI 0 "register_operand" "")
- (match_operand:SI 1 "arith_operand" "")))]
- ""
- "
-{
- sparc_compare_op0 = operands[0];
- sparc_compare_op1 = operands[1];
- DONE;
-}")
-
-(define_expand "cmpdi"
- [(set (reg:CCX 100)
- (compare:CCX (match_operand:DI 0 "register_operand" "")
- (match_operand:DI 1 "arith_double_operand" "")))]
- "TARGET_ARCH64"
- "
-{
- sparc_compare_op0 = operands[0];
- sparc_compare_op1 = operands[1];
- DONE;
-}")
-
-(define_expand "cmpsf"
- ;; The 96 here isn't ever used by anyone.
- [(set (reg:CCFP 96)
- (compare:CCFP (match_operand:SF 0 "register_operand" "")
- (match_operand:SF 1 "register_operand" "")))]
- "TARGET_FPU"
- "
-{
- sparc_compare_op0 = operands[0];
- sparc_compare_op1 = operands[1];
- DONE;
-}")
-
-(define_expand "cmpdf"
- ;; The 96 here isn't ever used by anyone.
- [(set (reg:CCFP 96)
- (compare:CCFP (match_operand:DF 0 "register_operand" "")
- (match_operand:DF 1 "register_operand" "")))]
- "TARGET_FPU"
- "
-{
- sparc_compare_op0 = operands[0];
- sparc_compare_op1 = operands[1];
- DONE;
-}")
-
-(define_expand "cmptf"
- ;; The 96 here isn't ever used by anyone.
- [(set (reg:CCFP 96)
- (compare:CCFP (match_operand:TF 0 "register_operand" "")
- (match_operand:TF 1 "register_operand" "")))]
- "TARGET_FPU"
- "
-{
- sparc_compare_op0 = operands[0];
- sparc_compare_op1 = operands[1];
- DONE;
-}")
-
-;; Now the compare DEFINE_INSNs.
-
-(define_insn "*cmpsi_insn"
- [(set (reg:CC 100)
- (compare:CC (match_operand:SI 0 "register_operand" "r")
- (match_operand:SI 1 "arith_operand" "rI")))]
- ""
- "cmp\\t%0, %1"
- [(set_attr "type" "compare")])
-
-(define_insn "*cmpdi_sp64"
- [(set (reg:CCX 100)
- (compare:CCX (match_operand:DI 0 "register_operand" "r")
- (match_operand:DI 1 "arith_double_operand" "rHI")))]
- "TARGET_ARCH64"
- "cmp\\t%0, %1"
- [(set_attr "type" "compare")])
-
-(define_insn "*cmpsf_fpe"
- [(set (match_operand:CCFPE 0 "fcc_reg_operand" "=c")
- (compare:CCFPE (match_operand:SF 1 "register_operand" "f")
- (match_operand:SF 2 "register_operand" "f")))]
- "TARGET_FPU"
- "*
-{
- if (TARGET_V9)
- return \"fcmpes\\t%0, %1, %2\";
- return \"fcmpes\\t%1, %2\";
-}"
- [(set_attr "type" "fpcmp")])
-
-(define_insn "*cmpdf_fpe"
- [(set (match_operand:CCFPE 0 "fcc_reg_operand" "=c")
- (compare:CCFPE (match_operand:DF 1 "register_operand" "e")
- (match_operand:DF 2 "register_operand" "e")))]
- "TARGET_FPU"
- "*
-{
- if (TARGET_V9)
- return \"fcmped\\t%0, %1, %2\";
- return \"fcmped\\t%1, %2\";
-}"
- [(set_attr "type" "fpcmp")])
-
-(define_insn "*cmptf_fpe"
- [(set (match_operand:CCFPE 0 "fcc_reg_operand" "=c")
- (compare:CCFPE (match_operand:TF 1 "register_operand" "e")
- (match_operand:TF 2 "register_operand" "e")))]
- "TARGET_FPU && TARGET_HARD_QUAD"
- "*
-{
- if (TARGET_V9)
- return \"fcmpeq\\t%0, %1, %2\";
- return \"fcmpeq\\t%1, %2\";
-}"
- [(set_attr "type" "fpcmp")])
-
-(define_insn "*cmpsf_fp"
- [(set (match_operand:CCFP 0 "fcc_reg_operand" "=c")
- (compare:CCFP (match_operand:SF 1 "register_operand" "f")
- (match_operand:SF 2 "register_operand" "f")))]
- "TARGET_FPU"
- "*
-{
- if (TARGET_V9)
- return \"fcmps\\t%0, %1, %2\";
- return \"fcmps\\t%1, %2\";
-}"
- [(set_attr "type" "fpcmp")])
-
-(define_insn "*cmpdf_fp"
- [(set (match_operand:CCFP 0 "fcc_reg_operand" "=c")
- (compare:CCFP (match_operand:DF 1 "register_operand" "e")
- (match_operand:DF 2 "register_operand" "e")))]
- "TARGET_FPU"
- "*
-{
- if (TARGET_V9)
- return \"fcmpd\\t%0, %1, %2\";
- return \"fcmpd\\t%1, %2\";
-}"
- [(set_attr "type" "fpcmp")])
-
-(define_insn "*cmptf_fp"
- [(set (match_operand:CCFP 0 "fcc_reg_operand" "=c")
- (compare:CCFP (match_operand:TF 1 "register_operand" "e")
- (match_operand:TF 2 "register_operand" "e")))]
- "TARGET_FPU && TARGET_HARD_QUAD"
- "*
-{
- if (TARGET_V9)
- return \"fcmpq\\t%0, %1, %2\";
- return \"fcmpq\\t%1, %2\";
-}"
- [(set_attr "type" "fpcmp")])
-
-;; Next come the scc insns. For seq, sne, sgeu, and sltu, we can do this
-;; without jumps using the addx/subx instructions. For seq/sne on v9 we use
-;; the same code as v8 (the addx/subx method has more applications). The
-;; exception to this is "reg != 0" which can be done in one instruction on v9
-;; (so we do it). For the rest, on v9 we use conditional moves; on v8, we do
-;; branches.
-
-;; Seq_special[_xxx] and sne_special[_xxx] clobber the CC reg, because they
-;; generate addcc/subcc instructions.
-
-(define_expand "seqsi_special"
- [(set (match_dup 3)
- (xor:SI (match_operand:SI 1 "register_operand" "")
- (match_operand:SI 2 "register_operand" "")))
- (parallel [(set (match_operand:SI 0 "register_operand" "")
- (eq:SI (match_dup 3) (const_int 0)))
- (clobber (reg:CC 100))])]
- "! TARGET_LIVE_G0"
- "{ operands[3] = gen_reg_rtx (SImode); }")
-
-(define_expand "seqdi_special"
- [(set (match_dup 3)
- (xor:DI (match_operand:DI 1 "register_operand" "")
- (match_operand:DI 2 "register_operand" "")))
- (set (match_operand:DI 0 "register_operand" "")
- (eq:DI (match_dup 3) (const_int 0)))]
- "TARGET_ARCH64"
- "{ operands[3] = gen_reg_rtx (DImode); }")
-
-(define_expand "snesi_special"
- [(set (match_dup 3)
- (xor:SI (match_operand:SI 1 "register_operand" "")
- (match_operand:SI 2 "register_operand" "")))
- (parallel [(set (match_operand:SI 0 "register_operand" "")
- (ne:SI (match_dup 3) (const_int 0)))
- (clobber (reg:CC 100))])]
- "! TARGET_LIVE_G0"
- "{ operands[3] = gen_reg_rtx (SImode); }")
-
-(define_expand "snedi_special"
- [(set (match_dup 3)
- (xor:DI (match_operand:DI 1 "register_operand" "")
- (match_operand:DI 2 "register_operand" "")))
- (set (match_operand:DI 0 "register_operand" "")
- (ne:DI (match_dup 3) (const_int 0)))]
- "TARGET_ARCH64"
- "{ operands[3] = gen_reg_rtx (DImode); }")
-
-(define_expand "seqdi_special_trunc"
- [(set (match_dup 3)
- (xor:DI (match_operand:DI 1 "register_operand" "")
- (match_operand:DI 2 "register_operand" "")))
- (set (match_operand:SI 0 "register_operand" "")
- (eq:SI (match_dup 3) (const_int 0)))]
- "TARGET_ARCH64"
- "{ operands[3] = gen_reg_rtx (DImode); }")
-
-(define_expand "snedi_special_trunc"
- [(set (match_dup 3)
- (xor:DI (match_operand:DI 1 "register_operand" "")
- (match_operand:DI 2 "register_operand" "")))
- (set (match_operand:SI 0 "register_operand" "")
- (ne:SI (match_dup 3) (const_int 0)))]
- "TARGET_ARCH64"
- "{ operands[3] = gen_reg_rtx (DImode); }")
-
-(define_expand "seqsi_special_extend"
- [(set (match_dup 3)
- (xor:SI (match_operand:SI 1 "register_operand" "")
- (match_operand:SI 2 "register_operand" "")))
- (parallel [(set (match_operand:DI 0 "register_operand" "")
- (eq:DI (match_dup 3) (const_int 0)))
- (clobber (reg:CC 100))])]
- "TARGET_ARCH64"
- "{ operands[3] = gen_reg_rtx (SImode); }")
-
-(define_expand "snesi_special_extend"
- [(set (match_dup 3)
- (xor:SI (match_operand:SI 1 "register_operand" "")
- (match_operand:SI 2 "register_operand" "")))
- (parallel [(set (match_operand:DI 0 "register_operand" "")
- (ne:DI (match_dup 3) (const_int 0)))
- (clobber (reg:CC 100))])]
- "TARGET_ARCH64"
- "{ operands[3] = gen_reg_rtx (SImode); }")
-
-;; ??? v9: Operand 0 needs a mode, so SImode was chosen.
-;; However, the code handles both SImode and DImode.
-(define_expand "seq"
- [(set (match_operand:SI 0 "intreg_operand" "")
- (eq:SI (match_dup 1) (const_int 0)))]
- "! TARGET_LIVE_G0"
- "
-{
- if (GET_MODE (sparc_compare_op0) == SImode)
- {
- rtx pat;
-
- if (GET_MODE (operands[0]) == SImode)
- pat = gen_seqsi_special (operands[0], sparc_compare_op0,
- sparc_compare_op1);
- else if (! TARGET_ARCH64)
- FAIL;
- else
- pat = gen_seqsi_special_extend (operands[0], sparc_compare_op0,
- sparc_compare_op1);
- emit_insn (pat);
- DONE;
- }
- else if (GET_MODE (sparc_compare_op0) == DImode)
- {
- rtx pat;
-
- if (! TARGET_ARCH64)
- FAIL;
- else if (GET_MODE (operands[0]) == SImode)
- pat = gen_seqdi_special_trunc (operands[0], sparc_compare_op0,
- sparc_compare_op1);
- else
- pat = gen_seqdi_special (operands[0], sparc_compare_op0,
- sparc_compare_op1);
- emit_insn (pat);
- DONE;
- }
- else if (GET_MODE (sparc_compare_op0) == TFmode && ! TARGET_HARD_QUAD)
- {
- emit_float_lib_cmp (sparc_compare_op0, sparc_compare_op1, EQ);
- emit_insn (gen_sne (operands[0]));
- DONE;
- }
- else if (TARGET_V9)
- {
- if (gen_v9_scc (EQ, operands))
- DONE;
- /* fall through */
- }
- FAIL;
-}")
-
-;; ??? v9: Operand 0 needs a mode, so SImode was chosen.
-;; However, the code handles both SImode and DImode.
-(define_expand "sne"
- [(set (match_operand:SI 0 "intreg_operand" "")
- (ne:SI (match_dup 1) (const_int 0)))]
- "! TARGET_LIVE_G0"
- "
-{
- if (GET_MODE (sparc_compare_op0) == SImode)
- {
- rtx pat;
-
- if (GET_MODE (operands[0]) == SImode)
- pat = gen_snesi_special (operands[0], sparc_compare_op0,
- sparc_compare_op1);
- else if (! TARGET_ARCH64)
- FAIL;
- else
- pat = gen_snesi_special_extend (operands[0], sparc_compare_op0,
- sparc_compare_op1);
- emit_insn (pat);
- DONE;
- }
- else if (GET_MODE (sparc_compare_op0) == DImode)
- {
- rtx pat;
-
- if (! TARGET_ARCH64)
- FAIL;
- else if (GET_MODE (operands[0]) == SImode)
- pat = gen_snedi_special_trunc (operands[0], sparc_compare_op0,
- sparc_compare_op1);
- else
- pat = gen_snedi_special (operands[0], sparc_compare_op0,
- sparc_compare_op1);
- emit_insn (pat);
- DONE;
- }
- else if (GET_MODE (sparc_compare_op0) == TFmode && ! TARGET_HARD_QUAD)
- {
- emit_float_lib_cmp (sparc_compare_op0, sparc_compare_op1, NE);
- emit_insn (gen_sne (operands[0]));
- DONE;
- }
- else if (TARGET_V9)
- {
- if (gen_v9_scc (NE, operands))
- DONE;
- /* fall through */
- }
- FAIL;
-}")
-
-(define_expand "sgt"
- [(set (match_operand:SI 0 "intreg_operand" "")
- (gt:SI (match_dup 1) (const_int 0)))]
- "! TARGET_LIVE_G0"
- "
-{
- if (GET_MODE (sparc_compare_op0) == TFmode && ! TARGET_HARD_QUAD)
- {
- emit_float_lib_cmp (sparc_compare_op0, sparc_compare_op1, GT);
- emit_insn (gen_sne (operands[0]));
- DONE;
- }
- else if (TARGET_V9)
- {
- if (gen_v9_scc (GT, operands))
- DONE;
- /* fall through */
- }
- FAIL;
-}")
-
-(define_expand "slt"
- [(set (match_operand:SI 0 "intreg_operand" "")
- (lt:SI (match_dup 1) (const_int 0)))]
- "! TARGET_LIVE_G0"
- "
-{
- if (GET_MODE (sparc_compare_op0) == TFmode && ! TARGET_HARD_QUAD)
- {
- emit_float_lib_cmp (sparc_compare_op0, sparc_compare_op1, LT);
- emit_insn (gen_sne (operands[0]));
- DONE;
- }
- else if (TARGET_V9)
- {
- if (gen_v9_scc (LT, operands))
- DONE;
- /* fall through */
- }
- FAIL;
-}")
-
-(define_expand "sge"
- [(set (match_operand:SI 0 "intreg_operand" "")
- (ge:SI (match_dup 1) (const_int 0)))]
- "! TARGET_LIVE_G0"
- "
-{
- if (GET_MODE (sparc_compare_op0) == TFmode && ! TARGET_HARD_QUAD)
- {
- emit_float_lib_cmp (sparc_compare_op0, sparc_compare_op1, GE);
- emit_insn (gen_sne (operands[0]));
- DONE;
- }
- else if (TARGET_V9)
- {
- if (gen_v9_scc (GE, operands))
- DONE;
- /* fall through */
- }
- FAIL;
-}")
-
-(define_expand "sle"
- [(set (match_operand:SI 0 "intreg_operand" "")
- (le:SI (match_dup 1) (const_int 0)))]
- "! TARGET_LIVE_G0"
- "
-{
- if (GET_MODE (sparc_compare_op0) == TFmode && ! TARGET_HARD_QUAD)
- {
- emit_float_lib_cmp (sparc_compare_op0, sparc_compare_op1, LE);
- emit_insn (gen_sne (operands[0]));
- DONE;
- }
- else if (TARGET_V9)
- {
- if (gen_v9_scc (LE, operands))
- DONE;
- /* fall through */
- }
- FAIL;
-}")
-
-(define_expand "sgtu"
- [(set (match_operand:SI 0 "intreg_operand" "")
- (gtu:SI (match_dup 1) (const_int 0)))]
- "! TARGET_LIVE_G0"
- "
-{
- if (! TARGET_V9)
- {
- rtx tem, pat;
-
- /* We can do ltu easily, so if both operands are registers, swap them and
- do a LTU. */
- if ((GET_CODE (sparc_compare_op0) == REG
- || GET_CODE (sparc_compare_op0) == SUBREG)
- && (GET_CODE (sparc_compare_op1) == REG
- || GET_CODE (sparc_compare_op1) == SUBREG))
- {
- tem = sparc_compare_op0;
- sparc_compare_op0 = sparc_compare_op1;
- sparc_compare_op1 = tem;
- pat = gen_sltu (operands[0]);
- if (pat == NULL_RTX)
- FAIL;
- emit_insn (pat);
- DONE;
- }
- }
- else
- {
- if (gen_v9_scc (GTU, operands))
- DONE;
- }
- FAIL;
-}")
-
-(define_expand "sltu"
- [(set (match_operand:SI 0 "intreg_operand" "")
- (ltu:SI (match_dup 1) (const_int 0)))]
- "! TARGET_LIVE_G0"
- "
-{
- if (TARGET_V9)
- {
- if (gen_v9_scc (LTU, operands))
- DONE;
- }
- operands[1] = gen_compare_reg (LTU, sparc_compare_op0, sparc_compare_op1);
-}")
-
-(define_expand "sgeu"
- [(set (match_operand:SI 0 "intreg_operand" "")
- (geu:SI (match_dup 1) (const_int 0)))]
- "! TARGET_LIVE_G0"
- "
-{
- if (TARGET_V9)
- {
- if (gen_v9_scc (GEU, operands))
- DONE;
- }
- operands[1] = gen_compare_reg (GEU, sparc_compare_op0, sparc_compare_op1);
-}")
-
-(define_expand "sleu"
- [(set (match_operand:SI 0 "intreg_operand" "")
- (leu:SI (match_dup 1) (const_int 0)))]
- "! TARGET_LIVE_G0"
- "
-{
- if (! TARGET_V9)
- {
- rtx tem, pat;
-
- /* We can do geu easily, so if both operands are registers, swap them and
- do a GEU. */
- if ((GET_CODE (sparc_compare_op0) == REG
- || GET_CODE (sparc_compare_op0) == SUBREG)
- && (GET_CODE (sparc_compare_op1) == REG
- || GET_CODE (sparc_compare_op1) == SUBREG))
- {
- tem = sparc_compare_op0;
- sparc_compare_op0 = sparc_compare_op1;
- sparc_compare_op1 = tem;
- pat = gen_sgeu (operands[0]);
- if (pat == NULL_RTX)
- FAIL;
- emit_insn (pat);
- DONE;
- }
- }
- else
- {
- if (gen_v9_scc (LEU, operands))
- DONE;
- }
- FAIL;
-}")
-
-;; Now the DEFINE_INSNs for the scc cases.
-
-;; The SEQ and SNE patterns are special because they can be done
-;; without any branching and do not involve a COMPARE. We want
-;; them to always use the splitz below so the results can be
-;; scheduled.
-
-(define_insn "*snesi_zero"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (ne:SI (match_operand:SI 1 "register_operand" "r")
- (const_int 0)))
- (clobber (reg:CC 100))]
- "! TARGET_LIVE_G0"
- "#"
- [(set_attr "length" "2")])
-
-(define_split
- [(set (match_operand:SI 0 "register_operand" "")
- (ne:SI (match_operand:SI 1 "register_operand" "")
- (const_int 0)))
- (clobber (reg:CC 100))]
- ""
- [(set (reg:CC_NOOV 100) (compare:CC_NOOV (neg:SI (match_dup 1))
- (const_int 0)))
- (set (match_dup 0) (ltu:SI (reg:CC 100) (const_int 0)))]
- "")
-
-(define_insn "*neg_snesi_zero"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (neg:SI (ne:SI (match_operand:SI 1 "register_operand" "r")
- (const_int 0))))
- (clobber (reg:CC 100))]
- "! TARGET_LIVE_G0"
- "#"
- [(set_attr "length" "2")])
-
-(define_split
- [(set (match_operand:SI 0 "register_operand" "")
- (neg:SI (ne:SI (match_operand:SI 1 "register_operand" "")
- (const_int 0))))
- (clobber (reg:CC 100))]
- ""
- [(set (reg:CC_NOOV 100) (compare:CC_NOOV (neg:SI (match_dup 1))
- (const_int 0)))
- (set (match_dup 0) (neg:SI (ltu:SI (reg:CC 100) (const_int 0))))]
- "")
-
-(define_insn "*snesi_zero_extend"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (ne:DI (match_operand:SI 1 "register_operand" "r")
- (const_int 0)))
- (clobber (reg:CC 100))]
- "TARGET_ARCH64"
- "#"
- [(set_attr "type" "unary")
- (set_attr "length" "2")])
-
-(define_split
- [(set (match_operand:DI 0 "register_operand" "")
- (ne:DI (match_operand:SI 1 "register_operand" "")
- (const_int 0)))
- (clobber (reg:CC 100))]
- "TARGET_ARCH64"
- [(set (reg:CC_NOOV 100) (compare:CC_NOOV (minus:SI (const_int 0) (match_dup 1))
- (const_int 0)))
- (set (match_dup 0) (zero_extend:DI (plus:SI (plus:SI (const_int 0)
- (const_int 0))
- (ltu:SI (reg:CC_NOOV 100)
- (const_int 0)))))]
- "")
-
-(define_insn "*snedi_zero"
- [(set (match_operand:DI 0 "register_operand" "=&r")
- (ne:DI (match_operand:DI 1 "register_operand" "r")
- (const_int 0)))]
- "TARGET_ARCH64"
- "#"
- [(set_attr "type" "cmove")
- (set_attr "length" "2")])
-
-(define_split
- [(set (match_operand:DI 0 "register_operand" "")
- (ne:DI (match_operand:DI 1 "register_operand" "")
- (const_int 0)))]
- "TARGET_ARCH64"
- [(set (match_dup 0) (const_int 0))
- (set (match_dup 0) (if_then_else:DI (ne:DI (match_dup 1)
- (const_int 0))
- (const_int 1)
- (match_dup 0)))]
- "")
-
-(define_insn "*neg_snedi_zero"
- [(set (match_operand:DI 0 "register_operand" "=&r")
- (neg:DI (ne:DI (match_operand:DI 1 "register_operand" "r")
- (const_int 0))))]
- "TARGET_ARCH64"
- "#"
- [(set_attr "type" "cmove")
- (set_attr "length" "2")])
-
-(define_split
- [(set (match_operand:DI 0 "register_operand" "")
- (neg:DI (ne:DI (match_operand:DI 1 "register_operand" "")
- (const_int 0))))]
- "TARGET_ARCH64"
- [(set (match_dup 0) (const_int 0))
- (set (match_dup 0) (if_then_else:DI (ne:DI (match_dup 1)
- (const_int 0))
- (const_int -1)
- (match_dup 0)))]
- "")
-
-(define_insn "*snedi_zero_trunc"
- [(set (match_operand:SI 0 "register_operand" "=&r")
- (ne:SI (match_operand:DI 1 "register_operand" "r")
- (const_int 0)))]
- "TARGET_ARCH64"
- "#"
- [(set_attr "type" "cmove")
- (set_attr "length" "2")])
-
-(define_split
- [(set (match_operand:SI 0 "register_operand" "")
- (ne:SI (match_operand:DI 1 "register_operand" "")
- (const_int 0)))]
- "TARGET_ARCH64"
- [(set (match_dup 0) (const_int 0))
- (set (match_dup 0) (if_then_else:SI (ne:DI (match_dup 1)
- (const_int 0))
- (const_int 1)
- (match_dup 0)))]
- "")
-
-(define_insn "*seqsi_zero"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (eq:SI (match_operand:SI 1 "register_operand" "r")
- (const_int 0)))
- (clobber (reg:CC 100))]
- "! TARGET_LIVE_G0"
- "#"
- [(set_attr "length" "2")])
-
-(define_split
- [(set (match_operand:SI 0 "register_operand" "")
- (eq:SI (match_operand:SI 1 "register_operand" "")
- (const_int 0)))
- (clobber (reg:CC 100))]
- ""
- [(set (reg:CC_NOOV 100) (compare:CC_NOOV (neg:SI (match_dup 1))
- (const_int 0)))
- (set (match_dup 0) (geu:SI (reg:CC 100) (const_int 0)))]
- "")
-
-(define_insn "*neg_seqsi_zero"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (neg:SI (eq:SI (match_operand:SI 1 "register_operand" "r")
- (const_int 0))))
- (clobber (reg:CC 100))]
- "! TARGET_LIVE_G0"
- "#"
- [(set_attr "length" "2")])
-
-(define_split
- [(set (match_operand:SI 0 "register_operand" "")
- (neg:SI (eq:SI (match_operand:SI 1 "register_operand" "")
- (const_int 0))))
- (clobber (reg:CC 100))]
- ""
- [(set (reg:CC_NOOV 100) (compare:CC_NOOV (neg:SI (match_dup 1))
- (const_int 0)))
- (set (match_dup 0) (neg:SI (geu:SI (reg:CC 100) (const_int 0))))]
- "")
-
-(define_insn "*seqsi_zero_extend"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (eq:DI (match_operand:SI 1 "register_operand" "r")
- (const_int 0)))
- (clobber (reg:CC 100))]
- "TARGET_ARCH64"
- "#"
- [(set_attr "type" "unary")
- (set_attr "length" "2")])
-
-(define_split
- [(set (match_operand:DI 0 "register_operand" "")
- (eq:DI (match_operand:SI 1 "register_operand" "")
- (const_int 0)))
- (clobber (reg:CC 100))]
- "TARGET_ARCH64"
- [(set (reg:CC_NOOV 100) (compare:CC_NOOV (minus:SI (const_int 0) (match_dup 1))
- (const_int 0)))
- (set (match_dup 0) (zero_extend:DI (minus:SI (minus:SI (const_int 0)
- (const_int -1))
- (ltu:SI (reg:CC_NOOV 100)
- (const_int 0)))))]
- "")
-
-(define_insn "*seqdi_zero"
- [(set (match_operand:DI 0 "register_operand" "=&r")
- (eq:DI (match_operand:DI 1 "register_operand" "r")
- (const_int 0)))]
- "TARGET_ARCH64"
- "#"
- [(set_attr "type" "cmove")
- (set_attr "length" "2")])
-
-(define_split
- [(set (match_operand:DI 0 "register_operand" "")
- (eq:DI (match_operand:DI 1 "register_operand" "")
- (const_int 0)))]
- "TARGET_ARCH64"
- [(set (match_dup 0) (const_int 0))
- (set (match_dup 0) (if_then_else:DI (eq:DI (match_dup 1)
- (const_int 0))
- (const_int 1)
- (match_dup 0)))]
- "")
-
-(define_insn "*neg_seqdi_zero"
- [(set (match_operand:DI 0 "register_operand" "=&r")
- (neg:DI (eq:DI (match_operand:DI 1 "register_operand" "r")
- (const_int 0))))]
- "TARGET_ARCH64"
- "#"
- [(set_attr "type" "cmove")
- (set_attr "length" "2")])
-
-(define_split
- [(set (match_operand:DI 0 "register_operand" "")
- (neg:DI (eq:DI (match_operand:DI 1 "register_operand" "")
- (const_int 0))))]
- "TARGET_ARCH64"
- [(set (match_dup 0) (const_int 0))
- (set (match_dup 0) (if_then_else:DI (eq:DI (match_dup 1)
- (const_int 0))
- (const_int -1)
- (match_dup 0)))]
- "")
-
-(define_insn "*seqdi_zero_trunc"
- [(set (match_operand:SI 0 "register_operand" "=&r")
- (eq:SI (match_operand:DI 1 "register_operand" "r")
- (const_int 0)))]
- "TARGET_ARCH64"
- "#"
- [(set_attr "type" "cmove")
- (set_attr "length" "2")])
-
-(define_split
- [(set (match_operand:SI 0 "register_operand" "")
- (eq:SI (match_operand:DI 1 "register_operand" "")
- (const_int 0)))]
- "TARGET_ARCH64"
- [(set (match_dup 0) (const_int 0))
- (set (match_dup 0) (if_then_else:SI (eq:DI (match_dup 1)
- (const_int 0))
- (const_int 1)
- (match_dup 0)))]
- "")
-
-;; We can also do (x + (i == 0)) and related, so put them in.
-;; ??? The addx/subx insns use the 32 bit carry flag so there are no DImode
-;; versions for v9.
-
-(define_insn "*x_plus_i_ne_0"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (plus:SI (ne:SI (match_operand:SI 1 "register_operand" "r")
- (const_int 0))
- (match_operand:SI 2 "register_operand" "r")))
- (clobber (reg:CC 100))]
- "! TARGET_LIVE_G0"
- "#"
- [(set_attr "length" "2")])
-
-(define_split
- [(set (match_operand:SI 0 "register_operand" "")
- (plus:SI (ne:SI (match_operand:SI 1 "register_operand" "")
- (const_int 0))
- (match_operand:SI 2 "register_operand" "")))
- (clobber (reg:CC 100))]
- "! TARGET_LIVE_G0"
- [(set (reg:CC_NOOV 100) (compare:CC_NOOV (neg:SI (match_dup 1))
- (const_int 0)))
- (set (match_dup 0) (plus:SI (ltu:SI (reg:CC 100) (const_int 0))
- (match_dup 2)))]
- "")
-
-(define_insn "*x_minus_i_ne_0"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (minus:SI (match_operand:SI 2 "register_operand" "r")
- (ne:SI (match_operand:SI 1 "register_operand" "r")
- (const_int 0))))
- (clobber (reg:CC 100))]
- "! TARGET_LIVE_G0"
- "#"
- [(set_attr "length" "2")])
-
-(define_split
- [(set (match_operand:SI 0 "register_operand" "")
- (minus:SI (match_operand:SI 2 "register_operand" "")
- (ne:SI (match_operand:SI 1 "register_operand" "")
- (const_int 0))))
- (clobber (reg:CC 100))]
- "! TARGET_LIVE_G0"
- [(set (reg:CC_NOOV 100) (compare:CC_NOOV (neg:SI (match_dup 1))
- (const_int 0)))
- (set (match_dup 0) (minus:SI (match_dup 2)
- (ltu:SI (reg:CC 100) (const_int 0))))]
- "")
-
-(define_insn "*x_plus_i_eq_0"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (plus:SI (eq:SI (match_operand:SI 1 "register_operand" "r")
- (const_int 0))
- (match_operand:SI 2 "register_operand" "r")))
- (clobber (reg:CC 100))]
- "! TARGET_LIVE_G0"
- "#"
- [(set_attr "length" "2")])
-
-(define_split
- [(set (match_operand:SI 0 "register_operand" "")
- (plus:SI (eq:SI (match_operand:SI 1 "register_operand" "")
- (const_int 0))
- (match_operand:SI 2 "register_operand" "")))
- (clobber (reg:CC 100))]
- "! TARGET_LIVE_G0"
- [(set (reg:CC_NOOV 100) (compare:CC_NOOV (neg:SI (match_dup 1))
- (const_int 0)))
- (set (match_dup 0) (plus:SI (geu:SI (reg:CC 100) (const_int 0))
- (match_dup 2)))]
- "")
-
-(define_insn "*x_minus_i_eq_0"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (minus:SI (match_operand:SI 2 "register_operand" "r")
- (eq:SI (match_operand:SI 1 "register_operand" "r")
- (const_int 0))))
- (clobber (reg:CC 100))]
- "! TARGET_LIVE_G0"
- "#"
- [(set_attr "length" "2")])
-
-(define_split
- [(set (match_operand:SI 0 "register_operand" "")
- (minus:SI (match_operand:SI 2 "register_operand" "")
- (eq:SI (match_operand:SI 1 "register_operand" "")
- (const_int 0))))
- (clobber (reg:CC 100))]
- "! TARGET_LIVE_G0"
- [(set (reg:CC_NOOV 100) (compare:CC_NOOV (neg:SI (match_dup 1))
- (const_int 0)))
- (set (match_dup 0) (minus:SI (match_dup 2)
- (geu:SI (reg:CC 100) (const_int 0))))]
- "")
-
-;; We can also do GEU and LTU directly, but these operate after a compare.
-;; ??? The addx/subx insns use the 32 bit carry flag so there are no DImode
-;; versions for v9.
-
-(define_insn "*sltu_insn"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (ltu:SI (reg:CC 100) (const_int 0)))]
- "! TARGET_LIVE_G0"
- "addx\\t%%g0, 0, %0"
- [(set_attr "type" "misc")
- (set_attr "length" "1")])
-
-(define_insn "*neg_sltu_insn"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (neg:SI (ltu:SI (reg:CC 100) (const_int 0))))]
- "! TARGET_LIVE_G0"
- "subx\\t%%g0, 0, %0"
- [(set_attr "type" "misc")
- (set_attr "length" "1")])
-
-;; ??? Combine should canonicalize these next two to the same pattern.
-(define_insn "*neg_sltu_minus_x"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (minus:SI (neg:SI (ltu:SI (reg:CC 100) (const_int 0)))
- (match_operand:SI 1 "arith_operand" "rI")))]
- "! TARGET_LIVE_G0"
- "subx\\t%%g0, %1, %0"
- [(set_attr "type" "misc")
- (set_attr "length" "1")])
-
-(define_insn "*neg_sltu_plus_x"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (neg:SI (plus:SI (ltu:SI (reg:CC 100) (const_int 0))
- (match_operand:SI 1 "arith_operand" "rI"))))]
- "! TARGET_LIVE_G0"
- "subx\\t%%g0, %1, %0"
- [(set_attr "type" "misc")
- (set_attr "length" "1")])
-
-(define_insn "*sgeu_insn"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (geu:SI (reg:CC 100) (const_int 0)))]
- "! TARGET_LIVE_G0"
- "subx\\t%%g0, -1, %0"
- [(set_attr "type" "misc")
- (set_attr "length" "1")])
-
-(define_insn "*neg_sgeu_insn"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (neg:SI (geu:SI (reg:CC 100) (const_int 0))))]
- "! TARGET_LIVE_G0"
- "addx\\t%%g0, -1, %0"
- [(set_attr "type" "misc")
- (set_attr "length" "1")])
-
-;; We can also do (x + ((unsigned) i >= 0)) and related, so put them in.
-;; ??? The addx/subx insns use the 32 bit carry flag so there are no DImode
-;; versions for v9.
-
-(define_insn "*sltu_plus_x"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (plus:SI (ltu:SI (reg:CC 100) (const_int 0))
- (match_operand:SI 1 "arith_operand" "rI")))]
- "! TARGET_LIVE_G0"
- "addx\\t%%g0, %1, %0"
- [(set_attr "type" "misc")
- (set_attr "length" "1")])
-
-(define_insn "*sltu_plus_x_plus_y"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (plus:SI (ltu:SI (reg:CC 100) (const_int 0))
- (plus:SI (match_operand:SI 1 "arith_operand" "%r")
- (match_operand:SI 2 "arith_operand" "rI"))))]
- ""
- "addx\\t%1, %2, %0"
- [(set_attr "type" "misc")
- (set_attr "length" "1")])
-
-(define_insn "*x_minus_sltu"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (minus:SI (match_operand:SI 1 "register_operand" "r")
- (ltu:SI (reg:CC 100) (const_int 0))))]
- ""
- "subx\\t%1, 0, %0"
- [(set_attr "type" "misc")
- (set_attr "length" "1")])
-
-;; ??? Combine should canonicalize these next two to the same pattern.
-(define_insn "*x_minus_y_minus_sltu"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (minus:SI (minus:SI (match_operand:SI 1 "reg_or_0_operand" "rJ")
- (match_operand:SI 2 "arith_operand" "rI"))
- (ltu:SI (reg:CC 100) (const_int 0))))]
- ""
- "subx\\t%r1, %2, %0"
- [(set_attr "type" "misc")
- (set_attr "length" "1")])
-
-(define_insn "*x_minus_sltu_plus_y"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (minus:SI (match_operand:SI 1 "reg_or_0_operand" "rJ")
- (plus:SI (ltu:SI (reg:CC 100) (const_int 0))
- (match_operand:SI 2 "arith_operand" "rI"))))]
- ""
- "subx\\t%r1, %2, %0"
- [(set_attr "type" "misc")
- (set_attr "length" "1")])
-
-(define_insn "*sgeu_plus_x"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (plus:SI (geu:SI (reg:CC 100) (const_int 0))
- (match_operand:SI 1 "register_operand" "r")))]
- ""
- "subx\\t%1, -1, %0"
- [(set_attr "type" "misc")
- (set_attr "length" "1")])
-
-(define_insn "*x_minus_sgeu"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (minus:SI (match_operand:SI 1 "register_operand" "r")
- (geu:SI (reg:CC 100) (const_int 0))))]
- ""
- "addx\\t%1, -1, %0"
- [(set_attr "type" "misc")
- (set_attr "length" "1")])
-
-(define_split
- [(set (match_operand:SI 0 "register_operand" "=r")
- (match_operator:SI 2 "noov_compare_op"
- [(match_operand 1 "icc_or_fcc_reg_operand" "")
- (const_int 0)]))]
- ;; 32 bit LTU/GEU are better implemented using addx/subx
- "TARGET_V9 && REGNO (operands[1]) == SPARC_ICC_REG
- && (GET_MODE (operands[1]) == CCXmode
- || (GET_CODE (operands[2]) != LTU && GET_CODE (operands[2]) != GEU))"
- [(set (match_dup 0) (const_int 0))
- (set (match_dup 0)
- (if_then_else:SI (match_op_dup:SI 2 [(match_dup 1) (const_int 0)])
- (const_int 1)
- (match_dup 0)))]
- "")
-
-
-;; These control RTL generation for conditional jump insns
-
-;; The quad-word fp compare library routines all return nonzero to indicate
-;; true, which is different from the equivalent libgcc routines, so we must
-;; handle them specially here.
-
-(define_expand "beq"
- [(set (pc)
- (if_then_else (eq (match_dup 1) (const_int 0))
- (label_ref (match_operand 0 "" ""))
- (pc)))]
- ""
- "
-{
- if (TARGET_ARCH64 && sparc_compare_op1 == const0_rtx
- && GET_CODE (sparc_compare_op0) == REG
- && GET_MODE (sparc_compare_op0) == DImode)
- {
- emit_v9_brxx_insn (EQ, sparc_compare_op0, operands[0]);
- DONE;
- }
- else if (GET_MODE (sparc_compare_op0) == TFmode && ! TARGET_HARD_QUAD)
- {
- emit_float_lib_cmp (sparc_compare_op0, sparc_compare_op1, EQ);
- emit_jump_insn (gen_bne (operands[0]));
- DONE;
- }
- operands[1] = gen_compare_reg (EQ, sparc_compare_op0, sparc_compare_op1);
-}")
-
-(define_expand "bne"
- [(set (pc)
- (if_then_else (ne (match_dup 1) (const_int 0))
- (label_ref (match_operand 0 "" ""))
- (pc)))]
- ""
- "
-{
- if (TARGET_ARCH64 && sparc_compare_op1 == const0_rtx
- && GET_CODE (sparc_compare_op0) == REG
- && GET_MODE (sparc_compare_op0) == DImode)
- {
- emit_v9_brxx_insn (NE, sparc_compare_op0, operands[0]);
- DONE;
- }
- else if (GET_MODE (sparc_compare_op0) == TFmode && ! TARGET_HARD_QUAD)
- {
- emit_float_lib_cmp (sparc_compare_op0, sparc_compare_op1, NE);
- emit_jump_insn (gen_bne (operands[0]));
- DONE;
- }
- operands[1] = gen_compare_reg (NE, sparc_compare_op0, sparc_compare_op1);
-}")
-
-(define_expand "bgt"
- [(set (pc)
- (if_then_else (gt (match_dup 1) (const_int 0))
- (label_ref (match_operand 0 "" ""))
- (pc)))]
- ""
- "
-{
- if (TARGET_ARCH64 && sparc_compare_op1 == const0_rtx
- && GET_CODE (sparc_compare_op0) == REG
- && GET_MODE (sparc_compare_op0) == DImode)
- {
- emit_v9_brxx_insn (GT, sparc_compare_op0, operands[0]);
- DONE;
- }
- else if (GET_MODE (sparc_compare_op0) == TFmode && ! TARGET_HARD_QUAD)
- {
- emit_float_lib_cmp (sparc_compare_op0, sparc_compare_op1, GT);
- emit_jump_insn (gen_bne (operands[0]));
- DONE;
- }
- operands[1] = gen_compare_reg (GT, sparc_compare_op0, sparc_compare_op1);
-}")
-
-(define_expand "bgtu"
- [(set (pc)
- (if_then_else (gtu (match_dup 1) (const_int 0))
- (label_ref (match_operand 0 "" ""))
- (pc)))]
- ""
- "
-{ operands[1] = gen_compare_reg (GTU, sparc_compare_op0, sparc_compare_op1);
-}")
-
-(define_expand "blt"
- [(set (pc)
- (if_then_else (lt (match_dup 1) (const_int 0))
- (label_ref (match_operand 0 "" ""))
- (pc)))]
- ""
- "
-{
- if (TARGET_ARCH64 && sparc_compare_op1 == const0_rtx
- && GET_CODE (sparc_compare_op0) == REG
- && GET_MODE (sparc_compare_op0) == DImode)
- {
- emit_v9_brxx_insn (LT, sparc_compare_op0, operands[0]);
- DONE;
- }
- else if (GET_MODE (sparc_compare_op0) == TFmode && ! TARGET_HARD_QUAD)
- {
- emit_float_lib_cmp (sparc_compare_op0, sparc_compare_op1, LT);
- emit_jump_insn (gen_bne (operands[0]));
- DONE;
- }
- operands[1] = gen_compare_reg (LT, sparc_compare_op0, sparc_compare_op1);
-}")
-
-(define_expand "bltu"
- [(set (pc)
- (if_then_else (ltu (match_dup 1) (const_int 0))
- (label_ref (match_operand 0 "" ""))
- (pc)))]
- ""
- "
-{ operands[1] = gen_compare_reg (LTU, sparc_compare_op0, sparc_compare_op1);
-}")
-
-(define_expand "bge"
- [(set (pc)
- (if_then_else (ge (match_dup 1) (const_int 0))
- (label_ref (match_operand 0 "" ""))
- (pc)))]
- ""
- "
-{
- if (TARGET_ARCH64 && sparc_compare_op1 == const0_rtx
- && GET_CODE (sparc_compare_op0) == REG
- && GET_MODE (sparc_compare_op0) == DImode)
- {
- emit_v9_brxx_insn (GE, sparc_compare_op0, operands[0]);
- DONE;
- }
- else if (GET_MODE (sparc_compare_op0) == TFmode && ! TARGET_HARD_QUAD)
- {
- emit_float_lib_cmp (sparc_compare_op0, sparc_compare_op1, GE);
- emit_jump_insn (gen_bne (operands[0]));
- DONE;
- }
- operands[1] = gen_compare_reg (GE, sparc_compare_op0, sparc_compare_op1);
-}")
-
-(define_expand "bgeu"
- [(set (pc)
- (if_then_else (geu (match_dup 1) (const_int 0))
- (label_ref (match_operand 0 "" ""))
- (pc)))]
- ""
- "
-{ operands[1] = gen_compare_reg (GEU, sparc_compare_op0, sparc_compare_op1);
-}")
-
-(define_expand "ble"
- [(set (pc)
- (if_then_else (le (match_dup 1) (const_int 0))
- (label_ref (match_operand 0 "" ""))
- (pc)))]
- ""
- "
-{
- if (TARGET_ARCH64 && sparc_compare_op1 == const0_rtx
- && GET_CODE (sparc_compare_op0) == REG
- && GET_MODE (sparc_compare_op0) == DImode)
- {
- emit_v9_brxx_insn (LE, sparc_compare_op0, operands[0]);
- DONE;
- }
- else if (GET_MODE (sparc_compare_op0) == TFmode && ! TARGET_HARD_QUAD)
- {
- emit_float_lib_cmp (sparc_compare_op0, sparc_compare_op1, LE);
- emit_jump_insn (gen_bne (operands[0]));
- DONE;
- }
- operands[1] = gen_compare_reg (LE, sparc_compare_op0, sparc_compare_op1);
-}")
-
-(define_expand "bleu"
- [(set (pc)
- (if_then_else (leu (match_dup 1) (const_int 0))
- (label_ref (match_operand 0 "" ""))
- (pc)))]
- ""
- "
-{ operands[1] = gen_compare_reg (LEU, sparc_compare_op0, sparc_compare_op1);
-}")
-
-;; Now match both normal and inverted jump.
-
-;; XXX fpcmp nop braindamage
-(define_insn "*normal_branch"
- [(set (pc)
- (if_then_else (match_operator 0 "noov_compare_op"
- [(reg 100) (const_int 0)])
- (label_ref (match_operand 1 "" ""))
- (pc)))]
- ""
- "*
-{
- return output_cbranch (operands[0], 1, 0,
- final_sequence && INSN_ANNULLED_BRANCH_P (insn),
- ! final_sequence, insn);
-}"
- [(set_attr "type" "branch")])
-
-;; XXX fpcmp nop braindamage
-(define_insn "*inverted_branch"
- [(set (pc)
- (if_then_else (match_operator 0 "noov_compare_op"
- [(reg 100) (const_int 0)])
- (pc)
- (label_ref (match_operand 1 "" ""))))]
- ""
- "*
-{
- return output_cbranch (operands[0], 1, 1,
- final_sequence && INSN_ANNULLED_BRANCH_P (insn),
- ! final_sequence, insn);
-}"
- [(set_attr "type" "branch")])
-
-;; XXX fpcmp nop braindamage
-(define_insn "*normal_fp_branch"
- [(set (pc)
- (if_then_else (match_operator 1 "comparison_operator"
- [(match_operand:CCFP 0 "fcc_reg_operand" "c")
- (const_int 0)])
- (label_ref (match_operand 2 "" ""))
- (pc)))]
- ""
- "*
-{
- return output_cbranch (operands[1], 2, 0,
- final_sequence && INSN_ANNULLED_BRANCH_P (insn),
- ! final_sequence, insn);
-}"
- [(set_attr "type" "branch")])
-
-;; XXX fpcmp nop braindamage
-(define_insn "*inverted_fp_branch"
- [(set (pc)
- (if_then_else (match_operator 1 "comparison_operator"
- [(match_operand:CCFP 0 "fcc_reg_operand" "c")
- (const_int 0)])
- (pc)
- (label_ref (match_operand 2 "" ""))))]
- ""
- "*
-{
- return output_cbranch (operands[1], 2, 1,
- final_sequence && INSN_ANNULLED_BRANCH_P (insn),
- ! final_sequence, insn);
-}"
- [(set_attr "type" "branch")])
-
-;; XXX fpcmp nop braindamage
-(define_insn "*normal_fpe_branch"
- [(set (pc)
- (if_then_else (match_operator 1 "comparison_operator"
- [(match_operand:CCFPE 0 "fcc_reg_operand" "c")
- (const_int 0)])
- (label_ref (match_operand 2 "" ""))
- (pc)))]
- ""
- "*
-{
- return output_cbranch (operands[1], 2, 0,
- final_sequence && INSN_ANNULLED_BRANCH_P (insn),
- ! final_sequence, insn);
-}"
- [(set_attr "type" "branch")])
-
-;; XXX fpcmp nop braindamage
-(define_insn "*inverted_fpe_branch"
- [(set (pc)
- (if_then_else (match_operator 1 "comparison_operator"
- [(match_operand:CCFPE 0 "fcc_reg_operand" "c")
- (const_int 0)])
- (pc)
- (label_ref (match_operand 2 "" ""))))]
- ""
- "*
-{
- return output_cbranch (operands[1], 2, 1,
- final_sequence && INSN_ANNULLED_BRANCH_P (insn),
- ! final_sequence, insn);
-}"
- [(set_attr "type" "branch")])
-
-;; Sparc V9-specific jump insns. None of these are guaranteed to be
-;; in the architecture.
-
-;; There are no 32 bit brreg insns.
-
-;; XXX
-(define_insn "*normal_int_branch_sp64"
- [(set (pc)
- (if_then_else (match_operator 0 "v9_regcmp_op"
- [(match_operand:DI 1 "register_operand" "r")
- (const_int 0)])
- (label_ref (match_operand 2 "" ""))
- (pc)))]
- "TARGET_ARCH64"
- "*
-{
- return output_v9branch (operands[0], 1, 2, 0,
- final_sequence && INSN_ANNULLED_BRANCH_P (insn),
- ! final_sequence, insn);
-}"
- [(set_attr "type" "branch")])
-
-;; XXX
-(define_insn "*inverted_int_branch_sp64"
- [(set (pc)
- (if_then_else (match_operator 0 "v9_regcmp_op"
- [(match_operand:DI 1 "register_operand" "r")
- (const_int 0)])
- (pc)
- (label_ref (match_operand 2 "" ""))))]
- "TARGET_ARCH64"
- "*
-{
- return output_v9branch (operands[0], 1, 2, 1,
- final_sequence && INSN_ANNULLED_BRANCH_P (insn),
- ! final_sequence, insn);
-}"
- [(set_attr "type" "branch")])
-
-;; Load program counter insns.
-
-(define_insn "get_pc"
- [(clobber (reg:SI 15))
- (set (match_operand 0 "register_operand" "=r")
- (unspec [(match_operand 1 "" "") (match_operand 2 "" "")] 2))]
- "flag_pic && REGNO (operands[0]) == 23"
- "sethi\\t%%hi(%a1-4), %0\\n\\tcall\\t%a2\\n\\tadd\\t%0, %%lo(%a1+4), %0"
- [(set_attr "length" "3")])
-
-;; Currently unused...
-;; (define_insn "get_pc_via_rdpc"
-;; [(set (match_operand 0 "register_operand" "=r") (pc))]
-;; "TARGET_V9"
-;; "rd\\t%%pc, %0"
-;; [(set_attr "type" "move")])
-
-
-;; Move instructions
-
-(define_expand "movqi"
- [(set (match_operand:QI 0 "general_operand" "")
- (match_operand:QI 1 "general_operand" ""))]
- ""
- "
-{
- /* Working with CONST_INTs is easier, so convert
- a double if needed. */
- if (GET_CODE (operands[1]) == CONST_DOUBLE)
- {
- operands[1] = GEN_INT (CONST_DOUBLE_LOW (operands[1]) & 0xff);
- }
- else if (GET_CODE (operands[1]) == CONST_INT)
- {
- /* And further, we know for all QI cases that only the
- low byte is significant, which we can always process
- in a single insn. So mask it now. */
- operands[1] = GEN_INT (INTVAL (operands[1]) & 0xff);
- }
-
- /* Handle sets of MEM first. */
- if (GET_CODE (operands[0]) == MEM)
- {
- /* This checks TARGET_LIVE_G0 for us. */
- if (reg_or_0_operand (operands[1], QImode))
- goto movqi_is_ok;
-
- if (! reload_in_progress)
- {
- operands[0] = validize_mem (operands[0]);
- operands[1] = force_reg (QImode, operands[1]);
- }
- }
-
- /* Fixup PIC cases. */
- if (flag_pic)
- {
- if (CONSTANT_P (operands[1])
- && pic_address_needs_scratch (operands[1]))
- operands[1] = legitimize_pic_address (operands[1], QImode, 0);
-
- if (symbolic_operand (operands[1], QImode))
- {
- operands[1] = legitimize_pic_address (operands[1],
- QImode,
- (reload_in_progress ?
- operands[0] :
- NULL_RTX));
- goto movqi_is_ok;
- }
- }
-
- /* All QI constants require only one insn, so proceed. */
-
- movqi_is_ok:
- ;
-}")
-
-(define_insn "*movqi_insn"
- [(set (match_operand:QI 0 "general_operand" "=r,r,m")
- (match_operand:QI 1 "input_operand" "rI,m,rJ"))]
- "(register_operand (operands[0], QImode)
- || reg_or_0_operand (operands[1], QImode))"
- "@
- mov\\t%1, %0
- ldub\\t%1, %0
- stb\\t%r1, %0"
- [(set_attr "type" "move,load,store")
- (set_attr "length" "1")])
-
-(define_expand "movhi"
- [(set (match_operand:HI 0 "general_operand" "")
- (match_operand:HI 1 "general_operand" ""))]
- ""
- "
-{
- /* Working with CONST_INTs is easier, so convert
- a double if needed. */
- if (GET_CODE (operands[1]) == CONST_DOUBLE)
- operands[1] = GEN_INT (CONST_DOUBLE_LOW (operands[1]));
-
- /* Handle sets of MEM first. */
- if (GET_CODE (operands[0]) == MEM)
- {
- /* This checks TARGET_LIVE_G0 for us. */
- if (reg_or_0_operand (operands[1], HImode))
- goto movhi_is_ok;
-
- if (! reload_in_progress)
- {
- operands[0] = validize_mem (operands[0]);
- operands[1] = force_reg (HImode, operands[1]);
- }
- }
-
- /* Fixup PIC cases. */
- if (flag_pic)
- {
- if (CONSTANT_P (operands[1])
- && pic_address_needs_scratch (operands[1]))
- operands[1] = legitimize_pic_address (operands[1], HImode, 0);
-
- if (symbolic_operand (operands[1], HImode))
- {
- operands[1] = legitimize_pic_address (operands[1],
- HImode,
- (reload_in_progress ?
- operands[0] :
- NULL_RTX));
- goto movhi_is_ok;
- }
- }
-
- /* This makes sure we will not get rematched due to splittage. */
- if (! CONSTANT_P (operands[1]) || input_operand (operands[1], HImode))
- ;
- else if (CONSTANT_P (operands[1])
- && GET_CODE (operands[1]) != HIGH
- && GET_CODE (operands[1]) != LO_SUM)
- {
- sparc_emit_set_const32 (operands[0], operands[1]);
- DONE;
- }
- movhi_is_ok:
- ;
-}")
-
-(define_insn "*movhi_const64_special"
- [(set (match_operand:HI 0 "register_operand" "=r")
- (match_operand:HI 1 "const64_high_operand" ""))]
- "TARGET_ARCH64"
- "sethi\\t%%hi(%a1), %0"
- [(set_attr "type" "move")
- (set_attr "length" "1")])
-
-(define_insn "*movhi_insn"
- [(set (match_operand:HI 0 "general_operand" "=r,r,r,m")
- (match_operand:HI 1 "input_operand" "rI,K,m,rJ"))]
- "(register_operand (operands[0], HImode)
- || reg_or_0_operand (operands[1], HImode))"
- "@
- mov\\t%1, %0
- sethi\\t%%hi(%a1), %0
- lduh\\t%1, %0
- sth\\t%r1, %0"
- [(set_attr "type" "move,move,load,store")
- (set_attr "length" "1")])
-
-;; We always work with constants here.
-(define_insn "*movhi_lo_sum"
- [(set (match_operand:HI 0 "register_operand" "=r")
- (ior:HI (match_operand:HI 1 "arith_operand" "%r")
- (match_operand:HI 2 "arith_operand" "I")))]
- ""
- "or\\t%1, %2, %0"
- [(set_attr "type" "ialu")
- (set_attr "length" "1")])
-
-(define_expand "movsi"
- [(set (match_operand:SI 0 "general_operand" "")
- (match_operand:SI 1 "general_operand" ""))]
- ""
- "
-{
- /* Working with CONST_INTs is easier, so convert
- a double if needed. */
- if (GET_CODE (operands[1]) == CONST_DOUBLE)
- operands[1] = GEN_INT (CONST_DOUBLE_LOW (operands[1]));
-
- /* Handle sets of MEM first. */
- if (GET_CODE (operands[0]) == MEM)
- {
- /* This checks TARGET_LIVE_G0 for us. */
- if (reg_or_0_operand (operands[1], SImode))
- goto movsi_is_ok;
-
- if (! reload_in_progress)
- {
- operands[0] = validize_mem (operands[0]);
- operands[1] = force_reg (SImode, operands[1]);
- }
- }
-
- /* Fixup PIC cases. */
- if (flag_pic)
- {
- if (CONSTANT_P (operands[1])
- && pic_address_needs_scratch (operands[1]))
- operands[1] = legitimize_pic_address (operands[1], SImode, 0);
-
- if (GET_CODE (operands[1]) == LABEL_REF)
- {
- /* shit */
- emit_insn (gen_movsi_pic_label_ref (operands[0], operands[1]));
- DONE;
- }
-
- if (symbolic_operand (operands[1], SImode))
- {
- operands[1] = legitimize_pic_address (operands[1],
- SImode,
- (reload_in_progress ?
- operands[0] :
- NULL_RTX));
- goto movsi_is_ok;
- }
- }
-
- /* If we are trying to toss an integer constant into the
- FPU registers, force it into memory. */
- if (GET_CODE (operands[0]) == REG
- && REGNO (operands[0]) >= SPARC_FIRST_FP_REG
- && REGNO (operands[0]) <= SPARC_LAST_V9_FP_REG
- && CONSTANT_P (operands[1]))
- operands[1] = validize_mem (force_const_mem (GET_MODE (operands[0]),
- operands[1]));
-
- /* This makes sure we will not get rematched due to splittage. */
- if (! CONSTANT_P (operands[1]) || input_operand (operands[1], SImode))
- ;
- else if (CONSTANT_P (operands[1])
- && GET_CODE (operands[1]) != HIGH
- && GET_CODE (operands[1]) != LO_SUM)
- {
- sparc_emit_set_const32 (operands[0], operands[1]);
- DONE;
- }
- movsi_is_ok:
- ;
-}")
-
-;; Special LIVE_G0 pattern to obtain zero in a register.
-(define_insn "*movsi_zero_liveg0"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (match_operand:SI 1 "zero_operand" "J"))]
- "TARGET_LIVE_G0"
- "and\\t%0, 0, %0"
- [(set_attr "type" "binary")
- (set_attr "length" "1")])
-
-;; This is needed to show CSE exactly which bits are set
-;; in a 64-bit register by sethi instructions.
-(define_insn "*movsi_const64_special"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (match_operand:SI 1 "const64_high_operand" ""))]
- "TARGET_ARCH64"
- "sethi\\t%%hi(%a1), %0"
- [(set_attr "type" "move")
- (set_attr "length" "1")])
-
-(define_insn "*movsi_insn"
- [(set (match_operand:SI 0 "general_operand" "=r,f,r,r,r,f,m,m,d")
- (match_operand:SI 1 "input_operand" "rI,!f,K,J,m,!m,rJ,!f,J"))]
- "(register_operand (operands[0], SImode)
- || reg_or_0_operand (operands[1], SImode))"
- "@
- mov\\t%1, %0
- fmovs\\t%1, %0
- sethi\\t%%hi(%a1), %0
- clr\\t%0
- ld\\t%1, %0
- ld\\t%1, %0
- st\\t%r1, %0
- st\\t%1, %0
- fzeros\\t%0"
- [(set_attr "type" "move,fpmove,move,move,load,fpload,store,fpstore,fpmove")
- (set_attr "length" "1")])
-
-(define_insn "*movsi_lo_sum"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
- (match_operand:SI 2 "immediate_operand" "in")))]
- ""
- "or\\t%1, %%lo(%a2), %0"
- [(set_attr "type" "ialu")
- (set_attr "length" "1")])
-
-(define_insn "*movsi_high"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (high:SI (match_operand:SI 1 "immediate_operand" "in")))]
- ""
- "sethi\\t%%hi(%a1), %0"
- [(set_attr "type" "move")
- (set_attr "length" "1")])
-
-;; The next two patterns must wrap the SYMBOL_REF in an UNSPEC
-;; so that CSE won't optimize the address computation away.
-(define_insn "movsi_lo_sum_pic"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
- (unspec:SI [(match_operand:SI 2 "immediate_operand" "in")] 0)))]
- "flag_pic"
- "or\\t%1, %%lo(%a2), %0"
- [(set_attr "type" "ialu")
- (set_attr "length" "1")])
-
-(define_insn "movsi_high_pic"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (high:SI (unspec:SI [(match_operand 1 "" "")] 0)))]
- "flag_pic && check_pic (1)"
- "sethi\\t%%hi(%a1), %0"
- [(set_attr "type" "move")
- (set_attr "length" "1")])
-
-(define_expand "movsi_pic_label_ref"
- [(set (match_dup 3) (high:SI
- (unspec:SI [(match_operand:SI 1 "label_ref_operand" "")
- (match_dup 2)] 5)))
- (set (match_dup 4) (lo_sum:SI (match_dup 3)
- (unspec:SI [(match_dup 1) (match_dup 2)] 5)))
- (set (match_operand:SI 0 "register_operand" "=r")
- (minus:SI (match_dup 5) (match_dup 4)))]
- "flag_pic"
- "
-{
- current_function_uses_pic_offset_table = 1;
- operands[2] = gen_rtx_SYMBOL_REF (Pmode, \"_GLOBAL_OFFSET_TABLE_\");
- operands[3] = gen_reg_rtx (SImode);
- operands[4] = gen_reg_rtx (SImode);
- operands[5] = pic_offset_table_rtx;
-}")
-
-(define_insn "*movsi_high_pic_label_ref"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (high:SI
- (unspec:SI [(match_operand:SI 1 "label_ref_operand" "")
- (match_operand:SI 2 "" "")] 5)))]
- "flag_pic"
- "sethi\\t%%hi(%a2-(%a1-.)), %0"
- [(set_attr "type" "move")
- (set_attr "length" "1")])
-
-(define_insn "*movsi_lo_sum_pic_label_ref"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
- (unspec:SI [(match_operand:SI 2 "label_ref_operand" "")
- (match_operand:SI 3 "" "")] 5)))]
- "flag_pic"
- "or\\t%1, %%lo(%a3-(%a2-.)), %0"
- [(set_attr "type" "ialu")
- (set_attr "length" "1")])
-
-(define_expand "movdi"
- [(set (match_operand:DI 0 "reg_or_nonsymb_mem_operand" "")
- (match_operand:DI 1 "general_operand" ""))]
- ""
- "
-{
- /* Where possible, convert CONST_DOUBLE into a CONST_INT. */
- if (GET_CODE (operands[1]) == CONST_DOUBLE
-#if HOST_BITS_PER_WIDE_INT == 32
- && ((CONST_DOUBLE_HIGH (operands[1]) == 0
- && (CONST_DOUBLE_LOW (operands[1]) & 0x80000000) == 0)
- || (CONST_DOUBLE_HIGH (operands[1]) == (HOST_WIDE_INT) 0xffffffff
- && (CONST_DOUBLE_LOW (operands[1]) & 0x80000000) != 0))
-#endif
- )
- operands[1] = GEN_INT (CONST_DOUBLE_LOW (operands[1]));
-
- /* Handle MEM cases first. */
- if (GET_CODE (operands[0]) == MEM)
- {
- /* If it's a REG, we can always do it.
- The const zero case is more complex, on v9
- we can always perform it. */
- if (register_operand (operands[1], DImode)
- || (TARGET_ARCH64
- && (operands[1] == const0_rtx)))
- goto movdi_is_ok;
-
- if (! reload_in_progress)
- {
- operands[0] = validize_mem (operands[0]);
- operands[1] = force_reg (DImode, operands[1]);
- }
- }
-
- if (flag_pic)
- {
- if (CONSTANT_P (operands[1])
- && pic_address_needs_scratch (operands[1]))
- operands[1] = legitimize_pic_address (operands[1], DImode, 0);
-
- if (GET_CODE (operands[1]) == LABEL_REF)
- {
- if (! TARGET_ARCH64)
- abort ();
- emit_insn (gen_movdi_pic_label_ref (operands[0], operands[1]));
- DONE;
- }
-
- if (symbolic_operand (operands[1], DImode))
- {
- operands[1] = legitimize_pic_address (operands[1],
- DImode,
- (reload_in_progress ?
- operands[0] :
- NULL_RTX));
- goto movdi_is_ok;
- }
- }
-
- /* If we are trying to toss an integer constant into the
- FPU registers, force it into memory. */
- if (GET_CODE (operands[0]) == REG
- && REGNO (operands[0]) >= SPARC_FIRST_FP_REG
- && REGNO (operands[0]) <= SPARC_LAST_V9_FP_REG
- && CONSTANT_P (operands[1]))
- operands[1] = validize_mem (force_const_mem (GET_MODE (operands[0]),
- operands[1]));
-
- /* This makes sure we will not get rematched due to splittage. */
- if (! CONSTANT_P (operands[1]) || input_operand (operands[1], DImode))
- ;
- else if (TARGET_ARCH64
- && CONSTANT_P (operands[1])
- && GET_CODE (operands[1]) != HIGH
- && GET_CODE (operands[1]) != LO_SUM)
- {
- sparc_emit_set_const64 (operands[0], operands[1]);
- DONE;
- }
-
- movdi_is_ok:
- ;
-}")
-
-;; Be careful, fmovd does not exist when !arch64.
-;; We match MEM moves directly when we have correct even
-;; numbered registers, but fall into splits otherwise.
-;; The constraint ordering here is really important to
-;; avoid insane problems in reload, especially for patterns
-;; of the form:
-;;
-;; (set (mem:DI (plus:SI (reg:SI 30 %fp)
-;; (const_int -5016)))
-;; (reg:DI 2 %g2))
-;;
-(define_insn "*movdi_insn_sp32"
- [(set (match_operand:DI 0 "general_operand" "=T,U,o,r,r,r,?T,?f,?f,?o,?f")
- (match_operand:DI 1 "input_operand" "U,T,r,o,i,r,f,T,o,f,f"))]
- "! TARGET_ARCH64 &&
- (register_operand (operands[0], DImode)
- || register_operand (operands[1], DImode))"
- "@
- std\\t%1, %0
- ldd\\t%1, %0
- #
- #
- #
- #
- std\\t%1, %0
- ldd\\t%1, %0
- #
- #
- #"
- [(set_attr "type" "store,load,*,*,*,*,fpstore,fpload,*,*,*")
- (set_attr "length" "1,1,2,2,2,2,1,1,2,2,2")])
-
-;; The following are generated by sparc_emit_set_const64
-(define_insn "*movdi_sp64_dbl"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (match_operand:DI 1 "const64_operand" ""))]
- "(TARGET_ARCH64
- && HOST_BITS_PER_WIDE_INT != 64)"
- "mov\\t%1, %0"
- [(set_attr "type" "move")
- (set_attr "length" "1")])
-
-;; This is needed to show CSE exactly which bits are set
-;; in a 64-bit register by sethi instructions.
-(define_insn "*movdi_const64_special"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (match_operand:DI 1 "const64_high_operand" ""))]
- "TARGET_ARCH64"
- "sethi\\t%%hi(%a1), %0"
- [(set_attr "type" "move")
- (set_attr "length" "1")])
-
-(define_insn "*movdi_insn_sp64"
- [(set (match_operand:DI 0 "general_operand" "=r,r,r,r,m,?e,?e,?m,b")
- (match_operand:DI 1 "input_operand" "rI,K,J,m,rJ,e,m,e,J"))]
- "TARGET_ARCH64 &&
- (register_operand (operands[0], DImode)
- || reg_or_0_operand (operands[1], DImode))"
- "@
- mov\\t%1, %0
- sethi\\t%%hi(%a1), %0
- clr\\t%0
- ldx\\t%1, %0
- stx\\t%r1, %0
- fmovd\\t%1, %0
- ldd\\t%1, %0
- std\\t%1, %0
- fzero\\t%0"
- [(set_attr "type" "move,move,move,load,store,fpmove,fpload,fpstore,fpmove")
- (set_attr "length" "1")])
-
-(define_expand "movdi_pic_label_ref"
- [(set (match_dup 3) (high:DI
- (unspec:DI [(match_operand:DI 1 "label_ref_operand" "")
- (match_dup 2)] 5)))
- (set (match_dup 4) (lo_sum:DI (match_dup 3)
- (unspec:DI [(match_dup 1) (match_dup 2)] 5)))
- (set (match_operand:DI 0 "register_operand" "=r")
- (minus:DI (match_dup 5) (match_dup 4)))]
- "TARGET_ARCH64 && flag_pic"
- "
-{
- current_function_uses_pic_offset_table = 1;
- operands[2] = gen_rtx_SYMBOL_REF (Pmode, \"_GLOBAL_OFFSET_TABLE_\");
- operands[3] = gen_reg_rtx (DImode);
- operands[4] = gen_reg_rtx (DImode);
- operands[5] = pic_offset_table_rtx;
-}")
-
-(define_insn "*movdi_high_pic_label_ref"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (high:DI
- (unspec:DI [(match_operand:DI 1 "label_ref_operand" "")
- (match_operand:DI 2 "" "")] 5)))]
- "TARGET_ARCH64 && flag_pic"
- "sethi\\t%%hi(%a2-(%a1-.)), %0"
- [(set_attr "type" "move")
- (set_attr "length" "1")])
-
-(define_insn "*movdi_lo_sum_pic_label_ref"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (lo_sum:DI (match_operand:DI 1 "register_operand" "r")
- (unspec:DI [(match_operand:DI 2 "label_ref_operand" "")
- (match_operand:DI 3 "" "")] 5)))]
- "TARGET_ARCH64 && flag_pic"
- "or\\t%1, %%lo(%a3-(%a2-.)), %0"
- [(set_attr "type" "ialu")
- (set_attr "length" "1")])
-
-;; Sparc-v9 code model support insns. See sparc_emit_set_symbolic_const64
-;; in sparc.c to see what is going on here... PIC stuff comes first.
-
-(define_insn "movdi_lo_sum_pic"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (lo_sum:DI (match_operand:DI 1 "register_operand" "r")
- (unspec:DI [(match_operand:DI 2 "immediate_operand" "in")] 0)))]
- "TARGET_ARCH64 && flag_pic"
- "or\\t%1, %%lo(%a2), %0"
- [(set_attr "type" "ialu")
- (set_attr "length" "1")])
-
-(define_insn "movdi_high_pic"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (high:DI (unspec:DI [(match_operand 1 "" "")] 0)))]
- "TARGET_ARCH64 && flag_pic && check_pic (1)"
- "sethi\\t%%hi(%a1), %0"
- [(set_attr "type" "move")
- (set_attr "length" "1")])
-
-(define_insn "*sethi_di_medlow_embmedany_pic"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (high:DI (match_operand:DI 1 "sp64_medium_pic_operand" "")))]
- "(TARGET_CM_MEDLOW || TARGET_CM_EMBMEDANY) && check_pic (1)"
- "sethi\\t%%lo(%a1), %0"
- [(set_attr "type" "move")
- (set_attr "length" "1")])
-
-(define_insn "*sethi_di_medlow"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (high:DI (match_operand:DI 1 "symbolic_operand" "")))]
- "TARGET_CM_MEDLOW && check_pic (1)"
- "sethi\\t%%hi(%a1), %0"
- [(set_attr "type" "move")
- (set_attr "length" "1")])
-
-(define_insn "*losum_di_medlow"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (lo_sum:DI (match_operand:DI 1 "register_operand" "r")
- (match_operand:DI 2 "symbolic_operand" "")))]
- "TARGET_CM_MEDLOW"
- "or\\t%1, %%lo(%a2), %0"
- [(set_attr "type" "ialu")
- (set_attr "length" "1")])
-
-(define_insn "seth44"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (high:DI (unspec:DI [(match_operand:DI 1 "symbolic_operand" "")] 6)))]
- "TARGET_CM_MEDMID"
- "sethi\\t%%h44(%a1), %0"
- [(set_attr "type" "move")
- (set_attr "length" "1")])
-
-(define_insn "setm44"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (lo_sum:DI (match_operand:DI 1 "register_operand" "r")
- (unspec:DI [(match_operand:DI 2 "symbolic_operand" "")] 7)))]
- "TARGET_CM_MEDMID"
- "or\\t%1, %%m44(%a2), %0"
- [(set_attr "type" "move")
- (set_attr "length" "1")])
-
-(define_insn "setl44"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (lo_sum:DI (match_operand:DI 1 "register_operand" "r")
- (match_operand:DI 2 "symbolic_operand" "")))]
- "TARGET_CM_MEDMID"
- "or\\t%1, %%l44(%a2), %0"
- [(set_attr "type" "ialu")
- (set_attr "length" "1")])
-
-(define_insn "sethh"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (high:DI (unspec:DI [(match_operand:DI 1 "symbolic_operand" "")] 9)))]
- "TARGET_CM_MEDANY"
- "sethi\\t%%hh(%a1), %0"
- [(set_attr "type" "move")
- (set_attr "length" "1")])
-
-(define_insn "setlm"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (high:DI (unspec:DI [(match_operand:DI 1 "symbolic_operand" "")] 10)))]
- "TARGET_CM_MEDANY"
- "sethi\\t%%lm(%a1), %0"
- [(set_attr "type" "move")
- (set_attr "length" "1")])
-
-(define_insn "sethm"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (lo_sum:DI (match_operand:DI 1 "register_operand" "r")
- (unspec:DI [(match_operand:DI 2 "symbolic_operand" "")] 18)))]
- "TARGET_CM_MEDANY"
- "or\\t%1, %%hm(%a2), %0"
- [(set_attr "type" "ialu")
- (set_attr "length" "1")])
-
-(define_insn "setlo"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (lo_sum:DI (match_operand:DI 1 "register_operand" "r")
- (match_operand:DI 2 "symbolic_operand" "")))]
- "TARGET_CM_MEDANY"
- "or\\t%1, %%lo(%a2), %0"
- [(set_attr "type" "ialu")
- (set_attr "length" "1")])
-
-(define_insn "embmedany_sethi"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (high:DI (unspec:DI [(match_operand:DI 1 "data_segment_operand" "")] 11)))]
- "TARGET_CM_EMBMEDANY && check_pic (1)"
- "sethi\\t%%hi(%a1), %0"
- [(set_attr "type" "move")
- (set_attr "length" "1")])
-
-(define_insn "embmedany_losum"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (lo_sum:DI (match_operand:DI 1 "register_operand" "r")
- (match_operand:DI 2 "data_segment_operand" "")))]
- "TARGET_CM_EMBMEDANY"
- "add\\t%1, %%lo(%a2), %0"
- [(set_attr "type" "ialu")
- (set_attr "length" "1")])
-
-(define_insn "embmedany_brsum"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (unspec:DI [(match_operand:DI 1 "register_operand" "r")] 11))]
- "TARGET_CM_EMBMEDANY"
- "add\\t%1, %_, %0"
- [(set_attr "length" "1")])
-
-(define_insn "embmedany_textuhi"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (high:DI (unspec:DI [(match_operand:DI 1 "text_segment_operand" "")] 13)))]
- "TARGET_CM_EMBMEDANY && check_pic (1)"
- "sethi\\t%%uhi(%a1), %0"
- [(set_attr "type" "move")
- (set_attr "length" "1")])
-
-(define_insn "embmedany_texthi"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (high:DI (unspec:DI [(match_operand:DI 1 "text_segment_operand" "")] 14)))]
- "TARGET_CM_EMBMEDANY && check_pic (1)"
- "sethi\\t%%hi(%a1), %0"
- [(set_attr "type" "move")
- (set_attr "length" "1")])
-
-(define_insn "embmedany_textulo"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (lo_sum:DI (match_operand:DI 1 "register_operand" "r")
- (unspec:DI [(match_operand:DI 2 "text_segment_operand" "")] 15)))]
- "TARGET_CM_EMBMEDANY"
- "or\\t%1, %%ulo(%a2), %0"
- [(set_attr "type" "ialu")
- (set_attr "length" "1")])
-
-(define_insn "embmedany_textlo"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (lo_sum:DI (match_operand:DI 1 "register_operand" "r")
- (match_operand:DI 2 "text_segment_operand" "")))]
- "TARGET_CM_EMBMEDANY"
- "or\\t%1, %%lo(%a2), %0"
- [(set_attr "type" "ialu")
- (set_attr "length" "1")])
-
-;; Now some patterns to help reload out a bit.
-(define_expand "reload_indi"
- [(parallel [(match_operand:DI 0 "register_operand" "=r")
- (match_operand:DI 1 "immediate_operand" "")
- (match_operand:TI 2 "register_operand" "=&r")])]
- "(TARGET_CM_MEDANY
- || TARGET_CM_EMBMEDANY)
- && ! flag_pic"
- "
-{
- sparc_emit_set_symbolic_const64 (operands[0], operands[1],
- gen_rtx_REG (DImode, REGNO (operands[2])));
- DONE;
-}")
-
-(define_expand "reload_outdi"
- [(parallel [(match_operand:DI 0 "register_operand" "=r")
- (match_operand:DI 1 "immediate_operand" "")
- (match_operand:TI 2 "register_operand" "=&r")])]
- "(TARGET_CM_MEDANY
- || TARGET_CM_EMBMEDANY)
- && ! flag_pic"
- "
-{
- sparc_emit_set_symbolic_const64 (operands[0], operands[1],
- gen_rtx_REG (DImode, REGNO (operands[2])));
- DONE;
-}")
-
-;; Split up putting CONSTs and REGs into DI regs when !arch64
-(define_split
- [(set (match_operand:DI 0 "register_operand" "")
- (match_operand:DI 1 "const_int_operand" ""))]
- "! TARGET_ARCH64 && reload_completed"
- [(clobber (const_int 0))]
- "
-{
- emit_insn (gen_movsi (gen_highpart (SImode, operands[0]),
- (INTVAL (operands[1]) < 0) ?
- constm1_rtx :
- const0_rtx));
- emit_insn (gen_movsi (gen_lowpart (SImode, operands[0]),
- operands[1]));
- DONE;
-}")
-
-(define_split
- [(set (match_operand:DI 0 "register_operand" "")
- (match_operand:DI 1 "const_double_operand" ""))]
- "! TARGET_ARCH64 && reload_completed"
- [(clobber (const_int 0))]
- "
-{
- emit_insn (gen_movsi (gen_highpart (SImode, operands[0]),
- GEN_INT (CONST_DOUBLE_HIGH (operands[1]))));
-
- /* Slick... but this trick loses if this subreg constant part
- can be done in one insn. */
- if (CONST_DOUBLE_LOW (operands[1]) == CONST_DOUBLE_HIGH (operands[1])
- && !(SPARC_SETHI_P (CONST_DOUBLE_HIGH (operands[1]))
- || SPARC_SIMM13_P (CONST_DOUBLE_HIGH (operands[1]))))
- {
- emit_insn (gen_movsi (gen_lowpart (SImode, operands[0]),
- gen_highpart (SImode, operands[0])));
- }
- else
- {
- emit_insn (gen_movsi (gen_lowpart (SImode, operands[0]),
- GEN_INT (CONST_DOUBLE_LOW (operands[1]))));
- }
- DONE;
-}")
-
-(define_split
- [(set (match_operand:DI 0 "register_operand" "")
- (match_operand:DI 1 "register_operand" ""))]
- "! TARGET_ARCH64 && reload_completed"
- [(clobber (const_int 0))]
- "
-{
- rtx set_dest = operands[0];
- rtx set_src = operands[1];
- rtx dest1, dest2;
- rtx src1, src2;
-
- if (GET_CODE (set_dest) == SUBREG)
- set_dest = alter_subreg (set_dest);
- if (GET_CODE (set_src) == SUBREG)
- set_src = alter_subreg (set_src);
-
- dest1 = gen_highpart (SImode, set_dest);
- dest2 = gen_lowpart (SImode, set_dest);
- src1 = gen_highpart (SImode, set_src);
- src2 = gen_lowpart (SImode, set_src);
-
- /* Now emit using the real source and destination we found, swapping
- the order if we detect overlap. */
- if (reg_overlap_mentioned_p (dest1, src2))
- {
- emit_insn (gen_movsi (dest2, src2));
- emit_insn (gen_movsi (dest1, src1));
- }
- else
- {
- emit_insn (gen_movsi (dest1, src1));
- emit_insn (gen_movsi (dest2, src2));
- }
- DONE;
-}")
-
-;; Now handle the cases of memory moves from/to non-even
-;; DI mode register pairs.
-(define_split
- [(set (match_operand:DI 0 "register_operand" "")
- (match_operand:DI 1 "memory_operand" ""))]
- "(! TARGET_ARCH64
- && reload_completed
- && sparc_splitdi_legitimate (operands[0], operands[1]))"
- [(clobber (const_int 0))]
- "
-{
- rtx word0 = change_address (operands[1], SImode, NULL_RTX);
- rtx word1 = change_address (operands[1], SImode,
- plus_constant_for_output (XEXP (word0, 0), 4));
- rtx high_part = gen_highpart (SImode, operands[0]);
- rtx low_part = gen_lowpart (SImode, operands[0]);
-
- if (reg_overlap_mentioned_p (high_part, word1))
- {
- emit_insn (gen_movsi (low_part, word1));
- emit_insn (gen_movsi (high_part, word0));
- }
- else
- {
- emit_insn (gen_movsi (high_part, word0));
- emit_insn (gen_movsi (low_part, word1));
- }
- DONE;
-}")
-
-(define_split
- [(set (match_operand:DI 0 "memory_operand" "")
- (match_operand:DI 1 "register_operand" ""))]
- "(! TARGET_ARCH64
- && reload_completed
- && sparc_splitdi_legitimate (operands[1], operands[0]))"
- [(clobber (const_int 0))]
- "
-{
- rtx word0 = change_address (operands[0], SImode, NULL_RTX);
- rtx word1 = change_address (operands[0], SImode,
- plus_constant_for_output (XEXP (word0, 0), 4));
- rtx high_part = gen_highpart (SImode, operands[1]);
- rtx low_part = gen_lowpart (SImode, operands[1]);
-
- emit_insn (gen_movsi (word0, high_part));
- emit_insn (gen_movsi (word1, low_part));
- DONE;
-}")
-
-
-;; Floating point move insns
-
-(define_insn "*clear_sf"
- [(set (match_operand:SF 0 "general_operand" "=f")
- (match_operand:SF 1 "" ""))]
- "TARGET_VIS
- && GET_CODE (operands[1]) == CONST_DOUBLE
- && GET_CODE (operands[0]) == REG
- && fp_zero_operand (operands[1])"
- "fzeros\\t%0"
- [(set_attr "type" "fpmove")
- (set_attr "length" "1")])
-
-(define_insn "*movsf_const_intreg"
- [(set (match_operand:SF 0 "general_operand" "=f,r")
- (match_operand:SF 1 "" "m,F"))]
- "TARGET_FPU
- && GET_CODE (operands[1]) == CONST_DOUBLE
- && GET_CODE (operands[0]) == REG"
- "*
-{
- REAL_VALUE_TYPE r;
- long i;
-
- if (which_alternative == 0)
- return \"ld\\t%1, %0\";
-
- REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
- REAL_VALUE_TO_TARGET_SINGLE (r, i);
- if (SPARC_SIMM13_P (i) || SPARC_SETHI_P (i))
- {
- operands[1] = GEN_INT (i);
- if (SPARC_SIMM13_P (INTVAL (operands[1])))
- return \"mov\\t%1, %0\";
- else if (SPARC_SETHI_P (INTVAL (operands[1])))
- return \"sethi\\t%%hi(%a1), %0\";
- else
- abort ();
- }
- else
- return \"#\";
-}"
- [(set_attr "type" "move")
- (set_attr "length" "1,2")])
-
-;; There isn't much I can do about this, if I change the
-;; mode then flow info gets really confused because the
-;; destination no longer looks the same. Ho hum...
-(define_insn "*movsf_const_high"
- [(set (match_operand:SF 0 "register_operand" "=r")
- (unspec:SF [(match_operand 1 "const_int_operand" "")] 12))]
- ""
- "sethi\\t%%hi(%a1), %0"
- [(set_attr "type" "move")
- (set_attr "length" "1")])
-
-(define_insn "*movsf_const_lo"
- [(set (match_operand:SF 0 "register_operand" "=r")
- (unspec:SF [(match_operand 1 "register_operand" "r")
- (match_operand 2 "const_int_operand" "")] 17))]
- ""
- "or\\t%1, %%lo(%a2), %0"
- [(set_attr "type" "move")
- (set_attr "length" "1")])
-
-(define_split
- [(set (match_operand:SF 0 "register_operand" "")
- (match_operand:SF 1 "const_double_operand" ""))]
- "TARGET_FPU
- && (GET_CODE (operands[0]) == REG
- && REGNO (operands[0]) < 32)"
- [(set (match_dup 0) (unspec:SF [(match_dup 1)] 12))
- (set (match_dup 0) (unspec:SF [(match_dup 0) (match_dup 1)] 17))]
- "
-{
- REAL_VALUE_TYPE r;
- long i;
-
- REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
- REAL_VALUE_TO_TARGET_SINGLE (r, i);
- operands[1] = GEN_INT (i);
-}")
-
-(define_expand "movsf"
- [(set (match_operand:SF 0 "general_operand" "")
- (match_operand:SF 1 "general_operand" ""))]
- ""
- "
-{
- /* Force SFmode constants into memory. */
- if (GET_CODE (operands[0]) == REG
- && CONSTANT_P (operands[1]))
- {
- if (TARGET_VIS
- && GET_CODE (operands[1]) == CONST_DOUBLE
- && fp_zero_operand (operands[1]))
- goto movsf_is_ok;
-
- /* emit_group_store will send such bogosity to us when it is
- not storing directly into memory. So fix this up to avoid
- crashes in output_constant_pool. */
- if (operands [1] == const0_rtx)
- operands[1] = CONST0_RTX (SFmode);
- operands[1] = validize_mem (force_const_mem (GET_MODE (operands[0]),
- operands[1]));
- }
-
- /* Handle sets of MEM first. */
- if (GET_CODE (operands[0]) == MEM)
- {
- if (register_operand (operands[1], SFmode))
- goto movsf_is_ok;
-
- if (! reload_in_progress)
- {
- operands[0] = validize_mem (operands[0]);
- operands[1] = force_reg (SFmode, operands[1]);
- }
- }
-
- /* Fixup PIC cases. */
- if (flag_pic)
- {
- if (CONSTANT_P (operands[1])
- && pic_address_needs_scratch (operands[1]))
- operands[1] = legitimize_pic_address (operands[1], SFmode, 0);
-
- if (symbolic_operand (operands[1], SFmode))
- {
- operands[1] = legitimize_pic_address (operands[1],
- SFmode,
- (reload_in_progress ?
- operands[0] :
- NULL_RTX));
- }
- }
-
- movsf_is_ok:
- ;
-}")
-
-(define_insn "*movsf_insn"
- [(set (match_operand:SF 0 "general_operand" "=f,f,m,r,r,m")
- (match_operand:SF 1 "input_operand" "f,m,f,r,m,r"))]
- "TARGET_FPU
- && (register_operand (operands[0], SFmode)
- || register_operand (operands[1], SFmode))"
- "@
- fmovs\\t%1, %0
- ld\\t%1, %0
- st\\t%1, %0
- mov\\t%1, %0
- ld\\t%1, %0
- st\\t%1, %0"
- [(set_attr "type" "fpmove,fpload,fpstore,move,load,store")
- (set_attr "length" "1")])
-
-;; Exactly the same as above, except that all `f' cases are deleted.
-;; This is necessary to prevent reload from ever trying to use a `f' reg
-;; when -mno-fpu.
-
-(define_insn "*movsf_no_f_insn"
- [(set (match_operand:SF 0 "general_operand" "=r,r,m")
- (match_operand:SF 1 "input_operand" "r,m,r"))]
- "! TARGET_FPU
- && (register_operand (operands[0], SFmode)
- || register_operand (operands[1], SFmode))"
- "@
- mov\\t%1, %0
- ld\\t%1, %0
- st\\t%1, %0"
- [(set_attr "type" "move,load,store")
- (set_attr "length" "1")])
-
-(define_insn "*clear_df"
- [(set (match_operand:DF 0 "general_operand" "=e")
- (match_operand:DF 1 "" ""))]
- "TARGET_VIS
- && GET_CODE (operands[1]) == CONST_DOUBLE
- && GET_CODE (operands[0]) == REG
- && fp_zero_operand (operands[1])"
- "fzero\\t%0"
- [(set_attr "type" "fpmove")
- (set_attr "length" "1")])
-
-(define_insn "*movdf_const_intreg_sp32"
- [(set (match_operand:DF 0 "general_operand" "=e,e,r")
- (match_operand:DF 1 "" "T,o,F"))]
- "TARGET_FPU && ! TARGET_ARCH64
- && GET_CODE (operands[1]) == CONST_DOUBLE
- && GET_CODE (operands[0]) == REG"
- "*
-{
- if (which_alternative == 0)
- return \"ldd\\t%1, %0\";
- else
- return \"#\";
-}"
- [(set_attr "type" "move")
- (set_attr "length" "1,2,2")])
-
-;; Now that we redo life analysis with a clean slate after
-;; instruction splitting for sched2 this can work.
-(define_insn "*movdf_const_intreg_sp64"
- [(set (match_operand:DF 0 "general_operand" "=e,e,r")
- (match_operand:DF 1 "" "m,o,F"))]
- "TARGET_FPU
- && TARGET_ARCH64
- && GET_CODE (operands[1]) == CONST_DOUBLE
- && GET_CODE (operands[0]) == REG"
- "*
-{
- if (which_alternative == 0)
- return \"ldd\\t%1, %0\";
- else
- return \"#\";
-}"
- [(set_attr "type" "move")
- (set_attr "length" "1,2,2")])
-
-(define_split
- [(set (match_operand:DF 0 "register_operand" "")
- (match_operand:DF 1 "const_double_operand" ""))]
- "TARGET_FPU
- && GET_CODE (operands[1]) == CONST_DOUBLE
- && (GET_CODE (operands[0]) == REG
- && REGNO (operands[0]) < 32)
- && reload_completed"
- [(clobber (const_int 0))]
- "
-{
- REAL_VALUE_TYPE r;
- long l[2];
-
- REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
- REAL_VALUE_TO_TARGET_DOUBLE (r, l);
- if (GET_CODE (operands[0]) == SUBREG)
- operands[0] = alter_subreg (operands[0]);
- operands[0] = gen_rtx_raw_REG (DImode, REGNO (operands[0]));
-
- if (TARGET_ARCH64)
- {
-#if HOST_BITS_PER_WIDE_INT == 64
- HOST_WIDE_INT val;
-
- val = ((HOST_WIDE_INT)l[1] |
- ((HOST_WIDE_INT)l[0] << 32));
- emit_insn (gen_movdi (operands[0], GEN_INT (val)));
-#else
- emit_insn (gen_movdi (operands[0],
- gen_rtx_CONST_DOUBLE (VOIDmode, const0_rtx,
- l[1], l[0])));
-#endif
- }
- else
- {
- emit_insn (gen_movsi (gen_highpart (SImode, operands[0]),
- GEN_INT (l[0])));
-
- /* Slick... but this trick loses if this subreg constant part
- can be done in one insn. */
- if (l[1] == l[0]
- && !(SPARC_SETHI_P (l[0])
- || SPARC_SIMM13_P (l[0])))
- {
- emit_insn (gen_movsi (gen_lowpart (SImode, operands[0]),
- gen_highpart (SImode, operands[0])));
- }
- else
- {
- emit_insn (gen_movsi (gen_lowpart (SImode, operands[0]),
- GEN_INT (l[1])));
- }
- }
- DONE;
-}")
-
-(define_expand "movdf"
- [(set (match_operand:DF 0 "general_operand" "")
- (match_operand:DF 1 "general_operand" ""))]
- ""
- "
-{
- /* Force DFmode constants into memory. */
- if (GET_CODE (operands[0]) == REG
- && CONSTANT_P (operands[1]))
- {
- if (TARGET_VIS
- && GET_CODE (operands[1]) == CONST_DOUBLE
- && fp_zero_operand (operands[1]))
- goto movdf_is_ok;
-
- /* emit_group_store will send such bogosity to us when it is
- not storing directly into memory. So fix this up to avoid
- crashes in output_constant_pool. */
- if (operands [1] == const0_rtx)
- operands[1] = CONST0_RTX (DFmode);
- operands[1] = validize_mem (force_const_mem (GET_MODE (operands[0]),
- operands[1]));
- }
-
- /* Handle MEM cases first. */
- if (GET_CODE (operands[0]) == MEM)
- {
- if (register_operand (operands[1], DFmode))
- goto movdf_is_ok;
-
- if (! reload_in_progress)
- {
- operands[0] = validize_mem (operands[0]);
- operands[1] = force_reg (DFmode, operands[1]);
- }
- }
-
- /* Fixup PIC cases. */
- if (flag_pic)
- {
- if (CONSTANT_P (operands[1])
- && pic_address_needs_scratch (operands[1]))
- operands[1] = legitimize_pic_address (operands[1], DFmode, 0);
-
- if (symbolic_operand (operands[1], DFmode))
- {
- operands[1] = legitimize_pic_address (operands[1],
- DFmode,
- (reload_in_progress ?
- operands[0] :
- NULL_RTX));
- }
- }
-
- movdf_is_ok:
- ;
-}")
-
-;; Be careful, fmovd does not exist when !v9.
-(define_insn "*movdf_insn_sp32"
- [(set (match_operand:DF 0 "general_operand" "=e,T,U,T,e,r,r,o,e,o")
- (match_operand:DF 1 "input_operand" "T,e,T,U,e,r,o,r,o,e"))]
- "TARGET_FPU
- && ! TARGET_V9
- && (register_operand (operands[0], DFmode)
- || register_operand (operands[1], DFmode))"
- "@
- ldd\\t%1, %0
- std\\t%1, %0
- ldd\\t%1, %0
- std\\t%1, %0
- #
- #
- #
- #
- #
- #"
- [(set_attr "type" "fpload,fpstore,load,store,*,*,*,*,*,*")
- (set_attr "length" "1,1,1,1,2,2,2,2,2,2")])
-
-(define_insn "*movdf_no_e_insn_sp32"
- [(set (match_operand:DF 0 "general_operand" "=U,T,r,r,o")
- (match_operand:DF 1 "input_operand" "T,U,r,o,r"))]
- "! TARGET_FPU
- && ! TARGET_ARCH64
- && (register_operand (operands[0], DFmode)
- || register_operand (operands[1], DFmode))"
- "@
- ldd\\t%1, %0
- std\\t%1, %0
- #
- #
- #"
- [(set_attr "type" "load,store,*,*,*")
- (set_attr "length" "1,1,2,2,2")])
-
-;; We have available v9 double floats but not 64-bit
-;; integer registers.
-(define_insn "*movdf_insn_v9only"
- [(set (match_operand:DF 0 "general_operand" "=e,e,m,U,T,r,r,o")
- (match_operand:DF 1 "input_operand" "e,m,e,T,U,r,o,r"))]
- "TARGET_FPU
- && TARGET_V9
- && ! TARGET_ARCH64
- && (register_operand (operands[0], DFmode)
- || register_operand (operands[1], DFmode))"
- "@
- fmovd\\t%1, %0
- ldd\\t%1, %0
- std\\t%1, %0
- ldd\\t%1, %0
- std\\t%1, %0
- #
- #
- #"
- [(set_attr "type" "fpmove,load,store,load,store,*,*,*")
- (set_attr "length" "1,1,1,1,1,2,2,2")])
-
-;; We have available both v9 double floats and 64-bit
-;; integer registers.
-(define_insn "*movdf_insn_sp64"
- [(set (match_operand:DF 0 "general_operand" "=e,e,m,r,r,m")
- (match_operand:DF 1 "input_operand" "e,m,e,r,m,r"))]
- "TARGET_FPU
- && TARGET_V9
- && TARGET_ARCH64
- && (register_operand (operands[0], DFmode)
- || register_operand (operands[1], DFmode))"
- "@
- fmovd\\t%1, %0
- ldd\\t%1, %0
- std\\t%1, %0
- mov\\t%1, %0
- ldx\\t%1, %0
- stx\\t%1, %0"
- [(set_attr "type" "fpmove,load,store,move,load,store")
- (set_attr "length" "1")])
-
-(define_insn "*movdf_no_e_insn_sp64"
- [(set (match_operand:DF 0 "general_operand" "=r,r,m")
- (match_operand:DF 1 "input_operand" "r,m,r"))]
- "! TARGET_FPU
- && TARGET_ARCH64
- && (register_operand (operands[0], DFmode)
- || register_operand (operands[1], DFmode))"
- "@
- mov\\t%1, %0
- ldx\\t%1, %0
- stx\\t%1, %0"
- [(set_attr "type" "move,load,store")
- (set_attr "length" "1")])
-
-;; Ok, now the splits to handle all the multi insn and
-;; mis-aligned memory address cases.
-;; In these splits please take note that we must be
-;; careful when V9 but not ARCH64 because the integer
-;; register DFmode cases must be handled.
-(define_split
- [(set (match_operand:DF 0 "register_operand" "")
- (match_operand:DF 1 "register_operand" ""))]
- "(! TARGET_V9
- || (! TARGET_ARCH64
- && ((GET_CODE (operands[0]) == REG
- && REGNO (operands[0]) < 32)
- || (GET_CODE (operands[0]) == SUBREG
- && GET_CODE (SUBREG_REG (operands[0])) == REG
- && REGNO (SUBREG_REG (operands[0])) < 32))))
- && reload_completed"
- [(clobber (const_int 0))]
- "
-{
- rtx set_dest = operands[0];
- rtx set_src = operands[1];
- rtx dest1, dest2;
- rtx src1, src2;
-
- if (GET_CODE (set_dest) == SUBREG)
- set_dest = alter_subreg (set_dest);
- if (GET_CODE (set_src) == SUBREG)
- set_src = alter_subreg (set_src);
-
- dest1 = gen_highpart (SFmode, set_dest);
- dest2 = gen_lowpart (SFmode, set_dest);
- src1 = gen_highpart (SFmode, set_src);
- src2 = gen_lowpart (SFmode, set_src);
-
- /* Now emit using the real source and destination we found, swapping
- the order if we detect overlap. */
- if (reg_overlap_mentioned_p (dest1, src2))
- {
- emit_insn (gen_movsf (dest2, src2));
- emit_insn (gen_movsf (dest1, src1));
- }
- else
- {
- emit_insn (gen_movsf (dest1, src1));
- emit_insn (gen_movsf (dest2, src2));
- }
- DONE;
-}")
-
-(define_split
- [(set (match_operand:DF 0 "register_operand" "")
- (match_operand:DF 1 "memory_operand" ""))]
- "((! TARGET_V9
- || (! TARGET_ARCH64
- && ((GET_CODE (operands[0]) == REG
- && REGNO (operands[0]) < 32)
- || (GET_CODE (operands[0]) == SUBREG
- && GET_CODE (SUBREG_REG (operands[0])) == REG
- && REGNO (SUBREG_REG (operands[0])) < 32))))
- && (reload_completed
- && (((REGNO (operands[0])) % 2) != 0
- || ! mem_min_alignment (operands[1], 8))
- && offsettable_memref_p (operands[1])))"
- [(clobber (const_int 0))]
- "
-{
- rtx word0 = change_address (operands[1], SFmode, NULL_RTX);
- rtx word1 = change_address (operands[1], SFmode,
- plus_constant_for_output (XEXP (word0, 0), 4));
-
- if (GET_CODE (operands[0]) == SUBREG)
- operands[0] = alter_subreg (operands[0]);
-
- if (reg_overlap_mentioned_p (gen_highpart (SFmode, operands[0]), word1))
- {
- emit_insn (gen_movsf (gen_lowpart (SFmode, operands[0]),
- word1));
- emit_insn (gen_movsf (gen_highpart (SFmode, operands[0]),
- word0));
- }
- else
- {
- emit_insn (gen_movsf (gen_highpart (SFmode, operands[0]),
- word0));
- emit_insn (gen_movsf (gen_lowpart (SFmode, operands[0]),
- word1));
- }
- DONE;
-}")
-
-(define_split
- [(set (match_operand:DF 0 "memory_operand" "")
- (match_operand:DF 1 "register_operand" ""))]
- "((! TARGET_V9
- || (! TARGET_ARCH64
- && ((GET_CODE (operands[1]) == REG
- && REGNO (operands[1]) < 32)
- || (GET_CODE (operands[1]) == SUBREG
- && GET_CODE (SUBREG_REG (operands[1])) == REG
- && REGNO (SUBREG_REG (operands[1])) < 32))))
- && (reload_completed
- && (((REGNO (operands[1])) % 2) != 0
- || ! mem_min_alignment (operands[0], 8))
- && offsettable_memref_p (operands[0])))"
- [(clobber (const_int 0))]
- "
-{
- rtx word0 = change_address (operands[0], SFmode, NULL_RTX);
- rtx word1 = change_address (operands[0], SFmode,
- plus_constant_for_output (XEXP (word0, 0), 4));
-
- if (GET_CODE (operands[1]) == SUBREG)
- operands[1] = alter_subreg (operands[1]);
- emit_insn (gen_movsf (word0,
- gen_highpart (SFmode, operands[1])));
- emit_insn (gen_movsf (word1,
- gen_lowpart (SFmode, operands[1])));
- DONE;
-}")
-
-(define_expand "movtf"
- [(set (match_operand:TF 0 "general_operand" "")
- (match_operand:TF 1 "general_operand" ""))]
- ""
- "
-{
- /* Force TFmode constants into memory. */
- if (GET_CODE (operands[0]) == REG
- && CONSTANT_P (operands[1]))
- {
- /* emit_group_store will send such bogosity to us when it is
- not storing directly into memory. So fix this up to avoid
- crashes in output_constant_pool. */
- if (operands [1] == const0_rtx)
- operands[1] = CONST0_RTX (TFmode);
- operands[1] = validize_mem (force_const_mem (GET_MODE (operands[0]),
- operands[1]));
- }
-
- /* Handle MEM cases first, note that only v9 guarentees
- full 16-byte alignment for quads. */
- if (GET_CODE (operands[0]) == MEM)
- {
- if (register_operand (operands[1], TFmode))
- goto movtf_is_ok;
-
- if (! reload_in_progress)
- {
- operands[0] = validize_mem (operands[0]);
- operands[1] = force_reg (TFmode, operands[1]);
- }
- }
-
- /* Fixup PIC cases. */
- if (flag_pic)
- {
- if (CONSTANT_P (operands[1])
- && pic_address_needs_scratch (operands[1]))
- operands[1] = legitimize_pic_address (operands[1], TFmode, 0);
-
- if (symbolic_operand (operands[1], TFmode))
- {
- operands[1] = legitimize_pic_address (operands[1],
- TFmode,
- (reload_in_progress ?
- operands[0] :
- NULL_RTX));
- }
- }
-
- movtf_is_ok:
- ;
-}")
-
-;; Be careful, fmovq and {st,ld}{x,q} do not exist when !arch64 so
-;; we must split them all. :-(
-(define_insn "*movtf_insn_sp32"
- [(set (match_operand:TF 0 "general_operand" "=e,o,U,o,e,r,r,o")
- (match_operand:TF 1 "input_operand" "o,e,o,U,e,r,o,r"))]
- "TARGET_FPU
- && ! TARGET_ARCH64
- && (register_operand (operands[0], TFmode)
- || register_operand (operands[1], TFmode))"
- "#"
- [(set_attr "length" "4")])
-
-;; Exactly the same as above, except that all `e' cases are deleted.
-;; This is necessary to prevent reload from ever trying to use a `e' reg
-;; when -mno-fpu.
-
-(define_insn "*movtf_no_e_insn_sp32"
- [(set (match_operand:TF 0 "general_operand" "=U,o,r,r,o")
- (match_operand:TF 1 "input_operand" "o,U,r,o,r"))]
- "! TARGET_FPU
- && ! TARGET_ARCH64
- && (register_operand (operands[0], TFmode)
- || register_operand (operands[1], TFmode))"
- "#"
- [(set_attr "length" "4")])
-
-;; Now handle the float reg cases directly when arch64,
-;; hard_quad, and proper reg number alignment are all true.
-(define_insn "*movtf_insn_hq_sp64"
- [(set (match_operand:TF 0 "general_operand" "=e,e,m,r,r,o")
- (match_operand:TF 1 "input_operand" "e,m,e,r,o,r"))]
- "TARGET_FPU
- && TARGET_ARCH64
- && TARGET_V9
- && TARGET_HARD_QUAD
- && (register_operand (operands[0], TFmode)
- || register_operand (operands[1], TFmode))"
- "@
- fmovq\\t%1, %0
- ldq\\t%1, %0
- stq\\t%1, %0
- #
- #
- #"
- [(set_attr "type" "fpmove,fpload,fpstore,*,*,*")
- (set_attr "length" "1,1,1,2,2,2")])
-
-;; Now we allow the integer register cases even when
-;; only arch64 is true.
-(define_insn "*movtf_insn_sp64"
- [(set (match_operand:TF 0 "general_operand" "=e,o,r,o,e,r")
- (match_operand:TF 1 "input_operand" "o,e,o,r,e,r"))]
- "TARGET_FPU
- && TARGET_ARCH64
- && ! TARGET_HARD_QUAD
- && (register_operand (operands[0], TFmode)
- || register_operand (operands[1], TFmode))"
- "#"
- [(set_attr "length" "2")])
-
-(define_insn "*movtf_no_e_insn_sp64"
- [(set (match_operand:TF 0 "general_operand" "=r,o,r")
- (match_operand:TF 1 "input_operand" "o,r,r"))]
- "! TARGET_FPU
- && TARGET_ARCH64
- && (register_operand (operands[0], TFmode)
- || register_operand (operands[1], TFmode))"
- "#"
- [(set_attr "length" "2")])
-
-;; Now all the splits to handle multi-insn TF mode moves.
-(define_split
- [(set (match_operand:TF 0 "register_operand" "")
- (match_operand:TF 1 "register_operand" ""))]
- "reload_completed
- && (! TARGET_ARCH64
- || (TARGET_FPU
- && ! TARGET_HARD_QUAD))"
- [(clobber (const_int 0))]
- "
-{
- rtx set_dest = operands[0];
- rtx set_src = operands[1];
- rtx dest1, dest2;
- rtx src1, src2;
-
- if (GET_CODE (set_dest) == SUBREG)
- set_dest = alter_subreg (set_dest);
- if (GET_CODE (set_src) == SUBREG)
- set_src = alter_subreg (set_src);
-
- /* Ugly, but gen_highpart will crap out here for 32-bit targets. */
- dest1 = gen_rtx_SUBREG (DFmode, set_dest, WORDS_BIG_ENDIAN == 0);
- dest2 = gen_rtx_SUBREG (DFmode, set_dest, WORDS_BIG_ENDIAN != 0);
- src1 = gen_rtx_SUBREG (DFmode, set_src, WORDS_BIG_ENDIAN == 0);
- src2 = gen_rtx_SUBREG (DFmode, set_src, WORDS_BIG_ENDIAN != 0);
-
- /* Now emit using the real source and destination we found, swapping
- the order if we detect overlap. */
- if (reg_overlap_mentioned_p (dest1, src2))
- {
- emit_insn (gen_movdf (dest2, src2));
- emit_insn (gen_movdf (dest1, src1));
- }
- else
- {
- emit_insn (gen_movdf (dest1, src1));
- emit_insn (gen_movdf (dest2, src2));
- }
- DONE;
-}")
-
-(define_split
- [(set (match_operand:TF 0 "register_operand" "")
- (match_operand:TF 1 "memory_operand" ""))]
- "(reload_completed
- && offsettable_memref_p (operands[1]))"
- [(clobber (const_int 0))]
- "
-{
- rtx word0 = change_address (operands[1], DFmode, NULL_RTX);
- rtx word1 = change_address (operands[1], DFmode,
- plus_constant_for_output (XEXP (word0, 0), 8));
- rtx dest1, dest2;
-
- /* Ugly, but gen_highpart will crap out here for 32-bit targets. */
- dest1 = gen_rtx_SUBREG (DFmode, operands[0], WORDS_BIG_ENDIAN == 0);
- dest2 = gen_rtx_SUBREG (DFmode, operands[0], WORDS_BIG_ENDIAN != 0);
-
- /* Now output, ordering such that we don't clobber any registers
- mentioned in the address. */
- if (reg_overlap_mentioned_p (dest1, word1))
-
- {
- emit_insn (gen_movdf (dest2, word1));
- emit_insn (gen_movdf (dest1, word0));
- }
- else
- {
- emit_insn (gen_movdf (dest1, word0));
- emit_insn (gen_movdf (dest2, word1));
- }
- DONE;
-}")
-
-(define_split
- [(set (match_operand:TF 0 "memory_operand" "")
- (match_operand:TF 1 "register_operand" ""))]
- "(reload_completed
- && offsettable_memref_p (operands[0]))"
- [(clobber (const_int 0))]
- "
-{
- rtx word0 = change_address (operands[0], DFmode, NULL_RTX);
- rtx word1 = change_address (operands[0], DFmode,
- plus_constant_for_output (XEXP (word0, 0), 8));
- rtx src1, src2;
-
- /* Ugly, but gen_highpart will crap out here for 32-bit targets. */
- src1 = gen_rtx_SUBREG (DFmode, operands[1], WORDS_BIG_ENDIAN == 0);
- src2 = gen_rtx_SUBREG (DFmode, operands[1], WORDS_BIG_ENDIAN != 0);
- emit_insn (gen_movdf (word0, src1));
- emit_insn (gen_movdf (word1, src2));
- DONE;
-}")
-
-;; Sparc V9 conditional move instructions.
-
-;; We can handle larger constants here for some flavors, but for now we keep
-;; it simple and only allow those constants supported by all flavours.
-;; Note that emit_conditional_move canonicalizes operands 2,3 so that operand
-;; 3 contains the constant if one is present, but we handle either for
-;; generality (sparc.c puts a constant in operand 2).
-
-(define_expand "movqicc"
- [(set (match_operand:QI 0 "register_operand" "")
- (if_then_else:QI (match_operand 1 "comparison_operator" "")
- (match_operand:QI 2 "arith10_operand" "")
- (match_operand:QI 3 "arith10_operand" "")))]
- "TARGET_V9"
- "
-{
- enum rtx_code code = GET_CODE (operands[1]);
-
- if (GET_MODE (sparc_compare_op0) == DImode
- && ! TARGET_ARCH64)
- FAIL;
-
- if (sparc_compare_op1 == const0_rtx
- && GET_CODE (sparc_compare_op0) == REG
- && GET_MODE (sparc_compare_op0) == DImode
- && v9_regcmp_p (code))
- {
- operands[1] = gen_rtx_fmt_ee (code, DImode,
- sparc_compare_op0, sparc_compare_op1);
- }
- else
- {
- rtx cc_reg = gen_compare_reg (code,
- sparc_compare_op0, sparc_compare_op1);
- operands[1] = gen_rtx_fmt_ee (code, GET_MODE (cc_reg), cc_reg, const0_rtx);
- }
-}")
-
-(define_expand "movhicc"
- [(set (match_operand:HI 0 "register_operand" "")
- (if_then_else:HI (match_operand 1 "comparison_operator" "")
- (match_operand:HI 2 "arith10_operand" "")
- (match_operand:HI 3 "arith10_operand" "")))]
- "TARGET_V9"
- "
-{
- enum rtx_code code = GET_CODE (operands[1]);
-
- if (GET_MODE (sparc_compare_op0) == DImode
- && ! TARGET_ARCH64)
- FAIL;
-
- if (sparc_compare_op1 == const0_rtx
- && GET_CODE (sparc_compare_op0) == REG
- && GET_MODE (sparc_compare_op0) == DImode
- && v9_regcmp_p (code))
- {
- operands[1] = gen_rtx_fmt_ee (code, DImode,
- sparc_compare_op0, sparc_compare_op1);
- }
- else
- {
- rtx cc_reg = gen_compare_reg (code,
- sparc_compare_op0, sparc_compare_op1);
- operands[1] = gen_rtx_fmt_ee (code, GET_MODE (cc_reg), cc_reg, const0_rtx);
- }
-}")
-
-(define_expand "movsicc"
- [(set (match_operand:SI 0 "register_operand" "")
- (if_then_else:SI (match_operand 1 "comparison_operator" "")
- (match_operand:SI 2 "arith10_operand" "")
- (match_operand:SI 3 "arith10_operand" "")))]
- "TARGET_V9"
- "
-{
- enum rtx_code code = GET_CODE (operands[1]);
- enum machine_mode op0_mode = GET_MODE (sparc_compare_op0);
-
- if (sparc_compare_op1 == const0_rtx
- && GET_CODE (sparc_compare_op0) == REG
- && (TARGET_ARCH64 && op0_mode == DImode && v9_regcmp_p (code)))
- {
- operands[1] = gen_rtx_fmt_ee (code, op0_mode,
- sparc_compare_op0, sparc_compare_op1);
- }
- else
- {
- rtx cc_reg = gen_compare_reg (code,
- sparc_compare_op0, sparc_compare_op1);
- operands[1] = gen_rtx_fmt_ee (code, GET_MODE (cc_reg),
- cc_reg, const0_rtx);
- }
-}")
-
-(define_expand "movdicc"
- [(set (match_operand:DI 0 "register_operand" "")
- (if_then_else:DI (match_operand 1 "comparison_operator" "")
- (match_operand:DI 2 "arith10_double_operand" "")
- (match_operand:DI 3 "arith10_double_operand" "")))]
- "TARGET_ARCH64"
- "
-{
- enum rtx_code code = GET_CODE (operands[1]);
-
- if (sparc_compare_op1 == const0_rtx
- && GET_CODE (sparc_compare_op0) == REG
- && GET_MODE (sparc_compare_op0) == DImode
- && v9_regcmp_p (code))
- {
- operands[1] = gen_rtx_fmt_ee (code, DImode,
- sparc_compare_op0, sparc_compare_op1);
- }
- else
- {
- rtx cc_reg = gen_compare_reg (code,
- sparc_compare_op0, sparc_compare_op1);
- operands[1] = gen_rtx_fmt_ee (code, GET_MODE (cc_reg),
- cc_reg, const0_rtx);
- }
-}")
-
-(define_expand "movsfcc"
- [(set (match_operand:SF 0 "register_operand" "")
- (if_then_else:SF (match_operand 1 "comparison_operator" "")
- (match_operand:SF 2 "register_operand" "")
- (match_operand:SF 3 "register_operand" "")))]
- "TARGET_V9 && TARGET_FPU"
- "
-{
- enum rtx_code code = GET_CODE (operands[1]);
-
- if (GET_MODE (sparc_compare_op0) == DImode
- && ! TARGET_ARCH64)
- FAIL;
-
- if (sparc_compare_op1 == const0_rtx
- && GET_CODE (sparc_compare_op0) == REG
- && GET_MODE (sparc_compare_op0) == DImode
- && v9_regcmp_p (code))
- {
- operands[1] = gen_rtx_fmt_ee (code, DImode,
- sparc_compare_op0, sparc_compare_op1);
- }
- else
- {
- rtx cc_reg = gen_compare_reg (code,
- sparc_compare_op0, sparc_compare_op1);
- operands[1] = gen_rtx_fmt_ee (code, GET_MODE (cc_reg), cc_reg, const0_rtx);
- }
-}")
-
-(define_expand "movdfcc"
- [(set (match_operand:DF 0 "register_operand" "")
- (if_then_else:DF (match_operand 1 "comparison_operator" "")
- (match_operand:DF 2 "register_operand" "")
- (match_operand:DF 3 "register_operand" "")))]
- "TARGET_V9 && TARGET_FPU"
- "
-{
- enum rtx_code code = GET_CODE (operands[1]);
-
- if (GET_MODE (sparc_compare_op0) == DImode
- && ! TARGET_ARCH64)
- FAIL;
-
- if (sparc_compare_op1 == const0_rtx
- && GET_CODE (sparc_compare_op0) == REG
- && GET_MODE (sparc_compare_op0) == DImode
- && v9_regcmp_p (code))
- {
- operands[1] = gen_rtx_fmt_ee (code, DImode,
- sparc_compare_op0, sparc_compare_op1);
- }
- else
- {
- rtx cc_reg = gen_compare_reg (code,
- sparc_compare_op0, sparc_compare_op1);
- operands[1] = gen_rtx_fmt_ee (code, GET_MODE (cc_reg), cc_reg, const0_rtx);
- }
-}")
-
-(define_expand "movtfcc"
- [(set (match_operand:TF 0 "register_operand" "")
- (if_then_else:TF (match_operand 1 "comparison_operator" "")
- (match_operand:TF 2 "register_operand" "")
- (match_operand:TF 3 "register_operand" "")))]
- "TARGET_V9 && TARGET_FPU"
- "
-{
- enum rtx_code code = GET_CODE (operands[1]);
-
- if (GET_MODE (sparc_compare_op0) == DImode
- && ! TARGET_ARCH64)
- FAIL;
-
- if (sparc_compare_op1 == const0_rtx
- && GET_CODE (sparc_compare_op0) == REG
- && GET_MODE (sparc_compare_op0) == DImode
- && v9_regcmp_p (code))
- {
- operands[1] = gen_rtx_fmt_ee (code, DImode,
- sparc_compare_op0, sparc_compare_op1);
- }
- else
- {
- rtx cc_reg = gen_compare_reg (code,
- sparc_compare_op0, sparc_compare_op1);
- operands[1] = gen_rtx_fmt_ee (code, GET_MODE (cc_reg), cc_reg, const0_rtx);
- }
-}")
-
-;; Conditional move define_insns.
-
-(define_insn "*movqi_cc_sp64"
- [(set (match_operand:QI 0 "register_operand" "=r,r")
- (if_then_else:QI (match_operator 1 "comparison_operator"
- [(match_operand 2 "icc_or_fcc_reg_operand" "X,X")
- (const_int 0)])
- (match_operand:QI 3 "arith11_operand" "rL,0")
- (match_operand:QI 4 "arith11_operand" "0,rL")))]
- "TARGET_V9"
- "@
- mov%C1\\t%x2, %3, %0
- mov%c1\\t%x2, %4, %0"
- [(set_attr "type" "cmove")
- (set_attr "length" "1")])
-
-(define_insn "*movhi_cc_sp64"
- [(set (match_operand:HI 0 "register_operand" "=r,r")
- (if_then_else:HI (match_operator 1 "comparison_operator"
- [(match_operand 2 "icc_or_fcc_reg_operand" "X,X")
- (const_int 0)])
- (match_operand:HI 3 "arith11_operand" "rL,0")
- (match_operand:HI 4 "arith11_operand" "0,rL")))]
- "TARGET_V9"
- "@
- mov%C1\\t%x2, %3, %0
- mov%c1\\t%x2, %4, %0"
- [(set_attr "type" "cmove")
- (set_attr "length" "1")])
-
-(define_insn "*movsi_cc_sp64"
- [(set (match_operand:SI 0 "register_operand" "=r,r")
- (if_then_else:SI (match_operator 1 "comparison_operator"
- [(match_operand 2 "icc_or_fcc_reg_operand" "X,X")
- (const_int 0)])
- (match_operand:SI 3 "arith11_operand" "rL,0")
- (match_operand:SI 4 "arith11_operand" "0,rL")))]
- "TARGET_V9"
- "@
- mov%C1\\t%x2, %3, %0
- mov%c1\\t%x2, %4, %0"
- [(set_attr "type" "cmove")
- (set_attr "length" "1")])
-
-;; ??? The constraints of operands 3,4 need work.
-(define_insn "*movdi_cc_sp64"
- [(set (match_operand:DI 0 "register_operand" "=r,r")
- (if_then_else:DI (match_operator 1 "comparison_operator"
- [(match_operand 2 "icc_or_fcc_reg_operand" "X,X")
- (const_int 0)])
- (match_operand:DI 3 "arith11_double_operand" "rLH,0")
- (match_operand:DI 4 "arith11_double_operand" "0,rLH")))]
- "TARGET_ARCH64"
- "@
- mov%C1\\t%x2, %3, %0
- mov%c1\\t%x2, %4, %0"
- [(set_attr "type" "cmove")
- (set_attr "length" "1")])
-
-(define_insn "*movdi_cc_sp64_trunc"
- [(set (match_operand:SI 0 "register_operand" "=r,r")
- (if_then_else:SI (match_operator 1 "comparison_operator"
- [(match_operand 2 "icc_or_fcc_reg_operand" "X,X")
- (const_int 0)])
- (match_operand:SI 3 "arith11_double_operand" "rLH,0")
- (match_operand:SI 4 "arith11_double_operand" "0,rLH")))]
- "TARGET_ARCH64"
- "@
- mov%C1\\t%x2, %3, %0
- mov%c1\\t%x2, %4, %0"
- [(set_attr "type" "cmove")
- (set_attr "length" "1")])
-
-(define_insn "*movsf_cc_sp64"
- [(set (match_operand:SF 0 "register_operand" "=f,f")
- (if_then_else:SF (match_operator 1 "comparison_operator"
- [(match_operand 2 "icc_or_fcc_reg_operand" "X,X")
- (const_int 0)])
- (match_operand:SF 3 "register_operand" "f,0")
- (match_operand:SF 4 "register_operand" "0,f")))]
- "TARGET_V9 && TARGET_FPU"
- "@
- fmovs%C1\\t%x2, %3, %0
- fmovs%c1\\t%x2, %4, %0"
- [(set_attr "type" "fpcmove")
- (set_attr "length" "1")])
-
-(define_insn "*movdf_cc_sp64"
- [(set (match_operand:DF 0 "register_operand" "=e,e")
- (if_then_else:DF (match_operator 1 "comparison_operator"
- [(match_operand 2 "icc_or_fcc_reg_operand" "X,X")
- (const_int 0)])
- (match_operand:DF 3 "register_operand" "e,0")
- (match_operand:DF 4 "register_operand" "0,e")))]
- "TARGET_V9 && TARGET_FPU"
- "@
- fmovd%C1\\t%x2, %3, %0
- fmovd%c1\\t%x2, %4, %0"
- [(set_attr "type" "fpcmove")
- (set_attr "length" "1")])
-
-(define_insn "*movtf_cc_sp64"
- [(set (match_operand:TF 0 "register_operand" "=e,e")
- (if_then_else:TF (match_operator 1 "comparison_operator"
- [(match_operand 2 "icc_or_fcc_reg_operand" "X,X")
- (const_int 0)])
- (match_operand:TF 3 "register_operand" "e,0")
- (match_operand:TF 4 "register_operand" "0,e")))]
- "TARGET_V9 && TARGET_FPU && TARGET_HARD_QUAD"
- "@
- fmovq%C1\\t%x2, %3, %0
- fmovq%c1\\t%x2, %4, %0"
- [(set_attr "type" "fpcmove")
- (set_attr "length" "1")])
-
-(define_insn "*movqi_cc_reg_sp64"
- [(set (match_operand:QI 0 "register_operand" "=r,r")
- (if_then_else:QI (match_operator 1 "v9_regcmp_op"
- [(match_operand:DI 2 "register_operand" "r,r")
- (const_int 0)])
- (match_operand:QI 3 "arith10_operand" "rM,0")
- (match_operand:QI 4 "arith10_operand" "0,rM")))]
- "TARGET_ARCH64"
- "@
- movr%D1\\t%2, %r3, %0
- movr%d1\\t%2, %r4, %0"
- [(set_attr "type" "cmove")
- (set_attr "length" "1")])
-
-(define_insn "*movhi_cc_reg_sp64"
- [(set (match_operand:HI 0 "register_operand" "=r,r")
- (if_then_else:HI (match_operator 1 "v9_regcmp_op"
- [(match_operand:DI 2 "register_operand" "r,r")
- (const_int 0)])
- (match_operand:HI 3 "arith10_operand" "rM,0")
- (match_operand:HI 4 "arith10_operand" "0,rM")))]
- "TARGET_ARCH64"
- "@
- movr%D1\\t%2, %r3, %0
- movr%d1\\t%2, %r4, %0"
- [(set_attr "type" "cmove")
- (set_attr "length" "1")])
-
-(define_insn "*movsi_cc_reg_sp64"
- [(set (match_operand:SI 0 "register_operand" "=r,r")
- (if_then_else:SI (match_operator 1 "v9_regcmp_op"
- [(match_operand:DI 2 "register_operand" "r,r")
- (const_int 0)])
- (match_operand:SI 3 "arith10_operand" "rM,0")
- (match_operand:SI 4 "arith10_operand" "0,rM")))]
- "TARGET_ARCH64"
- "@
- movr%D1\\t%2, %r3, %0
- movr%d1\\t%2, %r4, %0"
- [(set_attr "type" "cmove")
- (set_attr "length" "1")])
-
-;; ??? The constraints of operands 3,4 need work.
-(define_insn "*movdi_cc_reg_sp64"
- [(set (match_operand:DI 0 "register_operand" "=r,r")
- (if_then_else:DI (match_operator 1 "v9_regcmp_op"
- [(match_operand:DI 2 "register_operand" "r,r")
- (const_int 0)])
- (match_operand:DI 3 "arith10_double_operand" "rMH,0")
- (match_operand:DI 4 "arith10_double_operand" "0,rMH")))]
- "TARGET_ARCH64"
- "@
- movr%D1\\t%2, %r3, %0
- movr%d1\\t%2, %r4, %0"
- [(set_attr "type" "cmove")
- (set_attr "length" "1")])
-
-(define_insn "*movdi_cc_reg_sp64_trunc"
- [(set (match_operand:SI 0 "register_operand" "=r,r")
- (if_then_else:SI (match_operator 1 "v9_regcmp_op"
- [(match_operand:DI 2 "register_operand" "r,r")
- (const_int 0)])
- (match_operand:SI 3 "arith10_double_operand" "rMH,0")
- (match_operand:SI 4 "arith10_double_operand" "0,rMH")))]
- "TARGET_ARCH64"
- "@
- movr%D1\\t%2, %r3, %0
- movr%d1\\t%2, %r4, %0"
- [(set_attr "type" "cmove")
- (set_attr "length" "1")])
-
-(define_insn "*movsf_cc_reg_sp64"
- [(set (match_operand:SF 0 "register_operand" "=f,f")
- (if_then_else:SF (match_operator 1 "v9_regcmp_op"
- [(match_operand:DI 2 "register_operand" "r,r")
- (const_int 0)])
- (match_operand:SF 3 "register_operand" "f,0")
- (match_operand:SF 4 "register_operand" "0,f")))]
- "TARGET_ARCH64 && TARGET_FPU"
- "@
- fmovrs%D1\\t%2, %3, %0
- fmovrs%d1\\t%2, %4, %0"
- [(set_attr "type" "fpcmove")
- (set_attr "length" "1")])
-
-(define_insn "*movdf_cc_reg_sp64"
- [(set (match_operand:DF 0 "register_operand" "=e,e")
- (if_then_else:DF (match_operator 1 "v9_regcmp_op"
- [(match_operand:DI 2 "register_operand" "r,r")
- (const_int 0)])
- (match_operand:DF 3 "register_operand" "e,0")
- (match_operand:DF 4 "register_operand" "0,e")))]
- "TARGET_ARCH64 && TARGET_FPU"
- "@
- fmovrd%D1\\t%2, %3, %0
- fmovrd%d1\\t%2, %4, %0"
- [(set_attr "type" "fpcmove")
- (set_attr "length" "1")])
-
-(define_insn "*movtf_cc_reg_sp64"
- [(set (match_operand:TF 0 "register_operand" "=e,e")
- (if_then_else:TF (match_operator 1 "v9_regcmp_op"
- [(match_operand:DI 2 "register_operand" "r,r")
- (const_int 0)])
- (match_operand:TF 3 "register_operand" "e,0")
- (match_operand:TF 4 "register_operand" "0,e")))]
- "TARGET_ARCH64 && TARGET_FPU"
- "@
- fmovrq%D1\\t%2, %3, %0
- fmovrq%d1\\t%2, %4, %0"
- [(set_attr "type" "fpcmove")
- (set_attr "length" "1")])
-
-;;- zero extension instructions
-
-;; These patterns originally accepted general_operands, however, slightly
-;; better code is generated by only accepting register_operands, and then
-;; letting combine generate the ldu[hb] insns.
-
-(define_expand "zero_extendhisi2"
- [(set (match_operand:SI 0 "register_operand" "")
- (zero_extend:SI (match_operand:HI 1 "register_operand" "")))]
- ""
- "
-{
- rtx temp = gen_reg_rtx (SImode);
- rtx shift_16 = GEN_INT (16);
- int op1_subword = 0;
-
- if (GET_CODE (operand1) == SUBREG)
- {
- op1_subword = SUBREG_WORD (operand1);
- operand1 = XEXP (operand1, 0);
- }
-
- emit_insn (gen_ashlsi3 (temp, gen_rtx_SUBREG (SImode, operand1,
- op1_subword),
- shift_16));
- emit_insn (gen_lshrsi3 (operand0, temp, shift_16));
- DONE;
-}")
-
-(define_insn "*zero_extendhisi2_insn"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (zero_extend:SI (match_operand:HI 1 "memory_operand" "m")))]
- ""
- "lduh\\t%1, %0"
- [(set_attr "type" "load")
- (set_attr "length" "1")])
-
-(define_expand "zero_extendqihi2"
- [(set (match_operand:HI 0 "register_operand" "")
- (zero_extend:HI (match_operand:QI 1 "register_operand" "")))]
- ""
- "")
-
-(define_insn "*zero_extendqihi2_insn"
- [(set (match_operand:HI 0 "register_operand" "=r,r")
- (zero_extend:HI (match_operand:QI 1 "input_operand" "r,m")))]
- "GET_CODE (operands[1]) != CONST_INT"
- "@
- and\\t%1, 0xff, %0
- ldub\\t%1, %0"
- [(set_attr "type" "unary,load")
- (set_attr "length" "1")])
-
-(define_expand "zero_extendqisi2"
- [(set (match_operand:SI 0 "register_operand" "")
- (zero_extend:SI (match_operand:QI 1 "register_operand" "")))]
- ""
- "")
-
-(define_insn "*zero_extendqisi2_insn"
- [(set (match_operand:SI 0 "register_operand" "=r,r")
- (zero_extend:SI (match_operand:QI 1 "input_operand" "r,m")))]
- "GET_CODE (operands[1]) != CONST_INT"
- "@
- and\\t%1, 0xff, %0
- ldub\\t%1, %0"
- [(set_attr "type" "unary,load")
- (set_attr "length" "1")])
-
-(define_expand "zero_extendqidi2"
- [(set (match_operand:DI 0 "register_operand" "")
- (zero_extend:DI (match_operand:QI 1 "register_operand" "")))]
- "TARGET_ARCH64"
- "")
-
-(define_insn "*zero_extendqidi2_insn"
- [(set (match_operand:DI 0 "register_operand" "=r,r")
- (zero_extend:DI (match_operand:QI 1 "input_operand" "r,m")))]
- "TARGET_ARCH64 && GET_CODE (operands[1]) != CONST_INT"
- "@
- and\\t%1, 0xff, %0
- ldub\\t%1, %0"
- [(set_attr "type" "unary,load")
- (set_attr "length" "1")])
-
-(define_expand "zero_extendhidi2"
- [(set (match_operand:DI 0 "register_operand" "")
- (zero_extend:DI (match_operand:HI 1 "register_operand" "")))]
- "TARGET_ARCH64"
- "
-{
- rtx temp = gen_reg_rtx (DImode);
- rtx shift_48 = GEN_INT (48);
- int op1_subword = 0;
-
- if (GET_CODE (operand1) == SUBREG)
- {
- op1_subword = SUBREG_WORD (operand1);
- operand1 = XEXP (operand1, 0);
- }
-
- emit_insn (gen_ashldi3 (temp, gen_rtx_SUBREG (DImode, operand1,
- op1_subword),
- shift_48));
- emit_insn (gen_lshrdi3 (operand0, temp, shift_48));
- DONE;
-}")
-
-(define_insn "*zero_extendhidi2_insn"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (zero_extend:DI (match_operand:HI 1 "memory_operand" "m")))]
- "TARGET_ARCH64"
- "lduh\\t%1, %0"
- [(set_attr "type" "load")
- (set_attr "length" "1")])
-
-
-;; ??? Write truncdisi pattern using sra?
-
-(define_expand "zero_extendsidi2"
- [(set (match_operand:DI 0 "register_operand" "")
- (zero_extend:DI (match_operand:SI 1 "register_operand" "")))]
- ""
- "")
-
-(define_insn "*zero_extendsidi2_insn_sp64"
- [(set (match_operand:DI 0 "register_operand" "=r,r")
- (zero_extend:DI (match_operand:SI 1 "input_operand" "r,m")))]
- "TARGET_ARCH64 && GET_CODE (operands[1]) != CONST_INT"
- "@
- srl\\t%1, 0, %0
- lduw\\t%1, %0"
- [(set_attr "type" "shift,load")
- (set_attr "length" "1")])
-
-(define_insn "*zero_extendsidi2_insn_sp32"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (zero_extend:DI (match_operand:SI 1 "register_operand" "r")))]
- "! TARGET_ARCH64"
- "#"
- [(set_attr "type" "unary")
- (set_attr "length" "2")])
-
-(define_split
- [(set (match_operand:DI 0 "register_operand" "")
- (zero_extend:DI (match_operand:SI 1 "register_operand" "")))]
- "! TARGET_ARCH64 && reload_completed"
- [(set (match_dup 2) (match_dup 3))
- (set (match_dup 4) (match_dup 5))]
- "
-{
- rtx dest1, dest2;
-
- if (GET_CODE (operands[0]) == SUBREG)
- operands[0] = alter_subreg (operands[0]);
-
- dest1 = gen_highpart (SImode, operands[0]);
- dest2 = gen_lowpart (SImode, operands[0]);
-
- /* Swap the order in case of overlap. */
- if (REGNO (dest1) == REGNO (operands[1]))
- {
- operands[2] = dest2;
- operands[3] = operands[1];
- operands[4] = dest1;
- operands[5] = const0_rtx;
- }
- else
- {
- operands[2] = dest1;
- operands[3] = const0_rtx;
- operands[4] = dest2;
- operands[5] = operands[1];
- }
-}")
-
-;; Simplify comparisons of extended values.
-
-(define_insn "*cmp_zero_extendqisi2"
- [(set (reg:CC 100)
- (compare:CC (zero_extend:SI (match_operand:QI 0 "register_operand" "r"))
- (const_int 0)))]
- "! TARGET_LIVE_G0"
- "andcc\\t%0, 0xff, %%g0"
- [(set_attr "type" "compare")
- (set_attr "length" "1")])
-
-(define_insn "*cmp_zero_extendqisi2_set"
- [(set (reg:CC 100)
- (compare:CC (zero_extend:SI (match_operand:QI 1 "register_operand" "r"))
- (const_int 0)))
- (set (match_operand:SI 0 "register_operand" "=r")
- (zero_extend:SI (match_dup 1)))]
- ""
- "andcc\\t%1, 0xff, %0"
- [(set_attr "type" "compare")
- (set_attr "length" "1")])
-
-(define_insn "*cmp_zero_extendqidi2"
- [(set (reg:CCX 100)
- (compare:CCX (zero_extend:DI (match_operand:QI 0 "register_operand" "r"))
- (const_int 0)))]
- "TARGET_ARCH64"
- "andcc\\t%0, 0xff, %%g0"
- [(set_attr "type" "compare")
- (set_attr "length" "1")])
-
-(define_insn "*cmp_zero_extendqidi2_set"
- [(set (reg:CCX 100)
- (compare:CCX (zero_extend:DI (match_operand:QI 1 "register_operand" "r"))
- (const_int 0)))
- (set (match_operand:DI 0 "register_operand" "=r")
- (zero_extend:DI (match_dup 1)))]
- "TARGET_ARCH64"
- "andcc\\t%1, 0xff, %0"
- [(set_attr "type" "compare")
- (set_attr "length" "1")])
-
-;; Similarly, handle {SI,DI}->QI mode truncation followed by a compare.
-
-(define_insn "*cmp_siqi_trunc"
- [(set (reg:CC 100)
- (compare:CC (subreg:QI (match_operand:SI 0 "register_operand" "r") 0)
- (const_int 0)))]
- "! TARGET_LIVE_G0"
- "andcc\\t%0, 0xff, %%g0"
- [(set_attr "type" "compare")
- (set_attr "length" "1")])
-
-(define_insn "*cmp_siqi_trunc_set"
- [(set (reg:CC 100)
- (compare:CC (subreg:QI (match_operand:SI 1 "register_operand" "r") 0)
- (const_int 0)))
- (set (match_operand:QI 0 "register_operand" "=r")
- (subreg:QI (match_dup 1) 0))]
- ""
- "andcc\\t%1, 0xff, %0"
- [(set_attr "type" "compare")
- (set_attr "length" "1")])
-
-(define_insn "*cmp_diqi_trunc"
- [(set (reg:CC 100)
- (compare:CC (subreg:QI (match_operand:DI 0 "register_operand" "r") 0)
- (const_int 0)))]
- "TARGET_ARCH64"
- "andcc\\t%0, 0xff, %%g0"
- [(set_attr "type" "compare")
- (set_attr "length" "1")])
-
-(define_insn "*cmp_diqi_trunc_set"
- [(set (reg:CC 100)
- (compare:CC (subreg:QI (match_operand:DI 1 "register_operand" "r") 0)
- (const_int 0)))
- (set (match_operand:QI 0 "register_operand" "=r")
- (subreg:QI (match_dup 1) 0))]
- "TARGET_ARCH64"
- "andcc\\t%1, 0xff, %0"
- [(set_attr "type" "compare")
- (set_attr "length" "1")])
-
-;;- sign extension instructions
-
-;; These patterns originally accepted general_operands, however, slightly
-;; better code is generated by only accepting register_operands, and then
-;; letting combine generate the lds[hb] insns.
-
-(define_expand "extendhisi2"
- [(set (match_operand:SI 0 "register_operand" "")
- (sign_extend:SI (match_operand:HI 1 "register_operand" "")))]
- ""
- "
-{
- rtx temp = gen_reg_rtx (SImode);
- rtx shift_16 = GEN_INT (16);
- int op1_subword = 0;
-
- if (GET_CODE (operand1) == SUBREG)
- {
- op1_subword = SUBREG_WORD (operand1);
- operand1 = XEXP (operand1, 0);
- }
-
- emit_insn (gen_ashlsi3 (temp, gen_rtx_SUBREG (SImode, operand1,
- op1_subword),
- shift_16));
- emit_insn (gen_ashrsi3 (operand0, temp, shift_16));
- DONE;
-}")
-
-(define_insn "*sign_extendhisi2_insn"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (sign_extend:SI (match_operand:HI 1 "memory_operand" "m")))]
- ""
- "ldsh\\t%1, %0"
- [(set_attr "type" "sload")
- (set_attr "length" "1")])
-
-(define_expand "extendqihi2"
- [(set (match_operand:HI 0 "register_operand" "")
- (sign_extend:HI (match_operand:QI 1 "register_operand" "")))]
- ""
- "
-{
- rtx temp = gen_reg_rtx (SImode);
- rtx shift_24 = GEN_INT (24);
- int op1_subword = 0;
- int op0_subword = 0;
-
- if (GET_CODE (operand1) == SUBREG)
- {
- op1_subword = SUBREG_WORD (operand1);
- operand1 = XEXP (operand1, 0);
- }
- if (GET_CODE (operand0) == SUBREG)
- {
- op0_subword = SUBREG_WORD (operand0);
- operand0 = XEXP (operand0, 0);
- }
- emit_insn (gen_ashlsi3 (temp, gen_rtx_SUBREG (SImode, operand1,
- op1_subword),
- shift_24));
- if (GET_MODE (operand0) != SImode)
- operand0 = gen_rtx_SUBREG (SImode, operand0, op0_subword);
- emit_insn (gen_ashrsi3 (operand0, temp, shift_24));
- DONE;
-}")
-
-(define_insn "*sign_extendqihi2_insn"
- [(set (match_operand:HI 0 "register_operand" "=r")
- (sign_extend:HI (match_operand:QI 1 "memory_operand" "m")))]
- ""
- "ldsb\\t%1, %0"
- [(set_attr "type" "sload")
- (set_attr "length" "1")])
-
-(define_expand "extendqisi2"
- [(set (match_operand:SI 0 "register_operand" "")
- (sign_extend:SI (match_operand:QI 1 "register_operand" "")))]
- ""
- "
-{
- rtx temp = gen_reg_rtx (SImode);
- rtx shift_24 = GEN_INT (24);
- int op1_subword = 0;
-
- if (GET_CODE (operand1) == SUBREG)
- {
- op1_subword = SUBREG_WORD (operand1);
- operand1 = XEXP (operand1, 0);
- }
-
- emit_insn (gen_ashlsi3 (temp, gen_rtx_SUBREG (SImode, operand1,
- op1_subword),
- shift_24));
- emit_insn (gen_ashrsi3 (operand0, temp, shift_24));
- DONE;
-}")
-
-(define_insn "*sign_extendqisi2_insn"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (sign_extend:SI (match_operand:QI 1 "memory_operand" "m")))]
- ""
- "ldsb\\t%1, %0"
- [(set_attr "type" "sload")
- (set_attr "length" "1")])
-
-(define_expand "extendqidi2"
- [(set (match_operand:DI 0 "register_operand" "")
- (sign_extend:DI (match_operand:QI 1 "register_operand" "")))]
- "TARGET_ARCH64"
- "
-{
- rtx temp = gen_reg_rtx (DImode);
- rtx shift_56 = GEN_INT (56);
- int op1_subword = 0;
-
- if (GET_CODE (operand1) == SUBREG)
- {
- op1_subword = SUBREG_WORD (operand1);
- operand1 = XEXP (operand1, 0);
- }
-
- emit_insn (gen_ashldi3 (temp, gen_rtx_SUBREG (DImode, operand1,
- op1_subword),
- shift_56));
- emit_insn (gen_ashrdi3 (operand0, temp, shift_56));
- DONE;
-}")
-
-(define_insn "*sign_extendqidi2_insn"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (sign_extend:DI (match_operand:QI 1 "memory_operand" "m")))]
- "TARGET_ARCH64"
- "ldsb\\t%1, %0"
- [(set_attr "type" "sload")
- (set_attr "length" "1")])
-
-(define_expand "extendhidi2"
- [(set (match_operand:DI 0 "register_operand" "")
- (sign_extend:DI (match_operand:HI 1 "register_operand" "")))]
- "TARGET_ARCH64"
- "
-{
- rtx temp = gen_reg_rtx (DImode);
- rtx shift_48 = GEN_INT (48);
- int op1_subword = 0;
-
- if (GET_CODE (operand1) == SUBREG)
- {
- op1_subword = SUBREG_WORD (operand1);
- operand1 = XEXP (operand1, 0);
- }
-
- emit_insn (gen_ashldi3 (temp, gen_rtx_SUBREG (DImode, operand1,
- op1_subword),
- shift_48));
- emit_insn (gen_ashrdi3 (operand0, temp, shift_48));
- DONE;
-}")
-
-(define_insn "*sign_extendhidi2_insn"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (sign_extend:DI (match_operand:HI 1 "memory_operand" "m")))]
- "TARGET_ARCH64"
- "ldsh\\t%1, %0"
- [(set_attr "type" "sload")
- (set_attr "length" "1")])
-
-(define_expand "extendsidi2"
- [(set (match_operand:DI 0 "register_operand" "")
- (sign_extend:DI (match_operand:SI 1 "register_operand" "")))]
- "TARGET_ARCH64"
- "")
-
-(define_insn "*sign_extendsidi2_insn"
- [(set (match_operand:DI 0 "register_operand" "=r,r")
- (sign_extend:DI (match_operand:SI 1 "input_operand" "r,m")))]
- "TARGET_ARCH64"
- "@
- sra\\t%1, 0, %0
- ldsw\\t%1, %0"
- [(set_attr "type" "shift,sload")
- (set_attr "length" "1")])
-
-;; Special pattern for optimizing bit-field compares. This is needed
-;; because combine uses this as a canonical form.
-
-(define_insn "*cmp_zero_extract"
- [(set (reg:CC 100)
- (compare:CC
- (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
- (match_operand:SI 1 "small_int_or_double" "n")
- (match_operand:SI 2 "small_int_or_double" "n"))
- (const_int 0)))]
- "! TARGET_LIVE_G0
- && ((GET_CODE (operands[2]) == CONST_INT
- && INTVAL (operands[2]) > 19)
- || (GET_CODE (operands[2]) == CONST_DOUBLE
- && CONST_DOUBLE_LOW (operands[2]) > 19))"
- "*
-{
- int len = (GET_CODE (operands[1]) == CONST_INT
- ? INTVAL (operands[1])
- : CONST_DOUBLE_LOW (operands[1]));
- int pos = 32 -
- (GET_CODE (operands[2]) == CONST_INT
- ? INTVAL (operands[2])
- : CONST_DOUBLE_LOW (operands[2])) - len;
- HOST_WIDE_INT mask = ((1 << len) - 1) << pos;
-
- operands[1] = GEN_INT (mask);
- return \"andcc\\t%0, %1, %%g0\";
-}"
- [(set_attr "type" "compare")
- (set_attr "length" "1")])
-
-(define_insn "*cmp_zero_extract_sp64"
- [(set (reg:CCX 100)
- (compare:CCX
- (zero_extract:DI (match_operand:DI 0 "register_operand" "r")
- (match_operand:SI 1 "small_int_or_double" "n")
- (match_operand:SI 2 "small_int_or_double" "n"))
- (const_int 0)))]
- "TARGET_ARCH64
- && ((GET_CODE (operands[2]) == CONST_INT
- && INTVAL (operands[2]) > 51)
- || (GET_CODE (operands[2]) == CONST_DOUBLE
- && CONST_DOUBLE_LOW (operands[2]) > 51))"
- "*
-{
- int len = (GET_CODE (operands[1]) == CONST_INT
- ? INTVAL (operands[1])
- : CONST_DOUBLE_LOW (operands[1]));
- int pos = 64 -
- (GET_CODE (operands[2]) == CONST_INT
- ? INTVAL (operands[2])
- : CONST_DOUBLE_LOW (operands[2])) - len;
- HOST_WIDE_INT mask = (((unsigned HOST_WIDE_INT) 1 << len) - 1) << pos;
-
- operands[1] = GEN_INT (mask);
- return \"andcc\\t%0, %1, %%g0\";
-}"
- [(set_attr "type" "compare")
- (set_attr "length" "1")])
-
-;; Conversions between float, double and long double.
-
-(define_insn "extendsfdf2"
- [(set (match_operand:DF 0 "register_operand" "=e")
- (float_extend:DF
- (match_operand:SF 1 "register_operand" "f")))]
- "TARGET_FPU"
- "fstod\\t%1, %0"
- [(set_attr "type" "fp")
- (set_attr "length" "1")])
-
-(define_insn "extendsftf2"
- [(set (match_operand:TF 0 "register_operand" "=e")
- (float_extend:TF
- (match_operand:SF 1 "register_operand" "f")))]
- "TARGET_FPU && TARGET_HARD_QUAD"
- "fstoq\\t%1, %0"
- [(set_attr "type" "fp")
- (set_attr "length" "1")])
-
-(define_insn "extenddftf2"
- [(set (match_operand:TF 0 "register_operand" "=e")
- (float_extend:TF
- (match_operand:DF 1 "register_operand" "e")))]
- "TARGET_FPU && TARGET_HARD_QUAD"
- "fdtoq\\t%1, %0"
- [(set_attr "type" "fp")
- (set_attr "length" "1")])
-
-(define_insn "truncdfsf2"
- [(set (match_operand:SF 0 "register_operand" "=f")
- (float_truncate:SF
- (match_operand:DF 1 "register_operand" "e")))]
- "TARGET_FPU"
- "fdtos\\t%1, %0"
- [(set_attr "type" "fp")
- (set_attr "length" "1")])
-
-(define_insn "trunctfsf2"
- [(set (match_operand:SF 0 "register_operand" "=f")
- (float_truncate:SF
- (match_operand:TF 1 "register_operand" "e")))]
- "TARGET_FPU && TARGET_HARD_QUAD"
- "fqtos\\t%1, %0"
- [(set_attr "type" "fp")
- (set_attr "length" "1")])
-
-(define_insn "trunctfdf2"
- [(set (match_operand:DF 0 "register_operand" "=e")
- (float_truncate:DF
- (match_operand:TF 1 "register_operand" "e")))]
- "TARGET_FPU && TARGET_HARD_QUAD"
- "fqtod\\t%1, %0"
- [(set_attr "type" "fp")
- (set_attr "length" "1")])
-
-;; Conversion between fixed point and floating point.
-
-(define_insn "floatsisf2"
- [(set (match_operand:SF 0 "register_operand" "=f")
- (float:SF (match_operand:SI 1 "register_operand" "f")))]
- "TARGET_FPU"
- "fitos\\t%1, %0"
- [(set_attr "type" "fp")
- (set_attr "length" "1")])
-
-(define_insn "floatsidf2"
- [(set (match_operand:DF 0 "register_operand" "=e")
- (float:DF (match_operand:SI 1 "register_operand" "f")))]
- "TARGET_FPU"
- "fitod\\t%1, %0"
- [(set_attr "type" "fp")
- (set_attr "length" "1")])
-
-(define_insn "floatsitf2"
- [(set (match_operand:TF 0 "register_operand" "=e")
- (float:TF (match_operand:SI 1 "register_operand" "f")))]
- "TARGET_FPU && TARGET_HARD_QUAD"
- "fitoq\\t%1, %0"
- [(set_attr "type" "fp")
- (set_attr "length" "1")])
-
-;; Now the same for 64 bit sources.
-
-(define_insn "floatdisf2"
- [(set (match_operand:SF 0 "register_operand" "=f")
- (float:SF (match_operand:DI 1 "register_operand" "e")))]
- "TARGET_V9 && TARGET_FPU"
- "fxtos\\t%1, %0"
- [(set_attr "type" "fp")
- (set_attr "length" "1")])
-
-(define_insn "floatdidf2"
- [(set (match_operand:DF 0 "register_operand" "=e")
- (float:DF (match_operand:DI 1 "register_operand" "e")))]
- "TARGET_V9 && TARGET_FPU"
- "fxtod\\t%1, %0"
- [(set_attr "type" "fp")
- (set_attr "length" "1")])
-
-(define_insn "floatditf2"
- [(set (match_operand:TF 0 "register_operand" "=e")
- (float:TF (match_operand:DI 1 "register_operand" "e")))]
- "TARGET_V9 && TARGET_FPU && TARGET_HARD_QUAD"
- "fxtoq\\t%1, %0"
- [(set_attr "type" "fp")
- (set_attr "length" "1")])
-
-;; Convert a float to an actual integer.
-;; Truncation is performed as part of the conversion.
-
-(define_insn "fix_truncsfsi2"
- [(set (match_operand:SI 0 "register_operand" "=f")
- (fix:SI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
- "TARGET_FPU"
- "fstoi\\t%1, %0"
- [(set_attr "type" "fp")
- (set_attr "length" "1")])
-
-(define_insn "fix_truncdfsi2"
- [(set (match_operand:SI 0 "register_operand" "=f")
- (fix:SI (fix:DF (match_operand:DF 1 "register_operand" "e"))))]
- "TARGET_FPU"
- "fdtoi\\t%1, %0"
- [(set_attr "type" "fp")
- (set_attr "length" "1")])
-
-(define_insn "fix_trunctfsi2"
- [(set (match_operand:SI 0 "register_operand" "=f")
- (fix:SI (fix:TF (match_operand:TF 1 "register_operand" "e"))))]
- "TARGET_FPU && TARGET_HARD_QUAD"
- "fqtoi\\t%1, %0"
- [(set_attr "type" "fp")
- (set_attr "length" "1")])
-
-;; Now the same, for V9 targets
-
-(define_insn "fix_truncsfdi2"
- [(set (match_operand:DI 0 "register_operand" "=e")
- (fix:DI (fix:SF (match_operand:SF 1 "register_operand" "f"))))]
- "TARGET_V9 && TARGET_FPU"
- "fstox\\t%1, %0"
- [(set_attr "type" "fp")
- (set_attr "length" "1")])
-
-(define_insn "fix_truncdfdi2"
- [(set (match_operand:DI 0 "register_operand" "=e")
- (fix:DI (fix:DF (match_operand:DF 1 "register_operand" "e"))))]
- "TARGET_V9 && TARGET_FPU"
- "fdtox\\t%1, %0"
- [(set_attr "type" "fp")
- (set_attr "length" "1")])
-
-(define_insn "fix_trunctfdi2"
- [(set (match_operand:DI 0 "register_operand" "=e")
- (fix:DI (fix:TF (match_operand:TF 1 "register_operand" "e"))))]
- "TARGET_V9 && TARGET_FPU && TARGET_HARD_QUAD"
- "fqtox\\t%1, %0"
- [(set_attr "type" "fp")
- (set_attr "length" "1")])
-
-;;- arithmetic instructions
-
-(define_expand "adddi3"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (plus:DI (match_operand:DI 1 "arith_double_operand" "%r")
- (match_operand:DI 2 "arith_double_add_operand" "rHI")))]
- ""
- "
-{
- if (! TARGET_ARCH64)
- {
- emit_insn (gen_rtx_PARALLEL (VOIDmode, gen_rtvec (2,
- gen_rtx_SET (VOIDmode, operands[0],
- gen_rtx_PLUS (DImode, operands[1],
- operands[2])),
- gen_rtx_CLOBBER (VOIDmode,
- gen_rtx_REG (CCmode, SPARC_ICC_REG)))));
- DONE;
- }
- if (arith_double_4096_operand(operands[2], DImode))
- {
- emit_insn (gen_rtx_SET (VOIDmode, operands[0],
- gen_rtx_MINUS (DImode, operands[1],
- GEN_INT(-4096))));
- DONE;
- }
-}")
-
-(define_insn "adddi3_insn_sp32"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (plus:DI (match_operand:DI 1 "arith_double_operand" "%r")
- (match_operand:DI 2 "arith_double_operand" "rHI")))
- (clobber (reg:CC 100))]
- "! TARGET_ARCH64"
- "#"
- [(set_attr "length" "2")])
-
-(define_split
- [(set (match_operand:DI 0 "register_operand" "=r")
- (plus:DI (match_operand:DI 1 "arith_double_operand" "%r")
- (match_operand:DI 2 "arith_double_operand" "rHI")))
- (clobber (reg:CC 100))]
- "! TARGET_ARCH64 && reload_completed"
- [(parallel [(set (reg:CC_NOOV 100)
- (compare:CC_NOOV (plus:SI (match_dup 4)
- (match_dup 5))
- (const_int 0)))
- (set (match_dup 3)
- (plus:SI (match_dup 4) (match_dup 5)))])
- (set (match_dup 6)
- (plus:SI (plus:SI (match_dup 7)
- (match_dup 8))
- (ltu:SI (reg:CC_NOOV 100) (const_int 0))))]
- "
-{
- operands[3] = gen_lowpart (SImode, operands[0]);
- operands[4] = gen_lowpart (SImode, operands[1]);
- operands[5] = gen_lowpart (SImode, operands[2]);
- operands[6] = gen_highpart (SImode, operands[0]);
- operands[7] = gen_highpart (SImode, operands[1]);
- if (GET_CODE (operands[2]) == CONST_INT)
- {
- if (INTVAL (operands[2]) < 0)
- operands[8] = constm1_rtx;
- else
- operands[8] = const0_rtx;
- }
- else
- operands[8] = gen_highpart (SImode, operands[2]);
-}")
-
-(define_split
- [(set (match_operand:DI 0 "register_operand" "=r")
- (minus:DI (match_operand:DI 1 "arith_double_operand" "r")
- (match_operand:DI 2 "arith_double_operand" "rHI")))
- (clobber (reg:CC 100))]
- "! TARGET_ARCH64 && reload_completed"
- [(parallel [(set (reg:CC_NOOV 100)
- (compare:CC_NOOV (minus:SI (match_dup 4)
- (match_dup 5))
- (const_int 0)))
- (set (match_dup 3)
- (minus:SI (match_dup 4) (match_dup 5)))])
- (set (match_dup 6)
- (minus:SI (minus:SI (match_dup 7)
- (match_dup 8))
- (ltu:SI (reg:CC_NOOV 100) (const_int 0))))]
- "
-{
- operands[3] = gen_lowpart (SImode, operands[0]);
- operands[4] = gen_lowpart (SImode, operands[1]);
- operands[5] = gen_lowpart (SImode, operands[2]);
- operands[6] = gen_highpart (SImode, operands[0]);
- operands[7] = gen_highpart (SImode, operands[1]);
- if (GET_CODE (operands[2]) == CONST_INT)
- {
- if (INTVAL (operands[2]) < 0)
- operands[8] = constm1_rtx;
- else
- operands[8] = const0_rtx;
- }
- else
- operands[8] = gen_highpart (SImode, operands[2]);
-}")
-
-;; LTU here means "carry set"
-(define_insn "addx"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (plus:SI (plus:SI (match_operand:SI 1 "arith_operand" "%r")
- (match_operand:SI 2 "arith_operand" "rI"))
- (ltu:SI (reg:CC_NOOV 100) (const_int 0))))]
- ""
- "addx\\t%1, %2, %0"
- [(set_attr "type" "unary")
- (set_attr "length" "1")])
-
-(define_insn "*addx_extend_sp32"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (zero_extend:DI (plus:SI (plus:SI (match_operand:SI 1 "reg_or_0_operand" "%rJ")
- (match_operand:SI 2 "arith_operand" "rI"))
- (ltu:SI (reg:CC_NOOV 100) (const_int 0)))))]
- "! TARGET_ARCH64"
- "#"
- [(set_attr "type" "unary")
- (set_attr "length" "2")])
-
-(define_split
- [(set (match_operand:DI 0 "register_operand" "")
- (zero_extend:DI (plus:SI (plus:SI (match_operand:SI 1 "reg_or_0_operand" "")
- (match_operand:SI 2 "arith_operand" ""))
- (ltu:SI (reg:CC_NOOV 100) (const_int 0)))))]
- "! TARGET_ARCH64 && reload_completed"
- [(set (match_dup 3) (plus:SI (plus:SI (match_dup 1) (match_dup 2))
- (ltu:SI (reg:CC_NOOV 100) (const_int 0))))
- (set (match_dup 4) (const_int 0))]
- "operands[3] = gen_lowpart (SImode, operands[0]);
- operands[4] = gen_highpart (SImode, operands[1]);")
-
-(define_insn "*addx_extend_sp64"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (zero_extend:DI (plus:SI (plus:SI (match_operand:SI 1 "reg_or_0_operand" "%rJ")
- (match_operand:SI 2 "arith_operand" "rI"))
- (ltu:SI (reg:CC_NOOV 100) (const_int 0)))))]
- "TARGET_ARCH64"
- "addx\\t%r1, %2, %0"
- [(set_attr "type" "misc")
- (set_attr "length" "1")])
-
-(define_insn "subx"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (minus:SI (minus:SI (match_operand:SI 1 "reg_or_0_operand" "rJ")
- (match_operand:SI 2 "arith_operand" "rI"))
- (ltu:SI (reg:CC_NOOV 100) (const_int 0))))]
- ""
- "subx\\t%r1, %2, %0"
- [(set_attr "type" "misc")
- (set_attr "length" "1")])
-
-(define_insn "*subx_extend_sp64"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (zero_extend:DI (minus:SI (minus:SI (match_operand:SI 1 "reg_or_0_operand" "rJ")
- (match_operand:SI 2 "arith_operand" "rI"))
- (ltu:SI (reg:CC_NOOV 100) (const_int 0)))))]
- "TARGET_ARCH64"
- "subx\\t%r1, %2, %0"
- [(set_attr "type" "misc")
- (set_attr "length" "1")])
-
-(define_insn "*subx_extend"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (zero_extend:DI (minus:SI (minus:SI (match_operand:SI 1 "reg_or_0_operand" "rJ")
- (match_operand:SI 2 "arith_operand" "rI"))
- (ltu:SI (reg:CC_NOOV 100) (const_int 0)))))]
- "! TARGET_ARCH64"
- "#"
- [(set_attr "type" "unary")
- (set_attr "length" "2")])
-
-(define_split
- [(set (match_operand:DI 0 "register_operand" "=r")
- (zero_extend:DI (minus:SI (minus:SI (match_operand:SI 1 "reg_or_0_operand" "rJ")
- (match_operand:SI 2 "arith_operand" "rI"))
- (ltu:SI (reg:CC_NOOV 100) (const_int 0)))))]
- "! TARGET_ARCH64 && reload_completed"
- [(set (match_dup 3) (minus:SI (minus:SI (match_dup 1) (match_dup 2))
- (ltu:SI (reg:CC_NOOV 100) (const_int 0))))
- (set (match_dup 4) (const_int 0))]
- "operands[3] = gen_lowpart (SImode, operands[0]);
- operands[4] = gen_highpart (SImode, operands[0]);")
-
-(define_insn ""
- [(set (match_operand:DI 0 "register_operand" "=r")
- (plus:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "r"))
- (match_operand:DI 2 "register_operand" "r")))
- (clobber (reg:CC 100))]
- "! TARGET_ARCH64"
- "#"
- [(set_attr "type" "multi")
- (set_attr "length" "2")])
-
-(define_split
- [(set (match_operand:DI 0 "register_operand" "")
- (plus:DI (zero_extend:DI (match_operand:SI 1 "register_operand" ""))
- (match_operand:DI 2 "register_operand" "")))
- (clobber (reg:CC 100))]
- "! TARGET_ARCH64 && reload_completed"
- [(parallel [(set (reg:CC_NOOV 100)
- (compare:CC_NOOV (plus:SI (match_dup 3) (match_dup 1))
- (const_int 0)))
- (set (match_dup 5) (plus:SI (match_dup 3) (match_dup 1)))])
- (set (match_dup 6)
- (plus:SI (plus:SI (match_dup 4) (const_int 0))
- (ltu:SI (reg:CC_NOOV 100) (const_int 0))))]
- "operands[3] = gen_lowpart (SImode, operands[2]);
- operands[4] = gen_highpart (SImode, operands[2]);
- operands[5] = gen_lowpart (SImode, operands[0]);
- operands[6] = gen_highpart (SImode, operands[0]);")
-
-(define_insn "*adddi3_sp64"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (plus:DI (match_operand:DI 1 "arith_double_operand" "%r")
- (match_operand:DI 2 "arith_double_operand" "rHI")))]
- "TARGET_ARCH64"
- "add\\t%1, %2, %0"
- [(set_attr "type" "binary")
- (set_attr "length" "1")])
-
-(define_expand "addsi3"
- [(set (match_operand:SI 0 "register_operand" "=r,d")
- (plus:SI (match_operand:SI 1 "arith_operand" "%r,d")
- (match_operand:SI 2 "arith_add_operand" "rI,d")))]
- ""
- "
-{
- if (arith_4096_operand(operands[2], DImode))
- {
- emit_insn (gen_rtx_SET (VOIDmode, operands[0],
- gen_rtx_MINUS (SImode, operands[1],
- GEN_INT(-4096))));
- DONE;
- }
-}")
-
-(define_insn "*addsi3"
- [(set (match_operand:SI 0 "register_operand" "=r,d")
- (plus:SI (match_operand:SI 1 "arith_operand" "%r,d")
- (match_operand:SI 2 "arith_operand" "rI,d")))]
- ""
- "@
- add\\t%1, %2, %0
- fpadd32s\\t%1, %2, %0"
- [(set_attr "type" "ialu,fp")
- (set_attr "length" "1")])
-
-(define_insn "*cmp_cc_plus"
- [(set (reg:CC_NOOV 100)
- (compare:CC_NOOV (plus:SI (match_operand:SI 0 "arith_operand" "%r")
- (match_operand:SI 1 "arith_operand" "rI"))
- (const_int 0)))]
- "! TARGET_LIVE_G0"
- "addcc\\t%0, %1, %%g0"
- [(set_attr "type" "compare")
- (set_attr "length" "1")])
-
-(define_insn "*cmp_ccx_plus"
- [(set (reg:CCX_NOOV 100)
- (compare:CCX_NOOV (plus:DI (match_operand:DI 0 "arith_double_operand" "%r")
- (match_operand:DI 1 "arith_double_operand" "rHI"))
- (const_int 0)))]
- "TARGET_ARCH64"
- "addcc\\t%0, %1, %%g0"
- [(set_attr "type" "compare")
- (set_attr "length" "1")])
-
-(define_insn "*cmp_cc_plus_set"
- [(set (reg:CC_NOOV 100)
- (compare:CC_NOOV (plus:SI (match_operand:SI 1 "arith_operand" "%r")
- (match_operand:SI 2 "arith_operand" "rI"))
- (const_int 0)))
- (set (match_operand:SI 0 "register_operand" "=r")
- (plus:SI (match_dup 1) (match_dup 2)))]
- ""
- "addcc\\t%1, %2, %0"
- [(set_attr "type" "compare")
- (set_attr "length" "1")])
-
-(define_insn "*cmp_ccx_plus_set"
- [(set (reg:CCX_NOOV 100)
- (compare:CCX_NOOV (plus:DI (match_operand:DI 1 "arith_double_operand" "%r")
- (match_operand:DI 2 "arith_double_operand" "rHI"))
- (const_int 0)))
- (set (match_operand:DI 0 "register_operand" "=r")
- (plus:DI (match_dup 1) (match_dup 2)))]
- "TARGET_ARCH64"
- "addcc\\t%1, %2, %0"
- [(set_attr "type" "compare")
- (set_attr "length" "1")])
-
-(define_expand "subdi3"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (minus:DI (match_operand:DI 1 "register_operand" "r")
- (match_operand:DI 2 "arith_double_add_operand" "rHI")))]
- ""
- "
-{
- if (! TARGET_ARCH64)
- {
- emit_insn (gen_rtx_PARALLEL (VOIDmode, gen_rtvec (2,
- gen_rtx_SET (VOIDmode, operands[0],
- gen_rtx_MINUS (DImode, operands[1],
- operands[2])),
- gen_rtx_CLOBBER (VOIDmode,
- gen_rtx_REG (CCmode, SPARC_ICC_REG)))));
- DONE;
- }
- if (arith_double_4096_operand(operands[2], DImode))
- {
- emit_insn (gen_rtx_SET (VOIDmode, operands[0],
- gen_rtx_PLUS (DImode, operands[1],
- GEN_INT(-4096))));
- DONE;
- }
-}")
-
-(define_insn "*subdi3_sp32"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (minus:DI (match_operand:DI 1 "register_operand" "r")
- (match_operand:DI 2 "arith_double_operand" "rHI")))
- (clobber (reg:CC 100))]
- "! TARGET_ARCH64"
- "#"
- [(set_attr "length" "2")])
-
-(define_split
- [(set (match_operand:DI 0 "register_operand" "")
- (minus:DI (match_operand:DI 1 "register_operand" "")
- (match_operand:DI 2 "arith_double_operand" "")))
- (clobber (reg:CC 100))]
- "! TARGET_ARCH64
- && reload_completed
- && (GET_CODE (operands[2]) == CONST_INT
- || GET_CODE (operands[2]) == CONST_DOUBLE)"
- [(clobber (const_int 0))]
- "
-{
- rtx highp, lowp;
-
- highp = gen_highpart (SImode, operands[2]);
- lowp = gen_lowpart (SImode, operands[2]);
- if ((lowp == const0_rtx)
- && (operands[0] == operands[1]))
- {
- emit_insn (gen_rtx_SET (VOIDmode,
- gen_highpart (SImode, operands[0]),
- gen_rtx_MINUS (SImode,
- gen_highpart (SImode, operands[1]),
- highp)));
- }
- else
- {
- emit_insn (gen_cmp_minus_cc_set (gen_lowpart (SImode, operands[0]),
- gen_lowpart (SImode, operands[1]),
- lowp));
- emit_insn (gen_subx (gen_highpart (SImode, operands[0]),
- gen_highpart (SImode, operands[1]),
- highp));
- }
- DONE;
-}")
-
-(define_split
- [(set (match_operand:DI 0 "register_operand" "")
- (minus:DI (match_operand:DI 1 "register_operand" "")
- (match_operand:DI 2 "register_operand" "")))
- (clobber (reg:CC 100))]
- "! TARGET_ARCH64
- && reload_completed"
- [(clobber (const_int 0))]
- "
-{
- emit_insn (gen_cmp_minus_cc_set (gen_lowpart (SImode, operands[0]),
- gen_lowpart (SImode, operands[1]),
- gen_lowpart (SImode, operands[2])));
- emit_insn (gen_subx (gen_highpart (SImode, operands[0]),
- gen_highpart (SImode, operands[1]),
- gen_highpart (SImode, operands[2])));
- DONE;
-}")
-
-(define_insn ""
- [(set (match_operand:DI 0 "register_operand" "=r")
- (minus:DI (match_operand:DI 1 "register_operand" "r")
- (zero_extend:DI (match_operand:SI 2 "register_operand" "r"))))
- (clobber (reg:CC 100))]
- "! TARGET_ARCH64"
- "#"
- [(set_attr "type" "multi")
- (set_attr "length" "2")])
-
-(define_split
- [(set (match_operand:DI 0 "register_operand" "")
- (minus:DI (match_operand:DI 1 "register_operand" "")
- (zero_extend:DI (match_operand:SI 2 "register_operand" ""))))
- (clobber (reg:CC 100))]
- "! TARGET_ARCH64 && reload_completed"
- [(parallel [(set (reg:CC_NOOV 100)
- (compare:CC_NOOV (minus:SI (match_dup 3) (match_dup 2))
- (const_int 0)))
- (set (match_dup 5) (minus:SI (match_dup 3) (match_dup 2)))])
- (set (match_dup 6)
- (minus:SI (minus:SI (match_dup 4) (const_int 0))
- (ltu:SI (reg:CC_NOOV 100) (const_int 0))))]
- "operands[3] = gen_lowpart (SImode, operands[1]);
- operands[4] = gen_highpart (SImode, operands[1]);
- operands[5] = gen_lowpart (SImode, operands[0]);
- operands[6] = gen_highpart (SImode, operands[0]);")
-
-(define_insn "*subdi3_sp64"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (minus:DI (match_operand:DI 1 "register_operand" "r")
- (match_operand:DI 2 "arith_double_operand" "rHI")))]
- "TARGET_ARCH64"
- "sub\\t%1, %2, %0"
- [(set_attr "type" "binary")
- (set_attr "length" "1")])
-
-(define_expand "subsi3"
- [(set (match_operand:SI 0 "register_operand" "=r,d")
- (minus:SI (match_operand:SI 1 "register_operand" "r,d")
- (match_operand:SI 2 "arith_add_operand" "rI,d")))]
- ""
- "
-{
- if (arith_4096_operand(operands[2], DImode))
- {
- emit_insn (gen_rtx_SET (VOIDmode, operands[0],
- gen_rtx_PLUS (SImode, operands[1],
- GEN_INT(-4096))));
- DONE;
- }
-}")
-
-(define_insn "*subsi3"
- [(set (match_operand:SI 0 "register_operand" "=r,d")
- (minus:SI (match_operand:SI 1 "register_operand" "r,d")
- (match_operand:SI 2 "arith_operand" "rI,d")))]
- ""
- "@
- sub\\t%1, %2, %0
- fpsub32s\\t%1, %2, %0"
- [(set_attr "type" "ialu,fp")
- (set_attr "length" "1")])
-
-(define_insn "*cmp_minus_cc"
- [(set (reg:CC_NOOV 100)
- (compare:CC_NOOV (minus:SI (match_operand:SI 0 "reg_or_0_operand" "rJ")
- (match_operand:SI 1 "arith_operand" "rI"))
- (const_int 0)))]
- "! TARGET_LIVE_G0"
- "subcc\\t%r0, %1, %%g0"
- [(set_attr "type" "compare")
- (set_attr "length" "1")])
-
-(define_insn "*cmp_minus_ccx"
- [(set (reg:CCX_NOOV 100)
- (compare:CCX_NOOV (minus:DI (match_operand:DI 0 "register_operand" "r")
- (match_operand:DI 1 "arith_double_operand" "rHI"))
- (const_int 0)))]
- "TARGET_ARCH64"
- "subcc\\t%0, %1, %%g0"
- [(set_attr "type" "compare")
- (set_attr "length" "1")])
-
-(define_insn "cmp_minus_cc_set"
- [(set (reg:CC_NOOV 100)
- (compare:CC_NOOV (minus:SI (match_operand:SI 1 "reg_or_0_operand" "rJ")
- (match_operand:SI 2 "arith_operand" "rI"))
- (const_int 0)))
- (set (match_operand:SI 0 "register_operand" "=r")
- (minus:SI (match_dup 1) (match_dup 2)))]
- ""
- "subcc\\t%r1, %2, %0"
- [(set_attr "type" "compare")
- (set_attr "length" "1")])
-
-(define_insn "*cmp_minus_ccx_set"
- [(set (reg:CCX_NOOV 100)
- (compare:CCX_NOOV (minus:DI (match_operand:DI 1 "register_operand" "r")
- (match_operand:DI 2 "arith_double_operand" "rHI"))
- (const_int 0)))
- (set (match_operand:DI 0 "register_operand" "=r")
- (minus:DI (match_dup 1) (match_dup 2)))]
- "TARGET_ARCH64"
- "subcc\\t%1, %2, %0"
- [(set_attr "type" "compare")
- (set_attr "length" "1")])
-
-;; Integer Multiply/Divide.
-
-;; The 32 bit multiply/divide instructions are deprecated on v9 and shouldn't
-;; we used. We still use them in 32 bit v9 compilers.
-;; The 64 bit v9 compiler will (/should) widen the args and use muldi3.
-
-(define_insn "mulsi3"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (mult:SI (match_operand:SI 1 "arith_operand" "%r")
- (match_operand:SI 2 "arith_operand" "rI")))]
- "TARGET_HARD_MUL"
- "smul\\t%1, %2, %0"
- [(set_attr "type" "imul")
- (set_attr "length" "1")])
-
-(define_expand "muldi3"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (mult:DI (match_operand:DI 1 "arith_double_operand" "%r")
- (match_operand:DI 2 "arith_double_operand" "rHI")))]
- "TARGET_ARCH64 || TARGET_V8PLUS"
- "
-{
- if (TARGET_V8PLUS)
- {
- emit_insn (gen_muldi3_v8plus (operands[0], operands[1], operands[2]));
- DONE;
- }
-}")
-
-(define_insn "*muldi3_sp64"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (mult:DI (match_operand:DI 1 "arith_double_operand" "%r")
- (match_operand:DI 2 "arith_double_operand" "rHI")))]
- "TARGET_ARCH64"
- "mulx\\t%1, %2, %0"
- [(set_attr "type" "imul")
- (set_attr "length" "1")])
-
-;; V8plus wide multiply.
-;; XXX
-(define_insn "muldi3_v8plus"
- [(set (match_operand:DI 0 "register_operand" "=r,h")
- (mult:DI (match_operand:DI 1 "arith_double_operand" "%r,0")
- (match_operand:DI 2 "arith_double_operand" "rHI,rHI")))
- (clobber (match_scratch:SI 3 "=&h,X"))
- (clobber (match_scratch:SI 4 "=&h,X"))]
- "TARGET_V8PLUS"
- "*
-{
- if (sparc_check_64 (operands[1], insn) <= 0)
- output_asm_insn (\"srl\\t%L1, 0, %L1\", operands);
- if (which_alternative == 1)
- output_asm_insn (\"sllx\\t%H1, 32, %H1\", operands);
- if (sparc_check_64 (operands[2], insn) <= 0)
- output_asm_insn (\"srl\\t%L2, 0, %L2\", operands);
- if (which_alternative == 1)
- return \"or\\t%L1, %H1, %H1\\n\\tsllx\\t%H2, 32, %L1\\n\\tor\\t%L2, %L1, %L1\\n\\tmulx\\t%H1, %L1, %L0\;srlx\\t%L0, 32, %H0\";
- else
- return \"sllx\\t%H1, 32, %3\\n\\tsllx\\t%H2, 32, %4\\n\\tor\\t%L1, %3, %3\\n\\tor\\t%L2, %4, %4\\n\\tmulx\\t%3, %4, %3\\n\\tsrlx\\t%3, 32, %H0\\n\\tmov\\t%3, %L0\";
-}"
- [(set_attr "length" "9,8")])
-
-;; It is not known whether this will match.
-
-(define_insn "*cmp_mul_set"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (mult:SI (match_operand:SI 1 "arith_operand" "%r")
- (match_operand:SI 2 "arith_operand" "rI")))
- (set (reg:CC_NOOV 100)
- (compare:CC_NOOV (mult:SI (match_dup 1) (match_dup 2))
- (const_int 0)))]
- "TARGET_V8 || TARGET_SPARCLITE || TARGET_DEPRECATED_V8_INSNS"
- "smulcc\\t%1, %2, %0"
- [(set_attr "type" "imul")
- (set_attr "length" "1")])
-
-(define_expand "mulsidi3"
- [(set (match_operand:DI 0 "register_operand" "")
- (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" ""))
- (sign_extend:DI (match_operand:SI 2 "arith_operand" ""))))]
- "TARGET_HARD_MUL"
- "
-{
- if (CONSTANT_P (operands[2]))
- {
- if (TARGET_V8PLUS)
- {
- emit_insn (gen_const_mulsidi3_v8plus (operands[0], operands[1],
- operands[2]));
- DONE;
- }
- emit_insn (gen_const_mulsidi3 (operands[0], operands[1], operands[2]));
- DONE;
- }
- if (TARGET_V8PLUS)
- {
- emit_insn (gen_mulsidi3_v8plus (operands[0], operands[1], operands[2]));
- DONE;
- }
-}")
-
-;; V9 puts the 64 bit product in a 64 bit register. Only out or global
-;; registers can hold 64 bit values in the V8plus environment.
-;; XXX
-(define_insn "mulsidi3_v8plus"
- [(set (match_operand:DI 0 "register_operand" "=h,r")
- (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "r,r"))
- (sign_extend:DI (match_operand:SI 2 "register_operand" "r,r"))))
- (clobber (match_scratch:SI 3 "=X,&h"))]
- "TARGET_V8PLUS"
- "@
- smul\\t%1, %2, %L0\\n\\tsrlx\\t%L0, 32, %H0
- smul\\t%1, %2, %3\\n\\tsrlx\\t%3, 32, %H0\\n\\tmov\\t%3, %L0"
- [(set_attr "length" "2,3")])
-
-;; XXX
-(define_insn "const_mulsidi3_v8plus"
- [(set (match_operand:DI 0 "register_operand" "=h,r")
- (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "r,r"))
- (match_operand:SI 2 "small_int" "I,I")))
- (clobber (match_scratch:SI 3 "=X,&h"))]
- "TARGET_V8PLUS"
- "@
- smul\\t%1, %2, %L0\\n\\tsrlx\\t%L0, 32, %H0
- smul\\t%1, %2, %3\\n\\tsrlx\\t%3, 32, %H0\\n\\tmov\\t%3, %L0"
- [(set_attr "length" "2,3")])
-
-;; XXX
-(define_insn "*mulsidi3_sp32"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "r"))
- (sign_extend:DI (match_operand:SI 2 "register_operand" "r"))))]
- "TARGET_HARD_MUL32"
- "*
-{
- return TARGET_SPARCLET ? \"smuld\\t%1, %2, %L0\" : \"smul\\t%1, %2, %L0\\n\\trd\\t%%y, %H0\";
-}"
- [(set (attr "length")
- (if_then_else (eq_attr "isa" "sparclet")
- (const_int 1) (const_int 2)))])
-
-;; Extra pattern, because sign_extend of a constant isn't valid.
-
-;; XXX
-(define_insn "const_mulsidi3"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "r"))
- (match_operand:SI 2 "small_int" "I")))]
- "TARGET_HARD_MUL"
- "*
-{
- return TARGET_SPARCLET ? \"smuld\\t%1, %2, %L0\" : \"smul\\t%1, %2, %L0\\n\\trd\\t%%y, %H0\";
-}"
- [(set (attr "length")
- (if_then_else (eq_attr "isa" "sparclet")
- (const_int 1) (const_int 2)))])
-
-(define_expand "smulsi3_highpart"
- [(set (match_operand:SI 0 "register_operand" "")
- (truncate:SI
- (lshiftrt:DI (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" ""))
- (sign_extend:DI (match_operand:SI 2 "arith_operand" "")))
- (const_int 32))))]
- "TARGET_HARD_MUL"
- "
-{
- if (CONSTANT_P (operands[2]))
- {
- if (TARGET_V8PLUS)
- {
- emit_insn (gen_const_smulsi3_highpart_v8plus (operands[0],
- operands[1],
- operands[2],
- GEN_INT (32)));
- DONE;
- }
- emit_insn (gen_const_smulsi3_highpart (operands[0], operands[1], operands[2]));
- DONE;
- }
- if (TARGET_V8PLUS)
- {
- emit_insn (gen_smulsi3_highpart_v8plus (operands[0], operands[1],
- operands[2], GEN_INT (32)));
- DONE;
- }
-}")
-
-;; XXX
-(define_insn "smulsi3_highpart_v8plus"
- [(set (match_operand:SI 0 "register_operand" "=h,r")
- (truncate:SI
- (lshiftrt:DI (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "r,r"))
- (sign_extend:DI (match_operand:SI 2 "register_operand" "r,r")))
- (match_operand:SI 3 "const_int_operand" "i,i"))))
- (clobber (match_scratch:SI 4 "=X,&h"))]
- "TARGET_V8PLUS"
- "@
- smul %1,%2,%0\;srlx %0,%3,%0
- smul %1,%2,%4\;srlx %4,%3,%0"
- [(set_attr "length" "2")])
-
-;; The combiner changes TRUNCATE in the previous pattern to SUBREG.
-;; XXX
-(define_insn ""
- [(set (match_operand:SI 0 "register_operand" "=h,r")
- (subreg:SI
- (lshiftrt:DI
- (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "r,r"))
- (sign_extend:DI (match_operand:SI 2 "register_operand" "r,r")))
- (match_operand:SI 3 "const_int_operand" "i,i"))
- 1))
- (clobber (match_scratch:SI 4 "=X,&h"))]
- "TARGET_V8PLUS"
- "@
- smul\\t%1, %2, %0\\n\\tsrlx\\t%0, %3, %0
- smul\\t%1, %2, %4\\n\\tsrlx\\t%4, %3, %0"
- [(set_attr "length" "2")])
-
-;; XXX
-(define_insn "const_smulsi3_highpart_v8plus"
- [(set (match_operand:SI 0 "register_operand" "=h,r")
- (truncate:SI
- (lshiftrt:DI (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "r,r"))
- (match_operand 2 "small_int" "i,i"))
- (match_operand:SI 3 "const_int_operand" "i,i"))))
- (clobber (match_scratch:SI 4 "=X,&h"))]
- "TARGET_V8PLUS"
- "@
- smul\\t%1, %2, %0\\n\\tsrlx\\t%0, %3, %0
- smul\\t%1, %2, %4\\n\\tsrlx\\t%4, %3, %0"
- [(set_attr "length" "2")])
-
-;; XXX
-(define_insn "*smulsi3_highpart_sp32"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (truncate:SI
- (lshiftrt:DI (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "r"))
- (sign_extend:DI (match_operand:SI 2 "register_operand" "r")))
- (const_int 32))))]
- "TARGET_HARD_MUL32
- && ! TARGET_LIVE_G0"
- "smul\\t%1, %2, %%g0\\n\\trd\\t%%y, %0"
- [(set_attr "length" "2")])
-
-;; XXX
-(define_insn "const_smulsi3_highpart"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (truncate:SI
- (lshiftrt:DI (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "r"))
- (match_operand:SI 2 "register_operand" "r"))
- (const_int 32))))]
- "TARGET_HARD_MUL32
- && ! TARGET_LIVE_G0"
- "smul\\t%1, %2, %%g0\\n\\trd\\t%%y, %0"
- [(set_attr "length" "2")])
-
-(define_expand "umulsidi3"
- [(set (match_operand:DI 0 "register_operand" "")
- (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" ""))
- (zero_extend:DI (match_operand:SI 2 "uns_arith_operand" ""))))]
- "TARGET_HARD_MUL"
- "
-{
- if (CONSTANT_P (operands[2]))
- {
- if (TARGET_V8PLUS)
- {
- emit_insn (gen_const_umulsidi3_v8plus (operands[0], operands[1],
- operands[2]));
- DONE;
- }
- emit_insn (gen_const_umulsidi3 (operands[0], operands[1], operands[2]));
- DONE;
- }
- if (TARGET_V8PLUS)
- {
- emit_insn (gen_umulsidi3_v8plus (operands[0], operands[1], operands[2]));
- DONE;
- }
-}")
-
-;; XXX
-(define_insn "umulsidi3_v8plus"
- [(set (match_operand:DI 0 "register_operand" "=h,r")
- (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "r,r"))
- (zero_extend:DI (match_operand:SI 2 "register_operand" "r,r"))))
- (clobber (match_scratch:SI 3 "=X,&h"))]
- "TARGET_V8PLUS"
- "@
- umul\\t%1, %2, %L0\\n\\tsrlx\\t%L0, 32, %H0
- umul\\t%1, %2, %3\\n\\tsrlx\\t%3, 32, %H0\\n\\tmov\\t%3, %L0"
- [(set_attr "length" "2,3")])
-
-;; XXX
-(define_insn "*umulsidi3_sp32"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "r"))
- (zero_extend:DI (match_operand:SI 2 "register_operand" "r"))))]
- "TARGET_HARD_MUL32"
- "*
-{
- return TARGET_SPARCLET ? \"umuld\\t%1, %2, %L0\" : \"umul\\t%1, %2, %L0\\n\\trd\\t%%y, %H0\";
-}"
- [(set (attr "length")
- (if_then_else (eq_attr "isa" "sparclet")
- (const_int 1) (const_int 2)))])
-
-;; Extra pattern, because sign_extend of a constant isn't valid.
-
-;; XXX
-(define_insn "const_umulsidi3"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "r"))
- (match_operand:SI 2 "uns_small_int" "")))]
- "TARGET_HARD_MUL32"
- "*
-{
- return TARGET_SPARCLET ? \"umuld\\t%1, %2, %L0\" : \"umul\\t%1, %2, %L0\\n\\trd\\t%%y, %H0\";
-}"
- [(set (attr "length")
- (if_then_else (eq_attr "isa" "sparclet")
- (const_int 1) (const_int 2)))])
-
-;; XXX
-(define_insn "const_umulsidi3_v8plus"
- [(set (match_operand:DI 0 "register_operand" "=h,r")
- (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "r,r"))
- (match_operand:SI 2 "uns_small_int" "")))
- (clobber (match_scratch:SI 3 "=X,h"))]
- "TARGET_V8PLUS"
- "@
- umul\\t%1, %2, %L0\\n\\tsrlx\\t%L0, 32, %H0
- umul\\t%1, %2, %3\\n\\tsrlx\\t%3, 32, %H0\\n\\tmov\\t%3, %L0"
- [(set_attr "length" "2,3")])
-
-(define_expand "umulsi3_highpart"
- [(set (match_operand:SI 0 "register_operand" "")
- (truncate:SI
- (lshiftrt:DI (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" ""))
- (zero_extend:DI (match_operand:SI 2 "uns_arith_operand" "")))
- (const_int 32))))]
- "TARGET_HARD_MUL"
- "
-{
- if (CONSTANT_P (operands[2]))
- {
- if (TARGET_V8PLUS)
- {
- emit_insn (gen_const_umulsi3_highpart_v8plus (operands[0],
- operands[1],
- operands[2],
- GEN_INT (32)));
- DONE;
- }
- emit_insn (gen_const_umulsi3_highpart (operands[0], operands[1], operands[2]));
- DONE;
- }
- if (TARGET_V8PLUS)
- {
- emit_insn (gen_umulsi3_highpart_v8plus (operands[0], operands[1],
- operands[2], GEN_INT (32)));
- DONE;
- }
-}")
-
-;; XXX
-(define_insn "umulsi3_highpart_v8plus"
- [(set (match_operand:SI 0 "register_operand" "=h,r")
- (truncate:SI
- (lshiftrt:DI (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "r,r"))
- (zero_extend:DI (match_operand:SI 2 "register_operand" "r,r")))
- (match_operand:SI 3 "const_int_operand" "i,i"))))
- (clobber (match_scratch:SI 4 "=X,h"))]
- "TARGET_V8PLUS"
- "@
- umul\\t%1, %2, %0\\n\\tsrlx\\t%0, %3, %0
- umul\\t%1, %2, %4\\n\\tsrlx\\t%4, %3, %0"
- [(set_attr "length" "2")])
-
-;; XXX
-(define_insn "const_umulsi3_highpart_v8plus"
- [(set (match_operand:SI 0 "register_operand" "=h,r")
- (truncate:SI
- (lshiftrt:DI (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "r,r"))
- (match_operand:SI 2 "uns_small_int" ""))
- (match_operand:SI 3 "const_int_operand" "i,i"))))
- (clobber (match_scratch:SI 4 "=X,h"))]
- "TARGET_V8PLUS"
- "@
- umul\\t%1, %2, %0\\n\\tsrlx\\t%0, %3, %0
- umul\\t%1, %2, %4\\n\\tsrlx\\t%4, %3, %0"
- [(set_attr "length" "2")])
-
-;; XXX
-(define_insn "*umulsi3_highpart_sp32"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (truncate:SI
- (lshiftrt:DI (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "r"))
- (zero_extend:DI (match_operand:SI 2 "register_operand" "r")))
- (const_int 32))))]
- "TARGET_HARD_MUL32
- && ! TARGET_LIVE_G0"
- "umul\\t%1, %2, %%g0\\n\\trd\\t%%y, %0"
- [(set_attr "length" "2")])
-
-;; XXX
-(define_insn "const_umulsi3_highpart"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (truncate:SI
- (lshiftrt:DI (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "r"))
- (match_operand:SI 2 "uns_small_int" ""))
- (const_int 32))))]
- "TARGET_HARD_MUL32
- && ! TARGET_LIVE_G0"
- "umul\\t%1, %2, %%g0\\n\\trd\\t%%y, %0"
- [(set_attr "length" "2")])
-
-;; The v8 architecture specifies that there must be 3 instructions between
-;; a y register write and a use of it for correct results.
-
-;; XXX SHEESH
-(define_insn "divsi3"
- [(set (match_operand:SI 0 "register_operand" "=r,r")
- (div:SI (match_operand:SI 1 "register_operand" "r,r")
- (match_operand:SI 2 "input_operand" "rI,m")))
- (clobber (match_scratch:SI 3 "=&r,&r"))]
- "(TARGET_V8
- || TARGET_DEPRECATED_V8_INSNS)
- && ! TARGET_LIVE_G0"
- "*
-{
- if (which_alternative == 0)
- if (TARGET_V9)
- return \"sra\\t%1, 31, %3\\n\\twr\\t%%g0, %3, %%y\\n\\tsdiv\\t%1, %2, %0\";
- else
- return \"sra\\t%1, 31, %3\\n\\twr\\t%%g0, %3, %%y\\n\\tnop\\n\\tnop\\n\\tnop\\n\\tsdiv\\t%1, %2, %0\";
- else
- if (TARGET_V9)
- return \"sra\\t%1, 31, %3\\n\\twr\\t%%g0, %3, %%y\\n\\tld\\t%2, %3\\n\\tsdiv\\t%1, %3, %0\";
- else
- return \"sra\\t%1, 31, %3\\n\\twr\\t%%g0, %3, %%y\\n\\tld\\t%2, %3\\n\\tnop\\n\\tnop\\n\\tsdiv\\t%1, %3, %0\";
-}"
- [(set (attr "length")
- (if_then_else (eq_attr "isa" "v9")
- (const_int 4) (const_int 7)))])
-
-(define_insn "divdi3"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (div:DI (match_operand:DI 1 "register_operand" "r")
- (match_operand:DI 2 "arith_double_operand" "rHI")))]
- "TARGET_ARCH64"
- "sdivx\\t%1, %2, %0")
-
-;; It is not known whether this will match.
-
-;; XXX I hope it doesn't fucking match...
-(define_insn "*cmp_sdiv_cc_set"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (div:SI (match_operand:SI 1 "register_operand" "r")
- (match_operand:SI 2 "arith_operand" "rI")))
- (set (reg:CC 100)
- (compare:CC (div:SI (match_dup 1) (match_dup 2))
- (const_int 0)))
- (clobber (match_scratch:SI 3 "=&r"))]
- "(TARGET_V8
- || TARGET_DEPRECATED_V8_INSNS)
- && ! TARGET_LIVE_G0"
- "*
-{
- if (TARGET_V9)
- return \"sra\\t%1, 31, %3\\n\\twr\\t%%g0, %3, %%y\\n\\tsdivcc\\t%1, %2, %0\";
- else
- return \"sra\\t%1, 31, %3\\n\\twr\\t%%g0, %3, %%y\\n\\tnop\\n\\tnop\\n\\tnop\\n\\tsdivcc\\t%1, %2, %0\";
-}"
- [(set (attr "length")
- (if_then_else (eq_attr "isa" "v9")
- (const_int 3) (const_int 6)))])
-
-;; XXX
-(define_insn "udivsi3"
- [(set (match_operand:SI 0 "register_operand" "=r,&r,&r")
- (udiv:SI (match_operand:SI 1 "reg_or_nonsymb_mem_operand" "r,r,m")
- (match_operand:SI 2 "input_operand" "rI,m,r")))]
- "(TARGET_V8
- || TARGET_DEPRECATED_V8_INSNS)
- && ! TARGET_LIVE_G0"
- "*
-{
- output_asm_insn (\"wr\\t%%g0, %%g0, %%y\", operands);
- switch (which_alternative)
- {
- default:
- if (TARGET_V9)
- return \"udiv\\t%1, %2, %0\";
- return \"nop\\n\\tnop\\n\\tnop\\n\\tudiv\\t%1, %2, %0\";
- case 1:
- return \"ld\\t%2, %0\\n\\tnop\\n\\tnop\\n\\tudiv\\t%1, %0, %0\";
- case 2:
- return \"ld\\t%1, %0\\n\\tnop\\n\\tnop\\n\\tudiv\\t%0, %2, %0\";
- }
-}"
- [(set (attr "length")
- (if_then_else (and (eq_attr "isa" "v9")
- (eq_attr "alternative" "0"))
- (const_int 2) (const_int 5)))])
-
-(define_insn "udivdi3"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (udiv:DI (match_operand:DI 1 "register_operand" "r")
- (match_operand:DI 2 "arith_double_operand" "rHI")))]
- "TARGET_ARCH64"
- "udivx\\t%1, %2, %0")
-
-;; It is not known whether this will match.
-
-;; XXX I hope it doesn't fucking match...
-(define_insn "*cmp_udiv_cc_set"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (udiv:SI (match_operand:SI 1 "register_operand" "r")
- (match_operand:SI 2 "arith_operand" "rI")))
- (set (reg:CC 100)
- (compare:CC (udiv:SI (match_dup 1) (match_dup 2))
- (const_int 0)))]
- "(TARGET_V8
- || TARGET_DEPRECATED_V8_INSNS)
- && ! TARGET_LIVE_G0"
- "*
-{
- if (TARGET_V9)
- return \"wr\\t%%g0, %%g0, %%y\\n\\tudivcc\\t%1, %2, %0\";
- else
- return \"wr\\t%%g0, %%g0, %%y\\n\\tnop\\n\\tnop\\n\\tnop\\n\\tudivcc\\t%1, %2, %0\";
-}"
- [(set (attr "length")
- (if_then_else (eq_attr "isa" "v9")
- (const_int 2) (const_int 5)))])
-
-; sparclet multiply/accumulate insns
-
-(define_insn "*smacsi"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "%r")
- (match_operand:SI 2 "arith_operand" "rI"))
- (match_operand:SI 3 "register_operand" "0")))]
- "TARGET_SPARCLET"
- "smac\\t%1, %2, %0"
- [(set_attr "type" "imul")
- (set_attr "length" "1")])
-
-(define_insn "*smacdi"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (plus:DI (mult:DI (sign_extend:DI
- (match_operand:SI 1 "register_operand" "%r"))
- (sign_extend:DI
- (match_operand:SI 2 "register_operand" "r")))
- (match_operand:DI 3 "register_operand" "0")))]
- "TARGET_SPARCLET"
- "smacd\\t%1, %2, %L0"
- [(set_attr "type" "imul")
- (set_attr "length" "1")])
-
-(define_insn "*umacdi"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (plus:DI (mult:DI (zero_extend:DI
- (match_operand:SI 1 "register_operand" "%r"))
- (zero_extend:DI
- (match_operand:SI 2 "register_operand" "r")))
- (match_operand:DI 3 "register_operand" "0")))]
- "TARGET_SPARCLET"
- "umacd\\t%1, %2, %L0"
- [(set_attr "type" "imul")
- (set_attr "length" "1")])
-
-;;- Boolean instructions
-;; We define DImode `and' so with DImode `not' we can get
-;; DImode `andn'. Other combinations are possible.
-
-(define_expand "anddi3"
- [(set (match_operand:DI 0 "register_operand" "")
- (and:DI (match_operand:DI 1 "arith_double_operand" "")
- (match_operand:DI 2 "arith_double_operand" "")))]
- ""
- "")
-
-(define_insn "*anddi3_sp32"
- [(set (match_operand:DI 0 "register_operand" "=r,b")
- (and:DI (match_operand:DI 1 "arith_double_operand" "%r,b")
- (match_operand:DI 2 "arith_double_operand" "rHI,b")))]
- "! TARGET_ARCH64"
- "@
- #
- fand\\t%1, %2, %0"
- [(set_attr "type" "ialu,fp")
- (set_attr "length" "2,1")])
-
-(define_insn "*anddi3_sp64"
- [(set (match_operand:DI 0 "register_operand" "=r,b")
- (and:DI (match_operand:DI 1 "arith_double_operand" "%r,b")
- (match_operand:DI 2 "arith_double_operand" "rHI,b")))]
- "TARGET_ARCH64"
- "@
- and\\t%1, %2, %0
- fand\\t%1, %2, %0"
- [(set_attr "type" "ialu,fp")
- (set_attr "length" "1,1")])
-
-(define_insn "andsi3"
- [(set (match_operand:SI 0 "register_operand" "=r,d")
- (and:SI (match_operand:SI 1 "arith_operand" "%r,d")
- (match_operand:SI 2 "arith_operand" "rI,d")))]
- ""
- "@
- and\\t%1, %2, %0
- fands\\t%1, %2, %0"
- [(set_attr "type" "ialu,fp")
- (set_attr "length" "1,1")])
-
-(define_split
- [(set (match_operand:SI 0 "register_operand" "")
- (and:SI (match_operand:SI 1 "register_operand" "")
- (match_operand:SI 2 "" "")))
- (clobber (match_operand:SI 3 "register_operand" ""))]
- "GET_CODE (operands[2]) == CONST_INT
- && !SMALL_INT32 (operands[2])
- && (INTVAL (operands[2]) & 0x3ff) == 0x3ff"
- [(set (match_dup 3) (match_dup 4))
- (set (match_dup 0) (and:SI (not:SI (match_dup 3)) (match_dup 1)))]
- "
-{
- operands[4] = GEN_INT (~INTVAL (operands[2]) & 0xffffffff);
-}")
-
-;; Split DImode logical operations requiring two instructions.
-(define_split
- [(set (match_operand:DI 0 "register_operand" "")
- (match_operator:DI 1 "cc_arithop" ; AND, IOR, XOR
- [(match_operand:DI 2 "register_operand" "")
- (match_operand:DI 3 "arith_double_operand" "")]))]
- "! TARGET_ARCH64
- && reload_completed
- && ((GET_CODE (operands[0]) == REG
- && REGNO (operands[0]) < 32)
- || (GET_CODE (operands[0]) == SUBREG
- && GET_CODE (SUBREG_REG (operands[0])) == REG
- && REGNO (SUBREG_REG (operands[0])) < 32))"
- [(set (match_dup 4) (match_op_dup:SI 1 [(match_dup 6) (match_dup 8)]))
- (set (match_dup 5) (match_op_dup:SI 1 [(match_dup 7) (match_dup 9)]))]
- "
-{
- if (GET_CODE (operands[0]) == SUBREG)
- operands[0] = alter_subreg (operands[0]);
- operands[4] = gen_highpart (SImode, operands[0]);
- operands[5] = gen_lowpart (SImode, operands[0]);
- operands[6] = gen_highpart (SImode, operands[2]);
- operands[7] = gen_lowpart (SImode, operands[2]);
- if (GET_CODE (operands[3]) == CONST_INT)
- {
- if (INTVAL (operands[3]) < 0)
- operands[8] = constm1_rtx;
- else
- operands[8] = const0_rtx;
- }
- else
- operands[8] = gen_highpart (SImode, operands[3]);
- operands[9] = gen_lowpart (SImode, operands[3]);
-}")
-
-(define_insn "*and_not_di_sp32"
- [(set (match_operand:DI 0 "register_operand" "=r,b")
- (and:DI (not:DI (match_operand:DI 1 "register_operand" "r,b"))
- (match_operand:DI 2 "register_operand" "r,b")))]
- "! TARGET_ARCH64"
- "@
- #
- fandnot1\\t%1, %2, %0"
- [(set_attr "type" "ialu,fp")
- (set_attr "length" "2,1")])
-
-(define_split
- [(set (match_operand:DI 0 "register_operand" "")
- (and:DI (not:DI (match_operand:DI 1 "register_operand" ""))
- (match_operand:DI 2 "register_operand" "")))]
- "! TARGET_ARCH64
- && reload_completed
- && ((GET_CODE (operands[0]) == REG
- && REGNO (operands[0]) < 32)
- || (GET_CODE (operands[0]) == SUBREG
- && GET_CODE (SUBREG_REG (operands[0])) == REG
- && REGNO (SUBREG_REG (operands[0])) < 32))"
- [(set (match_dup 3) (and:SI (not:SI (match_dup 4)) (match_dup 5)))
- (set (match_dup 6) (and:SI (not:SI (match_dup 7)) (match_dup 8)))]
- "if (GET_CODE (operands[0]) == SUBREG)
- operands[0] = alter_subreg (operands[0]);
- operands[3] = gen_highpart (SImode, operands[0]);
- operands[4] = gen_highpart (SImode, operands[1]);
- operands[5] = gen_highpart (SImode, operands[2]);
- operands[6] = gen_lowpart (SImode, operands[0]);
- operands[7] = gen_lowpart (SImode, operands[1]);
- operands[8] = gen_lowpart (SImode, operands[2]);")
-
-(define_insn "*and_not_di_sp64"
- [(set (match_operand:DI 0 "register_operand" "=r,b")
- (and:DI (not:DI (match_operand:DI 1 "register_operand" "r,b"))
- (match_operand:DI 2 "register_operand" "r,b")))]
- "TARGET_ARCH64"
- "@
- andn\\t%2, %1, %0
- fandnot1\\t%1, %2, %0"
- [(set_attr "type" "ialu,fp")
- (set_attr "length" "1,1")])
-
-(define_insn "*and_not_si"
- [(set (match_operand:SI 0 "register_operand" "=r,d")
- (and:SI (not:SI (match_operand:SI 1 "register_operand" "r,d"))
- (match_operand:SI 2 "register_operand" "r,d")))]
- ""
- "@
- andn\\t%2, %1, %0
- fandnot1s\\t%1, %2, %0"
- [(set_attr "type" "ialu,fp")
- (set_attr "length" "1,1")])
-
-(define_expand "iordi3"
- [(set (match_operand:DI 0 "register_operand" "")
- (ior:DI (match_operand:DI 1 "arith_double_operand" "")
- (match_operand:DI 2 "arith_double_operand" "")))]
- ""
- "")
-
-(define_insn "*iordi3_sp32"
- [(set (match_operand:DI 0 "register_operand" "=r,b")
- (ior:DI (match_operand:DI 1 "arith_double_operand" "%r,b")
- (match_operand:DI 2 "arith_double_operand" "rHI,b")))]
- "! TARGET_ARCH64"
- "@
- #
- for\\t%1, %2, %0"
- [(set_attr "type" "ialu,fp")
- (set_attr "length" "2,1")])
-
-(define_insn "*iordi3_sp64"
- [(set (match_operand:DI 0 "register_operand" "=r,b")
- (ior:DI (match_operand:DI 1 "arith_double_operand" "%r,b")
- (match_operand:DI 2 "arith_double_operand" "rHI,b")))]
- "TARGET_ARCH64"
- "@
- or\\t%1, %2, %0
- for\\t%1, %2, %0"
- [(set_attr "type" "ialu,fp")
- (set_attr "length" "1,1")])
-
-(define_insn "iorsi3"
- [(set (match_operand:SI 0 "register_operand" "=r,d")
- (ior:SI (match_operand:SI 1 "arith_operand" "%r,d")
- (match_operand:SI 2 "arith_operand" "rI,d")))]
- ""
- "@
- or\\t%1, %2, %0
- fors\\t%1, %2, %0"
- [(set_attr "type" "ialu,fp")
- (set_attr "length" "1,1")])
-
-(define_split
- [(set (match_operand:SI 0 "register_operand" "")
- (ior:SI (match_operand:SI 1 "register_operand" "")
- (match_operand:SI 2 "" "")))
- (clobber (match_operand:SI 3 "register_operand" ""))]
- "GET_CODE (operands[2]) == CONST_INT
- && !SMALL_INT32 (operands[2])
- && (INTVAL (operands[2]) & 0x3ff) == 0x3ff"
- [(set (match_dup 3) (match_dup 4))
- (set (match_dup 0) (ior:SI (not:SI (match_dup 3)) (match_dup 1)))]
- "
-{
- operands[4] = GEN_INT (~INTVAL (operands[2]) & 0xffffffff);
-}")
-
-(define_insn "*or_not_di_sp32"
- [(set (match_operand:DI 0 "register_operand" "=r,b")
- (ior:DI (not:DI (match_operand:DI 1 "register_operand" "r,b"))
- (match_operand:DI 2 "register_operand" "r,b")))]
- "! TARGET_ARCH64"
- "@
- #
- fornot1\\t%1, %2, %0"
- [(set_attr "type" "ialu,fp")
- (set_attr "length" "2,1")])
-
-(define_split
- [(set (match_operand:DI 0 "register_operand" "")
- (ior:DI (not:DI (match_operand:DI 1 "register_operand" ""))
- (match_operand:DI 2 "register_operand" "")))]
- "! TARGET_ARCH64
- && reload_completed
- && ((GET_CODE (operands[0]) == REG
- && REGNO (operands[0]) < 32)
- || (GET_CODE (operands[0]) == SUBREG
- && GET_CODE (SUBREG_REG (operands[0])) == REG
- && REGNO (SUBREG_REG (operands[0])) < 32))"
- [(set (match_dup 3) (ior:SI (not:SI (match_dup 4)) (match_dup 5)))
- (set (match_dup 6) (ior:SI (not:SI (match_dup 7)) (match_dup 8)))]
- "if (GET_CODE (operands[0]) == SUBREG)
- operands[0] = alter_subreg (operands[0]);
- operands[3] = gen_highpart (SImode, operands[0]);
- operands[4] = gen_highpart (SImode, operands[1]);
- operands[5] = gen_highpart (SImode, operands[2]);
- operands[6] = gen_lowpart (SImode, operands[0]);
- operands[7] = gen_lowpart (SImode, operands[1]);
- operands[8] = gen_lowpart (SImode, operands[2]);")
-
-(define_insn "*or_not_di_sp64"
- [(set (match_operand:DI 0 "register_operand" "=r,b")
- (ior:DI (not:DI (match_operand:DI 1 "register_operand" "r,b"))
- (match_operand:DI 2 "register_operand" "r,b")))]
- "TARGET_ARCH64"
- "@
- orn\\t%2, %1, %0
- fornot1\\t%1, %2, %0"
- [(set_attr "type" "ialu,fp")
- (set_attr "length" "1,1")])
-
-(define_insn "*or_not_si"
- [(set (match_operand:SI 0 "register_operand" "=r,d")
- (ior:SI (not:SI (match_operand:SI 1 "register_operand" "r,d"))
- (match_operand:SI 2 "register_operand" "r,d")))]
- ""
- "@
- orn\\t%2, %1, %0
- fornot1s\\t%1, %2, %0"
- [(set_attr "type" "ialu,fp")
- (set_attr "length" "1,1")])
-
-(define_expand "xordi3"
- [(set (match_operand:DI 0 "register_operand" "")
- (xor:DI (match_operand:DI 1 "arith_double_operand" "")
- (match_operand:DI 2 "arith_double_operand" "")))]
- ""
- "")
-
-(define_insn "*xordi3_sp32"
- [(set (match_operand:DI 0 "register_operand" "=r,b")
- (xor:DI (match_operand:DI 1 "arith_double_operand" "%r,b")
- (match_operand:DI 2 "arith_double_operand" "rHI,b")))]
- "! TARGET_ARCH64"
- "@
- #
- fxor\\t%1, %2, %0"
- [(set_attr "length" "2,1")
- (set_attr "type" "ialu,fp")])
-
-(define_insn "*xordi3_sp64"
- [(set (match_operand:DI 0 "register_operand" "=r,b")
- (xor:DI (match_operand:DI 1 "arith_double_operand" "%rJ,b")
- (match_operand:DI 2 "arith_double_operand" "rHI,b")))]
- "TARGET_ARCH64"
- "@
- xor\\t%r1, %2, %0
- fxor\\t%1, %2, %0"
- [(set_attr "type" "ialu,fp")
- (set_attr "length" "1,1")])
-
-(define_insn "*xordi3_sp64_dbl"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (xor:DI (match_operand:DI 1 "register_operand" "r")
- (match_operand:DI 2 "const64_operand" "")))]
- "(TARGET_ARCH64
- && HOST_BITS_PER_WIDE_INT != 64)"
- "xor\\t%1, %2, %0"
- [(set_attr "type" "ialu")
- (set_attr "length" "1")])
-
-(define_insn "xorsi3"
- [(set (match_operand:SI 0 "register_operand" "=r,d")
- (xor:SI (match_operand:SI 1 "arith_operand" "%rJ,d")
- (match_operand:SI 2 "arith_operand" "rI,d")))]
- ""
- "@
- xor\\t%r1, %2, %0
- fxors\\t%1, %2, %0"
- [(set_attr "type" "ialu,fp")
- (set_attr "length" "1,1")])
-
-(define_split
- [(set (match_operand:SI 0 "register_operand" "")
- (xor:SI (match_operand:SI 1 "register_operand" "")
- (match_operand:SI 2 "" "")))
- (clobber (match_operand:SI 3 "register_operand" ""))]
- "GET_CODE (operands[2]) == CONST_INT
- && !SMALL_INT32 (operands[2])
- && (INTVAL (operands[2]) & 0x3ff) == 0x3ff"
- [(set (match_dup 3) (match_dup 4))
- (set (match_dup 0) (not:SI (xor:SI (match_dup 3) (match_dup 1))))]
- "
-{
- operands[4] = GEN_INT (~INTVAL (operands[2]) & 0xffffffff);
-}")
-
-(define_split
- [(set (match_operand:SI 0 "register_operand" "")
- (not:SI (xor:SI (match_operand:SI 1 "register_operand" "")
- (match_operand:SI 2 "" ""))))
- (clobber (match_operand:SI 3 "register_operand" ""))]
- "GET_CODE (operands[2]) == CONST_INT
- && !SMALL_INT32 (operands[2])
- && (INTVAL (operands[2]) & 0x3ff) == 0x3ff"
- [(set (match_dup 3) (match_dup 4))
- (set (match_dup 0) (xor:SI (match_dup 3) (match_dup 1)))]
- "
-{
- operands[4] = GEN_INT (~INTVAL (operands[2]) & 0xffffffff);
-}")
-
-;; xnor patterns. Note that (a ^ ~b) == (~a ^ b) == ~(a ^ b).
-;; Combine now canonicalizes to the rightmost expression.
-(define_insn "*xor_not_di_sp32"
- [(set (match_operand:DI 0 "register_operand" "=r,b")
- (not:DI (xor:DI (match_operand:DI 1 "register_operand" "r,b")
- (match_operand:DI 2 "register_operand" "r,b"))))]
- "! TARGET_ARCH64"
- "@
- #
- fxnor\\t%1, %2, %0"
- [(set_attr "length" "2,1")
- (set_attr "type" "ialu,fp")])
-
-(define_split
- [(set (match_operand:DI 0 "register_operand" "")
- (not:DI (xor:DI (match_operand:DI 1 "register_operand" "")
- (match_operand:DI 2 "register_operand" ""))))]
- "! TARGET_ARCH64
- && reload_completed
- && ((GET_CODE (operands[0]) == REG
- && REGNO (operands[0]) < 32)
- || (GET_CODE (operands[0]) == SUBREG
- && GET_CODE (SUBREG_REG (operands[0])) == REG
- && REGNO (SUBREG_REG (operands[0])) < 32))"
- [(set (match_dup 3) (not:SI (xor:SI (match_dup 4) (match_dup 5))))
- (set (match_dup 6) (not:SI (xor:SI (match_dup 7) (match_dup 8))))]
- "if (GET_CODE (operands[0]) == SUBREG)
- operands[0] = alter_subreg (operands[0]);
- operands[3] = gen_highpart (SImode, operands[0]);
- operands[4] = gen_highpart (SImode, operands[1]);
- operands[5] = gen_highpart (SImode, operands[2]);
- operands[6] = gen_lowpart (SImode, operands[0]);
- operands[7] = gen_lowpart (SImode, operands[1]);
- operands[8] = gen_lowpart (SImode, operands[2]);")
-
-(define_insn "*xor_not_di_sp64"
- [(set (match_operand:DI 0 "register_operand" "=r,b")
- (not:DI (xor:DI (match_operand:DI 1 "reg_or_0_operand" "rJ,b")
- (match_operand:DI 2 "arith_double_operand" "rHI,b"))))]
- "TARGET_ARCH64"
- "@
- xnor\\t%r1, %2, %0
- fxnor\\t%1, %2, %0"
- [(set_attr "type" "ialu,fp")
- (set_attr "length" "1,1")])
-
-(define_insn "*xor_not_si"
- [(set (match_operand:SI 0 "register_operand" "=r,d")
- (not:SI (xor:SI (match_operand:SI 1 "reg_or_0_operand" "rJ,d")
- (match_operand:SI 2 "arith_operand" "rI,d"))))]
- ""
- "@
- xnor\\t%r1, %2, %0
- fxnors\\t%1, %2, %0"
- [(set_attr "type" "ialu,fp")
- (set_attr "length" "1,1")])
-
-;; These correspond to the above in the case where we also (or only)
-;; want to set the condition code.
-
-(define_insn "*cmp_cc_arith_op"
- [(set (reg:CC 100)
- (compare:CC
- (match_operator:SI 2 "cc_arithop"
- [(match_operand:SI 0 "arith_operand" "%r")
- (match_operand:SI 1 "arith_operand" "rI")])
- (const_int 0)))]
- "! TARGET_LIVE_G0"
- "%A2cc\\t%0, %1, %%g0"
- [(set_attr "type" "compare")
- (set_attr "length" "1")])
-
-(define_insn "*cmp_ccx_arith_op"
- [(set (reg:CCX 100)
- (compare:CCX
- (match_operator:DI 2 "cc_arithop"
- [(match_operand:DI 0 "arith_double_operand" "%r")
- (match_operand:DI 1 "arith_double_operand" "rHI")])
- (const_int 0)))]
- "TARGET_ARCH64"
- "%A2cc\\t%0, %1, %%g0"
- [(set_attr "type" "compare")
- (set_attr "length" "1")])
-
-(define_insn "*cmp_cc_arith_op_set"
- [(set (reg:CC 100)
- (compare:CC
- (match_operator:SI 3 "cc_arithop"
- [(match_operand:SI 1 "arith_operand" "%r")
- (match_operand:SI 2 "arith_operand" "rI")])
- (const_int 0)))
- (set (match_operand:SI 0 "register_operand" "=r")
- (match_dup 3))]
- ""
- "%A3cc\\t%1, %2, %0"
- [(set_attr "type" "compare")
- (set_attr "length" "1")])
-
-(define_insn "*cmp_ccx_arith_op_set"
- [(set (reg:CCX 100)
- (compare:CCX
- (match_operator:DI 3 "cc_arithop"
- [(match_operand:DI 1 "arith_double_operand" "%r")
- (match_operand:DI 2 "arith_double_operand" "rHI")])
- (const_int 0)))
- (set (match_operand:DI 0 "register_operand" "=r")
- (match_dup 3))]
- "TARGET_ARCH64"
- "%A3cc\\t%1, %2, %0"
- [(set_attr "type" "compare")
- (set_attr "length" "1")])
-
-(define_insn "*cmp_cc_xor_not"
- [(set (reg:CC 100)
- (compare:CC
- (not:SI (xor:SI (match_operand:SI 0 "reg_or_0_operand" "%rJ")
- (match_operand:SI 1 "arith_operand" "rI")))
- (const_int 0)))]
- "! TARGET_LIVE_G0"
- "xnorcc\\t%r0, %1, %%g0"
- [(set_attr "type" "compare")
- (set_attr "length" "1")])
-
-(define_insn "*cmp_ccx_xor_not"
- [(set (reg:CCX 100)
- (compare:CCX
- (not:DI (xor:DI (match_operand:DI 0 "reg_or_0_operand" "%rJ")
- (match_operand:DI 1 "arith_double_operand" "rHI")))
- (const_int 0)))]
- "TARGET_ARCH64"
- "xnorcc\\t%r0, %1, %%g0"
- [(set_attr "type" "compare")
- (set_attr "length" "1")])
-
-(define_insn "*cmp_cc_xor_not_set"
- [(set (reg:CC 100)
- (compare:CC
- (not:SI (xor:SI (match_operand:SI 1 "reg_or_0_operand" "%rJ")
- (match_operand:SI 2 "arith_operand" "rI")))
- (const_int 0)))
- (set (match_operand:SI 0 "register_operand" "=r")
- (not:SI (xor:SI (match_dup 1) (match_dup 2))))]
- ""
- "xnorcc\\t%r1, %2, %0"
- [(set_attr "type" "compare")
- (set_attr "length" "1")])
-
-(define_insn "*cmp_ccx_xor_not_set"
- [(set (reg:CCX 100)
- (compare:CCX
- (not:DI (xor:DI (match_operand:DI 1 "reg_or_0_operand" "%rJ")
- (match_operand:DI 2 "arith_double_operand" "rHI")))
- (const_int 0)))
- (set (match_operand:DI 0 "register_operand" "=r")
- (not:DI (xor:DI (match_dup 1) (match_dup 2))))]
- "TARGET_ARCH64"
- "xnorcc\\t%r1, %2, %0"
- [(set_attr "type" "compare")
- (set_attr "length" "1")])
-
-(define_insn "*cmp_cc_arith_op_not"
- [(set (reg:CC 100)
- (compare:CC
- (match_operator:SI 2 "cc_arithopn"
- [(not:SI (match_operand:SI 0 "arith_operand" "rI"))
- (match_operand:SI 1 "reg_or_0_operand" "rJ")])
- (const_int 0)))]
- "! TARGET_LIVE_G0"
- "%B2cc\\t%r1, %0, %%g0"
- [(set_attr "type" "compare")
- (set_attr "length" "1")])
-
-(define_insn "*cmp_ccx_arith_op_not"
- [(set (reg:CCX 100)
- (compare:CCX
- (match_operator:DI 2 "cc_arithopn"
- [(not:DI (match_operand:DI 0 "arith_double_operand" "rHI"))
- (match_operand:DI 1 "reg_or_0_operand" "rJ")])
- (const_int 0)))]
- "TARGET_ARCH64"
- "%B2cc\\t%r1, %0, %%g0"
- [(set_attr "type" "compare")
- (set_attr "length" "1")])
-
-(define_insn "*cmp_cc_arith_op_not_set"
- [(set (reg:CC 100)
- (compare:CC
- (match_operator:SI 3 "cc_arithopn"
- [(not:SI (match_operand:SI 1 "arith_operand" "rI"))
- (match_operand:SI 2 "reg_or_0_operand" "rJ")])
- (const_int 0)))
- (set (match_operand:SI 0 "register_operand" "=r")
- (match_dup 3))]
- ""
- "%B3cc\\t%r2, %1, %0"
- [(set_attr "type" "compare")
- (set_attr "length" "1")])
-
-(define_insn "*cmp_ccx_arith_op_not_set"
- [(set (reg:CCX 100)
- (compare:CCX
- (match_operator:DI 3 "cc_arithopn"
- [(not:DI (match_operand:DI 1 "arith_double_operand" "rHI"))
- (match_operand:DI 2 "reg_or_0_operand" "rJ")])
- (const_int 0)))
- (set (match_operand:DI 0 "register_operand" "=r")
- (match_dup 3))]
- "TARGET_ARCH64"
- "%B3cc\\t%r2, %1, %0"
- [(set_attr "type" "compare")
- (set_attr "length" "1")])
-
-;; We cannot use the "neg" pseudo insn because the Sun assembler
-;; does not know how to make it work for constants.
-
-(define_expand "negdi2"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (neg:DI (match_operand:DI 1 "register_operand" "r")))]
- ""
- "
-{
- if (! TARGET_ARCH64)
- {
- emit_insn (gen_rtx_PARALLEL (VOIDmode, gen_rtvec (2,
- gen_rtx_SET (VOIDmode, operand0,
- gen_rtx_NEG (DImode, operand1)),
- gen_rtx_CLOBBER (VOIDmode,
- gen_rtx_REG (CCmode, SPARC_ICC_REG)))));
- DONE;
- }
-}")
-
-(define_insn "*negdi2_sp32"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (neg:DI (match_operand:DI 1 "register_operand" "r")))
- (clobber (reg:CC 100))]
- "! TARGET_ARCH64
- && ! TARGET_LIVE_G0"
- "#"
- [(set_attr "type" "unary")
- (set_attr "length" "2")])
-
-(define_split
- [(set (match_operand:DI 0 "register_operand" "")
- (neg:DI (match_operand:DI 1 "register_operand" "")))
- (clobber (reg:CC 100))]
- "! TARGET_ARCH64
- && ! TARGET_LIVE_G0
- && reload_completed"
- [(parallel [(set (reg:CC_NOOV 100)
- (compare:CC_NOOV (minus:SI (const_int 0) (match_dup 5))
- (const_int 0)))
- (set (match_dup 4) (minus:SI (const_int 0) (match_dup 5)))])
- (set (match_dup 2) (minus:SI (minus:SI (const_int 0) (match_dup 3))
- (ltu:SI (reg:CC 100) (const_int 0))))]
- "operands[2] = gen_highpart (SImode, operands[0]);
- operands[3] = gen_highpart (SImode, operands[1]);
- operands[4] = gen_lowpart (SImode, operands[0]);
- operands[5] = gen_lowpart (SImode, operands[1]);")
-
-(define_insn "*negdi2_sp64"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (neg:DI (match_operand:DI 1 "register_operand" "r")))]
- "TARGET_ARCH64"
- "sub\\t%%g0, %1, %0"
- [(set_attr "type" "unary")
- (set_attr "length" "1")])
-
-(define_expand "negsi2"
- [(set (match_operand:SI 0 "register_operand" "")
- (neg:SI (match_operand:SI 1 "arith_operand" "")))]
- ""
- "
-{
- if (TARGET_LIVE_G0)
- {
- rtx zero_reg = gen_reg_rtx (SImode);
-
- emit_insn (gen_rtx_SET (VOIDmode, zero_reg, const0_rtx));
- emit_insn (gen_rtx_SET (VOIDmode, operands[0],
- gen_rtx_MINUS (SImode, zero_reg,
- operands[1])));
- DONE;
- }
-}")
-
-(define_insn "*negsi2_not_liveg0"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (neg:SI (match_operand:SI 1 "arith_operand" "rI")))]
- "! TARGET_LIVE_G0"
- "sub\\t%%g0, %1, %0"
- [(set_attr "type" "unary")
- (set_attr "length" "1")])
-
-(define_insn "*cmp_cc_neg"
- [(set (reg:CC_NOOV 100)
- (compare:CC_NOOV (neg:SI (match_operand:SI 0 "arith_operand" "rI"))
- (const_int 0)))]
- "! TARGET_LIVE_G0"
- "subcc\\t%%g0, %0, %%g0"
- [(set_attr "type" "compare")
- (set_attr "length" "1")])
-
-(define_insn "*cmp_ccx_neg"
- [(set (reg:CCX_NOOV 100)
- (compare:CCX_NOOV (neg:DI (match_operand:DI 0 "arith_double_operand" "rHI"))
- (const_int 0)))]
- "TARGET_ARCH64"
- "subcc\\t%%g0, %0, %%g0"
- [(set_attr "type" "compare")
- (set_attr "length" "1")])
-
-(define_insn "*cmp_cc_set_neg"
- [(set (reg:CC_NOOV 100)
- (compare:CC_NOOV (neg:SI (match_operand:SI 1 "arith_operand" "rI"))
- (const_int 0)))
- (set (match_operand:SI 0 "register_operand" "=r")
- (neg:SI (match_dup 1)))]
- "! TARGET_LIVE_G0"
- "subcc\\t%%g0, %1, %0"
- [(set_attr "type" "compare")
- (set_attr "length" "1")])
-
-(define_insn "*cmp_ccx_set_neg"
- [(set (reg:CCX_NOOV 100)
- (compare:CCX_NOOV (neg:DI (match_operand:DI 1 "arith_double_operand" "rHI"))
- (const_int 0)))
- (set (match_operand:DI 0 "register_operand" "=r")
- (neg:DI (match_dup 1)))]
- "TARGET_ARCH64"
- "subcc\\t%%g0, %1, %0"
- [(set_attr "type" "compare")
- (set_attr "length" "1")])
-
-;; We cannot use the "not" pseudo insn because the Sun assembler
-;; does not know how to make it work for constants.
-(define_expand "one_cmpldi2"
- [(set (match_operand:DI 0 "register_operand" "")
- (not:DI (match_operand:DI 1 "register_operand" "")))]
- ""
- "")
-
-(define_insn "*one_cmpldi2_sp32"
- [(set (match_operand:DI 0 "register_operand" "=r,b")
- (not:DI (match_operand:DI 1 "register_operand" "r,b")))]
- "! TARGET_ARCH64"
- "@
- #
- fnot1\\t%1, %0"
- [(set_attr "type" "unary,fp")
- (set_attr "length" "2,1")])
-
-(define_split
- [(set (match_operand:DI 0 "register_operand" "")
- (not:DI (match_operand:DI 1 "register_operand" "")))]
- "! TARGET_ARCH64
- && reload_completed
- && ((GET_CODE (operands[0]) == REG
- && REGNO (operands[0]) < 32)
- || (GET_CODE (operands[0]) == SUBREG
- && GET_CODE (SUBREG_REG (operands[0])) == REG
- && REGNO (SUBREG_REG (operands[0])) < 32))"
- [(set (match_dup 2) (not:SI (xor:SI (match_dup 3) (const_int 0))))
- (set (match_dup 4) (not:SI (xor:SI (match_dup 5) (const_int 0))))]
- "if (GET_CODE (operands[0]) == SUBREG)
- operands[0] = alter_subreg (operands[0]);
- operands[2] = gen_highpart (SImode, operands[0]);
- operands[3] = gen_highpart (SImode, operands[1]);
- operands[4] = gen_lowpart (SImode, operands[0]);
- operands[5] = gen_lowpart (SImode, operands[1]);")
-
-(define_insn "*one_cmpldi2_sp64"
- [(set (match_operand:DI 0 "register_operand" "=r,b")
- (not:DI (match_operand:DI 1 "arith_double_operand" "rHI,b")))]
- "TARGET_ARCH64"
- "@
- xnor\\t%%g0, %1, %0
- fnot1\\t%1, %0"
- [(set_attr "type" "unary,fp")
- (set_attr "length" "1")])
-
-(define_expand "one_cmplsi2"
- [(set (match_operand:SI 0 "register_operand" "")
- (not:SI (match_operand:SI 1 "arith_operand" "")))]
- ""
- "
-{
- if (TARGET_LIVE_G0
- && GET_CODE (operands[1]) == CONST_INT)
- {
- rtx zero_reg = gen_reg_rtx (SImode);
-
- emit_insn (gen_rtx_SET (VOIDmode, zero_reg, const0_rtx));
- emit_insn (gen_rtx_SET (VOIDmode,
- operands[0],
- gen_rtx_NOT (SImode,
- gen_rtx_XOR (SImode,
- zero_reg,
- operands[1]))));
- DONE;
- }
-}")
-
-(define_insn "*one_cmplsi2_not_liveg0"
- [(set (match_operand:SI 0 "register_operand" "=r,d")
- (not:SI (match_operand:SI 1 "arith_operand" "rI,d")))]
- "! TARGET_LIVE_G0"
- "@
- xnor\\t%%g0, %1, %0
- fnot1s\\t%1, %0"
- [(set_attr "type" "unary,fp")
- (set_attr "length" "1,1")])
-
-(define_insn "*one_cmplsi2_liveg0"
- [(set (match_operand:SI 0 "register_operand" "=r,d")
- (not:SI (match_operand:SI 1 "arith_operand" "r,d")))]
- "TARGET_LIVE_G0"
- "@
- xnor\\t%1, 0, %0
- fnot1s\\t%1, %0"
- [(set_attr "type" "unary,fp")
- (set_attr "length" "1,1")])
-
-(define_insn "*cmp_cc_not"
- [(set (reg:CC 100)
- (compare:CC (not:SI (match_operand:SI 0 "arith_operand" "rI"))
- (const_int 0)))]
- "! TARGET_LIVE_G0"
- "xnorcc\\t%%g0, %0, %%g0"
- [(set_attr "type" "compare")
- (set_attr "length" "1")])
-
-(define_insn "*cmp_ccx_not"
- [(set (reg:CCX 100)
- (compare:CCX (not:DI (match_operand:DI 0 "arith_double_operand" "rHI"))
- (const_int 0)))]
- "TARGET_ARCH64"
- "xnorcc\\t%%g0, %0, %%g0"
- [(set_attr "type" "compare")
- (set_attr "length" "1")])
-
-(define_insn "*cmp_cc_set_not"
- [(set (reg:CC 100)
- (compare:CC (not:SI (match_operand:SI 1 "arith_operand" "rI"))
- (const_int 0)))
- (set (match_operand:SI 0 "register_operand" "=r")
- (not:SI (match_dup 1)))]
- "! TARGET_LIVE_G0"
- "xnorcc\\t%%g0, %1, %0"
- [(set_attr "type" "compare")
- (set_attr "length" "1")])
-
-(define_insn "*cmp_ccx_set_not"
- [(set (reg:CCX 100)
- (compare:CCX (not:DI (match_operand:DI 1 "arith_double_operand" "rHI"))
- (const_int 0)))
- (set (match_operand:DI 0 "register_operand" "=r")
- (not:DI (match_dup 1)))]
- "TARGET_ARCH64"
- "xnorcc\\t%%g0, %1, %0"
- [(set_attr "type" "compare")
- (set_attr "length" "1")])
-
-;; Floating point arithmetic instructions.
-
-(define_insn "addtf3"
- [(set (match_operand:TF 0 "register_operand" "=e")
- (plus:TF (match_operand:TF 1 "register_operand" "e")
- (match_operand:TF 2 "register_operand" "e")))]
- "TARGET_FPU && TARGET_HARD_QUAD"
- "faddq\\t%1, %2, %0"
- [(set_attr "type" "fp")
- (set_attr "length" "1")])
-
-(define_insn "adddf3"
- [(set (match_operand:DF 0 "register_operand" "=e")
- (plus:DF (match_operand:DF 1 "register_operand" "e")
- (match_operand:DF 2 "register_operand" "e")))]
- "TARGET_FPU"
- "faddd\\t%1, %2, %0"
- [(set_attr "type" "fp")
- (set_attr "length" "1")])
-
-(define_insn "addsf3"
- [(set (match_operand:SF 0 "register_operand" "=f")
- (plus:SF (match_operand:SF 1 "register_operand" "f")
- (match_operand:SF 2 "register_operand" "f")))]
- "TARGET_FPU"
- "fadds\\t%1, %2, %0"
- [(set_attr "type" "fp")
- (set_attr "length" "1")])
-
-(define_insn "subtf3"
- [(set (match_operand:TF 0 "register_operand" "=e")
- (minus:TF (match_operand:TF 1 "register_operand" "e")
- (match_operand:TF 2 "register_operand" "e")))]
- "TARGET_FPU && TARGET_HARD_QUAD"
- "fsubq\\t%1, %2, %0"
- [(set_attr "type" "fp")
- (set_attr "length" "1")])
-
-(define_insn "subdf3"
- [(set (match_operand:DF 0 "register_operand" "=e")
- (minus:DF (match_operand:DF 1 "register_operand" "e")
- (match_operand:DF 2 "register_operand" "e")))]
- "TARGET_FPU"
- "fsubd\\t%1, %2, %0"
- [(set_attr "type" "fp")
- (set_attr "length" "1")])
-
-(define_insn "subsf3"
- [(set (match_operand:SF 0 "register_operand" "=f")
- (minus:SF (match_operand:SF 1 "register_operand" "f")
- (match_operand:SF 2 "register_operand" "f")))]
- "TARGET_FPU"
- "fsubs\\t%1, %2, %0"
- [(set_attr "type" "fp")
- (set_attr "length" "1")])
-
-(define_insn "multf3"
- [(set (match_operand:TF 0 "register_operand" "=e")
- (mult:TF (match_operand:TF 1 "register_operand" "e")
- (match_operand:TF 2 "register_operand" "e")))]
- "TARGET_FPU && TARGET_HARD_QUAD"
- "fmulq\\t%1, %2, %0"
- [(set_attr "type" "fpmul")
- (set_attr "length" "1")])
-
-(define_insn "muldf3"
- [(set (match_operand:DF 0 "register_operand" "=e")
- (mult:DF (match_operand:DF 1 "register_operand" "e")
- (match_operand:DF 2 "register_operand" "e")))]
- "TARGET_FPU"
- "fmuld\\t%1, %2, %0"
- [(set_attr "type" "fpmul")
- (set_attr "length" "1")])
-
-(define_insn "mulsf3"
- [(set (match_operand:SF 0 "register_operand" "=f")
- (mult:SF (match_operand:SF 1 "register_operand" "f")
- (match_operand:SF 2 "register_operand" "f")))]
- "TARGET_FPU"
- "fmuls\\t%1, %2, %0"
- [(set_attr "type" "fpmul")
- (set_attr "length" "1")])
-
-(define_insn "*muldf3_extend"
- [(set (match_operand:DF 0 "register_operand" "=e")
- (mult:DF (float_extend:DF (match_operand:SF 1 "register_operand" "f"))
- (float_extend:DF (match_operand:SF 2 "register_operand" "f"))))]
- "(TARGET_V8 || TARGET_V9) && TARGET_FPU"
- "fsmuld\\t%1, %2, %0"
- [(set_attr "type" "fpmul")
- (set_attr "length" "1")])
-
-(define_insn "*multf3_extend"
- [(set (match_operand:TF 0 "register_operand" "=e")
- (mult:TF (float_extend:TF (match_operand:DF 1 "register_operand" "e"))
- (float_extend:TF (match_operand:DF 2 "register_operand" "e"))))]
- "(TARGET_V8 || TARGET_V9) && TARGET_FPU && TARGET_HARD_QUAD"
- "fdmulq\\t%1, %2, %0"
- [(set_attr "type" "fpmul")
- (set_attr "length" "1")])
-
-;; don't have timing for quad-prec. divide.
-(define_insn "divtf3"
- [(set (match_operand:TF 0 "register_operand" "=e")
- (div:TF (match_operand:TF 1 "register_operand" "e")
- (match_operand:TF 2 "register_operand" "e")))]
- "TARGET_FPU && TARGET_HARD_QUAD"
- "fdivq\\t%1, %2, %0"
- [(set_attr "type" "fpdivd")
- (set_attr "length" "1")])
-
-(define_insn "divdf3"
- [(set (match_operand:DF 0 "register_operand" "=e")
- (div:DF (match_operand:DF 1 "register_operand" "e")
- (match_operand:DF 2 "register_operand" "e")))]
- "TARGET_FPU"
- "fdivd\\t%1, %2, %0"
- [(set_attr "type" "fpdivd")
- (set_attr "length" "1")])
-
-(define_insn "divsf3"
- [(set (match_operand:SF 0 "register_operand" "=f")
- (div:SF (match_operand:SF 1 "register_operand" "f")
- (match_operand:SF 2 "register_operand" "f")))]
- "TARGET_FPU"
- "fdivs\\t%1, %2, %0"
- [(set_attr "type" "fpdivs")
- (set_attr "length" "1")])
-
-(define_expand "negtf2"
- [(set (match_operand:TF 0 "register_operand" "=e,e")
- (neg:TF (match_operand:TF 1 "register_operand" "0,e")))]
- "TARGET_FPU"
- "")
-
-(define_insn "*negtf2_notv9"
- [(set (match_operand:TF 0 "register_operand" "=e,e")
- (neg:TF (match_operand:TF 1 "register_operand" "0,e")))]
- ; We don't use quad float insns here so we don't need TARGET_HARD_QUAD.
- "TARGET_FPU
- && ! TARGET_V9"
- "@
- fnegs\\t%0, %0
- #"
- [(set_attr "type" "fpmove")
- (set_attr "length" "1,2")])
-
-(define_split
- [(set (match_operand:TF 0 "register_operand" "")
- (neg:TF (match_operand:TF 1 "register_operand" "")))]
- "TARGET_FPU
- && ! TARGET_V9
- && reload_completed
- && sparc_absnegfloat_split_legitimate (operands[0], operands[1])"
- [(set (match_dup 2) (neg:SF (match_dup 3)))
- (set (match_dup 4) (match_dup 5))
- (set (match_dup 6) (match_dup 7))]
- "if (GET_CODE (operands[0]) == SUBREG)
- operands[0] = alter_subreg (operands[0]);
- if (GET_CODE (operands[1]) == SUBREG)
- operands[1] = alter_subreg (operands[1]);
- operands[2] = gen_rtx_raw_REG (SFmode, REGNO (operands[0]));
- operands[3] = gen_rtx_raw_REG (SFmode, REGNO (operands[1]));
- operands[4] = gen_rtx_raw_REG (SFmode, REGNO (operands[0]) + 1);
- operands[5] = gen_rtx_raw_REG (SFmode, REGNO (operands[1]) + 1);
- operands[6] = gen_rtx_raw_REG (DFmode, REGNO (operands[0]) + 2);
- operands[7] = gen_rtx_raw_REG (DFmode, REGNO (operands[1]) + 2);")
-
-(define_insn "*negtf2_v9"
- [(set (match_operand:TF 0 "register_operand" "=e,e")
- (neg:TF (match_operand:TF 1 "register_operand" "0,e")))]
- ; We don't use quad float insns here so we don't need TARGET_HARD_QUAD.
- "TARGET_FPU && TARGET_V9"
- "@
- fnegd\\t%0, %0
- #"
- [(set_attr "type" "fpmove")
- (set_attr "length" "1,2")])
-
-(define_split
- [(set (match_operand:TF 0 "register_operand" "")
- (neg:TF (match_operand:TF 1 "register_operand" "")))]
- "TARGET_FPU
- && TARGET_V9
- && reload_completed
- && sparc_absnegfloat_split_legitimate (operands[0], operands[1])"
- [(set (match_dup 2) (neg:DF (match_dup 3)))
- (set (match_dup 4) (match_dup 5))]
- "if (GET_CODE (operands[0]) == SUBREG)
- operands[0] = alter_subreg (operands[0]);
- if (GET_CODE (operands[1]) == SUBREG)
- operands[1] = alter_subreg (operands[1]);
- operands[2] = gen_rtx_raw_REG (DFmode, REGNO (operands[0]));
- operands[3] = gen_rtx_raw_REG (DFmode, REGNO (operands[1]));
- operands[4] = gen_rtx_raw_REG (DFmode, REGNO (operands[0]) + 2);
- operands[5] = gen_rtx_raw_REG (DFmode, REGNO (operands[1]) + 2);")
-
-(define_expand "negdf2"
- [(set (match_operand:DF 0 "register_operand" "")
- (neg:DF (match_operand:DF 1 "register_operand" "")))]
- "TARGET_FPU"
- "")
-
-(define_insn "*negdf2_notv9"
- [(set (match_operand:DF 0 "register_operand" "=e,e")
- (neg:DF (match_operand:DF 1 "register_operand" "0,e")))]
- "TARGET_FPU && ! TARGET_V9"
- "@
- fnegs\\t%0, %0
- #"
- [(set_attr "type" "fpmove")
- (set_attr "length" "1,2")])
-
-(define_split
- [(set (match_operand:DF 0 "register_operand" "")
- (neg:DF (match_operand:DF 1 "register_operand" "")))]
- "TARGET_FPU
- && ! TARGET_V9
- && reload_completed
- && sparc_absnegfloat_split_legitimate (operands[0], operands[1])"
- [(set (match_dup 2) (neg:SF (match_dup 3)))
- (set (match_dup 4) (match_dup 5))]
- "if (GET_CODE (operands[0]) == SUBREG)
- operands[0] = alter_subreg (operands[0]);
- if (GET_CODE (operands[1]) == SUBREG)
- operands[1] = alter_subreg (operands[1]);
- operands[2] = gen_rtx_raw_REG (SFmode, REGNO (operands[0]));
- operands[3] = gen_rtx_raw_REG (SFmode, REGNO (operands[1]));
- operands[4] = gen_rtx_raw_REG (SFmode, REGNO (operands[0]) + 1);
- operands[5] = gen_rtx_raw_REG (SFmode, REGNO (operands[1]) + 1);")
-
-(define_insn "*negdf2_v9"
- [(set (match_operand:DF 0 "register_operand" "=e")
- (neg:DF (match_operand:DF 1 "register_operand" "e")))]
- "TARGET_FPU && TARGET_V9"
- "fnegd\\t%1, %0"
- [(set_attr "type" "fpmove")
- (set_attr "length" "1")])
-
-(define_insn "negsf2"
- [(set (match_operand:SF 0 "register_operand" "=f")
- (neg:SF (match_operand:SF 1 "register_operand" "f")))]
- "TARGET_FPU"
- "fnegs\\t%1, %0"
- [(set_attr "type" "fpmove")
- (set_attr "length" "1")])
-
-(define_expand "abstf2"
- [(set (match_operand:TF 0 "register_operand" "")
- (abs:TF (match_operand:TF 1 "register_operand" "")))]
- "TARGET_FPU"
- "")
-
-(define_insn "*abstf2_notv9"
- [(set (match_operand:TF 0 "register_operand" "=e,e")
- (abs:TF (match_operand:TF 1 "register_operand" "0,e")))]
- ; We don't use quad float insns here so we don't need TARGET_HARD_QUAD.
- "TARGET_FPU && ! TARGET_V9"
- "@
- fabss\\t%0, %0
- #"
- [(set_attr "type" "fpmove")
- (set_attr "length" "1,2")])
-
-(define_split
- [(set (match_operand:TF 0 "register_operand" "=e,e")
- (abs:TF (match_operand:TF 1 "register_operand" "0,e")))]
- "TARGET_FPU
- && ! TARGET_V9
- && reload_completed
- && sparc_absnegfloat_split_legitimate (operands[0], operands[1])"
- [(set (match_dup 2) (abs:SF (match_dup 3)))
- (set (match_dup 4) (match_dup 5))
- (set (match_dup 6) (match_dup 7))]
- "if (GET_CODE (operands[0]) == SUBREG)
- operands[0] = alter_subreg (operands[0]);
- if (GET_CODE (operands[1]) == SUBREG)
- operands[1] = alter_subreg (operands[1]);
- operands[2] = gen_rtx_raw_REG (SFmode, REGNO (operands[0]));
- operands[3] = gen_rtx_raw_REG (SFmode, REGNO (operands[1]));
- operands[4] = gen_rtx_raw_REG (SFmode, REGNO (operands[0]) + 1);
- operands[5] = gen_rtx_raw_REG (SFmode, REGNO (operands[1]) + 1);
- operands[6] = gen_rtx_raw_REG (DFmode, REGNO (operands[0]) + 2);
- operands[7] = gen_rtx_raw_REG (DFmode, REGNO (operands[1]) + 2);")
-
-(define_insn "*abstf2_hq_v9"
- [(set (match_operand:TF 0 "register_operand" "=e,e")
- (abs:TF (match_operand:TF 1 "register_operand" "0,e")))]
- "TARGET_FPU && TARGET_V9 && TARGET_HARD_QUAD"
- "@
- fabsd\\t%0, %0
- fabsq\\t%1, %0"
- [(set_attr "type" "fpmove")
- (set_attr "length" "1")])
-
-(define_insn "*abstf2_v9"
- [(set (match_operand:TF 0 "register_operand" "=e,e")
- (abs:TF (match_operand:TF 1 "register_operand" "0,e")))]
- "TARGET_FPU && TARGET_V9 && !TARGET_HARD_QUAD"
- "@
- fabsd\\t%0, %0
- #"
- [(set_attr "type" "fpmove")
- (set_attr "length" "1,2")])
-
-(define_split
- [(set (match_operand:TF 0 "register_operand" "=e,e")
- (abs:TF (match_operand:TF 1 "register_operand" "0,e")))]
- "TARGET_FPU
- && TARGET_V9
- && reload_completed
- && sparc_absnegfloat_split_legitimate (operands[0], operands[1])"
- [(set (match_dup 2) (abs:DF (match_dup 3)))
- (set (match_dup 4) (match_dup 5))]
- "if (GET_CODE (operands[0]) == SUBREG)
- operands[0] = alter_subreg (operands[0]);
- if (GET_CODE (operands[1]) == SUBREG)
- operands[1] = alter_subreg (operands[1]);
- operands[2] = gen_rtx_raw_REG (DFmode, REGNO (operands[0]));
- operands[3] = gen_rtx_raw_REG (DFmode, REGNO (operands[1]));
- operands[4] = gen_rtx_raw_REG (DFmode, REGNO (operands[0]) + 2);
- operands[5] = gen_rtx_raw_REG (DFmode, REGNO (operands[1]) + 2);")
-
-(define_expand "absdf2"
- [(set (match_operand:DF 0 "register_operand" "")
- (abs:DF (match_operand:DF 1 "register_operand" "")))]
- "TARGET_FPU"
- "")
-
-(define_insn "*absdf2_notv9"
- [(set (match_operand:DF 0 "register_operand" "=e,e")
- (abs:DF (match_operand:DF 1 "register_operand" "0,e")))]
- "TARGET_FPU && ! TARGET_V9"
- "@
- fabss\\t%0, %0
- #"
- [(set_attr "type" "fpmove")
- (set_attr "length" "1,2")])
-
-(define_split
- [(set (match_operand:DF 0 "register_operand" "=e,e")
- (abs:DF (match_operand:DF 1 "register_operand" "0,e")))]
- "TARGET_FPU
- && ! TARGET_V9
- && reload_completed
- && sparc_absnegfloat_split_legitimate (operands[0], operands[1])"
- [(set (match_dup 2) (abs:SF (match_dup 3)))
- (set (match_dup 4) (match_dup 5))]
- "if (GET_CODE (operands[0]) == SUBREG)
- operands[0] = alter_subreg (operands[0]);
- if (GET_CODE (operands[1]) == SUBREG)
- operands[1] = alter_subreg (operands[1]);
- operands[2] = gen_rtx_raw_REG (SFmode, REGNO (operands[0]));
- operands[3] = gen_rtx_raw_REG (SFmode, REGNO (operands[1]));
- operands[4] = gen_rtx_raw_REG (SFmode, REGNO (operands[0]) + 1);
- operands[5] = gen_rtx_raw_REG (SFmode, REGNO (operands[1]) + 1);")
-
-(define_insn "*absdf2_v9"
- [(set (match_operand:DF 0 "register_operand" "=e")
- (abs:DF (match_operand:DF 1 "register_operand" "e")))]
- "TARGET_FPU && TARGET_V9"
- "fabsd\\t%1, %0"
- [(set_attr "type" "fpmove")
- (set_attr "length" "1")])
-
-(define_insn "abssf2"
- [(set (match_operand:SF 0 "register_operand" "=f")
- (abs:SF (match_operand:SF 1 "register_operand" "f")))]
- "TARGET_FPU"
- "fabss\\t%1, %0"
- [(set_attr "type" "fpmove")
- (set_attr "length" "1")])
-
-(define_insn "sqrttf2"
- [(set (match_operand:TF 0 "register_operand" "=e")
- (sqrt:TF (match_operand:TF 1 "register_operand" "e")))]
- "TARGET_FPU && TARGET_HARD_QUAD"
- "fsqrtq\\t%1, %0"
- [(set_attr "type" "fpsqrt")
- (set_attr "length" "1")])
-
-(define_insn "sqrtdf2"
- [(set (match_operand:DF 0 "register_operand" "=e")
- (sqrt:DF (match_operand:DF 1 "register_operand" "e")))]
- "TARGET_FPU"
- "fsqrtd\\t%1, %0"
- [(set_attr "type" "fpsqrt")
- (set_attr "length" "1")])
-
-(define_insn "sqrtsf2"
- [(set (match_operand:SF 0 "register_operand" "=f")
- (sqrt:SF (match_operand:SF 1 "register_operand" "f")))]
- "TARGET_FPU"
- "fsqrts\\t%1, %0"
- [(set_attr "type" "fpsqrt")
- (set_attr "length" "1")])
-
-;;- arithmetic shift instructions
-
-(define_insn "ashlsi3"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (ashift:SI (match_operand:SI 1 "register_operand" "r")
- (match_operand:SI 2 "arith_operand" "rI")))]
- ""
- "*
-{
- if (GET_CODE (operands[2]) == CONST_INT
- && (unsigned HOST_WIDE_INT) INTVAL (operands[2]) > 31)
- operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
-
- return \"sll\\t%1, %2, %0\";
-}"
- [(set_attr "type" "shift")
- (set_attr "length" "1")])
-
-;; We special case multiplication by two, as add can be done
-;; in both ALUs, while shift only in IEU0 on UltraSPARC.
-(define_insn "*ashlsi3_const1"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (ashift:SI (match_operand:SI 1 "register_operand" "r")
- (const_int 1)))]
- ""
- "add\\t%1, %1, %0"
- [(set_attr "type" "binary")
- (set_attr "length" "1")])
-
-(define_expand "ashldi3"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (ashift:DI (match_operand:DI 1 "register_operand" "r")
- (match_operand:SI 2 "arith_operand" "rI")))]
- "TARGET_ARCH64 || TARGET_V8PLUS"
- "
-{
- if (! TARGET_ARCH64)
- {
- if (GET_CODE (operands[2]) == CONST_INT)
- FAIL;
- emit_insn (gen_ashldi3_v8plus (operands[0], operands[1], operands[2]));
- DONE;
- }
-}")
-
-;; We special case multiplication by two, as add can be done
-;; in both ALUs, while shift only in IEU0 on UltraSPARC.
-(define_insn "*ashldi3_const1"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (ashift:DI (match_operand:DI 1 "register_operand" "r")
- (const_int 1)))]
- "TARGET_ARCH64"
- "add\\t%1, %1, %0"
- [(set_attr "type" "binary")
- (set_attr "length" "1")])
-
-(define_insn "*ashldi3_sp64"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (ashift:DI (match_operand:DI 1 "register_operand" "r")
- (match_operand:SI 2 "arith_operand" "rI")))]
- "TARGET_ARCH64"
- "*
-{
- if (GET_CODE (operands[2]) == CONST_INT
- && (unsigned HOST_WIDE_INT) INTVAL (operands[2]) > 63)
- operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
-
- return \"sllx\\t%1, %2, %0\";
-}"
- [(set_attr "type" "shift")
- (set_attr "length" "1")])
-
-;; XXX UGH!
-(define_insn "ashldi3_v8plus"
- [(set (match_operand:DI 0 "register_operand" "=&h,&h,r")
- (ashift:DI (match_operand:DI 1 "arith_operand" "rI,0,rI")
- (match_operand:SI 2 "arith_operand" "rI,rI,rI")))
- (clobber (match_scratch:SI 3 "=X,X,&h"))]
- "TARGET_V8PLUS"
- "*return sparc_v8plus_shift (operands, insn, \"sllx\");"
- [(set_attr "length" "5,5,6")])
-
-;; Optimize (1LL<<x)-1
-;; XXX this also needs to be fixed to handle equal subregs
-;; XXX first before we could re-enable it.
-(define_insn ""
- [(set (match_operand:DI 0 "register_operand" "=h")
- (plus:DI (ashift:DI (const_int 1)
- (match_operand:SI 2 "arith_operand" "rI"))
- (const_int -1)))]
- "0 && TARGET_V8PLUS"
- "*
-{
- if (GET_CODE (operands[2]) == REG && REGNO (operands[2]) == REGNO (operands[0]))
- return \"mov 1,%L0\;sllx %L0,%2,%L0\;sub %L0,1,%L0\;srlx %L0,32,%H0\";
- return \"mov 1,%H0\;sllx %H0,%2,%L0\;sub %L0,1,%L0\;srlx %L0,32,%H0\";
-}"
- [(set_attr "length" "4")])
-
-(define_insn "*cmp_cc_ashift_1"
- [(set (reg:CC_NOOV 100)
- (compare:CC_NOOV (ashift:SI (match_operand:SI 0 "register_operand" "r")
- (const_int 1))
- (const_int 0)))]
- "! TARGET_LIVE_G0"
- "addcc\\t%0, %0, %%g0"
- [(set_attr "type" "compare")
- (set_attr "length" "1")])
-
-(define_insn "*cmp_cc_set_ashift_1"
- [(set (reg:CC_NOOV 100)
- (compare:CC_NOOV (ashift:SI (match_operand:SI 1 "register_operand" "r")
- (const_int 1))
- (const_int 0)))
- (set (match_operand:SI 0 "register_operand" "=r")
- (ashift:SI (match_dup 1) (const_int 1)))]
- ""
- "addcc\\t%1, %1, %0"
- [(set_attr "type" "compare")
- (set_attr "length" "1")])
-
-(define_insn "ashrsi3"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (ashiftrt:SI (match_operand:SI 1 "register_operand" "r")
- (match_operand:SI 2 "arith_operand" "rI")))]
- ""
- "*
-{
- if (GET_CODE (operands[2]) == CONST_INT
- && (unsigned HOST_WIDE_INT) INTVAL (operands[2]) > 31)
- operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
-
- return \"sra\\t%1, %2, %0\";
-}"
- [(set_attr "type" "shift")
- (set_attr "length" "1")])
-
-(define_insn "*ashrsi3_extend"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (sign_extend:DI (ashiftrt:SI (match_operand:SI 1 "register_operand" "r")
- (match_operand:SI 2 "arith_operand" "r"))))]
- "TARGET_ARCH64"
- "sra\\t%1, %2, %0"
- [(set_attr "type" "shift")
- (set_attr "length" "1")])
-
-;; This handles the case as above, but with constant shift instead of
-;; register. Combiner "simplifies" it for us a little bit though.
-(define_insn "*ashrsi3_extend2"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (ashiftrt:DI (ashift:DI (subreg:DI (match_operand:SI 1 "register_operand" "r") 0)
- (const_int 32))
- (match_operand:SI 2 "small_int_or_double" "n")))]
- "TARGET_ARCH64
- && ((GET_CODE (operands[2]) == CONST_INT
- && INTVAL (operands[2]) >= 32 && INTVAL (operands[2]) < 64)
- || (GET_CODE (operands[2]) == CONST_DOUBLE
- && !CONST_DOUBLE_HIGH (operands[2])
- && CONST_DOUBLE_LOW (operands[2]) >= 32
- && CONST_DOUBLE_LOW (operands[2]) < 64))"
- "*
-{
- operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
-
- return \"sra\\t%1, %2, %0\";
-}"
- [(set_attr "type" "shift")
- (set_attr "length" "1")])
-
-(define_expand "ashrdi3"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (ashiftrt:DI (match_operand:DI 1 "register_operand" "r")
- (match_operand:SI 2 "arith_operand" "rI")))]
- "TARGET_ARCH64 || TARGET_V8PLUS"
- "
-{
- if (! TARGET_ARCH64)
- {
- if (GET_CODE (operands[2]) == CONST_INT)
- FAIL; /* prefer generic code in this case */
- emit_insn (gen_ashrdi3_v8plus (operands[0], operands[1], operands[2]));
- DONE;
- }
-}")
-
-(define_insn ""
- [(set (match_operand:DI 0 "register_operand" "=r")
- (ashiftrt:DI (match_operand:DI 1 "register_operand" "r")
- (match_operand:SI 2 "arith_operand" "rI")))]
- "TARGET_ARCH64"
- "*
-{
- if (GET_CODE (operands[2]) == CONST_INT
- && (unsigned HOST_WIDE_INT) INTVAL (operands[2]) > 63)
- operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
-
- return \"srax\\t%1, %2, %0\";
-}"
- [(set_attr "type" "shift")
- (set_attr "length" "1")])
-
-;; XXX
-(define_insn "ashrdi3_v8plus"
- [(set (match_operand:DI 0 "register_operand" "=&h,&h,r")
- (ashiftrt:DI (match_operand:DI 1 "arith_operand" "rI,0,rI")
- (match_operand:SI 2 "arith_operand" "rI,rI,rI")))
- (clobber (match_scratch:SI 3 "=X,X,&h"))]
- "TARGET_V8PLUS"
- "*return sparc_v8plus_shift (operands, insn, \"srax\");"
- [(set_attr "length" "5,5,6")])
-
-(define_insn "lshrsi3"
- [(set (match_operand:SI 0 "register_operand" "=r")
- (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
- (match_operand:SI 2 "arith_operand" "rI")))]
- ""
- "*
-{
- if (GET_CODE (operands[2]) == CONST_INT
- && (unsigned HOST_WIDE_INT) INTVAL (operands[2]) > 31)
- operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f);
-
- return \"srl\\t%1, %2, %0\";
-}"
- [(set_attr "type" "shift")
- (set_attr "length" "1")])
-
-;; This handles the case where
-;; (zero_extend:DI (lshiftrt:SI (match_operand:SI) (match_operand:SI))),
-;; but combiner "simplifies" it for us.
-(define_insn "*lshrsi3_extend"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (and:DI (subreg:DI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
- (match_operand:SI 2 "arith_operand" "r")) 0)
- (match_operand 3 "" "")))]
- "TARGET_ARCH64
- && ((GET_CODE (operands[3]) == CONST_DOUBLE
- && CONST_DOUBLE_HIGH (operands[3]) == 0
- && CONST_DOUBLE_LOW (operands[3]) == 0xffffffff)
-#if HOST_BITS_PER_WIDE_INT >= 64
- || (GET_CODE (operands[3]) == CONST_INT
- && (unsigned HOST_WIDE_INT) INTVAL (operands[3]) == 0xffffffff)
-#endif
- )"
- "srl\\t%1, %2, %0"
- [(set_attr "type" "shift")
- (set_attr "length" "1")])
-
-;; This handles the case where
-;; (lshiftrt:DI (zero_extend:DI (match_operand:SI)) (const_int >=0 < 32))
-;; but combiner "simplifies" it for us.
-(define_insn "*lshrsi3_extend2"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (zero_extract:DI (subreg:DI (match_operand:SI 1 "register_operand" "r") 0)
- (match_operand 2 "small_int_or_double" "n")
- (const_int 32)))]
- "TARGET_ARCH64
- && ((GET_CODE (operands[2]) == CONST_INT
- && (unsigned HOST_WIDE_INT) INTVAL (operands[2]) < 32)
- || (GET_CODE (operands[2]) == CONST_DOUBLE
- && CONST_DOUBLE_HIGH (operands[2]) == 0
- && (unsigned HOST_WIDE_INT) CONST_DOUBLE_LOW (operands[2]) < 32))"
- "*
-{
- operands[2] = GEN_INT (32 - INTVAL (operands[2]));
-
- return \"srl\\t%1, %2, %0\";
-}"
- [(set_attr "type" "shift")
- (set_attr "length" "1")])
-
-(define_expand "lshrdi3"
- [(set (match_operand:DI 0 "register_operand" "=r")
- (lshiftrt:DI (match_operand:DI 1 "register_operand" "r")
- (match_operand:SI 2 "arith_operand" "rI")))]
- "TARGET_ARCH64 || TARGET_V8PLUS"
- "
-{
- if (! TARGET_ARCH64)
- {
- if (GET_CODE (operands[2]) == CONST_INT)
- FAIL;
- emit_insn (gen_lshrdi3_v8plus (operands[0], operands[1], operands[2]));
- DONE;
- }
-}")
-
-(define_insn ""
- [(set (match_operand:DI 0 "register_operand" "=r")
- (lshiftrt:DI (match_operand:DI 1 "register_operand" "r")
- (match_operand:SI 2 "arith_operand" "rI")))]
- "TARGET_ARCH64"
- "*
-{
- if (GET_CODE (operands[2]) == CONST_INT
- && (unsigned HOST_WIDE_INT) INTVAL (operands[2]) > 63)
- operands[2] = GEN_INT (INTVAL (operands[2]) & 0x3f);
-
- return \"srlx\\t%1, %2, %0\";
-}"
- [(set_attr "type" "shift")
- (set_attr "length" "1")])
-
-;; XXX
-(define_insn "lshrdi3_v8plus"
- [(set (match_operand:DI 0 "register_operand" "=&h,&h,r")
- (lshiftrt:DI (match_operand:DI 1 "arith_operand" "rI,0,rI")
- (match_operand:SI 2 "arith_operand" "rI,rI,rI")))
- (clobber (match_scratch:SI 3 "=X,X,&h"))]
- "TARGET_V8PLUS"
- "*return sparc_v8plus_shift (operands, insn, \"srlx\");"
- [(set_attr "length" "5,5,6")])
-
-;; Unconditional and other jump instructions
-;; On the Sparc, by setting the annul bit on an unconditional branch, the
-;; following insn is never executed. This saves us a nop. Dbx does not
-;; handle such branches though, so we only use them when optimizing.
-(define_insn "jump"
- [(set (pc) (label_ref (match_operand 0 "" "")))]
- ""
- "*
-{
- /* TurboSparc is reported to have problems with
- with
- foo: b,a foo
- i.e. an empty loop with the annul bit set. The workaround is to use
- foo: b foo; nop
- instead. */
-
- if (! TARGET_V9 && flag_delayed_branch
- && (insn_addresses[INSN_UID (operands[0])]
- == insn_addresses[INSN_UID (insn)]))
- return \"b\\t%l0%#\";
- else
- return TARGET_V9 ? \"ba,pt%*\\t%%xcc, %l0%(\" : \"b%*\\t%l0%(\";
-}"
- [(set_attr "type" "uncond_branch")])
-
-(define_expand "tablejump"
- [(parallel [(set (pc) (match_operand 0 "register_operand" "r"))
- (use (label_ref (match_operand 1 "" "")))])]
- ""
- "
-{
- if (GET_MODE (operands[0]) != CASE_VECTOR_MODE)
- abort ();
-
- /* In pic mode, our address differences are against the base of the
- table. Add that base value back in; CSE ought to be able to combine
- the two address loads. */
- if (flag_pic)
- {
- rtx tmp, tmp2;
- tmp = gen_rtx_LABEL_REF (Pmode, operands[1]);
- tmp2 = operands[0];
- if (CASE_VECTOR_MODE != Pmode)
- tmp2 = gen_rtx_SIGN_EXTEND (Pmode, tmp2);
- tmp = gen_rtx_PLUS (Pmode, tmp2, tmp);
- operands[0] = memory_address (Pmode, tmp);
- }
-}")
-
-(define_insn "*tablejump_sp32"
- [(set (pc) (match_operand:SI 0 "address_operand" "p"))
- (use (label_ref (match_operand 1 "" "")))]
- "! TARGET_PTR64"
- "jmp\\t%a0%#"
- [(set_attr "type" "uncond_branch")])
-
-(define_insn "*tablejump_sp64"
- [(set (pc) (match_operand:DI 0 "address_operand" "p"))
- (use (label_ref (match_operand 1 "" "")))]
- "TARGET_PTR64"
- "jmp\\t%a0%#"
- [(set_attr "type" "uncond_branch")])
-
-;; This pattern recognizes the "instruction" that appears in
-;; a function call that wants a structure value,
-;; to inform the called function if compiled with Sun CC.
-;(define_insn "*unimp_insn"
-; [(match_operand:SI 0 "immediate_operand" "")]
-; "GET_CODE (operands[0]) == CONST_INT && INTVAL (operands[0]) > 0"
-; "unimp\\t%0"
-; [(set_attr "type" "marker")])
-
-;;- jump to subroutine
-(define_expand "call"
- ;; Note that this expression is not used for generating RTL.
- ;; All the RTL is generated explicitly below.
- [(call (match_operand 0 "call_operand" "")
- (match_operand 3 "" "i"))]
- ;; operands[2] is next_arg_register
- ;; operands[3] is struct_value_size_rtx.
- ""
- "
-{
- rtx fn_rtx, nregs_rtx;
-
- if (GET_MODE (operands[0]) != FUNCTION_MODE)
- abort ();
-
- if (GET_CODE (XEXP (operands[0], 0)) == LABEL_REF)
- {
- /* This is really a PIC sequence. We want to represent
- it as a funny jump so its delay slots can be filled.
-
- ??? But if this really *is* a CALL, will not it clobber the
- call-clobbered registers? We lose this if it is a JUMP_INSN.
- Why cannot we have delay slots filled if it were a CALL? */
-
- if (! TARGET_ARCH64 && INTVAL (operands[3]) != 0)
- emit_jump_insn
- (gen_rtx_PARALLEL (VOIDmode,
- gen_rtvec (3,
- gen_rtx_SET (VOIDmode, pc_rtx,
- XEXP (operands[0], 0)),
- operands[3],
- gen_rtx_CLOBBER (VOIDmode,
- gen_rtx_REG (Pmode, 15)))));
- else
- emit_jump_insn
- (gen_rtx_PARALLEL (VOIDmode,
- gen_rtvec (2,
- gen_rtx_SET (VOIDmode, pc_rtx,
- XEXP (operands[0], 0)),
- gen_rtx_CLOBBER (VOIDmode,
- gen_rtx_REG (Pmode, 15)))));
- goto finish_call;
- }
-
- fn_rtx = operands[0];
-
- /* Count the number of parameter registers being used by this call.
- if that argument is NULL, it means we are using them all, which
- means 6 on the sparc. */
-#if 0
- if (operands[2])
- nregs_rtx = GEN_INT (REGNO (operands[2]) - 8);
- else
- nregs_rtx = GEN_INT (6);
-#else
- nregs_rtx = const0_rtx;
-#endif
-
- if (! TARGET_ARCH64 && INTVAL (operands[3]) != 0)
- emit_call_insn
- (gen_rtx_PARALLEL (VOIDmode,
- gen_rtvec (3, gen_rtx_CALL (VOIDmode, fn_rtx, nregs_rtx),
- operands[3],
- gen_rtx_CLOBBER (VOIDmode,
- gen_rtx_REG (Pmode, 15)))));
- else
- emit_call_insn
- (gen_rtx_PARALLEL (VOIDmode,
- gen_rtvec (2, gen_rtx_CALL (VOIDmode, fn_rtx, nregs_rtx),
- gen_rtx_CLOBBER (VOIDmode,
- gen_rtx_REG (Pmode, 15)))));
-
- finish_call:
-#if 0
- /* If this call wants a structure value,
- emit an unimp insn to let the called function know about this. */
- if (! TARGET_ARCH64 && INTVAL (operands[3]) > 0)
- {
- rtx insn = emit_insn (operands[3]);
- SCHED_GROUP_P (insn) = 1;
- }
-#endif
-
- DONE;
-}")
-
-;; We can't use the same pattern for these two insns, because then registers
-;; in the address may not be properly reloaded.
-
-(define_insn "*call_address_sp32"
- [(call (mem:SI (match_operand:SI 0 "address_operand" "p"))
- (match_operand 1 "" ""))
- (clobber (reg:SI 15))]
- ;;- Do not use operand 1 for most machines.
- "! TARGET_PTR64"
- "call\\t%a0, %1%#"
- [(set_attr "type" "call")])
-
-(define_insn "*call_symbolic_sp32"
- [(call (mem:SI (match_operand:SI 0 "symbolic_operand" "s"))
- (match_operand 1 "" ""))
- (clobber (reg:SI 15))]
- ;;- Do not use operand 1 for most machines.
- "! TARGET_PTR64"
- "call\\t%a0, %1%#"
- [(set_attr "type" "call")])
-
-(define_insn "*call_address_sp64"
- [(call (mem:SI (match_operand:DI 0 "address_operand" "p"))
- (match_operand 1 "" ""))
- (clobber (reg:DI 15))]
- ;;- Do not use operand 1 for most machines.
- "TARGET_PTR64"
- "call\\t%a0, %1%#"
- [(set_attr "type" "call")])
-
-(define_insn "*call_symbolic_sp64"
- [(call (mem:SI (match_operand:DI 0 "symbolic_operand" "s"))
- (match_operand 1 "" ""))
- (clobber (reg:DI 15))]
- ;;- Do not use operand 1 for most machines.
- "TARGET_PTR64"
- "call\\t%a0, %1%#"
- [(set_attr "type" "call")])
-
-;; This is a call that wants a structure value.
-;; There is no such critter for v9 (??? we may need one anyway).
-(define_insn "*call_address_struct_value_sp32"
- [(call (mem:SI (match_operand:SI 0 "address_operand" "p"))
- (match_operand 1 "" ""))
- (match_operand 2 "immediate_operand" "")
- (clobber (reg:SI 15))]
- ;;- Do not use operand 1 for most machines.
- "! TARGET_ARCH64 && GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 0"
- "call\\t%a0, %1\\n\\tnop\\n\\tunimp\\t%2"
- [(set_attr "type" "call_no_delay_slot")])
-
-;; This is a call that wants a structure value.
-;; There is no such critter for v9 (??? we may need one anyway).
-(define_insn "*call_symbolic_struct_value_sp32"
- [(call (mem:SI (match_operand:SI 0 "symbolic_operand" "s"))
- (match_operand 1 "" ""))
- (match_operand 2 "immediate_operand" "")
- (clobber (reg:SI 15))]
- ;;- Do not use operand 1 for most machines.
- "! TARGET_ARCH64 && GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 0"
- "call\\t%a0, %1\\n\\tnop\\n\\tunimp\\t%2"
- [(set_attr "type" "call_no_delay_slot")])
-
-;; This is a call that may want a structure value. This is used for
-;; untyped_calls.
-(define_insn "*call_address_untyped_struct_value_sp32"
- [(call (mem:SI (match_operand:SI 0 "address_operand" "p"))
- (match_operand 1 "" ""))
- (match_operand 2 "immediate_operand" "")
- (clobber (reg:SI 15))]
- ;;- Do not use operand 1 for most machines.
- "! TARGET_ARCH64 && GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < 0"
- "call\\t%a0, %1\\n\\tnop\\n\\tnop"
- [(set_attr "type" "call_no_delay_slot")])
-
-;; This is a call that wants a structure value.
-(define_insn "*call_symbolic_untyped_struct_value_sp32"
- [(call (mem:SI (match_operand:SI 0 "symbolic_operand" "s"))
- (match_operand 1 "" ""))
- (match_operand 2 "immediate_operand" "")
- (clobber (reg:SI 15))]
- ;;- Do not use operand 1 for most machines.
- "! TARGET_ARCH64 && GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) < 0"
- "call\\t%a0, %1\\n\\tnop\\n\\tnop"
- [(set_attr "type" "call_no_delay_slot")])
-
-(define_expand "call_value"
- ;; Note that this expression is not used for generating RTL.
- ;; All the RTL is generated explicitly below.
- [(set (match_operand 0 "register_operand" "=rf")
- (call (match_operand:SI 1 "" "")
- (match_operand 4 "" "")))]
- ;; operand 2 is stack_size_rtx
- ;; operand 3 is next_arg_register
- ""
- "
-{
- rtx fn_rtx, nregs_rtx;
- rtvec vec;
-
- if (GET_MODE (operands[1]) != FUNCTION_MODE)
- abort ();
-
- fn_rtx = operands[1];
-
-#if 0
- if (operands[3])
- nregs_rtx = GEN_INT (REGNO (operands[3]) - 8);
- else
- nregs_rtx = GEN_INT (6);
-#else
- nregs_rtx = const0_rtx;
-#endif
-
- vec = gen_rtvec (2,
- gen_rtx_SET (VOIDmode, operands[0],
- gen_rtx_CALL (VOIDmode, fn_rtx, nregs_rtx)),
- gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (Pmode, 15)));
-
- emit_call_insn (gen_rtx_PARALLEL (VOIDmode, vec));
-
- DONE;
-}")
-
-(define_insn "*call_value_address_sp32"
- [(set (match_operand 0 "" "=rf")
- (call (mem:SI (match_operand:SI 1 "address_operand" "p"))
- (match_operand 2 "" "")))
- (clobber (reg:SI 15))]
- ;;- Do not use operand 2 for most machines.
- "! TARGET_PTR64"
- "call\\t%a1, %2%#"
- [(set_attr "type" "call")])
-
-(define_insn "*call_value_symbolic_sp32"
- [(set (match_operand 0 "" "=rf")
- (call (mem:SI (match_operand:SI 1 "symbolic_operand" "s"))
- (match_operand 2 "" "")))
- (clobber (reg:SI 15))]
- ;;- Do not use operand 2 for most machines.
- "! TARGET_PTR64"
- "call\\t%a1, %2%#"
- [(set_attr "type" "call")])
-
-(define_insn "*call_value_address_sp64"
- [(set (match_operand 0 "" "")
- (call (mem:SI (match_operand:DI 1 "address_operand" "p"))
- (match_operand 2 "" "")))
- (clobber (reg:DI 15))]
- ;;- Do not use operand 2 for most machines.
- "TARGET_PTR64"
- "call\\t%a1, %2%#"
- [(set_attr "type" "call")])
-
-(define_insn "*call_value_symbolic_sp64"
- [(set (match_operand 0 "" "")
- (call (mem:SI (match_operand:DI 1 "symbolic_operand" "s"))
- (match_operand 2 "" "")))
- (clobber (reg:DI 15))]
- ;;- Do not use operand 2 for most machines.
- "TARGET_PTR64"
- "call\\t%a1, %2%#"
- [(set_attr "type" "call")])
-
-(define_expand "untyped_call"
- [(parallel [(call (match_operand 0 "" "")
- (const_int 0))
- (match_operand 1 "" "")
- (match_operand 2 "" "")])]
- ""
- "
-{
- int i;
-
- /* Pass constm1 to indicate that it may expect a structure value, but
- we don't know what size it is. */
- emit_call_insn (gen_call (operands[0], const0_rtx, NULL, constm1_rtx));
-
- for (i = 0; i < XVECLEN (operands[2], 0); i++)
- {
- rtx set = XVECEXP (operands[2], 0, i);
- emit_move_insn (SET_DEST (set), SET_SRC (set));
- }
-
- /* The optimizer does not know that the call sets the function value
- registers we stored in the result block. We avoid problems by
- claiming that all hard registers are used and clobbered at this
- point. */
- emit_insn (gen_blockage ());
-
- DONE;
-}")
-
-;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
-;; all of memory. This blocks insns from being moved across this point.
-
-(define_insn "blockage"
- [(unspec_volatile [(const_int 0)] 0)]
- ""
- ""
- [(set_attr "length" "0")])
-
-;; Prepare to return any type including a structure value.
-
-(define_expand "untyped_return"
- [(match_operand:BLK 0 "memory_operand" "")
- (match_operand 1 "" "")]
- ""
- "
-{
- rtx valreg1 = gen_rtx_REG (DImode, 24);
- rtx valreg2 = gen_rtx_REG (TARGET_ARCH64 ? TFmode : DFmode, 32);
- rtx result = operands[0];
-
- if (! TARGET_ARCH64)
- {
- rtx rtnreg = gen_rtx_REG (SImode, (current_function_uses_only_leaf_regs
- ? 15 : 31));
- rtx value = gen_reg_rtx (SImode);
-
- /* Fetch the instruction where we will return to and see if it's an unimp
- instruction (the most significant 10 bits will be zero). If so,
- update the return address to skip the unimp instruction. */
- emit_move_insn (value,
- gen_rtx_MEM (SImode, plus_constant (rtnreg, 8)));
- emit_insn (gen_lshrsi3 (value, value, GEN_INT (22)));
- emit_insn (gen_update_return (rtnreg, value));
- }
-
- /* Reload the function value registers. */
- emit_move_insn (valreg1, change_address (result, DImode, XEXP (result, 0)));
- emit_move_insn (valreg2,
- change_address (result, TARGET_ARCH64 ? TFmode : DFmode,
- plus_constant (XEXP (result, 0), 8)));
-
- /* Put USE insns before the return. */
- emit_insn (gen_rtx_USE (VOIDmode, valreg1));
- emit_insn (gen_rtx_USE (VOIDmode, valreg2));
-
- /* Construct the return. */
- expand_null_return ();
-
- DONE;
-}")
-
-;; This is a bit of a hack. We're incrementing a fixed register (%i7),
-;; and parts of the compiler don't want to believe that the add is needed.
-
-(define_insn "update_return"
- [(unspec:SI [(match_operand:SI 0 "register_operand" "r")
- (match_operand:SI 1 "register_operand" "r")] 1)]
- "! TARGET_ARCH64"
- "cmp %1,0\;be,a .+8\;add %0,4,%0"
- [(set_attr "type" "multi")])
-
-(define_insn "return"
- [(return)
- (use (reg:SI 31))]
- "! TARGET_EPILOGUE"
- "* return output_return (operands);"
- [(set_attr "type" "return")])
-
-(define_peephole
- [(set (match_operand:SI 0 "register_operand" "=r")
- (match_operand:SI 1 "arith_operand" "rI"))
- (parallel [(return)
- (use (reg:SI 31))])]
- "sparc_return_peephole_ok (operands[0], operands[1])"
- "return\\t%%i7+8\\n\\tmov\\t%Y1, %Y0")
-
-(define_insn "nop"
- [(const_int 0)]
- ""
- "nop"
- [(set_attr "type" "ialu")
- (set_attr "length" "1")])
-
-(define_expand "indirect_jump"
- [(set (pc) (match_operand 0 "address_operand" "p"))]
- ""
- "")
-
-(define_insn "*branch_sp32"
- [(set (pc) (match_operand:SI 0 "address_operand" "p"))]
- "! TARGET_PTR64"
- "jmp\\t%a0%#"
- [(set_attr "type" "uncond_branch")])
-
-(define_insn "*branch_sp64"
- [(set (pc) (match_operand:DI 0 "address_operand" "p"))]
- "TARGET_PTR64"
- "jmp\\t%a0%#"
- [(set_attr "type" "uncond_branch")])
-
-;; ??? Doesn't work with -mflat.
-(define_expand "nonlocal_goto"
- [(match_operand:SI 0 "general_operand" "")
- (match_operand:SI 1 "general_operand" "")
- (match_operand:SI 2 "general_operand" "")
- (match_operand:SI 3 "" "")]
- ""
- "
-{
-#if 0
- rtx chain = operands[0];
-#endif
- rtx fp = operands[1];
- rtx stack = operands[2];
- rtx lab = operands[3];
- rtx labreg;
-
- /* Trap instruction to flush all the register windows. */
- emit_insn (gen_flush_register_windows ());
-
- /* Load the fp value for the containing fn into %fp. This is needed
- because STACK refers to %fp. Note that virtual register instantiation
- fails if the virtual %fp isn't set from a register. */
- if (GET_CODE (fp) != REG)
- fp = force_reg (Pmode, fp);
- emit_move_insn (virtual_stack_vars_rtx, fp);
-
- /* Find the containing function's current nonlocal goto handler,
- which will do any cleanups and then jump to the label. */
- labreg = gen_rtx_REG (Pmode, 8);
- emit_move_insn (labreg, lab);
-
- /* Restore %fp from stack pointer value for containing function.
- The restore insn that follows will move this to %sp,
- and reload the appropriate value into %fp. */
- emit_move_insn (frame_pointer_rtx, stack);
-
- /* USE of frame_pointer_rtx added for consistency; not clear if
- really needed. */
- /*emit_insn (gen_rtx_USE (VOIDmode, frame_pointer_rtx));*/
- emit_insn (gen_rtx_USE (VOIDmode, stack_pointer_rtx));
-
-#if 0
- /* Return, restoring reg window and jumping to goto handler. */
- if (TARGET_V9 && GET_CODE (chain) == CONST_INT
- && ! (INTVAL (chain) & ~(HOST_WIDE_INT)0xffffffff))
- {
- emit_insn (gen_goto_handler_and_restore_v9 (labreg, static_chain_rtx,
- chain));
- emit_barrier ();
- DONE;
- }
- /* Put in the static chain register the nonlocal label address. */
- emit_move_insn (static_chain_rtx, chain);
-#endif
-
- emit_insn (gen_rtx_USE (VOIDmode, static_chain_rtx));
- emit_insn (gen_goto_handler_and_restore (labreg));
- emit_barrier ();
- DONE;
-}")
-
-;; Special trap insn to flush register windows.
-(define_insn "flush_register_windows"
- [(unspec_volatile [(const_int 0)] 1)]
- ""
- "* return TARGET_V9 ? \"flushw\" : \"ta\\t3\";"
- [(set_attr "type" "misc")
- (set_attr "length" "1")])
-
-(define_insn "goto_handler_and_restore"
- [(unspec_volatile [(match_operand 0 "register_operand" "=r")] 2)]
- ""
- "jmp\\t%0+0\\n\\trestore"
- [(set_attr "type" "misc")
- (set_attr "length" "2")])
-
-;;(define_insn "goto_handler_and_restore_v9"
-;; [(unspec_volatile [(match_operand:SI 0 "register_operand" "=r,r")
-;; (match_operand:SI 1 "register_operand" "=r,r")
-;; (match_operand:SI 2 "const_int_operand" "I,n")] 3)]
-;; "TARGET_V9 && ! TARGET_ARCH64"
-;; "@
-;; return\\t%0+0\\n\\tmov\\t%2, %Y1
-;; sethi\\t%%hi(%2), %1\\n\\treturn\\t%0+0\\n\\tor\\t%Y1, %%lo(%2), %Y1"
-;; [(set_attr "type" "misc")
-;; (set_attr "length" "2,3")])
-;;
-;;(define_insn "*goto_handler_and_restore_v9_sp64"
-;; [(unspec_volatile [(match_operand:DI 0 "register_operand" "=r,r")
-;; (match_operand:DI 1 "register_operand" "=r,r")
-;; (match_operand:SI 2 "const_int_operand" "I,n")] 3)]
-;; "TARGET_V9 && TARGET_ARCH64"
-;; "@
-;; return\\t%0+0\\n\\tmov\\t%2, %Y1
-;; sethi\\t%%hi(%2), %1\\n\\treturn\\t%0+0\\n\\tor\\t%Y1, %%lo(%2), %Y1"
-;; [(set_attr "type" "misc")
-;; (set_attr "length" "2,3")])
-
-;; Pattern for use after a setjmp to store FP and the return register
-;; into the stack area.
-
-(define_expand "setjmp"
- [(const_int 0)]
- ""
- "
-{
- if (TARGET_ARCH64)
- emit_insn (gen_setjmp_64 ());
- else
- emit_insn (gen_setjmp_32 ());
- DONE;
-}")
-
-(define_expand "setjmp_32"
- [(set (mem:SI (plus:SI (reg:SI 14) (const_int 56))) (match_dup 0))
- (set (mem:SI (plus:SI (reg:SI 14) (const_int 60))) (reg:SI 31))]
- ""
- "
-{ operands[0] = frame_pointer_rtx; }")
-
-(define_expand "setjmp_64"
- [(set (mem:DI (plus:DI (reg:DI 14) (const_int 112))) (match_dup 0))
- (set (mem:DI (plus:DI (reg:DI 14) (const_int 120))) (reg:DI 31))]
- ""
- "
-{ operands[0] = frame_pointer_rtx; }")
-
-;; Special pattern for the FLUSH instruction.
-
-(define_insn "flush"
- [(unspec_volatile [(match_operand 0 "memory_operand" "m")] 4)]
- ""
- "* return TARGET_V9 ? \"flush\\t%f0\" : \"iflush\\t%f0\";"
- [(set_attr "type" "misc")
- (set_attr "length" "1")])
-
-;; find first set.
-
-;; The scan instruction searches from the most significant bit while ffs
-;; searches from the least significant bit. The bit index and treatment of
-;; zero also differ. It takes at least 7 instructions to get the proper
-;; result. Here is an obvious 8 instruction sequence.
-
-;; XXX
-(define_insn "ffssi2"
- [(set (match_operand:SI 0 "register_operand" "=&r")
- (ffs:SI (match_operand:SI 1 "register_operand" "r")))
- (clobber (match_scratch:SI 2 "=&r"))]
- "TARGET_SPARCLITE || TARGET_SPARCLET"
- "*
-{
- if (TARGET_LIVE_G0)
- output_asm_insn (\"and %%g0,0,%%g0\", operands);
- return \"sub %%g0,%1,%0\;and %0,%1,%0\;scan %0,0,%0\;mov 32,%2\;sub %2,%0,%0\;sra %0,31,%2\;and %2,31,%2\;add %2,%0,%0\";
-}"
- [(set_attr "type" "multi")
- (set_attr "length" "8")])
-
-;; ??? This should be a define expand, so that the extra instruction have
-;; a chance of being optimized away.
-
-;; Disabled because none of the UltraSparcs implement popc. The HAL R1
-;; does, but no one uses that and we don't have a switch for it.
-;
-;(define_insn "ffsdi2"
-; [(set (match_operand:DI 0 "register_operand" "=&r")
-; (ffs:DI (match_operand:DI 1 "register_operand" "r")))
-; (clobber (match_scratch:DI 2 "=&r"))]
-; "TARGET_ARCH64"
-; "neg %1,%2\;xnor %1,%2,%2\;popc %2,%0\;movzr %1,0,%0"
-; [(set_attr "type" "multi")
-; (set_attr "length" "4")])
-
-
-;; Peepholes go at the end.
-
-;; Optimize consecutive loads or stores into ldd and std when possible.
-;; The conditions in which we do this are very restricted and are
-;; explained in the code for {registers,memory}_ok_for_ldd functions.
-
-(define_peephole
- [(set (match_operand:SI 0 "memory_operand" "")
- (const_int 0))
- (set (match_operand:SI 1 "memory_operand" "")
- (const_int 0))]
- "TARGET_V9
- && ! MEM_VOLATILE_P (operands[0])
- && ! MEM_VOLATILE_P (operands[1])
- && addrs_ok_for_ldd_peep (XEXP (operands[0], 0), XEXP (operands[1], 0))"
- "stx\\t%%g0, %0")
-
-(define_peephole
- [(set (match_operand:SI 0 "memory_operand" "")
- (const_int 0))
- (set (match_operand:SI 1 "memory_operand" "")
- (const_int 0))]
- "TARGET_V9
- && ! MEM_VOLATILE_P (operands[0])
- && ! MEM_VOLATILE_P (operands[1])
- && addrs_ok_for_ldd_peep (XEXP (operands[1], 0), XEXP (operands[0], 0))"
- "stx\\t%%g0, %1")
-
-(define_peephole
- [(set (match_operand:SI 0 "register_operand" "=rf")
- (match_operand:SI 1 "memory_operand" ""))
- (set (match_operand:SI 2 "register_operand" "=rf")
- (match_operand:SI 3 "memory_operand" ""))]
- "registers_ok_for_ldd_peep (operands[0], operands[2])
- && ! MEM_VOLATILE_P (operands[1])
- && ! MEM_VOLATILE_P (operands[3])
- && addrs_ok_for_ldd_peep (XEXP (operands[1], 0), XEXP (operands[3], 0))"
- "ldd\\t%1, %0")
-
-(define_peephole
- [(set (match_operand:SI 0 "memory_operand" "")
- (match_operand:SI 1 "register_operand" "rf"))
- (set (match_operand:SI 2 "memory_operand" "")
- (match_operand:SI 3 "register_operand" "rf"))]
- "registers_ok_for_ldd_peep (operands[1], operands[3])
- && ! MEM_VOLATILE_P (operands[0])
- && ! MEM_VOLATILE_P (operands[2])
- && addrs_ok_for_ldd_peep (XEXP (operands[0], 0), XEXP (operands[2], 0))"
- "std\\t%1, %0")
-
-(define_peephole
- [(set (match_operand:SF 0 "register_operand" "=fr")
- (match_operand:SF 1 "memory_operand" ""))
- (set (match_operand:SF 2 "register_operand" "=fr")
- (match_operand:SF 3 "memory_operand" ""))]
- "registers_ok_for_ldd_peep (operands[0], operands[2])
- && ! MEM_VOLATILE_P (operands[1])
- && ! MEM_VOLATILE_P (operands[3])
- && addrs_ok_for_ldd_peep (XEXP (operands[1], 0), XEXP (operands[3], 0))"
- "ldd\\t%1, %0")
-
-(define_peephole
- [(set (match_operand:SF 0 "memory_operand" "")
- (match_operand:SF 1 "register_operand" "fr"))
- (set (match_operand:SF 2 "memory_operand" "")
- (match_operand:SF 3 "register_operand" "fr"))]
- "registers_ok_for_ldd_peep (operands[1], operands[3])
- && ! MEM_VOLATILE_P (operands[0])
- && ! MEM_VOLATILE_P (operands[2])
- && addrs_ok_for_ldd_peep (XEXP (operands[0], 0), XEXP (operands[2], 0))"
- "std\\t%1, %0")
-
-(define_peephole
- [(set (match_operand:SI 0 "register_operand" "=rf")
- (match_operand:SI 1 "memory_operand" ""))
- (set (match_operand:SI 2 "register_operand" "=rf")
- (match_operand:SI 3 "memory_operand" ""))]
- "registers_ok_for_ldd_peep (operands[2], operands[0])
- && ! MEM_VOLATILE_P (operands[3])
- && ! MEM_VOLATILE_P (operands[1])
- && addrs_ok_for_ldd_peep (XEXP (operands[3], 0), XEXP (operands[1], 0))"
- "ldd\\t%3, %2")
-
-(define_peephole
- [(set (match_operand:SI 0 "memory_operand" "")
- (match_operand:SI 1 "register_operand" "rf"))
- (set (match_operand:SI 2 "memory_operand" "")
- (match_operand:SI 3 "register_operand" "rf"))]
- "registers_ok_for_ldd_peep (operands[3], operands[1])
- && ! MEM_VOLATILE_P (operands[2])
- && ! MEM_VOLATILE_P (operands[0])
- && addrs_ok_for_ldd_peep (XEXP (operands[2], 0), XEXP (operands[0], 0))"
- "std\\t%3, %2")
-
-(define_peephole
- [(set (match_operand:SF 0 "register_operand" "=fr")
- (match_operand:SF 1 "memory_operand" ""))
- (set (match_operand:SF 2 "register_operand" "=fr")
- (match_operand:SF 3 "memory_operand" ""))]
- "registers_ok_for_ldd_peep (operands[2], operands[0])
- && ! MEM_VOLATILE_P (operands[3])
- && ! MEM_VOLATILE_P (operands[1])
- && addrs_ok_for_ldd_peep (XEXP (operands[3], 0), XEXP (operands[1], 0))"
- "ldd\\t%3, %2")
-
-(define_peephole
- [(set (match_operand:SF 0 "memory_operand" "")
- (match_operand:SF 1 "register_operand" "fr"))
- (set (match_operand:SF 2 "memory_operand" "")
- (match_operand:SF 3 "register_operand" "fr"))]
- "registers_ok_for_ldd_peep (operands[3], operands[1])
- && ! MEM_VOLATILE_P (operands[2])
- && ! MEM_VOLATILE_P (operands[0])
- && addrs_ok_for_ldd_peep (XEXP (operands[2], 0), XEXP (operands[0], 0))"
- "std\\t%3, %2")
-
-;; Optimize the case of following a reg-reg move with a test
-;; of reg just moved. Don't allow floating point regs for operand 0 or 1.
-;; This can result from a float to fix conversion.
-
-(define_peephole
- [(set (match_operand:SI 0 "register_operand" "=r")
- (match_operand:SI 1 "register_operand" "r"))
- (set (reg:CC 100)
- (compare:CC (match_operand:SI 2 "register_operand" "r")
- (const_int 0)))]
- "(rtx_equal_p (operands[2], operands[0])
- || rtx_equal_p (operands[2], operands[1]))
- && ! FP_REG_P (operands[0])
- && ! FP_REG_P (operands[1])"
- "orcc\\t%1, 0, %0")
-
-(define_peephole
- [(set (match_operand:DI 0 "register_operand" "=r")
- (match_operand:DI 1 "register_operand" "r"))
- (set (reg:CCX 100)
- (compare:CCX (match_operand:DI 2 "register_operand" "r")
- (const_int 0)))]
- "TARGET_ARCH64
- && (rtx_equal_p (operands[2], operands[0])
- || rtx_equal_p (operands[2], operands[1]))
- && ! FP_REG_P (operands[0])
- && ! FP_REG_P (operands[1])"
- "orcc\\t%1, 0, %0")
-
-;; Return peepholes. First the "normal" ones.
-;; These are necessary to catch insns ending up in the epilogue delay list.
-
-(define_insn "*return_qi"
- [(set (match_operand:QI 0 "restore_operand" "")
- (match_operand:QI 1 "arith_operand" "rI"))
- (return)]
- "! TARGET_EPILOGUE && ! TARGET_LIVE_G0"
- "*
-{
- if (! TARGET_ARCH64 && current_function_returns_struct)
- return \"jmp\\t%%i7+12\\n\\trestore %%g0, %1, %Y0\";
- else if (TARGET_V9 && (GET_CODE (operands[1]) == CONST_INT
- || IN_OR_GLOBAL_P (operands[1])))
- return \"return\\t%%i7+8\\n\\tmov\\t%Y1, %Y0\";
- else
- return \"ret\\n\\trestore %%g0, %1, %Y0\";
-}"
- [(set_attr "type" "multi")])
-
-(define_insn "*return_hi"
- [(set (match_operand:HI 0 "restore_operand" "")
- (match_operand:HI 1 "arith_operand" "rI"))
- (return)]
- "! TARGET_EPILOGUE && ! TARGET_LIVE_G0"
- "*
-{
- if (! TARGET_ARCH64 && current_function_returns_struct)
- return \"jmp\\t%%i7+12\\n\\trestore %%g0, %1, %Y0\";
- else if (TARGET_V9 && (GET_CODE (operands[1]) == CONST_INT
- || IN_OR_GLOBAL_P (operands[1])))
- return \"return\\t%%i7+8\\n\\tmov\\t%Y1, %Y0\";
- else
- return \"ret\;restore %%g0, %1, %Y0\";
-}"
- [(set_attr "type" "multi")])
-
-(define_insn "*return_si"
- [(set (match_operand:SI 0 "restore_operand" "")
- (match_operand:SI 1 "arith_operand" "rI"))
- (return)]
- "! TARGET_EPILOGUE && ! TARGET_LIVE_G0"
- "*
-{
- if (! TARGET_ARCH64 && current_function_returns_struct)
- return \"jmp\\t%%i7+12\\n\\trestore %%g0, %1, %Y0\";
- else if (TARGET_V9 && (GET_CODE (operands[1]) == CONST_INT
- || IN_OR_GLOBAL_P (operands[1])))
- return \"return\\t%%i7+8\\n\\tmov\\t%Y1, %Y0\";
- else
- return \"ret\;restore %%g0, %1, %Y0\";
-}"
- [(set_attr "type" "multi")])
-
-;; The following pattern is only generated by delayed-branch scheduling,
-;; when the insn winds up in the epilogue. This can happen not only when
-;; ! TARGET_FPU because we move complex types around by parts using
-;; SF mode SUBREGs.
-(define_insn "*return_sf_no_fpu"
- [(set (match_operand:SF 0 "restore_operand" "r")
- (match_operand:SF 1 "register_operand" "r"))
- (return)]
- "! TARGET_EPILOGUE && ! TARGET_LIVE_G0"
- "*
-{
- if (! TARGET_ARCH64 && current_function_returns_struct)
- return \"jmp\\t%%i7+12\\n\\trestore %%g0, %1, %Y0\";
- else if (TARGET_V9 && IN_OR_GLOBAL_P (operands[1]))
- return \"return\\t%%i7+8\\n\\tmov\\t%Y1, %Y0\";
- else
- return \"ret\;restore %%g0, %1, %Y0\";
-}"
- [(set_attr "type" "multi")])
-
-(define_insn "*return_addsi"
- [(set (match_operand:SI 0 "restore_operand" "")
- (plus:SI (match_operand:SI 1 "register_operand" "r")
- (match_operand:SI 2 "arith_operand" "rI")))
- (return)]
- "! TARGET_EPILOGUE && ! TARGET_LIVE_G0"
- "*
-{
- if (! TARGET_ARCH64 && current_function_returns_struct)
- return \"jmp\\t%%i7+12\\n\\trestore %r1, %2, %Y0\";
- /* If operands are global or in registers, can use return */
- else if (TARGET_V9 && IN_OR_GLOBAL_P (operands[1])
- && (GET_CODE (operands[2]) == CONST_INT
- || IN_OR_GLOBAL_P (operands[2])))
- return \"return\\t%%i7+8\\n\\tadd\\t%Y1, %Y2, %Y0\";
- else
- return \"ret\;restore %r1, %2, %Y0\";
-}"
- [(set_attr "type" "multi")])
-
-(define_insn "*return_di"
- [(set (match_operand:DI 0 "restore_operand" "")
- (match_operand:DI 1 "arith_double_operand" "rHI"))
- (return)]
- "TARGET_ARCH64 && ! TARGET_EPILOGUE"
- "ret\;restore %%g0, %1, %Y0"
- [(set_attr "type" "multi")])
-
-(define_insn "*return_adddi"
- [(set (match_operand:DI 0 "restore_operand" "")
- (plus:DI (match_operand:DI 1 "arith_operand" "%r")
- (match_operand:DI 2 "arith_double_operand" "rHI")))
- (return)]
- "TARGET_ARCH64 && ! TARGET_EPILOGUE"
- "ret\;restore %r1, %2, %Y0"
- [(set_attr "type" "multi")])
-
-;; The following pattern is only generated by delayed-branch scheduling,
-;; when the insn winds up in the epilogue.
-(define_insn "*return_sf"
- [(set (reg:SF 32)
- (match_operand:SF 0 "register_operand" "f"))
- (return)]
- "! TARGET_EPILOGUE"
- "ret\;fmovs\\t%0, %%f0"
- [(set_attr "type" "multi")])
-
-;; Now peepholes to do a call followed by a jump.
-
-(define_peephole
- [(parallel [(set (match_operand 0 "" "")
- (call (mem:SI (match_operand:SI 1 "call_operand_address" "ps"))
- (match_operand 2 "" "")))
- (clobber (reg:SI 15))])
- (set (pc) (label_ref (match_operand 3 "" "")))]
- "short_branch (INSN_UID (insn), INSN_UID (operands[3]))
- && in_same_eh_region (insn, operands[3])
- && in_same_eh_region (insn, ins1)"
- "call\\t%a1, %2\\n\\tadd\\t%%o7, (%l3-.-4), %%o7")
-
-(define_peephole
- [(parallel [(call (mem:SI (match_operand:SI 0 "call_operand_address" "ps"))
- (match_operand 1 "" ""))
- (clobber (reg:SI 15))])
- (set (pc) (label_ref (match_operand 2 "" "")))]
- "short_branch (INSN_UID (insn), INSN_UID (operands[2]))
- && in_same_eh_region (insn, operands[2])
- && in_same_eh_region (insn, ins1)"
- "call\\t%a0, %1\\n\\tadd\\t%%o7, (%l2-.-4), %%o7")
-
-(define_peephole
- [(parallel [(set (match_operand 0 "" "")
- (call (mem:SI (match_operand:DI 1 "call_operand_address" "ps"))
- (match_operand 2 "" "")))
- (clobber (reg:DI 15))])
- (set (pc) (label_ref (match_operand 3 "" "")))]
- "TARGET_ARCH64
- && short_branch (INSN_UID (insn), INSN_UID (operands[3]))
- && in_same_eh_region (insn, operands[3])
- && in_same_eh_region (insn, ins1)"
- "call\\t%a1, %2\\n\\tadd\\t%%o7, (%l3-.-4), %%o7")
-
-(define_peephole
- [(parallel [(call (mem:SI (match_operand:DI 0 "call_operand_address" "ps"))
- (match_operand 1 "" ""))
- (clobber (reg:DI 15))])
- (set (pc) (label_ref (match_operand 2 "" "")))]
- "TARGET_ARCH64
- && short_branch (INSN_UID (insn), INSN_UID (operands[2]))
- && in_same_eh_region (insn, operands[2])
- && in_same_eh_region (insn, ins1)"
- "call\\t%a0, %1\\n\\tadd\\t%%o7, (%l2-.-4), %%o7")
-
-;; After a nonlocal goto, we need to restore the PIC register, but only
-;; if we need it. So do nothing much here, but we'll check for this in
-;; finalize_pic.
-
-;; Make sure this unspec_volatile number agrees with finalize_pic.
-(define_insn "nonlocal_goto_receiver"
- [(unspec_volatile [(const_int 0)] 5)]
- "flag_pic"
- ""
- [(set_attr "length" "0")])
-
-(define_insn "trap"
- [(trap_if (const_int 1) (const_int 5))]
- ""
- "ta\\t5"
- [(set_attr "type" "misc")
- (set_attr "length" "1")])
-
-(define_expand "conditional_trap"
- [(trap_if (match_operator 0 "noov_compare_op"
- [(match_dup 2) (match_dup 3)])
- (match_operand:SI 1 "arith_operand" ""))]
- ""
- "operands[2] = gen_compare_reg (GET_CODE (operands[0]),
- sparc_compare_op0, sparc_compare_op1);
- operands[3] = const0_rtx;")
-
-(define_insn ""
- [(trap_if (match_operator 0 "noov_compare_op" [(reg:CC 100) (const_int 0)])
- (match_operand:SI 1 "arith_operand" "rM"))]
- ""
- "t%C0\\t%1"
- [(set_attr "type" "misc")
- (set_attr "length" "1")])
-
-(define_insn ""
- [(trap_if (match_operator 0 "noov_compare_op" [(reg:CCX 100) (const_int 0)])
- (match_operand:SI 1 "arith_operand" "rM"))]
- "TARGET_V9"
- "t%C0\\t%%xcc, %1"
- [(set_attr "type" "misc")
- (set_attr "length" "1")])
diff --git a/contrib/gcc/config/sparc/splet.h b/contrib/gcc/config/sparc/splet.h
deleted file mode 100644
index d924e7089963..000000000000
--- a/contrib/gcc/config/sparc/splet.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* Definitions of target machine for GNU compiler, for SPARClet.
- Copyright (C) 1996, 1997 Free Software Foundation, Inc.
- Contributed by Doug Evans (dje@cygnus.com).
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-#include "sparc/aout.h"
-
-/* -mbroken-saverestore is not included here because the long term
- default is -mno-broken-saverestore. */
-#undef TARGET_DEFAULT
-#define TARGET_DEFAULT (MASK_APP_REGS + MASK_EPILOGUE)
-
-/* -mlive-g0 is only supported on the sparclet. */
-#undef SUBTARGET_SWITCHES
-#define SUBTARGET_SWITCHES \
-{"big-endian", -MASK_LITTLE_ENDIAN, "Generate code for big endian" }, \
-{"little-endian", MASK_LITTLE_ENDIAN, "Generate code for little endian" }, \
-{"live-g0", MASK_LIVE_G0, "Use g0 as a normal register" }, \
-{"no-live-g0", -MASK_LIVE_G0, "Register g0 is fixed with a zero value" }, \
-{"broken-saverestore", MASK_BROKEN_SAVERESTORE, "Enable save/restore bug workarounds" }, \
-{"no-broken-saverestore", -MASK_BROKEN_SAVERESTORE, "Disable save/restore bug workarouns" },
-
-#undef ASM_SPEC
-#define ASM_SPEC "%{mlittle-endian:-EL} %(asm_cpu)"
-
-/* Require the user to supply crt0.o. */
-#undef STARTFILE_SPEC
-#define STARTFILE_SPEC ""
-
-#undef LINK_SPEC
-#define LINK_SPEC "%{mlittle-endian:-EL}"
-
-/* sparclet chips are bi-endian. */
-#undef BYTES_BIG_ENDIAN
-#define BYTES_BIG_ENDIAN (! TARGET_LITTLE_ENDIAN)
-#undef WORDS_BIG_ENDIAN
-#define WORDS_BIG_ENDIAN (! TARGET_LITTLE_ENDIAN)
-
-#undef SUBTARGET_OVERRIDE_OPTIONS
-#define SUBTARGET_OVERRIDE_OPTIONS \
- do { \
- if (TARGET_LIVE_G0) \
- { \
- warning ("Option '-mlive-g0' deprecated."); \
- target_flags &= ~MASK_LIVE_G0; \
- } \
- else if (TARGET_BROKEN_SAVERESTORE) \
- { \
- warning ("Option '-mbroken-saverestore' deprecated."); \
- target_flags &= ~MASK_BROKEN_SAVERESTORE; \
- } \
- } while (0)
-
diff --git a/contrib/gcc/config/sparc/sun4gas.h b/contrib/gcc/config/sparc/sun4gas.h
deleted file mode 100644
index 3cea9560b4fe..000000000000
--- a/contrib/gcc/config/sparc/sun4gas.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Definitions of target machine for GNU compiler, for SunOS 4.x with gas
- Copyright (C) 1997 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-/* gas supports unaligned data. */
-#define UNALIGNED_DOUBLE_INT_ASM_OP ".uaxword"
-#define UNALIGNED_INT_ASM_OP ".uaword"
-#define UNALIGNED_SHORT_ASM_OP ".uahalf"
-
-/* defaults.h will define DWARF2_UNWIND_INFO for us. */
-#undef DWARF2_UNWIND_INFO
diff --git a/contrib/gcc/config/sparc/sun4o3.h b/contrib/gcc/config/sparc/sun4o3.h
deleted file mode 100644
index d2a53c1f2372..000000000000
--- a/contrib/gcc/config/sparc/sun4o3.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#include "sparc/sparc.h"
-
-/* Override the name of the mcount profiling function. */
-
-#undef MCOUNT_FUNCTION
-#define MCOUNT_FUNCTION "*.mcount"
-
-/* LINK_SPEC is needed only for SunOS 4. */
-
-#undef LINK_SPEC
-
-/* Override MACHINE_STATE_{SAVE,RESTORE} because we have special
- traps available which can get and set the condition codes
- reliably. */
-#undef MACHINE_STATE_SAVE
-#define MACHINE_STATE_SAVE(ID) \
- unsigned long int ms_flags, ms_saveret; \
- asm volatile("ta 0x20\n\t" \
- "mov %%g1, %0\n\t" \
- "mov %%g2, %1\n\t" \
- : "=r" (ms_flags), "=r" (ms_saveret));
-
-#undef MACHINE_STATE_RESTORE
-#define MACHINE_STATE_RESTORE(ID) \
- asm volatile("mov %0, %%g1\n\t" \
- "mov %1, %%g2\n\t" \
- "ta 0x21\n\t" \
- : /* no outputs */ \
- : "r" (ms_flags), "r" (ms_saveret));
diff --git a/contrib/gcc/config/sparc/sunos4.h b/contrib/gcc/config/sparc/sunos4.h
deleted file mode 100644
index 14c7a437d67c..000000000000
--- a/contrib/gcc/config/sparc/sunos4.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* Definitions of target machine for GNU compiler, for SunOS 4.x
- Copyright (C) 1994 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-#define SUNOS4_SHARED_LIBRARIES 1
-
-/* Use N_BINCL stabs. */
-
-#define DBX_USE_BINCL
-
-#include "sparc/sparc.h"
-
-/* The Sun as doesn't like unaligned data. */
-#define DWARF2_UNWIND_INFO 0
-
-/* Override MACHINE_STATE_{SAVE,RESTORE} because we have special
- traps available which can get and set the condition codes
- reliably. */
-#undef MACHINE_STATE_SAVE
-#define MACHINE_STATE_SAVE(ID) \
- unsigned long int ms_flags, ms_saveret; \
- asm volatile("ta 0x20\n\t" \
- "mov %%g1, %0\n\t" \
- "mov %%g2, %1\n\t" \
- : "=r" (ms_flags), "=r" (ms_saveret));
-
-#undef MACHINE_STATE_RESTORE
-#define MACHINE_STATE_RESTORE(ID) \
- asm volatile("mov %0, %%g1\n\t" \
- "mov %1, %%g2\n\t" \
- "ta 0x21\n\t" \
- : /* no outputs */ \
- : "r" (ms_flags), "r" (ms_saveret));
diff --git a/contrib/gcc/config/sparc/sysv4.h b/contrib/gcc/config/sparc/sysv4.h
deleted file mode 100644
index 5f9bba9e594d..000000000000
--- a/contrib/gcc/config/sparc/sysv4.h
+++ /dev/null
@@ -1,216 +0,0 @@
-/* Target definitions for GNU compiler for Sparc running System V.4
- Copyright (C) 1991, 92, 95, 96, 97, 1998 Free Software Foundation, Inc.
- Contributed by Ron Guilmette (rfg@monkeys.com).
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-#include "sparc/sparc.h"
-
-/* Undefine some symbols which are defined in "sparc.h" but which are
- appropriate only for SunOS 4.x, and not for svr4. */
-
-#undef WORD_SWITCH_TAKES_ARG
-#undef ASM_OUTPUT_SOURCE_LINE
-#undef SELECT_SECTION
-#undef ASM_DECLARE_FUNCTION_NAME
-#undef TEXT_SECTION_ASM_OP
-#undef DATA_SECTION_ASM_OP
-
-#include "svr4.h"
-
-/* ??? Put back the SIZE_TYPE/PTRDIFF_TYPE definitions set by sparc.h.
- Why, exactly, is svr4.h messing with this? Seems like the chip
- would know best. */
-
-#undef SIZE_TYPE
-#define SIZE_TYPE (TARGET_ARCH64 ? "long unsigned int" : "unsigned int")
-
-#undef PTRDIFF_TYPE
-#define PTRDIFF_TYPE (TARGET_ARCH64 ? "long int" : "int")
-
-/* Undefined some symbols which are defined in "svr4.h" but which are
- appropriate only for typical svr4 systems, but not for the specific
- case of svr4 running on a Sparc. */
-
-#undef INIT_SECTION_ASM_OP
-#undef FINI_SECTION_ASM_OP
-#undef CONST_SECTION_ASM_OP
-#undef TYPE_OPERAND_FMT
-#undef PUSHSECTION_FORMAT
-#undef STRING_ASM_OP
-#undef COMMON_ASM_OP
-#undef SKIP_ASM_OP
-#undef SET_ASM_OP /* Has no equivalent. See ASM_OUTPUT_DEF below. */
-
-/* Provide a set of pre-definitions and pre-assertions appropriate for
- the Sparc running svr4. __svr4__ is our extension. */
-
-#define CPP_PREDEFINES \
-"-Dsparc -Dunix -D__svr4__ -Asystem(unix) -Asystem(svr4)"
-
-/* The native assembler can't compute differences between symbols in different
- sections when generating pic code, so we must put jump tables in the
- text section. */
-/* But we now defer the tables to the end of the function, so we make
- this 0 to not confuse the branch shortening code. */
-#define JUMP_TABLES_IN_TEXT_SECTION 0
-
-/* Pass -K to the assembler when PIC. */
-#undef ASM_SPEC
-#define ASM_SPEC \
- "%{v:-V} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*} \
- %{fpic:-K PIC} %{fPIC:-K PIC} %(asm_cpu)"
-
-/* Must use data section for relocatable constants when pic. */
-#undef SELECT_RTX_SECTION
-#define SELECT_RTX_SECTION(MODE,RTX) \
-{ \
- if (flag_pic && symbolic_operand (RTX)) \
- data_section (); \
- else \
- const_section (); \
-}
-
-/* Define the names of various pseudo-op used by the Sparc/svr4 assembler.
- Note that many of these are different from the typical pseudo-ops used
- by most svr4 assemblers. That is probably due to a (misguided?) attempt
- to keep the Sparc/svr4 assembler somewhat compatible with the Sparc/SunOS
- assembler. */
-
-#define STRING_ASM_OP ".asciz"
-#define COMMON_ASM_OP ".common"
-#define SKIP_ASM_OP ".skip"
-#define UNALIGNED_DOUBLE_INT_ASM_OP ".uaxword"
-#define UNALIGNED_INT_ASM_OP ".uaword"
-#define UNALIGNED_SHORT_ASM_OP ".uahalf"
-#define PUSHSECTION_ASM_OP ".pushsection"
-#define POPSECTION_ASM_OP ".popsection"
-
-/* This is defined in sparc.h but is not used by svr4.h. */
-#undef ASM_LONG
-#define ASM_LONG ".long"
-
-/* This is the format used to print the second operand of a .type pseudo-op
- for the Sparc/svr4 assembler. */
-
-#define TYPE_OPERAND_FMT "#%s"
-
-/* This is the format used to print a .pushsection pseudo-op (and its operand)
- for the Sparc/svr4 assembler. */
-
-#define PUSHSECTION_FORMAT "\t%s\t\"%s\"\n"
-
-#undef ASM_OUTPUT_CASE_LABEL
-#define ASM_OUTPUT_CASE_LABEL(FILE, PREFIX, NUM, JUMPTABLE) \
-do { ASM_OUTPUT_ALIGN ((FILE), Pmode == SImode ? 2 : 3); \
- ASM_OUTPUT_INTERNAL_LABEL ((FILE), PREFIX, NUM); \
- } while (0)
-
-/* This is how to equate one symbol to another symbol. The syntax used is
- `SYM1=SYM2'. Note that this is different from the way equates are done
- with most svr4 assemblers, where the syntax is `.set SYM1,SYM2'. */
-
-#define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \
- do { fprintf ((FILE), "\t"); \
- assemble_name (FILE, LABEL1); \
- fprintf (FILE, " = "); \
- assemble_name (FILE, LABEL2); \
- fprintf (FILE, "\n"); \
- } while (0)
-
-/* Define how the Sparc registers should be numbered for Dwarf output.
- The numbering provided here should be compatible with the native
- svr4 SDB debugger in the Sparc/svr4 reference port. The numbering
- is as follows:
-
- Assembly name gcc internal regno Dwarf regno
- ----------------------------------------------------------
- g0-g7 0-7 0-7
- o0-o7 8-15 8-15
- l0-l7 16-23 16-23
- i0-i7 24-31 24-31
- f0-f31 32-63 40-71
-*/
-
-#define DBX_REGISTER_NUMBER(REGNO) ((REGNO) < 32 ? (REGNO) : (REGNO) + 8)
-
-/* A set of symbol definitions for assembly pseudo-ops which will
- get us switched to various sections of interest. These are used
- in all places where we simply want to switch to a section, and
- *not* to push the previous section name onto the assembler's
- section names stack (as we do often in dwarfout.c). */
-
-#define TEXT_SECTION_ASM_OP ".section\t\".text\""
-#define DATA_SECTION_ASM_OP ".section\t\".data\""
-#define BSS_SECTION_ASM_OP ".section\t\".bss\""
-#define CONST_SECTION_ASM_OP ".section\t\".rodata\""
-#define INIT_SECTION_ASM_OP ".section\t\".init\""
-#define FINI_SECTION_ASM_OP ".section\t\".fini\""
-
-/* Define the pseudo-ops used to switch to the .ctors and .dtors sections.
-
- Note that we want to give these sections the SHF_WRITE attribute
- because these sections will actually contain data (i.e. tables of
- addresses of functions in the current root executable or shared library
- file) and, in the case of a shared library, the relocatable addresses
- will have to be properly resolved/relocated (and then written into) by
- the dynamic linker when it actually attaches the given shared library
- to the executing process. (Note that on SVR4, you may wish to use the
- `-z text' option to the ELF linker, when building a shared library, as
- an additional check that you are doing everything right. But if you do
- use the `-z text' option when building a shared library, you will get
- errors unless the .ctors and .dtors sections are marked as writable
- via the SHF_WRITE attribute.) */
-
-#undef CTORS_SECTION_ASM_OP
-#define CTORS_SECTION_ASM_OP ".section\t\".ctors\",#alloc,#write"
-#undef DTORS_SECTION_ASM_OP
-#define DTORS_SECTION_ASM_OP ".section\t\".dtors\",#alloc,#write"
-#undef EH_FRAME_SECTION_ASM_OP
-#define EH_FRAME_SECTION_ASM_OP ".section\t\".eh_frame\",#alloc,#write"
-
-/* A C statement to output something to the assembler file to switch to section
- NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or
- NULL_TREE. Some target formats do not support arbitrary sections. Do not
- define this macro in such cases. */
-
-#undef ASM_OUTPUT_SECTION_NAME /* Override svr4.h's definition. */
-#define ASM_OUTPUT_SECTION_NAME(FILE, DECL, NAME, RELOC) \
-do { \
- if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
- fprintf (FILE, ".section\t\"%s\",#alloc,#execinstr\n", \
- (NAME)); \
- else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \
- fprintf (FILE, ".section\t\"%s\",#alloc\n", (NAME)); \
- else \
- fprintf (FILE, ".section\t\"%s\",#alloc,#write\n", (NAME)); \
-} while (0)
-
-/* A C statement (sans semicolon) to output to the stdio stream
- FILE the assembler definition of uninitialized global DECL named
- NAME whose size is SIZE bytes and alignment is ALIGN bytes.
- Try to use asm_output_aligned_bss to implement this macro. */
-
-#undef ASM_OUTPUT_ALIGNED_BSS
-#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
- asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
-
-/* Override the name of the mcount profiling function. */
-
-#undef MCOUNT_FUNCTION
-#define MCOUNT_FUNCTION "*_mcount"
diff --git a/contrib/gcc/config/sparc/t-elf b/contrib/gcc/config/sparc/t-elf
deleted file mode 100644
index da9df38368ee..000000000000
--- a/contrib/gcc/config/sparc/t-elf
+++ /dev/null
@@ -1,39 +0,0 @@
-# we need to supply our own assembly versions of libgcc1.c files,
-# since the user may not have native 'cc' available
-
-CROSS_LIBGCC1 = libgcc1-asm.a
-LIB1ASMSRC = sparc/lb1spc.asm
-LIB1ASMFUNCS = _mulsi3 _divsi3 _modsi3
-
-# crt0 is built elsewhere
-LIBGCC1_TEST =
-
-# These are really part of libgcc1, but this will cause them to be
-# built correctly, so...
-
-LIB2FUNCS_EXTRA = fp-bit.c dp-bit.c
-
-dp-bit.c: $(srcdir)/config/fp-bit.c
- cat $(srcdir)/config/fp-bit.c > dp-bit.c
-
-fp-bit.c: $(srcdir)/config/fp-bit.c
- echo '#define FLOAT' > fp-bit.c
- cat $(srcdir)/config/fp-bit.c >> fp-bit.c
-
-# MULTILIB_OPTIONS should have msparclite too, but we'd have to make
-# gas build...
-#MULTILIB_OPTIONS = msoft-float mcpu=v8
-MULTILIB_OPTIONS = msoft-float
-#MULTILIB_DIRNAMES = soft v8
-MULTILIB_DIRNAMES = soft
-#MULTILIB_MATCHES = msoft-float=mno-fpu mcpu?v8=mv8
-MULTILIB_MATCHES = msoft-float=mno-fpu
-
-LIBGCC = stmp-multilib
-INSTALL_LIBGCC = install-multilib
-
-# Assemble startup files.
-crti.o: $(srcdir)/config/sparc/sol2-ci.asm $(GCC_PASSES)
- $(GCC_FOR_TARGET) -c -o crti.o -x assembler $(srcdir)/config/sparc/sol2-ci.asm
-crtn.o: $(srcdir)/config/sparc/sol2-cn.asm $(GCC_PASSES)
- $(GCC_FOR_TARGET) -c -o crtn.o -x assembler $(srcdir)/config/sparc/sol2-cn.asm
diff --git a/contrib/gcc/config/sparc/t-halos b/contrib/gcc/config/sparc/t-halos
deleted file mode 100644
index 0bd5496ac238..000000000000
--- a/contrib/gcc/config/sparc/t-halos
+++ /dev/null
@@ -1,2 +0,0 @@
-# For a native HALOS compile, we need to set -e1 for the assembler
-AS=as -e1
diff --git a/contrib/gcc/config/sparc/t-linux64 b/contrib/gcc/config/sparc/t-linux64
deleted file mode 100644
index 077cf69e7193..000000000000
--- a/contrib/gcc/config/sparc/t-linux64
+++ /dev/null
@@ -1,21 +0,0 @@
-MULTILIB_OPTIONS = m64/m32
-MULTILIB_DIRNAMES = 64 32
-MULTILIB_MATCHES =
-
-LIBGCC = stmp-multilib
-INSTALL_LIBGCC = install-multilib
-
-EXTRA_MULTILIB_PARTS=crtbegin.o crtend.o crtbeginS.o crtendS.o
-
-tcrtbeginS.o: crtstuff.c $(GCC_PASSES) $(CONFIG_H) \
- defaults.h frame.h gbl-ctors.h
- $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0 \
- -finhibit-size-directive -fno-inline-functions -fno-exceptions $(CRTSTUFF_T_CFLAGS_S) \
- -c $(srcdir)/crtstuff.c -DCRT_BEGIN -o tcrtbeginS$(objext)
-
-tcrtendS.o: crtstuff.c $(GCC_PASSES) $(CONFIG_H) \
- defaults.h frame.h gbl-ctors.h
- $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0 \
- -finhibit-size-directive -fno-inline-functions -fno-exceptions $(CRTSTUFF_T_CFLAGS_S) \
- -c $(srcdir)/crtstuff.c -DCRT_END -o tcrtendS$(objext)
-
diff --git a/contrib/gcc/config/sparc/t-sol2 b/contrib/gcc/config/sparc/t-sol2
deleted file mode 100644
index a9b6ee147939..000000000000
--- a/contrib/gcc/config/sparc/t-sol2
+++ /dev/null
@@ -1,30 +0,0 @@
-# we need to supply our own assembly versions of libgcc1.c files,
-# since the user may not have native 'cc' available
-
-LIBGCC1 =
-CROSS_LIBGCC1 =
-LIBGCC1_TEST =
-
-# gmon build rule:
-$(T)gmon.o: $(srcdir)/config/sparc/gmon-sol2.c $(GCC_PASSES) $(CONFIG_H) stmp-int-hdrs
- $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) \
- -c $(srcdir)/config/sparc/gmon-sol2.c -o $(T)gmon.o
-
-# Assemble startup files.
-$(T)crt1.o: $(srcdir)/config/sparc/sol2-c1.asm $(GCC_PASSES)
- $(GCC_FOR_TARGET) $(MULTILIB_CFLAGS) -c -o $(T)crt1.o -x assembler-with-cpp $(srcdir)/config/sparc/sol2-c1.asm
-$(T)crti.o: $(srcdir)/config/sparc/sol2-ci.asm $(GCC_PASSES)
- $(GCC_FOR_TARGET) $(MULTILIB_CFLAGS) -c -o $(T)crti.o -x assembler-with-cpp $(srcdir)/config/sparc/sol2-ci.asm
-$(T)crtn.o: $(srcdir)/config/sparc/sol2-cn.asm $(GCC_PASSES)
- $(GCC_FOR_TARGET) $(MULTILIB_CFLAGS) -c -o $(T)crtn.o -x assembler-with-cpp $(srcdir)/config/sparc/sol2-cn.asm
-$(T)gcrt1.o: $(srcdir)/config/sparc/sol2-c1.asm $(GCC_PASSES)
- $(GCC_FOR_TARGET) $(MULTILIB_CFLAGS) -c -DGCRT1 -o $(T)gcrt1.o -x assembler-with-cpp $(srcdir)/config/sparc/sol2-c1.asm
-
-# We need to use -fPIC when we are using gcc to compile the routines in
-# crtstuff.c. This is only really needed when we are going to use gcc/g++
-# to produce a shared library, but since we don't know ahead of time when
-# we will be doing that, we just always use -fPIC when compiling the
-# routines in crtstuff.c.
-
-CRTSTUFF_T_CFLAGS = -fPIC
-TARGET_LIBGCC2_CFLAGS = -fPIC
diff --git a/contrib/gcc/config/sparc/t-sol2-64 b/contrib/gcc/config/sparc/t-sol2-64
deleted file mode 100644
index 8d42c4453542..000000000000
--- a/contrib/gcc/config/sparc/t-sol2-64
+++ /dev/null
@@ -1,8 +0,0 @@
-MULTILIB_OPTIONS = m32/m64
-MULTILIB_DIRNAMES = sparcv7 sparcv9
-MULTILIB_MATCHES =
-
-LIBGCC = stmp-multilib
-INSTALL_LIBGCC = install-multilib
-
-EXTRA_MULTILIB_PARTS=crtbegin.o crtend.o gmon.o crt1.o crti.o crtn.o gcrt1.o
diff --git a/contrib/gcc/config/sparc/t-sp64 b/contrib/gcc/config/sparc/t-sp64
deleted file mode 100644
index 99acd5d54235..000000000000
--- a/contrib/gcc/config/sparc/t-sp64
+++ /dev/null
@@ -1,2 +0,0 @@
-LIBGCC1 =
-CROSS_LIBGCC1 =
diff --git a/contrib/gcc/config/sparc/t-sparcbare b/contrib/gcc/config/sparc/t-sparcbare
deleted file mode 100644
index 8bd978b068d9..000000000000
--- a/contrib/gcc/config/sparc/t-sparcbare
+++ /dev/null
@@ -1,26 +0,0 @@
-# configuration file for a bare sparc cpu
-
-CROSS_LIBGCC1 = libgcc1-asm.a
-LIB1ASMSRC = sparc/lb1spc.asm
-LIB1ASMFUNCS = _mulsi3 _divsi3 _modsi3
-
-# These are really part of libgcc1, but this will cause them to be
-# built correctly, so...
-
-LIB2FUNCS_EXTRA = fp-bit.c dp-bit.c
-
-dp-bit.c: $(srcdir)/config/fp-bit.c
- cat $(srcdir)/config/fp-bit.c > dp-bit.c
-
-fp-bit.c: $(srcdir)/config/fp-bit.c
- echo '#define FLOAT' > fp-bit.c
- cat $(srcdir)/config/fp-bit.c >> fp-bit.c
-
-# MULTILIB_OPTIONS should have msparclite too, but we'd have to make
-# gas build...
-MULTILIB_OPTIONS = msoft-float mcpu=v8
-MULTILIB_DIRNAMES = soft v8
-MULTILIB_MATCHES = msoft-float=mno-fpu mcpu?v8=mv8
-
-LIBGCC = stmp-multilib
-INSTALL_LIBGCC = install-multilib
diff --git a/contrib/gcc/config/sparc/t-sparclite b/contrib/gcc/config/sparc/t-sparclite
deleted file mode 100644
index 7cdfbb04551c..000000000000
--- a/contrib/gcc/config/sparc/t-sparclite
+++ /dev/null
@@ -1,24 +0,0 @@
-CROSS_LIBGCC1 = libgcc1-asm.a
-LIB1ASMSRC = sparc/lb1spl.asm
-LIB1ASMFUNCS = _divsi3 _udivsi3 _modsi3 _umodsi3
-
-# These are really part of libgcc1, but this will cause them to be
-# built correctly, so...
-
-LIB2FUNCS_EXTRA = fp-bit.c dp-bit.c
-
-dp-bit.c: $(srcdir)/config/fp-bit.c
- echo '#define US_SOFTWARE_GOFAST' > dp-bit.c
- cat $(srcdir)/config/fp-bit.c >> dp-bit.c
-
-fp-bit.c: $(srcdir)/config/fp-bit.c
- echo '#define FLOAT' > fp-bit.c
- echo '#define US_SOFTWARE_GOFAST' >> fp-bit.c
- cat $(srcdir)/config/fp-bit.c >> fp-bit.c
-
-MULTILIB_OPTIONS = mfpu mflat
-MULTILIB_DIRNAMES =
-MULTILIB_MATCHES = mfpu=mhard-float mfpu=mcpu?f934
-
-LIBGCC = stmp-multilib
-INSTALL_LIBGCC = install-multilib
diff --git a/contrib/gcc/config/sparc/t-splet b/contrib/gcc/config/sparc/t-splet
deleted file mode 100644
index 3329e0bef072..000000000000
--- a/contrib/gcc/config/sparc/t-splet
+++ /dev/null
@@ -1,22 +0,0 @@
-# configuration file for a bare sparclet cpu, aout format files
-
-CROSS_LIBGCC1 = libgcc1-asm.a
-LIB1ASMSRC = sparc/lb1spc.asm
-LIB1ASMFUNCS = _mulsi3 _divsi3 _modsi3
-
-# These are really part of libgcc1, but this will cause them to be
-# built correctly, so...
-
-LIB2FUNCS_EXTRA = fp-bit.c dp-bit.c
-
-dp-bit.c: $(srcdir)/config/fp-bit.c
- cat $(srcdir)/config/fp-bit.c > dp-bit.c
-
-fp-bit.c: $(srcdir)/config/fp-bit.c
- echo '#define FLOAT' > fp-bit.c
- cat $(srcdir)/config/fp-bit.c >> fp-bit.c
-
-MULTILIB_OPTIONS = mlittle-endian mflat
-MULTILIB_DIRNAMES = little flat
-LIBGCC = stmp-multilib
-INSTALL_LIBGCC = install-multilib
diff --git a/contrib/gcc/config/sparc/t-sunos40 b/contrib/gcc/config/sparc/t-sunos40
deleted file mode 100644
index 3e10575eaea5..000000000000
--- a/contrib/gcc/config/sparc/t-sunos40
+++ /dev/null
@@ -1,7 +0,0 @@
-# SunOS 4.0.*
-# /bin/as doesn't recognize the v8 instructions, so we can't do a v8
-# multilib build.
-
-LIBGCC1 =
-CROSS_LIBGCC1 =
-LIBGCC1_TEST =
diff --git a/contrib/gcc/config/sparc/t-sunos41 b/contrib/gcc/config/sparc/t-sunos41
deleted file mode 100644
index 5783d6a26258..000000000000
--- a/contrib/gcc/config/sparc/t-sunos41
+++ /dev/null
@@ -1,16 +0,0 @@
-# SunOS 4.1.*
-
-LIBGCC1 =
-CROSS_LIBGCC1 =
-LIBGCC1_TEST =
-
-MULTILIB_OPTIONS = fpic/fPIC mcpu=v8
-MULTILIB_DIRNAMES = pic ucpic v8
-MULTILIB_MATCHES = mcpu?v8=mv8
-
-LIBGCC = stmp-multilib
-INSTALL_LIBGCC = install-multilib
-
-# The native linker doesn't handle linking -fpic code with -fPIC code. Ugh.
-# We cope by building both variants of libgcc.
-#TARGET_LIBGCC2_CFLAGS = -fPIC
diff --git a/contrib/gcc/config/sparc/t-vxsparc b/contrib/gcc/config/sparc/t-vxsparc
deleted file mode 100644
index 0c7a14a44295..000000000000
--- a/contrib/gcc/config/sparc/t-vxsparc
+++ /dev/null
@@ -1,17 +0,0 @@
-LIBGCC1 =
-CROSS_LIBGCC1 =
-
-# We don't want to build .umul, etc., because VxWorks provides them,
-# which means that libgcc1-test will fail.
-LIBGCC1_TEST =
-
-# We don't want to put exit in libgcc.a for VxWorks, because VxWorks
-# does not have _exit.
-TARGET_LIBGCC2_CFLAGS = -Dexit=unused_exit
-
-MULTILIB_OPTIONS=msoft-float mv8
-MULTILIB_DIRNAMES=soft v8
-MULTILIB_MATCHES=msoft-float=mno-fpu
-
-LIBGCC = stmp-multilib
-INSTALL_LIBGCC = install-multilib
diff --git a/contrib/gcc/config/sparc/vxsim.h b/contrib/gcc/config/sparc/vxsim.h
deleted file mode 100644
index 6c80375f56b9..000000000000
--- a/contrib/gcc/config/sparc/vxsim.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/* Definitions of target machine for GNU compiler, for SPARC VxSim
- Copyright 1996 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-/* Supposedly the same as vanilla sparc svr4, except for the stuff below: */
-#include "sparc/sysv4.h"
-
-#undef CPP_PREDEFINES
-#define CPP_PREDEFINES \
- "-DCPU=SIMSPARCSOLARIS -D__vxworks -D__vxworks__ -Dsparc -D__svr4__ -D__SVR4 \
- -Asystem(embedded) -Asystem(svr4) -Acpu(sparc) -Amachine(sparc)\
- -D__GCC_NEW_VARARGS__"
-
-#undef CPP_SPEC
-#define CPP_SPEC ""
-
-#undef CC1_SPEC
-#define CC1_SPEC "-fno-builtin %{sun4:} %{target:}"
-
-/* The sun bundled assembler doesn't accept -Yd, (and neither does gas).
- It's safe to pass -s always, even if -g is not used. */
-#undef ASM_SPEC
-#define ASM_SPEC \
- "%{V} %{v:%{!V:-V}} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s \
- %{fpic:-K PIC} %{fPIC:-K PIC}"
-
-/* However it appears that Solaris 2.0 uses the same reg numbering as
- the old BSD-style system did. */
-
-#undef DBX_REGISTER_NUMBER
-/* Same as sparc.h */
-#define DBX_REGISTER_NUMBER(REGNO) (REGNO)
-
-/* We use stabs-in-elf for debugging, because that is what the native
- toolchain uses. */
-#undef PREFERRED_DEBUGGING_TYPE
-#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
-
-/* The Solaris 2 assembler uses .skip, not .zero, so put this back. */
-#undef ASM_OUTPUT_SKIP
-#define ASM_OUTPUT_SKIP(FILE,SIZE) \
- fprintf (FILE, "\t.skip %u\n", (SIZE))
-
-#undef ASM_OUTPUT_ALIGNED_LOCAL
-#define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
-do { \
- fputs ("\t.local\t", (FILE)); \
- assemble_name ((FILE), (NAME)); \
- putc ('\n', (FILE)); \
- ASM_OUTPUT_ALIGNED_COMMON (FILE, NAME, SIZE, ALIGN); \
-} while (0)
-
-#undef COMMON_ASM_OP
-#define COMMON_ASM_OP "\t.common"
-
-/* This is how to output a definition of an internal numbered label where
- PREFIX is the class of label and NUM is the number within the class. */
-
-#undef ASM_OUTPUT_INTERNAL_LABEL
-#define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \
- fprintf (FILE, ".L%s%d:\n", PREFIX, NUM)
-
-/* This is how to output a reference to an internal numbered label where
- PREFIX is the class of label and NUM is the number within the class. */
-
-#undef ASM_OUTPUT_INTERNAL_LABELREF
-#define ASM_OUTPUT_INTERNAL_LABELREF(FILE,PREFIX,NUM) \
- fprintf (FILE, ".L%s%d", PREFIX, NUM)
-
-/* This is how to store into the string LABEL
- the symbol_ref name of an internal numbered label where
- PREFIX is the class of label and NUM is the number within the class.
- This is suitable for output with `assemble_name'. */
-
-#undef ASM_GENERATE_INTERNAL_LABEL
-#define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \
- sprintf (LABEL, "*.L%s%d", PREFIX, NUM)
-
-
-
-#undef LIB_SPEC
-#define LIB_SPEC ""
-
-#undef STARTFILE_SPEC
-#define STARTFILE_SPEC ""
-
-#undef ENDFILE_SPEC
-#define ENDFILE_SPEC ""
-
-#undef LINK_SPEC
-#define LINK_SPEC "-r"
-
-/* This defines which switch letters take arguments.
- It is as in svr4.h but with -R added. */
-
-#undef SWITCH_TAKES_ARG
-#define SWITCH_TAKES_ARG(CHAR) \
- ( (CHAR) == 'D' \
- || (CHAR) == 'U' \
- || (CHAR) == 'o' \
- || (CHAR) == 'e' \
- || (CHAR) == 'u' \
- || (CHAR) == 'I' \
- || (CHAR) == 'm' \
- || (CHAR) == 'L' \
- || (CHAR) == 'R' \
- || (CHAR) == 'A' \
- || (CHAR) == 'h' \
- || (CHAR) == 'z')
-
-/* ??? This does not work in SunOS 4.x, so it is not enabled in sparc.h.
- Instead, it is enabled here, because it does work under Solaris. */
-/* Define for support of TFmode long double and REAL_ARITHMETIC.
- Sparc ABI says that long double is 4 words. */
-#define LONG_DOUBLE_TYPE_SIZE 64
diff --git a/contrib/gcc/config/sparc/vxsparc.h b/contrib/gcc/config/sparc/vxsparc.h
deleted file mode 100644
index 18ce6ed97b70..000000000000
--- a/contrib/gcc/config/sparc/vxsparc.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* Definitions of target machine for GNU compiler. Vxworks SPARC version.
- Copyright (C) 1994, 1996 Free Software Foundation, Inc.
- Contributed by David Henkel-Wallace (gumby@cygnus.com)
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-#include "sparc/aout.h"
-
-/* Specify what to link with. */
-/* VxWorks does all the library stuff itself. */
-
-#undef LIB_SPEC
-#define LIB_SPEC ""
-
-/* Provide required defaults for linker -e. */
-#undef LINK_SPEC
-#define LINK_SPEC "%{!nostdlib:%{!r*:%{!e*:-e start}}}"
-
-/* VxWorks provides the functionality of crt0.o and friends itself. */
-#undef STARTFILE_SPEC
-#define STARTFILE_SPEC ""
-
-#undef CPP_PREDEFINES
-#define CPP_PREDEFINES "-Dsparc -Acpu(sparc) -Amachine(sparc)"
-
-/* Note that we define CPU here even if the user has specified -ansi.
- This violates user namespace, but the VxWorks headers, and potentially
- user code, all explicitly rely upon the definition of CPU in order to get
- the proper processor information. */
-#undef CPP_SPEC
-#define CPP_SPEC "%(cpp_cpu) -DCPU=SPARC"
-
-#undef PTRDIFF_TYPE
-#undef SIZE_TYPE
-#undef WCHAR_TYPE
-#undef WCHAR_TYPE_SIZE
-
-#define PTRDIFF_TYPE "long int"
-#define SIZE_TYPE "unsigned int"
-#define WCHAR_TYPE "char"
-#define WCHAR_TYPE_SIZE 8
-
-/* US Software GOFAST library support. */
-#include "gofast.h"
-#undef INIT_SUBTARGET_OPTABS
-#define INIT_SUBTARGET_OPTABS INIT_GOFAST_OPTABS
diff --git a/contrib/gcc/config/sparc/x-sysv4 b/contrib/gcc/config/sparc/x-sysv4
deleted file mode 100644
index 2a661e359993..000000000000
--- a/contrib/gcc/config/sparc/x-sysv4
+++ /dev/null
@@ -1,2 +0,0 @@
-X_CFLAGS=-DSVR4
-ALLOCA=alloca.o
diff --git a/contrib/gcc/config/sparc/xm-linux.h b/contrib/gcc/config/sparc/xm-linux.h
deleted file mode 100644
index 691c7d167847..000000000000
--- a/contrib/gcc/config/sparc/xm-linux.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/* Configuration for GCC for SPARC running Linux-based GNU systems.
- Copyright (C) 1996, 1997 Free Software Foundation, Inc.
- Contributed by Eddie C. Dost (ecd@skynet.be)
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-#ifndef inhibit_libc
-#include <alloca.h>
-#include <stdlib.h>
-#include <string.h>
-#endif
diff --git a/contrib/gcc/config/sparc/xm-lynx.h b/contrib/gcc/config/sparc/xm-lynx.h
deleted file mode 100644
index 90fef8543b91..000000000000
--- a/contrib/gcc/config/sparc/xm-lynx.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Configuration for GNU C-compiler for sparc platforms running LynxOS.
- Copyright (C) 1995 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-#include <xm-lynx.h>
-
-/* This describes the machine the compiler is hosted on. */
-#define HOST_BITS_PER_CHAR 8
-#define HOST_BITS_PER_SHORT 16
-#define HOST_BITS_PER_INT 32
-#define HOST_BITS_PER_LONG 32
-#define HOST_BITS_PER_LONGLONG 64
-
-#define HOST_WORDS_BIG_ENDIAN 1
-
-/* Include <sys/wait.h> to define the exit status access macros. */
-#include <sys/types.h>
-#include <sys/wait.h>
-
-/* target machine dependencies.
- tm.h is a symbolic link to the actual target specific file. */
-
-#include "tm.h"
diff --git a/contrib/gcc/config/sparc/xm-openbsd.h b/contrib/gcc/config/sparc/xm-openbsd.h
deleted file mode 100644
index 2df7fb3e3639..000000000000
--- a/contrib/gcc/config/sparc/xm-openbsd.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Configuration file for an host running sparc OpenBSD.
- Copyright (C) 1999 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-#include <xm-openbsd.h>
-#include <sparc/xm-sparc.h>
-
diff --git a/contrib/gcc/config/sparc/xm-pbd.h b/contrib/gcc/config/sparc/xm-pbd.h
deleted file mode 100644
index 1c3f47590c79..000000000000
--- a/contrib/gcc/config/sparc/xm-pbd.h
+++ /dev/null
@@ -1,10 +0,0 @@
-/* Host environment for the tti "Unicom" PBB 68020 boards */
-
-#include "sparc/xm-sparc.h"
-
-#define USG
-
-#ifndef __GNUC__
-#define USE_C_ALLOCA
-#endif
-
diff --git a/contrib/gcc/config/sparc/xm-sol2.h b/contrib/gcc/config/sparc/xm-sol2.h
deleted file mode 100644
index 5613b086b572..000000000000
--- a/contrib/gcc/config/sparc/xm-sol2.h
+++ /dev/null
@@ -1,4 +0,0 @@
-/* If not compiled with GNU C, include the system's <alloca.h> header. */
-#ifndef __GNUC__
-#include <alloca.h>
-#endif
diff --git a/contrib/gcc/config/sparc/xm-sp64.h b/contrib/gcc/config/sparc/xm-sp64.h
deleted file mode 100644
index b673161282f4..000000000000
--- a/contrib/gcc/config/sparc/xm-sp64.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Configuration for GCC for Sparc v9 running 64-bit native.
- Copyright (C) 1997 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-#include <sparc/xm-sparc.h>
-
-/* This describes the machine the compiler is hosted on. */
-#if defined(__arch64__) || defined(__sparc_v9__) || defined(__sparcv9)
-#undef HOST_BITS_PER_LONG
-#define HOST_BITS_PER_LONG 64
-#endif
diff --git a/contrib/gcc/config/sparc/xm-sparc.h b/contrib/gcc/config/sparc/xm-sparc.h
deleted file mode 100644
index e553a0df0b25..000000000000
--- a/contrib/gcc/config/sparc/xm-sparc.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* Configuration for GNU C-compiler for Sun Sparc.
- Copyright (C) 1988, 1993, 1995, 1997 Free Software Foundation, Inc.
- Contributed by Michael Tiemann (tiemann@cygnus.com).
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-
-/* #defines that need visibility everywhere. */
-#define FALSE 0
-#define TRUE 1
-
-/* This describes the machine the compiler is hosted on. */
-#define HOST_BITS_PER_CHAR 8
-#define HOST_BITS_PER_SHORT 16
-#define HOST_BITS_PER_INT 32
-#define HOST_BITS_PER_LONG 32
-#define HOST_BITS_PER_LONGLONG 64
-
-/* Doubles are stored in memory with the high order word first. This
- matters when cross-compiling. */
-#define HOST_WORDS_BIG_ENDIAN 1
-
-/* target machine dependencies.
- tm.h is a symbolic link to the actual target specific file. */
-#include "tm.h"
-
-/* Arguments to use with `exit'. */
-#define SUCCESS_EXIT_CODE 0
-#define FATAL_EXIT_CODE 33
-
-/* If compiled with Sun CC, the use of alloca requires this #include. */
-#ifndef __GNUC__
-#include "alloca.h"
-#endif
diff --git a/contrib/gcc/config/sparc/xm-sysv4-64.h b/contrib/gcc/config/sparc/xm-sysv4-64.h
deleted file mode 100644
index c506d22dd360..000000000000
--- a/contrib/gcc/config/sparc/xm-sysv4-64.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Configuration for GCC for Sparc v9 running 64-bit native.
- Copyright (C) 1998 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-#include <sparc/xm-sysv4.h>
-
-/* This describes the machine the compiler is hosted on. */
-#if defined(__arch64__) || defined(__sparc_v9__) || defined(__sparcv9)
-#undef HOST_BITS_PER_LONG
-#define HOST_BITS_PER_LONG 64
-#endif
diff --git a/contrib/gcc/config/sparc/xm-sysv4.h b/contrib/gcc/config/sparc/xm-sysv4.h
deleted file mode 100644
index 6e663d12cfa1..000000000000
--- a/contrib/gcc/config/sparc/xm-sysv4.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/* Configuration for GNU C-compiler for Sun Sparc running System V.4.
- Copyright (C) 1992, 1993, 1998 Free Software Foundation, Inc.
- Contributed by Ron Guilmette (rfg@netcom.com).
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-
-/* #defines that need visibility everywhere. */
-#define FALSE 0
-#define TRUE 1
-
-/* This describes the machine the compiler is hosted on. */
-#define HOST_BITS_PER_CHAR 8
-#define HOST_BITS_PER_SHORT 16
-#define HOST_BITS_PER_INT 32
-#define HOST_BITS_PER_LONG 32
-#define HOST_BITS_PER_LONGLONG 64
-
-/* Doubles are stored in memory with the high order word first. This
- matters when cross-compiling. */
-#define HOST_WORDS_BIG_ENDIAN 1
-
-/* target machine dependencies.
- tm.h is a symbolic link to the actual target specific file. */
-#include "tm.h"
-
-/* Arguments to use with `exit'. */
-#define SUCCESS_EXIT_CODE 0
-#define FATAL_EXIT_CODE 33
-
-#ifndef __GNUC__
-#define ONLY_INT_FIELDS
-#endif
diff --git a/contrib/gcc/config/x-netbsd b/contrib/gcc/config/x-netbsd
deleted file mode 100644
index 1c272f5a8dc8..000000000000
--- a/contrib/gcc/config/x-netbsd
+++ /dev/null
@@ -1,6 +0,0 @@
-# Don't run fixproto
-STMP_FIXPROTO =
-
-# We don't need GCC's own include files.
-USER_H =
-INSTALL_ASSERT_H =
diff --git a/contrib/gcc/config/xm-netbsd.h b/contrib/gcc/config/xm-netbsd.h
deleted file mode 100644
index 099a9234ffa6..000000000000
--- a/contrib/gcc/config/xm-netbsd.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/* Configuration for GNU C-compiler for hosts running NetBSD.
- Copyright (C) 1995 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-/* This file defines machine-independent things specific to a host
- running NetBSD. This file should not be specified as $xm_file itself;
- instead $xm_file should be CPU/xm-netbsd.h, which should include both
- CPU/xm-CPU.h and this file xm-netbsd.h. */
-
-#define HAVE_VPRINTF
diff --git a/contrib/gcc/config/xm-siglist.h b/contrib/gcc/config/xm-siglist.h
deleted file mode 100644
index d6133d6a194a..000000000000
--- a/contrib/gcc/config/xm-siglist.h
+++ /dev/null
@@ -1,6 +0,0 @@
-/* Some systems provide no sys_siglist, but do offer the same data under
- another name. */
-
-#define sys_siglist _sys_siglist
-#undef SYS_SIGLIST_DECLARED
-#define SYS_SIGLIST_DECLARED
diff --git a/contrib/gcc/cp/class.h b/contrib/gcc/cp/class.h
deleted file mode 100644
index f2c21735cc4c..000000000000
--- a/contrib/gcc/cp/class.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/* Variables and structures for overloading rules.
- Copyright (C) 1993 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-/* The following structure is used when comparing various alternatives
- for overloading. The unsigned quantity `strikes.i' is used
- for fast comparison of two possibilities. This number is an
- aggregate of four constituents:
-
- EVIL: if this is non-zero, then the candidate should not be considered
- ELLIPSIS: if this is non-zero, then some actual argument has been matched
- against an ellipsis
- USER: if this is non-zero, then a user-defined type conversion is needed
- B_OR_D: if this is non-zero, then use a base pointer instead of the
- type of the pointer we started with.
- EASY: if this is non-zero, then we have a builtin conversion
- (such as int to long, int to float, etc) to do.
-
- If two candidates require user-defined type conversions, and the
- type conversions are not identical, then an ambiguity error
- is reported.
-
- If two candidates agree on user-defined type conversions,
- and one uses pointers of strictly higher type (derived where
- another uses base), then that alternative is silently chosen.
-
- Note that this technique really only works for 255 arguments. Perhaps
- this is not enough. */
-
-/* These macros and harshness_code are used by the NEW METHOD. */
-#define EVIL_CODE (1<<7)
-#define CONST_CODE (1<<6)
-#define ELLIPSIS_CODE (1<<5)
-#define USER_CODE (1<<4)
-#define STD_CODE (1<<3)
-#define PROMO_CODE (1<<2)
-#define QUAL_CODE (1<<1)
-#define TRIVIAL_CODE (1<<0)
-
-struct harshness_code
-{
- /* What kind of conversion is involved. */
- unsigned short code;
-
- /* The inheritance distance. */
- short distance;
-
- /* For a PROMO_CODE, Any special penalties involved in integral conversions.
- This exists because $4.1 of the ARM states that something like
- `short unsigned int' should promote to `int', not `unsigned int'.
- If, for example, it tries to match two fns, f(int) and f(unsigned),
- f(int) should be a better match than f(unsigned) by this rule. Without
- this extra metric, they both only appear as "integral promotions", which
- will lead to an ambiguity.
- For a TRIVIAL_CODE, This is also used by build_overload_call_real and
- convert_harshness to keep track of other information we need. */
- unsigned short int_penalty;
-};
-
-struct candidate
-{
- struct harshness_code h; /* Used for single-argument conversions. */
-
- int h_len; /* The length of the harshness vector. */
-
- tree function; /* A FUNCTION_DECL */
- tree basetypes; /* The path to function. */
- tree arg; /* first parm to function. */
-
- /* Indexed by argument number, encodes evil, user, d_to_b, and easy
- strikes for that argument. At end of array, we store the index+1
- of where we started using default parameters, or 0 if there are
- none. */
- struct harshness_code *harshness;
-
- union
- {
- tree field; /* If no evil strikes, the FUNCTION_DECL of
- the function (if a member function). */
- int bad_arg; /* the index of the first bad argument:
- 0 if no bad arguments
- > 0 is first bad argument
- -1 if extra actual arguments
- -2 if too few actual arguments.
- -3 if const/non const method mismatch.
- -4 if type unification failed.
- -5 if contravariance violation. */
- } u;
-};
-int rank_for_overload ();
-
-/* Variables shared between class.c and call.c. */
-
-extern int n_vtables;
-extern int n_vtable_entries;
-extern int n_vtable_searches;
-extern int n_vtable_elems;
-extern int n_convert_harshness;
-extern int n_compute_conversion_costs;
-extern int n_build_method_call;
-extern int n_inner_fields_searched;
diff --git a/contrib/gcc/cp/edsel.c b/contrib/gcc/cp/edsel.c
deleted file mode 100644
index 35099d523f76..000000000000
--- a/contrib/gcc/cp/edsel.c
+++ /dev/null
@@ -1,928 +0,0 @@
-/* Interface to LUCID Cadillac system for GNU compiler.
- Copyright (C) 1988, 1992, 1993 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-#include "config.h"
-
-#include "tree.h"
-#include "flags.h"
-#include <stdio.h>
-#include "cp-tree.h"
-#include "obstack.h"
-
-#ifdef CADILLAC
-#include <compilerreq.h>
-#include <compilerconn.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <errno.h>
-#include <sys/file.h>
-
-#define obstack_chunk_alloc xmalloc
-#define obstack_chunk_free free
-
-void init_cadillac ();
-
-extern char *input_filename;
-extern int lineno;
-
-/* Put random information we might want to get back from
- Cadillac here. */
-typedef struct
-{
- /* The connection to the Cadillac kernel. */
- Connection *conn;
-
- /* Input and output file descriptors for Cadillac. */
- short fd_input, fd_output;
-
- /* #include nesting of current file. */
- short depth;
-
- /* State variables for the connection. */
- char messages;
- char conversion;
- char emission;
- char process_until;
-
- /* #if level of current file. */
- int iflevel;
-
- /* Line number that starts current source file. */
- int lineno;
-
- /* Name of current file. */
- char *filename;
-
- /* Where to stop processing (if process_until is set). */
- char *end_filename;
- int end_position;
-
-} cadillac_struct;
-static cadillac_struct cadillacObj;
-
-/* Nonzero if in the process of exiting. */
-static int exiting;
-
-void cadillac_note_source ();
-static void CWriteLanguageDecl ();
-static void CWriteLanguageType ();
-static void CWriteTopLevel ();
-static void cadillac_note_filepos ();
-static void cadillac_process_request (), cadillac_process_requests ();
-static void cadillac_switch_source ();
-static void exit_cadillac ();
-
-/* Blocking test. */
-static int
-readable_p (fd)
- int fd;
-{
- fd_set f;
-
- FD_ZERO (&f);
- FD_SET (fd, &f);
-
- return select (32, &f, NULL, NULL, 0) == 1;
-}
-
-static CObjectType *tree_to_cadillac_map;
-struct obstack cadillac_obstack;
-
-
-#include "stack.h"
-
-struct context_level
-{
- struct stack_level base;
-
- tree context;
-};
-
-/* Stack for maintaining contexts (in case functions or types are nested).
- When defining a struct type, the `context' field is the RECORD_TYPE.
- When defining a function, the `context' field is the FUNCTION_DECL. */
-
-static struct context_level *context_stack;
-
-static struct context_level *
-push_context_level (stack, obstack)
- struct stack_level *stack;
- struct obstack *obstack;
-{
- struct context_level tem;
-
- tem.base.prev = stack;
- return (struct context_level *)push_stack_level (obstack, &tem, sizeof (tem));
-}
-
-/* Discard a level of search allocation. */
-
-static struct context_level *
-pop_context_level (stack)
- struct context_level *stack;
-{
- stack = (struct context_level *)pop_stack_level (stack);
- return stack;
-}
-
-void
-init_cadillac ()
-{
- extern FILE *finput;
- extern int errno;
- CCompilerMessage* req;
- cadillac_struct *cp = &cadillacObj;
- int i;
-
- if (! flag_cadillac)
- return;
-
- tree_to_cadillac_map = (CObjectType*) xmalloc (sizeof (CObjectType) * LAST_CPLUS_TREE_CODE);
- for (i = 0; i < LAST_CPLUS_TREE_CODE; i++)
- tree_to_cadillac_map[i] = MiscOType;
- tree_to_cadillac_map[RECORD_TYPE] = StructOType;
- tree_to_cadillac_map[UNION_TYPE] = UnionOType;
- tree_to_cadillac_map[ENUMERAL_TYPE] = EnumTypeOType;
- tree_to_cadillac_map[TYPE_DECL] = TypedefOType;
- tree_to_cadillac_map[VAR_DECL] = VariableOType;
- tree_to_cadillac_map[CONST_DECL] = EnumConstantOType;
- tree_to_cadillac_map[FUNCTION_DECL] = FunctionOType;
- tree_to_cadillac_map[FIELD_DECL] = FieldOType;
-
-#ifdef sun
- on_exit (&exit_cadillac, 0);
-#endif
-
- gcc_obstack_init (&cadillac_obstack);
-
- /* Yow! This is the way Cadillac was designed to deal with
- Oregon C++ compiler! */
- cp->fd_input = flag_cadillac;
- cp->fd_output = flag_cadillac;
-
- /* Start in "turned-on" state. */
- cp->messages = 1;
- cp->conversion = 1;
- cp->emission = 1;
-
- /* Establish a connection with Cadillac here. */
- cp->conn = NewConnection (cp, cp->fd_input, cp->fd_output);
-
- CWriteHeader (cp->conn, WaitingMType, 0);
- CWriteRequestBuffer (cp->conn);
-
- if (!readable_p (cp->fd_input))
- ;
-
- req = CReadCompilerMessage (cp->conn);
-
- if (!req)
- switch (errno)
- {
- case EWOULDBLOCK:
- sleep (5);
- return;
-
- case 0:
- fatal ("init_cadillac: EOF on connection to kernel, exiting\n");
- break;
-
- default:
- perror ("Editor to kernel connection");
- exit (0);
- }
-}
-
-static void
-cadillac_process_requests (conn)
- Connection *conn;
-{
- CCompilerMessage *req;
- while (req = (CCompilerMessage*) CPeekNextRequest (conn))
- {
- req = CReadCompilerMessage (conn);
- cadillac_process_request (&cadillacObj, req);
- }
-}
-
-static void
-cadillac_process_request (cp, req)
- cadillac_struct *cp;
- CCompilerMessage *req;
-{
- if (! req)
- return;
-
- switch (req->reqType)
- {
- case ProcessUntilMType:
- if (cp->process_until)
- my_friendly_abort (23);
- cp->process_until = 1;
- /* This is not really right. */
- cp->end_position = ((CCompilerCommand*)req)->processuntil.position;
-#if 0
- cp->end_filename = req->processuntil.filename;
-#endif
- break;
-
- case CommandMType:
- switch (req->header.data)
- {
- case MessagesOnCType:
- cp->messages = 1;
- break;
- case MessagesOffCType:
- cp->messages = 0;
- break;
- case ConversionOnCType:
- cp->conversion = 1;
- break;
- case ConversionOffCType:
- cp->conversion = 0;
- break;
- case EmissionOnCType:
- cp->emission = 1;
- break;
- case EmissionOffCType:
- cp->emission = 0;
- break;
-
- case FinishAnalysisCType:
- return;
-
- case PuntAnalysisCType:
- case ContinueAnalysisCType:
- case GotoFileposCType:
- case OpenSucceededCType:
- case OpenFailedCType:
- fprintf (stderr, "request type %d not implemented\n", req->reqType);
- return;
-
- case DieCType:
- if (! exiting)
- my_friendly_abort (24);
- return;
-
- }
- break;
-
- default:
- fatal ("unknown request type %d", req->reqType);
- }
-}
-
-void
-cadillac_start ()
-{
- Connection *conn = cadillacObj.conn;
- CCompilerMessage *req;
-
- /* Let Cadillac know that we start in C++ language scope. */
- CWriteHeader (conn, ForeignLinkageMType, LinkCPlus);
- CWriteLength (conn);
- CWriteRequestBuffer (conn);
-
- cadillac_process_requests (conn);
-}
-
-static void
-cadillac_printf (msg, name)
-{
- if (cadillacObj.messages)
- printf ("[%s,%4d] %s `%s'\n", input_filename, lineno, msg, name);
-}
-
-void
-cadillac_start_decl (decl)
- tree decl;
-{
- Connection *conn = cadillacObj.conn;
- CObjectType object_type = tree_to_cadillac_map [TREE_CODE (decl)];
-
- if (context_stack)
- switch (TREE_CODE (context_stack->context))
- {
- case FUNCTION_DECL:
- /* Currently, cadillac only implements top-level forms. */
- return;
- case RECORD_TYPE:
- case UNION_TYPE:
- cadillac_printf ("start class-level decl", IDENTIFIER_POINTER (DECL_NAME (decl)));
- break;
- default:
- my_friendly_abort (25);
- }
- else
- {
- cadillac_printf ("start top-level decl", IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
- CWriteTopLevel (conn, StartMType);
- }
-
- CWriteLanguageDecl (conn, decl, tree_to_cadillac_map[TREE_CODE (decl)]);
- CWriteRequestBuffer (conn);
- cadillac_process_requests (conn);
-}
-
-void
-cadillac_finish_decl (decl)
- tree decl;
-{
- Connection *conn = cadillacObj.conn;
-
- if (context_stack)
- switch (TREE_CODE (context_stack->context))
- {
- case FUNCTION_DECL:
- return;
- case RECORD_TYPE:
- case UNION_TYPE:
- cadillac_printf ("end class-level decl", IDENTIFIER_POINTER (DECL_NAME (decl)));
- CWriteHeader (conn, EndDefMType, 0);
- CWriteLength (conn);
- break;
- default:
- my_friendly_abort (26);
- }
- else
- {
- cadillac_printf ("end top-level decl", IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
- CWriteHeader (conn, EndDefMType, 0);
- CWriteLength (conn);
- CWriteTopLevel (conn, StopMType);
- }
-
- CWriteRequestBuffer (conn);
- cadillac_process_requests (conn);
-}
-
-void
-cadillac_start_function (fndecl)
- tree fndecl;
-{
- Connection *conn = cadillacObj.conn;
-
- if (context_stack)
- /* nested functions not yet handled. */
- my_friendly_abort (27);
-
- cadillac_printf ("start top-level function", lang_printable_name (fndecl));
- context_stack = push_context_level (context_stack, &cadillac_obstack);
- context_stack->context = fndecl;
-
- CWriteTopLevel (conn, StartMType);
- my_friendly_assert (TREE_CODE (fndecl) == FUNCTION_DECL, 202);
- CWriteLanguageDecl (conn, fndecl,
- (TREE_CODE (TREE_TYPE (fndecl)) == METHOD_TYPE
- ? MemberFnOType : FunctionOType));
- CWriteRequestBuffer (conn);
- cadillac_process_requests (conn);
-}
-
-void
-cadillac_finish_function (fndecl)
- tree fndecl;
-{
- Connection *conn = cadillacObj.conn;
-
- cadillac_printf ("end top-level function", lang_printable_name (fndecl));
- context_stack = pop_context_level (context_stack);
-
- if (context_stack)
- /* nested functions not yet implemented. */
- my_friendly_abort (28);
-
- CWriteHeader (conn, EndDefMType, 0);
- CWriteLength (conn);
- CWriteTopLevel (conn, StopMType);
- CWriteRequestBuffer (conn);
- cadillac_process_requests (conn);
-}
-
-void
-cadillac_finish_anon_union (decl)
- tree decl;
-{
- Connection *conn = cadillacObj.conn;
-
- if (! global_bindings_p ())
- return;
- cadillac_printf ("finish top-level anon union", "");
- CWriteHeader (conn, EndDefMType, 0);
- CWriteLength (conn);
- CWriteTopLevel (conn, StopMType);
- CWriteRequestBuffer (conn);
- cadillac_process_requests (conn);
-}
-
-void
-cadillac_start_enum (type)
- tree type;
-{
- Connection *conn = cadillacObj.conn;
-
- tree name = TYPE_NAME (type);
-
- if (TREE_CODE (name) == TYPE_DECL)
- name = DECL_NAME (name);
-
- if (context_stack)
- switch (TREE_CODE (context_stack->context))
- {
- case FUNCTION_DECL:
- return;
- case RECORD_TYPE:
- case UNION_TYPE:
- break;
- default:
- my_friendly_abort (29);
- }
- else
- {
- cadillac_printf ("start top-level enum", IDENTIFIER_POINTER (name));
- CWriteTopLevel (conn, StartMType);
- }
-
- CWriteLanguageType (conn, type, tree_to_cadillac_map[ENUMERAL_TYPE]);
-}
-
-void
-cadillac_finish_enum (type)
- tree type;
-{
- Connection *conn = cadillacObj.conn;
- tree name = TYPE_NAME (type);
-
- if (TREE_CODE (name) == TYPE_DECL)
- name = DECL_NAME (name);
-
- if (context_stack)
- switch (TREE_CODE (context_stack->context))
- {
- case FUNCTION_DECL:
- return;
- case RECORD_TYPE:
- case UNION_TYPE:
- CWriteHeader (conn, EndDefMType, 0);
- CWriteLength (conn);
- break;
- default:
- my_friendly_abort (30);
- }
- else
- {
- CWriteHeader (conn, EndDefMType, 0);
- CWriteLength (conn);
- cadillac_printf ("finish top-level enum", IDENTIFIER_POINTER (name));
- CWriteTopLevel (conn, StopMType);
- }
-
- CWriteRequestBuffer (conn);
- cadillac_process_requests (conn);
-}
-
-void
-cadillac_start_struct (type)
- tree type;
-{
- Connection *conn = cadillacObj.conn;
- tree name = TYPE_NAME (type);
-
- if (TREE_CODE (name) == TYPE_DECL)
- name = DECL_NAME (name);
-
- if (context_stack)
- switch (TREE_CODE (context_stack->context))
- {
- case FUNCTION_DECL:
- return;
- case RECORD_TYPE:
- case UNION_TYPE:
- return;
- default:
- my_friendly_abort (31);
- }
- else
- {
- cadillac_printf ("start struct", IDENTIFIER_POINTER (name));
- CWriteTopLevel (conn, StartMType);
- }
-
- context_stack = push_context_level (context_stack, &cadillac_obstack);
- context_stack->context = type;
-
- CWriteLanguageType (conn, type,
- TYPE_LANG_SPECIFIC (type) && CLASSTYPE_DECLARED_CLASS (type) ? ClassOType : tree_to_cadillac_map[TREE_CODE (type)]);
-}
-
-void
-cadillac_finish_struct (type)
- tree type;
-{
- Connection *conn = cadillacObj.conn;
- tree name = TYPE_NAME (type);
-
- if (TREE_CODE (name) == TYPE_DECL)
- name = DECL_NAME (name);
-
- context_stack = pop_context_level (context_stack);
- if (context_stack)
- return;
-
- cadillac_printf ("finish struct", IDENTIFIER_POINTER (name));
- CWriteHeader (conn, EndDefMType, 0);
- CWriteLength (conn);
- CWriteTopLevel (conn, StopMType);
- CWriteRequestBuffer (conn);
- cadillac_process_requests (conn);
-}
-
-void
-cadillac_finish_exception (type)
- tree type;
-{
- Connection *conn = cadillacObj.conn;
-
- fatal ("cadillac_finish_exception");
- CWriteHeader (conn, EndDefMType, 0);
- CWriteLength (conn);
- CWriteTopLevel (conn, StopMType);
- CWriteRequestBuffer (conn);
- cadillac_process_requests (conn);
-}
-
-void
-cadillac_push_class (type)
- tree type;
-{
-}
-
-void
-cadillac_pop_class ()
-{
-}
-
-void
-cadillac_push_lang (name)
- tree name;
-{
- Connection *conn = cadillacObj.conn;
- CLinkLanguageType m;
-
- if (name == lang_name_cplusplus)
- m = LinkCPlus;
- else if (name == lang_name_c)
- m = LinkC;
- else
- my_friendly_abort (32);
- CWriteHeader (conn, ForeignLinkageMType, m);
- CWriteRequestBuffer (conn);
- cadillac_process_requests (conn);
-}
-
-void
-cadillac_pop_lang ()
-{
- Connection *conn = cadillacObj.conn;
-
- CWriteHeader (conn, ForeignLinkageMType, LinkPop);
- CWriteRequestBuffer (conn);
- cadillac_process_requests (conn);
-}
-
-void
-cadillac_finish_stmt ()
-{
-}
-
-void
-cadillac_note_source ()
-{
- cadillacObj.lineno = lineno;
- cadillacObj.filename = input_filename;
-}
-
-static void
-CWriteTopLevel (conn, m)
- Connection *conn;
- CMessageSubType m;
-{
- static context_id = 0;
- CWriteHeader (conn, TopLevelFormMType, m);
- cadillac_note_filepos ();
-
- /* Eventually, this will point somewhere into the digest file. */
- context_id += 1;
- CWriteSomething (conn, &context_id, sizeof (BITS32));
-
- CWriteSomething (conn, &cadillacObj.iflevel, sizeof (BITS32));
- CWriteLength (conn);
-}
-
-static void
-cadillac_note_filepos ()
-{
- extern FILE *finput;
- int pos = ftell (finput);
- CWriteSomething (cadillacObj.conn, &pos, sizeof (BITS32));
-}
-
-void
-cadillac_switch_source (startflag)
- int startflag;
-{
- Connection *conn = cadillacObj.conn;
- /* Send out the name of the source file being compiled. */
-
- CWriteHeader (conn, SourceFileMType, startflag ? StartMType : StopMType);
- CWriteSomething (conn, &cadillacObj.depth, sizeof (BITS16));
- CWriteVstring0 (conn, input_filename);
- CWriteLength (conn);
- CWriteRequestBuffer (conn);
- cadillac_process_requests (conn);
-}
-
-void
-cadillac_push_source ()
-{
- cadillacObj.depth += 1;
- cadillac_switch_source (1);
-}
-
-void
-cadillac_pop_source ()
-{
- cadillacObj.depth -= 1;
- cadillac_switch_source (0);
-}
-
-struct cadillac_mdep
-{
- short object_type;
- char linkage;
- char access;
- short length;
-};
-
-static void
-CWriteLanguageElem (conn, p, name)
- Connection *conn;
- struct cadillac_mdep *p;
- char *name;
-{
- CWriteSomething (conn, &p->object_type, sizeof (BITS16));
- CWriteSomething (conn, &p->linkage, sizeof (BITS8));
- CWriteSomething (conn, &p->access, sizeof (BITS8));
- CWriteSomething (conn, &p->length, sizeof (BITS16));
- CWriteVstring0 (conn, name);
-
-#if 0
- /* Don't write date_type. */
- CWriteVstring0 (conn, "");
-#endif
- CWriteLength (conn);
-}
-
-static void
-CWriteLanguageDecl (conn, decl, object_type)
- Connection *conn;
- tree decl;
- CObjectType object_type;
-{
- struct cadillac_mdep foo;
- tree name;
-
- CWriteHeader (conn, LanguageElementMType, StartDefineMType);
- foo.object_type = object_type;
- if (decl_type_context (decl))
- {
- foo.linkage = ParentLinkage;
- if (TREE_PRIVATE (decl))
- foo.access = PrivateAccess;
- else if (TREE_PROTECTED (decl))
- foo.access = ProtectedAccess;
- else
- foo.access = PublicAccess;
- }
- else
- {
- if (TREE_PUBLIC (decl))
- foo.linkage = GlobalLinkage;
- else
- foo.linkage = FileLinkage;
- foo.access = PublicAccess;
- }
- name = DECL_NAME (decl);
- foo.length = IDENTIFIER_LENGTH (name);
-
- CWriteLanguageElem (conn, &foo, IDENTIFIER_POINTER (name));
- CWriteRequestBuffer (conn);
- cadillac_process_requests (conn);
-}
-
-static void
-CWriteLanguageType (conn, type, object_type)
- Connection *conn;
- tree type;
- CObjectType object_type;
-{
- struct cadillac_mdep foo;
- tree name = TYPE_NAME (type);
-
- CWriteHeader (conn, LanguageElementMType, StartDefineMType);
- foo.object_type = object_type;
- if (current_class_type)
- {
- foo.linkage = ParentLinkage;
- if (TREE_PRIVATE (type))
- foo.access = PrivateAccess;
- else if (TREE_PROTECTED (type))
- foo.access = ProtectedAccess;
- else
- foo.access = PublicAccess;
- }
- else
- {
- foo.linkage = NoLinkage;
- foo.access = PublicAccess;
- }
- if (TREE_CODE (name) == TYPE_DECL)
- name = DECL_NAME (name);
-
- foo.length = IDENTIFIER_LENGTH (name);
-
- CWriteLanguageElem (conn, &foo, IDENTIFIER_POINTER (name));
- CWriteRequestBuffer (conn);
- cadillac_process_requests (conn);
-}
-
-static void
-CWriteUseObject (conn, type, object_type, use)
- Connection *conn;
- tree type;
- CObjectType object_type;
- CMessageSubType use;
-{
- struct cadillac_mdep foo;
- tree name = NULL_TREE;
-
- CWriteHeader (conn, LanguageElementMType, use);
- foo.object_type = object_type;
- if (current_class_type)
- {
- foo.linkage = ParentLinkage;
- if (TREE_PRIVATE (type))
- foo.access = PrivateAccess;
- else if (TREE_PROTECTED (type))
- foo.access = ProtectedAccess;
- else
- foo.access = PublicAccess;
- }
- else
- {
- foo.linkage = NoLinkage;
- foo.access = PublicAccess;
- }
- switch (TREE_CODE (type))
- {
- case VAR_DECL:
- case FIELD_DECL:
- case TYPE_DECL:
- case CONST_DECL:
- case FUNCTION_DECL:
- name = DECL_NAME (type);
- break;
-
- default:
- my_friendly_abort (33);
- }
-
- foo.length = IDENTIFIER_LENGTH (name);
-
- CWriteLanguageElem (conn, &foo, IDENTIFIER_POINTER (name));
- CWriteRequestBuffer (conn);
- cadillac_process_requests (conn);
-}
-
-/* Here's how we exit under cadillac. */
-
-static void
-exit_cadillac ()
-{
- extern int errorcount;
-
- Connection *conn = cadillacObj.conn;
-
- if (flag_cadillac)
- {
- CCompilerMessage *req;
-
- CWriteHeader (conn, FinishedMType,
- errorcount ? 0 : CsObjectWritten | CsComplete);
- /* Bye, bye! */
- CWriteRequestBuffer (conn);
-
- /* Block on read. */
- while (! readable_p (cadillacObj.fd_input))
- {
- if (exiting)
- my_friendly_abort (34);
- exiting = 1;
- }
- exiting = 1;
-
- req = CReadCompilerMessage (conn);
- cadillac_process_request (&cadillacObj, req);
- }
-}
-
-#else
-/* Stubs. */
-void init_cadillac () {}
-void cadillac_start () {}
-void cadillac_start_decl (decl)
- tree decl;
-{}
-void
-cadillac_finish_decl (decl)
- tree decl;
-{}
-void
-cadillac_start_function (fndecl)
- tree fndecl;
-{}
-void
-cadillac_finish_function (fndecl)
- tree fndecl;
-{}
-void
-cadillac_finish_anon_union (decl)
- tree decl;
-{}
-void
-cadillac_start_enum (type)
- tree type;
-{}
-void
-cadillac_finish_enum (type)
- tree type;
-{}
-void
-cadillac_start_struct (type)
- tree type;
-{}
-void
-cadillac_finish_struct (type)
- tree type;
-{}
-void
-cadillac_finish_exception (type)
- tree type;
-{}
-void
-cadillac_push_class (type)
- tree type;
-{}
-void
-cadillac_pop_class ()
-{}
-void
-cadillac_push_lang (name)
- tree name;
-{}
-void
-cadillac_pop_lang ()
-{}
-void
-cadillac_note_source ()
-{}
-void
-cadillac_finish_stmt ()
-{}
-void
-cadillac_switch_source ()
-{}
-void
-cadillac_push_source ()
-{}
-void
-cadillac_pop_source ()
-{}
-#endif
diff --git a/contrib/gcc/cp/g++.c b/contrib/gcc/cp/g++.c
deleted file mode 100644
index efb6231a20d1..000000000000
--- a/contrib/gcc/cp/g++.c
+++ /dev/null
@@ -1,582 +0,0 @@
-/* G++ preliminary semantic processing for the compiler driver.
- Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
- Contributed by Brendan Kehoe (brendan@cygnus.com).
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-/* This program is a wrapper to the main `gcc' driver. For GNU C++,
- we need to do two special things: a) append `-lg++' in situations
- where it's appropriate, to link in libg++, and b) add `-xc++'..`-xnone'
- around file arguments named `foo.c' or `foo.i'. So, we do all of
- this semantic processing then just exec gcc with the new argument
- list.
-
- We used to do all of this in a small shell script, but many users
- found the performance of this as a shell script to be unacceptable.
- In situations where your PATH has a lot of NFS-mounted directories,
- using a script that runs sed and other things would be a nasty
- performance hit. With this program, we never search the PATH at all. */
-
-#include "config.h"
-#ifdef __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-#include <stdio.h>
-#include <sys/types.h>
-#if !defined(_WIN32)
-#include <sys/file.h> /* May get R_OK, etc. on some systems. */
-#else
-#include <process.h>
-#endif
-#include <errno.h>
-
-/* Defined to the name of the compiler; if using a cross compiler, the
- Makefile should compile this file with the proper name
- (e.g., "i386-aout-gcc"). */
-#ifndef GCC_NAME
-#define GCC_NAME "gcc"
-#endif
-
-/* This bit is set if we saw a `-xfoo' language specification. */
-#define LANGSPEC (1<<1)
-/* This bit is set if they did `-lm' or `-lmath'. */
-#define MATHLIB (1<<2)
-
-#ifndef MATH_LIBRARY
-#define MATH_LIBRARY "-lm"
-#endif
-
-/* On MSDOS, write temp files in current dir
- because there's no place else we can expect to use. */
-#ifdef __MSDOS__
-#ifndef P_tmpdir
-#define P_tmpdir "."
-#endif
-#ifndef R_OK
-#define R_OK 4
-#define W_OK 2
-#define X_OK 1
-#endif
-#endif
-
-#ifndef VPROTO
-#ifdef __STDC__
-#define PVPROTO(ARGS) ARGS
-#define VPROTO(ARGS) ARGS
-#define VA_START(va_list,var) va_start(va_list,var)
-#else
-#define PVPROTO(ARGS) ()
-#define VPROTO(ARGS) (va_alist) va_dcl
-#define VA_START(va_list,var) va_start(va_list)
-#endif
-#endif
-
-#ifndef errno
-extern int errno;
-#endif
-
-extern int sys_nerr;
-#ifndef HAVE_STRERROR
-#if defined(bsd4_4)
-extern const char *const sys_errlist[];
-#else
-extern char *sys_errlist[];
-#endif
-#else
-extern char *strerror();
-#endif
-
-/* Name with which this program was invoked. */
-static char *programname;
-
-char *
-my_strerror(e)
- int e;
-{
-
-#ifdef HAVE_STRERROR
- return strerror(e);
-
-#else
-
- static char buffer[30];
- if (!e)
- return "";
-
- if (e > 0 && e < sys_nerr)
- return sys_errlist[e];
-
- sprintf (buffer, "Unknown error %d", e);
- return buffer;
-#endif
-}
-
-#ifdef HAVE_VPRINTF
-/* Output an error message and exit */
-
-static void
-fatal VPROTO((char *format, ...))
-{
-#ifndef __STDC__
- char *format;
-#endif
- va_list ap;
-
- VA_START (ap, format);
-
-#ifndef __STDC__
- format = va_arg (ap, char*);
-#endif
-
- fprintf (stderr, "%s: ", programname);
- vfprintf (stderr, format, ap);
- va_end (ap);
- fprintf (stderr, "\n");
-#if 0
- /* XXX Not needed for g++ driver. */
- delete_temp_files ();
-#endif
- exit (1);
-}
-
-static void
-error VPROTO((char *format, ...))
-{
-#ifndef __STDC__
- char *format;
-#endif
- va_list ap;
-
- VA_START (ap, format);
-
-#ifndef __STDC__
- format = va_arg (ap, char*);
-#endif
-
- fprintf (stderr, "%s: ", programname);
- vfprintf (stderr, format, ap);
- va_end (ap);
-
- fprintf (stderr, "\n");
-}
-
-#else /* not HAVE_VPRINTF */
-
-static void
-error (msg, arg1, arg2)
- char *msg, *arg1, *arg2;
-{
- fprintf (stderr, "%s: ", programname);
- fprintf (stderr, msg, arg1, arg2);
- fprintf (stderr, "\n");
-}
-
-static void
-fatal (msg, arg1, arg2)
- char *msg, *arg1, *arg2;
-{
- error (msg, arg1, arg2);
-#if 0
- /* XXX Not needed for g++ driver. */
- delete_temp_files ();
-#endif
- exit (1);
-}
-
-#endif /* not HAVE_VPRINTF */
-
-/* More 'friendly' abort that prints the line and file.
- config.h can #define abort fancy_abort if you like that sort of thing. */
-
-void
-fancy_abort ()
-{
- fatal ("Internal g++ abort.");
-}
-
-char *
-xmalloc (size)
- unsigned size;
-{
- register char *value = (char *) malloc (size);
- if (value == 0)
- fatal ("virtual memory exhausted");
- return value;
-}
-
-/* Return a newly-allocated string whose contents concatenate those
- of s1, s2, s3. */
-static char *
-concat (s1, s2, s3)
- char *s1, *s2, *s3;
-{
- int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3);
- char *result = xmalloc (len1 + len2 + len3 + 1);
-
- strcpy (result, s1);
- strcpy (result + len1, s2);
- strcpy (result + len1 + len2, s3);
- *(result + len1 + len2 + len3) = 0;
-
- return result;
-}
-
-static void
-pfatal_with_name (name)
- char *name;
-{
- fatal (concat ("%s: ", my_strerror (errno), ""), name);
-}
-
-#ifdef __MSDOS__
-/* This is the common prefix we use to make temp file names. */
-char *temp_filename;
-
-/* Length of the prefix. */
-int temp_filename_length;
-
-/* Compute a string to use as the base of all temporary file names. */
-static char *
-choose_temp_base_try (try, base)
-char *try;
-char *base;
-{
- char *rv;
- if (base)
- rv = base;
- else if (try == (char *)0)
- rv = 0;
- else if (access (try, R_OK | W_OK) != 0)
- rv = 0;
- else
- rv = try;
- return rv;
-}
-
-static void
-choose_temp_base ()
-{
- char *base = 0;
- int len;
-
- base = choose_temp_base_try (getenv ("TMPDIR"), base);
- base = choose_temp_base_try (getenv ("TMP"), base);
- base = choose_temp_base_try (getenv ("TEMP"), base);
-
-#ifdef P_tmpdir
- base = choose_temp_base_try (P_tmpdir, base);
-#endif
-
- base = choose_temp_base_try ("/usr/tmp", base);
- base = choose_temp_base_try ("/tmp", base);
-
- /* If all else fails, use the current directory! */
- if (base == (char *)0)
- base = "./";
-
- len = strlen (base);
- temp_filename = xmalloc (len + sizeof("/ccXXXXXX"));
- strcpy (temp_filename, base);
- if (len > 0 && temp_filename[len-1] != '/')
- temp_filename[len++] = '/';
- strcpy (temp_filename + len, "ccXXXXXX");
-
- mktemp (temp_filename);
- temp_filename_length = strlen (temp_filename);
- if (temp_filename_length == 0)
- abort ();
-}
-
-static void
-perror_exec (name)
- char *name;
-{
- char *s;
-
- if (errno < sys_nerr)
- s = concat ("installation problem, cannot exec %s: ",
- my_strerror( errno ), "");
- else
- s = "installation problem, cannot exec %s";
- error (s, name);
-}
-
-/* This is almost exactly what's in gcc.c:pexecute for MSDOS. */
-void
-run_dos (program, argv)
- char *program;
- char *argv[];
-{
- char *scmd, *rf;
- FILE *argfile;
- int i;
-
- choose_temp_base (); /* not in gcc.c */
-
- scmd = (char *) malloc (strlen (program) + strlen (temp_filename) + 10);
- rf = scmd + strlen (program) + 6;
- sprintf (scmd, "%s.exe @%s.gp", program, temp_filename);
-
- argfile = fopen (rf, "w");
- if (argfile == 0)
- pfatal_with_name (rf);
-
- for (i=1; argv[i]; i++)
- {
- char *cp;
- for (cp = argv[i]; *cp; cp++)
- {
- if (*cp == '"' || *cp == '\'' || *cp == '\\' || isspace (*cp))
- fputc ('\\', argfile);
- fputc (*cp, argfile);
- }
- fputc ('\n', argfile);
- }
- fclose (argfile);
-
- i = system (scmd);
-
- remove (rf);
-
- if (i == -1)
- perror_exec (program);
-}
-#endif /* __MSDOS__ */
-
-int
-main (argc, argv)
- int argc;
- char **argv;
-{
- register int i, j = 0;
- register char *p;
- int verbose = 0;
-
- /* This will be 0 if we encounter a situation where we should not
- link in libstdc++, or 2 if we should link in libg++ as well. */
- int library = 1;
-
- /* Used to track options that take arguments, so we don't go wrapping
- those with -xc++/-xnone. */
- char *quote = NULL;
-
- /* The new argument list will be contained in this. */
- char **arglist;
-
- /* The name of the compiler we will want to run---by default, it
- will be the definition of `GCC_NAME', e.g., `gcc'. */
- char *gcc = GCC_NAME;
-
- /* Non-zero if we saw a `-xfoo' language specification on the
- command line. Used to avoid adding our own -xc++ if the user
- already gave a language for the file. */
- int saw_speclang = 0;
-
- /* Non-zero if we saw `-lm' or `-lmath' on the command line. */
- char *saw_math = 0;
-
- /* The number of arguments being added to what's in argv, other than
- libraries. We use this to track the number of times we've inserted
- -xc++/-xnone. */
- int added = 0;
-
- /* An array used to flag each argument that needs a bit set for
- LANGSPEC or MATHLIB. */
- int *args;
-
- p = argv[0] + strlen (argv[0]);
-
- /* If we're called as g++ (or i386-aout-g++), link in libg++ as well. */
-
- if (strcmp (p - 3, "g++") == 0)
- {
- library = 2;
- }
-
- while (p != argv[0] && p[-1] != '/')
- --p;
- programname = p;
-
- if (argc == 1)
- fatal ("No input files specified");
-
-#ifndef __MSDOS__
- /* We do a little magic to find out where the main gcc executable
- is. If they ran us as /usr/local/bin/g++, then we will look
- for /usr/local/bin/gcc; similarly, if they just ran us as `g++',
- we'll just look for `gcc'. */
- if (p != argv[0])
- {
- *--p = '\0';
- gcc = (char *) malloc ((strlen (argv[0]) + 1 + strlen (GCC_NAME) + 1)
- * sizeof (char));
- sprintf (gcc, "%s/%s", argv[0], GCC_NAME);
- }
-#endif
-
- args = (int *) malloc (argc * sizeof (int));
- bzero ((char *) args, argc * sizeof (int));
-
- for (i = 1; i < argc; i++)
- {
- /* If the previous option took an argument, we swallow it here. */
- if (quote)
- {
- quote = NULL;
- continue;
- }
-
- if (argv[i][0] == '\0' || argv[i][1] == '\0')
- continue;
-
- if (argv[i][0] == '-')
- {
- if (library != 0 && strcmp (argv[i], "-nostdlib") == 0)
- {
- library = 0;
- }
- else if (strcmp (argv[i], "-lm") == 0
- || strcmp (argv[i], "-lmath") == 0)
- args[i] |= MATHLIB;
- else if (strcmp (argv[i], "-v") == 0)
- {
- verbose = 1;
- if (argc == 2)
- {
- /* If they only gave us `-v', don't try to link
- in libg++. */
- library = 0;
- }
- }
- else if (strncmp (argv[i], "-x", 2) == 0)
- saw_speclang = 1;
- else if (((argv[i][2] == '\0'
- && (char *)strchr ("bBVDUoeTuIYmLiA", argv[i][1]) != NULL)
- || strcmp (argv[i], "-Tdata") == 0))
- quote = argv[i];
- else if (library != 0 && ((argv[i][2] == '\0'
- && (char *) strchr ("cSEM", argv[i][1]) != NULL)
- || strcmp (argv[i], "-MM") == 0))
- {
- /* Don't specify libraries if we won't link, since that would
- cause a warning. */
- library = 0;
- }
- else
- /* Pass other options through. */
- continue;
- }
- else
- {
- int len;
-
- if (saw_speclang)
- {
- saw_speclang = 0;
- continue;
- }
-
- /* If the filename ends in .c or .i, put options around it.
- But not if a specified -x option is currently active. */
- len = strlen (argv[i]);
- if (len > 2
- && (argv[i][len - 1] == 'c' || argv[i][len - 1] == 'i')
- && argv[i][len - 2] == '.')
- {
- args[i] |= LANGSPEC;
- added += 2;
- }
- }
- }
-
- if (quote)
- fatal ("argument to `%s' missing\n", quote);
-
- if (added || library)
- {
- arglist = (char **) malloc ((argc + added + 4) * sizeof (char *));
-
- for (i = 1, j = 1; i < argc; i++, j++)
- {
- arglist[j] = argv[i];
-
- /* Make sure -lg++ is before the math library, since libg++
- itself uses those math routines. */
- if (!saw_math && (args[i] & MATHLIB) && library)
- {
- --j;
- saw_math = argv[i];
- }
-
- /* Wrap foo.c and foo.i files in a language specification to
- force the gcc compiler driver to run cc1plus on them. */
- if (args[i] & LANGSPEC)
- {
- int len = strlen (argv[i]);
- if (argv[i][len - 1] == 'i')
- arglist[j++] = "-xc++-cpp-output";
- else
- arglist[j++] = "-xc++";
- arglist[j++] = argv[i];
- arglist[j] = "-xnone";
- }
- }
-
- /* Add `-lg++' if we haven't already done so. */
- if (library == 2)
- arglist[j++] = "-lg++";
- if (library)
- arglist[j++] = "-lstdc++";
- if (saw_math)
- arglist[j++] = saw_math;
- else if (library)
- arglist[j++] = MATH_LIBRARY;
-
- arglist[j] = NULL;
- }
- else
- /* No need to copy 'em all. */
- arglist = argv;
-
- arglist[0] = gcc;
-
- if (verbose)
- {
- if (j == 0)
- j = argc;
-
- for (i = 0; i < j; i++)
- fprintf (stderr, " %s", arglist[i]);
- fprintf (stderr, "\n");
- }
-#if !defined(OS2) && !defined (_WIN32)
-#ifdef __MSDOS__
- run_dos (gcc, arglist);
-#else /* !__MSDOS__ */
- if (execvp (gcc, arglist) < 0)
- pfatal_with_name (gcc);
-#endif /* __MSDOS__ */
-#else /* OS2 or _WIN32 */
- if (spawnvp (1, gcc, arglist) < 0)
- pfatal_with_name (gcc);
-#endif
-
- return 0;
-}
diff --git a/contrib/gcc/cp/gc.c b/contrib/gcc/cp/gc.c
deleted file mode 100644
index cff1635f53a4..000000000000
--- a/contrib/gcc/cp/gc.c
+++ /dev/null
@@ -1,1550 +0,0 @@
-/* Garbage collection primitives for GNU C++.
- Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
- Contributed by Michael Tiemann (tiemann@cygnus.com)
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-
-#include "config.h"
-#include "tree.h"
-#include "cp-tree.h"
-#include "flags.h"
-#include "output.h"
-
-#undef NULL
-#define NULL 0
-
-extern tree define_function ();
-extern tree build_t_desc_overload ();
-extern struct obstack *permanent_obstack;
-
-/* This is the function decl for the (pseudo-builtin) __gc_protect
- function. Args are (class *value, int index); Returns value. */
-tree gc_protect_fndecl;
-
-/* This is the function decl for the (pseudo-builtin) __gc_unprotect
- function. Args are (int index); void return. */
-tree gc_unprotect_fndecl;
-
-/* This is the function decl for the (pseudo-builtin) __gc_push
- function. Args are (int length); void return. */
-tree gc_push_fndecl;
-
-/* This is the function decl for the (pseudo-builtin) __gc_pop
- function. Args are void; void return. */
-tree gc_pop_fndecl;
-
-/* Special integers that are used to represent bits in gc-safe objects. */
-tree gc_nonobject;
-tree gc_visible;
-tree gc_white;
-tree gc_offwhite;
-tree gc_grey;
-tree gc_black;
-
-/* in c-common.c */
-extern tree combine_strings PROTO((tree));
-
-/* Predicate that returns non-zero if TYPE needs some kind of
- entry for the GC. Returns zero otherwise. */
-int
-type_needs_gc_entry (type)
- tree type;
-{
- tree ttype = type;
-
- if (! flag_gc || type == error_mark_node)
- return 0;
-
- /* Aggregate types need gc entries if any of their members
- need gc entries. */
- if (IS_AGGR_TYPE (type))
- {
- tree binfos;
- tree fields = TYPE_FIELDS (type);
- int i;
-
- /* We don't care about certain pointers. Pointers
- to virtual baseclasses are always up front. We also
- cull out virtual function table pointers because it's
- easy, and it simplifies the logic.*/
- while (fields
- && (DECL_NAME (fields) == NULL_TREE
- || VFIELD_NAME_P (DECL_NAME (fields))
- || VBASE_NAME_P (DECL_NAME (fields))
- || !strcmp (IDENTIFIER_POINTER (DECL_NAME (fields)), "__bits")))
- fields = TREE_CHAIN (fields);
-
- while (fields)
- {
- if (type_needs_gc_entry (TREE_TYPE (fields)))
- return 1;
- fields = TREE_CHAIN (fields);
- }
-
- binfos = TYPE_BINFO_BASETYPES (type);
- if (binfos)
- for (i = TREE_VEC_LENGTH (binfos)-1; i >= 0; i--)
- if (type_needs_gc_entry (BINFO_TYPE (TREE_VEC_ELT (binfos, i))))
- return 1;
-
- return 0;
- }
-
- while (TREE_CODE (ttype) == ARRAY_TYPE
- && TREE_CODE (TREE_TYPE (ttype)) == ARRAY_TYPE)
- ttype = TREE_TYPE (ttype);
- if ((TREE_CODE (ttype) == POINTER_TYPE
- || TREE_CODE (ttype) == ARRAY_TYPE
- || TREE_CODE (ttype) == REFERENCE_TYPE)
- && IS_AGGR_TYPE (TREE_TYPE (ttype))
- && CLASSTYPE_RTTI (TREE_TYPE (ttype)))
- return 1;
-
- return 0;
-}
-
-/* Predicate that returns non-zero iff FROM is safe from the GC.
-
- If TO is nonzero, it means we know that FROM is being stored
- in TO, which make make it safe. */
-int
-value_safe_from_gc (to, from)
- tree to, from;
-{
- /* First, return non-zero for easy cases: parameters,
- static variables. */
- if (TREE_CODE (from) == PARM_DECL
- || (TREE_CODE (from) == VAR_DECL
- && TREE_STATIC (from)))
- return 1;
-
- /* If something has its address taken, it cannot be
- in the heap, so it doesn't need to be protected. */
- if (TREE_CODE (from) == ADDR_EXPR || TREE_REFERENCE_EXPR (from))
- return 1;
-
- /* If we are storing into a static variable, then what
- we store will be safe from the gc. */
- if (to && TREE_CODE (to) == VAR_DECL
- && TREE_STATIC (to))
- return 1;
-
- /* Now recurse on structure of FROM. */
- switch (TREE_CODE (from))
- {
- case COMPONENT_REF:
- /* These guys are special, and safe. */
- if (TREE_CODE (TREE_OPERAND (from, 1)) == FIELD_DECL
- && (VFIELD_NAME_P (DECL_NAME (TREE_OPERAND (from, 1)))
- || VBASE_NAME_P (DECL_NAME (TREE_OPERAND (from, 1)))))
- return 1;
- /* fall through... */
- case NOP_EXPR:
- case CONVERT_EXPR:
- case NON_LVALUE_EXPR:
- case WITH_CLEANUP_EXPR:
- case SAVE_EXPR:
- case PREDECREMENT_EXPR:
- case PREINCREMENT_EXPR:
- case POSTDECREMENT_EXPR:
- case POSTINCREMENT_EXPR:
- if (value_safe_from_gc (to, TREE_OPERAND (from, 0)))
- return 1;
- break;
-
- case VAR_DECL:
- case PARM_DECL:
- /* We can safely pass these things as parameters to functions. */
- if (to == 0)
- return 1;
-
- case ARRAY_REF:
- case INDIRECT_REF:
- case RESULT_DECL:
- case OFFSET_REF:
- case CALL_EXPR:
- case METHOD_CALL_EXPR:
- break;
-
- case COMPOUND_EXPR:
- case TARGET_EXPR:
- if (value_safe_from_gc (to, TREE_OPERAND (from, 1)))
- return 1;
- break;
-
- case COND_EXPR:
- if (value_safe_from_gc (to, TREE_OPERAND (from, 1))
- && value_safe_from_gc (to, TREE_OPERAND (from, 2)))
- return 1;
- break;
-
- case PLUS_EXPR:
- case MINUS_EXPR:
- if ((type_needs_gc_entry (TREE_TYPE (TREE_OPERAND (from, 0)))
- || value_safe_from_gc (to, TREE_OPERAND (from, 0)))
- && (type_needs_gc_entry (TREE_TYPE (TREE_OPERAND (from, 1))) == 0
- || value_safe_from_gc (to, TREE_OPERAND (from, 1))))
- return 1;
- break;
-
- case RTL_EXPR:
- /* Every time we build an RTL_EXPR in the front-end, we must
- ensure that everything in it is safe from the garbage collector.
- ??? This has only been done for `build_new'. */
- return 1;
-
- default:
- my_friendly_abort (41);
- }
-
- if (to == 0)
- return 0;
-
- /* FROM wasn't safe. But other properties of TO might make it safe. */
- switch (TREE_CODE (to))
- {
- case VAR_DECL:
- case PARM_DECL:
- /* We already culled out static VAR_DECLs above. */
- return 0;
-
- case COMPONENT_REF:
- /* These guys are special, and safe. */
- if (TREE_CODE (TREE_OPERAND (to, 1)) == FIELD_DECL
- && (VFIELD_NAME_P (DECL_NAME (TREE_OPERAND (to, 1)))
- || VBASE_NAME_P (DECL_NAME (TREE_OPERAND (to, 1)))))
- return 1;
- /* fall through... */
-
- case NOP_EXPR:
- case NON_LVALUE_EXPR:
- case WITH_CLEANUP_EXPR:
- case SAVE_EXPR:
- case PREDECREMENT_EXPR:
- case PREINCREMENT_EXPR:
- case POSTDECREMENT_EXPR:
- case POSTINCREMENT_EXPR:
- return value_safe_from_gc (TREE_OPERAND (to, 0), from);
-
- case COMPOUND_EXPR:
- case TARGET_EXPR:
- return value_safe_from_gc (TREE_OPERAND (to, 1), from);
-
- case COND_EXPR:
- return (value_safe_from_gc (TREE_OPERAND (to, 1), from)
- && value_safe_from_gc (TREE_OPERAND (to, 2), from));
-
- case INDIRECT_REF:
- case ARRAY_REF:
- /* This used to be 0, but our current restricted model
- allows this to be 1. We'll never get arrays this way. */
- return 1;
-
- default:
- my_friendly_abort (42);
- }
-
- /* Catch-all case is that TO/FROM is not safe. */
- return 0;
-}
-
-/* Function to build a static GC entry for DECL. TYPE is DECL's type.
-
- For objects of type `class *', this is just an entry in the
- static vector __PTR_LIST__.
-
- For objects of type `class[]', this requires building an entry
- in the static vector __ARR_LIST__.
-
- For aggregates, this records all fields of type `class *'
- and `class[]' in the respective lists above. */
-void
-build_static_gc_entry (decl, type)
- tree decl;
- tree type;
-{
- /* Now, figure out what sort of entry to build. */
- if (TREE_CODE (type) == POINTER_TYPE
- || TREE_CODE (type) == REFERENCE_TYPE)
- assemble_gc_entry (IDENTIFIER_POINTER (DECL_NAME (decl)));
- else if (TREE_CODE (type) == RECORD_TYPE)
- {
- tree ref = get_temp_name (build_reference_type (type), 1);
- DECL_INITIAL (ref) = build1 (ADDR_EXPR, TREE_TYPE (ref), decl);
- TREE_CONSTANT (DECL_INITIAL (ref)) = 1;
- cp_finish_decl (ref, DECL_INITIAL (ref), NULL_TREE, 0, 0);
- }
- else
- {
- /* Not yet implemented.
-
- Cons up a static variable that holds address and length info
- and add that to ___ARR_LIST__. */
- my_friendly_abort (43);
- }
-}
-
-/* Protect FROM from the GC, assuming FROM is going to be
- stored into TO. We handle three cases for TO here:
-
- case 1: TO is a stack variable.
- case 2: TO is zero (which means it is a parameter).
- case 3: TO is a return value. */
-
-tree
-protect_value_from_gc (to, from)
- tree to, from;
-{
- if (to == 0)
- {
- tree cleanup;
-
- to = get_temp_regvar (TREE_TYPE (from), from);
-
- /* Convert from integer to list form since we'll use it twice. */
- DECL_GC_OFFSET (to) = build_tree_list (NULL_TREE, DECL_GC_OFFSET (to));
- cleanup = build_function_call (gc_unprotect_fndecl,
- DECL_GC_OFFSET (to));
-
- if (! cp_expand_decl_cleanup (to, cleanup))
- {
- compiler_error ("cannot unprotect parameter in this scope");
- return error_mark_node;
- }
- }
-
- /* Should never need to protect a value that's headed for static storage. */
- if (TREE_STATIC (to))
- my_friendly_abort (44);
-
- switch (TREE_CODE (to))
- {
- case COMPONENT_REF:
- case INDIRECT_REF:
- return protect_value_from_gc (TREE_OPERAND (to, 0), from);
-
- case VAR_DECL:
- case PARM_DECL:
- {
- tree rval;
- if (DECL_GC_OFFSET (to) == NULL_TREE)
- {
- /* Because of a cast or a conversion, we might stick
- a value into a variable that would not normally
- have a GC entry. */
- DECL_GC_OFFSET (to) = size_int (++current_function_obstack_index);
- }
-
- if (TREE_CODE (DECL_GC_OFFSET (to)) != TREE_LIST)
- {
- DECL_GC_OFFSET (to)
- = build_tree_list (NULL_TREE, DECL_GC_OFFSET (to));
- }
-
- current_function_obstack_usage = 1;
- rval = build_function_call (gc_protect_fndecl,
- tree_cons (NULL_TREE, from,
- DECL_GC_OFFSET (to)));
- TREE_TYPE (rval) = TREE_TYPE (from);
- return rval;
- }
- }
-
- /* If we fall through the switch, assume we lost. */
- my_friendly_abort (45);
- /* NOTREACHED */
- return NULL_TREE;
-}
-
-/* Given the expression EXP of type `class *', return the head
- of the object pointed to by EXP. */
-tree
-build_headof (exp)
- tree exp;
-{
- tree type = TREE_TYPE (exp);
- tree vptr, offset;
-
- if (TREE_CODE (type) != POINTER_TYPE)
- {
- error ("`headof' applied to non-pointer type");
- return error_mark_node;
- }
- type = TREE_TYPE (type);
-
- if (!TYPE_VIRTUAL_P (type) || CLASSTYPE_VFIELD (type) == NULL_TREE)
- return exp;
-
- vptr = fold (size_binop (PLUS_EXPR,
- size_binop (FLOOR_DIV_EXPR,
- DECL_FIELD_BITPOS (CLASSTYPE_VFIELD (type)),
- size_int (BITS_PER_UNIT)),
- exp));
- vptr = build1 (INDIRECT_REF, build_pointer_type (vtable_entry_type), vptr);
-
- if (flag_vtable_thunks)
- offset = build_array_ref (vptr, integer_zero_node);
- else
- offset = build_component_ref (build_array_ref (vptr, integer_zero_node),
- delta_identifier,
- NULL_TREE, 0);
-
- type = build_type_variant (ptr_type_node, TREE_READONLY (exp),
- TREE_THIS_VOLATILE (exp));
- return build (PLUS_EXPR, type, exp,
- convert (ptrdiff_type_node, offset));
-}
-
-/* Return the type_info node associated with the expression EXP. If EXP is
- a reference to a polymorphic class, return the dynamic type; otherwise
- return the static type of the expression. */
-tree
-build_typeid (exp)
- tree exp;
-{
- tree type;
-
- if (!flag_rtti)
- cp_error ("cannot take typeid of object when -frtti is not specified");
-
- if (exp == error_mark_node)
- return error_mark_node;
-
- type = TREE_TYPE (exp);
-
- /* Strip top-level cv-qualifiers. */
- type = TYPE_MAIN_VARIANT (type);
-
- /* if b is an instance of B, typeid(b) == typeid(B). Do this before
- reference trickiness. */
- if (TREE_CODE (exp) == VAR_DECL && TREE_CODE (type) == RECORD_TYPE)
- return get_typeid (type);
-
- /* peel back references, so they match. */
- if (TREE_CODE (type) == REFERENCE_TYPE)
- type = TREE_TYPE (type);
-
- /* Peel off cv qualifiers. */
- type = TYPE_MAIN_VARIANT (type);
-
- /* Apply trivial conversion T -> T& for dereferenced ptrs. */
- if (TREE_CODE (type) == RECORD_TYPE)
- type = build_reference_type (type);
-
- /* If exp is a reference to polymorphic type, get the real type_info. */
- if (TREE_CODE (type) == REFERENCE_TYPE && TYPE_VIRTUAL_P (TREE_TYPE (type)))
- {
- /* build reference to type_info from vtable. */
- tree t;
-
- if (flag_vtable_thunks)
- t = build_vfn_ref ((tree *) NULL_TREE, exp, integer_one_node);
- else
- t = build_vfn_ref ((tree *) NULL_TREE, exp, integer_zero_node);
-
- TREE_TYPE (t) = build_pointer_type (__class_desc_type_node);
- t = build_indirect_ref (t, NULL);
- return t;
- }
-
- /* otherwise return the type_info for the static type of the expr. */
- return get_typeid (type);
-}
-
-/* Return the type_info object for TYPE, creating it if necessary. */
-tree
-get_typeid (type)
- tree type;
-{
- tree t, td;
-
- if (type == error_mark_node)
- return error_mark_node;
-
- /* Is it useful (and/or correct) to have different typeids for `T &'
- and `T'? */
- if (TREE_CODE (type) == REFERENCE_TYPE)
- type = TREE_TYPE (type);
-
- td = build_t_desc (type, 1);
- if (td == error_mark_node)
- return error_mark_node;
-
- t = TREE_OPERAND (td, 0);
- return t;
-}
-
-/* Get a bad_cast node for the program to throw...
-
- See libstdc++::exception{,.cc} for __bad_cast_object */
-tree
-get_bad_cast_node ()
-{
- static tree t;
- if (t == NULL_TREE
- && (t = lookup_name (get_identifier ("__bad_cast_object"), 0))
- == NULL_TREE)
- {
- error ("you must #include <typeinfo>");
- return error_mark_node;
- }
- return t;
-}
-
-/* Execute a dynamic cast, as described in section 5.2.6 of the 9/93 working
- paper. */
-tree
-build_dynamic_cast (type, expr)
- tree type, expr;
-{
- enum tree_code tc = TREE_CODE (type);
- tree exprtype = TREE_TYPE (expr);
- enum tree_code ec = TREE_CODE (exprtype);
- tree retval;
-
- if (type == error_mark_node || expr == error_mark_node)
- return error_mark_node;
-
- switch (tc)
- {
- case POINTER_TYPE:
- if (ec == REFERENCE_TYPE)
- {
- expr = convert_from_reference (expr);
- exprtype = TREE_TYPE (expr);
- ec = TREE_CODE (exprtype);
- }
- if (ec != POINTER_TYPE)
- goto fail;
- if (TREE_CODE (TREE_TYPE (exprtype)) != RECORD_TYPE)
- goto fail;
- if (TYPE_SIZE (TREE_TYPE (exprtype)) == 0)
- goto fail;
- if (TREE_READONLY (TREE_TYPE (exprtype)) &&
- ! TYPE_READONLY (TREE_TYPE (type)))
- goto fail;
- if (TYPE_MAIN_VARIANT (TREE_TYPE (type)) == void_type_node)
- break;
- /* else fall through */
- case REFERENCE_TYPE:
- if (TREE_CODE (TREE_TYPE (type)) == RECORD_TYPE
- && TYPE_SIZE (TREE_TYPE (type)) != NULL_TREE)
- break;
- /* else fall through */
- default:
- goto fail;
- }
-
- /* Apply trivial conversion T -> T& for dereferenced ptrs. */
- if (ec == RECORD_TYPE)
- {
- exprtype = build_type_variant (exprtype, TREE_READONLY (expr),
- TREE_THIS_VOLATILE (expr));
- exprtype = build_reference_type (exprtype);
- expr = convert_to_reference (exprtype, expr, CONV_IMPLICIT,
- LOOKUP_NORMAL, NULL_TREE);
- ec = REFERENCE_TYPE;
- }
-
- if (tc == REFERENCE_TYPE)
- {
- if (ec != REFERENCE_TYPE)
- goto fail;
- if (TREE_CODE (TREE_TYPE (exprtype)) != RECORD_TYPE)
- goto fail;
- if (TYPE_SIZE (TREE_TYPE (exprtype)) == 0)
- goto fail;
- }
-
- /* If *type is an unambiguous accessible base class of *exprtype,
- convert statically. */
- {
- int distance;
- tree path;
-
- distance = get_base_distance (TREE_TYPE (type), TREE_TYPE (exprtype), 1,
- &path);
- if (distance >= 0)
- return build_vbase_path (PLUS_EXPR, type, expr, path, 0);
- }
-
- /* Otherwise *exprtype must be a polymorphic class (have a vtbl). */
- if (TYPE_VIRTUAL_P (TREE_TYPE (exprtype)))
- {
- /* if TYPE is `void *', return pointer to complete object. */
- if (tc == POINTER_TYPE
- && TYPE_MAIN_VARIANT (TREE_TYPE (type)) == void_type_node)
- {
- /* if b is an object, dynamic_cast<void *>(&b) == (void *)&b. */
- if (TREE_CODE (expr) == ADDR_EXPR
- && TREE_CODE (TREE_OPERAND (expr, 0)) == VAR_DECL
- && TREE_CODE (TREE_TYPE (TREE_OPERAND (expr, 0))) == RECORD_TYPE)
- return build1 (NOP_EXPR, type, expr);
-
- return build_headof (expr);
- }
- else
- {
- tree retval;
- tree result, td1, td2, elems, tmp1, expr1;
-
- /* If we got here, we can't convert statically. Therefore,
- dynamic_cast<D&>(b) (b an object) cannot succeed. */
- if (ec == REFERENCE_TYPE)
- {
- if (TREE_CODE (expr) == VAR_DECL
- && TREE_CODE (TREE_TYPE (expr)) == RECORD_TYPE)
- {
- cp_warning ("dynamic_cast of `%#D' to `%#T' can never succeed",
- expr, type);
- return build_throw (get_bad_cast_node ());
- }
- }
- /* Ditto for dynamic_cast<D*>(&b). */
- else if (TREE_CODE (expr) == ADDR_EXPR)
- {
- tree op = TREE_OPERAND (expr, 0);
- if (TREE_CODE (op) == VAR_DECL
- && TREE_CODE (TREE_TYPE (op)) == RECORD_TYPE)
- {
- cp_warning ("dynamic_cast of `%#D' to `%#T' can never succeed",
- expr, type);
- retval = build_int_2 (0, 0);
- TREE_TYPE (retval) = type;
- return retval;
- }
- }
-
- expr1 = expr;
- if (tc == REFERENCE_TYPE)
- expr1 = build_unary_op (ADDR_EXPR, expr1, 0);
-
- /* Build run-time conversion. */
- expr1 = build_headof (expr1);
-
- if (ec == POINTER_TYPE)
- td1 = build_typeid (build_indirect_ref (expr, NULL_PTR));
- else
- td1 = build_typeid (expr);
-
- if (tc == POINTER_TYPE)
- td2 = get_typeid (TREE_TYPE (type));
- else
- td2 = get_typeid (type);
-
- elems = tree_cons (NULL_TREE, td2,
- tree_cons (NULL_TREE, build_int_2 (1, 0),
- tree_cons (NULL_TREE, expr1, NULL_TREE)));
- result = build_method_call (td1,
- get_identifier ("__rtti_match"), elems, NULL_TREE, LOOKUP_NORMAL);
-
- if (tc == REFERENCE_TYPE)
- {
- expr1 = build_throw (get_bad_cast_node ());
- expr1 = build_compound_expr (tree_cons (NULL_TREE, expr1,
- build_tree_list (NULL_TREE, convert (type, integer_zero_node))));
- TREE_TYPE (expr1) = type;
- return build (COND_EXPR, type, result, result, expr1);
- }
-
- /* Now back to the type we want from a void*. */
- result = convert (type, result);
- return result;
- }
- }
-
- fail:
- cp_error ("cannot dynamic_cast `%E' (of type `%#T') to type `%#T'",
- expr, exprtype, type);
- return error_mark_node;
-}
-
-/* Build and initialize various sorts of descriptors. Every descriptor
- node has a name associated with it (the name created by mangling).
- For this reason, we use the identifier as our access to the __*_desc
- nodes, instead of sticking them directly in the types. Otherwise we
- would burden all built-in types (and pointer types) with slots that
- we don't necessarily want to use.
-
- For each descriptor we build, we build a variable that contains
- the descriptor's information. When we need this info at runtime,
- all we need is access to these variables.
-
- Note: these constructors always return the address of the descriptor
- info, since that is simplest for their mutual interaction. */
-
-static tree
-build_generic_desc (tdecl, type, elems)
- tree tdecl;
- tree type;
- tree elems;
-{
- tree init = elems;
- int toplev = global_bindings_p ();
-
- TREE_CONSTANT (init) = 1;
- TREE_STATIC (init) = 1;
- TREE_READONLY (init) = 1;
-
- TREE_TYPE (tdecl) = type;
- DECL_INITIAL (tdecl) = init;
- TREE_STATIC (tdecl) = 1;
- DECL_SIZE (tdecl) = NULL_TREE;
- layout_decl (tdecl, 0);
- if (! toplev)
- push_to_top_level ();
- cp_finish_decl (tdecl, init, NULL_TREE, 0, 0);
- if (! toplev)
- pop_from_top_level ();
-
- if (! TREE_USED (tdecl))
- {
- assemble_external (tdecl);
- TREE_USED (tdecl) = 1;
- }
-
- return IDENTIFIER_AS_DESC (DECL_NAME (tdecl));
-}
-
-/* Build an initializer for a __bltn_desc node. */
-static tree
-build_bltn_desc (tdecl, type)
- tree tdecl;
- tree type;
-{
- tree elems, t;
-
- if (type == boolean_type_node)
- t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_BOOL"),
- 0, 0);
- else if (type == char_type_node)
- t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_CHAR"),
- 0, 0);
- else if (type == short_integer_type_node)
- t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_SHORT"),
- 0, 0);
- else if (type == integer_type_node)
- t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_INT"),
- 0, 0);
- else if (type == long_integer_type_node)
- t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_LONG"),
- 0, 0);
- else if (type == long_long_integer_type_node)
- t = lookup_field (__bltn_desc_type_node,
- get_identifier("_RTTI_BI_LONGLONG"), 0, 0);
- else if (type == float_type_node)
- t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_FLOAT"),
- 0, 0);
- else if (type == double_type_node)
- t = lookup_field (__bltn_desc_type_node,
- get_identifier("_RTTI_BI_DOUBLE"), 0, 0);
- else if (type == long_double_type_node)
- t = lookup_field (__bltn_desc_type_node,
- get_identifier("_RTTI_BI_LDOUBLE"), 0, 0);
- else if (type == unsigned_char_type_node)
- t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_UCHAR"),
- 0, 0);
- else if (type == short_unsigned_type_node)
- t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_USHORT"),
- 0, 0);
- else if (type == unsigned_type_node)
- t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_UINT"),
- 0, 0);
- else if (type == long_unsigned_type_node)
- t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_ULONG"),
- 0, 0);
- else if (type == long_long_unsigned_type_node)
- t = lookup_field (__bltn_desc_type_node,
- get_identifier("_RTTI_BI_ULONGLONG"), 0, 0);
- else if (type == signed_char_type_node)
- t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_SCHAR"),
- 0, 0);
- else if (type == wchar_type_node)
- t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_WCHAR"),
- 0, 0);
- else if (type == void_type_node)
- t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_VOID"),
- 0, 0);
- else
- {
- cp_compiler_error ("type `%T' not handled as a built-in type");
- }
-
- elems = tree_cons (NULL_TREE, t, NULL_TREE);
- return build_generic_desc (tdecl, __bltn_desc_type_node, elems);
-}
-
-/* Build an initializer for a __user_desc node. */
-static tree
-build_user_desc (tdecl)
- tree tdecl;
-{
- tree elems, name_string, t;
- tree tname = DECL_NAME (tdecl);
-
- name_string = combine_strings (build_string
- (IDENTIFIER_LENGTH (tname)+1, IDENTIFIER_POINTER (tname)));
- elems = name_string;
- return build_generic_desc (tdecl, __user_desc_type_node, elems);
-}
-
-/* Build an initializer for a __class_type_info node. */
-static tree
-build_class_desc (tdecl, type)
- tree tdecl;
- tree type;
-{
- tree tname = DECL_NAME (tdecl);
- tree name_string;
-
- int i = CLASSTYPE_N_BASECLASSES (type);
- int n_base = i;
- int base_cnt = 0;
- tree binfos = TYPE_BINFO_BASETYPES (type);
- tree vb = CLASSTYPE_VBASECLASSES (type);
- tree base, elems, access, offset, isvir;
- tree base_list, off_list, acc_list, isvir_list;
- tree t;
- static tree acc_pub = NULL_TREE;
- static tree acc_pro = NULL_TREE;
- static tree acc_pri = NULL_TREE;
-
- if (acc_pub == NULL_TREE)
- {
- acc_pub = lookup_field (__class_desc_type_node,
- get_identifier("_RTTI_ACCESS_PUBLIC"), 0, 0);
- acc_pro = lookup_field (__class_desc_type_node,
- get_identifier("_RTTI_ACCESS_PROTECTED"), 0, 0);
- acc_pri = lookup_field (__class_desc_type_node,
- get_identifier("_RTTI_ACCESS_PRIVATE"), 0, 0);
- }
-
- base_list = build_tree_list (NULL_TREE, integer_zero_node);
- off_list = build_tree_list (NULL_TREE, integer_zero_node);
- acc_list = build_tree_list (NULL_TREE, integer_zero_node);
- isvir_list = build_tree_list (NULL_TREE, integer_zero_node);
- while (--i >= 0)
- {
- tree binfo = TREE_VEC_ELT (binfos, i);
-
- base = build_t_desc (BINFO_TYPE (binfo), 1);
- if (TREE_VIA_VIRTUAL (binfo))
- {
- tree t = BINFO_TYPE (binfo);
- char *name;
- tree field;
- int off;
-
- name = (char *) alloca (TYPE_NAME_LENGTH (t)+sizeof (VBASE_NAME)+1);
- sprintf (name, VBASE_NAME_FORMAT, TYPE_NAME_STRING (t));
- field = lookup_field (type, get_identifier (name), 0, 0);
- offset = size_binop (FLOOR_DIV_EXPR,
- DECL_FIELD_BITPOS (field), size_int (BITS_PER_UNIT));
- }
- else
- offset = BINFO_OFFSET (binfo);
-
- if (TREE_VIA_PUBLIC (binfo))
- access = acc_pub;
- else if (TREE_VIA_PROTECTED (binfo))
- access = acc_pro;
- else
- access = acc_pri;
- if (TREE_VIA_VIRTUAL (binfo))
- isvir = build_int_2 (1, 0);
- else
- isvir = build_int_2 (0, 0);
-
- base_list = tree_cons (NULL_TREE, base, base_list);
- isvir_list = tree_cons (NULL_TREE, isvir, isvir_list);
- acc_list = tree_cons (NULL_TREE, access, acc_list);
- off_list = tree_cons (NULL_TREE, offset, off_list);
- base_cnt++;
- }
-#if 0
- i = n_base;
- while (vb)
- {
- tree b;
- access = acc_pub;
- while (--i >= 0)
- {
- b = TREE_VEC_ELT (binfos, i);
- if (BINFO_TYPE (vb) == BINFO_TYPE (b) && TREE_VIA_VIRTUAL (b))
- {
- if (TREE_VIA_PUBLIC (b))
- access = acc_pub;
- else if (TREE_VIA_PROTECTED (b))
- access = acc_pro;
- else
- access = acc_pri;
- break;
- }
- }
- base = build_t_desc (BINFO_TYPE (vb), 1);
- offset = BINFO_OFFSET (vb);
- isvir = build_int_2 (1, 0);
-
- base_list = tree_cons (NULL_TREE, base, base_list);
- isvir_list = tree_cons (NULL_TREE, isvir, isvir_list);
- acc_list = tree_cons (NULL_TREE, access, acc_list);
- off_list = tree_cons (NULL_TREE, offset, off_list);
-
- base_cnt++;
- vb = TREE_CHAIN (vb);
- }
-#endif
- base_list = finish_table (NULL_TREE, build_pointer_type (__t_desc_type_node),
- base_list, 0);
- off_list = finish_table (NULL_TREE, integer_type_node,
- off_list, 0);
- isvir_list = finish_table (NULL_TREE, integer_type_node,
- isvir_list, 0);
- acc_list = finish_table (NULL_TREE, __access_mode_type_node,
- acc_list, 0);
-
-
- name_string = combine_strings (build_string (IDENTIFIER_LENGTH (tname)+1, IDENTIFIER_POINTER (tname)));
-
- elems = tree_cons (NULL_TREE, name_string,
- tree_cons (NULL_TREE, default_conversion (base_list),
- tree_cons (NULL_TREE, default_conversion (off_list),
- tree_cons (NULL_TREE, default_conversion (isvir_list),
- tree_cons (NULL_TREE, default_conversion (acc_list),
- tree_cons (NULL_TREE, build_int_2 (base_cnt, 0), NULL_TREE))))));
-
- return build_generic_desc (tdecl, __class_desc_type_node, elems);
-}
-
-/* Build an initializer for a __pointer_type_info node. */
-static tree
-build_ptr_desc (tdecl, type)
- tree tdecl;
- tree type;
-{
- tree t, elems;
-
- t = TREE_TYPE (type);
- t = build_t_desc (t, 1);
- t = build_indirect_ref (t, NULL);
- elems = tree_cons (NULL_TREE, t, NULL_TREE);
- return build_generic_desc (tdecl, __ptr_desc_type_node, elems);
-}
-
-/* Build an initializer for a __attr_type_info node. */
-static tree
-build_attr_desc (tdecl, type)
- tree tdecl;
- tree type;
-{
- tree elems, t, attrval;
-
- if (TYPE_READONLY (type))
- {
- if (TYPE_VOLATILE (type))
- attrval = lookup_field (__attr_desc_type_node,
- get_identifier("_RTTI_ATTR_CONSTVOL"), 0, 0);
- else
- attrval = lookup_field (__attr_desc_type_node,
- get_identifier("_RTTI_ATTR_CONST"), 0, 0);
- }
- else
- {
- if (TYPE_VOLATILE (type))
- attrval = lookup_field (__attr_desc_type_node,
- get_identifier("_RTTI_ATTR_VOLATILE"), 0, 0);
- }
- t = build_t_desc (TYPE_MAIN_VARIANT (type), 1);
- t = build_indirect_ref (t , NULL);
- elems = tree_cons (NULL_TREE, attrval, tree_cons (NULL_TREE, t, NULL_TREE));
- return build_generic_desc (tdecl, __attr_desc_type_node, elems);
-}
-
-/* Build an initializer for a __func_type_info node. */
-static tree
-build_func_desc (tdecl)
- tree tdecl;
-{
- tree elems, name_string;
- tree tname = DECL_NAME (tdecl);
-
- name_string = combine_strings (build_string
- (IDENTIFIER_LENGTH (tname)+1, IDENTIFIER_POINTER (tname)));
- elems = name_string;
- return build_generic_desc (tdecl, __func_desc_type_node, elems);
-}
-
-/* Build an initializer for a __ptmf_type_info node. */
-static tree
-build_ptmf_desc (tdecl, type)
- tree tdecl;
- tree type;
-{
- tree elems, name_string;
- tree tname = DECL_NAME (tdecl);
-
- name_string = combine_strings (build_string
- (IDENTIFIER_LENGTH (tname)+1, IDENTIFIER_POINTER (tname)));
- elems = name_string;
- return build_generic_desc (tdecl, __ptmf_desc_type_node, elems);
-}
-
-/* Build an initializer for a __ptmd_type_info node. */
-static tree
-build_ptmd_desc (tdecl, type)
- tree tdecl;
- tree type;
-{
- tree tc, t, elems;
- tc = build_t_desc (TYPE_OFFSET_BASETYPE (type), 1);
- tc = build_indirect_ref (tc , NULL);
- t = build_t_desc (TREE_TYPE (type), 1);
- t = build_indirect_ref (t , NULL);
- elems = tree_cons (NULL_TREE, tc,
- tree_cons (NULL_TREE, t, NULL_TREE));
- return build_generic_desc (tdecl, __ptmd_desc_type_node, elems);
-}
-
-struct uninst_st {
- tree type;
- struct uninst_st *next;
-};
-typedef struct uninst_st uninst_node;
-static uninst_node * uninst_desc = (uninst_node *)NULL;
-
-static void
-add_uninstantiated_desc (type)
- tree type;
-{
- uninst_node *t;
-
- t = (uninst_node *) xmalloc (sizeof (struct uninst_st));
- t->type = type;
- t->next = uninst_desc;
- uninst_desc = t;
-}
-
-/* We may choose to link the emitting of certain high use TDs for certain
- objects, we do that here. Return the type to link against if such a
- link exists, otherwise just return TYPE. */
-
-tree
-get_def_to_follow (type)
- tree type;
-{
-#if 0
- /* For now we don't lay out T&, T* TDs with the main TD for the object. */
- /* Let T* and T& be written only when T is written (if T is an aggr).
- We do this for const, but not for volatile, since volatile
- is rare and const is not. */
- if (!TYPE_VOLATILE (taggr)
- && (TREE_CODE (taggr) == POINTER_TYPE
- || TREE_CODE (taggr) == REFERENCE_TYPE)
- && IS_AGGR_TYPE (TREE_TYPE (taggr)))
- taggr = TREE_TYPE (taggr);
-#endif
- return type;
-}
-
-/* build a general type_info node. */
-tree
-build_t_desc (type, definition)
- tree type;
- int definition;
-{
- tree tdecl;
- tree tname, name_string;
- tree elems;
- tree t, tt, taggr;
-
- if (__ptmd_desc_type_node == NULL_TREE)
- {
- init_type_desc();
- if (__ptmd_desc_type_node)
- {
- for ( ; uninst_desc; uninst_desc = uninst_desc->next )
- build_t_desc (uninst_desc->type, 1);
- }
- }
- if (__t_desc_type_node == NULL_TREE)
- {
- static int warned = 0;
- if (! warned)
- {
- cp_error ("failed to build type descriptor node of '%T', maybe typeinfo.h not included", type);
- }
- warned = 1;
- return error_mark_node;
- }
- if (__ptmd_desc_type_node == NULL_TREE)
- {
- add_uninstantiated_desc (type);
- definition = 0;
- }
-
- push_obstacks (&permanent_obstack, &permanent_obstack);
- tname = build_t_desc_overload (type);
-
- if (!IDENTIFIER_AS_DESC (tname))
- {
- tdecl = build_decl (VAR_DECL, tname, __t_desc_type_node);
- DECL_EXTERNAL (tdecl) = 1;
- TREE_PUBLIC (tdecl) = 1;
- tdecl = pushdecl_top_level (tdecl);
- SET_IDENTIFIER_AS_DESC (tname, build_unary_op (ADDR_EXPR, tdecl, 0));
- if (!definition)
- cp_finish_decl (tdecl, NULL_TREE, NULL_TREE, 0, 0);
- }
- else
- tdecl = TREE_OPERAND (IDENTIFIER_AS_DESC (tname), 0);
-
- /* If it's not a definition, don't do anything more. */
- if (!definition)
- return IDENTIFIER_AS_DESC (tname);
-
- /* If it has already been written, don't to anything more. */
- /* Should this be on tdecl? */
- if (TREE_ASM_WRITTEN (IDENTIFIER_AS_DESC (tname)))
- return IDENTIFIER_AS_DESC (tname);
-
- /* If we previously defined it, return the defined result. */
- if (DECL_INITIAL (tdecl))
- return IDENTIFIER_AS_DESC (tname);
-
- taggr = get_def_to_follow (type);
-
- /* If we know that we don't need to write out this type's
- vtable, then don't write out it's type_info. Somebody
- else will take care of that. */
- if (IS_AGGR_TYPE (taggr) && CLASSTYPE_VFIELD (taggr))
- {
- /* Let's play follow the vtable. */
- TREE_PUBLIC (tdecl) = CLASSTYPE_INTERFACE_KNOWN (taggr);
- DECL_EXTERNAL (tdecl) = CLASSTYPE_INTERFACE_ONLY (taggr);
- }
- else
- {
- DECL_EXTERNAL (tdecl) = 0;
- TREE_PUBLIC (tdecl) = (definition > 1);
- }
-
- if (DECL_EXTERNAL (tdecl))
- return IDENTIFIER_AS_DESC (tname);
-
- /* Show that we are defining the t_desc for this type. */
- DECL_INITIAL (tdecl) = error_mark_node;
- t = DECL_CONTEXT (tdecl);
- if ( t && TREE_CODE_CLASS (TREE_CODE (t)) == 't')
- pushclass (t, 2);
-
- if (TYPE_VOLATILE (type) || TYPE_READONLY (type))
- t = build_attr_desc (tdecl, type);
- else if (TREE_CODE (type) == ARRAY_TYPE)
- t = build_ptr_desc (tdecl, type);
- else if (TREE_CODE (type) == POINTER_TYPE)
- {
- if (TREE_CODE (TREE_TYPE (type)) == OFFSET_TYPE)
- {
- type = TREE_TYPE (type);
- t = build_ptmd_desc (tdecl, type);
- }
- else
- {
- t = build_ptr_desc (tdecl, type);
- }
- }
- else if (TYPE_BUILT_IN (type))
- t = build_bltn_desc (tdecl, type);
- else if (IS_AGGR_TYPE (type))
- {
- if (TYPE_PTRMEMFUNC_P (type))
- {
- t = build_ptmf_desc (tdecl, type);
- }
- else
- {
- t = build_class_desc (tdecl, type);
- }
- }
- else if (TREE_CODE (type) == FUNCTION_TYPE)
- t = build_func_desc (tdecl);
- else
- t = build_user_desc (tdecl);
-
- pop_obstacks ();
- return t;
-}
-
-#if 0
-/* This is the old dossier type descriptor generation code, it's much
- more extended than rtti. It's reserved for later use. */
-/* Build an initializer for a __t_desc node. So that we can take advantage
- of recursion, we accept NULL for TYPE.
- DEFINITION is greater than zero iff we must define the type descriptor
- (as opposed to merely referencing it). 1 means treat according to
- #pragma interface/#pragma implementation rules. 2 means define as
- global and public, no matter what. */
-tree
-build_t_desc (type, definition)
- tree type;
- int definition;
-{
- tree tdecl;
- tree tname, name_string;
- tree elems, fields;
- tree parents, vbases, offsets, ivars, methods, target_type;
- int method_count = 0, field_count = 0;
-
- if (type == NULL_TREE)
- return NULL_TREE;
-
- tname = build_t_desc_overload (type);
- if (IDENTIFIER_AS_DESC (tname)
- && (!definition || TREE_ASM_WRITTEN (IDENTIFIER_AS_DESC (tname))))
- return IDENTIFIER_AS_DESC (tname);
-
- tdecl = lookup_name (tname, 0);
- if (tdecl == NULL_TREE)
- {
- tdecl = build_decl (VAR_DECL, tname, __t_desc_type_node);
- DECL_EXTERNAL (tdecl) = 1;
- TREE_PUBLIC (tdecl) = 1;
- tdecl = pushdecl_top_level (tdecl);
- }
- /* If we previously defined it, return the defined result. */
- else if (definition && DECL_INITIAL (tdecl))
- return IDENTIFIER_AS_DESC (tname);
-
- if (definition)
- {
- tree taggr = type;
- /* Let T* and T& be written only when T is written (if T is an aggr).
- We do this for const, but not for volatile, since volatile
- is rare and const is not. */
- if (!TYPE_VOLATILE (taggr)
- && (TREE_CODE (taggr) == POINTER_TYPE
- || TREE_CODE (taggr) == REFERENCE_TYPE)
- && IS_AGGR_TYPE (TREE_TYPE (taggr)))
- taggr = TREE_TYPE (taggr);
-
- /* If we know that we don't need to write out this type's
- vtable, then don't write out it's dossier. Somebody
- else will take care of that. */
- if (IS_AGGR_TYPE (taggr) && CLASSTYPE_VFIELD (taggr))
- {
- if (CLASSTYPE_VTABLE_NEEDS_WRITING (taggr))
- {
- TREE_PUBLIC (tdecl) = ! CLASSTYPE_INTERFACE_ONLY (taggr)
- && CLASSTYPE_INTERFACE_KNOWN (taggr);
- DECL_EXTERNAL (tdecl) = 0;
- }
- else
- {
- if (write_virtuals != 0)
- TREE_PUBLIC (tdecl) = 1;
- }
- }
- else
- {
- DECL_EXTERNAL (tdecl) = 0;
- TREE_PUBLIC (tdecl) = (definition > 1);
- }
- }
- SET_IDENTIFIER_AS_DESC (tname, build_unary_op (ADDR_EXPR, tdecl, 0));
-
- if (!definition || DECL_EXTERNAL (tdecl))
- {
- /* That's it! */
- cp_finish_decl (tdecl, NULL_TREE, NULL_TREE, 0, 0);
- return IDENTIFIER_AS_DESC (tname);
- }
-
- /* Show that we are defining the t_desc for this type. */
- DECL_INITIAL (tdecl) = error_mark_node;
-
- parents = build_tree_list (NULL_TREE, integer_zero_node);
- vbases = build_tree_list (NULL_TREE, integer_zero_node);
- offsets = build_tree_list (NULL_TREE, integer_zero_node);
- methods = NULL_TREE;
- ivars = NULL_TREE;
-
- if (TYPE_LANG_SPECIFIC (type))
- {
- int i = CLASSTYPE_N_BASECLASSES (type);
- tree method_vec = CLASSTYPE_METHOD_VEC (type);
- tree *meth, *end;
- tree binfos = TYPE_BINFO_BASETYPES (type);
- tree vb = CLASSTYPE_VBASECLASSES (type);
-
- while (--i >= 0)
- parents = tree_cons (NULL_TREE, build_t_desc (BINFO_TYPE (TREE_VEC_ELT (binfos, i)), 0), parents);
-
- while (vb)
- {
- vbases = tree_cons (NULL_TREE, build_t_desc (BINFO_TYPE (vb), 0), vbases);
- offsets = tree_cons (NULL_TREE, BINFO_OFFSET (vb), offsets);
- vb = TREE_CHAIN (vb);
- }
-
- if (method_vec)
- for (meth = TREE_VEC_END (method_vec),
- end = &TREE_VEC_ELT (method_vec, 0); meth-- != end; )
- if (*meth)
- {
- methods = tree_cons (NULL_TREE, build_m_desc (*meth), methods);
- method_count++;
- }
- }
-
- if (IS_AGGR_TYPE (type))
- {
- for (fields = TYPE_FIELDS (type); fields; fields = TREE_CHAIN (fields))
- if (TREE_CODE (fields) == FIELD_DECL
- || TREE_CODE (fields) == VAR_DECL)
- {
- ivars = tree_cons (NULL_TREE, build_i_desc (fields), ivars);
- field_count++;
- }
- ivars = nreverse (ivars);
- }
-
- parents = finish_table (NULL_TREE, build_pointer_type (__t_desc_type_node), parents, 0);
- vbases = finish_table (NULL_TREE, build_pointer_type (__t_desc_type_node), vbases, 0);
- offsets = finish_table (NULL_TREE, integer_type_node, offsets, 0);
- if (methods == NULL_TREE)
- methods = null_pointer_node;
- else
- methods = build_unary_op (ADDR_EXPR,
- finish_table (NULL_TREE, __m_desc_type_node, methods, 0),
- 0);
- if (ivars == NULL_TREE)
- ivars = null_pointer_node;
- else
- ivars = build_unary_op (ADDR_EXPR,
- finish_table (NULL_TREE, __i_desc_type_node, ivars, 0),
- 0);
- if (TREE_TYPE (type))
- target_type = build_t_desc (TREE_TYPE (type), definition);
- else
- target_type = integer_zero_node;
-
- name_string = combine_strings (build_string (IDENTIFIER_LENGTH (tname)+1, IDENTIFIER_POINTER (tname)));
-
- elems = tree_cons (NULL_TREE, build_unary_op (ADDR_EXPR, name_string, 0),
- tree_cons (NULL_TREE,
- TYPE_SIZE(type)? size_in_bytes(type) : integer_zero_node,
- /* really should use bitfield initialization here. */
- tree_cons (NULL_TREE, integer_zero_node,
- tree_cons (NULL_TREE, target_type,
- tree_cons (NULL_TREE, build_int_2 (field_count, 2),
- tree_cons (NULL_TREE, build_int_2 (method_count, 2),
- tree_cons (NULL_TREE, ivars,
- tree_cons (NULL_TREE, methods,
- tree_cons (NULL_TREE, build_unary_op (ADDR_EXPR, parents, 0),
- tree_cons (NULL_TREE, build_unary_op (ADDR_EXPR, vbases, 0),
- build_tree_list (NULL_TREE, build_unary_op (ADDR_EXPR, offsets, 0))))))))))));
- return build_generic_desc (tdecl, elems);
-}
-
-/* Build an initializer for a __i_desc node. */
-tree
-build_i_desc (decl)
- tree decl;
-{
- tree elems, name_string;
- tree taggr;
-
- name_string = DECL_NAME (decl);
- name_string = combine_strings (build_string (IDENTIFIER_LENGTH (name_string)+1, IDENTIFIER_POINTER (name_string)));
-
- /* Now decide whether this ivar should cause it's type to get
- def'd or ref'd in this file. If the type we are looking at
- has a proxy definition, we look at the proxy (i.e., a
- `foo *' is equivalent to a `foo'). */
- taggr = TREE_TYPE (decl);
-
- if ((TREE_CODE (taggr) == POINTER_TYPE
- || TREE_CODE (taggr) == REFERENCE_TYPE)
- && TYPE_VOLATILE (taggr) == 0)
- taggr = TREE_TYPE (taggr);
-
- elems = tree_cons (NULL_TREE, build_unary_op (ADDR_EXPR, name_string, 0),
- tree_cons (NULL_TREE, DECL_FIELD_BITPOS (decl),
- build_tree_list (NULL_TREE, build_t_desc (TREE_TYPE (decl),
- ! IS_AGGR_TYPE (taggr)))));
- taggr = build (CONSTRUCTOR, __i_desc_type_node, NULL_TREE, elems);
- TREE_CONSTANT (taggr) = 1;
- TREE_STATIC (taggr) = 1;
- TREE_READONLY (taggr) = 1;
- return taggr;
-}
-
-/* Build an initializer for a __m_desc node. */
-tree
-build_m_desc (decl)
- tree decl;
-{
- tree taggr, elems, name_string;
- tree parm_count, req_count, vindex, vcontext;
- tree parms;
- int p_count, r_count;
- tree parm_types = NULL_TREE;
-
- for (parms = TYPE_ARG_TYPES (TREE_TYPE (decl)), p_count = 0, r_count = 0;
- parms != NULL_TREE; parms = TREE_CHAIN (parms), p_count++)
- {
- taggr = TREE_VALUE (parms);
- if ((TREE_CODE (taggr) == POINTER_TYPE
- || TREE_CODE (taggr) == REFERENCE_TYPE)
- && TYPE_VOLATILE (taggr) == 0)
- taggr = TREE_TYPE (taggr);
-
- parm_types = tree_cons (NULL_TREE, build_t_desc (TREE_VALUE (parms),
- ! IS_AGGR_TYPE (taggr)),
- parm_types);
- if (TREE_PURPOSE (parms) == NULL_TREE)
- r_count++;
- }
-
- parm_types = finish_table (NULL_TREE, build_pointer_type (__t_desc_type_node),
- nreverse (parm_types), 0);
- parm_count = build_int_2 (p_count, 0);
- req_count = build_int_2 (r_count, 0);
-
- if (DECL_VINDEX (decl))
- vindex = DECL_VINDEX (decl);
- else
- vindex = integer_zero_node;
- if (DECL_CONTEXT (decl)
- && TREE_CODE_CLASS (TREE_CODE (DECL_CONTEXT (decl))) == 't')
- vcontext = build_t_desc (DECL_CONTEXT (decl), 0);
- else
- vcontext = integer_zero_node;
- name_string = DECL_NAME (decl);
- if (name_string == NULL)
- name_string = DECL_ASSEMBLER_NAME (decl);
- name_string = combine_strings (build_string (IDENTIFIER_LENGTH (name_string)+1, IDENTIFIER_POINTER (name_string)));
-
- /* Now decide whether the return type of this mvar
- should cause it's type to get def'd or ref'd in this file.
- If the type we are looking at has a proxy definition,
- we look at the proxy (i.e., a `foo *' is equivalent to a `foo'). */
- taggr = TREE_TYPE (TREE_TYPE (decl));
-
- if ((TREE_CODE (taggr) == POINTER_TYPE
- || TREE_CODE (taggr) == REFERENCE_TYPE)
- && TYPE_VOLATILE (taggr) == 0)
- taggr = TREE_TYPE (taggr);
-
- elems = tree_cons (NULL_TREE, build_unary_op (ADDR_EXPR, name_string, 0),
- tree_cons (NULL_TREE, vindex,
- tree_cons (NULL_TREE, vcontext,
- tree_cons (NULL_TREE, build_t_desc (TREE_TYPE (TREE_TYPE (decl)),
- ! IS_AGGR_TYPE (taggr)),
- tree_cons (NULL_TREE, build_c_cast (build_pointer_type (default_function_type), build_unary_op (ADDR_EXPR, decl, 0), 0),
- tree_cons (NULL_TREE, parm_count,
- tree_cons (NULL_TREE, req_count,
- build_tree_list (NULL_TREE, build_unary_op (ADDR_EXPR, parm_types, 0)))))))));
-
- taggr = build (CONSTRUCTOR, __m_desc_type_node, NULL_TREE, elems);
- TREE_CONSTANT (taggr) = 1;
- TREE_STATIC (taggr) = 1;
- TREE_READONLY (taggr) = 1;
- return taggr;
-}
-#endif /* dossier */
-
-
-/* Conditionally emit code to set up an unwind-protect for the
- garbage collector. If this function doesn't do anything that involves
- the garbage collector, then do nothing. Otherwise, call __gc_push
- at the beginning and __gc_pop at the end.
-
- NOTE! The __gc_pop function must operate transparently, since
- it comes where the logical return label lies. This means that
- at runtime *it* must preserve any return value registers. */
-
-void
-expand_gc_prologue_and_epilogue ()
-{
- extern tree maybe_gc_cleanup;
- struct rtx_def *last_parm_insn, *mark;
- extern struct rtx_def *get_last_insn ();
- extern struct rtx_def *get_first_nonparm_insn ();
- extern struct rtx_def *previous_insn ();
- tree action;
-
- /* If we didn't need the obstack, don't cons any space. */
- if (current_function_obstack_index == 0
- || current_function_obstack_usage == 0)
- return;
-
- mark = get_last_insn ();
- last_parm_insn = get_first_nonparm_insn ();
- if (last_parm_insn == 0) last_parm_insn = mark;
- else last_parm_insn = previous_insn (last_parm_insn);
-
- action = build_function_call (gc_push_fndecl,
- build_tree_list (NULL_TREE, size_int (++current_function_obstack_index)));
- expand_expr_stmt (action);
-
- reorder_insns (next_insn (mark), get_last_insn (), last_parm_insn);
-
- /* This will be expanded as a cleanup. */
- TREE_VALUE (maybe_gc_cleanup)
- = build_function_call (gc_pop_fndecl, NULL_TREE);
-}
-
-/* Some day we'll use this function as a call-back and clean
- up all the unnecessary gc dribble that we otherwise create. */
-void
-lang_expand_end_bindings (first, last)
- struct rtx_def *first, *last;
-{
-}
-
-void
-init_gc_processing ()
-{
- tree parmtypes = hash_tree_chain (class_star_type_node,
- hash_tree_chain (integer_type_node, NULL_TREE));
- gc_protect_fndecl = define_function ("__gc_protect",
- build_function_type (class_star_type_node, parmtypes),
- NOT_BUILT_IN, 0, 0);
-
- parmtypes = hash_tree_chain (integer_type_node, NULL_TREE);
- gc_unprotect_fndecl = define_function ("__gc_unprotect",
- build_function_type (void_type_node, parmtypes),
- NOT_BUILT_IN, 0, 0);
-
- gc_push_fndecl = define_function ("__gc_push",
- TREE_TYPE (gc_unprotect_fndecl),
- NOT_BUILT_IN, 0, 0);
-
- gc_pop_fndecl = define_function ("__gc_pop",
- build_function_type (void_type_node,
- void_list_node),
- NOT_BUILT_IN, 0, 0);
- gc_nonobject = build_int_2 (0x80000000, 0);
- gc_visible = build_int_2 (0x40000000, 0);
- gc_white = integer_zero_node;
- gc_offwhite = build_int_2 (0x10000000, 0);
- gc_grey = build_int_2 (0x20000000, 0);
- gc_black = build_int_2 (0x30000000, 0);
-}
diff --git a/contrib/gcc/cp/gpcompare.texi b/contrib/gcc/cp/gpcompare.texi
deleted file mode 100644
index 7b0d573105b6..000000000000
--- a/contrib/gcc/cp/gpcompare.texi
+++ /dev/null
@@ -1,236 +0,0 @@
-@node ANSI
-@chapter @sc{gnu} C++ Conformance to @sc{ansi} C++
-
-These changes in the @sc{gnu} C++ compiler were made to comply more
-closely with the @sc{ansi} base document, @cite{The Annotated C++
-Reference Manual} (the @sc{arm}). Further reducing the divergences from
-@sc{ansi} C++ is a continued goal of the @sc{gnu} C++ Renovation
-Project.
-
-@b{Section 3.4}, @i{Start and Termination}. It is now invalid to take
-the address of the function @samp{main()}.
-
-@b{Section 4.8}, @i{Pointers to Members}. The compiler produces
-an error for trying to convert between a pointer to a member and the type
-@samp{void *}.
-
-@b{Section 5.2.5}, @i{Increment and Decrement}. It is an error to use
-the increment and decrement operators on an enumerated type.
-
-@b{Section 5.3.2}, @i{Sizeof}. Doing @code{sizeof} on a function is now
-an error.
-
-@b{Section 5.3.4}, @i{Delete}. The syntax of a @i{cast-expression} is
-now more strictly controlled.
-
-@b{Section 7.1.1}, @i{Storage Class Specifiers}. Using the
-@code{static} and @code{extern} specifiers can now only be applied to
-names of objects, functions, and anonymous unions.
-
-@b{Section 7.1.1}, @i{Storage Class Specifiers}. The compiler no longer complains
-about taking the address of a variable which has been declared to have @code{register}
-storage.
-
-@b{Section 7.1.2}, @i{Function Specifiers}. The compiler produces an
-error when the @code{inline} or @code{virtual} specifiers are
-used on anything other than a function.
-
-@b{Section 8.3}, @i{Function Definitions}. It is now an error to shadow
-a parameter name with a local variable; in the past, the compiler only
-gave a warning in such a situation.
-
-@b{Section 8.4.1}, @i{Aggregates}. The rules concerning declaration of
-an aggregate are now all checked in the @sc{gnu} C++ compiler; they
-include having no private or protected members and no base classes.
-
-@b{Section 8.4.3}, @i{References}. Declaring an array of references is
-now forbidden. Initializing a reference with an initializer list is
-also considered an error.
-
-@b{Section 9.5}, @i{Unions}. Global anonymous unions must be declared
-@code{static}.
-
-@b{Section 11.4}, @i{Friends}. Declaring a member to be a friend of a
-type that has not yet been defined is an error.
-
-@b{Section 12.1}, @i{Constructors}. The compiler generates a
-default copy constructor for a class if no constructor has been declared.
-
-@ignore
-@b{Section 12.4}, @i{Destructors}. In accordance with the @sc{ansi} C++
-draft standard working paper, a pure virtual destructor must now be
-defined.
-@end ignore
-
-@b{Section 12.6.2}, @i{Special Member Functions}. When using a
-@i{mem-initializer} list, the compiler will now initialize class members
-in declaration order, not in the order in which you specify them.
-Also, the compiler enforces the rule that non-static @code{const}
-and reference members must be initialized with a @i{mem-initializer}
-list when their class does not have a constructor.
-
-@b{Section 12.8}, @i{Copying Class Objects}. The compiler generates
-default copy constructors correctly, and supplies default assignment
-operators compatible with user-defined ones.
-
-@b{Section 13.4}, @i{Overloaded Operators}. An overloaded operator may
-no longer have default arguments.
-
-@b{Section 13.4.4}, @i{Function Call}. An overloaded @samp{operator ()}
-must be a non-static member function.
-
-@b{Section 13.4.5}, @i{Subscripting}. An overloaded @samp{operator []}
-must be a non-static member function.
-
-@b{Section 13.4.6}, @i{Class Member Access}. An overloaded @samp{operator ->}
-must be a non-static member function.
-
-@b{Section 13.4.7}, @i{Increment and Decrement}. The compiler will now
-make sure a postfix @samp{@w{operator ++}} or @samp{@w{operator --}} has an
-@code{int} as its second argument.
-
-
-@node Encoding
-@chapter Name Encoding in @sc{gnu} C++
-
-@c FIXME!! rewrite name encoding section
-@c ...to give complete rules rather than diffs from ARM.
-@c To avoid plagiarism, invent some different way of structuring the
-@c description of the rules than what ARM uses.
-
-@cindex mangling
-@cindex name encoding
-@cindex encoding information in names
-In order to support its strong typing rules and the ability to provide
-function overloading, the C++ programming language @dfn{encodes}
-information about functions and objects, so that conflicts across object
-files can be detected during linking. @footnote{This encoding is also
-sometimes called, whimsically enough, @dfn{mangling}; the corresponding
-decoding is sometimes called @dfn{demangling}.} These rules tend to be
-unique to each individual implementation of C++.
-
-The scheme detailed in the commentary for 7.2.1 of @cite{The Annotated
-Reference Manual} offers a description of a possible implementation
-which happens to closely resemble the @code{cfront} compiler. The
-design used in @sc{gnu} C++ differs from this model in a number of ways:
-
-@itemize @bullet
-@item
-In addition to the basic types @code{void}, @code{char}, @code{short},
-@code{int}, @code{long}, @code{float}, @code{double}, and @code{long
-double}, @sc{gnu} C++ supports two additional types: @code{wchar_t}, the wide
-character type, and @code{long long} (if the host supports it). The
-encodings for these are @samp{w} and @samp{x} respectively.
-
-@item
-According to the @sc{arm}, qualified names (e.g., @samp{foo::bar::baz}) are
-encoded with a leading @samp{Q}. Followed by the number of
-qualifications (in this case, three) and the respective names, this
-might be encoded as @samp{Q33foo3bar3baz}. @sc{gnu} C++ adds a leading
-underscore to the list, producing @samp{_Q33foo3bar3baz}.
-
-@item
-The operator @samp{*=} is encoded as @samp{__aml}, not @samp{__amu}, to
-match the normal @samp{*} operator, which is encoded as @samp{__ml}.
-
-@c XXX left out ->(), __wr
-@item
-In addition to the normal operators, @sc{gnu} C++ also offers the minimum and
-maximum operators @samp{>?} and @samp{<?}, encoded as @samp{__mx} and
-@samp{__mn}, and the conditional operator @samp{?:}, encoded as @samp{__cn}.
-
-@cindex destructors, encoding of
-@cindex constructors, encoding of
-@item
-Constructors are encoded as simply @samp{__@var{name}}, where @var{name}
-is the encoded name (e.g., @code{3foo} for the @code{foo} class
-constructor). Destructors are encoded as two leading underscores
-separated by either a period or a dollar sign, depending on the
-capabilities of the local host, followed by the encoded name. For
-example, the destructor @samp{foo::~foo} is encoded as @samp{_$_3foo}.
-
-@item
-Virtual tables are encoded with a prefix of @samp{_vt}, rather than
-@samp{__vtbl}. The names of their classes are separated by dollar signs
-(or periods), and not encoded as normal: the virtual table for
-@code{foo} is @samp{__vt$foo}, and the table for @code{foo::bar} is
-named @samp{__vt$foo$bar}.
-
-@item
-Static members are encoded as a leading underscore, followed by the
-encoded name of the class in which they appear, a separating dollar sign
-or period, and finally the unencoded name of the variable. For example,
-if the class @code{foo} contains a static member @samp{bar}, its
-encoding would be @samp{_3foo$bar}.
-
-@item
-@sc{gnu} C++ is not as aggressive as other compilers when it comes to always
-generating @samp{Fv} for functions with no arguments. In particular,
-the compiler does not add the sequence to conversion operators. The
-function @samp{foo::bar()} is encoded as @samp{bar__3foo}, not
-@samp{bar__3fooFv}.
-
-@item
-The argument list for methods is not prefixed by a leading @samp{F}; it
-is considered implied.
-
-@item
-@sc{gnu} C++ approaches the task of saving space in encodings
-differently from that noted in the @sc{arm}. It does use the
-@samp{T@var{n}} and @samp{N@var{x}@var{y}} codes to signify copying the
-@var{n}th argument's type, and making the next @var{x} arguments be the
-type of the @var{y}th argument, respectively. However, the values for
-@var{n} and @var{y} begin at zero with @sc{gnu} C++, whereas the
-@sc{arm} describes them as starting at one. For the function @samp{foo
-(bartype, bartype)}, @sc{gnu} C++ uses @samp{foo__7bartypeT0}, while
-compilers following the @sc{arm} example generate @samp{foo__7bartypeT1}.
-
-@c Note it loses on `foo (int, int, int, int, int)'.
-@item
-@sc{gnu} C++ does not bother using the space-saving methods for types whose
-encoding is a single character (like an integer, encoded as @samp{i}).
-This is useful in the most common cases (two @code{int}s would result in
-using three letters, instead of just @samp{ii}).
-@end itemize
-
-@c @node Cfront
-@c @chapter @code{cfront} Compared to @sc{gnu} C++
-@c
-@c
-@c FIXME!! Fill in. Consider points in the following:
-@c
-@c @display
-@c Date: Thu, 2 Jan 92 21:35:20 EST
-@c From: raeburn@@cygnus.com
-@c Message-Id: <9201030235.AA10999@@cambridge.cygnus.com>
-@c To: mrs@@charlie.secs.csun.edu
-@c Cc: g++@@cygnus.com
-@c Subject: Re: ARM and GNU C++ incompatabilities
-@c
-@c Along with that, we should probably describe how g++ differs from
-@c cfront, in ways that the users will notice. (E.g., cfront supposedly
-@c allows "free (new char[10])"; does g++? How do the template
-@c implementations differ? "New" placement syntax?)
-@c @end display
-@c
-@c XXX For next revision.
-@c
-@c GNU C++:
-@c * supports expanding inline functions in many situations,
-@c including those which have static objects, use `for' statements,
-@c and other situations. Part of this versatility is due to is
-@c ability to not always generate temporaries for assignments.
-@c * deliberately allows divide by 0 and mod 0, since [according
-@c to Wilson] there are actually situations where you'd like to allow
-@c such things. Note on most systems it will cause some sort of trap
-@c or bus error. Cfront considers it an error.
-@c * does [appear to] support nested classes within templates.
-@c * conversion functions among baseclasses are all usable by
-@c a class that's derived from all of those bases.
-@c * sizeof works even when the class is defined within its ()'s
-@c * conditional expressions work with member fns and pointers to
-@c members.
-@c * can handle non-trivial declarations of variables within switch
-@c statements.
-@c
-@c Cfront:
diff --git a/contrib/gcc/cp/reno.texi b/contrib/gcc/cp/reno.texi
deleted file mode 100644
index d5f254a6929b..000000000000
--- a/contrib/gcc/cp/reno.texi
+++ /dev/null
@@ -1,752 +0,0 @@
-\input texinfo @c -*- Texinfo -*-
-@setfilename reno-1.info
-
-@ifinfo
-@format
-START-INFO-DIR-ENTRY
-* Reno 1: (reno). The GNU C++ Renovation Project, Phase 1.
-END-INFO-DIR-ENTRY
-@end format
-@end ifinfo
-
-@ifinfo
-Copyright @copyright{} 1992, 1993, 1994 Free Software Foundation, Inc.
-
-Permission is granted to make and distribute verbatim copies of
-this manual provided the copyright notice and this permission notice
-are preserved on all copies.
-
-@ignore
-Permission is granted to process this file through TeX and print the
-results, provided the printed document carries a copying permission
-notice identical to this one except for the removal of this paragraph
-(this paragraph not being relevant to the printed manual).
-
-@end ignore
-
-Permission is granted to copy and distribute modified versions of this
-manual under the conditions for verbatim copying, provided also that
-the entire resulting derived work is distributed under the terms of a
-permission notice identical to this one.
-
-Permission is granted to copy and distribute translations of this manual
-into another language, under the above conditions for modified versions.
-@end ifinfo
-
-@setchapternewpage odd
-@settitle GNU C++ Renovation Project
-@c @smallbook
-
-@titlepage
-@finalout
-@title GNU C++ Renovation Project
-@subtitle Phase 1.3
-@author Brendan Kehoe, Jason Merrill,
-@author Mike Stump, Michael Tiemann
-@page
-
-Edited March, 1994 by Roland Pesch (@code{pesch@@cygnus.com})
-@vskip 0pt plus 1filll
-Copyright @copyright{} 1992, 1993, 1994 Free Software Foundation, Inc.
-
-Permission is granted to make and distribute verbatim copies of
-this manual provided the copyright notice and this permission notice
-are preserved on all copies.
-
-@ignore
-Permission is granted to process this file through Tex and print the
-results, provided the printed document carries copying permission
-notice identical to this one except for the removal of this paragraph
-(this paragraph not being relevant to the printed manual).
-@end ignore
-
-Permission is granted to copy and distribute modified versions of this
-manual under the conditions for verbatim copying, provided also that
-the entire resulting derived work is distributed under the terms of a
-permission notice identical to this one.
-
-Permission is granted to copy and distribute translations of this manual
-into another language, under the above conditions for modified versions.
-@end titlepage
-
-@ifinfo
-@node Top
-@top @sc{gnu} C++ Renovation Project
-
-This file describes the goals of the @sc{gnu} C++ Renovation Project,
-and its accomplishments to date (as of Phase 1.3).
-
-It also discusses the remaining divergences from @sc{gnu} C++, and how the
-name encoding in @sc{gnu} C++ differs from the sample encoding in
-@cite{The Annotated C++ Reference Manual}.
-@c This is not a good place to introduce the acronym ARM because it's
-@c info-only.
-
-@menu
-* Introduction:: What is the GNU C++ Renovation Project?
-* Changes:: Summary of changes since previous GNU C++ releases.
-* Plans:: Plans for Reno-2.
-* Templates:: The template implementation.
-* ANSI:: GNU C++ conformance to ANSI C++.
-* Encoding:: Name encoding in GNU C++.
-@end menu
-
-@end ifinfo
-
-@node Introduction
-@chapter Introduction
-
-As you may remember, @sc{gnu} C++ was the first native-code C++
-compiler available under Unix (December 1987). In November 1988, it was
-judged superior to the AT&T compiler in a Unix World review. In 1990 it
-won a Sun Observer ``Best-Of'' award. But now, with new requirements
-coming out of the @sc{ansi} C++ committee and a growing backlog of bugs, it's
-clear that @sc{gnu} C++ needs an overhaul.
-
-The C++ language has been under development since 1982. It has
-evolved significantly since its original incarnation (C with Classes),
-addressing many commercial needs and incorporating many lessons
-learned as more and more people started using ``object-oriented''
-programming techniques. In 1989, the first X3J16 committee meeting
-was held in Washington DC; in the interest of users, C++ was going to
-be standardized.
-
-As C++ has become more popular, more demands have been placed on its
-compilers. Some compilers are up to the demands, others are not.
-@sc{gnu} C++ was used to prototype several features which have since
-been incorporated into the standard, most notably exception handling.
-While @sc{gnu} C++ has been an excellent experimental vehicle, it did
-not have the resources that AT&T, Borland, or Microsoft have at their
-disposal.
-
-We believe that @sc{gnu} C++ is an important compiler, providing users with
-many of the features that have made @sc{gnu} C so popular: fast compilation,
-good error messages, innovative features, and full sources that may be
-freely redistributed. The purpose of this overhaul, dubbed the @var{@sc{gnu}
-C++ Renovation Project}, is to take advantage of the functionality that
-@sc{gnu} C++ offers today, to strengthen its base technology, and put it in a
-position to remain---as other @sc{gnu} software currently is---the technical
-leader in the field.
-
-This release represents the latest phase of work in strengthening the
-compiler on a variety of points. It includes many months of
-work concentrated on fixing many of the more egregious bugs that
-presented themselves in the compiler recently.
-@ignore
-@c FIXME-- update?
-Nearly 85% of all bugs reported in the period of February to September
-of 1992 were fixed as part of the work in the first phase.
-@end ignore
-In the coming months, we hope to continue expanding and enhancing the
-quality and dependability of the industry's only freely redistributable
-C++ compiler.
-
-@node Changes
-@chapter Changes in Behavior in @sc{gnu} C++
-
-The @sc{gnu} C++ compiler continues to improve and change. A major goal
-of our work has been to continue to bring the compiler into compliance
-with the draft @sc{ansi} C++ standard, and with @cite{The Annotated C++
-Reference Manual} (the @sc{arm}). This section outlines most of the
-user-noticeable changes that might be encountered during the normal
-course of use.
-
-@menu
-* Summary of Phase 1.3::
-* Major changes::
-* New features::
-* Enhancements and bug fixes::
-* Problems with debugging::
-@end menu
-
-@node Summary of Phase 1.3
-@section Summary of Changes in Phase 1.3
-
-The bulk of this note discusses the cumulative effects of the @sc{gnu} C++
-Renovation Project to date. The work during its most recent phase (1.3)
-had these major effects:
-
-@itemize @bullet
-@item The standard compiler driver @code{g++} is now the faster compiled
-version, rather than a shell script.
-
-@item Nested types work much better; notably, nesting is no longer
-restricted to nine levels.
-
-@item Better @sc{arm} conformance on member access control.
-
-@item The compiler now always generates default assignment operators
-(@samp{operator =}), copy constructors (@samp{X::X(X&)}), and default
-constructors (@samp{X::X()}) whenever they are required.
-
-@item The new draft @sc{ansi} standard keyword @code{mutable} is supported.
-
-@item @samp{-fansi-overloading} is the default, to comply better with
-the @sc{arm} (at some cost in compatibility to earlier versions of @sc{gnu} C++).
-
-@item More informative error messages.
-
-@item System include files are automatically treated as if they were
-wrapped in @samp{extern "C" @{ @}}.
-
-@item The new option @samp{-falt-external-templates} provides alternate
-template instantiation semantics.
-
-@item Operator declarations are now checked more strictly.
-
-@item You can now use template type arguments in the template parameter list.
-
-@item You can call the destructor for any type.
-
-@item The compiler source code is better organized.
-
-@item You can specify where to instantiate template definitions explicitly.
-@end itemize
-
-Much of the work in Phase 1.3 went to elimination of known bugs, as well
-as the major items above.
-
-During the span of Phase 1.3, there were also two changes associated
-with the compiler that, while not specifically part of the C++
-Renovation project, may be of interest:
-
-@itemize @bullet
-@item @code{gcov}, a code coverage tool for @sc{gnu cc}, is now available
-from Cygnus Support. (@code{gcov} is free software, but the @sc{fsf} has not
-yet accepted it.) @xref{Gcov,, @code{gcov}: a Test Coverage Program,
-gcc.info, Using GNU CC}, for more information (in Cygnus releases of
-that manual).
-
-@item @sc{gnu} C++ now supports @dfn{signatures}, a language extension to
-provide more flexibility in abstract type definitions. @xref{C++
-Signatures,, Type Abstraction using Signatures, gcc.info, Using GNU CC}.
-@end itemize
-
-@node Major changes
-@section Major Changes
-
-This release includes four wholesale rewrites of certain areas of
-compiler functionality:
-
-@enumerate 1
-@item Argument matching. @sc{gnu} C++ is more compliant with the rules
-described in Chapter 13, ``Overloading'', of the @sc{arm}. This behavior is
-the default, though you can specify it explicitly with
-@samp{-fansi-overloading}. For compatibility with earlier releases of
-@sc{gnu} C++, specify @samp{-fno-ansi-overloading}; this makes the compiler
-behave as it used to with respect to argument matching and name overloading.
-
-@item Default constructors/destructors. Section 12.8 of the @sc{arm}, ``Copying
-Class Objects'', and Section 12.1, ``Constructors'', state that a
-compiler must declare such default functions if the user does not
-specify them. @sc{gnu} C++ now declares, and generates when necessary,
-the defaults for constructors and destructors you might omit. In
-particular, assignment operators (@samp{operator =}) behave the same way
-whether you define them, or whether the compiler generates them by
-default; taking the address of the default @samp{operator =} is now
-guaranteed to work. Default copy constructors (@samp{X::X(X&)}) now
-function correctly, rather than calling the copy assignment operator for
-the base class. Finally, constructors (@samp{X::X()}), as well as
-assignment operators and copy constructors, are now available whenever
-they are required.
-
-@c XXX This may be taken out eventually...
-@item Binary incompatibility. There are no new binary incompatibilities
-in Phase 1.3, but Phase 1.2 introduced two binary incompatibilities with
-earlier releases. First, the functionality of @samp{operator
-new} and @samp{operator delete} changed. Name encoding
-(``mangling'') of virtual table names changed as well. Libraries
-built with versions of the compiler earlier than Phase 1.2 must be
-compiled with the new compiler. (This includes the Cygnus Q2
-progressive release and the FSF 2.4.5 release.)
-
-@item New @code{g++} driver.
-A new binary @code{g++} compiler driver replaces the shell script.
-The new driver executes faster.
-@end enumerate
-
-@node New features
-@section New features
-
-@itemize @bullet
-@item
-The compiler warns when a class contains only private constructors
-or destructors, and has no friends. At the request of some of our
-customers, we have added a new option, @samp{-Wctor-dtor-privacy} (on by
-default), and its negation, @samp{-Wno-ctor-dtor-privacy}, to control
-the emission of this warning. If, for example, you are working towards
-making your code compile warning-free, you can use @w{@samp{-Wall
--Wno-ctor-dtor-privacy}} to find the most common warnings.
-
-@item
-There is now a mechanism which controls exactly when templates are
-expanded, so that you can reduce memory usage and program size and also
-instantiate them exactly once. You can control this mechanism with the
-option @samp{-fexternal-templates} and its corresponding negation
-@samp{-fno-external-templates}. Without this feature, space consumed by
-template instantiations can grow unacceptably in large-scale projects
-with many different source files. The default is
-@samp{-fno-external-templates}.
-
-You do not need to use the @samp{-fexternal-templates} option when
-compiling a file that does not define and instantiate templates used in
-other files, even if those files @emph{are} compiled with
-@samp{-fexternal-templates}. The only side effect is an increase in
-object size for each file that was compiled without
-@samp{-fexternal-templates}.
-
-When your code is compiled with @samp{-fexternal-templates}, all
-template instantiations are external; this requires that the templates
-be under the control of @samp{#pragma interface} and @samp{#pragma
-implementation}. All instantiations that will be needed should be in
-the implementation file; you can do this with a @code{typedef} that
-references the instantiation needed. Conversely, when you compile using
-the option @samp{-fno-external-templates}, all template instantiations are
-explicitly internal.
-
-@samp{-fexternal-templates} also allows you to finally separate class
-template function definitions from their declarations, thus speeding up
-compilation times for every file that includes the template declaration.
-Now you can have tens or even hundreds of lines in template
-declarations, and thousands or tens of thousands of lines in template
-definitions, with the definitions only going through the compiler once
-instead of once for each source file. It is important to note that you
-must remember to externally instantiate @emph{all} templates that are
-used from template declarations in interface files. If you forget to do
-this, unresolved externals will occur.
-
-In the example below, the object file generated (@file{example.o}) will
-contain the global instantiation for @samp{Stack<int>}. If other types
-of @samp{Stack} are needed, they can be added to @file{example.cc} or
-placed in a new file, in the same spirit as @file{example.cc}.
-
-@code{foo.h}:
-@smallexample
-@group
-#pragma interface "foo.h"
-template<class T>
-class Stack @{
- static int statc;
- static T statc2;
- Stack() @{ @}
- virtual ~Stack() @{ @}
- int bar();
-@};
-@end group
-@end smallexample
-
-@code{example.cc}:
-@smallexample
-@group
-#pragma implementation "foo.h"
-#include "foo.h"
-
-typedef Stack<int> t;
-int Stack<int>::statc;
-int Stack<int>::statc2;
-int Stack<int>::bar() @{ @}
-@end group
-@end smallexample
-
-Note that using @samp{-fexternal-templates} does not reduce memory usage
-from completely different instantiations (@samp{Stack<Name>} vs.
-@samp{Stack<Net_Connection>}), but only collapses different occurrences
-of @samp{Stack<Name>} so that only one @samp{Stack<Name>} is generated.
-
-@samp{-falt-external-templates} selects a slight variation in the
-semantics described above (incidentally, you need not specify both
-options; @samp{-falt-external-templates} implies
-@samp{-fexternal-templates}).
-
-With @samp{-fexternal-templates}, the compiler emits a definition in the
-implementation file that includes the header definition, @emph{even if}
-instantiation is triggered from a @emph{different} implementation file
-(e.g. with a template that uses another template).
-
-With @samp{-falt-external-templates}, the definition always goes in the
-implementation file that triggers instantiation.
-
-For instance, with these two header files---
-
-@example
-@exdent @file{a.h}:
-#pragma interface
-template <class T> class A @{ @dots{} @};
-
-@exdent @file{b.h}:
-#pragma interface
-class B @{ @dots{} @};
-void f (A<B>);
-@end example
-
-Under @samp{-fexternal-templates}, the definition of @samp{A<B>} ends up
-in the implementation file that includes @file{a.h}. Under
-@samp{-falt-external-templates}, the same definition ends up in the
-implementation file that includes @file{b.h}.
-
-@item
-You can control explicitly where a template is instantiated, without
-having to @emph{use} the template to get an instantiation.
-
-To instantiate a class template explicitly, write @samp{template
-class @var{name}<paramvals>}, where @var{paramvals} is a list of values
-for the template parameters. For example, you might write
-
-@example
-template class A<int>
-@end example
-
-Similarly, to instantiate a function template explicitly, write
-@samp{template @var{fnsign}} where @var{fnsign} is the particular
-function signature you need. For example, you might write
-
-@example
-template void foo (int, int)
-@end example
-
-This syntax for explicit template instantiation agrees with recent
-extensions to the draft @sc{ansi} standard.
-
-@item
-The compiler's actions on @sc{ansi}-related warnings and errors have
-been further enhanced. The @samp{-pedantic-errors} option produces
-error messages in a number of new situations: using @code{return} in a
-non-@code{void} function (one returning a value); declaring a local
-variable that shadows a parameter (e.g., the function takes an argument
-@samp{a}, and has a local variable @samp{a}); and use of the @samp{asm}
-keyword. Finally, the compiler by default now issues a warning when
-converting from an @code{int} to an enumerated type. This is likely to
-cause many new warnings in code that hadn't triggered them before. For
-example, when you compile this code,
-
-@smallexample
-@group
-enum boolean @{ false, true @};
-void
-f ()
-@{
- boolean x;
-
- x = 1; //@i{assigning an @code{int} to an @code{enum} now triggers a warning}
-@}
-@end group
-@end smallexample
-
-@noindent
-you should see the warning ``@code{anachronistic conversion from integer
-type to enumeral type `boolean'}''. Instead of assigning the value 1,
-assign the original enumerated value @samp{true}.
-@end itemize
-
-@node Enhancements and bug fixes
-@section Enhancements and bug fixes
-
-@itemize @bullet
-@cindex nested types in template parameters
-@item
-You can now use nested types in a template parameter list, even if the nested
-type is defined within the same class that attempts to use the template.
-For example, given a template @code{list}, the following now works:
-
-@smallexample
-struct glyph @{
- @dots{}
- struct stroke @{ @dots{} @};
- list<stroke> l;
- @dots{}
-@}
-@end smallexample
-
-@cindex function pointers vs template parameters
-@item
-Function pointers now work in template parameter lists. For
-example, you might want to instantiate a parameterized @code{list} class
-in terms of a pointer to a function like this:
-
-@smallexample
-list<int (*)(int, void *)> fnlist;
-@end smallexample
-
-@item
-@c FIXME! Really no limit? Jason said "deeper than 9" now OK...
-Nested types are now handled correctly. In particular, there is no
-longer a limit to how deeply you can nest type definitions.
-
-@item
-@sc{gnu} C++ now conforms to the specifications in Chapter 11 of the
-@sc{arm}, ``Member Access Control''.
-
-@item
-The @sc{ansi} C++ committee has introduced a new keyword @code{mutable}.
-@sc{gnu} C++ supports it. Use @code{mutable} to specify that some
-particular members of a @code{const} class are @emph{not} constant. For
-example, you can use this to include a cache in a data structure that
-otherwise represents a read-only database.
-
-@item
-Error messages now explicitly specify the declaration, type, or
-expression that contains an error.
-
-@item
-To avoid copying and editing all system include files during @sc{gnu}
-C++ installation, the compiler now automatically recognizes system
-include files as C language definitions, as if they were wrapped in
-@samp{extern "C" @{ @dots{} @}}.
-
-@item
-The compiler checks operator declarations more strictly. For example,
-you may no longer declare an @samp{operator +} with three arguments.
-
-@item
-You can now use template type arguments in the same template
-parameter list where the type argument is specified (as well as in the
-template body). For example, you may write
-
-@example
-template <class T, T t> class A @{ @dots{} @};
-@end example
-
-@item
-Destructors are now available for all types, even built-in ones; for
-example, you can call @samp{int::~int}. (Destructors for types like
-@code{int} do not actually do anything, but their existence provides a
-level of generality that permits smooth template expansion in more
-cases.)
-
-@item
-Enumerated types declared inside a class are now handled correctly.
-
-@item
-An argument list for a function may not use an initializer list for its default
-value. For example, @w{@samp{void foo ( T x = @{ 1, 2 @} )}} is not permitted.
-
-@item
-A significant amount of work went into improving the ability of the
-compiler to act accurately on multiple inheritance and virtual
-functions. Virtual function dispatch has been enhanced as well.
-
-@item
-The warning concerning a virtual inheritance environment with a
-non-virtual destructor has been disabled, since it is not clear that
-such a warning is warranted.
-
-@item
-Until exception handling is fully implemented in the Reno-2 release, use
-of the identifiers @samp{catch}, @samp{throw}, or @samp{try} results
-in the warning:
-
-@smallexample
-t.C:1: warning: `catch', `throw', and `try'
- are all C++ reserved words
-@end smallexample
-
-@item
-When giving a warning or error concerning initialization of a member in a
-class, the compiler gives the name of the member if it has one.
-
-@item
-Detecting friendship between classes is more accurately checked.
-
-@item
-The syntaxes of @w{@samp{#pragma implementation "file.h"}} and
-@samp{#pragma interface} are now more strictly controlled. The compiler
-notices (and warns) when any text follows @file{file.h} in the
-implementation pragma, or follows the word @samp{interface}. Any such
-text is otherwise ignored.
-
-@item
-Trying to declare a template on a variable or type is now considered an
-error, not an unimplemented feature.
-
-@item
-When an error occurs involving a template, the compiler attempts to
-tell you at which point of instantiation the error occurred, in
-addition to noting the line in the template declaration which had the
-actual error.
-
-@item
-The symbol names for function templates in the resulting assembly file
-are now encoded according to the arguments, rather than just being
-emitted as, for example, two definitions of a function @samp{foo}.
-
-@item
-Template member functions that are declared @code{static} no longer
-receive a @code{this} pointer.
-
-@item
-Case labels are no longer allowed to have commas to make up their
-expressions.
-
-@item
-Warnings concerning the shift count of a left or right shift now tell
-you if it was a @samp{left} or @samp{right} shift.
-
-@item
-The compiler now warns when a decimal constant is so large that it
-becomes @code{unsigned}.
-
-@item
-Union initializers which are raw constructors are now handled properly.
-
-@item
-The compiler no longer gives incorrect errors when initializing a
-union with an empty initializer list.
-
-@item
-Anonymous unions are now correctly used when nested inside a class.
-
-@item
-Anonymous unions declared as static class members are now handled
-properly.
-
-@item
-The compiler now notices when a field in a class is declared both as
-a type and a non-type.
-
-@item
-The compiler now warns when a user-defined function shadows a
-built-in function, rather than emitting an error.
-
-@item
-A conflict between two function declarations now produces an error
-regardless of their language context.
-
-@item
-Duplicate definitions of variables with @samp{extern "C"} linkage are no
-longer considered in error. (Note in C++ linkage---the default---you may
-not have more than one definition of a variable.)
-
-@item
-Referencing a label that is not defined in any function is now an error.
-
-@item
-The syntax for pointers to methods has been improved; there are still
-some minor bugs, but a number of cases should now be accepted by the
-compiler.
-
-@item
-In error messages, arguments are now numbered starting at 1, instead of
-0. Therefore, in the function @samp{void foo (int a, int b)}, the
-argument @samp{a} is argument 1, and @samp{b} is argument 2. There is
-no longer an argument 0.
-
-@item
-The tag for an enumerator, rather than its value, used as a default
-argument is now shown in all error messages. For example, @w{@samp{void
-foo (enum x (= true))}} is shown instead of @w{@samp{void foo (enum x (=
-1))}}.
-
-@item
-The @samp{__asm__} keyword is now accepted by the C++ front-end.
-
-@item
-Expressions of the form @samp{foo->~Class()} are now handled properly.
-
-@item
-The compiler now gives better warnings for situations which result in
-integer overflows (e.g., in storage sizes, enumerators, unary
-expressions, etc).
-
-@item
-@code{unsigned} bitfields are now promoted to @code{signed int} if the
-field isn't as wide as an @code{int}.
-
-@item
-Declaration and usage of prefix and postfix @samp{operator ++} and
-@samp{operator --} are now handled correctly. For example,
-
-@smallexample
-@group
-class foo
-@{
-public:
- operator ++ ();
- operator ++ (int);
- operator -- ();
- operator -- (int);
-@};
-
-void
-f (foo *f)
-@{
- f++; // @i{call @code{f->operator++(int)}}
- ++f; // @i{call @code{f->operator++()}}
- f--; // @i{call @code{f->operator++(int)}}
- --f; // @i{call @code{f->operator++()}}
-@}
-@end group
-@end smallexample
-
-@item
-In accordance with @sc{arm} section 10.1.1, ambiguities and dominance are now
-handled properly. The rules described in section 10.1.1 are now fully
-implemented.
-
-@end itemize
-
-@node Problems with debugging
-@section Problems with debugging
-
-Two problems remain with regard to debugging:
-
-@itemize @bullet
-@item
-Debugging of anonymous structures on the IBM RS/6000 host is incorrect.
-
-@item
-Symbol table size is overly large due to redundant symbol information;
-this can make @code{gdb} coredump under certain circumstances. This
-problem is not host-specific.
-@end itemize
-
-@node Plans
-@chapter Plans for Reno-2
-
-The overall goal for the second phase of the @sc{gnu} C++ Renovation
-Project is to bring @sc{gnu} C++ to a new level of reliability, quality,
-and competitiveness. As particular elements of this strategy, we intend
-to:
-
-@enumerate 0
-@item
-Fully implement @sc{ansi} exception handling.
-
-@item
-With the exception handling, add Runtime Type Identification
-(@sc{rtti}), if the @sc{ansi} committee adopts it into the standard.
-
-@item
-Bring the compiler into closer compliance with the @sc{arm} and the draft
-@sc{ansi} standard, and document what points in the @sc{arm} we do not yet comply,
-or agree, with.
-
-@item
-Add further support for the @sc{dwarf} debugging format.
-
-@item
-Finish the work to make the compiler compliant with @sc{arm} Section 12.6.2,
-initializing base classes in declaration order, rather than in the order
-that you specify them in a @var{mem-initializer} list.
-
-@item
-Perform a full coverage analysis on the compiler, and weed out unused
-code, for a gain in performance and a reduction in the size of the compiler.
-
-@item
-Further improve the multiple inheritance implementation in the
-compiler to make it cleaner and more complete.
-@end enumerate
-
-@noindent
-As always, we encourage you to make suggestions and ask questions about
-@sc{gnu} C++ as a whole, so we can be sure that the end of this project
-will bring a compiler that everyone will find essential for C++ and will
-meet the needs of the world's C++ community.
-
-@include templates.texi
-
-@include gpcompare.texi
-
-@contents
-
-@bye
diff --git a/contrib/gcc/cp/templates.texi b/contrib/gcc/cp/templates.texi
deleted file mode 100644
index 2a6db07f42b2..000000000000
--- a/contrib/gcc/cp/templates.texi
+++ /dev/null
@@ -1,235 +0,0 @@
-@node Templates
-@chapter The Template Implementation
-
-@cindex templates
-@cindex function templates
-@cindex class templates
-@cindex parameterized types
-@cindex types, parameterized
-The C++ template@footnote{Class templates are also known as
-@dfn{parameterized types}.} facility, which effectively allows use of
-variables for types in declarations, is one of the newest features of
-the language.
-
-@sc{gnu} C++ is one of the first compilers to implement many
-of the template facilities currently defined by the @sc{ansi} committee.
-
-Nevertheless, the template implementation is not yet complete. This
-chapter maps the current limitations of the @sc{gnu} C++ template
-implementation.
-
-@menu
-* Template limitations:: Limitations for function and class templates
-* Function templates:: Limitations for function templates
-* Class templates:: Limitations for class templates
-* Template debugging:: Debugging information for templates
-@end menu
-
-@node Template limitations
-@section Limitations for function and class templates
-
-@cindex template limitations
-@cindex template bugs
-@cindex bugs, templates
-These limitations apply to any use of templates (function templates or
-class templates) with @sc{gnu} C++:
-
-@table @emph
-@item Template definitions must be visible
-When you compile code with templates, the template definitions must come
-first (before the compiler needs to expand them), and template
-definitions you use must be visible in the current scope.
-@c FIXME! Is this a defined property of templates, rather than a
-@c temporary limitation?
-@c ANSWER: It's a limitation, but it's hard to say why it's a limitation
-@c to someone. We need an infinite link-cycle, in one camp, to
-@c accomplish things so you don't need the template definitions around.
-
-@cindex static data in template classes
-@cindex template classes, static data in
-@item Individual initializers needed for static data
-Templates for static data in template classes do not work. @xref{Class
-templates,,Limitations for class templates}.
-@end table
-
-@node Function templates
-@section Limitations for function templates
-
-@cindex function template limitations
-Function templates are implemented for the most part. The compiler can
-correctly determine template parameter values, and will delay
-instantiation of a function that uses templates until the requisite type
-information is available.
-
-@noindent
-The following limitations remain:
-
-@itemize @bullet
-@cindex template vs declaration, functions
-@cindex declaration vs template, functions
-@cindex function declaration vs template
-@item
-Narrowed specification: function declarations should not prevent
-template expansion. When you declare a function, @sc{gnu} C++
-interprets the declaration as an indication that you will provide a
-definition for that function. Therefore, @sc{gnu} C++ does not use a
-template expansion if there is also an applicable declaration. @sc{gnu}
-C++ only expands the template when there is no such declaration.
-
-The specification in Bjarne Stroustrup's @cite{The C++ Programming
-Language, Second Edition} is narrower, and the @sc{gnu} C++
-implementation is now clearly incorrect. With this new specification, a
-declaration that corresponds to an instantiation of a function template
-only affects whether conversions are needed to use that version of the
-function. It should no longer prevent expansion of the template
-definition.
-
-For example, this code fragment must be treated differently:
-
-@smallexample
-template <class X> X min (X& x1, X& x2) @{ @dots{} @}
-int min (int, int);
-@dots{}
-int i; short s;
-min (i, s); // @r{should call} min(int,int)
- // @r{derived from template}
-@dots{}
-@end smallexample
-
-@item
-The compiler does not yet understand function signatures where types are
-nested within template parameters. For example, a function like the
-following produces a syntax error on the closing @samp{)} of the
-definition of the function @code{f}:
-
-@smallexample
-template <class T> class A @{ public: T x; class Y @{@}; @};
-template <class X> int f (A<X>::Y y) @{ @dots{} @}
-@end smallexample
-
-@cindex @code{inline} and function templates
-@cindex function templates and @code{inline}
-@item
-If you declare an @code{inline} function using templates, the compiler
-can only inline the code @emph{after} the first time you use
-that function with whatever particular type signature the template
-was instantiated.
-
-Removing this limitation is akin to supporting nested function
-definitions in @sc{gnu} C++; the limitation will probably remain until the
-more general problem of nested functions is solved.
-
-@item
-All the @emph{method} templates (templates for member functions) for a
-class must be visible to the compiler when the class template is
-instantiated.
-@end itemize
-
-@node Class templates
-@section Limitations for class templates
-
-@cindex class template limitations
-@ignore
-FIXME!! Include a comprehensible version of this if someone can explain it.
- (Queried Brendan and Raeburn w/full orig context, 26may1993---pesch)
- - [RHP: I don't understand what the following fragment refers to. If it's
- the "BIG BUG" section in the original, why does it say "overriding class
- declarations" here when the more detailed text refers to *function*
- declarations? Here's the fragment I don't understand:]
- there are problems with user-supplied overriding class declarations (see
- below).
-@end ignore
-
-@itemize @bullet
-@ignore
-@cindex static data, not working in templates
-@item
-Templates for static data in template classes do not work.
-Currently, you must initialize each case of such data
-individually.
-@c FIXME!! Brendan to see if still true.
-@c ANSWER: This section presumes that it's incorrect to have to
-@c initialize for each type you instantiate with. It's not, it's the
-@c right way to do it.
-@end ignore
-
-Unfortunately, individual initializations of this sort are likely to be
-considered errors eventually; since they're needed now, you might want to
-flag places where you use them with comments to mark the need for a
-future transition.
-
-@cindex nested type results vs templates
-@item
-Member functions in template classes may not have results of nested
-type; @sc{gnu} C++ signals a syntax error on the attempt. The following
-example illustrates this problem with an @code{enum} type @code{alph}:
-
-@smallexample
-template <class T> class list @{
- @dots{}
- enum alph @{a,b,c@};
- alph bar();
- @dots{}
-@};
-
-template <class T>
-list<int>::alph list<int>::bar() // @i{Syntax error here}
-@{
-@dots{}
-@}
-@end smallexample
-
-@cindex preprocessor conditionals in templates
-@cindex conditionals (preprocessor) in templates
-@item
-A parsing bug makes it difficult to use preprocessor conditionals within
-templates. For example, in this code:
-
-@smallexample
-template <class T>
-class list @{
- @dots{}
-#ifdef SYSWRONG
- T x;
-#endif
- @dots{}
-@}
-@end smallexample
-
-The preprocessor output leaves sourcefile line number information (lines
-like @samp{# 6 "foo.cc"} when it expands the @code{#ifdef} block. These
-lines confuse the compiler while parsing templates, giving a syntax
-error.
-
-If you cannot avoid preprocessor conditionals in templates, you can
-suppress the line number information using the @samp{-P} preprocessor
-option (but this will make debugging more difficult), by compiling the
-affected modules like this:
-
-@smallexample
-g++ -P foo.cc -o foo
-@end smallexample
-
-@cindex parsing errors, templates
-@item
-Parsing errors are reported when templates are first
-@emph{instantiated}---not on the template definition itself. In
-particular, if you do not instantiate a template definition at all, the
-compiler never reports any parsing errors that may be in the template
-definition.
-@end itemize
-
-@node Template debugging
-@section Debugging information for templates
-
-@cindex templates and debugging information
-@cindex debugging information and templates
-Debugging information for templates works for some object code formats,
-but not others. It works for stabs@footnote{Except that insufficient
-debugging information for methods of template classes is generated in
-stabs.} (used primarily in @sc{a.out} object code, but also in the Solaris 2
-version of @sc{elf}), and the @sc{mips} version of @sc{coff} debugging
-format.
-
-@sc{dwarf} support is currently minimal, and requires further
-development.
diff --git a/contrib/gcc/cp/tree.def b/contrib/gcc/cp/tree.def
deleted file mode 100644
index 82b7954e29c0..000000000000
--- a/contrib/gcc/cp/tree.def
+++ /dev/null
@@ -1,116 +0,0 @@
-/* This file contains the definitions and documentation for the
- additional tree codes used in the GNU C++ compiler (see tree.def
- for the standard codes).
- Copyright (C) 1987, 1988, 1990, 1993 Free Software Foundation, Inc.
- Hacked by Michael Tiemann (tiemann@cygnus.com)
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-
-/* Reference to the contents of an offset
- (a value whose type is an OFFSET_TYPE).
- Operand 0 is the object within which the offset is taken.
- Operand 1 is the offset. The language independent OFFSET_REF
- just won't work for us. */
-DEFTREECODE (CP_OFFSET_REF, "cp_offset_ref", "r", 2)
-
-/* For DELETE_EXPR, operand 0 is the store to be destroyed.
- Operand 1 is the value to pass to the destroying function
- saying whether the store should be deallocated as well. */
-DEFTREECODE (DELETE_EXPR, "dl_expr", "e", 2)
-DEFTREECODE (VEC_DELETE_EXPR, "vec_dl_expr", "e", 2)
-
-/* For a UNSAVE_EXPR, operand 0 is the value to unsave. By unsave, we
- mean that all _EXPRs such as TARGET_EXPRs, SAVE_EXPRs,
- WITH_CLEANUP_EXPRs, CALL_EXPRs and RTL_EXPRs, that are protected
- from being evaluated more than once should be reset so that a new
- expand_expr call of this expr will cause those to be re-evaluated.
- This is useful when we want to reuse a tree in different places,
- but where we must re-expand. */
-DEFTREECODE (UNSAVE_EXPR, "unsave_expr", "e", 1)
-
-/* Value is reference to particular overloaded class method.
- Operand 0 is the class name (an IDENTIFIER_NODE);
- operand 1 is the field (also an IDENTIFIER_NODE).
- The COMPLEXITY field holds the class level (usually 0). */
-DEFTREECODE (SCOPE_REF, "scope_ref", "r", 2)
-
-/* When composing an object with a member, this is the result.
- Operand 0 is the object. Operand 1 is the member (usually
- a dereferenced pointer to member). */
-DEFTREECODE (MEMBER_REF, "member_ref", "r", 2)
-
-/* Type conversion operator in C++. TREE_TYPE is type that this
- operator converts to. Operand is expression to be converted. */
-DEFTREECODE (TYPE_EXPR, "type_expr", "e", 1)
-
-/* For CPLUS_NEW_EXPR, operand 0 is function which performs initialization,
- operand 1 is argument list to initialization function,
- and operand 2 is the slot which was allocated for this expression. */
-DEFTREECODE (NEW_EXPR, "nw_expr", "e", 3)
-DEFTREECODE (VEC_NEW_EXPR, "vec_nw_expr", "e", 3)
-
-/* A throw expression. operand 0 is the expression, if there was one,
- else it is NULL_TREE. */
-DEFTREECODE (THROW_EXPR, "throw_expr", "e", 1)
-
-/* Template definition. The following fields have the specified uses,
- although there are other macros in cp-tree.h that should be used for
- accessing this data.
- DECL_ARGUMENTS template parm vector
- DECL_TEMPLATE_INFO template text &c
- DECL_VINDEX list of instantiations already produced;
- only done for functions so far
- For class template:
- DECL_INITIAL associated templates (methods &c)
- DECL_RESULT null
- For non-class templates:
- TREE_TYPE type of object to be constructed
- DECL_RESULT decl for object to be created
- (e.g., FUNCTION_DECL with tmpl parms used)
- */
-DEFTREECODE (TEMPLATE_DECL, "template_decl", "d", 0)
-
-/* Index into a template parameter list. This parameter must be a type.
- Use TYPE_FIELDS to find parmlist and index. */
-DEFTREECODE (TEMPLATE_TYPE_PARM, "template_type_parm", "t", 0)
-
-/* Index into a template parameter list. This parameter must not be a
- type. */
-DEFTREECODE (TEMPLATE_CONST_PARM, "template_const_parm", "c", 2)
-
-/* For uninstantiated parameterized types.
- TYPE_VALUES tree list:
- TREE_PURPOSE template decl
- TREE_VALUE parm vector
- TREE_CHAIN null
- Other useful fields to be defined later. */
-DEFTREECODE (UNINSTANTIATED_P_TYPE, "uninstantiated_p_type", "t", 0)
-
-/* A thunk is a stub function.
-
- Thunks are used to implement multiple inheritance:
- At run-time, such a thunk subtracts THUNK_DELTA (an int, not a tree)
- from the this pointer, and then jumps to DECL_INITIAL
- (which is an ADDR_EXPR whose operand is a FUNCTION_DECL).
-
- Other kinds of thunks may be defined later. */
-DEFTREECODE (THUNK_DECL, "thunk_decl", "d", 0)
-
-/* A namespace declaration. */
-DEFTREECODE (NAMESPACE_DECL, "namespace_decl", "d", 0)
diff --git a/contrib/gcc/fixinc.dgux b/contrib/gcc/fixinc.dgux
deleted file mode 100755
index 422ba5f725fd..000000000000
--- a/contrib/gcc/fixinc.dgux
+++ /dev/null
@@ -1,185 +0,0 @@
-#!/bin/sh
-#
-# modified for dgux by hassey@dg-rtp.dg.com based on
-#
-# fixinc.svr4 written by Ron Guilmette (rfg@ncd.com).
-#
-# This file is part of GNU CC.
-#
-# GNU CC is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# GNU CC is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU CC; see the file COPYING. If not, write to
-# the Free Software Foundation, 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-#
-#
-# See README-fixinc for more information.
-
-# Directory containing the original header files.
-INPUT=${2-${INPUT-/usr/include}}
-
-# Fail if no arg to specify a directory for the output.
-if [ x$1 = x ]
-then echo fixincludes: no output directory specified
-exit 1
-fi
-
-# Directory in which to store the results.
-LIB=${1?"fixincludes: output directory not specified"}
-
-# Make sure it exists.
-if [ ! -d $LIB ]; then
- mkdir $LIB || exit 1
-fi
-
-ORIG_DIR=`pwd`
-
-# Make LIB absolute if it is relative.
-# Don't do this if not necessary, since may screw up automounters.
-case $LIB in
-/*)
- ;;
-*)
- cd $LIB; LIB=`${PWDCMD-pwd}`
- ;;
-esac
-
-echo 'Building fixincludes in ' ${LIB}
-
-# Determine whether this filesystem has symbolic links.
-if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
- rm -f $LIB/ShouldNotExist
- LINKS=true
-else
- LINKS=false
-fi
-
-echo 'Making directories:'
-cd ${INPUT}
-if $LINKS; then
- files=`ls -LR | sed -n s/:$//p`
-else
- files=`find . -type d -print | sed '/^.$/d'`
-fi
-for file in $files; do
- rm -rf $LIB/$file
- if [ ! -d $LIB/$file ]
- then mkdir $LIB/$file
- fi
-done
-
-# treetops gets an alternating list
-# of old directories to copy
-# and the new directories to copy to.
-treetops="${INPUT} ${LIB}"
-
-if $LINKS; then
- echo 'Making internal symbolic directory links'
- for file in $files; do
- dest=`ls -ld $file | sed -n 's/.*-> //p'`
- if [ "$dest" ]; then
- cwd=`pwd`
- # In case $dest is relative, get to $file's dir first.
- cd ${INPUT}
- cd `echo ./$file | sed -n 's&[^/]*$&&p'`
- # Check that the target directory exists.
- # Redirections changed to avoid bug in sh on Ultrix.
- (cd $dest) > /dev/null 2>&1
- if [ $? = 0 ]; then
- cd $dest
- # X gets the dir that the link actually leads to.
- x=`pwd`
- # If link leads back into ${INPUT},
- # make a similar link here.
- if expr $x : "${INPUT}/.*" > /dev/null; then
- # Y gets the actual target dir name, relative to ${INPUT}.
- y=`echo $x | sed -n "s&${INPUT}/&&p"`
- # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
- dots=`echo "$file" |
- sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
- echo $file '->' $dots$y ': Making link'
- rm -fr ${LIB}/$file > /dev/null 2>&1
- ln -s $dots$y ${LIB}/$file > /dev/null 2>&1
- else
- # If the link is to outside ${INPUT},
- # treat this directory as if it actually contained the files.
-# This line used to have $dest instead of $x.
-# $dest seemed to be wrong for links found in subdirectories
-# of ${INPUT}. Does this change break anything?
- treetops="$treetops $x ${LIB}/$file"
- fi
- fi
- cd $cwd
- fi
- done
-fi
-
-# Completely replace <_int_varargs.h> with a file that defines
-# va_list and gnuc_va_list
-
-file=_int_varargs.h
-if [ -r ${INPUT}/$file ]; then
- echo Replacing $file
- cat > ${LIB}/$file << EOF
-/* This file was generated by fixinc.dgux. */
-#ifndef __INT_VARARGS_H
-#define __INT_VARARGS_H
-
-#if defined(__m88k__) && defined (__DGUX__)
-#ifndef __GNUC_VA_LIST
-#define __GNUC_VA_LIST
-typedef struct
-{
- int __va_arg; /* argument number */
- int *__va_stk; /* start of args passed on stack */
- int *__va_reg; /* start of args passed in regs */
-} __gnuc_va_list;
-#endif /* not __GNUC_VA_LIST */
-#endif /* 88k && dgux */
-
-#ifndef _VA_LIST_
-#define _VA_LIST_
-typedef __gnuc_va_list va_list;
-#endif /* _VA_LIST_ */
-
-#endif /* __INT_VARARGS_H */
-
-EOF
- chmod a+r ${LIB}/$file
-fi
-
-echo 'Removing unneeded directories:'
-cd $LIB
-files=`find . -type d -print | sort -r`
-for file in $files; do
- rmdir $LIB/$file > /dev/null 2>&1
-done
-
-if $LINKS; then
- echo 'Making internal symbolic non-directory links'
- cd ${INPUT}
- files=`find . -type l -print`
- for file in $files; do
- dest=`ls -ld $file | sed -n 's/.*-> //p'`
- if expr "$dest" : '[^/].*' > /dev/null; then
- target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
- if [ -f $target ]; then
- ln -s $dest ${LIB}/$file >/dev/null 2>&1
- fi
- fi
- done
-fi
-
-cd ${ORIG_DIR}
-
-exit 0
-
diff --git a/contrib/gcc/fixinc.ptx b/contrib/gcc/fixinc.ptx
deleted file mode 100644
index 93a8f2c5d0e8..000000000000
--- a/contrib/gcc/fixinc.ptx
+++ /dev/null
@@ -1,257 +0,0 @@
-#! /bin/sh
-# Install modified versions of certain ANSI-incompatible
-# native Sequent DYNIX/ptx System V Release 3.2 system include files.
-# Copyright (C) 1994, 1996, 1997 Free Software Foundation, Inc.
-# Contributed by Bill Burton <billb@progress.com>
-# Portions adapted from fixinc.svr4 and fixincludes.
-#
-# This file is part of GNU CC.
-#
-# GNU CC is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# GNU CC is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU CC; see the file COPYING. If not, write to
-# the Free Software Foundation, 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-#
-# This script munges the native include files provided with DYNIX/ptx
-# so as to remove things which are violations of the ANSI C standard.
-# This is done by first running fixinc.svr4 which does most of the
-# work. A few includes have fixes made to them afterwards by this
-# script. Once munged, the resulting new system include files are
-# placed in a directory that GNU C will search *before* searching the
-# /usr/include directory. This script should work properly for most
-# DYNIX/ptx systems. For other types of systems, you should use the
-# `fixincludes' script instead.
-#
-# See README-fixinc for more information.
-
-# Directory containing the original header files.
-INPUT=${2-${INPUT-/usr/include}}
-
-# Fail if no arg to specify a directory for the output.
-if [ x$1 = x ]
-then echo fixincludes: no output directory specified
-exit 1
-fi
-
-# Directory in which to store the results.
-LIB=${1?"fixincludes: output directory not specified"}
-
-# Make sure it exists.
-if [ ! -d $LIB ]; then
- mkdir $LIB || exit 1
-fi
-
-ORIG_DIR=`pwd`
-
-# Make LIB absolute if it is relative.
-# Don't do this if not necessary, since may screw up automounters.
-case $LIB in
-/*)
- ;;
-*)
- LIB=$ORIG_DIR/$LIB
- ;;
-esac
-
-echo 'Running fixinc.svr4'
-# DYNIX/ptx has dirname so this is no problem
-`dirname $0`/fixinc.svr4 $*
-echo 'Finished fixinc.svr4'
-
-echo 'Building fixincludes in ' ${LIB}
-
-# Copied from fixincludes.
-# Don't use or define the name va_list in stdio.h.
-# This is for ANSI and also to interoperate properly with gcc's varargs.h.
-file=stdio.h
-if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
- cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
- chmod +w ${LIB}/$file 2>/dev/null
- chmod a+r ${LIB}/$file 2>/dev/null
-fi
-
-if [ -r ${LIB}/$file ]; then
- echo Fixing $file, use of va_list
- # Arrange for stdio.h to use stdarg.h to define __gnuc_va_list
- (echo "#define __need___va_list"
- echo "#include <stdarg.h>") > ${LIB}/${file}.sed
- # Use __gnuc_va_list in arg types in place of va_list.
- # On 386BSD use __gnuc_va_list instead of _VA_LIST_. We're hoping the
- # trailing parentheses and semicolon save all other systems from this.
- # Define __va_list__ (something harmless and unused) instead of va_list.
- # Don't claim to have defined va_list.
- sed -e 's@ va_list @ __gnuc_va_list @' \
- -e 's@ va_list)@ __gnuc_va_list)@' \
- -e 's@ _VA_LIST_));@ __gnuc_va_list));@' \
- -e 's@ va_list@ __va_list__@' \
- -e 's@\*va_list@*__va_list__@' \
- -e 's@ __va_list)@ __gnuc_va_list)@' \
- -e 's@_NEED___VA_LIST@_NEED___Va_LIST@' \
- -e 's@VA_LIST@DUMMY_VA_LIST@' \
- -e 's@_NEED___Va_LIST@_NEED___VA_LIST@' \
- ${LIB}/$file >> ${LIB}/${file}.sed
-
- rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
- if cmp $file ${LIB}/$file >/dev/null 2>&1; then
- rm -f ${LIB}/$file
- fi
-fi
-
-# In pwd.h, PTX 1.x needs stdio.h included since FILE * was added in a
-# prototype later on in the file.
-file=pwd.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- if grep stdio $file_to_fix > /dev/null; then
- true
- else
- sed -e '/#include <sys\/types\.h>/a\
-\
-#if defined(__STDC__) || defined(__cplusplus)\
-#include <stdio.h>\
-#endif /* __STDC__ */
-' \
- $file_to_fix > ${LIB}/${file}.sed
- rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
- echo Fixed $file_to_fix
- fi
-fi
-
-# Copied from fixincludes.
-# math.h puts the declaration of matherr before the definition
-# of struct exception, so the prototype (added by fixproto) causes havoc.
-file=math.h
-if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
- cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
- chmod +w ${LIB}/$file 2>/dev/null
- chmod a+r ${LIB}/$file 2>/dev/null
-fi
-
-if [ -r ${LIB}/$file ]; then
- echo Fixing $file, matherr declaration
- sed -e '/^struct exception/,$b' \
- -e '/matherr/i\
-struct exception;
-'\
- ${LIB}/$file > ${LIB}/${file}.sed
- rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
- if cmp $file ${LIB}/$file >/dev/null 2>&1; then
- rm -f ${LIB}/$file
- fi
-fi
-
-# In netinet/in.h, the network byte swapping asm functions supported by the
-# native cc compiler on PTX 1.x and 2.x is not supported in gcc. Instead,
-# include <sys/byteorder.h> written out by the fixinc.svr4 script which has
-# these same routines written in an asm format supported by gcc.
-file=netinet/in.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- if grep __GNUC__ $file_to_fix > /dev/null; then
- true
- else
- sed -e '/#define NETSWAP/a\
-\
-#if defined (__GNUC__) || defined (__GNUG__)\
-#include <sys/byteorder.h>\
-#else /* not __GNUC__ */
-' \
- -e '/#endif[ ]*\/\* NETSWAP \*\//i\
-#endif /* not __GNUC__ */
-' \
- $file_to_fix > ${LIB}/${file}.sed
- rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
- echo Fixed $file_to_fix
- fi
-fi
-
-# /usr/include/sys/mc_param.h has an embedded asm for the cpuid instruction
-# on the P5. This is not used by anything else so we ifdef it out.
-file=sys/mc_param.h
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- if grep __GNUC__ $file_to_fix > /dev/null; then
- true
- else
- sed -e '/__asm/,/}/{
-/__asm/i\
-#if !defined (__GNUC__) && !defined (__GNUG__)
-/}/a\
-#endif
-}' \
- $file_to_fix > ${LIB}/${file}.sed
- rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
- echo Fixed $file_to_fix
- fi
-fi
-
-# /usr/include/sys/mc_param.h has an embedded asm for the cpuid instruction
-# on the P5. This is not used by anything else so we ifdef it out.
-file=sys/mc_param.h
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- if grep __GNUC__ $file_to_fix > /dev/null; then
- true
- else
- sed -e '/__asm/,/}/{
-/__asm/i\
-#if !defined (__GNUC__) && !defined (__GNUG__)
-/}/a\
-#endif
-}' \
- $file_to_fix > ${LIB}/${file}.sed
- rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
- echo Fixed $file_to_fix
- fi
-fi
-
-exit 0
-
diff --git a/contrib/gcc/fixinc.sco b/contrib/gcc/fixinc.sco
deleted file mode 100755
index 5caaf7fc3854..000000000000
--- a/contrib/gcc/fixinc.sco
+++ /dev/null
@@ -1,427 +0,0 @@
-#! /bin/sh
-#
-# fixinc.sco -- Install modified versions of SCO system include
-# files.
-#
-# Based on fixinc.svr4 script by Ron Guilmette (rfg@ncd.com) (SCO
-# modifications by Ian Lance Taylor (ian@airs.com)).
-#
-# Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
-#
-# This file is part of GNU CC.
-#
-# GNU CC is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# GNU CC is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU CC; see the file COPYING. If not, write to
-# the Free Software Foundation, 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-#
-# This script munges the native include files provided with SCO
-# 3.2v4 systems so as to provide a reasonable namespace when
-# compiling with gcc. The header files by default do not
-# provide many essential definitions and declarations if
-# __STDC__ is 1. This script modifies the header files to check
-# for __STRICT_ANSI__ being defined instead. Once munged, the
-# resulting new system include files are placed in a directory
-# that GNU C will search *before* searching the /usr/include
-# directory. This script should work properly for most SCO
-# 3.2v4 systems. For other types of systems, you should use the
-# `fixincludes' or the `fixinc.svr4' script instead.
-#
-# See README-fixinc for more information.
-
-# Directory containing the original header files.
-INPUT=${2-${INPUT-/usr/include}}
-
-# Fail if no arg to specify a directory for the output.
-if [ x$1 = x ]
-then echo fixincludes: no output directory specified
-exit 1
-fi
-
-# Directory in which to store the results.
-LIB=${1?"fixincludes: output directory not specified"}
-
-# Make sure it exists.
-if [ ! -d $LIB ]; then
- mkdir $LIB || exit 1
-fi
-
-ORIG_DIR=`pwd`
-
-# Make LIB absolute if it is relative.
-# Don't do this if not necessary, since may screw up automounters.
-case $LIB in
-/*)
- ;;
-*)
- cd $LIB; LIB=`${PWDCMD-pwd}`
- ;;
-esac
-
-echo 'Building fixincludes in ' ${LIB}
-
-# Determine whether this filesystem has symbolic links.
-if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
- rm -f $LIB/ShouldNotExist
- LINKS=true
-else
- LINKS=false
-fi
-
-echo 'Making directories:'
-cd ${INPUT}
-if $LINKS; then
- files=`ls -LR | sed -n s/:$//p`
-else
- files=`find . -type d -print | sed '/^.$/d'`
-fi
-for file in $files; do
- rm -rf $LIB/$file
- if [ ! -d $LIB/$file ]
- then mkdir $LIB/$file
- fi
-done
-
-# treetops gets an alternating list
-# of old directories to copy
-# and the new directories to copy to.
-treetops="${INPUT} ${LIB}"
-
-if $LINKS; then
- echo 'Making internal symbolic directory links'
- for file in $files; do
- dest=`ls -ld $file | sed -n 's/.*-> //p'`
- if [ "$dest" ]; then
- cwd=`pwd`
- # In case $dest is relative, get to $file's dir first.
- cd ${INPUT}
- cd `echo ./$file | sed -n 's&[^/]*$&&p'`
- # Check that the target directory exists.
- # Redirections changed to avoid bug in sh on Ultrix.
- (cd $dest) > /dev/null 2>&1
- if [ $? = 0 ]; then
- cd $dest
- # X gets the dir that the link actually leads to.
- x=`pwd`
- # If link leads back into ${INPUT},
- # make a similar link here.
- if expr $x : "${INPUT}/.*" > /dev/null; then
- # Y gets the actual target dir name, relative to ${INPUT}.
- y=`echo $x | sed -n "s&${INPUT}/&&p"`
- echo $file '->' $y ': Making link'
- rm -fr ${LIB}/$file > /dev/null 2>&1
- ln -s ${LIB}/$y ${LIB}/$file > /dev/null 2>&1
- else
- # If the link is to outside ${INPUT},
- # treat this directory as if it actually contained the files.
-# This line used to have $dest instead of $x.
-# $dest seemed to be wrong for links found in subdirectories
-# of ${INPUT}. Does this change break anything?
- treetops="$treetops $x ${LIB}/$file"
- fi
- fi
- cd $cwd
- fi
- done
-fi
-
-set - $treetops
-while [ $# != 0 ]; do
- # $1 is an old directory to copy, and $2 is the new directory to copy to.
- echo "Finding header files in $1:"
- cd ${INPUT}
- cd $1
- files=`find . -name '*.h' -type f -print`
- echo 'Checking header files:'
- for file in $files; do
- if egrep '!__STDC__' $file >/dev/null; then
- if [ -r $file ]; then
- cp $file $2/$file >/dev/null 2>&1 || echo "Can't copy $file"
- chmod +w $2/$file
- chmod a+r $2/$file
-
-# The following have been removed from the sed command below
-# because it is more useful to leave these things in.
-# The only reason to remove them was for -pedantic,
-# which isn't much of a reason. -- rms.
-# /^[ ]*#[ ]*ident/d
-
- sed -e '
- s/!__STDC__/!defined (__STRICT_ANSI__)/g
- ' $2/$file > $2/$file.sed
- mv $2/$file.sed $2/$file
- if cmp $file $2/$file >/dev/null 2>&1; then
- rm $2/$file
- else
- echo Fixed $file
- fi
- fi
- fi
- done
- shift; shift
-done
-
-# We shouldn't stay in the directory we just copied.
-cd ${INPUT}
-
-# Fix first broken decl of getcwd present on some svr4 systems.
-
-file=stdlib.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- sed -e 's/getcwd(char \{0,\}\*, int)/getcwd(char *, size_t)/' $file_to_fix > /tmp/$base
- if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
- true
- else
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base ${LIB}/$file
- chmod a+r ${LIB}/$file
- fi
- rm -f /tmp/$base
-fi
-
-# Fix second broken decl of getcwd present on some svr4 systems. Also
-# fix the incorrect decl of profil present on some svr4 systems.
-
-file=unistd.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix \
- | sed -e 's/profil(unsigned short \*, unsigned int, unsigned int, unsigned int)/profil(unsigned short *, size_t, int, unsigned)/' > /tmp/$base
- if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
- true
- else
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base ${LIB}/$file
- chmod a+r ${LIB}/$file
- fi
- rm -f /tmp/$base
-fi
-
-# Fix third broken decl of getcwd on SCO. Also fix incorrect decl of
-# link.
-file=prototypes.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix \
- | sed -e 's/const int link(const char \*, char \*)/extern int link(const char *, const char *)/' > /tmp/$base
- if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
- true
- else
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base ${LIB}/$file
- chmod a+r ${LIB}/$file
- fi
- rm -f /tmp/$base
-fi
-
-# Fix an error in this file: the #if says _cplusplus, not the double
-# underscore __cplusplus that it should be
-file=tinfo.h
-if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
- mkdir ${LIB}/rpcsvc 2>/dev/null
- cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
- chmod +w ${LIB}/$file 2>/dev/null
- chmod a+r ${LIB}/$file 2>/dev/null
-fi
-
-if [ -r ${LIB}/$file ]; then
- echo Fixing $file, __cplusplus macro
- sed -e 's/[ ]_cplusplus/ __cplusplus/' ${LIB}/$file > ${LIB}/${file}.sed
- rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
- if cmp $file ${LIB}/$file >/dev/null 2>&1; then
- rm ${LIB}/$file
- fi
-fi
-
-# Fix prototype declaration of utime in sys/times.h. In 3.2v4.0 the
-# const is missing.
-file=sys/times.h
-if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
- cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
- chmod +w ${LIB}/$file 2>/dev/null
- chmod a+r ${LIB}/$file 2>/dev/null
-fi
-
-if [ -r ${LIB}/$file ]; then
- echo Fixing $file, utime prototype
- sed -e 's/(const char \*, struct utimbuf \*);/(const char *, const struct utimbuf *);/' ${LIB}/$file > ${LIB}/${file}.sed
- rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
- if cmp $file ${LIB}/$file >/dev/null 2>&1; then
- rm ${LIB}/$file
- fi
-fi
-
-# This function is borrowed from fixinclude.svr4
-# The OpenServer math.h defines struct exception, which conflicts with
-# the class exception defined in the C++ file std/stdexcept.h. We
-# redefine it to __math_exception. This is not a great fix, but I
-# haven't been able to think of anything better.
-#
-# OpenServer's math.h declares abs as inline int abs... Unfortunately,
-# we blow over that one (with C++ linkage) and stick a new one in stdlib.h
-# with C linkage. So we eat the one out of math.h.
-file=math.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- sed -e '/struct exception/i\
-#ifdef __cplusplus\
-#define exception __math_exception\
-#endif'\
- -e '/struct exception/a\
-#ifdef __cplusplus\
-#undef exception\
-#endif' \
- -e 's@inline int abs(int [a-z][a-z]*) {.*}@extern "C" int abs(int);@' \
- $file_to_fix > /tmp/$base
- if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
- true
- else
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base ${LIB}/$file
- chmod a+r ${LIB}/$file
- fi
- rm -f /tmp/$base
-fi
-
-#
-# Also, the static functions lstat() and fchmod() in <sys/stat.h>
-# cause G++ grief since they're not wrapped in "if __cplusplus".
-# Fix that up now.
-#
-file=sys/stat.h
-if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
- cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
- chmod +w ${LIB}/$file 2>/dev/null
- chmod a+r ${LIB}/$file 2>/dev/null
-fi
-
-if [ -r ${LIB}/$file ]; then
- echo Fixing $file, static definitions not C++-aware.
- sed -e '/^static int[ ]*/i\
-#if __cplusplus\
-extern "C"\
-{\
-#endif /* __cplusplus */ \
-' \
--e '/^}$/a\
-#if __cplusplus\
-}\
-#endif /* __cplusplus */ \
-' ${LIB}/$file > ${LIB}/${file}.sed
- rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
- if cmp $file ${LIB}/$file >/dev/null 2>&1; then
- rm -f ${LIB}/$file
- fi
-fi
-
-# This fix has the regex modified from the from fixinc.wrap
-# Avoid the definition of the bool type in the following files when using
-# g++, since it's now an official type in the C++ language.
-for file in term.h tinfo.h
-do
- if [ -r $INPUT/$file ]; then
- echo Checking $INPUT/$file
- w='[ ]'
- if grep "typedef$w.*char$w.*bool$w*;" $INPUT/$file >/dev/null
- then
- echo Fixed $file
- rm -f $LIB/$file
- cat << __EOF__ >$LIB/$file
-#ifndef _CURSES_H_WRAPPER
-#ifdef __cplusplus
-# define bool __curses_bool_t
-#endif
-#include_next <$file>
-#ifdef __cplusplus
-# undef bool
-#endif
-#define _CURSES_H_WRAPPER
-#endif /* _CURSES_H_WRAPPER */
-__EOF__
- # Define _CURSES_H_WRAPPER at the end of the wrapper, not the start,
- # so that if #include_next gets another instance of the wrapper,
- # this will follow the #include_next chain until we arrive at
- # the real system include file.
- chmod a+r $LIB/$file
- fi
- fi
-done
-
-echo 'Removing unneeded directories:'
-cd $LIB
-files=`find . -type d -print | sort -r`
-for file in $files; do
- rmdir $LIB/$file > /dev/null 2>&1
-done
-
-if $LINKS; then
- echo 'Making internal symbolic non-directory links'
- cd ${INPUT}
- files=`find . -type l -print`
- for file in $files; do
- dest=`ls -ld $file | sed -n 's/.*-> //p'`
- if expr "$dest" : '[^/].*' > /dev/null; then
- target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
- if [ -f $target ]; then
- ln -s $dest ${LIB}/$file >/dev/null 2>&1
- fi
- fi
- done
-fi
-
-exit 0
diff --git a/contrib/gcc/fixinc.svr4 b/contrib/gcc/fixinc.svr4
deleted file mode 100755
index 46e07ce0ac9f..000000000000
--- a/contrib/gcc/fixinc.svr4
+++ /dev/null
@@ -1,1726 +0,0 @@
-#! /bin/sh
-# Install modified versions of certain ANSI-incompatible
-# native System V Release 4 system include files.
-# Copyright (C) 1994, 1996, 1997 Free Software Foundation, Inc.
-# Contributed by Ron Guilmette (rfg@monkeys.com).
-#
-# This file is part of GNU CC.
-#
-# GNU CC is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# GNU CC is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU CC; see the file COPYING. If not, write to
-# the Free Software Foundation, 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-#
-# This script munges the native include files provided with System V
-# Release 4 systems so as to remove things which are violations of the
-# ANSI C standard. Once munged, the resulting new system include files
-# are placed in a directory that GNU C will search *before* searching
-# the /usr/include directory. This script should work properly for most
-# System V Release 4 systems. For other types of systems, you should
-# use the `fixincludes' script instead.
-#
-# See README-fixinc for more information.
-
-# Directory containing the original header files.
-INPUT=${2-${INPUT-/usr/include}}
-
-# Fail if no arg to specify a directory for the output.
-if [ x$1 = x ]
-then echo fixincludes: no output directory specified
-exit 1
-fi
-
-# Directory in which to store the results.
-LIB=${1?"fixincludes: output directory not specified"}
-
-# Make sure it exists.
-if [ ! -d $LIB ]; then
- mkdir $LIB || exit 1
-fi
-
-ORIG_DIR=`pwd`
-
-# Make LIB absolute if it is relative.
-# Don't do this if not necessary, since may screw up automounters.
-case $LIB in
-/*)
- ;;
-*)
- LIB=$ORIG_DIR/$LIB
- ;;
-esac
-
-echo 'Building fixincludes in ' ${LIB}
-
-# Determine whether this filesystem has symbolic links.
-if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
- rm -f $LIB/ShouldNotExist
- LINKS=true
-else
- LINKS=false
-fi
-
-echo 'Making directories:'
-cd ${INPUT}
-if $LINKS; then
- files=`find . -follow -type d -print 2>/dev/null | sed '/^.$/d'`
-else
- files=`find . -type d -print | sed '/^.$/d'`
-fi
-for file in $files; do
- rm -rf $LIB/$file
- if [ ! -d $LIB/$file ]
- then mkdir $LIB/$file
- fi
-done
-
-# treetops gets an alternating list
-# of old directories to copy
-# and the new directories to copy to.
-treetops="${INPUT} ${LIB}"
-
-if $LINKS; then
- echo 'Making internal symbolic directory links'
- for file in $files; do
- dest=`ls -ld $file | sed -n 's/.*-> //p'`
- if [ "$dest" ]; then
- cwd=`pwd`
- # In case $dest is relative, get to $file's dir first.
- cd ${INPUT}
- cd `echo ./$file | sed -n 's&[^/]*$&&p'`
- rwd=`pwd`
- # Check that the target directory exists.
- # Redirections changed to avoid bug in sh on Ultrix.
- (cd $dest) > /dev/null 2>&1
- if [ $? = 0 ]; then
- cd $dest
- # X gets the dir that the link actually leads to.
- x=`pwd`
- # If link leads back into ${INPUT},
- # make a similar link here.
- if expr "$dest" : '[^/][^/]*' >/dev/null && [ ! -h $dest ]; then
- echo $file '->' $dest': Making link'
- rm -fr ${LIB}/$file > /dev/null 2>&1
- ln -s $dest ${LIB}/$file > /dev/null 2>&1
- elif expr $x : "${INPUT}/.*" > /dev/null; then
- # Y gets the actual target dir name, relative to ${INPUT}.
- y=`echo $x | sed -n "s&${INPUT}/&&p"`
- # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
- dots=`echo "$file" |
- sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
- echo $file '->' $dots$y ': Making link'
- rm -fr ${LIB}/$file > /dev/null 2>&1
- ln -s $dots$y ${LIB}/$file > /dev/null 2>&1
- elif expr $x : "${rwd}/.*" > /dev/null; then
- # Y gets the actual target dir name, relative to the directory where the link is.
- y=`echo $x | sed -n "s&${rwd}/&&p"`
- # DOTS is the relative path from ${LIB}/$file's dir back to ${LIB}.
- dots=`echo "$file" |
- sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
- echo $file '->' $dots$y ': Making link'
- rm -fr ${LIB}/$file > /dev/null 2>&1
- ln -s $dots$y ${LIB}/$file > /dev/null 2>&1
- else
- # If the link is to outside ${INPUT},
- # treat this directory as if it actually contained the files.
-# This line used to have $dest instead of $x.
-# $dest seemed to be wrong for links found in subdirectories
-# of ${INPUT}. Does this change break anything?
- treetops="$treetops $x ${LIB}/$file"
- fi
- fi
- cd $cwd
- fi
- done
-fi
-
-set - $treetops
-while [ $# != 0 ]; do
- # $1 is an old directory to copy, and $2 is the new directory to copy to.
- echo "Finding header files in $1:"
- cd ${INPUT}
- cd $1
- files=`find . -name '*.h' -type f -print`
- echo 'Checking header files:'
- for file in $files; do
- if [ -r $file ]; then
- cp $file $2/$file >/dev/null 2>&1 || echo "Can't copy $file"
- chmod +w $2/$file
- chmod a+r $2/$file
-
-# The following have been removed from the sed command below
-# because it is more useful to leave these things in.
-# The only reason to remove them was for -pedantic,
-# which isn't much of a reason. -- rms.
-# /^[ ]*#[ ]*ident/d
-
-# This code makes Solaris SCSI fail, because it changes the
-# alignment within some critical structures. See <sys/scsi/impl/commands.h>.
-# s/u_char\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
-# Disable these also, since they probably aren't safe either.
-# s/u_short\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
-# s/ushort\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
-# s/evcm_t\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*[0-9][0-9]*\)/u_int\1/
-# s/Pbyte\([ ][ ]*[a-zA-Z0-9_][a-zA-Z0-9_]*[ ]*:[ ]*SEQSIZ\)/unsigned int\1/
-
-# The change of u_char, etc, to u_int
-# applies to bit fields.
- sed -e '
- s%^\([ ]*#[ ]*else\)[ ]*/[^*].*%\1%
- s%^\([ ]*#[ ]*else\)[ ]*[^/ ].*%\1%
- s%^\([ ]*#[ ]*endif\)[ ]*/[^*].*%\1%
- s%^\([ ]*#[ ]*endif\)[ ]*[^/ ].*%\1%
- s/#lint(on)/defined(lint)/g
- s/#lint(off)/!defined(lint)/g
- s/#machine(\([^)]*\))/defined(__\1__)/g
- s/#system(\([^)]*\))/defined(__\1__)/g
- s/#cpu(\([^)]*\))/defined(__\1__)/g
- /#[a-z]*if.*[ (]m68k/ s/\([^_]\)m68k/\1__m68k__/g
- /#[a-z]*if.*[ (]__i386\([^_]\)/ s/__i386/__i386__/g
- /#[a-z]*if.*[ (]i386/ s/\([^_]\)i386/\1__i386__/g
- /#[a-z]*if.*[ (!]__i860\([^_]\)/ s/__i860/__i860__/g
- /#[a-z]*if.*[ (!]i860/ s/\([^_]\)i860/\1__i860__/g
- /#[a-z]*if.*[ (]sparc/ s/\([^_]\)sparc/\1__sparc__/g
- /#[a-z]*if.*[ (]mc68000/ s/\([^_]\)mc68000/\1__mc68000__/g
- /#[a-z]*if.*[ (]vax/ s/\([^_]\)vax/\1__vax__/g
- /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)\([^a-z0-9_]\)/\1__\2__\3/g
- /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)$/\1__\2__/g
- /#[a-z]*if.*[ (]ns32000/ s/\([^_]\)ns32000/\1__ns32000__/g
- /#[a-z]*if.*[ (]pyr/ s/\([^_]\)pyr/\1__pyr__/g
- /#[a-z]*if.*[ (]is68k/ s/\([^_]\)is68k/\1__is68k__/g
- s/__STDC__[ ][ ]*==[ ][ ]*0/!defined (__STRICT_ANSI__)/g
- s/__STDC__[ ][ ]*==[ ][ ]*1/defined (__STRICT_ANSI__)/g
- s/__STDC__[ ][ ]*!=[ ][ ]*0/defined (__STRICT_ANSI__)/g
- s/__STDC__[ ][ ]*!=[ ][ ]*1/!defined (__STRICT_ANSI__)/g
- s/__STDC__ - 0 == 0/!defined (__STRICT_ANSI__)/g
- s/__STDC__ - 0 == 1/defined (__STRICT_ANSI__)/g
- /^typedef[ ][ ]*[unsigned ]*long[ ][ ]*[u_]*longlong_t;/s/long/long long/
- ' $2/$file > $2/$file.sed
- mv $2/$file.sed $2/$file
- if cmp $file $2/$file >/dev/null 2>&1; then
- rm $2/$file
- else
- echo Fixed $file
- fi
- fi
- done
- shift; shift
-done
-
-# Install the proper definition of the three standard types in header files
-# that they come from.
-for file in sys/types.h stdlib.h sys/stdtypes.h stddef.h memory.h unistd.h; do
- if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
- cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
- chmod +w ${LIB}/$file 2>/dev/null
- chmod a+r ${LIB}/$file 2>/dev/null
- fi
-
- if [ -r ${LIB}/$file ]; then
- echo Fixing size_t, ptrdiff_t and wchar_t in $file
- sed \
- -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/i\
-#ifndef __SIZE_TYPE__\
-#define __SIZE_TYPE__ long unsigned int\
-#endif
-' \
- -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]size_t/typedef __SIZE_TYPE__ size_t/' \
- -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/i\
-#ifndef __PTRDIFF_TYPE__\
-#define __PTRDIFF_TYPE__ long int\
-#endif
-' \
- -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]ptrdiff_t/typedef __PTRDIFF_TYPE__ ptrdiff_t/' \
- -e '/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/i\
-#ifndef __WCHAR_TYPE__\
-#define __WCHAR_TYPE__ int\
-#endif
-' \
- -e 's/typedef[ ][ ]*[a-z_][ a-z_]*[ ]wchar_t/typedef __WCHAR_TYPE__ wchar_t/' \
- ${LIB}/$file > ${LIB}/${file}.sed
- rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
- if cmp $file ${LIB}/$file >/dev/null 2>&1; then
- rm ${LIB}/$file
- fi
- fi
-done
-
-# Fix first broken decl of getcwd present on some svr4 systems.
-
-file=stdlib.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix > /tmp/$base
- if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
- true
- else
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base ${LIB}/$file
- chmod a+r ${LIB}/$file
- fi
- rm -f /tmp/$base
-fi
-
-# Fix second broken decl of getcwd present on some svr4 systems. Also
-# fix the incorrect decl of profil present on some svr4 systems.
-
-file=unistd.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix \
- | sed -e 's/profil(unsigned short \*, unsigned int, unsigned int, unsigned int)/profil(unsigned short *, size_t, int, unsigned)/' > /tmp/$base
- if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
- true
- else
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base ${LIB}/$file
- chmod a+r ${LIB}/$file
- fi
- rm -f /tmp/$base
-fi
-
-# Fix the definition of NULL in <sys/param.h> so that it is conditional
-# and so that it is correct for both C and C++.
-
-file=sys/param.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- cp $file_to_fix /tmp/$base
- chmod +w /tmp/$base
- chmod a+r /tmp/$base
- sed -e '/^#define[ ]*NULL[ ]*0$/c\
-#ifndef NULL\
-#ifdef __cplusplus\
-#define __NULL_TYPE\
-#else /* !defined(__cplusplus) */\
-#define __NULL_TYPE (void *)\
-#endif /* !defined(__cplusplus) */\
-#define NULL (__NULL_TYPE 0)\
-#endif /* !defined(NULL) */' /tmp/$base > /tmp/$base.sed
- if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
- true
- else
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base.sed ${LIB}/$file
- chmod a+r ${LIB}/$file
- fi
- rm -f /tmp/$base /tmp/$base.sed
-fi
-
-# Likewise fix the definition of NULL in <stdio.h> so that it is conditional
-# and so that it is correct for both C and C++.
-
-file=stdio.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- cp $file_to_fix /tmp/$base
- chmod +w /tmp/$base
- sed -e '/^#define[ ]*NULL[ ]*0$/c\
-#ifdef __cplusplus\
-#define __NULL_TYPE\
-#else /* !defined(__cplusplus) */\
-#define __NULL_TYPE (void *)\
-#endif /* !defined(__cplusplus) */\
-#define NULL (__NULL_TYPE 0)' /tmp/$base > /tmp/$base.sed
- if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
- true
- else
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base.sed ${LIB}/$file
- chmod a+r ${LIB}/$file
- fi
- rm -f /tmp/$base /tmp/$base.sed
-fi
-
-# Likewise fix the definition of NULL in <dbm.h> so that it is conditional
-# and so that it is correct for both C and C++.
-
-file=dbm.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- cp $file_to_fix /tmp/$base
- chmod +w /tmp/$base
- sed -e '/^#define[ ]*NULL[ ]*((char \*) 0)$/c\
-#ifndef NULL\
-#ifdef __cplusplus\
-#define __NULL_TYPE\
-#else /* !defined(__cplusplus) */\
-#define __NULL_TYPE (void *)\
-#endif /* !defined(__cplusplus) */\
-#define NULL (__NULL_TYPE 0)\
-#endif /* !defined(NULL) */' /tmp/$base > /tmp/$base.sed
- if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
- true
- else
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base.sed ${LIB}/$file
- chmod a+r ${LIB}/$file
- fi
- rm -f /tmp/$base /tmp/$base.sed
-fi
-
-# Add a prototyped declaration of mmap to <sys/mman.h>.
-
-file=sys/mman.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- cp $file_to_fix /tmp/$base
- chmod +w /tmp/$base
- sed -e '/^extern caddr_t mmap();$/c\
-#ifdef __STDC__\
-extern caddr_t mmap (caddr_t, size_t, int, int, int, off_t);\
-#else /* !defined(__STDC__) */\
-extern caddr_t mmap ();\
-#endif /* !defined(__STDC__) */' /tmp/$base > /tmp/$base.sed
- if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
- true
- else
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base.sed ${LIB}/$file
- chmod a+r ${LIB}/$file
- fi
- rm -f /tmp/$base /tmp/$base.sed
-fi
-
-# Fix declarations of `ftw' and `nftw' in <ftw.h>. On some/most SVR4 systems
-# the file <ftw.h> contains extern declarations of these functions followed
-# by explicitly `static' definitions of these functions... and that's not
-# allowed according to ANSI C. (Note however that on Solaris, this header
-# file glitch has been pre-fixed by Sun. In the Solaris version of <ftw.h>
-# there are no static definitions of any function so we don't need to do
-# any of this stuff when on Solaris.
-
-file=ftw.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if test -z "$file_to_fix" || grep 'define ftw' $file_to_fix > /dev/null; then
-# Either we have no <ftw.h> file at all, or else we have the pre-fixed Solaris
-# one. Either way, we don't have to do anything.
- true
-else
- echo Checking $file_to_fix
- cp $file_to_fix /tmp/$base
- chmod +w /tmp/$base
- sed -e '/^extern int ftw(const/i\
-#if !defined(_STYPES)\
-static\
-#else\
-extern\
-#endif
-'\
- -e 's/extern \(int ftw(const.*\)$/\1/' \
- -e '/^extern int nftw/i\
-#if defined(_STYPES)\
-static\
-#else\
-extern\
-#endif
-'\
- -e 's/extern \(int nftw.*\)$/\1/' \
- -e '/^extern int ftw(),/c\
-#if !defined(_STYPES)\
-static\
-#else\
-extern\
-#endif\
- int ftw();\
-#if defined(_STYPES)\
-static\
-#else\
-extern\
-#endif\
- int nftw();' /tmp/$base > /tmp/$base.sed
- if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
- true
- else
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base.sed ${LIB}/$file
- chmod a+r ${LIB}/$file
- fi
- rm -f /tmp/$base /tmp/$base.sed
-fi
-
-# Avoid the definition of the bool type in the Solaris 2.x curses.h when using
-# g++, since it's now an official type in the C++ language.
-file=curses.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- cp $file_to_fix /tmp/$base
- chmod +w /tmp/$base
- sed -e 's,^typedef[ ]char[ ]bool;$,#ifndef __cplusplus\
-typedef char bool;\
-#endif /* !defined __cplusplus */,' /tmp/$base > /tmp/$base.sed
- if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
- true
- else
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base.sed ${LIB}/$file
- chmod a+r ${LIB}/$file
- fi
- rm -f /tmp/$base /tmp/$base.sed
-fi
-
-# Add a `static' declaration of `getrnge' into <regexp.h>.
-
-# Don't do this if there is already a `static void getrnge' declaration
-# present, since this would cause a redeclaration error. Solaris 2.x has
-# such a declaration.
-
-file=regexp.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- if grep "static void getrnge" $file_to_fix > /dev/null; then
- true
- else
- cp $file_to_fix /tmp/$base
- chmod +w /tmp/$base
- sed -e '/^static int[ ]*size;/c\
-static int size ;\
-\
-static int getrnge ();' /tmp/$base > /tmp/$base.sed
- if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
- true
- else
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base.sed ${LIB}/$file
- chmod a+r ${LIB}/$file
- fi
- fi
- rm -f /tmp/$base /tmp/$base.sed
-fi
-
-# Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
-# that is visible to any ANSI compiler using this include. Simply
-# delete the lines that #define some string functions to internal forms.
-
-file=string.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- cp $file_to_fix /tmp/$base
- chmod +w /tmp/$base
- sed -e '/#define.*__std_hdr_/d' /tmp/$base > /tmp/$base.sed
- if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
- true
- else
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base.sed ${LIB}/$file
- chmod a+r ${LIB}/$file
- fi
- rm -f /tmp/$base /tmp/$base.sed
-fi
-
-# Delete any #defines of `__i386' which may be present in <ieeefp.h>. They
-# tend to conflict with the compiler's own definition of this symbol. (We
-# will use the compiler's definition.)
-# Likewise __sparc, for Solaris, and __i860, and a few others
-# (guessing it is necessary for all of them).
-
-file=ieeefp.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- cp $file_to_fix /tmp/$base
- chmod +w /tmp/$base
- sed -e '/#define[ ]*__i386 /d' -e '/#define[ ]*__sparc /d' \
- -e '/#define[ ]*__i860 /d' -e '/#define[ ]*__m88k /d' \
- -e '/#define[ ]*__mips /d' -e '/#define[ ]*__m68k /d' \
- /tmp/$base > /tmp/$base.sed
- if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
- true
- else
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base.sed ${LIB}/$file
- chmod a+r ${LIB}/$file
- fi
- rm -f /tmp/$base /tmp/$base.sed
-fi
-
-# Add a #define of _SIGACTION_ into <sys/signal.h>.
-# Also fix types of SIG_DFL, SIG_ERR, SIG_IGN, and SIG_HOLD.
-
-file=sys/signal.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- cp $file_to_fix /tmp/$base
- chmod +w /tmp/$base
- sed -e '/^struct sigaction {/c\
-#define _SIGACTION_\
-struct sigaction {' \
- -e '1,$s/(void *(\*)())/(void (*)(int))/' /tmp/$base > /tmp/$base.sed
- if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
- true
- else
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base.sed ${LIB}/$file
- chmod a+r ${LIB}/$file
- fi
- rm -f /tmp/$base /tmp/$base.sed
-fi
-
-# Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>.
-
-file=sys/mkdev.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- cp $file_to_fix /tmp/$base
- chmod +w /tmp/$base
- sed -e '/^dev_t makedev(const/c\
-static dev_t makedev(const major_t, const minor_t);' \
- -e '/^dev_t makedev()/c\
-static dev_t makedev();' \
- -e '/^major_t major(const/c\
-static major_t major(const dev_t);' \
- -e '/^major_t major()/c\
-static major_t major();' \
- -e '/^minor_t minor(const/c\
-static minor_t minor(const dev_t);' \
- -e '/^minor_t minor()/c\
-static minor_t minor();' /tmp/$base > /tmp/$base.sed
- if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
- true
- else
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base.sed ${LIB}/$file
- chmod a+r ${LIB}/$file
- fi
- rm -f /tmp/$base /tmp/$base.sed
-fi
-
-# Fix reference to NMSZ in <sys/adv.h>.
-
-file=sys/adv.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- sed 's/\[NMSZ\]/\[RFS_NMSZ\]/g' $file_to_fix > /tmp/$base
- if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
- true
- else
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base ${LIB}/$file
- chmod a+r ${LIB}/$file
- fi
- rm -f /tmp/$base
-fi
-
-# Fix reference to NC_NPI_RAW in <sys/netcspace.h>. Also fix types of
-# array initializers.
-
-file=sys/netcspace.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- sed 's/NC_NPI_RAW/NC_TPI_RAW/g' $file_to_fix \
- | sed 's/NC_/(unsigned long) NC_/' > /tmp/$base
- if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
- true
- else
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base ${LIB}/$file
- chmod a+r ${LIB}/$file
- fi
- rm -f /tmp/$base
-fi
-
-# Conditionalize all of <fs/rfs/rf_cache.h> on _KERNEL being defined.
-
-file=fs/rfs/rf_cache.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- if grep _KERNEL $file_to_fix > /dev/null; then
- true
- else
- echo '#ifdef _KERNEL' > /tmp/$base
- cat $file_to_fix >> /tmp/$base
- echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base ${LIB}/$file
- chmod a+r ${LIB}/$file
- rm -f /tmp/$base
- fi
-fi
-
-# Conditionalize all of <sys/erec.h> on _KERNEL being defined.
-
-file=sys/erec.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- if grep _KERNEL $file_to_fix > /dev/null; then
- true
- else
- echo '#ifdef _KERNEL' > /tmp/$base
- cat $file_to_fix >> /tmp/$base
- echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base ${LIB}/$file
- chmod a+r ${LIB}/$file
- rm -f /tmp/$base
- fi
-fi
-
-# Conditionalize all of <sys/err.h> on _KERNEL being defined.
-
-file=sys/err.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- if grep _KERNEL $file_to_fix > /dev/null; then
- true
- else
- echo '#ifdef _KERNEL' > /tmp/$base
- cat $file_to_fix >> /tmp/$base
- echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base ${LIB}/$file
- chmod a+r ${LIB}/$file
- rm -f /tmp/$base
- fi
-fi
-
-# Conditionalize all of <sys/char.h> on _KERNEL being defined.
-
-file=sys/char.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- if grep _KERNEL $file_to_fix > /dev/null; then
- true
- else
- echo '#ifdef _KERNEL' > /tmp/$base
- cat $file_to_fix >> /tmp/$base
- echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base ${LIB}/$file
- chmod a+r ${LIB}/$file
- rm -f /tmp/$base
- fi
-fi
-
-# Conditionalize all of <sys/getpages.h> on _KERNEL being defined.
-
-file=sys/getpages.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- if grep _KERNEL $file_to_fix > /dev/null; then
- true
- else
- echo '#ifdef _KERNEL' > /tmp/$base
- cat $file_to_fix >> /tmp/$base
- echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base ${LIB}/$file
- chmod a+r ${LIB}/$file
- rm -f /tmp/$base
- fi
-fi
-
-# Conditionalize all of <sys/map.h> on _KERNEL being defined.
-
-file=sys/map.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- if grep _KERNEL $file_to_fix > /dev/null; then
- true
- else
- echo '#ifdef _KERNEL' > /tmp/$base
- cat $file_to_fix >> /tmp/$base
- echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base ${LIB}/$file
- chmod a+r ${LIB}/$file
- rm -f /tmp/$base
- fi
-fi
-
-# Conditionalize all of <sys/cmn_err.h> on _KERNEL being defined.
-
-file=sys/cmn_err.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- if grep _KERNEL $file_to_fix > /dev/null; then
- true
- else
- echo '#ifdef _KERNEL' > /tmp/$base
- cat $file_to_fix >> /tmp/$base
- echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base ${LIB}/$file
- chmod a+r ${LIB}/$file
- rm -f /tmp/$base
- fi
-fi
-
-# Conditionalize all of <sys/kdebugger.h> on _KERNEL being defined.
-
-file=sys/kdebugger.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- if grep _KERNEL $file_to_fix > /dev/null; then
- true
- else
- echo '#ifdef _KERNEL' > /tmp/$base
- cat $file_to_fix >> /tmp/$base
- echo '#endif /* defined(_KERNEL) */' >> /tmp/$base
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base ${LIB}/$file
- chmod a+r ${LIB}/$file
- rm -f /tmp/$base
- fi
-fi
-
-# Conditionalize some of <netinet/in.h> on _KERNEL being defined.
-# This has been taken out because it breaks on some versions of
-# DYNIX/ptx, and it does not seem to do much good on any system.
-# file=netinet/in.h
-# base=`basename $file`
-# if [ -r ${LIB}/$file ]; then
-# file_to_fix=${LIB}/$file
-# else
-# if [ -r ${INPUT}/$file ]; then
-# file_to_fix=${INPUT}/$file
-# else
-# file_to_fix=""
-# fi
-# fi
-# if [ \! -z "$file_to_fix" ]; then
-# echo Checking $file_to_fix
-# if grep _KERNEL $file_to_fix > /dev/null; then
-# true
-# else
-# sed -e '/#ifdef INKERNEL/i\
-# #ifdef _KERNEL
-# ' \
-# -e '/#endif[ ]*\/\* INKERNEL \*\//a\
-# #endif /* _KERNEL */
-# ' \
-# $file_to_fix > ${LIB}/${file}.sed
-# rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
-# echo Fixed $file_to_fix
-# fi
-# fi
-
-# Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__.
-
-file=sys/endian.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- if grep __GNUC__ $file_to_fix > /dev/null; then
- true
- else
- sed -e '/# ifdef __STDC__/i\
-# if !defined (__GNUC__) && !defined (__GNUG__)
-' \
- -e '/# include <sys\/byteorder.h>/s/ / /'\
- -e '/# include <sys\/byteorder.h>/i\
-# endif /* !defined (__GNUC__) && !defined (__GNUG__) */
-'\
- $file_to_fix > ${LIB}/${file}.sed
- rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
- echo Fixed $file_to_fix
- fi
-fi
-
-# Commented out because tmcconne@sedona.intel.com says we don't clearly need it
-# and the text in types.h is not erroneous.
-## In sys/types.h, don't name the enum for booleans.
-#
-#file=sys/types.h
-#base=`basename $file`
-#if [ -r ${LIB}/$file ]; then
-# file_to_fix=${LIB}/$file
-#else
-# if [ -r ${INPUT}/$file ]; then
-# file_to_fix=${INPUT}/$file
-# else
-# file_to_fix=""
-# fi
-#fi
-#if [ \! -z "$file_to_fix" ]; then
-# echo Checking $file_to_fix
-# if grep "enum boolean" $file_to_fix > /dev/null; then
-# sed -e 's/enum boolean/enum/' ${LIB}/$file > ${LIB}/${file}.sed
-# rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file
-# echo Fixed $file_to_fix
-# else
-# true
-# fi
-#fi
-
-# Remove useless extern keyword from struct forward declarations in
-# <sys/stream.h> and <sys/strsubr.h>
-
-file=sys/stream.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- sed -e '
- s/extern struct stdata;/struct stdata;/g
- s/extern struct strevent;/struct strevent;/g
- ' $file_to_fix > /tmp/$base
- if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
- true
- else
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base ${LIB}/$file
- chmod a+r ${LIB}/$file
- fi
- rm -f /tmp/$base
-fi
-
-file=sys/strsubr.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- sed -e '
- s/extern struct strbuf;/struct strbuf;/g
- s/extern struct uio;/struct uio;/g
- s/extern struct thread;/struct thread;/g
- s/extern struct proc;/struct proc;/g
- ' $file_to_fix > /tmp/$base
- if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
- true
- else
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base ${LIB}/$file
- chmod a+r ${LIB}/$file
- fi
- rm -f /tmp/$base
-fi
-
-# Put storage class at start of decl, to avoid warning.
-file=rpc/types.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- sed -e '
- s/const extern/extern const/g
- ' $file_to_fix > /tmp/$base
- if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
- true
- else
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base ${LIB}/$file
- chmod a+r ${LIB}/$file
- fi
- rm -f /tmp/$base
-fi
-
-# Convert functions to prototype form, and fix arg names in <sys/stat.h>.
-
-file=sys/stat.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- cp $file_to_fix /tmp/$base
- chmod +w /tmp/$base
- sed -e '/^stat([ ]*[^c]/{
-N
-N
-s/(.*)\n/( /
-s/;\n/, /
-s/;$/)/
-}' \
- -e '/^lstat([ ]*[^c]/{
-N
-N
-s/(.*)\n/( /
-s/;\n/, /
-s/;$/)/
-}' \
- -e '/^fstat([ ]*[^i]/{
-N
-N
-s/(.*)\n/( /
-s/;\n/, /
-s/;$/)/
-}' \
- -e '/^mknod([ ]*[^c]/{
-N
-N
-N
-s/(.*)\n/( /
-s/;\n/, /g
-s/;$/)/
-}' \
- -e '1,$s/\([^A-Za-z]\)path\([^A-Za-z]\)/\1__path\2/g' \
- -e '1,$s/\([^A-Za-z]\)buf\([^A-Za-z]\)/\1__buf\2/g' \
- -e '1,$s/\([^A-Za-z]\)fd\([^A-Za-z]\)/\1__fd\2/g' \
- -e '1,$s/ret\([^u]\)/__ret\1/g' \
- -e '1,$s/\([^_]\)mode\([^_]\)/\1__mode\2/g' \
- -e '1,$s/\([^_r]\)dev\([^_]\)/\1__dev\2/g' /tmp/$base > /tmp/$base.sed
- if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then \
- true
- else
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base.sed ${LIB}/$file
- chmod a+r ${LIB}/$file
- fi
- rm -f /tmp/$base /tmp/$base.sed
-fi
-
-# Sony NEWSOS 5.0 does not support the complete ANSI C standard.
-
-if [ -x /bin/sony ]; then
- if /bin/sony; then
-
- # Change <stdio.h> to not define __filbuf, __flsbuf, and __iob
-
- file=stdio.h
- base=`basename $file`
- if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
- else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
- fi
- if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- cp $file_to_fix /tmp/$base
- chmod +w /tmp/$base
- sed -e '
- s/__filbuf/_filbuf/g
- s/__flsbuf/_flsbuf/g
- s/__iob/_iob/g
- ' /tmp/$base > /tmp/$base.sed
- mv /tmp/$base.sed /tmp/$base
- if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then
- true
- else
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base ${LIB}/$file
- chmod a+r ${LIB}/$file
- fi
- rm -f /tmp/$base
- fi
-
- # Change <ctype.h> to not define __ctype
-
- file=ctype.h
- base=`basename $file`
- if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
- else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
- fi
- if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- cp $file_to_fix /tmp/$base
- chmod +w /tmp/$base
- sed -e '
- s/__ctype/_ctype/g
- ' /tmp/$base > /tmp/$base.sed
- mv /tmp/$base.sed /tmp/$base
- if cmp $file_to_fix /tmp/$base.sed >/dev/null 2>&1; then
- true
- else
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base ${LIB}/$file
- chmod a+r ${LIB}/$file
- fi
- rm -f /tmp/$base
- fi
- fi
-fi
-
-# In limits.h, put #ifndefs around things that are supposed to be defined
-# in float.h to avoid redefinition errors if float.h is included first.
-# Solaris 2.1 has this problem.
-
-file=limits.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- sed -e '/[ ]FLT_MIN[ ]/i\
-#ifndef FLT_MIN
-'\
- -e '/[ ]FLT_MIN[ ]/a\
-#endif
-'\
- -e '/[ ]FLT_MAX[ ]/i\
-#ifndef FLT_MAX
-'\
- -e '/[ ]FLT_MAX[ ]/a\
-#endif
-'\
- -e '/[ ]FLT_DIG[ ]/i\
-#ifndef FLT_DIG
-'\
- -e '/[ ]FLT_DIG[ ]/a\
-#endif
-'\
- -e '/[ ]DBL_MIN[ ]/i\
-#ifndef DBL_MIN
-'\
- -e '/[ ]DBL_MIN[ ]/a\
-#endif
-'\
- -e '/[ ]DBL_MAX[ ]/i\
-#ifndef DBL_MAX
-'\
- -e '/[ ]DBL_MAX[ ]/a\
-#endif
-'\
- -e '/[ ]DBL_DIG[ ]/i\
-#ifndef DBL_DIG
-'\
- -e '/[ ]DBL_DIG[ ]/a\
-#endif
-' $file_to_fix > /tmp/$base
- if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
- true
- else
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base ${LIB}/$file
- chmod a+r ${LIB}/$file
- fi
- rm -f /tmp/$base
-fi
-
-# Completely replace <sys/varargs.h> with a file that includes gcc's
-# stdarg.h or varargs.h files as appropriate.
-
-file=sys/varargs.h
-if [ -r ${INPUT}/$file ]; then
- echo Replacing $file
- cat > ${LIB}/$file << EOF
-/* This file was generated by fixincludes. */
-#ifndef _SYS_VARARGS_H
-#define _SYS_VARARGS_H
-
-#ifdef __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-#endif /* _SYS_VARARGS_H */
-EOF
- chmod a+r ${LIB}/$file
-fi
-
-# In math.h, put #ifndefs around things that might be defined in a gcc
-# specific math-*.h file.
-
-file=math.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- sed -e '/define[ ]HUGE_VAL[ ]/i\
-#ifndef HUGE_VAL
-'\
- -e '/define[ ]HUGE_VAL[ ]/a\
-#endif
-' $file_to_fix > /tmp/$base
- if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
- true
- else
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base ${LIB}/$file
- chmod a+r ${LIB}/$file
- fi
- rm -f /tmp/$base
-fi
-
-# Solaris math.h and floatingpoint.h define __P without protection,
-# which conflicts with the fixproto definition. The fixproto
-# definition and the Solaris definition are used the same way.
-for file in math.h floatingpoint.h; do
- base=`basename $file`
- if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
- else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
- fi
- if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- sed -e '/^#define[ ]*__P/i\
-#ifndef __P
-'\
- -e '/^#define[ ]*__P/a\
-#endif
-' $file_to_fix > /tmp/$base
- if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
- true
- else
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base ${LIB}/$file
- chmod a+r ${LIB}/$file
- fi
- rm -f /tmp/$base
- fi
-done
-
-# The Solaris math.h defines struct exception, which conflicts with
-# the class exception defined in the C++ file std/stdexcept.h. We
-# redefine it to __math_exception. This is not a great fix, but I
-# haven't been able to think of anything better.
-file=math.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- sed -e '/struct exception/i\
-#ifdef __cplusplus\
-#define exception __math_exception\
-#endif'\
- -e '/struct exception/a\
-#ifdef __cplusplus\
-#undef exception\
-#endif' $file_to_fix > /tmp/$base
- if cmp $file_to_fix /tmp/$base >/dev/null 2>&1; then \
- true
- else
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base ${LIB}/$file
- chmod a+r ${LIB}/$file
- fi
- rm -f /tmp/$base
-fi
-
-echo 'Removing unneeded directories:'
-cd $LIB
-files=`find . -type d -print | sort -r`
-for file in $files; do
- rmdir $LIB/$file > /dev/null 2>&1
-done
-
-if $LINKS; then
- echo 'Making internal symbolic non-directory links'
- cd ${INPUT}
- files=`find . -type l -print`
- for file in $files; do
- dest=`ls -ld $file | sed -n 's/.*-> //p'`
- if expr "$dest" : '[^/].*' > /dev/null; then
- target=${LIB}/`echo $file | sed "s|[^/]*\$|$dest|"`
- if [ -f $target ]; then
- ln -s $dest ${LIB}/$file >/dev/null 2>&1
- fi
- fi
- done
-fi
-
-cd ${ORIG_DIR}
-
-echo 'Replacing <sys/byteorder.h>'
-if [ \! -d $LIB/sys ]; then
- mkdir $LIB/sys
-fi
-rm -f ${LIB}/sys/byteorder.h
-cat <<'__EOF__' >${LIB}/sys/byteorder.h
-#ifndef _SYS_BYTEORDER_H
-#define _SYS_BYTEORDER_H
-
-/* Functions to convert `short' and `long' quantities from host byte order
- to (internet) network byte order (i.e. big-endian).
-
- Written by Ron Guilmette (rfg@ncd.com).
-
- This isn't actually used by GCC. It is installed by fixinc.svr4.
-
- For big-endian machines these functions are essentially no-ops.
-
- For little-endian machines, we define the functions using specialized
- asm sequences in cases where doing so yields better code (e.g. i386). */
-
-#if !defined (__GNUC__) && !defined (__GNUG__)
-#error You lose! This file is only useful with GNU compilers.
-#endif
-
-#ifndef __BYTE_ORDER__
-/* Byte order defines. These are as defined on UnixWare 1.1, but with
- double underscores added at the front and back. */
-#define __LITTLE_ENDIAN__ 1234
-#define __BIG_ENDIAN__ 4321
-#define __PDP_ENDIAN__ 3412
-#endif
-
-#ifdef __STDC__
-static __inline__ unsigned long htonl (unsigned long);
-static __inline__ unsigned short htons (unsigned int);
-static __inline__ unsigned long ntohl (unsigned long);
-static __inline__ unsigned short ntohs (unsigned int);
-#endif /* defined (__STDC__) */
-
-#if defined (__i386__)
-
-#ifndef __BYTE_ORDER__
-#define __BYTE_ORDER__ __LITTLE_ENDIAN__
-#endif
-
-/* Convert a host long to a network long. */
-
-/* We must use a new-style function definition, so that this will also
- be valid for C++. */
-static __inline__ unsigned long
-htonl (unsigned long __arg)
-{
- register unsigned long __result;
-
- __asm__ ("xchg%B0 %b0,%h0\n\
- ror%L0 $16,%0\n\
- xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
- return __result;
-}
-
-/* Convert a host short to a network short. */
-
-static __inline__ unsigned short
-htons (unsigned int __arg)
-{
- register unsigned short __result;
-
- __asm__ ("xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg));
- return __result;
-}
-
-#elif ((defined (__i860__) && !defined (__i860_big_endian__)) \
- || defined (__ns32k__) || defined (__vax__) \
- || defined (__spur__) || defined (__arm__))
-
-#ifndef __BYTE_ORDER__
-#define __BYTE_ORDER__ __LITTLE_ENDIAN__
-#endif
-
-/* For other little-endian machines, using C code is just as efficient as
- using assembly code. */
-
-/* Convert a host long to a network long. */
-
-static __inline__ unsigned long
-htonl (unsigned long __arg)
-{
- register unsigned long __result;
-
- __result = (__arg >> 24) & 0x000000ff;
- __result |= (__arg >> 8) & 0x0000ff00;
- __result |= (__arg << 8) & 0x00ff0000;
- __result |= (__arg << 24) & 0xff000000;
- return __result;
-}
-
-/* Convert a host short to a network short. */
-
-static __inline__ unsigned short
-htons (unsigned int __arg)
-{
- register unsigned short __result;
-
- __result = (__arg << 8) & 0xff00;
- __result |= (__arg >> 8) & 0x00ff;
- return __result;
-}
-
-#else /* must be a big-endian machine */
-
-#ifndef __BYTE_ORDER__
-#define __BYTE_ORDER__ __BIG_ENDIAN__
-#endif
-
-/* Convert a host long to a network long. */
-
-static __inline__ unsigned long
-htonl (unsigned long __arg)
-{
- return __arg;
-}
-
-/* Convert a host short to a network short. */
-
-static __inline__ unsigned short
-htons (unsigned int __arg)
-{
- return __arg;
-}
-
-#endif /* big-endian */
-
-/* Convert a network long to a host long. */
-
-static __inline__ unsigned long
-ntohl (unsigned long __arg)
-{
- return htonl (__arg);
-}
-
-/* Convert a network short to a host short. */
-
-static __inline__ unsigned short
-ntohs (unsigned int __arg)
-{
- return htons (__arg);
-}
-
-__EOF__
-
-if [ -r ${INPUT}/sys/byteorder.h ]; then
- if grep BYTE_ORDER ${INPUT}/sys/byteorder.h >/dev/null 2>/dev/null; then
- cat <<'__EOF__' >>${LIB}/sys/byteorder.h
-#ifndef BYTE_ORDER
-#define LITTLE_ENDIAN __LITTLE_ENDIAN__
-#define BIG_ENDIAN __BIG_ENDIAN__
-#define PDP_ENDIAN __PDP_ENDIAN__
-#define BYTE_ORDER __BYTE_ORDER__
-#endif
-
-__EOF__
- fi
-fi
-
-cat <<'__EOF__' >>${LIB}/sys/byteorder.h
-#endif /* !defined (_SYS_BYTEORDER_H) */
-__EOF__
-
-chmod a+r ${LIB}/sys/byteorder.h
-
-exit 0
-
diff --git a/contrib/gcc/fixinc.winnt b/contrib/gcc/fixinc.winnt
deleted file mode 100644
index 915ac723b85e..000000000000
--- a/contrib/gcc/fixinc.winnt
+++ /dev/null
@@ -1,232 +0,0 @@
-#! sh
-#
-# fixinc.winnt -- Install modified versions of Windows NT system include
-# files.
-#
-# Based on fixinc.sco script by Ian Lance Taylor (ian@airs.com)).
-# Modifications by Douglas Rupp (drupp@cs.washington.edu)
-#
-# This file is part of GNU CC.
-#
-# GNU CC is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# GNU CC is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU CC; see the file COPYING. If not, write to
-# the Free Software Foundation, 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-#
-# This script munges the native include files provided with Windows NT
-# 3.5 SDK systems so as to provide a reasonable namespace when
-# compiling with gcc. The header files by default do not
-# provide many essential definitions and declarations if
-# __STDC__ is 1. This script modifies the header files to check
-# for __STRICT_ANSI__ being defined instead. Once munged, the
-# resulting new system include files are placed in a directory
-# that GNU C will search *before* searching the Include
-# directory.
-#
-# See README-fixinc for more information.
-
-ORIG_DIR=`pwd`
-
-# Directory containing the original header files.
-cd $2; SEDFILE=`${PWDCMD-pwd}`/fixinc-nt.sed
-echo $SEDFILE
-if [ ! -f $SEDFILE ]
-then echo fixincludes: sed script 'fixinc-nt.sed' not found
-exit 1
-fi
-echo 'Using sed script: ' ${SEDFILE}
-
-cd $ORIG_DIR
-
-INPUT=${INCLUDE}
-echo 'Using the Include environment variable to find header files to fix'
-
-# Fail if no arg to specify a directory for the output.
-if [ x$1 = x ]
-then echo fixincludes: no output directory specified
-exit 1
-fi
-
-# Directory in which to store the results.
-LIB=${1?"fixincludes: output directory not specified"}
-
-# Make sure it exists.
-if [ ! -d $LIB ]; then
- mkdir $LIB || exit 1
-fi
-
-ORIG_DIR=`pwd`
-
-# Make LIB absolute if it is relative.
-# Don't do this if not necessary, since may screw up automounters.
-case $LIB in
-/*)
- ;;
-*)
- cd $LIB; LIB=`${PWDCMD-pwd}`
- ;;
-esac
-
-echo 'Building fixincludes in ' ${LIB}
-
-# Determine whether this filesystem has symbolic links.
-if ln -s X $LIB/ShouldNotExist 2>NUL; then
- rm -f $LIB/ShouldNotExist
- LINKS=true
-else
- LINKS=false
-fi
-
-echo 'Making directories:'
-cd ${INPUT}
-if $LINKS; then
- files=`ls -LR | sed -n s/:$//p`
-else
- files=`find . -type d -print | sed '/^.$/d'`
-fi
-for file in $files; do
- rm -rf $LIB/$file
- if [ ! -d $LIB/$file ]
- then mkdir $LIB/$file
- fi
-done
-
-# treetops gets an alternating list
-# of old directories to copy
-# and the new directories to copy to.
-treetops="${INPUT} ${LIB}"
-
-set - $treetops
-while [ $# != 0 ]; do
- # $1 is an old directory to copy, and $2 is the new directory to copy to.
- echo "Finding header files in $1:"
- cd ${INPUT}
- cd $1
- files=`find . -name '*.[hH]' -type f -print`
- echo 'Checking header files:'
- for file in $files; do
- echo $file
- if egrep "!__STDC__" $file >NUL; then
- if [ -r $file ]; then
- cp $file $2/$file >NUL 2>&1 || echo "Can't copy $file"
- chmod +w,a+r $2/$file
-
-# The following have been removed from the sed command below
-# because it is more useful to leave these things in.
-# The only reason to remove them was for -pedantic,
-# which isn't much of a reason. -- rms.
-# /^[ ]*#[ ]*ident/d
-
- sed -e '
- s/!__STDC__/!defined (__STRICT_ANSI__)/g
- ' $2/$file > $2/$file.sed
- mv $2/$file.sed $2/$file
- if cmp $file $2/$file >NUL 2>&1; then
- rm $2/$file
- else
- echo Fixed $file
- fi
- fi
- fi
- done
- shift; shift
-done
-
-# Fix first broken decl of getcwd present on some svr4 systems.
-
-file=direct.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- sed -e 's/getcwd(char \*, int)/getcwd(char *, size_t)/' $file_to_fix > /tmp/$base
- if cmp $file_to_fix /tmp/$base >NUL 2>&1; then \
- true
- else
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base ${LIB}/$file
- chmod a+r ${LIB}/$file
- fi
- rm -f /tmp/$base
-fi
-
-file=rpcndr.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- sed -e 's/Format\[\]/Format\[1\]/' $file_to_fix > /tmp/$base
- if cmp $file_to_fix /tmp/$base >NUL 2>&1; then \
- true
- else
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base ${LIB}/$file
- chmod a+r ${LIB}/$file
- fi
- rm -f /tmp/$base
-fi
-
-file=winnt.h
-base=`basename $file`
-if [ -r ${LIB}/$file ]; then
- file_to_fix=${LIB}/$file
-else
- if [ -r ${INPUT}/$file ]; then
- file_to_fix=${INPUT}/$file
- else
- file_to_fix=""
- fi
-fi
-if [ \! -z "$file_to_fix" ]; then
- echo Checking $file_to_fix
- sed -e '
- s/^#if !defined (__cplusplus)/#if 0/
- s/^#define DECLSPEC_IMPORT __declspec(dllimport)/#define DECLSPEC_IMPORT/
- ' $file_to_fix > /tmp/$base
- if cmp $file_to_fix /tmp/$base >NUL 2>&1; then \
- true
- else
- echo Fixed $file_to_fix
- rm -f ${LIB}/$file
- cp /tmp/$base ${LIB}/$file
- chmod a+r ${LIB}/$file
- fi
- rm -f /tmp/$base
-fi
-
-echo 'Removing unneeded directories:'
-cd $LIB
-files=`find . -type d -print | sort -r`
-for file in $files; do
- rmdir $LIB/$file > NUL 2>&1
-done
-
-exit 0
diff --git a/contrib/gcc/install.sh b/contrib/gcc/install.sh
deleted file mode 100755
index 58719246f040..000000000000
--- a/contrib/gcc/install.sh
+++ /dev/null
@@ -1,238 +0,0 @@
-#! /bin/sh
-#
-# install - install a program, script, or datafile
-# This comes from X11R5.
-#
-# Calling this script install-sh is preferred over install.sh, to prevent
-# `make' implicit rules from creating a file called install from it
-# when there is no Makefile.
-#
-# This script is compatible with the BSD install script, but was written
-# from scratch.
-#
-
-
-# set DOITPROG to echo to test this script
-
-# Don't use :- since 4.3BSD and earlier shells don't like it.
-doit="${DOITPROG-}"
-
-
-# put in absolute paths if you don't have them in your path; or use env. vars.
-
-mvprog="${MVPROG-mv}"
-cpprog="${CPPROG-cp}"
-chmodprog="${CHMODPROG-chmod}"
-chownprog="${CHOWNPROG-chown}"
-chgrpprog="${CHGRPPROG-chgrp}"
-stripprog="${STRIPPROG-strip}"
-rmprog="${RMPROG-rm}"
-mkdirprog="${MKDIRPROG-mkdir}"
-
-transformbasename=""
-transform_arg=""
-instcmd="$mvprog"
-chmodcmd="$chmodprog 0755"
-chowncmd=""
-chgrpcmd=""
-stripcmd=""
-rmcmd="$rmprog -f"
-mvcmd="$mvprog"
-src=""
-dst=""
-dir_arg=""
-
-while [ x"$1" != x ]; do
- case $1 in
- -c) instcmd="$cpprog"
- shift
- continue;;
-
- -d) dir_arg=true
- shift
- continue;;
-
- -m) chmodcmd="$chmodprog $2"
- shift
- shift
- continue;;
-
- -o) chowncmd="$chownprog $2"
- shift
- shift
- continue;;
-
- -g) chgrpcmd="$chgrpprog $2"
- shift
- shift
- continue;;
-
- -s) stripcmd="$stripprog"
- shift
- continue;;
-
- -t=*) transformarg=`echo $1 | sed 's/-t=//'`
- shift
- continue;;
-
- -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
- shift
- continue;;
-
- *) if [ x"$src" = x ]
- then
- src=$1
- else
- # this colon is to work around a 386BSD /bin/sh bug
- :
- dst=$1
- fi
- shift
- continue;;
- esac
-done
-
-if [ x"$src" = x ]
-then
- echo "install: no input file specified"
- exit 1
-else
- true
-fi
-
-if [ x"$dir_arg" != x ]; then
- dst=$src
- src=""
-
- if [ -d $dst ]; then
- instcmd=:
- else
- instcmd=mkdir
- fi
-else
-
-# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
-# might cause directories to be created, which would be especially bad
-# if $src (and thus $dsttmp) contains '*'.
-
- if [ -f $src -o -d $src ]
- then
- true
- else
- echo "install: $src does not exist"
- exit 1
- fi
-
- if [ x"$dst" = x ]
- then
- echo "install: no destination specified"
- exit 1
- else
- true
- fi
-
-# If destination is a directory, append the input filename; if your system
-# does not like double slashes in filenames, you may need to add some logic
-
- if [ -d $dst ]
- then
- dst="$dst"/`basename $src`
- else
- true
- fi
-fi
-
-## this sed command emulates the dirname command
-dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
-
-# Make sure that the destination directory exists.
-# this part is taken from Noah Friedman's mkinstalldirs script
-
-# Skip lots of stat calls in the usual case.
-if [ ! -d "$dstdir" ]; then
-defaultIFS='
-'
-IFS="${IFS-${defaultIFS}}"
-
-oIFS="${IFS}"
-# Some sh's can't handle IFS=/ for some reason.
-IFS='%'
-set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
-IFS="${oIFS}"
-
-pathcomp=''
-
-while [ $# -ne 0 ] ; do
- pathcomp="${pathcomp}${1}"
- shift
-
- if [ ! -d "${pathcomp}" ] ;
- then
- $mkdirprog "${pathcomp}"
- else
- true
- fi
-
- pathcomp="${pathcomp}/"
-done
-fi
-
-if [ x"$dir_arg" != x ]
-then
- $doit $instcmd $dst &&
-
- if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
- if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
- if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
- if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
-else
-
-# If we're going to rename the final executable, determine the name now.
-
- if [ x"$transformarg" = x ]
- then
- dstfile=`basename $dst`
- else
- dstfile=`basename $dst $transformbasename |
- sed $transformarg`$transformbasename
- fi
-
-# don't allow the sed command to completely eliminate the filename
-
- if [ x"$dstfile" = x ]
- then
- dstfile=`basename $dst`
- else
- true
- fi
-
-# Make a temp file name in the proper directory.
-
- dsttmp=$dstdir/#inst.$$#
-
-# Move or copy the file name to the temp name
-
- $doit $instcmd $src $dsttmp &&
-
- trap "rm -f ${dsttmp}" 0 &&
-
-# and set any options; do chmod last to preserve setuid bits
-
-# If any of these fail, we abort the whole thing. If we want to
-# ignore errors from any of these, just make sure not to ignore
-# errors from the above "$doit $instcmd $src $dsttmp" command.
-
- if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
- if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
- if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
- if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
-
-# Now rename the file to the real destination.
-
- $doit $rmcmd -f $dstdir/$dstfile &&
- $doit $mvcmd $dsttmp $dstdir/$dstfile
-
-fi &&
-
-
-exit 0
diff --git a/contrib/gcc/modemap.def b/contrib/gcc/modemap.def
deleted file mode 100644
index 753ca54d7627..000000000000
--- a/contrib/gcc/modemap.def
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Bytecode specific machine mode info for GNU C-compiler.
- Copyright (C) 1993 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-/* Map mode to signed, unsigned typecodes, bytecode to push const,
- to load, to store */
-DEF_MODEMAP(QImode, QIcode, QUcode, constQI, loadQI, storeQI)
-DEF_MODEMAP(HImode, HIcode, HUcode, constHI, loadHI, storeHI)
-DEF_MODEMAP(VOIDmode, SIcode, SUcode, constSI, loadSI, storeSI)
-DEF_MODEMAP(SImode, SIcode, SUcode, constSI, loadSI, storeSI)
-DEF_MODEMAP(DImode, DIcode, DUcode, constDI, loadDI, storeDI)
-DEF_MODEMAP(PSImode, Pcode, Pcode, constP, loadP, storeP)
-DEF_MODEMAP(BLKmode, Pcode, Pcode, constP, loadP, neverneverland)
-DEF_MODEMAP(SFmode, SFcode, SFcode, constSF, loadSF, storeSF)
-DEF_MODEMAP(DFmode, DFcode, DFcode, constDF, loadDF, storeDF)
diff --git a/contrib/gcc/objc-act.c b/contrib/gcc/objc-act.c
deleted file mode 100644
index 951f46909215..000000000000
--- a/contrib/gcc/objc-act.c
+++ /dev/null
@@ -1,8268 +0,0 @@
-/* Implement classes and message passing for Objective C.
- Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
- Contributed by Steve Naroff.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-/* Purpose: This module implements the Objective-C 4.0 language.
-
- compatibility issues (with the Stepstone translator):
-
- - does not recognize the following 3.3 constructs.
- @requires, @classes, @messages, = (...)
- - methods with variable arguments must conform to ANSI standard.
- - tagged structure definitions that appear in BOTH the interface
- and implementation are not allowed.
- - public/private: all instance variables are public within the
- context of the implementation...I consider this to be a bug in
- the translator.
- - statically allocated objects are not supported. the user will
- receive an error if this service is requested.
-
- code generation `options':
-
- - OBJC_INT_SELECTORS */
-
-#include <stdio.h>
-#include "config.h"
-#include "tree.h"
-#include "c-tree.h"
-#include "c-lex.h"
-#include "flags.h"
-#include "objc-act.h"
-#include "input.h"
-#include "function.h"
-
-
-/* This is the default way of generating a method name. */
-/* I am not sure it is really correct.
- Perhaps there's a danger that it will make name conflicts
- if method names contain underscores. -- rms. */
-#ifndef OBJC_GEN_METHOD_LABEL
-#define OBJC_GEN_METHOD_LABEL(BUF, IS_INST, CLASS_NAME, CAT_NAME, SEL_NAME, NUM) \
- do { \
- char *temp; \
- sprintf ((BUF), "_%s_%s_%s_%s", \
- ((IS_INST) ? "i" : "c"), \
- (CLASS_NAME), \
- ((CAT_NAME)? (CAT_NAME) : ""), \
- (SEL_NAME)); \
- for (temp = (BUF); *temp; temp++) \
- if (*temp == ':') *temp = '_'; \
- } while (0)
-#endif
-
-/* These need specifying. */
-#ifndef OBJC_FORWARDING_STACK_OFFSET
-#define OBJC_FORWARDING_STACK_OFFSET 0
-#endif
-
-#ifndef OBJC_FORWARDING_MIN_OFFSET
-#define OBJC_FORWARDING_MIN_OFFSET 0
-#endif
-
-/* Define the special tree codes that we use. */
-
-/* Table indexed by tree code giving a string containing a character
- classifying the tree code. Possibilities are
- t, d, s, c, r, <, 1 and 2. See objc-tree.def for details. */
-
-#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
-
-char *objc_tree_code_type[] = {
- "x",
-#include "objc-tree.def"
-};
-#undef DEFTREECODE
-
-/* Table indexed by tree code giving number of expression
- operands beyond the fixed part of the node structure.
- Not used for types or decls. */
-
-#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
-
-int objc_tree_code_length[] = {
- 0,
-#include "objc-tree.def"
-};
-#undef DEFTREECODE
-
-/* Names of tree components.
- Used for printing out the tree and error messages. */
-#define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
-
-char *objc_tree_code_name[] = {
- "@@dummy",
-#include "objc-tree.def"
-};
-#undef DEFTREECODE
-
-/* Set up for use of obstacks. */
-
-#include "obstack.h"
-
-#define obstack_chunk_alloc xmalloc
-#define obstack_chunk_free free
-
-/* This obstack is used to accumulate the encoding of a data type. */
-static struct obstack util_obstack;
-/* This points to the beginning of obstack contents,
- so we can free the whole contents. */
-char *util_firstobj;
-
-/* List of classes with list of their static instances. */
-static tree objc_static_instances;
-
-/* The declaration of the array administrating the static instances. */
-static tree static_instances_decl;
-
-/* for encode_method_def */
-#include "rtl.h"
-#include "c-parse.h"
-
-#define OBJC_VERSION (flag_next_runtime ? 5 : 7)
-#define PROTOCOL_VERSION 2
-
-#define OBJC_ENCODE_INLINE_DEFS 0
-#define OBJC_ENCODE_DONT_INLINE_DEFS 1
-
-/*** Private Interface (procedures) ***/
-
-/* Used by compile_file. */
-
-static void init_objc PROTO((void));
-static void finish_objc PROTO((void));
-
-/* Code generation. */
-
-static void synth_module_prologue PROTO((void));
-static tree build_constructor PROTO((tree, tree));
-static char *build_module_descriptor PROTO((void));
-static tree init_module_descriptor PROTO((tree));
-static tree build_objc_method_call PROTO((int, tree, tree,
- tree, tree, tree));
-static void generate_strings PROTO((void));
-static tree get_proto_encoding PROTO((tree));
-static void build_selector_translation_table PROTO((void));
-static tree build_ivar_chain PROTO((tree, int));
-
-static tree objc_add_static_instance PROTO((tree, tree));
-
-static tree build_ivar_template PROTO((void));
-static tree build_method_template PROTO((void));
-static tree build_private_template PROTO((tree));
-static void build_class_template PROTO((void));
-static void build_selector_template PROTO((void));
-static void build_category_template PROTO((void));
-static tree build_super_template PROTO((void));
-static tree build_category_initializer PROTO((tree, tree, tree,
- tree, tree, tree));
-static tree build_protocol_initializer PROTO((tree, tree, tree,
- tree, tree));
-
-static void synth_forward_declarations PROTO((void));
-static void generate_ivar_lists PROTO((void));
-static void generate_dispatch_tables PROTO((void));
-static void generate_shared_structures PROTO((void));
-static tree generate_protocol_list PROTO((tree));
-static void generate_forward_declaration_to_string_table PROTO((void));
-static void build_protocol_reference PROTO((tree));
-
-static tree init_selector PROTO((int));
-static tree build_keyword_selector PROTO((tree));
-static tree synth_id_with_class_suffix PROTO((char *, tree));
-
-/* From expr.c */
-extern int apply_args_register_offset PROTO((int));
-
-/* Misc. bookkeeping */
-
-typedef struct hashed_entry *hash;
-typedef struct hashed_attribute *attr;
-
-struct hashed_attribute
-{
- attr next;
- tree value;
-};
-struct hashed_entry
-{
- attr list;
- hash next;
- tree key;
-};
-
-static void hash_init PROTO((void));
-static void hash_enter PROTO((hash *, tree));
-static hash hash_lookup PROTO((hash *, tree));
-static void hash_add_attr PROTO((hash, tree));
-static tree lookup_method PROTO((tree, tree));
-static tree lookup_instance_method_static PROTO((tree, tree));
-static tree lookup_class_method_static PROTO((tree, tree));
-static tree add_class PROTO((tree));
-static void add_category PROTO((tree, tree));
-
-enum string_section
-{
- class_names, /* class, category, protocol, module names */
- meth_var_names, /* method and variable names */
- meth_var_types /* method and variable type descriptors */
-};
-
-static tree add_objc_string PROTO((tree,
- enum string_section));
-static tree build_objc_string_decl PROTO((tree,
- enum string_section));
-static tree build_selector_reference_decl PROTO((tree));
-
-/* Protocol additions. */
-
-static tree add_protocol PROTO((tree));
-static tree lookup_protocol PROTO((tree));
-static tree lookup_and_install_protocols PROTO((tree));
-
-/* Type encoding. */
-
-static void encode_type_qualifiers PROTO((tree));
-static void encode_pointer PROTO((tree, int, int));
-static void encode_array PROTO((tree, int, int));
-static void encode_aggregate PROTO((tree, int, int));
-static void encode_bitfield PROTO((int, int));
-static void encode_type PROTO((tree, int, int));
-static void encode_field_decl PROTO((tree, int, int));
-
-static void really_start_method PROTO((tree, tree));
-static int comp_method_with_proto PROTO((tree, tree));
-static int comp_proto_with_proto PROTO((tree, tree));
-static tree get_arg_type_list PROTO((tree, int, int));
-static tree expr_last PROTO((tree));
-
-/* Utilities for debugging and error diagnostics. */
-
-static void warn_with_method PROTO((char *, int, tree));
-static void error_with_ivar PROTO((char *, tree, tree));
-static char *gen_method_decl PROTO((tree, char *));
-static char *gen_declaration PROTO((tree, char *));
-static char *gen_declarator PROTO((tree, char *, char *));
-static int is_complex_decl PROTO((tree));
-static void adorn_decl PROTO((tree, char *));
-static void dump_interface PROTO((FILE *, tree));
-
-/* Everything else. */
-
-static void objc_fatal PROTO((void));
-static tree define_decl PROTO((tree, tree));
-static tree lookup_method_in_protocol_list PROTO((tree, tree, int));
-static tree lookup_protocol_in_reflist PROTO((tree, tree));
-static tree create_builtin_decl PROTO((enum tree_code,
- tree, char *));
-static tree my_build_string PROTO((int, char *));
-static void build_objc_symtab_template PROTO((void));
-static tree init_def_list PROTO((tree));
-static tree init_objc_symtab PROTO((tree));
-static void forward_declare_categories PROTO((void));
-static void generate_objc_symtab_decl PROTO((void));
-static tree build_selector PROTO((tree));
-static tree build_msg_pool_reference PROTO((int));
-static tree build_typed_selector_reference PROTO((tree, tree));
-static tree build_selector_reference PROTO((tree));
-static tree build_class_reference_decl PROTO((tree));
-static void add_class_reference PROTO((tree));
-static tree objc_copy_list PROTO((tree, tree *));
-static tree build_protocol_template PROTO((void));
-static tree build_descriptor_table_initializer PROTO((tree, tree));
-static tree build_method_prototype_list_template PROTO((tree, int));
-static tree build_method_prototype_template PROTO((void));
-static int forwarding_offset PROTO((tree));
-static tree encode_method_prototype PROTO((tree, tree));
-static tree generate_descriptor_table PROTO((tree, char *, int, tree, tree));
-static void generate_method_descriptors PROTO((tree));
-static tree build_tmp_function_decl PROTO((void));
-static void hack_method_prototype PROTO((tree, tree));
-static void generate_protocol_references PROTO((tree));
-static void generate_protocols PROTO((void));
-static void check_ivars PROTO((tree, tree));
-static tree build_ivar_list_template PROTO((tree, int));
-static tree build_method_list_template PROTO((tree, int));
-static tree build_ivar_list_initializer PROTO((tree, tree));
-static tree generate_ivars_list PROTO((tree, char *,
- int, tree));
-static tree build_dispatch_table_initializer PROTO((tree, tree));
-static tree generate_dispatch_table PROTO((tree, char *,
- int, tree));
-static tree build_shared_structure_initializer PROTO((tree, tree, tree, tree,
- tree, int, tree, tree,
- tree));
-static void generate_category PROTO((tree));
-static int is_objc_type_qualifier PROTO((tree));
-static tree adjust_type_for_id_default PROTO((tree));
-static tree check_duplicates PROTO((hash));
-static tree receiver_is_class_object PROTO((tree));
-static int check_methods PROTO((tree, tree, int));
-static int conforms_to_protocol PROTO((tree, tree));
-static void check_protocols PROTO((tree, char *, char *));
-static tree encode_method_def PROTO((tree));
-static void gen_declspecs PROTO((tree, char *, int));
-static void generate_classref_translation_entry PROTO((tree));
-static void handle_class_ref PROTO((tree));
-
-/*** Private Interface (data) ***/
-
-/* Reserved tag definitions. */
-
-#define TYPE_ID "id"
-#define TAG_OBJECT "objc_object"
-#define TAG_CLASS "objc_class"
-#define TAG_SUPER "objc_super"
-#define TAG_SELECTOR "objc_selector"
-
-#define UTAG_CLASS "_objc_class"
-#define UTAG_IVAR "_objc_ivar"
-#define UTAG_IVAR_LIST "_objc_ivar_list"
-#define UTAG_METHOD "_objc_method"
-#define UTAG_METHOD_LIST "_objc_method_list"
-#define UTAG_CATEGORY "_objc_category"
-#define UTAG_MODULE "_objc_module"
-#define UTAG_STATICS "_objc_statics"
-#define UTAG_SYMTAB "_objc_symtab"
-#define UTAG_SUPER "_objc_super"
-#define UTAG_SELECTOR "_objc_selector"
-
-#define UTAG_PROTOCOL "_objc_protocol"
-#define UTAG_PROTOCOL_LIST "_objc_protocol_list"
-#define UTAG_METHOD_PROTOTYPE "_objc_method_prototype"
-#define UTAG_METHOD_PROTOTYPE_LIST "_objc__method_prototype_list"
-
-#define STRING_OBJECT_CLASS_NAME "NXConstantString"
-#define PROTOCOL_OBJECT_CLASS_NAME "Protocol"
-
-static char *TAG_GETCLASS;
-static char *TAG_GETMETACLASS;
-static char *TAG_MSGSEND;
-static char *TAG_MSGSENDSUPER;
-static char *TAG_EXECCLASS;
-
-/* Set by `continue_class' and checked by `is_public'. */
-
-#define TREE_STATIC_TEMPLATE(record_type) (TREE_PUBLIC (record_type))
-#define TYPED_OBJECT(type) \
- (TREE_CODE (type) == RECORD_TYPE && TREE_STATIC_TEMPLATE (type))
-
-/* Some commonly used instances of "identifier_node". */
-
-static tree self_id, ucmd_id;
-static tree unused_list;
-
-static tree self_decl, umsg_decl, umsg_super_decl;
-static tree objc_get_class_decl, objc_get_meta_class_decl;
-
-static tree super_type, selector_type, id_type, objc_class_type;
-static tree instance_type, protocol_type;
-
-/* Type checking macros. */
-
-#define IS_ID(TYPE) \
- (TYPE_MAIN_VARIANT (TYPE) == TYPE_MAIN_VARIANT (id_type))
-#define IS_PROTOCOL_QUALIFIED_ID(TYPE) \
- (IS_ID (TYPE) && TYPE_PROTOCOL_LIST (TYPE))
-#define IS_SUPER(TYPE) \
- (super_type && TYPE_MAIN_VARIANT (TYPE) == TYPE_MAIN_VARIANT (super_type))
-
-static tree class_chain = NULL_TREE;
-static tree alias_chain = NULL_TREE;
-static tree interface_chain = NULL_TREE;
-static tree protocol_chain = NULL_TREE;
-
-/* Chains to manage selectors that are referenced and defined in the module. */
-
-static tree cls_ref_chain = NULL_TREE; /* Classes referenced. */
-static tree sel_ref_chain = NULL_TREE; /* Selectors referenced. */
-
-/* Chains to manage uniquing of strings. */
-
-static tree class_names_chain = NULL_TREE;
-static tree meth_var_names_chain = NULL_TREE;
-static tree meth_var_types_chain = NULL_TREE;
-
-/* Hash tables to manage the global pool of method prototypes. */
-
-static hash *nst_method_hash_list = 0;
-static hash *cls_method_hash_list = 0;
-
-/* Backend data declarations. */
-
-static tree UOBJC_SYMBOLS_decl;
-static tree UOBJC_INSTANCE_VARIABLES_decl, UOBJC_CLASS_VARIABLES_decl;
-static tree UOBJC_INSTANCE_METHODS_decl, UOBJC_CLASS_METHODS_decl;
-static tree UOBJC_CLASS_decl, UOBJC_METACLASS_decl;
-static tree UOBJC_SELECTOR_TABLE_decl;
-static tree UOBJC_MODULES_decl;
-static tree UOBJC_STRINGS_decl;
-
-/* The following are used when compiling a class implementation.
- implementation_template will normally be an interface, however if
- none exists this will be equal to implementation_context...it is
- set in start_class. */
-
-static tree implementation_context = NULL_TREE;
-static tree implementation_template = NULL_TREE;
-
-struct imp_entry
-{
- struct imp_entry *next;
- tree imp_context;
- tree imp_template;
- tree class_decl; /* _OBJC_CLASS_<my_name>; */
- tree meta_decl; /* _OBJC_METACLASS_<my_name>; */
-};
-
-static void handle_impent PROTO((struct imp_entry *));
-
-static struct imp_entry *imp_list = 0;
-static int imp_count = 0; /* `@implementation' */
-static int cat_count = 0; /* `@category' */
-
-static tree objc_class_template, objc_category_template, uprivate_record;
-static tree objc_protocol_template, objc_selector_template;
-static tree ucls_super_ref, uucls_super_ref;
-
-static tree objc_method_template, objc_ivar_template;
-static tree objc_symtab_template, objc_module_template;
-static tree objc_super_template, objc_object_reference;
-
-static tree objc_object_id, objc_class_id, objc_id_id;
-static tree constant_string_id;
-static tree constant_string_type;
-static tree UOBJC_SUPER_decl;
-
-static tree method_context = NULL_TREE;
-static int method_slot = 0; /* Used by start_method_def, */
-
-#define BUFSIZE 1024
-
-static char *errbuf; /* Buffer for error diagnostics */
-
-/* Data imported from tree.c. */
-
-extern enum debug_info_type write_symbols;
-
-/* Data imported from toplev.c. */
-
-extern char *dump_base_name;
-
-/* Generate code for GNU or NeXT runtime environment. */
-
-#ifdef NEXT_OBJC_RUNTIME
-int flag_next_runtime = 1;
-#else
-int flag_next_runtime = 0;
-#endif
-
-int flag_typed_selectors;
-
-/* Open and close the file for outputting class declarations, if requested. */
-
-int flag_gen_declaration = 0;
-
-FILE *gen_declaration_file;
-
-/* Warn if multiple methods are seen for the same selector, but with
- different argument types. */
-
-int warn_selector = 0;
-
-/* Warn if methods required by a protocol are not implemented in the
- class adopting it. When turned off, methods inherited to that
- class are also considered implemented */
-
-int flag_warn_protocol = 1;
-
-/* Tells "encode_pointer/encode_aggregate" whether we are generating
- type descriptors for instance variables (as opposed to methods).
- Type descriptors for instance variables contain more information
- than methods (for static typing and embedded structures). This
- was added to support features being planned for dbkit2. */
-
-static int generating_instance_variables = 0;
-
-void
-lang_init ()
-{
- /* The beginning of the file is a new line; check for #.
- With luck, we discover the real source file's name from that
- and put it in input_filename. */
- ungetc (check_newline (), finput);
-
- /* The line number can be -1 if we had -g3 and the input file
- had a directive specifying line 0. But we want predefined
- functions to have a line number of 0, not -1. */
- if (lineno == -1)
- lineno = 0;
-
- /* If gen_declaration desired, open the output file. */
- if (flag_gen_declaration)
- {
- int dump_base_name_length = strlen (dump_base_name);
- register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
- strcpy (dumpname, dump_base_name);
- strcat (dumpname, ".decl");
- gen_declaration_file = fopen (dumpname, "w");
- if (gen_declaration_file == 0)
- pfatal_with_name (dumpname);
- }
-
- if (flag_next_runtime)
- {
- TAG_GETCLASS = "objc_getClass";
- TAG_GETMETACLASS = "objc_getMetaClass";
- TAG_MSGSEND = "objc_msgSend";
- TAG_MSGSENDSUPER = "objc_msgSendSuper";
- TAG_EXECCLASS = "__objc_execClass";
- }
- else
- {
- TAG_GETCLASS = "objc_get_class";
- TAG_GETMETACLASS = "objc_get_meta_class";
- TAG_MSGSEND = "objc_msg_lookup";
- TAG_MSGSENDSUPER = "objc_msg_lookup_super";
- TAG_EXECCLASS = "__objc_exec_class";
- flag_typed_selectors = 1;
- }
-
- if (doing_objc_thang)
- init_objc ();
-}
-
-static void
-objc_fatal ()
-{
- fatal ("Objective-C text in C source file");
-}
-
-void
-finish_file ()
-{
- if (doing_objc_thang)
- finish_objc (); /* Objective-C finalization */
-
- if (gen_declaration_file)
- fclose (gen_declaration_file);
-}
-
-void
-lang_finish ()
-{
-}
-
-char *
-lang_identify ()
-{
- return "objc";
-}
-
-int
-lang_decode_option (p)
- char *p;
-{
- if (!strcmp (p, "-lang-objc"))
- doing_objc_thang = 1;
- else if (!strcmp (p, "-gen-decls"))
- flag_gen_declaration = 1;
- else if (!strcmp (p, "-Wselector"))
- warn_selector = 1;
- else if (!strcmp (p, "-Wno-selector"))
- warn_selector = 0;
- else if (!strcmp (p, "-Wprotocol"))
- flag_warn_protocol = 1;
- else if (!strcmp (p, "-Wno-protocol"))
- flag_warn_protocol = 0;
- else if (!strcmp (p, "-fgnu-runtime"))
- flag_next_runtime = 0;
- else if (!strcmp (p, "-fno-next-runtime"))
- flag_next_runtime = 0;
- else if (!strcmp (p, "-fno-gnu-runtime"))
- flag_next_runtime = 1;
- else if (!strcmp (p, "-fnext-runtime"))
- flag_next_runtime = 1;
- else
- return c_decode_option (p);
-
- return 1;
-}
-
-static tree
-define_decl (declarator, declspecs)
- tree declarator;
- tree declspecs;
-{
- tree decl = start_decl (declarator, declspecs, 0, NULL_TREE, NULL_TREE);
- finish_decl (decl, NULL_TREE, NULL_TREE);
- return decl;
-}
-
-/* Return 1 if LHS and RHS are compatible types for assignment or
- various other operations. Return 0 if they are incompatible, and
- return -1 if we choose to not decide. When the operation is
- REFLEXIVE, check for compatibility in either direction.
-
- For statically typed objects, an assignment of the form `a' = `b'
- is permitted if:
-
- `a' is of type "id",
- `a' and `b' are the same class type, or
- `a' and `b' are of class types A and B such that B is a descendant of A. */
-
-int
-maybe_objc_comptypes (lhs, rhs, reflexive)
- tree lhs, rhs;
- int reflexive;
-{
- if (doing_objc_thang)
- return objc_comptypes (lhs, rhs, reflexive);
- return -1;
-}
-
-static tree
-lookup_method_in_protocol_list (rproto_list, sel_name, class_meth)
- tree rproto_list;
- tree sel_name;
- int class_meth;
-{
- tree rproto, p;
- tree fnd = 0;
-
- for (rproto = rproto_list; rproto; rproto = TREE_CHAIN (rproto))
- {
- p = TREE_VALUE (rproto);
-
- if (TREE_CODE (p) == PROTOCOL_INTERFACE_TYPE)
- {
- if ((fnd = lookup_method (class_meth
- ? PROTOCOL_CLS_METHODS (p)
- : PROTOCOL_NST_METHODS (p), sel_name)))
- ;
- else if (PROTOCOL_LIST (p))
- fnd = lookup_method_in_protocol_list (PROTOCOL_LIST (p),
- sel_name, class_meth);
- }
- else
- ; /* An identifier...if we could not find a protocol. */
-
- if (fnd)
- return fnd;
- }
-
- return 0;
-}
-
-static tree
-lookup_protocol_in_reflist (rproto_list, lproto)
- tree rproto_list;
- tree lproto;
-{
- tree rproto, p;
-
- /* Make sure the protocol is support by the object on the rhs. */
- if (TREE_CODE (lproto) == PROTOCOL_INTERFACE_TYPE)
- {
- tree fnd = 0;
- for (rproto = rproto_list; rproto; rproto = TREE_CHAIN (rproto))
- {
- p = TREE_VALUE (rproto);
-
- if (TREE_CODE (p) == PROTOCOL_INTERFACE_TYPE)
- {
- if (lproto == p)
- fnd = lproto;
-
- else if (PROTOCOL_LIST (p))
- fnd = lookup_protocol_in_reflist (PROTOCOL_LIST (p), lproto);
- }
-
- if (fnd)
- return fnd;
- }
- }
- else
- ; /* An identifier...if we could not find a protocol. */
-
- return 0;
-}
-
-/* Return 1 if LHS and RHS are compatible types for assignment
- or various other operations. Return 0 if they are incompatible,
- and return -1 if we choose to not decide. When the operation
- is REFLEXIVE, check for compatibility in either direction. */
-
-int
-objc_comptypes (lhs, rhs, reflexive)
- tree lhs;
- tree rhs;
- int reflexive;
-{
- /* New clause for protocols. */
-
- if (TREE_CODE (lhs) == POINTER_TYPE
- && TREE_CODE (TREE_TYPE (lhs)) == RECORD_TYPE
- && TREE_CODE (rhs) == POINTER_TYPE
- && TREE_CODE (TREE_TYPE (rhs)) == RECORD_TYPE)
- {
- int lhs_is_proto = IS_PROTOCOL_QUALIFIED_ID (lhs);
- int rhs_is_proto = IS_PROTOCOL_QUALIFIED_ID (rhs);
-
- if (lhs_is_proto)
- {
- tree lproto, lproto_list = TYPE_PROTOCOL_LIST (lhs);
- tree rproto, rproto_list;
- tree p;
-
- if (rhs_is_proto)
- {
- rproto_list = TYPE_PROTOCOL_LIST (rhs);
-
- /* Make sure the protocol is supported by the object
- on the rhs. */
- for (lproto = lproto_list; lproto; lproto = TREE_CHAIN (lproto))
- {
- p = TREE_VALUE (lproto);
- rproto = lookup_protocol_in_reflist (rproto_list, p);
-
- if (!rproto)
- warning ("object does not conform to the `%s' protocol",
- IDENTIFIER_POINTER (PROTOCOL_NAME (p)));
- }
- }
- else if (TYPED_OBJECT (TREE_TYPE (rhs)))
- {
- tree rname = TYPE_NAME (TREE_TYPE (rhs));
- tree rinter;
-
- /* Make sure the protocol is supported by the object
- on the rhs. */
- for (lproto = lproto_list; lproto; lproto = TREE_CHAIN (lproto))
- {
- p = TREE_VALUE (lproto);
- rproto = 0;
- rinter = lookup_interface (rname);
-
- while (rinter && !rproto)
- {
- tree cat;
-
- rproto_list = CLASS_PROTOCOL_LIST (rinter);
- rproto = lookup_protocol_in_reflist (rproto_list, p);
-
- /* Check for protocols adopted by categories. */
- cat = CLASS_CATEGORY_LIST (rinter);
- while (cat && !rproto)
- {
- rproto_list = CLASS_PROTOCOL_LIST (cat);
- rproto = lookup_protocol_in_reflist (rproto_list, p);
-
- cat = CLASS_CATEGORY_LIST (cat);
- }
-
- rinter = lookup_interface (CLASS_SUPER_NAME (rinter));
- }
-
- if (!rproto)
- warning ("class `%s' does not implement the `%s' protocol",
- IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (rhs))),
- IDENTIFIER_POINTER (PROTOCOL_NAME (p)));
- }
- }
-
- /* May change...based on whether there was any mismatch */
- return 1;
- }
- else if (rhs_is_proto)
- /* Lhs is not a protocol...warn if it is statically typed */
- return (TYPED_OBJECT (TREE_TYPE (lhs)) != 0);
-
- else
- /* Defer to comptypes .*/
- return -1;
- }
-
- else if (TREE_CODE (lhs) == RECORD_TYPE && TREE_CODE (rhs) == RECORD_TYPE)
- ; /* Fall thru. This is the case we have been handling all along */
- else
- /* Defer to comptypes. */
- return -1;
-
- /* `id' = `<class> *', `<class> *' = `id' */
-
- if ((TYPE_NAME (lhs) == objc_object_id && TYPED_OBJECT (rhs))
- || (TYPE_NAME (rhs) == objc_object_id && TYPED_OBJECT (lhs)))
- return 1;
-
- /* `id' = `Class', `Class' = `id' */
-
- else if ((TYPE_NAME (lhs) == objc_object_id
- && TYPE_NAME (rhs) == objc_class_id)
- || (TYPE_NAME (lhs) == objc_class_id
- && TYPE_NAME (rhs) == objc_object_id))
- return 1;
-
- /* `<class> *' = `<class> *' */
-
- else if (TYPED_OBJECT (lhs) && TYPED_OBJECT (rhs))
- {
- tree lname = TYPE_NAME (lhs);
- tree rname = TYPE_NAME (rhs);
- tree inter;
-
- if (lname == rname)
- return 1;
-
- /* If the left hand side is a super class of the right hand side,
- allow it. */
- for (inter = lookup_interface (rname); inter;
- inter = lookup_interface (CLASS_SUPER_NAME (inter)))
- if (lname == CLASS_SUPER_NAME (inter))
- return 1;
-
- /* Allow the reverse when reflexive. */
- if (reflexive)
- for (inter = lookup_interface (lname); inter;
- inter = lookup_interface (CLASS_SUPER_NAME (inter)))
- if (rname == CLASS_SUPER_NAME (inter))
- return 1;
-
- return 0;
- }
- else
- /* Defer to comptypes. */
- return -1;
-}
-
-/* Called from c-decl.c before all calls to rest_of_decl_compilation. */
-
-void
-objc_check_decl (decl)
- tree decl;
-{
- tree type = TREE_TYPE (decl);
-
- if (TREE_CODE (type) == RECORD_TYPE
- && TREE_STATIC_TEMPLATE (type)
- && type != constant_string_type)
- {
- error_with_decl (decl, "`%s' cannot be statically allocated");
- fatal ("statically allocated objects not supported");
- }
-}
-
-void
-maybe_objc_check_decl (decl)
- tree decl;
-{
- if (doing_objc_thang)
- objc_check_decl (decl);
-}
-
-/* Implement static typing. At this point, we know we have an interface. */
-
-tree
-get_static_reference (interface, protocols)
- tree interface;
- tree protocols;
-{
- tree type = xref_tag (RECORD_TYPE, interface);
-
- if (protocols)
- {
- tree t, m = TYPE_MAIN_VARIANT (type);
-
- push_obstacks_nochange ();
- end_temporary_allocation ();
- t = copy_node (type);
- TYPE_BINFO (t) = make_tree_vec (2);
- pop_obstacks ();
-
- /* Add this type to the chain of variants of TYPE. */
- TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (m);
- TYPE_NEXT_VARIANT (m) = t;
-
- /* Look up protocols and install in lang specific list. */
- TYPE_PROTOCOL_LIST (t) = lookup_and_install_protocols (protocols);
-
- /* This forces a new pointer type to be created later
- (in build_pointer_type)...so that the new template
- we just created will actually be used...what a hack! */
- if (TYPE_POINTER_TO (t))
- TYPE_POINTER_TO (t) = 0;
-
- type = t;
- }
-
- return type;
-}
-
-tree
-get_object_reference (protocols)
- tree protocols;
-{
- tree type_decl = lookup_name (objc_id_id);
- tree type;
-
- if (type_decl && TREE_CODE (type_decl) == TYPE_DECL)
- {
- type = TREE_TYPE (type_decl);
- if (TYPE_MAIN_VARIANT (type) != id_type)
- warning ("Unexpected type for `id' (%s)",
- gen_declaration (type, errbuf));
- }
- else
- fatal ("Undefined type `id', please import <objc/objc.h>");
-
- /* This clause creates a new pointer type that is qualified with
- the protocol specification...this info is used later to do more
- elaborate type checking. */
-
- if (protocols)
- {
- tree t, m = TYPE_MAIN_VARIANT (type);
-
- push_obstacks_nochange ();
- end_temporary_allocation ();
- t = copy_node (type);
- TYPE_BINFO (t) = make_tree_vec (2);
- pop_obstacks ();
-
- /* Add this type to the chain of variants of TYPE. */
- TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (m);
- TYPE_NEXT_VARIANT (m) = t;
-
- /* Look up protocols...and install in lang specific list */
- TYPE_PROTOCOL_LIST (t) = lookup_and_install_protocols (protocols);
-
- /* This forces a new pointer type to be created later
- (in build_pointer_type)...so that the new template
- we just created will actually be used...what a hack! */
- if (TYPE_POINTER_TO (t))
- TYPE_POINTER_TO (t) = NULL;
-
- type = t;
- }
- return type;
-}
-
-static tree
-lookup_and_install_protocols (protocols)
- tree protocols;
-{
- tree proto;
- tree prev = NULL;
- tree return_value = protocols;
-
- for (proto = protocols; proto; proto = TREE_CHAIN (proto))
- {
- tree ident = TREE_VALUE (proto);
- tree p = lookup_protocol (ident);
-
- if (!p)
- {
- error ("Cannot find protocol declaration for `%s'",
- IDENTIFIER_POINTER (ident));
- if (prev)
- TREE_CHAIN (prev) = TREE_CHAIN (proto);
- else
- return_value = TREE_CHAIN (proto);
- }
- else
- {
- /* Replace identifier with actual protocol node. */
- TREE_VALUE (proto) = p;
- prev = proto;
- }
- }
-
- return return_value;
-}
-
-/* Create and push a decl for a built-in external variable or field NAME.
- CODE says which.
- TYPE is its data type. */
-
-static tree
-create_builtin_decl (code, type, name)
- enum tree_code code;
- tree type;
- char *name;
-{
- tree decl = build_decl (code, get_identifier (name), type);
-
- if (code == VAR_DECL)
- {
- TREE_STATIC (decl) = 1;
- make_decl_rtl (decl, 0, 1);
- pushdecl (decl);
- }
-
- DECL_ARTIFICIAL (decl) = 1;
- return decl;
-}
-
-/* Purpose: "play" parser, creating/installing representations
- of the declarations that are required by Objective-C.
-
- Model:
-
- type_spec--------->sc_spec
- (tree_list) (tree_list)
- | |
- | |
- identifier_node identifier_node */
-
-static void
-synth_module_prologue ()
-{
- tree temp_type;
- tree super_p;
-
- /* Defined in `objc.h' */
- objc_object_id = get_identifier (TAG_OBJECT);
-
- objc_object_reference = xref_tag (RECORD_TYPE, objc_object_id);
-
- id_type = build_pointer_type (objc_object_reference);
-
- objc_id_id = get_identifier (TYPE_ID);
- objc_class_id = get_identifier (TAG_CLASS);
-
- objc_class_type = build_pointer_type (xref_tag (RECORD_TYPE, objc_class_id));
- protocol_type = build_pointer_type (xref_tag (RECORD_TYPE,
- get_identifier (PROTOCOL_OBJECT_CLASS_NAME)));
-
- /* Declare type of selector-objects that represent an operation name. */
-
-#ifdef OBJC_INT_SELECTORS
- /* `unsigned int' */
- selector_type = unsigned_type_node;
-#else
- /* `struct objc_selector *' */
- selector_type
- = build_pointer_type (xref_tag (RECORD_TYPE,
- get_identifier (TAG_SELECTOR)));
-#endif /* not OBJC_INT_SELECTORS */
-
- /* Forward declare type, or else the prototype for msgSendSuper will
- complain. */
-
- super_p = build_pointer_type (xref_tag (RECORD_TYPE,
- get_identifier (TAG_SUPER)));
-
-
- /* id objc_msgSend (id, SEL, ...); */
-
- temp_type
- = build_function_type (id_type,
- tree_cons (NULL_TREE, id_type,
- tree_cons (NULL_TREE, selector_type,
- NULL_TREE)));
-
- if (! flag_next_runtime)
- {
- umsg_decl = build_decl (FUNCTION_DECL,
- get_identifier (TAG_MSGSEND), temp_type);
- DECL_EXTERNAL (umsg_decl) = 1;
- TREE_PUBLIC (umsg_decl) = 1;
- DECL_INLINE (umsg_decl) = 1;
- DECL_ARTIFICIAL (umsg_decl) = 1;
-
- if (flag_traditional && TAG_MSGSEND[0] != '_')
- DECL_BUILT_IN_NONANSI (umsg_decl) = 1;
-
- make_decl_rtl (umsg_decl, NULL_PTR, 1);
- pushdecl (umsg_decl);
- }
- else
- umsg_decl = builtin_function (TAG_MSGSEND, temp_type, NOT_BUILT_IN, 0);
-
- /* id objc_msgSendSuper (struct objc_super *, SEL, ...); */
-
- temp_type
- = build_function_type (id_type,
- tree_cons (NULL_TREE, super_p,
- tree_cons (NULL_TREE, selector_type,
- NULL_TREE)));
-
- umsg_super_decl = builtin_function (TAG_MSGSENDSUPER,
- temp_type, NOT_BUILT_IN, 0);
-
- /* id objc_getClass (const char *); */
-
- temp_type = build_function_type (id_type,
- tree_cons (NULL_TREE,
- const_string_type_node,
- tree_cons (NULL_TREE, void_type_node,
- NULL_TREE)));
-
- objc_get_class_decl
- = builtin_function (TAG_GETCLASS, temp_type, NOT_BUILT_IN, 0);
-
- /* id objc_getMetaClass (const char *); */
-
- objc_get_meta_class_decl
- = builtin_function (TAG_GETMETACLASS, temp_type, NOT_BUILT_IN, 0);
-
- /* static SEL _OBJC_SELECTOR_TABLE[]; */
-
- if (! flag_next_runtime)
- {
- if (flag_typed_selectors)
- {
- /* Suppress outputting debug symbols, because
- dbxout_init hasn'r been called yet. */
- enum debug_info_type save_write_symbols = write_symbols;
- write_symbols = NO_DEBUG;
-
- build_selector_template ();
- temp_type = build_array_type (objc_selector_template, NULL_TREE);
-
- write_symbols = save_write_symbols;
- }
- else
- temp_type = build_array_type (selector_type, NULL_TREE);
-
- layout_type (temp_type);
- UOBJC_SELECTOR_TABLE_decl
- = create_builtin_decl (VAR_DECL, temp_type,
- "_OBJC_SELECTOR_TABLE");
-
- /* Avoid warning when not sending messages. */
- TREE_USED (UOBJC_SELECTOR_TABLE_decl) = 1;
- }
-
- generate_forward_declaration_to_string_table ();
-
- /* Forward declare constant_string_id and constant_string_type. */
- constant_string_id = get_identifier (STRING_OBJECT_CLASS_NAME);
- constant_string_type = xref_tag (RECORD_TYPE, constant_string_id);
-}
-
-/* Custom build_string which sets TREE_TYPE! */
-
-static tree
-my_build_string (len, str)
- int len;
- char *str;
-{
- int wide_flag = 0;
- tree a_string = build_string (len, str);
-
- /* Some code from combine_strings, which is local to c-parse.y. */
- if (TREE_TYPE (a_string) == int_array_type_node)
- wide_flag = 1;
-
- TREE_TYPE (a_string)
- = build_array_type (wide_flag ? integer_type_node : char_type_node,
- build_index_type (build_int_2 (len - 1, 0)));
-
- TREE_CONSTANT (a_string) = 1; /* Puts string in the readonly segment */
- TREE_STATIC (a_string) = 1;
-
- return a_string;
-}
-
-/* Return a newly constructed OBJC_STRING_CST node whose value is
- the LEN characters at STR.
- The TREE_TYPE is not initialized. */
-
-tree
-build_objc_string (len, str)
- int len;
- char *str;
-{
- tree s = build_string (len, str);
-
- TREE_SET_CODE (s, OBJC_STRING_CST);
- return s;
-}
-
-/* Given a chain of OBJC_STRING_CST's, build a static instance of
- NXConstanString which points at the concatenation of those strings.
- We place the string object in the __string_objects section of the
- __OBJC segment. The Objective-C runtime will initialize the isa
- pointers of the string objects to point at the NXConstandString class
- object. */
-
-tree
-build_objc_string_object (strings)
- tree strings;
-{
- tree string, initlist, constructor;
- int length;
-
- if (!doing_objc_thang)
- objc_fatal ();
-
- if (lookup_interface (constant_string_id) == NULL_TREE)
- {
- error ("Cannot find interface declaration for `%s'",
- IDENTIFIER_POINTER (constant_string_id));
- return error_mark_node;
- }
-
- add_class_reference (constant_string_id);
-
- /* Combine_strings will work for OBJC_STRING_CST's too. */
- string = combine_strings (strings);
- TREE_SET_CODE (string, STRING_CST);
- length = TREE_STRING_LENGTH (string) - 1;
-
- if (! flag_next_runtime)
- {
- push_obstacks_nochange ();
- end_temporary_allocation ();
- if (! TREE_PERMANENT (strings))
- string = my_build_string (length + 1,
- TREE_STRING_POINTER (string));
- }
-
- /* & ((NXConstantString) {0, string, length}) */
-
- initlist = build_tree_list (NULL_TREE, build_int_2 (0, 0));
- initlist
- = tree_cons (NULL_TREE, copy_node (build_unary_op (ADDR_EXPR, string, 1)),
- initlist);
- initlist = tree_cons (NULL_TREE, build_int_2 (length, 0), initlist);
- constructor = build_constructor (constant_string_type, nreverse (initlist));
-
- if (!flag_next_runtime)
- {
- constructor
- = objc_add_static_instance (constructor, constant_string_type);
- pop_obstacks ();
- }
-
- return (build_unary_op (ADDR_EXPR, constructor, 1));
-}
-
-/* Declare a static instance of CLASS_DECL initialized by CONSTRUCTOR. */
-
-static tree
-objc_add_static_instance (constructor, class_decl)
- tree constructor, class_decl;
-{
- static int num_static_inst;
- tree *chain, decl, decl_spec, decl_expr;
- char buf[256];
-
- push_obstacks_nochange ();
- end_temporary_allocation ();
-
- /* Find the list of static instances for the CLASS_DECL. Create one if
- not found. */
- for (chain = &objc_static_instances;
- *chain && TREE_VALUE (*chain) != class_decl;
- chain = &TREE_CHAIN (*chain));
- if (!*chain)
- {
- *chain = tree_cons (NULL_TREE, class_decl, NULL_TREE);
- add_objc_string (TYPE_NAME (class_decl), class_names);
- }
-
- sprintf (buf, "_OBJC_INSTANCE_%d", num_static_inst++);
- decl = build_decl (VAR_DECL, get_identifier (buf), class_decl);
- DECL_COMMON (decl) = 1;
- TREE_STATIC (decl) = 1;
- DECL_ARTIFICIAL (decl) = 1;
- pushdecl_top_level (decl);
- rest_of_decl_compilation (decl, 0, 1, 0);
-
- /* Do this here so it gets output later instead of possibly
- inside something else we are writing. */
- DECL_INITIAL (decl) = constructor;
-
- /* Add the DECL to the head of this CLASS' list. */
- TREE_PURPOSE (*chain) = tree_cons (NULL_TREE, decl, TREE_PURPOSE (*chain));
-
- pop_obstacks ();
- return decl;
-}
-
-/* Build a static constant CONSTRUCTOR
- with type TYPE and elements ELTS. */
-
-static tree
-build_constructor (type, elts)
- tree type, elts;
-{
- tree constructor = build (CONSTRUCTOR, type, NULL_TREE, elts);
-
- TREE_CONSTANT (constructor) = 1;
- TREE_STATIC (constructor) = 1;
- TREE_READONLY (constructor) = 1;
-
- return constructor;
-}
-
-/* Take care of defining and initializing _OBJC_SYMBOLS. */
-
-/* Predefine the following data type:
-
- struct _objc_symtab
- {
- long sel_ref_cnt;
- SEL *refs;
- short cls_def_cnt;
- short cat_def_cnt;
- void *defs[cls_def_cnt + cat_def_cnt];
- }; */
-
-static void
-build_objc_symtab_template ()
-{
- tree field_decl, field_decl_chain, index;
-
- objc_symtab_template
- = start_struct (RECORD_TYPE, get_identifier (UTAG_SYMTAB));
-
- /* long sel_ref_cnt; */
-
- field_decl = create_builtin_decl (FIELD_DECL,
- long_integer_type_node,
- "sel_ref_cnt");
- field_decl_chain = field_decl;
-
- /* SEL *refs; */
-
- field_decl = create_builtin_decl (FIELD_DECL,
- build_pointer_type (selector_type),
- "refs");
- chainon (field_decl_chain, field_decl);
-
- /* short cls_def_cnt; */
-
- field_decl = create_builtin_decl (FIELD_DECL,
- short_integer_type_node,
- "cls_def_cnt");
- chainon (field_decl_chain, field_decl);
-
- /* short cat_def_cnt; */
-
- field_decl = create_builtin_decl (FIELD_DECL,
- short_integer_type_node,
- "cat_def_cnt");
- chainon (field_decl_chain, field_decl);
-
- /* void *defs[cls_def_cnt + cat_def_cnt]; */
-
- index = build_index_type (build_int_2 (imp_count + cat_count - 1,
- imp_count == 0 && cat_count == 0
- ? -1 : 0));
- field_decl = create_builtin_decl (FIELD_DECL,
- build_array_type (ptr_type_node, index),
- "defs");
- chainon (field_decl_chain, field_decl);
-
- finish_struct (objc_symtab_template, field_decl_chain, NULL_TREE);
-}
-
-/* Create the initial value for the `defs' field of _objc_symtab.
- This is a CONSTRUCTOR. */
-
-static tree
-init_def_list (type)
- tree type;
-{
- tree expr, initlist = NULL_TREE;
- struct imp_entry *impent;
-
- if (imp_count)
- for (impent = imp_list; impent; impent = impent->next)
- {
- if (TREE_CODE (impent->imp_context) == CLASS_IMPLEMENTATION_TYPE)
- {
- expr = build_unary_op (ADDR_EXPR, impent->class_decl, 0);
- initlist = tree_cons (NULL_TREE, expr, initlist);
- }
- }
-
- if (cat_count)
- for (impent = imp_list; impent; impent = impent->next)
- {
- if (TREE_CODE (impent->imp_context) == CATEGORY_IMPLEMENTATION_TYPE)
- {
- expr = build_unary_op (ADDR_EXPR, impent->class_decl, 0);
- initlist = tree_cons (NULL_TREE, expr, initlist);
- }
- }
-
- return build_constructor (type, nreverse (initlist));
-}
-
-/* Construct the initial value for all of _objc_symtab. */
-
-static tree
-init_objc_symtab (type)
- tree type;
-{
- tree initlist;
-
- /* sel_ref_cnt = { ..., 5, ... } */
-
- initlist = build_tree_list (NULL_TREE, build_int_2 (0, 0));
-
- /* refs = { ..., _OBJC_SELECTOR_TABLE, ... } */
-
- if (flag_next_runtime || ! sel_ref_chain)
- initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist);
- else
- initlist = tree_cons (NULL_TREE,
- build_unary_op (ADDR_EXPR,
- UOBJC_SELECTOR_TABLE_decl, 1),
- initlist);
-
- /* cls_def_cnt = { ..., 5, ... } */
-
- initlist = tree_cons (NULL_TREE, build_int_2 (imp_count, 0), initlist);
-
- /* cat_def_cnt = { ..., 5, ... } */
-
- initlist = tree_cons (NULL_TREE, build_int_2 (cat_count, 0), initlist);
-
- /* cls_def = { ..., { &Foo, &Bar, ...}, ... } */
-
- if (imp_count || cat_count)
- {
- tree field = TYPE_FIELDS (type);
- field = TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (field))));
-
- initlist = tree_cons (NULL_TREE, init_def_list (TREE_TYPE (field)),
- initlist);
- }
-
- return build_constructor (type, nreverse (initlist));
-}
-
-/* Push forward-declarations of all the categories
- so that init_def_list can use them in a CONSTRUCTOR. */
-
-static void
-forward_declare_categories ()
-{
- struct imp_entry *impent;
- tree sav = implementation_context;
-
- for (impent = imp_list; impent; impent = impent->next)
- {
- if (TREE_CODE (impent->imp_context) == CATEGORY_IMPLEMENTATION_TYPE)
- {
- /* Set an invisible arg to synth_id_with_class_suffix. */
- implementation_context = impent->imp_context;
- impent->class_decl
- = create_builtin_decl (VAR_DECL, objc_category_template,
- IDENTIFIER_POINTER (synth_id_with_class_suffix ("_OBJC_CATEGORY", implementation_context)));
- }
- }
- implementation_context = sav;
-}
-
-/* Create the declaration of _OBJC_SYMBOLS, with type `strict _objc_symtab'
- and initialized appropriately. */
-
-static void
-generate_objc_symtab_decl ()
-{
- tree sc_spec;
-
- if (!objc_category_template)
- build_category_template ();
-
- /* forward declare categories */
- if (cat_count)
- forward_declare_categories ();
-
- if (!objc_symtab_template)
- build_objc_symtab_template ();
-
- sc_spec = build_tree_list (NULL_TREE, ridpointers[(int) RID_STATIC]);
-
- UOBJC_SYMBOLS_decl = start_decl (get_identifier ("_OBJC_SYMBOLS"),
- tree_cons (NULL_TREE,
- objc_symtab_template, sc_spec),
- 1,
- NULL_TREE, NULL_TREE);
-
- TREE_USED (UOBJC_SYMBOLS_decl) = 1;
- DECL_IGNORED_P (UOBJC_SYMBOLS_decl) = 1;
- DECL_ARTIFICIAL (UOBJC_SYMBOLS_decl) = 1;
- finish_decl (UOBJC_SYMBOLS_decl,
- init_objc_symtab (TREE_TYPE (UOBJC_SYMBOLS_decl)),
- NULL_TREE);
-}
-
-static tree
-init_module_descriptor (type)
- tree type;
-{
- tree initlist, expr;
-
- /* version = { 1, ... } */
-
- expr = build_int_2 (OBJC_VERSION, 0);
- initlist = build_tree_list (NULL_TREE, expr);
-
- /* size = { ..., sizeof (struct objc_module), ... } */
-
- expr = size_in_bytes (objc_module_template);
- initlist = tree_cons (NULL_TREE, expr, initlist);
-
- /* name = { ..., "foo.m", ... } */
-
- expr = add_objc_string (get_identifier (input_filename), class_names);
- initlist = tree_cons (NULL_TREE, expr, initlist);
-
-
- if (!flag_next_runtime)
- {
- /* statics = { ..., _OBJC_STATIC_INSTANCES, ... } */
- if (static_instances_decl)
- expr = build_unary_op (ADDR_EXPR, static_instances_decl, 0);
- else
- expr = build_int_2 (0, 0);
- initlist = tree_cons (NULL_TREE, expr, initlist);
- }
-
- /* symtab = { ..., _OBJC_SYMBOLS, ... } */
-
- if (UOBJC_SYMBOLS_decl)
- expr = build_unary_op (ADDR_EXPR, UOBJC_SYMBOLS_decl, 0);
- else
- expr = build_int_2 (0, 0);
- initlist = tree_cons (NULL_TREE, expr, initlist);
-
- return build_constructor (type, nreverse (initlist));
-}
-
-/* Write out the data structures to describe Objective C classes defined.
- If appropriate, compile and output a setup function to initialize them.
- Return a string which is the name of a function to call to initialize
- the Objective C data structures for this file (and perhaps for other files
- also).
-
- struct objc_module { ... } _OBJC_MODULE = { ... }; */
-
-static char *
-build_module_descriptor ()
-{
- tree decl_specs, field_decl, field_decl_chain;
-
- objc_module_template
- = start_struct (RECORD_TYPE, get_identifier (UTAG_MODULE));
-
- /* Long version; */
-
- decl_specs = build_tree_list (NULL_TREE, ridpointers[(int) RID_LONG]);
- field_decl = get_identifier ("version");
- field_decl
- = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE);
- field_decl_chain = field_decl;
-
- /* long size; */
-
- decl_specs = build_tree_list (NULL_TREE, ridpointers[(int) RID_LONG]);
- field_decl = get_identifier ("size");
- field_decl
- = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE);
- chainon (field_decl_chain, field_decl);
-
- /* char *name; */
-
- decl_specs = build_tree_list (NULL_TREE, ridpointers[(int) RID_CHAR]);
- field_decl = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("name"));
- field_decl
- = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE);
- chainon (field_decl_chain, field_decl);
-
-
- if (!flag_next_runtime)
- {
- /* void *statics */
-
- decl_specs = get_identifier (UTAG_STATICS);
- decl_specs
- = build_tree_list (NULL_TREE, xref_tag (RECORD_TYPE, decl_specs));
- field_decl
- = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("statics"));
- field_decl = grokfield (input_filename, lineno, field_decl,
- decl_specs, NULL_TREE);
- chainon (field_decl_chain, field_decl);
- }
-
-
- /* struct objc_symtab *symtab; */
-
- decl_specs = get_identifier (UTAG_SYMTAB);
- decl_specs = build_tree_list (NULL_TREE, xref_tag (RECORD_TYPE, decl_specs));
- field_decl = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("symtab"));
- field_decl
- = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE);
- chainon (field_decl_chain, field_decl);
-
- finish_struct (objc_module_template, field_decl_chain, NULL_TREE);
-
- /* Create an instance of "objc_module". */
-
- decl_specs = tree_cons (NULL_TREE, objc_module_template,
- build_tree_list (NULL_TREE,
- ridpointers[(int) RID_STATIC]));
-
- UOBJC_MODULES_decl = start_decl (get_identifier ("_OBJC_MODULES"),
- decl_specs, 1, NULL_TREE, NULL_TREE);
-
- DECL_ARTIFICIAL (UOBJC_MODULES_decl) = 1;
- DECL_IGNORED_P (UOBJC_MODULES_decl) = 1;
- finish_decl (UOBJC_MODULES_decl,
- init_module_descriptor (TREE_TYPE (UOBJC_MODULES_decl)),
- NULL_TREE);
-
- /* Mark the decl to avoid "defined but not used" warning. */
- DECL_IN_SYSTEM_HEADER (UOBJC_MODULES_decl) = 1;
-
- /* Generate a constructor call for the module descriptor.
- This code was generated by reading the grammar rules
- of c-parse.in; Therefore, it may not be the most efficient
- way of generating the requisite code. */
-
- if (flag_next_runtime)
- return 0;
-
- {
- tree parms, function_decl, decelerator, void_list_node;
- tree function_type;
- extern tree get_file_function_name ();
- tree init_function_name = get_file_function_name ('I');
-
- /* Declare void __objc_execClass (void*); */
-
- void_list_node = build_tree_list (NULL_TREE, void_type_node);
- function_type
- = build_function_type (void_type_node,
- tree_cons (NULL_TREE, ptr_type_node,
- void_list_node));
- function_decl = build_decl (FUNCTION_DECL,
- get_identifier (TAG_EXECCLASS),
- function_type);
- DECL_EXTERNAL (function_decl) = 1;
- DECL_ARTIFICIAL (function_decl) = 1;
- TREE_PUBLIC (function_decl) = 1;
-
- pushdecl (function_decl);
- rest_of_decl_compilation (function_decl, 0, 0, 0);
-
- parms
- = build_tree_list (NULL_TREE,
- build_unary_op (ADDR_EXPR, UOBJC_MODULES_decl, 0));
- decelerator = build_function_call (function_decl, parms);
-
- /* void _GLOBAL_$I$<gnyf> () {objc_execClass (&L_OBJC_MODULES);} */
-
- start_function (void_list_node,
- build_parse_node (CALL_EXPR, init_function_name,
- /* This has the format of the output
- of get_parm_info. */
- tree_cons (NULL_TREE, NULL_TREE,
- void_list_node),
- NULL_TREE),
- NULL_TREE, NULL_TREE, 0);
-#if 0 /* This should be turned back on later
- for the systems where collect is not needed. */
- /* Make these functions nonglobal
- so each file can use the same name. */
- TREE_PUBLIC (current_function_decl) = 0;
-#endif
- TREE_USED (current_function_decl) = 1;
- store_parm_decls ();
-
- assemble_external (function_decl);
- c_expand_expr_stmt (decelerator);
-
- TREE_PUBLIC (current_function_decl) = 1;
-
- function_decl = current_function_decl;
- finish_function (0);
-
- /* Return the name of the constructor function. */
- return XSTR (XEXP (DECL_RTL (function_decl), 0), 0);
- }
-}
-
-/* extern const char _OBJC_STRINGS[]; */
-
-static void
-generate_forward_declaration_to_string_table ()
-{
- tree sc_spec, decl_specs, expr_decl;
-
- sc_spec = tree_cons (NULL_TREE, ridpointers[(int) RID_EXTERN], NULL_TREE);
- decl_specs = tree_cons (NULL_TREE, ridpointers[(int) RID_CHAR], sc_spec);
-
- expr_decl
- = build_nt (ARRAY_REF, get_identifier ("_OBJC_STRINGS"), NULL_TREE);
-
- UOBJC_STRINGS_decl = define_decl (expr_decl, decl_specs);
-}
-
-/* Return the DECL of the string IDENT in the SECTION. */
-
-static tree
-get_objc_string_decl (ident, section)
- tree ident;
- enum string_section section;
-{
- tree chain, decl;
-
- if (section == class_names)
- chain = class_names_chain;
- else if (section == meth_var_names)
- chain = meth_var_names_chain;
- else if (section == meth_var_types)
- chain = meth_var_types_chain;
-
- for (; chain != 0; chain = TREE_VALUE (chain))
- if (TREE_VALUE (chain) == ident)
- return (TREE_PURPOSE (chain));
-
- abort ();
- return NULL_TREE;
-}
-
-/* Output references to all statically allocated objects. Return the DECL
- for the array built. */
-
-static tree
-generate_static_references ()
-{
- tree decls = NULL_TREE, ident, decl_spec, expr_decl, expr = NULL_TREE;
- tree class_name, class, decl, instance, idecl, initlist;
- tree cl_chain, in_chain, type;
- int num_inst, num_class;
- char buf[256];
-
- if (flag_next_runtime)
- abort ();
-
- for (cl_chain = objc_static_instances, num_class = 0;
- cl_chain; cl_chain = TREE_CHAIN (cl_chain), num_class++)
- {
- for (num_inst = 0, in_chain = TREE_PURPOSE (cl_chain);
- in_chain; num_inst++, in_chain = TREE_CHAIN (in_chain));
-
- sprintf (buf, "_OBJC_STATIC_INSTANCES_%d", num_class);
- ident = get_identifier (buf);
-
- expr_decl = build_nt (ARRAY_REF, ident, NULL_TREE);
- decl_spec = tree_cons (NULL_TREE, build_pointer_type (void_type_node),
- build_tree_list (NULL_TREE,
- ridpointers[(int) RID_STATIC]));
- decl = start_decl (expr_decl, decl_spec, 1, NULL_TREE, NULL_TREE);
- DECL_CONTEXT (decl) = 0;
- DECL_ARTIFICIAL (decl) = 1;
-
- /* Output {class_name, ...}. */
- class = TREE_VALUE (cl_chain);
- class_name = get_objc_string_decl (TYPE_NAME (class), class_names);
- initlist = build_tree_list (NULL_TREE,
- build_unary_op (ADDR_EXPR, class_name, 1));
-
- /* Output {..., instance, ...}. */
- for (in_chain = TREE_PURPOSE (cl_chain);
- in_chain; in_chain = TREE_CHAIN (in_chain))
- {
- expr = build_unary_op (ADDR_EXPR, TREE_VALUE (in_chain), 1);
- initlist = tree_cons (NULL_TREE, expr, initlist);
- }
-
- /* Output {..., NULL}. */
- initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist);
-
- expr = build_constructor (TREE_TYPE (decl), nreverse (initlist));
- finish_decl (decl, expr, NULL_TREE);
- TREE_USED (decl) = 1;
-
- type = build_array_type (build_pointer_type (void_type_node), 0);
- decl = build_decl (VAR_DECL, ident, type);
- make_decl_rtl (decl, 0, 1);
- TREE_USED (decl) = 1;
- decls
- = tree_cons (NULL_TREE, build_unary_op (ADDR_EXPR, decl, 1), decls);
- }
-
- decls = tree_cons (NULL_TREE, build_int_2 (0, 0), decls);
- ident = get_identifier ("_OBJC_STATIC_INSTANCES");
- expr_decl = build_nt (ARRAY_REF, ident, NULL_TREE);
- decl_spec = tree_cons (NULL_TREE, build_pointer_type (void_type_node),
- build_tree_list (NULL_TREE,
- ridpointers[(int) RID_STATIC]));
- static_instances_decl
- = start_decl (expr_decl, decl_spec, 1, NULL_TREE, NULL_TREE);
- DECL_CONTEXT (static_instances_decl) = 0;
- DECL_ARTIFICIAL (static_instances_decl) = 1;
- end_temporary_allocation ();
- expr = build_constructor (TREE_TYPE (static_instances_decl),
- nreverse (decls));
- finish_decl (static_instances_decl, expr, NULL_TREE);
-}
-
-/* Output all strings. */
-
-static void
-generate_strings ()
-{
- tree sc_spec, decl_specs, expr_decl;
- tree chain, string_expr;
- tree string, decl;
-
- for (chain = class_names_chain; chain; chain = TREE_CHAIN (chain))
- {
- string = TREE_VALUE (chain);
- decl = TREE_PURPOSE (chain);
- sc_spec
- = tree_cons (NULL_TREE, ridpointers[(int) RID_STATIC], NULL_TREE);
- decl_specs = tree_cons (NULL_TREE, ridpointers[(int) RID_CHAR], sc_spec);
- expr_decl = build_nt (ARRAY_REF, DECL_NAME (decl), NULL_TREE);
- decl = start_decl (expr_decl, decl_specs, 1, NULL_TREE, NULL_TREE);
- end_temporary_allocation ();
- string_expr = my_build_string (IDENTIFIER_LENGTH (string) + 1,
- IDENTIFIER_POINTER (string));
- finish_decl (decl, string_expr, NULL_TREE);
- }
-
- for (chain = meth_var_names_chain; chain; chain = TREE_CHAIN (chain))
- {
- string = TREE_VALUE (chain);
- decl = TREE_PURPOSE (chain);
- sc_spec
- = tree_cons (NULL_TREE, ridpointers[(int) RID_STATIC], NULL_TREE);
- decl_specs = tree_cons (NULL_TREE, ridpointers[(int) RID_CHAR], sc_spec);
- expr_decl = build_nt (ARRAY_REF, DECL_NAME (decl), NULL_TREE);
- decl = start_decl (expr_decl, decl_specs, 1, NULL_TREE, NULL_TREE);
- string_expr = my_build_string (IDENTIFIER_LENGTH (string) + 1,
- IDENTIFIER_POINTER (string));
- finish_decl (decl, string_expr, NULL_TREE);
- }
-
- for (chain = meth_var_types_chain; chain; chain = TREE_CHAIN (chain))
- {
- string = TREE_VALUE (chain);
- decl = TREE_PURPOSE (chain);
- sc_spec
- = tree_cons (NULL_TREE, ridpointers[(int) RID_STATIC], NULL_TREE);
- decl_specs = tree_cons (NULL_TREE, ridpointers[(int) RID_CHAR], sc_spec);
- expr_decl = build_nt (ARRAY_REF, DECL_NAME (decl), NULL_TREE);
- decl = start_decl (expr_decl, decl_specs, 1, NULL_TREE, NULL_TREE);
- string_expr = my_build_string (IDENTIFIER_LENGTH (string) + 1,
- IDENTIFIER_POINTER (string));
- finish_decl (decl, string_expr, NULL_TREE);
- }
-}
-
-static tree
-build_selector_reference_decl (name)
- tree name;
-{
- tree decl, ident;
- char buf[256];
- static int idx = 0;
-
- sprintf (buf, "_OBJC_SELECTOR_REFERENCES_%d", idx++);
-
- push_obstacks_nochange ();
- end_temporary_allocation ();
-
- ident = get_identifier (buf);
-
- decl = build_decl (VAR_DECL, ident, selector_type);
- DECL_EXTERNAL (decl) = 1;
- TREE_PUBLIC (decl) = 1;
- TREE_USED (decl) = 1;
- TREE_READONLY (decl) = 1;
- DECL_ARTIFICIAL (decl) = 1;
- DECL_CONTEXT (decl) = 0;
-
- make_decl_rtl (decl, 0, 1);
- pushdecl_top_level (decl);
-
- pop_obstacks ();
-
- return decl;
-}
-
-/* Just a handy wrapper for add_objc_string. */
-
-static tree
-build_selector (ident)
- tree ident;
-{
- tree expr = add_objc_string (ident, meth_var_names);
- if (flag_typed_selectors)
- return expr;
- else
- return build_c_cast (selector_type, expr); /* cast! */
-}
-
-/* Synthesize the following expr: (char *)&_OBJC_STRINGS[<offset>]
- The cast stops the compiler from issuing the following message:
- grok.m: warning: initialization of non-const * pointer from const *
- grok.m: warning: initialization between incompatible pointer types. */
-
-static tree
-build_msg_pool_reference (offset)
- int offset;
-{
- tree expr = build_int_2 (offset, 0);
- tree cast;
-
- expr = build_array_ref (UOBJC_STRINGS_decl, expr);
- expr = build_unary_op (ADDR_EXPR, expr, 0);
-
- cast = build_tree_list (build_tree_list (NULL_TREE,
- ridpointers[(int) RID_CHAR]),
- build1 (INDIRECT_REF, NULL_TREE, NULL_TREE));
- TREE_TYPE (expr) = groktypename (cast);
- return expr;
-}
-
-static tree
-init_selector (offset)
- int offset;
-{
- tree expr = build_msg_pool_reference (offset);
- TREE_TYPE (expr) = selector_type;
- return expr;
-}
-
-static void
-build_selector_translation_table ()
-{
- tree sc_spec, decl_specs;
- tree chain, initlist = NULL_TREE;
- int offset = 0;
- tree decl, var_decl, name;
-
- /* The corresponding pop_obstacks is in finish_decl,
- called at the end of this function. */
- if (! flag_next_runtime)
- push_obstacks_nochange ();
-
- for (chain = sel_ref_chain; chain; chain = TREE_CHAIN (chain))
- {
- tree expr;
-
- expr = build_selector (TREE_VALUE (chain));
-
- if (flag_next_runtime)
- {
- name = DECL_NAME (TREE_PURPOSE (chain));
-
- sc_spec = build_tree_list (NULL_TREE, ridpointers[(int) RID_STATIC]);
-
- /* static SEL _OBJC_SELECTOR_REFERENCES_n = ...; */
- decl_specs = tree_cons (NULL_TREE, selector_type, sc_spec);
-
- var_decl = name;
-
- /* The `decl' that is returned from start_decl is the one that we
- forward declared in `build_selector_reference' */
- decl = start_decl (var_decl, decl_specs, 1, NULL_TREE, NULL_TREE);
- }
-
- /* add one for the '\0' character */
- offset += IDENTIFIER_LENGTH (TREE_VALUE (chain)) + 1;
-
- if (flag_next_runtime)
- finish_decl (decl, expr, NULL_TREE);
- else
- {
- if (flag_typed_selectors)
- {
- tree eltlist = NULL_TREE;
- tree encoding = get_proto_encoding (TREE_PURPOSE (chain));
- eltlist = tree_cons (NULL_TREE, expr, NULL_TREE);
- eltlist = tree_cons (NULL_TREE, encoding, eltlist);
- expr = build_constructor (objc_selector_template,
- nreverse (eltlist));
- }
- initlist = tree_cons (NULL_TREE, expr, initlist);
-
- }
- }
-
- if (! flag_next_runtime)
- {
- /* Cause the variable and its initial value to be actually output. */
- DECL_EXTERNAL (UOBJC_SELECTOR_TABLE_decl) = 0;
- TREE_STATIC (UOBJC_SELECTOR_TABLE_decl) = 1;
- /* NULL terminate the list and fix the decl for output. */
- initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist);
- DECL_INITIAL (UOBJC_SELECTOR_TABLE_decl) = (tree) 1;
- initlist = build_constructor (TREE_TYPE (UOBJC_SELECTOR_TABLE_decl),
- nreverse (initlist));
- finish_decl (UOBJC_SELECTOR_TABLE_decl, initlist, NULL_TREE);
- current_function_decl = NULL_TREE;
- }
-}
-
-static tree
-get_proto_encoding (proto)
- tree proto;
-{
- tree encoding;
- if (proto)
- {
- tree tmp_decl;
-
- if (! METHOD_ENCODING (proto))
- {
- tmp_decl = build_tmp_function_decl ();
- hack_method_prototype (proto, tmp_decl);
- encoding = encode_method_prototype (proto, tmp_decl);
- METHOD_ENCODING (proto) = encoding;
- }
- else
- encoding = METHOD_ENCODING (proto);
-
- return add_objc_string (encoding, meth_var_types);
- }
- else
- return build_int_2 (0, 0);
-}
-
-/* sel_ref_chain is a list whose "value" fields will be instances of
- identifier_node that represent the selector. */
-
-static tree
-build_typed_selector_reference (ident, proto)
- tree ident, proto;
-{
- tree *chain = &sel_ref_chain;
- tree expr;
- int index = 0;
-
- while (*chain)
- {
- if (TREE_PURPOSE (*chain) == ident && TREE_VALUE (*chain) == proto)
- goto return_at_index;
-
- index++;
- chain = &TREE_CHAIN (*chain);
- }
-
- *chain = perm_tree_cons (proto, ident, NULL_TREE);
-
- return_at_index:
- expr = build_unary_op (ADDR_EXPR,
- build_array_ref (UOBJC_SELECTOR_TABLE_decl,
- build_int_2 (index, 0)),
- 1);
- return build_c_cast (selector_type, expr);
-}
-
-static tree
-build_selector_reference (ident)
- tree ident;
-{
- tree *chain = &sel_ref_chain;
- tree expr;
- int index = 0;
-
- while (*chain)
- {
- if (TREE_VALUE (*chain) == ident)
- return (flag_next_runtime
- ? TREE_PURPOSE (*chain)
- : build_array_ref (UOBJC_SELECTOR_TABLE_decl,
- build_int_2 (index, 0)));
-
- index++;
- chain = &TREE_CHAIN (*chain);
- }
-
- expr = build_selector_reference_decl (ident);
-
- *chain = perm_tree_cons (expr, ident, NULL_TREE);
-
- return (flag_next_runtime
- ? expr
- : build_array_ref (UOBJC_SELECTOR_TABLE_decl,
- build_int_2 (index, 0)));
-}
-
-static tree
-build_class_reference_decl (name)
- tree name;
-{
- tree decl, ident;
- char buf[256];
- static int idx = 0;
-
- sprintf (buf, "_OBJC_CLASS_REFERENCES_%d", idx++);
-
- push_obstacks_nochange ();
- end_temporary_allocation ();
-
- ident = get_identifier (buf);
-
- decl = build_decl (VAR_DECL, ident, objc_class_type);
- DECL_EXTERNAL (decl) = 1;
- TREE_PUBLIC (decl) = 1;
- TREE_USED (decl) = 1;
- TREE_READONLY (decl) = 1;
- DECL_CONTEXT (decl) = 0;
- DECL_ARTIFICIAL (decl) = 1;
-
- make_decl_rtl (decl, 0, 1);
- pushdecl_top_level (decl);
-
- pop_obstacks ();
-
- return decl;
-}
-
-/* Create a class reference, but don't create a variable to reference
- it. */
-
-static void
-add_class_reference (ident)
- tree ident;
-{
- tree chain;
-
- if ((chain = cls_ref_chain))
- {
- tree tail;
- do
- {
- if (ident == TREE_VALUE (chain))
- return;
-
- tail = chain;
- chain = TREE_CHAIN (chain);
- }
- while (chain);
-
- /* Append to the end of the list */
- TREE_CHAIN (tail) = perm_tree_cons (NULL_TREE, ident, NULL_TREE);
- }
- else
- cls_ref_chain = perm_tree_cons (NULL_TREE, ident, NULL_TREE);
-}
-
-/* Get a class reference, creating it if necessary. Also create the
- reference variable. */
-
-tree
-get_class_reference (ident)
- tree ident;
-{
- if (flag_next_runtime)
- {
- tree *chain;
- tree decl;
-
- for (chain = &cls_ref_chain; *chain; chain = &TREE_CHAIN (*chain))
- if (TREE_VALUE (*chain) == ident)
- {
- if (! TREE_PURPOSE (*chain))
- TREE_PURPOSE (*chain) = build_class_reference_decl (ident);
-
- return TREE_PURPOSE (*chain);
- }
-
- decl = build_class_reference_decl (ident);
- *chain = perm_tree_cons (decl, ident, NULL_TREE);
- return decl;
- }
- else
- {
- tree params;
-
- add_class_reference (ident);
-
- params = build_tree_list (NULL_TREE,
- my_build_string (IDENTIFIER_LENGTH (ident) + 1,
- IDENTIFIER_POINTER (ident)));
-
- assemble_external (objc_get_class_decl);
- return build_function_call (objc_get_class_decl, params);
- }
-}
-
-/* SEL_REFDEF_CHAIN is a list whose "value" fields will be instances
- of identifier_node that represent the selector. It returns the
- offset of the selector from the beginning of the _OBJC_STRINGS
- pool. This offset is typically used by init_selector during code
- generation.
-
- For each string section we have a chain which maps identifier nodes
- to decls for the strings. */
-
-static tree
-add_objc_string (ident, section)
- tree ident;
- enum string_section section;
-{
- tree *chain, decl;
-
- if (section == class_names)
- chain = &class_names_chain;
- else if (section == meth_var_names)
- chain = &meth_var_names_chain;
- else if (section == meth_var_types)
- chain = &meth_var_types_chain;
-
- while (*chain)
- {
- if (TREE_VALUE (*chain) == ident)
- return build_unary_op (ADDR_EXPR, TREE_PURPOSE (*chain), 1);
-
- chain = &TREE_CHAIN (*chain);
- }
-
- decl = build_objc_string_decl (ident, section);
-
- *chain = perm_tree_cons (decl, ident, NULL_TREE);
-
- return build_unary_op (ADDR_EXPR, decl, 1);
-}
-
-static tree
-build_objc_string_decl (name, section)
- tree name;
- enum string_section section;
-{
- tree decl, ident;
- char buf[256];
- static int class_names_idx = 0;
- static int meth_var_names_idx = 0;
- static int meth_var_types_idx = 0;
-
- if (section == class_names)
- sprintf (buf, "_OBJC_CLASS_NAME_%d", class_names_idx++);
- else if (section == meth_var_names)
- sprintf (buf, "_OBJC_METH_VAR_NAME_%d", meth_var_names_idx++);
- else if (section == meth_var_types)
- sprintf (buf, "_OBJC_METH_VAR_TYPE_%d", meth_var_types_idx++);
-
- push_obstacks_nochange ();
- end_temporary_allocation ();
- ident = get_identifier (buf);
-
- decl = build_decl (VAR_DECL, ident, build_array_type (char_type_node, 0));
- DECL_EXTERNAL (decl) = 1;
- TREE_PUBLIC (decl) = 1;
- TREE_USED (decl) = 1;
- TREE_READONLY (decl) = 1;
- TREE_CONSTANT (decl) = 1;
- DECL_CONTEXT (decl) = 0;
- DECL_ARTIFICIAL (decl) = 1;
-
- make_decl_rtl (decl, 0, 1);
- pushdecl_top_level (decl);
-
- pop_obstacks ();
-
- return decl;
-}
-
-
-void
-objc_declare_alias (alias_ident, class_ident)
- tree alias_ident;
- tree class_ident;
-{
- if (!doing_objc_thang)
- objc_fatal ();
-
- if (is_class_name (class_ident) != class_ident)
- warning ("Cannot find class `%s'", IDENTIFIER_POINTER (class_ident));
- else if (is_class_name (alias_ident))
- warning ("Class `%s' already exists", IDENTIFIER_POINTER (alias_ident));
- else
- alias_chain = tree_cons (class_ident, alias_ident, alias_chain);
-}
-
-void
-objc_declare_class (ident_list)
- tree ident_list;
-{
- tree list;
-
- if (!doing_objc_thang)
- objc_fatal ();
-
- for (list = ident_list; list; list = TREE_CHAIN (list))
- {
- tree ident = TREE_VALUE (list);
- tree decl;
-
- if ((decl = lookup_name (ident)))
- {
- error ("`%s' redeclared as different kind of symbol",
- IDENTIFIER_POINTER (ident));
- error_with_decl (decl, "previous declaration of `%s'");
- }
-
- if (! is_class_name (ident))
- {
- tree record = xref_tag (RECORD_TYPE, ident);
- TREE_STATIC_TEMPLATE (record) = 1;
- class_chain = tree_cons (NULL_TREE, ident, class_chain);
- }
- }
-}
-
-tree
-is_class_name (ident)
- tree ident;
-{
- tree chain;
-
- if (lookup_interface (ident))
- return ident;
-
- for (chain = class_chain; chain; chain = TREE_CHAIN (chain))
- {
- if (ident == TREE_VALUE (chain))
- return ident;
- }
-
- for (chain = alias_chain; chain; chain = TREE_CHAIN (chain))
- {
- if (ident == TREE_VALUE (chain))
- return TREE_PURPOSE (chain);
- }
-
- return 0;
-}
-
-tree
-lookup_interface (ident)
- tree ident;
-{
- tree chain;
-
- for (chain = interface_chain; chain; chain = TREE_CHAIN (chain))
- {
- if (ident == CLASS_NAME (chain))
- return chain;
- }
- return NULL_TREE;
-}
-
-static tree
-objc_copy_list (list, head)
- tree list;
- tree *head;
-{
- tree newlist = NULL_TREE, tail = NULL_TREE;
-
- while (list)
- {
- tail = copy_node (list);
-
- /* The following statement fixes a bug when inheriting instance
- variables that are declared to be bitfields. finish_struct
- expects to find the width of the bitfield in DECL_INITIAL,
- which it nulls out after processing the decl of the super
- class...rather than change the way finish_struct works (which
- is risky), I create the situation it expects...s.naroff
- (7/23/89). */
-
- if (DECL_BIT_FIELD (tail) && DECL_INITIAL (tail) == 0)
- DECL_INITIAL (tail) = build_int_2 (DECL_FIELD_SIZE (tail), 0);
-
- newlist = chainon (newlist, tail);
- list = TREE_CHAIN (list);
- }
-
- *head = newlist;
- return tail;
-}
-
-/* Used by: build_private_template, get_class_ivars, and
- continue_class. COPY is 1 when called from @defs. In this case
- copy all fields. Otherwise don't copy leaf ivars since we rely on
- them being side-effected exactly once by finish_struct. */
-
-static tree
-build_ivar_chain (interface, copy)
- tree interface;
- int copy;
-{
- tree my_name, super_name, ivar_chain;
-
- my_name = CLASS_NAME (interface);
- super_name = CLASS_SUPER_NAME (interface);
-
- /* Possibly copy leaf ivars. */
- if (copy)
- objc_copy_list (CLASS_IVARS (interface), &ivar_chain);
- else
- ivar_chain = CLASS_IVARS (interface);
-
- while (super_name)
- {
- tree op1;
- tree super_interface = lookup_interface (super_name);
-
- if (!super_interface)
- {
- /* fatal did not work with 2 args...should fix */
- error ("Cannot find interface declaration for `%s', superclass of `%s'",
- IDENTIFIER_POINTER (super_name),
- IDENTIFIER_POINTER (my_name));
- exit (FATAL_EXIT_CODE);
- }
-
- if (super_interface == interface)
- {
- fatal ("Circular inheritance in interface declaration for `%s'",
- IDENTIFIER_POINTER (super_name));
- }
-
- interface = super_interface;
- my_name = CLASS_NAME (interface);
- super_name = CLASS_SUPER_NAME (interface);
-
- op1 = CLASS_IVARS (interface);
- if (op1)
- {
- tree head, tail = objc_copy_list (op1, &head);
-
- /* Prepend super class ivars...make a copy of the list, we
- do not want to alter the original. */
- TREE_CHAIN (tail) = ivar_chain;
- ivar_chain = head;
- }
- }
- return ivar_chain;
-}
-
-/* struct <classname> {
- struct objc_class *isa;
- ...
- }; */
-
-static tree
-build_private_template (class)
- tree class;
-{
- tree ivar_context;
-
- if (CLASS_STATIC_TEMPLATE (class))
- {
- uprivate_record = CLASS_STATIC_TEMPLATE (class);
- ivar_context = TYPE_FIELDS (CLASS_STATIC_TEMPLATE (class));
- }
- else
- {
- uprivate_record = start_struct (RECORD_TYPE, CLASS_NAME (class));
-
- ivar_context = build_ivar_chain (class, 0);
-
- finish_struct (uprivate_record, ivar_context, NULL_TREE);
-
- CLASS_STATIC_TEMPLATE (class) = uprivate_record;
-
- /* mark this record as class template - for class type checking */
- TREE_STATIC_TEMPLATE (uprivate_record) = 1;
- }
-
- instance_type
- = groktypename (build_tree_list (build_tree_list (NULL_TREE,
- uprivate_record),
- build1 (INDIRECT_REF, NULL_TREE,
- NULL_TREE)));
-
- return ivar_context;
-}
-
-/* Begin code generation for protocols... */
-
-/* struct objc_protocol {
- char *protocol_name;
- struct objc_protocol **protocol_list;
- struct objc_method_desc *instance_methods;
- struct objc_method_desc *class_methods;
- }; */
-
-static tree
-build_protocol_template ()
-{
- tree decl_specs, field_decl, field_decl_chain;
- tree template;
-
- template = start_struct (RECORD_TYPE, get_identifier (UTAG_PROTOCOL));
-
- /* struct objc_class *isa; */
-
- decl_specs = build_tree_list (NULL_TREE, xref_tag (RECORD_TYPE,
- get_identifier (UTAG_CLASS)));
- field_decl = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("isa"));
- field_decl
- = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE);
- field_decl_chain = field_decl;
-
- /* char *protocol_name; */
-
- decl_specs = build_tree_list (NULL_TREE, ridpointers[(int) RID_CHAR]);
- field_decl
- = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("protocol_name"));
- field_decl
- = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE);
- chainon (field_decl_chain, field_decl);
-
- /* struct objc_protocol **protocol_list; */
-
- decl_specs = build_tree_list (NULL_TREE, template);
- field_decl
- = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("protocol_list"));
- field_decl = build1 (INDIRECT_REF, NULL_TREE, field_decl);
- field_decl
- = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE);
- chainon (field_decl_chain, field_decl);
-
- /* struct objc_method_list *instance_methods; */
-
- decl_specs
- = build_tree_list (NULL_TREE,
- xref_tag (RECORD_TYPE,
- get_identifier (UTAG_METHOD_PROTOTYPE_LIST)));
- field_decl
- = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("instance_methods"));
- field_decl
- = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE);
- chainon (field_decl_chain, field_decl);
-
- /* struct objc_method_list *class_methods; */
-
- decl_specs
- = build_tree_list (NULL_TREE,
- xref_tag (RECORD_TYPE,
- get_identifier (UTAG_METHOD_PROTOTYPE_LIST)));
- field_decl
- = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("class_methods"));
- field_decl
- = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE);
- chainon (field_decl_chain, field_decl);
-
- return finish_struct (template, field_decl_chain, NULL_TREE);
-}
-
-static tree
-build_descriptor_table_initializer (type, entries)
- tree type;
- tree entries;
-{
- tree initlist = NULL_TREE;
-
- do
- {
- tree eltlist = NULL_TREE;
-
- eltlist
- = tree_cons (NULL_TREE,
- build_selector (METHOD_SEL_NAME (entries)), NULL_TREE);
- eltlist
- = tree_cons (NULL_TREE,
- add_objc_string (METHOD_ENCODING (entries),
- meth_var_types),
- eltlist);
-
- initlist
- = tree_cons (NULL_TREE,
- build_constructor (type, nreverse (eltlist)), initlist);
-
- entries = TREE_CHAIN (entries);
- }
- while (entries);
-
- return build_constructor (build_array_type (type, 0), nreverse (initlist));
-}
-
-/* struct objc_method_prototype_list {
- int count;
- struct objc_method_prototype {
- SEL name;
- char *types;
- } list[1];
- }; */
-
-static tree
-build_method_prototype_list_template (list_type, size)
- tree list_type;
- int size;
-{
- tree objc_ivar_list_record;
- tree decl_specs, field_decl, field_decl_chain;
-
- /* Generate an unnamed struct definition. */
-
- objc_ivar_list_record = start_struct (RECORD_TYPE, NULL_TREE);
-
- /* int method_count; */
-
- decl_specs = build_tree_list (NULL_TREE, ridpointers[(int) RID_INT]);
- field_decl = get_identifier ("method_count");
-
- field_decl
- = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE);
- field_decl_chain = field_decl;
-
- /* struct objc_method method_list[]; */
-
- decl_specs = build_tree_list (NULL_TREE, list_type);
- field_decl = build_nt (ARRAY_REF, get_identifier ("method_list"),
- build_int_2 (size, 0));
-
- field_decl
- = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE);
- chainon (field_decl_chain, field_decl);
-
- finish_struct (objc_ivar_list_record, field_decl_chain, NULL_TREE);
-
- return objc_ivar_list_record;
-}
-
-static tree
-build_method_prototype_template ()
-{
- tree proto_record;
- tree decl_specs, field_decl, field_decl_chain;
-
- proto_record
- = start_struct (RECORD_TYPE, get_identifier (UTAG_METHOD_PROTOTYPE));
-
-#ifdef OBJC_INT_SELECTORS
- /* unsigned int _cmd; */
- decl_specs
- = tree_cons (NULL_TREE, ridpointers[(int) RID_UNSIGNED], NULL_TREE);
- decl_specs = tree_cons (NULL_TREE, ridpointers[(int) RID_INT], decl_specs);
- field_decl = get_identifier ("_cmd");
-#else /* OBJC_INT_SELECTORS */
- /* struct objc_selector *_cmd; */
- decl_specs = tree_cons (NULL_TREE, xref_tag (RECORD_TYPE,
- get_identifier (TAG_SELECTOR)), NULL_TREE);
- field_decl = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("_cmd"));
-#endif /* OBJC_INT_SELECTORS */
-
- field_decl
- = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE);
- field_decl_chain = field_decl;
-
- decl_specs = tree_cons (NULL_TREE, ridpointers[(int) RID_CHAR], NULL_TREE);
- field_decl
- = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("method_types"));
- field_decl
- = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE);
- chainon (field_decl_chain, field_decl);
-
- finish_struct (proto_record, field_decl_chain, NULL_TREE);
-
- return proto_record;
-}
-
-/* True if last call to forwarding_offset yielded a register offset. */
-static int offset_is_register;
-
-static int
-forwarding_offset (parm)
- tree parm;
-{
- int offset_in_bytes;
-
- if (GET_CODE (DECL_INCOMING_RTL (parm)) == MEM)
- {
- rtx addr = XEXP (DECL_INCOMING_RTL (parm), 0);
-
- /* ??? Here we assume that the parm address is indexed
- off the frame pointer or arg pointer.
- If that is not true, we produce meaningless results,
- but do not crash. */
- if (GET_CODE (addr) == PLUS
- && GET_CODE (XEXP (addr, 1)) == CONST_INT)
- offset_in_bytes = INTVAL (XEXP (addr, 1));
- else
- offset_in_bytes = 0;
-
- offset_in_bytes += OBJC_FORWARDING_STACK_OFFSET;
- offset_is_register = 0;
- }
- else if (GET_CODE (DECL_INCOMING_RTL (parm)) == REG)
- {
- int regno = REGNO (DECL_INCOMING_RTL (parm));
- offset_in_bytes = apply_args_register_offset (regno);
- offset_is_register = 1;
- }
- else
- return 0;
-
- /* This is the case where the parm is passed as an int or double
- and it is converted to a char, short or float and stored back
- in the parmlist. In this case, describe the parm
- with the variable's declared type, and adjust the address
- if the least significant bytes (which we are using) are not
- the first ones. */
- if (BYTES_BIG_ENDIAN && TREE_TYPE (parm) != DECL_ARG_TYPE (parm))
- offset_in_bytes += (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parm)))
- - GET_MODE_SIZE (GET_MODE (DECL_RTL (parm))));
-
- return offset_in_bytes;
-}
-
-static tree
-encode_method_prototype (method_decl, func_decl)
- tree method_decl;
- tree func_decl;
-{
- tree parms;
- int stack_size, i;
- tree user_args;
- int max_parm_end = 0;
- char buf[40];
- tree result;
-
- /* ONEWAY and BYCOPY, for remote object are the only method qualifiers. */
- encode_type_qualifiers (TREE_PURPOSE (TREE_TYPE (method_decl)));
-
- /* C type. */
- encode_type (TREE_TYPE (TREE_TYPE (func_decl)),
- obstack_object_size (&util_obstack),
- OBJC_ENCODE_INLINE_DEFS);
-
- /* Stack size. */
- for (parms = DECL_ARGUMENTS (func_decl); parms;
- parms = TREE_CHAIN (parms))
- {
- int parm_end = (forwarding_offset (parms)
- + (TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (parms)))
- / BITS_PER_UNIT));
-
- if (!offset_is_register && max_parm_end < parm_end)
- max_parm_end = parm_end;
- }
-
- stack_size = max_parm_end - OBJC_FORWARDING_MIN_OFFSET;
-
- sprintf (buf, "%d", stack_size);
- obstack_grow (&util_obstack, buf, strlen (buf));
-
- user_args = METHOD_SEL_ARGS (method_decl);
-
- /* Argument types. */
- for (parms = DECL_ARGUMENTS (func_decl), i = 0; parms;
- parms = TREE_CHAIN (parms), i++)
- {
- /* Process argument qualifiers for user supplied arguments. */
- if (i > 1)
- {
- encode_type_qualifiers (TREE_PURPOSE (TREE_TYPE (user_args)));
- user_args = TREE_CHAIN (user_args);
- }
-
- /* Type. */
- encode_type (TREE_TYPE (parms),
- obstack_object_size (&util_obstack),
- OBJC_ENCODE_INLINE_DEFS);
-
- /* Compute offset. */
- sprintf (buf, "%d", forwarding_offset (parms));
-
- /* Indicate register. */
- if (offset_is_register)
- obstack_1grow (&util_obstack, '+');
-
- obstack_grow (&util_obstack, buf, strlen (buf));
- }
-
- obstack_1grow (&util_obstack, '\0');
- result = get_identifier (obstack_finish (&util_obstack));
- obstack_free (&util_obstack, util_firstobj);
- return result;
-}
-
-static tree
-generate_descriptor_table (type, name, size, list, proto)
- tree type;
- char *name;
- int size;
- tree list;
- tree proto;
-{
- tree sc_spec, decl_specs, decl, initlist;
-
- sc_spec = tree_cons (NULL_TREE, ridpointers[(int) RID_STATIC], NULL_TREE);
- decl_specs = tree_cons (NULL_TREE, type, sc_spec);
-
- decl = start_decl (synth_id_with_class_suffix (name, proto),
- decl_specs, 1, NULL_TREE, NULL_TREE);
-
- initlist = build_tree_list (NULL_TREE, build_int_2 (size, 0));
- initlist = tree_cons (NULL_TREE, list, initlist);
-
- finish_decl (decl, build_constructor (type, nreverse (initlist)),
- NULL_TREE);
-
- return decl;
-}
-
-static void
-generate_method_descriptors (protocol) /* generate_dispatch_tables */
- tree protocol;
-{
- static tree objc_method_prototype_template;
- tree initlist, chain, method_list_template;
- tree cast, variable_length_type;
- int size;
-
- if (!objc_method_prototype_template)
- objc_method_prototype_template = build_method_prototype_template ();
-
- cast = build_tree_list (build_tree_list (NULL_TREE, xref_tag (RECORD_TYPE,
- get_identifier (UTAG_METHOD_PROTOTYPE_LIST))),
- NULL_TREE);
- variable_length_type = groktypename (cast);
-
- chain = PROTOCOL_CLS_METHODS (protocol);
- if (chain)
- {
- size = list_length (chain);
-
- method_list_template
- = build_method_prototype_list_template (objc_method_prototype_template,
- size);
-
- initlist
- = build_descriptor_table_initializer (objc_method_prototype_template,
- chain);
-
- UOBJC_CLASS_METHODS_decl
- = generate_descriptor_table (method_list_template,
- "_OBJC_PROTOCOL_CLASS_METHODS",
- size, initlist, protocol);
- TREE_TYPE (UOBJC_CLASS_METHODS_decl) = variable_length_type;
- }
- else
- UOBJC_CLASS_METHODS_decl = 0;
-
- chain = PROTOCOL_NST_METHODS (protocol);
- if (chain)
- {
- size = list_length (chain);
-
- method_list_template
- = build_method_prototype_list_template (objc_method_prototype_template,
- size);
- initlist
- = build_descriptor_table_initializer (objc_method_prototype_template,
- chain);
-
- UOBJC_INSTANCE_METHODS_decl
- = generate_descriptor_table (method_list_template,
- "_OBJC_PROTOCOL_INSTANCE_METHODS",
- size, initlist, protocol);
- TREE_TYPE (UOBJC_INSTANCE_METHODS_decl) = variable_length_type;
- }
- else
- UOBJC_INSTANCE_METHODS_decl = 0;
-}
-
-static tree
-build_tmp_function_decl ()
-{
- tree decl_specs, expr_decl, parms;
- static int xxx = 0;
- char buffer[80];
-
- /* struct objc_object *objc_xxx (id, SEL, ...); */
- pushlevel (0);
- decl_specs = build_tree_list (NULL_TREE, objc_object_reference);
- push_parm_decl (build_tree_list
- (build_tree_list (decl_specs,
- build1 (INDIRECT_REF, NULL_TREE,
- NULL_TREE)),
- build_tree_list (NULL_TREE, NULL_TREE)));
-
- decl_specs = build_tree_list (NULL_TREE, xref_tag (RECORD_TYPE,
- get_identifier (TAG_SELECTOR)));
- expr_decl = build1 (INDIRECT_REF, NULL_TREE, NULL_TREE);
-
- push_parm_decl (build_tree_list (build_tree_list (decl_specs, expr_decl),
- build_tree_list (NULL_TREE, NULL_TREE)));
- parms = get_parm_info (0);
- poplevel (0, 0, 0);
-
- decl_specs = build_tree_list (NULL_TREE, objc_object_reference);
- sprintf (buffer, "__objc_tmp_%x", xxx++);
- expr_decl = build_nt (CALL_EXPR, get_identifier (buffer), parms, NULL_TREE);
- expr_decl = build1 (INDIRECT_REF, NULL_TREE, expr_decl);
-
- return define_decl (expr_decl, decl_specs);
-}
-
-static void
-hack_method_prototype (nst_methods, tmp_decl)
- tree nst_methods;
- tree tmp_decl;
-{
- tree parms;
- tree parm;
-
- /* Hack to avoid problem with static typing of self arg. */
- TREE_SET_CODE (nst_methods, CLASS_METHOD_DECL);
- start_method_def (nst_methods);
- TREE_SET_CODE (nst_methods, INSTANCE_METHOD_DECL);
-
- if (METHOD_ADD_ARGS (nst_methods) == (tree) 1)
- parms = get_parm_info (0); /* we have a `, ...' */
- else
- parms = get_parm_info (1); /* place a `void_at_end' */
-
- poplevel (0, 0, 0); /* Must be called BEFORE start_function. */
-
- /* Usually called from store_parm_decls -> init_function_start. */
-
- DECL_ARGUMENTS (tmp_decl) = TREE_PURPOSE (parms);
- current_function_decl = tmp_decl;
-
- {
- /* Code taken from start_function. */
- tree restype = TREE_TYPE (TREE_TYPE (tmp_decl));
- /* Promote the value to int before returning it. */
- if (TREE_CODE (restype) == INTEGER_TYPE
- && TYPE_PRECISION (restype) < TYPE_PRECISION (integer_type_node))
- restype = integer_type_node;
- DECL_RESULT (tmp_decl) = build_decl (RESULT_DECL, 0, restype);
- }
-
- for (parm = DECL_ARGUMENTS (tmp_decl); parm; parm = TREE_CHAIN (parm))
- DECL_CONTEXT (parm) = tmp_decl;
-
- init_function_start (tmp_decl, "objc-act", 0);
-
- /* Typically called from expand_function_start for function definitions. */
- assign_parms (tmp_decl, 0);
-
- /* install return type */
- TREE_TYPE (TREE_TYPE (tmp_decl)) = groktypename (TREE_TYPE (nst_methods));
-
-}
-
-static void
-generate_protocol_references (plist)
- tree plist;
-{
- tree lproto;
-
- /* Forward declare protocols referenced. */
- for (lproto = plist; lproto; lproto = TREE_CHAIN (lproto))
- {
- tree proto = TREE_VALUE (lproto);
-
- if (TREE_CODE (proto) == PROTOCOL_INTERFACE_TYPE
- && PROTOCOL_NAME (proto))
- {
- if (! PROTOCOL_FORWARD_DECL (proto))
- build_protocol_reference (proto);
-
- if (PROTOCOL_LIST (proto))
- generate_protocol_references (PROTOCOL_LIST (proto));
- }
- }
-}
-
-static void
-generate_protocols ()
-{
- tree p, tmp_decl, encoding;
- tree sc_spec, decl_specs, decl;
- tree initlist, protocol_name_expr, refs_decl, refs_expr;
- tree cast_type2 = 0;
-
- tmp_decl = build_tmp_function_decl ();
-
- if (! objc_protocol_template)
- objc_protocol_template = build_protocol_template ();
-
- /* If a protocol was directly referenced, pull in indirect references. */
- for (p = protocol_chain; p; p = TREE_CHAIN (p))
- if (PROTOCOL_FORWARD_DECL (p) && PROTOCOL_LIST (p))
- generate_protocol_references (PROTOCOL_LIST (p));
-
- for (p = protocol_chain; p; p = TREE_CHAIN (p))
- {
- tree nst_methods = PROTOCOL_NST_METHODS (p);
- tree cls_methods = PROTOCOL_CLS_METHODS (p);
-
- /* If protocol wasn't referenced, don't generate any code. */
- if (! PROTOCOL_FORWARD_DECL (p))
- continue;
-
- /* Make sure we link in the Protocol class. */
- add_class_reference (get_identifier (PROTOCOL_OBJECT_CLASS_NAME));
-
- while (nst_methods)
- {
- if (! METHOD_ENCODING (nst_methods))
- {
- hack_method_prototype (nst_methods, tmp_decl);
- encoding = encode_method_prototype (nst_methods, tmp_decl);
- METHOD_ENCODING (nst_methods) = encoding;
- }
- nst_methods = TREE_CHAIN (nst_methods);
- }
-
- while (cls_methods)
- {
- if (! METHOD_ENCODING (cls_methods))
- {
- hack_method_prototype (cls_methods, tmp_decl);
- encoding = encode_method_prototype (cls_methods, tmp_decl);
- METHOD_ENCODING (cls_methods) = encoding;
- }
-
- cls_methods = TREE_CHAIN (cls_methods);
- }
- generate_method_descriptors (p);
-
- if (PROTOCOL_LIST (p))
- refs_decl = generate_protocol_list (p);
- else
- refs_decl = 0;
-
- /* static struct objc_protocol _OBJC_PROTOCOL_<mumble>; */
-
- sc_spec = tree_cons (NULL_TREE, ridpointers[(int) RID_STATIC],
- NULL_TREE);
- decl_specs = tree_cons (NULL_TREE, objc_protocol_template, sc_spec);
-
- decl = start_decl (synth_id_with_class_suffix ("_OBJC_PROTOCOL", p),
- decl_specs, 1, NULL_TREE, NULL_TREE);
-
- protocol_name_expr = add_objc_string (PROTOCOL_NAME (p), class_names);
-
- if (refs_decl)
- {
- if (!cast_type2)
- cast_type2
- = groktypename
- (build_tree_list (build_tree_list (NULL_TREE,
- objc_protocol_template),
- build1 (INDIRECT_REF, NULL_TREE,
- build1 (INDIRECT_REF, NULL_TREE,
- NULL_TREE))));
-
- refs_expr = build_unary_op (ADDR_EXPR, refs_decl, 0);
- TREE_TYPE (refs_expr) = cast_type2;
- }
- else
- refs_expr = build_int_2 (0, 0);
-
- /* UOBJC_INSTANCE_METHODS_decl/UOBJC_CLASS_METHODS_decl are set
- by generate_method_descriptors, which is called above. */
- initlist = build_protocol_initializer (TREE_TYPE (decl),
- protocol_name_expr, refs_expr,
- UOBJC_INSTANCE_METHODS_decl,
- UOBJC_CLASS_METHODS_decl);
- finish_decl (decl, initlist, NULL_TREE);
-
- /* Mark the decl as used to avoid "defined but not used" warning. */
- TREE_USED (decl) = 1;
- }
-}
-
-static tree
-build_protocol_initializer (type, protocol_name, protocol_list,
- instance_methods, class_methods)
- tree type;
- tree protocol_name;
- tree protocol_list;
- tree instance_methods;
- tree class_methods;
-{
- tree initlist = NULL_TREE, expr;
- static tree cast_type = 0;
-
- if (!cast_type)
- cast_type
- = groktypename
- (build_tree_list
- (build_tree_list (NULL_TREE,
- xref_tag (RECORD_TYPE,
- get_identifier (UTAG_CLASS))),
- build1 (INDIRECT_REF, NULL_TREE, NULL_TREE)));
-
- /* Filling the "isa" in with one allows the runtime system to
- detect that the version change...should remove before final release. */
-
- expr = build_int_2 (PROTOCOL_VERSION, 0);
- TREE_TYPE (expr) = cast_type;
- initlist = tree_cons (NULL_TREE, expr, initlist);
- initlist = tree_cons (NULL_TREE, protocol_name, initlist);
- initlist = tree_cons (NULL_TREE, protocol_list, initlist);
-
- if (!instance_methods)
- initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist);
- else
- {
- expr = build_unary_op (ADDR_EXPR, instance_methods, 0);
- initlist = tree_cons (NULL_TREE, expr, initlist);
- }
-
- if (!class_methods)
- initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist);
- else
- {
- expr = build_unary_op (ADDR_EXPR, class_methods, 0);
- initlist = tree_cons (NULL_TREE, expr, initlist);
- }
-
- return build_constructor (type, nreverse (initlist));
-}
-
-/* struct objc_category {
- char *category_name;
- char *class_name;
- struct objc_method_list *instance_methods;
- struct objc_method_list *class_methods;
- struct objc_protocol_list *protocols;
- }; */
-
-static void
-build_category_template ()
-{
- tree decl_specs, field_decl, field_decl_chain;
-
- objc_category_template = start_struct (RECORD_TYPE,
- get_identifier (UTAG_CATEGORY));
- /* char *category_name; */
-
- decl_specs = build_tree_list (NULL_TREE, ridpointers[(int) RID_CHAR]);
- field_decl
- = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("category_name"));
- field_decl
- = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE);
- field_decl_chain = field_decl;
-
- /* char *class_name; */
-
- decl_specs = build_tree_list (NULL_TREE, ridpointers[(int) RID_CHAR]);
- field_decl = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("class_name"));
- field_decl
- = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE);
- chainon (field_decl_chain, field_decl);
-
- /* struct objc_method_list *instance_methods; */
-
- decl_specs = build_tree_list (NULL_TREE,
- xref_tag (RECORD_TYPE,
- get_identifier (UTAG_METHOD_LIST)));
- field_decl
- = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("instance_methods"));
- field_decl
- = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE);
- chainon (field_decl_chain, field_decl);
-
- /* struct objc_method_list *class_methods; */
-
- decl_specs = build_tree_list (NULL_TREE,
- xref_tag (RECORD_TYPE,
- get_identifier (UTAG_METHOD_LIST)));
- field_decl
- = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("class_methods"));
- field_decl
- = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE);
- chainon (field_decl_chain, field_decl);
-
- /* struct objc_protocol **protocol_list; */
-
- decl_specs = build_tree_list (NULL_TREE,
- xref_tag (RECORD_TYPE,
- get_identifier (UTAG_PROTOCOL)));
- field_decl
- = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("protocol_list"));
- field_decl = build1 (INDIRECT_REF, NULL_TREE, field_decl);
- field_decl
- = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE);
- chainon (field_decl_chain, field_decl);
-
- finish_struct (objc_category_template, field_decl_chain, NULL_TREE);
-}
-
-/* struct objc_selector {
- void *sel_id;
- char *sel_type;
- }; */
-
-static void
-build_selector_template ()
-{
-
- tree decl_specs, field_decl, field_decl_chain;
-
- objc_selector_template
- = start_struct (RECORD_TYPE, get_identifier (UTAG_SELECTOR));
-
- /* void *sel_id; */
-
- decl_specs = build_tree_list (NULL_TREE, ridpointers[(int) RID_VOID]);
- field_decl = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("sel_id"));
- field_decl
- = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE);
- field_decl_chain = field_decl;
-
- /* char *sel_type; */
-
- decl_specs = build_tree_list (NULL_TREE, ridpointers[(int) RID_CHAR]);
- field_decl = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("sel_type"));
- field_decl
- = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE);
- chainon (field_decl_chain, field_decl);
-
- finish_struct (objc_selector_template, field_decl_chain, NULL_TREE);
-}
-
-/* struct objc_class {
- struct objc_class *isa;
- struct objc_class *super_class;
- char *name;
- long version;
- long info;
- long instance_size;
- struct objc_ivar_list *ivars;
- struct objc_method_list *methods;
- if (flag_next_runtime)
- struct objc_cache *cache;
- else {
- struct sarray *dtable;
- struct objc_class *subclass_list;
- struct objc_class *sibling_class;
- }
- struct objc_protocol_list *protocols;
- }; */
-
-static void
-build_class_template ()
-{
- tree decl_specs, field_decl, field_decl_chain;
-
- objc_class_template
- = start_struct (RECORD_TYPE, get_identifier (UTAG_CLASS));
-
- /* struct objc_class *isa; */
-
- decl_specs = build_tree_list (NULL_TREE, objc_class_template);
- field_decl = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("isa"));
- field_decl
- = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE);
- field_decl_chain = field_decl;
-
- /* struct objc_class *super_class; */
-
- decl_specs = build_tree_list (NULL_TREE, objc_class_template);
- field_decl
- = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("super_class"));
- field_decl
- = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE);
- chainon (field_decl_chain, field_decl);
-
- /* char *name; */
-
- decl_specs = build_tree_list (NULL_TREE, ridpointers[(int) RID_CHAR]);
- field_decl = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("name"));
- field_decl
- = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE);
- chainon (field_decl_chain, field_decl);
-
- /* long version; */
-
- decl_specs = build_tree_list (NULL_TREE, ridpointers[(int) RID_LONG]);
- field_decl = get_identifier ("version");
- field_decl
- = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE);
- chainon (field_decl_chain, field_decl);
-
- /* long info; */
-
- decl_specs = build_tree_list (NULL_TREE, ridpointers[(int) RID_LONG]);
- field_decl = get_identifier ("info");
- field_decl
- = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE);
- chainon (field_decl_chain, field_decl);
-
- /* long instance_size; */
-
- decl_specs = build_tree_list (NULL_TREE, ridpointers[(int) RID_LONG]);
- field_decl = get_identifier ("instance_size");
- field_decl
- = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE);
- chainon (field_decl_chain, field_decl);
-
- /* struct objc_ivar_list *ivars; */
-
- decl_specs = build_tree_list (NULL_TREE,
- xref_tag (RECORD_TYPE,
- get_identifier (UTAG_IVAR_LIST)));
- field_decl = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("ivars"));
- field_decl
- = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE);
- chainon (field_decl_chain, field_decl);
-
- /* struct objc_method_list *methods; */
-
- decl_specs = build_tree_list (NULL_TREE,
- xref_tag (RECORD_TYPE,
- get_identifier (UTAG_METHOD_LIST)));
- field_decl = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("methods"));
- field_decl
- = grokfield (input_filename, lineno, field_decl, decl_specs, NULL_TREE);
- chainon (field_decl_chain, field_decl);
-
- if (flag_next_runtime)
- {
- /* struct objc_cache *cache; */
-
- decl_specs = build_tree_list (NULL_TREE,
- xref_tag (RECORD_TYPE,
- get_identifier ("objc_cache")));
- field_decl = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("cache"));
- field_decl = grokfield (input_filename, lineno, field_decl,
- decl_specs, NULL_TREE);
- chainon (field_decl_chain, field_decl);
- }
- else
- {
- /* struct sarray *dtable; */
-
- decl_specs = build_tree_list (NULL_TREE,
- xref_tag (RECORD_TYPE,
- get_identifier ("sarray")));
- field_decl = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("dtable"));
- field_decl = grokfield (input_filename, lineno, field_decl,
- decl_specs, NULL_TREE);
- chainon (field_decl_chain, field_decl);
-
- /* struct objc_class *subclass_list; */
-
- decl_specs = build_tree_list (NULL_TREE, objc_class_template);
- field_decl
- = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("subclass_list"));
- field_decl = grokfield (input_filename, lineno, field_decl,
- decl_specs, NULL_TREE);
- chainon (field_decl_chain, field_decl);
-
- /* struct objc_class *sibling_class; */
-
- decl_specs = build_tree_list (NULL_TREE, objc_class_template);
- field_decl
- = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("sibling_class"));
- field_decl = grokfield (input_filename, lineno, field_decl,
- decl_specs, NULL_TREE);
- chainon (field_decl_chain, field_decl);
- }
-
- /* struct objc_protocol **protocol_list; */
-
- decl_specs = build_tree_list (NULL_TREE,
- xref_tag (RECORD_TYPE,
- get_identifier (UTAG_PROTOCOL)));
- field_decl
- = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("protocol_list"));
- field_decl
- = build1 (INDIRECT_REF, NULL_TREE, field_decl);
- field_decl = grokfield (input_filename, lineno, field_decl,
- decl_specs, NULL_TREE);
- chainon (field_decl_chain, field_decl);
-
-
- finish_struct (objc_class_template, field_decl_chain, NULL_TREE);
-}
-
-/* Generate appropriate forward declarations for an implementation. */
-
-static void
-synth_forward_declarations ()
-{
- tree sc_spec, decl_specs, an_id;
-
- /* extern struct objc_class _OBJC_CLASS_<my_name>; */
-
- an_id = synth_id_with_class_suffix ("_OBJC_CLASS", implementation_context);
-
- sc_spec = build_tree_list (NULL_TREE, ridpointers[(int) RID_EXTERN]);
- decl_specs = tree_cons (NULL_TREE, objc_class_template, sc_spec);
- UOBJC_CLASS_decl = define_decl (an_id, decl_specs);
- TREE_USED (UOBJC_CLASS_decl) = 1;
- DECL_ARTIFICIAL (UOBJC_CLASS_decl) = 1;
-
- /* extern struct objc_class _OBJC_METACLASS_<my_name>; */
-
- an_id = synth_id_with_class_suffix ("_OBJC_METACLASS",
- implementation_context);
-
- UOBJC_METACLASS_decl = define_decl (an_id, decl_specs);
- TREE_USED (UOBJC_METACLASS_decl) = 1;
- DECL_ARTIFICIAL(UOBJC_METACLASS_decl) = 1;
-
- /* Pre-build the following entities - for speed/convenience. */
-
- an_id = get_identifier ("super_class");
- ucls_super_ref = build_component_ref (UOBJC_CLASS_decl, an_id);
- uucls_super_ref = build_component_ref (UOBJC_METACLASS_decl, an_id);
-}
-
-static void
-error_with_ivar (message, decl, rawdecl)
- char *message;
- tree decl;
- tree rawdecl;
-{
- count_error (0);
-
- report_error_function (DECL_SOURCE_FILE (decl));
-
- fprintf (stderr, "%s:%d: ",
- DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
- bzero (errbuf, BUFSIZE);
- fprintf (stderr, "%s `%s'\n", message, gen_declaration (rawdecl, errbuf));
-}
-
-#define USERTYPE(t) \
- (TREE_CODE (t) == RECORD_TYPE || TREE_CODE (t) == UNION_TYPE \
- || TREE_CODE (t) == ENUMERAL_TYPE)
-
-static void
-check_ivars (inter, imp)
- tree inter;
- tree imp;
-{
- tree intdecls = CLASS_IVARS (inter);
- tree impdecls = CLASS_IVARS (imp);
- tree rawintdecls = CLASS_RAW_IVARS (inter);
- tree rawimpdecls = CLASS_RAW_IVARS (imp);
-
- while (1)
- {
- tree t1, t2;
-
- if (intdecls == 0 && impdecls == 0)
- break;
- if (intdecls == 0 || impdecls == 0)
- {
- error ("inconsistent instance variable specification");
- break;
- }
-
- t1 = TREE_TYPE (intdecls); t2 = TREE_TYPE (impdecls);
-
- if (!comptypes (t1, t2))
- {
- if (DECL_NAME (intdecls) == DECL_NAME (impdecls))
- {
- error_with_ivar ("conflicting instance variable type",
- impdecls, rawimpdecls);
- error_with_ivar ("previous declaration of",
- intdecls, rawintdecls);
- }
- else /* both the type and the name don't match */
- {
- error ("inconsistent instance variable specification");
- break;
- }
- }
-
- else if (DECL_NAME (intdecls) != DECL_NAME (impdecls))
- {
- error_with_ivar ("conflicting instance variable name",
- impdecls, rawimpdecls);
- error_with_ivar ("previous declaration of",
- intdecls, rawintdecls);
- }
-
- intdecls = TREE_CHAIN (intdecls);
- impdecls = TREE_CHAIN (impdecls);
- rawintdecls = TREE_CHAIN (rawintdecls);
- rawimpdecls = TREE_CHAIN (rawimpdecls);
- }
-}
-
-/* Set super_type to the data type node for struct objc_super *,
- first defining struct objc_super itself.
- This needs to be done just once per compilation. */
-
-static tree
-build_super_template ()
-{
- tree record, decl_specs, field_decl, field_decl_chain;
-
- record = start_struct (RECORD_TYPE, get_identifier (UTAG_SUPER));
-
- /* struct objc_object *self; */
-
- decl_specs = build_tree_list (NULL_TREE, objc_object_reference);
- field_decl = get_identifier ("self");
- field_decl = build1 (INDIRECT_REF, NULL_TREE, field_decl);
- field_decl = grokfield (input_filename, lineno,
- field_decl, decl_specs, NULL_TREE);
- field_decl_chain = field_decl;
-
- /* struct objc_class *class; */
-
- decl_specs = get_identifier (UTAG_CLASS);
- decl_specs = build_tree_list (NULL_TREE, xref_tag (RECORD_TYPE, decl_specs));
- field_decl = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("class"));
-
- field_decl = grokfield (input_filename, lineno,
- field_decl, decl_specs, NULL_TREE);
- chainon (field_decl_chain, field_decl);
-
- finish_struct (record, field_decl_chain, NULL_TREE);
-
- /* `struct objc_super *' */
- super_type = groktypename (build_tree_list (build_tree_list (NULL_TREE,
- record),
- build1 (INDIRECT_REF,
- NULL_TREE, NULL_TREE)));
- return record;
-}
-
-/* struct objc_ivar {
- char *ivar_name;
- char *ivar_type;
- int ivar_offset;
- }; */
-
-static tree
-build_ivar_template ()
-{
- tree objc_ivar_id, objc_ivar_record;
- tree decl_specs, field_decl, field_decl_chain;
-
- objc_ivar_id = get_identifier (UTAG_IVAR);
- objc_ivar_record = start_struct (RECORD_TYPE, objc_ivar_id);
-
- /* char *ivar_name; */
-
- decl_specs = build_tree_list (NULL_TREE, ridpointers[(int) RID_CHAR]);
- field_decl = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("ivar_name"));
-
- field_decl = grokfield (input_filename, lineno, field_decl,
- decl_specs, NULL_TREE);
- field_decl_chain = field_decl;
-
- /* char *ivar_type; */
-
- decl_specs = build_tree_list (NULL_TREE, ridpointers[(int) RID_CHAR]);
- field_decl = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("ivar_type"));
-
- field_decl = grokfield (input_filename, lineno, field_decl,
- decl_specs, NULL_TREE);
- chainon (field_decl_chain, field_decl);
-
- /* int ivar_offset; */
-
- decl_specs = build_tree_list (NULL_TREE, ridpointers[(int) RID_INT]);
- field_decl = get_identifier ("ivar_offset");
-
- field_decl = grokfield (input_filename, lineno, field_decl,
- decl_specs, NULL_TREE);
- chainon (field_decl_chain, field_decl);
-
- finish_struct (objc_ivar_record, field_decl_chain, NULL_TREE);
-
- return objc_ivar_record;
-}
-
-/* struct {
- int ivar_count;
- struct objc_ivar ivar_list[ivar_count];
- }; */
-
-static tree
-build_ivar_list_template (list_type, size)
- tree list_type;
- int size;
-{
- tree objc_ivar_list_record;
- tree decl_specs, field_decl, field_decl_chain;
-
- objc_ivar_list_record = start_struct (RECORD_TYPE, NULL_TREE);
-
- /* int ivar_count; */
-
- decl_specs = build_tree_list (NULL_TREE, ridpointers[(int) RID_INT]);
- field_decl = get_identifier ("ivar_count");
-
- field_decl = grokfield (input_filename, lineno, field_decl,
- decl_specs, NULL_TREE);
- field_decl_chain = field_decl;
-
- /* struct objc_ivar ivar_list[]; */
-
- decl_specs = build_tree_list (NULL_TREE, list_type);
- field_decl = build_nt (ARRAY_REF, get_identifier ("ivar_list"),
- build_int_2 (size, 0));
-
- field_decl = grokfield (input_filename, lineno,
- field_decl, decl_specs, NULL_TREE);
- chainon (field_decl_chain, field_decl);
-
- finish_struct (objc_ivar_list_record, field_decl_chain, NULL_TREE);
-
- return objc_ivar_list_record;
-}
-
-/* struct {
- int method_next;
- int method_count;
- struct objc_method method_list[method_count];
- }; */
-
-static tree
-build_method_list_template (list_type, size)
- tree list_type;
- int size;
-{
- tree objc_ivar_list_record;
- tree decl_specs, field_decl, field_decl_chain;
-
- objc_ivar_list_record = start_struct (RECORD_TYPE, NULL_TREE);
-
- /* int method_next; */
-
- decl_specs
- = build_tree_list
- (NULL_TREE,
- xref_tag (RECORD_TYPE,
- get_identifier (UTAG_METHOD_PROTOTYPE_LIST)));
- field_decl
- = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("method_next"));
- field_decl = grokfield (input_filename, lineno, field_decl,
- decl_specs, NULL_TREE);
- field_decl_chain = field_decl;
-
- /* int method_count; */
-
- decl_specs = build_tree_list (NULL_TREE, ridpointers[(int) RID_INT]);
- field_decl = get_identifier ("method_count");
-
- field_decl = grokfield (input_filename, lineno,
- field_decl, decl_specs, NULL_TREE);
- chainon (field_decl_chain, field_decl);
-
- /* struct objc_method method_list[]; */
-
- decl_specs = build_tree_list (NULL_TREE, list_type);
- field_decl = build_nt (ARRAY_REF, get_identifier ("method_list"),
- build_int_2 (size, 0));
-
- field_decl = grokfield (input_filename, lineno,
- field_decl, decl_specs, NULL_TREE);
- chainon (field_decl_chain, field_decl);
-
- finish_struct (objc_ivar_list_record, field_decl_chain, NULL_TREE);
-
- return objc_ivar_list_record;
-}
-
-static tree
-build_ivar_list_initializer (type, field_decl)
- tree type;
- tree field_decl;
-{
- tree initlist = NULL_TREE;
-
- do
- {
- tree ivar = NULL_TREE;
-
- /* Set name. */
- if (DECL_NAME (field_decl))
- ivar = tree_cons (NULL_TREE,
- add_objc_string (DECL_NAME (field_decl),
- meth_var_names),
- ivar);
- else
- /* Unnamed bit-field ivar (yuck). */
- ivar = tree_cons (NULL_TREE, build_int_2 (0, 0), ivar);
-
- /* Set type. */
- encode_field_decl (field_decl,
- obstack_object_size (&util_obstack),
- OBJC_ENCODE_DONT_INLINE_DEFS);
-
- /* Null terminate string. */
- obstack_1grow (&util_obstack, 0);
- ivar
- = tree_cons
- (NULL_TREE,
- add_objc_string (get_identifier (obstack_finish (&util_obstack)),
- meth_var_types),
- ivar);
- obstack_free (&util_obstack, util_firstobj);
-
- /* set offset */
- ivar
- = tree_cons
- (NULL_TREE,
- build_int_2 ((TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field_decl))
- / BITS_PER_UNIT),
- 0),
- ivar);
-
- initlist = tree_cons (NULL_TREE,
- build_constructor (type, nreverse (ivar)),
- initlist);
-
- field_decl = TREE_CHAIN (field_decl);
- }
- while (field_decl);
-
- return build_constructor (build_array_type (type, 0), nreverse (initlist));
-}
-
-static tree
-generate_ivars_list (type, name, size, list)
- tree type;
- char *name;
- int size;
- tree list;
-{
- tree sc_spec, decl_specs, decl, initlist;
-
- sc_spec = tree_cons (NULL_TREE, ridpointers[(int) RID_STATIC], NULL_TREE);
- decl_specs = tree_cons (NULL_TREE, type, sc_spec);
-
- decl = start_decl (synth_id_with_class_suffix (name, implementation_context),
- decl_specs, 1, NULL_TREE, NULL_TREE);
-
- initlist = build_tree_list (NULL_TREE, build_int_2 (size, 0));
- initlist = tree_cons (NULL_TREE, list, initlist);
-
- finish_decl (decl,
- build_constructor (TREE_TYPE (decl), nreverse (initlist)),
- NULL_TREE);
-
- return decl;
-}
-
-static void
-generate_ivar_lists ()
-{
- tree initlist, ivar_list_template, chain;
- tree cast, variable_length_type;
- int size;
-
- generating_instance_variables = 1;
-
- if (!objc_ivar_template)
- objc_ivar_template = build_ivar_template ();
-
- cast
- = build_tree_list
- (build_tree_list (NULL_TREE, xref_tag (RECORD_TYPE,
- get_identifier (UTAG_IVAR_LIST))),
- NULL_TREE);
- variable_length_type = groktypename (cast);
-
- /* Only generate class variables for the root of the inheritance
- hierarchy since these will be the same for every class. */
-
- if (CLASS_SUPER_NAME (implementation_template) == NULL_TREE
- && (chain = TYPE_FIELDS (objc_class_template)))
- {
- size = list_length (chain);
-
- ivar_list_template = build_ivar_list_template (objc_ivar_template, size);
- initlist = build_ivar_list_initializer (objc_ivar_template, chain);
-
- UOBJC_CLASS_VARIABLES_decl
- = generate_ivars_list (ivar_list_template, "_OBJC_CLASS_VARIABLES",
- size, initlist);
- TREE_TYPE (UOBJC_CLASS_VARIABLES_decl) = variable_length_type;
- }
- else
- UOBJC_CLASS_VARIABLES_decl = 0;
-
- chain = CLASS_IVARS (implementation_template);
- if (chain)
- {
- size = list_length (chain);
- ivar_list_template = build_ivar_list_template (objc_ivar_template, size);
- initlist = build_ivar_list_initializer (objc_ivar_template, chain);
-
- UOBJC_INSTANCE_VARIABLES_decl
- = generate_ivars_list (ivar_list_template, "_OBJC_INSTANCE_VARIABLES",
- size, initlist);
- TREE_TYPE (UOBJC_INSTANCE_VARIABLES_decl) = variable_length_type;
- }
- else
- UOBJC_INSTANCE_VARIABLES_decl = 0;
-
- generating_instance_variables = 0;
-}
-
-static tree
-build_dispatch_table_initializer (type, entries)
- tree type;
- tree entries;
-{
- tree initlist = NULL_TREE;
-
- do
- {
- tree elemlist = NULL_TREE;
-
- elemlist = tree_cons (NULL_TREE,
- build_selector (METHOD_SEL_NAME (entries)),
- NULL_TREE);
-
- elemlist = tree_cons (NULL_TREE,
- add_objc_string (METHOD_ENCODING (entries),
- meth_var_types),
- elemlist);
-
- elemlist = tree_cons (NULL_TREE,
- build_unary_op (ADDR_EXPR,
- METHOD_DEFINITION (entries), 1),
- elemlist);
-
- initlist = tree_cons (NULL_TREE,
- build_constructor (type, nreverse (elemlist)),
- initlist);
-
- entries = TREE_CHAIN (entries);
- }
- while (entries);
-
- return build_constructor (build_array_type (type, 0), nreverse (initlist));
-}
-
-/* To accomplish method prototyping without generating all kinds of
- inane warnings, the definition of the dispatch table entries were
- changed from:
-
- struct objc_method { SEL _cmd; ...; id (*_imp)(); };
- to:
- struct objc_method { SEL _cmd; ...; void *_imp; }; */
-
-static tree
-build_method_template ()
-{
- tree _SLT_record;
- tree decl_specs, field_decl, field_decl_chain;
-
- _SLT_record = start_struct (RECORD_TYPE, get_identifier (UTAG_METHOD));
-
-#ifdef OBJC_INT_SELECTORS
- /* unsigned int _cmd; */
- decl_specs = tree_cons (NULL_TREE, ridpointers[(int) RID_UNSIGNED],
- NULL_TREE);
- decl_specs = tree_cons (NULL_TREE, ridpointers[(int) RID_INT], decl_specs);
- field_decl = get_identifier ("_cmd");
-#else /* not OBJC_INT_SELECTORS */
- /* struct objc_selector *_cmd; */
- decl_specs = tree_cons (NULL_TREE,
- xref_tag (RECORD_TYPE,
- get_identifier (TAG_SELECTOR)),
- NULL_TREE);
- field_decl = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("_cmd"));
-#endif /* not OBJC_INT_SELECTORS */
-
- field_decl = grokfield (input_filename, lineno, field_decl,
- decl_specs, NULL_TREE);
- field_decl_chain = field_decl;
-
- decl_specs = tree_cons (NULL_TREE, ridpointers[(int) RID_CHAR], NULL_TREE);
- field_decl = build1 (INDIRECT_REF, NULL_TREE,
- get_identifier ("method_types"));
- field_decl = grokfield (input_filename, lineno, field_decl,
- decl_specs, NULL_TREE);
- chainon (field_decl_chain, field_decl);
-
- /* void *_imp; */
-
- decl_specs = tree_cons (NULL_TREE, ridpointers[(int) RID_VOID], NULL_TREE);
- field_decl = build1 (INDIRECT_REF, NULL_TREE, get_identifier ("_imp"));
- field_decl = grokfield (input_filename, lineno, field_decl,
- decl_specs, NULL_TREE);
- chainon (field_decl_chain, field_decl);
-
- finish_struct (_SLT_record, field_decl_chain, NULL_TREE);
-
- return _SLT_record;
-}
-
-
-static tree
-generate_dispatch_table (type, name, size, list)
- tree type;
- char *name;
- int size;
- tree list;
-{
- tree sc_spec, decl_specs, decl, initlist;
-
- sc_spec = tree_cons (NULL_TREE, ridpointers[(int) RID_STATIC], NULL_TREE);
- decl_specs = tree_cons (NULL_TREE, type, sc_spec);
-
- decl = start_decl (synth_id_with_class_suffix (name, implementation_context),
- decl_specs, 1, NULL_TREE, NULL_TREE);
-
- initlist = build_tree_list (NULL_TREE, build_int_2 (0, 0));
- initlist = tree_cons (NULL_TREE, build_int_2 (size, 0), initlist);
- initlist = tree_cons (NULL_TREE, list, initlist);
-
- finish_decl (decl,
- build_constructor (TREE_TYPE (decl), nreverse (initlist)),
- NULL_TREE);
-
- return decl;
-}
-
-static void
-generate_dispatch_tables ()
-{
- tree initlist, chain, method_list_template;
- tree cast, variable_length_type;
- int size;
-
- if (!objc_method_template)
- objc_method_template = build_method_template ();
-
- cast
- = build_tree_list
- (build_tree_list (NULL_TREE,
- xref_tag (RECORD_TYPE,
- get_identifier (UTAG_METHOD_LIST))),
- NULL_TREE);
-
- variable_length_type = groktypename (cast);
-
- chain = CLASS_CLS_METHODS (implementation_context);
- if (chain)
- {
- size = list_length (chain);
-
- method_list_template
- = build_method_list_template (objc_method_template, size);
- initlist
- = build_dispatch_table_initializer (objc_method_template, chain);
-
- UOBJC_CLASS_METHODS_decl
- = generate_dispatch_table (method_list_template,
- ((TREE_CODE (implementation_context)
- == CLASS_IMPLEMENTATION_TYPE)
- ? "_OBJC_CLASS_METHODS"
- : "_OBJC_CATEGORY_CLASS_METHODS"),
- size, initlist);
- TREE_TYPE (UOBJC_CLASS_METHODS_decl) = variable_length_type;
- }
- else
- UOBJC_CLASS_METHODS_decl = 0;
-
- chain = CLASS_NST_METHODS (implementation_context);
- if (chain)
- {
- size = list_length (chain);
-
- method_list_template
- = build_method_list_template (objc_method_template, size);
- initlist
- = build_dispatch_table_initializer (objc_method_template, chain);
-
- if (TREE_CODE (implementation_context) == CLASS_IMPLEMENTATION_TYPE)
- UOBJC_INSTANCE_METHODS_decl
- = generate_dispatch_table (method_list_template,
- "_OBJC_INSTANCE_METHODS",
- size, initlist);
- else
- /* We have a category. */
- UOBJC_INSTANCE_METHODS_decl
- = generate_dispatch_table (method_list_template,
- "_OBJC_CATEGORY_INSTANCE_METHODS",
- size, initlist);
- TREE_TYPE (UOBJC_INSTANCE_METHODS_decl) = variable_length_type;
- }
- else
- UOBJC_INSTANCE_METHODS_decl = 0;
-}
-
-static tree
-generate_protocol_list (i_or_p)
- tree i_or_p;
-{
- static tree cast_type = 0;
- tree initlist, decl_specs, sc_spec;
- tree refs_decl, expr_decl, lproto, e, plist;
- int size = 0;
-
- if (TREE_CODE (i_or_p) == CLASS_INTERFACE_TYPE
- || TREE_CODE (i_or_p) == CATEGORY_INTERFACE_TYPE)
- plist = CLASS_PROTOCOL_LIST (i_or_p);
- else if (TREE_CODE (i_or_p) == PROTOCOL_INTERFACE_TYPE)
- plist = PROTOCOL_LIST (i_or_p);
- else
- abort ();
-
- if (!cast_type)
- cast_type
- = groktypename
- (build_tree_list
- (build_tree_list (NULL_TREE,
- xref_tag (RECORD_TYPE,
- get_identifier (UTAG_PROTOCOL))),
- build1 (INDIRECT_REF, NULL_TREE, NULL_TREE)));
-
- /* Compute size. */
- for (lproto = plist; lproto; lproto = TREE_CHAIN (lproto))
- if (TREE_CODE (TREE_VALUE (lproto)) == PROTOCOL_INTERFACE_TYPE
- && PROTOCOL_FORWARD_DECL (TREE_VALUE (lproto)))
- size++;
-
- /* Build initializer. */
- initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), NULL_TREE);
-
- e = build_int_2 (size, 0);
- TREE_TYPE (e) = cast_type;
- initlist = tree_cons (NULL_TREE, e, initlist);
-
- for (lproto = plist; lproto; lproto = TREE_CHAIN (lproto))
- {
- tree pval = TREE_VALUE (lproto);
-
- if (TREE_CODE (pval) == PROTOCOL_INTERFACE_TYPE
- && PROTOCOL_FORWARD_DECL (pval))
- {
- e = build_unary_op (ADDR_EXPR, PROTOCOL_FORWARD_DECL (pval), 0);
- initlist = tree_cons (NULL_TREE, e, initlist);
- }
- }
-
- /* static struct objc_protocol *refs[n]; */
-
- sc_spec = tree_cons (NULL_TREE, ridpointers[(int) RID_STATIC], NULL_TREE);
- decl_specs = tree_cons (NULL_TREE, xref_tag (RECORD_TYPE,
- get_identifier (UTAG_PROTOCOL)),
- sc_spec);
-
- if (TREE_CODE (i_or_p) == PROTOCOL_INTERFACE_TYPE)
- expr_decl = build_nt (ARRAY_REF,
- synth_id_with_class_suffix ("_OBJC_PROTOCOL_REFS",
- i_or_p),
- build_int_2 (size + 2, 0));
- else if (TREE_CODE (i_or_p) == CLASS_INTERFACE_TYPE)
- expr_decl = build_nt (ARRAY_REF,
- synth_id_with_class_suffix ("_OBJC_CLASS_PROTOCOLS",
- i_or_p),
- build_int_2 (size + 2, 0));
- else if (TREE_CODE (i_or_p) == CATEGORY_INTERFACE_TYPE)
- expr_decl
- = build_nt (ARRAY_REF,
- synth_id_with_class_suffix ("_OBJC_CATEGORY_PROTOCOLS",
- i_or_p),
- build_int_2 (size + 2, 0));
-
- expr_decl = build1 (INDIRECT_REF, NULL_TREE, expr_decl);
-
- refs_decl = start_decl (expr_decl, decl_specs, 1, NULL_TREE, NULL_TREE);
-
- finish_decl (refs_decl, build_constructor (TREE_TYPE (refs_decl),
- nreverse (initlist)),
- NULL_TREE);
-
- return refs_decl;
-}
-
-static tree
-build_category_initializer (type, cat_name, class_name,
- instance_methods, class_methods, protocol_list)
- tree type;
- tree cat_name;
- tree class_name;
- tree instance_methods;
- tree class_methods;
- tree protocol_list;
-{
- tree initlist = NULL_TREE, expr;
-
- initlist = tree_cons (NULL_TREE, cat_name, initlist);
- initlist = tree_cons (NULL_TREE, class_name, initlist);
-
- if (!instance_methods)
- initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist);
- else
- {
- expr = build_unary_op (ADDR_EXPR, instance_methods, 0);
- initlist = tree_cons (NULL_TREE, expr, initlist);
- }
- if (!class_methods)
- initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist);
- else
- {
- expr = build_unary_op (ADDR_EXPR, class_methods, 0);
- initlist = tree_cons (NULL_TREE, expr, initlist);
- }
-
- /* protocol_list = */
- if (!protocol_list)
- initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist);
- else
- {
- static tree cast_type2;
-
- if (!cast_type2)
- cast_type2
- = groktypename
- (build_tree_list
- (build_tree_list (NULL_TREE,
- xref_tag (RECORD_TYPE,
- get_identifier (UTAG_PROTOCOL))),
- build1 (INDIRECT_REF, NULL_TREE,
- build1 (INDIRECT_REF, NULL_TREE, NULL_TREE))));
-
- expr = build_unary_op (ADDR_EXPR, protocol_list, 0);
- TREE_TYPE (expr) = cast_type2;
- initlist = tree_cons (NULL_TREE, expr, initlist);
- }
-
- return build_constructor (type, nreverse (initlist));
-}
-
-/* struct objc_class {
- struct objc_class *isa;
- struct objc_class *super_class;
- char *name;
- long version;
- long info;
- long instance_size;
- struct objc_ivar_list *ivars;
- struct objc_method_list *methods;
- if (flag_next_runtime)
- struct objc_cache *cache;
- else {
- struct sarray *dtable;
- struct objc_class *subclass_list;
- struct objc_class *sibling_class;
- }
- struct objc_protocol_list *protocols;
- }; */
-
-static tree
-build_shared_structure_initializer (type, isa, super, name, size, status,
- dispatch_table, ivar_list, protocol_list)
- tree type;
- tree isa;
- tree super;
- tree name;
- tree size;
- int status;
- tree dispatch_table;
- tree ivar_list;
- tree protocol_list;
-{
- tree initlist = NULL_TREE, expr;
-
- /* isa = */
- initlist = tree_cons (NULL_TREE, isa, initlist);
-
- /* super_class = */
- initlist = tree_cons (NULL_TREE, super, initlist);
-
- /* name = */
- initlist = tree_cons (NULL_TREE, default_conversion (name), initlist);
-
- /* version = */
- initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist);
-
- /* info = */
- initlist = tree_cons (NULL_TREE, build_int_2 (status, 0), initlist);
-
- /* instance_size = */
- initlist = tree_cons (NULL_TREE, size, initlist);
-
- /* objc_ivar_list = */
- if (!ivar_list)
- initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist);
- else
- {
- expr = build_unary_op (ADDR_EXPR, ivar_list, 0);
- initlist = tree_cons (NULL_TREE, expr, initlist);
- }
-
- /* objc_method_list = */
- if (!dispatch_table)
- initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist);
- else
- {
- expr = build_unary_op (ADDR_EXPR, dispatch_table, 0);
- initlist = tree_cons (NULL_TREE, expr, initlist);
- }
-
- if (flag_next_runtime)
- /* method_cache = */
- initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist);
- else
- {
- /* dtable = */
- initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist);
-
- /* subclass_list = */
- initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist);
-
- /* sibling_class = */
- initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist);
- }
-
- /* protocol_list = */
- if (! protocol_list)
- initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist);
- else
- {
- static tree cast_type2;
-
- if (!cast_type2)
- cast_type2
- = groktypename
- (build_tree_list
- (build_tree_list (NULL_TREE,
- xref_tag (RECORD_TYPE,
- get_identifier (UTAG_PROTOCOL))),
- build1 (INDIRECT_REF, NULL_TREE,
- build1 (INDIRECT_REF, NULL_TREE, NULL_TREE))));
-
- expr = build_unary_op (ADDR_EXPR, protocol_list, 0);
- TREE_TYPE (expr) = cast_type2;
- initlist = tree_cons (NULL_TREE, expr, initlist);
- }
-
- return build_constructor (type, nreverse (initlist));
-}
-
-/* static struct objc_category _OBJC_CATEGORY_<name> = { ... }; */
-static void
-generate_category (cat)
- tree cat;
-{
- tree sc_spec, decl_specs, decl;
- tree initlist, cat_name_expr, class_name_expr;
- tree protocol_decl, category;
-
- add_class_reference (CLASS_NAME (cat));
- cat_name_expr = add_objc_string (CLASS_SUPER_NAME (cat), class_names);
-
- class_name_expr = add_objc_string (CLASS_NAME (cat), class_names);
-
- category = CLASS_CATEGORY_LIST (implementation_template);
-
- /* find the category interface from the class it is associated with */
- while (category)
- {
- if (CLASS_SUPER_NAME (cat) == CLASS_SUPER_NAME (category))
- break;
- category = CLASS_CATEGORY_LIST (category);
- }
-
- if (category && CLASS_PROTOCOL_LIST (category))
- {
- generate_protocol_references (CLASS_PROTOCOL_LIST (category));
- protocol_decl = generate_protocol_list (category);
- }
- else
- protocol_decl = 0;
-
- sc_spec = tree_cons (NULL_TREE, ridpointers[(int) RID_STATIC], NULL_TREE);
- decl_specs = tree_cons (NULL_TREE, objc_category_template, sc_spec);
-
- decl = start_decl (synth_id_with_class_suffix ("_OBJC_CATEGORY",
- implementation_context),
- decl_specs, 1, NULL_TREE, NULL_TREE);
-
- initlist = build_category_initializer (TREE_TYPE (decl),
- cat_name_expr, class_name_expr,
- UOBJC_INSTANCE_METHODS_decl,
- UOBJC_CLASS_METHODS_decl,
- protocol_decl);
-
- TREE_USED (decl) = 1;
- finish_decl (decl, initlist, NULL_TREE);
-}
-
-/* static struct objc_class _OBJC_METACLASS_Foo={ ... };
- static struct objc_class _OBJC_CLASS_Foo={ ... }; */
-
-static void
-generate_shared_structures ()
-{
- tree sc_spec, decl_specs, decl;
- tree name_expr, super_expr, root_expr;
- tree my_root_id = NULL_TREE, my_super_id = NULL_TREE;
- tree cast_type, initlist, protocol_decl;
-
- my_super_id = CLASS_SUPER_NAME (implementation_template);
- if (my_super_id)
- {
- add_class_reference (my_super_id);
-
- /* Compute "my_root_id" - this is required for code generation.
- the "isa" for all meta class structures points to the root of
- the inheritance hierarchy (e.g. "__Object")... */
- my_root_id = my_super_id;
- do
- {
- tree my_root_int = lookup_interface (my_root_id);
-
- if (my_root_int && CLASS_SUPER_NAME (my_root_int))
- my_root_id = CLASS_SUPER_NAME (my_root_int);
- else
- break;
- }
- while (1);
- }
- else
- /* No super class. */
- my_root_id = CLASS_NAME (implementation_template);
-
- cast_type
- = groktypename (build_tree_list (build_tree_list (NULL_TREE,
- objc_class_template),
- build1 (INDIRECT_REF,
- NULL_TREE, NULL_TREE)));
-
- name_expr = add_objc_string (CLASS_NAME (implementation_template),
- class_names);
-
- /* Install class `isa' and `super' pointers at runtime. */
- if (my_super_id)
- {
- super_expr = add_objc_string (my_super_id, class_names);
- super_expr = build_c_cast (cast_type, super_expr); /* cast! */
- }
- else
- super_expr = build_int_2 (0, 0);
-
- root_expr = add_objc_string (my_root_id, class_names);
- root_expr = build_c_cast (cast_type, root_expr); /* cast! */
-
- if (CLASS_PROTOCOL_LIST (implementation_template))
- {
- generate_protocol_references
- (CLASS_PROTOCOL_LIST (implementation_template));
- protocol_decl = generate_protocol_list (implementation_template);
- }
- else
- protocol_decl = 0;
-
- /* static struct objc_class _OBJC_METACLASS_Foo = { ... }; */
-
- sc_spec = build_tree_list (NULL_TREE, ridpointers[(int) RID_STATIC]);
- decl_specs = tree_cons (NULL_TREE, objc_class_template, sc_spec);
-
- decl = start_decl (DECL_NAME (UOBJC_METACLASS_decl), decl_specs, 1,
- NULL_TREE, NULL_TREE);
-
- initlist
- = build_shared_structure_initializer
- (TREE_TYPE (decl),
- root_expr, super_expr, name_expr,
- build_int_2 ((TREE_INT_CST_LOW (TYPE_SIZE (objc_class_template))
- / BITS_PER_UNIT),
- 0),
- 2 /*CLS_META*/,
- UOBJC_CLASS_METHODS_decl,
- UOBJC_CLASS_VARIABLES_decl,
- protocol_decl);
-
- finish_decl (decl, initlist, NULL_TREE);
-
- /* static struct objc_class _OBJC_CLASS_Foo={ ... }; */
-
- decl = start_decl (DECL_NAME (UOBJC_CLASS_decl), decl_specs, 1,
- NULL_TREE, NULL_TREE);
-
- initlist
- = build_shared_structure_initializer
- (TREE_TYPE (decl),
- build_unary_op (ADDR_EXPR, UOBJC_METACLASS_decl, 0),
- super_expr, name_expr,
- build_int_2
- ((TREE_INT_CST_LOW
- (TYPE_SIZE (CLASS_STATIC_TEMPLATE (implementation_template)))
- / BITS_PER_UNIT),
- 0),
- 1 /*CLS_FACTORY*/,
- UOBJC_INSTANCE_METHODS_decl,
- UOBJC_INSTANCE_VARIABLES_decl,
- protocol_decl);
-
- finish_decl (decl, initlist, NULL_TREE);
-}
-
-static tree
-synth_id_with_class_suffix (preamble, ctxt)
- char *preamble;
- tree ctxt;
-{
- char *string;
- if (TREE_CODE (ctxt) == CLASS_IMPLEMENTATION_TYPE
- || TREE_CODE (ctxt) == CLASS_INTERFACE_TYPE)
- {
- char *class_name
- = IDENTIFIER_POINTER (CLASS_NAME (implementation_context));
- string = (char *) alloca (strlen (preamble) + strlen (class_name) + 3);
- sprintf (string, "%s_%s", preamble,
- IDENTIFIER_POINTER (CLASS_NAME (ctxt)));
- }
- else if (TREE_CODE (ctxt) == CATEGORY_IMPLEMENTATION_TYPE
- || TREE_CODE (ctxt) == CATEGORY_INTERFACE_TYPE)
- {
- /* We have a category. */
- char *class_name
- = IDENTIFIER_POINTER (CLASS_NAME (implementation_context));
- char *class_super_name
- = IDENTIFIER_POINTER (CLASS_SUPER_NAME (implementation_context));
- string = (char *) alloca (strlen (preamble)
- + strlen (class_name)
- + strlen (class_super_name)
- + 3);
- sprintf (string, "%s_%s_%s", preamble, class_name, class_super_name);
- }
- else if (TREE_CODE (ctxt) == PROTOCOL_INTERFACE_TYPE)
- {
- char *protocol_name = IDENTIFIER_POINTER (PROTOCOL_NAME (ctxt));
- string
- = (char *) alloca (strlen (preamble) + strlen (protocol_name) + 3);
- sprintf (string, "%s_%s", preamble, protocol_name);
- }
- return get_identifier (string);
-}
-
-static int
-is_objc_type_qualifier (node)
- tree node;
-{
- return (TREE_CODE (node) == IDENTIFIER_NODE
- && (node == ridpointers [(int) RID_CONST]
- || node == ridpointers [(int) RID_VOLATILE]
- || node == ridpointers [(int) RID_IN]
- || node == ridpointers [(int) RID_OUT]
- || node == ridpointers [(int) RID_INOUT]
- || node == ridpointers [(int) RID_BYCOPY]
- || node == ridpointers [(int) RID_ONEWAY]));
-}
-
-/* If type is empty or only type qualifiers are present, add default
- type of id (otherwise grokdeclarator will default to int). */
-
-static tree
-adjust_type_for_id_default (type)
- tree type;
-{
- tree declspecs, chain;
-
- if (!type)
- return build_tree_list (build_tree_list (NULL_TREE, objc_object_reference),
- build1 (INDIRECT_REF, NULL_TREE, NULL_TREE));
-
- declspecs = TREE_PURPOSE (type);
-
- /* Determine if a typespec is present. */
- for (chain = declspecs;
- chain;
- chain = TREE_CHAIN (chain))
- {
- if (!is_objc_type_qualifier (TREE_VALUE (chain)))
- return type;
- }
-
- return build_tree_list (tree_cons (NULL_TREE, objc_object_reference,
- declspecs),
- build1 (INDIRECT_REF, NULL_TREE, NULL_TREE));
-}
-
-/* Usage:
- keyworddecl:
- selector ':' '(' typename ')' identifier
-
- Purpose:
- Transform an Objective-C keyword argument into
- the C equivalent parameter declarator.
-
- In: key_name, an "identifier_node" (optional).
- arg_type, a "tree_list" (optional).
- arg_name, an "identifier_node".
-
- Note: It would be really nice to strongly type the preceding
- arguments in the function prototype; however, then I
- could not use the "accessor" macros defined in "tree.h".
-
- Out: an instance of "keyword_decl". */
-
-tree
-build_keyword_decl (key_name, arg_type, arg_name)
- tree key_name;
- tree arg_type;
- tree arg_name;
-{
- tree keyword_decl;
-
- /* If no type is specified, default to "id". */
- arg_type = adjust_type_for_id_default (arg_type);
-
- keyword_decl = make_node (KEYWORD_DECL);
-
- TREE_TYPE (keyword_decl) = arg_type;
- KEYWORD_ARG_NAME (keyword_decl) = arg_name;
- KEYWORD_KEY_NAME (keyword_decl) = key_name;
-
- return keyword_decl;
-}
-
-/* Given a chain of keyword_decl's, synthesize the full keyword selector. */
-
-static tree
-build_keyword_selector (selector)
- tree selector;
-{
- int len = 0;
- tree key_chain, key_name;
- char *buf;
-
- for (key_chain = selector; key_chain; key_chain = TREE_CHAIN (key_chain))
- {
- if (TREE_CODE (selector) == KEYWORD_DECL)
- key_name = KEYWORD_KEY_NAME (key_chain);
- else if (TREE_CODE (selector) == TREE_LIST)
- key_name = TREE_PURPOSE (key_chain);
-
- if (key_name)
- len += IDENTIFIER_LENGTH (key_name) + 1;
- else
- /* Just a ':' arg. */
- len++;
- }
-
- buf = (char *)alloca (len + 1);
- bzero (buf, len + 1);
-
- for (key_chain = selector; key_chain; key_chain = TREE_CHAIN (key_chain))
- {
- if (TREE_CODE (selector) == KEYWORD_DECL)
- key_name = KEYWORD_KEY_NAME (key_chain);
- else if (TREE_CODE (selector) == TREE_LIST)
- key_name = TREE_PURPOSE (key_chain);
-
- if (key_name)
- strcat (buf, IDENTIFIER_POINTER (key_name));
- strcat (buf, ":");
- }
-
- return get_identifier (buf);
-}
-
-/* Used for declarations and definitions. */
-
-tree
-build_method_decl (code, ret_type, selector, add_args)
- enum tree_code code;
- tree ret_type;
- tree selector;
- tree add_args;
-{
- tree method_decl;
-
- /* If no type is specified, default to "id". */
- ret_type = adjust_type_for_id_default (ret_type);
-
- method_decl = make_node (code);
- TREE_TYPE (method_decl) = ret_type;
-
- /* If we have a keyword selector, create an identifier_node that
- represents the full selector name (`:' included)... */
- if (TREE_CODE (selector) == KEYWORD_DECL)
- {
- METHOD_SEL_NAME (method_decl) = build_keyword_selector (selector);
- METHOD_SEL_ARGS (method_decl) = selector;
- METHOD_ADD_ARGS (method_decl) = add_args;
- }
- else
- {
- METHOD_SEL_NAME (method_decl) = selector;
- METHOD_SEL_ARGS (method_decl) = NULL_TREE;
- METHOD_ADD_ARGS (method_decl) = NULL_TREE;
- }
-
- return method_decl;
-}
-
-#define METHOD_DEF 0
-#define METHOD_REF 1
-
-/* Used by `build_message_expr' and `comp_method_types'. Return an
- argument list for method METH. CONTEXT is either METHOD_DEF or
- METHOD_REF, saying whether we are trying to define a method or call
- one. SUPERFLAG says this is for a send to super; this makes a
- difference for the NeXT calling sequence in which the lookup and
- the method call are done together. */
-
-static tree
-get_arg_type_list (meth, context, superflag)
- tree meth;
- int context;
- int superflag;
-{
- tree arglist, akey;
-
- /* Receiver type. */
- if (flag_next_runtime && superflag)
- arglist = build_tree_list (NULL_TREE, super_type);
- else if (context == METHOD_DEF)
- arglist = build_tree_list (NULL_TREE, TREE_TYPE (self_decl));
- else
- arglist = build_tree_list (NULL_TREE, id_type);
-
- /* Selector type - will eventually change to `int'. */
- chainon (arglist, build_tree_list (NULL_TREE, selector_type));
-
- /* Build a list of argument types. */
- for (akey = METHOD_SEL_ARGS (meth); akey; akey = TREE_CHAIN (akey))
- {
- tree arg_decl = groktypename_in_parm_context (TREE_TYPE (akey));
- chainon (arglist, build_tree_list (NULL_TREE, TREE_TYPE (arg_decl)));
- }
-
- if (METHOD_ADD_ARGS (meth) == (tree)1)
- /* We have a `, ...' immediately following the selector,
- finalize the arglist...simulate get_parm_info (0). */
- ;
- else if (METHOD_ADD_ARGS (meth))
- {
- /* we have a variable length selector */
- tree add_arg_list = TREE_CHAIN (METHOD_ADD_ARGS (meth));
- chainon (arglist, add_arg_list);
- }
- else
- /* finalize the arglist...simulate get_parm_info (1) */
- chainon (arglist, build_tree_list (NULL_TREE, void_type_node));
-
- return arglist;
-}
-
-static tree
-check_duplicates (hsh)
- hash hsh;
-{
- tree meth = NULL_TREE;
-
- if (hsh)
- {
- meth = hsh->key;
-
- if (hsh->list)
- {
- /* We have two methods with the same name and different types. */
- attr loop;
- char type = (TREE_CODE (meth) == INSTANCE_METHOD_DECL) ? '-' : '+';
-
- warning ("multiple declarations for method `%s'",
- IDENTIFIER_POINTER (METHOD_SEL_NAME (meth)));
-
- warn_with_method ("using", type, meth);
- for (loop = hsh->list; loop; loop = loop->next)
- warn_with_method ("also found", type, loop->value);
- }
- }
- return meth;
-}
-
-/* If RECEIVER is a class reference, return the identifier node for the
- referenced class. RECEIVER is created by get_class_reference, so we
- check the exact form created depending on which runtimes are used. */
-
-static tree
-receiver_is_class_object (receiver)
- tree receiver;
-{
- tree chain, exp, arg;
- if (flag_next_runtime)
- {
- /* The receiver is a variable created by build_class_reference_decl. */
- if (TREE_CODE (receiver) == VAR_DECL
- && TREE_TYPE (receiver) == objc_class_type)
- /* Look up the identifier. */
- for (chain = cls_ref_chain; chain; chain = TREE_CHAIN (chain))
- if (TREE_PURPOSE (chain) == receiver)
- return TREE_VALUE (chain);
- }
- else
- {
- /* The receiver is a function call that returns an id. Check if
- it is a call to objc_getClass, if so, pick up the class name. */
- if ((exp = TREE_OPERAND (receiver, 0))
- && TREE_CODE (exp) == ADDR_EXPR
- && (exp = TREE_OPERAND (exp, 0))
- && TREE_CODE (exp) == FUNCTION_DECL
- && exp == objc_get_class_decl
- /* we have a call to objc_getClass! */
- && (arg = TREE_OPERAND (receiver, 1))
- && TREE_CODE (arg) == TREE_LIST
- && (arg = TREE_VALUE (arg)))
- {
- STRIP_NOPS (arg);
- if (TREE_CODE (arg) == ADDR_EXPR
- && (arg = TREE_OPERAND (arg, 0))
- && TREE_CODE (arg) == STRING_CST)
- /* Finally, we have the class name. */
- return get_identifier (TREE_STRING_POINTER (arg));
- }
- }
- return 0;
-}
-
-/* If we are currently building a message expr, this holds
- the identifier of the selector of the message. This is
- used when printing warnings about argument mismatches. */
-
-static tree building_objc_message_expr = 0;
-
-tree
-maybe_building_objc_message_expr ()
-{
- return building_objc_message_expr;
-}
-
-/* Construct an expression for sending a message.
- MESS has the object to send to in TREE_PURPOSE
- and the argument list (including selector) in TREE_VALUE.
-
- (*(<abstract_decl>(*)())_msg)(receiver, selTransTbl[n], ...);
- (*(<abstract_decl>(*)())_msgSuper)(receiver, selTransTbl[n], ...); */
-
-tree
-build_message_expr (mess)
- tree mess;
-{
- tree receiver = TREE_PURPOSE (mess);
- tree selector, self_object;
- tree rtype, sel_name;
- tree args = TREE_VALUE (mess);
- tree method_params = NULL_TREE;
- tree method_prototype = NULL_TREE;
- tree retval;
- int statically_typed = 0, statically_allocated = 0;
- tree class_ident = 0;
-
- /* 1 if this is sending to the superclass. */
- int super;
-
- if (!doing_objc_thang)
- objc_fatal ();
-
- if (TREE_CODE (receiver) == ERROR_MARK)
- return error_mark_node;
-
- /* Determine receiver type. */
- rtype = TREE_TYPE (receiver);
- super = IS_SUPER (rtype);
-
- if (! super)
- {
- if (TREE_STATIC_TEMPLATE (rtype))
- statically_allocated = 1;
- else if (TREE_CODE (rtype) == POINTER_TYPE
- && TREE_STATIC_TEMPLATE (TREE_TYPE (rtype)))
- statically_typed = 1;
- else if ((flag_next_runtime
- || (TREE_CODE (receiver) == CALL_EXPR && IS_ID (rtype)))
- && (class_ident = receiver_is_class_object (receiver)))
- ;
- else if (! IS_ID (rtype)
- /* Allow any type that matches objc_class_type. */
- && ! comptypes (rtype, objc_class_type))
- {
- bzero (errbuf, BUFSIZE);
- warning ("invalid receiver type `%s'",
- gen_declaration (rtype, errbuf));
- }
-
- if (statically_allocated)
- receiver = build_unary_op (ADDR_EXPR, receiver, 0);
-
- /* Don't evaluate the receiver twice. */
- receiver = save_expr (receiver);
- self_object = receiver;
- }
- else
- /* If sending to `super', use current self as the object. */
- self_object = self_decl;
-
- /* Obtain the full selector name. */
-
- if (TREE_CODE (args) == IDENTIFIER_NODE)
- /* A unary selector. */
- sel_name = args;
- else if (TREE_CODE (args) == TREE_LIST)
- sel_name = build_keyword_selector (args);
-
- /* Build the parameter list to give to the method. */
-
- method_params = NULL_TREE;
- if (TREE_CODE (args) == TREE_LIST)
- {
- tree chain = args, prev = NULL_TREE;
-
- /* We have a keyword selector--check for comma expressions. */
- while (chain)
- {
- tree element = TREE_VALUE (chain);
-
- /* We have a comma expression, must collapse... */
- if (TREE_CODE (element) == TREE_LIST)
- {
- if (prev)
- TREE_CHAIN (prev) = element;
- else
- args = element;
- }
- prev = chain;
- chain = TREE_CHAIN (chain);
- }
- method_params = args;
- }
-
- /* Determine operation return type. */
-
- if (IS_SUPER (rtype))
- {
- tree iface;
-
- if (CLASS_SUPER_NAME (implementation_template))
- {
- iface
- = lookup_interface (CLASS_SUPER_NAME (implementation_template));
-
- if (TREE_CODE (method_context) == INSTANCE_METHOD_DECL)
- method_prototype = lookup_instance_method_static (iface, sel_name);
- else
- method_prototype = lookup_class_method_static (iface, sel_name);
-
- if (iface && !method_prototype)
- warning ("`%s' does not respond to `%s'",
- IDENTIFIER_POINTER (CLASS_SUPER_NAME (implementation_template)),
- IDENTIFIER_POINTER (sel_name));
- }
- else
- {
- error ("no super class declared in interface for `%s'",
- IDENTIFIER_POINTER (CLASS_NAME (implementation_template)));
- return error_mark_node;
- }
-
- }
- else if (statically_allocated)
- {
- tree ctype = TREE_TYPE (rtype);
- tree iface = lookup_interface (TYPE_NAME (rtype));
-
- if (iface)
- method_prototype = lookup_instance_method_static (iface, sel_name);
-
- if (! method_prototype && TYPE_PROTOCOL_LIST (ctype))
- method_prototype
- = lookup_method_in_protocol_list (TYPE_PROTOCOL_LIST (ctype),
- sel_name, 0);
-
- if (!method_prototype)
- warning ("`%s' does not respond to `%s'",
- IDENTIFIER_POINTER (TYPE_NAME (rtype)),
- IDENTIFIER_POINTER (sel_name));
- }
- else if (statically_typed)
- {
- tree ctype = TREE_TYPE (rtype);
-
- /* `self' is now statically_typed. All methods should be visible
- within the context of the implementation. */
- if (implementation_context
- && CLASS_NAME (implementation_context) == TYPE_NAME (ctype))
- {
- method_prototype
- = lookup_instance_method_static (implementation_template,
- sel_name);
-
- if (! method_prototype && TYPE_PROTOCOL_LIST (ctype))
- method_prototype
- = lookup_method_in_protocol_list (TYPE_PROTOCOL_LIST (ctype),
- sel_name, 0);
-
- if (! method_prototype
- && implementation_template != implementation_context)
- /* The method is not published in the interface. Check locally. */
- method_prototype
- = lookup_method (CLASS_NST_METHODS (implementation_context),
- sel_name);
- }
- else
- {
- tree iface;
-
- if ((iface = lookup_interface (TYPE_NAME (ctype))))
- method_prototype = lookup_instance_method_static (iface, sel_name);
-
- if (! method_prototype)
- {
- tree protocol_list = TYPE_PROTOCOL_LIST (ctype);
- if (protocol_list)
- method_prototype
- = lookup_method_in_protocol_list (protocol_list,
- sel_name, 0);
- }
- }
-
- if (!method_prototype)
- warning ("`%s' does not respond to `%s'",
- IDENTIFIER_POINTER (TYPE_NAME (ctype)),
- IDENTIFIER_POINTER (sel_name));
- }
- else if (class_ident)
- {
- if (implementation_context
- && CLASS_NAME (implementation_context) == class_ident)
- {
- method_prototype
- = lookup_class_method_static (implementation_template, sel_name);
-
- if (!method_prototype
- && implementation_template != implementation_context)
- /* The method is not published in the interface. Check locally. */
- method_prototype
- = lookup_method (CLASS_CLS_METHODS (implementation_context),
- sel_name);
- }
- else
- {
- tree iface;
-
- if ((iface = lookup_interface (class_ident)))
- method_prototype = lookup_class_method_static (iface, sel_name);
- }
-
- if (!method_prototype)
- {
- warning ("cannot find class (factory) method.");
- warning ("return type for `%s' defaults to id",
- IDENTIFIER_POINTER (sel_name));
- }
- }
- else if (IS_PROTOCOL_QUALIFIED_ID (rtype))
- {
- /* An anonymous object that has been qualified with a protocol. */
-
- tree protocol_list = TYPE_PROTOCOL_LIST (rtype);
-
- method_prototype = lookup_method_in_protocol_list (protocol_list,
- sel_name, 0);
-
- if (!method_prototype)
- {
- hash hsh;
-
- warning ("method `%s' not implemented by protocol.",
- IDENTIFIER_POINTER (sel_name));
-
- /* Try and find the method signature in the global pools. */
-
- if (!(hsh = hash_lookup (nst_method_hash_list, sel_name)))
- hsh = hash_lookup (cls_method_hash_list, sel_name);
-
- if (!(method_prototype = check_duplicates (hsh)))
- warning ("return type defaults to id");
- }
- }
- else
- {
- hash hsh;
-
- /* We think we have an instance...loophole: extern id Object; */
- hsh = hash_lookup (nst_method_hash_list, sel_name);
- if (!hsh)
- /* For various loopholes, like sending messages to self in a
- factory context. */
- hsh = hash_lookup (cls_method_hash_list, sel_name);
-
- method_prototype = check_duplicates (hsh);
- if (!method_prototype)
- {
- warning ("cannot find method.");
- warning ("return type for `%s' defaults to id",
- IDENTIFIER_POINTER (sel_name));
- }
- }
-
- /* Save the selector name for printing error messages. */
- building_objc_message_expr = sel_name;
-
- /* Build the parameters list for looking up the method.
- These are the object itself and the selector. */
-
- if (flag_typed_selectors)
- selector = build_typed_selector_reference (sel_name, method_prototype);
- else
- selector = build_selector_reference (sel_name);
-
- retval = build_objc_method_call (super, method_prototype,
- receiver, self_object,
- selector, method_params);
-
- building_objc_message_expr = 0;
-
- return retval;
-}
-
-/* Build a tree expression to send OBJECT the operation SELECTOR,
- looking up the method on object LOOKUP_OBJECT (often same as OBJECT),
- assuming the method has prototype METHOD_PROTOTYPE.
- (That is an INSTANCE_METHOD_DECL or CLASS_METHOD_DECL.)
- Use METHOD_PARAMS as list of args to pass to the method.
- If SUPER_FLAG is nonzero, we look up the superclass's method. */
-
-static tree
-build_objc_method_call (super_flag, method_prototype, lookup_object, object,
- selector, method_params)
- int super_flag;
- tree method_prototype, lookup_object, object, selector, method_params;
-{
- tree sender = (super_flag ? umsg_super_decl : umsg_decl);
- tree rcv_p = (super_flag
- ? build_pointer_type (xref_tag (RECORD_TYPE,
- get_identifier (TAG_SUPER)))
- : id_type);
-
- if (flag_next_runtime)
- {
- if (! method_prototype)
- {
- method_params = tree_cons (NULL_TREE, lookup_object,
- tree_cons (NULL_TREE, selector,
- method_params));
- assemble_external (sender);
- return build_function_call (sender, method_params);
- }
- else
- {
- /* This is a real kludge, but it is used only for the Next.
- Clobber the data type of SENDER temporarily to accept
- all the arguments for this operation, and to return
- whatever this operation returns. */
- tree arglist = NULL_TREE;
- tree retval;
-
- /* Save the proper contents of SENDER's data type. */
- tree savarg = TYPE_ARG_TYPES (TREE_TYPE (sender));
- tree savret = TREE_TYPE (TREE_TYPE (sender));
-
- /* Install this method's argument types. */
- arglist = get_arg_type_list (method_prototype, METHOD_REF,
- super_flag);
- TYPE_ARG_TYPES (TREE_TYPE (sender)) = arglist;
-
- /* Install this method's return type. */
- TREE_TYPE (TREE_TYPE (sender))
- = groktypename (TREE_TYPE (method_prototype));
-
- /* Call SENDER with all the parameters. This will do type
- checking using the arg types for this method. */
- method_params = tree_cons (NULL_TREE, lookup_object,
- tree_cons (NULL_TREE, selector,
- method_params));
- assemble_external (sender);
- retval = build_function_call (sender, method_params);
-
- /* Restore SENDER's return/argument types. */
- TYPE_ARG_TYPES (TREE_TYPE (sender)) = savarg;
- TREE_TYPE (TREE_TYPE (sender)) = savret;
- return retval;
- }
- }
- else
- {
- /* This is the portable way.
- First call the lookup function to get a pointer to the method,
- then cast the pointer, then call it with the method arguments. */
- tree method;
-
- /* Avoid trouble since we may evaluate each of these twice. */
- object = save_expr (object);
- selector = save_expr (selector);
-
- lookup_object = build_c_cast (rcv_p, lookup_object);
-
- assemble_external (sender);
- method
- = build_function_call (sender,
- tree_cons (NULL_TREE, lookup_object,
- tree_cons (NULL_TREE, selector,
- NULL_TREE)));
-
- /* If we have a method prototype, construct the data type this
- method needs, and cast what we got from SENDER into a pointer
- to that type. */
- if (method_prototype)
- {
- tree arglist = get_arg_type_list (method_prototype, METHOD_REF,
- super_flag);
- tree valtype = groktypename (TREE_TYPE (method_prototype));
- tree fake_function_type = build_function_type (valtype, arglist);
- TREE_TYPE (method) = build_pointer_type (fake_function_type);
- }
- else
- TREE_TYPE (method)
- = build_pointer_type (build_function_type (ptr_type_node, NULL_TREE));
-
- /* Pass the object to the method. */
- assemble_external (method);
- return build_function_call (method,
- tree_cons (NULL_TREE, object,
- tree_cons (NULL_TREE, selector,
- method_params)));
- }
-}
-
-static void
-build_protocol_reference (p)
- tree p;
-{
- tree decl, ident, ptype;
-
- push_obstacks_nochange ();
- end_temporary_allocation ();
-
- /* extern struct objc_protocol _OBJC_PROTOCOL_<mumble>; */
-
- ident = synth_id_with_class_suffix ("_OBJC_PROTOCOL", p);
- ptype
- = groktypename (build_tree_list (build_tree_list (NULL_TREE,
- objc_protocol_template),
- NULL_TREE));
-
- if (IDENTIFIER_GLOBAL_VALUE (ident))
- decl = IDENTIFIER_GLOBAL_VALUE (ident); /* Set by pushdecl. */
- else
- {
- decl = build_decl (VAR_DECL, ident, ptype);
- DECL_EXTERNAL (decl) = 1;
- TREE_PUBLIC (decl) = 1;
- TREE_USED (decl) = 1;
- DECL_ARTIFICIAL (decl) = 1;
-
- make_decl_rtl (decl, 0, 1);
- pushdecl_top_level (decl);
- }
-
- PROTOCOL_FORWARD_DECL (p) = decl;
- pop_obstacks ();
-}
-
-tree
-build_protocol_expr (protoname)
- tree protoname;
-{
- tree expr;
- tree p;
-
- if (!doing_objc_thang)
- objc_fatal ();
-
- p = lookup_protocol (protoname);
-
- if (!p)
- {
- error ("Cannot find protocol declaration for `%s'",
- IDENTIFIER_POINTER (protoname));
- return error_mark_node;
- }
-
- if (!PROTOCOL_FORWARD_DECL (p))
- build_protocol_reference (p);
-
- expr = build_unary_op (ADDR_EXPR, PROTOCOL_FORWARD_DECL (p), 0);
-
- TREE_TYPE (expr) = protocol_type;
-
- return expr;
-}
-
-tree
-build_selector_expr (selnamelist)
- tree selnamelist;
-{
- tree selname;
-
- if (!doing_objc_thang)
- objc_fatal ();
-
- /* Obtain the full selector name. */
- if (TREE_CODE (selnamelist) == IDENTIFIER_NODE)
- /* A unary selector. */
- selname = selnamelist;
- else if (TREE_CODE (selnamelist) == TREE_LIST)
- selname = build_keyword_selector (selnamelist);
-
- if (flag_typed_selectors)
- return build_typed_selector_reference (selname, 0);
- else
- return build_selector_reference (selname);
-}
-
-tree
-build_encode_expr (type)
- tree type;
-{
- tree result;
- char *string;
-
- if (!doing_objc_thang)
- objc_fatal ();
-
- encode_type (type, obstack_object_size (&util_obstack),
- OBJC_ENCODE_INLINE_DEFS);
- obstack_1grow (&util_obstack, 0); /* null terminate string */
- string = obstack_finish (&util_obstack);
-
- /* Synthesize a string that represents the encoded struct/union. */
- result = my_build_string (strlen (string) + 1, string);
- obstack_free (&util_obstack, util_firstobj);
- return result;
-}
-
-tree
-build_ivar_reference (id)
- tree id;
-{
- if (TREE_CODE (method_context) == CLASS_METHOD_DECL)
- {
- /* Historically, a class method that produced objects (factory
- method) would assign `self' to the instance that it
- allocated. This would effectively turn the class method into
- an instance method. Following this assignment, the instance
- variables could be accessed. That practice, while safe,
- violates the simple rule that a class method should not refer
- to an instance variable. It's better to catch the cases
- where this is done unknowingly than to support the above
- paradigm. */
- warning ("instance variable `%s' accessed in class method",
- IDENTIFIER_POINTER (id));
- TREE_TYPE (self_decl) = instance_type; /* cast */
- }
-
- return build_component_ref (build_indirect_ref (self_decl, "->"), id);
-}
-
-#define HASH_ALLOC_LIST_SIZE 170
-#define ATTR_ALLOC_LIST_SIZE 170
-#define SIZEHASHTABLE 257
-
-/* make positive */
-#define HASHFUNCTION(key) ((HOST_WIDE_INT) key & 0x7fffffff)
-
-static void
-hash_init ()
-{
- nst_method_hash_list = (hash *)xmalloc (SIZEHASHTABLE * sizeof (hash));
- cls_method_hash_list = (hash *)xmalloc (SIZEHASHTABLE * sizeof (hash));
-
- if (!nst_method_hash_list || !cls_method_hash_list)
- perror ("unable to allocate space in objc-tree.c");
- else
- {
- int i;
-
- for (i = 0; i < SIZEHASHTABLE; i++)
- {
- nst_method_hash_list[i] = 0;
- cls_method_hash_list[i] = 0;
- }
- }
-}
-
-static void
-hash_enter (hashlist, method)
- hash *hashlist;
- tree method;
-{
- static hash hash_alloc_list = 0;
- static int hash_alloc_index = 0;
- hash obj;
- int slot = HASHFUNCTION (METHOD_SEL_NAME (method)) % SIZEHASHTABLE;
-
- if (! hash_alloc_list || hash_alloc_index >= HASH_ALLOC_LIST_SIZE)
- {
- hash_alloc_index = 0;
- hash_alloc_list = (hash) xmalloc (sizeof (struct hashed_entry)
- * HASH_ALLOC_LIST_SIZE);
- if (! hash_alloc_list)
- perror ("unable to allocate in objc-tree.c");
- }
- obj = &hash_alloc_list[hash_alloc_index++];
- obj->list = 0;
- obj->next = hashlist[slot];
- obj->key = method;
-
- hashlist[slot] = obj; /* append to front */
-}
-
-static hash
-hash_lookup (hashlist, sel_name)
- hash *hashlist;
- tree sel_name;
-{
- hash target;
-
- target = hashlist[HASHFUNCTION (sel_name) % SIZEHASHTABLE];
-
- while (target)
- {
- if (sel_name == METHOD_SEL_NAME (target->key))
- return target;
-
- target = target->next;
- }
- return 0;
-}
-
-static void
-hash_add_attr (entry, value)
- hash entry;
- tree value;
-{
- static attr attr_alloc_list = 0;
- static int attr_alloc_index = 0;
- attr obj;
-
- if (! attr_alloc_list || attr_alloc_index >= ATTR_ALLOC_LIST_SIZE)
- {
- attr_alloc_index = 0;
- attr_alloc_list = (attr) xmalloc (sizeof (struct hashed_attribute)
- * ATTR_ALLOC_LIST_SIZE);
- if (! attr_alloc_list)
- perror ("unable to allocate in objc-tree.c");
- }
- obj = &attr_alloc_list[attr_alloc_index++];
- obj->next = entry->list;
- obj->value = value;
-
- entry->list = obj; /* append to front */
-}
-
-static tree
-lookup_method (mchain, method)
- tree mchain;
- tree method;
-{
- tree key;
-
- if (TREE_CODE (method) == IDENTIFIER_NODE)
- key = method;
- else
- key = METHOD_SEL_NAME (method);
-
- while (mchain)
- {
- if (METHOD_SEL_NAME (mchain) == key)
- return mchain;
- mchain = TREE_CHAIN (mchain);
- }
- return NULL_TREE;
-}
-
-static tree
-lookup_instance_method_static (interface, ident)
- tree interface;
- tree ident;
-{
- tree inter = interface;
- tree chain = CLASS_NST_METHODS (inter);
- tree meth = NULL_TREE;
-
- do
- {
- if ((meth = lookup_method (chain, ident)))
- return meth;
-
- if (CLASS_CATEGORY_LIST (inter))
- {
- tree category = CLASS_CATEGORY_LIST (inter);
- chain = CLASS_NST_METHODS (category);
-
- do
- {
- if ((meth = lookup_method (chain, ident)))
- return meth;
-
- /* Check for instance methods in protocols in categories. */
- if (CLASS_PROTOCOL_LIST (category))
- {
- if ((meth = (lookup_method_in_protocol_list
- (CLASS_PROTOCOL_LIST (category), ident, 0))))
- return meth;
- }
-
- if ((category = CLASS_CATEGORY_LIST (category)))
- chain = CLASS_NST_METHODS (category);
- }
- while (category);
- }
-
- if (CLASS_PROTOCOL_LIST (inter))
- {
- if ((meth = (lookup_method_in_protocol_list
- (CLASS_PROTOCOL_LIST (inter), ident, 0))))
- return meth;
- }
-
- if ((inter = lookup_interface (CLASS_SUPER_NAME (inter))))
- chain = CLASS_NST_METHODS (inter);
- }
- while (inter);
-
- return meth;
-}
-
-static tree
-lookup_class_method_static (interface, ident)
- tree interface;
- tree ident;
-{
- tree inter = interface;
- tree chain = CLASS_CLS_METHODS (inter);
- tree meth = NULL_TREE;
- tree root_inter = NULL_TREE;
-
- do
- {
- if ((meth = lookup_method (chain, ident)))
- return meth;
-
- if (CLASS_CATEGORY_LIST (inter))
- {
- tree category = CLASS_CATEGORY_LIST (inter);
- chain = CLASS_CLS_METHODS (category);
-
- do
- {
- if ((meth = lookup_method (chain, ident)))
- return meth;
-
- /* Check for class methods in protocols in categories. */
- if (CLASS_PROTOCOL_LIST (category))
- {
- if ((meth = (lookup_method_in_protocol_list
- (CLASS_PROTOCOL_LIST (category), ident, 1))))
- return meth;
- }
-
- if ((category = CLASS_CATEGORY_LIST (category)))
- chain = CLASS_CLS_METHODS (category);
- }
- while (category);
- }
-
- /* Check for class methods in protocols. */
- if (CLASS_PROTOCOL_LIST (inter))
- {
- if ((meth = (lookup_method_in_protocol_list
- (CLASS_PROTOCOL_LIST (inter), ident, 1))))
- return meth;
- }
-
- root_inter = inter;
- if ((inter = lookup_interface (CLASS_SUPER_NAME (inter))))
- chain = CLASS_CLS_METHODS (inter);
- }
- while (inter);
-
- /* Simulate wrap around. */
- return lookup_instance_method_static (root_inter, ident);
-}
-
-tree
-add_class_method (class, method)
- tree class;
- tree method;
-{
- tree mth;
- hash hsh;
-
- /* We will have allocated the method parameter declarations on the
- maybepermanent_obstack. Need to make sure they stick around! */
- preserve_data ();
-
- if (!(mth = lookup_method (CLASS_CLS_METHODS (class), method)))
- {
- /* put method on list in reverse order */
- TREE_CHAIN (method) = CLASS_CLS_METHODS (class);
- CLASS_CLS_METHODS (class) = method;
- }
- else
- {
- if (TREE_CODE (class) == CLASS_IMPLEMENTATION_TYPE)
- error ("duplicate definition of class method `%s'.",
- IDENTIFIER_POINTER (METHOD_SEL_NAME (mth)));
- else
- {
- /* Check types; if different, complain. */
- if (!comp_proto_with_proto (method, mth))
- error ("duplicate declaration of class method `%s'.",
- IDENTIFIER_POINTER (METHOD_SEL_NAME (mth)));
- }
- }
-
- if (!(hsh = hash_lookup (cls_method_hash_list, METHOD_SEL_NAME (method))))
- {
- /* Install on a global chain. */
- hash_enter (cls_method_hash_list, method);
- }
- else
- {
- /* Check types; if different, add to a list. */
- if (!comp_proto_with_proto (method, hsh->key))
- hash_add_attr (hsh, method);
- }
- return method;
-}
-
-tree
-add_instance_method (class, method)
- tree class;
- tree method;
-{
- tree mth;
- hash hsh;
-
- /* We will have allocated the method parameter declarations on the
- maybepermanent_obstack. Need to make sure they stick around! */
- preserve_data ();
-
- if (!(mth = lookup_method (CLASS_NST_METHODS (class), method)))
- {
- /* Put method on list in reverse order. */
- TREE_CHAIN (method) = CLASS_NST_METHODS (class);
- CLASS_NST_METHODS (class) = method;
- }
- else
- {
- if (TREE_CODE (class) == CLASS_IMPLEMENTATION_TYPE)
- error ("duplicate definition of instance method `%s'.",
- IDENTIFIER_POINTER (METHOD_SEL_NAME (mth)));
- else
- {
- /* Check types; if different, complain. */
- if (!comp_proto_with_proto (method, mth))
- error ("duplicate declaration of instance method `%s'.",
- IDENTIFIER_POINTER (METHOD_SEL_NAME (mth)));
- }
- }
-
- if (!(hsh = hash_lookup (nst_method_hash_list, METHOD_SEL_NAME (method))))
- {
- /* Install on a global chain. */
- hash_enter (nst_method_hash_list, method);
- }
- else
- {
- /* Check types; if different, add to a list. */
- if (!comp_proto_with_proto (method, hsh->key))
- hash_add_attr (hsh, method);
- }
- return method;
-}
-
-static tree
-add_class (class)
- tree class;
-{
- /* Put interfaces on list in reverse order. */
- TREE_CHAIN (class) = interface_chain;
- interface_chain = class;
- return interface_chain;
-}
-
-static void
-add_category (class, category)
- tree class;
- tree category;
-{
- /* Put categories on list in reverse order. */
- tree cat = CLASS_CATEGORY_LIST (class);
-
- while (cat)
- {
- if (CLASS_SUPER_NAME (cat) == CLASS_SUPER_NAME (category))
- warning ("duplicate interface declaration for category `%s(%s)'",
- IDENTIFIER_POINTER (CLASS_NAME (class)),
- IDENTIFIER_POINTER (CLASS_SUPER_NAME (category)));
- cat = CLASS_CATEGORY_LIST (cat);
- }
-
- CLASS_CATEGORY_LIST (category) = CLASS_CATEGORY_LIST (class);
- CLASS_CATEGORY_LIST (class) = category;
-}
-
-/* Called after parsing each instance variable declaration. Necessary to
- preserve typedefs and implement public/private...
-
- PUBLIC is 1 for public, 0 for protected, and 2 for private. */
-
-tree
-add_instance_variable (class, public, declarator, declspecs, width)
- tree class;
- int public;
- tree declarator;
- tree declspecs;
- tree width;
-{
- tree field_decl, raw_decl;
-
- raw_decl = build_tree_list (declspecs, declarator);
-
- if (CLASS_RAW_IVARS (class))
- chainon (CLASS_RAW_IVARS (class), raw_decl);
- else
- CLASS_RAW_IVARS (class) = raw_decl;
-
- field_decl = grokfield (input_filename, lineno,
- declarator, declspecs, width);
-
- /* Overload the public attribute, it is not used for FIELD_DECLs. */
- switch (public)
- {
- case 0:
- TREE_PUBLIC (field_decl) = 0;
- TREE_PRIVATE (field_decl) = 0;
- TREE_PROTECTED (field_decl) = 1;
- break;
-
- case 1:
- TREE_PUBLIC (field_decl) = 1;
- TREE_PRIVATE (field_decl) = 0;
- TREE_PROTECTED (field_decl) = 0;
- break;
-
- case 2:
- TREE_PUBLIC (field_decl) = 0;
- TREE_PRIVATE (field_decl) = 1;
- TREE_PROTECTED (field_decl) = 0;
- break;
-
- }
-
- if (CLASS_IVARS (class))
- chainon (CLASS_IVARS (class), field_decl);
- else
- CLASS_IVARS (class) = field_decl;
-
- return class;
-}
-
-tree
-is_ivar (decl_chain, ident)
- tree decl_chain;
- tree ident;
-{
- for ( ; decl_chain; decl_chain = TREE_CHAIN (decl_chain))
- if (DECL_NAME (decl_chain) == ident)
- return decl_chain;
- return NULL_TREE;
-}
-
-/* True if the ivar is private and we are not in its implementation. */
-
-int
-is_private (decl)
- tree decl;
-{
- if (TREE_PRIVATE (decl)
- && ! is_ivar (CLASS_IVARS (implementation_template), DECL_NAME (decl)))
- {
- error ("instance variable `%s' is declared private",
- IDENTIFIER_POINTER (DECL_NAME (decl)));
- return 1;
- }
- else
- return 0;
-}
-
-/* We have an instance variable reference;, check to see if it is public. */
-
-int
-is_public (expr, identifier)
- tree expr;
- tree identifier;
-{
- tree basetype = TREE_TYPE (expr);
- enum tree_code code = TREE_CODE (basetype);
- tree decl;
-
- if (code == RECORD_TYPE)
- {
- if (TREE_STATIC_TEMPLATE (basetype))
- {
- if (!lookup_interface (TYPE_NAME (basetype)))
- {
- error ("Cannot find interface declaration for `%s'",
- IDENTIFIER_POINTER (TYPE_NAME (basetype)));
- return 0;
- }
-
- if ((decl = is_ivar (TYPE_FIELDS (basetype), identifier)))
- {
- if (TREE_PUBLIC (decl))
- return 1;
-
- /* Important difference between the Stepstone translator:
- all instance variables should be public within the context
- of the implementation. */
- if (implementation_context
- && (((TREE_CODE (implementation_context)
- == CLASS_IMPLEMENTATION_TYPE)
- || (TREE_CODE (implementation_context)
- == CATEGORY_IMPLEMENTATION_TYPE))
- && (CLASS_NAME (implementation_context)
- == TYPE_NAME (basetype))))
- return ! is_private (decl);
-
- error ("instance variable `%s' is declared %s",
- IDENTIFIER_POINTER (identifier),
- TREE_PRIVATE (decl) ? "private" : "protected");
- return 0;
- }
- }
-
- else if (implementation_context && (basetype == objc_object_reference))
- {
- TREE_TYPE (expr) = uprivate_record;
- warning ("static access to object of type `id'");
- }
- }
-
- return 1;
-}
-
-/* Implement @defs (<classname>) within struct bodies. */
-
-tree
-get_class_ivars (interface)
- tree interface;
-{
- if (!doing_objc_thang)
- objc_fatal ();
-
- return build_ivar_chain (interface, 1);
-}
-
-/* Make sure all entries in CHAIN are also in LIST. */
-
-static int
-check_methods (chain, list, mtype)
- tree chain;
- tree list;
- int mtype;
-{
- int first = 1;
-
- while (chain)
- {
- if (!lookup_method (list, chain))
- {
- if (first)
- {
- if (TREE_CODE (implementation_context)
- == CLASS_IMPLEMENTATION_TYPE)
- warning ("incomplete implementation of class `%s'",
- IDENTIFIER_POINTER (CLASS_NAME (implementation_context)));
- else if (TREE_CODE (implementation_context)
- == CATEGORY_IMPLEMENTATION_TYPE)
- warning ("incomplete implementation of category `%s'",
- IDENTIFIER_POINTER (CLASS_SUPER_NAME (implementation_context)));
- first = 0;
- }
-
- warning ("method definition for `%c%s' not found",
- mtype, IDENTIFIER_POINTER (METHOD_SEL_NAME (chain)));
- }
-
- chain = TREE_CHAIN (chain);
- }
-
- return first;
-}
-
-static int
-conforms_to_protocol (class, protocol)
- tree class;
- tree protocol;
-{
- while (protocol)
- {
- tree p = CLASS_PROTOCOL_LIST (class);
-
- while (p && TREE_VALUE (p) != TREE_VALUE (protocol))
- p = TREE_CHAIN (p);
-
- if (!p)
- {
- tree super = (CLASS_SUPER_NAME (class)
- ? lookup_interface (CLASS_SUPER_NAME (class))
- : NULL_TREE);
- int tmp = super ? conforms_to_protocol (super, protocol) : 0;
- if (!tmp)
- return 0;
- }
-
- protocol = TREE_CHAIN (protocol);
- }
-
- return 1;
-}
-
-/* Make sure all methods in CHAIN are accessible as MTYPE methods in
- CONTEXT. This is one of two mechanisms to check protocol integrity. */
-
-static int
-check_methods_accessible (chain, context, mtype)
- tree chain;
- tree context;
- int mtype;
-{
- int first = 1;
- tree list;
- tree base_context = context;
-
- while (chain)
- {
- context = base_context;
- while (context)
- {
- if (mtype == '+')
- list = CLASS_CLS_METHODS (context);
- else
- list = CLASS_NST_METHODS (context);
-
- if (lookup_method (list, chain))
- break;
-
- else if (TREE_CODE (context) == CLASS_IMPLEMENTATION_TYPE
- || TREE_CODE (context) == CLASS_INTERFACE_TYPE)
- context = (CLASS_SUPER_NAME (context)
- ? lookup_interface (CLASS_SUPER_NAME (context))
- : NULL_TREE);
-
- else if (TREE_CODE (context) == CATEGORY_IMPLEMENTATION_TYPE
- || TREE_CODE (context) == CATEGORY_INTERFACE_TYPE)
- context = (CLASS_NAME (context)
- ? lookup_interface (CLASS_NAME (context))
- : NULL_TREE);
- else
- abort ();
- }
-
- if (context == NULL_TREE)
- {
- if (first)
- {
- if (TREE_CODE (implementation_context)
- == CLASS_IMPLEMENTATION_TYPE)
- warning ("incomplete implementation of class `%s'",
- IDENTIFIER_POINTER
- (CLASS_NAME (implementation_context)));
- else if (TREE_CODE (implementation_context)
- == CATEGORY_IMPLEMENTATION_TYPE)
- warning ("incomplete implementation of category `%s'",
- IDENTIFIER_POINTER
- (CLASS_SUPER_NAME (implementation_context)));
- first = 0;
- }
- warning ("method definition for `%c%s' not found",
- mtype, IDENTIFIER_POINTER (METHOD_SEL_NAME (chain)));
- }
-
- chain = TREE_CHAIN (chain); /* next method... */
- }
- return first;
-}
-
-static void
-check_protocols (proto_list, type, name)
- tree proto_list;
- char *type;
- char *name;
-{
- for ( ; proto_list; proto_list = TREE_CHAIN (proto_list))
- {
- tree p = TREE_VALUE (proto_list);
-
- if (TREE_CODE (p) == PROTOCOL_INTERFACE_TYPE)
- {
- int f1, f2;
-
- /* Ensure that all protocols have bodies. */
- if (flag_warn_protocol) {
- f1 = check_methods (PROTOCOL_CLS_METHODS (p),
- CLASS_CLS_METHODS (implementation_context),
- '+');
- f2 = check_methods (PROTOCOL_NST_METHODS (p),
- CLASS_NST_METHODS (implementation_context),
- '-');
- } else {
- f1 = check_methods_accessible (PROTOCOL_CLS_METHODS (p),
- implementation_context,
- '+');
- f2 = check_methods_accessible (PROTOCOL_NST_METHODS (p),
- implementation_context,
- '-');
- }
-
- if (!f1 || !f2)
- warning ("%s `%s' does not fully implement the `%s' protocol",
- type, name, IDENTIFIER_POINTER (PROTOCOL_NAME (p)));
-
- }
- else
- ; /* An identifier if we could not find a protocol. */
-
- /* Check protocols recursively. */
- if (PROTOCOL_LIST (p))
- {
- tree super_class
- = lookup_interface (CLASS_SUPER_NAME (implementation_template));
- if (! conforms_to_protocol (super_class, PROTOCOL_LIST (p)))
- check_protocols (PROTOCOL_LIST (p), type, name);
- }
- }
-}
-
-/* Make sure that the class CLASS_NAME is defined
- CODE says which kind of thing CLASS_NAME ought to be.
- It can be CLASS_INTERFACE_TYPE, CLASS_IMPLEMENTATION_TYPE,
- CATEGORY_INTERFACE_TYPE, or CATEGORY_IMPLEMENTATION_TYPE.
-
- If CODE is CLASS_INTERFACE_TYPE, we also do a push_obstacks_nochange
- whose matching pop is in continue_class. */
-
-tree
-start_class (code, class_name, super_name, protocol_list)
- enum tree_code code;
- tree class_name;
- tree super_name;
- tree protocol_list;
-{
- tree class, decl;
-
- if (code == CLASS_INTERFACE_TYPE)
- {
- push_obstacks_nochange ();
- end_temporary_allocation ();
- }
-
- if (!doing_objc_thang)
- objc_fatal ();
-
- class = make_node (code);
- TYPE_BINFO (class) = make_tree_vec (5);
-
- CLASS_NAME (class) = class_name;
- CLASS_SUPER_NAME (class) = super_name;
- CLASS_CLS_METHODS (class) = NULL_TREE;
-
- if (! is_class_name (class_name) && (decl = lookup_name (class_name)))
- {
- error ("`%s' redeclared as different kind of symbol",
- IDENTIFIER_POINTER (class_name));
- error_with_decl (decl, "previous declaration of `%s'");
- }
-
- if (code == CLASS_IMPLEMENTATION_TYPE)
- {
- {
- static tree implemented_classes = 0;
- tree chain = implemented_classes;
- for (chain = implemented_classes; chain; chain = TREE_CHAIN (chain))
- if (TREE_VALUE (chain) == class_name)
- {
- error ("reimplementation of class `%s'",
- IDENTIFIER_POINTER (class_name));
- return error_mark_node;
- }
- implemented_classes = perm_tree_cons (NULL_TREE, class_name,
- implemented_classes);
- }
-
- /* Pre-build the following entities - for speed/convenience. */
- if (!self_id)
- self_id = get_identifier ("self");
- if (!ucmd_id)
- ucmd_id = get_identifier ("_cmd");
- if (!unused_list)
- unused_list
- = build_tree_list (get_identifier ("__unused__"), NULL_TREE);
- if (!objc_super_template)
- objc_super_template = build_super_template ();
-
- /* Reset for multiple classes per file. */
- method_slot = 0;
-
- implementation_context = class;
-
- /* Lookup the interface for this implementation. */
-
- if (!(implementation_template = lookup_interface (class_name)))
- {
- warning ("Cannot find interface declaration for `%s'",
- IDENTIFIER_POINTER (class_name));
- add_class (implementation_template = implementation_context);
- }
-
- /* If a super class has been specified in the implementation,
- insure it conforms to the one specified in the interface. */
-
- if (super_name
- && (super_name != CLASS_SUPER_NAME (implementation_template)))
- {
- tree previous_name = CLASS_SUPER_NAME (implementation_template);
- char *name = previous_name ? IDENTIFIER_POINTER (previous_name) : "";
- error ("conflicting super class name `%s'",
- IDENTIFIER_POINTER (super_name));
- error ("previous declaration of `%s'", name);
- }
-
- else if (! super_name)
- {
- CLASS_SUPER_NAME (implementation_context)
- = CLASS_SUPER_NAME (implementation_template);
- }
- }
-
- else if (code == CLASS_INTERFACE_TYPE)
- {
- if (lookup_interface (class_name))
- warning ("duplicate interface declaration for class `%s'",
- IDENTIFIER_POINTER (class_name));
- else
- add_class (class);
-
- if (protocol_list)
- CLASS_PROTOCOL_LIST (class)
- = lookup_and_install_protocols (protocol_list);
- }
-
- else if (code == CATEGORY_INTERFACE_TYPE)
- {
- tree class_category_is_assoc_with;
-
- /* For a category, class_name is really the name of the class that
- the following set of methods will be associated with. We must
- find the interface so that can derive the objects template. */
-
- if (!(class_category_is_assoc_with = lookup_interface (class_name)))
- {
- error ("Cannot find interface declaration for `%s'",
- IDENTIFIER_POINTER (class_name));
- exit (FATAL_EXIT_CODE);
- }
- else
- add_category (class_category_is_assoc_with, class);
-
- if (protocol_list)
- CLASS_PROTOCOL_LIST (class)
- = lookup_and_install_protocols (protocol_list);
- }
-
- else if (code == CATEGORY_IMPLEMENTATION_TYPE)
- {
- /* Pre-build the following entities for speed/convenience. */
- if (!self_id)
- self_id = get_identifier ("self");
- if (!ucmd_id)
- ucmd_id = get_identifier ("_cmd");
- if (!unused_list)
- unused_list
- = build_tree_list (get_identifier ("__unused__"), NULL_TREE);
- if (!objc_super_template)
- objc_super_template = build_super_template ();
-
- /* Reset for multiple classes per file. */
- method_slot = 0;
-
- implementation_context = class;
-
- /* For a category, class_name is really the name of the class that
- the following set of methods will be associated with. We must
- find the interface so that can derive the objects template. */
-
- if (!(implementation_template = lookup_interface (class_name)))
- {
- error ("Cannot find interface declaration for `%s'",
- IDENTIFIER_POINTER (class_name));
- exit (FATAL_EXIT_CODE);
- }
- }
- return class;
-}
-
-tree
-continue_class (class)
- tree class;
-{
- if (TREE_CODE (class) == CLASS_IMPLEMENTATION_TYPE
- || TREE_CODE (class) == CATEGORY_IMPLEMENTATION_TYPE)
- {
- struct imp_entry *imp_entry;
- tree ivar_context;
-
- /* Check consistency of the instance variables. */
-
- if (CLASS_IVARS (class))
- check_ivars (implementation_template, class);
-
- /* code generation */
-
- ivar_context = build_private_template (implementation_template);
-
- if (!objc_class_template)
- build_class_template ();
-
- if (!(imp_entry
- = (struct imp_entry *) xmalloc (sizeof (struct imp_entry))))
- perror ("unable to allocate in objc-tree.c");
-
- imp_entry->next = imp_list;
- imp_entry->imp_context = class;
- imp_entry->imp_template = implementation_template;
-
- synth_forward_declarations ();
- imp_entry->class_decl = UOBJC_CLASS_decl;
- imp_entry->meta_decl = UOBJC_METACLASS_decl;
-
- /* Append to front and increment count. */
- imp_list = imp_entry;
- if (TREE_CODE (class) == CLASS_IMPLEMENTATION_TYPE)
- imp_count++;
- else
- cat_count++;
-
- return ivar_context;
- }
-
- else if (TREE_CODE (class) == CLASS_INTERFACE_TYPE)
- {
- tree record = xref_tag (RECORD_TYPE, CLASS_NAME (class));
-
- if (!TYPE_FIELDS (record))
- {
- finish_struct (record, build_ivar_chain (class, 0), NULL_TREE);
- CLASS_STATIC_TEMPLATE (class) = record;
-
- /* Mark this record as a class template for static typing. */
- TREE_STATIC_TEMPLATE (record) = 1;
- }
-
- return NULL_TREE;
- }
-
- else
- return error_mark_node;
-}
-
-/* This is called once we see the "@end" in an interface/implementation. */
-
-void
-finish_class (class)
- tree class;
-{
- if (TREE_CODE (class) == CLASS_IMPLEMENTATION_TYPE)
- {
- /* All code generation is done in finish_objc. */
-
- if (implementation_template != implementation_context)
- {
- /* Ensure that all method listed in the interface contain bodies. */
- check_methods (CLASS_CLS_METHODS (implementation_template),
- CLASS_CLS_METHODS (implementation_context), '+');
- check_methods (CLASS_NST_METHODS (implementation_template),
- CLASS_NST_METHODS (implementation_context), '-');
-
- if (CLASS_PROTOCOL_LIST (implementation_template))
- check_protocols (CLASS_PROTOCOL_LIST (implementation_template),
- "class",
- IDENTIFIER_POINTER (CLASS_NAME (implementation_context)));
- }
- }
-
- else if (TREE_CODE (class) == CATEGORY_IMPLEMENTATION_TYPE)
- {
- tree category = CLASS_CATEGORY_LIST (implementation_template);
-
- /* Find the category interface from the class it is associated with. */
- while (category)
- {
- if (CLASS_SUPER_NAME (class) == CLASS_SUPER_NAME (category))
- break;
- category = CLASS_CATEGORY_LIST (category);
- }
-
- if (category)
- {
- /* Ensure all method listed in the interface contain bodies. */
- check_methods (CLASS_CLS_METHODS (category),
- CLASS_CLS_METHODS (implementation_context), '+');
- check_methods (CLASS_NST_METHODS (category),
- CLASS_NST_METHODS (implementation_context), '-');
-
- if (CLASS_PROTOCOL_LIST (category))
- check_protocols (CLASS_PROTOCOL_LIST (category),
- "category",
- IDENTIFIER_POINTER (CLASS_SUPER_NAME (implementation_context)));
- }
- }
-
- else if (TREE_CODE (class) == CLASS_INTERFACE_TYPE)
- {
- tree decl_specs;
- char *class_name = IDENTIFIER_POINTER (CLASS_NAME (class));
- char *string = (char *) alloca (strlen (class_name) + 3);
-
- /* extern struct objc_object *_<my_name>; */
-
- sprintf (string, "_%s", class_name);
-
- decl_specs = build_tree_list (NULL_TREE, ridpointers[(int) RID_EXTERN]);
- decl_specs = tree_cons (NULL_TREE, objc_object_reference, decl_specs);
- define_decl (build1 (INDIRECT_REF, NULL_TREE, get_identifier (string)),
- decl_specs);
- }
-}
-
-static tree
-add_protocol (protocol)
- tree protocol;
-{
- /* Put protocol on list in reverse order. */
- TREE_CHAIN (protocol) = protocol_chain;
- protocol_chain = protocol;
- return protocol_chain;
-}
-
-static tree
-lookup_protocol (ident)
- tree ident;
-{
- tree chain;
-
- for (chain = protocol_chain; chain; chain = TREE_CHAIN (chain))
- {
- if (ident == PROTOCOL_NAME (chain))
- return chain;
- }
-
- return NULL_TREE;
-}
-
-tree
-start_protocol (code, name, list)
- enum tree_code code;
- tree name;
- tree list;
-{
- tree protocol;
-
- if (!doing_objc_thang)
- objc_fatal ();
-
- /* This is as good a place as any. Need to invoke push_tag_toplevel. */
- if (!objc_protocol_template)
- objc_protocol_template = build_protocol_template ();
-
- protocol = make_node (code);
- TYPE_BINFO (protocol) = make_tree_vec (2);
-
- PROTOCOL_NAME (protocol) = name;
- PROTOCOL_LIST (protocol) = list;
-
- lookup_and_install_protocols (list);
-
- if (lookup_protocol (name))
- warning ("duplicate declaration for protocol `%s'",
- IDENTIFIER_POINTER (name));
- else
- add_protocol (protocol);
-
- PROTOCOL_FORWARD_DECL (protocol) = NULL_TREE;
-
- return protocol;
-}
-
-void
-finish_protocol (protocol)
- tree protocol;
-{
-}
-
-
-/* "Encode" a data type into a string, which grows in util_obstack.
- ??? What is the FORMAT? Someone please document this! */
-
-static void
-encode_type_qualifiers (declspecs)
- tree declspecs;
-{
- tree spec;
-
- for (spec = declspecs; spec; spec = TREE_CHAIN (spec))
- {
- if (ridpointers[(int) RID_CONST] == TREE_VALUE (spec))
- obstack_1grow (&util_obstack, 'r');
- else if (ridpointers[(int) RID_IN] == TREE_VALUE (spec))
- obstack_1grow (&util_obstack, 'n');
- else if (ridpointers[(int) RID_INOUT] == TREE_VALUE (spec))
- obstack_1grow (&util_obstack, 'N');
- else if (ridpointers[(int) RID_OUT] == TREE_VALUE (spec))
- obstack_1grow (&util_obstack, 'o');
- else if (ridpointers[(int) RID_BYCOPY] == TREE_VALUE (spec))
- obstack_1grow (&util_obstack, 'O');
- else if (ridpointers[(int) RID_ONEWAY] == TREE_VALUE (spec))
- obstack_1grow (&util_obstack, 'V');
- }
-}
-
-/* Encode a pointer type. */
-
-static void
-encode_pointer (type, curtype, format)
- tree type;
- int curtype;
- int format;
-{
- tree pointer_to = TREE_TYPE (type);
-
- if (TREE_CODE (pointer_to) == RECORD_TYPE)
- {
- if (TYPE_NAME (pointer_to)
- && TREE_CODE (TYPE_NAME (pointer_to)) == IDENTIFIER_NODE)
- {
- char *name = IDENTIFIER_POINTER (TYPE_NAME (pointer_to));
-
- if (strcmp (name, TAG_OBJECT) == 0) /* '@' */
- {
- obstack_1grow (&util_obstack, '@');
- return;
- }
- else if (TREE_STATIC_TEMPLATE (pointer_to))
- {
- if (generating_instance_variables)
- {
- obstack_1grow (&util_obstack, '@');
- obstack_1grow (&util_obstack, '"');
- obstack_grow (&util_obstack, name, strlen (name));
- obstack_1grow (&util_obstack, '"');
- return;
- }
- else
- {
- obstack_1grow (&util_obstack, '@');
- return;
- }
- }
- else if (strcmp (name, TAG_CLASS) == 0) /* '#' */
- {
- obstack_1grow (&util_obstack, '#');
- return;
- }
-#ifndef OBJC_INT_SELECTORS
- else if (strcmp (name, TAG_SELECTOR) == 0) /* ':' */
- {
- obstack_1grow (&util_obstack, ':');
- return;
- }
-#endif /* OBJC_INT_SELECTORS */
- }
- }
- else if (TREE_CODE (pointer_to) == INTEGER_TYPE
- && TYPE_MODE (pointer_to) == QImode)
- {
- obstack_1grow (&util_obstack, '*');
- return;
- }
-
- /* We have a type that does not get special treatment. */
-
- /* NeXT extension */
- obstack_1grow (&util_obstack, '^');
- encode_type (pointer_to, curtype, format);
-}
-
-static void
-encode_array (type, curtype, format)
- tree type;
- int curtype;
- int format;
-{
- tree an_int_cst = TYPE_SIZE (type);
- tree array_of = TREE_TYPE (type);
- char buffer[40];
-
- /* An incomplete array is treated like a pointer. */
- if (an_int_cst == NULL)
- {
- encode_pointer (type, curtype, format);
- return;
- }
-
- sprintf (buffer, "[%d",
- (TREE_INT_CST_LOW (an_int_cst)
- / TREE_INT_CST_LOW (TYPE_SIZE (array_of))));
-
- obstack_grow (&util_obstack, buffer, strlen (buffer));
- encode_type (array_of, curtype, format);
- obstack_1grow (&util_obstack, ']');
- return;
-}
-
-static void
-encode_aggregate (type, curtype, format)
- tree type;
- int curtype;
- int format;
-{
- enum tree_code code = TREE_CODE (type);
-
- switch (code)
- {
- case RECORD_TYPE:
- {
- if (obstack_object_size (&util_obstack) > 0
- && *(obstack_next_free (&util_obstack) - 1) == '^')
- {
- tree name = TYPE_NAME (type);
-
- /* We have a reference; this is a NeXT extension. */
-
- if (obstack_object_size (&util_obstack) - curtype == 1
- && format == OBJC_ENCODE_INLINE_DEFS)
- {
- /* Output format of struct for first level only. */
- tree fields = TYPE_FIELDS (type);
-
- if (name && TREE_CODE (name) == IDENTIFIER_NODE)
- {
- obstack_1grow (&util_obstack, '{');
- obstack_grow (&util_obstack,
- IDENTIFIER_POINTER (name),
- strlen (IDENTIFIER_POINTER (name)));
- obstack_1grow (&util_obstack, '=');
- }
-
- else
- obstack_grow (&util_obstack, "{?=", 3);
-
- for ( ; fields; fields = TREE_CHAIN (fields))
- encode_field_decl (fields, curtype, format);
-
- obstack_1grow (&util_obstack, '}');
- }
-
- else if (name && TREE_CODE (name) == IDENTIFIER_NODE)
- {
- obstack_1grow (&util_obstack, '{');
- obstack_grow (&util_obstack,
- IDENTIFIER_POINTER (name),
- strlen (IDENTIFIER_POINTER (name)));
- obstack_1grow (&util_obstack, '}');
- }
-
- else
- /* We have an untagged structure or a typedef. */
- obstack_grow (&util_obstack, "{?}", 3);
- }
-
- else
- {
- tree name = TYPE_NAME (type);
- tree fields = TYPE_FIELDS (type);
-
- if (format == OBJC_ENCODE_INLINE_DEFS
- || generating_instance_variables)
- {
- obstack_1grow (&util_obstack, '{');
- if (name && TREE_CODE (name) == IDENTIFIER_NODE)
- obstack_grow (&util_obstack,
- IDENTIFIER_POINTER (name),
- strlen (IDENTIFIER_POINTER (name)));
-
- else
- obstack_1grow (&util_obstack, '?');
-
- obstack_1grow (&util_obstack, '=');
-
- for (; fields; fields = TREE_CHAIN (fields))
- {
- if (generating_instance_variables)
- {
- tree fname = DECL_NAME (fields);
-
- obstack_1grow (&util_obstack, '"');
- if (fname && TREE_CODE (fname) == IDENTIFIER_NODE)
- {
- obstack_grow (&util_obstack,
- IDENTIFIER_POINTER (fname),
- strlen (IDENTIFIER_POINTER (fname)));
- }
-
- obstack_1grow (&util_obstack, '"');
- }
-
- encode_field_decl (fields, curtype, format);
- }
-
- obstack_1grow (&util_obstack, '}');
- }
-
- else
- {
- obstack_1grow (&util_obstack, '{');
- if (name && TREE_CODE (name) == IDENTIFIER_NODE)
- obstack_grow (&util_obstack,
- IDENTIFIER_POINTER (name),
- strlen (IDENTIFIER_POINTER (name)));
- else
- /* We have an untagged structure or a typedef. */
- obstack_1grow (&util_obstack, '?');
-
- obstack_1grow (&util_obstack, '}');
- }
- }
- break;
- }
-
- case UNION_TYPE:
- {
- if (*obstack_next_free (&util_obstack) == '^'
- || format != OBJC_ENCODE_INLINE_DEFS)
- {
- /* We have a reference (this is a NeXT extension)
- or we don't want the details. */
- if (TYPE_NAME (type)
- && TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
- {
- obstack_1grow (&util_obstack, '(');
- obstack_grow (&util_obstack,
- IDENTIFIER_POINTER (TYPE_NAME (type)),
- strlen (IDENTIFIER_POINTER (TYPE_NAME (type))));
- obstack_1grow (&util_obstack, ')');
- }
-
- else
- /* We have an untagged structure or a typedef. */
- obstack_grow (&util_obstack, "(?)", 3);
- }
- else
- {
- tree fields = TYPE_FIELDS (type);
- obstack_1grow (&util_obstack, '(');
- for ( ; fields; fields = TREE_CHAIN (fields))
- encode_field_decl (fields, curtype, format);
-
- obstack_1grow (&util_obstack, ')');
- }
- break;
- }
-
- case ENUMERAL_TYPE:
- obstack_1grow (&util_obstack, 'i');
- break;
- }
-}
-
-/* Support bitfields. The current version of Objective-C does not support
- them. The string will consist of one or more "b:n"'s where n is an
- integer describing the width of the bitfield. Currently, classes in
- the kit implement a method "-(char *)describeBitfieldStruct:" that
- simulates this. If they do not implement this method, the archiver
- assumes the bitfield is 16 bits wide (padded if necessary) and packed
- according to the GNU compiler. After looking at the "kit", it appears
- that all classes currently rely on this default behavior, rather than
- hand generating this string (which is tedious). */
-
-static void
-encode_bitfield (width, format)
- int width;
- int format;
-{
- char buffer[40];
- sprintf (buffer, "b%d", width);
- obstack_grow (&util_obstack, buffer, strlen (buffer));
-}
-
-/* FORMAT will be OBJC_ENCODE_INLINE_DEFS or OBJC_ENCODE_DONT_INLINE_DEFS. */
-
-static void
-encode_type (type, curtype, format)
- tree type;
- int curtype;
- int format;
-{
- enum tree_code code = TREE_CODE (type);
-
- if (code == INTEGER_TYPE)
- {
- if (TREE_INT_CST_LOW (TYPE_MIN_VALUE (type)) == 0
- && TREE_INT_CST_HIGH (TYPE_MIN_VALUE (type)) == 0)
- {
- /* Unsigned integer types. */
-
- if (TYPE_MODE (type) == QImode)
- obstack_1grow (&util_obstack, 'C');
- else if (TYPE_MODE (type) == HImode)
- obstack_1grow (&util_obstack, 'S');
- else if (TYPE_MODE (type) == SImode)
- {
- if (type == long_unsigned_type_node)
- obstack_1grow (&util_obstack, 'L');
- else
- obstack_1grow (&util_obstack, 'I');
- }
- else if (TYPE_MODE (type) == DImode)
- obstack_1grow (&util_obstack, 'Q');
- }
-
- else
- /* Signed integer types. */
- {
- if (TYPE_MODE (type) == QImode)
- obstack_1grow (&util_obstack, 'c');
- else if (TYPE_MODE (type) == HImode)
- obstack_1grow (&util_obstack, 's');
- else if (TYPE_MODE (type) == SImode)
- {
- if (type == long_integer_type_node)
- obstack_1grow (&util_obstack, 'l');
- else
- obstack_1grow (&util_obstack, 'i');
- }
-
- else if (TYPE_MODE (type) == DImode)
- obstack_1grow (&util_obstack, 'q');
- }
- }
-
- else if (code == REAL_TYPE)
- {
- /* Floating point types. */
-
- if (TYPE_MODE (type) == SFmode)
- obstack_1grow (&util_obstack, 'f');
- else if (TYPE_MODE (type) == DFmode
- || TYPE_MODE (type) == TFmode)
- obstack_1grow (&util_obstack, 'd');
- }
-
- else if (code == VOID_TYPE)
- obstack_1grow (&util_obstack, 'v');
-
- else if (code == ARRAY_TYPE)
- encode_array (type, curtype, format);
-
- else if (code == POINTER_TYPE)
- encode_pointer (type, curtype, format);
-
- else if (code == RECORD_TYPE || code == UNION_TYPE || code == ENUMERAL_TYPE)
- encode_aggregate (type, curtype, format);
-
- else if (code == FUNCTION_TYPE) /* '?' */
- obstack_1grow (&util_obstack, '?');
-}
-
-static void
-encode_field_decl (field_decl, curtype, format)
- tree field_decl;
- int curtype;
- int format;
-{
- tree type;
-
- /* If this field is obviously a bitfield, or is a bitfield that has been
- clobbered to look like a ordinary integer mode, go ahead and generate
- the bitfield typing information. */
- type = TREE_TYPE (field_decl);
- if (DECL_BIT_FIELD (field_decl))
- encode_bitfield (DECL_FIELD_SIZE (field_decl), format);
- else if (TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST
- && DECL_FIELD_SIZE (field_decl)
- && TYPE_MODE (type) > DECL_MODE (field_decl))
- encode_bitfield (DECL_FIELD_SIZE (field_decl), format);
- else
- encode_type (TREE_TYPE (field_decl), curtype, format);
-}
-
-static tree
-expr_last (complex_expr)
- tree complex_expr;
-{
- tree next;
-
- if (complex_expr)
- while ((next = TREE_OPERAND (complex_expr, 0)))
- complex_expr = next;
-
- return complex_expr;
-}
-
-/* The selector of the current method,
- or NULL if we aren't compiling a method. */
-
-tree
-maybe_objc_method_name (decl)
- tree decl;
-{
- if (method_context)
- return METHOD_SEL_NAME (method_context);
- else
- return 0;
-}
-
-/* Transform a method definition into a function definition as follows:
- - synthesize the first two arguments, "self" and "_cmd". */
-
-void
-start_method_def (method)
- tree method;
-{
- tree decl_specs;
-
- /* Required to implement _msgSuper. */
- method_context = method;
- UOBJC_SUPER_decl = NULL_TREE;
-
- /* Must be called BEFORE start_function. */
- pushlevel (0);
-
- /* Generate prototype declarations for arguments..."new-style". */
-
- if (TREE_CODE (method_context) == INSTANCE_METHOD_DECL)
- decl_specs = build_tree_list (NULL_TREE, uprivate_record);
- else
- /* Really a `struct objc_class *'. However, we allow people to
- assign to self, which changes its type midstream. */
- decl_specs = build_tree_list (NULL_TREE, objc_object_reference);
-
- push_parm_decl (build_tree_list
- (build_tree_list (decl_specs,
- build1 (INDIRECT_REF, NULL_TREE, self_id)),
- build_tree_list (unused_list, NULL_TREE)));
-
-#ifdef OBJC_INT_SELECTORS
- decl_specs = build_tree_list (NULL_TREE, ridpointers[(int) RID_UNSIGNED]);
- decl_specs = tree_cons (NULL_TREE, ridpointers[(int) RID_INT], decl_specs);
- push_parm_decl (build_tree_list (build_tree_list (decl_specs, ucmd_id),
- build_tree_list (unused_list, NULL_TREE)));
-#else /* not OBJC_INT_SELECTORS */
- decl_specs = build_tree_list (NULL_TREE,
- xref_tag (RECORD_TYPE,
- get_identifier (TAG_SELECTOR)));
- push_parm_decl (build_tree_list
- (build_tree_list (decl_specs,
- build1 (INDIRECT_REF, NULL_TREE, ucmd_id)),
- build_tree_list (unused_list, NULL_TREE)));
-#endif /* not OBJC_INT_SELECTORS */
-
- /* Generate argument declarations if a keyword_decl. */
- if (METHOD_SEL_ARGS (method))
- {
- tree arglist = METHOD_SEL_ARGS (method);
- do
- {
- tree arg_spec = TREE_PURPOSE (TREE_TYPE (arglist));
- tree arg_decl = TREE_VALUE (TREE_TYPE (arglist));
-
- if (arg_decl)
- {
- tree last_expr = expr_last (arg_decl);
-
- /* Unite the abstract decl with its name. */
- TREE_OPERAND (last_expr, 0) = KEYWORD_ARG_NAME (arglist);
- push_parm_decl (build_tree_list
- (build_tree_list (arg_spec, arg_decl),
- build_tree_list (NULL_TREE, NULL_TREE)));
-
- /* Unhook: restore the abstract declarator. */
- TREE_OPERAND (last_expr, 0) = NULL_TREE;
- }
-
- else
- push_parm_decl (build_tree_list
- (build_tree_list (arg_spec,
- KEYWORD_ARG_NAME (arglist)),
- build_tree_list (NULL_TREE, NULL_TREE)));
-
- arglist = TREE_CHAIN (arglist);
- }
- while (arglist);
- }
-
- if (METHOD_ADD_ARGS (method) > (tree)1)
- {
- /* We have a variable length selector - in "prototype" format. */
- tree akey = TREE_PURPOSE (METHOD_ADD_ARGS (method));
- while (akey)
- {
- /* This must be done prior to calling pushdecl. pushdecl is
- going to change our chain on us. */
- tree nextkey = TREE_CHAIN (akey);
- pushdecl (akey);
- akey = nextkey;
- }
- }
-}
-
-static void
-warn_with_method (message, mtype, method)
- char *message;
- int mtype;
- tree method;
-{
- if (count_error (1) == 0)
- return;
-
- report_error_function (DECL_SOURCE_FILE (method));
-
- fprintf (stderr, "%s:%d: warning: ",
- DECL_SOURCE_FILE (method), DECL_SOURCE_LINE (method));
- bzero (errbuf, BUFSIZE);
- fprintf (stderr, "%s `%c%s'\n",
- message, mtype, gen_method_decl (method, errbuf));
-}
-
-/* Return 1 if METHOD is consistent with PROTO. */
-
-static int
-comp_method_with_proto (method, proto)
- tree method, proto;
-{
- static tree function_type = 0;
-
- /* Create a function_type node once. */
- if (!function_type)
- {
- push_obstacks_nochange ();
- end_temporary_allocation ();
- function_type = make_node (FUNCTION_TYPE);
- pop_obstacks ();
- }
-
- /* Install argument types - normally set by build_function_type. */
- TYPE_ARG_TYPES (function_type) = get_arg_type_list (proto, METHOD_DEF, 0);
-
- /* install return type */
- TREE_TYPE (function_type) = groktypename (TREE_TYPE (proto));
-
- return comptypes (TREE_TYPE (METHOD_DEFINITION (method)), function_type);
-}
-
-/* Return 1 if PROTO1 is consistent with PROTO2. */
-
-static int
-comp_proto_with_proto (proto1, proto2)
- tree proto1, proto2;
-{
- static tree function_type1 = 0, function_type2 = 0;
-
- /* Create a couple function_type node's once. */
- if (!function_type1)
- {
- push_obstacks_nochange ();
- end_temporary_allocation ();
- function_type1 = make_node (FUNCTION_TYPE);
- function_type2 = make_node (FUNCTION_TYPE);
- pop_obstacks ();
- }
-
- /* Install argument types; normally set by build_function_type. */
- TYPE_ARG_TYPES (function_type1) = get_arg_type_list (proto1, METHOD_REF, 0);
- TYPE_ARG_TYPES (function_type2) = get_arg_type_list (proto2, METHOD_REF, 0);
-
- /* Install return type. */
- TREE_TYPE (function_type1) = groktypename (TREE_TYPE (proto1));
- TREE_TYPE (function_type2) = groktypename (TREE_TYPE (proto2));
-
- return comptypes (function_type1, function_type2);
-}
-
-/* - Generate an identifier for the function. the format is "_n_cls",
- where 1 <= n <= nMethods, and cls is the name the implementation we
- are processing.
- - Install the return type from the method declaration.
- - If we have a prototype, check for type consistency. */
-
-static void
-really_start_method (method, parmlist)
- tree method, parmlist;
-{
- tree sc_spec, ret_spec, ret_decl, decl_specs;
- tree method_decl, method_id;
- char *buf, *sel_name, *class_name, *cat_name;
-
- /* Synth the storage class & assemble the return type. */
- sc_spec = tree_cons (NULL_TREE, ridpointers[(int) RID_STATIC], NULL_TREE);
- ret_spec = TREE_PURPOSE (TREE_TYPE (method));
- decl_specs = chainon (sc_spec, ret_spec);
-
- sel_name = IDENTIFIER_POINTER (METHOD_SEL_NAME (method));
- class_name = IDENTIFIER_POINTER (CLASS_NAME (implementation_context));
- cat_name = ((TREE_CODE (implementation_context)
- == CLASS_IMPLEMENTATION_TYPE)
- ? NULL
- : IDENTIFIER_POINTER (CLASS_SUPER_NAME (implementation_context)));
- method_slot++;
-
- /* Make sure this is big enough for any plausible method label. */
- buf = (char *) alloca (50 + strlen (sel_name) + strlen (class_name)
- + (cat_name ? strlen (cat_name) : 0));
-
- OBJC_GEN_METHOD_LABEL (buf, TREE_CODE (method) == INSTANCE_METHOD_DECL,
- class_name, cat_name, sel_name, method_slot);
-
- method_id = get_identifier (buf);
-
- method_decl = build_nt (CALL_EXPR, method_id, parmlist, NULL_TREE);
-
- /* Check the declarator portion of the return type for the method. */
- if ((ret_decl = TREE_VALUE (TREE_TYPE (method))))
- {
- /* Unite the complex decl (specified in the abstract decl) with the
- function decl just synthesized..(int *), (int (*)()), (int (*)[]). */
- tree save_expr = expr_last (ret_decl);
-
- TREE_OPERAND (save_expr, 0) = method_decl;
- method_decl = ret_decl;
-
- /* Fool the parser into thinking it is starting a function. */
- start_function (decl_specs, method_decl, NULL_TREE, NULL_TREE, 0);
-
- /* Unhook: this has the effect of restoring the abstract declarator. */
- TREE_OPERAND (save_expr, 0) = NULL_TREE;
- }
-
- else
- {
- TREE_VALUE (TREE_TYPE (method)) = method_decl;
-
- /* Fool the parser into thinking it is starting a function. */
- start_function (decl_specs, method_decl, NULL_TREE, NULL_TREE, 0);
-
- /* Unhook: this has the effect of restoring the abstract declarator. */
- TREE_VALUE (TREE_TYPE (method)) = NULL_TREE;
- }
-
- METHOD_DEFINITION (method) = current_function_decl;
-
- if (implementation_template != implementation_context)
- {
- tree proto;
-
- if (TREE_CODE (method) == INSTANCE_METHOD_DECL)
- proto = lookup_instance_method_static (implementation_template,
- METHOD_SEL_NAME (method));
- else
- proto = lookup_class_method_static (implementation_template,
- METHOD_SEL_NAME (method));
-
- if (proto && ! comp_method_with_proto (method, proto))
- {
- char type = (TREE_CODE (method) == INSTANCE_METHOD_DECL ? '-' : '+');
-
- warn_with_method ("conflicting types for", type, method);
- warn_with_method ("previous declaration of", type, proto);
- }
- }
-}
-
-/* The following routine is always called...this "architecture" is to
- accommodate "old-style" variable length selectors.
-
- - a:a b:b // prototype ; id c; id d; // old-style. */
-
-void
-continue_method_def ()
-{
- tree parmlist;
-
- if (METHOD_ADD_ARGS (method_context) == (tree)1)
- /* We have a `, ...' immediately following the selector. */
- parmlist = get_parm_info (0);
- else
- parmlist = get_parm_info (1); /* place a `void_at_end' */
-
- /* Set self_decl from the first argument...this global is used by
- build_ivar_reference calling build_indirect_ref. */
- self_decl = TREE_PURPOSE (parmlist);
-
- poplevel (0, 0, 0);
- really_start_method (method_context, parmlist);
- store_parm_decls ();
-}
-
-/* Called by the parser, from the `pushlevel' production. */
-
-void
-add_objc_decls ()
-{
- if (!UOBJC_SUPER_decl)
- {
- UOBJC_SUPER_decl = start_decl (get_identifier (UTAG_SUPER),
- build_tree_list (NULL_TREE,
- objc_super_template),
- 0, NULL_TREE, NULL_TREE);
-
- finish_decl (UOBJC_SUPER_decl, NULL_TREE, NULL_TREE);
-
- /* This prevents `unused variable' warnings when compiling with -Wall. */
- TREE_USED (UOBJC_SUPER_decl) = 1;
- DECL_ARTIFICIAL (UOBJC_SUPER_decl) = 1;
- }
-}
-
-/* _n_Method (id self, SEL sel, ...)
- {
- struct objc_super _S;
- _msgSuper ((_S.self = self, _S.class = _cls, &_S), ...);
- } */
-
-tree
-get_super_receiver ()
-{
- if (method_context)
- {
- tree super_expr, super_expr_list;
-
- /* Set receiver to self. */
- super_expr = build_component_ref (UOBJC_SUPER_decl, self_id);
- super_expr = build_modify_expr (super_expr, NOP_EXPR, self_decl);
- super_expr_list = build_tree_list (NULL_TREE, super_expr);
-
- /* Set class to begin searching. */
- super_expr = build_component_ref (UOBJC_SUPER_decl,
- get_identifier ("class"));
-
- if (TREE_CODE (implementation_context) == CLASS_IMPLEMENTATION_TYPE)
- {
- /* [_cls, __cls]Super are "pre-built" in
- synth_forward_declarations. */
-
- super_expr = build_modify_expr (super_expr, NOP_EXPR,
- ((TREE_CODE (method_context)
- == INSTANCE_METHOD_DECL)
- ? ucls_super_ref
- : uucls_super_ref));
- }
-
- else
- /* We have a category. */
- {
- tree super_name = CLASS_SUPER_NAME (implementation_template);
- tree super_class;
-
- if (!super_name)
- {
- error ("no super class declared in interface for `%s'",
- IDENTIFIER_POINTER (CLASS_NAME (implementation_template)));
- return error_mark_node;
- }
-
- if (flag_next_runtime)
- {
- super_class = get_class_reference (super_name);
- if (TREE_CODE (method_context) == CLASS_METHOD_DECL)
- super_class
- = build_component_ref (build_indirect_ref (super_class, "->"),
- get_identifier ("isa"));
- }
- else
- {
- add_class_reference (super_name);
- super_class = (TREE_CODE (method_context) == INSTANCE_METHOD_DECL
- ? objc_get_class_decl : objc_get_meta_class_decl);
- assemble_external (super_class);
- super_class
- = build_function_call
- (super_class,
- build_tree_list
- (NULL_TREE,
- my_build_string (IDENTIFIER_LENGTH (super_name) + 1,
- IDENTIFIER_POINTER (super_name))));
- }
-
- TREE_TYPE (super_class) = TREE_TYPE (ucls_super_ref);
- super_expr = build_modify_expr (super_expr, NOP_EXPR, super_class);
- }
-
- chainon (super_expr_list, build_tree_list (NULL_TREE, super_expr));
-
- super_expr = build_unary_op (ADDR_EXPR, UOBJC_SUPER_decl, 0);
- chainon (super_expr_list, build_tree_list (NULL_TREE, super_expr));
-
- return build_compound_expr (super_expr_list);
- }
- else
- {
- error ("[super ...] must appear in a method context");
- return error_mark_node;
- }
-}
-
-static tree
-encode_method_def (func_decl)
- tree func_decl;
-{
- tree parms;
- int stack_size;
- int max_parm_end = 0;
- char buffer[40];
- tree result;
-
- /* Return type. */
- encode_type (TREE_TYPE (TREE_TYPE (func_decl)),
- obstack_object_size (&util_obstack),
- OBJC_ENCODE_INLINE_DEFS);
-
- /* Stack size. */
- for (parms = DECL_ARGUMENTS (func_decl); parms;
- parms = TREE_CHAIN (parms))
- {
- int parm_end = (forwarding_offset (parms)
- + (TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (parms)))
- / BITS_PER_UNIT));
-
- if (!offset_is_register && parm_end > max_parm_end)
- max_parm_end = parm_end;
- }
-
- stack_size = max_parm_end - OBJC_FORWARDING_MIN_OFFSET;
-
- sprintf (buffer, "%d", stack_size);
- obstack_grow (&util_obstack, buffer, strlen (buffer));
-
- /* Argument types. */
- for (parms = DECL_ARGUMENTS (func_decl); parms;
- parms = TREE_CHAIN (parms))
- {
- /* Type. */
- encode_type (TREE_TYPE (parms),
- obstack_object_size (&util_obstack),
- OBJC_ENCODE_INLINE_DEFS);
-
- /* Compute offset. */
- sprintf (buffer, "%d", forwarding_offset (parms));
-
- /* Indicate register. */
- if (offset_is_register)
- obstack_1grow (&util_obstack, '+');
-
- obstack_grow (&util_obstack, buffer, strlen (buffer));
- }
-
- obstack_1grow (&util_obstack, 0);
- result = get_identifier (obstack_finish (&util_obstack));
- obstack_free (&util_obstack, util_firstobj);
- return result;
-}
-
-void
-finish_method_def ()
-{
- METHOD_ENCODING (method_context) = encode_method_def (current_function_decl);
-
- finish_function (0);
-
- /* Required to implement _msgSuper. This must be done AFTER finish_function,
- since the optimizer may find "may be used before set" errors. */
- method_context = NULL_TREE;
-}
-
-int
-lang_report_error_function (decl)
- tree decl;
-{
- if (method_context)
- {
- fprintf (stderr, "In method `%s'\n",
- IDENTIFIER_POINTER (METHOD_SEL_NAME (method_context)));
- return 1;
- }
-
- else
- return 0;
-}
-
-static int
-is_complex_decl (type)
- tree type;
-{
- return (TREE_CODE (type) == ARRAY_TYPE
- || TREE_CODE (type) == FUNCTION_TYPE
- || (TREE_CODE (type) == POINTER_TYPE && ! IS_ID (type)));
-}
-
-
-/* Code to convert a decl node into text for a declaration in C. */
-
-static char tmpbuf[256];
-
-static void
-adorn_decl (decl, str)
- tree decl;
- char *str;
-{
- enum tree_code code = TREE_CODE (decl);
-
- if (code == ARRAY_REF)
- {
- tree an_int_cst = TREE_OPERAND (decl, 1);
-
- if (an_int_cst && TREE_CODE (an_int_cst) == INTEGER_CST)
- sprintf (str + strlen (str), "[%d]", TREE_INT_CST_LOW (an_int_cst));
- else
- strcat (str, "[]");
- }
-
- else if (code == ARRAY_TYPE)
- {
- tree an_int_cst = TYPE_SIZE (decl);
- tree array_of = TREE_TYPE (decl);
-
- if (an_int_cst && TREE_CODE (an_int_cst) == INTEGER_TYPE)
- sprintf (str + strlen (str), "[%d]",
- (TREE_INT_CST_LOW (an_int_cst)
- / TREE_INT_CST_LOW (TYPE_SIZE (array_of))));
- else
- strcat (str, "[]");
- }
-
- else if (code == CALL_EXPR)
- {
- tree chain = TREE_PURPOSE (TREE_OPERAND (decl, 1));
-
- strcat (str, "(");
- while (chain)
- {
- gen_declaration (chain, str);
- chain = TREE_CHAIN (chain);
- if (chain)
- strcat (str, ", ");
- }
- strcat (str, ")");
- }
-
- else if (code == FUNCTION_TYPE)
- {
- tree chain = TYPE_ARG_TYPES (decl);
-
- strcat (str, "(");
- while (chain && TREE_VALUE (chain) != void_type_node)
- {
- gen_declaration (TREE_VALUE (chain), str);
- chain = TREE_CHAIN (chain);
- if (chain && TREE_VALUE (chain) != void_type_node)
- strcat (str, ", ");
- }
- strcat (str, ")");
- }
-
- else if (code == INDIRECT_REF)
- {
- strcpy (tmpbuf, "*");
- if (TREE_TYPE (decl) && TREE_CODE (TREE_TYPE (decl)) == TREE_LIST)
- {
- tree chain;
-
- for (chain = nreverse (copy_list (TREE_TYPE (decl)));
- chain;
- chain = TREE_CHAIN (chain))
- {
- if (TREE_CODE (TREE_VALUE (chain)) == IDENTIFIER_NODE)
- {
- strcat (tmpbuf, " ");
- strcat (tmpbuf, IDENTIFIER_POINTER (TREE_VALUE (chain)));
- }
- }
- if (str[0])
- strcat (tmpbuf, " ");
- }
- strcat (tmpbuf, str);
- strcpy (str, tmpbuf);
- }
-
- else if (code == POINTER_TYPE)
- {
- strcpy (tmpbuf, "*");
- if (TREE_READONLY (decl) || TYPE_VOLATILE (decl))
- {
- if (TREE_READONLY (decl))
- strcat (tmpbuf, " const");
- if (TYPE_VOLATILE (decl))
- strcat (tmpbuf, " volatile");
- if (str[0])
- strcat (tmpbuf, " ");
- }
- strcat (tmpbuf, str);
- strcpy (str, tmpbuf);
- }
-}
-
-static char *
-gen_declarator (decl, buf, name)
- tree decl;
- char *buf;
- char *name;
-{
- if (decl)
- {
- enum tree_code code = TREE_CODE (decl);
- char *str;
- tree op;
- int wrap = 0;
-
- switch (code)
- {
- case ARRAY_REF:
- case INDIRECT_REF:
- case CALL_EXPR:
- op = TREE_OPERAND (decl, 0);
-
- /* We have a pointer to a function or array...(*)(), (*)[] */
- if ((code == ARRAY_REF || code == CALL_EXPR)
- && op && TREE_CODE (op) == INDIRECT_REF)
- wrap = 1;
-
- str = gen_declarator (op, buf, name);
-
- if (wrap)
- {
- strcpy (tmpbuf, "(");
- strcat (tmpbuf, str);
- strcat (tmpbuf, ")");
- strcpy (str, tmpbuf);
- }
-
- adorn_decl (decl, str);
- break;
-
- case ARRAY_TYPE:
- case FUNCTION_TYPE:
- case POINTER_TYPE:
- strcpy (buf, name);
- str = buf;
-
- /* This clause is done iteratively rather than recursively. */
- do
- {
- op = (is_complex_decl (TREE_TYPE (decl))
- ? TREE_TYPE (decl) : NULL_TREE);
-
- adorn_decl (decl, str);
-
- /* We have a pointer to a function or array...(*)(), (*)[] */
- if (code == POINTER_TYPE
- && op && (TREE_CODE (op) == FUNCTION_TYPE
- || TREE_CODE (op) == ARRAY_TYPE))
- {
- strcpy (tmpbuf, "(");
- strcat (tmpbuf, str);
- strcat (tmpbuf, ")");
- strcpy (str, tmpbuf);
- }
-
- decl = (is_complex_decl (TREE_TYPE (decl))
- ? TREE_TYPE (decl) : NULL_TREE);
- }
-
- while (decl && (code = TREE_CODE (decl)))
- ;
-
- break;
-
- case IDENTIFIER_NODE:
- /* Will only happen if we are processing a "raw" expr-decl. */
- strcpy (buf, IDENTIFIER_POINTER (decl));
- return buf;
- }
-
- return str;
- }
-
- else
- /* We have an abstract declarator or a _DECL node. */
- {
- strcpy (buf, name);
- return buf;
- }
-}
-
-static void
-gen_declspecs (declspecs, buf, raw)
- tree declspecs;
- char *buf;
- int raw;
-{
- if (raw)
- {
- tree chain;
-
- for (chain = nreverse (copy_list (declspecs));
- chain; chain = TREE_CHAIN (chain))
- {
- tree aspec = TREE_VALUE (chain);
-
- if (TREE_CODE (aspec) == IDENTIFIER_NODE)
- strcat (buf, IDENTIFIER_POINTER (aspec));
- else if (TREE_CODE (aspec) == RECORD_TYPE)
- {
- if (TYPE_NAME (aspec))
- {
- tree protocol_list = TYPE_PROTOCOL_LIST (aspec);
-
- if (! TREE_STATIC_TEMPLATE (aspec))
- strcat (buf, "struct ");
- strcat (buf, IDENTIFIER_POINTER (TYPE_NAME (aspec)));
-
- /* NEW!!! */
- if (protocol_list)
- {
- tree chain = protocol_list;
-
- strcat (buf, " <");
- while (chain)
- {
- strcat (buf,
- IDENTIFIER_POINTER
- (PROTOCOL_NAME (TREE_VALUE (chain))));
- chain = TREE_CHAIN (chain);
- if (chain)
- strcat (buf, ", ");
- }
- strcat (buf, ">");
- }
- }
-
- else
- strcat (buf, "untagged struct");
- }
-
- else if (TREE_CODE (aspec) == UNION_TYPE)
- {
- if (TYPE_NAME (aspec))
- {
- if (! TREE_STATIC_TEMPLATE (aspec))
- strcat (buf, "union ");
- strcat (buf, IDENTIFIER_POINTER (TYPE_NAME (aspec)));
- }
- else
- strcat (buf, "untagged union");
- }
-
- else if (TREE_CODE (aspec) == ENUMERAL_TYPE)
- {
- if (TYPE_NAME (aspec))
- {
- if (! TREE_STATIC_TEMPLATE (aspec))
- strcat (buf, "enum ");
- strcat (buf, IDENTIFIER_POINTER (TYPE_NAME (aspec)));
- }
- else
- strcat (buf, "untagged enum");
- }
-
- else if (TREE_CODE (aspec) == TYPE_DECL && DECL_NAME (aspec))
- strcat (buf, IDENTIFIER_POINTER (DECL_NAME (aspec)));
-
- else if (IS_ID (aspec))
- {
- tree protocol_list = TYPE_PROTOCOL_LIST (aspec);
-
- strcat (buf, "id");
- if (protocol_list)
- {
- tree chain = protocol_list;
-
- strcat (buf, " <");
- while (chain)
- {
- strcat (buf,
- IDENTIFIER_POINTER
- (PROTOCOL_NAME (TREE_VALUE (chain))));
- chain = TREE_CHAIN (chain);
- if (chain)
- strcat (buf, ", ");
- }
- strcat (buf, ">");
- }
- }
- if (TREE_CHAIN (chain))
- strcat (buf, " ");
- }
- }
- else
- {
- /* Type qualifiers. */
- if (TREE_READONLY (declspecs))
- strcat (buf, "const ");
- if (TYPE_VOLATILE (declspecs))
- strcat (buf, "volatile ");
-
- switch (TREE_CODE (declspecs))
- {
- /* Type specifiers. */
-
- case INTEGER_TYPE:
- declspecs = TYPE_MAIN_VARIANT (declspecs);
-
- /* Signed integer types. */
-
- if (declspecs == short_integer_type_node)
- strcat (buf, "short int ");
- else if (declspecs == integer_type_node)
- strcat (buf, "int ");
- else if (declspecs == long_integer_type_node)
- strcat (buf, "long int ");
- else if (declspecs == long_long_integer_type_node)
- strcat (buf, "long long int ");
- else if (declspecs == signed_char_type_node
- || declspecs == char_type_node)
- strcat (buf, "char ");
-
- /* Unsigned integer types. */
-
- else if (declspecs == short_unsigned_type_node)
- strcat (buf, "unsigned short ");
- else if (declspecs == unsigned_type_node)
- strcat (buf, "unsigned int ");
- else if (declspecs == long_unsigned_type_node)
- strcat (buf, "unsigned long ");
- else if (declspecs == long_long_unsigned_type_node)
- strcat (buf, "unsigned long long ");
- else if (declspecs == unsigned_char_type_node)
- strcat (buf, "unsigned char ");
- break;
-
- case REAL_TYPE:
- declspecs = TYPE_MAIN_VARIANT (declspecs);
-
- if (declspecs == float_type_node)
- strcat (buf, "float ");
- else if (declspecs == double_type_node)
- strcat (buf, "double ");
- else if (declspecs == long_double_type_node)
- strcat (buf, "long double ");
- break;
-
- case RECORD_TYPE:
- if (TYPE_NAME (declspecs)
- && TREE_CODE (TYPE_NAME (declspecs)) == IDENTIFIER_NODE)
- {
- tree protocol_list = TYPE_PROTOCOL_LIST (declspecs);
-
- if (! TREE_STATIC_TEMPLATE (declspecs))
- strcat (buf, "struct ");
- strcat (buf, IDENTIFIER_POINTER (TYPE_NAME (declspecs)));
-
- if (protocol_list)
- {
- tree chain = protocol_list;
-
- strcat (buf, " <");
- while (chain)
- {
- strcat (buf,
- IDENTIFIER_POINTER
- (PROTOCOL_NAME (TREE_VALUE (chain))));
- chain = TREE_CHAIN (chain);
- if (chain)
- strcat (buf, ", ");
- }
- strcat (buf, ">");
- }
- }
-
- else
- strcat (buf, "untagged struct");
-
- strcat (buf, " ");
- break;
-
- case UNION_TYPE:
- if (TYPE_NAME (declspecs)
- && TREE_CODE (TYPE_NAME (declspecs)) == IDENTIFIER_NODE)
- {
- strcat (buf, "union ");
- strcat (buf, IDENTIFIER_POINTER (TYPE_NAME (declspecs)));
- strcat (buf, " ");
- }
-
- else
- strcat (buf, "untagged union ");
- break;
-
- case ENUMERAL_TYPE:
- if (TYPE_NAME (declspecs)
- && TREE_CODE (TYPE_NAME (declspecs)) == IDENTIFIER_NODE)
- {
- strcat (buf, "enum ");
- strcat (buf, IDENTIFIER_POINTER (TYPE_NAME (declspecs)));
- strcat (buf, " ");
- }
-
- else
- strcat (buf, "untagged enum ");
- break;
-
- case VOID_TYPE:
- strcat (buf, "void ");
- break;
-
- case POINTER_TYPE:
- {
- tree protocol_list = TYPE_PROTOCOL_LIST (declspecs);
-
- strcat (buf, "id");
- if (protocol_list)
- {
- tree chain = protocol_list;
-
- strcat (buf, " <");
- while (chain)
- {
- strcat (buf,
- IDENTIFIER_POINTER
- (PROTOCOL_NAME (TREE_VALUE (chain))));
- chain = TREE_CHAIN (chain);
- if (chain)
- strcat (buf, ", ");
- }
-
- strcat (buf, ">");
- }
- }
- }
- }
-}
-
-static char *
-gen_declaration (atype_or_adecl, buf)
- tree atype_or_adecl;
- char *buf;
-{
- char declbuf[256];
-
- if (TREE_CODE (atype_or_adecl) == TREE_LIST)
- {
- tree declspecs; /* "identifier_node", "record_type" */
- tree declarator; /* "array_ref", "indirect_ref", "call_expr"... */
-
- /* We have a "raw", abstract declarator (typename). */
- declarator = TREE_VALUE (atype_or_adecl);
- declspecs = TREE_PURPOSE (atype_or_adecl);
-
- gen_declspecs (declspecs, buf, 1);
- if (declarator)
- {
- strcat (buf, " ");
- strcat (buf, gen_declarator (declarator, declbuf, ""));
- }
- }
-
- else
- {
- tree atype;
- tree declspecs; /* "integer_type", "real_type", "record_type"... */
- tree declarator; /* "array_type", "function_type", "pointer_type". */
-
- if (TREE_CODE (atype_or_adecl) == FIELD_DECL
- || TREE_CODE (atype_or_adecl) == PARM_DECL
- || TREE_CODE (atype_or_adecl) == FUNCTION_DECL)
- atype = TREE_TYPE (atype_or_adecl);
- else
- /* Assume we have a *_type node. */
- atype = atype_or_adecl;
-
- if (is_complex_decl (atype))
- {
- tree chain;
-
- /* Get the declaration specifier; it is at the end of the list. */
- declarator = chain = atype;
- do
- chain = TREE_TYPE (chain); /* not TREE_CHAIN (chain); */
- while (is_complex_decl (chain));
- declspecs = chain;
- }
-
- else
- {
- declspecs = atype;
- declarator = NULL_TREE;
- }
-
- gen_declspecs (declspecs, buf, 0);
-
- if (TREE_CODE (atype_or_adecl) == FIELD_DECL
- || TREE_CODE (atype_or_adecl) == PARM_DECL
- || TREE_CODE (atype_or_adecl) == FUNCTION_DECL)
- {
- char *decl_name = (DECL_NAME (atype_or_adecl)
- ? IDENTIFIER_POINTER (DECL_NAME (atype_or_adecl))
- : "");
-
- if (declarator)
- {
- strcat (buf, " ");
- strcat (buf, gen_declarator (declarator, declbuf, decl_name));
- }
-
- else if (decl_name[0])
- {
- strcat (buf, " ");
- strcat (buf, decl_name);
- }
- }
- else if (declarator)
- {
- strcat (buf, " ");
- strcat (buf, gen_declarator (declarator, declbuf, ""));
- }
- }
-
- return buf;
-}
-
-#define RAW_TYPESPEC(meth) (TREE_VALUE (TREE_PURPOSE (TREE_TYPE (meth))))
-
-static char *
-gen_method_decl (method, buf)
- tree method;
- char *buf;
-{
- tree chain;
-
- if (RAW_TYPESPEC (method) != objc_object_reference)
- {
- strcpy (buf, "(");
- gen_declaration (TREE_TYPE (method), buf);
- strcat (buf, ")");
- }
-
- chain = METHOD_SEL_ARGS (method);
- if (chain)
- {
- /* We have a chain of keyword_decls. */
- do
- {
- if (KEYWORD_KEY_NAME (chain))
- strcat (buf, IDENTIFIER_POINTER (KEYWORD_KEY_NAME (chain)));
-
- strcat (buf, ":");
- if (RAW_TYPESPEC (chain) != objc_object_reference)
- {
- strcat (buf, "(");
- gen_declaration (TREE_TYPE (chain), buf);
- strcat (buf, ")");
- }
-
- strcat (buf, IDENTIFIER_POINTER (KEYWORD_ARG_NAME (chain)));
- if ((chain = TREE_CHAIN (chain)))
- strcat (buf, " ");
- }
- while (chain);
-
- if (METHOD_ADD_ARGS (method) == (tree)1)
- strcat (buf, ", ...");
- else if (METHOD_ADD_ARGS (method))
- {
- /* We have a tree list node as generate by get_parm_info. */
- chain = TREE_PURPOSE (METHOD_ADD_ARGS (method));
-
- /* Know we have a chain of parm_decls. */
- while (chain)
- {
- strcat (buf, ", ");
- gen_declaration (chain, buf);
- chain = TREE_CHAIN (chain);
- }
- }
- }
-
- else
- /* We have a unary selector. */
- strcat (buf, IDENTIFIER_POINTER (METHOD_SEL_NAME (method)));
-
- return buf;
-}
-
-/* Debug info. */
-
-static void
-dump_interface (fp, chain)
- FILE *fp;
- tree chain;
-{
- char *buf = (char *)xmalloc (256);
- char *my_name = IDENTIFIER_POINTER (CLASS_NAME (chain));
- tree ivar_decls = CLASS_RAW_IVARS (chain);
- tree nst_methods = CLASS_NST_METHODS (chain);
- tree cls_methods = CLASS_CLS_METHODS (chain);
-
- fprintf (fp, "\n@interface %s", my_name);
-
- if (CLASS_SUPER_NAME (chain))
- {
- char *super_name = IDENTIFIER_POINTER (CLASS_SUPER_NAME (chain));
- fprintf (fp, " : %s\n", super_name);
- }
- else
- fprintf (fp, "\n");
-
- if (ivar_decls)
- {
- fprintf (fp, "{\n");
- do
- {
- bzero (buf, 256);
- fprintf (fp, "\t%s;\n", gen_declaration (ivar_decls, buf));
- ivar_decls = TREE_CHAIN (ivar_decls);
- }
- while (ivar_decls);
- fprintf (fp, "}\n");
- }
-
- while (nst_methods)
- {
- bzero (buf, 256);
- fprintf (fp, "- %s;\n", gen_method_decl (nst_methods, buf));
- nst_methods = TREE_CHAIN (nst_methods);
- }
-
- while (cls_methods)
- {
- bzero (buf, 256);
- fprintf (fp, "+ %s;\n", gen_method_decl (cls_methods, buf));
- cls_methods = TREE_CHAIN (cls_methods);
- }
- fprintf (fp, "\n@end");
-}
-
-static void
-init_objc ()
-{
- /* Add the special tree codes of Objective C to the tables. */
-
-#define LAST_CODE LAST_AND_UNUSED_TREE_CODE
-
- gcc_obstack_init (&util_obstack);
- util_firstobj = (char *) obstack_finish (&util_obstack);
-
- tree_code_type
- = (char **) xrealloc (tree_code_type,
- sizeof (char *) * LAST_OBJC_TREE_CODE);
- tree_code_length
- = (int *) xrealloc (tree_code_length,
- sizeof (int) * LAST_OBJC_TREE_CODE);
- tree_code_name
- = (char **) xrealloc (tree_code_name,
- sizeof (char *) * LAST_OBJC_TREE_CODE);
- bcopy ((char *) objc_tree_code_type,
- (char *) (tree_code_type + (int) LAST_CODE),
- (((int) LAST_OBJC_TREE_CODE - (int) LAST_CODE)
- * sizeof (char *)));
- bcopy ((char *) objc_tree_code_length,
- (char *) (tree_code_length + (int) LAST_CODE),
- (((int) LAST_OBJC_TREE_CODE - (int) LAST_CODE)
- * sizeof (int)));
- bcopy ((char *) objc_tree_code_name,
- (char *) (tree_code_name + (int) LAST_CODE),
- (((int) LAST_OBJC_TREE_CODE - (int) LAST_CODE)
- * sizeof (char *)));
-
- errbuf = (char *)xmalloc (BUFSIZE);
- hash_init ();
- synth_module_prologue ();
-}
-
-static void
-finish_objc ()
-{
- struct imp_entry *impent;
- tree chain;
- /* The internally generated initializers appear to have missing braces.
- Don't warn about this. */
- int save_warn_missing_braces = warn_missing_braces;
- warn_missing_braces = 0;
-
- generate_forward_declaration_to_string_table ();
-
-#ifdef OBJC_PROLOGUE
- OBJC_PROLOGUE;
-#endif
-
- if (implementation_context || class_names_chain
- || meth_var_names_chain || meth_var_types_chain || sel_ref_chain)
- generate_objc_symtab_decl ();
-
- for (impent = imp_list; impent; impent = impent->next)
- {
- implementation_context = impent->imp_context;
- implementation_template = impent->imp_template;
-
- UOBJC_CLASS_decl = impent->class_decl;
- UOBJC_METACLASS_decl = impent->meta_decl;
-
- if (TREE_CODE (implementation_context) == CLASS_IMPLEMENTATION_TYPE)
- {
- /* all of the following reference the string pool... */
- generate_ivar_lists ();
- generate_dispatch_tables ();
- generate_shared_structures ();
- }
- else
- {
- generate_dispatch_tables ();
- generate_category (implementation_context);
- }
- }
-
- /* If we are using an array of selectors, we must always
- finish up the array decl even if no selectors were used. */
- if (! flag_next_runtime || sel_ref_chain)
- build_selector_translation_table ();
-
- if (protocol_chain)
- generate_protocols ();
-
- if (objc_static_instances)
- generate_static_references ();
-
- if (implementation_context || class_names_chain || objc_static_instances
- || meth_var_names_chain || meth_var_types_chain || sel_ref_chain)
- {
- /* Arrange for Objc data structures to be initialized at run time. */
- char *init_name = build_module_descriptor ();
- if (init_name)
- assemble_constructor (init_name);
- }
-
- /* Dump the class references. This forces the appropriate classes
- to be linked into the executable image, preserving unix archive
- semantics. This can be removed when we move to a more dynamically
- linked environment. */
-
- for (chain = cls_ref_chain; chain; chain = TREE_CHAIN (chain))
- {
- handle_class_ref (chain);
- if (TREE_PURPOSE (chain))
- generate_classref_translation_entry (chain);
- }
-
- for (impent = imp_list; impent; impent = impent->next)
- handle_impent (impent);
-
- /* Dump the string table last. */
-
- generate_strings ();
-
- if (flag_gen_declaration)
- {
- add_class (implementation_context);
- dump_interface (gen_declaration_file, implementation_context);
- }
-
- if (warn_selector)
- {
- int slot;
- hash hsh;
-
- /* Run through the selector hash tables and print a warning for any
- selector which has multiple methods. */
-
- for (slot = 0; slot < SIZEHASHTABLE; slot++)
- for (hsh = cls_method_hash_list[slot]; hsh; hsh = hsh->next)
- if (hsh->list)
- {
- tree meth = hsh->key;
- char type = (TREE_CODE (meth) == INSTANCE_METHOD_DECL
- ? '-' : '+');
- attr loop;
-
- warning ("potential selector conflict for method `%s'",
- IDENTIFIER_POINTER (METHOD_SEL_NAME (meth)));
- warn_with_method ("found", type, meth);
- for (loop = hsh->list; loop; loop = loop->next)
- warn_with_method ("found", type, loop->value);
- }
-
- for (slot = 0; slot < SIZEHASHTABLE; slot++)
- for (hsh = nst_method_hash_list[slot]; hsh; hsh = hsh->next)
- if (hsh->list)
- {
- tree meth = hsh->key;
- char type = (TREE_CODE (meth) == INSTANCE_METHOD_DECL
- ? '-' : '+');
- attr loop;
-
- warning ("potential selector conflict for method `%s'",
- IDENTIFIER_POINTER (METHOD_SEL_NAME (meth)));
- warn_with_method ("found", type, meth);
- for (loop = hsh->list; loop; loop = loop->next)
- warn_with_method ("found", type, loop->value);
- }
- }
-
- warn_missing_braces = save_warn_missing_braces;
-}
-
-/* Subroutines of finish_objc. */
-
-static void
-generate_classref_translation_entry (chain)
- tree chain;
-{
- tree expr, name, decl_specs, decl, sc_spec;
- tree type;
-
- type = TREE_TYPE (TREE_PURPOSE (chain));
-
- expr = add_objc_string (TREE_VALUE (chain), class_names);
- expr = build_c_cast (type, expr); /* cast! */
-
- name = DECL_NAME (TREE_PURPOSE (chain));
-
- sc_spec = build_tree_list (NULL_TREE, ridpointers[(int) RID_STATIC]);
-
- /* static struct objc_class * _OBJC_CLASS_REFERENCES_n = ...; */
- decl_specs = tree_cons (NULL_TREE, type, sc_spec);
-
- /* The decl that is returned from start_decl is the one that we
- forward declared in build_class_reference. */
- decl = start_decl (name, decl_specs, 1, NULL_TREE, NULL_TREE);
- finish_decl (decl, expr, NULL_TREE);
- return;
-}
-
-static void
-handle_class_ref (chain)
- tree chain;
-{
- char *name = IDENTIFIER_POINTER (TREE_VALUE (chain));
- if (! flag_next_runtime)
- {
- tree decl;
- char *string = (char *) alloca (strlen (name) + 30);
- tree exp;
-
- sprintf (string, "%sobjc_class_name_%s",
- (flag_next_runtime ? "." : "__"), name);
-
- /* Make a decl for this name, so we can use its address in a tree. */
- decl = build_decl (VAR_DECL, get_identifier (string), char_type_node);
- DECL_EXTERNAL (decl) = 1;
- TREE_PUBLIC (decl) = 1;
-
- pushdecl (decl);
- rest_of_decl_compilation (decl, 0, 0, 0);
-
- /* Make following constant read-only (why not)? */
- readonly_data_section ();
-
- exp = build1 (ADDR_EXPR, string_type_node, decl);
-
- /* Align the section properly. */
- assemble_constant_align (exp);
-
- /* Inform the assembler about this new external thing. */
- assemble_external (decl);
-
- /* Output a constant to reference this address. */
- output_constant (exp, int_size_in_bytes (string_type_node));
- }
- else
- {
- /* This overreliance on our assembler (i.e. lack of portability)
- should be dealt with at some point. The GNU strategy (above)
- won't work either, but it is a start. */
- char *string = (char *) alloca (strlen (name) + 30);
- sprintf (string, ".reference .objc_class_name_%s", name);
- assemble_asm (my_build_string (strlen (string) + 1, string));
- }
-}
-
-static void
-handle_impent (impent)
- struct imp_entry *impent;
-{
- implementation_context = impent->imp_context;
- implementation_template = impent->imp_template;
-
- if (TREE_CODE (impent->imp_context) == CLASS_IMPLEMENTATION_TYPE)
- {
- char *class_name = IDENTIFIER_POINTER (CLASS_NAME (impent->imp_context));
- char *string = (char *) alloca (strlen (class_name) + 30);
-
- if (flag_next_runtime)
- {
- /* Grossly unportable.
- People should know better than to assume
- such things about assembler syntax! */
- sprintf (string, ".objc_class_name_%s=0", class_name);
- assemble_asm (my_build_string (strlen (string) + 1, string));
-
- sprintf (string, ".globl .objc_class_name_%s", class_name);
- assemble_asm (my_build_string (strlen (string) + 1, string));
- }
-
- else
- {
- sprintf (string, "%sobjc_class_name_%s",
- (flag_next_runtime ? "." : "__"), class_name);
- assemble_global (string);
- assemble_label (string);
- }
- }
-
- else if (TREE_CODE (impent->imp_context) == CATEGORY_IMPLEMENTATION_TYPE)
- {
- char *class_name = IDENTIFIER_POINTER (CLASS_NAME (impent->imp_context));
- char *class_super_name
- = IDENTIFIER_POINTER (CLASS_SUPER_NAME (impent->imp_context));
- char *string = (char *) alloca (strlen (class_name)
- + strlen (class_super_name) + 30);
-
- /* Do the same for categories. Even though no references to these
- symbols are generated automatically by the compiler, it gives
- you a handle to pull them into an archive by hand. */
- if (flag_next_runtime)
- {
- /* Grossly unportable. */
- sprintf (string, ".objc_category_name_%s_%s=0",
- class_name, class_super_name);
- assemble_asm (my_build_string (strlen (string) + 1, string));
-
- sprintf (string, ".globl .objc_category_name_%s_%s",
- class_name, class_super_name);
- assemble_asm (my_build_string (strlen (string) + 1, string));
- }
-
- else
- {
- sprintf (string, "%sobjc_category_name_%s_%s",
- (flag_next_runtime ? "." : "__"),
- class_name, class_super_name);
- assemble_global (string);
- assemble_label (string);
- }
- }
-}
-
-#ifdef DEBUG
-
-static void
-objc_debug (fp)
- FILE *fp;
-{
- char *buf = (char *)xmalloc (256);
-
- { /* dump function prototypes */
- tree loop = UOBJC_MODULES_decl;
-
- fprintf (fp, "\n\nfunction prototypes:\n");
- while (loop)
- {
- if (TREE_CODE (loop) == FUNCTION_DECL && DECL_INITIAL (loop))
- {
- /* We have a function definition: generate prototype. */
- bzero (errbuf, BUFSIZE);
- gen_declaration (loop, errbuf);
- fprintf (fp, "%s;\n", errbuf);
- }
- loop = TREE_CHAIN (loop);
- }
- }
- {
- /* Dump global chains. */
- tree loop;
- int i, index = 0, offset = 0;
- hash hashlist;
-
- for (i = 0; i < SIZEHASHTABLE; i++)
- {
- if (hashlist = nst_method_hash_list[i])
- {
- fprintf (fp, "\n\nnst_method_hash_list[%d]:\n", i);
- do
- {
- bzero (buf, 256);
- fprintf (fp, "-%s;\n", gen_method_decl (hashlist->key, buf));
- hashlist = hashlist->next;
- }
- while (hashlist);
- }
- }
-
- for (i = 0; i < SIZEHASHTABLE; i++)
- {
- if (hashlist = cls_method_hash_list[i])
- {
- fprintf (fp, "\n\ncls_method_hash_list[%d]:\n", i);
- do
- {
- bzero (buf, 256);
- fprintf (fp, "-%s;\n", gen_method_decl (hashlist->key, buf));
- hashlist = hashlist->next;
- }
- while (hashlist);
- }
- }
-
- fprintf (fp, "\nsel_refdef_chain:\n");
- for (loop = sel_refdef_chain; loop; loop = TREE_CHAIN (loop))
- {
- fprintf (fp, "(index: %4d offset: %4d) %s\n", index, offset,
- IDENTIFIER_POINTER (TREE_VALUE (loop)));
- index++;
- /* add one for the '\0' character */
- offset += IDENTIFIER_LENGTH (TREE_VALUE (loop)) + 1;
- }
-
- fprintf (fp, "\n (max_selector_index: %4d.\n", max_selector_index);
- }
-}
-#endif
-
-void
-print_lang_statistics ()
-{
-}
diff --git a/contrib/gcc/objc-act.h b/contrib/gcc/objc-act.h
deleted file mode 100644
index 65224de84f4c..000000000000
--- a/contrib/gcc/objc-act.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/* Declarations for objc-act.c.
- Copyright (C) 1990 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-
-/*** Public Interface (procedures) ***/
-
-/* used by yyparse */
-
-void finish_file PROTO((void));
-tree start_class PROTO((enum tree_code, tree, tree, tree));
-tree continue_class PROTO((tree));
-void finish_class PROTO((tree));
-void start_method_def PROTO((tree));
-void continue_method_def PROTO((void));
-void finish_method_def PROTO((void));
-tree start_protocol PROTO((enum tree_code, tree, tree));
-void finish_protocol PROTO((tree));
-void add_objc_decls PROTO((void));
-
-tree is_ivar PROTO((tree, tree));
-int is_private PROTO((tree));
-int is_public PROTO((tree, tree));
-tree add_instance_variable PROTO((tree, int, tree, tree, tree));
-tree add_class_method PROTO((tree, tree));
-tree add_instance_method PROTO((tree, tree));
-tree get_super_receiver PROTO((void));
-tree get_class_ivars PROTO((tree));
-tree get_class_reference PROTO((tree));
-tree get_static_reference PROTO((tree, tree));
-tree get_object_reference PROTO((tree));
-tree build_message_expr PROTO((tree));
-tree build_selector_expr PROTO((tree));
-tree build_ivar_reference PROTO((tree));
-tree build_keyword_decl PROTO((tree, tree, tree));
-tree build_method_decl PROTO((enum tree_code, tree, tree, tree));
-tree build_protocol_expr PROTO((tree));
-tree build_objc_string_object PROTO((tree));
-
-extern tree objc_ivar_chain;
-extern tree objc_method_context;
-
-void objc_declare_alias PROTO((tree, tree));
-void objc_declare_class PROTO((tree));
-
-extern int objc_receiver_context;
-
-/* the following routines are used to implement statically typed objects */
-
-int objc_comptypes PROTO((tree, tree, int));
-void objc_check_decl PROTO((tree));
-
-/* NeXT extensions */
-
-tree build_encode_expr PROTO((tree));
-
-/* Objective-C structures */
-
-/* KEYWORD_DECL */
-#define KEYWORD_KEY_NAME(DECL) ((DECL)->decl.name)
-#define KEYWORD_ARG_NAME(DECL) ((DECL)->decl.arguments)
-
-/* INSTANCE_METHOD_DECL, CLASS_METHOD_DECL */
-#define METHOD_SEL_NAME(DECL) ((DECL)->decl.name)
-#define METHOD_SEL_ARGS(DECL) ((DECL)->decl.arguments)
-#define METHOD_ADD_ARGS(DECL) ((DECL)->decl.result)
-#define METHOD_DEFINITION(DECL) ((DECL)->decl.initial)
-#define METHOD_ENCODING(DECL) ((DECL)->decl.context)
-
-/* CLASS_INTERFACE_TYPE, CLASS_IMPLEMENTATION_TYPE,
- CATEGORY_INTERFACE_TYPE, CATEGORY_IMPLEMENTATION_TYPE,
- PROTOCOL_INTERFACE_TYPE */
-#define CLASS_NAME(CLASS) ((CLASS)->type.name)
-#define CLASS_SUPER_NAME(CLASS) ((CLASS)->type.context)
-#define CLASS_IVARS(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 0)
-#define CLASS_RAW_IVARS(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 1)
-#define CLASS_NST_METHODS(CLASS) ((CLASS)->type.minval)
-#define CLASS_CLS_METHODS(CLASS) ((CLASS)->type.maxval)
-#define CLASS_STATIC_TEMPLATE(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 2)
-#define CLASS_CATEGORY_LIST(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 3)
-#define CLASS_PROTOCOL_LIST(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 4)
-#define PROTOCOL_NAME(CLASS) ((CLASS)->type.name)
-#define PROTOCOL_LIST(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 0)
-#define PROTOCOL_NST_METHODS(CLASS) ((CLASS)->type.minval)
-#define PROTOCOL_CLS_METHODS(CLASS) ((CLASS)->type.maxval)
-#define PROTOCOL_FORWARD_DECL(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 1)
-#define TYPE_PROTOCOL_LIST(TYPE) ((TYPE)->type.context)
-
-/* Define the Objective-C or Objective-C++ language-specific tree codes. */
-
-#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) SYM,
-enum objc_tree_code {
-#ifdef OBJCPLUS
- dummy_tree_code = LAST_CPLUS_TREE_CODE,
-#else
- dummy_tree_code = LAST_AND_UNUSED_TREE_CODE,
-#endif
-#include "objc-tree.def"
- LAST_OBJC_TREE_CODE
-};
-#undef DEFTREECODE
diff --git a/contrib/gcc/objc-tree.def b/contrib/gcc/objc-tree.def
deleted file mode 100644
index 03f0c715776c..000000000000
--- a/contrib/gcc/objc-tree.def
+++ /dev/null
@@ -1,37 +0,0 @@
-/* This file contains the definitions and documentation for the
- additional tree codes used in the Objective C front end (see tree.def
- for the standard codes).
- Copyright (C) 1990 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-
-/* Objective-C types. */
-DEFTREECODE (CLASS_INTERFACE_TYPE, "class_interface_type", "t", 0)
-DEFTREECODE (CLASS_IMPLEMENTATION_TYPE, "class_implementation_type", "t", 0)
-DEFTREECODE (CATEGORY_INTERFACE_TYPE, "category_interface_type", "t", 0)
-DEFTREECODE (CATEGORY_IMPLEMENTATION_TYPE,"category_implementation_type","t",0)
-DEFTREECODE (PROTOCOL_INTERFACE_TYPE, "protocol_interface_type", "t", 0)
-
-/* Objective-C decls. */
-DEFTREECODE (KEYWORD_DECL, "keyword_decl", "d", 0)
-DEFTREECODE (INSTANCE_METHOD_DECL, "instance_method_decl", "d", 0)
-DEFTREECODE (CLASS_METHOD_DECL, "class_method_decl", "d", 0)
-
-/* Objective-C constants. */
-DEFTREECODE (OBJC_STRING_CST, "objc_string_cst", "c", 3)
diff --git a/contrib/gcc/objc/Makefile b/contrib/gcc/objc/Makefile
deleted file mode 100644
index 36981337585a..000000000000
--- a/contrib/gcc/objc/Makefile
+++ /dev/null
@@ -1,100 +0,0 @@
-# GNU Objective C Runtime Makefile
-# Copyright (C) 1993, 1995 Free Software Foundation, Inc.
-#
-# This file is part of GNU CC.
-#
-# GNU CC is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2, or (at your option) any later version.
-#
-# GNU CC is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
-# details.
-#
-# You should have received a copy of the GNU General Public License along with
-# GNU CC; see the file COPYING. If not, write to the Free Software
-# Foundation, 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-
-# This makefile is run by the parent dir's makefile.
-# thisdir1=`pwd`; \
-# srcdir1=`cd $(srcdir); pwd`; \
-# cd objc; \
-# $(MAKE) $(MAKEFLAGS) -f $$srcdir1/objc/Makefile libobjc.a \
-# srcdir=$$srcdir1 tooldir=$(tooldir) AR="$(AR)" AR_FLAGS="$(AR_FLAGS)" \
-# GCC_FOR_TARGET="$$thisdir1/xgcc -B$$thisdir1/" \
-# GCC_CFLAGS="$(GCC_CFLAGS)" incinstalldir=$$thisdir1/include
-# Two targets are used by ../Makefile: `all' and `mostlyclean'.
-
-SHELL=/bin/sh
-
-.SUFFIXES: .m
-
-OPTIMIZE= -O
-
-VPATH = $(srcdir)/objc
-
-AR = ar
-AR_FLAGS = rc
-
-# Always search these dirs when compiling.
-SUBDIR_INCLUDES = -I. -I.. -I$(srcdir) -I$(srcdir)/config
-
-.c.o:
- $(GCC_FOR_TARGET) $(OPTIMIZE) \
- -c $(GCC_CFLAGS) $(SUBDIR_INCLUDES) $<
-
-.m.o:
- $(GCC_FOR_TARGET) $(OPTIMIZE) -fgnu-runtime \
- -c $(GCC_CFLAGS) $(SUBDIR_INCLUDES) $<
-
-# If we were not invoked from the parent dir,
-# invoke make in the parent dir and have reinvoke this makefile.
-# That's necessary to get the right values for srcdir, etc.
-all:
- cd ..; $(MAKE) sublibobjc.a
-
-OBJC_O = hash.o sarray.o class.o sendmsg.o init.o archive.o encoding.o \
- selector.o objects.o misc.o NXConstStr.o Object.o Protocol.o
-
-libobjc.a: $(OBJC_O)
- -rm -f libobjc.a
- $(AR) rc libobjc.a $?
-# ranlib is run in the parent directory's makefile.
-
-OBJC_H = hash.h list.h sarray.h objc.h \
- objc-api.h \
- NXConstStr.h Object.h Protocol.h encoding.h typedstream.h
-
-# copy objc headers to installation include directory
-copy-headers:
- -rm -fr $(incinstalldir)/objc
- -mkdir $(incinstalldir)/objc
- for file in $(OBJC_H); do \
- realfile=$(srcdir)/objc/$${file}; \
- cp $${realfile} $(incinstalldir)/objc; \
- chmod a+r $(incinstalldir)/objc/$${file}; \
- done
-
-mostlyclean:
- -rm -f *.o libobjc.a xforward fflags
-clean: mostlyclean
-distclean: mostlyclean
-extraclean: mostlyclean
-
-# For Sun VPATH.
-
-hash.o: hash.c
-sarray.o: sarray.c
-class.o: class.c
-sendmsg.o: sendmsg.c
-init.o: init.c
-archive.o: archive.c
-encoding.o: encoding.c
-selector.o: selector.c
-objects.o: objects.c
-misc.o: misc.c
-NXConstStr.o: NXConstStr.m
-Object.o: Object.m
-Protocol.o: Protocol.m
diff --git a/contrib/gcc/objc/NXConstStr.h b/contrib/gcc/objc/NXConstStr.h
deleted file mode 100644
index c9799544a029..000000000000
--- a/contrib/gcc/objc/NXConstStr.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* Interface for the NXConstantString class for Objective-C.
- Copyright (C) 1995 Free Software Foundation, Inc.
- Contributed by Pieter J. Schoenmakers <tiggr@es.ele.tue.nl>
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option) any
-later version.
-
-GNU CC is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
-License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-/* As a special exception, if you link this library with files
- compiled with GCC to produce an executable, this does not cause
- the resulting executable to be covered by the GNU General Public License.
- This exception does not however invalidate any other reasons why
- the executable file might be covered by the GNU General Public License. */
-
-#ifndef __nxconstantstring_INCLUDE_GNU
-#define __nxconstantstring_INCLUDE_GNU
-
-#include "objc/Object.h"
-
-@interface NXConstantString: Object
-{
- char *c_string;
- unsigned int len;
-}
-
--(const char *) cString;
--(unsigned int) length;
-
-@end
-
-#endif
diff --git a/contrib/gcc/objc/NXConstStr.m b/contrib/gcc/objc/NXConstStr.m
deleted file mode 100644
index 4d2f3e1d7fc0..000000000000
--- a/contrib/gcc/objc/NXConstStr.m
+++ /dev/null
@@ -1,42 +0,0 @@
-/* Implementation of the NXConstantString class for Objective-C.
- Copyright (C) 1995 Free Software Foundation, Inc.
- Contributed by Pieter J. Schoenmakers <tiggr@es.ele.tue.nl>
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option) any
-later version.
-
-GNU CC is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
-License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-/* As a special exception, if you link this library with files
- compiled with GCC to produce an executable, this does not cause
- the resulting executable to be covered by the GNU General Public License.
- This exception does not however invalidate any other reasons why
- the executable file might be covered by the GNU General Public License. */
-
-#include "objc/NXConstStr.h"
-
-@implementation NXConstantString
-
--(const char *) cString
-{
- return (c_string);
-} /* -cString */
-
--(unsigned int) length
-{
- return (len);
-} /* -length */
-
-@end
diff --git a/contrib/gcc/objc/Object.h b/contrib/gcc/objc/Object.h
deleted file mode 100644
index a762acc3f7db..000000000000
--- a/contrib/gcc/objc/Object.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/* Interface for the Object class for Objective-C.
- Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option) any
-later version.
-
-GNU CC is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
-License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-/* As a special exception, if you link this library with files compiled
- with GCC to produce an executable, this does not cause the resulting
- executable to be covered by the GNU General Public License. This
- exception does not however invalidate any other reasons why the
- executable file might be covered by the GNU General Public License. */
-
-#ifndef __object_INCLUDE_GNU
-#define __object_INCLUDE_GNU
-
-#include <objc/objc.h>
-#include <objc/typedstream.h>
-
-/*
- * All classes are derived from Object. As such,
- * this is the overhead tacked onto those objects.
- */
-@interface Object
-{
- Class isa; /* A pointer to the instance's class structure */
-}
-
- /* Initializing classes and instances */
-+ initialize;
-- init;
-
- /* Creating, freeing, and copying instances */
-+ new;
-+ alloc;
-- free;
-- copy;
-- shallowCopy;
-- deepen;
-- deepCopy;
-
- /* Identifying classes */
-- (Class)class;
-- (Class)superClass;
-- (MetaClass)metaClass;
-- (const char *)name;
-
- /* Identifying and comparing objects */
-- self;
-- (unsigned int)hash;
-- (BOOL)isEqual:anObject;
-- (int)compare:anotherObject;
-
- /* Testing object type */
-- (BOOL)isMetaClass;
-- (BOOL)isClass;
-- (BOOL)isInstance;
-
- /* Testing inheritance relationships */
-- (BOOL)isKindOf:(Class)aClassObject;
-- (BOOL)isMemberOf:(Class)aClassObject;
-- (BOOL)isKindOfClassNamed:(const char *)aClassName;
-- (BOOL)isMemberOfClassNamed:(const char *)aClassName;
-
- /* Testing class functionality */
-+ (BOOL)instancesRespondTo:(SEL)aSel;
-- (BOOL)respondsTo:(SEL)aSel;
-
- /* Testing protocol conformance */
-- (BOOL)conformsTo:(Protocol*)aProtocol;
-
- /* Introspection */
-+ (IMP)instanceMethodFor:(SEL)aSel;
-- (IMP)methodFor:(SEL)aSel;
-+ (struct objc_method_description *)descriptionForInstanceMethod:(SEL)aSel;
-- (struct objc_method_description *)descriptionForMethod:(SEL)aSel;
-
- /* Sending messages determined at run time */
-- perform:(SEL)aSel;
-- perform:(SEL)aSel with:anObject;
-- perform:(SEL)aSel with:anObject1 with:anObject2;
-
- /* Forwarding */
-- (retval_t)forward:(SEL)aSel :(arglist_t)argFrame;
-- (retval_t)performv:(SEL)aSel :(arglist_t)argFrame;
-
- /* Posing */
-+ poseAs:(Class)aClassObject;
-- (Class)transmuteClassTo:(Class)aClassObject;
-
- /* Enforcing intentions */
-- subclassResponsibility:(SEL)aSel;
-- notImplemented:(SEL)aSel;
-- shouldNotImplement:(SEL)aSel;
-
- /* Error handling */
-- doesNotRecognize:(SEL)aSel;
-- error:(const char *)aString, ...;
-
- /* Archiving */
-+ (int)version;
-+ setVersion:(int)aVersion;
-+ (int)streamVersion: (TypedStream*)aStream;
-
-- read: (TypedStream*)aStream;
-- write: (TypedStream*)aStream;
-- awake;
-
-@end
-
-#endif
diff --git a/contrib/gcc/objc/Object.m b/contrib/gcc/objc/Object.m
deleted file mode 100644
index 64b52f483687..000000000000
--- a/contrib/gcc/objc/Object.m
+++ /dev/null
@@ -1,387 +0,0 @@
-/* The implementation of class Object for Objective-C.
- Copyright (C) 1993, 1994, 1995, 1997 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option) any
-later version.
-
-GNU CC is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
-License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-/* As a special exception, if you link this library with files compiled
- with GCC to produce an executable, this does not cause the resulting
- executable to be covered by the GNU General Public License. This
- exception does not however invalidate any other reasons why the
- executable file might be covered by the GNU General Public License. */
-
-#include <stdarg.h>
-#include "objc/Object.h"
-#include "objc/Protocol.h"
-#include "objc/objc-api.h"
-
-extern int errno;
-
-#define MAX_CLASS_NAME_LEN 256
-
-@implementation Object
-
-+ initialize
-{
- return self;
-}
-
-- init
-{
- return self;
-}
-
-+ new
-{
- return [[self alloc] init];
-}
-
-+ alloc
-{
- return class_create_instance(self);
-}
-
-- free
-{
- return object_dispose(self);
-}
-
-- copy
-{
- return [[self shallowCopy] deepen];
-}
-
-- shallowCopy
-{
- return object_copy(self);
-}
-
-- deepen
-{
- return self;
-}
-
-- deepCopy
-{
- return [self copy];
-}
-
-- (Class)class
-{
- return object_get_class(self);
-}
-
-- (Class)superClass
-{
- return object_get_super_class(self);
-}
-
-- (MetaClass)metaClass
-{
- return object_get_meta_class(self);
-}
-
-- (const char *)name
-{
- return object_get_class_name(self);
-}
-
-- self
-{
- return self;
-}
-
-- (unsigned int)hash
-{
- return (size_t)self;
-}
-
-- (BOOL)isEqual:anObject
-{
- return self==anObject;
-}
-
-- (int)compare:anotherObject;
-{
- if ([self isEqual:anotherObject])
- return 0;
- // Ordering objects by their address is pretty useless,
- // so subclasses should override this is some useful way.
- else if (self > anotherObject)
- return 1;
- else
- return -1;
-}
-
-- (BOOL)isMetaClass
-{
- return NO;
-}
-
-- (BOOL)isClass
-{
- return object_is_class(self);
-}
-
-- (BOOL)isInstance
-{
- return object_is_instance(self);
-}
-
-- (BOOL)isKindOf:(Class)aClassObject
-{
- Class class;
-
- for (class = self->isa; class!=Nil; class = class_get_super_class(class))
- if (class==aClassObject)
- return YES;
- return NO;
-}
-
-- (BOOL)isMemberOf:(Class)aClassObject
-{
- return self->isa==aClassObject;
-}
-
-- (BOOL)isKindOfClassNamed:(const char *)aClassName
-{
- Class class;
-
- if (aClassName!=NULL)
- for (class = self->isa; class!=Nil; class = class_get_super_class(class))
- if (!strcmp(class_get_class_name(class), aClassName))
- return YES;
- return NO;
-}
-
-- (BOOL)isMemberOfClassNamed:(const char *)aClassName
-{
- return ((aClassName!=NULL)
- &&!strcmp(class_get_class_name(self->isa), aClassName));
-}
-
-+ (BOOL)instancesRespondTo:(SEL)aSel
-{
- return class_get_instance_method(self, aSel)!=METHOD_NULL;
-}
-
-- (BOOL)respondsTo:(SEL)aSel
-{
- return ((object_is_instance(self)
- ?class_get_instance_method(self->isa, aSel)
- :class_get_class_method(self->isa, aSel))!=METHOD_NULL);
-}
-
-+ (IMP)instanceMethodFor:(SEL)aSel
-{
- return method_get_imp(class_get_instance_method(self, aSel));
-}
-
-// Indicates if the receiving class or instance conforms to the given protocol
-// not usually overridden by subclasses
-//
-// Modified 9/5/94 to always search the class object's protocol list, rather
-// than the meta class.
-
-+ (BOOL) conformsTo: (Protocol*)aProtocol
-{
- int i;
- struct objc_protocol_list* proto_list;
- id parent;
-
- for (proto_list = ((Class)self)->protocols;
- proto_list; proto_list = proto_list->next)
- {
- for (i=0; i < proto_list->count; i++)
- {
- if ([proto_list->list[i] conformsTo: aProtocol])
- return YES;
- }
- }
-
- if ((parent = [self superClass]))
- return [parent conformsTo: aProtocol];
- else
- return NO;
-}
-
-- (BOOL) conformsTo: (Protocol*)aProtocol
-{
- return [[self class] conformsTo:aProtocol];
-}
-
-- (IMP)methodFor:(SEL)aSel
-{
- return (method_get_imp(object_is_instance(self)
- ?class_get_instance_method(self->isa, aSel)
- :class_get_class_method(self->isa, aSel)));
-}
-
-+ (struct objc_method_description *)descriptionForInstanceMethod:(SEL)aSel
-{
- return ((struct objc_method_description *)
- class_get_instance_method(self, aSel));
-}
-
-- (struct objc_method_description *)descriptionForMethod:(SEL)aSel
-{
- return ((struct objc_method_description *)
- (object_is_instance(self)
- ?class_get_instance_method(self->isa, aSel)
- :class_get_class_method(self->isa, aSel)));
-}
-
-- perform:(SEL)aSel
-{
- IMP msg = objc_msg_lookup(self, aSel);
- if (!msg)
- return [self error:"invalid selector passed to %s", sel_get_name(_cmd)];
- return (*msg)(self, aSel);
-}
-
-- perform:(SEL)aSel with:anObject
-{
- IMP msg = objc_msg_lookup(self, aSel);
- if (!msg)
- return [self error:"invalid selector passed to %s", sel_get_name(_cmd)];
- return (*msg)(self, aSel, anObject);
-}
-
-- perform:(SEL)aSel with:anObject1 with:anObject2
-{
- IMP msg = objc_msg_lookup(self, aSel);
- if (!msg)
- return [self error:"invalid selector passed to %s", sel_get_name(_cmd)];
- return (*msg)(self, aSel, anObject1, anObject2);
-}
-
-- (retval_t)forward:(SEL)aSel :(arglist_t)argFrame
-{
- return (retval_t)[self doesNotRecognize: aSel];
-}
-
-- (retval_t)performv:(SEL)aSel :(arglist_t)argFrame
-{
- return objc_msg_sendv(self, aSel, argFrame);
-}
-
-+ poseAs:(Class)aClassObject
-{
- return class_pose_as(self, aClassObject);
-}
-
-- (Class)transmuteClassTo:(Class)aClassObject
-{
- if (object_is_instance(self))
- if (class_is_class(aClassObject))
- if (class_get_instance_size(aClassObject)==class_get_instance_size(isa))
- if ([self isKindOf:aClassObject])
- {
- Class old_isa = isa;
- isa = aClassObject;
- return old_isa;
- }
- return nil;
-}
-
-- subclassResponsibility:(SEL)aSel
-{
- return [self error:"subclass should override %s", sel_get_name(aSel)];
-}
-
-- notImplemented:(SEL)aSel
-{
- return [self error:"method %s not implemented", sel_get_name(aSel)];
-}
-
-- shouldNotImplement:(SEL)aSel
-{
- return [self error:"%s should not implement %s",
- object_get_class_name(self), sel_get_name(aSel)];
-}
-
-- doesNotRecognize:(SEL)aSel
-{
- return [self error:"%s does not recognize %s",
- object_get_class_name(self), sel_get_name(aSel)];
-}
-
-#ifdef __alpha__
-extern size_t strlen(const char*);
-#endif
-
-- error:(const char *)aString, ...
-{
-#define FMT "error: %s (%s)\n%s\n"
- char fmt[(strlen((char*)FMT)+strlen((char*)object_get_class_name(self))
- +((aString!=NULL)?strlen((char*)aString):0)+8)];
- va_list ap;
-
- sprintf(fmt, FMT, object_get_class_name(self),
- object_is_instance(self)?"instance":"class",
- (aString!=NULL)?aString:"");
- va_start(ap, aString);
- objc_verror(self, OBJC_ERR_UNKNOWN, fmt, ap);
- va_end(ap);
- return nil;
-#undef FMT
-}
-
-+ (int)version
-{
- return class_get_version(self);
-}
-
-+ setVersion:(int)aVersion
-{
- class_set_version(self, aVersion);
- return self;
-}
-
-+ (int)streamVersion: (TypedStream*)aStream
-{
- if (aStream->mode == OBJC_READONLY)
- return objc_get_stream_class_version (aStream, self);
- else
- return class_get_version (self);
-}
-
-// These are used to write or read the instance variables
-// declared in this particular part of the object. Subclasses
-// should extend these, by calling [super read/write: aStream]
-// before doing their own archiving. These methods are private, in
-// the sense that they should only be called from subclasses.
-
-- read: (TypedStream*)aStream
-{
- // [super read: aStream];
- return self;
-}
-
-- write: (TypedStream*)aStream
-{
- // [super write: aStream];
- return self;
-}
-
-- awake
-{
- // [super awake];
- return self;
-}
-
-@end
diff --git a/contrib/gcc/objc/Protocol.h b/contrib/gcc/objc/Protocol.h
deleted file mode 100644
index c7464cf17a9a..000000000000
--- a/contrib/gcc/objc/Protocol.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* Declare the class Protocol for Objective C programs.
- Copyright (C) 1993 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-/* As a special exception, if you link this library with files
- compiled with GCC to produce an executable, this does not cause
- the resulting executable to be covered by the GNU General Public License.
- This exception does not however invalidate any other reasons why
- the executable file might be covered by the GNU General Public License. */
-
-#ifndef __Protocol_INCLUDE_GNU
-#define __Protocol_INCLUDE_GNU
-
-#include "objc/Object.h"
-
-@interface Protocol : Object
-{
-@private
- char *protocol_name;
- struct objc_protocol_list *protocol_list;
- struct objc_method_description_list *instance_methods, *class_methods;
-}
-
-/* Obtaining attributes intrinsic to the protocol */
-
-- (const char *)name;
-
-/* Testing protocol conformance */
-
-- (BOOL) conformsTo: (Protocol *)aProtocolObject;
-
-/* Looking up information specific to a protocol */
-
-- (struct objc_method_description *) descriptionForInstanceMethod:(SEL)aSel;
-- (struct objc_method_description *) descriptionForClassMethod:(SEL)aSel;
-
-@end
-
-
-
-
-#endif __Protocol_INCLUDE_GNU
diff --git a/contrib/gcc/objc/Protocol.m b/contrib/gcc/objc/Protocol.m
deleted file mode 100644
index 43ba44eaf4f7..000000000000
--- a/contrib/gcc/objc/Protocol.m
+++ /dev/null
@@ -1,128 +0,0 @@
-/* This file contains the implementation of class Protocol.
- Copyright (C) 1993 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-/* As a special exception, if you link this library with files
- compiled with GCC to produce an executable, this does not cause
- the resulting executable to be covered by the GNU General Public License.
- This exception does not however invalidate any other reasons why
- the executable file might be covered by the GNU General Public License. */
-
-#include "objc/Protocol.h"
-#include "objc/objc-api.h"
-
-/* Method description list */
-struct objc_method_description_list {
- int count;
- struct objc_method_description list[1];
-};
-
-
-@implementation Protocol
-{
-@private
- char *protocol_name;
- struct objc_protocol_list *protocol_list;
- struct objc_method_description_list *instance_methods, *class_methods;
-}
-
-/* Obtaining attributes intrinsic to the protocol */
-
-- (const char *)name
-{
- return protocol_name;
-}
-
-/* Testing protocol conformance */
-
-- (BOOL) conformsTo: (Protocol *)aProtocolObject
-{
- int i;
- struct objc_protocol_list* proto_list;
-
- if (!strcmp(aProtocolObject->protocol_name, self->protocol_name))
- return YES;
-
- for (proto_list = protocol_list; proto_list; proto_list = proto_list->next)
- {
- for (i=0; i < proto_list->count; i++)
- {
- if ([proto_list->list[i] conformsTo: aProtocolObject])
- return YES;
- }
- }
-
- return NO;
-}
-
-/* Looking up information specific to a protocol */
-
-- (struct objc_method_description *) descriptionForInstanceMethod:(SEL)aSel
-{
- int i;
- struct objc_protocol_list* proto_list;
- const char* name = sel_get_name (aSel);
- struct objc_method_description *result;
-
- for (i = 0; i < instance_methods->count; i++)
- {
- if (!strcmp ((char*)instance_methods->list[i].name, name))
- return &(instance_methods->list[i]);
- }
-
- for (proto_list = protocol_list; proto_list; proto_list = proto_list->next)
- {
- for (i=0; i < proto_list->count; i++)
- {
- if ((result = [proto_list->list[i]
- descriptionForInstanceMethod: aSel]))
- return result;
- }
- }
-
- return NULL;
-}
-
-- (struct objc_method_description *) descriptionForClassMethod:(SEL)aSel;
-{
- int i;
- struct objc_protocol_list* proto_list;
- const char* name = sel_get_name (aSel);
- struct objc_method_description *result;
-
- for (i = 0; i < class_methods->count; i++)
- {
- if (!strcmp ((char*)class_methods->list[i].name, name))
- return &(class_methods->list[i]);
- }
-
- for (proto_list = protocol_list; proto_list; proto_list = proto_list->next)
- {
- for (i=0; i < proto_list->count; i++)
- {
- if ((result = [proto_list->list[i]
- descriptionForClassMethod: aSel]))
- return result;
- }
- }
-
- return NULL;
-}
-
-@end
diff --git a/contrib/gcc/objc/archive.c b/contrib/gcc/objc/archive.c
deleted file mode 100644
index c762fe6186e5..000000000000
--- a/contrib/gcc/objc/archive.c
+++ /dev/null
@@ -1,1651 +0,0 @@
-/* GNU Objective C Runtime archiving
- Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
- Contributed by Kresten Krab Thorup
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the Free Software
-Foundation; either version 2, or (at your option) any later version.
-
-GNU CC is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
-details.
-
-You should have received a copy of the GNU General Public License along with
-GNU CC; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-/* As a special exception, if you link this library with files compiled with
- GCC to produce an executable, this does not cause the resulting executable
- to be covered by the GNU General Public License. This exception does not
- however invalidate any other reasons why the executable file might be
- covered by the GNU General Public License. */
-
-#include "config.h"
-#include "runtime.h"
-#include "typedstream.h"
-#include "encoding.h"
-
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-
-extern int fflush(FILE*);
-
-#define ROUND(V, A) \
- ({ typeof(V) __v=(V); typeof(A) __a=(A); \
- __a*((__v+__a-1)/__a); })
-
-#define PTR2LONG(P) (((char*)(P))-(char*)0)
-#define LONG2PTR(L) (((char*)0)+(L))
-
-/* Declare some functions... */
-
-static int
-objc_read_class (struct objc_typed_stream* stream, Class* class);
-
-int objc_sizeof_type(const char* type);
-
-static int
-objc_write_use_common (struct objc_typed_stream* stream, unsigned long key);
-
-static int
-objc_write_register_common (struct objc_typed_stream* stream,
- unsigned long key);
-
-static int
-objc_write_class (struct objc_typed_stream* stream,
- struct objc_class* class);
-
-const char* objc_skip_type (const char* type);
-
-static void __objc_finish_write_root_object(struct objc_typed_stream*);
-static void __objc_finish_read_root_object(struct objc_typed_stream*);
-
-static __inline__ int
-__objc_code_unsigned_char (unsigned char* buf, unsigned char val)
-{
- if ((val&_B_VALUE) == val)
- {
- buf[0] = val|_B_SINT;
- return 1;
- }
- else
- {
- buf[0] = _B_NINT|0x01;
- buf[1] = val;
- return 2;
- }
-}
-
-int
-objc_write_unsigned_char (struct objc_typed_stream* stream,
- unsigned char value)
-{
- unsigned char buf[sizeof (unsigned char)+1];
- int len = __objc_code_unsigned_char (buf, value);
- return (*stream->write)(stream->physical, buf, len);
-}
-
-static __inline__ int
-__objc_code_char (unsigned char* buf, char val)
-{
- if (val >= 0)
- return __objc_code_unsigned_char (buf, val);
- else
- {
- buf[0] = _B_NINT|_B_SIGN|0x01;
- buf[1] = -val;
- return 2;
- }
-}
-
-int
-objc_write_char (struct objc_typed_stream* stream, char value)
-{
- unsigned char buf[sizeof (char)+1];
- int len = __objc_code_char (buf, value);
- return (*stream->write)(stream->physical, buf, len);
-}
-
-static __inline__ int
-__objc_code_unsigned_short (unsigned char* buf, unsigned short val)
-{
- if ((val&_B_VALUE) == val)
- {
- buf[0] = val|_B_SINT;
- return 1;
- }
- else
- {
- int c, b;
-
- buf[0] = _B_NINT;
-
- for (c= sizeof(short); c != 0; c -= 1)
- if (((val>>(8*(c-1)))%0x100) != 0)
- break;
-
- buf[0] |= c;
-
- for (b = 1; c != 0; c--, b++)
- {
- buf[b] = (val >> (8*(c-1)))%0x100;
- }
-
- return b;
- }
-}
-
-int
-objc_write_unsigned_short (struct objc_typed_stream* stream,
- unsigned short value)
-{
- unsigned char buf[sizeof (unsigned short)+1];
- int len = __objc_code_unsigned_short (buf, value);
- return (*stream->write)(stream->physical, buf, len);
-}
-
-static __inline__ int
-__objc_code_short (unsigned char* buf, short val)
-{
- int sign = (val < 0);
- int size = __objc_code_unsigned_short (buf, sign ? -val : val);
- if (sign)
- buf[0] |= _B_SIGN;
- return size;
-}
-
-int
-objc_write_short (struct objc_typed_stream* stream, short value)
-{
- unsigned char buf[sizeof (short)+1];
- int len = __objc_code_short (buf, value);
- return (*stream->write)(stream->physical, buf, len);
-}
-
-
-static __inline__ int
-__objc_code_unsigned_int (unsigned char* buf, unsigned int val)
-{
- if ((val&_B_VALUE) == val)
- {
- buf[0] = val|_B_SINT;
- return 1;
- }
- else
- {
- int c, b;
-
- buf[0] = _B_NINT;
-
- for (c= sizeof(int); c != 0; c -= 1)
- if (((val>>(8*(c-1)))%0x100) != 0)
- break;
-
- buf[0] |= c;
-
- for (b = 1; c != 0; c--, b++)
- {
- buf[b] = (val >> (8*(c-1)))%0x100;
- }
-
- return b;
- }
-}
-
-int
-objc_write_unsigned_int (struct objc_typed_stream* stream, unsigned int value)
-{
- unsigned char buf[sizeof(unsigned int)+1];
- int len = __objc_code_unsigned_int (buf, value);
- return (*stream->write)(stream->physical, buf, len);
-}
-
-static __inline__ int
-__objc_code_int (unsigned char* buf, int val)
-{
- int sign = (val < 0);
- int size = __objc_code_unsigned_int (buf, sign ? -val : val);
- if (sign)
- buf[0] |= _B_SIGN;
- return size;
-}
-
-int
-objc_write_int (struct objc_typed_stream* stream, int value)
-{
- unsigned char buf[sizeof(int)+1];
- int len = __objc_code_int (buf, value);
- return (*stream->write)(stream->physical, buf, len);
-}
-
-static __inline__ int
-__objc_code_unsigned_long (unsigned char* buf, unsigned long val)
-{
- if ((val&_B_VALUE) == val)
- {
- buf[0] = val|_B_SINT;
- return 1;
- }
- else
- {
- int c, b;
-
- buf[0] = _B_NINT;
-
- for (c= sizeof(long); c != 0; c -= 1)
- if (((val>>(8*(c-1)))%0x100) != 0)
- break;
-
- buf[0] |= c;
-
- for (b = 1; c != 0; c--, b++)
- {
- buf[b] = (val >> (8*(c-1)))%0x100;
- }
-
- return b;
- }
-}
-
-int
-objc_write_unsigned_long (struct objc_typed_stream* stream,
- unsigned long value)
-{
- unsigned char buf[sizeof(unsigned long)+1];
- int len = __objc_code_unsigned_long (buf, value);
- return (*stream->write)(stream->physical, buf, len);
-}
-
-static __inline__ int
-__objc_code_long (unsigned char* buf, long val)
-{
- int sign = (val < 0);
- int size = __objc_code_unsigned_long (buf, sign ? -val : val);
- if (sign)
- buf[0] |= _B_SIGN;
- return size;
-}
-
-int
-objc_write_long (struct objc_typed_stream* stream, long value)
-{
- unsigned char buf[sizeof(long)+1];
- int len = __objc_code_long (buf, value);
- return (*stream->write)(stream->physical, buf, len);
-}
-
-
-int
-objc_write_string (struct objc_typed_stream* stream,
- const unsigned char* string, unsigned int nbytes)
-{
- unsigned char buf[sizeof(unsigned int)+1];
- int len = __objc_code_unsigned_int (buf, nbytes);
-
- if ((buf[0]&_B_CODE) == _B_SINT)
- buf[0] = (buf[0]&_B_VALUE)|_B_SSTR;
-
- else /* _B_NINT */
- buf[0] = (buf[0]&_B_VALUE)|_B_NSTR;
-
- if ((*stream->write)(stream->physical, buf, len) != 0)
- return (*stream->write)(stream->physical, string, nbytes);
- else
- return 0;
-}
-
-int
-objc_write_string_atomic (struct objc_typed_stream* stream,
- unsigned char* string, unsigned int nbytes)
-{
- unsigned long key;
- if ((key = PTR2LONG(hash_value_for_key (stream->stream_table, string))))
- return objc_write_use_common (stream, key);
- else
- {
- int length;
- hash_add (&stream->stream_table, LONG2PTR(key=PTR2LONG(string)), string);
- if ((length = objc_write_register_common (stream, key)))
- return objc_write_string (stream, string, nbytes);
- return length;
- }
-}
-
-static int
-objc_write_register_common (struct objc_typed_stream* stream,
- unsigned long key)
-{
- unsigned char buf[sizeof (unsigned long)+2];
- int len = __objc_code_unsigned_long (buf+1, key);
- if (len == 1)
- {
- buf[0] = _B_RCOMM|0x01;
- buf[1] &= _B_VALUE;
- return (*stream->write)(stream->physical, buf, len+1);
- }
- else
- {
- buf[1] = (buf[1]&_B_VALUE)|_B_RCOMM;
- return (*stream->write)(stream->physical, buf+1, len);
- }
-}
-
-static int
-objc_write_use_common (struct objc_typed_stream* stream, unsigned long key)
-{
- unsigned char buf[sizeof (unsigned long)+2];
- int len = __objc_code_unsigned_long (buf+1, key);
- if (len == 1)
- {
- buf[0] = _B_UCOMM|0x01;
- buf[1] &= _B_VALUE;
- return (*stream->write)(stream->physical, buf, 2);
- }
- else
- {
- buf[1] = (buf[1]&_B_VALUE)|_B_UCOMM;
- return (*stream->write)(stream->physical, buf+1, len);
- }
-}
-
-static __inline__ int
-__objc_write_extension (struct objc_typed_stream* stream, unsigned char code)
-{
- if (code <= _B_VALUE)
- {
- unsigned char buf = code|_B_EXT;
- return (*stream->write)(stream->physical, &buf, 1);
- }
- else
- {
- objc_error(nil, OBJC_ERR_BAD_OPCODE,
- "__objc_write_extension: bad opcode %c\n", code);
- return -1;
- }
-}
-
-__inline__ int
-__objc_write_object (struct objc_typed_stream* stream, id object)
-{
- unsigned char buf = '\0';
- SEL write_sel = sel_get_any_uid ("write:");
- if (object)
- {
- __objc_write_extension (stream, _BX_OBJECT);
- objc_write_class (stream, object->class_pointer);
- (*objc_msg_lookup(object, write_sel))(object, write_sel, stream);
- return (*stream->write)(stream->physical, &buf, 1);
- }
- else
- return objc_write_use_common(stream, 0);
-}
-
-int
-objc_write_object_reference (struct objc_typed_stream* stream, id object)
-{
- unsigned long key;
- if ((key = PTR2LONG(hash_value_for_key (stream->object_table, object))))
- return objc_write_use_common (stream, key);
-
- __objc_write_extension (stream, _BX_OBJREF);
- return objc_write_unsigned_long (stream, PTR2LONG (object));
-}
-
-int
-objc_write_root_object (struct objc_typed_stream* stream, id object)
-{
- int len = 0;
- if (stream->writing_root_p)
- objc_error (nil, OBJC_ERR_RECURSE_ROOT,
- "objc_write_root_object called recursively");
- else
- {
- stream->writing_root_p = 1;
- __objc_write_extension (stream, _BX_OBJROOT);
- if((len = objc_write_object (stream, object)))
- __objc_finish_write_root_object(stream);
- stream->writing_root_p = 0;
- }
- return len;
-}
-
-int
-objc_write_object (struct objc_typed_stream* stream, id object)
-{
- unsigned long key;
- if ((key = PTR2LONG(hash_value_for_key (stream->object_table, object))))
- return objc_write_use_common (stream, key);
-
- else if (object == nil)
- return objc_write_use_common(stream, 0);
-
- else
- {
- int length;
- hash_add (&stream->object_table, LONG2PTR(key=PTR2LONG(object)), object);
- if ((length = objc_write_register_common (stream, key)))
- return __objc_write_object (stream, object);
- return length;
- }
-}
-
-__inline__ int
-__objc_write_class (struct objc_typed_stream* stream, struct objc_class* class)
-{
- __objc_write_extension (stream, _BX_CLASS);
- objc_write_string_atomic(stream, (char*)class->name,
- strlen((char*)class->name));
- return objc_write_unsigned_long (stream, class->version);
-}
-
-
-static int
-objc_write_class (struct objc_typed_stream* stream,
- struct objc_class* class)
-{
- unsigned long key;
- if ((key = PTR2LONG(hash_value_for_key (stream->stream_table, class))))
- return objc_write_use_common (stream, key);
- else
- {
- int length;
- hash_add (&stream->stream_table, LONG2PTR(key=PTR2LONG(class)), class);
- if ((length = objc_write_register_common (stream, key)))
- return __objc_write_class (stream, class);
- return length;
- }
-}
-
-
-__inline__ int
-__objc_write_selector (struct objc_typed_stream* stream, SEL selector)
-{
- const char* sel_name;
- __objc_write_extension (stream, _BX_SEL);
- /* to handle NULL selectors */
- if ((SEL)0 == selector)
- return objc_write_string (stream, "", 0);
- sel_name = sel_get_name (selector);
- return objc_write_string (stream, sel_name, strlen ((char*)sel_name));
-}
-
-int
-objc_write_selector (struct objc_typed_stream* stream, SEL selector)
-{
- const char* sel_name;
- unsigned long key;
-
- /* to handle NULL selectors */
- if ((SEL)0 == selector)
- return __objc_write_selector (stream, selector);
-
- sel_name = sel_get_name (selector);
- if ((key = PTR2LONG(hash_value_for_key (stream->stream_table, sel_name))))
- return objc_write_use_common (stream, key);
- else
- {
- int length;
- hash_add (&stream->stream_table,
- LONG2PTR(key=PTR2LONG(sel_name)), (char*)sel_name);
- if ((length = objc_write_register_common (stream, key)))
- return __objc_write_selector (stream, selector);
- return length;
- }
-}
-
-
-
-/*
-** Read operations
-*/
-
-__inline__ int
-objc_read_char (struct objc_typed_stream* stream, char* val)
-{
- unsigned char buf;
- int len;
- len = (*stream->read)(stream->physical, &buf, 1);
- if (len != 0)
- {
- if ((buf & _B_CODE) == _B_SINT)
- (*val) = (buf & _B_VALUE);
-
- else if ((buf & _B_NUMBER) == 1)
- {
- len = (*stream->read)(stream->physical, val, 1);
- if (buf&_B_SIGN)
- (*val) = -1*(*val);
- }
-
- else
- objc_error(nil, OBJC_ERR_BAD_DATA,
- "expected 8bit signed int, got %dbit int",
- (int)(buf&_B_NUMBER)*8);
- }
- return len;
-}
-
-
-__inline__ int
-objc_read_unsigned_char (struct objc_typed_stream* stream, unsigned char* val)
-{
- unsigned char buf;
- int len;
- if ((len = (*stream->read)(stream->physical, &buf, 1)))
- {
- if ((buf & _B_CODE) == _B_SINT)
- (*val) = (buf & _B_VALUE);
-
- else if ((buf & _B_NUMBER) == 1)
- len = (*stream->read)(stream->physical, val, 1);
-
- else
- objc_error(nil, OBJC_ERR_BAD_DATA,
- "expected 8bit unsigned int, got %dbit int",
- (int)(buf&_B_NUMBER)*8);
- }
- return len;
-}
-
-__inline__ int
-objc_read_short (struct objc_typed_stream* stream, short* value)
-{
- unsigned char buf[sizeof(short)+1];
- int len;
- if ((len = (*stream->read)(stream->physical, buf, 1)))
- {
- if ((buf[0] & _B_CODE) == _B_SINT)
- (*value) = (buf[0] & _B_VALUE);
-
- else
- {
- int pos = 1;
- int nbytes = buf[0] & _B_NUMBER;
- if (nbytes > sizeof (short))
- objc_error(nil, OBJC_ERR_BAD_DATA,
- "expected short, got bigger (%dbits)", nbytes*8);
- len = (*stream->read)(stream->physical, buf+1, nbytes);
- (*value) = 0;
- while (pos <= nbytes)
- (*value) = ((*value)*0x100) + buf[pos++];
- if (buf[0] & _B_SIGN)
- (*value) = -(*value);
- }
- }
- return len;
-}
-
-__inline__ int
-objc_read_unsigned_short (struct objc_typed_stream* stream,
- unsigned short* value)
-{
- unsigned char buf[sizeof(unsigned short)+1];
- int len;
- if ((len = (*stream->read)(stream->physical, buf, 1)))
- {
- if ((buf[0] & _B_CODE) == _B_SINT)
- (*value) = (buf[0] & _B_VALUE);
-
- else
- {
- int pos = 1;
- int nbytes = buf[0] & _B_NUMBER;
- if (nbytes > sizeof (short))
- objc_error(nil, OBJC_ERR_BAD_DATA,
- "expected short, got int or bigger");
- len = (*stream->read)(stream->physical, buf+1, nbytes);
- (*value) = 0;
- while (pos <= nbytes)
- (*value) = ((*value)*0x100) + buf[pos++];
- }
- }
- return len;
-}
-
-
-__inline__ int
-objc_read_int (struct objc_typed_stream* stream, int* value)
-{
- unsigned char buf[sizeof(int)+1];
- int len;
- if ((len = (*stream->read)(stream->physical, buf, 1)))
- {
- if ((buf[0] & _B_CODE) == _B_SINT)
- (*value) = (buf[0] & _B_VALUE);
-
- else
- {
- int pos = 1;
- int nbytes = buf[0] & _B_NUMBER;
- if (nbytes > sizeof (int))
- objc_error(nil, OBJC_ERR_BAD_DATA, "expected int, got bigger");
- len = (*stream->read)(stream->physical, buf+1, nbytes);
- (*value) = 0;
- while (pos <= nbytes)
- (*value) = ((*value)*0x100) + buf[pos++];
- if (buf[0] & _B_SIGN)
- (*value) = -(*value);
- }
- }
- return len;
-}
-
-__inline__ int
-objc_read_long (struct objc_typed_stream* stream, long* value)
-{
- unsigned char buf[sizeof(long)+1];
- int len;
- if ((len = (*stream->read)(stream->physical, buf, 1)))
- {
- if ((buf[0] & _B_CODE) == _B_SINT)
- (*value) = (buf[0] & _B_VALUE);
-
- else
- {
- int pos = 1;
- int nbytes = buf[0] & _B_NUMBER;
- if (nbytes > sizeof (long))
- objc_error(nil, OBJC_ERR_BAD_DATA, "expected long, got bigger");
- len = (*stream->read)(stream->physical, buf+1, nbytes);
- (*value) = 0;
- while (pos <= nbytes)
- (*value) = ((*value)*0x100) + buf[pos++];
- if (buf[0] & _B_SIGN)
- (*value) = -(*value);
- }
- }
- return len;
-}
-
-__inline__ int
-__objc_read_nbyte_uint (struct objc_typed_stream* stream,
- unsigned int nbytes, unsigned int* val)
-{
- int len, pos = 0;
- unsigned char buf[sizeof(unsigned int)+1];
-
- if (nbytes > sizeof (int))
- objc_error(nil, OBJC_ERR_BAD_DATA, "expected int, got bigger");
-
- len = (*stream->read)(stream->physical, buf, nbytes);
- (*val) = 0;
- while (pos < nbytes)
- (*val) = ((*val)*0x100) + buf[pos++];
- return len;
-}
-
-
-__inline__ int
-objc_read_unsigned_int (struct objc_typed_stream* stream,
- unsigned int* value)
-{
- unsigned char buf[sizeof(unsigned int)+1];
- int len;
- if ((len = (*stream->read)(stream->physical, buf, 1)))
- {
- if ((buf[0] & _B_CODE) == _B_SINT)
- (*value) = (buf[0] & _B_VALUE);
-
- else
- len = __objc_read_nbyte_uint (stream, (buf[0] & _B_VALUE), value);
-
- }
- return len;
-}
-
-int
-__objc_read_nbyte_ulong (struct objc_typed_stream* stream,
- unsigned int nbytes, unsigned long* val)
-{
- int len, pos = 0;
- unsigned char buf[sizeof(unsigned long)+1];
-
- if (nbytes > sizeof (long))
- objc_error(nil, OBJC_ERR_BAD_DATA, "expected long, got bigger");
-
- len = (*stream->read)(stream->physical, buf, nbytes);
- (*val) = 0;
- while (pos < nbytes)
- (*val) = ((*val)*0x100) + buf[pos++];
- return len;
-}
-
-
-__inline__ int
-objc_read_unsigned_long (struct objc_typed_stream* stream,
- unsigned long* value)
-{
- unsigned char buf[sizeof(unsigned long)+1];
- int len;
- if ((len = (*stream->read)(stream->physical, buf, 1)))
- {
- if ((buf[0] & _B_CODE) == _B_SINT)
- (*value) = (buf[0] & _B_VALUE);
-
- else
- len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), value);
-
- }
- return len;
-}
-
-__inline__ int
-objc_read_string (struct objc_typed_stream* stream,
- char** string)
-{
- unsigned char buf[sizeof(unsigned int)+1];
- int len;
- if ((len = (*stream->read)(stream->physical, buf, 1)))
- {
- unsigned long key = 0;
-
- if ((buf[0]&_B_CODE) == _B_RCOMM) /* register following */
- {
- len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key);
- len = (*stream->read)(stream->physical, buf, 1);
- }
-
- switch (buf[0]&_B_CODE) {
- case _B_SSTR:
- {
- int length = buf[0]&_B_VALUE;
- (*string) = (char*)objc_malloc(length+1);
- if (key)
- hash_add (&stream->stream_table, LONG2PTR(key), *string);
- len = (*stream->read)(stream->physical, *string, length);
- (*string)[length] = '\0';
- }
- break;
-
- case _B_UCOMM:
- {
- char *tmp;
- len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key);
- tmp = hash_value_for_key (stream->stream_table, LONG2PTR (key));
- *string = objc_malloc (strlen(tmp) + 1);
- strcpy (*string, tmp);
- }
- break;
-
- case _B_NSTR:
- {
- unsigned int nbytes = buf[0]&_B_VALUE;
- len = __objc_read_nbyte_uint(stream, nbytes, &nbytes);
- if (len) {
- (*string) = (char*)objc_malloc(nbytes+1);
- if (key)
- hash_add (&stream->stream_table, LONG2PTR(key), *string);
- len = (*stream->read)(stream->physical, *string, nbytes);
- (*string)[nbytes] = '\0';
- }
- }
- break;
-
- default:
- objc_error(nil, OBJC_ERR_BAD_DATA,
- "expected string, got opcode %c\n", (buf[0]&_B_CODE));
- }
- }
-
- return len;
-}
-
-
-int
-objc_read_object (struct objc_typed_stream* stream, id* object)
-{
- unsigned char buf[sizeof (unsigned int)];
- int len;
- if ((len = (*stream->read)(stream->physical, buf, 1)))
- {
- SEL read_sel = sel_get_any_uid ("read:");
- unsigned long key = 0;
-
- if ((buf[0]&_B_CODE) == _B_RCOMM) /* register common */
- {
- len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key);
- len = (*stream->read)(stream->physical, buf, 1);
- }
-
- if (buf[0] == (_B_EXT | _BX_OBJECT))
- {
- Class class;
-
- /* get class */
- len = objc_read_class (stream, &class);
-
- /* create instance */
- (*object) = class_create_instance(class);
-
- /* register? */
- if (key)
- hash_add (&stream->object_table, LONG2PTR(key), *object);
-
- /* send -read: */
- if (__objc_responds_to (*object, read_sel))
- (*get_imp(class, read_sel))(*object, read_sel, stream);
-
- /* check null-byte */
- len = (*stream->read)(stream->physical, buf, 1);
- if (buf[0] != '\0')
- objc_error(nil, OBJC_ERR_BAD_DATA,
- "expected null-byte, got opcode %c", buf[0]);
- }
-
- else if ((buf[0]&_B_CODE) == _B_UCOMM)
- {
- if (key)
- objc_error(nil, OBJC_ERR_BAD_KEY, "cannot register use upcode...");
- len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key);
- (*object) = hash_value_for_key (stream->object_table, LONG2PTR(key));
- }
-
- else if (buf[0] == (_B_EXT | _BX_OBJREF)) /* a forward reference */
- {
- struct objc_list* other;
- len = objc_read_unsigned_long (stream, &key);
- other = (struct objc_list*)hash_value_for_key (stream->object_refs,
- LONG2PTR(key));
- hash_add (&stream->object_refs, LONG2PTR(key),
- (void*)list_cons(object, other));
- }
-
- else if (buf[0] == (_B_EXT | _BX_OBJROOT)) /* a root object */
- {
- if (key)
- objc_error(nil, OBJC_ERR_BAD_KEY,
- "cannot register root object...");
- len = objc_read_object (stream, object);
- __objc_finish_read_root_object (stream);
- }
-
- else
- objc_error(nil, OBJC_ERR_BAD_DATA,
- "expected object, got opcode %c", buf[0]);
- }
- return len;
-}
-
-static int
-objc_read_class (struct objc_typed_stream* stream, Class* class)
-{
- unsigned char buf[sizeof (unsigned int)];
- int len;
- if ((len = (*stream->read)(stream->physical, buf, 1)))
- {
- unsigned long key = 0;
-
- if ((buf[0]&_B_CODE) == _B_RCOMM) /* register following */
- {
- len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key);
- len = (*stream->read)(stream->physical, buf, 1);
- }
-
- if (buf[0] == (_B_EXT | _BX_CLASS))
- {
- char* class_name;
- unsigned long version;
-
- /* get class */
- len = objc_read_string (stream, &class_name);
- (*class) = objc_get_class(class_name);
- objc_free(class_name);
-
- /* register */
- if (key)
- hash_add (&stream->stream_table, LONG2PTR(key), *class);
-
- objc_read_unsigned_long(stream, &version);
- hash_add (&stream->class_table, (*class)->name, (void*)version);
- }
-
- else if ((buf[0]&_B_CODE) == _B_UCOMM)
- {
- if (key)
- objc_error(nil, OBJC_ERR_BAD_KEY, "cannot register use upcode...");
- len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key);
- (*class) = hash_value_for_key (stream->stream_table, LONG2PTR(key));
- if (!*class)
- objc_error(nil, OBJC_ERR_BAD_CLASS,
- "cannot find class for key %lu", key);
- }
-
- else
- objc_error(nil, OBJC_ERR_BAD_DATA,
- "expected class, got opcode %c", buf[0]);
- }
- return len;
-}
-
-int
-objc_read_selector (struct objc_typed_stream* stream, SEL* selector)
-{
- unsigned char buf[sizeof (unsigned int)];
- int len;
- if ((len = (*stream->read)(stream->physical, buf, 1)))
- {
- unsigned long key = 0;
-
- if ((buf[0]&_B_CODE) == _B_RCOMM) /* register following */
- {
- len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key);
- len = (*stream->read)(stream->physical, buf, 1);
- }
-
- if (buf[0] == (_B_EXT|_BX_SEL)) /* selector! */
- {
- char* selector_name;
-
- /* get selector */
- len = objc_read_string (stream, &selector_name);
- /* To handle NULL selectors */
- if (0 == strlen(selector_name))
- {
- (*selector) = (SEL)0;
- return 0;
- }
- else
- (*selector) = sel_get_any_uid(selector_name);
- objc_free(selector_name);
-
- /* register */
- if (key)
- hash_add (&stream->stream_table, LONG2PTR(key), (void*)*selector);
- }
-
- else if ((buf[0]&_B_CODE) == _B_UCOMM)
- {
- if (key)
- objc_error(nil, OBJC_ERR_BAD_KEY, "cannot register use upcode...");
- len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key);
- (*selector) = hash_value_for_key (stream->stream_table,
- LONG2PTR(key));
- }
-
- else
- objc_error(nil, OBJC_ERR_BAD_DATA,
- "expected selector, got opcode %c", buf[0]);
- }
- return len;
-}
-
-/*
-** USER LEVEL FUNCTIONS
-*/
-
-/*
-** Write one object, encoded in TYPE and pointed to by DATA to the
-** typed stream STREAM.
-*/
-
-int
-objc_write_type(TypedStream* stream, const char* type, const void* data)
-{
- switch(*type) {
- case _C_ID:
- return objc_write_object (stream, *(id*)data);
- break;
-
- case _C_CLASS:
- return objc_write_class (stream, *(Class*)data);
- break;
-
- case _C_SEL:
- return objc_write_selector (stream, *(SEL*)data);
- break;
-
- case _C_CHR:
- return objc_write_char(stream, *(char*)data);
- break;
-
- case _C_UCHR:
- return objc_write_unsigned_char(stream, *(unsigned char*)data);
- break;
-
- case _C_SHT:
- return objc_write_short(stream, *(short*)data);
- break;
-
- case _C_USHT:
- return objc_write_unsigned_short(stream, *(unsigned short*)data);
- break;
-
- case _C_INT:
- return objc_write_int(stream, *(int*)data);
- break;
-
- case _C_UINT:
- return objc_write_unsigned_int(stream, *(unsigned int*)data);
- break;
-
- case _C_LNG:
- return objc_write_long(stream, *(long*)data);
- break;
-
- case _C_ULNG:
- return objc_write_unsigned_long(stream, *(unsigned long*)data);
- break;
-
- case _C_CHARPTR:
- return objc_write_string (stream, *(char**)data, strlen(*(char**)data));
- break;
-
- case _C_ATOM:
- return objc_write_string_atomic (stream, *(char**)data,
- strlen(*(char**)data));
- break;
-
- case _C_ARY_B:
- {
- int len = atoi(type+1);
- while (isdigit(*++type))
- ;
- return objc_write_array (stream, type, len, data);
- }
- break;
-
- case _C_STRUCT_B:
- {
- int acc_size = 0;
- int align;
- while (*type != _C_STRUCT_E && *type++ != '=')
- ; /* skip "<name>=" */
- while (*type != _C_STRUCT_E)
- {
- align = objc_alignof_type (type); /* padd to alignment */
- acc_size += ROUND (acc_size, align);
- objc_write_type (stream, type, ((char*)data)+acc_size);
- acc_size += objc_sizeof_type (type); /* add component size */
- type = objc_skip_typespec (type); /* skip component */
- }
- return 1;
- }
-
- default:
- {
- objc_error(nil, OBJC_ERR_BAD_TYPE,
- "objc_write_type: cannot parse typespec: %s\n", type);
- return 0;
- }
- }
-}
-
-/*
-** Read one object, encoded in TYPE and pointed to by DATA to the
-** typed stream STREAM. DATA specifies the address of the types to
-** read. Expected type is checked against the type actually present
-** on the stream.
-*/
-
-int
-objc_read_type(TypedStream* stream, const char* type, void* data)
-{
- char c;
- switch(c = *type) {
- case _C_ID:
- return objc_read_object (stream, (id*)data);
- break;
-
- case _C_CLASS:
- return objc_read_class (stream, (Class*)data);
- break;
-
- case _C_SEL:
- return objc_read_selector (stream, (SEL*)data);
- break;
-
- case _C_CHR:
- return objc_read_char (stream, (char*)data);
- break;
-
- case _C_UCHR:
- return objc_read_unsigned_char (stream, (unsigned char*)data);
- break;
-
- case _C_SHT:
- return objc_read_short (stream, (short*)data);
- break;
-
- case _C_USHT:
- return objc_read_unsigned_short (stream, (unsigned short*)data);
- break;
-
- case _C_INT:
- return objc_read_int (stream, (int*)data);
- break;
-
- case _C_UINT:
- return objc_read_unsigned_int (stream, (unsigned int*)data);
- break;
-
- case _C_LNG:
- return objc_read_long (stream, (long*)data);
- break;
-
- case _C_ULNG:
- return objc_read_unsigned_long (stream, (unsigned long*)data);
- break;
-
- case _C_CHARPTR:
- case _C_ATOM:
- return objc_read_string (stream, (char**)data);
- break;
-
- case _C_ARY_B:
- {
- int len = atoi(type+1);
- while (isdigit(*++type))
- ;
- return objc_read_array (stream, type, len, data);
- }
- break;
-
- case _C_STRUCT_B:
- {
- int acc_size = 0;
- int align;
- while (*type != _C_STRUCT_E && *type++ != '=')
- ; /* skip "<name>=" */
- while (*type != _C_STRUCT_E)
- {
- align = objc_alignof_type (type); /* padd to alignment */
- acc_size += ROUND (acc_size, align);
- objc_read_type (stream, type, ((char*)data)+acc_size);
- acc_size += objc_sizeof_type (type); /* add component size */
- type = objc_skip_typespec (type); /* skip component */
- }
- return 1;
- }
-
- default:
- {
- objc_error(nil, OBJC_ERR_BAD_TYPE,
- "objc_read_type: cannot parse typespec: %s\n", type);
- return 0;
- }
- }
-}
-
-/*
-** Write the object specified by the template TYPE to STREAM. Last
-** arguments specify addresses of values to be written. It might
-** seem surprising to specify values by address, but this is extremely
-** convenient for copy-paste with objc_read_types calls. A more
-** down-to-the-earth cause for this passing of addresses is that values
-** of arbitrary size is not well supported in ANSI C for functions with
-** variable number of arguments.
-*/
-
-int
-objc_write_types (TypedStream* stream, const char* type, ...)
-{
- va_list args;
- const char *c;
- int res = 0;
-
- va_start(args, type);
-
- for (c = type; *c; c = objc_skip_typespec (c))
- {
- switch(*c) {
- case _C_ID:
- res = objc_write_object (stream, *va_arg (args, id*));
- break;
-
- case _C_CLASS:
- res = objc_write_class (stream, *va_arg(args, Class*));
- break;
-
- case _C_SEL:
- res = objc_write_selector (stream, *va_arg(args, SEL*));
- break;
-
- case _C_CHR:
- res = objc_write_char (stream, *va_arg (args, char*));
- break;
-
- case _C_UCHR:
- res = objc_write_unsigned_char (stream,
- *va_arg (args, unsigned char*));
- break;
-
- case _C_SHT:
- res = objc_write_short (stream, *va_arg(args, short*));
- break;
-
- case _C_USHT:
- res = objc_write_unsigned_short (stream,
- *va_arg(args, unsigned short*));
- break;
-
- case _C_INT:
- res = objc_write_int(stream, *va_arg(args, int*));
- break;
-
- case _C_UINT:
- res = objc_write_unsigned_int(stream, *va_arg(args, unsigned int*));
- break;
-
- case _C_LNG:
- res = objc_write_long(stream, *va_arg(args, long*));
- break;
-
- case _C_ULNG:
- res = objc_write_unsigned_long(stream, *va_arg(args, unsigned long*));
- break;
-
- case _C_CHARPTR:
- {
- char** str = va_arg(args, char**);
- res = objc_write_string (stream, *str, strlen(*str));
- }
- break;
-
- case _C_ATOM:
- {
- char** str = va_arg(args, char**);
- res = objc_write_string_atomic (stream, *str, strlen(*str));
- }
- break;
-
- case _C_ARY_B:
- {
- int len = atoi(c+1);
- const char* t = c;
- while (isdigit(*++t))
- ;
- res = objc_write_array (stream, t, len, va_arg(args, void*));
- t = objc_skip_typespec (t);
- if (*t != _C_ARY_E)
- objc_error(nil, OBJC_ERR_BAD_TYPE, "expected `]', got: %s", t);
- }
- break;
-
- default:
- objc_error(nil, OBJC_ERR_BAD_TYPE,
- "objc_write_types: cannot parse typespec: %s\n", type);
- }
- }
- va_end(args);
- return res;
-}
-
-
-/*
-** Last arguments specify addresses of values to be read. Expected
-** type is checked against the type actually present on the stream.
-*/
-
-int
-objc_read_types(TypedStream* stream, const char* type, ...)
-{
- va_list args;
- const char *c;
- int res = 0;
-
- va_start(args, type);
-
- for (c = type; *c; c = objc_skip_typespec(c))
- {
- switch(*c) {
- case _C_ID:
- res = objc_read_object(stream, va_arg(args, id*));
- break;
-
- case _C_CLASS:
- res = objc_read_class(stream, va_arg(args, Class*));
- break;
-
- case _C_SEL:
- res = objc_read_selector(stream, va_arg(args, SEL*));
- break;
-
- case _C_CHR:
- res = objc_read_char(stream, va_arg(args, char*));
- break;
-
- case _C_UCHR:
- res = objc_read_unsigned_char(stream, va_arg(args, unsigned char*));
- break;
-
- case _C_SHT:
- res = objc_read_short(stream, va_arg(args, short*));
- break;
-
- case _C_USHT:
- res = objc_read_unsigned_short(stream, va_arg(args, unsigned short*));
- break;
-
- case _C_INT:
- res = objc_read_int(stream, va_arg(args, int*));
- break;
-
- case _C_UINT:
- res = objc_read_unsigned_int(stream, va_arg(args, unsigned int*));
- break;
-
- case _C_LNG:
- res = objc_read_long(stream, va_arg(args, long*));
- break;
-
- case _C_ULNG:
- res = objc_read_unsigned_long(stream, va_arg(args, unsigned long*));
- break;
-
- case _C_CHARPTR:
- case _C_ATOM:
- {
- char** str = va_arg(args, char**);
- res = objc_read_string (stream, str);
- }
- break;
-
- case _C_ARY_B:
- {
- int len = atoi(c+1);
- const char* t = c;
- while (isdigit(*++t))
- ;
- res = objc_read_array (stream, t, len, va_arg(args, void*));
- t = objc_skip_typespec (t);
- if (*t != _C_ARY_E)
- objc_error(nil, OBJC_ERR_BAD_TYPE, "expected `]', got: %s", t);
- }
- break;
-
- default:
- objc_error(nil, OBJC_ERR_BAD_TYPE,
- "objc_read_types: cannot parse typespec: %s\n", type);
- }
- }
- va_end(args);
- return res;
-}
-
-/*
-** Write an array of COUNT elements of TYPE from the memory address DATA.
-** This is equivalent of objc_write_type (stream, "[N<type>]", data)
-*/
-
-int
-objc_write_array (TypedStream* stream, const char* type,
- int count, const void* data)
-{
- int off = objc_sizeof_type(type);
- const char* where = data;
-
- while (count-- > 0)
- {
- objc_write_type(stream, type, where);
- where += off;
- }
- return 1;
-}
-
-/*
-** Read an array of COUNT elements of TYPE into the memory address
-** DATA. The memory pointed to by data is supposed to be allocated
-** by the callee. This is equivalent of
-** objc_read_type (stream, "[N<type>]", data)
-*/
-
-int
-objc_read_array (TypedStream* stream, const char* type,
- int count, void* data)
-{
- int off = objc_sizeof_type(type);
- char* where = (char*)data;
-
- while (count-- > 0)
- {
- objc_read_type(stream, type, where);
- where += off;
- }
- return 1;
-}
-
-static int
-__objc_fread(FILE* file, char* data, int len)
-{
- return fread(data, len, 1, file);
-}
-
-static int
-__objc_fwrite(FILE* file, char* data, int len)
-{
- return fwrite(data, len, 1, file);
-}
-
-static int
-__objc_feof(FILE* file)
-{
- return feof(file);
-}
-
-static int
-__objc_no_write(FILE* file, char* data, int len)
-{
- objc_error (nil, OBJC_ERR_NO_WRITE, "TypedStream not open for writing");
- return 0;
-}
-
-static int
-__objc_no_read(FILE* file, char* data, int len)
-{
- objc_error (nil, OBJC_ERR_NO_READ, "TypedStream not open for reading");
- return 0;
-}
-
-static int
-__objc_read_typed_stream_signature (TypedStream* stream)
-{
- char buffer[80];
- int pos = 0;
- do
- (*stream->read)(stream->physical, buffer+pos, 1);
- while (buffer[pos++] != '\0')
- ;
- sscanf (buffer, "GNU TypedStream %d", &stream->version);
- if (stream->version != OBJC_TYPED_STREAM_VERSION)
- objc_error (nil, OBJC_ERR_STREAM_VERSION,
- "cannot handle TypedStream version %d", stream->version);
- return 1;
-}
-
-static int
-__objc_write_typed_stream_signature (TypedStream* stream)
-{
- char buffer[80];
- sprintf(buffer, "GNU TypedStream %d", OBJC_TYPED_STREAM_VERSION);
- stream->version = OBJC_TYPED_STREAM_VERSION;
- (*stream->write)(stream->physical, buffer, strlen(buffer)+1);
- return 1;
-}
-
-static void __objc_finish_write_root_object(struct objc_typed_stream* stream)
-{
- hash_delete (stream->object_table);
- stream->object_table = hash_new(64,
- (hash_func_type)hash_ptr,
- (compare_func_type)compare_ptrs);
-}
-
-static void __objc_finish_read_root_object(struct objc_typed_stream* stream)
-{
- node_ptr node;
- SEL awake_sel = sel_get_any_uid ("awake");
- cache_ptr free_list = hash_new (64,
- (hash_func_type) hash_ptr,
- (compare_func_type) compare_ptrs);
-
- /* resolve object forward references */
- for (node = hash_next (stream->object_refs, NULL); node;
- node = hash_next (stream->object_refs, node))
- {
- struct objc_list* reflist = node->value;
- const void* key = node->key;
- id object = hash_value_for_key (stream->object_table, key);
- while(reflist)
- {
- *((id*)reflist->head) = object;
- if (hash_value_for_key (free_list,reflist) == NULL)
- hash_add (&free_list,reflist,reflist);
-
- reflist = reflist->tail;
- }
- }
-
- /* apply __objc_free to all objects stored in free_list */
- for (node = hash_next (free_list, NULL); node;
- node = hash_next (free_list, node))
- objc_free ((void *) node->key);
-
- hash_delete (free_list);
-
- /* empty object reference table */
- hash_delete (stream->object_refs);
- stream->object_refs = hash_new(8, (hash_func_type)hash_ptr,
- (compare_func_type)compare_ptrs);
-
- /* call -awake for all objects read */
- if (awake_sel)
- {
- for (node = hash_next (stream->object_table, NULL); node;
- node = hash_next (stream->object_table, node))
- {
- id object = node->value;
- if (__objc_responds_to (object, awake_sel))
- (*objc_msg_lookup(object, awake_sel))(object, awake_sel);
- }
- }
-
- /* empty object table */
- hash_delete (stream->object_table);
- stream->object_table = hash_new(64,
- (hash_func_type)hash_ptr,
- (compare_func_type)compare_ptrs);
-}
-
-/*
-** Open the stream PHYSICAL in MODE
-*/
-
-TypedStream*
-objc_open_typed_stream (FILE* physical, int mode)
-{
- TypedStream* s = (TypedStream*)objc_malloc(sizeof(TypedStream));
-
- s->mode = mode;
- s->physical = physical;
- s->stream_table = hash_new(64,
- (hash_func_type)hash_ptr,
- (compare_func_type)compare_ptrs);
- s->object_table = hash_new(64,
- (hash_func_type)hash_ptr,
- (compare_func_type)compare_ptrs);
- s->eof = (objc_typed_eof_func)__objc_feof;
- s->flush = (objc_typed_flush_func)fflush;
- s->writing_root_p = 0;
- if (mode == OBJC_READONLY)
- {
- s->class_table = hash_new(8, (hash_func_type)hash_string,
- (compare_func_type)compare_strings);
- s->object_refs = hash_new(8, (hash_func_type)hash_ptr,
- (compare_func_type)compare_ptrs);
- s->read = (objc_typed_read_func)__objc_fread;
- s->write = (objc_typed_write_func)__objc_no_write;
- __objc_read_typed_stream_signature (s);
- }
- else if (mode == OBJC_WRITEONLY)
- {
- s->class_table = 0;
- s->object_refs = 0;
- s->read = (objc_typed_read_func)__objc_no_read;
- s->write = (objc_typed_write_func)__objc_fwrite;
- __objc_write_typed_stream_signature (s);
- }
- else
- {
- objc_close_typed_stream (s);
- return NULL;
- }
- s->type = OBJC_FILE_STREAM;
- return s;
-}
-
-/*
-** Open the file named by FILE_NAME in MODE
-*/
-
-TypedStream*
-objc_open_typed_stream_for_file (const char* file_name, int mode)
-{
- FILE* file = NULL;
- TypedStream* s;
-
- if (mode == OBJC_READONLY)
- file = fopen (file_name, "r");
- else
- file = fopen (file_name, "w");
-
- if (file)
- {
- s = objc_open_typed_stream (file, mode);
- if (s)
- s->type |= OBJC_MANAGED_STREAM;
- return s;
- }
- else
- return NULL;
-}
-
-/*
-** Close STREAM freeing the structure it self. If it was opened with
-** objc_open_typed_stream_for_file, the file will also be closed.
-*/
-
-void
-objc_close_typed_stream (TypedStream* stream)
-{
- if (stream->mode == OBJC_READONLY)
- {
- __objc_finish_read_root_object (stream); /* Just in case... */
- hash_delete (stream->class_table);
- hash_delete (stream->object_refs);
- }
-
- hash_delete (stream->stream_table);
- hash_delete (stream->object_table);
-
- if (stream->type == (OBJC_MANAGED_STREAM | OBJC_FILE_STREAM))
- fclose ((FILE*)stream->physical);
-
- objc_free(stream);
-}
-
-BOOL
-objc_end_of_typed_stream (TypedStream* stream)
-{
- return (*stream->eof)(stream->physical);
-}
-
-void
-objc_flush_typed_stream (TypedStream* stream)
-{
- (*stream->flush)(stream->physical);
-}
-
-long
-objc_get_stream_class_version (TypedStream* stream, Class class)
-{
- if (stream->class_table)
- return PTR2LONG(hash_value_for_key (stream->class_table, class->name));
- else
- return class_get_version (class);
-}
-
diff --git a/contrib/gcc/objc/class.c b/contrib/gcc/objc/class.c
deleted file mode 100644
index 44aa1b9f98eb..000000000000
--- a/contrib/gcc/objc/class.c
+++ /dev/null
@@ -1,358 +0,0 @@
-/* GNU Objective C Runtime class related functions
- Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
- Contributed by Kresten Krab Thorup and Dennis Glatting.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the Free Software
-Foundation; either version 2, or (at your option) any later version.
-
-GNU CC is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
-details.
-
-You should have received a copy of the GNU General Public License along with
-GNU CC; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* As a special exception, if you link this library with files compiled with
- GCC to produce an executable, this does not cause the resulting executable
- to be covered by the GNU General Public License. This exception does not
- however invalidate any other reasons why the executable file might be
- covered by the GNU General Public License. */
-
-#include "runtime.h" /* the kitchen sink */
-#include "sarray.h"
-
-/* The table of classname->class. Used for objc_lookup_class and friends */
-static cache_ptr __objc_class_hash = 0; /* !T:MUTEX */
-
-/* This is a hook which is called by objc_get_class and
- objc_lookup_class if the runtime is not able to find the class.
- This may e.g. try to load in the class using dynamic loading */
-Class (*_objc_lookup_class)(const char* name) = 0; /* !T:SAFE */
-
-
-/* True when class links has been resolved */
-BOOL __objc_class_links_resolved = NO; /* !T:UNUSED */
-
-
-/* Initial number of buckets size of class hash table. */
-#define CLASS_HASH_SIZE 32
-
-void __objc_init_class_tables()
-{
- /* Allocate the class hash table */
-
- if(__objc_class_hash)
- return;
-
- objc_mutex_lock(__objc_runtime_mutex);
-
- __objc_class_hash
- = hash_new (CLASS_HASH_SIZE,
- (hash_func_type) hash_string,
- (compare_func_type) compare_strings);
-
- objc_mutex_unlock(__objc_runtime_mutex);
-}
-
-/* This function adds a class to the class hash table, and assigns the
- class a number, unless it's already known */
-void
-__objc_add_class_to_hash(Class class)
-{
- Class h_class;
-
- objc_mutex_lock(__objc_runtime_mutex);
-
- /* make sure the table is there */
- assert(__objc_class_hash);
-
- /* make sure it's not a meta class */
- assert(CLS_ISCLASS(class));
-
- /* Check to see if the class is already in the hash table. */
- h_class = hash_value_for_key (__objc_class_hash, class->name);
- if (!h_class)
- {
- /* The class isn't in the hash table. Add the class and assign a class
- number. */
- static unsigned int class_number = 1;
-
- CLS_SETNUMBER(class, class_number);
- CLS_SETNUMBER(class->class_pointer, class_number);
-
- ++class_number;
- hash_add (&__objc_class_hash, class->name, class);
- }
-
- objc_mutex_unlock(__objc_runtime_mutex);
-}
-
-/* Get the class object for the class named NAME. If NAME does not
- identify a known class, the hook _objc_lookup_class is called. If
- this fails, nil is returned */
-Class objc_lookup_class (const char* name)
-{
- Class class;
-
- objc_mutex_lock(__objc_runtime_mutex);
-
- /* Make sure the class hash table exists. */
- assert (__objc_class_hash);
-
- class = hash_value_for_key (__objc_class_hash, name);
-
- objc_mutex_unlock(__objc_runtime_mutex);
-
- if (class)
- return class;
-
- if (_objc_lookup_class)
- return (*_objc_lookup_class)(name);
- else
- return 0;
-}
-
-/* Get the class object for the class named NAME. If NAME does not
- identify a known class, the hook _objc_lookup_class is called. If
- this fails, an error message is issued and the system aborts */
-Class
-objc_get_class (const char *name)
-{
- Class class;
-
- objc_mutex_lock(__objc_runtime_mutex);
-
- /* Make sure the class hash table exists. */
- assert (__objc_class_hash);
-
- class = hash_value_for_key (__objc_class_hash, name);
-
- objc_mutex_unlock(__objc_runtime_mutex);
-
- if (class)
- return class;
-
- if (_objc_lookup_class)
- class = (*_objc_lookup_class)(name);
-
- if(class)
- return class;
-
- objc_error(nil, OBJC_ERR_BAD_CLASS,
- "objc runtime: cannot find class %s\n", name);
- return 0;
-}
-
-MetaClass
-objc_get_meta_class(const char *name)
-{
- return objc_get_class(name)->class_pointer;
-}
-
-/* This function provides a way to enumerate all the classes in the
- executable. Pass *ENUM_STATE == NULL to start the enumeration. The
- function will return 0 when there are no more classes.
- For example:
- id class;
- void *es = NULL;
- while ((class = objc_next_class(&es)))
- ... do something with class;
-*/
-Class
-objc_next_class(void **enum_state)
-{
- objc_mutex_lock(__objc_runtime_mutex);
-
- /* make sure the table is there */
- assert(__objc_class_hash);
-
- *(node_ptr*)enum_state =
- hash_next(__objc_class_hash, *(node_ptr*)enum_state);
-
- objc_mutex_unlock(__objc_runtime_mutex);
-
- if (*(node_ptr*)enum_state)
- return (*(node_ptr*)enum_state)->value;
- return (Class)0;
-}
-
-/* Resolve super/subclass links for all classes. The only thing we
- can be sure of is that the class_pointer for class objects point
- to the right meta class objects */
-void __objc_resolve_class_links()
-{
- node_ptr node;
- Class object_class = objc_get_class ("Object");
-
- assert(object_class);
-
- objc_mutex_lock(__objc_runtime_mutex);
-
- /* Assign subclass links */
- for (node = hash_next (__objc_class_hash, NULL); node;
- node = hash_next (__objc_class_hash, node))
- {
- Class class1 = node->value;
-
- /* Make sure we have what we think we have. */
- assert (CLS_ISCLASS(class1));
- assert (CLS_ISMETA(class1->class_pointer));
-
- /* The class_pointer of all meta classes point to Object's meta class. */
- class1->class_pointer->class_pointer = object_class->class_pointer;
-
- if (!(CLS_ISRESOLV(class1)))
- {
- CLS_SETRESOLV(class1);
- CLS_SETRESOLV(class1->class_pointer);
-
- if(class1->super_class)
- {
- Class a_super_class
- = objc_get_class ((char *) class1->super_class);
-
- assert (a_super_class);
-
- DEBUG_PRINTF ("making class connections for: %s\n",
- class1->name);
-
- /* assign subclass links for superclass */
- class1->sibling_class = a_super_class->subclass_list;
- a_super_class->subclass_list = class1;
-
- /* Assign subclass links for meta class of superclass */
- if (a_super_class->class_pointer)
- {
- class1->class_pointer->sibling_class
- = a_super_class->class_pointer->subclass_list;
- a_super_class->class_pointer->subclass_list
- = class1->class_pointer;
- }
- }
- else /* a root class, make its meta object */
- /* be a subclass of Object */
- {
- class1->class_pointer->sibling_class
- = object_class->subclass_list;
- object_class->subclass_list = class1->class_pointer;
- }
- }
- }
-
- /* Assign superclass links */
- for (node = hash_next (__objc_class_hash, NULL); node;
- node = hash_next (__objc_class_hash, node))
- {
- Class class1 = node->value;
- Class sub_class;
- for (sub_class = class1->subclass_list; sub_class;
- sub_class = sub_class->sibling_class)
- {
- sub_class->super_class = class1;
- if(CLS_ISCLASS(sub_class))
- sub_class->class_pointer->super_class = class1->class_pointer;
- }
- }
-
- objc_mutex_unlock(__objc_runtime_mutex);
-}
-
-
-
-#define CLASSOF(c) ((c)->class_pointer)
-
-Class
-class_pose_as (Class impostor, Class super_class)
-{
- node_ptr node;
- Class class1;
-
- if (!CLS_ISRESOLV (impostor))
- __objc_resolve_class_links ();
-
- /* preconditions */
- assert (impostor);
- assert (super_class);
- assert (impostor->super_class == super_class);
- assert (CLS_ISCLASS (impostor));
- assert (CLS_ISCLASS (super_class));
- assert (impostor->instance_size == super_class->instance_size);
-
- {
- Class *subclass = &(super_class->subclass_list);
-
- /* move subclasses of super_class to impostor */
- while (*subclass)
- {
- Class nextSub = (*subclass)->sibling_class;
-
- if (*subclass != impostor)
- {
- Class sub = *subclass;
-
- /* classes */
- sub->sibling_class = impostor->subclass_list;
- sub->super_class = impostor;
- impostor->subclass_list = sub;
-
- /* It will happen that SUB is not a class object if it is
- the top of the meta class hierarchy chain. (root
- meta-class objects inherit their class object) If that is
- the case... don't mess with the meta-meta class. */
- if (CLS_ISCLASS (sub))
- {
- /* meta classes */
- CLASSOF (sub)->sibling_class =
- CLASSOF (impostor)->subclass_list;
- CLASSOF (sub)->super_class = CLASSOF (impostor);
- CLASSOF (impostor)->subclass_list = CLASSOF (sub);
- }
- }
-
- *subclass = nextSub;
- }
-
- /* set subclasses of superclass to be impostor only */
- super_class->subclass_list = impostor;
- CLASSOF (super_class)->subclass_list = CLASSOF (impostor);
-
- /* set impostor to have no sibling classes */
- impostor->sibling_class = 0;
- CLASSOF (impostor)->sibling_class = 0;
- }
-
- /* check relationship of impostor and super_class is kept. */
- assert (impostor->super_class == super_class);
- assert (CLASSOF (impostor)->super_class == CLASSOF (super_class));
-
- /* This is how to update the lookup table. Regardless of
- what the keys of the hashtable is, change all values that are
- superclass into impostor. */
-
- objc_mutex_lock(__objc_runtime_mutex);
-
- for (node = hash_next (__objc_class_hash, NULL); node;
- node = hash_next (__objc_class_hash, node))
- {
- class1 = (Class)node->value;
- if (class1 == super_class)
- {
- node->value = impostor; /* change hash table value */
- }
- }
-
- objc_mutex_unlock(__objc_runtime_mutex);
-
- /* next, we update the dispatch tables... */
- __objc_update_dispatch_table_for_class (CLASSOF (impostor));
- __objc_update_dispatch_table_for_class (impostor);
-
- return impostor;
-}
-
-
diff --git a/contrib/gcc/objc/encoding.c b/contrib/gcc/objc/encoding.c
deleted file mode 100644
index e6f84aa04a4f..000000000000
--- a/contrib/gcc/objc/encoding.c
+++ /dev/null
@@ -1,554 +0,0 @@
-/* Encoding of types for Objective C.
- Copyright (C) 1993, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
- Contributed by Kresten Krab Thorup
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-/* As a special exception, if you link this library with files
- compiled with GCC to produce an executable, this does not cause
- the resulting executable to be covered by the GNU General Public License.
- This exception does not however invalidate any other reasons why
- the executable file might be covered by the GNU General Public License. */
-
-#include "encoding.h"
-
-#define MAX(X, Y) \
- ({ typeof(X) __x = (X), __y = (Y); \
- (__x > __y ? __x : __y); })
-
-#define MIN(X, Y) \
- ({ typeof(X) __x = (X), __y = (Y); \
- (__x < __y ? __x : __y); })
-
-#define ROUND(V, A) \
- ({ typeof(V) __v=(V); typeof(A) __a=(A); \
- __a*((__v+__a-1)/__a); })
-
-
-static inline int
-atoi (const char* str)
-{
- int res = 0;
-
- while (isdigit (*str))
- res *= 10, res += (*str++ - '0');
-
- return res;
-}
-
-/*
- return the size of an object specified by type
-*/
-
-int
-objc_sizeof_type(const char* type)
-{
- switch(*type) {
- case _C_ID:
- return sizeof(id);
- break;
-
- case _C_CLASS:
- return sizeof(Class);
- break;
-
- case _C_SEL:
- return sizeof(SEL);
- break;
-
- case _C_CHR:
- return sizeof(char);
- break;
-
- case _C_UCHR:
- return sizeof(unsigned char);
- break;
-
- case _C_SHT:
- return sizeof(short);
- break;
-
- case _C_USHT:
- return sizeof(unsigned short);
- break;
-
- case _C_INT:
- return sizeof(int);
- break;
-
- case _C_UINT:
- return sizeof(unsigned int);
- break;
-
- case _C_LNG:
- return sizeof(long);
- break;
-
- case _C_ULNG:
- return sizeof(unsigned long);
- break;
-
- case _C_FLT:
- return sizeof(float);
- break;
-
- case _C_DBL:
- return sizeof(double);
- break;
-
- case _C_VOID:
- return sizeof(void);
- break;
- case _C_PTR:
- case _C_ATOM:
- case _C_CHARPTR:
- return sizeof(char*);
- break;
-
- case _C_ARY_B:
- {
- int len = atoi(type+1);
- while (isdigit(*++type));
- return len*objc_aligned_size (type);
- }
- break;
-
- case _C_STRUCT_B:
- {
- int acc_size = 0;
- int align;
- while (*type != _C_STRUCT_E && *type++ != '='); /* skip "<name>=" */
- while (*type != _C_STRUCT_E)
- {
- align = objc_alignof_type (type); /* padd to alignment */
- acc_size = ROUND (acc_size, align);
- acc_size += objc_sizeof_type (type); /* add component size */
- type = objc_skip_typespec (type); /* skip component */
- }
- return acc_size;
- }
-
- case _C_UNION_B:
- {
- int max_size = 0;
- while (*type != _C_UNION_E && *type++ != '=') /* do nothing */;
- while (*type != _C_UNION_E)
- {
- max_size = MAX (max_size, objc_sizeof_type (type));
- type = objc_skip_typespec (type);
- }
- return max_size;
- }
-
- default:
- {
- objc_error(nil, OBJC_ERR_BAD_TYPE, "unknown type %s\n", type);
- return 0;
- }
- }
-}
-
-
-/*
- Return the alignment of an object specified by type
-*/
-
-int
-objc_alignof_type(const char* type)
-{
- switch(*type) {
- case _C_ID:
- return __alignof__(id);
- break;
-
- case _C_CLASS:
- return __alignof__(Class);
- break;
-
- case _C_SEL:
- return __alignof__(SEL);
- break;
-
- case _C_CHR:
- return __alignof__(char);
- break;
-
- case _C_UCHR:
- return __alignof__(unsigned char);
- break;
-
- case _C_SHT:
- return __alignof__(short);
- break;
-
- case _C_USHT:
- return __alignof__(unsigned short);
- break;
-
- case _C_INT:
- return __alignof__(int);
- break;
-
- case _C_UINT:
- return __alignof__(unsigned int);
- break;
-
- case _C_LNG:
- return __alignof__(long);
- break;
-
- case _C_ULNG:
- return __alignof__(unsigned long);
- break;
-
- case _C_FLT:
- return __alignof__(float);
- break;
-
- case _C_DBL:
- return __alignof__(double);
- break;
-
- case _C_PTR:
- case _C_ATOM:
- case _C_CHARPTR:
- return __alignof__(char*);
- break;
-
- case _C_ARY_B:
- while (isdigit(*++type)) /* do nothing */;
- return objc_alignof_type (type);
-
- case _C_STRUCT_B:
- {
- struct { int x; double y; } fooalign;
- while(*type != _C_STRUCT_E && *type++ != '=') /* do nothing */;
- if (*type != _C_STRUCT_E)
- return MAX (objc_alignof_type (type), __alignof__ (fooalign));
- else
- return __alignof__ (fooalign);
- }
-
- case _C_UNION_B:
- {
- int maxalign = 0;
- while (*type != _C_UNION_E && *type++ != '=') /* do nothing */;
- while (*type != _C_UNION_E)
- {
- maxalign = MAX (maxalign, objc_alignof_type (type));
- type = objc_skip_typespec (type);
- }
- return maxalign;
- }
-
- default:
- {
- objc_error(nil, OBJC_ERR_BAD_TYPE, "unknown type %s\n", type);
- return 0;
- }
- }
-}
-
-/*
- The aligned size if the size rounded up to the nearest alignment.
-*/
-
-int
-objc_aligned_size (const char* type)
-{
- int size = objc_sizeof_type (type);
- int align = objc_alignof_type (type);
- return ROUND (size, align);
-}
-
-/*
- The size rounded up to the nearest integral of the wordsize, taken
- to be the size of a void*.
-*/
-
-int
-objc_promoted_size (const char* type)
-{
- int size = objc_sizeof_type (type);
- int wordsize = sizeof (void*);
-
- return ROUND (size, wordsize);
-}
-
-/*
- Skip type qualifiers. These may eventually precede typespecs
- occurring in method prototype encodings.
-*/
-
-inline const char*
-objc_skip_type_qualifiers (const char* type)
-{
- while (*type == _C_CONST
- || *type == _C_IN
- || *type == _C_INOUT
- || *type == _C_OUT
- || *type == _C_BYCOPY
- || *type == _C_ONEWAY)
- {
- type += 1;
- }
- return type;
-}
-
-
-/*
- Skip one typespec element. If the typespec is prepended by type
- qualifiers, these are skipped as well.
-*/
-
-const char*
-objc_skip_typespec (const char* type)
-{
- type = objc_skip_type_qualifiers (type);
-
- switch (*type) {
-
- case _C_ID:
- /* An id may be annotated by the actual type if it is known
- with the @"ClassName" syntax */
-
- if (*++type != '"')
- return type;
- else
- {
- while (*++type != '"') /* do nothing */;
- return type + 1;
- }
-
- /* The following are one character type codes */
- case _C_CLASS:
- case _C_SEL:
- case _C_CHR:
- case _C_UCHR:
- case _C_CHARPTR:
- case _C_ATOM:
- case _C_SHT:
- case _C_USHT:
- case _C_INT:
- case _C_UINT:
- case _C_LNG:
- case _C_ULNG:
- case _C_FLT:
- case _C_DBL:
- case _C_VOID:
- case _C_UNDEF:
- return ++type;
- break;
-
- case _C_ARY_B:
- /* skip digits, typespec and closing ']' */
-
- while(isdigit(*++type));
- type = objc_skip_typespec(type);
- if (*type == _C_ARY_E)
- return ++type;
- else
- {
- objc_error(nil, OBJC_ERR_BAD_TYPE, "bad array type %s\n", type);
- return 0;
- }
-
- case _C_STRUCT_B:
- /* skip name, and elements until closing '}' */
-
- while (*type != _C_STRUCT_E && *type++ != '=');
- while (*type != _C_STRUCT_E) { type = objc_skip_typespec (type); }
- return ++type;
-
- case _C_UNION_B:
- /* skip name, and elements until closing ')' */
-
- while (*type != _C_UNION_E && *type++ != '=');
- while (*type != _C_UNION_E) { type = objc_skip_typespec (type); }
- return ++type;
-
- case _C_PTR:
- /* Just skip the following typespec */
-
- return objc_skip_typespec (++type);
-
- default:
- {
- objc_error(nil, OBJC_ERR_BAD_TYPE, "unknown type %s\n", type);
- return 0;
- }
- }
-}
-
-/*
- Skip an offset as part of a method encoding. This is prepended by a
- '+' if the argument is passed in registers.
-*/
-inline const char*
-objc_skip_offset (const char* type)
-{
- if (*type == '+') type++;
- while(isdigit(*++type));
- return type;
-}
-
-/*
- Skip an argument specification of a method encoding.
-*/
-const char*
-objc_skip_argspec (const char* type)
-{
- type = objc_skip_typespec (type);
- type = objc_skip_offset (type);
- return type;
-}
-
-/*
- Return the number of arguments that the method MTH expects.
- Note that all methods need two implicit arguments `self' and
- `_cmd'.
-*/
-int
-method_get_number_of_arguments (struct objc_method* mth)
-{
- int i = 0;
- const char* type = mth->method_types;
- while (*type)
- {
- type = objc_skip_argspec (type);
- i += 1;
- }
- return i - 1;
-}
-
-/*
- Return the size of the argument block needed on the stack to invoke
- the method MTH. This may be zero, if all arguments are passed in
- registers.
-*/
-
-int
-method_get_sizeof_arguments (struct objc_method* mth)
-{
- const char* type = objc_skip_typespec (mth->method_types);
- return atoi (type);
-}
-
-/*
- Return a pointer to the next argument of ARGFRAME. type points to
- the last argument. Typical use of this look like:
-
- {
- char *datum, *type;
- for (datum = method_get_first_argument (method, argframe, &type);
- datum; datum = method_get_next_argument (argframe, &type))
- {
- unsigned flags = objc_get_type_qualifiers (type);
- type = objc_skip_type_qualifiers (type);
- if (*type != _C_PTR)
- [portal encodeData: datum ofType: type];
- else
- {
- if ((flags & _F_IN) == _F_IN)
- [portal encodeData: *(char**)datum ofType: ++type];
- }
- }
- }
-*/
-
-char*
-method_get_next_argument (arglist_t argframe,
- const char **type)
-{
- const char *t = objc_skip_argspec (*type);
-
- if (*t == '\0')
- return 0;
-
- *type = t;
- t = objc_skip_typespec (t);
-
- if (*t == '+')
- return argframe->arg_regs + atoi (++t);
- else
- return argframe->arg_ptr + atoi (t);
-}
-
-/*
- Return a pointer to the value of the first argument of the method
- described in M with the given argumentframe ARGFRAME. The type
- is returned in TYPE. type must be passed to successive calls of
- method_get_next_argument.
-*/
-char*
-method_get_first_argument (struct objc_method* m,
- arglist_t argframe,
- const char** type)
-{
- *type = m->method_types;
- return method_get_next_argument (argframe, type);
-}
-
-/*
- Return a pointer to the ARGth argument of the method
- M from the frame ARGFRAME. The type of the argument
- is returned in the value-result argument TYPE
-*/
-
-char*
-method_get_nth_argument (struct objc_method* m,
- arglist_t argframe, int arg,
- const char **type)
-{
- const char* t = objc_skip_argspec (m->method_types);
-
- if (arg > method_get_number_of_arguments (m))
- return 0;
-
- while (arg--)
- t = objc_skip_argspec (t);
-
- *type = t;
- t = objc_skip_typespec (t);
-
- if (*t == '+')
- return argframe->arg_regs + atoi (++t);
- else
- return argframe->arg_ptr + atoi (t);
-}
-
-unsigned
-objc_get_type_qualifiers (const char* type)
-{
- unsigned res = 0;
- BOOL flag = YES;
-
- while (flag)
- switch (*type++)
- {
- case _C_CONST: res |= _F_CONST; break;
- case _C_IN: res |= _F_IN; break;
- case _C_INOUT: res |= _F_INOUT; break;
- case _C_OUT: res |= _F_OUT; break;
- case _C_BYCOPY: res |= _F_BYCOPY; break;
- case _C_ONEWAY: res |= _F_ONEWAY; break;
- default: flag = NO;
- }
-
- return res;
-}
diff --git a/contrib/gcc/objc/hash.c b/contrib/gcc/objc/hash.c
deleted file mode 100644
index 7534330fa1c7..000000000000
--- a/contrib/gcc/objc/hash.c
+++ /dev/null
@@ -1,283 +0,0 @@
-/* Hash tables for Objective C internal structures
- Copyright (C) 1993, 1996, 1997 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-/* As a special exception, if you link this library with files
- compiled with GCC to produce an executable, this does not cause
- the resulting executable to be covered by the GNU General Public License.
- This exception does not however invalidate any other reasons why
- the executable file might be covered by the GNU General Public License. */
-
-#include "assert.h"
-
-#include "objc/hash.h"
-
-#include "runtime.h" /* for DEBUG_PRINTF */
-
-/* These two macros determine when a hash table is full and
- by how much it should be expanded respectively.
-
- These equations are percentages. */
-#define FULLNESS(cache) \
- ((((cache)->size * 75) / 100) <= (cache)->used)
-#define EXPANSION(cache) \
- ((cache)->size * 2)
-
-cache_ptr
-hash_new (unsigned int size, hash_func_type hash_func,
- compare_func_type compare_func)
-{
- cache_ptr cache;
-
- /* Pass me a value greater than 0 and a power of 2. */
- assert (size);
- assert (!(size & (size - 1)));
-
- /* Allocate the cache structure. calloc insures
- its initialization for default values. */
- cache = (cache_ptr) objc_calloc (1, sizeof (struct cache));
- assert (cache);
-
- /* Allocate the array of buckets for the cache.
- calloc initializes all of the pointers to NULL. */
- cache->node_table
- = (node_ptr *) objc_calloc (size, sizeof (node_ptr));
- assert (cache->node_table);
-
- cache->size = size;
-
- /* This should work for all processor architectures? */
- cache->mask = (size - 1);
-
- /* Store the hashing function so that codes can be computed. */
- cache->hash_func = hash_func;
-
- /* Store the function that compares hash keys to
- determine if they are equal. */
- cache->compare_func = compare_func;
-
- return cache;
-}
-
-
-void
-hash_delete (cache_ptr cache)
-{
- node_ptr node;
- node_ptr next_node;
- unsigned int i;
-
- /* Purge all key/value pairs from the table. */
- /* Step through the nodes one by one and remove every node WITHOUT
- using hash_next. this makes hash_delete much more efficient. */
- for (i = 0;i < cache->size;i++) {
- if ((node = cache->node_table[i])) {
- /* an entry in the hash table has been found, now step through the
- nodes next in the list and free them. */
- while ((next_node = node->next)) {
- hash_remove (cache,node->key);
- node = next_node;
- }
-
- hash_remove (cache,node->key);
- }
- }
-
- /* Release the array of nodes and the cache itself. */
- objc_free(cache->node_table);
- objc_free(cache);
-}
-
-
-void
-hash_add (cache_ptr *cachep, const void *key, void *value)
-{
- size_t indx = (*(*cachep)->hash_func)(*cachep, key);
- node_ptr node = (node_ptr) objc_calloc (1, sizeof (struct cache_node));
-
-
- assert (node);
-
- /* Initialize the new node. */
- node->key = key;
- node->value = value;
- node->next = (*cachep)->node_table[indx];
-
- /* Debugging.
- Check the list for another key. */
-#ifdef DEBUG
- { node_ptr node1 = (*cachep)->node_table[indx];
-
- while (node1) {
-
- assert (node1->key != key);
- node1 = node1->next;
- }
- }
-#endif
-
- /* Install the node as the first element on the list. */
- (*cachep)->node_table[indx] = node;
-
- /* Bump the number of entries in the cache. */
- ++(*cachep)->used;
-
- /* Check the hash table's fullness. We're going
- to expand if it is above the fullness level. */
- if (FULLNESS (*cachep)) {
-
- /* The hash table has reached its fullness level. Time to
- expand it.
-
- I'm using a slow method here but is built on other
- primitive functions thereby increasing its
- correctness. */
- node_ptr node1 = NULL;
- cache_ptr new = hash_new (EXPANSION (*cachep),
- (*cachep)->hash_func,
- (*cachep)->compare_func);
-
- DEBUG_PRINTF ("Expanding cache %#x from %d to %d\n",
- *cachep, (*cachep)->size, new->size);
-
- /* Copy the nodes from the first hash table to the new one. */
- while ((node1 = hash_next (*cachep, node1)))
- hash_add (&new, node1->key, node1->value);
-
- /* Trash the old cache. */
- hash_delete (*cachep);
-
- /* Return a pointer to the new hash table. */
- *cachep = new;
- }
-}
-
-
-void
-hash_remove (cache_ptr cache, const void *key)
-{
- size_t indx = (*cache->hash_func)(cache, key);
- node_ptr node = cache->node_table[indx];
-
-
- /* We assume there is an entry in the table. Error if it is not. */
- assert (node);
-
- /* Special case. First element is the key/value pair to be removed. */
- if ((*cache->compare_func)(node->key, key)) {
- cache->node_table[indx] = node->next;
- objc_free(node);
- } else {
-
- /* Otherwise, find the hash entry. */
- node_ptr prev = node;
- BOOL removed = NO;
-
- do {
-
- if ((*cache->compare_func)(node->key, key)) {
- prev->next = node->next, removed = YES;
- objc_free(node);
- } else
- prev = node, node = node->next;
- } while (!removed && node);
- assert (removed);
- }
-
- /* Decrement the number of entries in the hash table. */
- --cache->used;
-}
-
-
-node_ptr
-hash_next (cache_ptr cache, node_ptr node)
-{
- /* If the scan is being started then reset the last node
- visitied pointer and bucket index. */
- if (!node)
- cache->last_bucket = 0;
-
- /* If there is a node visited last then check for another
- entry in the same bucket; Otherwise step to the next bucket. */
- if (node) {
- if (node->next)
- /* There is a node which follows the last node
- returned. Step to that node and retun it. */
- return node->next;
- else
- ++cache->last_bucket;
- }
-
- /* If the list isn't exhausted then search the buckets for
- other nodes. */
- if (cache->last_bucket < cache->size) {
- /* Scan the remainder of the buckets looking for an entry
- at the head of the list. Return the first item found. */
- while (cache->last_bucket < cache->size)
- if (cache->node_table[cache->last_bucket])
- return cache->node_table[cache->last_bucket];
- else
- ++cache->last_bucket;
-
- /* No further nodes were found in the hash table. */
- return NULL;
- } else
- return NULL;
-}
-
-
-/* Given KEY, return corresponding value for it in CACHE.
- Return NULL if the KEY is not recorded. */
-
-void *
-hash_value_for_key (cache_ptr cache, const void *key)
-{
- node_ptr node = cache->node_table[(*cache->hash_func)(cache, key)];
- void *retval = NULL;
-
- if (node)
- do {
- if ((*cache->compare_func)(node->key, key)) {
- retval = node->value;
- break;
- } else
- node = node->next;
- } while (!retval && node);
-
- return retval;
-}
-
-/* Given KEY, return YES if it exists in the CACHE.
- Return NO if it does not */
-
-BOOL
-hash_is_key_in_hash (cache_ptr cache, const void *key)
-{
- node_ptr node = cache->node_table[(*cache->hash_func)(cache, key)];
-
- if (node)
- do {
- if ((*cache->compare_func)(node->key, key))
- return YES;
- else
- node = node->next;
- } while (node);
-
- return NO;
-}
diff --git a/contrib/gcc/objc/hash.h b/contrib/gcc/objc/hash.h
deleted file mode 100644
index bddb791c820c..000000000000
--- a/contrib/gcc/objc/hash.h
+++ /dev/null
@@ -1,206 +0,0 @@
-/* Hash tables for Objective C method dispatch.
- Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-/* As a special exception, if you link this library with files
- compiled with GCC to produce an executable, this does not cause
- the resulting executable to be covered by the GNU General Public License.
- This exception does not however invalidate any other reasons why
- the executable file might be covered by the GNU General Public License. */
-
-
-#ifndef __hash_INCLUDE_GNU
-#define __hash_INCLUDE_GNU
-
-#include <stddef.h>
-#include <objc/objc.h>
-
-/*
- * This data structure is used to hold items
- * stored in a hash table. Each node holds
- * a key/value pair.
- *
- * Items in the cache are really of type void *.
- */
-typedef struct cache_node
-{
- struct cache_node *next; /* Pointer to next entry on the list.
- NULL indicates end of list. */
- const void *key; /* Key used to locate the value. Used
- to locate value when more than one
- key computes the same hash
- value. */
- void *value; /* Value stored for the key. */
-} *node_ptr;
-
-
-/*
- * This data type is the function that computes a hash code given a key.
- * Therefore, the key can be a pointer to anything and the function specific
- * to the key type.
- *
- * Unfortunately there is a mutual data structure reference problem with this
- * typedef. Therefore, to remove compiler warnings the functions passed to
- * hash_new will have to be casted to this type.
- */
-typedef unsigned int (*hash_func_type)(void *, const void *);
-
-/*
- * This data type is the function that compares two hash keys and returns an
- * integer greater than, equal to, or less than 0, according as the first
- * parameter is lexicographically greater than, equal to, or less than the
- * second.
- */
-
-typedef int (*compare_func_type)(const void *, const void *);
-
-
-/*
- * This data structure is the cache.
- *
- * It must be passed to all of the hashing routines
- * (except for new).
- */
-typedef struct cache
-{
- /* Variables used to implement the hash itself. */
- node_ptr *node_table; /* Pointer to an array of hash nodes. */
- /* Variables used to track the size of the hash table so to determine
- when to resize it. */
- unsigned int size; /* Number of buckets allocated for the hash table
- (number of array entries allocated for
- "node_table"). Must be a power of two. */
- unsigned int used; /* Current number of entries in the hash table. */
- unsigned int mask; /* Precomputed mask. */
-
- /* Variables used to implement indexing through the hash table. */
-
- unsigned int last_bucket; /* Tracks which entry in the array where
- the last value was returned. */
- /* Function used to compute a hash code given a key.
- This function is specified when the hash table is created. */
- hash_func_type hash_func;
- /* Function used to compare two hash keys to see if they are equal. */
- compare_func_type compare_func;
-} *cache_ptr;
-
-
-/* Two important hash tables. */
-extern cache_ptr module_hash_table, class_hash_table;
-
-/* Allocate and initialize a hash table. */
-
-cache_ptr hash_new (unsigned int size,
- hash_func_type hash_func,
- compare_func_type compare_func);
-
-/* Deallocate all of the hash nodes and the cache itself. */
-
-void hash_delete (cache_ptr cache);
-
-/* Add the key/value pair to the hash table. If the
- hash table reaches a level of fullness then it will be resized.
-
- assert if the key is already in the hash. */
-
-void hash_add (cache_ptr *cachep, const void *key, void *value);
-
-/* Remove the key/value pair from the hash table.
- assert if the key isn't in the table. */
-
-void hash_remove (cache_ptr cache, const void *key);
-
-/* Used to index through the hash table. Start with NULL
- to get the first entry.
-
- Successive calls pass the value returned previously.
- ** Don't modify the hash during this operation ***
-
- Cache nodes are returned such that key or value can
- be extracted. */
-
-node_ptr hash_next (cache_ptr cache, node_ptr node);
-
-/* Used to return a value from a hash table using a given key. */
-
-void *hash_value_for_key (cache_ptr cache, const void *key);
-
-/* Used to determine if the given key exists in the hash table */
-
-BOOL hash_is_key_in_hash (cache_ptr cache, const void *key);
-
-/************************************************
-
- Useful hashing functions.
-
- Declared inline for your pleasure.
-
-************************************************/
-
-/* Calculate a hash code by performing some
- manipulation of the key pointer. (Use the lowest bits
- except for those likely to be 0 due to alignment.) */
-
-static inline unsigned int
-hash_ptr (cache_ptr cache, const void *key)
-{
- return ((size_t)key / sizeof (void *)) & cache->mask;
-}
-
-
-/* Calculate a hash code by iterating over a NULL
- terminate string. */
-static inline unsigned int
-hash_string (cache_ptr cache, const void *key)
-{
- unsigned int ret = 0;
- unsigned int ctr = 0;
-
-
- while (*(char*)key) {
- ret ^= *(char*)key++ << ctr;
- ctr = (ctr + 1) % sizeof (void *);
- }
-
- return ret & cache->mask;
-}
-
-
-/* Compare two pointers for equality. */
-static inline int
-compare_ptrs (const void *k1, const void *k2)
-{
- return !(k1 - k2);
-}
-
-
-/* Compare two strings. */
-static inline int
-compare_strings (const void *k1, const void *k2)
-{
- if (k1 == k2)
- return 1;
- else if (k1 == 0 || k2 == 0)
- return 0;
- else
- return !strcmp (k1, k2);
-}
-
-
-#endif /* not __hash_INCLUDE_GNU */
diff --git a/contrib/gcc/objc/init.c b/contrib/gcc/objc/init.c
deleted file mode 100644
index f1fea8123186..000000000000
--- a/contrib/gcc/objc/init.c
+++ /dev/null
@@ -1,834 +0,0 @@
-/* GNU Objective C Runtime initialization
- Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
- Contributed by Kresten Krab Thorup
- +load support contributed by Ovidiu Predescu <ovidiu@net-community.com>
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the Free Software
-Foundation; either version 2, or (at your option) any later version.
-
-GNU CC is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
-details.
-
-You should have received a copy of the GNU General Public License along with
-GNU CC; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* As a special exception, if you link this library with files compiled with
- GCC to produce an executable, this does not cause the resulting executable
- to be covered by the GNU General Public License. This exception does not
- however invalidate any other reasons why the executable file might be
- covered by the GNU General Public License. */
-
-#include "runtime.h"
-
-/* The version number of this runtime. This must match the number
- defined in gcc (objc-act.c) */
-#define OBJC_VERSION 8
-#define PROTOCOL_VERSION 2
-
-/* This list contains all modules currently loaded into the runtime */
-static struct objc_list* __objc_module_list = 0; /* !T:MUTEX */
-
-/* This list contains all proto_list's not yet assigned class links */
-static struct objc_list* unclaimed_proto_list = 0; /* !T:MUTEX */
-
-/* List of unresolved static instances. */
-static struct objc_list *uninitialized_statics = 0; /* !T:MUTEX */
-
-/* Global runtime "write" mutex. */
-objc_mutex_t __objc_runtime_mutex = 0;
-
-/* Number of threads that are alive. */
-int __objc_runtime_threads_alive = 1; /* !T:MUTEX */
-
-/* Check compiler vs runtime version */
-static void init_check_module_version (Module_t);
-
-/* Assign isa links to protos */
-static void __objc_init_protocols (struct objc_protocol_list* protos);
-
-/* Add protocol to class */
-static void __objc_class_add_protocols (Class, struct objc_protocol_list*);
-
-/* This is a hook which is called by __objc_exec_class every time a class
- or a category is loaded into the runtime. This may e.g. help a
- dynamic loader determine the classes that have been loaded when
- an object file is dynamically linked in */
-void (*_objc_load_callback)(Class class, Category* category); /* !T:SAFE */
-
-/* Is all categories/classes resolved? */
-BOOL __objc_dangling_categories = NO; /* !T:UNUSED */
-
-extern SEL
-__sel_register_typed_name (const char *name, const char *types,
- struct objc_selector *orig, BOOL is_const);
-
-/* Sends +load to all classes and categories in certain situations. */
-static void objc_send_load (void);
-
-/* Inserts all the classes defined in module in a tree of classes that
- resembles the class hierarchy. This tree is traversed in preorder and the
- classes in its nodes receive the +load message if these methods were not
- executed before. The algorithm ensures that when the +load method of a class
- is executed all the superclasses have been already received the +load
- message. */
-static void __objc_create_classes_tree (Module_t module);
-
-static void __objc_call_callback (Module_t module);
-
-/* A special version that works only before the classes are completely
- installed in the runtime. */
-static BOOL class_is_subclass_of_class (Class class, Class superclass);
-
-typedef struct objc_class_tree {
- Class class;
- struct objc_list *subclasses; /* `head' is pointer to an objc_class_tree */
-} objc_class_tree;
-
-/* This is a linked list of objc_class_tree trees. The head of these trees
- are root classes (their super class is Nil). These different trees
- represent different class hierarchies. */
-static struct objc_list *__objc_class_tree_list = NULL;
-
-/* Keeps the +load methods who have been already executed. This hash should
- not be destroyed during the execution of the program. */
-static cache_ptr __objc_load_methods = NULL;
-
-/* Creates a tree of classes whose topmost class is directly inherited from
- `upper' and the bottom class in this tree is `bottom_class'. The classes
- in this tree are super classes of `bottom_class'. `subclasses' member
- of each tree node point to the next subclass tree node. */
-static objc_class_tree *
-create_tree_of_subclasses_inherited_from (Class bottom_class, Class upper)
-{
- Class superclass = bottom_class->super_class ?
- objc_lookup_class ((char*)bottom_class->super_class)
- : Nil;
-
- objc_class_tree *tree, *prev;
-
- DEBUG_PRINTF ("create_tree_of_subclasses_inherited_from:");
- DEBUG_PRINTF ("bottom_class = %s, upper = %s\n",
- (bottom_class ? bottom_class->name : NULL),
- (upper ? upper->name : NULL));
-
- tree = prev = objc_calloc (1, sizeof (objc_class_tree));
- prev->class = bottom_class;
-
- while (superclass != upper)
- {
- tree = objc_calloc (1, sizeof (objc_class_tree));
- tree->class = superclass;
- tree->subclasses = list_cons (prev, tree->subclasses);
- superclass = (superclass->super_class ?
- objc_lookup_class ((char*)superclass->super_class)
- : Nil);
- prev = tree;
- }
-
- return tree;
-}
-
-/* Insert the `class' into the proper place in the `tree' class hierarchy. This
- function returns a new tree if the class has been successfully inserted into
- the tree or NULL if the class is not part of the classes hierarchy described
- by `tree'. This function is private to objc_tree_insert_class(), you should
- not call it directly. */
-static objc_class_tree *
-__objc_tree_insert_class (objc_class_tree *tree, Class class)
-{
- DEBUG_PRINTF ("__objc_tree_insert_class: tree = %x, class = %s\n",
- tree, class->name);
-
- if (tree == NULL)
- return create_tree_of_subclasses_inherited_from (class, NULL);
- else if (class == tree->class)
- {
- /* `class' has been already inserted */
- DEBUG_PRINTF ("1. class %s was previously inserted\n", class->name);
- return tree;
- }
- else if ((class->super_class ?
- objc_lookup_class ((char*)class->super_class)
- : Nil)
- == tree->class)
- {
- /* If class is a direct subclass of tree->class then add class to the
- list of subclasses. First check to see if it wasn't already
- inserted. */
- struct objc_list *list = tree->subclasses;
- objc_class_tree *node;
-
- while (list)
- {
- /* Class has been already inserted; do nothing just return
- the tree. */
- if (((objc_class_tree*)list->head)->class == class)
- {
- DEBUG_PRINTF ("2. class %s was previously inserted\n",
- class->name);
- return tree;
- }
- list = list->tail;
- }
-
- /* Create a new node class and insert it into the list of subclasses */
- node = objc_calloc (1, sizeof (objc_class_tree));
- node->class = class;
- tree->subclasses = list_cons (node, tree->subclasses);
- DEBUG_PRINTF ("3. class %s inserted\n", class->name);
- return tree;
- }
- else
- {
- /* The class is not a direct subclass of tree->class. Search for class's
- superclasses in the list of subclasses. */
- struct objc_list *subclasses = tree->subclasses;
-
- /* Precondition: the class must be a subclass of tree->class; otherwise
- return NULL to indicate our caller that it must take the next tree. */
- if (!class_is_subclass_of_class (class, tree->class))
- return NULL;
-
- for (; subclasses != NULL; subclasses = subclasses->tail)
- {
- Class aClass = ((objc_class_tree*)(subclasses->head))->class;
-
- if (class_is_subclass_of_class (class, aClass))
- {
- /* If we found one of class's superclasses we insert the class
- into its subtree and return the original tree since nothing
- has been changed. */
- subclasses->head
- = __objc_tree_insert_class (subclasses->head, class);
- DEBUG_PRINTF ("4. class %s inserted\n", class->name);
- return tree;
- }
- }
-
- /* We haven't found a subclass of `class' in the `subclasses' list.
- Create a new tree of classes whose topmost class is a direct subclass
- of tree->class. */
- {
- objc_class_tree *new_tree
- = create_tree_of_subclasses_inherited_from (class, tree->class);
- tree->subclasses = list_cons (new_tree, tree->subclasses);
- DEBUG_PRINTF ("5. class %s inserted\n", class->name);
- return tree;
- }
- }
-}
-
-/* This function inserts `class' in the right tree hierarchy classes. */
-static void
-objc_tree_insert_class (Class class)
-{
- struct objc_list *list_node;
- objc_class_tree *tree;
-
- list_node = __objc_class_tree_list;
- while (list_node)
- {
- tree = __objc_tree_insert_class (list_node->head, class);
- if (tree)
- {
- list_node->head = tree;
- break;
- }
- else
- list_node = list_node->tail;
- }
-
- /* If the list was finished but the class hasn't been inserted, insert it
- here. */
- if (!list_node)
- {
- __objc_class_tree_list = list_cons (NULL, __objc_class_tree_list);
- __objc_class_tree_list->head = __objc_tree_insert_class (NULL, class);
- }
-}
-
-/* Traverse tree in preorder. Used to send +load. */
-static void
-objc_preorder_traverse (objc_class_tree *tree,
- int level,
- void (*function)(objc_class_tree*, int))
-{
- struct objc_list *node;
-
- (*function) (tree, level);
- for (node = tree->subclasses; node; node = node->tail)
- objc_preorder_traverse (node->head, level + 1, function);
-}
-
-/* Traverse tree in postorder. Used to destroy a tree. */
-static void
-objc_postorder_traverse (objc_class_tree *tree,
- int level,
- void (*function)(objc_class_tree*, int))
-{
- struct objc_list *node;
-
- for (node = tree->subclasses; node; node = node->tail)
- objc_postorder_traverse (node->head, level + 1, function);
- (*function) (tree, level);
-}
-
-/* Used to print a tree class hierarchy. */
-#ifdef DEBUG
-static void
-__objc_tree_print (objc_class_tree *tree, int level)
-{
- int i;
-
- for (i = 0; i < level; i++)
- printf (" ");
- printf ("%s\n", tree->class->name);
-}
-#endif
-
-/* Walks on a linked list of methods in the reverse order and executes all
- the methods corresponding to `op' selector. Walking in the reverse order
- assures the +load of class is executed first and then +load of categories
- because of the way in which categories are added to the class methods. */
-static void
-__objc_send_message_in_list (MethodList_t method_list, Class class, SEL op)
-{
- int i;
-
- if (!method_list)
- return;
-
- /* First execute the `op' message in the following method lists */
- __objc_send_message_in_list (method_list->method_next, class, op);
-
- /* Search the method list. */
- for (i = 0; i < method_list->method_count; i++)
- {
- Method_t mth = &method_list->method_list[i];
-
- if (mth->method_name && sel_eq (mth->method_name, op)
- && !hash_is_key_in_hash (__objc_load_methods, mth->method_name))
- {
- /* The method was found and wasn't previously executed. */
- (*mth->method_imp) ((id)class, mth->method_name);
-
- /* Add this method into the +load hash table */
- hash_add (&__objc_load_methods, mth->method_imp, mth->method_imp);
-
- DEBUG_PRINTF ("sending +load in class: %s\n", class->name);
-
- break;
- }
- }
-}
-
-static void
-__objc_send_load (objc_class_tree *tree, int level)
-{
- static SEL load_sel = 0;
- Class class = tree->class;
- MethodList_t method_list = class->class_pointer->methods;
-
- if (!load_sel)
- load_sel = sel_register_name ("load");
-
- __objc_send_message_in_list (method_list, class, load_sel);
-}
-
-static void
-__objc_destroy_class_tree_node (objc_class_tree *tree, int level)
-{
- objc_free (tree);
-}
-
-/* This is used to check if the relationship between two classes before the
- runtime completely installs the classes. */
-static BOOL
-class_is_subclass_of_class (Class class, Class superclass)
-{
- for (; class != Nil;)
- {
- if (class == superclass)
- return YES;
- class = (class->super_class ?
- objc_lookup_class ((char*)class->super_class)
- : Nil);
- }
-
- return NO;
-}
-
-/* This list contains all the classes in the runtime system for whom their
- superclasses are not yet know to the runtime. */
-static struct objc_list* unresolved_classes = 0;
-
-/* Static function used to reference the Object and NXConstantString classes.
- */
-static void
-__objc_force_linking (void)
-{
- extern void __objc_linking (void);
- __objc_linking ();
-
- /* Call the function to avoid compiler warning */
- __objc_force_linking ();
-}
-
-/* Run through the statics list, removing modules as soon as all its statics
- have been initialized. */
-static void
-objc_init_statics (void)
-{
- struct objc_list **cell = &uninitialized_statics;
- struct objc_static_instances **statics_in_module;
-
- objc_mutex_lock(__objc_runtime_mutex);
-
- while (*cell)
- {
- int module_initialized = 1;
-
- for (statics_in_module = (*cell)->head;
- *statics_in_module; statics_in_module++)
- {
- struct objc_static_instances *statics = *statics_in_module;
- Class class = objc_lookup_class (statics->class_name);
-
- if (!class)
- module_initialized = 0;
- /* Actually, the static's class_pointer will be NULL when we
- haven't been here before. However, the comparison is to be
- reminded of taking into account class posing and to think about
- possible semantics... */
- else if (class != statics->instances[0]->class_pointer)
- {
- id *inst;
-
- for (inst = &statics->instances[0]; *inst; inst++)
- {
- (*inst)->class_pointer = class;
-
- /* ??? Make sure the object will not be freed. With
- refcounting, invoke `-retain'. Without refcounting, do
- nothing and hope that `-free' will never be invoked. */
-
- /* ??? Send the object an `-initStatic' or something to
- that effect now or later on? What are the semantics of
- statically allocated instances, besides the trivial
- NXConstantString, anyway? */
- }
- }
- }
- if (module_initialized)
- {
- /* Remove this module from the uninitialized list. */
- struct objc_list *this = *cell;
- *cell = this->tail;
- objc_free(this);
- }
- else
- cell = &(*cell)->tail;
- }
-
- objc_mutex_unlock(__objc_runtime_mutex);
-} /* objc_init_statics */
-
-/* This function is called by constructor functions generated for each
- module compiled. (_GLOBAL_$I$...) The purpose of this function is to
- gather the module pointers so that they may be processed by the
- initialization routines as soon as possible */
-
-void
-__objc_exec_class (Module_t module)
-{
- /* Have we processed any constructors previously? This flag is used to
- indicate that some global data structures need to be built. */
- static BOOL previous_constructors = 0;
-
- static struct objc_list* unclaimed_categories = 0;
-
- /* The symbol table (defined in objc-api.h) generated by gcc */
- Symtab_t symtab = module->symtab;
-
- /* The statics in this module */
- struct objc_static_instances **statics
- = symtab->defs[symtab->cls_def_cnt + symtab->cat_def_cnt];
-
- /* Entry used to traverse hash lists */
- struct objc_list** cell;
-
- /* The table of selector references for this module */
- SEL selectors = symtab->refs;
-
- /* dummy counter */
- int i;
-
- DEBUG_PRINTF ("received module: %s\n", module->name);
-
- /* check gcc version */
- init_check_module_version(module);
-
- /* On the first call of this routine, initialize some data structures. */
- if (!previous_constructors)
- {
- /* Initialize thread-safe system */
- __objc_init_thread_system();
- __objc_runtime_threads_alive = 1;
- __objc_runtime_mutex = objc_mutex_allocate();
-
- __objc_init_selector_tables();
- __objc_init_class_tables();
- __objc_init_dispatch_tables();
- __objc_class_tree_list = list_cons (NULL, __objc_class_tree_list);
- __objc_load_methods
- = hash_new (128, (hash_func_type)hash_ptr, compare_ptrs);
- previous_constructors = 1;
- }
-
- /* Save the module pointer for later processing. (not currently used) */
- objc_mutex_lock(__objc_runtime_mutex);
- __objc_module_list = list_cons(module, __objc_module_list);
-
- /* Replace referenced selectors from names to SEL's. */
- if (selectors)
- {
- for (i = 0; selectors[i].sel_id; ++i)
- {
- const char *name, *type;
- name = (char*)selectors[i].sel_id;
- type = (char*)selectors[i].sel_types;
- /* Constructors are constant static data so we can safely store
- pointers to them in the runtime structures. is_const == YES */
- __sel_register_typed_name (name, type,
- (struct objc_selector*)&(selectors[i]),
- YES);
- }
- }
-
- /* Parse the classes in the load module and gather selector information. */
- DEBUG_PRINTF ("gathering selectors from module: %s\n", module->name);
- for (i = 0; i < symtab->cls_def_cnt; ++i)
- {
- Class class = (Class) symtab->defs[i];
- const char* superclass = (char*)class->super_class;
-
- /* Make sure we have what we think. */
- assert (CLS_ISCLASS(class));
- assert (CLS_ISMETA(class->class_pointer));
- DEBUG_PRINTF ("phase 1, processing class: %s\n", class->name);
-
- /* Initialize the subclass list to be NULL.
- In some cases it isn't and this crashes the program. */
- class->subclass_list = NULL;
-
- /* Store the class in the class table and assign class numbers. */
- __objc_add_class_to_hash (class);
-
- /* Register all of the selectors in the class and meta class. */
- __objc_register_selectors_from_class (class);
- __objc_register_selectors_from_class ((Class) class->class_pointer);
-
- /* Install the fake dispatch tables */
- __objc_install_premature_dtable(class);
- __objc_install_premature_dtable(class->class_pointer);
-
- /* Register the instance methods as class methods, this is
- only done for root classes. */
- __objc_register_instance_methods_to_class(class);
-
- if (class->protocols)
- __objc_init_protocols (class->protocols);
-
- /* Check to see if the superclass is known in this point. If it's not
- add the class to the unresolved_classes list. */
- if (superclass && !objc_lookup_class (superclass))
- unresolved_classes = list_cons (class, unresolved_classes);
- }
-
- /* Process category information from the module. */
- for (i = 0; i < symtab->cat_def_cnt; ++i)
- {
- Category_t category = symtab->defs[i + symtab->cls_def_cnt];
- Class class = objc_lookup_class (category->class_name);
-
- /* If the class for the category exists then append its methods. */
- if (class)
- {
-
- DEBUG_PRINTF ("processing categories from (module,object): %s, %s\n",
- module->name,
- class->name);
-
- /* Do instance methods. */
- if (category->instance_methods)
- class_add_method_list (class, category->instance_methods);
-
- /* Do class methods. */
- if (category->class_methods)
- class_add_method_list ((Class) class->class_pointer,
- category->class_methods);
-
- if (category->protocols)
- {
- __objc_init_protocols (category->protocols);
- __objc_class_add_protocols (class, category->protocols);
- }
-
- /* Register the instance methods as class methods, this is
- only done for root classes. */
- __objc_register_instance_methods_to_class(class);
- }
- else
- {
- /* The object to which the category methods belong can't be found.
- Save the information. */
- unclaimed_categories = list_cons(category, unclaimed_categories);
- }
- }
-
- if (statics)
- uninitialized_statics = list_cons (statics, uninitialized_statics);
- if (uninitialized_statics)
- objc_init_statics ();
-
- /* Scan the unclaimed category hash. Attempt to attach any unclaimed
- categories to objects. */
- for (cell = &unclaimed_categories;
- *cell;
- ({ if (*cell) cell = &(*cell)->tail; }))
- {
- Category_t category = (*cell)->head;
- Class class = objc_lookup_class (category->class_name);
-
- if (class)
- {
- DEBUG_PRINTF ("attaching stored categories to object: %s\n",
- class->name);
-
- list_remove_head (cell);
-
- if (category->instance_methods)
- class_add_method_list (class, category->instance_methods);
-
- if (category->class_methods)
- class_add_method_list ((Class) class->class_pointer,
- category->class_methods);
-
- if (category->protocols)
- {
- __objc_init_protocols (category->protocols);
- __objc_class_add_protocols (class, category->protocols);
- }
-
- /* Register the instance methods as class methods, this is
- only done for root classes. */
- __objc_register_instance_methods_to_class(class);
- }
- }
-
- if (unclaimed_proto_list && objc_lookup_class ("Protocol"))
- {
- list_mapcar (unclaimed_proto_list,(void(*)(void*))__objc_init_protocols);
- list_free (unclaimed_proto_list);
- unclaimed_proto_list = 0;
- }
-
- objc_send_load ();
-
- objc_mutex_unlock(__objc_runtime_mutex);
-}
-
-static void objc_send_load (void)
-{
- if (!__objc_module_list)
- return;
-
- /* Try to find out if all the classes loaded so far also have their
- superclasses known to the runtime. We suppose that the objects that are
- allocated in the +load method are in general of a class declared in the
- same module. */
- if (unresolved_classes)
- {
- Class class = unresolved_classes->head;
-
- while (objc_lookup_class ((char*)class->super_class))
- {
- list_remove_head (&unresolved_classes);
- if (unresolved_classes)
- class = unresolved_classes->head;
- else
- break;
- }
-
- /*
- * If we still have classes for whom we don't have yet their super
- * classes known to the runtime we don't send the +load messages.
- */
- if (unresolved_classes)
- return;
- }
-
- /* Special check to allow creating and sending messages to constant strings
- in +load methods. If these classes are not yet known, even if all the
- other classes are known, delay sending of +load. */
- if (!objc_lookup_class ("NXConstantString") ||
- !objc_lookup_class ("Object"))
- return;
-
- /* Iterate over all modules in the __objc_module_list and call on them the
- __objc_create_classes_tree function. This function creates a tree of
- classes that resembles the class hierarchy. */
- list_mapcar (__objc_module_list, (void(*)(void*))__objc_create_classes_tree);
-
- while (__objc_class_tree_list)
- {
-#ifdef DEBUG
- objc_preorder_traverse (__objc_class_tree_list->head,
- 0, __objc_tree_print);
-#endif
- objc_preorder_traverse (__objc_class_tree_list->head,
- 0, __objc_send_load);
- objc_postorder_traverse (__objc_class_tree_list->head,
- 0, __objc_destroy_class_tree_node);
- list_remove_head (&__objc_class_tree_list);
- }
-
- list_mapcar (__objc_module_list, (void(*)(void*))__objc_call_callback);
- list_free (__objc_module_list);
- __objc_module_list = NULL;
-}
-
-static void
-__objc_create_classes_tree (Module_t module)
-{
- /* The runtime mutex is locked in this point */
-
- Symtab_t symtab = module->symtab;
- int i;
-
- /* Iterate thru classes defined in this module and insert them in the classes
- tree hierarchy. */
- for (i = 0; i < symtab->cls_def_cnt; i++)
- {
- Class class = (Class) symtab->defs[i];
-
- objc_tree_insert_class (class);
- }
-}
-
-static void
-__objc_call_callback (Module_t module)
-{
- /* The runtime mutex is locked in this point */
-
- Symtab_t symtab = module->symtab;
- int i;
-
- /* Iterate thru classes defined in this module and call the callback for
- each one. */
- for (i = 0; i < symtab->cls_def_cnt; i++)
- {
- Class class = (Class) symtab->defs[i];
-
- /* Call the _objc_load_callback for this class. */
- if (_objc_load_callback)
- _objc_load_callback(class, 0);
- }
-
- /* Call the _objc_load_callback for categories. Don't register the instance
- methods as class methods for categories to root classes since they were
- already added in the class. */
- for (i = 0; i < symtab->cat_def_cnt; i++)
- {
- Category_t category = symtab->defs[i + symtab->cls_def_cnt];
- Class class = objc_lookup_class (category->class_name);
-
- if (_objc_load_callback)
- _objc_load_callback(class, category);
- }
-}
-
-/* Sanity check the version of gcc used to compile `module'*/
-static void init_check_module_version(Module_t module)
-{
- if ((module->version != OBJC_VERSION) || (module->size != sizeof (Module)))
- {
- int code;
-
- if(module->version > OBJC_VERSION)
- code = OBJC_ERR_OBJC_VERSION;
- else if (module->version < OBJC_VERSION)
- code = OBJC_ERR_GCC_VERSION;
- else
- code = OBJC_ERR_MODULE_SIZE;
-
- objc_error(nil, code, "Module %s version %d doesn't match runtime %d\n",
- module->name, (int)module->version, OBJC_VERSION);
- }
-}
-
-static void
-__objc_init_protocols (struct objc_protocol_list* protos)
-{
- int i;
- static Class proto_class = 0;
-
- if (! protos)
- return;
-
- objc_mutex_lock(__objc_runtime_mutex);
-
- if (!proto_class)
- proto_class = objc_lookup_class("Protocol");
-
- if (!proto_class)
- {
- unclaimed_proto_list = list_cons (protos, unclaimed_proto_list);
- objc_mutex_unlock(__objc_runtime_mutex);
- return;
- }
-
-#if 0
- assert (protos->next == 0); /* only single ones allowed */
-#endif
-
- for(i = 0; i < protos->count; i++)
- {
- struct objc_protocol* aProto = protos->list[i];
- if (((size_t)aProto->class_pointer) == PROTOCOL_VERSION)
- {
- /* assign class pointer */
- aProto->class_pointer = proto_class;
-
- /* init super protocols */
- __objc_init_protocols (aProto->protocol_list);
- }
- else if (protos->list[i]->class_pointer != proto_class)
- {
- objc_error(nil, OBJC_ERR_PROTOCOL_VERSION,
- "Version %d doesn't match runtime protocol version %d\n",
- (int)((char*)protos->list[i]->class_pointer-(char*)0),
- PROTOCOL_VERSION);
- }
- }
-
- objc_mutex_unlock(__objc_runtime_mutex);
-}
-
-static void __objc_class_add_protocols (Class class,
- struct objc_protocol_list* protos)
-{
- /* Well... */
- if (! protos)
- return;
-
- /* Add it... */
- protos->next = class->protocols;
- class->protocols = protos;
-}
diff --git a/contrib/gcc/objc/list.h b/contrib/gcc/objc/list.h
deleted file mode 100644
index a59b116d9673..000000000000
--- a/contrib/gcc/objc/list.h
+++ /dev/null
@@ -1,150 +0,0 @@
-/* Generic single linked list to keep various information
- Copyright (C) 1993, 1994 Free Software Foundation, Inc.
-
-Author: Kresten Krab Thorup
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-/* As a special exception, if you link this library with files compiled with
- GCC to produce an executable, this does not cause the resulting executable
- to be covered by the GNU General Public License. This exception does not
- however invalidate any other reasons why the executable file might be
- covered by the GNU General Public License. */
-
-#ifndef __GNU_OBJC_LIST_H
-#define __GNU_OBJC_LIST_H
-void * __objc_xrealloc (void *optr, size_t size);
-void * __objc_xmalloc (size_t size);
-
-struct objc_list {
- void *head;
- struct objc_list *tail;
-};
-
-/* Return a cons cell produced from (head . tail) */
-
-static inline struct objc_list*
-list_cons(void* head, struct objc_list* tail)
-{
- struct objc_list* cell;
-
- cell = (struct objc_list*)__objc_xmalloc(sizeof(struct objc_list));
- cell->head = head;
- cell->tail = tail;
- return cell;
-}
-
-/* Return the length of a list, list_length(NULL) returns zero */
-
-static inline int
-list_length(struct objc_list* list)
-{
- int i = 0;
- while(list)
- {
- i += 1;
- list = list->tail;
- }
- return i;
-}
-
-/* Return the Nth element of LIST, where N count from zero. If N
- larger than the list length, NULL is returned */
-
-static inline void*
-list_nth(int index, struct objc_list* list)
-{
- while(index-- != 0)
- {
- if(list->tail)
- list = list->tail;
- else
- return 0;
- }
- return list->head;
-}
-
-/* Remove the element at the head by replacing it by its successor */
-
-static inline void
-list_remove_head(struct objc_list** list)
-{
- if ((*list)->tail)
- {
- struct objc_list* tail = (*list)->tail; /* fetch next */
- *(*list) = *tail; /* copy next to list head */
- free(tail); /* free next */
- }
- else /* only one element in list */
- {
- free (*list);
- (*list) = 0;
- }
-}
-
-
-/* Remove the element with `car' set to ELEMENT */
-
-static inline void
-list_remove_elem(struct objc_list** list, void* elem)
-{
- while (*list) {
- if ((*list)->head == elem)
- list_remove_head(list);
- list = &((*list)->tail);
- }
-}
-
-/* Map FUNCTION over all elements in LIST */
-
-static inline void
-list_mapcar(struct objc_list* list, void(*function)(void*))
-{
- while(list)
- {
- (*function)(list->head);
- list = list->tail;
- }
-}
-
-/* Return element that has ELEM as car */
-
-static inline struct objc_list**
-list_find(struct objc_list** list, void* elem)
-{
- while(*list)
- {
- if ((*list)->head == elem)
- return list;
- list = &((*list)->tail);
- }
- return NULL;
-}
-
-/* Free list (backwards recursive) */
-
-static void
-list_free(struct objc_list* list)
-{
- if(list)
- {
- list_free(list->tail);
- free(list);
- }
-}
-#endif __GNU_OBJC_LIST_H
diff --git a/contrib/gcc/objc/makefile.dos b/contrib/gcc/objc/makefile.dos
deleted file mode 100644
index 3e1b1871e40e..000000000000
--- a/contrib/gcc/objc/makefile.dos
+++ /dev/null
@@ -1,56 +0,0 @@
-# GNU Objective C Runtime Makefile for compiling with djgpp
-# Copyright (C) 1993, 1994, 1996 Free Software Foundation, Inc.
-#
-# This file is part of GNU CC.
-#
-# GNU CC is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2, or (at your option) any later version.
-#
-# GNU CC is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
-# details.
-#
-# You should have received a copy of the GNU General Public License along with
-# GNU CC; see the file COPYING. If not, write to the Free Software
-# Foundation, 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-
-# This Makefile is configured for GnuMAKE
-
-GCC_FOR_TARGET=gcc
-
-.SUFFIXES: .o .m
-
-OPTIMIZE = -O2
-
-# Always search these dirs when compiling.
-SUBDIR_INCLUDES = -I. -I.. -I../config
-
-.c.o:
- $(GCC_FOR_TARGET) $(OPTIMIZE) \
- -c $(GCC_CFLAGS) $(SUBDIR_INCLUDES) $<
-
-.m.o:
- $(GCC_FOR_TARGET) $(OPTIMIZE) -fgnu-runtime \
- -c $(GCC_CFLAGS) $(SUBDIR_INCLUDES) $<
-
-OBJC_O = hash.o sarray.o class.o sendmsg.o init.o archive.o \
- selector.o objects.o misc.o object.o protocol.o encoding.o thread.o
-
-libobjc.a: $(OBJC_O)
- -rm -f libobjc.a
- ar rc libobjc.a $(OBJC_O)
- ranlib libobjc.a
-
-OBJC_H = hash.h objc-list.h sarray.h objc.h \
- objc-api.h \
- object.h protocol.h mutex.h \
- typedstream.h thread.h
-
-mostlyclean:
- -rm -f *.o libobjc.a xforward fflags
-clean: mostlyclean
-distclean: mostlyclean
-extraclean: mostlyclean
diff --git a/contrib/gcc/objc/misc.c b/contrib/gcc/objc/misc.c
deleted file mode 100644
index 01f9d3bbafa8..000000000000
--- a/contrib/gcc/objc/misc.c
+++ /dev/null
@@ -1,152 +0,0 @@
-/* GNU Objective C Runtime Miscellaneous
- Copyright (C) 1993, 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
- Contributed by Kresten Krab Thorup
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option) any
-later version.
-
-GNU CC is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-/* As a special exception, if you link this library with files compiled with
- GCC to produce an executable, this does not cause the resulting executable
- to be covered by the GNU General Public License. This exception does not
- however invalidate any other reasons why the executable file might be
- covered by the GNU General Public License. */
-
-#define __USE_FIXED_PROTOTYPES__
-#include <stdlib.h>
-#include "runtime.h"
-
-/*
-** Error handler function
-** NULL so that default is to just print to stderr
-*/
-static objc_error_handler _objc_error_handler = NULL;
-
-/* Trigger an objc error */
-void
-objc_error(id object, int code, const char* fmt, ...)
-{
- va_list ap;
-
- va_start(ap, fmt);
- objc_verror(object, code, fmt, ap);
- va_end(ap);
-}
-
-/* Trigger an objc error */
-void
-objc_verror(id object, int code, const char* fmt, va_list ap)
-{
- BOOL result = NO;
-
- /* Call the error handler if its there
- Otherwise print to stderr */
- if (_objc_error_handler)
- result = (*_objc_error_handler)(object, code, fmt, ap);
- else
- vfprintf (stderr, fmt, ap);
-
- /* Continue if the error handler says its ok
- Otherwise abort the program */
- if (result)
- return;
- else
- abort();
-}
-
-/* Set the error handler */
-objc_error_handler
-objc_set_error_handler(objc_error_handler func)
-{
- objc_error_handler temp = _objc_error_handler;
- _objc_error_handler = func;
- return temp;
-}
-
-/*
-** Standard functions for memory allocation and disposal.
-** Users should use these functions in their ObjC programs so
-** that they work properly with garbage collectors as well as
-** can take advantage of the exception/error handling available.
-*/
-
-void *
-objc_malloc(size_t size)
-{
- void* res = (void*) (*_objc_malloc)(size);
- if(!res)
- objc_error(nil, OBJC_ERR_MEMORY, "Virtual memory exhausted\n");
- return res;
-}
-
-void *
-objc_atomic_malloc(size_t size)
-{
- void* res = (void*) (*_objc_atomic_malloc)(size);
- if(!res)
- objc_error(nil, OBJC_ERR_MEMORY, "Virtual memory exhausted\n");
- return res;
-}
-
-void *
-objc_valloc(size_t size)
-{
- void* res = (void*) (*_objc_valloc)(size);
- if(!res)
- objc_error(nil, OBJC_ERR_MEMORY, "Virtual memory exhausted\n");
- return res;
-}
-
-void *
-objc_realloc(void *mem, size_t size)
-{
- void* res = (void*) (*_objc_realloc)(mem, size);
- if(!res)
- objc_error(nil, OBJC_ERR_MEMORY, "Virtual memory exhausted\n");
- return res;
-}
-
-void *
-objc_calloc(size_t nelem, size_t size)
-{
- void* res = (void*) (*_objc_calloc)(nelem, size);
- if(!res)
- objc_error(nil, OBJC_ERR_MEMORY, "Virtual memory exhausted\n");
- return res;
-}
-
-void
-objc_free(void *mem)
-{
- (*_objc_free)(mem);
-}
-
-/*
-** Hook functions for memory allocation and disposal.
-** This makes it easy to substitute garbage collection systems
-** such as Boehm's GC by assigning these function pointers
-** to the GC's allocation routines. By default these point
-** to the ANSI standard malloc, realloc, free, etc.
-**
-** Users should call the normal objc routines above for
-** memory allocation and disposal within their programs.
-*/
-void *(*_objc_malloc)(size_t) = malloc;
-void *(*_objc_atomic_malloc)(size_t) = malloc;
-void *(*_objc_valloc)(size_t) = malloc;
-void *(*_objc_realloc)(void *, size_t) = realloc;
-void *(*_objc_calloc)(size_t, size_t) = calloc;
-void (*_objc_free)(void *) = free;
diff --git a/contrib/gcc/objc/objc-api.h b/contrib/gcc/objc/objc-api.h
deleted file mode 100644
index 9eb000b5b391..000000000000
--- a/contrib/gcc/objc/objc-api.h
+++ /dev/null
@@ -1,584 +0,0 @@
-/* GNU Objective-C Runtime API.
- Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option) any
-later version.
-
-GNU CC is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
-License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-/* As a special exception, if you link this library with files compiled
- with GCC to produce an executable, this does not cause the resulting
- executable to be covered by the GNU General Public License. This
- exception does not however invalidate any other reasons why the
- executable file might be covered by the GNU General Public License. */
-
-#ifndef __objc_api_INCLUDE_GNU
-#define __objc_api_INCLUDE_GNU
-
-#include "objc/objc.h"
-#include "objc/hash.h"
-#include "objc/thr.h"
-#include <stdio.h>
-#include <stdarg.h>
-
-/* For functions which return Method_t */
-#define METHOD_NULL (Method_t)0
- /* Boolean typedefs */
-/*
-** Method descriptor returned by introspective Object methods.
-** This is really just the first part of the more complete objc_method
-** structure defined below and used internally by the runtime.
-*/
-struct objc_method_description
-{
- SEL name; /* this is a selector, not a string */
- char *types; /* type encoding */
-};
-
-/* Filer types used to describe Ivars and Methods. */
-#define _C_ID '@'
-#define _C_CLASS '#'
-#define _C_SEL ':'
-#define _C_CHR 'c'
-#define _C_UCHR 'C'
-#define _C_SHT 's'
-#define _C_USHT 'S'
-#define _C_INT 'i'
-#define _C_UINT 'I'
-#define _C_LNG 'l'
-#define _C_ULNG 'L'
-#define _C_FLT 'f'
-#define _C_DBL 'd'
-#define _C_BFLD 'b'
-#define _C_VOID 'v'
-#define _C_UNDEF '?'
-#define _C_PTR '^'
-#define _C_CHARPTR '*'
-#define _C_ATOM '%'
-#define _C_ARY_B '['
-#define _C_ARY_E ']'
-#define _C_UNION_B '('
-#define _C_UNION_E ')'
-#define _C_STRUCT_B '{'
-#define _C_STRUCT_E '}'
-
-
-/*
-** Error handling
-**
-** Call objc_error() or objc_verror() to record an error; this error
-** routine will generally exit the program but not necessarily if the
-** user has installed his own error handler.
-**
-** Call objc_set_error_handler to assign your own function for
-** handling errors. The function should return YES if it is ok
-** to continue execution, or return NO or just abort if the
-** program should be stopped. The default error handler is just to
-** print a message on stderr.
-**
-** The error handler function should be of type objc_error_handler
-** The first parameter is an object instance of relevance.
-** The second parameter is an error code.
-** The third parameter is a format string in the printf style.
-** The fourth parameter is a variable list of arguments.
-*/
-extern void objc_error(id object, int code, const char* fmt, ...);
-extern void objc_verror(id object, int code, const char* fmt, va_list ap);
-typedef BOOL (*objc_error_handler)(id, int code, const char *fmt, va_list ap);
-objc_error_handler objc_set_error_handler(objc_error_handler func);
-
-/*
-** Error codes
-** These are used by the runtime library, and your
-** error handling may use them to determine if the error is
-** hard or soft thus whether execution can continue or abort.
-*/
-#define OBJC_ERR_UNKNOWN 0 /* Generic error */
-
-#define OBJC_ERR_OBJC_VERSION 1 /* Incorrect runtime version */
-#define OBJC_ERR_GCC_VERSION 2 /* Incorrect compiler version */
-#define OBJC_ERR_MODULE_SIZE 3 /* Bad module size */
-#define OBJC_ERR_PROTOCOL_VERSION 4 /* Incorrect protocol version */
-
-#define OBJC_ERR_MEMORY 10 /* Out of memory */
-
-#define OBJC_ERR_RECURSE_ROOT 20 /* Attempt to archive the root
- object more than once. */
-#define OBJC_ERR_BAD_DATA 21 /* Didn't read expected data */
-#define OBJC_ERR_BAD_KEY 22 /* Bad key for object */
-#define OBJC_ERR_BAD_CLASS 23 /* Unknown class */
-#define OBJC_ERR_BAD_TYPE 24 /* Bad type specification */
-#define OBJC_ERR_NO_READ 25 /* Cannot read stream */
-#define OBJC_ERR_NO_WRITE 26 /* Cannot write stream */
-#define OBJC_ERR_STREAM_VERSION 27 /* Incorrect stream version */
-#define OBJC_ERR_BAD_OPCODE 28 /* Bad opcode */
-
-#define OBJC_ERR_UNIMPLEMENTED 30 /* Method is not implemented */
-
-#define OBJC_ERR_BAD_STATE 40 /* Bad thread state */
-
-/*
-** Set this variable nonzero to print a line describing each
-** message that is sent. (this is currently disabled)
-*/
-extern BOOL objc_trace;
-
-
-/* For every class which happens to have statically allocated instances in
- this module, one OBJC_STATIC_INSTANCES is allocated by the compiler.
- INSTANCES is NULL terminated and points to all statically allocated
- instances of this class. */
-struct objc_static_instances
-{
- char *class_name;
- id instances[0];
-};
-
-/*
-** Whereas a Module (defined further down) is the root (typically) of a file,
-** a Symtab is the root of the class and category definitions within the
-** module.
-**
-** A Symtab contains a variable length array of pointers to classes and
-** categories defined in the module.
-*/
-typedef struct objc_symtab {
- unsigned long sel_ref_cnt; /* Unknown. */
- SEL refs; /* Unknown. */
- unsigned short cls_def_cnt; /* Number of classes compiled
- (defined) in the module. */
- unsigned short cat_def_cnt; /* Number of categories
- compiled (defined) in the
- module. */
-
- void *defs[1]; /* Variable array of pointers.
- cls_def_cnt of type Class
- followed by cat_def_cnt of
- type Category_t, followed
- by a NULL terminated array
- of objc_static_instances. */
-} Symtab, *Symtab_t;
-
-
-/*
-** The compiler generates one of these structures for each module that
-** composes the executable (eg main.m).
-**
-** This data structure is the root of the definition tree for the module.
-**
-** A collect program runs between ld stages and creates a ObjC ctor array.
-** That array holds a pointer to each module structure of the executable.
-*/
-typedef struct objc_module {
- unsigned long version; /* Compiler revision. */
- unsigned long size; /* sizeof(Module). */
- const char* name; /* Name of the file where the
- module was generated. The
- name includes the path. */
-
- Symtab_t symtab; /* Pointer to the Symtab of
- the module. The Symtab
- holds an array of
- pointers to
- the classes and categories
- defined in the module. */
-} Module, *Module_t;
-
-
-/*
-** The compiler generates one of these structures for a class that has
-** instance variables defined in its specification.
-*/
-typedef struct objc_ivar* Ivar_t;
-typedef struct objc_ivar_list {
- int ivar_count; /* Number of structures (Ivar)
- contained in the list. One
- structure per instance
- variable defined in the
- class. */
- struct objc_ivar {
- const char* ivar_name; /* Name of the instance
- variable as entered in the
- class definition. */
- const char* ivar_type; /* Description of the Ivar's
- type. Useful for
- debuggers. */
- int ivar_offset; /* Byte offset from the base
- address of the instance
- structure to the variable. */
-
- } ivar_list[1]; /* Variable length
- structure. */
-} IvarList, *IvarList_t;
-
-
-/*
-** The compiler generates one (or more) of these structures for a class that
-** has methods defined in its specification.
-**
-** The implementation of a class can be broken into separate pieces in a file
-** and categories can break them across modules. To handle this problem is a
-** singly linked list of methods.
-*/
-typedef struct objc_method Method;
-typedef Method* Method_t;
-typedef struct objc_method_list {
- struct objc_method_list* method_next; /* This variable is used to link
- a method list to another. It
- is a singly linked list. */
- int method_count; /* Number of methods defined in
- this structure. */
- struct objc_method {
- SEL method_name; /* This variable is the method's
- name. It is a char*.
- The unique integer passed to
- objc_msg_send is a char* too.
- It is compared against
- method_name using strcmp. */
- const char* method_types; /* Description of the method's
- parameter list. Useful for
- debuggers. */
- IMP method_imp; /* Address of the method in the
- executable. */
- } method_list[1]; /* Variable length
- structure. */
-} MethodList, *MethodList_t;
-
-struct objc_protocol_list {
- struct objc_protocol_list *next;
- int count;
- Protocol *list[1];
-};
-
-/*
-** This is used to assure consistent access to the info field of
-** classes
-*/
-#ifndef HOST_BITS_PER_LONG
-#define HOST_BITS_PER_LONG (sizeof(long)*8)
-#endif
-
-#define __CLS_INFO(cls) ((cls)->info)
-#define __CLS_ISINFO(cls, mask) ((__CLS_INFO(cls)&mask)==mask)
-#define __CLS_SETINFO(cls, mask) (__CLS_INFO(cls) |= mask)
-
-/* The structure is of type MetaClass */
-#define _CLS_META 0x2L
-#define CLS_ISMETA(cls) ((cls)&&__CLS_ISINFO(cls, _CLS_META))
-
-
-/* The structure is of type Class */
-#define _CLS_CLASS 0x1L
-#define CLS_ISCLASS(cls) ((cls)&&__CLS_ISINFO(cls, _CLS_CLASS))
-
-/*
-** The class is initialized within the runtime. This means that
-** it has had correct super and sublinks assigned
-*/
-#define _CLS_RESOLV 0x8L
-#define CLS_ISRESOLV(cls) __CLS_ISINFO(cls, _CLS_RESOLV)
-#define CLS_SETRESOLV(cls) __CLS_SETINFO(cls, _CLS_RESOLV)
-
-/*
-** The class has been send a +initialize message or a such is not
-** defined for this class
-*/
-#define _CLS_INITIALIZED 0x04L
-#define CLS_ISINITIALIZED(cls) __CLS_ISINFO(cls, _CLS_INITIALIZED)
-#define CLS_SETINITIALIZED(cls) __CLS_SETINFO(cls, _CLS_INITIALIZED)
-
-/*
-** The class number of this class. This must be the same for both the
-** class and its meta class object
-*/
-#define CLS_GETNUMBER(cls) (__CLS_INFO(cls) >> (HOST_BITS_PER_LONG/2))
-#define CLS_SETNUMBER(cls, num) \
- ({ (cls)->info <<= (HOST_BITS_PER_LONG/2); \
- (cls)->info >>= (HOST_BITS_PER_LONG/2); \
- __CLS_SETINFO(cls, (((unsigned long)num) << (HOST_BITS_PER_LONG/2))); })
-
-/*
-** The compiler generates one of these structures for each category. A class
-** may have many categories and contain both instance and factory methods.
-*/
-typedef struct objc_category {
- const char* category_name; /* Name of the category. Name
- contained in the () of the
- category definition. */
- const char* class_name; /* Name of the class to which
- the category belongs. */
- MethodList_t instance_methods; /* Linked list of instance
- methods defined in the
- category. NULL indicates no
- instance methods defined. */
- MethodList_t class_methods; /* Linked list of factory
- methods defined in the
- category. NULL indicates no
- class methods defined. */
- struct objc_protocol_list *protocols; /* List of Protocols
- conformed to */
-} Category, *Category_t;
-
-/*
-** Structure used when a message is send to a class's super class. The
-** compiler generates one of these structures and passes it to
-** objc_msg_super.
-*/
-typedef struct objc_super {
- id self; /* Id of the object sending
- the message. */
- Class class; /* Object's super class. */
-} Super, *Super_t;
-
-IMP objc_msg_lookup_super(Super_t super, SEL sel);
-
-retval_t objc_msg_sendv(id, SEL, arglist_t);
-
-
-
-/*
-** This is a hook which is called by objc_lookup_class and
-** objc_get_class if the runtime is not able to find the class.
-** This may e.g. try to load in the class using dynamic loading.
-** The function is guaranteed to be passed a non-NULL name string.
-*/
-extern Class (*_objc_lookup_class)(const char *name);
-
-/*
-** This is a hook which is called by __objc_exec_class every time a class
-** or a category is loaded into the runtime. This may e.g. help a
-** dynamic loader determine the classes that have been loaded when
-** an object file is dynamically linked in.
-*/
-extern void (*_objc_load_callback)(Class class, Category* category);
-
-/*
-** Hook functions for allocating, copying and disposing of instances
-*/
-extern id (*_objc_object_alloc)(Class class);
-extern id (*_objc_object_copy)(id object);
-extern id (*_objc_object_dispose)(id object);
-
-/*
-** Standard functions for memory allocation and disposal.
-** Users should use these functions in their ObjC programs so
-** that they work properly with garbage collectors as well as
-** can take advantage of the exception/error handling available.
-*/
-void *
-objc_malloc(size_t size);
-
-void *
-objc_atomic_malloc(size_t size);
-
-void *
-objc_valloc(size_t size);
-
-void *
-objc_realloc(void *mem, size_t size);
-
-void *
-objc_calloc(size_t nelem, size_t size);
-
-void
-objc_free(void *mem);
-
-/*
-** Hook functions for memory allocation and disposal.
-** This makes it easy to substitute garbage collection systems
-** such as Boehm's GC by assigning these function pointers
-** to the GC's allocation routines. By default these point
-** to the ANSI standard malloc, realloc, free, etc.
-**
-** Users should call the normal objc routines above for
-** memory allocation and disposal within their programs.
-*/
-extern void *(*_objc_malloc)(size_t);
-extern void *(*_objc_atomic_malloc)(size_t);
-extern void *(*_objc_valloc)(size_t);
-extern void *(*_objc_realloc)(void *, size_t);
-extern void *(*_objc_calloc)(size_t, size_t);
-extern void (*_objc_free)(void *);
-
-Method_t class_get_class_method(MetaClass class, SEL aSel);
-
-Method_t class_get_instance_method(Class class, SEL aSel);
-
-Class class_pose_as(Class impostor, Class superclass);
-
-Class objc_get_class(const char *name);
-
-Class objc_lookup_class(const char *name);
-
-Class objc_next_class(void **enum_state);
-
-const char *sel_get_name(SEL selector);
-
-const char *sel_get_type(SEL selector);
-
-SEL sel_get_uid(const char *name);
-
-SEL sel_get_any_uid(const char *name);
-
-SEL sel_get_any_typed_uid(const char *name);
-
-SEL sel_get_typed_uid(const char *name, const char*);
-
-SEL sel_register_name(const char *name);
-
-SEL sel_register_typed_name(const char *name, const char*type);
-
-
-BOOL sel_is_mapped (SEL aSel);
-
-extern id class_create_instance(Class class);
-
-static inline const char *
-class_get_class_name(Class class)
-{
- return CLS_ISCLASS(class)?class->name:((class==Nil)?"Nil":0);
-}
-
-static inline long
-class_get_instance_size(Class class)
-{
- return CLS_ISCLASS(class)?class->instance_size:0;
-}
-
-static inline MetaClass
-class_get_meta_class(Class class)
-{
- return CLS_ISCLASS(class)?class->class_pointer:Nil;
-}
-
-static inline Class
-class_get_super_class(Class class)
-{
- return CLS_ISCLASS(class)?class->super_class:Nil;
-}
-
-static inline int
-class_get_version(Class class)
-{
- return CLS_ISCLASS(class)?class->version:-1;
-}
-
-static inline BOOL
-class_is_class(Class class)
-{
- return CLS_ISCLASS(class);
-}
-
-static inline BOOL
-class_is_meta_class(Class class)
-{
- return CLS_ISMETA(class);
-}
-
-
-static inline void
-class_set_version(Class class, long version)
-{
- if (CLS_ISCLASS(class))
- class->version = version;
-}
-
-static inline IMP
-method_get_imp(Method_t method)
-{
- return (method!=METHOD_NULL)?method->method_imp:(IMP)0;
-}
-
-IMP get_imp (Class class, SEL sel);
-
-/* Redefine on NeXTSTEP so as not to conflict with system function */
-#ifdef __NeXT__
-#define object_copy gnu_object_copy
-#define object_dispose gnu_object_dispose
-#endif
-
-id object_copy(id object);
-
-id object_dispose(id object);
-
-static inline Class
-object_get_class(id object)
-{
- return ((object!=nil)
- ? (CLS_ISCLASS(object->class_pointer)
- ? object->class_pointer
- : (CLS_ISMETA(object->class_pointer)
- ? (Class)object
- : Nil))
- : Nil);
-}
-
-static inline const char *
-object_get_class_name(id object)
-{
- return ((object!=nil)?(CLS_ISCLASS(object->class_pointer)
- ?object->class_pointer->name
- :((Class)object)->name)
- :"Nil");
-}
-
-static inline MetaClass
-object_get_meta_class(id object)
-{
- return ((object!=nil)?(CLS_ISCLASS(object->class_pointer)
- ?object->class_pointer->class_pointer
- :(CLS_ISMETA(object->class_pointer)
- ?object->class_pointer
- :Nil))
- :Nil);
-}
-
-static inline Class
-object_get_super_class
-(id object)
-{
- return ((object!=nil)?(CLS_ISCLASS(object->class_pointer)
- ?object->class_pointer->super_class
- :(CLS_ISMETA(object->class_pointer)
- ?((Class)object)->super_class
- :Nil))
- :Nil);
-}
-
-static inline BOOL
-object_is_class(id object)
-{
- return CLS_ISCLASS((Class)object);
-}
-
-static inline BOOL
-object_is_instance(id object)
-{
- return (object!=nil)&&CLS_ISCLASS(object->class_pointer);
-}
-
-static inline BOOL
-object_is_meta_class(id object)
-{
- return CLS_ISMETA((Class)object);
-}
-
-struct sarray*
-objc_get_uninstalled_dtable(void);
-
-#endif /* not __objc_api_INCLUDE_GNU */
-
-
-
diff --git a/contrib/gcc/objc/objc.h b/contrib/gcc/objc/objc.h
deleted file mode 100644
index e48b0fd5bfb4..000000000000
--- a/contrib/gcc/objc/objc.h
+++ /dev/null
@@ -1,157 +0,0 @@
-/* Basic data types for Objective C.
- Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-/* As a special exception, if you link this library with files
- compiled with GCC to produce an executable, this does not cause
- the resulting executable to be covered by the GNU General Public License.
- This exception does not however invalidate any other reasons why
- the executable file might be covered by the GNU General Public License. */
-
-#ifndef __objc_INCLUDE_GNU
-#define __objc_INCLUDE_GNU
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stddef.h>
-
-/*
-** Definition of the boolean type.
-*/
-#ifdef __vxworks
-typedef int BOOL;
-#else
-typedef unsigned char BOOL;
-#endif
-#define YES (BOOL)1
-#define NO (BOOL)0
-
-/*
-** Definition of a selector. Selectors themselves are not unique, but
-** the sel_id is a unique identifier.
-*/
-typedef const struct objc_selector
-{
- void *sel_id;
- const char *sel_types;
-} *SEL;
-
-inline static BOOL
-sel_eq (SEL s1, SEL s2)
-{
- if (s1 == 0 || s2 == 0)
- return s1 == s2;
- else
- return s1->sel_id == s2->sel_id;
-}
-
-
-/*
-** ObjC uses this typedef for untyped instances.
-*/
-typedef struct objc_object {
- struct objc_class* class_pointer;
-} *id;
-
-/*
-** Definition of method type. When retrieving the implementation of a
-** method, this is type of the pointer returned
-*/
-typedef id (*IMP)(id, SEL, ...);
-
-/*
-** More simple types...
-*/
-#define nil (id)0 /* id of Nil instance */
-#define Nil (Class)0 /* id of Nil class */
-typedef char *STR; /* String alias */
-
-/*
-** The compiler generates one of these structures for each class.
-**
-** This structure is the definition for classes.
-**
-** This structure is generated by the compiler in the executable and used by
-** the run-time during normal messaging operations. Therefore some members
-** change type. The compiler generates "char* const" and places a string in
-** the following member variables: super_class.
-*/
-typedef struct objc_class *MetaClass;
-typedef struct objc_class *Class;
-struct objc_class {
- MetaClass class_pointer; /* Pointer to the class's
- meta class. */
- struct objc_class* super_class; /* Pointer to the super
- class. NULL for class
- Object. */
- const char* name; /* Name of the class. */
- long version; /* Unknown. */
- unsigned long info; /* Bit mask. See class masks
- defined above. */
- long instance_size; /* Size in bytes of the class.
- The sum of the class
- definition and all super
- class definitions. */
- struct objc_ivar_list* ivars; /* Pointer to a structure that
- describes the instance
- variables in the class
- definition. NULL indicates
- no instance variables. Does
- not include super class
- variables. */
- struct objc_method_list* methods; /* Linked list of instance
- methods defined for the
- class. */
- struct sarray * dtable; /* Pointer to instance
- method dispatch table. */
- struct objc_class* subclass_list; /* Subclasses */
- struct objc_class* sibling_class;
-
- struct objc_protocol_list *protocols; /* Protocols conformed to */
-};
-
-#ifndef __OBJC__
-typedef struct objc_protocol {
- struct objc_class* class_pointer;
- char *protocol_name;
- struct objc_protocol_list *protocol_list;
- struct objc_method_description_list *instance_methods, *class_methods;
-} Protocol;
-
-#else /* __OBJC__ */
-@class Protocol;
-#endif
-
-typedef void* retval_t; /* return value */
-typedef void(*apply_t)(void); /* function pointer */
-typedef union {
- char *arg_ptr;
- char arg_regs[sizeof (char*)];
-} *arglist_t; /* argument frame */
-
-
-IMP objc_msg_lookup(id receiver, SEL op);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* not __objc_INCLUDE_GNU */
diff --git a/contrib/gcc/objc/objects.c b/contrib/gcc/objc/objects.c
deleted file mode 100644
index 3e68334c924b..000000000000
--- a/contrib/gcc/objc/objects.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/* GNU Objective C Runtime class related functions
- Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc.
- Contributed by Kresten Krab Thorup
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the Free Software
-Foundation; either version 2, or (at your option) any later version.
-
-GNU CC is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
-details.
-
-You should have received a copy of the GNU General Public License along with
-GNU CC; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-/* As a special exception, if you link this library with files compiled with
- GCC to produce an executable, this does not cause the resulting executable
- to be covered by the GNU General Public License. This exception does not
- however invalidate any other reasons why the executable file might be
- covered by the GNU General Public License. */
-
-#include "../tconfig.h" /* include defs of bzero for target */
-#include "runtime.h" /* the kitchen sink */
-
-id __objc_object_alloc(Class);
-id __objc_object_dispose(id);
-id __objc_object_copy(id);
-
-id (*_objc_object_alloc)(Class) = __objc_object_alloc; /* !T:SINGLE */
-id (*_objc_object_dispose)(id) = __objc_object_dispose; /* !T:SINGLE */
-id (*_objc_object_copy)(id) = __objc_object_copy; /* !T:SINGLE */
-
-id
-class_create_instance(Class class)
-{
- id new = nil;
- if (CLS_ISCLASS(class))
- new = (*_objc_object_alloc)(class);
- if (new!=nil)
- {
- memset (new, 0, class->instance_size);
- new->class_pointer = class;
- }
- return new;
-}
-
-id
-object_copy(id object)
-{
- if ((object!=nil)&&CLS_ISCLASS(object->class_pointer))
- return (*_objc_object_copy)(object);
- else
- return nil;
-}
-
-id
-object_dispose(id object)
-{
- if ((object!=nil)&&CLS_ISCLASS(object->class_pointer))
- {
- if (_objc_object_dispose)
- (*_objc_object_dispose)(object);
- else
- objc_free(object);
- }
- return nil;
-}
-
-id __objc_object_alloc(Class class)
-{
- return (id)objc_malloc(class->instance_size);
-}
-
-id __objc_object_dispose(id object)
-{
- objc_free(object);
- return 0;
-}
-
-id __objc_object_copy(id object)
-{
- id copy = class_create_instance(object->class_pointer);
- memcpy(copy, object, object->class_pointer->instance_size);
- return copy;
-}
-
-
diff --git a/contrib/gcc/objc/runtime.h b/contrib/gcc/objc/runtime.h
deleted file mode 100644
index b0eae4a222d3..000000000000
--- a/contrib/gcc/objc/runtime.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* GNU Objective C Runtime internal declarations
- Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
- Contributed by Kresten Krab Thorup
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the Free Software
-Foundation; either version 2, or (at your option) any later version.
-
-GNU CC is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
-details.
-
-You should have received a copy of the GNU General Public License along with
-GNU CC; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* As a special exception, if you link this library with files compiled with
- GCC to produce an executable, this does not cause the resulting executable
- to be covered by the GNU General Public License. This exception does not
- however invalidate any other reasons why the executable file might be
- covered by the GNU General Public License. */
-
-#ifndef __objc_runtime_INCLUDE_GNU
-#define __objc_runtime_INCLUDE_GNU
-
-#include <stdarg.h> /* for varargs and va_list's */
-
-#include <stdio.h>
-#include <ctype.h>
-
-#include <stddef.h> /* so noone else will get system versions */
-#include "assert.h"
-
-#include "objc/objc.h" /* core data types */
-#include "objc/objc-api.h" /* runtime api functions */
-
-#include "objc/thr.h" /* thread and mutex support */
-
-#include "objc/hash.h" /* hash structures */
-#include "objc/objc-list.h" /* linear lists */
-
-extern void __objc_add_class_to_hash(Class); /* (objc-class.c) */
-extern void __objc_init_selector_tables(void); /* (objc-sel.c) */
-extern void __objc_init_class_tables(void); /* (objc-class.c) */
-extern void __objc_init_dispatch_tables(void); /* (objc-dispatch.c) */
-extern void __objc_install_premature_dtable(Class); /* (objc-dispatch.c) */
-extern void __objc_resolve_class_links(void); /* (objc-class.c) */
-extern void __objc_register_selectors_from_class(Class); /* (objc-sel.c) */
-extern void __objc_update_dispatch_table_for_class (Class);/* (objc-msg.c) */
-
-extern int __objc_init_thread_system(void); /* thread.c */
-extern int __objc_fini_thread_system(void); /* thread.c */
-extern void __objc_print_dtable_stats(void); /* sendmsg.c */
-
-extern void class_add_method_list(Class, MethodList_t);
-
-/* Registering instance methods as class methods for root classes */
-extern void __objc_register_instance_methods_to_class(Class);
-extern Method_t search_for_method_in_list(MethodList_t list, SEL op);
-
-/* True when class links has been resolved */
-extern BOOL __objc_class_links_resolved;
-
-/* Number of selectors stored in each of the selector tables */
-extern int __objc_selector_max_index;
-
-/* Mutex locking __objc_selector_max_index and its arrays. */
-extern objc_mutex_t __objc_runtime_mutex;
-
-/* Number of threads which are alive. */
-extern int __objc_runtime_threads_alive;
-
-#ifdef DEBUG
-#define DEBUG_PRINTF(format, args...) printf (format, ## args)
-#else
-#define DEBUG_PRINTF(format, args...)
-#endif
-
-BOOL __objc_responds_to (id object, SEL sel); /* for internal use only! */
-SEL __sel_register_typed_name (const char*, const char*,
- struct objc_selector*, BOOL is_const);
-
-#endif /* not __objc_runtime_INCLUDE_GNU */
-
-
diff --git a/contrib/gcc/objc/sarray.c b/contrib/gcc/objc/sarray.c
deleted file mode 100644
index 7e40fba750f6..000000000000
--- a/contrib/gcc/objc/sarray.c
+++ /dev/null
@@ -1,522 +0,0 @@
-/* Sparse Arrays for Objective C dispatch tables
- Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-/* As a special exception, if you link this library with files
- compiled with GCC to produce an executable, this does not cause
- the resulting executable to be covered by the GNU General Public License.
- This exception does not however invalidate any other reasons why
- the executable file might be covered by the GNU General Public License. */
-
-#include "objc/sarray.h"
-#include "objc/runtime.h"
-#include <stdio.h>
-#include "assert.h"
-
-int nbuckets = 0; /* !T:MUTEX */
-int nindices = 0; /* !T:MUTEX */
-int narrays = 0; /* !T:MUTEX */
-int idxsize = 0; /* !T:MUTEX */
-
-static void * first_free_data = NULL; /* !T:MUTEX */
-
-#ifdef OBJC_SPARSE2
-const char* __objc_sparse2_id = "2 level sparse indices";
-#endif
-
-#ifdef OBJC_SPARSE3
-const char* __objc_sparse3_id = "3 level sparse indices";
-#endif
-
-#ifdef __alpha__
-const void *memcpy (void*, const void*, size_t);
-#endif
-
-/* This function removes any structures left over from free operations
- that were not safe in a multi-threaded environment. */
-void
-sarray_remove_garbage(void)
-{
- void **vp;
- void *np;
-
- objc_mutex_lock(__objc_runtime_mutex);
-
- vp = first_free_data;
- first_free_data = NULL;
-
- while (vp) {
- np = *vp;
- objc_free(vp);
- vp = np;
- }
-
- objc_mutex_unlock(__objc_runtime_mutex);
-}
-
-/* Free a block of dynamically allocated memory. If we are in multi-threaded
- mode, it is ok to free it. If not, we add it to the garbage heap to be
- freed later. */
-
-static void
-sarray_free_garbage(void *vp)
-{
- objc_mutex_lock(__objc_runtime_mutex);
-
- if (__objc_runtime_threads_alive == 1) {
- objc_free(vp);
- if (first_free_data)
- sarray_remove_garbage();
- }
- else {
- *(void **)vp = first_free_data;
- first_free_data = vp;
- }
-
- objc_mutex_unlock(__objc_runtime_mutex);
-}
-
-/* sarray_at_put : copies data in such a way as to be thread reader safe. */
-void
-sarray_at_put(struct sarray* array, sidx index, void* element)
-{
-#ifdef OBJC_SPARSE3
- struct sindex** the_index;
- struct sindex* new_index;
-#endif
- struct sbucket** the_bucket;
- struct sbucket* new_bucket;
-#ifdef OBJC_SPARSE3
- size_t ioffset;
-#endif
- size_t boffset;
- size_t eoffset;
-#ifdef PRECOMPUTE_SELECTORS
- union sofftype xx;
- xx.idx = index;
-#ifdef OBJC_SPARSE3
- ioffset = xx.off.ioffset;
-#endif
- boffset = xx.off.boffset;
- eoffset = xx.off.eoffset;
-#else /* not PRECOMPUTE_SELECTORS */
-#ifdef OBJC_SPARSE3
- ioffset = index/INDEX_CAPACITY;
- boffset = (index/BUCKET_SIZE)%INDEX_SIZE;
- eoffset = index%BUCKET_SIZE;
-#else
- boffset = index/BUCKET_SIZE;
- eoffset = index%BUCKET_SIZE;
-#endif
-#endif /* not PRECOMPUTE_SELECTORS */
-
- assert(soffset_decode(index) < array->capacity); /* Range check */
-
-#ifdef OBJC_SPARSE3
- the_index = &(array->indices[ioffset]);
- the_bucket = &((*the_index)->buckets[boffset]);
-#else
- the_bucket = &(array->buckets[boffset]);
-#endif
-
- if ((*the_bucket)->elems[eoffset] == element)
- return; /* great! we just avoided a lazy copy */
-
-#ifdef OBJC_SPARSE3
-
- /* First, perform lazy copy/allocation of index if needed */
-
- if ((*the_index) == array->empty_index) {
-
- /* The index was previously empty, allocate a new */
- new_index = (struct sindex*)objc_malloc(sizeof(struct sindex));
- memcpy(new_index, array->empty_index, sizeof(struct sindex));
- new_index->version.version = array->version.version;
- *the_index = new_index; /* Prepared for install. */
- the_bucket = &((*the_index)->buckets[boffset]);
-
- nindices += 1;
- } else if ((*the_index)->version.version != array->version.version) {
-
- /* This index must be lazy copied */
- struct sindex* old_index = *the_index;
- new_index = (struct sindex*)objc_malloc(sizeof(struct sindex));
- memcpy( new_index, old_index, sizeof(struct sindex));
- new_index->version.version = array->version.version;
- *the_index = new_index; /* Prepared for install. */
- the_bucket = &((*the_index)->buckets[boffset]);
-
- nindices += 1;
- }
-
-#endif /* OBJC_SPARSE3 */
-
- /* next, perform lazy allocation/copy of the bucket if needed */
-
- if ((*the_bucket) == array->empty_bucket) {
-
- /* The bucket was previously empty (or something like that), */
- /* allocate a new. This is the effect of `lazy' allocation */
- new_bucket = (struct sbucket*)objc_malloc(sizeof(struct sbucket));
- memcpy((void *) new_bucket, (const void*)array->empty_bucket,
- sizeof(struct sbucket));
- new_bucket->version.version = array->version.version;
- *the_bucket = new_bucket; /* Prepared for install. */
-
- nbuckets += 1;
-
- } else if ((*the_bucket)->version.version != array->version.version) {
-
- /* Perform lazy copy. */
- struct sbucket* old_bucket = *the_bucket;
- new_bucket = (struct sbucket*)objc_malloc(sizeof(struct sbucket));
- memcpy( new_bucket, old_bucket, sizeof(struct sbucket));
- new_bucket->version.version = array->version.version;
- *the_bucket = new_bucket; /* Prepared for install. */
-
- nbuckets += 1;
-
- }
- (*the_bucket)->elems[eoffset] = element;
-}
-
-void
-sarray_at_put_safe(struct sarray* array, sidx index, void* element)
-{
- if(soffset_decode(index) >= array->capacity)
- sarray_realloc(array, soffset_decode(index)+1);
- sarray_at_put(array, index, element);
-}
-
-struct sarray*
-sarray_new (int size, void* default_element)
-{
- struct sarray* arr;
-#ifdef OBJC_SPARSE3
- size_t num_indices = ((size-1)/(INDEX_CAPACITY))+1;
- struct sindex ** new_indices;
-#else /* OBJC_SPARSE2 */
- size_t num_indices = ((size-1)/BUCKET_SIZE)+1;
- struct sbucket ** new_buckets;
-#endif
- int counter;
-
- assert(size > 0);
-
- /* Allocate core array */
- arr = (struct sarray*) objc_malloc(sizeof(struct sarray));
- arr->version.version = 0;
-
- /* Initialize members */
-#ifdef OBJC_SPARSE3
- arr->capacity = num_indices*INDEX_CAPACITY;
- new_indices = (struct sindex**)
- objc_malloc(sizeof(struct sindex*)*num_indices);
-
- arr->empty_index = (struct sindex*) objc_malloc(sizeof(struct sindex));
- arr->empty_index->version.version = 0;
-
- narrays += 1;
- idxsize += num_indices;
- nindices += 1;
-
-#else /* OBJC_SPARSE2 */
- arr->capacity = num_indices*BUCKET_SIZE;
- new_buckets = (struct sbucket**)
- objc_malloc(sizeof(struct sbucket*)*num_indices);
-
- narrays += 1;
- idxsize += num_indices;
-
-#endif
-
- arr->empty_bucket = (struct sbucket*) objc_malloc(sizeof(struct sbucket));
- arr->empty_bucket->version.version = 0;
-
- nbuckets += 1;
-
- arr->ref_count = 1;
- arr->is_copy_of = (struct sarray*)0;
-
- for (counter=0; counter<BUCKET_SIZE; counter++)
- arr->empty_bucket->elems[counter] = default_element;
-
-#ifdef OBJC_SPARSE3
- for (counter=0; counter<INDEX_SIZE; counter++)
- arr->empty_index->buckets[counter] = arr->empty_bucket;
-
- for (counter=0; counter<num_indices; counter++)
- new_indices[counter] = arr->empty_index;
-
-#else /* OBJC_SPARSE2 */
-
- for (counter=0; counter<num_indices; counter++)
- new_buckets[counter] = arr->empty_bucket;
-
-#endif
-
-#ifdef OBJC_SPARSE3
- arr->indices = new_indices;
-#else /* OBJC_SPARSE2 */
- arr->buckets = new_buckets;
-#endif
-
- return arr;
-}
-
-
-/* Reallocate the sparse array to hold `newsize' entries
- Note: We really allocate and then free. We have to do this to ensure that
- any concurrent readers notice the update. */
-
-void
-sarray_realloc(struct sarray* array, int newsize)
-{
-#ifdef OBJC_SPARSE3
- size_t old_max_index = (array->capacity-1)/INDEX_CAPACITY;
- size_t new_max_index = ((newsize-1)/INDEX_CAPACITY);
- size_t rounded_size = (new_max_index+1)*INDEX_CAPACITY;
-
- struct sindex ** new_indices;
- struct sindex ** old_indices;
-
-#else /* OBJC_SPARSE2 */
- size_t old_max_index = (array->capacity-1)/BUCKET_SIZE;
- size_t new_max_index = ((newsize-1)/BUCKET_SIZE);
- size_t rounded_size = (new_max_index+1)*BUCKET_SIZE;
-
- struct sbucket ** new_buckets;
- struct sbucket ** old_buckets;
-
-#endif
-
- int counter;
-
- assert(newsize > 0);
-
- /* The size is the same, just ignore the request */
- if(rounded_size <= array->capacity)
- return;
-
- assert(array->ref_count == 1); /* stop if lazy copied... */
-
- /* We are asked to extend the array -- allocate new bucket table, */
- /* and insert empty_bucket in newly allocated places. */
- if(rounded_size > array->capacity)
- {
-
-#ifdef OBJC_SPARSE3
- new_max_index += 4;
- rounded_size = (new_max_index+1)*INDEX_CAPACITY;
-
-#else /* OBJC_SPARSE2 */
- new_max_index += 4;
- rounded_size = (new_max_index+1)*BUCKET_SIZE;
-#endif
-
- /* update capacity */
- array->capacity = rounded_size;
-
-#ifdef OBJC_SPARSE3
- /* alloc to force re-read by any concurrent readers. */
- old_indices = array->indices;
- new_indices = (struct sindex**)
- objc_malloc((new_max_index+1)*sizeof(struct sindex*));
-#else /* OBJC_SPARSE2 */
- old_buckets = array->buckets;
- new_buckets = (struct sbucket**)
- objc_malloc((new_max_index+1)*sizeof(struct sbucket*));
-#endif
-
- /* copy buckets below old_max_index (they are still valid) */
- for(counter = 0; counter <= old_max_index; counter++ ) {
-#ifdef OBJC_SPARSE3
- new_indices[counter] = old_indices[counter];
-#else /* OBJC_SPARSE2 */
- new_buckets[counter] = old_buckets[counter];
-#endif
- }
-
-#ifdef OBJC_SPARSE3
- /* reset entries above old_max_index to empty_bucket */
- for(counter = old_max_index+1; counter <= new_max_index; counter++)
- new_indices[counter] = array->empty_index;
-#else /* OBJC_SPARSE2 */
- /* reset entries above old_max_index to empty_bucket */
- for(counter = old_max_index+1; counter <= new_max_index; counter++)
- new_buckets[counter] = array->empty_bucket;
-#endif
-
-#ifdef OBJC_SPARSE3
- /* install the new indices */
- array->indices = new_indices;
-#else /* OBJC_SPARSE2 */
- array->buckets = new_buckets;
-#endif
-
-#ifdef OBJC_SPARSE3
- /* free the old indices */
- sarray_free_garbage(old_indices);
-#else /* OBJC_SPARSE2 */
- sarray_free_garbage(old_buckets);
-#endif
-
- idxsize += (new_max_index-old_max_index);
- return;
- }
-}
-
-
-/* Free a sparse array allocated with sarray_new */
-
-void
-sarray_free(struct sarray* array) {
-
-#ifdef OBJC_SPARSE3
- size_t old_max_index = (array->capacity-1)/INDEX_CAPACITY;
- struct sindex ** old_indices;
-#else
- size_t old_max_index = (array->capacity-1)/BUCKET_SIZE;
- struct sbucket ** old_buckets;
-#endif
- int counter = 0;
-
- assert(array->ref_count != 0); /* Freed multiple times!!! */
-
- if(--(array->ref_count) != 0) /* There exists copies of me */
- return;
-
-#ifdef OBJC_SPARSE3
- old_indices = array->indices;
-#else
- old_buckets = array->buckets;
-#endif
-
- if((array->is_copy_of) && ((array->is_copy_of->ref_count - 1) == 0))
- sarray_free(array->is_copy_of);
-
- /* Free all entries that do not point to empty_bucket */
- for(counter = 0; counter <= old_max_index; counter++ ) {
-#ifdef OBJC_SPARSE3
- struct sindex* idx = old_indices[counter];
- if((idx != array->empty_index) &&
- (idx->version.version == array->version.version)) {
- int c2;
- for(c2=0; c2<INDEX_SIZE; c2++) {
- struct sbucket* bkt = idx->buckets[c2];
- if((bkt != array->empty_bucket) &&
- (bkt->version.version == array->version.version))
- {
- sarray_free_garbage(bkt);
- nbuckets -= 1;
- }
- }
- sarray_free_garbage(idx);
- nindices -= 1;
- }
-#else /* OBJC_SPARSE2 */
- struct sbucket* bkt = array->buckets[counter];
- if ((bkt != array->empty_bucket) &&
- (bkt->version.version == array->version.version))
- {
- sarray_free_garbage(bkt);
- nbuckets -= 1;
- }
-#endif
- }
-
-#ifdef OBJC_SPARSE3
- /* free empty_index */
- if(array->empty_index->version.version == array->version.version) {
- sarray_free_garbage(array->empty_index);
- nindices -= 1;
- }
-#endif
-
- /* free empty_bucket */
- if(array->empty_bucket->version.version == array->version.version) {
- sarray_free_garbage(array->empty_bucket);
- nbuckets -= 1;
- }
- idxsize -= (old_max_index+1);
- narrays -= 1;
-
-#ifdef OBJC_SPARSE3
- /* free bucket table */
- sarray_free_garbage(array->indices);
-
-#else
- /* free bucket table */
- sarray_free_garbage(array->buckets);
-
-#endif
-
- /* free array */
- sarray_free_garbage(array);
-}
-
-/* This is a lazy copy. Only the core of the structure is actually */
-/* copied. */
-
-struct sarray*
-sarray_lazy_copy(struct sarray* oarr)
-{
- struct sarray* arr;
-
-#ifdef OBJC_SPARSE3
- size_t num_indices = ((oarr->capacity-1)/INDEX_CAPACITY)+1;
- struct sindex ** new_indices;
-#else /* OBJC_SPARSE2 */
- size_t num_indices = ((oarr->capacity-1)/BUCKET_SIZE)+1;
- struct sbucket ** new_buckets;
-#endif
-
- /* Allocate core array */
- arr = (struct sarray*) objc_malloc(sizeof(struct sarray)); /* !!! */
- arr->version.version = oarr->version.version + 1;
-#ifdef OBJC_SPARSE3
- arr->empty_index = oarr->empty_index;
-#endif
- arr->empty_bucket = oarr->empty_bucket;
- arr->ref_count = 1;
- oarr->ref_count += 1;
- arr->is_copy_of = oarr;
- arr->capacity = oarr->capacity;
-
-#ifdef OBJC_SPARSE3
- /* Copy bucket table */
- new_indices = (struct sindex**)
- objc_malloc(sizeof(struct sindex*)*num_indices);
- memcpy( new_indices,oarr->indices,
- sizeof(struct sindex*)*num_indices);
- arr->indices = new_indices;
-#else
- /* Copy bucket table */
- new_buckets = (struct sbucket**)
- objc_malloc(sizeof(struct sbucket*)*num_indices);
- memcpy( new_buckets,oarr->buckets,
- sizeof(struct sbucket*)*num_indices);
- arr->buckets = new_buckets;
-#endif
-
- idxsize += num_indices;
- narrays += 1;
-
- return arr;
-}
diff --git a/contrib/gcc/objc/sarray.h b/contrib/gcc/objc/sarray.h
deleted file mode 100644
index 74fa38652ba3..000000000000
--- a/contrib/gcc/objc/sarray.h
+++ /dev/null
@@ -1,237 +0,0 @@
-/* Sparse Arrays for Objective C dispatch tables
- Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc.
- Contributed by Kresten Krab Thorup.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-/* As a special exception, if you link this library with files
- compiled with GCC to produce an executable, this does not cause
- the resulting executable to be covered by the GNU General Public License.
- This exception does not however invalidate any other reasons why
- the executable file might be covered by the GNU General Public License. */
-
-#ifndef __sarray_INCLUDE_GNU
-#define __sarray_INCLUDE_GNU
-
-#define OBJC_SPARSE2 /* 2-level sparse array */
-/* #define OBJC_SPARSE3 */ /* 3-level sparse array */
-
-#ifdef OBJC_SPARSE2
-extern const char* __objc_sparse2_id;
-#endif
-
-#ifdef OBJC_SPARSE3
-extern const char* __objc_sparse3_id;
-#endif
-
-#include <stddef.h>
-
-#include "objc/thr.h"
-
-extern int nbuckets; /* for stats */
-extern int nindices;
-extern int narrays;
-extern int idxsize;
-
-#include <assert.h>
-
-/* An unsigned integer of same size as a pointer */
-#define SIZET_BITS (sizeof(size_t)*8)
-
-#if defined(__sparc__) || defined(OBJC_SPARSE2)
-#define PRECOMPUTE_SELECTORS
-#endif
-
-#ifdef OBJC_SPARSE3
-
-/* Buckets are 8 words each */
-#define BUCKET_BITS 3
-#define BUCKET_SIZE (1<<BUCKET_BITS)
-#define BUCKET_MASK (BUCKET_SIZE-1)
-
-/* Indices are 16 words each */
-#define INDEX_BITS 4
-#define INDEX_SIZE (1<<INDEX_BITS)
-#define INDEX_MASK (INDEX_SIZE-1)
-
-#define INDEX_CAPACITY (BUCKET_SIZE*INDEX_SIZE)
-
-#else /* OBJC_SPARSE2 */
-
-/* Buckets are 32 words each */
-#define BUCKET_BITS 5
-#define BUCKET_SIZE (1<<BUCKET_BITS)
-#define BUCKET_MASK (BUCKET_SIZE-1)
-
-#endif /* OBJC_SPARSE2 */
-
-typedef size_t sidx;
-
-#ifdef PRECOMPUTE_SELECTORS
-
-struct soffset {
-#ifdef OBJC_SPARSE3
- unsigned int unused : SIZET_BITS/4;
- unsigned int eoffset : SIZET_BITS/4;
- unsigned int boffset : SIZET_BITS/4;
- unsigned int ioffset : SIZET_BITS/4;
-#else /* OBJC_SPARSE2 */
-#ifdef __sparc__
- unsigned int boffset : (SIZET_BITS - 2) - BUCKET_BITS;
- unsigned int eoffset : BUCKET_BITS;
- unsigned int unused : 2;
-#else
- unsigned int boffset : SIZET_BITS/2;
- unsigned int eoffset : SIZET_BITS/2;
-#endif
-#endif /* OBJC_SPARSE2 */
-};
-
-union sofftype {
- struct soffset off;
- sidx idx;
-};
-
-#endif /* not PRECOMPUTE_SELECTORS */
-
-union sversion {
- int version;
- void *next_free;
-};
-
-struct sbucket {
- void* elems[BUCKET_SIZE]; /* elements stored in array */
- union sversion version; /* used for copy-on-write */
-};
-
-#ifdef OBJC_SPARSE3
-
-struct sindex {
- struct sbucket* buckets[INDEX_SIZE];
- union sversion version; /* used for copy-on-write */
-};
-
-#endif /* OBJC_SPARSE3 */
-
-struct sarray {
-#ifdef OBJC_SPARSE3
- struct sindex** indices;
- struct sindex* empty_index;
-#else /* OBJC_SPARSE2 */
- struct sbucket** buckets;
-#endif /* OBJC_SPARSE2 */
- struct sbucket* empty_bucket;
- union sversion version; /* used for copy-on-write */
- short ref_count;
- struct sarray* is_copy_of;
- size_t capacity;
-};
-
-struct sarray* sarray_new(int, void* default_element);
-void sarray_free(struct sarray*);
-struct sarray* sarray_lazy_copy(struct sarray*);
-void sarray_realloc(struct sarray*, int new_size);
-void sarray_at_put(struct sarray*, sidx index, void* elem);
-void sarray_at_put_safe(struct sarray*, sidx index, void* elem);
-
-struct sarray* sarray_hard_copy(struct sarray*); /* ... like the name? */
-void sarray_remove_garbage(void);
-
-
-#ifdef PRECOMPUTE_SELECTORS
-/* Transform soffset values to ints and vica verca */
-static inline unsigned int
-soffset_decode(sidx index)
-{
- union sofftype x;
- x.idx = index;
-#ifdef OBJC_SPARSE3
- return x.off.eoffset
- + (x.off.boffset*BUCKET_SIZE)
- + (x.off.ioffset*INDEX_CAPACITY);
-#else /* OBJC_SPARSE2 */
- return x.off.eoffset + (x.off.boffset*BUCKET_SIZE);
-#endif /* OBJC_SPARSE2 */
-}
-
-static inline sidx
-soffset_encode(size_t offset)
-{
- union sofftype x;
- x.off.eoffset = offset%BUCKET_SIZE;
-#ifdef OBJC_SPARSE3
- x.off.boffset = (offset/BUCKET_SIZE)%INDEX_SIZE;
- x.off.ioffset = offset/INDEX_CAPACITY;
-#else /* OBJC_SPARSE2 */
- x.off.boffset = offset/BUCKET_SIZE;
-#endif
- return (sidx)x.idx;
-}
-
-#else /* not PRECOMPUTE_SELECTORS */
-
-static inline size_t
-soffset_decode(sidx index)
-{
- return index;
-}
-
-static inline sidx
-soffset_encode(size_t offset)
-{
- return offset;
-}
-#endif /* not PRECOMPUTE_SELECTORS */
-
-/* Get element from the Sparse array `array' at offset `index' */
-
-static inline void* sarray_get(struct sarray* array, sidx index)
-{
-#ifdef PRECOMPUTE_SELECTORS
- union sofftype x;
- x.idx = index;
-#ifdef OBJC_SPARSE3
- return
- array->
- indices[x.off.ioffset]->
- buckets[x.off.boffset]->
- elems[x.off.eoffset];
-#else /* OBJC_SPARSE2 */
- return array->buckets[x.off.boffset]->elems[x.off.eoffset];
-#endif /* OBJC_SPARSE2 */
-#else /* not PRECOMPUTE_SELECTORS */
-#ifdef OBJC_SPARSE3
- return array->
- indices[index/INDEX_CAPACITY]->
- buckets[(index/BUCKET_SIZE)%INDEX_SIZE]->
- elems[index%BUCKET_SIZE];
-#else /* OBJC_SPARSE2 */
- return array->buckets[index/BUCKET_SIZE]->elems[index%BUCKET_SIZE];
-#endif /* not OBJC_SPARSE3 */
-#endif /* not PRECOMPUTE_SELECTORS */
-}
-
-static inline void* sarray_get_safe(struct sarray* array, sidx index)
-{
- if(soffset_decode(index) < array->capacity)
- return sarray_get(array, index);
- else
- return (array->empty_bucket->elems[0]);
-}
-
-#endif /* __sarray_INCLUDE_GNU */
diff --git a/contrib/gcc/objc/selector.c b/contrib/gcc/objc/selector.c
deleted file mode 100644
index 83c70e4ae0f1..000000000000
--- a/contrib/gcc/objc/selector.c
+++ /dev/null
@@ -1,458 +0,0 @@
-/* GNU Objective C Runtime selector related functions
- Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
- Contributed by Kresten Krab Thorup
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the Free Software
-Foundation; either version 2, or (at your option) any later version.
-
-GNU CC is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
-details.
-
-You should have received a copy of the GNU General Public License along with
-GNU CC; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* As a special exception, if you link this library with files compiled with
- GCC to produce an executable, this does not cause the resulting executable
- to be covered by the GNU General Public License. This exception does not
- however invalidate any other reasons why the executable file might be
- covered by the GNU General Public License. */
-
-#include "runtime.h"
-#include "objc/sarray.h"
-#include "encoding.h"
-
-/* Initial selector hash table size. Value doesn't matter much */
-#define SELECTOR_HASH_SIZE 128
-
-/* Tables mapping selector names to uid and opposite */
-static struct sarray* __objc_selector_array = 0; /* uid -> sel !T:MUTEX */
-static struct sarray* __objc_selector_names = 0; /* uid -> name !T:MUTEX */
-static cache_ptr __objc_selector_hash = 0; /* name -> uid !T:MUTEX */
-
-static void register_selectors_from_list(MethodList_t);
-
-/* Number of selectors stored in each of the above tables */
-int __objc_selector_max_index = 0; /* !T:MUTEX */
-
-void __objc_init_selector_tables()
-{
- __objc_selector_array = sarray_new (SELECTOR_HASH_SIZE, 0);
- __objc_selector_names = sarray_new (SELECTOR_HASH_SIZE, 0);
- __objc_selector_hash
- = hash_new (SELECTOR_HASH_SIZE,
- (hash_func_type) hash_string,
- (compare_func_type) compare_strings);
-}
-
-/* This routine is given a class and records all of the methods in its class
- structure in the record table. */
-void
-__objc_register_selectors_from_class (Class class)
-{
- MethodList_t method_list;
-
- method_list = class->methods;
- while (method_list)
- {
- register_selectors_from_list (method_list);
- method_list = method_list->method_next;
- }
-}
-
-
-/* This routine is given a list of methods and records each of the methods in
- the record table. This is the routine that does the actual recording
- work.
-
- This one is only called for Class objects. For categories,
- class_add_method_list is called.
- */
-static void
-register_selectors_from_list (MethodList_t method_list)
-{
- int i = 0;
- while (i < method_list->method_count)
- {
- Method_t method = &method_list->method_list[i];
- method->method_name
- = sel_register_typed_name ((const char*)method->method_name,
- method->method_types);
- i += 1;
- }
-}
-
-
-/* Register instance methods as class methods for root classes */
-void __objc_register_instance_methods_to_class(Class class)
-{
- MethodList_t method_list;
- MethodList_t class_method_list;
- int max_methods_no = 16;
- MethodList_t new_list;
- Method_t curr_method;
-
- /* Only if a root class. */
- if(class->super_class)
- return;
-
- /* Allocate a method list to hold the new class methods */
- new_list = objc_calloc(sizeof(struct objc_method_list)
- + sizeof(struct objc_method[max_methods_no]), 1);
- method_list = class->methods;
- class_method_list = class->class_pointer->methods;
- curr_method = &new_list->method_list[0];
-
- /* Iterate through the method lists for the class */
- while (method_list)
- {
- int i;
-
- /* Iterate through the methods from this method list */
- for (i = 0; i < method_list->method_count; i++)
- {
- Method_t mth = &method_list->method_list[i];
- if (mth->method_name
- && !search_for_method_in_list (class_method_list,
- mth->method_name))
- {
- /* This instance method isn't a class method.
- Add it into the new_list. */
- *curr_method = *mth;
-
- /* Reallocate the method list if necessary */
- if(++new_list->method_count == max_methods_no)
- new_list =
- objc_realloc(new_list, sizeof(struct objc_method_list)
- + sizeof(struct
- objc_method[max_methods_no += 16]));
- curr_method = &new_list->method_list[new_list->method_count];
- }
- }
-
- method_list = method_list->method_next;
- }
-
- /* If we created any new class methods
- then attach the method list to the class */
- if (new_list->method_count)
- {
- new_list =
- objc_realloc(new_list, sizeof(struct objc_method_list)
- + sizeof(struct objc_method[new_list->method_count]));
- new_list->method_next = class->class_pointer->methods;
- class->class_pointer->methods = new_list;
- }
-
- __objc_update_dispatch_table_for_class (class->class_pointer);
-}
-
-
-/* Returns YES iff t1 and t2 have same method types, but we ignore
- the argframe layout */
-BOOL
-sel_types_match (const char* t1, const char* t2)
-{
- if (!t1 || !t2)
- return NO;
- while (*t1 && *t2)
- {
- if (*t1 == '+') t1++;
- if (*t2 == '+') t2++;
- while (isdigit(*t1)) t1++;
- while (isdigit(*t2)) t2++;
- /* xxx Remove these next two lines when qualifiers are put in
- all selectors, not just Protocol selectors. */
- t1 = objc_skip_type_qualifiers(t1);
- t2 = objc_skip_type_qualifiers(t2);
- if (!*t1 && !*t2)
- return YES;
- if (*t1 != *t2)
- return NO;
- t1++;
- t2++;
- }
- return NO;
-}
-
-/* return selector representing name */
-SEL
-sel_get_typed_uid (const char *name, const char *types)
-{
- struct objc_list *l;
- sidx i;
-
- objc_mutex_lock(__objc_runtime_mutex);
-
- i = (sidx) hash_value_for_key (__objc_selector_hash, name);
- if (i == 0)
- {
- objc_mutex_unlock(__objc_runtime_mutex);
- return 0;
- }
-
- for (l = (struct objc_list*)sarray_get_safe (__objc_selector_array, i);
- l; l = l->tail)
- {
- SEL s = (SEL)l->head;
- if (types == 0 || s->sel_types == 0)
- {
- if (s->sel_types == types)
- {
- objc_mutex_unlock(__objc_runtime_mutex);
- return s;
- }
- }
- else if (sel_types_match (s->sel_types, types))
- {
- objc_mutex_unlock(__objc_runtime_mutex);
- return s;
- }
- }
-
- objc_mutex_unlock(__objc_runtime_mutex);
- return 0;
-}
-
-/* Return selector representing name; prefer a selector with non-NULL type */
-SEL
-sel_get_any_typed_uid (const char *name)
-{
- struct objc_list *l;
- sidx i;
- SEL s = NULL;
-
- objc_mutex_lock(__objc_runtime_mutex);
-
- i = (sidx) hash_value_for_key (__objc_selector_hash, name);
- if (i == 0)
- {
- objc_mutex_unlock(__objc_runtime_mutex);
- return 0;
- }
-
- for (l = (struct objc_list*)sarray_get_safe (__objc_selector_array, i);
- l; l = l->tail)
- {
- s = (SEL) l->head;
- if (s->sel_types)
- {
- objc_mutex_unlock(__objc_runtime_mutex);
- return s;
- }
- }
-
- objc_mutex_unlock(__objc_runtime_mutex);
- return s;
-}
-
-/* return selector representing name */
-SEL
-sel_get_any_uid (const char *name)
-{
- struct objc_list *l;
- sidx i;
-
- objc_mutex_lock(__objc_runtime_mutex);
-
- i = (sidx) hash_value_for_key (__objc_selector_hash, name);
- if (soffset_decode (i) == 0)
- {
- objc_mutex_unlock(__objc_runtime_mutex);
- return 0;
- }
-
- l = (struct objc_list*)sarray_get_safe (__objc_selector_array, i);
- objc_mutex_unlock(__objc_runtime_mutex);
-
- if (l == 0)
- return 0;
-
- return (SEL)l->head;
-}
-
-/* return selector representing name */
-SEL
-sel_get_uid (const char *name)
-{
- return sel_register_typed_name (name, 0);
-}
-
-/* Get name of selector. If selector is unknown, the empty string ""
- is returned */
-const char*
-sel_get_name (SEL selector)
-{
- const char *ret;
-
- objc_mutex_lock(__objc_runtime_mutex);
- if ((soffset_decode((sidx)selector->sel_id) > 0)
- && (soffset_decode((sidx)selector->sel_id) <= __objc_selector_max_index))
- ret = sarray_get_safe (__objc_selector_names, (sidx) selector->sel_id);
- else
- ret = 0;
- objc_mutex_unlock(__objc_runtime_mutex);
- return ret;
-}
-
-BOOL
-sel_is_mapped (SEL selector)
-{
- unsigned int idx = soffset_decode ((sidx)selector->sel_id);
- return ((idx > 0) && (idx <= __objc_selector_max_index));
-}
-
-
-const char*
-sel_get_type (SEL selector)
-{
- if (selector)
- return selector->sel_types;
- else
- return 0;
-}
-
-/* The uninstalled dispatch table */
-extern struct sarray* __objc_uninstalled_dtable;
-
-/* Store the passed selector name in the selector record and return its
- selector value (value returned by sel_get_uid).
- Assumes that the calling function has locked down __objc_runtime_mutex. */
-/* is_const parameter tells us if the name and types parameters
- are really constant or not. If YES then they are constant and
- we can just store the pointers. If NO then we need to copy
- name and types because the pointers may disappear later on. */
-SEL
-__sel_register_typed_name (const char *name, const char *types,
- struct objc_selector *orig, BOOL is_const)
-{
- struct objc_selector* j;
- sidx i;
- struct objc_list *l;
-
- i = (sidx) hash_value_for_key (__objc_selector_hash, name);
- if (soffset_decode (i) != 0)
- {
- for (l = (struct objc_list*)sarray_get_safe (__objc_selector_array, i);
- l; l = l->tail)
- {
- SEL s = (SEL)l->head;
- if (types == 0 || s->sel_types == 0)
- {
- if (s->sel_types == types)
- {
- if (orig)
- {
- orig->sel_id = (void*)i;
- return orig;
- }
- else
- return s;
- }
- }
- else if (!strcmp (s->sel_types, types))
- {
- if (orig)
- {
- orig->sel_id = (void*)i;
- return orig;
- }
- else
- return s;
- }
- }
- if (orig)
- j = orig;
- else
- j = objc_malloc (sizeof (struct objc_selector));
-
- j->sel_id = (void*)i;
- /* Can we use the pointer or must copy types? Don't copy if NULL */
- if ((is_const) || (types == 0))
- j->sel_types = (const char*)types;
- else {
- j->sel_types = (char *) objc_malloc(strlen(types)+1);
- strcpy((char *)j->sel_types, types);
- }
- l = (struct objc_list*)sarray_get_safe (__objc_selector_array, i);
- }
- else
- {
- __objc_selector_max_index += 1;
- i = soffset_encode(__objc_selector_max_index);
- if (orig)
- j = orig;
- else
- j = objc_malloc (sizeof (struct objc_selector));
-
- j->sel_id = (void*)i;
- /* Can we use the pointer or must copy types? Don't copy if NULL */
- if ((is_const) || (types == 0))
- j->sel_types = (const char*)types;
- else {
- j->sel_types = (char *) objc_malloc(strlen(types)+1);
- strcpy((char *)j->sel_types, types);
- }
- l = 0;
- }
-
- DEBUG_PRINTF ("Record selector %s[%s] as: %ld\n", name, types,
- soffset_decode (i));
-
- {
- int is_new = (l == 0);
- const char *new_name;
-
- /* Can we use the pointer or must copy name? Don't copy if NULL */
- if ((is_const) || (name == 0))
- new_name = name;
- else {
- new_name = (char *) objc_malloc(strlen(name)+1);
- strcpy((char *)new_name, name);
- }
-
- l = list_cons ((void*)j, l);
- sarray_at_put_safe (__objc_selector_names, i, (void *) new_name);
- sarray_at_put_safe (__objc_selector_array, i, (void *) l);
- if (is_new)
- hash_add (&__objc_selector_hash, (void *) new_name, (void *) i);
- }
-
- sarray_realloc(__objc_uninstalled_dtable, __objc_selector_max_index+1);
-
- return (SEL) j;
-}
-
-SEL
-sel_register_name (const char *name)
-{
- SEL ret;
-
- objc_mutex_lock(__objc_runtime_mutex);
- /* Assume that name is not constant static memory and needs to be
- copied before put into a runtime structure. is_const == NO */
- ret = __sel_register_typed_name (name, 0, 0, NO);
- objc_mutex_unlock(__objc_runtime_mutex);
-
- return ret;
-}
-
-SEL
-sel_register_typed_name (const char *name, const char *type)
-{
- SEL ret;
-
- objc_mutex_lock(__objc_runtime_mutex);
- /* Assume that name and type are not constant static memory and need to
- be copied before put into a runtime structure. is_const == NO */
- ret = __sel_register_typed_name (name, type, 0, NO);
- objc_mutex_unlock(__objc_runtime_mutex);
-
- return ret;
-}
-
diff --git a/contrib/gcc/objc/sendmsg.c b/contrib/gcc/objc/sendmsg.c
deleted file mode 100644
index 54281220bb94..000000000000
--- a/contrib/gcc/objc/sendmsg.c
+++ /dev/null
@@ -1,653 +0,0 @@
-/* GNU Objective C Runtime message lookup
- Copyright (C) 1993, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
- Contributed by Kresten Krab Thorup
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify it under the
-terms of the GNU General Public License as published by the Free Software
-Foundation; either version 2, or (at your option) any later version.
-
-GNU CC is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
-details.
-
-You should have received a copy of the GNU General Public License along with
-GNU CC; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-/* As a special exception, if you link this library with files compiled with
- GCC to produce an executable, this does not cause the resulting executable
- to be covered by the GNU General Public License. This exception does not
- however invalidate any other reasons why the executable file might be
- covered by the GNU General Public License. */
-
-/* $FreeBSD$ */
-
-#include "../tconfig.h"
-#include "runtime.h"
-#include "sarray.h"
-#include "encoding.h"
-#include "runtime-info.h"
-
-/* this is how we hack STRUCT_VALUE to be 1 or 0 */
-#define gen_rtx(args...) 1
-#define gen_rtx_MEM(args...) 1
-#define rtx int
-
-#if !defined(STRUCT_VALUE) || STRUCT_VALUE == 0
-#define INVISIBLE_STRUCT_RETURN 1
-#else
-#define INVISIBLE_STRUCT_RETURN 0
-#endif
-
-/* The uninstalled dispatch table */
-struct sarray* __objc_uninstalled_dtable = 0; /* !T:MUTEX */
-
-/* Send +initialize to class */
-static void __objc_send_initialize(Class);
-
-static void __objc_install_dispatch_table_for_class (Class);
-
-/* Forward declare some functions */
-static void __objc_init_install_dtable(id, SEL);
-
-/* Various forwarding functions that are used based upon the
- return type for the selector.
- __objc_block_forward for structures.
- __objc_double_forward for floats/doubles.
- __objc_word_forward for pointers or types that fit in registers.
- */
-static double __objc_double_forward(id, SEL, ...);
-static id __objc_word_forward(id, SEL, ...);
-typedef struct { id many[8]; } __big;
-#if INVISIBLE_STRUCT_RETURN
-static __big
-#else
-static id
-#endif
-__objc_block_forward(id, SEL, ...);
-static Method_t search_for_method_in_hierarchy (Class class, SEL sel);
-Method_t search_for_method_in_list(MethodList_t list, SEL op);
-id nil_method(id, SEL, ...);
-
-/* Given a selector, return the proper forwarding implementation. */
-__inline__
-IMP
-__objc_get_forward_imp (SEL sel)
-{
- const char *t = sel->sel_types;
-
- if (t && (*t == '[' || *t == '(' || *t == '{')
-#ifdef OBJC_MAX_STRUCT_BY_VALUE
- && objc_sizeof_type(t) > OBJC_MAX_STRUCT_BY_VALUE
-#endif
- )
- return (IMP)__objc_block_forward;
- else if (t && (*t == 'f' || *t == 'd'))
- return (IMP)__objc_double_forward;
- else
- return (IMP)__objc_word_forward;
-}
-
-/* Given a class and selector, return the selector's implementation. */
-__inline__
-IMP
-get_imp (Class class, SEL sel)
-{
- void* res = sarray_get_safe (class->dtable, (size_t) sel->sel_id);
- if (res == 0)
- {
- /* Not a valid method */
- if(class->dtable == __objc_uninstalled_dtable)
- {
- /* The dispatch table needs to be installed. */
- objc_mutex_lock(__objc_runtime_mutex);
- __objc_install_dispatch_table_for_class (class);
- objc_mutex_unlock(__objc_runtime_mutex);
- /* Call ourselves with the installed dispatch table
- and get the real method */
- res = get_imp(class, sel);
- }
- else
- {
- /* The dispatch table has been installed so the
- method just doesn't exist for the class.
- Return the forwarding implementation. */
- res = __objc_get_forward_imp(sel);
- }
- }
- return res;
-}
-
-/* Query if an object can respond to a selector, returns YES if the
-object implements the selector otherwise NO. Does not check if the
-method can be forwarded. */
-__inline__
-BOOL
-__objc_responds_to (id object, SEL sel)
-{
- void* res;
-
- /* Install dispatch table if need be */
- if (object->class_pointer->dtable == __objc_uninstalled_dtable)
- {
- objc_mutex_lock(__objc_runtime_mutex);
- __objc_install_dispatch_table_for_class (object->class_pointer);
- objc_mutex_unlock(__objc_runtime_mutex);
- }
-
- /* Get the method from the dispatch table */
- res = sarray_get_safe (object->class_pointer->dtable, (size_t) sel->sel_id);
- return (res != 0);
-}
-
-/* This is the lookup function. All entries in the table are either a
- valid method *or* zero. If zero then either the dispatch table
- needs to be installed or it doesn't exist and forwarding is attempted. */
-__inline__
-IMP
-objc_msg_lookup(id receiver, SEL op)
-{
- IMP result;
- if(receiver)
- {
- result = sarray_get_safe (receiver->class_pointer->dtable,
- (sidx)op->sel_id);
- if (result == 0)
- {
- /* Not a valid method */
- if(receiver->class_pointer->dtable == __objc_uninstalled_dtable)
- {
- /* The dispatch table needs to be installed.
- This happens on the very first method call to the class. */
- __objc_init_install_dtable(receiver, op);
-
- /* Get real method for this in newly installed dtable */
- result = get_imp(receiver->class_pointer, op);
- }
- else
- {
- /* The dispatch table has been installed so the
- method just doesn't exist for the class.
- Attempt to forward the method. */
- result = __objc_get_forward_imp(op);
- }
- }
- return result;
- }
- else
- return nil_method;
-}
-
-IMP
-objc_msg_lookup_super (Super_t super, SEL sel)
-{
- if (super->self)
- return get_imp (super->class, sel);
- else
- return nil_method;
-}
-
-int method_get_sizeof_arguments (Method*);
-
-retval_t
-objc_msg_sendv(id object, SEL op, arglist_t arg_frame)
-{
- Method* m = class_get_instance_method(object->class_pointer, op);
- const char *type;
- *((id*)method_get_first_argument (m, arg_frame, &type)) = object;
- *((SEL*)method_get_next_argument (arg_frame, &type)) = op;
- return __builtin_apply((apply_t)m->method_imp,
- arg_frame,
- method_get_sizeof_arguments (m));
-}
-
-void
-__objc_init_dispatch_tables()
-{
- __objc_uninstalled_dtable
- = sarray_new(200, 0);
-}
-
-/* This function is called by objc_msg_lookup when the
- dispatch table needs to be installed; thus it is called once
- for each class, namely when the very first message is sent to it. */
-static void
-__objc_init_install_dtable(id receiver, SEL op)
-{
- /* This may happen, if the programmer has taken the address of a
- method before the dtable was initialized... too bad for him! */
- if(receiver->class_pointer->dtable != __objc_uninstalled_dtable)
- return;
-
- objc_mutex_lock(__objc_runtime_mutex);
-
- if(CLS_ISCLASS(receiver->class_pointer))
- {
- /* receiver is an ordinary object */
- assert(CLS_ISCLASS(receiver->class_pointer));
-
- /* install instance methods table */
- __objc_install_dispatch_table_for_class (receiver->class_pointer);
-
- /* call +initialize -- this will in turn install the factory
- dispatch table if not already done :-) */
- __objc_send_initialize(receiver->class_pointer);
- }
- else
- {
- /* receiver is a class object */
- assert(CLS_ISCLASS((Class)receiver));
- assert(CLS_ISMETA(receiver->class_pointer));
-
- /* Install real dtable for factory methods */
- __objc_install_dispatch_table_for_class (receiver->class_pointer);
-
- if (strcmp (sel_get_name (op), "initialize"))
- __objc_send_initialize((Class)receiver);
- else
- CLS_SETINITIALIZED((Class)receiver);
- }
- objc_mutex_unlock(__objc_runtime_mutex);
-}
-
-/* Install dummy table for class which causes the first message to
- that class (or instances hereof) to be initialized properly */
-void
-__objc_install_premature_dtable(Class class)
-{
- assert(__objc_uninstalled_dtable);
- class->dtable = __objc_uninstalled_dtable;
-}
-
-/* Send +initialize to class if not already done */
-static void
-__objc_send_initialize(Class class)
-{
- /* This *must* be a class object */
- assert(CLS_ISCLASS(class));
- assert(!CLS_ISMETA(class));
-
- if (!CLS_ISINITIALIZED(class))
- {
- CLS_SETINITIALIZED(class);
- CLS_SETINITIALIZED(class->class_pointer);
-
- if(class->super_class)
- __objc_send_initialize(class->super_class);
-
- {
- SEL op = sel_register_name ("initialize");
- Class tmpclass = class;
- IMP imp = 0;
-
- while (!imp && tmpclass) {
- MethodList_t method_list = tmpclass->class_pointer->methods;
-
- while(!imp && method_list) {
- int i;
- Method_t method;
-
- for (i=0;i<method_list->method_count;i++) {
- method = &(method_list->method_list[i]);
- if (method->method_name
- && method->method_name->sel_id == op->sel_id) {
- imp = method->method_imp;
- break;
- }
- }
-
- method_list = method_list->method_next;
-
- }
-
- tmpclass = tmpclass->super_class;
- }
- if (imp)
- (*imp)((id)class, op);
-
- }
- }
-}
-
-/* Walk on the methods list of class and install the methods in the reverse
- order of the lists. Since methods added by categories are before the methods
- of class in the methods list, this allows categories to substitute methods
- declared in class. However if more than one category replaces the same
- method nothing is guaranteed about what method will be used.
- Assumes that __objc_runtime_mutex is locked down. */
-static void
-__objc_install_methods_in_dtable (Class class, MethodList_t method_list)
-{
- int i;
-
- if (!method_list)
- return;
-
- if (method_list->method_next)
- __objc_install_methods_in_dtable (class, method_list->method_next);
-
- for (i = 0; i < method_list->method_count; i++)
- {
- Method_t method = &(method_list->method_list[i]);
- sarray_at_put_safe (class->dtable,
- (sidx) method->method_name->sel_id,
- method->method_imp);
- }
-}
-
-/* Assumes that __objc_runtime_mutex is locked down. */
-static void
-__objc_install_dispatch_table_for_class (Class class)
-{
- Class super;
-
- /* If the class has not yet had its class links resolved, we must
- re-compute all class links */
- if(!CLS_ISRESOLV(class))
- __objc_resolve_class_links();
-
- super = class->super_class;
-
- if (super != 0 && (super->dtable == __objc_uninstalled_dtable))
- __objc_install_dispatch_table_for_class (super);
-
- /* Allocate dtable if necessary */
- if (super == 0)
- {
- objc_mutex_lock(__objc_runtime_mutex);
- class->dtable = sarray_new (__objc_selector_max_index, 0);
- objc_mutex_unlock(__objc_runtime_mutex);
- }
- else
- class->dtable = sarray_lazy_copy (super->dtable);
-
- __objc_install_methods_in_dtable (class, class->methods);
-}
-
-void
-__objc_update_dispatch_table_for_class (Class class)
-{
- Class next;
- struct sarray *arr;
-
- /* not yet installed -- skip it */
- if (class->dtable == __objc_uninstalled_dtable)
- return;
-
- objc_mutex_lock(__objc_runtime_mutex);
-
- arr = class->dtable;
- __objc_install_premature_dtable (class); /* someone might require it... */
- sarray_free (arr); /* release memory */
-
- /* could have been lazy... */
- __objc_install_dispatch_table_for_class (class);
-
- if (class->subclass_list) /* Traverse subclasses */
- for (next = class->subclass_list; next; next = next->sibling_class)
- __objc_update_dispatch_table_for_class (next);
-
- objc_mutex_unlock(__objc_runtime_mutex);
-}
-
-
-/* This function adds a method list to a class. This function is
- typically called by another function specific to the run-time. As
- such this function does not worry about thread safe issues.
-
- This one is only called for categories. Class objects have their
- methods installed right away, and their selectors are made into
- SEL's by the function __objc_register_selectors_from_class. */
-void
-class_add_method_list (Class class, MethodList_t list)
-{
- int i;
-
- /* Passing of a linked list is not allowed. Do multiple calls. */
- assert (!list->method_next);
-
- /* Check for duplicates. */
- for (i = 0; i < list->method_count; ++i)
- {
- Method_t method = &list->method_list[i];
-
- if (method->method_name) /* Sometimes these are NULL */
- {
- /* This is where selector names are transmogrified to SEL's */
- method->method_name =
- sel_register_typed_name ((const char*)method->method_name,
- method->method_types);
- }
- }
-
- /* Add the methods to the class's method list. */
- list->method_next = class->methods;
- class->methods = list;
-
- /* Update the dispatch table of class */
- __objc_update_dispatch_table_for_class (class);
-}
-
-Method_t
-class_get_instance_method(Class class, SEL op)
-{
- return search_for_method_in_hierarchy(class, op);
-}
-
-Method_t
-class_get_class_method(MetaClass class, SEL op)
-{
- return search_for_method_in_hierarchy(class, op);
-}
-
-
-/* Search for a method starting from the current class up its hierarchy.
- Return a pointer to the method's method structure if found. NULL
- otherwise. */
-
-static Method_t
-search_for_method_in_hierarchy (Class cls, SEL sel)
-{
- Method_t method = NULL;
- Class class;
-
- if (! sel_is_mapped (sel))
- return NULL;
-
- /* Scan the method list of the class. If the method isn't found in the
- list then step to its super class. */
- for (class = cls; ((! method) && class); class = class->super_class)
- method = search_for_method_in_list (class->methods, sel);
-
- return method;
-}
-
-
-
-/* Given a linked list of method and a method's name. Search for the named
- method's method structure. Return a pointer to the method's method
- structure if found. NULL otherwise. */
-Method_t
-search_for_method_in_list (MethodList_t list, SEL op)
-{
- MethodList_t method_list = list;
-
- if (! sel_is_mapped (op))
- return NULL;
-
- /* If not found then we'll search the list. */
- while (method_list)
- {
- int i;
-
- /* Search the method list. */
- for (i = 0; i < method_list->method_count; ++i)
- {
- Method_t method = &method_list->method_list[i];
-
- if (method->method_name)
- if (method->method_name->sel_id == op->sel_id)
- return method;
- }
-
- /* The method wasn't found. Follow the link to the next list of
- methods. */
- method_list = method_list->method_next;
- }
-
- return NULL;
-}
-
-static retval_t __objc_forward (id object, SEL sel, arglist_t args);
-
-/* Forwarding pointers/integers through the normal registers */
-static id
-__objc_word_forward (id rcv, SEL op, ...)
-{
- void *args, *res;
-
- args = __builtin_apply_args ();
- res = __objc_forward (rcv, op, args);
- if (res)
- __builtin_return (res);
- else
- return res;
-}
-
-/* Specific routine for forwarding floats/double because of
- architectural differences on some processors. i386s for
- example which uses a floating point stack versus general
- registers for floating point numbers. This forward routine
- makes sure that GCC restores the proper return values */
-static double
-__objc_double_forward (id rcv, SEL op, ...)
-{
- void *args, *res;
-
- args = __builtin_apply_args ();
- res = __objc_forward (rcv, op, args);
- __builtin_return (res);
-}
-
-#if INVISIBLE_STRUCT_RETURN
-static __big
-#else
-static id
-#endif
-__objc_block_forward (id rcv, SEL op, ...)
-{
- void *args, *res;
-
- args = __builtin_apply_args ();
- res = __objc_forward (rcv, op, args);
- if (res)
- __builtin_return (res);
- else
-#if INVISIBLE_STRUCT_RETURN
- return (__big) {{0, 0, 0, 0, 0, 0, 0, 0}};
-#else
- return nil;
-#endif
-}
-
-
-/* This function is installed in the dispatch table for all methods which are
- not implemented. Thus, it is called when a selector is not recognized. */
-static retval_t
-__objc_forward (id object, SEL sel, arglist_t args)
-{
- IMP imp;
- static SEL frwd_sel = 0; /* !T:SAFE2 */
- SEL err_sel;
-
- /* first try if the object understands forward:: */
- if (!frwd_sel)
- frwd_sel = sel_get_any_uid("forward::");
-
- if (__objc_responds_to (object, frwd_sel))
- {
- imp = get_imp(object->class_pointer, frwd_sel);
- return (*imp)(object, frwd_sel, sel, args);
- }
-
- /* If the object recognizes the doesNotRecognize: method then we're going
- to send it. */
- err_sel = sel_get_any_uid ("doesNotRecognize:");
- if (__objc_responds_to (object, err_sel))
- {
- imp = get_imp (object->class_pointer, err_sel);
- return (*imp) (object, err_sel, sel);
- }
-
- /* The object doesn't recognize the method. Check for responding to
- error:. If it does then sent it. */
- {
- size_t strlen (const char*);
- char msg[256 + strlen ((const char*)sel_get_name (sel))
- + strlen ((const char*)object->class_pointer->name)];
-
- sprintf (msg, "(%s) %s does not recognize %s",
- (CLS_ISMETA(object->class_pointer)
- ? "class"
- : "instance" ),
- object->class_pointer->name, sel_get_name (sel));
-
- err_sel = sel_get_any_uid ("error:");
- if (__objc_responds_to (object, err_sel))
- {
- imp = get_imp (object->class_pointer, err_sel);
- return (*imp) (object, sel_get_any_uid ("error:"), msg);
- }
-
- /* The object doesn't respond to doesNotRecognize: or error:; Therefore,
- a default action is taken. */
- objc_error (object, OBJC_ERR_UNIMPLEMENTED, "%s\n", msg);
-
- return 0;
- }
-}
-
-void
-__objc_print_dtable_stats()
-{
- int total = 0;
-
- objc_mutex_lock(__objc_runtime_mutex);
-
- printf("memory usage: (%s)\n",
-#ifdef OBJC_SPARSE2
- "2-level sparse arrays"
-#else
- "3-level sparse arrays"
-#endif
- );
-
- printf("arrays: %d = %ld bytes\n", narrays,
- (long)narrays*sizeof(struct sarray));
- total += narrays*sizeof(struct sarray);
- printf("buckets: %d = %ld bytes\n", nbuckets,
- (long)nbuckets*sizeof(struct sbucket));
- total += nbuckets*sizeof(struct sbucket);
-
- printf("idxtables: %d = %ld bytes\n", idxsize, (long)idxsize*sizeof(void*));
- total += idxsize*sizeof(void*);
- printf("-----------------------------------\n");
- printf("total: %d bytes\n", total);
- printf("===================================\n");
-
- objc_mutex_unlock(__objc_runtime_mutex);
-}
-
-/* Returns the uninstalled dispatch table indicator.
- If a class' dispatch table points to __objc_uninstalled_dtable
- then that means it needs its dispatch table to be installed. */
-__inline__
-struct sarray*
-objc_get_uninstalled_dtable()
-{
- return __objc_uninstalled_dtable;
-}
diff --git a/contrib/gcc/objc/typedstream.h b/contrib/gcc/objc/typedstream.h
deleted file mode 100644
index eb4642f344be..000000000000
--- a/contrib/gcc/objc/typedstream.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/* GNU Objective-C Typed Streams interface.
- Copyright (C) 1993, 1995 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option) any
-later version.
-
-GNU CC is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
-License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-/* As a special exception, if you link this library with files compiled
- with GCC to produce an executable, this does not cause the resulting
- executable to be covered by the GNU General Public License. This
- exception does not however invalidate any other reasons why the
- executable file might be covered by the GNU General Public License. */
-
-#ifndef __typedstream_INCLUDE_GNU
-#define __typedstream_INCLUDE_GNU
-
-#include "objc/objc.h"
-#include "objc/hash.h"
-#include <stdio.h>
-
-typedef int (*objc_typed_read_func)(void*, char*, int);
-typedef int (*objc_typed_write_func)(void*, const char*, int);
-typedef int (*objc_typed_flush_func)(void*);
-typedef int (*objc_typed_eof_func)(void*);
-
-#define OBJC_READONLY 0x01
-#define OBJC_WRITEONLY 0x02
-
-#define OBJC_MANAGED_STREAM 0x01
-#define OBJC_FILE_STREAM 0x02
-#define OBJC_MEMORY_STREAM 0x04
-
-#define OBJC_TYPED_STREAM_VERSION 0x01
-
-typedef struct objc_typed_stream {
- void* physical;
- cache_ptr object_table; /* read/written objects */
- cache_ptr stream_table; /* other read/written but shared things.. */
- cache_ptr class_table; /* class version mapping */
- cache_ptr object_refs; /* forward references */
- int mode; /* OBJC_READONLY or OBJC_WRITEONLY */
- int type; /* MANAGED, FILE, MEMORY etc bit string */
- int version; /* version used when writing */
- int writing_root_p;
- objc_typed_read_func read;
- objc_typed_write_func write;
- objc_typed_eof_func eof;
- objc_typed_flush_func flush;
-} TypedStream;
-
-/* opcode masks */
-#define _B_VALUE 0x1fU
-#define _B_CODE 0xe0U
-#define _B_SIGN 0x10U
-#define _B_NUMBER 0x0fU
-
-/* standard opcodes */
-#define _B_INVALID 0x00U
-#define _B_SINT 0x20U
-#define _B_NINT 0x40U
-#define _B_SSTR 0x60U
-#define _B_NSTR 0x80U
-#define _B_RCOMM 0xa0U
-#define _B_UCOMM 0xc0U
-#define _B_EXT 0xe0U
-
-/* eXtension opcodes */
-#define _BX_OBJECT 0x00U
-#define _BX_CLASS 0x01U
-#define _BX_SEL 0x02U
-#define _BX_OBJREF 0x03U
-#define _BX_OBJROOT 0x04U
-#define _BX_EXT 0x1fU
-
-/*
-** Read and write objects as specified by TYPE. All the `last'
-** arguments are pointers to the objects to read/write.
-*/
-
-int objc_write_type (TypedStream* stream, const char* type, const void* data);
-int objc_read_type (TypedStream* stream, const char* type, void* data);
-
-int objc_write_types (TypedStream* stream, const char* type, ...);
-int objc_read_types (TypedStream* stream, const char* type, ...);
-
-int objc_write_object_reference (TypedStream* stream, id object);
-int objc_write_root_object (TypedStream* stream, id object);
-
-long objc_get_stream_class_version (TypedStream* stream, Class class);
-
-
-/*
-** Convenience functions
-*/
-
-int objc_write_array (TypedStream* stream, const char* type,
- int count, const void* data);
-int objc_read_array (TypedStream* stream, const char* type,
- int count, void* data);
-
-int objc_write_object (TypedStream* stream, id object);
-int objc_read_object (TypedStream* stream, id* object);
-
-
-
-/*
-** Open a typed stream for reading or writing. MODE may be either of
-** OBJC_READONLY or OBJC_WRITEONLY.
-*/
-
-TypedStream* objc_open_typed_stream (FILE* physical, int mode);
-TypedStream* objc_open_typed_stream_for_file (const char* file_name, int mode);
-
-void objc_close_typed_stream (TypedStream* stream);
-
-BOOL objc_end_of_typed_stream (TypedStream* stream);
-void objc_flush_typed_stream (TypedStream* stream);
-
-#endif /* not __typedstream_INCLUDE_GNU */
diff --git a/contrib/gdb/gdb/ser-ocd.c b/contrib/gdb/gdb/ser-ocd.c
deleted file mode 100644
index 971f84e049c4..000000000000
--- a/contrib/gdb/gdb/ser-ocd.c
+++ /dev/null
@@ -1,209 +0,0 @@
-/* Remote serial interface for Macraigor Systems implementation of
- On-Chip Debugging using serial target box or serial wiggler
-
- Copyright 1994, 1997 Free Software Foundation, Inc.
-
- This file is part of GDB.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-#include "serial.h"
-
-#ifdef _WIN32
-#include <windows.h>
-#endif
-
-static int ser_ocd_open PARAMS ((serial_t scb, const char *name));
-static void ser_ocd_raw PARAMS ((serial_t scb));
-static int ser_ocd_readchar PARAMS ((serial_t scb, int timeout));
-static int ser_ocd_setbaudrate PARAMS ((serial_t scb, int rate));
-static int ser_ocd_write PARAMS ((serial_t scb, const char *str, int len));
-static void ser_ocd_close PARAMS ((serial_t scb));
-static serial_ttystate ser_ocd_get_tty_state PARAMS ((serial_t scb));
-static int ser_ocd_set_tty_state PARAMS ((serial_t scb, serial_ttystate state));
-
-#ifdef _WIN32
-/* On Windows, this function pointer is initialized to a function in
- the wiggler DLL. */
-static int (*dll_do_command) PARAMS ((const char *, char *));
-#endif
-
-static int
-ocd_open (scb, name)
- serial_t scb;
- const char *name;
-{
-#ifdef _WIN32
- /* Find the wiggler DLL which talks to the board. */
- if (dll_do_command == NULL)
- {
- HINSTANCE handle;
-
- /* FIXME: Should the user be able to configure this? */
- handle = LoadLibrary ("Wigglers.dll");
- if (handle == NULL)
- error ("Can't load Wigglers.dll");
-
- dll_do_command = ((int (*) PARAMS ((const char *, char *)))
- GetProcAddress (handle, "do_command"));
- if (dll_do_command == NULL)
- error ("Can't find do_command function in Wigglers.dll");
- }
-#else
- /* No wiggler DLLs on Unix yet, fail. */
- error ("Wiggler library not available for this type of host.");
-#endif /* _WIN32 */
- return 0;
-}
-
-static int
-ocd_noop (scb)
- serial_t scb;
-{
- return 0;
-}
-
-static void
-ocd_raw (scb)
- serial_t scb;
-{
- /* Always in raw mode */
-}
-
-static void
-ocd_readremote ()
-{
-}
-
-/* We need a buffer to store responses from the Wigglers.dll */
-#define WIGGLER_BUFF_SIZE 512
-unsigned char from_wiggler_buffer[WIGGLER_BUFF_SIZE];
-unsigned char * wiggler_buffer_ptr; /* curr spot in buffer */
-
-static int
-ocd_readchar (scb, timeout)
- serial_t scb;
- int timeout;
-{
- /* Catch attempts at reading past the end of the buffer */
- if (wiggler_buffer_ptr >
- (from_wiggler_buffer + (sizeof (char *) * WIGGLER_BUFF_SIZE)))
- error ("ocd_readchar asked to read past the end of the buffer!");
-
- return (int) *wiggler_buffer_ptr++; /* return curr char and increment ptr */
-}
-
-struct ocd_ttystate {
- int dummy;
-};
-
-/* ocd_{get set}_tty_state() are both dummys to fill out the function
- vector. Someday, they may do something real... */
-
-static serial_ttystate
-ocd_get_tty_state (scb)
- serial_t scb;
-{
- struct ocd_ttystate *state;
-
- state = (struct ocd_ttystate *) xmalloc (sizeof *state);
-
- return (serial_ttystate) state;
-}
-
-static int
-ocd_set_tty_state (scb, ttystate)
- serial_t scb;
- serial_ttystate ttystate;
-{
- return 0;
-}
-
-static int
-ocd_noflush_set_tty_state (scb, new_ttystate, old_ttystate)
- serial_t scb;
- serial_ttystate new_ttystate;
- serial_ttystate old_ttystate;
-{
- return 0;
-}
-
-static void
-ocd_print_tty_state (scb, ttystate)
- serial_t scb;
- serial_ttystate ttystate;
-{
- /* Nothing to print. */
- return;
-}
-
-static int
-ocd_setbaudrate (scb, rate)
- serial_t scb;
- int rate;
-{
- return 0;
-}
-
-static int
-ocd_write (scb, str, len)
- serial_t scb;
- const char *str;
- int len;
-{
- char c;
-
-#ifdef _WIN32
- /* send packet to Wigglers.dll and store response so we can give it to
- remote-wiggler.c when get_packet is run */
- dll_do_command (str, from_wiggler_buffer);
- wiggler_buffer_ptr = from_wiggler_buffer;
-#endif
-
- return 0;
-}
-
-static void
-ocd_close (scb)
- serial_t scb;
-{
-}
-
-static struct serial_ops ocd_ops =
-{
- "ocd",
- 0,
- ocd_open,
- ocd_close,
- ocd_readchar,
- ocd_write,
- ocd_noop, /* flush output */
- ocd_noop, /* flush input */
- ocd_noop, /* send break -- currently used only for nindy */
- ocd_raw,
- ocd_get_tty_state,
- ocd_set_tty_state,
- ocd_print_tty_state,
- ocd_noflush_set_tty_state,
- ocd_setbaudrate,
- ocd_noop, /* wait for output to drain */
-};
-
-void
-_initialize_ser_ocd_bdm ()
-{
- serial_add_interface (&ocd_ops);
-}
diff --git a/contrib/groff/src/devices/grotty/grotty.man b/contrib/groff/src/devices/grotty/grotty.man
deleted file mode 100644
index 4a109ced1034..000000000000
--- a/contrib/groff/src/devices/grotty/grotty.man
+++ /dev/null
@@ -1,212 +0,0 @@
-.ig \"-*- nroff -*-
-Copyright (C) 1989-1995 Free Software Foundation, Inc.
-
-Permission is granted to make and distribute verbatim copies of
-this manual provided the copyright notice and this permission notice
-are preserved on all copies.
-
-Permission is granted to copy and distribute modified versions of this
-manual under the conditions for verbatim copying, provided that the
-entire resulting derived work is distributed under the terms of a
-permission notice identical to this one.
-
-Permission is granted to copy and distribute translations of this
-manual into another language, under the above conditions for modified
-versions, except that this permission notice may be included in
-translations approved by the Free Software Foundation instead of in
-the original English.
-..
-.TH GROTTY @MAN1EXT@ "@MDATE@" "Groff Version @VERSION@"
-.SH NAME
-grotty \- groff driver for typewriter-like devices
-.SH SYNOPSIS
-.B grotty
-[
-.B \-hfbuodBUv
-] [
-.BI \-F dir
-] [
-.IR files \|.\|.\|.
-]
-.SH DESCRIPTION
-.B grotty
-translates the output of GNU
-.B troff
-into a form suitable for typewriter-like devices.
-Normally
-.B grotty
-should invoked by using the
-.B groff
-command
-with a
-.BR \-Tascii ,
-.B \-Tkoi8-r
-or
-.B \-Tlatin1
-option.
-If no files are given,
-.B grotty
-will read the standard input.
-A filename of
-.B \-
-will also cause
-.B grotty
-to read the standard input.
-Output is written to the standard output.
-.LP
-Normally
-.B grotty
-prints a bold character
-.I c
-using the sequence
-.RI ` c
-.SM BACKSPACE
-.IR c '
-and a italic character
-.I c
-by the sequence
-.RB ` _
-.SM BACKSPACE
-.IR c '.
-These sequences can be displayed on a terminal
-by piping through
-.BR ul (1).
-Pagers such as
-.BR more (1)
-or
-.BR less (1)
-are also able to display these sequences.
-Use either
-.B \-B
-or
-.B \-U
-when piping into
-.BR less (1);
-use
-.B \-b
-when piping into
-.BR more (1).
-There is no need to filter the output through
-.BR col (1)
-since
-.B grotty
-never outputs reverse line feeds.
-.LP
-The font description file may contain a command
-.IP
-.BI internalname\ n
-.LP
-where
-.I n
-is a decimal integer.
-If the 01 bit in
-.I n
-is set,
-then the font will be treated as an italic font;
-if the 02 bit is set,
-then it will be treated as a bold font.
-The code field in the font description field gives the
-code which will be used to output the character.
-This code can also be used in the
-.B \eN
-escape sequence in
-.BR troff .
-.SH OPTIONS
-.TP
-.BI \-F dir
-Search the directory
-.IB dir /dev name
-for font and device description files;
-.I name
-is the name of the device, usually
-.BR ascii ,
-.B koi8-r
-or
-.BR latin1 .
-.TP
-.B \-h
-Use horizontal tabs in the output.
-Tabs are assumed to be set every 8 columns.
-.TP
-.B \-f
-Use form feeds in the output.
-A form feed will be output at the end of each page that has no output
-on its last line.
-.TP
-.B \-b
-Suppress the use of overstriking for bold characters.
-.TP
-.B \-u
-Suppress the use of underlining for italic characters.
-.TP
-.B \-B
-Use only overstriking for bold-italic characters.
-.TP
-.B \-U
-Use only underlining for bold-italic characters.
-.TP
-.B \-o
-Suppress overstriking (other than for bold or underlined characters).
-.TP
-.B \-d
-Ignore all
-.B \eD
-commands.
-Without this
-.B grotty
-will render
-.B \eD'l\|.\|.\|.'
-commands that have at least at least one zero argument
-(and so are either horizontal or vertical)
-using
-.BR \- ,
-.B |
-and
-.B +
-characters.
-.TP
-.B \-v
-Print the version number.
-.SH FILES
-.TP
-.B @FONTDIR@/dev\fIname\fB/DESC
-Device description file for
-.I name
-device.
-.TP
-.BI @FONTDIR@/dev\fIname\fB/ F
-Font description file for font
-.I F
-of
-.I name
-device.
-.TP
-.B @MACRODIR@/tmac.tty
-Macros for use with
-.BR grotty .
-.TP
-.B @MACRODIR@/tmac.tty-char
-Additional klugey character definitions for use with
-.BR grotty .
-.SH BUGS
-.LP
-.B grotty
-is intended only for simple documents.
-.LP
-There is no support for fractional horizontal or vertical motions.
-.LP
-There is no support for
-.B \eD
-commands
-other than horizontal and vertical lines.
-.LP
-Characters above the first line (ie with a vertical position of 0)
-cannot be printed.
-.SH "SEE ALSO"
-.BR groff (@MAN1EXT@),
-.BR @g@troff (@MAN1EXT@),
-.BR groff_out (@MAN5EXT@),
-.BR groff_font (@MAN5EXT@),
-.BR groff_char (@MAN7EXT@),
-.BR ul (1),
-.BR more (1)
diff --git a/contrib/groff/src/libs/libgroff/illegal.cc b/contrib/groff/src/libs/libgroff/illegal.cc
deleted file mode 100644
index ca9e0888e37c..000000000000
--- a/contrib/groff/src/libs/libgroff/illegal.cc
+++ /dev/null
@@ -1,22 +0,0 @@
-#include "lib.h"
-
-// Table of illegal input characters.
-
-char illegal_char_table[256]= {
- 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 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, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 1, 1, 1, 1, 1, 1, 1, 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, 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,
-};
diff --git a/contrib/groff/src/preproc/eqn/neqn.sh b/contrib/groff/src/preproc/eqn/neqn.sh
deleted file mode 100644
index f33b68e3b350..000000000000
--- a/contrib/groff/src/preproc/eqn/neqn.sh
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/sh
-# Provision of this shell script should not be taken to imply that use of
-# GNU eqn with groff -Tascii|-Tlatin1 is supported.
-
-# Default device.
-locale=${LC_CTYPE:-$LANG}
-if test `expr "$locale" : ".*\.ISO_8859-1"` -gt 0
-then
- T=latin1
-else
-if test `expr "$locale" : ".*\.KOI8-R"` -gt 0
-then
- T=koi8-r
-else
- T=ascii
-fi
-fi
-
-exec @g@eqn -T${T} ${1+"$@"}
diff --git a/contrib/groff/src/roff/groff/groff.man b/contrib/groff/src/roff/groff/groff.man
deleted file mode 100644
index 1f95a779f2d7..000000000000
--- a/contrib/groff/src/roff/groff/groff.man
+++ /dev/null
@@ -1,434 +0,0 @@
-.ig \"-*- nroff -*-
-Copyright (C) 1999 Free Software Foundation, Inc.
-
-Permission is granted to make and distribute verbatim copies of
-this manual provided the copyright notice and this permission notice
-are preserved on all copies.
-
-Permission is granted to copy and distribute modified versions of this
-manual under the conditions for verbatim copying, provided that the
-entire resulting derived work is distributed under the terms of a
-permission notice identical to this one.
-
-Permission is granted to copy and distribute translations of this
-manual into another language, under the above conditions for modified
-versions, except that this permission notice may be included in
-translations approved by the Free Software Foundation instead of in
-the original English.
-
- $FreeBSD$
-
-..
-.de TQ
-.br
-.ns
-.TP \\$1
-..
-.\" Like TP, but if specified indent is more than half
-.\" the current line-length - indent, use the default indent.
-.de Tp
-.ie \\n(.$=0:((0\\$1)*2u>(\\n(.lu-\\n(.iu)) .TP
-.el .TP "\\$1"
-..
-.TH GROFF @MAN1EXT@ "@MDATE@" "Groff Version @VERSION@"
-.SH NAME
-groff \- front end for the groff document formatting system
-.SH SYNOPSIS
-.B groff
-[
-.B \-abehilpstvzCENRSUVXZ
-]
-[
-.BI \-w name
-]
-[
-.BI \-W name
-]
-[
-.BI \-m name
-]
-[
-.BI \-F dir
-]
-[
-.BI \-I dir
-]
-[
-.BI \-T dev
-]
-[
-.BI \-f fam
-]
-[
-.BI \-M dir
-]
-[
-.BI \-d cs
-]
-[
-.BI \-r cn
-]
-[
-.BI \-n num
-]
-[
-.BI \-o list
-]
-[
-.BI \-P arg
-]
-[
-.BI \-L arg
-]
-[
-.IR files \|.\|.\|.\|
-]
-.SH DESCRIPTION
-.B groff
-is a front-end to the groff document formatting system.
-Normally it runs the
-.B @g@troff
-program and a postprocessor appropriate for the selected
-device.
-Available devices are:
-.TP
-.B ps
-For PostScript printers and previewers
-.TP
-.B dvi
-For TeX dvi format.
-.TP
-.B X75
-For a 75 dpi X11 previewer.
-.TP
-.B X100
-For a 100dpi X11 previewer.
-.TP
-.B ascii
-For typewriter-like devices.
-.TP
-.B latin1
-For typewriter-like devices using the ISO Latin-1 character set.
-.TP
-.B lj4
-For an HP LaserJet4-compatible (or other PCL5-compatible) printer.
-.TP
-.B koi8-r
-For typewriter-like devices using the russian KOI8-R character set.
-.TP
-.B html
-To produce HTML output.
-.LP
-The postprocessor to be used for a device is specified by the
-.B postpro
-command in the device description file.
-This can be overridden with the
-.B \-X
-option.
-.LP
-The default device is
-.BR @DEVICE@ .
-It can optionally preprocess with any of
-.BR @g@pic ,
-.BR @g@eqn ,
-.BR @g@tbl ,
-.BR @g@refer ,
-or
-.B @g@soelim.
-.LP
-Options without an argument can be grouped behind a single
-.BR \- .
-A filename of
-.B \-
-denotes the standard input.
-.LP
-The
-.B grog
-command can be used to guess the correct groff command to use to
-format a file.
-.SH OPTIONS
-.TP
-.B \-h
-Print a help message.
-.TP
-.B \-e
-Preprocess with @g@eqn.
-.TP
-.B \-t
-Preprocess with @g@tbl.
-.TP
-.B \-p
-Preprocess with @g@pic.
-.TP
-.B \-s
-Preprocess with @g@soelim.
-.TP
-.BI \-I dir
-This option is as described in
-.BR @g@soelim (@MAN1EXT@) .
-This option implies the
-.B \-s
-option.
-.TP
-.B \-R
-Preprocess with @g@refer.
-No mechanism is provided for passing arguments to
-.B @g@refer
-because most @g@refer options have equivalent commands
-which can be included in the file.
-See
-.BR @g@refer (@MAN1EXT@)
-for more details.
-.TP
-.B \-v
-Make programs run by
-.B groff
-print out their version number.
-.TP
-.B \-V
-Print the pipeline on stdout instead of executing it.
-.TP
-.B \-z
-Suppress output from
-.BR @g@troff .
-Only error messages will be printed.
-.TP
-.B \-Z
-Do not postprocess the output of
-.BR @g@troff .
-Normally
-.B groff
-will automatically run the appropriate postprocessor.
-.TP
-.BI \-P arg
-Pass
-.I arg
-to the postprocessor.
-Each argument should be passed with a separate
-.B \-P
-option.
-Note that
-.B groff
-does not prepend
-.B \-
-to
-.I arg
-before passing it to the postprocessor.
-.TP
-.B \-l
-Send the output to a printer.
-The command used for this is specified by the
-.B print
-command in the device description file.
-.TP
-.BI \-L arg
-Pass
-.I arg
-to the spooler.
-Each argument should be passed with a separate
-.B \-L
-option.
-Note that
-.B groff
-does not prepend
-.B \-
-to
-.I arg
-before passing it to the postprocessor.
-.TP
-.BI \-T dev
-Prepare output for device
-.IR dev .
-The default device is
-.BR @DEVICE@ .
-.TP
-.B \-X
-Preview with
-.B gxditview
-instead of using the usual postprocessor.
-.B Groff
-passes
-.B gxditview
-a
-.B -printCommand
-option which will make the
-.B Print
-action do what
-.B groff
-would have done if the
-.B -l
-option had been given.
-This is unlikely to produce good results except with
-.BR \-Tps .
-.TP
-.B \-N
-Don't allow newlines with eqn delimiters.
-This is the same as the
-.B \-N
-option in
-.BR @g@eqn .
-.TP
-.B \-S
-Safer mode. Pass the
-.B \-S
-option to
-.B @g@pic
-and use the
-.B \%\-msafer
-macros with
-.BR @g@troff .
-(enabled by default)
-.TP
-.B \-U
-Unsafe mode. Reverts to the old unsafe behaviour.
-.TP
-.B \-a
-.TQ
-.B \-b
-.TQ
-.B \-i
-.TQ
-.B \-C
-.TQ
-.B \-E
-.TQ
-.BI \-w name
-.TQ
-.BI \-W name
-.TQ
-.BI \-m name
-.TQ
-.BI \-o list
-.TQ
-.BI \-d cs
-.TQ
-.BI \-r cn
-.TQ
-.BI \-F dir
-.TQ
-.BI \-M dir
-.TQ
-.BI \-f fam
-.TQ
-.BI \-n num
-These are as described in
-.BR @g@troff (@MAN1EXT@) .
-.SH ENVIRONMENT
-.TP
-.SM
-.B GROFF_COMMAND_PREFIX
-If this is set
-.IR X ,
-then
-.B groff
-will run
-.IB X troff
-instead of
-.BR @g@troff .
-This also applies to
-.BR tbl ,
-.BR pic ,
-.BR eqn ,
-.BR refer ,
-and
-.BR soelim .
-It does not apply to
-.BR grops ,
-.BR grodvi ,
-.BR grotty ,
-.BR grolj4 ,
-.BR grohtml ,
-and
-.BR gxditview .
-.TP
-.SM
-.B GROFF_TMAC_PATH
-A colon separated list of directories in which to search for
-macro files.
-.TP
-.SM
-.B GROFF_TYPESETTER
-Default device.
-.TP
-.SM
-.B GROFF_FONT_PATH
-A colon separated list of directories in which to search for the
-.BI dev name
-directory.
-.TP
-.SM
-.B PATH
-The search path for commands executed by
-.BR groff .
-.TP
-.SM
-.B GROFF_TMPDIR
-The directory in which temporary files will be created.
-If this is not set and
-.B
-.SM TMPDIR
-is set, temporary files will be created in that directory.
-Otherwise temporary files will be created in
-.BR /tmp .
-The
-.BR grops (@MAN1EXT@)
-and
-.BR @g@refer (@MAN1EXT@)
-commands can create temporary files.
-.SH FILES
-.Tp \w'\fB@FONTDIR@/dev\fIname\fB/DESC'u+3n
-.BI @FONTDIR@/dev name /DESC
-Device description file for device
-.IR name .
-.TP
-.BI @FONTDIR@/dev name / F
-Font file for font
-.I F
-of device
-.IR name .
-.SH AUTHOR
-James Clark <jjc@jclark.com>
-.SH BUGS
-Report bugs to bug-groff@gnu.org.
-Include a complete, self-contained example
-that will allow the bug to be reproduced,
-and say which version of groff you are using.
-.SH COPYRIGHT
-Copyright \(co 1989, 1990, 1991, 1992, 1999 Free Software Foundation, Inc.
-.LP
-groff is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
-version.
-.LP
-groff is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-.LP
-You should have received a copy of the GNU General Public License along
-with groff; see the file COPYING. If not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-.SH AVAILABILITY
-The most recent released version of groff is always available for
-anonymous ftp from ftp.gnu.org in the directory gnu/groff.
-.SH "SEE ALSO"
-.BR grog (@MAN1EXT@),
-.BR @g@troff (@MAN1EXT@),
-.BR @g@tbl (@MAN1EXT@),
-.BR @g@pic (@MAN1EXT@),
-.BR @g@eqn (@MAN1EXT@),
-.BR @g@soelim (@MAN1EXT@) ,
-.BR @g@refer (@MAN1EXT@),
-.BR grops (@MAN1EXT@),
-.BR grodvi (@MAN1EXT@),
-.BR grotty (@MAN1EXT@),
-.BR grohtml (@MAN1EXT@),
-.BR grohtml (@MAN1EXT@),
-.BR groff_font (@MAN5EXT@),
-.BR groff_out (@MAN5EXT@),
-.BR groff_man (@MAN7EXT@),
-.BR groff_ms (@MAN7EXT@),
-.BR groff_me (@MAN7EXT@),
-.BR groff_char (@MAN7EXT@),
-.BR groff_msafer (@MAN7EXT@)
diff --git a/contrib/groff/src/roff/nroff/nroff.man b/contrib/groff/src/roff/nroff/nroff.man
deleted file mode 100644
index d8d981626ddf..000000000000
--- a/contrib/groff/src/roff/nroff/nroff.man
+++ /dev/null
@@ -1,107 +0,0 @@
-.ig \"-*- nroff -*-
-Copyright (C) 1989-1999 Free Software Foundation, Inc.
-
-Permission is granted to make and distribute verbatim copies of
-this manual provided the copyright notice and this permission notice
-are preserved on all copies.
-
-Permission is granted to copy and distribute modified versions of this
-manual under the conditions for verbatim copying, provided that the
-entire resulting derived work is distributed under the terms of a
-permission notice identical to this one.
-
-Permission is granted to copy and distribute translations of this
-manual into another language, under the above conditions for modified
-versions, except that this permission notice may be included in
-translations approved by the Free Software Foundation instead of in
-the original English.
-
- $FreeBSD$
-
-..
-.TH @G@NROFF @MAN1EXT@ "@MDATE@" "Groff Version @VERSION@"
-.SH NAME
-@g@nroff \- emulate nroff command with groff
-.SH SYNOPSIS
-.B @g@nroff
-[
-.B \-h
-]
-[
-.B \-i
-]
-[
-.BI \-m name
-]
-[
-.BI \-n num
-]
-[
-.BI \-o list
-]
-[
-.BI \-p
-]
-[
-.BI \-r cn
-]
-[
-.BI \-t
-]
-[
-.BI \-T name
-]
-[
-.I file\|.\|.\|.
-]
-.SH DESCRIPTION
-The
-.B @g@nroff
-script emulates the
-.B nroff
-command using groff.
-The
-.B \-T
-option with an argument other than
-.B ascii
-and
-.B latin1
-and
-.B koi8-r
-will be ignored.
-The
-.B \-h
-option
-is equivalent to the
-.B grotty
-.B \-h
-option.
-The
-.BR \-i ,
-.BR \-n ,
-.BR \-m ,
-.BR \-p ,
-.BR \-o ,
-.B \-r
-and
-.B \-t
-options have the effect described in
-.BR @g@troff (@MAN1EXT@).
-In addition
-.B @g@nroff
-silently ignores options of
-.BR \-e ,
-.B \-q
-or
-.BR \-s .
-Options
-.B \-S
-(safer) and
-.B \-U
-(unsafe) are passed to groff.
-.B \-S
-is passed by default.
-.SH "SEE ALSO"
-.BR groff (@MAN1EXT@),
-.BR @g@troff (@MAN1EXT@),
-.BR grotty (@MAN1EXT@)
diff --git a/contrib/groff/src/roff/nroff/nroff.sh b/contrib/groff/src/roff/nroff/nroff.sh
deleted file mode 100755
index 12f3fd16a2c1..000000000000
--- a/contrib/groff/src/roff/nroff/nroff.sh
+++ /dev/null
@@ -1,77 +0,0 @@
-#!/bin/sh
-# Emulate nroff with groff.
-# $FreeBSD$
-
-prog="$0"
-# Default device.
-locale=${LC_CTYPE:-$LANG}
-if test `expr "$locale" : ".*\.ISO_8859-1"` -gt 0
-then
- T=-Tlatin1
-else
-if test `expr "$locale" : ".*\.KOI8-R"` -gt 0
-then
- T=-Tkoi8-r
-else
- T=-Tascii
-fi
-fi
-opts=
-safer=-S
-
-for i
-do
- case $1 in
- -h)
- opts="$opts -P-h"
- ;;
- -[eq]|-s*)
- # ignore these options
- ;;
- -[mrnoT])
- echo "$prog: option $1 requires an argument" >&2
- exit 1
- ;;
- -[iStp]|-[mrno]*)
- opts="$opts $1";
- ;;
-
- -Tascii|-Tlatin1|-Tkoi8-r)
- T=$1
- ;;
- -T*)
- # ignore other devices
- ;;
- -S)
- # safer behaviour
- safer=-S
- ;;
- -U)
- # unsafe behaviour
- safer=-U
- ;;
- -u*)
- # Solaris 2.2 `man' uses -u0; ignore it,
- # since `less' and `more' can use the emboldening info.
- ;;
- --)
- shift
- break
- ;;
- -)
- break
- ;;
- -*)
- echo "$prog: invalid option $1" >&2
- exit 1
- ;;
- *)
- break
- ;;
- esac
- shift
-done
-
-# This shell script is intended for use with man, so warnings are
-# probably not wanted. Also load nroff-style character definitions.
-exec groff $safer -Wall -mtty-char $T $opts ${1+"$@"}
diff --git a/contrib/libpam/modules/pam_nologin/Makefile b/contrib/libpam/modules/pam_nologin/Makefile
deleted file mode 100644
index 0769bb993120..000000000000
--- a/contrib/libpam/modules/pam_nologin/Makefile
+++ /dev/null
@@ -1,86 +0,0 @@
-#
-# This Makefile controls a build process of $(TITLE) module for
-# Linux-PAM. You should not modify this Makefile (unless you know
-# what you are doing!).
-#
-# Michael K. Johnson <johnsonm@redhat.com> 1996/10/24
-#
-
-TITLE=pam_nologin
-
-#
-
-LIBSRC = $(TITLE).c
-LIBOBJ = $(TITLE).o
-LIBOBJD = $(addprefix dynamic/,$(LIBOBJ))
-LIBOBJS = $(addprefix static/,$(LIBOBJ))
-
-dynamic/%.o : %.c
- $(CC) $(CFLAGS) $(DYNAMIC) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
-
-static/%.o : %.c
- $(CC) $(CFLAGS) $(STATIC) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
-
-
-ifdef DYNAMIC
-LIBSHARED = $(TITLE).so
-endif
-
-ifdef STATIC
-LIBSTATIC = lib$(TITLE).o
-endif
-
-####################### don't edit below #######################
-
-dummy:
-
- @echo "**** This is not a top-level Makefile "
- exit
-
-all: dirs $(LIBSHARED) $(LIBSTATIC) register
-
-dirs:
-ifdef DYNAMIC
- mkdir -p ./dynamic
-endif
-ifdef STATIC
- mkdir -p ./static
-endif
-
-register:
-ifdef STATIC
- ( cd .. ; ./register_static $(TITLE) $(TITLE)/$(LIBSTATIC) )
-endif
-
-ifdef DYNAMIC
-$(LIBOBJD): $(LIBSRC)
-
-$(LIBSHARED): $(LIBOBJD)
- $(LD_D) -o $@ $(LIBOBJD)
-endif
-
-ifdef STATIC
-$(LIBOBJS): $(LIBSRC)
-
-$(LIBSTATIC): $(LIBOBJS)
- $(LD) -r -o $@ $(LIBOBJS)
-endif
-
-install: all
- mkdir -p $(FAKEROOT)$(SECUREDIR)
-ifdef DYNAMIC
- install -m $(SHLIBMODE) $(LIBSHARED) $(FAKEROOT)$(SECUREDIR)
-endif
-
-remove:
- rm -f $(FAKEROOT)$(SECUREDIR)/$(TITLE).so
-
-clean:
- rm -f $(LIBOBJD) $(LIBOBJS) core *~
-
-extraclean: clean
- rm -f *.a *.o *.so *.bak dynamic/* static/*
-
-.c.o:
- $(CC) $(CFLAGS) -c $<
-
diff --git a/contrib/libreadline/doc/readline.3 b/contrib/libreadline/doc/readline.3
deleted file mode 100644
index 5f01b6c1a5f1..000000000000
--- a/contrib/libreadline/doc/readline.3
+++ /dev/null
@@ -1,1204 +0,0 @@
-.\"
-.\" MAN PAGE COMMENTS to
-.\"
-.\" Chet Ramey
-.\" Information Network Services
-.\" Case Western Reserve University
-.\" chet@ins.CWRU.Edu
-.\"
-.\" Last Change: Thu Dec 31 10:16:30 EST 1998
-.\"
-.TH READLINE 3 "1998 Dec 31" GNU
-.\"
-.\" File Name macro. This used to be `.PN', for Path Name,
-.\" but Sun doesn't seem to like that very much.
-.\"
-.de FN
-\fI\|\\$1\|\fP
-..
-.SH NAME
-readline \- get a line from a user with editing
-.SH SYNOPSIS
-.LP
-.nf
-.ft B
-#include <stdio.h>
-#include <readline/readline.h>
-#include <readline/history.h>
-.ft
-.fi
-.LP
-.nf
-.ft B
-char *readline (prompt)
-char *prompt;
-.ft
-.fi
-.SH COPYRIGHT
-.if n Readline is Copyright (C) 1989, 1991, 1993, 1995, 1996 by the Free Software Foundation, Inc.
-.if t Readline is Copyright \(co 1989, 1991, 1993, 1995, 1996 by the Free Software Foundation, Inc.
-.SH DESCRIPTION
-.LP
-.B readline
-will read a line from the terminal
-and return it, using
-.B prompt
-as a prompt. If
-.B prompt
-is null, no prompt is issued. The line returned is allocated with
-.IR malloc (3),
-so the caller must free it when finished. The line returned
-has the final newline removed, so only the text of the line
-remains.
-.LP
-.B readline
-offers editing capabilities while the user is entering the
-line.
-By default, the line editing commands
-are similar to those of emacs.
-A vi\-style line editing interface is also available.
-.SH RETURN VALUE
-.LP
-.B readline
-returns the text of the line read. A blank line
-returns the empty string. If
-.B EOF
-is encountered while reading a line, and the line is empty,
-.B NULL
-is returned. If an
-.B EOF
-is read with a non\-empty line, it is
-treated as a newline.
-.SH NOTATION
-.LP
-An emacs-style notation is used to denote
-keystrokes. Control keys are denoted by C\-\fIkey\fR, e.g., C\-n
-means Control\-N. Similarly,
-.I meta
-keys are denoted by M\-\fIkey\fR, so M\-x means Meta\-X. (On keyboards
-without a
-.I meta
-key, M\-\fIx\fP means ESC \fIx\fP, i.e., press the Escape key
-then the
-.I x
-key. This makes ESC the \fImeta prefix\fP.
-The combination M\-C\-\fIx\fP means ESC\-Control\-\fIx\fP,
-or press the Escape key
-then hold the Control key while pressing the
-.I x
-key.)
-.PP
-Readline commands may be given numeric
-.IR arguments ,
-which normally act as a repeat count. Sometimes, however, it is the
-sign of the argument that is significant. Passing a negative argument
-to a command that acts in the forward direction (e.g., \fBkill\-line\fP)
-causes that command to act in a backward direction. Commands whose
-behavior with arguments deviates from this are noted.
-.PP
-When a command is described as \fIkilling\fP text, the text
-deleted is saved for possible future retrieval
-(\fIyanking\fP). The killed text is saved in a
-\fIkill ring\fP. Consecutive kills cause the text to be
-accumulated into one unit, which can be yanked all at once.
-Commands which do not kill text separate the chunks of text
-on the kill ring.
-.SH INITIALIZATION FILE
-.LP
-Readline is customized by putting commands in an initialization
-file (the \fIinputrc\fP file).
-The name of this file is taken from the value of the
-.B INPUTRC
-environment variable. If that variable is unset, the default is
-.IR ~/.inputrc .
-When a program which uses the readline library starts up, the
-init file is read, and the key bindings and variables are set.
-There are only a few basic constructs allowed in the
-readline init file. Blank lines are ignored.
-Lines beginning with a \fB#\fP are comments.
-Lines beginning with a \fB$\fP indicate conditional constructs.
-Other lines denote key bindings and variable settings.
-Each program using this library may add its own commands
-and bindings.
-.PP
-For example, placing
-.RS
-.PP
-M\-Control\-u: universal\-argument
-.RE
-or
-.RS
-C\-Meta\-u: universal\-argument
-.RE
-into the
-.I inputrc
-would make M\-C\-u execute the readline command
-.IR universal\-argument .
-.PP
-The following symbolic character names are recognized while
-processing key bindings:
-.IR RUBOUT ,
-.IR DEL ,
-.IR ESC ,
-.IR LFD ,
-.IR NEWLINE ,
-.IR RET ,
-.IR RETURN ,
-.IR SPC ,
-.IR SPACE ,
-and
-.IR TAB .
-In addition to command names, readline allows keys to be bound
-to a string that is inserted when the key is pressed (a \fImacro\fP).
-.PP
-.SS Key Bindings
-.PP
-The syntax for controlling key bindings in the
-.I inputrc
-file is simple. All that is required is the name of the
-command or the text of a macro and a key sequence to which
-it should be bound. The name may be specified in one of two ways:
-as a symbolic key name, possibly with \fIMeta\-\fP or \fIControl\-\fP
-prefixes, or as a key sequence.
-When using the form \fBkeyname\fP:\^\fIfunction-name\fP or \fImacro\fP,
-.I keyname
-is the name of a key spelled out in English. For example:
-.sp
-.RS
-Control\-u: universal\-argument
-.br
-Meta\-Rubout: backward\-kill\-word
-.br
-Control\-o: ">&output"
-.RE
-.LP
-In the above example,
-.I C\-u
-is bound to the function
-.BR universal\-argument ,
-.I M-DEL
-is bound to the function
-.BR backward\-kill\-word ,
-and
-.I C\-o
-is bound to run the macro
-expressed on the right hand side (that is, to insert the text
-.I >&output
-into the line).
-.PP
-In the second form, \fB"keyseq"\fP:\^\fIfunction\-name\fP or \fImacro\fP,
-.B keyseq
-differs from
-.B keyname
-above in that strings denoting
-an entire key sequence may be specified by placing the sequence
-within double quotes. Some GNU Emacs style key escapes can be
-used, as in the following example.
-.sp
-.RS
-"\eC\-u": universal\-argument
-.br
-"\eC\-x\eC\-r": re\-read\-init\-file
-.br
-"\ee[11~": "Function Key 1"
-.RE
-.PP
-In this example,
-.I C-u
-is again bound to the function
-.BR universal\-argument .
-.I "C-x C-r"
-is bound to the function
-.BR re\-read\-init\-file ,
-and
-.I "ESC [ 1 1 ~"
-is bound to insert the text
-.BR "Function Key 1" .
-The full set of GNU Emacs style escape sequences is
-.RS
-.PD 0
-.TP
-.B \eC\-
-control prefix
-.TP
-.B \eM\-
-meta prefix
-.TP
-.B \ee
-an escape character
-.TP
-.B \e\e
-backslash
-.TP
-.B \e"
-literal "
-.TP
-.B \e'
-literal '
-.RE
-.PD
-.PP
-In addition to the GNU Emacs style escape sequences, a second
-set of backslash escapes is available:
-.RS
-.PD 0
-.TP
-.B \ea
-alert (bell)
-.TP
-.B \eb
-backspace
-.TP
-.B \ed
-delete
-.TP
-.B \ef
-form feed
-.TP
-.B \en
-newline
-.TP
-.B \er
-carriage return
-.TP
-.B \et
-horizontal tab
-.TP
-.B \ev
-vertical tab
-.TP
-.B \e\fInnn\fP
-the character whose ASCII code is the octal value \fInnn\fP
-(one to three digits)
-.TP
-.B \ex\fInnn\fP
-the character whose ASCII code is the hexadecimal value \fInnn\fP
-(one to three digits)
-.RE
-.PD
-.PP
-When entering the text of a macro, single or double quotes should
-be used to indicate a macro definition. Unquoted text
-is assumed to be a function name.
-In the macro body, the backslash escapes described above are expanded.
-Backslash will quote any other character in the macro text,
-including " and '.
-.PP
-.B Bash
-allows the current readline key bindings to be displayed or modified
-with the
-.B bind
-builtin command. The editing mode may be switched during interactive
-use by using the
-.B \-o
-option to the
-.B set
-builtin command. Other programs using this library provide
-similar mechanisms. The
-.I inputrc
-file may be edited and re-read if a program does not provide
-any other means to incorporate new bindings.
-.SS Variables
-.PP
-Readline has variables that can be used to further customize its
-behavior. A variable may be set in the
-.I inputrc
-file with a statement of the form
-.RS
-.PP
-\fBset\fP \fIvariable\-name\fP \fIvalue\fP
-.RE
-.PP
-Except where noted, readline variables can take the values
-.B On
-or
-.BR Off .
-The variables and their default values are:
-.PP
-.PD 0
-.TP
-.B bell\-style (audible)
-Controls what happens when readline wants to ring the terminal bell.
-If set to \fBnone\fP, readline never rings the bell. If set to
-\fBvisible\fP, readline uses a visible bell if one is available.
-If set to \fBaudible\fP, readline attempts to ring the terminal's bell.
-.TP
-.B comment\-begin (``#'')
-The string that is inserted in \fBvi\fP mode when the
-.B insert\-comment
-command is executed.
-This command is bound to
-.B M\-#
-in emacs mode and to
-.B #
-in vi command mode.
-.TP
-.B completion\-ignore\-case (Off)
-If set to \fBOn\fP, readline performs filename matching and completion
-in a case\-insensitive fashion.
-.TP
-.B completion\-query\-items (100)
-This determines when the user is queried about viewing
-the number of possible completions
-generated by the \fBpossible\-completions\fP command.
-It may be set to any integer value greater than or equal to
-zero. If the number of possible completions is greater than
-or equal to the value of this variable, the user is asked whether
-or not he wishes to view them; otherwise they are simply listed
-on the terminal.
-.TP
-.B convert\-meta (On)
-If set to \fBOn\fP, readline will convert characters with the
-eighth bit set to an ASCII key sequence
-by stripping the eighth bit and prepending an
-escape character (in effect, using escape as the \fImeta prefix\fP).
-.TP
-.B disable\-completion (Off)
-If set to \fBOn\fP, readline will inhibit word completion. Completion
-characters will be inserted into the line as if they had been
-mapped to \fBself-insert\fP.
-.TP
-.B editing\-mode (emacs)
-Controls whether readline begins with a set of key bindings similar
-to \fIemacs\fP or \fIvi\fP.
-.B editing\-mode
-can be set to either
-.B emacs
-or
-.BR vi .
-.TP
-.B enable\-keypad (Off)
-When set to \fBOn\fP, readline will try to enable the application
-keypad when it is called. Some systems need this to enable the
-arrow keys.
-.TP
-.B expand\-tilde (Off)
-If set to \fBon\fP, tilde expansion is performed when readline
-attempts word completion.
-.TP
-.B horizontal\-scroll\-mode (Off)
-When set to \fBOn\fP, makes readline use a single line for display,
-scrolling the input horizontally on a single screen line when it
-becomes longer than the screen width rather than wrapping to a new line.
-.TP
-.B input\-meta (Off)
-If set to \fBOn\fP, readline will enable eight-bit input (that is,
-it will not strip the high bit from the characters it reads),
-regardless of what the terminal claims it can support. The name
-.B meta\-flag
-is a synonym for this variable.
-.TP
-.B isearch\-terminators (``C\-[C\-J'')
-The string of characters that should terminate an incremental
-search without subsequently executing the character as a command.
-If this variable has not been given a value, the characters
-\fIESC\fP and \fIC\-J\fP will terminate an incremental search.
-.TP
-.B keymap (emacs)
-Set the current readline keymap. The set of legal keymap names is
-\fIemacs, emacs-standard, emacs-meta, emacs-ctlx, vi, vi-move,
-vi-command\fP, and
-.IR vi-insert .
-\fIvi\fP is equivalent to \fIvi-command\fP; \fIemacs\fP is
-equivalent to \fIemacs-standard\fP. The default value is
-.IR emacs ;
-the value of
-.B editing\-mode
-also affects the default keymap.
-.TP
-.B mark\-directories (On)
-If set to \fBOn\fP, complete<d directory names have a slash
-appended.
-.TP
-.B mark\-modified\-lines (Off)
-If set to \fBOn\fP, history lines that have been modified are displayed
-with a preceding asterisk (\fB*\fP).
-.TP
-.B output\-meta (Off)
-If set to \fBOn\fP, readline will display characters with the
-eighth bit set directly rather than as a meta-prefixed escape
-sequence.
-.TP
-.B print\-completions\-horizontally (Off)
-If set to \fBOn\fP, readline will display completions with matches
-sorted horizontally in alphabetical order, rather than down the screen.
-.TP
-.B show\-all\-if\-ambiguous (Off)
-This alters the default behavior of the completion functions. If
-set to
-.BR on ,
-words which have more than one possible completion cause the
-matches to be listed immediately instead of ringing the bell.
-.TP
-.B visible\-stats (Off)
-If set to \fBOn\fP, a character denoting a file's type as reported
-by \fBstat\fP(2) is appended to the filename when listing possible
-completions.
-.PD
-.SS Conditional Constructs
-.PP
-Readline implements a facility similar in spirit to the conditional
-compilation features of the C preprocessor which allows key
-bindings and variable settings to be performed as the result
-of tests. There are four parser directives used.
-.IP \fB$if\fP
-The
-.B $if
-construct allows bindings to be made based on the
-editing mode, the terminal being used, or the application using
-readline. The text of the test extends to the end of the line;
-no characters are required to isolate it.
-.RS
-.IP \fBmode\fP
-The \fBmode=\fP form of the \fB$if\fP directive is used to test
-whether readline is in emacs or vi mode.
-This may be used in conjunction
-with the \fBset keymap\fP command, for instance, to set bindings in
-the \fIemacs-standard\fP and \fIemacs-ctlx\fP keymaps only if
-readline is starting out in emacs mode.
-.IP \fBterm\fP
-The \fBterm=\fP form may be used to include terminal-specific
-key bindings, perhaps to bind the key sequences output by the
-terminal's function keys. The word on the right side of the
-.B =
-is tested against the full name of the terminal and the portion
-of the terminal name before the first \fB\-\fP. This allows
-.I sun
-to match both
-.I sun
-and
-.IR sun\-cmd ,
-for instance.
-.IP \fBapplication\fP
-The \fBapplication\fP construct is used to include
-application-specific settings. Each program using the readline
-library sets the \fIapplication name\fP, and an initialization
-file can test for a particular value.
-This could be used to bind key sequences to functions useful for
-a specific program. For instance, the following command adds a
-key sequence that quotes the current or previous word in Bash:
-.sp 1
-.RS
-.nf
-\fB$if\fP bash
-# Quote the current or previous word
-"\eC-xq": "\eeb\e"\eef\e""
-\fB$endif\fP
-.fi
-.RE
-.RE
-.IP \fB$endif\fP
-This command, as seen in the previous example, terminates an
-\fB$if\fP command.
-.IP \fB$else\fP
-Commands in this branch of the \fB$if\fP directive are executed if
-the test fails.
-.IP \fB$include\fP
-This directive takes a single filename as an argument and reads commands
-and bindings from that file. For example, the following directive
-would read \fI/etc/inputrc\fP:
-.sp 1
-.RS
-.nf
-\fB$include\fP \^ \fI/etc/inputrc\fP
-.fi
-.RE
-.SH SEARCHING
-.PP
-Readline provides commands for searching through the command history
-for lines containing a specified string.
-There are two search modes:
-.I incremental
-and
-.IR non-incremental .
-.PP
-Incremental searches begin before the user has finished typing the
-search string.
-As each character of the search string is typed, readline displays
-the next entry from the history matching the string typed so far.
-An incremental search requires only as many characters as needed to
-find the desired history entry.
-The characters present in the value of the \fIisearch-terminators\fP
-variable are used to terminate an incremental search.
-If that variable has not been assigned a value the Escape and
-Control-J characters will terminate an incremental search.
-Control-G will abort an incremental search and restore the original
-line.
-When the search is terminated, the history entry containing the
-search string becomes the current line.
-To find other matching entries in the history list, type Control-S or
-Control-R as appropriate.
-This will search backward or forward in the history for the next
-line matching the search string typed so far.
-Any other key sequence bound to a readline command will terminate
-the search and execute that command.
-For instance, a \fInewline\fP will terminate the search and accept
-the line, thereby executing the command from the history list.
-.PP
-Non-incremental searches read the entire search string before starting
-to search for matching history lines. The search string may be
-typed by the user or be part of the contents of the current line.
-.SH EDITING COMMANDS
-.PP
-The following is a list of the names of the commands and the default
-key sequences to which they are bound.
-Command names without an accompanying key sequence are unbound by default.
-.SS Commands for Moving
-.PP
-.PD 0
-.TP
-.B beginning\-of\-line (C\-a)
-Move to the start of the current line.
-.TP
-.B end\-of\-line (C\-e)
-Move to the end of the line.
-.TP
-.B forward\-char (C\-f)
-Move forward a character.
-.TP
-.B backward\-char (C\-b)
-Move back a character.
-.TP
-.B forward\-word (M\-f)
-Move forward to the end of the next word. Words are composed of
-alphanumeric characters (letters and digits).
-.TP
-.B backward\-word (M\-b)
-Move back to the start of this, or the previous, word. Words are
-composed of alphanumeric characters (letters and digits).
-.TP
-.B clear\-screen (C\-l)
-Clear the screen leaving the current line at the top of the screen.
-With an argument, refresh the current line without clearing the
-screen.
-.TP
-.B redraw\-current\-line
-Refresh the current line.
-.PD
-.SS Commands for Manipulating the History
-.PP
-.PD 0
-.TP
-.B accept\-line (Newline, Return)
-Accept the line regardless of where the cursor is. If this line is
-non-empty, add it to the history list. If the line is a modified
-history line, then restore the history line to its original state.
-.TP
-.B previous\-history (C\-p)
-Fetch the previous command from the history list, moving back in
-the list.
-.TP
-.B next\-history (C\-n)
-Fetch the next command from the history list, moving forward in the
-list.
-.TP
-.B beginning\-of\-history (M\-<)
-Move to the first line in the history.
-.TP
-.B end\-of\-history (M\->)
-Move to the end of the input history, i.e., the line currently being
-entered.
-.TP
-.B reverse\-search\-history (C\-r)
-Search backward starting at the current line and moving `up' through
-the history as necessary. This is an incremental search.
-.TP
-.B forward\-search\-history (C\-s)
-Search forward starting at the current line and moving `down' through
-the history as necessary. This is an incremental search.
-.TP
-.B non\-incremental\-reverse\-search\-history (M\-p)
-Search backward through the history starting at the current line
-using a non-incremental search for a string supplied by the user.
-.TP
-.B non\-incremental\-forward\-search\-history (M\-n)
-Search forward through the history using a non-incremental search
-for a string supplied by the user.
-.TP
-.B history\-search\-forward
-Search forward through the history for the string of characters
-between the start of the current line and the current cursor
-position (the \fIpoint\fP).
-This is a non-incremental search.
-.TP
-.B history\-search\-backward
-Search backward through the history for the string of characters
-between the start of the current line and the point.
-This is a non-incremental search.
-.TP
-.B yank\-nth\-arg (M\-C\-y)
-Insert the first argument to the previous command (usually
-the second word on the previous line) at point (the current
-cursor position). With an argument
-.IR n ,
-insert the \fIn\fPth word from the previous command (the words
-in the previous command begin with word 0). A negative argument
-inserts the \fIn\fPth word from the end of the previous command.
-.TP
-.B
-yank\-last\-arg (M\-.\^, M\-_\^)
-Insert the last argument to the previous command (the last word of
-the previous history entry). With an argument,
-behave exactly like \fByank\-nth\-arg\fP.
-Successive calls to \fByank\-last\-arg\fP move back through the history
-list, inserting the last argument of each line in turn.
-.PD
-.SS Commands for Changing Text
-.PP
-.PD 0
-.TP
-.B delete\-char (C\-d)
-Delete the character under the cursor. If point is at the
-beginning of the line, there are no characters in the line, and
-the last character typed was not bound to \fBBdelete\-char\fP, then return
-.SM
-.BR EOF .
-.TP
-.B backward\-delete\-char (Rubout)
-Delete the character behind the cursor. When given a numeric argument,
-save the deleted text on the kill ring.
-.TP
-.B forward\-backward\-delete\-char
-Delete the character under the cursor, unless the cursor is at the
-end of the line, in which case the character behind the cursor is
-deleted. By default, this is not bound to a key.
-.TP
-.B quoted\-insert (C\-q, C\-v)
-Add the next character that you type to the line verbatim. This is
-how to insert characters like \fBC\-q\fP, for example.
-.TP
-.B tab\-insert (M-TAB)
-Insert a tab character.
-.TP
-.B self\-insert (a,\ b,\ A,\ 1,\ !,\ ...)
-Insert the character typed.
-.TP
-.B transpose\-chars (C\-t)
-Drag the character before point forward over the character at point.
-Point moves forward as well. If point is at the end of the line, then
-transpose the two characters before point. Negative arguments don't work.
-.TP
-.B transpose\-words (M\-t)
-Drag the word behind the cursor past the word in front of the cursor
-moving the cursor over that word as well.
-.TP
-.B upcase\-word (M\-u)
-Uppercase the current (or following) word. With a negative argument,
-uppercase the previous word, but do not move point.
-.TP
-.B downcase\-word (M\-l)
-Lowercase the current (or following) word. With a negative argument,
-lowercase the previous word, but do not move point.
-.TP
-.B capitalize\-word (M\-c)
-Capitalize the current (or following) word. With a negative argument,
-capitalize the previous word, but do not move point.
-.PD
-.SS Killing and Yanking
-.PP
-.PD 0
-.TP
-.B kill\-line (C\-k)
-Kill the text from the current cursor position to the end of the line.
-.TP
-.B backward\-kill\-line (C\-x Rubout)
-Kill backward to the beginning of the line.
-.TP
-.B unix\-line\-discard (C\-u)
-Kill backward from point to the beginning of the line.
-The killed text is saved on the kill-ring.
-.\" There is no real difference between this and backward-kill-line
-.TP
-.B kill\-whole\-line
-Kill all characters on the current line, no matter where the
-cursor is.
-.TP
-.B kill\-word (M\-d)
-Kill from the cursor to the end of the current word, or if between
-words, to the end of the next word. Word boundaries are the same as
-those used by \fBforward\-word\fP.
-.TP
-.B backward\-kill\-word (M\-Rubout)
-Kill the word behind the cursor. Word boundaries are the same as
-those used by \fBbackward\-word\fP.
-.TP
-.B unix\-word\-rubout (C\-w)
-Kill the word behind the cursor, using white space as a word boundary.
-The word boundaries are different from
-.BR backward\-kill\-word .
-.TP
-.B delete\-horizontal\-space (M\-\e)
-Delete all spaces and tabs around point.
-.TP
-.B kill\-region
-Kill the text between the point and \fImark\fP (saved cursor position).
-This text is referred to as the \fIregion\fP.
-.TP
-.B copy\-region\-as\-kill
-Copy the text in the region to the kill buffer.
-.TP
-.B copy\-backward\-word
-Copy the word before point to the kill buffer.
-The word boundaries are the same as \fBbackward\-word\fP.
-.TP
-.B copy\-forward\-word
-Copy the word following point to the kill buffer.
-The word boundaries are the same as \fBforward\-word\fP.
-.TP
-.B yank (C\-y)
-Yank the top of the kill ring into the buffer at the cursor.
-.TP
-.B yank\-pop (M\-y)
-Rotate the kill ring, and yank the new top. Only works following
-.B yank
-or
-.BR yank\-pop .
-.PD
-.SS Numeric Arguments
-.PP
-.PD 0
-.TP
-.B digit\-argument (M\-0, M\-1, ..., M\-\-)
-Add this digit to the argument already accumulating, or start a new
-argument. M\-\- starts a negative argument.
-.TP
-.B universal\-argument
-This is another way to specify an argument.
-If this command is followed by one or more digits, optionally with a
-leading minus sign, those digits define the argument.
-If the command is followed by digits, executing
-.B universal\-argument
-again ends the numeric argument, but is otherwise ignored.
-As a special case, if this command is immediately followed by a
-character that is neither a digit or minus sign, the argument count
-for the next command is multiplied by four.
-The argument count is initially one, so executing this function the
-first time makes the argument count four, a second time makes the
-argument count sixteen, and so on.
-.PD
-.SS Completing
-.PP
-.PD 0
-.TP
-.B complete (TAB)
-Attempt to perform completion on the text before point.
-The actual completion performed is application-specific.
-.BR Bash ,
-for instance, attempts completion treating the text as a variable
-(if the text begins with \fB$\fP), username (if the text begins with
-\fB~\fP), hostname (if the text begins with \fB@\fP), or
-command (including aliases and functions) in turn. If none
-of these produces a match, filename completion is attempted.
-.BR Gdb ,
-on the other hand,
-allows completion of program functions and variables, and
-only attempts filename completion under certain circumstances.
-.TP
-.B possible\-completions (M\-?)
-List the possible completions of the text before point.
-.TP
-.B insert\-completions (M\-*)
-Insert all completions of the text before point
-that would have been generated by
-\fBpossible\-completions\fP.
-.TP
-.B menu\-complete
-Similar to \fBcomplete\fP, but replaces the word to be completed
-with a single match from the list of possible completions.
-Repeated execution of \fBmenu\-complete\fP steps through the list
-of possible completions, inserting each match in turn.
-At the end of the list of completions, the bell is rung and the
-original text is restored.
-An argument of \fIn\fP moves \fIn\fP positions forward in the list
-of matches; a negative argument may be used to move backward
-through the list.
-This command is intended to be bound to \fBTAB\fP, but is unbound
-by default.
-.TP
-.B delete\-char\-or\-list
-Deletes the character under the cursor if not at the beginning or
-end of the line (like \fBdelete-char\fP).
-If at the end of the line, behaves identically to
-\fBpossible-completions\fP.
-This command is unbound by default.
-.PD
-.SS Keyboard Macros
-.PP
-.PD 0
-.TP
-.B start\-kbd\-macro (C\-x (\^)
-Begin saving the characters typed into the current keyboard macro.
-.TP
-.B end\-kbd\-macro (C\-x )\^)
-Stop saving the characters typed into the current keyboard macro
-and store the definition.
-.TP
-.B call\-last\-kbd\-macro (C\-x e)
-Re-execute the last keyboard macro defined, by making the characters
-in the macro appear as if typed at the keyboard.
-.PD
-.SS Miscellaneous
-.PP
-.PD 0
-.TP
-.B re\-read\-init\-file (C\-x C\-r)
-Read in the contents of the \fIinputrc\fP file, and incorporate
-any bindings or variable assignments found there.
-.TP
-.B abort (C\-g)
-Abort the current editing command and
-ring the terminal's bell (subject to the setting of
-.BR bell\-style ).
-.TP
-.B do\-uppercase\-version (M\-a, M\-b, M\-\fIx\fP, ...)
-If the metafied character \fIx\fP is lowercase, run the command
-that is bound to the corresponding uppercase character.
-.TP
-.B prefix\-meta (ESC)
-Metafy the next character typed.
-.SM
-.B ESC
-.B f
-is equivalent to
-.BR Meta\-f .
-.TP
-.B undo (C\-_, C\-x C\-u)
-Incremental undo, separately remembered for each line.
-.TP
-.B revert\-line (M\-r)
-Undo all changes made to this line. This is like executing the
-.B undo
-command enough times to return the line to its initial state.
-.TP
-.B tilde\-expand (M\-&)
-Perform tilde expansion on the current word.
-.TP
-.B set\-mark (C\-@, M-<space>)
-Set the mark to the current point. If a
-numeric argument is supplied, the mark is set to that position.
-.TP
-.B exchange\-point\-and\-mark (C\-x C\-x)
-Swap the point with the mark. The current cursor position is set to
-the saved position, and the old cursor position is saved as the mark.
-.TP
-.B character\-search (C\-])
-A character is read and point is moved to the next occurrence of that
-character. A negative count searches for previous occurrences.
-.TP
-.B character\-search\-backward (M\-C\-])
-A character is read and point is moved to the previous occurrence of that
-character. A negative count searches for subsequent occurrences.
-.TP
-.B insert\-comment (M\-#)
-The value of the readline
-.B comment\-begin
-variable is inserted at the beginning of the current line, and the line
-is accepted as if a newline had been typed. This makes the current line
-a shell comment.
-.TP
-.B dump\-functions
-Print all of the functions and their key bindings to the
-readline output stream. If a numeric argument is supplied,
-the output is formatted in such a way that it can be made part
-of an \fIinputrc\fP file.
-.TP
-.B dump\-variables
-Print all of the settable variables and their values to the
-readline output stream. If a numeric argument is supplied,
-the output is formatted in such a way that it can be made part
-of an \fIinputrc\fP file.
-.TP
-.B dump\-macros
-Print all of the readline key sequences bound to macros and the
-strings they ouput. If a numeric argument is supplied,
-the output is formatted in such a way that it can be made part
-of an \fIinputrc\fP file.
-.TP
-.B emacs\-editing\-mode (C\-e)
-When in
-.B vi
-editing mode, this causes a switch to
-.B emacs
-editing mode.
-.TP
-.B vi\-editing\-mode (M\-C\-j)
-When in
-.B emacs
-editing mode, this causes a switch to
-.B vi
-editing mode.
-.PD
-.SH DEFAULT KEY BINDINGS
-.LP
-The following is a list of the default emacs and vi bindings.
-Characters with the 8th bit set are written as M\-<character>, and
-are referred to as
-.I metafied
-characters.
-The printable ASCII characters not mentioned in the list of emacs
-standard bindings are bound to the
-.I self\-insert
-function, which just inserts the given character into the input line.
-In vi insertion mode, all characters not specifically mentioned are
-bound to
-.IR self\-insert .
-Characters assigned to signal generation by
-.IR stty (1)
-or the terminal driver, such as C-Z or C-C,
-retain that function.
-Upper and lower case
-.I metafied
-characters are bound to the same function in the emacs mode
-meta keymap.
-The remaining characters are unbound, which causes readline
-to ring the bell (subject to the setting of the
-.B bell\-style
-variable).
-.SS Emacs Mode
-.RS +.6i
-.nf
-.ta 2.5i
-.sp
-Emacs Standard bindings
-.sp
-"C-@" set-mark
-"C-A" beginning-of-line
-"C-B" backward-char
-"C-D" delete-char
-"C-E" end-of-line
-"C-F" forward-char
-"C-G" abort
-"C-H" backward-delete-char
-"C-I" complete
-"C-J" accept-line
-"C-K" kill-line
-"C-L" clear-screen
-"C-M" accept-line
-"C-N" next-history
-"C-P" previous-history
-"C-Q" quoted-insert
-"C-R" reverse-search-history
-"C-S" forward-search-history
-"C-T" transpose-chars
-"C-U" unix-line-discard
-"C-V" quoted-insert
-"C-W" unix-word-rubout
-"C-Y" yank
-"C-]" character-search
-"C-_" undo
-"\^ " to "/" self-insert
-"0" to "9" self-insert
-":" to "~" self-insert
-"C-?" backward-delete-char
-.PP
-Emacs Meta bindings
-.sp
-"M-C-G" abort
-"M-C-H" backward-kill-word
-"M-C-I" tab-insert
-"M-C-J" vi-editing-mode
-"M-C-M" vi-editing-mode
-"M-C-R" revert-line
-"M-C-Y" yank-nth-arg
-"M-C-[" complete
-"M-C-]" character-search-backward
-"M-space" set-mark
-"M-#" insert-comment
-"M-&" tilde-expand
-"M-*" insert-completions
-"M--" digit-argument
-"M-." yank-last-arg
-"M-0" digit-argument
-"M-1" digit-argument
-"M-2" digit-argument
-"M-3" digit-argument
-"M-4" digit-argument
-"M-5" digit-argument
-"M-6" digit-argument
-"M-7" digit-argument
-"M-8" digit-argument
-"M-9" digit-argument
-"M-<" beginning-of-history
-"M-=" possible-completions
-"M->" end-of-history
-"M-?" possible-completions
-"M-B" backward-word
-"M-C" capitalize-word
-"M-D" kill-word
-"M-F" forward-word
-"M-L" downcase-word
-"M-N" non-incremental-forward-search-history
-"M-P" non-incremental-reverse-search-history
-"M-R" revert-line
-"M-T" transpose-words
-"M-U" upcase-word
-"M-Y" yank-pop
-"M-\e" delete-horizontal-space
-"M-~" tilde-expand
-"M-C-?" backward-delete-word
-"M-_" yank-last-arg
-.PP
-Emacs Control-X bindings
-.sp
-"C-XC-G" abort
-"C-XC-R" re-read-init-file
-"C-XC-U" undo
-"C-XC-X" exchange-point-and-mark
-"C-X(" start-kbd-macro
-"C-X)" end-kbd-macro
-"C-XE" call-last-kbd-macro
-"C-XC-?" backward-kill-line
-.sp
-.RE
-.SS VI Mode bindings
-.RS +.6i
-.nf
-.ta 2.5i
-.sp
-.PP
-VI Insert Mode functions
-.sp
-"C-D" vi-eof-maybe
-"C-H" backward-delete-char
-"C-I" complete
-"C-J" accept-line
-"C-M" accept-line
-"C-R" reverse-search-history
-"C-S" forward-search-history
-"C-T" transpose-chars
-"C-U" unix-line-discard
-"C-V" quoted-insert
-"C-W" unix-word-rubout
-"C-Y" yank
-"C-[" vi-movement-mode
-"C-_" undo
-"\^ " to "~" self-insert
-"C-?" backward-delete-char
-.PP
-VI Command Mode functions
-.sp
-"C-D" vi-eof-maybe
-"C-E" emacs-editing-mode
-"C-G" abort
-"C-H" backward-char
-"C-J" accept-line
-"C-K" kill-line
-"C-L" clear-screen
-"C-M" accept-line
-"C-N" next-history
-"C-P" previous-history
-"C-Q" quoted-insert
-"C-R" reverse-search-history
-"C-S" forward-search-history
-"C-T" transpose-chars
-"C-U" unix-line-discard
-"C-V" quoted-insert
-"C-W" unix-word-rubout
-"C-Y" yank
-"\^ " forward-char
-"#" insert-comment
-"$" end-of-line
-"%" vi-match
-"&" vi-tilde-expand
-"*" vi-complete
-"+" next-history
-"," vi-char-search
-"-" previous-history
-"." vi-redo
-"/" vi-search
-"0" beginning-of-line
-"1" to "9" vi-arg-digit
-";" vi-char-search
-"=" vi-complete
-"?" vi-search
-"A" vi-append-eol
-"B" vi-prev-word
-"C" vi-change-to
-"D" vi-delete-to
-"E" vi-end-word
-"F" vi-char-search
-"G" vi-fetch-history
-"I" vi-insert-beg
-"N" vi-search-again
-"P" vi-put
-"R" vi-replace
-"S" vi-subst
-"T" vi-char-search
-"U" revert-line
-"W" vi-next-word
-"X" backward-delete-char
-"Y" vi-yank-to
-"\e" vi-complete
-"^" vi-first-print
-"_" vi-yank-arg
-"`" vi-goto-mark
-"a" vi-append-mode
-"b" vi-prev-word
-"c" vi-change-to
-"d" vi-delete-to
-"e" vi-end-word
-"f" vi-char-search
-"h" backward-char
-"i" vi-insertion-mode
-"j" next-history
-"k" prev-history
-"l" forward-char
-"m" vi-set-mark
-"n" vi-search-again
-"p" vi-put
-"r" vi-change-char
-"s" vi-subst
-"t" vi-char-search
-"u" undo
-"w" vi-next-word
-"x" vi-delete
-"y" vi-yank-to
-"|" vi-column
-"~" vi-change-case
-.RE
-.SH "SEE ALSO"
-.PD 0
-.TP
-\fIThe Gnu Readline Library\fP, Brian Fox and Chet Ramey
-.TP
-\fIThe Gnu History Library\fP, Brian Fox and Chet Ramey
-.TP
-\fIbash\fP(1)
-.PD
-.SH FILES
-.PD 0
-.TP
-.FN ~/.inputrc
-Individual \fBreadline\fP initialization file
-.PD
-.SH AUTHORS
-Brian Fox, Free Software Foundation (primary author)
-.br
-bfox@ai.MIT.Edu
-.PP
-Chet Ramey, Case Western Reserve University
-.br
-chet@ins.CWRU.Edu
-.SH BUG REPORTS
-If you find a bug in
-.B readline,
-you should report it. But first, you should
-make sure that it really is a bug, and that it appears in the latest
-version of the
-.B readline
-library that you have.
-.PP
-Once you have determined that a bug actually exists, mail a
-bug report to \fIbug\-readline\fP@\fIgnu.org\fP.
-If you have a fix, you are welcome to mail that
-as well! Suggestions and `philosophical' bug reports may be mailed
-to \fPbug-readline\fP@\fIgnu.org\fP or posted to the Usenet
-newsgroup
-.BR gnu.bash.bug .
-.PP
-Comments and bug reports concerning
-this manual page should be directed to
-.IR chet@ins.CWRU.Edu .
-.SH BUGS
-.PP
-It's too big and too slow.
diff --git a/contrib/nvi/catalog/ru_RU.KOI8-R b/contrib/nvi/catalog/ru_RU.KOI8-R
deleted file mode 100644
index 3af029331990..000000000000
--- a/contrib/nvi/catalog/ru_RU.KOI8-R
+++ /dev/null
@@ -1,267 +0,0 @@
-VI_MESSAGE_CATALOG
-ðÅÒÅÐÏÌÎÅÎÉÅ ÚÎÁÞÅÎÉÑ ÄÌÉÎÙ ÓÔÒÏËÉX
-ÎÅ×ÏÚÍÏÖÎÏ ÕÄÁÌÉÔØ ÓÔÒÏËÕ %luX
-ÎÅ×ÏÚÍÏÖÎÏ ÄÏÂÁ×ÉÔØ Ë ÓÔÒÏËÅ %luX
-ÎÅ×ÏÚÍÏÖÎÏ ×ÓÔÁ×ÉÔØ × ÓÔÒÏËÕ %luX
-ÎÅ×ÏÚÍÏÖÎÏ ÓÏÈÒÁÎÉÔØ ÓÔÒÏËÕ %luX
-ÎÅ×ÏÚÍÏÖÎÏ ÄÏÓÔÁÔØ ÐÏÓÌÅÄÎÀÀ ÓÔÒÏËÕX
-
-æÁÊÌ ÚÁÐÉÓÅÊX
-úÁÐÉÓÉ ÎÅ ×ÅÌÉÓØ, ÎÅ×ÏÚÍÏÖÎÏ ÏÔÍÅÎÉÔØ ÐÏÓÌÅÄÎÀÀ ËÏÍÁÎÄÕX
-îÅÔ ÉÚÍÅÎÅÎÉÊ ÄÌÑ ÏÔÍÅÎÙX
-úÁÐÉÓÉ ÎÅ ×ÅÌÉÓØ, ÎÅ×ÏÚÍÏÖÎÏ ÏÔÍÅÎÉÔØ ÐÏÓÌÅÄÎÀÀ ËÏÍÁÎÄÕX
-úÁÐÉÓÉ ÎÅ ×ÅÌÉÓØ, ÎÅ×ÏÚÍÏÖÎÏ ÐÒÏÓÍÏÔÒÅÔØ ×ÐÅÒÅÄX
-îÅÔ ÉÚÍÅÎÅÎÉÊ ÄÌÑ ÐÅÒÅÄÅÌËÉX
-%s/%d: ÏÛÉÂËÁ ÐÒÉ ÚÁÐÉÓÉ ÐÒÏÔÏËÏÌÁX
-óÔÁÎÄÁÒÔÎÙÊ ××ÏÄ/×Ù×ÏÄ ÄÌÑ VI ÄÏÌÖÅÎ ÂÙÔØ ÔÅÒÍÉÎÁÌX
-ïÔÍÅÔËÁ %s: ÎÅ ÕÓÔÁÎÏ×ÌÅÎÁX
-ïÔÍÅÔËÁ %s: ÓÔÒÏËÁ ÂÙÌÁ ÕÄÁÌÅÎÁX
-ïÔÍÅÔËÁ %s: ÐÏÚÉÃÉÉ ËÕÒÓÏÒÁ ÂÏÌØÛÅ ÎÅ ÓÕÝÅÓÔ×ÕÅÔX
-ïÛÉÂËÁ: X
-
-
-
-
-
-
-
-
-
-æÁÊÌ %s ÎÅ Ñ×ÌÑÅÔÓÑ ËÁÔÁÌÏÇÏÍ ÓÏÏÂÝÅÎÉÊX
-îÅ×ÏÚÍÏÖÎÏ ÕÓÔÁÎÏ×ÉÔØ ÏÐÃÉÀ %s ÐÏ ÕÍÏÌÞÁÎÉÀX
-éÓÐÏÌØÚÏ×ÁÎÉÅ: %sX
-ïÐÃÉÉ %s ÎÅÔ: 'set all' ÐÏËÁÚÙ×ÁÅÔ ×ÓÅ ×ÏÚÍÏÖÎÙÅ ÏÐÃÉÉX
-set: [no]%s ÎÅ ÐÒÉÎÉÍÁÅÔ ÔÁËÏÇÏ ÚÎÁÞÅÎÉÑX
-set: %s ÏÐÃÉÑ ÎÅ Ñ×ÌÑÅÔÓÑ ÌÏÇÉÞÅÓËÏÊX
-
-
-set: ÎÅÐÒÁ×ÉÌØÎÏÅ ÚÎÁÞÅÎÉÅ %sX
-set: %s ÏÐÃÉÑ ÎÅ Ñ×ÌÑÅÔÓÑ ÌÏÇÉÞÅÓËÏÊX
-ëÏÌÉÞÅÓÔ×Ï ËÏÌÏÎÏË ÜËÒÁÎÁ ÓÌÉÛËÏÍ ÍÁÌÏ, ÍÅÎØÛÅ ÞÅÍ %dX
-ëÏÌÉÞÅÓÔ×Ï ËÏÌÏÎÏË ÜËÒÁÎÁ ÓÌÉÛËÏÍ ×ÅÌÉËÏ, ÂÏÌØÛÅ ÞÅÍ %dX
-ëÏÌÉÞÅÓÔ×Ï ÓÔÒÏË ÜËÒÁÎÁ ÓÌÉÛËÏÍ ÍÁÌÏ, ÍÅÎØÛÅ ÞÅÍ %dX
-ëÏÌÉÞÅÓÔ×Ï ÓÔÒÏË ÜËÒÁÎÁ ÓÌÉÛËÏÍ ×ÅÌÉËÏ, ÂÏÌØÛÅ ÞÅÍ %dX
-ïÐÃÉÑ lisp ÏÔÓÕÔÓÔ×ÕÅÔX
-óÏÏÂÝÅÎÉÑ ÎÅ ×ÙËÌÀÞÅÎÙ: %sX
-óÏÏÂÝÅÎÉÑ ÎÅ ×ËÌÀÞÅÎÙ: %sX
-
-ïÐÃÉÑ paragraph ÄÏÌÖÎÁ ÓÏÓÔÏÑÔØ ÉÚ ÇÒÕÐÐ Ó Ä×ÕÍÑ ÓÉÍ×ÏÌÁÍÉX
-ïÐÃÉÑ section ÄÏÌÖÎÁ ÓÏÓÔÏÑÔØ ÉÚ ÇÒÕÐÐ Ó Ä×ÕÍÑ ÓÉÍ×ÏÌÁÍÉX
-
-
-
-óÔÁÒÔÏ×ÙÊ ÂÕÆÅÒ ÐÕÓÔX
-âÕÆÅÒ %s ÐÕÓÔX
-æÁÊÌÙ Ó ÓÉÍ×ÏÌÁÍÉ ÐÅÒÅ×ÏÄÁ ÓÔÒÏËÉ × ÉÍÅÎÉ ÎÅ ÍÏÇÕÔ ÂÙÔØ ×ÏÓÓÔÁÎÏ×ÌÅÎÙX
-éÚÍÅÎÅÎÉÑ ÎÅ ÓÏÈÒÁÎÅÎÙ ÐÒÉ ËÒÁÈÅ ÓÅÓÓÉÉX
-
-óÏÈÒÁÎÅÎÉÅ ÎÅ ÕÄÁÌÏÓØ: %sX
-éÚÍÅÎÅÎÉÑ ÎÅ ÓÏÈÒÁÎÑÀÔÓÑ ÐÒÉ ÏÂÒÙ×Å ÓÅÓÓÉÉX
-óÏÈÒÁÎÅÎÉÅ ËÏÐÉÉ ÆÁÊÌÁ ÎÅ ÕÄÁÌÏÓØ: %sX
-
-éÎÆÏÒÍÁÃÉÉ ÎÁ ÐÏÌØÚÏ×ÁÔÅÌÑ %u ÎÅ ÎÁÊÄÅÎÏX
-îÅ×ÏÚÍÏÖÎÏ ÚÁÝÉÔÉÔØ ÓÐÁÓÅÎÎÙÊ ÆÁÊÌX
-âÕÆÅÒ ×ÏÓÓÔÁÎÏ×ÌÅÎÎÏÇÏ ÆÁÊÌÁ ÐÅÒÅÐÏÌÎÅÎX
-÷ÏÓÓÔÁÎÏ×ÌÅÎÎÙÊ ÆÁÊÌX
-%s: ÎÅ ÄÏ ËÏÎÃÁ ×ÏÓÓÔÁÎÏ×ÌÅÎÎÙÊ ÆÁÊÌX
-%s: ÎÅ ÄÏ ËÏÎÃÁ ×ÏÓÓÔÁÎÏ×ÌÅÎÎÙÊ ÆÁÊÌX
-æÁÊÌÏ× Ó ÉÍÅÎÅÍ %s, ËÏÔÏÒÙÅ ÷Ù ÍÏÖÅÔÅ ÞÉÔÁÔØ, ÎÅ ÓÕÝÅÓÔ×ÕÅÔX
-åÓÔØ ÓÔÁÒÙÅ ×ÅÒÓÉÉ ÆÁÊÌÁ, ËÏÔÏÒÙÅ ÍÏÖÎÏ ×ÏÓÓÔÁÎÏ×ÉÔØX
-óÕÝÅÓÔ×ÕÀÔ ÄÒÕÇÉÅ ÆÁÊÌÙ, ËÏÔÏÒÙÅ ÍÏÖÎÏ ×ÏÓÓÔÁÎÏ×ÉÔØX
-Å-mail ÎÅ ÐÏÓÌÁÎ: %sX
-æÁÊÌ ÐÕÓÔ - ÉÓËÁÔØ ÎÅÞÅÇÏX
-äÏÓÔÉÇÎÕÔ ËÏÎÅà ÆÁÊÌÁ ÂÅÚ ÎÁÈÏÖÄÅÎÉÑ ÏÂÒÁÚÃÁ ÐÏÉÓËÁX
-îÅ ÚÁÄÁÎ ÏÂÒÁÚÅà ÐÏÉÓËÁX
-ïÂÒÁÚÅà ÐÏÉÓËÁ ÎÅ ÎÁÊÄÅÎX
-äÏÓÔÕÐÎÏ ÎÁÞÁÌÏ ÆÁÊÌÁ ÂÅÚ ÎÁÈÏÖÄÅÎÉÑ ÏÂÒÁÚÃÁ ÐÏÉÓËÁX
-ðÏÉÓË ÚÁÃÉËÌÅÎX
-
-îÅÐÅÞÁÔÎÙÈ ÓÉÍ×ÏÌÏ× ÎÅ ÎÁÊÄÅÎÏX
-îÅÉÚ×ÅÓÔÎÁÑ ËÏÍÁÎÄÁX
-
-%s: ËÏÍÁÎÄÁ ÎÅ ÄÏÓÔÕÐÎÁ × ÒÅÖÉÍÅ exX
-óÞÅÔÞÉË ÎÅ ÍÏÖÅÔ ÂÙÔØ ÎÕÌÅÍX
-%s: ÎÅÐÒÁ×ÉÌØÎÏÅ ÕËÁÚÁÎÉÅ ÓÔÒÏËÉX
-÷ÎÕÔÒÅÎÎÑÑ ÏÛÉÂËÁ × ÓÉÎÔÁËÓÉÓÅ (%s: %s)X
-éÓÐÏÌØÚÏ×ÁÎÉÅ: %sX
-%s: ×ÒÅÍÅÎÎÙÊ ÂÕÆÅÒ ÎÅ ÉÓÐÏÌØÚÏ×ÁÎX
-íÅÔËÁ ÐÏÓÔÁ×ÌÅÎÁ ÐÅÒÅÄ ÓÔÒÏËÏÊ 1X
-íÅÔËÁ ÐÏÓÔÁ×ÌÅÎÁ ÐÏÓÌÅ ËÏÎÃÁ ÆÁÊÌÁX
-
-
-ëÏÍÁÎÄÁ ex ÎÅ ÕÄÁÌÁÓØ: ÐÏÓÌÅÄÕÀÝÉÅ ËÏÍÁÎÄÙ ÚÁÂÙÔÙX
-
-÷ÔÏÒÏÊ ÁÄÒÅÓ ÍÅÎØÛÅ ÞÅÍ ÐÅÒ×ÙÊX
-îÅ ÕËÁÚÁÎÏ ÎÁÚ×ÁÎÉÅ ÏÔÍÅÔËÉX
-\\ ÎÅ ÚÁ×ÅÒÛÁÅÔÓÑ / ÉÌÉ ?X
-óÓÙÌËÁ Ë ÓÔÒÏËÅ Ó ÎÏÍÅÒÏÍ ÍÅÎØÛÅ 0X
-ëÏÍÁÎÄÁ %s ÎÅÉÚ×ÅÓÔÎÁX
-ðÅÒÅÐÏÌÎÅÎÉÅ ÚÎÁÞÅÎÉÑ ÁÄÒÅÓÁX
-îÅÄÏÂÏÒ ÚÎÁÞÅÎÉÑ ÁÄÒÅÓÁX
-îÅÄÏÐÕÓÔÉÍÁÑ ËÏÍÂÉÎÁÃÉÑ × ÁÄÒÅÓÅX
-îÅÐÒÁ×ÉÌØÎÙÊ ÁÄÒÅÓ: ×ÓÅÇÏ %lu ÓÔÒÏË × ÆÁÊÌÅX
-îÅÐÒÁ×ÉÌØÎÙÊ ÁÄÒÅÓ: ÆÁÊÌ ÐÕÓÔX
-ëÏÍÍÁÎÄÁ %s ÎÅ ÍÏÖÅÔ ÉÓÐÏÌØÚÏ×ÁÔØ ÁÄÒÅÓ 0X
-áÂÂÒÅ×ÉÁÔÕÒÙ ÏÔÓÕÔÓÔ×ÕÀÔX
-áÂÂÒÅ×ÉÁÔÕÒÙ ÄÏÌÖÎÙ ÚÁËÁÎÞÉ×ÁÔØÓÑ ÓÉÍ×ÏÌÏÍ "word"X
-áÂÂÒÅ×ÉÁÔÕÒÙ ÎÅ ÍÏÇÕÔ ÓÏÄÅÒÖÁÔØ ÓÉÍ×ÏÌÏÙ ÔÁÂÌÑÃÉÉ ÉÌÉ ÐÒÏÂÅÌÙX
-áÂÂÒÅ×ÉÁÔÕÒÙ ÎÅ ÍÏÇÕÔ ÓÏÞÅÔÁÔØÓÑ Ó ÓÉÍ×ÏÌÁÍÉ ÓÌÏ×/ÎÅ-ÓÌÏ×, ÚÁ ÉÓËÌÀÞÅÎÉÅÍ ËÏÎÃÁ ÓÔÒÏËÉX
-"%s" ÎÅ Ñ×ÌÑÅÔÓÑ ÁÂÂÒÅ×ÉÁÔÕÒÏÊX
-
-æÁÊÌÏ× ÄÌÑ ÒÅÄÁËÔÉÒÏ×ÁÎÉÑ ÂÏÌØÛÅ ÎÅÔX
-ïÔÓÕÔÓÔ×ÉÅ ÐÒÅÄÙÄÕÝÅÇÏ ÆÁÊÌÁ ÄÌÑ ÒÅÄÁËÔÉÒÏ×ÁÎÉÑX
-ïÔÓÕÔÓÔ×ÉÅ ÐÒÅÄÙÄÕÝÅÇÏ ÆÁÊÌÁ ÄÌÑ ÐÒÏÓÍÏÔÒÁ ÎÁÚÁÄX
-îÅÔ ÆÁÊÌÏ×X
-ïÔÓÕÔÓÔ×ÉÅ ÐÒÅÄÙÄÕÝÅÊ ËÏÍÁÎÄÙ ÄÌÑ ÚÁÍÅÎÙ "!"X
-ïÔÓÕÔÓÔ×ÉÅ ÚÁÍÅÎÙ ÄÌÑ %%X
-ïÔÓÕÔÓÔ×ÉÅ ÚÁÍÅÎÙ ÄÌÑ #X
-ïÛÉÂËÁ: execl: %sX
-ïÛÉÂËÁ ××ÏÄÁ/×Ù×ÏÄÁ: %sX
-æÁÊÌ ÉÚÍÅÎÅÎ Ó ÍÏÍÅÎÔÁ ÐÏÓÌÅÄÎÅÊ ÐÏÌÎÏÊ ÚÁÐÉÓÉ: ÉÓÐÏÌØÚÕÊÔÅ ! ÄÌÑ ÏÂÈÏÄÁX
-îÅ×ÏÚÍÏÖÎÏ ÎÁÊÔÉ ÄÏÍÁÛÎÉÊ ËÁÔÁÌÏÇX
-îÏ×ÙÊ ËÁÔÁÌÏÇ: %sX
-îÅÔ ×ÙÒÅÚÁÎÙÈ ÂÕÆÅÒÏ×X
-ëÏÍÁÎÄÁ %s ÎÅ ÍÏÖÅÔ ÂÙÔØ ÉÓÐÏÌØÚÏ×ÁÎÁ ×ÎÕÔÒÉ ÇÌÏÂÁÌØÎÏÊ ÉÌÉ v ËÏÍÁÎÄÙX
-%s/%s: ÎÅ ÏÔËÒÙÔ: ÎÅ ÐÒÉÎÁÄÌÅÖÉÔ ÷ÁÍ ÉÌÉ root-ÕX
-%s/%s: ÎÅ ÏÔËÒÙÔ: ÎÅ ÐÒÉÎÁÄÌÅÖÉÔ ÷ÁÍX
-%s/%s: ÎÅ ÏÔËÒÙÔ: ×ÏÚÍÏÖÎÏÓÔØ ÚÁÐÉÓÉ Õ ÐÏÌØÚÏ×ÁÔÅÌÑ, ÎÅ Ñ×ÌÑÀÝÅÇÏÓÑ ×ÌÁÄÅÌØÃÅÍX
-%s: ÎÅ ÓÞÉÔÁÎ: ÎÅ ÐÒÉÎÁÄÌÅÖÉÔ ÷ÁÍ ÉÌÉ root-ÕX
-%s: ÎÅ ÓÞÉÔÁÎ: ÎÅ ÐÒÉÎÁÄÌÅÖÉÔ ÷ÁÍX
-%s: ÎÅ ÓÞÉÔÁÎ: ×ÏÚÍÏÖÎÏÓÔØ ÚÁÐÉÓÉ Õ ÐÏÌØÚÏ×ÁÔÅÌÑ, ÎÅ Ñ×ÌÑÀÝÅÇÏÓÑ ×ÌÁÄÅÌØÃÅÍX
-ðÏÓÌÅÄÕÀÝÉÅ ÓÔÒÏËÉ ÏÔÓÕÔÓÔ×ÕÀÔX
-ïÔÓÕÔÓÔ×ÉÅ ÐÁÒÁÍÅÔÒÏ× ××ÏÄÁX
-ïÔÓÕÔÓÔ×ÉÅ ÐÁÒÁÍÅÔÒÏ× ËÏÍÁÎÄÙX
-óÉÍ×ÏÌ %s ÎÅ ÍÏÖÅÔ ÂÙÔØ ÐÅÒÅÎÁÚÎÁÞÅÎX
-"%s" ÎÁ ÄÁÎÎÙÊ ÍÏÍÅÎÔ ÎÅ ÎÁÚÎÁÞÅÎX
-éÍÑ ÍÅÔËÉ ÄÏÌÖÎÏ ÂÙÔØ ÏÄÎÉÍ ÓÉÍ×ÏÌÏÍX
-%s ÓÕÝÅÓÔ×ÕÅÔ, ÎÅ ÚÁÐÉÓÁÎ; ÉÓÐÏÌØÚÕÊÔÅ ! ÄÌÑ ÏÂÈÏÄÁX
-îÏ×ÙÊ ÆÁÊÌ exrc: %sX
-óÔÒÏËÁ ÐÅÒÅÎÏÓÁ ÎÁÈÏÄÉÔÓÑ ×ÎÕÔÒÉ ÐÁÒÁÍÅÔÒÏ× ÐÅÒÅÎÏÓÁX
-ëÏÍÁÎÄÁ open ÐÏÄÒÁÚÕÍÅ×ÁÅÔ ÕÓÔÁÎÏ×ËÕ ÏÐÃÉÉ openX
-ëÏÍÁÎÄÁ open ÎÅ ÒÅÁÌÉÚÏ×ÁÎÁX
-úÁÝÉÔÁ ÆÁÊÌÁ ÎÅ×ÏÚÍÏÖÎÁX
-æÁÊÌ ÚÁÝÉÝÅÎX
-%s ÒÁÓÛÉÒÉÌÓÑ × ÓÌÉÛËÏÍ ÂÏÌØÛÏÅ ËÏÌÉÞÅÓÔ×Ï ÉÍÅÎ ÆÁÊÌÏ×X
-
-%s: ÚÁÝÉÔÁ ÎÁ ÞÔÅÎÉÅ ÂÙÌÁ ÎÅÄÏÓÔÕÐÎÁX
-
-%s: %lu ÓÔÒÏË, %lu ÓÉÍ×ÏÌÏ×X
-îÅÔ ÔÅÎÅ×ÙÈ ÏËÏÎX
-ëÏÍÁÎÄÁ script ÉÓÐÏÌØÚÕÅÔÓÑ ÔÏÌØËÏ × ÒÅÖÉÍÅ viX
-îÅÔ ËÏÍÁÎÄÙ ÄÌÑ ÉÓÐÏÌÎÅÎÉÑX
-ïÐÃÉÑ shiftwidth ÕÓÔÁÎÏ×ÌÅÎÁ ÎÁ 0X
-ðÅÒÅÐÏÌÎÅÎÉÅ ÓÞÅÔÞÉËÁX
-ãÉËÌ ×ÙÐÏÌÎÅÎ ÎÅ ÄÏ ËÏÎÃÁX
-õËÁÚÁÎÏ ÒÅÇÕÌÑÒÎÏÅ ×ÙÒÁÖÅÎÉÅ: ÆÌÁÇ r ÎÅ ÎÕÖÅÎX
-æÌÁÇÉ #, l É p ÎÅ ÍÏÇÕÔ ÂÙÔØ ÏÂßÅÄÉÎÅÎÙ Ó ÆÌÁÇÏÍ c × ÒÅÖÉÍÅ viX
-óÏ×ÐÁÄÅÎÉÊ ÎÅÔX
-íÅÔËÁ ÏÔÓÕÔÓÔ×ÕÅÔX
-÷ ÓÔÅËÅ ÍÅÔÏË ÚÁÐÉÓÅÊ ÍÅÎØÛÅ, ÞÅÍ %s, ÉÓÐÏÌØÚÕÊÔÅ :display t[ags]X
-æÁÊÌÁ Ó ÉÍÅÎÅÍ %s × ÓÔÅËÅ ÍÅÔÏË ÎÅÔ; ÉÓÐÏÌØÚÕÊÔÅ :display t[ags]X
-
-%s: ÍÅÔËÁ ÎÅ ÎÁÊÄÅÎÁX
-%s: ÐÌÏÈÁÑ ÍÅÔËÁ × %sX
-
-óÔÅË ÍÅÔÏË ÐÕÓÔX
-%s: ÏÂÒÁÚÅÃ ÐÏÉÓËÁ ÎÅ ÎÁÊÄÅÎX
-
-âÕÆÅÒ %s ÐÕÓÔX
-
-ðÒÅÒ×ÁÎÏX
-ïÔÓÕÔÓÔ×ÉÅ ÂÕÆÅÒÁ ÄÌÑ ÉÓÐÏÌØÚÏ×ÁÎÉÑX
-îÅÔ ÐÒÅÄÉÄÕÝÅÇÏ ÒÅÇÕÌÑÒÎÏÇÏ ×ÙÒÁÖÅÎÉÑX
-ëÏÍÁÎÄÁ %s ÐÏÄÒÁÚÕÍÅ×ÁÅÔ ÎÁÌÉÞÉÅ ÐÒÏÞÔÅÎÎÏÇÏ ÆÁÊÌÁX
-éÓÐÏÌØÚÏ×ÁÎÉÅ: %sX
-ëÏÍÁÎÄÁ visual ÐÏÄÒÁÚÕÍÅ×ÁÅÔ ÏÂÑÚÁÔÅÌØÎÕÀ ÕÓÔÁÎÏ×ËÕ ÏÐÃÉÉ openX
-
-ðÕÓÔÏÊ ÆÁÊÌX
-îÅÔ ÐÒÅÄÙÄÕÝÅÇÏ ÐÏÉÓËÁ F, f, T, ÉÌÉ tX
-%s ÎÅ ÎÁÊÄÅÎÏX
-îÅÔ ÐÒÅÄÙÄÕÝÅÇÏ ÆÁÊÌÁ ÄÌÑ ÒÅÄÁËÔÉÒÏ×ÁÎÉÑX
-ëÕÒÓÏÒ ÓÔÏÉÔ ÎÅ ÎÁ ÃÉÆÒÅX
-ðÏÌÕÞÅÎÎÏÅ ÞÉÓÌÏ ÓÌÉÛËÏÍ ×ÅÌÉËÏX
-ðÏÌÕÞÅÎÎÏÅ ÞÉÓÌÏ ÓÌÉÛËÏÍ ÍÁÌÏX
-ðÏÄÈÏÄÑÝÅÇÏ ÓÉÍ×ÏÌÁ ÎÅÔ ÎÁ ÜÔÏÊ ÓÔÒÏËÅX
-ðÏÄÈÏÄÑÝÉÊ ÓÉÍ×ÏÌ ÎÅ ÎÁÊÄÅÎX
-îÅÔ ÓÉÍ×ÏÌÏ× ÄÌÑ ÕÄÁÌÅÎÉÑX
-äÒÕÇÏÇÏ ÜËÒÁÎÁ ÎÅ ÓÕÝÅÓÔ×ÕÅÔX
-óÉÍ×ÏÌÙ ÐÏÓÌÅ ÓÔÒÏËÉ ÄÌÑ ÐÏÉÓËÁ, ÓÍÅÝÅÎÉÑ ÓÔÒÏËÉ É/ÉÌÉ ËÏÍÁÎÄÙ zX
-ðÒÏÛÌÙÊ ÏÂÒÁÚÅÃ ÐÏÉÓËÁ ÏÔÓÕÔÓÔ×ÕÅÔX
-ðÏÉÓË ÚÁ×ÅÒÛÉÌÓÑ ÎÁ ÎÁÞÁÌØÎÏÊ ÐÏÚÉÃÉÉX
-
-óÉÍ×ÏÌ ÎÅÐÒÁ×ÉÌÅÎ; Ë×ÏÔÉÒÕÊÔÅ ÄÌÑ ××ÏÄÁX
-õÖÅ ÎÁ ÎÁÞÁÌÅ ×ÓÔÁ×ËÉX
-îÅÔ ÓÉÍ×ÏÌÏ× ÄÌÑ ÕÄÁÌÅÎÉÑX
-ðÅÒÅÄ×ÉÖÅÎÉÅ ÚÁ ËÏÎÅà ÆÁÊÌÁX
-ðÅÒÅÄ×ÉÖÅÎÉÅ ÚÁ ËÏÎÅà ÓÔÒÏËÉX
-ä×ÉÖÅÎÉÅ ÓÔÒÏËÉ ÎÅ ÓÄÅÌÁÎÏX
-õÖÅ ÎÁ ÎÁÞÁÌÅ ÆÁÊÌÁX
-ä×ÉÖÅÎÉÅ ËÕÒÓÏÒÁ ÚÁ ÎÁÞÁÌÏ ÆÁÊÌÁX
-õÖÅ × ÐÅÒ×ÏÊ ËÏÌÏÎËÅX
-âÕÆÅÒÙ ÄÏÌÖÎÙ ÂÙÔØ ÕËÁÚÁÎÙ ÄÏ ×ÙÐÏÌÎÅÎÉÑ ËÏÍÁÎÄÙX
-õÖÅ ÎÁ ËÏÎÃÅ ÆÁÊÌÁX
-õÖÅ ÎÁ ËÏÎÃÅ ÓÔÒÏËÉX
-%s ÎÅ Ñ×ÌÑÅÔÓÑ ËÏÍÁÎÄÏÊ VIX
-éÓÐÏÌØÚÏ×ÁÎÉÅ: %sX
-îÅÔ ÓÉÍ×ÏÌÏ× ÄÌÑ ÕÄÁÌÅÎÉÑX
-
-îÅÔ ËÏÍÁÎÄÙ ÄÌÑ ÐÏ×ÔÏÒÁX
-
-ëÏÍÁÎÄÁ %s ÎÅ ÍÏÖÅÔ ÂÙÔØ ÉÓÐÏÌØÚÏ×ÁÎÁ ËÁË ËÏÍÁÎÄÁ ÐÅÒÅÍÅÝÅÎÉÑX
-õÖÅ × ËÏÍÁÎÄÎÏÍ ÒÅÖÉÍÅX
-
-
-úÎÁÞÅÎÉÅ ÏÐÃÉÉ windows ÓÌÉÛËÏÍ ×ÅÌÉËÏ, ÍÁËÓÉÍÁÌØÎÏÅ ÚÎÁÞÅÎÉÅ = %uX
-
-
-
-
-
-ä×ÉÖÅÎÉÅ ËÕÒÓÏÒÁ ÚÁ ËÏÎÅà ÜËÒÁÎÁX
-ä×ÉÖÅÎÉÅ ËÕÒÓÏÒÁ ÚÁ ÎÁÞÁÌÏ ÜËÒÁÎÁX
-
-ôÅÎÅ×ÙÈ ÏËÏÎ ÎÅÔX
-îÅ ÓÕÝÅÓÔ×ÕÅÔ ÔÅÎÅ×ÏÇÏ ÏËÎÁ Ó ÒÅÄÁËÔÉÒÏ×ÁÎÉÅÍ ÆÁÊÌÁ %sX
-÷Ù ÎÅ ÍÏÖÅÔÅ ÓÄÅÌÁÔØ ÅÄÉÎÓÔ×ÅÎÎÏÅ ÏËÎÏ ÔÅÎÅ×ÙÍX
-üËÒÁÎ ÍÏÖÅÔ ÂÙÔØ ÓÖÁÔX
-üËÒÁÎ ÎÅ ÍÏÖÅÔ ÂÙÔØ ÓÖÁÔ ÔÏÌØËÏ ÄÏ %d ÓÔÒÏËX
-üËÒÁÎ ÎÅ ÍÏÖÅÔ ÂÙÔØ ÒÁÓÛÉÒÅÎX
-
-
-
-
-äÁÎÎÙÊ ÔÉÐ ÔÅÒÍÉÎÁÌÁ ÎÅ ÉÍÅÅÔ ËÌÁ×ÉÛÉ %sX
-
-
-
-îÅ×ÏÚÍÏÖÎÏ ÓÏÚÄÁÔØ ×ÒÅÍÅÎÎÙÊ ÆÁÊÌX
-÷ÎÉÍÁÎÉÅ: %s ÓÐÅÃÉÁÌØÎÙÊ ÆÁÊÌX
-%s ÕÖÅ ÚÁÂÌÏËÉÒÏ×ÁÎ, ÄÏÓÔÕÐÅÎ ÔÏÌØËÏ ÎÁ ÞÔÅÎÉÅX
-%s: ÕÄÁÌÅÎX
-%s: ÚÁËÒÙÔX
-%s: ÕÄÁÌÅÎX
-%s: ÕÄÁÌÅÎX
-æÁÊÌ ÔÏÌØËÏ ÄÌÑ ÞÔÅÎÉÑ, ÎÅ ÚÁÐÉÓÁÎ: éÓÐÏÌØÚÕÊÔÅ ! ÄÌÑ ÏÂÈÏÄÁX
-æÁÊÌ ÔÏÌØËÏ ÄÌÑ ÞÔÅÎÉÑ, ÎÅ ÚÁÐÉÓÁÎX
-%s ÓÕÝÅÓÔ×ÕÅÔ, ÎÅ ÚÁÐÉÓÁÎ; ÉÓÐÏÌØÚÕÊÔÅ ! ÄÌÑ ÏÂÈÏÄÁX
-%s ÓÕÝÅÓÔ×ÕÅÔ, ÎÅ ÚÁÐÉÓÁÎX
-éÓÐÏÌØÚÕÊÔÅ ! ÄÌÑ ÞÁÓÔÉÞÎÏÊ ÚÁÐÉÓÉ ÆÁÊÌÁX
-þÁÓÔØ ÆÁÊÌÁ, ÆÁÊÌ ÎÅ ÚÁÐÉÓÁÎX
-%s: æÁÊÌ ÉÚÍÅÎÑÌÓÑ ÐÏÚÄÎÅÅ, ÞÅÍ ÄÁÎÎÁÑ ËÏÐÉÑ: ÉÓÐÏÌØÚÕÊÔÅ ! ÄÌÑ ÏÂÈÏÄÁX
-%s: æÁÊÌ ÉÚÍÅÎÑÌÓÑ ÐÏÚÄÎÅÅ, ÞÅÍ ÄÁÎÎÁÑ ËÏÐÉÑX
-%s: ÚÁÝÉÔÁ ÎÁ ÚÁÐÉÓØ ÂÙÌÁ ÎÅÄÏÓÔÕÐÎÁX
-
-%s: ÷îéíáîéå: æáêì õóåþåîX
-
-%s: ÎÏ×ÙÊ ÆÁÊÌ: %lu ÓÔÒÏË, %lu ÓÉÍ×ÏÌÏ×X
-%s: %lu ÓÔÒÏË, %lu ÓÉÍ×ÏÌÏ×X
-%s ÒÁÓÛÉÒÉÌÓÑ × ÓÌÉÛËÏÍ ÂÏÌØÛÏÅ ËÏÌÉÞÅÓÔ×Ï ÉÍÅÎ ÆÁÊÌÏ×X
-%s: ÓÐÅÃÉÁÌØÎÙÊ ÆÁÊÌX
-%s: ÎÅ ÐÒÉÎÁÄÌÅÖÉÔ ÷ÁÍX
-%s: ÄÏÓÔÕÐÅÎ ÎÅ ÔÏÌØËÏ ÷ÁÍX
-æÁÊÌ ÉÚÍÅÎÅÎ ÓÏ ×ÒÅÍÅÎÉ ÐÏÓÌÅÄÎÅÊ ÚÁÐÉÓÉ: ÓÏÈÒÁÎÉÔÅ ÉÌÉ ÉÓÐÏÌØÚÕÊÔÅ ! ÄÌÑ ÏÂÈÏÄÁX
-æÁÊÌ ÉÚÍÅÎÅÎ ÓÏ ×ÒÅÍÅÎÉ ÐÏÓÌÅÄÎÅÊ ÚÁÐÉÓÉ: ÓÏÈÒÁÎÉÔÅ ÉÌÉ ÉÓÐÏÌØÚÕÊÔÅ :edit ÄÌÑ ÏÂÈÏÄÁX
-æÁÊÌ ÉÚÍÅÎÅÎ ÓÏ ×ÒÅÍÅÎÉ ÐÏÓÌÅÄÎÅÊ ÚÁÐÉÓÉ: ÓÏÈÒÁÎÉÔÅ ÉÌÉ ÉÓÐÏÌØÚÕÊÔÅ ! ÄÌÑ ÏÂÈÏÄÁX
-æÁÊÌ ×ÒÅÍÅÎÎÙÊ: ×ÙÈÏÄ ÓÏÔÒÅÔ ÌÀÂÙÅ ÉÚÍÅÎÅÎÉÑX
-
-úÁÐÉÓÉ ÎÁÞÁÔÙ ÚÁÎÏ×ÏX
diff --git a/contrib/nvi/catalog/ru_RU.KOI8-R.base b/contrib/nvi/catalog/ru_RU.KOI8-R.base
deleted file mode 100644
index a52532df5d84..000000000000
--- a/contrib/nvi/catalog/ru_RU.KOI8-R.base
+++ /dev/null
@@ -1,214 +0,0 @@
-002 "ðÅÒÅÐÏÌÎÅÎÉÅ ÚÎÁÞÅÎÉÑ ÄÌÉÎÙ ÓÔÒÏËÉ"
-003 "ÎÅ×ÏÚÍÏÖÎÏ ÕÄÁÌÉÔØ ÓÔÒÏËÕ %lu"
-004 "ÎÅ×ÏÚÍÏÖÎÏ ÄÏÂÁ×ÉÔØ Ë ÓÔÒÏËÅ %lu"
-005 "ÎÅ×ÏÚÍÏÖÎÏ ×ÓÔÁ×ÉÔØ × ÓÔÒÏËÕ %lu"
-006 "ÎÅ×ÏÚÍÏÖÎÏ ÓÏÈÒÁÎÉÔØ ÓÔÒÏËÕ %lu"
-007 "ÎÅ×ÏÚÍÏÖÎÏ ÄÏÓÔÁÔØ ÐÏÓÌÅÄÎÀÀ ÓÔÒÏËÕ"
-009 "æÁÊÌ ÚÁÐÉÓÅÊ"
-010 "úÁÐÉÓÉ ÎÅ ×ÅÌÉÓØ, ÎÅ×ÏÚÍÏÖÎÏ ÏÔÍÅÎÉÔØ ÐÏÓÌÅÄÎÀÀ ËÏÍÁÎÄÕ"
-011 "îÅÔ ÉÚÍÅÎÅÎÉÊ ÄÌÑ ÏÔÍÅÎÙ"
-012 "úÁÐÉÓÉ ÎÅ ×ÅÌÉÓØ, ÎÅ×ÏÚÍÏÖÎÏ ÏÔÍÅÎÉÔØ ÐÏÓÌÅÄÎÀÀ ËÏÍÁÎÄÕ"
-013 "úÁÐÉÓÉ ÎÅ ×ÅÌÉÓØ, ÎÅ×ÏÚÍÏÖÎÏ ÐÒÏÓÍÏÔÒÅÔØ ×ÐÅÒÅÄ"
-014 "îÅÔ ÉÚÍÅÎÅÎÉÊ ÄÌÑ ÐÅÒÅÄÅÌËÉ"
-015 "%s/%d: ÏÛÉÂËÁ ÐÒÉ ÚÁÐÉÓÉ ÐÒÏÔÏËÏÌÁ"
-016 "óÔÁÎÄÁÒÔÎÙÊ ××ÏÄ/×Ù×ÏÄ ÄÌÑ VI ÄÏÌÖÅÎ ÂÙÔØ ÔÅÒÍÉÎÁÌ"
-017 "ïÔÍÅÔËÁ %s: ÎÅ ÕÓÔÁÎÏ×ÌÅÎÁ"
-018 "ïÔÍÅÔËÁ %s: ÓÔÒÏËÁ ÂÙÌÁ ÕÄÁÌÅÎÁ"
-019 "ïÔÍÅÔËÁ %s: ÐÏÚÉÃÉÉ ËÕÒÓÏÒÁ ÂÏÌØÛÅ ÎÅ ÓÕÝÅÓÔ×ÕÅÔ"
-020 "ïÛÉÂËÁ: "
-030 "æÁÊÌ %s ÎÅ Ñ×ÌÑÅÔÓÑ ËÁÔÁÌÏÇÏÍ ÓÏÏÂÝÅÎÉÊ"
-031 "îÅ×ÏÚÍÏÖÎÏ ÕÓÔÁÎÏ×ÉÔØ ÏÐÃÉÀ %s ÐÏ ÕÍÏÌÞÁÎÉÀ"
-032 "éÓÐÏÌØÚÏ×ÁÎÉÅ: %s"
-033 "ïÐÃÉÉ %s ÎÅÔ: 'set all' ÐÏËÁÚÙ×ÁÅÔ ×ÓÅ ×ÏÚÍÏÖÎÙÅ ÏÐÃÉÉ"
-034 "set: [no]%s ÎÅ ÐÒÉÎÉÍÁÅÔ ÔÁËÏÇÏ ÚÎÁÞÅÎÉÑ"
-035 "set: %s ÏÐÃÉÑ ÎÅ Ñ×ÌÑÅÔÓÑ ÌÏÇÉÞÅÓËÏÊ"
-038 "set: ÎÅÐÒÁ×ÉÌØÎÏÅ ÚÎÁÞÅÎÉÅ %s"
-039 "set: %s ÏÐÃÉÑ ÎÅ Ñ×ÌÑÅÔÓÑ ÌÏÇÉÞÅÓËÏÊ"
-040 "ëÏÌÉÞÅÓÔ×Ï ËÏÌÏÎÏË ÜËÒÁÎÁ ÓÌÉÛËÏÍ ÍÁÌÏ, ÍÅÎØÛÅ ÞÅÍ %d"
-041 "ëÏÌÉÞÅÓÔ×Ï ËÏÌÏÎÏË ÜËÒÁÎÁ ÓÌÉÛËÏÍ ×ÅÌÉËÏ, ÂÏÌØÛÅ ÞÅÍ %d"
-042 "ëÏÌÉÞÅÓÔ×Ï ÓÔÒÏË ÜËÒÁÎÁ ÓÌÉÛËÏÍ ÍÁÌÏ, ÍÅÎØÛÅ ÞÅÍ %d"
-043 "ëÏÌÉÞÅÓÔ×Ï ÓÔÒÏË ÜËÒÁÎÁ ÓÌÉÛËÏÍ ×ÅÌÉËÏ, ÂÏÌØÛÅ ÞÅÍ %d"
-044 "ïÐÃÉÑ lisp ÏÔÓÕÔÓÔ×ÕÅÔ"
-045 "óÏÏÂÝÅÎÉÑ ÎÅ ×ÙËÌÀÞÅÎÙ: %s"
-046 "óÏÏÂÝÅÎÉÑ ÎÅ ×ËÌÀÞÅÎÙ: %s"
-048 "ïÐÃÉÑ paragraph ÄÏÌÖÎÁ ÓÏÓÔÏÑÔØ ÉÚ ÇÒÕÐÐ Ó Ä×ÕÍÑ ÓÉÍ×ÏÌÁÍÉ"
-049 "ïÐÃÉÑ section ÄÏÌÖÎÁ ÓÏÓÔÏÑÔØ ÉÚ ÇÒÕÐÐ Ó Ä×ÕÍÑ ÓÉÍ×ÏÌÁÍÉ"
-053 "óÔÁÒÔÏ×ÙÊ ÂÕÆÅÒ ÐÕÓÔ"
-054 "âÕÆÅÒ %s ÐÕÓÔ"
-055 "æÁÊÌÙ Ó ÓÉÍ×ÏÌÁÍÉ ÐÅÒÅ×ÏÄÁ ÓÔÒÏËÉ × ÉÍÅÎÉ ÎÅ ÍÏÇÕÔ ÂÙÔØ ×ÏÓÓÔÁÎÏ×ÌÅÎÙ"
-056 "éÚÍÅÎÅÎÉÑ ÎÅ ÓÏÈÒÁÎÅÎÙ ÐÒÉ ËÒÁÈÅ ÓÅÓÓÉÉ"
-058 "óÏÈÒÁÎÅÎÉÅ ÎÅ ÕÄÁÌÏÓØ: %s"
-059 "éÚÍÅÎÅÎÉÑ ÎÅ ÓÏÈÒÁÎÑÀÔÓÑ ÐÒÉ ÏÂÒÙ×Å ÓÅÓÓÉÉ"
-060 "óÏÈÒÁÎÅÎÉÅ ËÏÐÉÉ ÆÁÊÌÁ ÎÅ ÕÄÁÌÏÓØ: %s"
-062 "éÎÆÏÒÍÁÃÉÉ ÎÁ ÐÏÌØÚÏ×ÁÔÅÌÑ %u ÎÅ ÎÁÊÄÅÎÏ"
-063 "îÅ×ÏÚÍÏÖÎÏ ÚÁÝÉÔÉÔØ ÓÐÁÓÅÎÎÙÊ ÆÁÊÌ"
-064 "âÕÆÅÒ ×ÏÓÓÔÁÎÏ×ÌÅÎÎÏÇÏ ÆÁÊÌÁ ÐÅÒÅÐÏÌÎÅÎ"
-065 "÷ÏÓÓÔÁÎÏ×ÌÅÎÎÙÊ ÆÁÊÌ"
-066 "%s: ÎÅ ÄÏ ËÏÎÃÁ ×ÏÓÓÔÁÎÏ×ÌÅÎÎÙÊ ÆÁÊÌ"
-067 "%s: ÎÅ ÄÏ ËÏÎÃÁ ×ÏÓÓÔÁÎÏ×ÌÅÎÎÙÊ ÆÁÊÌ"
-068 "æÁÊÌÏ× Ó ÉÍÅÎÅÍ %s, ËÏÔÏÒÙÅ ÷Ù ÍÏÖÅÔÅ ÞÉÔÁÔØ, ÎÅ ÓÕÝÅÓÔ×ÕÅÔ"
-069 "åÓÔØ ÓÔÁÒÙÅ ×ÅÒÓÉÉ ÆÁÊÌÁ, ËÏÔÏÒÙÅ ÍÏÖÎÏ ×ÏÓÓÔÁÎÏ×ÉÔØ"
-070 "óÕÝÅÓÔ×ÕÀÔ ÄÒÕÇÉÅ ÆÁÊÌÙ, ËÏÔÏÒÙÅ ÍÏÖÎÏ ×ÏÓÓÔÁÎÏ×ÉÔØ"
-071 "Å-mail ÎÅ ÐÏÓÌÁÎ: %s"
-072 "æÁÊÌ ÐÕÓÔ - ÉÓËÁÔØ ÎÅÞÅÇÏ"
-073 "äÏÓÔÉÇÎÕÔ ËÏÎÅà ÆÁÊÌÁ ÂÅÚ ÎÁÈÏÖÄÅÎÉÑ ÏÂÒÁÚÃÁ ÐÏÉÓËÁ"
-074 "îÅ ÚÁÄÁÎ ÏÂÒÁÚÅà ÐÏÉÓËÁ"
-075 "ïÂÒÁÚÅà ÐÏÉÓËÁ ÎÅ ÎÁÊÄÅÎ"
-076 "äÏÓÔÕÐÎÏ ÎÁÞÁÌÏ ÆÁÊÌÁ ÂÅÚ ÎÁÈÏÖÄÅÎÉÑ ÏÂÒÁÚÃÁ ÐÏÉÓËÁ"
-077 "ðÏÉÓË ÚÁÃÉËÌÅÎ"
-079 "îÅÐÅÞÁÔÎÙÈ ÓÉÍ×ÏÌÏ× ÎÅ ÎÁÊÄÅÎÏ"
-080 "îÅÉÚ×ÅÓÔÎÁÑ ËÏÍÁÎÄÁ"
-082 "%s: ËÏÍÁÎÄÁ ÎÅ ÄÏÓÔÕÐÎÁ × ÒÅÖÉÍÅ ex"
-083 "óÞÅÔÞÉË ÎÅ ÍÏÖÅÔ ÂÙÔØ ÎÕÌÅÍ"
-084 "%s: ÎÅÐÒÁ×ÉÌØÎÏÅ ÕËÁÚÁÎÉÅ ÓÔÒÏËÉ"
-085 "÷ÎÕÔÒÅÎÎÑÑ ÏÛÉÂËÁ × ÓÉÎÔÁËÓÉÓÅ (%s: %s)"
-086 "éÓÐÏÌØÚÏ×ÁÎÉÅ: %s"
-087 "%s: ×ÒÅÍÅÎÎÙÊ ÂÕÆÅÒ ÎÅ ÉÓÐÏÌØÚÏ×ÁÎ"
-088 "íÅÔËÁ ÐÏÓÔÁ×ÌÅÎÁ ÐÅÒÅÄ ÓÔÒÏËÏÊ 1"
-089 "íÅÔËÁ ÐÏÓÔÁ×ÌÅÎÁ ÐÏÓÌÅ ËÏÎÃÁ ÆÁÊÌÁ"
-092 "ëÏÍÁÎÄÁ ex ÎÅ ÕÄÁÌÁÓØ: ÐÏÓÌÅÄÕÀÝÉÅ ËÏÍÁÎÄÙ ÚÁÂÙÔÙ"
-094 "÷ÔÏÒÏÊ ÁÄÒÅÓ ÍÅÎØÛÅ ÞÅÍ ÐÅÒ×ÙÊ"
-095 "îÅ ÕËÁÚÁÎÏ ÎÁÚ×ÁÎÉÅ ÏÔÍÅÔËÉ"
-096 "\\ ÎÅ ÚÁ×ÅÒÛÁÅÔÓÑ / ÉÌÉ ?"
-097 "óÓÙÌËÁ Ë ÓÔÒÏËÅ Ó ÎÏÍÅÒÏÍ ÍÅÎØÛÅ 0"
-098 "ëÏÍÁÎÄÁ %s ÎÅÉÚ×ÅÓÔÎÁ"
-099 "ðÅÒÅÐÏÌÎÅÎÉÅ ÚÎÁÞÅÎÉÑ ÁÄÒÅÓÁ"
-100 "îÅÄÏÂÏÒ ÚÎÁÞÅÎÉÑ ÁÄÒÅÓÁ"
-101 "îÅÄÏÐÕÓÔÉÍÁÑ ËÏÍÂÉÎÁÃÉÑ × ÁÄÒÅÓÅ"
-102 "îÅÐÒÁ×ÉÌØÎÙÊ ÁÄÒÅÓ: ×ÓÅÇÏ %lu ÓÔÒÏË × ÆÁÊÌÅ"
-103 "îÅÐÒÁ×ÉÌØÎÙÊ ÁÄÒÅÓ: ÆÁÊÌ ÐÕÓÔ"
-104 "ëÏÍÍÁÎÄÁ %s ÎÅ ÍÏÖÅÔ ÉÓÐÏÌØÚÏ×ÁÔØ ÁÄÒÅÓ 0"
-105 "áÂÂÒÅ×ÉÁÔÕÒÙ ÏÔÓÕÔÓÔ×ÕÀÔ"
-106 "áÂÂÒÅ×ÉÁÔÕÒÙ ÄÏÌÖÎÙ ÚÁËÁÎÞÉ×ÁÔØÓÑ ÓÉÍ×ÏÌÏÍ "word""
-107 "áÂÂÒÅ×ÉÁÔÕÒÙ ÎÅ ÍÏÇÕÔ ÓÏÄÅÒÖÁÔØ ÓÉÍ×ÏÌÏÙ ÔÁÂÌÑÃÉÉ ÉÌÉ ÐÒÏÂÅÌÙ"
-108 "áÂÂÒÅ×ÉÁÔÕÒÙ ÎÅ ÍÏÇÕÔ ÓÏÞÅÔÁÔØÓÑ Ó ÓÉÍ×ÏÌÁÍÉ ÓÌÏ×/ÎÅ-ÓÌÏ×, ÚÁ ÉÓËÌÀÞÅÎÉÅÍ ËÏÎÃÁ ÓÔÒÏËÉ"
-109 ""%s" ÎÅ Ñ×ÌÑÅÔÓÑ ÁÂÂÒÅ×ÉÁÔÕÒÏÊ"
-111 "æÁÊÌÏ× ÄÌÑ ÒÅÄÁËÔÉÒÏ×ÁÎÉÑ ÂÏÌØÛÅ ÎÅÔ"
-112 "ïÔÓÕÔÓÔ×ÉÅ ÐÒÅÄÙÄÕÝÅÇÏ ÆÁÊÌÁ ÄÌÑ ÒÅÄÁËÔÉÒÏ×ÁÎÉÑ"
-113 "ïÔÓÕÔÓÔ×ÉÅ ÐÒÅÄÙÄÕÝÅÇÏ ÆÁÊÌÁ ÄÌÑ ÐÒÏÓÍÏÔÒÁ ÎÁÚÁÄ"
-114 "îÅÔ ÆÁÊÌÏ×"
-115 "ïÔÓÕÔÓÔ×ÉÅ ÐÒÅÄÙÄÕÝÅÊ ËÏÍÁÎÄÙ ÄÌÑ ÚÁÍÅÎÙ "!""
-116 "ïÔÓÕÔÓÔ×ÉÅ ÚÁÍÅÎÙ ÄÌÑ %%"
-117 "ïÔÓÕÔÓÔ×ÉÅ ÚÁÍÅÎÙ ÄÌÑ #"
-118 "ïÛÉÂËÁ: execl: %s"
-119 "ïÛÉÂËÁ ××ÏÄÁ/×Ù×ÏÄÁ: %s"
-120 "æÁÊÌ ÉÚÍÅÎÅÎ Ó ÍÏÍÅÎÔÁ ÐÏÓÌÅÄÎÅÊ ÐÏÌÎÏÊ ÚÁÐÉÓÉ: ÉÓÐÏÌØÚÕÊÔÅ ! ÄÌÑ ÏÂÈÏÄÁ"
-121 "îÅ×ÏÚÍÏÖÎÏ ÎÁÊÔÉ ÄÏÍÁÛÎÉÊ ËÁÔÁÌÏÇ"
-122 "îÏ×ÙÊ ËÁÔÁÌÏÇ: %s"
-123 "îÅÔ ×ÙÒÅÚÁÎÙÈ ÂÕÆÅÒÏ×"
-124 "ëÏÍÁÎÄÁ %s ÎÅ ÍÏÖÅÔ ÂÙÔØ ÉÓÐÏÌØÚÏ×ÁÎÁ ×ÎÕÔÒÉ ÇÌÏÂÁÌØÎÏÊ ÉÌÉ v ËÏÍÁÎÄÙ"
-125 "%s/%s: ÎÅ ÏÔËÒÙÔ: ÎÅ ÐÒÉÎÁÄÌÅÖÉÔ ÷ÁÍ ÉÌÉ root-Õ"
-126 "%s/%s: ÎÅ ÏÔËÒÙÔ: ÎÅ ÐÒÉÎÁÄÌÅÖÉÔ ÷ÁÍ"
-127 "%s/%s: ÎÅ ÏÔËÒÙÔ: ×ÏÚÍÏÖÎÏÓÔØ ÚÁÐÉÓÉ Õ ÐÏÌØÚÏ×ÁÔÅÌÑ, ÎÅ Ñ×ÌÑÀÝÅÇÏÓÑ ×ÌÁÄÅÌØÃÅÍ"
-128 "%s: ÎÅ ÓÞÉÔÁÎ: ÎÅ ÐÒÉÎÁÄÌÅÖÉÔ ÷ÁÍ ÉÌÉ root-Õ"
-129 "%s: ÎÅ ÓÞÉÔÁÎ: ÎÅ ÐÒÉÎÁÄÌÅÖÉÔ ÷ÁÍ"
-130 "%s: ÎÅ ÓÞÉÔÁÎ: ×ÏÚÍÏÖÎÏÓÔØ ÚÁÐÉÓÉ Õ ÐÏÌØÚÏ×ÁÔÅÌÑ, ÎÅ Ñ×ÌÑÀÝÅÇÏÓÑ ×ÌÁÄÅÌØÃÅÍ"
-131 "ðÏÓÌÅÄÕÀÝÉÅ ÓÔÒÏËÉ ÏÔÓÕÔÓÔ×ÕÀÔ"
-132 "ïÔÓÕÔÓÔ×ÉÅ ÐÁÒÁÍÅÔÒÏ× ××ÏÄÁ"
-133 "ïÔÓÕÔÓÔ×ÉÅ ÐÁÒÁÍÅÔÒÏ× ËÏÍÁÎÄÙ"
-134 "óÉÍ×ÏÌ %s ÎÅ ÍÏÖÅÔ ÂÙÔØ ÐÅÒÅÎÁÚÎÁÞÅÎ"
-135 ""%s" ÎÁ ÄÁÎÎÙÊ ÍÏÍÅÎÔ ÎÅ ÎÁÚÎÁÞÅÎ"
-136 "éÍÑ ÍÅÔËÉ ÄÏÌÖÎÏ ÂÙÔØ ÏÄÎÉÍ ÓÉÍ×ÏÌÏÍ"
-137 "%s ÓÕÝÅÓÔ×ÕÅÔ, ÎÅ ÚÁÐÉÓÁÎ; ÉÓÐÏÌØÚÕÊÔÅ ! ÄÌÑ ÏÂÈÏÄÁ"
-138 "îÏ×ÙÊ ÆÁÊÌ exrc: %s"
-139 "óÔÒÏËÁ ÐÅÒÅÎÏÓÁ ÎÁÈÏÄÉÔÓÑ ×ÎÕÔÒÉ ÐÁÒÁÍÅÔÒÏ× ÐÅÒÅÎÏÓÁ"
-140 "ëÏÍÁÎÄÁ open ÐÏÄÒÁÚÕÍÅ×ÁÅÔ ÕÓÔÁÎÏ×ËÕ ÏÐÃÉÉ open"
-141 "ëÏÍÁÎÄÁ open ÎÅ ÒÅÁÌÉÚÏ×ÁÎÁ"
-142 "úÁÝÉÔÁ ÆÁÊÌÁ ÎÅ×ÏÚÍÏÖÎÁ"
-143 "æÁÊÌ ÚÁÝÉÝÅÎ"
-144 "%s ÒÁÓÛÉÒÉÌÓÑ × ÓÌÉÛËÏÍ ÂÏÌØÛÏÅ ËÏÌÉÞÅÓÔ×Ï ÉÍÅÎ ÆÁÊÌÏ×"
-146 "%s: ÚÁÝÉÔÁ ÎÁ ÞÔÅÎÉÅ ÂÙÌÁ ÎÅÄÏÓÔÕÐÎÁ"
-148 "%s: %lu ÓÔÒÏË, %lu ÓÉÍ×ÏÌÏ×"
-149 "îÅÔ ÔÅÎÅ×ÙÈ ÏËÏÎ"
-150 "ëÏÍÁÎÄÁ script ÉÓÐÏÌØÚÕÅÔÓÑ ÔÏÌØËÏ × ÒÅÖÉÍÅ vi"
-151 "îÅÔ ËÏÍÁÎÄÙ ÄÌÑ ÉÓÐÏÌÎÅÎÉÑ"
-152 "ïÐÃÉÑ shiftwidth ÕÓÔÁÎÏ×ÌÅÎÁ ÎÁ 0"
-153 "ðÅÒÅÐÏÌÎÅÎÉÅ ÓÞÅÔÞÉËÁ"
-154 "ãÉËÌ ×ÙÐÏÌÎÅÎ ÎÅ ÄÏ ËÏÎÃÁ"
-155 "õËÁÚÁÎÏ ÒÅÇÕÌÑÒÎÏÅ ×ÙÒÁÖÅÎÉÅ: ÆÌÁÇ r ÎÅ ÎÕÖÅÎ"
-156 "æÌÁÇÉ #, l É p ÎÅ ÍÏÇÕÔ ÂÙÔØ ÏÂßÅÄÉÎÅÎÙ Ó ÆÌÁÇÏÍ c × ÒÅÖÉÍÅ vi"
-157 "óÏ×ÐÁÄÅÎÉÊ ÎÅÔ"
-158 "íÅÔËÁ ÏÔÓÕÔÓÔ×ÕÅÔ"
-159 "÷ ÓÔÅËÅ ÍÅÔÏË ÚÁÐÉÓÅÊ ÍÅÎØÛÅ, ÞÅÍ %s, ÉÓÐÏÌØÚÕÊÔÅ :display t[ags]"
-160 "æÁÊÌÁ Ó ÉÍÅÎÅÍ %s × ÓÔÅËÅ ÍÅÔÏË ÎÅÔ; ÉÓÐÏÌØÚÕÊÔÅ :display t[ags]"
-162 "%s: ÍÅÔËÁ ÎÅ ÎÁÊÄÅÎÁ"
-163 "%s: ÐÌÏÈÁÑ ÍÅÔËÁ × %s"
-165 "óÔÅË ÍÅÔÏË ÐÕÓÔ"
-166 "%s: ÏÂÒÁÚÅÃ ÐÏÉÓËÁ ÎÅ ÎÁÊÄÅÎ"
-168 "âÕÆÅÒ %s ÐÕÓÔ"
-170 "ðÒÅÒ×ÁÎÏ"
-171 "ïÔÓÕÔÓÔ×ÉÅ ÂÕÆÅÒÁ ÄÌÑ ÉÓÐÏÌØÚÏ×ÁÎÉÑ"
-172 "îÅÔ ÐÒÅÄÉÄÕÝÅÇÏ ÒÅÇÕÌÑÒÎÏÇÏ ×ÙÒÁÖÅÎÉÑ"
-173 "ëÏÍÁÎÄÁ %s ÐÏÄÒÁÚÕÍÅ×ÁÅÔ ÎÁÌÉÞÉÅ ÐÒÏÞÔÅÎÎÏÇÏ ÆÁÊÌÁ"
-174 "éÓÐÏÌØÚÏ×ÁÎÉÅ: %s"
-175 "ëÏÍÁÎÄÁ visual ÐÏÄÒÁÚÕÍÅ×ÁÅÔ ÏÂÑÚÁÔÅÌØÎÕÀ ÕÓÔÁÎÏ×ËÕ ÏÐÃÉÉ open"
-177 "ðÕÓÔÏÊ ÆÁÊÌ"
-178 "îÅÔ ÐÒÅÄÙÄÕÝÅÇÏ ÐÏÉÓËÁ F, f, T, ÉÌÉ t"
-179 "%s ÎÅ ÎÁÊÄÅÎÏ"
-180 "îÅÔ ÐÒÅÄÙÄÕÝÅÇÏ ÆÁÊÌÁ ÄÌÑ ÒÅÄÁËÔÉÒÏ×ÁÎÉÑ"
-181 "ëÕÒÓÏÒ ÓÔÏÉÔ ÎÅ ÎÁ ÃÉÆÒÅ"
-182 "ðÏÌÕÞÅÎÎÏÅ ÞÉÓÌÏ ÓÌÉÛËÏÍ ×ÅÌÉËÏ"
-183 "ðÏÌÕÞÅÎÎÏÅ ÞÉÓÌÏ ÓÌÉÛËÏÍ ÍÁÌÏ"
-184 "ðÏÄÈÏÄÑÝÅÇÏ ÓÉÍ×ÏÌÁ ÎÅÔ ÎÁ ÜÔÏÊ ÓÔÒÏËÅ"
-185 "ðÏÄÈÏÄÑÝÉÊ ÓÉÍ×ÏÌ ÎÅ ÎÁÊÄÅÎ"
-186 "îÅÔ ÓÉÍ×ÏÌÏ× ÄÌÑ ÕÄÁÌÅÎÉÑ"
-187 "äÒÕÇÏÇÏ ÜËÒÁÎÁ ÎÅ ÓÕÝÅÓÔ×ÕÅÔ"
-188 "óÉÍ×ÏÌÙ ÐÏÓÌÅ ÓÔÒÏËÉ ÄÌÑ ÐÏÉÓËÁ, ÓÍÅÝÅÎÉÑ ÓÔÒÏËÉ É/ÉÌÉ ËÏÍÁÎÄÙ z"
-189 "ðÒÏÛÌÙÊ ÏÂÒÁÚÅÃ ÐÏÉÓËÁ ÏÔÓÕÔÓÔ×ÕÅÔ"
-190 "ðÏÉÓË ÚÁ×ÅÒÛÉÌÓÑ ÎÁ ÎÁÞÁÌØÎÏÊ ÐÏÚÉÃÉÉ"
-192 "óÉÍ×ÏÌ ÎÅÐÒÁ×ÉÌÅÎ; Ë×ÏÔÉÒÕÊÔÅ ÄÌÑ ××ÏÄÁ"
-193 "õÖÅ ÎÁ ÎÁÞÁÌÅ ×ÓÔÁ×ËÉ"
-194 "îÅÔ ÓÉÍ×ÏÌÏ× ÄÌÑ ÕÄÁÌÅÎÉÑ"
-195 "ðÅÒÅÄ×ÉÖÅÎÉÅ ÚÁ ËÏÎÅà ÆÁÊÌÁ"
-196 "ðÅÒÅÄ×ÉÖÅÎÉÅ ÚÁ ËÏÎÅà ÓÔÒÏËÉ"
-197 "ä×ÉÖÅÎÉÅ ÓÔÒÏËÉ ÎÅ ÓÄÅÌÁÎÏ"
-198 "õÖÅ ÎÁ ÎÁÞÁÌÅ ÆÁÊÌÁ"
-199 "ä×ÉÖÅÎÉÅ ËÕÒÓÏÒÁ ÚÁ ÎÁÞÁÌÏ ÆÁÊÌÁ"
-200 "õÖÅ × ÐÅÒ×ÏÊ ËÏÌÏÎËÅ"
-201 "âÕÆÅÒÙ ÄÏÌÖÎÙ ÂÙÔØ ÕËÁÚÁÎÙ ÄÏ ×ÙÐÏÌÎÅÎÉÑ ËÏÍÁÎÄÙ"
-202 "õÖÅ ÎÁ ËÏÎÃÅ ÆÁÊÌÁ"
-203 "õÖÅ ÎÁ ËÏÎÃÅ ÓÔÒÏËÉ"
-204 "%s ÎÅ Ñ×ÌÑÅÔÓÑ ËÏÍÁÎÄÏÊ VI"
-205 "éÓÐÏÌØÚÏ×ÁÎÉÅ: %s"
-206 "îÅÔ ÓÉÍ×ÏÌÏ× ÄÌÑ ÕÄÁÌÅÎÉÑ"
-208 "îÅÔ ËÏÍÁÎÄÙ ÄÌÑ ÐÏ×ÔÏÒÁ"
-210 "ëÏÍÁÎÄÁ %s ÎÅ ÍÏÖÅÔ ÂÙÔØ ÉÓÐÏÌØÚÏ×ÁÎÁ ËÁË ËÏÍÁÎÄÁ ÐÅÒÅÍÅÝÅÎÉÑ"
-211 "õÖÅ × ËÏÍÁÎÄÎÏÍ ÒÅÖÉÍÅ"
-214 "úÎÁÞÅÎÉÅ ÏÐÃÉÉ windows ÓÌÉÛËÏÍ ×ÅÌÉËÏ, ÍÁËÓÉÍÁÌØÎÏÅ ÚÎÁÞÅÎÉÅ = %u"
-220 "ä×ÉÖÅÎÉÅ ËÕÒÓÏÒÁ ÚÁ ËÏÎÅà ÜËÒÁÎÁ"
-221 "ä×ÉÖÅÎÉÅ ËÕÒÓÏÒÁ ÚÁ ÎÁÞÁÌÏ ÜËÒÁÎÁ"
-223 "ôÅÎÅ×ÙÈ ÏËÏÎ ÎÅÔ"
-224 "îÅ ÓÕÝÅÓÔ×ÕÅÔ ÔÅÎÅ×ÏÇÏ ÏËÎÁ Ó ÒÅÄÁËÔÉÒÏ×ÁÎÉÅÍ ÆÁÊÌÁ %s"
-225 "÷Ù ÎÅ ÍÏÖÅÔÅ ÓÄÅÌÁÔØ ÅÄÉÎÓÔ×ÅÎÎÏÅ ÏËÎÏ ÔÅÎÅ×ÙÍ"
-226 "üËÒÁÎ ÍÏÖÅÔ ÂÙÔØ ÓÖÁÔ"
-227 "üËÒÁÎ ÎÅ ÍÏÖÅÔ ÂÙÔØ ÓÖÁÔ ÔÏÌØËÏ ÄÏ %d ÓÔÒÏË"
-228 "üËÒÁÎ ÎÅ ÍÏÖÅÔ ÂÙÔØ ÒÁÓÛÉÒÅÎ"
-233 "äÁÎÎÙÊ ÔÉÐ ÔÅÒÍÉÎÁÌÁ ÎÅ ÉÍÅÅÔ ËÌÁ×ÉÛÉ %s"
-237 "îÅ×ÏÚÍÏÖÎÏ ÓÏÚÄÁÔØ ×ÒÅÍÅÎÎÙÊ ÆÁÊÌ"
-238 "÷ÎÉÍÁÎÉÅ: %s ÓÐÅÃÉÁÌØÎÙÊ ÆÁÊÌ"
-239 "%s ÕÖÅ ÚÁÂÌÏËÉÒÏ×ÁÎ, ÄÏÓÔÕÐÅÎ ÔÏÌØËÏ ÎÁ ÞÔÅÎÉÅ"
-240 "%s: ÕÄÁÌÅÎ"
-241 "%s: ÚÁËÒÙÔ"
-242 "%s: ÕÄÁÌÅÎ"
-243 "%s: ÕÄÁÌÅÎ"
-244 "æÁÊÌ ÔÏÌØËÏ ÄÌÑ ÞÔÅÎÉÑ, ÎÅ ÚÁÐÉÓÁÎ: éÓÐÏÌØÚÕÊÔÅ ! ÄÌÑ ÏÂÈÏÄÁ"
-245 "æÁÊÌ ÔÏÌØËÏ ÄÌÑ ÞÔÅÎÉÑ, ÎÅ ÚÁÐÉÓÁÎ"
-246 "%s ÓÕÝÅÓÔ×ÕÅÔ, ÎÅ ÚÁÐÉÓÁÎ; ÉÓÐÏÌØÚÕÊÔÅ ! ÄÌÑ ÏÂÈÏÄÁ"
-247 "%s ÓÕÝÅÓÔ×ÕÅÔ, ÎÅ ÚÁÐÉÓÁÎ"
-248 "éÓÐÏÌØÚÕÊÔÅ ! ÄÌÑ ÞÁÓÔÉÞÎÏÊ ÚÁÐÉÓÉ ÆÁÊÌÁ"
-249 "þÁÓÔØ ÆÁÊÌÁ, ÆÁÊÌ ÎÅ ÚÁÐÉÓÁÎ"
-250 "%s: æÁÊÌ ÉÚÍÅÎÑÌÓÑ ÐÏÚÄÎÅÅ, ÞÅÍ ÄÁÎÎÁÑ ËÏÐÉÑ: ÉÓÐÏÌØÚÕÊÔÅ ! ÄÌÑ ÏÂÈÏÄÁ"
-251 "%s: æÁÊÌ ÉÚÍÅÎÑÌÓÑ ÐÏÚÄÎÅÅ, ÞÅÍ ÄÁÎÎÁÑ ËÏÐÉÑ"
-252 "%s: ÚÁÝÉÔÁ ÎÁ ÚÁÐÉÓØ ÂÙÌÁ ÎÅÄÏÓÔÕÐÎÁ"
-254 "%s: ÷îéíáîéå: æáêì õóåþåî"
-256 "%s: ÎÏ×ÙÊ ÆÁÊÌ: %lu ÓÔÒÏË, %lu ÓÉÍ×ÏÌÏ×"
-257 "%s: %lu ÓÔÒÏË, %lu ÓÉÍ×ÏÌÏ×"
-258 "%s ÒÁÓÛÉÒÉÌÓÑ × ÓÌÉÛËÏÍ ÂÏÌØÛÏÅ ËÏÌÉÞÅÓÔ×Ï ÉÍÅÎ ÆÁÊÌÏ×"
-259 "%s: ÓÐÅÃÉÁÌØÎÙÊ ÆÁÊÌ"
-260 "%s: ÎÅ ÐÒÉÎÁÄÌÅÖÉÔ ÷ÁÍ"
-261 "%s: ÄÏÓÔÕÐÅÎ ÎÅ ÔÏÌØËÏ ÷ÁÍ"
-262 "æÁÊÌ ÉÚÍÅÎÅÎ ÓÏ ×ÒÅÍÅÎÉ ÐÏÓÌÅÄÎÅÊ ÚÁÐÉÓÉ: ÓÏÈÒÁÎÉÔÅ ÉÌÉ ÉÓÐÏÌØÚÕÊÔÅ ! ÄÌÑ ÏÂÈÏÄÁ"
-263 "æÁÊÌ ÉÚÍÅÎÅÎ ÓÏ ×ÒÅÍÅÎÉ ÐÏÓÌÅÄÎÅÊ ÚÁÐÉÓÉ: ÓÏÈÒÁÎÉÔÅ ÉÌÉ ÉÓÐÏÌØÚÕÊÔÅ :edit ÄÌÑ ÏÂÈÏÄÁ"
-264 "æÁÊÌ ÉÚÍÅÎÅÎ ÓÏ ×ÒÅÍÅÎÉ ÐÏÓÌÅÄÎÅÊ ÚÁÐÉÓÉ: ÓÏÈÒÁÎÉÔÅ ÉÌÉ ÉÓÐÏÌØÚÕÊÔÅ ! ÄÌÑ ÏÂÈÏÄÁ"
-265 "æÁÊÌ ×ÒÅÍÅÎÎÙÊ: ×ÙÈÏÄ ÓÏÔÒÅÔ ÌÀÂÙÅ ÉÚÍÅÎÅÎÉÑ"
-267 "úÁÐÉÓÉ ÎÁÞÁÔÙ ÚÁÎÏ×Ï"
diff --git a/contrib/nvi/catalog/ru_RU.KOI8-R.check b/contrib/nvi/catalog/ru_RU.KOI8-R.check
deleted file mode 100644
index 6dcca1b8246e..000000000000
--- a/contrib/nvi/catalog/ru_RU.KOI8-R.check
+++ /dev/null
@@ -1,169 +0,0 @@
-Unused message id's (this is okay):
-001
-008
-021
-022
-023
-024
-025
-026
-027
-028
-029
-036
-037
-047
-050
-051
-052
-057
-061
-078
-081
-090
-091
-093
-110
-145
-147
-161
-164
-167
-169
-176
-191
-207
-209
-212
-213
-215
-216
-217
-218
-219
-222
-229
-230
-231
-232
-234
-235
-236
-253
-255
-266
-=========================
-MISSING ERROR MESSAGES (Please add!):
-008
-021
-022
-023
-024
-025
-026
-027
-028
-029
-036
-037
-057
-061
-078
-090
-091
-093
-110
-145
-147
-161
-164
-167
-169
-191
-207
-209
-212
-215
-216
-217
-218
-219
-222
-230
-231
-232
-234
-235
-236
-253
-255
-266
-268
-269
-270
-271
-272
-273
-274
-275
-276
-277
-278
-279
-280
-281
-282
-283
-284
-285
-286
-287
-289
-290
-291
-292
-293
-294
-295
-296
-297
-298
-299
-300
-301
-302
-303
-304
-305
-306
-307
-308
-309
-310
-311
-312
-313
-314
-315
-316
-317
-=========================
-Extra error messages (just delete them):
-=========================
-MESSAGES WITH THE SAME MESSAGE ID's (FIX!):
-=========================
-Duplicate messages, both id and message (this is okay):
-=========================
-Duplicate messages, just message (this is okay):
- 2 %s ÒÁÓÛÉÒÉÌÓÑ × ÓÌÉÛËÏÍ ÂÏÌØÛÏÅ ËÏÌÉÞÅÓÔ×Ï ÉÍÅÎ ÆÁÊÌÏ×X
- 2 %s ÓÕÝÅÓÔ×ÕÅÔ, ÎÅ ÚÁÐÉÓÁÎ; ÉÓÐÏÌØÚÕÊÔÅ ! ÄÌÑ ÏÂÈÏÄÁX
- 2 %s: %lu ÓÔÒÏË, %lu ÓÉÍ×ÏÌÏ×X
- 2 %s: ÎÅ ÄÏ ËÏÎÃÁ ×ÏÓÓÔÁÎÏ×ÌÅÎÎÙÊ ÆÁÊÌX
- 2 âÕÆÅÒ %s ÐÕÓÔX
- 2 úÁÐÉÓÉ ÎÅ ×ÅÌÉÓØ, ÎÅ×ÏÚÍÏÖÎÏ ÏÔÍÅÎÉÔØ ÐÏÓÌÅÄÎÀÀ ËÏÍÁÎÄÕX
- 2 æÁÊÌ ÉÚÍÅÎÅÎ ÓÏ ×ÒÅÍÅÎÉ ÐÏÓÌÅÄÎÅÊ ÚÁÐÉÓÉ: ÓÏÈÒÁÎÉÔÅ ÉÌÉ ÉÓÐÏÌØÚÕÊÔÅ ! ÄÌÑ ÏÂÈÏÄÁX
- 2 set: %s ÏÐÃÉÑ ÎÅ Ñ×ÌÑÅÔÓÑ ÌÏÇÉÞÅÓËÏÊX
- 3 %s: ÕÄÁÌÅÎX
- 3 îÅÔ ÓÉÍ×ÏÌÏ× ÄÌÑ ÕÄÁÌÅÎÉÑX
- 4 éÓÐÏÌØÚÏ×ÁÎÉÅ: %sX
-=========================
diff --git a/contrib/nvi/catalog/ru_RU.KOI8-R.owner b/contrib/nvi/catalog/ru_RU.KOI8-R.owner
deleted file mode 100644
index 077a0a68836b..000000000000
--- a/contrib/nvi/catalog/ru_RU.KOI8-R.owner
+++ /dev/null
@@ -1 +0,0 @@
-Dima Ruban <dima@rdy.com>, "Andrey A. Chernov" <ache@nagual.ru>
diff --git a/contrib/telnet/arpa/telnet.h b/contrib/telnet/arpa/telnet.h
deleted file mode 100644
index 8a17ff160f71..000000000000
--- a/contrib/telnet/arpa/telnet.h
+++ /dev/null
@@ -1,341 +0,0 @@
-/*
- * Copyright (c) 1983, 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)telnet.h 8.2 (Berkeley) 12/15/93
- */
-
-#ifndef _ARPA_TELNET_H_
-#define _ARPA_TELNET_H_
-
-/*
- * Definitions for the TELNET protocol.
- */
-#define IAC 255 /* interpret as command: */
-#define DONT 254 /* you are not to use option */
-#define DO 253 /* please, you use option */
-#define WONT 252 /* I won't use option */
-#define WILL 251 /* I will use option */
-#define SB 250 /* interpret as subnegotiation */
-#define GA 249 /* you may reverse the line */
-#define EL 248 /* erase the current line */
-#define EC 247 /* erase the current character */
-#define AYT 246 /* are you there */
-#define AO 245 /* abort output--but let prog finish */
-#define IP 244 /* interrupt process--permanently */
-#define BREAK 243 /* break */
-#define DM 242 /* data mark--for connect. cleaning */
-#define NOP 241 /* nop */
-#define SE 240 /* end sub negotiation */
-#define EOR 239 /* end of record (transparent mode) */
-#define ABORT 238 /* Abort process */
-#define SUSP 237 /* Suspend process */
-#define xEOF 236 /* End of file: EOF is already used... */
-
-#define SYNCH 242 /* for telfunc calls */
-
-#ifdef TELCMDS
-char *telcmds[] = {
- "EOF", "SUSP", "ABORT", "EOR",
- "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC",
- "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC",
- 0
-};
-#else
-extern char *telcmds[];
-#endif
-
-#define TELCMD_FIRST xEOF
-#define TELCMD_LAST IAC
-#define TELCMD_OK(x) ((unsigned int)(x) <= TELCMD_LAST && \
- (unsigned int)(x) >= TELCMD_FIRST)
-#define TELCMD(x) telcmds[(x)-TELCMD_FIRST]
-
-/* telnet options */
-#define TELOPT_BINARY 0 /* 8-bit data path */
-#define TELOPT_ECHO 1 /* echo */
-#define TELOPT_RCP 2 /* prepare to reconnect */
-#define TELOPT_SGA 3 /* suppress go ahead */
-#define TELOPT_NAMS 4 /* approximate message size */
-#define TELOPT_STATUS 5 /* give status */
-#define TELOPT_TM 6 /* timing mark */
-#define TELOPT_RCTE 7 /* remote controlled transmission and echo */
-#define TELOPT_NAOL 8 /* negotiate about output line width */
-#define TELOPT_NAOP 9 /* negotiate about output page size */
-#define TELOPT_NAOCRD 10 /* negotiate about CR disposition */
-#define TELOPT_NAOHTS 11 /* negotiate about horizontal tabstops */
-#define TELOPT_NAOHTD 12 /* negotiate about horizontal tab disposition */
-#define TELOPT_NAOFFD 13 /* negotiate about formfeed disposition */
-#define TELOPT_NAOVTS 14 /* negotiate about vertical tab stops */
-#define TELOPT_NAOVTD 15 /* negotiate about vertical tab disposition */
-#define TELOPT_NAOLFD 16 /* negotiate about output LF disposition */
-#define TELOPT_XASCII 17 /* extended ascic character set */
-#define TELOPT_LOGOUT 18 /* force logout */
-#define TELOPT_BM 19 /* byte macro */
-#define TELOPT_DET 20 /* data entry terminal */
-#define TELOPT_SUPDUP 21 /* supdup protocol */
-#define TELOPT_SUPDUPOUTPUT 22 /* supdup output */
-#define TELOPT_SNDLOC 23 /* send location */
-#define TELOPT_TTYPE 24 /* terminal type */
-#define TELOPT_EOR 25 /* end or record */
-#define TELOPT_TUID 26 /* TACACS user identification */
-#define TELOPT_OUTMRK 27 /* output marking */
-#define TELOPT_TTYLOC 28 /* terminal location number */
-#define TELOPT_3270REGIME 29 /* 3270 regime */
-#define TELOPT_X3PAD 30 /* X.3 PAD */
-#define TELOPT_NAWS 31 /* window size */
-#define TELOPT_TSPEED 32 /* terminal speed */
-#define TELOPT_LFLOW 33 /* remote flow control */
-#define TELOPT_LINEMODE 34 /* Linemode option */
-#define TELOPT_XDISPLOC 35 /* X Display Location */
-#define TELOPT_OLD_ENVIRON 36 /* Old - Environment variables */
-#define TELOPT_AUTHENTICATION 37/* Authenticate */
-#define TELOPT_ENCRYPT 38 /* Encryption option */
-#define TELOPT_NEW_ENVIRON 39 /* New - Environment variables */
-#define TELOPT_EXOPL 255 /* extended-options-list */
-
-
-#define NTELOPTS (1+TELOPT_NEW_ENVIRON)
-#ifdef TELOPTS
-char *telopts[NTELOPTS+1] = {
- "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME",
- "STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP",
- "NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS",
- "NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO",
- "DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT",
- "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD",
- "TACACS UID", "OUTPUT MARKING", "TTYLOC",
- "3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW",
- "LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION",
- "ENCRYPT", "NEW-ENVIRON",
- 0
-};
-#define TELOPT_FIRST TELOPT_BINARY
-#define TELOPT_LAST TELOPT_NEW_ENVIRON
-#define TELOPT_OK(x) ((unsigned int)(x) <= TELOPT_LAST)
-#define TELOPT(x) telopts[(x)-TELOPT_FIRST]
-#endif
-
-/* sub-option qualifiers */
-#define TELQUAL_IS 0 /* option is... */
-#define TELQUAL_SEND 1 /* send option */
-#define TELQUAL_INFO 2 /* ENVIRON: informational version of IS */
-#define TELQUAL_REPLY 2 /* AUTHENTICATION: client version of IS */
-#define TELQUAL_NAME 3 /* AUTHENTICATION: client version of IS */
-
-#define LFLOW_OFF 0 /* Disable remote flow control */
-#define LFLOW_ON 1 /* Enable remote flow control */
-#define LFLOW_RESTART_ANY 2 /* Restart output on any char */
-#define LFLOW_RESTART_XON 3 /* Restart output only on XON */
-
-/*
- * LINEMODE suboptions
- */
-
-#define LM_MODE 1
-#define LM_FORWARDMASK 2
-#define LM_SLC 3
-
-#define MODE_EDIT 0x01
-#define MODE_TRAPSIG 0x02
-#define MODE_ACK 0x04
-#define MODE_SOFT_TAB 0x08
-#define MODE_LIT_ECHO 0x10
-
-#define MODE_MASK 0x1f
-
-/* Not part of protocol, but needed to simplify things... */
-#define MODE_FLOW 0x0100
-#define MODE_ECHO 0x0200
-#define MODE_INBIN 0x0400
-#define MODE_OUTBIN 0x0800
-#define MODE_FORCE 0x1000
-
-#define SLC_SYNCH 1
-#define SLC_BRK 2
-#define SLC_IP 3
-#define SLC_AO 4
-#define SLC_AYT 5
-#define SLC_EOR 6
-#define SLC_ABORT 7
-#define SLC_EOF 8
-#define SLC_SUSP 9
-#define SLC_EC 10
-#define SLC_EL 11
-#define SLC_EW 12
-#define SLC_RP 13
-#define SLC_LNEXT 14
-#define SLC_XON 15
-#define SLC_XOFF 16
-#define SLC_FORW1 17
-#define SLC_FORW2 18
-#define SLC_MCL 19
-#define SLC_MCR 20
-#define SLC_MCWL 21
-#define SLC_MCWR 22
-#define SLC_MCBOL 23
-#define SLC_MCEOL 24
-#define SLC_INSRT 25
-#define SLC_OVER 26
-#define SLC_ECR 27
-#define SLC_EWR 28
-#define SLC_EBOL 29
-#define SLC_EEOL 30
-
-#define NSLC 30
-
-/*
- * For backwards compatability, we define SLC_NAMES to be the
- * list of names if SLC_NAMES is not defined.
- */
-#define SLC_NAMELIST "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \
- "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \
- "LNEXT", "XON", "XOFF", "FORW1", "FORW2", \
- "MCL", "MCR", "MCWL", "MCWR", "MCBOL", \
- "MCEOL", "INSRT", "OVER", "ECR", "EWR", \
- "EBOL", "EEOL", \
- 0
-
-#ifdef SLC_NAMES
-char *slc_names[] = {
- SLC_NAMELIST
-};
-#else
-extern char *slc_names[];
-#define SLC_NAMES SLC_NAMELIST
-#endif
-
-#define SLC_NAME_OK(x) ((unsigned int)(x) <= NSLC)
-#define SLC_NAME(x) slc_names[x]
-
-#define SLC_NOSUPPORT 0
-#define SLC_CANTCHANGE 1
-#define SLC_VARIABLE 2
-#define SLC_DEFAULT 3
-#define SLC_LEVELBITS 0x03
-
-#define SLC_FUNC 0
-#define SLC_FLAGS 1
-#define SLC_VALUE 2
-
-#define SLC_ACK 0x80
-#define SLC_FLUSHIN 0x40
-#define SLC_FLUSHOUT 0x20
-
-#define OLD_ENV_VAR 1
-#define OLD_ENV_VALUE 0
-#define NEW_ENV_VAR 0
-#define NEW_ENV_VALUE 1
-#define ENV_ESC 2
-#define ENV_USERVAR 3
-
-/*
- * AUTHENTICATION suboptions
- */
-
-/*
- * Who is authenticating who ...
- */
-#define AUTH_WHO_CLIENT 0 /* Client authenticating server */
-#define AUTH_WHO_SERVER 1 /* Server authenticating client */
-#define AUTH_WHO_MASK 1
-
-/*
- * amount of authentication done
- */
-#define AUTH_HOW_ONE_WAY 0
-#define AUTH_HOW_MUTUAL 2
-#define AUTH_HOW_MASK 2
-
-#define AUTHTYPE_NULL 0
-#define AUTHTYPE_KERBEROS_V4 1
-#define AUTHTYPE_KERBEROS_V5 2
-#define AUTHTYPE_SPX 3
-#define AUTHTYPE_MINK 4
-#define AUTHTYPE_SRA 6
-#define AUTHTYPE_CNT 7
-
-#define AUTHTYPE_TEST 99
-
-#ifdef AUTH_NAMES
-char *authtype_names[] = {
- "NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", NULL, "SRA",
- 0
-};
-#else
-extern char *authtype_names[];
-#endif
-
-#define AUTHTYPE_NAME_OK(x) ((unsigned int)(x) < AUTHTYPE_CNT)
-#define AUTHTYPE_NAME(x) authtype_names[x]
-
-/*
- * ENCRYPTion suboptions
- */
-#define ENCRYPT_IS 0 /* I pick encryption type ... */
-#define ENCRYPT_SUPPORT 1 /* I support encryption types ... */
-#define ENCRYPT_REPLY 2 /* Initial setup response */
-#define ENCRYPT_START 3 /* Am starting to send encrypted */
-#define ENCRYPT_END 4 /* Am ending encrypted */
-#define ENCRYPT_REQSTART 5 /* Request you start encrypting */
-#define ENCRYPT_REQEND 6 /* Request you end encrypting */
-#define ENCRYPT_ENC_KEYID 7
-#define ENCRYPT_DEC_KEYID 8
-#define ENCRYPT_CNT 9
-
-#define ENCTYPE_ANY 0
-#define ENCTYPE_DES_CFB64 1
-#define ENCTYPE_DES_OFB64 2
-#define ENCTYPE_CNT 3
-
-#ifdef ENCRYPT_NAMES
-char *encrypt_names[] = {
- "IS", "SUPPORT", "REPLY", "START", "END",
- "REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID",
- 0
-};
-char *enctype_names[] = {
- "ANY", "DES_CFB64", "DES_OFB64",
- 0
-};
-#else
-extern char *encrypt_names[];
-extern char *enctype_names[];
-#endif
-
-
-#define ENCRYPT_NAME_OK(x) ((unsigned int)(x) < ENCRYPT_CNT)
-#define ENCRYPT_NAME(x) encrypt_names[x]
-
-#define ENCTYPE_NAME_OK(x) ((unsigned int)(x) < ENCTYPE_CNT)
-#define ENCTYPE_NAME(x) enctype_names[x]
-
-#endif /* !_TELNET_H_ */
diff --git a/contrib/telnet/libtelnet/auth-proto.h b/contrib/telnet/libtelnet/auth-proto.h
deleted file mode 100644
index c62fe5f8c3be..000000000000
--- a/contrib/telnet/libtelnet/auth-proto.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/*-
- * Copyright (c) 1991, 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)auth-proto.h 8.1 (Berkeley) 6/4/93
- */
-
-/*
- * Copyright (C) 1990 by the Massachusetts Institute of Technology
- *
- * Export of this software from the United States of America is assumed
- * to require a specific license from the United States Government.
- * It is the responsibility of any person or organization contemplating
- * export to obtain such a license before exporting.
- *
- * WITHIN THAT CONSTRAINT, 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 appear in all copies and that both that copyright notice and
- * this permission notice appear in supporting documentation, and that
- * the name of M.I.T. not be used in advertising or publicity pertaining
- * to distribution of the software without specific, written prior
- * permission. M.I.T. makes no representations about the suitability of
- * this software for any purpose. It is provided "as is" without express
- * or implied warranty.
- */
-
-#if !defined(P)
-#ifdef __STDC__
-#define P(x) x
-#else
-#define P(x) ()
-#endif
-#endif
-
-#if defined(AUTHENTICATION)
-Authenticator *findauthenticator P((int, int));
-
-void auth_init P((char *, int));
-int auth_cmd P((int, char **));
-void auth_request P((void));
-void auth_send P((unsigned char *, int));
-void auth_send_retry P((void));
-void auth_is P((unsigned char *, int));
-void auth_reply P((unsigned char *, int));
-void auth_finished P((Authenticator *, int));
-int auth_wait P((char *));
-void auth_disable_name P((char *));
-void auth_gen_printsub P((unsigned char *, int, unsigned char *, int));
-void auth_name P((unsigned char *, int));
-void auth_printsub P((unsigned char *, int, unsigned char *, int));
-int auth_sendname P((unsigned char *, int));
-void auth_encrypt_user P((char *));
-
-#ifdef KRB4
-int kerberos4_init P((Authenticator *, int));
-int kerberos4_send P((Authenticator *));
-void kerberos4_is P((Authenticator *, unsigned char *, int));
-void kerberos4_reply P((Authenticator *, unsigned char *, int));
-int kerberos4_status P((Authenticator *, char *, int));
-void kerberos4_printsub P((unsigned char *, int, unsigned char *, int));
-#endif
-
-#ifdef KRB5
-int kerberos5_init P((Authenticator *, int));
-int kerberos5_send P((Authenticator *));
-void kerberos5_is P((Authenticator *, unsigned char *, int));
-void kerberos5_reply P((Authenticator *, unsigned char *, int));
-int kerberos5_status P((Authenticator *, char *, int));
-void kerberos5_printsub P((unsigned char *, int, unsigned char *, int));
-#endif
-#ifdef SRA
-int sra_init P((Authenticator *, int));
-int sra_send P((Authenticator *));
-void sra_is P((Authenticator *, unsigned char *, int));
-void sra_reply P((Authenticator *, unsigned char *, int));
-int sra_status P((Authenticator *, char *, int));
-void sra_printsub P((unsigned char *, int, unsigned char *, int));
-#endif
-#endif
diff --git a/contrib/telnet/libtelnet/auth.c b/contrib/telnet/libtelnet/auth.c
deleted file mode 100644
index d574b1e70f60..000000000000
--- a/contrib/telnet/libtelnet/auth.c
+++ /dev/null
@@ -1,684 +0,0 @@
-/*-
- * Copyright (c) 1991, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-static const char sccsid[] = "@(#)auth.c 8.3 (Berkeley) 5/30/95";
-#endif /* not lint */
-
-/*
- * Copyright (C) 1990 by the Massachusetts Institute of Technology
- *
- * Export of this software from the United States of America is assumed
- * to require a specific license from the United States Government.
- * It is the responsibility of any person or organization contemplating
- * export to obtain such a license before exporting.
- *
- * WITHIN THAT CONSTRAINT, 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 appear in all copies and that both that copyright notice and
- * this permission notice appear in supporting documentation, and that
- * the name of M.I.T. not be used in advertising or publicity pertaining
- * to distribution of the software without specific, written prior
- * permission. M.I.T. makes no representations about the suitability of
- * this software for any purpose. It is provided "as is" without express
- * or implied warranty.
- */
-
-
-#if defined(AUTHENTICATION)
-#include <stdio.h>
-#include <sys/types.h>
-#include <signal.h>
-#define AUTH_NAMES
-#include <arpa/telnet.h>
-#ifdef __STDC__
-#include <stdlib.h>
-#include <unistd.h>
-#endif
-#ifdef NO_STRING_H
-#include <strings.h>
-#else
-#include <string.h>
-#endif
-
-#include "encrypt.h"
-#include "auth.h"
-#include "misc-proto.h"
-#include "auth-proto.h"
-
-#define typemask(x) (1<<((x)-1))
-
-#ifdef KRB4_ENCPWD
-extern krb4encpwd_init();
-extern krb4encpwd_send();
-extern krb4encpwd_is();
-extern krb4encpwd_reply();
-extern krb4encpwd_status();
-extern krb4encpwd_printsub();
-#endif
-
-#ifdef RSA_ENCPWD
-extern rsaencpwd_init();
-extern rsaencpwd_send();
-extern rsaencpwd_is();
-extern rsaencpwd_reply();
-extern rsaencpwd_status();
-extern rsaencpwd_printsub();
-#endif
-
-int auth_debug_mode = 0;
-static char *Name = "Noname";
-static int Server = 0;
-static Authenticator *authenticated = 0;
-static int authenticating = 0;
-static int validuser = 0;
-static unsigned char _auth_send_data[256];
-static unsigned char *auth_send_data;
-static int auth_send_cnt = 0;
-
-int auth_onoff(char *type, int on);
-void auth_encrypt_user(char *name);
-
-/*
- * Authentication types supported. Plese note that these are stored
- * in priority order, i.e. try the first one first.
- */
-Authenticator authenticators[] = {
-#ifdef SPX
- { AUTHTYPE_SPX, AUTH_WHO_CLIENT|AUTH_HOW_MUTUAL,
- spx_init,
- spx_send,
- spx_is,
- spx_reply,
- spx_status,
- spx_printsub },
- { AUTHTYPE_SPX, AUTH_WHO_CLIENT|AUTH_HOW_ONE_WAY,
- spx_init,
- spx_send,
- spx_is,
- spx_reply,
- spx_status,
- spx_printsub },
-#endif
-#ifdef KRB5
-# ifdef ENCRYPTION
- { AUTHTYPE_KERBEROS_V5, AUTH_WHO_CLIENT|AUTH_HOW_MUTUAL,
- kerberos5_init,
- kerberos5_send,
- kerberos5_is,
- kerberos5_reply,
- kerberos5_status,
- kerberos5_printsub },
-# endif /* ENCRYPTION */
- { AUTHTYPE_KERBEROS_V5, AUTH_WHO_CLIENT|AUTH_HOW_ONE_WAY,
- kerberos5_init,
- kerberos5_send,
- kerberos5_is,
- kerberos5_reply,
- kerberos5_status,
- kerberos5_printsub },
-#endif
-#ifdef KRB4
-# ifdef ENCRYPTION
- { AUTHTYPE_KERBEROS_V4, AUTH_WHO_CLIENT|AUTH_HOW_MUTUAL,
- kerberos4_init,
- kerberos4_send,
- kerberos4_is,
- kerberos4_reply,
- kerberos4_status,
- kerberos4_printsub },
-# endif /* ENCRYPTION */
- { AUTHTYPE_KERBEROS_V4, AUTH_WHO_CLIENT|AUTH_HOW_ONE_WAY,
- kerberos4_init,
- kerberos4_send,
- kerberos4_is,
- kerberos4_reply,
- kerberos4_status,
- kerberos4_printsub },
-#endif
-#ifdef KRB4_ENCPWD
- { AUTHTYPE_KRB4_ENCPWD, AUTH_WHO_CLIENT|AUTH_HOW_MUTUAL,
- krb4encpwd_init,
- krb4encpwd_send,
- krb4encpwd_is,
- krb4encpwd_reply,
- krb4encpwd_status,
- krb4encpwd_printsub },
-#endif
-#ifdef RSA_ENCPWD
- { AUTHTYPE_RSA_ENCPWD, AUTH_WHO_CLIENT|AUTH_HOW_ONE_WAY,
- rsaencpwd_init,
- rsaencpwd_send,
- rsaencpwd_is,
- rsaencpwd_reply,
- rsaencpwd_status,
- rsaencpwd_printsub },
-#endif
-#ifdef SRA
- { AUTHTYPE_SRA, AUTH_WHO_CLIENT|AUTH_HOW_ONE_WAY,
- sra_init,
- sra_send,
- sra_is,
- sra_reply,
- sra_status,
- sra_printsub },
-
-#endif
- { 0, },
-};
-
-static Authenticator NoAuth = { 0 };
-
-static int i_support = 0;
-static int i_wont_support = 0;
-
- Authenticator *
-findauthenticator(type, way)
- int type;
- int way;
-{
- Authenticator *ap = authenticators;
-
- while (ap->type && (ap->type != type || ap->way != way))
- ++ap;
- return(ap->type ? ap : 0);
-}
-
- void
-auth_init(name, server)
- char *name;
- int server;
-{
- Authenticator *ap = authenticators;
-
- Server = server;
- Name = name;
-
- i_support = 0;
- authenticated = 0;
- authenticating = 0;
- while (ap->type) {
- if (!ap->init || (*ap->init)(ap, server)) {
- i_support |= typemask(ap->type);
- if (auth_debug_mode)
- printf(">>>%s: I support auth type %d %d\r\n",
- Name,
- ap->type, ap->way);
- }
- else if (auth_debug_mode)
- printf(">>>%s: Init failed: auth type %d %d\r\n",
- Name, ap->type, ap->way);
- ++ap;
- }
-}
-
- void
-auth_disable_name(name)
- char *name;
-{
- int x;
- for (x = 0; x < AUTHTYPE_CNT; ++x) {
- if (!strcasecmp(name, AUTHTYPE_NAME(x))) {
- i_wont_support |= typemask(x);
- break;
- }
- }
-}
-
- int
-getauthmask(type, maskp)
- char *type;
- int *maskp;
-{
- register int x;
-
- if (!strcasecmp(type, AUTHTYPE_NAME(0))) {
- *maskp = -1;
- return(1);
- }
-
- for (x = 1; x < AUTHTYPE_CNT; ++x) {
- if (!strcasecmp(type, AUTHTYPE_NAME(x))) {
- *maskp = typemask(x);
- return(1);
- }
- }
- return(0);
-}
-
- int
-auth_enable(type)
- char *type;
-{
- return(auth_onoff(type, 1));
-}
-
- int
-auth_disable(type)
- char *type;
-{
- return(auth_onoff(type, 0));
-}
-
- int
-auth_onoff(type, on)
- char *type;
- int on;
-{
- int i, mask = -1;
- Authenticator *ap;
-
- if (!strcasecmp(type, "?") || !strcasecmp(type, "help")) {
- printf("auth %s 'type'\n", on ? "enable" : "disable");
- printf("Where 'type' is one of:\n");
- printf("\t%s\n", AUTHTYPE_NAME(0));
- mask = 0;
- for (ap = authenticators; ap->type; ap++) {
- if ((mask & (i = typemask(ap->type))) != 0)
- continue;
- mask |= i;
- printf("\t%s\n", AUTHTYPE_NAME(ap->type));
- }
- return(0);
- }
-
- if (!getauthmask(type, &mask)) {
- printf("%s: invalid authentication type\n", type);
- return(0);
- }
- if (on)
- i_wont_support &= ~mask;
- else
- i_wont_support |= mask;
- return(1);
-}
-
- int
-auth_togdebug(on)
- int on;
-{
- if (on < 0)
- auth_debug_mode ^= 1;
- else
- auth_debug_mode = on;
- printf("auth debugging %s\n", auth_debug_mode ? "enabled" : "disabled");
- return(1);
-}
-
- int
-auth_status()
-{
- Authenticator *ap;
- int i, mask;
-
- if (i_wont_support == -1)
- printf("Authentication disabled\n");
- else
- printf("Authentication enabled\n");
-
- mask = 0;
- for (ap = authenticators; ap->type; ap++) {
- if ((mask & (i = typemask(ap->type))) != 0)
- continue;
- mask |= i;
- printf("%s: %s\n", AUTHTYPE_NAME(ap->type),
- (i_wont_support & typemask(ap->type)) ?
- "disabled" : "enabled");
- }
- return(1);
-}
-
-/*
- * This routine is called by the server to start authentication
- * negotiation.
- */
- void
-auth_request()
-{
- static unsigned char str_request[64] = { IAC, SB,
- TELOPT_AUTHENTICATION,
- TELQUAL_SEND, };
- Authenticator *ap = authenticators;
- unsigned char *e = str_request + 4;
-
- if (!authenticating) {
- authenticating = 1;
- while (ap->type) {
- if (i_support & ~i_wont_support & typemask(ap->type)) {
- if (auth_debug_mode) {
- printf(">>>%s: Sending type %d %d\r\n",
- Name, ap->type, ap->way);
- }
- *e++ = ap->type;
- *e++ = ap->way;
- }
- ++ap;
- }
- *e++ = IAC;
- *e++ = SE;
- net_write(str_request, e - str_request);
- printsub('>', &str_request[2], e - str_request - 2);
- }
-}
-
-/*
- * This is called when an AUTH SEND is received.
- * It should never arrive on the server side (as only the server can
- * send an AUTH SEND).
- * You should probably respond to it if you can...
- *
- * If you want to respond to the types out of order (i.e. even
- * if he sends LOGIN KERBEROS and you support both, you respond
- * with KERBEROS instead of LOGIN (which is against what the
- * protocol says)) you will have to hack this code...
- */
- void
-auth_send(data, cnt)
- unsigned char *data;
- int cnt;
-{
- Authenticator *ap;
- static unsigned char str_none[] = { IAC, SB, TELOPT_AUTHENTICATION,
- TELQUAL_IS, AUTHTYPE_NULL, 0,
- IAC, SE };
- if (Server) {
- if (auth_debug_mode) {
- printf(">>>%s: auth_send called!\r\n", Name);
- }
- return;
- }
-
- if (auth_debug_mode) {
- printf(">>>%s: auth_send got:", Name);
- printd(data, cnt); printf("\r\n");
- }
-
- /*
- * Save the data, if it is new, so that we can continue looking
- * at it if the authorization we try doesn't work
- */
- if (data < _auth_send_data ||
- data > _auth_send_data + sizeof(_auth_send_data)) {
- auth_send_cnt = cnt > sizeof(_auth_send_data)
- ? sizeof(_auth_send_data)
- : cnt;
- memmove((void *)_auth_send_data, (void *)data, auth_send_cnt);
- auth_send_data = _auth_send_data;
- } else {
- /*
- * This is probably a no-op, but we just make sure
- */
- auth_send_data = data;
- auth_send_cnt = cnt;
- }
- while ((auth_send_cnt -= 2) >= 0) {
- if (auth_debug_mode)
- printf(">>>%s: He supports %d\r\n",
- Name, *auth_send_data);
- if ((i_support & ~i_wont_support) & typemask(*auth_send_data)) {
- ap = findauthenticator(auth_send_data[0],
- auth_send_data[1]);
- if (ap && ap->send) {
- if (auth_debug_mode)
- printf(">>>%s: Trying %d %d\r\n",
- Name, auth_send_data[0],
- auth_send_data[1]);
- if ((*ap->send)(ap)) {
- /*
- * Okay, we found one we like
- * and did it.
- * we can go home now.
- */
- if (auth_debug_mode)
- printf(">>>%s: Using type %d\r\n",
- Name, *auth_send_data);
- auth_send_data += 2;
- return;
- }
- }
- /* else
- * just continue on and look for the
- * next one if we didn't do anything.
- */
- }
- auth_send_data += 2;
- }
- net_write(str_none, sizeof(str_none));
- printsub('>', &str_none[2], sizeof(str_none) - 2);
- if (auth_debug_mode)
- printf(">>>%s: Sent failure message\r\n", Name);
- auth_finished(0, AUTH_REJECT);
-#ifdef KANNAN
- /*
- * We requested strong authentication, however no mechanisms worked.
- * Therefore, exit on client end.
- */
- printf("Unable to securely authenticate user ... exit\n");
- exit(0);
-#endif /* KANNAN */
-}
-
- void
-auth_send_retry()
-{
- /*
- * if auth_send_cnt <= 0 then auth_send will end up rejecting
- * the authentication and informing the other side of this.
- */
- auth_send(auth_send_data, auth_send_cnt);
-}
-
- void
-auth_is(data, cnt)
- unsigned char *data;
- int cnt;
-{
- Authenticator *ap;
-
- if (cnt < 2)
- return;
-
- if (data[0] == AUTHTYPE_NULL) {
- auth_finished(0, AUTH_REJECT);
- return;
- }
-
- if ((ap = findauthenticator(data[0], data[1]))) {
- if (ap->is)
- (*ap->is)(ap, data+2, cnt-2);
- } else if (auth_debug_mode)
- printf(">>>%s: Invalid authentication in IS: %d\r\n",
- Name, *data);
-}
-
- void
-auth_reply(data, cnt)
- unsigned char *data;
- int cnt;
-{
- Authenticator *ap;
-
- if (cnt < 2)
- return;
-
- if ((ap = findauthenticator(data[0], data[1]))) {
- if (ap->reply)
- (*ap->reply)(ap, data+2, cnt-2);
- } else if (auth_debug_mode)
- printf(">>>%s: Invalid authentication in SEND: %d\r\n",
- Name, *data);
-}
-
- void
-auth_name(data, cnt)
- unsigned char *data;
- int cnt;
-{
- unsigned char savename[256];
-
- if (cnt < 1) {
- if (auth_debug_mode)
- printf(">>>%s: Empty name in NAME\r\n", Name);
- return;
- }
- if (cnt > sizeof(savename) - 1) {
- if (auth_debug_mode)
- printf(">>>%s: Name in NAME (%d) exceeds %d length\r\n",
- Name, cnt, sizeof(savename)-1);
- return;
- }
- memmove((void *)savename, (void *)data, cnt);
- savename[cnt] = '\0'; /* Null terminate */
- if (auth_debug_mode)
- printf(">>>%s: Got NAME [%s]\r\n", Name, savename);
- auth_encrypt_user(savename);
-}
-
- int
-auth_sendname(cp, len)
- unsigned char *cp;
- int len;
-{
- static unsigned char str_request[256+6]
- = { IAC, SB, TELOPT_AUTHENTICATION, TELQUAL_NAME, };
- register unsigned char *e = str_request + 4;
- register unsigned char *ee = &str_request[sizeof(str_request)-2];
-
- while (--len >= 0) {
- if ((*e++ = *cp++) == IAC)
- *e++ = IAC;
- if (e >= ee)
- return(0);
- }
- *e++ = IAC;
- *e++ = SE;
- net_write(str_request, e - str_request);
- printsub('>', &str_request[2], e - &str_request[2]);
- return(1);
-}
-
- void
-auth_finished(ap, result)
- Authenticator *ap;
- int result;
-{
- if (!(authenticated = ap))
- authenticated = &NoAuth;
- validuser = result;
-}
-
- /* ARGSUSED */
- static void
-auth_intr(sig)
- int sig;
-{
- auth_finished(0, AUTH_REJECT);
-}
-
- int
-auth_wait(name)
- char *name;
-{
- if (auth_debug_mode)
- printf(">>>%s: in auth_wait.\r\n", Name);
-
- if (Server && !authenticating)
- return(0);
-
- (void) signal(SIGALRM, auth_intr);
- alarm(30);
- while (!authenticated)
- if (telnet_spin())
- break;
- alarm(0);
- (void) signal(SIGALRM, SIG_DFL);
-
- /*
- * Now check to see if the user is valid or not
- */
- if (!authenticated || authenticated == &NoAuth)
- return(AUTH_REJECT);
-
- if (validuser == AUTH_VALID)
- validuser = AUTH_USER;
-
- if (authenticated->status)
- validuser = (*authenticated->status)(authenticated,
- name, validuser);
- return(validuser);
-}
-
- void
-auth_debug(mode)
- int mode;
-{
- auth_debug_mode = mode;
-}
-
- void
-auth_printsub(data, cnt, buf, buflen)
- unsigned char *data, *buf;
- int cnt, buflen;
-{
- Authenticator *ap;
-
- if ((ap = findauthenticator(data[1], data[2])) && ap->printsub)
- (*ap->printsub)(data, cnt, buf, buflen);
- else
- auth_gen_printsub(data, cnt, buf, buflen);
-}
-
- void
-auth_gen_printsub(data, cnt, buf, buflen)
- unsigned char *data, *buf;
- int cnt, buflen;
-{
- register unsigned char *cp;
- unsigned char tbuf[16];
-
- cnt -= 3;
- data += 3;
- buf[buflen-1] = '\0';
- buf[buflen-2] = '*';
- buflen -= 2;
- for (; cnt > 0; cnt--, data++) {
- sprintf((char *)tbuf, " %d", *data);
- for (cp = tbuf; *cp && buflen > 0; --buflen)
- *buf++ = *cp++;
- if (buflen <= 0)
- return;
- }
- *buf = '\0';
-}
-#endif
diff --git a/contrib/telnet/libtelnet/auth.h b/contrib/telnet/libtelnet/auth.h
deleted file mode 100644
index 615e8a07b894..000000000000
--- a/contrib/telnet/libtelnet/auth.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*-
- * Copyright (c) 1991, 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)auth.h 8.1 (Berkeley) 6/4/93
- */
-
-/*
- * Copyright (C) 1990 by the Massachusetts Institute of Technology
- *
- * Export of this software from the United States of America is assumed
- * to require a specific license from the United States Government.
- * It is the responsibility of any person or organization contemplating
- * export to obtain such a license before exporting.
- *
- * WITHIN THAT CONSTRAINT, 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 appear in all copies and that both that copyright notice and
- * this permission notice appear in supporting documentation, and that
- * the name of M.I.T. not be used in advertising or publicity pertaining
- * to distribution of the software without specific, written prior
- * permission. M.I.T. makes no representations about the suitability of
- * this software for any purpose. It is provided "as is" without express
- * or implied warranty.
- */
-
-#ifndef __AUTH__
-#define __AUTH__
-
-#define AUTH_REJECT 0 /* Rejected */
-#define AUTH_UNKNOWN 1 /* We don't know who he is, but he's okay */
-#define AUTH_OTHER 2 /* We know him, but not his name */
-#define AUTH_USER 3 /* We know he name */
-#define AUTH_VALID 4 /* We know him, and he needs no password */
-
-#if !defined(P)
-#ifdef __STDC__
-#define P(x) x
-#else
-#define P(x) ()
-#endif
-#endif
-
-typedef struct XauthP {
- int type;
- int way;
- int (*init) P((struct XauthP *, int));
- int (*send) P((struct XauthP *));
- void (*is) P((struct XauthP *, unsigned char *, int));
- void (*reply) P((struct XauthP *, unsigned char *, int));
- int (*status) P((struct XauthP *, char *, int));
- void (*printsub) P((unsigned char *, int, unsigned char *, int));
-} Authenticator;
-
-#include "auth-proto.h"
-
-extern auth_debug_mode;
-#endif
diff --git a/contrib/telnet/libtelnet/enc-proto.h b/contrib/telnet/libtelnet/enc-proto.h
deleted file mode 100644
index 8cec406afee3..000000000000
--- a/contrib/telnet/libtelnet/enc-proto.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/*-
- * Copyright (c) 1991, 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)enc-proto.h 8.1 (Berkeley) 6/4/93
- */
-
-/*
- * Copyright (C) 1990 by the Massachusetts Institute of Technology
- *
- * Export of this software from the United States of America is assumed
- * to require a specific license from the United States Government.
- * It is the responsibility of any person or organization contemplating
- * export to obtain such a license before exporting.
- *
- * WITHIN THAT CONSTRAINT, 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 appear in all copies and that both that copyright notice and
- * this permission notice appear in supporting documentation, and that
- * the name of M.I.T. not be used in advertising or publicity pertaining
- * to distribution of the software without specific, written prior
- * permission. M.I.T. makes no representations about the suitability of
- * this software for any purpose. It is provided "as is" without express
- * or implied warranty.
- */
-#if !defined(P)
-#ifdef __STDC__
-#define P(x) x
-#else
-#define P(x) ()
-#endif
-#endif
-
-#ifdef ENCRYPTION
-void encrypt_init P((char *, int));
-Encryptions *findencryption P((int));
-void encrypt_send_supprt P((void));
-void encrypt_auto P((int));
-void decrypt_auto P((int));
-void encrypt_is P((unsigned char *, int));
-void encrypt_reply P((unsigned char *, int));
-void encrypt_start_input P((int));
-void encrypt_session_key P((Session_Key *, int));
-void encrypt_end_input P((void));
-void encrypt_start_output P((int));
-void encrypt_end_output P((void));
-void encrypt_send_request_start P((void));
-void encrypt_send_request_end P((void));
-void encrypt_send_end P((void));
-void encrypt_wait P((void));
-void encrypt_send_support P((void));
-void encrypt_send_keyid P((int, unsigned char *, int, int));
-void encrypt_start P((unsigned char *, int));
-void encrypt_end P((void));
-void encrypt_support P((unsigned char *, int));
-void encrypt_request_start P((unsigned char *, int));
-void encrypt_request_end P((void));
-void encrypt_enc_keyid P((unsigned char *, int));
-void encrypt_dec_keyid P((unsigned char *, int));
-void encrypt_printsub P((unsigned char *, int, unsigned char *, int));
-int net_write P((unsigned char *, int));
-
-#ifndef TELENTD
-int encrypt_cmd P((int, char **));
-void encrypt_display P((void));
-#endif
-
-#ifdef DES_ENCRYPTION
-void krbdes_encrypt P((unsigned char *, int));
-int krbdes_decrypt P((int));
-int krbdes_is P((unsigned char *, int));
-int krbdes_reply P((unsigned char *, int));
-void krbdes_init P((int));
-int krbdes_start P((int, int));
-void krbdes_session P((Session_Key *, int));
-void krbdes_printsub P((unsigned char *, int, unsigned char *, int));
-
-void cfb64_encrypt P((unsigned char *, int));
-int cfb64_decrypt P((int));
-void cfb64_init P((int));
-int cfb64_start P((int, int));
-int cfb64_is P((unsigned char *, int));
-int cfb64_reply P((unsigned char *, int));
-void cfb64_session P((Session_Key *, int));
-int cfb64_keyid P((int, unsigned char *, int *));
-void cfb64_printsub P((unsigned char *, int, unsigned char *, int));
-
-void ofb64_encrypt P((unsigned char *, int));
-int ofb64_decrypt P((int));
-void ofb64_init P((int));
-int ofb64_start P((int, int));
-int ofb64_is P((unsigned char *, int));
-int ofb64_reply P((unsigned char *, int));
-void ofb64_session P((Session_Key *, int));
-int ofb64_keyid P((int, unsigned char *, int *));
-void ofb64_printsub P((unsigned char *, int, unsigned char *, int));
-#endif /* DES_ENCRYPTION */
-
-#endif /* ENCRYPTION */
diff --git a/contrib/telnet/libtelnet/enc_des.c b/contrib/telnet/libtelnet/enc_des.c
deleted file mode 100644
index c0f669b59929..000000000000
--- a/contrib/telnet/libtelnet/enc_des.c
+++ /dev/null
@@ -1,722 +0,0 @@
-/*-
- * Copyright (c) 1991, 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- */
-
-#ifndef lint
-static const char sccsid[] = "@(#)enc_des.c 8.3 (Berkeley) 5/30/95";
-#endif /* not lint */
-
-#ifdef ENCRYPTION
-# ifdef AUTHENTICATION
-# ifdef DES_ENCRYPTION
-#include <arpa/telnet.h>
-#include <stdio.h>
-#ifdef __STDC__
-#include <stdlib.h>
-#endif
-
-#include <openssl/des.h>
-#include <string.h>
-#include "encrypt.h"
-#include "key-proto.h"
-#include "misc-proto.h"
-
-extern encrypt_debug_mode;
-
-#define CFB 0
-#define OFB 1
-
-#define NO_SEND_IV 1
-#define NO_RECV_IV 2
-#define NO_KEYID 4
-#define IN_PROGRESS (NO_SEND_IV|NO_RECV_IV|NO_KEYID)
-#define SUCCESS 0
-#define FAILED -1
-
-
-struct fb {
- Block krbdes_key;
- Schedule krbdes_sched;
- Block temp_feed;
- unsigned char fb_feed[64];
- int need_start;
- int state[2];
- int keyid[2];
- int once;
- struct stinfo {
- Block str_output;
- Block str_feed;
- Block str_iv;
- Block str_ikey;
- Schedule str_sched;
- int str_index;
- int str_flagshift;
- } streams[2];
-};
-
-static struct fb fb[2];
-
-struct keyidlist {
- char *keyid;
- int keyidlen;
- char *key;
- int keylen;
- int flags;
-} keyidlist [] = {
- { "\0", 1, 0, 0, 0 }, /* default key of zero */
- { 0, 0, 0, 0, 0 }
-};
-
-#define KEYFLAG_MASK 03
-
-#define KEYFLAG_NOINIT 00
-#define KEYFLAG_INIT 01
-#define KEYFLAG_OK 02
-#define KEYFLAG_BAD 03
-
-#define KEYFLAG_SHIFT 2
-
-#define SHIFT_VAL(a,b) (KEYFLAG_SHIFT*((a)+((b)*2)))
-
-#define FB64_IV 1
-#define FB64_IV_OK 2
-#define FB64_IV_BAD 3
-
-
-void fb64_stream_iv P((Block, struct stinfo *));
-void fb64_init P((struct fb *));
-static int fb64_start P((struct fb *, int, int));
-int fb64_is P((unsigned char *, int, struct fb *));
-int fb64_reply P((unsigned char *, int, struct fb *));
-static void fb64_session P((Session_Key *, int, struct fb *));
-void fb64_stream_key P((Block, struct stinfo *));
-int fb64_keyid P((int, unsigned char *, int *, struct fb *));
-
- void
-cfb64_init(server)
- int server;
-{
- fb64_init(&fb[CFB]);
- fb[CFB].fb_feed[4] = ENCTYPE_DES_CFB64;
- fb[CFB].streams[0].str_flagshift = SHIFT_VAL(0, CFB);
- fb[CFB].streams[1].str_flagshift = SHIFT_VAL(1, CFB);
-}
-
- void
-ofb64_init(server)
- int server;
-{
- fb64_init(&fb[OFB]);
- fb[OFB].fb_feed[4] = ENCTYPE_DES_OFB64;
- fb[CFB].streams[0].str_flagshift = SHIFT_VAL(0, OFB);
- fb[CFB].streams[1].str_flagshift = SHIFT_VAL(1, OFB);
-}
-
- void
-fb64_init(fbp)
- register struct fb *fbp;
-{
- memset((void *)fbp, 0, sizeof(*fbp));
- fbp->state[0] = fbp->state[1] = FAILED;
- fbp->fb_feed[0] = IAC;
- fbp->fb_feed[1] = SB;
- fbp->fb_feed[2] = TELOPT_ENCRYPT;
- fbp->fb_feed[3] = ENCRYPT_IS;
-}
-
-/*
- * Returns:
- * -1: some error. Negotiation is done, encryption not ready.
- * 0: Successful, initial negotiation all done.
- * 1: successful, negotiation not done yet.
- * 2: Not yet. Other things (like getting the key from
- * Kerberos) have to happen before we can continue.
- */
- int
-cfb64_start(dir, server)
- int dir;
- int server;
-{
- return(fb64_start(&fb[CFB], dir, server));
-}
- int
-ofb64_start(dir, server)
- int dir;
- int server;
-{
- return(fb64_start(&fb[OFB], dir, server));
-}
-
- static int
-fb64_start(fbp, dir, server)
- struct fb *fbp;
- int dir;
- int server;
-{
- int x;
- unsigned char *p;
- register int state;
-
- switch (dir) {
- case DIR_DECRYPT:
- /*
- * This is simply a request to have the other side
- * start output (our input). He will negotiate an
- * IV so we need not look for it.
- */
- state = fbp->state[dir-1];
- if (state == FAILED)
- state = IN_PROGRESS;
- break;
-
- case DIR_ENCRYPT:
- state = fbp->state[dir-1];
- if (state == FAILED)
- state = IN_PROGRESS;
- else if ((state & NO_SEND_IV) == 0)
- break;
-
- if (!VALIDKEY(fbp->krbdes_key)) {
- fbp->need_start = 1;
- break;
- }
- state &= ~NO_SEND_IV;
- state |= NO_RECV_IV;
- if (encrypt_debug_mode)
- printf("Creating new feed\r\n");
- /*
- * Create a random feed and send it over.
- */
- des_new_random_key((Block *)fbp->temp_feed);
- des_ecb_encrypt((Block *)fbp->temp_feed, (Block *)fbp->temp_feed,
- fbp->krbdes_sched, 1);
- p = fbp->fb_feed + 3;
- *p++ = ENCRYPT_IS;
- p++;
- *p++ = FB64_IV;
- for (x = 0; x < sizeof(Block); ++x) {
- if ((*p++ = fbp->temp_feed[x]) == IAC)
- *p++ = IAC;
- }
- *p++ = IAC;
- *p++ = SE;
- printsub('>', &fbp->fb_feed[2], p - &fbp->fb_feed[2]);
- net_write(fbp->fb_feed, p - fbp->fb_feed);
- break;
- default:
- return(FAILED);
- }
- return(fbp->state[dir-1] = state);
-}
-
-/*
- * Returns:
- * -1: some error. Negotiation is done, encryption not ready.
- * 0: Successful, initial negotiation all done.
- * 1: successful, negotiation not done yet.
- */
- int
-cfb64_is(data, cnt)
- unsigned char *data;
- int cnt;
-{
- return(fb64_is(data, cnt, &fb[CFB]));
-}
- int
-ofb64_is(data, cnt)
- unsigned char *data;
- int cnt;
-{
- return(fb64_is(data, cnt, &fb[OFB]));
-}
-
- int
-fb64_is(data, cnt, fbp)
- unsigned char *data;
- int cnt;
- struct fb *fbp;
-{
- unsigned char *p;
- register int state = fbp->state[DIR_DECRYPT-1];
-
- if (cnt-- < 1)
- goto failure;
-
- switch (*data++) {
- case FB64_IV:
- if (cnt != sizeof(Block)) {
- if (encrypt_debug_mode)
- printf("CFB64: initial vector failed on size\r\n");
- state = FAILED;
- goto failure;
- }
-
- if (encrypt_debug_mode)
- printf("CFB64: initial vector received\r\n");
-
- if (encrypt_debug_mode)
- printf("Initializing Decrypt stream\r\n");
-
- fb64_stream_iv((void *)data, &fbp->streams[DIR_DECRYPT-1]);
-
- p = fbp->fb_feed + 3;
- *p++ = ENCRYPT_REPLY;
- p++;
- *p++ = FB64_IV_OK;
- *p++ = IAC;
- *p++ = SE;
- printsub('>', &fbp->fb_feed[2], p - &fbp->fb_feed[2]);
- net_write(fbp->fb_feed, p - fbp->fb_feed);
-
- state = fbp->state[DIR_DECRYPT-1] = IN_PROGRESS;
- break;
-
- default:
- if (encrypt_debug_mode) {
- printf("Unknown option type: %d\r\n", *(data-1));
- printd(data, cnt);
- printf("\r\n");
- }
- /* FALL THROUGH */
- failure:
- /*
- * We failed. Send an FB64_IV_BAD option
- * to the other side so it will know that
- * things failed.
- */
- p = fbp->fb_feed + 3;
- *p++ = ENCRYPT_REPLY;
- p++;
- *p++ = FB64_IV_BAD;
- *p++ = IAC;
- *p++ = SE;
- printsub('>', &fbp->fb_feed[2], p - &fbp->fb_feed[2]);
- net_write(fbp->fb_feed, p - fbp->fb_feed);
-
- break;
- }
- return(fbp->state[DIR_DECRYPT-1] = state);
-}
-
-/*
- * Returns:
- * -1: some error. Negotiation is done, encryption not ready.
- * 0: Successful, initial negotiation all done.
- * 1: successful, negotiation not done yet.
- */
- int
-cfb64_reply(data, cnt)
- unsigned char *data;
- int cnt;
-{
- return(fb64_reply(data, cnt, &fb[CFB]));
-}
- int
-ofb64_reply(data, cnt)
- unsigned char *data;
- int cnt;
-{
- return(fb64_reply(data, cnt, &fb[OFB]));
-}
-
-
- int
-fb64_reply(data, cnt, fbp)
- unsigned char *data;
- int cnt;
- struct fb *fbp;
-{
- register int state = fbp->state[DIR_ENCRYPT-1];
-
- if (cnt-- < 1)
- goto failure;
-
- switch (*data++) {
- case FB64_IV_OK:
- fb64_stream_iv(fbp->temp_feed, &fbp->streams[DIR_ENCRYPT-1]);
- if (state == FAILED)
- state = IN_PROGRESS;
- state &= ~NO_RECV_IV;
- encrypt_send_keyid(DIR_ENCRYPT, (unsigned char *)"\0", 1, 1);
- break;
-
- case FB64_IV_BAD:
- memset(fbp->temp_feed, 0, sizeof(Block));
- fb64_stream_iv(fbp->temp_feed, &fbp->streams[DIR_ENCRYPT-1]);
- state = FAILED;
- break;
-
- default:
- if (encrypt_debug_mode) {
- printf("Unknown option type: %d\r\n", data[-1]);
- printd(data, cnt);
- printf("\r\n");
- }
- /* FALL THROUGH */
- failure:
- state = FAILED;
- break;
- }
- return(fbp->state[DIR_ENCRYPT-1] = state);
-}
-
- void
-cfb64_session(key, server)
- Session_Key *key;
- int server;
-{
- fb64_session(key, server, &fb[CFB]);
-}
-
- void
-ofb64_session(key, server)
- Session_Key *key;
- int server;
-{
- fb64_session(key, server, &fb[OFB]);
-}
-
- static void
-fb64_session(key, server, fbp)
- Session_Key *key;
- int server;
- struct fb *fbp;
-{
-
- if (!key || key->type != SK_DES) {
- if (encrypt_debug_mode)
- printf("Can't set krbdes's session key (%d != %d)\r\n",
- key ? key->type : -1, SK_DES);
- return;
- }
- memmove((void *)fbp->krbdes_key, (void *)key->data, sizeof(Block));
-
- fb64_stream_key(fbp->krbdes_key, &fbp->streams[DIR_ENCRYPT-1]);
- fb64_stream_key(fbp->krbdes_key, &fbp->streams[DIR_DECRYPT-1]);
-
- if (fbp->once == 0) {
- des_set_random_generator_seed((Block *)fbp->krbdes_key);
- fbp->once = 1;
- }
- des_key_sched((Block *)fbp->krbdes_key, fbp->krbdes_sched);
- /*
- * Now look to see if krbdes_start() was was waiting for
- * the key to show up. If so, go ahead an call it now
- * that we have the key.
- */
- if (fbp->need_start) {
- fbp->need_start = 0;
- fb64_start(fbp, DIR_ENCRYPT, server);
- }
-}
-
-/*
- * We only accept a keyid of 0. If we get a keyid of
- * 0, then mark the state as SUCCESS.
- */
- int
-cfb64_keyid(dir, kp, lenp)
- int dir, *lenp;
- unsigned char *kp;
-{
- return(fb64_keyid(dir, kp, lenp, &fb[CFB]));
-}
-
- int
-ofb64_keyid(dir, kp, lenp)
- int dir, *lenp;
- unsigned char *kp;
-{
- return(fb64_keyid(dir, kp, lenp, &fb[OFB]));
-}
-
- int
-fb64_keyid(dir, kp, lenp, fbp)
- int dir, *lenp;
- unsigned char *kp;
- struct fb *fbp;
-{
- register int state = fbp->state[dir-1];
-
- if (*lenp != 1 || (*kp != '\0')) {
- *lenp = 0;
- return(state);
- }
-
- if (state == FAILED)
- state = IN_PROGRESS;
-
- state &= ~NO_KEYID;
-
- return(fbp->state[dir-1] = state);
-}
-
- void
-fb64_printsub(data, cnt, buf, buflen, type)
- unsigned char *data, *buf, *type;
- int cnt, buflen;
-{
- char lbuf[32];
- register int i;
- char *cp;
-
- buf[buflen-1] = '\0'; /* make sure it's NULL terminated */
- buflen -= 1;
-
- switch(data[2]) {
- case FB64_IV:
- sprintf(lbuf, "%s_IV", type);
- cp = lbuf;
- goto common;
-
- case FB64_IV_OK:
- sprintf(lbuf, "%s_IV_OK", type);
- cp = lbuf;
- goto common;
-
- case FB64_IV_BAD:
- sprintf(lbuf, "%s_IV_BAD", type);
- cp = lbuf;
- goto common;
-
- default:
- sprintf(lbuf, " %d (unknown)", data[2]);
- cp = lbuf;
- common:
- for (; (buflen > 0) && (*buf = *cp++); buf++)
- buflen--;
- for (i = 3; i < cnt; i++) {
- sprintf(lbuf, " %d", data[i]);
- for (cp = lbuf; (buflen > 0) && (*buf = *cp++); buf++)
- buflen--;
- }
- break;
- }
-}
-
- void
-cfb64_printsub(data, cnt, buf, buflen)
- unsigned char *data, *buf;
- int cnt, buflen;
-{
- fb64_printsub(data, cnt, buf, buflen, "CFB64");
-}
-
- void
-ofb64_printsub(data, cnt, buf, buflen)
- unsigned char *data, *buf;
- int cnt, buflen;
-{
- fb64_printsub(data, cnt, buf, buflen, "OFB64");
-}
-
- void
-fb64_stream_iv(seed, stp)
- Block seed;
- register struct stinfo *stp;
-{
-
- memmove((void *)stp->str_iv, (void *)seed, sizeof(Block));
- memmove((void *)stp->str_output, (void *)seed, sizeof(Block));
-
- des_key_sched((Block *)stp->str_ikey, stp->str_sched);
-
- stp->str_index = sizeof(Block);
-}
-
- void
-fb64_stream_key(key, stp)
- Block key;
- register struct stinfo *stp;
-{
- memmove((void *)stp->str_ikey, (void *)key, sizeof(Block));
- des_key_sched((Block *)key, stp->str_sched);
-
- memmove((void *)stp->str_output, (void *)stp->str_iv, sizeof(Block));
-
- stp->str_index = sizeof(Block);
-}
-
-/*
- * DES 64 bit Cipher Feedback
- *
- * key --->+-----+
- * +->| DES |--+
- * | +-----+ |
- * | v
- * INPUT --(--------->(+)+---> DATA
- * | |
- * +-------------+
- *
- *
- * Given:
- * iV: Initial vector, 64 bits (8 bytes) long.
- * Dn: the nth chunk of 64 bits (8 bytes) of data to encrypt (decrypt).
- * On: the nth chunk of 64 bits (8 bytes) of encrypted (decrypted) output.
- *
- * V0 = DES(iV, key)
- * On = Dn ^ Vn
- * V(n+1) = DES(On, key)
- */
-
- void
-cfb64_encrypt(s, c)
- register unsigned char *s;
- int c;
-{
- register struct stinfo *stp = &fb[CFB].streams[DIR_ENCRYPT-1];
- register int index;
-
- index = stp->str_index;
- while (c-- > 0) {
- if (index == sizeof(Block)) {
- Block b;
- des_ecb_encrypt((Block *)stp->str_output, (Block *)b, stp->str_sched, 1);
- memmove((void *)stp->str_feed, (void *)b, sizeof(Block));
- index = 0;
- }
-
- /* On encryption, we store (feed ^ data) which is cypher */
- *s = stp->str_output[index] = (stp->str_feed[index] ^ *s);
- s++;
- index++;
- }
- stp->str_index = index;
-}
-
- int
-cfb64_decrypt(data)
- int data;
-{
- register struct stinfo *stp = &fb[CFB].streams[DIR_DECRYPT-1];
- int index;
-
- if (data == -1) {
- /*
- * Back up one byte. It is assumed that we will
- * never back up more than one byte. If we do, this
- * may or may not work.
- */
- if (stp->str_index)
- --stp->str_index;
- return(0);
- }
-
- index = stp->str_index++;
- if (index == sizeof(Block)) {
- Block b;
- des_ecb_encrypt((Block *)stp->str_output, (Block *)b, stp->str_sched, 1);
- memmove((void *)stp->str_feed, (void *)b, sizeof(Block));
- stp->str_index = 1; /* Next time will be 1 */
- index = 0; /* But now use 0 */
- }
-
- /* On decryption we store (data) which is cypher. */
- stp->str_output[index] = data;
- return(data ^ stp->str_feed[index]);
-}
-
-/*
- * DES 64 bit Output Feedback
- *
- * key --->+-----+
- * +->| DES |--+
- * | +-----+ |
- * +-----------+
- * v
- * INPUT -------->(+) ----> DATA
- *
- * Given:
- * iV: Initial vector, 64 bits (8 bytes) long.
- * Dn: the nth chunk of 64 bits (8 bytes) of data to encrypt (decrypt).
- * On: the nth chunk of 64 bits (8 bytes) of encrypted (decrypted) output.
- *
- * V0 = DES(iV, key)
- * V(n+1) = DES(Vn, key)
- * On = Dn ^ Vn
- */
- void
-ofb64_encrypt(s, c)
- register unsigned char *s;
- int c;
-{
- register struct stinfo *stp = &fb[OFB].streams[DIR_ENCRYPT-1];
- register int index;
-
- index = stp->str_index;
- while (c-- > 0) {
- if (index == sizeof(Block)) {
- Block b;
- des_ecb_encrypt((Block *)stp->str_feed, (Block *)b, stp->str_sched, 1);
- memmove((void *)stp->str_feed, (void *)b, sizeof(Block));
- index = 0;
- }
- *s++ ^= stp->str_feed[index];
- index++;
- }
- stp->str_index = index;
-}
-
- int
-ofb64_decrypt(data)
- int data;
-{
- register struct stinfo *stp = &fb[OFB].streams[DIR_DECRYPT-1];
- int index;
-
- if (data == -1) {
- /*
- * Back up one byte. It is assumed that we will
- * never back up more than one byte. If we do, this
- * may or may not work.
- */
- if (stp->str_index)
- --stp->str_index;
- return(0);
- }
-
- index = stp->str_index++;
- if (index == sizeof(Block)) {
- Block b;
- des_ecb_encrypt((Block *)stp->str_feed, (Block *)b, stp->str_sched, 1);
- memmove((void *)stp->str_feed, (void *)b, sizeof(Block));
- stp->str_index = 1; /* Next time will be 1 */
- index = 0; /* But now use 0 */
- }
-
- return(data ^ stp->str_feed[index]);
-}
-# endif /* DES_ENCRYPTION */
-# endif /* AUTHENTICATION */
-#endif /* ENCRYPTION */
diff --git a/contrib/telnet/libtelnet/encrypt.c b/contrib/telnet/libtelnet/encrypt.c
deleted file mode 100644
index e1ac1c4a5f81..000000000000
--- a/contrib/telnet/libtelnet/encrypt.c
+++ /dev/null
@@ -1,1023 +0,0 @@
-/*-
- * Copyright (c) 1991, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-static const char sccsid[] = "@(#)encrypt.c 8.2 (Berkeley) 5/30/95";
-#endif /* not lint */
-
-/*
- * Copyright (C) 1990 by the Massachusetts Institute of Technology
- *
- * Export of this software from the United States of America is assumed
- * to require a specific license from the United States Government.
- * It is the responsibility of any person or organization contemplating
- * export to obtain such a license before exporting.
- *
- * WITHIN THAT CONSTRAINT, 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 appear in all copies and that both that copyright notice and
- * this permission notice appear in supporting documentation, and that
- * the name of M.I.T. not be used in advertising or publicity pertaining
- * to distribution of the software without specific, written prior
- * permission. M.I.T. makes no representations about the suitability of
- * this software for any purpose. It is provided "as is" without express
- * or implied warranty.
- */
-
-#ifdef ENCRYPTION
-
-#define ENCRYPT_NAMES
-#include <stdio.h>
-#include <arpa/telnet.h>
-
-#include "encrypt.h"
-#include "misc.h"
-
-#ifdef __STDC__
-#include <stdlib.h>
-#endif
-#ifdef NO_STRING_H
-#include <strings.h>
-#else
-#include <string.h>
-#endif
-
-/*
- * These functions pointers point to the current routines
- * for encrypting and decrypting data.
- */
-void (*encrypt_output) P((unsigned char *, int));
-int (*decrypt_input) P((int));
-
-int EncryptType(char *type, char *mode);
-int EncryptStart(char *mode);
-int EncryptStop(char *mode);
-int EncryptStartInput(void);
-int EncryptStartOutput(void);
-int EncryptStopInput(void);
-int EncryptStopOutput(void);
-
-int Ambiguous(char **s);
-int isprefix(char *s1, char *s2);
-char **genget(char *name, char **table, int stlen);
-
-int encrypt_debug_mode = 0;
-static int decrypt_mode = 0;
-static int encrypt_mode = 0;
-static int encrypt_verbose = 0;
-static int autoencrypt = 0;
-static int autodecrypt = 0;
-static int havesessionkey = 0;
-static int Server = 0;
-static char *Name = "Noname";
-
-#define typemask(x) ((x) > 0 ? 1 << ((x)-1) : 0)
-
-static long i_support_encrypt = 0
-#ifdef DES_ENCRYPTION
- | typemask(ENCTYPE_DES_CFB64) | typemask(ENCTYPE_DES_OFB64)
-#endif
- |0;
-static long i_support_decrypt = 0
-#ifdef DES_ENCRYPTION
- | typemask(ENCTYPE_DES_CFB64) | typemask(ENCTYPE_DES_OFB64)
-#endif
- |0;
-
-static long i_wont_support_encrypt = 0;
-static long i_wont_support_decrypt = 0;
-#define I_SUPPORT_ENCRYPT (i_support_encrypt & ~i_wont_support_encrypt)
-#define I_SUPPORT_DECRYPT (i_support_decrypt & ~i_wont_support_decrypt)
-
-static long remote_supports_encrypt = 0;
-static long remote_supports_decrypt = 0;
-
-static Encryptions encryptions[] = {
-#ifdef DES_ENCRYPTION
- { "DES_CFB64", ENCTYPE_DES_CFB64,
- cfb64_encrypt,
- cfb64_decrypt,
- cfb64_init,
- cfb64_start,
- cfb64_is,
- cfb64_reply,
- cfb64_session,
- cfb64_keyid,
- cfb64_printsub },
- { "DES_OFB64", ENCTYPE_DES_OFB64,
- ofb64_encrypt,
- ofb64_decrypt,
- ofb64_init,
- ofb64_start,
- ofb64_is,
- ofb64_reply,
- ofb64_session,
- ofb64_keyid,
- ofb64_printsub },
-#endif /* DES_ENCRYPTION */
- { 0, },
-};
-
-static unsigned char str_send[64] = { IAC, SB, TELOPT_ENCRYPT,
- ENCRYPT_SUPPORT };
-static unsigned char str_suplen = 0;
-static unsigned char str_start[72] = { IAC, SB, TELOPT_ENCRYPT };
-static unsigned char str_end[] = { IAC, SB, TELOPT_ENCRYPT, 0, IAC, SE };
-
- Encryptions *
-findencryption(type)
- int type;
-{
- Encryptions *ep = encryptions;
-
- if (!(I_SUPPORT_ENCRYPT & remote_supports_decrypt & typemask(type)))
- return(0);
- while (ep->type && ep->type != type)
- ++ep;
- return(ep->type ? ep : 0);
-}
-
- Encryptions *
-finddecryption(type)
- int type;
-{
- Encryptions *ep = encryptions;
-
- if (!(I_SUPPORT_DECRYPT & remote_supports_encrypt & typemask(type)))
- return(0);
- while (ep->type && ep->type != type)
- ++ep;
- return(ep->type ? ep : 0);
-}
-
-#define MAXKEYLEN 64
-
-static struct key_info {
- unsigned char keyid[MAXKEYLEN];
- int keylen;
- int dir;
- int *modep;
- Encryptions *(*getcrypt)();
-} ki[2] = {
- { { 0 }, 0, DIR_ENCRYPT, &encrypt_mode, findencryption },
- { { 0 }, 0, DIR_DECRYPT, &decrypt_mode, finddecryption },
-};
-
-static void encrypt_keyid(struct key_info *kp, unsigned char *keyid, int len);
-
- void
-encrypt_init(name, server)
- char *name;
- int server;
-{
- Encryptions *ep = encryptions;
-
- Name = name;
- Server = server;
- i_support_encrypt = i_support_decrypt = 0;
- remote_supports_encrypt = remote_supports_decrypt = 0;
- encrypt_mode = 0;
- decrypt_mode = 0;
- encrypt_output = 0;
- decrypt_input = 0;
-#ifdef notdef
- encrypt_verbose = !server;
-#endif
-
- str_suplen = 4;
-
- while (ep->type) {
- if (encrypt_debug_mode)
- printf(">>>%s: I will support %s\r\n",
- Name, ENCTYPE_NAME(ep->type));
- i_support_encrypt |= typemask(ep->type);
- i_support_decrypt |= typemask(ep->type);
- if ((i_wont_support_decrypt & typemask(ep->type)) == 0)
- if ((str_send[str_suplen++] = ep->type) == IAC)
- str_send[str_suplen++] = IAC;
- if (ep->init)
- (*ep->init)(Server);
- ++ep;
- }
- str_send[str_suplen++] = IAC;
- str_send[str_suplen++] = SE;
-}
-
- void
-encrypt_list_types()
-{
- Encryptions *ep = encryptions;
-
- printf("Valid encryption types:\n");
- while (ep->type) {
- printf("\t%s (%d)\r\n", ENCTYPE_NAME(ep->type), ep->type);
- ++ep;
- }
-}
-
- int
-EncryptEnable(type, mode)
- char *type, *mode;
-{
- if (isprefix(type, "help") || isprefix(type, "?")) {
- printf("Usage: encrypt enable <type> [input|output]\n");
- encrypt_list_types();
- return(0);
- }
- if (EncryptType(type, mode))
- return(EncryptStart(mode));
- return(0);
-}
-
- int
-EncryptDisable(type, mode)
- char *type, *mode;
-{
- register Encryptions *ep;
- int ret = 0;
-
- if (isprefix(type, "help") || isprefix(type, "?")) {
- printf("Usage: encrypt disable <type> [input|output]\n");
- encrypt_list_types();
- } else if ((ep = (Encryptions *)genget(type, (char **)encryptions,
- sizeof(Encryptions))) == 0) {
- printf("%s: invalid encryption type\n", type);
- } else if (Ambiguous((char **)ep)) {
- printf("Ambiguous type '%s'\n", type);
- } else {
- if ((mode == 0) || (isprefix(mode, "input") ? 1 : 0)) {
- if (decrypt_mode == ep->type)
- EncryptStopInput();
- i_wont_support_decrypt |= typemask(ep->type);
- ret = 1;
- }
- if ((mode == 0) || (isprefix(mode, "output"))) {
- if (encrypt_mode == ep->type)
- EncryptStopOutput();
- i_wont_support_encrypt |= typemask(ep->type);
- ret = 1;
- }
- if (ret == 0)
- printf("%s: invalid encryption mode\n", mode);
- }
- return(ret);
-}
-
- int
-EncryptType(type, mode)
- char *type;
- char *mode;
-{
- register Encryptions *ep;
- int ret = 0;
-
- if (isprefix(type, "help") || isprefix(type, "?")) {
- printf("Usage: encrypt type <type> [input|output]\n");
- encrypt_list_types();
- } else if ((ep = (Encryptions *)genget(type, (char **)encryptions,
- sizeof(Encryptions))) == 0) {
- printf("%s: invalid encryption type\n", type);
- } else if (Ambiguous((char **)ep)) {
- printf("Ambiguous type '%s'\n", type);
- } else {
- if ((mode == 0) || isprefix(mode, "input")) {
- decrypt_mode = ep->type;
- i_wont_support_decrypt &= ~typemask(ep->type);
- ret = 1;
- }
- if ((mode == 0) || isprefix(mode, "output")) {
- encrypt_mode = ep->type;
- i_wont_support_encrypt &= ~typemask(ep->type);
- ret = 1;
- }
- if (ret == 0)
- printf("%s: invalid encryption mode\n", mode);
- }
- return(ret);
-}
-
- int
-EncryptStart(mode)
- char *mode;
-{
- register int ret = 0;
- if (mode) {
- if (isprefix(mode, "input"))
- return(EncryptStartInput());
- if (isprefix(mode, "output"))
- return(EncryptStartOutput());
- if (isprefix(mode, "help") || isprefix(mode, "?")) {
- printf("Usage: encrypt start [input|output]\n");
- return(0);
- }
- printf("%s: invalid encryption mode 'encrypt start ?' for help\n", mode);
- return(0);
- }
- ret += EncryptStartInput();
- ret += EncryptStartOutput();
- return(ret);
-}
-
- int
-EncryptStartInput()
-{
- if (decrypt_mode) {
- encrypt_send_request_start();
- return(1);
- }
- printf("No previous decryption mode, decryption not enabled\r\n");
- return(0);
-}
-
- int
-EncryptStartOutput()
-{
- if (encrypt_mode) {
- encrypt_start_output(encrypt_mode);
- return(1);
- }
- printf("No previous encryption mode, encryption not enabled\r\n");
- return(0);
-}
-
- int
-EncryptStop(mode)
- char *mode;
-{
- int ret = 0;
- if (mode) {
- if (isprefix(mode, "input"))
- return(EncryptStopInput());
- if (isprefix(mode, "output"))
- return(EncryptStopOutput());
- if (isprefix(mode, "help") || isprefix(mode, "?")) {
- printf("Usage: encrypt stop [input|output]\n");
- return(0);
- }
- printf("%s: invalid encryption mode 'encrypt stop ?' for help\n", mode);
- return(0);
- }
- ret += EncryptStopInput();
- ret += EncryptStopOutput();
- return(ret);
-}
-
- int
-EncryptStopInput()
-{
- encrypt_send_request_end();
- return(1);
-}
-
- int
-EncryptStopOutput()
-{
- encrypt_send_end();
- return(1);
-}
-
- void
-encrypt_display()
-{
- if (encrypt_output)
- printf("Currently encrypting output with %s\r\n",
- ENCTYPE_NAME(encrypt_mode));
- if (decrypt_input)
- printf("Currently decrypting input with %s\r\n",
- ENCTYPE_NAME(decrypt_mode));
-}
-
- int
-EncryptStatus()
-{
- if (encrypt_output)
- printf("Currently encrypting output with %s\r\n",
- ENCTYPE_NAME(encrypt_mode));
- else if (encrypt_mode) {
- printf("Currently output is clear text.\r\n");
- printf("Last encryption mode was %s\r\n",
- ENCTYPE_NAME(encrypt_mode));
- }
- if (decrypt_input) {
- printf("Currently decrypting input with %s\r\n",
- ENCTYPE_NAME(decrypt_mode));
- } else if (decrypt_mode) {
- printf("Currently input is clear text.\r\n");
- printf("Last decryption mode was %s\r\n",
- ENCTYPE_NAME(decrypt_mode));
- }
- return 1;
-}
-
- void
-encrypt_send_support()
-{
- if (str_suplen) {
- /*
- * If the user has requested that decryption start
- * immediatly, then send a "REQUEST START" before
- * we negotiate the type.
- */
- if (!Server && autodecrypt)
- encrypt_send_request_start();
- net_write(str_send, str_suplen);
- printsub('>', &str_send[2], str_suplen - 2);
- str_suplen = 0;
- }
-}
-
- int
-EncryptDebug(on)
- int on;
-{
- if (on < 0)
- encrypt_debug_mode ^= 1;
- else
- encrypt_debug_mode = on;
- printf("Encryption debugging %s\r\n",
- encrypt_debug_mode ? "enabled" : "disabled");
- return(1);
-}
-
- int
-EncryptVerbose(on)
- int on;
-{
- if (on < 0)
- encrypt_verbose ^= 1;
- else
- encrypt_verbose = on;
- printf("Encryption %s verbose\r\n",
- encrypt_verbose ? "is" : "is not");
- return(1);
-}
-
- int
-EncryptAutoEnc(on)
- int on;
-{
- encrypt_auto(on);
- printf("Automatic encryption of output is %s\r\n",
- autoencrypt ? "enabled" : "disabled");
- return(1);
-}
-
- int
-EncryptAutoDec(on)
- int on;
-{
- decrypt_auto(on);
- printf("Automatic decryption of input is %s\r\n",
- autodecrypt ? "enabled" : "disabled");
- return(1);
-}
-
-/*
- * Called when ENCRYPT SUPPORT is received.
- */
- void
-encrypt_support(typelist, cnt)
- unsigned char *typelist;
- int cnt;
-{
- register int type, use_type = 0;
- Encryptions *ep;
-
- /*
- * Forget anything the other side has previously told us.
- */
- remote_supports_decrypt = 0;
-
- while (cnt-- > 0) {
- type = *typelist++;
- if (encrypt_debug_mode)
- printf(">>>%s: He is supporting %s (%d)\r\n",
- Name,
- ENCTYPE_NAME(type), type);
- if ((type < ENCTYPE_CNT) &&
- (I_SUPPORT_ENCRYPT & typemask(type))) {
- remote_supports_decrypt |= typemask(type);
- if (use_type == 0)
- use_type = type;
- }
- }
- if (use_type) {
- ep = findencryption(use_type);
- if (!ep)
- return;
- type = ep->start ? (*ep->start)(DIR_ENCRYPT, Server) : 0;
- if (encrypt_debug_mode)
- printf(">>>%s: (*ep->start)() returned %d\r\n",
- Name, type);
- if (type < 0)
- return;
- encrypt_mode = use_type;
- if (type == 0)
- encrypt_start_output(use_type);
- }
-}
-
- void
-encrypt_is(data, cnt)
- unsigned char *data;
- int cnt;
-{
- Encryptions *ep;
- register int type, ret;
-
- if (--cnt < 0)
- return;
- type = *data++;
- if (type < ENCTYPE_CNT)
- remote_supports_encrypt |= typemask(type);
- if (!(ep = finddecryption(type))) {
- if (encrypt_debug_mode)
- printf(">>>%s: Can't find type %s (%d) for initial negotiation\r\n",
- Name,
- ENCTYPE_NAME_OK(type)
- ? ENCTYPE_NAME(type) : "(unknown)",
- type);
- return;
- }
- if (!ep->is) {
- if (encrypt_debug_mode)
- printf(">>>%s: No initial negotiation needed for type %s (%d)\r\n",
- Name,
- ENCTYPE_NAME_OK(type)
- ? ENCTYPE_NAME(type) : "(unknown)",
- type);
- ret = 0;
- } else {
- ret = (*ep->is)(data, cnt);
- if (encrypt_debug_mode)
- printf("(*ep->is)(%p, %d) returned %s(%d)\n", data, cnt,
- (ret < 0) ? "FAIL " :
- (ret == 0) ? "SUCCESS " : "MORE_TO_DO ", ret);
- }
- if (ret < 0) {
- autodecrypt = 0;
- } else {
- decrypt_mode = type;
- if (ret == 0 && autodecrypt)
- encrypt_send_request_start();
- }
-}
-
- void
-encrypt_reply(data, cnt)
- unsigned char *data;
- int cnt;
-{
- Encryptions *ep;
- register int ret, type;
-
- if (--cnt < 0)
- return;
- type = *data++;
- if (!(ep = findencryption(type))) {
- if (encrypt_debug_mode)
- printf(">>>%s: Can't find type %s (%d) for initial negotiation\r\n",
- Name,
- ENCTYPE_NAME_OK(type)
- ? ENCTYPE_NAME(type) : "(unknown)",
- type);
- return;
- }
- if (!ep->reply) {
- if (encrypt_debug_mode)
- printf(">>>%s: No initial negotiation needed for type %s (%d)\r\n",
- Name,
- ENCTYPE_NAME_OK(type)
- ? ENCTYPE_NAME(type) : "(unknown)",
- type);
- ret = 0;
- } else {
- ret = (*ep->reply)(data, cnt);
- if (encrypt_debug_mode)
- printf("(*ep->reply)(%p, %d) returned %s(%d)\n",
- data, cnt,
- (ret < 0) ? "FAIL " :
- (ret == 0) ? "SUCCESS " : "MORE_TO_DO ", ret);
- }
- if (encrypt_debug_mode)
- printf(">>>%s: encrypt_reply returned %d\n", Name, ret);
- if (ret < 0) {
- autoencrypt = 0;
- } else {
- encrypt_mode = type;
- if (ret == 0 && autoencrypt)
- encrypt_start_output(type);
- }
-}
-
-/*
- * Called when a ENCRYPT START command is received.
- */
- void
-encrypt_start(data, cnt)
- unsigned char *data;
- int cnt;
-{
- Encryptions *ep;
-
- if (!decrypt_mode) {
- /*
- * Something is wrong. We should not get a START
- * command without having already picked our
- * decryption scheme. Send a REQUEST-END to
- * attempt to clear the channel...
- */
- printf("%s: Warning, Cannot decrypt input stream!!!\r\n", Name);
- encrypt_send_request_end();
- return;
- }
-
- if ((ep = finddecryption(decrypt_mode))) {
- decrypt_input = ep->input;
- if (encrypt_verbose)
- printf("[ Input is now decrypted with type %s ]\r\n",
- ENCTYPE_NAME(decrypt_mode));
- if (encrypt_debug_mode)
- printf(">>>%s: Start to decrypt input with type %s\r\n",
- Name, ENCTYPE_NAME(decrypt_mode));
- } else {
- printf("%s: Warning, Cannot decrypt type %s (%d)!!!\r\n",
- Name,
- ENCTYPE_NAME_OK(decrypt_mode)
- ? ENCTYPE_NAME(decrypt_mode)
- : "(unknown)",
- decrypt_mode);
- encrypt_send_request_end();
- }
-}
-
- void
-encrypt_session_key(key, server)
- Session_Key *key;
- int server;
-{
- Encryptions *ep = encryptions;
-
- havesessionkey = 1;
-
- while (ep->type) {
- if (ep->session)
- (*ep->session)(key, server);
-#ifdef notdef
- if (!encrypt_output && autoencrypt && !server)
- encrypt_start_output(ep->type);
- if (!decrypt_input && autodecrypt && !server)
- encrypt_send_request_start();
-#endif
- ++ep;
- }
-}
-
-/*
- * Called when ENCRYPT END is received.
- */
- void
-encrypt_end()
-{
- decrypt_input = 0;
- if (encrypt_debug_mode)
- printf(">>>%s: Input is back to clear text\r\n", Name);
- if (encrypt_verbose)
- printf("[ Input is now clear text ]\r\n");
-}
-
-/*
- * Called when ENCRYPT REQUEST-END is received.
- */
- void
-encrypt_request_end()
-{
- encrypt_send_end();
-}
-
-/*
- * Called when ENCRYPT REQUEST-START is received. If we receive
- * this before a type is picked, then that indicates that the
- * other side wants us to start encrypting data as soon as we
- * can.
- */
- void
-encrypt_request_start(data, cnt)
- unsigned char *data;
- int cnt;
-{
- if (encrypt_mode == 0) {
- if (Server)
- autoencrypt = 1;
- return;
- }
- encrypt_start_output(encrypt_mode);
-}
-
-static unsigned char str_keyid[(MAXKEYLEN*2)+5] = { IAC, SB, TELOPT_ENCRYPT };
-
- void
-encrypt_enc_keyid(keyid, len)
- unsigned char *keyid;
- int len;
-{
- encrypt_keyid(&ki[1], keyid, len);
-}
-
- void
-encrypt_dec_keyid(keyid, len)
- unsigned char *keyid;
- int len;
-{
- encrypt_keyid(&ki[0], keyid, len);
-}
-
- void
-encrypt_keyid(kp, keyid, len)
- struct key_info *kp;
- unsigned char *keyid;
- int len;
-{
- Encryptions *ep;
- int dir = kp->dir;
- register int ret = 0;
-
- if (!(ep = (*kp->getcrypt)(*kp->modep))) {
- if (len == 0)
- return;
- kp->keylen = 0;
- } else if (len == 0) {
- /*
- * Empty option, indicates a failure.
- */
- if (kp->keylen == 0)
- return;
- kp->keylen = 0;
- if (ep->keyid)
- (void)(*ep->keyid)(dir, kp->keyid, &kp->keylen);
-
- } else if ((len != kp->keylen) ||
- (memcmp(keyid, kp->keyid, len) != 0)) {
- /*
- * Length or contents are different
- */
- kp->keylen = len;
- memmove(kp->keyid, keyid, len);
- if (ep->keyid)
- (void)(*ep->keyid)(dir, kp->keyid, &kp->keylen);
- } else {
- if (ep->keyid)
- ret = (*ep->keyid)(dir, kp->keyid, &kp->keylen);
- if ((ret == 0) && (dir == DIR_ENCRYPT) && autoencrypt)
- encrypt_start_output(*kp->modep);
- return;
- }
-
- encrypt_send_keyid(dir, kp->keyid, kp->keylen, 0);
-}
-
- void
-encrypt_send_keyid(dir, keyid, keylen, saveit)
- int dir;
- unsigned char *keyid;
- int keylen;
- int saveit;
-{
- unsigned char *strp;
-
- str_keyid[3] = (dir == DIR_ENCRYPT)
- ? ENCRYPT_ENC_KEYID : ENCRYPT_DEC_KEYID;
- if (saveit) {
- struct key_info *kp = &ki[(dir == DIR_ENCRYPT) ? 0 : 1];
- memmove(kp->keyid, keyid, keylen);
- kp->keylen = keylen;
- }
-
- for (strp = &str_keyid[4]; keylen > 0; --keylen) {
- if ((*strp++ = *keyid++) == IAC)
- *strp++ = IAC;
- }
- *strp++ = IAC;
- *strp++ = SE;
- net_write(str_keyid, strp - str_keyid);
- printsub('>', &str_keyid[2], strp - str_keyid - 2);
-}
-
- void
-encrypt_auto(on)
- int on;
-{
- if (on < 0)
- autoencrypt ^= 1;
- else
- autoencrypt = on ? 1 : 0;
-}
-
- void
-decrypt_auto(on)
- int on;
-{
- if (on < 0)
- autodecrypt ^= 1;
- else
- autodecrypt = on ? 1 : 0;
-}
-
- void
-encrypt_start_output(type)
- int type;
-{
- Encryptions *ep;
- register unsigned char *p;
- register int i;
-
- if (!(ep = findencryption(type))) {
- if (encrypt_debug_mode) {
- printf(">>>%s: Can't encrypt with type %s (%d)\r\n",
- Name,
- ENCTYPE_NAME_OK(type)
- ? ENCTYPE_NAME(type) : "(unknown)",
- type);
- }
- return;
- }
- if (ep->start) {
- i = (*ep->start)(DIR_ENCRYPT, Server);
- if (encrypt_debug_mode) {
- printf(">>>%s: Encrypt start: %s (%d) %s\r\n",
- Name,
- (i < 0) ? "failed" :
- "initial negotiation in progress",
- i, ENCTYPE_NAME(type));
- }
- if (i)
- return;
- }
- p = str_start + 3;
- *p++ = ENCRYPT_START;
- for (i = 0; i < ki[0].keylen; ++i) {
- if ((*p++ = ki[0].keyid[i]) == IAC)
- *p++ = IAC;
- }
- *p++ = IAC;
- *p++ = SE;
- net_write(str_start, p - str_start);
- net_encrypt();
- printsub('>', &str_start[2], p - &str_start[2]);
- /*
- * If we are already encrypting in some mode, then
- * encrypt the ring (which includes our request) in
- * the old mode, mark it all as "clear text" and then
- * switch to the new mode.
- */
- encrypt_output = ep->output;
- encrypt_mode = type;
- if (encrypt_debug_mode)
- printf(">>>%s: Started to encrypt output with type %s\r\n",
- Name, ENCTYPE_NAME(type));
- if (encrypt_verbose)
- printf("[ Output is now encrypted with type %s ]\r\n",
- ENCTYPE_NAME(type));
-}
-
- void
-encrypt_send_end()
-{
- if (!encrypt_output)
- return;
-
- str_end[3] = ENCRYPT_END;
- net_write(str_end, sizeof(str_end));
- net_encrypt();
- printsub('>', &str_end[2], sizeof(str_end) - 2);
- /*
- * Encrypt the output buffer now because it will not be done by
- * netflush...
- */
- encrypt_output = 0;
- if (encrypt_debug_mode)
- printf(">>>%s: Output is back to clear text\r\n", Name);
- if (encrypt_verbose)
- printf("[ Output is now clear text ]\r\n");
-}
-
- void
-encrypt_send_request_start()
-{
- register unsigned char *p;
- register int i;
-
- p = &str_start[3];
- *p++ = ENCRYPT_REQSTART;
- for (i = 0; i < ki[1].keylen; ++i) {
- if ((*p++ = ki[1].keyid[i]) == IAC)
- *p++ = IAC;
- }
- *p++ = IAC;
- *p++ = SE;
- net_write(str_start, p - str_start);
- printsub('>', &str_start[2], p - &str_start[2]);
- if (encrypt_debug_mode)
- printf(">>>%s: Request input to be encrypted\r\n", Name);
-}
-
- void
-encrypt_send_request_end()
-{
- str_end[3] = ENCRYPT_REQEND;
- net_write(str_end, sizeof(str_end));
- printsub('>', &str_end[2], sizeof(str_end) - 2);
-
- if (encrypt_debug_mode)
- printf(">>>%s: Request input to be clear text\r\n", Name);
-}
-
- void
-encrypt_wait()
-{
- if (encrypt_debug_mode)
- printf(">>>%s: in encrypt_wait\r\n", Name);
- if (!havesessionkey || !(I_SUPPORT_ENCRYPT & remote_supports_decrypt))
- return;
- while (autoencrypt && !encrypt_output)
- if (telnet_spin())
- return;
-}
-
- void
-encrypt_debug(mode)
- int mode;
-{
- encrypt_debug_mode = mode;
-}
-
- void
-encrypt_gen_printsub(data, cnt, buf, buflen)
- unsigned char *data, *buf;
- int cnt, buflen;
-{
- char tbuf[16], *cp;
-
- cnt -= 2;
- data += 2;
- buf[buflen-1] = '\0';
- buf[buflen-2] = '*';
- buflen -= 2;;
- for (; cnt > 0; cnt--, data++) {
- sprintf(tbuf, " %d", *data);
- for (cp = tbuf; *cp && buflen > 0; --buflen)
- *buf++ = *cp++;
- if (buflen <= 0)
- return;
- }
- *buf = '\0';
-}
-
- void
-encrypt_printsub(data, cnt, buf, buflen)
- unsigned char *data, *buf;
- int cnt, buflen;
-{
- Encryptions *ep;
- register int type = data[1];
-
- for (ep = encryptions; ep->type && ep->type != type; ep++)
- ;
-
- if (ep->printsub)
- (*ep->printsub)(data, cnt, buf, buflen);
- else
- encrypt_gen_printsub(data, cnt, buf, buflen);
-}
-#endif /* ENCRYPTION */
diff --git a/contrib/telnet/libtelnet/encrypt.h b/contrib/telnet/libtelnet/encrypt.h
deleted file mode 100644
index 869ad751709a..000000000000
--- a/contrib/telnet/libtelnet/encrypt.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/*-
- * Copyright (c) 1991, 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)encrypt.h 8.1 (Berkeley) 6/4/93
- * $FreeBSD$
- */
-
-/*
- * Copyright (C) 1990 by the Massachusetts Institute of Technology
- *
- * Export of this software from the United States of America is assumed
- * to require a specific license from the United States Government.
- * It is the responsibility of any person or organization contemplating
- * export to obtain such a license before exporting.
- *
- * WITHIN THAT CONSTRAINT, 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 appear in all copies and that both that copyright notice and
- * this permission notice appear in supporting documentation, and that
- * the name of M.I.T. not be used in advertising or publicity pertaining
- * to distribution of the software without specific, written prior
- * permission. M.I.T. makes no representations about the suitability of
- * this software for any purpose. It is provided "as is" without express
- * or implied warranty.
- */
-
-#ifdef ENCRYPTION
-# ifndef __ENCRYPTION__
-# define __ENCRYPTION__
-
-#define DIR_DECRYPT 1
-#define DIR_ENCRYPT 2
-
-#include <openssl/des.h>
-typedef unsigned char Block[8];
-typedef unsigned char *BlockT;
-#if 0
-typedef struct { Block __; } Schedule[16];
-#else
-#define Schedule des_key_schedule
-#endif
-
-#define VALIDKEY(key) ( key[0] | key[1] | key[2] | key[3] | \
- key[4] | key[5] | key[6] | key[7])
-
-#define SAMEKEY(k1, k2) (!bcmp((void *)k1, (void *)k2, sizeof(Block)))
-
-typedef struct {
- short type;
- int length;
- unsigned char *data;
-} Session_Key;
-
-# if !defined(P)
-# ifdef __STDC__
-# define P(x) x
-# else
-# define P(x) ()
-# endif
-# endif
-
-typedef struct {
- char *name;
- int type;
- void (*output) P((unsigned char *, int));
- int (*input) P((int));
- void (*init) P((int));
- int (*start) P((int, int));
- int (*is) P((unsigned char *, int));
- int (*reply) P((unsigned char *, int));
- void (*session) P((Session_Key *, int));
- int (*keyid) P((int, unsigned char *, int *));
- void (*printsub) P((unsigned char *, int, unsigned char *, int));
-} Encryptions;
-
-#define SK_DES 1 /* Matched Kerberos v5 KEYTYPE_DES */
-
-#include "enc-proto.h"
-
-extern int encrypt_debug_mode;
-extern int (*decrypt_input) P((int));
-extern void (*encrypt_output) P((unsigned char *, int));
-# endif /* __ENCRYPTION__ */
-#endif /* ENCRYPTION */
diff --git a/contrib/telnet/libtelnet/genget.c b/contrib/telnet/libtelnet/genget.c
deleted file mode 100644
index 8668db47a700..000000000000
--- a/contrib/telnet/libtelnet/genget.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/*-
- * Copyright (c) 1991, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-static const char sccsid[] = "@(#)genget.c 8.2 (Berkeley) 5/30/95";
-#endif /* not lint */
-
-
-#include <ctype.h>
-
-#define LOWER(x) (isupper(x) ? tolower(x) : (x))
-/*
- * The prefix function returns 0 if *s1 is not a prefix
- * of *s2. If *s1 exactly matches *s2, the negative of
- * the length is returned. If *s1 is a prefix of *s2,
- * the length of *s1 is returned.
- */
- int
-isprefix(s1, s2)
- register char *s1, *s2;
-{
- char *os1;
- register char c1, c2;
-
- if (*s1 == '\0')
- return(-1);
- os1 = s1;
- c1 = *s1;
- c2 = *s2;
- while (LOWER(c1) == LOWER(c2)) {
- if (c1 == '\0')
- break;
- c1 = *++s1;
- c2 = *++s2;
- }
- return(*s1 ? 0 : (*s2 ? (s1 - os1) : (os1 - s1)));
-}
-
-static char *ambiguous; /* special return value for command routines */
-
- char **
-genget(name, table, stlen)
- char *name; /* name to match */
- char **table; /* name entry in table */
- int stlen;
-{
- register char **c, **found;
- register int n;
-
- if (name == 0)
- return 0;
-
- found = 0;
- for (c = table; *c != 0; c = (char **)((char *)c + stlen)) {
- if ((n = isprefix(name, *c)) == 0)
- continue;
- if (n < 0) /* exact match */
- return(c);
- if (found)
- return(&ambiguous);
- found = c;
- }
- return(found);
-}
-
-/*
- * Function call version of Ambiguous()
- */
- int
-Ambiguous(s)
- char **s;
-{
- return(s == &ambiguous);
-}
diff --git a/contrib/telnet/libtelnet/getent.c b/contrib/telnet/libtelnet/getent.c
deleted file mode 100644
index 5aa1049a3c8d..000000000000
--- a/contrib/telnet/libtelnet/getent.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/*-
- * Copyright (c) 1991, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-static char sccsid[] = "@(#)getent.c 8.2 (Berkeley) 12/15/93";
-#endif /* not lint */
-
-static char *area;
-
-/*ARGSUSED*/
-getent(cp, name)
-char *cp, *name;
-{
-#ifdef HAS_CGETENT
- char *dba[2];
-
- dba[0] = "/etc/gettytab";
- dba[1] = 0;
- return((cgetent(&area, dba, name) == 0) ? 1 : 0);
-#else
- return(0);
-#endif
-}
-
-#ifndef SOLARIS
-/*ARGSUSED*/
-char *
-Getstr(id, cpp)
-char *id, **cpp;
-{
-# ifdef HAS_CGETENT
- char *answer;
- return((cgetstr(area, id, &answer) > 0) ? answer : 0);
-# else
- return(0);
-# endif
-}
-#endif
diff --git a/contrib/telnet/libtelnet/kerberos.c b/contrib/telnet/libtelnet/kerberos.c
deleted file mode 100644
index 3b6155e593b4..000000000000
--- a/contrib/telnet/libtelnet/kerberos.c
+++ /dev/null
@@ -1,552 +0,0 @@
-/*-
- * Copyright (c) 1991, 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- */
-
-#ifndef lint
-static const char sccsid[] = "@(#)kerberos.c 8.3 (Berkeley) 5/30/95";
-#endif /* not lint */
-
-/*
- * Copyright (C) 1990 by the Massachusetts Institute of Technology
- *
- * Export of this software from the United States of America is assumed
- * to require a specific license from the United States Government.
- * It is the responsibility of any person or organization contemplating
- * export to obtain such a license before exporting.
- *
- * WITHIN THAT CONSTRAINT, 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 appear in all copies and that both that copyright notice and
- * this permission notice appear in supporting documentation, and that
- * the name of M.I.T. not be used in advertising or publicity pertaining
- * to distribution of the software without specific, written prior
- * permission. M.I.T. makes no representations about the suitability of
- * this software for any purpose. It is provided "as is" without express
- * or implied warranty.
- */
-
-#ifdef KRB4
-#include <sys/types.h>
-#include <arpa/telnet.h>
-#include <stdio.h>
-#include <openssl/des.h> /* BSD wont include this in krb.h, so we do it here */
-#include <krb.h>
-#ifdef __STDC__
-#include <stdlib.h>
-#endif
-#ifdef NO_STRING_H
-#include <strings.h>
-#else
-#include <string.h>
-#endif
-
-#include "encrypt.h"
-#include "auth.h"
-#include "misc.h"
-
-int kerberos4_cksum P((unsigned char *, int));
-int kuserok P((AUTH_DAT *, char *));
-
-extern auth_debug_mode;
-
-static unsigned char str_data[1024] = { IAC, SB, TELOPT_AUTHENTICATION, 0,
- AUTHTYPE_KERBEROS_V4, };
-
-#define KRB_AUTH 0 /* Authentication data follows */
-#define KRB_REJECT 1 /* Rejected (reason might follow) */
-#define KRB_ACCEPT 2 /* Accepted */
-#define KRB_CHALLENGE 3 /* Challenge for mutual auth. */
-#define KRB_RESPONSE 4 /* Response for mutual auth. */
-
-#define KRB_SERVICE_NAME "rcmd"
-
-static KTEXT_ST auth;
-static char name[ANAME_SZ];
-static AUTH_DAT adat = { 0 };
-#ifdef ENCRYPTION
-static Block session_key = { 0 };
-static des_key_schedule sched;
-static Block challenge = { 0 };
-#endif /* ENCRYPTION */
-
- static int
-Data(ap, type, d, c)
- Authenticator *ap;
- int type;
- void *d;
- int c;
-{
- unsigned char *p = str_data + 4;
- unsigned char *cd = (unsigned char *)d;
-
- if (c == -1)
- c = strlen((char *)cd);
-
- if (auth_debug_mode) {
- printf("%s:%d: [%d] (%d)",
- str_data[3] == TELQUAL_IS ? ">>>IS" : ">>>REPLY",
- str_data[3],
- type, c);
- printd(d, c);
- printf("\r\n");
- }
- *p++ = ap->type;
- *p++ = ap->way;
- *p++ = type;
- while (c-- > 0) {
- if ((*p++ = *cd++) == IAC)
- *p++ = IAC;
- }
- *p++ = IAC;
- *p++ = SE;
- if (str_data[3] == TELQUAL_IS)
- printsub('>', &str_data[2], p - (&str_data[2]));
- return(net_write(str_data, p - str_data));
-}
-
- int
-kerberos4_init(ap, server)
- Authenticator *ap;
- int server;
-{
- FILE *fp;
-
- if (server) {
- str_data[3] = TELQUAL_REPLY;
- if ((fp = fopen(KEYFILE, "r")) == NULL)
- return(0);
- fclose(fp);
- } else {
- str_data[3] = TELQUAL_IS;
- }
- return(1);
-}
-
-char dst_realm_buf[REALM_SZ], *dest_realm = NULL;
-int dst_realm_sz = REALM_SZ;
-
- int
-kerberos4_send(ap)
- Authenticator *ap;
-{
- KTEXT_ST auth;
- char instance[INST_SZ];
- char *realm;
- char *krb_realmofhost();
- char *krb_get_phost();
- CREDENTIALS cred;
- int r;
-
- printf("[ Trying KERBEROS4 ... ]\n");
- if (!UserNameRequested) {
- if (auth_debug_mode) {
- printf("Kerberos V4: no user name supplied\r\n");
- }
- return(0);
- }
-
- memset(instance, 0, sizeof(instance));
-
- if ((realm = krb_get_phost(RemoteHostName)))
- strncpy(instance, realm, sizeof(instance));
-
- instance[sizeof(instance)-1] = '\0';
-
- realm = dest_realm ? dest_realm : krb_realmofhost(RemoteHostName);
-
- if (!realm) {
- printf("Kerberos V4: no realm for %s\r\n", RemoteHostName);
- return(0);
- }
- if ((r = krb_mk_req(&auth, KRB_SERVICE_NAME, instance, realm, 0L))) {
- printf("mk_req failed: %s\r\n", krb_err_txt[r]);
- return(0);
- }
- if ((r = krb_get_cred(KRB_SERVICE_NAME, instance, realm, &cred))) {
- printf("get_cred failed: %s\r\n", krb_err_txt[r]);
- return(0);
- }
- if (!auth_sendname(UserNameRequested, strlen(UserNameRequested))) {
- if (auth_debug_mode)
- printf("Not enough room for user name\r\n");
- return(0);
- }
- if (auth_debug_mode)
- printf("Sent %d bytes of authentication data\r\n", auth.length);
- if (!Data(ap, KRB_AUTH, (void *)auth.dat, auth.length)) {
- if (auth_debug_mode)
- printf("Not enough room for authentication data\r\n");
- return(0);
- }
-#ifdef ENCRYPTION
- /*
- * If we are doing mutual authentication, get set up to send
- * the challenge, and verify it when the response comes back.
- */
- if ((ap->way & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL) {
- register int i;
-
- des_key_sched(&cred.session, sched);
- des_init_random_number_generator(&cred.session);
- des_new_random_key(&session_key);
- des_ecb_encrypt(&session_key, &session_key, sched, 0);
- des_ecb_encrypt(&session_key, &challenge, sched, 0);
- /*
- * Increment the challenge by 1, and encrypt it for
- * later comparison.
- */
- for (i = 7; i >= 0; --i) {
- register int x;
- x = (unsigned int)challenge[i] + 1;
- challenge[i] = x; /* ignore overflow */
- if (x < 256) /* if no overflow, all done */
- break;
- }
- des_ecb_encrypt(&challenge, &challenge, sched, 1);
- }
-#endif /* ENCRYPTION */
-
- if (auth_debug_mode) {
- printf("CK: %d:", kerberos4_cksum(auth.dat, auth.length));
- printd(auth.dat, auth.length);
- printf("\r\n");
- printf("Sent Kerberos V4 credentials to server\r\n");
- }
- return(1);
-}
-
- void
-kerberos4_is(ap, data, cnt)
- Authenticator *ap;
- unsigned char *data;
- int cnt;
-{
-#ifdef ENCRYPTION
- Session_Key skey;
- Block datablock;
-#endif /* ENCRYPTION */
- char realm[REALM_SZ];
- char instance[INST_SZ];
- int r;
-
- if (cnt-- < 1)
- return;
- switch (*data++) {
- case KRB_AUTH:
- if (krb_get_lrealm(realm, 1) != KSUCCESS) {
- Data(ap, KRB_REJECT, (void *)"No local V4 Realm.", -1);
- auth_finished(ap, AUTH_REJECT);
- if (auth_debug_mode)
- printf("No local realm\r\n");
- return;
- }
- memmove((void *)auth.dat, (void *)data, auth.length = cnt);
- if (auth_debug_mode) {
- printf("Got %d bytes of authentication data\r\n", cnt);
- printf("CK: %d:", kerberos4_cksum(auth.dat, auth.length));
- printd(auth.dat, auth.length);
- printf("\r\n");
- }
- instance[0] = '*'; instance[1] = 0;
- if ((r = krb_rd_req(&auth, KRB_SERVICE_NAME,
- instance, 0, &adat, ""))) {
- if (auth_debug_mode)
- printf("Kerberos failed him as %s\r\n", name);
- Data(ap, KRB_REJECT, (void *)krb_err_txt[r], -1);
- auth_finished(ap, AUTH_REJECT);
- return;
- }
-#ifdef ENCRYPTION
- memmove((void *)session_key, (void *)adat.session, sizeof(Block));
-#endif /* ENCRYPTION */
- krb_kntoln(&adat, name);
-
- if (UserNameRequested && !kuserok(&adat, UserNameRequested))
- Data(ap, KRB_ACCEPT, (void *)0, 0);
- else
- Data(ap, KRB_REJECT,
- (void *)"user is not authorized", -1);
- auth_finished(ap, AUTH_USER);
- break;
-
- case KRB_CHALLENGE:
-#ifndef ENCRYPTION
- Data(ap, KRB_RESPONSE, (void *)0, 0);
-#else /* ENCRYPTION */
- if (!VALIDKEY(session_key)) {
- /*
- * We don't have a valid session key, so just
- * send back a response with an empty session
- * key.
- */
- Data(ap, KRB_RESPONSE, (void *)0, 0);
- break;
- }
-
- /*
- * Initialize the random number generator since it's
- * used later on by the encryption routine.
- */
- des_init_random_number_generator(&session_key);
- des_key_sched(&session_key, sched);
- memmove((void *)datablock, (void *)data, sizeof(Block));
- /*
- * Take the received encrypted challenge, and encrypt
- * it again to get a unique session_key for the
- * ENCRYPT option.
- */
- des_ecb_encrypt(&datablock, &session_key, sched, 1);
- skey.type = SK_DES;
- skey.length = 8;
- skey.data = session_key;
- encrypt_session_key(&skey, 1);
- /*
- * Now decrypt the received encrypted challenge,
- * increment by one, re-encrypt it and send it back.
- */
- des_ecb_encrypt(&datablock, &challenge, sched, 0);
- for (r = 7; r >= 0; r--) {
- register int t;
- t = (unsigned int)challenge[r] + 1;
- challenge[r] = t; /* ignore overflow */
- if (t < 256) /* if no overflow, all done */
- break;
- }
- des_ecb_encrypt(&challenge, &challenge, sched, 1);
- Data(ap, KRB_RESPONSE, (void *)challenge, sizeof(challenge));
-#endif /* ENCRYPTION */
- break;
-
- default:
- if (auth_debug_mode)
- printf("Unknown Kerberos option %d\r\n", data[-1]);
- Data(ap, KRB_REJECT, 0, 0);
- break;
- }
-}
-
- void
-kerberos4_reply(ap, data, cnt)
- Authenticator *ap;
- unsigned char *data;
- int cnt;
-{
-#ifdef ENCRYPTION
- Session_Key skey;
-#endif /* ENCRYPTION */
-
- if (cnt-- < 1)
- return;
- switch (*data++) {
- case KRB_REJECT:
- if (cnt > 0) {
- printf("[ Kerberos V4 refuses authentication because %.*s ]\r\n",
- cnt, data);
- } else
- printf("[ Kerberos V4 refuses authentication ]\r\n");
- auth_send_retry();
- return;
- case KRB_ACCEPT:
- printf("[ Kerberos V4 accepts you ]\n");
- if ((ap->way & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL) {
- /*
- * Send over the encrypted challenge.
- */
-#ifndef ENCRYPTION
- Data(ap, KRB_CHALLENGE, (void *)0, 0);
-#else /* ENCRYPTION */
- Data(ap, KRB_CHALLENGE, (void *)session_key,
- sizeof(session_key));
- des_ecb_encrypt(&session_key, &session_key, sched, 1);
- skey.type = SK_DES;
- skey.length = 8;
- skey.data = session_key;
- encrypt_session_key(&skey, 0);
-#endif /* ENCRYPTION */
- return;
- }
- auth_finished(ap, AUTH_USER);
- return;
- case KRB_RESPONSE:
-#ifdef ENCRYPTION
- /*
- * Verify that the response to the challenge is correct.
- */
- if ((cnt != sizeof(Block)) ||
- (0 != memcmp((void *)data, (void *)challenge,
- sizeof(challenge))))
- {
-#endif /* ENCRYPTION */
- printf("[ Kerberos V4 challenge failed!!! ]\r\n");
- auth_send_retry();
- return;
-#ifdef ENCRYPTION
- }
- printf("[ Kerberos V4 challenge successful ]\r\n");
- auth_finished(ap, AUTH_USER);
-#endif /* ENCRYPTION */
- break;
- default:
- if (auth_debug_mode)
- printf("Unknown Kerberos option %d\r\n", data[-1]);
- return;
- }
-}
-
- int
-kerberos4_status(ap, name, level)
- Authenticator *ap;
- char *name;
- int level;
-{
- if (level < AUTH_USER)
- return(level);
-
- if (UserNameRequested && !kuserok(&adat, UserNameRequested)) {
- strcpy(name, UserNameRequested);
- return(AUTH_VALID);
- } else
- return(AUTH_USER);
-}
-
-#define BUMP(buf, len) while (*(buf)) {++(buf), --(len);}
-#define ADDC(buf, len, c) if ((len) > 0) {*(buf)++ = (c); --(len);}
-
- void
-kerberos4_printsub(data, cnt, buf, buflen)
- unsigned char *data, *buf;
- int cnt, buflen;
-{
- char lbuf[32];
- register int i;
-
- buf[buflen-1] = '\0'; /* make sure its NULL terminated */
- buflen -= 1;
-
- switch(data[3]) {
- case KRB_REJECT: /* Rejected (reason might follow) */
- strncpy((char *)buf, " REJECT ", buflen);
- goto common;
-
- case KRB_ACCEPT: /* Accepted (name might follow) */
- strncpy((char *)buf, " ACCEPT ", buflen);
- common:
- BUMP(buf, buflen);
- if (cnt <= 4)
- break;
- ADDC(buf, buflen, '"');
- for (i = 4; i < cnt; i++)
- ADDC(buf, buflen, data[i]);
- ADDC(buf, buflen, '"');
- ADDC(buf, buflen, '\0');
- break;
-
- case KRB_AUTH: /* Authentication data follows */
- strncpy((char *)buf, " AUTH", buflen);
- goto common2;
-
- case KRB_CHALLENGE:
- strncpy((char *)buf, " CHALLENGE", buflen);
- goto common2;
-
- case KRB_RESPONSE:
- strncpy((char *)buf, " RESPONSE", buflen);
- goto common2;
-
- default:
- sprintf(lbuf, " %d (unknown)", data[3]);
- strncpy((char *)buf, lbuf, buflen);
- common2:
- BUMP(buf, buflen);
- for (i = 4; i < cnt; i++) {
- sprintf(lbuf, " %d", data[i]);
- strncpy((char *)buf, lbuf, buflen);
- BUMP(buf, buflen);
- }
- break;
- }
-}
-
- int
-kerberos4_cksum(d, n)
- unsigned char *d;
- int n;
-{
- int ck = 0;
-
- /*
- * A comment is probably needed here for those not
- * well versed in the "C" language. Yes, this is
- * supposed to be a "switch" with the body of the
- * "switch" being a "while" statement. The whole
- * purpose of the switch is to allow us to jump into
- * the middle of the while() loop, and then not have
- * to do any more switch()s.
- *
- * Some compilers will spit out a warning message
- * about the loop not being entered at the top.
- */
- switch (n&03)
- while (n > 0) {
- case 0:
- ck ^= (int)*d++ << 24;
- --n;
- case 3:
- ck ^= (int)*d++ << 16;
- --n;
- case 2:
- ck ^= (int)*d++ << 8;
- --n;
- case 1:
- ck ^= (int)*d++;
- --n;
- }
- return(ck);
-}
-#endif
-
-#ifdef notdef
-
-prkey(msg, key)
- char *msg;
- unsigned char *key;
-{
- register int i;
- printf("%s:", msg);
- for (i = 0; i < 8; i++)
- printf(" %3d", key[i]);
- printf("\r\n");
-}
-#endif
diff --git a/contrib/telnet/libtelnet/kerberos5.c b/contrib/telnet/libtelnet/kerberos5.c
deleted file mode 100644
index bcf1a9f0c348..000000000000
--- a/contrib/telnet/libtelnet/kerberos5.c
+++ /dev/null
@@ -1,764 +0,0 @@
-/*
- * $Source: /mit/krb5/.cvsroot/src/appl/telnet/libtelnet/kerberos5.c,v $
- * $Author: tytso $
- * $Id: kerberos5.c,v 1.1 1997/09/04 06:11:15 markm Exp $
- */
-
-#if !defined(lint) && !defined(SABER)
-static
-#ifdef __STDC__
-const
-#endif
-char rcsid_kerberos5_c[] = "$Id: kerberos5.c,v 1.1 1997/09/04 06:11:15 markm Exp $";
-#endif /* lint */
-
-/*-
- * Copyright (c) 1991, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-static char sccsid[] = "@(#)kerberos5.c 8.3 (Berkeley) 5/30/95";
-#endif /* not lint */
-
-/*
- * Copyright (C) 1990 by the Massachusetts Institute of Technology
- *
- * Export of this software from the United States of America may
- * require a specific license from the United States Government.
- * It is the responsibility of any person or organization contemplating
- * export to obtain such a license before exporting.
- *
- * WITHIN THAT CONSTRAINT, 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 appear in all copies and that both that copyright notice and
- * this permission notice appear in supporting documentation, and that
- * the name of M.I.T. not be used in advertising or publicity pertaining
- * to distribution of the software without specific, written prior
- * permission. M.I.T. makes no representations about the suitability of
- * this software for any purpose. It is provided "as is" without express
- * or implied warranty.
- */
-
-
-#ifdef KRB5
-#include <arpa/telnet.h>
-#include <stdio.h>
-#include <krb5/krb5.h>
-#include <krb5/asn1.h>
-#include <krb5/crc-32.h>
-#include <krb5/los-proto.h>
-#include <krb5/ext-proto.h>
-#include <com_err.h>
-#include <netdb.h>
-#include <ctype.h>
-
-/* kerberos 5 include files (ext-proto.h) will get an appropriate stdlib.h
- and string.h/strings.h */
-
-#include "encrypt.h"
-#include "auth.h"
-#include "misc.h"
-
-extern auth_debug_mode;
-
-#ifdef FORWARD
-int forward_flags = 0; /* Flags get set in telnet/main.c on -f and -F */
-
-/* These values need to be the same as those defined in telnet/main.c. */
-/* Either define them in both places, or put in some common header file. */
-#define OPTS_FORWARD_CREDS 0x00000002
-#define OPTS_FORWARDABLE_CREDS 0x00000001
-
-void kerberos5_forward();
-
-#endif /* FORWARD */
-
-static unsigned char str_data[1024] = { IAC, SB, TELOPT_AUTHENTICATION, 0,
- AUTHTYPE_KERBEROS_V5, };
-/*static unsigned char str_name[1024] = { IAC, SB, TELOPT_AUTHENTICATION,
- TELQUAL_NAME, };*/
-
-#define KRB_AUTH 0 /* Authentication data follows */
-#define KRB_REJECT 1 /* Rejected (reason might follow) */
-#define KRB_ACCEPT 2 /* Accepted */
-#define KRB_RESPONSE 3 /* Response for mutual auth. */
-
-#ifdef FORWARD
-#define KRB_FORWARD 4 /* Forwarded credentials follow */
-#define KRB_FORWARD_ACCEPT 5 /* Forwarded credentials accepted */
-#define KRB_FORWARD_REJECT 6 /* Forwarded credentials rejected */
-#endif /* FORWARD */
-
-static krb5_data auth;
- /* telnetd gets session key from here */
-static krb5_tkt_authent *authdat = NULL;
-/* telnet matches the AP_REQ and AP_REP with this */
-static krb5_authenticator authenticator;
-
-/* some compilers can't hack void *, so we use the Kerberos krb5_pointer,
- which is either void * or char *, depending on the compiler. */
-
-#define Voidptr krb5_pointer
-
-Block session_key;
-
- static int
-Data(ap, type, d, c)
- Authenticator *ap;
- int type;
- Voidptr d;
- int c;
-{
- unsigned char *p = str_data + 4;
- unsigned char *cd = (unsigned char *)d;
-
- if (c == -1)
- c = strlen((char *)cd);
-
- if (auth_debug_mode) {
- printf("%s:%d: [%d] (%d)",
- str_data[3] == TELQUAL_IS ? ">>>IS" : ">>>REPLY",
- str_data[3],
- type, c);
- printd(d, c);
- printf("\r\n");
- }
- *p++ = ap->type;
- *p++ = ap->way;
- *p++ = type;
- while (c-- > 0) {
- if ((*p++ = *cd++) == IAC)
- *p++ = IAC;
- }
- *p++ = IAC;
- *p++ = SE;
- if (str_data[3] == TELQUAL_IS)
- printsub('>', &str_data[2], p - &str_data[2]);
- return(net_write(str_data, p - str_data));
-}
-
- int
-kerberos5_init(ap, server)
- Authenticator *ap;
- int server;
-{
- if (server)
- str_data[3] = TELQUAL_REPLY;
- else
- str_data[3] = TELQUAL_IS;
- krb5_init_ets();
- return(1);
-}
-
- int
-kerberos5_send(ap)
- Authenticator *ap;
-{
- char **realms;
- char *name;
- char *p1, *p2;
- krb5_checksum ksum;
- krb5_octet sum[CRC32_CKSUM_LENGTH];
- krb5_principal server;
- krb5_error_code r;
- krb5_ccache ccache;
- krb5_creds creds; /* telnet gets session key from here */
- extern krb5_flags krb5_kdc_default_options;
- int ap_opts;
-
-#ifdef ENCRYPTION
- krb5_keyblock *newkey = 0;
-#endif /* ENCRYPTION */
-
- ksum.checksum_type = CKSUMTYPE_CRC32;
- ksum.contents = sum;
- ksum.length = sizeof(sum);
- memset((Voidptr )sum, 0, sizeof(sum));
-
- if (!UserNameRequested) {
- if (auth_debug_mode) {
- printf("Kerberos V5: no user name supplied\r\n");
- }
- return(0);
- }
-
- if (r = krb5_cc_default(&ccache)) {
- if (auth_debug_mode) {
- printf("Kerberos V5: could not get default ccache\r\n");
- }
- return(0);
- }
-
- if ((name = malloc(strlen(RemoteHostName)+1)) == NULL) {
- if (auth_debug_mode)
- printf("Out of memory for hostname in Kerberos V5\r\n");
- return(0);
- }
-
- if (r = krb5_get_host_realm(RemoteHostName, &realms)) {
- if (auth_debug_mode)
- printf("Kerberos V5: no realm for %s\r\n", RemoteHostName);
- free(name);
- return(0);
- }
-
- p1 = RemoteHostName;
- p2 = name;
-
- while (*p2 = *p1++) {
- if (isupper(*p2))
- *p2 |= 040;
- ++p2;
- }
-
- if (r = krb5_build_principal_ext(&server,
- strlen(realms[0]), realms[0],
- 4, "host",
- p2 - name, name,
- 0)) {
- if (auth_debug_mode) {
- printf("Kerberos V5: failure setting up principal (%s)\r\n",
- error_message(r));
- }
- free(name);
- krb5_free_host_realm(realms);
- return(0);
- }
-
-
- memset((char *)&creds, 0, sizeof(creds));
- creds.server = server;
-
- if (r = krb5_cc_get_principal(ccache, &creds.client)) {
- if (auth_debug_mode) {
- printf("Kerberos V5: failure on principal (%s)\r\n",
- error_message(r));
- }
- free(name);
- krb5_free_principal(server);
- krb5_free_host_realm(realms);
- return(0);
- }
-
- if (r = krb5_get_credentials(krb5_kdc_default_options, ccache, &creds)) {
- if (auth_debug_mode) {
- printf("Kerberos V5: failure on credentials(%d)\r\n",r);
- }
- free(name);
- krb5_free_host_realm(realms);
- krb5_free_principal(server);
- return(0);
- }
-
- if ((ap->way & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL)
- ap_opts = AP_OPTS_MUTUAL_REQUIRED;
- else
- ap_opts = 0;
-
- r = krb5_mk_req_extended(ap_opts, &ksum, krb5_kdc_default_options, 0,
-#ifdef ENCRYPTION
- &newkey,
-#else /* ENCRYPTION */
- 0,
-#endif /* ENCRYPTION */
- ccache, &creds, &authenticator, &auth);
- /* don't let the key get freed if we clean up the authenticator */
- authenticator.subkey = 0;
-
- free(name);
- krb5_free_host_realm(realms);
- krb5_free_principal(server);
-#ifdef ENCRYPTION
- if (newkey) {
- /* keep the key in our private storage, but don't use it
- yet---see kerberos5_reply() below */
- if (newkey->keytype != KEYTYPE_DES) {
- if (creds.keyblock.keytype == KEYTYPE_DES)
- /* use the session key in credentials instead */
- memmove((char *)session_key,
- (char *)creds.keyblock.contents, sizeof(Block));
- else
- /* XXX ? */;
- } else {
- memmove((char *)session_key, (char *)newkey->contents,
- sizeof(Block));
- }
- krb5_free_keyblock(newkey);
- }
-#endif /* ENCRYPTION */
- if (r) {
- if (auth_debug_mode) {
- printf("Kerberos V5: mk_req failed (%s)\r\n",
- error_message(r));
- }
- return(0);
- }
-
- if (!auth_sendname(UserNameRequested, strlen(UserNameRequested))) {
- if (auth_debug_mode)
- printf("Not enough room for user name\r\n");
- return(0);
- }
- if (!Data(ap, KRB_AUTH, auth.data, auth.length)) {
- if (auth_debug_mode)
- printf("Not enough room for authentication data\r\n");
- return(0);
- }
- if (auth_debug_mode) {
- printf("Sent Kerberos V5 credentials to server\r\n");
- }
- return(1);
-}
-
- void
-kerberos5_is(ap, data, cnt)
- Authenticator *ap;
- unsigned char *data;
- int cnt;
-{
- int r;
- struct hostent *hp;
- char *p1, *p2;
- static char *realm = NULL;
- krb5_principal server;
- krb5_ap_rep_enc_part reply;
- krb5_data outbuf;
-#ifdef ENCRYPTION
- Session_Key skey;
-#endif /* ENCRYPTION */
- char *name;
- char *getenv();
- krb5_data inbuf;
-
- if (cnt-- < 1)
- return;
- switch (*data++) {
- case KRB_AUTH:
- auth.data = (char *)data;
- auth.length = cnt;
-
- if (!(hp = gethostbyname(LocalHostName))) {
- if (auth_debug_mode)
- printf("Cannot resolve local host name\r\n");
- Data(ap, KRB_REJECT, "Unknown local hostname.", -1);
- auth_finished(ap, AUTH_REJECT);
- return;
- }
-
- if (!realm && (krb5_get_default_realm(&realm))) {
- if (auth_debug_mode)
- printf("Could not get default realm\r\n");
- Data(ap, KRB_REJECT, "Could not get default realm.", -1);
- auth_finished(ap, AUTH_REJECT);
- return;
- }
-
- if ((name = malloc(strlen(hp->h_name)+1)) == NULL) {
- if (auth_debug_mode)
- printf("Out of memory for hostname in Kerberos V5\r\n");
- Data(ap, KRB_REJECT, "Out of memory.", -1);
- auth_finished(ap, AUTH_REJECT);
- return;
- }
-
- p1 = hp->h_name;
- p2 = name;
-
- while (*p2 = *p1++) {
- if (isupper(*p2))
- *p2 |= 040;
- ++p2;
- }
-
- if (authdat)
- krb5_free_tkt_authent(authdat);
-
- r = krb5_build_principal_ext(&server,
- strlen(realm), realm,
- 4, "host",
- p2 - name, name,
- 0);
- if (!r) {
- r = krb5_rd_req_simple(&auth, server, 0, &authdat);
- krb5_free_principal(server);
- }
- if (r) {
- char errbuf[128];
-
- errout:
- authdat = 0;
- (void) strcpy(errbuf, "Read req failed: ");
- (void) strcat(errbuf, error_message(r));
- Data(ap, KRB_REJECT, errbuf, -1);
- if (auth_debug_mode)
- printf("%s\r\n", errbuf);
- return;
- }
- free(name);
- if ((ap->way & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL) {
- /* do ap_rep stuff here */
- reply.ctime = authdat->authenticator->ctime;
- reply.cusec = authdat->authenticator->cusec;
- reply.subkey = 0; /* use the one he gave us, so don't
- need to return one here */
- reply.seq_number = 0; /* we don't do seq #'s. */
-
- if (r = krb5_mk_rep(&reply,
- authdat->authenticator->subkey ?
- authdat->authenticator->subkey :
- authdat->ticket->enc_part2->session,
- &outbuf)) {
- goto errout;
- }
- Data(ap, KRB_RESPONSE, outbuf.data, outbuf.length);
- }
- if (krb5_unparse_name(authdat->ticket->enc_part2 ->client,
- &name))
- name = 0;
- Data(ap, KRB_ACCEPT, name, name ? -1 : 0);
- if (auth_debug_mode) {
- printf("Kerberos5 identifies him as ``%s''\r\n",
- name ? name : "");
- }
- auth_finished(ap, AUTH_USER);
-
- free(name);
- if (authdat->authenticator->subkey &&
- authdat->authenticator->subkey->keytype == KEYTYPE_DES) {
- memmove((Voidptr )session_key,
- (Voidptr )authdat->authenticator->subkey->contents,
- sizeof(Block));
- } else if (authdat->ticket->enc_part2->session->keytype ==
- KEYTYPE_DES) {
- memmove((Voidptr )session_key,
- (Voidptr )authdat->ticket->enc_part2->session->contents,
- sizeof(Block));
- } else
- break;
-
-#ifdef ENCRYPTION
- skey.type = SK_DES;
- skey.length = 8;
- skey.data = session_key;
- encrypt_session_key(&skey, 1);
-#endif /* ENCRYPTION */
- break;
-#ifdef FORWARD
- case KRB_FORWARD:
- inbuf.data = (char *)data;
- inbuf.length = cnt;
- if (r = rd_and_store_for_creds(&inbuf, authdat->ticket,
- UserNameRequested)) {
- char errbuf[128];
-
- (void) strcpy(errbuf, "Read forwarded creds failed: ");
- (void) strcat(errbuf, error_message(r));
- Data(ap, KRB_FORWARD_REJECT, errbuf, -1);
- if (auth_debug_mode)
- printf("Could not read forwarded credentials\r\n");
- }
- else
- Data(ap, KRB_FORWARD_ACCEPT, 0, 0);
- if (auth_debug_mode)
- printf("Forwarded credentials obtained\r\n");
- break;
-#endif /* FORWARD */
- default:
- if (auth_debug_mode)
- printf("Unknown Kerberos option %d\r\n", data[-1]);
- Data(ap, KRB_REJECT, 0, 0);
- break;
- }
-}
-
- void
-kerberos5_reply(ap, data, cnt)
- Authenticator *ap;
- unsigned char *data;
- int cnt;
-{
- Session_Key skey;
- static int mutual_complete = 0;
-
- if (cnt-- < 1)
- return;
- switch (*data++) {
- case KRB_REJECT:
- if (cnt > 0) {
- printf("[ Kerberos V5 refuses authentication because %.*s ]\r\n",
- cnt, data);
- } else
- printf("[ Kerberos V5 refuses authentication ]\r\n");
- auth_send_retry();
- return;
- case KRB_ACCEPT:
- if ((ap->way & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL &&
- !mutual_complete) {
- printf("[ Kerberos V5 accepted you, but didn't provide mutual authentication! ]\n");
- auth_send_retry();
- return;
- }
- if (cnt)
- printf("[ Kerberos V5 accepts you as ``%.*s'' ]\n", cnt, data);
- else
- printf("[ Kerberos V5 accepts you ]\n");
- auth_finished(ap, AUTH_USER);
-#ifdef FORWARD
- if (forward_flags & OPTS_FORWARD_CREDS)
- kerberos5_forward(ap);
-#endif /* FORWARD */
- break;
- case KRB_RESPONSE:
- if ((ap->way & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL) {
- /* the rest of the reply should contain a krb_ap_rep */
- krb5_ap_rep_enc_part *reply;
- krb5_data inbuf;
- krb5_error_code r;
- krb5_keyblock tmpkey;
-
- inbuf.length = cnt;
- inbuf.data = (char *)data;
-
- tmpkey.keytype = KEYTYPE_DES;
- tmpkey.contents = session_key;
- tmpkey.length = sizeof(Block);
-
- if (r = krb5_rd_rep(&inbuf, &tmpkey, &reply)) {
- printf("[ Mutual authentication failed: %s ]\n",
- error_message(r));
- auth_send_retry();
- return;
- }
- if (reply->ctime != authenticator.ctime ||
- reply->cusec != authenticator.cusec) {
- printf("[ Mutual authentication failed (mismatched KRB_AP_REP) ]\n");
- auth_send_retry();
- return;
- }
- krb5_free_ap_rep_enc_part(reply);
-#ifdef ENCRYPTION
- skey.type = SK_DES;
- skey.length = 8;
- skey.data = session_key;
- encrypt_session_key(&skey, 0);
-#endif /* ENCRYPTION */
- mutual_complete = 1;
- }
- return;
-#ifdef FORWARD
- case KRB_FORWARD_ACCEPT:
- printf("[ Kerberos V5 accepted forwarded credentials ]\n");
- return;
- case KRB_FORWARD_REJECT:
- printf("[ Kerberos V5 refuses forwarded credentials because %.*s ]\r\n",
- cnt, data);
- return;
-#endif /* FORWARD */
- default:
- if (auth_debug_mode)
- printf("Unknown Kerberos option %d\r\n", data[-1]);
- return;
- }
-}
-
- int
-kerberos5_status(ap, name, level)
- Authenticator *ap;
- char *name;
- int level;
-{
- if (level < AUTH_USER)
- return(level);
-
- if (UserNameRequested &&
- krb5_kuserok(authdat->ticket->enc_part2->client, UserNameRequested))
- {
- strcpy(name, UserNameRequested);
- return(AUTH_VALID);
- } else
- return(AUTH_USER);
-}
-
-#define BUMP(buf, len) while (*(buf)) {++(buf), --(len);}
-#define ADDC(buf, len, c) if ((len) > 0) {*(buf)++ = (c); --(len);}
-
- void
-kerberos5_printsub(data, cnt, buf, buflen)
- unsigned char *data, *buf;
- int cnt, buflen;
-{
- char lbuf[32];
- register int i;
-
- buf[buflen-1] = '\0'; /* make sure its NULL terminated */
- buflen -= 1;
-
- switch(data[3]) {
- case KRB_REJECT: /* Rejected (reason might follow) */
- strncpy((char *)buf, " REJECT ", buflen);
- goto common;
-
- case KRB_ACCEPT: /* Accepted (name might follow) */
- strncpy((char *)buf, " ACCEPT ", buflen);
- common:
- BUMP(buf, buflen);
- if (cnt <= 4)
- break;
- ADDC(buf, buflen, '"');
- for (i = 4; i < cnt; i++)
- ADDC(buf, buflen, data[i]);
- ADDC(buf, buflen, '"');
- ADDC(buf, buflen, '\0');
- break;
-
-
- case KRB_AUTH: /* Authentication data follows */
- strncpy((char *)buf, " AUTH", buflen);
- goto common2;
-
- case KRB_RESPONSE:
- strncpy((char *)buf, " RESPONSE", buflen);
- goto common2;
-
-#ifdef FORWARD
- case KRB_FORWARD: /* Forwarded credentials follow */
- strncpy((char *)buf, " FORWARD", buflen);
- goto common2;
-
- case KRB_FORWARD_ACCEPT: /* Forwarded credentials accepted */
- strncpy((char *)buf, " FORWARD_ACCEPT", buflen);
- goto common2;
-
- case KRB_FORWARD_REJECT: /* Forwarded credentials rejected */
- /* (reason might follow) */
- strncpy((char *)buf, " FORWARD_REJECT", buflen);
- goto common2;
-#endif /* FORWARD */
-
- default:
- sprintf(lbuf, " %d (unknown)", data[3]);
- strncpy((char *)buf, lbuf, buflen);
- common2:
- BUMP(buf, buflen);
- for (i = 4; i < cnt; i++) {
- sprintf(lbuf, " %d", data[i]);
- strncpy((char *)buf, lbuf, buflen);
- BUMP(buf, buflen);
- }
- break;
- }
-}
-
-#ifdef FORWARD
- void
-kerberos5_forward(ap)
- Authenticator *ap;
-{
- struct hostent *hp;
- krb5_creds *local_creds;
- krb5_error_code r;
- krb5_data forw_creds;
- extern krb5_cksumtype krb5_kdc_req_sumtype;
- krb5_ccache ccache;
- int i;
-
- if (!(local_creds = (krb5_creds *)
- calloc(1, sizeof(*local_creds)))) {
- if (auth_debug_mode)
- printf("Kerberos V5: could not allocate memory for credentials\r\n");
- return;
- }
-
- if (r = krb5_sname_to_principal(RemoteHostName, "host", 1,
- &local_creds->server)) {
- if (auth_debug_mode)
- printf("Kerberos V5: could not build server name - %s\r\n",
- error_message(r));
- krb5_free_creds(local_creds);
- return;
- }
-
- if (r = krb5_cc_default(&ccache)) {
- if (auth_debug_mode)
- printf("Kerberos V5: could not get default ccache - %s\r\n",
- error_message(r));
- krb5_free_creds(local_creds);
- return;
- }
-
- if (r = krb5_cc_get_principal(ccache, &local_creds->client)) {
- if (auth_debug_mode)
- printf("Kerberos V5: could not get default principal - %s\r\n",
- error_message(r));
- krb5_free_creds(local_creds);
- return;
- }
-
- /* Get ticket from credentials cache */
- if (r = krb5_get_credentials(KRB5_GC_CACHED, ccache, local_creds)) {
- if (auth_debug_mode)
- printf("Kerberos V5: could not obtain credentials - %s\r\n",
- error_message(r));
- krb5_free_creds(local_creds);
- return;
- }
-
- if (r = get_for_creds(ETYPE_DES_CBC_CRC,
- krb5_kdc_req_sumtype,
- RemoteHostName,
- local_creds->client,
- &local_creds->keyblock,
- forward_flags & OPTS_FORWARDABLE_CREDS,
- &forw_creds)) {
- if (auth_debug_mode)
- printf("Kerberos V5: error getting forwarded creds - %s\r\n",
- error_message(r));
- krb5_free_creds(local_creds);
- return;
- }
-
- /* Send forwarded credentials */
- if (!Data(ap, KRB_FORWARD, forw_creds.data, forw_creds.length)) {
- if (auth_debug_mode)
- printf("Not enough room for authentication data\r\n");
- }
- else {
- if (auth_debug_mode)
- printf("Forwarded local Kerberos V5 credentials to server\r\n");
- }
-
- krb5_free_creds(local_creds);
-}
-#endif /* FORWARD */
-
-#endif /* KRB5 */
diff --git a/contrib/telnet/libtelnet/key-proto.h b/contrib/telnet/libtelnet/key-proto.h
deleted file mode 100644
index 9668a775be50..000000000000
--- a/contrib/telnet/libtelnet/key-proto.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*-
- * Copyright (c) 1991, 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)key-proto.h 8.1 (Berkeley) 6/4/93
- */
-
-/*
- * Copyright (C) 1990 by the Massachusetts Institute of Technology
- *
- * Export of this software from the United States of America is assumed
- * to require a specific license from the United States Government.
- * It is the responsibility of any person or organization contemplating
- * export to obtain such a license before exporting.
- *
- * WITHIN THAT CONSTRAINT, 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 appear in all copies and that both that copyright notice and
- * this permission notice appear in supporting documentation, and that
- * the name of M.I.T. not be used in advertising or publicity pertaining
- * to distribution of the software without specific, written prior
- * permission. M.I.T. makes no representations about the suitability of
- * this software for any purpose. It is provided "as is" without express
- * or implied warranty.
- */
-
-#ifndef __KEY_PROTO__
-#define __KEY_PROTO__
-
-#if !defined(P)
-#ifdef __STDC__
-#define P(x) x
-#else
-#define P(x) ()
-#endif
-#endif
-
-int key_file_exists P((void));
-void key_lookup P((unsigned char *, Block));
-void key_stream_init P((Block, Block, int));
-unsigned char key_stream P((int, int));
-#endif
diff --git a/contrib/telnet/libtelnet/krb4encpwd.c b/contrib/telnet/libtelnet/krb4encpwd.c
deleted file mode 100644
index 3184a529ce0d..000000000000
--- a/contrib/telnet/libtelnet/krb4encpwd.c
+++ /dev/null
@@ -1,447 +0,0 @@
-/*-
- * 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- */
-
-#ifndef lint
-static char sccsid[] = "@(#)krb4encpwd.c 8.3 (Berkeley) 5/30/95";
-#endif /* not lint */
-
-
-#ifdef KRB4_ENCPWD
-/*
- * COPYRIGHT (C) 1990 DIGITAL EQUIPMENT CORPORATION
- * ALL RIGHTS RESERVED
- *
- * "Digital Equipment Corporation authorizes the reproduction,
- * distribution and modification of this software subject to the following
- * restrictions:
- *
- * 1. Any partial or whole copy of this software, or any modification
- * thereof, must include this copyright notice in its entirety.
- *
- * 2. This software is supplied "as is" with no warranty of any kind,
- * expressed or implied, for any purpose, including any warranty of fitness
- * or merchantibility. DIGITAL assumes no responsibility for the use or
- * reliability of this software, nor promises to provide any form of
- * support for it on any basis.
- *
- * 3. Distribution of this software is authorized only if no profit or
- * remuneration of any kind is received in exchange for such distribution.
- *
- * 4. This software produces public key authentication certificates
- * bearing an expiration date established by DIGITAL and RSA Data
- * Security, Inc. It may cease to generate certificates after the expiration
- * date. Any modification of this software that changes or defeats
- * the expiration date or its effect is unauthorized.
- *
- * 5. Software that will renew or extend the expiration date of
- * authentication certificates produced by this software may be obtained
- * from RSA Data Security, Inc., 10 Twin Dolphin Drive, Redwood City, CA
- * 94065, (415)595-8782, or from DIGITAL"
- *
- */
-
-#include <sys/types.h>
-#include <arpa/telnet.h>
-#include <pwd.h>
-#include <stdio.h>
-
-#include <openssl/des.h>
-#include <krb.h>
-#ifdef __STDC__
-#include <stdlib.h>
-#endif
-#ifdef NO_STRING_H
-#include <strings.h>
-#else
-#include <string.h>
-#endif
-
-#include "encrypt.h"
-#include "auth.h"
-#include "misc.h"
-
-int krb_mk_encpwd_req P((KTEXT, char *, char *, char *, char *, char *, char *));
-int krb_rd_encpwd_req P((KTEXT, char *, char *, u_long, AUTH_DAT *, char *, char *, char *, char *));
-
-extern auth_debug_mode;
-
-static unsigned char str_data[1024] = { IAC, SB, TELOPT_AUTHENTICATION, 0,
- AUTHTYPE_KRB4_ENCPWD, };
-static unsigned char str_name[1024] = { IAC, SB, TELOPT_AUTHENTICATION,
- TELQUAL_NAME, };
-
-#define KRB4_ENCPWD_AUTH 0 /* Authentication data follows */
-#define KRB4_ENCPWD_REJECT 1 /* Rejected (reason might follow) */
-#define KRB4_ENCPWD_ACCEPT 2 /* Accepted */
-#define KRB4_ENCPWD_CHALLENGE 3 /* Challenge for mutual auth. */
-#define KRB4_ENCPWD_ACK 4 /* Acknowledge */
-
-#define KRB_SERVICE_NAME "rcmd"
-
-static KTEXT_ST auth;
-static char name[ANAME_SZ];
-static char user_passwd[ANAME_SZ];
-static AUTH_DAT adat = { 0 };
-#ifdef ENCRYPTION
-static Block session_key = { 0 };
-#endif /* ENCRYPTION */
-static char challenge[REALM_SZ];
-
- static int
-Data(ap, type, d, c)
- Authenticator *ap;
- int type;
- void *d;
- int c;
-{
- unsigned char *p = str_data + 4;
- unsigned char *cd = (unsigned char *)d;
-
- if (c == -1)
- c = strlen((char *)cd);
-
- if (0) {
- printf("%s:%d: [%d] (%d)",
- str_data[3] == TELQUAL_IS ? ">>>IS" : ">>>REPLY",
- str_data[3],
- type, c);
- printd(d, c);
- printf("\r\n");
- }
- *p++ = ap->type;
- *p++ = ap->way;
- *p++ = type;
- while (c-- > 0) {
- if ((*p++ = *cd++) == IAC)
- *p++ = IAC;
- }
- *p++ = IAC;
- *p++ = SE;
- if (str_data[3] == TELQUAL_IS)
- printsub('>', &str_data[2], p - (&str_data[2]));
- return(net_write(str_data, p - str_data));
-}
-
- int
-krb4encpwd_init(ap, server)
- Authenticator *ap;
- int server;
-{
- char hostname[80], *cp, *realm;
- C_Block skey;
-
- if (server) {
- str_data[3] = TELQUAL_REPLY;
- } else {
- str_data[3] = TELQUAL_IS;
- gethostname(hostname, sizeof(hostname));
- realm = krb_realmofhost(hostname);
- cp = strchr(hostname, '.');
- if (*cp != NULL) *cp = NULL;
- if (read_service_key(KRB_SERVICE_NAME, hostname, realm, 0,
- KEYFILE, (char *)skey)) {
- return(0);
- }
- }
- return(1);
-}
-
- int
-krb4encpwd_send(ap)
- Authenticator *ap;
-{
-
- printf("[ Trying KRB4ENCPWD ... ]\n");
- if (!UserNameRequested) {
- return(0);
- }
- if (!auth_sendname(UserNameRequested, strlen(UserNameRequested))) {
- return(0);
- }
-
- if (!Data(ap, KRB4_ENCPWD_ACK, (void *)NULL, 0)) {
- return(0);
- }
-
- return(1);
-}
-
- void
-krb4encpwd_is(ap, data, cnt)
- Authenticator *ap;
- unsigned char *data;
- int cnt;
-{
- Session_Key skey;
- Block datablock;
- char r_passwd[ANAME_SZ], r_user[ANAME_SZ];
- char lhostname[ANAME_SZ], *cp;
- int r;
- time_t now;
-
- if (cnt-- < 1)
- return;
- switch (*data++) {
- case KRB4_ENCPWD_AUTH:
- memmove((void *)auth.dat, (void *)data, auth.length = cnt);
-
- gethostname(lhostname, sizeof(lhostname));
- if ((cp = strchr(lhostname, '.')) != 0) *cp = '\0';
-
- if (r = krb_rd_encpwd_req(&auth, KRB_SERVICE_NAME, lhostname, 0, &adat, NULL, challenge, r_user, r_passwd)) {
- Data(ap, KRB4_ENCPWD_REJECT, (void *)"Auth failed", -1);
- auth_finished(ap, AUTH_REJECT);
- return;
- }
- auth_encrypt_userpwd(r_passwd);
- if (passwdok(UserNameRequested, UserPassword) == 0) {
- /*
- * illegal username and password
- */
- Data(ap, KRB4_ENCPWD_REJECT, (void *)"Illegal password", -1);
- auth_finished(ap, AUTH_REJECT);
- return;
- }
-
- memmove((void *)session_key, (void *)adat.session, sizeof(Block));
- Data(ap, KRB4_ENCPWD_ACCEPT, (void *)0, 0);
- auth_finished(ap, AUTH_USER);
- break;
-
- case KRB4_ENCPWD_CHALLENGE:
- /*
- * Take the received random challenge text and save
- * for future authentication.
- */
- memmove((void *)challenge, (void *)data, sizeof(Block));
- break;
-
-
- case KRB4_ENCPWD_ACK:
- /*
- * Receive ack, if mutual then send random challenge
- */
-
- /*
- * If we are doing mutual authentication, get set up to send
- * the challenge, and verify it when the response comes back.
- */
-
- if ((ap->way & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL) {
- register int i;
-
- time(&now);
- sprintf(challenge, "%x", now);
- Data(ap, KRB4_ENCPWD_CHALLENGE, (void *)challenge, strlen(challenge));
- }
- break;
-
- default:
- Data(ap, KRB4_ENCPWD_REJECT, 0, 0);
- break;
- }
-}
-
-
- void
-krb4encpwd_reply(ap, data, cnt)
- Authenticator *ap;
- unsigned char *data;
- int cnt;
-{
- Session_Key skey;
- KTEXT_ST krb_token;
- Block enckey;
- CREDENTIALS cred;
- int r;
- char randchal[REALM_SZ], instance[ANAME_SZ], *cp;
- char hostname[80], *realm;
-
- if (cnt-- < 1)
- return;
- switch (*data++) {
- case KRB4_ENCPWD_REJECT:
- if (cnt > 0) {
- printf("[ KRB4_ENCPWD refuses authentication because %.*s ]\r\n",
- cnt, data);
- } else
- printf("[ KRB4_ENCPWD refuses authentication ]\r\n");
- auth_send_retry();
- return;
- case KRB4_ENCPWD_ACCEPT:
- printf("[ KRB4_ENCPWD accepts you ]\n");
- auth_finished(ap, AUTH_USER);
- return;
- case KRB4_ENCPWD_CHALLENGE:
- /*
- * Verify that the response to the challenge is correct.
- */
-
- gethostname(hostname, sizeof(hostname));
- realm = krb_realmofhost(hostname);
- memmove((void *)challenge, (void *)data, cnt);
- memset(user_passwd, 0, sizeof(user_passwd));
- local_des_read_pw_string(user_passwd, sizeof(user_passwd)-1, "Password: ", 0);
- UserPassword = user_passwd;
- Challenge = challenge;
- strcpy(instance, RemoteHostName);
- if ((cp = strchr(instance, '.')) != 0) *cp = '\0';
-
- if (r = krb_mk_encpwd_req(&krb_token, KRB_SERVICE_NAME, instance, realm, Challenge, UserNameRequested, user_passwd)) {
- krb_token.length = 0;
- }
-
- if (!Data(ap, KRB4_ENCPWD_AUTH, (void *)krb_token.dat, krb_token.length)) {
- return;
- }
-
- break;
-
- default:
- return;
- }
-}
-
- int
-krb4encpwd_status(ap, name, level)
- Authenticator *ap;
- char *name;
- int level;
-{
-
- if (level < AUTH_USER)
- return(level);
-
- if (UserNameRequested && passwdok(UserNameRequested, UserPassword)) {
- strcpy(name, UserNameRequested);
- return(AUTH_VALID);
- } else {
- return(AUTH_USER);
- }
-}
-
-#define BUMP(buf, len) while (*(buf)) {++(buf), --(len);}
-#define ADDC(buf, len, c) if ((len) > 0) {*(buf)++ = (c); --(len);}
-
- void
-krb4encpwd_printsub(data, cnt, buf, buflen)
- unsigned char *data, *buf;
- int cnt, buflen;
-{
- char lbuf[32];
- register int i;
-
- buf[buflen-1] = '\0'; /* make sure its NULL terminated */
- buflen -= 1;
-
- switch(data[3]) {
- case KRB4_ENCPWD_REJECT: /* Rejected (reason might follow) */
- strncpy((char *)buf, " REJECT ", buflen);
- goto common;
-
- case KRB4_ENCPWD_ACCEPT: /* Accepted (name might follow) */
- strncpy((char *)buf, " ACCEPT ", buflen);
- common:
- BUMP(buf, buflen);
- if (cnt <= 4)
- break;
- ADDC(buf, buflen, '"');
- for (i = 4; i < cnt; i++)
- ADDC(buf, buflen, data[i]);
- ADDC(buf, buflen, '"');
- ADDC(buf, buflen, '\0');
- break;
-
- case KRB4_ENCPWD_AUTH: /* Authentication data follows */
- strncpy((char *)buf, " AUTH", buflen);
- goto common2;
-
- case KRB4_ENCPWD_CHALLENGE:
- strncpy((char *)buf, " CHALLENGE", buflen);
- goto common2;
-
- case KRB4_ENCPWD_ACK:
- strncpy((char *)buf, " ACK", buflen);
- goto common2;
-
- default:
- sprintf(lbuf, " %d (unknown)", data[3]);
- strncpy((char *)buf, lbuf, buflen);
- common2:
- BUMP(buf, buflen);
- for (i = 4; i < cnt; i++) {
- sprintf(lbuf, " %d", data[i]);
- strncpy((char *)buf, lbuf, buflen);
- BUMP(buf, buflen);
- }
- break;
- }
-}
-
-int passwdok(name, passwd)
-char *name, *passwd;
-{
- char *crypt();
- char *salt, *p;
- struct passwd *pwd;
- int passwdok_status = 0;
-
- if (pwd = getpwnam(name))
- salt = pwd->pw_passwd;
- else salt = "xx";
-
- p = crypt(passwd, salt);
-
- if (pwd && !strcmp(p, pwd->pw_passwd)) {
- passwdok_status = 1;
- } else passwdok_status = 0;
- return(passwdok_status);
-}
-
-#endif
-
-#ifdef notdef
-
-prkey(msg, key)
- char *msg;
- unsigned char *key;
-{
- register int i;
- printf("%s:", msg);
- for (i = 0; i < 8; i++)
- printf(" %3d", key[i]);
- printf("\r\n");
-}
-#endif
diff --git a/contrib/telnet/libtelnet/misc-proto.h b/contrib/telnet/libtelnet/misc-proto.h
deleted file mode 100644
index e5f334a9bdd0..000000000000
--- a/contrib/telnet/libtelnet/misc-proto.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*-
- * Copyright (c) 1991, 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)misc-proto.h 8.1 (Berkeley) 6/4/93
- */
-
-/*
- * Copyright (C) 1990 by the Massachusetts Institute of Technology
- *
- * Export of this software from the United States of America is assumed
- * to require a specific license from the United States Government.
- * It is the responsibility of any person or organization contemplating
- * export to obtain such a license before exporting.
- *
- * WITHIN THAT CONSTRAINT, 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 appear in all copies and that both that copyright notice and
- * this permission notice appear in supporting documentation, and that
- * the name of M.I.T. not be used in advertising or publicity pertaining
- * to distribution of the software without specific, written prior
- * permission. M.I.T. makes no representations about the suitability of
- * this software for any purpose. It is provided "as is" without express
- * or implied warranty.
- */
-
-#ifndef __MISC_PROTO__
-#define __MISC_PROTO__
-
-#if !defined(P)
-#ifdef __STDC__
-#define P(x) x
-#else
-#define P(x) ()
-#endif
-#endif
-
-void auth_encrypt_init P((char *, char *, char *, int));
-void auth_encrypt_connect P((int));
-void printd P((unsigned char *, int));
-
-/*
- * These functions are imported from the application
- */
-int net_write P((unsigned char *, int));
-void net_encrypt P((void));
-int telnet_spin P((void));
-char *telnet_getenv P((char *));
-char *telnet_gets P((char *, char *, int, int));
-#endif
diff --git a/contrib/telnet/libtelnet/misc.c b/contrib/telnet/libtelnet/misc.c
deleted file mode 100644
index 4f8f8d53644b..000000000000
--- a/contrib/telnet/libtelnet/misc.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/*-
- * Copyright (c) 1991, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-static const char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 6/4/93";
-#endif /* not lint */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "misc.h"
-#include "auth.h"
-#include "encrypt.h"
-
-char *RemoteHostName;
-char *LocalHostName;
-char *UserNameRequested = 0;
-int ConnectedCount = 0;
-
- void
-auth_encrypt_init(local, remote, name, server)
- char *local;
- char *remote;
- char *name;
- int server;
-{
- RemoteHostName = remote;
- LocalHostName = local;
-#if defined(AUTHENTICATION)
- auth_init(name, server);
-#endif
-#ifdef ENCRYPTION
- encrypt_init(name, server);
-#endif /* ENCRYPTION */
- if (UserNameRequested) {
- free(UserNameRequested);
- UserNameRequested = 0;
- }
-}
-
- void
-auth_encrypt_user(name)
- char *name;
-{
- extern char *strdup();
-
- if (UserNameRequested)
- free(UserNameRequested);
- UserNameRequested = name ? strdup(name) : 0;
-}
-
- void
-auth_encrypt_connect(cnt)
- int cnt;
-{
-}
-
- void
-printd(data, cnt)
- unsigned char *data;
- int cnt;
-{
- if (cnt > 16)
- cnt = 16;
- while (cnt-- > 0) {
- printf(" %02x", *data);
- ++data;
- }
-}
diff --git a/contrib/telnet/libtelnet/misc.h b/contrib/telnet/libtelnet/misc.h
deleted file mode 100644
index 41ffa7f67aa7..000000000000
--- a/contrib/telnet/libtelnet/misc.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*-
- * Copyright (c) 1991, 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)misc.h 8.1 (Berkeley) 6/4/93
- */
-
-extern char *UserNameRequested;
-extern char *LocalHostName;
-extern char *RemoteHostName;
-extern int ConnectedCount;
-extern int ReservedPort;
-
-#include "misc-proto.h"
diff --git a/contrib/telnet/libtelnet/pk.c b/contrib/telnet/libtelnet/pk.c
deleted file mode 100644
index 9af8915148a7..000000000000
--- a/contrib/telnet/libtelnet/pk.c
+++ /dev/null
@@ -1,267 +0,0 @@
-/* public key routines */
-/* $FreeBSD$ */
-/* functions:
- genkeys(char *public, char *secret)
- common_key(char *secret, char *public, desData *deskey)
- pk_encode(char *in, *out, DesData *deskey);
- pk_decode(char *in, *out, DesData *deskey);
- where
- char public[HEXKEYBYTES + 1];
- char secret[HEXKEYBYTES + 1];
- */
-
-#include <stdio.h>
-#include <sys/time.h>
-#include <string.h>
-#include <fcntl.h>
-#include <openssl/des.h>
-#include "mp.h"
-#include "pk.h"
-#if defined(SOLARIS2) || defined(LINUX)
-#include <stdlib.h>
-#endif
-
-/*
- * Choose top 128 bits of the common key to use as our idea key.
- */
-static
-extractideakey(ck, ideakey)
- MINT *ck;
- IdeaData *ideakey;
-{
- MINT *a;
- MINT *z;
- short r;
- int i;
- short base = (1 << 8);
- char *k;
-
- z = itom(0);
- a = itom(0);
- madd(ck, z, a);
- for (i = 0; i < ((KEYSIZE - 128) / 8); i++) {
- sdiv(a, base, a, &r);
- }
- k = (char *)ideakey;
- for (i = 0; i < 16; i++) {
- sdiv(a, base, a, &r);
- *k++ = r;
- }
- mfree(z);
- mfree(a);
-}
-
-/*
- * Choose middle 64 bits of the common key to use as our des key, possibly
- * overwriting the lower order bits by setting parity.
- */
-static
-extractdeskey(ck, deskey)
- MINT *ck;
- DesData *deskey;
-{
- MINT *a;
- MINT *z;
- short r;
- int i;
- short base = (1 << 8);
- char *k;
-
- z = itom(0);
- a = itom(0);
- madd(ck, z, a);
- for (i = 0; i < ((KEYSIZE - 64) / 2) / 8; i++) {
- sdiv(a, base, a, &r);
- }
- k = (char *)deskey;
- for (i = 0; i < 8; i++) {
- sdiv(a, base, a, &r);
- *k++ = r;
- }
- mfree(z);
- mfree(a);
-}
-
-/*
- * get common key from my secret key and his public key
- */
-void common_key(char *xsecret, char *xpublic, IdeaData *ideakey, DesData *deskey)
-{
- MINT *public;
- MINT *secret;
- MINT *common;
- MINT *modulus = xtom(HEXMODULUS);
-
- public = xtom(xpublic);
- secret = xtom(xsecret);
- common = itom(0);
- pow(public, secret, modulus, common);
- extractdeskey(common, deskey);
- extractideakey(common, ideakey);
-#if DES_OSTHOLM
- des_fixup_key_parity(deskey);
-#else
- des_set_odd_parity(deskey);
-#endif
- mfree(common);
- mfree(secret);
- mfree(public);
- mfree(modulus);
-}
-
-
-/*
- * Generate a seed
- */
-void getseed(seed, seedsize)
- char *seed;
- int seedsize;
-{
- int i,f;
- int rseed;
- struct timeval tv;
- long devrand;
-
- (void)gettimeofday(&tv, (struct timezone *)NULL);
- rseed = tv.tv_sec + tv.tv_usec;
-/* XXX What the hell is this?! */
- for (i = 0; i < 8; i++) {
- rseed ^= (rseed << 8);
- }
-
- f=open("/dev/random",O_NONBLOCK|O_RDONLY);
- if (f>=0)
- {
- read(f,&devrand,sizeof(devrand));
- close(f);
- }
- srand48((long)rseed^devrand);
-
- for (i = 0; i < seedsize; i++) {
- seed[i] = (lrand48() & 0xff);
- }
-}
-
-
-/*
- * Generate a random public/secret key pair
- */
-void genkeys(public, secret)
- char *public;
- char *secret;
-{
- int i;
-
-# define BASEBITS (8*sizeof(short) - 1)
-# define BASE (1 << BASEBITS)
-
- MINT *pk = itom(0);
- MINT *sk = itom(0);
- MINT *tmp;
- MINT *base = itom(BASE);
- MINT *root = itom(PROOT);
- MINT *modulus = xtom(HEXMODULUS);
- short r;
- unsigned short seed[KEYSIZE/BASEBITS + 1];
- char *xkey;
-
- getseed((char *)seed, sizeof(seed));
- for (i = 0; i < KEYSIZE/BASEBITS + 1; i++) {
- r = seed[i] % BASE;
- tmp = itom(r);
- mult(sk, base, sk);
- madd(sk, tmp, sk);
- mfree(tmp);
- }
- tmp = itom(0);
- mdiv(sk, modulus, tmp, sk);
- mfree(tmp);
- pow(root, sk, modulus, pk);
- xkey = mtox(sk);
- adjust(secret, xkey);
- xkey = mtox(pk);
- adjust(public, xkey);
- mfree(sk);
- mfree(base);
- mfree(pk);
- mfree(root);
- mfree(modulus);
-}
-
-/*
- * Adjust the input key so that it is 0-filled on the left
- */
-adjust(keyout, keyin)
- char keyout[HEXKEYBYTES+1];
- char *keyin;
-{
- char *p;
- char *s;
-
- for (p = keyin; *p; p++)
- ;
- for (s = keyout + HEXKEYBYTES; p >= keyin; p--, s--) {
- *s = *p;
- }
- while (s >= keyout) {
- *s-- = '0';
- }
-}
-
-static char hextab[17] = "0123456789ABCDEF";
-
-/* given a DES key, cbc encrypt and translate input to terminated hex */
-void pk_encode(in, out, key)
-char *in,*out;
-DesData *key;
-{
- char buf[256];
- DesData i;
- des_key_schedule k;
- int l,op,deslen;
-
- memset(&i,0,sizeof(i));
- memset(buf,0,sizeof(buf));
- deslen = ((strlen(in) + 7)/8)*8;
- des_key_sched(key, k);
- des_cbc_encrypt((des_cblock *)in,(des_cblock *)buf,deslen,
- k,&i,DES_ENCRYPT);
- for (l=0,op=0;l<deslen;l++) {
- out[op++] = hextab[(buf[l] & 0xf0) >> 4];
- out[op++] = hextab[(buf[l] & 0x0f)];
- }
- out[op] = '\0';
-}
-
-/* given a DES key, translate input from hex and decrypt */
-void pk_decode(in, out, key)
-char *in,*out;
-DesData *key;
-{
- char buf[256];
- DesData i;
- des_key_schedule k;
- int l,n1,n2,op;
-
- memset(&i,0,sizeof(i));
- memset(buf,0,sizeof(buf));
- for (l=0,op=0;l<strlen(in)/2;l++,op+=2) {
- if(in[op] == '0' && in[op+1] == '0') {
- buf[l] = '\0';
- break;
- }
- if (in[op] > '9')
- n1 = in[op] - 'A' + 10;
- else
- n1 = in[op] - '0';
- if (in[op+1] > '9')
- n2 = in[op+1] - 'A' + 10;
- else
- n2 = in[op+1] - '0';
- buf[l] = n1*16 +n2;
- }
- des_key_sched(key, k);
- des_cbc_encrypt((des_cblock *)buf,(des_cblock *)out,strlen(in)/2,
- k,&i,DES_DECRYPT);
- out[strlen(in)/2] = '\0';
-}
diff --git a/contrib/telnet/libtelnet/pk.h b/contrib/telnet/libtelnet/pk.h
deleted file mode 100644
index b41bba5987d6..000000000000
--- a/contrib/telnet/libtelnet/pk.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* header for the des routines that we will use */
-
-typedef unsigned char byte, DesData[ 8], IdeaData[16];
-#if 0
-typedef unsigned long word, DesKeys[32];
-#else
-#define DesKeys des_key_schedule
-#endif
-
-#define DES_DECRYPT 0
-#define DES_ENCRYPT 1
-
-#if 0
-extern void des_fixup_key_parity(); /* (DesData *key) */
-extern int des_key_sched(); /* (DesData *key, DesKeys *m) */
-extern int des_ecb_encrypt(); /* (DesData *src, *dst, DesKeys *m, int mode) */
-extern int des_cbc_encrypt(); /* (char *src, *dst, int length,
- DesKeys *m, DesData *init, int mode) */
-#endif
-
-/* public key routines */
-/* functions:
- genkeys(char *public, char *secret)
- common_key(char *secret, char *public, desData *deskey)
- where
- char public[HEXKEYBYTES + 1];
- char secret[HEXKEYBYTES + 1];
- */
-
-#define HEXMODULUS "d4a0ba0250b6fd2ec626e7efd637df76c716e22d0944b88b"
-#define HEXKEYBYTES 48
-#define KEYSIZE 192
-#define KEYBYTES 24
-#define PROOT 3
-
-extern void genkeys(char *public, char *secret);
-extern void common_key(char *secret, char *public, IdeaData *common,
- DesData *deskey);
-extern void pk_encode(char *in, char *out, DesData *deskey);
-extern void pk_decode(char *in, char *out, DesData *deskey);
-
diff --git a/contrib/telnet/libtelnet/read_password.c b/contrib/telnet/libtelnet/read_password.c
deleted file mode 100644
index 4676ed3a01bb..000000000000
--- a/contrib/telnet/libtelnet/read_password.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/*-
- * 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-static char sccsid[] = "@(#)read_password.c 8.3 (Berkeley) 5/30/95";
-#endif /* not lint */
-
-/*
- * $Source: /mit/kerberos/src/lib/des/RCS/read_password.c,v $
- * $Author: jon $
- *
- * Copyright 1985, 1986, 1987, 1988 by the Massachusetts Institute
- * of Technology.
- *
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
- *
- * This routine prints the supplied string to standard
- * output as a prompt, and reads a password string without
- * echoing.
- */
-
-#if defined(RSA_ENCPWD) || defined(KRB4_ENCPWD)
-
-#include <stdio.h>
-#include <strings.h>
-#include <sys/ioctl.h>
-#include <signal.h>
-#include <setjmp.h>
-
-static jmp_buf env;
-
-/*** Routines ****************************************************** */
-/*
- * This version just returns the string, doesn't map to key.
- *
- * Returns 0 on success, non-zero on failure.
- */
-
-int
-local_des_read_pw_string(s,max,prompt,verify)
- char *s;
- int max;
- char *prompt;
- int verify;
-{
- int ok = 0;
- char *ptr;
-
- jmp_buf old_env;
- struct sgttyb tty_state;
- char key_string[BUFSIZ];
-
- if (max > BUFSIZ) {
- return -1;
- }
-
- /* XXX assume jmp_buf is typedef'ed to an array */
- memmove((char *)env, (char *)old_env, sizeof(env));
- if (setjmp(env))
- goto lose;
-
- /* save terminal state*/
- if (ioctl(0,TIOCGETP,(char *)&tty_state) == -1)
- return -1;
-/*
- push_signals();
-*/
- /* Turn off echo */
- tty_state.sg_flags &= ~ECHO;
- if (ioctl(0,TIOCSETP,(char *)&tty_state) == -1)
- return -1;
- while (!ok) {
- (void) printf(prompt);
- (void) fflush(stdout);
- while (!fgets(s, max, stdin));
-
- if ((ptr = strchr(s, '\n')))
- *ptr = '\0';
- if (verify) {
- printf("\nVerifying, please re-enter %s",prompt);
- (void) fflush(stdout);
- if (!fgets(key_string, sizeof(key_string), stdin)) {
- clearerr(stdin);
- continue;
- }
- if ((ptr = strchr(key_string, '\n')))
- *ptr = '\0';
- if (strcmp(s,key_string)) {
- printf("\n\07\07Mismatch - try again\n");
- (void) fflush(stdout);
- continue;
- }
- }
- ok = 1;
- }
-
-lose:
- if (!ok)
- memset(s, 0, max);
- printf("\n");
- /* turn echo back on */
- tty_state.sg_flags |= ECHO;
- if (ioctl(0,TIOCSETP,(char *)&tty_state))
- ok = 0;
-/*
- pop_signals();
-*/
- memmove((char *)old_env, (char *)env, sizeof(env));
- if (verify)
- memset(key_string, 0, sizeof (key_string));
- s[max-1] = 0; /* force termination */
- return !ok; /* return nonzero if not okay */
-}
-#endif /* defined(RSA_ENCPWD) || defined(KRB4_ENCPWD) */
diff --git a/contrib/telnet/libtelnet/rsaencpwd.c b/contrib/telnet/libtelnet/rsaencpwd.c
deleted file mode 100644
index 5906d999af68..000000000000
--- a/contrib/telnet/libtelnet/rsaencpwd.c
+++ /dev/null
@@ -1,492 +0,0 @@
-/*-
- * 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-static char sccsid[] = "@(#)rsaencpwd.c 8.3 (Berkeley) 5/30/95";
-#endif /* not lint */
-
-
-#ifdef RSA_ENCPWD
-/*
- * COPYRIGHT (C) 1990 DIGITAL EQUIPMENT CORPORATION
- * ALL RIGHTS RESERVED
- *
- * "Digital Equipment Corporation authorizes the reproduction,
- * distribution and modification of this software subject to the following
- * restrictions:
- *
- * 1. Any partial or whole copy of this software, or any modification
- * thereof, must include this copyright notice in its entirety.
- *
- * 2. This software is supplied "as is" with no warranty of any kind,
- * expressed or implied, for any purpose, including any warranty of fitness
- * or merchantibility. DIGITAL assumes no responsibility for the use or
- * reliability of this software, nor promises to provide any form of
- * support for it on any basis.
- *
- * 3. Distribution of this software is authorized only if no profit or
- * remuneration of any kind is received in exchange for such distribution.
- *
- * 4. This software produces public key authentication certificates
- * bearing an expiration date established by DIGITAL and RSA Data
- * Security, Inc. It may cease to generate certificates after the expiration
- * date. Any modification of this software that changes or defeats
- * the expiration date or its effect is unauthorized.
- *
- * 5. Software that will renew or extend the expiration date of
- * authentication certificates produced by this software may be obtained
- * from RSA Data Security, Inc., 10 Twin Dolphin Drive, Redwood City, CA
- * 94065, (415)595-8782, or from DIGITAL"
- *
- */
-
-#include <sys/types.h>
-#include <arpa/telnet.h>
-#include <pwd.h>
-#include <stdio.h>
-
-#ifdef __STDC__
-#include <stdlib.h>
-#endif
-#ifdef NO_STRING_H
-#include <strings.h>
-#else
-#include <string.h>
-#endif
-
-#include "encrypt.h"
-#include "auth.h"
-#include "misc.h"
-#include "cdc.h"
-
-extern auth_debug_mode;
-
-static unsigned char str_data[1024] = { IAC, SB, TELOPT_AUTHENTICATION, 0,
- AUTHTYPE_RSA_ENCPWD, };
-static unsigned char str_name[1024] = { IAC, SB, TELOPT_AUTHENTICATION,
- TELQUAL_NAME, };
-
-#define RSA_ENCPWD_AUTH 0 /* Authentication data follows */
-#define RSA_ENCPWD_REJECT 1 /* Rejected (reason might follow) */
-#define RSA_ENCPWD_ACCEPT 2 /* Accepted */
-#define RSA_ENCPWD_CHALLENGEKEY 3 /* Challenge and public key */
-
-#define NAME_SZ 40
-#define CHAL_SZ 20
-#define PWD_SZ 40
-
-static KTEXT_ST auth;
-static char name[NAME_SZ];
-static char user_passwd[PWD_SZ];
-static char key_file[2*NAME_SZ];
-static char lhostname[NAME_SZ];
-static char challenge[CHAL_SZ];
-static int challenge_len;
-
- static int
-Data(ap, type, d, c)
- Authenticator *ap;
- int type;
- void *d;
- int c;
-{
- unsigned char *p = str_data + 4;
- unsigned char *cd = (unsigned char *)d;
-
- if (c == -1)
- c = strlen((char *)cd);
-
- if (0) {
- printf("%s:%d: [%d] (%d)",
- str_data[3] == TELQUAL_IS ? ">>>IS" : ">>>REPLY",
- str_data[3],
- type, c);
- printd(d, c);
- printf("\r\n");
- }
- *p++ = ap->type;
- *p++ = ap->way;
- if (type != NULL) *p++ = type;
- while (c-- > 0) {
- if ((*p++ = *cd++) == IAC)
- *p++ = IAC;
- }
- *p++ = IAC;
- *p++ = SE;
- if (str_data[3] == TELQUAL_IS)
- printsub('>', &str_data[2], p - (&str_data[2]));
- return(net_write(str_data, p - str_data));
-}
-
- int
-rsaencpwd_init(ap, server)
- Authenticator *ap;
- int server;
-{
- char *cp;
- FILE *fp;
-
- if (server) {
- str_data[3] = TELQUAL_REPLY;
- memset(key_file, 0, sizeof(key_file));
- gethostname(lhostname, sizeof(lhostname));
- if ((cp = strchr(lhostname, '.')) != 0) *cp = '\0';
- strcpy(key_file, "/etc/.");
- strcat(key_file, lhostname);
- strcat(key_file, "_privkey");
- if ((fp=fopen(key_file, "r"))==NULL) return(0);
- fclose(fp);
- } else {
- str_data[3] = TELQUAL_IS;
- }
- return(1);
-}
-
- int
-rsaencpwd_send(ap)
- Authenticator *ap;
-{
-
- printf("[ Trying RSAENCPWD ... ]\n");
- if (!UserNameRequested) {
- return(0);
- }
- if (!auth_sendname(UserNameRequested, strlen(UserNameRequested))) {
- return(0);
- }
- if (!Data(ap, NULL, (void *)NULL, 0)) {
- return(0);
- }
-
-
- return(1);
-}
-
- void
-rsaencpwd_is(ap, data, cnt)
- Authenticator *ap;
- unsigned char *data;
- int cnt;
-{
- Session_Key skey;
- Block datablock;
- char r_passwd[PWD_SZ], r_user[NAME_SZ];
- char *cp, key[160];
- char chalkey[160], *ptr;
- FILE *fp;
- int r, i, j, chalkey_len, len;
- time_t now;
-
- cnt--;
- switch (*data++) {
- case RSA_ENCPWD_AUTH:
- memmove((void *)auth.dat, (void *)data, auth.length = cnt);
-
- if ((fp=fopen(key_file, "r"))==NULL) {
- Data(ap, RSA_ENCPWD_REJECT, (void *)"Auth failed", -1);
- auth_finished(ap, AUTH_REJECT);
- return;
- }
- /*
- * get privkey
- */
- fscanf(fp, "%x;", &len);
- for (i=0;i<len;i++) {
- j = getc(fp); key[i]=j;
- }
- fclose(fp);
-
- r = accept_rsa_encpwd(&auth, key, challenge,
- challenge_len, r_passwd);
- if (r < 0) {
- Data(ap, RSA_ENCPWD_REJECT, (void *)"Auth failed", -1);
- auth_finished(ap, AUTH_REJECT);
- return;
- }
- auth_encrypt_userpwd(r_passwd);
- if (rsaencpwd_passwdok(UserNameRequested, UserPassword) == 0) {
- /*
- * illegal username and password
- */
- Data(ap, RSA_ENCPWD_REJECT, (void *)"Illegal password", -1);
- auth_finished(ap, AUTH_REJECT);
- return;
- }
-
- Data(ap, RSA_ENCPWD_ACCEPT, (void *)0, 0);
- auth_finished(ap, AUTH_USER);
- break;
-
-
- case IAC:
-
- /*
- * If we are doing mutual authentication, get set up to send
- * the challenge, and verify it when the response comes back.
- */
- if ((ap->way & AUTH_HOW_MASK) == AUTH_HOW_ONE_WAY) {
- register int i;
-
-
- time(&now);
- if ((now % 2) == 0) {
- sprintf(challenge, "%x", now);
- challenge_len = strlen(challenge);
- } else {
- strcpy(challenge, "randchal");
- challenge_len = 8;
- }
-
- if ((fp=fopen(key_file, "r"))==NULL) {
- Data(ap, RSA_ENCPWD_REJECT, (void *)"Auth failed", -1);
- auth_finished(ap, AUTH_REJECT);
- return;
- }
- /*
- * skip privkey
- */
- fscanf(fp, "%x;", &len);
- for (i=0;i<len;i++) {
- j = getc(fp);
- }
- /*
- * get pubkey
- */
- fscanf(fp, "%x;", &len);
- for (i=0;i<len;i++) {
- j = getc(fp); key[i]=j;
- }
- fclose(fp);
- chalkey[0] = 0x30;
- ptr = (char *) &chalkey[1];
- chalkey_len = 1+NumEncodeLengthOctets(i)+i+1+NumEncodeLengthOctets(challenge_len)+challenge_len;
- EncodeLength(ptr, chalkey_len);
- ptr +=NumEncodeLengthOctets(chalkey_len);
- *ptr++ = 0x04; /* OCTET STRING */
- *ptr++ = challenge_len;
- memmove(ptr, challenge, challenge_len);
- ptr += challenge_len;
- *ptr++ = 0x04; /* OCTET STRING */
- EncodeLength(ptr, i);
- ptr += NumEncodeLengthOctets(i);
- memmove(ptr, key, i);
- chalkey_len = 1+NumEncodeLengthOctets(chalkey_len)+chalkey_len;
- Data(ap, RSA_ENCPWD_CHALLENGEKEY, (void *)chalkey, chalkey_len);
- }
- break;
-
- default:
- Data(ap, RSA_ENCPWD_REJECT, 0, 0);
- break;
- }
-}
-
-
- void
-rsaencpwd_reply(ap, data, cnt)
- Authenticator *ap;
- unsigned char *data;
- int cnt;
-{
- Session_Key skey;
- KTEXT_ST token;
- Block enckey;
- int r, pubkey_len;
- char randchal[CHAL_SZ], *cp;
- char chalkey[160], pubkey[128], *ptr;
-
- if (cnt-- < 1)
- return;
- switch (*data++) {
- case RSA_ENCPWD_REJECT:
- if (cnt > 0) {
- printf("[ RSA_ENCPWD refuses authentication because %.*s ]\r\n",
- cnt, data);
- } else
- printf("[ RSA_ENCPWD refuses authentication ]\r\n");
- auth_send_retry();
- return;
- case RSA_ENCPWD_ACCEPT:
- printf("[ RSA_ENCPWD accepts you ]\n");
- auth_finished(ap, AUTH_USER);
- return;
- case RSA_ENCPWD_CHALLENGEKEY:
- /*
- * Verify that the response to the challenge is correct.
- */
-
- memmove((void *)chalkey, (void *)data, cnt);
- ptr = (char *) &chalkey[0];
- ptr += DecodeHeaderLength(chalkey);
- if (*ptr != 0x04) {
- return;
- }
- *ptr++;
- challenge_len = DecodeValueLength(ptr);
- ptr += NumEncodeLengthOctets(challenge_len);
- memmove(challenge, ptr, challenge_len);
- ptr += challenge_len;
- if (*ptr != 0x04) {
- return;
- }
- *ptr++;
- pubkey_len = DecodeValueLength(ptr);
- ptr += NumEncodeLengthOctets(pubkey_len);
- memmove(pubkey, ptr, pubkey_len);
- memset(user_passwd, 0, sizeof(user_passwd));
- local_des_read_pw_string(user_passwd, sizeof(user_passwd)-1, "Password: ", 0);
- UserPassword = user_passwd;
- Challenge = challenge;
- r = init_rsa_encpwd(&token, user_passwd, challenge, challenge_len, pubkey);
- if (r < 0) {
- token.length = 1;
- }
-
- if (!Data(ap, RSA_ENCPWD_AUTH, (void *)token.dat, token.length)) {
- return;
- }
-
- break;
-
- default:
- return;
- }
-}
-
- int
-rsaencpwd_status(ap, name, level)
- Authenticator *ap;
- char *name;
- int level;
-{
-
- if (level < AUTH_USER)
- return(level);
-
- if (UserNameRequested && rsaencpwd_passwdok(UserNameRequested, UserPassword)) {
- strcpy(name, UserNameRequested);
- return(AUTH_VALID);
- } else {
- return(AUTH_USER);
- }
-}
-
-#define BUMP(buf, len) while (*(buf)) {++(buf), --(len);}
-#define ADDC(buf, len, c) if ((len) > 0) {*(buf)++ = (c); --(len);}
-
- void
-rsaencpwd_printsub(data, cnt, buf, buflen)
- unsigned char *data, *buf;
- int cnt, buflen;
-{
- char lbuf[32];
- register int i;
-
- buf[buflen-1] = '\0'; /* make sure its NULL terminated */
- buflen -= 1;
-
- switch(data[3]) {
- case RSA_ENCPWD_REJECT: /* Rejected (reason might follow) */
- strncpy((char *)buf, " REJECT ", buflen);
- goto common;
-
- case RSA_ENCPWD_ACCEPT: /* Accepted (name might follow) */
- strncpy((char *)buf, " ACCEPT ", buflen);
- common:
- BUMP(buf, buflen);
- if (cnt <= 4)
- break;
- ADDC(buf, buflen, '"');
- for (i = 4; i < cnt; i++)
- ADDC(buf, buflen, data[i]);
- ADDC(buf, buflen, '"');
- ADDC(buf, buflen, '\0');
- break;
-
- case RSA_ENCPWD_AUTH: /* Authentication data follows */
- strncpy((char *)buf, " AUTH", buflen);
- goto common2;
-
- case RSA_ENCPWD_CHALLENGEKEY:
- strncpy((char *)buf, " CHALLENGEKEY", buflen);
- goto common2;
-
- default:
- sprintf(lbuf, " %d (unknown)", data[3]);
- strncpy((char *)buf, lbuf, buflen);
- common2:
- BUMP(buf, buflen);
- for (i = 4; i < cnt; i++) {
- sprintf(lbuf, " %d", data[i]);
- strncpy((char *)buf, lbuf, buflen);
- BUMP(buf, buflen);
- }
- break;
- }
-}
-
-int rsaencpwd_passwdok(name, passwd)
-char *name, *passwd;
-{
- char *crypt();
- char *salt, *p;
- struct passwd *pwd;
- int passwdok_status = 0;
-
- if (pwd = getpwnam(name))
- salt = pwd->pw_passwd;
- else salt = "xx";
-
- p = crypt(passwd, salt);
-
- if (pwd && !strcmp(p, pwd->pw_passwd)) {
- passwdok_status = 1;
- } else passwdok_status = 0;
- return(passwdok_status);
-}
-
-#endif
-
-#ifdef notdef
-
-prkey(msg, key)
- char *msg;
- unsigned char *key;
-{
- register int i;
- printf("%s:", msg);
- for (i = 0; i < 8; i++)
- printf(" %3d", key[i]);
- printf("\r\n");
-}
-#endif
diff --git a/contrib/telnet/libtelnet/spx.c b/contrib/telnet/libtelnet/spx.c
deleted file mode 100644
index 90c37a47ebd6..000000000000
--- a/contrib/telnet/libtelnet/spx.c
+++ /dev/null
@@ -1,587 +0,0 @@
-/*-
- * 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-static char sccsid[] = "@(#)spx.c 8.2 (Berkeley) 5/30/95";
-#endif /* not lint */
-
-#ifdef SPX
-/*
- * COPYRIGHT (C) 1990 DIGITAL EQUIPMENT CORPORATION
- * ALL RIGHTS RESERVED
- *
- * "Digital Equipment Corporation authorizes the reproduction,
- * distribution and modification of this software subject to the following
- * restrictions:
- *
- * 1. Any partial or whole copy of this software, or any modification
- * thereof, must include this copyright notice in its entirety.
- *
- * 2. This software is supplied "as is" with no warranty of any kind,
- * expressed or implied, for any purpose, including any warranty of fitness
- * or merchantibility. DIGITAL assumes no responsibility for the use or
- * reliability of this software, nor promises to provide any form of
- * support for it on any basis.
- *
- * 3. Distribution of this software is authorized only if no profit or
- * remuneration of any kind is received in exchange for such distribution.
- *
- * 4. This software produces public key authentication certificates
- * bearing an expiration date established by DIGITAL and RSA Data
- * Security, Inc. It may cease to generate certificates after the expiration
- * date. Any modification of this software that changes or defeats
- * the expiration date or its effect is unauthorized.
- *
- * 5. Software that will renew or extend the expiration date of
- * authentication certificates produced by this software may be obtained
- * from RSA Data Security, Inc., 10 Twin Dolphin Drive, Redwood City, CA
- * 94065, (415)595-8782, or from DIGITAL"
- *
- */
-
-#include <sys/types.h>
-#include <arpa/telnet.h>
-#include <stdio.h>
-#include "gssapi_defs.h"
-#ifdef __STDC__
-#include <stdlib.h>
-#endif
-#ifdef NO_STRING_H
-#include <strings.h>
-#else
-#include <string.h>
-#endif
-
-#include <pwd.h>
-#include "encrypt.h"
-#include "auth.h"
-#include "misc.h"
-
-extern auth_debug_mode;
-
-static unsigned char str_data[1024] = { IAC, SB, TELOPT_AUTHENTICATION, 0,
- AUTHTYPE_SPX, };
-static unsigned char str_name[1024] = { IAC, SB, TELOPT_AUTHENTICATION,
- TELQUAL_NAME, };
-
-#define SPX_AUTH 0 /* Authentication data follows */
-#define SPX_REJECT 1 /* Rejected (reason might follow) */
-#define SPX_ACCEPT 2 /* Accepted */
-
-#ifdef ENCRYPTION
-static Block session_key = { 0 };
-#endif /* ENCRYPTION */
-static Block challenge = { 0 };
-
-
-/*******************************************************************/
-
-gss_OID_set actual_mechs;
-gss_OID actual_mech_type, output_name_type;
-int major_status, status, msg_ctx = 0, new_status;
-int req_flags = 0, ret_flags, lifetime_rec;
-gss_cred_id_t gss_cred_handle;
-gss_ctx_id_t actual_ctxhandle, context_handle;
-gss_buffer_desc output_token, input_token, input_name_buffer;
-gss_buffer_desc status_string;
-gss_name_t desired_targname, src_name;
-gss_channel_bindings input_chan_bindings;
-char lhostname[GSS_C_MAX_PRINTABLE_NAME];
-char targ_printable[GSS_C_MAX_PRINTABLE_NAME];
-int to_addr=0, from_addr=0;
-char *address;
-gss_buffer_desc fullname_buffer;
-gss_OID fullname_type;
-gss_cred_id_t gss_delegated_cred_handle;
-
-/*******************************************************************/
-
-
-
- static int
-Data(ap, type, d, c)
- Authenticator *ap;
- int type;
- void *d;
- int c;
-{
- unsigned char *p = str_data + 4;
- unsigned char *cd = (unsigned char *)d;
-
- if (c == -1)
- c = strlen((char *)cd);
-
- if (0) {
- printf("%s:%d: [%d] (%d)",
- str_data[3] == TELQUAL_IS ? ">>>IS" : ">>>REPLY",
- str_data[3],
- type, c);
- printd(d, c);
- printf("\r\n");
- }
- *p++ = ap->type;
- *p++ = ap->way;
- *p++ = type;
- while (c-- > 0) {
- if ((*p++ = *cd++) == IAC)
- *p++ = IAC;
- }
- *p++ = IAC;
- *p++ = SE;
- if (str_data[3] == TELQUAL_IS)
- printsub('>', &str_data[2], p - (&str_data[2]));
- return(net_write(str_data, p - str_data));
-}
-
- int
-spx_init(ap, server)
- Authenticator *ap;
- int server;
-{
- gss_cred_id_t tmp_cred_handle;
-
- if (server) {
- str_data[3] = TELQUAL_REPLY;
- gethostname(lhostname, sizeof(lhostname));
- strcpy(targ_printable, "SERVICE:rcmd@");
- strcat(targ_printable, lhostname);
- input_name_buffer.length = strlen(targ_printable);
- input_name_buffer.value = targ_printable;
- major_status = gss_import_name(&status,
- &input_name_buffer,
- GSS_C_NULL_OID,
- &desired_targname);
- major_status = gss_acquire_cred(&status,
- desired_targname,
- 0,
- GSS_C_NULL_OID_SET,
- GSS_C_ACCEPT,
- &tmp_cred_handle,
- &actual_mechs,
- &lifetime_rec);
- if (major_status != GSS_S_COMPLETE) return(0);
- } else {
- str_data[3] = TELQUAL_IS;
- }
- return(1);
-}
-
- int
-spx_send(ap)
- Authenticator *ap;
-{
- Block enckey;
- int r;
-
- gss_OID actual_mech_type, output_name_type;
- int msg_ctx = 0, new_status, status;
- int req_flags = 0, ret_flags, lifetime_rec, major_status;
- gss_buffer_desc output_token, input_token, input_name_buffer;
- gss_buffer_desc output_name_buffer, status_string;
- gss_name_t desired_targname;
- gss_channel_bindings input_chan_bindings;
- char targ_printable[GSS_C_MAX_PRINTABLE_NAME];
- int from_addr=0, to_addr=0, myhostlen, j;
- int deleg_flag=1, mutual_flag=0, replay_flag=0, seq_flag=0;
- char *address;
-
- printf("[ Trying SPX ... ]\n");
- strcpy(targ_printable, "SERVICE:rcmd@");
- strcat(targ_printable, RemoteHostName);
-
- input_name_buffer.length = strlen(targ_printable);
- input_name_buffer.value = targ_printable;
-
- if (!UserNameRequested) {
- return(0);
- }
-
- major_status = gss_import_name(&status,
- &input_name_buffer,
- GSS_C_NULL_OID,
- &desired_targname);
-
-
- major_status = gss_display_name(&status,
- desired_targname,
- &output_name_buffer,
- &output_name_type);
-
- printf("target is '%s'\n", output_name_buffer.value); fflush(stdout);
-
- major_status = gss_release_buffer(&status, &output_name_buffer);
-
- input_chan_bindings = (gss_channel_bindings)
- malloc(sizeof(gss_channel_bindings_desc));
-
- input_chan_bindings->initiator_addrtype = GSS_C_AF_INET;
- input_chan_bindings->initiator_address.length = 4;
- address = (char *) malloc(4);
- input_chan_bindings->initiator_address.value = (char *) address;
- address[0] = ((from_addr & 0xff000000) >> 24);
- address[1] = ((from_addr & 0xff0000) >> 16);
- address[2] = ((from_addr & 0xff00) >> 8);
- address[3] = (from_addr & 0xff);
- input_chan_bindings->acceptor_addrtype = GSS_C_AF_INET;
- input_chan_bindings->acceptor_address.length = 4;
- address = (char *) malloc(4);
- input_chan_bindings->acceptor_address.value = (char *) address;
- address[0] = ((to_addr & 0xff000000) >> 24);
- address[1] = ((to_addr & 0xff0000) >> 16);
- address[2] = ((to_addr & 0xff00) >> 8);
- address[3] = (to_addr & 0xff);
- input_chan_bindings->application_data.length = 0;
-
- req_flags = 0;
- if (deleg_flag) req_flags = req_flags | 1;
- if (mutual_flag) req_flags = req_flags | 2;
- if (replay_flag) req_flags = req_flags | 4;
- if (seq_flag) req_flags = req_flags | 8;
-
- major_status = gss_init_sec_context(&status, /* minor status */
- GSS_C_NO_CREDENTIAL, /* cred handle */
- &actual_ctxhandle, /* ctx handle */
- desired_targname, /* target name */
- GSS_C_NULL_OID, /* mech type */
- req_flags, /* req flags */
- 0, /* time req */
- input_chan_bindings, /* chan binding */
- GSS_C_NO_BUFFER, /* input token */
- &actual_mech_type, /* actual mech */
- &output_token, /* output token */
- &ret_flags, /* ret flags */
- &lifetime_rec); /* time rec */
-
- if ((major_status != GSS_S_COMPLETE) &&
- (major_status != GSS_S_CONTINUE_NEEDED)) {
- gss_display_status(&new_status,
- status,
- GSS_C_MECH_CODE,
- GSS_C_NULL_OID,
- &msg_ctx,
- &status_string);
- printf("%s\n", status_string.value);
- return(0);
- }
-
- if (!auth_sendname(UserNameRequested, strlen(UserNameRequested))) {
- return(0);
- }
-
- if (!Data(ap, SPX_AUTH, (void *)output_token.value, output_token.length)) {
- return(0);
- }
-
- return(1);
-}
-
- void
-spx_is(ap, data, cnt)
- Authenticator *ap;
- unsigned char *data;
- int cnt;
-{
- Session_Key skey;
- Block datablock;
- int r;
-
- if (cnt-- < 1)
- return;
- switch (*data++) {
- case SPX_AUTH:
- input_token.length = cnt;
- input_token.value = (char *) data;
-
- gethostname(lhostname, sizeof(lhostname));
-
- strcpy(targ_printable, "SERVICE:rcmd@");
- strcat(targ_printable, lhostname);
-
- input_name_buffer.length = strlen(targ_printable);
- input_name_buffer.value = targ_printable;
-
- major_status = gss_import_name(&status,
- &input_name_buffer,
- GSS_C_NULL_OID,
- &desired_targname);
-
- major_status = gss_acquire_cred(&status,
- desired_targname,
- 0,
- GSS_C_NULL_OID_SET,
- GSS_C_ACCEPT,
- &gss_cred_handle,
- &actual_mechs,
- &lifetime_rec);
-
- major_status = gss_release_name(&status, desired_targname);
-
- input_chan_bindings = (gss_channel_bindings)
- malloc(sizeof(gss_channel_bindings_desc));
-
- input_chan_bindings->initiator_addrtype = GSS_C_AF_INET;
- input_chan_bindings->initiator_address.length = 4;
- address = (char *) malloc(4);
- input_chan_bindings->initiator_address.value = (char *) address;
- address[0] = ((from_addr & 0xff000000) >> 24);
- address[1] = ((from_addr & 0xff0000) >> 16);
- address[2] = ((from_addr & 0xff00) >> 8);
- address[3] = (from_addr & 0xff);
- input_chan_bindings->acceptor_addrtype = GSS_C_AF_INET;
- input_chan_bindings->acceptor_address.length = 4;
- address = (char *) malloc(4);
- input_chan_bindings->acceptor_address.value = (char *) address;
- address[0] = ((to_addr & 0xff000000) >> 24);
- address[1] = ((to_addr & 0xff0000) >> 16);
- address[2] = ((to_addr & 0xff00) >> 8);
- address[3] = (to_addr & 0xff);
- input_chan_bindings->application_data.length = 0;
-
- major_status = gss_accept_sec_context(&status,
- &context_handle,
- gss_cred_handle,
- &input_token,
- input_chan_bindings,
- &src_name,
- &actual_mech_type,
- &output_token,
- &ret_flags,
- &lifetime_rec,
- &gss_delegated_cred_handle);
-
-
- if (major_status != GSS_S_COMPLETE) {
-
- major_status = gss_display_name(&status,
- src_name,
- &fullname_buffer,
- &fullname_type);
- Data(ap, SPX_REJECT, (void *)"auth failed", -1);
- auth_finished(ap, AUTH_REJECT);
- return;
- }
-
- major_status = gss_display_name(&status,
- src_name,
- &fullname_buffer,
- &fullname_type);
-
-
- Data(ap, SPX_ACCEPT, (void *)output_token.value, output_token.length);
- auth_finished(ap, AUTH_USER);
- break;
-
- default:
- Data(ap, SPX_REJECT, 0, 0);
- break;
- }
-}
-
-
- void
-spx_reply(ap, data, cnt)
- Authenticator *ap;
- unsigned char *data;
- int cnt;
-{
- Session_Key skey;
-
- if (cnt-- < 1)
- return;
- switch (*data++) {
- case SPX_REJECT:
- if (cnt > 0) {
- printf("[ SPX refuses authentication because %.*s ]\r\n",
- cnt, data);
- } else
- printf("[ SPX refuses authentication ]\r\n");
- auth_send_retry();
- return;
- case SPX_ACCEPT:
- printf("[ SPX accepts you ]\n");
- if ((ap->way & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL) {
- /*
- * Send over the encrypted challenge.
- */
- input_token.value = (char *) data;
- input_token.length = cnt;
-
- major_status = gss_init_sec_context(&status, /* minor stat */
- GSS_C_NO_CREDENTIAL, /* cred handle */
- &actual_ctxhandle, /* ctx handle */
- desired_targname, /* target name */
- GSS_C_NULL_OID, /* mech type */
- req_flags, /* req flags */
- 0, /* time req */
- input_chan_bindings, /* chan binding */
- &input_token, /* input token */
- &actual_mech_type, /* actual mech */
- &output_token, /* output token */
- &ret_flags, /* ret flags */
- &lifetime_rec); /* time rec */
-
- if (major_status != GSS_S_COMPLETE) {
- gss_display_status(&new_status,
- status,
- GSS_C_MECH_CODE,
- GSS_C_NULL_OID,
- &msg_ctx,
- &status_string);
- printf("[ SPX mutual response fails ... '%s' ]\r\n",
- status_string.value);
- auth_send_retry();
- return;
- }
- }
- auth_finished(ap, AUTH_USER);
- return;
-
- default:
- return;
- }
-}
-
- int
-spx_status(ap, name, level)
- Authenticator *ap;
- char *name;
- int level;
-{
-
- gss_buffer_desc fullname_buffer, acl_file_buffer;
- gss_OID fullname_type;
- char acl_file[160], fullname[160];
- int major_status, status = 0;
- struct passwd *pwd;
-
- /*
- * hard code fullname to
- * "SPX:/C=US/O=Digital/OU=LKG/OU=Sphinx/OU=Users/CN=Kannan Alagappan"
- * and acl_file to "~kannan/.sphinx"
- */
-
- pwd = getpwnam(UserNameRequested);
- if (pwd == NULL) {
- return(AUTH_USER); /* not authenticated */
- }
-
- strcpy(acl_file, pwd->pw_dir);
- strcat(acl_file, "/.sphinx");
- acl_file_buffer.value = acl_file;
- acl_file_buffer.length = strlen(acl_file);
-
- major_status = gss_display_name(&status,
- src_name,
- &fullname_buffer,
- &fullname_type);
-
- if (level < AUTH_USER)
- return(level);
-
- major_status = gss__check_acl(&status, &fullname_buffer,
- &acl_file_buffer);
-
- if (major_status == GSS_S_COMPLETE) {
- strcpy(name, UserNameRequested);
- return(AUTH_VALID);
- } else {
- return(AUTH_USER);
- }
-
-}
-
-#define BUMP(buf, len) while (*(buf)) {++(buf), --(len);}
-#define ADDC(buf, len, c) if ((len) > 0) {*(buf)++ = (c); --(len);}
-
- void
-spx_printsub(data, cnt, buf, buflen)
- unsigned char *data, *buf;
- int cnt, buflen;
-{
- char lbuf[32];
- register int i;
-
- buf[buflen-1] = '\0'; /* make sure its NULL terminated */
- buflen -= 1;
-
- switch(data[3]) {
- case SPX_REJECT: /* Rejected (reason might follow) */
- strncpy((char *)buf, " REJECT ", buflen);
- goto common;
-
- case SPX_ACCEPT: /* Accepted (name might follow) */
- strncpy((char *)buf, " ACCEPT ", buflen);
- common:
- BUMP(buf, buflen);
- if (cnt <= 4)
- break;
- ADDC(buf, buflen, '"');
- for (i = 4; i < cnt; i++)
- ADDC(buf, buflen, data[i]);
- ADDC(buf, buflen, '"');
- ADDC(buf, buflen, '\0');
- break;
-
- case SPX_AUTH: /* Authentication data follows */
- strncpy((char *)buf, " AUTH", buflen);
- goto common2;
-
- default:
- sprintf(lbuf, " %d (unknown)", data[3]);
- strncpy((char *)buf, lbuf, buflen);
- common2:
- BUMP(buf, buflen);
- for (i = 4; i < cnt; i++) {
- sprintf(lbuf, " %d", data[i]);
- strncpy((char *)buf, lbuf, buflen);
- BUMP(buf, buflen);
- }
- break;
- }
-}
-
-#endif
-
-#ifdef notdef
-
-prkey(msg, key)
- char *msg;
- unsigned char *key;
-{
- register int i;
- printf("%s:", msg);
- for (i = 0; i < 8; i++)
- printf(" %3d", key[i]);
- printf("\r\n");
-}
-#endif
diff --git a/contrib/telnet/libtelnet/sra.c b/contrib/telnet/libtelnet/sra.c
deleted file mode 100644
index 44a26f26b220..000000000000
--- a/contrib/telnet/libtelnet/sra.c
+++ /dev/null
@@ -1,478 +0,0 @@
-#ifdef SRA
-#include <sys/types.h>
-#include <arpa/telnet.h>
-#include <stdio.h>
-#ifdef __STDC__
-#include <stdlib.h>
-#endif
-#ifdef NO_STRING_H
-#include <strings.h>
-#else
-#include <string.h>
-#endif
-
-#include "auth.h"
-#include "misc.h"
-#include "encrypt.h"
-#include "pk.h"
-
-char pka[HEXKEYBYTES+1], ska[HEXKEYBYTES+1], pkb[HEXKEYBYTES+1];
-char *user,*pass,*xuser,*xpass;
-DesData ck;
-IdeaData ik;
-
-extern int auth_debug_mode;
-static sra_valid = 0;
-static passwd_sent = 0;
-
-static unsigned char str_data[1024] = { IAC, SB, TELOPT_AUTHENTICATION, 0,
- AUTHTYPE_SRA, };
-
-#define SRA_KEY 0
-#define SRA_USER 1
-#define SRA_CONTINUE 2
-#define SRA_PASS 3
-#define SRA_ACCEPT 4
-#define SRA_REJECT 5
-
-/* support routine to send out authentication message */
-static int Data(ap, type, d, c)
-Authenticator *ap;
-int type;
-void *d;
-int c;
-{
- unsigned char *p = str_data + 4;
- unsigned char *cd = (unsigned char *)d;
-
- if (c == -1)
- c = strlen((char *)cd);
-
- if (auth_debug_mode) {
- printf("%s:%d: [%d] (%d)",
- str_data[3] == TELQUAL_IS ? ">>>IS" : ">>>REPLY",
- str_data[3],
- type, c);
- printd(d, c);
- printf("\r\n");
- }
- *p++ = ap->type;
- *p++ = ap->way;
- *p++ = type;
- while (c-- > 0) {
- if ((*p++ = *cd++) == IAC)
- *p++ = IAC;
- }
- *p++ = IAC;
- *p++ = SE;
- if (str_data[3] == TELQUAL_IS)
- printsub('>', &str_data[2], p - (&str_data[2]));
- return(net_write(str_data, p - str_data));
-}
-
-int sra_init(ap, server)
-Authenticator *ap;
-int server;
-{
- if (server)
- str_data[3] = TELQUAL_REPLY;
- else
- str_data[3] = TELQUAL_IS;
-
- user = (char *)malloc(256);
- xuser = (char *)malloc(512);
- pass = (char *)malloc(256);
- xpass = (char *)malloc(512);
- passwd_sent = 0;
-
- genkeys(pka,ska);
- return(1);
-}
-
-/* client received a go-ahead for sra */
-int sra_send(ap)
-Authenticator *ap;
-{
- /* send PKA */
-
- if (auth_debug_mode)
- printf("Sent PKA to server.\r\n" );
- printf("Trying SRA secure login:\r\n");
- if (!Data(ap, SRA_KEY, (void *)pka, HEXKEYBYTES)) {
- if (auth_debug_mode)
- printf("Not enough room for authentication data\r\n");
- return(0);
- }
-
- return(1);
-}
-
-/* server received an IS -- could be SRA KEY, USER, or PASS */
-void sra_is(ap, data, cnt)
-Authenticator *ap;
-unsigned char *data;
-int cnt;
-{
- int valid;
- Session_Key skey;
-
- if (cnt-- < 1)
- return;
- switch (*data++) {
-
- case SRA_KEY:
- if (cnt < HEXKEYBYTES) {
- Data(ap, SRA_REJECT, (void *)0, 0);
- auth_finished(ap, AUTH_USER);
- if (auth_debug_mode) {
- printf("SRA user rejected for bad PKB\r\n");
- }
- return;
- }
- if (auth_debug_mode)
- printf("Sent pka\r\n");
- if (!Data(ap, SRA_KEY, (void *)pka, HEXKEYBYTES)) {
- if (auth_debug_mode)
- printf("Not enough room\r\n");
- return;
- }
- memcpy(pkb,data,HEXKEYBYTES);
- pkb[HEXKEYBYTES] = '\0';
- common_key(ska,pkb,&ik,&ck);
- break;
-
- case SRA_USER:
- /* decode KAB(u) */
- memcpy(xuser,data,cnt);
- xuser[cnt] = '\0';
- pk_decode(xuser,user,&ck);
- auth_encrypt_user(user);
- Data(ap, SRA_CONTINUE, (void *)0, 0);
-
- break;
-
- case SRA_PASS:
- /* decode KAB(P) */
- memcpy(xpass,data,cnt);
- xpass[cnt] = '\0';
- pk_decode(xpass,pass,&ck);
-
- /* check user's password */
- valid = check_user(user,pass);
-
- if(valid) {
- Data(ap, SRA_ACCEPT, (void *)0, 0);
-#ifdef DES_ENCRYPTION
- skey.data = ck;
- skey.type = SK_DES;
- skey.length = 8;
- encrypt_session_key(&skey, 1);
-#endif
-
- sra_valid = 1;
- auth_finished(ap, AUTH_VALID);
- if (auth_debug_mode) {
- printf("SRA user accepted\r\n");
- }
- }
- else {
- Data(ap, SRA_CONTINUE, (void *)0, 0);
-/*
- Data(ap, SRA_REJECT, (void *)0, 0);
- sra_valid = 0;
- auth_finished(ap, AUTH_REJECT);
-*/
- if (auth_debug_mode) {
- printf("SRA user failed\r\n");
- }
- }
- break;
-
- default:
- if (auth_debug_mode)
- printf("Unknown SRA option %d\r\n", data[-1]);
- Data(ap, SRA_REJECT, 0, 0);
- sra_valid = 0;
- auth_finished(ap, AUTH_REJECT);
- break;
- }
-}
-
-extern char *getpass();
-
-/* client received REPLY -- could be SRA KEY, CONTINUE, ACCEPT, or REJECT */
-void sra_reply(ap, data, cnt)
-Authenticator *ap;
-unsigned char *data;
-int cnt;
-{
- extern char *telnet_gets();
- char uprompt[256],tuser[256];
- Session_Key skey;
- int i;
-
- if (cnt-- < 1)
- return;
- switch (*data++) {
-
- case SRA_KEY:
- /* calculate common key */
- if (cnt < HEXKEYBYTES) {
- if (auth_debug_mode) {
- printf("SRA user rejected for bad PKB\r\n");
- }
- return;
- }
- memcpy(pkb,data,HEXKEYBYTES);
- pkb[HEXKEYBYTES] = '\0';
-
- common_key(ska,pkb,&ik,&ck);
-
- enc_user:
-
- /* encode user */
- memset(tuser,0,sizeof(tuser));
- sprintf(uprompt,"User (%s): ",UserNameRequested);
- telnet_gets(uprompt,tuser,255,1);
- if (tuser[0] == '\n' || tuser[0] == '\r' )
- strcpy(user,UserNameRequested);
- else {
- /* telnet_gets leaves the newline on */
- for(i=0;i<sizeof(tuser);i++) {
- if (tuser[i] == '\n') {
- tuser[i] = '\0';
- break;
- }
- }
- strcpy(user,tuser);
- }
- pk_encode(user,xuser,&ck);
-
- /* send it off */
- if (auth_debug_mode)
- printf("Sent KAB(U)\r\n");
- if (!Data(ap, SRA_USER, (void *)xuser, strlen(xuser))) {
- if (auth_debug_mode)
- printf("Not enough room\r\n");
- return;
- }
- break;
-
- case SRA_CONTINUE:
- if (passwd_sent) {
- passwd_sent = 0;
- printf("[ SRA login failed ]\r\n");
- goto enc_user;
- }
- /* encode password */
- memset(pass,0,sizeof(pass));
- telnet_gets("Password: ",pass,255,0);
- pk_encode(pass,xpass,&ck);
- /* send it off */
- if (auth_debug_mode)
- printf("Sent KAB(P)\r\n");
- if (!Data(ap, SRA_PASS, (void *)xpass, strlen(xpass))) {
- if (auth_debug_mode)
- printf("Not enough room\r\n");
- return;
- }
- passwd_sent = 1;
- break;
-
- case SRA_REJECT:
- printf("[ SRA refuses authentication ]\r\n");
- printf("Trying plaintext login:\r\n");
- auth_finished(0,AUTH_REJECT);
- return;
-
- case SRA_ACCEPT:
- printf("[ SRA accepts you ]\r\n");
-#ifdef DES_ENCRYPTION
- skey.data = ck;
- skey.type = SK_DES;
- skey.length = 8;
- encrypt_session_key(&skey, 0);
-#endif
-
- auth_finished(ap, AUTH_VALID);
- return;
- default:
- if (auth_debug_mode)
- printf("Unknown SRA option %d\r\n", data[-1]);
- return;
- }
-}
-
-int sra_status(ap, name, level)
-Authenticator *ap;
-char *name;
-int level;
-{
- if (level < AUTH_USER)
- return(level);
- if (UserNameRequested && sra_valid) {
- strcpy(name, UserNameRequested);
- return(AUTH_VALID);
- } else
- return(AUTH_USER);
-}
-
-#define BUMP(buf, len) while (*(buf)) {++(buf), --(len);}
-#define ADDC(buf, len, c) if ((len) > 0) {*(buf)++ = (c); --(len);}
-
-void sra_printsub(data, cnt, buf, buflen)
-unsigned char *data, *buf;
-int cnt, buflen;
-{
- char lbuf[32];
- register int i;
-
- buf[buflen-1] = '\0'; /* make sure its NULL terminated */
- buflen -= 1;
-
- switch(data[3]) {
-
- case SRA_CONTINUE:
- strncpy((char *)buf, " CONTINUE ", buflen);
- goto common;
-
- case SRA_REJECT: /* Rejected (reason might follow) */
- strncpy((char *)buf, " REJECT ", buflen);
- goto common;
-
- case SRA_ACCEPT: /* Accepted (name might follow) */
- strncpy((char *)buf, " ACCEPT ", buflen);
-
- common:
- BUMP(buf, buflen);
- if (cnt <= 4)
- break;
- ADDC(buf, buflen, '"');
- for (i = 4; i < cnt; i++)
- ADDC(buf, buflen, data[i]);
- ADDC(buf, buflen, '"');
- ADDC(buf, buflen, '\0');
- break;
-
- case SRA_KEY: /* Authentication data follows */
- strncpy((char *)buf, " KEY ", buflen);
- goto common2;
-
- case SRA_USER:
- strncpy((char *)buf, " USER ", buflen);
- goto common2;
-
- case SRA_PASS:
- strncpy((char *)buf, " PASS ", buflen);
- goto common2;
-
- default:
- sprintf(lbuf, " %d (unknown)", data[3]);
- strncpy((char *)buf, lbuf, buflen);
- common2:
- BUMP(buf, buflen);
- for (i = 4; i < cnt; i++) {
- sprintf(lbuf, " %d", data[i]);
- strncpy((char *)buf, lbuf, buflen);
- BUMP(buf, buflen);
- }
- break;
- }
-}
-
-struct passwd *pw;
-
-/*
- * Helper function for sgetpwnam().
- */
-char *
-sgetsave(s)
- char *s;
-{
- char *new = malloc((unsigned) strlen(s) + 1);
-
- if (new == NULL) {
- return(NULL);
- }
- (void) strcpy(new, s);
- return (new);
-}
-
-#include <pwd.h>
-#include <syslog.h>
-#ifdef USE_SHADOW
-#include <shadow.h>
-#endif
-
-
-struct passwd *
-sgetpwnam(name)
- char *name;
-{
- static struct passwd save;
- register struct passwd *p;
- char *sgetsave();
-
- if ((p = getpwnam(name)) == NULL)
- return (p);
- if (save.pw_name) {
- free(save.pw_name);
- free(save.pw_passwd);
- free(save.pw_gecos);
- free(save.pw_dir);
- free(save.pw_shell);
- }
- save = *p;
- save.pw_name = sgetsave(p->pw_name);
- save.pw_passwd = sgetsave(p->pw_passwd);
- save.pw_gecos = sgetsave(p->pw_gecos);
- save.pw_dir = sgetsave(p->pw_dir);
- save.pw_shell = sgetsave(p->pw_shell);
-#if 0
-syslog(LOG_WARNING,"%s\n",save.pw_name);
-syslog(LOG_WARNING,"%s\n",save.pw_passwd);
-syslog(LOG_WARNING,"%s\n",save.pw_gecos);
-syslog(LOG_WARNING,"%s\n",save.pw_dir);
-#endif
-#ifdef USE_SHADOW
- {
- struct spwd *sp;
- sp = getspnam(name);
- free(save.pw_passwd);
- save.pw_passwd = sgetsave(sp->sp_pwdp);
- }
-#endif
- return (&save);
-}
-
-char *crypt();
-
-int check_user(name, pass)
-char *name;
-char *pass;
-{
- register char *cp;
- char *xpasswd, *salt;
-
- if (pw = sgetpwnam(name)) {
- if (pw->pw_shell == NULL) {
- pw = (struct passwd *) NULL;
- return(0);
- }
-
- salt = pw->pw_passwd;
- xpasswd = crypt(pass, salt);
- /* The strcmp does not catch null passwords! */
- if (pw == NULL || *pw->pw_passwd == '\0' ||
- strcmp(xpasswd, pw->pw_passwd)) {
- pw = (struct passwd *) NULL;
- return(0);
- }
- return(1);
- }
- return(0);
-}
-
-
-#endif
-
diff --git a/contrib/telnet/telnet/authenc.c b/contrib/telnet/telnet/authenc.c
deleted file mode 100644
index f829b1a741a9..000000000000
--- a/contrib/telnet/telnet/authenc.c
+++ /dev/null
@@ -1,111 +0,0 @@
-/*-
- * Copyright (c) 1991, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-static const char sccsid[] = "@(#)authenc.c 8.1 (Berkeley) 6/6/93";
-#endif /* not lint */
-
-#if defined(AUTHENTICATION) || defined(ENCRYPTION)
-#include <sys/types.h>
-#include <arpa/telnet.h>
-#include <libtelnet/encrypt.h>
-#include <libtelnet/misc.h>
-
-#include "general.h"
-#include "ring.h"
-#include "externs.h"
-#include "defines.h"
-#include "types.h"
-
- int
-net_write(str, len)
- unsigned char *str;
- int len;
-{
- if (NETROOM() > len) {
- ring_supply_data(&netoring, str, len);
- if (str[0] == IAC && str[1] == SE)
- printsub('>', &str[2], len-2);
- return(len);
- }
- return(0);
-}
-
- void
-net_encrypt()
-{
-#ifdef ENCRYPTION
- if (encrypt_output)
- ring_encrypt(&netoring, encrypt_output);
- else
- ring_clearto(&netoring);
-#endif /* ENCRYPTION */
-}
-
- int
-telnet_spin()
-{
- return(-1);
-}
-
- char *
-telnet_getenv(val)
- char *val;
-{
- return((char *)env_getvalue((unsigned char *)val));
-}
-
- char *
-telnet_gets(prompt, result, length, echo)
- char *prompt;
- char *result;
- int length;
- int echo;
-{
- extern char *getpass();
- extern int globalmode;
- int om = globalmode;
- char *res;
-
- TerminalNewMode(-1);
- if (echo) {
- printf("%s", prompt);
- res = fgets(result, length, stdin);
- } else if ((res = getpass(prompt))) {
- strncpy(result, res, length);
- res = result;
- }
- TerminalNewMode(om);
- return(res);
-}
-#endif /* defined(AUTHENTICATION) || defined(ENCRYPTION) */
diff --git a/contrib/telnet/telnet/commands.c b/contrib/telnet/telnet/commands.c
deleted file mode 100644
index dadc5e5c8e1b..000000000000
--- a/contrib/telnet/telnet/commands.c
+++ /dev/null
@@ -1,3239 +0,0 @@
-/*
- * Copyright (c) 1988, 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- */
-
-#ifndef lint
-static const char sccsid[] = "@(#)commands.c 8.4 (Berkeley) 5/30/95";
-#endif /* not lint */
-
-#if defined(unix)
-#include <sys/param.h>
-#if defined(CRAY) || defined(sysV88)
-#include <sys/types.h>
-#endif
-#include <sys/file.h>
-#else
-#include <sys/types.h>
-#endif /* defined(unix) */
-#include <sys/socket.h>
-#include <netinet/in.h>
-#ifdef CRAY
-#include <fcntl.h>
-#endif /* CRAY */
-
-#include <signal.h>
-#include <netdb.h>
-#include <ctype.h>
-#include <pwd.h>
-#include <varargs.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdlib.h>
-
-#include <arpa/telnet.h>
-
-#include "general.h"
-
-#include "ring.h"
-
-#include "externs.h"
-#include "defines.h"
-#include "types.h"
-
-#if defined(AUTHENTICATION)
-#include <libtelnet/auth.h>
-#endif
-#if defined(ENCRYPTION)
-#include <libtelnet/encrypt.h>
-#endif
-
-#if !defined(CRAY) && !defined(sysV88)
-#include <netinet/in_systm.h>
-# if (defined(vax) || defined(tahoe) || defined(hp300)) && !defined(ultrix)
-# include <machine/endian.h>
-# endif /* vax */
-#endif /* !defined(CRAY) && !defined(sysV88) */
-#include <netinet/ip.h>
-#include <netinet/ip6.h>
-
-
-#ifndef MAXHOSTNAMELEN
-#define MAXHOSTNAMELEN 64
-#endif MAXHOSTNAMELEN
-
-#if defined(IPPROTO_IP) && defined(IP_TOS)
-int tos = -1;
-#endif /* defined(IPPROTO_IP) && defined(IP_TOS) */
-
-char *hostname;
-static char _hostname[MAXHOSTNAMELEN];
-
-extern char *getenv();
-
-extern int isprefix();
-extern char **genget();
-extern int Ambiguous();
-
-static int help(int argc, char *argv[]);
-static int call();
-static void cmdrc(char *m1, char *m2);
-static int switch_af(struct addrinfo **aip);
-
-int quit(void);
-
-typedef struct {
- char *name; /* command name */
- char *help; /* help string (NULL for no help) */
- int (*handler)(); /* routine which executes command */
- int needconnect; /* Do we need to be connected to execute? */
-} Command;
-
-static char line[256];
-static char saveline[256];
-static int margc;
-static char *margv[20];
-
-#if defined(SKEY)
-#include <sys/wait.h>
-#define PATH_SKEY "/usr/bin/key"
- int
-skey_calc(argc, argv)
- int argc;
- char **argv;
-{
- int status;
-
- if(argc != 3) {
- printf("%s sequence challenge\n", argv[0]);
- return;
- }
-
- switch(fork()) {
- case 0:
- execv(PATH_SKEY, argv);
- exit (1);
- case -1:
- perror("fork");
- break;
- default:
- (void) wait(&status);
- if (WIFEXITED(status))
- return (WEXITSTATUS(status));
- return (0);
- }
-}
-#endif
-
- static void
-makeargv()
-{
- register char *cp, *cp2, c;
- register char **argp = margv;
-
- margc = 0;
- cp = line;
- if (*cp == '!') { /* Special case shell escape */
- strcpy(saveline, line); /* save for shell command */
- *argp++ = "!"; /* No room in string to get this */
- margc++;
- cp++;
- }
- while ((c = *cp)) {
- register int inquote = 0;
- while (isspace(c))
- c = *++cp;
- if (c == '\0')
- break;
- *argp++ = cp;
- margc += 1;
- for (cp2 = cp; c != '\0'; c = *++cp) {
- if (inquote) {
- if (c == inquote) {
- inquote = 0;
- continue;
- }
- } else {
- if (c == '\\') {
- if ((c = *++cp) == '\0')
- break;
- } else if (c == '"') {
- inquote = '"';
- continue;
- } else if (c == '\'') {
- inquote = '\'';
- continue;
- } else if (isspace(c))
- break;
- }
- *cp2++ = c;
- }
- *cp2 = '\0';
- if (c == '\0')
- break;
- cp++;
- }
- *argp++ = 0;
-}
-
-/*
- * Make a character string into a number.
- *
- * Todo: 1. Could take random integers (12, 0x12, 012, 0b1).
- */
-
- static int
-special(s)
- register char *s;
-{
- register char c;
- char b;
-
- switch (*s) {
- case '^':
- b = *++s;
- if (b == '?') {
- c = b | 0x40; /* DEL */
- } else {
- c = b & 0x1f;
- }
- break;
- default:
- c = *s;
- break;
- }
- return c;
-}
-
-/*
- * Construct a control character sequence
- * for a special character.
- */
- static char *
-control(c)
- register cc_t c;
-{
- static char buf[5];
- /*
- * The only way I could get the Sun 3.5 compiler
- * to shut up about
- * if ((unsigned int)c >= 0x80)
- * was to assign "c" to an unsigned int variable...
- * Arggg....
- */
- register unsigned int uic = (unsigned int)c;
-
- if (uic == 0x7f)
- return ("^?");
- if (c == (cc_t)_POSIX_VDISABLE) {
- return "off";
- }
- if (uic >= 0x80) {
- buf[0] = '\\';
- buf[1] = ((c>>6)&07) + '0';
- buf[2] = ((c>>3)&07) + '0';
- buf[3] = (c&07) + '0';
- buf[4] = 0;
- } else if (uic >= 0x20) {
- buf[0] = c;
- buf[1] = 0;
- } else {
- buf[0] = '^';
- buf[1] = '@'+c;
- buf[2] = 0;
- }
- return (buf);
-}
-
-
-
-/*
- * The following are data structures and routines for
- * the "send" command.
- *
- */
-
-struct sendlist {
- char *name; /* How user refers to it (case independent) */
- char *help; /* Help information (0 ==> no help) */
- int needconnect; /* Need to be connected */
- int narg; /* Number of arguments */
- int (*handler)(); /* Routine to perform (for special ops) */
- int nbyte; /* Number of bytes to send this command */
- int what; /* Character to be sent (<0 ==> special) */
-};
-
-
-static int
- send_esc P((void)),
- send_help P((void)),
- send_docmd P((char *)),
- send_dontcmd P((char *)),
- send_willcmd P((char *)),
- send_wontcmd P((char *));
-
-static struct sendlist Sendlist[] = {
- { "ao", "Send Telnet Abort output", 1, 0, 0, 2, AO },
- { "ayt", "Send Telnet 'Are You There'", 1, 0, 0, 2, AYT },
- { "brk", "Send Telnet Break", 1, 0, 0, 2, BREAK },
- { "break", 0, 1, 0, 0, 2, BREAK },
- { "ec", "Send Telnet Erase Character", 1, 0, 0, 2, EC },
- { "el", "Send Telnet Erase Line", 1, 0, 0, 2, EL },
- { "escape", "Send current escape character", 1, 0, send_esc, 1, 0 },
- { "ga", "Send Telnet 'Go Ahead' sequence", 1, 0, 0, 2, GA },
- { "ip", "Send Telnet Interrupt Process", 1, 0, 0, 2, IP },
- { "intp", 0, 1, 0, 0, 2, IP },
- { "interrupt", 0, 1, 0, 0, 2, IP },
- { "intr", 0, 1, 0, 0, 2, IP },
- { "nop", "Send Telnet 'No operation'", 1, 0, 0, 2, NOP },
- { "eor", "Send Telnet 'End of Record'", 1, 0, 0, 2, EOR },
- { "abort", "Send Telnet 'Abort Process'", 1, 0, 0, 2, ABORT },
- { "susp", "Send Telnet 'Suspend Process'", 1, 0, 0, 2, SUSP },
- { "eof", "Send Telnet End of File Character", 1, 0, 0, 2, xEOF },
- { "synch", "Perform Telnet 'Synch operation'", 1, 0, dosynch, 2, 0 },
- { "getstatus", "Send request for STATUS", 1, 0, get_status, 6, 0 },
- { "?", "Display send options", 0, 0, send_help, 0, 0 },
- { "help", 0, 0, 0, send_help, 0, 0 },
- { "do", 0, 0, 1, send_docmd, 3, 0 },
- { "dont", 0, 0, 1, send_dontcmd, 3, 0 },
- { "will", 0, 0, 1, send_willcmd, 3, 0 },
- { "wont", 0, 0, 1, send_wontcmd, 3, 0 },
- { 0 }
-};
-
-#define GETSEND(name) ((struct sendlist *) genget(name, (char **) Sendlist, \
- sizeof(struct sendlist)))
-
- static int
-sendcmd(argc, argv)
- int argc;
- char **argv;
-{
- int count; /* how many bytes we are going to need to send */
- int i;
- struct sendlist *s; /* pointer to current command */
- int success = 0;
- int needconnect = 0;
-
- if (argc < 2) {
- printf("need at least one argument for 'send' command\n");
- printf("'send ?' for help\n");
- return 0;
- }
- /*
- * First, validate all the send arguments.
- * In addition, we see how much space we are going to need, and
- * whether or not we will be doing a "SYNCH" operation (which
- * flushes the network queue).
- */
- count = 0;
- for (i = 1; i < argc; i++) {
- s = GETSEND(argv[i]);
- if (s == 0) {
- printf("Unknown send argument '%s'\n'send ?' for help.\n",
- argv[i]);
- return 0;
- } else if (Ambiguous(s)) {
- printf("Ambiguous send argument '%s'\n'send ?' for help.\n",
- argv[i]);
- return 0;
- }
- if (i + s->narg >= argc) {
- fprintf(stderr,
- "Need %d argument%s to 'send %s' command. 'send %s ?' for help.\n",
- s->narg, s->narg == 1 ? "" : "s", s->name, s->name);
- return 0;
- }
- count += s->nbyte;
- if (s->handler == send_help) {
- send_help();
- return 0;
- }
-
- i += s->narg;
- needconnect += s->needconnect;
- }
- if (!connected && needconnect) {
- printf("?Need to be connected first.\n");
- printf("'send ?' for help\n");
- return 0;
- }
- /* Now, do we have enough room? */
- if (NETROOM() < count) {
- printf("There is not enough room in the buffer TO the network\n");
- printf("to process your request. Nothing will be done.\n");
- printf("('send synch' will throw away most data in the network\n");
- printf("buffer, if this might help.)\n");
- return 0;
- }
- /* OK, they are all OK, now go through again and actually send */
- count = 0;
- for (i = 1; i < argc; i++) {
- if ((s = GETSEND(argv[i])) == 0) {
- fprintf(stderr, "Telnet 'send' error - argument disappeared!\n");
- (void) quit();
- /*NOTREACHED*/
- }
- if (s->handler) {
- count++;
- success += (*s->handler)((s->narg > 0) ? argv[i+1] : 0,
- (s->narg > 1) ? argv[i+2] : 0);
- i += s->narg;
- } else {
- NET2ADD(IAC, s->what);
- printoption("SENT", IAC, s->what);
- }
- }
- return (count == success);
-}
-
- static int
-send_esc()
-{
- NETADD(escape);
- return 1;
-}
-
- static int
-send_docmd(name)
- char *name;
-{
- return(send_tncmd(send_do, "do", name));
-}
-
- static int
-send_dontcmd(name)
- char *name;
-{
- return(send_tncmd(send_dont, "dont", name));
-}
- static int
-send_willcmd(name)
- char *name;
-{
- return(send_tncmd(send_will, "will", name));
-}
- static int
-send_wontcmd(name)
- char *name;
-{
- return(send_tncmd(send_wont, "wont", name));
-}
-
- int
-send_tncmd(func, cmd, name)
- void (*func)();
- char *cmd, *name;
-{
- char **cpp;
- extern char *telopts[];
- register int val = 0;
-
- if (isprefix(name, "help") || isprefix(name, "?")) {
- register int col, len;
-
- printf("Usage: send %s <value|option>\n", cmd);
- printf("\"value\" must be from 0 to 255\n");
- printf("Valid options are:\n\t");
-
- col = 8;
- for (cpp = telopts; *cpp; cpp++) {
- len = strlen(*cpp) + 3;
- if (col + len > 65) {
- printf("\n\t");
- col = 8;
- }
- printf(" \"%s\"", *cpp);
- col += len;
- }
- printf("\n");
- return 0;
- }
- cpp = (char **)genget(name, telopts, sizeof(char *));
- if (Ambiguous(cpp)) {
- fprintf(stderr,"'%s': ambiguous argument ('send %s ?' for help).\n",
- name, cmd);
- return 0;
- }
- if (cpp) {
- val = cpp - telopts;
- } else {
- register char *cp = name;
-
- while (*cp >= '0' && *cp <= '9') {
- val *= 10;
- val += *cp - '0';
- cp++;
- }
- if (*cp != 0) {
- fprintf(stderr, "'%s': unknown argument ('send %s ?' for help).\n",
- name, cmd);
- return 0;
- } else if (val < 0 || val > 255) {
- fprintf(stderr, "'%s': bad value ('send %s ?' for help).\n",
- name, cmd);
- return 0;
- }
- }
- if (!connected) {
- printf("?Need to be connected first.\n");
- return 0;
- }
- (*func)(val, 1);
- return 1;
-}
-
- static int
-send_help()
-{
- struct sendlist *s; /* pointer to current command */
- for (s = Sendlist; s->name; s++) {
- if (s->help)
- printf("%-15s %s\n", s->name, s->help);
- }
- return(0);
-}
-
-/*
- * The following are the routines and data structures referred
- * to by the arguments to the "toggle" command.
- */
-
- static int
-lclchars()
-{
- donelclchars = 1;
- return 1;
-}
-
- static int
-togdebug()
-{
-#ifndef NOT43
- if (net > 0 &&
- (SetSockOpt(net, SOL_SOCKET, SO_DEBUG, debug)) < 0) {
- perror("setsockopt (SO_DEBUG)");
- }
-#else /* NOT43 */
- if (debug) {
- if (net > 0 && SetSockOpt(net, SOL_SOCKET, SO_DEBUG, 1) < 0)
- perror("setsockopt (SO_DEBUG)");
- } else
- printf("Cannot turn off socket debugging\n");
-#endif /* NOT43 */
- return 1;
-}
-
-
- static int
-togcrlf()
-{
- if (crlf) {
- printf("Will send carriage returns as telnet <CR><LF>.\n");
- } else {
- printf("Will send carriage returns as telnet <CR><NUL>.\n");
- }
- return 1;
-}
-
-int binmode;
-
- static int
-togbinary(val)
- int val;
-{
- donebinarytoggle = 1;
-
- if (val >= 0) {
- binmode = val;
- } else {
- if (my_want_state_is_will(TELOPT_BINARY) &&
- my_want_state_is_do(TELOPT_BINARY)) {
- binmode = 1;
- } else if (my_want_state_is_wont(TELOPT_BINARY) &&
- my_want_state_is_dont(TELOPT_BINARY)) {
- binmode = 0;
- }
- val = binmode ? 0 : 1;
- }
-
- if (val == 1) {
- if (my_want_state_is_will(TELOPT_BINARY) &&
- my_want_state_is_do(TELOPT_BINARY)) {
- printf("Already operating in binary mode with remote host.\n");
- } else {
- printf("Negotiating binary mode with remote host.\n");
- tel_enter_binary(3);
- }
- } else {
- if (my_want_state_is_wont(TELOPT_BINARY) &&
- my_want_state_is_dont(TELOPT_BINARY)) {
- printf("Already in network ascii mode with remote host.\n");
- } else {
- printf("Negotiating network ascii mode with remote host.\n");
- tel_leave_binary(3);
- }
- }
- return 1;
-}
-
- static int
-togrbinary(val)
- int val;
-{
- donebinarytoggle = 1;
-
- if (val == -1)
- val = my_want_state_is_do(TELOPT_BINARY) ? 0 : 1;
-
- if (val == 1) {
- if (my_want_state_is_do(TELOPT_BINARY)) {
- printf("Already receiving in binary mode.\n");
- } else {
- printf("Negotiating binary mode on input.\n");
- tel_enter_binary(1);
- }
- } else {
- if (my_want_state_is_dont(TELOPT_BINARY)) {
- printf("Already receiving in network ascii mode.\n");
- } else {
- printf("Negotiating network ascii mode on input.\n");
- tel_leave_binary(1);
- }
- }
- return 1;
-}
-
- static int
-togxbinary(val)
- int val;
-{
- donebinarytoggle = 1;
-
- if (val == -1)
- val = my_want_state_is_will(TELOPT_BINARY) ? 0 : 1;
-
- if (val == 1) {
- if (my_want_state_is_will(TELOPT_BINARY)) {
- printf("Already transmitting in binary mode.\n");
- } else {
- printf("Negotiating binary mode on output.\n");
- tel_enter_binary(2);
- }
- } else {
- if (my_want_state_is_wont(TELOPT_BINARY)) {
- printf("Already transmitting in network ascii mode.\n");
- } else {
- printf("Negotiating network ascii mode on output.\n");
- tel_leave_binary(2);
- }
- }
- return 1;
-}
-
-
-static int togglehelp P((void));
-#if defined(AUTHENTICATION)
-extern int auth_togdebug P((int));
-#endif
-#ifdef ENCRYPTION
-extern int EncryptAutoEnc P((int));
-extern int EncryptAutoDec P((int));
-extern int EncryptDebug P((int));
-extern int EncryptVerbose P((int));
-#endif /* ENCRYPTION */
-
-struct togglelist {
- char *name; /* name of toggle */
- char *help; /* help message */
- int (*handler)(); /* routine to do actual setting */
- int *variable;
- char *actionexplanation;
-};
-
-static struct togglelist Togglelist[] = {
- { "autoflush",
- "flushing of output when sending interrupt characters",
- 0,
- &autoflush,
- "flush output when sending interrupt characters" },
- { "autosynch",
- "automatic sending of interrupt characters in urgent mode",
- 0,
- &autosynch,
- "send interrupt characters in urgent mode" },
-#if defined(AUTHENTICATION)
- { "autologin",
- "automatic sending of login and/or authentication info",
- 0,
- &autologin,
- "send login name and/or authentication information" },
- { "authdebug",
- "Toggle authentication debugging",
- auth_togdebug,
- 0,
- "print authentication debugging information" },
-#endif
-#ifdef ENCRYPTION
- { "autoencrypt",
- "automatic encryption of data stream",
- EncryptAutoEnc,
- 0,
- "automatically encrypt output" },
- { "autodecrypt",
- "automatic decryption of data stream",
- EncryptAutoDec,
- 0,
- "automatically decrypt input" },
- { "verbose_encrypt",
- "Toggle verbose encryption output",
- EncryptVerbose,
- 0,
- "print verbose encryption output" },
- { "encdebug",
- "Toggle encryption debugging",
- EncryptDebug,
- 0,
- "print encryption debugging information" },
-#endif /* ENCRYPTION */
- { "skiprc",
- "don't read ~/.telnetrc file",
- 0,
- &skiprc,
- "skip reading of ~/.telnetrc file" },
- { "binary",
- "sending and receiving of binary data",
- togbinary,
- 0,
- 0 },
- { "inbinary",
- "receiving of binary data",
- togrbinary,
- 0,
- 0 },
- { "outbinary",
- "sending of binary data",
- togxbinary,
- 0,
- 0 },
- { "crlf",
- "sending carriage returns as telnet <CR><LF>",
- togcrlf,
- &crlf,
- 0 },
- { "crmod",
- "mapping of received carriage returns",
- 0,
- &crmod,
- "map carriage return on output" },
- { "localchars",
- "local recognition of certain control characters",
- lclchars,
- &localchars,
- "recognize certain control characters" },
- { " ", "", 0 }, /* empty line */
-#if defined(unix) && defined(TN3270)
- { "apitrace",
- "(debugging) toggle tracing of API transactions",
- 0,
- &apitrace,
- "trace API transactions" },
- { "cursesdata",
- "(debugging) toggle printing of hexadecimal curses data",
- 0,
- &cursesdata,
- "print hexadecimal representation of curses data" },
-#endif /* defined(unix) && defined(TN3270) */
- { "debug",
- "debugging",
- togdebug,
- &debug,
- "turn on socket level debugging" },
- { "netdata",
- "printing of hexadecimal network data (debugging)",
- 0,
- &netdata,
- "print hexadecimal representation of network traffic" },
- { "prettydump",
- "output of \"netdata\" to user readable format (debugging)",
- 0,
- &prettydump,
- "print user readable output for \"netdata\"" },
- { "options",
- "viewing of options processing (debugging)",
- 0,
- &showoptions,
- "show option processing" },
-#if defined(unix)
- { "termdata",
- "(debugging) toggle printing of hexadecimal terminal data",
- 0,
- &termdata,
- "print hexadecimal representation of terminal traffic" },
-#endif /* defined(unix) */
- { "?",
- 0,
- togglehelp },
- { "help",
- 0,
- togglehelp },
- { 0 }
-};
-
- static int
-togglehelp()
-{
- struct togglelist *c;
-
- for (c = Togglelist; c->name; c++) {
- if (c->help) {
- if (*c->help)
- printf("%-15s toggle %s\n", c->name, c->help);
- else
- printf("\n");
- }
- }
- printf("\n");
- printf("%-15s %s\n", "?", "display help information");
- return 0;
-}
-
- static void
-settogglehelp(set)
- int set;
-{
- struct togglelist *c;
-
- for (c = Togglelist; c->name; c++) {
- if (c->help) {
- if (*c->help)
- printf("%-15s %s %s\n", c->name, set ? "enable" : "disable",
- c->help);
- else
- printf("\n");
- }
- }
-}
-
-#define GETTOGGLE(name) (struct togglelist *) \
- genget(name, (char **) Togglelist, sizeof(struct togglelist))
-
- static int
-toggle(argc, argv)
- int argc;
- char *argv[];
-{
- int retval = 1;
- char *name;
- struct togglelist *c;
-
- if (argc < 2) {
- fprintf(stderr,
- "Need an argument to 'toggle' command. 'toggle ?' for help.\n");
- return 0;
- }
- argc--;
- argv++;
- while (argc--) {
- name = *argv++;
- c = GETTOGGLE(name);
- if (Ambiguous(c)) {
- fprintf(stderr, "'%s': ambiguous argument ('toggle ?' for help).\n",
- name);
- return 0;
- } else if (c == 0) {
- fprintf(stderr, "'%s': unknown argument ('toggle ?' for help).\n",
- name);
- return 0;
- } else {
- if (c->variable) {
- *c->variable = !*c->variable; /* invert it */
- if (c->actionexplanation) {
- printf("%s %s.\n", *c->variable? "Will" : "Won't",
- c->actionexplanation);
- }
- }
- if (c->handler) {
- retval &= (*c->handler)(-1);
- }
- }
- }
- return retval;
-}
-
-/*
- * The following perform the "set" command.
- */
-
-#ifdef USE_TERMIO
-struct termio new_tc = { 0 };
-#endif
-
-struct setlist {
- char *name; /* name */
- char *help; /* help information */
- void (*handler)();
- cc_t *charp; /* where it is located at */
-};
-
-static struct setlist Setlist[] = {
-#ifdef KLUDGELINEMODE
- { "echo", "character to toggle local echoing on/off", 0, &echoc },
-#endif
- { "escape", "character to escape back to telnet command mode", 0, &escape },
- { "rlogin", "rlogin escape character", 0, &rlogin },
- { "tracefile", "file to write trace information to", SetNetTrace, (cc_t *)NetTraceFile},
- { " ", "" },
- { " ", "The following need 'localchars' to be toggled true", 0, 0 },
- { "flushoutput", "character to cause an Abort Output", 0, termFlushCharp },
- { "interrupt", "character to cause an Interrupt Process", 0, termIntCharp },
- { "quit", "character to cause an Abort process", 0, termQuitCharp },
- { "eof", "character to cause an EOF ", 0, termEofCharp },
- { " ", "" },
- { " ", "The following are for local editing in linemode", 0, 0 },
- { "erase", "character to use to erase a character", 0, termEraseCharp },
- { "kill", "character to use to erase a line", 0, termKillCharp },
- { "lnext", "character to use for literal next", 0, termLiteralNextCharp },
- { "susp", "character to cause a Suspend Process", 0, termSuspCharp },
- { "reprint", "character to use for line reprint", 0, termRprntCharp },
- { "worderase", "character to use to erase a word", 0, termWerasCharp },
- { "start", "character to use for XON", 0, termStartCharp },
- { "stop", "character to use for XOFF", 0, termStopCharp },
- { "forw1", "alternate end of line character", 0, termForw1Charp },
- { "forw2", "alternate end of line character", 0, termForw2Charp },
- { "ayt", "alternate AYT character", 0, termAytCharp },
- { 0 }
-};
-
-#if defined(CRAY) && !defined(__STDC__)
-/* Work around compiler bug in pcc 4.1.5 */
- void
-_setlist_init()
-{
-#ifndef KLUDGELINEMODE
-#define N 5
-#else
-#define N 6
-#endif
- Setlist[N+0].charp = &termFlushChar;
- Setlist[N+1].charp = &termIntChar;
- Setlist[N+2].charp = &termQuitChar;
- Setlist[N+3].charp = &termEofChar;
- Setlist[N+6].charp = &termEraseChar;
- Setlist[N+7].charp = &termKillChar;
- Setlist[N+8].charp = &termLiteralNextChar;
- Setlist[N+9].charp = &termSuspChar;
- Setlist[N+10].charp = &termRprntChar;
- Setlist[N+11].charp = &termWerasChar;
- Setlist[N+12].charp = &termStartChar;
- Setlist[N+13].charp = &termStopChar;
- Setlist[N+14].charp = &termForw1Char;
- Setlist[N+15].charp = &termForw2Char;
- Setlist[N+16].charp = &termAytChar;
-#undef N
-}
-#endif /* defined(CRAY) && !defined(__STDC__) */
-
- static struct setlist *
-getset(name)
- char *name;
-{
- return (struct setlist *)
- genget(name, (char **) Setlist, sizeof(struct setlist));
-}
-
- void
-set_escape_char(s)
- char *s;
-{
- if (rlogin != _POSIX_VDISABLE) {
- rlogin = (s && *s) ? special(s) : _POSIX_VDISABLE;
- printf("Telnet rlogin escape character is '%s'.\n",
- control(rlogin));
- } else {
- escape = (s && *s) ? special(s) : _POSIX_VDISABLE;
- printf("Telnet escape character is '%s'.\n", control(escape));
- }
-}
-
- static int
-setcmd(argc, argv)
- int argc;
- char *argv[];
-{
- int value;
- struct setlist *ct;
- struct togglelist *c;
-
- if (argc < 2 || argc > 3) {
- printf("Format is 'set Name Value'\n'set ?' for help.\n");
- return 0;
- }
- if ((argc == 2) && (isprefix(argv[1], "?") || isprefix(argv[1], "help"))) {
- for (ct = Setlist; ct->name; ct++)
- printf("%-15s %s\n", ct->name, ct->help);
- printf("\n");
- settogglehelp(1);
- printf("%-15s %s\n", "?", "display help information");
- return 0;
- }
-
- ct = getset(argv[1]);
- if (ct == 0) {
- c = GETTOGGLE(argv[1]);
- if (c == 0) {
- fprintf(stderr, "'%s': unknown argument ('set ?' for help).\n",
- argv[1]);
- return 0;
- } else if (Ambiguous(c)) {
- fprintf(stderr, "'%s': ambiguous argument ('set ?' for help).\n",
- argv[1]);
- return 0;
- }
- if (c->variable) {
- if ((argc == 2) || (strcmp("on", argv[2]) == 0))
- *c->variable = 1;
- else if (strcmp("off", argv[2]) == 0)
- *c->variable = 0;
- else {
- printf("Format is 'set togglename [on|off]'\n'set ?' for help.\n");
- return 0;
- }
- if (c->actionexplanation) {
- printf("%s %s.\n", *c->variable? "Will" : "Won't",
- c->actionexplanation);
- }
- }
- if (c->handler)
- (*c->handler)(1);
- } else if (argc != 3) {
- printf("Format is 'set Name Value'\n'set ?' for help.\n");
- return 0;
- } else if (Ambiguous(ct)) {
- fprintf(stderr, "'%s': ambiguous argument ('set ?' for help).\n",
- argv[1]);
- return 0;
- } else if (ct->handler) {
- (*ct->handler)(argv[2]);
- printf("%s set to \"%s\".\n", ct->name, (char *)ct->charp);
- } else {
- if (strcmp("off", argv[2])) {
- value = special(argv[2]);
- } else {
- value = _POSIX_VDISABLE;
- }
- *(ct->charp) = (cc_t)value;
- printf("%s character is '%s'.\n", ct->name, control(*(ct->charp)));
- }
- slc_check();
- return 1;
-}
-
- static int
-unsetcmd(argc, argv)
- int argc;
- char *argv[];
-{
- struct setlist *ct;
- struct togglelist *c;
- register char *name;
-
- if (argc < 2) {
- fprintf(stderr,
- "Need an argument to 'unset' command. 'unset ?' for help.\n");
- return 0;
- }
- if (isprefix(argv[1], "?") || isprefix(argv[1], "help")) {
- for (ct = Setlist; ct->name; ct++)
- printf("%-15s %s\n", ct->name, ct->help);
- printf("\n");
- settogglehelp(0);
- printf("%-15s %s\n", "?", "display help information");
- return 0;
- }
-
- argc--;
- argv++;
- while (argc--) {
- name = *argv++;
- ct = getset(name);
- if (ct == 0) {
- c = GETTOGGLE(name);
- if (c == 0) {
- fprintf(stderr, "'%s': unknown argument ('unset ?' for help).\n",
- name);
- return 0;
- } else if (Ambiguous(c)) {
- fprintf(stderr, "'%s': ambiguous argument ('unset ?' for help).\n",
- name);
- return 0;
- }
- if (c->variable) {
- *c->variable = 0;
- if (c->actionexplanation) {
- printf("%s %s.\n", *c->variable? "Will" : "Won't",
- c->actionexplanation);
- }
- }
- if (c->handler)
- (*c->handler)(0);
- } else if (Ambiguous(ct)) {
- fprintf(stderr, "'%s': ambiguous argument ('unset ?' for help).\n",
- name);
- return 0;
- } else if (ct->handler) {
- (*ct->handler)(0);
- printf("%s reset to \"%s\".\n", ct->name, (char *)ct->charp);
- } else {
- *(ct->charp) = _POSIX_VDISABLE;
- printf("%s character is '%s'.\n", ct->name, control(*(ct->charp)));
- }
- }
- return 1;
-}
-
-/*
- * The following are the data structures and routines for the
- * 'mode' command.
- */
-#ifdef KLUDGELINEMODE
-extern int kludgelinemode;
-
- static int
-dokludgemode()
-{
- kludgelinemode = 1;
- send_wont(TELOPT_LINEMODE, 1);
- send_dont(TELOPT_SGA, 1);
- send_dont(TELOPT_ECHO, 1);
- return 1;
-}
-#endif
-
- static int
-dolinemode()
-{
-#ifdef KLUDGELINEMODE
- if (kludgelinemode)
- send_dont(TELOPT_SGA, 1);
-#endif
- send_will(TELOPT_LINEMODE, 1);
- send_dont(TELOPT_ECHO, 1);
- return 1;
-}
-
- static int
-docharmode()
-{
-#ifdef KLUDGELINEMODE
- if (kludgelinemode)
- send_do(TELOPT_SGA, 1);
- else
-#endif
- send_wont(TELOPT_LINEMODE, 1);
- send_do(TELOPT_ECHO, 1);
- return 1;
-}
-
- static int
-dolmmode(bit, on)
- int bit, on;
-{
- unsigned char c;
- extern int linemode;
-
- if (my_want_state_is_wont(TELOPT_LINEMODE)) {
- printf("?Need to have LINEMODE option enabled first.\n");
- printf("'mode ?' for help.\n");
- return 0;
- }
-
- if (on)
- c = (linemode | bit);
- else
- c = (linemode & ~bit);
- lm_mode(&c, 1, 1);
- return 1;
-}
-
- int
-setmod(bit)
-{
- return dolmmode(bit, 1);
-}
-
- int
-clearmode(bit)
-{
- return dolmmode(bit, 0);
-}
-
-struct modelist {
- char *name; /* command name */
- char *help; /* help string */
- int (*handler)(); /* routine which executes command */
- int needconnect; /* Do we need to be connected to execute? */
- int arg1;
-};
-
-extern int modehelp();
-
-static struct modelist ModeList[] = {
- { "character", "Disable LINEMODE option", docharmode, 1 },
-#ifdef KLUDGELINEMODE
- { "", "(or disable obsolete line-by-line mode)", 0 },
-#endif
- { "line", "Enable LINEMODE option", dolinemode, 1 },
-#ifdef KLUDGELINEMODE
- { "", "(or enable obsolete line-by-line mode)", 0 },
-#endif
- { "", "", 0 },
- { "", "These require the LINEMODE option to be enabled", 0 },
- { "isig", "Enable signal trapping", setmod, 1, MODE_TRAPSIG },
- { "+isig", 0, setmod, 1, MODE_TRAPSIG },
- { "-isig", "Disable signal trapping", clearmode, 1, MODE_TRAPSIG },
- { "edit", "Enable character editing", setmod, 1, MODE_EDIT },
- { "+edit", 0, setmod, 1, MODE_EDIT },
- { "-edit", "Disable character editing", clearmode, 1, MODE_EDIT },
- { "softtabs", "Enable tab expansion", setmod, 1, MODE_SOFT_TAB },
- { "+softtabs", 0, setmod, 1, MODE_SOFT_TAB },
- { "-softtabs", "Disable character editing", clearmode, 1, MODE_SOFT_TAB },
- { "litecho", "Enable literal character echo", setmod, 1, MODE_LIT_ECHO },
- { "+litecho", 0, setmod, 1, MODE_LIT_ECHO },
- { "-litecho", "Disable literal character echo", clearmode, 1, MODE_LIT_ECHO },
- { "help", 0, modehelp, 0 },
-#ifdef KLUDGELINEMODE
- { "kludgeline", 0, dokludgemode, 1 },
-#endif
- { "", "", 0 },
- { "?", "Print help information", modehelp, 0 },
- { 0 },
-};
-
-
- int
-modehelp()
-{
- struct modelist *mt;
-
- printf("format is: 'mode Mode', where 'Mode' is one of:\n\n");
- for (mt = ModeList; mt->name; mt++) {
- if (mt->help) {
- if (*mt->help)
- printf("%-15s %s\n", mt->name, mt->help);
- else
- printf("\n");
- }
- }
- return 0;
-}
-
-#define GETMODECMD(name) (struct modelist *) \
- genget(name, (char **) ModeList, sizeof(struct modelist))
-
- static int
-modecmd(argc, argv)
- int argc;
- char *argv[];
-{
- struct modelist *mt;
-
- if (argc != 2) {
- printf("'mode' command requires an argument\n");
- printf("'mode ?' for help.\n");
- } else if ((mt = GETMODECMD(argv[1])) == 0) {
- fprintf(stderr, "Unknown mode '%s' ('mode ?' for help).\n", argv[1]);
- } else if (Ambiguous(mt)) {
- fprintf(stderr, "Ambiguous mode '%s' ('mode ?' for help).\n", argv[1]);
- } else if (mt->needconnect && !connected) {
- printf("?Need to be connected first.\n");
- printf("'mode ?' for help.\n");
- } else if (mt->handler) {
- return (*mt->handler)(mt->arg1);
- }
- return 0;
-}
-
-/*
- * The following data structures and routines implement the
- * "display" command.
- */
-
- static int
-display(argc, argv)
- int argc;
- char *argv[];
-{
- struct togglelist *tl;
- struct setlist *sl;
-
-#define dotog(tl) if (tl->variable && tl->actionexplanation) { \
- if (*tl->variable) { \
- printf("will"); \
- } else { \
- printf("won't"); \
- } \
- printf(" %s.\n", tl->actionexplanation); \
- }
-
-#define doset(sl) if (sl->name && *sl->name != ' ') { \
- if (sl->handler == 0) \
- printf("%-15s [%s]\n", sl->name, control(*sl->charp)); \
- else \
- printf("%-15s \"%s\"\n", sl->name, (char *)sl->charp); \
- }
-
- if (argc == 1) {
- for (tl = Togglelist; tl->name; tl++) {
- dotog(tl);
- }
- printf("\n");
- for (sl = Setlist; sl->name; sl++) {
- doset(sl);
- }
- } else {
- int i;
-
- for (i = 1; i < argc; i++) {
- sl = getset(argv[i]);
- tl = GETTOGGLE(argv[i]);
- if (Ambiguous(sl) || Ambiguous(tl)) {
- printf("?Ambiguous argument '%s'.\n", argv[i]);
- return 0;
- } else if (!sl && !tl) {
- printf("?Unknown argument '%s'.\n", argv[i]);
- return 0;
- } else {
- if (tl) {
- dotog(tl);
- }
- if (sl) {
- doset(sl);
- }
- }
- }
- }
-/*@*/optionstatus();
-#ifdef ENCRYPTION
- EncryptStatus();
-#endif /* ENCRYPTION */
- return 1;
-#undef doset
-#undef dotog
-}
-
-/*
- * The following are the data structures, and many of the routines,
- * relating to command processing.
- */
-
-/*
- * Set the escape character.
- */
- static int
-setescape(argc, argv)
- int argc;
- char *argv[];
-{
- register char *arg;
- char buf[50];
-
- printf(
- "Deprecated usage - please use 'set escape%s%s' in the future.\n",
- (argc > 2)? " ":"", (argc > 2)? argv[1]: "");
- if (argc > 2)
- arg = argv[1];
- else {
- printf("new escape character: ");
- (void) fgets(buf, sizeof(buf), stdin);
- arg = buf;
- }
- if (arg[0] != '\0')
- escape = arg[0];
- if (!In3270) {
- printf("Escape character is '%s'.\n", control(escape));
- }
- (void) fflush(stdout);
- return 1;
-}
-
- /*VARARGS*/
- static int
-togcrmod()
-{
- crmod = !crmod;
- printf("Deprecated usage - please use 'toggle crmod' in the future.\n");
- printf("%s map carriage return on output.\n", crmod ? "Will" : "Won't");
- (void) fflush(stdout);
- return 1;
-}
-
- /*VARARGS*/
- int
-suspend()
-{
-#ifdef SIGTSTP
- setcommandmode();
- {
- long oldrows, oldcols, newrows, newcols, err;
-
- err = (TerminalWindowSize(&oldrows, &oldcols) == 0) ? 1 : 0;
- (void) kill(0, SIGTSTP);
- /*
- * If we didn't get the window size before the SUSPEND, but we
- * can get them now (?), then send the NAWS to make sure that
- * we are set up for the right window size.
- */
- if (TerminalWindowSize(&newrows, &newcols) && connected &&
- (err || ((oldrows != newrows) || (oldcols != newcols)))) {
- sendnaws();
- }
- }
- /* reget parameters in case they were changed */
- TerminalSaveState();
- setconnmode(0);
-#else
- printf("Suspend is not supported. Try the '!' command instead\n");
-#endif
- return 1;
-}
-
-#if !defined(TN3270)
- /*ARGSUSED*/
- int
-shell(argc, argv)
- int argc;
- char *argv[];
-{
- long oldrows, oldcols, newrows, newcols, err;
-
- setcommandmode();
-
- err = (TerminalWindowSize(&oldrows, &oldcols) == 0) ? 1 : 0;
- switch(vfork()) {
- case -1:
- perror("Fork failed\n");
- break;
-
- case 0:
- {
- /*
- * Fire up the shell in the child.
- */
- register char *shellp, *shellname;
- extern char *strrchr();
-
- shellp = getenv("SHELL");
- if (shellp == NULL)
- shellp = "/bin/sh";
- if ((shellname = strrchr(shellp, '/')) == 0)
- shellname = shellp;
- else
- shellname++;
- if (argc > 1)
- execl(shellp, shellname, "-c", &saveline[1], 0);
- else
- execl(shellp, shellname, 0);
- perror("Execl");
- _exit(1);
- }
- default:
- (void)wait((int *)0); /* Wait for the shell to complete */
-
- if (TerminalWindowSize(&newrows, &newcols) && connected &&
- (err || ((oldrows != newrows) || (oldcols != newcols)))) {
- sendnaws();
- }
- break;
- }
- return 1;
-}
-#else /* !defined(TN3270) */
-extern int shell();
-#endif /* !defined(TN3270) */
-
- /*VARARGS*/
- static int
-bye(argc, argv)
- int argc; /* Number of arguments */
- char *argv[]; /* arguments */
-{
- extern int resettermname;
-
- if (connected) {
- (void) shutdown(net, 2);
- printf("Connection closed.\n");
- (void) NetClose(net);
- connected = 0;
- resettermname = 1;
-#if defined(AUTHENTICATION) || defined(ENCRYPTION)
- auth_encrypt_connect(connected);
-#endif /* defined(AUTHENTICATION) || defined(ENCRYPTION) */
- /* reset options */
- tninit();
-#if defined(TN3270)
- SetIn3270(); /* Get out of 3270 mode */
-#endif /* defined(TN3270) */
- }
- if ((argc != 2) || (strcmp(argv[1], "fromquit") != 0)) {
- longjmp(toplevel, 1);
- /* NOTREACHED */
- }
- return 1; /* Keep lint, etc., happy */
-}
-
-/*VARARGS*/
- int
-quit()
-{
- (void) call(bye, "bye", "fromquit", 0);
- Exit(0);
- /*NOTREACHED*/
-}
-
-/*VARARGS*/
- int
-logout()
-{
- send_do(TELOPT_LOGOUT, 1);
- (void) netflush();
- return 1;
-}
-
-
-/*
- * The SLC command.
- */
-
-struct slclist {
- char *name;
- char *help;
- void (*handler)();
- int arg;
-};
-
-static void slc_help();
-
-struct slclist SlcList[] = {
- { "export", "Use local special character definitions",
- slc_mode_export, 0 },
- { "import", "Use remote special character definitions",
- slc_mode_import, 1 },
- { "check", "Verify remote special character definitions",
- slc_mode_import, 0 },
- { "help", 0, slc_help, 0 },
- { "?", "Print help information", slc_help, 0 },
- { 0 },
-};
-
- static void
-slc_help()
-{
- struct slclist *c;
-
- for (c = SlcList; c->name; c++) {
- if (c->help) {
- if (*c->help)
- printf("%-15s %s\n", c->name, c->help);
- else
- printf("\n");
- }
- }
-}
-
- static struct slclist *
-getslc(name)
- char *name;
-{
- return (struct slclist *)
- genget(name, (char **) SlcList, sizeof(struct slclist));
-}
-
- static int
-slccmd(argc, argv)
- int argc;
- char *argv[];
-{
- struct slclist *c;
-
- if (argc != 2) {
- fprintf(stderr,
- "Need an argument to 'slc' command. 'slc ?' for help.\n");
- return 0;
- }
- c = getslc(argv[1]);
- if (c == 0) {
- fprintf(stderr, "'%s': unknown argument ('slc ?' for help).\n",
- argv[1]);
- return 0;
- }
- if (Ambiguous(c)) {
- fprintf(stderr, "'%s': ambiguous argument ('slc ?' for help).\n",
- argv[1]);
- return 0;
- }
- (*c->handler)(c->arg);
- slcstate();
- return 1;
-}
-
-/*
- * The ENVIRON command.
- */
-
-struct envlist {
- char *name;
- char *help;
- void (*handler)();
- int narg;
-};
-
-extern struct env_lst *
- env_define P((unsigned char *, unsigned char *));
-extern void
- env_undefine P((unsigned char *)),
- env_export P((unsigned char *)),
- env_unexport P((unsigned char *)),
- env_send P((unsigned char *)),
-#if defined(OLD_ENVIRON) && defined(ENV_HACK)
- env_varval P((unsigned char *)),
-#endif
- env_list P((void));
-static void
- env_help P((void));
-
-struct envlist EnvList[] = {
- { "define", "Define an environment variable",
- (void (*)())env_define, 2 },
- { "undefine", "Undefine an environment variable",
- env_undefine, 1 },
- { "export", "Mark an environment variable for automatic export",
- env_export, 1 },
- { "unexport", "Don't mark an environment variable for automatic export",
- env_unexport, 1 },
- { "send", "Send an environment variable", env_send, 1 },
- { "list", "List the current environment variables",
- env_list, 0 },
-#if defined(OLD_ENVIRON) && defined(ENV_HACK)
- { "varval", "Reverse VAR and VALUE (auto, right, wrong, status)",
- env_varval, 1 },
-#endif
- { "help", 0, env_help, 0 },
- { "?", "Print help information", env_help, 0 },
- { 0 },
-};
-
- static void
-env_help()
-{
- struct envlist *c;
-
- for (c = EnvList; c->name; c++) {
- if (c->help) {
- if (*c->help)
- printf("%-15s %s\n", c->name, c->help);
- else
- printf("\n");
- }
- }
-}
-
- static struct envlist *
-getenvcmd(name)
- char *name;
-{
- return (struct envlist *)
- genget(name, (char **) EnvList, sizeof(struct envlist));
-}
-
- int
-env_cmd(argc, argv)
- int argc;
- char *argv[];
-{
- struct envlist *c;
-
- if (argc < 2) {
- fprintf(stderr,
- "Need an argument to 'environ' command. 'environ ?' for help.\n");
- return 0;
- }
- c = getenvcmd(argv[1]);
- if (c == 0) {
- fprintf(stderr, "'%s': unknown argument ('environ ?' for help).\n",
- argv[1]);
- return 0;
- }
- if (Ambiguous(c)) {
- fprintf(stderr, "'%s': ambiguous argument ('environ ?' for help).\n",
- argv[1]);
- return 0;
- }
- if (c->narg + 2 != argc) {
- fprintf(stderr,
- "Need %s%d argument%s to 'environ %s' command. 'environ ?' for help.\n",
- c->narg < argc + 2 ? "only " : "",
- c->narg, c->narg == 1 ? "" : "s", c->name);
- return 0;
- }
- (*c->handler)(argv[2], argv[3]);
- return 1;
-}
-
-struct env_lst {
- struct env_lst *next; /* pointer to next structure */
- struct env_lst *prev; /* pointer to previous structure */
- unsigned char *var; /* pointer to variable name */
- unsigned char *value; /* pointer to variable value */
- int export; /* 1 -> export with default list of variables */
- int welldefined; /* A well defined variable */
-};
-
-struct env_lst envlisthead;
-
- struct env_lst *
-env_find(var)
- unsigned char *var;
-{
- register struct env_lst *ep;
-
- for (ep = envlisthead.next; ep; ep = ep->next) {
- if (strcmp((char *)ep->var, (char *)var) == 0)
- return(ep);
- }
- return(NULL);
-}
-
- void
-env_init()
-{
- extern char **environ;
- register char **epp, *cp;
- register struct env_lst *ep;
- extern char *strchr();
-
- for (epp = environ; *epp; epp++) {
- if ((cp = strchr(*epp, '='))) {
- *cp = '\0';
- ep = env_define((unsigned char *)*epp,
- (unsigned char *)cp+1);
- ep->export = 0;
- *cp = '=';
- }
- }
- /*
- * Special case for DISPLAY variable. If it is ":0.0" or
- * "unix:0.0", we have to get rid of "unix" and insert our
- * hostname.
- */
- if ((ep = env_find("DISPLAY"))
- && ((*ep->value == ':')
- || (strncmp((char *)ep->value, "unix:", 5) == 0))) {
- char hbuf[256+1];
- char *cp2 = strchr((char *)ep->value, ':');
-
- gethostname(hbuf, 256);
- hbuf[256] = '\0';
- cp = (char *)malloc(strlen(hbuf) + strlen(cp2) + 1);
- sprintf((char *)cp, "%s%s", hbuf, cp2);
- free(ep->value);
- ep->value = (unsigned char *)cp;
- }
- /*
- * If USER is not defined, but LOGNAME is, then add
- * USER with the value from LOGNAME. By default, we
- * don't export the USER variable.
- */
- if ((env_find("USER") == NULL) && (ep = env_find("LOGNAME"))) {
- env_define((unsigned char *)"USER", ep->value);
- env_unexport((unsigned char *)"USER");
- }
- env_export((unsigned char *)"DISPLAY");
- env_export((unsigned char *)"PRINTER");
-}
-
- struct env_lst *
-env_define(var, value)
- unsigned char *var, *value;
-{
- register struct env_lst *ep;
-
- if ((ep = env_find(var))) {
- if (ep->var)
- free(ep->var);
- if (ep->value)
- free(ep->value);
- } else {
- ep = (struct env_lst *)malloc(sizeof(struct env_lst));
- ep->next = envlisthead.next;
- envlisthead.next = ep;
- ep->prev = &envlisthead;
- if (ep->next)
- ep->next->prev = ep;
- }
- ep->welldefined = opt_welldefined(var);
- ep->export = 1;
- ep->var = (unsigned char *)strdup((char *)var);
- ep->value = (unsigned char *)strdup((char *)value);
- return(ep);
-}
-
- void
-env_undefine(var)
- unsigned char *var;
-{
- register struct env_lst *ep;
-
- if ((ep = env_find(var))) {
- ep->prev->next = ep->next;
- if (ep->next)
- ep->next->prev = ep->prev;
- if (ep->var)
- free(ep->var);
- if (ep->value)
- free(ep->value);
- free(ep);
- }
-}
-
- void
-env_export(var)
- unsigned char *var;
-{
- register struct env_lst *ep;
-
- if ((ep = env_find(var)))
- ep->export = 1;
-}
-
- void
-env_unexport(var)
- unsigned char *var;
-{
- register struct env_lst *ep;
-
- if ((ep = env_find(var)))
- ep->export = 0;
-}
-
- void
-env_send(var)
- unsigned char *var;
-{
- register struct env_lst *ep;
-
- if (my_state_is_wont(TELOPT_NEW_ENVIRON)
-#ifdef OLD_ENVIRON
- && my_state_is_wont(TELOPT_OLD_ENVIRON)
-#endif
- ) {
- fprintf(stderr,
- "Cannot send '%s': Telnet ENVIRON option not enabled\n",
- var);
- return;
- }
- ep = env_find(var);
- if (ep == 0) {
- fprintf(stderr, "Cannot send '%s': variable not defined\n",
- var);
- return;
- }
- env_opt_start_info();
- env_opt_add(ep->var);
- env_opt_end(0);
-}
-
- void
-env_list()
-{
- register struct env_lst *ep;
-
- for (ep = envlisthead.next; ep; ep = ep->next) {
- printf("%c %-20s %s\n", ep->export ? '*' : ' ',
- ep->var, ep->value);
- }
-}
-
- unsigned char *
-env_default(init, welldefined)
- int init;
-{
- static struct env_lst *nep = NULL;
-
- if (init) {
- nep = &envlisthead;
- return(NULL);
- }
- if (nep) {
- while ((nep = nep->next)) {
- if (nep->export && (nep->welldefined == welldefined))
- return(nep->var);
- }
- }
- return(NULL);
-}
-
- unsigned char *
-env_getvalue(var)
- unsigned char *var;
-{
- register struct env_lst *ep;
-
- if ((ep = env_find(var)))
- return(ep->value);
- return(NULL);
-}
-
-#if defined(OLD_ENVIRON) && defined(ENV_HACK)
- void
-env_varval(what)
- unsigned char *what;
-{
- extern int old_env_var, old_env_value, env_auto;
- int len = strlen((char *)what);
-
- if (len == 0)
- goto unknown;
-
- if (strncasecmp((char *)what, "status", len) == 0) {
- if (env_auto)
- printf("%s%s", "VAR and VALUE are/will be ",
- "determined automatically\n");
- if (old_env_var == OLD_ENV_VAR)
- printf("VAR and VALUE set to correct definitions\n");
- else
- printf("VAR and VALUE definitions are reversed\n");
- } else if (strncasecmp((char *)what, "auto", len) == 0) {
- env_auto = 1;
- old_env_var = OLD_ENV_VALUE;
- old_env_value = OLD_ENV_VAR;
- } else if (strncasecmp((char *)what, "right", len) == 0) {
- env_auto = 0;
- old_env_var = OLD_ENV_VAR;
- old_env_value = OLD_ENV_VALUE;
- } else if (strncasecmp((char *)what, "wrong", len) == 0) {
- env_auto = 0;
- old_env_var = OLD_ENV_VALUE;
- old_env_value = OLD_ENV_VAR;
- } else {
-unknown:
- printf("Unknown \"varval\" command. (\"auto\", \"right\", \"wrong\", \"status\")\n");
- }
-}
-#endif
-
-#if defined(AUTHENTICATION)
-/*
- * The AUTHENTICATE command.
- */
-
-struct authlist {
- char *name;
- char *help;
- int (*handler)();
- int narg;
-};
-
-extern int
- auth_enable P((char *)),
- auth_disable P((char *)),
- auth_status P((void));
-static int
- auth_help P((void));
-
-struct authlist AuthList[] = {
- { "status", "Display current status of authentication information",
- auth_status, 0 },
- { "disable", "Disable an authentication type ('auth disable ?' for more)",
- auth_disable, 1 },
- { "enable", "Enable an authentication type ('auth enable ?' for more)",
- auth_enable, 1 },
- { "help", 0, auth_help, 0 },
- { "?", "Print help information", auth_help, 0 },
- { 0 },
-};
-
- static int
-auth_help()
-{
- struct authlist *c;
-
- for (c = AuthList; c->name; c++) {
- if (c->help) {
- if (*c->help)
- printf("%-15s %s\n", c->name, c->help);
- else
- printf("\n");
- }
- }
- return 0;
-}
-
- int
-auth_cmd(argc, argv)
- int argc;
- char *argv[];
-{
- struct authlist *c;
-
- if (argc < 2) {
- fprintf(stderr,
- "Need an argument to 'auth' command. 'auth ?' for help.\n");
- return 0;
- }
-
- c = (struct authlist *)
- genget(argv[1], (char **) AuthList, sizeof(struct authlist));
- if (c == 0) {
- fprintf(stderr, "'%s': unknown argument ('auth ?' for help).\n",
- argv[1]);
- return 0;
- }
- if (Ambiguous(c)) {
- fprintf(stderr, "'%s': ambiguous argument ('auth ?' for help).\n",
- argv[1]);
- return 0;
- }
- if (c->narg + 2 != argc) {
- fprintf(stderr,
- "Need %s%d argument%s to 'auth %s' command. 'auth ?' for help.\n",
- c->narg < argc + 2 ? "only " : "",
- c->narg, c->narg == 1 ? "" : "s", c->name);
- return 0;
- }
- return((*c->handler)(argv[2], argv[3]));
-}
-#endif
-
-#ifdef ENCRYPTION
-/*
- * The ENCRYPT command.
- */
-
-struct encryptlist {
- char *name;
- char *help;
- int (*handler)();
- int needconnect;
- int minarg;
- int maxarg;
-};
-
-extern int
- EncryptEnable P((char *, char *)),
- EncryptDisable P((char *, char *)),
- EncryptType P((char *, char *)),
- EncryptStart P((char *)),
- EncryptStartInput P((void)),
- EncryptStartOutput P((void)),
- EncryptStop P((char *)),
- EncryptStopInput P((void)),
- EncryptStopOutput P((void)),
- EncryptStatus P((void));
-static int
- EncryptHelp P((void));
-
-struct encryptlist EncryptList[] = {
- { "enable", "Enable encryption. ('encrypt enable ?' for more)",
- EncryptEnable, 1, 1, 2 },
- { "disable", "Disable encryption. ('encrypt enable ?' for more)",
- EncryptDisable, 0, 1, 2 },
- { "type", "Set encryption type. ('encrypt type ?' for more)",
- EncryptType, 0, 1, 1 },
- { "start", "Start encryption. ('encrypt start ?' for more)",
- EncryptStart, 1, 0, 1 },
- { "stop", "Stop encryption. ('encrypt stop ?' for more)",
- EncryptStop, 1, 0, 1 },
- { "input", "Start encrypting the input stream",
- EncryptStartInput, 1, 0, 0 },
- { "-input", "Stop encrypting the input stream",
- EncryptStopInput, 1, 0, 0 },
- { "output", "Start encrypting the output stream",
- EncryptStartOutput, 1, 0, 0 },
- { "-output", "Stop encrypting the output stream",
- EncryptStopOutput, 1, 0, 0 },
-
- { "status", "Display current status of authentication information",
- EncryptStatus, 0, 0, 0 },
- { "help", 0, EncryptHelp, 0, 0, 0 },
- { "?", "Print help information", EncryptHelp, 0, 0, 0 },
- { 0 },
-};
-
- static int
-EncryptHelp()
-{
- struct encryptlist *c;
-
- for (c = EncryptList; c->name; c++) {
- if (c->help) {
- if (*c->help)
- printf("%-15s %s\n", c->name, c->help);
- else
- printf("\n");
- }
- }
- return 0;
-}
-
- int
-encrypt_cmd(argc, argv)
- int argc;
- char *argv[];
-{
- struct encryptlist *c;
-
- if (argc < 2) {
- fprintf(stderr,
- "Need an argument to 'encrypt' command. 'encrypt ?' for help.\n");
- return 0;
- }
-
- c = (struct encryptlist *)
- genget(argv[1], (char **) EncryptList, sizeof(struct encryptlist));
- if (c == 0) {
- fprintf(stderr, "'%s': unknown argument ('encrypt ?' for help).\n",
- argv[1]);
- return 0;
- }
- if (Ambiguous(c)) {
- fprintf(stderr, "'%s': ambiguous argument ('encrypt ?' for help).\n",
- argv[1]);
- return 0;
- }
- argc -= 2;
- if (argc < c->minarg || argc > c->maxarg) {
- if (c->minarg == c->maxarg) {
- fprintf(stderr, "Need %s%d argument%s ",
- c->minarg < argc ? "only " : "", c->minarg,
- c->minarg == 1 ? "" : "s");
- } else {
- fprintf(stderr, "Need %s%d-%d arguments ",
- c->maxarg < argc ? "only " : "", c->minarg, c->maxarg);
- }
- fprintf(stderr, "to 'encrypt %s' command. 'encrypt ?' for help.\n",
- c->name);
- return 0;
- }
- if (c->needconnect && !connected) {
- if (!(argc && (isprefix(argv[2], "help") || isprefix(argv[2], "?")))) {
- printf("?Need to be connected first.\n");
- return 0;
- }
- }
- return ((*c->handler)(argc > 0 ? argv[2] : 0,
- argc > 1 ? argv[3] : 0,
- argc > 2 ? argv[4] : 0));
-}
-#endif /* ENCRYPTION */
-
-#if defined(unix) && defined(TN3270)
- static void
-filestuff(fd)
- int fd;
-{
- int res;
-
-#ifdef F_GETOWN
- setconnmode(0);
- res = fcntl(fd, F_GETOWN, 0);
- setcommandmode();
-
- if (res == -1) {
- perror("fcntl");
- return;
- }
- printf("\tOwner is %d.\n", res);
-#endif
-
- setconnmode(0);
- res = fcntl(fd, F_GETFL, 0);
- setcommandmode();
-
- if (res == -1) {
- perror("fcntl");
- return;
- }
-#ifdef notdef
- printf("\tFlags are 0x%x: %s\n", res, decodeflags(res));
-#endif
-}
-#endif /* defined(unix) && defined(TN3270) */
-
-/*
- * Print status about the connection.
- */
- /*ARGSUSED*/
- static int
-status(argc, argv)
- int argc;
- char *argv[];
-{
- if (connected) {
- printf("Connected to %s.\n", hostname);
- if ((argc < 2) || strcmp(argv[1], "notmuch")) {
- int mode = getconnmode();
-
- if (my_want_state_is_will(TELOPT_LINEMODE)) {
- printf("Operating with LINEMODE option\n");
- printf("%s line editing\n", (mode&MODE_EDIT) ? "Local" : "No");
- printf("%s catching of signals\n",
- (mode&MODE_TRAPSIG) ? "Local" : "No");
- slcstate();
-#ifdef KLUDGELINEMODE
- } else if (kludgelinemode && my_want_state_is_dont(TELOPT_SGA)) {
- printf("Operating in obsolete linemode\n");
-#endif
- } else {
- printf("Operating in single character mode\n");
- if (localchars)
- printf("Catching signals locally\n");
- }
- printf("%s character echo\n", (mode&MODE_ECHO) ? "Local" : "Remote");
- if (my_want_state_is_will(TELOPT_LFLOW))
- printf("%s flow control\n", (mode&MODE_FLOW) ? "Local" : "No");
-#ifdef ENCRYPTION
- encrypt_display();
-#endif /* ENCRYPTION */
- }
- } else {
- printf("No connection.\n");
- }
-# if !defined(TN3270)
- printf("Escape character is '%s'.\n", control(escape));
- (void) fflush(stdout);
-# else /* !defined(TN3270) */
- if ((!In3270) && ((argc < 2) || strcmp(argv[1], "notmuch"))) {
- printf("Escape character is '%s'.\n", control(escape));
- }
-# if defined(unix)
- if ((argc >= 2) && !strcmp(argv[1], "everything")) {
- printf("SIGIO received %d time%s.\n",
- sigiocount, (sigiocount == 1)? "":"s");
- if (In3270) {
- printf("Process ID %d, process group %d.\n",
- getpid(), getpgrp(getpid()));
- printf("Terminal input:\n");
- filestuff(tin);
- printf("Terminal output:\n");
- filestuff(tout);
- printf("Network socket:\n");
- filestuff(net);
- }
- }
- if (In3270 && transcom) {
- printf("Transparent mode command is '%s'.\n", transcom);
- }
-# endif /* defined(unix) */
- (void) fflush(stdout);
- if (In3270) {
- return 0;
- }
-# endif /* defined(TN3270) */
- return 1;
-}
-
-#ifdef SIGINFO
-/*
- * Function that gets called when SIGINFO is received.
- */
- void
-ayt_status()
-{
- (void) call(status, "status", "notmuch", 0);
-}
-#endif
-
-static const char *
-sockaddr_ntop(sa)
- struct sockaddr *sa;
-{
- void *addr;
- static char addrbuf[INET6_ADDRSTRLEN];
-
- switch (sa->sa_family) {
- case AF_INET:
- addr = &((struct sockaddr_in *)sa)->sin_addr;
- break;
-#ifdef INET6
- case AF_INET6:
- addr = &((struct sockaddr_in6 *)sa)->sin6_addr;
- break;
-#endif
- default:
- return NULL;
- }
- inet_ntop(sa->sa_family, addr, addrbuf, sizeof(addrbuf));
- return addrbuf;
-}
-
-#if defined(IPSEC) && defined(IPSEC_POLICY_IPSEC)
-static int
-setpolicy(net, res, policy)
- int net;
- struct addrinfo *res;
- char *policy;
-{
- char *buf;
- int level;
- int optname;
-
- if (policy == NULL)
- return 0;
-
- buf = ipsec_set_policy(policy, strlen(policy));
- if (buf == NULL) {
- printf("%s\n", ipsec_strerror());
- return -1;
- }
- level = res->ai_family == AF_INET ? IPPROTO_IP : IPPROTO_IPV6;
- optname = res->ai_family == AF_INET ? IP_IPSEC_POLICY : IPV6_IPSEC_POLICY;
- if (setsockopt(net, level, optname, buf, ipsec_get_policylen(buf)) < 0){
- perror("setsockopt");
- return -1;
- }
-
- free(buf);
-}
-#endif
-
-#ifdef INET6
-/*
- * When an Address Family related error happend, check if retry with
- * another AF is possible or not.
- * Return 1, if retry with another af is OK. Else, return 0.
- */
-static int
-switch_af(aip)
- struct addrinfo **aip;
-{
- int nextaf;
- struct addrinfo *ai;
-
- ai = *aip;
- nextaf = (ai->ai_family == AF_INET) ? AF_INET6 : AF_INET;
- do
- ai=ai->ai_next;
- while (ai != NULL && ai->ai_family != nextaf);
- *aip = ai;
- if (*aip != NULL) {
- return 1;
- }
- return 0;
-}
-#endif
-
- int
-tn(argc, argv)
- int argc;
- char *argv[];
-{
- char *srp = 0, *strrchr();
- int proto, opt;
- int sourceroute(), srlen;
- int srcroute = 0, result;
- char *cmd, *hostp = 0, *portp = 0, *user = 0;
- char *src_addr = NULL;
- struct addrinfo hints, *res, *res0 = NULL, *src_res, *src_res0 = NULL;
- int error = 0, af_error = 0;
-
- if (connected) {
- printf("?Already connected to %s\n", hostname);
- setuid(getuid());
- return 0;
- }
- if (argc < 2) {
- (void) strcpy(line, "open ");
- printf("(to) ");
- (void) fgets(&line[strlen(line)], sizeof(line) - strlen(line), stdin);
- makeargv();
- argc = margc;
- argv = margv;
- }
- cmd = *argv;
- --argc; ++argv;
- while (argc) {
- if (strcmp(*argv, "help") == 0 || isprefix(*argv, "?"))
- goto usage;
- if (strcmp(*argv, "-l") == 0) {
- --argc; ++argv;
- if (argc == 0)
- goto usage;
- user = *argv++;
- --argc;
- continue;
- }
- if (strcmp(*argv, "-a") == 0) {
- --argc; ++argv;
- autologin = 1;
- continue;
- }
- if (strcmp(*argv, "-s") == 0) {
- --argc; ++argv;
- if (argc == 0)
- goto usage;
- src_addr = *argv++;
- --argc;
- continue;
- }
- if (hostp == 0) {
- hostp = *argv++;
- --argc;
- continue;
- }
- if (portp == 0) {
- portp = *argv++;
- --argc;
- continue;
- }
- usage:
- printf("usage: %s [-l user] [-a] [-s src_addr] host-name [port]\n", cmd);
- setuid(getuid());
- return 0;
- }
- if (hostp == 0)
- goto usage;
-
- if (src_addr != NULL) {
- memset(&hints, 0, sizeof(hints));
- hints.ai_flags = AI_NUMERICHOST;
- hints.ai_family = family;
- hints.ai_socktype = SOCK_STREAM;
- error = getaddrinfo(src_addr, 0, &hints, &src_res);
- if (error == EAI_NONAME) {
- hints.ai_flags = 0;
- error = getaddrinfo(src_addr, 0, &hints, &src_res);
- }
- if (error != 0) {
- fprintf(stderr, "%s: %s\n", src_addr, gai_strerror(error));
- if (error == EAI_SYSTEM)
- fprintf(stderr, "%s: %s\n", src_addr, strerror(errno));
- setuid(getuid());
- return 0;
- }
- src_res0 = src_res;
- }
- if (hostp[0] == '@' || hostp[0] == '!') {
- if (
-#ifdef INET6
- family == AF_INET6 ||
-#endif
- (hostname = strrchr(hostp, ':')) == NULL)
- hostname = strrchr(hostp, '@');
- hostname++;
- srcroute = 1;
- } else
- hostname = hostp;
- if (!portp) {
- telnetport = 1;
- portp = "telnet";
- } else if (*portp == '-') {
- portp++;
- telnetport = 1;
- } else
- telnetport = 0;
-
- memset(&hints, 0, sizeof(hints));
- hints.ai_flags = AI_NUMERICHOST;
- hints.ai_family = family;
- hints.ai_socktype = SOCK_STREAM;
- error = getaddrinfo(hostname, portp, &hints, &res);
- if (error == 0) {
- int gni_err = 1;
-
- if (doaddrlookup)
- gni_err = getnameinfo(res->ai_addr, res->ai_addr->sa_len,
- _hostname, sizeof(_hostname) - 1, NULL, 0,
- NI_NAMEREQD);
- if (gni_err != 0)
- (void) strncpy(_hostname, hostp, sizeof(_hostname) - 1);
- _hostname[sizeof(_hostname)-1] = '\0';
- hostname = _hostname;
- } else if (error == EAI_NONAME) {
- hints.ai_flags = AI_CANONNAME;
- error = getaddrinfo(hostname, portp, &hints, &res);
- if (error != 0) {
- fprintf(stderr, "%s: %s\n", hostname, gai_strerror(error));
- if (error == EAI_SYSTEM)
- fprintf(stderr, "%s: %s\n", hostname, strerror(errno));
- setuid(getuid());
- goto fail;
- }
- if (srcroute != 0)
- (void) strncpy(_hostname, hostname, sizeof(_hostname) - 1);
- else if (res->ai_canonname != NULL)
- strcpy(_hostname, res->ai_canonname);
- else
- (void) strncpy(_hostname, hostp, sizeof(_hostname) - 1);
- _hostname[sizeof(_hostname)-1] = '\0';
- hostname = _hostname;
- } else if (error != 0) {
- fprintf(stderr, "%s: %s\n", hostname, gai_strerror(error));
- if (error == EAI_SYSTEM)
- fprintf(stderr, "%s: %s\n", hostname, strerror(errno));
- setuid(getuid());
- goto fail;
- }
- res0 = res;
- af_again:
- if (srcroute != 0) {
- static char hostbuf[BUFSIZ];
-
- if (af_error == 0) { /* save intermediate hostnames for retry */
- strncpy(hostbuf, hostp, BUFSIZ - 1);
- hostbuf[BUFSIZ - 1] = '\0';
- } else
- hostp = hostbuf;
- srp = 0;
- result = sourceroute(res, hostp, &srp, &srlen, &proto, &opt);
- if (result == 0) {
-#ifdef INET6
- if (family == AF_UNSPEC && af_error == 0 &&
- switch_af(&res) == 1) {
- af_error = 1;
- goto af_again;
- }
-#endif
- setuid(getuid());
- goto fail;
- } else if (result == -1) {
- printf("Bad source route option: %s\n", hostp);
- setuid(getuid());
- goto fail;
- }
- }
- do {
- printf("Trying %s...\n", sockaddr_ntop(res->ai_addr));
- net = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
- setuid(getuid());
- if (net < 0) {
-#ifdef INET6
- if (family == AF_UNSPEC && af_error == 0 &&
- switch_af(&res) == 1) {
- af_error = 1;
- goto af_again;
- }
-#endif
- perror("telnet: socket");
- goto fail;
- }
- if (srp && setsockopt(net, proto, opt, (char *)srp, srlen) < 0)
- perror("setsockopt (source route)");
-#if defined(IPPROTO_IP) && defined(IP_TOS)
- if (res->ai_family == PF_INET) {
-# if defined(HAS_GETTOS)
- struct tosent *tp;
- if (tos < 0 && (tp = gettosbyname("telnet", "tcp")))
- tos = tp->t_tos;
-# endif
- if (tos < 0)
- tos = 020; /* Low Delay bit */
- if (tos
- && (setsockopt(net, IPPROTO_IP, IP_TOS,
- (char *)&tos, sizeof(int)) < 0)
- && (errno != ENOPROTOOPT))
- perror("telnet: setsockopt (IP_TOS) (ignored)");
- }
-#endif /* defined(IPPROTO_IP) && defined(IP_TOS) */
-
- if (debug && SetSockOpt(net, SOL_SOCKET, SO_DEBUG, 1) < 0) {
- perror("setsockopt (SO_DEBUG)");
- }
-
- if (src_addr != NULL) {
- for (src_res = src_res0; src_res != 0; src_res = src_res->ai_next)
- if (src_res->ai_family == res->ai_family)
- break;
- if (src_res == NULL)
- src_res = src_res0;
- if (bind(net, src_res->ai_addr, src_res->ai_addrlen) == -1) {
-#ifdef INET6
- if (family == AF_UNSPEC && af_error == 0 &&
- switch_af(&res) == 1) {
- af_error = 1;
- (void) NetClose(net);
- goto af_again;
- }
-#endif
- perror("bind");
- (void) NetClose(net);
- goto fail;
- }
- }
-#if defined(IPSEC) && defined(IPSEC_POLICY_IPSEC)
- if (setpolicy(net, res, ipsec_policy_in) < 0) {
- (void) NetClose(net);
- goto fail;
- }
- if (setpolicy(net, res, ipsec_policy_out) < 0) {
- (void) NetClose(net);
- goto fail;
- }
-#endif
-
- if (connect(net, res->ai_addr, res->ai_addrlen) < 0) {
- struct addrinfo *next;
-
- next = res->ai_next;
- /* If already an af failed, only try same af. */
- if (af_error != 0)
- while (next != NULL && next->ai_family != res->ai_family)
- next = next->ai_next;
- warn("connect to address %s", sockaddr_ntop(res->ai_addr));
- if (next != NULL) {
- res = next;
- (void) NetClose(net);
- continue;
- }
- warnx("Unable to connect to remote host");
- (void) NetClose(net);
- goto fail;
- }
- connected++;
-#if defined(AUTHENTICATION) || defined(ENCRYPTION)
- auth_encrypt_connect(connected);
-#endif /* defined(AUTHENTICATION) || defined(ENCRYPTION) */
- } while (connected == 0);
- freeaddrinfo(res0);
- if (src_res0 != NULL)
- freeaddrinfo(src_res0);
- cmdrc(hostp, hostname);
- if (autologin && user == NULL) {
- struct passwd *pw;
-
- user = getenv("USER");
- if (user == NULL ||
- ((pw = getpwnam(user)) && pw->pw_uid != getuid())) {
- if ((pw = getpwuid(getuid())))
- user = pw->pw_name;
- else
- user = NULL;
- }
- }
- if (user) {
- env_define((unsigned char *)"USER", (unsigned char *)user);
- env_export((unsigned char *)"USER");
- }
- (void) call(status, "status", "notmuch", 0);
- if (setjmp(peerdied) == 0)
- telnet(user);
- (void) NetClose(net);
- ExitString("Connection closed by foreign host.\n",1);
- /*NOTREACHED*/
- fail:
- if (res0 != NULL)
- freeaddrinfo(res0);
- if (src_res0 != NULL)
- freeaddrinfo(src_res0);
- return 0;
-}
-
-#define HELPINDENT (sizeof ("connect"))
-
-static char
- openhelp[] = "connect to a site",
- closehelp[] = "close current connection",
- logouthelp[] = "forcibly logout remote user and close the connection",
- quithelp[] = "exit telnet",
- statushelp[] = "print status information",
- helphelp[] = "print help information",
- sendhelp[] = "transmit special characters ('send ?' for more)",
- sethelp[] = "set operating parameters ('set ?' for more)",
- unsethelp[] = "unset operating parameters ('unset ?' for more)",
- togglestring[] ="toggle operating parameters ('toggle ?' for more)",
- slchelp[] = "change state of special charaters ('slc ?' for more)",
- displayhelp[] = "display operating parameters",
-#if defined(TN3270) && defined(unix)
- transcomhelp[] = "specify Unix command for transparent mode pipe",
-#endif /* defined(TN3270) && defined(unix) */
-#if defined(AUTHENTICATION)
- authhelp[] = "turn on (off) authentication ('auth ?' for more)",
-#endif
-#ifdef ENCRYPTION
- encrypthelp[] = "turn on (off) encryption ('encrypt ?' for more)",
-#endif /* ENCRYPTION */
-#if defined(unix)
- zhelp[] = "suspend telnet",
-#endif /* defined(unix) */
-#if defined(SKEY)
- skeyhelp[] = "compute response to s/key challenge",
-#endif
- shellhelp[] = "invoke a subshell",
- envhelp[] = "change environment variables ('environ ?' for more)",
- modestring[] = "try to enter line or character mode ('mode ?' for more)";
-
-static Command cmdtab[] = {
- { "close", closehelp, bye, 1 },
- { "logout", logouthelp, logout, 1 },
- { "display", displayhelp, display, 0 },
- { "mode", modestring, modecmd, 0 },
- { "open", openhelp, tn, 0 },
- { "quit", quithelp, quit, 0 },
- { "send", sendhelp, sendcmd, 0 },
- { "set", sethelp, setcmd, 0 },
- { "unset", unsethelp, unsetcmd, 0 },
- { "status", statushelp, status, 0 },
- { "toggle", togglestring, toggle, 0 },
- { "slc", slchelp, slccmd, 0 },
-#if defined(TN3270) && defined(unix)
- { "transcom", transcomhelp, settranscom, 0 },
-#endif /* defined(TN3270) && defined(unix) */
-#if defined(AUTHENTICATION)
- { "auth", authhelp, auth_cmd, 0 },
-#endif
-#ifdef ENCRYPTION
- { "encrypt", encrypthelp, encrypt_cmd, 0 },
-#endif /* ENCRYPTION */
-#if defined(unix)
- { "z", zhelp, suspend, 0 },
-#endif /* defined(unix) */
-#if defined(TN3270)
- { "!", shellhelp, shell, 1 },
-#else
- { "!", shellhelp, shell, 0 },
-#endif
- { "environ", envhelp, env_cmd, 0 },
- { "?", helphelp, help, 0 },
-#if defined(SKEY)
- { "skey", skeyhelp, skey_calc, 0 },
-#endif
- { 0, 0, 0, 0 }
-};
-
-static char crmodhelp[] = "deprecated command -- use 'toggle crmod' instead";
-static char escapehelp[] = "deprecated command -- use 'set escape' instead";
-
-static Command cmdtab2[] = {
- { "help", 0, help, 0 },
- { "escape", escapehelp, setescape, 0 },
- { "crmod", crmodhelp, togcrmod, 0 },
- { 0, 0, 0, 0 }
-};
-
-
-/*
- * Call routine with argc, argv set from args (terminated by 0).
- */
-
- /*VARARGS1*/
- static int
-call(va_alist)
- va_dcl
-{
- va_list ap;
- typedef int (*intrtn_t)();
- intrtn_t routine;
- char *args[100];
- int argno = 0;
-
- va_start(ap);
- routine = (va_arg(ap, intrtn_t));
- while ((args[argno++] = va_arg(ap, char *)) != 0) {
- ;
- }
- va_end(ap);
- return (*routine)(argno-1, args);
-}
-
-
- static Command *
-getcmd(name)
- char *name;
-{
- Command *cm;
-
- if ((cm = (Command *) genget(name, (char **) cmdtab, sizeof(Command))))
- return cm;
- return (Command *) genget(name, (char **) cmdtab2, sizeof(Command));
-}
-
- void
-command(top, tbuf, cnt)
- int top;
- char *tbuf;
- int cnt;
-{
- register Command *c;
-
- setcommandmode();
- if (!top) {
- putchar('\n');
-#if defined(unix)
- } else {
- (void) signal(SIGINT, SIG_DFL);
- (void) signal(SIGQUIT, SIG_DFL);
-#endif /* defined(unix) */
- }
- for (;;) {
- if (rlogin == _POSIX_VDISABLE)
- printf("%s> ", prompt);
- if (tbuf) {
- register char *cp;
- cp = line;
- while (cnt > 0 && (*cp++ = *tbuf++) != '\n')
- cnt--;
- tbuf = 0;
- if (cp == line || *--cp != '\n' || cp == line)
- goto getline;
- *cp = '\0';
- if (rlogin == _POSIX_VDISABLE)
- printf("%s\n", line);
- } else {
- getline:
- if (rlogin != _POSIX_VDISABLE)
- printf("%s> ", prompt);
- if (fgets(line, sizeof(line), stdin) == NULL) {
- if (feof(stdin) || ferror(stdin)) {
- (void) quit();
- /*NOTREACHED*/
- }
- break;
- }
- }
- if (line[0] == 0)
- break;
- makeargv();
- if (margv[0] == 0) {
- break;
- }
- c = getcmd(margv[0]);
- if (Ambiguous(c)) {
- printf("?Ambiguous command\n");
- continue;
- }
- if (c == 0) {
- printf("?Invalid command\n");
- continue;
- }
- if (c->needconnect && !connected) {
- printf("?Need to be connected first.\n");
- continue;
- }
- if ((*c->handler)(margc, margv)) {
- break;
- }
- }
- if (!top) {
- if (!connected) {
- longjmp(toplevel, 1);
- /*NOTREACHED*/
- }
-#if defined(TN3270)
- if (shell_active == 0) {
- setconnmode(0);
- }
-#else /* defined(TN3270) */
- setconnmode(0);
-#endif /* defined(TN3270) */
- }
-}
-
-/*
- * Help command.
- */
- static int
-help(argc, argv)
- int argc;
- char *argv[];
-{
- register Command *c;
-
- if (argc == 1) {
- printf("Commands may be abbreviated. Commands are:\n\n");
- for (c = cmdtab; c->name; c++)
- if (c->help) {
- printf("%-*s\t%s\n", HELPINDENT, c->name,
- c->help);
- }
- }
- else while (--argc > 0) {
- register char *arg;
- arg = *++argv;
- c = getcmd(arg);
- if (Ambiguous(c))
- printf("?Ambiguous help command %s\n", arg);
- else if (c == (Command *)0)
- printf("?Invalid help command %s\n", arg);
- else
- printf("%s\n", c->help);
- }
- return(0);
-}
-
-static char *rcname = 0;
-static char rcbuf[128];
-
- void
-cmdrc(m1, m2)
- char *m1, *m2;
-{
- register Command *c;
- FILE *rcfile;
- int gotmachine = 0;
- int l1 = strlen(m1);
- int l2 = strlen(m2);
- char m1save[64];
-
- if (skiprc)
- return;
-
- strcpy(m1save, m1);
- m1 = m1save;
-
- if (rcname == 0) {
- rcname = getenv("HOME");
- if (rcname && (strlen(rcname) + 10) < sizeof(rcbuf))
- strcpy(rcbuf, rcname);
- else
- rcbuf[0] = '\0';
- strcat(rcbuf, "/.telnetrc");
- rcname = rcbuf;
- }
-
- if ((rcfile = fopen(rcname, "r")) == 0) {
- return;
- }
-
- for (;;) {
- if (fgets(line, sizeof(line), rcfile) == NULL)
- break;
- if (line[0] == 0)
- break;
- if (line[0] == '#')
- continue;
- if (gotmachine) {
- if (!isspace(line[0]))
- gotmachine = 0;
- }
- if (gotmachine == 0) {
- if (isspace(line[0]))
- continue;
- if (strncasecmp(line, m1, l1) == 0)
- strncpy(line, &line[l1], sizeof(line) - l1);
- else if (strncasecmp(line, m2, l2) == 0)
- strncpy(line, &line[l2], sizeof(line) - l2);
- else if (strncasecmp(line, "DEFAULT", 7) == 0)
- strncpy(line, &line[7], sizeof(line) - 7);
- else
- continue;
- if (line[0] != ' ' && line[0] != '\t' && line[0] != '\n')
- continue;
- gotmachine = 1;
- }
- makeargv();
- if (margv[0] == 0)
- continue;
- c = getcmd(margv[0]);
- if (Ambiguous(c)) {
- printf("?Ambiguous command: %s\n", margv[0]);
- continue;
- }
- if (c == 0) {
- printf("?Invalid command: %s\n", margv[0]);
- continue;
- }
- /*
- * This should never happen...
- */
- if (c->needconnect && !connected) {
- printf("?Need to be connected first for %s.\n", margv[0]);
- continue;
- }
- (*c->handler)(margc, margv);
- }
- fclose(rcfile);
-}
-
-/*
- * Source route is handed in as
- * [!]@hop1@hop2...[@|:]dst
- * If the leading ! is present, it is a
- * strict source route, otherwise it is
- * assmed to be a loose source route.
- *
- * We fill in the source route option as
- * hop1,hop2,hop3...dest
- * and return a pointer to hop1, which will
- * be the address to connect() to.
- *
- * Arguments:
- *
- * res: ponter to addrinfo structure which contains sockaddr to
- * the host to connect to.
- *
- * arg: pointer to route list to decipher
- *
- * cpp: If *cpp is not equal to NULL, this is a
- * pointer to a pointer to a character array
- * that should be filled in with the option.
- *
- * lenp: pointer to an integer that contains the
- * length of *cpp if *cpp != NULL.
- *
- * protop: pointer to an integer that should be filled in with
- * appropriate protocol for setsockopt, as socket
- * protocol family.
- *
- * optp: pointer to an integer that should be filled in with
- * appropriate option for setsockopt, as socket protocol
- * family.
- *
- * Return values:
- *
- * If the return value is 1, then all operations are
- * successful. If the
- * return value is -1, there was a syntax error in the
- * option, either unknown characters, or too many hosts.
- * If the return value is 0, one of the hostnames in the
- * path is unknown, and *cpp is set to point to the bad
- * hostname.
- *
- * *cpp: If *cpp was equal to NULL, it will be filled
- * in with a pointer to our static area that has
- * the option filled in. This will be 32bit aligned.
- *
- * *lenp: This will be filled in with how long the option
- * pointed to by *cpp is.
- *
- * *protop: This will be filled in with appropriate protocol for
- * setsockopt, as socket protocol family.
- *
- * *optp: This will be filled in with appropriate option for
- * setsockopt, as socket protocol family.
- */
-int
-sourceroute(ai, arg, cpp, lenp, protop, optp)
- struct addrinfo *ai;
- char *arg;
- char **cpp;
- int *lenp;
- int *protop;
- int *optp;
-{
- static char buf[1024]; /*XXX*/
- struct cmsghdr *cmsg;
-#ifdef sysV88
- static IOPTN ipopt;
-#endif
- char *cp, *cp2, *lsrp, *ep;
- register int tmp;
- struct sockaddr_in *sin;
- struct sockaddr_in6 *sin6;
- struct addrinfo hints, *res;
- int error;
- register char c;
-
- /*
- * Verify the arguments, and make sure we have
- * at least 7 bytes for the option.
- */
- if (cpp == NULL || lenp == NULL)
- return -1;
- if (*cpp != NULL) {
- switch (res->ai_family) {
- case AF_INET:
- if (*lenp < 7)
- return -1;
- break;
-#ifdef INET6
- case AF_INET6:
- if (*lenp < CMSG_SPACE(sizeof(struct ip6_rthdr) +
- sizeof(struct in6_addr)))
- return -1;
- break;
-#endif
- }
- }
- /*
- * Decide whether we have a buffer passed to us,
- * or if we need to use our own static buffer.
- */
- if (*cpp) {
- lsrp = *cpp;
- ep = lsrp + *lenp;
- } else {
- *cpp = lsrp = ALIGN(buf);
- ep = lsrp + 1024;
- }
-
- cp = arg;
-
-#ifdef INET6
- if (ai->ai_family == AF_INET6) {
- cmsg = inet6_rthdr_init(*cpp, IPV6_RTHDR_TYPE_0);
- if (*cp != '@')
- return -1;
- *protop = IPPROTO_IPV6;
- *optp = IPV6_PKTOPTIONS;
- } else
-#endif
- {
- /*
- * Next, decide whether we have a loose source
- * route or a strict source route, and fill in
- * the begining of the option.
- */
-#ifndef sysV88
- if (*cp == '!') {
- cp++;
- *lsrp++ = IPOPT_SSRR;
- } else
- *lsrp++ = IPOPT_LSRR;
-#else
- if (*cp == '!') {
- cp++;
- ipopt.io_type = IPOPT_SSRR;
- } else
- ipopt.io_type = IPOPT_LSRR;
-#endif
-
- if (*cp != '@')
- return -1;
-
-#ifndef sysV88
- lsrp++; /* skip over length, we'll fill it in later */
- *lsrp++ = 4;
-#endif
- *protop = IPPROTO_IP;
- *optp = IP_OPTIONS;
- }
-
- cp++;
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = ai->ai_family;
- hints.ai_socktype = SOCK_STREAM;
- for (c = 0;;) {
- if (
-#ifdef INET6
- ai->ai_family != AF_INET6 &&
-#endif
- c == ':')
- cp2 = 0;
- else for (cp2 = cp; (c = *cp2); cp2++) {
- if (c == ',') {
- *cp2++ = '\0';
- if (*cp2 == '@')
- cp2++;
- } else if (c == '@') {
- *cp2++ = '\0';
- } else if (
-#ifdef INET6
- ai->ai_family != AF_INET6 &&
-#endif
- c == ':') {
- *cp2++ = '\0';
- } else
- continue;
- break;
- }
- if (!c)
- cp2 = 0;
-
- hints.ai_flags = AI_NUMERICHOST;
- error = getaddrinfo(cp, NULL, &hints, &res);
- if (error == EAI_NONAME) {
- hints.ai_flags = 0;
- error = getaddrinfo(cp, NULL, &hints, &res);
- }
- if (error != 0) {
- fprintf(stderr, "%s: %s\n", cp, gai_strerror(error));
- if (error == EAI_SYSTEM)
- fprintf(stderr, "%s: %s\n", cp,
- strerror(errno));
- *cpp = cp;
- return(0);
- }
-#ifdef INET6
- if (res->ai_family == AF_INET6) {
- sin6 = (struct sockaddr_in6 *)res->ai_addr;
- inet6_rthdr_add(cmsg, &sin6->sin6_addr,
- IPV6_RTHDR_LOOSE);
- } else
-#endif
- {
- sin = (struct sockaddr_in *)res->ai_addr;
- memcpy(lsrp, (char *)&sin->sin_addr, 4);
- lsrp += 4;
- }
- if (cp2)
- cp = cp2;
- else
- break;
- /*
- * Check to make sure there is space for next address
- */
-#ifdef INET6
- if (res->ai_family == AF_INET6) {
- if (((char *)CMSG_DATA(cmsg) +
- sizeof(struct ip6_rthdr) +
- ((inet6_rthdr_segments(cmsg) + 1) *
- sizeof(struct in6_addr))) > ep)
- return -1;
- } else
-#endif
- if (lsrp + 4 > ep)
- return -1;
- freeaddrinfo(res);
- }
-#ifdef INET6
- if (res->ai_family == AF_INET6) {
- inet6_rthdr_lasthop(cmsg, IPV6_RTHDR_LOOSE);
- *lenp = cmsg->cmsg_len;
- } else
-#endif
- {
-#ifndef sysV88
- if ((*(*cpp+IPOPT_OLEN) = lsrp - *cpp) <= 7) {
- *cpp = 0;
- *lenp = 0;
- return -1;
- }
- *lsrp++ = IPOPT_NOP; /* 32 bit word align it */
- *lenp = lsrp - *cpp;
-#else
- ipopt.io_len = lsrp - *cpp;
- if (ipopt.io_len <= 5) { /* Is 3 better ? */
- *cpp = 0;
- *lenp = 0;
- return -1;
- }
- *lenp = sizeof(ipopt);
- *cpp = (char *) &ipopt;
-#endif
- }
- freeaddrinfo(res);
- return 1;
-}
-
-
-
diff --git a/contrib/telnet/telnet/defines.h b/contrib/telnet/telnet/defines.h
deleted file mode 100644
index 0978173ea995..000000000000
--- a/contrib/telnet/telnet/defines.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)defines.h 8.1 (Berkeley) 6/6/93
- */
-
-#define settimer(x) clocks.x = clocks.system++
-
-#if !defined(TN3270)
-
-#define SetIn3270()
-
-#endif /* !defined(TN3270) */
-
-#define NETADD(c) { *netoring.supply = c; ring_supplied(&netoring, 1); }
-#define NET2ADD(c1,c2) { NETADD(c1); NETADD(c2); }
-#define NETBYTES() (ring_full_count(&netoring))
-#define NETROOM() (ring_empty_count(&netoring))
-
-#define TTYADD(c) if (!(SYNCHing||flushout)) { \
- *ttyoring.supply = c; \
- ring_supplied(&ttyoring, 1); \
- }
-#define TTYBYTES() (ring_full_count(&ttyoring))
-#define TTYROOM() (ring_empty_count(&ttyoring))
-
-/* Various modes */
-#define MODE_LOCAL_CHARS(m) ((m)&(MODE_EDIT|MODE_TRAPSIG))
-#define MODE_LOCAL_ECHO(m) ((m)&MODE_ECHO)
-#define MODE_COMMAND_LINE(m) ((m)==-1)
-
-#define CONTROL(x) ((x)&0x1f) /* CTRL(x) is not portable */
diff --git a/contrib/telnet/telnet/externs.h b/contrib/telnet/telnet/externs.h
deleted file mode 100644
index 46253d9a6048..000000000000
--- a/contrib/telnet/telnet/externs.h
+++ /dev/null
@@ -1,502 +0,0 @@
-/*
- * Copyright (c) 1988, 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)externs.h 8.3 (Berkeley) 5/30/95
- * $FreeBSD$
- */
-
-#ifndef BSD
-# define BSD 43
-#endif
-
-/*
- * ucb stdio.h defines BSD as something wierd
- */
-#if defined(sun) && defined(__svr4__)
-#define BSD 43
-#endif
-
-#ifndef USE_TERMIO
-# if BSD > 43 || defined(SYSV_TERMIO)
-# define USE_TERMIO
-# endif
-#endif
-
-#include <stdio.h>
-#include <setjmp.h>
-#if defined(CRAY) && !defined(NO_BSD_SETJMP)
-#include <bsdsetjmp.h>
-#endif
-#ifndef FILIO_H
-#include <sys/ioctl.h>
-#else
-#include <sys/filio.h>
-#endif
-#ifdef CRAY
-# include <errno.h>
-#endif /* CRAY */
-#ifdef USE_TERMIO
-# ifndef VINTR
-# ifdef SYSV_TERMIO
-# include <sys/termio.h>
-# else
-# include <sys/termios.h>
-# define termio termios
-# endif
-# endif
-#endif
-#if defined(NO_CC_T) || !defined(USE_TERMIO)
-# if !defined(USE_TERMIO)
-typedef char cc_t;
-# else
-typedef unsigned char cc_t;
-# endif
-#endif
-
-#ifndef NO_STRING_H
-#include <string.h>
-#else
-#include <strings.h>
-#endif
-
-#if defined(IPSEC)
-#include <netinet6/ipsec.h>
-#if defined(IPSEC_POLICY_IPSEC)
-extern char *ipsec_policy_in;
-extern char *ipsec_policy_out;
-#endif
-#endif
-
-#ifndef _POSIX_VDISABLE
-# ifdef sun
-# include <sys/param.h> /* pick up VDISABLE definition, mayby */
-# endif
-# ifdef VDISABLE
-# define _POSIX_VDISABLE VDISABLE
-# else
-# define _POSIX_VDISABLE ((cc_t)'\377')
-# endif
-#endif
-
-#define SUBBUFSIZE 256
-
-#ifndef CRAY
-extern int errno; /* outside this world */
-#endif /* !CRAY */
-
-#if !defined(P)
-# ifdef __STDC__
-# define P(x) x
-# else
-# define P(x) ()
-# endif
-#endif
-
-extern int
- autologin, /* Autologin enabled */
- skiprc, /* Don't process the ~/.telnetrc file */
- eight, /* use eight bit mode (binary in and/or out */
- family, /* address family of peer */
- flushout, /* flush output */
- connected, /* Are we connected to the other side? */
- globalmode, /* Mode tty should be in */
- In3270, /* Are we in 3270 mode? */
- telnetport, /* Are we connected to the telnet port? */
- localflow, /* Flow control handled locally */
- restartany, /* If flow control, restart output on any character */
- localchars, /* we recognize interrupt/quit */
- donelclchars, /* the user has set "localchars" */
- showoptions,
- net, /* Network file descriptor */
- tin, /* Terminal input file descriptor */
- tout, /* Terminal output file descriptor */
- crlf, /* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */
- autoflush, /* flush output when interrupting? */
- autosynch, /* send interrupt characters with SYNCH? */
- SYNCHing, /* Is the stream in telnet SYNCH mode? */
- donebinarytoggle, /* the user has put us in binary */
- dontlecho, /* do we suppress local echoing right now? */
- crmod,
- netdata, /* Print out network data flow */
- prettydump, /* Print "netdata" output in user readable format */
-#if defined(unix)
-#if defined(TN3270)
- cursesdata, /* Print out curses data flow */
- apitrace, /* Trace API transactions */
-#endif /* defined(TN3270) */
- termdata, /* Print out terminal data flow */
-#endif /* defined(unix) */
- debug, /* Debug level */
- doaddrlookup, /* do a reverse lookup? */
- clienteof; /* Client received EOF */
-
-extern cc_t escape; /* Escape to command mode */
-extern cc_t rlogin; /* Rlogin mode escape character */
-#ifdef KLUDGELINEMODE
-extern cc_t echoc; /* Toggle local echoing */
-#endif
-
-extern char
- *prompt; /* Prompt for command. */
-
-extern char
- doopt[],
- dont[],
- will[],
- wont[],
- options[], /* All the little options */
- *hostname; /* Who are we connected to? */
-#ifdef ENCRYPTION
-extern void (*encrypt_output) P((unsigned char *, int));
-extern int (*decrypt_input) P((int));
-#endif /* ENCRYPTION */
-
-/*
- * We keep track of each side of the option negotiation.
- */
-
-#define MY_STATE_WILL 0x01
-#define MY_WANT_STATE_WILL 0x02
-#define MY_STATE_DO 0x04
-#define MY_WANT_STATE_DO 0x08
-
-/*
- * Macros to check the current state of things
- */
-
-#define my_state_is_do(opt) (options[opt]&MY_STATE_DO)
-#define my_state_is_will(opt) (options[opt]&MY_STATE_WILL)
-#define my_want_state_is_do(opt) (options[opt]&MY_WANT_STATE_DO)
-#define my_want_state_is_will(opt) (options[opt]&MY_WANT_STATE_WILL)
-
-#define my_state_is_dont(opt) (!my_state_is_do(opt))
-#define my_state_is_wont(opt) (!my_state_is_will(opt))
-#define my_want_state_is_dont(opt) (!my_want_state_is_do(opt))
-#define my_want_state_is_wont(opt) (!my_want_state_is_will(opt))
-
-#define set_my_state_do(opt) {options[opt] |= MY_STATE_DO;}
-#define set_my_state_will(opt) {options[opt] |= MY_STATE_WILL;}
-#define set_my_want_state_do(opt) {options[opt] |= MY_WANT_STATE_DO;}
-#define set_my_want_state_will(opt) {options[opt] |= MY_WANT_STATE_WILL;}
-
-#define set_my_state_dont(opt) {options[opt] &= ~MY_STATE_DO;}
-#define set_my_state_wont(opt) {options[opt] &= ~MY_STATE_WILL;}
-#define set_my_want_state_dont(opt) {options[opt] &= ~MY_WANT_STATE_DO;}
-#define set_my_want_state_wont(opt) {options[opt] &= ~MY_WANT_STATE_WILL;}
-
-/*
- * Make everything symetrical
- */
-
-#define HIS_STATE_WILL MY_STATE_DO
-#define HIS_WANT_STATE_WILL MY_WANT_STATE_DO
-#define HIS_STATE_DO MY_STATE_WILL
-#define HIS_WANT_STATE_DO MY_WANT_STATE_WILL
-
-#define his_state_is_do my_state_is_will
-#define his_state_is_will my_state_is_do
-#define his_want_state_is_do my_want_state_is_will
-#define his_want_state_is_will my_want_state_is_do
-
-#define his_state_is_dont my_state_is_wont
-#define his_state_is_wont my_state_is_dont
-#define his_want_state_is_dont my_want_state_is_wont
-#define his_want_state_is_wont my_want_state_is_dont
-
-#define set_his_state_do set_my_state_will
-#define set_his_state_will set_my_state_do
-#define set_his_want_state_do set_my_want_state_will
-#define set_his_want_state_will set_my_want_state_do
-
-#define set_his_state_dont set_my_state_wont
-#define set_his_state_wont set_my_state_dont
-#define set_his_want_state_dont set_my_want_state_wont
-#define set_his_want_state_wont set_my_want_state_dont
-
-
-extern FILE
- *NetTrace; /* Where debugging output goes */
-extern unsigned char
- NetTraceFile[]; /* Name of file where debugging output goes */
-extern void
- SetNetTrace P((char *)); /* Function to change where debugging goes */
-
-extern jmp_buf
- peerdied,
- toplevel; /* For error conditions. */
-
-extern void
- command P((int, char *, int)),
- Dump P((int, unsigned char *, int)),
- ExitString P((char *, int)),
- init_3270 P((void)),
- printoption P((char *, int, int)),
- printsub P((int, unsigned char *, int)),
- sendnaws P((void)),
- setconnmode P((int)),
- setcommandmode P((void)),
- setneturg P((void)),
- sys_telnet_init P((void)),
- telnet P((char *)),
- tel_enter_binary P((int)),
- TerminalFlushOutput P((void)),
- TerminalNewMode P((int)),
- TerminalRestoreState P((void)),
- TerminalSaveState P((void)),
- tninit P((void)),
- upcase P((char *)),
- willoption P((int)),
- wontoption P((int));
-
-extern void
- send_do P((int, int)),
- send_dont P((int, int)),
- send_will P((int, int)),
- send_wont P((int, int));
-
-extern void
- lm_will P((unsigned char *, int)),
- lm_wont P((unsigned char *, int)),
- lm_do P((unsigned char *, int)),
- lm_dont P((unsigned char *, int)),
- lm_mode P((unsigned char *, int, int));
-
-extern void
- slc_init P((void)),
- slcstate P((void)),
- slc_mode_export P((void)),
- slc_mode_import P((int)),
- slc_import P((int)),
- slc_export P((void)),
- slc P((unsigned char *, int)),
- slc_check P((void)),
- slc_start_reply P((void)),
- slc_add_reply P((int, int, int)),
- slc_end_reply P((void));
-extern int
- NetClose P((int)),
- netflush P((void)),
- SetSockOpt P((int, int, int, int)),
- slc_update P((void)),
- telrcv P((void)),
- TerminalWrite P((char *, int)),
- TerminalAutoFlush P((void)),
- ttyflush P((int));
-
-extern void
- env_opt P((unsigned char *, int)),
- env_opt_start P((void)),
- env_opt_start_info P((void)),
- env_opt_add P((unsigned char *)),
- env_opt_end P((int));
-
-extern unsigned char
- *env_default P((int, int)),
- *env_getvalue P((unsigned char *));
-
-extern int
- get_status P((void)),
- dosynch P((void));
-
-extern cc_t
- *tcval P((int));
-
-#ifndef USE_TERMIO
-
-extern struct tchars ntc;
-extern struct ltchars nltc;
-extern struct sgttyb nttyb;
-
-# define termEofChar ntc.t_eofc
-# define termEraseChar nttyb.sg_erase
-# define termFlushChar nltc.t_flushc
-# define termIntChar ntc.t_intrc
-# define termKillChar nttyb.sg_kill
-# define termLiteralNextChar nltc.t_lnextc
-# define termQuitChar ntc.t_quitc
-# define termSuspChar nltc.t_suspc
-# define termRprntChar nltc.t_rprntc
-# define termWerasChar nltc.t_werasc
-# define termStartChar ntc.t_startc
-# define termStopChar ntc.t_stopc
-# define termForw1Char ntc.t_brkc
-extern cc_t termForw2Char;
-extern cc_t termAytChar;
-
-# define termEofCharp (cc_t *)&ntc.t_eofc
-# define termEraseCharp (cc_t *)&nttyb.sg_erase
-# define termFlushCharp (cc_t *)&nltc.t_flushc
-# define termIntCharp (cc_t *)&ntc.t_intrc
-# define termKillCharp (cc_t *)&nttyb.sg_kill
-# define termLiteralNextCharp (cc_t *)&nltc.t_lnextc
-# define termQuitCharp (cc_t *)&ntc.t_quitc
-# define termSuspCharp (cc_t *)&nltc.t_suspc
-# define termRprntCharp (cc_t *)&nltc.t_rprntc
-# define termWerasCharp (cc_t *)&nltc.t_werasc
-# define termStartCharp (cc_t *)&ntc.t_startc
-# define termStopCharp (cc_t *)&ntc.t_stopc
-# define termForw1Charp (cc_t *)&ntc.t_brkc
-# define termForw2Charp (cc_t *)&termForw2Char
-# define termAytCharp (cc_t *)&termAytChar
-
-# else
-
-extern struct termio new_tc;
-
-# define termEofChar new_tc.c_cc[VEOF]
-# define termEraseChar new_tc.c_cc[VERASE]
-# define termIntChar new_tc.c_cc[VINTR]
-# define termKillChar new_tc.c_cc[VKILL]
-# define termQuitChar new_tc.c_cc[VQUIT]
-
-# ifndef VSUSP
-extern cc_t termSuspChar;
-# else
-# define termSuspChar new_tc.c_cc[VSUSP]
-# endif
-# if defined(VFLUSHO) && !defined(VDISCARD)
-# define VDISCARD VFLUSHO
-# endif
-# ifndef VDISCARD
-extern cc_t termFlushChar;
-# else
-# define termFlushChar new_tc.c_cc[VDISCARD]
-# endif
-# ifndef VWERASE
-extern cc_t termWerasChar;
-# else
-# define termWerasChar new_tc.c_cc[VWERASE]
-# endif
-# ifndef VREPRINT
-extern cc_t termRprntChar;
-# else
-# define termRprntChar new_tc.c_cc[VREPRINT]
-# endif
-# ifndef VLNEXT
-extern cc_t termLiteralNextChar;
-# else
-# define termLiteralNextChar new_tc.c_cc[VLNEXT]
-# endif
-# ifndef VSTART
-extern cc_t termStartChar;
-# else
-# define termStartChar new_tc.c_cc[VSTART]
-# endif
-# ifndef VSTOP
-extern cc_t termStopChar;
-# else
-# define termStopChar new_tc.c_cc[VSTOP]
-# endif
-# ifndef VEOL
-extern cc_t termForw1Char;
-# else
-# define termForw1Char new_tc.c_cc[VEOL]
-# endif
-# ifndef VEOL2
-extern cc_t termForw2Char;
-# else
-# define termForw2Char new_tc.c_cc[VEOL]
-# endif
-# ifndef VSTATUS
-extern cc_t termAytChar;
-#else
-# define termAytChar new_tc.c_cc[VSTATUS]
-#endif
-
-# if !defined(CRAY) || defined(__STDC__)
-# define termEofCharp &termEofChar
-# define termEraseCharp &termEraseChar
-# define termIntCharp &termIntChar
-# define termKillCharp &termKillChar
-# define termQuitCharp &termQuitChar
-# define termSuspCharp &termSuspChar
-# define termFlushCharp &termFlushChar
-# define termWerasCharp &termWerasChar
-# define termRprntCharp &termRprntChar
-# define termLiteralNextCharp &termLiteralNextChar
-# define termStartCharp &termStartChar
-# define termStopCharp &termStopChar
-# define termForw1Charp &termForw1Char
-# define termForw2Charp &termForw2Char
-# define termAytCharp &termAytChar
-# else
- /* Work around a compiler bug */
-# define termEofCharp 0
-# define termEraseCharp 0
-# define termIntCharp 0
-# define termKillCharp 0
-# define termQuitCharp 0
-# define termSuspCharp 0
-# define termFlushCharp 0
-# define termWerasCharp 0
-# define termRprntCharp 0
-# define termLiteralNextCharp 0
-# define termStartCharp 0
-# define termStopCharp 0
-# define termForw1Charp 0
-# define termForw2Charp 0
-# define termAytCharp 0
-# endif
-#endif
-
-
-/* Ring buffer structures which are shared */
-
-extern Ring
- netoring,
- netiring,
- ttyoring,
- ttyiring;
-
-/* Tn3270 section */
-#if defined(TN3270)
-
-extern int
- HaveInput, /* Whether an asynchronous I/O indication came in */
- noasynchtty, /* Don't do signals on I/O (SIGURG, SIGIO) */
- noasynchnet, /* Don't do signals on I/O (SIGURG, SIGIO) */
- sigiocount, /* Count of SIGIO receptions */
- shell_active; /* Subshell is active */
-
-extern char
- *Ibackp, /* Oldest byte of 3270 data */
- Ibuf[], /* 3270 buffer */
- *Ifrontp, /* Where next 3270 byte goes */
- tline[],
- *transcom; /* Transparent command */
-
-extern int
- settranscom P((int, char**));
-
-extern void
- inputAvailable P((int));
-#endif /* defined(TN3270) */
diff --git a/contrib/telnet/telnet/fdset.h b/contrib/telnet/telnet/fdset.h
deleted file mode 100644
index 045bb7221419..000000000000
--- a/contrib/telnet/telnet/fdset.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)fdset.h 8.1 (Berkeley) 6/6/93
- */
-
-/*
- * The following is defined just in case someone should want to run
- * this telnet on a 4.2 system.
- *
- */
-
-#ifndef FD_SETSIZE
-
-#define FD_SET(n, p) ((p)->fds_bits[0] |= (1<<(n)))
-#define FD_CLR(n, p) ((p)->fds_bits[0] &= ~(1<<(n)))
-#define FD_ISSET(n, p) ((p)->fds_bits[0] & (1<<(n)))
-#define FD_ZERO(p) ((p)->fds_bits[0] = 0)
-
-#endif
diff --git a/contrib/telnet/telnet/general.h b/contrib/telnet/telnet/general.h
deleted file mode 100644
index 4efa9519469e..000000000000
--- a/contrib/telnet/telnet/general.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)general.h 8.1 (Berkeley) 6/6/93
- */
-
-/*
- * Some general definitions.
- */
-
-
-#define numberof(x) (sizeof x/sizeof x[0])
-#define highestof(x) (numberof(x)-1)
-
-#define ClearElement(x) memset((char *)&x, 0, sizeof x)
-#define ClearArray(x) memset((char *)x, 0, sizeof x)
diff --git a/contrib/telnet/telnet/main.c b/contrib/telnet/telnet/main.c
deleted file mode 100644
index c3d0f5d74ba9..000000000000
--- a/contrib/telnet/telnet/main.c
+++ /dev/null
@@ -1,389 +0,0 @@
-/*
- * Copyright (c) 1988, 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- */
-
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1988, 1990, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static const char sccsid[] = "@(#)main.c 8.3 (Berkeley) 5/30/95";
-#endif /* not lint */
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <stdlib.h>
-
-#include "ring.h"
-#include "externs.h"
-#include "defines.h"
-
-#if defined(AUTHENTICATION)
-#include <libtelnet/auth.h>
-#endif
-#if defined(ENCRYPTION)
-#include <libtelnet/encrypt.h>
-#endif
-
-/* These values need to be the same as defined in libtelnet/kerberos5.c */
-/* Either define them in both places, or put in some common header file. */
-#define OPTS_FORWARD_CREDS 0x00000002
-#define OPTS_FORWARDABLE_CREDS 0x00000001
-
-#if 0
-#define FORWARD
-#endif
-
-void init_terminal(void);
-void init_network(void);
-void init_telnet(void);
-void init_sys(void);
-void init_3270(void);
-
-#if defined(IPSEC) && defined(IPSEC_POLICY_IPSEC)
-char *ipsec_policy_in = NULL;
-char *ipsec_policy_out = NULL;
-#endif
-
-int family = AF_UNSPEC;
-
-/*
- * Initialize variables.
- */
- void
-tninit()
-{
- init_terminal();
-
- init_network();
-
- init_telnet();
-
- init_sys();
-
-#if defined(TN3270)
- init_3270();
-#endif
-}
-
- void
-usage()
-{
- fprintf(stderr, "Usage: %s %s%s%s%s\n",
- prompt,
-#ifdef AUTHENTICATION
- "[-4] [-6] [-8] [-E] [-K] [-L] [-N] [-S tos] [-X atype] [-a] [-c] [-d]",
- "\n\t[-e char] [-k realm] [-l user] [-f/-F] [-n tracefile] ",
-#else
- "[-4] [-6] [-8] [-E] [-L] [-N] [-S tos] [-a] [-c] [-d] [-e char] [-l user]",
- "\n\t[-n tracefile] ",
-#endif
-#if defined(TN3270) && defined(unix)
-# ifdef AUTHENTICATION
- "[-noasynch] [-noasynctty]\n\t"
- "[-noasyncnet] [-r] [-s src_addr] [-t transcom] ",
-# else
- "[-noasynch] [-noasynctty] [-noasyncnet] [-r]\n\t"
- "[-s src_addr] [-t transcom]",
-# endif
-#else
- "[-r] [-s src_addr] ",
-#endif
-#if defined(IPSEC) && defined(IPSEC_POLICY_IPSEC)
- "[-P policy]"
-#endif
-#ifdef ENCRYPTION
- "[-x] [host-name [port]]"
-#else /* ENCRYPTION */
- "[host-name [port]]"
-#endif /* ENCRYPTION */
- );
- exit(1);
-}
-
-/*
- * main. Parse arguments, invoke the protocol or command parser.
- */
-
- int
-main(argc, argv)
- int argc;
- char *argv[];
-{
- extern char *optarg;
- extern int optind;
- int ch;
- char *user, *strrchr();
- char *src_addr = NULL;
-#ifdef FORWARD
- extern int forward_flags;
-#endif /* FORWARD */
-
- tninit(); /* Clear out things */
-#if defined(CRAY) && !defined(__STDC__)
- _setlist_init(); /* Work around compiler bug */
-#endif
-
- TerminalSaveState();
-
- if ((prompt = strrchr(argv[0], '/')))
- ++prompt;
- else
- prompt = argv[0];
-
- user = NULL;
-
- rlogin = (strncmp(prompt, "rlog", 4) == 0) ? '~' : _POSIX_VDISABLE;
- autologin = -1;
-
-#if defined(IPSEC) && defined(IPSEC_POLICY_IPSEC)
-#define IPSECOPT "P:"
-#else
-#define IPSECOPT
-#endif
- while ((ch = getopt(argc, argv,
- "468EKLNS:X:acde:fFk:l:n:rs:t:x" IPSECOPT)) != -1)
-#undef IPSECOPT
- {
- switch(ch) {
- case '4':
- family = AF_INET;
- break;
-#ifdef INET6
- case '6':
- family = AF_INET6;
- break;
-#endif
- case '8':
- eight = 3; /* binary output and input */
- break;
- case 'E':
- rlogin = escape = _POSIX_VDISABLE;
- break;
- case 'K':
-#ifdef AUTHENTICATION
- autologin = 0;
-#endif
- break;
- case 'L':
- eight |= 2; /* binary output only */
- break;
- case 'N':
- doaddrlookup = 0;
- break;
- case 'S':
- {
-#ifdef HAS_GETTOS
- extern int tos;
-
- if ((tos = parsetos(optarg, "tcp")) < 0)
- fprintf(stderr, "%s%s%s%s\n",
- prompt, ": Bad TOS argument '",
- optarg,
- "; will try to use default TOS");
-#else
- fprintf(stderr,
- "%s: Warning: -S ignored, no parsetos() support.\n",
- prompt);
-#endif
- }
- break;
- case 'X':
-#ifdef AUTHENTICATION
- auth_disable_name(optarg);
-#endif
- break;
- case 'a':
- autologin = 1;
- break;
- case 'c':
- skiprc = 1;
- break;
- case 'd':
- debug = 1;
- break;
- case 'e':
- set_escape_char(optarg);
- break;
- case 'f':
-#if defined(AUTHENTICATION) && defined(KRB5) && defined(FORWARD)
- if (forward_flags & OPTS_FORWARD_CREDS) {
- fprintf(stderr,
- "%s: Only one of -f and -F allowed.\n",
- prompt);
- usage();
- }
- forward_flags |= OPTS_FORWARD_CREDS;
-#else
- fprintf(stderr,
- "%s: Warning: -f ignored, no Kerberos V5 support.\n",
- prompt);
-#endif
- break;
- case 'F':
-#if defined(AUTHENTICATION) && defined(KRB5) && defined(FORWARD)
- if (forward_flags & OPTS_FORWARD_CREDS) {
- fprintf(stderr,
- "%s: Only one of -f and -F allowed.\n",
- prompt);
- usage();
- }
- forward_flags |= OPTS_FORWARD_CREDS;
- forward_flags |= OPTS_FORWARDABLE_CREDS;
-#else
- fprintf(stderr,
- "%s: Warning: -F ignored, no Kerberos V5 support.\n",
- prompt);
-#endif
- break;
- case 'k':
-#if defined(AUTHENTICATION) && defined(KRB4)
- {
- extern char *dest_realm, dst_realm_buf[], dst_realm_sz;
- dest_realm = dst_realm_buf;
- (void)strncpy(dest_realm, optarg, dst_realm_sz);
- }
-#else
- fprintf(stderr,
- "%s: Warning: -k ignored, no Kerberos V4 support.\n",
- prompt);
-#endif
- break;
- case 'l':
- autologin = 1;
- user = optarg;
- break;
- case 'n':
-#if defined(TN3270) && defined(unix)
- /* distinguish between "-n oasynch" and "-noasynch" */
- if (argv[optind - 1][0] == '-' && argv[optind - 1][1]
- == 'n' && argv[optind - 1][2] == 'o') {
- if (!strcmp(optarg, "oasynch")) {
- noasynchtty = 1;
- noasynchnet = 1;
- } else if (!strcmp(optarg, "oasynchtty"))
- noasynchtty = 1;
- else if (!strcmp(optarg, "oasynchnet"))
- noasynchnet = 1;
- } else
-#endif /* defined(TN3270) && defined(unix) */
- SetNetTrace(optarg);
- break;
- case 'r':
- rlogin = '~';
- break;
- case 's':
- src_addr = optarg;
- break;
- case 't':
-#if defined(TN3270) && defined(unix)
- transcom = tline;
- (void)strcpy(transcom, optarg);
-#else
- fprintf(stderr,
- "%s: Warning: -t ignored, no TN3270 support.\n",
- prompt);
-#endif
- break;
- case 'x':
-#ifdef ENCRYPTION
- encrypt_auto(1);
- decrypt_auto(1);
-#else /* ENCRYPTION */
- fprintf(stderr,
- "%s: Warning: -x ignored, no ENCRYPT support.\n",
- prompt);
-#endif /* ENCRYPTION */
- break;
-#if defined(IPSEC) && defined(IPSEC_POLICY_IPSEC)
- case 'P':
- if (!strncmp("in", optarg, 2))
- ipsec_policy_in = strdup(optarg);
- else if (!strncmp("out", optarg, 3))
- ipsec_policy_out = strdup(optarg);
- else
- usage();
- break;
-#endif
- case '?':
- default:
- usage();
- /* NOTREACHED */
- }
- }
- if (autologin == -1)
- autologin = (rlogin == _POSIX_VDISABLE) ? 0 : 1;
-
- argc -= optind;
- argv += optind;
-
- if (argc) {
- char *args[9], **argp = args;
-
- if (argc > 2)
- usage();
- *argp++ = prompt;
- if (user) {
- *argp++ = "-l";
- *argp++ = user;
- }
- if (src_addr) {
- *argp++ = "-s";
- *argp++ = src_addr;
- }
- *argp++ = argv[0]; /* host */
- if (argc > 1)
- *argp++ = argv[1]; /* port */
- *argp = 0;
-
- if (setjmp(toplevel) != 0)
- Exit(0);
- if (tn(argp - args, args) == 1)
- return (0);
- else
- return (1);
- }
- (void)setjmp(toplevel);
- for (;;) {
-#ifdef TN3270
- if (shell_active)
- shell_continue();
- else
-#endif
- command(1, 0, 0);
- }
- return 0;
-}
diff --git a/contrib/telnet/telnet/network.c b/contrib/telnet/telnet/network.c
deleted file mode 100644
index 9964bc205cef..000000000000
--- a/contrib/telnet/telnet/network.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-static const char sccsid[] = "@(#)network.c 8.2 (Berkeley) 12/15/93";
-#endif /* not lint */
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/time.h>
-
-#include <errno.h>
-
-#include <arpa/telnet.h>
-#include <unistd.h>
-
-#include "ring.h"
-
-#include "defines.h"
-#include "externs.h"
-#include "fdset.h"
-
-Ring netoring, netiring;
-unsigned char netobuf[2*BUFSIZ], netibuf[BUFSIZ];
-
-/*
- * Initialize internal network data structures.
- */
-
- void
-init_network()
-{
- if (ring_init(&netoring, netobuf, sizeof netobuf) != 1) {
- exit(1);
- }
- if (ring_init(&netiring, netibuf, sizeof netibuf) != 1) {
- exit(1);
- }
- NetTrace = stdout;
-}
-
-
-/*
- * Check to see if any out-of-band data exists on a socket (for
- * Telnet "synch" processing).
- */
-
- int
-stilloob()
-{
- static struct timeval timeout = { 0 };
- fd_set excepts;
- int value;
-
- do {
- FD_ZERO(&excepts);
- FD_SET(net, &excepts);
- value = select(net+1, (fd_set *)0, (fd_set *)0, &excepts, &timeout);
- } while ((value == -1) && (errno == EINTR));
-
- if (value < 0) {
- perror("select");
- (void) quit();
- /* NOTREACHED */
- }
- if (FD_ISSET(net, &excepts)) {
- return 1;
- } else {
- return 0;
- }
-}
-
-
-/*
- * setneturg()
- *
- * Sets "neturg" to the current location.
- */
-
- void
-setneturg()
-{
- ring_mark(&netoring);
-}
-
-
-/*
- * netflush
- * Send as much data as possible to the network,
- * handling requests for urgent data.
- *
- * The return value indicates whether we did any
- * useful work.
- */
-
-
- int
-netflush()
-{
- register int n, n1;
-
-#ifdef ENCRYPTION
- if (encrypt_output)
- ring_encrypt(&netoring, encrypt_output);
-#endif /* ENCRYPTION */
- if ((n1 = n = ring_full_consecutive(&netoring)) > 0) {
- if (!ring_at_mark(&netoring)) {
- n = send(net, (char *)netoring.consume, n, 0); /* normal write */
- } else {
- /*
- * In 4.2 (and 4.3) systems, there is some question about
- * what byte in a sendOOB operation is the "OOB" data.
- * To make ourselves compatible, we only send ONE byte
- * out of band, the one WE THINK should be OOB (though
- * we really have more the TCP philosophy of urgent data
- * rather than the Unix philosophy of OOB data).
- */
- n = send(net, (char *)netoring.consume, 1, MSG_OOB);/* URGENT data */
- }
- }
- if (n < 0) {
- if (errno != ENOBUFS && errno != EWOULDBLOCK) {
- setcommandmode();
- perror(hostname);
- (void)NetClose(net);
- ring_clear_mark(&netoring);
- longjmp(peerdied, -1);
- /*NOTREACHED*/
- }
- n = 0;
- }
- if (netdata && n) {
- Dump('>', netoring.consume, n);
- }
- if (n) {
- ring_consumed(&netoring, n);
- /*
- * If we sent all, and more to send, then recurse to pick
- * up the other half.
- */
- if ((n1 == n) && ring_full_consecutive(&netoring)) {
- (void) netflush();
- }
- return 1;
- } else {
- return 0;
- }
-}
diff --git a/contrib/telnet/telnet/ring.c b/contrib/telnet/telnet/ring.c
deleted file mode 100644
index 13fe6c2b79cb..000000000000
--- a/contrib/telnet/telnet/ring.c
+++ /dev/null
@@ -1,364 +0,0 @@
-/*
- * 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-static const char sccsid[] = "@(#)ring.c 8.2 (Berkeley) 5/30/95";
-#endif /* not lint */
-
-/*
- * This defines a structure for a ring buffer.
- *
- * The circular buffer has two parts:
- *(((
- * full: [consume, supply)
- * empty: [supply, consume)
- *]]]
- *
- */
-
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
-
-#ifdef size_t
-#undef size_t
-#endif
-
-#include <sys/types.h>
-#ifndef FILIO_H
-#include <sys/ioctl.h>
-#endif
-#include <sys/socket.h>
-
-#include "ring.h"
-#include "general.h"
-
-/* Internal macros */
-
-#if !defined(MIN)
-#define MIN(a,b) (((a)<(b))? (a):(b))
-#endif /* !defined(MIN) */
-
-#define ring_subtract(d,a,b) (((a)-(b) >= 0)? \
- (a)-(b): (((a)-(b))+(d)->size))
-
-#define ring_increment(d,a,c) (((a)+(c) < (d)->top)? \
- (a)+(c) : (((a)+(c))-(d)->size))
-
-#define ring_decrement(d,a,c) (((a)-(c) >= (d)->bottom)? \
- (a)-(c) : (((a)-(c))-(d)->size))
-
-
-/*
- * The following is a clock, used to determine full, empty, etc.
- *
- * There is some trickiness here. Since the ring buffers are initialized
- * to ZERO on allocation, we need to make sure, when interpreting the
- * clock, that when the times are EQUAL, then the buffer is FULL.
- */
-static u_long ring_clock = 0;
-
-
-#define ring_empty(d) (((d)->consume == (d)->supply) && \
- ((d)->consumetime >= (d)->supplytime))
-#define ring_full(d) (((d)->supply == (d)->consume) && \
- ((d)->supplytime > (d)->consumetime))
-
-
-
-
-
-/* Buffer state transition routines */
-
- int
- ring_init(ring, buffer, count)
-Ring *ring;
- unsigned char *buffer;
- int count;
-{
- memset((char *)ring, 0, sizeof *ring);
-
- ring->size = count;
-
- ring->supply = ring->consume = ring->bottom = buffer;
-
- ring->top = ring->bottom+ring->size;
-
-#ifdef ENCRYPTION
- ring->clearto = 0;
-#endif /* ENCRYPTION */
-
- return 1;
-}
-
-/* Mark routines */
-
-/*
- * Mark the most recently supplied byte.
- */
-
- void
-ring_mark(ring)
- Ring *ring;
-{
- ring->mark = ring_decrement(ring, ring->supply, 1);
-}
-
-/*
- * Is the ring pointing to the mark?
- */
-
- int
-ring_at_mark(ring)
- Ring *ring;
-{
- if (ring->mark == ring->consume) {
- return 1;
- } else {
- return 0;
- }
-}
-
-/*
- * Clear any mark set on the ring.
- */
-
- void
-ring_clear_mark(ring)
- Ring *ring;
-{
- ring->mark = 0;
-}
-
-/*
- * Add characters from current segment to ring buffer.
- */
- void
-ring_supplied(ring, count)
- Ring *ring;
- int count;
-{
- ring->supply = ring_increment(ring, ring->supply, count);
- ring->supplytime = ++ring_clock;
-}
-
-/*
- * We have just consumed "c" bytes.
- */
- void
-ring_consumed(ring, count)
- Ring *ring;
- int count;
-{
- if (count == 0) /* don't update anything */
- return;
-
- if (ring->mark &&
- (ring_subtract(ring, ring->mark, ring->consume) < count)) {
- ring->mark = 0;
- }
-#ifdef ENCRYPTION
- if (ring->consume < ring->clearto &&
- ring->clearto <= ring->consume + count)
- ring->clearto = 0;
- else if (ring->consume + count > ring->top &&
- ring->bottom <= ring->clearto &&
- ring->bottom + ((ring->consume + count) - ring->top))
- ring->clearto = 0;
-#endif /* ENCRYPTION */
- ring->consume = ring_increment(ring, ring->consume, count);
- ring->consumetime = ++ring_clock;
- /*
- * Try to encourage "ring_empty_consecutive()" to be large.
- */
- if (ring_empty(ring)) {
- ring->consume = ring->supply = ring->bottom;
- }
-}
-
-
-
-/* Buffer state query routines */
-
-
-/* Number of bytes that may be supplied */
- int
-ring_empty_count(ring)
- Ring *ring;
-{
- if (ring_empty(ring)) { /* if empty */
- return ring->size;
- } else {
- return ring_subtract(ring, ring->consume, ring->supply);
- }
-}
-
-/* number of CONSECUTIVE bytes that may be supplied */
- int
-ring_empty_consecutive(ring)
- Ring *ring;
-{
- if ((ring->consume < ring->supply) || ring_empty(ring)) {
- /*
- * if consume is "below" supply, or empty, then
- * return distance to the top
- */
- return ring_subtract(ring, ring->top, ring->supply);
- } else {
- /*
- * else, return what we may.
- */
- return ring_subtract(ring, ring->consume, ring->supply);
- }
-}
-
-/* Return the number of bytes that are available for consuming
- * (but don't give more than enough to get to cross over set mark)
- */
-
- int
-ring_full_count(ring)
- Ring *ring;
-{
- if ((ring->mark == 0) || (ring->mark == ring->consume)) {
- if (ring_full(ring)) {
- return ring->size; /* nothing consumed, but full */
- } else {
- return ring_subtract(ring, ring->supply, ring->consume);
- }
- } else {
- return ring_subtract(ring, ring->mark, ring->consume);
- }
-}
-
-/*
- * Return the number of CONSECUTIVE bytes available for consuming.
- * However, don't return more than enough to cross over set mark.
- */
- int
-ring_full_consecutive(ring)
- Ring *ring;
-{
- if ((ring->mark == 0) || (ring->mark == ring->consume)) {
- if ((ring->supply < ring->consume) || ring_full(ring)) {
- return ring_subtract(ring, ring->top, ring->consume);
- } else {
- return ring_subtract(ring, ring->supply, ring->consume);
- }
- } else {
- if (ring->mark < ring->consume) {
- return ring_subtract(ring, ring->top, ring->consume);
- } else { /* Else, distance to mark */
- return ring_subtract(ring, ring->mark, ring->consume);
- }
- }
-}
-
-/*
- * Move data into the "supply" portion of of the ring buffer.
- */
- void
-ring_supply_data(ring, buffer, count)
- Ring *ring;
- unsigned char *buffer;
- int count;
-{
- int i;
-
- while (count) {
- i = MIN(count, ring_empty_consecutive(ring));
- memmove(ring->supply, buffer, i);
- ring_supplied(ring, i);
- count -= i;
- buffer += i;
- }
-}
-
-#ifdef notdef
-
-/*
- * Move data from the "consume" portion of the ring buffer
- */
- void
-ring_consume_data(ring, buffer, count)
- Ring *ring;
- unsigned char *buffer;
- int count;
-{
- int i;
-
- while (count) {
- i = MIN(count, ring_full_consecutive(ring));
- memmove(buffer, ring->consume, i);
- ring_consumed(ring, i);
- count -= i;
- buffer += i;
- }
-}
-#endif
-
-#ifdef ENCRYPTION
- void
-ring_encrypt(ring, encryptor)
- Ring *ring;
- void (*encryptor)();
-{
- unsigned char *s, *c;
-
- if (ring_empty(ring) || ring->clearto == ring->supply)
- return;
-
- if (!(c = ring->clearto))
- c = ring->consume;
-
- s = ring->supply;
-
- if (s <= c) {
- (*encryptor)(c, ring->top - c);
- (*encryptor)(ring->bottom, s - ring->bottom);
- } else
- (*encryptor)(c, s - c);
-
- ring->clearto = ring->supply;
-}
-
- void
-ring_clearto(ring)
- Ring *ring;
-{
- if (!ring_empty(ring))
- ring->clearto = ring->supply;
- else
- ring->clearto = 0;
-}
-#endif /* ENCRYPTION */
diff --git a/contrib/telnet/telnet/ring.h b/contrib/telnet/telnet/ring.h
deleted file mode 100644
index 2a36781e5ae5..000000000000
--- a/contrib/telnet/telnet/ring.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)ring.h 8.1 (Berkeley) 6/6/93
- */
-
-#if defined(P)
-# undef P
-#endif
-
-#if defined(__STDC__) || defined(LINT_ARGS)
-# define P(x) x
-#else
-# define P(x) ()
-#endif
-
-/*
- * This defines a structure for a ring buffer.
- *
- * The circular buffer has two parts:
- *(((
- * full: [consume, supply)
- * empty: [supply, consume)
- *]]]
- *
- */
-typedef struct {
- unsigned char *consume, /* where data comes out of */
- *supply, /* where data comes in to */
- *bottom, /* lowest address in buffer */
- *top, /* highest address+1 in buffer */
- *mark; /* marker (user defined) */
-#ifdef ENCRYPTION
- unsigned char *clearto; /* Data to this point is clear text */
- unsigned char *encryyptedto; /* Data is encrypted to here */
-#endif /* ENCRYPTION */
- int size; /* size in bytes of buffer */
- u_long consumetime, /* help us keep straight full, empty, etc. */
- supplytime;
-} Ring;
-
-/* Here are some functions and macros to deal with the ring buffer */
-
-/* Initialization routine */
-extern int
- ring_init P((Ring *ring, unsigned char *buffer, int count));
-
-/* Data movement routines */
-extern void
- ring_supply_data P((Ring *ring, unsigned char *buffer, int count));
-#ifdef notdef
-extern void
- ring_consume_data P((Ring *ring, unsigned char *buffer, int count));
-#endif
-
-/* Buffer state transition routines */
-extern void
- ring_supplied P((Ring *ring, int count)),
- ring_consumed P((Ring *ring, int count));
-
-/* Buffer state query routines */
-extern int
- ring_empty_count P((Ring *ring)),
- ring_empty_consecutive P((Ring *ring)),
- ring_full_count P((Ring *ring)),
- ring_full_consecutive P((Ring *ring));
-
-#ifdef ENCRYPTION
-extern void
- ring_encrypt P((Ring *ring, void (*func)())),
- ring_clearto P((Ring *ring));
-#endif /* ENCRYPTION */
-
-extern void
- ring_clear_mark(),
- ring_mark();
diff --git a/contrib/telnet/telnet/sys_bsd.c b/contrib/telnet/telnet/sys_bsd.c
deleted file mode 100644
index ed5f459e957c..000000000000
--- a/contrib/telnet/telnet/sys_bsd.c
+++ /dev/null
@@ -1,1221 +0,0 @@
-/*
- * Copyright (c) 1988, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-static const char sccsid[] = "@(#)sys_bsd.c 8.4 (Berkeley) 5/30/95";
-#endif /* not lint */
-
-/*
- * The following routines try to encapsulate what is system dependent
- * (at least between 4.x and dos) which is used in telnet.c.
- */
-
-
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/socket.h>
-#include <signal.h>
-#include <errno.h>
-#include <arpa/telnet.h>
-#include <unistd.h>
-
-#include "ring.h"
-
-#include "fdset.h"
-
-#include "defines.h"
-#include "externs.h"
-#include "types.h"
-
-#if defined(CRAY) || (defined(USE_TERMIO) && !defined(SYSV_TERMIO))
-#define SIG_FUNC_RET void
-#else
-#define SIG_FUNC_RET int
-#endif
-
-#ifdef SIGINFO
-extern SIG_FUNC_RET ayt_status();
-#endif
-
-int
- tout, /* Output file descriptor */
- tin, /* Input file descriptor */
- net;
-
-#ifndef USE_TERMIO
-struct tchars otc = { 0 }, ntc = { 0 };
-struct ltchars oltc = { 0 }, nltc = { 0 };
-struct sgttyb ottyb = { 0 }, nttyb = { 0 };
-int olmode = 0;
-# define cfgetispeed(ptr) (ptr)->sg_ispeed
-# define cfgetospeed(ptr) (ptr)->sg_ospeed
-# define old_tc ottyb
-
-#else /* USE_TERMIO */
-struct termio old_tc = { 0 };
-extern struct termio new_tc;
-
-# ifndef TCSANOW
-# ifdef TCSETS
-# define TCSANOW TCSETS
-# define TCSADRAIN TCSETSW
-# define tcgetattr(f, t) ioctl(f, TCGETS, (char *)t)
-# else
-# ifdef TCSETA
-# define TCSANOW TCSETA
-# define TCSADRAIN TCSETAW
-# define tcgetattr(f, t) ioctl(f, TCGETA, (char *)t)
-# else
-# define TCSANOW TIOCSETA
-# define TCSADRAIN TIOCSETAW
-# define tcgetattr(f, t) ioctl(f, TIOCGETA, (char *)t)
-# endif
-# endif
-# define tcsetattr(f, a, t) ioctl(f, a, (char *)t)
-# define cfgetospeed(ptr) ((ptr)->c_cflag&CBAUD)
-# ifdef CIBAUD
-# define cfgetispeed(ptr) (((ptr)->c_cflag&CIBAUD) >> IBSHIFT)
-# else
-# define cfgetispeed(ptr) cfgetospeed(ptr)
-# endif
-# endif /* TCSANOW */
-# ifdef sysV88
-# define TIOCFLUSH TC_PX_DRAIN
-# endif
-#endif /* USE_TERMIO */
-
-static fd_set ibits, obits, xbits;
-
-
- void
-init_sys()
-{
- tout = fileno(stdout);
- tin = fileno(stdin);
- FD_ZERO(&ibits);
- FD_ZERO(&obits);
- FD_ZERO(&xbits);
-
- errno = 0;
-}
-
-
- int
-TerminalWrite(buf, n)
- char *buf;
- int n;
-{
- return write(tout, buf, n);
-}
-
- int
-TerminalRead(buf, n)
- char *buf;
- int n;
-{
- return read(tin, buf, n);
-}
-
-/*
- *
- */
-
- int
-TerminalAutoFlush()
-{
-#if defined(LNOFLSH)
- int flush;
-
- ioctl(0, TIOCLGET, (char *)&flush);
- return !(flush&LNOFLSH); /* if LNOFLSH, no autoflush */
-#else /* LNOFLSH */
- return 1;
-#endif /* LNOFLSH */
-}
-
-#ifdef KLUDGELINEMODE
-extern int kludgelinemode;
-#endif
-/*
- * TerminalSpecialChars()
- *
- * Look at an input character to see if it is a special character
- * and decide what to do.
- *
- * Output:
- *
- * 0 Don't add this character.
- * 1 Do add this character
- */
-
-extern void xmitAO(), xmitEL(), xmitEC(), intp(), sendbrk();
-
- int
-TerminalSpecialChars(c)
- int c;
-{
- if (c == termIntChar) {
- intp();
- return 0;
- } else if (c == termQuitChar) {
-#ifdef KLUDGELINEMODE
- if (kludgelinemode)
- sendbrk();
- else
-#endif
- sendabort();
- return 0;
- } else if (c == termEofChar) {
- if (my_want_state_is_will(TELOPT_LINEMODE)) {
- sendeof();
- return 0;
- }
- return 1;
- } else if (c == termSuspChar) {
- sendsusp();
- return(0);
- } else if (c == termFlushChar) {
- xmitAO(); /* Transmit Abort Output */
- return 0;
- } else if (!MODE_LOCAL_CHARS(globalmode)) {
- if (c == termKillChar) {
- xmitEL();
- return 0;
- } else if (c == termEraseChar) {
- xmitEC(); /* Transmit Erase Character */
- return 0;
- }
- }
- return 1;
-}
-
-
-/*
- * Flush output to the terminal
- */
-
- void
-TerminalFlushOutput()
-{
-#ifdef TIOCFLUSH
- (void) ioctl(fileno(stdout), TIOCFLUSH, (char *) 0);
-#else
- (void) ioctl(fileno(stdout), TCFLSH, (char *) 0);
-#endif
-}
-
- void
-TerminalSaveState()
-{
-#ifndef USE_TERMIO
- ioctl(0, TIOCGETP, (char *)&ottyb);
- ioctl(0, TIOCGETC, (char *)&otc);
- ioctl(0, TIOCGLTC, (char *)&oltc);
- ioctl(0, TIOCLGET, (char *)&olmode);
-
- ntc = otc;
- nltc = oltc;
- nttyb = ottyb;
-
-#else /* USE_TERMIO */
- tcgetattr(0, &old_tc);
-
- new_tc = old_tc;
-
-#ifndef VDISCARD
- termFlushChar = CONTROL('O');
-#endif
-#ifndef VWERASE
- termWerasChar = CONTROL('W');
-#endif
-#ifndef VREPRINT
- termRprntChar = CONTROL('R');
-#endif
-#ifndef VLNEXT
- termLiteralNextChar = CONTROL('V');
-#endif
-#ifndef VSTART
- termStartChar = CONTROL('Q');
-#endif
-#ifndef VSTOP
- termStopChar = CONTROL('S');
-#endif
-#ifndef VSTATUS
- termAytChar = CONTROL('T');
-#endif
-#endif /* USE_TERMIO */
-}
-
- cc_t *
-tcval(func)
- register int func;
-{
- switch(func) {
- case SLC_IP: return(&termIntChar);
- case SLC_ABORT: return(&termQuitChar);
- case SLC_EOF: return(&termEofChar);
- case SLC_EC: return(&termEraseChar);
- case SLC_EL: return(&termKillChar);
- case SLC_XON: return(&termStartChar);
- case SLC_XOFF: return(&termStopChar);
- case SLC_FORW1: return(&termForw1Char);
-#ifdef USE_TERMIO
- case SLC_FORW2: return(&termForw2Char);
-# ifdef VDISCARD
- case SLC_AO: return(&termFlushChar);
-# endif
-# ifdef VSUSP
- case SLC_SUSP: return(&termSuspChar);
-# endif
-# ifdef VWERASE
- case SLC_EW: return(&termWerasChar);
-# endif
-# ifdef VREPRINT
- case SLC_RP: return(&termRprntChar);
-# endif
-# ifdef VLNEXT
- case SLC_LNEXT: return(&termLiteralNextChar);
-# endif
-# ifdef VSTATUS
- case SLC_AYT: return(&termAytChar);
-# endif
-#endif
-
- case SLC_SYNCH:
- case SLC_BRK:
- case SLC_EOR:
- default:
- return((cc_t *)0);
- }
-}
-
- void
-TerminalDefaultChars()
-{
-#ifndef USE_TERMIO
- ntc = otc;
- nltc = oltc;
- nttyb.sg_kill = ottyb.sg_kill;
- nttyb.sg_erase = ottyb.sg_erase;
-#else /* USE_TERMIO */
- memmove(new_tc.c_cc, old_tc.c_cc, sizeof(old_tc.c_cc));
-# ifndef VDISCARD
- termFlushChar = CONTROL('O');
-# endif
-# ifndef VWERASE
- termWerasChar = CONTROL('W');
-# endif
-# ifndef VREPRINT
- termRprntChar = CONTROL('R');
-# endif
-# ifndef VLNEXT
- termLiteralNextChar = CONTROL('V');
-# endif
-# ifndef VSTART
- termStartChar = CONTROL('Q');
-# endif
-# ifndef VSTOP
- termStopChar = CONTROL('S');
-# endif
-# ifndef VSTATUS
- termAytChar = CONTROL('T');
-# endif
-#endif /* USE_TERMIO */
-}
-
-#ifdef notdef
-void
-TerminalRestoreState()
-{
-}
-#endif
-
-/*
- * TerminalNewMode - set up terminal to a specific mode.
- * MODE_ECHO: do local terminal echo
- * MODE_FLOW: do local flow control
- * MODE_TRAPSIG: do local mapping to TELNET IAC sequences
- * MODE_EDIT: do local line editing
- *
- * Command mode:
- * MODE_ECHO|MODE_EDIT|MODE_FLOW|MODE_TRAPSIG
- * local echo
- * local editing
- * local xon/xoff
- * local signal mapping
- *
- * Linemode:
- * local/no editing
- * Both Linemode and Single Character mode:
- * local/remote echo
- * local/no xon/xoff
- * local/no signal mapping
- */
-
-
- void
-TerminalNewMode(f)
- register int f;
-{
- static int prevmode = 0;
-#ifndef USE_TERMIO
- struct tchars tc;
- struct ltchars ltc;
- struct sgttyb sb;
- int lmode;
-#else /* USE_TERMIO */
- struct termio tmp_tc;
-#endif /* USE_TERMIO */
- int onoff;
- int old;
- cc_t esc;
-
- globalmode = f&~MODE_FORCE;
- if (prevmode == f)
- return;
-
- /*
- * Write any outstanding data before switching modes
- * ttyflush() returns 0 only when there is no more data
- * left to write out, it returns -1 if it couldn't do
- * anything at all, otherwise it returns 1 + the number
- * of characters left to write.
-#ifndef USE_TERMIO
- * We would really like ask the kernel to wait for the output
- * to drain, like we can do with the TCSADRAIN, but we don't have
- * that option. The only ioctl that waits for the output to
- * drain, TIOCSETP, also flushes the input queue, which is NOT
- * what we want (TIOCSETP is like TCSADFLUSH).
-#endif
- */
- old = ttyflush(SYNCHing|flushout);
- if (old < 0 || old > 1) {
-#ifdef USE_TERMIO
- tcgetattr(tin, &tmp_tc);
-#endif /* USE_TERMIO */
- do {
- /*
- * Wait for data to drain, then flush again.
- */
-#ifdef USE_TERMIO
- tcsetattr(tin, TCSADRAIN, &tmp_tc);
-#endif /* USE_TERMIO */
- old = ttyflush(SYNCHing|flushout);
- } while (old < 0 || old > 1);
- }
-
- old = prevmode;
- prevmode = f&~MODE_FORCE;
-#ifndef USE_TERMIO
- sb = nttyb;
- tc = ntc;
- ltc = nltc;
- lmode = olmode;
-#else
- tmp_tc = new_tc;
-#endif
-
- if (f&MODE_ECHO) {
-#ifndef USE_TERMIO
- sb.sg_flags |= ECHO;
-#else
- tmp_tc.c_lflag |= ECHO;
- tmp_tc.c_oflag |= ONLCR;
- if (crlf)
- tmp_tc.c_iflag |= ICRNL;
-#endif
- } else {
-#ifndef USE_TERMIO
- sb.sg_flags &= ~ECHO;
-#else
- tmp_tc.c_lflag &= ~ECHO;
- tmp_tc.c_oflag &= ~ONLCR;
-# ifdef notdef
- if (crlf)
- tmp_tc.c_iflag &= ~ICRNL;
-# endif
-#endif
- }
-
- if ((f&MODE_FLOW) == 0) {
-#ifndef USE_TERMIO
- tc.t_startc = _POSIX_VDISABLE;
- tc.t_stopc = _POSIX_VDISABLE;
-#else
- tmp_tc.c_iflag &= ~(IXOFF|IXON); /* Leave the IXANY bit alone */
- } else {
- if (restartany < 0) {
- tmp_tc.c_iflag |= IXOFF|IXON; /* Leave the IXANY bit alone */
- } else if (restartany > 0) {
- tmp_tc.c_iflag |= IXOFF|IXON|IXANY;
- } else {
- tmp_tc.c_iflag |= IXOFF|IXON;
- tmp_tc.c_iflag &= ~IXANY;
- }
-#endif
- }
-
- if ((f&MODE_TRAPSIG) == 0) {
-#ifndef USE_TERMIO
- tc.t_intrc = _POSIX_VDISABLE;
- tc.t_quitc = _POSIX_VDISABLE;
- tc.t_eofc = _POSIX_VDISABLE;
- ltc.t_suspc = _POSIX_VDISABLE;
- ltc.t_dsuspc = _POSIX_VDISABLE;
-#else
- tmp_tc.c_lflag &= ~ISIG;
-#endif
- localchars = 0;
- } else {
-#ifdef USE_TERMIO
- tmp_tc.c_lflag |= ISIG;
-#endif
- localchars = 1;
- }
-
- if (f&MODE_EDIT) {
-#ifndef USE_TERMIO
- sb.sg_flags &= ~CBREAK;
- sb.sg_flags |= CRMOD;
-#else
- tmp_tc.c_lflag |= ICANON;
-#endif
- } else {
-#ifndef USE_TERMIO
- sb.sg_flags |= CBREAK;
- if (f&MODE_ECHO)
- sb.sg_flags |= CRMOD;
- else
- sb.sg_flags &= ~CRMOD;
-#else
- tmp_tc.c_lflag &= ~ICANON;
- tmp_tc.c_iflag &= ~ICRNL;
- tmp_tc.c_cc[VMIN] = 1;
- tmp_tc.c_cc[VTIME] = 0;
-#endif
- }
-
- if ((f&(MODE_EDIT|MODE_TRAPSIG)) == 0) {
-#ifndef USE_TERMIO
- ltc.t_lnextc = _POSIX_VDISABLE;
-#else
-# ifdef VLNEXT
- tmp_tc.c_cc[VLNEXT] = (cc_t)(_POSIX_VDISABLE);
-# endif
-#endif
- }
-
- if (f&MODE_SOFT_TAB) {
-#ifndef USE_TERMIO
- sb.sg_flags |= XTABS;
-#else
-# ifdef OXTABS
- tmp_tc.c_oflag |= OXTABS;
-# endif
-# ifdef TABDLY
- tmp_tc.c_oflag &= ~TABDLY;
- tmp_tc.c_oflag |= TAB3;
-# endif
-#endif
- } else {
-#ifndef USE_TERMIO
- sb.sg_flags &= ~XTABS;
-#else
-# ifdef OXTABS
- tmp_tc.c_oflag &= ~OXTABS;
-# endif
-# ifdef TABDLY
- tmp_tc.c_oflag &= ~TABDLY;
-# endif
-#endif
- }
-
- if (f&MODE_LIT_ECHO) {
-#ifndef USE_TERMIO
- lmode &= ~LCTLECH;
-#else
-# ifdef ECHOCTL
- tmp_tc.c_lflag &= ~ECHOCTL;
-# endif
-#endif
- } else {
-#ifndef USE_TERMIO
- lmode |= LCTLECH;
-#else
-# ifdef ECHOCTL
- tmp_tc.c_lflag |= ECHOCTL;
-# endif
-#endif
- }
-
- if (f == -1) {
- onoff = 0;
- } else {
-#ifndef USE_TERMIO
- if (f & MODE_OUTBIN)
- lmode |= LLITOUT;
- else
- lmode &= ~LLITOUT;
-
- if (f & MODE_INBIN)
- lmode |= LPASS8;
- else
- lmode &= ~LPASS8;
-#else
- if (f & MODE_INBIN)
- tmp_tc.c_iflag &= ~ISTRIP;
- else
- tmp_tc.c_iflag |= ISTRIP;
- if (f & MODE_OUTBIN) {
- tmp_tc.c_cflag &= ~(CSIZE|PARENB);
- tmp_tc.c_cflag |= CS8;
- tmp_tc.c_oflag &= ~OPOST;
- } else {
- tmp_tc.c_cflag &= ~(CSIZE|PARENB);
- tmp_tc.c_cflag |= old_tc.c_cflag & (CSIZE|PARENB);
- tmp_tc.c_oflag |= OPOST;
- }
-#endif
- onoff = 1;
- }
-
- if (f != -1) {
-#ifdef SIGTSTP
- SIG_FUNC_RET susp();
-#endif /* SIGTSTP */
-#ifdef SIGINFO
- SIG_FUNC_RET ayt();
-#endif
-
-#ifdef SIGTSTP
- (void) signal(SIGTSTP, susp);
-#endif /* SIGTSTP */
-#ifdef SIGINFO
- (void) signal(SIGINFO, ayt);
-#endif
-#if defined(USE_TERMIO) && defined(NOKERNINFO)
- tmp_tc.c_lflag |= NOKERNINFO;
-#endif
- /*
- * We don't want to process ^Y here. It's just another
- * character that we'll pass on to the back end. It has
- * to process it because it will be processed when the
- * user attempts to read it, not when we send it.
- */
-#ifndef USE_TERMIO
- ltc.t_dsuspc = _POSIX_VDISABLE;
-#else
-# ifdef VDSUSP
- tmp_tc.c_cc[VDSUSP] = (cc_t)(_POSIX_VDISABLE);
-# endif
-#endif
-#ifdef USE_TERMIO
- /*
- * If the VEOL character is already set, then use VEOL2,
- * otherwise use VEOL.
- */
- esc = (rlogin != _POSIX_VDISABLE) ? rlogin : escape;
- if ((tmp_tc.c_cc[VEOL] != esc)
-# ifdef VEOL2
- && (tmp_tc.c_cc[VEOL2] != esc)
-# endif
- ) {
- if (tmp_tc.c_cc[VEOL] == (cc_t)(_POSIX_VDISABLE))
- tmp_tc.c_cc[VEOL] = esc;
-# ifdef VEOL2
- else if (tmp_tc.c_cc[VEOL2] == (cc_t)(_POSIX_VDISABLE))
- tmp_tc.c_cc[VEOL2] = esc;
-# endif
- }
-#else
- if (tc.t_brkc == (cc_t)(_POSIX_VDISABLE))
- tc.t_brkc = esc;
-#endif
- } else {
-#ifdef SIGINFO
- SIG_FUNC_RET ayt_status();
-
- (void) signal(SIGINFO, ayt_status);
-#endif
-#ifdef SIGTSTP
- (void) signal(SIGTSTP, SIG_DFL);
-# ifndef SOLARIS
- (void) sigsetmask(sigblock(0) & ~(1<<(SIGTSTP-1)));
-# else SOLARIS
- (void) sigrelse(SIGTSTP);
-# endif SOLARIS
-#endif /* SIGTSTP */
-#ifndef USE_TERMIO
- ltc = oltc;
- tc = otc;
- sb = ottyb;
- lmode = olmode;
-#else
- tmp_tc = old_tc;
-#endif
- }
-#ifndef USE_TERMIO
- ioctl(tin, TIOCLSET, (char *)&lmode);
- ioctl(tin, TIOCSLTC, (char *)&ltc);
- ioctl(tin, TIOCSETC, (char *)&tc);
- ioctl(tin, TIOCSETN, (char *)&sb);
-#else
- if (tcsetattr(tin, TCSADRAIN, &tmp_tc) < 0)
- tcsetattr(tin, TCSANOW, &tmp_tc);
-#endif
-
-#if (!defined(TN3270)) || ((!defined(NOT43)) || defined(PUTCHAR))
-# if !defined(sysV88)
- ioctl(tin, FIONBIO, (char *)&onoff);
- ioctl(tout, FIONBIO, (char *)&onoff);
-# endif
-#endif /* (!defined(TN3270)) || ((!defined(NOT43)) || defined(PUTCHAR)) */
-#if defined(TN3270)
- if (noasynchtty == 0) {
- ioctl(tin, FIOASYNC, (char *)&onoff);
- }
-#endif /* defined(TN3270) */
-
-}
-
-/*
- * Try to guess whether speeds are "encoded" (4.2BSD) or just numeric (4.4BSD).
- */
-#if B4800 != 4800
-#define DECODE_BAUD
-#endif
-
-#ifdef DECODE_BAUD
-#ifndef B7200
-#define B7200 B4800
-#endif
-
-#ifndef B14400
-#define B14400 B9600
-#endif
-
-#ifndef B19200
-# define B19200 B14400
-#endif
-
-#ifndef B28800
-#define B28800 B19200
-#endif
-
-#ifndef B38400
-# define B38400 B28800
-#endif
-
-#ifndef B57600
-#define B57600 B38400
-#endif
-
-#ifndef B76800
-#define B76800 B57600
-#endif
-
-#ifndef B115200
-#define B115200 B76800
-#endif
-
-#ifndef B230400
-#define B230400 B115200
-#endif
-
-
-/*
- * This code assumes that the values B0, B50, B75...
- * are in ascending order. They do not have to be
- * contiguous.
- */
-struct termspeeds {
- long speed;
- long value;
-} termspeeds[] = {
- { 0, B0 }, { 50, B50 }, { 75, B75 },
- { 110, B110 }, { 134, B134 }, { 150, B150 },
- { 200, B200 }, { 300, B300 }, { 600, B600 },
- { 1200, B1200 }, { 1800, B1800 }, { 2400, B2400 },
- { 4800, B4800 }, { 7200, B7200 }, { 9600, B9600 },
- { 14400, B14400 }, { 19200, B19200 }, { 28800, B28800 },
- { 38400, B38400 }, { 57600, B57600 }, { 115200, B115200 },
- { 230400, B230400 }, { -1, B230400 }
-};
-#endif /* DECODE_BAUD */
-
- void
-TerminalSpeeds(ispeed, ospeed)
- long *ispeed;
- long *ospeed;
-{
-#ifdef DECODE_BAUD
- register struct termspeeds *tp;
-#endif /* DECODE_BAUD */
- register long in, out;
-
- out = cfgetospeed(&old_tc);
- in = cfgetispeed(&old_tc);
- if (in == 0)
- in = out;
-
-#ifdef DECODE_BAUD
- tp = termspeeds;
- while ((tp->speed != -1) && (tp->value < in))
- tp++;
- *ispeed = tp->speed;
-
- tp = termspeeds;
- while ((tp->speed != -1) && (tp->value < out))
- tp++;
- *ospeed = tp->speed;
-#else /* DECODE_BAUD */
- *ispeed = in;
- *ospeed = out;
-#endif /* DECODE_BAUD */
-}
-
- int
-TerminalWindowSize(rows, cols)
- long *rows, *cols;
-{
-#ifdef TIOCGWINSZ
- struct winsize ws;
-
- if (ioctl(fileno(stdin), TIOCGWINSZ, (char *)&ws) >= 0) {
- *rows = ws.ws_row;
- *cols = ws.ws_col;
- return 1;
- }
-#endif /* TIOCGWINSZ */
- return 0;
-}
-
- int
-NetClose(fd)
- int fd;
-{
- return close(fd);
-}
-
-
- void
-NetNonblockingIO(fd, onoff)
- int fd;
- int onoff;
-{
- ioctl(fd, FIONBIO, (char *)&onoff);
-}
-
-#if defined(TN3270)
- void
-NetSigIO(fd, onoff)
- int fd;
- int onoff;
-{
- ioctl(fd, FIOASYNC, (char *)&onoff); /* hear about input */
-}
-
- void
-NetSetPgrp(fd)
- int fd;
-{
- int myPid;
-
- myPid = getpid();
- fcntl(fd, F_SETOWN, myPid);
-}
-#endif /*defined(TN3270)*/
-
-/*
- * Various signal handling routines.
- */
-
- /* ARGSUSED */
- SIG_FUNC_RET
-deadpeer(sig)
- int sig;
-{
- setcommandmode();
- longjmp(peerdied, -1);
-}
-
- /* ARGSUSED */
- SIG_FUNC_RET
-intr(sig)
- int sig;
-{
- if (localchars) {
- intp();
- return;
- }
- setcommandmode();
- longjmp(toplevel, -1);
-}
-
- /* ARGSUSED */
- SIG_FUNC_RET
-intr2(sig)
- int sig;
-{
- if (localchars) {
-#ifdef KLUDGELINEMODE
- if (kludgelinemode)
- sendbrk();
- else
-#endif
- sendabort();
- return;
- }
-}
-
-#ifdef SIGTSTP
- /* ARGSUSED */
- SIG_FUNC_RET
-susp(sig)
- int sig;
-{
- if ((rlogin != _POSIX_VDISABLE) && rlogin_susp())
- return;
- if (localchars)
- sendsusp();
-}
-#endif
-
-#ifdef SIGWINCH
- /* ARGSUSED */
- SIG_FUNC_RET
-sendwin(sig)
- int sig;
-{
- if (connected) {
- sendnaws();
- }
-}
-#endif
-
-#ifdef SIGINFO
- /* ARGSUSED */
- SIG_FUNC_RET
-ayt(sig)
- int sig;
-{
- if (connected)
- sendayt();
- else
- ayt_status();
-}
-#endif
-
-
- void
-sys_telnet_init()
-{
- (void) signal(SIGINT, intr);
- (void) signal(SIGQUIT, intr2);
- (void) signal(SIGPIPE, deadpeer);
-#ifdef SIGWINCH
- (void) signal(SIGWINCH, sendwin);
-#endif
-#ifdef SIGTSTP
- (void) signal(SIGTSTP, susp);
-#endif
-#ifdef SIGINFO
- (void) signal(SIGINFO, ayt);
-#endif
-
- setconnmode(0);
-
- NetNonblockingIO(net, 1);
-
-#if defined(TN3270)
- if (noasynchnet == 0) { /* DBX can't handle! */
- NetSigIO(net, 1);
- NetSetPgrp(net);
- }
-#endif /* defined(TN3270) */
-
-#if defined(SO_OOBINLINE)
- if (SetSockOpt(net, SOL_SOCKET, SO_OOBINLINE, 1) == -1) {
- perror("SetSockOpt");
- }
-#endif /* defined(SO_OOBINLINE) */
-}
-
-/*
- * Process rings -
- *
- * This routine tries to fill up/empty our various rings.
- *
- * The parameter specifies whether this is a poll operation,
- * or a block-until-something-happens operation.
- *
- * The return value is 1 if something happened, 0 if not.
- */
-
- int
-process_rings(netin, netout, netex, ttyin, ttyout, poll)
- int poll; /* If 0, then block until something to do */
-{
- register int c;
- /* One wants to be a bit careful about setting returnValue
- * to one, since a one implies we did some useful work,
- * and therefore probably won't be called to block next
- * time (TN3270 mode only).
- */
- int returnValue = 0;
- static struct timeval TimeValue = { 0 };
-
- if (netout) {
- FD_SET(net, &obits);
- }
- if (ttyout) {
- FD_SET(tout, &obits);
- }
-#if defined(TN3270)
- if (ttyin) {
- FD_SET(tin, &ibits);
- }
-#else /* defined(TN3270) */
- if (ttyin) {
- FD_SET(tin, &ibits);
- }
-#endif /* defined(TN3270) */
-#if defined(TN3270)
- if (netin) {
- FD_SET(net, &ibits);
- }
-# else /* !defined(TN3270) */
- if (netin) {
- FD_SET(net, &ibits);
- }
-# endif /* !defined(TN3270) */
- if (netex) {
- FD_SET(net, &xbits);
- }
- if ((c = select(16, &ibits, &obits, &xbits,
- (poll == 0)? (struct timeval *)0 : &TimeValue)) < 0) {
- if (c == -1) {
- /*
- * we can get EINTR if we are in line mode,
- * and the user does an escape (TSTP), or
- * some other signal generator.
- */
- if (errno == EINTR) {
- return 0;
- }
-# if defined(TN3270)
- /*
- * we can get EBADF if we were in transparent
- * mode, and the transcom process died.
- */
- if (errno == EBADF) {
- /*
- * zero the bits (even though kernel does it)
- * to make sure we are selecting on the right
- * ones.
- */
- FD_ZERO(&ibits);
- FD_ZERO(&obits);
- FD_ZERO(&xbits);
- return 0;
- }
-# endif /* defined(TN3270) */
- /* I don't like this, does it ever happen? */
- printf("sleep(5) from telnet, after select: %s\r\n", strerror(errno));
- sleep(5);
- }
- return 0;
- }
-
- /*
- * Any urgent data?
- */
- if (FD_ISSET(net, &xbits)) {
- FD_CLR(net, &xbits);
- SYNCHing = 1;
- (void) ttyflush(1); /* flush already enqueued data */
- }
-
- /*
- * Something to read from the network...
- */
- if (FD_ISSET(net, &ibits)) {
- int canread;
-
- FD_CLR(net, &ibits);
- canread = ring_empty_consecutive(&netiring);
-#if !defined(SO_OOBINLINE)
- /*
- * In 4.2 (and some early 4.3) systems, the
- * OOB indication and data handling in the kernel
- * is such that if two separate TCP Urgent requests
- * come in, one byte of TCP data will be overlaid.
- * This is fatal for Telnet, but we try to live
- * with it.
- *
- * In addition, in 4.2 (and...), a special protocol
- * is needed to pick up the TCP Urgent data in
- * the correct sequence.
- *
- * What we do is: if we think we are in urgent
- * mode, we look to see if we are "at the mark".
- * If we are, we do an OOB receive. If we run
- * this twice, we will do the OOB receive twice,
- * but the second will fail, since the second
- * time we were "at the mark", but there wasn't
- * any data there (the kernel doesn't reset
- * "at the mark" until we do a normal read).
- * Once we've read the OOB data, we go ahead
- * and do normal reads.
- *
- * There is also another problem, which is that
- * since the OOB byte we read doesn't put us
- * out of OOB state, and since that byte is most
- * likely the TELNET DM (data mark), we would
- * stay in the TELNET SYNCH (SYNCHing) state.
- * So, clocks to the rescue. If we've "just"
- * received a DM, then we test for the
- * presence of OOB data when the receive OOB
- * fails (and AFTER we did the normal mode read
- * to clear "at the mark").
- */
- if (SYNCHing) {
- int atmark;
- static int bogus_oob = 0, first = 1;
-
- ioctl(net, SIOCATMARK, (char *)&atmark);
- if (atmark) {
- c = recv(net, netiring.supply, canread, MSG_OOB);
- if ((c == -1) && (errno == EINVAL)) {
- c = recv(net, netiring.supply, canread, 0);
- if (clocks.didnetreceive < clocks.gotDM) {
- SYNCHing = stilloob(net);
- }
- } else if (first && c > 0) {
- /*
- * Bogosity check. Systems based on 4.2BSD
- * do not return an error if you do a second
- * recv(MSG_OOB). So, we do one. If it
- * succeeds and returns exactly the same
- * data, then assume that we are running
- * on a broken system and set the bogus_oob
- * flag. (If the data was different, then
- * we probably got some valid new data, so
- * increment the count...)
- */
- int i;
- i = recv(net, netiring.supply + c, canread - c, MSG_OOB);
- if (i == c &&
- memcmp(netiring.supply, netiring.supply + c, i) == 0) {
- bogus_oob = 1;
- first = 0;
- } else if (i < 0) {
- bogus_oob = 0;
- first = 0;
- } else
- c += i;
- }
- if (bogus_oob && c > 0) {
- int i;
- /*
- * Bogosity. We have to do the read
- * to clear the atmark to get out of
- * an infinate loop.
- */
- i = read(net, netiring.supply + c, canread - c);
- if (i > 0)
- c += i;
- }
- } else {
- c = recv(net, netiring.supply, canread, 0);
- }
- } else {
- c = recv(net, netiring.supply, canread, 0);
- }
- settimer(didnetreceive);
-#else /* !defined(SO_OOBINLINE) */
- c = recv(net, (char *)netiring.supply, canread, 0);
-#endif /* !defined(SO_OOBINLINE) */
- if (c < 0 && errno == EWOULDBLOCK) {
- c = 0;
- } else if (c <= 0) {
- return -1;
- }
- if (netdata) {
- Dump('<', netiring.supply, c);
- }
- if (c)
- ring_supplied(&netiring, c);
- returnValue = 1;
- }
-
- /*
- * Something to read from the tty...
- */
- if (FD_ISSET(tin, &ibits)) {
- FD_CLR(tin, &ibits);
- c = TerminalRead(ttyiring.supply, ring_empty_consecutive(&ttyiring));
- if (c < 0 && errno == EIO)
- c = 0;
- if (c < 0 && errno == EWOULDBLOCK) {
- c = 0;
- } else {
- /* EOF detection for line mode!!!! */
- if ((c == 0) && MODE_LOCAL_CHARS(globalmode) && isatty(tin)) {
- /* must be an EOF... */
- *ttyiring.supply = termEofChar;
- c = 1;
- }
- if (c <= 0) {
- return -1;
- }
- if (termdata) {
- Dump('<', ttyiring.supply, c);
- }
- ring_supplied(&ttyiring, c);
- }
- returnValue = 1; /* did something useful */
- }
-
- if (FD_ISSET(net, &obits)) {
- FD_CLR(net, &obits);
- returnValue |= netflush();
- }
- if (FD_ISSET(tout, &obits)) {
- FD_CLR(tout, &obits);
- returnValue |= (ttyflush(SYNCHing|flushout) > 0);
- }
-
- return returnValue;
-}
diff --git a/contrib/telnet/telnet/telnet.1 b/contrib/telnet/telnet/telnet.1
deleted file mode 100644
index 3378d3a4ad92..000000000000
--- a/contrib/telnet/telnet/telnet.1
+++ /dev/null
@@ -1,1384 +0,0 @@
-.\" Copyright (c) 1983, 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. 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, Berkeley and its contributors.
-.\" 4. 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.
-.\"
-.\" @(#)telnet.1 8.6 (Berkeley) 6/1/94
-.\" $FreeBSD$
-.\"
-.Dd January 27, 2000
-.Dt TELNET 1
-.Os BSD 4.2
-.Sh NAME
-.Nm telnet
-.Nd user interface to the
-.Tn TELNET
-protocol
-.Sh SYNOPSIS
-.Nm telnet
-.Op Fl 8EFKLNacdfrx
-.Op Fl S Ar tos
-.Op Fl X Ar authtype
-.Op Fl e Ar escapechar
-.Op Fl k Ar realm
-.Op Fl l Ar user
-.Op Fl n Ar tracefile
-.Op Fl s Ar src_addr
-.Oo
-.Ar host
-.Op port
-.Oc
-.Sh DESCRIPTION
-The
-.Nm telnet
-command
-is used to communicate with another host using the
-.Tn TELNET
-protocol.
-If
-.Nm telnet
-is invoked without the
-.Ar host
-argument, it enters command mode,
-indicated by its prompt
-.Pq Nm telnet\&> .
-In this mode, it accepts and executes the commands listed below.
-If it is invoked with arguments, it performs an
-.Ic open
-command with those arguments.
-.Pp
-Options:
-.Bl -tag -width indent
-.It Fl 8
-Specifies an 8-bit data path. This causes an attempt to
-negotiate the
-.Dv TELNET BINARY
-option on both input and output.
-.It Fl E
-Stops any character from being recognized as an escape character.
-.It Fl F
-If Kerberos V5 authentication is being used, the
-.Fl F
-option allows the local credentials to be forwarded
-to the remote system, including any credentials that
-have already been forwarded into the local environment.
-.It Fl K
-Specifies no automatic login to the remote system.
-.It Fl L
-Specifies an 8-bit data path on output. This causes the
-BINARY option to be negotiated on output.
-.It Fl N
-Prevents IP address to name lookup when destination host is given
-as an IP address.
-.It Fl S Ar tos
-Sets the IP type-of-service (TOS) option for the telnet
-connection to the value
-.Ar tos,
-which can be a numeric TOS value
-or, on systems that support it, a symbolic
-TOS name found in the /etc/iptos file.
-.It Fl X Ar atype
-Disables the
-.Ar atype
-type of authentication.
-.It Fl a
-Attempt automatic login.
-Currently, this sends the user name via the
-.Ev USER
-variable
-of the
-.Ev ENVIRON
-option if supported by the remote system.
-The name used is that of the current user as returned by
-.Xr getlogin 2
-if it agrees with the current user ID,
-otherwise it is the name associated with the user ID.
-.It Fl c
-Disables the reading of the user's
-.Pa \&.telnetrc
-file. (See the
-.Ic toggle skiprc
-command on this man page.)
-.It Fl d
-Sets the initial value of the
-.Ic debug
-toggle to
-.Dv TRUE
-.It Fl e Ar escape char
-Sets the initial
-.Nm
-.Nm telnet
-escape character to
-.Ar escape char.
-If
-.Ar escape char
-is omitted, then
-there will be no escape character.
-.It Fl f
-If Kerberos V5 authentication is being used, the
-.Fl f
-option allows the local credentials to be forwarded to the remote system.
-.ne 1i
-.It Fl k Ar realm
-If Kerberos authentication is being used, the
-.Fl k
-option requests that telnet obtain tickets for the remote host in
-realm realm instead of the remote host's realm, as determined
-by
-.Xr krb_realmofhost 3 .
-.It Fl l Ar user
-When connecting to the remote system, if the remote system
-understands the
-.Ev ENVIRON
-option, then
-.Ar user
-will be sent to the remote system as the value for the variable USER.
-This option implies the
-.Fl a
-option.
-This option may also be used with the
-.Ic open
-command.
-.It Fl n Ar tracefile
-Opens
-.Ar tracefile
-for recording trace information.
-See the
-.Ic set tracefile
-command below.
-.It Fl r
-Specifies a user interface similar to
-.Xr rlogin 1 .
-In this
-mode, the escape character is set to the tilde (~) character,
-unless modified by the -e option.
-.It Fl s Ar src_addr
-Set the source IP address for the
-.Nm
-connection to
-.Ar src_addr ,
-which can be an IP address or a host name.
-.It Fl x
-Turns on encryption of the data stream if possible. This
-option is not available outside of the United States and
-Canada.
-.It Ar host
-Indicates the official name, an alias, or the Internet address
-of a remote host.
-.It Ar port
-Indicates a port number (address of an application). If a number is
-not specified, the default
-.Nm telnet
-port is used.
-.El
-.Pp
-When in rlogin mode, a line of the form ~. disconnects from the
-remote host; ~ is the telnet escape character.
-Similarly, the line ~^Z suspends the telnet session.
-The line ~^] escapes to the normal telnet escape prompt.
-.Pp
-Once a connection has been opened,
-.Nm telnet
-will attempt to enable the
-.Dv TELNET LINEMODE
-option.
-If this fails, then
-.Nm telnet
-will revert to one of two input modes:
-either \*(Lqcharacter at a time\*(Rq
-or \*(Lqold line by line\*(Rq
-depending on what the remote system supports.
-.Pp
-When
-.Dv LINEMODE
-is enabled, character processing is done on the
-local system, under the control of the remote system. When input
-editing or character echoing is to be disabled, the remote system
-will relay that information. The remote system will also relay
-changes to any special characters that happen on the remote
-system, so that they can take effect on the local system.
-.Pp
-In \*(Lqcharacter at a time\*(Rq mode, most
-text typed is immediately sent to the remote host for processing.
-.Pp
-In \*(Lqold line by line\*(Rq mode, all text is echoed locally,
-and (normally) only completed lines are sent to the remote host.
-The \*(Lqlocal echo character\*(Rq (initially \*(Lq^E\*(Rq) may be used
-to turn off and on the local echo
-(this would mostly be used to enter passwords
-without the password being echoed).
-.Pp
-If the
-.Dv LINEMODE
-option is enabled, or if the
-.Ic localchars
-toggle is
-.Dv TRUE
-(the default for \*(Lqold line by line\*(Lq; see below),
-the user's
-.Ic quit ,
-.Ic intr ,
-and
-.Ic flush
-characters are trapped locally, and sent as
-.Tn TELNET
-protocol sequences to the remote side.
-If
-.Dv LINEMODE
-has ever been enabled, then the user's
-.Ic susp
-and
-.Ic eof
-are also sent as
-.Tn TELNET
-protocol sequences,
-and
-.Ic quit
-is sent as a
-.Dv TELNET ABORT
-instead of
-.Dv BREAK
-There are options (see
-.Ic toggle
-.Ic autoflush
-and
-.Ic toggle
-.Ic autosynch
-below)
-which cause this action to flush subsequent output to the terminal
-(until the remote host acknowledges the
-.Tn TELNET
-sequence) and flush previous terminal input
-(in the case of
-.Ic quit
-and
-.Ic intr ) .
-.Pp
-While connected to a remote host,
-.Nm telnet
-command mode may be entered by typing the
-.Nm telnet
-\*(Lqescape character\*(Rq (initially \*(Lq^]\*(Rq).
-When in command mode, the normal terminal editing conventions are available.
-.Pp
-The following
-.Nm telnet
-commands are available.
-Only enough of each command to uniquely identify it need be typed
-(this is also true for arguments to the
-.Ic mode ,
-.Ic set ,
-.Ic toggle ,
-.Ic unset ,
-.Ic slc ,
-.Ic environ ,
-and
-.Ic display
-commands).
-.Pp
-.Bl -tag -width "mode type"
-.It Ic auth Ar argument ...
-The auth command manipulates the information sent through the
-.Dv TELNET AUTHENTICATE
-option. Valid arguments for the
-auth command are as follows:
-.Bl -tag -width "disable type"
-.It Ic disable Ar type
-Disables the specified type of authentication. To
-obtain a list of available types, use the
-.Ic auth disable \&?
-command.
-.It Ic enable Ar type
-Enables the specified type of authentication. To
-obtain a list of available types, use the
-.Ic auth enable \&?
-command.
-.It Ic status
-Lists the current status of the various types of
-authentication.
-.El
-.It Ic close
-Close a
-.Tn TELNET
-session and return to command mode.
-.It Ic display Ar argument ...
-Displays all, or some, of the
-.Ic set
-and
-.Ic toggle
-values (see below).
-.It Ic encrypt Ar argument ...
-The encrypt command manipulates the information sent through the
-.Dv TELNET ENCRYPT
-option.
-.Pp
-Note: Because of export controls, the
-.Dv TELNET ENCRYPT
-option is not supported outside of the United States and Canada.
-.Pp
-Valid arguments for the encrypt command are as follows:
-.Bl -tag -width Ar
-.It Ic disable Ar type Ic [input|output]
-Disables the specified type of encryption. If you
-omit the input and output, both input and output
-are disabled. To obtain a list of available
-types, use the
-.Ic encrypt disable \&?
-command.
-.It Ic enable Ar type Ic [input|output]
-Enables the specified type of encryption. If you
-omit input and output, both input and output are
-enabled. To obtain a list of available types, use the
-.Ic encrypt enable \&?
-command.
-.It Ic input
-This is the same as the
-.Ic encrypt start input
-command.
-.It Ic -input
-This is the same as the
-.Ic encrypt stop input
-command.
-.It Ic output
-This is the same as the
-.Ic encrypt start output
-command.
-.It Ic -output
-This is the same as the
-.Ic encrypt stop output
-command.
-.It Ic start Ic [input|output]
-Attempts to start encryption. If you omit
-.Ic input
-and
-.Ic output,
-both input and output are enabled. To
-obtain a list of available types, use the
-.Ic encrypt enable \&?
-command.
-.It Ic status
-Lists the current status of encryption.
-.It Ic stop Ic [input|output]
-Stops encryption. If you omit input and output,
-encryption is on both input and output.
-.It Ic type Ar type
-Sets the default type of encryption to be used
-with later
-.Ic encrypt start
-or
-.Ic encrypt stop
-commands.
-.El
-.It Ic environ Ar arguments...
-The
-.Ic environ
-command is used to manipulate the
-the variables that my be sent through the
-.Dv TELNET ENVIRON
-option.
-The initial set of variables is taken from the users
-environment, with only the
-.Ev DISPLAY
-and
-.Ev PRINTER
-variables being exported by default.
-The
-.Ev USER
-variable is also exported if the
-.Fl a
-or
-.Fl l
-options are used.
-.br
-Valid arguments for the
-.Ic environ
-command are:
-.Bl -tag -width Fl
-.It Ic define Ar variable value
-Define the variable
-.Ar variable
-to have a value of
-.Ar value.
-Any variables defined by this command are automatically exported.
-The
-.Ar value
-may be enclosed in single or double quotes so
-that tabs and spaces may be included.
-.It Ic undefine Ar variable
-Remove
-.Ar variable
-from the list of environment variables.
-.It Ic export Ar variable
-Mark the variable
-.Ar variable
-to be exported to the remote side.
-.It Ic unexport Ar variable
-Mark the variable
-.Ar variable
-to not be exported unless
-explicitly asked for by the remote side.
-.It Ic list
-List the current set of environment variables.
-Those marked with a
-.Cm *
-will be sent automatically,
-other variables will only be sent if explicitly requested.
-.It Ic \&?
-Prints out help information for the
-.Ic environ
-command.
-.El
-.It Ic logout
-Sends the
-.Dv TELNET LOGOUT
-option to the remote side.
-This command is similar to a
-.Ic close
-command; however, if the remote side does not support the
-.Dv LOGOUT
-option, nothing happens.
-If, however, the remote side does support the
-.Dv LOGOUT
-option, this command should cause the remote side to close the
-.Tn TELNET
-connection.
-If the remote side also supports the concept of
-suspending a user's session for later reattachment,
-the logout argument indicates that you
-should terminate the session immediately.
-.It Ic mode Ar type
-.Ar Type
-is one of several options, depending on the state of the
-.Tn TELNET
-session.
-The remote host is asked for permission to go into the requested mode.
-If the remote host is capable of entering that mode, the requested
-mode will be entered.
-.Bl -tag -width Ar
-.It Ic character
-Disable the
-.Dv TELNET LINEMODE
-option, or, if the remote side does not understand the
-.Dv LINEMODE
-option, then enter \*(Lqcharacter at a time\*(Lq mode.
-.It Ic line
-Enable the
-.Dv TELNET LINEMODE
-option, or, if the remote side does not understand the
-.Dv LINEMODE
-option, then attempt to enter \*(Lqold-line-by-line\*(Lq mode.
-.It Ic isig Pq Ic \-isig
-Attempt to enable (disable) the
-.Dv TRAPSIG
-mode of the
-.Dv LINEMODE
-option.
-This requires that the
-.Dv LINEMODE
-option be enabled.
-.It Ic edit Pq Ic \-edit
-Attempt to enable (disable) the
-.Dv EDIT
-mode of the
-.Dv LINEMODE
-option.
-This requires that the
-.Dv LINEMODE
-option be enabled.
-.It Ic softtabs Pq Ic \-softtabs
-Attempt to enable (disable) the
-.Dv SOFT_TAB
-mode of the
-.Dv LINEMODE
-option.
-This requires that the
-.Dv LINEMODE
-option be enabled.
-.ne 1i
-.It Ic litecho Pq Ic \-litecho
-Attempt to enable (disable) the
-.Dv LIT_ECHO
-mode of the
-.Dv LINEMODE
-option.
-This requires that the
-.Dv LINEMODE
-option be enabled.
-.It Ic \&?
-Prints out help information for the
-.Ic mode
-command.
-.El
-.It Xo
-.Ic open Ar host
-.Oo Op Fl l
-.Ar user
-.Oc Ns Oo Fl
-.Ar port Oc
-.Xc
-Open a connection to the named host.
-If no port number
-is specified,
-.Nm telnet
-will attempt to contact a
-.Tn TELNET
-server at the default port.
-The host specification may be either a host name (see
-.Xr hosts 5 ) ,
-an Internet address specified in the \*(Lqdot notation\*(Rq (see
-.Xr inet 3 ) ,
-or IPv6 host name or IPv6 coloned-hexadecimal addreess.
-The
-.Op Fl l
-option may be used to specify the user name
-to be passed to the remote system via the
-.Ev ENVIRON
-option.
-When connecting to a non-standard port,
-.Nm telnet
-omits any automatic initiation of
-.Tn TELNET
-options. When the port number is preceded by a minus sign,
-the initial option negotiation is done.
-After establishing a connection, the file
-.Pa \&.telnetrc
-in the
-users home directory is opened. Lines beginning with a # are
-comment lines. Blank lines are ignored. Lines that begin
-without white space are the start of a machine entry. The
-first thing on the line is the name of the machine that is
-being connected to. The rest of the line, and successive
-lines that begin with white space are assumed to be
-.Nm telnet
-commands and are processed as if they had been typed
-in manually to the
-.Nm telnet
-command prompt.
-.It Ic quit
-Close any open
-.Tn TELNET
-session and exit
-.Nm telnet .
-An end of file (in command mode) will also close a session and exit.
-.It Ic send Ar arguments
-Sends one or more special character sequences to the remote host.
-The following are the arguments which may be specified
-(more than one argument may be specified at a time):
-.Pp
-.Bl -tag -width escape
-.It Ic abort
-Sends the
-.Dv TELNET ABORT
-(Abort
-processes)
-sequence.
-.It Ic ao
-Sends the
-.Dv TELNET AO
-(Abort Output) sequence, which should cause the remote system to flush
-all output
-.Em from
-the remote system
-.Em to
-the user's terminal.
-.It Ic ayt
-Sends the
-.Dv TELNET AYT
-(Are You There)
-sequence, to which the remote system may or may not choose to respond.
-.It Ic brk
-Sends the
-.Dv TELNET BRK
-(Break) sequence, which may have significance to the remote
-system.
-.It Ic ec
-Sends the
-.Dv TELNET EC
-(Erase Character)
-sequence, which should cause the remote system to erase the last character
-entered.
-.It Ic el
-Sends the
-.Dv TELNET EL
-(Erase Line)
-sequence, which should cause the remote system to erase the line currently
-being entered.
-.It Ic eof
-Sends the
-.Dv TELNET EOF
-(End Of File)
-sequence.
-.It Ic eor
-Sends the
-.Dv TELNET EOR
-(End of Record)
-sequence.
-.It Ic escape
-Sends the current
-.Nm telnet
-escape character (initially \*(Lq^\*(Rq).
-.It Ic ga
-Sends the
-.Dv TELNET GA
-(Go Ahead)
-sequence, which likely has no significance to the remote system.
-.It Ic getstatus
-If the remote side supports the
-.Dv TELNET STATUS
-command,
-.Ic getstatus
-will send the subnegotiation to request that the server send
-its current option status.
-.ne 1i
-.It Ic ip
-Sends the
-.Dv TELNET IP
-(Interrupt Process) sequence, which should cause the remote
-system to abort the currently running process.
-.It Ic nop
-Sends the
-.Dv TELNET NOP
-(No OPeration)
-sequence.
-.It Ic susp
-Sends the
-.Dv TELNET SUSP
-(SUSPend process)
-sequence.
-.It Ic synch
-Sends the
-.Dv TELNET SYNCH
-sequence.
-This sequence causes the remote system to discard all previously typed
-(but not yet read) input.
-This sequence is sent as
-.Tn TCP
-urgent
-data (and may not work if the remote system is a
-.Bx 4.2
-system -- if
-it doesn't work, a lower case \*(Lqr\*(Rq may be echoed on the terminal).
-.It Ic do Ar cmd
-.It Ic dont Ar cmd
-.It Ic will Ar cmd
-.It Ic wont Ar cmd
-Sends the
-.Dv TELNET DO
-.Ar cmd
-sequence.
-.Ar Cmd
-can be either a decimal number between 0 and 255,
-or a symbolic name for a specific
-.Dv TELNET
-command.
-.Ar Cmd
-can also be either
-.Ic help
-or
-.Ic \&?
-to print out help information, including
-a list of known symbolic names.
-.It Ic \&?
-Prints out help information for the
-.Ic send
-command.
-.El
-.It Ic set Ar argument value
-.It Ic unset Ar argument value
-The
-.Ic set
-command will set any one of a number of
-.Nm telnet
-variables to a specific value or to
-.Dv TRUE .
-The special value
-.Ic off
-turns off the function associated with
-the variable, this is equivalent to using the
-.Ic unset
-command.
-The
-.Ic unset
-command will disable or set to
-.Dv FALSE
-any of the specified functions.
-The values of variables may be interrogated with the
-.Ic display
-command.
-The variables which may be set or unset, but not toggled, are
-listed here. In addition, any of the variables for the
-.Ic toggle
-command may be explicitly set or unset using
-the
-.Ic set
-and
-.Ic unset
-commands.
-.Bl -tag -width escape
-.It Ic ayt
-If
-.Tn TELNET
-is in localchars mode, or
-.Dv LINEMODE
-is enabled, and the status character is typed, a
-.Dv TELNET AYT
-sequence (see
-.Ic send ayt
-preceding) is sent to the
-remote host. The initial value for the "Are You There"
-character is the terminal's status character.
-.It Ic echo
-This is the value (initially \*(Lq^E\*(Rq) which, when in
-\*(Lqline by line\*(Rq mode, toggles between doing local echoing
-of entered characters (for normal processing), and suppressing
-echoing of entered characters (for entering, say, a password).
-.It Ic eof
-If
-.Nm telnet
-is operating in
-.Dv LINEMODE
-or \*(Lqold line by line\*(Rq mode, entering this character
-as the first character on a line will cause this character to be
-sent to the remote system.
-The initial value of the eof character is taken to be the terminal's
-.Ic eof
-character.
-.It Ic erase
-If
-.Nm telnet
-is in
-.Ic localchars
-mode (see
-.Ic toggle
-.Ic localchars
-below),
-.Sy and
-if
-.Nm telnet
-is operating in \*(Lqcharacter at a time\*(Rq mode, then when this
-character is typed, a
-.Dv TELNET EC
-sequence (see
-.Ic send
-.Ic ec
-above)
-is sent to the remote system.
-The initial value for the erase character is taken to be
-the terminal's
-.Ic erase
-character.
-.It Ic escape
-This is the
-.Nm telnet
-escape character (initially \*(Lq^[\*(Rq) which causes entry
-into
-.Nm telnet
-command mode (when connected to a remote system).
-.It Ic flushoutput
-If
-.Nm telnet
-is in
-.Ic localchars
-mode (see
-.Ic toggle
-.Ic localchars
-below)
-and the
-.Ic flushoutput
-character is typed, a
-.Dv TELNET AO
-sequence (see
-.Ic send
-.Ic ao
-above)
-is sent to the remote host.
-The initial value for the flush character is taken to be
-the terminal's
-.Ic flush
-character.
-.It Ic forw1
-.It Ic forw2
-If
-.Tn TELNET
-is operating in
-.Dv LINEMODE ,
-these are the
-characters that, when typed, cause partial lines to be
-forwarded to the remote system. The initial value for
-the forwarding characters are taken from the terminal's
-eol and eol2 characters.
-.It Ic interrupt
-If
-.Nm telnet
-is in
-.Ic localchars
-mode (see
-.Ic toggle
-.Ic localchars
-below)
-and the
-.Ic interrupt
-character is typed, a
-.Dv TELNET IP
-sequence (see
-.Ic send
-.Ic ip
-above)
-is sent to the remote host.
-The initial value for the interrupt character is taken to be
-the terminal's
-.Ic intr
-character.
-.It Ic kill
-If
-.Nm telnet
-is in
-.Ic localchars
-mode (see
-.Ic toggle
-.Ic localchars
-below),
-.Ic and
-if
-.Nm telnet
-is operating in \*(Lqcharacter at a time\*(Rq mode, then when this
-character is typed, a
-.Dv TELNET EL
-sequence (see
-.Ic send
-.Ic el
-above)
-is sent to the remote system.
-The initial value for the kill character is taken to be
-the terminal's
-.Ic kill
-character.
-.It Ic lnext
-If
-.Nm telnet
-is operating in
-.Dv LINEMODE
-or \*(Lqold line by line\*(Lq mode, then this character is taken to
-be the terminal's
-.Ic lnext
-character.
-The initial value for the lnext character is taken to be
-the terminal's
-.Ic lnext
-character.
-.It Ic quit
-If
-.Nm telnet
-is in
-.Ic localchars
-mode (see
-.Ic toggle
-.Ic localchars
-below)
-and the
-.Ic quit
-character is typed, a
-.Dv TELNET BRK
-sequence (see
-.Ic send
-.Ic brk
-above)
-is sent to the remote host.
-The initial value for the quit character is taken to be
-the terminal's
-.Ic quit
-character.
-.It Ic reprint
-If
-.Nm telnet
-is operating in
-.Dv LINEMODE
-or \*(Lqold line by line\*(Lq mode, then this character is taken to
-be the terminal's
-.Ic reprint
-character.
-The initial value for the reprint character is taken to be
-the terminal's
-.Ic reprint
-character.
-.It Ic rlogin
-This is the rlogin escape character.
-If set, the normal
-.Tn TELNET
-escape character is ignored unless it is
-preceded by this character at the beginning of a line.
-This character, at the beginning of a line followed by
-a "." closes the connection; when followed by a ^Z it
-suspends the telnet command. The initial state is to
-disable the rlogin escape character.
-.It Ic start
-If the
-.Dv TELNET TOGGLE-FLOW-CONTROL
-option has been enabled,
-then this character is taken to
-be the terminal's
-.Ic start
-character.
-The initial value for the kill character is taken to be
-the terminal's
-.Ic start
-character.
-.It Ic stop
-If the
-.Dv TELNET TOGGLE-FLOW-CONTROL
-option has been enabled,
-then this character is taken to
-be the terminal's
-.Ic stop
-character.
-The initial value for the kill character is taken to be
-the terminal's
-.Ic stop
-character.
-.It Ic susp
-If
-.Nm telnet
-is in
-.Ic localchars
-mode, or
-.Dv LINEMODE
-is enabled, and the
-.Ic suspend
-character is typed, a
-.Dv TELNET SUSP
-sequence (see
-.Ic send
-.Ic susp
-above)
-is sent to the remote host.
-The initial value for the suspend character is taken to be
-the terminal's
-.Ic suspend
-character.
-.ne 1i
-.It Ic tracefile
-This is the file to which the output, caused by
-.Ic netdata
-or
-.Ic option
-tracing being
-.Dv TRUE ,
-will be written. If it is set to
-.Dq Fl ,
-then tracing information will be written to standard output (the default).
-.It Ic worderase
-If
-.Nm telnet
-is operating in
-.Dv LINEMODE
-or \*(Lqold line by line\*(Lq mode, then this character is taken to
-be the terminal's
-.Ic worderase
-character.
-The initial value for the worderase character is taken to be
-the terminal's
-.Ic worderase
-character.
-.It Ic \&?
-Displays the legal
-.Ic set
-.Pq Ic unset
-commands.
-.El
-.It Ic skey Ar sequence challenge
-The
-.Ic skey
-command computes a response to the S/Key challenge.
-.It Ic slc Ar state
-The
-.Ic slc
-command (Set Local Characters) is used to set
-or change the state of the the special
-characters when the
-.Dv TELNET LINEMODE
-option has
-been enabled. Special characters are characters that get
-mapped to
-.Tn TELNET
-commands sequences (like
-.Ic ip
-or
-.Ic quit )
-or line editing characters (like
-.Ic erase
-and
-.Ic kill ) .
-By default, the local special characters are exported.
-.Bl -tag -width Fl
-.It Ic check
-Verify the current settings for the current special characters.
-The remote side is requested to send all the current special
-character settings, and if there are any discrepancies with
-the local side, the local side will switch to the remote value.
-.It Ic export
-Switch to the local defaults for the special characters. The
-local default characters are those of the local terminal at
-the time when
-.Nm telnet
-was started.
-.It Ic import
-Switch to the remote defaults for the special characters.
-The remote default characters are those of the remote system
-at the time when the
-.Tn TELNET
-connection was established.
-.It Ic \&?
-Prints out help information for the
-.Ic slc
-command.
-.El
-.It Ic status
-Show the current status of
-.Nm telnet .
-This includes the peer one is connected to, as well
-as the current mode.
-.It Ic toggle Ar arguments ...
-Toggle (between
-.Dv TRUE
-and
-.Dv FALSE )
-various flags that control how
-.Nm telnet
-responds to events.
-These flags may be set explicitly to
-.Dv TRUE
-or
-.Dv FALSE
-using the
-.Ic set
-and
-.Ic unset
-commands listed above.
-More than one argument may be specified.
-The state of these flags may be interrogated with the
-.Ic display
-command.
-Valid arguments are:
-.Bl -tag -width Ar
-.It Ic authdebug
-Turns on debugging information for the authentication code.
-.It Ic autoflush
-If
-.Ic autoflush
-and
-.Ic localchars
-are both
-.Dv TRUE ,
-then when the
-.Ic ao ,
-or
-.Ic quit
-characters are recognized (and transformed into
-.Tn TELNET
-sequences; see
-.Ic set
-above for details),
-.Nm telnet
-refuses to display any data on the user's terminal
-until the remote system acknowledges (via a
-.Dv TELNET TIMING MARK
-option)
-that it has processed those
-.Tn TELNET
-sequences.
-The initial value for this toggle is
-.Dv TRUE
-if the terminal user had not
-done an "stty noflsh", otherwise
-.Dv FALSE
-(see
-.Xr stty 1 ) .
-.It Ic autodecrypt
-When the
-.Dv TELNET ENCRYPT
-option is negotiated, by
-default the actual encryption (decryption) of the data
-stream does not start automatically. The autoencrypt
-(autodecrypt) command states that encryption of the
-output (input) stream should be enabled as soon as
-possible.
-.sp
-.Pp
-Note: Because of export controls, the
-.Dv TELNET ENCRYPT
-option is not supported outside the United States and Canada.
-.It Ic autologin
-If the remote side supports the
-.Dv TELNET AUTHENTICATION
-option
-.Tn TELNET
-attempts to use it to perform automatic authentication. If the
-.Dv AUTHENTICATION
-option is not supported, the user's login
-name are propagated through the
-.Dv TELNET ENVIRON
-option.
-This command is the same as specifying
-.Ar a
-option on the
-.Ic open
-command.
-.It Ic autosynch
-If
-.Ic autosynch
-and
-.Ic localchars
-are both
-.Dv TRUE ,
-then when either the
-.Ic intr
-or
-.Ic quit
-characters is typed (see
-.Ic set
-above for descriptions of the
-.Ic intr
-and
-.Ic quit
-characters), the resulting
-.Tn TELNET
-sequence sent is followed by the
-.Dv TELNET SYNCH
-sequence.
-This procedure
-.Ic should
-cause the remote system to begin throwing away all previously
-typed input until both of the
-.Tn TELNET
-sequences have been read and acted upon.
-The initial value of this toggle is
-.Dv FALSE .
-.It Ic binary
-Enable or disable the
-.Dv TELNET BINARY
-option on both input and output.
-.It Ic inbinary
-Enable or disable the
-.Dv TELNET BINARY
-option on input.
-.It Ic outbinary
-Enable or disable the
-.Dv TELNET BINARY
-option on output.
-.It Ic crlf
-If this is
-.Dv TRUE ,
-then carriage returns will be sent as
-.Li <CR><LF> .
-If this is
-.Dv FALSE ,
-then carriage returns will be send as
-.Li <CR><NUL> .
-The initial value for this toggle is
-.Dv FALSE .
-.It Ic crmod
-Toggle carriage return mode.
-When this mode is enabled, most carriage return characters received from
-the remote host will be mapped into a carriage return followed by
-a line feed.
-This mode does not affect those characters typed by the user, only
-those received from the remote host.
-This mode is not very useful unless the remote host
-only sends carriage return, but never line feed.
-The initial value for this toggle is
-.Dv FALSE .
-.It Ic debug
-Toggles socket level debugging (useful only to the
-.Ic super user ) .
-The initial value for this toggle is
-.Dv FALSE .
-.It Ic encdebug
-Turns on debugging information for the encryption code.
-.It Ic localchars
-If this is
-.Dv TRUE ,
-then the
-.Ic flush ,
-.Ic interrupt ,
-.Ic quit ,
-.Ic erase ,
-and
-.Ic kill
-characters (see
-.Ic set
-above) are recognized locally, and transformed into (hopefully) appropriate
-.Tn TELNET
-control sequences
-(respectively
-.Ic ao ,
-.Ic ip ,
-.Ic brk ,
-.Ic ec ,
-and
-.Ic el ;
-see
-.Ic send
-above).
-The initial value for this toggle is
-.Dv TRUE
-in \*(Lqold line by line\*(Rq mode,
-and
-.Dv FALSE
-in \*(Lqcharacter at a time\*(Rq mode.
-When the
-.Dv LINEMODE
-option is enabled, the value of
-.Ic localchars
-is ignored, and assumed to always be
-.Dv TRUE .
-If
-.Dv LINEMODE
-has ever been enabled, then
-.Ic quit
-is sent as
-.Ic abort ,
-and
-.Ic eof and
-.B suspend
-are sent as
-.Ic eof and
-.Ic susp ,
-see
-.Ic send
-above).
-.It Ic netdata
-Toggles the display of all network data (in hexadecimal format).
-The initial value for this toggle is
-.Dv FALSE .
-.It Ic options
-Toggles the display of some internal
-.Nm telnet
-protocol processing (having to do with
-.Tn TELNET
-options).
-The initial value for this toggle is
-.Dv FALSE .
-.ne 1i
-.It Ic prettydump
-When the
-.Ic netdata
-toggle is enabled, if
-.Ic prettydump
-is enabled the output from the
-.Ic netdata
-command will be formatted in a more user readable format.
-Spaces are put between each character in the output, and the
-beginning of any
-.Tn TELNET
-escape sequence is preceded by a '*' to aid in locating them.
-.It Ic skiprc
-When the skiprc toggle is
-.Dv TRUE ,
-.Tn TELNET
-skips the reading of the
-.Pa \&.telnetrc
-file in the users home
-directory when connections are opened. The initial
-value for this toggle is
-.Dv FALSE.
-.It Ic termdata
-Toggles the display of all terminal data (in hexadecimal format).
-The initial value for this toggle is
-.Dv FALSE .
-.It Ic verbose_encrypt
-When the
-.Ic verbose_encrypt
-toggle is
-.Dv TRUE ,
-.Tn TELNET
-prints out a message each time encryption is enabled or
-disabled. The initial value for this toggle is
-.Dv FALSE.
-Note: Because of export controls, data encryption
-is not supported outside of the United States and Canada.
-.It Ic \&?
-Displays the legal
-.Ic toggle
-commands.
-.El
-.It Ic z
-Suspend
-.Nm telnet .
-This command only works when the user is using the
-.Xr csh 1 .
-.It Ic \&! Op Ar command
-Execute a single command in a subshell on the local
-system. If
-.Ic command
-is omitted, then an interactive
-subshell is invoked.
-.It Ic \&? Op Ar command
-Get help. With no arguments,
-.Nm telnet
-prints a help summary.
-If a command is specified,
-.Nm telnet
-will print the help information for just that command.
-.El
-.Sh ENVIRONMENT
-.Nm Telnet
-uses at least the
-.Ev HOME ,
-.Ev SHELL ,
-.Ev DISPLAY ,
-and
-.Ev TERM
-environment variables.
-Other environment variables may be propagated
-to the other side via the
-.Dv TELNET ENVIRON
-option.
-.Sh FILES
-.Bl -tag -width ~/.telnetrc -compact
-.It Pa ~/.telnetrc
-user customized telnet startup values
-.El
-.Sh HISTORY
-The
-.Nm Telnet
-command appeared in
-.Bx 4.2 .
-.Pp
-IPv6 support was added by WIDE/KAME project.
-.Sh NOTES
-.Pp
-On some remote systems, echo has to be turned off manually when in
-\*(Lqold line by line\*(Rq mode.
-.Pp
-In \*(Lqold line by line\*(Rq mode or
-.Dv LINEMODE
-the terminal's
-.Ic eof
-character is only recognized (and sent to the remote system)
-when it is the first character on a line.
diff --git a/contrib/telnet/telnet/telnet.c b/contrib/telnet/telnet/telnet.c
deleted file mode 100644
index 1f9c38345af0..000000000000
--- a/contrib/telnet/telnet/telnet.c
+++ /dev/null
@@ -1,2662 +0,0 @@
-/*
- * Copyright (c) 1988, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-static const char sccsid[] = "@(#)telnet.c 8.4 (Berkeley) 5/30/95";
-#endif /* not lint */
-
-#include <sys/types.h>
-
-#if defined(unix)
-#include <signal.h>
-/* By the way, we need to include curses.h before telnet.h since,
- * among other things, telnet.h #defines 'DO', which is a variable
- * declared in curses.h.
- */
-#endif /* defined(unix) */
-
-#include <arpa/telnet.h>
-
-#include <ctype.h>
-
-#include <stdlib.h>
-#include <unistd.h>
-
-#include "ring.h"
-
-#include "defines.h"
-#include "externs.h"
-#include "types.h"
-#include "general.h"
-
-#if defined(AUTHENTICATION)
-#include <libtelnet/auth.h>
-#endif
-#if defined(ENCRYPTION)
-#include <libtelnet/encrypt.h>
-#endif
-#include <libtelnet/misc.h>
-
-#define strip(x) ((my_want_state_is_wont(TELOPT_BINARY)) ? ((x)&0x7f) : (x))
-
-static unsigned char subbuffer[SUBBUFSIZE],
- *subpointer, *subend; /* buffer for sub-options */
-#define SB_CLEAR() subpointer = subbuffer;
-#define SB_TERM() { subend = subpointer; SB_CLEAR(); }
-#define SB_ACCUM(c) if (subpointer < (subbuffer+sizeof subbuffer)) { \
- *subpointer++ = (c); \
- }
-
-#define SB_GET() ((*subpointer++)&0xff)
-#define SB_PEEK() ((*subpointer)&0xff)
-#define SB_EOF() (subpointer >= subend)
-#define SB_LEN() (subend - subpointer)
-
-char options[256]; /* The combined options */
-char do_dont_resp[256];
-char will_wont_resp[256];
-
-int
- eight = 0,
- autologin = 0, /* Autologin anyone? */
- skiprc = 0,
- connected,
- showoptions,
- In3270, /* Are we in 3270 mode? */
- ISend, /* trying to send network data in */
- debug = 0,
- crmod,
- netdata, /* Print out network data flow */
- crlf, /* Should '\r' be mapped to <CR><LF> (or <CR><NUL>)? */
-#if defined(TN3270)
- noasynchtty = 0,/* User specified "-noasynch" on command line */
- noasynchnet = 0,/* User specified "-noasynch" on command line */
- askedSGA = 0, /* We have talked about suppress go ahead */
-#endif /* defined(TN3270) */
- telnetport,
- SYNCHing, /* we are in TELNET SYNCH mode */
- flushout, /* flush output */
- autoflush = 0, /* flush output when interrupting? */
- autosynch, /* send interrupt characters with SYNCH? */
- localflow, /* we handle flow control locally */
- restartany, /* if flow control enabled, restart on any character */
- localchars, /* we recognize interrupt/quit */
- donelclchars, /* the user has set "localchars" */
- donebinarytoggle, /* the user has put us in binary */
- dontlecho, /* do we suppress local echoing right now? */
- globalmode,
- doaddrlookup = 1, /* do a reverse address lookup? */
- clienteof = 0;
-
-char *prompt = 0;
-
-cc_t escape;
-cc_t rlogin;
-#ifdef KLUDGELINEMODE
-cc_t echoc;
-#endif
-
-/*
- * Telnet receiver states for fsm
- */
-#define TS_DATA 0
-#define TS_IAC 1
-#define TS_WILL 2
-#define TS_WONT 3
-#define TS_DO 4
-#define TS_DONT 5
-#define TS_CR 6
-#define TS_SB 7 /* sub-option collection */
-#define TS_SE 8 /* looking for sub-option end */
-
-static int telrcv_state;
-#ifdef OLD_ENVIRON
-unsigned char telopt_environ = TELOPT_NEW_ENVIRON;
-#else
-# define telopt_environ TELOPT_NEW_ENVIRON
-#endif
-
-jmp_buf toplevel = { 0 };
-jmp_buf peerdied;
-
-int flushline;
-int linemode;
-
-#ifdef KLUDGELINEMODE
-int kludgelinemode = 1;
-#endif
-
-/*
- * The following are some clocks used to decide how to interpret
- * the relationship between various variables.
- */
-
-Clocks clocks;
-
-#ifdef notdef
-Modelist modelist[] = {
- { "telnet command mode", COMMAND_LINE },
- { "character-at-a-time mode", 0 },
- { "character-at-a-time mode (local echo)", LOCAL_ECHO|LOCAL_CHARS },
- { "line-by-line mode (remote echo)", LINE | LOCAL_CHARS },
- { "line-by-line mode", LINE | LOCAL_ECHO | LOCAL_CHARS },
- { "line-by-line mode (local echoing suppressed)", LINE | LOCAL_CHARS },
- { "3270 mode", 0 },
-};
-#endif
-
-
-/*
- * Initialize telnet environment.
- */
-
- void
-init_telnet()
-{
- env_init();
-
- SB_CLEAR();
- ClearArray(options);
-
- connected = In3270 = ISend = localflow = donebinarytoggle = 0;
-#if defined(AUTHENTICATION) || defined(ENCRYPTION)
- auth_encrypt_connect(connected);
-#endif /* defined(AUTHENTICATION) || defined(ENCRYPTION) */
- restartany = -1;
-
- SYNCHing = 0;
-
- /* Don't change NetTrace */
-
- escape = CONTROL(']');
- rlogin = _POSIX_VDISABLE;
-#ifdef KLUDGELINEMODE
- echoc = CONTROL('E');
-#endif
-
- flushline = 1;
- telrcv_state = TS_DATA;
-}
-
-
-#ifdef notdef
-#include <varargs.h>
-
- /*VARARGS*/
- static void
-printring(va_alist)
- va_dcl
-{
- va_list ap;
- char buffer[100]; /* where things go */
- char *ptr;
- char *format;
- char *string;
- Ring *ring;
- int i;
-
- va_start(ap);
-
- ring = va_arg(ap, Ring *);
- format = va_arg(ap, char *);
- ptr = buffer;
-
- while ((i = *format++) != 0) {
- if (i == '%') {
- i = *format++;
- switch (i) {
- case 'c':
- *ptr++ = va_arg(ap, int);
- break;
- case 's':
- string = va_arg(ap, char *);
- ring_supply_data(ring, buffer, ptr-buffer);
- ring_supply_data(ring, string, strlen(string));
- ptr = buffer;
- break;
- case 0:
- ExitString("printring: trailing %%.\n", 1);
- /*NOTREACHED*/
- default:
- ExitString("printring: unknown format character.\n", 1);
- /*NOTREACHED*/
- }
- } else {
- *ptr++ = i;
- }
- }
- ring_supply_data(ring, buffer, ptr-buffer);
-}
-#endif
-
-/*
- * These routines are in charge of sending option negotiations
- * to the other side.
- *
- * The basic idea is that we send the negotiation if either side
- * is in disagreement as to what the current state should be.
- */
-
- void
-send_do(c, init)
- register int c, init;
-{
- if (init) {
- if (((do_dont_resp[c] == 0) && my_state_is_do(c)) ||
- my_want_state_is_do(c))
- return;
- set_my_want_state_do(c);
- do_dont_resp[c]++;
- }
- NET2ADD(IAC, DO);
- NETADD(c);
- printoption("SENT", DO, c);
-}
-
- void
-send_dont(c, init)
- register int c, init;
-{
- if (init) {
- if (((do_dont_resp[c] == 0) && my_state_is_dont(c)) ||
- my_want_state_is_dont(c))
- return;
- set_my_want_state_dont(c);
- do_dont_resp[c]++;
- }
- NET2ADD(IAC, DONT);
- NETADD(c);
- printoption("SENT", DONT, c);
-}
-
- void
-send_will(c, init)
- register int c, init;
-{
- if (init) {
- if (((will_wont_resp[c] == 0) && my_state_is_will(c)) ||
- my_want_state_is_will(c))
- return;
- set_my_want_state_will(c);
- will_wont_resp[c]++;
- }
- NET2ADD(IAC, WILL);
- NETADD(c);
- printoption("SENT", WILL, c);
-}
-
- void
-send_wont(c, init)
- register int c, init;
-{
- if (init) {
- if (((will_wont_resp[c] == 0) && my_state_is_wont(c)) ||
- my_want_state_is_wont(c))
- return;
- set_my_want_state_wont(c);
- will_wont_resp[c]++;
- }
- NET2ADD(IAC, WONT);
- NETADD(c);
- printoption("SENT", WONT, c);
-}
-
-
- void
-willoption(option)
- int option;
-{
- int new_state_ok = 0;
-
- if (do_dont_resp[option]) {
- --do_dont_resp[option];
- if (do_dont_resp[option] && my_state_is_do(option))
- --do_dont_resp[option];
- }
-
- if ((do_dont_resp[option] == 0) && my_want_state_is_dont(option)) {
-
- switch (option) {
-
- case TELOPT_ECHO:
-# if defined(TN3270)
- /*
- * The following is a pain in the rear-end.
- * Various IBM servers (some versions of Wiscnet,
- * possibly Fibronics/Spartacus, and who knows who
- * else) will NOT allow us to send "DO SGA" too early
- * in the setup proceedings. On the other hand,
- * 4.2 servers (telnetd) won't set SGA correctly.
- * So, we are stuck. Empirically (but, based on
- * a VERY small sample), the IBM servers don't send
- * out anything about ECHO, so we postpone our sending
- * "DO SGA" until we see "WILL ECHO" (which 4.2 servers
- * DO send).
- */
- {
- if (askedSGA == 0) {
- askedSGA = 1;
- if (my_want_state_is_dont(TELOPT_SGA))
- send_do(TELOPT_SGA, 1);
- }
- }
- /* Fall through */
- case TELOPT_EOR:
-#endif /* defined(TN3270) */
- case TELOPT_BINARY:
- case TELOPT_SGA:
- settimer(modenegotiated);
- /* FALL THROUGH */
- case TELOPT_STATUS:
-#if defined(AUTHENTICATION)
- case TELOPT_AUTHENTICATION:
-#endif
-#ifdef ENCRYPTION
- case TELOPT_ENCRYPT:
-#endif /* ENCRYPTION */
- new_state_ok = 1;
- break;
-
- case TELOPT_TM:
- if (flushout)
- flushout = 0;
- /*
- * Special case for TM. If we get back a WILL,
- * pretend we got back a WONT.
- */
- set_my_want_state_dont(option);
- set_my_state_dont(option);
- return; /* Never reply to TM will's/wont's */
-
- case TELOPT_LINEMODE:
- default:
- break;
- }
-
- if (new_state_ok) {
- set_my_want_state_do(option);
- send_do(option, 0);
- setconnmode(0); /* possibly set new tty mode */
- } else {
- do_dont_resp[option]++;
- send_dont(option, 0);
- }
- }
- set_my_state_do(option);
-#ifdef ENCRYPTION
- if (option == TELOPT_ENCRYPT)
- encrypt_send_support();
-#endif /* ENCRYPTION */
-}
-
- void
-wontoption(option)
- int option;
-{
- if (do_dont_resp[option]) {
- --do_dont_resp[option];
- if (do_dont_resp[option] && my_state_is_dont(option))
- --do_dont_resp[option];
- }
-
- if ((do_dont_resp[option] == 0) && my_want_state_is_do(option)) {
-
- switch (option) {
-
-#ifdef KLUDGELINEMODE
- case TELOPT_SGA:
- if (!kludgelinemode)
- break;
- /* FALL THROUGH */
-#endif
- case TELOPT_ECHO:
- settimer(modenegotiated);
- break;
-
- case TELOPT_TM:
- if (flushout)
- flushout = 0;
- set_my_want_state_dont(option);
- set_my_state_dont(option);
- return; /* Never reply to TM will's/wont's */
-
- default:
- break;
- }
- set_my_want_state_dont(option);
- if (my_state_is_do(option))
- send_dont(option, 0);
- setconnmode(0); /* Set new tty mode */
- } else if (option == TELOPT_TM) {
- /*
- * Special case for TM.
- */
- if (flushout)
- flushout = 0;
- set_my_want_state_dont(option);
- }
- set_my_state_dont(option);
-}
-
- static void
-dooption(option)
- int option;
-{
- int new_state_ok = 0;
-
- if (will_wont_resp[option]) {
- --will_wont_resp[option];
- if (will_wont_resp[option] && my_state_is_will(option))
- --will_wont_resp[option];
- }
-
- if (will_wont_resp[option] == 0) {
- if (my_want_state_is_wont(option)) {
-
- switch (option) {
-
- case TELOPT_TM:
- /*
- * Special case for TM. We send a WILL, but pretend
- * we sent WONT.
- */
- send_will(option, 0);
- set_my_want_state_wont(TELOPT_TM);
- set_my_state_wont(TELOPT_TM);
- return;
-
-# if defined(TN3270)
- case TELOPT_EOR: /* end of record */
-# endif /* defined(TN3270) */
- case TELOPT_BINARY: /* binary mode */
- case TELOPT_NAWS: /* window size */
- case TELOPT_TSPEED: /* terminal speed */
- case TELOPT_LFLOW: /* local flow control */
- case TELOPT_TTYPE: /* terminal type option */
- case TELOPT_SGA: /* no big deal */
-#ifdef ENCRYPTION
- case TELOPT_ENCRYPT: /* encryption variable option */
-#endif /* ENCRYPTION */
- new_state_ok = 1;
- break;
-
- case TELOPT_NEW_ENVIRON: /* New environment variable option */
-#ifdef OLD_ENVIRON
- if (my_state_is_will(TELOPT_OLD_ENVIRON))
- send_wont(TELOPT_OLD_ENVIRON, 1); /* turn off the old */
- goto env_common;
- case TELOPT_OLD_ENVIRON: /* Old environment variable option */
- if (my_state_is_will(TELOPT_NEW_ENVIRON))
- break; /* Don't enable if new one is in use! */
- env_common:
- telopt_environ = option;
-#endif
- new_state_ok = 1;
- break;
-
-#if defined(AUTHENTICATION)
- case TELOPT_AUTHENTICATION:
- if (autologin)
- new_state_ok = 1;
- break;
-#endif
-
- case TELOPT_XDISPLOC: /* X Display location */
- if (env_getvalue((unsigned char *)"DISPLAY"))
- new_state_ok = 1;
- break;
-
- case TELOPT_LINEMODE:
-#ifdef KLUDGELINEMODE
- kludgelinemode = 0;
- send_do(TELOPT_SGA, 1);
-#endif
- set_my_want_state_will(TELOPT_LINEMODE);
- send_will(option, 0);
- set_my_state_will(TELOPT_LINEMODE);
- slc_init();
- return;
-
- case TELOPT_ECHO: /* We're never going to echo... */
- default:
- break;
- }
-
- if (new_state_ok) {
- set_my_want_state_will(option);
- send_will(option, 0);
- setconnmode(0); /* Set new tty mode */
- } else {
- will_wont_resp[option]++;
- send_wont(option, 0);
- }
- } else {
- /*
- * Handle options that need more things done after the
- * other side has acknowledged the option.
- */
- switch (option) {
- case TELOPT_LINEMODE:
-#ifdef KLUDGELINEMODE
- kludgelinemode = 0;
- send_do(TELOPT_SGA, 1);
-#endif
- set_my_state_will(option);
- slc_init();
- send_do(TELOPT_SGA, 0);
- return;
- }
- }
- }
- set_my_state_will(option);
-}
-
- static void
-dontoption(option)
- int option;
-{
-
- if (will_wont_resp[option]) {
- --will_wont_resp[option];
- if (will_wont_resp[option] && my_state_is_wont(option))
- --will_wont_resp[option];
- }
-
- if ((will_wont_resp[option] == 0) && my_want_state_is_will(option)) {
- switch (option) {
- case TELOPT_LINEMODE:
- linemode = 0; /* put us back to the default state */
- break;
-#ifdef OLD_ENVIRON
- case TELOPT_NEW_ENVIRON:
- /*
- * The new environ option wasn't recognized, try
- * the old one.
- */
- send_will(TELOPT_OLD_ENVIRON, 1);
- telopt_environ = TELOPT_OLD_ENVIRON;
- break;
-#endif
- }
- /* we always accept a DONT */
- set_my_want_state_wont(option);
- if (my_state_is_will(option))
- send_wont(option, 0);
- setconnmode(0); /* Set new tty mode */
- }
- set_my_state_wont(option);
-}
-
-/*
- * Given a buffer returned by tgetent(), this routine will turn
- * the pipe seperated list of names in the buffer into an array
- * of pointers to null terminated names. We toss out any bad,
- * duplicate, or verbose names (names with spaces).
- */
-
-static char *name_unknown = "UNKNOWN";
-static char *unknown[] = { 0, 0 };
-
- char **
-mklist(buf, name)
- char *buf, *name;
-{
- register int n;
- register char c, *cp, **argvp, *cp2, **argv, **avt;
-
- if (name) {
- if ((int)strlen(name) > 40) {
- name = 0;
- unknown[0] = name_unknown;
- } else {
- unknown[0] = name;
- upcase(name);
- }
- } else
- unknown[0] = name_unknown;
- /*
- * Count up the number of names.
- */
- for (n = 1, cp = buf; *cp && *cp != ':'; cp++) {
- if (*cp == '|')
- n++;
- }
- /*
- * Allocate an array to put the name pointers into
- */
- argv = (char **)malloc((n+3)*sizeof(char *));
- if (argv == 0)
- return(unknown);
-
- /*
- * Fill up the array of pointers to names.
- */
- *argv = 0;
- argvp = argv+1;
- n = 0;
- for (cp = cp2 = buf; (c = *cp); cp++) {
- if (c == '|' || c == ':') {
- *cp++ = '\0';
- /*
- * Skip entries that have spaces or are over 40
- * characters long. If this is our environment
- * name, then put it up front. Otherwise, as
- * long as this is not a duplicate name (case
- * insensitive) add it to the list.
- */
- if (n || (cp - cp2 > 41))
- ;
- else if (name && (strncasecmp(name, cp2, cp-cp2) == 0))
- *argv = cp2;
- else if (is_unique(cp2, argv+1, argvp))
- *argvp++ = cp2;
- if (c == ':')
- break;
- /*
- * Skip multiple delimiters. Reset cp2 to
- * the beginning of the next name. Reset n,
- * the flag for names with spaces.
- */
- while ((c = *cp) == '|')
- cp++;
- cp2 = cp;
- n = 0;
- }
- /*
- * Skip entries with spaces or non-ascii values.
- * Convert lower case letters to upper case.
- */
- if ((c == ' ') || !isascii(c))
- n = 1;
- else if (islower(c))
- *cp = toupper(c);
- }
-
- /*
- * Check for an old V6 2 character name. If the second
- * name points to the beginning of the buffer, and is
- * only 2 characters long, move it to the end of the array.
- */
- if ((argv[1] == buf) && (strlen(argv[1]) == 2)) {
- --argvp;
- for (avt = &argv[1]; avt < argvp; avt++)
- *avt = *(avt+1);
- *argvp++ = buf;
- }
-
- /*
- * Duplicate last name, for TTYPE option, and null
- * terminate the array. If we didn't find a match on
- * our terminal name, put that name at the beginning.
- */
- cp = *(argvp-1);
- *argvp++ = cp;
- *argvp = 0;
-
- if (*argv == 0) {
- if (name)
- *argv = name;
- else {
- --argvp;
- for (avt = argv; avt < argvp; avt++)
- *avt = *(avt+1);
- }
- }
- if (*argv)
- return(argv);
- else
- return(unknown);
-}
-
- int
-is_unique(name, as, ae)
- register char *name, **as, **ae;
-{
- register char **ap;
- register int n;
-
- n = strlen(name) + 1;
- for (ap = as; ap < ae; ap++)
- if (strncasecmp(*ap, name, n) == 0)
- return(0);
- return (1);
-}
-
-#ifdef TERMCAP
-char termbuf[1024];
-
- /*ARGSUSED*/
- int
-setupterm(tname, fd, errp)
- char *tname;
- int fd, *errp;
-{
- if (tgetent(termbuf, tname) == 1) {
- termbuf[1023] = '\0';
- if (errp)
- *errp = 1;
- return(0);
- }
- if (errp)
- *errp = 0;
- return(-1);
-}
-#else
-#define termbuf ttytype
-extern char ttytype[];
-#endif
-
-int resettermname = 1;
-
- char *
-gettermname()
-{
- char *tname;
- static char **tnamep = 0;
- static char **next;
- int err;
-
- if (resettermname) {
- resettermname = 0;
- if (tnamep && tnamep != unknown)
- free(tnamep);
- if ((tname = (char *)env_getvalue((unsigned char *)"TERM")) &&
- (setupterm(tname, 1, &err) == 0)) {
- tnamep = mklist(termbuf, tname);
- } else {
- if (tname && ((int)strlen(tname) <= 40)) {
- unknown[0] = tname;
- upcase(tname);
- } else
- unknown[0] = name_unknown;
- tnamep = unknown;
- }
- next = tnamep;
- }
- if (*next == 0)
- next = tnamep;
- return(*next++);
-}
-/*
- * suboption()
- *
- * Look at the sub-option buffer, and try to be helpful to the other
- * side.
- *
- * Currently we recognize:
- *
- * Terminal type, send request.
- * Terminal speed (send request).
- * Local flow control (is request).
- * Linemode
- */
-
- static void
-suboption()
-{
- unsigned char subchar;
-
- printsub('<', subbuffer, SB_LEN()+2);
- switch (subchar = SB_GET()) {
- case TELOPT_TTYPE:
- if (my_want_state_is_wont(TELOPT_TTYPE))
- return;
- if (SB_EOF() || SB_GET() != TELQUAL_SEND) {
- return;
- } else {
- char *name;
- unsigned char temp[50];
- int len;
-
-#if defined(TN3270)
- if (tn3270_ttype()) {
- return;
- }
-#endif /* defined(TN3270) */
- name = gettermname();
- len = strlen(name) + 4 + 2;
- if (len < NETROOM()) {
- sprintf((char *)temp, "%c%c%c%c%s%c%c", IAC, SB, TELOPT_TTYPE,
- TELQUAL_IS, name, IAC, SE);
- ring_supply_data(&netoring, temp, len);
- printsub('>', &temp[2], len-2);
- } else {
- ExitString("No room in buffer for terminal type.\n", 1);
- /*NOTREACHED*/
- }
- }
- break;
- case TELOPT_TSPEED:
- if (my_want_state_is_wont(TELOPT_TSPEED))
- return;
- if (SB_EOF())
- return;
- if (SB_GET() == TELQUAL_SEND) {
- long ospeed, ispeed;
- unsigned char temp[50];
- int len;
-
- TerminalSpeeds(&ispeed, &ospeed);
-
- sprintf((char *)temp, "%c%c%c%c%ld,%ld%c%c", IAC, SB, TELOPT_TSPEED,
- TELQUAL_IS, ospeed, ispeed, IAC, SE);
- len = strlen((char *)temp+4) + 4; /* temp[3] is 0 ... */
-
- if (len < NETROOM()) {
- ring_supply_data(&netoring, temp, len);
- printsub('>', temp+2, len - 2);
- }
-/*@*/ else printf("lm_will: not enough room in buffer\n");
- }
- break;
- case TELOPT_LFLOW:
- if (my_want_state_is_wont(TELOPT_LFLOW))
- return;
- if (SB_EOF())
- return;
- switch(SB_GET()) {
- case LFLOW_RESTART_ANY:
- restartany = 1;
- break;
- case LFLOW_RESTART_XON:
- restartany = 0;
- break;
- case LFLOW_ON:
- localflow = 1;
- break;
- case LFLOW_OFF:
- localflow = 0;
- break;
- default:
- return;
- }
- setcommandmode();
- setconnmode(0);
- break;
-
- case TELOPT_LINEMODE:
- if (my_want_state_is_wont(TELOPT_LINEMODE))
- return;
- if (SB_EOF())
- return;
- switch (SB_GET()) {
- case WILL:
- lm_will(subpointer, SB_LEN());
- break;
- case WONT:
- lm_wont(subpointer, SB_LEN());
- break;
- case DO:
- lm_do(subpointer, SB_LEN());
- break;
- case DONT:
- lm_dont(subpointer, SB_LEN());
- break;
- case LM_SLC:
- slc(subpointer, SB_LEN());
- break;
- case LM_MODE:
- lm_mode(subpointer, SB_LEN(), 0);
- break;
- default:
- break;
- }
- break;
-
-#ifdef OLD_ENVIRON
- case TELOPT_OLD_ENVIRON:
-#endif
- case TELOPT_NEW_ENVIRON:
- if (SB_EOF())
- return;
- switch(SB_PEEK()) {
- case TELQUAL_IS:
- case TELQUAL_INFO:
- if (my_want_state_is_dont(subchar))
- return;
- break;
- case TELQUAL_SEND:
- if (my_want_state_is_wont(subchar)) {
- return;
- }
- break;
- default:
- return;
- }
- env_opt(subpointer, SB_LEN());
- break;
-
- case TELOPT_XDISPLOC:
- if (my_want_state_is_wont(TELOPT_XDISPLOC))
- return;
- if (SB_EOF())
- return;
- if (SB_GET() == TELQUAL_SEND) {
- unsigned char temp[50], *dp;
- int len;
-
- if ((dp = env_getvalue((unsigned char *)"DISPLAY")) == NULL) {
- /*
- * Something happened, we no longer have a DISPLAY
- * variable. So, turn off the option.
- */
- send_wont(TELOPT_XDISPLOC, 1);
- break;
- }
- sprintf((char *)temp, "%c%c%c%c%s%c%c", IAC, SB, TELOPT_XDISPLOC,
- TELQUAL_IS, dp, IAC, SE);
- len = strlen((char *)temp+4) + 4; /* temp[3] is 0 ... */
-
- if (len < NETROOM()) {
- ring_supply_data(&netoring, temp, len);
- printsub('>', temp+2, len - 2);
- }
-/*@*/ else printf("lm_will: not enough room in buffer\n");
- }
- break;
-
-#if defined(AUTHENTICATION)
- case TELOPT_AUTHENTICATION: {
- if (!autologin)
- break;
- if (SB_EOF())
- return;
- switch(SB_GET()) {
- case TELQUAL_IS:
- if (my_want_state_is_dont(TELOPT_AUTHENTICATION))
- return;
- auth_is(subpointer, SB_LEN());
- break;
- case TELQUAL_SEND:
- if (my_want_state_is_wont(TELOPT_AUTHENTICATION))
- return;
- auth_send(subpointer, SB_LEN());
- break;
- case TELQUAL_REPLY:
- if (my_want_state_is_wont(TELOPT_AUTHENTICATION))
- return;
- auth_reply(subpointer, SB_LEN());
- break;
- case TELQUAL_NAME:
- if (my_want_state_is_dont(TELOPT_AUTHENTICATION))
- return;
- auth_name(subpointer, SB_LEN());
- break;
- }
- }
- break;
-#endif
-#ifdef ENCRYPTION
- case TELOPT_ENCRYPT:
- if (SB_EOF())
- return;
- switch(SB_GET()) {
- case ENCRYPT_START:
- if (my_want_state_is_dont(TELOPT_ENCRYPT))
- return;
- encrypt_start(subpointer, SB_LEN());
- break;
- case ENCRYPT_END:
- if (my_want_state_is_dont(TELOPT_ENCRYPT))
- return;
- encrypt_end();
- break;
- case ENCRYPT_SUPPORT:
- if (my_want_state_is_wont(TELOPT_ENCRYPT))
- return;
- encrypt_support(subpointer, SB_LEN());
- break;
- case ENCRYPT_REQSTART:
- if (my_want_state_is_wont(TELOPT_ENCRYPT))
- return;
- encrypt_request_start(subpointer, SB_LEN());
- break;
- case ENCRYPT_REQEND:
- if (my_want_state_is_wont(TELOPT_ENCRYPT))
- return;
- /*
- * We can always send an REQEND so that we cannot
- * get stuck encrypting. We should only get this
- * if we have been able to get in the correct mode
- * anyhow.
- */
- encrypt_request_end();
- break;
- case ENCRYPT_IS:
- if (my_want_state_is_dont(TELOPT_ENCRYPT))
- return;
- encrypt_is(subpointer, SB_LEN());
- break;
- case ENCRYPT_REPLY:
- if (my_want_state_is_wont(TELOPT_ENCRYPT))
- return;
- encrypt_reply(subpointer, SB_LEN());
- break;
- case ENCRYPT_ENC_KEYID:
- if (my_want_state_is_dont(TELOPT_ENCRYPT))
- return;
- encrypt_enc_keyid(subpointer, SB_LEN());
- break;
- case ENCRYPT_DEC_KEYID:
- if (my_want_state_is_wont(TELOPT_ENCRYPT))
- return;
- encrypt_dec_keyid(subpointer, SB_LEN());
- break;
- default:
- break;
- }
- break;
-#endif /* ENCRYPTION */
- default:
- break;
- }
-}
-
-static unsigned char str_lm[] = { IAC, SB, TELOPT_LINEMODE, 0, 0, IAC, SE };
-
- void
-lm_will(cmd, len)
- unsigned char *cmd;
- int len;
-{
- if (len < 1) {
-/*@*/ printf("lm_will: no command!!!\n"); /* Should not happen... */
- return;
- }
- switch(cmd[0]) {
- case LM_FORWARDMASK: /* We shouldn't ever get this... */
- default:
- str_lm[3] = DONT;
- str_lm[4] = cmd[0];
- if (NETROOM() > sizeof(str_lm)) {
- ring_supply_data(&netoring, str_lm, sizeof(str_lm));
- printsub('>', &str_lm[2], sizeof(str_lm)-2);
- }
-/*@*/ else printf("lm_will: not enough room in buffer\n");
- break;
- }
-}
-
- void
-lm_wont(cmd, len)
- unsigned char *cmd;
- int len;
-{
- if (len < 1) {
-/*@*/ printf("lm_wont: no command!!!\n"); /* Should not happen... */
- return;
- }
- switch(cmd[0]) {
- case LM_FORWARDMASK: /* We shouldn't ever get this... */
- default:
- /* We are always DONT, so don't respond */
- return;
- }
-}
-
- void
-lm_do(cmd, len)
- unsigned char *cmd;
- int len;
-{
- if (len < 1) {
-/*@*/ printf("lm_do: no command!!!\n"); /* Should not happen... */
- return;
- }
- switch(cmd[0]) {
- case LM_FORWARDMASK:
- default:
- str_lm[3] = WONT;
- str_lm[4] = cmd[0];
- if (NETROOM() > sizeof(str_lm)) {
- ring_supply_data(&netoring, str_lm, sizeof(str_lm));
- printsub('>', &str_lm[2], sizeof(str_lm)-2);
- }
-/*@*/ else printf("lm_do: not enough room in buffer\n");
- break;
- }
-}
-
- void
-lm_dont(cmd, len)
- unsigned char *cmd;
- int len;
-{
- if (len < 1) {
-/*@*/ printf("lm_dont: no command!!!\n"); /* Should not happen... */
- return;
- }
- switch(cmd[0]) {
- case LM_FORWARDMASK:
- default:
- /* we are always WONT, so don't respond */
- break;
- }
-}
-
-static unsigned char str_lm_mode[] = {
- IAC, SB, TELOPT_LINEMODE, LM_MODE, 0, IAC, SE
-};
-
- void
-lm_mode(cmd, len, init)
- unsigned char *cmd;
- int len, init;
-{
- if (len != 1)
- return;
- if ((linemode&MODE_MASK&~MODE_ACK) == *cmd)
- return;
- if (*cmd&MODE_ACK)
- return;
- linemode = *cmd&(MODE_MASK&~MODE_ACK);
- str_lm_mode[4] = linemode;
- if (!init)
- str_lm_mode[4] |= MODE_ACK;
- if (NETROOM() > sizeof(str_lm_mode)) {
- ring_supply_data(&netoring, str_lm_mode, sizeof(str_lm_mode));
- printsub('>', &str_lm_mode[2], sizeof(str_lm_mode)-2);
- }
-/*@*/ else printf("lm_mode: not enough room in buffer\n");
- setconnmode(0); /* set changed mode */
-}
-
-
-
-/*
- * slc()
- * Handle special character suboption of LINEMODE.
- */
-
-struct spc {
- cc_t val;
- cc_t *valp;
- char flags; /* Current flags & level */
- char mylevel; /* Maximum level & flags */
-} spc_data[NSLC+1];
-
-#define SLC_IMPORT 0
-#define SLC_EXPORT 1
-#define SLC_RVALUE 2
-static int slc_mode = SLC_EXPORT;
-
- void
-slc_init()
-{
- register struct spc *spcp;
-
- localchars = 1;
- for (spcp = spc_data; spcp < &spc_data[NSLC+1]; spcp++) {
- spcp->val = 0;
- spcp->valp = 0;
- spcp->flags = spcp->mylevel = SLC_NOSUPPORT;
- }
-
-#define initfunc(func, flags) { \
- spcp = &spc_data[func]; \
- if ((spcp->valp = tcval(func))) { \
- spcp->val = *spcp->valp; \
- spcp->mylevel = SLC_VARIABLE|flags; \
- } else { \
- spcp->val = 0; \
- spcp->mylevel = SLC_DEFAULT; \
- } \
- }
-
- initfunc(SLC_SYNCH, 0);
- /* No BRK */
- initfunc(SLC_AO, 0);
- initfunc(SLC_AYT, 0);
- /* No EOR */
- initfunc(SLC_ABORT, SLC_FLUSHIN|SLC_FLUSHOUT);
- initfunc(SLC_EOF, 0);
-#ifndef SYSV_TERMIO
- initfunc(SLC_SUSP, SLC_FLUSHIN);
-#endif
- initfunc(SLC_EC, 0);
- initfunc(SLC_EL, 0);
-#ifndef SYSV_TERMIO
- initfunc(SLC_EW, 0);
- initfunc(SLC_RP, 0);
- initfunc(SLC_LNEXT, 0);
-#endif
- initfunc(SLC_XON, 0);
- initfunc(SLC_XOFF, 0);
-#ifdef SYSV_TERMIO
- spc_data[SLC_XON].mylevel = SLC_CANTCHANGE;
- spc_data[SLC_XOFF].mylevel = SLC_CANTCHANGE;
-#endif
- initfunc(SLC_FORW1, 0);
-#ifdef USE_TERMIO
- initfunc(SLC_FORW2, 0);
- /* No FORW2 */
-#endif
-
- initfunc(SLC_IP, SLC_FLUSHIN|SLC_FLUSHOUT);
-#undef initfunc
-
- if (slc_mode == SLC_EXPORT)
- slc_export();
- else
- slc_import(1);
-
-}
-
- void
-slcstate()
-{
- printf("Special characters are %s values\n",
- slc_mode == SLC_IMPORT ? "remote default" :
- slc_mode == SLC_EXPORT ? "local" :
- "remote");
-}
-
- void
-slc_mode_export()
-{
- slc_mode = SLC_EXPORT;
- if (my_state_is_will(TELOPT_LINEMODE))
- slc_export();
-}
-
- void
-slc_mode_import(def)
- int def;
-{
- slc_mode = def ? SLC_IMPORT : SLC_RVALUE;
- if (my_state_is_will(TELOPT_LINEMODE))
- slc_import(def);
-}
-
-unsigned char slc_import_val[] = {
- IAC, SB, TELOPT_LINEMODE, LM_SLC, 0, SLC_VARIABLE, 0, IAC, SE
-};
-unsigned char slc_import_def[] = {
- IAC, SB, TELOPT_LINEMODE, LM_SLC, 0, SLC_DEFAULT, 0, IAC, SE
-};
-
- void
-slc_import(def)
- int def;
-{
- if (NETROOM() > sizeof(slc_import_val)) {
- if (def) {
- ring_supply_data(&netoring, slc_import_def, sizeof(slc_import_def));
- printsub('>', &slc_import_def[2], sizeof(slc_import_def)-2);
- } else {
- ring_supply_data(&netoring, slc_import_val, sizeof(slc_import_val));
- printsub('>', &slc_import_val[2], sizeof(slc_import_val)-2);
- }
- }
-/*@*/ else printf("slc_import: not enough room\n");
-}
-
- void
-slc_export()
-{
- register struct spc *spcp;
-
- TerminalDefaultChars();
-
- slc_start_reply();
- for (spcp = &spc_data[1]; spcp < &spc_data[NSLC+1]; spcp++) {
- if (spcp->mylevel != SLC_NOSUPPORT) {
- if (spcp->val == (cc_t)(_POSIX_VDISABLE))
- spcp->flags = SLC_NOSUPPORT;
- else
- spcp->flags = spcp->mylevel;
- if (spcp->valp)
- spcp->val = *spcp->valp;
- slc_add_reply(spcp - spc_data, spcp->flags, spcp->val);
- }
- }
- slc_end_reply();
- (void)slc_update();
- setconnmode(1); /* Make sure the character values are set */
-}
-
- void
-slc(cp, len)
- register unsigned char *cp;
- int len;
-{
- register struct spc *spcp;
- register int func,level;
-
- slc_start_reply();
-
- for (; len >= 3; len -=3, cp +=3) {
-
- func = cp[SLC_FUNC];
-
- if (func == 0) {
- /*
- * Client side: always ignore 0 function.
- */
- continue;
- }
- if (func > NSLC) {
- if ((cp[SLC_FLAGS] & SLC_LEVELBITS) != SLC_NOSUPPORT)
- slc_add_reply(func, SLC_NOSUPPORT, 0);
- continue;
- }
-
- spcp = &spc_data[func];
-
- level = cp[SLC_FLAGS]&(SLC_LEVELBITS|SLC_ACK);
-
- if ((cp[SLC_VALUE] == (unsigned char)spcp->val) &&
- ((level&SLC_LEVELBITS) == (spcp->flags&SLC_LEVELBITS))) {
- continue;
- }
-
- if (level == (SLC_DEFAULT|SLC_ACK)) {
- /*
- * This is an error condition, the SLC_ACK
- * bit should never be set for the SLC_DEFAULT
- * level. Our best guess to recover is to
- * ignore the SLC_ACK bit.
- */
- cp[SLC_FLAGS] &= ~SLC_ACK;
- }
-
- if (level == ((spcp->flags&SLC_LEVELBITS)|SLC_ACK)) {
- spcp->val = (cc_t)cp[SLC_VALUE];
- spcp->flags = cp[SLC_FLAGS]; /* include SLC_ACK */
- continue;
- }
-
- level &= ~SLC_ACK;
-
- if (level <= (spcp->mylevel&SLC_LEVELBITS)) {
- spcp->flags = cp[SLC_FLAGS]|SLC_ACK;
- spcp->val = (cc_t)cp[SLC_VALUE];
- }
- if (level == SLC_DEFAULT) {
- if ((spcp->mylevel&SLC_LEVELBITS) != SLC_DEFAULT)
- spcp->flags = spcp->mylevel;
- else
- spcp->flags = SLC_NOSUPPORT;
- }
- slc_add_reply(func, spcp->flags, spcp->val);
- }
- slc_end_reply();
- if (slc_update())
- setconnmode(1); /* set the new character values */
-}
-
- void
-slc_check()
-{
- register struct spc *spcp;
-
- slc_start_reply();
- for (spcp = &spc_data[1]; spcp < &spc_data[NSLC+1]; spcp++) {
- if (spcp->valp && spcp->val != *spcp->valp) {
- spcp->val = *spcp->valp;
- if (spcp->val == (cc_t)(_POSIX_VDISABLE))
- spcp->flags = SLC_NOSUPPORT;
- else
- spcp->flags = spcp->mylevel;
- slc_add_reply(spcp - spc_data, spcp->flags, spcp->val);
- }
- }
- slc_end_reply();
- setconnmode(1);
-}
-
-
-unsigned char slc_reply[128];
-unsigned char *slc_replyp;
-
- void
-slc_start_reply()
-{
- slc_replyp = slc_reply;
- *slc_replyp++ = IAC;
- *slc_replyp++ = SB;
- *slc_replyp++ = TELOPT_LINEMODE;
- *slc_replyp++ = LM_SLC;
-}
-
- void
-slc_add_reply(func, flags, value)
- unsigned char func;
- unsigned char flags;
- cc_t value;
-{
- if ((*slc_replyp++ = func) == IAC)
- *slc_replyp++ = IAC;
- if ((*slc_replyp++ = flags) == IAC)
- *slc_replyp++ = IAC;
- if ((*slc_replyp++ = (unsigned char)value) == IAC)
- *slc_replyp++ = IAC;
-}
-
- void
-slc_end_reply()
-{
- register int len;
-
- *slc_replyp++ = IAC;
- *slc_replyp++ = SE;
- len = slc_replyp - slc_reply;
- if (len <= 6)
- return;
- if (NETROOM() > len) {
- ring_supply_data(&netoring, slc_reply, slc_replyp - slc_reply);
- printsub('>', &slc_reply[2], slc_replyp - slc_reply - 2);
- }
-/*@*/else printf("slc_end_reply: not enough room\n");
-}
-
- int
-slc_update()
-{
- register struct spc *spcp;
- int need_update = 0;
-
- for (spcp = &spc_data[1]; spcp < &spc_data[NSLC+1]; spcp++) {
- if (!(spcp->flags&SLC_ACK))
- continue;
- spcp->flags &= ~SLC_ACK;
- if (spcp->valp && (*spcp->valp != spcp->val)) {
- *spcp->valp = spcp->val;
- need_update = 1;
- }
- }
- return(need_update);
-}
-
-#ifdef OLD_ENVIRON
-# ifdef ENV_HACK
-/*
- * Earlier version of telnet/telnetd from the BSD code had
- * the definitions of VALUE and VAR reversed. To ensure
- * maximum interoperability, we assume that the server is
- * an older BSD server, until proven otherwise. The newer
- * BSD servers should be able to handle either definition,
- * so it is better to use the wrong values if we don't
- * know what type of server it is.
- */
-int env_auto = 1;
-int old_env_var = OLD_ENV_VAR;
-int old_env_value = OLD_ENV_VALUE;
-# else
-# define old_env_var OLD_ENV_VAR
-# define old_env_value OLD_ENV_VALUE
-# endif
-#endif
-
- void
-env_opt(buf, len)
- register unsigned char *buf;
- register int len;
-{
- register unsigned char *ep = 0, *epc = 0;
- register int i;
-
- switch(buf[0]&0xff) {
- case TELQUAL_SEND:
- env_opt_start();
- if (len == 1) {
- env_opt_add(NULL);
- } else for (i = 1; i < len; i++) {
- switch (buf[i]&0xff) {
-#ifdef OLD_ENVIRON
- case OLD_ENV_VAR:
-# ifdef ENV_HACK
- if (telopt_environ == TELOPT_OLD_ENVIRON
- && env_auto) {
- /* Server has the same definitions */
- old_env_var = OLD_ENV_VAR;
- old_env_value = OLD_ENV_VALUE;
- }
- /* FALL THROUGH */
-# endif
- case OLD_ENV_VALUE:
- /*
- * Although OLD_ENV_VALUE is not legal, we will
- * still recognize it, just in case it is an
- * old server that has VAR & VALUE mixed up...
- */
- /* FALL THROUGH */
-#else
- case NEW_ENV_VAR:
-#endif
- case ENV_USERVAR:
- if (ep) {
- *epc = 0;
- env_opt_add(ep);
- }
- ep = epc = &buf[i+1];
- break;
- case ENV_ESC:
- i++;
- /*FALL THROUGH*/
- default:
- if (epc)
- *epc++ = buf[i];
- break;
- }
- }
- if (ep) {
- *epc = 0;
- env_opt_add(ep);
- }
- env_opt_end(1);
- break;
-
- case TELQUAL_IS:
- case TELQUAL_INFO:
- /* Ignore for now. We shouldn't get it anyway. */
- break;
-
- default:
- break;
- }
-}
-
-#define OPT_REPLY_SIZE 256
-unsigned char *opt_reply;
-unsigned char *opt_replyp;
-unsigned char *opt_replyend;
-
- void
-env_opt_start()
-{
- if (opt_reply)
- opt_reply = (unsigned char *)realloc(opt_reply, OPT_REPLY_SIZE);
- else
- opt_reply = (unsigned char *)malloc(OPT_REPLY_SIZE);
- if (opt_reply == NULL) {
-/*@*/ printf("env_opt_start: malloc()/realloc() failed!!!\n");
- opt_reply = opt_replyp = opt_replyend = NULL;
- return;
- }
- opt_replyp = opt_reply;
- opt_replyend = opt_reply + OPT_REPLY_SIZE;
- *opt_replyp++ = IAC;
- *opt_replyp++ = SB;
- *opt_replyp++ = telopt_environ;
- *opt_replyp++ = TELQUAL_IS;
-}
-
- void
-env_opt_start_info()
-{
- env_opt_start();
- if (opt_replyp)
- opt_replyp[-1] = TELQUAL_INFO;
-}
-
- void
-env_opt_add(ep)
- register unsigned char *ep;
-{
- register unsigned char *vp, c;
-
- if (opt_reply == NULL) /*XXX*/
- return; /*XXX*/
-
- if (ep == NULL || *ep == '\0') {
- /* Send user defined variables first. */
- env_default(1, 0);
- while ((ep = env_default(0, 0)))
- env_opt_add(ep);
-
- /* Now add the list of well know variables. */
- env_default(1, 1);
- while ((ep = env_default(0, 1)))
- env_opt_add(ep);
- return;
- }
- vp = env_getvalue(ep);
- if (opt_replyp + (vp ? strlen((char *)vp) : 0) +
- strlen((char *)ep) + 6 > opt_replyend)
- {
- register int len;
- opt_replyend += OPT_REPLY_SIZE;
- len = opt_replyend - opt_reply;
- opt_reply = (unsigned char *)realloc(opt_reply, len);
- if (opt_reply == NULL) {
-/*@*/ printf("env_opt_add: realloc() failed!!!\n");
- opt_reply = opt_replyp = opt_replyend = NULL;
- return;
- }
- opt_replyp = opt_reply + len - (opt_replyend - opt_replyp);
- opt_replyend = opt_reply + len;
- }
- if (opt_welldefined(ep))
-#ifdef OLD_ENVIRON
- if (telopt_environ == TELOPT_OLD_ENVIRON)
- *opt_replyp++ = old_env_var;
- else
-#endif
- *opt_replyp++ = NEW_ENV_VAR;
- else
- *opt_replyp++ = ENV_USERVAR;
- for (;;) {
- while ((c = *ep++)) {
- switch(c&0xff) {
- case IAC:
- *opt_replyp++ = IAC;
- break;
- case NEW_ENV_VAR:
- case NEW_ENV_VALUE:
- case ENV_ESC:
- case ENV_USERVAR:
- *opt_replyp++ = ENV_ESC;
- break;
- }
- *opt_replyp++ = c;
- }
- if ((ep = vp)) {
-#ifdef OLD_ENVIRON
- if (telopt_environ == TELOPT_OLD_ENVIRON)
- *opt_replyp++ = old_env_value;
- else
-#endif
- *opt_replyp++ = NEW_ENV_VALUE;
- vp = NULL;
- } else
- break;
- }
-}
-
- int
-opt_welldefined(ep)
- char *ep;
-{
- if ((strcmp(ep, "USER") == 0) ||
- (strcmp(ep, "DISPLAY") == 0) ||
- (strcmp(ep, "PRINTER") == 0) ||
- (strcmp(ep, "SYSTEMTYPE") == 0) ||
- (strcmp(ep, "JOB") == 0) ||
- (strcmp(ep, "ACCT") == 0))
- return(1);
- return(0);
-}
- void
-env_opt_end(emptyok)
- register int emptyok;
-{
- register int len;
-
- len = opt_replyp - opt_reply + 2;
- if (emptyok || len > 6) {
- *opt_replyp++ = IAC;
- *opt_replyp++ = SE;
- if (NETROOM() > len) {
- ring_supply_data(&netoring, opt_reply, len);
- printsub('>', &opt_reply[2], len - 2);
- }
-/*@*/ else printf("slc_end_reply: not enough room\n");
- }
- if (opt_reply) {
- free(opt_reply);
- opt_reply = opt_replyp = opt_replyend = NULL;
- }
-}
-
-
-
- int
-telrcv()
-{
- register int c;
- register int scc;
- register unsigned char *sbp;
- int count;
- int returnValue = 0;
-
- scc = 0;
- count = 0;
- while (TTYROOM() > 2) {
- if (scc == 0) {
- if (count) {
- ring_consumed(&netiring, count);
- returnValue = 1;
- count = 0;
- }
- sbp = netiring.consume;
- scc = ring_full_consecutive(&netiring);
- if (scc == 0) {
- /* No more data coming in */
- break;
- }
- }
-
- c = *sbp++ & 0xff, scc--; count++;
-#ifdef ENCRYPTION
- if (decrypt_input)
- c = (*decrypt_input)(c);
-#endif /* ENCRYPTION */
-
- switch (telrcv_state) {
-
- case TS_CR:
- telrcv_state = TS_DATA;
- if (c == '\0') {
- break; /* Ignore \0 after CR */
- }
- else if ((c == '\n') && my_want_state_is_dont(TELOPT_ECHO) && !crmod) {
- TTYADD(c);
- break;
- }
- /* Else, fall through */
-
- case TS_DATA:
- if (c == IAC) {
- telrcv_state = TS_IAC;
- break;
- }
-# if defined(TN3270)
- if (In3270) {
- *Ifrontp++ = c;
- while (scc > 0) {
- c = *sbp++ & 0377, scc--; count++;
-#ifdef ENCRYPTION
- if (decrypt_input)
- c = (*decrypt_input)(c);
-#endif /* ENCRYPTION */
- if (c == IAC) {
- telrcv_state = TS_IAC;
- break;
- }
- *Ifrontp++ = c;
- }
- } else
-# endif /* defined(TN3270) */
- /*
- * The 'crmod' hack (see following) is needed
- * since we can't * set CRMOD on output only.
- * Machines like MULTICS like to send \r without
- * \n; since we must turn off CRMOD to get proper
- * input, the mapping is done here (sigh).
- */
- if ((c == '\r') && my_want_state_is_dont(TELOPT_BINARY)) {
- if (scc > 0) {
- c = *sbp&0xff;
-#ifdef ENCRYPTION
- if (decrypt_input)
- c = (*decrypt_input)(c);
-#endif /* ENCRYPTION */
- if (c == 0) {
- sbp++, scc--; count++;
- /* a "true" CR */
- TTYADD('\r');
- } else if (my_want_state_is_dont(TELOPT_ECHO) &&
- (c == '\n')) {
- sbp++, scc--; count++;
- TTYADD('\n');
- } else {
-#ifdef ENCRYPTION
- if (decrypt_input)
- (*decrypt_input)(-1);
-#endif /* ENCRYPTION */
-
- TTYADD('\r');
- if (crmod) {
- TTYADD('\n');
- }
- }
- } else {
- telrcv_state = TS_CR;
- TTYADD('\r');
- if (crmod) {
- TTYADD('\n');
- }
- }
- } else {
- TTYADD(c);
- }
- continue;
-
- case TS_IAC:
-process_iac:
- switch (c) {
-
- case WILL:
- telrcv_state = TS_WILL;
- continue;
-
- case WONT:
- telrcv_state = TS_WONT;
- continue;
-
- case DO:
- telrcv_state = TS_DO;
- continue;
-
- case DONT:
- telrcv_state = TS_DONT;
- continue;
-
- case DM:
- /*
- * We may have missed an urgent notification,
- * so make sure we flush whatever is in the
- * buffer currently.
- */
- printoption("RCVD", IAC, DM);
- SYNCHing = 1;
- (void) ttyflush(1);
- SYNCHing = stilloob();
- settimer(gotDM);
- break;
-
- case SB:
- SB_CLEAR();
- telrcv_state = TS_SB;
- continue;
-
-# if defined(TN3270)
- case EOR:
- if (In3270) {
- if (Ibackp == Ifrontp) {
- Ibackp = Ifrontp = Ibuf;
- ISend = 0; /* should have been! */
- } else {
- Ibackp += DataFromNetwork(Ibackp, Ifrontp-Ibackp, 1);
- ISend = 1;
- }
- }
- printoption("RCVD", IAC, EOR);
- break;
-# endif /* defined(TN3270) */
-
- case IAC:
-# if !defined(TN3270)
- TTYADD(IAC);
-# else /* !defined(TN3270) */
- if (In3270) {
- *Ifrontp++ = IAC;
- } else {
- TTYADD(IAC);
- }
-# endif /* !defined(TN3270) */
- break;
-
- case NOP:
- case GA:
- default:
- printoption("RCVD", IAC, c);
- break;
- }
- telrcv_state = TS_DATA;
- continue;
-
- case TS_WILL:
- printoption("RCVD", WILL, c);
- willoption(c);
- SetIn3270();
- telrcv_state = TS_DATA;
- continue;
-
- case TS_WONT:
- printoption("RCVD", WONT, c);
- wontoption(c);
- SetIn3270();
- telrcv_state = TS_DATA;
- continue;
-
- case TS_DO:
- printoption("RCVD", DO, c);
- dooption(c);
- SetIn3270();
- if (c == TELOPT_NAWS) {
- sendnaws();
- } else if (c == TELOPT_LFLOW) {
- localflow = 1;
- setcommandmode();
- setconnmode(0);
- }
- telrcv_state = TS_DATA;
- continue;
-
- case TS_DONT:
- printoption("RCVD", DONT, c);
- dontoption(c);
- flushline = 1;
- setconnmode(0); /* set new tty mode (maybe) */
- SetIn3270();
- telrcv_state = TS_DATA;
- continue;
-
- case TS_SB:
- if (c == IAC) {
- telrcv_state = TS_SE;
- } else {
- SB_ACCUM(c);
- }
- continue;
-
- case TS_SE:
- if (c != SE) {
- if (c != IAC) {
- /*
- * This is an error. We only expect to get
- * "IAC IAC" or "IAC SE". Several things may
- * have happend. An IAC was not doubled, the
- * IAC SE was left off, or another option got
- * inserted into the suboption are all possibilities.
- * If we assume that the IAC was not doubled,
- * and really the IAC SE was left off, we could
- * get into an infinate loop here. So, instead,
- * we terminate the suboption, and process the
- * partial suboption if we can.
- */
- SB_ACCUM(IAC);
- SB_ACCUM(c);
- subpointer -= 2;
- SB_TERM();
-
- printoption("In SUBOPTION processing, RCVD", IAC, c);
- suboption(); /* handle sub-option */
- SetIn3270();
- telrcv_state = TS_IAC;
- goto process_iac;
- }
- SB_ACCUM(c);
- telrcv_state = TS_SB;
- } else {
- SB_ACCUM(IAC);
- SB_ACCUM(SE);
- subpointer -= 2;
- SB_TERM();
- suboption(); /* handle sub-option */
- SetIn3270();
- telrcv_state = TS_DATA;
- }
- }
- }
- if (count)
- ring_consumed(&netiring, count);
- return returnValue||count;
-}
-
-static int bol = 1, local = 0;
-
- int
-rlogin_susp()
-{
- if (local) {
- local = 0;
- bol = 1;
- command(0, "z\n", 2);
- return(1);
- }
- return(0);
-}
-
- static int
-telsnd()
-{
- int tcc;
- int count;
- int returnValue = 0;
- unsigned char *tbp;
-
- tcc = 0;
- count = 0;
- while (NETROOM() > 2) {
- register int sc;
- register int c;
-
- if (tcc == 0) {
- if (count) {
- ring_consumed(&ttyiring, count);
- returnValue = 1;
- count = 0;
- }
- tbp = ttyiring.consume;
- tcc = ring_full_consecutive(&ttyiring);
- if (tcc == 0) {
- break;
- }
- }
- c = *tbp++ & 0xff, sc = strip(c), tcc--; count++;
- if (rlogin != _POSIX_VDISABLE) {
- if (bol) {
- bol = 0;
- if (sc == rlogin) {
- local = 1;
- continue;
- }
- } else if (local) {
- local = 0;
- if (sc == '.' || c == termEofChar) {
- bol = 1;
- command(0, "close\n", 6);
- continue;
- }
- if (sc == termSuspChar) {
- bol = 1;
- command(0, "z\n", 2);
- continue;
- }
- if (sc == escape) {
- command(0, (char *)tbp, tcc);
- bol = 1;
- count += tcc;
- tcc = 0;
- flushline = 1;
- break;
- }
- if (sc != rlogin) {
- ++tcc;
- --tbp;
- --count;
- c = sc = rlogin;
- }
- }
- if ((sc == '\n') || (sc == '\r'))
- bol = 1;
- } else if (escape != _POSIX_VDISABLE && sc == escape) {
- /*
- * Double escape is a pass through of a single escape character.
- */
- if (tcc && strip(*tbp) == escape) {
- tbp++;
- tcc--;
- count++;
- bol = 0;
- } else {
- command(0, (char *)tbp, tcc);
- bol = 1;
- count += tcc;
- tcc = 0;
- flushline = 1;
- break;
- }
- } else
- bol = 0;
-#ifdef KLUDGELINEMODE
- if (kludgelinemode && (globalmode&MODE_EDIT) && (sc == echoc)) {
- if (tcc > 0 && strip(*tbp) == echoc) {
- tcc--; tbp++; count++;
- } else {
- dontlecho = !dontlecho;
- settimer(echotoggle);
- setconnmode(0);
- flushline = 1;
- break;
- }
- }
-#endif
- if (MODE_LOCAL_CHARS(globalmode)) {
- if (TerminalSpecialChars(sc) == 0) {
- bol = 1;
- break;
- }
- }
- if (my_want_state_is_wont(TELOPT_BINARY)) {
- switch (c) {
- case '\n':
- /*
- * If we are in CRMOD mode (\r ==> \n)
- * on our local machine, then probably
- * a newline (unix) is CRLF (TELNET).
- */
- if (MODE_LOCAL_CHARS(globalmode)) {
- NETADD('\r');
- }
- NETADD('\n');
- bol = flushline = 1;
- break;
- case '\r':
- if (!crlf) {
- NET2ADD('\r', '\0');
- } else {
- NET2ADD('\r', '\n');
- }
- bol = flushline = 1;
- break;
- case IAC:
- NET2ADD(IAC, IAC);
- break;
- default:
- NETADD(c);
- break;
- }
- } else if (c == IAC) {
- NET2ADD(IAC, IAC);
- } else {
- NETADD(c);
- }
- }
- if (count)
- ring_consumed(&ttyiring, count);
- return returnValue||count; /* Non-zero if we did anything */
-}
-
-/*
- * Scheduler()
- *
- * Try to do something.
- *
- * If we do something useful, return 1; else return 0.
- *
- */
-
-
- int
-Scheduler(block)
- int block; /* should we block in the select ? */
-{
- /* One wants to be a bit careful about setting returnValue
- * to one, since a one implies we did some useful work,
- * and therefore probably won't be called to block next
- * time (TN3270 mode only).
- */
- int returnValue;
- int netin, netout, netex, ttyin, ttyout;
-
- /* Decide which rings should be processed */
-
- netout = ring_full_count(&netoring) &&
- (flushline ||
- (my_want_state_is_wont(TELOPT_LINEMODE)
-#ifdef KLUDGELINEMODE
- && (!kludgelinemode || my_want_state_is_do(TELOPT_SGA))
-#endif
- ) ||
- my_want_state_is_will(TELOPT_BINARY));
- ttyout = ring_full_count(&ttyoring);
-
-#if defined(TN3270)
- ttyin = ring_empty_count(&ttyiring) && (clienteof == 0) && (shell_active == 0);
-#else /* defined(TN3270) */
- ttyin = ring_empty_count(&ttyiring) && (clienteof == 0);
-#endif /* defined(TN3270) */
-
-#if defined(TN3270)
- netin = ring_empty_count(&netiring);
-# else /* !defined(TN3270) */
- netin = !ISend && ring_empty_count(&netiring);
-# endif /* !defined(TN3270) */
-
- netex = !SYNCHing;
-
- /* If we have seen a signal recently, reset things */
-# if defined(TN3270) && defined(unix)
- if (HaveInput) {
- HaveInput = 0;
- (void) signal(SIGIO, inputAvailable);
- }
-#endif /* defined(TN3270) && defined(unix) */
-
- /* Call to system code to process rings */
-
- returnValue = process_rings(netin, netout, netex, ttyin, ttyout, !block);
-
- /* Now, look at the input rings, looking for work to do. */
-
- if (ring_full_count(&ttyiring)) {
-# if defined(TN3270)
- if (In3270) {
- int c;
-
- c = DataFromTerminal(ttyiring.consume,
- ring_full_consecutive(&ttyiring));
- if (c) {
- returnValue = 1;
- ring_consumed(&ttyiring, c);
- }
- } else {
-# endif /* defined(TN3270) */
- returnValue |= telsnd();
-# if defined(TN3270)
- }
-# endif /* defined(TN3270) */
- }
-
- if (ring_full_count(&netiring)) {
-# if !defined(TN3270)
- returnValue |= telrcv();
-# else /* !defined(TN3270) */
- returnValue = Push3270();
-# endif /* !defined(TN3270) */
- }
- return returnValue;
-}
-
-/*
- * Select from tty and network...
- */
- void
-telnet(user)
- char *user;
-{
- sys_telnet_init();
-
-#if defined(AUTHENTICATION) || defined(ENCRYPTION)
- {
- static char local_host[256] = { 0 };
-
- if (!local_host[0]) {
- gethostname(local_host, sizeof(local_host));
- local_host[sizeof(local_host)-1] = 0;
- }
- auth_encrypt_init(local_host, hostname, "TELNET", 0);
- auth_encrypt_user(user);
- }
-#endif /* defined(AUTHENTICATION) || defined(ENCRYPTION) */
-# if !defined(TN3270)
- if (telnetport) {
-#if defined(AUTHENTICATION)
- if (autologin)
- send_will(TELOPT_AUTHENTICATION, 1);
-#endif
-#ifdef ENCRYPTION
- send_do(TELOPT_ENCRYPT, 1);
- send_will(TELOPT_ENCRYPT, 1);
-#endif /* ENCRYPTION */
- send_do(TELOPT_SGA, 1);
- send_will(TELOPT_TTYPE, 1);
- send_will(TELOPT_NAWS, 1);
- send_will(TELOPT_TSPEED, 1);
- send_will(TELOPT_LFLOW, 1);
- send_will(TELOPT_LINEMODE, 1);
- send_will(TELOPT_NEW_ENVIRON, 1);
- send_do(TELOPT_STATUS, 1);
- if (env_getvalue((unsigned char *)"DISPLAY"))
- send_will(TELOPT_XDISPLOC, 1);
- if (eight)
- tel_enter_binary(eight);
- }
-# endif /* !defined(TN3270) */
-
-# if !defined(TN3270)
- for (;;) {
- int schedValue;
-
- while ((schedValue = Scheduler(0)) != 0) {
- if (schedValue == -1) {
- setcommandmode();
- return;
- }
- }
-
- if (Scheduler(1) == -1) {
- setcommandmode();
- return;
- }
- }
-# else /* !defined(TN3270) */
- for (;;) {
- int schedValue;
-
- while (!In3270 && !shell_active) {
- if (Scheduler(1) == -1) {
- setcommandmode();
- return;
- }
- }
-
- while ((schedValue = Scheduler(0)) != 0) {
- if (schedValue == -1) {
- setcommandmode();
- return;
- }
- }
- /* If there is data waiting to go out to terminal, don't
- * schedule any more data for the terminal.
- */
- if (ring_full_count(&ttyoring)) {
- schedValue = 1;
- } else {
- if (shell_active) {
- if (shell_continue() == 0) {
- ConnectScreen();
- }
- } else if (In3270) {
- schedValue = DoTerminalOutput();
- }
- }
- if (schedValue && (shell_active == 0)) {
- if (Scheduler(1) == -1) {
- setcommandmode();
- return;
- }
- }
- }
-# endif /* !defined(TN3270) */
-}
-
-#if 0 /* XXX - this not being in is a bug */
-/*
- * nextitem()
- *
- * Return the address of the next "item" in the TELNET data
- * stream. This will be the address of the next character if
- * the current address is a user data character, or it will
- * be the address of the character following the TELNET command
- * if the current address is a TELNET IAC ("I Am a Command")
- * character.
- */
-
- static char *
-nextitem(current)
- char *current;
-{
- if ((*current&0xff) != IAC) {
- return current+1;
- }
- switch (*(current+1)&0xff) {
- case DO:
- case DONT:
- case WILL:
- case WONT:
- return current+3;
- case SB: /* loop forever looking for the SE */
- {
- register char *look = current+2;
-
- for (;;) {
- if ((*look++&0xff) == IAC) {
- if ((*look++&0xff) == SE) {
- return look;
- }
- }
- }
- }
- default:
- return current+2;
- }
-}
-#endif /* 0 */
-
-/*
- * netclear()
- *
- * We are about to do a TELNET SYNCH operation. Clear
- * the path to the network.
- *
- * Things are a bit tricky since we may have sent the first
- * byte or so of a previous TELNET command into the network.
- * So, we have to scan the network buffer from the beginning
- * until we are up to where we want to be.
- *
- * A side effect of what we do, just to keep things
- * simple, is to clear the urgent data pointer. The principal
- * caller should be setting the urgent data pointer AFTER calling
- * us in any case.
- */
-
- static void
-netclear()
-{
-#if 0 /* XXX */
- register char *thisitem, *next;
- char *good;
-#define wewant(p) ((nfrontp > p) && ((*p&0xff) == IAC) && \
- ((*(p+1)&0xff) != EC) && ((*(p+1)&0xff) != EL))
-
- thisitem = netobuf;
-
- while ((next = nextitem(thisitem)) <= netobuf.send) {
- thisitem = next;
- }
-
- /* Now, thisitem is first before/at boundary. */
-
- good = netobuf; /* where the good bytes go */
-
- while (netoring.add > thisitem) {
- if (wewant(thisitem)) {
- int length;
-
- next = thisitem;
- do {
- next = nextitem(next);
- } while (wewant(next) && (nfrontp > next));
- length = next-thisitem;
- memmove(good, thisitem, length);
- good += length;
- thisitem = next;
- } else {
- thisitem = nextitem(thisitem);
- }
- }
-
-#endif /* 0 */
-}
-
-/*
- * These routines add various telnet commands to the data stream.
- */
-
- static void
-doflush()
-{
- NET2ADD(IAC, DO);
- NETADD(TELOPT_TM);
- flushline = 1;
- flushout = 1;
- (void) ttyflush(1); /* Flush/drop output */
- /* do printoption AFTER flush, otherwise the output gets tossed... */
- printoption("SENT", DO, TELOPT_TM);
-}
-
- void
-xmitAO()
-{
- NET2ADD(IAC, AO);
- printoption("SENT", IAC, AO);
- if (autoflush) {
- doflush();
- }
-}
-
-
- void
-xmitEL()
-{
- NET2ADD(IAC, EL);
- printoption("SENT", IAC, EL);
-}
-
- void
-xmitEC()
-{
- NET2ADD(IAC, EC);
- printoption("SENT", IAC, EC);
-}
-
-
- int
-dosynch()
-{
- netclear(); /* clear the path to the network */
- NETADD(IAC);
- setneturg();
- NETADD(DM);
- printoption("SENT", IAC, DM);
- return 1;
-}
-
-int want_status_response = 0;
-
- int
-get_status()
-{
- unsigned char tmp[16];
- register unsigned char *cp;
-
- if (my_want_state_is_dont(TELOPT_STATUS)) {
- printf("Remote side does not support STATUS option\n");
- return 0;
- }
- cp = tmp;
-
- *cp++ = IAC;
- *cp++ = SB;
- *cp++ = TELOPT_STATUS;
- *cp++ = TELQUAL_SEND;
- *cp++ = IAC;
- *cp++ = SE;
- if (NETROOM() >= cp - tmp) {
- ring_supply_data(&netoring, tmp, cp-tmp);
- printsub('>', tmp+2, cp - tmp - 2);
- }
- ++want_status_response;
- return 1;
-}
-
- void
-intp()
-{
- NET2ADD(IAC, IP);
- printoption("SENT", IAC, IP);
- flushline = 1;
- if (autoflush) {
- doflush();
- }
- if (autosynch) {
- dosynch();
- }
-}
-
- void
-sendbrk()
-{
- NET2ADD(IAC, BREAK);
- printoption("SENT", IAC, BREAK);
- flushline = 1;
- if (autoflush) {
- doflush();
- }
- if (autosynch) {
- dosynch();
- }
-}
-
- void
-sendabort()
-{
- NET2ADD(IAC, ABORT);
- printoption("SENT", IAC, ABORT);
- flushline = 1;
- if (autoflush) {
- doflush();
- }
- if (autosynch) {
- dosynch();
- }
-}
-
- void
-sendsusp()
-{
- NET2ADD(IAC, SUSP);
- printoption("SENT", IAC, SUSP);
- flushline = 1;
- if (autoflush) {
- doflush();
- }
- if (autosynch) {
- dosynch();
- }
-}
-
- void
-sendeof()
-{
- NET2ADD(IAC, xEOF);
- printoption("SENT", IAC, xEOF);
-}
-
- void
-sendayt()
-{
- NET2ADD(IAC, AYT);
- printoption("SENT", IAC, AYT);
-}
-
-/*
- * Send a window size update to the remote system.
- */
-
- void
-sendnaws()
-{
- long rows, cols;
- unsigned char tmp[16];
- register unsigned char *cp;
-
- if (my_state_is_wont(TELOPT_NAWS))
- return;
-
-#define PUTSHORT(cp, x) { if ((*cp++ = ((x)>>8)&0xff) == IAC) *cp++ = IAC; \
- if ((*cp++ = ((x))&0xff) == IAC) *cp++ = IAC; }
-
- if (TerminalWindowSize(&rows, &cols) == 0) { /* Failed */
- return;
- }
-
- cp = tmp;
-
- *cp++ = IAC;
- *cp++ = SB;
- *cp++ = TELOPT_NAWS;
- PUTSHORT(cp, cols);
- PUTSHORT(cp, rows);
- *cp++ = IAC;
- *cp++ = SE;
- if (NETROOM() >= cp - tmp) {
- ring_supply_data(&netoring, tmp, cp-tmp);
- printsub('>', tmp+2, cp - tmp - 2);
- }
-}
-
- void
-tel_enter_binary(rw)
- int rw;
-{
- if (rw&1)
- send_do(TELOPT_BINARY, 1);
- if (rw&2)
- send_will(TELOPT_BINARY, 1);
-}
-
- void
-tel_leave_binary(rw)
- int rw;
-{
- if (rw&1)
- send_dont(TELOPT_BINARY, 1);
- if (rw&2)
- send_wont(TELOPT_BINARY, 1);
-}
diff --git a/contrib/telnet/telnet/terminal.c b/contrib/telnet/telnet/terminal.c
deleted file mode 100644
index a2383d9e6696..000000000000
--- a/contrib/telnet/telnet/terminal.c
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * Copyright (c) 1988, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-static const char sccsid[] = "@(#)terminal.c 8.2 (Berkeley) 2/16/95";
-#endif /* not lint */
-
-#include <arpa/telnet.h>
-#include <sys/types.h>
-
-#include "ring.h"
-
-#include "externs.h"
-#include "types.h"
-
-#if defined(ENCRYPTION)
-#include <libtelnet/encrypt.h>
-#endif
-
-Ring ttyoring, ttyiring;
-unsigned char ttyobuf[2*BUFSIZ], ttyibuf[BUFSIZ];
-
-int termdata; /* Debugging flag */
-
-#ifdef USE_TERMIO
-# ifndef VDISCARD
-cc_t termFlushChar;
-# endif
-# ifndef VLNEXT
-cc_t termLiteralNextChar;
-# endif
-# ifndef VSUSP
-cc_t termSuspChar;
-# endif
-# ifndef VWERASE
-cc_t termWerasChar;
-# endif
-# ifndef VREPRINT
-cc_t termRprntChar;
-# endif
-# ifndef VSTART
-cc_t termStartChar;
-# endif
-# ifndef VSTOP
-cc_t termStopChar;
-# endif
-# ifndef VEOL
-cc_t termForw1Char;
-# endif
-# ifndef VEOL2
-cc_t termForw2Char;
-# endif
-# ifndef VSTATUS
-cc_t termAytChar;
-# endif
-#else
-cc_t termForw2Char;
-cc_t termAytChar;
-#endif
-
-/*
- * initialize the terminal data structures.
- */
-
- void
-init_terminal()
-{
- if (ring_init(&ttyoring, ttyobuf, sizeof ttyobuf) != 1) {
- exit(1);
- }
- if (ring_init(&ttyiring, ttyibuf, sizeof ttyibuf) != 1) {
- exit(1);
- }
- autoflush = TerminalAutoFlush();
-}
-
-
-/*
- * Send as much data as possible to the terminal.
- *
- * Return value:
- * -1: No useful work done, data waiting to go out.
- * 0: No data was waiting, so nothing was done.
- * 1: All waiting data was written out.
- * n: All data - n was written out.
- */
-
-
- int
-ttyflush(drop)
- int drop;
-{
- register int n, n0, n1;
-
- n0 = ring_full_count(&ttyoring);
- if ((n1 = n = ring_full_consecutive(&ttyoring)) > 0) {
- if (drop) {
- TerminalFlushOutput();
- /* we leave 'n' alone! */
- } else {
- n = TerminalWrite(ttyoring.consume, n);
- }
- }
- if (n > 0) {
- if (termdata && n) {
- Dump('>', ttyoring.consume, n);
- }
- /*
- * If we wrote everything, and the full count is
- * larger than what we wrote, then write the
- * rest of the buffer.
- */
- if (n1 == n && n0 > n) {
- n1 = n0 - n;
- if (!drop)
- n1 = TerminalWrite(ttyoring.bottom, n1);
- if (n1 > 0)
- n += n1;
- }
- ring_consumed(&ttyoring, n);
- }
- if (n < 0)
- return -1;
- if (n == n0) {
- if (n0)
- return -1;
- return 0;
- }
- return n0 - n + 1;
-}
-
-
-/*
- * These routines decides on what the mode should be (based on the values
- * of various global variables).
- */
-
-
- int
-getconnmode()
-{
- extern int linemode;
- int mode = 0;
-#ifdef KLUDGELINEMODE
- extern int kludgelinemode;
-#endif
-
- if (In3270)
- return(MODE_FLOW);
-
- if (my_want_state_is_dont(TELOPT_ECHO))
- mode |= MODE_ECHO;
-
- if (localflow)
- mode |= MODE_FLOW;
-
- if (my_want_state_is_will(TELOPT_BINARY))
- mode |= MODE_INBIN;
-
- if (his_want_state_is_will(TELOPT_BINARY))
- mode |= MODE_OUTBIN;
-
-#ifdef KLUDGELINEMODE
- if (kludgelinemode) {
- if (my_want_state_is_dont(TELOPT_SGA)) {
- mode |= (MODE_TRAPSIG|MODE_EDIT);
- if (dontlecho && (clocks.echotoggle > clocks.modenegotiated)) {
- mode &= ~MODE_ECHO;
- }
- }
- return(mode);
- }
-#endif
- if (my_want_state_is_will(TELOPT_LINEMODE))
- mode |= linemode;
- return(mode);
-}
-
- void
-setconnmode(force)
- int force;
-{
-#ifdef ENCRYPTION
- static int enc_passwd = 0;
-#endif /* ENCRYPTION */
- register int newmode;
-
- newmode = getconnmode()|(force?MODE_FORCE:0);
-
- TerminalNewMode(newmode);
-
-#ifdef ENCRYPTION
- if ((newmode & (MODE_ECHO|MODE_EDIT)) == MODE_EDIT) {
- if (my_want_state_is_will(TELOPT_ENCRYPT)
- && (enc_passwd == 0) && !encrypt_output) {
- encrypt_request_start(0, 0);
- enc_passwd = 1;
- }
- } else {
- if (enc_passwd) {
- encrypt_request_end();
- enc_passwd = 0;
- }
- }
-#endif /* ENCRYPTION */
-
-}
-
-
- void
-setcommandmode()
-{
- TerminalNewMode(-1);
-}
diff --git a/contrib/telnet/telnet/tn3270.c b/contrib/telnet/telnet/tn3270.c
deleted file mode 100644
index 5a453d98cc5b..000000000000
--- a/contrib/telnet/telnet/tn3270.c
+++ /dev/null
@@ -1,411 +0,0 @@
-/*
- * 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-static const char sccsid[] = "@(#)tn3270.c 8.2 (Berkeley) 5/30/95";
-#endif /* not lint */
-
-#include <sys/types.h>
-#include <arpa/telnet.h>
-
-#include "general.h"
-
-#include "defines.h"
-#include "ring.h"
-#include "externs.h"
-#include "fdset.h"
-
-#if defined(TN3270)
-
-#include "../ctlr/screen.h"
-#include "../general/globals.h"
-
-#include "../sys_curses/telextrn.h"
-#include "../ctlr/externs.h"
-
-#if defined(unix)
-int
- HaveInput, /* There is input available to scan */
- cursesdata, /* Do we dump curses data? */
- sigiocount; /* Number of times we got a SIGIO */
-
-char tline[200];
-char *transcom = 0; /* transparent mode command (default: none) */
-#endif /* defined(unix) */
-
-char Ibuf[8*BUFSIZ], *Ifrontp, *Ibackp;
-
-static char sb_terminal[] = { IAC, SB,
- TELOPT_TTYPE, TELQUAL_IS,
- 'I', 'B', 'M', '-', '3', '2', '7', '8', '-', '2',
- IAC, SE };
-#define SBTERMMODEL 13
-
-static int
- Sent3270TerminalType; /* Have we said we are a 3270? */
-
-#endif /* defined(TN3270) */
-
-
- void
-init_3270()
-{
-#if defined(TN3270)
-#if defined(unix)
- HaveInput = 0;
- sigiocount = 0;
-#endif /* defined(unix) */
- Sent3270TerminalType = 0;
- Ifrontp = Ibackp = Ibuf;
- init_ctlr(); /* Initialize some things */
- init_keyboard();
- init_screen();
- init_system();
-#endif /* defined(TN3270) */
-}
-
-
-#if defined(TN3270)
-
-/*
- * DataToNetwork - queue up some data to go to network. If "done" is set,
- * then when last byte is queued, we add on an IAC EOR sequence (so,
- * don't call us with "done" until you want that done...)
- *
- * We actually do send all the data to the network buffer, since our
- * only client needs for us to do that.
- */
-
- int
-DataToNetwork(buffer, count, done)
- register char *buffer; /* where the data is */
- register int count; /* how much to send */
- int done; /* is this the last of a logical block */
-{
- register int loop, c;
- int origCount;
-
- origCount = count;
-
- while (count) {
- /* If not enough room for EORs, IACs, etc., wait */
- if (NETROOM() < 6) {
- fd_set o;
-
- FD_ZERO(&o);
- netflush();
- while (NETROOM() < 6) {
- FD_SET(net, &o);
- (void) select(net+1, (fd_set *) 0, &o, (fd_set *) 0,
- (struct timeval *) 0);
- netflush();
- }
- }
- c = ring_empty_count(&netoring);
- if (c > count) {
- c = count;
- }
- loop = c;
- while (loop) {
- if (((unsigned char)*buffer) == IAC) {
- break;
- }
- buffer++;
- loop--;
- }
- if ((c = c-loop)) {
- ring_supply_data(&netoring, buffer-c, c);
- count -= c;
- }
- if (loop) {
- NET2ADD(IAC, IAC);
- count--;
- buffer++;
- }
- }
-
- if (done) {
- NET2ADD(IAC, EOR);
- netflush(); /* try to move along as quickly as ... */
- }
- return(origCount - count);
-}
-
-
-#if defined(unix)
- void
-inputAvailable(signo)
- int signo;
-{
- HaveInput = 1;
- sigiocount++;
-}
-#endif /* defined(unix) */
-
- void
-outputPurge()
-{
- (void) ttyflush(1);
-}
-
-
-/*
- * The following routines are places where the various tn3270
- * routines make calls into telnet.c.
- */
-
-/*
- * DataToTerminal - queue up some data to go to terminal.
- *
- * Note: there are people who call us and depend on our processing
- * *all* the data at one time (thus the select).
- */
-
- int
-DataToTerminal(buffer, count)
- register char *buffer; /* where the data is */
- register int count; /* how much to send */
-{
- register int c;
- int origCount;
-
- origCount = count;
-
- while (count) {
- if (TTYROOM() == 0) {
-#if defined(unix)
- fd_set o;
-
- FD_ZERO(&o);
-#endif /* defined(unix) */
- (void) ttyflush(0);
- while (TTYROOM() == 0) {
-#if defined(unix)
- FD_SET(tout, &o);
- (void) select(tout+1, (fd_set *) 0, &o, (fd_set *) 0,
- (struct timeval *) 0);
-#endif /* defined(unix) */
- (void) ttyflush(0);
- }
- }
- c = TTYROOM();
- if (c > count) {
- c = count;
- }
- ring_supply_data(&ttyoring, buffer, c);
- count -= c;
- buffer += c;
- }
- return(origCount);
-}
-
-
-/*
- * Push3270 - Try to send data along the 3270 output (to screen) direction.
- */
-
- int
-Push3270()
-{
- int save = ring_full_count(&netiring);
-
- if (save) {
- if (Ifrontp+save > Ibuf+sizeof Ibuf) {
- if (Ibackp != Ibuf) {
- memmove(Ibuf, Ibackp, Ifrontp-Ibackp);
- Ifrontp -= (Ibackp-Ibuf);
- Ibackp = Ibuf;
- }
- }
- if (Ifrontp+save < Ibuf+sizeof Ibuf) {
- (void)telrcv();
- }
- }
- return save != ring_full_count(&netiring);
-}
-
-
-/*
- * Finish3270 - get the last dregs of 3270 data out to the terminal
- * before quitting.
- */
-
- void
-Finish3270()
-{
- while (Push3270() || !DoTerminalOutput()) {
-#if defined(unix)
- HaveInput = 0;
-#endif /* defined(unix) */
- ;
- }
-}
-
-
-/* StringToTerminal - output a null terminated string to the terminal */
-
- void
-StringToTerminal(s)
- char *s;
-{
- int count;
-
- count = strlen(s);
- if (count) {
- (void) DataToTerminal(s, count); /* we know it always goes... */
- }
-}
-
-
-#if ((!defined(NOT43)) || defined(PUTCHAR))
-/* _putchar - output a single character to the terminal. This name is so that
- * curses(3x) can call us to send out data.
- */
-
- void
-_putchar(c)
- char c;
-{
-#if defined(sun) /* SunOS 4.0 bug */
- c &= 0x7f;
-#endif /* defined(sun) */
- if (cursesdata) {
- Dump('>', &c, 1);
- }
- if (!TTYROOM()) {
- (void) DataToTerminal(&c, 1);
- } else {
- TTYADD(c);
- }
-}
-#endif /* ((!defined(NOT43)) || defined(PUTCHAR)) */
-
- void
-SetIn3270()
-{
- if (Sent3270TerminalType && my_want_state_is_will(TELOPT_BINARY)
- && my_want_state_is_do(TELOPT_BINARY) && !donebinarytoggle) {
- if (!In3270) {
- In3270 = 1;
- Init3270(); /* Initialize 3270 functions */
- /* initialize terminal key mapping */
- InitTerminal(); /* Start terminal going */
- setconnmode(0);
- }
- } else {
- if (In3270) {
- StopScreen(1);
- In3270 = 0;
- Stop3270(); /* Tell 3270 we aren't here anymore */
- setconnmode(0);
- }
- }
-}
-
-/*
- * tn3270_ttype()
- *
- * Send a response to a terminal type negotiation.
- *
- * Return '0' if no more responses to send; '1' if a response sent.
- */
-
- int
-tn3270_ttype()
-{
- /*
- * Try to send a 3270 type terminal name. Decide which one based
- * on the format of our screen, and (in the future) color
- * capaiblities.
- */
- InitTerminal(); /* Sets MaxNumberColumns, MaxNumberLines */
- if ((MaxNumberLines >= 24) && (MaxNumberColumns >= 80)) {
- Sent3270TerminalType = 1;
- if ((MaxNumberLines >= 27) && (MaxNumberColumns >= 132)) {
- MaxNumberLines = 27;
- MaxNumberColumns = 132;
- sb_terminal[SBTERMMODEL] = '5';
- } else if (MaxNumberLines >= 43) {
- MaxNumberLines = 43;
- MaxNumberColumns = 80;
- sb_terminal[SBTERMMODEL] = '4';
- } else if (MaxNumberLines >= 32) {
- MaxNumberLines = 32;
- MaxNumberColumns = 80;
- sb_terminal[SBTERMMODEL] = '3';
- } else {
- MaxNumberLines = 24;
- MaxNumberColumns = 80;
- sb_terminal[SBTERMMODEL] = '2';
- }
- NumberLines = 24; /* before we start out... */
- NumberColumns = 80;
- ScreenSize = NumberLines*NumberColumns;
- if ((MaxNumberLines*MaxNumberColumns) > MAXSCREENSIZE) {
- ExitString("Programming error: MAXSCREENSIZE too small.\n",
- 1);
- /*NOTREACHED*/
- }
- printsub('>', sb_terminal+2, sizeof sb_terminal-2);
- ring_supply_data(&netoring, sb_terminal, sizeof sb_terminal);
- return 1;
- } else {
- return 0;
- }
-}
-
-#if defined(unix)
- int
-settranscom(argc, argv)
- int argc;
- char *argv[];
-{
- int i;
-
- if (argc == 1 && transcom) {
- transcom = 0;
- }
- if (argc == 1) {
- return 1;
- }
- transcom = tline;
- (void) strcpy(transcom, argv[1]);
- for (i = 2; i < argc; ++i) {
- (void) strcat(transcom, " ");
- (void) strcat(transcom, argv[i]);
- }
- return 1;
-}
-#endif /* defined(unix) */
-
-#endif /* defined(TN3270) */
diff --git a/contrib/telnet/telnet/types.h b/contrib/telnet/telnet/types.h
deleted file mode 100644
index 191d311fd154..000000000000
--- a/contrib/telnet/telnet/types.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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. 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, Berkeley and its contributors.
- * 4. 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.1 (Berkeley) 6/6/93
- */
-
-typedef struct {
- char *modedescriptions;
- char modetype;
-} Modelist;
-
-extern Modelist modelist[];
-
-typedef struct {
- int
- system, /* what the current time is */
- echotoggle, /* last time user entered echo character */
- modenegotiated, /* last time operating mode negotiated */
- didnetreceive, /* last time we read data from network */
- gotDM; /* when did we last see a data mark */
-} Clocks;
-
-extern Clocks clocks;
diff --git a/contrib/telnet/telnet/utilities.c b/contrib/telnet/telnet/utilities.c
deleted file mode 100644
index 0ee882ebd87c..000000000000
--- a/contrib/telnet/telnet/utilities.c
+++ /dev/null
@@ -1,946 +0,0 @@
-/*
- * 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-static const char sccsid[] = "@(#)utilities.c 8.3 (Berkeley) 5/30/95";
-#endif /* not lint */
-
-#define TELOPTS
-#define TELCMDS
-#define SLC_NAMES
-#include <arpa/telnet.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <unistd.h>
-
-#include <ctype.h>
-
-#include "general.h"
-
-#include "fdset.h"
-
-#include "ring.h"
-
-#include "defines.h"
-
-#include "externs.h"
-
-#if defined(AUTHENTICATION)
-#include <libtelnet/auth.h>
-#endif
-#if defined(ENCRYPTION)
-#include <libtelnet/encrypt.h>
-#endif
-
-FILE *NetTrace = 0; /* Not in bss, since needs to stay */
-int prettydump;
-
-/*
- * upcase()
- *
- * Upcase (in place) the argument.
- */
-
- void
-upcase(argument)
- register char *argument;
-{
- register int c;
-
- while ((c = *argument) != 0) {
- if (islower(c)) {
- *argument = toupper(c);
- }
- argument++;
- }
-}
-
-/*
- * SetSockOpt()
- *
- * Compensate for differences in 4.2 and 4.3 systems.
- */
-
- int
-SetSockOpt(fd, level, option, yesno)
- int fd, level, option, yesno;
-{
-#ifndef NOT43
- return setsockopt(fd, level, option,
- (char *)&yesno, sizeof yesno);
-#else /* NOT43 */
- if (yesno == 0) { /* Can't do that in 4.2! */
- fprintf(stderr, "Error: attempt to turn off an option 0x%x.\n",
- option);
- return -1;
- }
- return setsockopt(fd, level, option, 0, 0);
-#endif /* NOT43 */
-}
-
-/*
- * The following are routines used to print out debugging information.
- */
-
-unsigned char NetTraceFile[256] = "(standard output)";
-
- void
-SetNetTrace(file)
- register char *file;
-{
- if (NetTrace && NetTrace != stdout)
- fclose(NetTrace);
- if (file && (strcmp(file, "-") != 0)) {
- NetTrace = fopen(file, "w");
- if (NetTrace) {
- strcpy((char *)NetTraceFile, file);
- return;
- }
- fprintf(stderr, "Cannot open %s.\n", file);
- }
- NetTrace = stdout;
- strcpy((char *)NetTraceFile, "(standard output)");
-}
-
- void
-Dump(direction, buffer, length)
- char direction;
- unsigned char *buffer;
- int length;
-{
-# define BYTES_PER_LINE 32
-# define min(x,y) ((x<y)? x:y)
- unsigned char *pThis;
- int offset;
-
- offset = 0;
-
- while (length) {
- /* print one line */
- fprintf(NetTrace, "%c 0x%x\t", direction, offset);
- pThis = buffer;
- if (prettydump) {
- buffer = buffer + min(length, BYTES_PER_LINE/2);
- while (pThis < buffer) {
- fprintf(NetTrace, "%c%.2x",
- (((*pThis)&0xff) == 0xff) ? '*' : ' ',
- (*pThis)&0xff);
- pThis++;
- }
- length -= BYTES_PER_LINE/2;
- offset += BYTES_PER_LINE/2;
- } else {
- buffer = buffer + min(length, BYTES_PER_LINE);
- while (pThis < buffer) {
- fprintf(NetTrace, "%.2x", (*pThis)&0xff);
- pThis++;
- }
- length -= BYTES_PER_LINE;
- offset += BYTES_PER_LINE;
- }
- if (NetTrace == stdout) {
- fprintf(NetTrace, "\r\n");
- } else {
- fprintf(NetTrace, "\n");
- }
- if (length < 0) {
- fflush(NetTrace);
- return;
- }
- /* find next unique line */
- }
- fflush(NetTrace);
-}
-
-
- void
-printoption(direction, cmd, option)
- char *direction;
- int cmd, option;
-{
- if (!showoptions)
- return;
- if (cmd == IAC) {
- if (TELCMD_OK(option))
- fprintf(NetTrace, "%s IAC %s", direction, TELCMD(option));
- else
- fprintf(NetTrace, "%s IAC %d", direction, option);
- } else {
- register char *fmt;
- fmt = (cmd == WILL) ? "WILL" : (cmd == WONT) ? "WONT" :
- (cmd == DO) ? "DO" : (cmd == DONT) ? "DONT" : 0;
- if (fmt) {
- fprintf(NetTrace, "%s %s ", direction, fmt);
- if (TELOPT_OK(option))
- fprintf(NetTrace, "%s", TELOPT(option));
- else if (option == TELOPT_EXOPL)
- fprintf(NetTrace, "EXOPL");
- else
- fprintf(NetTrace, "%d", option);
- } else
- fprintf(NetTrace, "%s %d %d", direction, cmd, option);
- }
- if (NetTrace == stdout) {
- fprintf(NetTrace, "\r\n");
- fflush(NetTrace);
- } else {
- fprintf(NetTrace, "\n");
- }
- return;
-}
-
- void
-optionstatus()
-{
- register int i;
- extern char will_wont_resp[], do_dont_resp[];
-
- for (i = 0; i < 256; i++) {
- if (do_dont_resp[i]) {
- if (TELOPT_OK(i))
- printf("resp DO_DONT %s: %d\n", TELOPT(i), do_dont_resp[i]);
- else if (TELCMD_OK(i))
- printf("resp DO_DONT %s: %d\n", TELCMD(i), do_dont_resp[i]);
- else
- printf("resp DO_DONT %d: %d\n", i,
- do_dont_resp[i]);
- if (my_want_state_is_do(i)) {
- if (TELOPT_OK(i))
- printf("want DO %s\n", TELOPT(i));
- else if (TELCMD_OK(i))
- printf("want DO %s\n", TELCMD(i));
- else
- printf("want DO %d\n", i);
- } else {
- if (TELOPT_OK(i))
- printf("want DONT %s\n", TELOPT(i));
- else if (TELCMD_OK(i))
- printf("want DONT %s\n", TELCMD(i));
- else
- printf("want DONT %d\n", i);
- }
- } else {
- if (my_state_is_do(i)) {
- if (TELOPT_OK(i))
- printf(" DO %s\n", TELOPT(i));
- else if (TELCMD_OK(i))
- printf(" DO %s\n", TELCMD(i));
- else
- printf(" DO %d\n", i);
- }
- }
- if (will_wont_resp[i]) {
- if (TELOPT_OK(i))
- printf("resp WILL_WONT %s: %d\n", TELOPT(i), will_wont_resp[i]);
- else if (TELCMD_OK(i))
- printf("resp WILL_WONT %s: %d\n", TELCMD(i), will_wont_resp[i]);
- else
- printf("resp WILL_WONT %d: %d\n",
- i, will_wont_resp[i]);
- if (my_want_state_is_will(i)) {
- if (TELOPT_OK(i))
- printf("want WILL %s\n", TELOPT(i));
- else if (TELCMD_OK(i))
- printf("want WILL %s\n", TELCMD(i));
- else
- printf("want WILL %d\n", i);
- } else {
- if (TELOPT_OK(i))
- printf("want WONT %s\n", TELOPT(i));
- else if (TELCMD_OK(i))
- printf("want WONT %s\n", TELCMD(i));
- else
- printf("want WONT %d\n", i);
- }
- } else {
- if (my_state_is_will(i)) {
- if (TELOPT_OK(i))
- printf(" WILL %s\n", TELOPT(i));
- else if (TELCMD_OK(i))
- printf(" WILL %s\n", TELCMD(i));
- else
- printf(" WILL %d\n", i);
- }
- }
- }
-
-}
-
- void
-printsub(direction, pointer, length)
- char direction; /* '<' or '>' */
- unsigned char *pointer; /* where suboption data sits */
- int length; /* length of suboption data */
-{
- register int i;
- char buf[512];
- extern int want_status_response;
-
- if (showoptions || direction == 0 ||
- (want_status_response && (pointer[0] == TELOPT_STATUS))) {
- if (direction) {
- fprintf(NetTrace, "%s IAC SB ",
- (direction == '<')? "RCVD":"SENT");
- if (length >= 3) {
- register int j;
-
- i = pointer[length-2];
- j = pointer[length-1];
-
- if (i != IAC || j != SE) {
- fprintf(NetTrace, "(terminated by ");
- if (TELOPT_OK(i))
- fprintf(NetTrace, "%s ", TELOPT(i));
- else if (TELCMD_OK(i))
- fprintf(NetTrace, "%s ", TELCMD(i));
- else
- fprintf(NetTrace, "%d ", i);
- if (TELOPT_OK(j))
- fprintf(NetTrace, "%s", TELOPT(j));
- else if (TELCMD_OK(j))
- fprintf(NetTrace, "%s", TELCMD(j));
- else
- fprintf(NetTrace, "%d", j);
- fprintf(NetTrace, ", not IAC SE!) ");
- }
- }
- length -= 2;
- }
- if (length < 1) {
- fprintf(NetTrace, "(Empty suboption??\?)");
- if (NetTrace == stdout)
- fflush(NetTrace);
- return;
- }
- switch (pointer[0]) {
- case TELOPT_TTYPE:
- fprintf(NetTrace, "TERMINAL-TYPE ");
- switch (pointer[1]) {
- case TELQUAL_IS:
- fprintf(NetTrace, "IS \"%.*s\"", length-2, (char *)pointer+2);
- break;
- case TELQUAL_SEND:
- fprintf(NetTrace, "SEND");
- break;
- default:
- fprintf(NetTrace,
- "- unknown qualifier %d (0x%x).",
- pointer[1], pointer[1]);
- }
- break;
- case TELOPT_TSPEED:
- fprintf(NetTrace, "TERMINAL-SPEED");
- if (length < 2) {
- fprintf(NetTrace, " (empty suboption??\?)");
- break;
- }
- switch (pointer[1]) {
- case TELQUAL_IS:
- fprintf(NetTrace, " IS ");
- fprintf(NetTrace, "%.*s", length-2, (char *)pointer+2);
- break;
- default:
- if (pointer[1] == 1)
- fprintf(NetTrace, " SEND");
- else
- fprintf(NetTrace, " %d (unknown)", pointer[1]);
- for (i = 2; i < length; i++)
- fprintf(NetTrace, " ?%d?", pointer[i]);
- break;
- }
- break;
-
- case TELOPT_LFLOW:
- fprintf(NetTrace, "TOGGLE-FLOW-CONTROL");
- if (length < 2) {
- fprintf(NetTrace, " (empty suboption??\?)");
- break;
- }
- switch (pointer[1]) {
- case LFLOW_OFF:
- fprintf(NetTrace, " OFF"); break;
- case LFLOW_ON:
- fprintf(NetTrace, " ON"); break;
- case LFLOW_RESTART_ANY:
- fprintf(NetTrace, " RESTART-ANY"); break;
- case LFLOW_RESTART_XON:
- fprintf(NetTrace, " RESTART-XON"); break;
- default:
- fprintf(NetTrace, " %d (unknown)", pointer[1]);
- }
- for (i = 2; i < length; i++)
- fprintf(NetTrace, " ?%d?", pointer[i]);
- break;
-
- case TELOPT_NAWS:
- fprintf(NetTrace, "NAWS");
- if (length < 2) {
- fprintf(NetTrace, " (empty suboption??\?)");
- break;
- }
- if (length == 2) {
- fprintf(NetTrace, " ?%d?", pointer[1]);
- break;
- }
- fprintf(NetTrace, " %d %d (%d)",
- pointer[1], pointer[2],
- (int)((((unsigned int)pointer[1])<<8)|((unsigned int)pointer[2])));
- if (length == 4) {
- fprintf(NetTrace, " ?%d?", pointer[3]);
- break;
- }
- fprintf(NetTrace, " %d %d (%d)",
- pointer[3], pointer[4],
- (int)((((unsigned int)pointer[3])<<8)|((unsigned int)pointer[4])));
- for (i = 5; i < length; i++)
- fprintf(NetTrace, " ?%d?", pointer[i]);
- break;
-
-#if defined(AUTHENTICATION)
- case TELOPT_AUTHENTICATION:
- fprintf(NetTrace, "AUTHENTICATION");
- if (length < 2) {
- fprintf(NetTrace, " (empty suboption??\?)");
- break;
- }
- switch (pointer[1]) {
- case TELQUAL_REPLY:
- case TELQUAL_IS:
- fprintf(NetTrace, " %s ", (pointer[1] == TELQUAL_IS) ?
- "IS" : "REPLY");
- if (AUTHTYPE_NAME_OK(pointer[2]))
- fprintf(NetTrace, "%s ", AUTHTYPE_NAME(pointer[2]));
- else
- fprintf(NetTrace, "%d ", pointer[2]);
- if (length < 3) {
- fprintf(NetTrace, "(partial suboption??\?)");
- break;
- }
- fprintf(NetTrace, "%s|%s",
- ((pointer[3] & AUTH_WHO_MASK) == AUTH_WHO_CLIENT) ?
- "CLIENT" : "SERVER",
- ((pointer[3] & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL) ?
- "MUTUAL" : "ONE-WAY");
-
- auth_printsub(&pointer[1], length - 1, buf, sizeof(buf));
- fprintf(NetTrace, "%s", buf);
- break;
-
- case TELQUAL_SEND:
- i = 2;
- fprintf(NetTrace, " SEND ");
- while (i < length) {
- if (AUTHTYPE_NAME_OK(pointer[i]))
- fprintf(NetTrace, "%s ", AUTHTYPE_NAME(pointer[i]));
- else
- fprintf(NetTrace, "%d ", pointer[i]);
- if (++i >= length) {
- fprintf(NetTrace, "(partial suboption??\?)");
- break;
- }
- fprintf(NetTrace, "%s|%s ",
- ((pointer[i] & AUTH_WHO_MASK) == AUTH_WHO_CLIENT) ?
- "CLIENT" : "SERVER",
- ((pointer[i] & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL) ?
- "MUTUAL" : "ONE-WAY");
- ++i;
- }
- break;
-
- case TELQUAL_NAME:
- i = 2;
- fprintf(NetTrace, " NAME \"");
- while (i < length)
- putc(pointer[i++], NetTrace);
- putc('"', NetTrace);
- break;
-
- default:
- for (i = 2; i < length; i++)
- fprintf(NetTrace, " ?%d?", pointer[i]);
- break;
- }
- break;
-#endif
-
-#ifdef ENCRYPTION
- case TELOPT_ENCRYPT:
- fprintf(NetTrace, "ENCRYPT");
- if (length < 2) {
- fprintf(NetTrace, " (empty suboption??\?)");
- break;
- }
- switch (pointer[1]) {
- case ENCRYPT_START:
- fprintf(NetTrace, " START");
- break;
-
- case ENCRYPT_END:
- fprintf(NetTrace, " END");
- break;
-
- case ENCRYPT_REQSTART:
- fprintf(NetTrace, " REQUEST-START");
- break;
-
- case ENCRYPT_REQEND:
- fprintf(NetTrace, " REQUEST-END");
- break;
-
- case ENCRYPT_IS:
- case ENCRYPT_REPLY:
- fprintf(NetTrace, " %s ", (pointer[1] == ENCRYPT_IS) ?
- "IS" : "REPLY");
- if (length < 3) {
- fprintf(NetTrace, " (partial suboption??\?)");
- break;
- }
- if (ENCTYPE_NAME_OK(pointer[2]))
- fprintf(NetTrace, "%s ", ENCTYPE_NAME(pointer[2]));
- else
- fprintf(NetTrace, " %d (unknown)", pointer[2]);
-
- encrypt_printsub(&pointer[1], length - 1, buf, sizeof(buf));
- fprintf(NetTrace, "%s", buf);
- break;
-
- case ENCRYPT_SUPPORT:
- i = 2;
- fprintf(NetTrace, " SUPPORT ");
- while (i < length) {
- if (ENCTYPE_NAME_OK(pointer[i]))
- fprintf(NetTrace, "%s ", ENCTYPE_NAME(pointer[i]));
- else
- fprintf(NetTrace, "%d ", pointer[i]);
- i++;
- }
- break;
-
- case ENCRYPT_ENC_KEYID:
- fprintf(NetTrace, " ENC_KEYID ");
- goto encommon;
-
- case ENCRYPT_DEC_KEYID:
- fprintf(NetTrace, " DEC_KEYID ");
- goto encommon;
-
- default:
- fprintf(NetTrace, " %d (unknown)", pointer[1]);
- encommon:
- for (i = 2; i < length; i++)
- fprintf(NetTrace, " %d", pointer[i]);
- break;
- }
- break;
-#endif /* ENCRYPTION */
-
- case TELOPT_LINEMODE:
- fprintf(NetTrace, "LINEMODE ");
- if (length < 2) {
- fprintf(NetTrace, " (empty suboption??\?)");
- break;
- }
- switch (pointer[1]) {
- case WILL:
- fprintf(NetTrace, "WILL ");
- goto common;
- case WONT:
- fprintf(NetTrace, "WONT ");
- goto common;
- case DO:
- fprintf(NetTrace, "DO ");
- goto common;
- case DONT:
- fprintf(NetTrace, "DONT ");
- common:
- if (length < 3) {
- fprintf(NetTrace, "(no option??\?)");
- break;
- }
- switch (pointer[2]) {
- case LM_FORWARDMASK:
- fprintf(NetTrace, "Forward Mask");
- for (i = 3; i < length; i++)
- fprintf(NetTrace, " %x", pointer[i]);
- break;
- default:
- fprintf(NetTrace, "%d (unknown)", pointer[2]);
- for (i = 3; i < length; i++)
- fprintf(NetTrace, " %d", pointer[i]);
- break;
- }
- break;
-
- case LM_SLC:
- fprintf(NetTrace, "SLC");
- for (i = 2; i < length - 2; i += 3) {
- if (SLC_NAME_OK(pointer[i+SLC_FUNC]))
- fprintf(NetTrace, " %s", SLC_NAME(pointer[i+SLC_FUNC]));
- else
- fprintf(NetTrace, " %d", pointer[i+SLC_FUNC]);
- switch (pointer[i+SLC_FLAGS]&SLC_LEVELBITS) {
- case SLC_NOSUPPORT:
- fprintf(NetTrace, " NOSUPPORT"); break;
- case SLC_CANTCHANGE:
- fprintf(NetTrace, " CANTCHANGE"); break;
- case SLC_VARIABLE:
- fprintf(NetTrace, " VARIABLE"); break;
- case SLC_DEFAULT:
- fprintf(NetTrace, " DEFAULT"); break;
- }
- fprintf(NetTrace, "%s%s%s",
- pointer[i+SLC_FLAGS]&SLC_ACK ? "|ACK" : "",
- pointer[i+SLC_FLAGS]&SLC_FLUSHIN ? "|FLUSHIN" : "",
- pointer[i+SLC_FLAGS]&SLC_FLUSHOUT ? "|FLUSHOUT" : "");
- if (pointer[i+SLC_FLAGS]& ~(SLC_ACK|SLC_FLUSHIN|
- SLC_FLUSHOUT| SLC_LEVELBITS))
- fprintf(NetTrace, "(0x%x)", pointer[i+SLC_FLAGS]);
- fprintf(NetTrace, " %d;", pointer[i+SLC_VALUE]);
- if ((pointer[i+SLC_VALUE] == IAC) &&
- (pointer[i+SLC_VALUE+1] == IAC))
- i++;
- }
- for (; i < length; i++)
- fprintf(NetTrace, " ?%d?", pointer[i]);
- break;
-
- case LM_MODE:
- fprintf(NetTrace, "MODE ");
- if (length < 3) {
- fprintf(NetTrace, "(no mode??\?)");
- break;
- }
- {
- char tbuf[64];
- sprintf(tbuf, "%s%s%s%s%s",
- pointer[2]&MODE_EDIT ? "|EDIT" : "",
- pointer[2]&MODE_TRAPSIG ? "|TRAPSIG" : "",
- pointer[2]&MODE_SOFT_TAB ? "|SOFT_TAB" : "",
- pointer[2]&MODE_LIT_ECHO ? "|LIT_ECHO" : "",
- pointer[2]&MODE_ACK ? "|ACK" : "");
- fprintf(NetTrace, "%s", tbuf[1] ? &tbuf[1] : "0");
- }
- if (pointer[2]&~(MODE_MASK))
- fprintf(NetTrace, " (0x%x)", pointer[2]);
- for (i = 3; i < length; i++)
- fprintf(NetTrace, " ?0x%x?", pointer[i]);
- break;
- default:
- fprintf(NetTrace, "%d (unknown)", pointer[1]);
- for (i = 2; i < length; i++)
- fprintf(NetTrace, " %d", pointer[i]);
- }
- break;
-
- case TELOPT_STATUS: {
- register char *cp;
- register int j, k;
-
- fprintf(NetTrace, "STATUS");
-
- switch (pointer[1]) {
- default:
- if (pointer[1] == TELQUAL_SEND)
- fprintf(NetTrace, " SEND");
- else
- fprintf(NetTrace, " %d (unknown)", pointer[1]);
- for (i = 2; i < length; i++)
- fprintf(NetTrace, " ?%d?", pointer[i]);
- break;
- case TELQUAL_IS:
- if (--want_status_response < 0)
- want_status_response = 0;
- if (NetTrace == stdout)
- fprintf(NetTrace, " IS\r\n");
- else
- fprintf(NetTrace, " IS\n");
-
- for (i = 2; i < length; i++) {
- switch(pointer[i]) {
- case DO: cp = "DO"; goto common2;
- case DONT: cp = "DONT"; goto common2;
- case WILL: cp = "WILL"; goto common2;
- case WONT: cp = "WONT"; goto common2;
- common2:
- i++;
- if (TELOPT_OK((int)pointer[i]))
- fprintf(NetTrace, " %s %s", cp, TELOPT(pointer[i]));
- else
- fprintf(NetTrace, " %s %d", cp, pointer[i]);
-
- if (NetTrace == stdout)
- fprintf(NetTrace, "\r\n");
- else
- fprintf(NetTrace, "\n");
- break;
-
- case SB:
- fprintf(NetTrace, " SB ");
- i++;
- j = k = i;
- while (j < length) {
- if (pointer[j] == SE) {
- if (j+1 == length)
- break;
- if (pointer[j+1] == SE)
- j++;
- else
- break;
- }
- pointer[k++] = pointer[j++];
- }
- printsub(0, &pointer[i], k - i);
- if (i < length) {
- fprintf(NetTrace, " SE");
- i = j;
- } else
- i = j - 1;
-
- if (NetTrace == stdout)
- fprintf(NetTrace, "\r\n");
- else
- fprintf(NetTrace, "\n");
-
- break;
-
- default:
- fprintf(NetTrace, " %d", pointer[i]);
- break;
- }
- }
- break;
- }
- break;
- }
-
- case TELOPT_XDISPLOC:
- fprintf(NetTrace, "X-DISPLAY-LOCATION ");
- switch (pointer[1]) {
- case TELQUAL_IS:
- fprintf(NetTrace, "IS \"%.*s\"", length-2, (char *)pointer+2);
- break;
- case TELQUAL_SEND:
- fprintf(NetTrace, "SEND");
- break;
- default:
- fprintf(NetTrace, "- unknown qualifier %d (0x%x).",
- pointer[1], pointer[1]);
- }
- break;
-
- case TELOPT_NEW_ENVIRON:
- fprintf(NetTrace, "NEW-ENVIRON ");
-#ifdef OLD_ENVIRON
- goto env_common1;
- case TELOPT_OLD_ENVIRON:
- fprintf(NetTrace, "OLD-ENVIRON");
- env_common1:
-#endif
- switch (pointer[1]) {
- case TELQUAL_IS:
- fprintf(NetTrace, "IS ");
- goto env_common;
- case TELQUAL_SEND:
- fprintf(NetTrace, "SEND ");
- goto env_common;
- case TELQUAL_INFO:
- fprintf(NetTrace, "INFO ");
- env_common:
- {
- register int noquote = 2;
-#if defined(ENV_HACK) && defined(OLD_ENVIRON)
- extern int old_env_var, old_env_value;
-#endif
- for (i = 2; i < length; i++ ) {
- switch (pointer[i]) {
- case NEW_ENV_VALUE:
-#ifdef OLD_ENVIRON
- /* case NEW_ENV_OVAR: */
- if (pointer[0] == TELOPT_OLD_ENVIRON) {
-# ifdef ENV_HACK
- if (old_env_var == OLD_ENV_VALUE)
- fprintf(NetTrace, "\" (VALUE) " + noquote);
- else
-# endif
- fprintf(NetTrace, "\" VAR " + noquote);
- } else
-#endif /* OLD_ENVIRON */
- fprintf(NetTrace, "\" VALUE " + noquote);
- noquote = 2;
- break;
-
- case NEW_ENV_VAR:
-#ifdef OLD_ENVIRON
- /* case OLD_ENV_VALUE: */
- if (pointer[0] == TELOPT_OLD_ENVIRON) {
-# ifdef ENV_HACK
- if (old_env_value == OLD_ENV_VAR)
- fprintf(NetTrace, "\" (VAR) " + noquote);
- else
-# endif
- fprintf(NetTrace, "\" VALUE " + noquote);
- } else
-#endif /* OLD_ENVIRON */
- fprintf(NetTrace, "\" VAR " + noquote);
- noquote = 2;
- break;
-
- case ENV_ESC:
- fprintf(NetTrace, "\" ESC " + noquote);
- noquote = 2;
- break;
-
- case ENV_USERVAR:
- fprintf(NetTrace, "\" USERVAR " + noquote);
- noquote = 2;
- break;
-
- default:
- if (isprint(pointer[i]) && pointer[i] != '"') {
- if (noquote) {
- putc('"', NetTrace);
- noquote = 0;
- }
- putc(pointer[i], NetTrace);
- } else {
- fprintf(NetTrace, "\" %03o " + noquote,
- pointer[i]);
- noquote = 2;
- }
- break;
- }
- }
- if (!noquote)
- putc('"', NetTrace);
- break;
- }
- }
- break;
-
- default:
- if (TELOPT_OK(pointer[0]))
- fprintf(NetTrace, "%s (unknown)", TELOPT(pointer[0]));
- else
- fprintf(NetTrace, "%d (unknown)", pointer[0]);
- for (i = 1; i < length; i++)
- fprintf(NetTrace, " %d", pointer[i]);
- break;
- }
- if (direction) {
- if (NetTrace == stdout)
- fprintf(NetTrace, "\r\n");
- else
- fprintf(NetTrace, "\n");
- }
- if (NetTrace == stdout)
- fflush(NetTrace);
- }
-}
-
-/* EmptyTerminal - called to make sure that the terminal buffer is empty.
- * Note that we consider the buffer to run all the
- * way to the kernel (thus the select).
- */
-
- void
-EmptyTerminal()
-{
-#if defined(unix)
- fd_set o;
-
- FD_ZERO(&o);
-#endif /* defined(unix) */
-
- if (TTYBYTES() == 0) {
-#if defined(unix)
- FD_SET(tout, &o);
- (void) select(tout+1, (fd_set *) 0, &o, (fd_set *) 0,
- (struct timeval *) 0); /* wait for TTLOWAT */
-#endif /* defined(unix) */
- } else {
- while (TTYBYTES()) {
- (void) ttyflush(0);
-#if defined(unix)
- FD_SET(tout, &o);
- (void) select(tout+1, (fd_set *) 0, &o, (fd_set *) 0,
- (struct timeval *) 0); /* wait for TTLOWAT */
-#endif /* defined(unix) */
- }
- }
-}
-
- void
-SetForExit()
-{
- setconnmode(0);
-#if defined(TN3270)
- if (In3270) {
- Finish3270();
- }
-#else /* defined(TN3270) */
- do {
- (void)telrcv(); /* Process any incoming data */
- EmptyTerminal();
- } while (ring_full_count(&netiring)); /* While there is any */
-#endif /* defined(TN3270) */
- setcommandmode();
- fflush(stdout);
- fflush(stderr);
-#if defined(TN3270)
- if (In3270) {
- StopScreen(1);
- }
-#endif /* defined(TN3270) */
- setconnmode(0);
- EmptyTerminal(); /* Flush the path to the tty */
- setcommandmode();
-}
-
- void
-Exit(returnCode)
- int returnCode;
-{
- SetForExit();
- exit(returnCode);
-}
-
- void
-ExitString(string, returnCode)
- char *string;
- int returnCode;
-{
- SetForExit();
- fwrite(string, 1, strlen(string), stderr);
- exit(returnCode);
-}
diff --git a/contrib/telnet/telnetd/authenc.c b/contrib/telnet/telnetd/authenc.c
deleted file mode 100644
index 39a38d4df92b..000000000000
--- a/contrib/telnet/telnetd/authenc.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/*-
- * Copyright (c) 1991, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-#if 0
-static const char sccsid[] = "@(#)authenc.c 8.2 (Berkeley) 5/30/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#if defined(AUTHENTICATION) || defined(ENCRYPTION)
-#include "telnetd.h"
-#include <libtelnet/misc.h>
-
- int
-net_write(str, len)
- unsigned char *str;
- int len;
-{
- if (nfrontp + len < netobuf + BUFSIZ) {
- memmove((void *)nfrontp, (void *)str, len);
- nfrontp += len;
- return(len);
- }
- return(0);
-}
-
- void
-net_encrypt()
-{
-#ifdef ENCRYPTION
- char *s = (nclearto > nbackp) ? nclearto : nbackp;
- if (s < nfrontp && encrypt_output) {
- (*encrypt_output)((unsigned char *)s, nfrontp - s);
- }
- nclearto = nfrontp;
-#endif /* ENCRYPTION */
-}
-
- int
-telnet_spin()
-{
- ttloop();
- return(0);
-}
-
- char *
-telnet_getenv(val)
- char *val;
-{
- return(getenv(val));
-}
-
- char *
-telnet_gets(prompt, result, length, echo)
- char *prompt;
- char *result;
- int length;
- int echo;
-{
- return((char *)0);
-}
-#endif /* defined(AUTHENTICATION) || defined(ENCRYPTION) */
diff --git a/contrib/telnet/telnetd/defs.h b/contrib/telnet/telnetd/defs.h
deleted file mode 100644
index a73d4a619978..000000000000
--- a/contrib/telnet/telnetd/defs.h
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
- * Copyright (c) 1989, 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)defs.h 8.1 (Berkeley) 6/4/93
- */
-
-/*
- * Telnet server defines
- */
-#include <sys/types.h>
-#include <sys/param.h>
-
-#ifndef BSD
-# define BSD 43
-#endif
-
-#if defined(CRAY) && !defined(LINEMODE)
-# define SYSV_TERMIO
-# define LINEMODE
-# define KLUDGELINEMODE
-# define DIAGNOSTICS
-# if defined(UNICOS50) && !defined(UNICOS5)
-# define UNICOS5
-# endif
-# if !defined(UNICOS5)
-# define BFTPDAEMON
-# define HAS_IP_TOS
-# endif
-#endif /* CRAY */
-#if defined(UNICOS5) && !defined(NO_SETSID)
-# define NO_SETSID
-#endif
-
-#if defined(PRINTOPTIONS) && defined(DIAGNOSTICS)
-#define TELOPTS
-#define TELCMDS
-#define SLC_NAMES
-#endif
-
-#if defined(SYSV_TERMIO) && !defined(USE_TERMIO)
-# define USE_TERMIO
-#endif
-
-#include <sys/socket.h>
-#ifndef CRAY
-#include <sys/wait.h>
-#endif /* CRAY */
-#include <fcntl.h>
-#include <sys/file.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#ifndef FILIO_H
-#include <sys/ioctl.h>
-#else
-#include <sys/filio.h>
-#endif
-
-#include <netinet/in.h>
-
-#include <arpa/telnet.h>
-
-#include <stdio.h>
-#ifdef __STDC__
-#include <stdlib.h>
-#endif
-#include <signal.h>
-#include <errno.h>
-#include <netdb.h>
-#include <syslog.h>
-#ifndef LOG_DAEMON
-#define LOG_DAEMON 0
-#endif
-#ifndef LOG_ODELAY
-#define LOG_ODELAY 0
-#endif
-#include <ctype.h>
-#ifndef NO_STRING_H
-#include <string.h>
-#else
-#include <strings.h>
-#endif
-
-#ifndef USE_TERMIO
-#include <sgtty.h>
-#else
-# ifdef SYSV_TERMIO
-# include <termio.h>
-# else
-# include <termios.h>
-# endif
-#endif
-#if !defined(USE_TERMIO) || defined(NO_CC_T)
-typedef unsigned char cc_t;
-#endif
-
-#ifdef __STDC__
-#include <unistd.h>
-#endif
-
-#ifndef _POSIX_VDISABLE
-# ifdef VDISABLE
-# define _POSIX_VDISABLE VDISABLE
-# else
-# define _POSIX_VDISABLE ((unsigned char)'\377')
-# endif
-#endif
-
-
-#ifdef CRAY
-# ifdef CRAY1
-# include <sys/pty.h>
-# ifndef FD_ZERO
-# include <sys/select.h>
-# endif /* FD_ZERO */
-# endif /* CRAY1 */
-
-#include <memory.h>
-#endif /* CRAY */
-
-#ifdef __hpux
-#include <sys/ptyio.h>
-#endif
-
-#if !defined(TIOCSCTTY) && defined(TCSETCTTY)
-# define TIOCSCTTY TCSETCTTY
-#endif
-
-#ifndef FD_SET
-#ifndef HAVE_fd_set
-typedef struct fd_set { int fds_bits[1]; } fd_set;
-#endif
-
-#define FD_SET(n, p) ((p)->fds_bits[0] |= (1<<(n)))
-#define FD_CLR(n, p) ((p)->fds_bits[0] &= ~(1<<(n)))
-#define FD_ISSET(n, p) ((p)->fds_bits[0] & (1<<(n)))
-#define FD_ZERO(p) ((p)->fds_bits[0] = 0)
-#endif /* FD_SET */
-
-/*
- * I/O data buffers defines
- */
-#define NETSLOP 64
-#ifdef CRAY
-#undef BUFSIZ
-#define BUFSIZ 2048
-#endif
-
-#define NIACCUM(c) { *netip++ = c; \
- ncc++; \
- }
-
-/* clock manipulations */
-#define settimer(x) (clocks.x = ++clocks.system)
-#define sequenceIs(x,y) (clocks.x < clocks.y)
-
-/*
- * Linemode support states, in decreasing order of importance
- */
-#define REAL_LINEMODE 0x04
-#define KLUDGE_OK 0x03
-#define NO_AUTOKLUDGE 0x02
-#define KLUDGE_LINEMODE 0x01
-#define NO_LINEMODE 0x00
-
-/*
- * Structures of information for each special character function.
- */
-typedef struct {
- unsigned char flag; /* the flags for this function */
- cc_t val; /* the value of the special character */
-} slcent, *Slcent;
-
-typedef struct {
- slcent defset; /* the default settings */
- slcent current; /* the current settings */
- cc_t *sptr; /* a pointer to the char in */
- /* system data structures */
-} slcfun, *Slcfun;
-
-#ifdef DIAGNOSTICS
-/*
- * Diagnostics capabilities
- */
-#define TD_REPORT 0x01 /* Report operations to client */
-#define TD_EXERCISE 0x02 /* Exercise client's implementation */
-#define TD_NETDATA 0x04 /* Display received data stream */
-#define TD_PTYDATA 0x08 /* Display data passed to pty */
-#define TD_OPTIONS 0x10 /* Report just telnet options */
-#endif /* DIAGNOSTICS */
-
-/*
- * We keep track of each side of the option negotiation.
- */
-
-#define MY_STATE_WILL 0x01
-#define MY_WANT_STATE_WILL 0x02
-#define MY_STATE_DO 0x04
-#define MY_WANT_STATE_DO 0x08
-
-/*
- * Macros to check the current state of things
- */
-
-#define my_state_is_do(opt) (options[opt]&MY_STATE_DO)
-#define my_state_is_will(opt) (options[opt]&MY_STATE_WILL)
-#define my_want_state_is_do(opt) (options[opt]&MY_WANT_STATE_DO)
-#define my_want_state_is_will(opt) (options[opt]&MY_WANT_STATE_WILL)
-
-#define my_state_is_dont(opt) (!my_state_is_do(opt))
-#define my_state_is_wont(opt) (!my_state_is_will(opt))
-#define my_want_state_is_dont(opt) (!my_want_state_is_do(opt))
-#define my_want_state_is_wont(opt) (!my_want_state_is_will(opt))
-
-#define set_my_state_do(opt) (options[opt] |= MY_STATE_DO)
-#define set_my_state_will(opt) (options[opt] |= MY_STATE_WILL)
-#define set_my_want_state_do(opt) (options[opt] |= MY_WANT_STATE_DO)
-#define set_my_want_state_will(opt) (options[opt] |= MY_WANT_STATE_WILL)
-
-#define set_my_state_dont(opt) (options[opt] &= ~MY_STATE_DO)
-#define set_my_state_wont(opt) (options[opt] &= ~MY_STATE_WILL)
-#define set_my_want_state_dont(opt) (options[opt] &= ~MY_WANT_STATE_DO)
-#define set_my_want_state_wont(opt) (options[opt] &= ~MY_WANT_STATE_WILL)
-
-/*
- * Tricky code here. What we want to know is if the MY_STATE_WILL
- * and MY_WANT_STATE_WILL bits have the same value. Since the two
- * bits are adjacent, a little arithmatic will show that by adding
- * in the lower bit, the upper bit will be set if the two bits were
- * different, and clear if they were the same.
- */
-#define my_will_wont_is_changing(opt) \
- ((options[opt]+MY_STATE_WILL) & MY_WANT_STATE_WILL)
-
-#define my_do_dont_is_changing(opt) \
- ((options[opt]+MY_STATE_DO) & MY_WANT_STATE_DO)
-
-/*
- * Make everything symetrical
- */
-
-#define HIS_STATE_WILL MY_STATE_DO
-#define HIS_WANT_STATE_WILL MY_WANT_STATE_DO
-#define HIS_STATE_DO MY_STATE_WILL
-#define HIS_WANT_STATE_DO MY_WANT_STATE_WILL
-
-#define his_state_is_do my_state_is_will
-#define his_state_is_will my_state_is_do
-#define his_want_state_is_do my_want_state_is_will
-#define his_want_state_is_will my_want_state_is_do
-
-#define his_state_is_dont my_state_is_wont
-#define his_state_is_wont my_state_is_dont
-#define his_want_state_is_dont my_want_state_is_wont
-#define his_want_state_is_wont my_want_state_is_dont
-
-#define set_his_state_do set_my_state_will
-#define set_his_state_will set_my_state_do
-#define set_his_want_state_do set_my_want_state_will
-#define set_his_want_state_will set_my_want_state_do
-
-#define set_his_state_dont set_my_state_wont
-#define set_his_state_wont set_my_state_dont
-#define set_his_want_state_dont set_my_want_state_wont
-#define set_his_want_state_wont set_my_want_state_dont
-
-#define his_will_wont_is_changing my_do_dont_is_changing
-#define his_do_dont_is_changing my_will_wont_is_changing
diff --git a/contrib/telnet/telnetd/ext.h b/contrib/telnet/telnetd/ext.h
deleted file mode 100644
index f60139e078ac..000000000000
--- a/contrib/telnet/telnetd/ext.h
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Copyright (c) 1989, 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)ext.h 8.2 (Berkeley) 12/15/93
- */
-
-/*
- * Telnet server variable declarations
- */
-extern char options[256];
-extern char do_dont_resp[256];
-extern char will_wont_resp[256];
-extern int linemode; /* linemode on/off */
-#ifdef LINEMODE
-extern int uselinemode; /* what linemode to use (on/off) */
-extern int editmode; /* edit modes in use */
-extern int useeditmode; /* edit modes to use */
-extern int alwayslinemode; /* command line option */
-extern int lmodetype; /* Client support for linemode */
-#endif /* LINEMODE */
-extern int flowmode; /* current flow control state */
-extern int restartany; /* restart output on any character state */
-#ifdef DIAGNOSTICS
-extern int diagnostic; /* telnet diagnostic capabilities */
-#endif /* DIAGNOSTICS */
-#ifdef BFTPDAEMON
-extern int bftpd; /* behave as bftp daemon */
-#endif /* BFTPDAEMON */
-#if defined(SecurID)
-extern int require_SecurID;
-#endif
-#if defined(AUTHENTICATION)
-extern int auth_level;
-#endif
-
-extern slcfun slctab[NSLC + 1]; /* slc mapping table */
-
-char *terminaltype;
-
-/*
- * I/O data buffers, pointers, and counters.
- */
-extern char ptyobuf[BUFSIZ+NETSLOP], *pfrontp, *pbackp;
-
-extern char netibuf[BUFSIZ], *netip;
-
-extern char netobuf[BUFSIZ+NETSLOP], *nfrontp, *nbackp;
-extern char *neturg; /* one past last bye of urgent data */
-
-extern int pcc, ncc;
-
-#if defined(CRAY2) && defined(UNICOS5)
-extern int unpcc; /* characters left unprocessed by CRAY-2 terminal routine */
-extern char *unptyip; /* pointer to remaining characters in buffer */
-#endif
-
-extern int pty, net;
-extern char *line;
-extern int SYNCHing; /* we are in TELNET SYNCH mode */
-
-#ifndef P
-# ifdef __STDC__
-# define P(x) x
-# else
-# define P(x) ()
-# endif
-#endif
-
-extern void
- _termstat P((void)),
- add_slc P((int, int, int)),
- check_slc P((void)),
- change_slc P((int, int, int)),
- cleanup P((int)),
- clientstat P((int, int, int)),
- copy_termbuf P((char *, int)),
- deferslc P((void)),
- defer_terminit P((void)),
- do_opt_slc P((unsigned char *, int)),
- doeof P((void)),
- dooption P((int)),
- dontoption P((int)),
- edithost P((char *, char *)),
- fatal P((int, char *)),
- fatalperror P((int, char *)),
- get_slc_defaults P((void)),
- init_env P((void)),
- init_termbuf P((void)),
- interrupt P((void)),
- localstat P((void)),
- flowstat P((void)),
- netclear P((void)),
- netflush P((void)),
-#ifdef DIAGNOSTICS
- printoption P((char *, int)),
- printdata P((char *, char *, int)),
- printsub P((int, unsigned char *, int)),
-#endif
- ptyflush P((void)),
- putchr P((int)),
- putf P((char *, char *)),
- recv_ayt P((void)),
- send_do P((int, int)),
- send_dont P((int, int)),
- send_slc P((void)),
- send_status P((void)),
- send_will P((int, int)),
- send_wont P((int, int)),
- sendbrk P((void)),
- sendsusp P((void)),
- set_termbuf P((void)),
- start_login P((char *, int, char *)),
- start_slc P((int)),
-#if defined(AUTHENTICATION)
- start_slave P((char *)),
-#else
- start_slave P((char *, int, char *)),
-#endif
- suboption P((void)),
- telrcv P((void)),
- ttloop P((void)),
- tty_binaryin P((int)),
- tty_binaryout P((int));
-
-extern int
- end_slc P((unsigned char **)),
- getnpty P((void)),
-#ifndef convex
- getpty P((int *)),
-#endif
- login_tty P((int)),
- spcset P((int, cc_t *, cc_t **)),
- stilloob P((int)),
- terminit P((void)),
- termstat P((void)),
- tty_flowmode P((void)),
- tty_restartany P((void)),
- tty_isbinaryin P((void)),
- tty_isbinaryout P((void)),
- tty_iscrnl P((void)),
- tty_isecho P((void)),
- tty_isediting P((void)),
- tty_islitecho P((void)),
- tty_isnewmap P((void)),
- tty_israw P((void)),
- tty_issofttab P((void)),
- tty_istrapsig P((void)),
- tty_linemode P((void));
-
-extern void
- tty_rspeed P((int)),
- tty_setecho P((int)),
- tty_setedit P((int)),
- tty_setlinemode P((int)),
- tty_setlitecho P((int)),
- tty_setsig P((int)),
- tty_setsofttab P((int)),
- tty_tspeed P((int)),
- willoption P((int)),
- wontoption P((int)),
- writenet P((unsigned char *, int));
-
-#ifdef ENCRYPTION
-extern void (*encrypt_output) P((unsigned char *, int));
-extern int (*decrypt_input) P((int));
-extern char *nclearto;
-#endif /* ENCRYPTION */
-
-
-/*
- * The following are some clocks used to decide how to interpret
- * the relationship between various variables.
- */
-
-extern struct {
- int
- system, /* what the current time is */
- echotoggle, /* last time user entered echo character */
- modenegotiated, /* last time operating mode negotiated */
- didnetreceive, /* last time we read data from network */
- ttypesubopt, /* ttype subopt is received */
- tspeedsubopt, /* tspeed subopt is received */
- environsubopt, /* environ subopt is received */
- oenvironsubopt, /* old environ subopt is received */
- xdisplocsubopt, /* xdisploc subopt is received */
- baseline, /* time started to do timed action */
- gotDM; /* when did we last see a data mark */
-} clocks;
-
-
-#if defined(CRAY2) && defined(UNICOS5)
-extern int needtermstat;
-#endif
-
-#ifndef DEFAULT_IM
-# ifdef CRAY
-# define DEFAULT_IM "\r\n\r\nCray UNICOS (%h) (%t)\r\n\r\r\n\r"
-# else
-# ifdef sun
-# define DEFAULT_IM "\r\n\r\nSunOS UNIX (%h) (%t)\r\n\r\r\n\r"
-# else
-# ifdef ultrix
-# define DEFAULT_IM "\r\n\r\nULTRIX (%h) (%t)\r\n\r\r\n\r"
-# else
-# ifdef __FreeBSD__
-# define DEFAULT_IM "\r\n\r\nFreeBSD (%h) (%t)\r\n\r\r\n\r"
-# else
-# define DEFAULT_IM "\r\n\r\n4.4 BSD UNIX (%h) (%t)\r\n\r\r\n\r"
-# endif
-# endif
-# endif
-# endif
-#endif
diff --git a/contrib/telnet/telnetd/global.c b/contrib/telnet/telnetd/global.c
deleted file mode 100644
index 0cf95dbd463e..000000000000
--- a/contrib/telnet/telnetd/global.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 1989, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-#if 0
-static const char sccsid[] = "@(#)global.c 8.1 (Berkeley) 6/4/93";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-/*
- * Allocate global variables. We do this
- * by including the header file that defines
- * them all as externs, but first we define
- * the keyword "extern" to be nothing, so that
- * we will actually allocate the space.
- */
-
-#include "defs.h"
-#define extern
-#include "ext.h"
diff --git a/contrib/telnet/telnetd/pathnames.h b/contrib/telnet/telnetd/pathnames.h
deleted file mode 100644
index c8b0806e7814..000000000000
--- a/contrib/telnet/telnetd/pathnames.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 1989, 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)pathnames.h 8.1 (Berkeley) 6/4/93
- */
-
-#if BSD > 43
-
-# include <paths.h>
-
-# ifndef _PATH_LOGIN
-# define _PATH_LOGIN "/usr/bin/login"
-# endif
-
-#else
-
-# define _PATH_TTY "/dev/tty"
-# ifndef _PATH_LOGIN
-# define _PATH_LOGIN "/bin/login"
-# endif
-
-#endif
-
-#ifdef BFTPDAEMON
-#define BFTPPATH "/usr/ucb/bftp"
-#endif /* BFTPDAEMON */
diff --git a/contrib/telnet/telnetd/slc.c b/contrib/telnet/telnetd/slc.c
deleted file mode 100644
index 65dc6891a940..000000000000
--- a/contrib/telnet/telnetd/slc.c
+++ /dev/null
@@ -1,495 +0,0 @@
-/*
- * Copyright (c) 1989, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-#if 0
-static const char sccsid[] = "@(#)slc.c 8.2 (Berkeley) 5/30/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include "telnetd.h"
-
-#ifdef LINEMODE
-/*
- * local variables
- */
-static unsigned char *def_slcbuf = (unsigned char *)0;
-static int def_slclen = 0;
-static int slcchange; /* change to slc is requested */
-static unsigned char *slcptr; /* pointer into slc buffer */
-static unsigned char slcbuf[NSLC*6]; /* buffer for slc negotiation */
-
-/*
- * send_slc
- *
- * Write out the current special characters to the client.
- */
- void
-send_slc()
-{
- register int i;
-
- /*
- * Send out list of triplets of special characters
- * to client. We only send info on the characters
- * that are currently supported.
- */
- for (i = 1; i <= NSLC; i++) {
- if ((slctab[i].defset.flag & SLC_LEVELBITS) == SLC_NOSUPPORT)
- continue;
- add_slc((unsigned char)i, slctab[i].current.flag,
- slctab[i].current.val);
- }
-
-} /* end of send_slc */
-
-/*
- * default_slc
- *
- * Set pty special characters to all the defaults.
- */
- void
-default_slc()
-{
- register int i;
-
- for (i = 1; i <= NSLC; i++) {
- slctab[i].current.val = slctab[i].defset.val;
- if (slctab[i].current.val == (cc_t)(_POSIX_VDISABLE))
- slctab[i].current.flag = SLC_NOSUPPORT;
- else
- slctab[i].current.flag = slctab[i].defset.flag;
- if (slctab[i].sptr) {
- *(slctab[i].sptr) = slctab[i].defset.val;
- }
- }
- slcchange = 1;
-
-} /* end of default_slc */
-#endif /* LINEMODE */
-
-/*
- * get_slc_defaults
- *
- * Initialize the slc mapping table.
- */
- void
-get_slc_defaults()
-{
- register int i;
-
- init_termbuf();
-
- for (i = 1; i <= NSLC; i++) {
- slctab[i].defset.flag =
- spcset(i, &slctab[i].defset.val, &slctab[i].sptr);
- slctab[i].current.flag = SLC_NOSUPPORT;
- slctab[i].current.val = 0;
- }
-
-} /* end of get_slc_defaults */
-
-#ifdef LINEMODE
-/*
- * add_slc
- *
- * Add an slc triplet to the slc buffer.
- */
- void
-add_slc(func, flag, val)
- register char func, flag;
- register cc_t val;
-{
-
- if ((*slcptr++ = (unsigned char)func) == 0xff)
- *slcptr++ = 0xff;
-
- if ((*slcptr++ = (unsigned char)flag) == 0xff)
- *slcptr++ = 0xff;
-
- if ((*slcptr++ = (unsigned char)val) == 0xff)
- *slcptr++ = 0xff;
-
-} /* end of add_slc */
-
-/*
- * start_slc
- *
- * Get ready to process incoming slc's and respond to them.
- *
- * The parameter getit is non-zero if it is necessary to grab a copy
- * of the terminal control structures.
- */
- void
-start_slc(getit)
- register int getit;
-{
-
- slcchange = 0;
- if (getit)
- init_termbuf();
- (void) sprintf((char *)slcbuf, "%c%c%c%c",
- IAC, SB, TELOPT_LINEMODE, LM_SLC);
- slcptr = slcbuf + 4;
-
-} /* end of start_slc */
-
-/*
- * end_slc
- *
- * Finish up the slc negotiation. If something to send, then send it.
- */
- int
-end_slc(bufp)
- register unsigned char **bufp;
-{
- register int len;
- void netflush();
-
- /*
- * If a change has occured, store the new terminal control
- * structures back to the terminal driver.
- */
- if (slcchange) {
- set_termbuf();
- }
-
- /*
- * If the pty state has not yet been fully processed and there is a
- * deferred slc request from the client, then do not send any
- * sort of slc negotiation now. We will respond to the client's
- * request very soon.
- */
- if (def_slcbuf && (terminit() == 0)) {
- return(0);
- }
-
- if (slcptr > (slcbuf + 4)) {
- if (bufp) {
- *bufp = &slcbuf[4];
- return(slcptr - slcbuf - 4);
- } else {
- (void) sprintf((char *)slcptr, "%c%c", IAC, SE);
- slcptr += 2;
- len = slcptr - slcbuf;
- writenet(slcbuf, len);
- netflush(); /* force it out immediately */
- DIAG(TD_OPTIONS, printsub('>', slcbuf+2, len-2););
- }
- }
- return (0);
-
-} /* end of end_slc */
-
-/*
- * process_slc
- *
- * Figure out what to do about the client's slc
- */
- void
-process_slc(func, flag, val)
- register unsigned char func, flag;
- register cc_t val;
-{
- register int hislevel, mylevel, ack;
-
- /*
- * Ensure that we know something about this function
- */
- if (func > NSLC) {
- add_slc(func, SLC_NOSUPPORT, 0);
- return;
- }
-
- /*
- * Process the special case requests of 0 SLC_DEFAULT 0
- * and 0 SLC_VARIABLE 0. Be a little forgiving here, don't
- * worry about whether the value is actually 0 or not.
- */
- if (func == 0) {
- if ((flag = flag & SLC_LEVELBITS) == SLC_DEFAULT) {
- default_slc();
- send_slc();
- } else if (flag == SLC_VARIABLE) {
- send_slc();
- }
- return;
- }
-
- /*
- * Appears to be a function that we know something about. So
- * get on with it and see what we know.
- */
-
- hislevel = flag & SLC_LEVELBITS;
- mylevel = slctab[func].current.flag & SLC_LEVELBITS;
- ack = flag & SLC_ACK;
- /*
- * ignore the command if:
- * the function value and level are the same as what we already have;
- * or the level is the same and the ack bit is set
- */
- if (hislevel == mylevel && (val == slctab[func].current.val || ack)) {
- return;
- } else if (ack) {
- /*
- * If we get here, we got an ack, but the levels don't match.
- * This shouldn't happen. If it does, it is probably because
- * we have sent two requests to set a variable without getting
- * a response between them, and this is the first response.
- * So, ignore it, and wait for the next response.
- */
- return;
- } else {
- change_slc(func, flag, val);
- }
-
-} /* end of process_slc */
-
-/*
- * change_slc
- *
- * Process a request to change one of our special characters.
- * Compare client's request with what we are capable of supporting.
- */
- void
-change_slc(func, flag, val)
- register char func, flag;
- register cc_t val;
-{
- register int hislevel, mylevel;
-
- hislevel = flag & SLC_LEVELBITS;
- mylevel = slctab[(int)func].defset.flag & SLC_LEVELBITS;
- /*
- * If client is setting a function to NOSUPPORT
- * or DEFAULT, then we can easily and directly
- * accomodate the request.
- */
- if (hislevel == SLC_NOSUPPORT) {
- slctab[(int)func].current.flag = flag;
- slctab[(int)func].current.val = (cc_t)_POSIX_VDISABLE;
- flag |= SLC_ACK;
- add_slc(func, flag, val);
- return;
- }
- if (hislevel == SLC_DEFAULT) {
- /*
- * Special case here. If client tells us to use
- * the default on a function we don't support, then
- * return NOSUPPORT instead of what we may have as a
- * default level of DEFAULT.
- */
- if (mylevel == SLC_DEFAULT) {
- slctab[(int)func].current.flag = SLC_NOSUPPORT;
- } else {
- slctab[(int)func].current.flag = slctab[(int)func].defset.flag;
- }
- slctab[(int)func].current.val = slctab[(int)func].defset.val;
- add_slc(func, slctab[(int)func].current.flag,
- slctab[(int)func].current.val);
- return;
- }
-
- /*
- * Client wants us to change to a new value or he
- * is telling us that he can't change to our value.
- * Some of the slc's we support and can change,
- * some we do support but can't change,
- * and others we don't support at all.
- * If we can change it then we have a pointer to
- * the place to put the new value, so change it,
- * otherwise, continue the negotiation.
- */
- if (slctab[(int)func].sptr) {
- /*
- * We can change this one.
- */
- slctab[(int)func].current.val = val;
- *(slctab[(int)func].sptr) = val;
- slctab[(int)func].current.flag = flag;
- flag |= SLC_ACK;
- slcchange = 1;
- add_slc(func, flag, val);
- } else {
- /*
- * It is not possible for us to support this
- * request as he asks.
- *
- * If our level is DEFAULT, then just ack whatever was
- * sent.
- *
- * If he can't change and we can't change,
- * then degenerate to NOSUPPORT.
- *
- * Otherwise we send our level back to him, (CANTCHANGE
- * or NOSUPPORT) and if CANTCHANGE, send
- * our value as well.
- */
- if (mylevel == SLC_DEFAULT) {
- slctab[(int)func].current.flag = flag;
- slctab[(int)func].current.val = val;
- flag |= SLC_ACK;
- } else if (hislevel == SLC_CANTCHANGE &&
- mylevel == SLC_CANTCHANGE) {
- flag &= ~SLC_LEVELBITS;
- flag |= SLC_NOSUPPORT;
- slctab[(int)func].current.flag = flag;
- } else {
- flag &= ~SLC_LEVELBITS;
- flag |= mylevel;
- slctab[(int)func].current.flag = flag;
- if (mylevel == SLC_CANTCHANGE) {
- slctab[(int)func].current.val =
- slctab[(int)func].defset.val;
- val = slctab[(int)func].current.val;
- }
- }
- add_slc(func, flag, val);
- }
-
-} /* end of change_slc */
-
-#if defined(USE_TERMIO) && (VEOF == VMIN)
-cc_t oldeofc = '\004';
-#endif
-
-/*
- * check_slc
- *
- * Check the special characters in use and notify the client if any have
- * changed. Only those characters that are capable of being changed are
- * likely to have changed. If a local change occurs, kick the support level
- * and flags up to the defaults.
- */
- void
-check_slc()
-{
- register int i;
-
- for (i = 1; i <= NSLC; i++) {
-#if defined(USE_TERMIO) && (VEOF == VMIN)
- /*
- * In a perfect world this would be a neat little
- * function. But in this world, we should not notify
- * client of changes to the VEOF char when
- * ICANON is off, because it is not representing
- * a special character.
- */
- if (i == SLC_EOF) {
- if (!tty_isediting())
- continue;
- else if (slctab[i].sptr)
- oldeofc = *(slctab[i].sptr);
- }
-#endif /* defined(USE_TERMIO) && defined(SYSV_TERMIO) */
- if (slctab[i].sptr &&
- (*(slctab[i].sptr) != slctab[i].current.val)) {
- slctab[i].current.val = *(slctab[i].sptr);
- if (*(slctab[i].sptr) == (cc_t)_POSIX_VDISABLE)
- slctab[i].current.flag = SLC_NOSUPPORT;
- else
- slctab[i].current.flag = slctab[i].defset.flag;
- add_slc((unsigned char)i, slctab[i].current.flag,
- slctab[i].current.val);
- }
- }
-} /* check_slc */
-
-/*
- * do_opt_slc
- *
- * Process an slc option buffer. Defer processing of incoming slc's
- * until after the terminal state has been processed. Save the first slc
- * request that comes along, but discard all others.
- *
- * ptr points to the beginning of the buffer, len is the length.
- */
- void
-do_opt_slc(ptr, len)
- register unsigned char *ptr;
- register int len;
-{
- register unsigned char func, flag;
- cc_t val;
- register unsigned char *end = ptr + len;
-
- if (terminit()) { /* go ahead */
- while (ptr < end) {
- func = *ptr++;
- if (ptr >= end) break;
- flag = *ptr++;
- if (ptr >= end) break;
- val = (cc_t)*ptr++;
-
- process_slc(func, flag, val);
-
- }
- } else {
- /*
- * save this slc buffer if it is the first, otherwise dump
- * it.
- */
- if (def_slcbuf == (unsigned char *)0) {
- def_slclen = len;
- def_slcbuf = (unsigned char *)malloc((unsigned)len);
- if (def_slcbuf == (unsigned char *)0)
- return; /* too bad */
- memmove(def_slcbuf, ptr, len);
- }
- }
-
-} /* end of do_opt_slc */
-
-/*
- * deferslc
- *
- * Do slc stuff that was deferred.
- */
- void
-deferslc()
-{
- if (def_slcbuf) {
- start_slc(1);
- do_opt_slc(def_slcbuf, def_slclen);
- (void) end_slc(0);
- free(def_slcbuf);
- def_slcbuf = (unsigned char *)0;
- def_slclen = 0;
- }
-
-} /* end of deferslc */
-
-#endif /* LINEMODE */
diff --git a/contrib/telnet/telnetd/state.c b/contrib/telnet/telnetd/state.c
deleted file mode 100644
index 4a066b7f2b22..000000000000
--- a/contrib/telnet/telnetd/state.c
+++ /dev/null
@@ -1,1619 +0,0 @@
-/*
- * Copyright (c) 1989, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-#if 0
-static const char sccsid[] = "@(#)state.c 8.5 (Berkeley) 5/30/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include "telnetd.h"
-#if defined(AUTHENTICATION)
-#include <libtelnet/auth.h>
-#endif
-#if defined(ENCRYPTION)
-#include <libtelnet/encrypt.h>
-#endif
-
-unsigned char doopt[] = { IAC, DO, '%', 'c', 0 };
-unsigned char dont[] = { IAC, DONT, '%', 'c', 0 };
-unsigned char will[] = { IAC, WILL, '%', 'c', 0 };
-unsigned char wont[] = { IAC, WONT, '%', 'c', 0 };
-int not42 = 1;
-
-/*
- * Buffer for sub-options, and macros
- * for suboptions buffer manipulations
- */
-unsigned char subbuffer[512], *subpointer= subbuffer, *subend= subbuffer;
-
-#define SB_CLEAR() subpointer = subbuffer
-#define SB_TERM() { subend = subpointer; SB_CLEAR(); }
-#define SB_ACCUM(c) if (subpointer < (subbuffer+sizeof subbuffer)) { \
- *subpointer++ = (c); \
- }
-#define SB_GET() ((*subpointer++)&0xff)
-#define SB_EOF() (subpointer >= subend)
-#define SB_LEN() (subend - subpointer)
-
-#ifdef ENV_HACK
-unsigned char *subsave;
-#define SB_SAVE() subsave = subpointer;
-#define SB_RESTORE() subpointer = subsave;
-#endif
-
-
-/*
- * State for recv fsm
- */
-#define TS_DATA 0 /* base state */
-#define TS_IAC 1 /* look for double IAC's */
-#define TS_CR 2 /* CR-LF ->'s CR */
-#define TS_SB 3 /* throw away begin's... */
-#define TS_SE 4 /* ...end's (suboption negotiation) */
-#define TS_WILL 5 /* will option negotiation */
-#define TS_WONT 6 /* wont " */
-#define TS_DO 7 /* do " */
-#define TS_DONT 8 /* dont " */
-
- void
-telrcv()
-{
- register int c;
- static int state = TS_DATA;
-#if defined(CRAY2) && defined(UNICOS5)
- char *opfrontp = pfrontp;
-#endif
-
- while (ncc > 0) {
- if ((&ptyobuf[BUFSIZ] - pfrontp) < 2)
- break;
- c = *netip++ & 0377, ncc--;
-#ifdef ENCRYPTION
- if (decrypt_input)
- c = (*decrypt_input)(c);
-#endif /* ENCRYPTION */
- switch (state) {
-
- case TS_CR:
- state = TS_DATA;
- /* Strip off \n or \0 after a \r */
- if ((c == 0) || (c == '\n')) {
- break;
- }
- /* FALL THROUGH */
-
- case TS_DATA:
- if (c == IAC) {
- state = TS_IAC;
- break;
- }
- /*
- * We now map \r\n ==> \r for pragmatic reasons.
- * Many client implementations send \r\n when
- * the user hits the CarriageReturn key.
- *
- * We USED to map \r\n ==> \n, since \r\n says
- * that we want to be in column 1 of the next
- * printable line, and \n is the standard
- * unix way of saying that (\r is only good
- * if CRMOD is set, which it normally is).
- */
- if ((c == '\r') && his_state_is_wont(TELOPT_BINARY)) {
- int nc = *netip;
-#ifdef ENCRYPTION
- if (decrypt_input)
- nc = (*decrypt_input)(nc & 0xff);
-#endif /* ENCRYPTION */
-#ifdef LINEMODE
- /*
- * If we are operating in linemode,
- * convert to local end-of-line.
- */
- if (linemode && (ncc > 0) && (('\n' == nc) ||
- ((0 == nc) && tty_iscrnl())) ) {
- netip++; ncc--;
- c = '\n';
- } else
-#endif
- {
-#ifdef ENCRYPTION
- if (decrypt_input)
- (void)(*decrypt_input)(-1);
-#endif /* ENCRYPTION */
- state = TS_CR;
- }
- }
- *pfrontp++ = c;
- break;
-
- case TS_IAC:
-gotiac: switch (c) {
-
- /*
- * Send the process on the pty side an
- * interrupt. Do this with a NULL or
- * interrupt char; depending on the tty mode.
- */
- case IP:
- DIAG(TD_OPTIONS,
- printoption("td: recv IAC", c));
- interrupt();
- break;
-
- case BREAK:
- DIAG(TD_OPTIONS,
- printoption("td: recv IAC", c));
- sendbrk();
- break;
-
- /*
- * Are You There?
- */
- case AYT:
- DIAG(TD_OPTIONS,
- printoption("td: recv IAC", c));
- recv_ayt();
- break;
-
- /*
- * Abort Output
- */
- case AO:
- {
- DIAG(TD_OPTIONS,
- printoption("td: recv IAC", c));
- ptyflush(); /* half-hearted */
- init_termbuf();
-
- if (slctab[SLC_AO].sptr &&
- *slctab[SLC_AO].sptr != (cc_t)(_POSIX_VDISABLE)) {
- *pfrontp++ =
- (unsigned char)*slctab[SLC_AO].sptr;
- }
-
- netclear(); /* clear buffer back */
- *nfrontp++ = IAC;
- *nfrontp++ = DM;
- neturg = nfrontp-1; /* off by one XXX */
- DIAG(TD_OPTIONS,
- printoption("td: send IAC", DM));
- break;
- }
-
- /*
- * Erase Character and
- * Erase Line
- */
- case EC:
- case EL:
- {
- cc_t ch;
-
- DIAG(TD_OPTIONS,
- printoption("td: recv IAC", c));
- ptyflush(); /* half-hearted */
- init_termbuf();
- if (c == EC)
- ch = *slctab[SLC_EC].sptr;
- else
- ch = *slctab[SLC_EL].sptr;
- if (ch != (cc_t)(_POSIX_VDISABLE))
- *pfrontp++ = (unsigned char)ch;
- break;
- }
-
- /*
- * Check for urgent data...
- */
- case DM:
- DIAG(TD_OPTIONS,
- printoption("td: recv IAC", c));
- SYNCHing = stilloob(net);
- settimer(gotDM);
- break;
-
-
- /*
- * Begin option subnegotiation...
- */
- case SB:
- state = TS_SB;
- SB_CLEAR();
- continue;
-
- case WILL:
- state = TS_WILL;
- continue;
-
- case WONT:
- state = TS_WONT;
- continue;
-
- case DO:
- state = TS_DO;
- continue;
-
- case DONT:
- state = TS_DONT;
- continue;
- case EOR:
- if (his_state_is_will(TELOPT_EOR))
- doeof();
- break;
-
- /*
- * Handle RFC 10xx Telnet linemode option additions
- * to command stream (EOF, SUSP, ABORT).
- */
- case xEOF:
- doeof();
- break;
-
- case SUSP:
- sendsusp();
- break;
-
- case ABORT:
- sendbrk();
- break;
-
- case IAC:
- *pfrontp++ = c;
- break;
- }
- state = TS_DATA;
- break;
-
- case TS_SB:
- if (c == IAC) {
- state = TS_SE;
- } else {
- SB_ACCUM(c);
- }
- break;
-
- case TS_SE:
- if (c != SE) {
- if (c != IAC) {
- /*
- * bad form of suboption negotiation.
- * handle it in such a way as to avoid
- * damage to local state. Parse
- * suboption buffer found so far,
- * then treat remaining stream as
- * another command sequence.
- */
-
- /* for DIAGNOSTICS */
- SB_ACCUM(IAC);
- SB_ACCUM(c);
- subpointer -= 2;
-
- SB_TERM();
- suboption();
- state = TS_IAC;
- goto gotiac;
- }
- SB_ACCUM(c);
- state = TS_SB;
- } else {
- /* for DIAGNOSTICS */
- SB_ACCUM(IAC);
- SB_ACCUM(SE);
- subpointer -= 2;
-
- SB_TERM();
- suboption(); /* handle sub-option */
- state = TS_DATA;
- }
- break;
-
- case TS_WILL:
- willoption(c);
- state = TS_DATA;
- continue;
-
- case TS_WONT:
- wontoption(c);
- state = TS_DATA;
- continue;
-
- case TS_DO:
- dooption(c);
- state = TS_DATA;
- continue;
-
- case TS_DONT:
- dontoption(c);
- state = TS_DATA;
- continue;
-
- default:
- syslog(LOG_ERR, "panic state=%d", state);
- printf("telnetd: panic state=%d\n", state);
- exit(1);
- }
- }
-#if defined(CRAY2) && defined(UNICOS5)
- if (!linemode) {
- char xptyobuf[BUFSIZ+NETSLOP];
- char xbuf2[BUFSIZ];
- register char *cp;
- int n = pfrontp - opfrontp, oc;
- memmove(xptyobuf, opfrontp, n);
- pfrontp = opfrontp;
- pfrontp += term_input(xptyobuf, pfrontp, n, BUFSIZ+NETSLOP,
- xbuf2, &oc, BUFSIZ);
- for (cp = xbuf2; oc > 0; --oc)
- if ((*nfrontp++ = *cp++) == IAC)
- *nfrontp++ = IAC;
- }
-#endif /* defined(CRAY2) && defined(UNICOS5) */
-} /* end of telrcv */
-
-/*
- * The will/wont/do/dont state machines are based on Dave Borman's
- * Telnet option processing state machine.
- *
- * These correspond to the following states:
- * my_state = the last negotiated state
- * want_state = what I want the state to go to
- * want_resp = how many requests I have sent
- * All state defaults are negative, and resp defaults to 0.
- *
- * When initiating a request to change state to new_state:
- *
- * if ((want_resp == 0 && new_state == my_state) || want_state == new_state) {
- * do nothing;
- * } else {
- * want_state = new_state;
- * send new_state;
- * want_resp++;
- * }
- *
- * When receiving new_state:
- *
- * if (want_resp) {
- * want_resp--;
- * if (want_resp && (new_state == my_state))
- * want_resp--;
- * }
- * if ((want_resp == 0) && (new_state != want_state)) {
- * if (ok_to_switch_to new_state)
- * want_state = new_state;
- * else
- * want_resp++;
- * send want_state;
- * }
- * my_state = new_state;
- *
- * Note that new_state is implied in these functions by the function itself.
- * will and do imply positive new_state, wont and dont imply negative.
- *
- * Finally, there is one catch. If we send a negative response to a
- * positive request, my_state will be the positive while want_state will
- * remain negative. my_state will revert to negative when the negative
- * acknowlegment arrives from the peer. Thus, my_state generally tells
- * us not only the last negotiated state, but also tells us what the peer
- * wants to be doing as well. It is important to understand this difference
- * as we may wish to be processing data streams based on our desired state
- * (want_state) or based on what the peer thinks the state is (my_state).
- *
- * This all works fine because if the peer sends a positive request, the data
- * that we receive prior to negative acknowlegment will probably be affected
- * by the positive state, and we can process it as such (if we can; if we
- * can't then it really doesn't matter). If it is that important, then the
- * peer probably should be buffering until this option state negotiation
- * is complete.
- *
- */
- void
-send_do(option, init)
- int option, init;
-{
- if (init) {
- if ((do_dont_resp[option] == 0 && his_state_is_will(option)) ||
- his_want_state_is_will(option))
- return;
- /*
- * Special case for TELOPT_TM: We send a DO, but pretend
- * that we sent a DONT, so that we can send more DOs if
- * we want to.
- */
- if (option == TELOPT_TM)
- set_his_want_state_wont(option);
- else
- set_his_want_state_will(option);
- do_dont_resp[option]++;
- }
- (void) sprintf(nfrontp, (char *)doopt, option);
- nfrontp += sizeof (dont) - 2;
-
- DIAG(TD_OPTIONS, printoption("td: send do", option));
-}
-
-#ifdef AUTHENTICATION
-extern void auth_request();
-#endif
-#ifdef LINEMODE
-extern void doclientstat();
-#endif
-#ifdef ENCRYPTION
-extern void encrypt_send_support();
-#endif /* ENCRYPTION */
-
- void
-willoption(option)
- int option;
-{
- int changeok = 0;
- void (*func)() = 0;
-
- /*
- * process input from peer.
- */
-
- DIAG(TD_OPTIONS, printoption("td: recv will", option));
-
- if (do_dont_resp[option]) {
- do_dont_resp[option]--;
- if (do_dont_resp[option] && his_state_is_will(option))
- do_dont_resp[option]--;
- }
- if (do_dont_resp[option] == 0) {
- if (his_want_state_is_wont(option)) {
- switch (option) {
-
- case TELOPT_BINARY:
- init_termbuf();
- tty_binaryin(1);
- set_termbuf();
- changeok++;
- break;
-
- case TELOPT_ECHO:
- /*
- * See comments below for more info.
- */
- not42 = 0; /* looks like a 4.2 system */
- break;
-
- case TELOPT_TM:
-#if defined(LINEMODE) && defined(KLUDGELINEMODE)
- /*
- * This telnetd implementation does not really
- * support timing marks, it just uses them to
- * support the kludge linemode stuff. If we
- * receive a will or wont TM in response to our
- * do TM request that may have been sent to
- * determine kludge linemode support, process
- * it, otherwise TM should get a negative
- * response back.
- */
- /*
- * Handle the linemode kludge stuff.
- * If we are not currently supporting any
- * linemode at all, then we assume that this
- * is the client telling us to use kludge
- * linemode in response to our query. Set the
- * linemode type that is to be supported, note
- * that the client wishes to use linemode, and
- * eat the will TM as though it never arrived.
- */
- if (lmodetype < KLUDGE_LINEMODE) {
- lmodetype = KLUDGE_LINEMODE;
- clientstat(TELOPT_LINEMODE, WILL, 0);
- send_wont(TELOPT_SGA, 1);
- } else if (lmodetype == NO_AUTOKLUDGE) {
- lmodetype = KLUDGE_OK;
- }
-#endif /* defined(LINEMODE) && defined(KLUDGELINEMODE) */
- /*
- * We never respond to a WILL TM, and
- * we leave the state WONT.
- */
- return;
-
- case TELOPT_LFLOW:
- /*
- * If we are going to support flow control
- * option, then don't worry peer that we can't
- * change the flow control characters.
- */
- slctab[SLC_XON].defset.flag &= ~SLC_LEVELBITS;
- slctab[SLC_XON].defset.flag |= SLC_DEFAULT;
- slctab[SLC_XOFF].defset.flag &= ~SLC_LEVELBITS;
- slctab[SLC_XOFF].defset.flag |= SLC_DEFAULT;
- case TELOPT_TTYPE:
- case TELOPT_SGA:
- case TELOPT_NAWS:
- case TELOPT_TSPEED:
- case TELOPT_XDISPLOC:
- case TELOPT_NEW_ENVIRON:
- case TELOPT_OLD_ENVIRON:
- changeok++;
- break;
-
-#ifdef LINEMODE
- case TELOPT_LINEMODE:
-# ifdef KLUDGELINEMODE
- /*
- * Note client's desire to use linemode.
- */
- lmodetype = REAL_LINEMODE;
-# endif /* KLUDGELINEMODE */
- func = doclientstat;
- changeok++;
- break;
-#endif /* LINEMODE */
-
-#ifdef AUTHENTICATION
- case TELOPT_AUTHENTICATION:
- func = auth_request;
- changeok++;
- break;
-#endif
-
-#ifdef ENCRYPTION
- case TELOPT_ENCRYPT:
- func = encrypt_send_support;
- changeok++;
- break;
-#endif /* ENCRYPTION */
-
- default:
- break;
- }
- if (changeok) {
- set_his_want_state_will(option);
- send_do(option, 0);
- } else {
- do_dont_resp[option]++;
- send_dont(option, 0);
- }
- } else {
- /*
- * Option processing that should happen when
- * we receive conformation of a change in
- * state that we had requested.
- */
- switch (option) {
- case TELOPT_ECHO:
- not42 = 0; /* looks like a 4.2 system */
- /*
- * Egads, he responded "WILL ECHO". Turn
- * it off right now!
- */
- send_dont(option, 1);
- /*
- * "WILL ECHO". Kludge upon kludge!
- * A 4.2 client is now echoing user input at
- * the tty. This is probably undesireable and
- * it should be stopped. The client will
- * respond WONT TM to the DO TM that we send to
- * check for kludge linemode. When the WONT TM
- * arrives, linemode will be turned off and a
- * change propogated to the pty. This change
- * will cause us to process the new pty state
- * in localstat(), which will notice that
- * linemode is off and send a WILL ECHO
- * so that we are properly in character mode and
- * all is well.
- */
- break;
-#ifdef LINEMODE
- case TELOPT_LINEMODE:
-# ifdef KLUDGELINEMODE
- /*
- * Note client's desire to use linemode.
- */
- lmodetype = REAL_LINEMODE;
-# endif /* KLUDGELINEMODE */
- func = doclientstat;
- break;
-#endif /* LINEMODE */
-
-#ifdef AUTHENTICATION
- case TELOPT_AUTHENTICATION:
- func = auth_request;
- break;
-#endif
-
-#ifdef ENCRYPTION
- case TELOPT_ENCRYPT:
- func = encrypt_send_support;
- break;
-#endif /* ENCRYPTION */
- case TELOPT_LFLOW:
- func = flowstat;
- break;
- }
- }
- }
- set_his_state_will(option);
- if (func)
- (*func)();
-} /* end of willoption */
-
- void
-send_dont(option, init)
- int option, init;
-{
- if (init) {
- if ((do_dont_resp[option] == 0 && his_state_is_wont(option)) ||
- his_want_state_is_wont(option))
- return;
- set_his_want_state_wont(option);
- do_dont_resp[option]++;
- }
- (void) sprintf(nfrontp, (char *)dont, option);
- nfrontp += sizeof (doopt) - 2;
-
- DIAG(TD_OPTIONS, printoption("td: send dont", option));
-}
-
- void
-wontoption(option)
- int option;
-{
- /*
- * Process client input.
- */
-
- DIAG(TD_OPTIONS, printoption("td: recv wont", option));
-
- if (do_dont_resp[option]) {
- do_dont_resp[option]--;
- if (do_dont_resp[option] && his_state_is_wont(option))
- do_dont_resp[option]--;
- }
- if (do_dont_resp[option] == 0) {
- if (his_want_state_is_will(option)) {
- /* it is always ok to change to negative state */
- switch (option) {
- case TELOPT_ECHO:
- not42 = 1; /* doesn't seem to be a 4.2 system */
- break;
-
- case TELOPT_BINARY:
- init_termbuf();
- tty_binaryin(0);
- set_termbuf();
- break;
-
-#ifdef LINEMODE
- case TELOPT_LINEMODE:
-# ifdef KLUDGELINEMODE
- /*
- * If real linemode is supported, then client is
- * asking to turn linemode off.
- */
- if (lmodetype != REAL_LINEMODE)
- break;
-# endif /* KLUDGELINEMODE */
- clientstat(TELOPT_LINEMODE, WONT, 0);
- break;
-#endif /* LINEMODE */
-
- case TELOPT_TM:
- /*
- * If we get a WONT TM, and had sent a DO TM,
- * don't respond with a DONT TM, just leave it
- * as is. Short circut the state machine to
- * achive this.
- */
- set_his_want_state_wont(TELOPT_TM);
- return;
-
- case TELOPT_LFLOW:
- /*
- * If we are not going to support flow control
- * option, then let peer know that we can't
- * change the flow control characters.
- */
- slctab[SLC_XON].defset.flag &= ~SLC_LEVELBITS;
- slctab[SLC_XON].defset.flag |= SLC_CANTCHANGE;
- slctab[SLC_XOFF].defset.flag &= ~SLC_LEVELBITS;
- slctab[SLC_XOFF].defset.flag |= SLC_CANTCHANGE;
- break;
-
-#if defined(AUTHENTICATION)
- case TELOPT_AUTHENTICATION:
- auth_finished(0, AUTH_REJECT);
- break;
-#endif
-
- /*
- * For options that we might spin waiting for
- * sub-negotiation, if the client turns off the
- * option rather than responding to the request,
- * we have to treat it here as if we got a response
- * to the sub-negotiation, (by updating the timers)
- * so that we'll break out of the loop.
- */
- case TELOPT_TTYPE:
- settimer(ttypesubopt);
- break;
-
- case TELOPT_TSPEED:
- settimer(tspeedsubopt);
- break;
-
- case TELOPT_XDISPLOC:
- settimer(xdisplocsubopt);
- break;
-
- case TELOPT_OLD_ENVIRON:
- settimer(oenvironsubopt);
- break;
-
- case TELOPT_NEW_ENVIRON:
- settimer(environsubopt);
- break;
-
- default:
- break;
- }
- set_his_want_state_wont(option);
- if (his_state_is_will(option))
- send_dont(option, 0);
- } else {
- switch (option) {
- case TELOPT_TM:
-#if defined(LINEMODE) && defined(KLUDGELINEMODE)
- if (lmodetype < NO_AUTOKLUDGE) {
- lmodetype = NO_LINEMODE;
- clientstat(TELOPT_LINEMODE, WONT, 0);
- send_will(TELOPT_SGA, 1);
- send_will(TELOPT_ECHO, 1);
- }
-#endif /* defined(LINEMODE) && defined(KLUDGELINEMODE) */
- break;
-
-#if defined(AUTHENTICATION)
- case TELOPT_AUTHENTICATION:
- auth_finished(0, AUTH_REJECT);
- break;
-#endif
- default:
- break;
- }
- }
- }
- set_his_state_wont(option);
-
-} /* end of wontoption */
-
- void
-send_will(option, init)
- int option, init;
-{
- if (init) {
- if ((will_wont_resp[option] == 0 && my_state_is_will(option))||
- my_want_state_is_will(option))
- return;
- set_my_want_state_will(option);
- will_wont_resp[option]++;
- }
- (void) sprintf(nfrontp, (char *)will, option);
- nfrontp += sizeof (doopt) - 2;
-
- DIAG(TD_OPTIONS, printoption("td: send will", option));
-}
-
-#if !defined(LINEMODE) || !defined(KLUDGELINEMODE)
-/*
- * When we get a DONT SGA, we will try once to turn it
- * back on. If the other side responds DONT SGA, we
- * leave it at that. This is so that when we talk to
- * clients that understand KLUDGELINEMODE but not LINEMODE,
- * we'll keep them in char-at-a-time mode.
- */
-int turn_on_sga = 0;
-#endif
-
- void
-dooption(option)
- int option;
-{
- int changeok = 0;
-
- /*
- * Process client input.
- */
-
- DIAG(TD_OPTIONS, printoption("td: recv do", option));
-
- if (will_wont_resp[option]) {
- will_wont_resp[option]--;
- if (will_wont_resp[option] && my_state_is_will(option))
- will_wont_resp[option]--;
- }
- if ((will_wont_resp[option] == 0) && (my_want_state_is_wont(option))) {
- switch (option) {
- case TELOPT_ECHO:
-#ifdef LINEMODE
-# ifdef KLUDGELINEMODE
- if (lmodetype == NO_LINEMODE)
-# else
- if (his_state_is_wont(TELOPT_LINEMODE))
-# endif
-#endif
- {
- init_termbuf();
- tty_setecho(1);
- set_termbuf();
- }
- changeok++;
- break;
-
- case TELOPT_BINARY:
- init_termbuf();
- tty_binaryout(1);
- set_termbuf();
- changeok++;
- break;
-
- case TELOPT_SGA:
-#if defined(LINEMODE) && defined(KLUDGELINEMODE)
- /*
- * If kludge linemode is in use, then we must
- * process an incoming do SGA for linemode
- * purposes.
- */
- if (lmodetype == KLUDGE_LINEMODE) {
- /*
- * Receipt of "do SGA" in kludge
- * linemode is the peer asking us to
- * turn off linemode. Make note of
- * the request.
- */
- clientstat(TELOPT_LINEMODE, WONT, 0);
- /*
- * If linemode did not get turned off
- * then don't tell peer that we did.
- * Breaking here forces a wont SGA to
- * be returned.
- */
- if (linemode)
- break;
- }
-#else
- turn_on_sga = 0;
-#endif /* defined(LINEMODE) && defined(KLUDGELINEMODE) */
- changeok++;
- break;
-
- case TELOPT_STATUS:
- changeok++;
- break;
-
- case TELOPT_TM:
- /*
- * Special case for TM. We send a WILL, but
- * pretend we sent a WONT.
- */
- send_will(option, 0);
- set_my_want_state_wont(option);
- set_my_state_wont(option);
- return;
-
- case TELOPT_LOGOUT:
- /*
- * When we get a LOGOUT option, respond
- * with a WILL LOGOUT, make sure that
- * it gets written out to the network,
- * and then just go away...
- */
- set_my_want_state_will(TELOPT_LOGOUT);
- send_will(TELOPT_LOGOUT, 0);
- set_my_state_will(TELOPT_LOGOUT);
- (void)netflush();
- cleanup(0);
- /* NOT REACHED */
- break;
-
-#ifdef ENCRYPTION
- case TELOPT_ENCRYPT:
- changeok++;
- break;
-#endif /* ENCRYPTION */
- case TELOPT_LINEMODE:
- case TELOPT_TTYPE:
- case TELOPT_NAWS:
- case TELOPT_TSPEED:
- case TELOPT_LFLOW:
- case TELOPT_XDISPLOC:
-#ifdef TELOPT_ENVIRON
- case TELOPT_NEW_ENVIRON:
-#endif
- case TELOPT_OLD_ENVIRON:
- default:
- break;
- }
- if (changeok) {
- set_my_want_state_will(option);
- send_will(option, 0);
- } else {
- will_wont_resp[option]++;
- send_wont(option, 0);
- }
- }
- set_my_state_will(option);
-
-} /* end of dooption */
-
- void
-send_wont(option, init)
- int option, init;
-{
- if (init) {
- if ((will_wont_resp[option] == 0 && my_state_is_wont(option)) ||
- my_want_state_is_wont(option))
- return;
- set_my_want_state_wont(option);
- will_wont_resp[option]++;
- }
- (void) sprintf(nfrontp, (char *)wont, option);
- nfrontp += sizeof (wont) - 2;
-
- DIAG(TD_OPTIONS, printoption("td: send wont", option));
-}
-
- void
-dontoption(option)
- int option;
-{
- /*
- * Process client input.
- */
-
-
- DIAG(TD_OPTIONS, printoption("td: recv dont", option));
-
- if (will_wont_resp[option]) {
- will_wont_resp[option]--;
- if (will_wont_resp[option] && my_state_is_wont(option))
- will_wont_resp[option]--;
- }
- if ((will_wont_resp[option] == 0) && (my_want_state_is_will(option))) {
- switch (option) {
- case TELOPT_BINARY:
- init_termbuf();
- tty_binaryout(0);
- set_termbuf();
- break;
-
- case TELOPT_ECHO: /* we should stop echoing */
-#ifdef LINEMODE
-# ifdef KLUDGELINEMODE
- if ((lmodetype != REAL_LINEMODE) &&
- (lmodetype != KLUDGE_LINEMODE))
-# else
- if (his_state_is_wont(TELOPT_LINEMODE))
-# endif
-#endif
- {
- init_termbuf();
- tty_setecho(0);
- set_termbuf();
- }
- break;
-
- case TELOPT_SGA:
-#if defined(LINEMODE) && defined(KLUDGELINEMODE)
- /*
- * If kludge linemode is in use, then we
- * must process an incoming do SGA for
- * linemode purposes.
- */
- if ((lmodetype == KLUDGE_LINEMODE) ||
- (lmodetype == KLUDGE_OK)) {
- /*
- * The client is asking us to turn
- * linemode on.
- */
- lmodetype = KLUDGE_LINEMODE;
- clientstat(TELOPT_LINEMODE, WILL, 0);
- /*
- * If we did not turn line mode on,
- * then what do we say? Will SGA?
- * This violates design of telnet.
- * Gross. Very Gross.
- */
- }
- break;
-#else
- set_my_want_state_wont(option);
- if (my_state_is_will(option))
- send_wont(option, 0);
- set_my_state_wont(option);
- if (turn_on_sga ^= 1)
- send_will(option, 1);
- return;
-#endif /* defined(LINEMODE) && defined(KLUDGELINEMODE) */
-
- default:
- break;
- }
-
- set_my_want_state_wont(option);
- if (my_state_is_will(option))
- send_wont(option, 0);
- }
- set_my_state_wont(option);
-
-} /* end of dontoption */
-
-#ifdef ENV_HACK
-int env_ovar = -1;
-int env_ovalue = -1;
-#else /* ENV_HACK */
-# define env_ovar OLD_ENV_VAR
-# define env_ovalue OLD_ENV_VALUE
-#endif /* ENV_HACK */
-
-/*
- * suboption()
- *
- * Look at the sub-option buffer, and try to be helpful to the other
- * side.
- *
- * Currently we recognize:
- *
- * Terminal type is
- * Linemode
- * Window size
- * Terminal speed
- */
- void
-suboption()
-{
- register int subchar;
-
- DIAG(TD_OPTIONS, {netflush(); printsub('<', subpointer, SB_LEN()+2);});
-
- subchar = SB_GET();
- switch (subchar) {
- case TELOPT_TSPEED: {
- register int xspeed, rspeed;
-
- if (his_state_is_wont(TELOPT_TSPEED)) /* Ignore if option disabled */
- break;
-
- settimer(tspeedsubopt);
-
- if (SB_EOF() || SB_GET() != TELQUAL_IS)
- return;
-
- xspeed = atoi((char *)subpointer);
-
- while (SB_GET() != ',' && !SB_EOF());
- if (SB_EOF())
- return;
-
- rspeed = atoi((char *)subpointer);
- clientstat(TELOPT_TSPEED, xspeed, rspeed);
-
- break;
-
- } /* end of case TELOPT_TSPEED */
-
- case TELOPT_TTYPE: { /* Yaaaay! */
- static char terminalname[41];
-
- if (his_state_is_wont(TELOPT_TTYPE)) /* Ignore if option disabled */
- break;
- settimer(ttypesubopt);
-
- if (SB_EOF() || SB_GET() != TELQUAL_IS) {
- return; /* ??? XXX but, this is the most robust */
- }
-
- terminaltype = terminalname;
-
- while ((terminaltype < (terminalname + sizeof terminalname-1)) &&
- !SB_EOF()) {
- register int c;
-
- c = SB_GET();
- if (isupper(c)) {
- c = tolower(c);
- }
- *terminaltype++ = c; /* accumulate name */
- }
- *terminaltype = 0;
- terminaltype = terminalname;
- break;
- } /* end of case TELOPT_TTYPE */
-
- case TELOPT_NAWS: {
- register int xwinsize, ywinsize;
-
- if (his_state_is_wont(TELOPT_NAWS)) /* Ignore if option disabled */
- break;
-
- if (SB_EOF())
- return;
- xwinsize = SB_GET() << 8;
- if (SB_EOF())
- return;
- xwinsize |= SB_GET();
- if (SB_EOF())
- return;
- ywinsize = SB_GET() << 8;
- if (SB_EOF())
- return;
- ywinsize |= SB_GET();
- clientstat(TELOPT_NAWS, xwinsize, ywinsize);
-
- break;
-
- } /* end of case TELOPT_NAWS */
-
-#ifdef LINEMODE
- case TELOPT_LINEMODE: {
- register int request;
-
- if (his_state_is_wont(TELOPT_LINEMODE)) /* Ignore if option disabled */
- break;
- /*
- * Process linemode suboptions.
- */
- if (SB_EOF())
- break; /* garbage was sent */
- request = SB_GET(); /* get will/wont */
-
- if (SB_EOF())
- break; /* another garbage check */
-
- if (request == LM_SLC) { /* SLC is not preceeded by WILL or WONT */
- /*
- * Process suboption buffer of slc's
- */
- start_slc(1);
- do_opt_slc(subpointer, subend - subpointer);
- (void) end_slc(0);
- break;
- } else if (request == LM_MODE) {
- if (SB_EOF())
- return;
- useeditmode = SB_GET(); /* get mode flag */
- clientstat(LM_MODE, 0, 0);
- break;
- }
-
- if (SB_EOF())
- break;
- switch (SB_GET()) { /* what suboption? */
- case LM_FORWARDMASK:
- /*
- * According to spec, only server can send request for
- * forwardmask, and client can only return a positive response.
- * So don't worry about it.
- */
-
- default:
- break;
- }
- break;
- } /* end of case TELOPT_LINEMODE */
-#endif
- case TELOPT_STATUS: {
- int mode;
-
- if (SB_EOF())
- break;
- mode = SB_GET();
- switch (mode) {
- case TELQUAL_SEND:
- if (my_state_is_will(TELOPT_STATUS))
- send_status();
- break;
-
- case TELQUAL_IS:
- break;
-
- default:
- break;
- }
- break;
- } /* end of case TELOPT_STATUS */
-
- case TELOPT_XDISPLOC: {
- if (SB_EOF() || SB_GET() != TELQUAL_IS)
- return;
- settimer(xdisplocsubopt);
- subpointer[SB_LEN()] = '\0';
- (void)setenv("DISPLAY", (char *)subpointer, 1);
- break;
- } /* end of case TELOPT_XDISPLOC */
-
-#ifdef TELOPT_NEW_ENVIRON
- case TELOPT_NEW_ENVIRON:
-#endif
- case TELOPT_OLD_ENVIRON: {
- register int c;
- register char *cp, *varp, *valp;
-
- if (SB_EOF())
- return;
- c = SB_GET();
- if (c == TELQUAL_IS) {
- if (subchar == TELOPT_OLD_ENVIRON)
- settimer(oenvironsubopt);
- else
- settimer(environsubopt);
- } else if (c != TELQUAL_INFO) {
- return;
- }
-
-#ifdef TELOPT_NEW_ENVIRON
- if (subchar == TELOPT_NEW_ENVIRON) {
- while (!SB_EOF()) {
- c = SB_GET();
- if ((c == NEW_ENV_VAR) || (c == ENV_USERVAR))
- break;
- }
- } else
-#endif
- {
-#ifdef ENV_HACK
- /*
- * We only want to do this if we haven't already decided
- * whether or not the other side has its VALUE and VAR
- * reversed.
- */
- if (env_ovar < 0) {
- register int last = -1; /* invalid value */
- int empty = 0;
- int got_var = 0, got_value = 0, got_uservar = 0;
-
- /*
- * The other side might have its VALUE and VAR values
- * reversed. To be interoperable, we need to determine
- * which way it is. If the first recognized character
- * is a VAR or VALUE, then that will tell us what
- * type of client it is. If the fist recognized
- * character is a USERVAR, then we continue scanning
- * the suboption looking for two consecutive
- * VAR or VALUE fields. We should not get two
- * consecutive VALUE fields, so finding two
- * consecutive VALUE or VAR fields will tell us
- * what the client is.
- */
- SB_SAVE();
- while (!SB_EOF()) {
- c = SB_GET();
- switch(c) {
- case OLD_ENV_VAR:
- if (last < 0 || last == OLD_ENV_VAR
- || (empty && (last == OLD_ENV_VALUE)))
- goto env_ovar_ok;
- got_var++;
- last = OLD_ENV_VAR;
- break;
- case OLD_ENV_VALUE:
- if (last < 0 || last == OLD_ENV_VALUE
- || (empty && (last == OLD_ENV_VAR)))
- goto env_ovar_wrong;
- got_value++;
- last = OLD_ENV_VALUE;
- break;
- case ENV_USERVAR:
- /* count strings of USERVAR as one */
- if (last != ENV_USERVAR)
- got_uservar++;
- if (empty) {
- if (last == OLD_ENV_VALUE)
- goto env_ovar_ok;
- if (last == OLD_ENV_VAR)
- goto env_ovar_wrong;
- }
- last = ENV_USERVAR;
- break;
- case ENV_ESC:
- if (!SB_EOF())
- c = SB_GET();
- /* FALL THROUGH */
- default:
- empty = 0;
- continue;
- }
- empty = 1;
- }
- if (empty) {
- if (last == OLD_ENV_VALUE)
- goto env_ovar_ok;
- if (last == OLD_ENV_VAR)
- goto env_ovar_wrong;
- }
- /*
- * Ok, the first thing was a USERVAR, and there
- * are not two consecutive VAR or VALUE commands,
- * and none of the VAR or VALUE commands are empty.
- * If the client has sent us a well-formed option,
- * then the number of VALUEs received should always
- * be less than or equal to the number of VARs and
- * USERVARs received.
- *
- * If we got exactly as many VALUEs as VARs and
- * USERVARs, the client has the same definitions.
- *
- * If we got exactly as many VARs as VALUEs and
- * USERVARS, the client has reversed definitions.
- */
- if (got_uservar + got_var == got_value) {
- env_ovar_ok:
- env_ovar = OLD_ENV_VAR;
- env_ovalue = OLD_ENV_VALUE;
- } else if (got_uservar + got_value == got_var) {
- env_ovar_wrong:
- env_ovar = OLD_ENV_VALUE;
- env_ovalue = OLD_ENV_VAR;
- DIAG(TD_OPTIONS, {sprintf(nfrontp,
- "ENVIRON VALUE and VAR are reversed!\r\n");
- nfrontp += strlen(nfrontp);});
-
- }
- }
- SB_RESTORE();
-#endif
-
- while (!SB_EOF()) {
- c = SB_GET();
- if ((c == env_ovar) || (c == ENV_USERVAR))
- break;
- }
- }
-
- if (SB_EOF())
- return;
-
- cp = varp = (char *)subpointer;
- valp = 0;
-
- while (!SB_EOF()) {
- c = SB_GET();
- if (subchar == TELOPT_OLD_ENVIRON) {
- if (c == env_ovar)
- c = NEW_ENV_VAR;
- else if (c == env_ovalue)
- c = NEW_ENV_VALUE;
- }
- switch (c) {
-
- case NEW_ENV_VALUE:
- *cp = '\0';
- cp = valp = (char *)subpointer;
- break;
-
- case NEW_ENV_VAR:
- case ENV_USERVAR:
- *cp = '\0';
- if (valp)
- (void)setenv(varp, valp, 1);
- else
- unsetenv(varp);
- cp = varp = (char *)subpointer;
- valp = 0;
- break;
-
- case ENV_ESC:
- if (SB_EOF())
- break;
- c = SB_GET();
- /* FALL THROUGH */
- default:
- *cp++ = c;
- break;
- }
- }
- *cp = '\0';
- if (valp)
- (void)setenv(varp, valp, 1);
- else
- unsetenv(varp);
- break;
- } /* end of case TELOPT_NEW_ENVIRON */
-#if defined(AUTHENTICATION)
- case TELOPT_AUTHENTICATION:
- if (SB_EOF())
- break;
- switch(SB_GET()) {
- case TELQUAL_SEND:
- case TELQUAL_REPLY:
- /*
- * These are sent by us and cannot be sent by
- * the client.
- */
- break;
- case TELQUAL_IS:
- auth_is(subpointer, SB_LEN());
- break;
- case TELQUAL_NAME:
- auth_name(subpointer, SB_LEN());
- break;
- }
- break;
-#endif
-#ifdef ENCRYPTION
- case TELOPT_ENCRYPT:
- if (SB_EOF())
- break;
- switch(SB_GET()) {
- case ENCRYPT_SUPPORT:
- encrypt_support(subpointer, SB_LEN());
- break;
- case ENCRYPT_IS:
- encrypt_is(subpointer, SB_LEN());
- break;
- case ENCRYPT_REPLY:
- encrypt_reply(subpointer, SB_LEN());
- break;
- case ENCRYPT_START:
- encrypt_start(subpointer, SB_LEN());
- break;
- case ENCRYPT_END:
- encrypt_end();
- break;
- case ENCRYPT_REQSTART:
- encrypt_request_start(subpointer, SB_LEN());
- break;
- case ENCRYPT_REQEND:
- /*
- * We can always send an REQEND so that we cannot
- * get stuck encrypting. We should only get this
- * if we have been able to get in the correct mode
- * anyhow.
- */
- encrypt_request_end();
- break;
- case ENCRYPT_ENC_KEYID:
- encrypt_enc_keyid(subpointer, SB_LEN());
- break;
- case ENCRYPT_DEC_KEYID:
- encrypt_dec_keyid(subpointer, SB_LEN());
- break;
- default:
- break;
- }
- break;
-#endif /* ENCRYPTION */
-
- default:
- break;
- } /* end of switch */
-
-} /* end of suboption */
-
- void
-doclientstat()
-{
- clientstat(TELOPT_LINEMODE, WILL, 0);
-}
-
-#define ADD(c) *ncp++ = c
-#define ADD_DATA(c) { *ncp++ = c; if (c == SE || c == IAC) *ncp++ = c; }
- void
-send_status()
-{
- unsigned char statusbuf[256];
- register unsigned char *ncp;
- register unsigned char i;
-
- ncp = statusbuf;
-
- netflush(); /* get rid of anything waiting to go out */
-
- ADD(IAC);
- ADD(SB);
- ADD(TELOPT_STATUS);
- ADD(TELQUAL_IS);
-
- /*
- * We check the want_state rather than the current state,
- * because if we received a DO/WILL for an option that we
- * don't support, and the other side didn't send a DONT/WONT
- * in response to our WONT/DONT, then the "state" will be
- * WILL/DO, and the "want_state" will be WONT/DONT. We
- * need to go by the latter.
- */
- for (i = 0; i < (unsigned char)NTELOPTS; i++) {
- if (my_want_state_is_will(i)) {
- ADD(WILL);
- ADD_DATA(i);
- }
- if (his_want_state_is_will(i)) {
- ADD(DO);
- ADD_DATA(i);
- }
- }
-
- if (his_want_state_is_will(TELOPT_LFLOW)) {
- ADD(SB);
- ADD(TELOPT_LFLOW);
- if (flowmode) {
- ADD(LFLOW_ON);
- } else {
- ADD(LFLOW_OFF);
- }
- ADD(SE);
-
- if (restartany >= 0) {
- ADD(SB);
- ADD(TELOPT_LFLOW);
- if (restartany) {
- ADD(LFLOW_RESTART_ANY);
- } else {
- ADD(LFLOW_RESTART_XON);
- }
- ADD(SE);
- }
- }
-
-#ifdef LINEMODE
- if (his_want_state_is_will(TELOPT_LINEMODE)) {
- unsigned char *cp, *cpe;
- int len;
-
- ADD(SB);
- ADD(TELOPT_LINEMODE);
- ADD(LM_MODE);
- ADD_DATA(editmode);
- ADD(SE);
-
- ADD(SB);
- ADD(TELOPT_LINEMODE);
- ADD(LM_SLC);
- start_slc(0);
- send_slc();
- len = end_slc(&cp);
- for (cpe = cp + len; cp < cpe; cp++)
- ADD_DATA(*cp);
- ADD(SE);
- }
-#endif /* LINEMODE */
-
- ADD(IAC);
- ADD(SE);
-
- writenet(statusbuf, ncp - statusbuf);
- netflush(); /* Send it on its way */
-
- DIAG(TD_OPTIONS,
- {printsub('>', statusbuf, ncp - statusbuf); netflush();});
-}
diff --git a/contrib/telnet/telnetd/sys_term.c b/contrib/telnet/telnetd/sys_term.c
deleted file mode 100644
index 235e409be7aa..000000000000
--- a/contrib/telnet/telnetd/sys_term.c
+++ /dev/null
@@ -1,2333 +0,0 @@
-/*
- * Copyright (c) 1989, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-#if 0
-static const char sccsid[] = "@(#)sys_term.c 8.4+1 (Berkeley) 5/30/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include "telnetd.h"
-#include "pathnames.h"
-
-#if defined(AUTHENTICATION)
-#include <libtelnet/auth.h>
-#endif
-
-extern char *altlogin;
-int cleanopen(char *line);
-void scrub_env(void);
-
-#if defined(CRAY) || defined(__hpux)
-# define PARENT_DOES_UTMP
-#endif
-
-#ifdef NEWINIT
-#include <initreq.h>
-#else /* NEWINIT*/
-# ifdef UTMPX
-# include <utmpx.h>
-struct utmpx wtmp;
-# else
-# include <utmp.h>
-struct utmp wtmp;
-# endif /* UTMPX */
-
-# ifndef PARENT_DOES_UTMP
-#ifdef _PATH_WTMP
-char wtmpf[] = _PATH_WTMP;
-#else
-char wtmpf[] = "/usr/adm/wtmp";
-#endif
-#ifdef _PATH_UTMP
-char utmpf[] = _PATH_UTMP;
-#else
-char utmpf[] = "/etc/utmp";
-#endif
-# else /* PARENT_DOES_UTMP */
-char wtmpf[] = "/etc/wtmp";
-# endif /* PARENT_DOES_UTMP */
-
-#include <libutil.h>
-
-# ifdef CRAY
-#include <tmpdir.h>
-#include <sys/wait.h>
-# if (UNICOS_LVL == '7.0') || (UNICOS_LVL == '7.1')
-# define UNICOS7x
-# endif
-
-# ifdef UNICOS7x
-#include <sys/sysv.h>
-#include <sys/secstat.h>
-extern int secflag;
-extern struct sysv sysv;
-# endif /* UNICOS7x */
-# endif /* CRAY */
-#endif /* NEWINIT */
-
-#ifdef STREAMSPTY
-#include <sac.h>
-#include <sys/stropts.h>
-#endif
-
-#define SCPYN(a, b) (void) strncpy(a, b, sizeof(a))
-#define SCMPN(a, b) strncmp(a, b, sizeof(a))
-
-#ifdef STREAMS
-#include <sys/stream.h>
-#endif
-#ifdef __hpux
-#include <sys/resource.h>
-#include <sys/proc.h>
-#endif
-#include <sys/tty.h>
-#ifdef t_erase
-#undef t_erase
-#undef t_kill
-#undef t_intrc
-#undef t_quitc
-#undef t_startc
-#undef t_stopc
-#undef t_eofc
-#undef t_brkc
-#undef t_suspc
-#undef t_dsuspc
-#undef t_rprntc
-#undef t_flushc
-#undef t_werasc
-#undef t_lnextc
-#endif
-
-#if defined(UNICOS5) && defined(CRAY2) && !defined(EXTPROC)
-# define EXTPROC 0400
-#endif
-
-#ifndef USE_TERMIO
-struct termbuf {
- struct sgttyb sg;
- struct tchars tc;
- struct ltchars ltc;
- int state;
- int lflags;
-} termbuf, termbuf2;
-# define cfsetospeed(tp, val) (tp)->sg.sg_ospeed = (val)
-# define cfsetispeed(tp, val) (tp)->sg.sg_ispeed = (val)
-# define cfgetospeed(tp) (tp)->sg.sg_ospeed
-# define cfgetispeed(tp) (tp)->sg.sg_ispeed
-#else /* USE_TERMIO */
-# ifdef SYSV_TERMIO
-# define termios termio
-# endif
-# ifndef TCSANOW
-# ifdef TCSETS
-# define TCSANOW TCSETS
-# define TCSADRAIN TCSETSW
-# define tcgetattr(f, t) ioctl(f, TCGETS, (char *)t)
-# else
-# ifdef TCSETA
-# define TCSANOW TCSETA
-# define TCSADRAIN TCSETAW
-# define tcgetattr(f, t) ioctl(f, TCGETA, (char *)t)
-# else
-# define TCSANOW TIOCSETA
-# define TCSADRAIN TIOCSETAW
-# define tcgetattr(f, t) ioctl(f, TIOCGETA, (char *)t)
-# endif
-# endif
-# define tcsetattr(f, a, t) ioctl(f, a, t)
-# define cfsetospeed(tp, val) (tp)->c_cflag &= ~CBAUD; \
- (tp)->c_cflag |= (val)
-# define cfgetospeed(tp) ((tp)->c_cflag & CBAUD)
-# ifdef CIBAUD
-# define cfsetispeed(tp, val) (tp)->c_cflag &= ~CIBAUD; \
- (tp)->c_cflag |= ((val)<<IBSHIFT)
-# define cfgetispeed(tp) (((tp)->c_cflag & CIBAUD)>>IBSHIFT)
-# else
-# define cfsetispeed(tp, val) (tp)->c_cflag &= ~CBAUD; \
- (tp)->c_cflag |= (val)
-# define cfgetispeed(tp) ((tp)->c_cflag & CBAUD)
-# endif
-# endif /* TCSANOW */
-struct termios termbuf, termbuf2; /* pty control structure */
-# ifdef STREAMSPTY
-int ttyfd = -1;
-# endif
-#endif /* USE_TERMIO */
-
-#include <sys/types.h>
-#include <libutil.h>
-
-int cleanopen __P((char *));
-void scrub_env __P((void));
-
-/*
- * init_termbuf()
- * copy_termbuf(cp)
- * set_termbuf()
- *
- * These three routines are used to get and set the "termbuf" structure
- * to and from the kernel. init_termbuf() gets the current settings.
- * copy_termbuf() hands in a new "termbuf" to write to the kernel, and
- * set_termbuf() writes the structure into the kernel.
- */
-
- void
-init_termbuf()
-{
-#ifndef USE_TERMIO
- (void) ioctl(pty, TIOCGETP, (char *)&termbuf.sg);
- (void) ioctl(pty, TIOCGETC, (char *)&termbuf.tc);
- (void) ioctl(pty, TIOCGLTC, (char *)&termbuf.ltc);
-# ifdef TIOCGSTATE
- (void) ioctl(pty, TIOCGSTATE, (char *)&termbuf.state);
-# endif
-#else
-# ifdef STREAMSPTY
- (void) tcgetattr(ttyfd, &termbuf);
-# else
- (void) tcgetattr(pty, &termbuf);
-# endif
-#endif
- termbuf2 = termbuf;
-}
-
-#if defined(LINEMODE) && defined(TIOCPKT_IOCTL)
- void
-copy_termbuf(cp, len)
- char *cp;
- int len;
-{
- if (len > sizeof(termbuf))
- len = sizeof(termbuf);
- memmove((char *)&termbuf, cp, len);
- termbuf2 = termbuf;
-}
-#endif /* defined(LINEMODE) && defined(TIOCPKT_IOCTL) */
-
- void
-set_termbuf()
-{
- /*
- * Only make the necessary changes.
- */
-#ifndef USE_TERMIO
- if (memcmp((char *)&termbuf.sg, (char *)&termbuf2.sg,
- sizeof(termbuf.sg)))
- (void) ioctl(pty, TIOCSETN, (char *)&termbuf.sg);
- if (memcmp((char *)&termbuf.tc, (char *)&termbuf2.tc,
- sizeof(termbuf.tc)))
- (void) ioctl(pty, TIOCSETC, (char *)&termbuf.tc);
- if (memcmp((char *)&termbuf.ltc, (char *)&termbuf2.ltc,
- sizeof(termbuf.ltc)))
- (void) ioctl(pty, TIOCSLTC, (char *)&termbuf.ltc);
- if (termbuf.lflags != termbuf2.lflags)
- (void) ioctl(pty, TIOCLSET, (char *)&termbuf.lflags);
-#else /* USE_TERMIO */
- if (memcmp((char *)&termbuf, (char *)&termbuf2, sizeof(termbuf)))
-# ifdef STREAMSPTY
- (void) tcsetattr(ttyfd, TCSANOW, &termbuf);
-# else
- (void) tcsetattr(pty, TCSANOW, &termbuf);
-# endif
-# if defined(CRAY2) && defined(UNICOS5)
- needtermstat = 1;
-# endif
-#endif /* USE_TERMIO */
-}
-
-
-/*
- * spcset(func, valp, valpp)
- *
- * This function takes various special characters (func), and
- * sets *valp to the current value of that character, and
- * *valpp to point to where in the "termbuf" structure that
- * value is kept.
- *
- * It returns the SLC_ level of support for this function.
- */
-
-#ifndef USE_TERMIO
- int
-spcset(func, valp, valpp)
- int func;
- cc_t *valp;
- cc_t **valpp;
-{
- switch(func) {
- case SLC_EOF:
- *valp = termbuf.tc.t_eofc;
- *valpp = (cc_t *)&termbuf.tc.t_eofc;
- return(SLC_VARIABLE);
- case SLC_EC:
- *valp = termbuf.sg.sg_erase;
- *valpp = (cc_t *)&termbuf.sg.sg_erase;
- return(SLC_VARIABLE);
- case SLC_EL:
- *valp = termbuf.sg.sg_kill;
- *valpp = (cc_t *)&termbuf.sg.sg_kill;
- return(SLC_VARIABLE);
- case SLC_IP:
- *valp = termbuf.tc.t_intrc;
- *valpp = (cc_t *)&termbuf.tc.t_intrc;
- return(SLC_VARIABLE|SLC_FLUSHIN|SLC_FLUSHOUT);
- case SLC_ABORT:
- *valp = termbuf.tc.t_quitc;
- *valpp = (cc_t *)&termbuf.tc.t_quitc;
- return(SLC_VARIABLE|SLC_FLUSHIN|SLC_FLUSHOUT);
- case SLC_XON:
- *valp = termbuf.tc.t_startc;
- *valpp = (cc_t *)&termbuf.tc.t_startc;
- return(SLC_VARIABLE);
- case SLC_XOFF:
- *valp = termbuf.tc.t_stopc;
- *valpp = (cc_t *)&termbuf.tc.t_stopc;
- return(SLC_VARIABLE);
- case SLC_AO:
- *valp = termbuf.ltc.t_flushc;
- *valpp = (cc_t *)&termbuf.ltc.t_flushc;
- return(SLC_VARIABLE);
- case SLC_SUSP:
- *valp = termbuf.ltc.t_suspc;
- *valpp = (cc_t *)&termbuf.ltc.t_suspc;
- return(SLC_VARIABLE);
- case SLC_EW:
- *valp = termbuf.ltc.t_werasc;
- *valpp = (cc_t *)&termbuf.ltc.t_werasc;
- return(SLC_VARIABLE);
- case SLC_RP:
- *valp = termbuf.ltc.t_rprntc;
- *valpp = (cc_t *)&termbuf.ltc.t_rprntc;
- return(SLC_VARIABLE);
- case SLC_LNEXT:
- *valp = termbuf.ltc.t_lnextc;
- *valpp = (cc_t *)&termbuf.ltc.t_lnextc;
- return(SLC_VARIABLE);
- case SLC_FORW1:
- *valp = termbuf.tc.t_brkc;
- *valpp = (cc_t *)&termbuf.ltc.t_lnextc;
- return(SLC_VARIABLE);
- case SLC_BRK:
- case SLC_SYNCH:
- case SLC_AYT:
- case SLC_EOR:
- *valp = (cc_t)0;
- *valpp = (cc_t *)0;
- return(SLC_DEFAULT);
- default:
- *valp = (cc_t)0;
- *valpp = (cc_t *)0;
- return(SLC_NOSUPPORT);
- }
-}
-
-#else /* USE_TERMIO */
-
- int
-spcset(func, valp, valpp)
- int func;
- cc_t *valp;
- cc_t **valpp;
-{
-
-#define setval(a, b) *valp = termbuf.c_cc[a]; \
- *valpp = &termbuf.c_cc[a]; \
- return(b);
-#define defval(a) *valp = ((cc_t)a); *valpp = (cc_t *)0; return(SLC_DEFAULT);
-
- switch(func) {
- case SLC_EOF:
- setval(VEOF, SLC_VARIABLE);
- case SLC_EC:
- setval(VERASE, SLC_VARIABLE);
- case SLC_EL:
- setval(VKILL, SLC_VARIABLE);
- case SLC_IP:
- setval(VINTR, SLC_VARIABLE|SLC_FLUSHIN|SLC_FLUSHOUT);
- case SLC_ABORT:
- setval(VQUIT, SLC_VARIABLE|SLC_FLUSHIN|SLC_FLUSHOUT);
- case SLC_XON:
-#ifdef VSTART
- setval(VSTART, SLC_VARIABLE);
-#else
- defval(0x13);
-#endif
- case SLC_XOFF:
-#ifdef VSTOP
- setval(VSTOP, SLC_VARIABLE);
-#else
- defval(0x11);
-#endif
- case SLC_EW:
-#ifdef VWERASE
- setval(VWERASE, SLC_VARIABLE);
-#else
- defval(0);
-#endif
- case SLC_RP:
-#ifdef VREPRINT
- setval(VREPRINT, SLC_VARIABLE);
-#else
- defval(0);
-#endif
- case SLC_LNEXT:
-#ifdef VLNEXT
- setval(VLNEXT, SLC_VARIABLE);
-#else
- defval(0);
-#endif
- case SLC_AO:
-#if !defined(VDISCARD) && defined(VFLUSHO)
-# define VDISCARD VFLUSHO
-#endif
-#ifdef VDISCARD
- setval(VDISCARD, SLC_VARIABLE|SLC_FLUSHOUT);
-#else
- defval(0);
-#endif
- case SLC_SUSP:
-#ifdef VSUSP
- setval(VSUSP, SLC_VARIABLE|SLC_FLUSHIN);
-#else
- defval(0);
-#endif
-#ifdef VEOL
- case SLC_FORW1:
- setval(VEOL, SLC_VARIABLE);
-#endif
-#ifdef VEOL2
- case SLC_FORW2:
- setval(VEOL2, SLC_VARIABLE);
-#endif
- case SLC_AYT:
-#ifdef VSTATUS
- setval(VSTATUS, SLC_VARIABLE);
-#else
- defval(0);
-#endif
-
- case SLC_BRK:
- case SLC_SYNCH:
- case SLC_EOR:
- defval(0);
-
- default:
- *valp = 0;
- *valpp = 0;
- return(SLC_NOSUPPORT);
- }
-}
-#endif /* USE_TERMIO */
-
-#ifdef CRAY
-/*
- * getnpty()
- *
- * Return the number of pty's configured into the system.
- */
- int
-getnpty()
-{
-#ifdef _SC_CRAY_NPTY
- int numptys;
-
- if ((numptys = sysconf(_SC_CRAY_NPTY)) != -1)
- return numptys;
- else
-#endif /* _SC_CRAY_NPTY */
- return 128;
-}
-#endif /* CRAY */
-
-#ifndef convex
-/*
- * getpty()
- *
- * Allocate a pty. As a side effect, the external character
- * array "line" contains the name of the slave side.
- *
- * Returns the file descriptor of the opened pty.
- */
-#ifndef __GNUC__
-char *line = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
-#else
-static char Xline[] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
-char *line = Xline;
-#endif
-#ifdef CRAY
-char *myline = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
-#endif /* CRAY */
-
- int
-getpty(ptynum)
-int *ptynum;
-{
- register int p;
-#ifdef STREAMSPTY
- int t;
- char *ptsname();
-
- p = open("/dev/ptmx", 2);
- if (p > 0) {
- grantpt(p);
- unlockpt(p);
- strcpy(line, ptsname(p));
- return(p);
- }
-
-#else /* ! STREAMSPTY */
-#ifndef CRAY
- register char *cp, *p1, *p2;
- register int i;
-#if defined(sun) && defined(TIOCGPGRP) && BSD < 199207
- int dummy;
-#endif
-
-#ifndef __hpux
- (void) strcpy(line, "/dev/ptyXX");
- p1 = &line[8];
- p2 = &line[9];
-#else
- (void) strcpy(line, "/dev/ptym/ptyXX");
- p1 = &line[13];
- p2 = &line[14];
-#endif
-
- for (cp = "pqrsPQRS"; *cp; cp++) {
- struct stat stb;
-
- *p1 = *cp;
- *p2 = '0';
- /*
- * This stat() check is just to keep us from
- * looping through all 256 combinations if there
- * aren't that many ptys available.
- */
- if (stat(line, &stb) < 0)
- break;
- for (i = 0; i < 32; i++) {
- *p2 = "0123456789abcdefghijklmnopqrstuv"[i];
- p = open(line, 2);
- if (p > 0) {
-#ifndef __hpux
- line[5] = 't';
-#else
- for (p1 = &line[8]; *p1; p1++)
- *p1 = *(p1+1);
- line[9] = 't';
-#endif
- chown(line, 0, 0);
- chmod(line, 0600);
-#if defined(sun) && defined(TIOCGPGRP) && BSD < 199207
- if (ioctl(p, TIOCGPGRP, &dummy) == 0
- || errno != EIO) {
- chmod(line, 0666);
- close(p);
- line[5] = 'p';
- } else
-#endif /* defined(sun) && defined(TIOCGPGRP) && BSD < 199207 */
- return(p);
- }
- }
- }
-#else /* CRAY */
- extern lowpty, highpty;
- struct stat sb;
-
- for (*ptynum = lowpty; *ptynum <= highpty; (*ptynum)++) {
- (void) sprintf(myline, "/dev/pty/%03d", *ptynum);
- p = open(myline, 2);
- if (p < 0)
- continue;
- (void) sprintf(line, "/dev/ttyp%03d", *ptynum);
- /*
- * Here are some shenanigans to make sure that there
- * are no listeners lurking on the line.
- */
- if(stat(line, &sb) < 0) {
- (void) close(p);
- continue;
- }
- if(sb.st_uid || sb.st_gid || sb.st_mode != 0600) {
- chown(line, 0, 0);
- chmod(line, 0600);
- (void)close(p);
- p = open(myline, 2);
- if (p < 0)
- continue;
- }
- /*
- * Now it should be safe...check for accessability.
- */
- if (access(line, 6) == 0)
- return(p);
- else {
- /* no tty side to pty so skip it */
- (void) close(p);
- }
- }
-#endif /* CRAY */
-#endif /* STREAMSPTY */
- return(-1);
-}
-#endif /* convex */
-
-#ifdef LINEMODE
-/*
- * tty_flowmode() Find out if flow control is enabled or disabled.
- * tty_linemode() Find out if linemode (external processing) is enabled.
- * tty_setlinemod(on) Turn on/off linemode.
- * tty_isecho() Find out if echoing is turned on.
- * tty_setecho(on) Enable/disable character echoing.
- * tty_israw() Find out if terminal is in RAW mode.
- * tty_binaryin(on) Turn on/off BINARY on input.
- * tty_binaryout(on) Turn on/off BINARY on output.
- * tty_isediting() Find out if line editing is enabled.
- * tty_istrapsig() Find out if signal trapping is enabled.
- * tty_setedit(on) Turn on/off line editing.
- * tty_setsig(on) Turn on/off signal trapping.
- * tty_issofttab() Find out if tab expansion is enabled.
- * tty_setsofttab(on) Turn on/off soft tab expansion.
- * tty_islitecho() Find out if typed control chars are echoed literally
- * tty_setlitecho() Turn on/off literal echo of control chars
- * tty_tspeed(val) Set transmit speed to val.
- * tty_rspeed(val) Set receive speed to val.
- */
-
-#ifdef convex
-static int linestate;
-#endif
-
- int
-tty_linemode()
-{
-#ifndef convex
-#ifndef USE_TERMIO
- return(termbuf.state & TS_EXTPROC);
-#else
- return(termbuf.c_lflag & EXTPROC);
-#endif
-#else
- return(linestate);
-#endif
-}
-
- void
-tty_setlinemode(on)
- int on;
-{
-#ifdef TIOCEXT
-# ifndef convex
- set_termbuf();
-# else
- linestate = on;
-# endif
- (void) ioctl(pty, TIOCEXT, (char *)&on);
-# ifndef convex
- init_termbuf();
-# endif
-#else /* !TIOCEXT */
-# ifdef EXTPROC
- if (on)
- termbuf.c_lflag |= EXTPROC;
- else
- termbuf.c_lflag &= ~EXTPROC;
-# endif
-#endif /* TIOCEXT */
-}
-#endif /* LINEMODE */
-
- int
-tty_isecho()
-{
-#ifndef USE_TERMIO
- return (termbuf.sg.sg_flags & ECHO);
-#else
- return (termbuf.c_lflag & ECHO);
-#endif
-}
-
- int
-tty_flowmode()
-{
-#ifndef USE_TERMIO
- return(((termbuf.tc.t_startc) > 0 && (termbuf.tc.t_stopc) > 0) ? 1 : 0);
-#else
- return((termbuf.c_iflag & IXON) ? 1 : 0);
-#endif
-}
-
- int
-tty_restartany()
-{
-#ifndef USE_TERMIO
-# ifdef DECCTQ
- return((termbuf.lflags & DECCTQ) ? 0 : 1);
-# else
- return(-1);
-# endif
-#else
- return((termbuf.c_iflag & IXANY) ? 1 : 0);
-#endif
-}
-
- void
-tty_setecho(on)
- int on;
-{
-#ifndef USE_TERMIO
- if (on)
- termbuf.sg.sg_flags |= ECHO|CRMOD;
- else
- termbuf.sg.sg_flags &= ~(ECHO|CRMOD);
-#else
- if (on)
- termbuf.c_lflag |= ECHO;
- else
- termbuf.c_lflag &= ~ECHO;
-#endif
-}
-
- int
-tty_israw()
-{
-#ifndef USE_TERMIO
- return(termbuf.sg.sg_flags & RAW);
-#else
- return(!(termbuf.c_lflag & ICANON));
-#endif
-}
-
-#if defined (AUTHENTICATION) && defined(NO_LOGIN_F) && defined(LOGIN_R)
- int
-tty_setraw(on)
-{
-# ifndef USE_TERMIO
- if (on)
- termbuf.sg.sg_flags |= RAW;
- else
- termbuf.sg.sg_flags &= ~RAW;
-# else
- if (on)
- termbuf.c_lflag &= ~ICANON;
- else
- termbuf.c_lflag |= ICANON;
-# endif
-}
-#endif
-
- void
-tty_binaryin(on)
- int on;
-{
-#ifndef USE_TERMIO
- if (on)
- termbuf.lflags |= LPASS8;
- else
- termbuf.lflags &= ~LPASS8;
-#else
- if (on) {
- termbuf.c_iflag &= ~ISTRIP;
- } else {
- termbuf.c_iflag |= ISTRIP;
- }
-#endif
-}
-
- void
-tty_binaryout(on)
- int on;
-{
-#ifndef USE_TERMIO
- if (on)
- termbuf.lflags |= LLITOUT;
- else
- termbuf.lflags &= ~LLITOUT;
-#else
- if (on) {
- termbuf.c_cflag &= ~(CSIZE|PARENB);
- termbuf.c_cflag |= CS8;
- termbuf.c_oflag &= ~OPOST;
- } else {
- termbuf.c_cflag &= ~CSIZE;
- termbuf.c_cflag |= CS7|PARENB;
- termbuf.c_oflag |= OPOST;
- }
-#endif
-}
-
- int
-tty_isbinaryin()
-{
-#ifndef USE_TERMIO
- return(termbuf.lflags & LPASS8);
-#else
- return(!(termbuf.c_iflag & ISTRIP));
-#endif
-}
-
- int
-tty_isbinaryout()
-{
-#ifndef USE_TERMIO
- return(termbuf.lflags & LLITOUT);
-#else
- return(!(termbuf.c_oflag&OPOST));
-#endif
-}
-
-#ifdef LINEMODE
- int
-tty_isediting()
-{
-#ifndef USE_TERMIO
- return(!(termbuf.sg.sg_flags & (CBREAK|RAW)));
-#else
- return(termbuf.c_lflag & ICANON);
-#endif
-}
-
- int
-tty_istrapsig()
-{
-#ifndef USE_TERMIO
- return(!(termbuf.sg.sg_flags&RAW));
-#else
- return(termbuf.c_lflag & ISIG);
-#endif
-}
-
- void
-tty_setedit(on)
- int on;
-{
-#ifndef USE_TERMIO
- if (on)
- termbuf.sg.sg_flags &= ~CBREAK;
- else
- termbuf.sg.sg_flags |= CBREAK;
-#else
- if (on)
- termbuf.c_lflag |= ICANON;
- else
- termbuf.c_lflag &= ~ICANON;
-#endif
-}
-
- void
-tty_setsig(on)
- int on;
-{
-#ifndef USE_TERMIO
- if (on)
- ;
-#else
- if (on)
- termbuf.c_lflag |= ISIG;
- else
- termbuf.c_lflag &= ~ISIG;
-#endif
-}
-#endif /* LINEMODE */
-
- int
-tty_issofttab()
-{
-#ifndef USE_TERMIO
- return (termbuf.sg.sg_flags & XTABS);
-#else
-# ifdef OXTABS
- return (termbuf.c_oflag & OXTABS);
-# endif
-# ifdef TABDLY
- return ((termbuf.c_oflag & TABDLY) == TAB3);
-# endif
-#endif
-}
-
- void
-tty_setsofttab(on)
- int on;
-{
-#ifndef USE_TERMIO
- if (on)
- termbuf.sg.sg_flags |= XTABS;
- else
- termbuf.sg.sg_flags &= ~XTABS;
-#else
- if (on) {
-# ifdef OXTABS
- termbuf.c_oflag |= OXTABS;
-# endif
-# ifdef TABDLY
- termbuf.c_oflag &= ~TABDLY;
- termbuf.c_oflag |= TAB3;
-# endif
- } else {
-# ifdef OXTABS
- termbuf.c_oflag &= ~OXTABS;
-# endif
-# ifdef TABDLY
- termbuf.c_oflag &= ~TABDLY;
- termbuf.c_oflag |= TAB0;
-# endif
- }
-#endif
-}
-
- int
-tty_islitecho()
-{
-#ifndef USE_TERMIO
- return (!(termbuf.lflags & LCTLECH));
-#else
-# ifdef ECHOCTL
- return (!(termbuf.c_lflag & ECHOCTL));
-# endif
-# ifdef TCTLECH
- return (!(termbuf.c_lflag & TCTLECH));
-# endif
-# if !defined(ECHOCTL) && !defined(TCTLECH)
- return (0); /* assumes ctl chars are echoed '^x' */
-# endif
-#endif
-}
-
- void
-tty_setlitecho(on)
- int on;
-{
-#ifndef USE_TERMIO
- if (on)
- termbuf.lflags &= ~LCTLECH;
- else
- termbuf.lflags |= LCTLECH;
-#else
-# ifdef ECHOCTL
- if (on)
- termbuf.c_lflag &= ~ECHOCTL;
- else
- termbuf.c_lflag |= ECHOCTL;
-# endif
-# ifdef TCTLECH
- if (on)
- termbuf.c_lflag &= ~TCTLECH;
- else
- termbuf.c_lflag |= TCTLECH;
-# endif
-#endif
-}
-
- int
-tty_iscrnl()
-{
-#ifndef USE_TERMIO
- return (termbuf.sg.sg_flags & CRMOD);
-#else
- return (termbuf.c_iflag & ICRNL);
-#endif
-}
-
-/*
- * Try to guess whether speeds are "encoded" (4.2BSD) or just numeric (4.4BSD).
- */
-#if B4800 != 4800
-#define DECODE_BAUD
-#endif
-
-#ifdef DECODE_BAUD
-
-/*
- * A table of available terminal speeds
- */
-struct termspeeds {
- int speed;
- int value;
-} termspeeds[] = {
- { 0, B0 }, { 50, B50 }, { 75, B75 },
- { 110, B110 }, { 134, B134 }, { 150, B150 },
- { 200, B200 }, { 300, B300 }, { 600, B600 },
- { 1200, B1200 }, { 1800, B1800 }, { 2400, B2400 },
- { 4800, B4800 },
-#ifdef B7200
- { 7200, B7200 },
-#endif
- { 9600, B9600 },
-#ifdef B14400
- { 14400, B14400 },
-#endif
-#ifdef B19200
- { 19200, B19200 },
-#endif
-#ifdef B28800
- { 28800, B28800 },
-#endif
-#ifdef B38400
- { 38400, B38400 },
-#endif
-#ifdef B57600
- { 57600, B57600 },
-#endif
-#ifdef B115200
- { 115200, B115200 },
-#endif
-#ifdef B230400
- { 230400, B230400 },
-#endif
- { -1, 0 }
-};
-#endif /* DECODE_BAUD */
-
- void
-tty_tspeed(val)
- int val;
-{
-#ifdef DECODE_BAUD
- register struct termspeeds *tp;
-
- for (tp = termspeeds; (tp->speed != -1) && (val > tp->speed); tp++)
- ;
- if (tp->speed == -1) /* back up to last valid value */
- --tp;
- cfsetospeed(&termbuf, tp->value);
-#else /* DECODE_BAUD */
- cfsetospeed(&termbuf, val);
-#endif /* DECODE_BAUD */
-}
-
- void
-tty_rspeed(val)
- int val;
-{
-#ifdef DECODE_BAUD
- register struct termspeeds *tp;
-
- for (tp = termspeeds; (tp->speed != -1) && (val > tp->speed); tp++)
- ;
- if (tp->speed == -1) /* back up to last valid value */
- --tp;
- cfsetispeed(&termbuf, tp->value);
-#else /* DECODE_BAUD */
- cfsetispeed(&termbuf, val);
-#endif /* DECODE_BAUD */
-}
-
-#if defined(CRAY2) && defined(UNICOS5)
- int
-tty_isnewmap()
-{
- return((termbuf.c_oflag & OPOST) && (termbuf.c_oflag & ONLCR) &&
- !(termbuf.c_oflag & ONLRET));
-}
-#endif
-
-#ifdef PARENT_DOES_UTMP
-# ifndef NEWINIT
-extern struct utmp wtmp;
-extern char wtmpf[];
-# else /* NEWINIT */
-int gotalarm;
-
- /* ARGSUSED */
- void
-nologinproc(sig)
- int sig;
-{
- gotalarm++;
-}
-# endif /* NEWINIT */
-#endif /* PARENT_DOES_UTMP */
-
-#ifndef NEWINIT
-# ifdef PARENT_DOES_UTMP
-extern void utmp_sig_init P((void));
-extern void utmp_sig_reset P((void));
-extern void utmp_sig_wait P((void));
-extern void utmp_sig_notify P((int));
-# endif /* PARENT_DOES_UTMP */
-#endif
-
-/*
- * getptyslave()
- *
- * Open the slave side of the pty, and do any initialization
- * that is necessary.
- */
- void
-getptyslave()
-{
- register int t = -1;
- char erase;
-
-#if !defined(CRAY) || !defined(NEWINIT)
-# ifdef LINEMODE
- int waslm;
-# endif
-# ifdef TIOCGWINSZ
- struct winsize ws;
- extern int def_row, def_col;
-# endif
- extern int def_tspeed, def_rspeed;
- /*
- * Opening the slave side may cause initilization of the
- * kernel tty structure. We need remember the state of
- * if linemode was turned on
- * terminal window size
- * terminal speed
- * erase character
- * so that we can re-set them if we need to.
- */
-# ifdef LINEMODE
- waslm = tty_linemode();
-# endif
- erase = termbuf.c_cc[VERASE];
-
- /*
- * Make sure that we don't have a controlling tty, and
- * that we are the session (process group) leader.
- */
-# ifdef TIOCNOTTY
- t = open(_PATH_TTY, O_RDWR);
- if (t >= 0) {
- (void) ioctl(t, TIOCNOTTY, (char *)0);
- (void) close(t);
- }
-# endif
-
-
-# ifdef PARENT_DOES_UTMP
- /*
- * Wait for our parent to get the utmp stuff to get done.
- */
- utmp_sig_wait();
-# endif
-
- t = cleanopen(line);
- if (t < 0)
- fatalperror(net, line);
-
-#ifdef STREAMSPTY
-#ifdef USE_TERMIO
- ttyfd = t;
-#endif
- if (ioctl(t, I_PUSH, "ptem") < 0)
- fatal(net, "I_PUSH ptem");
- if (ioctl(t, I_PUSH, "ldterm") < 0)
- fatal(net, "I_PUSH ldterm");
- if (ioctl(t, I_PUSH, "ttcompat") < 0)
- fatal(net, "I_PUSH ttcompat");
- if (ioctl(pty, I_PUSH, "pckt") < 0)
- fatal(net, "I_PUSH pckt");
-#endif
-
- /*
- * set up the tty modes as we like them to be.
- */
- init_termbuf();
-# ifdef TIOCGWINSZ
- if (def_row || def_col) {
- memset((char *)&ws, 0, sizeof(ws));
- ws.ws_col = def_col;
- ws.ws_row = def_row;
- (void)ioctl(t, TIOCSWINSZ, (char *)&ws);
- }
-# endif
-
- /*
- * Settings for sgtty based systems
- */
-# ifndef USE_TERMIO
- termbuf.sg.sg_flags |= CRMOD|ANYP|ECHO|XTABS;
-# endif /* USE_TERMIO */
-
- /*
- * Settings for UNICOS (and HPUX)
- */
-# if defined(CRAY) || defined(__hpux)
- termbuf.c_oflag = OPOST|ONLCR|TAB3;
- termbuf.c_iflag = IGNPAR|ISTRIP|ICRNL|IXON;
- termbuf.c_lflag = ISIG|ICANON|ECHO|ECHOE|ECHOK;
- termbuf.c_cflag = EXTB|HUPCL|CS8;
-# endif
-
- /*
- * Settings for all other termios/termio based
- * systems, other than 4.4BSD. In 4.4BSD the
- * kernel does the initial terminal setup.
- */
-# if defined(USE_TERMIO) && !(defined(CRAY) || defined(__hpux)) && (BSD <= 43)
-# ifndef OXTABS
-# define OXTABS 0
-# endif
- termbuf.c_lflag |= ECHO;
- termbuf.c_oflag |= ONLCR|OXTABS;
- termbuf.c_iflag |= ICRNL;
- termbuf.c_iflag &= ~IXOFF;
-# endif /* defined(USE_TERMIO) && !defined(CRAY) && (BSD <= 43) */
- tty_rspeed((def_rspeed > 0) ? def_rspeed : 9600);
- tty_tspeed((def_tspeed > 0) ? def_tspeed : 9600);
- if (erase)
- termbuf.c_cc[VERASE] = erase;
-# ifdef LINEMODE
- if (waslm)
- tty_setlinemode(1);
-# endif /* LINEMODE */
-
- /*
- * Set the tty modes, and make this our controlling tty.
- */
- set_termbuf();
- if (login_tty(t) == -1)
- fatalperror(net, "login_tty");
-#endif /* !defined(CRAY) || !defined(NEWINIT) */
- if (net > 2)
- (void) close(net);
-#if defined(AUTHENTICATION) && defined(NO_LOGIN_F) && defined(LOGIN_R)
- /*
- * Leave the pty open so that we can write out the rlogin
- * protocol for /bin/login, if the authentication works.
- */
-#else
- if (pty > 2) {
- (void) close(pty);
- pty = -1;
- }
-#endif
-}
-
-#if !defined(CRAY) || !defined(NEWINIT)
-#ifndef O_NOCTTY
-#define O_NOCTTY 0
-#endif
-/*
- * Open the specified slave side of the pty,
- * making sure that we have a clean tty.
- */
- int
-cleanopen(line)
- char *line;
-{
- register int t;
-#ifdef UNICOS7x
- struct secstat secbuf;
-#endif /* UNICOS7x */
-
-#ifndef STREAMSPTY
- /*
- * Make sure that other people can't open the
- * slave side of the connection.
- */
- (void) chown(line, 0, 0);
- (void) chmod(line, 0600);
-#endif
-
-# if !defined(CRAY) && (BSD > 43)
- (void) revoke(line);
-# endif
-#ifdef UNICOS7x
- if (secflag) {
- if (secstat(line, &secbuf) < 0)
- return(-1);
- if (setulvl(secbuf.st_slevel) < 0)
- return(-1);
- if (setucmp(secbuf.st_compart) < 0)
- return(-1);
- }
-#endif /* UNICOS7x */
-
- t = open(line, O_RDWR|O_NOCTTY);
-
-#ifdef UNICOS7x
- if (secflag) {
- if (setulvl(sysv.sy_minlvl) < 0)
- return(-1);
- if (setucmp(0) < 0)
- return(-1);
- }
-#endif /* UNICOS7x */
-
- if (t < 0)
- return(-1);
-
- /*
- * Hangup anybody else using this ttyp, then reopen it for
- * ourselves.
- */
-# if !(defined(CRAY) || defined(__hpux)) && (BSD <= 43) && !defined(STREAMSPTY)
- (void) signal(SIGHUP, SIG_IGN);
- vhangup();
- (void) signal(SIGHUP, SIG_DFL);
- t = open(line, O_RDWR|O_NOCTTY);
- if (t < 0)
- return(-1);
-# endif
-# if defined(CRAY) && defined(TCVHUP)
- {
- register int i;
- (void) signal(SIGHUP, SIG_IGN);
- (void) ioctl(t, TCVHUP, (char *)0);
- (void) signal(SIGHUP, SIG_DFL);
-
-#ifdef UNICOS7x
- if (secflag) {
- if (secstat(line, &secbuf) < 0)
- return(-1);
- if (setulvl(secbuf.st_slevel) < 0)
- return(-1);
- if (setucmp(secbuf.st_compart) < 0)
- return(-1);
- }
-#endif /* UNICOS7x */
-
- i = open(line, O_RDWR);
-
-#ifdef UNICOS7x
- if (secflag) {
- if (setulvl(sysv.sy_minlvl) < 0)
- return(-1);
- if (setucmp(0) < 0)
- return(-1);
- }
-#endif /* UNICOS7x */
-
- if (i < 0)
- return(-1);
- (void) close(t);
- t = i;
- }
-# endif /* defined(CRAY) && defined(TCVHUP) */
- return(t);
-}
-#endif /* !defined(CRAY) || !defined(NEWINIT) */
-
-#if BSD <= 43
-
- int
-login_tty(t)
- int t;
-{
- if (setsid() < 0) {
-#ifdef ultrix
- /*
- * The setsid() may have failed because we
- * already have a pgrp == pid. Zero out
- * our pgrp and try again...
- */
- if ((setpgrp(0, 0) < 0) || (setsid() < 0))
-#endif
- fatalperror(net, "setsid()");
- }
-# ifdef TIOCSCTTY
- if (ioctl(t, TIOCSCTTY, (char *)0) < 0)
- fatalperror(net, "ioctl(sctty)");
-# if defined(CRAY)
- /*
- * Close the hard fd to /dev/ttypXXX, and re-open through
- * the indirect /dev/tty interface.
- */
- close(t);
- if ((t = open("/dev/tty", O_RDWR)) < 0)
- fatalperror(net, "open(/dev/tty)");
-# endif
-# else
- /*
- * We get our controlling tty assigned as a side-effect
- * of opening up a tty device. But on BSD based systems,
- * this only happens if our process group is zero. The
- * setsid() call above may have set our pgrp, so clear
- * it out before opening the tty...
- */
-# ifndef SOLARIS
- (void) setpgrp(0, 0);
-# else
- (void) setpgrp();
-# endif
- close(open(line, O_RDWR));
-# endif
- if (t != 0)
- (void) dup2(t, 0);
- if (t != 1)
- (void) dup2(t, 1);
- if (t != 2)
- (void) dup2(t, 2);
- if (t > 2)
- close(t);
- return(0);
-}
-#endif /* BSD <= 43 */
-
-#ifdef NEWINIT
-char *gen_id = "fe";
-#endif
-
-/*
- * startslave(host)
- *
- * Given a hostname, do whatever
- * is necessary to startup the login process on the slave side of the pty.
- */
-
-/* ARGSUSED */
- void
-startslave(host, autologin, autoname)
- char *host;
- int autologin;
- char *autoname;
-{
- register int i;
-#ifdef NEWINIT
- extern char *ptyip;
- struct init_request request;
- void nologinproc();
- register int n;
-#endif /* NEWINIT */
-
-#if defined(AUTHENTICATION)
- if (!autoname || !autoname[0])
- autologin = 0;
-
- if (autologin < auth_level) {
- fatal(net, "Authorization failed");
- exit(1);
- }
-#endif
-
-#ifndef NEWINIT
-# ifdef PARENT_DOES_UTMP
- utmp_sig_init();
-# endif /* PARENT_DOES_UTMP */
-
- if ((i = fork()) < 0)
- fatalperror(net, "fork");
- if (i) {
-# ifdef PARENT_DOES_UTMP
- /*
- * Cray parent will create utmp entry for child and send
- * signal to child to tell when done. Child waits for signal
- * before doing anything important.
- */
- register int pid = i;
- void sigjob P((int));
-
- setpgrp();
- utmp_sig_reset(); /* reset handler to default */
- /*
- * Create utmp entry for child
- */
- (void) time(&wtmp.ut_time);
- wtmp.ut_type = LOGIN_PROCESS;
- wtmp.ut_pid = pid;
- SCPYN(wtmp.ut_user, "LOGIN");
- SCPYN(wtmp.ut_host, host);
- SCPYN(wtmp.ut_line, line + sizeof("/dev/") - 1);
-#ifndef __hpux
- SCPYN(wtmp.ut_id, wtmp.ut_line+3);
-#else
- SCPYN(wtmp.ut_id, wtmp.ut_line+7);
-#endif
- pututline(&wtmp);
- endutent();
- if ((i = open(wtmpf, O_WRONLY|O_APPEND)) >= 0) {
- (void) write(i, (char *)&wtmp, sizeof(struct utmp));
- (void) close(i);
- }
-#ifdef CRAY
- (void) signal(WJSIGNAL, sigjob);
-#endif
- utmp_sig_notify(pid);
-# endif /* PARENT_DOES_UTMP */
- } else {
- getptyslave(autologin);
- start_login(host, autologin, autoname);
- /*NOTREACHED*/
- }
-#else /* NEWINIT */
-
- /*
- * Init will start up login process if we ask nicely. We only wait
- * for it to start up and begin normal telnet operation.
- */
- if ((i = open(INIT_FIFO, O_WRONLY)) < 0) {
- char tbuf[128];
- (void) snprintf(tbuf, sizeof(tbuf), "Can't open %s\n", INIT_FIFO);
- fatalperror(net, tbuf);
- }
- memset((char *)&request, 0, sizeof(request));
- request.magic = INIT_MAGIC;
- SCPYN(request.gen_id, gen_id);
- SCPYN(request.tty_id, &line[8]);
- SCPYN(request.host, host);
- SCPYN(request.term_type, terminaltype ? terminaltype : "network");
-#if !defined(UNICOS5)
- request.signal = SIGCLD;
- request.pid = getpid();
-#endif
-#ifdef BFTPDAEMON
- /*
- * Are we working as the bftp daemon?
- */
- if (bftpd) {
- SCPYN(request.exec_name, BFTPPATH);
- }
-#endif /* BFTPDAEMON */
- if (write(i, (char *)&request, sizeof(request)) < 0) {
- char tbuf[128];
- (void) snprintf(tbuf, sizeof(tbuf), "Can't write to %s\n", INIT_FIFO);
- fatalperror(net, tbuf);
- }
- (void) close(i);
- (void) signal(SIGALRM, nologinproc);
- for (i = 0; ; i++) {
- char tbuf[128];
- alarm(15);
- n = read(pty, ptyip, BUFSIZ);
- if (i == 3 || n >= 0 || !gotalarm)
- break;
- gotalarm = 0;
- snprintf(tbuf, sizeof(tbuf), "telnetd: waiting for /etc/init to start login process on %s\r\n", line);
- (void) write(net, tbuf, strlen(tbuf));
- }
- if (n < 0 && gotalarm)
- fatal(net, "/etc/init didn't start login process");
- pcc += n;
- alarm(0);
- (void) signal(SIGALRM, SIG_DFL);
-
- return;
-#endif /* NEWINIT */
-}
-
-char *envinit[3];
-extern char **environ;
-
- void
-init_env()
-{
- extern char *getenv();
- char **envp;
-
- envp = envinit;
- if ((*envp = getenv("TZ")))
- *envp++ -= 3;
-#if defined(CRAY) || defined(__hpux)
- else
- *envp++ = "TZ=GMT0";
-#endif
- *envp = 0;
- environ = envinit;
-}
-
-#ifndef NEWINIT
-
-/*
- * start_login(host)
- *
- * Assuming that we are now running as a child processes, this
- * function will turn us into the login process.
- */
-
- void
-start_login(host, autologin, name)
- char *host;
- int autologin;
- char *name;
-{
- register char **argv;
- char **addarg(), *user;
- extern char *getenv();
-#ifdef UTMPX
- register int pid = getpid();
- struct utmpx utmpx;
-#endif
-#ifdef SOLARIS
- char *term;
- char termbuf[64];
-#endif
-
-#ifdef UTMPX
- /*
- * Create utmp entry for child
- */
-
- memset(&utmpx, 0, sizeof(utmpx));
- SCPYN(utmpx.ut_user, ".telnet");
- SCPYN(utmpx.ut_line, line + sizeof("/dev/") - 1);
- utmpx.ut_pid = pid;
- utmpx.ut_id[0] = 't';
- utmpx.ut_id[1] = 'n';
- utmpx.ut_id[2] = SC_WILDC;
- utmpx.ut_id[3] = SC_WILDC;
- utmpx.ut_type = LOGIN_PROCESS;
- (void) time(&utmpx.ut_tv.tv_sec);
- if (makeutx(&utmpx) == NULL)
- fatal(net, "makeutx failed");
-#endif
-
- scrub_env();
-
- /*
- * -h : pass on name of host.
- * WARNING: -h is accepted by login if and only if
- * getuid() == 0.
- * -p : don't clobber the environment (so terminal type stays set).
- *
- * -f : force this login, he has already been authenticated
- */
- argv = addarg(0, "login");
-
-#if !defined(NO_LOGIN_H)
-
-# if defined (AUTHENTICATION) && defined(NO_LOGIN_F) && defined(LOGIN_R)
- /*
- * Don't add the "-h host" option if we are going
- * to be adding the "-r host" option down below...
- */
- if ((auth_level < 0) || (autologin != AUTH_VALID))
-# endif
- {
- argv = addarg(argv, "-h");
- argv = addarg(argv, host);
-#ifdef SOLARIS
- /*
- * SVR4 version of -h takes TERM= as second arg, or -
- */
- term = getenv("TERM");
- if (term == NULL || term[0] == 0) {
- term = "-";
- } else {
- strcpy(termbuf, "TERM=");
- strncat(termbuf, term, sizeof(termbuf) - 6);
- term = termbuf;
- }
- argv = addarg(argv, term);
-#endif
- }
-#endif
-#if !defined(NO_LOGIN_P)
- argv = addarg(argv, "-p");
-#endif
-#ifdef LINEMODE
- /*
- * Set the environment variable "LINEMODE" to either
- * "real" or "kludge" if we are operating in either
- * real or kludge linemode.
- */
- if (lmodetype == REAL_LINEMODE)
- setenv("LINEMODE", "real", 1);
-# ifdef KLUDGELINEMODE
- else if (lmodetype == KLUDGE_LINEMODE || lmodetype == KLUDGE_OK)
- setenv("LINEMODE", "kludge", 1);
-# endif
-#endif
-#ifdef BFTPDAEMON
- /*
- * Are we working as the bftp daemon? If so, then ask login
- * to start bftp instead of shell.
- */
- if (bftpd) {
- argv = addarg(argv, "-e");
- argv = addarg(argv, BFTPPATH);
- } else
-#endif
-#if defined (SecurID)
- /*
- * don't worry about the -f that might get sent.
- * A -s is supposed to override it anyhow.
- */
- if (require_SecurID)
- argv = addarg(argv, "-s");
-#endif
-#if defined (AUTHENTICATION)
- if (auth_level >= 0 && autologin == AUTH_VALID) {
-# if !defined(NO_LOGIN_F)
- argv = addarg(argv, "-f");
- argv = addarg(argv, "--");
- argv = addarg(argv, name);
-# else
-# if defined(LOGIN_R)
- /*
- * We don't have support for "login -f", but we
- * can fool /bin/login into thinking that we are
- * rlogind, and allow us to log in without a
- * password. The rlogin protocol expects
- * local-user\0remote-user\0term/speed\0
- */
-
- if (pty > 2) {
- register char *cp;
- char speed[128];
- int isecho, israw, xpty, len;
- extern int def_rspeed;
-# ifndef LOGIN_HOST
- /*
- * Tell login that we are coming from "localhost".
- * If we passed in the real host name, then the
- * user would have to allow .rhost access from
- * every machine that they want authenticated
- * access to work from, which sort of defeats
- * the purpose of an authenticated login...
- * So, we tell login that the session is coming
- * from "localhost", and the user will only have
- * to have "localhost" in their .rhost file.
- */
-# define LOGIN_HOST "localhost"
-# endif
- argv = addarg(argv, "-r");
- argv = addarg(argv, LOGIN_HOST);
-
- xpty = pty;
-# ifndef STREAMSPTY
- pty = 0;
-# else
- ttyfd = 0;
-# endif
- init_termbuf();
- isecho = tty_isecho();
- israw = tty_israw();
- if (isecho || !israw) {
- tty_setecho(0); /* Turn off echo */
- tty_setraw(1); /* Turn on raw */
- set_termbuf();
- }
- len = strlen(name)+1;
- write(xpty, name, len);
- write(xpty, name, len);
- snprintf(speed, sizeof(speed),
- "%s/%d", (cp = getenv("TERM")) ? cp : "",
- (def_rspeed > 0) ? def_rspeed : 9600);
- len = strlen(speed)+1;
- write(xpty, speed, len);
-
- if (isecho || !israw) {
- init_termbuf();
- tty_setecho(isecho);
- tty_setraw(israw);
- set_termbuf();
- if (!israw) {
- /*
- * Write a newline to ensure
- * that login will be able to
- * read the line...
- */
- write(xpty, "\n", 1);
- }
- }
- pty = xpty;
- }
-# else
- argv = addarg(argv, "--");
- argv = addarg(argv, name);
-# endif
-# endif
- } else
-#endif
- if (getenv("USER")) {
- argv = addarg(argv, "--");
- argv = addarg(argv, getenv("USER"));
-#if defined(LOGIN_ARGS) && defined(NO_LOGIN_P)
- {
- register char **cpp;
- for (cpp = environ; *cpp; cpp++)
- argv = addarg(argv, *cpp);
- }
-#endif
- /*
- * Assume that login will set the USER variable
- * correctly. For SysV systems, this means that
- * USER will no longer be set, just LOGNAME by
- * login. (The problem is that if the auto-login
- * fails, and the user then specifies a different
- * account name, he can get logged in with both
- * LOGNAME and USER in his environment, but the
- * USER value will be wrong.
- */
- unsetenv("USER");
- }
-#ifdef SOLARIS
- else {
- char **p;
-
- argv = addarg(argv, ""); /* no login name */
- for (p = environ; *p; p++) {
- argv = addarg(argv, *p);
- }
- }
-#endif /* SOLARIS */
-#if defined(AUTHENTICATION) && defined(NO_LOGIN_F) && defined(LOGIN_R)
- if (pty > 2)
- close(pty);
-#endif
- closelog();
-
- if (altlogin == NULL) {
- altlogin = _PATH_LOGIN;
- }
- execv(altlogin, argv);
-
- syslog(LOG_ERR, "%s: %m", altlogin);
- fatalperror(net, altlogin);
- /*NOTREACHED*/
-}
-
- char **
-addarg(argv, val)
- register char **argv;
- register char *val;
-{
- register char **cpp;
-
- if (argv == NULL) {
- /*
- * 10 entries, a leading length, and a null
- */
- argv = (char **)malloc(sizeof(*argv) * 12);
- if (argv == NULL)
- return(NULL);
- *argv++ = (char *)10;
- *argv = (char *)0;
- }
- for (cpp = argv; *cpp; cpp++)
- ;
- if (cpp == &argv[(int)argv[-1]]) {
- --argv;
- *argv = (char *)((int)(*argv) + 10);
- argv = (char **)realloc(argv, sizeof(*argv)*((int)(*argv) + 2));
- if (argv == NULL)
- return(NULL);
- argv++;
- cpp = &argv[(int)argv[-1] - 10];
- }
- *cpp++ = val;
- *cpp = 0;
- return(argv);
-}
-#endif /* NEWINIT */
-
-/*
- * scrub_env()
- *
- * Remove a few things from the environment that
- * don't need to be there.
- */
- void
-scrub_env()
-{
- register char **cpp, **cpp2;
-
- for (cpp2 = cpp = environ; *cpp; cpp++) {
-#ifdef __FreeBSD__
- if (strncmp(*cpp, "LD_LIBRARY_PATH=", 16) &&
- strncmp(*cpp, "LD_PRELOAD=", 11) &&
-#else
- if (strncmp(*cpp, "LD_", 3) &&
- strncmp(*cpp, "_RLD_", 5) &&
- strncmp(*cpp, "LIBPATH=", 8) &&
-#endif
- strncmp(*cpp, "IFS=", 4))
- *cpp2++ = *cpp;
- }
- *cpp2 = 0;
-}
-
-/*
- * cleanup()
- *
- * This is the routine to call when we are all through, to
- * clean up anything that needs to be cleaned up.
- */
- /* ARGSUSED */
- void
-cleanup(sig)
- int sig;
-{
-#ifndef PARENT_DOES_UTMP
-# if (BSD > 43) || defined(convex)
- char *p;
-
- p = line + sizeof("/dev/") - 1;
- if (logout(p))
- logwtmp(p, "", "");
- (void)chmod(line, 0666);
- (void)chown(line, 0, 0);
- *p = 'p';
- (void)chmod(line, 0666);
- (void)chown(line, 0, 0);
- (void) shutdown(net, 2);
- exit(1);
-# else
- void rmut();
-
- rmut();
- vhangup(); /* XXX */
- (void) shutdown(net, 2);
- exit(1);
-# endif
-#else /* PARENT_DOES_UTMP */
-# ifdef NEWINIT
- (void) shutdown(net, 2);
- exit(1);
-# else /* NEWINIT */
-# ifdef CRAY
- static int incleanup = 0;
- register int t;
- int child_status; /* status of child process as returned by waitpid */
- int flags = WNOHANG|WUNTRACED;
-
- /*
- * 1: Pick up the zombie, if we are being called
- * as the signal handler.
- * 2: If we are a nested cleanup(), return.
- * 3: Try to clean up TMPDIR.
- * 4: Fill in utmp with shutdown of process.
- * 5: Close down the network and pty connections.
- * 6: Finish up the TMPDIR cleanup, if needed.
- */
- if (sig == SIGCHLD) {
- while (waitpid(-1, &child_status, flags) > 0)
- ; /* VOID */
- /* Check if the child process was stopped
- * rather than exited. We want cleanup only if
- * the child has died.
- */
- if (WIFSTOPPED(child_status)) {
- return;
- }
- }
- t = sigblock(sigmask(SIGCHLD));
- if (incleanup) {
- sigsetmask(t);
- return;
- }
- incleanup = 1;
- sigsetmask(t);
-#ifdef UNICOS7x
- if (secflag) {
- /*
- * We need to set ourselves back to a null
- * label to clean up.
- */
-
- setulvl(sysv.sy_minlvl);
- setucmp((long)0);
- }
-#endif /* UNICOS7x */
-
- t = cleantmp(&wtmp);
- setutent(); /* just to make sure */
-# endif /* CRAY */
- rmut(line);
- close(pty);
- (void) shutdown(net, 2);
-# ifdef CRAY
- if (t == 0)
- cleantmp(&wtmp);
-# endif /* CRAY */
- exit(1);
-# endif /* NEWINT */
-#endif /* PARENT_DOES_UTMP */
-}
-
-#if defined(PARENT_DOES_UTMP) && !defined(NEWINIT)
-/*
- * _utmp_sig_rcv
- * utmp_sig_init
- * utmp_sig_wait
- * These three functions are used to coordinate the handling of
- * the utmp file between the server and the soon-to-be-login shell.
- * The server actually creates the utmp structure, the child calls
- * utmp_sig_wait(), until the server calls utmp_sig_notify() and
- * signals the future-login shell to proceed.
- */
-static int caught=0; /* NZ when signal intercepted */
-static void (*func)(); /* address of previous handler */
-
- void
-_utmp_sig_rcv(sig)
- int sig;
-{
- caught = 1;
- (void) signal(SIGUSR1, func);
-}
-
- void
-utmp_sig_init()
-{
- /*
- * register signal handler for UTMP creation
- */
- if ((int)(func = signal(SIGUSR1, _utmp_sig_rcv)) == -1)
- fatalperror(net, "telnetd/signal");
-}
-
- void
-utmp_sig_reset()
-{
- (void) signal(SIGUSR1, func); /* reset handler to default */
-}
-
-# ifdef __hpux
-# define sigoff() /* do nothing */
-# define sigon() /* do nothing */
-# endif
-
- void
-utmp_sig_wait()
-{
- /*
- * Wait for parent to write our utmp entry.
- */
- sigoff();
- while (caught == 0) {
- pause(); /* wait until we get a signal (sigon) */
- sigoff(); /* turn off signals while we check caught */
- }
- sigon(); /* turn on signals again */
-}
-
- void
-utmp_sig_notify(pid)
-{
- kill(pid, SIGUSR1);
-}
-
-# ifdef CRAY
-static int gotsigjob = 0;
-
- /*ARGSUSED*/
- void
-sigjob(sig)
- int sig;
-{
- register int jid;
- register struct jobtemp *jp;
-
- while ((jid = waitjob(NULL)) != -1) {
- if (jid == 0) {
- return;
- }
- gotsigjob++;
- jobend(jid, NULL, NULL);
- }
-}
-
-/*
- * jid_getutid:
- * called by jobend() before calling cleantmp()
- * to find the correct $TMPDIR to cleanup.
- */
-
- struct utmp *
-jid_getutid(jid)
- int jid;
-{
- struct utmp *cur = NULL;
-
- setutent(); /* just to make sure */
- while (cur = getutent()) {
- if ( (cur->ut_type != NULL) && (jid == cur->ut_jid) ) {
- return(cur);
- }
- }
-
- return(0);
-}
-
-/*
- * Clean up the TMPDIR that login created.
- * The first time this is called we pick up the info
- * from the utmp. If the job has already gone away,
- * then we'll clean up and be done. If not, then
- * when this is called the second time it will wait
- * for the signal that the job is done.
- */
- int
-cleantmp(wtp)
- register struct utmp *wtp;
-{
- struct utmp *utp;
- static int first = 1;
- register int mask, omask, ret;
- extern struct utmp *getutid P((const struct utmp *_Id));
-
-
- mask = sigmask(WJSIGNAL);
-
- if (first == 0) {
- omask = sigblock(mask);
- while (gotsigjob == 0)
- sigpause(omask);
- return(1);
- }
- first = 0;
- setutent(); /* just to make sure */
-
- utp = getutid(wtp);
- if (utp == 0) {
- syslog(LOG_ERR, "can't get /etc/utmp entry to clean TMPDIR");
- return(-1);
- }
- /*
- * Nothing to clean up if the user shell was never started.
- */
- if (utp->ut_type != USER_PROCESS || utp->ut_jid == 0)
- return(1);
-
- /*
- * Block the WJSIGNAL while we are in jobend().
- */
- omask = sigblock(mask);
- ret = jobend(utp->ut_jid, utp->ut_tpath, utp->ut_user);
- sigsetmask(omask);
- return(ret);
-}
-
- int
-jobend(jid, path, user)
- register int jid;
- register char *path;
- register char *user;
-{
- static int saved_jid = 0;
- static int pty_saved_jid = 0;
- static char saved_path[sizeof(wtmp.ut_tpath)+1];
- static char saved_user[sizeof(wtmp.ut_user)+1];
-
- /*
- * this little piece of code comes into play
- * only when ptyreconnect is used to reconnect
- * to an previous session.
- *
- * this is the only time when the
- * "saved_jid != jid" code is executed.
- */
-
- if ( saved_jid && saved_jid != jid ) {
- if (!path) { /* called from signal handler */
- pty_saved_jid = jid;
- } else {
- pty_saved_jid = saved_jid;
- }
- }
-
- if (path) {
- strncpy(saved_path, path, sizeof(wtmp.ut_tpath));
- strncpy(saved_user, user, sizeof(wtmp.ut_user));
- saved_path[sizeof(saved_path)] = '\0';
- saved_user[sizeof(saved_user)] = '\0';
- }
- if (saved_jid == 0) {
- saved_jid = jid;
- return(0);
- }
-
- /* if the jid has changed, get the correct entry from the utmp file */
-
- if ( saved_jid != jid ) {
- struct utmp *utp = NULL;
- struct utmp *jid_getutid();
-
- utp = jid_getutid(pty_saved_jid);
-
- if (utp == 0) {
- syslog(LOG_ERR, "Can't get /etc/utmp entry to clean TMPDIR");
- return(-1);
- }
-
- cleantmpdir(jid, utp->ut_tpath, utp->ut_user);
- return(1);
- }
-
- cleantmpdir(jid, saved_path, saved_user);
- return(1);
-}
-
-/*
- * Fork a child process to clean up the TMPDIR
- */
-cleantmpdir(jid, tpath, user)
- register int jid;
- register char *tpath;
- register char *user;
-{
- switch(fork()) {
- case -1:
- syslog(LOG_ERR, "TMPDIR cleanup(%s): fork() failed: %m",
- tpath);
- break;
- case 0:
- execl(CLEANTMPCMD, CLEANTMPCMD, user, tpath, 0);
- syslog(LOG_ERR, "TMPDIR cleanup(%s): execl(%s) failed: %m",
- tpath, CLEANTMPCMD);
- exit(1);
- default:
- /*
- * Forget about child. We will exit, and
- * /etc/init will pick it up.
- */
- break;
- }
-}
-# endif /* CRAY */
-#endif /* defined(PARENT_DOES_UTMP) && !defined(NEWINIT) */
-
-/*
- * rmut()
- *
- * This is the function called by cleanup() to
- * remove the utmp entry for this person.
- */
-
-#ifdef UTMPX
- void
-rmut()
-{
- register f;
- int found = 0;
- struct utmp *u, *utmp;
- int nutmp;
- struct stat statbf;
-
- struct utmpx *utxp, utmpx;
-
- /*
- * This updates the utmpx and utmp entries and make a wtmp/x entry
- */
-
- SCPYN(utmpx.ut_line, line + sizeof("/dev/") - 1);
- utxp = getutxline(&utmpx);
- if (utxp) {
- utxp->ut_type = DEAD_PROCESS;
- utxp->ut_exit.e_termination = 0;
- utxp->ut_exit.e_exit = 0;
- (void) time(&utmpx.ut_tv.tv_sec);
- utmpx.ut_tv.tv_usec = 0;
- modutx(utxp);
- }
- endutxent();
-} /* end of rmut */
-#endif
-
-#if !defined(UTMPX) && !(defined(CRAY) || defined(__hpux)) && BSD <= 43
- void
-rmut()
-{
- register f;
- int found = 0;
- struct utmp *u, *utmp;
- int nutmp;
- struct stat statbf;
-
- f = open(utmpf, O_RDWR);
- if (f >= 0) {
- (void) fstat(f, &statbf);
- utmp = (struct utmp *)malloc((unsigned)statbf.st_size);
- if (!utmp)
- syslog(LOG_ERR, "utmp malloc failed");
- if (statbf.st_size && utmp) {
- nutmp = read(f, (char *)utmp, (int)statbf.st_size);
- nutmp /= sizeof(struct utmp);
-
- for (u = utmp ; u < &utmp[nutmp] ; u++) {
- if (SCMPN(u->ut_line, line+5) ||
- u->ut_name[0]==0)
- continue;
- (void) lseek(f, ((long)u)-((long)utmp), L_SET);
- SCPYN(u->ut_name, "");
- SCPYN(u->ut_host, "");
- (void) time(&u->ut_time);
- (void) write(f, (char *)u, sizeof(wtmp));
- found++;
- }
- }
- (void) close(f);
- }
- if (found) {
- f = open(wtmpf, O_WRONLY|O_APPEND);
- if (f >= 0) {
- SCPYN(wtmp.ut_line, line+5);
- SCPYN(wtmp.ut_name, "");
- SCPYN(wtmp.ut_host, "");
- (void) time(&wtmp.ut_time);
- (void) write(f, (char *)&wtmp, sizeof(wtmp));
- (void) close(f);
- }
- }
- (void) chmod(line, 0666);
- (void) chown(line, 0, 0);
- line[strlen("/dev/")] = 'p';
- (void) chmod(line, 0666);
- (void) chown(line, 0, 0);
-} /* end of rmut */
-#endif /* CRAY */
-
-#ifdef __hpux
-rmut (line)
-char *line;
-{
- struct utmp utmp;
- struct utmp *utptr;
- int fd; /* for /etc/wtmp */
-
- utmp.ut_type = USER_PROCESS;
- (void) strncpy(utmp.ut_id, line+12, sizeof(utmp.ut_id));
- (void) setutent();
- utptr = getutid(&utmp);
- /* write it out only if it exists */
- if (utptr) {
- utptr->ut_type = DEAD_PROCESS;
- utptr->ut_time = time((long *) 0);
- (void) pututline(utptr);
- /* set wtmp entry if wtmp file exists */
- if ((fd = open(wtmpf, O_WRONLY | O_APPEND)) >= 0) {
- (void) write(fd, utptr, sizeof(utmp));
- (void) close(fd);
- }
- }
- (void) endutent();
-
- (void) chmod(line, 0666);
- (void) chown(line, 0, 0);
- line[14] = line[13];
- line[13] = line[12];
- line[8] = 'm';
- line[9] = '/';
- line[10] = 'p';
- line[11] = 't';
- line[12] = 'y';
- (void) chmod(line, 0666);
- (void) chown(line, 0, 0);
-}
-#endif
diff --git a/contrib/telnet/telnetd/telnetd.8 b/contrib/telnet/telnetd/telnetd.8
deleted file mode 100644
index 5835c7dba7f5..000000000000
--- a/contrib/telnet/telnetd/telnetd.8
+++ /dev/null
@@ -1,615 +0,0 @@
-.\" Copyright (c) 1983, 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. 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, Berkeley and its contributors.
-.\" 4. 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.
-.\"
-.\" @(#)telnetd.8 8.4 (Berkeley) 6/1/94
-.\" $FreeBSD$
-.\"
-.Dd January 27, 2000
-.Dt TELNETD 8
-.Os BSD 4.2
-.Sh NAME
-.Nm telnetd
-.Nd DARPA
-.Tn TELNET
-protocol server
-.Sh SYNOPSIS
-.Nm /usr/libexec/telnetd
-.Op Fl BUhlkns
-.Op Fl D Ar debugmode
-.Op Fl I Ns Ar initid
-.Op Fl S Ar tos
-.Op Fl X Ar authtype
-.Op Fl a Ar authmode
-.Op Fl edebug
-.Op Fl p Ar loginprog
-.Op Fl r Ns Ar lowpty-highpty
-.Op Fl u Ar len
-.Op Fl debug Op Ar port
-.Sh DESCRIPTION
-The
-.Nm
-command is a server which supports the
-.Tn DARPA
-standard
-.Tn TELNET
-virtual terminal protocol.
-.Nm Telnetd
-is normally invoked by the internet server (see
-.Xr inetd 8 )
-for requests to connect to the
-.Tn TELNET
-port as indicated by the
-.Pa /etc/services
-file (see
-.Xr services 5 ).
-The
-.Fl debug
-option may be used to start up
-.Nm
-manually, instead of through
-.Xr inetd 8 .
-If started up this way,
-.Ar port
-may be specified to run
-.Nm
-on an alternate
-.Tn TCP
-port number.
-.Pp
-The
-.Nm
-command accepts the following options:
-.Bl -tag -width indent
-.It Fl a Ar authmode
-This option may be used for specifying what mode should
-be used for authentication.
-Note that this option is only useful if
-.Nm
-has been compiled with support for the
-.Dv AUTHENTICATION
-option.
-There are several valid values for
-.Ar authmode :
-.Bl -tag -width debug
-.It Cm debug
-Turn on authentication debugging code.
-.It Cm user
-Only allow connections when the remote user
-can provide valid authentication information
-to identify the remote user,
-and is allowed access to the specified account
-without providing a password.
-.It Cm valid
-Only allow connections when the remote user
-can provide valid authentication information
-to identify the remote user.
-The
-.Xr login 1
-command will provide any additional user verification
-needed if the remote user is not allowed automatic
-access to the specified account.
-.It Cm other
-Only allow connections that supply some authentication information.
-This option is currently not supported
-by any of the existing authentication mechanisms,
-and is thus the same as specifying
-.Fl a
-.Cm valid .
-.It Cm none
-This is the default state.
-Authentication information is not required.
-If no or insufficient authentication information
-is provided, then the
-.Xr login 1
-program will provide the necessary user
-verification.
-.It Cm off
-Disable the authentication code.
-All user verification will happen through the
-.Xr login 1
-program.
-.El
-.It Fl B
-Specify bftp server mode. In this mode,
-.Nm
-causes login to start a
-.Xr bftp 1
-session rather than the user's
-normal shell. In bftp daemon mode normal
-logins are not supported, and it must be used
-on a port other than the normal
-.Tn TELNET
-port.
-.It Fl D Ar debugmode
-This option may be used for debugging purposes.
-This allows
-.Nm
-to print out debugging information
-to the connection, allowing the user to see what
-.Nm
-is doing.
-There are several possible values for
-.Ar debugmode :
-.Bl -tag -width exercise
-.It Cm options
-Print information about the negotiation of
-.Tn TELNET
-options.
-.It Cm report
-Print the
-.Cm options
-information, plus some additional information
-about what processing is going on.
-.It Cm netdata
-Display the data stream received by
-.Nm Ns .
-.It Cm ptydata
-Display data written to the pty.
-.It Cm exercise
-Has not been implemented yet.
-.El
-.It Fl debug
-Enable debugging on each socket created by
-.Nm
-(see
-.Dv SO_DEBUG
-in
-.Xr socket 2 ) .
-.It Fl edebug
-If
-.Nm
-has been compiled with support for data encryption, then the
-.Fl edebug
-option may be used to enable encryption debugging code.
-.It Fl p Ar loginprog
-Specify an alternate
-.Xr login 1
-command to run to complete the login. The alternate command must
-understand the same command arguments as the standard login.
-.It Fl h
-Disable the printing of host-specific information before
-login has been completed.
-.It Fl I Ar initid
-This option is only applicable to
-.Tn UNICOS
-systems prior to 7.0.
-It specifies the
-.Dv ID
-from
-.Pa /etc/inittab
-to use when init starts login sessions. The default
-.Dv ID
-is
-.Dv fe.
-.It Fl k
-This option is only useful if
-.Nm
-has been compiled with both linemode and kludge linemode
-support. If the
-.Fl k
-option is specified, then if the remote client does not
-support the
-.Dv LINEMODE
-option, then
-.Nm
-will operate in character at a time mode.
-It will still support kludge linemode, but will only
-go into kludge linemode if the remote client requests
-it.
-(This is done by the client sending
-.Dv DONT SUPPRESS-GO-AHEAD
-and
-.Dv DONT ECHO . )
-The
-.Fl k
-option is most useful when there are remote clients
-that do not support kludge linemode, but pass the heuristic
-(if they respond with
-.Dv WILL TIMING-MARK
-in response to a
-.Dv DO TIMING-MARK)
-for kludge linemode support.
-.It Fl l
-Specify line mode. Try to force clients to use line-
-at-a-time mode.
-If the
-.Dv LINEMODE
-option is not supported, it will go
-into kludge linemode.
-.It Fl n
-Disable
-.Dv TCP
-keep-alives. Normally
-.Nm
-enables the
-.Tn TCP
-keep-alive mechanism to probe connections that
-have been idle for some period of time to determine
-if the client is still there, so that idle connections
-from machines that have crashed or can no longer
-be reached may be cleaned up.
-.It Fl r Ar lowpty-highpty
-This option is only enabled when
-.Nm
-is compiled for
-.Dv UNICOS.
-It specifies an inclusive range of pseudo-terminal devices to
-use. If the system has sysconf variable
-.Dv _SC_CRAY_NPTY
-configured, the default pty search range is 0 to
-.Dv _SC_CRAY_NPTY;
-otherwise, the default range is 0 to 128. Either
-.Ar lowpty
-or
-.Ar highpty
-may be omitted to allow changing
-either end of the search range. If
-.Ar lowpty
-is omitted, the - character is still required so that
-.Nm
-can differentiate
-.Ar highpty
-from
-.Ar lowpty .
-.It Fl s
-This option is only enabled if
-.Nm
-is compiled with support for
-.Tn SecurID
-cards.
-It causes the
-.Fl s
-option to be passed on to
-.Xr login 1 ,
-and thus is only useful if
-.Xr login 1
-supports the
-.Fl s
-flag to indicate that only
-.Tn SecurID
-validated logins are allowed, and is
-usually useful for controlling remote logins
-from outside of a firewall.
-.It Fl S Ar tos
-.It Fl u Ar len
-This option is used to specify the size of the field
-in the
-.Dv utmp
-structure that holds the remote host name.
-If the resolved host name is longer than
-.Ar len ,
-the dotted decimal value will be used instead.
-This allows hosts with very long host names that
-overflow this field to still be uniquely identified.
-Specifying
-.Fl u0
-indicates that only dotted decimal addresses
-should be put into the
-.Pa utmp
-file.
-.ne 1i
-.It Fl U
-This option causes
-.Nm
-to refuse connections from addresses that
-cannot be mapped back into a symbolic name
-via the
-.Xr gethostbyaddr 3
-routine.
-.It Fl X Ar authtype
-This option is only valid if
-.Nm
-has been built with support for the authentication option.
-It disables the use of
-.Ar authtype
-authentication, and
-can be used to temporarily disable
-a specific authentication type without having to recompile
-.Nm Ns .
-.El
-.Pp
-.Nm Telnetd
-operates by allocating a pseudo-terminal device (see
-.Xr pty 4 )
-for a client, then creating a login process which has
-the slave side of the pseudo-terminal as
-.Dv stdin ,
-.Dv stdout
-and
-.Dv stderr .
-.Nm Telnetd
-manipulates the master side of the pseudo-terminal,
-implementing the
-.Tn TELNET
-protocol and passing characters
-between the remote client and the login process.
-.Pp
-When a
-.Tn TELNET
-session is started up,
-.Nm
-sends
-.Tn TELNET
-options to the client side indicating
-a willingness to do the
-following
-.Tn TELNET
-options, which are described in more detail below:
-.Bd -literal -offset indent
-DO AUTHENTICATION
-WILL ENCRYPT
-DO TERMINAL TYPE
-DO TSPEED
-DO XDISPLOC
-DO NEW-ENVIRON
-DO ENVIRON
-WILL SUPPRESS GO AHEAD
-DO ECHO
-DO LINEMODE
-DO NAWS
-WILL STATUS
-DO LFLOW
-DO TIMING-MARK
-.Ed
-.Pp
-The pseudo-terminal allocated to the client is configured
-to operate in \*(lqcooked\*(rq mode, and with
-.Dv XTABS and
-.Dv CRMOD
-enabled (see
-.Xr tty 4 ) .
-.Pp
-.Nm Telnetd
-has support for enabling locally the following
-.Tn TELNET
-options:
-.Bl -tag -width "DO AUTHENTICATION"
-.It "WILL ECHO"
-When the
-.Dv LINEMODE
-option is enabled, a
-.Dv WILL ECHO
-or
-.Dv WONT ECHO
-will be sent to the client to indicate the
-current state of terminal echoing.
-When terminal echo is not desired, a
-.Dv WILL ECHO
-is sent to indicate that
-.Nm
-will take care of echoing any data that needs to be
-echoed to the terminal, and then nothing is echoed.
-When terminal echo is desired, a
-.Dv WONT ECHO
-is sent to indicate that
-.Nm
-will not be doing any terminal echoing, so the
-client should do any terminal echoing that is needed.
-.It "WILL BINARY"
-Indicate that the client is willing to send a
-8 bits of data, rather than the normal 7 bits
-of the Network Virtual Terminal.
-.It "WILL SGA"
-Indicate that it will not be sending
-.Dv IAC GA,
-go ahead, commands.
-.It "WILL STATUS"
-Indicate a willingness to send the client, upon
-request, of the current status of all
-.Tn TELNET
-options.
-.It "WILL TIMING-MARK"
-Whenever a
-.Dv DO TIMING-MARK
-command is received, it is always responded
-to with a
-.Dv WILL TIMING-MARK
-.ne 1i
-.It "WILL LOGOUT"
-When a
-.Dv DO LOGOUT
-is received, a
-.Dv WILL LOGOUT
-is sent in response, and the
-.Tn TELNET
-session is shut down.
-.It "WILL ENCRYPT"
-Only sent if
-.Nm
-is compiled with support for data encryption, and
-indicates a willingness to decrypt
-the data stream.
-.El
-.Pp
-.Nm Telnetd
-has support for enabling remotely the following
-.Tn TELNET
-options:
-.Bl -tag -width "DO AUTHENTICATION"
-.It "DO BINARY"
-Sent to indicate that
-.Nm
-is willing to receive an 8 bit data stream.
-.It "DO LFLOW"
-Requests that the client handle flow control
-characters remotely.
-.It "DO ECHO"
-This is not really supported, but is sent to identify a 4.2BSD
-.Xr telnet 1
-client, which will improperly respond with
-.Dv WILL ECHO.
-If a
-.Dv WILL ECHO
-is received, a
-.Dv DONT ECHO
-will be sent in response.
-.It "DO TERMINAL-TYPE"
-Indicate a desire to be able to request the
-name of the type of terminal that is attached
-to the client side of the connection.
-.It "DO SGA"
-Indicate that it does not need to receive
-.Dv IAC GA,
-the go ahead command.
-.It "DO NAWS"
-Requests that the client inform the server when
-the window (display) size changes.
-.It "DO TERMINAL-SPEED"
-Indicate a desire to be able to request information
-about the speed of the serial line to which
-the client is attached.
-.It "DO XDISPLOC"
-Indicate a desire to be able to request the name
-of the X Window System display that is associated with
-the telnet client.
-.It "DO NEW-ENVIRON"
-Indicate a desire to be able to request environment
-variable information, as described in RFC 1572.
-.It "DO ENVIRON"
-Indicate a desire to be able to request environment
-variable information, as described in RFC 1408.
-.It "DO LINEMODE"
-Only sent if
-.Nm
-is compiled with support for linemode, and
-requests that the client do line by line processing.
-.It "DO TIMING-MARK"
-Only sent if
-.Nm
-is compiled with support for both linemode and
-kludge linemode, and the client responded with
-.Dv WONT LINEMODE.
-If the client responds with
-.Dv WILL TM,
-the it is assumed that the client supports
-kludge linemode.
-Note that the
-.Op Fl k
-option can be used to disable this.
-.It "DO AUTHENTICATION"
-Only sent if
-.Nm
-is compiled with support for authentication, and
-indicates a willingness to receive authentication
-information for automatic login.
-.It "DO ENCRYPT"
-Only sent if
-.Nm
-is compiled with support for data encryption, and
-indicates a willingness to decrypt
-the data stream.
-.Sh ENVIRONMENT
-.Sh FILES
-.Bl -tag -width /usr/ucb/bftp -compact
-.It Pa /etc/services
-.It Pa /etc/inittab
-(UNICOS systems only)
-.It Pa /etc/iptos
-(if supported)
-.It Pa /usr/ucb/bftp
-(if supported)
-.El
-.Sh "SEE ALSO"
-.Xr bftp 1 ,
-.Xr login 1 ,
-.Xr telnet 1
-(if supported)
-.Sh STANDARDS
-.Bl -tag -compact -width RFC-1572
-.It Cm RFC-854
-.Tn TELNET
-PROTOCOL SPECIFICATION
-.It Cm RFC-855
-TELNET OPTION SPECIFICATIONS
-.It Cm RFC-856
-TELNET BINARY TRANSMISSION
-.It Cm RFC-857
-TELNET ECHO OPTION
-.It Cm RFC-858
-TELNET SUPPRESS GO AHEAD OPTION
-.It Cm RFC-859
-TELNET STATUS OPTION
-.It Cm RFC-860
-TELNET TIMING MARK OPTION
-.It Cm RFC-861
-TELNET EXTENDED OPTIONS - LIST OPTION
-.It Cm RFC-885
-TELNET END OF RECORD OPTION
-.It Cm RFC-1073
-Telnet Window Size Option
-.It Cm RFC-1079
-Telnet Terminal Speed Option
-.It Cm RFC-1091
-Telnet Terminal-Type Option
-.It Cm RFC-1096
-Telnet X Display Location Option
-.It Cm RFC-1123
-Requirements for Internet Hosts -- Application and Support
-.It Cm RFC-1184
-Telnet Linemode Option
-.It Cm RFC-1372
-Telnet Remote Flow Control Option
-.It Cm RFC-1416
-Telnet Authentication Option
-.It Cm RFC-1411
-Telnet Authentication: Kerberos Version 4
-.It Cm RFC-1412
-Telnet Authentication: SPX
-.It Cm RFC-1571
-Telnet Environment Option Interoperability Issues
-.It Cm RFC-1572
-Telnet Environment Option
-.Sh BUGS
-Some
-.Tn TELNET
-commands are only partially implemented.
-.Pp
-Because of bugs in the original 4.2 BSD
-.Xr telnet 1 ,
-.Nm
-performs some dubious protocol exchanges to try to discover if the remote
-client is, in fact, a 4.2 BSD
-.Xr telnet 1 .
-.Pp
-Binary mode
-has no common interpretation except between similar operating systems
-(Unix in this case).
-.Pp
-The terminal type name received from the remote client is converted to
-lower case.
-.Pp
-.Nm Telnetd
-never sends
-.Tn TELNET
-.Dv IAC GA
-(go ahead) commands.
-.Sh HISTORY
-IPv6 support was added by WIDE/KAME project.
diff --git a/contrib/telnet/telnetd/telnetd.c b/contrib/telnet/telnetd/telnetd.c
deleted file mode 100644
index 6d7bcde5fc4f..000000000000
--- a/contrib/telnet/telnetd/telnetd.c
+++ /dev/null
@@ -1,1634 +0,0 @@
-/*
- * Copyright (c) 1989, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-static const char copyright[] =
-"@(#) Copyright (c) 1989, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-#if 0
-static const char sccsid[] = "@(#)telnetd.c 8.4 (Berkeley) 5/30/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include "telnetd.h"
-#include "pathnames.h"
-
-#if defined(_SC_CRAY_SECURE_SYS) && !defined(SCM_SECURITY)
-/*
- * UNICOS 6.0/6.1 do not have SCM_SECURITY defined, so we can
- * use it to tell us to turn off all the socket security code,
- * since that is only used in UNICOS 7.0 and later.
- */
-# undef _SC_CRAY_SECURE_SYS
-#endif
-
-#include <err.h>
-#include <arpa/inet.h>
-
-#include <libutil.h>
-#include <utmp.h>
-
-#if defined(_SC_CRAY_SECURE_SYS)
-#include <sys/sysv.h>
-#include <sys/secdev.h>
-# ifdef SO_SEC_MULTI /* 8.0 code */
-#include <sys/secparm.h>
-#include <sys/usrv.h>
-# endif /* SO_SEC_MULTI */
-
-/* wrapper for KAME-special getnameinfo() */
-#ifndef NI_WITHSCOPEID
-#define NI_WITHSCOPEID 0
-#endif
-
-int secflag;
-char tty_dev[16];
-struct secdev dv;
-struct sysv sysv;
-# ifdef SO_SEC_MULTI /* 8.0 code */
-struct socksec ss;
-# else /* SO_SEC_MULTI */ /* 7.0 code */
-struct socket_security ss;
-# endif /* SO_SEC_MULTI */
-#endif /* _SC_CRAY_SECURE_SYS */
-
-#if defined(AUTHENTICATION)
-#include <libtelnet/auth.h>
-int auth_level = 0;
-#endif
-#if defined(ENCRYPTION)
-#include <libtelnet/encrypt.h>
-#endif
-#include <libtelnet/misc.h>
-#if defined(SecurID)
-int require_SecurID = 0;
-#endif
-
-char remote_hostname[MAXHOSTNAMELEN];
-int utmp_len = sizeof(remote_hostname) - 1;
-int registerd_host_only = 0;
-
-#ifdef STREAMSPTY
-# include <stropts.h>
-# include <termio.h>
-/* make sure we don't get the bsd version */
-# include "/usr/include/sys/tty.h"
-# include <sys/ptyvar.h>
-
-/*
- * Because of the way ptyibuf is used with streams messages, we need
- * ptyibuf+1 to be on a full-word boundary. The following wierdness
- * is simply to make that happen.
- */
-long ptyibufbuf[BUFSIZ/sizeof(long)+1];
-char *ptyibuf = ((char *)&ptyibufbuf[1])-1;
-char *ptyip = ((char *)&ptyibufbuf[1])-1;
-char ptyibuf2[BUFSIZ];
-unsigned char ctlbuf[BUFSIZ];
-struct strbuf strbufc, strbufd;
-
-#else /* ! STREAMPTY */
-
-/*
- * I/O data buffers,
- * pointers, and counters.
- */
-char ptyibuf[BUFSIZ], *ptyip = ptyibuf;
-char ptyibuf2[BUFSIZ];
-
-# include <termcap.h>
-
-int readstream(int p, char *ibuf, int bufsize);
-void doit(struct sockaddr *who);
-int terminaltypeok(char *s);
-void startslave(char *host, int autologin, char *autoname);
-
-#endif /* ! STREAMPTY */
-
-int hostinfo = 1; /* do we print login banner? */
-
-#ifdef CRAY
-extern int newmap; /* nonzero if \n maps to ^M^J */
-int lowpty = 0, highpty; /* low, high pty numbers */
-#endif /* CRAY */
-
-int debug = 0;
-int keepalive = 1;
-char *altlogin;
-
-void doit __P((struct sockaddr *));
-int terminaltypeok __P((char *));
-void startslave __P((char *, int, char *));
-extern void usage P((void));
-
-/*
- * The string to pass to getopt(). We do it this way so
- * that only the actual options that we support will be
- * passed off to getopt().
- */
-char valid_opts[] = {
- 'd', ':', 'h', 'k', 'n', 'p', ':', 'S', ':', 'u', ':', 'U',
- '4', '6',
-#ifdef AUTHENTICATION
- 'a', ':', 'X', ':',
-#endif
-#ifdef BFTPDAEMON
- 'B',
-#endif
-#ifdef DIAGNOSTICS
- 'D', ':',
-#endif
-#ifdef ENCRYPTION
- 'e', ':',
-#endif
-#if defined(CRAY) && defined(NEWINIT)
- 'I', ':',
-#endif
-#ifdef LINEMODE
- 'l',
-#endif
-#ifdef CRAY
- 'r', ':',
-#endif
-#ifdef SecurID
- 's',
-#endif
- '\0'
-};
-
-int family = AF_INET;
-
-int
-main(argc, argv)
- char *argv[];
-{
- struct sockaddr_storage from;
- int on = 1, fromlen;
- register int ch;
-#if defined(IPPROTO_IP) && defined(IP_TOS)
- int tos = -1;
-#endif
-
- pfrontp = pbackp = ptyobuf;
- netip = netibuf;
- nfrontp = nbackp = netobuf;
-#ifdef ENCRYPTION
- nclearto = 0;
-#endif /* ENCRYPTION */
-
- /*
- * This initialization causes linemode to default to a configuration
- * that works on all telnet clients, including the FreeBSD client.
- * This is not quite the same as the telnet client issuing a "mode
- * character" command, but has most of the same benefits, and is
- * preferable since some clients (like usofts) don't have the
- * mode character command anyway and linemode breaks things.
- * The most notable symptom of fix is that csh "set filec" operations
- * like <ESC> (filename completion) and ^D (choices) keys now work
- * in telnet sessions and can be used more than once on the same line.
- * CR/LF handling is also corrected in some termio modes. This
- * change resolves problem reports bin/771 and bin/1037.
- */
-
- linemode=1; /*Default to mode that works on bulk of clients*/
-
-#ifdef CRAY
- /*
- * Get number of pty's before trying to process options,
- * which may include changing pty range.
- */
- highpty = getnpty();
-#endif /* CRAY */
-
- while ((ch = getopt(argc, argv, valid_opts)) != -1) {
- switch(ch) {
-
-#ifdef AUTHENTICATION
- case 'a':
- /*
- * Check for required authentication level
- */
- if (strcmp(optarg, "debug") == 0) {
- extern int auth_debug_mode;
- auth_debug_mode = 1;
- } else if (strcasecmp(optarg, "none") == 0) {
- auth_level = 0;
- } else if (strcasecmp(optarg, "other") == 0) {
- auth_level = AUTH_OTHER;
- } else if (strcasecmp(optarg, "user") == 0) {
- auth_level = AUTH_USER;
- } else if (strcasecmp(optarg, "valid") == 0) {
- auth_level = AUTH_VALID;
- } else if (strcasecmp(optarg, "off") == 0) {
- /*
- * This hack turns off authentication
- */
- auth_level = -1;
- } else {
- warnx("unknown authorization level for -a");
- }
- break;
-#endif /* AUTHENTICATION */
-
-#ifdef BFTPDAEMON
- case 'B':
- bftpd++;
- break;
-#endif /* BFTPDAEMON */
-
- case 'd':
- if (strcmp(optarg, "ebug") == 0) {
- debug++;
- break;
- }
- usage();
- /* NOTREACHED */
- break;
-
-#ifdef DIAGNOSTICS
- case 'D':
- /*
- * Check for desired diagnostics capabilities.
- */
- if (!strcmp(optarg, "report")) {
- diagnostic |= TD_REPORT|TD_OPTIONS;
- } else if (!strcmp(optarg, "exercise")) {
- diagnostic |= TD_EXERCISE;
- } else if (!strcmp(optarg, "netdata")) {
- diagnostic |= TD_NETDATA;
- } else if (!strcmp(optarg, "ptydata")) {
- diagnostic |= TD_PTYDATA;
- } else if (!strcmp(optarg, "options")) {
- diagnostic |= TD_OPTIONS;
- } else {
- usage();
- /* NOT REACHED */
- }
- break;
-#endif /* DIAGNOSTICS */
-
-#ifdef ENCRYPTION
- case 'e':
- if (strcmp(optarg, "debug") == 0) {
- extern int encrypt_debug_mode;
- encrypt_debug_mode = 1;
- break;
- }
- usage();
- /* NOTREACHED */
- break;
-#endif /* ENCRYPTION */
-
- case 'h':
- hostinfo = 0;
- break;
-
-#if defined(CRAY) && defined(NEWINIT)
- case 'I':
- {
- extern char *gen_id;
- gen_id = optarg;
- break;
- }
-#endif /* defined(CRAY) && defined(NEWINIT) */
-
-#ifdef LINEMODE
- case 'l':
- alwayslinemode = 1;
- break;
-#endif /* LINEMODE */
-
- case 'k':
-#if defined(LINEMODE) && defined(KLUDGELINEMODE)
- lmodetype = NO_AUTOKLUDGE;
-#else
- /* ignore -k option if built without kludge linemode */
-#endif /* defined(LINEMODE) && defined(KLUDGELINEMODE) */
- break;
-
- case 'n':
- keepalive = 0;
- break;
-
- case 'p':
- altlogin = optarg;
- break;
-
-#ifdef CRAY
- case 'r':
- {
- char *strchr();
- char *c;
-
- /*
- * Allow the specification of alterations
- * to the pty search range. It is legal to
- * specify only one, and not change the
- * other from its default.
- */
- c = strchr(optarg, '-');
- if (c) {
- *c++ = '\0';
- highpty = atoi(c);
- }
- if (*optarg != '\0')
- lowpty = atoi(optarg);
- if ((lowpty > highpty) || (lowpty < 0) ||
- (highpty > 32767)) {
- usage();
- /* NOT REACHED */
- }
- break;
- }
-#endif /* CRAY */
-
-#ifdef SecurID
- case 's':
- /* SecurID required */
- require_SecurID = 1;
- break;
-#endif /* SecurID */
- case 'S':
-#ifdef HAS_GETTOS
- if ((tos = parsetos(optarg, "tcp")) < 0)
- warnx("%s%s%s",
- "bad TOS argument '", optarg,
- "'; will try to use default TOS");
-#else
- warnx("TOS option unavailable; -S flag not supported");
-#endif
- break;
-
- case 'u':
- utmp_len = atoi(optarg);
- if (utmp_len < 0)
- utmp_len = -utmp_len;
- if (utmp_len >= sizeof(remote_hostname))
- utmp_len = sizeof(remote_hostname) - 1;
- break;
-
- case 'U':
- registerd_host_only = 1;
- break;
-
-#ifdef AUTHENTICATION
- case 'X':
- /*
- * Check for invalid authentication types
- */
- auth_disable_name(optarg);
- break;
-#endif /* AUTHENTICATION */
-
- case '4':
- family = AF_INET;
- break;
-
-#ifdef INET6
- case '6':
- family = AF_INET6;
- break;
-#endif
-
- default:
- warnx("%c: unknown option", ch);
- /* FALLTHROUGH */
- case '?':
- usage();
- /* NOTREACHED */
- }
- }
-
- argc -= optind;
- argv += optind;
-
- if (debug) {
- int s, ns, foo, error;
- char *service = "telnet";
- struct addrinfo hints, *res;
-
- if (argc > 1) {
- usage();
- /* NOT REACHED */
- } else if (argc == 1)
- service = *argv;
-
- memset(&hints, 0, sizeof(hints));
- hints.ai_flags = AI_PASSIVE;
- hints.ai_family = family;
- hints.ai_socktype = SOCK_STREAM;
- hints.ai_protocol = 0;
- error = getaddrinfo(NULL, service, &hints, &res);
-
- if (error) {
- errx(1, "tcp/%s: %s\n", service, gai_strerror(error));
- if (error == EAI_SYSTEM)
- errx(1, "tcp/%s: %s\n", service, strerror(errno));
- usage();
- }
-
- s = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
- if (s < 0)
- err(1, "socket");
- (void) setsockopt(s, SOL_SOCKET, SO_REUSEADDR,
- (char *)&on, sizeof(on));
- if (bind(s, res->ai_addr, res->ai_addrlen) < 0)
- err(1, "bind");
- if (listen(s, 1) < 0)
- err(1, "listen");
- foo = res->ai_addrlen;
- ns = accept(s, res->ai_addr, &foo);
- if (ns < 0)
- err(1, "accept");
- (void) dup2(ns, 0);
- (void) close(ns);
- (void) close(s);
-#ifdef convex
- } else if (argc == 1) {
- ; /* VOID*/ /* Just ignore the host/port name */
-#endif
- } else if (argc > 0) {
- usage();
- /* NOT REACHED */
- }
-
-#if defined(_SC_CRAY_SECURE_SYS)
- secflag = sysconf(_SC_CRAY_SECURE_SYS);
-
- /*
- * Get socket's security label
- */
- if (secflag) {
- int szss = sizeof(ss);
-#ifdef SO_SEC_MULTI /* 8.0 code */
- int sock_multi;
- int szi = sizeof(int);
-#endif /* SO_SEC_MULTI */
-
- memset((char *)&dv, 0, sizeof(dv));
-
- if (getsysv(&sysv, sizeof(struct sysv)) != 0)
- err(1, "getsysv");
-
- /*
- * Get socket security label and set device values
- * {security label to be set on ttyp device}
- */
-#ifdef SO_SEC_MULTI /* 8.0 code */
- if ((getsockopt(0, SOL_SOCKET, SO_SECURITY,
- (char *)&ss, &szss) < 0) ||
- (getsockopt(0, SOL_SOCKET, SO_SEC_MULTI,
- (char *)&sock_multi, &szi) < 0)) {
- err(1, "getsockopt");
- } else {
- dv.dv_actlvl = ss.ss_actlabel.lt_level;
- dv.dv_actcmp = ss.ss_actlabel.lt_compart;
- if (!sock_multi) {
- dv.dv_minlvl = dv.dv_maxlvl = dv.dv_actlvl;
- dv.dv_valcmp = dv.dv_actcmp;
- } else {
- dv.dv_minlvl = ss.ss_minlabel.lt_level;
- dv.dv_maxlvl = ss.ss_maxlabel.lt_level;
- dv.dv_valcmp = ss.ss_maxlabel.lt_compart;
- }
- dv.dv_devflg = 0;
- }
-#else /* SO_SEC_MULTI */ /* 7.0 code */
- if (getsockopt(0, SOL_SOCKET, SO_SECURITY,
- (char *)&ss, &szss) >= 0) {
- dv.dv_actlvl = ss.ss_slevel;
- dv.dv_actcmp = ss.ss_compart;
- dv.dv_minlvl = ss.ss_minlvl;
- dv.dv_maxlvl = ss.ss_maxlvl;
- dv.dv_valcmp = ss.ss_maxcmp;
- }
-#endif /* SO_SEC_MULTI */
- }
-#endif /* _SC_CRAY_SECURE_SYS */
-
- openlog("telnetd", LOG_PID | LOG_ODELAY, LOG_DAEMON);
- fromlen = sizeof (from);
- if (getpeername(0, (struct sockaddr *)&from, &fromlen) < 0) {
- warn("getpeername");
- _exit(1);
- }
- if (keepalive &&
- setsockopt(0, SOL_SOCKET, SO_KEEPALIVE,
- (char *)&on, sizeof (on)) < 0) {
- syslog(LOG_WARNING, "setsockopt (SO_KEEPALIVE): %m");
- }
-
-#if defined(IPPROTO_IP) && defined(IP_TOS)
- if (from.ss_family == AF_INET) {
-# if defined(HAS_GETTOS)
- struct tosent *tp;
- if (tos < 0 && (tp = gettosbyname("telnet", "tcp")))
- tos = tp->t_tos;
-# endif
- if (tos < 0)
- tos = 020; /* Low Delay bit */
- if (tos
- && (setsockopt(0, IPPROTO_IP, IP_TOS,
- (char *)&tos, sizeof(tos)) < 0)
- && (errno != ENOPROTOOPT) )
- syslog(LOG_WARNING, "setsockopt (IP_TOS): %m");
- }
-#endif /* defined(IPPROTO_IP) && defined(IP_TOS) */
- net = 0;
- doit((struct sockaddr *)&from);
- /* NOTREACHED */
- return(0);
-} /* end of main */
-
- void
-usage()
-{
- fprintf(stderr, "usage: telnetd");
-#ifdef AUTHENTICATION
- fprintf(stderr, " [-a (debug|other|user|valid|off|none)]\n\t");
-#endif
-#ifdef BFTPDAEMON
- fprintf(stderr, " [-B]");
-#endif
- fprintf(stderr, " [-debug]");
-#ifdef DIAGNOSTICS
- fprintf(stderr, " [-D (options|report|exercise|netdata|ptydata)]\n\t");
-#endif
-#ifdef AUTHENTICATION
- fprintf(stderr, " [-edebug]");
-#endif
- fprintf(stderr, " [-h]");
-#if defined(CRAY) && defined(NEWINIT)
- fprintf(stderr, " [-Iinitid]");
-#endif
-#if defined(LINEMODE) && defined(KLUDGELINEMODE)
- fprintf(stderr, " [-k]");
-#endif
-#ifdef LINEMODE
- fprintf(stderr, " [-l]");
-#endif
- fprintf(stderr, " [-n]");
-#ifdef CRAY
- fprintf(stderr, " [-r[lowpty]-[highpty]]");
-#endif
- fprintf(stderr, "\n\t");
-#ifdef SecurID
- fprintf(stderr, " [-s]");
-#endif
-#ifdef HAS_GETTOS
- fprintf(stderr, " [-S tos]");
-#endif
-#ifdef AUTHENTICATION
- fprintf(stderr, " [-X auth-type]");
-#endif
- fprintf(stderr, " [-u utmp_hostname_length] [-U]");
- fprintf(stderr, " [port]\n");
- exit(1);
-}
-
-/*
- * getterminaltype
- *
- * Ask the other end to send along its terminal type and speed.
- * Output is the variable terminaltype filled in.
- */
-static unsigned char ttytype_sbbuf[] = {
- IAC, SB, TELOPT_TTYPE, TELQUAL_SEND, IAC, SE
-};
-
- int
-getterminaltype(name)
- char *name;
-{
- int retval = -1;
- void _gettermname();
-
- settimer(baseline);
-#if defined(AUTHENTICATION)
- /*
- * Handle the Authentication option before we do anything else.
- */
- send_do(TELOPT_AUTHENTICATION, 1);
- while (his_will_wont_is_changing(TELOPT_AUTHENTICATION))
- ttloop();
- if (his_state_is_will(TELOPT_AUTHENTICATION)) {
- retval = auth_wait(name);
- }
-#endif
-
-#ifdef ENCRYPTION
- send_will(TELOPT_ENCRYPT, 1);
-#endif /* ENCRYPTION */
- send_do(TELOPT_TTYPE, 1);
- send_do(TELOPT_TSPEED, 1);
- send_do(TELOPT_XDISPLOC, 1);
- send_do(TELOPT_NEW_ENVIRON, 1);
- send_do(TELOPT_OLD_ENVIRON, 1);
- while (
-#ifdef ENCRYPTION
- his_do_dont_is_changing(TELOPT_ENCRYPT) ||
-#endif /* ENCRYPTION */
- his_will_wont_is_changing(TELOPT_TTYPE) ||
- his_will_wont_is_changing(TELOPT_TSPEED) ||
- his_will_wont_is_changing(TELOPT_XDISPLOC) ||
- his_will_wont_is_changing(TELOPT_NEW_ENVIRON) ||
- his_will_wont_is_changing(TELOPT_OLD_ENVIRON)) {
- ttloop();
- }
-#ifdef ENCRYPTION
- /*
- * Wait for the negotiation of what type of encryption we can
- * send with. If autoencrypt is not set, this will just return.
- */
- if (his_state_is_will(TELOPT_ENCRYPT)) {
- encrypt_wait();
- }
-#endif /* ENCRYPTION */
- if (his_state_is_will(TELOPT_TSPEED)) {
- static unsigned char sb[] =
- { IAC, SB, TELOPT_TSPEED, TELQUAL_SEND, IAC, SE };
-
- memmove(nfrontp, sb, sizeof sb);
- nfrontp += sizeof sb;
- DIAG(TD_OPTIONS, printsub('>', sb + 2, sizeof sb - 2););
- }
- if (his_state_is_will(TELOPT_XDISPLOC)) {
- static unsigned char sb[] =
- { IAC, SB, TELOPT_XDISPLOC, TELQUAL_SEND, IAC, SE };
-
- memmove(nfrontp, sb, sizeof sb);
- nfrontp += sizeof sb;
- DIAG(TD_OPTIONS, printsub('>', sb + 2, sizeof sb - 2););
- }
- if (his_state_is_will(TELOPT_NEW_ENVIRON)) {
- static unsigned char sb[] =
- { IAC, SB, TELOPT_NEW_ENVIRON, TELQUAL_SEND, IAC, SE };
-
- memmove(nfrontp, sb, sizeof sb);
- nfrontp += sizeof sb;
- DIAG(TD_OPTIONS, printsub('>', sb + 2, sizeof sb - 2););
- }
- else if (his_state_is_will(TELOPT_OLD_ENVIRON)) {
- static unsigned char sb[] =
- { IAC, SB, TELOPT_OLD_ENVIRON, TELQUAL_SEND, IAC, SE };
-
- memmove(nfrontp, sb, sizeof sb);
- nfrontp += sizeof sb;
- DIAG(TD_OPTIONS, printsub('>', sb + 2, sizeof sb - 2););
- }
- if (his_state_is_will(TELOPT_TTYPE)) {
-
- memmove(nfrontp, ttytype_sbbuf, sizeof ttytype_sbbuf);
- nfrontp += sizeof ttytype_sbbuf;
- DIAG(TD_OPTIONS, printsub('>', ttytype_sbbuf + 2,
- sizeof ttytype_sbbuf - 2););
- }
- if (his_state_is_will(TELOPT_TSPEED)) {
- while (sequenceIs(tspeedsubopt, baseline))
- ttloop();
- }
- if (his_state_is_will(TELOPT_XDISPLOC)) {
- while (sequenceIs(xdisplocsubopt, baseline))
- ttloop();
- }
- if (his_state_is_will(TELOPT_NEW_ENVIRON)) {
- while (sequenceIs(environsubopt, baseline))
- ttloop();
- }
- if (his_state_is_will(TELOPT_OLD_ENVIRON)) {
- while (sequenceIs(oenvironsubopt, baseline))
- ttloop();
- }
- if (his_state_is_will(TELOPT_TTYPE)) {
- char first[256], last[256];
-
- while (sequenceIs(ttypesubopt, baseline))
- ttloop();
-
- /*
- * If the other side has already disabled the option, then
- * we have to just go with what we (might) have already gotten.
- */
- if (his_state_is_will(TELOPT_TTYPE) && !terminaltypeok(terminaltype)) {
- (void) strncpy(first, terminaltype, sizeof(first)-1);
- first[sizeof(first)-1] = '\0';
- for(;;) {
- /*
- * Save the unknown name, and request the next name.
- */
- (void) strncpy(last, terminaltype, sizeof(last)-1);
- last[sizeof(last)-1] = '\0';
- _gettermname();
- if (terminaltypeok(terminaltype))
- break;
- if ((strncmp(last, terminaltype, sizeof(last)) == 0) ||
- his_state_is_wont(TELOPT_TTYPE)) {
- /*
- * We've hit the end. If this is the same as
- * the first name, just go with it.
- */
- if (strncmp(first, terminaltype, sizeof(first)) == 0)
- break;
- /*
- * Get the terminal name one more time, so that
- * RFC1091 compliant telnets will cycle back to
- * the start of the list.
- */
- _gettermname();
- if (strncmp(first, terminaltype, sizeof(first)) != 0) {
- (void) strncpy(terminaltype, first, sizeof(terminaltype)-1);
- terminaltype[sizeof(terminaltype)-1] = '\0';
- }
- break;
- }
- }
- }
- }
- return(retval);
-} /* end of getterminaltype */
-
- void
-_gettermname()
-{
- /*
- * If the client turned off the option,
- * we can't send another request, so we
- * just return.
- */
- if (his_state_is_wont(TELOPT_TTYPE))
- return;
- settimer(baseline);
- memmove(nfrontp, ttytype_sbbuf, sizeof ttytype_sbbuf);
- nfrontp += sizeof ttytype_sbbuf;
- DIAG(TD_OPTIONS, printsub('>', ttytype_sbbuf + 2,
- sizeof ttytype_sbbuf - 2););
- while (sequenceIs(ttypesubopt, baseline))
- ttloop();
-}
-
- int
-terminaltypeok(s)
- char *s;
-{
- char buf[1024];
-
- if (terminaltype == NULL)
- return(1);
-
- /*
- * tgetent() will return 1 if the type is known, and
- * 0 if it is not known. If it returns -1, it couldn't
- * open the database. But if we can't open the database,
- * it won't help to say we failed, because we won't be
- * able to verify anything else. So, we treat -1 like 1.
- */
- if (tgetent(buf, s) == 0)
- return(0);
- return(1);
-}
-
-#ifndef MAXHOSTNAMELEN
-#define MAXHOSTNAMELEN 64
-#endif /* MAXHOSTNAMELEN */
-
-char *hostname;
-char host_name[MAXHOSTNAMELEN];
-
-extern void telnet P((int, int, char *));
-
-int level;
-char user_name[256];
-/*
- * Get a pty, scan input lines.
- */
- void
-doit(who)
- struct sockaddr *who;
-{
- int err;
- int ptynum;
-
- /*
- * Find an available pty to use.
- */
-#ifndef convex
- pty = getpty(&ptynum);
- if (pty < 0)
- fatal(net, "All network ports in use");
-#else
- for (;;) {
- char *lp;
- extern char *line, *getpty();
-
- if ((lp = getpty()) == NULL)
- fatal(net, "Out of ptys");
-
- if ((pty = open(lp, 2)) >= 0) {
- strcpy(line,lp);
- line[5] = 't';
- break;
- }
- }
-#endif
-
-#if defined(_SC_CRAY_SECURE_SYS)
- /*
- * set ttyp line security label
- */
- if (secflag) {
- char slave_dev[16];
-
- sprintf(tty_dev, "/dev/pty/%03d", ptynum);
- if (setdevs(tty_dev, &dv) < 0)
- fatal(net, "cannot set pty security");
- sprintf(slave_dev, "/dev/ttyp%03d", ptynum);
- if (setdevs(slave_dev, &dv) < 0)
- fatal(net, "cannot set tty security");
- }
-#endif /* _SC_CRAY_SECURE_SYS */
-
- /* get name of connected client */
- if (realhostname_sa(remote_hostname, sizeof(remote_hostname) - 1,
- who, who->sa_len) == HOSTNAME_INVALIDADDR && registerd_host_only)
- fatal(net, "Couldn't resolve your address into a host name.\r\n\
- Please contact your net administrator");
- remote_hostname[sizeof(remote_hostname) - 1] = '\0';
-
- trimdomain(remote_hostname, UT_HOSTSIZE);
- if (!isdigit(remote_hostname[0]) && strlen(remote_hostname) > utmp_len)
- err = getnameinfo(who, who->sa_len, remote_hostname,
- sizeof(remote_hostname), NULL, 0,
- NI_NUMERICHOST|NI_WITHSCOPEID);
- /* XXX: do 'err' check */
-
- (void) gethostname(host_name, sizeof(host_name) - 1);
- host_name[sizeof(host_name) - 1] = '\0';
- hostname = host_name;
-
-#if defined(AUTHENTICATION) || defined(ENCRYPTION)
- auth_encrypt_init(hostname, remote_hostname, "TELNETD", 1);
-#endif
-
- init_env();
- /*
- * get terminal type.
- */
- *user_name = 0;
- level = getterminaltype(user_name);
- setenv("TERM", terminaltype ? terminaltype : "network", 1);
-
-#if defined(_SC_CRAY_SECURE_SYS)
- if (secflag) {
- if (setulvl(dv.dv_actlvl) < 0)
- fatal(net,"cannot setulvl()");
- if (setucmp(dv.dv_actcmp) < 0)
- fatal(net, "cannot setucmp()");
- }
-#endif /* _SC_CRAY_SECURE_SYS */
-
- telnet(net, pty, remote_hostname); /* begin server process */
-
- /*NOTREACHED*/
-} /* end of doit */
-
-#if defined(CRAY2) && defined(UNICOS5) && defined(UNICOS50)
- int
-Xterm_output(ibufp, obuf, icountp, ocount)
- char **ibufp, *obuf;
- int *icountp, ocount;
-{
- int ret;
- ret = term_output(*ibufp, obuf, *icountp, ocount);
- *ibufp += *icountp;
- *icountp = 0;
- return(ret);
-}
-#define term_output Xterm_output
-#endif /* defined(CRAY2) && defined(UNICOS5) && defined(UNICOS50) */
-
-/*
- * Main loop. Select from pty and network, and
- * hand data to telnet receiver finite state machine.
- */
- void
-telnet(f, p, host)
- int f, p;
- char *host;
-{
- int on = 1;
-#define TABBUFSIZ 512
- char defent[TABBUFSIZ];
- char defstrs[TABBUFSIZ];
-#undef TABBUFSIZ
- char *HE;
- char *HN;
- char *IM;
- void netflush();
- int nfd;
-
- /*
- * Initialize the slc mapping table.
- */
- get_slc_defaults();
-
- /*
- * Do some tests where it is desireable to wait for a response.
- * Rather than doing them slowly, one at a time, do them all
- * at once.
- */
- if (my_state_is_wont(TELOPT_SGA))
- send_will(TELOPT_SGA, 1);
- /*
- * Is the client side a 4.2 (NOT 4.3) system? We need to know this
- * because 4.2 clients are unable to deal with TCP urgent data.
- *
- * To find out, we send out a "DO ECHO". If the remote system
- * answers "WILL ECHO" it is probably a 4.2 client, and we note
- * that fact ("WILL ECHO" ==> that the client will echo what
- * WE, the server, sends it; it does NOT mean that the client will
- * echo the terminal input).
- */
- send_do(TELOPT_ECHO, 1);
-
-#ifdef LINEMODE
- if (his_state_is_wont(TELOPT_LINEMODE)) {
- /* Query the peer for linemode support by trying to negotiate
- * the linemode option.
- */
- linemode = 0;
- editmode = 0;
- send_do(TELOPT_LINEMODE, 1); /* send do linemode */
- }
-#endif /* LINEMODE */
-
- /*
- * Send along a couple of other options that we wish to negotiate.
- */
- send_do(TELOPT_NAWS, 1);
- send_will(TELOPT_STATUS, 1);
- flowmode = 1; /* default flow control state */
- restartany = -1; /* uninitialized... */
- send_do(TELOPT_LFLOW, 1);
-
- /*
- * Spin, waiting for a response from the DO ECHO. However,
- * some REALLY DUMB telnets out there might not respond
- * to the DO ECHO. So, we spin looking for NAWS, (most dumb
- * telnets so far seem to respond with WONT for a DO that
- * they don't understand...) because by the time we get the
- * response, it will already have processed the DO ECHO.
- * Kludge upon kludge.
- */
- while (his_will_wont_is_changing(TELOPT_NAWS))
- ttloop();
-
- /*
- * But...
- * The client might have sent a WILL NAWS as part of its
- * startup code; if so, we'll be here before we get the
- * response to the DO ECHO. We'll make the assumption
- * that any implementation that understands about NAWS
- * is a modern enough implementation that it will respond
- * to our DO ECHO request; hence we'll do another spin
- * waiting for the ECHO option to settle down, which is
- * what we wanted to do in the first place...
- */
- if (his_want_state_is_will(TELOPT_ECHO) &&
- his_state_is_will(TELOPT_NAWS)) {
- while (his_will_wont_is_changing(TELOPT_ECHO))
- ttloop();
- }
- /*
- * On the off chance that the telnet client is broken and does not
- * respond to the DO ECHO we sent, (after all, we did send the
- * DO NAWS negotiation after the DO ECHO, and we won't get here
- * until a response to the DO NAWS comes back) simulate the
- * receipt of a will echo. This will also send a WONT ECHO
- * to the client, since we assume that the client failed to
- * respond because it believes that it is already in DO ECHO
- * mode, which we do not want.
- */
- if (his_want_state_is_will(TELOPT_ECHO)) {
- DIAG(TD_OPTIONS,
- {sprintf(nfrontp, "td: simulating recv\r\n");
- nfrontp += strlen(nfrontp);});
- willoption(TELOPT_ECHO);
- }
-
- /*
- * Finally, to clean things up, we turn on our echo. This
- * will break stupid 4.2 telnets out of local terminal echo.
- */
-
- if (my_state_is_wont(TELOPT_ECHO))
- send_will(TELOPT_ECHO, 1);
-
-#ifndef STREAMSPTY
- /*
- * Turn on packet mode
- */
- (void) ioctl(p, TIOCPKT, (char *)&on);
-#endif
-
-#if defined(LINEMODE) && defined(KLUDGELINEMODE)
- /*
- * Continuing line mode support. If client does not support
- * real linemode, attempt to negotiate kludge linemode by sending
- * the do timing mark sequence.
- */
- if (lmodetype < REAL_LINEMODE)
- send_do(TELOPT_TM, 1);
-#endif /* defined(LINEMODE) && defined(KLUDGELINEMODE) */
-
- /*
- * Call telrcv() once to pick up anything received during
- * terminal type negotiation, 4.2/4.3 determination, and
- * linemode negotiation.
- */
- telrcv();
-
- (void) ioctl(f, FIONBIO, (char *)&on);
- (void) ioctl(p, FIONBIO, (char *)&on);
-#if defined(CRAY2) && defined(UNICOS5)
- init_termdriver(f, p, interrupt, sendbrk);
-#endif
-
-#if defined(SO_OOBINLINE)
- (void) setsockopt(net, SOL_SOCKET, SO_OOBINLINE,
- (char *)&on, sizeof on);
-#endif /* defined(SO_OOBINLINE) */
-
-#ifdef SIGTSTP
- (void) signal(SIGTSTP, SIG_IGN);
-#endif
-#ifdef SIGTTOU
- /*
- * Ignoring SIGTTOU keeps the kernel from blocking us
- * in ttioct() in /sys/tty.c.
- */
- (void) signal(SIGTTOU, SIG_IGN);
-#endif
-
- (void) signal(SIGCHLD, cleanup);
-
-#if defined(CRAY2) && defined(UNICOS5)
- /*
- * Cray-2 will send a signal when pty modes are changed by slave
- * side. Set up signal handler now.
- */
- if ((int)signal(SIGUSR1, termstat) < 0)
- warn("signal");
- else if (ioctl(p, TCSIGME, (char *)SIGUSR1) < 0)
- warn("ioctl:TCSIGME");
- /*
- * Make processing loop check terminal characteristics early on.
- */
- termstat();
-#endif
-
-#ifdef TIOCNOTTY
- {
- register int t;
- t = open(_PATH_TTY, O_RDWR);
- if (t >= 0) {
- (void) ioctl(t, TIOCNOTTY, (char *)0);
- (void) close(t);
- }
- }
-#endif
-
-#if defined(CRAY) && defined(NEWINIT) && defined(TIOCSCTTY)
- (void) setsid();
- ioctl(p, TIOCSCTTY, 0);
-#endif
-
- /*
- * Show banner that getty never gave.
- *
- * We put the banner in the pty input buffer. This way, it
- * gets carriage return null processing, etc., just like all
- * other pty --> client data.
- */
-
-#if !defined(CRAY) || !defined(NEWINIT)
- if (getenv("USER"))
- hostinfo = 0;
-#endif
-
- if (getent(defent, "default") == 1) {
- char *Getstr();
- char *cp=defstrs;
-
- HE = Getstr("he", &cp);
- HN = Getstr("hn", &cp);
- IM = Getstr("im", &cp);
- if (HN && *HN)
- (void) strcpy(host_name, HN);
- if (IM == 0)
- IM = "";
- } else {
- IM = DEFAULT_IM;
- HE = 0;
- }
- edithost(HE, host_name);
- if (hostinfo && *IM)
- putf(IM, ptyibuf2);
-
- if (pcc)
- (void) strncat(ptyibuf2, ptyip, pcc+1);
- ptyip = ptyibuf2;
- pcc = strlen(ptyip);
-#ifdef LINEMODE
- /*
- * Last check to make sure all our states are correct.
- */
- init_termbuf();
- localstat();
-#endif /* LINEMODE */
-
- DIAG(TD_REPORT,
- {sprintf(nfrontp, "td: Entering processing loop\r\n");
- nfrontp += strlen(nfrontp);});
-
- /*
- * Startup the login process on the slave side of the terminal
- * now. We delay this until here to insure option negotiation
- * is complete.
- */
- startslave(host, level, user_name);
-
- nfd = ((f > p) ? f : p) + 1;
- for (;;) {
- fd_set ibits, obits, xbits;
- register int c;
-
- if (ncc < 0 && pcc < 0)
- break;
-
-#if defined(CRAY2) && defined(UNICOS5)
- if (needtermstat)
- _termstat();
-#endif /* defined(CRAY2) && defined(UNICOS5) */
- FD_ZERO(&ibits);
- FD_ZERO(&obits);
- FD_ZERO(&xbits);
- /*
- * Never look for input if there's still
- * stuff in the corresponding output buffer
- */
- if (nfrontp - nbackp || pcc > 0) {
- FD_SET(f, &obits);
- } else {
- FD_SET(p, &ibits);
- }
- if (pfrontp - pbackp || ncc > 0) {
- FD_SET(p, &obits);
- } else {
- FD_SET(f, &ibits);
- }
- if (!SYNCHing) {
- FD_SET(f, &xbits);
- }
- if ((c = select(nfd, &ibits, &obits, &xbits,
- (struct timeval *)0)) < 1) {
- if (c == -1) {
- if (errno == EINTR) {
- continue;
- }
- }
- sleep(5);
- continue;
- }
-
- /*
- * Any urgent data?
- */
- if (FD_ISSET(net, &xbits)) {
- SYNCHing = 1;
- }
-
- /*
- * Something to read from the network...
- */
- if (FD_ISSET(net, &ibits)) {
-#if !defined(SO_OOBINLINE)
- /*
- * In 4.2 (and 4.3 beta) systems, the
- * OOB indication and data handling in the kernel
- * is such that if two separate TCP Urgent requests
- * come in, one byte of TCP data will be overlaid.
- * This is fatal for Telnet, but we try to live
- * with it.
- *
- * In addition, in 4.2 (and...), a special protocol
- * is needed to pick up the TCP Urgent data in
- * the correct sequence.
- *
- * What we do is: if we think we are in urgent
- * mode, we look to see if we are "at the mark".
- * If we are, we do an OOB receive. If we run
- * this twice, we will do the OOB receive twice,
- * but the second will fail, since the second
- * time we were "at the mark", but there wasn't
- * any data there (the kernel doesn't reset
- * "at the mark" until we do a normal read).
- * Once we've read the OOB data, we go ahead
- * and do normal reads.
- *
- * There is also another problem, which is that
- * since the OOB byte we read doesn't put us
- * out of OOB state, and since that byte is most
- * likely the TELNET DM (data mark), we would
- * stay in the TELNET SYNCH (SYNCHing) state.
- * So, clocks to the rescue. If we've "just"
- * received a DM, then we test for the
- * presence of OOB data when the receive OOB
- * fails (and AFTER we did the normal mode read
- * to clear "at the mark").
- */
- if (SYNCHing) {
- int atmark;
-
- (void) ioctl(net, SIOCATMARK, (char *)&atmark);
- if (atmark) {
- ncc = recv(net, netibuf, sizeof (netibuf), MSG_OOB);
- if ((ncc == -1) && (errno == EINVAL)) {
- ncc = read(net, netibuf, sizeof (netibuf));
- if (sequenceIs(didnetreceive, gotDM)) {
- SYNCHing = stilloob(net);
- }
- }
- } else {
- ncc = read(net, netibuf, sizeof (netibuf));
- }
- } else {
- ncc = read(net, netibuf, sizeof (netibuf));
- }
- settimer(didnetreceive);
-#else /* !defined(SO_OOBINLINE)) */
- ncc = read(net, netibuf, sizeof (netibuf));
-#endif /* !defined(SO_OOBINLINE)) */
- if (ncc < 0 && errno == EWOULDBLOCK)
- ncc = 0;
- else {
- if (ncc <= 0) {
- break;
- }
- netip = netibuf;
- }
- DIAG((TD_REPORT | TD_NETDATA),
- {sprintf(nfrontp, "td: netread %d chars\r\n", ncc);
- nfrontp += strlen(nfrontp);});
- DIAG(TD_NETDATA, printdata("nd", netip, ncc));
- }
-
- /*
- * Something to read from the pty...
- */
- if (FD_ISSET(p, &ibits)) {
-#ifndef STREAMSPTY
- pcc = read(p, ptyibuf, BUFSIZ);
-#else
- pcc = readstream(p, ptyibuf, BUFSIZ);
-#endif
- /*
- * On some systems, if we try to read something
- * off the master side before the slave side is
- * opened, we get EIO.
- */
- if (pcc < 0 && (errno == EWOULDBLOCK ||
-#ifdef EAGAIN
- errno == EAGAIN ||
-#endif
- errno == EIO)) {
- pcc = 0;
- } else {
- if (pcc <= 0)
- break;
-#if !defined(CRAY2) || !defined(UNICOS5)
-#ifdef LINEMODE
- /*
- * If ioctl from pty, pass it through net
- */
- if (ptyibuf[0] & TIOCPKT_IOCTL) {
- copy_termbuf(ptyibuf+1, pcc-1);
- localstat();
- pcc = 1;
- }
-#endif /* LINEMODE */
- if (ptyibuf[0] & TIOCPKT_FLUSHWRITE) {
- netclear(); /* clear buffer back */
-#ifndef NO_URGENT
- /*
- * There are client telnets on some
- * operating systems get screwed up
- * royally if we send them urgent
- * mode data.
- */
- *nfrontp++ = IAC;
- *nfrontp++ = DM;
- neturg = nfrontp-1; /* off by one XXX */
- DIAG(TD_OPTIONS,
- printoption("td: send IAC", DM));
-
-#endif
- }
- if (his_state_is_will(TELOPT_LFLOW) &&
- (ptyibuf[0] &
- (TIOCPKT_NOSTOP|TIOCPKT_DOSTOP))) {
- int newflow =
- ptyibuf[0] & TIOCPKT_DOSTOP ? 1 : 0;
- if (newflow != flowmode) {
- flowmode = newflow;
- (void) sprintf(nfrontp,
- "%c%c%c%c%c%c",
- IAC, SB, TELOPT_LFLOW,
- flowmode ? LFLOW_ON
- : LFLOW_OFF,
- IAC, SE);
- nfrontp += 6;
- DIAG(TD_OPTIONS, printsub('>',
- (unsigned char *)nfrontp-4,
- 4););
- }
- }
- pcc--;
- ptyip = ptyibuf+1;
-#else /* defined(CRAY2) && defined(UNICOS5) */
- if (!uselinemode) {
- unpcc = pcc;
- unptyip = ptyibuf;
- pcc = term_output(&unptyip, ptyibuf2,
- &unpcc, BUFSIZ);
- ptyip = ptyibuf2;
- } else
- ptyip = ptyibuf;
-#endif /* defined(CRAY2) && defined(UNICOS5) */
- }
- }
-
- while (pcc > 0) {
- if ((&netobuf[BUFSIZ] - nfrontp) < 2)
- break;
- c = *ptyip++ & 0377, pcc--;
- if (c == IAC)
- *nfrontp++ = c;
-#if defined(CRAY2) && defined(UNICOS5)
- else if (c == '\n' &&
- my_state_is_wont(TELOPT_BINARY) && newmap)
- *nfrontp++ = '\r';
-#endif /* defined(CRAY2) && defined(UNICOS5) */
- *nfrontp++ = c;
- if ((c == '\r') && (my_state_is_wont(TELOPT_BINARY))) {
- if (pcc > 0 && ((*ptyip & 0377) == '\n')) {
- *nfrontp++ = *ptyip++ & 0377;
- pcc--;
- } else
- *nfrontp++ = '\0';
- }
- }
-#if defined(CRAY2) && defined(UNICOS5)
- /*
- * If chars were left over from the terminal driver,
- * note their existence.
- */
- if (!uselinemode && unpcc) {
- pcc = unpcc;
- unpcc = 0;
- ptyip = unptyip;
- }
-#endif /* defined(CRAY2) && defined(UNICOS5) */
-
- if (FD_ISSET(f, &obits) && (nfrontp - nbackp) > 0)
- netflush();
- if (ncc > 0)
- telrcv();
- if (FD_ISSET(p, &obits) && (pfrontp - pbackp) > 0)
- ptyflush();
- }
- cleanup(0);
-} /* end of telnet */
-
-#ifndef TCSIG
-# ifdef TIOCSIG
-# define TCSIG TIOCSIG
-# endif
-#endif
-
-#ifdef STREAMSPTY
-
-int flowison = -1; /* current state of flow: -1 is unknown */
-
-int readstream(p, ibuf, bufsize)
- int p;
- char *ibuf;
- int bufsize;
-{
- int flags = 0;
- int ret = 0;
- struct termios *tsp;
- struct termio *tp;
- struct iocblk *ip;
- char vstop, vstart;
- int ixon;
- int newflow;
-
- strbufc.maxlen = BUFSIZ;
- strbufc.buf = (char *)ctlbuf;
- strbufd.maxlen = bufsize-1;
- strbufd.len = 0;
- strbufd.buf = ibuf+1;
- ibuf[0] = 0;
-
- ret = getmsg(p, &strbufc, &strbufd, &flags);
- if (ret < 0) /* error of some sort -- probably EAGAIN */
- return(-1);
-
- if (strbufc.len <= 0 || ctlbuf[0] == M_DATA) {
- /* data message */
- if (strbufd.len > 0) { /* real data */
- return(strbufd.len + 1); /* count header char */
- } else {
- /* nothing there */
- errno = EAGAIN;
- return(-1);
- }
- }
-
- /*
- * It's a control message. Return 1, to look at the flag we set
- */
-
- switch (ctlbuf[0]) {
- case M_FLUSH:
- if (ibuf[1] & FLUSHW)
- ibuf[0] = TIOCPKT_FLUSHWRITE;
- return(1);
-
- case M_IOCTL:
- ip = (struct iocblk *) (ibuf+1);
-
- switch (ip->ioc_cmd) {
- case TCSETS:
- case TCSETSW:
- case TCSETSF:
- tsp = (struct termios *)
- (ibuf+1 + sizeof(struct iocblk));
- vstop = tsp->c_cc[VSTOP];
- vstart = tsp->c_cc[VSTART];
- ixon = tsp->c_iflag & IXON;
- break;
- case TCSETA:
- case TCSETAW:
- case TCSETAF:
- tp = (struct termio *) (ibuf+1 + sizeof(struct iocblk));
- vstop = tp->c_cc[VSTOP];
- vstart = tp->c_cc[VSTART];
- ixon = tp->c_iflag & IXON;
- break;
- default:
- errno = EAGAIN;
- return(-1);
- }
-
- newflow = (ixon && (vstart == 021) && (vstop == 023)) ? 1 : 0;
- if (newflow != flowison) { /* it's a change */
- flowison = newflow;
- ibuf[0] = newflow ? TIOCPKT_DOSTOP : TIOCPKT_NOSTOP;
- return(1);
- }
- }
-
- /* nothing worth doing anything about */
- errno = EAGAIN;
- return(-1);
-}
-#endif /* STREAMSPTY */
-
-/*
- * Send interrupt to process on other side of pty.
- * If it is in raw mode, just write NULL;
- * otherwise, write intr char.
- */
- void
-interrupt()
-{
- ptyflush(); /* half-hearted */
-
-#if defined(STREAMSPTY) && defined(TIOCSIGNAL)
- /* Streams PTY style ioctl to post a signal */
- {
- int sig = SIGINT;
- (void) ioctl(pty, TIOCSIGNAL, &sig);
- (void) ioctl(pty, I_FLUSH, FLUSHR);
- }
-#else
-#ifdef TCSIG
- (void) ioctl(pty, TCSIG, (char *)SIGINT);
-#else /* TCSIG */
- init_termbuf();
- *pfrontp++ = slctab[SLC_IP].sptr ?
- (unsigned char)*slctab[SLC_IP].sptr : '\177';
-#endif /* TCSIG */
-#endif
-}
-
-/*
- * Send quit to process on other side of pty.
- * If it is in raw mode, just write NULL;
- * otherwise, write quit char.
- */
- void
-sendbrk()
-{
- ptyflush(); /* half-hearted */
-#ifdef TCSIG
- (void) ioctl(pty, TCSIG, (char *)SIGQUIT);
-#else /* TCSIG */
- init_termbuf();
- *pfrontp++ = slctab[SLC_ABORT].sptr ?
- (unsigned char)*slctab[SLC_ABORT].sptr : '\034';
-#endif /* TCSIG */
-}
-
- void
-sendsusp()
-{
-#ifdef SIGTSTP
- ptyflush(); /* half-hearted */
-# ifdef TCSIG
- (void) ioctl(pty, TCSIG, (char *)SIGTSTP);
-# else /* TCSIG */
- *pfrontp++ = slctab[SLC_SUSP].sptr ?
- (unsigned char)*slctab[SLC_SUSP].sptr : '\032';
-# endif /* TCSIG */
-#endif /* SIGTSTP */
-}
-
-/*
- * When we get an AYT, if ^T is enabled, use that. Otherwise,
- * just send back "[Yes]".
- */
- void
-recv_ayt()
-{
-#if defined(SIGINFO) && defined(TCSIG)
- if (slctab[SLC_AYT].sptr && *slctab[SLC_AYT].sptr != _POSIX_VDISABLE) {
- (void) ioctl(pty, TCSIG, (char *)SIGINFO);
- return;
- }
-#endif
- (void) strcpy(nfrontp, "\r\n[Yes]\r\n");
- nfrontp += 9;
-}
-
- void
-doeof()
-{
- init_termbuf();
-
-#if defined(LINEMODE) && defined(USE_TERMIO) && (VEOF == VMIN)
- if (!tty_isediting()) {
- extern char oldeofc;
- *pfrontp++ = oldeofc;
- return;
- }
-#endif
- *pfrontp++ = slctab[SLC_EOF].sptr ?
- (unsigned char)*slctab[SLC_EOF].sptr : '\004';
-}
diff --git a/contrib/telnet/telnetd/telnetd.h b/contrib/telnet/telnetd/telnetd.h
deleted file mode 100644
index 234b9739e758..000000000000
--- a/contrib/telnet/telnetd/telnetd.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 1989, 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)telnetd.h 8.1 (Berkeley) 6/4/93
- */
-
-
-#include "defs.h"
-#include "ext.h"
-
-#ifdef DIAGNOSTICS
-#define DIAG(a,b) if (diagnostic & (a)) b
-#else
-#define DIAG(a,b)
-#endif
-
-/* other external variables */
-extern char **environ;
-extern int errno;
-
diff --git a/contrib/telnet/telnetd/termstat.c b/contrib/telnet/telnetd/termstat.c
deleted file mode 100644
index 46b20ffb2cc0..000000000000
--- a/contrib/telnet/telnetd/termstat.c
+++ /dev/null
@@ -1,677 +0,0 @@
-/*
- * Copyright (c) 1989, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-#if 0
-static const char sccsid[] = "@(#)termstat.c 8.2 (Berkeley) 5/30/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include "telnetd.h"
-
-#if defined(ENCRYPTION)
-#include <libtelnet/encrypt.h>
-#endif
-
-/*
- * local variables
- */
-int def_tspeed = -1, def_rspeed = -1;
-#ifdef TIOCSWINSZ
-int def_row = 0, def_col = 0;
-#endif
-#ifdef LINEMODE
-static int _terminit = 0;
-#endif /* LINEMODE */
-
-#if defined(CRAY2) && defined(UNICOS5)
-int newmap = 1; /* nonzero if \n maps to ^M^J */
-#endif
-
-#ifdef LINEMODE
-/*
- * localstat
- *
- * This function handles all management of linemode.
- *
- * Linemode allows the client to do the local editing of data
- * and send only complete lines to the server. Linemode state is
- * based on the state of the pty driver. If the pty is set for
- * external processing, then we can use linemode. Further, if we
- * can use real linemode, then we can look at the edit control bits
- * in the pty to determine what editing the client should do.
- *
- * Linemode support uses the following state flags to keep track of
- * current and desired linemode state.
- * alwayslinemode : true if -l was specified on the telnetd
- * command line. It means to have linemode on as much as
- * possible.
- *
- * lmodetype: signifies whether the client can
- * handle real linemode, or if use of kludgeomatic linemode
- * is preferred. It will be set to one of the following:
- * REAL_LINEMODE : use linemode option
- * NO_KLUDGE : don't initiate kludge linemode.
- * KLUDGE_LINEMODE : use kludge linemode
- * NO_LINEMODE : client is ignorant of linemode
- *
- * linemode, uselinemode : linemode is true if linemode
- * is currently on, uselinemode is the state that we wish
- * to be in. If another function wishes to turn linemode
- * on or off, it sets or clears uselinemode.
- *
- * editmode, useeditmode : like linemode/uselinemode, but
- * these contain the edit mode states (edit and trapsig).
- *
- * The state variables correspond to some of the state information
- * in the pty.
- * linemode:
- * In real linemode, this corresponds to whether the pty
- * expects external processing of incoming data.
- * In kludge linemode, this more closely corresponds to the
- * whether normal processing is on or not. (ICANON in
- * system V, or COOKED mode in BSD.)
- * If the -l option was specified (alwayslinemode), then
- * an attempt is made to force external processing on at
- * all times.
- *
- * The following heuristics are applied to determine linemode
- * handling within the server.
- * 1) Early on in starting up the server, an attempt is made
- * to negotiate the linemode option. If this succeeds
- * then lmodetype is set to REAL_LINEMODE and all linemode
- * processing occurs in the context of the linemode option.
- * 2) If the attempt to negotiate the linemode option failed,
- * and the "-k" (don't initiate kludge linemode) isn't set,
- * then we try to use kludge linemode. We test for this
- * capability by sending "do Timing Mark". If a positive
- * response comes back, then we assume that the client
- * understands kludge linemode (ech!) and the
- * lmodetype flag is set to KLUDGE_LINEMODE.
- * 3) Otherwise, linemode is not supported at all and
- * lmodetype remains set to NO_LINEMODE (which happens
- * to be 0 for convenience).
- * 4) At any time a command arrives that implies a higher
- * state of linemode support in the client, we move to that
- * linemode support.
- *
- * A short explanation of kludge linemode is in order here.
- * 1) The heuristic to determine support for kludge linemode
- * is to send a do timing mark. We assume that a client
- * that supports timing marks also supports kludge linemode.
- * A risky proposition at best.
- * 2) Further negotiation of linemode is done by changing the
- * the server's state regarding SGA. If server will SGA,
- * then linemode is off, if server won't SGA, then linemode
- * is on.
- */
- void
-localstat()
-{
- void netflush();
- int need_will_echo = 0;
-
-#if defined(CRAY2) && defined(UNICOS5)
- /*
- * Keep track of that ol' CR/NL mapping while we're in the
- * neighborhood.
- */
- newmap = tty_isnewmap();
-#endif /* defined(CRAY2) && defined(UNICOS5) */
-
- /*
- * Check for changes to flow control if client supports it.
- */
- flowstat();
-
- /*
- * Check linemode on/off state
- */
- uselinemode = tty_linemode();
-
- /*
- * If alwayslinemode is on, and pty is changing to turn it off, then
- * force linemode back on.
- */
- if (alwayslinemode && linemode && !uselinemode) {
- uselinemode = 1;
- tty_setlinemode(uselinemode);
- }
-
- if (uselinemode) {
- /*
- * Check for state of BINARY options.
- *
- * We only need to do the binary dance if we are actually going
- * to use linemode. As this confuses some telnet clients
- * that don't support linemode, and doesn't gain us
- * anything, we don't do it unless we're doing linemode.
- * -Crh (henrich@msu.edu)
- */
-
- if (tty_isbinaryin()) {
- if (his_want_state_is_wont(TELOPT_BINARY))
- send_do(TELOPT_BINARY, 1);
- } else {
- if (his_want_state_is_will(TELOPT_BINARY))
- send_dont(TELOPT_BINARY, 1);
- }
-
- if (tty_isbinaryout()) {
- if (my_want_state_is_wont(TELOPT_BINARY))
- send_will(TELOPT_BINARY, 1);
- } else {
- if (my_want_state_is_will(TELOPT_BINARY))
- send_wont(TELOPT_BINARY, 1);
- }
- }
-
-#ifdef ENCRYPTION
- /*
- * If the terminal is not echoing, but editing is enabled,
- * something like password input is going to happen, so
- * if we the other side is not currently sending encrypted
- * data, ask the other side to start encrypting.
- */
- if (his_state_is_will(TELOPT_ENCRYPT)) {
- static int enc_passwd = 0;
- if (uselinemode && !tty_isecho() && tty_isediting()
- && (enc_passwd == 0) && !decrypt_input) {
- encrypt_send_request_start();
- enc_passwd = 1;
- } else if (enc_passwd) {
- encrypt_send_request_end();
- enc_passwd = 0;
- }
- }
-#endif /* ENCRYPTION */
-
- /*
- * Do echo mode handling as soon as we know what the
- * linemode is going to be.
- * If the pty has echo turned off, then tell the client that
- * the server will echo. If echo is on, then the server
- * will echo if in character mode, but in linemode the
- * client should do local echoing. The state machine will
- * not send anything if it is unnecessary, so don't worry
- * about that here.
- *
- * If we need to send the WILL ECHO (because echo is off),
- * then delay that until after we have changed the MODE.
- * This way, when the user is turning off both editing
- * and echo, the client will get editing turned off first.
- * This keeps the client from going into encryption mode
- * and then right back out if it is doing auto-encryption
- * when passwords are being typed.
- */
- if (uselinemode) {
- if (tty_isecho())
- send_wont(TELOPT_ECHO, 1);
- else
- need_will_echo = 1;
-#ifdef KLUDGELINEMODE
- if (lmodetype == KLUDGE_OK)
- lmodetype = KLUDGE_LINEMODE;
-#endif
- }
-
- /*
- * If linemode is being turned off, send appropriate
- * command and then we're all done.
- */
- if (!uselinemode && linemode) {
-# ifdef KLUDGELINEMODE
- if (lmodetype == REAL_LINEMODE) {
-# endif /* KLUDGELINEMODE */
- send_dont(TELOPT_LINEMODE, 1);
-# ifdef KLUDGELINEMODE
- } else if (lmodetype == KLUDGE_LINEMODE)
- send_will(TELOPT_SGA, 1);
-# endif /* KLUDGELINEMODE */
- send_will(TELOPT_ECHO, 1);
- linemode = uselinemode;
- goto done;
- }
-
-# ifdef KLUDGELINEMODE
- /*
- * If using real linemode check edit modes for possible later use.
- * If we are in kludge linemode, do the SGA negotiation.
- */
- if (lmodetype == REAL_LINEMODE) {
-# endif /* KLUDGELINEMODE */
- useeditmode = 0;
- if (tty_isediting())
- useeditmode |= MODE_EDIT;
- if (tty_istrapsig())
- useeditmode |= MODE_TRAPSIG;
- if (tty_issofttab())
- useeditmode |= MODE_SOFT_TAB;
- if (tty_islitecho())
- useeditmode |= MODE_LIT_ECHO;
-# ifdef KLUDGELINEMODE
- } else if (lmodetype == KLUDGE_LINEMODE) {
- if (tty_isediting() && uselinemode)
- send_wont(TELOPT_SGA, 1);
- else
- send_will(TELOPT_SGA, 1);
- }
-# endif /* KLUDGELINEMODE */
-
- /*
- * Negotiate linemode on if pty state has changed to turn it on.
- * Send appropriate command and send along edit mode, then all done.
- */
- if (uselinemode && !linemode) {
-# ifdef KLUDGELINEMODE
- if (lmodetype == KLUDGE_LINEMODE) {
- send_wont(TELOPT_SGA, 1);
- } else if (lmodetype == REAL_LINEMODE) {
-# endif /* KLUDGELINEMODE */
- send_do(TELOPT_LINEMODE, 1);
- /* send along edit modes */
- (void) sprintf(nfrontp, "%c%c%c%c%c%c%c", IAC, SB,
- TELOPT_LINEMODE, LM_MODE, useeditmode,
- IAC, SE);
- nfrontp += 7;
- editmode = useeditmode;
-# ifdef KLUDGELINEMODE
- }
-# endif /* KLUDGELINEMODE */
- linemode = uselinemode;
- goto done;
- }
-
-# ifdef KLUDGELINEMODE
- /*
- * None of what follows is of any value if not using
- * real linemode.
- */
- if (lmodetype < REAL_LINEMODE)
- goto done;
-# endif /* KLUDGELINEMODE */
-
- if (linemode && his_state_is_will(TELOPT_LINEMODE)) {
- /*
- * If edit mode changed, send edit mode.
- */
- if (useeditmode != editmode) {
- /*
- * Send along appropriate edit mode mask.
- */
- (void) sprintf(nfrontp, "%c%c%c%c%c%c%c", IAC, SB,
- TELOPT_LINEMODE, LM_MODE, useeditmode,
- IAC, SE);
- nfrontp += 7;
- editmode = useeditmode;
- }
-
-
- /*
- * Check for changes to special characters in use.
- */
- start_slc(0);
- check_slc();
- (void) end_slc(0);
- }
-
-done:
- if (need_will_echo)
- send_will(TELOPT_ECHO, 1);
- /*
- * Some things should be deferred until after the pty state has
- * been set by the local process. Do those things that have been
- * deferred now. This only happens once.
- */
- if (_terminit == 0) {
- _terminit = 1;
- defer_terminit();
- }
-
- netflush();
- set_termbuf();
- return;
-
-} /* end of localstat */
-#endif /* LINEMODE */
-
-/*
- * flowstat
- *
- * Check for changes to flow control
- */
- void
-flowstat()
-{
- if (his_state_is_will(TELOPT_LFLOW)) {
- if (tty_flowmode() != flowmode) {
- flowmode = tty_flowmode();
- (void) sprintf(nfrontp, "%c%c%c%c%c%c",
- IAC, SB, TELOPT_LFLOW,
- flowmode ? LFLOW_ON : LFLOW_OFF,
- IAC, SE);
- nfrontp += 6;
- }
- if (tty_restartany() != restartany) {
- restartany = tty_restartany();
- (void) sprintf(nfrontp, "%c%c%c%c%c%c",
- IAC, SB, TELOPT_LFLOW,
- restartany ? LFLOW_RESTART_ANY
- : LFLOW_RESTART_XON,
- IAC, SE);
- nfrontp += 6;
- }
- }
-}
-
-/*
- * clientstat
- *
- * Process linemode related requests from the client.
- * Client can request a change to only one of linemode, editmode or slc's
- * at a time, and if using kludge linemode, then only linemode may be
- * affected.
- */
- void
-clientstat(code, parm1, parm2)
- register int code, parm1, parm2;
-{
- void netflush();
-
- /*
- * Get a copy of terminal characteristics.
- */
- init_termbuf();
-
- /*
- * Process request from client. code tells what it is.
- */
- switch (code) {
-#ifdef LINEMODE
- case TELOPT_LINEMODE:
- /*
- * Don't do anything unless client is asking us to change
- * modes.
- */
- uselinemode = (parm1 == WILL);
- if (uselinemode != linemode) {
-# ifdef KLUDGELINEMODE
- /*
- * If using kludge linemode, make sure that
- * we can do what the client asks.
- * We can not turn off linemode if alwayslinemode
- * and the ICANON bit is set.
- */
- if (lmodetype == KLUDGE_LINEMODE) {
- if (alwayslinemode && tty_isediting()) {
- uselinemode = 1;
- }
- }
-
- /*
- * Quit now if we can't do it.
- */
- if (uselinemode == linemode)
- return;
-
- /*
- * If using real linemode and linemode is being
- * turned on, send along the edit mode mask.
- */
- if (lmodetype == REAL_LINEMODE && uselinemode)
-# else /* KLUDGELINEMODE */
- if (uselinemode)
-# endif /* KLUDGELINEMODE */
- {
- useeditmode = 0;
- if (tty_isediting())
- useeditmode |= MODE_EDIT;
- if (tty_istrapsig)
- useeditmode |= MODE_TRAPSIG;
- if (tty_issofttab())
- useeditmode |= MODE_SOFT_TAB;
- if (tty_islitecho())
- useeditmode |= MODE_LIT_ECHO;
- (void) sprintf(nfrontp, "%c%c%c%c%c%c%c", IAC,
- SB, TELOPT_LINEMODE, LM_MODE,
- useeditmode, IAC, SE);
- nfrontp += 7;
- editmode = useeditmode;
- }
-
-
- tty_setlinemode(uselinemode);
-
- linemode = uselinemode;
-
- if (!linemode)
- send_will(TELOPT_ECHO, 1);
- }
- break;
-
- case LM_MODE:
- {
- register int ack, changed;
-
- /*
- * Client has sent along a mode mask. If it agrees with
- * what we are currently doing, ignore it; if not, it could
- * be viewed as a request to change. Note that the server
- * will change to the modes in an ack if it is different from
- * what we currently have, but we will not ack the ack.
- */
- useeditmode &= MODE_MASK;
- ack = (useeditmode & MODE_ACK);
- useeditmode &= ~MODE_ACK;
-
- if ((changed = (useeditmode ^ editmode))) {
- /*
- * This check is for a timing problem. If the
- * state of the tty has changed (due to the user
- * application) we need to process that info
- * before we write in the state contained in the
- * ack!!! This gets out the new MODE request,
- * and when the ack to that command comes back
- * we'll set it and be in the right mode.
- */
- if (ack)
- localstat();
- if (changed & MODE_EDIT)
- tty_setedit(useeditmode & MODE_EDIT);
-
- if (changed & MODE_TRAPSIG)
- tty_setsig(useeditmode & MODE_TRAPSIG);
-
- if (changed & MODE_SOFT_TAB)
- tty_setsofttab(useeditmode & MODE_SOFT_TAB);
-
- if (changed & MODE_LIT_ECHO)
- tty_setlitecho(useeditmode & MODE_LIT_ECHO);
-
- set_termbuf();
-
- if (!ack) {
- (void) sprintf(nfrontp, "%c%c%c%c%c%c%c", IAC,
- SB, TELOPT_LINEMODE, LM_MODE,
- useeditmode|MODE_ACK,
- IAC, SE);
- nfrontp += 7;
- }
-
- editmode = useeditmode;
- }
-
- break;
-
- } /* end of case LM_MODE */
-#endif /* LINEMODE */
-
- case TELOPT_NAWS:
-#ifdef TIOCSWINSZ
- {
- struct winsize ws;
-
- def_col = parm1;
- def_row = parm2;
-#ifdef LINEMODE
- /*
- * Defer changing window size until after terminal is
- * initialized.
- */
- if (terminit() == 0)
- return;
-#endif /* LINEMODE */
-
- /*
- * Change window size as requested by client.
- */
-
- ws.ws_col = parm1;
- ws.ws_row = parm2;
- (void) ioctl(pty, TIOCSWINSZ, (char *)&ws);
- }
-#endif /* TIOCSWINSZ */
-
- break;
-
- case TELOPT_TSPEED:
- {
- def_tspeed = parm1;
- def_rspeed = parm2;
-#ifdef LINEMODE
- /*
- * Defer changing the terminal speed.
- */
- if (terminit() == 0)
- return;
-#endif /* LINEMODE */
- /*
- * Change terminal speed as requested by client.
- * We set the receive speed first, so that if we can't
- * store seperate receive and transmit speeds, the transmit
- * speed will take precedence.
- */
- tty_rspeed(parm2);
- tty_tspeed(parm1);
- set_termbuf();
-
- break;
-
- } /* end of case TELOPT_TSPEED */
-
- default:
- /* What? */
- break;
- } /* end of switch */
-
-#if defined(CRAY2) && defined(UNICOS5)
- /*
- * Just in case of the likely event that we changed the pty state.
- */
- rcv_ioctl();
-#endif /* defined(CRAY2) && defined(UNICOS5) */
-
- netflush();
-
-} /* end of clientstat */
-
-#if defined(CRAY2) && defined(UNICOS5)
- void
-termstat()
-{
- needtermstat = 1;
-}
-
- void
-_termstat()
-{
- needtermstat = 0;
- init_termbuf();
- localstat();
- rcv_ioctl();
-}
-#endif /* defined(CRAY2) && defined(UNICOS5) */
-
-#ifdef LINEMODE
-/*
- * defer_terminit
- *
- * Some things should not be done until after the login process has started
- * and all the pty modes are set to what they are supposed to be. This
- * function is called when the pty state has been processed for the first time.
- * It calls other functions that do things that were deferred in each module.
- */
- void
-defer_terminit()
-{
-
- /*
- * local stuff that got deferred.
- */
- if (def_tspeed != -1) {
- clientstat(TELOPT_TSPEED, def_tspeed, def_rspeed);
- def_tspeed = def_rspeed = 0;
- }
-
-#ifdef TIOCSWINSZ
- if (def_col || def_row) {
- struct winsize ws;
-
- memset((char *)&ws, 0, sizeof(ws));
- ws.ws_col = def_col;
- ws.ws_row = def_row;
- (void) ioctl(pty, TIOCSWINSZ, (char *)&ws);
- }
-#endif
-
- /*
- * The only other module that currently defers anything.
- */
- deferslc();
-
-} /* end of defer_terminit */
-
-/*
- * terminit
- *
- * Returns true if the pty state has been processed yet.
- */
- int
-terminit()
-{
- return(_terminit);
-
-} /* end of terminit */
-#endif /* LINEMODE */
diff --git a/contrib/telnet/telnetd/utility.c b/contrib/telnet/telnetd/utility.c
deleted file mode 100644
index dc695fa690cc..000000000000
--- a/contrib/telnet/telnetd/utility.c
+++ /dev/null
@@ -1,1246 +0,0 @@
-/*
- * Copyright (c) 1989, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-#if 0
-static const char sccsid[] = "@(#)utility.c 8.4 (Berkeley) 5/30/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#ifdef __FreeBSD__
-#include <locale.h>
-#include <sys/utsname.h>
-#endif
-#define PRINTOPTIONS
-#include "telnetd.h"
-
-#if defined(AUTHENTICATION)
-#include <libtelnet/auth.h>
-#endif
-#if defined(ENCRYPTION)
-#include <libtelnet/encrypt.h>
-#endif
-
-/*
- * utility functions performing io related tasks
- */
-
-/*
- * ttloop
- *
- * A small subroutine to flush the network output buffer, get some data
- * from the network, and pass it through the telnet state machine. We
- * also flush the pty input buffer (by dropping its data) if it becomes
- * too full.
- */
-
- void
-ttloop()
-{
- void netflush();
-
- DIAG(TD_REPORT, {sprintf(nfrontp, "td: ttloop\r\n");
- nfrontp += strlen(nfrontp);});
- if (nfrontp-nbackp) {
- netflush();
- }
- ncc = read(net, netibuf, sizeof netibuf);
- if (ncc < 0) {
- syslog(LOG_INFO, "ttloop: read: %m");
- exit(1);
- } else if (ncc == 0) {
- syslog(LOG_INFO, "ttloop: peer died: %m");
- exit(1);
- }
- DIAG(TD_REPORT, {sprintf(nfrontp, "td: ttloop read %d chars\r\n", ncc);
- nfrontp += strlen(nfrontp);});
- netip = netibuf;
- telrcv(); /* state machine */
- if (ncc > 0) {
- pfrontp = pbackp = ptyobuf;
- telrcv();
- }
-} /* end of ttloop */
-
-/*
- * Check a descriptor to see if out of band data exists on it.
- */
- int
-stilloob(s)
- int s; /* socket number */
-{
- static struct timeval timeout = { 0 };
- fd_set excepts;
- int value;
-
- do {
- FD_ZERO(&excepts);
- FD_SET(s, &excepts);
- memset((char *)&timeout, 0, sizeof timeout);
- value = select(s+1, (fd_set *)0, (fd_set *)0, &excepts, &timeout);
- } while ((value == -1) && (errno == EINTR));
-
- if (value < 0) {
- fatalperror(pty, "select");
- }
- if (FD_ISSET(s, &excepts)) {
- return 1;
- } else {
- return 0;
- }
-}
-
- void
-ptyflush()
-{
- int n;
-
- if ((n = pfrontp - pbackp) > 0) {
- DIAG((TD_REPORT | TD_PTYDATA),
- { sprintf(nfrontp, "td: ptyflush %d chars\r\n", n);
- nfrontp += strlen(nfrontp); });
- DIAG(TD_PTYDATA, printdata("pd", pbackp, n));
- n = write(pty, pbackp, n);
- }
- if (n < 0) {
- if (errno == EWOULDBLOCK || errno == EINTR)
- return;
- cleanup(0);
- }
- pbackp += n;
- if (pbackp == pfrontp)
- pbackp = pfrontp = ptyobuf;
-}
-
-/*
- * nextitem()
- *
- * Return the address of the next "item" in the TELNET data
- * stream. This will be the address of the next character if
- * the current address is a user data character, or it will
- * be the address of the character following the TELNET command
- * if the current address is a TELNET IAC ("I Am a Command")
- * character.
- */
- char *
-nextitem(current)
- char *current;
-{
- if ((*current&0xff) != IAC) {
- return current+1;
- }
- switch (*(current+1)&0xff) {
- case DO:
- case DONT:
- case WILL:
- case WONT:
- return current+3;
- case SB: /* loop forever looking for the SE */
- {
- register char *look = current+2;
-
- for (;;) {
- if ((*look++&0xff) == IAC) {
- if ((*look++&0xff) == SE) {
- return look;
- }
- }
- }
- }
- default:
- return current+2;
- }
-} /* end of nextitem */
-
-
-/*
- * netclear()
- *
- * We are about to do a TELNET SYNCH operation. Clear
- * the path to the network.
- *
- * Things are a bit tricky since we may have sent the first
- * byte or so of a previous TELNET command into the network.
- * So, we have to scan the network buffer from the beginning
- * until we are up to where we want to be.
- *
- * A side effect of what we do, just to keep things
- * simple, is to clear the urgent data pointer. The principal
- * caller should be setting the urgent data pointer AFTER calling
- * us in any case.
- */
- void
-netclear()
-{
- register char *thisitem, *next;
- char *good;
-#define wewant(p) ((nfrontp > p) && ((*p&0xff) == IAC) && \
- ((*(p+1)&0xff) != EC) && ((*(p+1)&0xff) != EL))
-
-#ifdef ENCRYPTION
- thisitem = nclearto > netobuf ? nclearto : netobuf;
-#else /* ENCRYPTION */
- thisitem = netobuf;
-#endif /* ENCRYPTION */
-
- while ((next = nextitem(thisitem)) <= nbackp) {
- thisitem = next;
- }
-
- /* Now, thisitem is first before/at boundary. */
-
-#ifdef ENCRYPTION
- good = nclearto > netobuf ? nclearto : netobuf;
-#else /* ENCRYPTION */
- good = netobuf; /* where the good bytes go */
-#endif /* ENCRYPTION */
-
- while (nfrontp > thisitem) {
- if (wewant(thisitem)) {
- int length;
-
- next = thisitem;
- do {
- next = nextitem(next);
- } while (wewant(next) && (nfrontp > next));
- length = next-thisitem;
- memmove(good, thisitem, length);
- good += length;
- thisitem = next;
- } else {
- thisitem = nextitem(thisitem);
- }
- }
-
- nbackp = netobuf;
- nfrontp = good; /* next byte to be sent */
- neturg = 0;
-} /* end of netclear */
-
-/*
- * netflush
- * Send as much data as possible to the network,
- * handling requests for urgent data.
- */
- void
-netflush()
-{
- int n;
- extern int not42;
-
- if ((n = nfrontp - nbackp) > 0) {
- DIAG(TD_REPORT,
- { sprintf(nfrontp, "td: netflush %d chars\r\n", n);
- n += strlen(nfrontp); /* get count first */
- nfrontp += strlen(nfrontp); /* then move pointer */
- });
-#ifdef ENCRYPTION
- if (encrypt_output) {
- char *s = nclearto ? nclearto : nbackp;
- if (nfrontp - s > 0) {
- (*encrypt_output)((unsigned char *)s, nfrontp-s);
- nclearto = nfrontp;
- }
- }
-#endif /* ENCRYPTION */
- /*
- * if no urgent data, or if the other side appears to be an
- * old 4.2 client (and thus unable to survive TCP urgent data),
- * write the entire buffer in non-OOB mode.
- */
- if ((neturg == 0) || (not42 == 0)) {
- n = write(net, nbackp, n); /* normal write */
- } else {
- n = neturg - nbackp;
- /*
- * In 4.2 (and 4.3) systems, there is some question about
- * what byte in a sendOOB operation is the "OOB" data.
- * To make ourselves compatible, we only send ONE byte
- * out of band, the one WE THINK should be OOB (though
- * we really have more the TCP philosophy of urgent data
- * rather than the Unix philosophy of OOB data).
- */
- if (n > 1) {
- n = send(net, nbackp, n-1, 0); /* send URGENT all by itself */
- } else {
- n = send(net, nbackp, n, MSG_OOB); /* URGENT data */
- }
- }
- }
- if (n < 0) {
- if (errno == EWOULDBLOCK || errno == EINTR)
- return;
- cleanup(0);
- }
- nbackp += n;
-#ifdef ENCRYPTION
- if (nbackp > nclearto)
- nclearto = 0;
-#endif /* ENCRYPTION */
- if (nbackp >= neturg) {
- neturg = 0;
- }
- if (nbackp == nfrontp) {
- nbackp = nfrontp = netobuf;
-#ifdef ENCRYPTION
- nclearto = 0;
-#endif /* ENCRYPTION */
- }
- return;
-} /* end of netflush */
-
-
-/*
- * writenet
- *
- * Just a handy little function to write a bit of raw data to the net.
- * It will force a transmit of the buffer if necessary
- *
- * arguments
- * ptr - A pointer to a character string to write
- * len - How many bytes to write
- */
- void
-writenet(ptr, len)
- register unsigned char *ptr;
- register int len;
-{
- /* flush buffer if no room for new data) */
- if ((&netobuf[BUFSIZ] - nfrontp) < len) {
- /* if this fails, don't worry, buffer is a little big */
- netflush();
- }
-
- memmove(nfrontp, ptr, len);
- nfrontp += len;
-
-} /* end of writenet */
-
-
-/*
- * miscellaneous functions doing a variety of little jobs follow ...
- */
-
-
- void
-fatal(f, msg)
- int f;
- char *msg;
-{
- char buf[BUFSIZ];
-
- (void) sprintf(buf, "telnetd: %s.\r\n", msg);
-#ifdef ENCRYPTION
- if (encrypt_output) {
- /*
- * Better turn off encryption first....
- * Hope it flushes...
- */
- encrypt_send_end();
- netflush();
- }
-#endif /* ENCRYPTION */
- (void) write(f, buf, (int)strlen(buf));
- sleep(1); /*XXX*/
- exit(1);
-}
-
- void
-fatalperror(f, msg)
- int f;
- char *msg;
-{
- char buf[BUFSIZ], *strerror();
-
- (void) sprintf(buf, "%s: %s", msg, strerror(errno));
- fatal(f, buf);
-}
-
-char editedhost[32];
-
- void
-edithost(pat, host)
- register char *pat;
- register char *host;
-{
- register char *res = editedhost;
-
- if (!pat)
- pat = "";
- while (*pat) {
- switch (*pat) {
-
- case '#':
- if (*host)
- host++;
- break;
-
- case '@':
- if (*host)
- *res++ = *host++;
- break;
-
- default:
- *res++ = *pat;
- break;
- }
- if (res == &editedhost[sizeof editedhost - 1]) {
- *res = '\0';
- return;
- }
- pat++;
- }
- if (*host)
- (void) strncpy(res, host,
- sizeof editedhost - (res - editedhost) -1);
- else
- *res = '\0';
- editedhost[sizeof editedhost - 1] = '\0';
-}
-
-static char *putlocation;
-
- void
-putstr(s)
- register char *s;
-{
-
- while (*s)
- putchr(*s++);
-}
-
- void
-putchr(cc)
- int cc;
-{
- *putlocation++ = cc;
-}
-
-#ifdef __FreeBSD__
-static char fmtstr[] = { "%+" };
-#else
-/*
- * This is split on two lines so that SCCS will not see the M
- * between two % signs and expand it...
- */
-static char fmtstr[] = { "%l:%M\
-%P on %A, %d %B %Y" };
-#endif
-
- void
-putf(cp, where)
- register char *cp;
- char *where;
-{
- char *slash;
- time_t t;
- char db[100];
-#ifdef STREAMSPTY
- extern char *strchr();
-#else
- extern char *strrchr();
-#endif
-#ifdef __FreeBSD__
- static struct utsname kerninfo;
-
- if (!*kerninfo.sysname)
- uname(&kerninfo);
-#endif
-
- putlocation = where;
-
- while (*cp) {
- if (*cp =='\n') {
- putstr("\r\n");
- cp++;
- continue;
- } else if (*cp != '%') {
- putchr(*cp++);
- continue;
- }
- switch (*++cp) {
-
- case 't':
-#ifdef STREAMSPTY
- /* names are like /dev/pts/2 -- we want pts/2 */
- slash = strchr(line+1, '/');
-#else
- slash = strrchr(line, '/');
-#endif
- if (slash == (char *) 0)
- putstr(line);
- else
- putstr(&slash[1]);
- break;
-
- case 'h':
- putstr(editedhost);
- break;
-
- case 'd':
-#ifdef __FreeBSD__
- setlocale(LC_TIME, "");
-#endif
- (void)time(&t);
- (void)strftime(db, sizeof(db), fmtstr, localtime(&t));
- putstr(db);
- break;
-
-#ifdef __FreeBSD__
- case 's':
- putstr(kerninfo.sysname);
- break;
-
- case 'm':
- putstr(kerninfo.machine);
- break;
-
- case 'r':
- putstr(kerninfo.release);
- break;
-
- case 'v':
- putstr(kerninfo.version);
- break;
-#endif
-
- case '%':
- putchr('%');
- break;
- }
- cp++;
- }
-}
-
-#ifdef DIAGNOSTICS
-/*
- * Print telnet options and commands in plain text, if possible.
- */
- void
-printoption(fmt, option)
- register char *fmt;
- register int option;
-{
- if (TELOPT_OK(option))
- sprintf(nfrontp, "%s %s\r\n", fmt, TELOPT(option));
- else if (TELCMD_OK(option))
- sprintf(nfrontp, "%s %s\r\n", fmt, TELCMD(option));
- else
- sprintf(nfrontp, "%s %d\r\n", fmt, option);
- nfrontp += strlen(nfrontp);
- return;
-}
-
- void
-printsub(direction, pointer, length)
- char direction; /* '<' or '>' */
- unsigned char *pointer; /* where suboption data sits */
- int length; /* length of suboption data */
-{
- register int i = 0;
-
- if (!(diagnostic & TD_OPTIONS))
- return;
-
- if (direction) {
- sprintf(nfrontp, "td: %s suboption ",
- direction == '<' ? "recv" : "send");
- nfrontp += strlen(nfrontp);
- if (length >= 3) {
- register int j;
-
- i = pointer[length-2];
- j = pointer[length-1];
-
- if (i != IAC || j != SE) {
- sprintf(nfrontp, "(terminated by ");
- nfrontp += strlen(nfrontp);
- if (TELOPT_OK(i))
- sprintf(nfrontp, "%s ", TELOPT(i));
- else if (TELCMD_OK(i))
- sprintf(nfrontp, "%s ", TELCMD(i));
- else
- sprintf(nfrontp, "%d ", i);
- nfrontp += strlen(nfrontp);
- if (TELOPT_OK(j))
- sprintf(nfrontp, "%s", TELOPT(j));
- else if (TELCMD_OK(j))
- sprintf(nfrontp, "%s", TELCMD(j));
- else
- sprintf(nfrontp, "%d", j);
- nfrontp += strlen(nfrontp);
- sprintf(nfrontp, ", not IAC SE!) ");
- nfrontp += strlen(nfrontp);
- }
- }
- length -= 2;
- }
- if (length < 1) {
- sprintf(nfrontp, "(Empty suboption??\?)");
- nfrontp += strlen(nfrontp);
- return;
- }
- switch (pointer[0]) {
- case TELOPT_TTYPE:
- sprintf(nfrontp, "TERMINAL-TYPE ");
- nfrontp += strlen(nfrontp);
- switch (pointer[1]) {
- case TELQUAL_IS:
- sprintf(nfrontp, "IS \"%.*s\"", length-2, (char *)pointer+2);
- break;
- case TELQUAL_SEND:
- sprintf(nfrontp, "SEND");
- break;
- default:
- sprintf(nfrontp,
- "- unknown qualifier %d (0x%x).",
- pointer[1], pointer[1]);
- }
- nfrontp += strlen(nfrontp);
- break;
- case TELOPT_TSPEED:
- sprintf(nfrontp, "TERMINAL-SPEED");
- nfrontp += strlen(nfrontp);
- if (length < 2) {
- sprintf(nfrontp, " (empty suboption??\?)");
- nfrontp += strlen(nfrontp);
- break;
- }
- switch (pointer[1]) {
- case TELQUAL_IS:
- sprintf(nfrontp, " IS %.*s", length-2, (char *)pointer+2);
- nfrontp += strlen(nfrontp);
- break;
- default:
- if (pointer[1] == 1)
- sprintf(nfrontp, " SEND");
- else
- sprintf(nfrontp, " %d (unknown)", pointer[1]);
- nfrontp += strlen(nfrontp);
- for (i = 2; i < length; i++) {
- sprintf(nfrontp, " ?%d?", pointer[i]);
- nfrontp += strlen(nfrontp);
- }
- break;
- }
- break;
-
- case TELOPT_LFLOW:
- sprintf(nfrontp, "TOGGLE-FLOW-CONTROL");
- nfrontp += strlen(nfrontp);
- if (length < 2) {
- sprintf(nfrontp, " (empty suboption??\?)");
- nfrontp += strlen(nfrontp);
- break;
- }
- switch (pointer[1]) {
- case LFLOW_OFF:
- sprintf(nfrontp, " OFF"); break;
- case LFLOW_ON:
- sprintf(nfrontp, " ON"); break;
- case LFLOW_RESTART_ANY:
- sprintf(nfrontp, " RESTART-ANY"); break;
- case LFLOW_RESTART_XON:
- sprintf(nfrontp, " RESTART-XON"); break;
- default:
- sprintf(nfrontp, " %d (unknown)", pointer[1]);
- }
- nfrontp += strlen(nfrontp);
- for (i = 2; i < length; i++) {
- sprintf(nfrontp, " ?%d?", pointer[i]);
- nfrontp += strlen(nfrontp);
- }
- break;
-
- case TELOPT_NAWS:
- sprintf(nfrontp, "NAWS");
- nfrontp += strlen(nfrontp);
- if (length < 2) {
- sprintf(nfrontp, " (empty suboption??\?)");
- nfrontp += strlen(nfrontp);
- break;
- }
- if (length == 2) {
- sprintf(nfrontp, " ?%d?", pointer[1]);
- nfrontp += strlen(nfrontp);
- break;
- }
- sprintf(nfrontp, " %d %d (%d)",
- pointer[1], pointer[2],
- (int)((((unsigned int)pointer[1])<<8)|((unsigned int)pointer[2])));
- nfrontp += strlen(nfrontp);
- if (length == 4) {
- sprintf(nfrontp, " ?%d?", pointer[3]);
- nfrontp += strlen(nfrontp);
- break;
- }
- sprintf(nfrontp, " %d %d (%d)",
- pointer[3], pointer[4],
- (int)((((unsigned int)pointer[3])<<8)|((unsigned int)pointer[4])));
- nfrontp += strlen(nfrontp);
- for (i = 5; i < length; i++) {
- sprintf(nfrontp, " ?%d?", pointer[i]);
- nfrontp += strlen(nfrontp);
- }
- break;
-
- case TELOPT_LINEMODE:
- sprintf(nfrontp, "LINEMODE ");
- nfrontp += strlen(nfrontp);
- if (length < 2) {
- sprintf(nfrontp, " (empty suboption??\?)");
- nfrontp += strlen(nfrontp);
- break;
- }
- switch (pointer[1]) {
- case WILL:
- sprintf(nfrontp, "WILL ");
- goto common;
- case WONT:
- sprintf(nfrontp, "WONT ");
- goto common;
- case DO:
- sprintf(nfrontp, "DO ");
- goto common;
- case DONT:
- sprintf(nfrontp, "DONT ");
- common:
- nfrontp += strlen(nfrontp);
- if (length < 3) {
- sprintf(nfrontp, "(no option??\?)");
- nfrontp += strlen(nfrontp);
- break;
- }
- switch (pointer[2]) {
- case LM_FORWARDMASK:
- sprintf(nfrontp, "Forward Mask");
- nfrontp += strlen(nfrontp);
- for (i = 3; i < length; i++) {
- sprintf(nfrontp, " %x", pointer[i]);
- nfrontp += strlen(nfrontp);
- }
- break;
- default:
- sprintf(nfrontp, "%d (unknown)", pointer[2]);
- nfrontp += strlen(nfrontp);
- for (i = 3; i < length; i++) {
- sprintf(nfrontp, " %d", pointer[i]);
- nfrontp += strlen(nfrontp);
- }
- break;
- }
- break;
-
- case LM_SLC:
- sprintf(nfrontp, "SLC");
- nfrontp += strlen(nfrontp);
- for (i = 2; i < length - 2; i += 3) {
- if (SLC_NAME_OK(pointer[i+SLC_FUNC]))
- sprintf(nfrontp, " %s", SLC_NAME(pointer[i+SLC_FUNC]));
- else
- sprintf(nfrontp, " %d", pointer[i+SLC_FUNC]);
- nfrontp += strlen(nfrontp);
- switch (pointer[i+SLC_FLAGS]&SLC_LEVELBITS) {
- case SLC_NOSUPPORT:
- sprintf(nfrontp, " NOSUPPORT"); break;
- case SLC_CANTCHANGE:
- sprintf(nfrontp, " CANTCHANGE"); break;
- case SLC_VARIABLE:
- sprintf(nfrontp, " VARIABLE"); break;
- case SLC_DEFAULT:
- sprintf(nfrontp, " DEFAULT"); break;
- }
- nfrontp += strlen(nfrontp);
- sprintf(nfrontp, "%s%s%s",
- pointer[i+SLC_FLAGS]&SLC_ACK ? "|ACK" : "",
- pointer[i+SLC_FLAGS]&SLC_FLUSHIN ? "|FLUSHIN" : "",
- pointer[i+SLC_FLAGS]&SLC_FLUSHOUT ? "|FLUSHOUT" : "");
- nfrontp += strlen(nfrontp);
- if (pointer[i+SLC_FLAGS]& ~(SLC_ACK|SLC_FLUSHIN|
- SLC_FLUSHOUT| SLC_LEVELBITS)) {
- sprintf(nfrontp, "(0x%x)", pointer[i+SLC_FLAGS]);
- nfrontp += strlen(nfrontp);
- }
- sprintf(nfrontp, " %d;", pointer[i+SLC_VALUE]);
- nfrontp += strlen(nfrontp);
- if ((pointer[i+SLC_VALUE] == IAC) &&
- (pointer[i+SLC_VALUE+1] == IAC))
- i++;
- }
- for (; i < length; i++) {
- sprintf(nfrontp, " ?%d?", pointer[i]);
- nfrontp += strlen(nfrontp);
- }
- break;
-
- case LM_MODE:
- sprintf(nfrontp, "MODE ");
- nfrontp += strlen(nfrontp);
- if (length < 3) {
- sprintf(nfrontp, "(no mode??\?)");
- nfrontp += strlen(nfrontp);
- break;
- }
- {
- char tbuf[32];
- sprintf(tbuf, "%s%s%s%s%s",
- pointer[2]&MODE_EDIT ? "|EDIT" : "",
- pointer[2]&MODE_TRAPSIG ? "|TRAPSIG" : "",
- pointer[2]&MODE_SOFT_TAB ? "|SOFT_TAB" : "",
- pointer[2]&MODE_LIT_ECHO ? "|LIT_ECHO" : "",
- pointer[2]&MODE_ACK ? "|ACK" : "");
- sprintf(nfrontp, "%s", tbuf[1] ? &tbuf[1] : "0");
- nfrontp += strlen(nfrontp);
- }
- if (pointer[2]&~(MODE_EDIT|MODE_TRAPSIG|MODE_ACK)) {
- sprintf(nfrontp, " (0x%x)", pointer[2]);
- nfrontp += strlen(nfrontp);
- }
- for (i = 3; i < length; i++) {
- sprintf(nfrontp, " ?0x%x?", pointer[i]);
- nfrontp += strlen(nfrontp);
- }
- break;
- default:
- sprintf(nfrontp, "%d (unknown)", pointer[1]);
- nfrontp += strlen(nfrontp);
- for (i = 2; i < length; i++) {
- sprintf(nfrontp, " %d", pointer[i]);
- nfrontp += strlen(nfrontp);
- }
- }
- break;
-
- case TELOPT_STATUS: {
- register char *cp;
- register int j, k;
-
- sprintf(nfrontp, "STATUS");
- nfrontp += strlen(nfrontp);
-
- switch (pointer[1]) {
- default:
- if (pointer[1] == TELQUAL_SEND)
- sprintf(nfrontp, " SEND");
- else
- sprintf(nfrontp, " %d (unknown)", pointer[1]);
- nfrontp += strlen(nfrontp);
- for (i = 2; i < length; i++) {
- sprintf(nfrontp, " ?%d?", pointer[i]);
- nfrontp += strlen(nfrontp);
- }
- break;
- case TELQUAL_IS:
- sprintf(nfrontp, " IS\r\n");
- nfrontp += strlen(nfrontp);
-
- for (i = 2; i < length; i++) {
- switch(pointer[i]) {
- case DO: cp = "DO"; goto common2;
- case DONT: cp = "DONT"; goto common2;
- case WILL: cp = "WILL"; goto common2;
- case WONT: cp = "WONT"; goto common2;
- common2:
- i++;
- if (TELOPT_OK(pointer[i]))
- sprintf(nfrontp, " %s %s", cp, TELOPT(pointer[i]));
- else
- sprintf(nfrontp, " %s %d", cp, pointer[i]);
- nfrontp += strlen(nfrontp);
-
- sprintf(nfrontp, "\r\n");
- nfrontp += strlen(nfrontp);
- break;
-
- case SB:
- sprintf(nfrontp, " SB ");
- nfrontp += strlen(nfrontp);
- i++;
- j = k = i;
- while (j < length) {
- if (pointer[j] == SE) {
- if (j+1 == length)
- break;
- if (pointer[j+1] == SE)
- j++;
- else
- break;
- }
- pointer[k++] = pointer[j++];
- }
- printsub(0, &pointer[i], k - i);
- if (i < length) {
- sprintf(nfrontp, " SE");
- nfrontp += strlen(nfrontp);
- i = j;
- } else
- i = j - 1;
-
- sprintf(nfrontp, "\r\n");
- nfrontp += strlen(nfrontp);
-
- break;
-
- default:
- sprintf(nfrontp, " %d", pointer[i]);
- nfrontp += strlen(nfrontp);
- break;
- }
- }
- break;
- }
- break;
- }
-
- case TELOPT_XDISPLOC:
- sprintf(nfrontp, "X-DISPLAY-LOCATION ");
- nfrontp += strlen(nfrontp);
- switch (pointer[1]) {
- case TELQUAL_IS:
- sprintf(nfrontp, "IS \"%.*s\"", length-2, (char *)pointer+2);
- break;
- case TELQUAL_SEND:
- sprintf(nfrontp, "SEND");
- break;
- default:
- sprintf(nfrontp, "- unknown qualifier %d (0x%x).",
- pointer[1], pointer[1]);
- }
- nfrontp += strlen(nfrontp);
- break;
-
- case TELOPT_NEW_ENVIRON:
- sprintf(nfrontp, "NEW-ENVIRON ");
- goto env_common1;
- case TELOPT_OLD_ENVIRON:
- sprintf(nfrontp, "OLD-ENVIRON");
- env_common1:
- nfrontp += strlen(nfrontp);
- switch (pointer[1]) {
- case TELQUAL_IS:
- sprintf(nfrontp, "IS ");
- goto env_common;
- case TELQUAL_SEND:
- sprintf(nfrontp, "SEND ");
- goto env_common;
- case TELQUAL_INFO:
- sprintf(nfrontp, "INFO ");
- env_common:
- nfrontp += strlen(nfrontp);
- {
- register int noquote = 2;
- for (i = 2; i < length; i++ ) {
- switch (pointer[i]) {
- case NEW_ENV_VAR:
- sprintf(nfrontp, "\" VAR " + noquote);
- nfrontp += strlen(nfrontp);
- noquote = 2;
- break;
-
- case NEW_ENV_VALUE:
- sprintf(nfrontp, "\" VALUE " + noquote);
- nfrontp += strlen(nfrontp);
- noquote = 2;
- break;
-
- case ENV_ESC:
- sprintf(nfrontp, "\" ESC " + noquote);
- nfrontp += strlen(nfrontp);
- noquote = 2;
- break;
-
- case ENV_USERVAR:
- sprintf(nfrontp, "\" USERVAR " + noquote);
- nfrontp += strlen(nfrontp);
- noquote = 2;
- break;
-
- default:
- if (isprint(pointer[i]) && pointer[i] != '"') {
- if (noquote) {
- *nfrontp++ = '"';
- noquote = 0;
- }
- *nfrontp++ = pointer[i];
- } else {
- sprintf(nfrontp, "\" %03o " + noquote,
- pointer[i]);
- nfrontp += strlen(nfrontp);
- noquote = 2;
- }
- break;
- }
- }
- if (!noquote)
- *nfrontp++ = '"';
- break;
- }
- }
- break;
-
-#if defined(AUTHENTICATION)
- case TELOPT_AUTHENTICATION:
- sprintf(nfrontp, "AUTHENTICATION");
- nfrontp += strlen(nfrontp);
-
- if (length < 2) {
- sprintf(nfrontp, " (empty suboption??\?)");
- nfrontp += strlen(nfrontp);
- break;
- }
- switch (pointer[1]) {
- case TELQUAL_REPLY:
- case TELQUAL_IS:
- sprintf(nfrontp, " %s ", (pointer[1] == TELQUAL_IS) ?
- "IS" : "REPLY");
- nfrontp += strlen(nfrontp);
- if (AUTHTYPE_NAME_OK(pointer[2]))
- sprintf(nfrontp, "%s ", AUTHTYPE_NAME(pointer[2]));
- else
- sprintf(nfrontp, "%d ", pointer[2]);
- nfrontp += strlen(nfrontp);
- if (length < 3) {
- sprintf(nfrontp, "(partial suboption??\?)");
- nfrontp += strlen(nfrontp);
- break;
- }
- sprintf(nfrontp, "%s|%s",
- ((pointer[3] & AUTH_WHO_MASK) == AUTH_WHO_CLIENT) ?
- "CLIENT" : "SERVER",
- ((pointer[3] & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL) ?
- "MUTUAL" : "ONE-WAY");
- nfrontp += strlen(nfrontp);
-
- {
- char buf[512];
- auth_printsub(&pointer[1], length - 1, buf, sizeof(buf));
- sprintf(nfrontp, "%s", buf);
- }
- nfrontp += strlen(nfrontp);
- break;
-
- case TELQUAL_SEND:
- i = 2;
- sprintf(nfrontp, " SEND ");
- nfrontp += strlen(nfrontp);
- while (i < length) {
- if (AUTHTYPE_NAME_OK(pointer[i]))
- sprintf(nfrontp, "%s ", AUTHTYPE_NAME(pointer[i]));
- else
- sprintf(nfrontp, "%d ", pointer[i]);
- nfrontp += strlen(nfrontp);
- if (++i >= length) {
- sprintf(nfrontp, "(partial suboption??\?)");
- nfrontp += strlen(nfrontp);
- break;
- }
- sprintf(nfrontp, "%s|%s ",
- ((pointer[i] & AUTH_WHO_MASK) == AUTH_WHO_CLIENT) ?
- "CLIENT" : "SERVER",
- ((pointer[i] & AUTH_HOW_MASK) == AUTH_HOW_MUTUAL) ?
- "MUTUAL" : "ONE-WAY");
- nfrontp += strlen(nfrontp);
- ++i;
- }
- break;
-
- case TELQUAL_NAME:
- i = 2;
- sprintf(nfrontp, " NAME \"");
- nfrontp += strlen(nfrontp);
- while (i < length)
- *nfrontp += pointer[i++];
- *nfrontp += '"';
- break;
-
- default:
- for (i = 2; i < length; i++) {
- sprintf(nfrontp, " ?%d?", pointer[i]);
- nfrontp += strlen(nfrontp);
- }
- break;
- }
- break;
-#endif
-
-#ifdef ENCRYPTION
- case TELOPT_ENCRYPT:
- sprintf(nfrontp, "ENCRYPT");
- nfrontp += strlen(nfrontp);
- if (length < 2) {
- sprintf(nfrontp, " (empty suboption??\?)");
- nfrontp += strlen(nfrontp);
- break;
- }
- switch (pointer[1]) {
- case ENCRYPT_START:
- sprintf(nfrontp, " START");
- nfrontp += strlen(nfrontp);
- break;
-
- case ENCRYPT_END:
- sprintf(nfrontp, " END");
- nfrontp += strlen(nfrontp);
- break;
-
- case ENCRYPT_REQSTART:
- sprintf(nfrontp, " REQUEST-START");
- nfrontp += strlen(nfrontp);
- break;
-
- case ENCRYPT_REQEND:
- sprintf(nfrontp, " REQUEST-END");
- nfrontp += strlen(nfrontp);
- break;
-
- case ENCRYPT_IS:
- case ENCRYPT_REPLY:
- sprintf(nfrontp, " %s ", (pointer[1] == ENCRYPT_IS) ?
- "IS" : "REPLY");
- nfrontp += strlen(nfrontp);
- if (length < 3) {
- sprintf(nfrontp, " (partial suboption??\?)");
- nfrontp += strlen(nfrontp);
- break;
- }
- if (ENCTYPE_NAME_OK(pointer[2]))
- sprintf(nfrontp, "%s ", ENCTYPE_NAME(pointer[2]));
- else
- sprintf(nfrontp, " %d (unknown)", pointer[2]);
- nfrontp += strlen(nfrontp);
-
- {
- char buf[512];
- encrypt_printsub(&pointer[1], length - 1, buf, sizeof(buf));
- sprintf(nfrontp, "%s", buf);
- }
- nfrontp += strlen(nfrontp);
- break;
-
- case ENCRYPT_SUPPORT:
- i = 2;
- sprintf(nfrontp, " SUPPORT ");
- nfrontp += strlen(nfrontp);
- while (i < length) {
- if (ENCTYPE_NAME_OK(pointer[i]))
- sprintf(nfrontp, "%s ", ENCTYPE_NAME(pointer[i]));
- else
- sprintf(nfrontp, "%d ", pointer[i]);
- nfrontp += strlen(nfrontp);
- i++;
- }
- break;
-
- case ENCRYPT_ENC_KEYID:
- sprintf(nfrontp, " ENC_KEYID");
- nfrontp += strlen(nfrontp);
- goto encommon;
-
- case ENCRYPT_DEC_KEYID:
- sprintf(nfrontp, " DEC_KEYID");
- nfrontp += strlen(nfrontp);
- goto encommon;
-
- default:
- sprintf(nfrontp, " %d (unknown)", pointer[1]);
- nfrontp += strlen(nfrontp);
- encommon:
- for (i = 2; i < length; i++) {
- sprintf(nfrontp, " %d", pointer[i]);
- nfrontp += strlen(nfrontp);
- }
- break;
- }
- break;
-#endif /* ENCRYPTION */
-
- default:
- if (TELOPT_OK(pointer[0]))
- sprintf(nfrontp, "%s (unknown)", TELOPT(pointer[0]));
- else
- sprintf(nfrontp, "%d (unknown)", pointer[i]);
- nfrontp += strlen(nfrontp);
- for (i = 1; i < length; i++) {
- sprintf(nfrontp, " %d", pointer[i]);
- nfrontp += strlen(nfrontp);
- }
- break;
- }
- sprintf(nfrontp, "\r\n");
- nfrontp += strlen(nfrontp);
-}
-
-/*
- * Dump a data buffer in hex and ascii to the output data stream.
- */
- void
-printdata(tag, ptr, cnt)
- register char *tag;
- register char *ptr;
- register int cnt;
-{
- register int i;
- char xbuf[30];
-
- while (cnt) {
- /* flush net output buffer if no room for new data) */
- if ((&netobuf[BUFSIZ] - nfrontp) < 80) {
- netflush();
- }
-
- /* add a line of output */
- sprintf(nfrontp, "%s: ", tag);
- nfrontp += strlen(nfrontp);
- for (i = 0; i < 20 && cnt; i++) {
- sprintf(nfrontp, "%02x", *ptr);
- nfrontp += strlen(nfrontp);
- if (isprint(*ptr)) {
- xbuf[i] = *ptr;
- } else {
- xbuf[i] = '.';
- }
- if (i % 2) {
- *nfrontp = ' ';
- nfrontp++;
- }
- cnt--;
- ptr++;
- }
- xbuf[i] = '\0';
- sprintf(nfrontp, " %s\r\n", xbuf );
- nfrontp += strlen(nfrontp);
- }
-}
-#endif /* DIAGNOSTICS */
diff --git a/etc/defaults/pccard.conf b/etc/defaults/pccard.conf
deleted file mode 100644
index bdbb00b71007..000000000000
--- a/etc/defaults/pccard.conf
+++ /dev/null
@@ -1,954 +0,0 @@
-# Sample PCCARD configuration file
-#
-# Removing all IRQ conflicts from this file can't be done because of some
-# IRQ-selfish PC-cards. So if you want to use some of these cards in
-# your machine, you will be forced to modify their IRQ parameters from
-# the following list.
-#
-# IRQ == 0 means "allocate free IRQ from IRQ pool"
-# IRQ == 16 means "do not use IRQ (e.g. PIO mode)"
-#
-# $FreeBSD$
-#
-# Send new entries for this file to imp@freebsd.org. He's volunteered
-# to act as coordinator for this file.
-#
-
-# Generally available IO ports
-io 0x240-0x360
-# Generally available IRQs (Built-in sound-card owners remove 5)
-irq 3 5 10 11 13 15
-# Available memory slots
-memory 0xd4000 96k
-
-
-# Aironet PC4500 2Mbps 802.11 wireless NIC
-card "Aironet" "PC4500"
- config 0x5 "an0" ?
- insert logger -t pccard:$device -s Aironet PC4500 inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s Aironet PC4500 removed
- remove /sbin/ifconfig $device delete
-
-# Aironet PC4800 11Mbps 802.11 wireless NIC
-card "Aironet" "PC4800"
- config 0x5 "an0" ?
- insert logger -t pccard:$device -s Aironet PC4800 inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s Aironet PC4800 removed
- remove /sbin/ifconfig $device delete
-
-# Lucent WaveLAN/IEEE
-card "Lucent Technologies" "WaveLAN/IEEE"
- config 0x1 "wi0" ?
- insert logger -t pccard:$device -s WaveLAN/IEEE inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s WaveLAN/IEEE removed
- remove /sbin/ifconfig $device delete
-
-# NCR WaveLAN/IEEE
-card "NCR" "WaveLAN/IEEE"
- config 0x1 "wi0" ?
-# config auto "wi0" ?
- insert logger -t pccard:$device -s WaveLAN/IEEE inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s WaveLAN/IEEE removed
- remove /sbin/ifconfig $device delete
-
-# Cabletron RoamAbout, WaveLAN/IEEE clone
-card "Cabletron" "RoamAbout 802.11 DS"
- config 0x1 "wi0" ?
- insert logger -t pccard:$device -s WaveLAN/IEEE inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s WaveLAN/IEEE removed
- remove /sbin/ifconfig $device delete
-
-# Socket LP-E (WinCE Low Power Ethernet)
-card "Low Power Ethernet LAN Adapter" "Socket Communications, Inc"
- config 0x20 "ed0" ?
- insert logger -t pccard:$device -s Socket LP-E inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s Socket LP-E removed
- remove /etc/pccard_ether_remove $device
-
-# CNet BC40 adapter
-card "CNet" "CN40BC Ethernet"
- config 0x20 "ed0" ?
- insert logger -t pccard:$device -s CNet CN40BC Ethernet inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s CNet CN40BC Ethernet removed
- remove /etc/pccard_ether_remove $device
-
-# LinkMates LM 336 LAN Fax/Modem PC Card
-card "PCMCIAs" "ComboCard"
- config 0x24 "ed0" ? 0x10
- insert logger -t pccard:$device -s LinkMates LM 336 inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s LinkMates LM 336 removed
- remove /sbin/ifconfig $device delete
-
-# IBM PCMCIA Ethernet I/II
-card "IBM Corp." "Ethernet"
- config 0x1 "ed0" ?
- ether 0xff0
- insert logger -t pccard:$device -s IBM PCMCIA Ethernet inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s IBM PCMCIA Ethernet removed
- remove /sbin/ifconfig $device delete
-
-# Melco LPC-T (PIO mode)
-card "PCMCIA" "UE2212"
- config 0x1 "ed0" ? 0x10
- ether 0xff0
- insert logger -t pccard:$device -s UE2212 inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s UE2212 removed
- remove /sbin/ifconfig $device delete
-
-# Billionton 10Base-TX ETHERNET PCCARD (aka UE2216)
-card "PCMCIA" "PCMCIA-ETHERNET-CARD"
- config 0x20 "ed0" ? 0x10
- insert logger -t pccard:$device -s UE2216 inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s UE2216 removed
- remove /sbin/ifconfig $device delete
-
-# Accton EN2212
-# Very slow! (PIO mode)
-card "ACCTON" "EN2212"
- config 0x1 "ed0" ? 0x10
- ether 0xff0
- insert logger -t pccard:$device -s Accton EN2212 inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s Accton EN2212 removed
- remove /sbin/ifconfig $device delete
-
-#Accton 2216
-card "ACCTON" "EN2216-PCMCIA-ETHERNET"
- config 0x20 "ed0" ?
-# config auto "ed0" ?
- insert logger -t pccard:$device -s Accton 2216 inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s Accton 2216 removed
- remove /sbin/ifconfig $device delete
-
-# COREGA EtherII PCC-T
-card "corega K.K." "corega EtherII PCC-T"
- config 0x20 "ed0" ?
-# config auto "ed0" ?
- insert logger -t pccard:$device -s EtherII PCC-T inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s EtherII PCC-T removed
- remove /sbin/ifconfig $device delete
-
-# I-O DATA PCLATE
-card "IO DATA" "PCLATE"
- config 0x20 "ed0" ? 0x10
- insert logger -t pccard:$device -s IO DATA PCLATE inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s IO DATA PCLATE removed
- remove /sbin/ifconfig $device delete
-
-# 3Com Etherlink III 3C589B, 3C589C
-card "3Com Corporation" "3C589"
- config 0x1 "ep0" ?
-# config auto "ep0" ?
- insert logger -t pccard:$device -s 3Com Etherlink III inserted
- insert /etc/pccard_ether $device -link0 link1
-# insert /etc/pccard_ether $device link0 -link1
- remove logger -t pccard:$device -s 3Com Etherlink III removed
- remove /sbin/ifconfig $device delete
-
-# 3Com Etherlink III 3C589D
-card "3Com Corporation" "3C589D"
- config 0x1 "ep0" ?
-# config auto "ep0" ?
- insert logger -t pccard:$device -s 3Com Etherlink III inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s 3Com Etherlink III removed
- remove /sbin/ifconfig $device delete
-
-# 3Com Etherlink III 3CXE589ET
-card "3Com" "Megahertz 589E"
- config 0x1 "ep0" ?
- insert logger -t pccard:$device -s 3Com 3C589E inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s 3Com 3C589E removed
- remove /sbin/ifconfig $device delete
-
-# 3Com Fast Etherlink 3C574TX
-card "3Com" "3C574-TX Fast EtherLink PC Card"
- config 0x1 "ep0" ? 0x1
- insert logger -t pccard:$device -s 3Com Fast Etherlink 3C574TX inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s 3Com Fast Etherlink 3C574TX removed
- remove /sbin/ifconfig $device delete
-
-# 3Com Megahertz 574B
-card "3Com" "Megahertz 574B"
- config 0x1 "ep0" ? 0x1
- insert logger -t pccard:$device -s 3Com Megahertz 574B inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s 3Com Megahertz 574B removed
- remove /sbin/ifconfig $device delete
-
-# LinkSys ethernet card
-card "E-CARD" "E-CARD"
- config 0x20 "ed0" ?
- insert logger -t pccard:$device -s "LinkSys card inserted"
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s "LinkSys card removed"
- remove /sbin/ifconfig $device delete
-
-# Linksys Combo PCMCIA EthernetCard (model EC2T on box)
-card "Linksys" "Combo PCMCIA EthernetCard (EC2T)"
- config 0x1 "ed0" ?
- insert logger -t pccard:$device -s Linksys Ethernet inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s Linksys Ethernet removed
- remove /sbin/ifconfig $device delete
-
-#Linksys EtherFast 10/100 PC Card (PCMPC100)
-card "Linksys" "EtherFast 10/100 PC Card (PCMPC100)"
- config 0x3 "ed0" ?
-# config auto "ed0" ?
- insert logger -t pccard:$device -s Linksys Fast 100-BaseT inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s Linksys Fast 100-BaseT removed
- remove /sbin/ifconfig $device delete
-
-# Farallon EtherMac
-card "Farallon" "ENet"
- config 0x1 "ep0" ?
- insert logger -t pccard:$device -s Farallon EtherMac inserted
- insert /etc/pccard_ether $device
-# insert /etc/pccard_ether $device link0
- remove logger -t pccard:$device -s Farallon EtherMac removed
- remove /sbin/ifconfig $device delete
-
-# Fujitsu MBH10302
-card "PCMCIA MBH10302" "01"
- config 0x14 "fe0" ?
- insert logger -t pccard:$device -s Fujitsu MBH10302 inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s Fujitsu MBH10302 removed
- remove /sbin/ifconfig $device delete
-
-# NextCom J Link NC5310
-card "NextComK.K." "NC5310 Ver1.0 "
- config 0x14 "fe0" ?
- insert logger -t pccard:$device -s NextCom J Link NC5310 inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s NextCom J Link NC5310 removed
- remove /sbin/ifconfig $device delete
-
-# HITACHI HT-4840-11
-card "HITACHI" "HT-4840-11"
- config 0x1a "fe0" ?
- insert logger -t pccard:$device -s HT-4840-11 inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s HT-4840-11 removed
- remove /sbin/ifconfig $device delete
-
-# Danpex (Alloy, etc.) EN-6200P2
-card "DANPEX" "EN-6200P2"
- config 0x22 "ed0" ?
- insert logger -t pccard:$device -s Danpex EN-6200P2 inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s Danpex EN-6200P2 removed
- remove /sbin/ifconfig $device delete
-
-# Fujitsu MBH10303 Ethernet PCMCIA
-card "EAGLE Technology" "NE200 ETHERNET LAN MBH10303 "
- config 0x1 "fe0" ?
- insert /etc/pccard_ether $device
- insert logger -t pccard:$device -s Fujitsu MBH10303 inserted
- remove /sbin/ifconfig $device delete
- remove logger -t pccard:$device -s Fujitsu MBH10303 removed
-
-# Compex Net-A adapter
-card "Ethernet" "Adapter"
- config 0x1 "ed0" ?
- ether 0xff0
- insert logger -t pccard:$device -s Compex Net-A adapter inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s Compex Net-A adapter removed
- remove /sbin/ifconfig $device delete
-
-# Telecom Device SuperSocket RE450T
-# Note: There are several revisions of the cardon the market.
-# Type A needs no "ether" line.
-# Type B needs "ether 0x110" line.
-# Type C needs "ether 0xff0" line.
-# Yet more revisions exist, reportedly.
-# If you see strange MAC address shown by ifconfig command,
-# try other config.
-card "Ethernet" "Adapter"
- config 0x2 "ed0" ?
-# ether 0x110 00:e0:98
-# ether 0xff0 00:e0:98
- insert logger -t pccard:$device -s Telecom SuperSocket RE450T inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s Telecom SuperSocket RE450T removed
- remove /sbin/ifconfig $device delete
-
-# D-Link DE-660 NE2000 clone
-card "D-Link" "DE-660"
- config 0x20 "ed0" ? 0x10
- insert logger -t pccard:$device -s D-Link DE-660 inserted
- insert /etc/pccard_ether $device link0 -link1
- remove logger -t pccard:$device -s D-Link DE-660 removed
- remove /sbin/ifconfig $device delete
-
-# D-Link DFE-650 NE2000 clone
-card "D-Link" "DFE-650"
- config 0x20 "ed0" ? 0x10
- insert logger -t pccard:$device -s D-Link DFE-650 inserted
- insert /etc/pccard_ether $device
-# insert /etc/pccard_ether $device link0 -link1
- remove logger -t pccard:$device -s D-Link DFE-650 removed
- remove /sbin/ifconfig $device delete
-
-# NDC Ethernet Instant-Link NE2000 clone
-card "NDC" "Ethernet"
- config 0x22 "ed0" ? 0x10
- insert logger -t pccard:$device -s NDC Ethernet Instant-Link adapter inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s NDC Ethernet Instant-Link adapter removed
- remove /sbin/ifconfig $device delete
-
-# CyQ've ELA-010
-card "CyQ've" "ELA-010"
- config 0x20 "ed0" ?
- insert logger -t pccard:$device -s CyQve ELA-010 inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s CyQve ELA-010 removed
- remove /sbin/ifconfig $device delete
-
-# Allied Telesis CentreCOM LA100-PCM-T V2
-card "Allied Telesis, K.K." "CentreCOM LA100-PCM-T V2 100/10M LAN PC Card"
- config auto "ed0" ?
- insert logger -t pccard:$device -s Allied Telesis LA100-PCM-T V2 inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s Allied Telesis LA100-PCM-T V2 removed
- remove /etc/pccard_ether_remove $device
-
-# Allied Telesis CentreCOM LA-PCM_V2 ethernet card
-# NTT-DATA ASTROWINK-M/MMOIL(IrLAN) ethernet card
-card "Allied Telesis, K.K." "CentreCOM LA-PCM_V2"
- config 0x20 "ed0" ?
- insert logger -t pccard:$device -s CentreCOM LA-PCM V2 Ethernet card inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s CentreCOM LA-PCM V2 Ethernet card removed
- remove /sbin/ifconfig $device delete
-
-# Intel EtherExpress PRO/100 Mobile Adapter (16-bit verison)
-card "Intel" "EtherExpress(TM) PRO/100 PC Card Mobile Adapter16"
- config 0x1 "xe0" ?
- insert logger -t pccard:$device -s Intel EtherExpress PRO/100 Mobile Adapter/16 inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s Intel EtherExpress PRO/100 Mobile Adapter/16 removed
- remove /sbin/ifconfig $device delete
-
-# BayNetworks NETGEAR FA410TXC Fast Ethernet
-card "NETGEAR" "FA410TX"
- config 0x20 "ed0" ?
- insert logger -t pccard:$device -s NETGEAR FA410TX Ethernet inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s NETGEAR FA410TX Ethernet removed
- remove /sbin/ifconfig $device delete
-
-# Network Everywhere Ethernet 10BaseT PC Card
-card "Network Everywhere" "Ethernet 10BaseT PC Card"
- config 0x1 "ed0" ?
- insert logger -t pccard:$device -s Network Everywhere Ethernet 10BaseT PC Card inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s Network Everywhere Ethernet 10BaseT PC Card removed
- remove /sbin/ifconfig $device delete
-
-
-# AIWA PV-JF288
-card "AIWA CO.,LTD." "PV-JF288 "
- config 0x23 "sio2" ?
- insert logger -t pccard:$device -s AIWA PV-JF288 inserted
- remove logger -t pccard:$device -s AIWA PV-JF288 removed
-
-# Apex Data 28.8 PC Card "MOBILE PLUS Cellular" modem.
-card "AD PC_CARD" "RC288ACL"
- config 0x22 "sio2" ?
-# config auto "sio2" ?
- insert logger -t pccard:$device -s Apex Data Mobile Plus 28.8 Modem inserted
- remove logger -t pccard:$device -s Apex Data Mobile Plus 28.8 Modem removed
-
-# Megahertz XJ1144
-card "MEGAHERTZ" "XJ1144"
- config 0x23 "sio2" ?
- insert logger -t pccard:$device -s Megahertz XJ1144 inserted
- remove logger -t pccard:$device -s Megahertz XJ1144 removed
-
-# Megahertz XJ2144 (US)
-card "MEGAHERTZ" "XJ2144"
- config 0x23 "sio2" ?
- insert logger -t pccard:$device -s Megahertz XJ2144 inserted
- remove logger -t pccard:$device -s Megahertz XJ2144 removed
-
-# Megahertz XJ2144 (JP)
-card "MEGAHERTZ" "XJ2144-81"
- config 0x23 "sio2" ?
- insert logger -t pccard:$device -s Megahertz XJ2144 inserted
- remove logger -t pccard:$device -s Megahertz XJ2144 removed
-
-# Megahertz XJ2288
-card "MEGAHERTZ" "XJ2288"
- config 0x23 "sio2" ?
- insert logger -t pccard:$device -s Megahertz XJ2288 inserted
- remove logger -t pccard:$device -s Megahertz XJ2288 removed
-
-# Megahertz XJ3288
-card "MEGAHERTZ" "XJ3288"
- config 0x21 "sio2" ?
- insert logger -t pccard:$device -s Megahertz XJ3288 inserted
- remove logger -t pccard:$device -s Megahertz XJ3288 removed
-
-# Megahertz XJ-CC4288
-card "Megahertz" "XJ-CC4288"
- config 0x23 "sio2" ?
- insert logger -t pccard:$device -s Megahertz XJ-CC4288 inserted
- remove logger -t pccard:$device -s Megahertz XJ-CC4288 removed
-
-# Megahertz XJ4336
-card "Megahertz" "XJ4336-CC4336"
- config 0x22 "sio2" ?
-# config auto "sio2" ?
-# config 0x23 "sio3" ?
- insert logger -t pccard:$device -s Megahertz XJ4336 inserted
- remove logger -t pccard:$device -s Megahertz XJ4336 removed
-
-# Megahertz XJEM1336 (as modem)
-card "MEGAHERTZ" "CC/XJEM3336"
- config auto "sio2" ?
- insert logger -t pccard:$device -s Megahertz CC/XJEM3336 inserted
- remove logger -t pccard:$device -s Megahertz CC/XJEM3336 removed
-
-# Megahertz XJ1336
-card "U.S. Robotics" "XJ/CC1336"
- config 0x21 "sio2" ?
- insert logger -t pccard:$device -s U.S. Robotics XJ/CC1336 inserted
- remove logger -t pccard:$device -s U.S. Robotics XJ/CC1336 removed
-
-# Nokia Cellular Data Card
-card "Nokia Mobile Phones" "DTP-2"
- config 0x22 "sio2" ?
- config 0x23 "sio3" ?
- insert logger -t pccard:$device -s Nokia Mobile Phones DTP-2 inserted
- remove logger -t pccard:$device -s Nokia Mobile Phones DTP-2 removed
-
-# This Nokia example allows either 1 or 2 Nokia cards to be fitted.
-# With 2 Mobile Phones and Multilink PPP you can get a 19200 data channel.
-# Nokia Cellular Data Card
-card "Nokia Mobile Phones" "DTP-2 ver II"
- config 0x23 "sio2" ?
- config 0x24 "sio3" ?
- insert logger -t pccard:$device -s Nokia Mobile Phones DTP-2 ver II inserted
- remove logger -t pccard:$device -s Nokia Mobile Phones DTP-2 ver II removed
-
-# Omron ME2814 FAX/DATA MODEM
-card "OMRON" "ME2814 FAX/DATA MOD"
- config 0x23 "sio2" ?
- insert logger -t pccard:$device -s OMRON ME2814 Modem inserted
- remove logger -t pccard:$device -s OMRON ME2814 Modem removed
-
-# TDK 14.4 FAX/Data Modem
-card "TDK" "DF1414 DATA/FAX MOD"
- config 0x23 "sio2" ?
- insert logger -t pccard:$device -s TDK DF1414 inserted
- remove logger -t pccard:$device -s TDK DF1414 removed
-
-# TDK 14.4 FAX/Data Modem
-card "TDK" "DF1414EX DATA/FAX M"
- config 0x23 "sio2" ?
- insert logger -t pccard:$device -s TDK DF1414 inserted
- remove logger -t pccard:$device -s TDK DF1414 removed
-
-# Panasonic Modem Card TO-706C
-card "Panasonic" "TO-706C"
- config 0x23 "sio2" ?
- insert logger -t pccard:$device -s Panasonic TO-706C inserted
- remove logger -t pccard:$device -s Panasonic TO-706C removed
-
-# Panasonic Modem Card TO-706C
-card "Panasonic" "TO-CAF288"
- config 0x23 "sio2" ?
- insert logger -t pccard:$device -s Panasonic TO-CAF288 inserted
- remove logger -t pccard:$device -s Panasonic TO-CAF288 removed
-
-# NewMedia 14.4K FAX/Data Modem
-card "CIRRUS LOGIC" "FAX MODEM"
- config 0x23 "sio2" ?
- insert logger -t pccard:$device -s Newmedia 14.4 Modem inserted
- remove logger -t pccard:$device -s Newmedia 14.4 Modem removed
-
-# Omron MD24XCA FAX/Data Modem
-#card "OMRON Corp." "MD24XCA"
-# config 0x23 "sio2" ?
-# reset 10000
-# insert logger -t pccard:$device -s OMRON MD24XCA Modem inserted
-# remove logger -t pccard:$device -s OMRON MD24XCA Modem removed
-
-# Hayes OPTIMA 288 FAX/Data Modem
-# currently does not work on my machine
-card "Hayes" "OPTIMA 288 + FAX fo"
- config 0x24 "sio2" ?
- reset 10000
- insert logger -t pccard:$device -s Optima 288 inserted
- remove logger -t pccard:$device -s Optima 288 removed
-
-# This one does work though
-card "HAYES" "OPT288"
- config 0x23 "sio3" ?
- insert logger -t pccard:$device -s Hayes Optima 28.8k inserted
- remove logger -t pccard:$device -s Hayes Optima 28.8k removed
-
-# PREMAX FM288 FAX/Data Modem
-card "PREMAX" "FM288 "
- config 0x23 "sio2" ?
- insert logger -t pccard:$device -s PREMAX FM288 Modem inserted
- remove logger -t pccard:$device -s PREMAX FM288 Modem removed
-
-# Novalink NovaModem 144
-card "NovaLink Tech." "NovaModem 144 "
- config 0x23 "sio2" ?
- insert logger -t pccard:$device -s NovaModem 144 Modem inserted
- remove logger -t pccard:$device -s NovaModem 144 Modem removed
-
-# Option International PCMCIA55K06
-card "Option International" "GSM Data/Fax/SMS Modem"
- config 0x22 "sio2" ?
- insert logger -t pccard:$device -s Option 55K06 Modem inserted
- remove logger -t pccard:$device -s Option 55K06 Modem removed
-
-# US Robotics Sportster PCMCIA V.34
-# US Robotics COURIER PCMCIA V.34
-card "USRobotics" "PCMCIA 28800 Data/F"
- config 0x3 "sio2" ?
- insert logger -t pccard:$device -s USRobotics PCMCIA Modem inserted
- remove logger -t pccard:$device -s USRobotics PCMCIA Modem removed
-
-# Xircom CreditCard Modem
-card "Xircom" "CreditCard Modem CM-56T"
- config 0x17 "sio1" ?
- reset 100
- insert logger -t pccard:$device -s Xircom CreditCard Modem CM-56T inserted
- remove logger -t pccard:$device -s Xircom CreditCard Modem CM-56T removed
-
-# Xircom CreditCard Ethernet+Modem (Modem only !!!)
-card "Xircom" "CreditCard Ethernet"
- config 0x23 "sio2" ?
- insert logger -t pccard:$device -s Xircom CreditCard Modem inserted
- remove logger -t pccard:$device -s Xircom CreditCard Modem removed
-
-# Xircom CreditCard Ethernet 10/100 + modem (modem part)
-card "Xircom" "CreditCard Ethernet+Modem 33.6"
- config 0x23 "sio2" ?
- insert logger -t pccard:$device -s Xircom CreditCard Modem inserted
- remove logger -t pccard:$device -s Xircom CreditCard Modem removed
-
-# Xircom CreditCard Ethernet 10/100 + modem (Ethernet part)
-card "Xircom" "CreditCard Ethernet 10/100 + Modem 56"
- config 0x1 "xe0" ?
- insert logger -t pccard:$device -s Xircom CreditCard Modem inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s Xircom CreditCard Modem removed
- remove /sbin/ifconfig $device delete
-
-# Xircom CreditCard Ethernet 10/100
-card "Xircom" "CreditCard 10/100"
- config 0x1 "xe0" ?
- insert logger -t pccard:$device -s Xircom CreditCard Ethernet inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s Xircom CreditCard Ethernet removed
- remove /etc/pccard_ether $device delete
-
-# Xircom GlobalACCESS modem
-card "Xircom" "CreditCard Modem 56 - GlobalA"
- config 0x1f "sio2" ?
- insert logger -t pccard:$device -s Xircom CreditCard Modem 56 - GlobalACCESS inserted
- remove logger -t pccard:$device -s Xircom CreditCard Modem 56 - GlobalACCESS removed
-
-# Xircom Realport card + modem
-card "Xircom" "16-bit Ethernet + Modem 56"
- config 0x27 "xe0" 9
- insert logger -t pccard:$device -s Xircom Realport Ethernet inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s Xircom Realport Ethernet removed
- remove /etc/pccard_ether $device delete
-
-# GATEWAY 2000 FAX/Data Modem (14.4K)
-card "GATEWAY2000" "CC3144"
- config 0x22 "sio3" ?
- insert logger -t pccard:$device -s GATEWAY2000 FAX/Data Modem inserted
- remove logger -t pccard:$device -s GATEWAY2000 FAX/Data Modem removed
-
-# IBM Push/Pop Modem (14.4K)
-card "IBM" "Push/Pop Modem(14.4K)"
- config 0x22 "sio2" ?
- insert logger -t pccard:$device -s IBM Push/Pop Modem inserted
- remove logger -t pccard:$device -s IBM Push/Pop Modem removed
-
-# Eiger PCCARD modem
-# Apparently this modem does not work unless the recommended
-# init string (AT&F&C1&D2) is supplied.
-card "PCMCIA " "33.6K Fax/Modem "
- config 23 "sio2" ?
- insert logger -t pccard:$device -s Eiger 33.6K modem inserted
- remove logger -t pccard:$device -s Eiger 33.6K modem removed
-
-# NTT ThunderCard Modem
-card "NTT-IT CO., LTD" "ThunderCard AVF288, V.34"
- config 0x22 "sio2" ?
- insert logger -t pccard:$device -s NTT ThunderCard inserted
- remove logger -t pccard:$device -s NTT ThunderCard removed
-
-# U.S. Robotics XJ1560J
-card "U.S. Robotics" "XJ/CC1560J"
- config 0x22 "sio2" ?
- insert logger -t pccard:$device -s U.S. Robotics XJ1560J inserted
- remove logger -t pccard:$device -s U.S. Robotics XJ1560J removed
-
-# 3com/USR/Megahertz 3CCM556
-card "3Com" "3CXM/3CCM556"
- config 0x23 "sio2" ?
- insert logger -t pccard:$device -s 3Com PCMCIA 56K Modem inserted
- remove logger -t pccard:$device -s 3Com PCMCIA 56K Modem removed
-
-# 3Com/NoteWorthy 56K modem (bundled with Toshiba notebooks)
-card "Toshiba America" "3CXM056-BNW"
- config 0x20 "sio1" ?
- insert logger -t pccard:$device -s NoteWorthy 56K PCMCIA Modem inserted
- remove logger -t pccard:$device -s NoteWorthy 56K PCMCIA Modem removed
-
-# BUG Linkboy D64K (ISDN)
-card "BUG Inc." "Linkboy D64K"
- config 0x23 "sio2" ?
- insert logger -t pccard:$device -s BUG Linkboy D64K inserted
- remove logger -t pccard:$device -s BUG Linkboy D64K removed
-
-# NTT DoCoMo DATA/FAX Adapter
-card "NTT DoCoMo" "PCMCIA DATA/FAX ADAPTER 9600"
- config 0x22 "sio3" ? 0x82
- insert logger -t pccard:$device -s NTT DoCoMo DATA/FAX Adapter inserted
- remove logger -t pccard:$device -s NTT DoCoMo DATA/FAX Adapter removed
-
-# NTT DoCoMo DATA/FAX Adapter
-card "NTT DoCoMo" "PCMCIA DATA/FAX ADAPTER 9600 Mark2"
- config auto "sio3" ?
- insert logger -t pccard:$device -s NTT DoCoMo DATA/FAX Adapter inserted
- remove logger -t pccard:$device -s NTT DoCoMo DATA/FAX Adapter removed
-
-# NTT DoCoMo Mobile D Card 96P1
-card "NTT DoCoMo" "Mobile D Card 96P1"
-# config 0x22 "sio2" ? 0x82
- config 0x23 "sio3" ? 0x82
-# config auto "sio3" ? 0x82
- insert logger -t pccard:$device -s NTT DoCoMo Mobile D Card 96P1 inserted
- remove logger -t pccard:$device -s NTT DoCoMo Mobile D Card 96P1 removed
-
-# Random modem bundled with Dell systems
-card "Psion Dacom" "Gold Card Global 56K+Fax"
- config 0x23 "sio2" ?
- insert logger -t pccard:$device -s "Psion Dacom modem card inserted"
- remove logger -t pccard:$device -s "Psion Dacom modem card removed"
-
-# Actiontec Datalink with v.90 upgrade
-card "PCMCIA " "56K V.90 Fax Modem (LK) "
- config 0x1f "sio2" ?
- insert logger -t pccard:$device -s "Actiontec Datalink modem card inserted"
- remove logger -t pccard:$device -s "Actiontec Datalink modem card removed"
-
-# Panasonic FM-RADIO card
-#card "Panasonic" "CF-JVR101"
-# config 0x22 "sio3" ?
-# insert logger -t pccard:$device -s Panasonic FM radio card inserted
-# remove logger -t pccard:$device -s Panasonic FM radio card removed
-
-# IO Data CBIDE (bundled with CDP-FX24, etc.)
-card "WIT" "IDE16"
- config auto "ata0" ?
- insert logger -t pccard:$device -s IO Data CBIDE inserted
- remove logger -t pccard:$device -s IO Data CBIDE removed
-
-# IBM Flash ATA (Ricoh Flash ATA 10MB)
-card "IBM" "IBM17JSSFP10"
- config auto "ata0" ? iosize 16
- insert logger -t pccard:$device -s IBM Flash ATA inserted
- remove logger -t pccard:$device -s IBM flash ATA removed
-
-# Non-brand Compact Flash Card(32MB)
-card " " "KCF 32M"
- config 0x1 "ata2" ? iosize 16
- insert logger -t pccard:$device -s Compact Flash Card 32MB inserted
- remove logger -t pccard:$device -s Compact Flash Card 32MB removed
-
-# SunDisk Flash ATA
-# (OEM: Epson Flash Packer)
-card "SunDisk" "SDP5"
- config 0x1 "ata2" ?
- insert logger -t pccard:$device -s Sundisk Flash ATA inserted
- remove logger -t pccard:$device -s Sundisk Flash ATA removed
-
-card "SunDisk" "SDP"
- config 0x1 "ata2" ?
- insert logger -t pccard:$device -s SunDisk Flash ATA Inserted
- remove logger -t pccard:$device -s SunDisk Flash ATA removed
-
-# Midori Elec Fast Flash
-card "Midori Elec." "FAST FLASH"
- config 0x3 "ata2" ?
- insert logger -t pccard:$device -s Midori Elec Fast FLASH inserted
- remove logger -t pccard:$device -s Midori Elec Fast FLASH removed
-
-# Simple Technology ata flash
-card "Simple Technology " "STI-ATA"
- config 0x2 "ata2" ?
- insert logger -t pccard:$device -s Simple Technology ata FLASH inserted
- remove logger -t pccard:$device -s Simple Technology ata FLASH removed
-
-# Viking ATA Flash card
-card "VIKING ATA/CF FLASH CARD " "TOR/AM "
- config 0x2 "ata2" ?
- insert logger -t pccard:$device -s Simple Technology ata FLASH inserted
- remove logger -t pccard:$device -s Simple Technology ata FLASH removed
-
-# Maxtor 131MB Type III HDD
-card "Maxtor" "MXL131"
- config 0x03 "ata2" ?
- insert logger -t pccard:$device -s Maxtor 131MB HDD inserted
- remove logger -t pccard:$device -s Maxtor 131MB HDD removed
-
-# SiliconTech, Inc flash card
-card "SiliconTech,Inc" "16MB Compact PC Card"
- config 0x1 "ata2" ?
- insert logger -t pccard:$device -s SiliconTech Flash ATA inserted
- remove logger -t pccard:$device -s SiliconTech Flash ATA removed
-
-# Adaptec SlimSCSI (also included with Sony CD-ROM players)
-card "Adaptec, Inc." "APA-1460 SCSI Host Adapter"
- config 0x9 "aic0" ?
- insert logger -t pccard:$device -s Adaptec Slim SCSI inserted
- remove logger -t pccard:$device -s Adaptec Slim SCSI removed
-
-# NewMedia Bustoaster SCSI
-card "New Media" "SCSI"
- config 0x22 "aic0" ?
- insert logger -t pccard:$device -s New Media Bus Toaster inserted
- remove logger -t pccard:$device -s New Media Bus Toaster removed
-
-# REX5535AC, REX5535X SCSI
-#card "PCMCIA SCSI MBH1040" "01"
-# config 0x3a "spc0" ?
-# insert logger -t pccard:$device -s REX-5535 SCSI card inserted
-# remove logger -t pccard:$device -s REX-5535 SCSI card removed
-
-# Libretto Floppy disk
-card "Y-E DATA" "External FDD"
- config 0x4 "fdc0" ?
- insert logger -t pccard:$device -s Libretto Floopy Disk inserted
- remove logger -t pccard:$device -s Libretto Floopy Disk removed
-
-# Viking V.90/K56Flex modem
-card "Viking" "V.90 K56flex"
- config 0x23 "sio3" ?
- insert logger -t pccard:$device -s Viking 56K Modem inserted
- remove logger -t pccard:$device -s Viking 56K Modem removed
-
-# Zoom 56K modem
-# Freezes your system entirely if you don't have the reset..
-card "Zoom Telephonics, Inc." "PCMCIA 56K LT DataFax"
- config 0x1f "sio2" ?
- reset 1000
- insert logger -t pccard:$device -s Zoom modem inserted
- remove logger -t pccard:$device -s Zoom modem removed
-
-# 3Com Megahertz 3CCE589E* 10 Mbps LAN PC Card
-card "3Com" "Megahertz 589E"
- config 0x1 "ep0" ?
-# config auto "ep0" ?
- insert logger -t pccard:$device -s 3Com Megahertz Ethernet card inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s 3Com Megahertz Ethernet card removed
- remove /sbin/ifconfig $device delete
-
-#AR-P500 ethernet card
-card "IC-CARD" "IC-CARD"
- config 0x20 "ed0" ?
- insert logger -t pccard:$device -s AR-P500 Ethernet card inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s AR-P500 Ethernet card removed
- remove ifconfig $device delete
-
-# 3Com/USR/MegaHertz 3CCM156
-card "3COM" "3CCM156"
- config 0x23 "sio2" ?
- insert logger -t pccard:$device -s 3Com PCMCIA 56K modem inserted
- remove logger -t pccard:$device -s 3Com PCMCIA 56K modem removed
-
-#Eiger 33.6 modem
-card "AT&T" "V34+ Fax Modem"
- config 0x23 "sio1" ?
- insert logger -t pccard:$device -s Eiger 33.6K modem inserted
- remove logger -t pccard:$device -s Eiger 33.6K modem removed
-
-# Motorola Montana
-card "Motorola" "MONTANA 33.6 FAX/MODEM"
- config 0x21 "sio1" ?
- insert echo Motorola Montana 33.6K FAX/modem inserted
- remove echo Motorola Montana 33.6K FAX/modem removed
-
-# AT&T Paradyne KeepInTouch 14.4 modem
-card "AT&T Paradyne" "KeepInTouch Card"
- config 0x23 "sio3" ?
- reset 1000
- insert logger -t pccard:$device -s ATT Paradyne 14.4 inserted
- remove logger -t pccard:$device -s ATT Paradyne 14.4 removed
-
-# AmbiCom 10BaseT card
-card "AmbiCom Inc" "AMB8002T"
- config 0x20 "ed0" ?
- insert logger -t pccard:$device -s AmbiCom 8002T inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s AmbiCom 8002T removed
- remove /sbin/ifconfig $device delete
-
-# 3Com OfficeConnect 3CXSH572BT
-#This had auto, so the config slot might be wrong. Replace it by the
-#one that pccardc dumpcis tells you is default.
-#
-card "3Com" "OfficeConnect 572B"
- config 0x1 "ep0" ? 0x1
- insert logger -t pccard:$device -s 3Com 3CXSH572BT inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s 3Com 3CXSH572BT removed
- remove /sbin/ifconfig $device delete
-
-# Elecom Laneed LD-CDF
-card "Laneed" "LD-CDF"
- config 0x20 "ed1" ?
- insert logger -t pccard:$device -s Elecom Laneed LD-CDF inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s Elecom Laneed LD-CDF removed
- remove /sbin/ifconfig $device delete
-
-# NTT DoCoMo (formerly NTT Personal) FAX/Data 32K PHS Card Paldio 321S
-card "NTT Personal" "32K Paldio 321S PC CARD"
- config 0x23 "sio2" ?
- insert logger -t pccard:$device -s NTT Personal Paldio 321S PC Card inserted
- remove logger -t pccard:$device -s NTT Personal Paldio 321S PC Card removed
-
-# NTT DoCoMo (formerly NTT Personal) FAX/Data 32K PHS Card Paldio 341S
-card "NTT Personal" "32K Paldio 341S PC CARD"
- config 0x23 "sio2" ?
- insert logger -t pccard:$device -s NTT Personal 32K Paldio 341S PC Card inserted
- remove logger -t pccard:$device -s NTT Personal 32K Paldio 341S PC Card removed
-
-# Allied Telesis Ethernet Card inserted
-card "Allied Telesis,K.K" "Ethernet LAN Card"
- config 0x1 "ed1" ? 0x10
- ether 0xff0
- insert logger -t pccard:$device -s Allied Telesis Ethernet Card inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s Allied Telesis Ethernet Card removed
- remove /sbin/ifconfig $device delete
-
-# Panasonic KX-PH402D
-card "Panasonic" "KX-PH402D"
- config 0x23 "sio4" ?
- insert logger -t pccard:$device -s Panasonic KX-PH402D inserted
- remove logger -t pccard:$device -s Panasonic KX-PH402D removed
-
-# Megahertz X-Jack Ethernet
-card "Megahertz" "CC10BT/2"
- config 0x1 "sn0" ?
- ether attr2
- insert logger -t pccard:$device -s Megahertz X-Jack Ethernet inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s Megahertz X-Jack Ethernet removed
- remove /etc/pccard_ether_remove $device
-
-# Surecom EtherPerfect EP-427
-card "TAMARACK" "Ethernet"
- config 0x21 "ed0" ?
- insert logger -t pccard:$device -s Surecom Ethernet card inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s Surecom Ethernet card removed
- remove ifconfig $device delete
-
-# COREGA Ether PCC-T
-card "corega K.K." "corega Ether PCC-T"
- config 0x20 "ed0" ?
-# config auto "ed0" ?
- insert logger -t pccard:$device -s Ether PCC-T inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s Ether PCC-T removed
- remove /etc/pccard_ether_remove $device
-
-# Planex FNW-3600-T 16bit FastEthernet
-card "Fast Ethernet" "Adapter"
- config 0x7 "ed0" ?
- iosize 32
- insert logger -t pccard:$device -s Planex FNW-3600-T inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s Planex FNW-3600-T removed
- remove /etc/pccard_ether_remove $device
-
-# IC-CARD+ Ethernet card
-card "IC-CARD+" "IC-CARD+"
- config auto "ed0" ?
- insert logger -t pccard:$device -s IC-CARD+ Ethernet card inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s IC-CARD+ Ethernet card removed
- remove ifconfig $device delete
-
-# Banksia CardModem 56
-card "PCCardModem" "CardModem 56"
- config 0x22 "sio3" ?
- insert logger -t pccard:$device -s Banksia CardModem 56 inserted
- remove logger -t pccard:$device -s Banksia CardModem 56 removed
-
-# Apollo PCMCIA Ethernet Adapter
-card "Ethernet" "Adapter"
- config 0x0 "ed0" ?
- insert logger -t pccard:$device -s Apollo PCMCIA Ethernet Adapter inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s Apollo PCMCIA Ethernet Adapter removed
- remove /sbin/ifconfig $device delete
-
-# Olicom OC2220
-card "Olicom" "Ethernet"
- config 0x1 "ex0" ?
- insert logger -t pccard:$device -s Olicom OC2220 inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s Olicom OC2220 removed
- remove /sbin/ifconfig $device delete
-
-# National Semiconductor InfoMover NE4100
-card "National Semiconductor" "InfoMover NE4100"
- config 0x1 "ed0" ?
- ether 0xff0
- insert logger -t pccard:$device -s National Semiconductor InfoMover NE4100 inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s National Semiconductor InfoMover NE4100 removed
- remove /sbin/ifconfig $device delete
-
-# Melco Airconnect
-card "MELCO" "WLI-PCM-L11"
- config 0x1 "wi0" ?
-
-# COM1 SA
-card "COM1 SA" "MC220 CARD"
- config 0x3 "sio2" ?
- insert logger -t pccard:$device -s COM1 SA MC220 CARD Modem inserted
- remove logger -t pccard:$device -s COM1 SA MC220 CARD Modem removed
- insert logger -t pccard:$device -s Melco Airconnect inserted
- insert /etc/pccard_ether $device
- remove logger -t pccard:$device -s Melco Airconnect removed
- remove /sbin/ifconfig $device delete
diff --git a/etc/disktab b/etc/disktab
deleted file mode 100644
index c426b449b471..000000000000
--- a/etc/disktab
+++ /dev/null
@@ -1,224 +0,0 @@
-# $FreeBSD$
-#
-# Disk geometry and partition layout tables.
-# Key:
-# dt controller type
-# ty type of disk (fixed, removeable, simulated)
-# d[0-4] drive-type-dependent parameters
-# ns #sectors/track
-# nt #tracks/cylinder
-# nc #cylinders/disk
-# sc #sectors/cylinder, ns*nt default
-# su #sectors/unit, sc*nc default
-# se sector size, DEV_BSIZE default
-# rm rpm, 3600 default
-# sf supports bad144-style bad sector forwarding
-# sk sector skew per track, default 0
-# cs sector skew per cylinder, default 0
-# hs headswitch time, default 0
-# ts one-cylinder seek time, default 0
-# il sector interleave (n:1), 1 default
-# bs boot block size, default BBSIZE
-# sb superblock size, default SBSIZE
-# o[a-h] partition offsets in sectors
-# p[a-h] partition sizes in sectors
-# b[a-h] partition block sizes in bytes
-# f[a-h] partition fragment sizes in bytes
-# t[a-h] partition types (filesystem, swap, etc)
-#
-# All partition sizes reserve space for bad sector tables.
-# (5 cylinders needed for maintenance + replacement sectors)
-#
-
-#
-# Floppy formats:
-#
-# To make a filesystem on a floppy:
-# fdformat [-f <size>] fd<drive>[.<size>]
-# disklabel -B -r -w fd<drive>[.<size>] fd<size>
-# newfs <opts> fd<drive>[.<size>]
-#
-# with <opts>:
-# -t 2 - two heads
-# -u 9|15|18 - sectors per track
-# (using the default value of 1/4096 is not much useful for floppies)
-# -l 1 - interleave 1 (for most floppies)
-# -i 65536 - bytes of data per i-node
-# (the default -i value will render you with a floppy wasting way
-# too much space in i-node areas)
-#
-
-fd360:\
- :ty=floppy:se#512:nt#2:rm#300:ns#9:nc#40:\
- :pa#720:oa#0:ba#4096:fa#512:\
- :pb#720:ob#0:bb#4096:fb#512:\
- :pc#720:oc#0:bc#4096:fc#512:
-
-fd720:\
- :ty=floppy:se#512:nt#2:rm#300:ns#9:nc#80:\
- :pa#1440:oa#0:ba#4096:fa#512:\
- :pb#1440:ob#0:bb#4096:fb#512:\
- :pc#1440:oc#0:bc#4096:fc#512:
-
-fd1200|floppy5|5in|5.25in High Density Floppy:\
- :ty=floppy:se#512:nt#2:rm#360:ns#15:nc#80:\
- :pa#2400:oa#0:ba#4096:fa#512:\
- :pb#2400:ob#0:bb#4096:fb#512:\
- :pc#2400:oc#0:bc#4096:fc#512:
-
-fd1440|floppy|floppy3|3in|3.5in High Density Floppy:\
- :ty=floppy:se#512:nt#2:rm#300:ns#18:nc#80:\
- :pa#2880:oa#0:ba#4096:fa#512:\
- :pb#2880:ob#0:bb#4096:fb#512:\
- :pc#2880:oc#0:bc#4096:fc#512:
-
-#
-# Stressed floppy-formats. No guarantees given.
-#
-
-fd800:\
- :ty=floppy:se#512:nt#2:rm#300:ns#10:nc#80:\
- :pa#1600:oa#0:ba#4096:fa#512:\
- :pb#1600:ob#0:bb#4096:fb#512:\
- :pc#1600:oc#0:bc#4096:fc#512:
-
-fd820:\
- :ty=floppy:se#512:nt#2:rm#300:ns#10:nc#82:\
- :pa#1640:oa#0:ba#4096:fa#512:\
- :pb#1640:ob#0:bb#4096:fb#512:\
- :pc#1640:oc#0:bc#4096:fc#512:
-
-fd1480:\
- :ty=floppy:se#512:nt#2:rm#300:ns#18:nc#82:\
- :pa#2952:oa#0:ba#4096:fa#512:\
- :pb#2952:ob#0:bb#4096:fb#512:\
- :pc#2952:oc#0:bc#4096:fc#512:
-
-fd1720:\
- :ty=floppy:se#512:nt#2:rm#300:ns#21:nc#82:\
- :pa#3444:oa#0:ba#4096:fa#512:\
- :pb#3444:ob#0:bb#4096:fb#512:\
- :pc#3444:oc#0:bc#4096:fc#512:
-
-#
-# LS-120 floppy-format.
-#
-fd120m|floppy120|floppy120m|3.5in LS-120 Floppy:\
- :ty=floppy:se#512:nt#8:rm#300:ns#32:nc#963:\
- :pa#246528:oa#0:ba#4096:fa#512:\
- :pb#246528:ob#0:bb#4096:fb#512:\
- :pc#246528:oc#0:bc#4096:fc#512:
-
-#
-# Harddisk formats
-#
-qp120at|Quantum Peripherals 120MB IDE:\
- :dt=ESDI:ty=winchester:se#512:nt#9:ns#32:nc#813:sf: \
- :pa#13824:oa#0:ta=4.2BSD:ba#4096:fa#512: \
- :pb#13824:ob#13824:tb=swap: \
- :pc#234144:oc#0: \
- :ph#206496:oh#27648:th=4.2BSD:bh#4096:fh#512:
-
-pan60|Panasonic Laptop's 60MB IDE:\
- :dt=ST506:ty=winchester:se#512:nt#13:ns#17:nc#565:\
- :pa#13260:oa#0:ta=4.2BSD:ba#4096:fa#512:\
- :pb#13260:ob#13260:tb=swap: \
- :pc#124865:oc#0: \
- :ph#97682:oh#26520:th=4.2BSD:bh#4096:fh#512:
-
-mk156|toshiba156|Toshiba MK156 156Mb:\
- :dt=SCSI:ty=winchester:se#512:nt#10:ns#35:nc#825:\
- :pa#15748:oa#0:ba#4096:fa#512:ta=4.2BSD:\
- :pb#15748:ob#15748:tb=swap:\
- :pc#288750:oc#0:\
- :ph#257250:oh#31500:bh#4096:fh#512:th=4.2BSD:
-
-cp3100|Connor Peripherals 100MB IDE:\
- :dt=ST506:ty=winchester:se#512:nt#8:ns#33:nc#766: \
- :pa#12144:oa#0:ta=4.2BSD:ba#4096:fa#512: \
- :pb#12144:ob#12144:tb=swap: \
- :pc#202224:oc#0: \
- :ph#177936:oh#24288:th=4.2BSD:bh#4096:fh#512:
-
-# a == root
-# b == swap
-# c == d == whole disk
-# e == /var
-# f == scratch
-# h == /usr
-
-cp3100new|Connor Peripherals 100MB IDE, with a different configuration:\
- :dt=ST506:ty=winchester:se#512:nt#8:ns#33:nc#766: \
- :pa#15840:oa#0:ta=4.2BSD:ba#4096:fa#512: \
- :pb#24288:ob#15840:tb=swap: \
- :pc#202224:oc#0: \
- :pd#202224:od#0: \
- :pe#15840:oe#40128:te=4.2BSD:be#4096:fe#512: \
- :pg#15840:og#55968:tg=4.2BSD:bg#4096:fg#512: \
- :ph#130416:oh#71808:th=4.2BSD:bh#4096:fh#512:
-
-maxtor4380|Maxtor XT4380E ESDI :\
- :dt=ESDI:ty=winchester:se#512:nt#15:ns#36:nc#1222:sf: \
- :pa#21600:oa#0:ta=4.2BSD:ba#4096:fa#512:\
- :pb#21600:ob#21600:tb=swap: \
- :pc#659880:oc#0: \
- :pd#216000:od#53200:td=4.2BSD:bd#4096:fd#512: \
- :ph#398520:oh#269200:th=4.2BSD:bh#4096:fh#512:
-
-miniscribe9380|compaq38|Miniscribe 9380 ESDI :\
- :ty=winchester:dt=ESDI:se#512:nt#15:ns#35:nc#1223:rm#3600:sf: \
- :pa#21000:oa#0:ba#8192:fa#1024:ta=4.2BSD: \
- :pb#42000:ob#21000:tb=swap: \
- :pc#642075:oc#0: \
- :pd#21000:od#63000:bd#8192:fd#1024:td=4.2BSD: \
- :ph#556500:oh#84000:bh#8192:fh#1024:th=4.2BSD:
-
-ida4|compaq88|Compaq IDA (4 drives) :\
- :ty=winchester:dt=IDA:se#512:nt#16:ns#63:nc#1644:rm#3600:\
- :pa#20160:oa#0:ba#8192:fa#1024:ta=4.2BSD: \
- :pb#80640:ob#20160:tb=swap: \
- :pc#1659168:oc#0: \
- :pd#201600:od#100800:bd#8192:fd#1024:td=4.2BSD: \
- :pe#20160:oe#1310400:be#8192:fe#1024:te=4.2BSD: \
- :ph#1008000:oh#302400:bh#8192:fh#1024:th=4.2BSD: \
- :pg#302400:og#1330560:bg#4096:fg#512:tg=4.2BSD:
-
-fuji513|Fujitsu M22XXXX: \
- :ty=winchester:dt=ESDI:se#512:nt#16:ns#63:nc#954:rm#3600:\
- :pa#20160:oa#82656:ba#4096:fa#512:ta=4.2BSD: \
- :pb#40320:ob#102816:tb=swap: \
- :pc#961632:oc#0: \
- :ph#656208:oh#143136:bh#4096:fh#512:th=4.2BSD:
-
-sony650|Sony 650 MB MOD|\
- :ty=removable:dt=SCSI:se#512:nt#1:ns#31:nc#18600:ts#1:rm#4800:\
- :pc#576600:oc#0:\
- :pa#576600:oa#0:ta=4.2BSD:ba#8192:fa#1024:
-
-mta3230|mo230|IBM MTA-3230 230 Meg 3.5inch Magneto-Optical:\
- :ty=removeable:dt=SCSI:rm#3600:\
- :se#512:nt#64:ns#32:nc#216:sc#2048:su#444384:\
- :pa#444384:oa#0:ba#4096:fa#0:ta=4.2BSD:\
- :pc#444384:oc#0:
-
-minimum:ty=mfs:se#512:nt#1:rm#300:\
- :ns#2880:nc#1:\
- :pa#2880:oa#0:ba#4096:fa#512:\
- :pc#2880:oc#0:bc#4096:fc#512:
-
-minimum2:ty=mfs:se#512:nt#1:rm#300:\
- :ns#5760:nc#1:\
- :pa#5760:oa#0:ba#4096:fa#512:\
- :pc#5760:oc#0:bc#4096:fc#512:
-
-zip100|zip 100:\
- :ty=removable:se#512:nc#96:nt#64:ns#32:\
- :pa#196608:oa#0:ba#4096:fa#512:\
- :pb#196608:ob#0:bb#4096:fb#512:\
- :pc#196608:oc#0:bc#4096:fc#512:
-
-orb2200|orb22|orb:\
- :ty=removable:ns#63:nt#128:nc#4273:sc#1008:su#4307184:se#512:\
- :pa#4307184:oa#0:ba#8192:fa#1024:\
- :pc#4307184:oc#0:bc#8192:fc#1024:
-
diff --git a/etc/etc.amd64/rc.amd64 b/etc/etc.amd64/rc.amd64
deleted file mode 100644
index dd72e80894c0..000000000000
--- a/etc/etc.amd64/rc.amd64
+++ /dev/null
@@ -1,225 +0,0 @@
-#!/bin/sh -
-#
-# $FreeBSD$
-# Do i386 specific processing
-#
-
-echo -n 'Initial rc.i386 initialization:'
-
-case ${apm_enable} in
-[Yy][Ee][Ss])
- echo -n ' apm'
- apm -e enable > /dev/null 2>&1
- APM_DONE=yes
- ;;
-esac
-
-case ${apmd_enable} in
-[Yy][Ee][Ss])
- case ${APM_DONE} in
- '')
- echo -n ' apm'
- apm -e enable > /dev/null 2>&1
- ;;
- esac
-
- echo -n ' apmd'; apmd ${apmd_flags}
- ;;
-esac
-
-# Start the SCO binary emulation if requested.
-#
-case ${ibcs2_enable} in
-[Yy][Ee][Ss])
- echo -n ' ibcs2'; ibcs2 > /dev/null 2>&1
- ;;
-esac
-
-# Start the Linux binary compatibility if requested.
-#
-case ${linux_enable} in
-[Yy][Ee][Ss])
- echo -n ' linux'; linux > /dev/null 2>&1
- ;;
-esac
-
-# Start the SysVR4 binary emulation if requested.
-#
-case ${svr4_enable} in
-[Yy][Ee][Ss])
- echo -n ' svr4'; svr4 > /dev/null 2>&1
- ;;
-esac
-
-case ${xtend_enable} in
-[Yy][Ee][Ss])
- echo -n ' xtend'; /usr/libexec/xtend
- ;;
-esac
-
-echo '.'
-
-##########################################################################
-####### Syscons section ########
-##########################################################################
-
-# stdin must be redirected because it might be for a serial console
-#
-kbddev=/dev/ttyv0
-viddev=/dev/ttyv0
-
-echo -n "rc.i386 configuring syscons:"
-
-# keymap
-#
-case ${keymap} in
-[Nn][Oo] | '')
- ;;
-*)
- echo -n ' keymap'; kbdcontrol < ${kbddev} -l ${keymap}
- ;;
-esac
-
-# keyrate
-#
-case ${keyrate} in
-[Nn][Oo] | '')
- ;;
-*)
- echo -n ' keyrate'; kbdcontrol < ${kbddev} -r ${keyrate}
- ;;
-esac
-
-# keybell
-#
-case ${keybell} in
-[Nn][Oo] | '')
- ;;
-*)
- echo -n ' keybell'; kbdcontrol < ${kbddev} -b ${keybell}
- ;;
-esac
-
-# change function keys
-#
-case ${keychange} in
-[Nn][Oo] | '')
- ;;
-*)
- echo -n " keychange"
- set - ${keychange}
- while [ $# -gt 0 ]; do
- kbdcontrol <${kbddev} -f "$1" "$2"
- shift; shift
- done
- ;;
-esac
-
-# cursor type
-#
-case ${cursor} in
-[Nn][Oo] | '')
- ;;
-*)
- echo -n ' cursor'; vidcontrol < ${viddev} -c ${cursor}
- ;;
-esac
-
-# screen mapping
-#
-case ${scrnmap} in
-[Nn][Oo] | '')
- ;;
-*)
- echo -n ' screen_map'; vidcontrol < ${viddev} -l ${scrnmap}
- ;;
-esac
-
-# font 8x16
-#
-case ${font8x16} in
-[Nn][Oo] | '')
- ;;
-*)
- echo -n ' font8x16'; vidcontrol < ${viddev} -f 8x16 ${font8x16}
- ;;
-esac
-
-# font 8x14
-#
-case ${font8x14} in
-[Nn][Oo] | '')
- ;;
-*)
- echo -n ' font8x14'; vidcontrol < ${viddev} -f 8x14 ${font8x14}
- ;;
-esac
-
-# font 8x8
-#
-case ${font8x8} in
-[Nn][Oo] | '')
- ;;
-*)
- echo -n ' font8x8'; vidcontrol < ${viddev} -f 8x8 ${font8x8}
- ;;
-esac
-
-# blank time
-#
-case ${blanktime} in
-[Nn][Oo] | '')
- ;;
-*)
- echo -n ' blank_time'; vidcontrol < ${viddev} -t ${blanktime}
- ;;
-esac
-
-# screen saver
-#
-case ${saver} in
-[Nn][Oo] | '')
- ;;
-*)
- echo -n ' screensaver'
- for i in `kldstat | awk '$5 ~ "^splash_.*$" { print $5 }'`; do
- kldunload ${i}
- done
- kldstat -v | grep -q _saver || kldload ${saver}_saver
- ;;
-esac
-
-# mouse daemon
-#
-case ${moused_enable} in
-[Yy][Ee][Ss])
- echo -n ' moused'
- moused ${moused_flags} -p ${moused_port} -t ${moused_type}
- vidcontrol < ${viddev} -m on
- ;;
-esac
-
-# set this mode for all virtual screens
-#
-if [ -n "${allscreens_flags}" ]; then
- echo -n ' allscreens'
- for ttyv in /dev/ttyv*; do
- vidcontrol ${allscreens_flags} < ${ttyv} > ${ttyv} 2>&1
- done
-fi
-
-echo '.'
-
-# interrupts for /dev/random device
-#
-case ${rand_irqs} in
-[Nn][Oo] | '')
- ;;
-*)
- echo -n 'entropy IRQs:'
- for irq in ${rand_irqs}; do
- echo -n " ${irq}" && rndcontrol -q -s ${irq}
- done
- echo '.'
- ;;
-esac
diff --git a/etc/etc.amd64/ttys b/etc/etc.amd64/ttys
deleted file mode 100644
index c38b0f0dc4b7..000000000000
--- a/etc/etc.amd64/ttys
+++ /dev/null
@@ -1,305 +0,0 @@
-#
-# $FreeBSD$
-# @(#)ttys 5.1 (Berkeley) 4/17/89
-#
-# This file specifies various information about terminals on the system.
-# It is used by several different programs. Common entries for the
-# various columns include:
-#
-# name The name of the terminal device.
-#
-# getty The program to start running on the terminal. Typically a
-# getty program, as the name implies. Other common entries
-# include none, when no getty is needed, and xdm, to start the
-# X Window System.
-#
-# type The initial terminal type for this port. For hardwired
-# terminal lines, this will contain the type of terminal used.
-# For virtual consoles, the correct type is cons25. Other
-# common values include network for network connections on
-# pseudo-terminals, dialup for incoming modem ports, and unknown
-# when the terminal type cannot be predetermined.
-#
-# status Must be on or off. If on, init will run the getty program on
-# the specified port. If the word "secure" appears, this tty
-# allows root login.
-#
-# name getty type status comments
-#
-# If console is marked "insecure", then init will ask for the root password
-# when going to single-user mode.
-console none unknown off secure
-#
-ttyv0 "/usr/libexec/getty Pc" cons25 on secure
-# Virtual terminals
-ttyv1 "/usr/libexec/getty Pc" cons25 on secure
-ttyv2 "/usr/libexec/getty Pc" cons25 on secure
-ttyv3 "/usr/libexec/getty Pc" cons25 on secure
-ttyv4 "/usr/libexec/getty Pc" cons25 on secure
-ttyv5 "/usr/libexec/getty Pc" cons25 on secure
-ttyv6 "/usr/libexec/getty Pc" cons25 on secure
-ttyv7 "/usr/libexec/getty Pc" cons25 on secure
-ttyv8 "/usr/X11R6/bin/xdm -nodaemon" xterm off secure
-# Serial terminals
-# The 'dialup' keyword identifies dialin lines to login, fingerd etc.
-ttyd0 "/usr/libexec/getty std.9600" dialup off secure
-ttyd1 "/usr/libexec/getty std.9600" dialup off secure
-ttyd2 "/usr/libexec/getty std.9600" dialup off secure
-ttyd3 "/usr/libexec/getty std.9600" dialup off secure
-# Pseudo terminals
-ttyp0 none network
-ttyp1 none network
-ttyp2 none network
-ttyp3 none network
-ttyp4 none network
-ttyp5 none network
-ttyp6 none network
-ttyp7 none network
-ttyp8 none network
-ttyp9 none network
-ttypa none network
-ttypb none network
-ttypc none network
-ttypd none network
-ttype none network
-ttypf none network
-ttypg none network
-ttyph none network
-ttypi none network
-ttypj none network
-ttypk none network
-ttypl none network
-ttypm none network
-ttypn none network
-ttypo none network
-ttypp none network
-ttypq none network
-ttypr none network
-ttyps none network
-ttypt none network
-ttypu none network
-ttypv none network
-ttyq0 none network
-ttyq1 none network
-ttyq2 none network
-ttyq3 none network
-ttyq4 none network
-ttyq5 none network
-ttyq6 none network
-ttyq7 none network
-ttyq8 none network
-ttyq9 none network
-ttyqa none network
-ttyqb none network
-ttyqc none network
-ttyqd none network
-ttyqe none network
-ttyqf none network
-ttyqg none network
-ttyqh none network
-ttyqi none network
-ttyqj none network
-ttyqk none network
-ttyql none network
-ttyqm none network
-ttyqn none network
-ttyqo none network
-ttyqp none network
-ttyqq none network
-ttyqr none network
-ttyqs none network
-ttyqt none network
-ttyqu none network
-ttyqv none network
-ttyr0 none network
-ttyr1 none network
-ttyr2 none network
-ttyr3 none network
-ttyr4 none network
-ttyr5 none network
-ttyr6 none network
-ttyr7 none network
-ttyr8 none network
-ttyr9 none network
-ttyra none network
-ttyrb none network
-ttyrc none network
-ttyrd none network
-ttyre none network
-ttyrf none network
-ttyrg none network
-ttyrh none network
-ttyri none network
-ttyrj none network
-ttyrk none network
-ttyrl none network
-ttyrm none network
-ttyrn none network
-ttyro none network
-ttyrp none network
-ttyrq none network
-ttyrr none network
-ttyrs none network
-ttyrt none network
-ttyru none network
-ttyrv none network
-ttys0 none network
-ttys1 none network
-ttys2 none network
-ttys3 none network
-ttys4 none network
-ttys5 none network
-ttys6 none network
-ttys7 none network
-ttys8 none network
-ttys9 none network
-ttysa none network
-ttysb none network
-ttysc none network
-ttysd none network
-ttyse none network
-ttysf none network
-ttysg none network
-ttysh none network
-ttysi none network
-ttysj none network
-ttysk none network
-ttysl none network
-ttysm none network
-ttysn none network
-ttyso none network
-ttysp none network
-ttysq none network
-ttysr none network
-ttyss none network
-ttyst none network
-ttysu none network
-ttysv none network
-ttyP0 none network
-ttyP1 none network
-ttyP2 none network
-ttyP3 none network
-ttyP4 none network
-ttyP5 none network
-ttyP6 none network
-ttyP7 none network
-ttyP8 none network
-ttyP9 none network
-ttyPa none network
-ttyPb none network
-ttyPc none network
-ttyPd none network
-ttyPe none network
-ttyPf none network
-ttyPg none network
-ttyPh none network
-ttyPi none network
-ttyPj none network
-ttyPk none network
-ttyPl none network
-ttyPm none network
-ttyPn none network
-ttyPo none network
-ttyPp none network
-ttyPq none network
-ttyPr none network
-ttyPs none network
-ttyPt none network
-ttyPu none network
-ttyPv none network
-ttyQ0 none network
-ttyQ1 none network
-ttyQ2 none network
-ttyQ3 none network
-ttyQ4 none network
-ttyQ5 none network
-ttyQ6 none network
-ttyQ7 none network
-ttyQ8 none network
-ttyQ9 none network
-ttyQa none network
-ttyQb none network
-ttyQc none network
-ttyQd none network
-ttyQe none network
-ttyQf none network
-ttyQg none network
-ttyQh none network
-ttyQi none network
-ttyQj none network
-ttyQk none network
-ttyQl none network
-ttyQm none network
-ttyQn none network
-ttyQo none network
-ttyQp none network
-ttyQq none network
-ttyQr none network
-ttyQs none network
-ttyQt none network
-ttyQu none network
-ttyQv none network
-ttyR0 none network
-ttyR1 none network
-ttyR2 none network
-ttyR3 none network
-ttyR4 none network
-ttyR5 none network
-ttyR6 none network
-ttyR7 none network
-ttyR8 none network
-ttyR9 none network
-ttyRa none network
-ttyRb none network
-ttyRc none network
-ttyRd none network
-ttyRe none network
-ttyRf none network
-ttyRg none network
-ttyRh none network
-ttyRi none network
-ttyRj none network
-ttyRk none network
-ttyRl none network
-ttyRm none network
-ttyRn none network
-ttyRo none network
-ttyRp none network
-ttyRq none network
-ttyRr none network
-ttyRs none network
-ttyRt none network
-ttyRu none network
-ttyRv none network
-ttyS0 none network
-ttyS1 none network
-ttyS2 none network
-ttyS3 none network
-ttyS4 none network
-ttyS5 none network
-ttyS6 none network
-ttyS7 none network
-ttyS8 none network
-ttyS9 none network
-ttySa none network
-ttySb none network
-ttySc none network
-ttySd none network
-ttySe none network
-ttySf none network
-ttySg none network
-ttySh none network
-ttySi none network
-ttySj none network
-ttySk none network
-ttySl none network
-ttySm none network
-ttySn none network
-ttySo none network
-ttySp none network
-ttySq none network
-ttySr none network
-ttySs none network
-ttySt none network
-ttySu none network
-ttySv none network
diff --git a/etc/mtree/BSD.x11-4.dist b/etc/mtree/BSD.x11-4.dist
deleted file mode 100644
index fd0527a000fe..000000000000
--- a/etc/mtree/BSD.x11-4.dist
+++ /dev/null
@@ -1,292 +0,0 @@
-# $FreeBSD$
-#
-# Please see the file README before making changes to this file.
-#
-
-/set type=dir uname=root gname=wheel mode=0755
-.
- bin
- ..
- etc
- rc.d
- ..
- ..
- include
- X11
- ICE
- ..
- PEX5
- ..
- PM
- ..
- SM
- ..
- Xaw
- ..
- Xmu
- ..
- bitmaps
- ..
- extensions
- ..
- fonts
- ..
- pixmaps
- ..
- ..
- ..
- info
- ..
- lib
- X11
- XF86Setup
- pics
- ..
- scripts
- ..
- tcllib
- ..
- ..
- app-defaults
- ..
- config
- ..
- doc
- ..
- etc
- ..
- fonts
- 100dpi
- ..
- 75dpi
- ..
- PEX
- ..
- Speedo
- ..
- Type1
- ..
- cyrillic
- ..
- local
- ..
- misc
- ..
- ..
- fs
- ..
- lbxproxy
- ..
- locale
- C
- ..
- en_US.utf
- ..
- iso8859-1
- ..
- iso8859-2
- ..
- iso8859-3
- ..
- iso8859-4
- ..
- iso8859-5
- ..
- iso8859-6
- ..
- iso8859-7
- ..
- iso8859-8
- ..
- iso8859-9
- ..
- ja
- ..
- ja.JIS
- ..
- ja.SJIS
- ..
- ko
- ..
- koi8-r
- ..
- tbl_data
- ..
- th_TH.TACTIS
- ..
- zh
- ..
- zh_TW
- ..
- ..
- proxymngr
- ..
- rstart
- commands
- x11r6
- ..
- ..
- contexts
- ..
- ..
- twm
- ..
- x11perfcomp
- ..
- xdm
- ..
- xinit
- ..
- xkb
- compat
- ..
- compiled
- ..
- geometry
- digital
- ..
- sgi
- ..
- ..
- keycodes
- digital
- ..
- sgi
- ..
- ..
- keymap
- digital
- ..
- sgi
- ..
- sun
- ..
- ..
- rules
- ..
- semantics
- ..
- symbols
- digital
- ..
- fujitsu
- ..
- nec
- ..
- sony
- ..
- sun
- ..
- ..
- ..
- xserver
- ..
- xsm
- ..
- ..
- modules
- ..
- ..
- libexec
- ..
- man
-/set type=dir uname=man gname=wheel mode=0755
- cat1
- ..
- cat2
- ..
- cat3
- ..
- cat4
- ..
- cat5
- ..
- cat6
- ..
- cat7
- ..
- cat8
- ..
- cat9
- ..
- catl
- ..
- catn
- ..
- ja uname=root
- cat1
- ..
- cat2
- ..
- cat3
- ..
- cat4
- ..
- cat5
- ..
- cat6
- ..
- cat7
- ..
- cat8
- ..
- cat9
- ..
- catl
- ..
- catn
- ..
-/set type=dir uname=root gname=wheel mode=0755
- man1
- ..
- man2
- ..
- man3
- ..
- man4
- ..
- man5
- ..
- man6
- ..
- man7
- ..
- man8
- ..
- man9
- ..
- manl
- ..
- mann
- ..
- ..
- man1
- ..
- man2
- ..
- man3
- ..
- man4
- ..
- man5
- ..
- man6
- ..
- man7
- ..
- man8
- ..
- man9
- ..
- manl
- ..
- mann
- ..
- ..
- share
- doc
- ..
- examples
- ..
- ..
-..
diff --git a/etc/network.subr b/etc/network.subr
deleted file mode 100644
index 0211181f0516..000000000000
--- a/etc/network.subr
+++ /dev/null
@@ -1,633 +0,0 @@
-#!/bin/sh -
-#
-# $FreeBSD$
-# From: @(#)netstart 5.9 (Berkeley) 3/30/91
-
-# Note that almost all of the user-configurable behavior is no longer in
-# this file, but rather in /etc/defaults/rc.conf. Please check that file
-# first before contemplating any changes here. If you do need to change
-# this file for some reason, we would like to know about it.
-
-# First pass startup stuff.
-#
-network_pass1() {
- echo -n 'Doing initial network setup:'
-
- # Set the host name if it is not already set
- #
- if [ -z "`hostname -s`" ]; then
- hostname ${hostname}
- echo -n ' hostname'
- fi
-
- # Set the domainname if we're using NIS
- #
- case ${nisdomainname} in
- [Nn][Oo] | '')
- ;;
- *)
- domainname ${nisdomainname}
- echo -n ' domain'
- ;;
- esac
-
- echo '.'
-
- # Initial ATM interface configuration
- #
- case ${atm_enable} in
- [Yy][Ee][Ss])
- if [ -r /etc/rc.atm ]; then
- . /etc/rc.atm
- atm_pass1
- fi
- ;;
- esac
-
- # Special options for sppp(4) interfaces go here. These need
- # to go _before_ the general ifconfig section, since in the case
- # of hardwired (no link1 flag) but required authentication, you
- # cannot pass auth parameters down to the already running interface.
- #
- for ifn in ${sppp_interfaces}; do
- eval spppcontrol_args=\$spppconfig_${ifn}
- if [ -n "${spppcontrol_args}" ]; then
- # The auth secrets might contain spaces; in order
- # to retain the quotation, we need to eval them
- # here.
- eval spppcontrol ${ifn} ${spppcontrol_args}
- fi
- done
-
- # Set up all the network interfaces, calling startup scripts if needed
- #
- case ${network_interfaces} in
- [Aa][Uu][Tt][Oo])
- network_interfaces="`ifconfig -l`"
- ;;
- esac
-
- dhcp_interfaces=""
- for ifn in ${network_interfaces}; do
- if [ -r /etc/start_if.${ifn} ]; then
- . /etc/start_if.${ifn}
- eval showstat_$ifn=1
- fi
-
- # Do the primary ifconfig if specified
- #
- eval ifconfig_args=\$ifconfig_${ifn}
-
- case ${ifconfig_args} in
- '')
- ;;
- [Dd][Hh][Cc][Pp])
- # DHCP inits are done all in one go below
- dhcp_interfaces="$dhcp_interfaces $ifn"
- eval showstat_$ifn=1
- ;;
- *)
- ifconfig ${ifn} ${ifconfig_args}
- eval showstat_$ifn=1
- ;;
- esac
- done
-
- if [ ! -z "${dhcp_interfaces}" ]; then
- ${dhcp_program:-/sbin/dhclient} ${dhcp_flags} ${dhcp_interfaces}
- fi
-
- for ifn in ${network_interfaces}; do
- # Check to see if aliases need to be added
- #
- alias=0
- while : ; do
- eval ifconfig_args=\$ifconfig_${ifn}_alias${alias}
- if [ -n "${ifconfig_args}" ]; then
- ifconfig ${ifn} ${ifconfig_args} alias
- eval showstat_$ifn=1
- alias=`expr ${alias} + 1`
- else
- break;
- fi
- done
-
- # Do ipx address if specified
- #
- eval ifconfig_args=\$ifconfig_${ifn}_ipx
- if [ -n "${ifconfig_args}" ]; then
- ifconfig ${ifn} ${ifconfig_args}
- eval showstat_$ifn=1
- fi
- done
-
- for ifn in ${network_interfaces}; do
- eval showstat=\$showstat_${ifn}
- if [ ! -z ${showstat} ]; then
- ifconfig ${ifn}
- fi
- done
-
- # ISDN subsystem startup
- #
- case ${isdn_enable} in
- [Yy][Ee][Ss])
- if [ -r /etc/rc.isdn ]; then
- . /etc/rc.isdn
- fi
- ;;
- esac
-
- # Warm up user ppp if required, must happen before natd.
- #
- case ${ppp_enable} in
- [Yy][Ee][Ss])
- # Establish ppp mode.
- #
- if [ "${ppp_mode}" != "ddial" -a "${ppp_mode}" != "direct" \
- -a "${ppp_mode}" != "dedicated" \
- -a "${ppp_mode}" != "background" ]; then
- ppp_mode="auto";
- fi
-
- ppp_command="-${ppp_mode} ";
-
- # Switch on alias mode?
- #
- case ${ppp_nat} in
- [Yy][Ee][Ss])
- ppp_command="${ppp_command} -nat";
- ;;
- esac
-
- echo -n 'Starting ppp: '; ppp ${ppp_command} -quiet ${ppp_profile}
- ;;
- esac
-
- # Initialize IP filtering using ipfw
- #
- echo ''
-
- if /sbin/ipfw -q flush > /dev/null 2>&1; then
- firewall_in_kernel=1
- else
- firewall_in_kernel=0
- fi
-
- case ${firewall_enable} in
- [Yy][Ee][Ss])
- if [ "${firewall_in_kernel}" -eq 0 ] && kldload ipfw; then
- firewall_in_kernel=1
- echo "Kernel firewall module loaded."
- elif [ "${firewall_in_kernel}" -eq 0 ]; then
- echo "Warning: firewall kernel module failed to load."
- fi
- ;;
- esac
-
- # Load the filters if required
- #
- case ${firewall_in_kernel} in
- 1)
- if [ -z "${firewall_script}" ]; then
- firewall_script=/etc/rc.firewall
- fi
-
- case ${firewall_enable} in
- [Yy][Ee][Ss])
- if [ -r "${firewall_script}" ]; then
- . "${firewall_script}"
- echo -n 'Firewall rules loaded, starting divert daemons:'
-
- # Network Address Translation daemon
- #
- case ${natd_enable} in
- [Yy][Ee][Ss])
- if [ -n "${natd_interface}" ]; then
- if echo ${natd_interface} | \
- grep -q -E '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$'; then
- natd_ifarg="-a ${natd_interface}"
- else
- natd_ifarg="-n ${natd_interface}"
- fi
-
- echo -n ' natd'; ${natd_program:-/sbin/natd} ${natd_flags} ${natd_ifarg}
- fi
- ;;
- esac
-
- echo '.'
-
- elif [ "`ipfw l 65535`" = "65535 deny ip from any to any" ]; then
- echo -n "Warning: kernel has firewall functionality, "
- echo "but firewall rules are not enabled."
- echo " All ip services are disabled."
- fi
- ;;
- esac
- ;;
- esac
-
- # Additional ATM interface configuration
- #
- if [ -n "${atm_pass1_done}" ]; then
- atm_pass2
- fi
-
- # Configure routing
- #
- case ${defaultrouter} in
- [Nn][Oo] | '')
- ;;
- *)
- static_routes="default ${static_routes}"
- route_default="default ${defaultrouter}"
- ;;
- esac
-
- # Set up any static routes. This should be done before router discovery.
- #
- if [ -n "${static_routes}" ]; then
- for i in ${static_routes}; do
- eval route_args=\$route_${i}
- route add ${route_args}
- done
- fi
-
- echo -n 'Additional routing options:'
- case ${tcp_extensions} in
- [Yy][Ee][Ss] | '')
- ;;
- *)
- echo -n ' tcp extensions=NO'
- sysctl -w net.inet.tcp.rfc1323=0 >/dev/null
- ;;
- esac
-
- case ${icmp_bmcastecho} in
- [Yy][Ee][Ss])
- echo -n ' broadcast ping responses=YES'
- sysctl -w net.inet.icmp.bmcastecho=1 >/dev/null
- ;;
- esac
-
- case ${icmp_drop_redirect} in
- [Yy][Ee][Ss])
- echo -n ' ignore ICMP redirect=YES'
- sysctl -w net.inet.icmp.drop_redirect=1 >/dev/null
- ;;
- esac
-
- case ${icmp_log_redirect} in
- [Yy][Ee][Ss])
- echo -n ' log ICMP redirect=YES'
- sysctl -w net.inet.icmp.log_redirect=1 >/dev/null
- ;;
- esac
-
- case ${gateway_enable} in
- [Yy][Ee][Ss])
- echo -n ' IP gateway=YES'
- sysctl -w net.inet.ip.forwarding=1 >/dev/null
- ;;
- esac
-
- case ${forward_sourceroute} in
- [Yy][Ee][Ss])
- echo -n ' do source routing=YES'
- sysctl -w net.inet.ip.sourceroute=1 >/dev/null
- ;;
- esac
-
- case ${accept_sourceroute} in
- [Yy][Ee][Ss])
- echo -n ' accept source routing=YES'
- sysctl -w net.inet.ip.accept_sourceroute=1 >/dev/null
- ;;
- esac
-
- case ${tcp_keepalive} in
- [Yy][Ee][Ss])
- echo -n ' TCP keepalive=YES'
- sysctl -w net.inet.tcp.always_keepalive=1 >/dev/null
- ;;
- esac
-
- case ${tcp_restrict_rst} in
- [Yy][Ee][Ss])
- echo -n ' restrict TCP reset=YES'
- sysctl -w net.inet.tcp.restrict_rst=1 >/dev/null
- ;;
- esac
-
- case ${tcp_drop_synfin} in
- [Yy][Ee][Ss])
- echo -n ' drop SYN+FIN packets=YES'
- sysctl -w net.inet.tcp.drop_synfin=1 >/dev/null
- ;;
- esac
-
- case ${ipxgateway_enable} in
- [Yy][Ee][Ss])
- echo -n ' IPX gateway=YES'
- sysctl -w net.ipx.ipx.ipxforwarding=1 >/dev/null
- ;;
- esac
-
- case ${arpproxy_all} in
- [Yy][Ee][Ss])
- echo -n ' ARP proxyall=YES'
- sysctl -w net.link.ether.inet.proxyall=1 >/dev/null
- ;;
- esac
- echo '.'
-
- echo -n 'routing daemons:'
- case ${router_enable} in
- [Yy][Ee][Ss])
- echo -n " ${router}"; ${router} ${router_flags}
- ;;
- esac
-
- case ${ipxrouted_enable} in
- [Yy][Ee][Ss])
- echo -n ' IPXrouted'
- IPXrouted ${ipxrouted_flags} > /dev/null 2>&1
- ;;
- esac
-
- case ${mrouted_enable} in
- [Yy][Ee][Ss])
- echo -n ' mrouted'; mrouted ${mrouted_flags}
- ;;
- esac
-
- case ${rarpd_enable} in
- [Yy][Ee][Ss])
- echo -n ' rarpd'; rarpd ${rarpd_flags}
- ;;
- esac
- echo '.'
-
- # Let future generations know we made it.
- #
- network_pass1_done=YES
-}
-
-network_pass2() {
- echo -n 'Doing additional network setup:'
- case ${named_enable} in
- [Yy][Ee][Ss])
- echo -n ' named'; ${named_program:-named} ${named_flags}
- ;;
- esac
-
- case ${ntpdate_enable} in
- [Yy][Ee][Ss])
- echo -n ' ntpdate'
- ${ntpdate_program:-ntpdate} ${ntpdate_flags} >/dev/null 2>&1
- ;;
- esac
-
- case ${xntpd_enable} in
- [Yy][Ee][Ss])
- echo -n ' ntpd'; ${xntpd_program:-ntpd} ${xntpd_flags}
- ;;
- esac
-
- case ${timed_enable} in
- [Yy][Ee][Ss])
- echo -n ' timed'; timed ${timed_flags}
- ;;
- esac
-
- case ${portmap_enable} in
- [Yy][Ee][Ss])
- echo -n ' portmap'; ${portmap_program:-/usr/sbin/portmap} ${portmap_flags}
- ;;
- esac
-
- # Start ypserv if we're an NIS server.
- # Run rpc.ypxfrd and rpc.yppasswdd only on the NIS master server.
- #
- case ${nis_server_enable} in
- [Yy][Ee][Ss])
- echo -n ' ypserv'; ypserv ${nis_server_flags}
-
- case ${nis_ypxfrd_enable} in
- [Yy][Ee][Ss])
- echo -n ' rpc.ypxfrd'
- rpc.ypxfrd ${nis_ypxfrd_flags}
- ;;
- esac
-
- case ${nis_yppasswdd_enable} in
- [Yy][Ee][Ss])
- echo -n ' rpc.yppasswdd'
- rpc.yppasswdd ${nis_yppasswdd_flags}
- ;;
- esac
- ;;
- esac
-
- # Start ypbind if we're an NIS client
- #
- case ${nis_client_enable} in
- [Yy][Ee][Ss])
- echo -n ' ypbind'; ypbind ${nis_client_flags}
- case ${nis_ypset_enable} in
- [Yy][Ee][Ss])
- echo -n ' ypset'; ypset ${nis_ypset_flags}
- ;;
- esac
- ;;
- esac
-
- # Start keyserv if we are running Secure RPC
- #
- case ${keyserv_enable} in
- [Yy][Ee][Ss])
- echo -n ' keyserv'; keyserv ${keyserv_flags}
- ;;
- esac
-
- # Start ypupdated if we are running Secure RPC and we are NIS master
- #
- case ${rpc_ypupdated_enable} in
- [Yy][Ee][Ss])
- echo -n ' rpc.ypupdated'; rpc.ypupdated
- ;;
- esac
-
- # Start ATM daemons
- if [ -n "${atm_pass2_done}" ]; then
- atm_pass3
- fi
-
- echo '.'
- network_pass2_done=YES
-}
-
-network_pass3() {
- echo -n 'Starting final network daemons:'
-
- case ${nfs_server_enable} in
- [Yy][Ee][Ss])
- if [ -r /etc/exports ]; then
- echo -n ' mountd'
-
- case ${weak_mountd_authentication} in
- [Yy][Ee][Ss])
- mountd_flags="-n"
- ;;
- esac
-
- mountd ${mountd_flags}
-
- case ${nfs_reserved_port_only} in
- [Yy][Ee][Ss])
- echo -n ' NFS on reserved port only=YES'
- sysctl -w vfs.nfs.nfs_privport=1 >/dev/null
- ;;
- esac
-
- echo -n ' nfsd'; nfsd ${nfs_server_flags}
-
- case ${rpc_lockd_enable} in
- [Yy][Ee][Ss])
- echo -n ' rpc.lockd'; rpc.lockd
- ;;
- esac
-
- case ${rpc_statd_enable} in
- [Yy][Ee][Ss])
- echo -n ' rpc.statd'; rpc.statd
- ;;
- esac
- fi
- ;;
- *)
- case ${single_mountd_enable} in
- [Yy][Ee][Ss])
- if [ -r /etc/exports ]; then
- echo -n ' mountd'
-
- case ${weak_mountd_authentication} in
- [Yy][Ee][Ss])
- mountd_flags="-n"
- ;;
- esac
-
- mountd ${mountd_flags}
- fi
- ;;
- esac
- ;;
- esac
-
- case ${nfs_client_enable} in
- [Yy][Ee][Ss])
- echo -n ' nfsiod'; nfsiod ${nfs_client_flags}
- if [ -n "${nfs_access_cache}" ]; then
- echo -n " NFS access cache time=${nfs_access_cache}"
- sysctl -w vfs.nfs.access_cache_timeout=${nfs_access_cache} \
- >/dev/null
- fi
- ;;
- esac
-
- # If /var/db/mounttab exists, some nfs-server has not been
- # sucessfully notified about a previous client shutdown.
- # If there is no /var/db/mounttab, we do nothing.
- if [ -f /var/db/mounttab ]; then
- rpc.umntall -k
- fi
-
- case ${amd_enable} in
- [Yy][Ee][Ss])
- echo -n ' amd'
- case ${amd_map_program} in
- [Nn][Oo] | '')
- ;;
- *)
- amd_flags="${amd_flags} `eval ${amd_map_program}`"
- ;;
- esac
-
- if [ -n "${amd_flags}" ]; then
- amd -p ${amd_flags} > /var/run/amd.pid 2> /dev/null
- else
- amd 2> /dev/null
- fi
- ;;
- esac
-
- case ${rwhod_enable} in
- [Yy][Ee][Ss])
- echo -n ' rwhod'; rwhod ${rwhod_flags}
- ;;
- esac
-
- # Kerberos runs ONLY on the Kerberos server machine
- case ${kerberos_server_enable} in
- [Yy][Ee][Ss])
- case ${kerberos_stash} in
- [Yy][Ee][Ss])
- stash_flag=-n
- ;;
- *)
- stash_flag=
- ;;
- esac
-
- echo -n ' kerberos'
- kerberos ${stash_flag} >> /var/log/kerberos.log &
-
- case ${kadmind_server_enable} in
- [Yy][Ee][Ss])
- echo -n ' kadmind'
- (sleep 20; kadmind ${stash_flag} >/dev/null 2>&1 &) &
- ;;
- esac
- unset stash_flag
- ;;
- esac
-
- case ${pppoed_enable} in
- [Yy][Ee][Ss])
- if [ -n "${pppoed_provider}" ]; then
- pppoed_flags="${pppoed_flags} -p ${pppoed_provider}"
- fi
- echo -n ' pppoed';
- /usr/libexec/pppoed ${pppoed_flags} ${pppoed_interface}
- ;;
- esac
-
- case ${sshd_enable} in
- [Yy][Ee][Ss])
- if [ ! -f /etc/ssh/ssh_host_key ]; then
- echo ' creating ssh host key';
- /usr/bin/ssh-keygen -N "" -f /etc/ssh/ssh_host_key
- fi
- ;;
- esac
-
- echo '.'
- network_pass3_done=YES
-}
-
-network_pass4() {
- echo -n 'Additional TCP options:'
- case ${log_in_vain} in
- [Nn][Oo] | '')
- ;;
- *)
- echo -n ' log_in_vain=YES'
- sysctl -w net.inet.tcp.log_in_vain=1 >/dev/null
- sysctl -w net.inet.udp.log_in_vain=1 >/dev/null
- ;;
- esac
-
- echo '.'
- network_pass4_done=YES
-}
diff --git a/etc/rc.d/atm1 b/etc/rc.d/atm1
deleted file mode 100644
index 72787ddcfb8c..000000000000
--- a/etc/rc.d/atm1
+++ /dev/null
@@ -1,193 +0,0 @@
-#!/bin/sh
-#
-
-# ATM networking startup script
-#
-# $FreeBSD$
-
-#
-# Initial interface configuration.
-# N.B. /usr is not mounted.
-#
-atm_pass1() {
- # Locate all probed ATM adapters
- atmdev=`atm sh stat int | while read dev junk; do
- case ${dev} in
- hea[0-9] | hea[0-9][0-9])
- echo "${dev} "
- ;;
- hfa[0-9] | hfa[0-9][0-9])
- echo "${dev} "
- ;;
- *)
- continue
- ;;
- esac
- done`
-
- if [ -z "${atmdev}" ]; then
- echo "No ATM adapters found."
- return 0
- fi
-
- # Load microcode into FORE adapters (if needed)
- if [ `expr "${atmdev}" : '.*hfa.*'` -ne 0 ]; then
- fore_dnld
- fi
-
- # Configure physical interfaces
- ilmid=0
- for phy in ${atmdev}; do
- echo -n "Configuring ATM device ${phy}:"
-
- # Define network interfaces
- eval netif_args=\$atm_netif_${phy}
- if [ -n "${netif_args}" ]; then
- atm set netif ${phy} ${netif_args} || continue
- else
- echo "missing network interface definition"
- continue
- fi
-
- # Override physical MAC address
- eval macaddr_args=\$atm_macaddr_${phy}
- if [ -n "${macaddr_args}" ]; then
- case ${macaddr_args} in
- [Nn][Oo] | '')
- ;;
- *)
- atm set mac ${phy} ${macaddr_args} || continue
- ;;
- esac
- fi
-
- # Configure signalling manager
- eval sigmgr_args=\$atm_sigmgr_${phy}
- if [ -n "${sigmgr_args}" ]; then
- atm attach ${phy} ${sigmgr_args} || continue
- else
- echo "missing signalling manager definition"
- continue
- fi
-
- # Configure UNI NSAP prefix
- eval prefix_args=\$atm_prefix_${phy}
- if [ `expr "${sigmgr_args}" : '[uU][nN][iI].*'` -ne 0 ]; then
- if [ -z "${prefix_args}" ]; then
- echo "missing NSAP prefix for UNI interface"
- continue
- fi
-
- case ${prefix_args} in
- ILMI)
- ilmid=1
- ;;
- *)
- atm set prefix ${phy} ${prefix_args} || continue
- ;;
- esac
- fi
-
- atm_phy="${atm_phy} ${phy}"
- echo "."
- done
-
- echo -n "Starting initial ATM daemons:"
- # Start ILMI daemon (if needed)
- case ${ilmid} in
- 1)
- echo -n " ilmid"
- ilmid
- ;;
- esac
-
- echo "."
- atm_pass1_done=YES
-}
-
-#
-# Finish up configuration.
-# N.B. /usr is not mounted.
-#
-atm_pass2() {
- echo -n "Configuring ATM network interfaces:"
-
- atm_scspd=0
- atm_atmarpd=""
-
- # Configure network interfaces
- for phy in ${atm_phy}; do
- eval netif_args=\$atm_netif_${phy}
- set -- ${netif_args}
- netname=$1
- netcnt=$2
- netindx=0
- while [ ${netindx} -lt ${netcnt} ]; do
- net="${netname}${netindx}"
- netindx=`expr ${netindx} + 1`
- echo -n " ${net}"
-
- # Configure atmarp server
- eval atmarp_args=\$atm_arpserver_${net}
- if [ -n "${atmarp_args}" ]; then
- atm set arpserver ${net} ${atmarp_args} ||
- continue
- fi
- eval scsparp_args=\$atm_scsparp_${net}
-
- case ${scsparp_args} in
- [Yy][Ee][Ss])
- case ${atmarp_args} in
- local)
- ;;
- *)
- echo "local arpserver required for SCSP"
- continue
- ;;
- esac
-
- atm_atmarpd="${atm_atmarpd} ${net}"
- atm_scspd=1
- esac
- done
- done
- echo "."
-
- # Define any PVCs.
- if [ -n "${atm_pvcs}" ]; then
- for i in ${atm_pvcs}; do
- eval pvc_args=\$atm_pvc_${i}
- atm add pvc ${pvc_args}
- done
- fi
-
- # Define any permanent ARP entries.
- if [ -n "${atm_arps}" ]; then
- for i in ${atm_arps}; do
- eval arp_args=\$atm_arp_${i}
- atm add arp ${arp_args}
- done
- fi
- atm_pass2_done=YES
-}
-
-#
-# Start any necessary daemons.
-#
-atm_pass3() {
- # Start SCSP daemon (if needed)
- case ${atm_scspd} in
- 1)
- echo -n " scspd"
- scspd
- ;;
- esac
-
- # Start ATMARP daemon (if needed)
- if [ -n "${atm_atmarpd}" ]; then
- echo -n " atmarpd"
- atmarpd ${atm_atmarpd}
- fi
-
- atm_pass3_done=YES
-}
diff --git a/etc/rc.d/atm2 b/etc/rc.d/atm2
deleted file mode 100644
index 72787ddcfb8c..000000000000
--- a/etc/rc.d/atm2
+++ /dev/null
@@ -1,193 +0,0 @@
-#!/bin/sh
-#
-
-# ATM networking startup script
-#
-# $FreeBSD$
-
-#
-# Initial interface configuration.
-# N.B. /usr is not mounted.
-#
-atm_pass1() {
- # Locate all probed ATM adapters
- atmdev=`atm sh stat int | while read dev junk; do
- case ${dev} in
- hea[0-9] | hea[0-9][0-9])
- echo "${dev} "
- ;;
- hfa[0-9] | hfa[0-9][0-9])
- echo "${dev} "
- ;;
- *)
- continue
- ;;
- esac
- done`
-
- if [ -z "${atmdev}" ]; then
- echo "No ATM adapters found."
- return 0
- fi
-
- # Load microcode into FORE adapters (if needed)
- if [ `expr "${atmdev}" : '.*hfa.*'` -ne 0 ]; then
- fore_dnld
- fi
-
- # Configure physical interfaces
- ilmid=0
- for phy in ${atmdev}; do
- echo -n "Configuring ATM device ${phy}:"
-
- # Define network interfaces
- eval netif_args=\$atm_netif_${phy}
- if [ -n "${netif_args}" ]; then
- atm set netif ${phy} ${netif_args} || continue
- else
- echo "missing network interface definition"
- continue
- fi
-
- # Override physical MAC address
- eval macaddr_args=\$atm_macaddr_${phy}
- if [ -n "${macaddr_args}" ]; then
- case ${macaddr_args} in
- [Nn][Oo] | '')
- ;;
- *)
- atm set mac ${phy} ${macaddr_args} || continue
- ;;
- esac
- fi
-
- # Configure signalling manager
- eval sigmgr_args=\$atm_sigmgr_${phy}
- if [ -n "${sigmgr_args}" ]; then
- atm attach ${phy} ${sigmgr_args} || continue
- else
- echo "missing signalling manager definition"
- continue
- fi
-
- # Configure UNI NSAP prefix
- eval prefix_args=\$atm_prefix_${phy}
- if [ `expr "${sigmgr_args}" : '[uU][nN][iI].*'` -ne 0 ]; then
- if [ -z "${prefix_args}" ]; then
- echo "missing NSAP prefix for UNI interface"
- continue
- fi
-
- case ${prefix_args} in
- ILMI)
- ilmid=1
- ;;
- *)
- atm set prefix ${phy} ${prefix_args} || continue
- ;;
- esac
- fi
-
- atm_phy="${atm_phy} ${phy}"
- echo "."
- done
-
- echo -n "Starting initial ATM daemons:"
- # Start ILMI daemon (if needed)
- case ${ilmid} in
- 1)
- echo -n " ilmid"
- ilmid
- ;;
- esac
-
- echo "."
- atm_pass1_done=YES
-}
-
-#
-# Finish up configuration.
-# N.B. /usr is not mounted.
-#
-atm_pass2() {
- echo -n "Configuring ATM network interfaces:"
-
- atm_scspd=0
- atm_atmarpd=""
-
- # Configure network interfaces
- for phy in ${atm_phy}; do
- eval netif_args=\$atm_netif_${phy}
- set -- ${netif_args}
- netname=$1
- netcnt=$2
- netindx=0
- while [ ${netindx} -lt ${netcnt} ]; do
- net="${netname}${netindx}"
- netindx=`expr ${netindx} + 1`
- echo -n " ${net}"
-
- # Configure atmarp server
- eval atmarp_args=\$atm_arpserver_${net}
- if [ -n "${atmarp_args}" ]; then
- atm set arpserver ${net} ${atmarp_args} ||
- continue
- fi
- eval scsparp_args=\$atm_scsparp_${net}
-
- case ${scsparp_args} in
- [Yy][Ee][Ss])
- case ${atmarp_args} in
- local)
- ;;
- *)
- echo "local arpserver required for SCSP"
- continue
- ;;
- esac
-
- atm_atmarpd="${atm_atmarpd} ${net}"
- atm_scspd=1
- esac
- done
- done
- echo "."
-
- # Define any PVCs.
- if [ -n "${atm_pvcs}" ]; then
- for i in ${atm_pvcs}; do
- eval pvc_args=\$atm_pvc_${i}
- atm add pvc ${pvc_args}
- done
- fi
-
- # Define any permanent ARP entries.
- if [ -n "${atm_arps}" ]; then
- for i in ${atm_arps}; do
- eval arp_args=\$atm_arp_${i}
- atm add arp ${arp_args}
- done
- fi
- atm_pass2_done=YES
-}
-
-#
-# Start any necessary daemons.
-#
-atm_pass3() {
- # Start SCSP daemon (if needed)
- case ${atm_scspd} in
- 1)
- echo -n " scspd"
- scspd
- ;;
- esac
-
- # Start ATMARP daemon (if needed)
- if [ -n "${atm_atmarpd}" ]; then
- echo -n " atmarpd"
- atmarpd ${atm_atmarpd}
- fi
-
- atm_pass3_done=YES
-}
diff --git a/etc/rc.d/atm2.sh b/etc/rc.d/atm2.sh
deleted file mode 100644
index 72787ddcfb8c..000000000000
--- a/etc/rc.d/atm2.sh
+++ /dev/null
@@ -1,193 +0,0 @@
-#!/bin/sh
-#
-
-# ATM networking startup script
-#
-# $FreeBSD$
-
-#
-# Initial interface configuration.
-# N.B. /usr is not mounted.
-#
-atm_pass1() {
- # Locate all probed ATM adapters
- atmdev=`atm sh stat int | while read dev junk; do
- case ${dev} in
- hea[0-9] | hea[0-9][0-9])
- echo "${dev} "
- ;;
- hfa[0-9] | hfa[0-9][0-9])
- echo "${dev} "
- ;;
- *)
- continue
- ;;
- esac
- done`
-
- if [ -z "${atmdev}" ]; then
- echo "No ATM adapters found."
- return 0
- fi
-
- # Load microcode into FORE adapters (if needed)
- if [ `expr "${atmdev}" : '.*hfa.*'` -ne 0 ]; then
- fore_dnld
- fi
-
- # Configure physical interfaces
- ilmid=0
- for phy in ${atmdev}; do
- echo -n "Configuring ATM device ${phy}:"
-
- # Define network interfaces
- eval netif_args=\$atm_netif_${phy}
- if [ -n "${netif_args}" ]; then
- atm set netif ${phy} ${netif_args} || continue
- else
- echo "missing network interface definition"
- continue
- fi
-
- # Override physical MAC address
- eval macaddr_args=\$atm_macaddr_${phy}
- if [ -n "${macaddr_args}" ]; then
- case ${macaddr_args} in
- [Nn][Oo] | '')
- ;;
- *)
- atm set mac ${phy} ${macaddr_args} || continue
- ;;
- esac
- fi
-
- # Configure signalling manager
- eval sigmgr_args=\$atm_sigmgr_${phy}
- if [ -n "${sigmgr_args}" ]; then
- atm attach ${phy} ${sigmgr_args} || continue
- else
- echo "missing signalling manager definition"
- continue
- fi
-
- # Configure UNI NSAP prefix
- eval prefix_args=\$atm_prefix_${phy}
- if [ `expr "${sigmgr_args}" : '[uU][nN][iI].*'` -ne 0 ]; then
- if [ -z "${prefix_args}" ]; then
- echo "missing NSAP prefix for UNI interface"
- continue
- fi
-
- case ${prefix_args} in
- ILMI)
- ilmid=1
- ;;
- *)
- atm set prefix ${phy} ${prefix_args} || continue
- ;;
- esac
- fi
-
- atm_phy="${atm_phy} ${phy}"
- echo "."
- done
-
- echo -n "Starting initial ATM daemons:"
- # Start ILMI daemon (if needed)
- case ${ilmid} in
- 1)
- echo -n " ilmid"
- ilmid
- ;;
- esac
-
- echo "."
- atm_pass1_done=YES
-}
-
-#
-# Finish up configuration.
-# N.B. /usr is not mounted.
-#
-atm_pass2() {
- echo -n "Configuring ATM network interfaces:"
-
- atm_scspd=0
- atm_atmarpd=""
-
- # Configure network interfaces
- for phy in ${atm_phy}; do
- eval netif_args=\$atm_netif_${phy}
- set -- ${netif_args}
- netname=$1
- netcnt=$2
- netindx=0
- while [ ${netindx} -lt ${netcnt} ]; do
- net="${netname}${netindx}"
- netindx=`expr ${netindx} + 1`
- echo -n " ${net}"
-
- # Configure atmarp server
- eval atmarp_args=\$atm_arpserver_${net}
- if [ -n "${atmarp_args}" ]; then
- atm set arpserver ${net} ${atmarp_args} ||
- continue
- fi
- eval scsparp_args=\$atm_scsparp_${net}
-
- case ${scsparp_args} in
- [Yy][Ee][Ss])
- case ${atmarp_args} in
- local)
- ;;
- *)
- echo "local arpserver required for SCSP"
- continue
- ;;
- esac
-
- atm_atmarpd="${atm_atmarpd} ${net}"
- atm_scspd=1
- esac
- done
- done
- echo "."
-
- # Define any PVCs.
- if [ -n "${atm_pvcs}" ]; then
- for i in ${atm_pvcs}; do
- eval pvc_args=\$atm_pvc_${i}
- atm add pvc ${pvc_args}
- done
- fi
-
- # Define any permanent ARP entries.
- if [ -n "${atm_arps}" ]; then
- for i in ${atm_arps}; do
- eval arp_args=\$atm_arp_${i}
- atm add arp ${arp_args}
- done
- fi
- atm_pass2_done=YES
-}
-
-#
-# Start any necessary daemons.
-#
-atm_pass3() {
- # Start SCSP daemon (if needed)
- case ${atm_scspd} in
- 1)
- echo -n " scspd"
- scspd
- ;;
- esac
-
- # Start ATMARP daemon (if needed)
- if [ -n "${atm_atmarpd}" ]; then
- echo -n " atmarpd"
- atmarpd ${atm_atmarpd}
- fi
-
- atm_pass3_done=YES
-}
diff --git a/etc/rc.d/atm3 b/etc/rc.d/atm3
deleted file mode 100644
index 72787ddcfb8c..000000000000
--- a/etc/rc.d/atm3
+++ /dev/null
@@ -1,193 +0,0 @@
-#!/bin/sh
-#
-
-# ATM networking startup script
-#
-# $FreeBSD$
-
-#
-# Initial interface configuration.
-# N.B. /usr is not mounted.
-#
-atm_pass1() {
- # Locate all probed ATM adapters
- atmdev=`atm sh stat int | while read dev junk; do
- case ${dev} in
- hea[0-9] | hea[0-9][0-9])
- echo "${dev} "
- ;;
- hfa[0-9] | hfa[0-9][0-9])
- echo "${dev} "
- ;;
- *)
- continue
- ;;
- esac
- done`
-
- if [ -z "${atmdev}" ]; then
- echo "No ATM adapters found."
- return 0
- fi
-
- # Load microcode into FORE adapters (if needed)
- if [ `expr "${atmdev}" : '.*hfa.*'` -ne 0 ]; then
- fore_dnld
- fi
-
- # Configure physical interfaces
- ilmid=0
- for phy in ${atmdev}; do
- echo -n "Configuring ATM device ${phy}:"
-
- # Define network interfaces
- eval netif_args=\$atm_netif_${phy}
- if [ -n "${netif_args}" ]; then
- atm set netif ${phy} ${netif_args} || continue
- else
- echo "missing network interface definition"
- continue
- fi
-
- # Override physical MAC address
- eval macaddr_args=\$atm_macaddr_${phy}
- if [ -n "${macaddr_args}" ]; then
- case ${macaddr_args} in
- [Nn][Oo] | '')
- ;;
- *)
- atm set mac ${phy} ${macaddr_args} || continue
- ;;
- esac
- fi
-
- # Configure signalling manager
- eval sigmgr_args=\$atm_sigmgr_${phy}
- if [ -n "${sigmgr_args}" ]; then
- atm attach ${phy} ${sigmgr_args} || continue
- else
- echo "missing signalling manager definition"
- continue
- fi
-
- # Configure UNI NSAP prefix
- eval prefix_args=\$atm_prefix_${phy}
- if [ `expr "${sigmgr_args}" : '[uU][nN][iI].*'` -ne 0 ]; then
- if [ -z "${prefix_args}" ]; then
- echo "missing NSAP prefix for UNI interface"
- continue
- fi
-
- case ${prefix_args} in
- ILMI)
- ilmid=1
- ;;
- *)
- atm set prefix ${phy} ${prefix_args} || continue
- ;;
- esac
- fi
-
- atm_phy="${atm_phy} ${phy}"
- echo "."
- done
-
- echo -n "Starting initial ATM daemons:"
- # Start ILMI daemon (if needed)
- case ${ilmid} in
- 1)
- echo -n " ilmid"
- ilmid
- ;;
- esac
-
- echo "."
- atm_pass1_done=YES
-}
-
-#
-# Finish up configuration.
-# N.B. /usr is not mounted.
-#
-atm_pass2() {
- echo -n "Configuring ATM network interfaces:"
-
- atm_scspd=0
- atm_atmarpd=""
-
- # Configure network interfaces
- for phy in ${atm_phy}; do
- eval netif_args=\$atm_netif_${phy}
- set -- ${netif_args}
- netname=$1
- netcnt=$2
- netindx=0
- while [ ${netindx} -lt ${netcnt} ]; do
- net="${netname}${netindx}"
- netindx=`expr ${netindx} + 1`
- echo -n " ${net}"
-
- # Configure atmarp server
- eval atmarp_args=\$atm_arpserver_${net}
- if [ -n "${atmarp_args}" ]; then
- atm set arpserver ${net} ${atmarp_args} ||
- continue
- fi
- eval scsparp_args=\$atm_scsparp_${net}
-
- case ${scsparp_args} in
- [Yy][Ee][Ss])
- case ${atmarp_args} in
- local)
- ;;
- *)
- echo "local arpserver required for SCSP"
- continue
- ;;
- esac
-
- atm_atmarpd="${atm_atmarpd} ${net}"
- atm_scspd=1
- esac
- done
- done
- echo "."
-
- # Define any PVCs.
- if [ -n "${atm_pvcs}" ]; then
- for i in ${atm_pvcs}; do
- eval pvc_args=\$atm_pvc_${i}
- atm add pvc ${pvc_args}
- done
- fi
-
- # Define any permanent ARP entries.
- if [ -n "${atm_arps}" ]; then
- for i in ${atm_arps}; do
- eval arp_args=\$atm_arp_${i}
- atm add arp ${arp_args}
- done
- fi
- atm_pass2_done=YES
-}
-
-#
-# Start any necessary daemons.
-#
-atm_pass3() {
- # Start SCSP daemon (if needed)
- case ${atm_scspd} in
- 1)
- echo -n " scspd"
- scspd
- ;;
- esac
-
- # Start ATMARP daemon (if needed)
- if [ -n "${atm_atmarpd}" ]; then
- echo -n " atmarpd"
- atmarpd ${atm_atmarpd}
- fi
-
- atm_pass3_done=YES
-}
diff --git a/etc/rc.d/atm3.sh b/etc/rc.d/atm3.sh
deleted file mode 100644
index 72787ddcfb8c..000000000000
--- a/etc/rc.d/atm3.sh
+++ /dev/null
@@ -1,193 +0,0 @@
-#!/bin/sh
-#
-
-# ATM networking startup script
-#
-# $FreeBSD$
-
-#
-# Initial interface configuration.
-# N.B. /usr is not mounted.
-#
-atm_pass1() {
- # Locate all probed ATM adapters
- atmdev=`atm sh stat int | while read dev junk; do
- case ${dev} in
- hea[0-9] | hea[0-9][0-9])
- echo "${dev} "
- ;;
- hfa[0-9] | hfa[0-9][0-9])
- echo "${dev} "
- ;;
- *)
- continue
- ;;
- esac
- done`
-
- if [ -z "${atmdev}" ]; then
- echo "No ATM adapters found."
- return 0
- fi
-
- # Load microcode into FORE adapters (if needed)
- if [ `expr "${atmdev}" : '.*hfa.*'` -ne 0 ]; then
- fore_dnld
- fi
-
- # Configure physical interfaces
- ilmid=0
- for phy in ${atmdev}; do
- echo -n "Configuring ATM device ${phy}:"
-
- # Define network interfaces
- eval netif_args=\$atm_netif_${phy}
- if [ -n "${netif_args}" ]; then
- atm set netif ${phy} ${netif_args} || continue
- else
- echo "missing network interface definition"
- continue
- fi
-
- # Override physical MAC address
- eval macaddr_args=\$atm_macaddr_${phy}
- if [ -n "${macaddr_args}" ]; then
- case ${macaddr_args} in
- [Nn][Oo] | '')
- ;;
- *)
- atm set mac ${phy} ${macaddr_args} || continue
- ;;
- esac
- fi
-
- # Configure signalling manager
- eval sigmgr_args=\$atm_sigmgr_${phy}
- if [ -n "${sigmgr_args}" ]; then
- atm attach ${phy} ${sigmgr_args} || continue
- else
- echo "missing signalling manager definition"
- continue
- fi
-
- # Configure UNI NSAP prefix
- eval prefix_args=\$atm_prefix_${phy}
- if [ `expr "${sigmgr_args}" : '[uU][nN][iI].*'` -ne 0 ]; then
- if [ -z "${prefix_args}" ]; then
- echo "missing NSAP prefix for UNI interface"
- continue
- fi
-
- case ${prefix_args} in
- ILMI)
- ilmid=1
- ;;
- *)
- atm set prefix ${phy} ${prefix_args} || continue
- ;;
- esac
- fi
-
- atm_phy="${atm_phy} ${phy}"
- echo "."
- done
-
- echo -n "Starting initial ATM daemons:"
- # Start ILMI daemon (if needed)
- case ${ilmid} in
- 1)
- echo -n " ilmid"
- ilmid
- ;;
- esac
-
- echo "."
- atm_pass1_done=YES
-}
-
-#
-# Finish up configuration.
-# N.B. /usr is not mounted.
-#
-atm_pass2() {
- echo -n "Configuring ATM network interfaces:"
-
- atm_scspd=0
- atm_atmarpd=""
-
- # Configure network interfaces
- for phy in ${atm_phy}; do
- eval netif_args=\$atm_netif_${phy}
- set -- ${netif_args}
- netname=$1
- netcnt=$2
- netindx=0
- while [ ${netindx} -lt ${netcnt} ]; do
- net="${netname}${netindx}"
- netindx=`expr ${netindx} + 1`
- echo -n " ${net}"
-
- # Configure atmarp server
- eval atmarp_args=\$atm_arpserver_${net}
- if [ -n "${atmarp_args}" ]; then
- atm set arpserver ${net} ${atmarp_args} ||
- continue
- fi
- eval scsparp_args=\$atm_scsparp_${net}
-
- case ${scsparp_args} in
- [Yy][Ee][Ss])
- case ${atmarp_args} in
- local)
- ;;
- *)
- echo "local arpserver required for SCSP"
- continue
- ;;
- esac
-
- atm_atmarpd="${atm_atmarpd} ${net}"
- atm_scspd=1
- esac
- done
- done
- echo "."
-
- # Define any PVCs.
- if [ -n "${atm_pvcs}" ]; then
- for i in ${atm_pvcs}; do
- eval pvc_args=\$atm_pvc_${i}
- atm add pvc ${pvc_args}
- done
- fi
-
- # Define any permanent ARP entries.
- if [ -n "${atm_arps}" ]; then
- for i in ${atm_arps}; do
- eval arp_args=\$atm_arp_${i}
- atm add arp ${arp_args}
- done
- fi
- atm_pass2_done=YES
-}
-
-#
-# Start any necessary daemons.
-#
-atm_pass3() {
- # Start SCSP daemon (if needed)
- case ${atm_scspd} in
- 1)
- echo -n " scspd"
- scspd
- ;;
- esac
-
- # Start ATMARP daemon (if needed)
- if [ -n "${atm_atmarpd}" ]; then
- echo -n " atmarpd"
- atmarpd ${atm_atmarpd}
- fi
-
- atm_pass3_done=YES
-}
diff --git a/etc/rc.d/diskless b/etc/rc.d/diskless
deleted file mode 100644
index 9ccdfa80ed14..000000000000
--- a/etc/rc.d/diskless
+++ /dev/null
@@ -1,43 +0,0 @@
-# $FreeBSD$
-#
-
-# PROVIDE: diskless
-# REQUIRE: initdiskless mountcritlocal
- if [ -n "$4" ]; then
- bpi="-i $4"
- fi
- /sbin/mdconfig -a -t malloc -s $1 -u $3
- /sbin/newfs $bpi /dev/md$3c
- /sbin/mount /dev/md$3c $2
-}
-
-mount_mfs -s ${varsize:=65536} -T qp120at dummy /var
-var_dirs="run dev db msgs tmp spool spool/mqueue spool/lpd spool/output \
- spool/output/lpd"
-for i in ${var_dirs}
-do
- mkdir /var/${i}
-done
-chmod 755 /var/run
-chmod 755 /var/db
-chmod 755 /var/spool
-chmod 1777 /var/tmp
-chown -R root.daemon /var/spool/output
-chgrp daemon /var/spool/lpd
-# Since we are starting with a very fresh /etc on an MFS:
-if [ -d /conf/default/etc ]; then
- newaliases
-fi
-if [ ! -h /tmp -a ! -h /var/tmp ]; then
- mount_null /var/tmp /tmp
-fi
-#
-# extract a list of device entries, then copy them to a writable partition
-(cd /; find -x dev | cpio -o -H newc) > /tmp/dev.tmp
-mount_mfs -s 4096 -i 512 -T qp120at dummy /dev
-(cd /; cpio -i -H newc -d < /tmp/dev.tmp)
- # extract a list of device entries, then copy them to a writable fs
- (cd /; find -x dev | cpio -o -H newc) > /tmp/dev.tmp
- mount_md 4096 /dev 3 512
- (cd /; cpio -i -H newc -d < /tmp/dev.tmp)
-fi
diff --git a/etc/rc.d/initdiskless b/etc/rc.d/initdiskless
deleted file mode 100644
index 6b306ba3046e..000000000000
--- a/etc/rc.d/initdiskless
+++ /dev/null
@@ -1,101 +0,0 @@
-# $FreeBSD$
-#
-# /etc/rc.diskless1 - general BOOTP startup
-#
-# BOOTP has mounted / for us. Assume a read-only mount. We must then
-# - figure out our IP by querying the interface
-# - fill /conf/etc (writable) with files from /etc, and then update
-# per-machine files from /conf/*/ where * is the IP of the host,
-# the IP of the subnet, "default", or nothing.
-# - mount /conf/etc over /etc so we can see the new files.
-#
-# WARNING: i thing you should not change /etc/rc or strange things could
-# happen.
-#
-# The operator is in charge of setting /conf/*/etc/* things as appropriate.
-# Typically rc.conf and fstab need to be changed, but possibly
-# also other files such as inetd.conf etc.
-
-# chkerr:
-#
-# Routine to check for error
-#
-# checks error code and drops into shell on failure.
-# if shell exits, terminates script as well as /etc/rc.
-#
-chkerr() {
- case $1 in
- 0)
- ;;
- *)
- echo "$2 failed: dropping into /bin/sh"
- /bin/sh
- # RESUME
- ;;
- esac
-}
-
-# DEBUGGING
-#
-# set -v
-
-# Figure out our interface and IP.
-#
-bootp_ifc=""
-bootp_ipa=""
-bootp_ipbca=""
-iflist=`ifconfig -l`
-for i in ${iflist} ; do
- set `ifconfig ${i}`
- while [ $# -ge 1 ] ; do
- if [ "${bootp_ifc}" = "" -a "$1" = "inet" ] ; then
- bootp_ifc=${i} ; bootp_ipa=${2} ; shift
- fi
- if [ "${bootp_ipbca}" = "" -a "$1" = "broadcast" ] ; then
- bootp_ipbca=$2; shift
- fi
- shift
- done
- if [ "${bootp_ifc}" != "" ] ; then
- break
- fi
-done
-echo "Interface ${bootp_ifc} IP-Address ${bootp_ipa} Broadcast ${bootp_ipbca}"
-
-# Files in /etc are copied to /conf/etc which is writable. Then
-# per-machine configs from /conf/ip.address/etc are copied onto this
-# directory. First choice is using the client's IP, then the client's
-# broadcast address, then a default configuration.
-# This way we have some flexibility to handle clusters of machines
-# on separate subnets.
-#
-# WARNING! null mounts cannot handle mmap, and since many programs
-# use mmap (such as 'cp'), we have to copy.
-#
-mount_mfs -s 2048 -T qp120at dummy /conf/etc
-cp -Rp /etc/* /conf/etc
-chkerr $? "MFS mount on /conf/etc"
-
-if [ -d /conf/${bootp_ipa} ] ; then
- cp -Rp /conf/${bootp_ipa}/etc/* /conf/etc
-elif [ -d /conf/${bootp_ipbca} ] ; then
- cp -Rp /conf/${bootp_ipbca}/etc/* /conf/etc
-else
- cp -Rp /conf/default/etc/* /conf/etc
-fi
-
-# Make the new directory available as /etc
-#
-mount_null /conf/etc /etc
-
-# Tell /etc/rc to run the specified script after
-# it does its mounts but before it does anything
-# else.
-#
-# This script is responsible for setting up the
-# diskless mount environment. This can be
-# overriden by /conf/ME/rc.conf.local if, for
-# example, you do not want to run the standard
-# system /etc/rc.diskless2
-
-diskless_mount="/etc/rc.diskless2"
diff --git a/etc/rc.d/isdnd b/etc/rc.d/isdnd
deleted file mode 100644
index 130210201082..000000000000
--- a/etc/rc.d/isdnd
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/bin/sh
-#---------------------------------------------------------------------------
-#
-# /etc/rc.isdn - isdn4bsd startup script
-# --------------------------------------
-#
-# last edit-date: [Mon Mar 8 12:15:56 1999]
-#
-# $FreeBSD$
-#
-#---------------------------------------------------------------------------
-
-case ${isdn_enable} in
-[Yy][Ee][Ss])
- echo -n 'ISDN subsystem setup:'
-
- # Terminal type for fullscreen mode, default to syscons driver
- #
- isdn_ttype=cons25
-
- # Check for pcvt driver (VT100/VT220 emulator)
- #
- if [ -x /usr/sbin/ispcvt ]; then
- if /usr/sbin/ispcvt; then
- isdn_ttype=pcvt25
- fi
- fi
-
- case ${isdn_flags} in
- [Nn][Oo] | '')
- isdn_flags=''
- ;;
- esac
-
- # Start the isdn daemon
- #
- if [ -x /usr/sbin/isdnd ]; then
- echo -n ' isdnd'
- case ${isdn_fsdev} in
- [Nn][Oo] | '')
- /usr/sbin/isdnd ${isdn_flags}
- ;;
- *)
- /usr/sbin/isdnd ${isdn_flags} -f -r ${isdn_fsdev} -t ${isdn_ttype}
- ;;
- esac
- fi
-
- # Start isdntrace
- #
- case ${isdn_trace} in
- [Yy][Ee][Ss])
- if [ -x /usr/sbin/isdntrace ]; then
- echo -n ' isdntrace'
- nohup /usr/sbin/isdntrace ${isdn_traceflags} >/dev/null 2>&1 &
- fi
- ;;
- esac
-
- echo '.'
- ;;
-esac
diff --git a/etc/rc.d/netoptions b/etc/rc.d/netoptions
deleted file mode 100644
index 0211181f0516..000000000000
--- a/etc/rc.d/netoptions
+++ /dev/null
@@ -1,633 +0,0 @@
-#!/bin/sh -
-#
-# $FreeBSD$
-# From: @(#)netstart 5.9 (Berkeley) 3/30/91
-
-# Note that almost all of the user-configurable behavior is no longer in
-# this file, but rather in /etc/defaults/rc.conf. Please check that file
-# first before contemplating any changes here. If you do need to change
-# this file for some reason, we would like to know about it.
-
-# First pass startup stuff.
-#
-network_pass1() {
- echo -n 'Doing initial network setup:'
-
- # Set the host name if it is not already set
- #
- if [ -z "`hostname -s`" ]; then
- hostname ${hostname}
- echo -n ' hostname'
- fi
-
- # Set the domainname if we're using NIS
- #
- case ${nisdomainname} in
- [Nn][Oo] | '')
- ;;
- *)
- domainname ${nisdomainname}
- echo -n ' domain'
- ;;
- esac
-
- echo '.'
-
- # Initial ATM interface configuration
- #
- case ${atm_enable} in
- [Yy][Ee][Ss])
- if [ -r /etc/rc.atm ]; then
- . /etc/rc.atm
- atm_pass1
- fi
- ;;
- esac
-
- # Special options for sppp(4) interfaces go here. These need
- # to go _before_ the general ifconfig section, since in the case
- # of hardwired (no link1 flag) but required authentication, you
- # cannot pass auth parameters down to the already running interface.
- #
- for ifn in ${sppp_interfaces}; do
- eval spppcontrol_args=\$spppconfig_${ifn}
- if [ -n "${spppcontrol_args}" ]; then
- # The auth secrets might contain spaces; in order
- # to retain the quotation, we need to eval them
- # here.
- eval spppcontrol ${ifn} ${spppcontrol_args}
- fi
- done
-
- # Set up all the network interfaces, calling startup scripts if needed
- #
- case ${network_interfaces} in
- [Aa][Uu][Tt][Oo])
- network_interfaces="`ifconfig -l`"
- ;;
- esac
-
- dhcp_interfaces=""
- for ifn in ${network_interfaces}; do
- if [ -r /etc/start_if.${ifn} ]; then
- . /etc/start_if.${ifn}
- eval showstat_$ifn=1
- fi
-
- # Do the primary ifconfig if specified
- #
- eval ifconfig_args=\$ifconfig_${ifn}
-
- case ${ifconfig_args} in
- '')
- ;;
- [Dd][Hh][Cc][Pp])
- # DHCP inits are done all in one go below
- dhcp_interfaces="$dhcp_interfaces $ifn"
- eval showstat_$ifn=1
- ;;
- *)
- ifconfig ${ifn} ${ifconfig_args}
- eval showstat_$ifn=1
- ;;
- esac
- done
-
- if [ ! -z "${dhcp_interfaces}" ]; then
- ${dhcp_program:-/sbin/dhclient} ${dhcp_flags} ${dhcp_interfaces}
- fi
-
- for ifn in ${network_interfaces}; do
- # Check to see if aliases need to be added
- #
- alias=0
- while : ; do
- eval ifconfig_args=\$ifconfig_${ifn}_alias${alias}
- if [ -n "${ifconfig_args}" ]; then
- ifconfig ${ifn} ${ifconfig_args} alias
- eval showstat_$ifn=1
- alias=`expr ${alias} + 1`
- else
- break;
- fi
- done
-
- # Do ipx address if specified
- #
- eval ifconfig_args=\$ifconfig_${ifn}_ipx
- if [ -n "${ifconfig_args}" ]; then
- ifconfig ${ifn} ${ifconfig_args}
- eval showstat_$ifn=1
- fi
- done
-
- for ifn in ${network_interfaces}; do
- eval showstat=\$showstat_${ifn}
- if [ ! -z ${showstat} ]; then
- ifconfig ${ifn}
- fi
- done
-
- # ISDN subsystem startup
- #
- case ${isdn_enable} in
- [Yy][Ee][Ss])
- if [ -r /etc/rc.isdn ]; then
- . /etc/rc.isdn
- fi
- ;;
- esac
-
- # Warm up user ppp if required, must happen before natd.
- #
- case ${ppp_enable} in
- [Yy][Ee][Ss])
- # Establish ppp mode.
- #
- if [ "${ppp_mode}" != "ddial" -a "${ppp_mode}" != "direct" \
- -a "${ppp_mode}" != "dedicated" \
- -a "${ppp_mode}" != "background" ]; then
- ppp_mode="auto";
- fi
-
- ppp_command="-${ppp_mode} ";
-
- # Switch on alias mode?
- #
- case ${ppp_nat} in
- [Yy][Ee][Ss])
- ppp_command="${ppp_command} -nat";
- ;;
- esac
-
- echo -n 'Starting ppp: '; ppp ${ppp_command} -quiet ${ppp_profile}
- ;;
- esac
-
- # Initialize IP filtering using ipfw
- #
- echo ''
-
- if /sbin/ipfw -q flush > /dev/null 2>&1; then
- firewall_in_kernel=1
- else
- firewall_in_kernel=0
- fi
-
- case ${firewall_enable} in
- [Yy][Ee][Ss])
- if [ "${firewall_in_kernel}" -eq 0 ] && kldload ipfw; then
- firewall_in_kernel=1
- echo "Kernel firewall module loaded."
- elif [ "${firewall_in_kernel}" -eq 0 ]; then
- echo "Warning: firewall kernel module failed to load."
- fi
- ;;
- esac
-
- # Load the filters if required
- #
- case ${firewall_in_kernel} in
- 1)
- if [ -z "${firewall_script}" ]; then
- firewall_script=/etc/rc.firewall
- fi
-
- case ${firewall_enable} in
- [Yy][Ee][Ss])
- if [ -r "${firewall_script}" ]; then
- . "${firewall_script}"
- echo -n 'Firewall rules loaded, starting divert daemons:'
-
- # Network Address Translation daemon
- #
- case ${natd_enable} in
- [Yy][Ee][Ss])
- if [ -n "${natd_interface}" ]; then
- if echo ${natd_interface} | \
- grep -q -E '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$'; then
- natd_ifarg="-a ${natd_interface}"
- else
- natd_ifarg="-n ${natd_interface}"
- fi
-
- echo -n ' natd'; ${natd_program:-/sbin/natd} ${natd_flags} ${natd_ifarg}
- fi
- ;;
- esac
-
- echo '.'
-
- elif [ "`ipfw l 65535`" = "65535 deny ip from any to any" ]; then
- echo -n "Warning: kernel has firewall functionality, "
- echo "but firewall rules are not enabled."
- echo " All ip services are disabled."
- fi
- ;;
- esac
- ;;
- esac
-
- # Additional ATM interface configuration
- #
- if [ -n "${atm_pass1_done}" ]; then
- atm_pass2
- fi
-
- # Configure routing
- #
- case ${defaultrouter} in
- [Nn][Oo] | '')
- ;;
- *)
- static_routes="default ${static_routes}"
- route_default="default ${defaultrouter}"
- ;;
- esac
-
- # Set up any static routes. This should be done before router discovery.
- #
- if [ -n "${static_routes}" ]; then
- for i in ${static_routes}; do
- eval route_args=\$route_${i}
- route add ${route_args}
- done
- fi
-
- echo -n 'Additional routing options:'
- case ${tcp_extensions} in
- [Yy][Ee][Ss] | '')
- ;;
- *)
- echo -n ' tcp extensions=NO'
- sysctl -w net.inet.tcp.rfc1323=0 >/dev/null
- ;;
- esac
-
- case ${icmp_bmcastecho} in
- [Yy][Ee][Ss])
- echo -n ' broadcast ping responses=YES'
- sysctl -w net.inet.icmp.bmcastecho=1 >/dev/null
- ;;
- esac
-
- case ${icmp_drop_redirect} in
- [Yy][Ee][Ss])
- echo -n ' ignore ICMP redirect=YES'
- sysctl -w net.inet.icmp.drop_redirect=1 >/dev/null
- ;;
- esac
-
- case ${icmp_log_redirect} in
- [Yy][Ee][Ss])
- echo -n ' log ICMP redirect=YES'
- sysctl -w net.inet.icmp.log_redirect=1 >/dev/null
- ;;
- esac
-
- case ${gateway_enable} in
- [Yy][Ee][Ss])
- echo -n ' IP gateway=YES'
- sysctl -w net.inet.ip.forwarding=1 >/dev/null
- ;;
- esac
-
- case ${forward_sourceroute} in
- [Yy][Ee][Ss])
- echo -n ' do source routing=YES'
- sysctl -w net.inet.ip.sourceroute=1 >/dev/null
- ;;
- esac
-
- case ${accept_sourceroute} in
- [Yy][Ee][Ss])
- echo -n ' accept source routing=YES'
- sysctl -w net.inet.ip.accept_sourceroute=1 >/dev/null
- ;;
- esac
-
- case ${tcp_keepalive} in
- [Yy][Ee][Ss])
- echo -n ' TCP keepalive=YES'
- sysctl -w net.inet.tcp.always_keepalive=1 >/dev/null
- ;;
- esac
-
- case ${tcp_restrict_rst} in
- [Yy][Ee][Ss])
- echo -n ' restrict TCP reset=YES'
- sysctl -w net.inet.tcp.restrict_rst=1 >/dev/null
- ;;
- esac
-
- case ${tcp_drop_synfin} in
- [Yy][Ee][Ss])
- echo -n ' drop SYN+FIN packets=YES'
- sysctl -w net.inet.tcp.drop_synfin=1 >/dev/null
- ;;
- esac
-
- case ${ipxgateway_enable} in
- [Yy][Ee][Ss])
- echo -n ' IPX gateway=YES'
- sysctl -w net.ipx.ipx.ipxforwarding=1 >/dev/null
- ;;
- esac
-
- case ${arpproxy_all} in
- [Yy][Ee][Ss])
- echo -n ' ARP proxyall=YES'
- sysctl -w net.link.ether.inet.proxyall=1 >/dev/null
- ;;
- esac
- echo '.'
-
- echo -n 'routing daemons:'
- case ${router_enable} in
- [Yy][Ee][Ss])
- echo -n " ${router}"; ${router} ${router_flags}
- ;;
- esac
-
- case ${ipxrouted_enable} in
- [Yy][Ee][Ss])
- echo -n ' IPXrouted'
- IPXrouted ${ipxrouted_flags} > /dev/null 2>&1
- ;;
- esac
-
- case ${mrouted_enable} in
- [Yy][Ee][Ss])
- echo -n ' mrouted'; mrouted ${mrouted_flags}
- ;;
- esac
-
- case ${rarpd_enable} in
- [Yy][Ee][Ss])
- echo -n ' rarpd'; rarpd ${rarpd_flags}
- ;;
- esac
- echo '.'
-
- # Let future generations know we made it.
- #
- network_pass1_done=YES
-}
-
-network_pass2() {
- echo -n 'Doing additional network setup:'
- case ${named_enable} in
- [Yy][Ee][Ss])
- echo -n ' named'; ${named_program:-named} ${named_flags}
- ;;
- esac
-
- case ${ntpdate_enable} in
- [Yy][Ee][Ss])
- echo -n ' ntpdate'
- ${ntpdate_program:-ntpdate} ${ntpdate_flags} >/dev/null 2>&1
- ;;
- esac
-
- case ${xntpd_enable} in
- [Yy][Ee][Ss])
- echo -n ' ntpd'; ${xntpd_program:-ntpd} ${xntpd_flags}
- ;;
- esac
-
- case ${timed_enable} in
- [Yy][Ee][Ss])
- echo -n ' timed'; timed ${timed_flags}
- ;;
- esac
-
- case ${portmap_enable} in
- [Yy][Ee][Ss])
- echo -n ' portmap'; ${portmap_program:-/usr/sbin/portmap} ${portmap_flags}
- ;;
- esac
-
- # Start ypserv if we're an NIS server.
- # Run rpc.ypxfrd and rpc.yppasswdd only on the NIS master server.
- #
- case ${nis_server_enable} in
- [Yy][Ee][Ss])
- echo -n ' ypserv'; ypserv ${nis_server_flags}
-
- case ${nis_ypxfrd_enable} in
- [Yy][Ee][Ss])
- echo -n ' rpc.ypxfrd'
- rpc.ypxfrd ${nis_ypxfrd_flags}
- ;;
- esac
-
- case ${nis_yppasswdd_enable} in
- [Yy][Ee][Ss])
- echo -n ' rpc.yppasswdd'
- rpc.yppasswdd ${nis_yppasswdd_flags}
- ;;
- esac
- ;;
- esac
-
- # Start ypbind if we're an NIS client
- #
- case ${nis_client_enable} in
- [Yy][Ee][Ss])
- echo -n ' ypbind'; ypbind ${nis_client_flags}
- case ${nis_ypset_enable} in
- [Yy][Ee][Ss])
- echo -n ' ypset'; ypset ${nis_ypset_flags}
- ;;
- esac
- ;;
- esac
-
- # Start keyserv if we are running Secure RPC
- #
- case ${keyserv_enable} in
- [Yy][Ee][Ss])
- echo -n ' keyserv'; keyserv ${keyserv_flags}
- ;;
- esac
-
- # Start ypupdated if we are running Secure RPC and we are NIS master
- #
- case ${rpc_ypupdated_enable} in
- [Yy][Ee][Ss])
- echo -n ' rpc.ypupdated'; rpc.ypupdated
- ;;
- esac
-
- # Start ATM daemons
- if [ -n "${atm_pass2_done}" ]; then
- atm_pass3
- fi
-
- echo '.'
- network_pass2_done=YES
-}
-
-network_pass3() {
- echo -n 'Starting final network daemons:'
-
- case ${nfs_server_enable} in
- [Yy][Ee][Ss])
- if [ -r /etc/exports ]; then
- echo -n ' mountd'
-
- case ${weak_mountd_authentication} in
- [Yy][Ee][Ss])
- mountd_flags="-n"
- ;;
- esac
-
- mountd ${mountd_flags}
-
- case ${nfs_reserved_port_only} in
- [Yy][Ee][Ss])
- echo -n ' NFS on reserved port only=YES'
- sysctl -w vfs.nfs.nfs_privport=1 >/dev/null
- ;;
- esac
-
- echo -n ' nfsd'; nfsd ${nfs_server_flags}
-
- case ${rpc_lockd_enable} in
- [Yy][Ee][Ss])
- echo -n ' rpc.lockd'; rpc.lockd
- ;;
- esac
-
- case ${rpc_statd_enable} in
- [Yy][Ee][Ss])
- echo -n ' rpc.statd'; rpc.statd
- ;;
- esac
- fi
- ;;
- *)
- case ${single_mountd_enable} in
- [Yy][Ee][Ss])
- if [ -r /etc/exports ]; then
- echo -n ' mountd'
-
- case ${weak_mountd_authentication} in
- [Yy][Ee][Ss])
- mountd_flags="-n"
- ;;
- esac
-
- mountd ${mountd_flags}
- fi
- ;;
- esac
- ;;
- esac
-
- case ${nfs_client_enable} in
- [Yy][Ee][Ss])
- echo -n ' nfsiod'; nfsiod ${nfs_client_flags}
- if [ -n "${nfs_access_cache}" ]; then
- echo -n " NFS access cache time=${nfs_access_cache}"
- sysctl -w vfs.nfs.access_cache_timeout=${nfs_access_cache} \
- >/dev/null
- fi
- ;;
- esac
-
- # If /var/db/mounttab exists, some nfs-server has not been
- # sucessfully notified about a previous client shutdown.
- # If there is no /var/db/mounttab, we do nothing.
- if [ -f /var/db/mounttab ]; then
- rpc.umntall -k
- fi
-
- case ${amd_enable} in
- [Yy][Ee][Ss])
- echo -n ' amd'
- case ${amd_map_program} in
- [Nn][Oo] | '')
- ;;
- *)
- amd_flags="${amd_flags} `eval ${amd_map_program}`"
- ;;
- esac
-
- if [ -n "${amd_flags}" ]; then
- amd -p ${amd_flags} > /var/run/amd.pid 2> /dev/null
- else
- amd 2> /dev/null
- fi
- ;;
- esac
-
- case ${rwhod_enable} in
- [Yy][Ee][Ss])
- echo -n ' rwhod'; rwhod ${rwhod_flags}
- ;;
- esac
-
- # Kerberos runs ONLY on the Kerberos server machine
- case ${kerberos_server_enable} in
- [Yy][Ee][Ss])
- case ${kerberos_stash} in
- [Yy][Ee][Ss])
- stash_flag=-n
- ;;
- *)
- stash_flag=
- ;;
- esac
-
- echo -n ' kerberos'
- kerberos ${stash_flag} >> /var/log/kerberos.log &
-
- case ${kadmind_server_enable} in
- [Yy][Ee][Ss])
- echo -n ' kadmind'
- (sleep 20; kadmind ${stash_flag} >/dev/null 2>&1 &) &
- ;;
- esac
- unset stash_flag
- ;;
- esac
-
- case ${pppoed_enable} in
- [Yy][Ee][Ss])
- if [ -n "${pppoed_provider}" ]; then
- pppoed_flags="${pppoed_flags} -p ${pppoed_provider}"
- fi
- echo -n ' pppoed';
- /usr/libexec/pppoed ${pppoed_flags} ${pppoed_interface}
- ;;
- esac
-
- case ${sshd_enable} in
- [Yy][Ee][Ss])
- if [ ! -f /etc/ssh/ssh_host_key ]; then
- echo ' creating ssh host key';
- /usr/bin/ssh-keygen -N "" -f /etc/ssh/ssh_host_key
- fi
- ;;
- esac
-
- echo '.'
- network_pass3_done=YES
-}
-
-network_pass4() {
- echo -n 'Additional TCP options:'
- case ${log_in_vain} in
- [Nn][Oo] | '')
- ;;
- *)
- echo -n ' log_in_vain=YES'
- sysctl -w net.inet.tcp.log_in_vain=1 >/dev/null
- sysctl -w net.inet.udp.log_in_vain=1 >/dev/null
- ;;
- esac
-
- echo '.'
- network_pass4_done=YES
-}
diff --git a/etc/rc.d/network1 b/etc/rc.d/network1
deleted file mode 100644
index 0211181f0516..000000000000
--- a/etc/rc.d/network1
+++ /dev/null
@@ -1,633 +0,0 @@
-#!/bin/sh -
-#
-# $FreeBSD$
-# From: @(#)netstart 5.9 (Berkeley) 3/30/91
-
-# Note that almost all of the user-configurable behavior is no longer in
-# this file, but rather in /etc/defaults/rc.conf. Please check that file
-# first before contemplating any changes here. If you do need to change
-# this file for some reason, we would like to know about it.
-
-# First pass startup stuff.
-#
-network_pass1() {
- echo -n 'Doing initial network setup:'
-
- # Set the host name if it is not already set
- #
- if [ -z "`hostname -s`" ]; then
- hostname ${hostname}
- echo -n ' hostname'
- fi
-
- # Set the domainname if we're using NIS
- #
- case ${nisdomainname} in
- [Nn][Oo] | '')
- ;;
- *)
- domainname ${nisdomainname}
- echo -n ' domain'
- ;;
- esac
-
- echo '.'
-
- # Initial ATM interface configuration
- #
- case ${atm_enable} in
- [Yy][Ee][Ss])
- if [ -r /etc/rc.atm ]; then
- . /etc/rc.atm
- atm_pass1
- fi
- ;;
- esac
-
- # Special options for sppp(4) interfaces go here. These need
- # to go _before_ the general ifconfig section, since in the case
- # of hardwired (no link1 flag) but required authentication, you
- # cannot pass auth parameters down to the already running interface.
- #
- for ifn in ${sppp_interfaces}; do
- eval spppcontrol_args=\$spppconfig_${ifn}
- if [ -n "${spppcontrol_args}" ]; then
- # The auth secrets might contain spaces; in order
- # to retain the quotation, we need to eval them
- # here.
- eval spppcontrol ${ifn} ${spppcontrol_args}
- fi
- done
-
- # Set up all the network interfaces, calling startup scripts if needed
- #
- case ${network_interfaces} in
- [Aa][Uu][Tt][Oo])
- network_interfaces="`ifconfig -l`"
- ;;
- esac
-
- dhcp_interfaces=""
- for ifn in ${network_interfaces}; do
- if [ -r /etc/start_if.${ifn} ]; then
- . /etc/start_if.${ifn}
- eval showstat_$ifn=1
- fi
-
- # Do the primary ifconfig if specified
- #
- eval ifconfig_args=\$ifconfig_${ifn}
-
- case ${ifconfig_args} in
- '')
- ;;
- [Dd][Hh][Cc][Pp])
- # DHCP inits are done all in one go below
- dhcp_interfaces="$dhcp_interfaces $ifn"
- eval showstat_$ifn=1
- ;;
- *)
- ifconfig ${ifn} ${ifconfig_args}
- eval showstat_$ifn=1
- ;;
- esac
- done
-
- if [ ! -z "${dhcp_interfaces}" ]; then
- ${dhcp_program:-/sbin/dhclient} ${dhcp_flags} ${dhcp_interfaces}
- fi
-
- for ifn in ${network_interfaces}; do
- # Check to see if aliases need to be added
- #
- alias=0
- while : ; do
- eval ifconfig_args=\$ifconfig_${ifn}_alias${alias}
- if [ -n "${ifconfig_args}" ]; then
- ifconfig ${ifn} ${ifconfig_args} alias
- eval showstat_$ifn=1
- alias=`expr ${alias} + 1`
- else
- break;
- fi
- done
-
- # Do ipx address if specified
- #
- eval ifconfig_args=\$ifconfig_${ifn}_ipx
- if [ -n "${ifconfig_args}" ]; then
- ifconfig ${ifn} ${ifconfig_args}
- eval showstat_$ifn=1
- fi
- done
-
- for ifn in ${network_interfaces}; do
- eval showstat=\$showstat_${ifn}
- if [ ! -z ${showstat} ]; then
- ifconfig ${ifn}
- fi
- done
-
- # ISDN subsystem startup
- #
- case ${isdn_enable} in
- [Yy][Ee][Ss])
- if [ -r /etc/rc.isdn ]; then
- . /etc/rc.isdn
- fi
- ;;
- esac
-
- # Warm up user ppp if required, must happen before natd.
- #
- case ${ppp_enable} in
- [Yy][Ee][Ss])
- # Establish ppp mode.
- #
- if [ "${ppp_mode}" != "ddial" -a "${ppp_mode}" != "direct" \
- -a "${ppp_mode}" != "dedicated" \
- -a "${ppp_mode}" != "background" ]; then
- ppp_mode="auto";
- fi
-
- ppp_command="-${ppp_mode} ";
-
- # Switch on alias mode?
- #
- case ${ppp_nat} in
- [Yy][Ee][Ss])
- ppp_command="${ppp_command} -nat";
- ;;
- esac
-
- echo -n 'Starting ppp: '; ppp ${ppp_command} -quiet ${ppp_profile}
- ;;
- esac
-
- # Initialize IP filtering using ipfw
- #
- echo ''
-
- if /sbin/ipfw -q flush > /dev/null 2>&1; then
- firewall_in_kernel=1
- else
- firewall_in_kernel=0
- fi
-
- case ${firewall_enable} in
- [Yy][Ee][Ss])
- if [ "${firewall_in_kernel}" -eq 0 ] && kldload ipfw; then
- firewall_in_kernel=1
- echo "Kernel firewall module loaded."
- elif [ "${firewall_in_kernel}" -eq 0 ]; then
- echo "Warning: firewall kernel module failed to load."
- fi
- ;;
- esac
-
- # Load the filters if required
- #
- case ${firewall_in_kernel} in
- 1)
- if [ -z "${firewall_script}" ]; then
- firewall_script=/etc/rc.firewall
- fi
-
- case ${firewall_enable} in
- [Yy][Ee][Ss])
- if [ -r "${firewall_script}" ]; then
- . "${firewall_script}"
- echo -n 'Firewall rules loaded, starting divert daemons:'
-
- # Network Address Translation daemon
- #
- case ${natd_enable} in
- [Yy][Ee][Ss])
- if [ -n "${natd_interface}" ]; then
- if echo ${natd_interface} | \
- grep -q -E '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$'; then
- natd_ifarg="-a ${natd_interface}"
- else
- natd_ifarg="-n ${natd_interface}"
- fi
-
- echo -n ' natd'; ${natd_program:-/sbin/natd} ${natd_flags} ${natd_ifarg}
- fi
- ;;
- esac
-
- echo '.'
-
- elif [ "`ipfw l 65535`" = "65535 deny ip from any to any" ]; then
- echo -n "Warning: kernel has firewall functionality, "
- echo "but firewall rules are not enabled."
- echo " All ip services are disabled."
- fi
- ;;
- esac
- ;;
- esac
-
- # Additional ATM interface configuration
- #
- if [ -n "${atm_pass1_done}" ]; then
- atm_pass2
- fi
-
- # Configure routing
- #
- case ${defaultrouter} in
- [Nn][Oo] | '')
- ;;
- *)
- static_routes="default ${static_routes}"
- route_default="default ${defaultrouter}"
- ;;
- esac
-
- # Set up any static routes. This should be done before router discovery.
- #
- if [ -n "${static_routes}" ]; then
- for i in ${static_routes}; do
- eval route_args=\$route_${i}
- route add ${route_args}
- done
- fi
-
- echo -n 'Additional routing options:'
- case ${tcp_extensions} in
- [Yy][Ee][Ss] | '')
- ;;
- *)
- echo -n ' tcp extensions=NO'
- sysctl -w net.inet.tcp.rfc1323=0 >/dev/null
- ;;
- esac
-
- case ${icmp_bmcastecho} in
- [Yy][Ee][Ss])
- echo -n ' broadcast ping responses=YES'
- sysctl -w net.inet.icmp.bmcastecho=1 >/dev/null
- ;;
- esac
-
- case ${icmp_drop_redirect} in
- [Yy][Ee][Ss])
- echo -n ' ignore ICMP redirect=YES'
- sysctl -w net.inet.icmp.drop_redirect=1 >/dev/null
- ;;
- esac
-
- case ${icmp_log_redirect} in
- [Yy][Ee][Ss])
- echo -n ' log ICMP redirect=YES'
- sysctl -w net.inet.icmp.log_redirect=1 >/dev/null
- ;;
- esac
-
- case ${gateway_enable} in
- [Yy][Ee][Ss])
- echo -n ' IP gateway=YES'
- sysctl -w net.inet.ip.forwarding=1 >/dev/null
- ;;
- esac
-
- case ${forward_sourceroute} in
- [Yy][Ee][Ss])
- echo -n ' do source routing=YES'
- sysctl -w net.inet.ip.sourceroute=1 >/dev/null
- ;;
- esac
-
- case ${accept_sourceroute} in
- [Yy][Ee][Ss])
- echo -n ' accept source routing=YES'
- sysctl -w net.inet.ip.accept_sourceroute=1 >/dev/null
- ;;
- esac
-
- case ${tcp_keepalive} in
- [Yy][Ee][Ss])
- echo -n ' TCP keepalive=YES'
- sysctl -w net.inet.tcp.always_keepalive=1 >/dev/null
- ;;
- esac
-
- case ${tcp_restrict_rst} in
- [Yy][Ee][Ss])
- echo -n ' restrict TCP reset=YES'
- sysctl -w net.inet.tcp.restrict_rst=1 >/dev/null
- ;;
- esac
-
- case ${tcp_drop_synfin} in
- [Yy][Ee][Ss])
- echo -n ' drop SYN+FIN packets=YES'
- sysctl -w net.inet.tcp.drop_synfin=1 >/dev/null
- ;;
- esac
-
- case ${ipxgateway_enable} in
- [Yy][Ee][Ss])
- echo -n ' IPX gateway=YES'
- sysctl -w net.ipx.ipx.ipxforwarding=1 >/dev/null
- ;;
- esac
-
- case ${arpproxy_all} in
- [Yy][Ee][Ss])
- echo -n ' ARP proxyall=YES'
- sysctl -w net.link.ether.inet.proxyall=1 >/dev/null
- ;;
- esac
- echo '.'
-
- echo -n 'routing daemons:'
- case ${router_enable} in
- [Yy][Ee][Ss])
- echo -n " ${router}"; ${router} ${router_flags}
- ;;
- esac
-
- case ${ipxrouted_enable} in
- [Yy][Ee][Ss])
- echo -n ' IPXrouted'
- IPXrouted ${ipxrouted_flags} > /dev/null 2>&1
- ;;
- esac
-
- case ${mrouted_enable} in
- [Yy][Ee][Ss])
- echo -n ' mrouted'; mrouted ${mrouted_flags}
- ;;
- esac
-
- case ${rarpd_enable} in
- [Yy][Ee][Ss])
- echo -n ' rarpd'; rarpd ${rarpd_flags}
- ;;
- esac
- echo '.'
-
- # Let future generations know we made it.
- #
- network_pass1_done=YES
-}
-
-network_pass2() {
- echo -n 'Doing additional network setup:'
- case ${named_enable} in
- [Yy][Ee][Ss])
- echo -n ' named'; ${named_program:-named} ${named_flags}
- ;;
- esac
-
- case ${ntpdate_enable} in
- [Yy][Ee][Ss])
- echo -n ' ntpdate'
- ${ntpdate_program:-ntpdate} ${ntpdate_flags} >/dev/null 2>&1
- ;;
- esac
-
- case ${xntpd_enable} in
- [Yy][Ee][Ss])
- echo -n ' ntpd'; ${xntpd_program:-ntpd} ${xntpd_flags}
- ;;
- esac
-
- case ${timed_enable} in
- [Yy][Ee][Ss])
- echo -n ' timed'; timed ${timed_flags}
- ;;
- esac
-
- case ${portmap_enable} in
- [Yy][Ee][Ss])
- echo -n ' portmap'; ${portmap_program:-/usr/sbin/portmap} ${portmap_flags}
- ;;
- esac
-
- # Start ypserv if we're an NIS server.
- # Run rpc.ypxfrd and rpc.yppasswdd only on the NIS master server.
- #
- case ${nis_server_enable} in
- [Yy][Ee][Ss])
- echo -n ' ypserv'; ypserv ${nis_server_flags}
-
- case ${nis_ypxfrd_enable} in
- [Yy][Ee][Ss])
- echo -n ' rpc.ypxfrd'
- rpc.ypxfrd ${nis_ypxfrd_flags}
- ;;
- esac
-
- case ${nis_yppasswdd_enable} in
- [Yy][Ee][Ss])
- echo -n ' rpc.yppasswdd'
- rpc.yppasswdd ${nis_yppasswdd_flags}
- ;;
- esac
- ;;
- esac
-
- # Start ypbind if we're an NIS client
- #
- case ${nis_client_enable} in
- [Yy][Ee][Ss])
- echo -n ' ypbind'; ypbind ${nis_client_flags}
- case ${nis_ypset_enable} in
- [Yy][Ee][Ss])
- echo -n ' ypset'; ypset ${nis_ypset_flags}
- ;;
- esac
- ;;
- esac
-
- # Start keyserv if we are running Secure RPC
- #
- case ${keyserv_enable} in
- [Yy][Ee][Ss])
- echo -n ' keyserv'; keyserv ${keyserv_flags}
- ;;
- esac
-
- # Start ypupdated if we are running Secure RPC and we are NIS master
- #
- case ${rpc_ypupdated_enable} in
- [Yy][Ee][Ss])
- echo -n ' rpc.ypupdated'; rpc.ypupdated
- ;;
- esac
-
- # Start ATM daemons
- if [ -n "${atm_pass2_done}" ]; then
- atm_pass3
- fi
-
- echo '.'
- network_pass2_done=YES
-}
-
-network_pass3() {
- echo -n 'Starting final network daemons:'
-
- case ${nfs_server_enable} in
- [Yy][Ee][Ss])
- if [ -r /etc/exports ]; then
- echo -n ' mountd'
-
- case ${weak_mountd_authentication} in
- [Yy][Ee][Ss])
- mountd_flags="-n"
- ;;
- esac
-
- mountd ${mountd_flags}
-
- case ${nfs_reserved_port_only} in
- [Yy][Ee][Ss])
- echo -n ' NFS on reserved port only=YES'
- sysctl -w vfs.nfs.nfs_privport=1 >/dev/null
- ;;
- esac
-
- echo -n ' nfsd'; nfsd ${nfs_server_flags}
-
- case ${rpc_lockd_enable} in
- [Yy][Ee][Ss])
- echo -n ' rpc.lockd'; rpc.lockd
- ;;
- esac
-
- case ${rpc_statd_enable} in
- [Yy][Ee][Ss])
- echo -n ' rpc.statd'; rpc.statd
- ;;
- esac
- fi
- ;;
- *)
- case ${single_mountd_enable} in
- [Yy][Ee][Ss])
- if [ -r /etc/exports ]; then
- echo -n ' mountd'
-
- case ${weak_mountd_authentication} in
- [Yy][Ee][Ss])
- mountd_flags="-n"
- ;;
- esac
-
- mountd ${mountd_flags}
- fi
- ;;
- esac
- ;;
- esac
-
- case ${nfs_client_enable} in
- [Yy][Ee][Ss])
- echo -n ' nfsiod'; nfsiod ${nfs_client_flags}
- if [ -n "${nfs_access_cache}" ]; then
- echo -n " NFS access cache time=${nfs_access_cache}"
- sysctl -w vfs.nfs.access_cache_timeout=${nfs_access_cache} \
- >/dev/null
- fi
- ;;
- esac
-
- # If /var/db/mounttab exists, some nfs-server has not been
- # sucessfully notified about a previous client shutdown.
- # If there is no /var/db/mounttab, we do nothing.
- if [ -f /var/db/mounttab ]; then
- rpc.umntall -k
- fi
-
- case ${amd_enable} in
- [Yy][Ee][Ss])
- echo -n ' amd'
- case ${amd_map_program} in
- [Nn][Oo] | '')
- ;;
- *)
- amd_flags="${amd_flags} `eval ${amd_map_program}`"
- ;;
- esac
-
- if [ -n "${amd_flags}" ]; then
- amd -p ${amd_flags} > /var/run/amd.pid 2> /dev/null
- else
- amd 2> /dev/null
- fi
- ;;
- esac
-
- case ${rwhod_enable} in
- [Yy][Ee][Ss])
- echo -n ' rwhod'; rwhod ${rwhod_flags}
- ;;
- esac
-
- # Kerberos runs ONLY on the Kerberos server machine
- case ${kerberos_server_enable} in
- [Yy][Ee][Ss])
- case ${kerberos_stash} in
- [Yy][Ee][Ss])
- stash_flag=-n
- ;;
- *)
- stash_flag=
- ;;
- esac
-
- echo -n ' kerberos'
- kerberos ${stash_flag} >> /var/log/kerberos.log &
-
- case ${kadmind_server_enable} in
- [Yy][Ee][Ss])
- echo -n ' kadmind'
- (sleep 20; kadmind ${stash_flag} >/dev/null 2>&1 &) &
- ;;
- esac
- unset stash_flag
- ;;
- esac
-
- case ${pppoed_enable} in
- [Yy][Ee][Ss])
- if [ -n "${pppoed_provider}" ]; then
- pppoed_flags="${pppoed_flags} -p ${pppoed_provider}"
- fi
- echo -n ' pppoed';
- /usr/libexec/pppoed ${pppoed_flags} ${pppoed_interface}
- ;;
- esac
-
- case ${sshd_enable} in
- [Yy][Ee][Ss])
- if [ ! -f /etc/ssh/ssh_host_key ]; then
- echo ' creating ssh host key';
- /usr/bin/ssh-keygen -N "" -f /etc/ssh/ssh_host_key
- fi
- ;;
- esac
-
- echo '.'
- network_pass3_done=YES
-}
-
-network_pass4() {
- echo -n 'Additional TCP options:'
- case ${log_in_vain} in
- [Nn][Oo] | '')
- ;;
- *)
- echo -n ' log_in_vain=YES'
- sysctl -w net.inet.tcp.log_in_vain=1 >/dev/null
- sysctl -w net.inet.udp.log_in_vain=1 >/dev/null
- ;;
- esac
-
- echo '.'
- network_pass4_done=YES
-}
diff --git a/etc/rc.d/network2 b/etc/rc.d/network2
deleted file mode 100644
index 0211181f0516..000000000000
--- a/etc/rc.d/network2
+++ /dev/null
@@ -1,633 +0,0 @@
-#!/bin/sh -
-#
-# $FreeBSD$
-# From: @(#)netstart 5.9 (Berkeley) 3/30/91
-
-# Note that almost all of the user-configurable behavior is no longer in
-# this file, but rather in /etc/defaults/rc.conf. Please check that file
-# first before contemplating any changes here. If you do need to change
-# this file for some reason, we would like to know about it.
-
-# First pass startup stuff.
-#
-network_pass1() {
- echo -n 'Doing initial network setup:'
-
- # Set the host name if it is not already set
- #
- if [ -z "`hostname -s`" ]; then
- hostname ${hostname}
- echo -n ' hostname'
- fi
-
- # Set the domainname if we're using NIS
- #
- case ${nisdomainname} in
- [Nn][Oo] | '')
- ;;
- *)
- domainname ${nisdomainname}
- echo -n ' domain'
- ;;
- esac
-
- echo '.'
-
- # Initial ATM interface configuration
- #
- case ${atm_enable} in
- [Yy][Ee][Ss])
- if [ -r /etc/rc.atm ]; then
- . /etc/rc.atm
- atm_pass1
- fi
- ;;
- esac
-
- # Special options for sppp(4) interfaces go here. These need
- # to go _before_ the general ifconfig section, since in the case
- # of hardwired (no link1 flag) but required authentication, you
- # cannot pass auth parameters down to the already running interface.
- #
- for ifn in ${sppp_interfaces}; do
- eval spppcontrol_args=\$spppconfig_${ifn}
- if [ -n "${spppcontrol_args}" ]; then
- # The auth secrets might contain spaces; in order
- # to retain the quotation, we need to eval them
- # here.
- eval spppcontrol ${ifn} ${spppcontrol_args}
- fi
- done
-
- # Set up all the network interfaces, calling startup scripts if needed
- #
- case ${network_interfaces} in
- [Aa][Uu][Tt][Oo])
- network_interfaces="`ifconfig -l`"
- ;;
- esac
-
- dhcp_interfaces=""
- for ifn in ${network_interfaces}; do
- if [ -r /etc/start_if.${ifn} ]; then
- . /etc/start_if.${ifn}
- eval showstat_$ifn=1
- fi
-
- # Do the primary ifconfig if specified
- #
- eval ifconfig_args=\$ifconfig_${ifn}
-
- case ${ifconfig_args} in
- '')
- ;;
- [Dd][Hh][Cc][Pp])
- # DHCP inits are done all in one go below
- dhcp_interfaces="$dhcp_interfaces $ifn"
- eval showstat_$ifn=1
- ;;
- *)
- ifconfig ${ifn} ${ifconfig_args}
- eval showstat_$ifn=1
- ;;
- esac
- done
-
- if [ ! -z "${dhcp_interfaces}" ]; then
- ${dhcp_program:-/sbin/dhclient} ${dhcp_flags} ${dhcp_interfaces}
- fi
-
- for ifn in ${network_interfaces}; do
- # Check to see if aliases need to be added
- #
- alias=0
- while : ; do
- eval ifconfig_args=\$ifconfig_${ifn}_alias${alias}
- if [ -n "${ifconfig_args}" ]; then
- ifconfig ${ifn} ${ifconfig_args} alias
- eval showstat_$ifn=1
- alias=`expr ${alias} + 1`
- else
- break;
- fi
- done
-
- # Do ipx address if specified
- #
- eval ifconfig_args=\$ifconfig_${ifn}_ipx
- if [ -n "${ifconfig_args}" ]; then
- ifconfig ${ifn} ${ifconfig_args}
- eval showstat_$ifn=1
- fi
- done
-
- for ifn in ${network_interfaces}; do
- eval showstat=\$showstat_${ifn}
- if [ ! -z ${showstat} ]; then
- ifconfig ${ifn}
- fi
- done
-
- # ISDN subsystem startup
- #
- case ${isdn_enable} in
- [Yy][Ee][Ss])
- if [ -r /etc/rc.isdn ]; then
- . /etc/rc.isdn
- fi
- ;;
- esac
-
- # Warm up user ppp if required, must happen before natd.
- #
- case ${ppp_enable} in
- [Yy][Ee][Ss])
- # Establish ppp mode.
- #
- if [ "${ppp_mode}" != "ddial" -a "${ppp_mode}" != "direct" \
- -a "${ppp_mode}" != "dedicated" \
- -a "${ppp_mode}" != "background" ]; then
- ppp_mode="auto";
- fi
-
- ppp_command="-${ppp_mode} ";
-
- # Switch on alias mode?
- #
- case ${ppp_nat} in
- [Yy][Ee][Ss])
- ppp_command="${ppp_command} -nat";
- ;;
- esac
-
- echo -n 'Starting ppp: '; ppp ${ppp_command} -quiet ${ppp_profile}
- ;;
- esac
-
- # Initialize IP filtering using ipfw
- #
- echo ''
-
- if /sbin/ipfw -q flush > /dev/null 2>&1; then
- firewall_in_kernel=1
- else
- firewall_in_kernel=0
- fi
-
- case ${firewall_enable} in
- [Yy][Ee][Ss])
- if [ "${firewall_in_kernel}" -eq 0 ] && kldload ipfw; then
- firewall_in_kernel=1
- echo "Kernel firewall module loaded."
- elif [ "${firewall_in_kernel}" -eq 0 ]; then
- echo "Warning: firewall kernel module failed to load."
- fi
- ;;
- esac
-
- # Load the filters if required
- #
- case ${firewall_in_kernel} in
- 1)
- if [ -z "${firewall_script}" ]; then
- firewall_script=/etc/rc.firewall
- fi
-
- case ${firewall_enable} in
- [Yy][Ee][Ss])
- if [ -r "${firewall_script}" ]; then
- . "${firewall_script}"
- echo -n 'Firewall rules loaded, starting divert daemons:'
-
- # Network Address Translation daemon
- #
- case ${natd_enable} in
- [Yy][Ee][Ss])
- if [ -n "${natd_interface}" ]; then
- if echo ${natd_interface} | \
- grep -q -E '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$'; then
- natd_ifarg="-a ${natd_interface}"
- else
- natd_ifarg="-n ${natd_interface}"
- fi
-
- echo -n ' natd'; ${natd_program:-/sbin/natd} ${natd_flags} ${natd_ifarg}
- fi
- ;;
- esac
-
- echo '.'
-
- elif [ "`ipfw l 65535`" = "65535 deny ip from any to any" ]; then
- echo -n "Warning: kernel has firewall functionality, "
- echo "but firewall rules are not enabled."
- echo " All ip services are disabled."
- fi
- ;;
- esac
- ;;
- esac
-
- # Additional ATM interface configuration
- #
- if [ -n "${atm_pass1_done}" ]; then
- atm_pass2
- fi
-
- # Configure routing
- #
- case ${defaultrouter} in
- [Nn][Oo] | '')
- ;;
- *)
- static_routes="default ${static_routes}"
- route_default="default ${defaultrouter}"
- ;;
- esac
-
- # Set up any static routes. This should be done before router discovery.
- #
- if [ -n "${static_routes}" ]; then
- for i in ${static_routes}; do
- eval route_args=\$route_${i}
- route add ${route_args}
- done
- fi
-
- echo -n 'Additional routing options:'
- case ${tcp_extensions} in
- [Yy][Ee][Ss] | '')
- ;;
- *)
- echo -n ' tcp extensions=NO'
- sysctl -w net.inet.tcp.rfc1323=0 >/dev/null
- ;;
- esac
-
- case ${icmp_bmcastecho} in
- [Yy][Ee][Ss])
- echo -n ' broadcast ping responses=YES'
- sysctl -w net.inet.icmp.bmcastecho=1 >/dev/null
- ;;
- esac
-
- case ${icmp_drop_redirect} in
- [Yy][Ee][Ss])
- echo -n ' ignore ICMP redirect=YES'
- sysctl -w net.inet.icmp.drop_redirect=1 >/dev/null
- ;;
- esac
-
- case ${icmp_log_redirect} in
- [Yy][Ee][Ss])
- echo -n ' log ICMP redirect=YES'
- sysctl -w net.inet.icmp.log_redirect=1 >/dev/null
- ;;
- esac
-
- case ${gateway_enable} in
- [Yy][Ee][Ss])
- echo -n ' IP gateway=YES'
- sysctl -w net.inet.ip.forwarding=1 >/dev/null
- ;;
- esac
-
- case ${forward_sourceroute} in
- [Yy][Ee][Ss])
- echo -n ' do source routing=YES'
- sysctl -w net.inet.ip.sourceroute=1 >/dev/null
- ;;
- esac
-
- case ${accept_sourceroute} in
- [Yy][Ee][Ss])
- echo -n ' accept source routing=YES'
- sysctl -w net.inet.ip.accept_sourceroute=1 >/dev/null
- ;;
- esac
-
- case ${tcp_keepalive} in
- [Yy][Ee][Ss])
- echo -n ' TCP keepalive=YES'
- sysctl -w net.inet.tcp.always_keepalive=1 >/dev/null
- ;;
- esac
-
- case ${tcp_restrict_rst} in
- [Yy][Ee][Ss])
- echo -n ' restrict TCP reset=YES'
- sysctl -w net.inet.tcp.restrict_rst=1 >/dev/null
- ;;
- esac
-
- case ${tcp_drop_synfin} in
- [Yy][Ee][Ss])
- echo -n ' drop SYN+FIN packets=YES'
- sysctl -w net.inet.tcp.drop_synfin=1 >/dev/null
- ;;
- esac
-
- case ${ipxgateway_enable} in
- [Yy][Ee][Ss])
- echo -n ' IPX gateway=YES'
- sysctl -w net.ipx.ipx.ipxforwarding=1 >/dev/null
- ;;
- esac
-
- case ${arpproxy_all} in
- [Yy][Ee][Ss])
- echo -n ' ARP proxyall=YES'
- sysctl -w net.link.ether.inet.proxyall=1 >/dev/null
- ;;
- esac
- echo '.'
-
- echo -n 'routing daemons:'
- case ${router_enable} in
- [Yy][Ee][Ss])
- echo -n " ${router}"; ${router} ${router_flags}
- ;;
- esac
-
- case ${ipxrouted_enable} in
- [Yy][Ee][Ss])
- echo -n ' IPXrouted'
- IPXrouted ${ipxrouted_flags} > /dev/null 2>&1
- ;;
- esac
-
- case ${mrouted_enable} in
- [Yy][Ee][Ss])
- echo -n ' mrouted'; mrouted ${mrouted_flags}
- ;;
- esac
-
- case ${rarpd_enable} in
- [Yy][Ee][Ss])
- echo -n ' rarpd'; rarpd ${rarpd_flags}
- ;;
- esac
- echo '.'
-
- # Let future generations know we made it.
- #
- network_pass1_done=YES
-}
-
-network_pass2() {
- echo -n 'Doing additional network setup:'
- case ${named_enable} in
- [Yy][Ee][Ss])
- echo -n ' named'; ${named_program:-named} ${named_flags}
- ;;
- esac
-
- case ${ntpdate_enable} in
- [Yy][Ee][Ss])
- echo -n ' ntpdate'
- ${ntpdate_program:-ntpdate} ${ntpdate_flags} >/dev/null 2>&1
- ;;
- esac
-
- case ${xntpd_enable} in
- [Yy][Ee][Ss])
- echo -n ' ntpd'; ${xntpd_program:-ntpd} ${xntpd_flags}
- ;;
- esac
-
- case ${timed_enable} in
- [Yy][Ee][Ss])
- echo -n ' timed'; timed ${timed_flags}
- ;;
- esac
-
- case ${portmap_enable} in
- [Yy][Ee][Ss])
- echo -n ' portmap'; ${portmap_program:-/usr/sbin/portmap} ${portmap_flags}
- ;;
- esac
-
- # Start ypserv if we're an NIS server.
- # Run rpc.ypxfrd and rpc.yppasswdd only on the NIS master server.
- #
- case ${nis_server_enable} in
- [Yy][Ee][Ss])
- echo -n ' ypserv'; ypserv ${nis_server_flags}
-
- case ${nis_ypxfrd_enable} in
- [Yy][Ee][Ss])
- echo -n ' rpc.ypxfrd'
- rpc.ypxfrd ${nis_ypxfrd_flags}
- ;;
- esac
-
- case ${nis_yppasswdd_enable} in
- [Yy][Ee][Ss])
- echo -n ' rpc.yppasswdd'
- rpc.yppasswdd ${nis_yppasswdd_flags}
- ;;
- esac
- ;;
- esac
-
- # Start ypbind if we're an NIS client
- #
- case ${nis_client_enable} in
- [Yy][Ee][Ss])
- echo -n ' ypbind'; ypbind ${nis_client_flags}
- case ${nis_ypset_enable} in
- [Yy][Ee][Ss])
- echo -n ' ypset'; ypset ${nis_ypset_flags}
- ;;
- esac
- ;;
- esac
-
- # Start keyserv if we are running Secure RPC
- #
- case ${keyserv_enable} in
- [Yy][Ee][Ss])
- echo -n ' keyserv'; keyserv ${keyserv_flags}
- ;;
- esac
-
- # Start ypupdated if we are running Secure RPC and we are NIS master
- #
- case ${rpc_ypupdated_enable} in
- [Yy][Ee][Ss])
- echo -n ' rpc.ypupdated'; rpc.ypupdated
- ;;
- esac
-
- # Start ATM daemons
- if [ -n "${atm_pass2_done}" ]; then
- atm_pass3
- fi
-
- echo '.'
- network_pass2_done=YES
-}
-
-network_pass3() {
- echo -n 'Starting final network daemons:'
-
- case ${nfs_server_enable} in
- [Yy][Ee][Ss])
- if [ -r /etc/exports ]; then
- echo -n ' mountd'
-
- case ${weak_mountd_authentication} in
- [Yy][Ee][Ss])
- mountd_flags="-n"
- ;;
- esac
-
- mountd ${mountd_flags}
-
- case ${nfs_reserved_port_only} in
- [Yy][Ee][Ss])
- echo -n ' NFS on reserved port only=YES'
- sysctl -w vfs.nfs.nfs_privport=1 >/dev/null
- ;;
- esac
-
- echo -n ' nfsd'; nfsd ${nfs_server_flags}
-
- case ${rpc_lockd_enable} in
- [Yy][Ee][Ss])
- echo -n ' rpc.lockd'; rpc.lockd
- ;;
- esac
-
- case ${rpc_statd_enable} in
- [Yy][Ee][Ss])
- echo -n ' rpc.statd'; rpc.statd
- ;;
- esac
- fi
- ;;
- *)
- case ${single_mountd_enable} in
- [Yy][Ee][Ss])
- if [ -r /etc/exports ]; then
- echo -n ' mountd'
-
- case ${weak_mountd_authentication} in
- [Yy][Ee][Ss])
- mountd_flags="-n"
- ;;
- esac
-
- mountd ${mountd_flags}
- fi
- ;;
- esac
- ;;
- esac
-
- case ${nfs_client_enable} in
- [Yy][Ee][Ss])
- echo -n ' nfsiod'; nfsiod ${nfs_client_flags}
- if [ -n "${nfs_access_cache}" ]; then
- echo -n " NFS access cache time=${nfs_access_cache}"
- sysctl -w vfs.nfs.access_cache_timeout=${nfs_access_cache} \
- >/dev/null
- fi
- ;;
- esac
-
- # If /var/db/mounttab exists, some nfs-server has not been
- # sucessfully notified about a previous client shutdown.
- # If there is no /var/db/mounttab, we do nothing.
- if [ -f /var/db/mounttab ]; then
- rpc.umntall -k
- fi
-
- case ${amd_enable} in
- [Yy][Ee][Ss])
- echo -n ' amd'
- case ${amd_map_program} in
- [Nn][Oo] | '')
- ;;
- *)
- amd_flags="${amd_flags} `eval ${amd_map_program}`"
- ;;
- esac
-
- if [ -n "${amd_flags}" ]; then
- amd -p ${amd_flags} > /var/run/amd.pid 2> /dev/null
- else
- amd 2> /dev/null
- fi
- ;;
- esac
-
- case ${rwhod_enable} in
- [Yy][Ee][Ss])
- echo -n ' rwhod'; rwhod ${rwhod_flags}
- ;;
- esac
-
- # Kerberos runs ONLY on the Kerberos server machine
- case ${kerberos_server_enable} in
- [Yy][Ee][Ss])
- case ${kerberos_stash} in
- [Yy][Ee][Ss])
- stash_flag=-n
- ;;
- *)
- stash_flag=
- ;;
- esac
-
- echo -n ' kerberos'
- kerberos ${stash_flag} >> /var/log/kerberos.log &
-
- case ${kadmind_server_enable} in
- [Yy][Ee][Ss])
- echo -n ' kadmind'
- (sleep 20; kadmind ${stash_flag} >/dev/null 2>&1 &) &
- ;;
- esac
- unset stash_flag
- ;;
- esac
-
- case ${pppoed_enable} in
- [Yy][Ee][Ss])
- if [ -n "${pppoed_provider}" ]; then
- pppoed_flags="${pppoed_flags} -p ${pppoed_provider}"
- fi
- echo -n ' pppoed';
- /usr/libexec/pppoed ${pppoed_flags} ${pppoed_interface}
- ;;
- esac
-
- case ${sshd_enable} in
- [Yy][Ee][Ss])
- if [ ! -f /etc/ssh/ssh_host_key ]; then
- echo ' creating ssh host key';
- /usr/bin/ssh-keygen -N "" -f /etc/ssh/ssh_host_key
- fi
- ;;
- esac
-
- echo '.'
- network_pass3_done=YES
-}
-
-network_pass4() {
- echo -n 'Additional TCP options:'
- case ${log_in_vain} in
- [Nn][Oo] | '')
- ;;
- *)
- echo -n ' log_in_vain=YES'
- sysctl -w net.inet.tcp.log_in_vain=1 >/dev/null
- sysctl -w net.inet.udp.log_in_vain=1 >/dev/null
- ;;
- esac
-
- echo '.'
- network_pass4_done=YES
-}
diff --git a/etc/rc.d/network3 b/etc/rc.d/network3
deleted file mode 100644
index 0211181f0516..000000000000
--- a/etc/rc.d/network3
+++ /dev/null
@@ -1,633 +0,0 @@
-#!/bin/sh -
-#
-# $FreeBSD$
-# From: @(#)netstart 5.9 (Berkeley) 3/30/91
-
-# Note that almost all of the user-configurable behavior is no longer in
-# this file, but rather in /etc/defaults/rc.conf. Please check that file
-# first before contemplating any changes here. If you do need to change
-# this file for some reason, we would like to know about it.
-
-# First pass startup stuff.
-#
-network_pass1() {
- echo -n 'Doing initial network setup:'
-
- # Set the host name if it is not already set
- #
- if [ -z "`hostname -s`" ]; then
- hostname ${hostname}
- echo -n ' hostname'
- fi
-
- # Set the domainname if we're using NIS
- #
- case ${nisdomainname} in
- [Nn][Oo] | '')
- ;;
- *)
- domainname ${nisdomainname}
- echo -n ' domain'
- ;;
- esac
-
- echo '.'
-
- # Initial ATM interface configuration
- #
- case ${atm_enable} in
- [Yy][Ee][Ss])
- if [ -r /etc/rc.atm ]; then
- . /etc/rc.atm
- atm_pass1
- fi
- ;;
- esac
-
- # Special options for sppp(4) interfaces go here. These need
- # to go _before_ the general ifconfig section, since in the case
- # of hardwired (no link1 flag) but required authentication, you
- # cannot pass auth parameters down to the already running interface.
- #
- for ifn in ${sppp_interfaces}; do
- eval spppcontrol_args=\$spppconfig_${ifn}
- if [ -n "${spppcontrol_args}" ]; then
- # The auth secrets might contain spaces; in order
- # to retain the quotation, we need to eval them
- # here.
- eval spppcontrol ${ifn} ${spppcontrol_args}
- fi
- done
-
- # Set up all the network interfaces, calling startup scripts if needed
- #
- case ${network_interfaces} in
- [Aa][Uu][Tt][Oo])
- network_interfaces="`ifconfig -l`"
- ;;
- esac
-
- dhcp_interfaces=""
- for ifn in ${network_interfaces}; do
- if [ -r /etc/start_if.${ifn} ]; then
- . /etc/start_if.${ifn}
- eval showstat_$ifn=1
- fi
-
- # Do the primary ifconfig if specified
- #
- eval ifconfig_args=\$ifconfig_${ifn}
-
- case ${ifconfig_args} in
- '')
- ;;
- [Dd][Hh][Cc][Pp])
- # DHCP inits are done all in one go below
- dhcp_interfaces="$dhcp_interfaces $ifn"
- eval showstat_$ifn=1
- ;;
- *)
- ifconfig ${ifn} ${ifconfig_args}
- eval showstat_$ifn=1
- ;;
- esac
- done
-
- if [ ! -z "${dhcp_interfaces}" ]; then
- ${dhcp_program:-/sbin/dhclient} ${dhcp_flags} ${dhcp_interfaces}
- fi
-
- for ifn in ${network_interfaces}; do
- # Check to see if aliases need to be added
- #
- alias=0
- while : ; do
- eval ifconfig_args=\$ifconfig_${ifn}_alias${alias}
- if [ -n "${ifconfig_args}" ]; then
- ifconfig ${ifn} ${ifconfig_args} alias
- eval showstat_$ifn=1
- alias=`expr ${alias} + 1`
- else
- break;
- fi
- done
-
- # Do ipx address if specified
- #
- eval ifconfig_args=\$ifconfig_${ifn}_ipx
- if [ -n "${ifconfig_args}" ]; then
- ifconfig ${ifn} ${ifconfig_args}
- eval showstat_$ifn=1
- fi
- done
-
- for ifn in ${network_interfaces}; do
- eval showstat=\$showstat_${ifn}
- if [ ! -z ${showstat} ]; then
- ifconfig ${ifn}
- fi
- done
-
- # ISDN subsystem startup
- #
- case ${isdn_enable} in
- [Yy][Ee][Ss])
- if [ -r /etc/rc.isdn ]; then
- . /etc/rc.isdn
- fi
- ;;
- esac
-
- # Warm up user ppp if required, must happen before natd.
- #
- case ${ppp_enable} in
- [Yy][Ee][Ss])
- # Establish ppp mode.
- #
- if [ "${ppp_mode}" != "ddial" -a "${ppp_mode}" != "direct" \
- -a "${ppp_mode}" != "dedicated" \
- -a "${ppp_mode}" != "background" ]; then
- ppp_mode="auto";
- fi
-
- ppp_command="-${ppp_mode} ";
-
- # Switch on alias mode?
- #
- case ${ppp_nat} in
- [Yy][Ee][Ss])
- ppp_command="${ppp_command} -nat";
- ;;
- esac
-
- echo -n 'Starting ppp: '; ppp ${ppp_command} -quiet ${ppp_profile}
- ;;
- esac
-
- # Initialize IP filtering using ipfw
- #
- echo ''
-
- if /sbin/ipfw -q flush > /dev/null 2>&1; then
- firewall_in_kernel=1
- else
- firewall_in_kernel=0
- fi
-
- case ${firewall_enable} in
- [Yy][Ee][Ss])
- if [ "${firewall_in_kernel}" -eq 0 ] && kldload ipfw; then
- firewall_in_kernel=1
- echo "Kernel firewall module loaded."
- elif [ "${firewall_in_kernel}" -eq 0 ]; then
- echo "Warning: firewall kernel module failed to load."
- fi
- ;;
- esac
-
- # Load the filters if required
- #
- case ${firewall_in_kernel} in
- 1)
- if [ -z "${firewall_script}" ]; then
- firewall_script=/etc/rc.firewall
- fi
-
- case ${firewall_enable} in
- [Yy][Ee][Ss])
- if [ -r "${firewall_script}" ]; then
- . "${firewall_script}"
- echo -n 'Firewall rules loaded, starting divert daemons:'
-
- # Network Address Translation daemon
- #
- case ${natd_enable} in
- [Yy][Ee][Ss])
- if [ -n "${natd_interface}" ]; then
- if echo ${natd_interface} | \
- grep -q -E '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$'; then
- natd_ifarg="-a ${natd_interface}"
- else
- natd_ifarg="-n ${natd_interface}"
- fi
-
- echo -n ' natd'; ${natd_program:-/sbin/natd} ${natd_flags} ${natd_ifarg}
- fi
- ;;
- esac
-
- echo '.'
-
- elif [ "`ipfw l 65535`" = "65535 deny ip from any to any" ]; then
- echo -n "Warning: kernel has firewall functionality, "
- echo "but firewall rules are not enabled."
- echo " All ip services are disabled."
- fi
- ;;
- esac
- ;;
- esac
-
- # Additional ATM interface configuration
- #
- if [ -n "${atm_pass1_done}" ]; then
- atm_pass2
- fi
-
- # Configure routing
- #
- case ${defaultrouter} in
- [Nn][Oo] | '')
- ;;
- *)
- static_routes="default ${static_routes}"
- route_default="default ${defaultrouter}"
- ;;
- esac
-
- # Set up any static routes. This should be done before router discovery.
- #
- if [ -n "${static_routes}" ]; then
- for i in ${static_routes}; do
- eval route_args=\$route_${i}
- route add ${route_args}
- done
- fi
-
- echo -n 'Additional routing options:'
- case ${tcp_extensions} in
- [Yy][Ee][Ss] | '')
- ;;
- *)
- echo -n ' tcp extensions=NO'
- sysctl -w net.inet.tcp.rfc1323=0 >/dev/null
- ;;
- esac
-
- case ${icmp_bmcastecho} in
- [Yy][Ee][Ss])
- echo -n ' broadcast ping responses=YES'
- sysctl -w net.inet.icmp.bmcastecho=1 >/dev/null
- ;;
- esac
-
- case ${icmp_drop_redirect} in
- [Yy][Ee][Ss])
- echo -n ' ignore ICMP redirect=YES'
- sysctl -w net.inet.icmp.drop_redirect=1 >/dev/null
- ;;
- esac
-
- case ${icmp_log_redirect} in
- [Yy][Ee][Ss])
- echo -n ' log ICMP redirect=YES'
- sysctl -w net.inet.icmp.log_redirect=1 >/dev/null
- ;;
- esac
-
- case ${gateway_enable} in
- [Yy][Ee][Ss])
- echo -n ' IP gateway=YES'
- sysctl -w net.inet.ip.forwarding=1 >/dev/null
- ;;
- esac
-
- case ${forward_sourceroute} in
- [Yy][Ee][Ss])
- echo -n ' do source routing=YES'
- sysctl -w net.inet.ip.sourceroute=1 >/dev/null
- ;;
- esac
-
- case ${accept_sourceroute} in
- [Yy][Ee][Ss])
- echo -n ' accept source routing=YES'
- sysctl -w net.inet.ip.accept_sourceroute=1 >/dev/null
- ;;
- esac
-
- case ${tcp_keepalive} in
- [Yy][Ee][Ss])
- echo -n ' TCP keepalive=YES'
- sysctl -w net.inet.tcp.always_keepalive=1 >/dev/null
- ;;
- esac
-
- case ${tcp_restrict_rst} in
- [Yy][Ee][Ss])
- echo -n ' restrict TCP reset=YES'
- sysctl -w net.inet.tcp.restrict_rst=1 >/dev/null
- ;;
- esac
-
- case ${tcp_drop_synfin} in
- [Yy][Ee][Ss])
- echo -n ' drop SYN+FIN packets=YES'
- sysctl -w net.inet.tcp.drop_synfin=1 >/dev/null
- ;;
- esac
-
- case ${ipxgateway_enable} in
- [Yy][Ee][Ss])
- echo -n ' IPX gateway=YES'
- sysctl -w net.ipx.ipx.ipxforwarding=1 >/dev/null
- ;;
- esac
-
- case ${arpproxy_all} in
- [Yy][Ee][Ss])
- echo -n ' ARP proxyall=YES'
- sysctl -w net.link.ether.inet.proxyall=1 >/dev/null
- ;;
- esac
- echo '.'
-
- echo -n 'routing daemons:'
- case ${router_enable} in
- [Yy][Ee][Ss])
- echo -n " ${router}"; ${router} ${router_flags}
- ;;
- esac
-
- case ${ipxrouted_enable} in
- [Yy][Ee][Ss])
- echo -n ' IPXrouted'
- IPXrouted ${ipxrouted_flags} > /dev/null 2>&1
- ;;
- esac
-
- case ${mrouted_enable} in
- [Yy][Ee][Ss])
- echo -n ' mrouted'; mrouted ${mrouted_flags}
- ;;
- esac
-
- case ${rarpd_enable} in
- [Yy][Ee][Ss])
- echo -n ' rarpd'; rarpd ${rarpd_flags}
- ;;
- esac
- echo '.'
-
- # Let future generations know we made it.
- #
- network_pass1_done=YES
-}
-
-network_pass2() {
- echo -n 'Doing additional network setup:'
- case ${named_enable} in
- [Yy][Ee][Ss])
- echo -n ' named'; ${named_program:-named} ${named_flags}
- ;;
- esac
-
- case ${ntpdate_enable} in
- [Yy][Ee][Ss])
- echo -n ' ntpdate'
- ${ntpdate_program:-ntpdate} ${ntpdate_flags} >/dev/null 2>&1
- ;;
- esac
-
- case ${xntpd_enable} in
- [Yy][Ee][Ss])
- echo -n ' ntpd'; ${xntpd_program:-ntpd} ${xntpd_flags}
- ;;
- esac
-
- case ${timed_enable} in
- [Yy][Ee][Ss])
- echo -n ' timed'; timed ${timed_flags}
- ;;
- esac
-
- case ${portmap_enable} in
- [Yy][Ee][Ss])
- echo -n ' portmap'; ${portmap_program:-/usr/sbin/portmap} ${portmap_flags}
- ;;
- esac
-
- # Start ypserv if we're an NIS server.
- # Run rpc.ypxfrd and rpc.yppasswdd only on the NIS master server.
- #
- case ${nis_server_enable} in
- [Yy][Ee][Ss])
- echo -n ' ypserv'; ypserv ${nis_server_flags}
-
- case ${nis_ypxfrd_enable} in
- [Yy][Ee][Ss])
- echo -n ' rpc.ypxfrd'
- rpc.ypxfrd ${nis_ypxfrd_flags}
- ;;
- esac
-
- case ${nis_yppasswdd_enable} in
- [Yy][Ee][Ss])
- echo -n ' rpc.yppasswdd'
- rpc.yppasswdd ${nis_yppasswdd_flags}
- ;;
- esac
- ;;
- esac
-
- # Start ypbind if we're an NIS client
- #
- case ${nis_client_enable} in
- [Yy][Ee][Ss])
- echo -n ' ypbind'; ypbind ${nis_client_flags}
- case ${nis_ypset_enable} in
- [Yy][Ee][Ss])
- echo -n ' ypset'; ypset ${nis_ypset_flags}
- ;;
- esac
- ;;
- esac
-
- # Start keyserv if we are running Secure RPC
- #
- case ${keyserv_enable} in
- [Yy][Ee][Ss])
- echo -n ' keyserv'; keyserv ${keyserv_flags}
- ;;
- esac
-
- # Start ypupdated if we are running Secure RPC and we are NIS master
- #
- case ${rpc_ypupdated_enable} in
- [Yy][Ee][Ss])
- echo -n ' rpc.ypupdated'; rpc.ypupdated
- ;;
- esac
-
- # Start ATM daemons
- if [ -n "${atm_pass2_done}" ]; then
- atm_pass3
- fi
-
- echo '.'
- network_pass2_done=YES
-}
-
-network_pass3() {
- echo -n 'Starting final network daemons:'
-
- case ${nfs_server_enable} in
- [Yy][Ee][Ss])
- if [ -r /etc/exports ]; then
- echo -n ' mountd'
-
- case ${weak_mountd_authentication} in
- [Yy][Ee][Ss])
- mountd_flags="-n"
- ;;
- esac
-
- mountd ${mountd_flags}
-
- case ${nfs_reserved_port_only} in
- [Yy][Ee][Ss])
- echo -n ' NFS on reserved port only=YES'
- sysctl -w vfs.nfs.nfs_privport=1 >/dev/null
- ;;
- esac
-
- echo -n ' nfsd'; nfsd ${nfs_server_flags}
-
- case ${rpc_lockd_enable} in
- [Yy][Ee][Ss])
- echo -n ' rpc.lockd'; rpc.lockd
- ;;
- esac
-
- case ${rpc_statd_enable} in
- [Yy][Ee][Ss])
- echo -n ' rpc.statd'; rpc.statd
- ;;
- esac
- fi
- ;;
- *)
- case ${single_mountd_enable} in
- [Yy][Ee][Ss])
- if [ -r /etc/exports ]; then
- echo -n ' mountd'
-
- case ${weak_mountd_authentication} in
- [Yy][Ee][Ss])
- mountd_flags="-n"
- ;;
- esac
-
- mountd ${mountd_flags}
- fi
- ;;
- esac
- ;;
- esac
-
- case ${nfs_client_enable} in
- [Yy][Ee][Ss])
- echo -n ' nfsiod'; nfsiod ${nfs_client_flags}
- if [ -n "${nfs_access_cache}" ]; then
- echo -n " NFS access cache time=${nfs_access_cache}"
- sysctl -w vfs.nfs.access_cache_timeout=${nfs_access_cache} \
- >/dev/null
- fi
- ;;
- esac
-
- # If /var/db/mounttab exists, some nfs-server has not been
- # sucessfully notified about a previous client shutdown.
- # If there is no /var/db/mounttab, we do nothing.
- if [ -f /var/db/mounttab ]; then
- rpc.umntall -k
- fi
-
- case ${amd_enable} in
- [Yy][Ee][Ss])
- echo -n ' amd'
- case ${amd_map_program} in
- [Nn][Oo] | '')
- ;;
- *)
- amd_flags="${amd_flags} `eval ${amd_map_program}`"
- ;;
- esac
-
- if [ -n "${amd_flags}" ]; then
- amd -p ${amd_flags} > /var/run/amd.pid 2> /dev/null
- else
- amd 2> /dev/null
- fi
- ;;
- esac
-
- case ${rwhod_enable} in
- [Yy][Ee][Ss])
- echo -n ' rwhod'; rwhod ${rwhod_flags}
- ;;
- esac
-
- # Kerberos runs ONLY on the Kerberos server machine
- case ${kerberos_server_enable} in
- [Yy][Ee][Ss])
- case ${kerberos_stash} in
- [Yy][Ee][Ss])
- stash_flag=-n
- ;;
- *)
- stash_flag=
- ;;
- esac
-
- echo -n ' kerberos'
- kerberos ${stash_flag} >> /var/log/kerberos.log &
-
- case ${kadmind_server_enable} in
- [Yy][Ee][Ss])
- echo -n ' kadmind'
- (sleep 20; kadmind ${stash_flag} >/dev/null 2>&1 &) &
- ;;
- esac
- unset stash_flag
- ;;
- esac
-
- case ${pppoed_enable} in
- [Yy][Ee][Ss])
- if [ -n "${pppoed_provider}" ]; then
- pppoed_flags="${pppoed_flags} -p ${pppoed_provider}"
- fi
- echo -n ' pppoed';
- /usr/libexec/pppoed ${pppoed_flags} ${pppoed_interface}
- ;;
- esac
-
- case ${sshd_enable} in
- [Yy][Ee][Ss])
- if [ ! -f /etc/ssh/ssh_host_key ]; then
- echo ' creating ssh host key';
- /usr/bin/ssh-keygen -N "" -f /etc/ssh/ssh_host_key
- fi
- ;;
- esac
-
- echo '.'
- network_pass3_done=YES
-}
-
-network_pass4() {
- echo -n 'Additional TCP options:'
- case ${log_in_vain} in
- [Nn][Oo] | '')
- ;;
- *)
- echo -n ' log_in_vain=YES'
- sysctl -w net.inet.tcp.log_in_vain=1 >/dev/null
- sysctl -w net.inet.udp.log_in_vain=1 >/dev/null
- ;;
- esac
-
- echo '.'
- network_pass4_done=YES
-}
diff --git a/etc/rc.d/network_ipv6 b/etc/rc.d/network_ipv6
deleted file mode 100644
index 801077f4df19..000000000000
--- a/etc/rc.d/network_ipv6
+++ /dev/null
@@ -1,329 +0,0 @@
-#! /bin/sh
-# $FreeBSD$
-
-# Note that almost all of the user-configurable behavior is not in this
-# file, but rather in /etc/defaults/rc.conf. Please check that file
-# first before contemplating any changes here. If you do need to change
-# this file for some reason, we would like to know about it.
-
-# IPv6 startup
-
-network6_pass1() {
- echo -n 'Doing IPv6 network setup:'
-
- case ${ipv6_gateway_enable} in
- [Yy][Ee][Ss])
- #
- # list of interfaces, and prefix for interfaces
- #
- case ${ipv6_network_interfaces} in
- [Aa][Uu][Tt][Oo])
- ipv6_network_interfaces="`ifconfig -l`"
- ;;
- esac
- ;;
- *)
- #
- # manual configurations - in case ip6_gateway_enable=NO
- # you can configure only single interface,
- # as specification assumes that
- # autoconfigured host has single interface only.
- #
- case ${ipv6_network_interfaces} in
- [Aa][Uu][Tt][Oo])
- ipv6_network_interfaces="`ifconfig -l \
- | sed -e 's/ .*//'`"
- ;;
- esac
- ;;
- esac
-
- # just to make sure
- ifconfig lo0 up
-
- # disallow "internal" addresses to appear on the wire
- route add -inet6 ::ffff:0.0.0.0 -prefixlen 96 ::1 -reject
- route add -inet6 ::0.0.0.0 -prefixlen 96 ::1 -reject
-
- case ${ipv6_gateway_enable} in
- [Yy][Ee][Ss])
- # act as a router
- sysctl -w net.inet6.ip6.forwarding=1
- sysctl -w net.inet6.ip6.accept_rtadv=0
-
- # wait for DAD
- for i in $ipv6_network_interfaces; do
- ifconfig $i up
- done
- sleep `sysctl -n net.inet6.ip6.dad_count`
- sleep 1
-
- # setting up interfaces
- for i in $ipv6_network_interfaces; do
- eval prefix=\$ipv6_prefix_$i
- case ${prefix} in
- '')
- continue;
- ;;
- esac
- for j in ${prefix}; do
- case ${prefixcmd_enable} in
- [Yy][Ee][Ss])
- prefix $i $j::
- ;;
- *)
- laddr=`ifconfig $i inet6 \
- | grep 'inet6 fe80:' \
- | head -1 | awk '{print $2}'`
- hostid=`echo ${laddr} | sed \
- -e 's/fe80:[0-9a-fA-F]+::/fe80::/' \
- -e 's/fe80:://' -e 's/%.*//'`
- address=$j\:${hostid}
-
- eval hostid_$i=${hostid}
- eval address_$i=${address}
-
- ifconfig $i inet6 ${address} \
- prefixlen 64 alias
- ;;
- esac
-
- # subnet-router anycast address (rfc2373)
- ifconfig $i inet6 $j:: prefixlen 64 \
- alias anycast
- done
-
- ifconfig $i inet6
- done
-
- # again, wait for DAD's completion (for global addrs)
- sleep `sysctl -n net.inet6.ip6.dad_count`
- sleep 1
-
- # Filter out interfaces on which IPv6 addr init failed.
- ipv6_working_interfaces=""
- for i in ${ipv6_network_interfaces}; do
- laddr=`ifconfig $i inet6 2>/dev/null | \
- grep 'inet6 fe80:' | \
- head -1 | grep -v tentative`
- case ${laddr} in
- '')
- ;;
- *)
- ipv6_working_interfaces="$i \
- ${ipv6_working_interfaces}"
- ;;
- esac
- done
- ipv6_network_interfaces=${ipv6_working_interfaces}
-
- # gifconfig
- network6_gif_setup
-
- # 6to4 setup
- network6_stf_setup
-
- # install the "default interface" to kernel, which will be used
- # as the default route when there's no router.
- network6_default_interface_setup
-
- # setup static routes
- network6_static_routes_setup
-
- # ipv6_router
- case ${ipv6_router_enable} in
- [Yy][Ee][Ss])
- if [ -x ${ipv6_router} ]; then
- echo -n " ${ipv6_router}"
- ${ipv6_router} ${ipv6_router_flags}
- fi
- ;;
- esac
-
- # rtadvd
- # This should enabled with a great care.
- # You may want to fine-tune /etc/rtadvd.conf.
- #
- # And if you wish your rtadvd to receive and process
- # router renumbering messages, specify your Router Renumbering
- # security policy by -P option.
- #
- # See `man 3 ipsec_set_policy` for IPsec policy specification
- # details.
- # (CAUTION: This enables your routers prefix renumbering
- # from another machine, so if you enable this, do it with
- # enough care.)
- #
- case ${rtadvd_enable} in
- [Yy][Ee][Ss])
- # default
- rtadvd_interfaces=`echo ${ipv6_network_interfaces} | \
- sed -e 's/ stf0//'`
- rtadvd ${rtadvd_interfaces}
- #
- # Enable Router Renumbering, unicast case
- # (use correct src/dst addr)
- # rtadvd -P "in ipsec ah/transport/fec0:0:0:1::1-fec0:0:0:10::1/require" \
- # ${ipv6_network_interfaces}
- # Enable Router Renumbering, multicast case
- # (use correct src addr)
- # rtadvd -P "in ipsec ah/transport/ff05::2-fec0:0:0:10::1/require" \
- # ${ipv6_network_interfaces}
- ;;
- esac
-
- # mroute6d
- case ${mroute6d_enable} in
- [Yy][Ee][Ss])
- if [ -x ${mroute6d_program} ]; then
- echo -n " ${mroute6d_program}"
- ${mroute6d_program} ${mroute6d_flags}
- fi
- ;;
- esac
- ;;
- *)
- # act as endhost - automatically configured
- sysctl -w net.inet6.ip6.forwarding=0
- sysctl -w net.inet6.ip6.accept_rtadv=1
-
- ifconfig ${ipv6_network_interfaces} up
- rtsol ${ipv6_network_interfaces}
-
-
-
- # wait for DAD's completion (for global addrs)
- sleep `sysctl -n net.inet6.ip6.dad_count`
- sleep 1
-
- # gifconfig
- network6_gif_setup
-
- # 6to4 setup
- network6_stf_setup
-
- # install the "default interface" to kernel, which will be used
- # as the default route when there's no router.
- # ndp -I ${ipv6_default_interface}
- network6_default_interface_setup
-
- # setup static routes
- network6_static_routes_setup
- ;;
- esac
-
- echo '.'
-
- # Let future generations know we made it.
- #
- network6_pass1_done=YES
-}
-
-network6_gif_setup() {
- case ${gif_interfaces} in
- [Nn][Oo] | '')
- ;;
- *)
- for i in ${gif_interfaces}; do
- eval peers=\$gifconfig_$i
- case ${peers} in
- '')
- continue
- ;;
- *)
- gifconfig $i ${peers}
- ;;
- esac
- done
- ;;
- esac
-}
-
-network6_stf_setup() {
- case ${stf_interface_ipv4addr} in
- [Nn][Oo] | '')
- ;;
- *)
- # setup outer IPv4 addrs
- gifconfig stf0 ${stf_interface_ipv4addr} 255.255.255.255
- # assign IPv6 addr and interface route for 6to4 interface
- stf_prefixlen=$((16+${stf_interface_ipv4plen:-0}))
- ipv4_in_hexformat=`echo ${stf_interface_ipv4addr} | \
- sed -e s/"\."/" "/g | \
- awk '{$5 = $1*256 + $2; $6 = $3*256 + $4; \
- printf "%x:%x\n", $5, $6}'`
- case ${stf_interface_ipv6_ifid} in
- [Aa][Uu][Tt][Oo] | '')
- laddr=`ifconfig stf0 inet6 | grep 'inet6 fe80:' \
- | head -1 | awk '{print $2}'`
- stf_interface_ipv6_ifid=`echo ${laddr} | sed \
- -e 's/fe80:[0-9a-fA-F]+::/fe80::/' \
- -e 's/fe80:://' -e 's/%.*//'`
- case ${stf_interface_ipv6_ifid} in
- '')
- stf_interface_ipv6_ifid=0:0:0:1
- ;;
- esac
- ;;
- esac
- ifconfig stf0 inet6 2002:${ipv4_in_hexformat}:${stf_interface_ipv6_slaid:-0}:${stf_interface_ipv6_ifid} \
- prefixlen ${stf_prefixlen}
- # disallow packets to malicious 6to4 prefix
- route add -inet6 2002:7f00:0000:: -prefixlen 24 ::1 -reject
- route add -inet6 2002:0000:0000:: -prefixlen 48 ::1 -reject
- route add -inet6 2002:ffff:ffff:: -prefixlen 48 ::1 -reject
- ;;
- esac
-}
-
-network6_static_routes_setup() {
- # Set up any static routes.
- case ${ipv6_static_routes} in
- [Nn][Oo] | '')
- ;;
- *)
- for i in ${ipv6_static_routes}; do
- eval ipv6_route_args=\$ipv6_route_${i}
- route add -inet6 ${ipv6_route_args}
- done
- ;;
- esac
-}
-
-network6_default_interface_setup() {
- # Choose IPv6 default interface if it is not clearly specified.
- case ${ipv6_default_interface} in
- [Nn][Oo] | '')
- for i in ${ipv6_network_interfaces}; do
- laddr=`ifconfig $i inet6 2>/dev/null \
- | grep 'inet6 fe80:' | \
- head -1 | grep -v tentative`
- case ${laddr} in
- '')
- ;;
- *)
- ipv6_default_interface=$i
- break
- ;;
- esac
- done
- ;;
- esac
-
- # Disallow unicast packets without outgoing scope identifiers,
- # or route such packets to a "default" interface, if it is specified.
- case ${ipv6_default_interface} in
- [Nn][Oo] | '')
- route add -inet6 fe80:: -prefixlen 10 ::1 -reject
- route add -inet6 ff02:: -prefixlen 16 ::1 -reject
- ;;
- *)
- laddr=`ifconfig ${ipv6_default_interface} inet6 \
- | grep 'inet6 fe80:' | head -1 | awk '{print $2}'`
- route add -inet6 fe80:: ${laddr} -prefixlen 10 -interface \
- -cloning
- route add -inet6 ff02:: ${laddr} -prefixlen 16 -interface \
- -cloning
- ;;
- esac
-}
diff --git a/etc/rc.d/pccard b/etc/rc.d/pccard
deleted file mode 100644
index 25ab16feafe6..000000000000
--- a/etc/rc.d/pccard
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/sh -
-# PC-card startup script
-# $FreeBSD$
-
-case ${pccard_enable} in
-[Yy][Ee][Ss])
- case ${pccard_mem} in
- [Dd][Ee][Ff][Aa][Uu][Ll][Tt])
- pccardc pccardmem 0xd0000
- ;;
- *)
- pccardc pccardmem ${pccard_mem}
- ;;
- esac
-
- if [ -n "${pccard_beep}" ] ; then
- pccardc beep ${pccard_beep}
- fi
-
- if [ -n "${pccard_conf}" ]; then
- pccardd_flags="${pccardd_flags} -f ${pccard_conf}"
- fi
-
- echo -n "Enable PC-card."
- pccardd ${pccardd_flags} 2>&1 > /var/log/pccardd.debug
- ;;
-esac
diff --git a/etc/rc.d/resolv b/etc/rc.d/resolv
deleted file mode 100644
index 9ccdfa80ed14..000000000000
--- a/etc/rc.d/resolv
+++ /dev/null
@@ -1,43 +0,0 @@
-# $FreeBSD$
-#
-
-# PROVIDE: diskless
-# REQUIRE: initdiskless mountcritlocal
- if [ -n "$4" ]; then
- bpi="-i $4"
- fi
- /sbin/mdconfig -a -t malloc -s $1 -u $3
- /sbin/newfs $bpi /dev/md$3c
- /sbin/mount /dev/md$3c $2
-}
-
-mount_mfs -s ${varsize:=65536} -T qp120at dummy /var
-var_dirs="run dev db msgs tmp spool spool/mqueue spool/lpd spool/output \
- spool/output/lpd"
-for i in ${var_dirs}
-do
- mkdir /var/${i}
-done
-chmod 755 /var/run
-chmod 755 /var/db
-chmod 755 /var/spool
-chmod 1777 /var/tmp
-chown -R root.daemon /var/spool/output
-chgrp daemon /var/spool/lpd
-# Since we are starting with a very fresh /etc on an MFS:
-if [ -d /conf/default/etc ]; then
- newaliases
-fi
-if [ ! -h /tmp -a ! -h /var/tmp ]; then
- mount_null /var/tmp /tmp
-fi
-#
-# extract a list of device entries, then copy them to a writable partition
-(cd /; find -x dev | cpio -o -H newc) > /tmp/dev.tmp
-mount_mfs -s 4096 -i 512 -T qp120at dummy /dev
-(cd /; cpio -i -H newc -d < /tmp/dev.tmp)
- # extract a list of device entries, then copy them to a writable fs
- (cd /; find -x dev | cpio -o -H newc) > /tmp/dev.tmp
- mount_md 4096 /dev 3 512
- (cd /; cpio -i -H newc -d < /tmp/dev.tmp)
-fi
diff --git a/etc/rc.d/routing b/etc/rc.d/routing
deleted file mode 100644
index 0211181f0516..000000000000
--- a/etc/rc.d/routing
+++ /dev/null
@@ -1,633 +0,0 @@
-#!/bin/sh -
-#
-# $FreeBSD$
-# From: @(#)netstart 5.9 (Berkeley) 3/30/91
-
-# Note that almost all of the user-configurable behavior is no longer in
-# this file, but rather in /etc/defaults/rc.conf. Please check that file
-# first before contemplating any changes here. If you do need to change
-# this file for some reason, we would like to know about it.
-
-# First pass startup stuff.
-#
-network_pass1() {
- echo -n 'Doing initial network setup:'
-
- # Set the host name if it is not already set
- #
- if [ -z "`hostname -s`" ]; then
- hostname ${hostname}
- echo -n ' hostname'
- fi
-
- # Set the domainname if we're using NIS
- #
- case ${nisdomainname} in
- [Nn][Oo] | '')
- ;;
- *)
- domainname ${nisdomainname}
- echo -n ' domain'
- ;;
- esac
-
- echo '.'
-
- # Initial ATM interface configuration
- #
- case ${atm_enable} in
- [Yy][Ee][Ss])
- if [ -r /etc/rc.atm ]; then
- . /etc/rc.atm
- atm_pass1
- fi
- ;;
- esac
-
- # Special options for sppp(4) interfaces go here. These need
- # to go _before_ the general ifconfig section, since in the case
- # of hardwired (no link1 flag) but required authentication, you
- # cannot pass auth parameters down to the already running interface.
- #
- for ifn in ${sppp_interfaces}; do
- eval spppcontrol_args=\$spppconfig_${ifn}
- if [ -n "${spppcontrol_args}" ]; then
- # The auth secrets might contain spaces; in order
- # to retain the quotation, we need to eval them
- # here.
- eval spppcontrol ${ifn} ${spppcontrol_args}
- fi
- done
-
- # Set up all the network interfaces, calling startup scripts if needed
- #
- case ${network_interfaces} in
- [Aa][Uu][Tt][Oo])
- network_interfaces="`ifconfig -l`"
- ;;
- esac
-
- dhcp_interfaces=""
- for ifn in ${network_interfaces}; do
- if [ -r /etc/start_if.${ifn} ]; then
- . /etc/start_if.${ifn}
- eval showstat_$ifn=1
- fi
-
- # Do the primary ifconfig if specified
- #
- eval ifconfig_args=\$ifconfig_${ifn}
-
- case ${ifconfig_args} in
- '')
- ;;
- [Dd][Hh][Cc][Pp])
- # DHCP inits are done all in one go below
- dhcp_interfaces="$dhcp_interfaces $ifn"
- eval showstat_$ifn=1
- ;;
- *)
- ifconfig ${ifn} ${ifconfig_args}
- eval showstat_$ifn=1
- ;;
- esac
- done
-
- if [ ! -z "${dhcp_interfaces}" ]; then
- ${dhcp_program:-/sbin/dhclient} ${dhcp_flags} ${dhcp_interfaces}
- fi
-
- for ifn in ${network_interfaces}; do
- # Check to see if aliases need to be added
- #
- alias=0
- while : ; do
- eval ifconfig_args=\$ifconfig_${ifn}_alias${alias}
- if [ -n "${ifconfig_args}" ]; then
- ifconfig ${ifn} ${ifconfig_args} alias
- eval showstat_$ifn=1
- alias=`expr ${alias} + 1`
- else
- break;
- fi
- done
-
- # Do ipx address if specified
- #
- eval ifconfig_args=\$ifconfig_${ifn}_ipx
- if [ -n "${ifconfig_args}" ]; then
- ifconfig ${ifn} ${ifconfig_args}
- eval showstat_$ifn=1
- fi
- done
-
- for ifn in ${network_interfaces}; do
- eval showstat=\$showstat_${ifn}
- if [ ! -z ${showstat} ]; then
- ifconfig ${ifn}
- fi
- done
-
- # ISDN subsystem startup
- #
- case ${isdn_enable} in
- [Yy][Ee][Ss])
- if [ -r /etc/rc.isdn ]; then
- . /etc/rc.isdn
- fi
- ;;
- esac
-
- # Warm up user ppp if required, must happen before natd.
- #
- case ${ppp_enable} in
- [Yy][Ee][Ss])
- # Establish ppp mode.
- #
- if [ "${ppp_mode}" != "ddial" -a "${ppp_mode}" != "direct" \
- -a "${ppp_mode}" != "dedicated" \
- -a "${ppp_mode}" != "background" ]; then
- ppp_mode="auto";
- fi
-
- ppp_command="-${ppp_mode} ";
-
- # Switch on alias mode?
- #
- case ${ppp_nat} in
- [Yy][Ee][Ss])
- ppp_command="${ppp_command} -nat";
- ;;
- esac
-
- echo -n 'Starting ppp: '; ppp ${ppp_command} -quiet ${ppp_profile}
- ;;
- esac
-
- # Initialize IP filtering using ipfw
- #
- echo ''
-
- if /sbin/ipfw -q flush > /dev/null 2>&1; then
- firewall_in_kernel=1
- else
- firewall_in_kernel=0
- fi
-
- case ${firewall_enable} in
- [Yy][Ee][Ss])
- if [ "${firewall_in_kernel}" -eq 0 ] && kldload ipfw; then
- firewall_in_kernel=1
- echo "Kernel firewall module loaded."
- elif [ "${firewall_in_kernel}" -eq 0 ]; then
- echo "Warning: firewall kernel module failed to load."
- fi
- ;;
- esac
-
- # Load the filters if required
- #
- case ${firewall_in_kernel} in
- 1)
- if [ -z "${firewall_script}" ]; then
- firewall_script=/etc/rc.firewall
- fi
-
- case ${firewall_enable} in
- [Yy][Ee][Ss])
- if [ -r "${firewall_script}" ]; then
- . "${firewall_script}"
- echo -n 'Firewall rules loaded, starting divert daemons:'
-
- # Network Address Translation daemon
- #
- case ${natd_enable} in
- [Yy][Ee][Ss])
- if [ -n "${natd_interface}" ]; then
- if echo ${natd_interface} | \
- grep -q -E '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$'; then
- natd_ifarg="-a ${natd_interface}"
- else
- natd_ifarg="-n ${natd_interface}"
- fi
-
- echo -n ' natd'; ${natd_program:-/sbin/natd} ${natd_flags} ${natd_ifarg}
- fi
- ;;
- esac
-
- echo '.'
-
- elif [ "`ipfw l 65535`" = "65535 deny ip from any to any" ]; then
- echo -n "Warning: kernel has firewall functionality, "
- echo "but firewall rules are not enabled."
- echo " All ip services are disabled."
- fi
- ;;
- esac
- ;;
- esac
-
- # Additional ATM interface configuration
- #
- if [ -n "${atm_pass1_done}" ]; then
- atm_pass2
- fi
-
- # Configure routing
- #
- case ${defaultrouter} in
- [Nn][Oo] | '')
- ;;
- *)
- static_routes="default ${static_routes}"
- route_default="default ${defaultrouter}"
- ;;
- esac
-
- # Set up any static routes. This should be done before router discovery.
- #
- if [ -n "${static_routes}" ]; then
- for i in ${static_routes}; do
- eval route_args=\$route_${i}
- route add ${route_args}
- done
- fi
-
- echo -n 'Additional routing options:'
- case ${tcp_extensions} in
- [Yy][Ee][Ss] | '')
- ;;
- *)
- echo -n ' tcp extensions=NO'
- sysctl -w net.inet.tcp.rfc1323=0 >/dev/null
- ;;
- esac
-
- case ${icmp_bmcastecho} in
- [Yy][Ee][Ss])
- echo -n ' broadcast ping responses=YES'
- sysctl -w net.inet.icmp.bmcastecho=1 >/dev/null
- ;;
- esac
-
- case ${icmp_drop_redirect} in
- [Yy][Ee][Ss])
- echo -n ' ignore ICMP redirect=YES'
- sysctl -w net.inet.icmp.drop_redirect=1 >/dev/null
- ;;
- esac
-
- case ${icmp_log_redirect} in
- [Yy][Ee][Ss])
- echo -n ' log ICMP redirect=YES'
- sysctl -w net.inet.icmp.log_redirect=1 >/dev/null
- ;;
- esac
-
- case ${gateway_enable} in
- [Yy][Ee][Ss])
- echo -n ' IP gateway=YES'
- sysctl -w net.inet.ip.forwarding=1 >/dev/null
- ;;
- esac
-
- case ${forward_sourceroute} in
- [Yy][Ee][Ss])
- echo -n ' do source routing=YES'
- sysctl -w net.inet.ip.sourceroute=1 >/dev/null
- ;;
- esac
-
- case ${accept_sourceroute} in
- [Yy][Ee][Ss])
- echo -n ' accept source routing=YES'
- sysctl -w net.inet.ip.accept_sourceroute=1 >/dev/null
- ;;
- esac
-
- case ${tcp_keepalive} in
- [Yy][Ee][Ss])
- echo -n ' TCP keepalive=YES'
- sysctl -w net.inet.tcp.always_keepalive=1 >/dev/null
- ;;
- esac
-
- case ${tcp_restrict_rst} in
- [Yy][Ee][Ss])
- echo -n ' restrict TCP reset=YES'
- sysctl -w net.inet.tcp.restrict_rst=1 >/dev/null
- ;;
- esac
-
- case ${tcp_drop_synfin} in
- [Yy][Ee][Ss])
- echo -n ' drop SYN+FIN packets=YES'
- sysctl -w net.inet.tcp.drop_synfin=1 >/dev/null
- ;;
- esac
-
- case ${ipxgateway_enable} in
- [Yy][Ee][Ss])
- echo -n ' IPX gateway=YES'
- sysctl -w net.ipx.ipx.ipxforwarding=1 >/dev/null
- ;;
- esac
-
- case ${arpproxy_all} in
- [Yy][Ee][Ss])
- echo -n ' ARP proxyall=YES'
- sysctl -w net.link.ether.inet.proxyall=1 >/dev/null
- ;;
- esac
- echo '.'
-
- echo -n 'routing daemons:'
- case ${router_enable} in
- [Yy][Ee][Ss])
- echo -n " ${router}"; ${router} ${router_flags}
- ;;
- esac
-
- case ${ipxrouted_enable} in
- [Yy][Ee][Ss])
- echo -n ' IPXrouted'
- IPXrouted ${ipxrouted_flags} > /dev/null 2>&1
- ;;
- esac
-
- case ${mrouted_enable} in
- [Yy][Ee][Ss])
- echo -n ' mrouted'; mrouted ${mrouted_flags}
- ;;
- esac
-
- case ${rarpd_enable} in
- [Yy][Ee][Ss])
- echo -n ' rarpd'; rarpd ${rarpd_flags}
- ;;
- esac
- echo '.'
-
- # Let future generations know we made it.
- #
- network_pass1_done=YES
-}
-
-network_pass2() {
- echo -n 'Doing additional network setup:'
- case ${named_enable} in
- [Yy][Ee][Ss])
- echo -n ' named'; ${named_program:-named} ${named_flags}
- ;;
- esac
-
- case ${ntpdate_enable} in
- [Yy][Ee][Ss])
- echo -n ' ntpdate'
- ${ntpdate_program:-ntpdate} ${ntpdate_flags} >/dev/null 2>&1
- ;;
- esac
-
- case ${xntpd_enable} in
- [Yy][Ee][Ss])
- echo -n ' ntpd'; ${xntpd_program:-ntpd} ${xntpd_flags}
- ;;
- esac
-
- case ${timed_enable} in
- [Yy][Ee][Ss])
- echo -n ' timed'; timed ${timed_flags}
- ;;
- esac
-
- case ${portmap_enable} in
- [Yy][Ee][Ss])
- echo -n ' portmap'; ${portmap_program:-/usr/sbin/portmap} ${portmap_flags}
- ;;
- esac
-
- # Start ypserv if we're an NIS server.
- # Run rpc.ypxfrd and rpc.yppasswdd only on the NIS master server.
- #
- case ${nis_server_enable} in
- [Yy][Ee][Ss])
- echo -n ' ypserv'; ypserv ${nis_server_flags}
-
- case ${nis_ypxfrd_enable} in
- [Yy][Ee][Ss])
- echo -n ' rpc.ypxfrd'
- rpc.ypxfrd ${nis_ypxfrd_flags}
- ;;
- esac
-
- case ${nis_yppasswdd_enable} in
- [Yy][Ee][Ss])
- echo -n ' rpc.yppasswdd'
- rpc.yppasswdd ${nis_yppasswdd_flags}
- ;;
- esac
- ;;
- esac
-
- # Start ypbind if we're an NIS client
- #
- case ${nis_client_enable} in
- [Yy][Ee][Ss])
- echo -n ' ypbind'; ypbind ${nis_client_flags}
- case ${nis_ypset_enable} in
- [Yy][Ee][Ss])
- echo -n ' ypset'; ypset ${nis_ypset_flags}
- ;;
- esac
- ;;
- esac
-
- # Start keyserv if we are running Secure RPC
- #
- case ${keyserv_enable} in
- [Yy][Ee][Ss])
- echo -n ' keyserv'; keyserv ${keyserv_flags}
- ;;
- esac
-
- # Start ypupdated if we are running Secure RPC and we are NIS master
- #
- case ${rpc_ypupdated_enable} in
- [Yy][Ee][Ss])
- echo -n ' rpc.ypupdated'; rpc.ypupdated
- ;;
- esac
-
- # Start ATM daemons
- if [ -n "${atm_pass2_done}" ]; then
- atm_pass3
- fi
-
- echo '.'
- network_pass2_done=YES
-}
-
-network_pass3() {
- echo -n 'Starting final network daemons:'
-
- case ${nfs_server_enable} in
- [Yy][Ee][Ss])
- if [ -r /etc/exports ]; then
- echo -n ' mountd'
-
- case ${weak_mountd_authentication} in
- [Yy][Ee][Ss])
- mountd_flags="-n"
- ;;
- esac
-
- mountd ${mountd_flags}
-
- case ${nfs_reserved_port_only} in
- [Yy][Ee][Ss])
- echo -n ' NFS on reserved port only=YES'
- sysctl -w vfs.nfs.nfs_privport=1 >/dev/null
- ;;
- esac
-
- echo -n ' nfsd'; nfsd ${nfs_server_flags}
-
- case ${rpc_lockd_enable} in
- [Yy][Ee][Ss])
- echo -n ' rpc.lockd'; rpc.lockd
- ;;
- esac
-
- case ${rpc_statd_enable} in
- [Yy][Ee][Ss])
- echo -n ' rpc.statd'; rpc.statd
- ;;
- esac
- fi
- ;;
- *)
- case ${single_mountd_enable} in
- [Yy][Ee][Ss])
- if [ -r /etc/exports ]; then
- echo -n ' mountd'
-
- case ${weak_mountd_authentication} in
- [Yy][Ee][Ss])
- mountd_flags="-n"
- ;;
- esac
-
- mountd ${mountd_flags}
- fi
- ;;
- esac
- ;;
- esac
-
- case ${nfs_client_enable} in
- [Yy][Ee][Ss])
- echo -n ' nfsiod'; nfsiod ${nfs_client_flags}
- if [ -n "${nfs_access_cache}" ]; then
- echo -n " NFS access cache time=${nfs_access_cache}"
- sysctl -w vfs.nfs.access_cache_timeout=${nfs_access_cache} \
- >/dev/null
- fi
- ;;
- esac
-
- # If /var/db/mounttab exists, some nfs-server has not been
- # sucessfully notified about a previous client shutdown.
- # If there is no /var/db/mounttab, we do nothing.
- if [ -f /var/db/mounttab ]; then
- rpc.umntall -k
- fi
-
- case ${amd_enable} in
- [Yy][Ee][Ss])
- echo -n ' amd'
- case ${amd_map_program} in
- [Nn][Oo] | '')
- ;;
- *)
- amd_flags="${amd_flags} `eval ${amd_map_program}`"
- ;;
- esac
-
- if [ -n "${amd_flags}" ]; then
- amd -p ${amd_flags} > /var/run/amd.pid 2> /dev/null
- else
- amd 2> /dev/null
- fi
- ;;
- esac
-
- case ${rwhod_enable} in
- [Yy][Ee][Ss])
- echo -n ' rwhod'; rwhod ${rwhod_flags}
- ;;
- esac
-
- # Kerberos runs ONLY on the Kerberos server machine
- case ${kerberos_server_enable} in
- [Yy][Ee][Ss])
- case ${kerberos_stash} in
- [Yy][Ee][Ss])
- stash_flag=-n
- ;;
- *)
- stash_flag=
- ;;
- esac
-
- echo -n ' kerberos'
- kerberos ${stash_flag} >> /var/log/kerberos.log &
-
- case ${kadmind_server_enable} in
- [Yy][Ee][Ss])
- echo -n ' kadmind'
- (sleep 20; kadmind ${stash_flag} >/dev/null 2>&1 &) &
- ;;
- esac
- unset stash_flag
- ;;
- esac
-
- case ${pppoed_enable} in
- [Yy][Ee][Ss])
- if [ -n "${pppoed_provider}" ]; then
- pppoed_flags="${pppoed_flags} -p ${pppoed_provider}"
- fi
- echo -n ' pppoed';
- /usr/libexec/pppoed ${pppoed_flags} ${pppoed_interface}
- ;;
- esac
-
- case ${sshd_enable} in
- [Yy][Ee][Ss])
- if [ ! -f /etc/ssh/ssh_host_key ]; then
- echo ' creating ssh host key';
- /usr/bin/ssh-keygen -N "" -f /etc/ssh/ssh_host_key
- fi
- ;;
- esac
-
- echo '.'
- network_pass3_done=YES
-}
-
-network_pass4() {
- echo -n 'Additional TCP options:'
- case ${log_in_vain} in
- [Nn][Oo] | '')
- ;;
- *)
- echo -n ' log_in_vain=YES'
- sysctl -w net.inet.tcp.log_in_vain=1 >/dev/null
- sysctl -w net.inet.udp.log_in_vain=1 >/dev/null
- ;;
- esac
-
- echo '.'
- network_pass4_done=YES
-}
diff --git a/etc/rc.d/serial b/etc/rc.d/serial
deleted file mode 100644
index 9d66530e454d..000000000000
--- a/etc/rc.d/serial
+++ /dev/null
@@ -1,127 +0,0 @@
-#!/bin/sh
-# $FreeBSD$
-
-# Change some defaults for serial devices.
-# Standard defaults are:
-# dtrwait 300 drainwait 0
-# initial cflag from <sys/ttydefaults.h> = cread cs8 hupcl
-# initial iflag, lflag and oflag all 0
-# speed 9600
-# special chars from <sys/ttydefaults.h>
-# nothing locked
-# except for serial consoles the initial iflag, lflag and oflag are from
-# <sys/ttydefaults.h> and clocal is locked on.
-
-default() {
- # Reset everything changed by the other functions to initial defaults.
-
- ci=$1; shift # call in device identifier
- co=$1; shift # call out device identifier
-
- for i in $*
- do
- comcontrol /dev/tty${ci}${i} dtrwait 300 drainwait 0
- stty < /dev/ttyi${ci}${i} -clocal crtscts hupcl 9600 reprint ^R
- stty < /dev/ttyl${ci}${i} -clocal -crtscts -hupcl 0
- stty < /dev/cuai${co}${i} -clocal crtscts hupcl 9600 reprint ^R
- stty < /dev/cual${co}${i} -clocal -crtscts -hupcl 0
- done
-}
-
-maybe() {
- # Special settings.
-
- ci=$1; shift
- co=$1; shift
-
- for i in $*
- do
- # Don't use ^R; it breaks bash's ^R when typed ahead.
- stty < /dev/ttyi${ci}${i} reprint undef
- stty < /dev/cuai${co}${i} reprint undef
- # Lock clocal off on dialin device for security.
- stty < /dev/ttyl${ci}${i} clocal
- # Lock the speeds to use old binaries that don't support them.
- # Any legal speed works to lock the initial speed.
- stty < /dev/ttyl${ci}${i} 300
- stty < /dev/cual${co}${i} 300
- done
-}
-
-modem() {
- # Modem that supports CTS and perhaps RTS handshaking.
-
- ci=$1; shift
- co=$1; shift
-
- for i in $*
- do
- # may depend on modem
- comcontrol /dev/tty${ci}${i} dtrwait 100 drainwait 180
- # Lock crtscts on.
- # Speed reasonable for V42bis.
- stty < /dev/ttyi${ci}${i} crtscts 57600
- stty < /dev/ttyl${ci}${i} crtscts
- stty < /dev/cuai${co}${i} crtscts 57600
- stty < /dev/cual${co}${i} crtscts
- done
-}
-
-mouse() {
- # Mouse on either callin or callout port.
-
- ci=$1; shift
- co=$1; shift
-
- for i in $*
- do
- # Lock clocal on, hupcl off.
- # Standard speed for Microsoft mouse.
- stty < /dev/ttyi${ci}${i} clocal -hupcl 1200
- stty < /dev/ttyl${ci}${i} clocal hupcl
- stty < /dev/cuai${co}${i} clocal -hupcl 1200
- stty < /dev/cual${co}${i} clocal hupcl
- done
-}
-
-terminal() {
- # Terminal that supports CTS and perhaps RTS handshaking
- # with the cable or terminal arranged so that DCD is on
- # at least while the terminal is on.
- # Also works for bidirectional communications to another pc
- # provided at most one side runs getty.
- # Same as modem() except we want a faster speed and no dtrwait.
-
- ci=$1; shift
- co=$1; shift
-
- modem ${ci} ${co} $*
- for i in $*
- do
- comcontrol /dev/tty${ci}${i} dtrwait 0
- stty < /dev/ttyi${ci}${i} 115200
- stty < /dev/cuai${co}${i} 115200
- done
-}
-
-# Don't use anything from this file unless you have some buggy programs
-# that require it.
-
-# Edit the functions and the examples to suit your system.
-# $1 is the call in device identifier, $2 is the call out device identifier
-# and the remainder of the line lists the device numbers.
-
-# Initialize assorted 8250-16550 (sio) ports.
-# maybe d a 0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v
-# mouse d a 2
-# modem d a 1
-# terminal d a 0
-
-# Initialize all ports on a Cyclades-8yo.
-# modem c c 00 01 02 03 04 05 06 07
-
-# Initialize all ports on a Cyclades-16ye.
-# modem c c 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
-
-# Initialize all ports on a Digiboard 8.
-# modem D D 00 01 02 03 04 05 06 07
diff --git a/etc/rc.d/sysctl b/etc/rc.d/sysctl
deleted file mode 100644
index 1a5c48eff461..000000000000
--- a/etc/rc.d/sysctl
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/sh
-#
-# Read in /etc/sysctl.conf and set things accordingly
-#
-# $FreeBSD$
-if [ -f /etc/sysctl.conf ]; then
- sed '
- /^[ ]*#/d
- /^[ ]*$/d
- s/#.*$//g
- ' /etc/sysctl.conf |
- while read var
- do
- sysctl -w ${var}
- done
-fi
diff --git a/etc/rc.d/tmp b/etc/rc.d/tmp
deleted file mode 100644
index 9ccdfa80ed14..000000000000
--- a/etc/rc.d/tmp
+++ /dev/null
@@ -1,43 +0,0 @@
-# $FreeBSD$
-#
-
-# PROVIDE: diskless
-# REQUIRE: initdiskless mountcritlocal
- if [ -n "$4" ]; then
- bpi="-i $4"
- fi
- /sbin/mdconfig -a -t malloc -s $1 -u $3
- /sbin/newfs $bpi /dev/md$3c
- /sbin/mount /dev/md$3c $2
-}
-
-mount_mfs -s ${varsize:=65536} -T qp120at dummy /var
-var_dirs="run dev db msgs tmp spool spool/mqueue spool/lpd spool/output \
- spool/output/lpd"
-for i in ${var_dirs}
-do
- mkdir /var/${i}
-done
-chmod 755 /var/run
-chmod 755 /var/db
-chmod 755 /var/spool
-chmod 1777 /var/tmp
-chown -R root.daemon /var/spool/output
-chgrp daemon /var/spool/lpd
-# Since we are starting with a very fresh /etc on an MFS:
-if [ -d /conf/default/etc ]; then
- newaliases
-fi
-if [ ! -h /tmp -a ! -h /var/tmp ]; then
- mount_null /var/tmp /tmp
-fi
-#
-# extract a list of device entries, then copy them to a writable partition
-(cd /; find -x dev | cpio -o -H newc) > /tmp/dev.tmp
-mount_mfs -s 4096 -i 512 -T qp120at dummy /dev
-(cd /; cpio -i -H newc -d < /tmp/dev.tmp)
- # extract a list of device entries, then copy them to a writable fs
- (cd /; find -x dev | cpio -o -H newc) > /tmp/dev.tmp
- mount_md 4096 /dev 3 512
- (cd /; cpio -i -H newc -d < /tmp/dev.tmp)
-fi
diff --git a/etc/rc.d/var b/etc/rc.d/var
deleted file mode 100644
index 9ccdfa80ed14..000000000000
--- a/etc/rc.d/var
+++ /dev/null
@@ -1,43 +0,0 @@
-# $FreeBSD$
-#
-
-# PROVIDE: diskless
-# REQUIRE: initdiskless mountcritlocal
- if [ -n "$4" ]; then
- bpi="-i $4"
- fi
- /sbin/mdconfig -a -t malloc -s $1 -u $3
- /sbin/newfs $bpi /dev/md$3c
- /sbin/mount /dev/md$3c $2
-}
-
-mount_mfs -s ${varsize:=65536} -T qp120at dummy /var
-var_dirs="run dev db msgs tmp spool spool/mqueue spool/lpd spool/output \
- spool/output/lpd"
-for i in ${var_dirs}
-do
- mkdir /var/${i}
-done
-chmod 755 /var/run
-chmod 755 /var/db
-chmod 755 /var/spool
-chmod 1777 /var/tmp
-chown -R root.daemon /var/spool/output
-chgrp daemon /var/spool/lpd
-# Since we are starting with a very fresh /etc on an MFS:
-if [ -d /conf/default/etc ]; then
- newaliases
-fi
-if [ ! -h /tmp -a ! -h /var/tmp ]; then
- mount_null /var/tmp /tmp
-fi
-#
-# extract a list of device entries, then copy them to a writable partition
-(cd /; find -x dev | cpio -o -H newc) > /tmp/dev.tmp
-mount_mfs -s 4096 -i 512 -T qp120at dummy /dev
-(cd /; cpio -i -H newc -d < /tmp/dev.tmp)
- # extract a list of device entries, then copy them to a writable fs
- (cd /; find -x dev | cpio -o -H newc) > /tmp/dev.tmp
- mount_md 4096 /dev 3 512
- (cd /; cpio -i -H newc -d < /tmp/dev.tmp)
-fi
diff --git a/etc/rc.initdiskless b/etc/rc.initdiskless
deleted file mode 100644
index 6b306ba3046e..000000000000
--- a/etc/rc.initdiskless
+++ /dev/null
@@ -1,101 +0,0 @@
-# $FreeBSD$
-#
-# /etc/rc.diskless1 - general BOOTP startup
-#
-# BOOTP has mounted / for us. Assume a read-only mount. We must then
-# - figure out our IP by querying the interface
-# - fill /conf/etc (writable) with files from /etc, and then update
-# per-machine files from /conf/*/ where * is the IP of the host,
-# the IP of the subnet, "default", or nothing.
-# - mount /conf/etc over /etc so we can see the new files.
-#
-# WARNING: i thing you should not change /etc/rc or strange things could
-# happen.
-#
-# The operator is in charge of setting /conf/*/etc/* things as appropriate.
-# Typically rc.conf and fstab need to be changed, but possibly
-# also other files such as inetd.conf etc.
-
-# chkerr:
-#
-# Routine to check for error
-#
-# checks error code and drops into shell on failure.
-# if shell exits, terminates script as well as /etc/rc.
-#
-chkerr() {
- case $1 in
- 0)
- ;;
- *)
- echo "$2 failed: dropping into /bin/sh"
- /bin/sh
- # RESUME
- ;;
- esac
-}
-
-# DEBUGGING
-#
-# set -v
-
-# Figure out our interface and IP.
-#
-bootp_ifc=""
-bootp_ipa=""
-bootp_ipbca=""
-iflist=`ifconfig -l`
-for i in ${iflist} ; do
- set `ifconfig ${i}`
- while [ $# -ge 1 ] ; do
- if [ "${bootp_ifc}" = "" -a "$1" = "inet" ] ; then
- bootp_ifc=${i} ; bootp_ipa=${2} ; shift
- fi
- if [ "${bootp_ipbca}" = "" -a "$1" = "broadcast" ] ; then
- bootp_ipbca=$2; shift
- fi
- shift
- done
- if [ "${bootp_ifc}" != "" ] ; then
- break
- fi
-done
-echo "Interface ${bootp_ifc} IP-Address ${bootp_ipa} Broadcast ${bootp_ipbca}"
-
-# Files in /etc are copied to /conf/etc which is writable. Then
-# per-machine configs from /conf/ip.address/etc are copied onto this
-# directory. First choice is using the client's IP, then the client's
-# broadcast address, then a default configuration.
-# This way we have some flexibility to handle clusters of machines
-# on separate subnets.
-#
-# WARNING! null mounts cannot handle mmap, and since many programs
-# use mmap (such as 'cp'), we have to copy.
-#
-mount_mfs -s 2048 -T qp120at dummy /conf/etc
-cp -Rp /etc/* /conf/etc
-chkerr $? "MFS mount on /conf/etc"
-
-if [ -d /conf/${bootp_ipa} ] ; then
- cp -Rp /conf/${bootp_ipa}/etc/* /conf/etc
-elif [ -d /conf/${bootp_ipbca} ] ; then
- cp -Rp /conf/${bootp_ipbca}/etc/* /conf/etc
-else
- cp -Rp /conf/default/etc/* /conf/etc
-fi
-
-# Make the new directory available as /etc
-#
-mount_null /conf/etc /etc
-
-# Tell /etc/rc to run the specified script after
-# it does its mounts but before it does anything
-# else.
-#
-# This script is responsible for setting up the
-# diskless mount environment. This can be
-# overriden by /conf/ME/rc.conf.local if, for
-# example, you do not want to run the standard
-# system /etc/rc.diskless2
-
-diskless_mount="/etc/rc.diskless2"
diff --git a/gnu/usr.bin/binutils/gdb/kvm-fbsd.c b/gnu/usr.bin/binutils/gdb/kvm-fbsd.c
deleted file mode 100644
index 2608e3c9b335..000000000000
--- a/gnu/usr.bin/binutils/gdb/kvm-fbsd.c
+++ /dev/null
@@ -1,974 +0,0 @@
-/* Live and postmortem kernel debugging functions for FreeBSD.
- Copyright 1996 Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#include "defs.h"
-
-#include <errno.h>
-#include <signal.h>
-#include <fcntl.h>
-#include <sys/sysctl.h>
-#include <sys/param.h>
-#include <sys/time.h>
-#include <sys/proc.h>
-#include <sys/user.h>
-#include "frame.h" /* required by inferior.h */
-#include "inferior.h"
-#include "symtab.h"
-#include "symfile.h"
-#include "objfiles.h"
-#include "command.h"
-#include "bfd.h"
-#include "target.h"
-#include "gdbcore.h"
-#include <sys/stat.h>
-#include <unistd.h>
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-
-#include <machine/vmparam.h>
-#include <machine/pcb.h>
-#include <machine/tss.h>
-#include <machine/frame.h>
-
-static void kcore_files_info PARAMS ((struct target_ops *));
-
-static void kcore_close PARAMS ((int));
-
-static void get_kcore_registers PARAMS ((int));
-
-static int kcore_xfer_kmem PARAMS ((CORE_ADDR, char *, int, int, struct target_ops *));
-
-static int xfer_umem PARAMS ((CORE_ADDR, char *, int, int));
-
-static CORE_ADDR ksym_lookup PARAMS ((const char *));
-
-static int read_pcb PARAMS ((int, CORE_ADDR));
-
-static struct proc * curProc PARAMS ((void));
-
-static int set_proc_context PARAMS ((CORE_ADDR paddr));
-
-static void kcore_open PARAMS ((char *filename, int from_tty));
-
-static void kcore_detach PARAMS ((char *args, int from_tty));
-
-static void set_proc_cmd PARAMS ((char *arg, int from_tty));
-
-static void set_cpu_cmd PARAMS ((char *arg, int from_tty));
-
-static CORE_ADDR kvtophys PARAMS ((int, CORE_ADDR));
-
-static int physrd PARAMS ((int, u_int, char*, int));
-
-static int kvm_open PARAMS ((const char *efile, char *cfile, char *sfile,
- int perm, char *errout));
-
-static int kvm_close PARAMS ((int fd));
-
-static int kvm_write PARAMS ((int core_kd, CORE_ADDR memaddr,
- char *myaddr, int len));
-
-static int kvm_read PARAMS ((int core_kd, CORE_ADDR memaddr,
- char *myaddr, int len));
-
-static int kvm_uread PARAMS ((int core_kd, struct proc *p,
- CORE_ADDR memaddr, char *myaddr,
- int len));
-
-static int kernel_core_file_hook PARAMS ((int fd, CORE_ADDR addr,
- char *buf, int len));
-
-static struct kinfo_proc * kvm_getprocs PARAMS ((int cfd, int op,
- CORE_ADDR proc, int *cnt));
-
-extern struct target_ops kcore_ops; /* Forward decl */
-
-/* Non-zero means we are debugging a kernel core file */
-int kernel_debugging = 0;
-int kernel_writablecore = 0;
-
-static char *core_file;
-static int core_kd = -1;
-static struct proc *cur_proc;
-static CORE_ADDR kernel_start;
-
-static int ncpus;
-static int cpuid;
-static CORE_ADDR prv_space; /* per-cpu private space */
-static int prv_space_size;
-#define prv_start (prv_space + cpuid * prv_space_size)
-
-/*
- * Read the "thing" at kernel address 'addr' into the space pointed to
- * by point. The length of the "thing" is determined by the type of p.
- * Result is non-zero if transfer fails.
- */
-#define kvread(addr, p) \
- (target_read_memory ((CORE_ADDR)(addr), (char *)(p), sizeof(*(p))))
-
-
-
-/*
- * The following is FreeBSD-specific hackery to decode special frames
- * and elide the assembly-language stub. This could be made faster by
- * defining a frame_type field in the machine-dependent frame information,
- * but we don't think that's too important right now.
- */
-enum frametype { tf_normal, tf_trap, tf_interrupt, tf_syscall };
-
-CORE_ADDR
-fbsd_kern_frame_saved_pc (fr)
-struct frame_info *fr;
-{
- struct minimal_symbol *sym;
- CORE_ADDR this_saved_pc;
- enum frametype frametype;
-
- this_saved_pc = read_memory_integer (fr->frame + 4, 4);
- sym = lookup_minimal_symbol_by_pc (this_saved_pc);
- frametype = tf_normal;
- if (sym != NULL) {
- if (strcmp (SYMBOL_NAME(sym), "calltrap") == 0)
- frametype = tf_trap;
- else if (strncmp (SYMBOL_NAME(sym), "Xresume", 7) == 0)
- frametype = tf_interrupt;
- else if (strcmp (SYMBOL_NAME(sym), "Xsyscall") == 0)
- frametype = tf_syscall;
- }
-
- switch (frametype) {
- case tf_normal:
- return (this_saved_pc);
-
-#define oEIP offsetof(struct trapframe, tf_eip)
-
- case tf_trap:
- return (read_memory_integer (fr->frame + 8 + oEIP, 4));
-
- case tf_interrupt:
- return (read_memory_integer (fr->frame + 16 + oEIP, 4));
-
- case tf_syscall:
- return (read_memory_integer (fr->frame + 8 + oEIP, 4));
-#undef oEIP
- }
-}
-
-static CORE_ADDR
-ksym_lookup (name)
-const char *name;
-{
- struct minimal_symbol *sym;
-
- sym = lookup_minimal_symbol (name, NULL, NULL);
- if (sym == NULL)
- error ("kernel symbol `%s' not found.", name);
-
- return SYMBOL_VALUE_ADDRESS (sym);
-}
-
-static struct proc *
-curProc ()
-{
- struct proc *p;
- CORE_ADDR addr = ksym_lookup ("gd_curproc") + prv_start;
-
- if (kvread (addr, &p))
- error ("cannot read proc pointer at %x\n", addr);
- return p;
-}
-
-/*
- * Set the process context to that of the proc structure at
- * system address paddr.
- */
-static int
-set_proc_context (paddr)
- CORE_ADDR paddr;
-{
- struct proc p;
-
- if (paddr < kernel_start)
- return (1);
-
- cur_proc = (struct proc *)paddr;
-#ifdef notyet
- set_kernel_boundaries (cur_proc);
-#endif
-
- /* Fetch all registers from core file */
- target_fetch_registers (-1);
-
- /* Now, set up the frame cache, and print the top of stack */
- flush_cached_frames ();
- set_current_frame (create_new_frame (read_fp (), read_pc ()));
- select_frame (get_current_frame (), 0);
- return (0);
-}
-
-/* Discard all vestiges of any previous core file
- and mark data and stack spaces as empty. */
-
-/* ARGSUSED */
-static void
-kcore_close (quitting)
- int quitting;
-{
- inferior_pid = 0; /* Avoid confusion from thread stuff */
-
- if (core_kd)
- {
- kvm_close (core_kd);
- free (core_file);
- core_file = NULL;
- core_kd = -1;
- }
-}
-
-/* This routine opens and sets up the core file bfd */
-
-static void
-kcore_open (filename, from_tty)
- char *filename;
- int from_tty;
-{
- const char *p;
- struct cleanup *old_chain;
- char buf[256], *cp;
- int ontop;
- CORE_ADDR addr;
- struct pcb pcb;
-
- target_preopen (from_tty);
-
- unpush_target (&kcore_ops);
-
- if (!filename)
- {
- /*error (core_kd?*/
- error ( (core_kd >= 0)?
- "No core file specified. (Use `detach' to stop debugging a core file.)"
- : "No core file specified.");
- }
-
- filename = tilde_expand (filename);
- if (filename[0] != '/')
- {
- cp = concat (current_directory, "/", filename, NULL);
- free (filename);
- filename = cp;
- }
-
- old_chain = make_cleanup (free, filename);
-
- /*
- * gdb doesn't really do anything if the exec-file couldn't
- * be opened (in that case exec_bfd is NULL). Usually that's
- * no big deal, but kvm_open needs the exec-file's name,
- * which results in dereferencing a NULL pointer, a real NO-NO !
- * So, check here if the open of the exec-file succeeded.
- */
- if (exec_bfd == NULL) /* the open failed */
- error ("kgdb could not open the exec-file, please check the name you used !");
-
- core_kd = kvm_open (exec_bfd->filename, filename, NULL,
- kernel_writablecore? O_RDWR : O_RDONLY, "kgdb: ");
- if (core_kd < 0)
- perror_with_name (filename);
-
- /* Looks semi-reasonable. Toss the old core file and work on the new. */
-
- discard_cleanups (old_chain); /* Don't free filename any more */
- core_file = filename;
- ontop = !push_target (&kcore_ops);
-
- kernel_start = bfd_get_start_address (exec_bfd); /* XXX */
-
- /* print out the panic string if there is one */
- if (kvread (ksym_lookup ("panicstr"), &addr) == 0
- && addr != 0
- && target_read_memory (addr, buf, sizeof (buf)) == 0)
- {
- for (cp = buf; cp < &buf[sizeof (buf)] && *cp; cp++)
- if (!isascii (*cp) || (!isprint (*cp) && !isspace (*cp)))
- *cp = '?';
- *cp = '\0';
- if (buf[0] != '\0')
- printf ("panicstr: %s\n", buf);
- }
-
- /* Print all the panic messages if possible. */
- if (symfile_objfile != NULL)
- {
- printf ("panic messages:\n---\n");
- snprintf (buf, sizeof buf,
- "/sbin/dmesg -N %s -M %s | \
- /usr/bin/awk '/^(panic:|Fatal trap) / { printing = 1 } \
- { if (printing) print $0 }'",
- symfile_objfile->name, filename);
- fflush(stdout);
- system (buf);
- printf ("---\n");
- }
-
- if (!ontop)
- {
- warning ("you won't be able to access this core file until you terminate\n\
-your %s; do ``info files''", target_longname);
- return;
- }
-
- /* we may need this later */
- cur_proc = (struct proc *)curProc ();
- /* Now, set up the frame cache, and print the top of stack */
- flush_cached_frames ();
- set_current_frame (create_new_frame (read_fp (), read_pc ()));
- select_frame (get_current_frame (), 0);
- print_stack_frame (selected_frame, selected_frame_level, 1);
-}
-
-static void
-kcore_detach (args, from_tty)
- char *args;
- int from_tty;
-{
- if (args)
- error ("Too many arguments");
- unpush_target (&kcore_ops);
- reinit_frame_cache ();
- if (from_tty)
- printf_filtered ("No kernel core file now.\n");
-}
-
-/* Get the registers out of a core file. This is the machine-
- independent part. Fetch_core_registers is the machine-dependent
- part, typically implemented in the xm-file for each architecture. */
-
-/* We just get all the registers, so we don't use regno. */
-/* ARGSUSED */
-static void
-get_kcore_registers (regno)
- int regno;
-{
- struct user *uaddr;
-
- /* find the pcb for the current process */
- if (cur_proc == NULL || kvread (&cur_proc->p_addr, &uaddr))
- error ("cannot read u area ptr for proc at %#x", cur_proc);
- if (read_pcb (core_kd, (CORE_ADDR)&uaddr->u_pcb) < 0)
- error ("cannot read pcb at %#x", &uaddr->u_pcb);
-}
-
-static void
-kcore_files_info (t)
- struct target_ops *t;
-{
- printf ("\t`%s'\n", core_file);
-}
-
-static int
-kcore_xfer_kmem (memaddr, myaddr, len, write, target)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
- int write;
- struct target_ops *target;
-{
- int ns;
- int nu;
-
- if (memaddr >= (CORE_ADDR)VM_MAXUSER_ADDRESS)
- nu = 0;
- else
- {
- nu = xfer_umem (memaddr, myaddr, len, write);
- if (nu <= 0)
- return (0);
- if (nu == len)
- return (nu);
- memaddr += nu;
- if (memaddr != (CORE_ADDR)VM_MAXUSER_ADDRESS)
- return (nu);
- myaddr += nu;
- len -= nu;
- }
-
- ns = (write ? kvm_write : kvm_read) (core_kd, memaddr, myaddr, len);
- if (ns < 0)
- ns = 0;
-
- return (nu + ns);
-}
-
-static int
-xfer_umem (memaddr, myaddr, len, write)
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
- int write; /* ignored */
-{
- int n;
- struct proc proc;
-
- if (cur_proc == NULL || kvread (cur_proc, &proc))
- error ("cannot read proc at %#x", cur_proc);
- n = kvm_uread (core_kd, &proc, memaddr, myaddr, len) ;
-
- if (n < 0)
- return 0;
- return n;
-}
-
-#define KERNOFF ((unsigned)KERNBASE)
-#define INKERNEL(x) ((x) >= KERNOFF)
-
-static CORE_ADDR sbr;
-static CORE_ADDR curpcb;
-static int found_pcb;
-static int devmem;
-static int kfd;
-static struct pcb pcb;
-
-static void
-set_proc_cmd (arg, from_tty)
- char *arg;
- int from_tty;
-{
- CORE_ADDR paddr;
- struct kinfo_proc *kp;
- int cnt = 0;
-
- if (!arg)
- error_no_arg ("proc address for new current process");
- if (!kernel_debugging)
- error ("not debugging kernel");
-
- paddr = (CORE_ADDR)parse_and_eval_address (arg);
- /* assume it's a proc pointer if it's in the kernel */
- if (paddr >= kernel_start) {
- if (set_proc_context(paddr))
- error("invalid proc address");
- } else {
- kp = kvm_getprocs(core_kd, KERN_PROC_PID, paddr, &cnt);
- if (!cnt)
- error("invalid pid");
- if (set_proc_context((CORE_ADDR)kp->kp_eproc.e_paddr))
- error("invalid proc address");
- }
-}
-
-static void
-set_cpu_cmd (arg, from_tty)
- char *arg;
- int from_tty;
-{
- CORE_ADDR paddr;
- struct kinfo_proc *kp;
- int cpu, cfd;
-
- if (!arg)
- error_no_arg ("cpu number");
- if (!kernel_debugging)
- error ("not debugging kernel");
- if (!ncpus)
- error ("not debugging SMP kernel");
-
- cpu = (int)parse_and_eval_address (arg);
- if (cpu < 0 || cpu > ncpus)
- error ("cpu number out of range");
- cpuid = cpu;
-
- cfd = core_kd;
- curpcb = kvtophys(cfd, ksym_lookup ("gd_curpcb") + prv_start);
- physrd (cfd, curpcb, (char*)&curpcb, sizeof curpcb);
-
- if (!devmem)
- paddr = ksym_lookup ("dumppcb") - KERNOFF;
- else
- paddr = kvtophys (cfd, curpcb);
- read_pcb (cfd, paddr);
- printf ("initial pcb at %lx\n", (unsigned long)paddr);
-
- if ((cur_proc = curProc()))
- target_fetch_registers (-1);
-
- /* Now, set up the frame cache, and print the top of stack */
- flush_cached_frames ();
- set_current_frame (create_new_frame (read_fp (), read_pc ()));
- select_frame (get_current_frame (), 0);
- print_stack_frame (selected_frame, selected_frame_level, 1);
-}
-
-/* substitutes for the stuff in libkvm which doesn't work */
-/* most of this was taken from the old kgdb */
-
-/* we don't need all this stuff, but the call should look the same */
-
-static int
-kvm_open (efile, cfile, sfile, perm, errout)
- const char *efile;
- char *cfile;
- char *sfile; /* makes this kvm_open more compatible to the one in libkvm */
- int perm;
- char *errout; /* makes this kvm_open more compatible to the one in libkvm */
-{
- struct stat stb;
- int cfd;
- CORE_ADDR paddr;
-
- if ((cfd = open (cfile, perm, 0)) < 0)
- return (cfd);
-
- fstat (cfd, &stb);
- if ((stb.st_mode & S_IFMT) == S_IFCHR
- && stb.st_rdev == makedev (2, 0))
- {
- devmem = 1;
- kfd = open ("/dev/kmem", perm, 0);
- }
-
- if (lookup_minimal_symbol("mp_ncpus", NULL, NULL)) {
- physrd(cfd, ksym_lookup("mp_ncpus") - KERNOFF,
- (char*)&ncpus, sizeof(ncpus));
- prv_space = ksym_lookup("SMP_prvspace");
- prv_space_size = (int)ksym_lookup("gd_idlestack_top");
- printf ("SMP %d cpus\n", ncpus);
- } else {
- ncpus = 0;
- prv_space = 0;
- prv_space_size = 0;
- }
- cpuid = 0;
-
- physrd (cfd, ksym_lookup ("IdlePTD") - KERNOFF, (char*)&sbr, sizeof sbr);
- printf ("IdlePTD %lu\n", (unsigned long)sbr);
- curpcb = kvtophys(cfd, ksym_lookup ("gd_curpcb") + prv_start);
- physrd (cfd, curpcb, (char*)&curpcb, sizeof curpcb);
-
- found_pcb = 1; /* for vtophys */
- if (!devmem)
- paddr = ksym_lookup ("dumppcb") - KERNOFF;
- else
- paddr = kvtophys (cfd, curpcb);
- read_pcb (cfd, paddr);
- printf ("initial pcb at %lx\n", (unsigned long)paddr);
-
- return (cfd);
-}
-
-static int
-kvm_close (fd)
- int fd;
-{
- return (close (fd));
-}
-
-static int
-kvm_write (core_kd, memaddr, myaddr, len)
- int core_kd;
- CORE_ADDR memaddr;
- char *myaddr;
-{
- int cc;
-
- if (devmem)
- {
- if (kfd > 0)
- {
- /*
- * Just like kvm_read, only we write.
- */
- errno = 0;
- if (lseek (kfd, (off_t)memaddr, 0) < 0
- && errno != 0)
- {
- error ("kvm_write:invalid address (%x)", memaddr);
- return (0);
- }
- cc = write (kfd, myaddr, len);
- if (cc < 0)
- {
- error ("kvm_write:write failed");
- return (0);
- }
- else if (cc < len)
- error ("kvm_write:short write");
- return (cc);
- }
- else
- return (0);
- }
- else
- {
- printf ("kvm_write not implemented for dead kernels\n");
- return (0);
- }
- /* NOTREACHED */
-}
-
-static int
-kvm_read (core_kd, memaddr, myaddr, len)
- int core_kd;
- CORE_ADDR memaddr;
- char *myaddr;
-{
- return (kernel_core_file_hook (core_kd, memaddr, myaddr, len));
-}
-
-static int
-kvm_uread (core_kd, p, memaddr, myaddr, len)
- int core_kd;
- register struct proc *p;
- CORE_ADDR memaddr;
- char *myaddr;
- int len;
-{
- register char *cp;
- char procfile[MAXPATHLEN];
- ssize_t amount;
- int fd;
-
- if (devmem)
- {
- sprintf (procfile, "/proc/%d/mem", p->p_pid);
- fd = open (procfile, O_RDONLY, 0);
- if (fd < 0)
- {
- error ("cannot open %s", procfile);
- close (fd);
- return (0);
- }
-
- cp = myaddr;
- while (len > 0)
- {
- errno = 0;
- if (lseek (fd, (off_t)memaddr, 0) == -1 && errno != 0)
- {
- error ("invalid address (%x) in %s", memaddr, procfile);
- break;
- }
- amount = read (fd, cp, len);
- if (amount < 0)
- {
- error ("error reading %s", procfile);
- break;
- }
- if (amount == 0)
- {
- error ("EOF reading %s", procfile);
- break;
- }
- cp += amount;
- memaddr += amount;
- len -= amount;
- }
-
- close (fd);
- return ((ssize_t) (cp - myaddr));
- }
- else
- return (kernel_core_file_hook (core_kd, memaddr, myaddr, len));
-}
-
-static struct kinfo_proc kp;
-
-/*
- * try to do what kvm_proclist in libkvm would do
- */
-static int
-kvm_proclist (cfd, pid, p, cnt)
-int cfd, pid, *cnt;
-struct proc *p;
-{
- struct proc lp;
-
- for (; p != NULL; p = lp.p_list.le_next) {
- if (!kvm_read(cfd, (CORE_ADDR)p, (char *)&lp, sizeof (lp)))
- return (0);
- if (lp.p_pid != pid)
- continue;
- kp.kp_eproc.e_paddr = p;
- *cnt = 1;
- return (1);
- }
- *cnt = 0;
- return (0);
-}
-
-/*
- * try to do what kvm_deadprocs in libkvm would do
- */
-static struct kinfo_proc *
-kvm_deadprocs (cfd, pid, cnt)
-int cfd, pid, *cnt;
-{
- CORE_ADDR allproc, zombproc;
- struct proc *p;
-
- allproc = ksym_lookup("allproc");
- if (kvm_read(cfd, allproc, (char *)&p, sizeof (p)) == 0)
- return (NULL);
- kvm_proclist (cfd, pid, p, cnt);
- if (!*cnt) {
- zombproc = ksym_lookup("zombproc");
- if (kvm_read(cfd, zombproc, (char *)&p, sizeof (p)) == 0)
- return (NULL);
- kvm_proclist (cfd, pid, p, cnt);
- }
- return (&kp);
-}
-
-/*
- * try to do what kvm_getprocs in libkvm would do
- */
-static struct kinfo_proc *
-kvm_getprocs (cfd, op, proc, cnt)
-int cfd, op, *cnt;
-CORE_ADDR proc;
-{
- int mib[4], size;
-
- *cnt = 0;
- /* assume it's a pid */
- if (devmem) { /* "live" kernel, use sysctl */
- mib[0] = CTL_KERN;
- mib[1] = KERN_PROC;
- mib[2] = KERN_PROC_PID;
- mib[3] = (int)proc;
- size = sizeof (kp);
- if (sysctl (mib, 4, &kp, &size, NULL, 0) < 0) {
- perror("sysctl");
- *cnt = 0;
- return (NULL);
- }
- if (!size)
- *cnt = 0;
- else
- *cnt = 1;
- return (&kp);
- } else
- return (kvm_deadprocs (cfd, (int)proc, cnt));
-}
-
-static int
-physrd (cfd, addr, dat, len)
- int cfd;
- u_int addr;
- char *dat;
- int len;
-{
- if (lseek (cfd, (off_t)addr, L_SET) == -1)
- return (-1);
- return (read (cfd, dat, len));
-}
-
-static CORE_ADDR
-kvtophys (fd, addr)
- int fd;
- CORE_ADDR addr;
-{
- CORE_ADDR v;
- unsigned int pte;
- static CORE_ADDR PTD = -1;
- CORE_ADDR current_ptd;
-
- /*
- * We may no longer have a linear system page table...
- *
- * Here's the scoop. IdlePTD contains the physical address
- * of a page table directory that always maps the kernel.
- * IdlePTD is in memory that is mapped 1-to-1, so we can
- * find it easily given its 'virtual' address from ksym_lookup().
- * For hysterical reasons, the value of IdlePTD is stored in sbr.
- *
- * To look up a kernel address, we first convert it to a 1st-level
- * address and look it up in IdlePTD. This gives us the physical
- * address of a page table page; we extract the 2nd-level part of
- * VA and read the 2nd-level pte. Finally, we add the offset part
- * of the VA into the physical address from the pte and return it.
- *
- * User addresses are a little more complicated. If we don't have
- * a current PCB from read_pcb(), we use PTD, which is the (fixed)
- * virtual address of the current ptd. Since it's NOT in 1-to-1
- * kernel space, we must look it up using IdlePTD. If we do have
- * a pcb, we get the ptd from pcb_ptd.
- */
-
- if (INKERNEL (addr))
- current_ptd = sbr;
- else if (found_pcb == 0)
- {
- if (PTD == -1)
- PTD = kvtophys (fd, ksym_lookup ("PTD"));
- current_ptd = PTD;
- }
- else
- current_ptd = pcb.pcb_cr3;
-
- /*
- * Read the first-level page table (ptd).
- */
- v = current_ptd + ( (unsigned)addr >> PDRSHIFT) * sizeof pte;
- if (physrd (fd, v, (char *)&pte, sizeof pte) < 0 || (pte&PG_V) == 0)
- return (~0);
-
- if (pte & PG_PS)
- {
- /*
- * No second-level page table; ptd describes one 4MB page.
- * (We assume that the kernel wouldn't set PG_PS without enabling
- * it cr0, and that the kernel doesn't support 36-bit physical
- * addresses).
- */
-#define PAGE4M_MASK (NBPDR - 1)
-#define PG_FRAME4M (~PAGE4M_MASK)
- addr = (pte & PG_FRAME4M) + (addr & PAGE4M_MASK);
- }
- else
- {
- /*
- * Read the second-level page table.
- */
- v = (pte&PG_FRAME) + ((addr >> PAGE_SHIFT)&(NPTEPG-1)) * sizeof pte;
- if (physrd (fd, v, (char *) &pte, sizeof (pte)) < 0 || (pte&PG_V) == 0)
- return (~0);
-
- addr = (pte & PG_FRAME) + (addr & PAGE_MASK);
- }
-#if 0
- printf ("vtophys (%x) -> %x\n", oldaddr, addr);
-#endif
- return (addr);
-}
-
-static int
-read_pcb (fd, uaddr)
- int fd;
- CORE_ADDR uaddr;
-{
- int i;
- int noreg;
- CORE_ADDR nuaddr = uaddr;
-
- /* need this for the `proc' command to work */
- if (INKERNEL(uaddr))
- nuaddr = kvtophys(fd, uaddr);
-
- if (physrd (fd, nuaddr, (char *)&pcb, sizeof pcb) < 0)
- {
- error ("cannot read pcb at %x\n", uaddr);
- return (-1);
- }
-
- /*
- * get the register values out of the sys pcb and
- * store them where `read_register' will find them.
- */
- /*
- * XXX many registers aren't available.
- * XXX for the non-core case, the registers are stale - they are for
- * the last context switch to the debugger.
- * XXX gcc's register numbers aren't all #defined in tm-i386.h.
- */
- noreg = 0;
- for (i = 0; i < 3; ++i) /* eax,ecx,edx */
- supply_register (i, (char *)&noreg);
- supply_register (3, (char *)&pcb.pcb_ebx);
- supply_register (SP_REGNUM, (char *)&pcb.pcb_esp);
- supply_register (FP_REGNUM, (char *)&pcb.pcb_ebp);
- supply_register (6, (char *)&pcb.pcb_esi);
- supply_register (7, (char *)&pcb.pcb_edi);
- supply_register (PC_REGNUM, (char *)&pcb.pcb_eip);
- for (i = 9; i < 14; ++i) /* eflags, cs, ss, ds, es, fs */
- supply_register (i, (char *)&noreg);
- supply_register (15, (char *)&pcb.pcb_gs);
-
- /* XXX 80387 registers? */
-}
-
-/*
- * read len bytes from kernel virtual address 'addr' into local
- * buffer 'buf'. Return numbert of bytes if read ok, 0 otherwise. On read
- * errors, portion of buffer not read is zeroed.
- */
-
-static int
-kernel_core_file_hook (fd, addr, buf, len)
- int fd;
- CORE_ADDR addr;
- char *buf;
- int len;
-{
- int i;
- CORE_ADDR paddr;
- register char *cp;
- int cc;
-
- cp = buf;
-
- while (len > 0)
- {
- paddr = kvtophys (fd, addr);
- if (paddr == ~0)
- {
- memset (buf, '\000', len);
- break;
- }
- /* we can't read across a page boundary */
- i = min (len, PAGE_SIZE - (addr & PAGE_MASK));
- if ( (cc = physrd (fd, paddr, cp, i)) <= 0)
- {
- memset (cp, '\000', len);
- return (cp - buf);
- }
- cp += cc;
- addr += cc;
- len -= cc;
- }
- return (cp - buf);
-}
-
-static struct target_ops kcore_ops;
-
-void
-_initialize_kcorelow()
-{
- kcore_ops.to_shortname = "kcore";
- kcore_ops.to_longname = "Kernel core dump file";
- kcore_ops.to_doc =
- "Use a core file as a target. Specify the filename of the core file.";
- kcore_ops.to_open = kcore_open;
- kcore_ops.to_close = kcore_close;
- kcore_ops.to_attach = find_default_attach;
- kcore_ops.to_detach = kcore_detach;
- kcore_ops.to_fetch_registers = get_kcore_registers;
- kcore_ops.to_xfer_memory = kcore_xfer_kmem;
- kcore_ops.to_files_info = kcore_files_info;
- kcore_ops.to_create_inferior = find_default_create_inferior;
- kcore_ops.to_stratum = kcore_stratum;
- kcore_ops.to_has_memory = 1;
- kcore_ops.to_has_stack = 1;
- kcore_ops.to_has_registers = 1;
- kcore_ops.to_magic = OPS_MAGIC;
-
- add_target (&kcore_ops);
- add_com ("proc", class_obscure, set_proc_cmd, "Set current process context");
- add_com ("cpu", class_obscure, set_cpu_cmd, "Set current cpu");
-}
diff --git a/gnu/usr.bin/binutils/libopcodes/Makefile.amd64 b/gnu/usr.bin/binutils/libopcodes/Makefile.amd64
deleted file mode 100644
index 96c0bc74af5b..000000000000
--- a/gnu/usr.bin/binutils/libopcodes/Makefile.amd64
+++ /dev/null
@@ -1,6 +0,0 @@
-#
-# $FreeBSD$
-#
-
-SRCS+= i386-dis.c
-CFLAGS+= -DARCH_i386
diff --git a/gnu/usr.bin/cvs/cvs/prepend_args.c b/gnu/usr.bin/cvs/cvs/prepend_args.c
deleted file mode 100644
index 12322ce48bdf..000000000000
--- a/gnu/usr.bin/cvs/cvs/prepend_args.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/* prepend_args.c - utilility programs for manpiulating argv[]
- Copyright (C) 1999 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- 02111-1307, USA. */
-
-/* $FreeBSD$ */
-
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-#include "cvs.h"
-#include "prepend_args.h"
-
-
-/* Find the white-space-separated options specified by OPTIONS, and
- using BUF to store copies of these options, set ARGV[0], ARGV[1],
- etc. to the option copies. Return the number N of options found.
- Do not set ARGV[N] to NULL. If ARGV is NULL, do not store ARGV[0]
- etc. Backslash can be used to escape whitespace (and backslashes). */
-static int
-prepend_args (options, buf, argv)
- char const *options;
- char *buf;
- char **argv;
-{
- char const *o = options;
- char *b = buf;
- int n = 0;
-
- for (;;)
- {
- while (isspace ((unsigned char) *o))
- o++;
- if (!*o)
- return n;
- if (argv)
- argv[n] = b;
- n++;
-
- do
- if ((*b++ = *o++) == '\\' && *o)
- b[-1] = *o++;
- while (*o && ! isspace ((unsigned char) *o));
-
- *b++ = '\0';
- }
-}
-
-/* Prepend the whitespace-separated options in OPTIONS to the argument
- vector of a main program with argument count *PARGC and argument
- vector *PARGV. */
-void
-prepend_default_options (options, pargc, pargv)
- char const *options;
- int *pargc;
- char ***pargv;
-{
- if (options)
- {
- char *buf = xmalloc (strlen (options) + 1);
- int prepended = prepend_args (options, buf, (char **) NULL);
- int argc = *pargc;
- char * const *argv = *pargv;
- char **pp = (char **) xmalloc ((prepended + argc + 1) * sizeof *pp);
- *pargc = prepended + argc;
- *pargv = pp;
- *pp++ = *argv++;
- pp += prepend_args (options, buf, pp);
- while ((*pp++ = *argv++))
- continue;
- }
-}
diff --git a/gnu/usr.bin/cvs/cvs/prepend_args.h b/gnu/usr.bin/cvs/cvs/prepend_args.h
deleted file mode 100644
index 6708442ec124..000000000000
--- a/gnu/usr.bin/cvs/cvs/prepend_args.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/* prepend_args.h - utilility programs for manpiulating argv[]
- Copyright (C) 1999 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- 02111-1307, USA. */
-
-/* $FreeBSD$ */
-
-/* This code, taken from GNU Grep, originally used the "PARAM" macro, as the
- current GNU coding standards requires. Older GNU code used the "PROTO"
- macro, before the GNU coding standards replaced it. We use the older
- form here to keep from having to include another file in cvs/src/main.c. */
-
-void prepend_default_options PROTO ((char const *, int *, char ***));
diff --git a/gnu/usr.bin/cvs/lib/config.h.proto b/gnu/usr.bin/cvs/lib/config.h.proto
deleted file mode 100644
index 4de42413f50e..000000000000
--- a/gnu/usr.bin/cvs/lib/config.h.proto
+++ /dev/null
@@ -1,279 +0,0 @@
-/* $FreeBSD$ */
-/* config.h. Generated automatically by configure. */
-/* config.h.in. Generated automatically from configure.in by autoheader. */
-
-/* Define if on AIX 3.
- System headers sometimes define this.
- We just want to avoid a redefinition error message. */
-#ifndef _ALL_SOURCE
-/* #undef _ALL_SOURCE */
-#endif
-
-/* Define if the closedir function returns void instead of int. */
-/* #undef CLOSEDIR_VOID */
-
-/* Define to empty if the keyword does not work. */
-/* #undef const */
-
-/* Define to `int' if <sys/types.h> doesn't define. */
-/* #undef gid_t */
-
-/* Define if you support file names longer than 14 characters. */
-#define HAVE_LONG_FILE_NAMES 1
-
-/* Define if your struct stat has st_blksize. */
-#define HAVE_ST_BLKSIZE 1
-
-/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
-#define HAVE_SYS_WAIT_H 1
-
-/* Define if utime(file, NULL) sets file's timestamp to the present. */
-#define HAVE_UTIME_NULL 1
-
-/* Define if you have <vfork.h>. */
-/* #undef HAVE_VFORK_H */
-
-/* Define if on MINIX. */
-/* #undef _MINIX */
-
-/* Define to `int' if <sys/types.h> doesn't define. */
-/* #undef mode_t */
-
-/* Define to `int' if <sys/types.h> doesn't define. */
-/* #undef pid_t */
-
-/* Define if the system does not provide POSIX.1 features except
- with this defined. */
-/* #undef _POSIX_1_SOURCE */
-
-/* Define if you need to in order for stat and other things to work. */
-/* #undef _POSIX_SOURCE */
-
-/* Define as the return type of signal handlers (int or void). */
-#define RETSIGTYPE void
-
-/* Define to `unsigned' if <sys/types.h> doesn't define. */
-/* #undef size_t */
-
-/* Define if the `S_IS*' macros in <sys/stat.h> do not work properly. */
-/* #undef STAT_MACROS_BROKEN */
-
-/* Define if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Define if you can safely include both <sys/time.h> and <time.h>. */
-#define TIME_WITH_SYS_TIME 1
-
-/* Define to `int' if <sys/types.h> doesn't define. */
-/* #undef uid_t */
-
-/* Define vfork as fork if vfork does not work. */
-/* #undef vfork */
-
-/* Define if you have MIT Kerberos version 4 available. */
-/* #undef HAVE_KERBEROS */
-
-/* Define if you have GSSAPI with MIT Kerberos version 5 available. */
-/* #undef HAVE_GSSAPI */
-
-/* Define if GSS_C_NT_HOSTBASED_SERVICE is defined in the gssapi.h
- header file. Only relevant when using GSSAPI. */
-/* #undef HAVE_GSS_C_NT_HOSTBASED_SERVICE */
-
-/* Define if you want CVS to be able to be a remote repository client. */
-#define CLIENT_SUPPORT 1
-
-/* Define if you want CVS to be able to serve repositories to remote
- clients. */
-#define SERVER_SUPPORT 1
-
-/* Define if you want to use the password authenticated server. */
-#define AUTH_SERVER_SUPPORT 1
-
-/* Define if you want encryption support. */
-/* #undef ENCRYPTION */
-
-/* Define if you have the connect function. */
-/* #undef HAVE_CONNECT */
-
-/* Define if this system supports chown(), link(), and friends. */
-#define PRESERVE_PERMISSIONS_SUPPORT 1
-
-/* Define if you have memchr (always for CVS). */
-#define HAVE_MEMCHR 1
-
-/* Define if you have strchr (always for CVS). */
-#define HAVE_STRCHR 1
-
-/* Define if utime requires write access to the file (true on Windows,
- but not Unix). */
-/* #undef UTIME_EXPECTS_WRITABLE */
-
-/* Define if setmode is required when writing binary data to stdout. */
-/* #undef USE_SETMODE_STDOUT */
-
-/* Define if the diff library should use setmode for binary files.
- FIXME: Why two different macros for setmode? */
-/* #undef HAVE_SETMODE */
-
-/* Define if you have the crypt function. */
-#define HAVE_CRYPT 1
-
-/* Define if you have the fchdir function. */
-#define HAVE_FCHDIR 1
-
-/* Define if you have the fchmod function. */
-#define HAVE_FCHMOD 1
-
-/* Define if you have the fsync function. */
-#define HAVE_FSYNC 1
-
-/* Define if you have the ftime function. */
-/* #undef HAVE_FTIME */
-
-/* Define if you have the ftruncate function. */
-#define HAVE_FTRUNCATE 1
-
-/* Define if you have the getpagesize function. */
-#define HAVE_GETPAGESIZE 1
-
-/* Define if you have the getspnam function. */
-/* #undef HAVE_GETSPNAM */
-
-/* Define if you have the initgroups function. */
-#define HAVE_INITGROUPS 1
-
-/* Define if you have the krb_get_err_text function. */
-/* #undef HAVE_KRB_GET_ERR_TEXT */
-
-/* Define if you have the mktemp function. */
-#define HAVE_MKTEMP 1
-
-/* Define if you have the putenv function. */
-#define HAVE_PUTENV 1
-
-/* Define if you have the readlink function. */
-#define HAVE_READLINK 1
-
-/* Define if you have the sigaction function. */
-#define HAVE_SIGACTION 1
-
-/* Define if you have the sigblock function. */
-#define HAVE_SIGBLOCK 1
-
-/* Define if you have the sigprocmask function. */
-#define HAVE_SIGPROCMASK 1
-
-/* Define if you have the sigsetmask function. */
-#define HAVE_SIGSETMASK 1
-
-/* Define if you have the sigvec function. */
-#define HAVE_SIGVEC 1
-
-/* Define if you have the tempnam function. */
-#define HAVE_TEMPNAM 1
-
-/* Define if you have the timezone function. */
-#define HAVE_TIMEZONE 1
-
-/* Define if you have the tzset function. */
-#define HAVE_TZSET 1
-
-/* Define if you have the vprintf function. */
-#define HAVE_VPRINTF 1
-
-/* Define if you have the wait3 function. */
-#define HAVE_WAIT3 1
-
-/* Define if you have the <direct.h> header file. */
-/* #undef HAVE_DIRECT_H */
-
-/* Define if you have the <dirent.h> header file. */
-#define HAVE_DIRENT_H 1
-
-/* Define if you have the <errno.h> header file. */
-#define HAVE_ERRNO_H 1
-
-/* Define if you have the <fcntl.h> header file. */
-#define HAVE_FCNTL_H 1
-
-/* Define if you have the <gssapi.h> header file. */
-/* #undef HAVE_GSSAPI_H */
-
-/* Define if you have the <gssapi/gssapi.h> header file. */
-/* #undef HAVE_GSSAPI_GSSAPI_H */
-
-/* Define if you have the <gssapi/gssapi_generic.h> header file. */
-/* #undef HAVE_GSSAPI_GSSAPI_GENERIC_H */
-
-/* Define if you have the <io.h> header file. */
-/* #undef HAVE_IO_H */
-
-/* Define if you have the <limits.h> header file. */
-#define HAVE_LIMITS_H 1
-
-/* Define if you have the <memory.h> header file. */
-#define HAVE_MEMORY_H 1
-
-/* Define if you have the <ndbm.h> header file. */
-#define HAVE_NDBM_H 1
-
-/* Define if you have the <ndir.h> header file. */
-/* #undef HAVE_NDIR_H */
-
-/* Define if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Define if you have the <sys/bsdtypes.h> header file. */
-/* #undef HAVE_SYS_BSDTYPES_H */
-
-/* Define if you have the <sys/dir.h> header file. */
-/* #undef HAVE_SYS_DIR_H */
-
-/* Define if you have the <sys/file.h> header file. */
-#define HAVE_SYS_FILE_H 1
-
-/* Define if you have the <sys/ndir.h> header file. */
-/* #undef HAVE_SYS_NDIR_H */
-
-/* Define if you have the <sys/param.h> header file. */
-#define HAVE_SYS_PARAM_H 1
-
-/* Define if you have the <sys/resource.h> header file. */
-#define HAVE_SYS_RESOURCE_H 1
-
-/* Define if you have the <sys/select.h> header file. */
-#define HAVE_SYS_SELECT_H 1
-
-/* Define if you have the <sys/time.h> header file. */
-#define HAVE_SYS_TIME_H 1
-
-/* Define if you have the <sys/timeb.h> header file. */
-#define HAVE_SYS_TIMEB_H 1
-
-/* Define if you have the <unistd.h> header file. */
-#define HAVE_UNISTD_H 1
-
-/* Define if you have the <utime.h> header file. */
-#define HAVE_UTIME_H 1
-
-/* Define if you have the crypt library (-lcrypt). */
-#define HAVE_LIBCRYPT 1
-
-/* Define if you have the gen library (-lgen). */
-/* #undef HAVE_LIBGEN */
-
-/* Define if you have the inet library (-linet). */
-/* #undef HAVE_LIBINET */
-
-/* Define if you have the nsl library (-lnsl). */
-/* #undef HAVE_LIBNSL */
-
-/* Define if you have the nsl_s library (-lnsl_s). */
-/* #undef HAVE_LIBNSL_S */
-
-/* Define if you have the sec library (-lsec). */
-/* #undef HAVE_LIBSEC */
-
-/* Define if you have the socket library (-lsocket). */
-/* #undef HAVE_LIBSOCKET */
diff --git a/gnu/usr.bin/gdb/doc/inc-hist.diff b/gnu/usr.bin/gdb/doc/inc-hist.diff
deleted file mode 100644
index fdd212081cd3..000000000000
--- a/gnu/usr.bin/gdb/doc/inc-hist.diff
+++ /dev/null
@@ -1,24 +0,0 @@
-*** hsuser.texinfo Fri May 1 23:48:48 1998
---- inc-hist.texi Mon Jun 30 22:57:58 1997
-***************
-*** 34,42 ****
- @end ifset
- @ifclear BashFeatures
- This chapter describes how to use the GNU History Library interactively,
-! from a user's standpoint. It should be considered a user's guide. For
-! information on using the GNU History Library in your own programs,
-! @pxref{Programming with GNU History}.
- @end ifclear
-
- @ifset BashFeatures
---- 34,43 ----
- @end ifset
- @ifclear BashFeatures
- This chapter describes how to use the GNU History Library interactively,
-! from a user's standpoint.
-! @c It should be considered a user's guide. For
-! @c information on using the GNU History Library in your own programs,
-! @c @pxref{Programming with GNU History}.
- @end ifclear
-
- @ifset BashFeatures
diff --git a/gnu/usr.bin/groff/font/Makefile.dev b/gnu/usr.bin/groff/font/Makefile.dev
deleted file mode 100644
index 3f9d50617ba1..000000000000
--- a/gnu/usr.bin/groff/font/Makefile.dev
+++ /dev/null
@@ -1,33 +0,0 @@
-# @(#)Makefile.dev 6.2 (Berkeley) 3/16/91
-# Client Makefiles define DEV and DEVFILES and provide rules for
-# individual font files
-#
-# $FreeBSD$
-
-.include "../Makefile.cfg"
-
-FONTDIR?= /usr/share/groff_font
-DEVICEDIR?= $(FONTDIR)/dev$(DEV)
-FONTOWN?= ${BINOWN}
-FONTGRP?= ${BINGRP}
-FONTMODE?= ${NOBINMODE}
-
-all: $(DEVFILES)
-
-.for f in $(DEVFILES)
-.if exists(${.OBJDIR}/$f)
-beforeinstall:: ${.OBJDIR}/$f
- $(INSTALL) -c -o $(FONTOWN) -g $(FONTGRP) -m $(FONTMODE) \
- ${.OBJDIR}/$f $(DESTDIR)$(DEVICEDIR)
-.elif exists(${.CURDIR}/$f)
-beforeinstall:: ${.CURDIR}/$f
- $(INSTALL) -c -o $(FONTOWN) -g $(FONTGRP) -m $(FONTMODE) \
- ${.CURDIR}/$f $(DESTDIR)$(DEVICEDIR)
-.else
-beforeinstall:: $(DIST_DIR)/$f
- $(INSTALL) -c -o $(FONTOWN) -g $(FONTGRP) -m $(FONTMODE) \
- $(DIST_DIR)/$f $(DESTDIR)$(DEVICEDIR)
-.endif
-.endfor
-
-.include <bsd.prog.mk>
diff --git a/gnu/usr.bin/groff/font/Makefile.tty b/gnu/usr.bin/groff/font/Makefile.tty
deleted file mode 100644
index b745c0247f00..000000000000
--- a/gnu/usr.bin/groff/font/Makefile.tty
+++ /dev/null
@@ -1,55 +0,0 @@
-# @(#)Makefile.tty 6.1 (Berkeley) 3/3/91
-#
-# Modified for Berkeley Unix by Donn Seeley, donn@okeeffe.berkeley.edu
-#
-#Copyright (C) 1989, 1990 Free Software Foundation, Inc.
-# Written by James Clark (jjc@jclark.uucp)
-#
-#This file is part of groff.
-#
-#groff is free software; you can redistribute it and/or modify it under
-#the terms of the GNU General Public License as published by the Free
-#Software Foundation; either version 1, or (at your option) any later
-#version.
-#
-#groff is distributed in the hope that it will be useful, but WITHOUT ANY
-#WARRANTY; without even the implied warranty of MERCHANTABILITY or
-#FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-#for more details.
-#
-#You should have received a copy of the GNU General Public License along
-#with groff; see the file LICENSE. If not, write to the Free Software
-#Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-
-.MAIN: all
-
-RES=240
-CPI=10
-LPI=6
-FONTS=R I B BI S L
-
-DEVFILES=$(FONTS) DESC
-CLEANFILES=$(DEVFILES)
-
-$(FONTS): R.proto
- @${ECHO} Making $@
- @(charwidth=`echo $(RES) / $(CPI) | bc` ; \
- sed -e "s/^name [A-Z]*$$/name $@/" \
- -e "s/^\\([^ ]*\\) [0-9]+ /\\1 $$charwidth /" \
- -e "s/^spacewidth [0-9]+$$/spacewidth $$charwidth/" \
- -e "s/^internalname .*$$/internalname $@/" \
- -e "/^internalname/s/BI/3/" \
- -e "/^internalname/s/B/2/" \
- -e "/^internalname/s/I/1/" \
- -e "/^internalname .*[^ 0-9]/d" \
- ${DIST_DIR}/R.proto >$@)
-
-DESC: DESC.proto
- @${ECHO} Making $@
- @sed -e "s/^res .*$$/res $(RES)/" \
- -e "s/^hor .*$$/hor `echo $(RES) / $(CPI) | bc`/" \
- -e "s/^vert .*$$/vert `echo $(RES) / $(LPI) | bc`/" \
- -e "s/^fonts .*$$/fonts `set $(FONTS); echo $$#` $(FONTS)/" \
- ${DIST_DIR}/DESC.proto >$@
-
-beforeinstall:: ${DEVFILES}
diff --git a/gnu/usr.bin/groff/font/devkoi8-r/R.proto b/gnu/usr.bin/groff/font/devkoi8-r/R.proto
deleted file mode 100644
index 1b327d93b49b..000000000000
--- a/gnu/usr.bin/groff/font/devkoi8-r/R.proto
+++ /dev/null
@@ -1,299 +0,0 @@
-name R
-internalname 0
-spacewidth 24
-charset
-! 24 0 0041
-" 24 0 0042
-lq "
-rq "
-# 24 0 0043
-sh "
-$ 24 0 0044
-Do "
-% 24 0 0045
-& 24 0 0046
-' 24 0 0047
-aa "
-fm "
-aq "
-( 24 0 0050
-) 24 0 0051
-* 24 0 0052
-** "
-+ 24 0 0053
-pl "
-, 24 0 0054
-\- 24 0 0055
-hy "
-- "
-mi "
-en "
-em "
-. 24 0 0056
-/ 24 0 0057
-sl "
-f/ "
-0 24 0 0060
-1 24 0 0061
-2 24 0 0062
-3 24 0 0063
-4 24 0 0064
-5 24 0 0065
-6 24 0 0066
-7 24 0 0067
-8 24 0 0070
-9 24 0 0071
-: 24 0 0072
-; 24 0 0073
-< 24 0 0074
-la "
-fo "
-= 24 0 0075
-eq "
-> 24 0 0076
-ra "
-fc "
-? 24 0 0077
-@ 24 0 0100
-at "
-A 24 0 0101
-*A "
-B 24 0 0102
-*B "
-C 24 0 0103
-D 24 0 0104
-E 24 0 0105
-*E "
-F 24 0 0106
-G 24 0 0107
-H 24 0 0110
-*Y "
-I 24 0 0111
-*I "
-J 24 0 0112
-K 24 0 0113
-*K "
-L 24 0 0114
-M 24 0 0115
-*M "
-N 24 0 0116
-*N "
-O 24 0 0117
-ci "
-*O "
-P 24 0 0120
-*R "
-Q 24 0 0121
-R 24 0 0122
-S 24 0 0123
-T 24 0 0124
-*T "
-U 24 0 0125
-V 24 0 0126
-W 24 0 0127
-X 24 0 0130
-*X "
-Y 24 0 0131
-*U "
-Z 24 0 0132
-*Z "
-[ 24 0 0133
-lB "
-\ 24 0 0134
-rs "
-] 24 0 0135
-rB "
-a^ 24 0 0136
-^ "
-ha "
-_ 24 0 0137
-ru "
-ul "
-` 24 0 0140
-oq "
-ga "
-a 24 0 0141
-b 24 0 0142
-c 24 0 0143
-d 24 0 0144
-e 24 0 0145
-f 24 0 0146
-g 24 0 0147
-h 24 0 0150
-i 24 0 0151
-.i "
-j 24 0 0152
-k 24 0 0153
-l 24 0 0154
-m 24 0 0155
-n 24 0 0156
-o 24 0 0157
-*o "
-:o "
-/o "
-p 24 0 0160
-q 24 0 0161
-r 24 0 0162
-s 24 0 0163
-t 24 0 0164
-u 24 0 0165
-v 24 0 0166
-w 24 0 0167
-x 24 0 0170
-mu "
-y 24 0 0171
-z 24 0 0172
-lC 24 0 0173
-{ "
-ba 24 0 0174
-or "
-bv "
-br "
-| "
-lb "
-lc "
-lf "
-lk "
-lt "
-rb "
-rc "
-rf "
-rk "
-rt "
-rC 24 0 0175
-} "
-a~ 24 0 0176
-~ "
-ap "
-ti "
-char135 24 0 0207
-char136 24 0 0210
-char137 24 0 0211
-char138 24 0 0212
-char139 24 0 0213
-char140 24 0 0214
-char141 24 0 0215
-char142 24 0 0216
-char143 24 0 0217
-char144 24 0 0220
-char145 24 0 0221
-char146 24 0 0222
-char147 24 0 0223
-bu 24 0 0224
-char148 "
-char149 24 0 0225
-char150 24 0 0226
-~= 24 0 0227
-char151 "
-<= 24 0 0230
-char152 "
->= 24 0 0231
-char153 "
-char155 24 0 0233
-de 24 0 0234
-char156 "
-S2 24 0 0235
-char157 "
-md 24 0 0236
-char158 "
-di 24 0 0237
-char159 "
-char160 24 0 0240
-char161 24 0 0241
-char162 24 0 0242
-char163 24 0 0243
-:e "
-char164 24 0 0244
-char165 24 0 0245
-char166 24 0 0246
-char167 24 0 0247
-char168 24 0 0250
-char169 24 0 0251
-char170 24 0 0252
-char171 24 0 0253
-char172 24 0 0254
-char173 24 0 0255
-char174 24 0 0256
-char175 24 0 0257
-char176 24 0 0260
-char177 24 0 0261
-char178 24 0 0262
-char179 24 0 0263
-:E "
-char180 24 0 0264
-char181 24 0 0265
-char182 24 0 0266
-char183 24 0 0267
-char184 24 0 0270
-char185 24 0 0271
-char186 24 0 0272
-char187 24 0 0273
-char188 24 0 0274
-char189 24 0 0275
-char190 24 0 0276
-co 24 0 0277
-char191 "
-char192 24 0 0300
-char193 24 0 0301
-char194 24 0 0302
-char195 24 0 0303
-char196 24 0 0304
-char197 24 0 0305
-char198 24 0 0306
-char199 24 0 0307
-char200 24 0 0310
-char201 24 0 0311
-char202 24 0 0312
-char203 24 0 0313
-char204 24 0 0314
-char205 24 0 0315
-char206 24 0 0316
-char207 24 0 0317
-char208 24 0 0320
-char209 24 0 0321
-char210 24 0 0322
-char211 24 0 0323
-char212 24 0 0324
-char213 24 0 0325
-char214 24 0 0326
-char215 24 0 0327
-char216 24 0 0330
-char217 24 0 0331
-char218 24 0 0332
-char219 24 0 0333
-char220 24 0 0334
-char221 24 0 0335
-char222 24 0 0336
-char223 24 0 0337
-char224 24 0 0340
-char225 24 0 0341
-char226 24 0 0342
-char227 24 0 0343
-char228 24 0 0344
-char229 24 0 0345
-char230 24 0 0346
-char231 24 0 0347
-char232 24 0 0350
-char233 24 0 0351
-char234 24 0 0352
-char235 24 0 0353
-char236 24 0 0354
-char237 24 0 0355
-char238 24 0 0356
-char239 24 0 0357
-char240 24 0 0360
-char241 24 0 0361
-char242 24 0 0362
-char243 24 0 0363
-char244 24 0 0364
-char245 24 0 0365
-char246 24 0 0366
-char247 24 0 0367
-char248 24 0 0370
-char249 24 0 0371
-char250 24 0 0372
-char251 24 0 0373
-char252 24 0 0374
-char253 24 0 0375
-char254 24 0 0376
-char255 24 0 0377
diff --git a/gnu/usr.bin/groff/src/include/defs.h b/gnu/usr.bin/groff/src/include/defs.h
deleted file mode 100644
index df2efba57eab..000000000000
--- a/gnu/usr.bin/groff/src/include/defs.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#define PROG_PREFIX ""
-#define DEVICE "ps"
-#define FONTPATH "/usr/share/groff_font"
-#define MACROPATH "/usr/share/tmac"
-#define INDEX_SUFFIX ".i"
-#define COMMON_WORDS_FILE "/usr/share/dict/eign"
-#define DEFAULT_INDEX_DIR "/usr/share/dict/papers"
-#define DEFAULT_INDEX_NAME "Ind"
-#define DEFAULT_INDEX "/usr/share/dict/papers/Ind"
diff --git a/include/_ctype.h b/include/_ctype.h
deleted file mode 100644
index 1f266feabfdc..000000000000
--- a/include/_ctype.h
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
- *
- * This code is derived from software contributed to Berkeley by
- * Paul Borman at Krystal Technologies.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)ctype.h 8.4 (Berkeley) 1/21/94
- * $FreeBSD$
- */
-
-#ifndef _CTYPE_H_
-#define _CTYPE_H_
-
-/*
- * XXX <runetype.h> brings massive namespace pollution (rune_t and struct
- * member names).
- */
-#include <runetype.h>
-
-#define _CTYPE_A 0x00000100L /* Alpha */
-#define _CTYPE_C 0x00000200L /* Control */
-#define _CTYPE_D 0x00000400L /* Digit */
-#define _CTYPE_G 0x00000800L /* Graph */
-#define _CTYPE_L 0x00001000L /* Lower */
-#define _CTYPE_P 0x00002000L /* Punct */
-#define _CTYPE_S 0x00004000L /* Space */
-#define _CTYPE_U 0x00008000L /* Upper */
-#define _CTYPE_X 0x00010000L /* X digit */
-#define _CTYPE_B 0x00020000L /* Blank */
-#define _CTYPE_R 0x00040000L /* Print */
-#define _CTYPE_I 0x00080000L /* Ideogram */
-#define _CTYPE_T 0x00100000L /* Special */
-#define _CTYPE_Q 0x00200000L /* Phonogram */
-
-__BEGIN_DECLS
-int isalnum __P((int));
-int isalpha __P((int));
-int iscntrl __P((int));
-int isdigit __P((int));
-int isgraph __P((int));
-int islower __P((int));
-int isprint __P((int));
-int ispunct __P((int));
-int isspace __P((int));
-int isupper __P((int));
-int isxdigit __P((int));
-int tolower __P((int));
-int toupper __P((int));
-
-#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
-int digittoint __P((int));
-int isascii __P((int));
-int isblank __P((int));
-int ishexnumber __P((int));
-int isideogram __P((int));
-int isnumber __P((int));
-int isphonogram __P((int));
-int isrune __P((int));
-int isspecial __P((int));
-int toascii __P((int));
-#endif
-__END_DECLS
-
-#define __istype(c,f) (!!__maskrune((c),(f)))
-
-#define isalnum(c) __istype((c), _CTYPE_A|_CTYPE_D)
-#define isalpha(c) __istype((c), _CTYPE_A)
-#define iscntrl(c) __istype((c), _CTYPE_C)
-#define isdigit(c) __isctype((c), _CTYPE_D) /* ANSI -- locale independent */
-#define isgraph(c) __istype((c), _CTYPE_G)
-#define islower(c) __istype((c), _CTYPE_L)
-#define isprint(c) __istype((c), _CTYPE_R)
-#define ispunct(c) __istype((c), _CTYPE_P)
-#define isspace(c) __istype((c), _CTYPE_S)
-#define isupper(c) __istype((c), _CTYPE_U)
-#define isxdigit(c) __isctype((c), _CTYPE_X) /* ANSI -- locale independent */
-#define tolower(c) __tolower(c)
-#define toupper(c) __toupper(c)
-
-#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
-#define digittoint(c) __maskrune((c), 0xFF)
-#define isascii(c) (((c) & ~0x7F) == 0)
-#define isblank(c) __istype((c), _CTYPE_B)
-#define ishexnumber(c) __istype((c), _CTYPE_X)
-#define isideogram(c) __istype((c), _CTYPE_I)
-#define isnumber(c) __istype((c), _CTYPE_D)
-#define isphonogram(c) __istype((c), _CTYPE_Q)
-#define isrune(c) __istype((c), 0xFFFFFF00L)
-#define isspecial(c) __istype((c), _CTYPE_T)
-#define toascii(c) ((c) & 0x7F)
-#endif
-
-/* See comments in <machine/ansi.h> about _BSD_CT_RUNE_T_. */
-__BEGIN_DECLS
-unsigned long ___runetype __P((_BSD_CT_RUNE_T_));
-_BSD_CT_RUNE_T_ ___tolower __P((_BSD_CT_RUNE_T_));
-_BSD_CT_RUNE_T_ ___toupper __P((_BSD_CT_RUNE_T_));
-__END_DECLS
-
-/*
- * _EXTERNALIZE_CTYPE_INLINES_ is defined in locale/nomacros.c to tell us
- * to generate code for extern versions of all our inline functions.
- */
-#ifdef _EXTERNALIZE_CTYPE_INLINES_
-#define _USE_CTYPE_INLINE_
-#define static
-#define __inline
-#endif
-
-/*
- * Use inline functions if we are allowed to and the compiler supports them.
- */
-#if !defined(_DONT_USE_CTYPE_INLINE_) && \
- (defined(_USE_CTYPE_INLINE_) || defined(__GNUC__) || defined(__cplusplus))
-static __inline int
-__maskrune(_BSD_CT_RUNE_T_ _c, unsigned long _f)
-{
- return ((_c < 0 || _c >= _CACHED_RUNES) ? ___runetype(_c) :
- _CurrentRuneLocale->runetype[_c]) & _f;
-}
-
-static __inline int
-__isctype(_BSD_CT_RUNE_T_ _c, unsigned long _f)
-{
- return (_c < 0 || _c >= _CACHED_RUNES) ? 0 :
- !!(_DefaultRuneLocale.runetype[_c] & _f);
-}
-
-static __inline _BSD_CT_RUNE_T_
-__toupper(_BSD_CT_RUNE_T_ _c)
-{
- return (_c < 0 || _c >= _CACHED_RUNES) ? ___toupper(_c) :
- _CurrentRuneLocale->mapupper[_c];
-}
-
-static __inline _BSD_CT_RUNE_T_
-__tolower(_BSD_CT_RUNE_T_ _c)
-{
- return (_c < 0 || _c >= _CACHED_RUNES) ? ___tolower(_c) :
- _CurrentRuneLocale->maplower[_c];
-}
-
-#else /* not using inlines */
-
-__BEGIN_DECLS
-int __maskrune __P((_BSD_CT_RUNE_T_, unsigned long));
-int __isctype __P((_BSD_CT_RUNE_T_, unsigned long));
-_BSD_CT_RUNE_T_ __toupper __P((_BSD_CT_RUNE_T_));
-_BSD_CT_RUNE_T_ __tolower __P((_BSD_CT_RUNE_T_));
-__END_DECLS
-#endif /* using inlines */
-
-#endif /* !_CTYPE_H_ */
diff --git a/include/elf-hints.h b/include/elf-hints.h
deleted file mode 100644
index 963308378330..000000000000
--- a/include/elf-hints.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-
- * Copyright (c) 1997 John D. Polstra.
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _ELF_H_
-#define _ELF_H_
-
-#include <sys/types.h>
-#include <machine/elf.h>
-
-/*
- * Hints file produced by ldconfig.
- */
-struct elfhints_hdr {
- u_int32_t magic; /* Magic number */
- u_int32_t version; /* File version (1) */
- u_int32_t strtab; /* Offset of string table in file */
- u_int32_t strsize; /* Size of string table */
- u_int32_t dirlist; /* Offset of directory list in
- string table */
- u_int32_t dirlistlen; /* strlen(dirlist) */
- u_int32_t spare[26]; /* Room for expansion */
-};
-
-#define ELFHINTS_MAGIC 0x746e6845
-
-#define _PATH_ELF_HINTS "/var/run/ld-elf.so.hints"
-
-#endif /* !_ELF_H_ */
diff --git a/kerberos5/lib/libtelnet/Makefile b/kerberos5/lib/libtelnet/Makefile
deleted file mode 100644
index d6f4031a411e..000000000000
--- a/kerberos5/lib/libtelnet/Makefile
+++ /dev/null
@@ -1,26 +0,0 @@
-# $FreeBSD$
-
-LIB= telnet
-
-SRCS= genget.c getent.c misc.c encrypt.c auth.c kerberos.c \
- enc_des.c pk.c sra.c
-
-CFLAGS+= -DHAS_CGETENT -DENCRYPTION -DDES_ENCRYPTION -DAUTHENTICATION \
- -DKRB4 -DSRA -I${TELNETDIR} \
- -I${KRB4DIR}/lib/krb
-
-NOPIC= yes
-
-INCLUDES= ${TELNETDIR}/arpa/telnet.h
-
-#
-# Remove obsolete shared libraries, if any. We don't bother moving them
-# to/usr/lib/compat, since they were only used by telnet, telnetd and
-# tn3270.
-#
-beforeinstall:
- rm -f ${DESTDIR}${SHLIBDIR}/lib${LIB}.so.2.0
-
-.include <bsd.lib.mk>
-
-.PATH: ${TELNETDIR}/libtelnet
diff --git a/kerberos5/libexec/kadmind/Makefile b/kerberos5/libexec/kadmind/Makefile
deleted file mode 100644
index f5bb9b15ffd7..000000000000
--- a/kerberos5/libexec/kadmind/Makefile
+++ /dev/null
@@ -1,48 +0,0 @@
-# $FreeBSD$
-
-PROG= k5admind
-SRCS= kadmind.c server.c \
- kadm5/private.h kadm5/admin.h kadm5/kadm5_err.h
-CFLAGS+= -I${KRB5DIR}/include \
- -I${KRB5DIR}/lib/roken \
- -I${KRB5DIR}/lib/krb5 \
- -I${KRB5DIR}/lib/asn1 \
- -I${KRB5DIR}/lib/hdb \
- -I${KRB5DIR}/lib/sl \
- -I${KRB5DIR}/kadmin \
- -I${ASN1OBJDIR} \
- -I${HDBOBJDIR} \
- -I${.OBJDIR}
-.if defined(MAKE_KERBEROS4)
-SRCS+= version4.c
-_krb4libs= -lkrb -lkafs
-_krb4deps= ${LIBKRB} ${LIBKAFS}
-.endif
-LDADD= -L${KRB5OBJDIR} -lkrb5 \
- -L${ROKENOBJDIR} -lroken ${_krb4libs} \
- -L${KADM5COBJDIR} -lkadm5clnt -L${KADM5SOBJDIR} -lkadm5srv \
- -L${HDBOBJDIR} -lhdb \
- -L${ASN1OBJDIR} -lasn1 -lcrypto -lmd -lcrypt -lcom_err
-DPADD= ${LIBKRB5} ${LIBKAFS5} ${LIBROKEN} ${_krb4deps} \
- ${LIBKADM5CLNT} ${LIBKADM5SRV} ${LIBHDB} \
- ${LIBASN1} ${LIBCRYPTO} ${LIBMD} ${LIBCRYPT} ${LIBCOM_ERR}
-NOMAN= yes
-
-.include <bsd.prog.mk>
-
-.PATH: ${KRB5DIR}/kadmin
-
-kadm5/private.h: kadm5
- cp ${KRB5DIR}/lib/kadm5/private.h ${.TARGET}
-
-kadm5/admin.h: kadm5
- cp ${KRB5DIR}/lib/kadm5/admin.h ${.TARGET}
-
-kadm5/kadm5_err.h: kadm5 kadm5_err.h
- cd ${.OBJDIR}/kadm5 && ln -sf ../kadm5_err.h
-
-kadm5:
- mkdir ${.TARGET}
-
-CLEANFILES+= kadm5/private.h kadm5/admin.h kadm5/kadm5_err.h
-CLEANDIRS+= kadm5
diff --git a/kerberos5/libexec/kpasswdd/Makefile b/kerberos5/libexec/kpasswdd/Makefile
deleted file mode 100644
index 4ec263fe5ad8..000000000000
--- a/kerberos5/libexec/kpasswdd/Makefile
+++ /dev/null
@@ -1,36 +0,0 @@
-# $FreeBSD$
-
-PROG= k5passwdd
-SRCS= kpasswdd.c krb5_err.h heim_err.h hdb_err.h kadm5/admin.h
-CFLAGS+= -I${KRB5DIR}/include \
- -I${KRB5DIR}/lib/asn1 \
- -I${KRB5DIR}/lib/hdb \
- -I${KRB5DIR}/lib/krb5 \
- -I${KRB5DIR}/lib/roken \
- -I${KRB5DIR}/kpasswd \
- -I${ASN1OBJDIR} \
- -I${HDBOBJDIR} \
- -I${.OBJDIR}
-.if defined(MAKE_KERBEROS4)
-_krb4libs= -lkrb -lkafs
-_krb4deps= ${LIBKRB} ${LIBKAFS}
-.endif
-LDADD= -L${KRB5OBJDIR} -lkrb5 -L${ROKENOBJDIR} -lroken ${_krb4libs} \
- -L${KADM5SOBJDIR} -lkadm5srv -L${HDBOBJDIR} -lhdb \
- -L${ASN1OBJDIR} -lasn1 -lcrypto -lmd -lcrypt -lcom_err
-DPADD= ${LIBKRB5} ${LIBROKEN} ${_krb4deps} \
- ${LIBASN1} ${LIBCRYPTO} ${LIBMD} ${LIBCRYPT} ${LIBCOM_ERR}
-MAN8= kpasswdd.8
-
-.include <bsd.prog.mk>
-
-.PATH: ${KRB5DIR}/kpasswd
-
-kadm5/admin.h: kadm5
- cp ${KRB5DIR}/lib/kadm5/admin.h ${.TARGET}
-
-kadm5:
- mkdir ${.TARGET}
-
-CLEANFILES+= kadm5/admin.h
-CLEANDIRS+= kadm5
diff --git a/kerberos5/libexec/telnetd/Makefile b/kerberos5/libexec/telnetd/Makefile
deleted file mode 100644
index 6ec63616fa17..000000000000
--- a/kerberos5/libexec/telnetd/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
-# $FreeBSD$
-
-# Do not define -DKLUDGELINEMODE, as it does not interact well with many
-# telnet implementations.
-
-PROG= telnetd
-MAN8= telnetd.8
-
-CFLAGS+= -DLINEMODE -DUSE_TERMIO -DDIAGNOSTICS -DOLD_ENVIRON \
- -DENV_HACK -DAUTHENTICATION -DENCRYPTION \
- -I${TELNETDIR} -DINET6
-
-SRCS= global.c slc.c state.c sys_term.c telnetd.c \
- termstat.c utility.c authenc.c
-
-DPADD= ${LIBUTIL} ${LIBTERMCAP} ${LIBTELNET} ${LIBCRYPTO} ${LIBKRB} \
- ${LIBCRYPT} ${LIBCOM_ERR}
-LDADD= -lutil -ltermcap -L${TELNETOBJDIR} -ltelnet -lcrypto \
- -L${KRBOBJDIR} -lkrb -lcrypt -lcom_err -lmp
-
-.include <bsd.prog.mk>
-
-.PATH: ${TELNETDIR}/telnetd
diff --git a/kerberos5/usr.bin/kadmin/Makefile b/kerberos5/usr.bin/kadmin/Makefile
deleted file mode 100644
index 43cc5a53da4c..000000000000
--- a/kerberos5/usr.bin/kadmin/Makefile
+++ /dev/null
@@ -1,51 +0,0 @@
-# $FreeBSD$
-
-PROG= k5admin
-SRCS= kadmin.c ank.c cpw.c del.c del_enctype.c get.c rename.c util.c \
- ext.c mod.c init.c dump.c load.c random_password.c \
- krb5_err.h heim_err.h hdb_err.h \
- kadm5/private.h kadm5/admin.h kadm5/kadm5_err.h
-CFLAGS+= -I${KRB5DIR}/include \
- -I${KRB5DIR}/lib/roken \
- -I${KRB5DIR}/lib/krb5 \
- -I${KRB5DIR}/lib/asn1 \
- -I${KRB5DIR}/lib/hdb \
- -I${KRB5DIR}/lib/sl \
- -I${KRB5DIR}/kadmin \
- -I${ASN1OBJDIR} \
- -I${HDBOBJDIR} \
- -I${.OBJDIR}
-.if defined(MAKE_KERBEROS4)
-_krb4libs= -lkrb -lkafs
-_krb4deps= ${LIBKRB} ${LIBKAFS}
-.endif
-LDADD= -L${KRB5OBJDIR} -lkrb5 \
- -L${ROKENOBJDIR} -lroken ${_krb4libs} \
- -L${KADM5COBJDIR} -lkadm5clnt -L${KADM5SOBJDIR} -lkadm5srv \
- -L${HDBOBJDIR} -lhdb \
- -L${ASN1OBJDIR} -lasn1 -lcrypto -lcrypt -lmd -lcom_err \
- -L${SLOBJDIR} -lsl -lreadline
-DPADD= ${LIBKRB5} ${LIBKAFS5} ${LIBROKEN} ${_krb4deps} \
- ${LIBKADM5CLNT} ${LIBKADM5SRV} ${LIBHDB} \
- ${LIBASN1} ${LIBCRYPTO} ${LIBCRYPT} ${LIBMD} ${LIBCOM_ERR} \
- ${LIBSL} ${LIBREADLINE}
-NOMAN= yes
-
-.include <bsd.prog.mk>
-
-.PATH: ${KRB5DIR}/kadmin
-
-kadm5/private.h: kadm5
- cp ${KRB5DIR}/lib/kadm5/private.h ${.TARGET}
-
-kadm5/admin.h: kadm5
- cp ${KRB5DIR}/lib/kadm5/admin.h ${.TARGET}
-
-kadm5/kadm5_err.h: kadm5 kadm5_err.h
- cd ${.OBJDIR}/kadm5 && ln -sf ../kadm5_err.h
-
-kadm5:
- mkdir ${.TARGET}
-
-CLEANFILES+= kadm5/private.h kadm5/admin.h kadm5/kadm5_err.h
-CLEANDIRS+= kadm5
diff --git a/kerberos5/usr.bin/kdestroy/Makefile b/kerberos5/usr.bin/kdestroy/Makefile
deleted file mode 100644
index d8d9f3fdd912..000000000000
--- a/kerberos5/usr.bin/kdestroy/Makefile
+++ /dev/null
@@ -1,27 +0,0 @@
-# $FreeBSD$
-
-PROG= k5destroy
-SRCS= kdestroy.c krb5_err.h heim_err.h
-CFLAGS+= -I${KRB5DIR}/include \
- -I${KRB5DIR}/lib/roken \
- -I${KRB5DIR}/lib/krb5 \
- -I${KRB5DIR}/lib/asn1 \
- -I${KRB5DIR}/kuser \
- -I${ASN1OBJDIR} \
- -I${.OBJDIR}
-.if defined(MAKE_KERBEROS4)
-_krb4libs= -lkrb -lkafs
-_krb4deps= ${LIBKRB} ${LIBKAFS}
-.endif
-LDADD= -L${KRB5OBJDIR} -lkrb5 \
- -L${ROKENOBJDIR} -lroken ${_krb4libs} \
- -L${ASN1OBJDIR} -lasn1 -lcrypto -lmd -lcrypt -lcom_err
-DPADD= ${LIBKRB5} ${LIBKAFS5} ${LIBROKEN} ${_krb4deps} \
- ${LIBASN1} ${LIBCRYPTO} ${LIBMD} ${LIBCRYPT} ${LIBCOM_ERR}
-
-.include <bsd.prog.mk>
-
-.PATH: ${KRB5DIR}/kuser
-
-k5destroy.1: kdestroy.1
- ln -sf ${.OODATE} ${.TARGET}
diff --git a/kerberos5/usr.bin/kinit/Makefile b/kerberos5/usr.bin/kinit/Makefile
deleted file mode 100644
index 4c5b4705771b..000000000000
--- a/kerberos5/usr.bin/kinit/Makefile
+++ /dev/null
@@ -1,27 +0,0 @@
-# $FreeBSD$
-
-PROG= k5init
-SRCS= kinit.c kinit_options.c asn1_err.h krb5_err.h heim_err.h
-CFLAGS+= -I${KRB5DIR}/include \
- -I${KRB5DIR}/lib/roken \
- -I${KRB5DIR}/lib/krb5 \
- -I${KRB5DIR}/lib/asn1 \
- -I${KRB5DIR}/kuser \
- -I${ASN1OBJDIR} \
- -I${.OBJDIR}
-.if defined(MAKE_KERBEROS4)
-_krb4libs= -L${KAFS5OBJDIR} -lkafs5 -lkrb -lkafs
-_krb4deps= ${LIBKAFS5} ${LIBKRB} ${LIBKAFS}
-.endif
-LDADD= -L${KRB5OBJDIR} -lkrb5 \
- -L${ROKENOBJDIR} -lroken ${_krb4libs} \
- -L${ASN1OBJDIR} -lasn1 -lcrypto -lmd -lcrypt -lcom_err
-DPADD= ${LIBKRB5} ${LIBKAFS5} ${LIBROKEN} ${_krb4deps} \
- ${LIBASN1} ${LIBCRYPTO} ${LIBMD} ${LIBCRYPT} ${LIBCOM_ERR}
-
-.include <bsd.prog.mk>
-
-.PATH: ${KRB5DIR}/kuser
-
-k5init.1: kinit.1
- ln -sf ${.OODATE} ${.TARGET}
diff --git a/kerberos5/usr.bin/klist/Makefile b/kerberos5/usr.bin/klist/Makefile
deleted file mode 100644
index 6e2f0c19ce46..000000000000
--- a/kerberos5/usr.bin/klist/Makefile
+++ /dev/null
@@ -1,27 +0,0 @@
-# $FreeBSD$
-
-PROG= k5list
-SRCS= klist.c krb5_err.h heim_err.h
-CFLAGS+= -I${KRB5DIR}/include \
- -I${KRB5DIR}/lib/roken \
- -I${KRB5DIR}/lib/krb5 \
- -I${KRB5DIR}/lib/asn1 \
- -I${KRB5DIR}/kuser \
- -I${ASN1OBJDIR} \
- -I${.OBJDIR}
-.if defined(MAKE_KERBEROS4)
-_krb4libs= -lkrb -lkafs
-_krb4deps= ${LIBKRB} ${LIBKAFS}
-.endif
-LDADD= -L${KRB5OBJDIR} -lkrb5 \
- -L${ROKENOBJDIR} -lroken ${_krb4libs} \
- -L${ASN1OBJDIR} -lasn1 -lcrypto -lmd -lcrypt -lcom_err
-DPADD= ${LIBKRB5} ${LIBKAFS5} ${LIBROKEN} ${_krb4deps} \
- ${LIBASN1} ${LIBCRYPTO} ${LIBMD} ${LIBCRYPT} ${LIBCOM_ERR}
-
-.include <bsd.prog.mk>
-
-.PATH: ${KRB5DIR}/kuser
-
-k5list.1: klist.1
- ln -sf ${.OODATE} ${.TARGET}
diff --git a/kerberos5/usr.bin/kpasswd/Makefile b/kerberos5/usr.bin/kpasswd/Makefile
deleted file mode 100644
index be2b77d19015..000000000000
--- a/kerberos5/usr.bin/kpasswd/Makefile
+++ /dev/null
@@ -1,26 +0,0 @@
-# $FreeBSD$
-
-PROG= k5passwd
-SRCS= kpasswd.c krb5_err.h heim_err.h
-CFLAGS+= -I${KRB5DIR}/include \
- -I${KRB5DIR}/lib/asn1 \
- -I${KRB5DIR}/lib/krb5 \
- -I${KRB5DIR}/lib/roken \
- -I${KRB5DIR}/kpasswd \
- -I${ASN1OBJDIR} \
- -I${.OBJDIR}
-.if defined(MAKE_KERBEROS4)
-_krb4libs= -lkrb -lkafs
-_krb4deps= ${LIBKRB} ${LIBKAFS}
-.endif
-LDADD= -L${KRB5OBJDIR} -lkrb5 -L${ROKENOBJDIR} -lroken ${_krb4libs} \
- -L${ASN1OBJDIR} -lasn1 -lcrypto -lmd -lcrypt -lcom_err
-DPADD= ${LIBKRB5} ${LIBROKEN} ${_krb4deps} \
- ${LIBASN1} ${LIBCRYPTO} ${LIBMD} ${LIBCRYPT} ${LIBCOM_ERR}
-
-.include <bsd.prog.mk>
-
-.PATH: ${KRB5DIR}/kpasswd
-
-k5passwd.1: kpasswd.1
- ln -sf ${.OODATE} ${.TARGET}
diff --git a/kerberos5/usr.bin/telnet/Makefile b/kerberos5/usr.bin/telnet/Makefile
deleted file mode 100644
index e3c97f580995..000000000000
--- a/kerberos5/usr.bin/telnet/Makefile
+++ /dev/null
@@ -1,19 +0,0 @@
-# $FreeBSD$
-
-PROG= telnet
-
-CFLAGS+= -DKLUDGELINEMODE -DUSE_TERMIO -DENV_HACK -DSKEY \
- -DENCRYPTION -DAUTHENTICATION -DKRB4 \
- -I${TELNETDIR} -DIPSEC -DINET6
-
-SRCS= authenc.c commands.c main.c network.c ring.c sys_bsd.c \
- telnet.c terminal.c tn3270.c utilities.c
-
-DPADD= ${LIBTERMCAP} ${LIBTELNET} ${LIBCRYPTO} ${LIBKRB} ${LIBCRYPT} \
- ${LIBCOM_ERR} ${LIBIPSEC}
-LDADD= -ltermcap -L${TELNETOBJDIR} -ltelnet -lcrypto \
- -L${KRBOBJDIR} -lkrb -lcrypt -lcom_err -lmp -lipsec
-
-.include <bsd.prog.mk>
-
-.PATH: ${TELNETDIR}/telnet
diff --git a/kerberos5/usr.sbin/kstash/Makefile b/kerberos5/usr.sbin/kstash/Makefile
deleted file mode 100644
index f5d5a67f3b3c..000000000000
--- a/kerberos5/usr.sbin/kstash/Makefile
+++ /dev/null
@@ -1,27 +0,0 @@
-# $FreeBSD$
-
-PROG= k5stash
-SRCS= kstash.c hdb_err.h
-CFLAGS+= -I${KRB5DIR}/include \
- -I${KRB5DIR}/lib/roken \
- -I${KRB5DIR}/lib/krb5 \
- -I${KRB5DIR}/lib/asn1 \
- -I${KRB5DIR}/lib/hdb \
- -I${KRB5DIR}/kdc \
- -I${ASN1OBJDIR} \
- -I${HDBOBJDIR} \
- -I${.OBJDIR}
-.if defined(MAKE_KERBEROS4)
-_krb4libs= -lkrb -lkafs
-_krb4deps= ${LIBKRB} ${LIBKAFS}
-.endif
-LDADD= -L${KRB5OBJDIR} -lkrb5 \
- -L${ROKENOBJDIR} -lroken ${_krb4libs} \
- -L${ASN1OBJDIR} -lasn1 -lcrypto -lmd -lcrypt -lcom_err
-DPADD= ${LIBKRB5} ${LIBKAFS5} ${LIBROKEN} ${_krb4deps} \
- ${LIBASN1} ${LIBCRYPTO} ${LIBMD} ${LIBCRYPT} ${LIBCOM_ERR}
-MAN8= kstash.8
-
-.include <bsd.prog.mk>
-
-.PATH: ${KRB5DIR}/kdc
diff --git a/lib/csu/amd64/Makefile b/lib/csu/amd64/Makefile
deleted file mode 100644
index 50686fe05bd9..000000000000
--- a/lib/csu/amd64/Makefile
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# $FreeBSD$
-#
-
-SRCS= crt1.c crtbegin.c crtend.c crti.S crtn.S
-OBJS= ${SRCS:N*.h:R:S/$/.o/g}
-OBJS+= gcrt1.o
-SOBJS= crtbegin.So crtend.So
-CFLAGS+= -elf -Wall -fkeep-inline-functions
-LDFLAGS+= -elf
-NOMAN= true
-NOPIC= true
-NOPROFILE= true
-INTERNALLIB= true
-
-all: ${OBJS} ${SOBJS}
-
-gcrt1.o: crt1.c
- ${CC} ${CFLAGS} -DGCRT -c -o gcrt1.o ${.CURDIR}/crt1.c
-
-realinstall:
-.for file in ${OBJS} ${SOBJS}
- ${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
- ${file} ${DESTDIR}${LIBDIR}/${file:S/.So$/S.o/}
-.endfor
-
-.include <bsd.lib.mk>
diff --git a/lib/csu/amd64/crt1.c b/lib/csu/amd64/crt1.c
deleted file mode 100644
index 0ee070227107..000000000000
--- a/lib/csu/amd64/crt1.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/*-
- * Copyright 1996-1998 John D. Polstra.
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef __GNUC__
-#error "GCC is needed to compile this file"
-#endif
-
-#include <stddef.h>
-#include <stdlib.h>
-
-typedef void (*fptr)(void);
-
-extern void _fini(void);
-extern void _init(void);
-extern int main(int, char **, char **);
-
-#ifdef GCRT
-extern void _mcleanup(void);
-extern void monstartup(void *, void *);
-extern int eprol;
-extern int etext;
-#endif
-
-extern int _DYNAMIC;
-#pragma weak _DYNAMIC
-
-#ifdef __i386__
-#define get_rtld_cleanup() \
- ({ fptr __value; \
- __asm__("movl %%edx,%0" : "=rm"(__value)); \
- __value; })
-#else
-#error "This file only supports the i386 architecture"
-#endif
-
-char **environ;
-char *__progname = "";
-
-void
-_start(char *arguments, ...)
-{
- fptr rtld_cleanup;
- int argc;
- char **argv;
- char **env;
-
- rtld_cleanup = get_rtld_cleanup();
- argv = &arguments;
- argc = * (int *) (argv - 1);
- env = argv + argc + 1;
- environ = env;
- if(argc > 0 && argv[0] != NULL) {
- char *s;
- __progname = argv[0];
- for (s = __progname; *s != '\0'; s++)
- if (*s == '/')
- __progname = s + 1;
- }
-
- if(&_DYNAMIC != NULL)
- atexit(rtld_cleanup);
-
-#ifdef GCRT
- atexit(_mcleanup);
-#endif
- atexit(_fini);
-#ifdef GCRT
- monstartup(&eprol, &etext);
-#endif
- _init();
- exit( main(argc, argv, env) );
-}
-
-#ifdef GCRT
-__asm__(".text");
-__asm__("eprol:");
-__asm__(".previous");
-#endif
diff --git a/lib/csu/amd64/crti.S b/lib/csu/amd64/crti.S
deleted file mode 100644
index 0038497e04ba..000000000000
--- a/lib/csu/amd64/crti.S
+++ /dev/null
@@ -1,38 +0,0 @@
-/*-
- * Copyright 1996-1998 John D. Polstra.
- * 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.
- *
- * $FreeBSD$
- */
-
- .section .init,"ax",@progbits
- .align 4
- .globl _init
- .type _init,@function
-_init:
-
- .section .fini,"ax",@progbits
- .align 4
- .globl _fini
- .type _fini,@function
-_fini:
diff --git a/lib/csu/amd64/crtn.S b/lib/csu/amd64/crtn.S
deleted file mode 100644
index 0944ee36761d..000000000000
--- a/lib/csu/amd64/crtn.S
+++ /dev/null
@@ -1,32 +0,0 @@
-/*-
- * Copyright 1996-1998 John D. Polstra.
- * 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.
- *
- * $FreeBSD$
- */
-
- .section .init,"ax",@progbits
- ret
-
- .section .fini,"ax",@progbits
- ret
diff --git a/lib/csu/common/crtbegin.c b/lib/csu/common/crtbegin.c
deleted file mode 100644
index 7c1f11e4a010..000000000000
--- a/lib/csu/common/crtbegin.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*-
- * Copyright 1996-1998 John D. Polstra.
- * 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/cdefs.h>
-
-typedef void (*fptr)(void);
-
-static fptr ctor_list[1] __attribute__((section(".ctors"))) = { (fptr) -1 };
-static fptr dtor_list[1] __attribute__((section(".dtors"))) = { (fptr) -1 };
-
-static void do_ctors(void) __unused;
-static void do_dtors(void) __unused;
-
-static void
-do_ctors(void)
-{
- fptr *fpp;
-
- for(fpp = ctor_list + 1; *fpp != 0; ++fpp)
- ;
- while(--fpp > ctor_list)
- (**fpp)();
-}
-
-static void
-do_dtors(void)
-{
- fptr *fpp;
-
- for(fpp = dtor_list + 1; *fpp != 0; ++fpp)
- (**fpp)();
-}
-
-__asm__(".section .init,\"ax\",@progbits; call do_ctors; .previous");
-__asm__(".section .fini,\"ax\",@progbits; call do_dtors; .previous");
diff --git a/lib/libc/amd64/SYS.h b/lib/libc/amd64/SYS.h
deleted file mode 100644
index 155672f6bb82..000000000000
--- a/lib/libc/amd64/SYS.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)SYS.h 5.5 (Berkeley) 5/7/91
- *
- * $FreeBSD$
- */
-
-#include <sys/syscall.h>
-#include "DEFS.h"
-
-#define SYSCALL(x) 2: PIC_PROLOGUE; jmp PIC_PLT(HIDENAME(cerror)); \
- ENTRY(__CONCAT(_,x)); \
- .weak CNAME(x); \
- .set CNAME(x),CNAME(__CONCAT(_,x)); \
- lea __CONCAT(SYS_,x),%eax; KERNCALL; jb 2b
-
-#define RSYSCALL(x) SYSCALL(x); ret
-
-#define PSEUDO(x,y) ENTRY(__CONCAT(_,x)); \
- .weak CNAME(x); \
- .set CNAME(x),CNAME(__CONCAT(_,x)); \
- lea __CONCAT(SYS_,y), %eax; KERNCALL; ret
-
-/* gas messes up offset -- although we don't currently need it, do for BCS */
-#define LCALL(x,y) .byte 0x9a ; .long y; .word x
-
-/*
- * Design note:
- *
- * The macros PSYSCALL() and PRSYSCALL() are intended for use where a
- * syscall needs to be renamed in the threaded library. When building
- * a normal library, they default to the traditional SYSCALL() and
- * RSYSCALL(). This avoids the need to #ifdef _THREAD_SAFE everywhere
- * that the renamed function needs to be called.
- */
-#ifdef _THREAD_SAFE
-/*
- * For the thread_safe versions, we prepend _thread_sys_ to the function
- * name so that the 'C' wrapper can go around the real name.
- */
-#define PSYSCALL(x) 2: PIC_PROLOGUE; jmp PIC_PLT(HIDENAME(cerror)); \
- ENTRY(__CONCAT(_thread_sys_,x)); \
- .weak CNAME(__CONCAT(_,x)); \
- .set CNAME(__CONCAT(_,x)),CNAME(__CONCAT(_thread_sys_,x));\
- .weak CNAME(x); \
- .set CNAME(x),CNAME(__CONCAT(_,x)); \
- lea __CONCAT(SYS_,x),%eax; KERNCALL; jb 2b
-#define PRSYSCALL(x) PSYSCALL(x); ret
-#define PPSEUDO(x,y) ENTRY(__CONCAT(_thread_sys_,x)); \
- lea __CONCAT(SYS_,y), %eax; KERNCALL; ret
-#else
-/*
- * The non-threaded library defaults to traditional syscalls where
- * the function name matches the syscall name.
- */
-#define PSYSCALL(x) SYSCALL(x)
-#define PRSYSCALL(x) RSYSCALL(x)
-#define PPSEUDO(x,y) PSEUDO(x,y)
-#endif
-
-#ifdef __ELF__
-#define KERNCALL int $0x80 /* Faster */
-#else
-#define KERNCALL LCALL(7,0) /* The old way */
-#endif
diff --git a/lib/libc/amd64/gen/Makefile.inc b/lib/libc/amd64/gen/Makefile.inc
deleted file mode 100644
index f2506fdc6ae4..000000000000
--- a/lib/libc/amd64/gen/Makefile.inc
+++ /dev/null
@@ -1,5 +0,0 @@
-# @(#)Makefile.inc 8.1 (Berkeley) 6/4/93
-# $FreeBSD$
-
-SRCS+= _setjmp.S alloca.S fabs.S frexp.c infinity.c isinf.c ldexp.c modf.S \
- setjmp.S sigsetjmp.S
diff --git a/lib/libc/amd64/gen/_setjmp.S b/lib/libc/amd64/gen/_setjmp.S
deleted file mode 100644
index 9c66308dc502..000000000000
--- a/lib/libc/amd64/gen/_setjmp.S
+++ /dev/null
@@ -1,89 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- */
-
-#if defined(LIBC_RCS) && !defined(lint)
- .text
- .asciz "$FreeBSD$"
-#endif /* LIBC_RCS and not lint */
-
-/*
- * C library -- _setjmp, _longjmp
- *
- * _longjmp(a,v)
- * will generate a "return(v)" from the last call to
- * _setjmp(a)
- * by restoring registers from the environment 'a'.
- * The previous signal state is NOT restored.
- */
-
-#include "DEFS.h"
-
-ENTRY(_setjmp)
- movl 4(%esp),%eax
- movl 0(%esp),%edx
- movl %edx, 0(%eax) /* rta */
- movl %ebx, 4(%eax)
- movl %esp, 8(%eax)
- movl %ebp,12(%eax)
- movl %esi,16(%eax)
- movl %edi,20(%eax)
- fnstcw 24(%eax)
- xorl %eax,%eax
- ret
-
-#ifdef _THREAD_SAFE
-ENTRY(___longjmp)
-#else
-ALTENTRY(___longjmp)
-ENTRY(_longjmp)
-#endif
- movl 4(%esp),%edx
- movl 8(%esp),%eax
- movl 0(%edx),%ecx
- movl 4(%edx),%ebx
- movl 8(%edx),%esp
- movl 12(%edx),%ebp
- movl 16(%edx),%esi
- movl 20(%edx),%edi
- fninit
- fldcw 24(%edx)
- testl %eax,%eax
- jnz 1f
- incl %eax
-1: movl %ecx,0(%esp)
- ret
diff --git a/lib/libc/amd64/gen/frexp.c b/lib/libc/amd64/gen/frexp.c
deleted file mode 100644
index 4834f1788095..000000000000
--- a/lib/libc/amd64/gen/frexp.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/*-
- * Copyright (c) 1991, 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- */
-
-#if defined(LIBC_RCS) && !defined(lint)
-static const char rcsid[] = "$FreeBSD$";
-#endif /* LIBC_RCS and not lint */
-
-#include <sys/types.h>
-#include <math.h>
-
-double
-frexp(value, eptr)
- double value;
- int *eptr;
-{
- union {
- double v;
- struct {
- u_int u_mant2 : 32;
- u_int u_mant1 : 20;
- u_int u_exp : 11;
- u_int u_sign : 1;
- } s;
- } u;
-
- if (value) {
- u.v = value;
- *eptr = u.s.u_exp - 1022;
- u.s.u_exp = 1022;
- return(u.v);
- } else {
- *eptr = 0;
- return((double)0);
- }
-}
diff --git a/lib/libc/amd64/gen/infinity.c b/lib/libc/amd64/gen/infinity.c
deleted file mode 100644
index ac92d46e7ea9..000000000000
--- a/lib/libc/amd64/gen/infinity.c
+++ /dev/null
@@ -1,9 +0,0 @@
-/*
- * infinity.c
- * $FreeBSD$
- */
-
-#include <math.h>
-
-/* bytes for +Infinity on a 387 */
-char __infinity[] = { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f };
diff --git a/lib/libc/amd64/gen/isinf.c b/lib/libc/amd64/gen/isinf.c
deleted file mode 100644
index b2b63a8f7274..000000000000
--- a/lib/libc/amd64/gen/isinf.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/*-
- * Copyright (c) 1991, 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- */
-
-#if defined(LIBC_RCS) && !defined(lint)
-static const char rcsid[] = "$FreeBSD$";
-#endif /* LIBC_RCS and not lint */
-
-#include <sys/types.h>
-
-int
-isnan(d)
- double d;
-{
- register struct IEEEdp {
- u_int manl : 32;
- u_int manh : 20;
- u_int exp : 11;
- u_int sign : 1;
- } *p = (struct IEEEdp *)&d;
-
- return(p->exp == 2047 && (p->manh || p->manl));
-}
-
-int
-isinf(d)
- double d;
-{
- register struct IEEEdp {
- u_int manl : 32;
- u_int manh : 20;
- u_int exp : 11;
- u_int sign : 1;
- } *p = (struct IEEEdp *)&d;
-
- return(p->exp == 2047 && !p->manh && !p->manl);
-}
diff --git a/lib/libc/amd64/gen/ldexp.c b/lib/libc/amd64/gen/ldexp.c
deleted file mode 100644
index e7e58f05b2e0..000000000000
--- a/lib/libc/amd64/gen/ldexp.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Sean Eric Fagan.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- */
-
-#if defined(LIBC_RCS) && !defined(lint)
-static const char rcsid[] = "$FreeBSD$";
-#endif /* LIBC_RCS and not lint */
-
-/*
- * ldexp(value, exp): return value * (2 ** exp).
- *
- * Written by Sean Eric Fagan (sef@kithrup.COM)
- * Sun Mar 11 20:27:09 PST 1990
- */
-
-/*
- * We do the conversion in C to let gcc optimize it away, if possible.
- * The "fxch ; fstp" stuff is because value is still on the stack
- * (stupid 8087!).
- */
-double
-ldexp (double value, int exp)
-{
- double temp, texp, temp2;
- texp = exp;
-#ifdef __GNUC__
-#if __GNUC__ >= 2
- asm ("fscale "
- : "=u" (temp2), "=t" (temp)
- : "0" (texp), "1" (value));
-#else
- asm ("fscale ; fxch %%st(1) ; fstp%L1 %1 "
- : "=f" (temp), "=0" (temp2)
- : "0" (texp), "f" (value));
-#endif
-#else
-error unknown asm
-#endif
- return (temp);
-}
diff --git a/lib/libc/amd64/gen/setjmp.S b/lib/libc/amd64/gen/setjmp.S
deleted file mode 100644
index 39e9c2165ec1..000000000000
--- a/lib/libc/amd64/gen/setjmp.S
+++ /dev/null
@@ -1,116 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- */
-
-#if defined(LIBC_RCS) && !defined(lint)
- .text
- .asciz "$FreeBSD$"
-#endif /* LIBC_RCS and not lint */
-
-/*
- * C library -- _setjmp, _longjmp
- *
- * longjmp(a,v)
- * will generate a "return(v)" from the last call to
- * setjmp(a)
- * by restoring registers from the environment 'a'.
- * The previous signal state is restored.
- */
-
-#include "DEFS.h"
-#include "SYS.h"
-
-ENTRY(setjmp)
- movl 4(%esp),%ecx
- PIC_PROLOGUE
- leal 28(%ecx), %eax
- pushl %eax /* (sigset_t*)oset */
- pushl $0 /* (sigset_t*)set */
- pushl $1 /* SIG_BLOCK */
-#ifdef _THREAD_SAFE
- call PIC_PLT(CNAME(_thread_sys_sigprocmask))
-#else
- call PIC_PLT(CNAME(sigprocmask))
-#endif
- addl $12,%esp
- PIC_EPILOGUE
- movl 4(%esp),%ecx
- movl 0(%esp),%edx
- movl %edx, 0(%ecx)
- movl %ebx, 4(%ecx)
- movl %esp, 8(%ecx)
- movl %ebp,12(%ecx)
- movl %esi,16(%ecx)
- movl %edi,20(%ecx)
- fnstcw 24(%ecx)
- xorl %eax,%eax
- ret
-
-#ifdef _THREAD_SAFE
-ENTRY(__longjmp)
-#else
-ALTENTRY(__longjmp)
-ENTRY(longjmp)
-#endif
- movl 4(%esp),%edx
- PIC_PROLOGUE
- pushl $0 /* (sigset_t*)oset */
- leal 28(%edx), %eax
- pushl %eax /* (sigset_t*)set */
- pushl $3 /* SIG_SETMASK */
-#ifdef _THREAD_SAFE
- call PIC_PLT(CNAME(_thread_sys_sigprocmask))
-#else
- call PIC_PLT(CNAME(sigprocmask))
-#endif
- addl $12,%esp
- PIC_EPILOGUE
- movl 4(%esp),%edx
- movl 8(%esp),%eax
- movl 0(%edx),%ecx
- movl 4(%edx),%ebx
- movl 8(%edx),%esp
- movl 12(%edx),%ebp
- movl 16(%edx),%esi
- movl 20(%edx),%edi
- fninit
- fldcw 24(%edx)
- testl %eax,%eax
- jnz 1f
- incl %eax
-1: movl %ecx,0(%esp)
- ret
diff --git a/lib/libc/amd64/gen/sigsetjmp.S b/lib/libc/amd64/gen/sigsetjmp.S
deleted file mode 100644
index 13c0dc7246c1..000000000000
--- a/lib/libc/amd64/gen/sigsetjmp.S
+++ /dev/null
@@ -1,127 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- */
-
-#if defined(LIBC_RCS) && !defined(lint)
- .text
- .asciz "$FreeBSD$"
-#endif /* LIBC_RCS and not lint */
-
-#include "DEFS.h"
-#include "SYS.h"
-
-/*-
- * TODO:
- * Rename sigsetjmp to __sigsetjmp and siglongjmp to __siglongjmp,
- * remove the other *jmp functions and define everything in terms
- * of the renamed functions. This requires compiler support for
- * the renamed functions (introduced in gcc-2.5.3; previous versions
- * only supported *jmp with 0 or 1 leading underscores).
- *
- * Use sigprocmask() instead of sigblock() and sigsetmask(), and
- * check for and handle errors.
- *
- * Restore _all_ the registers and the signal mask atomically. Can
- * use sigreturn() if sigreturn() works.
- */
-
-ENTRY(sigsetjmp)
- movl 8(%esp),%eax
- movl 4(%esp),%ecx
- movl %eax,44(%ecx)
- testl %eax,%eax
- jz 2f
- PIC_PROLOGUE
- leal 28(%ecx), %eax
- pushl %eax /* (sigset_t*)oset */
- pushl $0 /* (sigset_t*)set */
- pushl $1 /* SIG_BLOCK */
-#ifdef _THREAD_SAFE
- call PIC_PLT(CNAME(_thread_sys_sigprocmask))
-#else
- call PIC_PLT(CNAME(sigprocmask))
-#endif
- addl $12,%esp
- PIC_EPILOGUE
- movl 4(%esp),%ecx
-2: movl 0(%esp),%edx
- movl %edx, 0(%ecx)
- movl %ebx, 4(%ecx)
- movl %esp, 8(%ecx)
- movl %ebp,12(%ecx)
- movl %esi,16(%ecx)
- movl %edi,20(%ecx)
- fnstcw 24(%ecx)
- xorl %eax,%eax
- ret
-
-#ifdef _THREAD_SAFE
-ENTRY(__siglongjmp)
-#else
-ALTENTRY(__siglongjmp)
-ENTRY(siglongjmp)
-#endif
- movl 4(%esp),%edx
- cmpl $0,44(%edx)
- jz 2f
- PIC_PROLOGUE
- pushl $0 /* (sigset_t*)oset */
- leal 28(%edx), %eax
- pushl %eax /* (sigset_t*)set */
- pushl $3 /* SIG_SETMASK */
-#ifdef _THREAD_SAFE
- call PIC_PLT(CNAME(_thread_sys_sigprocmask))
-#else
- call PIC_PLT(CNAME(sigprocmask))
-#endif
- addl $12,%esp
- PIC_EPILOGUE
- movl 4(%esp),%edx
-2: movl 8(%esp),%eax
- movl 0(%edx),%ecx
- movl 4(%edx),%ebx
- movl 8(%edx),%esp
- movl 12(%edx),%ebp
- movl 16(%edx),%esi
- movl 20(%edx),%edi
- fninit
- fldcw 24(%edx)
- testl %eax,%eax
- jnz 1f
- incl %eax
-1: movl %ecx,0(%esp)
- ret
diff --git a/lib/libc/amd64/net/Makefile.inc b/lib/libc/amd64/net/Makefile.inc
deleted file mode 100644
index 96e559bf8027..000000000000
--- a/lib/libc/amd64/net/Makefile.inc
+++ /dev/null
@@ -1,4 +0,0 @@
-# @(#)Makefile.inc 8.1 (Berkeley) 6/4/93
-# $FreeBSD$
-
-SRCS+= htonl.S htons.S ntohl.S ntohs.S
diff --git a/lib/libc/amd64/net/htonl.S b/lib/libc/amd64/net/htonl.S
deleted file mode 100644
index 48f1ca8adcf9..000000000000
--- a/lib/libc/amd64/net/htonl.S
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- */
-
-#if defined(LIBC_RCS) && !defined(lint)
- .text
- .asciz "$FreeBSD$"
-#endif /* LIBC_RCS and not lint */
-
-/* netorder = htonl(hostorder) */
-
-#include "DEFS.h"
-
-ENTRY(htonl)
- movl 4(%esp),%eax
- xchgb %al,%ah
- roll $16,%eax
- xchgb %al,%ah
- ret
diff --git a/lib/libc/amd64/net/htons.S b/lib/libc/amd64/net/htons.S
deleted file mode 100644
index 68f2b5a0131e..000000000000
--- a/lib/libc/amd64/net/htons.S
+++ /dev/null
@@ -1,51 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- */
-
-#if defined(LIBC_RCS) && !defined(lint)
- .text
- .asciz "$FreeBSD$"
-#endif /* LIBC_RCS and not lint */
-
-/* netorder = htons(hostorder) */
-
-#include "DEFS.h"
-
-ENTRY(htons)
- movzwl 4(%esp),%eax
- xchgb %al,%ah
- ret
diff --git a/lib/libc/amd64/net/ntohl.S b/lib/libc/amd64/net/ntohl.S
deleted file mode 100644
index 7be9deebe26c..000000000000
--- a/lib/libc/amd64/net/ntohl.S
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- */
-
-#if defined(LIBC_RCS) && !defined(lint)
- .text
- .asciz "$FreeBSD$"
-#endif /* LIBC_RCS and not lint */
-
-/* hostorder = ntohl(netorder) */
-
-#include "DEFS.h"
-
-ENTRY(ntohl)
- movl 4(%esp),%eax
- xchgb %al,%ah
- roll $16,%eax
- xchgb %al,%ah
- ret
diff --git a/lib/libc/amd64/net/ntohs.S b/lib/libc/amd64/net/ntohs.S
deleted file mode 100644
index 0f1d2280ce70..000000000000
--- a/lib/libc/amd64/net/ntohs.S
+++ /dev/null
@@ -1,51 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- */
-
-#if defined(LIBC_RCS) && !defined(lint)
- .text
- .asciz "$FreeBSD$"
-#endif /* LIBC_RCS and not lint */
-
-/* hostorder = ntohs(netorder) */
-
-#include "DEFS.h"
-
-ENTRY(ntohs)
- movzwl 4(%esp),%eax
- xchgb %al,%ah
- ret
diff --git a/lib/libc/amd64/sys/Makefile.inc b/lib/libc/amd64/sys/Makefile.inc
deleted file mode 100644
index c1c3d2d0e715..000000000000
--- a/lib/libc/amd64/sys/Makefile.inc
+++ /dev/null
@@ -1,28 +0,0 @@
-# from: Makefile.inc,v 1.1 1993/09/03 19:04:23 jtc Exp
-# $FreeBSD$
-
-SRCS+= i386_get_ioperm.c i386_get_ldt.c i386_set_ioperm.c i386_set_ldt.c \
- i386_vm86.c
-
-MDASM= Ovfork.S brk.S cerror.S exect.S fork.S pipe.S ptrace.S reboot.S \
- rfork.S sbrk.S setlogin.S sigreturn.S syscall.S
-
-# Don't generate default code for these syscalls:
-NOASM= __semctl.o break.o exit.o ftruncate.o getdomainname.o getlogin.o \
- lseek.o mlockall.o mmap.o msgctl.o msgget.o msgrcv.o msgsnd.o \
- munlockall.o openbsd_poll.o pread.o pwrite.o semconfig.o semget.o \
- semop.o setdomainname.o shmat.o shmctl.o shmdt.o shmget.o sstk.o \
- thr_sleep.o thr_wakeup.o truncate.o uname.o vfork.o yield.o
-
-PSEUDO= _getlogin.o
-
-# Pseudo syscalls that are renamed as _thread_sys_{pseudo} when
-# building libc_r.
-PSEUDOR= _exit.o
-
-.if ${LIB} == "c"
-MAN2+= i386_get_ioperm.2 i386_get_ldt.2 i386_vm86.2
-
-MLINKS+=i386_get_ioperm.2 i386_set_ioperm.2
-MLINKS+=i386_get_ldt.2 i386_set_ldt.2
-.endif
diff --git a/lib/libc/amd64/sys/brk.S b/lib/libc/amd64/sys/brk.S
deleted file mode 100644
index 57266750efd3..000000000000
--- a/lib/libc/amd64/sys/brk.S
+++ /dev/null
@@ -1,91 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- */
-
-#if defined(SYSLIBC_RCS) && !defined(lint)
- .text
- .asciz "$FreeBSD$"
-#endif /* SYSLIBC_RCS and not lint */
-
-#include "SYS.h"
-
- .globl HIDENAME(curbrk)
- .globl HIDENAME(minbrk)
-ENTRY(_brk)
- jmp ok
-
-ENTRY(brk)
-#ifdef PIC
- movl 4(%esp),%eax
- PIC_PROLOGUE
- movl PIC_GOT(HIDENAME(curbrk)),%edx # set up GOT addressing
- movl PIC_GOT(HIDENAME(minbrk)),%ecx #
- PIC_EPILOGUE
- cmpl %eax,(%ecx)
- jbe ok
- movl (%ecx),%eax
- movl %eax,4(%esp)
-ok:
- lea SYS_break,%eax
- KERNCALL
- jb err
- movl 4(%esp),%eax
- movl %eax,(%edx)
- movl $0,%eax
- ret
-err:
- PIC_PROLOGUE
- jmp PIC_PLT(HIDENAME(cerror))
-
-#else
-
- movl 4(%esp),%eax
- cmpl %eax,HIDENAME(minbrk)
- jbe ok
- movl HIDENAME(minbrk),%eax
- movl %eax,4(%esp)
-ok:
- lea SYS_break,%eax
- KERNCALL
- jb err
- movl 4(%esp),%eax
- movl %eax,HIDENAME(curbrk)
- movl $0,%eax
- ret
-err:
- jmp HIDENAME(cerror)
-#endif
diff --git a/lib/libc/amd64/sys/cerror.S b/lib/libc/amd64/sys/cerror.S
deleted file mode 100644
index 31c3622bd200..000000000000
--- a/lib/libc/amd64/sys/cerror.S
+++ /dev/null
@@ -1,70 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- */
-
-#if defined(SYSLIBC_RCS) && !defined(lint)
- .text
- .asciz "$FreeBSD$"
-#endif /* SYSLIBC_RCS and not lint */
-
-#include "SYS.h"
-
- .globl HIDENAME(cerror)
-
- /*
- * The __error() function is thread aware. For non-threaded
- * programs and the initial threaded in threaded programs,
- * it returns a pointer to the global errno variable.
- */
- .globl CNAME(__error)
- .type CNAME(__error),@function
-HIDENAME(cerror):
- pushl %eax
-#ifdef PIC
- /* The caller must execute the PIC prologue before jumping to cerror. */
- call PIC_PLT(CNAME(__error))
- popl %ecx
- PIC_EPILOGUE
-#else
- call CNAME(__error)
- popl %ecx
-#endif
- movl %ecx,(%eax)
- movl $-1,%eax
- movl $-1,%edx
- ret
-
diff --git a/lib/libc/amd64/sys/exect.S b/lib/libc/amd64/sys/exect.S
deleted file mode 100644
index 9f90060fe156..000000000000
--- a/lib/libc/amd64/sys/exect.S
+++ /dev/null
@@ -1,56 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- */
-
-#if defined(SYSLIBC_RCS) && !defined(lint)
- .text
- .asciz "$FreeBSD$"
-#endif /* SYSLIBC_RCS and not lint */
-
-#include "SYS.h"
-#include <machine/psl.h>
-
-ENTRY(exect)
- lea SYS_execve,%eax
- pushf
- popl %edx
- orl $ PSL_T,%edx
- pushl %edx
- popf
- KERNCALL
- PIC_PROLOGUE
- jmp PIC_PLT(HIDENAME(cerror)) /* exect(file, argv, env); */
diff --git a/lib/libc/amd64/sys/pipe.S b/lib/libc/amd64/sys/pipe.S
deleted file mode 100644
index 1684611f766f..000000000000
--- a/lib/libc/amd64/sys/pipe.S
+++ /dev/null
@@ -1,51 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- */
-
-#if defined(SYSLIBC_RCS) && !defined(lint)
- .text
- .asciz "$FreeBSD$"
-#endif /* SYSLIBC_RCS and not lint */
-
-#include "SYS.h"
-
-PSYSCALL(pipe)
- movl 4(%esp),%ecx
- movl %eax,(%ecx)
- movl %edx,4(%ecx)
- movl $0,%eax
- ret
diff --git a/lib/libc/amd64/sys/ptrace.S b/lib/libc/amd64/sys/ptrace.S
deleted file mode 100644
index 7f5e149d33e7..000000000000
--- a/lib/libc/amd64/sys/ptrace.S
+++ /dev/null
@@ -1,62 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- */
-
-#if defined(SYSLIBC_RCS) && !defined(lint)
- .text
- .asciz "$FreeBSD$"
-#endif /* SYSLIBC_RCS and not lint */
-
-#include "SYS.h"
-
-ENTRY(ptrace)
- xorl %eax,%eax
-#ifdef PIC
- PIC_PROLOGUE
- movl PIC_GOT(CNAME(errno)),%edx
- movl %eax,(%edx)
- PIC_EPILOGUE
-#else
- movl %eax,CNAME(errno)
-#endif
- lea SYS_ptrace,%eax
- KERNCALL
- jb err
- ret
-err:
- PIC_PROLOGUE
- jmp PIC_PLT(HIDENAME(cerror))
diff --git a/lib/libc/amd64/sys/reboot.S b/lib/libc/amd64/sys/reboot.S
deleted file mode 100644
index 4e39068fdff4..000000000000
--- a/lib/libc/amd64/sys/reboot.S
+++ /dev/null
@@ -1,47 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- */
-
-#if defined(SYSLIBC_RCS) && !defined(lint)
- .text
- .asciz "$FreeBSD$"
-#endif /* SYSLIBC_RCS and not lint */
-
-#include "SYS.h"
-
-SYSCALL(reboot)
- iret
diff --git a/lib/libc/amd64/sys/sbrk.S b/lib/libc/amd64/sys/sbrk.S
deleted file mode 100644
index f7aae351b00b..000000000000
--- a/lib/libc/amd64/sys/sbrk.S
+++ /dev/null
@@ -1,95 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- */
-
-#if defined(SYSLIBC_RCS) && !defined(lint)
- .text
- .asciz "$FreeBSD$"
-#endif /* SYSLIBC_RCS and not lint */
-
-#include "SYS.h"
-
- .globl CNAME(end)
- .globl HIDENAME(minbrk)
- .globl HIDENAME(curbrk)
-
- .data
-HIDENAME(minbrk): .long CNAME(end)
-HIDENAME(curbrk): .long CNAME(end)
- .text
-
-ENTRY(sbrk)
-#ifdef PIC
- movl 4(%esp),%ecx
- PIC_PROLOGUE
- movl PIC_GOT(HIDENAME(curbrk)),%edx
- movl (%edx),%eax
- PIC_EPILOGUE
- testl %ecx,%ecx
- jz back
- addl %eax,4(%esp)
- lea SYS_break,%eax
- KERNCALL
- jb err
- PIC_PROLOGUE
- movl PIC_GOT(HIDENAME(curbrk)),%edx
- movl (%edx),%eax
- addl %ecx,(%edx)
- PIC_EPILOGUE
-back:
- ret
-err:
- PIC_PROLOGUE
- jmp PIC_PLT(HIDENAME(cerror))
-
-#else /* !PIC */
-
- movl 4(%esp),%ecx
- movl HIDENAME(curbrk),%eax
- testl %ecx,%ecx
- jz back
- addl %eax,4(%esp)
- lea SYS_break,%eax
- KERNCALL
- jb err
- movl HIDENAME(curbrk),%eax
- addl %ecx,HIDENAME(curbrk)
-back:
- ret
-err:
- jmp HIDENAME(cerror)
-#endif /* PIC */
diff --git a/lib/libc/amd64/sys/setlogin.S b/lib/libc/amd64/sys/setlogin.S
deleted file mode 100644
index a4d74b0d10cf..000000000000
--- a/lib/libc/amd64/sys/setlogin.S
+++ /dev/null
@@ -1,59 +0,0 @@
-/*-
- * Copyright (c) 1991 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- */
-
-#if defined(LIBC_RCS) && !defined(lint)
- .text
- .asciz "$FreeBSD$"
-#endif /* LIBC_RCS and not lint */
-
-#include "SYS.h"
-
-.globl CNAME(_logname_valid) /* in getlogin() */
-
-SYSCALL(setlogin)
-#ifdef PIC
- PIC_PROLOGUE
- pushl %eax
- movl PIC_GOT(CNAME(_logname_valid)),%eax
- movl $0,(%eax)
- popl %eax
- PIC_EPILOGUE
-#else
- movl $0,CNAME(_logname_valid)
-#endif
- ret /* setlogin(name) */
diff --git a/lib/libc/amd64/sys/sigreturn.S b/lib/libc/amd64/sys/sigreturn.S
deleted file mode 100644
index 7405c340030e..000000000000
--- a/lib/libc/amd64/sys/sigreturn.S
+++ /dev/null
@@ -1,52 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- */
-
-#if defined(SYSLIBC_RCS) && !defined(lint)
- .text
- .asciz "$FreeBSD$"
-#endif /* SYSLIBC_RCS and not lint */
-
-#include "SYS.h"
-
-/*
- * NOTE: If the profiling ENTRY() code ever changes any registers, they
- * must be saved. On FreeBSD, this is not the case.
- */
-
-PSYSCALL(sigreturn)
- ret
diff --git a/lib/libc/amd64/sys/vfork.S b/lib/libc/amd64/sys/vfork.S
deleted file mode 100644
index 30d7fd1932b7..000000000000
--- a/lib/libc/amd64/sys/vfork.S
+++ /dev/null
@@ -1,72 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- */
-
-#if defined(SYSLIBC_RCS) && !defined(lint)
- .text
- .asciz "$FreeBSD$"
-#endif /* SYSLIBC_RCS and not lint */
-
-#include "DEFS.h"
-#include "SYS.h"
-
-/*
- * pid = vfork();
- *
- * %edx == 0 in parent process, %edx == 1 in child process.
- * %eax == pid of child in parent, %eax == pid of parent in child.
- *
- */
-
-#ifdef _THREAD_SAFE
-ENTRY(_thread_sys_vfork)
-#else
-ENTRY(vfork)
-#endif
- popl %ecx /* my rta into ecx */
- lea SYS_vfork,%eax
- KERNCALL
- jb 2f
- cmpl $0,%edx /* parent process? */
- je 1f /* yes */
- movl $0,%eax
-1:
- jmp %ecx
-2:
- pushl %ecx
- PIC_PROLOGUE
- jmp PIC_PLT(HIDENAME(cerror))
diff --git a/lib/libc/gen/__xuname.c b/lib/libc/gen/__xuname.c
deleted file mode 100644
index 944c2dc3b2ff..000000000000
--- a/lib/libc/gen/__xuname.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/*-
- * Copyright (c) 1994
- * 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. 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, Berkeley and its contributors.
- * 4. 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char sccsid[] = "From: @(#)uname.c 8.1 (Berkeley) 1/4/94";*/
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/param.h>
-#include <sys/sysctl.h>
-#include <sys/utsname.h>
-#include <errno.h>
-
-int
-uname(name)
- struct utsname *name;
-{
- int mib[2], rval;
- size_t len;
- char *p;
- int oerrno;
-
- rval = 0;
-
- mib[0] = CTL_KERN;
- mib[1] = KERN_OSTYPE;
- len = sizeof(name->sysname);
- oerrno = errno;
- if (sysctl(mib, 2, &name->sysname, &len, NULL, 0) == -1) {
- if(errno == ENOMEM)
- errno = oerrno;
- else
- rval = -1;
- }
- name->sysname[sizeof(name->sysname) - 1] = '\0';
-
- mib[0] = CTL_KERN;
- mib[1] = KERN_HOSTNAME;
- len = sizeof(name->nodename);
- oerrno = errno;
- if (sysctl(mib, 2, &name->nodename, &len, NULL, 0) == -1) {
- if(errno == ENOMEM)
- errno = oerrno;
- else
- rval = -1;
- }
- name->nodename[sizeof(name->nodename) - 1] = '\0';
-
- mib[0] = CTL_KERN;
- mib[1] = KERN_OSRELEASE;
- len = sizeof(name->release);
- oerrno = errno;
- if (sysctl(mib, 2, &name->release, &len, NULL, 0) == -1) {
- if(errno == ENOMEM)
- errno = oerrno;
- else
- rval = -1;
- }
- name->release[sizeof(name->release) - 1] = '\0';
-
- /* The version may have newlines in it, turn them into spaces. */
- mib[0] = CTL_KERN;
- mib[1] = KERN_VERSION;
- len = sizeof(name->version);
- oerrno = errno;
- if (sysctl(mib, 2, &name->version, &len, NULL, 0) == -1) {
- if (errno == ENOMEM)
- errno = oerrno;
- else
- rval = -1;
- }
- name->version[sizeof(name->version) - 1] = '\0';
- for (p = name->version; len--; ++p) {
- if (*p == '\n' || *p == '\t') {
- if (len > 1)
- *p = ' ';
- else
- *p = '\0';
- }
- }
-
- mib[0] = CTL_HW;
- mib[1] = HW_MACHINE;
- len = sizeof(name->machine);
- oerrno = errno;
- if (sysctl(mib, 2, &name->machine, &len, NULL, 0) == -1) {
- if (errno == ENOMEM)
- errno = oerrno;
- else
- rval = -1;
- }
- name->machine[sizeof(name->machine) - 1] = '\0';
- return (rval);
-}
diff --git a/lib/libc/gen/fts-compat.c b/lib/libc/gen/fts-compat.c
deleted file mode 100644
index 6b92a120676a..000000000000
--- a/lib/libc/gen/fts-compat.c
+++ /dev/null
@@ -1,1114 +0,0 @@
-/*-
- * Copyright (c) 1990, 1993, 1994
- * 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * $OpenBSD: fts.c,v 1.22 1999/10/03 19:22:22 millert Exp $
- *
- * $FreeBSD$
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-#if 0
-static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94";
-#else
-static char rcsid[] = "$FreeBSD$";
-#endif
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/param.h>
-#include <sys/stat.h>
-
-#include <dirent.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <fts.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-static FTSENT *fts_alloc __P((FTS *, char *, int));
-static FTSENT *fts_build __P((FTS *, int));
-static void fts_lfree __P((FTSENT *));
-static void fts_load __P((FTS *, FTSENT *));
-static size_t fts_maxarglen __P((char * const *));
-static void fts_padjust __P((FTS *, FTSENT *));
-static int fts_palloc __P((FTS *, size_t));
-static FTSENT *fts_sort __P((FTS *, FTSENT *, int));
-static u_short fts_stat __P((FTS *, FTSENT *, int));
-static int fts_safe_changedir __P((FTS *, FTSENT *, int));
-
-#define ISDOT(a) (a[0] == '.' && (!a[1] || (a[1] == '.' && !a[2])))
-
-#define CLR(opt) (sp->fts_options &= ~(opt))
-#define ISSET(opt) (sp->fts_options & (opt))
-#define SET(opt) (sp->fts_options |= (opt))
-
-#define CHDIR(sp, path) (!ISSET(FTS_NOCHDIR) && chdir(path))
-#define FCHDIR(sp, fd) (!ISSET(FTS_NOCHDIR) && fchdir(fd))
-
-/* fts_build flags */
-#define BCHILD 1 /* fts_children */
-#define BNAMES 2 /* fts_children, names only */
-#define BREAD 3 /* fts_read */
-
-FTS *
-fts_open(argv, options, compar)
- char * const *argv;
- register int options;
- int (*compar) __P((const FTSENT **, const FTSENT **));
-{
- register FTS *sp;
- register FTSENT *p, *root;
- register int nitems;
- FTSENT *parent, *tmp;
- int len;
-
- /* Options check. */
- if (options & ~FTS_OPTIONMASK) {
- errno = EINVAL;
- return (NULL);
- }
-
- /* Allocate/initialize the stream */
- if ((sp = malloc((u_int)sizeof(FTS))) == NULL)
- return (NULL);
- memset(sp, 0, sizeof(FTS));
- sp->fts_compar = compar;
- sp->fts_options = options;
-
- /* Shush, GCC. */
- tmp = NULL;
-
- /* Logical walks turn on NOCHDIR; symbolic links are too hard. */
- if (ISSET(FTS_LOGICAL))
- SET(FTS_NOCHDIR);
-
- /*
- * Start out with 1K of path space, and enough, in any case,
- * to hold the user's paths.
- */
- if (fts_palloc(sp, MAX(fts_maxarglen(argv), MAXPATHLEN)))
- goto mem1;
-
- /* Allocate/initialize root's parent. */
- if ((parent = fts_alloc(sp, "", 0)) == NULL)
- goto mem2;
- parent->fts_level = FTS_ROOTPARENTLEVEL;
-
- /* Allocate/initialize root(s). */
- for (root = NULL, nitems = 0; *argv; ++argv, ++nitems) {
- /* Don't allow zero-length paths. */
- if ((len = strlen(*argv)) == 0) {
- errno = ENOENT;
- goto mem3;
- }
-
- p = fts_alloc(sp, *argv, len);
- p->fts_level = FTS_ROOTLEVEL;
- p->fts_parent = parent;
- p->fts_accpath = p->fts_name;
- p->fts_info = fts_stat(sp, p, ISSET(FTS_COMFOLLOW));
-
- /* Command-line "." and ".." are real directories. */
- if (p->fts_info == FTS_DOT)
- p->fts_info = FTS_D;
-
- /*
- * If comparison routine supplied, traverse in sorted
- * order; otherwise traverse in the order specified.
- */
- if (compar) {
- p->fts_link = root;
- root = p;
- } else {
- p->fts_link = NULL;
- if (root == NULL)
- tmp = root = p;
- else {
- tmp->fts_link = p;
- tmp = p;
- }
- }
- }
- if (compar && nitems > 1)
- root = fts_sort(sp, root, nitems);
-
- /*
- * Allocate a dummy pointer and make fts_read think that we've just
- * finished the node before the root(s); set p->fts_info to FTS_INIT
- * so that everything about the "current" node is ignored.
- */
- if ((sp->fts_cur = fts_alloc(sp, "", 0)) == NULL)
- goto mem3;
- sp->fts_cur->fts_link = root;
- sp->fts_cur->fts_info = FTS_INIT;
-
- /*
- * If using chdir(2), grab a file descriptor pointing to dot to ensure
- * that we can get back here; this could be avoided for some paths,
- * but almost certainly not worth the effort. Slashes, symbolic links,
- * and ".." are all fairly nasty problems. Note, if we can't get the
- * descriptor we run anyway, just more slowly.
- */
- if (!ISSET(FTS_NOCHDIR) && (sp->fts_rfd = _open(".", O_RDONLY, 0)) < 0)
- SET(FTS_NOCHDIR);
-
- return (sp);
-
-mem3: fts_lfree(root);
- free(parent);
-mem2: free(sp->fts_path);
-mem1: free(sp);
- return (NULL);
-}
-
-static void
-fts_load(sp, p)
- FTS *sp;
- register FTSENT *p;
-{
- register int len;
- register char *cp;
-
- /*
- * Load the stream structure for the next traversal. Since we don't
- * actually enter the directory until after the preorder visit, set
- * the fts_accpath field specially so the chdir gets done to the right
- * place and the user can access the first node. From fts_open it's
- * known that the path will fit.
- */
- len = p->fts_pathlen = p->fts_namelen;
- memmove(sp->fts_path, p->fts_name, len + 1);
- if ((cp = strrchr(p->fts_name, '/')) && (cp != p->fts_name || cp[1])) {
- len = strlen(++cp);
- memmove(p->fts_name, cp, len + 1);
- p->fts_namelen = len;
- }
- p->fts_accpath = p->fts_path = sp->fts_path;
- sp->fts_dev = p->fts_dev;
-}
-
-int
-fts_close(sp)
- FTS *sp;
-{
- register FTSENT *freep, *p;
- int saved_errno;
-
- /*
- * This still works if we haven't read anything -- the dummy structure
- * points to the root list, so we step through to the end of the root
- * list which has a valid parent pointer.
- */
- if (sp->fts_cur) {
- for (p = sp->fts_cur; p->fts_level >= FTS_ROOTLEVEL;) {
- freep = p;
- p = p->fts_link ? p->fts_link : p->fts_parent;
- free(freep);
- }
- free(p);
- }
-
- /* Free up child linked list, sort array, path buffer. */
- if (sp->fts_child)
- fts_lfree(sp->fts_child);
- if (sp->fts_array)
- free(sp->fts_array);
- free(sp->fts_path);
-
- /* Return to original directory, save errno if necessary. */
- if (!ISSET(FTS_NOCHDIR)) {
- saved_errno = fchdir(sp->fts_rfd) ? errno : 0;
- (void)_close(sp->fts_rfd);
-
- /* Set errno and return. */
- if (saved_errno != 0) {
- /* Free up the stream pointer. */
- free(sp);
- errno = saved_errno;
- return (-1);
- }
- }
-
- /* Free up the stream pointer. */
- free(sp);
- return (0);
-}
-
-/*
- * Special case of "/" at the end of the path so that slashes aren't
- * appended which would cause paths to be written as "....//foo".
- */
-#define NAPPEND(p) \
- (p->fts_path[p->fts_pathlen - 1] == '/' \
- ? p->fts_pathlen - 1 : p->fts_pathlen)
-
-FTSENT *
-fts_read(sp)
- register FTS *sp;
-{
- register FTSENT *p, *tmp;
- register int instr;
- register char *t;
- int saved_errno;
-
- /* If finished or unrecoverable error, return NULL. */
- if (sp->fts_cur == NULL || ISSET(FTS_STOP))
- return (NULL);
-
- /* Set current node pointer. */
- p = sp->fts_cur;
-
- /* Save and zero out user instructions. */
- instr = p->fts_instr;
- p->fts_instr = FTS_NOINSTR;
-
- /* Any type of file may be re-visited; re-stat and re-turn. */
- if (instr == FTS_AGAIN) {
- p->fts_info = fts_stat(sp, p, 0);
- return (p);
- }
-
- /*
- * Following a symlink -- SLNONE test allows application to see
- * SLNONE and recover. If indirecting through a symlink, have
- * keep a pointer to current location. If unable to get that
- * pointer, follow fails.
- */
- if (instr == FTS_FOLLOW &&
- (p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE)) {
- p->fts_info = fts_stat(sp, p, 1);
- if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) {
- if ((p->fts_symfd = _open(".", O_RDONLY, 0)) < 0) {
- p->fts_errno = errno;
- p->fts_info = FTS_ERR;
- } else
- p->fts_flags |= FTS_SYMFOLLOW;
- }
- return (p);
- }
-
- /* Directory in pre-order. */
- if (p->fts_info == FTS_D) {
- /* If skipped or crossed mount point, do post-order visit. */
- if (instr == FTS_SKIP ||
- (ISSET(FTS_XDEV) && p->fts_dev != sp->fts_dev)) {
- if (p->fts_flags & FTS_SYMFOLLOW)
- (void)_close(p->fts_symfd);
- if (sp->fts_child) {
- fts_lfree(sp->fts_child);
- sp->fts_child = NULL;
- }
- p->fts_info = FTS_DP;
- return (p);
- }
-
- /* Rebuild if only read the names and now traversing. */
- if (sp->fts_child && ISSET(FTS_NAMEONLY)) {
- CLR(FTS_NAMEONLY);
- fts_lfree(sp->fts_child);
- sp->fts_child = NULL;
- }
-
- /*
- * Cd to the subdirectory.
- *
- * If have already read and now fail to chdir, whack the list
- * to make the names come out right, and set the parent errno
- * so the application will eventually get an error condition.
- * Set the FTS_DONTCHDIR flag so that when we logically change
- * directories back to the parent we don't do a chdir.
- *
- * If haven't read do so. If the read fails, fts_build sets
- * FTS_STOP or the fts_info field of the node.
- */
- if (sp->fts_child) {
- if (fts_safe_changedir(sp, p, -1)) {
- p->fts_errno = errno;
- p->fts_flags |= FTS_DONTCHDIR;
- for (p = sp->fts_child; p; p = p->fts_link)
- p->fts_accpath =
- p->fts_parent->fts_accpath;
- }
- } else if ((sp->fts_child = fts_build(sp, BREAD)) == NULL) {
- if (ISSET(FTS_STOP))
- return (NULL);
- return (p);
- }
- p = sp->fts_child;
- sp->fts_child = NULL;
- goto name;
- }
-
- /* Move to the next node on this level. */
-next: tmp = p;
- if ((p = p->fts_link)) {
- free(tmp);
-
- /*
- * If reached the top, return to the original directory (or
- * the root of the tree), and load the paths for the next root.
- */
- if (p->fts_level == FTS_ROOTLEVEL) {
- if (FCHDIR(sp, sp->fts_rfd)) {
- SET(FTS_STOP);
- return (NULL);
- }
- fts_load(sp, p);
- return (sp->fts_cur = p);
- }
-
- /*
- * User may have called fts_set on the node. If skipped,
- * ignore. If followed, get a file descriptor so we can
- * get back if necessary.
- */
- if (p->fts_instr == FTS_SKIP)
- goto next;
- if (p->fts_instr == FTS_FOLLOW) {
- p->fts_info = fts_stat(sp, p, 1);
- if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) {
- if ((p->fts_symfd =
- _open(".", O_RDONLY, 0)) < 0) {
- p->fts_errno = errno;
- p->fts_info = FTS_ERR;
- } else
- p->fts_flags |= FTS_SYMFOLLOW;
- }
- p->fts_instr = FTS_NOINSTR;
- }
-
-name: t = sp->fts_path + NAPPEND(p->fts_parent);
- *t++ = '/';
- memmove(t, p->fts_name, p->fts_namelen + 1);
- return (sp->fts_cur = p);
- }
-
- /* Move up to the parent node. */
- p = tmp->fts_parent;
- free(tmp);
-
- if (p->fts_level == FTS_ROOTPARENTLEVEL) {
- /*
- * Done; free everything up and set errno to 0 so the user
- * can distinguish between error and EOF.
- */
- free(p);
- errno = 0;
- return (sp->fts_cur = NULL);
- }
-
- /* NUL terminate the pathname. */
- sp->fts_path[p->fts_pathlen] = '\0';
-
- /*
- * Return to the parent directory. If at a root node or came through
- * a symlink, go back through the file descriptor. Otherwise, cd up
- * one directory.
- */
- if (p->fts_level == FTS_ROOTLEVEL) {
- if (FCHDIR(sp, sp->fts_rfd)) {
- SET(FTS_STOP);
- return (NULL);
- }
- } else if (p->fts_flags & FTS_SYMFOLLOW) {
- if (FCHDIR(sp, p->fts_symfd)) {
- saved_errno = errno;
- (void)_close(p->fts_symfd);
- errno = saved_errno;
- SET(FTS_STOP);
- return (NULL);
- }
- (void)_close(p->fts_symfd);
- } else if (!(p->fts_flags & FTS_DONTCHDIR)) {
- if (CHDIR(sp, "..")) {
- SET(FTS_STOP);
- return (NULL);
- }
- }
- p->fts_info = p->fts_errno ? FTS_ERR : FTS_DP;
- return (sp->fts_cur = p);
-}
-
-/*
- * Fts_set takes the stream as an argument although it's not used in this
- * implementation; it would be necessary if anyone wanted to add global
- * semantics to fts using fts_set. An error return is allowed for similar
- * reasons.
- */
-/* ARGSUSED */
-int
-fts_set(sp, p, instr)
- FTS *sp;
- FTSENT *p;
- int instr;
-{
- if (instr && instr != FTS_AGAIN && instr != FTS_FOLLOW &&
- instr != FTS_NOINSTR && instr != FTS_SKIP) {
- errno = EINVAL;
- return (1);
- }
- p->fts_instr = instr;
- return (0);
-}
-
-FTSENT *
-fts_children(sp, instr)
- register FTS *sp;
- int instr;
-{
- register FTSENT *p;
- int fd;
-
- if (instr && instr != FTS_NAMEONLY) {
- errno = EINVAL;
- return (NULL);
- }
-
- /* Set current node pointer. */
- p = sp->fts_cur;
-
- /*
- * Errno set to 0 so user can distinguish empty directory from
- * an error.
- */
- errno = 0;
-
- /* Fatal errors stop here. */
- if (ISSET(FTS_STOP))
- return (NULL);
-
- /* Return logical hierarchy of user's arguments. */
- if (p->fts_info == FTS_INIT)
- return (p->fts_link);
-
- /*
- * If not a directory being visited in pre-order, stop here. Could
- * allow FTS_DNR, assuming the user has fixed the problem, but the
- * same effect is available with FTS_AGAIN.
- */
- if (p->fts_info != FTS_D /* && p->fts_info != FTS_DNR */)
- return (NULL);
-
- /* Free up any previous child list. */
- if (sp->fts_child)
- fts_lfree(sp->fts_child);
-
- if (instr == FTS_NAMEONLY) {
- SET(FTS_NAMEONLY);
- instr = BNAMES;
- } else
- instr = BCHILD;
-
- /*
- * If using chdir on a relative path and called BEFORE fts_read does
- * its chdir to the root of a traversal, we can lose -- we need to
- * chdir into the subdirectory, and we don't know where the current
- * directory is, so we can't get back so that the upcoming chdir by
- * fts_read will work.
- */
- if (p->fts_level != FTS_ROOTLEVEL || p->fts_accpath[0] == '/' ||
- ISSET(FTS_NOCHDIR))
- return (sp->fts_child = fts_build(sp, instr));
-
- if ((fd = _open(".", O_RDONLY, 0)) < 0)
- return (NULL);
- sp->fts_child = fts_build(sp, instr);
- if (fchdir(fd))
- return (NULL);
- (void)_close(fd);
- return (sp->fts_child);
-}
-
-/*
- * This is the tricky part -- do not casually change *anything* in here. The
- * idea is to build the linked list of entries that are used by fts_children
- * and fts_read. There are lots of special cases.
- *
- * The real slowdown in walking the tree is the stat calls. If FTS_NOSTAT is
- * set and it's a physical walk (so that symbolic links can't be directories),
- * we can do things quickly. First, if it's a 4.4BSD file system, the type
- * of the file is in the directory entry. Otherwise, we assume that the number
- * of subdirectories in a node is equal to the number of links to the parent.
- * The former skips all stat calls. The latter skips stat calls in any leaf
- * directories and for any files after the subdirectories in the directory have
- * been found, cutting the stat calls by about 2/3.
- */
-static FTSENT *
-fts_build(sp, type)
- register FTS *sp;
- int type;
-{
- register struct dirent *dp;
- register FTSENT *p, *head;
- register int nitems;
- FTSENT *cur, *tail;
- DIR *dirp;
- void *oldaddr;
- int cderrno, descend, len, level, maxlen, nlinks, oflag, saved_errno,
- nostat, doadjust;
- char *cp;
-
- /* Set current node pointer. */
- cur = sp->fts_cur;
-
- /*
- * Open the directory for reading. If this fails, we're done.
- * If being called from fts_read, set the fts_info field.
- */
-#ifdef FTS_WHITEOUT
- if (ISSET(FTS_WHITEOUT))
- oflag = DTF_NODUP|DTF_REWIND;
- else
- oflag = DTF_HIDEW|DTF_NODUP|DTF_REWIND;
-#else
-#define __opendir2(path, flag) opendir(path)
-#endif
- if ((dirp = __opendir2(cur->fts_accpath, oflag)) == NULL) {
- if (type == BREAD) {
- cur->fts_info = FTS_DNR;
- cur->fts_errno = errno;
- }
- return (NULL);
- }
-
- /*
- * Nlinks is the number of possible entries of type directory in the
- * directory if we're cheating on stat calls, 0 if we're not doing
- * any stat calls at all, -1 if we're doing stats on everything.
- */
- if (type == BNAMES) {
- nlinks = 0;
- /* Be quiet about nostat, GCC. */
- nostat = 0;
- } else if (ISSET(FTS_NOSTAT) && ISSET(FTS_PHYSICAL)) {
- nlinks = cur->fts_nlink - (ISSET(FTS_SEEDOT) ? 0 : 2);
- nostat = 1;
- } else {
- nlinks = -1;
- nostat = 0;
- }
-
-#ifdef notdef
- (void)printf("nlinks == %d (cur: %d)\n", nlinks, cur->fts_nlink);
- (void)printf("NOSTAT %d PHYSICAL %d SEEDOT %d\n",
- ISSET(FTS_NOSTAT), ISSET(FTS_PHYSICAL), ISSET(FTS_SEEDOT));
-#endif
- /*
- * If we're going to need to stat anything or we want to descend
- * and stay in the directory, chdir. If this fails we keep going,
- * but set a flag so we don't chdir after the post-order visit.
- * We won't be able to stat anything, but we can still return the
- * names themselves. Note, that since fts_read won't be able to
- * chdir into the directory, it will have to return different path
- * names than before, i.e. "a/b" instead of "b". Since the node
- * has already been visited in pre-order, have to wait until the
- * post-order visit to return the error. There is a special case
- * here, if there was nothing to stat then it's not an error to
- * not be able to stat. This is all fairly nasty. If a program
- * needed sorted entries or stat information, they had better be
- * checking FTS_NS on the returned nodes.
- */
- cderrno = 0;
- if (nlinks || type == BREAD) {
- if (fts_safe_changedir(sp, cur, dirfd(dirp))) {
- if (nlinks && type == BREAD)
- cur->fts_errno = errno;
- cur->fts_flags |= FTS_DONTCHDIR;
- descend = 0;
- cderrno = errno;
- (void)closedir(dirp);
- dirp = NULL;
- } else
- descend = 1;
- } else
- descend = 0;
-
- /*
- * Figure out the max file name length that can be stored in the
- * current path -- the inner loop allocates more path as necessary.
- * We really wouldn't have to do the maxlen calculations here, we
- * could do them in fts_read before returning the path, but it's a
- * lot easier here since the length is part of the dirent structure.
- *
- * If not changing directories set a pointer so that can just append
- * each new name into the path.
- */
- len = NAPPEND(cur);
- if (ISSET(FTS_NOCHDIR)) {
- cp = sp->fts_path + len;
- *cp++ = '/';
- } else {
- /* GCC, you're too verbose. */
- cp = NULL;
- }
- len++;
- maxlen = sp->fts_pathlen - len;
-
- level = cur->fts_level + 1;
-
- /* Read the directory, attaching each entry to the `link' pointer. */
- doadjust = 0;
- for (head = tail = NULL, nitems = 0; dirp && (dp = readdir(dirp));) {
- if (!ISSET(FTS_SEEDOT) && ISDOT(dp->d_name))
- continue;
-
- if ((p = fts_alloc(sp, dp->d_name, (int)dp->d_namlen)) == NULL)
- goto mem1;
- if (dp->d_namlen >= maxlen) { /* include space for NUL */
- oldaddr = sp->fts_path;
- if (fts_palloc(sp, dp->d_namlen +len + 1)) {
- /*
- * No more memory for path or structures. Save
- * errno, free up the current structure and the
- * structures already allocated.
- */
-mem1: saved_errno = errno;
- if (p)
- free(p);
- fts_lfree(head);
- (void)closedir(dirp);
- cur->fts_info = FTS_ERR;
- SET(FTS_STOP);
- errno = saved_errno;
- return (NULL);
- }
- /* Did realloc() change the pointer? */
- if (oldaddr != sp->fts_path) {
- doadjust = 1;
- if (ISSET(FTS_NOCHDIR))
- cp = sp->fts_path + len;
- }
- maxlen = sp->fts_pathlen - len;
- }
-
- if (len + dp->d_namlen >= USHRT_MAX) {
- /*
- * In an FTSENT, fts_pathlen is a u_short so it is
- * possible to wraparound here. If we do, free up
- * the current structure and the structures already
- * allocated, then error out with ENAMETOOLONG.
- */
- free(p);
- fts_lfree(head);
- (void)closedir(dirp);
- cur->fts_info = FTS_ERR;
- SET(FTS_STOP);
- errno = ENAMETOOLONG;
- return (NULL);
- }
- p->fts_level = level;
- p->fts_parent = sp->fts_cur;
- p->fts_pathlen = len + dp->d_namlen;
-
-#ifdef FTS_WHITEOUT
- if (dp->d_type == DT_WHT)
- p->fts_flags |= FTS_ISW;
-#endif
-
- if (cderrno) {
- if (nlinks) {
- p->fts_info = FTS_NS;
- p->fts_errno = cderrno;
- } else
- p->fts_info = FTS_NSOK;
- p->fts_accpath = cur->fts_accpath;
- } else if (nlinks == 0
-#ifdef DT_DIR
- || (nostat &&
- dp->d_type != DT_DIR && dp->d_type != DT_UNKNOWN)
-#endif
- ) {
- p->fts_accpath =
- ISSET(FTS_NOCHDIR) ? p->fts_path : p->fts_name;
- p->fts_info = FTS_NSOK;
- } else {
- /* Build a file name for fts_stat to stat. */
- if (ISSET(FTS_NOCHDIR)) {
- p->fts_accpath = p->fts_path;
- memmove(cp, p->fts_name, p->fts_namelen + 1);
- } else
- p->fts_accpath = p->fts_name;
- /* Stat it. */
- p->fts_info = fts_stat(sp, p, 0);
-
- /* Decrement link count if applicable. */
- if (nlinks > 0 && (p->fts_info == FTS_D ||
- p->fts_info == FTS_DC || p->fts_info == FTS_DOT))
- --nlinks;
- }
-
- /* We walk in directory order so "ls -f" doesn't get upset. */
- p->fts_link = NULL;
- if (head == NULL)
- head = tail = p;
- else {
- tail->fts_link = p;
- tail = p;
- }
- ++nitems;
- }
- if (dirp)
- (void)closedir(dirp);
-
- /*
- * If realloc() changed the address of the path, adjust the
- * addresses for the rest of the tree and the dir list.
- */
- if (doadjust)
- fts_padjust(sp, head);
-
- /*
- * If not changing directories, reset the path back to original
- * state.
- */
- if (ISSET(FTS_NOCHDIR)) {
- if (len == sp->fts_pathlen || nitems == 0)
- --cp;
- *cp = '\0';
- }
-
- /*
- * If descended after called from fts_children or after called from
- * fts_read and nothing found, get back. At the root level we use
- * the saved fd; if one of fts_open()'s arguments is a relative path
- * to an empty directory, we wind up here with no other way back. If
- * can't get back, we're done.
- */
- if (descend && (type == BCHILD || !nitems) &&
- (cur->fts_level == FTS_ROOTLEVEL ?
- FCHDIR(sp, sp->fts_rfd) : CHDIR(sp, ".."))) {
- cur->fts_info = FTS_ERR;
- SET(FTS_STOP);
- return (NULL);
- }
-
- /* If didn't find anything, return NULL. */
- if (!nitems) {
- if (type == BREAD)
- cur->fts_info = FTS_DP;
- return (NULL);
- }
-
- /* Sort the entries. */
- if (sp->fts_compar && nitems > 1)
- head = fts_sort(sp, head, nitems);
- return (head);
-}
-
-static u_short
-fts_stat(sp, p, follow)
- FTS *sp;
- register FTSENT *p;
- int follow;
-{
- register FTSENT *t;
- register dev_t dev;
- register ino_t ino;
- struct stat *sbp, sb;
- int saved_errno;
-
- /* If user needs stat info, stat buffer already allocated. */
- sbp = ISSET(FTS_NOSTAT) ? &sb : p->fts_statp;
-
-#ifdef FTS_WHITEOUT
- /* check for whiteout */
- if (p->fts_flags & FTS_ISW) {
- if (sbp != &sb) {
- memset(sbp, '\0', sizeof (*sbp));
- sbp->st_mode = S_IFWHT;
- }
- return (FTS_W);
- }
-#endif
-
- /*
- * If doing a logical walk, or application requested FTS_FOLLOW, do
- * a stat(2). If that fails, check for a non-existent symlink. If
- * fail, set the errno from the stat call.
- */
- if (ISSET(FTS_LOGICAL) || follow) {
- if (stat(p->fts_accpath, sbp)) {
- saved_errno = errno;
- if (!lstat(p->fts_accpath, sbp)) {
- errno = 0;
- return (FTS_SLNONE);
- }
- p->fts_errno = saved_errno;
- goto err;
- }
- } else if (lstat(p->fts_accpath, sbp)) {
- p->fts_errno = errno;
-err: memset(sbp, 0, sizeof(struct stat));
- return (FTS_NS);
- }
-
- if (S_ISDIR(sbp->st_mode)) {
- /*
- * Set the device/inode. Used to find cycles and check for
- * crossing mount points. Also remember the link count, used
- * in fts_build to limit the number of stat calls. It is
- * understood that these fields are only referenced if fts_info
- * is set to FTS_D.
- */
- dev = p->fts_dev = sbp->st_dev;
- ino = p->fts_ino = sbp->st_ino;
- p->fts_nlink = sbp->st_nlink;
-
- if (ISDOT(p->fts_name))
- return (FTS_DOT);
-
- /*
- * Cycle detection is done by brute force when the directory
- * is first encountered. If the tree gets deep enough or the
- * number of symbolic links to directories is high enough,
- * something faster might be worthwhile.
- */
- for (t = p->fts_parent;
- t->fts_level >= FTS_ROOTLEVEL; t = t->fts_parent)
- if (ino == t->fts_ino && dev == t->fts_dev) {
- p->fts_cycle = t;
- return (FTS_DC);
- }
- return (FTS_D);
- }
- if (S_ISLNK(sbp->st_mode))
- return (FTS_SL);
- if (S_ISREG(sbp->st_mode))
- return (FTS_F);
- return (FTS_DEFAULT);
-}
-
-static FTSENT *
-fts_sort(sp, head, nitems)
- FTS *sp;
- FTSENT *head;
- register int nitems;
-{
- register FTSENT **ap, *p;
-
- /*
- * Construct an array of pointers to the structures and call qsort(3).
- * Reassemble the array in the order returned by qsort. If unable to
- * sort for memory reasons, return the directory entries in their
- * current order. Allocate enough space for the current needs plus
- * 40 so don't realloc one entry at a time.
- */
- if (nitems > sp->fts_nitems) {
- struct _ftsent **a;
-
- sp->fts_nitems = nitems + 40;
- if ((a = realloc(sp->fts_array,
- sp->fts_nitems * sizeof(FTSENT *))) == NULL) {
- if (sp->fts_array)
- free(sp->fts_array);
- sp->fts_array = NULL;
- sp->fts_nitems = 0;
- return (head);
- }
- sp->fts_array = a;
- }
- for (ap = sp->fts_array, p = head; p; p = p->fts_link)
- *ap++ = p;
- qsort((void *)sp->fts_array, nitems, sizeof(FTSENT *), sp->fts_compar);
- for (head = *(ap = sp->fts_array); --nitems; ++ap)
- ap[0]->fts_link = ap[1];
- ap[0]->fts_link = NULL;
- return (head);
-}
-
-static FTSENT *
-fts_alloc(sp, name, namelen)
- FTS *sp;
- char *name;
- register int namelen;
-{
- register FTSENT *p;
- size_t len;
-
- /*
- * The file name is a variable length array and no stat structure is
- * necessary if the user has set the nostat bit. Allocate the FTSENT
- * structure, the file name and the stat structure in one chunk, but
- * be careful that the stat structure is reasonably aligned. Since the
- * fts_name field is declared to be of size 1, the fts_name pointer is
- * namelen + 2 before the first possible address of the stat structure.
- */
- len = sizeof(FTSENT) + namelen;
- if (!ISSET(FTS_NOSTAT))
- len += sizeof(struct stat) + ALIGNBYTES;
- if ((p = malloc(len)) == NULL)
- return (NULL);
-
- /* Copy the name and guarantee NUL termination. */
- memmove(p->fts_name, name, namelen);
- p->fts_name[namelen] = '\0';
-
- if (!ISSET(FTS_NOSTAT))
- p->fts_statp = (struct stat *)ALIGN(p->fts_name + namelen + 2);
- p->fts_namelen = namelen;
- p->fts_path = sp->fts_path;
- p->fts_errno = 0;
- p->fts_flags = 0;
- p->fts_instr = FTS_NOINSTR;
- p->fts_number = 0;
- p->fts_pointer = NULL;
- return (p);
-}
-
-static void
-fts_lfree(head)
- register FTSENT *head;
-{
- register FTSENT *p;
-
- /* Free a linked list of structures. */
- while ((p = head)) {
- head = head->fts_link;
- free(p);
- }
-}
-
-/*
- * Allow essentially unlimited paths; find, rm, ls should all work on any tree.
- * Most systems will allow creation of paths much longer than MAXPATHLEN, even
- * though the kernel won't resolve them. Add the size (not just what's needed)
- * plus 256 bytes so don't realloc the path 2 bytes at a time.
- */
-static int
-fts_palloc(sp, more)
- FTS *sp;
- size_t more;
-{
- char *p;
-
- sp->fts_pathlen += more + 256;
- /*
- * Check for possible wraparound. In an FTS, fts_pathlen is
- * a signed int but in an FTSENT it is an unsigned short.
- * We limit fts_pathlen to USHRT_MAX to be safe in both cases.
- */
- if (sp->fts_pathlen < 0 || sp->fts_pathlen >= USHRT_MAX) {
- if (sp->fts_path)
- free(sp->fts_path);
- sp->fts_path = NULL;
- errno = ENAMETOOLONG;
- return (1);
- }
- p = realloc(sp->fts_path, sp->fts_pathlen);
- if (p == NULL) {
- if (sp->fts_path)
- free(sp->fts_path);
- sp->fts_path = NULL;
- return (1);
- }
- sp->fts_path = p;
- return (0);
-}
-
-/*
- * When the path is realloc'd, have to fix all of the pointers in structures
- * already returned.
- */
-static void
-fts_padjust(sp, head)
- FTS *sp;
- FTSENT *head;
-{
- FTSENT *p;
- char *addr = sp->fts_path;
-
-#define ADJUST(p) { \
- if ((p)->fts_accpath != (p)->fts_name) { \
- (p)->fts_accpath = \
- (char *)addr + ((p)->fts_accpath - (p)->fts_path); \
- } \
- (p)->fts_path = addr; \
-}
- /* Adjust the current set of children. */
- for (p = sp->fts_child; p; p = p->fts_link)
- ADJUST(p);
-
- /* Adjust the rest of the tree, including the current level. */
- for (p = head; p->fts_level >= FTS_ROOTLEVEL;) {
- ADJUST(p);
- p = p->fts_link ? p->fts_link : p->fts_parent;
- }
-}
-
-static size_t
-fts_maxarglen(argv)
- char * const *argv;
-{
- size_t len, max;
-
- for (max = 0; *argv; ++argv)
- if ((len = strlen(*argv)) > max)
- max = len;
- return (max + 1);
-}
-
-/*
- * Change to dir specified by fd or p->fts_accpath without getting
- * tricked by someone changing the world out from underneath us.
- * Assumes p->fts_dev and p->fts_ino are filled in.
- */
-static int
-fts_safe_changedir(sp, p, fd)
- FTS *sp;
- FTSENT *p;
- int fd;
-{
- int ret, oerrno, newfd;
- struct stat sb;
-
- newfd = fd;
- if (ISSET(FTS_NOCHDIR))
- return (0);
- if (fd < 0 && (newfd = _open(p->fts_accpath, O_RDONLY, 0)) < 0)
- return (-1);
- if (fstat(newfd, &sb)) {
- ret = -1;
- goto bail;
- }
- if (p->fts_dev != sb.st_dev || p->fts_ino != sb.st_ino) {
- errno = ENOENT; /* disinformation */
- ret = -1;
- goto bail;
- }
- ret = fchdir(newfd);
-bail:
- oerrno = errno;
- if (fd < 0)
- (void)_close(newfd);
- errno = oerrno;
- return (ret);
-}
diff --git a/lib/libc/gen/fts-compat.h b/lib/libc/gen/fts-compat.h
deleted file mode 100644
index 4fa4a3aa0ded..000000000000
--- a/lib/libc/gen/fts-compat.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (c) 1989, 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)fts.h 8.3 (Berkeley) 8/14/94
- */
-
-#ifndef _FTS_H_
-#define _FTS_H_
-
-typedef struct {
- struct _ftsent *fts_cur; /* current node */
- struct _ftsent *fts_child; /* linked list of children */
- struct _ftsent **fts_array; /* sort array */
- dev_t fts_dev; /* starting device # */
- char *fts_path; /* path for this descent */
- int fts_rfd; /* fd for root */
- int fts_pathlen; /* sizeof(path) */
- int fts_nitems; /* elements in the sort array */
- int (*fts_compar)(); /* compare function */
-
-#define FTS_COMFOLLOW 0x001 /* follow command line symlinks */
-#define FTS_LOGICAL 0x002 /* logical walk */
-#define FTS_NOCHDIR 0x004 /* don't change directories */
-#define FTS_NOSTAT 0x008 /* don't get stat info */
-#define FTS_PHYSICAL 0x010 /* physical walk */
-#define FTS_SEEDOT 0x020 /* return dot and dot-dot */
-#define FTS_XDEV 0x040 /* don't cross devices */
-#define FTS_WHITEOUT 0x080 /* return whiteout information */
-#define FTS_OPTIONMASK 0x0ff /* valid user option mask */
-
-#define FTS_NAMEONLY 0x100 /* (private) child names only */
-#define FTS_STOP 0x200 /* (private) unrecoverable error */
- int fts_options; /* fts_open options, global flags */
-} FTS;
-
-typedef struct _ftsent {
- struct _ftsent *fts_cycle; /* cycle node */
- struct _ftsent *fts_parent; /* parent directory */
- struct _ftsent *fts_link; /* next file in directory */
- long fts_number; /* local numeric value */
- void *fts_pointer; /* local address value */
- char *fts_accpath; /* access path */
- char *fts_path; /* root path */
- int fts_errno; /* errno for this node */
- int fts_symfd; /* fd for symlink */
- u_short fts_pathlen; /* strlen(fts_path) */
- u_short fts_namelen; /* strlen(fts_name) */
-
- ino_t fts_ino; /* inode */
- dev_t fts_dev; /* device */
- nlink_t fts_nlink; /* link count */
-
-#define FTS_ROOTPARENTLEVEL -1
-#define FTS_ROOTLEVEL 0
- short fts_level; /* depth (-1 to N) */
-
-#define FTS_D 1 /* preorder directory */
-#define FTS_DC 2 /* directory that causes cycles */
-#define FTS_DEFAULT 3 /* none of the above */
-#define FTS_DNR 4 /* unreadable directory */
-#define FTS_DOT 5 /* dot or dot-dot */
-#define FTS_DP 6 /* postorder directory */
-#define FTS_ERR 7 /* error; errno is set */
-#define FTS_F 8 /* regular file */
-#define FTS_INIT 9 /* initialized only */
-#define FTS_NS 10 /* stat(2) failed */
-#define FTS_NSOK 11 /* no stat(2) requested */
-#define FTS_SL 12 /* symbolic link */
-#define FTS_SLNONE 13 /* symbolic link without target */
-#define FTS_W 14 /* whiteout object */
- u_short fts_info; /* user flags for FTSENT structure */
-
-#define FTS_DONTCHDIR 0x01 /* don't chdir .. to the parent */
-#define FTS_SYMFOLLOW 0x02 /* followed a symlink to get here */
-#define FTS_ISW 0x04 /* this is a whiteout object */
- u_short fts_flags; /* private flags for FTSENT structure */
-
-#define FTS_AGAIN 1 /* read node again */
-#define FTS_FOLLOW 2 /* follow symbolic link */
-#define FTS_NOINSTR 3 /* no instructions */
-#define FTS_SKIP 4 /* discard node */
- u_short fts_instr; /* fts_set() instructions */
-
- struct stat *fts_statp; /* stat(2) information */
- char fts_name[1]; /* file name */
-} FTSENT;
-
-#include <sys/cdefs.h>
-
-__BEGIN_DECLS
-FTSENT *fts_children __P((FTS *, int));
-int fts_close __P((FTS *));
-FTS *fts_open __P((char * const *, int,
- int (*)(const FTSENT **, const FTSENT **)));
-FTSENT *fts_read __P((FTS *));
-int fts_set __P((FTS *, FTSENT *, int));
-__END_DECLS
-
-#endif /* !_FTS_H_ */
diff --git a/lib/libc/gen/pw_scan.c b/lib/libc/gen/pw_scan.c
deleted file mode 100644
index d0fb5f17d035..000000000000
--- a/lib/libc/gen/pw_scan.c
+++ /dev/null
@@ -1,174 +0,0 @@
-/*-
- * Copyright (c) 1990, 1993, 1994
- * 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-#if 0
-static char sccsid[] = "@(#)pw_scan.c 8.3 (Berkeley) 4/2/94";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-/*
- * This module is used to "verify" password entries by chpass(1) and
- * pwd_mkdb(8).
- */
-
-#include <sys/param.h>
-
-#include <err.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <pwd.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include "pw_scan.h"
-
-/*
- * Some software assumes that IDs are short. We should emit warnings
- * for id's which can not be stored in a short, but we are more liberal
- * by default, warning for IDs greater than USHRT_MAX.
- *
- * If pw_big_ids_warning is anything other than -1 on entry to pw_scan()
- * it will be set based on the existance of PW_SCAN_BIG_IDS in the
- * environment.
- */
-int pw_big_ids_warning = -1;
-
-int
-pw_scan(bp, pw)
- char *bp;
- struct passwd *pw;
-{
- uid_t id;
- int root;
- char *p, *sh;
-
- if (pw_big_ids_warning == -1)
- pw_big_ids_warning = getenv("PW_SCAN_BIG_IDS") == NULL ? 1 : 0;
-
- pw->pw_fields = 0;
- if (!(pw->pw_name = strsep(&bp, ":"))) /* login */
- goto fmt;
- root = !strcmp(pw->pw_name, "root");
- if(pw->pw_name[0] && (pw->pw_name[0] != '+' || pw->pw_name[1] == '\0'))
- pw->pw_fields |= _PWF_NAME;
-
- if (!(pw->pw_passwd = strsep(&bp, ":"))) /* passwd */
- goto fmt;
- if(pw->pw_passwd[0]) pw->pw_fields |= _PWF_PASSWD;
-
- if (!(p = strsep(&bp, ":"))) /* uid */
- goto fmt;
- if (p[0])
- pw->pw_fields |= _PWF_UID;
- else {
- if (pw->pw_name[0] != '+' && pw->pw_name[0] != '-') {
- warnx("no uid for user %s", pw->pw_name);
- return (0);
- }
- }
- id = strtoul(p, (char **)NULL, 10);
- if (errno == ERANGE) {
- warnx("%s > max uid value (%u)", p, ULONG_MAX);
- return (0);
- }
- if (root && id) {
- warnx("root uid should be 0");
- return (0);
- }
- if (pw_big_ids_warning && id > USHRT_MAX) {
- warnx("%s > recommended max uid value (%u)", p, USHRT_MAX);
- /*return (0);*/ /* THIS SHOULD NOT BE FATAL! */
- }
- pw->pw_uid = id;
-
- if (!(p = strsep(&bp, ":"))) /* gid */
- goto fmt;
- if(p[0]) pw->pw_fields |= _PWF_GID;
- id = strtoul(p, (char **)NULL, 10);
- if (errno == ERANGE) {
- warnx("%s > max gid value (%u)", p, ULONG_MAX);
- return (0);
- }
- if (pw_big_ids_warning && id > USHRT_MAX) {
- warnx("%s > recommended max gid value (%u)", p, USHRT_MAX);
- /* return (0); This should not be fatal! */
- }
- pw->pw_gid = id;
-
- pw->pw_class = strsep(&bp, ":"); /* class */
- if(pw->pw_class[0]) pw->pw_fields |= _PWF_CLASS;
-
- if (!(p = strsep(&bp, ":"))) /* change */
- goto fmt;
- if(p[0]) pw->pw_fields |= _PWF_CHANGE;
- pw->pw_change = atol(p);
-
- if (!(p = strsep(&bp, ":"))) /* expire */
- goto fmt;
- if(p[0]) pw->pw_fields |= _PWF_EXPIRE;
- pw->pw_expire = atol(p);
-
- if (!(pw->pw_gecos = strsep(&bp, ":"))) /* gecos */
- goto fmt;
- if(pw->pw_gecos[0]) pw->pw_fields |= _PWF_GECOS;
-
- if (!(pw->pw_dir = strsep(&bp, ":"))) /* directory */
- goto fmt;
- if(pw->pw_dir[0]) pw->pw_fields |= _PWF_DIR;
-
- if (!(pw->pw_shell = strsep(&bp, ":"))) /* shell */
- goto fmt;
-
- p = pw->pw_shell;
- if (root && *p) /* empty == /bin/sh */
- for (setusershell();;) {
- if (!(sh = getusershell())) {
- warnx("warning, unknown root shell");
- break;
- }
- if (!strcmp(p, sh))
- break;
- }
- if(p[0]) pw->pw_fields |= _PWF_SHELL;
-
- if ((p = strsep(&bp, ":"))) { /* too many */
-fmt: warnx("corrupted entry");
- return (0);
- }
- return (1);
-}
diff --git a/lib/libc/gen/pw_scan.h b/lib/libc/gen/pw_scan.h
deleted file mode 100644
index 2519bd45db01..000000000000
--- a/lib/libc/gen/pw_scan.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*-
- * Copyright (c) 1994
- * 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)pw_scan.h 8.1 (Berkeley) 4/1/94
- *
- * $FreeBSD$
- */
-
-extern int pw_big_ids_warning;
-
-extern int pw_scan __P((char *, struct passwd *));
diff --git a/lib/libc/gen/sem_destroy.3 b/lib/libc/gen/sem_destroy.3
deleted file mode 100644
index 770349dee281..000000000000
--- a/lib/libc/gen/sem_destroy.3
+++ /dev/null
@@ -1,83 +0,0 @@
-.\" Copyright (C) 2000 Jason Evans <jasone@canonware.com>.
-.\" 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(s), this list of conditions and the following disclaimer as
-.\" the first lines of this file unmodified other than the possible
-.\" addition of one or more copyright notices.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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.
-.\"
-.\" $FreeBSD$
-.Dd February 15, 2000
-.Dt SEM_DESTROY 3
-.Os
-.Sh NAME
-.Nm sem_destroy
-.Nd destroy an unnamed semaphore
-.Sh SYNOPSIS
-.Fd #include <semaphore.h>
-.Ft int
-.Fn sem_destroy "sem_t *sem"
-.Sh DESCRIPTION
-The
-.Fn sem_destroy
-function destroys the unnamed semaphore pointed to by
-.Fa sem .
-After a successful call to
-.Fn sem_destroy ,
-.Fa sem
-is unuseable until re-initialized by another call to
-.Fn sem_init .
-.Sh RETURN VALUES
-If successful,
-.Fn sem_destroy
-returns 0. Otherwise, -1 is returned and
-.Va errno
-is set to indicate the type of
-error.
-.Sh ERRORS
-.Fn sem_destroy
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-.Fa sem
-points to an invalid semaphore.
-.It Bq Er EBUSY
-There are currently threads blocked on the semaphore that
-.Fa sem
-points to.
-.El
-.Sh SEE ALSO
-.Xr sem_init 3
-.Sh STANDARDS
-.Fn sem_destroy
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 1996 Edition.
-.Pp
-POSIX does not define the behavior of
-.Fn sem_destroy
-if called while there are threads blocked on
-.Fa sem ,
-but this implementation is guaranteed to return -1 and set
-.Va errno
-to EBUSY if there are threads blocked on
-.Fa sem .
diff --git a/lib/libc/gen/sem_getvalue.3 b/lib/libc/gen/sem_getvalue.3
deleted file mode 100644
index be0cbae8ca7b..000000000000
--- a/lib/libc/gen/sem_getvalue.3
+++ /dev/null
@@ -1,77 +0,0 @@
-.\" Copyright (C) 2000 Jason Evans <jasone@canonware.com>.
-.\" 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(s), this list of conditions and the following disclaimer as
-.\" the first lines of this file unmodified other than the possible
-.\" addition of one or more copyright notices.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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.
-.\"
-.\" $FreeBSD$
-.Dd February 15, 2000
-.Dt SEM_GETVALUE 3
-.Os
-.Sh NAME
-.Nm sem_getvalue
-.Nd get the value of a semaphore
-.Sh SYNOPSIS
-.Fd #include <semaphore.h>
-.Ft int
-.Fn sem_getvalue "sem_t *sem" "int *sval"
-.Sh DESCRIPTION
-The
-.Fn sem_getvalue
-function sets the variable pointed to by
-.Fa sval
-to the current value of the semaphore pointed to by
-.Fa sem ,
-as of the time that the call to
-.Fn sem_getvalue
-is actually run.
-.Sh RETURN VALUES
-If successful,
-.Fn sem_getvalue
-returns 0. Otherwise, -1 is returned and
-.Va errno
-is set to indicate the type of
-error.
-.Sh ERRORS
-.Fn sem_getvalue
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-.Fa sem
-points to an invalid semaphore.
-.El
-.Sh SEE ALSO
-.Xr sem_post 3 ,
-.Xr sem_wait 3 ,
-.Xr sem_trywait 3
-.Sh STANDARDS
-.Fn sem_getvalue
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 1996 Edition.
-.Pp
-The value of the semaphore is never negative, even if there are threads blocked
-on the semaphore. POSIX is somewhat ambiguous in its wording with regard to
-what the value of the semaphore should be if there are blocked waiting threads,
-but this behavior is conformant, given the wording of the specification.
diff --git a/lib/libc/gen/sem_init.3 b/lib/libc/gen/sem_init.3
deleted file mode 100644
index 059a9c6aeba5..000000000000
--- a/lib/libc/gen/sem_init.3
+++ /dev/null
@@ -1,100 +0,0 @@
-.\" Copyright (C) 2000 Jason Evans <jasone@canonware.com>.
-.\" 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(s), this list of conditions and the following disclaimer as
-.\" the first lines of this file unmodified other than the possible
-.\" addition of one or more copyright notices.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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.
-.\"
-.\" $FreeBSD$
-.Dd February 15, 2000
-.Dt SEM_INIT 3
-.Os
-.Sh NAME
-.Nm sem_init
-.Nd initialize an unnamed semaphore
-.Sh SYNOPSIS
-.Fd #include <semaphore.h>
-.Ft int
-.Fn sem_init "sem_t *sem" "int pshared" "unsigned int value"
-.Sh DESCRIPTION
-The
-.Fn sem_init
-function initializes the unnamed semaphore pointed to by
-.Fa sem
-to have the value
-.Fa value .
-A non-zero value for
-.Fa pshared
-specifies a shared semaphore that can be used by multiple processes, which this
-implementation is not capable of.
-.Pp
-Following a successful call to
-.Fn sem_init ,
-.Fa sem
-can be used as an argument in subsequent calls to
-.Fa sem_wait ,
-.Fa sem_trywait ,
-.Fa sem_post ,
-and
-.Fa sem_destroy .
-.Fa sem
-is no longer valid after a successful call to
-.Fa sem_destroy .
-.Sh RETURN VALUES
-If successful,
-.Fn sem_init
-returns 0. Otherwise, -1 is returned and
-.Va errno
-is set to indicate the type of
-error.
-.Sh ERRORS
-.Fn sem_init
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-.Fa value
-exceeds SEM_VALUE_MAX.
-.It Bq Er ENOSPC
-Memory allocation error.
-.It Bq Er EPERM
-Unable to initialize a shared semaphore.
-.El
-.Sh SEE ALSO
-.Xr sem_wait 3 ,
-.Xr sem_trywait 3 ,
-.Xr sem_post 3 ,
-.Xr sem_destroy
-.Sh STANDARDS
-.Fn sem_init
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 1996 Edition.
-.Pp
-This implementation does not support shared semaphores, and reports this fact
-by setting
-.Va errno
-to EPERM. This is perhaps a stretch of the intention of POSIX, but is
-compliant, with the caveat that
-.Fn sem_init
-always reports a permissions error when an attempt to create a shared semaphore
-is made.
diff --git a/lib/libc/gen/sem_open.3 b/lib/libc/gen/sem_open.3
deleted file mode 100644
index a4729f97961b..000000000000
--- a/lib/libc/gen/sem_open.3
+++ /dev/null
@@ -1,80 +0,0 @@
-.\" Copyright (C) 2000 Jason Evans <jasone@canonware.com>.
-.\" 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(s), this list of conditions and the following disclaimer as
-.\" the first lines of this file unmodified other than the possible
-.\" addition of one or more copyright notices.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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.
-.\"
-.\" $FreeBSD$
-.Dd February 15, 2000
-.Dt SEM_OPEN 3
-.Os
-.Sh NAME
-.Nm sem_open ,
-.Nm sem_close ,
-.Nm sem_unlink
-.Nd named semaphore operations
-.Sh SYNOPSIS
-.Fd #include <semaphore.h>
-.Ft sem_t *
-.Fn sem_open "const char *name" "int oflag" "..."
-.Ft int
-.Fn sem_close "sem_t *sem"
-.Ft int
-.Fn sem_unlink "const char *name"
-.Sh DESCRIPTION
-The
-.Fn sem_open ,
-.Fn sem_close ,
-and
-.Fn sem_unlink
-functions are not supported by this implementation.
-.Sh RETURN VALUES
-.Fn sem_open
-returns SEM_FAILED and sets
-.Va errno
-to indicate an error.
-.Fn sem_close
-and
-.Fn sem_unlink
-return -1 and set
-.Va errno
-to indicate an error.
-.Sh ERRORS
-.Fn sem_open ,
-.Fn sem_close ,
-and
-.Fn sem_unlink
-will fail:
-.Bl -tag -width Er
-.It Bq Er ENOSYS
-Function not supported by this implementation.
-.El
-.Sh STANDARDS
-.Fn sem_open ,
-.Fn sem_close ,
-and
-.Fn sem_unlink
-conform to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 1996 Edition.
diff --git a/lib/libc/gen/sem_post.3 b/lib/libc/gen/sem_post.3
deleted file mode 100644
index c578e6d04e84..000000000000
--- a/lib/libc/gen/sem_post.3
+++ /dev/null
@@ -1,71 +0,0 @@
-.\" Copyright (C) 2000 Jason Evans <jasone@canonware.com>.
-.\" 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(s), this list of conditions and the following disclaimer as
-.\" the first lines of this file unmodified other than the possible
-.\" addition of one or more copyright notices.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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.
-.\"
-.\" $FreeBSD$
-.Dd February 15, 2000
-.Dt SEM_POST 3
-.Os
-.Sh NAME
-.Nm sem_post
-.Nd increment (unlock) a semaphore
-.Sh SYNOPSIS
-.Fd #include <semaphore.h>
-.Ft int
-.Fn sem_post "sem_t *sem"
-.Sh DESCRIPTION
-The
-.Fn sem_post
-function increments (unlocks) the semaphore pointed to by
-.Fa sem .
-If there are threads blocked on the semaphore when
-.Fn sem_post
-is called, then the highest priority thread that has been blocked the longest on
-the semaphore will be allowed to return from
-.Fn sem_wait .
-.Sh RETURN VALUES
-If successful,
-.Fn sem_post
-returns 0. Otherwise, -1 is returned and
-.Va errno
-is set to indicate the type of
-error.
-.Sh ERRORS
-.Fn sem_post
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-.Fa sem
-points to an invalid semaphore.
-.El
-.Sh SEE ALSO
-.Xr sem_wait 3 ,
-.Xr sem_trywait 3
-.Sh STANDARDS
-.Fn sem_post
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 1996 Edition.
diff --git a/lib/libc/gen/sem_wait.3 b/lib/libc/gen/sem_wait.3
deleted file mode 100644
index c60c8ee6cc67..000000000000
--- a/lib/libc/gen/sem_wait.3
+++ /dev/null
@@ -1,92 +0,0 @@
-.\" Copyright (C) 2000 Jason Evans <jasone@canonware.com>.
-.\" 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(s), this list of conditions and the following disclaimer as
-.\" the first lines of this file unmodified other than the possible
-.\" addition of one or more copyright notices.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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.
-.\"
-.\" $FreeBSD$
-.Dd February 15, 2000
-.Dt SEM_WAIT 3
-.Os
-.Sh NAME
-.Nm sem_wait ,
-.Nm sem_trywait
-.Nd decrement (lock) a semaphore
-.Sh SYNOPSIS
-.Fd #include <semaphore.h>
-.Ft int
-.Fn sem_wait "sem_t *sem"
-.Ft int
-.Fn sem_trywait "sem_t *sem"
-.Sh DESCRIPTION
-The
-.Fn sem_wait
-function decrements (locks) the semaphore pointed to by
-.Fa sem ,
-but blocks if the value of
-.Fa sem
-is zero, until the value is non-zero and the value can be decremented.
-.Pp
-The
-.Fn sem_trywait
-function decrements (locks) the semaphore pointed to by
-.Fa sem
-only if the value is non-zero. Otherwise, the semaphore is not decremented and
-an error is returned.
-.Sh RETURN VALUES
-If successful,
-.Fn sem_wait
-and
-.Fn sem_trywait
-return 0. Otherwise, -1 is returned and
-.Va errno
-is set to indicate the type of
-error.
-.Sh ERRORS
-.Fn sem_wait
-and
-.Fn sem_trywait
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-.Fa sem
-points to an invalid semaphore.
-.El
-.Pp
-Additionally,
-.Fn sem_trywait
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EAGAIN
-The semaphore value was zero, and thus could not be decremented.
-.El
-.Sh SEE ALSO
-.Xr sem_post 3
-.Sh STANDARDS
-.Fn sem_wait
-and
-.Fn sem_trywait
-conform to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 1996 Edition.
diff --git a/lib/libc/gen/setflagsbyname.3 b/lib/libc/gen/setflagsbyname.3
deleted file mode 100644
index 09c6208c3b08..000000000000
--- a/lib/libc/gen/setflagsbyname.3
+++ /dev/null
@@ -1,78 +0,0 @@
-.\" Copyright (c) 1989, 1991, 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. 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, Berkeley and its contributors.
-.\" 4. 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.
-.\"
-.\" @(#)setmode.3 8.2 (Berkeley) 4/28/95
-.\" $FreeBSD$
-.\"
-.Dd January 1, 2000
-.Dt SETFLAGS 3
-.Os
-.Sh NAME
-.Nm getflags ,
-.Nm setflags
-.Nd modify file flag bits
-.Sh SYNOPSIS
-.Fd #include <unistd.h>
-.Ft char *
-.Fn getflags "u_long flags" "char *def"
-.Ft int
-.Fn setflags "char **stringp" "u_long *setp" "u_long *clrp"
-.Sh DESCRIPTION
-The
-.Fn getflags
-function returns a comma separated string of the file flags represented by
-.Fa flags .
-If no flags are set the string
-.Fa def
-is returned instead.
-.Pp
-The
-.Fn setflags
-function takes a string of file flags, as described in
-.Xr chflags 1 ,
-parses it, and returns the 'set' flags and 'clear' flags
-such as would be given as arguments to
-.Xr chflags 2 .
-On success
-.Fn setflags
-returns 0, otherwise it returns non-zero and
-.Fa stringp
-is left pointing to the offending token.
-.Sh SEE ALSO
-.Xr chflags 1 ,
-.Xr chflags 2 ,
-.Sh HISTORY
-The
-.Fn getflags
-and
-.Fn setflags
-functions first appeared in
-.Fx 4.0 .
diff --git a/lib/libc/gen/setflagsbyname.c b/lib/libc/gen/setflagsbyname.c
deleted file mode 100644
index c1fe6c56adeb..000000000000
--- a/lib/libc/gen/setflagsbyname.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/*-
- * Copyright (c) 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-#if 0
-static char sccsid[] = "@(#)stat_flags.c 8.1 (Berkeley) 5/31/93";
-#else
-static const char rcsid[] =
- "$FreeBSD$";
-#endif
-#endif /* not lint */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include <stddef.h>
-#include <string.h>
-
-static struct {
- char *name;
- u_long flag;
- int invert;
-} mapping[] = {
- /* shorter names per flag first, all prefixed by "no" */
- { "nosappnd", SF_APPEND, 0 },
- { "nosappend", SF_APPEND, 0 },
- { "noarch", SF_ARCHIVED, 0 },
- { "noarchived", SF_ARCHIVED, 0 },
- { "noschg", SF_IMMUTABLE, 0 },
- { "noschange", SF_IMMUTABLE, 0 },
- { "nosimmutable", SF_IMMUTABLE, 0 },
- { "nosunlnk", SF_NOUNLINK, 0 },
- { "nosunlink", SF_NOUNLINK, 0 },
- { "nouappnd", UF_APPEND, 0 },
- { "nouappend", UF_APPEND, 0 },
- { "nouchg", UF_IMMUTABLE, 0 },
- { "nouchange", UF_IMMUTABLE, 0 },
- { "nouimmutable", UF_IMMUTABLE, 0 },
- { "nodump", UF_NODUMP, 1 },
- { "noopaque", UF_OPAQUE, 0 },
- { "nouunlnk", UF_NOUNLINK, 0 },
- { "nouunlink", UF_NOUNLINK, 0 }
-};
-#define nmappings (sizeof(mapping) / sizeof(mapping[0]))
-
-/*
- * getflags --
- * Convert stat flags to a comma-separated string. If no flags
- * are set, return the default string.
- */
-char *
-getflags(flags, def)
- u_long flags;
- char *def;
-{
- static char string[128];
- char *sp, *dp;
- u_long setflags;
- int i;
-
- setflags = flags;
- dp = string;
- for (i = 0; i < nmappings; i++) {
- if (setflags & mapping[i].flag) {
- if (dp > string)
- *dp++ = ',';
- for (sp = mapping[i].invert ? mapping[i].name :
- mapping[i].name + 2; *sp; *dp++ = *sp++) ;
- setflags &= ~mapping[i].flag;
- }
- }
- *dp = '\0';
- return (dp == string && def != NULL ? def : string);
-}
-
-/*
- * setflags --
- * Take string of arguments and return stat flags. Return 0 on
- * success, 1 on failure. On failure, stringp is set to point
- * to the offending token.
- */
-int
-setflags(stringp, setp, clrp)
- char **stringp;
- u_long *setp, *clrp;
-{
- char *string, *p;
- int i;
-
- if (setp)
- *setp = 0;
- if (clrp)
- *clrp = 0;
- string = *stringp;
- while ((p = strsep(&string, "\t ,")) != NULL) {
- *stringp = p;
- if (*p == '\0')
- continue;
- for (i = 0; i < nmappings; i++) {
- if (strcmp(p, mapping[i].name + 2) == 0) {
- if (mapping[i].invert) {
- if (clrp)
- *clrp |= mapping[i].flag;
- } else {
- if (setp)
- *setp |= mapping[i].flag;
- }
- break;
- } else if (strcmp(p, mapping[i].name) == 0) {
- if (mapping[i].invert) {
- if (setp)
- *setp |= mapping[i].flag;
- } else {
- if (clrp)
- *clrp |= mapping[i].flag;
- }
- break;
- }
- }
- if (i == nmappings)
- return 1;
- }
- return 0;
-}
diff --git a/lib/libc/gen/setproctitle.3 b/lib/libc/gen/setproctitle.3
deleted file mode 100644
index 10eae654736a..000000000000
--- a/lib/libc/gen/setproctitle.3
+++ /dev/null
@@ -1,101 +0,0 @@
-.\" Copyright (c) 1995 Peter Wemm <peter@freebsd.org>
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, is permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice immediately at the beginning of the file, without modification,
-.\" 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. This work was done expressly for inclusion into FreeBSD. Other use
-.\" is permitted provided this notation is included.
-.\" 4. Absolutely no warranty of function or purpose is made by the author
-.\" Peter Wemm.
-.\" 5. Modifications may be freely made to this file providing the above
-.\" conditions are met.
-.\"
-.\" $FreeBSD$
-.\"
-.\" The following requests are required for all man pages.
-.Dd December 16, 1995
-.Os FreeBSD
-.Dt SETPROCTITLE 3
-.Sh NAME
-.Nm setproctitle
-.Nd set the process title for
-.Xr ps 1
-.Sh SYNOPSIS
-.Fd #include <sys/types.h>
-.Fd #include <libutil.h>
-.Ft void
-.Fn setproctitle "const char *fmt" "..."
-.Pp
-Link with
-.Va -lutil
-on the
-.Xr cc 1
-command line.
-.Sh DESCRIPTION
-The
-.Fn setproctitle
-library routine sets the process title that appears on the
-.Xr ps 1
-command.
-.Pp
-The title is set from the executable's name, followed by the
-result of a
-.Xr printf 3
-style expansion of the arguments as specified by the
-.Va fmt
-argument.
-.Pp
-If
-.Va fmt
-is NULL, the process title is restored.
-.Sh EXAMPLES
-To set the title on a daemon to indicate its activity:
-.Bd -literal -offset indent
-setproctitle("talking to %s", inet_ntoa(addr));
-.Ed
-.Sh SEE ALSO
-.Xr ps 1 ,
-.Xr w 1 ,
-.Xr kvm 3 ,
-.Xr kvm_getargv 3 ,
-.Xr printf 3
-.Sh STANDARDS
-.Fn setproctitle
-is implicitly non-standard. Other methods of causing the
-.Xr ps 1
-command line to change, including copying over the argv[0] string are
-also implicitly non-portable. It is preferable to use an operating system
-supplied
-.Fn setproctitle
-if present.
-.Pp
-Unfortunately, it is possible that there are other calling conventions
-to other versions of
-.Fn setproctitle ,
-although none have been found by the author as yet. This is believed to be
-the predominant convention.
-.Pp
-It is thought that the implementation is compatible with other systems,
-including
-.Nx
-and
-.Tn BSD/OS .
-.Sh HISTORY
-.Fn setproctitle
-first appeared in
-.Fx 2.2 .
-Other operating systems have
-similar functions.
-.Sh AUTHORS
-.An Peter Wemm Aq peter@FreeBSD.org
-stole the idea from the
-.Sy "Sendmail 8.7.3"
-source code by
-.An Eric Allman Aq eric@sendmail.org .
diff --git a/lib/libc/gen/setproctitle.c b/lib/libc/gen/setproctitle.c
deleted file mode 100644
index 37b9fab52b3a..000000000000
--- a/lib/libc/gen/setproctitle.c
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Copyright (c) 1995 Peter Wemm <peter@freebsd.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, is permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice immediately at the beginning of the file, without modification,
- * 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. Absolutely no warranty of function or purpose is made by the author
- * Peter Wemm.
- *
- * $FreeBSD$
- */
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/exec.h>
-#include <sys/sysctl.h>
-
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <vm/pmap.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-/*
- * Older FreeBSD 2.0, 2.1 and 2.2 had different ps_strings structures and
- * in different locations.
- * 1: old_ps_strings at the very top of the stack.
- * 2: old_ps_strings at SPARE_USRSPACE below the top of the stack.
- * 3: ps_strings at the very top of the stack.
- * This attempts to support a kernel built in the #2 and #3 era.
- */
-
-struct old_ps_strings {
- char *old_ps_argvstr;
- int old_ps_nargvstr;
- char *old_ps_envstr;
- int old_ps_nenvstr;
-};
-#define OLD_PS_STRINGS ((struct old_ps_strings *) \
- (USRSTACK - SPARE_USRSPACE - sizeof(struct old_ps_strings)))
-
-#if defined(__STDC__) /* from other parts of sendmail */
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-
-#define SPT_BUFSIZE 2048 /* from other parts of sendmail */
-extern char * __progname; /* is this defined in a .h anywhere? */
-
-void
-#if defined(__STDC__)
-setproctitle(const char *fmt, ...)
-#else
-setproctitle(fmt, va_alist)
- const char *fmt;
- va_dcl
-#endif
-{
- static struct ps_strings *ps_strings;
- static char buf[SPT_BUFSIZE];
- static char obuf[SPT_BUFSIZE];
- static char **oargv, *kbuf;
- static int oargc = -1;
- static char *nargv[2] = { buf, NULL };
- char **nargvp;
- int nargc;
- va_list ap;
- size_t len;
- unsigned long ul_ps_strings;
- int oid[4];
-
-#if defined(__STDC__)
- va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
-
- if (fmt) {
- buf[sizeof(buf) - 1] = '\0';
-
- /* print program name heading for grep */
- (void) snprintf(buf, sizeof(buf), "%s: ", __progname);
-
- /*
- * can't use return from sprintf, as that is the count of how
- * much it wanted to write, not how much it actually did.
- */
-
- len = strlen(buf);
-
- /* print the argument string */
- (void) vsnprintf(buf + len, sizeof(buf) - len, fmt, ap);
-
- nargvp = nargv;
- nargc = 1;
- kbuf = buf;
- } else if (*obuf != '\0') {
- /* Idea from NetBSD - reset the title on fmt == NULL */
- nargvp = oargv;
- nargc = oargc;
- kbuf = obuf;
- } else
- /* Nothing to restore */
- return;
-
- va_end(ap);
-
- /* Set the title into the kernel cached command line */
- oid[0] = CTL_KERN;
- oid[1] = KERN_PROC;
- oid[2] = KERN_PROC_ARGS;
- oid[3] = getpid();
- sysctl(oid, 4, 0, 0, kbuf, strlen(kbuf) + 1);
-
- if (ps_strings == NULL) {
- len = sizeof(ul_ps_strings);
- if (sysctlbyname("kern.ps_strings", &ul_ps_strings, &len, NULL,
- 0) == -1)
- ul_ps_strings = PS_STRINGS;
- ps_strings = (struct ps_strings *)ul_ps_strings;
- }
-
- /* PS_STRINGS points to zeroed memory on a style #2 kernel */
- if (ps_strings->ps_argvstr) {
- /* style #3 */
- if (oargc == -1) {
- /* Record our original args */
- oargc = ps_strings->ps_nargvstr;
- oargv = ps_strings->ps_argvstr;
- for (nargc = len = 0; nargc < oargc; nargc++) {
- snprintf(obuf + len, sizeof(obuf) - len, "%s%s",
- len ? " " : "", oargv[nargc]);
- if (len)
- len++;
- len += strlen(oargv[nargc]);
- if (len >= sizeof(obuf))
- break;
- }
- }
- ps_strings->ps_nargvstr = nargc;
- ps_strings->ps_argvstr = nargvp;
- } else {
- /* style #2 - we can only restore our first arg :-( */
- if (*obuf == '\0')
- strncpy(obuf, OLD_PS_STRINGS->old_ps_argvstr,
- sizeof(obuf) - 1);
- OLD_PS_STRINGS->old_ps_nargvstr = 1;
- OLD_PS_STRINGS->old_ps_argvstr = nargvp[0];
- }
-}
diff --git a/lib/libc/gen/strtofflags.3 b/lib/libc/gen/strtofflags.3
deleted file mode 100644
index 09c6208c3b08..000000000000
--- a/lib/libc/gen/strtofflags.3
+++ /dev/null
@@ -1,78 +0,0 @@
-.\" Copyright (c) 1989, 1991, 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. 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, Berkeley and its contributors.
-.\" 4. 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.
-.\"
-.\" @(#)setmode.3 8.2 (Berkeley) 4/28/95
-.\" $FreeBSD$
-.\"
-.Dd January 1, 2000
-.Dt SETFLAGS 3
-.Os
-.Sh NAME
-.Nm getflags ,
-.Nm setflags
-.Nd modify file flag bits
-.Sh SYNOPSIS
-.Fd #include <unistd.h>
-.Ft char *
-.Fn getflags "u_long flags" "char *def"
-.Ft int
-.Fn setflags "char **stringp" "u_long *setp" "u_long *clrp"
-.Sh DESCRIPTION
-The
-.Fn getflags
-function returns a comma separated string of the file flags represented by
-.Fa flags .
-If no flags are set the string
-.Fa def
-is returned instead.
-.Pp
-The
-.Fn setflags
-function takes a string of file flags, as described in
-.Xr chflags 1 ,
-parses it, and returns the 'set' flags and 'clear' flags
-such as would be given as arguments to
-.Xr chflags 2 .
-On success
-.Fn setflags
-returns 0, otherwise it returns non-zero and
-.Fa stringp
-is left pointing to the offending token.
-.Sh SEE ALSO
-.Xr chflags 1 ,
-.Xr chflags 2 ,
-.Sh HISTORY
-The
-.Fn getflags
-and
-.Fn setflags
-functions first appeared in
-.Fx 4.0 .
diff --git a/lib/libc/gen/strtofflags.c b/lib/libc/gen/strtofflags.c
deleted file mode 100644
index c1fe6c56adeb..000000000000
--- a/lib/libc/gen/strtofflags.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/*-
- * Copyright (c) 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-#if 0
-static char sccsid[] = "@(#)stat_flags.c 8.1 (Berkeley) 5/31/93";
-#else
-static const char rcsid[] =
- "$FreeBSD$";
-#endif
-#endif /* not lint */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include <stddef.h>
-#include <string.h>
-
-static struct {
- char *name;
- u_long flag;
- int invert;
-} mapping[] = {
- /* shorter names per flag first, all prefixed by "no" */
- { "nosappnd", SF_APPEND, 0 },
- { "nosappend", SF_APPEND, 0 },
- { "noarch", SF_ARCHIVED, 0 },
- { "noarchived", SF_ARCHIVED, 0 },
- { "noschg", SF_IMMUTABLE, 0 },
- { "noschange", SF_IMMUTABLE, 0 },
- { "nosimmutable", SF_IMMUTABLE, 0 },
- { "nosunlnk", SF_NOUNLINK, 0 },
- { "nosunlink", SF_NOUNLINK, 0 },
- { "nouappnd", UF_APPEND, 0 },
- { "nouappend", UF_APPEND, 0 },
- { "nouchg", UF_IMMUTABLE, 0 },
- { "nouchange", UF_IMMUTABLE, 0 },
- { "nouimmutable", UF_IMMUTABLE, 0 },
- { "nodump", UF_NODUMP, 1 },
- { "noopaque", UF_OPAQUE, 0 },
- { "nouunlnk", UF_NOUNLINK, 0 },
- { "nouunlink", UF_NOUNLINK, 0 }
-};
-#define nmappings (sizeof(mapping) / sizeof(mapping[0]))
-
-/*
- * getflags --
- * Convert stat flags to a comma-separated string. If no flags
- * are set, return the default string.
- */
-char *
-getflags(flags, def)
- u_long flags;
- char *def;
-{
- static char string[128];
- char *sp, *dp;
- u_long setflags;
- int i;
-
- setflags = flags;
- dp = string;
- for (i = 0; i < nmappings; i++) {
- if (setflags & mapping[i].flag) {
- if (dp > string)
- *dp++ = ',';
- for (sp = mapping[i].invert ? mapping[i].name :
- mapping[i].name + 2; *sp; *dp++ = *sp++) ;
- setflags &= ~mapping[i].flag;
- }
- }
- *dp = '\0';
- return (dp == string && def != NULL ? def : string);
-}
-
-/*
- * setflags --
- * Take string of arguments and return stat flags. Return 0 on
- * success, 1 on failure. On failure, stringp is set to point
- * to the offending token.
- */
-int
-setflags(stringp, setp, clrp)
- char **stringp;
- u_long *setp, *clrp;
-{
- char *string, *p;
- int i;
-
- if (setp)
- *setp = 0;
- if (clrp)
- *clrp = 0;
- string = *stringp;
- while ((p = strsep(&string, "\t ,")) != NULL) {
- *stringp = p;
- if (*p == '\0')
- continue;
- for (i = 0; i < nmappings; i++) {
- if (strcmp(p, mapping[i].name + 2) == 0) {
- if (mapping[i].invert) {
- if (clrp)
- *clrp |= mapping[i].flag;
- } else {
- if (setp)
- *setp |= mapping[i].flag;
- }
- break;
- } else if (strcmp(p, mapping[i].name) == 0) {
- if (mapping[i].invert) {
- if (setp)
- *setp |= mapping[i].flag;
- } else {
- if (clrp)
- *clrp |= mapping[i].flag;
- }
- break;
- }
- }
- if (i == nmappings)
- return 1;
- }
- return 0;
-}
diff --git a/lib/libc/locale/euc.5 b/lib/libc/locale/euc.5
deleted file mode 100644
index ce319ba37ff4..000000000000
--- a/lib/libc/locale/euc.5
+++ /dev/null
@@ -1,242 +0,0 @@
-.\" Copyright (c) 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" This code is derived from software contributed to Berkeley by
-.\" Paul Borman at Krystal Technologies.
-.\"
-.\" 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 the University of
-.\" California, Berkeley and its contributors.
-.\" 4. 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.
-.\"
-.\" @(#)euc.4 8.1 (Berkeley) 6/4/93
-.\" $FreeBSD$
-.\"
-.Dd June 4, 1993
-.Dt EUC 4
-.Os
-.Sh NAME
-.Nm euc
-.Nd EUC encoding of runes
-.Sh SYNOPSIS
-.Nm ENCODING
-.Qq EUC
-.Pp
-.Nm VARIABLE
-.Ar len1
-.Ar mask1
-.Ar len2
-.Ar mask2
-.Ar len3
-.Ar mask3
-.Ar len4
-.Ar mask4
-.Ar mask
-.Sh DESCRIPTION
-The
-.Nm EUC
-encoding is provided for compatibility with
-.Ux
-based systems.
-See
-.Xr mklocale 1
-for a complete description of the
-.Ev LC_CTYPE
-source file format.
-.Pp
-.Nm EUC
-implements a system of 4 multibyte codesets.
-A multibyte character in the first codeset consists of
-.Ar len1
-bytes starting with a byte in the range of 0x00 to 0x7f.
-To allow use of ASCII,
-.Ar len1
-is always 1.
-A multibyte character in the second codeset consists of
-.Ar len2
-bytes starting with a byte in the range of 0x80-0xff excluding 0x8e and 0x8f.
-A multibyte character in the third codeset consists of
-.Ar len3
-bytes starting with the byte 0x8e.
-A multibyte character in the fourth codeset consists of
-.Ar len4
-bytes starting with the byte 0x8f.
-.Pp
-The
-.Ev rune_t
-encoding of
-.Nm EUC
-multibyte characters is dependent on the
-.Ar len
-and
-.Ar mask
-arguments.
-First, the bytes are moved into a
-.Ev rune_t
-as follows:
-.Bd -literal
-byte0 << ((\fIlen\fPN-1) * 8) | byte1 << ((\fIlen\fPN-2) * 8) | ... | byte\fIlen\fPN-1
-.Ed
-.Pp
-The result is then ANDed with
-.Ar ~mask
-and ORed with
-.Ar maskN .
-Codesets 2 and 3 are special in that the leading byte (0x8e or 0x8f) is
-first removed and the
-.Ar lenN
-argument is reduced by 1.
-.Pp
-For example, the Japanese locale has the following
-.Ev VARIABLE
-line:
-.Bd -literal
-VARIABLE 1 0x0000 2 0x8080 2 0x0080 3 0x8000 0x8080
-.Ed
-.Pp
-Codeset 1 consists of the values 0x0000 - 0x007f.
-.Pp
-Codeset 2 consists of the values who have the bits 0x8080 set.
-.Pp
-Codeset 3 consists of the values 0x0080 - 0x00ff.
-.Pp
-Codeset 4 consists of the values 0x8000 - 0xff7f excluding the values
-which have the 0x0080 bit set.
-.Pp
-Notice that the global
-.Ar mask
-is set to 0x8080, this implies that from those 2 bits the codeset can
-be determined.
-.Sh "EXAMPLE - Japanese Locale"
-This is a complete example of an
-.Ev LC_CTYPE
-source file for the Japanese locale
-.Bd -literal
-/*
- * Japanese LOCALE_CTYPE definitions using EUC of JIS character sets
- */
-
-ENCODING "EUC"
-
-/* JIS JIS JIS */
-/* X201 X208 X201 */
-/* 00-7f 84-fe */
-
-VARIABLE 1 0x0000 2 0x8080 2 0x0080 3 0x8000 0x8080
-
-/*
- * Code Set 1
- */
-ALPHA 'A' - 'Z' 'a' - 'z'
-CONTROL 0x00 - 0x1f 0x7f
-DIGIT '0' - '9'
-GRAPH 0x21 - 0x7e
-LOWER 'a' - 'z'
-PUNCT 0x21 - 0x2f 0x3a - 0x40 0x5b - 0x60 0x7b - 0x7e
-SPACE 0x09 - 0x0d 0x20
-UPPER 'A' - 'Z'
-XDIGIT 'a' - 'f' 'A' - 'F'
-BLANK ' ' '\t'
-PRINT 0x20 - 0x7e
-
-MAPLOWER < 'A' - 'Z' : 'a' > < 'a' - 'z' : 'a' >
-MAPUPPER < 'A' - 'Z' : 'A' > < 'a' - 'z' : 'A' >
-TODIGIT < '0' - '9' : 0 >
-TODIGIT < 'A' - 'F' : 10 > < 'a' - 'f' : 10 >
-
-/*
- * Code Set 2
- */
-
-SPACE 0xa1a1
-PHONOGRAM 0xa1bc
-SPECIAL 0xa1a2 - 0xa1fe
-PUNCT 0xa1a2 - 0xa1f8 /* A few too many in here... */
-
-SPECIAL 0xa2a1 - 0xa2ae 0xa2ba - 0xa2c1 0xa2ca - 0xa2d0 0xa2dc - 0xa2ea
-SPECIAL 0xa2f2 - 0xa2f9 0xa2fe
-
-DIGIT 0xa3b0 - 0xa3b9
-UPPER 0xa3c1 - 0xa3da /* Romaji */
-LOWER 0xa3e1 - 0xa3fa /* Romaji */
-MAPLOWER < 0xa3c1 - 0xa3da : 0xa3e1 > /* English */
-MAPLOWER < 0xa3e1 - 0xa3fa : 0xa3e1 > /* English */
-MAPUPPER < 0xa3c1 - 0xa3da : 0xa3c1 >
-MAPUPPER < 0xa3e1 - 0xa3fa : 0xa3c1 >
-
-XDIGIT 0xa3c1 - 0xa3c6 0xa3e1 - 0xa3e6
-
-TODIGIT < 0xa3b0 - 0xa3b9 : 0 >
-TODIGIT < 0xa3c1 - 0xa3c6 : 10 > < 0xa3e1 - 0xa3e6 : 10 >
-
-PHONOGRAM 0xa4a1 - 0xa4f3
-PHONOGRAM 0xa5a1 - 0xa5f6
-
-UPPER 0xa6a1 - 0xa6b8 /* Greek */
-LOWER 0xa6c1 - 0xa6d8 /* Greek */
-MAPLOWER < 0xa6a1 - 0xa6b8 : 0xa6c1 > < 0xa6c1 - 0xa6d8 : 0xa6c1 >
-MAPUPPER < 0xa6a1 - 0xa6b8 : 0xa6a1 > < 0xa6c1 - 0xa6d8 : 0xa6a1 >
-
-UPPER 0xa7a1 - 0xa7c1 /* Cyrillic */
-LOWER 0xa7d1 - 0xa7f1 /* Cyrillic */
-MAPLOWER < 0xa7a1 - 0xa7c1 : 0xa7d1 > < 0xa7d1 - 0xa7f1 : 0xa7d1 >
-MAPUPPER < 0xa7a1 - 0xa7c1 : 0xa7a1 > < 0xa7d1 - 0xa7f1 : 0xa7a1 >
-
-SPECIAL 0xa8a1 - 0xa8c0
-
-IDEOGRAM 0xb0a1 - 0xb0fe 0xb1a1 - 0xb1fe 0xb2a1 - 0xb2fe
-IDEOGRAM 0xb3a1 - 0xb3fe 0xb4a1 - 0xb4fe 0xb5a1 - 0xb5fe
-IDEOGRAM 0xb6a1 - 0xb6fe 0xb7a1 - 0xb7fe 0xb8a1 - 0xb8fe
-IDEOGRAM 0xb9a1 - 0xb9fe 0xbaa1 - 0xbafe 0xbba1 - 0xbbfe
-IDEOGRAM 0xbca1 - 0xbcfe 0xbda1 - 0xbdfe 0xbea1 - 0xbefe
-IDEOGRAM 0xbfa1 - 0xbffe 0xc0a1 - 0xc0fe 0xc1a1 - 0xc1fe
-IDEOGRAM 0xc2a1 - 0xc2fe 0xc3a1 - 0xc3fe 0xc4a1 - 0xc4fe
-IDEOGRAM 0xc5a1 - 0xc5fe 0xc6a1 - 0xc6fe 0xc7a1 - 0xc7fe
-IDEOGRAM 0xc8a1 - 0xc8fe 0xc9a1 - 0xc9fe 0xcaa1 - 0xcafe
-IDEOGRAM 0xcba1 - 0xcbfe 0xcca1 - 0xccfe 0xcda1 - 0xcdfe
-IDEOGRAM 0xcea1 - 0xcefe 0xcfa1 - 0xcfd3 0xd0a1 - 0xd0fe
-IDEOGRAM 0xd1a1 - 0xd1fe 0xd2a1 - 0xd2fe 0xd3a1 - 0xd3fe
-IDEOGRAM 0xd4a1 - 0xd4fe 0xd5a1 - 0xd5fe 0xd6a1 - 0xd6fe
-IDEOGRAM 0xd7a1 - 0xd7fe 0xd8a1 - 0xd8fe 0xd9a1 - 0xd9fe
-IDEOGRAM 0xdaa1 - 0xdafe 0xdba1 - 0xdbfe 0xdca1 - 0xdcfe
-IDEOGRAM 0xdda1 - 0xddfe 0xdea1 - 0xdefe 0xdfa1 - 0xdffe
-IDEOGRAM 0xe0a1 - 0xe0fe 0xe1a1 - 0xe1fe 0xe2a1 - 0xe2fe
-IDEOGRAM 0xe3a1 - 0xe3fe 0xe4a1 - 0xe4fe 0xe5a1 - 0xe5fe
-IDEOGRAM 0xe6a1 - 0xe6fe 0xe7a1 - 0xe7fe 0xe8a1 - 0xe8fe
-IDEOGRAM 0xe9a1 - 0xe9fe 0xeaa1 - 0xeafe 0xeba1 - 0xebfe
-IDEOGRAM 0xeca1 - 0xecfe 0xeda1 - 0xedfe 0xeea1 - 0xeefe
-IDEOGRAM 0xefa1 - 0xeffe 0xf0a1 - 0xf0fe 0xf1a1 - 0xf1fe
-IDEOGRAM 0xf2a1 - 0xf2fe 0xf3a1 - 0xf3fe 0xf4a1 - 0xf4a4
-/*
- * This is for Code Set 3, half-width kana
- */
-SPECIAL 0xa1 - 0xdf
-PHONOGRAM 0xa1 - 0xdf
-CONTROL 0x84 - 0x97 0x9b - 0x9f 0xe0 - 0xfe
-.Ed
-.Sh "SEE ALSO"
-.Xr mklocale 1 ,
-.Xr setlocale 3
diff --git a/lib/libc/locale/utf2.5 b/lib/libc/locale/utf2.5
deleted file mode 100644
index 3734dbab1669..000000000000
--- a/lib/libc/locale/utf2.5
+++ /dev/null
@@ -1,88 +0,0 @@
-.\" Copyright (c) 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" This code is derived from software contributed to Berkeley by
-.\" Paul Borman at Krystal Technologies.
-.\"
-.\" 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 the University of
-.\" California, Berkeley and its contributors.
-.\" 4. 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.
-.\"
-.\" @(#)utf2.4 8.1 (Berkeley) 6/4/93
-.\" $FreeBSD$
-.\"
-.Dd June 4, 1993
-.Dt UTF2 4
-.Os
-.Sh NAME
-.Nm utf2
-.Nd "Universal character set Transformation Format encoding of runes
-.Sh SYNOPSIS
-.Nm ENCODING
-.Qq UTF2
-.Sh DESCRIPTION
-The
-.Nm UTF2
-encoding is based on a proposed X-Open multibyte
-\s-1FSS-UCS-TF\s+1 (File System Safe Universal Character Set Transformation Format) encoding as used in
-.Nm Plan 9 from Bell Labs.
-Although it is capable of representing more than 16 bits,
-the current implementation is limited to 16 bits as defined by the
-Unicode Standard.
-.Pp
-.Nm UTF2
-representation is backwards compatible with ASCII, so 0x00-0x7f refer to the
-ASCII character set. The multibyte encoding of runes between 0x0080 and 0xffff
-consist entirely of bytes whose high order bit is set. The actual
-encoding is represented by the following table:
-.Bd -literal
-[0x0000 - 0x007f] [00000000.0bbbbbbb] -> 0bbbbbbb
-[0x0080 - 0x07ff] [00000bbb.bbbbbbbb] -> 110bbbbb, 10bbbbbb
-[0x0800 - 0xffff] [bbbbbbbb.bbbbbbbb] -> 1110bbbb, 10bbbbbb, 10bbbbbb
-.Ed
-.Pp
-If more than a single representation of a value exists (for example,
-0x00; 0xC0 0x80; 0xE0 0x80 0x80) the shortest representation is always
-used (but the longer ones will be correctly decoded).
-.Pp
-The final three encodings provided by X-Open:
-.Bd -literal
-[00000000.000bbbbb.bbbbbbbb.bbbbbbbb] ->
- 11110bbb, 10bbbbbb, 10bbbbbb, 10bbbbbb
-
-[000000bb.bbbbbbbb.bbbbbbbb.bbbbbbbb] ->
- 111110bb, 10bbbbbb, 10bbbbbb, 10bbbbbb, 10bbbbbb
-
-[0bbbbbbb.bbbbbbbb.bbbbbbbb.bbbbbbbb] ->
- 1111110b, 10bbbbbb, 10bbbbbb, 10bbbbbb, 10bbbbbb, 10bbbbbb
-.Ed
-.Pp
-which provides for the entire proposed ISO-10646 31 bit standard are currently
-not implemented.
-.Sh "SEE ALSO"
-.Xr mklocale 1 ,
-.Xr setlocale 3
diff --git a/lib/libc/posix1e/Makefile b/lib/libc/posix1e/Makefile
deleted file mode 100644
index 43a8a35b503f..000000000000
--- a/lib/libc/posix1e/Makefile
+++ /dev/null
@@ -1,38 +0,0 @@
-# $FreeBSD$
-
-LIB= posix1e
-SRCS+= acl_delete.c \
- acl_free.c \
- acl_from_text.c \
- acl_get.c \
- acl_init.c \
- acl_set.c \
- acl_support.c \
- acl_to_text.c \
- acl_valid.c
-
-MAN3= acl.3 \
- acl_delete.3 \
- acl_dup.3 \
- acl_free.3 \
- acl_from_text.3 \
- acl_get.3 \
- acl_init.3 \
- acl_set.3 \
- acl_to_text.3 \
- acl_valid.3 \
- posix1e.3
-
-MLINKS+=acl_delete.3 acl_delete_def_file.3 \
- acl_delete.3 acl_delete_file_np.3 \
- acl_delete.3 acl_delete_fd_np.3 \
- acl_get.3 acl_get_file.3 \
- acl_get.3 acl_get_fd.3 \
- acl_get.3 acl_get_fd_np.3 \
- acl_set.3 acl_set_file.3 \
- acl_set.3 acl_set_fd.3 \
- acl_set.3 acl_set_fd_np.3 \
- acl_valid.3 acl_valid_file_np.3 \
- acl_valid.3 acl_valid_fd_np.3
-
-.include <bsd.lib.mk>
diff --git a/lib/libc/posix1e/acl.3 b/lib/libc/posix1e/acl.3
deleted file mode 100644
index 20208fabeb15..000000000000
--- a/lib/libc/posix1e/acl.3
+++ /dev/null
@@ -1,180 +0,0 @@
-.\"-
-.\" Copyright (c) 2000 Robert N. M. Watson
-.\" 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 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd January 28, 2000
-.Dt ACL 3
-.Os FreeBSD 4.0
-.Sh NAME
-.Nm acl
-.Nd introduction to the POSIX.1e ACL security API
-.Sh SYNOPSIS
-.Fd #include <sys/types.h>
-.Fd #include <sys/acl.h>
-.Sh DESCRIPTION
-As shipped,
-.Fx 4.0
-permits file systems to export
-Access Control Lists via the VFS, and provides a library for userland
-access to and manipulation of these ACLs, but support for ACLs is not
-provided by any file systems shipped in the base operating system.
-The library calls shipped with 4.0 include routines to allocate,
-duplicate, retrieve, set, and validate ACLs associated with file objects.
-As well as the POSIX.1e routines, there are a number of non-portable
-extensions defined that allow for alternative ACL semantics than the
-POSIX.1e semantics, such as AFS, NTFS, Coda, and NWFS semantics. Where
-routines are non-standard, they are suffixed with _np to indicate that
-they are not portable.
-
-POSIX.1e describes a set of ACL manipulation routines to manage the
-contents of ACLs, as well as their relationships with files. This
-manipulation library is not currently implemented in FreeBSD, although
-a third party library was under development at the time this document
-was written. There is a general consensus that the POSIX.1e manipulation
-routines are ambiguously defined in the specification, and don't meet the
-needs of most applications. For the time being, applications may
-directly manipulate the ACL structures, defined in acl.h, although the
-recommended usage is to only ever handle text-form ACLs in applications,
-generated and maintained using
-.Fn acl_from_text
-and
-.Fn acl_to_text ,
-passed directly to and from the management routines. In this manner,
-an application can remain safely unaware of the contents of ACLs.
-
-Available functions, sorted by behavior, include:
-
-.Fn acl_delete_def_file ,
-.Fn acl_delete_file_np ,
-.Fn acl_delete_fd_np
-
-These functions are described in
-.Xr acl_delete 3 ,
-and may be used to delete ACLs from file system objects.
-
-.Fn acl_free
-
-This function is described in
-.Xr acl_free 3 ,
-and may be used to free userland working ACL storage.
-
-.Fn acl_from_text
-
-This function is described in
-.Xr acl_from_text 3 ,
-and may be used to convert a text-form ACL into working ACL state, if
-the ACL has POSIX.1e semantics.
-
-.Fn acl_get_file ,
-.Fn acl_get_fd ,
-.Fn acl_get_fd_np
-
-These functions are described in
-.Xr acl_get 3 ,
-and may be used to retrieve ACLs from file system objects.
-
-.Fn acl_init
-
-This function is described in
-.Xr acl_init 3 ,
-and may be used to allocate a fresh (empty) ACL structure.
-
-.Fn acl_dup
-
-This function is described in
-.Xr acl_dup 3 ,
-and may be used to duplicate an ACL structure.
-
-.Fn acl_set_file ,
-.Fn acl_set_fd ,
-.Fn acl_set_fd_np
-
-These functions are described in
-.Xr acl_set 3 ,
-and may be used to assign an ACL to a file system object.
-
-.Fn acl_to_text
-
-This function is described in
-.Xr acl_to_text 3 ,
-and may be used to generate a text-form of a POSIX.1e semantics ACL.
-
-.Fn acl_valid ,
-.Fn acl_valid_file_np ,
-.Fn acl_valid_fd_np
-
-Thee functions are described in
-.Xr acl_valid 3 ,
-and may be used to validate an ACL as correct POSIX.1e-semantics, or
-as appropriate for a particular file system object regardless of semantics.
-
-Documentation of the internal kernel interfaces backing these calls may
-be found in
-.Xr acl 9 .
-The syscalls between the internal interfaces and the public library
-routines may change over time, and as such are not documented. They are
-not intended to be called directly without going through the library.
-.Sh IMPLEMENTATION NOTES
-FreeBSD's support for POSIX.1e interfaces and features is still under
-development at this time.
-.Sh ENVIRONMENT
-POSIX.1e assigns security labels to all objects, extending the security
-functionality described in POSIX.1. These additional labels provide
-fine-grained discretionary access control, fine-grained capabilities,
-and labels necessary for mandatory access control. POSIX.2c describes
-a set of userland utilities for manipulating these labels. These userland
-utilities are not bundled with
-.Fx 4.0
-so as to discourage their
-use in the short term.
-.\" .Sh FILES
-.Sh SEE ALSO
-.Xr acl 3 ,
-.Xr acl_dup 3 ,
-.Xr acl_free 3 ,
-.Xr acl_from_text 3 ,
-.Xr acl_get 3 ,
-.Xr acl_set 3 ,
-.Xr acl_to_text 3 ,
-.Xr acl_valid 3 ,
-.Xr acl 9
-.Sh STANDARDS
-POSIX.1e is described in IEEE POSIX.1e draft 17. Discussion
-of the draft continues on the cross-platform POSIX.1e implementation
-mailing list. To join this list, see the
-.Fx
-POSIX.1e implementation
-page for more information.
-.Sh HISTORY
-POSIX.1e support was introduced in
-.Fx 4.0 ,
-and development continues.
-.Sh AUTHORS
-.An Robert N M Watson
-.Sh BUGS
-These features are not yet fully implemented. In particular, the shipped
-version of UFS/FFS does not support storage of additional security labels,
-and so is unable to (easily) provide support for most of these features.
diff --git a/lib/libc/posix1e/acl_delete.3 b/lib/libc/posix1e/acl_delete.3
deleted file mode 100644
index ef559d5f7533..000000000000
--- a/lib/libc/posix1e/acl_delete.3
+++ /dev/null
@@ -1,124 +0,0 @@
-.\"-
-.\" Copyright (c) 2000 Robert N. M. Watson
-.\" 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 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd January 28, 2000
-.Dt ACL_DELETE 3
-.Os FreeBSD 4.0
-.Sh NAME
-.Nm acl_delete_def_file ,
-.Nm acl_delete_file_np ,
-.Nm acl_delete_fd_np
-.Nd Delete an ACL from a file
-.Sh SYNOPSIS
-.Fd #include <sys/types.h>
-.Fd #include <sys/acl.h>
-.Ft int
-.Fn acl_delete_def_file "const char *path_p"
-.Ft int
-.Fn acl_delete_file_np "const char *path_p" "acl_type_t type"
-.Ft int
-.Fn acl_delete_fd_np "int filedes" "acl_type_t type"
-.Sh DESCRIPTION
-The
-.Fn acl_delete_def_file ,
-.Fn acl_delete_file_np ,
-and
-.Fn acl_delete_fd_np
-each allow the deletion of an ACL from a file.
-.Fn acl_delete_def_file
-is a POSIX.1e call that deletes the default ACL from a file (normally a
-directory) by name; the other two calls are non-portable extensions that
-allow deleting of arbitrary ACL types from a file/directory by either path
-name, or by file descriptor.
-.Sh IMPLEMENTATION NOTES
-FreeBSD's support for POSIX.1e interfaces and features is still under
-development at this time.
-.Sh RETURN VALUES
-In the event of success, 0 is returned. In the event of failure, -1 is
-returned, and
-.Va errno
-is set to indicate the error.
-.Sh ERRORS
-If any of the following conditions occur, these functions shall return -1
-and set
-.Va errno
-to the corresponding value:
-.Bl -tag -width Er
-.It Bq Er EACCES
-Search permission is denied for a component of the path prefix, or the
-object exists and the process does not have appropriate access rights.
-.It Bq Er EBADF
-The
-.Va fd
-argument is not a valid file descriptor.
-.It Bq Er EINVAL
-The ACL type passed is invalid for this file object.
-.It Bq Er ENAMETOOLONG
-A component of a pathname exceeded 255 characters, or an
-entire path name exceeded 1023 characters.
-.It Bq Er ENOENT
-The named object does not exist, or the
-.Va path_p
-argument points to an empty string.
-.It Bq Er ENOMEM
-Insufficient memory available to fulfill request.
-.It Bq Er ENOTDIR
-A component of the path prefix is not a directory.
-
-Argument
-.Va path_p
-must be a directory, and is not.
-.It Bq Er EOPNOTSUPP
-The file system does not support ACL deletion.
-.It Bq Er EPERM
-The process does not have appropriate privilege to perform the operation
-to delete an ACL.
-.It Bq Er EROFS
-The file system is read-only.
-.El
-.Sh SEE ALSO
-.Xr acl 3 ,
-.Xr acl_get 3 ,
-.Xr acl_set 3 ,
-.Xr posix1e 3
-.Sh STANDARDS
-POSIX.1e is described in IEEE POSIX.1e draft 17. Discussion
-of the draft continues on the cross-platform POSIX.1e implementation
-mailing list. To join this list, see the
-.Fx
-POSIX.1e implementation
-page for more information.
-.Sh HISTORY
-POSIX.1e support was introduced in
-.Fx 4.0 ,
-and development continues.
-.Sh AUTHORS
-.An Robert N M Watson
-.Sh BUGS
-These features are not yet fully implemented. In particular, the shipped
-version of UFS/FFS does not support storage of additional security labels,
-and so is unable to (easily) provide support for most of these features.
diff --git a/lib/libc/posix1e/acl_delete.c b/lib/libc/posix1e/acl_delete.c
deleted file mode 100644
index 8998400a0585..000000000000
--- a/lib/libc/posix1e/acl_delete.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*-
- * Copyright (c) 1999 Robert N. M. Watson
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-/*
- * acl_delete_def_file -- remove a default acl from a file
- */
-
-#include <sys/types.h>
-#include <sys/acl.h>
-#include <sys/errno.h>
-
-int
-acl_delete_def_file(const char *path_p)
-{
-
- return (__acl_delete_file(path_p, ACL_TYPE_DEFAULT));
-}
-
-
-int
-acl_delete_file_np(const char *path_p, acl_type_t type)
-{
-
- return (__acl_delete_file(path_p, type));
-}
-
-
-int
-acl_delete_fd_np(int filedes, acl_type_t type)
-{
-
- return (__acl_delete_fd(filedes, type));
-}
diff --git a/lib/libc/posix1e/acl_dup.3 b/lib/libc/posix1e/acl_dup.3
deleted file mode 100644
index aaceb54f7764..000000000000
--- a/lib/libc/posix1e/acl_dup.3
+++ /dev/null
@@ -1,105 +0,0 @@
-.\"-
-.\" Copyright (c) 2000 Robert N. M. Watson
-.\" 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 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd January 28, 2000
-.Dt ACL_DUP 3
-.Os FreeBSD 4.0
-.Sh NAME
-.Nm acl_dup
-.Nd Duplicate an ACL
-.Sh SYNOPSIS
-.Fd #include <sys/types.h>
-.Fd #include <sys/acl.h>
-.Ft acl_t
-.Fn acl_dup "acl_t acl"
-.Sh DESCRIPTION
-The
-.Fn acl_dup
-function returns a pointer to a copy of the ACL pointed to by the argument
-.Va acl .
-
-This function may cause memory to be allocated. The caller should free any
-releasable memory, when the new ACL is no longer required, by calling
-.Xr acl_free 3
-with the
-.Va (void*)acl_t
-as an argument.
-
-Any existing ACL pointers that refer to the ACL referred to by
-.Va acl
-shall continue to refer to the ACL.
-.Sh IMPLEMENTATION NOTES
-FreeBSD's support for POSIX.1e interfaces and features is still under
-development at this time.
-.Sh RETURN VALUES
-Upon successful completion, this function shall return a pointer to the
-duplicate ACL. Otherwise, a value of
-.Va (acl_t)NULL
-shall be returned, and
-.Va errno
-shall be set to indicate the error.
-.Sh ERRORS
-If any of the following conditions occur, the
-.Fn acl_init
-function shall return a value of
-.Va (acl_t)NULL
-and set
-.Va errno
-to the corresponding value:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-Argument
-.Va acl
-does not point to a valid ACL.
-.It Bq Er ENOMEM
-The
-.Va acl_t
-to be returned requires more memory than is allowed by the hardware or
-system-imposed memory management constraints.
-.El
-.Sh SEE ALSO
-.Xr acl 3 ,
-.Xr acl_free 3 ,
-.Xr acl_get 3 ,
-.Xr posix1e 3
-.Sh STANDARDS
-POSIX.1e is described in IEEE POSIX.1e draft 17. Discussion
-of the draft continues on the cross-platform POSIX.1e implementation
-mailing list. To join this list, see the
-.Fx
-POSIX.1e implementation
-page for more information.
-.Sh HISTORY
-POSIX.1e support was introduced in
-.Fx 4.0 ,
-and development continues.
-.Sh AUTHORS
-.An Robert N M Watson
-.Sh BUGS
-These features are not yet fully implemented. In particular, the shipped
-version of UFS/FFS does not support storage of additional security labels,
-and so is unable to (easily) provide support for most of these features.
diff --git a/lib/libc/posix1e/acl_free.3 b/lib/libc/posix1e/acl_free.3
deleted file mode 100644
index e02569b264a6..000000000000
--- a/lib/libc/posix1e/acl_free.3
+++ /dev/null
@@ -1,89 +0,0 @@
-.\"-
-.\" Copyright (c) 2000 Robert N. M. Watson
-.\" 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 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd January 28, 2000
-.Dt ACL_FREE 3
-.Os FreeBSD 4.0
-.Sh NAME
-.Nm acl_free
-.Nd Free ACL working state
-.Sh SYNOPSIS
-.Fd #include <sys/types.h>
-.Fd #include <sys/acl.h>
-.Ft int
-.Fn acl_free "void *obj_p"
-.Sh DESCRIPTION
-The
-.Fn acl_free
-call allows the freeing of ACL working space, such as is allocated by
-.Xr acl_dup 3 ,
-or
-.Xr acl_from_text 3 .
-.Sh IMPLEMENTATION NOTES
-FreeBSD's support for POSIX.1e interfaces and features is still under
-development at this time.
-.Sh RETURN VALUES
-In the event of success, 0 is returned. In the event of failure, -1 is
-returned, and
-.Va errno
-is set to indicate the error.
-.Sh ERRORS
-If any of the following conditions occur, the
-.Fn acl_free
-function shall return -1 and set
-.Va errno
-to the corresponding value:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The value of the
-.Va obj_p
-argument is invalid.
-.El
-.Sh SEE ALSO
-.Xr acl 3 ,
-.Xr acl_dup 3 ,
-.Xr acl_from_text 3 ,
-.Xr acl_get 3 ,
-.Xr acl_init 3 ,
-.Xr posix1e 3
-.Sh STANDARDS
-POSIX.1e is described in IEEE POSIX.1e draft 17. Discussion
-of the draft continues on the cross-platform POSIX.1e implementation
-mailing list. To join this list, see the
-.Fx
-POSIX.1e implementation
-page for more information.
-.Sh HISTORY
-POSIX.1e support was introduced in
-.Fx 4.0 ,
-and development continues.
-.Sh AUTHORS
-.An Robert N M Watson
-.Sh BUGS
-These features are not yet fully implemented. In particular, the shipped
-version of UFS/FFS does not support storage of additional security labels,
-and so is unable to (easily) provide support for most of these features.
diff --git a/lib/libc/posix1e/acl_free.c b/lib/libc/posix1e/acl_free.c
deleted file mode 100644
index 74b7238be966..000000000000
--- a/lib/libc/posix1e/acl_free.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/*-
- * Copyright (c) 1999 Robert N. M. Watson
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-/*
- * acl_free -- free ACL objects from user memory
- */
-
-#include <sys/types.h>
-#include <sys/acl.h>
-#include <sys/errno.h>
-#include <stdlib.h>
-
-int
-acl_free(void *obj_p)
-{
-
- free(obj_p);
- return (0);
-}
diff --git a/lib/libc/posix1e/acl_from_text.3 b/lib/libc/posix1e/acl_from_text.3
deleted file mode 100644
index 776376163284..000000000000
--- a/lib/libc/posix1e/acl_from_text.3
+++ /dev/null
@@ -1,125 +0,0 @@
-.\"-
-.\" Copyright (c) 2000 Robert N. M. Watson
-.\" 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 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd January 28, 2000
-.Dt ACL_FROM_TEXT 3
-.Os FreeBSD 4.0
-.Sh NAME
-.Nm acl_from_text
-.Nd Create an ACL from text
-.Sh SYNOPSIS
-.Fd #include <sys/types.h>
-.Fd #include <sys/acl.h>
-.Ft acl_t
-.Fn acl_from_text "const char *buf_p"
-.Sh DESCRIPTION
-The
-.Fn acl_from_text
-function converts the text form of an ACL referred to by
-.Va buf_p
-into the internal working structure for ACLs, appropriate for applying to
-files or manipulating.
-
-This function may cause memory to be allocated. The caller should free any
-releasable memory, when the new ACL is no longer required, by calling
-.Xr acl_free 3
-with the
-.Va (void *)acl_t
-as an argument.
-.Sh IMPLEMENTATION NOTES
-FreeBSD's support for POSIX.1e interfaces and features is still under
-development at this time.
-.Sh RETURN VALUES
-Upon successful completion, the function shall return a pointer to the
-internal representation of the ACL in working storage. Otherwise, a value
-of
-.Va (acl_t)NULL
-shall be returned, and
-.Va errno
-shall be set to indicate the error.
-.Sh ERRORS
-If any of the following conditions occur, the
-.Fn acl_from_text
-function shall return a value of
-.Va (acl_t)NULL
-and set
-.Va errno
-to the corresponding value:
-.Bl -tag -width Er
-.It Bq Er EACCES
-Search permission is denied for a component of the path prefix, or the
-object exists and the process does not have appropriate access rights.
-.It Bq Er EINVAL
-Argument
-.Va buf_p
-cannot be translated into an ACL.
-.It Bq Er ENOMEM
-The ACL working storage requires more memory than is allowed by the
-hardware or system-imposed memory management constraints.
-.El
-.Sh SEE ALSO
-.Xr acl 3 ,
-.Xr acl_free 3 ,
-.Xr acl_get 3 ,
-.Xr acl_to_text 3 ,
-.Xr posix1e 3
-.Sh STANDARDS
-POSIX.1e is described in IEEE POSIX.1e draft 17. Discussion
-of the draft continues on the cross-platform POSIX.1e implementation
-mailing list. To join this list, see the
-.Fx
-POSIX.1e implementation
-page for more information.
-.Sh HISTORY
-POSIX.1e support was introduced in
-.Fx 4.0 ,
-and development continues.
-.Sh AUTHORS
-.An Robert N M Watson
-.Sh BUGS
-These features are not yet fully implemented. In particular, the shipped
-version of UFS/FFS does not support storage of additional security labels,
-and so is unable to (easily) provide support for most of these features.
-
-.Fn acl_from_text
-and
-.Fn acl_to_text
-rely on the
-.Xr getpwent 3
-library calls to manage username and uid mapping, as well as the
-.Xr getgrent 3
-library calls to manage groupname and gid mapping. These calls are not
-thread safe, and so transitively, neither are
-.Fn acl_from_text
-and
-.Fn acl_to_text .
-These functions may also interfere with stateful
-calls associated with the
-.Fn getpwent
-and
-.Fn getgrent
-calls.
diff --git a/lib/libc/posix1e/acl_from_text.c b/lib/libc/posix1e/acl_from_text.c
deleted file mode 100644
index a71bbcae57ed..000000000000
--- a/lib/libc/posix1e/acl_from_text.c
+++ /dev/null
@@ -1,246 +0,0 @@
-/*-
- * Copyright (c) 1999 Robert N. M. Watson
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-/*
- * acl_from_text: convert a text-form ACL from a string to an acl_t
- */
-
-#include <sys/types.h>
-#include <sys/acl.h>
-#include <sys/errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "acl_support.h"
-
-enum PARSE_MODE {
- PM_BASE, /* initial, begin line, or after , */
- PM_QUALIFIER, /* in qualifier field */
- PM_PERM, /* in permission field */
- PM_COMMENT, /* in comment */
-};
-
-static char *
-string_skip_whitespace(char *string)
-{
-
- while (*string && ((*string == ' ') || (*string == '\t'))) {
- string++;
- }
- return (string);
-}
-
-static void
-string_trim_trailing_whitespace(char *string)
-{
- char *end;
-
- if (*string == '\0')
- return;
-
- end = string + strlen(string) - 1;
-
- while (end != string) {
- if ((*end == ' ') || (*end == '\t')) {
- *end = '\0';
- end--;
- } else {
- return;
- }
- }
-
- return;
-}
-
-acl_tag_t
-acl_string_to_tag(char *tag, char *qualifier)
-{
-
- if (*qualifier == '\0') {
- if ((!strcmp(tag, "user")) || (!strcmp(tag, "u"))) {
- return (ACL_USER_OBJ);
- } else
- if ((!strcmp(tag, "group")) || (!strcmp(tag, "g"))) {
- return (ACL_GROUP_OBJ);
- } else
- if ((!strcmp(tag, "mask")) || (!strcmp(tag, "m"))) {
- return (ACL_MASK);
- } else
- if ((!strcmp(tag, "other")) || (!strcmp(tag, "o"))) {
- return (ACL_OTHER);
- } else
- return(-1);
- } else {
- if ((!strcmp(tag, "user")) || (!strcmp(tag, "u"))) {
- return(ACL_USER);
- } else
- if ((!strcmp(tag, "group")) || (!strcmp(tag, "g"))) {
- return(ACL_GROUP);
- } else
- return(-1);
- }
-}
-
-/*
- * acl_from_text -- convert a string into an ACL
- * postpone most validity checking until the end and cal acl_valid to do
- * that.
- */
-acl_t
-acl_from_text(const char *buf_p)
-{
- acl_tag_t t;
- acl_perm_t p;
- acl_t acl;
- uid_t id;
- char *mybuf_p, *line, *cur, *notcomment, *comment, *entry;
- char *tag, *qualifier, *permission;
- int error;
-
- /* local copy we can mess up */
- mybuf_p = strdup(buf_p);
- if (!mybuf_p) {
- errno = ENOMEM;
- return(0);
- }
-
- acl = acl_init(3);
- if (!acl) {
- free(mybuf_p);
- errno = ENOMEM;
- return(0);
- }
-
- /* outer loop: delimit at \n boundaries */
- cur = mybuf_p;
- while ((line = strsep(&cur, "\n"))) {
- /* now split the line on the first # to strip out comments */
- comment = line;
- notcomment = strsep(&comment, "#");
-
- /* inner loop: delimit at , boundaries */
- while ((entry = strsep(&notcomment, ","))) {
- /* now split into three :-delimited fields */
- tag = strsep(&entry, ":");
- if (!tag) {
- /* printf("no tag\n"); */
- errno = EINVAL;
- goto error_label;
- }
- tag = string_skip_whitespace(tag);
- if ((*tag == '\0') && (!entry)) {
- /*
- * is an entirely comment line, skip to next
- * comma
- */
- continue;
- }
- string_trim_trailing_whitespace(tag);
-
- qualifier = strsep(&entry, ":");
- if (!qualifier) {
- /* printf("no qualifier\n"); */
- errno = EINVAL;
- goto error_label;
- }
- qualifier = string_skip_whitespace(qualifier);
- string_trim_trailing_whitespace(qualifier);
-
- permission = strsep(&entry, ":");
- if ((!permission) || (entry)) {
- /* printf("no permission, or more stuff\n"); */
- errno = EINVAL;
- goto error_label;
- }
- permission = string_skip_whitespace(permission);
- string_trim_trailing_whitespace(permission);
-
- /* printf("[%s/%s/%s]\n", tag, qualifier,
- permission); */
-
- t = acl_string_to_tag(tag, qualifier);
- if (t == -1) {
- errno = EINVAL;
- goto error_label;
- }
-
- error = acl_string_to_perm(permission, &p);
- if (error == -1) {
- errno = EINVAL;
- goto error_label;
- }
-
- switch(t) {
- case ACL_USER_OBJ:
- case ACL_GROUP_OBJ:
- case ACL_MASK:
- case ACL_OTHER:
- if (*qualifier != '\0') {
- errno = EINVAL;
- goto error_label;
- }
- id = 0;
- break;
-
- case ACL_USER:
- case ACL_GROUP:
- error = acl_name_to_id(t, qualifier, &id);
- if (error == -1)
- goto error_label;
- break;
-
- default:
- errno = EINVAL;
- goto error_label;
- }
-
- error = acl_add_entry(acl, t, id, p);
- if (error == -1)
- goto error_label;
- }
- }
-
-#if 0
- /* XXX should we only return ACLs valid according to acl_valid? */
- /* verify validity of the ACL we read in */
- if (acl_valid(acl) == -1) {
- errno = EINVAL;
- goto error_label;
- }
-#endif
-
- return(acl);
-
-error_label:
- acl_free(acl);
- free(mybuf_p);
- return(0);
-}
-
-
-
diff --git a/lib/libc/posix1e/acl_get.3 b/lib/libc/posix1e/acl_get.3
deleted file mode 100644
index 7781e40c5c11..000000000000
--- a/lib/libc/posix1e/acl_get.3
+++ /dev/null
@@ -1,138 +0,0 @@
-.\"-
-.\" Copyright (c) 2000 Robert N. M. Watson
-.\" 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 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd January 28, 2000
-.Dt ACL_GET 3
-.Os FreeBSD 4.0
-.Sh NAME
-.Nm acl_get_file ,
-.Nm acl_get_fd ,
-.Nm acl_get_fd_np
-.Nd Get an ACL for a file
-.Sh SYNOPSIS
-.Fd #include <sys/types.h>
-.Fd #include <sys/acl.h>
-.Ft acl_t
-.Fn acl_get_file "const char *path_p" "acl_type_t type"
-.Ft acl_t
-.Fn acl_get_fd "int fd"
-.Ft acl_t
-.Fn acl_get_fd_np "int fd" "acl_type_t type"
-.Sh DESCRIPTION
-The
-.Fn acl_get_file ,
-.Fn acl_get_fd ,
-and
-.Fn acl_get_fd_np
-each allow the retrieval of an ACL from a file.
-.Fn acl_get_file
-is a POSIX.1e call that allows the retrieval of a
-specified type of ACL from a file by name;
-.Fn acl_get_fd
-is a POSIX.1e call that allows the retrieval of an ACL of type
-ACL_TYPE_ACCESS
-from a file descriptor.
-.Fn acl_get_fd_np
-is a non-portable form of
-.Fn acl_get_fd
-that allows the retrieval of any type of ACL from a file descriptor.
-
-This function may cause memory to be allocated. The caller should free
-any releasable memory, when the new ACL is no longer required, by calling
-.Xr acl_free 3
-with the
-.Va (void *)acl_t
-as an argument.
-
-The ACL in the working storage is an independent copy of the ACL associated
-with the object referred to by
-.Va fd .
-The ACL in the working storage shall not participate in any access control
-decisions.
-.Sh IMPLEMENTATION NOTES
-FreeBSD's support for POSIX.1e interfaces and features is still under
-development at this time.
-.Sh RETURN VALUES
-Upon successful completion, the function shall return a pointer to the ACL
-that was retrieved. Otherwise, a value of
-.Va (acl_t)NULL
-shall be returned, and
-.Va errno
-shall be set to indicate the error.
-.Sh ERRORS
-If any of the following conditions occur, the
-.Fn acl_get_fd
-function shall return a value of
-.Va (acl_t)NULL
-and set
-.Va errno
-to the corresponding value:
-.Bl -tag -width Er
-.It Bq Er EACCES
-Search permission is denied for a component of the path prefix, or the
-object exists and the process does not have appropriate access rights.
-.It Bq Er EBADF
-The
-.Va fd
-argument is not a valid file descriptor.
-.It Bq Er EINVAL
-The ACL type passed is invalid for this file object.
-.It Bq Er ENAMETOOLONG
-A component of a pathname exceeded 255 characters, or an
-entire path name exceeded 1023 characters.
-.It Bq Er ENOENT
-The named object does not exist, or the
-.Va path_p
-argument points to an empty string.
-.It Bq Er ENOMEM
-Insufficient memory available to fulfill request.
-.It Bq Er EOPNOTSUPP
-The file system does not support ACL retrieval.
-.El
-.Sh SEE ALSO
-.Xr acl 3 ,
-.Xr acl_free 3 ,
-.Xr acl_get 3 ,
-.Xr acl_set 3 ,
-.Xr posix1e 3
-.Sh STANDARDS
-POSIX.1e is described in IEEE POSIX.1e draft 17. Discussion
-of the draft continues on the cross-platform POSIX.1e implementation
-mailing list. To join this list, see the
-.Fx
-POSIX.1e implementation
-page for more information.
-.Sh HISTORY
-POSIX.1e support was introduced in
-.Fx 4.0 ,
-and development continues.
-.Sh AUTHORS
-.An Robert N M Watson
-.Sh BUGS
-These features are not yet fully implemented. In particular, the shipped
-version of UFS/FFS does not support storage of additional security labels,
-and so is unable to (easily) provide support for most of these features.
diff --git a/lib/libc/posix1e/acl_get.c b/lib/libc/posix1e/acl_get.c
deleted file mode 100644
index 494eed7723ab..000000000000
--- a/lib/libc/posix1e/acl_get.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/*-
- * Copyright (c) 1999 Robert N. M. Watson
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-/*
- * acl_get_file - syscall wrapper for retrieving ACL by filename
- * acl_get_fd - syscall wrapper for retrieving access ACL by fd
- * acl_get_fd_np - syscall wrapper for retrieving ACL by fd (non-POSIX)
- */
-
-#include <sys/types.h>
-#include <sys/acl.h>
-#include <sys/errno.h>
-#include <stdlib.h>
-
-acl_t
-acl_get_file(const char *path_p, acl_type_t type)
-{
- struct acl *aclp;
- int error;
-
- aclp = acl_init(ACL_MAX_ENTRIES);
- if (!aclp) {
- return (0);
- }
-
- error = __acl_get_file(path_p, type, aclp);
- if (error) {
- acl_free(aclp);
- return (0);
- }
-
- return (aclp);
-}
-
-acl_t
-acl_get_fd(int fd)
-{
- struct acl *aclp;
- int error;
-
- aclp = acl_init(ACL_MAX_ENTRIES);
- if (!aclp) {
- return (0);
- }
-
- error = __acl_get_fd(fd, ACL_TYPE_ACCESS, aclp);
- if (error) {
- acl_free(aclp);
- return (0);
- }
-
- return (aclp);
-}
-
-acl_t
-acl_get_fd_np(int fd, acl_type_t type)
-{
- struct acl *aclp;
- int error;
-
- aclp = acl_init(ACL_MAX_ENTRIES);
- if (!aclp) {
- return (0);
- }
-
- error = __acl_get_fd(fd, type, aclp);
- if (error) {
- acl_free(aclp);
- return (0);
- }
-
- return (aclp);
-}
diff --git a/lib/libc/posix1e/acl_init.3 b/lib/libc/posix1e/acl_init.3
deleted file mode 100644
index 51b7c2a8f93f..000000000000
--- a/lib/libc/posix1e/acl_init.3
+++ /dev/null
@@ -1,104 +0,0 @@
-.\"-
-.\" Copyright (c) 2000 Robert N. M. Watson
-.\" 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 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd January 28, 2000
-.Dt ACL_INIT 3
-.Os FreeBSD 4.0
-.Sh NAME
-.Nm acl_init
-.Nd Initialize ACL working storage
-.Sh SYNOPSIS
-.Fd #include <sys/types.h>
-.Fd #include <sys/acl.h>
-.Ft acl_t
-.Fn acl_init "int count"
-.Sh DESCRIPTION
-The
-.Fn acl_init
-function allocates and initializes the working storage for an ACL of at
-least
-.Va count
-ACL entries. A pointer to the working storage is returned. The working
-storage allocated to contain the ACL is freed by a call to
-.Xr acl_free 3 .
-When the area is first allocated, it shall contain an an ACL that contains
-no ACL entries.
-
-This function may cause memory to be allocated. The caller should free any
-releasable memory, when the new ACL is no longer required, by calling
-.Xr acl_free 3
-with the
-.Va (void*)acl_t
-as an argument.
-.Sh IMPLEMENTATION NOTES
-FreeBSD's support for POSIX.1e interfaces and features is still under
-development at this time.
-.Sh RETURN VALUES
-Upon successful completion, this function shall return a pointer to the
-working storage. Otherwise, a value of
-.Va (acl_t)NULL
-shall be returned, and
-.Va errno
-shall be set to indicate the error.
-.Sh ERRORS
-If any of the following conditions occur, the
-.Fn acl_init
-function shall return a value of
-.Va (acl_t)NULL
-and set
-.Va errno
-to the corresponding value:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The value of count is less than zero.
-.It Bq Er ENOMEM
-The
-.Va acl_t
-to be returned requires more memory than is allowed by the hardware or
-system-imposed memory management constraints.
-.El
-.Sh SEE ALSO
-.Xr acl 3 ,
-.Xr acl_free 3 ,
-.Xr posix1e 3
-.Sh STANDARDS
-POSIX.1e is described in IEEE POSIX.1e draft 17. Discussion
-of the draft continues on the cross-platform POSIX.1e implementation
-mailing list. To join this list, see the
-.Fx
-POSIX.1e implementation
-page for more information.
-.Sh HISTORY
-POSIX.1e support was introduced in
-.Fx 4.0 ,
-and development continues.
-.Sh AUTHORS
-.An Robert N M Watson
-.Sh BUGS
-These features are not yet fully implemented. In particular, the shipped
-version of UFS/FFS does not support storage of additional security labels,
-and so is unable to (easily) provide support for most of these features.
diff --git a/lib/libc/posix1e/acl_init.c b/lib/libc/posix1e/acl_init.c
deleted file mode 100644
index c2fa43b8ab3b..000000000000
--- a/lib/libc/posix1e/acl_init.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/*-
- * Copyright (c) 1999 Robert N. M. Watson
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-/*
- * acl_init -- return a fresh acl structure
- * acl_dup -- duplicate an acl and return the new copy
- */
-
-#include <sys/types.h>
-#include <sys/acl.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-
-acl_t
-acl_init(int count)
-{
- struct acl *acl;
-
- if (count > ACL_MAX_ENTRIES) {
- errno = ENOMEM;
- return (0);
- }
-
- acl = (struct acl *) malloc(sizeof(struct acl));
- bzero(acl, sizeof(struct acl));
-
- return (acl);
-}
-
-acl_t
-acl_dup(acl_t acl)
-{
- struct acl *acl_new;
-
- acl_new = acl_init(ACL_MAX_ENTRIES);
- if (!acl_new)
- return(NULL);
-
- *acl_new = *acl;
-
- return(acl_new);
-}
diff --git a/lib/libc/posix1e/acl_set.3 b/lib/libc/posix1e/acl_set.3
deleted file mode 100644
index 916292c9d1eb..000000000000
--- a/lib/libc/posix1e/acl_set.3
+++ /dev/null
@@ -1,131 +0,0 @@
-.\"-
-.\" Copyright (c) 2000 Robert N. M. Watson
-.\" 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 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd January 28, 2000
-.Dt ACL_SET 3
-.Os FreeBSD 4.0
-.Sh NAME
-.Nm acl_set_file ,
-.Nm acl_set_fd ,
-.Nm acl_set_fd_np
-.Nd Get an ACL for a file
-.Sh SYNOPSIS
-.Fd #include <sys/types.h>
-.Fd #include <sys/acl.h>
-.Ft int
-.Fn acl_set_file "const char *path_p" "acl_type_t type" "acl_t acl"
-.Ft int
-.Fn acl_set_fd "int fd" "acl_t acl"
-.Ft int
-.Fn acl_set_fd_np "int fd" "acl_t acl" "acl_type_t type"
-.Sh DESCRIPTION
-The
-.Fn acl_set_file ,
-.Fn acl_set_fd ,
-and
-.Fn acl_set_fd_np
-each associate an ACL with an object referred to by
-.Va fd
-or
-.Va path_p .
-All except
-.Fn acl_set_fd_np
-are POSIX.1e calls--
-.Fn acl_set_fd
-allows only the setting of ACLs of type ACL_TYPE_ACCESS
-where as
-.Fn acl_set_fd_np
-allows the setting of ACLs of any type.
-.Sh IMPLEMENTATION NOTES
-FreeBSD's support for POSIX.1e interfaces and features is still under
-development at this time.
-.Sh RETURN VALUES
-Upon successful completion, the function shall return a value of zero.
-Otherwise, a value of -1 shall be returned and
-.Va errno
-shall be set to indicate the error.
-.Sh ERRORS
-If any of the following conditions occur, these functions shall return
--1 and set
-.Va errno
-to the corresponding value:
-.Bl -tag -width Er
-.It Bq Er EACCES
-Search permission is denied for a component of the path prefix, or the
-object exists and the process does not have appropriate access rights.
-.It Bq Er EBADF
-The
-.Va fd
-argument is not a valid file descriptor.
-.It Bq Er EINVAL
-Argument
-.Va acl
-does not point to a valid ACL for this object, or the ACL type
-specified in
-.Va type
-is invalid for this object, or both.
-.It Bq Er ENAMETOOLONG
-A component of a pathname exceeded 255 characters, or an
-entire path name exceeded 1023 characters.
-.It Bq Er ENOENT
-The named object does not exist, or the
-.Va path_p
-argument points to an empty string.
-.It Bq Er ENOMEM
-Insufficient memory available to fulfill request.
-.It Bq Er ENOSPC
-The directory or file system that would contain the new ACL cannot be
-extended, or the file system is out of file allocation resources.
-.It Bq Er EOPNOTSUPP
-The file system does not support ACL retrieval.
-.It Bq Er EROFS
-This function requires modification of a file system which is currently
-read-only.
-.El
-.Sh SEE ALSO
-.Xr acl 3 ,
-.Xr acl_delete 3 ,
-.Xr acl_get 3 ,
-.Xr acl_valid 3 ,
-.Xr posix1e 3
-.Sh STANDARDS
-POSIX.1e is described in IEEE POSIX.1e draft 17. Discussion
-of the draft continues on the cross-platform POSIX.1e implementation
-mailing list. To join this list, see the
-.Fx
-POSIX.1e implementation
-page for more information.
-.Sh HISTORY
-POSIX.1e support was introduced in
-.Fx 4.0 ,
-and development continues.
-.Sh AUTHORS
-.An Robert N M Watson
-.Sh BUGS
-These features are not yet fully implemented. In particular, the shipped
-version of UFS/FFS does not support storage of additional security labels,
-and so is unable to (easily) provide support for most of these features.
diff --git a/lib/libc/posix1e/acl_set.c b/lib/libc/posix1e/acl_set.c
deleted file mode 100644
index 070e2b16e5c1..000000000000
--- a/lib/libc/posix1e/acl_set.c
+++ /dev/null
@@ -1,88 +0,0 @@
-/*-
- * Copyright (c) 1999 Robert N. M. Watson
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-/*
- * acl_set_file -- set a file/directory ACL by name
- */
-
-#include <sys/types.h>
-#include <sys/acl.h>
-#include <errno.h>
-
-#include "acl_support.h"
-
-/*
- * For POSIX.1e-semantic ACLs, do a presort so the kernel doesn't have to
- * (the POSIX.1e semantic code will reject unsorted ACL submission). If it's
- * not a semantic that the library knows about, just submit it flat and
- * assume the caller knows what they're up to.
- */
-int
-acl_set_file(const char *path_p, acl_type_t type, acl_t acl)
-{
- int error;
-
- if (acl_posix1e(acl, type)) {
- error = acl_sort(acl);
- if (error) {
- errno = error;
- return (-1);
- }
- }
-
- return (__acl_set_file(path_p, type, acl));
-}
-
-int
-acl_set_fd(int fd, acl_t acl)
-{
- int error;
-
- error = acl_sort(acl);
- if (error) {
- errno = error;
- return(-1);
- }
-
- return (__acl_set_fd(fd, ACL_TYPE_ACCESS, acl));
-}
-
-int
-acl_set_fd_np(int fd, acl_t acl, acl_type_t type)
-{
- int error;
-
- if (acl_posix1e(acl, type)) {
- error = acl_sort(acl);
- if (error) {
- errno = error;
- return (-1);
- }
- }
-
- return (__acl_set_fd(fd, type, acl));
-}
diff --git a/lib/libc/posix1e/acl_support.c b/lib/libc/posix1e/acl_support.c
deleted file mode 100644
index a136407b287a..000000000000
--- a/lib/libc/posix1e/acl_support.c
+++ /dev/null
@@ -1,409 +0,0 @@
-/*-
- * Copyright (c) 1999 Robert N. M. Watson
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-/*
- * Support functionality for the POSIX.1e ACL interface
- * These calls are intended only to be called within the library.
- */
-
-#include <sys/types.h>
-#include <sys/acl.h>
-#include <errno.h>
-#include <grp.h>
-#include <pwd.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "acl_support.h"
-
-#define ACL_STRING_PERM_WRITE 'w'
-#define ACL_STRING_PERM_READ 'r'
-#define ACL_STRING_PERM_EXEC 'x'
-#define ACL_STRING_PERM_NONE '-'
-
-/*
- * acl_entry_compare -- compare two acl_entry structures to determine the
- * order they should appear in. Used by acl_sort to sort ACL entries into
- * the kernel-desired order -- i.e., the order useful for evaluation and
- * O(n) validity checking. Beter to have an O(nlogn) sort in userland and
- * an O(n) in kernel than to have both in kernel.
- */
-typedef int (*compare)(const void *, const void *);
-static int
-acl_entry_compare(struct acl_entry *a, struct acl_entry *b)
-{
- /*
- * First, sort between tags -- conveniently defined in the correct
- * order for verification.
- */
- if (a->ae_tag < b->ae_tag)
- return (-1);
- if (a->ae_tag > b->ae_tag)
- return (1);
-
- /*
- * Next compare uids/gids on appropriate types.
- */
-
- if (a->ae_tag == ACL_USER || a->ae_tag == ACL_GROUP) {
- if (a->ae_id < b->ae_id)
- return (-1);
- if (a->ae_id > b->ae_id)
- return (1);
-
- /* shouldn't be equal, fall through to the invalid case */
- }
-
- /*
- * Don't know how to sort multiple entries of the rest--either it's
- * a bad entry, or there shouldn't be more than one. Ignore and the
- * validity checker can get it later.
- */
- return (0);
-}
-
-/*
- * acl_sort -- sort ACL entries.
- * Give the opportunity to fail, althouh we don't currently have a way
- * to fail.
- */
-int
-acl_sort(acl_t acl)
-{
-
- qsort(&acl->acl_entry[0], acl->acl_cnt, sizeof(struct acl_entry),
- (compare) acl_entry_compare);
-
- return (0);
-}
-
-/*
- * acl_posix1e -- in what situations should we acl_sort before submission?
- * We apply posix1e ACL semantics for any ACL of type ACL_TYPE_ACCESS or
- * ACL_TYPE_DEFAULT
- */
-int
-acl_posix1e(acl_t acl, acl_type_t type)
-{
-
- return ((type == ACL_TYPE_ACCESS) || (type == ACL_TYPE_DEFAULT));
-}
-
-/*
- * acl_check -- given an ACL, check its validity. This is mirrored from
- * code in sys/kern/kern_acl.c, and if changes are made in one, they should
- * be made in the other also. This copy of acl_check is made available
- * in userland for the benefit of processes wanting to check ACLs for
- * validity before submitting them to the kernel, or for performing
- * in userland file system checking. Needless to say, the kernel makes
- * the real checks on calls to get/setacl.
- *
- * See the comments in kernel for explanation -- just briefly, it assumes
- * an already sorted ACL, and checks based on that assumption. The
- * POSIX.1e interface, acl_valid(), will perform the sort before calling
- * this. Returns 0 on success, EINVAL on failure.
- */
-int
-acl_check(struct acl *acl)
-{
- struct acl_entry *entry; /* current entry */
- uid_t obj_uid=-1, obj_gid=-1, highest_uid=0, highest_gid=0;
- int stage = ACL_USER_OBJ;
- int i = 0;
- int count_user_obj=0, count_user=0, count_group_obj=0,
- count_group=0, count_mask=0, count_other=0;
-
- /* printf("acl_check: checking acl with %d entries\n", acl->acl_cnt); */
- while (i < acl->acl_cnt) {
-
- entry = &acl->acl_entry[i];
-
- if ((entry->ae_perm | ACL_PERM_BITS) != ACL_PERM_BITS)
- return (EINVAL);
-
- switch(entry->ae_tag) {
- case ACL_USER_OBJ:
- /* printf("acl_check: %d: ACL_USER_OBJ\n", i); */
- if (stage > ACL_USER_OBJ)
- return (EINVAL);
- stage = ACL_USER;
- count_user_obj++;
- obj_uid = entry->ae_id;
- break;
-
- case ACL_USER:
- /* printf("acl_check: %d: ACL_USER\n", i); */
- if (stage > ACL_USER)
- return (EINVAL);
- stage = ACL_USER;
- if (entry->ae_id == obj_uid)
- return (EINVAL);
- if (count_user && (entry->ae_id <= highest_uid))
- return (EINVAL);
- highest_uid = entry->ae_id;
- count_user++;
- break;
-
- case ACL_GROUP_OBJ:
- /* printf("acl_check: %d: ACL_GROUP_OBJ\n", i); */
- if (stage > ACL_GROUP_OBJ)
- return (EINVAL);
- stage = ACL_GROUP;
- count_group_obj++;
- obj_gid = entry->ae_id;
- break;
-
- case ACL_GROUP:
- /* printf("acl_check: %d: ACL_GROUP\n", i); */
- if (stage > ACL_GROUP)
- return (EINVAL);
- stage = ACL_GROUP;
- if (entry->ae_id == obj_gid)
- return (EINVAL);
- if (count_group && (entry->ae_id <= highest_gid))
- return (EINVAL);
- highest_gid = entry->ae_id;
- count_group++;
- break;
-
- case ACL_MASK:
- /* printf("acl_check: %d: ACL_MASK\n", i); */
- if (stage > ACL_MASK)
- return (EINVAL);
- stage = ACL_MASK;
- count_mask++;
- break;
-
- case ACL_OTHER:
- /* printf("acl_check: %d: ACL_OTHER\n", i); */
- if (stage > ACL_OTHER)
- return (EINVAL);
- stage = ACL_OTHER;
- count_other++;
- break;
-
- default:
- /* printf("acl_check: %d: INVALID\n", i); */
- return (EINVAL);
- }
- i++;
- }
-
- if (count_user_obj != 1)
- return (EINVAL);
-
- if (count_group_obj != 1)
- return (EINVAL);
-
- if (count_mask != 0 && count_mask != 1)
- return (EINVAL);
-
- if (count_other != 1)
- return (EINVAL);
-
- return (0);
-}
-
-
-/*
- * Given a uid/gid, return a username/groupname for the text form of an ACL
- * XXX NOT THREAD SAFE, RELIES ON GETPWUID, GETGRGID
- * XXX USES *PW* AND *GR* WHICH ARE STATEFUL AND THEREFORE THIS ROUTINE
- * MAY HAVE SIDE-EFFECTS
- */
-int
-acl_id_to_name(acl_tag_t tag, uid_t id, ssize_t buf_len, char *buf)
-{
- struct group *g;
- struct passwd *p;
- int i;
-
- switch(tag) {
- case ACL_USER:
- p = getpwuid(id);
- if (!p)
- i = snprintf(buf, buf_len, "%d", id);
- else
- i = snprintf(buf, buf_len, "%s", p->pw_name);
-
- if (i >= buf_len) {
- errno = ENOMEM;
- return (-1);
- }
- return (0);
-
- case ACL_GROUP:
- g = getgrgid(id);
- if (!g)
- i = snprintf(buf, buf_len, "%d", id);
- else
- i = snprintf(buf, buf_len, "%s", g->gr_name);
-
- if (i >= buf_len) {
- errno = ENOMEM;
- return (-1);
- }
- return (0);
-
- default:
- return (EINVAL);
- }
-}
-
-
-/*
- * Given a username/groupname from a text form of an ACL, return the uid/gid
- * XXX NOT THREAD SAFE, RELIES ON GETPWNAM, GETGRNAM
- * XXX USES *PW* AND *GR* WHICH ARE STATEFUL AND THEREFORE THIS ROUTINE
- * MAY HAVE SIDE-EFFECTS
- *
- * XXX currently doesn't deal correctly with a numeric uid being passed
- * instead of a username. What is correct behavior here? Check chown.
- */
-int
-acl_name_to_id(acl_tag_t tag, char *name, uid_t *id)
-{
- struct group *g;
- struct passwd *p;
-
- switch(tag) {
- case ACL_USER:
- p = getpwnam(name);
- if (!p) {
- errno = EINVAL;
- return (-1);
- }
- *id = p->pw_uid;
- return (0);
-
- case ACL_GROUP:
- g = getgrnam(name);
- if (g) {
- errno = EINVAL;
- return (-1);
- }
- *id = g->gr_gid;
- return (0);
-
- default:
- return (EINVAL);
- }
-}
-
-
-/*
- * Given a right-shifted permission (i.e., direct ACL_PERM_* mask), fill
- * in a string describing the permissions.
- */
-int
-acl_perm_to_string(acl_perm_t perm, ssize_t buf_len, char *buf)
-{
-
- if (buf_len < ACL_STRING_PERM_MAXSIZE + 1) {
- errno = ENOMEM;
- return (-1);
- }
-
- if ((perm | ACL_PERM_BITS) != ACL_PERM_BITS) {
- errno = EINVAL;
- return (-1);
- }
-
- buf[3] = 0; /* null terminate */
-
- if (perm & ACL_PERM_READ)
- buf[0] = ACL_STRING_PERM_READ;
- else
- buf[0] = ACL_STRING_PERM_NONE;
-
- if (perm & ACL_PERM_WRITE)
- buf[1] = ACL_STRING_PERM_WRITE;
- else
- buf[1] = ACL_STRING_PERM_NONE;
-
- if (perm & ACL_PERM_EXEC)
- buf[2] = ACL_STRING_PERM_EXEC;
- else
- buf[2] = ACL_STRING_PERM_NONE;
-
- return (0);
-}
-
-/*
- * given a string, return a permission describing it
- */
-int
-acl_string_to_perm(char *string, acl_perm_t *perm)
-{
- acl_perm_t myperm = ACL_PERM_NONE;
- char *ch;
-
- ch = string;
- while (*ch) {
- switch(*ch) {
- case ACL_STRING_PERM_READ:
- myperm |= ACL_PERM_READ;
- break;
- case ACL_STRING_PERM_WRITE:
- myperm |= ACL_PERM_WRITE;
- break;
- case ACL_STRING_PERM_EXEC:
- myperm |= ACL_PERM_EXEC;
- break;
- case ACL_STRING_PERM_NONE:
- break;
- default:
- return (EINVAL);
- }
- ch++;
- }
-
- *perm = myperm;
- return (0);
-}
-
-/*
- * Add an ACL entry without doing much checking, et al
- */
-int
-acl_add_entry(acl_t acl, acl_tag_t tag, uid_t id, acl_perm_t perm)
-{
- struct acl_entry *e;
-
- if (acl->acl_cnt >= ACL_MAX_ENTRIES) {
- errno = ENOMEM;
- return (-1);
- }
-
- e = &(acl->acl_entry[acl->acl_cnt]);
- e->ae_perm = perm;
- e->ae_tag = tag;
- e->ae_id = id;
- acl->acl_cnt++;
-
- return (0);
-}
diff --git a/lib/libc/posix1e/acl_support.h b/lib/libc/posix1e/acl_support.h
deleted file mode 100644
index e34aca5e5646..000000000000
--- a/lib/libc/posix1e/acl_support.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*-
- * Copyright (c) 1999 Robert N. M. Watson
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-/*
- * Support functionality for the POSIX.1e ACL interface
- * These calls are intended only to be called within the library.
- */
-#ifndef _ACL_SUPPORT_H
-#define _ACL_SUPPORT_H
-
-#define ACL_STRING_PERM_MAXSIZE 3 /* read, write, exec */
-
-int acl_check(struct acl *acl);
-int acl_sort(acl_t acl);
-int acl_posix1e(acl_t acl, acl_type_t type);
-int acl_id_to_name(acl_tag_t tag, uid_t id, ssize_t buf_len, char *buf);
-int acl_name_to_id(acl_tag_t tag, char *name, uid_t *id);
-int acl_perm_to_string(acl_perm_t perm, ssize_t buf_len, char *buf);
-int acl_string_to_perm(char *string, acl_perm_t *perm);
-int acl_add_entry(acl_t acl, acl_tag_t tag, uid_t id, acl_perm_t perm);
-
-#endif
diff --git a/lib/libc/posix1e/acl_to_text.3 b/lib/libc/posix1e/acl_to_text.3
deleted file mode 100644
index 483dea7324ee..000000000000
--- a/lib/libc/posix1e/acl_to_text.3
+++ /dev/null
@@ -1,130 +0,0 @@
-.\"-
-.\" Copyright (c) 2000 Robert N. M. Watson
-.\" 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 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd January 28, 2000
-.Dt ACL_TO_TEXT 3
-.Os FreeBSD 4.0
-.Sh NAME
-.Nm acl_to_text
-.Nd Convert an ACL to Text
-.Sh SYNOPSIS
-.Fd #include <sys/types.h>
-.Fd #include <sys/acl.h>
-.Ft char *
-.Fn acl_to_text "acl_t acl" "ssize_t *len_p"
-.Sh DESCRIPTION
-The
-.Fn acl_to_text
-function translates the ACL pointed to by argument
-.Va acl
-into a NULL terminated character string. If the pointer
-.Va len_p
-is not NULL, then the function shall return the length of the string (not
-including the NULL terminator) in the location pointed to by
-.Va len_p .
-The format of the text string returned by
-.Fn acl_to_text
-shall be the POSIX.1e long ACL form.
-
-This function allocates any memory necessary to contain the string and
-returns a pointer to the string. The caller should free any releasable
-memory, when the new string is no longer required, by calling
-.Xr acl_free 3
-with the
-.Va (void*)char
-as an argument.
-.Sh IMPLEMENTATION NOTES
-FreeBSD's support for POSIX.1e interfaces and features is still under
-development at this time.
-.Sh RETURN VALUES
-Upon successful completion, the function shall return a pointer to the
-long text form of an ACL. Otherwise, a value of
-.Va (char*)NULL
-shall be returned and
-.Va errno
-shall be set to indicate the error.
-.Sh ERRORS
-If any of the following conditions occur, the
-.Fn acl_to_text
-function shall return a value of
-.Va (acl_t)NULL
-and set
-.Va errno
-to the corresponding value:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-Argument
-.Va acl
-does not point to a valid ACL.
-
-The ACL denoted by
-.Va acl
-contains one or more improperly formed ACL entries, or for some other
-reason cannot be translated into a text form of an ACL.
-.It Bq Er ENOMEM
-The character string to be returned requires more memory than is allowed
-by the hardware or software-imposed memory management constraints.
-.El
-.Sh SEE ALSO
-.Xr acl 3 ,
-.Xr acl_free 3 ,
-.Xr acl_from_text 3 ,
-.Xr posix1e 3
-.Sh STANDARDS
-POSIX.1e is described in IEEE POSIX.1e draft 17. Discussion
-of the draft continues on the cross-platform POSIX.1e implementation
-mailing list. To join this list, see the FreeBSD POSIX.1e implementation
-page for more information.
-.Sh HISTORY
-POSIX.1e support was introduced in
-.Fx 4.0 ,
-and development continues.
-.Sh AUTHORS
-.An Robert N M Watson
-.Sh BUGS
-These features are not yet fully implemented. In particular, the shipped
-version of UFS/FFS does not support storage of additional security labels,
-and so is unable to (easily) provide support for most of these features.
-
-.Fn acl_from_text
-and
-.Fn acl_to_text
-rely on the
-.Xr getpwent 3
-library calls to manage username and uid mapping, as well as the
-.Xr getgrent 3
-library calls to manage groupname and gid mapping. These calls are not
-thread safe, and so transitively, neither are
-.Fn acl_from_text
-and
-.Fn acl_to_text .
-These functions may also interfere with stateful
-calls associated with the
-.Fn getpwent
-and
-.Fn getgrent
-calls.
diff --git a/lib/libc/posix1e/acl_to_text.c b/lib/libc/posix1e/acl_to_text.c
deleted file mode 100644
index 0dc3058fbff0..000000000000
--- a/lib/libc/posix1e/acl_to_text.c
+++ /dev/null
@@ -1,233 +0,0 @@
-/*-
- * Copyright (c) 1999 Robert N. M. Watson
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-/*
- * acl_to_text - return a text string with a text representation of the acl
- * in it.
- */
-
-#include <sys/types.h>
-#include <sys/acl.h>
-#include <sys/errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <utmp.h>
-
-#include "acl_support.h"
-
-/*
- * acl_to_text - generate a text form of an acl
- * spec says nothing about output ordering, so leave in acl order
- *
- * This function will not produce nice results if it is called with
- * a non-POSIX.1e semantics ACL.
- */
-char *
-acl_to_text(acl_t acl, ssize_t *len_p)
-{
- char *buf, *tmpbuf;
- char name_buf[UT_NAMESIZE+1];
- char perm_buf[ACL_STRING_PERM_MAXSIZE+1],
- effective_perm_buf[ACL_STRING_PERM_MAXSIZE+1];
- int i, error, len;
- uid_t ae_id;
- acl_tag_t ae_tag;
- acl_perm_t ae_perm, effective_perm, mask_perm;
-
- buf = strdup("");
-
- mask_perm = ACL_PERM_BITS; /* effective is regular if no mask */
- for (i = 0; i < acl->acl_cnt; i++)
- if (acl->acl_entry[i].ae_tag == ACL_MASK)
- mask_perm = acl->acl_entry[i].ae_perm;
-
- for (i = 0; i < acl->acl_cnt; i++) {
- ae_tag = acl->acl_entry[i].ae_tag;
- ae_id = acl->acl_entry[i].ae_id;
- ae_perm = acl->acl_entry[i].ae_perm;
-
- switch(ae_tag) {
- case ACL_USER_OBJ:
- error = acl_perm_to_string(ae_perm,
- ACL_STRING_PERM_MAXSIZE+1, perm_buf);
- if (error)
- goto error_label;
- len = asprintf(&tmpbuf, "%suser::%s\n", buf,
- perm_buf);
- if (len == -1) {
- errno = ENOMEM;
- goto error_label;
- }
- free(buf);
- buf = tmpbuf;
- break;
-
- case ACL_USER:
- error = acl_perm_to_string(ae_perm,
- ACL_STRING_PERM_MAXSIZE+1, perm_buf);
- if (error)
- goto error_label;
-
- error = acl_id_to_name(ae_tag, ae_id, UT_NAMESIZE+1,
- name_buf);
- if (error)
- goto error_label;
-
- effective_perm = ae_perm & mask_perm;
- if (effective_perm != ae_perm) {
- error = acl_perm_to_string(effective_perm,
- ACL_STRING_PERM_MAXSIZE+1,
- effective_perm_buf);
- if (error)
- goto error_label;
- len = asprintf(&tmpbuf, "%suser:%s:%s\t\t# "
- "effective: %s\n",
- buf, name_buf, perm_buf,
- effective_perm_buf);
- } else {
- len = asprintf(&tmpbuf, "%suser:%s:%s\n", buf,
- name_buf, perm_buf);
- }
- if (len == -1) {
- errno = ENOMEM;
- goto error_label;
- }
- free(buf);
- buf = tmpbuf;
- break;
-
- case ACL_GROUP_OBJ:
- error = acl_perm_to_string(ae_perm,
- ACL_STRING_PERM_MAXSIZE+1, perm_buf);
- if (error)
- goto error_label;
-
- effective_perm = ae_perm & mask_perm;
- if (effective_perm != ae_perm) {
- error = acl_perm_to_string(effective_perm,
- ACL_STRING_PERM_MAXSIZE+1,
- effective_perm_buf);
- if (error)
- goto error_label;
- len = asprintf(&tmpbuf, "%sgroup::%s\t\t# "
- "effective: %s\n",
- buf, perm_buf, effective_perm_buf);
- } else {
- len = asprintf(&tmpbuf, "%sgroup::%s\n", buf,
- perm_buf);
- }
- if (len == -1) {
- errno = ENOMEM;
- goto error_label;
- }
- free(buf);
- buf = tmpbuf;
- break;
-
- case ACL_GROUP:
- error = acl_perm_to_string(ae_perm,
- ACL_STRING_PERM_MAXSIZE+1, perm_buf);
- if (error)
- goto error_label;
-
- error = acl_id_to_name(ae_tag, ae_id, UT_NAMESIZE+1,
- name_buf);
- if (error)
- goto error_label;
-
- effective_perm = ae_perm & mask_perm;
- if (effective_perm != ae_perm) {
- error = acl_perm_to_string(effective_perm,
- ACL_STRING_PERM_MAXSIZE+1,
- effective_perm_buf);
- if (error)
- goto error_label;
- len = asprintf(&tmpbuf, "%sgroup::%s\t\t# "
- "effective: %s\n",
- buf, perm_buf, effective_perm_buf);
- } else {
- len = asprintf(&tmpbuf, "%sgroup:%s:%s\n", buf,
- name_buf, perm_buf);
- }
- if (len == -1) {
- errno = ENOMEM;
- goto error_label;
- }
- free(buf);
- buf = tmpbuf;
- break;
-
- case ACL_MASK:
- error = acl_perm_to_string(ae_perm,
- ACL_STRING_PERM_MAXSIZE+1, perm_buf);
- if (error)
- goto error_label;
-
- len = asprintf(&tmpbuf, "%smask::%s\n", buf,
- perm_buf);
- if (len == -1) {
- errno = ENOMEM;
- goto error_label;
- }
- free(buf);
- buf = tmpbuf;
- break;
-
- case ACL_OTHER:
- error = acl_perm_to_string(ae_perm,
- ACL_STRING_PERM_MAXSIZE+1, perm_buf);
- if (error)
- goto error_label;
-
- len = asprintf(&tmpbuf, "%sother::%s\n", buf,
- perm_buf);
- if (len == -1) {
- errno = ENOMEM;
- goto error_label;
- }
- free(buf);
- buf = tmpbuf;
- break;
-
- default:
- free(buf);
- errno = EINVAL;
- return (0);
- }
- }
-
- if (len_p) {
- *len_p = strlen(buf);
- }
- return (buf);
-
-error_label:
- /* jump to here sets errno already, we just clean up */
- if (buf) free(buf);
- return (0);
-}
diff --git a/lib/libc/posix1e/acl_valid.3 b/lib/libc/posix1e/acl_valid.3
deleted file mode 100644
index 53ee879d20df..000000000000
--- a/lib/libc/posix1e/acl_valid.3
+++ /dev/null
@@ -1,144 +0,0 @@
-.\"-
-.\" Copyright (c) 2000 Robert N. M. Watson
-.\" 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 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd January 28, 2000
-.Dt ACL_VALID 3
-.Os FreeBSD 4.0
-.Sh NAME
-.Nm acl_valid ,
-.Nm acl_valid_fd_np ,
-.Nm acl_valid_file_np
-.Nd Validate an ACL
-.Sh SYNOPSIS
-.Fd #include <sys/types.h>
-.Fd #include <sys/acl.h>
-.Ft int
-.Fn acl_valid "acl_t acl"
-.Ft int
-.Fn acl_valid_fd_np "int fd" "acl_type_t type" "acl_t acl"
-.Ft int
-.Fn acl_valid_file_np "const char *path_p" "acl_type_t type" "acl_t acl"
-.Sh DESCRIPTION
-These functions check that the ACL referred to by the argument
-.Va acl
-is valid. The POSIX.1e routine,
-.Fn acl_valid ,
-checks this validity only with POSIX.1e ACL semantics, and irrespective
-of the context in which the ACL is to be used. The non-portable forms,
-.Fn acl_valid_fd_np
-and
-.Fn acl_valid_file_np ,
-allow an ACL to be checked in the context of a specific acl type,
-.Va type ,
-and file system object. In environments where additional ACL types are
-supported than just POSIX.1e, this makes more sense.
-
-For POSIX.1e semantics, the checks include:
-.Bd -literal -offset indent
-The three required entries (ACL_USER_OBJ, ACL_GROUP_OBJ,
-and ACL_OTHER) shall exist exactly once in the ACL. If
-the ACL contains any ACL_USER, ACL_GROUP, or any other
-implementation-defined entries in the file group class
-then one ACL_MASK entry shall also be required. The ACL
-shall contain at most on ACL_MASK entry.
-
-The qualifier field shall be unique among all entries of
-the same POSIX.1e ACL facility defined tag type. The
-tag type field shall contain valid values including any
-implementation-defined values. Validation of the values
-of the qualifier field is implementation-defined.
-.Ed
-
-The POSIX.1e
-.Fn acl_valid
-function may reorder the ACL for the purposes of verification; the
-non-portable validation functions will not.
-.Sh IMPLEMENTATION NOTES
-FreeBSD's support for POSIX.1e interfaces and features is still under
-development at this time.
-.Sh RETURN VALUES
-Upon successful completion, the function shall return a value of zero.
-Otherwise, a value of -1 shall be returned and
-.Va errno
-shall be set to indicate the error.
-.Sh ERRORS
-If any of the following conditions occur, these functions shall return
--1 and set
-.Va errno
-to the corresponding value:
-.Bl -tag -width Er
-.It Bq Er EACCES
-Search permission is denied for a component of the path prefix, or the
-object exists and the process does not have appropriate access rights.
-.It Bq Er EBADF
-The
-.Va fd
-argument is not a valid file descriptor.
-.It Bq Er EINVAL
-Argument
-.Va acl
-does not point to a valid ACL.
-
-One or more of the required ACL entries is not present in
-.Va acl .
-
-The ACL contains entries that are not unique.
-
-The file system rejects the ACL based on fs-specific semantics issues.
-.It Bq Er ENAMETOOLONG
-A component of a pathname exceeded 255 characters, or an
-entire path name exceeded 1023 characters.
-.It Bq Er ENOENT
-The named object does not exist, or the
-.Va path_p
-argument points to an empty string.
-.It Bq Er ENOMEM
-Insufficient memory available to fulfill request.
-.It Bq Er EOPNOTSUPP
-The file system does not support ACL retrieval.
-.El
-.Sh SEE ALSO
-.Xr acl 3 ,
-.Xr acl_get 3 ,
-.Xr acl_init 3 ,
-.Xr acl_set 3 ,
-.Xr posix1e 3
-.Sh STANDARDS
-POSIX.1e is described in IEEE POSIX.1e draft 17. Discussion
-of the draft continues on the cross-platform POSIX.1e implementation
-mailing list. To join this list, see the FreeBSD POSIX.1e implementation
-page for more information.
-.Sh HISTORY
-POSIX.1e support was introduced in
-.Fx 4.0 ,
-and development continues.
-.Sh AUTHORS
-.An Robert N M Watson
-.Sh BUGS
-These features are not yet fully implemented. In particular, the shipped
-version of UFS/FFS does not support storage of additional security labels,
-and so is unable to (easily) provide support for most of these features.
diff --git a/lib/libc/posix1e/acl_valid.c b/lib/libc/posix1e/acl_valid.c
deleted file mode 100644
index efb91ed73e42..000000000000
--- a/lib/libc/posix1e/acl_valid.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/*-
- * Copyright (c) 1999 Robert N. M. Watson
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-/*
- * acl_valid -- POSIX.1e ACL check routine
- */
-
-#include <sys/types.h>
-#include <sys/acl.h>
-#include <sys/errno.h>
-
-#include "acl_support.h"
-
-/*
- * acl_valid: accepts an ACL, returns 0 on valid ACL, -1 for invalid,
- * and errno set to EINVAL.
- *
- * Implemented by calling the acl_check routine in acl_support, which
- * requires ordering. We call acl_support's acl_sort to make this
- * true. POSIX.1e allows acl_valid() to reorder the ACL as it sees fit.
- *
- * This call is deprecated, as it doesn't ask whether the ACL is valid
- * for a particular target. However, this call is standardized, unlike
- * the other two forms.
- */
-int
-acl_valid(acl_t acl)
-{
- int error;
-
- acl_sort(acl);
- error = acl_check(acl);
- if (error) {
- errno = error;
- return (-1);
- } else {
- return (0);
- }
-}
-
-
-int
-acl_valid_file_np(const char *pathp, acl_type_t type, acl_t acl)
-{
- int error;
-
- if (acl_posix1e(acl, type)) {
- error = acl_sort(acl);
- if (error) {
- errno = error;
- return (-1);
- }
- }
-
- return (__acl_aclcheck_file(pathp, type, acl));
-}
-
-
-int
-acl_valid_fd_np(int fd, acl_type_t type, acl_t acl)
-{
- int error;
-
- if (acl_posix1e(acl, type)) {
- error = acl_sort(acl);
- if (error) {
- errno = error;
- return (-1);
- }
- }
-
- return (__acl_aclcheck_fd(fd, type, acl));
-}
diff --git a/lib/libc/posix1e/posix1e.3 b/lib/libc/posix1e/posix1e.3
deleted file mode 100644
index 3d433826ca5f..000000000000
--- a/lib/libc/posix1e/posix1e.3
+++ /dev/null
@@ -1,101 +0,0 @@
-.\"-
-.\" Copyright (c) 2000 Robert N. M. Watson
-.\" 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 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd January 17, 2000
-.Dt POSIX1E 3
-.Os FreeBSD 4.0
-.Sh NAME
-.Nm posix1e
-.Nd introduction to the POSIX.1e security API
-.Sh SYNOPSIS
-.Fd #include <sys/acl.h>
-.Fd #include <sys/audit.h>
-.Fd #include <sys/capability.h>
-.Fd #include <sys/mac.h>
-.Sh DESCRIPTION
-The IEEE POSIX.1e specification never left draft form, but the interfaces
-it describes are now widely used despite inherent limitations. Currently,
-only a few of the interfaces and features are implemented in FreeBSD,
-although efforts are underway to complete the integration at this time.
-
-POSIX.1e describes five security extensions to the base POSIX.1 API:
-Access Control Lists (ACLs), Auditing, Capabilities, Mandatory Access
-Control, and Information Flow Labels. Of these, the ACL interfaces are
-currently included with FreeBSD, Auditing, Capabilities, and Mandatory
-Access Control are in the wings, and Information Flow Labels are not on
-the calendar.
-
-POSIX.1e defines both syntax and semantics for these features, but fairly
-substantial changes are required to implement these features in the
-operating system. As shipped, FreeBSD 4.0 permits file systems to export
-Access Control Lists via the VFS, and provides a library for userland
-access to and manipulation of these ACLs, but support for ACLs is not
-provided by any file systems shipped in the base operating system.
-Available API calls relating to ACLs are described in detail in
-.Xr acl 3 .
-
-The patches supporting other POSIX.1e features are not available in the
-base operating system at this time--however, more information on them
-may be found on the FreeBSD POSIX.1e implementation web page:
-
-http://www.watson.org/fbsd-hardening/posix1e/
-.Sh IMPLEMENTATION NOTES
-FreeBSD's support for POSIX.1e interfaces and features is still under
-development at this time.
-.Sh ENVIRONMENT
-POSIX.1e assigns security labels to all objects, extending the security
-functionality described in POSIX.1. These additional labels provide
-fine-grained discretionary access control, fine-grained capabilities,
-and labels necessary for mandatory access control. POSIX.2c describes
-a set of userland utilities for manipulating these labels. These userland
-utilities are not bundled with
-.Fx 4.0
-so as to discourage their
-use in the short term.
-.Sh FILES
-.Sh SEE ALSO
-.Xr acl 3 ,
-.Xr acl 9 ,
-.Xr extattr 9
-.Sh STANDARDS
-POSIX.1e is described in IEEE POSIX.1e draft 17. Discussion
-of the draft continues on the cross-platform POSIX.1e implementation
-mailing list. To join this list, see the
-.Fx
-POSIX.1e implementation
-page for more information.
-.Sh HISTORY
-POSIX.1e support was introduced in
-.Fx 4.0 ,
-and development continues.
-.Sh AUTHORS
-.An Robert N M Watson ,
-.An Ilmar S Habibulin
-.Sh BUGS
-These features are not yet fully implemented. In particular, the shipped
-version of UFS/FFS does not support storage of additional security labels,
-and so is unable to (easily) provide support for most of these features.
diff --git a/lib/libc/stdlib/strtoll.c b/lib/libc/stdlib/strtoll.c
deleted file mode 100644
index f84e030531bb..000000000000
--- a/lib/libc/stdlib/strtoll.c
+++ /dev/null
@@ -1,138 +0,0 @@
-/*-
- * 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. 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, Berkeley and its contributors.
- * 4. 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strtoq.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/types.h>
-
-#include <limits.h>
-#include <errno.h>
-#include <ctype.h>
-#include <stdlib.h>
-
-/*
- * Convert a string to a quad integer.
- *
- * Ignores `locale' stuff. Assumes that the upper and lower case
- * alphabets and digits are each contiguous.
- */
-quad_t
-strtoq(nptr, endptr, base)
- const char *nptr;
- char **endptr;
- register int base;
-{
- register const char *s;
- register u_quad_t acc;
- register unsigned char c;
- register u_quad_t qbase, cutoff;
- register int neg, any, cutlim;
-
- /*
- * Skip white space and pick up leading +/- sign if any.
- * If base is 0, allow 0x for hex and 0 for octal, else
- * assume decimal; if base is already 16, allow 0x.
- */
- s = nptr;
- do {
- c = *s++;
- } while (isspace(c));
- if (c == '-') {
- neg = 1;
- c = *s++;
- } else {
- neg = 0;
- if (c == '+')
- c = *s++;
- }
- if ((base == 0 || base == 16) &&
- c == '0' && (*s == 'x' || *s == 'X')) {
- c = s[1];
- s += 2;
- base = 16;
- }
- if (base == 0)
- base = c == '0' ? 8 : 10;
-
- /*
- * Compute the cutoff value between legal numbers and illegal
- * numbers. That is the largest legal value, divided by the
- * base. An input number that is greater than this value, if
- * followed by a legal input character, is too big. One that
- * is equal to this value may be valid or not; the limit
- * between valid and invalid numbers is then based on the last
- * digit. For instance, if the range for quads is
- * [-9223372036854775808..9223372036854775807] and the input base
- * is 10, cutoff will be set to 922337203685477580 and cutlim to
- * either 7 (neg==0) or 8 (neg==1), meaning that if we have
- * accumulated a value > 922337203685477580, or equal but the
- * next digit is > 7 (or 8), the number is too big, and we will
- * return a range error.
- *
- * Set any if any `digits' consumed; make it negative to indicate
- * overflow.
- */
- qbase = (unsigned)base;
- cutoff = neg ? (u_quad_t)-(QUAD_MIN + QUAD_MAX) + QUAD_MAX : QUAD_MAX;
- cutlim = cutoff % qbase;
- cutoff /= qbase;
- for (acc = 0, any = 0;; c = *s++) {
- if (!isascii(c))
- break;
- if (isdigit(c))
- c -= '0';
- else if (isalpha(c))
- c -= isupper(c) ? 'A' - 10 : 'a' - 10;
- else
- break;
- if (c >= base)
- break;
- if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
- any = -1;
- else {
- any = 1;
- acc *= qbase;
- acc += c;
- }
- }
- if (any < 0) {
- acc = neg ? QUAD_MIN : QUAD_MAX;
- errno = ERANGE;
- } else if (neg)
- acc = -acc;
- if (endptr != 0)
- *endptr = (char *)(any ? s - 1 : nptr);
- return (acc);
-}
diff --git a/lib/libc/stdlib/strtoull.c b/lib/libc/stdlib/strtoull.c
deleted file mode 100644
index 7656a3c53b14..000000000000
--- a/lib/libc/stdlib/strtoull.c
+++ /dev/null
@@ -1,116 +0,0 @@
-/*-
- * 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. 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, Berkeley and its contributors.
- * 4. 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strtouq.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/types.h>
-
-#include <limits.h>
-#include <errno.h>
-#include <ctype.h>
-#include <stdlib.h>
-
-/*
- * Convert a string to an unsigned quad integer.
- *
- * Ignores `locale' stuff. Assumes that the upper and lower case
- * alphabets and digits are each contiguous.
- */
-u_quad_t
-strtouq(nptr, endptr, base)
- const char *nptr;
- char **endptr;
- register int base;
-{
- register const char *s = nptr;
- register u_quad_t acc;
- register unsigned char c;
- register u_quad_t qbase, cutoff;
- register int neg, any, cutlim;
-
- /*
- * See strtoq for comments as to the logic used.
- */
- s = nptr;
- do {
- c = *s++;
- } while (isspace(c));
- if (c == '-') {
- neg = 1;
- c = *s++;
- } else {
- neg = 0;
- if (c == '+')
- c = *s++;
- }
- if ((base == 0 || base == 16) &&
- c == '0' && (*s == 'x' || *s == 'X')) {
- c = s[1];
- s += 2;
- base = 16;
- }
- if (base == 0)
- base = c == '0' ? 8 : 10;
- qbase = (unsigned)base;
- cutoff = (u_quad_t)UQUAD_MAX / qbase;
- cutlim = (u_quad_t)UQUAD_MAX % qbase;
- for (acc = 0, any = 0;; c = *s++) {
- if (!isascii(c))
- break;
- if (isdigit(c))
- c -= '0';
- else if (isalpha(c))
- c -= isupper(c) ? 'A' - 10 : 'a' - 10;
- else
- break;
- if (c >= base)
- break;
- if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
- any = -1;
- else {
- any = 1;
- acc *= qbase;
- acc += c;
- }
- }
- if (any < 0) {
- acc = UQUAD_MAX;
- errno = ERANGE;
- } else if (neg)
- acc = -acc;
- if (endptr != 0)
- *endptr = (char *)(any ? s - 1 : nptr);
- return (acc);
-}
diff --git a/lib/libc_r/arch/amd64/_atomic_lock.S b/lib/libc_r/arch/amd64/_atomic_lock.S
deleted file mode 100644
index afaec7125ca1..000000000000
--- a/lib/libc_r/arch/amd64/_atomic_lock.S
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>.
- * All rights reserved.
- * copyright Douglas Santry 1996
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the above copyright is retained
- * in the source form.
- *
- * THIS SOFTWARE IS PROVIDED BY Douglas Santry 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 Douglas Santry 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.
- *
- * $FreeBSD$
- *
- */
-
-#if defined(LIBC_RCS) && !defined(lint)
- .text
- .asciz "$FreeBSD$"
-#endif /* LIBC_RCS and not lint */
-
-#include "DEFS.h"
-
-/*
- * Atomicly lock a location with an identifier provided the location
- * is not currently locked.
- *
- * long _atomic_lock(long *);
- * eax will contain the return value (zero if lock obtained).
- */
-ENTRY(_atomic_lock)
- movl 4(%esp), %ecx
- movl $1, %eax
- xchg %eax, (%ecx)
- ret
-
diff --git a/lib/libkse/Makefile b/lib/libkse/Makefile
deleted file mode 100644
index 1b0afbbf40f7..000000000000
--- a/lib/libkse/Makefile
+++ /dev/null
@@ -1,45 +0,0 @@
-# $FreeBSD$
-#
-# All library objects contain rcsid strings by default; they may be
-# excluded as a space-saving measure. To produce a library that does
-# not contain these strings, delete -DLIBC_RCS and -DSYSLIBC_RCS
-# from CFLAGS below. To remove these strings from just the system call
-# stubs, remove just -DSYSLIBC_RCS from CFLAGS.
-LIB=c_r
-SHLIB_MAJOR= 4
-SHLIB_MINOR= 0
-CFLAGS+=-DLIBC_RCS -DSYSLIBC_RCS -I${.CURDIR}/../libc/include
-CFLAGS+=-DPTHREAD_KERNEL -D_THREAD_SAFE -I${.CURDIR}/uthread
-CFLAGS+=-I${.CURDIR}/../../include
-
-# Uncomment this if you want libc_r to contain debug information for
-# thread locking.
-CFLAGS+=-D_LOCK_DEBUG
-
-# enable extra internal consistancy checks
-# CFLAGS+=-D_PTHREADS_INVARIANTS
-
-AINC= -I${.CURDIR}/../libc/${MACHINE_ARCH} -I${.CURDIR}/uthread
-PRECIOUSLIB= yes
-
-#
-# This is a list of syscalls that are renamed as _thread_sys_{syscall}
-# so that libc_r can provide replacement functions.
-#
-HIDDEN_SYSCALLS= aio_suspend.o accept.o bind.o close.o connect.o dup.o dup2.o \
- execve.o fchflags.o fchmod.o fchown.o fcntl.o \
- flock.o fpathconf.o fstat.o fstatfs.o fsync.o getdirentries.o \
- getlogin.o getpeername.o getsockname.o getsockopt.o ioctl.o listen.o \
- msync.o nanosleep.o nfssvc.o open.o poll.o read.o readv.o recvfrom.o \
- recvmsg.o sched_yield.o select.o sendmsg.o sendto.o \
- setsockopt.o shutdown.o sigaction.o sigaltstack.o \
- signanosleep.o sigpending.o sigprocmask.o sigreturn.o sigsetmask.o \
- sigsuspend.o socket.o \
- socketpair.o wait4.o write.o writev.o
-
-.include "${.CURDIR}/../libc/Makefile.inc"
-.include "${.CURDIR}/man/Makefile.inc"
-.include "${.CURDIR}/uthread/Makefile.inc"
-.include "${.CURDIR}/sys/Makefile.inc"
-
-.include <bsd.lib.mk>
diff --git a/lib/libkse/sys/Makefile.inc b/lib/libkse/sys/Makefile.inc
deleted file mode 100644
index e608afa69909..000000000000
--- a/lib/libkse/sys/Makefile.inc
+++ /dev/null
@@ -1,6 +0,0 @@
-# $FreeBSD$
-
-.PATH: ${.CURDIR}/sys ${.CURDIR}/arch/${MACHINE_ARCH}
-
-SRCS+= uthread_error.c _atomic_lock.S
-
diff --git a/lib/libkse/sys/thr_error.c b/lib/libkse/sys/thr_error.c
deleted file mode 100644
index 0d08ae83729a..000000000000
--- a/lib/libkse/sys/thr_error.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
- * Copyright (c) 1994 by Chris Provenzano, proven@mit.edu
- * 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 John Birrell
- * and Chris Provenzano.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
- *
- * $FreeBSD$
- */
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-extern int errno;
-
-int * __error()
-{
- int *p_errno;
- if (_thread_run == _thread_initial) {
- p_errno = &errno;
- } else {
- p_errno = &_thread_run->error;
- }
- return(p_errno);
-}
-#endif
diff --git a/lib/libkse/test/Makefile b/lib/libkse/test/Makefile
deleted file mode 100644
index 90ee5ad59ea4..000000000000
--- a/lib/libkse/test/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-# $FreeBSD$
-#
-# Tests for libc_r functionality.
-#
-
-SUBDIR= mutex sigsuspend sigwait
-
-.include <bsd.subdir.mk>
diff --git a/lib/libkse/thread/Makefile.inc b/lib/libkse/thread/Makefile.inc
deleted file mode 100644
index a88f9552b99b..000000000000
--- a/lib/libkse/thread/Makefile.inc
+++ /dev/null
@@ -1,127 +0,0 @@
-# $FreeBSD$
-
-# uthread sources
-.PATH: ${.CURDIR}/uthread
-
-SRCS+= \
- uthread_accept.c \
- uthread_aio_suspend.c \
- uthread_attr_destroy.c \
- uthread_attr_init.c \
- uthread_attr_getdetachstate.c \
- uthread_attr_getinheritsched.c \
- uthread_attr_getschedparam.c \
- uthread_attr_getschedpolicy.c \
- uthread_attr_getscope.c \
- uthread_attr_getstackaddr.c \
- uthread_attr_getstacksize.c \
- uthread_attr_setcreatesuspend_np.c \
- uthread_attr_setdetachstate.c \
- uthread_attr_setinheritsched.c \
- uthread_attr_setschedparam.c \
- uthread_attr_setschedpolicy.c \
- uthread_attr_setscope.c \
- uthread_attr_setstackaddr.c \
- uthread_attr_setstacksize.c \
- uthread_autoinit.cc \
- uthread_bind.c \
- uthread_cancel.c \
- uthread_clean.c \
- uthread_close.c \
- uthread_cond.c \
- uthread_condattr_destroy.c \
- uthread_condattr_init.c \
- uthread_connect.c \
- uthread_creat.c \
- uthread_create.c \
- uthread_detach.c \
- uthread_dup.c \
- uthread_dup2.c \
- uthread_equal.c \
- uthread_execve.c \
- uthread_exit.c \
- uthread_fchflags.c \
- uthread_fchmod.c \
- uthread_fchown.c \
- uthread_fcntl.c \
- uthread_fd.c \
- uthread_file.c \
- uthread_find_thread.c \
- uthread_flock.c \
- uthread_fork.c \
- uthread_fstat.c \
- uthread_fstatfs.c \
- uthread_fsync.c \
- uthread_gc.c \
- uthread_getdirentries.c \
- uthread_getpeername.c \
- uthread_getprio.c \
- uthread_getschedparam.c \
- uthread_getsockname.c \
- uthread_getsockopt.c \
- uthread_info.c \
- uthread_init.c \
- uthread_ioctl.c \
- uthread_jmp.c \
- uthread_join.c \
- uthread_kern.c \
- uthread_kill.c \
- uthread_listen.c \
- uthread_mattr_init.c \
- uthread_mattr_kind_np.c \
- uthread_msync.c \
- uthread_multi_np.c \
- uthread_mutex.c \
- uthread_mutex_prioceiling.c \
- uthread_mutex_protocol.c \
- uthread_mutexattr_destroy.c \
- uthread_nanosleep.c \
- uthread_once.c \
- uthread_open.c \
- uthread_pause.c \
- uthread_pipe.c \
- uthread_poll.c \
- uthread_priority_queue.c \
- uthread_read.c \
- uthread_readv.c \
- uthread_recvfrom.c \
- uthread_recvmsg.c \
- uthread_resume_np.c \
- uthread_rwlock.c \
- uthread_rwlockattr.c \
- uthread_select.c \
- uthread_self.c \
- uthread_sem.c \
- uthread_sendmsg.c \
- uthread_sendto.c \
- uthread_seterrno.c \
- uthread_setprio.c \
- uthread_setschedparam.c \
- uthread_setsockopt.c \
- uthread_shutdown.c \
- uthread_sig.c \
- uthread_sigaction.c \
- uthread_sigblock.c \
- uthread_sigmask.c \
- uthread_sigpending.c \
- uthread_sigprocmask.c \
- uthread_sigsetmask.c \
- uthread_sigsuspend.c \
- uthread_sigwait.c \
- uthread_single_np.c \
- uthread_sleep.c \
- uthread_socket.c \
- uthread_socketpair.c \
- uthread_spec.c \
- uthread_spinlock.c \
- uthread_suspend_np.c \
- uthread_switch_np.c \
- uthread_system.c \
- uthread_tcdrain.c \
- uthread_vfork.c \
- uthread_wait.c \
- uthread_wait4.c \
- uthread_waitpid.c \
- uthread_write.c \
- uthread_writev.c \
- uthread_yield.c
diff --git a/lib/libkse/thread/thr_aio_suspend.c b/lib/libkse/thread/thr_aio_suspend.c
deleted file mode 100644
index 5940282fe0a3..000000000000
--- a/lib/libkse/thread/thr_aio_suspend.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2000 Jason Evans <jasone@canonware.com>.
- * 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(s), this list of conditions and the following disclaimer as
- * the first lines of this file unmodified other than the possible
- * addition of one or more copyright notices.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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.
- *
- * $FreeBSD$
- */
-
-#include <aio.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-_aio_suspend(const struct aiocb * const iocbs[], int niocb, const struct
- timespec *timeout)
-{
- int ret;
-
- _thread_enter_cancellation_point();
- ret = _aio_suspend(iocbs, niocb, timeout);
- _thread_leave_cancellation_point();
-
- return ret;
-}
-
-__strong_reference(_aio_suspend, aio_suspend);
-#endif
diff --git a/lib/libkse/thread/thr_attr_destroy.c b/lib/libkse/thread/thr_attr_destroy.c
deleted file mode 100644
index dfe668ea2181..000000000000
--- a/lib/libkse/thread/thr_attr_destroy.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <stdlib.h>
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int pthread_attr_destroy(pthread_attr_t *attr)
-{
- int ret;
-
- /* Check for invalid arguments: */
- if (attr == NULL || *attr == NULL)
- /* Invalid argument: */
- ret = EINVAL;
- else {
- /* Free the memory allocated to the attribute object: */
- free(*attr);
-
- /*
- * Leave the attribute pointer NULL now that the memory
- * has been freed:
- */
- *attr = NULL;
- ret = 0;
- }
- return(ret);
-}
-#endif
diff --git a/lib/libkse/thread/thr_attr_getdetachstate.c b/lib/libkse/thread/thr_attr_getdetachstate.c
deleted file mode 100644
index fee1e8b11a2a..000000000000
--- a/lib/libkse/thread/thr_attr_getdetachstate.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int pthread_attr_getdetachstate(pthread_attr_t *attr, int *detachstate)
-{
- int ret;
-
- /* Check for invalid arguments: */
- if (attr == NULL || *attr == NULL || detachstate == NULL)
- ret = EINVAL;
- else {
- /* Check if the detached flag is set: */
- if ((*attr)->flags & PTHREAD_DETACHED)
- /* Return detached: */
- *detachstate = PTHREAD_CREATE_DETACHED;
- else
- /* Return joinable: */
- *detachstate = PTHREAD_CREATE_JOINABLE;
- ret = 0;
- }
- return(ret);
-}
-#endif
diff --git a/lib/libkse/thread/thr_attr_getinheritsched.c b/lib/libkse/thread/thr_attr_getinheritsched.c
deleted file mode 100644
index 7e243ed5b946..000000000000
--- a/lib/libkse/thread/thr_attr_getinheritsched.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>.
- * 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 Daniel Eischen.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_attr_getinheritsched(const pthread_attr_t *attr, int *sched_inherit)
-{
- int ret = 0;
-
- if ((attr == NULL) || (*attr == NULL))
- ret = EINVAL;
- else
- *sched_inherit = (*attr)->sched_inherit;
-
- return(ret);
-}
-#endif
diff --git a/lib/libkse/thread/thr_attr_getschedparam.c b/lib/libkse/thread/thr_attr_getschedparam.c
deleted file mode 100644
index 46586ffdd30d..000000000000
--- a/lib/libkse/thread/thr_attr_getschedparam.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>.
- * 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 Daniel Eischen.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_attr_getschedparam(const pthread_attr_t *attr, struct sched_param *param)
-{
- int ret = 0;
-
- if ((attr == NULL) || (*attr == NULL) || (param == NULL))
- ret = EINVAL;
- else
- param->sched_priority = (*attr)->prio;
-
- return(ret);
-}
-#endif
diff --git a/lib/libkse/thread/thr_attr_getschedpolicy.c b/lib/libkse/thread/thr_attr_getschedpolicy.c
deleted file mode 100644
index 19f835c46b93..000000000000
--- a/lib/libkse/thread/thr_attr_getschedpolicy.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>.
- * 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 Daniel Eischen.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_attr_getschedpolicy(const pthread_attr_t *attr, int *policy)
-{
- int ret = 0;
-
- if ((attr == NULL) || (*attr == NULL) || (policy == NULL))
- ret = EINVAL;
- else
- *policy = (*attr)->sched_policy;
-
- return(ret);
-}
-#endif
diff --git a/lib/libkse/thread/thr_attr_getscope.c b/lib/libkse/thread/thr_attr_getscope.c
deleted file mode 100644
index 176f01bfe47c..000000000000
--- a/lib/libkse/thread/thr_attr_getscope.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>.
- * 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 Daniel Eischen.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_attr_getscope(const pthread_attr_t *attr, int *contentionscope)
-{
- int ret = 0;
-
- if ((attr == NULL) || (*attr == NULL) || (contentionscope == NULL))
- /* Return an invalid argument: */
- ret = EINVAL;
-
- else
- *contentionscope = (*attr)->flags & PTHREAD_SCOPE_SYSTEM ?
- PTHREAD_SCOPE_SYSTEM : PTHREAD_SCOPE_PROCESS;
-
- return(ret);
-}
-#endif
diff --git a/lib/libkse/thread/thr_attr_getstackaddr.c b/lib/libkse/thread/thr_attr_getstackaddr.c
deleted file mode 100644
index 1fee4a5f8717..000000000000
--- a/lib/libkse/thread/thr_attr_getstackaddr.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int pthread_attr_getstackaddr(pthread_attr_t *attr, void **stackaddr)
-{
- int ret;
-
- /* Check for invalid arguments: */
- if (attr == NULL || *attr == NULL || stackaddr == NULL)
- ret = EINVAL;
- else {
- /* Return the stack address: */
- *stackaddr = (*attr)->stackaddr_attr;
- ret = 0;
- }
- return(ret);
-}
-#endif
diff --git a/lib/libkse/thread/thr_attr_getstacksize.c b/lib/libkse/thread/thr_attr_getstacksize.c
deleted file mode 100644
index 5c7a9e071359..000000000000
--- a/lib/libkse/thread/thr_attr_getstacksize.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int pthread_attr_getstacksize(pthread_attr_t *attr, size_t *stacksize)
-{
- int ret;
-
- /* Check for invalid arguments: */
- if (attr == NULL || *attr == NULL || stacksize == NULL)
- ret = EINVAL;
- else {
- /* Return the stack size: */
- *stacksize = (*attr)->stacksize_attr;
- ret = 0;
- }
- return(ret);
-}
-#endif
diff --git a/lib/libkse/thread/thr_attr_init.c b/lib/libkse/thread/thr_attr_init.c
deleted file mode 100644
index dbe3091b0ab2..000000000000
--- a/lib/libkse/thread/thr_attr_init.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int pthread_attr_init(pthread_attr_t *attr)
-{
- int ret;
- pthread_attr_t pattr;
-
- /* Allocate memory for the attribute object: */
- if ((pattr = (pthread_attr_t) malloc(sizeof(struct pthread_attr))) == NULL)
- /* Insufficient memory: */
- ret = ENOMEM;
- else {
- /* Initialise the attribute object with the defaults: */
- memcpy(pattr, &pthread_attr_default, sizeof(struct pthread_attr));
-
- /* Return a pointer to the attribute object: */
- *attr = pattr;
- ret = 0;
- }
- return(ret);
-}
-#endif
diff --git a/lib/libkse/thread/thr_attr_setcreatesuspend_np.c b/lib/libkse/thread/thr_attr_setcreatesuspend_np.c
deleted file mode 100644
index d230397f743f..000000000000
--- a/lib/libkse/thread/thr_attr_setcreatesuspend_np.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_attr_setcreatesuspend_np(pthread_attr_t *attr)
-{
- int ret;
- if (attr == NULL || *attr == NULL) {
- errno = EINVAL;
- ret = -1;
- } else {
- (*attr)->suspend = PTHREAD_CREATE_SUSPENDED;
- ret = 0;
- }
- return(ret);
-}
-#endif
diff --git a/lib/libkse/thread/thr_attr_setdetachstate.c b/lib/libkse/thread/thr_attr_setdetachstate.c
deleted file mode 100644
index 6be3e4ee73b3..000000000000
--- a/lib/libkse/thread/thr_attr_setdetachstate.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate)
-{
- int ret;
-
- /* Check for invalid arguments: */
- if (attr == NULL || *attr == NULL ||
- (detachstate != PTHREAD_CREATE_DETACHED &&
- detachstate != PTHREAD_CREATE_JOINABLE))
- ret = EINVAL;
- else {
- /* Check if detached state: */
- if (detachstate == PTHREAD_CREATE_DETACHED)
- /* Set the detached flag: */
- (*attr)->flags |= PTHREAD_DETACHED;
- else
- /* Reset the detached flag: */
- (*attr)->flags &= ~PTHREAD_DETACHED;
- ret = 0;
- }
- return(ret);
-}
-#endif
diff --git a/lib/libkse/thread/thr_attr_setinheritsched.c b/lib/libkse/thread/thr_attr_setinheritsched.c
deleted file mode 100644
index eb2384b8fc2b..000000000000
--- a/lib/libkse/thread/thr_attr_setinheritsched.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>.
- * 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 Daniel Eischen.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_attr_setinheritsched(pthread_attr_t *attr, int sched_inherit)
-{
- int ret = 0;
-
- if ((attr == NULL) || (*attr == NULL))
- ret = EINVAL;
- else
- (*attr)->sched_inherit = sched_inherit;
-
- return(ret);
-}
-#endif
diff --git a/lib/libkse/thread/thr_attr_setschedparam.c b/lib/libkse/thread/thr_attr_setschedparam.c
deleted file mode 100644
index 5746fe2fffb1..000000000000
--- a/lib/libkse/thread/thr_attr_setschedparam.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>.
- * 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 Daniel Eischen.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_attr_setschedparam(pthread_attr_t *attr, const struct sched_param *param)
-{
- int ret = 0;
-
- if ((attr == NULL) || (*attr == NULL) || (param == NULL))
- ret = EINVAL;
- else
- (*attr)->prio = param->sched_priority;
-
- return(ret);
-}
-#endif
diff --git a/lib/libkse/thread/thr_attr_setschedpolicy.c b/lib/libkse/thread/thr_attr_setschedpolicy.c
deleted file mode 100644
index 640cb38f0b06..000000000000
--- a/lib/libkse/thread/thr_attr_setschedpolicy.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>.
- * 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 Daniel Eischen.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy)
-{
- int ret = 0;
-
- if ((attr == NULL) || (*attr == NULL) || (policy < SCHED_FIFO) ||
- (policy > SCHED_RR))
- ret = EINVAL;
- else
- (*attr)->sched_policy = policy;
-
- return(ret);
-}
-#endif
diff --git a/lib/libkse/thread/thr_attr_setscope.c b/lib/libkse/thread/thr_attr_setscope.c
deleted file mode 100644
index 84239d7f6613..000000000000
--- a/lib/libkse/thread/thr_attr_setscope.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>.
- * 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 Daniel Eischen.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_attr_setscope(pthread_attr_t *attr, int contentionscope)
-{
- int ret = 0;
-
- if ((attr == NULL) || (*attr == NULL) ||
- (contentionscope != PTHREAD_SCOPE_PROCESS) ||
- (contentionscope != PTHREAD_SCOPE_SYSTEM))
- /* Return an invalid argument: */
- ret = EINVAL;
-
- else if (contentionscope == PTHREAD_SCOPE_SYSTEM)
- /* We don't support system wide contention: */
-#ifdef NOT_YET
- ret = ENOTSUP;
-#else
- ret = EOPNOTSUPP;
-#endif
-
- else
- (*attr)->flags |= contentionscope;
-
- return(ret);
-}
-#endif
diff --git a/lib/libkse/thread/thr_attr_setstackaddr.c b/lib/libkse/thread/thr_attr_setstackaddr.c
deleted file mode 100644
index 46469e4faf87..000000000000
--- a/lib/libkse/thread/thr_attr_setstackaddr.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_attr_setstackaddr(pthread_attr_t *attr, void *stackaddr)
-{
- int ret;
-
- /* Check for invalid arguments: */
- if (attr == NULL || *attr == NULL || stackaddr == NULL)
- ret = EINVAL;
- else {
- /* Save the stack address: */
- (*attr)->stackaddr_attr = stackaddr;
- ret = 0;
- }
- return(ret);
-}
-#endif
diff --git a/lib/libkse/thread/thr_attr_setstacksize.c b/lib/libkse/thread/thr_attr_setstacksize.c
deleted file mode 100644
index 3897811bb436..000000000000
--- a/lib/libkse/thread/thr_attr_setstacksize.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize)
-{
- int ret;
-
- /* Check for invalid arguments: */
- if (attr == NULL || *attr == NULL || stacksize < PTHREAD_STACK_MIN)
- ret = EINVAL;
- else {
- /* Save the stack size: */
- (*attr)->stacksize_attr = stacksize;
- ret = 0;
- }
- return(ret);
-}
-#endif
diff --git a/lib/libkse/thread/thr_cancel.c b/lib/libkse/thread/thr_cancel.c
deleted file mode 100644
index f22bfb55972d..000000000000
--- a/lib/libkse/thread/thr_cancel.c
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * David Leonard <d@openbsd.org>, 1999. Public domain.
- * $FreeBSD$
- */
-#include <sys/errno.h>
-#include <pthread.h>
-#include "pthread_private.h"
-
-static void finish_cancellation(void *arg);
-
-int
-pthread_cancel(pthread_t pthread)
-{
- int ret;
-
- if ((ret = _find_thread(pthread)) != 0) {
- /* NOTHING */
- } else if (pthread->state == PS_DEAD || pthread->state == PS_DEADLOCK) {
- ret = 0;
- } else {
- /* Protect the scheduling queues: */
- _thread_kern_sig_defer();
-
- if (((pthread->cancelflags & PTHREAD_CANCEL_DISABLE) != 0) ||
- (((pthread->cancelflags & PTHREAD_CANCEL_ASYNCHRONOUS) == 0) &&
- ((pthread->cancelflags & PTHREAD_AT_CANCEL_POINT) == 0)))
- /* Just mark it for cancellation: */
- pthread->cancelflags |= PTHREAD_CANCELLING;
- else {
- /*
- * Check if we need to kick it back into the
- * run queue:
- */
- switch (pthread->state) {
- case PS_RUNNING:
- /* No need to resume: */
- pthread->cancelflags |= PTHREAD_CANCELLING;
- break;
-
- case PS_SPINBLOCK:
- case PS_FDR_WAIT:
- case PS_FDW_WAIT:
- case PS_POLL_WAIT:
- case PS_SELECT_WAIT:
- /* Remove these threads from the work queue: */
- if ((pthread->flags & PTHREAD_FLAGS_IN_WORKQ)
- != 0)
- PTHREAD_WORKQ_REMOVE(pthread);
- /* Fall through: */
- case PS_SIGTHREAD:
- case PS_SLEEP_WAIT:
- case PS_WAIT_WAIT:
- case PS_SIGSUSPEND:
- case PS_SIGWAIT:
- case PS_SUSPENDED:
- /* Interrupt and resume: */
- pthread->interrupted = 1;
- pthread->cancelflags |= PTHREAD_CANCELLING;
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
- break;
-
- case PS_MUTEX_WAIT:
- case PS_COND_WAIT:
- case PS_FDLR_WAIT:
- case PS_FDLW_WAIT:
- case PS_FILE_WAIT:
- case PS_JOIN:
- /*
- * Threads in these states may be in queues.
- * In order to preserve queue integrity, the
- * cancelled thread must remove itself from the
- * queue. Mark the thread as interrupted and
- * needing cancellation, and set the state to
- * running. When the thread resumes, it will
- * remove itself from the queue and call the
- * cancellation completion routine.
- */
- pthread->interrupted = 1;
- pthread->cancelflags |= PTHREAD_CANCEL_NEEDED;
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
- pthread->continuation = finish_cancellation;
- break;
-
- case PS_DEAD:
- case PS_DEADLOCK:
- case PS_STATE_MAX:
- /* Ignore - only here to silence -Wall: */
- break;
- }
- }
-
- /* Unprotect the scheduling queues: */
- _thread_kern_sig_undefer();
-
- ret = 0;
- }
- return (ret);
-}
-
-int
-pthread_setcancelstate(int state, int *oldstate)
-{
- int ostate;
- int ret;
-
- ostate = _thread_run->cancelflags & PTHREAD_CANCEL_DISABLE;
-
- switch (state) {
- case PTHREAD_CANCEL_ENABLE:
- if (oldstate != NULL)
- *oldstate = ostate;
- _thread_run->cancelflags &= ~PTHREAD_CANCEL_DISABLE;
- if ((_thread_run->cancelflags & PTHREAD_CANCEL_ASYNCHRONOUS) != 0)
- pthread_testcancel();
- ret = 0;
- break;
- case PTHREAD_CANCEL_DISABLE:
- if (oldstate != NULL)
- *oldstate = ostate;
- _thread_run->cancelflags |= PTHREAD_CANCEL_DISABLE;
- ret = 0;
- break;
- default:
- ret = EINVAL;
- }
-
- return (ret);
-}
-
-int
-pthread_setcanceltype(int type, int *oldtype)
-{
- int otype;
- int ret;
-
- otype = _thread_run->cancelflags & PTHREAD_CANCEL_ASYNCHRONOUS;
- switch (type) {
- case PTHREAD_CANCEL_ASYNCHRONOUS:
- if (oldtype != NULL)
- *oldtype = otype;
- _thread_run->cancelflags |= PTHREAD_CANCEL_ASYNCHRONOUS;
- pthread_testcancel();
- ret = 0;
- break;
- case PTHREAD_CANCEL_DEFERRED:
- if (oldtype != NULL)
- *oldtype = otype;
- _thread_run->cancelflags &= ~PTHREAD_CANCEL_ASYNCHRONOUS;
- ret = 0;
- break;
- default:
- ret = EINVAL;
- }
-
- return (ret);
-}
-
-void
-pthread_testcancel(void)
-{
- if (((_thread_run->cancelflags & PTHREAD_CANCEL_DISABLE) == 0) &&
- ((_thread_run->cancelflags & PTHREAD_CANCELLING) != 0)) {
- /*
- * It is possible for this thread to be swapped out
- * while performing cancellation; do not allow it
- * to be cancelled again.
- */
- _thread_run->cancelflags &= ~PTHREAD_CANCELLING;
- _thread_exit_cleanup();
- pthread_exit(PTHREAD_CANCELED);
- PANIC("cancel");
- }
-}
-
-void
-_thread_enter_cancellation_point(void)
-{
- /* Look for a cancellation before we block: */
- pthread_testcancel();
- _thread_run->cancelflags |= PTHREAD_AT_CANCEL_POINT;
-}
-
-void
-_thread_leave_cancellation_point(void)
-{
- _thread_run->cancelflags &= ~PTHREAD_AT_CANCEL_POINT;
- /* Look for a cancellation after we unblock: */
- pthread_testcancel();
-}
-
-static void
-finish_cancellation(void *arg)
-{
- _thread_run->continuation = NULL;
- _thread_run->interrupted = 0;
-
- if ((_thread_run->cancelflags & PTHREAD_CANCEL_NEEDED) != 0) {
- _thread_run->cancelflags &= ~PTHREAD_CANCEL_NEEDED;
- _thread_exit_cleanup();
- pthread_exit(PTHREAD_CANCELED);
- }
-}
diff --git a/lib/libkse/thread/thr_clean.c b/lib/libkse/thread/thr_clean.c
deleted file mode 100644
index bba5500c8fe7..000000000000
--- a/lib/libkse/thread/thr_clean.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <signal.h>
-#include <errno.h>
-#include <stdlib.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-void
-pthread_cleanup_push(void (*routine) (void *), void *routine_arg)
-{
- struct pthread_cleanup *new;
-
- if ((new = (struct pthread_cleanup *) malloc(sizeof(struct pthread_cleanup))) != NULL) {
- new->routine = routine;
- new->routine_arg = routine_arg;
- new->next = _thread_run->cleanup;
-
- _thread_run->cleanup = new;
- }
-}
-
-void
-pthread_cleanup_pop(int execute)
-{
- struct pthread_cleanup *old;
-
- if ((old = _thread_run->cleanup) != NULL) {
- _thread_run->cleanup = old->next;
- if (execute) {
- old->routine(old->routine_arg);
- }
- free(old);
- }
-}
-
-#endif
diff --git a/lib/libkse/thread/thr_close.c b/lib/libkse/thread/thr_close.c
deleted file mode 100644
index 9dee2bc8b56e..000000000000
--- a/lib/libkse/thread/thr_close.c
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-_close(int fd)
-{
- int flags;
- int ret;
- struct stat sb;
- struct fd_table_entry *entry;
-
- if ((fd == _thread_kern_pipe[0]) || (fd == _thread_kern_pipe[1])) {
- /*
- * Don't allow silly programs to close the kernel pipe.
- */
- errno = EBADF;
- ret = -1;
- }
- /*
- * Lock the file descriptor while the file is closed and get
- * the file descriptor status:
- */
- else if (((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) &&
- ((ret = _thread_sys_fstat(fd, &sb)) == 0)) {
- /*
- * Check if the file should be left as blocking.
- *
- * This is so that the file descriptors shared with a parent
- * process aren't left set to non-blocking if the child
- * closes them prior to exit. An example where this causes
- * problems with /bin/sh is when a child closes stdin.
- *
- * Setting a file as blocking causes problems if a threaded
- * parent accesses the file descriptor before the child exits.
- * Once the threaded parent receives a SIGCHLD then it resets
- * all of its files to non-blocking, and so it is then safe
- * to access them.
- *
- * Pipes are not set to blocking when they are closed, as
- * the parent and child will normally close the file
- * descriptor of the end of the pipe that they are not
- * using, which would then cause any reads to block
- * indefinitely.
- */
- if ((S_ISREG(sb.st_mode) || S_ISCHR(sb.st_mode)) && (_thread_fd_table[fd]->flags & O_NONBLOCK) == 0) {
- /* Get the current flags: */
- flags = _thread_sys_fcntl(fd, F_GETFL, NULL);
- /* Clear the nonblocking file descriptor flag: */
- _thread_sys_fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);
- }
-
- /* XXX: Assumes well behaved threads. */
- /* XXX: Defer real close to avoid race condition */
- entry = _thread_fd_table[fd];
- _thread_fd_table[fd] = NULL;
- free(entry);
-
- /* Close the file descriptor: */
- ret = _thread_sys_close(fd);
- }
- return (ret);
-}
-
-int
-close(int fd)
-{
- int ret;
-
- _thread_enter_cancellation_point();
- ret = _close(fd);
- _thread_leave_cancellation_point();
-
- return ret;
-}
-#endif
diff --git a/lib/libkse/thread/thr_cond.c b/lib/libkse/thread/thr_cond.c
deleted file mode 100644
index d23660788fc9..000000000000
--- a/lib/libkse/thread/thr_cond.c
+++ /dev/null
@@ -1,639 +0,0 @@
-/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <stdlib.h>
-#include <errno.h>
-#include <string.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-/*
- * Prototypes
- */
-static inline pthread_t cond_queue_deq(pthread_cond_t);
-static inline void cond_queue_remove(pthread_cond_t, pthread_t);
-static inline void cond_queue_enq(pthread_cond_t, pthread_t);
-
-/* Reinitialize a condition variable to defaults. */
-int
-_cond_reinit(pthread_cond_t * cond)
-{
- int ret = 0;
-
- if (cond == NULL)
- ret = EINVAL;
- else if (*cond == NULL)
- ret = pthread_cond_init(cond, NULL);
- else {
- /*
- * Initialize the condition variable structure:
- */
- TAILQ_INIT(&(*cond)->c_queue);
- (*cond)->c_flags = COND_FLAGS_INITED;
- (*cond)->c_type = COND_TYPE_FAST;
- (*cond)->c_mutex = NULL;
- memset(&(*cond)->lock, 0, sizeof((*cond)->lock));
- }
- return (ret);
-}
-
-int
-pthread_cond_init(pthread_cond_t * cond, const pthread_condattr_t * cond_attr)
-{
- enum pthread_cond_type type;
- pthread_cond_t pcond;
- int rval = 0;
-
- if (cond == NULL)
- rval = EINVAL;
- else {
- /*
- * Check if a pointer to a condition variable attribute
- * structure was passed by the caller:
- */
- if (cond_attr != NULL && *cond_attr != NULL) {
- /* Default to a fast condition variable: */
- type = (*cond_attr)->c_type;
- } else {
- /* Default to a fast condition variable: */
- type = COND_TYPE_FAST;
- }
-
- /* Process according to condition variable type: */
- switch (type) {
- /* Fast condition variable: */
- case COND_TYPE_FAST:
- /* Nothing to do here. */
- break;
-
- /* Trap invalid condition variable types: */
- default:
- /* Return an invalid argument error: */
- rval = EINVAL;
- break;
- }
-
- /* Check for no errors: */
- if (rval == 0) {
- if ((pcond = (pthread_cond_t)
- malloc(sizeof(struct pthread_cond))) == NULL) {
- rval = ENOMEM;
- } else {
- /*
- * Initialise the condition variable
- * structure:
- */
- TAILQ_INIT(&pcond->c_queue);
- pcond->c_flags |= COND_FLAGS_INITED;
- pcond->c_type = type;
- pcond->c_mutex = NULL;
- memset(&pcond->lock,0,sizeof(pcond->lock));
- *cond = pcond;
- }
- }
- }
- /* Return the completion status: */
- return (rval);
-}
-
-int
-pthread_cond_destroy(pthread_cond_t * cond)
-{
- int rval = 0;
-
- if (cond == NULL || *cond == NULL)
- rval = EINVAL;
- else {
- /* Lock the condition variable structure: */
- _SPINLOCK(&(*cond)->lock);
-
- /*
- * Free the memory allocated for the condition
- * variable structure:
- */
- free(*cond);
-
- /*
- * NULL the caller's pointer now that the condition
- * variable has been destroyed:
- */
- *cond = NULL;
- }
- /* Return the completion status: */
- return (rval);
-}
-
-int
-pthread_cond_wait(pthread_cond_t * cond, pthread_mutex_t * mutex)
-{
- int rval = 0;
- int interrupted = 0;
-
- _thread_enter_cancellation_point();
-
- if (cond == NULL)
- rval = EINVAL;
-
- /*
- * If the condition variable is statically initialized,
- * perform the dynamic initialization:
- */
- else if (*cond != NULL ||
- (rval = pthread_cond_init(cond,NULL)) == 0) {
-
- _thread_enter_cancellation_point();
-
- /* Lock the condition variable structure: */
- _SPINLOCK(&(*cond)->lock);
-
- /*
- * If the condvar was statically allocated, properly
- * initialize the tail queue.
- */
- if (((*cond)->c_flags & COND_FLAGS_INITED) == 0) {
- TAILQ_INIT(&(*cond)->c_queue);
- (*cond)->c_flags |= COND_FLAGS_INITED;
- }
-
- /* Process according to condition variable type: */
- switch ((*cond)->c_type) {
- /* Fast condition variable: */
- case COND_TYPE_FAST:
- if ((mutex == NULL) || (((*cond)->c_mutex != NULL) &&
- ((*cond)->c_mutex != *mutex))) {
- /* Unlock the condition variable structure: */
- _SPINUNLOCK(&(*cond)->lock);
-
- /* Return invalid argument error: */
- rval = EINVAL;
- } else {
- /* Reset the timeout and interrupted flags: */
- _thread_run->timeout = 0;
- _thread_run->interrupted = 0;
-
- /*
- * Queue the running thread for the condition
- * variable:
- */
- cond_queue_enq(*cond, _thread_run);
-
- /* Remember the mutex that is being used: */
- (*cond)->c_mutex = *mutex;
-
- /* Wait forever: */
- _thread_run->wakeup_time.tv_sec = -1;
-
- /* Unlock the mutex: */
- if ((rval = _mutex_cv_unlock(mutex)) != 0) {
- /*
- * Cannot unlock the mutex, so remove
- * the running thread from the condition
- * variable queue:
- */
- cond_queue_remove(*cond, _thread_run);
-
- /* Check for no more waiters: */
- if (TAILQ_FIRST(&(*cond)->c_queue) ==
- NULL)
- (*cond)->c_mutex = NULL;
-
- /* Unlock the condition variable structure: */
- _SPINUNLOCK(&(*cond)->lock);
- }
- else {
- /*
- * Schedule the next thread and unlock
- * the condition variable structure:
- */
- _thread_kern_sched_state_unlock(PS_COND_WAIT,
- &(*cond)->lock, __FILE__, __LINE__);
-
- if (_thread_run->interrupted != 0) {
- /*
- * Remember that this thread
- * was interrupted:
- */
- interrupted = 1;
-
- /*
- * Lock the condition variable
- * while removing the thread.
- */
- _SPINLOCK(&(*cond)->lock);
-
- cond_queue_remove(*cond,
- _thread_run);
-
- /* Check for no more waiters: */
- if (TAILQ_FIRST(&(*cond)->c_queue) == NULL)
- (*cond)->c_mutex = NULL;
-
- _SPINUNLOCK(&(*cond)->lock);
- }
-
- /*
- * Note that even though this thread may have
- * been canceled, POSIX requires that the mutex
- * be reaquired prior to cancellation.
- */
- rval = _mutex_cv_lock(mutex);
- }
- }
- break;
-
- /* Trap invalid condition variable types: */
- default:
- /* Unlock the condition variable structure: */
- _SPINUNLOCK(&(*cond)->lock);
-
- /* Return an invalid argument error: */
- rval = EINVAL;
- break;
- }
-
- if (interrupted != 0 && _thread_run->continuation != NULL)
- _thread_run->continuation((void *) _thread_run);
-
- _thread_leave_cancellation_point();
- }
-
- _thread_leave_cancellation_point();
-
- /* Return the completion status: */
- return (rval);
-}
-
-int
-pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex,
- const struct timespec * abstime)
-{
- int rval = 0;
- int interrupted = 0;
-
- _thread_enter_cancellation_point();
-
- if (cond == NULL || abstime == NULL)
- rval = EINVAL;
-
- if (abstime->tv_sec < 0 ||
- abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) {
- errno = EINVAL;
- _thread_leave_cancellation_point();
- return (-1);
- }
-
- /*
- * If the condition variable is statically initialized,
- * perform the dynamic initialization:
- */
- if (*cond != NULL ||
- (rval = pthread_cond_init(cond,NULL)) == 0) {
-
- _thread_enter_cancellation_point();
-
- /* Lock the condition variable structure: */
- _SPINLOCK(&(*cond)->lock);
-
- /*
- * If the condvar was statically allocated, properly
- * initialize the tail queue.
- */
- if (((*cond)->c_flags & COND_FLAGS_INITED) == 0) {
- TAILQ_INIT(&(*cond)->c_queue);
- (*cond)->c_flags |= COND_FLAGS_INITED;
- }
-
- /* Process according to condition variable type: */
- switch ((*cond)->c_type) {
- /* Fast condition variable: */
- case COND_TYPE_FAST:
- if ((mutex == NULL) || (((*cond)->c_mutex != NULL) &&
- ((*cond)->c_mutex != *mutex))) {
- /* Return invalid argument error: */
- rval = EINVAL;
-
- /* Unlock the condition variable structure: */
- _SPINUNLOCK(&(*cond)->lock);
- } else {
- /* Set the wakeup time: */
- _thread_run->wakeup_time.tv_sec =
- abstime->tv_sec;
- _thread_run->wakeup_time.tv_nsec =
- abstime->tv_nsec;
-
- /* Reset the timeout and interrupted flags: */
- _thread_run->timeout = 0;
- _thread_run->interrupted = 0;
-
- /*
- * Queue the running thread for the condition
- * variable:
- */
- cond_queue_enq(*cond, _thread_run);
-
- /* Remember the mutex that is being used: */
- (*cond)->c_mutex = *mutex;
-
- /* Unlock the mutex: */
- if ((rval = _mutex_cv_unlock(mutex)) != 0) {
- /*
- * Cannot unlock the mutex, so remove
- * the running thread from the condition
- * variable queue:
- */
- cond_queue_remove(*cond, _thread_run);
-
- /* Check for no more waiters: */
- if (TAILQ_FIRST(&(*cond)->c_queue) == NULL)
- (*cond)->c_mutex = NULL;
-
- /* Unlock the condition variable structure: */
- _SPINUNLOCK(&(*cond)->lock);
- } else {
- /*
- * Schedule the next thread and unlock
- * the condition variable structure:
- */
- _thread_kern_sched_state_unlock(PS_COND_WAIT,
- &(*cond)->lock, __FILE__, __LINE__);
-
- /*
- * Check if the wait timedout or was
- * interrupted (canceled):
- */
- if ((_thread_run->timeout == 0) &&
- (_thread_run->interrupted == 0)) {
- /* Lock the mutex: */
- rval = _mutex_cv_lock(mutex);
-
- } else {
- /*
- * Remember if this thread was
- * interrupted:
- */
- interrupted = _thread_run->interrupted;
-
- /* Lock the condition variable structure: */
- _SPINLOCK(&(*cond)->lock);
-
- /*
- * The wait timed out; remove
- * the thread from the condition
- * variable queue:
- */
- cond_queue_remove(*cond,
- _thread_run);
-
- /* Check for no more waiters: */
- if (TAILQ_FIRST(&(*cond)->c_queue) == NULL)
- (*cond)->c_mutex = NULL;
-
- /* Unock the condition variable structure: */
- _SPINUNLOCK(&(*cond)->lock);
-
- /* Return a timeout error: */
- rval = ETIMEDOUT;
-
- /*
- * Lock the mutex and ignore any
- * errors. Note that even though
- * this thread may have been
- * canceled, POSIX requires that
- * the mutex be reaquired prior
- * to cancellation.
- */
- (void)_mutex_cv_lock(mutex);
- }
- }
- }
- break;
-
- /* Trap invalid condition variable types: */
- default:
- /* Unlock the condition variable structure: */
- _SPINUNLOCK(&(*cond)->lock);
-
- /* Return an invalid argument error: */
- rval = EINVAL;
- break;
- }
-
- if (interrupted != 0 && _thread_run->continuation != NULL)
- _thread_run->continuation((void *) _thread_run);
-
- _thread_leave_cancellation_point();
- }
-
- _thread_leave_cancellation_point();
-
- /* Return the completion status: */
- return (rval);
-}
-
-int
-pthread_cond_signal(pthread_cond_t * cond)
-{
- int rval = 0;
- pthread_t pthread;
-
- if (cond == NULL || *cond == NULL)
- rval = EINVAL;
- else {
- /*
- * Defer signals to protect the scheduling queues
- * from access by the signal handler:
- */
- _thread_kern_sig_defer();
-
- /* Lock the condition variable structure: */
- _SPINLOCK(&(*cond)->lock);
-
- /* Process according to condition variable type: */
- switch ((*cond)->c_type) {
- /* Fast condition variable: */
- case COND_TYPE_FAST:
- if ((pthread = cond_queue_deq(*cond)) != NULL)
- /* Allow the thread to run: */
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
-
- /* Check for no more waiters: */
- if (TAILQ_FIRST(&(*cond)->c_queue) == NULL)
- (*cond)->c_mutex = NULL;
- break;
-
- /* Trap invalid condition variable types: */
- default:
- /* Return an invalid argument error: */
- rval = EINVAL;
- break;
- }
-
- /* Unlock the condition variable structure: */
- _SPINUNLOCK(&(*cond)->lock);
-
- /*
- * Undefer and handle pending signals, yielding if
- * necessary:
- */
- _thread_kern_sig_undefer();
- }
-
- /* Return the completion status: */
- return (rval);
-}
-
-int
-pthread_cond_broadcast(pthread_cond_t * cond)
-{
- int rval = 0;
- pthread_t pthread;
-
- if (cond == NULL || *cond == NULL)
- rval = EINVAL;
- else {
- /*
- * Defer signals to protect the scheduling queues
- * from access by the signal handler:
- */
- _thread_kern_sig_defer();
-
- /* Lock the condition variable structure: */
- _SPINLOCK(&(*cond)->lock);
-
- /* Process according to condition variable type: */
- switch ((*cond)->c_type) {
- /* Fast condition variable: */
- case COND_TYPE_FAST:
- /*
- * Enter a loop to bring all threads off the
- * condition queue:
- */
- while ((pthread = cond_queue_deq(*cond)) != NULL) {
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
- }
-
- /* There are no more waiting threads: */
- (*cond)->c_mutex = NULL;
- break;
-
- /* Trap invalid condition variable types: */
- default:
- /* Return an invalid argument error: */
- rval = EINVAL;
- break;
- }
-
- /* Unlock the condition variable structure: */
- _SPINUNLOCK(&(*cond)->lock);
-
- /*
- * Undefer and handle pending signals, yielding if
- * necessary:
- */
- _thread_kern_sig_undefer();
- }
-
- /* Return the completion status: */
- return (rval);
-}
-
-/*
- * Dequeue a waiting thread from the head of a condition queue in
- * descending priority order.
- */
-static inline pthread_t
-cond_queue_deq(pthread_cond_t cond)
-{
- pthread_t pthread;
-
- while ((pthread = TAILQ_FIRST(&cond->c_queue)) != NULL) {
- TAILQ_REMOVE(&cond->c_queue, pthread, qe);
- pthread->flags &= ~PTHREAD_FLAGS_IN_CONDQ;
- if ((pthread->timeout == 0) && (pthread->interrupted == 0))
- /*
- * Only exit the loop when we find a thread
- * that hasn't timed out or been canceled;
- * those threads are already running and don't
- * need their run state changed.
- */
- break;
- }
-
- return(pthread);
-}
-
-/*
- * Remove a waiting thread from a condition queue in descending priority
- * order.
- */
-static inline void
-cond_queue_remove(pthread_cond_t cond, pthread_t pthread)
-{
- /*
- * Because pthread_cond_timedwait() can timeout as well
- * as be signaled by another thread, it is necessary to
- * guard against removing the thread from the queue if
- * it isn't in the queue.
- */
- if (pthread->flags & PTHREAD_FLAGS_IN_CONDQ) {
- TAILQ_REMOVE(&cond->c_queue, pthread, qe);
- pthread->flags &= ~PTHREAD_FLAGS_IN_CONDQ;
- }
-}
-
-/*
- * Enqueue a waiting thread to a condition queue in descending priority
- * order.
- */
-static inline void
-cond_queue_enq(pthread_cond_t cond, pthread_t pthread)
-{
- pthread_t tid = TAILQ_LAST(&cond->c_queue, cond_head);
-
- /*
- * For the common case of all threads having equal priority,
- * we perform a quick check against the priority of the thread
- * at the tail of the queue.
- */
- if ((tid == NULL) || (pthread->active_priority <= tid->active_priority))
- TAILQ_INSERT_TAIL(&cond->c_queue, pthread, qe);
- else {
- tid = TAILQ_FIRST(&cond->c_queue);
- while (pthread->active_priority <= tid->active_priority)
- tid = TAILQ_NEXT(tid, qe);
- TAILQ_INSERT_BEFORE(tid, pthread, qe);
- }
- pthread->flags |= PTHREAD_FLAGS_IN_CONDQ;
-}
-#endif
diff --git a/lib/libkse/thread/thr_condattr_destroy.c b/lib/libkse/thread/thr_condattr_destroy.c
deleted file mode 100644
index ad91228c3050..000000000000
--- a/lib/libkse/thread/thr_condattr_destroy.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <stdlib.h>
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int pthread_condattr_destroy(pthread_condattr_t *attr)
-{
- int ret;
- if (attr == NULL || *attr == NULL) {
- ret = EINVAL;
- } else {
- free(*attr);
- *attr = NULL;
- ret = 0;
- }
- return(ret);
-}
-#endif
diff --git a/lib/libkse/thread/thr_condattr_init.c b/lib/libkse/thread/thr_condattr_init.c
deleted file mode 100644
index 33798982f330..000000000000
--- a/lib/libkse/thread/thr_condattr_init.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_condattr_init(pthread_condattr_t *attr)
-{
- int ret;
- pthread_condattr_t pattr;
-
- if ((pattr = (pthread_condattr_t)
- malloc(sizeof(struct pthread_cond_attr))) == NULL) {
- ret = ENOMEM;
- } else {
- memcpy(pattr, &pthread_condattr_default,
- sizeof(struct pthread_cond_attr));
- *attr = pattr;
- ret = 0;
- }
- return(ret);
-}
-#endif
diff --git a/lib/libkse/thread/thr_creat.c b/lib/libkse/thread/thr_creat.c
deleted file mode 100644
index bb8e7c257c5b..000000000000
--- a/lib/libkse/thread/thr_creat.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2000 Jason Evans <jasone@canonware.com>.
- * 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(s), this list of conditions and the following disclaimer as
- * the first lines of this file unmodified other than the possible
- * addition of one or more copyright notices.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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.
- *
- * $FreeBSD$
- */
-
-#include <fcntl.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-creat(const char *path, mode_t mode)
-{
- int ret;
-
- _thread_enter_cancellation_point();
- ret = __creat(path, mode);
- _thread_leave_cancellation_point();
-
- return ret;
-}
-#endif
diff --git a/lib/libkse/thread/thr_create.c b/lib/libkse/thread/thr_create.c
deleted file mode 100644
index b8a1c466b978..000000000000
--- a/lib/libkse/thread/thr_create.c
+++ /dev/null
@@ -1,348 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <stddef.h>
-#include <sys/time.h>
-#include <sys/param.h>
-#include <sys/mman.h>
-#ifdef _THREAD_SAFE
-#include <machine/reg.h>
-#include <pthread.h>
-#include "pthread_private.h"
-#include "libc_private.h"
-
-static u_int64_t next_uniqueid = 1;
-
-#define OFF(f) offsetof(struct pthread, f)
-int _thread_next_offset = OFF(tle.tqe_next);
-int _thread_uniqueid_offset = OFF(uniqueid);
-int _thread_state_offset = OFF(state);
-int _thread_name_offset = OFF(name);
-int _thread_sig_saved_offset = OFF(sig_saved);
-int _thread_saved_sigcontext_offset = OFF(saved_sigcontext);
-int _thread_saved_jmp_buf_offset = OFF(saved_jmp_buf);
-#undef OFF
-
-int _thread_PS_RUNNING_value = PS_RUNNING;
-int _thread_PS_DEAD_value = PS_DEAD;
-
-int
-pthread_create(pthread_t * thread, const pthread_attr_t * attr,
- void *(*start_routine) (void *), void *arg)
-{
- int f_gc = 0;
- int ret = 0;
- pthread_t gc_thread;
- pthread_t new_thread;
- pthread_attr_t pattr;
- void *stack;
-
- /*
- * Locking functions in libc are required when there are
- * threads other than the initial thread.
- */
- __isthreaded = 1;
-
- /* Allocate memory for the thread structure: */
- if ((new_thread = (pthread_t) malloc(sizeof(struct pthread))) == NULL) {
- /* Insufficient memory to create a thread: */
- ret = EAGAIN;
- } else {
- /* Check if default thread attributes are required: */
- if (attr == NULL || *attr == NULL) {
- /* Use the default thread attributes: */
- pattr = &pthread_attr_default;
- } else {
- pattr = *attr;
- }
- /* Check if a stack was specified in the thread attributes: */
- if ((stack = pattr->stackaddr_attr) != NULL) {
- }
- /* Allocate memory for a default-size stack: */
- else if (pattr->stacksize_attr == PTHREAD_STACK_DEFAULT) {
- struct stack *spare_stack;
-
- /* Allocate or re-use a default-size stack. */
-
- /*
- * Use the garbage collector mutex for synchronization
- * of the spare stack list.
- */
- if (pthread_mutex_lock(&_gc_mutex) != 0)
- PANIC("Cannot lock gc mutex");
-
- if ((spare_stack = SLIST_FIRST(&_stackq)) != NULL) {
- /* Use the spare stack. */
- SLIST_REMOVE_HEAD(&_stackq, qe);
-
- /* Unlock the garbage collector mutex. */
- if (pthread_mutex_unlock(&_gc_mutex) != 0)
- PANIC("Cannot unlock gc mutex");
-
- stack = sizeof(struct stack)
- + (void *) spare_stack
- - PTHREAD_STACK_DEFAULT;
- } else {
- /* Allocate a new stack. */
- stack = _next_stack + PTHREAD_STACK_GUARD;
-
- /*
- * Even if stack allocation fails, we don't want
- * to try to use this location again, so
- * unconditionally decrement _next_stack. Under
- * normal operating conditions, the most likely
- * reason for an mmap() error is a stack
- * overflow of the adjacent thread stack.
- */
- _next_stack -= (PTHREAD_STACK_DEFAULT
- + PTHREAD_STACK_GUARD);
-
- /* Unlock the garbage collector mutex. */
- if (pthread_mutex_unlock(&_gc_mutex) != 0)
- PANIC("Cannot unlock gc mutex");
-
- /* Stack: */
- if (mmap(stack, PTHREAD_STACK_DEFAULT,
- PROT_READ | PROT_WRITE, MAP_STACK,
- -1, 0) == MAP_FAILED) {
- ret = EAGAIN;
- free(new_thread);
- }
- }
- }
- /*
- * The user wants a stack of a particular size. Lets hope they
- * really know what they want, and simply malloc the stack.
- */
- else if ((stack = (void *) malloc(pattr->stacksize_attr))
- == NULL) {
- /* Insufficient memory to create a thread: */
- ret = EAGAIN;
- free(new_thread);
- }
-
- /* Check for errors: */
- if (ret != 0) {
- } else {
- /* Initialise the thread structure: */
- memset(new_thread, 0, sizeof(struct pthread));
- new_thread->slice_usec = -1;
- new_thread->sig_saved = 0;
- new_thread->stack = stack;
- new_thread->start_routine = start_routine;
- new_thread->arg = arg;
-
- new_thread->cancelflags = PTHREAD_CANCEL_ENABLE |
- PTHREAD_CANCEL_DEFERRED;
-
- /*
- * Write a magic value to the thread structure
- * to help identify valid ones:
- */
- new_thread->magic = PTHREAD_MAGIC;
-
- /* Initialise the thread for signals: */
- new_thread->sigmask = _thread_run->sigmask;
-
- /* Initialise the jump buffer: */
- setjmp(new_thread->saved_jmp_buf);
-
- /*
- * Set up new stack frame so that it looks like it
- * returned from a longjmp() to the beginning of
- * _thread_start().
- */
-#if defined(__FreeBSD__)
-#if defined(__alpha__)
- new_thread->saved_jmp_buf[0]._jb[2] =
- (long)_thread_start;
- new_thread->saved_jmp_buf[0]._jb[4 + R_RA] =
- 0;
- new_thread->saved_jmp_buf[0]._jb[4 + R_T12] =
- (long)_thread_start;
-#else
- new_thread->saved_jmp_buf[0]._jb[0] =
- (long)_thread_start;
-#endif
-#elif defined(__NetBSD__)
-#if defined(__alpha__)
- new_thread->saved_jmp_buf[2] = (long)_thread_start;
- new_thread->saved_jmp_buf[4 + R_RA] = 0;
- new_thread->saved_jmp_buf[4 + R_T12] =
- (long)_thread_start;
-#else
- new_thread->saved_jmp_buf[0] = (long)_thread_start;
-#endif
-#else
-#error "Don't recognize this operating system!"
-#endif
-
- /* The stack starts high and builds down: */
-#if defined(__FreeBSD__)
-#if defined(__alpha__)
- new_thread->saved_jmp_buf[0]._jb[4 + R_SP] =
- (long)new_thread->stack + pattr->stacksize_attr
- - sizeof(double);
-#else
- new_thread->saved_jmp_buf[0]._jb[2] =
- (int)(new_thread->stack + pattr->stacksize_attr -
- sizeof(double));
-#endif
-#elif defined(__NetBSD__)
-#if defined(__alpha__)
- new_thread->saved_jmp_buf[4 + R_SP] =
- (long)new_thread->stack + pattr->stacksize_attr -
- sizeof(double);
-#else
- new_thread->saved_jmp_buf[2] = (long)new_thread->stack
- + pattr->stacksize_attr - sizeof(double);
-#endif
-#else
-#error "Don't recognize this operating system!"
-#endif
-
- /* Copy the thread attributes: */
- memcpy(&new_thread->attr, pattr, sizeof(struct pthread_attr));
-
- /*
- * Check if this thread is to inherit the scheduling
- * attributes from its parent:
- */
- if (new_thread->attr.flags & PTHREAD_INHERIT_SCHED) {
- /* Copy the scheduling attributes: */
- new_thread->base_priority
- = _thread_run->base_priority;
- new_thread->attr.prio
- = _thread_run->base_priority;
- new_thread->attr.sched_policy
- = _thread_run->attr.sched_policy;
- } else {
- /*
- * Use just the thread priority, leaving the
- * other scheduling attributes as their
- * default values:
- */
- new_thread->base_priority
- = new_thread->attr.prio;
- }
- new_thread->active_priority = new_thread->base_priority;
- new_thread->inherited_priority = 0;
-
- /* Initialise the join queue for the new thread: */
- TAILQ_INIT(&(new_thread->join_queue));
-
- /* Initialize the mutex queue: */
- TAILQ_INIT(&new_thread->mutexq);
-
- /* Initialise hooks in the thread structure: */
- new_thread->specific_data = NULL;
- new_thread->cleanup = NULL;
- new_thread->flags = 0;
- new_thread->poll_data.nfds = 0;
- new_thread->poll_data.fds = NULL;
- new_thread->jmpflags = 0;
- new_thread->continuation = NULL;
-
- /*
- * Defer signals to protect the scheduling queues
- * from access by the signal handler:
- */
- _thread_kern_sig_defer();
-
- /*
- * Initialise the unique id which GDB uses to
- * track threads.
- */
- new_thread->uniqueid = next_uniqueid++;
-
- /*
- * Check if the garbage collector thread
- * needs to be started.
- */
- f_gc = (TAILQ_FIRST(&_thread_list) == _thread_initial);
-
- /* Add the thread to the linked list of all threads: */
- TAILQ_INSERT_HEAD(&_thread_list, new_thread, tle);
-
- if (pattr->suspend == PTHREAD_CREATE_SUSPENDED) {
- new_thread->state = PS_SUSPENDED;
- PTHREAD_WAITQ_INSERT(new_thread);
- } else {
- new_thread->state = PS_RUNNING;
- PTHREAD_PRIOQ_INSERT_TAIL(new_thread);
- }
-
- /*
- * Undefer and handle pending signals, yielding
- * if necessary.
- */
- _thread_kern_sig_undefer();
-
- /* Return a pointer to the thread structure: */
- (*thread) = new_thread;
-
- /* Schedule the new user thread: */
- _thread_kern_sched(NULL);
-
- /*
- * Start a garbage collector thread
- * if necessary.
- */
- if (f_gc && pthread_create(&gc_thread,NULL,
- _thread_gc,NULL) != 0)
- PANIC("Can't create gc thread");
- }
- }
-
- /* Return the status: */
- return (ret);
-}
-
-void
-_thread_start(void)
-{
- /* We just left the scheduler via longjmp: */
- _thread_kern_in_sched = 0;
-
- /* Run the current thread's start routine with argument: */
- pthread_exit(_thread_run->start_routine(_thread_run->arg));
-
- /* This point should never be reached. */
- PANIC("Thread has resumed after exit");
-}
-#endif
diff --git a/lib/libkse/thread/thr_detach.c b/lib/libkse/thread/thr_detach.c
deleted file mode 100644
index 89cc6671179c..000000000000
--- a/lib/libkse/thread/thr_detach.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_detach(pthread_t pthread)
-{
- int rval = 0;
- pthread_t next_thread;
-
- /* Check for invalid calling parameters: */
- if (pthread == NULL || pthread->magic != PTHREAD_MAGIC)
- /* Return an invalid argument error: */
- rval = EINVAL;
-
- /* Check if the thread has not been detached: */
- else if ((pthread->attr.flags & PTHREAD_DETACHED) == 0) {
- /* Flag the thread as detached: */
- pthread->attr.flags |= PTHREAD_DETACHED;
-
- /*
- * Defer signals to protect the scheduling queues from
- * access by the signal handler:
- */
- _thread_kern_sig_defer();
-
- /* Enter a loop to bring all threads off the join queue: */
- while ((next_thread = TAILQ_FIRST(&pthread->join_queue)) != NULL) {
- /* Remove the thread from the queue: */
- TAILQ_REMOVE(&pthread->join_queue, next_thread, qe);
-
- /* Make the thread run: */
- PTHREAD_NEW_STATE(next_thread,PS_RUNNING);
- }
-
- /*
- * Undefer and handle pending signals, yielding if a
- * scheduling signal occurred while in the critical region.
- */
- _thread_kern_sig_undefer();
- } else
- /* Return an error: */
- rval = EINVAL;
-
- /* Return the completion status: */
- return (rval);
-}
-#endif
diff --git a/lib/libkse/thread/thr_equal.c b/lib/libkse/thread/thr_equal.c
deleted file mode 100644
index e03ba4afe445..000000000000
--- a/lib/libkse/thread/thr_equal.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_equal(pthread_t t1, pthread_t t2)
-{
- /* Compare the two thread pointers: */
- return (t1 == t2);
-}
-#endif
diff --git a/lib/libkse/thread/thr_exit.c b/lib/libkse/thread/thr_exit.c
deleted file mode 100644
index 0d22638fd7fc..000000000000
--- a/lib/libkse/thread/thr_exit.c
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-void __exit(int status)
-{
- int flags;
- int i;
- struct itimerval itimer;
-
- /* Disable the interval timer: */
- itimer.it_interval.tv_sec = 0;
- itimer.it_interval.tv_usec = 0;
- itimer.it_value.tv_sec = 0;
- itimer.it_value.tv_usec = 0;
- setitimer(_ITIMER_SCHED_TIMER, &itimer, NULL);
-
- /* Close the pthread kernel pipe: */
- _thread_sys_close(_thread_kern_pipe[0]);
- _thread_sys_close(_thread_kern_pipe[1]);
-
- /*
- * Enter a loop to set all file descriptors to blocking
- * if they were not created as non-blocking:
- */
- for (i = 0; i < _thread_dtablesize; i++) {
- /* Check if this file descriptor is in use: */
- if (_thread_fd_table[i] != NULL &&
- !(_thread_fd_table[i]->flags & O_NONBLOCK)) {
- /* Get the current flags: */
- flags = _thread_sys_fcntl(i, F_GETFL, NULL);
- /* Clear the nonblocking file descriptor flag: */
- _thread_sys_fcntl(i, F_SETFL, flags & ~O_NONBLOCK);
- }
- }
-
- /* Call the _exit syscall: */
- _thread_sys__exit(status);
-}
-
-__strong_reference(__exit, _exit);
-
-void
-_thread_exit(char *fname, int lineno, char *string)
-{
- char s[256];
-
- /* Prepare an error message string: */
- strcpy(s, "Fatal error '");
- strcat(s, string);
- strcat(s, "' at line ? ");
- strcat(s, "in file ");
- strcat(s, fname);
- strcat(s, " (errno = ?");
- strcat(s, ")\n");
-
- /* Write the string to the standard error file descriptor: */
- _thread_sys_write(2, s, strlen(s));
-
- /* Force this process to exit: */
- /* XXX - Do we want abort to be conditional on _PTHREADS_INVARIANTS? */
-#if defined(_PTHREADS_INVARIANTS)
- abort();
-#else
- _exit(1);
-#endif
-}
-
-/*
- * Only called when a thread is cancelled. It may be more useful
- * to call it from pthread_exit() if other ways of asynchronous or
- * abnormal thread termination can be found.
- */
-void
-_thread_exit_cleanup(void)
-{
- /*
- * POSIX states that cancellation/termination of a thread should
- * not release any visible resources (such as mutexes) and that
- * it is the applications responsibility. Resources that are
- * internal to the threads library, including file and fd locks,
- * are not visible to the application and need to be released.
- */
- /* Unlock all owned fd locks: */
- _thread_fd_unlock_owned(_thread_run);
-
- /* Unlock all owned file locks: */
- _funlock_owned(_thread_run);
-
- /* Unlock all private mutexes: */
- _mutex_unlock_private(_thread_run);
-
- /*
- * This still isn't quite correct because we don't account
- * for held spinlocks (see libc/stdlib/malloc.c).
- */
-}
-
-void
-pthread_exit(void *status)
-{
- pthread_t pthread;
-
- /* Check if this thread is already in the process of exiting: */
- if ((_thread_run->flags & PTHREAD_EXITING) != 0) {
- char msg[128];
- snprintf(msg, sizeof(msg), "Thread %p has called pthread_exit() from a destructor. POSIX 1003.1 1996 s16.2.5.2 does not allow this!",_thread_run);
- PANIC(msg);
- }
-
- /* Flag this thread as exiting: */
- _thread_run->flags |= PTHREAD_EXITING;
-
- /* Save the return value: */
- _thread_run->ret = status;
-
- while (_thread_run->cleanup != NULL) {
- pthread_cleanup_pop(1);
- }
-
- if (_thread_run->attr.cleanup_attr != NULL) {
- _thread_run->attr.cleanup_attr(_thread_run->attr.arg_attr);
- }
- /* Check if there is thread specific data: */
- if (_thread_run->specific_data != NULL) {
- /* Run the thread-specific data destructors: */
- _thread_cleanupspecific();
- }
-
- /* Free thread-specific poll_data structure, if allocated: */
- if (_thread_run->poll_data.fds != NULL) {
- free(_thread_run->poll_data.fds);
- _thread_run->poll_data.fds = NULL;
- }
-
- /*
- * Defer signals to protect the scheduling queues from access
- * by the signal handler:
- */
- _thread_kern_sig_defer();
-
- /* Check if there are any threads joined to this one: */
- while ((pthread = TAILQ_FIRST(&(_thread_run->join_queue))) != NULL) {
- /* Remove the thread from the queue: */
- TAILQ_REMOVE(&_thread_run->join_queue, pthread, qe);
-
- /* Wake the joined thread and let it detach this thread: */
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
- }
-
- /*
- * Undefer and handle pending signals, yielding if necessary:
- */
- _thread_kern_sig_undefer();
-
- /*
- * Lock the garbage collector mutex to ensure that the garbage
- * collector is not using the dead thread list.
- */
- if (pthread_mutex_lock(&_gc_mutex) != 0)
- PANIC("Cannot lock gc mutex");
-
- /* Add this thread to the list of dead threads. */
- TAILQ_INSERT_HEAD(&_dead_list, _thread_run, dle);
-
- /*
- * Defer signals to protect the scheduling queues from access
- * by the signal handler:
- */
- _thread_kern_sig_defer();
-
- /* Remove this thread from the thread list: */
- TAILQ_REMOVE(&_thread_list, _thread_run, tle);
-
- /*
- * Undefer and handle pending signals, yielding if necessary:
- */
- _thread_kern_sig_undefer();
-
- /*
- * Signal the garbage collector thread that there is something
- * to clean up.
- */
- if (pthread_cond_signal(&_gc_cond) != 0)
- PANIC("Cannot signal gc cond");
-
- /*
- * Mark the thread as dead so it will not return if it
- * gets context switched out when the mutex is unlocked.
- */
- PTHREAD_SET_STATE(_thread_run, PS_DEAD);
-
- /* Unlock the garbage collector mutex: */
- if (pthread_mutex_unlock(&_gc_mutex) != 0)
- PANIC("Cannot lock gc mutex");
-
- /* This this thread will never be re-scheduled. */
- _thread_kern_sched(NULL);
-
- /* This point should not be reached. */
- PANIC("Dead thread has resumed");
-}
-#endif
diff --git a/lib/libkse/thread/thr_fcntl.c b/lib/libkse/thread/thr_fcntl.c
deleted file mode 100644
index f5dd06416559..000000000000
--- a/lib/libkse/thread/thr_fcntl.c
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <stdarg.h>
-#include <unistd.h>
-#include <fcntl.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-_fcntl(int fd, int cmd,...)
-{
- int flags = 0;
- int nonblock;
- int oldfd;
- int ret;
- va_list ap;
-
- /* Lock the file descriptor: */
- if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) {
- /* Initialise the variable argument list: */
- va_start(ap, cmd);
-
- /* Process according to file control command type: */
- switch (cmd) {
- /* Duplicate a file descriptor: */
- case F_DUPFD:
- /*
- * Get the file descriptor that the caller wants to
- * use:
- */
- oldfd = va_arg(ap, int);
-
- /* Initialise the file descriptor table entry: */
- if ((ret = _thread_sys_fcntl(fd, cmd, oldfd)) < 0) {
- }
- /* Initialise the file descriptor table entry: */
- else if (_thread_fd_table_init(ret) != 0) {
- /* Quietly close the file: */
- _thread_sys_close(ret);
-
- /* Reset the file descriptor: */
- ret = -1;
- } else {
- /*
- * Save the file open flags so that they can
- * be checked later:
- */
- _thread_fd_table[ret]->flags = _thread_fd_table[fd]->flags;
- }
- break;
- case F_SETFD:
- flags = va_arg(ap, int);
- ret = _thread_sys_fcntl(fd, cmd, flags);
- break;
- case F_GETFD:
- ret = _thread_sys_fcntl(fd, cmd, 0);
- break;
- case F_GETFL:
- ret = _thread_fd_table[fd]->flags;
- break;
- case F_SETFL:
- /*
- * Get the file descriptor flags passed by the
- * caller:
- */
- flags = va_arg(ap, int);
-
- /*
- * Check if the user wants a non-blocking file
- * descriptor:
- */
- nonblock = flags & O_NONBLOCK;
-
- /* Set the file descriptor flags: */
- if ((ret = _thread_sys_fcntl(fd, cmd, flags | O_NONBLOCK)) != 0) {
-
- /* Get the flags so that we behave like the kernel: */
- } else if ((flags = _thread_sys_fcntl(fd,
- F_GETFL, 0)) == -1) {
- /* Error getting flags: */
- ret = -1;
-
- /*
- * Check if the file descriptor is non-blocking
- * with respect to the user:
- */
- } else if (nonblock)
- /* A non-blocking descriptor: */
- _thread_fd_table[fd]->flags = flags | O_NONBLOCK;
- else
- /* Save the flags: */
- _thread_fd_table[fd]->flags = flags & ~O_NONBLOCK;
- break;
- default:
- /* Might want to make va_arg use a union */
- ret = _thread_sys_fcntl(fd, cmd, va_arg(ap, void *));
- break;
- }
-
- /* Free variable arguments: */
- va_end(ap);
-
- /* Unlock the file descriptor: */
- _FD_UNLOCK(fd, FD_RDWR);
- }
- /* Return the completion status: */
- return (ret);
-}
-
-int
-fcntl(int fd, int cmd,...)
-{
- int ret;
- va_list ap;
-
- _thread_enter_cancellation_point();
-
- va_start(ap, cmd);
- switch (cmd) {
- case F_DUPFD:
- case F_SETFD:
- case F_SETFL:
- ret = _fcntl(fd, cmd, va_arg(ap, int));
- break;
- case F_GETFD:
- case F_GETFL:
- ret = _fcntl(fd, cmd);
- break;
- default:
- ret = _fcntl(fd, cmd, va_arg(ap, void *));
- }
- va_end(ap);
-
- _thread_leave_cancellation_point();
-
- return ret;
-}
-#endif
diff --git a/lib/libkse/thread/thr_find_thread.c b/lib/libkse/thread/thr_find_thread.c
deleted file mode 100644
index d4a3bbd1162d..000000000000
--- a/lib/libkse/thread/thr_find_thread.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (c) 1998 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-/* Find a thread in the linked list of active threads: */
-int
-_find_thread(pthread_t pthread)
-{
- pthread_t pthread1;
-
- /* Check if the caller has specified an invalid thread: */
- if (pthread == NULL || pthread->magic != PTHREAD_MAGIC)
- /* Invalid thread: */
- return(EINVAL);
-
- /*
- * Defer signals to protect the thread list from access
- * by the signal handler:
- */
- _thread_kern_sig_defer();
-
- /* Search for the specified thread: */
- TAILQ_FOREACH(pthread1, &_thread_list, tle) {
- if (pthread == pthread1)
- break;
- }
-
- /* Undefer and handle pending signals, yielding if necessary: */
- _thread_kern_sig_undefer();
-
- /* Return zero if the thread exists: */
- return ((pthread1 != NULL) ? 0:ESRCH);
-}
-
-/* Find a thread in the linked list of dead threads: */
-int
-_find_dead_thread(pthread_t pthread)
-{
- pthread_t pthread1;
-
- /* Check if the caller has specified an invalid thread: */
- if (pthread == NULL || pthread->magic != PTHREAD_MAGIC)
- /* Invalid thread: */
- return(EINVAL);
-
- /*
- * Lock the garbage collector mutex to ensure that the garbage
- * collector is not using the dead thread list.
- */
- if (pthread_mutex_lock(&_gc_mutex) != 0)
- PANIC("Cannot lock gc mutex");
-
- /* Search for the specified thread: */
- TAILQ_FOREACH(pthread1, &_dead_list, dle) {
- if (pthread1 == pthread)
- break;
- }
-
- /* Unlock the garbage collector mutex: */
- if (pthread_mutex_unlock(&_gc_mutex) != 0)
- PANIC("Cannot lock gc mutex");
-
- /* Return zero if the thread exists: */
- return ((pthread1 != NULL) ? 0:ESRCH);
-}
-#endif
diff --git a/lib/libkse/thread/thr_fork.c b/lib/libkse/thread/thr_fork.c
deleted file mode 100644
index a8e85d86e18f..000000000000
--- a/lib/libkse/thread/thr_fork.c
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-pid_t
-_fork(void)
-{
- int i, flags;
- pid_t ret;
- pthread_t pthread;
- pthread_t pthread_save;
-
- /*
- * Defer signals to protect the scheduling queues from access
- * by the signal handler:
- */
- _thread_kern_sig_defer();
-
- /* Fork a new process: */
- if ((ret = _thread_sys_fork()) != 0) {
- /* Parent process or error. Nothing to do here. */
- } else {
- /* Close the pthread kernel pipe: */
- _thread_sys_close(_thread_kern_pipe[0]);
- _thread_sys_close(_thread_kern_pipe[1]);
-
- /* Reset signals pending for the running thread: */
- sigemptyset(&_thread_run->sigpend);
-
- /*
- * Create a pipe that is written to by the signal handler to
- * prevent signals being missed in calls to
- * _thread_sys_select:
- */
- if (_thread_sys_pipe(_thread_kern_pipe) != 0) {
- /* Cannot create pipe, so abort: */
- PANIC("Cannot create pthread kernel pipe for forked process");
- }
- /* Get the flags for the read pipe: */
- else if ((flags = _thread_sys_fcntl(_thread_kern_pipe[0], F_GETFL, NULL)) == -1) {
- /* Abort this application: */
- abort();
- }
- /* Make the read pipe non-blocking: */
- else if (_thread_sys_fcntl(_thread_kern_pipe[0], F_SETFL, flags | O_NONBLOCK) == -1) {
- /* Abort this application: */
- abort();
- }
- /* Get the flags for the write pipe: */
- else if ((flags = _thread_sys_fcntl(_thread_kern_pipe[1], F_GETFL, NULL)) == -1) {
- /* Abort this application: */
- abort();
- }
- /* Make the write pipe non-blocking: */
- else if (_thread_sys_fcntl(_thread_kern_pipe[1], F_SETFL, flags | O_NONBLOCK) == -1) {
- /* Abort this application: */
- abort();
- }
- /* Reinitialize the GC mutex: */
- else if (_mutex_reinit(&_gc_mutex) != 0) {
- /* Abort this application: */
- PANIC("Cannot initialize GC mutex for forked process");
- }
- /* Reinitialize the GC condition variable: */
- else if (_cond_reinit(&_gc_cond) != 0) {
- /* Abort this application: */
- PANIC("Cannot initialize GC condvar for forked process");
- }
- /* Initialize the ready queue: */
- else if (_pq_init(&_readyq) != 0) {
- /* Abort this application: */
- PANIC("Cannot initialize priority ready queue.");
- } else {
- /*
- * Enter a loop to remove all threads other than
- * the running thread from the thread list:
- */
- pthread = TAILQ_FIRST(&_thread_list);
- while (pthread != NULL) {
- /* Save the thread to be freed: */
- pthread_save = pthread;
-
- /*
- * Advance to the next thread before
- * destroying the current thread:
- */
- pthread = TAILQ_NEXT(pthread, dle);
-
- /* Make sure this isn't the running thread: */
- if (pthread_save != _thread_run) {
- /* Remove this thread from the list: */
- TAILQ_REMOVE(&_thread_list,
- pthread_save, tle);
-
- if (pthread_save->attr.stackaddr_attr ==
- NULL && pthread_save->stack != NULL) {
- if (pthread_save->attr.stacksize_attr
- == PTHREAD_STACK_DEFAULT) {
- /*
- * Default-size stack.
- * Cache it:
- */
- struct stack *spare_stack;
-
- spare_stack
- = (pthread_save->stack
- + PTHREAD_STACK_DEFAULT
- - sizeof(struct stack));
- SLIST_INSERT_HEAD(&_stackq,
- spare_stack, qe);
- } else
- /*
- * Free the stack of
- * the dead thread:
- */
- free(pthread_save->stack);
- }
-
- if (pthread_save->specific_data != NULL)
- free(pthread_save->specific_data);
-
- if (pthread_save->poll_data.fds != NULL)
- free(pthread_save->poll_data.fds);
-
- free(pthread_save);
- }
- }
-
- /* Treat the current thread as the initial thread: */
- _thread_initial = _thread_run;
-
- /* Re-init the dead thread list: */
- TAILQ_INIT(&_dead_list);
-
- /* Re-init the waiting and work queues. */
- TAILQ_INIT(&_waitingq);
- TAILQ_INIT(&_workq);
-
- /* Re-init the threads mutex queue: */
- TAILQ_INIT(&_thread_run->mutexq);
-
- /* No spinlocks yet: */
- _spinblock_count = 0;
-
- /* Don't queue signals yet: */
- _queue_signals = 0;
-
- /* Initialize signal handling: */
- _thread_sig_init();
-
- /* Initialize the scheduling switch hook routine: */
- _sched_switch_hook = NULL;
-
- /* Clear out any locks in the file descriptor table: */
- for (i = 0; i < _thread_dtablesize; i++) {
- if (_thread_fd_table[i] != NULL) {
- /* Initialise the file locks: */
- memset(&_thread_fd_table[i]->lock, 0,
- sizeof(_thread_fd_table[i]->lock));
- _thread_fd_table[i]->r_owner = NULL;
- _thread_fd_table[i]->w_owner = NULL;
- _thread_fd_table[i]->r_fname = NULL;
- _thread_fd_table[i]->w_fname = NULL;
- _thread_fd_table[i]->r_lineno = 0;;
- _thread_fd_table[i]->w_lineno = 0;;
- _thread_fd_table[i]->r_lockcount = 0;;
- _thread_fd_table[i]->w_lockcount = 0;;
-
- /* Initialise the read/write queues: */
- TAILQ_INIT(&_thread_fd_table[i]->r_queue);
- TAILQ_INIT(&_thread_fd_table[i]->w_queue);
- }
- }
- }
- }
-
- /*
- * Undefer and handle pending signals, yielding if necessary:
- */
- _thread_kern_sig_undefer();
-
- /* Return the process ID: */
- return (ret);
-}
-
-__strong_reference(_fork, fork);
-#endif
diff --git a/lib/libkse/thread/thr_fsync.c b/lib/libkse/thread/thr_fsync.c
deleted file mode 100644
index 0d8832077238..000000000000
--- a/lib/libkse/thread/thr_fsync.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <unistd.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-_fsync(int fd)
-{
- int ret;
-
- if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) {
- ret = _thread_sys_fsync(fd);
- _FD_UNLOCK(fd, FD_RDWR);
- }
- return (ret);
-}
-
-int
-fsync(int fd)
-{
- int ret;
-
- _thread_enter_cancellation_point();
- ret = _fsync(fd);
- _thread_leave_cancellation_point();
-
- return ret;
-}
-#endif
diff --git a/lib/libkse/thread/thr_getprio.c b/lib/libkse/thread/thr_getprio.c
deleted file mode 100644
index 2f94b86b64af..000000000000
--- a/lib/libkse/thread/thr_getprio.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_getprio(pthread_t pthread)
-{
- int policy, ret;
- struct sched_param param;
-
- if ((ret = pthread_getschedparam(pthread, &policy, &param)) == 0)
- ret = param.sched_priority;
- else {
- /* Invalid thread: */
- errno = ret;
- ret = -1;
- }
-
- /* Return the thread priority or an error status: */
- return (ret);
-}
-#endif
diff --git a/lib/libkse/thread/thr_getschedparam.c b/lib/libkse/thread/thr_getschedparam.c
deleted file mode 100644
index 09d8c1bc3283..000000000000
--- a/lib/libkse/thread/thr_getschedparam.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>.
- * 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 Daniel Eischen.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_getschedparam(pthread_t pthread, int *policy,
- struct sched_param *param)
-{
- int ret;
-
- if ((param == NULL) || (policy == NULL))
- /* Return an invalid argument error: */
- ret = EINVAL;
-
- /* Find the thread in the list of active threads: */
- else if ((ret = _find_thread(pthread)) == 0) {
- /* Return the threads base priority and scheduling policy: */
- param->sched_priority = pthread->base_priority;
- *policy = pthread->attr.sched_policy;
- }
-
- return(ret);
-}
-#endif
diff --git a/lib/libkse/thread/thr_info.c b/lib/libkse/thread/thr_info.c
deleted file mode 100644
index 06b556e69b18..000000000000
--- a/lib/libkse/thread/thr_info.c
+++ /dev/null
@@ -1,311 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <stdio.h>
-#include <fcntl.h>
-#include <string.h>
-#include <unistd.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include <errno.h>
-#include "pthread_private.h"
-
-struct s_thread_info {
- enum pthread_state state;
- char *name;
-};
-
-/* Static variables: */
-static const struct s_thread_info thread_info[] = {
- {PS_RUNNING , "Running"},
- {PS_SIGTHREAD , "Waiting on signal thread"},
- {PS_MUTEX_WAIT , "Waiting on a mutex"},
- {PS_COND_WAIT , "Waiting on a condition variable"},
- {PS_FDLR_WAIT , "Waiting for a file read lock"},
- {PS_FDLW_WAIT , "Waiting for a file write lock"},
- {PS_FDR_WAIT , "Waiting for read"},
- {PS_FDW_WAIT , "Waiting for write"},
- {PS_FILE_WAIT , "Waiting for FILE lock"},
- {PS_POLL_WAIT , "Waiting on poll"},
- {PS_SELECT_WAIT , "Waiting on select"},
- {PS_SLEEP_WAIT , "Sleeping"},
- {PS_WAIT_WAIT , "Waiting process"},
- {PS_SIGSUSPEND , "Suspended, waiting for a signal"},
- {PS_SIGWAIT , "Waiting for a signal"},
- {PS_SPINBLOCK , "Waiting for a spinlock"},
- {PS_JOIN , "Waiting to join"},
- {PS_SUSPENDED , "Suspended"},
- {PS_DEAD , "Dead"},
- {PS_DEADLOCK , "Deadlocked"},
- {PS_STATE_MAX , "Not a real state!"}
-};
-
-void
-_thread_dump_info(void)
-{
- char s[512];
- int fd;
- int i;
- int j;
- pthread_t pthread;
- char tmpfile[128];
- pq_list_t *pq_list;
-
- for (i = 0; i < 100000; i++) {
- snprintf(tmpfile, sizeof(tmpfile), "/tmp/uthread.dump.%u.%i",
- getpid(), i);
- /* Open the dump file for append and create it if necessary: */
- if ((fd = _thread_sys_open(tmpfile, O_RDWR | O_CREAT | O_EXCL,
- 0666)) < 0) {
- /* Can't open the dump file. */
- if (errno == EEXIST)
- continue;
- /*
- * We only need to continue in case of
- * EEXIT error. Most other error
- * codes means that we will fail all
- * the times.
- */
- return;
- } else {
- break;
- }
- }
- if (i==100000) {
- /* all 100000 possibilities are in use :( */
- return;
- } else {
- /* Output a header for active threads: */
- strcpy(s, "\n\n=============\nACTIVE THREADS\n\n");
- _thread_sys_write(fd, s, strlen(s));
-
- /* Enter a loop to report each thread in the global list: */
- TAILQ_FOREACH(pthread, &_thread_list, tle) {
- /* Find the state: */
- for (j = 0; j < (sizeof(thread_info) /
- sizeof(struct s_thread_info)) - 1; j++)
- if (thread_info[j].state == pthread->state)
- break;
- /* Output a record for the current thread: */
- snprintf(s, sizeof(s),
- "--------------------\nThread %p (%s) prio %3d state %s [%s:%d]\n",
- pthread, (pthread->name == NULL) ?
- "":pthread->name, pthread->base_priority,
- thread_info[j].name,
- pthread->fname,pthread->lineno);
- _thread_sys_write(fd, s, strlen(s));
-
- /* Check if this is the running thread: */
- if (pthread == _thread_run) {
- /* Output a record for the running thread: */
- strcpy(s, "This is the running thread\n");
- _thread_sys_write(fd, s, strlen(s));
- }
- /* Check if this is the initial thread: */
- if (pthread == _thread_initial) {
- /* Output a record for the initial thread: */
- strcpy(s, "This is the initial thread\n");
- _thread_sys_write(fd, s, strlen(s));
- }
- /* Process according to thread state: */
- switch (pthread->state) {
- /* File descriptor read lock wait: */
- case PS_FDLR_WAIT:
- case PS_FDLW_WAIT:
- case PS_FDR_WAIT:
- case PS_FDW_WAIT:
- /* Write the lock details: */
- snprintf(s, sizeof(s), "fd %d[%s:%d]",
- pthread->data.fd.fd,
- pthread->data.fd.fname,
- pthread->data.fd.branch);
- _thread_sys_write(fd, s, strlen(s));
- snprintf(s, sizeof(s), "owner %pr/%pw\n",
- _thread_fd_table[pthread->data.fd.fd]->r_owner,
- _thread_fd_table[pthread->data.fd.fd]->w_owner);
- _thread_sys_write(fd, s, strlen(s));
- break;
- case PS_SIGWAIT:
- snprintf(s, sizeof(s), "sigmask (hi)");
- _thread_sys_write(fd, s, strlen(s));
- for (i = _SIG_WORDS - 1; i >= 0; i--) {
- snprintf(s, sizeof(s), "%08x\n",
- pthread->sigmask.__bits[i]);
- _thread_sys_write(fd, s, strlen(s));
- }
- snprintf(s, sizeof(s), "(lo)\n");
- _thread_sys_write(fd, s, strlen(s));
- break;
-
- /*
- * Trap other states that are not explicitly
- * coded to dump information:
- */
- default:
- /* Nothing to do here. */
- break;
- }
- }
-
- /* Output a header for ready threads: */
- strcpy(s, "\n\n=============\nREADY THREADS\n\n");
- _thread_sys_write(fd, s, strlen(s));
-
- /* Enter a loop to report each thread in the ready queue: */
- TAILQ_FOREACH (pq_list, &_readyq.pq_queue, pl_link) {
- TAILQ_FOREACH(pthread, &pq_list->pl_head, pqe) {
- /* Find the state: */
- for (j = 0; j < (sizeof(thread_info) /
- sizeof(struct s_thread_info)) - 1; j++)
- if (thread_info[j].state == pthread->state)
- break;
- /* Output a record for the current thread: */
- snprintf(s, sizeof(s),
- "--------------------\nThread %p (%s) prio %3d state %s [%s:%d]\n",
- pthread, (pthread->name == NULL) ?
- "":pthread->name, pthread->base_priority,
- thread_info[j].name,
- pthread->fname,pthread->lineno);
- _thread_sys_write(fd, s, strlen(s));
- }
- }
-
- /* Output a header for waiting threads: */
- strcpy(s, "\n\n=============\nWAITING THREADS\n\n");
- _thread_sys_write(fd, s, strlen(s));
-
- /* Enter a loop to report each thread in the waiting queue: */
- TAILQ_FOREACH (pthread, &_waitingq, pqe) {
- /* Find the state: */
- for (j = 0; j < (sizeof(thread_info) /
- sizeof(struct s_thread_info)) - 1; j++)
- if (thread_info[j].state == pthread->state)
- break;
- /* Output a record for the current thread: */
- snprintf(s, sizeof(s),
- "--------------------\nThread %p (%s) prio %3d state %s [%s:%d]\n",
- pthread, (pthread->name == NULL) ?
- "":pthread->name, pthread->base_priority,
- thread_info[j].name,
- pthread->fname,pthread->lineno);
- _thread_sys_write(fd, s, strlen(s));
- }
-
- /* Output a header for threads in the work queue: */
- strcpy(s, "\n\n=============\nTHREADS IN WORKQ\n\n");
- _thread_sys_write(fd, s, strlen(s));
-
- /* Enter a loop to report each thread in the waiting queue: */
- TAILQ_FOREACH (pthread, &_workq, qe) {
- /* Find the state: */
- for (j = 0; j < (sizeof(thread_info) /
- sizeof(struct s_thread_info)) - 1; j++)
- if (thread_info[j].state == pthread->state)
- break;
- /* Output a record for the current thread: */
- snprintf(s, sizeof(s),
- "--------------------\nThread %p (%s) prio %3d state %s [%s:%d]\n",
- pthread, (pthread->name == NULL) ?
- "":pthread->name, pthread->base_priority,
- thread_info[j].name,
- pthread->fname,pthread->lineno);
- _thread_sys_write(fd, s, strlen(s));
- }
-
- /* Check if there are no dead threads: */
- if (TAILQ_FIRST(&_dead_list) == NULL) {
- /* Output a record: */
- strcpy(s, "\n\nTHERE ARE NO DEAD THREADS\n");
- _thread_sys_write(fd, s, strlen(s));
- } else {
- /* Output a header for dead threads: */
- strcpy(s, "\n\nDEAD THREADS\n\n");
- _thread_sys_write(fd, s, strlen(s));
-
- /*
- * Enter a loop to report each thread in the global
- * dead thread list:
- */
- TAILQ_FOREACH(pthread, &_dead_list, dle) {
- /* Output a record for the current thread: */
- snprintf(s, sizeof(s),
- "Thread %p prio %3d [%s:%d]\n",
- pthread, pthread->base_priority,
- pthread->fname,pthread->lineno);
- _thread_sys_write(fd, s, strlen(s));
- }
- }
-
- /* Output a header for file descriptors: */
- snprintf(s, sizeof(s), "\n\n=============\nFILE DESCRIPTOR TABLE (table size %d)\n\n",_thread_dtablesize);
- _thread_sys_write(fd, s, strlen(s));
-
- /* Enter a loop to report file descriptor lock usage: */
- for (i = 0; i < _thread_dtablesize; i++) {
- /*
- * Check if memory is allocated for this file
- * descriptor:
- */
- if (_thread_fd_table[i] != NULL) {
- /* Report the file descriptor lock status: */
- snprintf(s, sizeof(s),
- "fd[%3d] read owner %p count %d [%s:%d]\n write owner %p count %d [%s:%d]\n",
- i,
- _thread_fd_table[i]->r_owner,
- _thread_fd_table[i]->r_lockcount,
- _thread_fd_table[i]->r_fname,
- _thread_fd_table[i]->r_lineno,
- _thread_fd_table[i]->w_owner,
- _thread_fd_table[i]->w_lockcount,
- _thread_fd_table[i]->w_fname,
- _thread_fd_table[i]->w_lineno);
- _thread_sys_write(fd, s, strlen(s));
- }
- }
-
- /* Close the dump file: */
- _thread_sys_close(fd);
- }
- return;
-}
-
-/* Set the thread name for debug: */
-void
-pthread_set_name_np(pthread_t thread, char *name)
-{
- /* Check if the caller has specified a valid thread: */
- if (thread != NULL && thread->magic == PTHREAD_MAGIC)
- thread->name = strdup(name);
- return;
-}
-#endif
diff --git a/lib/libkse/thread/thr_init.c b/lib/libkse/thread/thr_init.c
deleted file mode 100644
index dd5f53fac64e..000000000000
--- a/lib/libkse/thread/thr_init.c
+++ /dev/null
@@ -1,390 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-/* Allocate space for global thread variables here: */
-#define GLOBAL_PTHREAD_PRIVATE
-
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <fcntl.h>
-#include <paths.h>
-#include <poll.h>
-#include <unistd.h>
-#include <sys/ioctl.h>
-#include <sys/sysctl.h>
-#include <sys/time.h>
-#include <sys/ttycom.h>
-#include <sys/param.h>
-#include <sys/user.h>
-#include <sys/mman.h>
-#ifdef _THREAD_SAFE
-#include <machine/reg.h>
-#include <pthread.h>
-#include "pthread_private.h"
-
-#ifdef GCC_2_8_MADE_THREAD_AWARE
-typedef void *** (*dynamic_handler_allocator)();
-extern void __set_dynamic_handler_allocator(dynamic_handler_allocator);
-
-static pthread_key_t except_head_key;
-
-typedef struct {
- void **__dynamic_handler_chain;
- void *top_elt[2];
-} except_struct;
-
-static void ***dynamic_allocator_handler_fn()
-{
- except_struct *dh = (except_struct *)pthread_getspecific(except_head_key);
-
- if(dh == NULL) {
- dh = (except_struct *)malloc( sizeof(except_struct) );
- memset(dh, '\0', sizeof(except_struct));
- dh->__dynamic_handler_chain= dh->top_elt;
- pthread_setspecific(except_head_key, (void *)dh);
- }
- return &dh->__dynamic_handler_chain;
-}
-#endif /* GCC_2_8_MADE_THREAD_AWARE */
-
-/*
- * Threaded process initialization
- */
-void
-_thread_init(void)
-{
- int fd;
- int flags;
- int i;
- size_t len;
- int mib[2];
- struct timeval tv;
- struct clockinfo clockinfo;
- struct sigaction act;
-
- /* Check if this function has already been called: */
- if (_thread_initial)
- /* Only initialise the threaded application once. */
- return;
-
- /*
- * Check for the special case of this process running as
- * or in place of init as pid = 1:
- */
- if (getpid() == 1) {
- /*
- * Setup a new session for this process which is
- * assumed to be running as root.
- */
- if (setsid() == -1)
- PANIC("Can't set session ID");
- if (revoke(_PATH_CONSOLE) != 0)
- PANIC("Can't revoke console");
- if ((fd = _thread_sys_open(_PATH_CONSOLE, O_RDWR)) < 0)
- PANIC("Can't open console");
- if (setlogin("root") == -1)
- PANIC("Can't set login to root");
- if (_thread_sys_ioctl(fd,TIOCSCTTY, (char *) NULL) == -1)
- PANIC("Can't set controlling terminal");
- if (_thread_sys_dup2(fd,0) == -1 ||
- _thread_sys_dup2(fd,1) == -1 ||
- _thread_sys_dup2(fd,2) == -1)
- PANIC("Can't dup2");
- }
-
- /* Get the standard I/O flags before messing with them : */
- for (i = 0; i < 3; i++)
- if (((_pthread_stdio_flags[i] =
- _thread_sys_fcntl(i,F_GETFL, NULL)) == -1) &&
- (errno != EBADF))
- PANIC("Cannot get stdio flags");
-
- /*
- * Create a pipe that is written to by the signal handler to prevent
- * signals being missed in calls to _select:
- */
- if (_thread_sys_pipe(_thread_kern_pipe) != 0) {
- /* Cannot create pipe, so abort: */
- PANIC("Cannot create kernel pipe");
- }
- /* Get the flags for the read pipe: */
- else if ((flags = _thread_sys_fcntl(_thread_kern_pipe[0], F_GETFL, NULL)) == -1) {
- /* Abort this application: */
- PANIC("Cannot get kernel read pipe flags");
- }
- /* Make the read pipe non-blocking: */
- else if (_thread_sys_fcntl(_thread_kern_pipe[0], F_SETFL, flags | O_NONBLOCK) == -1) {
- /* Abort this application: */
- PANIC("Cannot make kernel read pipe non-blocking");
- }
- /* Get the flags for the write pipe: */
- else if ((flags = _thread_sys_fcntl(_thread_kern_pipe[1], F_GETFL, NULL)) == -1) {
- /* Abort this application: */
- PANIC("Cannot get kernel write pipe flags");
- }
- /* Make the write pipe non-blocking: */
- else if (_thread_sys_fcntl(_thread_kern_pipe[1], F_SETFL, flags | O_NONBLOCK) == -1) {
- /* Abort this application: */
- PANIC("Cannot get kernel write pipe flags");
- }
- /* Allocate and initialize the ready queue: */
- else if (_pq_alloc(&_readyq, PTHREAD_MIN_PRIORITY, PTHREAD_MAX_PRIORITY) != 0) {
- /* Abort this application: */
- PANIC("Cannot allocate priority ready queue.");
- }
- /* Allocate memory for the thread structure of the initial thread: */
- else if ((_thread_initial = (pthread_t) malloc(sizeof(struct pthread))) == NULL) {
- /*
- * Insufficient memory to initialise this application, so
- * abort:
- */
- PANIC("Cannot allocate memory for initial thread");
- } else {
- /* Zero the global kernel thread structure: */
- memset(&_thread_kern_thread, 0, sizeof(struct pthread));
- _thread_kern_thread.flags = PTHREAD_FLAGS_PRIVATE;
- memset(_thread_initial, 0, sizeof(struct pthread));
-
- /* Initialize the waiting and work queues: */
- TAILQ_INIT(&_waitingq);
- TAILQ_INIT(&_workq);
-
- /* Initialize the scheduling switch hook routine: */
- _sched_switch_hook = NULL;
-
- /* Give this thread default attributes: */
- memcpy((void *) &_thread_initial->attr, &pthread_attr_default,
- sizeof(struct pthread_attr));
-
- /* Initialize the thread stack cache: */
- SLIST_INIT(&_stackq);
-
- /*
- * Create a red zone below the main stack. All other stacks are
- * constrained to a maximum size by the paramters passed to
- * mmap(), but this stack is only limited by resource limits, so
- * this stack needs an explicitly mapped red zone to protect the
- * thread stack that is just beyond.
- */
- if (mmap((void *) USRSTACK - PTHREAD_STACK_INITIAL -
- PTHREAD_STACK_GUARD, PTHREAD_STACK_GUARD, 0, MAP_ANON,
- -1, 0) == MAP_FAILED)
- PANIC("Cannot allocate red zone for initial thread");
-
- /* Set the main thread stack pointer. */
- _thread_initial->stack = (void *) USRSTACK -
- PTHREAD_STACK_INITIAL;
-
- /* Set the stack attributes: */
- _thread_initial->attr.stackaddr_attr = _thread_initial->stack;
- _thread_initial->attr.stacksize_attr = PTHREAD_STACK_INITIAL;
-
- /*
- * Write a magic value to the thread structure
- * to help identify valid ones:
- */
- _thread_initial->magic = PTHREAD_MAGIC;
-
- /* Set the initial cancel state */
- _thread_initial->cancelflags = PTHREAD_CANCEL_ENABLE |
- PTHREAD_CANCEL_DEFERRED;
-
- /* Default the priority of the initial thread: */
- _thread_initial->base_priority = PTHREAD_DEFAULT_PRIORITY;
- _thread_initial->active_priority = PTHREAD_DEFAULT_PRIORITY;
- _thread_initial->inherited_priority = 0;
-
- /* Initialise the state of the initial thread: */
- _thread_initial->state = PS_RUNNING;
-
- /* Initialise the queue: */
- TAILQ_INIT(&(_thread_initial->join_queue));
-
- /* Initialize the owned mutex queue and count: */
- TAILQ_INIT(&(_thread_initial->mutexq));
- _thread_initial->priority_mutex_count = 0;
-
- /* Initialize last active time to now: */
- gettimeofday(&tv, NULL);
- _thread_initial->last_active.tv_sec = tv.tv_sec;
- _thread_initial->last_active.tv_usec = tv.tv_usec;
-
- /* Initialise the rest of the fields: */
- _thread_initial->poll_data.nfds = 0;
- _thread_initial->poll_data.fds = NULL;
- _thread_initial->sig_defer_count = 0;
- _thread_initial->yield_on_sig_undefer = 0;
- _thread_initial->specific_data = NULL;
- _thread_initial->cleanup = NULL;
- _thread_initial->flags = 0;
- _thread_initial->error = 0;
- TAILQ_INIT(&_thread_list);
- TAILQ_INSERT_HEAD(&_thread_list, _thread_initial, tle);
- _thread_run = _thread_initial;
-
- /* Initialise the global signal action structure: */
- sigfillset(&act.sa_mask);
- act.sa_handler = (void (*) ()) _thread_sig_handler;
- act.sa_flags = 0;
-
- /* Initialize signal handling: */
- _thread_sig_init();
-
- /* Enter a loop to get the existing signal status: */
- for (i = 1; i < NSIG; i++) {
- /* Check for signals which cannot be trapped: */
- if (i == SIGKILL || i == SIGSTOP) {
- }
-
- /* Get the signal handler details: */
- else if (_thread_sys_sigaction(i, NULL,
- &_thread_sigact[i - 1]) != 0) {
- /*
- * Abort this process if signal
- * initialisation fails:
- */
- PANIC("Cannot read signal handler info");
- }
- }
-
- /*
- * Install the signal handler for the most important
- * signals that the user-thread kernel needs. Actually
- * SIGINFO isn't really needed, but it is nice to have.
- */
- if (_thread_sys_sigaction(_SCHED_SIGNAL, &act, NULL) != 0 ||
- _thread_sys_sigaction(SIGINFO, &act, NULL) != 0 ||
- _thread_sys_sigaction(SIGCHLD, &act, NULL) != 0) {
- /*
- * Abort this process if signal initialisation fails:
- */
- PANIC("Cannot initialise signal handler");
- }
-
- /* Get the kernel clockrate: */
- mib[0] = CTL_KERN;
- mib[1] = KERN_CLOCKRATE;
- len = sizeof (struct clockinfo);
- if (sysctl(mib, 2, &clockinfo, &len, NULL, 0) == 0)
- _clock_res_nsec = clockinfo.tick * 1000;
-
- /* Get the table size: */
- if ((_thread_dtablesize = getdtablesize()) < 0) {
- /*
- * Cannot get the system defined table size, so abort
- * this process.
- */
- PANIC("Cannot get dtablesize");
- }
- /* Allocate memory for the file descriptor table: */
- if ((_thread_fd_table = (struct fd_table_entry **) malloc(sizeof(struct fd_table_entry *) * _thread_dtablesize)) == NULL) {
- /* Avoid accesses to file descriptor table on exit: */
- _thread_dtablesize = 0;
-
- /*
- * Cannot allocate memory for the file descriptor
- * table, so abort this process.
- */
- PANIC("Cannot allocate memory for file descriptor table");
- }
- /* Allocate memory for the pollfd table: */
- if ((_thread_pfd_table = (struct pollfd *) malloc(sizeof(struct pollfd) * _thread_dtablesize)) == NULL) {
- /*
- * Cannot allocate memory for the file descriptor
- * table, so abort this process.
- */
- PANIC("Cannot allocate memory for pollfd table");
- } else {
- /*
- * Enter a loop to initialise the file descriptor
- * table:
- */
- for (i = 0; i < _thread_dtablesize; i++) {
- /* Initialise the file descriptor table: */
- _thread_fd_table[i] = NULL;
- }
-
- /* Initialize stdio file descriptor table entries: */
- for (i = 0; i < 3; i++) {
- if ((_thread_fd_table_init(i) != 0) &&
- (errno != EBADF))
- PANIC("Cannot initialize stdio file "
- "descriptor table entry");
- }
- }
- }
-
-#ifdef GCC_2_8_MADE_THREAD_AWARE
- /* Create the thread-specific data for the exception linked list. */
- if(pthread_key_create(&except_head_key, NULL) != 0)
- PANIC("Failed to create thread specific execption head");
-
- /* Setup the gcc exception handler per thread. */
- __set_dynamic_handler_allocator( dynamic_allocator_handler_fn );
-#endif /* GCC_2_8_MADE_THREAD_AWARE */
-
- /* Initialise the garbage collector mutex and condition variable. */
- if (pthread_mutex_init(&_gc_mutex,NULL) != 0 ||
- pthread_cond_init(&_gc_cond,NULL) != 0)
- PANIC("Failed to initialise garbage collector mutex or condvar");
-
- gettimeofday(&kern_inc_prio_time, NULL);
-
- return;
-}
-
-/*
- * Special start up code for NetBSD/Alpha
- */
-#if defined(__NetBSD__) && defined(__alpha__)
-int
-main(int argc, char *argv[], char *env);
-
-int
-_thread_main(int argc, char *argv[], char *env)
-{
- _thread_init();
- return (main(argc, argv, env));
-}
-#endif
-#else
-/*
- * A stub for non-threaded programs.
- */
-void
-_thread_init(void)
-{
-}
-#endif
diff --git a/lib/libkse/thread/thr_join.c b/lib/libkse/thread/thr_join.c
deleted file mode 100644
index 1cffc96eaea3..000000000000
--- a/lib/libkse/thread/thr_join.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_join(pthread_t pthread, void **thread_return)
-{
- int ret = 0;
- pthread_t pthread1 = NULL;
-
- _thread_enter_cancellation_point();
-
- /* Check if the caller has specified an invalid thread: */
- if (pthread == NULL || pthread->magic != PTHREAD_MAGIC) {
- /* Invalid thread: */
- _thread_leave_cancellation_point();
- return(EINVAL);
- }
-
- /* Check if the caller has specified itself: */
- if (pthread == _thread_run) {
- /* Avoid a deadlock condition: */
- _thread_leave_cancellation_point();
- return(EDEADLK);
- }
-
- /*
- * Find the thread in the list of active threads or in the
- * list of dead threads:
- */
- if (_find_thread(pthread) == 0 ||
- _find_dead_thread(pthread) == 0)
- pthread1 = pthread;
-
- if (pthread1 == NULL)
- /* Return an error: */
- ret = ESRCH;
-
- /* Check if this thread has been detached: */
- else if ((pthread->attr.flags & PTHREAD_DETACHED) != 0)
- /* Return an error: */
- ret = ESRCH;
-
- /* Check if the thread is not dead: */
- else if (pthread->state != PS_DEAD) {
- /* Clear the interrupted flag: */
- _thread_run->interrupted = 0;
-
- /*
- * Protect against being context switched out while
- * adding this thread to the join queue.
- */
- _thread_kern_sig_defer();
-
- /* Add the running thread to the join queue: */
- TAILQ_INSERT_TAIL(&(pthread->join_queue), _thread_run, qe);
-
- /* Schedule the next thread: */
- _thread_kern_sched_state(PS_JOIN, __FILE__, __LINE__);
-
- if (_thread_run->interrupted != 0)
- TAILQ_REMOVE(&(pthread->join_queue), _thread_run, qe);
-
- _thread_kern_sig_undefer();
-
- if (_thread_run->interrupted != 0 &&
- _thread_run->continuation != NULL)
- _thread_run->continuation(_thread_run);
-
- /* Check if the thread is not detached: */
- if ((pthread->attr.flags & PTHREAD_DETACHED) == 0) {
- /* Check if the return value is required: */
- if (thread_return)
- /* Return the thread's return value: */
- *thread_return = pthread->ret;
- }
- else
- /* Return an error: */
- ret = ESRCH;
-
- /* Check if the return value is required: */
- } else if (thread_return != NULL)
- /* Return the thread's return value: */
- *thread_return = pthread->ret;
-
- _thread_leave_cancellation_point();
-
- /* Return the completion status: */
- return (ret);
-}
-#endif
diff --git a/lib/libkse/thread/thr_kern.c b/lib/libkse/thread/thr_kern.c
deleted file mode 100644
index 3e0ff17435db..000000000000
--- a/lib/libkse/thread/thr_kern.c
+++ /dev/null
@@ -1,1173 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- *
- */
-#include <errno.h>
-#include <poll.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <unistd.h>
-#include <setjmp.h>
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/signalvar.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/socket.h>
-#include <sys/uio.h>
-#include <sys/syscall.h>
-#include <fcntl.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-/* Static function prototype definitions: */
-static void
-_thread_kern_poll(int wait_reqd);
-
-static void
-dequeue_signals(void);
-
-static inline void
-thread_run_switch_hook(pthread_t thread_out, pthread_t thread_in);
-
-void
-_thread_kern_sched(ucontext_t * scp)
-{
-#ifndef __alpha__
- char *fdata;
-#endif
- pthread_t pthread, pthread_h = NULL;
- struct itimerval itimer;
- struct timespec ts, ts1;
- struct timeval tv, tv1;
- int set_timer = 0;
-
- /*
- * Flag the pthread kernel as executing scheduler code
- * to avoid a scheduler signal from interrupting this
- * execution and calling the scheduler again.
- */
- _thread_kern_in_sched = 1;
-
- /* Check if this function was called from the signal handler: */
- if (scp != NULL) {
- /*
- * Copy the signal context to the current thread's jump
- * buffer:
- */
- memcpy(&_thread_run->saved_sigcontext, scp, sizeof(_thread_run->saved_sigcontext));
-
-#ifndef __alpha__
- /* Point to the floating point data in the running thread: */
- fdata = _thread_run->saved_fp;
-
- /* Save the floating point data: */
-__asm__("fnsave %0": :"m"(*fdata));
-#endif
-
- /* Flag the signal context as the last state saved: */
- _thread_run->sig_saved = 1;
- }
- /* Save the state of the current thread: */
- else if (setjmp(_thread_run->saved_jmp_buf) != 0) {
- /*
- * This point is reached when a longjmp() is called to
- * restore the state of a thread.
- *
- * This is the normal way out of the scheduler.
- */
- _thread_kern_in_sched = 0;
-
- if (((_thread_run->cancelflags & PTHREAD_AT_CANCEL_POINT) == 0) &&
- ((_thread_run->cancelflags & PTHREAD_CANCEL_ASYNCHRONOUS) != 0)) {
- /*
- * Cancellations override signals.
- *
- * Stick a cancellation point at the start of
- * each async-cancellable thread's resumption.
- *
- * We allow threads woken at cancel points to do their
- * own checks.
- */
- pthread_testcancel();
- }
-
- /*
- * Check for undispatched signals due to calls to
- * pthread_kill().
- */
- if (SIGNOTEMPTY(_thread_run->sigpend))
- _dispatch_signals();
-
- if (_sched_switch_hook != NULL) {
- /* Run the installed switch hook: */
- thread_run_switch_hook(_last_user_thread, _thread_run);
- }
-
- return;
- } else
- /* Flag the jump buffer was the last state saved: */
- _thread_run->sig_saved = 0;
-
- /* If the currently running thread is a user thread, save it: */
- if ((_thread_run->flags & PTHREAD_FLAGS_PRIVATE) == 0)
- _last_user_thread = _thread_run;
-
- /*
- * Enter a scheduling loop that finds the next thread that is
- * ready to run. This loop completes when there are no more threads
- * in the global list or when a thread has its state restored by
- * either a sigreturn (if the state was saved as a sigcontext) or a
- * longjmp (if the state was saved by a setjmp).
- */
- while (!(TAILQ_EMPTY(&_thread_list))) {
- /* Get the current time of day: */
- gettimeofday(&tv, NULL);
- TIMEVAL_TO_TIMESPEC(&tv, &ts);
-
- /*
- * Protect the scheduling queues from access by the signal
- * handler.
- */
- _queue_signals = 1;
-
- if (_thread_run != &_thread_kern_thread) {
-
- /*
- * This thread no longer needs to yield the CPU.
- */
- _thread_run->yield_on_sig_undefer = 0;
-
- /*
- * Save the current time as the time that the thread
- * became inactive:
- */
- _thread_run->last_inactive.tv_sec = tv.tv_sec;
- _thread_run->last_inactive.tv_usec = tv.tv_usec;
-
- /*
- * Place the currently running thread into the
- * appropriate queue(s).
- */
- switch (_thread_run->state) {
- case PS_DEAD:
- case PS_STATE_MAX: /* to silence -Wall */
- /*
- * Dead threads are not placed in any queue:
- */
- break;
-
- case PS_RUNNING:
- /*
- * Runnable threads can't be placed in the
- * priority queue until after waiting threads
- * are polled (to preserve round-robin
- * scheduling).
- */
- if ((_thread_run->slice_usec != -1) &&
- (_thread_run->attr.sched_policy != SCHED_FIFO)) {
- /*
- * Accumulate the number of microseconds that
- * this thread has run for:
- */
- _thread_run->slice_usec +=
- (_thread_run->last_inactive.tv_sec -
- _thread_run->last_active.tv_sec) * 1000000 +
- _thread_run->last_inactive.tv_usec -
- _thread_run->last_active.tv_usec;
-
- /* Check for time quantum exceeded: */
- if (_thread_run->slice_usec > TIMESLICE_USEC)
- _thread_run->slice_usec = -1;
- }
- break;
-
- /*
- * States which do not depend on file descriptor I/O
- * operations or timeouts:
- */
- case PS_DEADLOCK:
- case PS_FDLR_WAIT:
- case PS_FDLW_WAIT:
- case PS_FILE_WAIT:
- case PS_JOIN:
- case PS_MUTEX_WAIT:
- case PS_SIGSUSPEND:
- case PS_SIGTHREAD:
- case PS_SIGWAIT:
- case PS_SUSPENDED:
- case PS_WAIT_WAIT:
- /* No timeouts for these states: */
- _thread_run->wakeup_time.tv_sec = -1;
- _thread_run->wakeup_time.tv_nsec = -1;
-
- /* Restart the time slice: */
- _thread_run->slice_usec = -1;
-
- /* Insert into the waiting queue: */
- PTHREAD_WAITQ_INSERT(_thread_run);
- break;
-
- /* States which can timeout: */
- case PS_COND_WAIT:
- case PS_SLEEP_WAIT:
- /* Restart the time slice: */
- _thread_run->slice_usec = -1;
-
- /* Insert into the waiting queue: */
- PTHREAD_WAITQ_INSERT(_thread_run);
- break;
-
- /* States that require periodic work: */
- case PS_SPINBLOCK:
- /* No timeouts for this state: */
- _thread_run->wakeup_time.tv_sec = -1;
- _thread_run->wakeup_time.tv_nsec = -1;
-
- /* Increment spinblock count: */
- _spinblock_count++;
-
- /* fall through */
- case PS_FDR_WAIT:
- case PS_FDW_WAIT:
- case PS_POLL_WAIT:
- case PS_SELECT_WAIT:
- /* Restart the time slice: */
- _thread_run->slice_usec = -1;
-
- /* Insert into the waiting queue: */
- PTHREAD_WAITQ_INSERT(_thread_run);
-
- /* Insert into the work queue: */
- PTHREAD_WORKQ_INSERT(_thread_run);
- break;
- }
- }
-
- /* Unprotect the scheduling queues: */
- _queue_signals = 0;
-
- /*
- * Poll file descriptors to update the state of threads
- * waiting on file I/O where data may be available:
- */
- _thread_kern_poll(0);
-
- /* Protect the scheduling queues: */
- _queue_signals = 1;
-
- /*
- * Wake up threads that have timedout. This has to be
- * done after polling in case a thread does a poll or
- * select with zero time.
- */
- PTHREAD_WAITQ_SETACTIVE();
- while (((pthread = TAILQ_FIRST(&_waitingq)) != NULL) &&
- (pthread->wakeup_time.tv_sec != -1) &&
- (((pthread->wakeup_time.tv_sec == 0) &&
- (pthread->wakeup_time.tv_nsec == 0)) ||
- (pthread->wakeup_time.tv_sec < ts.tv_sec) ||
- ((pthread->wakeup_time.tv_sec == ts.tv_sec) &&
- (pthread->wakeup_time.tv_nsec <= ts.tv_nsec)))) {
- switch (pthread->state) {
- case PS_POLL_WAIT:
- case PS_SELECT_WAIT:
- /* Return zero file descriptors ready: */
- pthread->data.poll_data->nfds = 0;
- /* fall through */
- default:
- /*
- * Remove this thread from the waiting queue
- * (and work queue if necessary) and place it
- * in the ready queue.
- */
- PTHREAD_WAITQ_CLEARACTIVE();
- if (pthread->flags & PTHREAD_FLAGS_IN_WORKQ)
- PTHREAD_WORKQ_REMOVE(pthread);
- PTHREAD_NEW_STATE(pthread, PS_RUNNING);
- PTHREAD_WAITQ_SETACTIVE();
- break;
- }
- /*
- * Flag the timeout in the thread structure:
- */
- pthread->timeout = 1;
- }
- PTHREAD_WAITQ_CLEARACTIVE();
-
- /*
- * Check if there is a current runnable thread that isn't
- * already in the ready queue:
- */
- if ((_thread_run != &_thread_kern_thread) &&
- (_thread_run->state == PS_RUNNING) &&
- ((_thread_run->flags & PTHREAD_FLAGS_IN_PRIOQ) == 0)) {
- if (_thread_run->slice_usec == -1) {
- /*
- * The thread exceeded its time
- * quantum or it yielded the CPU;
- * place it at the tail of the
- * queue for its priority.
- */
- PTHREAD_PRIOQ_INSERT_TAIL(_thread_run);
- } else {
- /*
- * The thread hasn't exceeded its
- * interval. Place it at the head
- * of the queue for its priority.
- */
- PTHREAD_PRIOQ_INSERT_HEAD(_thread_run);
- }
- }
-
- /*
- * Get the highest priority thread in the ready queue.
- */
- pthread_h = PTHREAD_PRIOQ_FIRST();
-
- /* Check if there are no threads ready to run: */
- if (pthread_h == NULL) {
- /*
- * Lock the pthread kernel by changing the pointer to
- * the running thread to point to the global kernel
- * thread structure:
- */
- _thread_run = &_thread_kern_thread;
-
- /* Unprotect the scheduling queues: */
- _queue_signals = 0;
-
- /*
- * There are no threads ready to run, so wait until
- * something happens that changes this condition:
- */
- _thread_kern_poll(1);
- } else {
- /* Remove the thread from the ready queue: */
- PTHREAD_PRIOQ_REMOVE(pthread_h);
-
- /* Get first thread on the waiting list: */
- pthread = TAILQ_FIRST(&_waitingq);
-
- /* Check to see if there is more than one thread: */
- if (pthread_h != TAILQ_FIRST(&_thread_list) ||
- TAILQ_NEXT(pthread_h, tle) != NULL)
- set_timer = 1;
- else
- set_timer = 0;
-
- /* Unprotect the scheduling queues: */
- _queue_signals = 0;
-
- /*
- * Check for signals queued while the scheduling
- * queues were protected:
- */
- while (_sigq_check_reqd != 0) {
- /* Clear before handling queued signals: */
- _sigq_check_reqd = 0;
-
- /* Protect the scheduling queues again: */
- _queue_signals = 1;
-
- dequeue_signals();
-
- /*
- * Check for a higher priority thread that
- * became runnable due to signal handling.
- */
- if (((pthread = PTHREAD_PRIOQ_FIRST()) != NULL) &&
- (pthread->active_priority > pthread_h->active_priority)) {
- /*
- * Insert the lower priority thread
- * at the head of its priority list:
- */
- PTHREAD_PRIOQ_INSERT_HEAD(pthread_h);
-
- /* Remove the thread from the ready queue: */
- PTHREAD_PRIOQ_REMOVE(pthread);
-
- /* There's a new thread in town: */
- pthread_h = pthread;
- }
-
- /* Get first thread on the waiting list: */
- pthread = TAILQ_FIRST(&_waitingq);
-
- /*
- * Check to see if there is more than one
- * thread:
- */
- if (pthread_h != TAILQ_FIRST(&_thread_list) ||
- TAILQ_NEXT(pthread_h, tle) != NULL)
- set_timer = 1;
- else
- set_timer = 0;
-
- /* Unprotect the scheduling queues: */
- _queue_signals = 0;
- }
-
- /* Make the selected thread the current thread: */
- _thread_run = pthread_h;
-
- /*
- * Save the current time as the time that the thread
- * became active:
- */
- _thread_run->last_active.tv_sec = tv.tv_sec;
- _thread_run->last_active.tv_usec = tv.tv_usec;
-
- /*
- * Define the maximum time before a scheduling signal
- * is required:
- */
- itimer.it_value.tv_sec = 0;
- itimer.it_value.tv_usec = TIMESLICE_USEC;
-
- /*
- * The interval timer is not reloaded when it
- * times out. The interval time needs to be
- * calculated every time.
- */
- itimer.it_interval.tv_sec = 0;
- itimer.it_interval.tv_usec = 0;
-
- /* Get first thread on the waiting list: */
- if ((pthread != NULL) &&
- (pthread->wakeup_time.tv_sec != -1)) {
- /*
- * Calculate the time until this thread
- * is ready, allowing for the clock
- * resolution:
- */
- ts1.tv_sec = pthread->wakeup_time.tv_sec
- - ts.tv_sec;
- ts1.tv_nsec = pthread->wakeup_time.tv_nsec
- - ts.tv_nsec + _clock_res_nsec;
-
- /*
- * Check for underflow of the nanosecond field:
- */
- while (ts1.tv_nsec < 0) {
- /*
- * Allow for the underflow of the
- * nanosecond field:
- */
- ts1.tv_sec--;
- ts1.tv_nsec += 1000000000;
- }
- /*
- * Check for overflow of the nanosecond field:
- */
- while (ts1.tv_nsec >= 1000000000) {
- /*
- * Allow for the overflow of the
- * nanosecond field:
- */
- ts1.tv_sec++;
- ts1.tv_nsec -= 1000000000;
- }
- /*
- * Convert the timespec structure to a
- * timeval structure:
- */
- TIMESPEC_TO_TIMEVAL(&tv1, &ts1);
-
- /*
- * Check if the thread will be ready
- * sooner than the earliest ones found
- * so far:
- */
- if (timercmp(&tv1, &itimer.it_value, <)) {
- /*
- * Update the time value:
- */
- itimer.it_value.tv_sec = tv1.tv_sec;
- itimer.it_value.tv_usec = tv1.tv_usec;
- }
- }
-
- /*
- * Check if this thread is running for the first time
- * or running again after using its full time slice
- * allocation:
- */
- if (_thread_run->slice_usec == -1) {
- /* Reset the accumulated time slice period: */
- _thread_run->slice_usec = 0;
- }
-
- /* Check if there is more than one thread: */
- if (set_timer != 0) {
- /*
- * Start the interval timer for the
- * calculated time interval:
- */
- if (setitimer(_ITIMER_SCHED_TIMER, &itimer, NULL) != 0) {
- /*
- * Cannot initialise the timer, so
- * abort this process:
- */
- PANIC("Cannot set scheduling timer");
- }
- }
-
- /*
- * Check if this thread is being continued from a
- * longjmp() out of a signal handler:
- */
- if ((_thread_run->jmpflags & JMPFLAGS_LONGJMP) != 0) {
- _thread_run->jmpflags = 0;
- __longjmp(_thread_run->nested_jmp.jmp,
- _thread_run->longjmp_val);
- }
- /*
- * Check if this thread is being continued from a
- * _longjmp() out of a signal handler:
- */
- else if ((_thread_run->jmpflags & JMPFLAGS__LONGJMP) !=
- 0) {
- _thread_run->jmpflags = 0;
- ___longjmp(_thread_run->nested_jmp.jmp,
- _thread_run->longjmp_val);
- }
- /*
- * Check if this thread is being continued from a
- * siglongjmp() out of a signal handler:
- */
- else if ((_thread_run->jmpflags & JMPFLAGS_SIGLONGJMP)
- != 0) {
- _thread_run->jmpflags = 0;
- __siglongjmp(
- _thread_run->nested_jmp.sigjmp,
- _thread_run->longjmp_val);
- }
- /* Check if a signal context was saved: */
- else if (_thread_run->sig_saved == 1) {
-#ifndef __alpha__
- /*
- * Point to the floating point data in the
- * running thread:
- */
- fdata = _thread_run->saved_fp;
-
- /* Restore the floating point state: */
- __asm__("frstor %0": :"m"(*fdata));
-#endif
- /*
- * Do a sigreturn to restart the thread that
- * was interrupted by a signal:
- */
- _thread_kern_in_sched = 0;
-
- /*
- * If we had a context switch, run any
- * installed switch hooks.
- */
- if ((_sched_switch_hook != NULL) &&
- (_last_user_thread != _thread_run)) {
- thread_run_switch_hook(_last_user_thread,
- _thread_run);
- }
- _thread_sys_sigreturn(&_thread_run->saved_sigcontext);
- } else {
- /*
- * Do a longjmp to restart the thread that
- * was context switched out (by a longjmp to
- * a different thread):
- */
- __longjmp(_thread_run->saved_jmp_buf, 1);
- }
-
- /* This point should not be reached. */
- PANIC("Thread has returned from sigreturn or longjmp");
- }
- }
-
- /* There are no more threads, so exit this process: */
- exit(0);
-}
-
-void
-_thread_kern_sched_state(enum pthread_state state, char *fname, int lineno)
-{
- /*
- * Flag the pthread kernel as executing scheduler code
- * to avoid a scheduler signal from interrupting this
- * execution and calling the scheduler again.
- */
- _thread_kern_in_sched = 1;
-
- /*
- * Prevent the signal handler from fiddling with this thread
- * before its state is set and is placed into the proper queue.
- */
- _queue_signals = 1;
-
- /* Change the state of the current thread: */
- _thread_run->state = state;
- _thread_run->fname = fname;
- _thread_run->lineno = lineno;
-
- /* Schedule the next thread that is ready: */
- _thread_kern_sched(NULL);
- return;
-}
-
-void
-_thread_kern_sched_state_unlock(enum pthread_state state,
- spinlock_t *lock, char *fname, int lineno)
-{
- /*
- * Flag the pthread kernel as executing scheduler code
- * to avoid a scheduler signal from interrupting this
- * execution and calling the scheduler again.
- */
- _thread_kern_in_sched = 1;
-
- /*
- * Prevent the signal handler from fiddling with this thread
- * before its state is set and it is placed into the proper
- * queue(s).
- */
- _queue_signals = 1;
-
- /* Change the state of the current thread: */
- _thread_run->state = state;
- _thread_run->fname = fname;
- _thread_run->lineno = lineno;
-
- _SPINUNLOCK(lock);
-
- /* Schedule the next thread that is ready: */
- _thread_kern_sched(NULL);
- return;
-}
-
-static void
-_thread_kern_poll(int wait_reqd)
-{
- int count = 0;
- int i, found;
- int kern_pipe_added = 0;
- int nfds = 0;
- int timeout_ms = 0;
- struct pthread *pthread;
- struct timespec ts;
- struct timeval tv;
-
- /* Check if the caller wants to wait: */
- if (wait_reqd == 0) {
- timeout_ms = 0;
- }
- else {
- /* Get the current time of day: */
- gettimeofday(&tv, NULL);
- TIMEVAL_TO_TIMESPEC(&tv, &ts);
-
- _queue_signals = 1;
- pthread = TAILQ_FIRST(&_waitingq);
- _queue_signals = 0;
-
- if ((pthread == NULL) || (pthread->wakeup_time.tv_sec == -1)) {
- /*
- * Either there are no threads in the waiting queue,
- * or there are no threads that can timeout.
- */
- timeout_ms = INFTIM;
- }
- else {
- /*
- * Calculate the time left for the next thread to
- * timeout allowing for the clock resolution:
- */
- timeout_ms = ((pthread->wakeup_time.tv_sec - ts.tv_sec) *
- 1000) + ((pthread->wakeup_time.tv_nsec - ts.tv_nsec +
- _clock_res_nsec) / 1000000);
- /*
- * Don't allow negative timeouts:
- */
- if (timeout_ms < 0)
- timeout_ms = 0;
- }
- }
-
- /* Protect the scheduling queues: */
- _queue_signals = 1;
-
- /*
- * Check to see if the signal queue needs to be walked to look
- * for threads awoken by a signal while in the scheduler.
- */
- if (_sigq_check_reqd != 0) {
- /* Reset flag before handling queued signals: */
- _sigq_check_reqd = 0;
-
- dequeue_signals();
- }
-
- /*
- * Check for a thread that became runnable due to a signal:
- */
- if (PTHREAD_PRIOQ_FIRST() != NULL) {
- /*
- * Since there is at least one runnable thread,
- * disable the wait.
- */
- timeout_ms = 0;
- }
-
- /*
- * Form the poll table:
- */
- nfds = 0;
- if (timeout_ms != 0) {
- /* Add the kernel pipe to the poll table: */
- _thread_pfd_table[nfds].fd = _thread_kern_pipe[0];
- _thread_pfd_table[nfds].events = POLLRDNORM;
- _thread_pfd_table[nfds].revents = 0;
- nfds++;
- kern_pipe_added = 1;
- }
-
- PTHREAD_WAITQ_SETACTIVE();
- TAILQ_FOREACH(pthread, &_workq, qe) {
- switch (pthread->state) {
- case PS_SPINBLOCK:
- /*
- * If the lock is available, let the thread run.
- */
- if (pthread->data.spinlock->access_lock == 0) {
- PTHREAD_WAITQ_CLEARACTIVE();
- PTHREAD_WORKQ_REMOVE(pthread);
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
- PTHREAD_WAITQ_SETACTIVE();
- /* One less thread in a spinblock state: */
- _spinblock_count--;
- /*
- * Since there is at least one runnable
- * thread, disable the wait.
- */
- timeout_ms = 0;
- }
- break;
-
- /* File descriptor read wait: */
- case PS_FDR_WAIT:
- /* Limit number of polled files to table size: */
- if (nfds < _thread_dtablesize) {
- _thread_pfd_table[nfds].events = POLLRDNORM;
- _thread_pfd_table[nfds].fd = pthread->data.fd.fd;
- nfds++;
- }
- break;
-
- /* File descriptor write wait: */
- case PS_FDW_WAIT:
- /* Limit number of polled files to table size: */
- if (nfds < _thread_dtablesize) {
- _thread_pfd_table[nfds].events = POLLWRNORM;
- _thread_pfd_table[nfds].fd = pthread->data.fd.fd;
- nfds++;
- }
- break;
-
- /* File descriptor poll or select wait: */
- case PS_POLL_WAIT:
- case PS_SELECT_WAIT:
- /* Limit number of polled files to table size: */
- if (pthread->data.poll_data->nfds + nfds <
- _thread_dtablesize) {
- for (i = 0; i < pthread->data.poll_data->nfds; i++) {
- _thread_pfd_table[nfds + i].fd =
- pthread->data.poll_data->fds[i].fd;
- _thread_pfd_table[nfds + i].events =
- pthread->data.poll_data->fds[i].events;
- }
- nfds += pthread->data.poll_data->nfds;
- }
- break;
-
- /* Other states do not depend on file I/O. */
- default:
- break;
- }
- }
- PTHREAD_WAITQ_CLEARACTIVE();
-
- /*
- * Wait for a file descriptor to be ready for read, write, or
- * an exception, or a timeout to occur:
- */
- count = _thread_sys_poll(_thread_pfd_table, nfds, timeout_ms);
-
- if (kern_pipe_added != 0)
- /*
- * Remove the pthread kernel pipe file descriptor
- * from the pollfd table:
- */
- nfds = 1;
- else
- nfds = 0;
-
- /*
- * Check if it is possible that there are bytes in the kernel
- * read pipe waiting to be read:
- */
- if (count < 0 || ((kern_pipe_added != 0) &&
- (_thread_pfd_table[0].revents & POLLRDNORM))) {
- /*
- * If the kernel read pipe was included in the
- * count:
- */
- if (count > 0) {
- /* Decrement the count of file descriptors: */
- count--;
- }
-
- if (_sigq_check_reqd != 0) {
- /* Reset flag before handling signals: */
- _sigq_check_reqd = 0;
-
- dequeue_signals();
- }
- }
-
- /*
- * Check if any file descriptors are ready:
- */
- if (count > 0) {
- /*
- * Enter a loop to look for threads waiting on file
- * descriptors that are flagged as available by the
- * _poll syscall:
- */
- PTHREAD_WAITQ_SETACTIVE();
- TAILQ_FOREACH(pthread, &_workq, qe) {
- switch (pthread->state) {
- case PS_SPINBLOCK:
- /*
- * If the lock is available, let the thread run.
- */
- if (pthread->data.spinlock->access_lock == 0) {
- PTHREAD_WAITQ_CLEARACTIVE();
- PTHREAD_WORKQ_REMOVE(pthread);
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
- PTHREAD_WAITQ_SETACTIVE();
-
- /*
- * One less thread in a spinblock state:
- */
- _spinblock_count--;
- }
- break;
-
- /* File descriptor read wait: */
- case PS_FDR_WAIT:
- if ((nfds < _thread_dtablesize) &&
- (_thread_pfd_table[nfds].revents & POLLRDNORM)) {
- PTHREAD_WAITQ_CLEARACTIVE();
- PTHREAD_WORKQ_REMOVE(pthread);
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
- PTHREAD_WAITQ_SETACTIVE();
- }
- nfds++;
- break;
-
- /* File descriptor write wait: */
- case PS_FDW_WAIT:
- if ((nfds < _thread_dtablesize) &&
- (_thread_pfd_table[nfds].revents & POLLWRNORM)) {
- PTHREAD_WAITQ_CLEARACTIVE();
- PTHREAD_WORKQ_REMOVE(pthread);
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
- PTHREAD_WAITQ_SETACTIVE();
- }
- nfds++;
- break;
-
- /* File descriptor poll or select wait: */
- case PS_POLL_WAIT:
- case PS_SELECT_WAIT:
- if (pthread->data.poll_data->nfds + nfds <
- _thread_dtablesize) {
- /*
- * Enter a loop looking for I/O
- * readiness:
- */
- found = 0;
- for (i = 0; i < pthread->data.poll_data->nfds; i++) {
- if (_thread_pfd_table[nfds + i].revents != 0) {
- pthread->data.poll_data->fds[i].revents =
- _thread_pfd_table[nfds + i].revents;
- found++;
- }
- }
-
- /* Increment before destroying: */
- nfds += pthread->data.poll_data->nfds;
-
- if (found != 0) {
- pthread->data.poll_data->nfds = found;
- PTHREAD_WAITQ_CLEARACTIVE();
- PTHREAD_WORKQ_REMOVE(pthread);
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
- PTHREAD_WAITQ_SETACTIVE();
- }
- }
- else
- nfds += pthread->data.poll_data->nfds;
- break;
-
- /* Other states do not depend on file I/O. */
- default:
- break;
- }
- }
- PTHREAD_WAITQ_CLEARACTIVE();
- }
- else if (_spinblock_count != 0) {
- /*
- * Enter a loop to look for threads waiting on a spinlock
- * that is now available.
- */
- PTHREAD_WAITQ_SETACTIVE();
- TAILQ_FOREACH(pthread, &_workq, qe) {
- if (pthread->state == PS_SPINBLOCK) {
- /*
- * If the lock is available, let the thread run.
- */
- if (pthread->data.spinlock->access_lock == 0) {
- PTHREAD_WAITQ_CLEARACTIVE();
- PTHREAD_WORKQ_REMOVE(pthread);
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
- PTHREAD_WAITQ_SETACTIVE();
-
- /*
- * One less thread in a spinblock state:
- */
- _spinblock_count--;
- }
- }
- }
- PTHREAD_WAITQ_CLEARACTIVE();
- }
-
- /* Unprotect the scheduling queues: */
- _queue_signals = 0;
-
- while (_sigq_check_reqd != 0) {
- /* Handle queued signals: */
- _sigq_check_reqd = 0;
-
- /* Protect the scheduling queues: */
- _queue_signals = 1;
-
- dequeue_signals();
-
- /* Unprotect the scheduling queues: */
- _queue_signals = 0;
- }
-
- /* Nothing to return. */
- return;
-}
-
-void
-_thread_kern_set_timeout(struct timespec * timeout)
-{
- struct timespec current_time;
- struct timeval tv;
-
- /* Reset the timeout flag for the running thread: */
- _thread_run->timeout = 0;
-
- /* Check if the thread is to wait forever: */
- if (timeout == NULL) {
- /*
- * Set the wakeup time to something that can be recognised as
- * different to an actual time of day:
- */
- _thread_run->wakeup_time.tv_sec = -1;
- _thread_run->wakeup_time.tv_nsec = -1;
- }
- /* Check if no waiting is required: */
- else if (timeout->tv_sec == 0 && timeout->tv_nsec == 0) {
- /* Set the wake up time to 'immediately': */
- _thread_run->wakeup_time.tv_sec = 0;
- _thread_run->wakeup_time.tv_nsec = 0;
- } else {
- /* Get the current time: */
- gettimeofday(&tv, NULL);
- TIMEVAL_TO_TIMESPEC(&tv, &current_time);
-
- /* Calculate the time for the current thread to wake up: */
- _thread_run->wakeup_time.tv_sec = current_time.tv_sec + timeout->tv_sec;
- _thread_run->wakeup_time.tv_nsec = current_time.tv_nsec + timeout->tv_nsec;
-
- /* Check if the nanosecond field needs to wrap: */
- if (_thread_run->wakeup_time.tv_nsec >= 1000000000) {
- /* Wrap the nanosecond field: */
- _thread_run->wakeup_time.tv_sec += 1;
- _thread_run->wakeup_time.tv_nsec -= 1000000000;
- }
- }
- return;
-}
-
-void
-_thread_kern_sig_defer(void)
-{
- /* Allow signal deferral to be recursive. */
- _thread_run->sig_defer_count++;
-}
-
-void
-_thread_kern_sig_undefer(void)
-{
- pthread_t pthread;
- int need_resched = 0;
-
- /*
- * Perform checks to yield only if we are about to undefer
- * signals.
- */
- if (_thread_run->sig_defer_count > 1) {
- /* Decrement the signal deferral count. */
- _thread_run->sig_defer_count--;
- }
- else if (_thread_run->sig_defer_count == 1) {
- /* Reenable signals: */
- _thread_run->sig_defer_count = 0;
-
- /*
- * Check if there are queued signals:
- */
- while (_sigq_check_reqd != 0) {
- /* Defer scheduling while we process queued signals: */
- _thread_run->sig_defer_count = 1;
-
- /* Clear the flag before checking the signal queue: */
- _sigq_check_reqd = 0;
-
- /* Dequeue and handle signals: */
- dequeue_signals();
-
- /*
- * Avoiding an unnecessary check to reschedule, check
- * to see if signal handling caused a higher priority
- * thread to become ready.
- */
- if ((need_resched == 0) &&
- (((pthread = PTHREAD_PRIOQ_FIRST()) != NULL) &&
- (pthread->active_priority > _thread_run->active_priority))) {
- need_resched = 1;
- }
-
- /* Reenable signals: */
- _thread_run->sig_defer_count = 0;
- }
-
- /* Yield the CPU if necessary: */
- if (need_resched || _thread_run->yield_on_sig_undefer != 0) {
- _thread_run->yield_on_sig_undefer = 0;
- _thread_kern_sched(NULL);
- }
- }
-}
-
-static void
-dequeue_signals(void)
-{
- char bufr[128];
- int i, num;
- pthread_t pthread;
-
- /*
- * Enter a loop to read and handle queued signals from the
- * pthread kernel pipe:
- */
- while (((num = _thread_sys_read(_thread_kern_pipe[0], bufr,
- sizeof(bufr))) > 0) || (num == -1 && errno == EINTR)) {
- /*
- * The buffer read contains one byte per signal and
- * each byte is the signal number.
- */
- for (i = 0; i < num; i++) {
- if ((int) bufr[i] == _SCHED_SIGNAL) {
- /*
- * Scheduling signals shouldn't ever be
- * queued; just ignore it for now.
- */
- }
- else {
- /* Handle this signal: */
- pthread = _thread_sig_handle((int) bufr[i],
- NULL);
- if (pthread != NULL)
- _thread_sig_deliver(pthread,
- (int) bufr[i]);
- }
- }
- }
- if ((num < 0) && (errno != EAGAIN)) {
- /*
- * The only error we should expect is if there is
- * no data to read.
- */
- PANIC("Unable to read from thread kernel pipe");
- }
-}
-
-static inline void
-thread_run_switch_hook(pthread_t thread_out, pthread_t thread_in)
-{
- pthread_t tid_out = thread_out;
- pthread_t tid_in = thread_in;
-
- if ((tid_out != NULL) &&
- (tid_out->flags & PTHREAD_FLAGS_PRIVATE) != 0)
- tid_out = NULL;
- if ((tid_in != NULL) &&
- (tid_in->flags & PTHREAD_FLAGS_PRIVATE) != 0)
- tid_in = NULL;
-
- if ((_sched_switch_hook != NULL) && (tid_out != tid_in)) {
- /* Run the scheduler switch hook: */
- _sched_switch_hook(tid_out, tid_in);
- }
-}
-#endif
diff --git a/lib/libkse/thread/thr_kill.c b/lib/libkse/thread/thr_kill.c
deleted file mode 100644
index 4bf1761cf9ed..000000000000
--- a/lib/libkse/thread/thr_kill.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#include <signal.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_kill(pthread_t pthread, int sig)
-{
- int ret;
-
- /* Check for invalid signal numbers: */
- if (sig < 0 || sig >= NSIG)
- /* Invalid signal: */
- ret = EINVAL;
- /*
- * Ensure the thread is in the list of active threads, and the
- * signal is valid (signal 0 specifies error checking only) and
- * not being ignored:
- */
- else if (((ret = _find_thread(pthread)) == 0) && (sig > 0) &&
- (_thread_sigact[sig - 1].sa_handler != SIG_IGN)) {
- /*
- * Defer signals to protect the scheduling queues from
- * access by the signal handler:
- */
- _thread_kern_sig_defer();
-
- _thread_sig_send(pthread, sig);
-
- /*
- * Undefer and handle pending signals, yielding if
- * necessary:
- */
- _thread_kern_sig_undefer();
- }
-
- /* Return the completion status: */
- return (ret);
-}
-#endif
diff --git a/lib/libkse/thread/thr_mattr_init.c b/lib/libkse/thread/thr_mattr_init.c
deleted file mode 100644
index 63d4401f2553..000000000000
--- a/lib/libkse/thread/thr_mattr_init.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 1996 Jeffrey Hsu <hsu@freebsd.org>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_mutexattr_init(pthread_mutexattr_t *attr)
-{
- int ret;
- pthread_mutexattr_t pattr;
-
- if ((pattr = (pthread_mutexattr_t)
- malloc(sizeof(struct pthread_mutex_attr))) == NULL) {
- ret = ENOMEM;
- } else {
- memcpy(pattr, &pthread_mutexattr_default,
- sizeof(struct pthread_mutex_attr));
- *attr = pattr;
- ret = 0;
- }
- return(ret);
-}
-#endif
diff --git a/lib/libkse/thread/thr_mattr_kind_np.c b/lib/libkse/thread/thr_mattr_kind_np.c
deleted file mode 100644
index 8b3b8cbafaf5..000000000000
--- a/lib/libkse/thread/thr_mattr_kind_np.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 1996 Jeffrey Hsu <hsu@freebsd.org>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_mutexattr_setkind_np(pthread_mutexattr_t *attr, int kind)
-{
- int ret;
- if (attr == NULL || *attr == NULL) {
- errno = EINVAL;
- ret = -1;
- } else {
- (*attr)->m_type = kind;
- ret = 0;
- }
- return(ret);
-}
-
-int
-pthread_mutexattr_getkind_np(pthread_mutexattr_t attr)
-{
- int ret;
- if (attr == NULL) {
- errno = EINVAL;
- ret = -1;
- } else {
- ret = attr->m_type;
- }
- return(ret);
-}
-
-int
-pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type)
-{
- int ret;
- if (attr == NULL || *attr == NULL || type >= MUTEX_TYPE_MAX) {
- errno = EINVAL;
- ret = -1;
- } else {
- (*attr)->m_type = type;
- ret = 0;
- }
- return(ret);
-}
-#endif
diff --git a/lib/libkse/thread/thr_msync.c b/lib/libkse/thread/thr_msync.c
deleted file mode 100644
index 2ae6ac75ab73..000000000000
--- a/lib/libkse/thread/thr_msync.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * David Leonard <d@openbsd.org>, 1999. Public Domain.
- *
- * $OpenBSD: uthread_msync.c,v 1.2 1999/06/09 07:16:17 d Exp $
- *
- * $FreeBSD$
- */
-
-#include <sys/types.h>
-#include <sys/mman.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-_msync(void *addr, size_t len, int flags)
-{
- int ret;
-
- ret = _thread_sys_msync(addr, len, flags);
-
- return (ret);
-}
-
-int
-msync(void *addr, size_t len, int flags)
-{
- int ret;
-
- /*
- * XXX This is quite pointless unless we know how to get the
- * file descriptor associated with the memory, and lock it for
- * write. The only real use of this wrapper is to guarantee
- * a cancellation point, as per the standard. sigh.
- */
- _thread_enter_cancellation_point();
- ret = _msync(addr, len, flags);
- _thread_leave_cancellation_point();
-
- return ret;
-}
-#endif
diff --git a/lib/libkse/thread/thr_multi_np.c b/lib/libkse/thread/thr_multi_np.c
deleted file mode 100644
index 9a2f7c1ece49..000000000000
--- a/lib/libkse/thread/thr_multi_np.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <string.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_multi_np()
-{
- /* Return to multi-threaded scheduling mode: */
- _thread_single = NULL;
- return(0);
-}
-#endif
diff --git a/lib/libkse/thread/thr_mutex.c b/lib/libkse/thread/thr_mutex.c
deleted file mode 100644
index 6d75ea52752e..000000000000
--- a/lib/libkse/thread/thr_mutex.c
+++ /dev/null
@@ -1,1404 +0,0 @@
-/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <stdlib.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/param.h>
-#include <sys/queue.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-#if defined(_PTHREADS_INVARIANTS)
-#define _MUTEX_INIT_LINK(m) do { \
- (m)->m_qe.tqe_prev = NULL; \
- (m)->m_qe.tqe_next = NULL; \
-} while (0)
-#define _MUTEX_ASSERT_IS_OWNED(m) do { \
- if ((m)->m_qe.tqe_prev == NULL) \
- PANIC("mutex is not on list"); \
-} while (0)
-#define _MUTEX_ASSERT_NOT_OWNED(m) do { \
- if (((m)->m_qe.tqe_prev != NULL) || \
- ((m)->m_qe.tqe_next != NULL)) \
- PANIC("mutex is on list"); \
-} while (0)
-#else
-#define _MUTEX_INIT_LINK(m)
-#define _MUTEX_ASSERT_IS_OWNED(m)
-#define _MUTEX_ASSERT_NOT_OWNED(m)
-#endif
-
-/*
- * Prototypes
- */
-static inline int mutex_self_trylock(pthread_mutex_t);
-static inline int mutex_self_lock(pthread_mutex_t);
-static inline int mutex_unlock_common(pthread_mutex_t *, int);
-static void mutex_priority_adjust(pthread_mutex_t);
-static void mutex_rescan_owned (pthread_t, pthread_mutex_t);
-static inline pthread_t mutex_queue_deq(pthread_mutex_t);
-static inline void mutex_queue_remove(pthread_mutex_t, pthread_t);
-static inline void mutex_queue_enq(pthread_mutex_t, pthread_t);
-
-
-static spinlock_t static_init_lock = _SPINLOCK_INITIALIZER;
-
-/* Reinitialize a mutex to defaults. */
-int
-_mutex_reinit(pthread_mutex_t * mutex)
-{
- int ret = 0;
-
- if (mutex == NULL)
- ret = EINVAL;
- else if (*mutex == NULL)
- ret = pthread_mutex_init(mutex, NULL);
- else {
- /*
- * Initialize the mutex structure:
- */
- (*mutex)->m_type = PTHREAD_MUTEX_DEFAULT;
- (*mutex)->m_protocol = PTHREAD_PRIO_NONE;
- TAILQ_INIT(&(*mutex)->m_queue);
- (*mutex)->m_owner = NULL;
- (*mutex)->m_data.m_count = 0;
- (*mutex)->m_flags &= MUTEX_FLAGS_PRIVATE;
- (*mutex)->m_flags |= MUTEX_FLAGS_INITED;
- (*mutex)->m_refcount = 0;
- (*mutex)->m_prio = 0;
- (*mutex)->m_saved_prio = 0;
- _MUTEX_INIT_LINK(*mutex);
- memset(&(*mutex)->lock, 0, sizeof((*mutex)->lock));
- }
- return (ret);
-}
-
-int
-pthread_mutex_init(pthread_mutex_t * mutex,
- const pthread_mutexattr_t * mutex_attr)
-{
- enum pthread_mutextype type;
- int protocol;
- int ceiling;
- pthread_mutex_t pmutex;
- int ret = 0;
-
- if (mutex == NULL)
- ret = EINVAL;
-
- /* Check if default mutex attributes: */
- else if (mutex_attr == NULL || *mutex_attr == NULL) {
- /* Default to a (error checking) POSIX mutex: */
- type = PTHREAD_MUTEX_ERRORCHECK;
- protocol = PTHREAD_PRIO_NONE;
- ceiling = PTHREAD_MAX_PRIORITY;
- }
-
- /* Check mutex type: */
- else if (((*mutex_attr)->m_type < PTHREAD_MUTEX_ERRORCHECK) ||
- ((*mutex_attr)->m_type >= MUTEX_TYPE_MAX))
- /* Return an invalid argument error: */
- ret = EINVAL;
-
- /* Check mutex protocol: */
- else if (((*mutex_attr)->m_protocol < PTHREAD_PRIO_NONE) ||
- ((*mutex_attr)->m_protocol > PTHREAD_MUTEX_RECURSIVE))
- /* Return an invalid argument error: */
- ret = EINVAL;
-
- else {
- /* Use the requested mutex type and protocol: */
- type = (*mutex_attr)->m_type;
- protocol = (*mutex_attr)->m_protocol;
- ceiling = (*mutex_attr)->m_ceiling;
- }
-
- /* Check no errors so far: */
- if (ret == 0) {
- if ((pmutex = (pthread_mutex_t)
- malloc(sizeof(struct pthread_mutex))) == NULL)
- ret = ENOMEM;
- else {
- /* Reset the mutex flags: */
- pmutex->m_flags = 0;
-
- /* Process according to mutex type: */
- switch (type) {
- /* case PTHREAD_MUTEX_DEFAULT: */
- case PTHREAD_MUTEX_ERRORCHECK:
- case PTHREAD_MUTEX_NORMAL:
- /* Nothing to do here. */
- break;
-
- /* Single UNIX Spec 2 recursive mutex: */
- case PTHREAD_MUTEX_RECURSIVE:
- /* Reset the mutex count: */
- pmutex->m_data.m_count = 0;
- break;
-
- /* Trap invalid mutex types: */
- default:
- /* Return an invalid argument error: */
- ret = EINVAL;
- break;
- }
- if (ret == 0) {
- /* Initialise the rest of the mutex: */
- TAILQ_INIT(&pmutex->m_queue);
- pmutex->m_flags |= MUTEX_FLAGS_INITED;
- pmutex->m_owner = NULL;
- pmutex->m_type = type;
- pmutex->m_protocol = protocol;
- pmutex->m_refcount = 0;
- if (protocol == PTHREAD_PRIO_PROTECT)
- pmutex->m_prio = ceiling;
- else
- pmutex->m_prio = 0;
- pmutex->m_saved_prio = 0;
- _MUTEX_INIT_LINK(pmutex);
- memset(&pmutex->lock, 0, sizeof(pmutex->lock));
- *mutex = pmutex;
- } else {
- free(pmutex);
- *mutex = NULL;
- }
- }
- }
- /* Return the completion status: */
- return(ret);
-}
-
-int
-pthread_mutex_destroy(pthread_mutex_t * mutex)
-{
- int ret = 0;
-
- if (mutex == NULL || *mutex == NULL)
- ret = EINVAL;
- else {
- /* Lock the mutex structure: */
- _SPINLOCK(&(*mutex)->lock);
-
- /*
- * Check to see if this mutex is in use:
- */
- if (((*mutex)->m_owner != NULL) ||
- (TAILQ_FIRST(&(*mutex)->m_queue) != NULL) ||
- ((*mutex)->m_refcount != 0)) {
- ret = EBUSY;
-
- /* Unlock the mutex structure: */
- _SPINUNLOCK(&(*mutex)->lock);
- }
- else {
- /*
- * Free the memory allocated for the mutex
- * structure:
- */
- _MUTEX_ASSERT_NOT_OWNED(*mutex);
- free(*mutex);
-
- /*
- * Leave the caller's pointer NULL now that
- * the mutex has been destroyed:
- */
- *mutex = NULL;
- }
- }
-
- /* Return the completion status: */
- return (ret);
-}
-
-static int
-init_static(pthread_mutex_t *mutex)
-{
- int ret;
-
- _SPINLOCK(&static_init_lock);
-
- if (*mutex == NULL)
- ret = pthread_mutex_init(mutex, NULL);
- else
- ret = 0;
-
- _SPINUNLOCK(&static_init_lock);
-
- return(ret);
-}
-
-int
-pthread_mutex_trylock(pthread_mutex_t * mutex)
-{
- int ret = 0;
-
- if (mutex == NULL)
- ret = EINVAL;
-
- /*
- * If the mutex is statically initialized, perform the dynamic
- * initialization:
- */
- else if (*mutex != NULL || (ret = init_static(mutex)) == 0) {
- /*
- * Defer signals to protect the scheduling queues from
- * access by the signal handler:
- */
- _thread_kern_sig_defer();
-
- /* Lock the mutex structure: */
- _SPINLOCK(&(*mutex)->lock);
-
- /*
- * If the mutex was statically allocated, properly
- * initialize the tail queue.
- */
- if (((*mutex)->m_flags & MUTEX_FLAGS_INITED) == 0) {
- TAILQ_INIT(&(*mutex)->m_queue);
- _MUTEX_INIT_LINK(*mutex);
- (*mutex)->m_flags |= MUTEX_FLAGS_INITED;
- }
-
- /* Process according to mutex type: */
- switch ((*mutex)->m_protocol) {
- /* Default POSIX mutex: */
- case PTHREAD_PRIO_NONE:
- /* Check if this mutex is not locked: */
- if ((*mutex)->m_owner == NULL) {
- /* Lock the mutex for the running thread: */
- (*mutex)->m_owner = _thread_run;
-
- /* Add to the list of owned mutexes: */
- _MUTEX_ASSERT_NOT_OWNED(*mutex);
- TAILQ_INSERT_TAIL(&_thread_run->mutexq,
- (*mutex), m_qe);
- } else if ((*mutex)->m_owner == _thread_run)
- ret = mutex_self_trylock(*mutex);
- else
- /* Return a busy error: */
- ret = EBUSY;
- break;
-
- /* POSIX priority inheritence mutex: */
- case PTHREAD_PRIO_INHERIT:
- /* Check if this mutex is not locked: */
- if ((*mutex)->m_owner == NULL) {
- /* Lock the mutex for the running thread: */
- (*mutex)->m_owner = _thread_run;
-
- /* Track number of priority mutexes owned: */
- _thread_run->priority_mutex_count++;
-
- /*
- * The mutex takes on the attributes of the
- * running thread when there are no waiters.
- */
- (*mutex)->m_prio = _thread_run->active_priority;
- (*mutex)->m_saved_prio =
- _thread_run->inherited_priority;
-
- /* Add to the list of owned mutexes: */
- _MUTEX_ASSERT_NOT_OWNED(*mutex);
- TAILQ_INSERT_TAIL(&_thread_run->mutexq,
- (*mutex), m_qe);
- } else if ((*mutex)->m_owner == _thread_run)
- ret = mutex_self_trylock(*mutex);
- else
- /* Return a busy error: */
- ret = EBUSY;
- break;
-
- /* POSIX priority protection mutex: */
- case PTHREAD_PRIO_PROTECT:
- /* Check for a priority ceiling violation: */
- if (_thread_run->active_priority > (*mutex)->m_prio)
- ret = EINVAL;
-
- /* Check if this mutex is not locked: */
- else if ((*mutex)->m_owner == NULL) {
- /* Lock the mutex for the running thread: */
- (*mutex)->m_owner = _thread_run;
-
- /* Track number of priority mutexes owned: */
- _thread_run->priority_mutex_count++;
-
- /*
- * The running thread inherits the ceiling
- * priority of the mutex and executes at that
- * priority.
- */
- _thread_run->active_priority = (*mutex)->m_prio;
- (*mutex)->m_saved_prio =
- _thread_run->inherited_priority;
- _thread_run->inherited_priority =
- (*mutex)->m_prio;
-
- /* Add to the list of owned mutexes: */
- _MUTEX_ASSERT_NOT_OWNED(*mutex);
- TAILQ_INSERT_TAIL(&_thread_run->mutexq,
- (*mutex), m_qe);
- } else if ((*mutex)->m_owner == _thread_run)
- ret = mutex_self_trylock(*mutex);
- else
- /* Return a busy error: */
- ret = EBUSY;
- break;
-
- /* Trap invalid mutex types: */
- default:
- /* Return an invalid argument error: */
- ret = EINVAL;
- break;
- }
-
- /* Unlock the mutex structure: */
- _SPINUNLOCK(&(*mutex)->lock);
-
- /*
- * Undefer and handle pending signals, yielding if
- * necessary:
- */
- _thread_kern_sig_undefer();
- }
-
- /* Return the completion status: */
- return (ret);
-}
-
-int
-pthread_mutex_lock(pthread_mutex_t * mutex)
-{
- int ret = 0;
-
- if (mutex == NULL)
- ret = EINVAL;
-
- /*
- * If the mutex is statically initialized, perform the dynamic
- * initialization:
- */
- else if (*mutex != NULL || (ret = init_static(mutex)) == 0) {
- /*
- * Defer signals to protect the scheduling queues from
- * access by the signal handler:
- */
- _thread_kern_sig_defer();
-
- /* Lock the mutex structure: */
- _SPINLOCK(&(*mutex)->lock);
-
- /*
- * If the mutex was statically allocated, properly
- * initialize the tail queue.
- */
- if (((*mutex)->m_flags & MUTEX_FLAGS_INITED) == 0) {
- TAILQ_INIT(&(*mutex)->m_queue);
- (*mutex)->m_flags |= MUTEX_FLAGS_INITED;
- _MUTEX_INIT_LINK(*mutex);
- }
-
- /* Reset the interrupted flag: */
- _thread_run->interrupted = 0;
-
- /* Process according to mutex type: */
- switch ((*mutex)->m_protocol) {
- /* Default POSIX mutex: */
- case PTHREAD_PRIO_NONE:
- if ((*mutex)->m_owner == NULL) {
- /* Lock the mutex for this thread: */
- (*mutex)->m_owner = _thread_run;
-
- /* Add to the list of owned mutexes: */
- _MUTEX_ASSERT_NOT_OWNED(*mutex);
- TAILQ_INSERT_TAIL(&_thread_run->mutexq,
- (*mutex), m_qe);
-
- } else if ((*mutex)->m_owner == _thread_run)
- ret = mutex_self_lock(*mutex);
- else {
- /*
- * Join the queue of threads waiting to lock
- * the mutex:
- */
- mutex_queue_enq(*mutex, _thread_run);
-
- /*
- * Keep a pointer to the mutex this thread
- * is waiting on:
- */
- _thread_run->data.mutex = *mutex;
-
- /*
- * Unlock the mutex structure and schedule the
- * next thread:
- */
- _thread_kern_sched_state_unlock(PS_MUTEX_WAIT,
- &(*mutex)->lock, __FILE__, __LINE__);
-
- /* Lock the mutex structure again: */
- _SPINLOCK(&(*mutex)->lock);
- }
- break;
-
- /* POSIX priority inheritence mutex: */
- case PTHREAD_PRIO_INHERIT:
- /* Check if this mutex is not locked: */
- if ((*mutex)->m_owner == NULL) {
- /* Lock the mutex for this thread: */
- (*mutex)->m_owner = _thread_run;
-
- /* Track number of priority mutexes owned: */
- _thread_run->priority_mutex_count++;
-
- /*
- * The mutex takes on attributes of the
- * running thread when there are no waiters.
- */
- (*mutex)->m_prio = _thread_run->active_priority;
- (*mutex)->m_saved_prio =
- _thread_run->inherited_priority;
- _thread_run->inherited_priority =
- (*mutex)->m_prio;
-
- /* Add to the list of owned mutexes: */
- _MUTEX_ASSERT_NOT_OWNED(*mutex);
- TAILQ_INSERT_TAIL(&_thread_run->mutexq,
- (*mutex), m_qe);
-
- } else if ((*mutex)->m_owner == _thread_run)
- ret = mutex_self_lock(*mutex);
- else {
- /*
- * Join the queue of threads waiting to lock
- * the mutex:
- */
- mutex_queue_enq(*mutex, _thread_run);
-
- /*
- * Keep a pointer to the mutex this thread
- * is waiting on:
- */
- _thread_run->data.mutex = *mutex;
-
- if (_thread_run->active_priority >
- (*mutex)->m_prio)
- /* Adjust priorities: */
- mutex_priority_adjust(*mutex);
-
- /*
- * Unlock the mutex structure and schedule the
- * next thread:
- */
- _thread_kern_sched_state_unlock(PS_MUTEX_WAIT,
- &(*mutex)->lock, __FILE__, __LINE__);
-
- /* Lock the mutex structure again: */
- _SPINLOCK(&(*mutex)->lock);
- }
- break;
-
- /* POSIX priority protection mutex: */
- case PTHREAD_PRIO_PROTECT:
- /* Check for a priority ceiling violation: */
- if (_thread_run->active_priority > (*mutex)->m_prio)
- ret = EINVAL;
-
- /* Check if this mutex is not locked: */
- else if ((*mutex)->m_owner == NULL) {
- /*
- * Lock the mutex for the running
- * thread:
- */
- (*mutex)->m_owner = _thread_run;
-
- /* Track number of priority mutexes owned: */
- _thread_run->priority_mutex_count++;
-
- /*
- * The running thread inherits the ceiling
- * priority of the mutex and executes at that
- * priority:
- */
- _thread_run->active_priority = (*mutex)->m_prio;
- (*mutex)->m_saved_prio =
- _thread_run->inherited_priority;
- _thread_run->inherited_priority =
- (*mutex)->m_prio;
-
- /* Add to the list of owned mutexes: */
- _MUTEX_ASSERT_NOT_OWNED(*mutex);
- TAILQ_INSERT_TAIL(&_thread_run->mutexq,
- (*mutex), m_qe);
- } else if ((*mutex)->m_owner == _thread_run)
- ret = mutex_self_lock(*mutex);
- else {
- /*
- * Join the queue of threads waiting to lock
- * the mutex:
- */
- mutex_queue_enq(*mutex, _thread_run);
-
- /*
- * Keep a pointer to the mutex this thread
- * is waiting on:
- */
- _thread_run->data.mutex = *mutex;
-
- /* Clear any previous error: */
- _thread_run->error = 0;
-
- /*
- * Unlock the mutex structure and schedule the
- * next thread:
- */
- _thread_kern_sched_state_unlock(PS_MUTEX_WAIT,
- &(*mutex)->lock, __FILE__, __LINE__);
-
- /* Lock the mutex structure again: */
- _SPINLOCK(&(*mutex)->lock);
-
- /*
- * The threads priority may have changed while
- * waiting for the mutex causing a ceiling
- * violation.
- */
- ret = _thread_run->error;
- _thread_run->error = 0;
- }
- break;
-
- /* Trap invalid mutex types: */
- default:
- /* Return an invalid argument error: */
- ret = EINVAL;
- break;
- }
-
- /*
- * Check to see if this thread was interrupted and
- * is still in the mutex queue of waiting threads:
- */
- if (_thread_run->interrupted != 0)
- mutex_queue_remove(*mutex, _thread_run);
-
- /* Unlock the mutex structure: */
- _SPINUNLOCK(&(*mutex)->lock);
-
- /*
- * Undefer and handle pending signals, yielding if
- * necessary:
- */
- _thread_kern_sig_undefer();
-
- if (_thread_run->interrupted != 0 &&
- _thread_run->continuation != NULL)
- _thread_run->continuation((void *) _thread_run);
- }
-
- /* Return the completion status: */
- return (ret);
-}
-
-int
-pthread_mutex_unlock(pthread_mutex_t * mutex)
-{
- return (mutex_unlock_common(mutex, /* add reference */ 0));
-}
-
-int
-_mutex_cv_unlock(pthread_mutex_t * mutex)
-{
- return (mutex_unlock_common(mutex, /* add reference */ 1));
-}
-
-int
-_mutex_cv_lock(pthread_mutex_t * mutex)
-{
- int ret;
- if ((ret = pthread_mutex_lock(mutex)) == 0)
- (*mutex)->m_refcount--;
- return (ret);
-}
-
-static inline int
-mutex_self_trylock(pthread_mutex_t mutex)
-{
- int ret = 0;
-
- switch (mutex->m_type) {
-
- /* case PTHREAD_MUTEX_DEFAULT: */
- case PTHREAD_MUTEX_ERRORCHECK:
- case PTHREAD_MUTEX_NORMAL:
- /*
- * POSIX specifies that mutexes should return EDEADLK if a
- * recursive lock is detected.
- */
- ret = EBUSY;
- break;
-
- case PTHREAD_MUTEX_RECURSIVE:
- /* Increment the lock count: */
- mutex->m_data.m_count++;
- break;
-
- default:
- /* Trap invalid mutex types; */
- ret = EINVAL;
- }
-
- return(ret);
-}
-
-static inline int
-mutex_self_lock(pthread_mutex_t mutex)
-{
- int ret = 0;
-
- switch (mutex->m_type) {
- /* case PTHREAD_MUTEX_DEFAULT: */
- case PTHREAD_MUTEX_ERRORCHECK:
- /*
- * POSIX specifies that mutexes should return EDEADLK if a
- * recursive lock is detected.
- */
- ret = EDEADLK;
- break;
-
- case PTHREAD_MUTEX_NORMAL:
- /*
- * What SS2 define as a 'normal' mutex. Intentionally
- * deadlock on attempts to get a lock you already own.
- */
- _thread_kern_sched_state_unlock(PS_DEADLOCK,
- &mutex->lock, __FILE__, __LINE__);
- break;
-
- case PTHREAD_MUTEX_RECURSIVE:
- /* Increment the lock count: */
- mutex->m_data.m_count++;
- break;
-
- default:
- /* Trap invalid mutex types; */
- ret = EINVAL;
- }
-
- return(ret);
-}
-
-static inline int
-mutex_unlock_common(pthread_mutex_t * mutex, int add_reference)
-{
- int ret = 0;
-
- if (mutex == NULL || *mutex == NULL) {
- ret = EINVAL;
- } else {
- /*
- * Defer signals to protect the scheduling queues from
- * access by the signal handler:
- */
- _thread_kern_sig_defer();
-
- /* Lock the mutex structure: */
- _SPINLOCK(&(*mutex)->lock);
-
- /* Process according to mutex type: */
- switch ((*mutex)->m_protocol) {
- /* Default POSIX mutex: */
- case PTHREAD_PRIO_NONE:
- /*
- * Check if the running thread is not the owner of the
- * mutex:
- */
- if ((*mutex)->m_owner != _thread_run) {
- /*
- * Return an invalid argument error for no
- * owner and a permission error otherwise:
- */
- ret = (*mutex)->m_owner == NULL ? EINVAL : EPERM;
- }
- else if (((*mutex)->m_type == PTHREAD_MUTEX_RECURSIVE) &&
- ((*mutex)->m_data.m_count > 1)) {
- /* Decrement the count: */
- (*mutex)->m_data.m_count--;
- } else {
- /*
- * Clear the count in case this is recursive
- * mutex.
- */
- (*mutex)->m_data.m_count = 0;
-
- /* Remove the mutex from the threads queue. */
- _MUTEX_ASSERT_IS_OWNED(*mutex);
- TAILQ_REMOVE(&(*mutex)->m_owner->mutexq,
- (*mutex), m_qe);
- _MUTEX_INIT_LINK(*mutex);
-
- /*
- * Get the next thread from the queue of
- * threads waiting on the mutex:
- */
- if (((*mutex)->m_owner =
- mutex_queue_deq(*mutex)) != NULL) {
- /*
- * Allow the new owner of the mutex to
- * run:
- */
- PTHREAD_NEW_STATE((*mutex)->m_owner,
- PS_RUNNING);
-
- /*
- * Add the mutex to the threads list of
- * owned mutexes:
- */
- TAILQ_INSERT_TAIL(&(*mutex)->m_owner->mutexq,
- (*mutex), m_qe);
-
- /*
- * The owner is no longer waiting for
- * this mutex:
- */
- (*mutex)->m_owner->data.mutex = NULL;
- }
- }
- break;
-
- /* POSIX priority inheritence mutex: */
- case PTHREAD_PRIO_INHERIT:
- /*
- * Check if the running thread is not the owner of the
- * mutex:
- */
- if ((*mutex)->m_owner != _thread_run) {
- /*
- * Return an invalid argument error for no
- * owner and a permission error otherwise:
- */
- ret = (*mutex)->m_owner == NULL ? EINVAL : EPERM;
- }
- else if (((*mutex)->m_type == PTHREAD_MUTEX_RECURSIVE) &&
- ((*mutex)->m_data.m_count > 1)) {
- /* Decrement the count: */
- (*mutex)->m_data.m_count--;
- } else {
- /*
- * Clear the count in case this is recursive
- * mutex.
- */
- (*mutex)->m_data.m_count = 0;
-
- /*
- * Restore the threads inherited priority and
- * recompute the active priority (being careful
- * not to override changes in the threads base
- * priority subsequent to locking the mutex).
- */
- _thread_run->inherited_priority =
- (*mutex)->m_saved_prio;
- _thread_run->active_priority =
- MAX(_thread_run->inherited_priority,
- _thread_run->base_priority);
-
- /*
- * This thread now owns one less priority mutex.
- */
- _thread_run->priority_mutex_count--;
-
- /* Remove the mutex from the threads queue. */
- _MUTEX_ASSERT_IS_OWNED(*mutex);
- TAILQ_REMOVE(&(*mutex)->m_owner->mutexq,
- (*mutex), m_qe);
- _MUTEX_INIT_LINK(*mutex);
-
- /*
- * Get the next thread from the queue of threads
- * waiting on the mutex:
- */
- if (((*mutex)->m_owner =
- mutex_queue_deq(*mutex)) == NULL)
- /* This mutex has no priority. */
- (*mutex)->m_prio = 0;
- else {
- /*
- * Track number of priority mutexes owned:
- */
- (*mutex)->m_owner->priority_mutex_count++;
-
- /*
- * Add the mutex to the threads list
- * of owned mutexes:
- */
- TAILQ_INSERT_TAIL(&(*mutex)->m_owner->mutexq,
- (*mutex), m_qe);
-
- /*
- * The owner is no longer waiting for
- * this mutex:
- */
- (*mutex)->m_owner->data.mutex = NULL;
-
- /*
- * Set the priority of the mutex. Since
- * our waiting threads are in descending
- * priority order, the priority of the
- * mutex becomes the active priority of
- * the thread we just dequeued.
- */
- (*mutex)->m_prio =
- (*mutex)->m_owner->active_priority;
-
- /*
- * Save the owning threads inherited
- * priority:
- */
- (*mutex)->m_saved_prio =
- (*mutex)->m_owner->inherited_priority;
-
- /*
- * The owning threads inherited priority
- * now becomes his active priority (the
- * priority of the mutex).
- */
- (*mutex)->m_owner->inherited_priority =
- (*mutex)->m_prio;
-
- /*
- * Allow the new owner of the mutex to
- * run:
- */
- PTHREAD_NEW_STATE((*mutex)->m_owner,
- PS_RUNNING);
- }
- }
- break;
-
- /* POSIX priority ceiling mutex: */
- case PTHREAD_PRIO_PROTECT:
- /*
- * Check if the running thread is not the owner of the
- * mutex:
- */
- if ((*mutex)->m_owner != _thread_run) {
- /*
- * Return an invalid argument error for no
- * owner and a permission error otherwise:
- */
- ret = (*mutex)->m_owner == NULL ? EINVAL : EPERM;
- }
- else if (((*mutex)->m_type == PTHREAD_MUTEX_RECURSIVE) &&
- ((*mutex)->m_data.m_count > 1)) {
- /* Decrement the count: */
- (*mutex)->m_data.m_count--;
- } else {
- /*
- * Clear the count in case this is recursive
- * mutex.
- */
- (*mutex)->m_data.m_count = 0;
-
- /*
- * Restore the threads inherited priority and
- * recompute the active priority (being careful
- * not to override changes in the threads base
- * priority subsequent to locking the mutex).
- */
- _thread_run->inherited_priority =
- (*mutex)->m_saved_prio;
- _thread_run->active_priority =
- MAX(_thread_run->inherited_priority,
- _thread_run->base_priority);
-
- /*
- * This thread now owns one less priority mutex.
- */
- _thread_run->priority_mutex_count--;
-
- /* Remove the mutex from the threads queue. */
- _MUTEX_ASSERT_IS_OWNED(*mutex);
- TAILQ_REMOVE(&(*mutex)->m_owner->mutexq,
- (*mutex), m_qe);
- _MUTEX_INIT_LINK(*mutex);
-
- /*
- * Enter a loop to find a waiting thread whose
- * active priority will not cause a ceiling
- * violation:
- */
- while ((((*mutex)->m_owner =
- mutex_queue_deq(*mutex)) != NULL) &&
- ((*mutex)->m_owner->active_priority >
- (*mutex)->m_prio)) {
- /*
- * Either the mutex ceiling priority
- * been lowered and/or this threads
- * priority has been raised subsequent
- * to this thread being queued on the
- * waiting list.
- */
- (*mutex)->m_owner->error = EINVAL;
- PTHREAD_NEW_STATE((*mutex)->m_owner,
- PS_RUNNING);
- /*
- * The thread is no longer waiting for
- * this mutex:
- */
- (*mutex)->m_owner->data.mutex = NULL;
- }
-
- /* Check for a new owner: */
- if ((*mutex)->m_owner != NULL) {
- /*
- * Track number of priority mutexes owned:
- */
- (*mutex)->m_owner->priority_mutex_count++;
-
- /*
- * Add the mutex to the threads list
- * of owned mutexes:
- */
- TAILQ_INSERT_TAIL(&(*mutex)->m_owner->mutexq,
- (*mutex), m_qe);
-
- /*
- * The owner is no longer waiting for
- * this mutex:
- */
- (*mutex)->m_owner->data.mutex = NULL;
-
- /*
- * Save the owning threads inherited
- * priority:
- */
- (*mutex)->m_saved_prio =
- (*mutex)->m_owner->inherited_priority;
-
- /*
- * The owning thread inherits the
- * ceiling priority of the mutex and
- * executes at that priority:
- */
- (*mutex)->m_owner->inherited_priority =
- (*mutex)->m_prio;
- (*mutex)->m_owner->active_priority =
- (*mutex)->m_prio;
-
- /*
- * Allow the new owner of the mutex to
- * run:
- */
- PTHREAD_NEW_STATE((*mutex)->m_owner,
- PS_RUNNING);
- }
- }
- break;
-
- /* Trap invalid mutex types: */
- default:
- /* Return an invalid argument error: */
- ret = EINVAL;
- break;
- }
-
- if ((ret == 0) && (add_reference != 0)) {
- /* Increment the reference count: */
- (*mutex)->m_refcount++;
- }
-
- /* Unlock the mutex structure: */
- _SPINUNLOCK(&(*mutex)->lock);
-
- /*
- * Undefer and handle pending signals, yielding if
- * necessary:
- */
- _thread_kern_sig_undefer();
- }
-
- /* Return the completion status: */
- return (ret);
-}
-
-
-/*
- * This function is called when a change in base priority occurs for
- * a thread that is holding or waiting for a priority protection or
- * inheritence mutex. A change in a threads base priority can effect
- * changes to active priorities of other threads and to the ordering
- * of mutex locking by waiting threads.
- *
- * This must be called while thread scheduling is deferred.
- */
-void
-_mutex_notify_priochange(pthread_t pthread)
-{
- /* Adjust the priorites of any owned priority mutexes: */
- if (pthread->priority_mutex_count > 0) {
- /*
- * Rescan the mutexes owned by this thread and correct
- * their priorities to account for this threads change
- * in priority. This has the side effect of changing
- * the threads active priority.
- */
- mutex_rescan_owned(pthread, /* rescan all owned */ NULL);
- }
-
- /*
- * If this thread is waiting on a priority inheritence mutex,
- * check for priority adjustments. A change in priority can
- * also effect a ceiling violation(*) for a thread waiting on
- * a priority protection mutex; we don't perform the check here
- * as it is done in pthread_mutex_unlock.
- *
- * (*) It should be noted that a priority change to a thread
- * _after_ taking and owning a priority ceiling mutex
- * does not affect ownership of that mutex; the ceiling
- * priority is only checked before mutex ownership occurs.
- */
- if (pthread->state == PS_MUTEX_WAIT) {
- /* Lock the mutex structure: */
- _SPINLOCK(&pthread->data.mutex->lock);
-
- /*
- * Check to make sure this thread is still in the same state
- * (the spinlock above can yield the CPU to another thread):
- */
- if (pthread->state == PS_MUTEX_WAIT) {
- /*
- * Remove and reinsert this thread into the list of
- * waiting threads to preserve decreasing priority
- * order.
- */
- mutex_queue_remove(pthread->data.mutex, pthread);
- mutex_queue_enq(pthread->data.mutex, pthread);
-
- if (pthread->data.mutex->m_protocol ==
- PTHREAD_PRIO_INHERIT) {
- /* Adjust priorities: */
- mutex_priority_adjust(pthread->data.mutex);
- }
- }
-
- /* Unlock the mutex structure: */
- _SPINUNLOCK(&pthread->data.mutex->lock);
- }
-}
-
-/*
- * Called when a new thread is added to the mutex waiting queue or
- * when a threads priority changes that is already in the mutex
- * waiting queue.
- */
-static void
-mutex_priority_adjust(pthread_mutex_t mutex)
-{
- pthread_t pthread_next, pthread = mutex->m_owner;
- int temp_prio;
- pthread_mutex_t m = mutex;
-
- /*
- * Calculate the mutex priority as the maximum of the highest
- * active priority of any waiting threads and the owning threads
- * active priority(*).
- *
- * (*) Because the owning threads current active priority may
- * reflect priority inherited from this mutex (and the mutex
- * priority may have changed) we must recalculate the active
- * priority based on the threads saved inherited priority
- * and its base priority.
- */
- pthread_next = TAILQ_FIRST(&m->m_queue); /* should never be NULL */
- temp_prio = MAX(pthread_next->active_priority,
- MAX(m->m_saved_prio, pthread->base_priority));
-
- /* See if this mutex really needs adjusting: */
- if (temp_prio == m->m_prio)
- /* No need to propagate the priority: */
- return;
-
- /* Set new priority of the mutex: */
- m->m_prio = temp_prio;
-
- while (m != NULL) {
- /*
- * Save the threads priority before rescanning the
- * owned mutexes:
- */
- temp_prio = pthread->active_priority;
-
- /*
- * Fix the priorities for all the mutexes this thread has
- * locked since taking this mutex. This also has a
- * potential side-effect of changing the threads priority.
- */
- mutex_rescan_owned(pthread, m);
-
- /*
- * If the thread is currently waiting on a mutex, check
- * to see if the threads new priority has affected the
- * priority of the mutex.
- */
- if ((temp_prio != pthread->active_priority) &&
- (pthread->state == PS_MUTEX_WAIT) &&
- (pthread->data.mutex->m_protocol == PTHREAD_PRIO_INHERIT)) {
- /* Grab the mutex this thread is waiting on: */
- m = pthread->data.mutex;
-
- /*
- * The priority for this thread has changed. Remove
- * and reinsert this thread into the list of waiting
- * threads to preserve decreasing priority order.
- */
- mutex_queue_remove(m, pthread);
- mutex_queue_enq(m, pthread);
-
- /* Grab the waiting thread with highest priority: */
- pthread_next = TAILQ_FIRST(&m->m_queue);
-
- /*
- * Calculate the mutex priority as the maximum of the
- * highest active priority of any waiting threads and
- * the owning threads active priority.
- */
- temp_prio = MAX(pthread_next->active_priority,
- MAX(m->m_saved_prio, m->m_owner->base_priority));
-
- if (temp_prio != m->m_prio) {
- /*
- * The priority needs to be propagated to the
- * mutex this thread is waiting on and up to
- * the owner of that mutex.
- */
- m->m_prio = temp_prio;
- pthread = m->m_owner;
- }
- else
- /* We're done: */
- m = NULL;
-
- }
- else
- /* We're done: */
- m = NULL;
- }
-}
-
-static void
-mutex_rescan_owned(pthread_t pthread, pthread_mutex_t mutex)
-{
- int active_prio, inherited_prio;
- pthread_mutex_t m;
- pthread_t pthread_next;
-
- /*
- * Start walking the mutexes the thread has taken since
- * taking this mutex.
- */
- if (mutex == NULL) {
- /*
- * A null mutex means start at the beginning of the owned
- * mutex list.
- */
- m = TAILQ_FIRST(&pthread->mutexq);
-
- /* There is no inherited priority yet. */
- inherited_prio = 0;
- }
- else {
- /*
- * The caller wants to start after a specific mutex. It
- * is assumed that this mutex is a priority inheritence
- * mutex and that its priority has been correctly
- * calculated.
- */
- m = TAILQ_NEXT(mutex, m_qe);
-
- /* Start inheriting priority from the specified mutex. */
- inherited_prio = mutex->m_prio;
- }
- active_prio = MAX(inherited_prio, pthread->base_priority);
-
- while (m != NULL) {
- /*
- * We only want to deal with priority inheritence
- * mutexes. This might be optimized by only placing
- * priority inheritence mutexes into the owned mutex
- * list, but it may prove to be useful having all
- * owned mutexes in this list. Consider a thread
- * exiting while holding mutexes...
- */
- if (m->m_protocol == PTHREAD_PRIO_INHERIT) {
- /*
- * Fix the owners saved (inherited) priority to
- * reflect the priority of the previous mutex.
- */
- m->m_saved_prio = inherited_prio;
-
- if ((pthread_next = TAILQ_FIRST(&m->m_queue)) != NULL)
- /* Recalculate the priority of the mutex: */
- m->m_prio = MAX(active_prio,
- pthread_next->active_priority);
- else
- m->m_prio = active_prio;
-
- /* Recalculate new inherited and active priorities: */
- inherited_prio = m->m_prio;
- active_prio = MAX(m->m_prio, pthread->base_priority);
- }
-
- /* Advance to the next mutex owned by this thread: */
- m = TAILQ_NEXT(m, m_qe);
- }
-
- /*
- * Fix the threads inherited priority and recalculate its
- * active priority.
- */
- pthread->inherited_priority = inherited_prio;
- active_prio = MAX(inherited_prio, pthread->base_priority);
-
- if (active_prio != pthread->active_priority) {
- /*
- * If this thread is in the priority queue, it must be
- * removed and reinserted for its new priority.
- */
- if (pthread->flags & PTHREAD_FLAGS_IN_PRIOQ) {
- /*
- * Remove the thread from the priority queue
- * before changing its priority:
- */
- PTHREAD_PRIOQ_REMOVE(pthread);
-
- /*
- * POSIX states that if the priority is being
- * lowered, the thread must be inserted at the
- * head of the queue for its priority if it owns
- * any priority protection or inheritence mutexes.
- */
- if ((active_prio < pthread->active_priority) &&
- (pthread->priority_mutex_count > 0)) {
- /* Set the new active priority. */
- pthread->active_priority = active_prio;
-
- PTHREAD_PRIOQ_INSERT_HEAD(pthread);
- }
- else {
- /* Set the new active priority. */
- pthread->active_priority = active_prio;
-
- PTHREAD_PRIOQ_INSERT_TAIL(pthread);
- }
- }
- else {
- /* Set the new active priority. */
- pthread->active_priority = active_prio;
- }
- }
-}
-
-void
-_mutex_unlock_private(pthread_t pthread)
-{
- struct pthread_mutex *m, *m_next;
-
- for (m = TAILQ_FIRST(&pthread->mutexq); m != NULL; m = m_next) {
- m_next = TAILQ_NEXT(m, m_qe);
- if ((m->m_flags & MUTEX_FLAGS_PRIVATE) != 0)
- pthread_mutex_unlock(&m);
- }
-}
-
-/*
- * Dequeue a waiting thread from the head of a mutex queue in descending
- * priority order.
- */
-static inline pthread_t
-mutex_queue_deq(pthread_mutex_t mutex)
-{
- pthread_t pthread;
-
- while ((pthread = TAILQ_FIRST(&mutex->m_queue)) != NULL) {
- TAILQ_REMOVE(&mutex->m_queue, pthread, qe);
- pthread->flags &= ~PTHREAD_FLAGS_IN_MUTEXQ;
-
- /*
- * Only exit the loop if the thread hasn't been
- * cancelled.
- */
- if (pthread->interrupted == 0)
- break;
- }
-
- return(pthread);
-}
-
-/*
- * Remove a waiting thread from a mutex queue in descending priority order.
- */
-static inline void
-mutex_queue_remove(pthread_mutex_t mutex, pthread_t pthread)
-{
- if ((pthread->flags & PTHREAD_FLAGS_IN_MUTEXQ) != 0) {
- TAILQ_REMOVE(&mutex->m_queue, pthread, qe);
- pthread->flags &= ~PTHREAD_FLAGS_IN_MUTEXQ;
- }
-}
-
-/*
- * Enqueue a waiting thread to a queue in descending priority order.
- */
-static inline void
-mutex_queue_enq(pthread_mutex_t mutex, pthread_t pthread)
-{
- pthread_t tid = TAILQ_LAST(&mutex->m_queue, mutex_head);
-
- /*
- * For the common case of all threads having equal priority,
- * we perform a quick check against the priority of the thread
- * at the tail of the queue.
- */
- if ((tid == NULL) || (pthread->active_priority <= tid->active_priority))
- TAILQ_INSERT_TAIL(&mutex->m_queue, pthread, qe);
- else {
- tid = TAILQ_FIRST(&mutex->m_queue);
- while (pthread->active_priority <= tid->active_priority)
- tid = TAILQ_NEXT(tid, qe);
- TAILQ_INSERT_BEFORE(tid, pthread, qe);
- }
- pthread->flags |= PTHREAD_FLAGS_IN_MUTEXQ;
-}
-
-#endif
diff --git a/lib/libkse/thread/thr_mutex_prioceiling.c b/lib/libkse/thread/thr_mutex_prioceiling.c
deleted file mode 100644
index c193c82a9c80..000000000000
--- a/lib/libkse/thread/thr_mutex_prioceiling.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>.
- * 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 Daniel Eischen.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_mutexattr_getprioceiling(pthread_mutexattr_t *mattr, int *prioceiling)
-{
- int ret = 0;
-
- if ((mattr == NULL) || (*mattr == NULL))
- ret = EINVAL;
- else if ((*mattr)->m_protocol != PTHREAD_PRIO_PROTECT)
- ret = EINVAL;
- else
- *prioceiling = (*mattr)->m_ceiling;
-
- return(ret);
-}
-
-int
-pthread_mutexattr_setprioceiling(pthread_mutexattr_t *mattr, int prioceiling)
-{
- int ret = 0;
-
- if ((mattr == NULL) || (*mattr == NULL))
- ret = EINVAL;
- else if ((*mattr)->m_protocol != PTHREAD_PRIO_PROTECT)
- ret = EINVAL;
- else
- (*mattr)->m_ceiling = prioceiling;
-
- return(ret);
-}
-
-int
-pthread_mutex_getprioceiling(pthread_mutex_t *mutex,
- int *prioceiling)
-{
- int ret;
-
- if ((mutex == NULL) || (*mutex == NULL))
- ret = EINVAL;
- else if ((*mutex)->m_protocol != PTHREAD_PRIO_PROTECT)
- ret = EINVAL;
- else
- ret = (*mutex)->m_prio;
-
- return(ret);
-}
-
-int
-pthread_mutex_setprioceiling(pthread_mutex_t *mutex,
- int prioceiling, int *old_ceiling)
-{
- int ret = 0;
-
- if ((mutex == NULL) || (*mutex == NULL))
- ret = EINVAL;
- else if ((*mutex)->m_protocol != PTHREAD_PRIO_PROTECT)
- ret = EINVAL;
- else {
- /* Lock the mutex: */
- if ((ret = pthread_mutex_lock(mutex)) == 0) {
- /* Return the old ceiling and set the new ceiling: */
- *old_ceiling = (*mutex)->m_prio;
- (*mutex)->m_prio = prioceiling;
-
- /* Unlock the mutex: */
- ret = pthread_mutex_unlock(mutex);
- }
- }
- return(ret);
-}
-#endif
diff --git a/lib/libkse/thread/thr_mutex_protocol.c b/lib/libkse/thread/thr_mutex_protocol.c
deleted file mode 100644
index 9847ae529eb8..000000000000
--- a/lib/libkse/thread/thr_mutex_protocol.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>.
- * 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 Daniel Eischen.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_mutexattr_getprotocol(pthread_mutexattr_t *mattr, int *protocol)
-{
- int ret = 0;
-
- if ((mattr == NULL) || (*mattr == NULL))
- ret = EINVAL;
- else
- *protocol = (*mattr)->m_protocol;
-
- return(ret);
-}
-
-int
-pthread_mutexattr_setprotocol(pthread_mutexattr_t *mattr, int protocol)
-{
- int ret = 0;
-
- if ((mattr == NULL) || (*mattr == NULL) ||
- (protocol < PTHREAD_PRIO_NONE) || (protocol > PTHREAD_PRIO_PROTECT))
- ret = EINVAL;
- else {
- (*mattr)->m_protocol = protocol;
- (*mattr)->m_ceiling = PTHREAD_MAX_PRIORITY;
- }
- return(ret);
-}
-
-#endif
diff --git a/lib/libkse/thread/thr_mutexattr_destroy.c b/lib/libkse/thread/thr_mutexattr_destroy.c
deleted file mode 100644
index 6eed2a256019..000000000000
--- a/lib/libkse/thread/thr_mutexattr_destroy.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <stdlib.h>
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_mutexattr_destroy(pthread_mutexattr_t *attr)
-{
- int ret;
- if (attr == NULL || *attr == NULL) {
- ret = EINVAL;
- } else {
- free(*attr);
- *attr = NULL;
- ret = 0;
- }
- return(ret);
-}
-#endif
diff --git a/lib/libkse/thread/thr_nanosleep.c b/lib/libkse/thread/thr_nanosleep.c
deleted file mode 100644
index 3bbc9a64fce6..000000000000
--- a/lib/libkse/thread/thr_nanosleep.c
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <stdio.h>
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-_nanosleep(const struct timespec * time_to_sleep,
- struct timespec * time_remaining)
-{
- int ret = 0;
- struct timespec current_time;
- struct timespec current_time1;
- struct timespec remaining_time;
- struct timeval tv;
-
- /* Check if the time to sleep is legal: */
- if (time_to_sleep == NULL || time_to_sleep->tv_sec < 0 ||
- time_to_sleep->tv_nsec < 0 || time_to_sleep->tv_nsec >= 1000000000) {
- /* Return an EINVAL error : */
- errno = EINVAL;
- ret = -1;
- } else {
- /* Get the current time: */
- gettimeofday(&tv, NULL);
- TIMEVAL_TO_TIMESPEC(&tv, &current_time);
-
- /* Calculate the time for the current thread to wake up: */
- _thread_run->wakeup_time.tv_sec = current_time.tv_sec + time_to_sleep->tv_sec;
- _thread_run->wakeup_time.tv_nsec = current_time.tv_nsec + time_to_sleep->tv_nsec;
-
- /* Check if the nanosecond field has overflowed: */
- if (_thread_run->wakeup_time.tv_nsec >= 1000000000) {
- /* Wrap the nanosecond field: */
- _thread_run->wakeup_time.tv_sec += 1;
- _thread_run->wakeup_time.tv_nsec -= 1000000000;
- }
- _thread_run->interrupted = 0;
-
- /* Reschedule the current thread to sleep: */
- _thread_kern_sched_state(PS_SLEEP_WAIT, __FILE__, __LINE__);
-
- /* Get the current time: */
- gettimeofday(&tv, NULL);
- TIMEVAL_TO_TIMESPEC(&tv, &current_time1);
-
- /* Calculate the remaining time to sleep: */
- remaining_time.tv_sec = time_to_sleep->tv_sec + current_time.tv_sec - current_time1.tv_sec;
- remaining_time.tv_nsec = time_to_sleep->tv_nsec + current_time.tv_nsec - current_time1.tv_nsec;
-
- /* Check if the nanosecond field has underflowed: */
- if (remaining_time.tv_nsec < 0) {
- /* Handle the underflow: */
- remaining_time.tv_sec -= 1;
- remaining_time.tv_nsec += 1000000000;
- }
-
- /* Check if the nanosecond field has overflowed: */
- if (remaining_time.tv_nsec >= 1000000000) {
- /* Handle the overflow: */
- remaining_time.tv_sec += 1;
- remaining_time.tv_nsec -= 1000000000;
- }
-
- /* Check if the sleep was longer than the required time: */
- if (remaining_time.tv_sec < 0) {
- /* Reset the time left: */
- remaining_time.tv_sec = 0;
- remaining_time.tv_nsec = 0;
- }
-
- /* Check if the time remaining is to be returned: */
- if (time_remaining != NULL) {
- /* Return the actual time slept: */
- time_remaining->tv_sec = remaining_time.tv_sec;
- time_remaining->tv_nsec = remaining_time.tv_nsec;
- }
-
- /* Check if the sleep was interrupted: */
- if (_thread_run->interrupted) {
- /* Return an EINTR error : */
- errno = EINTR;
- ret = -1;
- }
- }
- return (ret);
-}
-
-int
-nanosleep(const struct timespec * time_to_sleep, struct timespec *
- time_remaining)
-{
- int ret;
-
- _thread_enter_cancellation_point();
- ret = _nanosleep(time_to_sleep, time_remaining);
- _thread_leave_cancellation_point();
-
- return ret;
-}
-#endif
diff --git a/lib/libkse/thread/thr_once.c b/lib/libkse/thread/thr_once.c
deleted file mode 100644
index ea56d82c4d83..000000000000
--- a/lib/libkse/thread/thr_once.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_once(pthread_once_t * once_control, void (*init_routine) (void))
-{
- if (once_control->state == PTHREAD_NEEDS_INIT) {
- pthread_mutex_lock(&(once_control->mutex));
- if (once_control->state == PTHREAD_NEEDS_INIT) {
- init_routine();
- once_control->state = PTHREAD_DONE_INIT;
- }
- pthread_mutex_unlock(&(once_control->mutex));
- }
- return (0);
-}
-#endif
diff --git a/lib/libkse/thread/thr_open.c b/lib/libkse/thread/thr_open.c
deleted file mode 100644
index e7fef91f8e5d..000000000000
--- a/lib/libkse/thread/thr_open.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- *
- */
-#include <stdarg.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <dirent.h>
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-_open(const char *path, int flags,...)
-{
- int fd;
- int mode = 0;
- va_list ap;
-
- /* Check if the file is being created: */
- if (flags & O_CREAT) {
- /* Get the creation mode: */
- va_start(ap, flags);
- mode = va_arg(ap, int);
- va_end(ap);
- }
- /* Open the file: */
- if ((fd = _thread_sys_open(path, flags, mode)) < 0) {
- }
- /* Initialise the file descriptor table entry: */
- else if (_thread_fd_table_init(fd) != 0) {
- /* Quietly close the file: */
- _thread_sys_close(fd);
-
- /* Reset the file descriptor: */
- fd = -1;
- }
-
- /* Return the file descriptor or -1 on error: */
- return (fd);
-}
-
-int
-open(const char *path, int flags,...)
-{
- int ret;
- int mode = 0;
- va_list ap;
-
- _thread_enter_cancellation_point();
-
- /* Check if the file is being created: */
- if (flags & O_CREAT) {
- /* Get the creation mode: */
- va_start(ap, flags);
- mode = va_arg(ap, int);
- va_end(ap);
- }
-
- ret = _open(path, flags, mode);
- _thread_leave_cancellation_point();
-
- return ret;
-}
-#endif
diff --git a/lib/libkse/thread/thr_pause.c b/lib/libkse/thread/thr_pause.c
deleted file mode 100644
index a841556dc895..000000000000
--- a/lib/libkse/thread/thr_pause.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2000 Jason Evans <jasone@canonware.com>.
- * 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(s), this list of conditions and the following disclaimer as
- * the first lines of this file unmodified other than the possible
- * addition of one or more copyright notices.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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.
- *
- * $FreeBSD$
- */
-
-#include <unistd.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pause(void)
-{
- int ret;
-
- _thread_enter_cancellation_point();
- ret = __pause();
- _thread_leave_cancellation_point();
-
- return ret;
-}
-#endif
diff --git a/lib/libkse/thread/thr_poll.c b/lib/libkse/thread/thr_poll.c
deleted file mode 100644
index 3717273da084..000000000000
--- a/lib/libkse/thread/thr_poll.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (c) 1999 Daniel Eischen <eischen@vigrid.com>
- * 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 Daniel Eischen.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <unistd.h>
-#include <errno.h>
-#include <string.h>
-#include <poll.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/fcntl.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-
-int
-_poll(struct pollfd *fds, unsigned int nfds, int timeout)
-{
- struct timespec ts;
- int numfds = nfds;
- int i, ret = 0;
- struct pthread_poll_data data;
-
- if (numfds > _thread_dtablesize) {
- numfds = _thread_dtablesize;
- }
- /* Check if a timeout was specified: */
- if (timeout == INFTIM) {
- /* Wait for ever: */
- _thread_kern_set_timeout(NULL);
- } else if (timeout > 0) {
- /* Convert the timeout in msec to a timespec: */
- ts.tv_sec = timeout / 1000;
- ts.tv_nsec = (timeout % 1000) * 1000000;
-
- /* Set the wake up time: */
- _thread_kern_set_timeout(&ts);
- } else if (timeout < 0) {
- /* a timeout less than zero but not == INFTIM is invalid */
- errno = EINVAL;
- return (-1);
- }
-
- if (((ret = _thread_sys_poll(fds, numfds, 0)) == 0) && (timeout != 0)) {
- data.nfds = numfds;
- data.fds = fds;
-
- /*
- * Clear revents in case of a timeout which leaves fds
- * unchanged:
- */
- for (i = 0; i < numfds; i++) {
- fds[i].revents = 0;
- }
-
- _thread_run->data.poll_data = &data;
- _thread_run->interrupted = 0;
- _thread_kern_sched_state(PS_POLL_WAIT, __FILE__, __LINE__);
- if (_thread_run->interrupted) {
- errno = EINTR;
- ret = -1;
- } else {
- ret = data.nfds;
- }
- }
-
- return (ret);
-}
-
-__strong_reference(_poll, poll);
-#endif
diff --git a/lib/libkse/thread/thr_priority_queue.c b/lib/libkse/thread/thr_priority_queue.c
deleted file mode 100644
index 1b9fcba09573..000000000000
--- a/lib/libkse/thread/thr_priority_queue.c
+++ /dev/null
@@ -1,335 +0,0 @@
-/*
- * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>.
- * 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 Daniel Eischen.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <stdlib.h>
-#include <sys/queue.h>
-#include <string.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-/* Prototypes: */
-static void pq_insert_prio_list(pq_queue_t *pq, int prio);
-
-#if defined(_PTHREADS_INVARIANTS)
-
-static int _pq_active = 0;
-
-#define _PQ_IN_SCHEDQ (PTHREAD_FLAGS_IN_PRIOQ | PTHREAD_FLAGS_IN_WAITQ | PTHREAD_FLAGS_IN_WORKQ)
-
-#define _PQ_SET_ACTIVE() _pq_active = 1
-#define _PQ_CLEAR_ACTIVE() _pq_active = 0
-#define _PQ_ASSERT_ACTIVE(msg) do { \
- if (_pq_active == 0) \
- PANIC(msg); \
-} while (0)
-#define _PQ_ASSERT_INACTIVE(msg) do { \
- if (_pq_active != 0) \
- PANIC(msg); \
-} while (0)
-#define _PQ_ASSERT_IN_WAITQ(thrd, msg) do { \
- if (((thrd)->flags & PTHREAD_FLAGS_IN_WAITQ) == 0) \
- PANIC(msg); \
-} while (0)
-#define _PQ_ASSERT_IN_PRIOQ(thrd, msg) do { \
- if (((thrd)->flags & PTHREAD_FLAGS_IN_PRIOQ) == 0) \
- PANIC(msg); \
-} while (0)
-#define _PQ_ASSERT_NOT_QUEUED(thrd, msg) do { \
- if ((thrd)->flags & _PQ_IN_SCHEDQ) \
- PANIC(msg); \
-} while (0)
-
-#else
-
-#define _PQ_SET_ACTIVE()
-#define _PQ_CLEAR_ACTIVE()
-#define _PQ_ASSERT_ACTIVE(msg)
-#define _PQ_ASSERT_INACTIVE(msg)
-#define _PQ_ASSERT_IN_WAITQ(thrd, msg)
-#define _PQ_ASSERT_IN_PRIOQ(thrd, msg)
-#define _PQ_ASSERT_NOT_QUEUED(thrd, msg)
-#define _PQ_CHECK_PRIO()
-
-#endif
-
-
-int
-_pq_alloc(pq_queue_t *pq, int minprio, int maxprio)
-{
- int ret = 0;
- int prioslots = maxprio - minprio + 1;
-
- if (pq == NULL)
- ret = -1;
-
- /* Create the priority queue with (maxprio - minprio + 1) slots: */
- else if ((pq->pq_lists =
- (pq_list_t *) malloc(sizeof(pq_list_t) * prioslots)) == NULL)
- ret = -1;
-
- else {
- /* Remember the queue size: */
- pq->pq_size = prioslots;
-
- ret = _pq_init(pq);
-
- }
- return (ret);
-}
-
-int
-_pq_init(pq_queue_t *pq)
-{
- int i, ret = 0;
-
- if ((pq == NULL) || (pq->pq_lists == NULL))
- ret = -1;
-
- else {
- /* Initialize the queue for each priority slot: */
- for (i = 0; i < pq->pq_size; i++) {
- TAILQ_INIT(&pq->pq_lists[i].pl_head);
- pq->pq_lists[i].pl_prio = i;
- pq->pq_lists[i].pl_queued = 0;
- }
-
- /* Initialize the priority queue: */
- TAILQ_INIT(&pq->pq_queue);
- _PQ_CLEAR_ACTIVE();
- }
- return (ret);
-}
-
-void
-_pq_remove(pq_queue_t *pq, pthread_t pthread)
-{
- int prio = pthread->active_priority;
-
- /*
- * Make some assertions when debugging is enabled:
- */
- _PQ_ASSERT_INACTIVE("_pq_remove: pq_active");
- _PQ_SET_ACTIVE();
- _PQ_ASSERT_IN_PRIOQ(pthread, "_pq_remove: Not in priority queue");
-
- /*
- * Remove this thread from priority list. Note that if
- * the priority list becomes empty, it is not removed
- * from the priority queue because another thread may be
- * added to the priority list (resulting in a needless
- * removal/insertion). Priority lists are only removed
- * from the priority queue when _pq_first is called.
- */
- TAILQ_REMOVE(&pq->pq_lists[prio].pl_head, pthread, pqe);
-
- /* This thread is now longer in the priority queue. */
- pthread->flags &= ~PTHREAD_FLAGS_IN_PRIOQ;
-
- _PQ_CLEAR_ACTIVE();
-}
-
-
-void
-_pq_insert_head(pq_queue_t *pq, pthread_t pthread)
-{
- int prio = pthread->active_priority;
-
- /*
- * Make some assertions when debugging is enabled:
- */
- _PQ_ASSERT_INACTIVE("_pq_insert_head: pq_active");
- _PQ_SET_ACTIVE();
- _PQ_ASSERT_NOT_QUEUED(pthread,
- "_pq_insert_head: Already in priority queue");
-
- TAILQ_INSERT_HEAD(&pq->pq_lists[prio].pl_head, pthread, pqe);
- if (pq->pq_lists[prio].pl_queued == 0)
- /* Insert the list into the priority queue: */
- pq_insert_prio_list(pq, prio);
-
- /* Mark this thread as being in the priority queue. */
- pthread->flags |= PTHREAD_FLAGS_IN_PRIOQ;
-
- _PQ_CLEAR_ACTIVE();
-}
-
-
-void
-_pq_insert_tail(pq_queue_t *pq, pthread_t pthread)
-{
- int prio = pthread->active_priority;
-
- /*
- * Make some assertions when debugging is enabled:
- */
- _PQ_ASSERT_INACTIVE("_pq_insert_tail: pq_active");
- _PQ_SET_ACTIVE();
- _PQ_ASSERT_NOT_QUEUED(pthread,
- "_pq_insert_tail: Already in priority queue");
-
- TAILQ_INSERT_TAIL(&pq->pq_lists[prio].pl_head, pthread, pqe);
- if (pq->pq_lists[prio].pl_queued == 0)
- /* Insert the list into the priority queue: */
- pq_insert_prio_list(pq, prio);
-
- /* Mark this thread as being in the priority queue. */
- pthread->flags |= PTHREAD_FLAGS_IN_PRIOQ;
-
- _PQ_CLEAR_ACTIVE();
-}
-
-
-pthread_t
-_pq_first(pq_queue_t *pq)
-{
- pq_list_t *pql;
- pthread_t pthread = NULL;
-
- /*
- * Make some assertions when debugging is enabled:
- */
- _PQ_ASSERT_INACTIVE("_pq_first: pq_active");
- _PQ_SET_ACTIVE();
-
- while (((pql = TAILQ_FIRST(&pq->pq_queue)) != NULL) &&
- (pthread == NULL)) {
- if ((pthread = TAILQ_FIRST(&pql->pl_head)) == NULL) {
- /*
- * The priority list is empty; remove the list
- * from the queue.
- */
- TAILQ_REMOVE(&pq->pq_queue, pql, pl_link);
-
- /* Mark the list as not being in the queue: */
- pql->pl_queued = 0;
- }
- }
-
- _PQ_CLEAR_ACTIVE();
- return (pthread);
-}
-
-
-static void
-pq_insert_prio_list(pq_queue_t *pq, int prio)
-{
- pq_list_t *pql;
-
- /*
- * Make some assertions when debugging is enabled:
- */
- _PQ_ASSERT_ACTIVE("pq_insert_prio_list: pq_active");
-
- /*
- * The priority queue is in descending priority order. Start at
- * the beginning of the queue and find the list before which the
- * new list should be inserted.
- */
- pql = TAILQ_FIRST(&pq->pq_queue);
- while ((pql != NULL) && (pql->pl_prio > prio))
- pql = TAILQ_NEXT(pql, pl_link);
-
- /* Insert the list: */
- if (pql == NULL)
- TAILQ_INSERT_TAIL(&pq->pq_queue, &pq->pq_lists[prio], pl_link);
- else
- TAILQ_INSERT_BEFORE(pql, &pq->pq_lists[prio], pl_link);
-
- /* Mark this list as being in the queue: */
- pq->pq_lists[prio].pl_queued = 1;
-}
-
-#if defined(_PTHREADS_INVARIANTS)
-void
-_waitq_insert(pthread_t pthread)
-{
- pthread_t tid;
-
- /*
- * Make some assertions when debugging is enabled:
- */
- _PQ_ASSERT_INACTIVE("_waitq_insert: pq_active");
- _PQ_SET_ACTIVE();
- _PQ_ASSERT_NOT_QUEUED(pthread, "_waitq_insert: Already in queue");
-
- if (pthread->wakeup_time.tv_sec == -1)
- TAILQ_INSERT_TAIL(&_waitingq, pthread, pqe);
- else {
- tid = TAILQ_FIRST(&_waitingq);
- while ((tid != NULL) && (tid->wakeup_time.tv_sec != -1) &&
- ((tid->wakeup_time.tv_sec < pthread->wakeup_time.tv_sec) ||
- ((tid->wakeup_time.tv_sec == pthread->wakeup_time.tv_sec) &&
- (tid->wakeup_time.tv_nsec <= pthread->wakeup_time.tv_nsec))))
- tid = TAILQ_NEXT(tid, pqe);
- if (tid == NULL)
- TAILQ_INSERT_TAIL(&_waitingq, pthread, pqe);
- else
- TAILQ_INSERT_BEFORE(tid, pthread, pqe);
- }
- pthread->flags |= PTHREAD_FLAGS_IN_WAITQ;
-
- _PQ_CLEAR_ACTIVE();
-}
-
-void
-_waitq_remove(pthread_t pthread)
-{
- /*
- * Make some assertions when debugging is enabled:
- */
- _PQ_ASSERT_INACTIVE("_waitq_remove: pq_active");
- _PQ_SET_ACTIVE();
- _PQ_ASSERT_IN_WAITQ(pthread, "_waitq_remove: Not in queue");
-
- TAILQ_REMOVE(&_waitingq, pthread, pqe);
- pthread->flags &= ~PTHREAD_FLAGS_IN_WAITQ;
-
- _PQ_CLEAR_ACTIVE();
-}
-
-void
-_waitq_setactive(void)
-{
- _PQ_ASSERT_INACTIVE("_waitq_setactive: pq_active");
- _PQ_SET_ACTIVE();
-}
-
-void
-_waitq_clearactive(void)
-{
- _PQ_ASSERT_ACTIVE("_waitq_clearactive: ! pq_active");
- _PQ_CLEAR_ACTIVE();
-}
-#endif
-#endif
diff --git a/lib/libkse/thread/thr_private.h b/lib/libkse/thread/thr_private.h
deleted file mode 100644
index 962eb86957af..000000000000
--- a/lib/libkse/thread/thr_private.h
+++ /dev/null
@@ -1,1254 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * Private thread definitions for the uthread kernel.
- *
- * $FreeBSD$
- */
-
-#ifndef _PTHREAD_PRIVATE_H
-#define _PTHREAD_PRIVATE_H
-
-/*
- * Evaluate the storage class specifier.
- */
-#ifdef GLOBAL_PTHREAD_PRIVATE
-#define SCLASS
-#else
-#define SCLASS extern
-#endif
-
-/*
- * Include files.
- */
-#include <setjmp.h>
-#include <signal.h>
-#include <sys/queue.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sched.h>
-#include <spinlock.h>
-#include <pthread_np.h>
-
-/*
- * Kernel fatal error handler macro.
- */
-#define PANIC(string) _thread_exit(__FILE__,__LINE__,string)
-
-/* Output debug messages like this: */
-#define stdout_debug(_x) _thread_sys_write(1,_x,strlen(_x));
-#define stderr_debug(_x) _thread_sys_write(2,_x,strlen(_x));
-
-
-/*
- * Priority queue manipulation macros (using pqe link):
- */
-#define PTHREAD_PRIOQ_INSERT_HEAD(thrd) _pq_insert_head(&_readyq,thrd)
-#define PTHREAD_PRIOQ_INSERT_TAIL(thrd) _pq_insert_tail(&_readyq,thrd)
-#define PTHREAD_PRIOQ_REMOVE(thrd) _pq_remove(&_readyq,thrd)
-#define PTHREAD_PRIOQ_FIRST() _pq_first(&_readyq)
-
-/*
- * Waiting queue manipulation macros (using pqe link):
- */
-#if defined(_PTHREADS_INVARIANTS)
-#define PTHREAD_WAITQ_REMOVE(thrd) _waitq_remove(thrd)
-#define PTHREAD_WAITQ_INSERT(thrd) _waitq_insert(thrd)
-#define PTHREAD_WAITQ_CLEARACTIVE() _waitq_clearactive()
-#define PTHREAD_WAITQ_SETACTIVE() _waitq_setactive()
-#else
-#define PTHREAD_WAITQ_REMOVE(thrd) do { \
- TAILQ_REMOVE(&_waitingq,thrd,pqe); \
- (thrd)->flags &= ~PTHREAD_FLAGS_IN_WAITQ; \
-} while (0)
-
-#define PTHREAD_WAITQ_INSERT(thrd) do { \
- if ((thrd)->wakeup_time.tv_sec == -1) \
- TAILQ_INSERT_TAIL(&_waitingq,thrd,pqe); \
- else { \
- pthread_t tid = TAILQ_FIRST(&_waitingq); \
- while ((tid != NULL) && (tid->wakeup_time.tv_sec != -1) && \
- ((tid->wakeup_time.tv_sec < (thrd)->wakeup_time.tv_sec) || \
- ((tid->wakeup_time.tv_sec == (thrd)->wakeup_time.tv_sec) && \
- (tid->wakeup_time.tv_nsec <= (thrd)->wakeup_time.tv_nsec)))) \
- tid = TAILQ_NEXT(tid, pqe); \
- if (tid == NULL) \
- TAILQ_INSERT_TAIL(&_waitingq,thrd,pqe); \
- else \
- TAILQ_INSERT_BEFORE(tid,thrd,pqe); \
- } \
- (thrd)->flags | PTHREAD_FLAGS_IN_WAITQ; \
-} while (0)
-#define PTHREAD_WAITQ_CLEARACTIVE()
-#define PTHREAD_WAITQ_SETACTIVE()
-#endif
-
-/*
- * Work queue manipulation macros (using qe link):
- */
-#define PTHREAD_WORKQ_INSERT(thrd) do { \
- TAILQ_INSERT_TAIL(&_workq,thrd,qe); \
- (thrd)->flags |= PTHREAD_FLAGS_IN_WORKQ; \
-} while (0)
-#define PTHREAD_WORKQ_REMOVE(thrd) do { \
- TAILQ_REMOVE(&_workq,thrd,qe); \
- (thrd)->flags &= ~PTHREAD_FLAGS_IN_WORKQ; \
-} while (0)
-
-
-/*
- * State change macro without scheduling queue change:
- */
-#define PTHREAD_SET_STATE(thrd, newstate) do { \
- (thrd)->state = newstate; \
- (thrd)->fname = __FILE__; \
- (thrd)->lineno = __LINE__; \
-} while (0)
-
-/*
- * State change macro with scheduling queue change - This must be
- * called with preemption deferred (see thread_kern_sched_[un]defer).
- */
-#if defined(_PTHREADS_INVARIANTS)
-#define PTHREAD_NEW_STATE(thrd, newstate) do { \
- if (_thread_kern_new_state != 0) \
- PANIC("Recursive PTHREAD_NEW_STATE"); \
- _thread_kern_new_state = 1; \
- if ((thrd)->state != newstate) { \
- if ((thrd)->state == PS_RUNNING) { \
- PTHREAD_PRIOQ_REMOVE(thrd); \
- PTHREAD_WAITQ_INSERT(thrd); \
- } else if (newstate == PS_RUNNING) { \
- PTHREAD_WAITQ_REMOVE(thrd); \
- PTHREAD_PRIOQ_INSERT_TAIL(thrd); \
- } \
- } \
- _thread_kern_new_state = 0; \
- PTHREAD_SET_STATE(thrd, newstate); \
-} while (0)
-#else
-#define PTHREAD_NEW_STATE(thrd, newstate) do { \
- if ((thrd)->state != newstate) { \
- if ((thrd)->state == PS_RUNNING) { \
- PTHREAD_PRIOQ_REMOVE(thrd); \
- PTHREAD_WAITQ_INSERT(thrd); \
- } else if (newstate == PS_RUNNING) { \
- PTHREAD_WAITQ_REMOVE(thrd); \
- PTHREAD_PRIOQ_INSERT_TAIL(thrd); \
- } \
- } \
- PTHREAD_SET_STATE(thrd, newstate); \
-} while (0)
-#endif
-
-/*
- * Define the signals to be used for scheduling.
- */
-#if defined(_PTHREADS_COMPAT_SCHED)
-#define _ITIMER_SCHED_TIMER ITIMER_VIRTUAL
-#define _SCHED_SIGNAL SIGVTALRM
-#else
-#define _ITIMER_SCHED_TIMER ITIMER_PROF
-#define _SCHED_SIGNAL SIGPROF
-#endif
-
-/*
- * Priority queues.
- *
- * XXX It'd be nice if these were contained in uthread_priority_queue.[ch].
- */
-typedef struct pq_list {
- TAILQ_HEAD(, pthread) pl_head; /* list of threads at this priority */
- TAILQ_ENTRY(pq_list) pl_link; /* link for queue of priority lists */
- int pl_prio; /* the priority of this list */
- int pl_queued; /* is this in the priority queue */
-} pq_list_t;
-
-typedef struct pq_queue {
- TAILQ_HEAD(, pq_list) pq_queue; /* queue of priority lists */
- pq_list_t *pq_lists; /* array of all priority lists */
- int pq_size; /* number of priority lists */
-} pq_queue_t;
-
-
-/*
- * TailQ initialization values.
- */
-#define TAILQ_INITIALIZER { NULL, NULL }
-
-/*
- * Mutex definitions.
- */
-union pthread_mutex_data {
- void *m_ptr;
- int m_count;
-};
-
-struct pthread_mutex {
- enum pthread_mutextype m_type;
- int m_protocol;
- TAILQ_HEAD(mutex_head, pthread) m_queue;
- struct pthread *m_owner;
- union pthread_mutex_data m_data;
- long m_flags;
- int m_refcount;
-
- /*
- * Used for priority inheritence and protection.
- *
- * m_prio - For priority inheritence, the highest active
- * priority (threads locking the mutex inherit
- * this priority). For priority protection, the
- * ceiling priority of this mutex.
- * m_saved_prio - mutex owners inherited priority before
- * taking the mutex, restored when the owner
- * unlocks the mutex.
- */
- int m_prio;
- int m_saved_prio;
-
- /*
- * Link for list of all mutexes a thread currently owns.
- */
- TAILQ_ENTRY(pthread_mutex) m_qe;
-
- /*
- * Lock for accesses to this structure.
- */
- spinlock_t lock;
-};
-
-/*
- * Flags for mutexes.
- */
-#define MUTEX_FLAGS_PRIVATE 0x01
-#define MUTEX_FLAGS_INITED 0x02
-#define MUTEX_FLAGS_BUSY 0x04
-
-/*
- * Static mutex initialization values.
- */
-#define PTHREAD_MUTEX_STATIC_INITIALIZER \
- { PTHREAD_MUTEX_DEFAULT, PTHREAD_PRIO_NONE, TAILQ_INITIALIZER, \
- NULL, { NULL }, MUTEX_FLAGS_PRIVATE, 0, 0, 0, TAILQ_INITIALIZER, \
- _SPINLOCK_INITIALIZER }
-
-struct pthread_mutex_attr {
- enum pthread_mutextype m_type;
- int m_protocol;
- int m_ceiling;
- long m_flags;
-};
-
-/*
- * Condition variable definitions.
- */
-enum pthread_cond_type {
- COND_TYPE_FAST,
- COND_TYPE_MAX
-};
-
-struct pthread_cond {
- enum pthread_cond_type c_type;
- TAILQ_HEAD(cond_head, pthread) c_queue;
- pthread_mutex_t c_mutex;
- void *c_data;
- long c_flags;
-
- /*
- * Lock for accesses to this structure.
- */
- spinlock_t lock;
-};
-
-struct pthread_cond_attr {
- enum pthread_cond_type c_type;
- long c_flags;
-};
-
-/*
- * Flags for condition variables.
- */
-#define COND_FLAGS_PRIVATE 0x01
-#define COND_FLAGS_INITED 0x02
-#define COND_FLAGS_BUSY 0x04
-
-/*
- * Static cond initialization values.
- */
-#define PTHREAD_COND_STATIC_INITIALIZER \
- { COND_TYPE_FAST, TAILQ_INITIALIZER, NULL, NULL, \
- 0, _SPINLOCK_INITIALIZER }
-
-/*
- * Semaphore definitions.
- */
-struct sem {
-#define SEM_MAGIC ((u_int32_t) 0x09fa4012)
- u_int32_t magic;
- pthread_mutex_t lock;
- pthread_cond_t gtzero;
- u_int32_t count;
- u_int32_t nwaiters;
-};
-
-/*
- * Cleanup definitions.
- */
-struct pthread_cleanup {
- struct pthread_cleanup *next;
- void (*routine) ();
- void *routine_arg;
-};
-
-struct pthread_attr {
- int sched_policy;
- int sched_inherit;
- int sched_interval;
- int prio;
- int suspend;
- int flags;
- void *arg_attr;
- void (*cleanup_attr) ();
- void *stackaddr_attr;
- size_t stacksize_attr;
-};
-
-/*
- * Thread creation state attributes.
- */
-#define PTHREAD_CREATE_RUNNING 0
-#define PTHREAD_CREATE_SUSPENDED 1
-
-/*
- * Miscellaneous definitions.
- */
-#define PTHREAD_STACK_DEFAULT 65536
-/*
- * Size of red zone at the end of each stack. In actuality, this "red zone" is
- * merely an unmapped region, except in the case of the initial stack. Since
- * mmap() makes it possible to specify the maximum growth of a MAP_STACK region,
- * an unmapped gap between thread stacks achieves the same effect as explicitly
- * mapped red zones.
- */
-#define PTHREAD_STACK_GUARD PAGE_SIZE
-
-/*
- * Maximum size of initial thread's stack. This perhaps deserves to be larger
- * than the stacks of other threads, since many applications are likely to run
- * almost entirely on this stack.
- */
-#define PTHREAD_STACK_INITIAL 0x100000
-/* Address immediately beyond the beginning of the initial thread stack. */
-#define PTHREAD_DEFAULT_PRIORITY 64
-#define PTHREAD_MAX_PRIORITY 126
-#define PTHREAD_MIN_PRIORITY 0
-#define _POSIX_THREAD_ATTR_STACKSIZE
-
-/*
- * Clock resolution in nanoseconds.
- */
-#define CLOCK_RES_NSEC 10000000
-
-/*
- * Time slice period in microseconds.
- */
-#define TIMESLICE_USEC 100000
-
-struct pthread_key {
- spinlock_t lock;
- volatile int allocated;
- volatile int count;
- void (*destructor) ();
-};
-
-struct pthread_rwlockattr {
- int pshared;
-};
-
-struct pthread_rwlock {
- pthread_mutex_t lock; /* monitor lock */
- int state; /* 0 = idle >0 = # of readers -1 = writer */
- pthread_cond_t read_signal;
- pthread_cond_t write_signal;
- int blocked_writers;
-};
-
-/*
- * Thread states.
- */
-enum pthread_state {
- PS_RUNNING,
- PS_SIGTHREAD,
- PS_MUTEX_WAIT,
- PS_COND_WAIT,
- PS_FDLR_WAIT,
- PS_FDLW_WAIT,
- PS_FDR_WAIT,
- PS_FDW_WAIT,
- PS_FILE_WAIT,
- PS_POLL_WAIT,
- PS_SELECT_WAIT,
- PS_SLEEP_WAIT,
- PS_WAIT_WAIT,
- PS_SIGSUSPEND,
- PS_SIGWAIT,
- PS_SPINBLOCK,
- PS_JOIN,
- PS_SUSPENDED,
- PS_DEAD,
- PS_DEADLOCK,
- PS_STATE_MAX
-};
-
-
-/*
- * File descriptor locking definitions.
- */
-#define FD_READ 0x1
-#define FD_WRITE 0x2
-#define FD_RDWR (FD_READ | FD_WRITE)
-
-/*
- * File descriptor table structure.
- */
-struct fd_table_entry {
- /*
- * Lock for accesses to this file descriptor table
- * entry. This is passed to _spinlock() to provide atomic
- * access to this structure. It does *not* represent the
- * state of the lock on the file descriptor.
- */
- spinlock_t lock;
- TAILQ_HEAD(, pthread) r_queue; /* Read queue. */
- TAILQ_HEAD(, pthread) w_queue; /* Write queue. */
- struct pthread *r_owner; /* Ptr to thread owning read lock. */
- struct pthread *w_owner; /* Ptr to thread owning write lock. */
- char *r_fname; /* Ptr to read lock source file name */
- int r_lineno; /* Read lock source line number. */
- char *w_fname; /* Ptr to write lock source file name */
- int w_lineno; /* Write lock source line number. */
- int r_lockcount; /* Count for FILE read locks. */
- int w_lockcount; /* Count for FILE write locks. */
- int flags; /* Flags used in open. */
-};
-
-struct pthread_poll_data {
- int nfds;
- struct pollfd *fds;
-};
-
-union pthread_wait_data {
- pthread_mutex_t mutex;
- pthread_cond_t cond;
- const sigset_t *sigwait; /* Waiting on a signal in sigwait */
- struct {
- short fd; /* Used when thread waiting on fd */
- short branch; /* Line number, for debugging. */
- char *fname; /* Source file name for debugging.*/
- } fd;
- struct pthread_poll_data * poll_data;
- spinlock_t *spinlock;
-};
-
-/*
- * Define a continuation routine that can be used to perform a
- * transfer of control:
- */
-typedef void (*thread_continuation_t) (void *);
-
-/*
- * Thread structure.
- */
-struct pthread {
- /*
- * Magic value to help recognize a valid thread structure
- * from an invalid one:
- */
-#define PTHREAD_MAGIC ((u_int32_t) 0xd09ba115)
- u_int32_t magic;
- char *name;
- u_int64_t uniqueid; /* for gdb */
-
- /*
- * Lock for accesses to this thread structure.
- */
- spinlock_t lock;
-
- /* Queue entry for list of all threads: */
- TAILQ_ENTRY(pthread) tle;
-
- /* Queue entry for list of dead threads: */
- TAILQ_ENTRY(pthread) dle;
-
- /*
- * Thread start routine, argument, stack pointer and thread
- * attributes.
- */
- void *(*start_routine)(void *);
- void *arg;
- void *stack;
- struct pthread_attr attr;
-
-#if (defined(__FreeBSD__) || defined(__NetBSD__)) && defined(__i386__)
- /*
- * Saved floating point registers on systems where they are not
- * saved in the signal context.
- */
- char saved_fp[108];
-#endif
-
- /*
- * Saved signal context used in call to sigreturn by
- * _thread_kern_sched if sig_saved is TRUE.
- */
- ucontext_t saved_sigcontext;
-
- /*
- * Saved jump buffer used in call to longjmp by _thread_kern_sched
- * if sig_saved is FALSE.
- */
- jmp_buf saved_jmp_buf;
- jmp_buf *sighandler_jmp_buf;
-
- /*
- * Saved jump buffers for use when doing nested [sig|_]longjmp()s, as
- * when doing signal delivery.
- */
- union {
- jmp_buf jmp;
- sigjmp_buf sigjmp;
- } nested_jmp;
- int longjmp_val;
-
-#define JMPFLAGS_NONE 0x00
-#define JMPFLAGS_LONGJMP 0x01
-#define JMPFLAGS__LONGJMP 0x02
-#define JMPFLAGS_SIGLONGJMP 0x04
-#define JMPFLAGS_DEFERRED 0x08
- int jmpflags;
-
- /*
- * TRUE if the last state saved was a signal context. FALSE if the
- * last state saved was a jump buffer.
- */
- int sig_saved;
-
- /*
- * Used for tracking delivery of nested signal handlers.
- */
- int signal_nest_level;
-
- /*
- * Cancelability flags - the lower 2 bits are used by cancel
- * definitions in pthread.h
- */
-#define PTHREAD_AT_CANCEL_POINT 0x0004
-#define PTHREAD_CANCELLING 0x0008
-#define PTHREAD_CANCEL_NEEDED 0x0010
- int cancelflags;
-
- thread_continuation_t continuation;
-
- /*
- * Current signal mask and pending signals.
- */
- sigset_t sigmask;
- sigset_t sigpend;
-
- /* Thread state: */
- enum pthread_state state;
- enum pthread_state oldstate;
-
- /* Time that this thread was last made active. */
- struct timeval last_active;
-
- /* Time that this thread was last made inactive. */
- struct timeval last_inactive;
-
- /*
- * Number of microseconds accumulated by this thread when
- * time slicing is active.
- */
- long slice_usec;
-
- /*
- * Incremental priority accumulated by thread while it is ready to
- * run but is denied being run.
- */
- int inc_prio;
-
- /*
- * Time to wake up thread. This is used for sleeping threads and
- * for any operation which may time out (such as select).
- */
- struct timespec wakeup_time;
-
- /* TRUE if operation has timed out. */
- int timeout;
-
- /*
- * Error variable used instead of errno. The function __error()
- * returns a pointer to this.
- */
- int error;
-
- /* Join queue head and link for waiting threads: */
- TAILQ_HEAD(join_head, pthread) join_queue;
-
- /*
- * The current thread can belong to only one scheduling queue at
- * a time (ready or waiting queue). It can also belong to (only)
- * one of:
- *
- * o A queue of threads waiting for a mutex
- * o A queue of threads waiting for a condition variable
- * o A queue of threads waiting for another thread to terminate
- * (the join queue above)
- * o A queue of threads waiting for a file descriptor lock
- * o A queue of threads needing work done by the kernel thread
- * (waiting for a spinlock or file I/O)
- *
- * Use pqe for the scheduling queue link (both ready and waiting),
- * and qe for other links.
- */
-
- /* Priority queue entry for this thread: */
- TAILQ_ENTRY(pthread) pqe;
-
- /* Queue entry for this thread: */
- TAILQ_ENTRY(pthread) qe;
-
- /* Wait data. */
- union pthread_wait_data data;
-
- /*
- * Allocated for converting select into poll.
- */
- struct pthread_poll_data poll_data;
-
- /*
- * Set to TRUE if a blocking operation was
- * interrupted by a signal:
- */
- int interrupted;
-
- /* Signal number when in state PS_SIGWAIT: */
- int signo;
-
- /*
- * Set to non-zero when this thread has deferred signals.
- * We allow for recursive deferral.
- */
- int sig_defer_count;
-
- /*
- * Set to TRUE if this thread should yield after undeferring
- * signals.
- */
- int yield_on_sig_undefer;
-
- /* Miscellaneous flags; only set with signals deferred. */
- int flags;
-#define PTHREAD_FLAGS_PRIVATE 0x0001
-#define PTHREAD_EXITING 0x0002
-#define PTHREAD_FLAGS_IN_CONDQ 0x0004 /* in condition queue using qe link*/
-#define PTHREAD_FLAGS_IN_WORKQ 0x0008 /* in work queue using qe link */
-#define PTHREAD_FLAGS_IN_WAITQ 0x0010 /* in waiting queue using pqe link */
-#define PTHREAD_FLAGS_IN_PRIOQ 0x0020 /* in priority queue using pqe link */
-#define PTHREAD_FLAGS_IN_MUTEXQ 0x0040 /* in mutex queue using qe link */
-#define PTHREAD_FLAGS_IN_FILEQ 0x0080 /* in file lock queue using qe link */
-#define PTHREAD_FLAGS_IN_FDQ 0x0100 /* in fd lock queue using qe link */
-#define PTHREAD_FLAGS_TRACE 0x0200 /* for debugging purposes */
-
- /*
- * Base priority is the user setable and retrievable priority
- * of the thread. It is only affected by explicit calls to
- * set thread priority and upon thread creation via a thread
- * attribute or default priority.
- */
- char base_priority;
-
- /*
- * Inherited priority is the priority a thread inherits by
- * taking a priority inheritence or protection mutex. It
- * is not affected by base priority changes. Inherited
- * priority defaults to and remains 0 until a mutex is taken
- * that is being waited on by any other thread whose priority
- * is non-zero.
- */
- char inherited_priority;
-
- /*
- * Active priority is always the maximum of the threads base
- * priority and inherited priority. When there is a change
- * in either the base or inherited priority, the active
- * priority must be recalculated.
- */
- char active_priority;
-
- /* Number of priority ceiling or protection mutexes owned. */
- int priority_mutex_count;
-
- /*
- * Queue of currently owned mutexes.
- */
- TAILQ_HEAD(, pthread_mutex) mutexq;
-
- void *ret;
- const void **specific_data;
- int specific_data_count;
-
- /* Cleanup handlers Link List */
- struct pthread_cleanup *cleanup;
- char *fname; /* Ptr to source file name */
- int lineno; /* Source line number. */
-};
-
-/* Spare thread stack. */
-struct stack {
- SLIST_ENTRY(stack) qe; /* Queue entry for this stack. */
-};
-
-/*
- * Global variables for the uthread kernel.
- */
-
-/* Kernel thread structure used when there are no running threads: */
-SCLASS struct pthread _thread_kern_thread;
-
-/* Ptr to the thread structure for the running thread: */
-SCLASS struct pthread * volatile _thread_run
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= &_thread_kern_thread;
-#else
-;
-#endif
-
-/* Ptr to the thread structure for the last user thread to run: */
-SCLASS struct pthread * volatile _last_user_thread
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= &_thread_kern_thread;
-#else
-;
-#endif
-
-/*
- * Ptr to the thread running in single-threaded mode or NULL if
- * running multi-threaded (default POSIX behaviour).
- */
-SCLASS struct pthread * volatile _thread_single
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= NULL;
-#else
-;
-#endif
-
-/* List of all threads: */
-SCLASS TAILQ_HEAD(, pthread) _thread_list
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= TAILQ_HEAD_INITIALIZER(_thread_list);
-#else
-;
-#endif
-
-/*
- * Array of kernel pipe file descriptors that are used to ensure that
- * no signals are missed in calls to _select.
- */
-SCLASS int _thread_kern_pipe[2]
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= {
- -1,
- -1
-};
-#else
-;
-#endif
-SCLASS int volatile _queue_signals
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= 0;
-#else
-;
-#endif
-SCLASS int _thread_kern_in_sched
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= 0;
-#else
-;
-#endif
-
-/* Last time that an incremental priority update was performed: */
-SCLASS struct timeval kern_inc_prio_time
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= { 0, 0 };
-#else
-;
-#endif
-
-/* Dead threads: */
-SCLASS TAILQ_HEAD(, pthread) _dead_list
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= TAILQ_HEAD_INITIALIZER(_dead_list);
-#else
-;
-#endif
-
-/* Initial thread: */
-SCLASS struct pthread *_thread_initial
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= NULL;
-#else
-;
-#endif
-
-/* Default thread attributes: */
-SCLASS struct pthread_attr pthread_attr_default
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= { SCHED_RR, 0, TIMESLICE_USEC, PTHREAD_DEFAULT_PRIORITY, PTHREAD_CREATE_RUNNING,
- PTHREAD_CREATE_JOINABLE, NULL, NULL, NULL, PTHREAD_STACK_DEFAULT };
-#else
-;
-#endif
-
-/* Default mutex attributes: */
-SCLASS struct pthread_mutex_attr pthread_mutexattr_default
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= { PTHREAD_MUTEX_DEFAULT, PTHREAD_PRIO_NONE, 0, 0 };
-#else
-;
-#endif
-
-/* Default condition variable attributes: */
-SCLASS struct pthread_cond_attr pthread_condattr_default
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= { COND_TYPE_FAST, 0 };
-#else
-;
-#endif
-
-/*
- * Standard I/O file descriptors need special flag treatment since
- * setting one to non-blocking does all on *BSD. Sigh. This array
- * is used to store the initial flag settings.
- */
-SCLASS int _pthread_stdio_flags[3];
-
-/* File table information: */
-SCLASS struct fd_table_entry **_thread_fd_table
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= NULL;
-#else
-;
-#endif
-
-/* Table for polling file descriptors: */
-SCLASS struct pollfd *_thread_pfd_table
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= NULL;
-#else
-;
-#endif
-
-SCLASS const int dtablecount
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= 4096/sizeof(struct fd_table_entry);
-#else
-;
-#endif
-SCLASS int _thread_dtablesize /* Descriptor table size. */
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= 0;
-#else
-;
-#endif
-
-SCLASS int _clock_res_nsec /* Clock resolution in nsec. */
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= CLOCK_RES_NSEC;
-#else
-;
-#endif
-
-/* Garbage collector mutex and condition variable. */
-SCLASS pthread_mutex_t _gc_mutex
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= NULL
-#endif
-;
-SCLASS pthread_cond_t _gc_cond
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= NULL
-#endif
-;
-
-/*
- * Array of signal actions for this process.
- */
-SCLASS struct sigaction _thread_sigact[NSIG];
-
-/*
- * Pending signals for this process.
- */
-SCLASS sigset_t _process_sigpending;
-
-/*
- * Scheduling queues:
- */
-SCLASS pq_queue_t _readyq;
-SCLASS TAILQ_HEAD(, pthread) _waitingq;
-
-/*
- * Work queue:
- */
-SCLASS TAILQ_HEAD(, pthread) _workq;
-
-/* Tracks the number of threads blocked while waiting for a spinlock. */
-SCLASS volatile int _spinblock_count
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= 0
-#endif
-;
-
-/* Indicates that the signal queue needs to be checked. */
-SCLASS volatile int _sigq_check_reqd
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= 0
-#endif
-;
-
-/* Thread switch hook. */
-SCLASS pthread_switch_routine_t _sched_switch_hook
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= NULL
-#endif
-;
-
-/*
- * Spare stack queue. Stacks of default size are cached in order to reduce
- * thread creation time. Spare stacks are used in LIFO order to increase cache
- * locality.
- */
-SCLASS SLIST_HEAD(, stack) _stackq;
-
-/*
- * Base address of next unallocated default-size {stack, red zone}. Stacks are
- * allocated contiguously, starting below the bottom of the main stack. When a
- * new stack is created, a red zone is created (actually, the red zone is simply
- * left unmapped) below the bottom of the stack, such that the stack will not be
- * able to grow all the way to the top of the next stack. This isn't
- * fool-proof. It is possible for a stack to grow by a large amount, such that
- * it grows into the next stack, and as long as the memory within the red zone
- * is never accessed, nothing will prevent one thread stack from trouncing all
- * over the next.
- */
-SCLASS void * _next_stack
-#ifdef GLOBAL_PTHREAD_PRIVATE
-/* main stack top - main stack size - stack size - (red zone + main stack red zone) */
-= (void *) USRSTACK - PTHREAD_STACK_INITIAL - PTHREAD_STACK_DEFAULT - (2 * PTHREAD_STACK_GUARD)
-#endif
-;
-
-/* Used for _PTHREADS_INVARIANTS checking. */
-SCLASS int _thread_kern_new_state
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= 0
-#endif
-;
-
-/* Undefine the storage class specifier: */
-#undef SCLASS
-
-#ifdef _LOCK_DEBUG
-#define _FD_LOCK(_fd,_type,_ts) _thread_fd_lock_debug(_fd, _type, \
- _ts, __FILE__, __LINE__)
-#define _FD_UNLOCK(_fd,_type) _thread_fd_unlock_debug(_fd, _type, \
- __FILE__, __LINE__)
-#else
-#define _FD_LOCK(_fd,_type,_ts) _thread_fd_lock(_fd, _type, _ts)
-#define _FD_UNLOCK(_fd,_type) _thread_fd_unlock(_fd, _type)
-#endif
-
-/*
- * Function prototype definitions.
- */
-__BEGIN_DECLS
-char *__ttyname_basic(int);
-char *__ttyname_r_basic(int, char *, size_t);
-char *ttyname_r(int, char *, size_t);
-int _find_dead_thread(pthread_t);
-int _find_thread(pthread_t);
-void _funlock_owned(pthread_t);
-int _thread_create(pthread_t *,const pthread_attr_t *,void *(*start_routine)(void *),void *,pthread_t);
-int _thread_fd_lock(int, int, struct timespec *);
-int _thread_fd_lock_debug(int, int, struct timespec *,char *fname,int lineno);
-void _dispatch_signals(void);
-int _mutex_cv_lock(pthread_mutex_t *);
-int _mutex_cv_unlock(pthread_mutex_t *);
-void _mutex_notify_priochange(pthread_t);
-int _mutex_reinit(pthread_mutex_t *);
-void _mutex_unlock_private(pthread_t);
-int _cond_reinit(pthread_cond_t *);
-int _pq_alloc(struct pq_queue *, int, int);
-int _pq_init(struct pq_queue *);
-void _pq_remove(struct pq_queue *pq, struct pthread *);
-void _pq_insert_head(struct pq_queue *pq, struct pthread *);
-void _pq_insert_tail(struct pq_queue *pq, struct pthread *);
-struct pthread *_pq_first(struct pq_queue *pq);
-#if defined(_PTHREADS_INVARIANTS)
-void _waitq_insert(pthread_t pthread);
-void _waitq_remove(pthread_t pthread);
-void _waitq_setactive(void);
-void _waitq_clearactive(void);
-#endif
-void _thread_exit(char *, int, char *);
-void _thread_exit_cleanup(void);
-void _thread_fd_unlock(int, int);
-void _thread_fd_unlock_debug(int, int, char *, int);
-void _thread_fd_unlock_owned(pthread_t);
-void *_thread_cleanup(pthread_t);
-void _thread_cleanupspecific(void);
-void _thread_dump_info(void);
-void _thread_init(void);
-void _thread_kern_sched(ucontext_t *);
-void _thread_kern_sched_state(enum pthread_state,char *fname,int lineno);
-void _thread_kern_sched_state_unlock(enum pthread_state state,
- spinlock_t *lock, char *fname, int lineno);
-void _thread_kern_set_timeout(struct timespec *);
-void _thread_kern_sig_defer(void);
-void _thread_kern_sig_undefer(void);
-void _thread_sig_handler(int, int, ucontext_t *);
-pthread_t _thread_sig_handle(int, ucontext_t *);
-void _thread_sig_init(void);
-void _thread_sig_send(pthread_t pthread, int sig);
-void _thread_sig_deliver(pthread_t pthread, int sig);
-void _thread_start(void);
-void _thread_start_sig_handler(void);
-void _thread_seterrno(pthread_t,int);
-int _thread_fd_table_init(int fd);
-pthread_addr_t _thread_gc(pthread_addr_t);
-void _thread_enter_cancellation_point(void);
-void _thread_leave_cancellation_point(void);
-void _thread_cancellation_point(void);
-
-/* #include <signal.h> */
-int _thread_sys_sigaction(int, const struct sigaction *, struct sigaction *);
-int _thread_sys_sigpending(sigset_t *);
-int _thread_sys_sigprocmask(int, const sigset_t *, sigset_t *);
-int _thread_sys_sigsuspend(const sigset_t *);
-int _thread_sys_siginterrupt(int, int);
-int _thread_sys_sigpause(int);
-int _thread_sys_sigreturn(ucontext_t *);
-int _thread_sys_sigstack(const struct sigstack *, struct sigstack *);
-int _thread_sys_sigvec(int, struct sigvec *, struct sigvec *);
-void _thread_sys_psignal(unsigned int, const char *);
-void (*_thread_sys_signal(int, void (*)(int)))(int);
-
-/* #include <sys/stat.h> */
-#ifdef _SYS_STAT_H_
-int _thread_sys_fchmod(int, mode_t);
-int _thread_sys_fstat(int, struct stat *);
-int _thread_sys_fchflags(int, u_long);
-#endif
-
-/* #include <sys/mount.h> */
-#ifdef _SYS_MOUNT_H_
-int _thread_sys_fstatfs(int, struct statfs *);
-#endif
-int _thread_sys_pipe(int *);
-
-/* #include <sys/socket.h> */
-#ifdef _SYS_SOCKET_H_
-int _thread_sys_accept(int, struct sockaddr *, int *);
-int _thread_sys_bind(int, const struct sockaddr *, int);
-int _thread_sys_connect(int, const struct sockaddr *, int);
-int _thread_sys_getpeername(int, struct sockaddr *, int *);
-int _thread_sys_getsockname(int, struct sockaddr *, int *);
-int _thread_sys_getsockopt(int, int, int, void *, int *);
-int _thread_sys_listen(int, int);
-int _thread_sys_setsockopt(int, int, int, const void *, int);
-int _thread_sys_shutdown(int, int);
-int _thread_sys_socket(int, int, int);
-int _thread_sys_socketpair(int, int, int, int *);
-ssize_t _thread_sys_recv(int, void *, size_t, int);
-ssize_t _thread_sys_recvfrom(int, void *, size_t, int, struct sockaddr *, int *);
-ssize_t _thread_sys_recvmsg(int, struct msghdr *, int);
-ssize_t _thread_sys_send(int, const void *, size_t, int);
-ssize_t _thread_sys_sendmsg(int, const struct msghdr *, int);
-ssize_t _thread_sys_sendto(int, const void *,size_t, int, const struct sockaddr *, int);
-#endif
-
-/* #include <stdio.h> */
-#ifdef _STDIO_H_
-FILE *_thread_sys_fdopen(int, const char *);
-FILE *_thread_sys_fopen(const char *, const char *);
-FILE *_thread_sys_freopen(const char *, const char *, FILE *);
-FILE *_thread_sys_popen(const char *, const char *);
-FILE *_thread_sys_tmpfile(void);
-char *_thread_sys_ctermid(char *);
-char *_thread_sys_cuserid(char *);
-char *_thread_sys_fgetln(FILE *, size_t *);
-char *_thread_sys_fgets(char *, int, FILE *);
-char *_thread_sys_gets(char *);
-char *_thread_sys_tempnam(const char *, const char *);
-char *_thread_sys_tmpnam(char *);
-int _thread_sys_fclose(FILE *);
-int _thread_sys_feof(FILE *);
-int _thread_sys_ferror(FILE *);
-int _thread_sys_fflush(FILE *);
-int _thread_sys_fgetc(FILE *);
-int _thread_sys_fgetpos(FILE *, fpos_t *);
-int _thread_sys_fileno(FILE *);
-int _thread_sys_fprintf(FILE *, const char *, ...);
-int _thread_sys_fpurge(FILE *);
-int _thread_sys_fputc(int, FILE *);
-int _thread_sys_fputs(const char *, FILE *);
-int _thread_sys_fscanf(FILE *, const char *, ...);
-int _thread_sys_fseek(FILE *, long, int);
-int _thread_sys_fsetpos(FILE *, const fpos_t *);
-int _thread_sys_getc(FILE *);
-int _thread_sys_getchar(void);
-int _thread_sys_getw(FILE *);
-int _thread_sys_pclose(FILE *);
-int _thread_sys_printf(const char *, ...);
-int _thread_sys_putc(int, FILE *);
-int _thread_sys_putchar(int);
-int _thread_sys_puts(const char *);
-int _thread_sys_putw(int, FILE *);
-int _thread_sys_remove(const char *);
-int _thread_sys_rename (const char *, const char *);
-int _thread_sys_scanf(const char *, ...);
-int _thread_sys_setlinebuf(FILE *);
-int _thread_sys_setvbuf(FILE *, char *, int, size_t);
-int _thread_sys_snprintf(char *, size_t, const char *, ...);
-int _thread_sys_sprintf(char *, const char *, ...);
-int _thread_sys_sscanf(const char *, const char *, ...);
-int _thread_sys_ungetc(int, FILE *);
-int _thread_sys_vfprintf(FILE *, const char *, _BSD_VA_LIST_);
-int _thread_sys_vprintf(const char *, _BSD_VA_LIST_);
-int _thread_sys_vscanf(const char *, _BSD_VA_LIST_);
-int _thread_sys_vsnprintf(char *, size_t, const char *, _BSD_VA_LIST_);
-int _thread_sys_vsprintf(char *, const char *, _BSD_VA_LIST_);
-int _thread_sys_vsscanf(const char *, const char *, _BSD_VA_LIST_);
-long _thread_sys_ftell(FILE *);
-size_t _thread_sys_fread(void *, size_t, size_t, FILE *);
-size_t _thread_sys_fwrite(const void *, size_t, size_t, FILE *);
-void _thread_sys_clearerr(FILE *);
-void _thread_sys_perror(const char *);
-void _thread_sys_rewind(FILE *);
-void _thread_sys_setbuf(FILE *, char *);
-void _thread_sys_setbuffer(FILE *, char *, int);
-#endif
-
-/* #include <unistd.h> */
-#ifdef _UNISTD_H_
-char *_thread_sys_ttyname(int);
-int _thread_sys_close(int);
-int _thread_sys_dup(int);
-int _thread_sys_dup2(int, int);
-int _thread_sys_exect(const char *, char * const *, char * const *);
-int _thread_sys_execve(const char *, char * const *, char * const *);
-int _thread_sys_fchdir(int);
-int _thread_sys_fchown(int, uid_t, gid_t);
-int _thread_sys_fsync(int);
-int _thread_sys_ftruncate(int, off_t);
-int _thread_sys_pause(void);
-int _thread_sys_pipe(int *);
-int _thread_sys_select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
-off_t _thread_sys_lseek(int, off_t, int);
-pid_t _thread_sys_fork(void);
-pid_t _thread_sys_tcgetpgrp(int);
-ssize_t _thread_sys_read(int, void *, size_t);
-ssize_t _thread_sys_write(int, const void *, size_t);
-void _thread_sys__exit(int);
-#endif
-
-/* #include <fcntl.h> */
-#ifdef _SYS_FCNTL_H_
-int _thread_sys_creat(const char *, mode_t);
-int _thread_sys_fcntl(int, int, ...);
-int _thread_sys_flock(int, int);
-int _thread_sys_open(const char *, int, ...);
-#endif
-
-/* #include <sys/ioctl.h> */
-#ifdef _SYS_IOCTL_H_
-int _thread_sys_ioctl(int, unsigned long, ...);
-#endif
-
-/* #include <dirent.h> */
-#ifdef _DIRENT_H_
-DIR *___thread_sys_opendir2(const char *, int);
-DIR *_thread_sys_opendir(const char *);
-int _thread_sys_alphasort(const void *, const void *);
-int _thread_sys_scandir(const char *, struct dirent ***,
- int (*)(struct dirent *), int (*)(const void *, const void *));
-int _thread_sys_closedir(DIR *);
-int _thread_sys_getdirentries(int, char *, int, long *);
-long _thread_sys_telldir(const DIR *);
-struct dirent *_thread_sys_readdir(DIR *);
-void _thread_sys_rewinddir(DIR *);
-void _thread_sys_seekdir(DIR *, long);
-#endif
-
-/* #include <sys/uio.h> */
-#ifdef _SYS_UIO_H_
-ssize_t _thread_sys_readv(int, const struct iovec *, int);
-ssize_t _thread_sys_writev(int, const struct iovec *, int);
-#endif
-
-/* #include <sys/wait.h> */
-#ifdef WNOHANG
-pid_t _thread_sys_wait(int *);
-pid_t _thread_sys_waitpid(pid_t, int *, int);
-pid_t _thread_sys_wait3(int *, int, struct rusage *);
-pid_t _thread_sys_wait4(pid_t, int *, int, struct rusage *);
-#endif
-
-/* #include <poll.h> */
-#ifdef _SYS_POLL_H_
-int _thread_sys_poll(struct pollfd *, unsigned, int);
-#endif
-
-/* #include <sys/mman.h> */
-#ifdef _SYS_MMAN_H_
-int _thread_sys_msync(void *, size_t, int);
-#endif
-
-/* #include <setjmp.h> */
-#ifdef _SETJMP_H_
-extern void __siglongjmp(sigjmp_buf, int) __dead2;
-extern void __longjmp(jmp_buf, int) __dead2;
-extern void ___longjmp(jmp_buf, int) __dead2;
-#endif
-__END_DECLS
-
-#endif /* !_PTHREAD_PRIVATE_H */
diff --git a/lib/libkse/thread/thr_read.c b/lib/libkse/thread/thr_read.c
deleted file mode 100644
index b4d96943328a..000000000000
--- a/lib/libkse/thread/thr_read.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- *
- */
-#include <sys/types.h>
-#include <sys/fcntl.h>
-#include <sys/uio.h>
-#include <errno.h>
-#include <unistd.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-ssize_t
-_read(int fd, void *buf, size_t nbytes)
-{
- int ret;
- int type;
-
- /* POSIX says to do just this: */
- if (nbytes == 0) {
- return (0);
- }
-
- /* Lock the file descriptor for read: */
- if ((ret = _FD_LOCK(fd, FD_READ, NULL)) == 0) {
- /* Get the read/write mode type: */
- type = _thread_fd_table[fd]->flags & O_ACCMODE;
-
- /* Check if the file is not open for read: */
- if (type != O_RDONLY && type != O_RDWR) {
- /* File is not open for read: */
- errno = EBADF;
- _FD_UNLOCK(fd, FD_READ);
- return (-1);
- }
-
- /* Perform a non-blocking read syscall: */
- while ((ret = _thread_sys_read(fd, buf, nbytes)) < 0) {
- if ((_thread_fd_table[fd]->flags & O_NONBLOCK) == 0 &&
- (errno == EWOULDBLOCK || errno == EAGAIN)) {
- _thread_run->data.fd.fd = fd;
- _thread_kern_set_timeout(NULL);
-
- /* Reset the interrupted operation flag: */
- _thread_run->interrupted = 0;
-
- _thread_kern_sched_state(PS_FDR_WAIT,
- __FILE__, __LINE__);
-
- /*
- * Check if the operation was
- * interrupted by a signal
- */
- if (_thread_run->interrupted) {
- errno = EINTR;
- ret = -1;
- break;
- }
- } else {
- break;
- }
- }
- _FD_UNLOCK(fd, FD_READ);
- }
- return (ret);
-}
-
-ssize_t
-read(int fd, void *buf, size_t nbytes)
-{
- ssize_t ret;
-
- _thread_enter_cancellation_point();
- ret = _read(fd, buf, nbytes);
- _thread_leave_cancellation_point();
-
- return ret;
-}
-#endif
diff --git a/lib/libkse/thread/thr_readv.c b/lib/libkse/thread/thr_readv.c
deleted file mode 100644
index d8e02c0a3a05..000000000000
--- a/lib/libkse/thread/thr_readv.c
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- *
- */
-#include <sys/types.h>
-#include <sys/fcntl.h>
-#include <sys/uio.h>
-#include <errno.h>
-#include <unistd.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-ssize_t
-_readv(int fd, const struct iovec * iov, int iovcnt)
-{
- int ret;
- int type;
-
- /* Lock the file descriptor for read: */
- if ((ret = _FD_LOCK(fd, FD_READ, NULL)) == 0) {
- /* Get the read/write mode type: */
- type = _thread_fd_table[fd]->flags & O_ACCMODE;
-
- /* Check if the file is not open for read: */
- if (type != O_RDONLY && type != O_RDWR) {
- /* File is not open for read: */
- errno = EBADF;
- _FD_UNLOCK(fd, FD_READ);
- return (-1);
- }
-
- /* Perform a non-blocking readv syscall: */
- while ((ret = _thread_sys_readv(fd, iov, iovcnt)) < 0) {
- if ((_thread_fd_table[fd]->flags & O_NONBLOCK) == 0 &&
- (errno == EWOULDBLOCK || errno == EAGAIN)) {
- _thread_run->data.fd.fd = fd;
- _thread_kern_set_timeout(NULL);
-
- /* Reset the interrupted operation flag: */
- _thread_run->interrupted = 0;
-
- _thread_kern_sched_state(PS_FDR_WAIT,
- __FILE__, __LINE__);
-
- /*
- * Check if the operation was
- * interrupted by a signal
- */
- if (_thread_run->interrupted) {
- errno = EINTR;
- ret = -1;
- break;
- }
- } else {
- break;
- }
- }
- _FD_UNLOCK(fd, FD_READ);
- }
- return (ret);
-}
-
-__strong_reference(_readv, readv);
-#endif
diff --git a/lib/libkse/thread/thr_resume_np.c b/lib/libkse/thread/thr_resume_np.c
deleted file mode 100644
index 98ec7186d8f9..000000000000
--- a/lib/libkse/thread/thr_resume_np.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-/* Resume a thread: */
-int
-pthread_resume_np(pthread_t thread)
-{
- int ret;
-
- /* Find the thread in the list of active threads: */
- if ((ret = _find_thread(thread)) == 0) {
- /* The thread exists. Is it suspended? */
- if (thread->state != PS_SUSPENDED) {
- /*
- * Defer signals to protect the scheduling queues
- * from access by the signal handler:
- */
- _thread_kern_sig_defer();
-
- /* Allow the thread to run. */
- PTHREAD_NEW_STATE(thread,PS_RUNNING);
-
- /*
- * Undefer and handle pending signals, yielding if
- * necessary:
- */
- _thread_kern_sig_undefer();
- }
- }
- return(ret);
-}
-#endif
diff --git a/lib/libkse/thread/thr_rwlock.c b/lib/libkse/thread/thr_rwlock.c
deleted file mode 100644
index 648e8a394eeb..000000000000
--- a/lib/libkse/thread/thr_rwlock.c
+++ /dev/null
@@ -1,335 +0,0 @@
-/*-
- * Copyright (c) 1998 Alex Nash
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#ifdef _THREAD_SAFE
-#include <errno.h>
-#include <limits.h>
-#include <stdlib.h>
-
-#include <pthread.h>
-#include "pthread_private.h"
-
-/* maximum number of times a read lock may be obtained */
-#define MAX_READ_LOCKS (INT_MAX - 1)
-
-static int init_static (pthread_rwlock_t *rwlock);
-
-static spinlock_t static_init_lock = _SPINLOCK_INITIALIZER;
-
-static int
-init_static (pthread_rwlock_t *rwlock)
-{
- int ret;
-
- _SPINLOCK(&static_init_lock);
-
- if (*rwlock == NULL)
- ret = pthread_rwlock_init(rwlock, NULL);
- else
- ret = 0;
-
- _SPINUNLOCK(&static_init_lock);
-
- return(ret);
-}
-
-int
-pthread_rwlock_destroy (pthread_rwlock_t *rwlock)
-{
- int ret;
-
- if (rwlock == NULL)
- ret = EINVAL;
- else {
- pthread_rwlock_t prwlock;
-
- prwlock = *rwlock;
-
- pthread_mutex_destroy(&prwlock->lock);
- pthread_cond_destroy(&prwlock->read_signal);
- pthread_cond_destroy(&prwlock->write_signal);
- free(prwlock);
-
- *rwlock = NULL;
-
- ret = 0;
- }
-
- return(ret);
-}
-
-int
-pthread_rwlock_init (pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr)
-{
- pthread_rwlock_t prwlock;
- int ret;
-
- /* allocate rwlock object */
- prwlock = (pthread_rwlock_t)malloc(sizeof(struct pthread_rwlock));
-
- if (prwlock == NULL)
- return(ENOMEM);
-
- /* initialize the lock */
- if ((ret = pthread_mutex_init(&prwlock->lock, NULL)) != 0)
- free(prwlock);
- else {
- /* initialize the read condition signal */
- ret = pthread_cond_init(&prwlock->read_signal, NULL);
-
- if (ret != 0) {
- pthread_mutex_destroy(&prwlock->lock);
- free(prwlock);
- } else {
- /* initialize the write condition signal */
- ret = pthread_cond_init(&prwlock->write_signal, NULL);
-
- if (ret != 0) {
- pthread_cond_destroy(&prwlock->read_signal);
- pthread_mutex_destroy(&prwlock->lock);
- free(prwlock);
- } else {
- /* success */
- prwlock->state = 0;
- prwlock->blocked_writers = 0;
-
- *rwlock = prwlock;
- }
- }
- }
-
- return(ret);
-}
-
-int
-pthread_rwlock_rdlock (pthread_rwlock_t *rwlock)
-{
- pthread_rwlock_t prwlock;
- int ret;
-
- if (rwlock == NULL)
- return(EINVAL);
-
- prwlock = *rwlock;
-
- /* check for static initialization */
- if (prwlock == NULL) {
- if ((ret = init_static(rwlock)) != 0)
- return(ret);
-
- prwlock = *rwlock;
- }
-
- /* grab the monitor lock */
- if ((ret = pthread_mutex_lock(&prwlock->lock)) != 0)
- return(ret);
-
- /* give writers priority over readers */
- while (prwlock->blocked_writers || prwlock->state < 0) {
- ret = pthread_cond_wait(&prwlock->read_signal, &prwlock->lock);
-
- if (ret != 0) {
- /* can't do a whole lot if this fails */
- pthread_mutex_unlock(&prwlock->lock);
- return(ret);
- }
- }
-
- /* check lock count */
- if (prwlock->state == MAX_READ_LOCKS)
- ret = EAGAIN;
- else
- ++prwlock->state; /* indicate we are locked for reading */
-
- /*
- * Something is really wrong if this call fails. Returning
- * error won't do because we've already obtained the read
- * lock. Decrementing 'state' is no good because we probably
- * don't have the monitor lock.
- */
- pthread_mutex_unlock(&prwlock->lock);
-
- return(ret);
-}
-
-int
-pthread_rwlock_tryrdlock (pthread_rwlock_t *rwlock)
-{
- pthread_rwlock_t prwlock;
- int ret;
-
- if (rwlock == NULL)
- return(EINVAL);
-
- prwlock = *rwlock;
-
- /* check for static initialization */
- if (prwlock == NULL) {
- if ((ret = init_static(rwlock)) != 0)
- return(ret);
-
- prwlock = *rwlock;
- }
-
- /* grab the monitor lock */
- if ((ret = pthread_mutex_lock(&prwlock->lock)) != 0)
- return(ret);
-
- /* give writers priority over readers */
- if (prwlock->blocked_writers || prwlock->state < 0)
- ret = EWOULDBLOCK;
- else if (prwlock->state == MAX_READ_LOCKS)
- ret = EAGAIN; /* too many read locks acquired */
- else
- ++prwlock->state; /* indicate we are locked for reading */
-
- /* see the comment on this in pthread_rwlock_rdlock */
- pthread_mutex_unlock(&prwlock->lock);
-
- return(ret);
-}
-
-int
-pthread_rwlock_trywrlock (pthread_rwlock_t *rwlock)
-{
- pthread_rwlock_t prwlock;
- int ret;
-
- if (rwlock == NULL)
- return(EINVAL);
-
- prwlock = *rwlock;
-
- /* check for static initialization */
- if (prwlock == NULL) {
- if ((ret = init_static(rwlock)) != 0)
- return(ret);
-
- prwlock = *rwlock;
- }
-
- /* grab the monitor lock */
- if ((ret = pthread_mutex_lock(&prwlock->lock)) != 0)
- return(ret);
-
- if (prwlock->state != 0)
- ret = EWOULDBLOCK;
- else
- /* indicate we are locked for writing */
- prwlock->state = -1;
-
- /* see the comment on this in pthread_rwlock_rdlock */
- pthread_mutex_unlock(&prwlock->lock);
-
- return(ret);
-}
-
-int
-pthread_rwlock_unlock (pthread_rwlock_t *rwlock)
-{
- pthread_rwlock_t prwlock;
- int ret;
-
- if (rwlock == NULL)
- return(EINVAL);
-
- prwlock = *rwlock;
-
- if (prwlock == NULL)
- return(EINVAL);
-
- /* grab the monitor lock */
- if ((ret = pthread_mutex_lock(&prwlock->lock)) != 0)
- return(ret);
-
- if (prwlock->state > 0) {
- if (--prwlock->state == 0 && prwlock->blocked_writers)
- ret = pthread_cond_signal(&prwlock->write_signal);
- } else if (prwlock->state < 0) {
- prwlock->state = 0;
-
- if (prwlock->blocked_writers)
- ret = pthread_cond_signal(&prwlock->write_signal);
- else
- ret = pthread_cond_broadcast(&prwlock->read_signal);
- } else
- ret = EINVAL;
-
- /* see the comment on this in pthread_rwlock_rdlock */
- pthread_mutex_unlock(&prwlock->lock);
-
- return(ret);
-}
-
-int
-pthread_rwlock_wrlock (pthread_rwlock_t *rwlock)
-{
- pthread_rwlock_t prwlock;
- int ret;
-
- if (rwlock == NULL)
- return(EINVAL);
-
- prwlock = *rwlock;
-
- /* check for static initialization */
- if (prwlock == NULL) {
- if ((ret = init_static(rwlock)) != 0)
- return(ret);
-
- prwlock = *rwlock;
- }
-
- /* grab the monitor lock */
- if ((ret = pthread_mutex_lock(&prwlock->lock)) != 0)
- return(ret);
-
- while (prwlock->state != 0) {
- ++prwlock->blocked_writers;
-
- ret = pthread_cond_wait(&prwlock->write_signal, &prwlock->lock);
-
- if (ret != 0) {
- --prwlock->blocked_writers;
- pthread_mutex_unlock(&prwlock->lock);
- return(ret);
- }
-
- --prwlock->blocked_writers;
- }
-
- /* indicate we are locked for writing */
- prwlock->state = -1;
-
- /* see the comment on this in pthread_rwlock_rdlock */
- pthread_mutex_unlock(&prwlock->lock);
-
- return(ret);
-}
-
-#endif /* _THREAD_SAFE */
diff --git a/lib/libkse/thread/thr_rwlockattr.c b/lib/libkse/thread/thr_rwlockattr.c
deleted file mode 100644
index 37eb3eae66a9..000000000000
--- a/lib/libkse/thread/thr_rwlockattr.c
+++ /dev/null
@@ -1,95 +0,0 @@
-/*-
- * Copyright (c) 1998 Alex Nash
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#ifdef _THREAD_SAFE
-#include <errno.h>
-#include <stdlib.h>
-
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_rwlockattr_destroy(pthread_rwlockattr_t *rwlockattr)
-{
- pthread_rwlockattr_t prwlockattr;
-
- if (rwlockattr == NULL)
- return(EINVAL);
-
- prwlockattr = *rwlockattr;
-
- if (prwlockattr == NULL)
- return(EINVAL);
-
- free(prwlockattr);
-
- return(0);
-}
-
-int
-pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *rwlockattr,
- int *pshared)
-{
- *pshared = (*rwlockattr)->pshared;
-
- return(0);
-}
-
-int
-pthread_rwlockattr_init(pthread_rwlockattr_t *rwlockattr)
-{
- pthread_rwlockattr_t prwlockattr;
-
- if (rwlockattr == NULL)
- return(EINVAL);
-
- prwlockattr = (pthread_rwlockattr_t)
- malloc(sizeof(struct pthread_rwlockattr));
-
- if (prwlockattr == NULL)
- return(ENOMEM);
-
- prwlockattr->pshared = PTHREAD_PROCESS_PRIVATE;
- *rwlockattr = prwlockattr;
-
- return(0);
-}
-
-int
-pthread_rwlockattr_setpshared(pthread_rwlockattr_t *rwlockattr, int pshared)
-{
- /* Only PTHREAD_PROCESS_PRIVATE is supported. */
- if (pshared != PTHREAD_PROCESS_PRIVATE)
- return(EINVAL);
-
- (*rwlockattr)->pshared = pshared;
-
- return(0);
-}
-
-#endif /* _THREAD_SAFE */
diff --git a/lib/libkse/thread/thr_select.c b/lib/libkse/thread/thr_select.c
deleted file mode 100644
index 0a7c0d405c22..000000000000
--- a/lib/libkse/thread/thr_select.c
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <unistd.h>
-#include <errno.h>
-#include <poll.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/fcntl.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-_select(int numfds, fd_set * readfds, fd_set * writefds, fd_set * exceptfds,
- struct timeval * timeout)
-{
- struct timespec ts;
- int i, ret = 0, f_wait = 1;
- int pfd_index, got_one = 0, fd_count = 0;
- struct pthread_poll_data data;
-
- if (numfds > _thread_dtablesize) {
- numfds = _thread_dtablesize;
- }
- /* Check if a timeout was specified: */
- if (timeout) {
- if (timeout->tv_sec < 0 ||
- timeout->tv_usec < 0 || timeout->tv_usec >= 1000000) {
- errno = EINVAL;
- return (-1);
- }
-
- /* Convert the timeval to a timespec: */
- TIMEVAL_TO_TIMESPEC(timeout, &ts);
-
- /* Set the wake up time: */
- _thread_kern_set_timeout(&ts);
- if (ts.tv_sec == 0 && ts.tv_nsec == 0)
- f_wait = 0;
- } else {
- /* Wait for ever: */
- _thread_kern_set_timeout(NULL);
- }
-
- /* Count the number of file descriptors to be polled: */
- if (readfds || writefds || exceptfds) {
- for (i = 0; i < numfds; i++) {
- if ((readfds && FD_ISSET(i, readfds)) ||
- (exceptfds && FD_ISSET(i, exceptfds)) ||
- (writefds && FD_ISSET(i, writefds))) {
- fd_count++;
- }
- }
- }
-
- /*
- * Allocate memory for poll data if it hasn't already been
- * allocated or if previously allocated memory is insufficient.
- */
- if ((_thread_run->poll_data.fds == NULL) ||
- (_thread_run->poll_data.nfds < fd_count)) {
- data.fds = (struct pollfd *) realloc(_thread_run->poll_data.fds,
- sizeof(struct pollfd) * MAX(128, fd_count));
- if (data.fds == NULL) {
- errno = ENOMEM;
- ret = -1;
- }
- else {
- /*
- * Note that the threads poll data always
- * indicates what is allocated, not what is
- * currently being polled.
- */
- _thread_run->poll_data.fds = data.fds;
- _thread_run->poll_data.nfds = MAX(128, fd_count);
- }
- }
- if (ret == 0) {
- /* Setup the wait data. */
- data.fds = _thread_run->poll_data.fds;
- data.nfds = fd_count;
-
- /*
- * Setup the array of pollfds. Optimize this by
- * running the loop in reverse and stopping when
- * the number of selected file descriptors is reached.
- */
- for (i = numfds - 1, pfd_index = fd_count - 1;
- (i >= 0) && (pfd_index >= 0); i--) {
- data.fds[pfd_index].events = 0;
- if (readfds && FD_ISSET(i, readfds)) {
- data.fds[pfd_index].events = POLLRDNORM;
- }
- if (exceptfds && FD_ISSET(i, exceptfds)) {
- data.fds[pfd_index].events |= POLLRDBAND;
- }
- if (writefds && FD_ISSET(i, writefds)) {
- data.fds[pfd_index].events |= POLLWRNORM;
- }
- if (data.fds[pfd_index].events != 0) {
- /*
- * Set the file descriptor to be polled and
- * clear revents in case of a timeout which
- * leaves fds unchanged:
- */
- data.fds[pfd_index].fd = i;
- data.fds[pfd_index].revents = 0;
- pfd_index--;
- }
- }
- if (((ret = _thread_sys_poll(data.fds, data.nfds, 0)) == 0) &&
- (f_wait != 0)) {
- _thread_run->data.poll_data = &data;
- _thread_run->interrupted = 0;
- _thread_kern_sched_state(PS_SELECT_WAIT, __FILE__, __LINE__);
- if (_thread_run->interrupted) {
- errno = EINTR;
- data.nfds = 0;
- ret = -1;
- } else
- ret = data.nfds;
- }
- }
-
- if (ret >= 0) {
- numfds = 0;
- for (i = 0; i < fd_count; i++) {
- /*
- * Check the results of the poll and clear
- * this file descriptor from the fdset if
- * the requested event wasn't ready.
- */
- got_one = 0;
- if (readfds != NULL) {
- if (FD_ISSET(data.fds[i].fd, readfds)) {
- if (data.fds[i].revents & (POLLIN |
- POLLRDNORM))
- got_one = 1;
- else
- FD_CLR(data.fds[i].fd, readfds);
- }
- }
- if (writefds != NULL) {
- if (FD_ISSET(data.fds[i].fd, writefds)) {
- if (data.fds[i].revents & (POLLOUT |
- POLLWRNORM | POLLWRBAND))
- got_one = 1;
- else
- FD_CLR(data.fds[i].fd,
- writefds);
- }
- }
- if (exceptfds != NULL) {
- if (FD_ISSET(data.fds[i].fd, exceptfds)) {
- if (data.fds[i].revents & (POLLRDBAND |
- POLLPRI | POLLHUP | POLLERR |
- POLLNVAL))
- got_one = 1;
- else
- FD_CLR(data.fds[i].fd,
- exceptfds);
- }
- }
- if (got_one)
- numfds++;
- }
- ret = numfds;
- }
-
- return (ret);
-}
-
-__strong_reference(_select, select);
-#endif
diff --git a/lib/libkse/thread/thr_self.c b/lib/libkse/thread/thr_self.c
deleted file mode 100644
index 81ec427a3f04..000000000000
--- a/lib/libkse/thread/thr_self.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-pthread_t
-pthread_self(void)
-{
- /* Return the running thread pointer: */
- return (_thread_run);
-}
-#endif
diff --git a/lib/libkse/thread/thr_sem.c b/lib/libkse/thread/thr_sem.c
deleted file mode 100644
index d893c9405582..000000000000
--- a/lib/libkse/thread/thr_sem.c
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * Copyright (C) 2000 Jason Evans <jasone@canonware.com>.
- * 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(s), this list of conditions and the following disclaimer as
- * the first lines of this file unmodified other than the possible
- * addition of one or more copyright notices.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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.
- *
- * $FreeBSD$
- */
-
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <semaphore.h>
-#include <pthread.h>
-#include "pthread_private.h"
-
-#define _SEM_CHECK_VALIDITY(sem) \
- if ((*(sem))->magic != SEM_MAGIC) { \
- errno = EINVAL; \
- retval = -1; \
- goto RETURN; \
- }
-
-int
-sem_init(sem_t *sem, int pshared, unsigned int value)
-{
- int retval;
-
- /*
- * Range check the arguments.
- */
- if (pshared != 0) {
- /*
- * The user wants a semaphore that can be shared among
- * processes, which this implementation can't do. Sounds like a
- * permissions problem to me (yeah right).
- */
- errno = EPERM;
- retval = -1;
- goto RETURN;
- }
-
- if (value > SEM_VALUE_MAX) {
- errno = EINVAL;
- retval = -1;
- goto RETURN;
- }
-
- *sem = (sem_t)malloc(sizeof(struct sem));
- if (*sem == NULL) {
- errno = ENOSPC;
- retval = -1;
- goto RETURN;
- }
-
- /*
- * Initialize the semaphore.
- */
- if (pthread_mutex_init(&(*sem)->lock, NULL) != 0) {
- free(*sem);
- errno = ENOSPC;
- retval = -1;
- goto RETURN;
- }
-
- if (pthread_cond_init(&(*sem)->gtzero, NULL) != 0) {
- pthread_mutex_destroy(&(*sem)->lock);
- free(*sem);
- errno = ENOSPC;
- retval = -1;
- goto RETURN;
- }
-
- (*sem)->count = (u_int32_t)value;
- (*sem)->nwaiters = 0;
- (*sem)->magic = SEM_MAGIC;
-
- retval = 0;
- RETURN:
- return retval;
-}
-
-int
-sem_destroy(sem_t *sem)
-{
- int retval;
-
- _SEM_CHECK_VALIDITY(sem);
-
- /* Make sure there are no waiters. */
- pthread_mutex_lock(&(*sem)->lock);
- if ((*sem)->nwaiters > 0) {
- pthread_mutex_unlock(&(*sem)->lock);
- errno = EBUSY;
- retval = -1;
- goto RETURN;
- }
- pthread_mutex_unlock(&(*sem)->lock);
-
- pthread_mutex_destroy(&(*sem)->lock);
- pthread_cond_destroy(&(*sem)->gtzero);
- (*sem)->magic = 0;
-
- free(*sem);
-
- retval = 0;
- RETURN:
- return retval;
-}
-
-sem_t *
-sem_open(const char *name, int oflag, ...)
-{
- errno = ENOSYS;
- return SEM_FAILED;
-}
-
-int
-sem_close(sem_t *sem)
-{
- errno = ENOSYS;
- return -1;
-}
-
-int
-sem_unlink(const char *name)
-{
- errno = ENOSYS;
- return -1;
-}
-
-int
-sem_wait(sem_t *sem)
-{
- int retval;
-
- _thread_enter_cancellation_point();
-
- _SEM_CHECK_VALIDITY(sem);
-
- pthread_mutex_lock(&(*sem)->lock);
-
- while ((*sem)->count == 0) {
- (*sem)->nwaiters++;
- pthread_cond_wait(&(*sem)->gtzero, &(*sem)->lock);
- (*sem)->nwaiters--;
- }
- (*sem)->count--;
-
- pthread_mutex_unlock(&(*sem)->lock);
-
- retval = 0;
- RETURN:
- _thread_leave_cancellation_point();
- return retval;
-}
-
-int
-sem_trywait(sem_t *sem)
-{
- int retval;
-
- _SEM_CHECK_VALIDITY(sem);
-
- pthread_mutex_lock(&(*sem)->lock);
-
- if ((*sem)->count > 0) {
- (*sem)->count--;
- retval = 0;
- } else {
- errno = EAGAIN;
- retval = -1;
- }
-
- pthread_mutex_unlock(&(*sem)->lock);
-
- RETURN:
- return retval;
-}
-
-int
-sem_post(sem_t *sem)
-{
- int retval;
-
- _SEM_CHECK_VALIDITY(sem);
-
- pthread_mutex_lock(&(*sem)->lock);
-
- (*sem)->count++;
- if ((*sem)->nwaiters > 0) {
- /*
- * We must use pthread_cond_broadcast() rather than
- * pthread_cond_signal() in order to assure that the highest
- * priority thread is run by the scheduler, since
- * pthread_cond_signal() signals waiting threads in FIFO order.
- */
- pthread_cond_broadcast(&(*sem)->gtzero);
- }
-
- pthread_mutex_unlock(&(*sem)->lock);
-
- retval = 0;
- RETURN:
- return retval;
-}
-
-int
-sem_getvalue(sem_t *sem, int *sval)
-{
- int retval;
-
- _SEM_CHECK_VALIDITY(sem);
-
- pthread_mutex_lock(&(*sem)->lock);
- *sval = (int)(*sem)->count;
- pthread_mutex_unlock(&(*sem)->lock);
-
- retval = 0;
- RETURN:
- return retval;
-}
-#endif
diff --git a/lib/libkse/thread/thr_seterrno.c b/lib/libkse/thread/thr_seterrno.c
deleted file mode 100644
index 1934aac7222a..000000000000
--- a/lib/libkse/thread/thr_seterrno.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-/*
- * This function needs to reference the global error variable which is
- * normally hidden from the user.
- */
-#ifdef errno
-#undef errno;
-#endif
-extern int errno;
-
-void
-_thread_seterrno(pthread_t thread, int error)
-{
- /* Check for the initial thread: */
- if (thread == _thread_initial)
- /* The initial thread always uses the global error variable: */
- errno = error;
- else
- /*
- * Threads other than the initial thread always use the error
- * field in the thread structureL
- */
- thread->error = error;
-}
-#endif
diff --git a/lib/libkse/thread/thr_setprio.c b/lib/libkse/thread/thr_setprio.c
deleted file mode 100644
index c630db52d8f9..000000000000
--- a/lib/libkse/thread/thr_setprio.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_setprio(pthread_t pthread, int prio)
-{
- int ret, policy;
- struct sched_param param;
-
- if ((ret = pthread_getschedparam(pthread, &policy, &param)) == 0) {
- param.sched_priority = prio;
- ret = pthread_setschedparam(pthread, policy, &param);
- }
-
- /* Return the error status: */
- return (ret);
-}
-#endif
diff --git a/lib/libkse/thread/thr_setschedparam.c b/lib/libkse/thread/thr_setschedparam.c
deleted file mode 100644
index f080d5ddba57..000000000000
--- a/lib/libkse/thread/thr_setschedparam.c
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>.
- * 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 Daniel Eischen.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#include <sys/param.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_setschedparam(pthread_t pthread, int policy,
- const struct sched_param *param)
-{
- int old_prio, in_readyq = 0, ret = 0;
-
- if ((param == NULL) || (param->sched_priority < PTHREAD_MIN_PRIORITY) ||
- (param->sched_priority > PTHREAD_MAX_PRIORITY) ||
- (policy < SCHED_FIFO) || (policy > SCHED_RR))
- /* Return an invalid argument error: */
- ret = EINVAL;
-
- /* Find the thread in the list of active threads: */
- else if ((ret = _find_thread(pthread)) == 0) {
- /*
- * Defer signals to protect the scheduling queues from
- * access by the signal handler:
- */
- _thread_kern_sig_defer();
-
- if (param->sched_priority != pthread->base_priority) {
- /*
- * Remove the thread from its current priority
- * queue before any adjustments are made to its
- * active priority:
- */
- old_prio = pthread->active_priority;
- if ((pthread->flags & PTHREAD_FLAGS_IN_PRIOQ) != 0) {
- in_readyq = 1;
- PTHREAD_PRIOQ_REMOVE(pthread);
- }
-
- /* Set the thread base priority: */
- pthread->base_priority = param->sched_priority;
-
- /* Recalculate the active priority: */
- pthread->active_priority = MAX(pthread->base_priority,
- pthread->inherited_priority);
-
- if (in_readyq) {
- if ((pthread->priority_mutex_count > 0) &&
- (old_prio > pthread->active_priority)) {
- /*
- * POSIX states that if the priority is
- * being lowered, the thread must be
- * inserted at the head of the queue for
- * its priority if it owns any priority
- * protection or inheritence mutexes.
- */
- PTHREAD_PRIOQ_INSERT_HEAD(pthread);
- }
- else
- PTHREAD_PRIOQ_INSERT_TAIL(pthread);
- }
-
- /*
- * Check for any mutex priority adjustments. This
- * includes checking for a priority mutex on which
- * this thread is waiting.
- */
- _mutex_notify_priochange(pthread);
- }
-
- /* Set the scheduling policy: */
- pthread->attr.sched_policy = policy;
-
- /*
- * Undefer and handle pending signals, yielding if
- * necessary:
- */
- _thread_kern_sig_undefer();
- }
- return(ret);
-}
-#endif
diff --git a/lib/libkse/thread/thr_sig.c b/lib/libkse/thread/thr_sig.c
deleted file mode 100644
index dc6d209f85b0..000000000000
--- a/lib/libkse/thread/thr_sig.c
+++ /dev/null
@@ -1,759 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/signalvar.h>
-#include <signal.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <setjmp.h>
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-/* Prototypes: */
-static void thread_sig_check_state(pthread_t pthread, int sig);
-static void thread_sig_finish_longjmp(void *arg);
-static void handle_state_change(pthread_t pthread);
-
-
-/* Static variables: */
-static spinlock_t signal_lock = _SPINLOCK_INITIALIZER;
-static unsigned int pending_sigs[NSIG];
-static unsigned int handled_sigs[NSIG];
-static int volatile check_pending = 0;
-static int volatile check_waiting = 0;
-
-/* Initialize signal handling facility: */
-void
-_thread_sig_init(void)
-{
- int i;
-
- /* Clear pending and handled signal counts: */
- for (i = 1; i < NSIG; i++) {
- pending_sigs[i - 1] = 0;
- handled_sigs[i - 1] = 0;
- }
-
- /* Clear the lock: */
- signal_lock.access_lock = 0;
-
- /* Clear the process pending signals: */
- sigemptyset(&_process_sigpending);
-}
-
-void
-_thread_sig_handler(int sig, int code, ucontext_t * scp)
-{
- pthread_t pthread, pthread_next;
- int i;
- char c;
-
- /* Check if an interval timer signal: */
- if (sig == _SCHED_SIGNAL) {
- if (_thread_kern_in_sched != 0) {
- /*
- * The scheduler is already running; ignore this
- * signal.
- */
- }
- /*
- * Check if the scheduler interrupt has come when
- * the currently running thread has deferred thread
- * signals.
- */
- else if (_thread_run->sig_defer_count > 0)
- _thread_run->yield_on_sig_undefer = 1;
-
- else {
- /*
- * Schedule the next thread. This function is not
- * expected to return because it will do a longjmp
- * instead.
- */
- _thread_kern_sched(scp);
-
- /*
- * This point should not be reached, so abort the
- * process:
- */
- PANIC("Returned to signal function from scheduler");
- }
- }
- /*
- * Check if the kernel has been interrupted while the scheduler
- * is accessing the scheduling queues or if there is a currently
- * running thread that has deferred signals.
- */
- else if ((_queue_signals != 0) || ((_thread_kern_in_sched == 0) &&
- (_thread_run->sig_defer_count > 0))) {
- /* Cast the signal number to a character variable: */
- c = sig;
-
- /*
- * Write the signal number to the kernel pipe so that it will
- * be ready to read when this signal handler returns.
- */
- _thread_sys_write(_thread_kern_pipe[1], &c, 1);
-
- /* Indicate that there are queued signals in the pipe. */
- _sigq_check_reqd = 1;
- } else {
- if (_atomic_lock(&signal_lock.access_lock)) {
- /* There is another signal handler running: */
- pending_sigs[sig - 1]++;
- check_pending = 1;
- }
- else {
- /* It's safe to handle the signal now. */
- pthread = _thread_sig_handle(sig, scp);
-
- /* Reset the pending and handled count back to 0: */
- pending_sigs[sig - 1] = 0;
- handled_sigs[sig - 1] = 0;
-
- if (pthread == NULL)
- signal_lock.access_lock = 0;
- else {
- sigaddset(&pthread->sigmask, sig);
-
- /*
- * Make sure not to deliver the same signal to
- * the thread twice. sigpend is potentially
- * modified by the call chain
- * _thread_sig_handle() -->
- * thread_sig_check_state(), which can happen
- * just above.
- */
- if (sigismember(&pthread->sigpend, sig))
- sigdelset(&pthread->sigpend, sig);
-
- signal_lock.access_lock = 0;
- _thread_sig_deliver(pthread, sig);
- sigdelset(&pthread->sigmask, sig);
- }
- }
-
- /* Enter a loop to process pending signals: */
- while ((check_pending != 0) &&
- (_atomic_lock(&signal_lock.access_lock) == 0)) {
- check_pending = 0;
- for (i = 1; i < NSIG; i++) {
- if (pending_sigs[i - 1] > handled_sigs[i - 1]) {
- pending_sigs[i - 1] = handled_sigs[i - 1];
- pthread = _thread_sig_handle(i, scp);
- if (pthread != NULL) {
- sigaddset(&pthread->sigmask, i);
- /* Save the old state: */
- pthread->oldstate = pthread->state;
- signal_lock.access_lock = 0;
- _thread_sig_deliver(pthread, i);
- sigdelset(&pthread->sigmask, i);
- if (_atomic_lock(&signal_lock.access_lock)) {
- check_pending = 1;
- /*
- * Have the lock holder take care
- * of any state changes:
- */
- if (pthread->state != pthread->oldstate)
- check_waiting = 1;
- return;
- }
- if (pthread->state != pthread->oldstate)
- handle_state_change(pthread);
- }
- }
- }
- while (check_waiting != 0) {
- check_waiting = 0;
- /*
- * Enter a loop to wake up all threads waiting
- * for a process to complete:
- */
- for (pthread = TAILQ_FIRST(&_waitingq);
- pthread != NULL; pthread = pthread_next) {
- pthread_next = TAILQ_NEXT(pthread, pqe);
- if (pthread->state == PS_RUNNING)
- handle_state_change(pthread);
- }
- }
- /* Release the lock: */
- signal_lock.access_lock = 0;
- }
-
- /*
- * Check to see if the current thread performed a
- * [sig|_]longjmp() out of a signal handler.
- */
- if ((_thread_run->jmpflags & (JMPFLAGS_LONGJMP |
- JMPFLAGS__LONGJMP)) != 0) {
- _thread_run->jmpflags = JMPFLAGS_NONE;
- __longjmp(_thread_run->nested_jmp.jmp,
- _thread_run->longjmp_val);
- } else if ((_thread_run->jmpflags & JMPFLAGS_SIGLONGJMP) != 0) {
- _thread_run->jmpflags = JMPFLAGS_NONE;
- __siglongjmp(_thread_run->nested_jmp.sigjmp,
- _thread_run->longjmp_val);
- }
- }
-}
-
-pthread_t
-_thread_sig_handle(int sig, ucontext_t * scp)
-{
- int i, handler_installed;
- pthread_t pthread, pthread_next;
- pthread_t suspended_thread, signaled_thread;
-
- /* Check if the signal requires a dump of thread information: */
- if (sig == SIGINFO)
- /* Dump thread information to file: */
- _thread_dump_info();
-
- /* Check if an interval timer signal: */
- else if (sig == _SCHED_SIGNAL) {
- /*
- * This shouldn't ever occur (should this panic?).
- */
- } else {
- /* Check if a child has terminated: */
- if (sig == SIGCHLD) {
- /*
- * Go through the file list and set all files
- * to non-blocking again in case the child
- * set some of them to block. Sigh.
- */
- for (i = 0; i < _thread_dtablesize; i++) {
- /* Check if this file is used: */
- if (_thread_fd_table[i] != NULL) {
- /*
- * Set the file descriptor to
- * non-blocking:
- */
- _thread_sys_fcntl(i, F_SETFL,
- _thread_fd_table[i]->flags |
- O_NONBLOCK);
- }
- }
- /*
- * Enter a loop to wake up all threads waiting
- * for a process to complete:
- */
- for (pthread = TAILQ_FIRST(&_waitingq);
- pthread != NULL; pthread = pthread_next) {
- /*
- * Grab the next thread before possibly
- * destroying the link entry:
- */
- pthread_next = TAILQ_NEXT(pthread, pqe);
-
- /*
- * If this thread is waiting for a child
- * process to complete, wake it up:
- */
- if (pthread->state == PS_WAIT_WAIT) {
- /* Make the thread runnable: */
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
-
- /* Return the signal number: */
- pthread->signo = sig;
- }
- }
- }
-
- /*
- * POSIX says that pending SIGCONT signals are
- * discarded when one of these signals occurs.
- */
- if (sig == SIGTSTP || sig == SIGTTIN || sig == SIGTTOU) {
- /*
- * Enter a loop to discard pending SIGCONT
- * signals:
- */
- TAILQ_FOREACH(pthread, &_thread_list, tle) {
- sigdelset(&pthread->sigpend,SIGCONT);
- }
- }
-
- /*
- * Enter a loop to look for threads that have the signal
- * unmasked. POSIX specifies that a thread in a sigwait
- * will get the signal over any other threads. Second
- * preference will be threads in in a sigsuspend. If
- * none of the above, then the signal is delivered to the
- * first thread we find. Note that if a custom handler
- * is not installed, the signal only affects threads in
- * sigwait.
- */
- suspended_thread = NULL;
- signaled_thread = NULL;
- if ((_thread_sigact[sig - 1].sa_handler == SIG_IGN) ||
- (_thread_sigact[sig - 1].sa_handler == SIG_DFL))
- handler_installed = 0;
- else
- handler_installed = 1;
-
- for (pthread = TAILQ_FIRST(&_waitingq);
- pthread != NULL; pthread = pthread_next) {
- /*
- * Grab the next thread before possibly destroying
- * the link entry.
- */
- pthread_next = TAILQ_NEXT(pthread, pqe);
-
- if ((pthread->state == PS_SIGWAIT) &&
- sigismember(pthread->data.sigwait, sig)) {
- /* Change the state of the thread to run: */
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
-
- /* Return the signal number: */
- pthread->signo = sig;
-
- /*
- * POSIX doesn't doesn't specify which thread
- * will get the signal if there are multiple
- * waiters, so we give it to the first thread
- * we find.
- *
- * Do not attempt to deliver this signal
- * to other threads.
- */
- return (NULL);
- }
- else if ((handler_installed != 0) &&
- !sigismember(&pthread->sigmask, sig)) {
- if (pthread->state == PS_SIGSUSPEND) {
- if (suspended_thread == NULL)
- suspended_thread = pthread;
- } else if (signaled_thread == NULL)
- signaled_thread = pthread;
- }
- }
-
- /*
- * Only perform wakeups and signal delivery if there is a
- * custom handler installed:
- */
- if (handler_installed != 0) {
- /*
- * If we didn't find a thread in the waiting queue,
- * check the all threads queue:
- */
- if (suspended_thread == NULL &&
- signaled_thread == NULL) {
- /*
- * Enter a loop to look for other threads
- * capable of receiving the signal:
- */
- TAILQ_FOREACH(pthread, &_thread_list, tle) {
- if (!sigismember(&pthread->sigmask,
- sig)) {
- signaled_thread = pthread;
- break;
- }
- }
- }
-
- if (suspended_thread == NULL &&
- signaled_thread == NULL)
- /*
- * Add it to the set of signals pending
- * on the process:
- */
- sigaddset(&_process_sigpending, sig);
- else {
- /*
- * We only deliver the signal to one thread;
- * give preference to the suspended thread:
- */
- if (suspended_thread != NULL)
- pthread = suspended_thread;
- else
- pthread = signaled_thread;
-
- /*
- * Perform any state changes due to signal
- * arrival:
- */
- thread_sig_check_state(pthread, sig);
- return (pthread);
- }
- }
- }
-
- /* Returns nothing. */
- return (NULL);
-}
-
-static void
-thread_sig_finish_longjmp(void *arg)
-{
- /*
- * Check to see if the current thread performed a [_]longjmp() out of a
- * signal handler.
- */
- if ((_thread_run->jmpflags & (JMPFLAGS_LONGJMP | JMPFLAGS__LONGJMP))
- != 0) {
- _thread_run->jmpflags = JMPFLAGS_NONE;
- _thread_run->continuation = NULL;
- __longjmp(_thread_run->nested_jmp.jmp,
- _thread_run->longjmp_val);
- }
- /*
- * Check to see if the current thread performed a siglongjmp
- * out of a signal handler:
- */
- else if ((_thread_run->jmpflags & JMPFLAGS_SIGLONGJMP) != 0) {
- _thread_run->jmpflags = JMPFLAGS_NONE;
- _thread_run->continuation = NULL;
- __siglongjmp(_thread_run->nested_jmp.sigjmp,
- _thread_run->longjmp_val);
- }
-}
-
-static void
-handle_state_change(pthread_t pthread)
-{
- /*
- * We should only need to handle threads whose state was
- * changed to running:
- */
- if (pthread->state == PS_RUNNING) {
- switch (pthread->oldstate) {
- /*
- * States which do not change when a signal is trapped:
- */
- case PS_DEAD:
- case PS_DEADLOCK:
- case PS_RUNNING:
- case PS_SIGTHREAD:
- case PS_STATE_MAX:
- break;
-
- /*
- * States which need to return to critical sections
- * before they can switch contexts:
- */
- case PS_COND_WAIT:
- case PS_FDLR_WAIT:
- case PS_FDLW_WAIT:
- case PS_FILE_WAIT:
- case PS_JOIN:
- case PS_MUTEX_WAIT:
- /* Indicate that the thread was interrupted: */
- pthread->interrupted = 1;
- /*
- * Defer the [sig|_]longjmp until leaving the critical
- * region:
- */
- pthread->jmpflags |= JMPFLAGS_DEFERRED;
-
- /* Set the continuation routine: */
- pthread->continuation = thread_sig_finish_longjmp;
- /* FALLTHROUGH */
- case PS_FDR_WAIT:
- case PS_FDW_WAIT:
- case PS_POLL_WAIT:
- case PS_SELECT_WAIT:
- case PS_SIGSUSPEND:
- case PS_SIGWAIT:
- case PS_SLEEP_WAIT:
- case PS_SPINBLOCK:
- case PS_SUSPENDED:
- case PS_WAIT_WAIT:
- if ((pthread->flags & PTHREAD_FLAGS_IN_WAITQ) != 0) {
- PTHREAD_WAITQ_REMOVE(pthread);
- if (pthread->flags & PTHREAD_FLAGS_IN_WORKQ)
- PTHREAD_WORKQ_REMOVE(pthread);
- }
- break;
- }
-
- if ((pthread->flags & PTHREAD_FLAGS_IN_PRIOQ) == 0)
- PTHREAD_PRIOQ_INSERT_TAIL(pthread);
- }
-}
-
-
-/* Perform thread specific actions in response to a signal: */
-static void
-thread_sig_check_state(pthread_t pthread, int sig)
-{
- /*
- * Process according to thread state:
- */
- switch (pthread->state) {
- /*
- * States which do not change when a signal is trapped:
- */
- case PS_COND_WAIT:
- case PS_DEAD:
- case PS_DEADLOCK:
- case PS_FILE_WAIT:
- case PS_JOIN:
- case PS_MUTEX_WAIT:
- case PS_RUNNING:
- case PS_STATE_MAX:
- case PS_SIGTHREAD:
- case PS_SPINBLOCK:
- case PS_SUSPENDED:
- /* Increment the pending signal count. */
- sigaddset(&pthread->sigpend,sig);
- break;
-
- case PS_SIGWAIT:
- /* Wake up the thread if the signal is blocked. */
- if (sigismember(pthread->data.sigwait, sig)) {
- /* Change the state of the thread to run: */
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
-
- /* Return the signal number: */
- pthread->signo = sig;
- } else
- /* Increment the pending signal count. */
- sigaddset(&pthread->sigpend,sig);
- break;
-
- /*
- * The wait state is a special case due to the handling of
- * SIGCHLD signals.
- */
- case PS_WAIT_WAIT:
- /*
- * Check for signals other than the death of a child
- * process:
- */
- if (sig != SIGCHLD)
- /* Flag the operation as interrupted: */
- pthread->interrupted = 1;
-
- /* Change the state of the thread to run: */
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
-
- /* Return the signal number: */
- pthread->signo = sig;
- break;
-
- /*
- * States that are interrupted by the occurrence of a signal
- * other than the scheduling alarm:
- */
- case PS_FDLR_WAIT:
- case PS_FDLW_WAIT:
- case PS_FDR_WAIT:
- case PS_FDW_WAIT:
- case PS_POLL_WAIT:
- case PS_SLEEP_WAIT:
- case PS_SELECT_WAIT:
- if ((_thread_sigact[sig - 1].sa_flags & SA_RESTART) == 0) {
- /* Flag the operation as interrupted: */
- pthread->interrupted = 1;
-
- if (pthread->flags & PTHREAD_FLAGS_IN_WORKQ)
- PTHREAD_WORKQ_REMOVE(pthread);
-
- /* Change the state of the thread to run: */
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
-
- /* Return the signal number: */
- pthread->signo = sig;
- }
- break;
-
- case PS_SIGSUSPEND:
- /*
- * Only wake up the thread if there is a handler installed
- * for the signal.
- */
- if (_thread_sigact[sig - 1].sa_handler != SIG_DFL) {
- /* Change the state of the thread to run: */
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
-
- /* Return the signal number: */
- pthread->signo = sig;
- }
- break;
- }
-}
-
-/* Send a signal to a specific thread (ala pthread_kill): */
-void
-_thread_sig_send(pthread_t pthread, int sig)
-{
- /*
- * Check that the signal is not being ignored:
- */
- if (_thread_sigact[sig - 1].sa_handler != SIG_IGN) {
- if (pthread->state == PS_SIGWAIT &&
- sigismember(pthread->data.sigwait, sig)) {
- /* Change the state of the thread to run: */
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
-
- /* Return the signal number: */
- pthread->signo = sig;
- } else if (pthread->state != PS_SIGWAIT &&
- !sigismember(&pthread->sigmask, sig)) {
- /* Perform any state changes due to signal arrival: */
- thread_sig_check_state(pthread, sig);
- }
-
- /* Increment the pending signal count. */
- sigaddset(&pthread->sigpend,sig);
- }
-}
-
-/* Dispatch pending signals to the running thread: */
-void
-_dispatch_signals()
-{
- sigset_t sigset;
- int i;
-
- /*
- * Check if there are pending signals for the running
- * thread or process that aren't blocked:
- */
- sigset = _thread_run->sigpend;
- SIGSETOR(sigset, _process_sigpending);
- SIGSETNAND(sigset, _thread_run->sigmask);
- if (SIGNOTEMPTY(sigset)) {
- /*
- * Enter a loop to calculate deliverable pending signals
- * before actually delivering them. The pending signals
- * must be removed from the pending signal sets before
- * calling the signal handler because the handler may
- * call library routines that again check for and deliver
- * pending signals.
- */
- for (i = 1; i < NSIG; i++) {
- /*
- * Check that a custom handler is installed
- * and if the signal is not blocked:
- */
- if (_thread_sigact[i - 1].sa_handler != SIG_DFL &&
- _thread_sigact[i - 1].sa_handler != SIG_IGN &&
- sigismember(&sigset, i)) {
- if (sigismember(&_thread_run->sigpend,i))
- /* Clear the thread pending signal: */
- sigdelset(&_thread_run->sigpend,i);
- else
- /* Clear the process pending signal: */
- sigdelset(&_process_sigpending,i);
- }
- else
- /* Remove the signal if it can't be handled: */
- sigdelset(&sigset, i);
- }
-
- /* Now deliver the signals: */
- for (i = 1; i < NSIG; i++) {
- if (sigismember(&sigset, i))
- /* Deliver the signal to the running thread: */
- _thread_sig_deliver(_thread_run, i);
- }
- }
-}
-
-/* Deliver a signal to a thread: */
-void
-_thread_sig_deliver(pthread_t pthread, int sig)
-{
- sigset_t mask;
- pthread_t pthread_saved;
- jmp_buf jb, *saved_sighandler_jmp_buf;
-
- /*
- * Check that a custom handler is installed
- * and if the signal is not blocked:
- */
- if (_thread_sigact[sig - 1].sa_handler != SIG_DFL &&
- _thread_sigact[sig - 1].sa_handler != SIG_IGN) {
- /* Save the current thread: */
- pthread_saved = _thread_run;
-
- /* Save the threads signal mask: */
- mask = pthread->sigmask;
-
- /*
- * Add the current signal and signal handler
- * mask to the thread's current signal mask:
- */
- SIGSETOR(pthread->sigmask, _thread_sigact[sig - 1].sa_mask);
- sigaddset(&pthread->sigmask, sig);
-
- /* Current thread inside critical region? */
- if (_thread_run->sig_defer_count > 0)
- pthread->sig_defer_count++;
-
- /* Increment the number of nested signals being handled. */
- pthread->signal_nest_level++;
-
- /*
- * The jump buffer is allocated off the stack and the current
- * jump buffer is saved. If the signal handler tries to
- * [sig|_]longjmp(), our version of [sig|_]longjmp() will copy
- * the user supplied jump buffer into
- * _thread_run->nested_jmp.[sig]jmp and _longjmp() back to here.
- */
- saved_sighandler_jmp_buf = pthread->sighandler_jmp_buf;
- pthread->sighandler_jmp_buf = &jb;
-
- _thread_run = pthread;
-
- if (_setjmp(jb) == 0) {
- /*
- * Dispatch the signal via the custom signal
- * handler:
- */
- (*(_thread_sigact[sig - 1].sa_handler))(sig);
- }
-
- _thread_run = pthread_saved;
-
- pthread->sighandler_jmp_buf = saved_sighandler_jmp_buf;
-
- /* Decrement the signal nest level. */
- pthread->signal_nest_level--;
-
- /* Current thread inside critical region? */
- if (_thread_run->sig_defer_count > 0)
- pthread->sig_defer_count--;
-
- /* Restore the threads signal mask: */
- pthread->sigmask = mask;
- }
-}
-#endif
diff --git a/lib/libkse/thread/thr_sigaction.c b/lib/libkse/thread/thr_sigaction.c
deleted file mode 100644
index 319999bf3047..000000000000
--- a/lib/libkse/thread/thr_sigaction.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <signal.h>
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-_sigaction(int sig, const struct sigaction * act, struct sigaction * oact)
-{
- int ret = 0;
- struct sigaction gact;
-
- /* Check if the signal number is out of range: */
- if (sig < 1 || sig > NSIG) {
- /* Return an invalid argument: */
- errno = EINVAL;
- ret = -1;
- } else {
- /*
- * Check if the existing signal action structure contents are
- * to be returned:
- */
- if (oact != NULL) {
- /* Return the existing signal action contents: */
- oact->sa_handler = _thread_sigact[sig - 1].sa_handler;
- oact->sa_mask = _thread_sigact[sig - 1].sa_mask;
- oact->sa_flags = _thread_sigact[sig - 1].sa_flags;
- }
-
- /* Check if a signal action was supplied: */
- if (act != NULL) {
- /* Set the new signal handler: */
- _thread_sigact[sig - 1].sa_mask = act->sa_mask;
- _thread_sigact[sig - 1].sa_flags = act->sa_flags;
- _thread_sigact[sig - 1].sa_handler = act->sa_handler;
- }
-
- /*
- * Check if the kernel needs to be advised of a change
- * in signal action:
- */
- if (act != NULL && sig != _SCHED_SIGNAL && sig != SIGCHLD &&
- sig != SIGINFO) {
- /* Initialise the global signal action structure: */
- gact.sa_mask = act->sa_mask;
- gact.sa_flags = 0;
-
- /* Ensure the scheduling signal is masked: */
- sigaddset(&gact.sa_mask, _SCHED_SIGNAL);
-
- /*
- * Check if the signal handler is being set to
- * the default or ignore handlers:
- */
- if (act->sa_handler == SIG_DFL ||
- act->sa_handler == SIG_IGN)
- /* Specify the built in handler: */
- gact.sa_handler = act->sa_handler;
- else
- /*
- * Specify the thread kernel signal
- * handler:
- */
- gact.sa_handler = (void (*) ()) _thread_sig_handler;
-
- /* Change the signal action in the kernel: */
- if (_thread_sys_sigaction(sig,&gact,NULL) != 0)
- ret = -1;
- }
- }
-
- /* Return the completion status: */
- return (ret);
-}
-
-__strong_reference(_sigaction, sigaction);
-#endif
diff --git a/lib/libkse/thread/thr_sigmask.c b/lib/libkse/thread/thr_sigmask.c
deleted file mode 100644
index b880d9c748c8..000000000000
--- a/lib/libkse/thread/thr_sigmask.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/signalvar.h>
-#include <errno.h>
-#include <signal.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_sigmask(int how, const sigset_t *set, sigset_t *oset)
-{
- int ret = 0;
-
- /* Check if the existing signal process mask is to be returned: */
- if (oset != NULL) {
- /* Return the current mask: */
- *oset = _thread_run->sigmask;
- }
- /* Check if a new signal set was provided by the caller: */
- if (set != NULL) {
- /* Process according to what to do: */
- switch (how) {
- /* Block signals: */
- case SIG_BLOCK:
- /* Add signals to the existing mask: */
- SIGSETOR(_thread_run->sigmask, *set);
- break;
-
- /* Unblock signals: */
- case SIG_UNBLOCK:
- /* Clear signals from the existing mask: */
- SIGSETNAND(_thread_run->sigmask, *set);
- break;
-
- /* Set the signal process mask: */
- case SIG_SETMASK:
- /* Set the new mask: */
- _thread_run->sigmask = *set;
- break;
-
- /* Trap invalid actions: */
- default:
- /* Return an invalid argument: */
- errno = EINVAL;
- ret = -1;
- break;
- }
-
- /*
- * Dispatch signals to the running thread that are pending
- * and now unblocked:
- */
- _dispatch_signals();
- }
-
- /* Return the completion status: */
- return (ret);
-}
-#endif
diff --git a/lib/libkse/thread/thr_sigpending.c b/lib/libkse/thread/thr_sigpending.c
deleted file mode 100644
index a118347ca974..000000000000
--- a/lib/libkse/thread/thr_sigpending.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 1999 Daniel Eischen <eischen@vigrid.com>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <signal.h>
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-_sigpending(sigset_t * set)
-{
- int ret = 0;
-
- /* Check for a null signal set pointer: */
- if (set == NULL) {
- /* Return an invalid argument: */
- ret = EINVAL;
- }
- else {
- *set = _thread_run->sigpend;
- }
- /* Return the completion status: */
- return (ret);
-}
-
-__strong_reference(_sigpending, sigpending);
-#endif
diff --git a/lib/libkse/thread/thr_sigprocmask.c b/lib/libkse/thread/thr_sigprocmask.c
deleted file mode 100644
index 6addb4a948e9..000000000000
--- a/lib/libkse/thread/thr_sigprocmask.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/signalvar.h>
-#include <signal.h>
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-_sigprocmask(int how, const sigset_t * set, sigset_t * oset)
-{
- int ret = 0;
-
- /* Check if the existing signal process mask is to be returned: */
- if (oset != NULL) {
- /* Return the current mask: */
- *oset = _thread_run->sigmask;
- }
- /* Check if a new signal set was provided by the caller: */
- if (set != NULL) {
- /* Process according to what to do: */
- switch (how) {
- /* Block signals: */
- case SIG_BLOCK:
- /* Add signals to the existing mask: */
- SIGSETOR(_thread_run->sigmask, *set);
- break;
-
- /* Unblock signals: */
- case SIG_UNBLOCK:
- /* Clear signals from the existing mask: */
- SIGSETNAND(_thread_run->sigmask, *set);
- break;
-
- /* Set the signal process mask: */
- case SIG_SETMASK:
- /* Set the new mask: */
- _thread_run->sigmask = *set;
- break;
-
- /* Trap invalid actions: */
- default:
- /* Return an invalid argument: */
- errno = EINVAL;
- ret = -1;
- break;
- }
-
- /*
- * Dispatch signals to the running thread that are pending
- * and now unblocked:
- */
- _dispatch_signals();
- }
- /* Return the completion status: */
- return (ret);
-}
-
-__strong_reference(_sigprocmask, sigprocmask);
-#endif
diff --git a/lib/libkse/thread/thr_sigsuspend.c b/lib/libkse/thread/thr_sigsuspend.c
deleted file mode 100644
index 28959c8e094a..000000000000
--- a/lib/libkse/thread/thr_sigsuspend.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <signal.h>
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-_sigsuspend(const sigset_t * set)
-{
- int ret = -1;
- sigset_t oset;
-
- /* Check if a new signal set was provided by the caller: */
- if (set != NULL) {
- /* Save the current signal mask: */
- oset = _thread_run->sigmask;
-
- /* Change the caller's mask: */
- _thread_run->sigmask = *set;
-
- /* Wait for a signal: */
- _thread_kern_sched_state(PS_SIGSUSPEND, __FILE__, __LINE__);
-
- /* Always return an interrupted error: */
- errno = EINTR;
-
- /* Restore the signal mask: */
- _thread_run->sigmask = oset;
- } else {
- /* Return an invalid argument error: */
- errno = EINVAL;
- }
-
- /* Return the completion status: */
- return (ret);
-}
-
-int
-sigsuspend(const sigset_t * set)
-{
- int ret;
-
- _thread_enter_cancellation_point();
- ret = _sigsuspend(set);
- _thread_leave_cancellation_point();
-
- return ret;
-}
-#endif
diff --git a/lib/libkse/thread/thr_sigwait.c b/lib/libkse/thread/thr_sigwait.c
deleted file mode 100644
index a50968768082..000000000000
--- a/lib/libkse/thread/thr_sigwait.c
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <signal.h>
-#include <sys/param.h>
-#include <sys/signalvar.h>
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-sigwait(const sigset_t * set, int *sig)
-{
- int ret = 0;
- int i;
- sigset_t tempset, waitset;
- struct sigaction act;
-
- _thread_enter_cancellation_point();
- /*
- * Specify the thread kernel signal handler.
- */
- act.sa_handler = (void (*) ()) _thread_sig_handler;
- act.sa_flags = SA_RESTART;
- act.sa_mask = *set;
-
- /* Ensure the scheduling signal is masked: */
- sigaddset(&act.sa_mask, _SCHED_SIGNAL);
-
- /*
- * Initialize the set of signals that will be waited on:
- */
- waitset = *set;
-
- /* These signals can't be waited on. */
- sigdelset(&waitset, SIGKILL);
- sigdelset(&waitset, SIGSTOP);
- sigdelset(&waitset, _SCHED_SIGNAL);
- sigdelset(&waitset, SIGCHLD);
- sigdelset(&waitset, SIGINFO);
-
- /* Check to see if a pending signal is in the wait mask. */
- tempset = _thread_run->sigpend;
- SIGSETOR(tempset, _process_sigpending);
- SIGSETAND(tempset, waitset);
- if (SIGNOTEMPTY(tempset)) {
- /* Enter a loop to find a pending signal: */
- for (i = 1; i < NSIG; i++) {
- if (sigismember (&tempset, i))
- break;
- }
-
- /* Clear the pending signal: */
- if (sigismember(&_thread_run->sigpend,i))
- sigdelset(&_thread_run->sigpend,i);
- else
- sigdelset(&_process_sigpending,i);
-
- /* Return the signal number to the caller: */
- *sig = i;
-
- _thread_leave_cancellation_point();
- return (0);
- }
-
- /*
- * Enter a loop to find the signals that are SIG_DFL. For
- * these signals we must install a dummy signal handler in
- * order for the kernel to pass them in to us. POSIX says
- * that the _application_ must explicitly install a dummy
- * handler for signals that are SIG_IGN in order to sigwait
- * on them. Note that SIG_IGN signals are left in the
- * mask because a subsequent sigaction could enable an
- * ignored signal.
- */
- for (i = 1; i < NSIG; i++) {
- if (sigismember(&waitset, i) &&
- (_thread_sigact[i - 1].sa_handler == SIG_DFL)) {
- if (_thread_sys_sigaction(i,&act,NULL) != 0)
- ret = -1;
- }
- }
- if (ret == 0) {
- /*
- * Save the wait signal mask. The wait signal
- * mask is independent of the threads signal mask
- * and requires separate storage.
- */
- _thread_run->data.sigwait = &waitset;
-
- /* Wait for a signal: */
- _thread_kern_sched_state(PS_SIGWAIT, __FILE__, __LINE__);
-
- /* Return the signal number to the caller: */
- *sig = _thread_run->signo;
-
- /*
- * Probably unnecessary, but since it's in a union struct
- * we don't know how it could be used in the future.
- */
- _thread_run->data.sigwait = NULL;
- }
-
- /* Restore the sigactions: */
- act.sa_handler = SIG_DFL;
- for (i = 1; i < NSIG; i++) {
- if (sigismember(&waitset, i) &&
- (_thread_sigact[i - 1].sa_handler == SIG_DFL)) {
- if (_thread_sys_sigaction(i,&act,NULL) != 0)
- ret = -1;
- }
- }
-
- _thread_leave_cancellation_point();
-
- /* Return the completion status: */
- return (ret);
-}
-#endif
diff --git a/lib/libkse/thread/thr_single_np.c b/lib/libkse/thread/thr_single_np.c
deleted file mode 100644
index d6ecb48b4259..000000000000
--- a/lib/libkse/thread/thr_single_np.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <string.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int pthread_single_np()
-{
- /* Enter single-threaded (non-POSIX) scheduling mode: */
- _thread_single = _thread_run;
- return(0);
-}
-#endif
diff --git a/lib/libkse/thread/thr_sleep.c b/lib/libkse/thread/thr_sleep.c
deleted file mode 100644
index 34a592587024..000000000000
--- a/lib/libkse/thread/thr_sleep.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2000 Jason Evans <jasone@canonware.com>.
- * 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(s), this list of conditions and the following disclaimer as
- * the first lines of this file unmodified other than the possible
- * addition of one or more copyright notices.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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.
- *
- * $FreeBSD$
- */
-
-#include <unistd.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-unsigned int
-sleep(unsigned int seconds)
-{
- unsigned int ret;
-
- _thread_enter_cancellation_point();
- ret = __sleep(seconds);
- _thread_leave_cancellation_point();
-
- return ret;
-}
-#endif
diff --git a/lib/libkse/thread/thr_spec.c b/lib/libkse/thread/thr_spec.c
deleted file mode 100644
index 1485cbb7e9d9..000000000000
--- a/lib/libkse/thread/thr_spec.c
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <signal.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-/* Static variables: */
-static struct pthread_key key_table[PTHREAD_KEYS_MAX];
-
-int
-pthread_key_create(pthread_key_t * key, void (*destructor) (void *))
-{
- for ((*key) = 0; (*key) < PTHREAD_KEYS_MAX; (*key)++) {
- /* Lock the key table entry: */
- _SPINLOCK(&key_table[*key].lock);
-
- if (key_table[(*key)].allocated == 0) {
- key_table[(*key)].allocated = 1;
- key_table[(*key)].destructor = destructor;
-
- /* Unlock the key table entry: */
- _SPINUNLOCK(&key_table[*key].lock);
- return (0);
- }
-
- /* Unlock the key table entry: */
- _SPINUNLOCK(&key_table[*key].lock);
- }
- return (EAGAIN);
-}
-
-int
-pthread_key_delete(pthread_key_t key)
-{
- int ret = 0;
-
- if (key < PTHREAD_KEYS_MAX) {
- /* Lock the key table entry: */
- _SPINLOCK(&key_table[key].lock);
-
- if (key_table[key].allocated)
- key_table[key].allocated = 0;
- else
- ret = EINVAL;
-
- /* Unlock the key table entry: */
- _SPINUNLOCK(&key_table[key].lock);
- } else
- ret = EINVAL;
- return (ret);
-}
-
-void
-_thread_cleanupspecific(void)
-{
- void *data = NULL;
- int key;
- int itr;
- void (*destructor)( void *);
-
- for (itr = 0; itr < PTHREAD_DESTRUCTOR_ITERATIONS; itr++) {
- for (key = 0; key < PTHREAD_KEYS_MAX; key++) {
- if (_thread_run->specific_data_count) {
- /* Lock the key table entry: */
- _SPINLOCK(&key_table[key].lock);
- destructor = NULL;
-
- if (key_table[key].allocated) {
- if (_thread_run->specific_data[key]) {
- data = (void *) _thread_run->specific_data[key];
- _thread_run->specific_data[key] = NULL;
- _thread_run->specific_data_count--;
- destructor = key_table[key].destructor;
- }
- }
-
- /* Unlock the key table entry: */
- _SPINUNLOCK(&key_table[key].lock);
-
- /*
- * If there is a destructore, call it
- * with the key table entry unlocked:
- */
- if (destructor)
- destructor(data);
- } else {
- free(_thread_run->specific_data);
- _thread_run->specific_data = NULL;
- return;
- }
- }
- }
- free(_thread_run->specific_data);
- _thread_run->specific_data = NULL;
-}
-
-static inline const void **
-pthread_key_allocate_data(void)
-{
- const void **new_data;
- if ((new_data = (const void **) malloc(sizeof(void *) * PTHREAD_KEYS_MAX)) != NULL) {
- memset((void *) new_data, 0, sizeof(void *) * PTHREAD_KEYS_MAX);
- }
- return (new_data);
-}
-
-int
-pthread_setspecific(pthread_key_t key, const void *value)
-{
- pthread_t pthread;
- int ret = 0;
-
- /* Point to the running thread: */
- pthread = _thread_run;
-
- if ((pthread->specific_data) ||
- (pthread->specific_data = pthread_key_allocate_data())) {
- if (key < PTHREAD_KEYS_MAX) {
- if (key_table[key].allocated) {
- if (pthread->specific_data[key] == NULL) {
- if (value != NULL)
- pthread->specific_data_count++;
- } else {
- if (value == NULL)
- pthread->specific_data_count--;
- }
- pthread->specific_data[key] = value;
- ret = 0;
- } else
- ret = EINVAL;
- } else
- ret = EINVAL;
- } else
- ret = ENOMEM;
- return (ret);
-}
-
-void *
-pthread_getspecific(pthread_key_t key)
-{
- pthread_t pthread;
- void *data;
-
- /* Point to the running thread: */
- pthread = _thread_run;
-
- /* Check if there is specific data: */
- if (pthread->specific_data != NULL && key < PTHREAD_KEYS_MAX) {
- /* Check if this key has been used before: */
- if (key_table[key].allocated) {
- /* Return the value: */
- data = (void *) pthread->specific_data[key];
- } else {
- /*
- * This key has not been used before, so return NULL
- * instead:
- */
- data = NULL;
- }
- } else
- /* No specific data has been created, so just return NULL: */
- data = NULL;
- return (data);
-}
-#endif
diff --git a/lib/libkse/thread/thr_spinlock.c b/lib/libkse/thread/thr_spinlock.c
deleted file mode 100644
index e797f90a90fa..000000000000
--- a/lib/libkse/thread/thr_spinlock.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- *
- */
-
-#include <stdio.h>
-#include <sched.h>
-#include <unistd.h>
-#include <pthread.h>
-#include <string.h>
-#include "pthread_private.h"
-
-extern char *__progname;
-
-/*
- * Lock a location for the running thread. Yield to allow other
- * threads to run if this thread is blocked because the lock is
- * not available. Note that this function does not sleep. It
- * assumes that the lock will be available very soon.
- */
-void
-_spinlock(spinlock_t *lck)
-{
- /*
- * Try to grab the lock and loop if another thread grabs
- * it before we do.
- */
- while(_atomic_lock(&lck->access_lock)) {
- /* Block the thread until the lock. */
- _thread_run->data.spinlock = lck;
- _thread_kern_sched_state(PS_SPINBLOCK, __FILE__, __LINE__);
- }
-
- /* The running thread now owns the lock: */
- lck->lock_owner = (long) _thread_run;
-}
-
-/*
- * Lock a location for the running thread. Yield to allow other
- * threads to run if this thread is blocked because the lock is
- * not available. Note that this function does not sleep. It
- * assumes that the lock will be available very soon.
- *
- * This function checks if the running thread has already locked the
- * location, warns if this occurs and creates a thread dump before
- * returning.
- */
-void
-_spinlock_debug(spinlock_t *lck, char *fname, int lineno)
-{
- int cnt = 0;
-
- /*
- * Try to grab the lock and loop if another thread grabs
- * it before we do.
- */
- while(_atomic_lock(&lck->access_lock)) {
- cnt++;
- if (cnt > 100) {
- char str[256];
- snprintf(str, sizeof(str), "%s - Warning: Thread %p attempted to lock %p from %s (%d) was left locked from %s (%d)\n", __progname, _thread_run, lck, fname, lineno, lck->fname, lck->lineno);
- _thread_sys_write(2,str,strlen(str));
- __sleep(1);
- cnt = 0;
- }
-
- /* Block the thread until the lock. */
- _thread_run->data.spinlock = lck;
- _thread_kern_sched_state(PS_SPINBLOCK, fname, lineno);
- }
-
- /* The running thread now owns the lock: */
- lck->lock_owner = (long) _thread_run;
- lck->fname = fname;
- lck->lineno = lineno;
-}
diff --git a/lib/libkse/thread/thr_suspend_np.c b/lib/libkse/thread/thr_suspend_np.c
deleted file mode 100644
index ea9b1f857af5..000000000000
--- a/lib/libkse/thread/thr_suspend_np.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-/* Suspend a thread: */
-int
-pthread_suspend_np(pthread_t thread)
-{
- int ret;
-
- /* Find the thread in the list of active threads: */
- if ((ret = _find_thread(thread)) == 0) {
- /* The thread exists. Is it running? */
- if (thread->state != PS_RUNNING &&
- thread->state != PS_SUSPENDED) {
- /* The thread operation has been interrupted */
- _thread_seterrno(thread,EINTR);
- thread->interrupted = 1;
- }
-
- /*
- * Defer signals to protect the scheduling queues from
- * access by the signal handler:
- */
- _thread_kern_sig_defer();
-
- /* Suspend the thread. */
- PTHREAD_NEW_STATE(thread,PS_SUSPENDED);
-
- /*
- * Undefer and handle pending signals, yielding if
- * necessary:
- */
- _thread_kern_sig_undefer();
- }
- return(ret);
-}
-#endif
diff --git a/lib/libkse/thread/thr_switch_np.c b/lib/libkse/thread/thr_switch_np.c
deleted file mode 100644
index 9b83545fdd7e..000000000000
--- a/lib/libkse/thread/thr_switch_np.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>.
- * 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 Daniel Eischen.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include <pthread_np.h>
-#include "pthread_private.h"
-
-
-int
-pthread_switch_add_np(pthread_switch_routine_t routine)
-{
- int ret = 0;
-
- if (routine == NULL)
- /* Return an invalid argument error: */
- ret = EINVAL;
- else
- /* Shouldn't need a lock to protect this assigment. */
- _sched_switch_hook = routine;
-
- return(ret);
-}
-
-int
-pthread_switch_delete_np(pthread_switch_routine_t routine)
-{
- int ret = 0;
-
- if (routine != _sched_switch_hook)
- /* Return an invalid argument error: */
- ret = EINVAL;
- else
- /* Shouldn't need a lock to protect this assigment. */
- _sched_switch_hook = NULL;
-
- return(ret);
-}
-#endif
diff --git a/lib/libkse/thread/thr_system.c b/lib/libkse/thread/thr_system.c
deleted file mode 100644
index 9265975b0a0f..000000000000
--- a/lib/libkse/thread/thr_system.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2000 Jason Evans <jasone@canonware.com>.
- * 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(s), this list of conditions and the following disclaimer as
- * the first lines of this file unmodified other than the possible
- * addition of one or more copyright notices.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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.
- *
- * $FreeBSD$
- */
-
-#include <stdlib.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-system(const char *string)
-{
- int ret;
-
- _thread_enter_cancellation_point();
- ret = __system(string);
- _thread_leave_cancellation_point();
-
- return ret;
-}
-#endif
diff --git a/lib/libkse/thread/thr_tcdrain.c b/lib/libkse/thread/thr_tcdrain.c
deleted file mode 100644
index d040599ed521..000000000000
--- a/lib/libkse/thread/thr_tcdrain.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2000 Jason Evans <jasone@canonware.com>.
- * 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(s), this list of conditions and the following disclaimer as
- * the first lines of this file unmodified other than the possible
- * addition of one or more copyright notices.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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.
- *
- * $FreeBSD$
- */
-
-#include <termios.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-tcdrain(int fd)
-{
- int ret;
-
- _thread_enter_cancellation_point();
- ret = __tcdrain(fd);
- _thread_leave_cancellation_point();
-
- return ret;
-}
-#endif
diff --git a/lib/libkse/thread/thr_vfork.c b/lib/libkse/thread/thr_vfork.c
deleted file mode 100644
index bbfcf002bc02..000000000000
--- a/lib/libkse/thread/thr_vfork.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <unistd.h>
-#ifdef _THREAD_SAFE
-
-int
-vfork(void)
-{
- return (fork());
-}
-#endif
diff --git a/lib/libkse/thread/thr_wait.c b/lib/libkse/thread/thr_wait.c
deleted file mode 100644
index abc19cc7cc04..000000000000
--- a/lib/libkse/thread/thr_wait.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2000 Jason Evans <jasone@canonware.com>.
- * 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(s), this list of conditions and the following disclaimer as
- * the first lines of this file unmodified other than the possible
- * addition of one or more copyright notices.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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.
- *
- * $FreeBSD$
- */
-
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-pid_t
-wait(int *istat)
-{
- pid_t ret;
-
- _thread_enter_cancellation_point();
- ret = __wait(istat);
- _thread_leave_cancellation_point();
-
- return ret;
-}
-#endif
diff --git a/lib/libkse/thread/thr_wait4.c b/lib/libkse/thread/thr_wait4.c
deleted file mode 100644
index 083c230ec88c..000000000000
--- a/lib/libkse/thread/thr_wait4.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#include <sys/wait.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-pid_t
-_wait4(pid_t pid, int *istat, int options, struct rusage * rusage)
-{
- pid_t ret;
-
- _thread_kern_sig_defer();
-
- /* Perform a non-blocking wait4 syscall: */
- while ((ret = _thread_sys_wait4(pid, istat, options | WNOHANG, rusage)) == 0 && (options & WNOHANG) == 0) {
- /* Reset the interrupted operation flag: */
- _thread_run->interrupted = 0;
-
- /* Schedule the next thread while this one waits: */
- _thread_kern_sched_state(PS_WAIT_WAIT, __FILE__, __LINE__);
-
- /* Check if this call was interrupted by a signal: */
- if (_thread_run->interrupted) {
- errno = EINTR;
- ret = -1;
- break;
- }
- }
-
- _thread_kern_sig_undefer();
-
- return (ret);
-}
-
-__strong_reference(_wait4, wait4);
-#endif
diff --git a/lib/libkse/thread/thr_waitpid.c b/lib/libkse/thread/thr_waitpid.c
deleted file mode 100644
index a8472959e741..000000000000
--- a/lib/libkse/thread/thr_waitpid.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2000 Jason Evans <jasone@canonware.com>.
- * 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(s), this list of conditions and the following disclaimer as
- * the first lines of this file unmodified other than the possible
- * addition of one or more copyright notices.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/types.h>
-#include <sys/wait.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-pid_t
-waitpid(pid_t wpid, int *status, int options)
-{
- pid_t ret;
-
- _thread_enter_cancellation_point();
- ret = __waitpid(wpid, status, options);
- _thread_leave_cancellation_point();
-
- return ret;
-}
-#endif
diff --git a/lib/libkse/thread/thr_write.c b/lib/libkse/thread/thr_write.c
deleted file mode 100644
index 6408a64830c2..000000000000
--- a/lib/libkse/thread/thr_write.c
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- *
- */
-#include <sys/types.h>
-#include <sys/fcntl.h>
-#include <sys/uio.h>
-#include <errno.h>
-#include <unistd.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-ssize_t
-_write(int fd, const void *buf, size_t nbytes)
-{
- int blocking;
- int type;
- ssize_t n;
- ssize_t num = 0;
- ssize_t ret;
-
- /* POSIX says to do just this: */
- if (nbytes == 0)
- return (0);
-
- /* Lock the file descriptor for write: */
- if ((ret = _FD_LOCK(fd, FD_WRITE, NULL)) == 0) {
- /* Get the read/write mode type: */
- type = _thread_fd_table[fd]->flags & O_ACCMODE;
-
- /* Check if the file is not open for write: */
- if (type != O_WRONLY && type != O_RDWR) {
- /* File is not open for write: */
- errno = EBADF;
- _FD_UNLOCK(fd, FD_WRITE);
- return (-1);
- }
-
- /* Check if file operations are to block */
- blocking = ((_thread_fd_table[fd]->flags & O_NONBLOCK) == 0);
-
- /*
- * Loop while no error occurs and until the expected number
- * of bytes are written if performing a blocking write:
- */
- while (ret == 0) {
- /* Perform a non-blocking write syscall: */
- n = _thread_sys_write(fd, buf + num, nbytes - num);
-
- /* Check if one or more bytes were written: */
- if (n > 0)
- /*
- * Keep a count of the number of bytes
- * written:
- */
- num += n;
-
- /*
- * If performing a blocking write, check if the
- * write would have blocked or if some bytes
- * were written but there are still more to
- * write:
- */
- if (blocking && ((n < 0 && (errno == EWOULDBLOCK ||
- errno == EAGAIN)) || (n >= 0 && num < nbytes))) {
- _thread_run->data.fd.fd = fd;
- _thread_kern_set_timeout(NULL);
-
- /* Reset the interrupted operation flag: */
- _thread_run->interrupted = 0;
-
- _thread_kern_sched_state(PS_FDW_WAIT,
- __FILE__, __LINE__);
-
- /*
- * Check if the operation was
- * interrupted by a signal
- */
- if (_thread_run->interrupted) {
- /* Return an error: */
- ret = -1;
- }
-
- /*
- * If performing a non-blocking write or if an
- * error occurred, just return whatever the write
- * syscall did:
- */
- } else if (!blocking || n < 0) {
- /* A non-blocking call might return zero: */
- ret = n;
- break;
-
- /* Check if the write has completed: */
- } else if (num >= nbytes)
- /* Return the number of bytes written: */
- ret = num;
- }
- _FD_UNLOCK(fd, FD_RDWR);
- }
- return (ret);
-}
-
-ssize_t
-write(int fd, const void *buf, size_t nbytes)
-{
- ssize_t ret;
-
- _thread_enter_cancellation_point();
- ret = _write(fd, buf, nbytes);
- _thread_leave_cancellation_point();
-
- return ret;
-}
-#endif
diff --git a/lib/libkse/thread/thr_writev.c b/lib/libkse/thread/thr_writev.c
deleted file mode 100644
index 5f3146887765..000000000000
--- a/lib/libkse/thread/thr_writev.c
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- *
- */
-#include <sys/types.h>
-#include <sys/fcntl.h>
-#include <sys/uio.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-ssize_t
-_writev(int fd, const struct iovec * iov, int iovcnt)
-{
- int blocking;
- int idx = 0;
- int type;
- ssize_t cnt;
- ssize_t n;
- ssize_t num = 0;
- ssize_t ret;
- struct iovec liov[20];
- struct iovec *p_iov = liov;
-
- /* Check if the array size exceeds to compiled in size: */
- if (iovcnt > (sizeof(liov) / sizeof(struct iovec))) {
- /* Allocate memory for the local array: */
- if ((p_iov = (struct iovec *)
- malloc(iovcnt * sizeof(struct iovec))) == NULL) {
- /* Insufficient memory: */
- errno = ENOMEM;
- return (-1);
- }
- }
-
- /* Copy the caller's array so that it can be modified locally: */
- memcpy(p_iov,iov,iovcnt * sizeof(struct iovec));
-
- /* Lock the file descriptor for write: */
- if ((ret = _FD_LOCK(fd, FD_WRITE, NULL)) == 0) {
- /* Get the read/write mode type: */
- type = _thread_fd_table[fd]->flags & O_ACCMODE;
-
- /* Check if the file is not open for write: */
- if (type != O_WRONLY && type != O_RDWR) {
- /* File is not open for write: */
- errno = EBADF;
- _FD_UNLOCK(fd, FD_WRITE);
- return (-1);
- }
-
- /* Check if file operations are to block */
- blocking = ((_thread_fd_table[fd]->flags & O_NONBLOCK) == 0);
-
- /*
- * Loop while no error occurs and until the expected number
- * of bytes are written if performing a blocking write:
- */
- while (ret == 0) {
- /* Perform a non-blocking write syscall: */
- n = _thread_sys_writev(fd, &p_iov[idx], iovcnt - idx);
-
- /* Check if one or more bytes were written: */
- if (n > 0) {
- /*
- * Keep a count of the number of bytes
- * written:
- */
- num += n;
-
- /*
- * Enter a loop to check if a short write
- * occurred and move the index to the
- * array entry where the short write
- * ended:
- */
- cnt = n;
- while (cnt > 0 && idx < iovcnt) {
- /*
- * If the residual count exceeds
- * the size of this vector, then
- * it was completely written:
- */
- if (cnt >= p_iov[idx].iov_len)
- /*
- * Decrement the residual
- * count and increment the
- * index to the next array
- * entry:
- */
- cnt -= p_iov[idx++].iov_len;
- else {
- /*
- * This entry was only
- * partially written, so
- * adjust it's length
- * and base pointer ready
- * for the next write:
- */
- p_iov[idx].iov_len -= cnt;
- p_iov[idx].iov_base += cnt;
- cnt = 0;
- }
- }
- } else if (n == 0) {
- /*
- * Avoid an infinite loop if the last iov_len is
- * 0.
- */
- while (idx < iovcnt && p_iov[idx].iov_len == 0)
- idx++;
-
- if (idx == iovcnt) {
- ret = num;
- break;
- }
- }
-
- /*
- * If performing a blocking write, check if the
- * write would have blocked or if some bytes
- * were written but there are still more to
- * write:
- */
- if (blocking && ((n < 0 && (errno == EWOULDBLOCK ||
- errno == EAGAIN)) || (n >= 0 && idx < iovcnt))) {
- _thread_run->data.fd.fd = fd;
- _thread_kern_set_timeout(NULL);
-
- /* Reset the interrupted operation flag: */
- _thread_run->interrupted = 0;
-
- _thread_kern_sched_state(PS_FDW_WAIT,
- __FILE__, __LINE__);
-
- /*
- * Check if the operation was
- * interrupted by a signal
- */
- if (_thread_run->interrupted) {
- /* Return an error: */
- ret = -1;
- }
-
- /*
- * If performing a non-blocking write or if an
- * error occurred, just return whatever the write
- * syscall did:
- */
- } else if (!blocking || n < 0) {
- /* A non-blocking call might return zero: */
- ret = n;
- break;
-
- /* Check if the write has completed: */
- } else if (idx == iovcnt)
- /* Return the number of bytes written: */
- ret = num;
- }
- _FD_UNLOCK(fd, FD_RDWR);
- }
-
- /* If memory was allocated for the array, free it: */
- if (p_iov != liov)
- free(p_iov);
-
- return (ret);
-}
-
-__strong_reference(_writev, writev);
-#endif
diff --git a/lib/libkse/thread/thr_yield.c b/lib/libkse/thread/thr_yield.c
deleted file mode 100644
index 064dd826d34c..000000000000
--- a/lib/libkse/thread/thr_yield.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-sched_yield(void)
-{
- /* Reset the accumulated time slice value for the current thread: */
- _thread_run->slice_usec = -1;
-
- /* Schedule the next thread: */
- _thread_kern_sched(NULL);
-
- /* Always return no error. */
- return(0);
-}
-
-/* Draft 4 yield */
-void
-pthread_yield(void)
-{
- /* Reset the accumulated time slice value for the current thread: */
- _thread_run->slice_usec = -1;
-
- /* Schedule the next thread: */
- _thread_kern_sched(NULL);
-
- /* Nothing to return. */
- return;
-}
-#endif
diff --git a/lib/libkvm/kvm_amd64.c b/lib/libkvm/kvm_amd64.c
deleted file mode 100644
index 0b727fd59dd7..000000000000
--- a/lib/libkvm/kvm_amd64.c
+++ /dev/null
@@ -1,198 +0,0 @@
-/*-
- * Copyright (c) 1989, 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software developed by the Computer Systems
- * Engineering group at Lawrence Berkeley Laboratory under DARPA contract
- * BG 91-66 and contributed to Berkeley.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-#if 0
-static char sccsid[] = "@(#)kvm_hp300.c 8.1 (Berkeley) 6/4/93";
-#else
-static const char rcsid[] =
- "$FreeBSD$";
-#endif
-#endif /* LIBC_SCCS and not lint */
-
-/*
- * i386 machine dependent routines for kvm. Hopefully, the forthcoming
- * vm code will one day obsolete this module.
- */
-
-#include <sys/param.h>
-#include <sys/user.h>
-#include <sys/proc.h>
-#include <sys/stat.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <nlist.h>
-#include <kvm.h>
-
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-
-#include <limits.h>
-
-#include "kvm_private.h"
-
-#ifndef btop
-#define btop(x) (i386_btop(x))
-#define ptob(x) (i386_ptob(x))
-#endif
-
-struct vmstate {
- pd_entry_t *PTD;
-};
-
-void
-_kvm_freevtop(kvm_t *kd)
-{
- if (kd->vmst != 0) {
- if (kd->vmst->PTD) {
- free(kd->vmst->PTD);
- }
- free(kd->vmst);
- }
-}
-
-int
-_kvm_initvtop(kvm_t *kd)
-{
- struct vmstate *vm;
- struct nlist nlist[2];
- u_long pa;
- pd_entry_t *PTD;
-
- vm = (struct vmstate *)_kvm_malloc(kd, sizeof(*vm));
- if (vm == 0) {
- _kvm_err(kd, kd->program, "cannot allocate vm");
- return (-1);
- }
- kd->vmst = vm;
- vm->PTD = 0;
-
- nlist[0].n_name = "_IdlePTD";
- nlist[1].n_name = 0;
-
- if (kvm_nlist(kd, nlist) != 0) {
- _kvm_err(kd, kd->program, "bad namelist");
- return (-1);
- }
- if (kvm_read(kd, (nlist[0].n_value - KERNBASE), &pa, sizeof(pa)) != sizeof(pa)) {
- _kvm_err(kd, kd->program, "cannot read IdlePTD");
- return (-1);
- }
- PTD = _kvm_malloc(kd, PAGE_SIZE);
- if (kvm_read(kd, pa, PTD, PAGE_SIZE) != PAGE_SIZE) {
- _kvm_err(kd, kd->program, "cannot read PTD");
- return (-1);
- }
- vm->PTD = PTD;
- return (0);
-}
-
-static int
-_kvm_vatop(kvm_t *kd, u_long va, u_long *pa)
-{
- struct vmstate *vm;
- u_long offset;
- u_long pte_pa;
- pd_entry_t pde;
- pt_entry_t pte;
- u_long pdeindex;
- u_long pteindex;
- int i;
-
- if (ISALIVE(kd)) {
- _kvm_err(kd, 0, "vatop called in live kernel!");
- return((off_t)0);
- }
-
- vm = kd->vmst;
- offset = va & (PAGE_SIZE - 1);
-
- /*
- * If we are initializing (kernel page table descriptor pointer
- * not yet set) then return pa == va to avoid infinite recursion.
- */
- if (vm->PTD == 0) {
- *pa = va;
- return (PAGE_SIZE - offset);
- }
-
- pdeindex = va >> PDRSHIFT;
- pde = vm->PTD[pdeindex];
- if (((u_long)pde & PG_V) == 0)
- goto invalid;
-
- if ((u_long)pde & PG_PS) {
- /*
- * No second-level page table; ptd describes one 4MB page.
- * (We assume that the kernel wouldn't set PG_PS without enabling
- * it cr0, and that the kernel doesn't support 36-bit physical
- * addresses).
- */
-#define PAGE4M_MASK (NBPDR - 1)
-#define PG_FRAME4M (~PAGE4M_MASK)
- *pa = ((u_long)pde & PG_FRAME4M) + (va & PAGE4M_MASK);
- return (NBPDR - (va & PAGE4M_MASK));
- }
-
- pteindex = (va >> PAGE_SHIFT) & (NPTEPG-1);
- pte_pa = ((u_long)pde & PG_FRAME) + (pteindex * sizeof(pt_entry_t));
-
- /* XXX This has to be a physical address read, kvm_read is virtual */
- if (lseek(kd->pmfd, pte_pa, 0) == -1) {
- _kvm_syserr(kd, kd->program, "_kvm_vatop: lseek");
- goto invalid;
- }
- if (read(kd->pmfd, &pte, sizeof pte) != sizeof pte) {
- _kvm_syserr(kd, kd->program, "_kvm_vatop: read");
- goto invalid;
- }
- if (((u_long)pte & PG_V) == 0)
- goto invalid;
-
- *pa = ((u_long)pte & PG_FRAME) + offset;
- return (PAGE_SIZE - offset);
-
-invalid:
- _kvm_err(kd, 0, "invalid address (%x)", va);
- return (0);
-}
-
-int
-_kvm_kvatop(kvm_t *kd, u_long va, u_long *pa)
-{
- return (_kvm_vatop(kd, va, pa));
-}
diff --git a/lib/libopie/config.h b/lib/libopie/config.h
deleted file mode 100644
index bf91b2e68e8d..000000000000
--- a/lib/libopie/config.h
+++ /dev/null
@@ -1,379 +0,0 @@
-/* config.h. Generated automatically by configure. */
-/* config.h.in. Generated automatically from configure.in by autoheader. */
-
-/* Define if on AIX 3.
- System headers sometimes define this.
- We just want to avoid a redefinition error message. */
-#ifndef _ALL_SOURCE
-/* #undef _ALL_SOURCE */
-#endif
-
-/* Define if using alloca.c. */
-/* #undef C_ALLOCA */
-
-/* Define to empty if the keyword does not work. */
-/* #undef const */
-
-/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
- This function is required for alloca.c support on those systems. */
-/* #undef CRAY_STACKSEG_END */
-
-/* Define if you have alloca, as a function or macro. */
-#define HAVE_ALLOCA 1
-
-/* Define if you have <alloca.h> and it should be used (not on Ultrix). */
-/* #undef HAVE_ALLOCA_H */
-
-/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
-#define HAVE_SYS_WAIT_H 1
-
-/* Define if on MINIX. */
-/* #undef _MINIX */
-
-/* Define if the system does not provide POSIX.1 features except
- with this defined. */
-/* #undef _POSIX_1_SOURCE */
-
-/* Define if you need to in order for stat and other things to work. */
-/* #undef _POSIX_SOURCE */
-
-/* Define as the return type of signal handlers (int or void). */
-#define RETSIGTYPE void
-
-/* If using the C implementation of alloca, define if you know the
- direction of stack growth for your system; otherwise it will be
- automatically deduced at run-time.
- STACK_DIRECTION > 0 => grows toward higher addresses
- STACK_DIRECTION < 0 => grows toward lower addresses
- STACK_DIRECTION = 0 => direction of growth unknown
- */
-/* #undef STACK_DIRECTION */
-
-/* Define if you want the FTP daemon to support anonymous logins. */
-/* #undef DOANONYMOUS */
-
-/* The default value of the PATH environment variable */
-#define DEFAULT_PATH "/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
-
-/* Defined if the file /etc/default/login exists
- (and, presumably, should be looked at by login) */
-/* #undef HAVE_ETC_DEFAULT_LOGIN */
-
-/* Defined to the name of a file that contains a list of files whose
- permissions and ownerships should be changed on login. */
-/* #undef HAVE_LOGIN_PERMFILE */
-
-/* Defined to the name of a file that contains a list of environment
- values that should be set on login. */
-/* #undef HAVE_LOGIN_ENVFILE */
-
-/* Defined if the file /etc/securetty exists
- (and, presumably, should be looked at by login) */
-/* #undef HAVE_SECURETTY */
-
-/* Defined if the file /etc/shadow exists
- (and, presumably, should be looked at for shadow passwords) */
-/* #undef HAVE_ETC_SHADOW */
-
-/* The path to the access file, if we're going to use it */
-/* #undef PATH_ACCESS_FILE */
-
-/* The path to the mail spool, if we know it */
-#define PATH_MAIL "/var/mail"
-
-/* The path to the utmp file, if we know it */
-#define PATH_UTMP_AC "/var/run/utmp"
-
-/* The path to the wtmp file, if we know it */
-#define PATH_WTMP_AC "/var/log/wtmp"
-
-/* The path to the wtmpx file, if we know it */
-/* #undef PATH_WTMPX_AC */
-
-/* Defined if the system's profile (/etc/profile) displays
- the motd file */
-/* #undef HAVE_MOTD_IN_PROFILE */
-
-/* Defined if the system's profile (/etc/profile) informs the
- user of new mail */
-/* #undef HAVE_MAILCHECK_IN_PROFILE */
-
-/* Define if you have a nonstandard gettimeofday() that takes one argument
- instead of two. */
-/* #undef HAVE_ONE_ARG_GETTIMEOFDAY */
-
-/* Define if the system has the getenv function */
-#define HAVE_GETENV 1
-
-/* Define if the system has the setenv function */
-#define HAVE_SETENV 1
-
-/* Define if the system has the /var/adm/sulog file */
-/* #undef HAVE_SULOG */
-
-/* Define if the system has the unsetenv function */
-#define HAVE_UNSETENV 1
-
-/* Define if the compiler can handle ANSI-style argument lists */
-#define HAVE_ANSIDECL 1
-
-/* Define if the compiler can handle ANSI-style prototypes */
-#define HAVE_ANSIPROTO 1
-
-/* Define if the system has an ANSI-style printf (returns int instead of char *) */
-#define HAVE_ANSISPRINTF 1
-
-/* Define if the compiler can handle ANSI-style variable argument lists */
-#define HAVE_ANSISTDARG 1
-
-/* Define if the compiler can handle void argument lists to functions */
-#define HAVE_VOIDARG 1
-
-/* Define if the compiler can handle void return "values" from functions */
-#define HAVE_VOIDRET 1
-
-/* Define if the compiler can handle void pointers to our liking */
-#define HAVE_VOIDPTR 1
-
-/* Define if the /bin/ls command seems to support the -g flag */
-/* #undef HAVE_LS_G_FLAG */
-
-/* Define if there is a ut_pid field in struct utmp */
-/* #undef HAVE_UT_PID */
-
-/* Define if there is a ut_type field in struct utmp */
-/* #undef HAVE_UT_TYPE */
-
-/* Define if there is a ut_name field in struct utmp */
-#define HAVE_UT_NAME 1
-
-/* Define if there is a ut_host field in struct utmp */
-#define HAVE_UT_HOST 1
-
-/* Define if the system has getutline() */
-/* #undef HAVE_GETUTLINE */
-
-/* Defined if the system has SunOS C2 security shadow passwords */
-/* #undef HAVE_SUNOS_C2_SHADOW */
-
-/* Defined if you want to disable utmp support */
-/* #undef DISABLE_UTMP */
-
-/* Defined if you want to allow users to override the insecure checks */
-/* #undef INSECURE_OVERRIDE */
-
-/* Defined to the default hash value, always defined */
-#define MDX 5
-
-/* Defined if new-style prompts are to be used */
-#define NEW_PROMPTS 1
-
-/* Defined to the path of the OPIE lock directory */
-#define OPIE_LOCK_DIR "/var/spool/opielocks"
-
-/* Defined if users are to be asked to re-type secret pass phrases */
-/* #undef RETYPE */
-
-/* Defined if su should not switch to disabled accounts */
-/* #undef SU_STAR_CHECK */
-
-/* Defined if user locking is to be used */
-#define USER_LOCKING 1
-
-/* Define if you have the bcopy function. */
-/* #undef HAVE_BCOPY */
-
-/* Define if you have the bzero function. */
-/* #undef HAVE_BZERO */
-
-/* Define if you have the endspent function. */
-/* #undef HAVE_ENDSPENT */
-
-/* Define if you have the fpurge function. */
-#define HAVE_FPURGE 1
-
-/* Define if you have the getdtablesize function. */
-/* #undef HAVE_GETDTABLESIZE */
-
-/* Define if you have the getgroups function. */
-#define HAVE_GETGROUPS 1
-
-/* Define if you have the gethostname function. */
-/* #undef HAVE_GETHOSTNAME */
-
-/* Define if you have the getspnam function. */
-/* #undef HAVE_GETSPNAM */
-
-/* Define if you have the gettimeofday function. */
-#define HAVE_GETTIMEOFDAY 1
-
-/* Define if you have the getttynam function. */
-#define HAVE_GETTTYNAM 1
-
-/* Define if you have the getusershell function. */
-#define HAVE_GETUSERSHELL 1
-
-/* Define if you have the getutxline function. */
-/* #undef HAVE_GETUTXLINE */
-
-/* Define if you have the getwd function. */
-/* #undef HAVE_GETWD */
-
-/* Define if you have the index function. */
-/* #undef HAVE_INDEX */
-
-/* Define if you have the lstat function. */
-#define HAVE_LSTAT 1
-
-/* Define if you have the on_exit function. */
-/* #undef HAVE_ON_EXIT */
-
-/* Define if you have the pututxline function. */
-/* #undef HAVE_PUTUTXLINE */
-
-/* Define if you have the rindex function. */
-/* #undef HAVE_RINDEX */
-
-/* Define if you have the setgroups function. */
-#define HAVE_SETGROUPS 1
-
-/* Define if you have the setlogin function. */
-#define HAVE_SETLOGIN 1
-
-/* Define if you have the setpriority function. */
-#define HAVE_SETPRIORITY 1
-
-/* Define if you have the setregid function. */
-/* #undef HAVE_SETREGID */
-
-/* Define if you have the setresgid function. */
-/* #undef HAVE_SETRESGID */
-
-/* Define if you have the setresuid function. */
-/* #undef HAVE_SETRESUID */
-
-/* Define if you have the setreuid function. */
-/* #undef HAVE_SETREUID */
-
-/* Define if you have the setvbuf function. */
-#define HAVE_SETVBUF 1
-
-/* Define if you have the sigaddset function. */
-#define HAVE_SIGADDSET 1
-
-/* Define if you have the sigblock function. */
-/* #undef HAVE_SIGBLOCK */
-
-/* Define if you have the sigemptyset function. */
-#define HAVE_SIGEMPTYSET 1
-
-/* Define if you have the sigsetmask function. */
-/* #undef HAVE_SIGSETMASK */
-
-/* Define if you have the socket function. */
-#define HAVE_SOCKET 1
-
-/* Define if you have the strerror function. */
-#define HAVE_STRERROR 1
-
-/* Define if you have the strftime function. */
-#define HAVE_STRFTIME 1
-
-/* Define if you have the strncasecmp function. */
-#define HAVE_STRNCASECMP 1
-
-/* Define if you have the strstr function. */
-#define HAVE_STRSTR 1
-
-/* Define if you have the ttyslot function. */
-#define HAVE_TTYSLOT 1
-
-/* Define if you have the usleep function. */
-#define HAVE_USLEEP 1
-
-/* Define if you have the <crypt.h> header file. */
-/* #undef HAVE_CRYPT_H */
-
-/* Define if you have the <dirent.h> header file. */
-#define HAVE_DIRENT_H 1
-
-/* Define if you have the <fcntl.h> header file. */
-#define HAVE_FCNTL_H 1
-
-/* Define if you have the <lastlog.h> header file. */
-/* #undef HAVE_LASTLOG_H */
-
-/* Define if you have the <limits.h> header file. */
-#define HAVE_LIMITS_H 1
-
-/* Define if you have the <ndir.h> header file. */
-/* #undef HAVE_NDIR_H */
-
-/* Define if you have the <paths.h> header file. */
-#define HAVE_PATHS_H 1
-
-/* Define if you have the <pwd.h> header file. */
-#define HAVE_PWD_H 1
-
-/* Define if you have the <shadow.h> header file. */
-/* #undef HAVE_SHADOW_H */
-
-/* Define if you have the <signal.h> header file. */
-#define HAVE_SIGNAL_H 1
-
-/* Define if you have the <stdlib.h> header file. */
-#define HAVE_STDLIB_H 1
-
-/* Define if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Define if you have the <sys/dir.h> header file. */
-/* #undef HAVE_SYS_DIR_H */
-
-/* Define if you have the <sys/file.h> header file. */
-#define HAVE_SYS_FILE_H 1
-
-/* Define if you have the <sys/ioctl.h> header file. */
-#define HAVE_SYS_IOCTL_H 1
-
-/* Define if you have the <sys/ndir.h> header file. */
-/* #undef HAVE_SYS_NDIR_H */
-
-/* Define if you have the <sys/param.h> header file. */
-#define HAVE_SYS_PARAM_H 1
-
-/* Define if you have the <sys/select.h> header file. */
-#define HAVE_SYS_SELECT_H 1
-
-/* Define if you have the <sys/signal.h> header file. */
-#define HAVE_SYS_SIGNAL_H 1
-
-/* Define if you have the <sys/time.h> header file. */
-#define HAVE_SYS_TIME_H 1
-
-/* Define if you have the <sys/utsname.h> header file. */
-#define HAVE_SYS_UTSNAME_H 1
-
-/* Define if you have the <syslog.h> header file. */
-#define HAVE_SYSLOG_H 1
-
-/* Define if you have the <termios.h> header file. */
-#define HAVE_TERMIOS_H 1
-
-/* Define if you have the <unistd.h> header file. */
-#define HAVE_UNISTD_H 1
-
-/* Define if you have the <utmpx.h> header file. */
-/* #undef HAVE_UTMPX_H */
-
-/* Define if you have the crypt library (-lcrypt). */
-#define HAVE_LIBCRYPT 1
-
-/* Define if you have the nsl library (-lnsl). */
-/* #undef HAVE_LIBNSL */
-
-/* Define if you have the posix library (-lposix). */
-/* #undef HAVE_LIBPOSIX */
-
-/* Define if you have the socket library (-lsocket). */
-/* #undef HAVE_LIBSOCKET */
diff --git a/lib/libpam/libpam/security/pam_mod_misc.h b/lib/libpam/libpam/security/pam_mod_misc.h
deleted file mode 100644
index 06f474d293a2..000000000000
--- a/lib/libpam/libpam/security/pam_mod_misc.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*-
- * Copyright 1998 Juniper Networks, Inc.
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#ifndef PAM_MOD_MISC_H
-#define PAM_MOD_MISC_H
-
-#include <sys/cdefs.h>
-
-/* Options */
-#define PAM_OPT_DEBUG 0x01
-#define PAM_OPT_NO_WARN 0x02
-#define PAM_OPT_USE_FIRST_PASS 0x04
-#define PAM_OPT_TRY_FIRST_PASS 0x08
-#define PAM_OPT_USE_MAPPED_PASS 0x10
-#define PAM_OPT_ECHO_PASS 0x20
-
-__BEGIN_DECLS
-int pam_get_pass(pam_handle_t *, const char **, const char *, int);
-int pam_prompt(pam_handle_t *, int, const char *, char **);
-int pam_std_option(int *, const char *);
-__END_DECLS
-
-#endif
diff --git a/lib/libpam/modules/pam_login_access/login.access.5 b/lib/libpam/modules/pam_login_access/login.access.5
deleted file mode 100644
index f9f0eb5f0f0e..000000000000
--- a/lib/libpam/modules/pam_login_access/login.access.5
+++ /dev/null
@@ -1,56 +0,0 @@
-.\"
-.\" $FreeBSD$
-.\"
-.\" this is comment
-.Dd April 30, 1994
-.Dt LOGIN.ACCESS 5
-.Os FreeBSD
-.Sh NAME
-.Nm login.access
-.Nd login access control table
-.Sh DESCRIPTION
-The
-.Nm
-file specifies (user, host) combinations and/or (user, tty)
-combinations for which a login will be either accepted or refused.
-.Pp
-When someone logs in, the
-.Nm
-is scanned for the first entry that
-matches the (user, host) combination, or, in case of non-networked
-logins, the first entry that matches the (user, tty) combination. The
-permissions field of that table entry determines whether the login will
-be accepted or refused.
-.Pp
-Each line of the login access control table has three fields separated by a
-":" character: permission : users : origins
-.Pp
-The first field should be a "+" (access granted) or "-" (access denied)
-character.
-The second field should be a list of one or more login names,
-group names, or ALL (always matches). The third field should be a list
-of one or more tty names (for non-networked logins), host names, domain
-names (begin with "."), host addresses, internet network numbers (end
-with "."), ALL (always matches) or LOCAL (matches any string that does
-not contain a "." character). If you run NIS you can use @netgroupname
-in host or user patterns.
-.Pp
-The EXCEPT operator makes it possible to write very compact rules.
-.Pp
-The group file is searched only when a name does not match that of the
-logged-in user.
-Only groups are matched in which users are explicitly
-listed: the program does not look at a user's primary group id value.
-.Sh FILES
-.Bl -tag -width /etc/login.access -compact
-.It Pa /etc/login.access
-The
-.Nm
-file resides in
-.Pa /etc .
-.El
-.Sh SEE ALSO
-.Xr login 1 ,
-.Xr pam 8
-.Sh AUTHORS
-.An Guido van Rooij
diff --git a/lib/libpam/modules/pam_login_access/login_access.c b/lib/libpam/modules/pam_login_access/login_access.c
deleted file mode 100644
index cfb24d2e2e7a..000000000000
--- a/lib/libpam/modules/pam_login_access/login_access.c
+++ /dev/null
@@ -1,239 +0,0 @@
- /*
- * This module implements a simple but effective form of login access
- * control based on login names and on host (or domain) names, internet
- * addresses (or network numbers), or on terminal line names in case of
- * non-networked logins. Diagnostics are reported through syslog(3).
- *
- * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
- */
-
-#ifdef LOGIN_ACCESS
-#ifndef lint
-static const char sccsid[] = "%Z% %M% %I% %E% %U%";
-#endif
-
-#include <stdio.h>
-#include <syslog.h>
-#include <ctype.h>
-#include <sys/types.h>
-#include <grp.h>
-#include <errno.h>
-#include <string.h>
-#include <unistd.h>
-#include <stdlib.h>
-
-#include "pathnames.h"
-
- /* Delimiters for fields and for lists of users, ttys or hosts. */
-
-static char fs[] = ":"; /* field separator */
-static char sep[] = ", \t"; /* list-element separator */
-
- /* Constants to be used in assignments only, not in comparisons... */
-
-#define YES 1
-#define NO 0
-
-static int list_match();
-static int user_match();
-static int from_match();
-static int string_match();
-
-/* login_access - match username/group and host/tty with access control file */
-
-int
-login_access(user, from)
-char *user;
-char *from;
-{
- FILE *fp;
- char line[BUFSIZ];
- char *perm; /* becomes permission field */
- char *users; /* becomes list of login names */
- char *froms; /* becomes list of terminals or hosts */
- int match = NO;
- int end;
- int lineno = 0; /* for diagnostics */
-
- /*
- * Process the table one line at a time and stop at the first match.
- * Blank lines and lines that begin with a '#' character are ignored.
- * Non-comment lines are broken at the ':' character. All fields are
- * mandatory. The first field should be a "+" or "-" character. A
- * non-existing table means no access control.
- */
-
- if ((fp = fopen(_PATH_LOGACCESS, "r")) != NULL) {
- while (!match && fgets(line, sizeof(line), fp)) {
- lineno++;
- if (line[end = strlen(line) - 1] != '\n') {
- syslog(LOG_ERR, "%s: line %d: missing newline or line too long",
- _PATH_LOGACCESS, lineno);
- continue;
- }
- if (line[0] == '#')
- continue; /* comment line */
- while (end > 0 && isspace(line[end - 1]))
- end--;
- line[end] = 0; /* strip trailing whitespace */
- if (line[0] == 0) /* skip blank lines */
- continue;
- if (!(perm = strtok(line, fs))
- || !(users = strtok((char *) 0, fs))
- || !(froms = strtok((char *) 0, fs))
- || strtok((char *) 0, fs)) {
- syslog(LOG_ERR, "%s: line %d: bad field count", _PATH_LOGACCESS,
- lineno);
- continue;
- }
- if (perm[0] != '+' && perm[0] != '-') {
- syslog(LOG_ERR, "%s: line %d: bad first field", _PATH_LOGACCESS,
- lineno);
- continue;
- }
- match = (list_match(froms, from, from_match)
- && list_match(users, user, user_match));
- }
- (void) fclose(fp);
- } else if (errno != ENOENT) {
- syslog(LOG_ERR, "cannot open %s: %m", _PATH_LOGACCESS);
- }
- return (match == 0 || (line[0] == '+'));
-}
-
-/* list_match - match an item against a list of tokens with exceptions */
-
-static int list_match(list, item, match_fn)
-char *list;
-char *item;
-int (*match_fn) ();
-{
- char *tok;
- int match = NO;
-
- /*
- * Process tokens one at a time. We have exhausted all possible matches
- * when we reach an "EXCEPT" token or the end of the list. If we do find
- * a match, look for an "EXCEPT" list and recurse to determine whether
- * the match is affected by any exceptions.
- */
-
- for (tok = strtok(list, sep); tok != 0; tok = strtok((char *) 0, sep)) {
- if (strcasecmp(tok, "EXCEPT") == 0) /* EXCEPT: give up */
- break;
- if ((match = (*match_fn)(tok, item)) != NULL) /* YES */
- break;
- }
- /* Process exceptions to matches. */
-
- if (match != NO) {
- while ((tok = strtok((char *) 0, sep)) && strcasecmp(tok, "EXCEPT"))
- /* VOID */ ;
- if (tok == 0 || list_match((char *) 0, item, match_fn) == NO)
- return (match);
- }
- return (NO);
-}
-
-/* netgroup_match - match group against machine or user */
-
-static int netgroup_match(group, machine, user)
-gid_t group;
-char *machine;
-char *user;
-{
-#ifdef NIS
- static char *mydomain = 0;
-
- if (mydomain == 0)
- yp_get_default_domain(&mydomain);
- return (innetgr(group, machine, user, mydomain));
-#else
- syslog(LOG_ERR, "NIS netgroup support not configured");
- return 0;
-#endif
-}
-
-/* user_match - match a username against one token */
-
-static int user_match(tok, string)
-char *tok;
-char *string;
-{
- struct group *group;
- int i;
-
- /*
- * If a token has the magic value "ALL" the match always succeeds.
- * Otherwise, return YES if the token fully matches the username, or if
- * the token is a group that contains the username.
- */
-
- if (tok[0] == '@') { /* netgroup */
- return (netgroup_match(tok + 1, (char *) 0, string));
- } else if (string_match(tok, string)) { /* ALL or exact match */
- return (YES);
- } else if ((group = getgrnam(tok)) != NULL) {/* try group membership */
- for (i = 0; group->gr_mem[i]; i++)
- if (strcasecmp(string, group->gr_mem[i]) == 0)
- return (YES);
- }
- return (NO);
-}
-
-/* from_match - match a host or tty against a list of tokens */
-
-static int from_match(tok, string)
-char *tok;
-char *string;
-{
- int tok_len;
- int str_len;
-
- /*
- * If a token has the magic value "ALL" the match always succeeds. Return
- * YES if the token fully matches the string. If the token is a domain
- * name, return YES if it matches the last fields of the string. If the
- * token has the magic value "LOCAL", return YES if the string does not
- * contain a "." character. If the token is a network number, return YES
- * if it matches the head of the string.
- */
-
- if (tok[0] == '@') { /* netgroup */
- return (netgroup_match(tok + 1, string, (char *) 0));
- } else if (string_match(tok, string)) { /* ALL or exact match */
- return (YES);
- } else if (tok[0] == '.') { /* domain: match last fields */
- if ((str_len = strlen(string)) > (tok_len = strlen(tok))
- && strcasecmp(tok, string + str_len - tok_len) == 0)
- return (YES);
- } else if (strcasecmp(tok, "LOCAL") == 0) { /* local: no dots */
- if (strchr(string, '.') == 0)
- return (YES);
- } else if (tok[(tok_len = strlen(tok)) - 1] == '.' /* network */
- && strncmp(tok, string, tok_len) == 0) {
- return (YES);
- }
- return (NO);
-}
-
-/* string_match - match a string against one token */
-
-static int string_match(tok, string)
-char *tok;
-char *string;
-{
-
- /*
- * If the token has the magic value "ALL" the match always succeeds.
- * Otherwise, return YES if the token fully matches the string.
- */
-
- if (strcasecmp(tok, "ALL") == 0) { /* all: always matches */
- return (YES);
- } else if (strcasecmp(tok, string) == 0) { /* try exact match */
- return (YES);
- }
- return (NO);
-}
-#endif /* LOGIN_ACCES */
diff --git a/lib/libpam/modules/pam_ssh/pam_ssh.c b/lib/libpam/modules/pam_ssh/pam_ssh.c
deleted file mode 100644
index 19f7722af4eb..000000000000
--- a/lib/libpam/modules/pam_ssh/pam_ssh.c
+++ /dev/null
@@ -1,489 +0,0 @@
-/*-
- * Copyright (c) 1999 Andrew J. Korty
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- *
- */
-
-
-#include <sys/param.h>
-#include <sys/queue.h>
-
-#include <fcntl.h>
-#include <paths.h>
-#include <pwd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#define PAM_SM_AUTH
-#define PAM_SM_SESSION
-#include <security/pam_modules.h>
-#include <security/pam_mod_misc.h>
-
-#include "includes.h"
-#include "rsa.h"
-#include "ssh.h"
-#include "authfd.h"
-
-#define MODULE_NAME "pam_ssh"
-#define NEED_PASSPHRASE "Need passphrase for %s (%s).\nEnter passphrase: "
-#define PATH_SSH_AGENT "/usr/bin/ssh-agent"
-
-
-void
-rsa_cleanup(pam_handle_t *pamh, void *data, int error_status)
-{
- if (data)
- RSA_free(data);
-}
-
-
-void
-ssh_cleanup(pam_handle_t *pamh, void *data, int error_status)
-{
- if (data)
- free(data);
-}
-
-
-/*
- * The following set of functions allow the module to manipulate the
- * environment without calling the putenv() or setenv() stdlib functions.
- * At least one version of these functions, on the first call, copies
- * the environment into dynamically-allocated memory and then augments
- * it. On subsequent calls, the realloc() call is used to grow the
- * previously allocated buffer. Problems arise when the "environ"
- * variable is changed to point to static memory after putenv()/setenv()
- * have been called.
- *
- * We don't use putenv() or setenv() in case the application subsequently
- * manipulates environ, (e.g., to clear the environment by pointing
- * environ at an array of one element equal to NULL).
- */
-
-SLIST_HEAD(env_head, env_entry);
-
-struct env_entry {
- char *ee_env;
- SLIST_ENTRY(env_entry) ee_entries;
-};
-
-typedef struct env {
- char **e_environ_orig;
- char **e_environ_new;
- int e_count;
- struct env_head e_head;
- int e_committed;
-} ENV;
-
-extern char **environ;
-
-
-static ENV *
-env_new(void)
-{
- ENV *self;
-
- if (!(self = malloc(sizeof (ENV)))) {
- syslog(LOG_CRIT, "%m");
- return NULL;
- }
- SLIST_INIT(&self->e_head);
- self->e_count = 0;
- self->e_committed = 0;
- return self;
-}
-
-
-static int
-env_put(ENV *self, char *s)
-{
- struct env_entry *env;
-
- if (!(env = malloc(sizeof (struct env_entry))) ||
- !(env->ee_env = strdup(s))) {
- syslog(LOG_CRIT, "%m");
- return PAM_SERVICE_ERR;
- }
- SLIST_INSERT_HEAD(&self->e_head, env, ee_entries);
- ++self->e_count;
- return PAM_SUCCESS;
-}
-
-
-static void
-env_swap(ENV *self, int which)
-{
- environ = which ? self->e_environ_new : self->e_environ_orig;
-}
-
-
-static int
-env_commit(ENV *self)
-{
- int n;
- struct env_entry *p;
- char **v;
-
- for (v = environ, n = 0; v && *v; v++, n++)
- ;
- if (!(v = malloc((n + self->e_count + 1) * sizeof (char *)))) {
- syslog(LOG_CRIT, "%m");
- return PAM_SERVICE_ERR;
- }
- self->e_committed = 1;
- (void)memcpy(v, environ, n * sizeof (char *));
- SLIST_FOREACH(p, &self->e_head, ee_entries)
- v[n++] = p->ee_env;
- v[n] = NULL;
- self->e_environ_orig = environ;
- self->e_environ_new = v;
- env_swap(self, 1);
- return PAM_SUCCESS;
-}
-
-
-static void
-env_destroy(ENV *self)
-{
- struct env_entry *p;
-
- env_swap(self, 0);
- SLIST_FOREACH(p, &self->e_head, ee_entries) {
- free(p->ee_env);
- free(p);
- }
- if (self->e_committed)
- free(self->e_environ_new);
- free(self);
-}
-
-
-void
-env_cleanup(pam_handle_t *pamh, void *data, int error_status)
-{
- if (data)
- env_destroy(data);
-}
-
-
-typedef struct passwd PASSWD;
-
-PAM_EXTERN int
-pam_sm_authenticate(
- pam_handle_t *pamh,
- int flags,
- int argc,
- const char **argv)
-{
- char *comment_priv; /* on private key */
- char *comment_pub; /* on public key */
- char *identity; /* user's identity file */
- RSA *key; /* user's private key */
- int options; /* module options */
- const char *pass; /* passphrase */
- char *prompt; /* passphrase prompt */
- RSA *public_key; /* user's public key */
- const PASSWD *pwent; /* user's passwd entry */
- PASSWD *pwent_keep; /* our own copy */
- int retval; /* from calls */
- uid_t saved_uid; /* caller's uid */
- const char *user; /* username */
-
- options = 0;
- while (argc--)
- pam_std_option(&options, *argv++);
- if ((retval = pam_get_user(pamh, &user, NULL)) != PAM_SUCCESS)
- return retval;
- if (!((pwent = getpwnam(user)) && pwent->pw_dir)) {
- /* delay? */
- return PAM_AUTH_ERR;
- }
- /* locate the user's private key file */
- if (!asprintf(&identity, "%s/%s", pwent->pw_dir,
- SSH_CLIENT_IDENTITY)) {
- syslog(LOG_CRIT, "%s: %m", MODULE_NAME);
- return PAM_SERVICE_ERR;
- }
- /*
- * Fail unless we can load the public key. Change to the
- * owner's UID to appease load_public_key().
- */
- key = RSA_new();
- public_key = RSA_new();
- saved_uid = getuid();
- (void)setreuid(pwent->pw_uid, saved_uid);
- retval = load_public_key(identity, public_key, &comment_pub);
- (void)setuid(saved_uid);
- if (!retval) {
- free(identity);
- return PAM_AUTH_ERR;
- }
- RSA_free(public_key);
- /* build the passphrase prompt */
- retval = asprintf(&prompt, NEED_PASSPHRASE, identity, comment_pub);
- free(comment_pub);
- if (!retval) {
- syslog(LOG_CRIT, "%s: %m", MODULE_NAME);
- free(identity);
- return PAM_SERVICE_ERR;
- }
- /* pass prompt message to application and receive passphrase */
- retval = pam_get_pass(pamh, &pass, prompt, options);
- free(prompt);
- if (retval != PAM_SUCCESS) {
- free(identity);
- return retval;
- }
- /*
- * Try to decrypt the private key with the passphrase provided.
- * If success, the user is authenticated.
- */
- (void)setreuid(pwent->pw_uid, saved_uid);
- retval = load_private_key(identity, pass, key, &comment_priv);
- free(identity);
- (void)setuid(saved_uid);
- if (!retval)
- return PAM_AUTH_ERR;
- /*
- * Save the key and comment to pass to ssh-agent in the session
- * phase.
- */
- if ((retval = pam_set_data(pamh, "ssh_private_key", key,
- rsa_cleanup)) != PAM_SUCCESS) {
- RSA_free(key);
- free(comment_priv);
- return retval;
- }
- if ((retval = pam_set_data(pamh, "ssh_key_comment", comment_priv,
- ssh_cleanup)) != PAM_SUCCESS) {
- free(comment_priv);
- return retval;
- }
- /*
- * Copy the passwd entry (in case successive calls are made)
- * and save it for the session phase.
- */
- if (!(pwent_keep = malloc(sizeof *pwent))) {
- syslog(LOG_CRIT, "%m");
- return PAM_SERVICE_ERR;
- }
- (void)memcpy(pwent_keep, pwent, sizeof *pwent_keep);
- if ((retval = pam_set_data(pamh, "ssh_passwd_entry", pwent_keep,
- ssh_cleanup)) != PAM_SUCCESS) {
- free(pwent_keep);
- return retval;
- }
- return PAM_SUCCESS;
-}
-
-
-PAM_EXTERN int
-pam_sm_setcred(
- pam_handle_t *pamh,
- int flags,
- int argc,
- const char **argv)
-{
- return PAM_SUCCESS;
-}
-
-
-typedef AuthenticationConnection AC;
-
-PAM_EXTERN int
-pam_sm_open_session(
- pam_handle_t *pamh,
- int flags,
- int argc,
- const char **argv)
-{
- AC *ac; /* to ssh-agent */
- char *comment; /* on private key */
- char *env_end; /* end of env */
- char *env_file; /* to store env */
- FILE *env_fp; /* env_file handle */
- RSA *key; /* user's private key */
- FILE *pipe; /* ssh-agent handle */
- const PASSWD *pwent; /* user's passwd entry */
- int retval; /* from calls */
- uid_t saved_uid; /* caller's uid */
- ENV *ssh_env; /* env handle */
- const char *tty; /* tty or display name */
- char hname[MAXHOSTNAMELEN]; /* local hostname */
- char parse[BUFSIZ]; /* commands output */
-
- /* dump output of ssh-agent in ~/.ssh */
- if ((retval = pam_get_data(pamh, "ssh_passwd_entry",
- (const void **)&pwent)) != PAM_SUCCESS)
- return retval;
- /* use the tty or X display name in the filename */
- if ((retval = pam_get_item(pamh, PAM_TTY, (const void **)&tty))
- != PAM_SUCCESS)
- return retval;
- if (*tty == ':' && gethostname(hname, sizeof hname) == 0) {
- if (asprintf(&env_file, "%s/.ssh/agent-%s%s",
- pwent->pw_dir, hname, tty) == -1) {
- syslog(LOG_CRIT, "%s: %m", MODULE_NAME);
- return PAM_SERVICE_ERR;
- }
- } else if (asprintf(&env_file, "%s/.ssh/agent-%s", pwent->pw_dir,
- tty) == -1) {
- syslog(LOG_CRIT, "%s: %m", MODULE_NAME);
- return PAM_SERVICE_ERR;
- }
- /* save the filename so we can delete the file on session close */
- if ((retval = pam_set_data(pamh, "ssh_agent_env", env_file,
- ssh_cleanup)) != PAM_SUCCESS) {
- free(env_file);
- return retval;
- }
- /* start the agent as the user */
- saved_uid = geteuid();
- (void)seteuid(pwent->pw_uid);
- env_fp = fopen(env_file, "w");
- pipe = popen(PATH_SSH_AGENT, "r");
- (void)seteuid(saved_uid);
- if (!pipe) {
- syslog(LOG_ERR, "%s: %s: %m", MODULE_NAME, PATH_SSH_AGENT);
- if (env_fp)
- (void)fclose(env_fp);
- return PAM_SESSION_ERR;
- }
- if (!(ssh_env = env_new()))
- return PAM_SESSION_ERR;
- if ((retval = pam_set_data(pamh, "ssh_env_handle", ssh_env,
- env_cleanup)) != PAM_SUCCESS)
- return retval;
- while (fgets(parse, sizeof parse, pipe)) {
- if (env_fp)
- (void)fputs(parse, env_fp);
- /*
- * Save environment for application with pam_putenv()
- * but also with env_* functions for our own call to
- * ssh_get_authentication_connection().
- */
- if (strchr(parse, '=') && (env_end = strchr(parse, ';'))) {
- *env_end = '\0';
- /* pass to the application ... */
- if (!((retval = pam_putenv(pamh, parse)) ==
- PAM_SUCCESS)) {
- (void)pclose(pipe);
- if (env_fp)
- (void)fclose(env_fp);
- env_destroy(ssh_env);
- return PAM_SERVICE_ERR;
- }
- env_put(ssh_env, parse);
- }
- }
- if (env_fp)
- (void)fclose(env_fp);
- switch (retval = pclose(pipe)) {
- case -1:
- syslog(LOG_ERR, "%s: %s: %m", MODULE_NAME, PATH_SSH_AGENT);
- env_destroy(ssh_env);
- return PAM_SESSION_ERR;
- case 0:
- break;
- case 127:
- syslog(LOG_ERR, "%s: cannot execute %s", MODULE_NAME,
- PATH_SSH_AGENT);
- env_destroy(ssh_env);
- return PAM_SESSION_ERR;
- default:
- syslog(LOG_ERR, "%s: %s exited with status %d",
- MODULE_NAME, PATH_SSH_AGENT, WEXITSTATUS(retval));
- env_destroy(ssh_env);
- return PAM_SESSION_ERR;
- }
- /* connect to the agent and hand off the private key */
- if ((retval = pam_get_data(pamh, "ssh_private_key",
- (const void **)&key)) != PAM_SUCCESS ||
- (retval = pam_get_data(pamh, "ssh_key_comment",
- (const void **)&comment)) != PAM_SUCCESS ||
- (retval = env_commit(ssh_env)) != PAM_SUCCESS) {
- env_destroy(ssh_env);
- return retval;
- }
- if (!(ac = ssh_get_authentication_connection())) {
- syslog(LOG_ERR, "%s: could not connect to agent",
- MODULE_NAME);
- env_destroy(ssh_env);
- return PAM_SESSION_ERR;
- }
- retval = ssh_add_identity(ac, key, comment);
- ssh_close_authentication_connection(ac);
- env_swap(ssh_env, 0);
- return retval ? PAM_SUCCESS : PAM_SESSION_ERR;
-}
-
-
-PAM_EXTERN int
-pam_sm_close_session(
- pam_handle_t *pamh,
- int flags,
- int argc,
- const char **argv)
-{
- const char *env_file; /* ssh-agent environment */
- int retval; /* from calls */
- ENV *ssh_env; /* env handle */
-
- if ((retval = pam_get_data(pamh, "ssh_env_handle",
- (const void **)&ssh_env)) != PAM_SUCCESS)
- return retval;
- env_swap(ssh_env, 1);
- /* kill the agent */
- retval = system(PATH_SSH_AGENT " -k");
- env_destroy(ssh_env);
- switch (retval) {
- case -1:
- syslog(LOG_ERR, "%s: %s -k: %m", MODULE_NAME,
- PATH_SSH_AGENT);
- return PAM_SESSION_ERR;
- case 0:
- break;
- case 127:
- syslog(LOG_ERR, "%s: cannot execute %s -k", MODULE_NAME,
- PATH_SSH_AGENT);
- return PAM_SESSION_ERR;
- default:
- syslog(LOG_ERR, "%s: %s -k exited with status %d",
- MODULE_NAME, PATH_SSH_AGENT, WEXITSTATUS(retval));
- return PAM_SESSION_ERR;
- }
- /* retrieve environment filename, then remove the file */
- if ((retval = pam_get_data(pamh, "ssh_agent_env",
- (const void **)&env_file)) != PAM_SUCCESS)
- return retval;
- (void)unlink(env_file);
- return PAM_SUCCESS;
-}
-
-
-PAM_MODULE_ENTRY(MODULE_NAME);
diff --git a/lib/libpthread/Makefile b/lib/libpthread/Makefile
deleted file mode 100644
index 1b0afbbf40f7..000000000000
--- a/lib/libpthread/Makefile
+++ /dev/null
@@ -1,45 +0,0 @@
-# $FreeBSD$
-#
-# All library objects contain rcsid strings by default; they may be
-# excluded as a space-saving measure. To produce a library that does
-# not contain these strings, delete -DLIBC_RCS and -DSYSLIBC_RCS
-# from CFLAGS below. To remove these strings from just the system call
-# stubs, remove just -DSYSLIBC_RCS from CFLAGS.
-LIB=c_r
-SHLIB_MAJOR= 4
-SHLIB_MINOR= 0
-CFLAGS+=-DLIBC_RCS -DSYSLIBC_RCS -I${.CURDIR}/../libc/include
-CFLAGS+=-DPTHREAD_KERNEL -D_THREAD_SAFE -I${.CURDIR}/uthread
-CFLAGS+=-I${.CURDIR}/../../include
-
-# Uncomment this if you want libc_r to contain debug information for
-# thread locking.
-CFLAGS+=-D_LOCK_DEBUG
-
-# enable extra internal consistancy checks
-# CFLAGS+=-D_PTHREADS_INVARIANTS
-
-AINC= -I${.CURDIR}/../libc/${MACHINE_ARCH} -I${.CURDIR}/uthread
-PRECIOUSLIB= yes
-
-#
-# This is a list of syscalls that are renamed as _thread_sys_{syscall}
-# so that libc_r can provide replacement functions.
-#
-HIDDEN_SYSCALLS= aio_suspend.o accept.o bind.o close.o connect.o dup.o dup2.o \
- execve.o fchflags.o fchmod.o fchown.o fcntl.o \
- flock.o fpathconf.o fstat.o fstatfs.o fsync.o getdirentries.o \
- getlogin.o getpeername.o getsockname.o getsockopt.o ioctl.o listen.o \
- msync.o nanosleep.o nfssvc.o open.o poll.o read.o readv.o recvfrom.o \
- recvmsg.o sched_yield.o select.o sendmsg.o sendto.o \
- setsockopt.o shutdown.o sigaction.o sigaltstack.o \
- signanosleep.o sigpending.o sigprocmask.o sigreturn.o sigsetmask.o \
- sigsuspend.o socket.o \
- socketpair.o wait4.o write.o writev.o
-
-.include "${.CURDIR}/../libc/Makefile.inc"
-.include "${.CURDIR}/man/Makefile.inc"
-.include "${.CURDIR}/uthread/Makefile.inc"
-.include "${.CURDIR}/sys/Makefile.inc"
-
-.include <bsd.lib.mk>
diff --git a/lib/libpthread/arch/alpha/alpha/_atomic_lock.S b/lib/libpthread/arch/alpha/alpha/_atomic_lock.S
deleted file mode 100644
index 1cfb52faa824..000000000000
--- a/lib/libpthread/arch/alpha/alpha/_atomic_lock.S
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 1998 John Birrell <jb@cimlogic.com.au>.
- * All rights reserved.
- * copyright Douglas Santry 1996
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the above copyright is retained
- * in the source form.
- *
- * THIS SOFTWARE IS PROVIDED BY Douglas Santry 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 Douglas Santry 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.
- *
- * $FreeBSD$
- *
- */
-
-#include "SYS.h"
-
-/*
- * Atomicly lock a location with an identifier provided the location
- * is not currently locked.
- *
- * long _atomic_lock(long *);
- * v0 will contain the return value (zero if lock obtained).
- */
-LEAF(_atomic_lock,0)
- LDGP(pv)
-
-0: ldq_l v0, 0(a0) /* read existing lock value */
- mov 1, t0 /* locked value to store */
- stq_c t0, 0(a0) /* attempt to store, status in t0 */
- beq t0, 1f /* branch foward to optimise prediction */
- mb /* sync with other processors */
- RET /* return with v0==0 if lock obtained */
-1: br 0b /* loop to try again */
-END(_atomic_lock)
diff --git a/lib/libpthread/arch/i386/i386/_atomic_lock.S b/lib/libpthread/arch/i386/i386/_atomic_lock.S
deleted file mode 100644
index afaec7125ca1..000000000000
--- a/lib/libpthread/arch/i386/i386/_atomic_lock.S
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>.
- * All rights reserved.
- * copyright Douglas Santry 1996
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the above copyright is retained
- * in the source form.
- *
- * THIS SOFTWARE IS PROVIDED BY Douglas Santry 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 Douglas Santry 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.
- *
- * $FreeBSD$
- *
- */
-
-#if defined(LIBC_RCS) && !defined(lint)
- .text
- .asciz "$FreeBSD$"
-#endif /* LIBC_RCS and not lint */
-
-#include "DEFS.h"
-
-/*
- * Atomicly lock a location with an identifier provided the location
- * is not currently locked.
- *
- * long _atomic_lock(long *);
- * eax will contain the return value (zero if lock obtained).
- */
-ENTRY(_atomic_lock)
- movl 4(%esp), %ecx
- movl $1, %eax
- xchg %eax, (%ecx)
- ret
-
diff --git a/lib/libpthread/man/Makefile.inc b/lib/libpthread/man/Makefile.inc
deleted file mode 100644
index cba81ca86e2d..000000000000
--- a/lib/libpthread/man/Makefile.inc
+++ /dev/null
@@ -1,55 +0,0 @@
-# $FreeBSD$
-
-# POSIX thread man files
-
-.PATH: ${.CURDIR}/man
-
-MAN3+= pthread_cancel.3 \
- pthread_cleanup_pop.3 \
- pthread_cleanup_push.3 \
- pthread_cond_broadcast.3 \
- pthread_cond_destroy.3 \
- pthread_cond_init.3 \
- pthread_cond_signal.3 \
- pthread_cond_timedwait.3 \
- pthread_cond_wait.3 \
- pthread_create.3 \
- pthread_detach.3 \
- pthread_equal.3 \
- pthread_exit.3 \
- pthread_getspecific.3 \
- pthread_join.3 \
- pthread_key_create.3 \
- pthread_key_delete.3 \
- pthread_mutex_destroy.3 \
- pthread_mutex_init.3 \
- pthread_mutex_lock.3 \
- pthread_mutex_trylock.3 \
- pthread_mutex_unlock.3 \
- pthread_once.3 \
- pthread_rwlock_destroy.3 \
- pthread_rwlock_init.3 \
- pthread_rwlock_rdlock.3 \
- pthread_rwlock_unlock.3 \
- pthread_rwlock_wrlock.3 \
- pthread_rwlockattr_destroy.3 \
- pthread_rwlockattr_getpshared.3 \
- pthread_rwlockattr_init.3 \
- pthread_rwlockattr_setpshared.3 \
- pthread_self.3 \
- pthread_setspecific.3 \
- pthread_testcancel.3 \
- sem_destroy.3 \
- sem_getvalue.3 \
- sem_init.3 \
- sem_open.3 \
- sem_post.3 \
- sem_wait.3
-
-MLINKS+= pthread_cancel.3 pthread_getcancelstate.3 \
- pthread_cancel.3 pthread_setcancelstate.3 \
- pthread_rwlock_rdlock.3 pthread_rwlock_tryrdlock.3 \
- pthread_rwlock_wrlock.3 pthread_rwlock_trywrlock.3 \
- sem_open.3 sem_close.3 \
- sem_open.3 sem_unlink.3 \
- sem_wait.3 sem_trywait.3
diff --git a/lib/libpthread/man/pthread_cancel.3 b/lib/libpthread/man/pthread_cancel.3
deleted file mode 100644
index dd03f613ab12..000000000000
--- a/lib/libpthread/man/pthread_cancel.3
+++ /dev/null
@@ -1,78 +0,0 @@
-.\" $FreeBSD$
-.Dd January 17, 1999
-.Dt PTHREAD_CANCEL 3
-.Os
-.Sh NAME
-.Nm pthread_cancel
-.Nd cancel execution of a thread
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_cancel "pthread_t thread"
-.Sh DESCRIPTION
-The
-.Fn pthread_cancel
-function requests that
-.Fa thread
-be canceled.
-The target thread's cancelability state and type determines
-when the cancellation takes effect.
-When the cancellation is acted on,
-the cancellation cleanup handlers for
-.Fa thread
-are called.
-When the last cancellation cleanup handler returns,
-the thread-specific data destructor functions will be called for
-.Fa thread .
-When the last destructor function returns,
-.Fa thread
-will be terminated.
-.Pp
-The cancellation processing in the target thread runs asynchronously with
-respect to the calling thread returning from
-.Fn pthread_cancel .
-.Pp
-A status of
-.Dv PTHREAD_CANCELED
-is made available to any threads joining with the target.
-The symbolic
-constant
-.Dv PTHREAD_CANCELED
-expands to a constant expression of type
-.Ft "(void *)" ,
-whose value matches no pointer to an object in memory nor the value
-.Dv NULL .
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_cancel
-functions will return zero.
-Otherwise an error number will be returned to
-indicate the error.
-.Sh ERRORS
-.Fn pthread_cancel
-will fail if:
-.Bl -tag -width Er
-.It Bq Er ESRCH
-No thread could be found corresponding to that specified by the given
-thread ID.
-.El
-.Sh SEE ALSO
-.Xr pthread_cleanup_pop 3 ,
-.Xr pthread_cleanup_push 3 ,
-.Xr pthread_exit 3 ,
-.Xr pthread_join 3 ,
-.Xr pthread_setcancelstate 3 ,
-.Xr pthread_setcanceltype 3 ,
-.Xr pthread_testcancel 3
-.Sh STANDARDS
-.Fn pthread_cancel
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
-.Sh AUTHORS
-This man page was written by
-.An David Leonard Aq d@openbsd.org
-for the
-.Ox
-implementation of
-.Fn pthread_cancel .
diff --git a/lib/libpthread/man/pthread_cleanup_pop.3 b/lib/libpthread/man/pthread_cleanup_pop.3
deleted file mode 100644
index 009a85e91d9a..000000000000
--- a/lib/libpthread/man/pthread_cleanup_pop.3
+++ /dev/null
@@ -1,63 +0,0 @@
-.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com>
-.\" 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 author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd July 30, 1998
-.Dt PTHREAD_CLEANUP_POP 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_cleanup_pop
-.Nd call the first cleanup routine
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft void
-.Fn pthread_cleanup_pop "int execute"
-.Sh DESCRIPTION
-The
-.Fn pthread_cleanup_pop
-function pops the top cleanup routine off of the current threads cleanup
-routine stack, and, if
-.Fa execute
-is non-zero, it will execute the function.
-If there is no cleanup routine
-then
-.Fn pthread_cleanup_pop
-does nothing.
-.Sh RETURN VALUES
-.Fn pthread_cleanup_pop
-does not return any value.
-.Sh ERRORS
-None
-.Sh SEE ALSO
-.Xr pthread_cleanup_push 3 ,
-.Xr pthread_exit 3
-.Sh STANDARDS
-.Fn pthread_cleanup_pop
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/lib/libpthread/man/pthread_cleanup_push.3 b/lib/libpthread/man/pthread_cleanup_push.3
deleted file mode 100644
index 4f260affbc32..000000000000
--- a/lib/libpthread/man/pthread_cleanup_push.3
+++ /dev/null
@@ -1,65 +0,0 @@
-.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com>
-.\" 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 author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd July 30, 1998
-.Dt PTHREAD_CLEANUP_PUSH 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_cleanup_push
-.Nd add a cleanup function for thread exit
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft void
-.Fn pthread_cleanup_push "void (*cleanup_routine)(void *)" "void *arg"
-.Sh DESCRIPTION
-The
-.Fn pthread_cleanup_push
-function adds
-.Fa cleanup_routine
-to the top of the stack of cleanup handlers that
-get called when the current thread exits.
-.Pp
-When
-.Fn pthread_cleanup_push
-is called, it is passed
-.Fa arg
-as its only argument.
-.Sh RETURN VALUES
-.Fn pthread_cleanup_push
-does not return any value.
-.Sh ERRORS
-None
-.Sh SEE ALSO
-.Xr pthread_cleanup_pop 3 ,
-.Xr pthread_exit 3
-.Sh STANDARDS
-.Fn pthread_cleanup_push
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/lib/libpthread/man/pthread_cond_broadcast.3 b/lib/libpthread/man/pthread_cond_broadcast.3
deleted file mode 100644
index 6112695c9893..000000000000
--- a/lib/libpthread/man/pthread_cond_broadcast.3
+++ /dev/null
@@ -1,70 +0,0 @@
-.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com>
-.\" 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 author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd July 28, 1998
-.Dt PTHREAD_COND_BROADCAST 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_cond_broadcast
-.Nd unblock all threads waiting for a condition variable
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_cond_broadcast "pthread_cond_t *cond"
-.Sh DESCRIPTION
-The
-.Fn pthread_cond_broadcast
-function unblocks all threads waiting for the condition variable
-.Fa cond .
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_cond_broadcast
-function will return zero, otherwise an error number will be returned
-to indicate the error.
-.Sh ERRORS
-.Fn pthread_cond_broadcast
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The value specified by
-.Fa cond
-is invalid.
-.El
-.Pp
-.Sh SEE ALSO
-.Xr pthread_cond_destroy 3 ,
-.Xr pthread_cond_init 3 ,
-.Xr pthread_cond_signal 3 ,
-.Xr pthread_cond_timedwait 3 ,
-.Xr pthread_cond_wait 3
-.Sh STANDARDS
-.Fn pthread_cond_broadcast
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/lib/libpthread/man/pthread_cond_destroy.3 b/lib/libpthread/man/pthread_cond_destroy.3
deleted file mode 100644
index a9c4a9dbbdf7..000000000000
--- a/lib/libpthread/man/pthread_cond_destroy.3
+++ /dev/null
@@ -1,74 +0,0 @@
-.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com>
-.\" 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 author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd July 28, 1998
-.Dt PTHREAD_COND_DESTROY 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_cond_destroy
-.Nd destroy a condition variable
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_cond_destroy "pthread_cond_t *cond"
-.Sh DESCRIPTION
-The
-.Fn pthread_cond_destroy
-function frees the resources allocated by the condition variable
-.Fa cond .
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_cond_destroy
-function will return zero, otherwise an error number will be returned
-to indicate the error.
-.Sh ERRORS
-.Fn pthread_cond_destroy
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The value specified by
-.Fa cond
-is invalid.
-.It Bq Er EBUSY
-The variable
-.Fa cond
-is locked by another thread.
-.El
-.Pp
-.Sh SEE ALSO
-.Xr pthread_cond_broadcast 3 ,
-.Xr pthread_cond_init 3 ,
-.Xr pthread_cond_signal 3 ,
-.Xr pthread_cond_timedwait 3 ,
-.Xr pthread_cond_wait 3
-.Sh STANDARDS
-.Fn pthread_cond_destroy
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/lib/libpthread/man/pthread_cond_init.3 b/lib/libpthread/man/pthread_cond_init.3
deleted file mode 100644
index 2783672ce3d9..000000000000
--- a/lib/libpthread/man/pthread_cond_init.3
+++ /dev/null
@@ -1,79 +0,0 @@
-.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com>
-.\" 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 author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd July 28, 1998
-.Dt PTHREAD_COND_INIT 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_cond_init
-.Nd create a condition variable
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_cond_init "pthread_cond_t *cond" "const pthread_condattr_t *attr"
-.Sh DESCRIPTION
-The
-.Fn pthread_cond_init
-function creates a new condition variable, with attributes specified with
-.Fa attr .
-If
-.Fa attr
-is NULL the default attributes are used.
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_cond_init
-function will return zero and put the new condition variable id into
-.Fa cond ,
-otherwise an error number will be returned to indicate the error.
-.Sh ERRORS
-.Fn pthread_cond_init
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The value specified by
-.Fa attr
-is invalid.
-.It Bq Er ENOMEM
-The process cannot allocate enough memory to create another condition
-variable.
-.It Bq Er EAGAIN
-The temporarily lacks the resources to create another condition variable.
-.El
-.Pp
-.Sh SEE ALSO
-.Xr pthread_cond_broadcast 3 ,
-.Xr pthread_cond_destroy 3 ,
-.Xr pthread_cond_signal 3 ,
-.Xr pthread_cond_timedwait 3 ,
-.Xr pthread_cond_wait 3
-.Sh STANDARDS
-.Fn pthread_cond_init
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/lib/libpthread/man/pthread_cond_signal.3 b/lib/libpthread/man/pthread_cond_signal.3
deleted file mode 100644
index e3a22f88cf6c..000000000000
--- a/lib/libpthread/man/pthread_cond_signal.3
+++ /dev/null
@@ -1,70 +0,0 @@
-.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com>
-.\" 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 author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd July 28, 1998
-.Dt PTHREAD_COND_SIGNAL 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_cond_signal
-.Nd unblock a thread waiting for a condition variable
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_cond_signal "pthread_cond_t *cond"
-.Sh DESCRIPTION
-The
-.Fn pthread_cond_signal
-function unblocks one thread waiting for the condition variable
-.Fa cond .
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_cond_signal
-function will return zero, otherwise an error number will be returned
-to indicate the error.
-.Sh ERRORS
-.Fn pthread_cond_signal
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The value specified by
-.Fa cond
-is invalid.
-.El
-.Pp
-.Sh SEE ALSO
-.Xr pthread_cond_broadcast 3 ,
-.Xr pthread_cond_destroy 3 ,
-.Xr pthread_cond_init 3 ,
-.Xr pthread_cond_timedwait 3 ,
-.Xr pthread_cond_wait 3
-.Sh STANDARDS
-.Fn pthread_cond_signal
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/lib/libpthread/man/pthread_cond_timedwait.3 b/lib/libpthread/man/pthread_cond_timedwait.3
deleted file mode 100644
index 15f4bb3d64c3..000000000000
--- a/lib/libpthread/man/pthread_cond_timedwait.3
+++ /dev/null
@@ -1,89 +0,0 @@
-.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com>
-.\" 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 author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd July 28, 1998
-.Dt PTHREAD_COND_TIMEDWAIT 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_cond_timedwait
-.Nd wait on a condition variable for a specific amount of time
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_cond_timedwait "pthread_cond_t *cond" "pthread_mutex_t *mutex" "const struct timespec *abstime"
-.Sh DESCRIPTION
-The
-.Fn pthread_cond_timedwait
-function atomically blocks the current thread waiting on the condition
-variable specified by
-.Fa cond ,
-and unblocks the mutex specified by
-.Fa mutex .
-The waiting thread unblocks only after another thread calls
-.Xr pthread_cond_signal 3 ,
-or
-.Xr pthread_cond_broadcast 3
-with the same condition variable, or if the system time reaches the
-time specified in
-.Fa abstime ,
-and the current thread requires the lock on
-.Fa mutex .
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_cond_timedwait
-function will return zero.
-Otherwise an error number will be returned to
-indicate the error.
-.Sh ERRORS
-.Fn pthread_cond_timedwait
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The value specified by
-.Fa cond ,
-.Fa mutex
-or
-.Fa abstime
-is invalid.
-.It Bq Er ETIMEDOUT
-The system time has reached or exceeded the time specified in
-.Fa abstime .
-.El
-.Pp
-.Sh SEE ALSO
-.Xr pthread_cond_broadcast 3 ,
-.Xr pthread_cond_destroy 3 ,
-.Xr pthread_cond_init 3 ,
-.Xr pthread_cond_signal 3 ,
-.Xr pthread_cond_wait 3
-.Sh STANDARDS
-.Fn pthread_cond_timedwait
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/lib/libpthread/man/pthread_cond_wait.3 b/lib/libpthread/man/pthread_cond_wait.3
deleted file mode 100644
index e93114c7d924..000000000000
--- a/lib/libpthread/man/pthread_cond_wait.3
+++ /dev/null
@@ -1,82 +0,0 @@
-.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com>
-.\" 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 author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd July 28, 1998
-.Dt PTHREAD_COND_WAIT 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_cond_wait
-.Nd wait on a condition variable
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_cond_wait "pthread_cond_t *cond" "pthread_mutex_t *mutex"
-.Sh DESCRIPTION
-The
-.Fn pthread_cond_wait
-function atomically blocks the current thread waiting on the condition
-variable specified by
-.Fa cond ,
-and unblocks the mutex specified by
-.Fa mutex .
-The waiting thread unblocks only after another thread calls
-.Xr pthread_cond_signal 3 , or
-.Xr pthread_cond_broadcast 3
-with the same condition variable, and the current thread requires the lock
-on
-.Fa mutex .
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_cond_wait
-function will return zero.
-Otherwise an error number will be returned to
-indicate the error.
-.Sh ERRORS
-.Fn pthread_cond_wait
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The value specified by
-.Fa cond
-or the value specified by
-.Fa mutex
-is invalid.
-.El
-.Pp
-.Sh SEE ALSO
-.Xr pthread_cond_broadcast 3 ,
-.Xr pthread_cond_destroy 3 ,
-.Xr pthread_cond_init 3 ,
-.Xr pthread_cond_signal 3 ,
-.Xr pthread_cond_timedwait 3
-.Sh STANDARDS
-.Fn pthread_cond_wait
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/lib/libpthread/man/pthread_create.3 b/lib/libpthread/man/pthread_create.3
deleted file mode 100644
index 3e1ed04e80aa..000000000000
--- a/lib/libpthread/man/pthread_create.3
+++ /dev/null
@@ -1,121 +0,0 @@
-.\" Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>.
-.\" 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 John Birrell.
-.\" 4. Neither the name of the author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd April 4, 1996
-.Dt PTHREAD_CREATE 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_create
-.Nd create a new thread
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_create "pthread_t *thread" "const pthread_attr_t *attr" "void *(*start_routine)(void *)" "void *arg"
-.Sh DESCRIPTION
-The
-.Fn pthread_create
-function is used to create a new thread, with attributes specified by
-.Fa attr ,
-within a process.
-If
-.Fa attr
-is NULL, the default attributes are used.
-If the attributes specified by
-.Fa attr
-are modified later, the thread's attributes are not affected.
-Upon
-successful completion
-.Fn pthread_create
-will store the ID of the created thread in the location specified by
-.Fa thread .
-.Pp
-The thread is created executing
-.Fa start_routine
-with
-.Fa arg
-as its sole argument.
-If the
-.Fa start_routine
-returns, the effect is as if there was an implicit call to
-.Fn pthread_exit
-using the return value of
-.Fa start_routine
-as the exit status.
-Note that the thread in which
-.Fn main
-was originally invoked differs from this.
-When it returns from
-.Fn main ,
-the effect is as if there was an implicit call to
-.Fn exit
-using the return value of
-.Fn main
-as the exit status.
-.Pp
-The signal state of the new thread is initialized as:
-.Bl -bullet -offset indent
-.It
-The signal mask is inherited from the creating thread.
-.It
-The set of signals pending for the new thread is empty.
-.El
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_create
-function will return zero.
-Otherwise an error number will be returned to
-indicate the error.
-.Sh ERRORS
-.Fn pthread_create
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EAGAIN
-The system lacked the necessary resources to create another thread, or
-the system-imposed limit on the total number of threads in a process
-[PTHREAD_THREADS_MAX] would be exceeded.
-.It Bq Er EINVAL
-The value specified by
-.Fa attr
-is invalid.
-.El
-.Pp
-.Sh SEE ALSO
-.Xr fork 2 ,
-.Xr pthread_cleanup_pop 3 ,
-.Xr pthread_cleanup_push 3 ,
-.Xr pthread_exit 3 ,
-.Xr pthread_join 3
-.Sh STANDARDS
-.Fn pthread_create
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/lib/libpthread/man/pthread_detach.3 b/lib/libpthread/man/pthread_detach.3
deleted file mode 100644
index 120248d19d98..000000000000
--- a/lib/libpthread/man/pthread_detach.3
+++ /dev/null
@@ -1,89 +0,0 @@
-.\" Copyright (c) 1996-1998 John Birrell <jb@cimlogic.com.au>.
-.\" 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 John Birrell.
-.\" 4. Neither the name of the author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd April 4, 1996
-.Dt PTHREAD_DETACH 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_detach
-.Nd detach a thread
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_detach "pthread_t thread"
-.Sh DESCRIPTION
-The
-.Fn pthread_detach
-function is used to indicate to the implementation that storage for the
-thread
-.Fa thread
-can be reclaimed when the thread terminates.
-If
-.Fa thread
-has not terminated,
-.Fn pthread_detach
-will not cause it to terminate.
-The effect of multiple
-.Fn pthread_detach
-calls on the same target thread is unspecified.
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_detach
-function will return zero.
-Otherwise an error number will be returned to
-indicate the error.
-Note that the function does not change the value
-of errno as it did for some drafts of the standard.
-These early drafts
-also passed a pointer to pthread_t as the argument.
-Beware!
-.Sh ERRORS
-.Fn pthread_detach
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The implementation has detected that the value specified by
-.Fa thread
-does not refer to a joinable thread.
-.It Bq Er ESRCH
-No thread could be found corresponding to that specified by the given
-thread ID,
-.Fa thread .
-.El
-.Pp
-.Sh SEE ALSO
-.Xr pthread_join 3
-.Sh STANDARDS
-.Fn pthread_detach
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/lib/libpthread/man/pthread_equal.3 b/lib/libpthread/man/pthread_equal.3
deleted file mode 100644
index 5d443b3cb2c6..000000000000
--- a/lib/libpthread/man/pthread_equal.3
+++ /dev/null
@@ -1,68 +0,0 @@
-.\" Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>.
-.\" 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 John Birrell.
-.\" 4. Neither the name of the author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd April 4, 1996
-.Dt PTHREAD_EQUAL 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_equal
-.Nd compare thread IDs
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_equal "pthread_t t1" "pthread_t t2"
-.Sh DESCRIPTION
-The
-.Fn pthread_equal
-function compares the thread IDs
-.Fa t1
-and
-.Fa t2 .
-.Sh RETURN VALUES
-The
-.Fn pthread_equal
-function will non-zero if the thread IDs
-.Fa t1
-and
-.Fa t2
-correspond to the same thread, otherwise it will return zero.
-.Sh ERRORS
-None.
-.Pp
-.Sh SEE ALSO
-.Xr pthread_create 3 ,
-.Xr pthread_exit 3
-.Sh STANDARDS
-.Fn pthread_equal
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/lib/libpthread/man/pthread_exit.3 b/lib/libpthread/man/pthread_exit.3
deleted file mode 100644
index a5ff1b96ea9d..000000000000
--- a/lib/libpthread/man/pthread_exit.3
+++ /dev/null
@@ -1,105 +0,0 @@
-.\" Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>.
-.\" 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 John Birrell.
-.\" 4. Neither the name of the author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd April 4, 1996
-.Dt PTHREAD_EXIT 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_exit
-.Nd terminate the calling thread
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft void
-.Fn pthread_exit "void *value_ptr"
-.Sh DESCRIPTION
-The
-.Fn pthread_exit
-function terminates the calling thread and makes the value
-.Fa value_ptr
-available to any successful join with the terminating thread.
-Any
-cancellation cleanup handlers that have been pushed and are not yet popped
-are popped in the reverse order that they were pushed and then executed.
-After all cancellation handlers have been executed, if the thread has any
-thread-specific data, appropriate destructor functions are called in an
-unspecified order.
-Thread termination does not release any application
-visible process resources, including, but not limited to, mutexes and
-file descriptors, nor does it perform any process level cleanup
-actions, including, but not limited to, calling
-.Fn atexit
-routines that may exist.
-.Pp
-An implicit call to
-.Fn pthread_exit
-is made when a thread other than the thread in which
-.Fn main
-was first invoked returns from the start routine that was used to create
-it. The function's return value serves as the thread's exit status.
-.Pp
-The behavior of
-.Fn pthread_exit
-is undefied if called from a cancellation handler or destructor function
-that was invoked as the result of an implicit or explicit call to
-.Fn pthread_exit .
-.Pp
-After a thread has terminated, the result of access to local (auto)
-variables of the thread is undefined.
-Thus, references to local variables
-of the exiting thread should not be used for the
-.Fn pthread_exit
-.Fa value_ptr
-parameter value.
-.Pp
-The process will exit with an exit status of 0 after the last thread has
-been terminated.
-The behavior is as if the implementation called
-.Fn exit
-with a zero argument at thread termination time.
-.Pp
-.Sh RETURN VALUES
-The
-.Fn pthread_exit
-function cannot return to its caller.
-.Sh ERRORS
-None.
-.Pp
-.Sh SEE ALSO
-.Xr _exit 2 ,
-.Xr exit 3 ,
-.Xr pthread_create 3 ,
-.Xr pthread_join 3
-.Sh STANDARDS
-.Fn pthread_exit
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/lib/libpthread/man/pthread_getspecific.3 b/lib/libpthread/man/pthread_getspecific.3
deleted file mode 100644
index a56254108f6e..000000000000
--- a/lib/libpthread/man/pthread_getspecific.3
+++ /dev/null
@@ -1,82 +0,0 @@
-.\" Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>.
-.\" 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 John Birrell.
-.\" 4. Neither the name of the author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd April 4, 1996
-.Dt PTHREAD_GETSPECIFIC 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_getspecific
-.Nd get a thread-specific data value
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft void *
-.Fn pthread_getspecific "pthread_key_t key"
-.Sh DESCRIPTION
-The
-.Fn pthread_getspecific
-function returns the value currently bound to the specified
-.Fa key
-on behalf of the calling thread.
-.Pp
-The effect of calling
-.Fn pthread_getspecific
-with a
-.Fa key
-value not obtained from
-.Fn pthread_key_create
-or after
-.Fa key
-has been deleted with
-.Fn pthread_key_delete
-is undefined.
-.Pp
-.Fn pthread_getspecific
-may be called from a thread-specific data destructor function.
-.Sh RETURN VALUES
-The
-.Fn pthread_getspecific
-function will return the thread-specific data value associated with the given
-.Fa key .
-If no thread-specific data value is associated with
-.Fa key ,
-then the value NULL is returned.
-.Sh ERRORS
-None.
-.Sh SEE ALSO
-.Xr pthread_key_create 3 ,
-.Xr pthread_key_delete 3 ,
-.Xr pthread_setspecific 3
-.Sh STANDARDS
-.Fn pthread_getspecific
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/lib/libpthread/man/pthread_join.3 b/lib/libpthread/man/pthread_join.3
deleted file mode 100644
index 2e5ae40c105a..000000000000
--- a/lib/libpthread/man/pthread_join.3
+++ /dev/null
@@ -1,105 +0,0 @@
-.\" Copyright (c) 1996-1998 John Birrell <jb@cimlogic.com.au>.
-.\" 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 John Birrell.
-.\" 4. Neither the name of the author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd April 4, 1996
-.Dt PTHREAD_JOIN 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_join
-.Nd wait for thread termination
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_join "pthread_t thread" "void **value_ptr"
-.Sh DESCRIPTION
-The
-.Fn pthread_join
-function suspends execution of the calling thread until the target
-.Fa thread
-terminates unless the target
-.Fa thread
-has already terminated.
-.Pp
-On return from a successful
-.Fn pthread_join
-call with a non-NULL
-.Fa value_ptr
-argument, the value passed to
-.Fn pthread_exit
-by the terminating thread is stored in the location referenced by
-.Fa value_ptr .
-When a
-.Fn pthread_join
-returns successfully, the target thread has been terminated.
-The results
-of multiple simultaneous calls to
-.Fn pthread_join
-specifying the same target thread are undefined.
-If the thread calling
-.Fn pthread_join
-is cancelled, then the target thread is not detached.
-.Pp
-A thread that has exited but remains unjoined counts against
-[_POSIX_THREAD_THREADS_MAX].
-.Pp
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_join
-function will return zero.
-Otherwise an error number will be returned to
-indicate the error.
-.Sh ERRORS
-.Fn pthread_join
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The implementation has detected that the value specified by
-.Fa thread
-does not refer to a joinable thread.
-.It Bq Er ESRCH
-No thread could be found corresponding to that specified by the given
-thread ID,
-.Fa thread .
-.It Bq Er EDEADLK
-A deadlock was detected or the value of
-.Fa thread
-specifies the calling thread.
-.El
-.Pp
-.Sh SEE ALSO
-.Xr wait 2 ,
-.Xr pthread_create 3
-.Sh STANDARDS
-.Fn pthread_join
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/lib/libpthread/man/pthread_key_create.3 b/lib/libpthread/man/pthread_key_create.3
deleted file mode 100644
index 376ecf2fb542..000000000000
--- a/lib/libpthread/man/pthread_key_create.3
+++ /dev/null
@@ -1,107 +0,0 @@
-.\" Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>.
-.\" 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 John Birrell.
-.\" 4. Neither the name of the author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd April 4, 1996
-.Dt PTHREAD_KEY_CREATE 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_key_create
-.Nd thread-specific data key creation
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_key_create "pthread_key_t *key" "void (*destructor)(void *)"
-.Sh DESCRIPTION
-The
-.Fn pthread_key_create
-function creates a thread-specific data key visible to all threads in the
-process.
-Key values provided by
-.Fn pthread_key_create
-are opaque objects used to locate thread-specific data.
-Although the same
-key value may be used by different threads, the values bound to the key
-by
-.Fn pthread_setspecific
-are maintained on a per-thread basis and persist for the life of the calling
-thread.
-.Pp
-Upon key creation, the value NULL is associated with the new key in all
-active threads.
-Upon thread creation, the value NULL is associated with all
-defined keys in the new thread.
-.Pp
-An optional destructor function may be associated with each key value.
-At
-thread exit, if a key value has a non-NULL destructor pointer, and the
-thread has a non-NULL value associated with the key, the function pointed
-to is called with the current associated value as its sole argument.
-The
-order of destructor calls is unspecified if more than one destructor exists
-for a thread when it exits.
-.Pp
-If, after all the destructors have been called for all non-NULL values
-with associated destructors, there are still some non-NULL values with
-associated destructors, then the process is repeated.
-If, after at least
-[PTHREAD_DESTRUCTOR_ITERATIONS] iterations of destructor calls for
-outstanding non-NULL values, there are still some non-NULL values with
-associated destructors, the implementation stops calling destructors.
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_key_create
-function will store the newly created key value at the location specified by
-.Fa key
-and returns zero.
-Otherwise an error number will be returned to indicate
-the error.
-.Sh ERRORS
-.Fn pthread_key_create
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EAGAIN
-The system lacked the necessary resources to create another thread-specific
-data key, or the system-imposed limit on the total number of keys per process
-[PTHREAD_KEYS_MAX] would be exceeded.
-.It Bq Er ENOMEM
-Insufficient memory exists to create the key.
-.El
-.Pp
-.Sh SEE ALSO
-.Xr pthread_getspecific 3 ,
-.Xr pthread_key_delete 3 ,
-.Xr pthread_setspecific 3
-.Sh STANDARDS
-.Fn pthread_key_create
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/lib/libpthread/man/pthread_key_delete.3 b/lib/libpthread/man/pthread_key_delete.3
deleted file mode 100644
index 25f110f3be0b..000000000000
--- a/lib/libpthread/man/pthread_key_delete.3
+++ /dev/null
@@ -1,98 +0,0 @@
-.\" Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>.
-.\" 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 John Birrell.
-.\" 4. Neither the name of the author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd April 4, 1996
-.Dt PTHREAD_KEY_DELETE 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_key_delete
-.Nd delete a thread-specific data key
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_key_delete "pthread_key_t key"
-.Sh DESCRIPTION
-The
-.Fn pthread_key_delete
-function deletes a thread-specific data key previously returned by
-.Fn pthread_key_create .
-The thread-specific data values associated with
-.Fa key
-need not be NULL at the time that
-.Fn pthread_key_delete
-is called.
-It is the responsibility of the application to free any
-application storage or perform any cleanup actions for data structures
-related to the deleted key or associated thread-specific data in any threads;
-this cleanup can be done either before or after
-.Fn pthread_key_delete
-is called.
-Any attempt to use
-.Fa key
-following the call to
-.Fn pthread_key_delete
-results in undefined behavior.
-.Pp
-The
-.Fn pthread_key_delete
-function is callable from within destructor functions.
-Destructor functions
-are not invoked by
-.Fn pthread_key_delete .
-Any destructor function that may have been associated with
-.Fa key
-will no longer be called upon thread exit.
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_key_delete
-function will return zero.
-Otherwise an error number will be returned to
-indicate the error.
-.Sh ERRORS
-.Fn pthread_key_delete
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The
-.Fa key
-value is invalid.
-.El
-.Pp
-.Sh SEE ALSO
-.Xr pthread_getspecific 3 ,
-.Xr pthread_key_create 3 ,
-.Xr pthread_setspecific 3
-.Sh STANDARDS
-.Fn pthread_key_delete
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/lib/libpthread/man/pthread_mutex_destroy.3 b/lib/libpthread/man/pthread_mutex_destroy.3
deleted file mode 100644
index 517d6ebadf5d..000000000000
--- a/lib/libpthread/man/pthread_mutex_destroy.3
+++ /dev/null
@@ -1,72 +0,0 @@
-.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com>
-.\" 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 author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd July 29, 1998
-.Dt PTHREAD_MUTEX_DESTROY 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_mutex_destroy
-.Nd free resources allocated for a mutex
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_mutex_destroy "pthread_mutex_t *mutex"
-.Sh DESCRIPTION
-The
-.Fn pthread_mutex_destroy
-function frees the resources allocated for
-.Fa mutex .
-.Sh RETURN VALUES
-If successful,
-.Fn pthread_mutex_destroy
-will return zero, otherwise an error number will be returned to
-indicate the error.
-.Sh ERRORS
-.Fn pthread_mutex_destroy
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The value specified by
-.Fa mutex
-is invalid.
-.It Bq Er EBUSY
-.Fa Mutex
-is locked by another thread.
-.El
-.Pp
-.Sh SEE ALSO
-.Xr pthread_mutex_init 3 ,
-.Xr pthread_mutex_lock 3 ,
-.Xr pthread_mutex_trylock 3 ,
-.Xr pthread_mutex_unlock 3
-.Sh STANDARDS
-.Fn pthread_mutex_destroy
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/lib/libpthread/man/pthread_mutex_init.3 b/lib/libpthread/man/pthread_mutex_init.3
deleted file mode 100644
index 926b034b6011..000000000000
--- a/lib/libpthread/man/pthread_mutex_init.3
+++ /dev/null
@@ -1,77 +0,0 @@
-.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com>
-.\" 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 author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd July 29, 1998
-.Dt PTHREAD_MUTEX_INIT 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_mutex_init
-.Nd create a mutex
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_mutex_init "pthread_mutex_t *mutex" "const pthread_mutexattr_t *attr"
-.Sh DESCRIPTION
-The
-.Fn pthread_mutex_init
-function creates a new mutex, with attributes specified with
-.Fa attr .
-If
-.Fa attr
-is NULL the default attributes are used.
-.Sh RETURN VALUES
-If successful,
-.Fn pthread_mutex_init
-will return zero and put the new mutex id into
-.Fa mutex ,
-otherwise an error number will be returned to indicate the error.
-.Sh ERRORS
-.Fn pthread_mutex_init
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The value specified by
-.Fa attr
-is invalid.
-.It Bq Er ENOMEM
-The process cannot allocate enough memory to create another mutex.
-.It Bq Er EAGAIN
-The temporarily lacks the resources to create another mutex.
-.El
-.Pp
-.Sh SEE ALSO
-.Xr pthread_mutex_destroy 3 ,
-.Xr pthread_mutex_lock 3 ,
-.Xr pthread_mutex_trylock 3 ,
-.Xr pthread_mutex_unlock 3
-.Sh STANDARDS
-.Fn pthread_mutex_init
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/lib/libpthread/man/pthread_mutex_lock.3 b/lib/libpthread/man/pthread_mutex_lock.3
deleted file mode 100644
index 36473733ce11..000000000000
--- a/lib/libpthread/man/pthread_mutex_lock.3
+++ /dev/null
@@ -1,74 +0,0 @@
-.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com>
-.\" 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 author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd July 30, 1998
-.Dt PTHREAD_MUTEX_LOCK 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_mutex_lock
-.Nd lock a mutex
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_mutex_lock "pthread_mutex_t *mutex"
-.Sh DESCRIPTION
-The
-.Fn pthread_mutex_lock
-function locks
-.Fa mutex .
-If the mutex is already locked, the calling thread will block until the
-mutex becomes available.
-.Sh RETURN VALUES
-If successful,
-.Fn pthread_mutex_lock
-will return zero, otherwise an error number will be returned to
-indicate the error.
-.Sh ERRORS
-.Fn pthread_mutex_lock
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The value specified by
-.Fa mutex
-is invalid.
-.It Bq Er EDEADLK
-A deadlock would occur if the thread blocked waiting for
-.Fa mutex .
-.El
-.Pp
-.Sh SEE ALSO
-.Xr pthread_mutex_destroy 3 ,
-.Xr pthread_mutex_init 3 ,
-.Xr pthread_mutex_trylock 3 ,
-.Xr pthread_mutex_unlock 3
-.Sh STANDARDS
-.Fn pthread_mutex_lock
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/lib/libpthread/man/pthread_mutex_trylock.3 b/lib/libpthread/man/pthread_mutex_trylock.3
deleted file mode 100644
index 30faaa81bd4d..000000000000
--- a/lib/libpthread/man/pthread_mutex_trylock.3
+++ /dev/null
@@ -1,75 +0,0 @@
-.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com>
-.\" 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 author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd July 30, 1998
-.Dt PTHREAD_MUTEX_TRYLOCK 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_mutex_trylock
-.Nd attempt to lock a mutex without blocking
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_mutex_trylock "pthread_mutex_t *mutex"
-.Sh DESCRIPTION
-The
-.Fn pthread_mutex_trylock
-function locks
-.Fa mutex .
-If the mutex is already locked,
-.Fn pthread_mutex_trylock
-will not block waiting for the mutex, but will return an error condition.
-.Sh RETURN VALUES
-If successful,
-.Fn pthread_mutex_trylock
-will return zero, otherwise an error number will be returned to
-indicate the error.
-.Sh ERRORS
-.Fn pthread_mutex_trylock
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The value specified by
-.Fa mutex
-is invalid.
-.It Bq Er EBUSY
-.Fa Mutex
-is already locked.
-.El
-.Pp
-.Sh SEE ALSO
-.Xr pthread_mutex_destroy 3 ,
-.Xr pthread_mutex_init 3 ,
-.Xr pthread_mutex_lock 3 ,
-.Xr pthread_mutex_unlock 3
-.Sh STANDARDS
-.Fn pthread_mutex_trylock
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/lib/libpthread/man/pthread_mutex_unlock.3 b/lib/libpthread/man/pthread_mutex_unlock.3
deleted file mode 100644
index 27a4c337fe37..000000000000
--- a/lib/libpthread/man/pthread_mutex_unlock.3
+++ /dev/null
@@ -1,74 +0,0 @@
-.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com>
-.\" 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 author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd July 30, 1998
-.Dt PTHREAD_MUTEX_UNLOCK 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_mutex_unlock
-.Nd unlock a mutex
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_mutex_unlock "pthread_mutex_t *mutex"
-.Sh DESCRIPTION
-If the current thread holds the lock on
-.Fa mutex ,
-then the
-.Fn pthread_mutex_unlock
-function unlocks
-.Fa mutex .
-.Sh RETURN VALUES
-If successful,
-.Fn pthread_mutex_unlock
-will return zero, otherwise an error number will be returned to
-indicate the error.
-.Sh ERRORS
-.Fn pthread_mutex_trylock
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The value specified by
-.Fa mutex
-is invalid.
-.It Bq Er EPERM
-The current thread does not hold a lock on
-.Fa mutex .
-.El
-.Pp
-.Sh SEE ALSO
-.Xr pthread_mutex_destroy 3 ,
-.Xr pthread_mutex_init 3 ,
-.Xr pthread_mutex_lock 3 ,
-.Xr pthread_mutex_trylock 3
-.Sh STANDARDS
-.Fn pthread_mutex_unlock
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/lib/libpthread/man/pthread_once.3 b/lib/libpthread/man/pthread_once.3
deleted file mode 100644
index 8cd894abbd19..000000000000
--- a/lib/libpthread/man/pthread_once.3
+++ /dev/null
@@ -1,106 +0,0 @@
-.\" Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>.
-.\" 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 John Birrell.
-.\" 4. Neither the name of the author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd April 4, 1996
-.Dt PTHREAD_ONCE 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_once
-.Nd dynamic package initialization
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Pp
-pthread_once
-.Fa once_control
-= PTHREAD_ONCE_INIT;
-.Ft int
-.Fn pthread_once "pthread_once_t *once_control" "void (*init_routine)(void)"
-.Sh DESCRIPTION
-The first call to
-.Fn pthread_once
-by any thread in a process, with a given
-.Fa once_control ,
-will call the
-.Fn init_routine
-with no arguments.
-Subsequent calls to
-.Fn pthread_once
-with the same
-.Fa once_control
-will not call the
-.Fn init_routine .
-On return from
-.Fn pthread_once ,
-it is guaranteed that
-.Fn init_routine
-has completed.
-The
-.Fa once_control
-parameter is used to determine whether the associated initialization
-routine has been called.
-.Pp
-The function
-.Fn pthread_once
-is not a cancellation point.
-However, if
-.Fn init_routine
-is a cancellation point and is cancelled, the effect on
-.Fa once_control is as if
-.Fn pthread_once
-was never called.
-.Pp
-The constant
-.Fa PTHREAD_ONCE_INIT
-is defined by header
-.Aq Pa pthread.h .
-.Pp
-The behavior of
-.Fn pthread_once
-is undefined if
-.Fa once_control
-has automatic storage duration or is not initialized by
-.Fa PTHREAD_ONCE_INIT .
-.Pp
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_once
-function will return zero.
-Otherwise an error number will be returned to
-indicate the error.
-.Sh ERRORS
-None.
-.Pp
-.Sh STANDARDS
-.Fn pthread_once
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/lib/libpthread/man/pthread_rwlock_destroy.3 b/lib/libpthread/man/pthread_rwlock_destroy.3
deleted file mode 100644
index 14691c44bbf8..000000000000
--- a/lib/libpthread/man/pthread_rwlock_destroy.3
+++ /dev/null
@@ -1,80 +0,0 @@
-.\" Copyright (c) 1998 Alex Nash
-.\" 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 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd August 4, 1998
-.Dt PTHREAD_RWLOCK_DESTROY 3
-.Os
-.Sh NAME
-.Nm pthread_rwlock_destroy
-.Nd destroy a read/write lock
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_rwlock_destroy "pthread_rwlock_t *lock"
-.Sh DESCRIPTION
-The
-.Fn pthread_rwlock_destroy
-function is used to destroy a read/write lock previously created with
-.Fn pthread_rwlock_init .
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_rwlock_destroy
-function will return zero. Otherwise an error number will be returned
-to indicate the error.
-.Sh SEE ALSO
-.Xr pthread_rwlock_init 3
-.Sh STANDARDS
-The
-.Fn pthread_rwlock_destroy
-function is expected to conform to
-.St -susv2 .
-.Sh ERRORS
-The
-.Fn pthread_rwlock_destroy
-function will fail if:
-.Bl -tag -width Er
-.It Bq Er EPERM
-The caller does not have the privilege to perform the operation.
-.El
-.Pp
-The
-.Fn pthread_rwlock_destroy
-function may fail if:
-.Bl -tag -width Er
-.It Bq Er EBUSY
-The system has detected an attempt to destroy the object referenced by
-.Fa lock
-while it is locked.
-.It Bq Er EINVAL
-The value specified by
-.Fa lock
-is invalid.
-.El
-.Sh HISTORY
-The
-.Fn pthread_rwlock_destroy
-function first appeared in
-.Fx 3.0 .
diff --git a/lib/libpthread/man/pthread_rwlock_init.3 b/lib/libpthread/man/pthread_rwlock_init.3
deleted file mode 100644
index 306af61bbeb4..000000000000
--- a/lib/libpthread/man/pthread_rwlock_init.3
+++ /dev/null
@@ -1,99 +0,0 @@
-.\" Copyright (c) 1998 Alex Nash
-.\" 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 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd August 4, 1998
-.Dt PTHREAD_RWLOCK_INIT 3
-.Os
-.Sh NAME
-.Nm pthread_rwlock_init
-.Nd initialize a read/write lock
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_rwlock_init "pthread_rwlock_t *lock" "const pthread_rwlockattr_t *attr"
-.Sh DESCRIPTION
-The
-.Fn pthread_rwlock_init
-function is used to initialize a read/write lock, with attributes
-specified by
-.Fa attr .
-If
-.Fa attr
-is NULL, the default read/write lock attributes are used.
-.Pp
-The results of calling
-.Fn pthread_rwlock_init
-with an already initialized lock are undefined.
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_rwlock_init
-function will return zero. Otherwise an error number will be returned
-to indicate the error.
-.Sh SEE ALSO
-.Xr pthread_rwlock_destroy 3 ,
-.Xr pthread_rwlockattr_init 3 ,
-.Xr pthread_rwlockattr_setpshared 3
-.Sh STANDARDS
-The
-.Fn pthread_rwlock_init
-function is expected to conform to
-.St -susv2 .
-.Sh ERRORS
-The
-.Fn pthread_rwlock_init
-function will fail if:
-.Bl -tag -width Er
-.It Bq Er EAGAIN
-The system lacked the necessary resources (other than memory) to
-initialize the lock.
-.It Bq Er ENOMEM
-Insufficient memory exists to initialize the lock.
-.It Bq Er EPERM
-The caller does not have sufficient privilege to perform the
-operation.
-.El
-.Pp
-The
-.Fn pthread_rwlock_init
-function may fail if:
-.Bl -tag -width Er
-.It Bq Er EBUSY
-The system has detected an attempt to re-initialize the object
-referenced by
-.Fa lock ,
-a previously initialized but not yet destroyed read/write lock.
-.It Bq Er EINVAL
-The value specified by
-.Fa attr
-is invalid.
-.El
-.Sh HISTORY
-The
-.Fn pthread_rwlock_init
-function first appeared in
-.Fx 3.0 .
-.Sh BUGS
-The PTHREAD_PROCESS_SHARED attribute is not supported.
diff --git a/lib/libpthread/man/pthread_rwlock_rdlock.3 b/lib/libpthread/man/pthread_rwlock_rdlock.3
deleted file mode 100644
index bea219de0100..000000000000
--- a/lib/libpthread/man/pthread_rwlock_rdlock.3
+++ /dev/null
@@ -1,122 +0,0 @@
-.\" Copyright (c) 1998 Alex Nash
-.\" 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 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd August 4, 1998
-.Dt PTHREAD_RWLOCK_RDLOCK 3
-.Os
-.Sh NAME
-.Nm pthread_rwlock_rdlock ,
-.Nm pthread_rwlock_tryrdlock
-.Nd acquire a read/write lock for reading
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_rwlock_rdlock "pthread_rwlock_t *lock"
-.Ft int
-.Fn pthread_rwlock_tryrdlock "pthread_rwlock_t *lock"
-.Sh DESCRIPTION
-The
-.Fn pthread_rwlock_rdlock
-function acquires a read lock on
-.Fa lock
-provided that
-.Fa lock
-is not presently held for writing and no writer threads are
-presently blocked on the lock. If the read lock cannot be
-immediately acquired, the calling thread blocks until it can
-acquire the lock.
-.Pp
-The
-.Fn pthread_rwlock_tryrdlock
-function performs the same action, but does not block if the lock
-cannot be immediately obtained (i.e. the lock is held for writing
-or there are waiting writers).
-.Pp
-A thread may hold multiple concurrent read locks. If so,
-.Fn pthread_rwlock_unlock
-must be called once for each lock obtained.
-.Pp
-The results of acquiring a read lock while the calling thread holds
-a write lock are undefined.
-.Sh IMPLEMENTATION NOTES
-To prevent writer starvation, writers are favored over readers.
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_rwlock_rdlock
-and
-.Fn pthread_rwlock_tryrdlock
-functions will return zero. Otherwise an error number will be returned
-to indicate the error.
-.Sh SEE ALSO
-.Xr pthread_rwlock_init 3 ,
-.Xr pthread_rwlock_trywrlock 3 ,
-.Xr pthread_rwlock_unlock 3 ,
-.Xr pthread_rwlock_wrlock 3
-.Sh STANDARDS
-The
-.Fn pthread_rwlock_rdlock
-and
-.Fn pthread_rwlock_tryrdlock
-functions are expected to conform to
-.St -susv2 .
-.Sh ERRORS
-The
-.Fn pthread_rwlock_tryrdlock
-function will fail if:
-.Bl -tag -width Er
-.It Bq Er EBUSY
-The lock could not be acquired because a writer holds the lock or
-was blocked on it.
-.El
-.Pp
-The
-.Fn pthread_rwlock_rdlock
-and
-.Fn pthread_rwlock_tryrdlock
-functions may fail if:
-.Bl -tag -width Er
-.It Bq Er EAGAIN
-The lock could not be acquired because the maximum number of read locks
-against
-.Fa lock
-has been exceeded.
-.It Bq Er EDEADLK
-The current thread already owns
-.Fa lock
-for writing.
-.It Bq Er EINVAL
-The value specified by
-.Fa lock
-is invalid.
-.It Bq Er ENOMEM
-Insufficient memory exists to initialize the lock (applies to
-statically initialized locks only).
-.El
-.Sh HISTORY
-The
-.Fn pthread_rwlock_rdlock
-function first appeared in
-.Fx 3.0 .
diff --git a/lib/libpthread/man/pthread_rwlock_unlock.3 b/lib/libpthread/man/pthread_rwlock_unlock.3
deleted file mode 100644
index 7ad52b257120..000000000000
--- a/lib/libpthread/man/pthread_rwlock_unlock.3
+++ /dev/null
@@ -1,79 +0,0 @@
-.\" Copyright (c) 1998 Alex Nash
-.\" 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 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd August 4, 1998
-.Dt PTHREAD_RWLOCK_UNLOCK 3
-.Os
-.Sh NAME
-.Nm pthread_rwlock_unlock
-.Nd release a read/write lock
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_rwlock_unlock "pthread_rwlock_t *lock"
-.Sh DESCRIPTION
-The
-.Fn pthread_rwlock_unlock
-function is used to release the read/write lock previously obtained by
-.Fn pthread_rwlock_rdlock ,
-.Fn pthread_rwlock_wrlock ,
-.Fn pthread_rwlock_tryrdlock ,
-or
-.Fn pthread_rwlock_trywrlock .
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_rwlock_unlock
-function will return zero. Otherwise an error number will be returned
-to indicate the error.
-.Pp
-The results are undefined if
-.Fa lock
-is not held by the calling thread.
-.Sh SEE ALSO
-.Xr pthread_rwlock_rdlock 3 ,
-.Xr pthread_rwlock_wrlock 3
-.Sh STANDARDS
-The
-.Fn pthread_rwlock_unlock
-function is expected to conform to
-.St -susv2 .
-.Sh ERRORS
-The
-.Fn pthread_rwlock_unlock
-function may fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The value specified by
-.Fa lock
-is invalid.
-.It Bq Er EPERM
-The current thread does not own the read/write lock.
-.El
-.Sh HISTORY
-The
-.Fn pthread_rwlock_unlock
-function first appeared in
-.Fx 3.0 .
diff --git a/lib/libpthread/man/pthread_rwlock_wrlock.3 b/lib/libpthread/man/pthread_rwlock_wrlock.3
deleted file mode 100644
index b6a2312a79d6..000000000000
--- a/lib/libpthread/man/pthread_rwlock_wrlock.3
+++ /dev/null
@@ -1,102 +0,0 @@
-.\" Copyright (c) 1998 Alex Nash
-.\" 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 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd August 4, 1998
-.Dt PTHREAD_RWLOCK_WRLOCK 3
-.Os
-.Sh NAME
-.Nm pthread_rwlock_wrlock ,
-.Nm pthread_rwlock_trywrlock
-.Nd acquire a read/write lock for writing
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_rwlock_wrlock "pthread_rwlock_t *lock"
-.Ft int
-.Fn pthread_rwlock_trywrlock "pthread_rwlock_t *lock"
-.Sh DESCRIPTION
-The
-.Fn pthread_rwlock_wrlock
-function blocks until a write lock can be acquired against
-.Fa lock .
-The
-.Fn pthread_rwlock_trywrlock
-function performs the same action, but does not block if the lock
-cannot be immediately obtained.
-.Pp
-The results are undefined if the calling thread already holds the
-lock at the time the call is made.
-.Sh IMPLEMENTATION NOTES
-To prevent writer starvation, writers are favored over readers.
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_rwlock_wrlock
-and
-.Fn pthread_rwlock_trywrlock
-functions will return zero. Otherwise an error number will be returned
-to indicate the error.
-.Sh SEE ALSO
-.Xr pthread_rwlock_trywrlock 3 ,
-.Xr pthread_rwlock_unlock 3 ,
-.Xr pthread_rwlock_wrlock 3
-.Sh STANDARDS
-The
-.Fn pthread_rwlock_wrlock
-and
-.Fn pthread_rwlock_trywrlock
-functions are expected to conform to
-.St -susv2 .
-.Sh ERRORS
-The
-.Fn pthread_rwlock_trywrlock
-function will fail if:
-.Bl -tag -width Er
-.It Bq Er EBUSY
-The calling thread is not able to acquire the lock without blocking.
-.El
-.Pp
-The
-.Fn pthread_rwlock_wrlock
-and
-.Fn pthread_rwlock_trywrlock
-functions may fail if:
-.Bl -tag -width Er
-.It Bq Er EDEADLK
-The calling thread already owns the read/write lock (for reading
-or writing).
-.It Bq Er EINVAL
-The value specified by
-.Fa lock
-is invalid.
-.It Bq Er ENOMEM
-Insufficient memory exists to initialize the lock (applies to
-statically initialized locks only).
-.El
-.Sh HISTORY
-The
-.Fn pthread_rwlock_wrlock
-function first appeared in
-.Fx 3.0 .
diff --git a/lib/libpthread/man/pthread_rwlockattr_destroy.3 b/lib/libpthread/man/pthread_rwlockattr_destroy.3
deleted file mode 100644
index 2d67041ba161..000000000000
--- a/lib/libpthread/man/pthread_rwlockattr_destroy.3
+++ /dev/null
@@ -1,68 +0,0 @@
-.\" Copyright (c) 1998 Alex Nash
-.\" 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 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd August 4, 1998
-.Dt PTHREAD_RWLOCKATTR_DESTROY 3
-.Os
-.Sh NAME
-.Nm pthread_rwlockattr_destroy
-.Nd destroy a read/write lock
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_rwlockattr_destroy "pthread_rwlockattr_t *attr"
-.Sh DESCRIPTION
-The
-.Fn pthread_rwlockattr_destroy
-function is used to destroy a read/write lock attribute object
-previously created with
-.Fn pthread_rwlockattr_init .
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_rwlockattr_destroy
-function will return zero. Otherwise an error number will be returned
-to indicate the error.
-.Sh SEE ALSO
-.Xr pthread_rwlockattr_init 3
-.Sh STANDARDS
-The
-.Fn pthread_rwlockattr_destroy
-function is expected to conform to
-.St -susv2 .
-.Sh ERRORS
-.Fn pthread_rwlockattr_destroy
-may fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The value specified by
-.Fa attr
-is invalid.
-.El
-.Sh HISTORY
-The
-.Fn pthread_rwlockattr_destroy
-function first appeared in
-.Fx 3.0 .
diff --git a/lib/libpthread/man/pthread_rwlockattr_getpshared.3 b/lib/libpthread/man/pthread_rwlockattr_getpshared.3
deleted file mode 100644
index d2028dc58c6d..000000000000
--- a/lib/libpthread/man/pthread_rwlockattr_getpshared.3
+++ /dev/null
@@ -1,80 +0,0 @@
-.\" Copyright (c) 1998 Alex Nash
-.\" 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 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd March 22, 1999
-.Dt PTHREAD_RWLOCKATTR_GETPSHARED 3
-.Os
-.Sh NAME
-.Nm pthread_rwlockattr_getpshared
-.Nd get the process shared attribute
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_rwlockattr_getpshared "const pthread_rwlockattr_t *attr" "int *pshared"
-.Sh DESCRIPTION
-The
-.Fn pthread_rwlockattr_getpshared
-function is used to get the process shared setting of a read/write
-lock attribute object. The setting is returned via
-.Fa pshared ,
-and may be one of two values:
-.Bl -hang -offset flag -width 123456789012345678901234
-.It Ar PTHREAD_PROCESS_SHARED
-Any thread of any process that has access to the memory where the
-read/write lock resides can manipulate the lock.
-.It Ar PTHREAD_PROCESS_PRIVATE
-Only threads created within the same process as the thread that
-initialized the read/write lock can manipulate the lock. This is
-the default value.
-.El
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_rwlockattr_getpshared
-function will return zero. Otherwise an error number will be returned
-to indicate the error.
-.Sh SEE ALSO
-.Xr pthread_rwlock_init 3 ,
-.Xr pthread_rwlockattr_init 3 ,
-.Xr pthread_rwlockattr_setpshared 3
-.Sh STANDARDS
-The
-.Fn pthread_rwlockattr_getpshared
-function is expected to conform to
-.St -susv2 .
-.Sh ERRORS
-.Fn pthread_rwlockattr_getpshared
-may fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The value specified by
-.Fa attr
-is invalid.
-.El
-.Sh HISTORY
-The
-.Fn pthread_rwlockattr_getpshared
-function first appeared in
-.Fx 3.0 .
diff --git a/lib/libpthread/man/pthread_rwlockattr_init.3 b/lib/libpthread/man/pthread_rwlockattr_init.3
deleted file mode 100644
index ac191260c66d..000000000000
--- a/lib/libpthread/man/pthread_rwlockattr_init.3
+++ /dev/null
@@ -1,67 +0,0 @@
-.\" Copyright (c) 1998 Alex Nash
-.\" 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 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd August 4, 1998
-.Dt PTHREAD_RWLOCKATTR_INIT 3
-.Os
-.Sh NAME
-.Nm pthread_rwlockattr_init
-.Nd initialize a read/write lock
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_rwlockattr_init "pthread_rwlockattr_t *attr"
-.Sh DESCRIPTION
-The
-.Fn pthread_rwlockattr_init
-function is used to initialize a read/write lock attributes object.
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_rwlockattr_init
-function will return zero. Otherwise an error number will be returned
-to indicate the error.
-.Sh SEE ALSO
-.Xr pthread_rwlock_init 3 ,
-.Xr pthread_rwlockattr_destroy 3 ,
-.Xr pthread_rwlockattr_getpshared 3 ,
-.Xr pthread_rwlockattr_setpshared 3
-.Sh STANDARDS
-The
-.Fn pthread_rwlockattr_init
-function is expected to conform to
-.St -susv2 .
-.Sh ERRORS
-.Fn pthread_rwlockattr_init
-will fail if:
-.Bl -tag -width Er
-.It Bq Er ENOMEM
-Insufficient memory exists to initialize the attribute object.
-.El
-.Sh HISTORY
-The
-.Fn pthread_rwlockattr_init
-function first appeared in
-.Fx 3.0 .
diff --git a/lib/libpthread/man/pthread_rwlockattr_setpshared.3 b/lib/libpthread/man/pthread_rwlockattr_setpshared.3
deleted file mode 100644
index 4e4b15812c26..000000000000
--- a/lib/libpthread/man/pthread_rwlockattr_setpshared.3
+++ /dev/null
@@ -1,86 +0,0 @@
-.\" Copyright (c) 1998 Alex Nash
-.\" 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 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd August 4, 1998
-.Dt PTHREAD_RWLOCKATTR_SETPSHARED 3
-.Os
-.Sh NAME
-.Nm pthread_rwlockattr_setpshared
-.Nd set the process shared attribute
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_rwlockattr_setpshared "pthread_rwlockattr_t *attr" "int pshared"
-.Sh DESCRIPTION
-The
-.Fn pthread_rwlockattr_setpshared
-function sets the process shared attribute of
-.Fa attr
-to the value referenced by
-.Fa pshared .
-.Fa pshared
-may be one of two values:
-.Bl -hang -offset flag -width 123456789012345678901234
-.It Ar PTHREAD_PROCESS_SHARED
-Any thread of any process that has access to the memory where the
-read/write lock resides can manipulate the lock.
-.It Ar PTHREAD_PROCESS_PRIVATE
-Only threads created within the same process as the thread that
-initialized the read/write lock can manipulate the lock. This is
-the default value.
-.El
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_rwlockattr_setpshared
-function will return zero. Otherwise an error number will be returned
-to indicate the error.
-.Sh SEE ALSO
-.Xr pthread_rwlock_init 3 ,
-.Xr pthread_rwlockattr_init 3 ,
-.Xr pthread_rwlockattr_setpshared 3
-.Sh STANDARDS
-The
-.Fn pthread_rwlockattr_setpshared
-function is expected to conform to
-.St -susv2 .
-.Sh ERRORS
-.Fn pthread_rwlockattr_setpshared
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The value specified by
-.Fa attr
-or
-.Fa pshared
-is invalid.
-.El
-.Sh HISTORY
-The
-.Fn pthread_rwlockattr_setpshared
-function first appeared in
-.Fx 3.0 .
-.Sh BUGS
-The PTHREAD_PROCESS_SHARED attribute is not supported.
diff --git a/lib/libpthread/man/pthread_self.3 b/lib/libpthread/man/pthread_self.3
deleted file mode 100644
index be524b9345b9..000000000000
--- a/lib/libpthread/man/pthread_self.3
+++ /dev/null
@@ -1,61 +0,0 @@
-.\" Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>.
-.\" 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 John Birrell.
-.\" 4. Neither the name of the author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd April 4, 1996
-.Dt PTHREAD_SELF 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_self
-.Nd get the calling thread's ID
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft pthread_t
-.Fn pthread_self "void"
-.Sh DESCRIPTION
-The
-.Fn pthread_self
-function returns the thread ID of the calling thread.
-.Sh RETURN VALUES
-The
-.Fn pthread_self
-function returns the thread ID of the calling thread.
-.Sh ERRORS
-None.
-.Pp
-.Sh SEE ALSO
-.Xr pthread_create 3 ,
-.Xr pthread_equal 3
-.Sh STANDARDS
-.Fn pthread_self
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/lib/libpthread/man/pthread_setspecific.3 b/lib/libpthread/man/pthread_setspecific.3
deleted file mode 100644
index ca141deb3c81..000000000000
--- a/lib/libpthread/man/pthread_setspecific.3
+++ /dev/null
@@ -1,95 +0,0 @@
-.\" Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>.
-.\" 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 John Birrell.
-.\" 4. Neither the name of the author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd April 4, 1996
-.Dt PTHREAD_SETSPECIFIC 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_setspecific
-.Nd set a thread-specific data value
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_setspecific "pthread_key_t key" "const void *value"
-.Sh DESCRIPTION
-The
-.Fn pthread_setspecific
-function associates a thread-specific value with a
-.Fa key
-obtained via a previous call to
-.Fn pthread_key_create .
-Different threads man bind different values to the same key.
-These values are
-typically pointers to blocks of dynamically allocated memory that have been
-reserved for use by the calling thread.
-.Pp
-The effect of calling
-.Fn pthread_setspecific
-with a key value not obtained from
-.Fn pthread_key_create
-or after
-.Fa key
-has been deleted with
-.Fn pthread_key_delete
-is undefined.
-.Pp
-.Fn pthread_setspecific
-may be called from a thread-specific data destructor function, however this
-may result in lost storage or infinite loops.
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_setspecific
-function will return zero.
-Otherwise an error number will be returned to
-indicate the error.
-.Sh ERRORS
-.Fn pthread_setspecific
-will fail if:
-.Bl -tag -width Er
-.It Bq Er ENOMEM
-Insufficient memory exists to associate the value with the
-.Fa key .
-.It Bq Er EINVAL
-The
-.Fa key
-value is invalid.
-.El
-.Pp
-.Sh SEE ALSO
-.Xr pthread_getspecific 3 ,
-.Xr pthread_key_create 3 ,
-.Xr pthread_key_delete 3
-.Sh STANDARDS
-.Fn pthread_setspecific
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/lib/libpthread/man/pthread_testcancel.3 b/lib/libpthread/man/pthread_testcancel.3
deleted file mode 100644
index d911d2c647f3..000000000000
--- a/lib/libpthread/man/pthread_testcancel.3
+++ /dev/null
@@ -1,197 +0,0 @@
-.\" $FreeBSD$
-.Dd January 17, 1999
-.Dt PTHREAD_TESTCANCEL 3
-.Os
-.Sh NAME
-.Nm pthread_setcancelstate ,
-.Nm pthread_setcanceltype ,
-.Nm pthread_testcancel
-.Nd set cancelability state
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_setcancelstate "int state" "int *oldstate"
-.Ft int
-.Fn pthread_setcanceltype "int type" "int *oldtype"
-.Ft void
-.Fn pthread_testcancel "void"
-.Sh DESCRIPTION
-The
-.Fn pthread_setcancelstate
-function atomically both sets the calling thread's cancelability state
-to the indicated
-.Fa state
-and returns the previous cancelability state at the location referenced by
-.Fa oldstate .
-Legal values for
-.Fa state
-are
-.Dv PTHREAD_CANCEL_ENABLE
-and
-.Dv PTHREAD_CANCEL_DISABLE .
-.Pp
-The
-.Fn pthread_setcanceltype
-function atomically both sets the calling thread's cancelability type
-to the indicated
-.Fa type
-and returns the previous cancelability type at the location referenced by
-.Fa oldtype .
-Legal values for
-.Fa type
-are
-.Dv PTHREAD_CANCEL_DEFERRED
-and
-.Dv PTHREAD_CANCEL_ASYNCHRONOUS .
-.Pp
-The cancelability state and type of any newly created threads, including the
-thread in which
-.Fn main
-was first invoked, are
-.Dv PTHREAD_CANCEL_ENABLE
-and
-.Dv PTHREAD_CANCEL_DEFERRED
-respectively.
-.Pp
-The
-.Fn pthread_testcancel
-function creates a cancellation point in the calling thread.
-The
-.Fn pthread_testcancel
-function has no effect if cancelability is disabled.
-.Pp
-.Ss Cancelability States
-The cancelability state of a thread determines the action taken upon
-receipt of a cancellation request.
-The thread may control cancellation in
-a number of ways.
-.Pp
-Each thread maintains its own
-.Dq cancelability state
-which may be encoded in two bits:
-.Bl -hang
-.It Em Cancelability Enable
-When cancelability is
-.Dv PTHREAD_CANCEL_DISABLE ,
-cancellation requests against the target thread are held pending.
-.It Em Cancelability Type
-When cancelability is enabled and the cancelability type is
-.Dv PTHREAD_CANCEL_ASYNCHRONOUS ,
-new or pending cancellation requests may be acted upon at any time.
-When cancelability is enabled and the cancelability type is
-.Dv PTHREAD_CANCEL_DEFERRED ,
-cancellation requests are held pending until a cancellation point (see
-below) is reached.
-If cancelability is disabled, the setting of the
-cancelability type has no immediate effect as all cancellation requests
-are held pending; however, once cancelability is enabled again the new
-type will be in effect.
-.El
-.Ss Cancellation Points
-Cancellation points will occur when a thread is executing the following
-functions:
-.Fn close ,
-.Fn creat ,
-.Fn fcntl ,
-.Fn fsync ,
-.Fn msync ,
-.Fn nanosleep ,
-.Fn open ,
-.Fn pause ,
-.Fn pthread_cond_timedwait ,
-.Fn pthread_cond_wait ,
-.Fn pthread_join ,
-.Fn pthread_testcancel ,
-.Fn read ,
-.Fn sigwaitinfo ,
-.Fn sigsuspend ,
-.Fn sigwait ,
-.Fn sleep ,
-.Fn system ,
-.Fn tcdrain ,
-.Fn wait ,
-.Fn waitpid ,
-.Fn write .
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_setcancelstate
-and
-.Fn pthread_setcanceltype
-functions will return zero.
-Otherwise, an error number shall be returned to
-indicate the error.
-.Pp
-The
-.Fn pthread_setcancelstate
-and
-.Fn pthread_setcanceltype
-functions are used to control the points at which a thread may be
-asynchronously canceled.
-For cancellation control to be usable in modular
-fashion, some rules must be followed.
-.Pp
-For purposes of this discussion, consider an object to be a generalization
-of a procedure.
-It is a set of procedures and global variables written as
-a unit and called by clients not known by the object.
-Objects may depend
-on other objects.
-.Pp
-First, cancelability should only be disabled on entry to an object, never
-explicitly enabled.
-On exit from an object, the cancelability state should
-always be restored to its value on entry to the object.
-.Pp
-This follows from a modularity argument: if the client of an object (or the
-client of an object that uses that object) has disabled cancelability, it is
-because the client doesn't want to have to worry about how to clean up if the
-thread is canceled while executing some sequence of actions.
-If an object
-is called in such a state and it enables cancelability and a cancellation
-request is pending for that thread, then the thread will be canceled,
-contrary to the wish of the client that disabled.
-.Pp
-Second, the cancelability type may be explicitly set to either
-.Em deferred
-or
-.Em asynchronous
-upon entry to an object.
-But as with the cancelability state, on exit from
-an object that cancelability type should always be restored to its value on
-entry to the object.
-.Pp
-Finally, only functions that are cancel-safe may be called from a thread that
-is asynchronously cancelable.
-.Sh ERRORS
-The function
-.Fn pthread_setcancelstate
-may fail with:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The specified state is not
-.Dv PTHREAD_CANCEL_ENABLE
-or
-.Dv PTHREAD_CANCEL_DISABLE .
-.El
-.Pp
-The function
-.Fn pthread_setcanceltype
-may fail with:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The specified state is not
-.Dv PTHREAD_CANCEL_DEFERRED
-or
-.Dv PTHREAD_CANCEL_ASYNCHRONOUS .
-.El
-.Sh SEE ALSO
-.Xr pthread_cancel 3
-.Sh STANDARDS
-.Fn pthread_testcancel
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
-.Sh AUTHORS
-This man page was written by
-.An David Leonard <d@openbsd.org>
-for the OpenBSD implementation of pthread_cancel.
diff --git a/lib/libpthread/man/sem_destroy.3 b/lib/libpthread/man/sem_destroy.3
deleted file mode 100644
index 770349dee281..000000000000
--- a/lib/libpthread/man/sem_destroy.3
+++ /dev/null
@@ -1,83 +0,0 @@
-.\" Copyright (C) 2000 Jason Evans <jasone@canonware.com>.
-.\" 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(s), this list of conditions and the following disclaimer as
-.\" the first lines of this file unmodified other than the possible
-.\" addition of one or more copyright notices.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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.
-.\"
-.\" $FreeBSD$
-.Dd February 15, 2000
-.Dt SEM_DESTROY 3
-.Os
-.Sh NAME
-.Nm sem_destroy
-.Nd destroy an unnamed semaphore
-.Sh SYNOPSIS
-.Fd #include <semaphore.h>
-.Ft int
-.Fn sem_destroy "sem_t *sem"
-.Sh DESCRIPTION
-The
-.Fn sem_destroy
-function destroys the unnamed semaphore pointed to by
-.Fa sem .
-After a successful call to
-.Fn sem_destroy ,
-.Fa sem
-is unuseable until re-initialized by another call to
-.Fn sem_init .
-.Sh RETURN VALUES
-If successful,
-.Fn sem_destroy
-returns 0. Otherwise, -1 is returned and
-.Va errno
-is set to indicate the type of
-error.
-.Sh ERRORS
-.Fn sem_destroy
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-.Fa sem
-points to an invalid semaphore.
-.It Bq Er EBUSY
-There are currently threads blocked on the semaphore that
-.Fa sem
-points to.
-.El
-.Sh SEE ALSO
-.Xr sem_init 3
-.Sh STANDARDS
-.Fn sem_destroy
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 1996 Edition.
-.Pp
-POSIX does not define the behavior of
-.Fn sem_destroy
-if called while there are threads blocked on
-.Fa sem ,
-but this implementation is guaranteed to return -1 and set
-.Va errno
-to EBUSY if there are threads blocked on
-.Fa sem .
diff --git a/lib/libpthread/man/sem_getvalue.3 b/lib/libpthread/man/sem_getvalue.3
deleted file mode 100644
index be0cbae8ca7b..000000000000
--- a/lib/libpthread/man/sem_getvalue.3
+++ /dev/null
@@ -1,77 +0,0 @@
-.\" Copyright (C) 2000 Jason Evans <jasone@canonware.com>.
-.\" 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(s), this list of conditions and the following disclaimer as
-.\" the first lines of this file unmodified other than the possible
-.\" addition of one or more copyright notices.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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.
-.\"
-.\" $FreeBSD$
-.Dd February 15, 2000
-.Dt SEM_GETVALUE 3
-.Os
-.Sh NAME
-.Nm sem_getvalue
-.Nd get the value of a semaphore
-.Sh SYNOPSIS
-.Fd #include <semaphore.h>
-.Ft int
-.Fn sem_getvalue "sem_t *sem" "int *sval"
-.Sh DESCRIPTION
-The
-.Fn sem_getvalue
-function sets the variable pointed to by
-.Fa sval
-to the current value of the semaphore pointed to by
-.Fa sem ,
-as of the time that the call to
-.Fn sem_getvalue
-is actually run.
-.Sh RETURN VALUES
-If successful,
-.Fn sem_getvalue
-returns 0. Otherwise, -1 is returned and
-.Va errno
-is set to indicate the type of
-error.
-.Sh ERRORS
-.Fn sem_getvalue
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-.Fa sem
-points to an invalid semaphore.
-.El
-.Sh SEE ALSO
-.Xr sem_post 3 ,
-.Xr sem_wait 3 ,
-.Xr sem_trywait 3
-.Sh STANDARDS
-.Fn sem_getvalue
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 1996 Edition.
-.Pp
-The value of the semaphore is never negative, even if there are threads blocked
-on the semaphore. POSIX is somewhat ambiguous in its wording with regard to
-what the value of the semaphore should be if there are blocked waiting threads,
-but this behavior is conformant, given the wording of the specification.
diff --git a/lib/libpthread/man/sem_init.3 b/lib/libpthread/man/sem_init.3
deleted file mode 100644
index 059a9c6aeba5..000000000000
--- a/lib/libpthread/man/sem_init.3
+++ /dev/null
@@ -1,100 +0,0 @@
-.\" Copyright (C) 2000 Jason Evans <jasone@canonware.com>.
-.\" 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(s), this list of conditions and the following disclaimer as
-.\" the first lines of this file unmodified other than the possible
-.\" addition of one or more copyright notices.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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.
-.\"
-.\" $FreeBSD$
-.Dd February 15, 2000
-.Dt SEM_INIT 3
-.Os
-.Sh NAME
-.Nm sem_init
-.Nd initialize an unnamed semaphore
-.Sh SYNOPSIS
-.Fd #include <semaphore.h>
-.Ft int
-.Fn sem_init "sem_t *sem" "int pshared" "unsigned int value"
-.Sh DESCRIPTION
-The
-.Fn sem_init
-function initializes the unnamed semaphore pointed to by
-.Fa sem
-to have the value
-.Fa value .
-A non-zero value for
-.Fa pshared
-specifies a shared semaphore that can be used by multiple processes, which this
-implementation is not capable of.
-.Pp
-Following a successful call to
-.Fn sem_init ,
-.Fa sem
-can be used as an argument in subsequent calls to
-.Fa sem_wait ,
-.Fa sem_trywait ,
-.Fa sem_post ,
-and
-.Fa sem_destroy .
-.Fa sem
-is no longer valid after a successful call to
-.Fa sem_destroy .
-.Sh RETURN VALUES
-If successful,
-.Fn sem_init
-returns 0. Otherwise, -1 is returned and
-.Va errno
-is set to indicate the type of
-error.
-.Sh ERRORS
-.Fn sem_init
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-.Fa value
-exceeds SEM_VALUE_MAX.
-.It Bq Er ENOSPC
-Memory allocation error.
-.It Bq Er EPERM
-Unable to initialize a shared semaphore.
-.El
-.Sh SEE ALSO
-.Xr sem_wait 3 ,
-.Xr sem_trywait 3 ,
-.Xr sem_post 3 ,
-.Xr sem_destroy
-.Sh STANDARDS
-.Fn sem_init
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 1996 Edition.
-.Pp
-This implementation does not support shared semaphores, and reports this fact
-by setting
-.Va errno
-to EPERM. This is perhaps a stretch of the intention of POSIX, but is
-compliant, with the caveat that
-.Fn sem_init
-always reports a permissions error when an attempt to create a shared semaphore
-is made.
diff --git a/lib/libpthread/man/sem_open.3 b/lib/libpthread/man/sem_open.3
deleted file mode 100644
index a4729f97961b..000000000000
--- a/lib/libpthread/man/sem_open.3
+++ /dev/null
@@ -1,80 +0,0 @@
-.\" Copyright (C) 2000 Jason Evans <jasone@canonware.com>.
-.\" 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(s), this list of conditions and the following disclaimer as
-.\" the first lines of this file unmodified other than the possible
-.\" addition of one or more copyright notices.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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.
-.\"
-.\" $FreeBSD$
-.Dd February 15, 2000
-.Dt SEM_OPEN 3
-.Os
-.Sh NAME
-.Nm sem_open ,
-.Nm sem_close ,
-.Nm sem_unlink
-.Nd named semaphore operations
-.Sh SYNOPSIS
-.Fd #include <semaphore.h>
-.Ft sem_t *
-.Fn sem_open "const char *name" "int oflag" "..."
-.Ft int
-.Fn sem_close "sem_t *sem"
-.Ft int
-.Fn sem_unlink "const char *name"
-.Sh DESCRIPTION
-The
-.Fn sem_open ,
-.Fn sem_close ,
-and
-.Fn sem_unlink
-functions are not supported by this implementation.
-.Sh RETURN VALUES
-.Fn sem_open
-returns SEM_FAILED and sets
-.Va errno
-to indicate an error.
-.Fn sem_close
-and
-.Fn sem_unlink
-return -1 and set
-.Va errno
-to indicate an error.
-.Sh ERRORS
-.Fn sem_open ,
-.Fn sem_close ,
-and
-.Fn sem_unlink
-will fail:
-.Bl -tag -width Er
-.It Bq Er ENOSYS
-Function not supported by this implementation.
-.El
-.Sh STANDARDS
-.Fn sem_open ,
-.Fn sem_close ,
-and
-.Fn sem_unlink
-conform to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 1996 Edition.
diff --git a/lib/libpthread/man/sem_post.3 b/lib/libpthread/man/sem_post.3
deleted file mode 100644
index c578e6d04e84..000000000000
--- a/lib/libpthread/man/sem_post.3
+++ /dev/null
@@ -1,71 +0,0 @@
-.\" Copyright (C) 2000 Jason Evans <jasone@canonware.com>.
-.\" 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(s), this list of conditions and the following disclaimer as
-.\" the first lines of this file unmodified other than the possible
-.\" addition of one or more copyright notices.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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.
-.\"
-.\" $FreeBSD$
-.Dd February 15, 2000
-.Dt SEM_POST 3
-.Os
-.Sh NAME
-.Nm sem_post
-.Nd increment (unlock) a semaphore
-.Sh SYNOPSIS
-.Fd #include <semaphore.h>
-.Ft int
-.Fn sem_post "sem_t *sem"
-.Sh DESCRIPTION
-The
-.Fn sem_post
-function increments (unlocks) the semaphore pointed to by
-.Fa sem .
-If there are threads blocked on the semaphore when
-.Fn sem_post
-is called, then the highest priority thread that has been blocked the longest on
-the semaphore will be allowed to return from
-.Fn sem_wait .
-.Sh RETURN VALUES
-If successful,
-.Fn sem_post
-returns 0. Otherwise, -1 is returned and
-.Va errno
-is set to indicate the type of
-error.
-.Sh ERRORS
-.Fn sem_post
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-.Fa sem
-points to an invalid semaphore.
-.El
-.Sh SEE ALSO
-.Xr sem_wait 3 ,
-.Xr sem_trywait 3
-.Sh STANDARDS
-.Fn sem_post
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 1996 Edition.
diff --git a/lib/libpthread/man/sem_wait.3 b/lib/libpthread/man/sem_wait.3
deleted file mode 100644
index c60c8ee6cc67..000000000000
--- a/lib/libpthread/man/sem_wait.3
+++ /dev/null
@@ -1,92 +0,0 @@
-.\" Copyright (C) 2000 Jason Evans <jasone@canonware.com>.
-.\" 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(s), this list of conditions and the following disclaimer as
-.\" the first lines of this file unmodified other than the possible
-.\" addition of one or more copyright notices.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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.
-.\"
-.\" $FreeBSD$
-.Dd February 15, 2000
-.Dt SEM_WAIT 3
-.Os
-.Sh NAME
-.Nm sem_wait ,
-.Nm sem_trywait
-.Nd decrement (lock) a semaphore
-.Sh SYNOPSIS
-.Fd #include <semaphore.h>
-.Ft int
-.Fn sem_wait "sem_t *sem"
-.Ft int
-.Fn sem_trywait "sem_t *sem"
-.Sh DESCRIPTION
-The
-.Fn sem_wait
-function decrements (locks) the semaphore pointed to by
-.Fa sem ,
-but blocks if the value of
-.Fa sem
-is zero, until the value is non-zero and the value can be decremented.
-.Pp
-The
-.Fn sem_trywait
-function decrements (locks) the semaphore pointed to by
-.Fa sem
-only if the value is non-zero. Otherwise, the semaphore is not decremented and
-an error is returned.
-.Sh RETURN VALUES
-If successful,
-.Fn sem_wait
-and
-.Fn sem_trywait
-return 0. Otherwise, -1 is returned and
-.Va errno
-is set to indicate the type of
-error.
-.Sh ERRORS
-.Fn sem_wait
-and
-.Fn sem_trywait
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-.Fa sem
-points to an invalid semaphore.
-.El
-.Pp
-Additionally,
-.Fn sem_trywait
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EAGAIN
-The semaphore value was zero, and thus could not be decremented.
-.El
-.Sh SEE ALSO
-.Xr sem_post 3
-.Sh STANDARDS
-.Fn sem_wait
-and
-.Fn sem_trywait
-conform to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 1996 Edition.
diff --git a/lib/libpthread/sys/Makefile.inc b/lib/libpthread/sys/Makefile.inc
deleted file mode 100644
index e608afa69909..000000000000
--- a/lib/libpthread/sys/Makefile.inc
+++ /dev/null
@@ -1,6 +0,0 @@
-# $FreeBSD$
-
-.PATH: ${.CURDIR}/sys ${.CURDIR}/arch/${MACHINE_ARCH}
-
-SRCS+= uthread_error.c _atomic_lock.S
-
diff --git a/lib/libpthread/sys/thr_error.c b/lib/libpthread/sys/thr_error.c
deleted file mode 100644
index 0d08ae83729a..000000000000
--- a/lib/libpthread/sys/thr_error.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
- * Copyright (c) 1994 by Chris Provenzano, proven@mit.edu
- * 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 John Birrell
- * and Chris Provenzano.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
- *
- * $FreeBSD$
- */
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-extern int errno;
-
-int * __error()
-{
- int *p_errno;
- if (_thread_run == _thread_initial) {
- p_errno = &errno;
- } else {
- p_errno = &_thread_run->error;
- }
- return(p_errno);
-}
-#endif
diff --git a/lib/libpthread/test/Makefile b/lib/libpthread/test/Makefile
deleted file mode 100644
index 90ee5ad59ea4..000000000000
--- a/lib/libpthread/test/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-# $FreeBSD$
-#
-# Tests for libc_r functionality.
-#
-
-SUBDIR= mutex sigsuspend sigwait
-
-.include <bsd.subdir.mk>
diff --git a/lib/libpthread/thread/Makefile.inc b/lib/libpthread/thread/Makefile.inc
deleted file mode 100644
index a88f9552b99b..000000000000
--- a/lib/libpthread/thread/Makefile.inc
+++ /dev/null
@@ -1,127 +0,0 @@
-# $FreeBSD$
-
-# uthread sources
-.PATH: ${.CURDIR}/uthread
-
-SRCS+= \
- uthread_accept.c \
- uthread_aio_suspend.c \
- uthread_attr_destroy.c \
- uthread_attr_init.c \
- uthread_attr_getdetachstate.c \
- uthread_attr_getinheritsched.c \
- uthread_attr_getschedparam.c \
- uthread_attr_getschedpolicy.c \
- uthread_attr_getscope.c \
- uthread_attr_getstackaddr.c \
- uthread_attr_getstacksize.c \
- uthread_attr_setcreatesuspend_np.c \
- uthread_attr_setdetachstate.c \
- uthread_attr_setinheritsched.c \
- uthread_attr_setschedparam.c \
- uthread_attr_setschedpolicy.c \
- uthread_attr_setscope.c \
- uthread_attr_setstackaddr.c \
- uthread_attr_setstacksize.c \
- uthread_autoinit.cc \
- uthread_bind.c \
- uthread_cancel.c \
- uthread_clean.c \
- uthread_close.c \
- uthread_cond.c \
- uthread_condattr_destroy.c \
- uthread_condattr_init.c \
- uthread_connect.c \
- uthread_creat.c \
- uthread_create.c \
- uthread_detach.c \
- uthread_dup.c \
- uthread_dup2.c \
- uthread_equal.c \
- uthread_execve.c \
- uthread_exit.c \
- uthread_fchflags.c \
- uthread_fchmod.c \
- uthread_fchown.c \
- uthread_fcntl.c \
- uthread_fd.c \
- uthread_file.c \
- uthread_find_thread.c \
- uthread_flock.c \
- uthread_fork.c \
- uthread_fstat.c \
- uthread_fstatfs.c \
- uthread_fsync.c \
- uthread_gc.c \
- uthread_getdirentries.c \
- uthread_getpeername.c \
- uthread_getprio.c \
- uthread_getschedparam.c \
- uthread_getsockname.c \
- uthread_getsockopt.c \
- uthread_info.c \
- uthread_init.c \
- uthread_ioctl.c \
- uthread_jmp.c \
- uthread_join.c \
- uthread_kern.c \
- uthread_kill.c \
- uthread_listen.c \
- uthread_mattr_init.c \
- uthread_mattr_kind_np.c \
- uthread_msync.c \
- uthread_multi_np.c \
- uthread_mutex.c \
- uthread_mutex_prioceiling.c \
- uthread_mutex_protocol.c \
- uthread_mutexattr_destroy.c \
- uthread_nanosleep.c \
- uthread_once.c \
- uthread_open.c \
- uthread_pause.c \
- uthread_pipe.c \
- uthread_poll.c \
- uthread_priority_queue.c \
- uthread_read.c \
- uthread_readv.c \
- uthread_recvfrom.c \
- uthread_recvmsg.c \
- uthread_resume_np.c \
- uthread_rwlock.c \
- uthread_rwlockattr.c \
- uthread_select.c \
- uthread_self.c \
- uthread_sem.c \
- uthread_sendmsg.c \
- uthread_sendto.c \
- uthread_seterrno.c \
- uthread_setprio.c \
- uthread_setschedparam.c \
- uthread_setsockopt.c \
- uthread_shutdown.c \
- uthread_sig.c \
- uthread_sigaction.c \
- uthread_sigblock.c \
- uthread_sigmask.c \
- uthread_sigpending.c \
- uthread_sigprocmask.c \
- uthread_sigsetmask.c \
- uthread_sigsuspend.c \
- uthread_sigwait.c \
- uthread_single_np.c \
- uthread_sleep.c \
- uthread_socket.c \
- uthread_socketpair.c \
- uthread_spec.c \
- uthread_spinlock.c \
- uthread_suspend_np.c \
- uthread_switch_np.c \
- uthread_system.c \
- uthread_tcdrain.c \
- uthread_vfork.c \
- uthread_wait.c \
- uthread_wait4.c \
- uthread_waitpid.c \
- uthread_write.c \
- uthread_writev.c \
- uthread_yield.c
diff --git a/lib/libpthread/thread/thr_aio_suspend.c b/lib/libpthread/thread/thr_aio_suspend.c
deleted file mode 100644
index 5940282fe0a3..000000000000
--- a/lib/libpthread/thread/thr_aio_suspend.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2000 Jason Evans <jasone@canonware.com>.
- * 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(s), this list of conditions and the following disclaimer as
- * the first lines of this file unmodified other than the possible
- * addition of one or more copyright notices.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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.
- *
- * $FreeBSD$
- */
-
-#include <aio.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-_aio_suspend(const struct aiocb * const iocbs[], int niocb, const struct
- timespec *timeout)
-{
- int ret;
-
- _thread_enter_cancellation_point();
- ret = _aio_suspend(iocbs, niocb, timeout);
- _thread_leave_cancellation_point();
-
- return ret;
-}
-
-__strong_reference(_aio_suspend, aio_suspend);
-#endif
diff --git a/lib/libpthread/thread/thr_attr_destroy.c b/lib/libpthread/thread/thr_attr_destroy.c
deleted file mode 100644
index dfe668ea2181..000000000000
--- a/lib/libpthread/thread/thr_attr_destroy.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <stdlib.h>
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int pthread_attr_destroy(pthread_attr_t *attr)
-{
- int ret;
-
- /* Check for invalid arguments: */
- if (attr == NULL || *attr == NULL)
- /* Invalid argument: */
- ret = EINVAL;
- else {
- /* Free the memory allocated to the attribute object: */
- free(*attr);
-
- /*
- * Leave the attribute pointer NULL now that the memory
- * has been freed:
- */
- *attr = NULL;
- ret = 0;
- }
- return(ret);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_attr_getdetachstate.c b/lib/libpthread/thread/thr_attr_getdetachstate.c
deleted file mode 100644
index fee1e8b11a2a..000000000000
--- a/lib/libpthread/thread/thr_attr_getdetachstate.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int pthread_attr_getdetachstate(pthread_attr_t *attr, int *detachstate)
-{
- int ret;
-
- /* Check for invalid arguments: */
- if (attr == NULL || *attr == NULL || detachstate == NULL)
- ret = EINVAL;
- else {
- /* Check if the detached flag is set: */
- if ((*attr)->flags & PTHREAD_DETACHED)
- /* Return detached: */
- *detachstate = PTHREAD_CREATE_DETACHED;
- else
- /* Return joinable: */
- *detachstate = PTHREAD_CREATE_JOINABLE;
- ret = 0;
- }
- return(ret);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_attr_getinheritsched.c b/lib/libpthread/thread/thr_attr_getinheritsched.c
deleted file mode 100644
index 7e243ed5b946..000000000000
--- a/lib/libpthread/thread/thr_attr_getinheritsched.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>.
- * 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 Daniel Eischen.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_attr_getinheritsched(const pthread_attr_t *attr, int *sched_inherit)
-{
- int ret = 0;
-
- if ((attr == NULL) || (*attr == NULL))
- ret = EINVAL;
- else
- *sched_inherit = (*attr)->sched_inherit;
-
- return(ret);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_attr_getschedparam.c b/lib/libpthread/thread/thr_attr_getschedparam.c
deleted file mode 100644
index 46586ffdd30d..000000000000
--- a/lib/libpthread/thread/thr_attr_getschedparam.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>.
- * 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 Daniel Eischen.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_attr_getschedparam(const pthread_attr_t *attr, struct sched_param *param)
-{
- int ret = 0;
-
- if ((attr == NULL) || (*attr == NULL) || (param == NULL))
- ret = EINVAL;
- else
- param->sched_priority = (*attr)->prio;
-
- return(ret);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_attr_getschedpolicy.c b/lib/libpthread/thread/thr_attr_getschedpolicy.c
deleted file mode 100644
index 19f835c46b93..000000000000
--- a/lib/libpthread/thread/thr_attr_getschedpolicy.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>.
- * 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 Daniel Eischen.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_attr_getschedpolicy(const pthread_attr_t *attr, int *policy)
-{
- int ret = 0;
-
- if ((attr == NULL) || (*attr == NULL) || (policy == NULL))
- ret = EINVAL;
- else
- *policy = (*attr)->sched_policy;
-
- return(ret);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_attr_getscope.c b/lib/libpthread/thread/thr_attr_getscope.c
deleted file mode 100644
index 176f01bfe47c..000000000000
--- a/lib/libpthread/thread/thr_attr_getscope.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>.
- * 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 Daniel Eischen.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_attr_getscope(const pthread_attr_t *attr, int *contentionscope)
-{
- int ret = 0;
-
- if ((attr == NULL) || (*attr == NULL) || (contentionscope == NULL))
- /* Return an invalid argument: */
- ret = EINVAL;
-
- else
- *contentionscope = (*attr)->flags & PTHREAD_SCOPE_SYSTEM ?
- PTHREAD_SCOPE_SYSTEM : PTHREAD_SCOPE_PROCESS;
-
- return(ret);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_attr_getstackaddr.c b/lib/libpthread/thread/thr_attr_getstackaddr.c
deleted file mode 100644
index 1fee4a5f8717..000000000000
--- a/lib/libpthread/thread/thr_attr_getstackaddr.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int pthread_attr_getstackaddr(pthread_attr_t *attr, void **stackaddr)
-{
- int ret;
-
- /* Check for invalid arguments: */
- if (attr == NULL || *attr == NULL || stackaddr == NULL)
- ret = EINVAL;
- else {
- /* Return the stack address: */
- *stackaddr = (*attr)->stackaddr_attr;
- ret = 0;
- }
- return(ret);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_attr_getstacksize.c b/lib/libpthread/thread/thr_attr_getstacksize.c
deleted file mode 100644
index 5c7a9e071359..000000000000
--- a/lib/libpthread/thread/thr_attr_getstacksize.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int pthread_attr_getstacksize(pthread_attr_t *attr, size_t *stacksize)
-{
- int ret;
-
- /* Check for invalid arguments: */
- if (attr == NULL || *attr == NULL || stacksize == NULL)
- ret = EINVAL;
- else {
- /* Return the stack size: */
- *stacksize = (*attr)->stacksize_attr;
- ret = 0;
- }
- return(ret);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_attr_init.c b/lib/libpthread/thread/thr_attr_init.c
deleted file mode 100644
index dbe3091b0ab2..000000000000
--- a/lib/libpthread/thread/thr_attr_init.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int pthread_attr_init(pthread_attr_t *attr)
-{
- int ret;
- pthread_attr_t pattr;
-
- /* Allocate memory for the attribute object: */
- if ((pattr = (pthread_attr_t) malloc(sizeof(struct pthread_attr))) == NULL)
- /* Insufficient memory: */
- ret = ENOMEM;
- else {
- /* Initialise the attribute object with the defaults: */
- memcpy(pattr, &pthread_attr_default, sizeof(struct pthread_attr));
-
- /* Return a pointer to the attribute object: */
- *attr = pattr;
- ret = 0;
- }
- return(ret);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_attr_setcreatesuspend_np.c b/lib/libpthread/thread/thr_attr_setcreatesuspend_np.c
deleted file mode 100644
index d230397f743f..000000000000
--- a/lib/libpthread/thread/thr_attr_setcreatesuspend_np.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_attr_setcreatesuspend_np(pthread_attr_t *attr)
-{
- int ret;
- if (attr == NULL || *attr == NULL) {
- errno = EINVAL;
- ret = -1;
- } else {
- (*attr)->suspend = PTHREAD_CREATE_SUSPENDED;
- ret = 0;
- }
- return(ret);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_attr_setdetachstate.c b/lib/libpthread/thread/thr_attr_setdetachstate.c
deleted file mode 100644
index 6be3e4ee73b3..000000000000
--- a/lib/libpthread/thread/thr_attr_setdetachstate.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate)
-{
- int ret;
-
- /* Check for invalid arguments: */
- if (attr == NULL || *attr == NULL ||
- (detachstate != PTHREAD_CREATE_DETACHED &&
- detachstate != PTHREAD_CREATE_JOINABLE))
- ret = EINVAL;
- else {
- /* Check if detached state: */
- if (detachstate == PTHREAD_CREATE_DETACHED)
- /* Set the detached flag: */
- (*attr)->flags |= PTHREAD_DETACHED;
- else
- /* Reset the detached flag: */
- (*attr)->flags &= ~PTHREAD_DETACHED;
- ret = 0;
- }
- return(ret);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_attr_setinheritsched.c b/lib/libpthread/thread/thr_attr_setinheritsched.c
deleted file mode 100644
index eb2384b8fc2b..000000000000
--- a/lib/libpthread/thread/thr_attr_setinheritsched.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>.
- * 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 Daniel Eischen.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_attr_setinheritsched(pthread_attr_t *attr, int sched_inherit)
-{
- int ret = 0;
-
- if ((attr == NULL) || (*attr == NULL))
- ret = EINVAL;
- else
- (*attr)->sched_inherit = sched_inherit;
-
- return(ret);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_attr_setschedparam.c b/lib/libpthread/thread/thr_attr_setschedparam.c
deleted file mode 100644
index 5746fe2fffb1..000000000000
--- a/lib/libpthread/thread/thr_attr_setschedparam.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>.
- * 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 Daniel Eischen.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_attr_setschedparam(pthread_attr_t *attr, const struct sched_param *param)
-{
- int ret = 0;
-
- if ((attr == NULL) || (*attr == NULL) || (param == NULL))
- ret = EINVAL;
- else
- (*attr)->prio = param->sched_priority;
-
- return(ret);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_attr_setschedpolicy.c b/lib/libpthread/thread/thr_attr_setschedpolicy.c
deleted file mode 100644
index 640cb38f0b06..000000000000
--- a/lib/libpthread/thread/thr_attr_setschedpolicy.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>.
- * 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 Daniel Eischen.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy)
-{
- int ret = 0;
-
- if ((attr == NULL) || (*attr == NULL) || (policy < SCHED_FIFO) ||
- (policy > SCHED_RR))
- ret = EINVAL;
- else
- (*attr)->sched_policy = policy;
-
- return(ret);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_attr_setscope.c b/lib/libpthread/thread/thr_attr_setscope.c
deleted file mode 100644
index 84239d7f6613..000000000000
--- a/lib/libpthread/thread/thr_attr_setscope.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>.
- * 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 Daniel Eischen.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_attr_setscope(pthread_attr_t *attr, int contentionscope)
-{
- int ret = 0;
-
- if ((attr == NULL) || (*attr == NULL) ||
- (contentionscope != PTHREAD_SCOPE_PROCESS) ||
- (contentionscope != PTHREAD_SCOPE_SYSTEM))
- /* Return an invalid argument: */
- ret = EINVAL;
-
- else if (contentionscope == PTHREAD_SCOPE_SYSTEM)
- /* We don't support system wide contention: */
-#ifdef NOT_YET
- ret = ENOTSUP;
-#else
- ret = EOPNOTSUPP;
-#endif
-
- else
- (*attr)->flags |= contentionscope;
-
- return(ret);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_attr_setstackaddr.c b/lib/libpthread/thread/thr_attr_setstackaddr.c
deleted file mode 100644
index 46469e4faf87..000000000000
--- a/lib/libpthread/thread/thr_attr_setstackaddr.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_attr_setstackaddr(pthread_attr_t *attr, void *stackaddr)
-{
- int ret;
-
- /* Check for invalid arguments: */
- if (attr == NULL || *attr == NULL || stackaddr == NULL)
- ret = EINVAL;
- else {
- /* Save the stack address: */
- (*attr)->stackaddr_attr = stackaddr;
- ret = 0;
- }
- return(ret);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_attr_setstacksize.c b/lib/libpthread/thread/thr_attr_setstacksize.c
deleted file mode 100644
index 3897811bb436..000000000000
--- a/lib/libpthread/thread/thr_attr_setstacksize.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize)
-{
- int ret;
-
- /* Check for invalid arguments: */
- if (attr == NULL || *attr == NULL || stacksize < PTHREAD_STACK_MIN)
- ret = EINVAL;
- else {
- /* Save the stack size: */
- (*attr)->stacksize_attr = stacksize;
- ret = 0;
- }
- return(ret);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_cancel.c b/lib/libpthread/thread/thr_cancel.c
deleted file mode 100644
index f22bfb55972d..000000000000
--- a/lib/libpthread/thread/thr_cancel.c
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * David Leonard <d@openbsd.org>, 1999. Public domain.
- * $FreeBSD$
- */
-#include <sys/errno.h>
-#include <pthread.h>
-#include "pthread_private.h"
-
-static void finish_cancellation(void *arg);
-
-int
-pthread_cancel(pthread_t pthread)
-{
- int ret;
-
- if ((ret = _find_thread(pthread)) != 0) {
- /* NOTHING */
- } else if (pthread->state == PS_DEAD || pthread->state == PS_DEADLOCK) {
- ret = 0;
- } else {
- /* Protect the scheduling queues: */
- _thread_kern_sig_defer();
-
- if (((pthread->cancelflags & PTHREAD_CANCEL_DISABLE) != 0) ||
- (((pthread->cancelflags & PTHREAD_CANCEL_ASYNCHRONOUS) == 0) &&
- ((pthread->cancelflags & PTHREAD_AT_CANCEL_POINT) == 0)))
- /* Just mark it for cancellation: */
- pthread->cancelflags |= PTHREAD_CANCELLING;
- else {
- /*
- * Check if we need to kick it back into the
- * run queue:
- */
- switch (pthread->state) {
- case PS_RUNNING:
- /* No need to resume: */
- pthread->cancelflags |= PTHREAD_CANCELLING;
- break;
-
- case PS_SPINBLOCK:
- case PS_FDR_WAIT:
- case PS_FDW_WAIT:
- case PS_POLL_WAIT:
- case PS_SELECT_WAIT:
- /* Remove these threads from the work queue: */
- if ((pthread->flags & PTHREAD_FLAGS_IN_WORKQ)
- != 0)
- PTHREAD_WORKQ_REMOVE(pthread);
- /* Fall through: */
- case PS_SIGTHREAD:
- case PS_SLEEP_WAIT:
- case PS_WAIT_WAIT:
- case PS_SIGSUSPEND:
- case PS_SIGWAIT:
- case PS_SUSPENDED:
- /* Interrupt and resume: */
- pthread->interrupted = 1;
- pthread->cancelflags |= PTHREAD_CANCELLING;
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
- break;
-
- case PS_MUTEX_WAIT:
- case PS_COND_WAIT:
- case PS_FDLR_WAIT:
- case PS_FDLW_WAIT:
- case PS_FILE_WAIT:
- case PS_JOIN:
- /*
- * Threads in these states may be in queues.
- * In order to preserve queue integrity, the
- * cancelled thread must remove itself from the
- * queue. Mark the thread as interrupted and
- * needing cancellation, and set the state to
- * running. When the thread resumes, it will
- * remove itself from the queue and call the
- * cancellation completion routine.
- */
- pthread->interrupted = 1;
- pthread->cancelflags |= PTHREAD_CANCEL_NEEDED;
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
- pthread->continuation = finish_cancellation;
- break;
-
- case PS_DEAD:
- case PS_DEADLOCK:
- case PS_STATE_MAX:
- /* Ignore - only here to silence -Wall: */
- break;
- }
- }
-
- /* Unprotect the scheduling queues: */
- _thread_kern_sig_undefer();
-
- ret = 0;
- }
- return (ret);
-}
-
-int
-pthread_setcancelstate(int state, int *oldstate)
-{
- int ostate;
- int ret;
-
- ostate = _thread_run->cancelflags & PTHREAD_CANCEL_DISABLE;
-
- switch (state) {
- case PTHREAD_CANCEL_ENABLE:
- if (oldstate != NULL)
- *oldstate = ostate;
- _thread_run->cancelflags &= ~PTHREAD_CANCEL_DISABLE;
- if ((_thread_run->cancelflags & PTHREAD_CANCEL_ASYNCHRONOUS) != 0)
- pthread_testcancel();
- ret = 0;
- break;
- case PTHREAD_CANCEL_DISABLE:
- if (oldstate != NULL)
- *oldstate = ostate;
- _thread_run->cancelflags |= PTHREAD_CANCEL_DISABLE;
- ret = 0;
- break;
- default:
- ret = EINVAL;
- }
-
- return (ret);
-}
-
-int
-pthread_setcanceltype(int type, int *oldtype)
-{
- int otype;
- int ret;
-
- otype = _thread_run->cancelflags & PTHREAD_CANCEL_ASYNCHRONOUS;
- switch (type) {
- case PTHREAD_CANCEL_ASYNCHRONOUS:
- if (oldtype != NULL)
- *oldtype = otype;
- _thread_run->cancelflags |= PTHREAD_CANCEL_ASYNCHRONOUS;
- pthread_testcancel();
- ret = 0;
- break;
- case PTHREAD_CANCEL_DEFERRED:
- if (oldtype != NULL)
- *oldtype = otype;
- _thread_run->cancelflags &= ~PTHREAD_CANCEL_ASYNCHRONOUS;
- ret = 0;
- break;
- default:
- ret = EINVAL;
- }
-
- return (ret);
-}
-
-void
-pthread_testcancel(void)
-{
- if (((_thread_run->cancelflags & PTHREAD_CANCEL_DISABLE) == 0) &&
- ((_thread_run->cancelflags & PTHREAD_CANCELLING) != 0)) {
- /*
- * It is possible for this thread to be swapped out
- * while performing cancellation; do not allow it
- * to be cancelled again.
- */
- _thread_run->cancelflags &= ~PTHREAD_CANCELLING;
- _thread_exit_cleanup();
- pthread_exit(PTHREAD_CANCELED);
- PANIC("cancel");
- }
-}
-
-void
-_thread_enter_cancellation_point(void)
-{
- /* Look for a cancellation before we block: */
- pthread_testcancel();
- _thread_run->cancelflags |= PTHREAD_AT_CANCEL_POINT;
-}
-
-void
-_thread_leave_cancellation_point(void)
-{
- _thread_run->cancelflags &= ~PTHREAD_AT_CANCEL_POINT;
- /* Look for a cancellation after we unblock: */
- pthread_testcancel();
-}
-
-static void
-finish_cancellation(void *arg)
-{
- _thread_run->continuation = NULL;
- _thread_run->interrupted = 0;
-
- if ((_thread_run->cancelflags & PTHREAD_CANCEL_NEEDED) != 0) {
- _thread_run->cancelflags &= ~PTHREAD_CANCEL_NEEDED;
- _thread_exit_cleanup();
- pthread_exit(PTHREAD_CANCELED);
- }
-}
diff --git a/lib/libpthread/thread/thr_clean.c b/lib/libpthread/thread/thr_clean.c
deleted file mode 100644
index bba5500c8fe7..000000000000
--- a/lib/libpthread/thread/thr_clean.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <signal.h>
-#include <errno.h>
-#include <stdlib.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-void
-pthread_cleanup_push(void (*routine) (void *), void *routine_arg)
-{
- struct pthread_cleanup *new;
-
- if ((new = (struct pthread_cleanup *) malloc(sizeof(struct pthread_cleanup))) != NULL) {
- new->routine = routine;
- new->routine_arg = routine_arg;
- new->next = _thread_run->cleanup;
-
- _thread_run->cleanup = new;
- }
-}
-
-void
-pthread_cleanup_pop(int execute)
-{
- struct pthread_cleanup *old;
-
- if ((old = _thread_run->cleanup) != NULL) {
- _thread_run->cleanup = old->next;
- if (execute) {
- old->routine(old->routine_arg);
- }
- free(old);
- }
-}
-
-#endif
diff --git a/lib/libpthread/thread/thr_close.c b/lib/libpthread/thread/thr_close.c
deleted file mode 100644
index 9dee2bc8b56e..000000000000
--- a/lib/libpthread/thread/thr_close.c
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-_close(int fd)
-{
- int flags;
- int ret;
- struct stat sb;
- struct fd_table_entry *entry;
-
- if ((fd == _thread_kern_pipe[0]) || (fd == _thread_kern_pipe[1])) {
- /*
- * Don't allow silly programs to close the kernel pipe.
- */
- errno = EBADF;
- ret = -1;
- }
- /*
- * Lock the file descriptor while the file is closed and get
- * the file descriptor status:
- */
- else if (((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) &&
- ((ret = _thread_sys_fstat(fd, &sb)) == 0)) {
- /*
- * Check if the file should be left as blocking.
- *
- * This is so that the file descriptors shared with a parent
- * process aren't left set to non-blocking if the child
- * closes them prior to exit. An example where this causes
- * problems with /bin/sh is when a child closes stdin.
- *
- * Setting a file as blocking causes problems if a threaded
- * parent accesses the file descriptor before the child exits.
- * Once the threaded parent receives a SIGCHLD then it resets
- * all of its files to non-blocking, and so it is then safe
- * to access them.
- *
- * Pipes are not set to blocking when they are closed, as
- * the parent and child will normally close the file
- * descriptor of the end of the pipe that they are not
- * using, which would then cause any reads to block
- * indefinitely.
- */
- if ((S_ISREG(sb.st_mode) || S_ISCHR(sb.st_mode)) && (_thread_fd_table[fd]->flags & O_NONBLOCK) == 0) {
- /* Get the current flags: */
- flags = _thread_sys_fcntl(fd, F_GETFL, NULL);
- /* Clear the nonblocking file descriptor flag: */
- _thread_sys_fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);
- }
-
- /* XXX: Assumes well behaved threads. */
- /* XXX: Defer real close to avoid race condition */
- entry = _thread_fd_table[fd];
- _thread_fd_table[fd] = NULL;
- free(entry);
-
- /* Close the file descriptor: */
- ret = _thread_sys_close(fd);
- }
- return (ret);
-}
-
-int
-close(int fd)
-{
- int ret;
-
- _thread_enter_cancellation_point();
- ret = _close(fd);
- _thread_leave_cancellation_point();
-
- return ret;
-}
-#endif
diff --git a/lib/libpthread/thread/thr_cond.c b/lib/libpthread/thread/thr_cond.c
deleted file mode 100644
index d23660788fc9..000000000000
--- a/lib/libpthread/thread/thr_cond.c
+++ /dev/null
@@ -1,639 +0,0 @@
-/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <stdlib.h>
-#include <errno.h>
-#include <string.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-/*
- * Prototypes
- */
-static inline pthread_t cond_queue_deq(pthread_cond_t);
-static inline void cond_queue_remove(pthread_cond_t, pthread_t);
-static inline void cond_queue_enq(pthread_cond_t, pthread_t);
-
-/* Reinitialize a condition variable to defaults. */
-int
-_cond_reinit(pthread_cond_t * cond)
-{
- int ret = 0;
-
- if (cond == NULL)
- ret = EINVAL;
- else if (*cond == NULL)
- ret = pthread_cond_init(cond, NULL);
- else {
- /*
- * Initialize the condition variable structure:
- */
- TAILQ_INIT(&(*cond)->c_queue);
- (*cond)->c_flags = COND_FLAGS_INITED;
- (*cond)->c_type = COND_TYPE_FAST;
- (*cond)->c_mutex = NULL;
- memset(&(*cond)->lock, 0, sizeof((*cond)->lock));
- }
- return (ret);
-}
-
-int
-pthread_cond_init(pthread_cond_t * cond, const pthread_condattr_t * cond_attr)
-{
- enum pthread_cond_type type;
- pthread_cond_t pcond;
- int rval = 0;
-
- if (cond == NULL)
- rval = EINVAL;
- else {
- /*
- * Check if a pointer to a condition variable attribute
- * structure was passed by the caller:
- */
- if (cond_attr != NULL && *cond_attr != NULL) {
- /* Default to a fast condition variable: */
- type = (*cond_attr)->c_type;
- } else {
- /* Default to a fast condition variable: */
- type = COND_TYPE_FAST;
- }
-
- /* Process according to condition variable type: */
- switch (type) {
- /* Fast condition variable: */
- case COND_TYPE_FAST:
- /* Nothing to do here. */
- break;
-
- /* Trap invalid condition variable types: */
- default:
- /* Return an invalid argument error: */
- rval = EINVAL;
- break;
- }
-
- /* Check for no errors: */
- if (rval == 0) {
- if ((pcond = (pthread_cond_t)
- malloc(sizeof(struct pthread_cond))) == NULL) {
- rval = ENOMEM;
- } else {
- /*
- * Initialise the condition variable
- * structure:
- */
- TAILQ_INIT(&pcond->c_queue);
- pcond->c_flags |= COND_FLAGS_INITED;
- pcond->c_type = type;
- pcond->c_mutex = NULL;
- memset(&pcond->lock,0,sizeof(pcond->lock));
- *cond = pcond;
- }
- }
- }
- /* Return the completion status: */
- return (rval);
-}
-
-int
-pthread_cond_destroy(pthread_cond_t * cond)
-{
- int rval = 0;
-
- if (cond == NULL || *cond == NULL)
- rval = EINVAL;
- else {
- /* Lock the condition variable structure: */
- _SPINLOCK(&(*cond)->lock);
-
- /*
- * Free the memory allocated for the condition
- * variable structure:
- */
- free(*cond);
-
- /*
- * NULL the caller's pointer now that the condition
- * variable has been destroyed:
- */
- *cond = NULL;
- }
- /* Return the completion status: */
- return (rval);
-}
-
-int
-pthread_cond_wait(pthread_cond_t * cond, pthread_mutex_t * mutex)
-{
- int rval = 0;
- int interrupted = 0;
-
- _thread_enter_cancellation_point();
-
- if (cond == NULL)
- rval = EINVAL;
-
- /*
- * If the condition variable is statically initialized,
- * perform the dynamic initialization:
- */
- else if (*cond != NULL ||
- (rval = pthread_cond_init(cond,NULL)) == 0) {
-
- _thread_enter_cancellation_point();
-
- /* Lock the condition variable structure: */
- _SPINLOCK(&(*cond)->lock);
-
- /*
- * If the condvar was statically allocated, properly
- * initialize the tail queue.
- */
- if (((*cond)->c_flags & COND_FLAGS_INITED) == 0) {
- TAILQ_INIT(&(*cond)->c_queue);
- (*cond)->c_flags |= COND_FLAGS_INITED;
- }
-
- /* Process according to condition variable type: */
- switch ((*cond)->c_type) {
- /* Fast condition variable: */
- case COND_TYPE_FAST:
- if ((mutex == NULL) || (((*cond)->c_mutex != NULL) &&
- ((*cond)->c_mutex != *mutex))) {
- /* Unlock the condition variable structure: */
- _SPINUNLOCK(&(*cond)->lock);
-
- /* Return invalid argument error: */
- rval = EINVAL;
- } else {
- /* Reset the timeout and interrupted flags: */
- _thread_run->timeout = 0;
- _thread_run->interrupted = 0;
-
- /*
- * Queue the running thread for the condition
- * variable:
- */
- cond_queue_enq(*cond, _thread_run);
-
- /* Remember the mutex that is being used: */
- (*cond)->c_mutex = *mutex;
-
- /* Wait forever: */
- _thread_run->wakeup_time.tv_sec = -1;
-
- /* Unlock the mutex: */
- if ((rval = _mutex_cv_unlock(mutex)) != 0) {
- /*
- * Cannot unlock the mutex, so remove
- * the running thread from the condition
- * variable queue:
- */
- cond_queue_remove(*cond, _thread_run);
-
- /* Check for no more waiters: */
- if (TAILQ_FIRST(&(*cond)->c_queue) ==
- NULL)
- (*cond)->c_mutex = NULL;
-
- /* Unlock the condition variable structure: */
- _SPINUNLOCK(&(*cond)->lock);
- }
- else {
- /*
- * Schedule the next thread and unlock
- * the condition variable structure:
- */
- _thread_kern_sched_state_unlock(PS_COND_WAIT,
- &(*cond)->lock, __FILE__, __LINE__);
-
- if (_thread_run->interrupted != 0) {
- /*
- * Remember that this thread
- * was interrupted:
- */
- interrupted = 1;
-
- /*
- * Lock the condition variable
- * while removing the thread.
- */
- _SPINLOCK(&(*cond)->lock);
-
- cond_queue_remove(*cond,
- _thread_run);
-
- /* Check for no more waiters: */
- if (TAILQ_FIRST(&(*cond)->c_queue) == NULL)
- (*cond)->c_mutex = NULL;
-
- _SPINUNLOCK(&(*cond)->lock);
- }
-
- /*
- * Note that even though this thread may have
- * been canceled, POSIX requires that the mutex
- * be reaquired prior to cancellation.
- */
- rval = _mutex_cv_lock(mutex);
- }
- }
- break;
-
- /* Trap invalid condition variable types: */
- default:
- /* Unlock the condition variable structure: */
- _SPINUNLOCK(&(*cond)->lock);
-
- /* Return an invalid argument error: */
- rval = EINVAL;
- break;
- }
-
- if (interrupted != 0 && _thread_run->continuation != NULL)
- _thread_run->continuation((void *) _thread_run);
-
- _thread_leave_cancellation_point();
- }
-
- _thread_leave_cancellation_point();
-
- /* Return the completion status: */
- return (rval);
-}
-
-int
-pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex,
- const struct timespec * abstime)
-{
- int rval = 0;
- int interrupted = 0;
-
- _thread_enter_cancellation_point();
-
- if (cond == NULL || abstime == NULL)
- rval = EINVAL;
-
- if (abstime->tv_sec < 0 ||
- abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) {
- errno = EINVAL;
- _thread_leave_cancellation_point();
- return (-1);
- }
-
- /*
- * If the condition variable is statically initialized,
- * perform the dynamic initialization:
- */
- if (*cond != NULL ||
- (rval = pthread_cond_init(cond,NULL)) == 0) {
-
- _thread_enter_cancellation_point();
-
- /* Lock the condition variable structure: */
- _SPINLOCK(&(*cond)->lock);
-
- /*
- * If the condvar was statically allocated, properly
- * initialize the tail queue.
- */
- if (((*cond)->c_flags & COND_FLAGS_INITED) == 0) {
- TAILQ_INIT(&(*cond)->c_queue);
- (*cond)->c_flags |= COND_FLAGS_INITED;
- }
-
- /* Process according to condition variable type: */
- switch ((*cond)->c_type) {
- /* Fast condition variable: */
- case COND_TYPE_FAST:
- if ((mutex == NULL) || (((*cond)->c_mutex != NULL) &&
- ((*cond)->c_mutex != *mutex))) {
- /* Return invalid argument error: */
- rval = EINVAL;
-
- /* Unlock the condition variable structure: */
- _SPINUNLOCK(&(*cond)->lock);
- } else {
- /* Set the wakeup time: */
- _thread_run->wakeup_time.tv_sec =
- abstime->tv_sec;
- _thread_run->wakeup_time.tv_nsec =
- abstime->tv_nsec;
-
- /* Reset the timeout and interrupted flags: */
- _thread_run->timeout = 0;
- _thread_run->interrupted = 0;
-
- /*
- * Queue the running thread for the condition
- * variable:
- */
- cond_queue_enq(*cond, _thread_run);
-
- /* Remember the mutex that is being used: */
- (*cond)->c_mutex = *mutex;
-
- /* Unlock the mutex: */
- if ((rval = _mutex_cv_unlock(mutex)) != 0) {
- /*
- * Cannot unlock the mutex, so remove
- * the running thread from the condition
- * variable queue:
- */
- cond_queue_remove(*cond, _thread_run);
-
- /* Check for no more waiters: */
- if (TAILQ_FIRST(&(*cond)->c_queue) == NULL)
- (*cond)->c_mutex = NULL;
-
- /* Unlock the condition variable structure: */
- _SPINUNLOCK(&(*cond)->lock);
- } else {
- /*
- * Schedule the next thread and unlock
- * the condition variable structure:
- */
- _thread_kern_sched_state_unlock(PS_COND_WAIT,
- &(*cond)->lock, __FILE__, __LINE__);
-
- /*
- * Check if the wait timedout or was
- * interrupted (canceled):
- */
- if ((_thread_run->timeout == 0) &&
- (_thread_run->interrupted == 0)) {
- /* Lock the mutex: */
- rval = _mutex_cv_lock(mutex);
-
- } else {
- /*
- * Remember if this thread was
- * interrupted:
- */
- interrupted = _thread_run->interrupted;
-
- /* Lock the condition variable structure: */
- _SPINLOCK(&(*cond)->lock);
-
- /*
- * The wait timed out; remove
- * the thread from the condition
- * variable queue:
- */
- cond_queue_remove(*cond,
- _thread_run);
-
- /* Check for no more waiters: */
- if (TAILQ_FIRST(&(*cond)->c_queue) == NULL)
- (*cond)->c_mutex = NULL;
-
- /* Unock the condition variable structure: */
- _SPINUNLOCK(&(*cond)->lock);
-
- /* Return a timeout error: */
- rval = ETIMEDOUT;
-
- /*
- * Lock the mutex and ignore any
- * errors. Note that even though
- * this thread may have been
- * canceled, POSIX requires that
- * the mutex be reaquired prior
- * to cancellation.
- */
- (void)_mutex_cv_lock(mutex);
- }
- }
- }
- break;
-
- /* Trap invalid condition variable types: */
- default:
- /* Unlock the condition variable structure: */
- _SPINUNLOCK(&(*cond)->lock);
-
- /* Return an invalid argument error: */
- rval = EINVAL;
- break;
- }
-
- if (interrupted != 0 && _thread_run->continuation != NULL)
- _thread_run->continuation((void *) _thread_run);
-
- _thread_leave_cancellation_point();
- }
-
- _thread_leave_cancellation_point();
-
- /* Return the completion status: */
- return (rval);
-}
-
-int
-pthread_cond_signal(pthread_cond_t * cond)
-{
- int rval = 0;
- pthread_t pthread;
-
- if (cond == NULL || *cond == NULL)
- rval = EINVAL;
- else {
- /*
- * Defer signals to protect the scheduling queues
- * from access by the signal handler:
- */
- _thread_kern_sig_defer();
-
- /* Lock the condition variable structure: */
- _SPINLOCK(&(*cond)->lock);
-
- /* Process according to condition variable type: */
- switch ((*cond)->c_type) {
- /* Fast condition variable: */
- case COND_TYPE_FAST:
- if ((pthread = cond_queue_deq(*cond)) != NULL)
- /* Allow the thread to run: */
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
-
- /* Check for no more waiters: */
- if (TAILQ_FIRST(&(*cond)->c_queue) == NULL)
- (*cond)->c_mutex = NULL;
- break;
-
- /* Trap invalid condition variable types: */
- default:
- /* Return an invalid argument error: */
- rval = EINVAL;
- break;
- }
-
- /* Unlock the condition variable structure: */
- _SPINUNLOCK(&(*cond)->lock);
-
- /*
- * Undefer and handle pending signals, yielding if
- * necessary:
- */
- _thread_kern_sig_undefer();
- }
-
- /* Return the completion status: */
- return (rval);
-}
-
-int
-pthread_cond_broadcast(pthread_cond_t * cond)
-{
- int rval = 0;
- pthread_t pthread;
-
- if (cond == NULL || *cond == NULL)
- rval = EINVAL;
- else {
- /*
- * Defer signals to protect the scheduling queues
- * from access by the signal handler:
- */
- _thread_kern_sig_defer();
-
- /* Lock the condition variable structure: */
- _SPINLOCK(&(*cond)->lock);
-
- /* Process according to condition variable type: */
- switch ((*cond)->c_type) {
- /* Fast condition variable: */
- case COND_TYPE_FAST:
- /*
- * Enter a loop to bring all threads off the
- * condition queue:
- */
- while ((pthread = cond_queue_deq(*cond)) != NULL) {
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
- }
-
- /* There are no more waiting threads: */
- (*cond)->c_mutex = NULL;
- break;
-
- /* Trap invalid condition variable types: */
- default:
- /* Return an invalid argument error: */
- rval = EINVAL;
- break;
- }
-
- /* Unlock the condition variable structure: */
- _SPINUNLOCK(&(*cond)->lock);
-
- /*
- * Undefer and handle pending signals, yielding if
- * necessary:
- */
- _thread_kern_sig_undefer();
- }
-
- /* Return the completion status: */
- return (rval);
-}
-
-/*
- * Dequeue a waiting thread from the head of a condition queue in
- * descending priority order.
- */
-static inline pthread_t
-cond_queue_deq(pthread_cond_t cond)
-{
- pthread_t pthread;
-
- while ((pthread = TAILQ_FIRST(&cond->c_queue)) != NULL) {
- TAILQ_REMOVE(&cond->c_queue, pthread, qe);
- pthread->flags &= ~PTHREAD_FLAGS_IN_CONDQ;
- if ((pthread->timeout == 0) && (pthread->interrupted == 0))
- /*
- * Only exit the loop when we find a thread
- * that hasn't timed out or been canceled;
- * those threads are already running and don't
- * need their run state changed.
- */
- break;
- }
-
- return(pthread);
-}
-
-/*
- * Remove a waiting thread from a condition queue in descending priority
- * order.
- */
-static inline void
-cond_queue_remove(pthread_cond_t cond, pthread_t pthread)
-{
- /*
- * Because pthread_cond_timedwait() can timeout as well
- * as be signaled by another thread, it is necessary to
- * guard against removing the thread from the queue if
- * it isn't in the queue.
- */
- if (pthread->flags & PTHREAD_FLAGS_IN_CONDQ) {
- TAILQ_REMOVE(&cond->c_queue, pthread, qe);
- pthread->flags &= ~PTHREAD_FLAGS_IN_CONDQ;
- }
-}
-
-/*
- * Enqueue a waiting thread to a condition queue in descending priority
- * order.
- */
-static inline void
-cond_queue_enq(pthread_cond_t cond, pthread_t pthread)
-{
- pthread_t tid = TAILQ_LAST(&cond->c_queue, cond_head);
-
- /*
- * For the common case of all threads having equal priority,
- * we perform a quick check against the priority of the thread
- * at the tail of the queue.
- */
- if ((tid == NULL) || (pthread->active_priority <= tid->active_priority))
- TAILQ_INSERT_TAIL(&cond->c_queue, pthread, qe);
- else {
- tid = TAILQ_FIRST(&cond->c_queue);
- while (pthread->active_priority <= tid->active_priority)
- tid = TAILQ_NEXT(tid, qe);
- TAILQ_INSERT_BEFORE(tid, pthread, qe);
- }
- pthread->flags |= PTHREAD_FLAGS_IN_CONDQ;
-}
-#endif
diff --git a/lib/libpthread/thread/thr_condattr_destroy.c b/lib/libpthread/thread/thr_condattr_destroy.c
deleted file mode 100644
index ad91228c3050..000000000000
--- a/lib/libpthread/thread/thr_condattr_destroy.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <stdlib.h>
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int pthread_condattr_destroy(pthread_condattr_t *attr)
-{
- int ret;
- if (attr == NULL || *attr == NULL) {
- ret = EINVAL;
- } else {
- free(*attr);
- *attr = NULL;
- ret = 0;
- }
- return(ret);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_condattr_init.c b/lib/libpthread/thread/thr_condattr_init.c
deleted file mode 100644
index 33798982f330..000000000000
--- a/lib/libpthread/thread/thr_condattr_init.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_condattr_init(pthread_condattr_t *attr)
-{
- int ret;
- pthread_condattr_t pattr;
-
- if ((pattr = (pthread_condattr_t)
- malloc(sizeof(struct pthread_cond_attr))) == NULL) {
- ret = ENOMEM;
- } else {
- memcpy(pattr, &pthread_condattr_default,
- sizeof(struct pthread_cond_attr));
- *attr = pattr;
- ret = 0;
- }
- return(ret);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_creat.c b/lib/libpthread/thread/thr_creat.c
deleted file mode 100644
index bb8e7c257c5b..000000000000
--- a/lib/libpthread/thread/thr_creat.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2000 Jason Evans <jasone@canonware.com>.
- * 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(s), this list of conditions and the following disclaimer as
- * the first lines of this file unmodified other than the possible
- * addition of one or more copyright notices.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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.
- *
- * $FreeBSD$
- */
-
-#include <fcntl.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-creat(const char *path, mode_t mode)
-{
- int ret;
-
- _thread_enter_cancellation_point();
- ret = __creat(path, mode);
- _thread_leave_cancellation_point();
-
- return ret;
-}
-#endif
diff --git a/lib/libpthread/thread/thr_create.c b/lib/libpthread/thread/thr_create.c
deleted file mode 100644
index b8a1c466b978..000000000000
--- a/lib/libpthread/thread/thr_create.c
+++ /dev/null
@@ -1,348 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <stddef.h>
-#include <sys/time.h>
-#include <sys/param.h>
-#include <sys/mman.h>
-#ifdef _THREAD_SAFE
-#include <machine/reg.h>
-#include <pthread.h>
-#include "pthread_private.h"
-#include "libc_private.h"
-
-static u_int64_t next_uniqueid = 1;
-
-#define OFF(f) offsetof(struct pthread, f)
-int _thread_next_offset = OFF(tle.tqe_next);
-int _thread_uniqueid_offset = OFF(uniqueid);
-int _thread_state_offset = OFF(state);
-int _thread_name_offset = OFF(name);
-int _thread_sig_saved_offset = OFF(sig_saved);
-int _thread_saved_sigcontext_offset = OFF(saved_sigcontext);
-int _thread_saved_jmp_buf_offset = OFF(saved_jmp_buf);
-#undef OFF
-
-int _thread_PS_RUNNING_value = PS_RUNNING;
-int _thread_PS_DEAD_value = PS_DEAD;
-
-int
-pthread_create(pthread_t * thread, const pthread_attr_t * attr,
- void *(*start_routine) (void *), void *arg)
-{
- int f_gc = 0;
- int ret = 0;
- pthread_t gc_thread;
- pthread_t new_thread;
- pthread_attr_t pattr;
- void *stack;
-
- /*
- * Locking functions in libc are required when there are
- * threads other than the initial thread.
- */
- __isthreaded = 1;
-
- /* Allocate memory for the thread structure: */
- if ((new_thread = (pthread_t) malloc(sizeof(struct pthread))) == NULL) {
- /* Insufficient memory to create a thread: */
- ret = EAGAIN;
- } else {
- /* Check if default thread attributes are required: */
- if (attr == NULL || *attr == NULL) {
- /* Use the default thread attributes: */
- pattr = &pthread_attr_default;
- } else {
- pattr = *attr;
- }
- /* Check if a stack was specified in the thread attributes: */
- if ((stack = pattr->stackaddr_attr) != NULL) {
- }
- /* Allocate memory for a default-size stack: */
- else if (pattr->stacksize_attr == PTHREAD_STACK_DEFAULT) {
- struct stack *spare_stack;
-
- /* Allocate or re-use a default-size stack. */
-
- /*
- * Use the garbage collector mutex for synchronization
- * of the spare stack list.
- */
- if (pthread_mutex_lock(&_gc_mutex) != 0)
- PANIC("Cannot lock gc mutex");
-
- if ((spare_stack = SLIST_FIRST(&_stackq)) != NULL) {
- /* Use the spare stack. */
- SLIST_REMOVE_HEAD(&_stackq, qe);
-
- /* Unlock the garbage collector mutex. */
- if (pthread_mutex_unlock(&_gc_mutex) != 0)
- PANIC("Cannot unlock gc mutex");
-
- stack = sizeof(struct stack)
- + (void *) spare_stack
- - PTHREAD_STACK_DEFAULT;
- } else {
- /* Allocate a new stack. */
- stack = _next_stack + PTHREAD_STACK_GUARD;
-
- /*
- * Even if stack allocation fails, we don't want
- * to try to use this location again, so
- * unconditionally decrement _next_stack. Under
- * normal operating conditions, the most likely
- * reason for an mmap() error is a stack
- * overflow of the adjacent thread stack.
- */
- _next_stack -= (PTHREAD_STACK_DEFAULT
- + PTHREAD_STACK_GUARD);
-
- /* Unlock the garbage collector mutex. */
- if (pthread_mutex_unlock(&_gc_mutex) != 0)
- PANIC("Cannot unlock gc mutex");
-
- /* Stack: */
- if (mmap(stack, PTHREAD_STACK_DEFAULT,
- PROT_READ | PROT_WRITE, MAP_STACK,
- -1, 0) == MAP_FAILED) {
- ret = EAGAIN;
- free(new_thread);
- }
- }
- }
- /*
- * The user wants a stack of a particular size. Lets hope they
- * really know what they want, and simply malloc the stack.
- */
- else if ((stack = (void *) malloc(pattr->stacksize_attr))
- == NULL) {
- /* Insufficient memory to create a thread: */
- ret = EAGAIN;
- free(new_thread);
- }
-
- /* Check for errors: */
- if (ret != 0) {
- } else {
- /* Initialise the thread structure: */
- memset(new_thread, 0, sizeof(struct pthread));
- new_thread->slice_usec = -1;
- new_thread->sig_saved = 0;
- new_thread->stack = stack;
- new_thread->start_routine = start_routine;
- new_thread->arg = arg;
-
- new_thread->cancelflags = PTHREAD_CANCEL_ENABLE |
- PTHREAD_CANCEL_DEFERRED;
-
- /*
- * Write a magic value to the thread structure
- * to help identify valid ones:
- */
- new_thread->magic = PTHREAD_MAGIC;
-
- /* Initialise the thread for signals: */
- new_thread->sigmask = _thread_run->sigmask;
-
- /* Initialise the jump buffer: */
- setjmp(new_thread->saved_jmp_buf);
-
- /*
- * Set up new stack frame so that it looks like it
- * returned from a longjmp() to the beginning of
- * _thread_start().
- */
-#if defined(__FreeBSD__)
-#if defined(__alpha__)
- new_thread->saved_jmp_buf[0]._jb[2] =
- (long)_thread_start;
- new_thread->saved_jmp_buf[0]._jb[4 + R_RA] =
- 0;
- new_thread->saved_jmp_buf[0]._jb[4 + R_T12] =
- (long)_thread_start;
-#else
- new_thread->saved_jmp_buf[0]._jb[0] =
- (long)_thread_start;
-#endif
-#elif defined(__NetBSD__)
-#if defined(__alpha__)
- new_thread->saved_jmp_buf[2] = (long)_thread_start;
- new_thread->saved_jmp_buf[4 + R_RA] = 0;
- new_thread->saved_jmp_buf[4 + R_T12] =
- (long)_thread_start;
-#else
- new_thread->saved_jmp_buf[0] = (long)_thread_start;
-#endif
-#else
-#error "Don't recognize this operating system!"
-#endif
-
- /* The stack starts high and builds down: */
-#if defined(__FreeBSD__)
-#if defined(__alpha__)
- new_thread->saved_jmp_buf[0]._jb[4 + R_SP] =
- (long)new_thread->stack + pattr->stacksize_attr
- - sizeof(double);
-#else
- new_thread->saved_jmp_buf[0]._jb[2] =
- (int)(new_thread->stack + pattr->stacksize_attr -
- sizeof(double));
-#endif
-#elif defined(__NetBSD__)
-#if defined(__alpha__)
- new_thread->saved_jmp_buf[4 + R_SP] =
- (long)new_thread->stack + pattr->stacksize_attr -
- sizeof(double);
-#else
- new_thread->saved_jmp_buf[2] = (long)new_thread->stack
- + pattr->stacksize_attr - sizeof(double);
-#endif
-#else
-#error "Don't recognize this operating system!"
-#endif
-
- /* Copy the thread attributes: */
- memcpy(&new_thread->attr, pattr, sizeof(struct pthread_attr));
-
- /*
- * Check if this thread is to inherit the scheduling
- * attributes from its parent:
- */
- if (new_thread->attr.flags & PTHREAD_INHERIT_SCHED) {
- /* Copy the scheduling attributes: */
- new_thread->base_priority
- = _thread_run->base_priority;
- new_thread->attr.prio
- = _thread_run->base_priority;
- new_thread->attr.sched_policy
- = _thread_run->attr.sched_policy;
- } else {
- /*
- * Use just the thread priority, leaving the
- * other scheduling attributes as their
- * default values:
- */
- new_thread->base_priority
- = new_thread->attr.prio;
- }
- new_thread->active_priority = new_thread->base_priority;
- new_thread->inherited_priority = 0;
-
- /* Initialise the join queue for the new thread: */
- TAILQ_INIT(&(new_thread->join_queue));
-
- /* Initialize the mutex queue: */
- TAILQ_INIT(&new_thread->mutexq);
-
- /* Initialise hooks in the thread structure: */
- new_thread->specific_data = NULL;
- new_thread->cleanup = NULL;
- new_thread->flags = 0;
- new_thread->poll_data.nfds = 0;
- new_thread->poll_data.fds = NULL;
- new_thread->jmpflags = 0;
- new_thread->continuation = NULL;
-
- /*
- * Defer signals to protect the scheduling queues
- * from access by the signal handler:
- */
- _thread_kern_sig_defer();
-
- /*
- * Initialise the unique id which GDB uses to
- * track threads.
- */
- new_thread->uniqueid = next_uniqueid++;
-
- /*
- * Check if the garbage collector thread
- * needs to be started.
- */
- f_gc = (TAILQ_FIRST(&_thread_list) == _thread_initial);
-
- /* Add the thread to the linked list of all threads: */
- TAILQ_INSERT_HEAD(&_thread_list, new_thread, tle);
-
- if (pattr->suspend == PTHREAD_CREATE_SUSPENDED) {
- new_thread->state = PS_SUSPENDED;
- PTHREAD_WAITQ_INSERT(new_thread);
- } else {
- new_thread->state = PS_RUNNING;
- PTHREAD_PRIOQ_INSERT_TAIL(new_thread);
- }
-
- /*
- * Undefer and handle pending signals, yielding
- * if necessary.
- */
- _thread_kern_sig_undefer();
-
- /* Return a pointer to the thread structure: */
- (*thread) = new_thread;
-
- /* Schedule the new user thread: */
- _thread_kern_sched(NULL);
-
- /*
- * Start a garbage collector thread
- * if necessary.
- */
- if (f_gc && pthread_create(&gc_thread,NULL,
- _thread_gc,NULL) != 0)
- PANIC("Can't create gc thread");
- }
- }
-
- /* Return the status: */
- return (ret);
-}
-
-void
-_thread_start(void)
-{
- /* We just left the scheduler via longjmp: */
- _thread_kern_in_sched = 0;
-
- /* Run the current thread's start routine with argument: */
- pthread_exit(_thread_run->start_routine(_thread_run->arg));
-
- /* This point should never be reached. */
- PANIC("Thread has resumed after exit");
-}
-#endif
diff --git a/lib/libpthread/thread/thr_detach.c b/lib/libpthread/thread/thr_detach.c
deleted file mode 100644
index 89cc6671179c..000000000000
--- a/lib/libpthread/thread/thr_detach.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_detach(pthread_t pthread)
-{
- int rval = 0;
- pthread_t next_thread;
-
- /* Check for invalid calling parameters: */
- if (pthread == NULL || pthread->magic != PTHREAD_MAGIC)
- /* Return an invalid argument error: */
- rval = EINVAL;
-
- /* Check if the thread has not been detached: */
- else if ((pthread->attr.flags & PTHREAD_DETACHED) == 0) {
- /* Flag the thread as detached: */
- pthread->attr.flags |= PTHREAD_DETACHED;
-
- /*
- * Defer signals to protect the scheduling queues from
- * access by the signal handler:
- */
- _thread_kern_sig_defer();
-
- /* Enter a loop to bring all threads off the join queue: */
- while ((next_thread = TAILQ_FIRST(&pthread->join_queue)) != NULL) {
- /* Remove the thread from the queue: */
- TAILQ_REMOVE(&pthread->join_queue, next_thread, qe);
-
- /* Make the thread run: */
- PTHREAD_NEW_STATE(next_thread,PS_RUNNING);
- }
-
- /*
- * Undefer and handle pending signals, yielding if a
- * scheduling signal occurred while in the critical region.
- */
- _thread_kern_sig_undefer();
- } else
- /* Return an error: */
- rval = EINVAL;
-
- /* Return the completion status: */
- return (rval);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_equal.c b/lib/libpthread/thread/thr_equal.c
deleted file mode 100644
index e03ba4afe445..000000000000
--- a/lib/libpthread/thread/thr_equal.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_equal(pthread_t t1, pthread_t t2)
-{
- /* Compare the two thread pointers: */
- return (t1 == t2);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_exit.c b/lib/libpthread/thread/thr_exit.c
deleted file mode 100644
index 0d22638fd7fc..000000000000
--- a/lib/libpthread/thread/thr_exit.c
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-void __exit(int status)
-{
- int flags;
- int i;
- struct itimerval itimer;
-
- /* Disable the interval timer: */
- itimer.it_interval.tv_sec = 0;
- itimer.it_interval.tv_usec = 0;
- itimer.it_value.tv_sec = 0;
- itimer.it_value.tv_usec = 0;
- setitimer(_ITIMER_SCHED_TIMER, &itimer, NULL);
-
- /* Close the pthread kernel pipe: */
- _thread_sys_close(_thread_kern_pipe[0]);
- _thread_sys_close(_thread_kern_pipe[1]);
-
- /*
- * Enter a loop to set all file descriptors to blocking
- * if they were not created as non-blocking:
- */
- for (i = 0; i < _thread_dtablesize; i++) {
- /* Check if this file descriptor is in use: */
- if (_thread_fd_table[i] != NULL &&
- !(_thread_fd_table[i]->flags & O_NONBLOCK)) {
- /* Get the current flags: */
- flags = _thread_sys_fcntl(i, F_GETFL, NULL);
- /* Clear the nonblocking file descriptor flag: */
- _thread_sys_fcntl(i, F_SETFL, flags & ~O_NONBLOCK);
- }
- }
-
- /* Call the _exit syscall: */
- _thread_sys__exit(status);
-}
-
-__strong_reference(__exit, _exit);
-
-void
-_thread_exit(char *fname, int lineno, char *string)
-{
- char s[256];
-
- /* Prepare an error message string: */
- strcpy(s, "Fatal error '");
- strcat(s, string);
- strcat(s, "' at line ? ");
- strcat(s, "in file ");
- strcat(s, fname);
- strcat(s, " (errno = ?");
- strcat(s, ")\n");
-
- /* Write the string to the standard error file descriptor: */
- _thread_sys_write(2, s, strlen(s));
-
- /* Force this process to exit: */
- /* XXX - Do we want abort to be conditional on _PTHREADS_INVARIANTS? */
-#if defined(_PTHREADS_INVARIANTS)
- abort();
-#else
- _exit(1);
-#endif
-}
-
-/*
- * Only called when a thread is cancelled. It may be more useful
- * to call it from pthread_exit() if other ways of asynchronous or
- * abnormal thread termination can be found.
- */
-void
-_thread_exit_cleanup(void)
-{
- /*
- * POSIX states that cancellation/termination of a thread should
- * not release any visible resources (such as mutexes) and that
- * it is the applications responsibility. Resources that are
- * internal to the threads library, including file and fd locks,
- * are not visible to the application and need to be released.
- */
- /* Unlock all owned fd locks: */
- _thread_fd_unlock_owned(_thread_run);
-
- /* Unlock all owned file locks: */
- _funlock_owned(_thread_run);
-
- /* Unlock all private mutexes: */
- _mutex_unlock_private(_thread_run);
-
- /*
- * This still isn't quite correct because we don't account
- * for held spinlocks (see libc/stdlib/malloc.c).
- */
-}
-
-void
-pthread_exit(void *status)
-{
- pthread_t pthread;
-
- /* Check if this thread is already in the process of exiting: */
- if ((_thread_run->flags & PTHREAD_EXITING) != 0) {
- char msg[128];
- snprintf(msg, sizeof(msg), "Thread %p has called pthread_exit() from a destructor. POSIX 1003.1 1996 s16.2.5.2 does not allow this!",_thread_run);
- PANIC(msg);
- }
-
- /* Flag this thread as exiting: */
- _thread_run->flags |= PTHREAD_EXITING;
-
- /* Save the return value: */
- _thread_run->ret = status;
-
- while (_thread_run->cleanup != NULL) {
- pthread_cleanup_pop(1);
- }
-
- if (_thread_run->attr.cleanup_attr != NULL) {
- _thread_run->attr.cleanup_attr(_thread_run->attr.arg_attr);
- }
- /* Check if there is thread specific data: */
- if (_thread_run->specific_data != NULL) {
- /* Run the thread-specific data destructors: */
- _thread_cleanupspecific();
- }
-
- /* Free thread-specific poll_data structure, if allocated: */
- if (_thread_run->poll_data.fds != NULL) {
- free(_thread_run->poll_data.fds);
- _thread_run->poll_data.fds = NULL;
- }
-
- /*
- * Defer signals to protect the scheduling queues from access
- * by the signal handler:
- */
- _thread_kern_sig_defer();
-
- /* Check if there are any threads joined to this one: */
- while ((pthread = TAILQ_FIRST(&(_thread_run->join_queue))) != NULL) {
- /* Remove the thread from the queue: */
- TAILQ_REMOVE(&_thread_run->join_queue, pthread, qe);
-
- /* Wake the joined thread and let it detach this thread: */
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
- }
-
- /*
- * Undefer and handle pending signals, yielding if necessary:
- */
- _thread_kern_sig_undefer();
-
- /*
- * Lock the garbage collector mutex to ensure that the garbage
- * collector is not using the dead thread list.
- */
- if (pthread_mutex_lock(&_gc_mutex) != 0)
- PANIC("Cannot lock gc mutex");
-
- /* Add this thread to the list of dead threads. */
- TAILQ_INSERT_HEAD(&_dead_list, _thread_run, dle);
-
- /*
- * Defer signals to protect the scheduling queues from access
- * by the signal handler:
- */
- _thread_kern_sig_defer();
-
- /* Remove this thread from the thread list: */
- TAILQ_REMOVE(&_thread_list, _thread_run, tle);
-
- /*
- * Undefer and handle pending signals, yielding if necessary:
- */
- _thread_kern_sig_undefer();
-
- /*
- * Signal the garbage collector thread that there is something
- * to clean up.
- */
- if (pthread_cond_signal(&_gc_cond) != 0)
- PANIC("Cannot signal gc cond");
-
- /*
- * Mark the thread as dead so it will not return if it
- * gets context switched out when the mutex is unlocked.
- */
- PTHREAD_SET_STATE(_thread_run, PS_DEAD);
-
- /* Unlock the garbage collector mutex: */
- if (pthread_mutex_unlock(&_gc_mutex) != 0)
- PANIC("Cannot lock gc mutex");
-
- /* This this thread will never be re-scheduled. */
- _thread_kern_sched(NULL);
-
- /* This point should not be reached. */
- PANIC("Dead thread has resumed");
-}
-#endif
diff --git a/lib/libpthread/thread/thr_fcntl.c b/lib/libpthread/thread/thr_fcntl.c
deleted file mode 100644
index f5dd06416559..000000000000
--- a/lib/libpthread/thread/thr_fcntl.c
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <stdarg.h>
-#include <unistd.h>
-#include <fcntl.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-_fcntl(int fd, int cmd,...)
-{
- int flags = 0;
- int nonblock;
- int oldfd;
- int ret;
- va_list ap;
-
- /* Lock the file descriptor: */
- if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) {
- /* Initialise the variable argument list: */
- va_start(ap, cmd);
-
- /* Process according to file control command type: */
- switch (cmd) {
- /* Duplicate a file descriptor: */
- case F_DUPFD:
- /*
- * Get the file descriptor that the caller wants to
- * use:
- */
- oldfd = va_arg(ap, int);
-
- /* Initialise the file descriptor table entry: */
- if ((ret = _thread_sys_fcntl(fd, cmd, oldfd)) < 0) {
- }
- /* Initialise the file descriptor table entry: */
- else if (_thread_fd_table_init(ret) != 0) {
- /* Quietly close the file: */
- _thread_sys_close(ret);
-
- /* Reset the file descriptor: */
- ret = -1;
- } else {
- /*
- * Save the file open flags so that they can
- * be checked later:
- */
- _thread_fd_table[ret]->flags = _thread_fd_table[fd]->flags;
- }
- break;
- case F_SETFD:
- flags = va_arg(ap, int);
- ret = _thread_sys_fcntl(fd, cmd, flags);
- break;
- case F_GETFD:
- ret = _thread_sys_fcntl(fd, cmd, 0);
- break;
- case F_GETFL:
- ret = _thread_fd_table[fd]->flags;
- break;
- case F_SETFL:
- /*
- * Get the file descriptor flags passed by the
- * caller:
- */
- flags = va_arg(ap, int);
-
- /*
- * Check if the user wants a non-blocking file
- * descriptor:
- */
- nonblock = flags & O_NONBLOCK;
-
- /* Set the file descriptor flags: */
- if ((ret = _thread_sys_fcntl(fd, cmd, flags | O_NONBLOCK)) != 0) {
-
- /* Get the flags so that we behave like the kernel: */
- } else if ((flags = _thread_sys_fcntl(fd,
- F_GETFL, 0)) == -1) {
- /* Error getting flags: */
- ret = -1;
-
- /*
- * Check if the file descriptor is non-blocking
- * with respect to the user:
- */
- } else if (nonblock)
- /* A non-blocking descriptor: */
- _thread_fd_table[fd]->flags = flags | O_NONBLOCK;
- else
- /* Save the flags: */
- _thread_fd_table[fd]->flags = flags & ~O_NONBLOCK;
- break;
- default:
- /* Might want to make va_arg use a union */
- ret = _thread_sys_fcntl(fd, cmd, va_arg(ap, void *));
- break;
- }
-
- /* Free variable arguments: */
- va_end(ap);
-
- /* Unlock the file descriptor: */
- _FD_UNLOCK(fd, FD_RDWR);
- }
- /* Return the completion status: */
- return (ret);
-}
-
-int
-fcntl(int fd, int cmd,...)
-{
- int ret;
- va_list ap;
-
- _thread_enter_cancellation_point();
-
- va_start(ap, cmd);
- switch (cmd) {
- case F_DUPFD:
- case F_SETFD:
- case F_SETFL:
- ret = _fcntl(fd, cmd, va_arg(ap, int));
- break;
- case F_GETFD:
- case F_GETFL:
- ret = _fcntl(fd, cmd);
- break;
- default:
- ret = _fcntl(fd, cmd, va_arg(ap, void *));
- }
- va_end(ap);
-
- _thread_leave_cancellation_point();
-
- return ret;
-}
-#endif
diff --git a/lib/libpthread/thread/thr_find_thread.c b/lib/libpthread/thread/thr_find_thread.c
deleted file mode 100644
index d4a3bbd1162d..000000000000
--- a/lib/libpthread/thread/thr_find_thread.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (c) 1998 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-/* Find a thread in the linked list of active threads: */
-int
-_find_thread(pthread_t pthread)
-{
- pthread_t pthread1;
-
- /* Check if the caller has specified an invalid thread: */
- if (pthread == NULL || pthread->magic != PTHREAD_MAGIC)
- /* Invalid thread: */
- return(EINVAL);
-
- /*
- * Defer signals to protect the thread list from access
- * by the signal handler:
- */
- _thread_kern_sig_defer();
-
- /* Search for the specified thread: */
- TAILQ_FOREACH(pthread1, &_thread_list, tle) {
- if (pthread == pthread1)
- break;
- }
-
- /* Undefer and handle pending signals, yielding if necessary: */
- _thread_kern_sig_undefer();
-
- /* Return zero if the thread exists: */
- return ((pthread1 != NULL) ? 0:ESRCH);
-}
-
-/* Find a thread in the linked list of dead threads: */
-int
-_find_dead_thread(pthread_t pthread)
-{
- pthread_t pthread1;
-
- /* Check if the caller has specified an invalid thread: */
- if (pthread == NULL || pthread->magic != PTHREAD_MAGIC)
- /* Invalid thread: */
- return(EINVAL);
-
- /*
- * Lock the garbage collector mutex to ensure that the garbage
- * collector is not using the dead thread list.
- */
- if (pthread_mutex_lock(&_gc_mutex) != 0)
- PANIC("Cannot lock gc mutex");
-
- /* Search for the specified thread: */
- TAILQ_FOREACH(pthread1, &_dead_list, dle) {
- if (pthread1 == pthread)
- break;
- }
-
- /* Unlock the garbage collector mutex: */
- if (pthread_mutex_unlock(&_gc_mutex) != 0)
- PANIC("Cannot lock gc mutex");
-
- /* Return zero if the thread exists: */
- return ((pthread1 != NULL) ? 0:ESRCH);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_fork.c b/lib/libpthread/thread/thr_fork.c
deleted file mode 100644
index a8e85d86e18f..000000000000
--- a/lib/libpthread/thread/thr_fork.c
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-pid_t
-_fork(void)
-{
- int i, flags;
- pid_t ret;
- pthread_t pthread;
- pthread_t pthread_save;
-
- /*
- * Defer signals to protect the scheduling queues from access
- * by the signal handler:
- */
- _thread_kern_sig_defer();
-
- /* Fork a new process: */
- if ((ret = _thread_sys_fork()) != 0) {
- /* Parent process or error. Nothing to do here. */
- } else {
- /* Close the pthread kernel pipe: */
- _thread_sys_close(_thread_kern_pipe[0]);
- _thread_sys_close(_thread_kern_pipe[1]);
-
- /* Reset signals pending for the running thread: */
- sigemptyset(&_thread_run->sigpend);
-
- /*
- * Create a pipe that is written to by the signal handler to
- * prevent signals being missed in calls to
- * _thread_sys_select:
- */
- if (_thread_sys_pipe(_thread_kern_pipe) != 0) {
- /* Cannot create pipe, so abort: */
- PANIC("Cannot create pthread kernel pipe for forked process");
- }
- /* Get the flags for the read pipe: */
- else if ((flags = _thread_sys_fcntl(_thread_kern_pipe[0], F_GETFL, NULL)) == -1) {
- /* Abort this application: */
- abort();
- }
- /* Make the read pipe non-blocking: */
- else if (_thread_sys_fcntl(_thread_kern_pipe[0], F_SETFL, flags | O_NONBLOCK) == -1) {
- /* Abort this application: */
- abort();
- }
- /* Get the flags for the write pipe: */
- else if ((flags = _thread_sys_fcntl(_thread_kern_pipe[1], F_GETFL, NULL)) == -1) {
- /* Abort this application: */
- abort();
- }
- /* Make the write pipe non-blocking: */
- else if (_thread_sys_fcntl(_thread_kern_pipe[1], F_SETFL, flags | O_NONBLOCK) == -1) {
- /* Abort this application: */
- abort();
- }
- /* Reinitialize the GC mutex: */
- else if (_mutex_reinit(&_gc_mutex) != 0) {
- /* Abort this application: */
- PANIC("Cannot initialize GC mutex for forked process");
- }
- /* Reinitialize the GC condition variable: */
- else if (_cond_reinit(&_gc_cond) != 0) {
- /* Abort this application: */
- PANIC("Cannot initialize GC condvar for forked process");
- }
- /* Initialize the ready queue: */
- else if (_pq_init(&_readyq) != 0) {
- /* Abort this application: */
- PANIC("Cannot initialize priority ready queue.");
- } else {
- /*
- * Enter a loop to remove all threads other than
- * the running thread from the thread list:
- */
- pthread = TAILQ_FIRST(&_thread_list);
- while (pthread != NULL) {
- /* Save the thread to be freed: */
- pthread_save = pthread;
-
- /*
- * Advance to the next thread before
- * destroying the current thread:
- */
- pthread = TAILQ_NEXT(pthread, dle);
-
- /* Make sure this isn't the running thread: */
- if (pthread_save != _thread_run) {
- /* Remove this thread from the list: */
- TAILQ_REMOVE(&_thread_list,
- pthread_save, tle);
-
- if (pthread_save->attr.stackaddr_attr ==
- NULL && pthread_save->stack != NULL) {
- if (pthread_save->attr.stacksize_attr
- == PTHREAD_STACK_DEFAULT) {
- /*
- * Default-size stack.
- * Cache it:
- */
- struct stack *spare_stack;
-
- spare_stack
- = (pthread_save->stack
- + PTHREAD_STACK_DEFAULT
- - sizeof(struct stack));
- SLIST_INSERT_HEAD(&_stackq,
- spare_stack, qe);
- } else
- /*
- * Free the stack of
- * the dead thread:
- */
- free(pthread_save->stack);
- }
-
- if (pthread_save->specific_data != NULL)
- free(pthread_save->specific_data);
-
- if (pthread_save->poll_data.fds != NULL)
- free(pthread_save->poll_data.fds);
-
- free(pthread_save);
- }
- }
-
- /* Treat the current thread as the initial thread: */
- _thread_initial = _thread_run;
-
- /* Re-init the dead thread list: */
- TAILQ_INIT(&_dead_list);
-
- /* Re-init the waiting and work queues. */
- TAILQ_INIT(&_waitingq);
- TAILQ_INIT(&_workq);
-
- /* Re-init the threads mutex queue: */
- TAILQ_INIT(&_thread_run->mutexq);
-
- /* No spinlocks yet: */
- _spinblock_count = 0;
-
- /* Don't queue signals yet: */
- _queue_signals = 0;
-
- /* Initialize signal handling: */
- _thread_sig_init();
-
- /* Initialize the scheduling switch hook routine: */
- _sched_switch_hook = NULL;
-
- /* Clear out any locks in the file descriptor table: */
- for (i = 0; i < _thread_dtablesize; i++) {
- if (_thread_fd_table[i] != NULL) {
- /* Initialise the file locks: */
- memset(&_thread_fd_table[i]->lock, 0,
- sizeof(_thread_fd_table[i]->lock));
- _thread_fd_table[i]->r_owner = NULL;
- _thread_fd_table[i]->w_owner = NULL;
- _thread_fd_table[i]->r_fname = NULL;
- _thread_fd_table[i]->w_fname = NULL;
- _thread_fd_table[i]->r_lineno = 0;;
- _thread_fd_table[i]->w_lineno = 0;;
- _thread_fd_table[i]->r_lockcount = 0;;
- _thread_fd_table[i]->w_lockcount = 0;;
-
- /* Initialise the read/write queues: */
- TAILQ_INIT(&_thread_fd_table[i]->r_queue);
- TAILQ_INIT(&_thread_fd_table[i]->w_queue);
- }
- }
- }
- }
-
- /*
- * Undefer and handle pending signals, yielding if necessary:
- */
- _thread_kern_sig_undefer();
-
- /* Return the process ID: */
- return (ret);
-}
-
-__strong_reference(_fork, fork);
-#endif
diff --git a/lib/libpthread/thread/thr_fsync.c b/lib/libpthread/thread/thr_fsync.c
deleted file mode 100644
index 0d8832077238..000000000000
--- a/lib/libpthread/thread/thr_fsync.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <unistd.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-_fsync(int fd)
-{
- int ret;
-
- if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) {
- ret = _thread_sys_fsync(fd);
- _FD_UNLOCK(fd, FD_RDWR);
- }
- return (ret);
-}
-
-int
-fsync(int fd)
-{
- int ret;
-
- _thread_enter_cancellation_point();
- ret = _fsync(fd);
- _thread_leave_cancellation_point();
-
- return ret;
-}
-#endif
diff --git a/lib/libpthread/thread/thr_gc.c b/lib/libpthread/thread/thr_gc.c
deleted file mode 100644
index a6ffd4ba58d7..000000000000
--- a/lib/libpthread/thread/thr_gc.c
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * Copyright (c) 1998 John Birrell <jb@cimlogic.com.au>
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- *
- * Garbage collector thread. Frees memory allocated for dead threads.
- *
- */
-#include <errno.h>
-#include <time.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <pthread.h>
-#include "pthread_private.h"
-
-pthread_addr_t
-_thread_gc(pthread_addr_t arg)
-{
- int f_debug;
- int f_done = 0;
- int ret;
- sigset_t mask;
- pthread_t pthread;
- pthread_t pthread_cln;
- struct timespec abstime;
- void *p_stack;
-
- /* Block all signals */
- sigfillset (&mask);
- sigprocmask (SIG_BLOCK, &mask, NULL);
-
- /* Mark this thread as a library thread (not a user thread). */
- _thread_run->flags |= PTHREAD_FLAGS_PRIVATE;
-
- /* Set a debug flag based on an environment variable. */
- f_debug = (getenv("LIBC_R_DEBUG") != NULL);
-
- /* Set the name of this thread. */
- pthread_set_name_np(_thread_run,"GC");
-
- while (!f_done) {
- /* Check if debugging this application. */
- if (f_debug)
- /* Dump thread info to file. */
- _thread_dump_info();
-
- /*
- * Defer signals to protect the scheduling queues from
- * access by the signal handler:
- */
- _thread_kern_sig_defer();
-
- /* Check if this is the last running thread: */
- if (TAILQ_FIRST(&_thread_list) == _thread_run &&
- TAILQ_NEXT(_thread_run, tle) == NULL)
- /*
- * This is the last thread, so it can exit
- * now.
- */
- f_done = 1;
-
- /*
- * Undefer and handle pending signals, yielding if
- * necessary:
- */
- _thread_kern_sig_undefer();
-
- /*
- * Lock the garbage collector mutex which ensures that
- * this thread sees another thread exit:
- */
- if (pthread_mutex_lock(&_gc_mutex) != 0)
- PANIC("Cannot lock gc mutex");
-
- /* No stack of thread structure to free yet: */
- p_stack = NULL;
- pthread_cln = NULL;
-
- /*
- * Enter a loop to search for the first dead thread that
- * has memory to free.
- */
- for (pthread = TAILQ_FIRST(&_dead_list);
- p_stack == NULL && pthread_cln == NULL && pthread != NULL;
- pthread = TAILQ_NEXT(pthread, dle)) {
- /* Check if the initial thread: */
- if (pthread == _thread_initial) {
- /* Don't destroy the initial thread. */
- }
- /*
- * Check if this thread has detached:
- */
- else if ((pthread->attr.flags &
- PTHREAD_DETACHED) != 0) {
- /* Remove this thread from the dead list: */
- TAILQ_REMOVE(&_dead_list, pthread, dle);
-
- /*
- * Check if the stack was not specified by
- * the caller to pthread_create and has not
- * been destroyed yet:
- */
- if (pthread->attr.stackaddr_attr == NULL &&
- pthread->stack != NULL) {
- if (pthread->attr.stacksize_attr
- == PTHREAD_STACK_DEFAULT) {
- /*
- * Default-size stack. Cache
- * it:
- */
- struct stack *spare_stack;
-
- spare_stack
- = (pthread->stack
- + PTHREAD_STACK_DEFAULT
- - sizeof(struct stack));
- SLIST_INSERT_HEAD(&_stackq,
- spare_stack,
- qe);
- } else {
- /*
- * Non-standard stack size.
- * free() it outside the locks.
- */
- p_stack = pthread->stack;
- }
- }
-
- /*
- * Point to the thread structure that must
- * be freed outside the locks:
- */
- pthread_cln = pthread;
-
- } else {
- /*
- * This thread has not detached, so do
- * not destroy it.
- *
- * Check if the stack was not specified by
- * the caller to pthread_create and has not
- * been destroyed yet:
- */
- if (pthread->attr.stackaddr_attr == NULL &&
- pthread->stack != NULL) {
- if (pthread->attr.stacksize_attr
- == PTHREAD_STACK_DEFAULT) {
- /*
- * Default-size stack. Cache
- * it:
- */
- struct stack *spare_stack;
-
- spare_stack
- = (pthread->stack
- + PTHREAD_STACK_DEFAULT
- - sizeof(struct stack));
- SLIST_INSERT_HEAD(&_stackq,
- spare_stack,
- qe);
- } else {
- /*
- * Non-standard stack size.
- * free() it outside the locks:
- */
- p_stack = pthread->stack;
- }
-
- /*
- * NULL the stack pointer now
- * that the memory has been freed:
- */
- pthread->stack = NULL;
- }
- }
- }
-
- /*
- * Check if this is not the last thread and there is no
- * memory to free this time around.
- */
- if (!f_done && p_stack == NULL && pthread_cln == NULL) {
- /* Get the current time. */
- if (clock_gettime(CLOCK_REALTIME,&abstime) != 0)
- PANIC("gc cannot get time");
-
- /*
- * Do a backup poll in 10 seconds if no threads
- * die before then.
- */
- abstime.tv_sec += 10;
-
- /*
- * Wait for a signal from a dying thread or a
- * timeout (for a backup poll).
- */
- if ((ret = pthread_cond_timedwait(&_gc_cond,
- &_gc_mutex, &abstime)) != 0 && ret != ETIMEDOUT)
- PANIC("gc cannot wait for a signal");
- }
-
- /* Unlock the garbage collector mutex: */
- if (pthread_mutex_unlock(&_gc_mutex) != 0)
- PANIC("Cannot unlock gc mutex");
-
- /*
- * If there is memory to free, do it now. The call to
- * free() might block, so this must be done outside the
- * locks.
- */
- if (p_stack != NULL)
- free(p_stack);
- if (pthread_cln != NULL)
- /*
- * Free the memory allocated for the thread
- * structure.
- */
- free(pthread_cln);
- }
- return (NULL);
-}
diff --git a/lib/libpthread/thread/thr_getprio.c b/lib/libpthread/thread/thr_getprio.c
deleted file mode 100644
index 2f94b86b64af..000000000000
--- a/lib/libpthread/thread/thr_getprio.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_getprio(pthread_t pthread)
-{
- int policy, ret;
- struct sched_param param;
-
- if ((ret = pthread_getschedparam(pthread, &policy, &param)) == 0)
- ret = param.sched_priority;
- else {
- /* Invalid thread: */
- errno = ret;
- ret = -1;
- }
-
- /* Return the thread priority or an error status: */
- return (ret);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_getschedparam.c b/lib/libpthread/thread/thr_getschedparam.c
deleted file mode 100644
index 09d8c1bc3283..000000000000
--- a/lib/libpthread/thread/thr_getschedparam.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>.
- * 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 Daniel Eischen.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_getschedparam(pthread_t pthread, int *policy,
- struct sched_param *param)
-{
- int ret;
-
- if ((param == NULL) || (policy == NULL))
- /* Return an invalid argument error: */
- ret = EINVAL;
-
- /* Find the thread in the list of active threads: */
- else if ((ret = _find_thread(pthread)) == 0) {
- /* Return the threads base priority and scheduling policy: */
- param->sched_priority = pthread->base_priority;
- *policy = pthread->attr.sched_policy;
- }
-
- return(ret);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_info.c b/lib/libpthread/thread/thr_info.c
deleted file mode 100644
index 06b556e69b18..000000000000
--- a/lib/libpthread/thread/thr_info.c
+++ /dev/null
@@ -1,311 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <stdio.h>
-#include <fcntl.h>
-#include <string.h>
-#include <unistd.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include <errno.h>
-#include "pthread_private.h"
-
-struct s_thread_info {
- enum pthread_state state;
- char *name;
-};
-
-/* Static variables: */
-static const struct s_thread_info thread_info[] = {
- {PS_RUNNING , "Running"},
- {PS_SIGTHREAD , "Waiting on signal thread"},
- {PS_MUTEX_WAIT , "Waiting on a mutex"},
- {PS_COND_WAIT , "Waiting on a condition variable"},
- {PS_FDLR_WAIT , "Waiting for a file read lock"},
- {PS_FDLW_WAIT , "Waiting for a file write lock"},
- {PS_FDR_WAIT , "Waiting for read"},
- {PS_FDW_WAIT , "Waiting for write"},
- {PS_FILE_WAIT , "Waiting for FILE lock"},
- {PS_POLL_WAIT , "Waiting on poll"},
- {PS_SELECT_WAIT , "Waiting on select"},
- {PS_SLEEP_WAIT , "Sleeping"},
- {PS_WAIT_WAIT , "Waiting process"},
- {PS_SIGSUSPEND , "Suspended, waiting for a signal"},
- {PS_SIGWAIT , "Waiting for a signal"},
- {PS_SPINBLOCK , "Waiting for a spinlock"},
- {PS_JOIN , "Waiting to join"},
- {PS_SUSPENDED , "Suspended"},
- {PS_DEAD , "Dead"},
- {PS_DEADLOCK , "Deadlocked"},
- {PS_STATE_MAX , "Not a real state!"}
-};
-
-void
-_thread_dump_info(void)
-{
- char s[512];
- int fd;
- int i;
- int j;
- pthread_t pthread;
- char tmpfile[128];
- pq_list_t *pq_list;
-
- for (i = 0; i < 100000; i++) {
- snprintf(tmpfile, sizeof(tmpfile), "/tmp/uthread.dump.%u.%i",
- getpid(), i);
- /* Open the dump file for append and create it if necessary: */
- if ((fd = _thread_sys_open(tmpfile, O_RDWR | O_CREAT | O_EXCL,
- 0666)) < 0) {
- /* Can't open the dump file. */
- if (errno == EEXIST)
- continue;
- /*
- * We only need to continue in case of
- * EEXIT error. Most other error
- * codes means that we will fail all
- * the times.
- */
- return;
- } else {
- break;
- }
- }
- if (i==100000) {
- /* all 100000 possibilities are in use :( */
- return;
- } else {
- /* Output a header for active threads: */
- strcpy(s, "\n\n=============\nACTIVE THREADS\n\n");
- _thread_sys_write(fd, s, strlen(s));
-
- /* Enter a loop to report each thread in the global list: */
- TAILQ_FOREACH(pthread, &_thread_list, tle) {
- /* Find the state: */
- for (j = 0; j < (sizeof(thread_info) /
- sizeof(struct s_thread_info)) - 1; j++)
- if (thread_info[j].state == pthread->state)
- break;
- /* Output a record for the current thread: */
- snprintf(s, sizeof(s),
- "--------------------\nThread %p (%s) prio %3d state %s [%s:%d]\n",
- pthread, (pthread->name == NULL) ?
- "":pthread->name, pthread->base_priority,
- thread_info[j].name,
- pthread->fname,pthread->lineno);
- _thread_sys_write(fd, s, strlen(s));
-
- /* Check if this is the running thread: */
- if (pthread == _thread_run) {
- /* Output a record for the running thread: */
- strcpy(s, "This is the running thread\n");
- _thread_sys_write(fd, s, strlen(s));
- }
- /* Check if this is the initial thread: */
- if (pthread == _thread_initial) {
- /* Output a record for the initial thread: */
- strcpy(s, "This is the initial thread\n");
- _thread_sys_write(fd, s, strlen(s));
- }
- /* Process according to thread state: */
- switch (pthread->state) {
- /* File descriptor read lock wait: */
- case PS_FDLR_WAIT:
- case PS_FDLW_WAIT:
- case PS_FDR_WAIT:
- case PS_FDW_WAIT:
- /* Write the lock details: */
- snprintf(s, sizeof(s), "fd %d[%s:%d]",
- pthread->data.fd.fd,
- pthread->data.fd.fname,
- pthread->data.fd.branch);
- _thread_sys_write(fd, s, strlen(s));
- snprintf(s, sizeof(s), "owner %pr/%pw\n",
- _thread_fd_table[pthread->data.fd.fd]->r_owner,
- _thread_fd_table[pthread->data.fd.fd]->w_owner);
- _thread_sys_write(fd, s, strlen(s));
- break;
- case PS_SIGWAIT:
- snprintf(s, sizeof(s), "sigmask (hi)");
- _thread_sys_write(fd, s, strlen(s));
- for (i = _SIG_WORDS - 1; i >= 0; i--) {
- snprintf(s, sizeof(s), "%08x\n",
- pthread->sigmask.__bits[i]);
- _thread_sys_write(fd, s, strlen(s));
- }
- snprintf(s, sizeof(s), "(lo)\n");
- _thread_sys_write(fd, s, strlen(s));
- break;
-
- /*
- * Trap other states that are not explicitly
- * coded to dump information:
- */
- default:
- /* Nothing to do here. */
- break;
- }
- }
-
- /* Output a header for ready threads: */
- strcpy(s, "\n\n=============\nREADY THREADS\n\n");
- _thread_sys_write(fd, s, strlen(s));
-
- /* Enter a loop to report each thread in the ready queue: */
- TAILQ_FOREACH (pq_list, &_readyq.pq_queue, pl_link) {
- TAILQ_FOREACH(pthread, &pq_list->pl_head, pqe) {
- /* Find the state: */
- for (j = 0; j < (sizeof(thread_info) /
- sizeof(struct s_thread_info)) - 1; j++)
- if (thread_info[j].state == pthread->state)
- break;
- /* Output a record for the current thread: */
- snprintf(s, sizeof(s),
- "--------------------\nThread %p (%s) prio %3d state %s [%s:%d]\n",
- pthread, (pthread->name == NULL) ?
- "":pthread->name, pthread->base_priority,
- thread_info[j].name,
- pthread->fname,pthread->lineno);
- _thread_sys_write(fd, s, strlen(s));
- }
- }
-
- /* Output a header for waiting threads: */
- strcpy(s, "\n\n=============\nWAITING THREADS\n\n");
- _thread_sys_write(fd, s, strlen(s));
-
- /* Enter a loop to report each thread in the waiting queue: */
- TAILQ_FOREACH (pthread, &_waitingq, pqe) {
- /* Find the state: */
- for (j = 0; j < (sizeof(thread_info) /
- sizeof(struct s_thread_info)) - 1; j++)
- if (thread_info[j].state == pthread->state)
- break;
- /* Output a record for the current thread: */
- snprintf(s, sizeof(s),
- "--------------------\nThread %p (%s) prio %3d state %s [%s:%d]\n",
- pthread, (pthread->name == NULL) ?
- "":pthread->name, pthread->base_priority,
- thread_info[j].name,
- pthread->fname,pthread->lineno);
- _thread_sys_write(fd, s, strlen(s));
- }
-
- /* Output a header for threads in the work queue: */
- strcpy(s, "\n\n=============\nTHREADS IN WORKQ\n\n");
- _thread_sys_write(fd, s, strlen(s));
-
- /* Enter a loop to report each thread in the waiting queue: */
- TAILQ_FOREACH (pthread, &_workq, qe) {
- /* Find the state: */
- for (j = 0; j < (sizeof(thread_info) /
- sizeof(struct s_thread_info)) - 1; j++)
- if (thread_info[j].state == pthread->state)
- break;
- /* Output a record for the current thread: */
- snprintf(s, sizeof(s),
- "--------------------\nThread %p (%s) prio %3d state %s [%s:%d]\n",
- pthread, (pthread->name == NULL) ?
- "":pthread->name, pthread->base_priority,
- thread_info[j].name,
- pthread->fname,pthread->lineno);
- _thread_sys_write(fd, s, strlen(s));
- }
-
- /* Check if there are no dead threads: */
- if (TAILQ_FIRST(&_dead_list) == NULL) {
- /* Output a record: */
- strcpy(s, "\n\nTHERE ARE NO DEAD THREADS\n");
- _thread_sys_write(fd, s, strlen(s));
- } else {
- /* Output a header for dead threads: */
- strcpy(s, "\n\nDEAD THREADS\n\n");
- _thread_sys_write(fd, s, strlen(s));
-
- /*
- * Enter a loop to report each thread in the global
- * dead thread list:
- */
- TAILQ_FOREACH(pthread, &_dead_list, dle) {
- /* Output a record for the current thread: */
- snprintf(s, sizeof(s),
- "Thread %p prio %3d [%s:%d]\n",
- pthread, pthread->base_priority,
- pthread->fname,pthread->lineno);
- _thread_sys_write(fd, s, strlen(s));
- }
- }
-
- /* Output a header for file descriptors: */
- snprintf(s, sizeof(s), "\n\n=============\nFILE DESCRIPTOR TABLE (table size %d)\n\n",_thread_dtablesize);
- _thread_sys_write(fd, s, strlen(s));
-
- /* Enter a loop to report file descriptor lock usage: */
- for (i = 0; i < _thread_dtablesize; i++) {
- /*
- * Check if memory is allocated for this file
- * descriptor:
- */
- if (_thread_fd_table[i] != NULL) {
- /* Report the file descriptor lock status: */
- snprintf(s, sizeof(s),
- "fd[%3d] read owner %p count %d [%s:%d]\n write owner %p count %d [%s:%d]\n",
- i,
- _thread_fd_table[i]->r_owner,
- _thread_fd_table[i]->r_lockcount,
- _thread_fd_table[i]->r_fname,
- _thread_fd_table[i]->r_lineno,
- _thread_fd_table[i]->w_owner,
- _thread_fd_table[i]->w_lockcount,
- _thread_fd_table[i]->w_fname,
- _thread_fd_table[i]->w_lineno);
- _thread_sys_write(fd, s, strlen(s));
- }
- }
-
- /* Close the dump file: */
- _thread_sys_close(fd);
- }
- return;
-}
-
-/* Set the thread name for debug: */
-void
-pthread_set_name_np(pthread_t thread, char *name)
-{
- /* Check if the caller has specified a valid thread: */
- if (thread != NULL && thread->magic == PTHREAD_MAGIC)
- thread->name = strdup(name);
- return;
-}
-#endif
diff --git a/lib/libpthread/thread/thr_init.c b/lib/libpthread/thread/thr_init.c
deleted file mode 100644
index dd5f53fac64e..000000000000
--- a/lib/libpthread/thread/thr_init.c
+++ /dev/null
@@ -1,390 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-/* Allocate space for global thread variables here: */
-#define GLOBAL_PTHREAD_PRIVATE
-
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <fcntl.h>
-#include <paths.h>
-#include <poll.h>
-#include <unistd.h>
-#include <sys/ioctl.h>
-#include <sys/sysctl.h>
-#include <sys/time.h>
-#include <sys/ttycom.h>
-#include <sys/param.h>
-#include <sys/user.h>
-#include <sys/mman.h>
-#ifdef _THREAD_SAFE
-#include <machine/reg.h>
-#include <pthread.h>
-#include "pthread_private.h"
-
-#ifdef GCC_2_8_MADE_THREAD_AWARE
-typedef void *** (*dynamic_handler_allocator)();
-extern void __set_dynamic_handler_allocator(dynamic_handler_allocator);
-
-static pthread_key_t except_head_key;
-
-typedef struct {
- void **__dynamic_handler_chain;
- void *top_elt[2];
-} except_struct;
-
-static void ***dynamic_allocator_handler_fn()
-{
- except_struct *dh = (except_struct *)pthread_getspecific(except_head_key);
-
- if(dh == NULL) {
- dh = (except_struct *)malloc( sizeof(except_struct) );
- memset(dh, '\0', sizeof(except_struct));
- dh->__dynamic_handler_chain= dh->top_elt;
- pthread_setspecific(except_head_key, (void *)dh);
- }
- return &dh->__dynamic_handler_chain;
-}
-#endif /* GCC_2_8_MADE_THREAD_AWARE */
-
-/*
- * Threaded process initialization
- */
-void
-_thread_init(void)
-{
- int fd;
- int flags;
- int i;
- size_t len;
- int mib[2];
- struct timeval tv;
- struct clockinfo clockinfo;
- struct sigaction act;
-
- /* Check if this function has already been called: */
- if (_thread_initial)
- /* Only initialise the threaded application once. */
- return;
-
- /*
- * Check for the special case of this process running as
- * or in place of init as pid = 1:
- */
- if (getpid() == 1) {
- /*
- * Setup a new session for this process which is
- * assumed to be running as root.
- */
- if (setsid() == -1)
- PANIC("Can't set session ID");
- if (revoke(_PATH_CONSOLE) != 0)
- PANIC("Can't revoke console");
- if ((fd = _thread_sys_open(_PATH_CONSOLE, O_RDWR)) < 0)
- PANIC("Can't open console");
- if (setlogin("root") == -1)
- PANIC("Can't set login to root");
- if (_thread_sys_ioctl(fd,TIOCSCTTY, (char *) NULL) == -1)
- PANIC("Can't set controlling terminal");
- if (_thread_sys_dup2(fd,0) == -1 ||
- _thread_sys_dup2(fd,1) == -1 ||
- _thread_sys_dup2(fd,2) == -1)
- PANIC("Can't dup2");
- }
-
- /* Get the standard I/O flags before messing with them : */
- for (i = 0; i < 3; i++)
- if (((_pthread_stdio_flags[i] =
- _thread_sys_fcntl(i,F_GETFL, NULL)) == -1) &&
- (errno != EBADF))
- PANIC("Cannot get stdio flags");
-
- /*
- * Create a pipe that is written to by the signal handler to prevent
- * signals being missed in calls to _select:
- */
- if (_thread_sys_pipe(_thread_kern_pipe) != 0) {
- /* Cannot create pipe, so abort: */
- PANIC("Cannot create kernel pipe");
- }
- /* Get the flags for the read pipe: */
- else if ((flags = _thread_sys_fcntl(_thread_kern_pipe[0], F_GETFL, NULL)) == -1) {
- /* Abort this application: */
- PANIC("Cannot get kernel read pipe flags");
- }
- /* Make the read pipe non-blocking: */
- else if (_thread_sys_fcntl(_thread_kern_pipe[0], F_SETFL, flags | O_NONBLOCK) == -1) {
- /* Abort this application: */
- PANIC("Cannot make kernel read pipe non-blocking");
- }
- /* Get the flags for the write pipe: */
- else if ((flags = _thread_sys_fcntl(_thread_kern_pipe[1], F_GETFL, NULL)) == -1) {
- /* Abort this application: */
- PANIC("Cannot get kernel write pipe flags");
- }
- /* Make the write pipe non-blocking: */
- else if (_thread_sys_fcntl(_thread_kern_pipe[1], F_SETFL, flags | O_NONBLOCK) == -1) {
- /* Abort this application: */
- PANIC("Cannot get kernel write pipe flags");
- }
- /* Allocate and initialize the ready queue: */
- else if (_pq_alloc(&_readyq, PTHREAD_MIN_PRIORITY, PTHREAD_MAX_PRIORITY) != 0) {
- /* Abort this application: */
- PANIC("Cannot allocate priority ready queue.");
- }
- /* Allocate memory for the thread structure of the initial thread: */
- else if ((_thread_initial = (pthread_t) malloc(sizeof(struct pthread))) == NULL) {
- /*
- * Insufficient memory to initialise this application, so
- * abort:
- */
- PANIC("Cannot allocate memory for initial thread");
- } else {
- /* Zero the global kernel thread structure: */
- memset(&_thread_kern_thread, 0, sizeof(struct pthread));
- _thread_kern_thread.flags = PTHREAD_FLAGS_PRIVATE;
- memset(_thread_initial, 0, sizeof(struct pthread));
-
- /* Initialize the waiting and work queues: */
- TAILQ_INIT(&_waitingq);
- TAILQ_INIT(&_workq);
-
- /* Initialize the scheduling switch hook routine: */
- _sched_switch_hook = NULL;
-
- /* Give this thread default attributes: */
- memcpy((void *) &_thread_initial->attr, &pthread_attr_default,
- sizeof(struct pthread_attr));
-
- /* Initialize the thread stack cache: */
- SLIST_INIT(&_stackq);
-
- /*
- * Create a red zone below the main stack. All other stacks are
- * constrained to a maximum size by the paramters passed to
- * mmap(), but this stack is only limited by resource limits, so
- * this stack needs an explicitly mapped red zone to protect the
- * thread stack that is just beyond.
- */
- if (mmap((void *) USRSTACK - PTHREAD_STACK_INITIAL -
- PTHREAD_STACK_GUARD, PTHREAD_STACK_GUARD, 0, MAP_ANON,
- -1, 0) == MAP_FAILED)
- PANIC("Cannot allocate red zone for initial thread");
-
- /* Set the main thread stack pointer. */
- _thread_initial->stack = (void *) USRSTACK -
- PTHREAD_STACK_INITIAL;
-
- /* Set the stack attributes: */
- _thread_initial->attr.stackaddr_attr = _thread_initial->stack;
- _thread_initial->attr.stacksize_attr = PTHREAD_STACK_INITIAL;
-
- /*
- * Write a magic value to the thread structure
- * to help identify valid ones:
- */
- _thread_initial->magic = PTHREAD_MAGIC;
-
- /* Set the initial cancel state */
- _thread_initial->cancelflags = PTHREAD_CANCEL_ENABLE |
- PTHREAD_CANCEL_DEFERRED;
-
- /* Default the priority of the initial thread: */
- _thread_initial->base_priority = PTHREAD_DEFAULT_PRIORITY;
- _thread_initial->active_priority = PTHREAD_DEFAULT_PRIORITY;
- _thread_initial->inherited_priority = 0;
-
- /* Initialise the state of the initial thread: */
- _thread_initial->state = PS_RUNNING;
-
- /* Initialise the queue: */
- TAILQ_INIT(&(_thread_initial->join_queue));
-
- /* Initialize the owned mutex queue and count: */
- TAILQ_INIT(&(_thread_initial->mutexq));
- _thread_initial->priority_mutex_count = 0;
-
- /* Initialize last active time to now: */
- gettimeofday(&tv, NULL);
- _thread_initial->last_active.tv_sec = tv.tv_sec;
- _thread_initial->last_active.tv_usec = tv.tv_usec;
-
- /* Initialise the rest of the fields: */
- _thread_initial->poll_data.nfds = 0;
- _thread_initial->poll_data.fds = NULL;
- _thread_initial->sig_defer_count = 0;
- _thread_initial->yield_on_sig_undefer = 0;
- _thread_initial->specific_data = NULL;
- _thread_initial->cleanup = NULL;
- _thread_initial->flags = 0;
- _thread_initial->error = 0;
- TAILQ_INIT(&_thread_list);
- TAILQ_INSERT_HEAD(&_thread_list, _thread_initial, tle);
- _thread_run = _thread_initial;
-
- /* Initialise the global signal action structure: */
- sigfillset(&act.sa_mask);
- act.sa_handler = (void (*) ()) _thread_sig_handler;
- act.sa_flags = 0;
-
- /* Initialize signal handling: */
- _thread_sig_init();
-
- /* Enter a loop to get the existing signal status: */
- for (i = 1; i < NSIG; i++) {
- /* Check for signals which cannot be trapped: */
- if (i == SIGKILL || i == SIGSTOP) {
- }
-
- /* Get the signal handler details: */
- else if (_thread_sys_sigaction(i, NULL,
- &_thread_sigact[i - 1]) != 0) {
- /*
- * Abort this process if signal
- * initialisation fails:
- */
- PANIC("Cannot read signal handler info");
- }
- }
-
- /*
- * Install the signal handler for the most important
- * signals that the user-thread kernel needs. Actually
- * SIGINFO isn't really needed, but it is nice to have.
- */
- if (_thread_sys_sigaction(_SCHED_SIGNAL, &act, NULL) != 0 ||
- _thread_sys_sigaction(SIGINFO, &act, NULL) != 0 ||
- _thread_sys_sigaction(SIGCHLD, &act, NULL) != 0) {
- /*
- * Abort this process if signal initialisation fails:
- */
- PANIC("Cannot initialise signal handler");
- }
-
- /* Get the kernel clockrate: */
- mib[0] = CTL_KERN;
- mib[1] = KERN_CLOCKRATE;
- len = sizeof (struct clockinfo);
- if (sysctl(mib, 2, &clockinfo, &len, NULL, 0) == 0)
- _clock_res_nsec = clockinfo.tick * 1000;
-
- /* Get the table size: */
- if ((_thread_dtablesize = getdtablesize()) < 0) {
- /*
- * Cannot get the system defined table size, so abort
- * this process.
- */
- PANIC("Cannot get dtablesize");
- }
- /* Allocate memory for the file descriptor table: */
- if ((_thread_fd_table = (struct fd_table_entry **) malloc(sizeof(struct fd_table_entry *) * _thread_dtablesize)) == NULL) {
- /* Avoid accesses to file descriptor table on exit: */
- _thread_dtablesize = 0;
-
- /*
- * Cannot allocate memory for the file descriptor
- * table, so abort this process.
- */
- PANIC("Cannot allocate memory for file descriptor table");
- }
- /* Allocate memory for the pollfd table: */
- if ((_thread_pfd_table = (struct pollfd *) malloc(sizeof(struct pollfd) * _thread_dtablesize)) == NULL) {
- /*
- * Cannot allocate memory for the file descriptor
- * table, so abort this process.
- */
- PANIC("Cannot allocate memory for pollfd table");
- } else {
- /*
- * Enter a loop to initialise the file descriptor
- * table:
- */
- for (i = 0; i < _thread_dtablesize; i++) {
- /* Initialise the file descriptor table: */
- _thread_fd_table[i] = NULL;
- }
-
- /* Initialize stdio file descriptor table entries: */
- for (i = 0; i < 3; i++) {
- if ((_thread_fd_table_init(i) != 0) &&
- (errno != EBADF))
- PANIC("Cannot initialize stdio file "
- "descriptor table entry");
- }
- }
- }
-
-#ifdef GCC_2_8_MADE_THREAD_AWARE
- /* Create the thread-specific data for the exception linked list. */
- if(pthread_key_create(&except_head_key, NULL) != 0)
- PANIC("Failed to create thread specific execption head");
-
- /* Setup the gcc exception handler per thread. */
- __set_dynamic_handler_allocator( dynamic_allocator_handler_fn );
-#endif /* GCC_2_8_MADE_THREAD_AWARE */
-
- /* Initialise the garbage collector mutex and condition variable. */
- if (pthread_mutex_init(&_gc_mutex,NULL) != 0 ||
- pthread_cond_init(&_gc_cond,NULL) != 0)
- PANIC("Failed to initialise garbage collector mutex or condvar");
-
- gettimeofday(&kern_inc_prio_time, NULL);
-
- return;
-}
-
-/*
- * Special start up code for NetBSD/Alpha
- */
-#if defined(__NetBSD__) && defined(__alpha__)
-int
-main(int argc, char *argv[], char *env);
-
-int
-_thread_main(int argc, char *argv[], char *env)
-{
- _thread_init();
- return (main(argc, argv, env));
-}
-#endif
-#else
-/*
- * A stub for non-threaded programs.
- */
-void
-_thread_init(void)
-{
-}
-#endif
diff --git a/lib/libpthread/thread/thr_join.c b/lib/libpthread/thread/thr_join.c
deleted file mode 100644
index 1cffc96eaea3..000000000000
--- a/lib/libpthread/thread/thr_join.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_join(pthread_t pthread, void **thread_return)
-{
- int ret = 0;
- pthread_t pthread1 = NULL;
-
- _thread_enter_cancellation_point();
-
- /* Check if the caller has specified an invalid thread: */
- if (pthread == NULL || pthread->magic != PTHREAD_MAGIC) {
- /* Invalid thread: */
- _thread_leave_cancellation_point();
- return(EINVAL);
- }
-
- /* Check if the caller has specified itself: */
- if (pthread == _thread_run) {
- /* Avoid a deadlock condition: */
- _thread_leave_cancellation_point();
- return(EDEADLK);
- }
-
- /*
- * Find the thread in the list of active threads or in the
- * list of dead threads:
- */
- if (_find_thread(pthread) == 0 ||
- _find_dead_thread(pthread) == 0)
- pthread1 = pthread;
-
- if (pthread1 == NULL)
- /* Return an error: */
- ret = ESRCH;
-
- /* Check if this thread has been detached: */
- else if ((pthread->attr.flags & PTHREAD_DETACHED) != 0)
- /* Return an error: */
- ret = ESRCH;
-
- /* Check if the thread is not dead: */
- else if (pthread->state != PS_DEAD) {
- /* Clear the interrupted flag: */
- _thread_run->interrupted = 0;
-
- /*
- * Protect against being context switched out while
- * adding this thread to the join queue.
- */
- _thread_kern_sig_defer();
-
- /* Add the running thread to the join queue: */
- TAILQ_INSERT_TAIL(&(pthread->join_queue), _thread_run, qe);
-
- /* Schedule the next thread: */
- _thread_kern_sched_state(PS_JOIN, __FILE__, __LINE__);
-
- if (_thread_run->interrupted != 0)
- TAILQ_REMOVE(&(pthread->join_queue), _thread_run, qe);
-
- _thread_kern_sig_undefer();
-
- if (_thread_run->interrupted != 0 &&
- _thread_run->continuation != NULL)
- _thread_run->continuation(_thread_run);
-
- /* Check if the thread is not detached: */
- if ((pthread->attr.flags & PTHREAD_DETACHED) == 0) {
- /* Check if the return value is required: */
- if (thread_return)
- /* Return the thread's return value: */
- *thread_return = pthread->ret;
- }
- else
- /* Return an error: */
- ret = ESRCH;
-
- /* Check if the return value is required: */
- } else if (thread_return != NULL)
- /* Return the thread's return value: */
- *thread_return = pthread->ret;
-
- _thread_leave_cancellation_point();
-
- /* Return the completion status: */
- return (ret);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_kern.c b/lib/libpthread/thread/thr_kern.c
deleted file mode 100644
index 3e0ff17435db..000000000000
--- a/lib/libpthread/thread/thr_kern.c
+++ /dev/null
@@ -1,1173 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- *
- */
-#include <errno.h>
-#include <poll.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <unistd.h>
-#include <setjmp.h>
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/signalvar.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/socket.h>
-#include <sys/uio.h>
-#include <sys/syscall.h>
-#include <fcntl.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-/* Static function prototype definitions: */
-static void
-_thread_kern_poll(int wait_reqd);
-
-static void
-dequeue_signals(void);
-
-static inline void
-thread_run_switch_hook(pthread_t thread_out, pthread_t thread_in);
-
-void
-_thread_kern_sched(ucontext_t * scp)
-{
-#ifndef __alpha__
- char *fdata;
-#endif
- pthread_t pthread, pthread_h = NULL;
- struct itimerval itimer;
- struct timespec ts, ts1;
- struct timeval tv, tv1;
- int set_timer = 0;
-
- /*
- * Flag the pthread kernel as executing scheduler code
- * to avoid a scheduler signal from interrupting this
- * execution and calling the scheduler again.
- */
- _thread_kern_in_sched = 1;
-
- /* Check if this function was called from the signal handler: */
- if (scp != NULL) {
- /*
- * Copy the signal context to the current thread's jump
- * buffer:
- */
- memcpy(&_thread_run->saved_sigcontext, scp, sizeof(_thread_run->saved_sigcontext));
-
-#ifndef __alpha__
- /* Point to the floating point data in the running thread: */
- fdata = _thread_run->saved_fp;
-
- /* Save the floating point data: */
-__asm__("fnsave %0": :"m"(*fdata));
-#endif
-
- /* Flag the signal context as the last state saved: */
- _thread_run->sig_saved = 1;
- }
- /* Save the state of the current thread: */
- else if (setjmp(_thread_run->saved_jmp_buf) != 0) {
- /*
- * This point is reached when a longjmp() is called to
- * restore the state of a thread.
- *
- * This is the normal way out of the scheduler.
- */
- _thread_kern_in_sched = 0;
-
- if (((_thread_run->cancelflags & PTHREAD_AT_CANCEL_POINT) == 0) &&
- ((_thread_run->cancelflags & PTHREAD_CANCEL_ASYNCHRONOUS) != 0)) {
- /*
- * Cancellations override signals.
- *
- * Stick a cancellation point at the start of
- * each async-cancellable thread's resumption.
- *
- * We allow threads woken at cancel points to do their
- * own checks.
- */
- pthread_testcancel();
- }
-
- /*
- * Check for undispatched signals due to calls to
- * pthread_kill().
- */
- if (SIGNOTEMPTY(_thread_run->sigpend))
- _dispatch_signals();
-
- if (_sched_switch_hook != NULL) {
- /* Run the installed switch hook: */
- thread_run_switch_hook(_last_user_thread, _thread_run);
- }
-
- return;
- } else
- /* Flag the jump buffer was the last state saved: */
- _thread_run->sig_saved = 0;
-
- /* If the currently running thread is a user thread, save it: */
- if ((_thread_run->flags & PTHREAD_FLAGS_PRIVATE) == 0)
- _last_user_thread = _thread_run;
-
- /*
- * Enter a scheduling loop that finds the next thread that is
- * ready to run. This loop completes when there are no more threads
- * in the global list or when a thread has its state restored by
- * either a sigreturn (if the state was saved as a sigcontext) or a
- * longjmp (if the state was saved by a setjmp).
- */
- while (!(TAILQ_EMPTY(&_thread_list))) {
- /* Get the current time of day: */
- gettimeofday(&tv, NULL);
- TIMEVAL_TO_TIMESPEC(&tv, &ts);
-
- /*
- * Protect the scheduling queues from access by the signal
- * handler.
- */
- _queue_signals = 1;
-
- if (_thread_run != &_thread_kern_thread) {
-
- /*
- * This thread no longer needs to yield the CPU.
- */
- _thread_run->yield_on_sig_undefer = 0;
-
- /*
- * Save the current time as the time that the thread
- * became inactive:
- */
- _thread_run->last_inactive.tv_sec = tv.tv_sec;
- _thread_run->last_inactive.tv_usec = tv.tv_usec;
-
- /*
- * Place the currently running thread into the
- * appropriate queue(s).
- */
- switch (_thread_run->state) {
- case PS_DEAD:
- case PS_STATE_MAX: /* to silence -Wall */
- /*
- * Dead threads are not placed in any queue:
- */
- break;
-
- case PS_RUNNING:
- /*
- * Runnable threads can't be placed in the
- * priority queue until after waiting threads
- * are polled (to preserve round-robin
- * scheduling).
- */
- if ((_thread_run->slice_usec != -1) &&
- (_thread_run->attr.sched_policy != SCHED_FIFO)) {
- /*
- * Accumulate the number of microseconds that
- * this thread has run for:
- */
- _thread_run->slice_usec +=
- (_thread_run->last_inactive.tv_sec -
- _thread_run->last_active.tv_sec) * 1000000 +
- _thread_run->last_inactive.tv_usec -
- _thread_run->last_active.tv_usec;
-
- /* Check for time quantum exceeded: */
- if (_thread_run->slice_usec > TIMESLICE_USEC)
- _thread_run->slice_usec = -1;
- }
- break;
-
- /*
- * States which do not depend on file descriptor I/O
- * operations or timeouts:
- */
- case PS_DEADLOCK:
- case PS_FDLR_WAIT:
- case PS_FDLW_WAIT:
- case PS_FILE_WAIT:
- case PS_JOIN:
- case PS_MUTEX_WAIT:
- case PS_SIGSUSPEND:
- case PS_SIGTHREAD:
- case PS_SIGWAIT:
- case PS_SUSPENDED:
- case PS_WAIT_WAIT:
- /* No timeouts for these states: */
- _thread_run->wakeup_time.tv_sec = -1;
- _thread_run->wakeup_time.tv_nsec = -1;
-
- /* Restart the time slice: */
- _thread_run->slice_usec = -1;
-
- /* Insert into the waiting queue: */
- PTHREAD_WAITQ_INSERT(_thread_run);
- break;
-
- /* States which can timeout: */
- case PS_COND_WAIT:
- case PS_SLEEP_WAIT:
- /* Restart the time slice: */
- _thread_run->slice_usec = -1;
-
- /* Insert into the waiting queue: */
- PTHREAD_WAITQ_INSERT(_thread_run);
- break;
-
- /* States that require periodic work: */
- case PS_SPINBLOCK:
- /* No timeouts for this state: */
- _thread_run->wakeup_time.tv_sec = -1;
- _thread_run->wakeup_time.tv_nsec = -1;
-
- /* Increment spinblock count: */
- _spinblock_count++;
-
- /* fall through */
- case PS_FDR_WAIT:
- case PS_FDW_WAIT:
- case PS_POLL_WAIT:
- case PS_SELECT_WAIT:
- /* Restart the time slice: */
- _thread_run->slice_usec = -1;
-
- /* Insert into the waiting queue: */
- PTHREAD_WAITQ_INSERT(_thread_run);
-
- /* Insert into the work queue: */
- PTHREAD_WORKQ_INSERT(_thread_run);
- break;
- }
- }
-
- /* Unprotect the scheduling queues: */
- _queue_signals = 0;
-
- /*
- * Poll file descriptors to update the state of threads
- * waiting on file I/O where data may be available:
- */
- _thread_kern_poll(0);
-
- /* Protect the scheduling queues: */
- _queue_signals = 1;
-
- /*
- * Wake up threads that have timedout. This has to be
- * done after polling in case a thread does a poll or
- * select with zero time.
- */
- PTHREAD_WAITQ_SETACTIVE();
- while (((pthread = TAILQ_FIRST(&_waitingq)) != NULL) &&
- (pthread->wakeup_time.tv_sec != -1) &&
- (((pthread->wakeup_time.tv_sec == 0) &&
- (pthread->wakeup_time.tv_nsec == 0)) ||
- (pthread->wakeup_time.tv_sec < ts.tv_sec) ||
- ((pthread->wakeup_time.tv_sec == ts.tv_sec) &&
- (pthread->wakeup_time.tv_nsec <= ts.tv_nsec)))) {
- switch (pthread->state) {
- case PS_POLL_WAIT:
- case PS_SELECT_WAIT:
- /* Return zero file descriptors ready: */
- pthread->data.poll_data->nfds = 0;
- /* fall through */
- default:
- /*
- * Remove this thread from the waiting queue
- * (and work queue if necessary) and place it
- * in the ready queue.
- */
- PTHREAD_WAITQ_CLEARACTIVE();
- if (pthread->flags & PTHREAD_FLAGS_IN_WORKQ)
- PTHREAD_WORKQ_REMOVE(pthread);
- PTHREAD_NEW_STATE(pthread, PS_RUNNING);
- PTHREAD_WAITQ_SETACTIVE();
- break;
- }
- /*
- * Flag the timeout in the thread structure:
- */
- pthread->timeout = 1;
- }
- PTHREAD_WAITQ_CLEARACTIVE();
-
- /*
- * Check if there is a current runnable thread that isn't
- * already in the ready queue:
- */
- if ((_thread_run != &_thread_kern_thread) &&
- (_thread_run->state == PS_RUNNING) &&
- ((_thread_run->flags & PTHREAD_FLAGS_IN_PRIOQ) == 0)) {
- if (_thread_run->slice_usec == -1) {
- /*
- * The thread exceeded its time
- * quantum or it yielded the CPU;
- * place it at the tail of the
- * queue for its priority.
- */
- PTHREAD_PRIOQ_INSERT_TAIL(_thread_run);
- } else {
- /*
- * The thread hasn't exceeded its
- * interval. Place it at the head
- * of the queue for its priority.
- */
- PTHREAD_PRIOQ_INSERT_HEAD(_thread_run);
- }
- }
-
- /*
- * Get the highest priority thread in the ready queue.
- */
- pthread_h = PTHREAD_PRIOQ_FIRST();
-
- /* Check if there are no threads ready to run: */
- if (pthread_h == NULL) {
- /*
- * Lock the pthread kernel by changing the pointer to
- * the running thread to point to the global kernel
- * thread structure:
- */
- _thread_run = &_thread_kern_thread;
-
- /* Unprotect the scheduling queues: */
- _queue_signals = 0;
-
- /*
- * There are no threads ready to run, so wait until
- * something happens that changes this condition:
- */
- _thread_kern_poll(1);
- } else {
- /* Remove the thread from the ready queue: */
- PTHREAD_PRIOQ_REMOVE(pthread_h);
-
- /* Get first thread on the waiting list: */
- pthread = TAILQ_FIRST(&_waitingq);
-
- /* Check to see if there is more than one thread: */
- if (pthread_h != TAILQ_FIRST(&_thread_list) ||
- TAILQ_NEXT(pthread_h, tle) != NULL)
- set_timer = 1;
- else
- set_timer = 0;
-
- /* Unprotect the scheduling queues: */
- _queue_signals = 0;
-
- /*
- * Check for signals queued while the scheduling
- * queues were protected:
- */
- while (_sigq_check_reqd != 0) {
- /* Clear before handling queued signals: */
- _sigq_check_reqd = 0;
-
- /* Protect the scheduling queues again: */
- _queue_signals = 1;
-
- dequeue_signals();
-
- /*
- * Check for a higher priority thread that
- * became runnable due to signal handling.
- */
- if (((pthread = PTHREAD_PRIOQ_FIRST()) != NULL) &&
- (pthread->active_priority > pthread_h->active_priority)) {
- /*
- * Insert the lower priority thread
- * at the head of its priority list:
- */
- PTHREAD_PRIOQ_INSERT_HEAD(pthread_h);
-
- /* Remove the thread from the ready queue: */
- PTHREAD_PRIOQ_REMOVE(pthread);
-
- /* There's a new thread in town: */
- pthread_h = pthread;
- }
-
- /* Get first thread on the waiting list: */
- pthread = TAILQ_FIRST(&_waitingq);
-
- /*
- * Check to see if there is more than one
- * thread:
- */
- if (pthread_h != TAILQ_FIRST(&_thread_list) ||
- TAILQ_NEXT(pthread_h, tle) != NULL)
- set_timer = 1;
- else
- set_timer = 0;
-
- /* Unprotect the scheduling queues: */
- _queue_signals = 0;
- }
-
- /* Make the selected thread the current thread: */
- _thread_run = pthread_h;
-
- /*
- * Save the current time as the time that the thread
- * became active:
- */
- _thread_run->last_active.tv_sec = tv.tv_sec;
- _thread_run->last_active.tv_usec = tv.tv_usec;
-
- /*
- * Define the maximum time before a scheduling signal
- * is required:
- */
- itimer.it_value.tv_sec = 0;
- itimer.it_value.tv_usec = TIMESLICE_USEC;
-
- /*
- * The interval timer is not reloaded when it
- * times out. The interval time needs to be
- * calculated every time.
- */
- itimer.it_interval.tv_sec = 0;
- itimer.it_interval.tv_usec = 0;
-
- /* Get first thread on the waiting list: */
- if ((pthread != NULL) &&
- (pthread->wakeup_time.tv_sec != -1)) {
- /*
- * Calculate the time until this thread
- * is ready, allowing for the clock
- * resolution:
- */
- ts1.tv_sec = pthread->wakeup_time.tv_sec
- - ts.tv_sec;
- ts1.tv_nsec = pthread->wakeup_time.tv_nsec
- - ts.tv_nsec + _clock_res_nsec;
-
- /*
- * Check for underflow of the nanosecond field:
- */
- while (ts1.tv_nsec < 0) {
- /*
- * Allow for the underflow of the
- * nanosecond field:
- */
- ts1.tv_sec--;
- ts1.tv_nsec += 1000000000;
- }
- /*
- * Check for overflow of the nanosecond field:
- */
- while (ts1.tv_nsec >= 1000000000) {
- /*
- * Allow for the overflow of the
- * nanosecond field:
- */
- ts1.tv_sec++;
- ts1.tv_nsec -= 1000000000;
- }
- /*
- * Convert the timespec structure to a
- * timeval structure:
- */
- TIMESPEC_TO_TIMEVAL(&tv1, &ts1);
-
- /*
- * Check if the thread will be ready
- * sooner than the earliest ones found
- * so far:
- */
- if (timercmp(&tv1, &itimer.it_value, <)) {
- /*
- * Update the time value:
- */
- itimer.it_value.tv_sec = tv1.tv_sec;
- itimer.it_value.tv_usec = tv1.tv_usec;
- }
- }
-
- /*
- * Check if this thread is running for the first time
- * or running again after using its full time slice
- * allocation:
- */
- if (_thread_run->slice_usec == -1) {
- /* Reset the accumulated time slice period: */
- _thread_run->slice_usec = 0;
- }
-
- /* Check if there is more than one thread: */
- if (set_timer != 0) {
- /*
- * Start the interval timer for the
- * calculated time interval:
- */
- if (setitimer(_ITIMER_SCHED_TIMER, &itimer, NULL) != 0) {
- /*
- * Cannot initialise the timer, so
- * abort this process:
- */
- PANIC("Cannot set scheduling timer");
- }
- }
-
- /*
- * Check if this thread is being continued from a
- * longjmp() out of a signal handler:
- */
- if ((_thread_run->jmpflags & JMPFLAGS_LONGJMP) != 0) {
- _thread_run->jmpflags = 0;
- __longjmp(_thread_run->nested_jmp.jmp,
- _thread_run->longjmp_val);
- }
- /*
- * Check if this thread is being continued from a
- * _longjmp() out of a signal handler:
- */
- else if ((_thread_run->jmpflags & JMPFLAGS__LONGJMP) !=
- 0) {
- _thread_run->jmpflags = 0;
- ___longjmp(_thread_run->nested_jmp.jmp,
- _thread_run->longjmp_val);
- }
- /*
- * Check if this thread is being continued from a
- * siglongjmp() out of a signal handler:
- */
- else if ((_thread_run->jmpflags & JMPFLAGS_SIGLONGJMP)
- != 0) {
- _thread_run->jmpflags = 0;
- __siglongjmp(
- _thread_run->nested_jmp.sigjmp,
- _thread_run->longjmp_val);
- }
- /* Check if a signal context was saved: */
- else if (_thread_run->sig_saved == 1) {
-#ifndef __alpha__
- /*
- * Point to the floating point data in the
- * running thread:
- */
- fdata = _thread_run->saved_fp;
-
- /* Restore the floating point state: */
- __asm__("frstor %0": :"m"(*fdata));
-#endif
- /*
- * Do a sigreturn to restart the thread that
- * was interrupted by a signal:
- */
- _thread_kern_in_sched = 0;
-
- /*
- * If we had a context switch, run any
- * installed switch hooks.
- */
- if ((_sched_switch_hook != NULL) &&
- (_last_user_thread != _thread_run)) {
- thread_run_switch_hook(_last_user_thread,
- _thread_run);
- }
- _thread_sys_sigreturn(&_thread_run->saved_sigcontext);
- } else {
- /*
- * Do a longjmp to restart the thread that
- * was context switched out (by a longjmp to
- * a different thread):
- */
- __longjmp(_thread_run->saved_jmp_buf, 1);
- }
-
- /* This point should not be reached. */
- PANIC("Thread has returned from sigreturn or longjmp");
- }
- }
-
- /* There are no more threads, so exit this process: */
- exit(0);
-}
-
-void
-_thread_kern_sched_state(enum pthread_state state, char *fname, int lineno)
-{
- /*
- * Flag the pthread kernel as executing scheduler code
- * to avoid a scheduler signal from interrupting this
- * execution and calling the scheduler again.
- */
- _thread_kern_in_sched = 1;
-
- /*
- * Prevent the signal handler from fiddling with this thread
- * before its state is set and is placed into the proper queue.
- */
- _queue_signals = 1;
-
- /* Change the state of the current thread: */
- _thread_run->state = state;
- _thread_run->fname = fname;
- _thread_run->lineno = lineno;
-
- /* Schedule the next thread that is ready: */
- _thread_kern_sched(NULL);
- return;
-}
-
-void
-_thread_kern_sched_state_unlock(enum pthread_state state,
- spinlock_t *lock, char *fname, int lineno)
-{
- /*
- * Flag the pthread kernel as executing scheduler code
- * to avoid a scheduler signal from interrupting this
- * execution and calling the scheduler again.
- */
- _thread_kern_in_sched = 1;
-
- /*
- * Prevent the signal handler from fiddling with this thread
- * before its state is set and it is placed into the proper
- * queue(s).
- */
- _queue_signals = 1;
-
- /* Change the state of the current thread: */
- _thread_run->state = state;
- _thread_run->fname = fname;
- _thread_run->lineno = lineno;
-
- _SPINUNLOCK(lock);
-
- /* Schedule the next thread that is ready: */
- _thread_kern_sched(NULL);
- return;
-}
-
-static void
-_thread_kern_poll(int wait_reqd)
-{
- int count = 0;
- int i, found;
- int kern_pipe_added = 0;
- int nfds = 0;
- int timeout_ms = 0;
- struct pthread *pthread;
- struct timespec ts;
- struct timeval tv;
-
- /* Check if the caller wants to wait: */
- if (wait_reqd == 0) {
- timeout_ms = 0;
- }
- else {
- /* Get the current time of day: */
- gettimeofday(&tv, NULL);
- TIMEVAL_TO_TIMESPEC(&tv, &ts);
-
- _queue_signals = 1;
- pthread = TAILQ_FIRST(&_waitingq);
- _queue_signals = 0;
-
- if ((pthread == NULL) || (pthread->wakeup_time.tv_sec == -1)) {
- /*
- * Either there are no threads in the waiting queue,
- * or there are no threads that can timeout.
- */
- timeout_ms = INFTIM;
- }
- else {
- /*
- * Calculate the time left for the next thread to
- * timeout allowing for the clock resolution:
- */
- timeout_ms = ((pthread->wakeup_time.tv_sec - ts.tv_sec) *
- 1000) + ((pthread->wakeup_time.tv_nsec - ts.tv_nsec +
- _clock_res_nsec) / 1000000);
- /*
- * Don't allow negative timeouts:
- */
- if (timeout_ms < 0)
- timeout_ms = 0;
- }
- }
-
- /* Protect the scheduling queues: */
- _queue_signals = 1;
-
- /*
- * Check to see if the signal queue needs to be walked to look
- * for threads awoken by a signal while in the scheduler.
- */
- if (_sigq_check_reqd != 0) {
- /* Reset flag before handling queued signals: */
- _sigq_check_reqd = 0;
-
- dequeue_signals();
- }
-
- /*
- * Check for a thread that became runnable due to a signal:
- */
- if (PTHREAD_PRIOQ_FIRST() != NULL) {
- /*
- * Since there is at least one runnable thread,
- * disable the wait.
- */
- timeout_ms = 0;
- }
-
- /*
- * Form the poll table:
- */
- nfds = 0;
- if (timeout_ms != 0) {
- /* Add the kernel pipe to the poll table: */
- _thread_pfd_table[nfds].fd = _thread_kern_pipe[0];
- _thread_pfd_table[nfds].events = POLLRDNORM;
- _thread_pfd_table[nfds].revents = 0;
- nfds++;
- kern_pipe_added = 1;
- }
-
- PTHREAD_WAITQ_SETACTIVE();
- TAILQ_FOREACH(pthread, &_workq, qe) {
- switch (pthread->state) {
- case PS_SPINBLOCK:
- /*
- * If the lock is available, let the thread run.
- */
- if (pthread->data.spinlock->access_lock == 0) {
- PTHREAD_WAITQ_CLEARACTIVE();
- PTHREAD_WORKQ_REMOVE(pthread);
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
- PTHREAD_WAITQ_SETACTIVE();
- /* One less thread in a spinblock state: */
- _spinblock_count--;
- /*
- * Since there is at least one runnable
- * thread, disable the wait.
- */
- timeout_ms = 0;
- }
- break;
-
- /* File descriptor read wait: */
- case PS_FDR_WAIT:
- /* Limit number of polled files to table size: */
- if (nfds < _thread_dtablesize) {
- _thread_pfd_table[nfds].events = POLLRDNORM;
- _thread_pfd_table[nfds].fd = pthread->data.fd.fd;
- nfds++;
- }
- break;
-
- /* File descriptor write wait: */
- case PS_FDW_WAIT:
- /* Limit number of polled files to table size: */
- if (nfds < _thread_dtablesize) {
- _thread_pfd_table[nfds].events = POLLWRNORM;
- _thread_pfd_table[nfds].fd = pthread->data.fd.fd;
- nfds++;
- }
- break;
-
- /* File descriptor poll or select wait: */
- case PS_POLL_WAIT:
- case PS_SELECT_WAIT:
- /* Limit number of polled files to table size: */
- if (pthread->data.poll_data->nfds + nfds <
- _thread_dtablesize) {
- for (i = 0; i < pthread->data.poll_data->nfds; i++) {
- _thread_pfd_table[nfds + i].fd =
- pthread->data.poll_data->fds[i].fd;
- _thread_pfd_table[nfds + i].events =
- pthread->data.poll_data->fds[i].events;
- }
- nfds += pthread->data.poll_data->nfds;
- }
- break;
-
- /* Other states do not depend on file I/O. */
- default:
- break;
- }
- }
- PTHREAD_WAITQ_CLEARACTIVE();
-
- /*
- * Wait for a file descriptor to be ready for read, write, or
- * an exception, or a timeout to occur:
- */
- count = _thread_sys_poll(_thread_pfd_table, nfds, timeout_ms);
-
- if (kern_pipe_added != 0)
- /*
- * Remove the pthread kernel pipe file descriptor
- * from the pollfd table:
- */
- nfds = 1;
- else
- nfds = 0;
-
- /*
- * Check if it is possible that there are bytes in the kernel
- * read pipe waiting to be read:
- */
- if (count < 0 || ((kern_pipe_added != 0) &&
- (_thread_pfd_table[0].revents & POLLRDNORM))) {
- /*
- * If the kernel read pipe was included in the
- * count:
- */
- if (count > 0) {
- /* Decrement the count of file descriptors: */
- count--;
- }
-
- if (_sigq_check_reqd != 0) {
- /* Reset flag before handling signals: */
- _sigq_check_reqd = 0;
-
- dequeue_signals();
- }
- }
-
- /*
- * Check if any file descriptors are ready:
- */
- if (count > 0) {
- /*
- * Enter a loop to look for threads waiting on file
- * descriptors that are flagged as available by the
- * _poll syscall:
- */
- PTHREAD_WAITQ_SETACTIVE();
- TAILQ_FOREACH(pthread, &_workq, qe) {
- switch (pthread->state) {
- case PS_SPINBLOCK:
- /*
- * If the lock is available, let the thread run.
- */
- if (pthread->data.spinlock->access_lock == 0) {
- PTHREAD_WAITQ_CLEARACTIVE();
- PTHREAD_WORKQ_REMOVE(pthread);
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
- PTHREAD_WAITQ_SETACTIVE();
-
- /*
- * One less thread in a spinblock state:
- */
- _spinblock_count--;
- }
- break;
-
- /* File descriptor read wait: */
- case PS_FDR_WAIT:
- if ((nfds < _thread_dtablesize) &&
- (_thread_pfd_table[nfds].revents & POLLRDNORM)) {
- PTHREAD_WAITQ_CLEARACTIVE();
- PTHREAD_WORKQ_REMOVE(pthread);
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
- PTHREAD_WAITQ_SETACTIVE();
- }
- nfds++;
- break;
-
- /* File descriptor write wait: */
- case PS_FDW_WAIT:
- if ((nfds < _thread_dtablesize) &&
- (_thread_pfd_table[nfds].revents & POLLWRNORM)) {
- PTHREAD_WAITQ_CLEARACTIVE();
- PTHREAD_WORKQ_REMOVE(pthread);
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
- PTHREAD_WAITQ_SETACTIVE();
- }
- nfds++;
- break;
-
- /* File descriptor poll or select wait: */
- case PS_POLL_WAIT:
- case PS_SELECT_WAIT:
- if (pthread->data.poll_data->nfds + nfds <
- _thread_dtablesize) {
- /*
- * Enter a loop looking for I/O
- * readiness:
- */
- found = 0;
- for (i = 0; i < pthread->data.poll_data->nfds; i++) {
- if (_thread_pfd_table[nfds + i].revents != 0) {
- pthread->data.poll_data->fds[i].revents =
- _thread_pfd_table[nfds + i].revents;
- found++;
- }
- }
-
- /* Increment before destroying: */
- nfds += pthread->data.poll_data->nfds;
-
- if (found != 0) {
- pthread->data.poll_data->nfds = found;
- PTHREAD_WAITQ_CLEARACTIVE();
- PTHREAD_WORKQ_REMOVE(pthread);
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
- PTHREAD_WAITQ_SETACTIVE();
- }
- }
- else
- nfds += pthread->data.poll_data->nfds;
- break;
-
- /* Other states do not depend on file I/O. */
- default:
- break;
- }
- }
- PTHREAD_WAITQ_CLEARACTIVE();
- }
- else if (_spinblock_count != 0) {
- /*
- * Enter a loop to look for threads waiting on a spinlock
- * that is now available.
- */
- PTHREAD_WAITQ_SETACTIVE();
- TAILQ_FOREACH(pthread, &_workq, qe) {
- if (pthread->state == PS_SPINBLOCK) {
- /*
- * If the lock is available, let the thread run.
- */
- if (pthread->data.spinlock->access_lock == 0) {
- PTHREAD_WAITQ_CLEARACTIVE();
- PTHREAD_WORKQ_REMOVE(pthread);
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
- PTHREAD_WAITQ_SETACTIVE();
-
- /*
- * One less thread in a spinblock state:
- */
- _spinblock_count--;
- }
- }
- }
- PTHREAD_WAITQ_CLEARACTIVE();
- }
-
- /* Unprotect the scheduling queues: */
- _queue_signals = 0;
-
- while (_sigq_check_reqd != 0) {
- /* Handle queued signals: */
- _sigq_check_reqd = 0;
-
- /* Protect the scheduling queues: */
- _queue_signals = 1;
-
- dequeue_signals();
-
- /* Unprotect the scheduling queues: */
- _queue_signals = 0;
- }
-
- /* Nothing to return. */
- return;
-}
-
-void
-_thread_kern_set_timeout(struct timespec * timeout)
-{
- struct timespec current_time;
- struct timeval tv;
-
- /* Reset the timeout flag for the running thread: */
- _thread_run->timeout = 0;
-
- /* Check if the thread is to wait forever: */
- if (timeout == NULL) {
- /*
- * Set the wakeup time to something that can be recognised as
- * different to an actual time of day:
- */
- _thread_run->wakeup_time.tv_sec = -1;
- _thread_run->wakeup_time.tv_nsec = -1;
- }
- /* Check if no waiting is required: */
- else if (timeout->tv_sec == 0 && timeout->tv_nsec == 0) {
- /* Set the wake up time to 'immediately': */
- _thread_run->wakeup_time.tv_sec = 0;
- _thread_run->wakeup_time.tv_nsec = 0;
- } else {
- /* Get the current time: */
- gettimeofday(&tv, NULL);
- TIMEVAL_TO_TIMESPEC(&tv, &current_time);
-
- /* Calculate the time for the current thread to wake up: */
- _thread_run->wakeup_time.tv_sec = current_time.tv_sec + timeout->tv_sec;
- _thread_run->wakeup_time.tv_nsec = current_time.tv_nsec + timeout->tv_nsec;
-
- /* Check if the nanosecond field needs to wrap: */
- if (_thread_run->wakeup_time.tv_nsec >= 1000000000) {
- /* Wrap the nanosecond field: */
- _thread_run->wakeup_time.tv_sec += 1;
- _thread_run->wakeup_time.tv_nsec -= 1000000000;
- }
- }
- return;
-}
-
-void
-_thread_kern_sig_defer(void)
-{
- /* Allow signal deferral to be recursive. */
- _thread_run->sig_defer_count++;
-}
-
-void
-_thread_kern_sig_undefer(void)
-{
- pthread_t pthread;
- int need_resched = 0;
-
- /*
- * Perform checks to yield only if we are about to undefer
- * signals.
- */
- if (_thread_run->sig_defer_count > 1) {
- /* Decrement the signal deferral count. */
- _thread_run->sig_defer_count--;
- }
- else if (_thread_run->sig_defer_count == 1) {
- /* Reenable signals: */
- _thread_run->sig_defer_count = 0;
-
- /*
- * Check if there are queued signals:
- */
- while (_sigq_check_reqd != 0) {
- /* Defer scheduling while we process queued signals: */
- _thread_run->sig_defer_count = 1;
-
- /* Clear the flag before checking the signal queue: */
- _sigq_check_reqd = 0;
-
- /* Dequeue and handle signals: */
- dequeue_signals();
-
- /*
- * Avoiding an unnecessary check to reschedule, check
- * to see if signal handling caused a higher priority
- * thread to become ready.
- */
- if ((need_resched == 0) &&
- (((pthread = PTHREAD_PRIOQ_FIRST()) != NULL) &&
- (pthread->active_priority > _thread_run->active_priority))) {
- need_resched = 1;
- }
-
- /* Reenable signals: */
- _thread_run->sig_defer_count = 0;
- }
-
- /* Yield the CPU if necessary: */
- if (need_resched || _thread_run->yield_on_sig_undefer != 0) {
- _thread_run->yield_on_sig_undefer = 0;
- _thread_kern_sched(NULL);
- }
- }
-}
-
-static void
-dequeue_signals(void)
-{
- char bufr[128];
- int i, num;
- pthread_t pthread;
-
- /*
- * Enter a loop to read and handle queued signals from the
- * pthread kernel pipe:
- */
- while (((num = _thread_sys_read(_thread_kern_pipe[0], bufr,
- sizeof(bufr))) > 0) || (num == -1 && errno == EINTR)) {
- /*
- * The buffer read contains one byte per signal and
- * each byte is the signal number.
- */
- for (i = 0; i < num; i++) {
- if ((int) bufr[i] == _SCHED_SIGNAL) {
- /*
- * Scheduling signals shouldn't ever be
- * queued; just ignore it for now.
- */
- }
- else {
- /* Handle this signal: */
- pthread = _thread_sig_handle((int) bufr[i],
- NULL);
- if (pthread != NULL)
- _thread_sig_deliver(pthread,
- (int) bufr[i]);
- }
- }
- }
- if ((num < 0) && (errno != EAGAIN)) {
- /*
- * The only error we should expect is if there is
- * no data to read.
- */
- PANIC("Unable to read from thread kernel pipe");
- }
-}
-
-static inline void
-thread_run_switch_hook(pthread_t thread_out, pthread_t thread_in)
-{
- pthread_t tid_out = thread_out;
- pthread_t tid_in = thread_in;
-
- if ((tid_out != NULL) &&
- (tid_out->flags & PTHREAD_FLAGS_PRIVATE) != 0)
- tid_out = NULL;
- if ((tid_in != NULL) &&
- (tid_in->flags & PTHREAD_FLAGS_PRIVATE) != 0)
- tid_in = NULL;
-
- if ((_sched_switch_hook != NULL) && (tid_out != tid_in)) {
- /* Run the scheduler switch hook: */
- _sched_switch_hook(tid_out, tid_in);
- }
-}
-#endif
diff --git a/lib/libpthread/thread/thr_kill.c b/lib/libpthread/thread/thr_kill.c
deleted file mode 100644
index 4bf1761cf9ed..000000000000
--- a/lib/libpthread/thread/thr_kill.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#include <signal.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_kill(pthread_t pthread, int sig)
-{
- int ret;
-
- /* Check for invalid signal numbers: */
- if (sig < 0 || sig >= NSIG)
- /* Invalid signal: */
- ret = EINVAL;
- /*
- * Ensure the thread is in the list of active threads, and the
- * signal is valid (signal 0 specifies error checking only) and
- * not being ignored:
- */
- else if (((ret = _find_thread(pthread)) == 0) && (sig > 0) &&
- (_thread_sigact[sig - 1].sa_handler != SIG_IGN)) {
- /*
- * Defer signals to protect the scheduling queues from
- * access by the signal handler:
- */
- _thread_kern_sig_defer();
-
- _thread_sig_send(pthread, sig);
-
- /*
- * Undefer and handle pending signals, yielding if
- * necessary:
- */
- _thread_kern_sig_undefer();
- }
-
- /* Return the completion status: */
- return (ret);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_mattr_init.c b/lib/libpthread/thread/thr_mattr_init.c
deleted file mode 100644
index 63d4401f2553..000000000000
--- a/lib/libpthread/thread/thr_mattr_init.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 1996 Jeffrey Hsu <hsu@freebsd.org>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_mutexattr_init(pthread_mutexattr_t *attr)
-{
- int ret;
- pthread_mutexattr_t pattr;
-
- if ((pattr = (pthread_mutexattr_t)
- malloc(sizeof(struct pthread_mutex_attr))) == NULL) {
- ret = ENOMEM;
- } else {
- memcpy(pattr, &pthread_mutexattr_default,
- sizeof(struct pthread_mutex_attr));
- *attr = pattr;
- ret = 0;
- }
- return(ret);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_mattr_kind_np.c b/lib/libpthread/thread/thr_mattr_kind_np.c
deleted file mode 100644
index 8b3b8cbafaf5..000000000000
--- a/lib/libpthread/thread/thr_mattr_kind_np.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 1996 Jeffrey Hsu <hsu@freebsd.org>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_mutexattr_setkind_np(pthread_mutexattr_t *attr, int kind)
-{
- int ret;
- if (attr == NULL || *attr == NULL) {
- errno = EINVAL;
- ret = -1;
- } else {
- (*attr)->m_type = kind;
- ret = 0;
- }
- return(ret);
-}
-
-int
-pthread_mutexattr_getkind_np(pthread_mutexattr_t attr)
-{
- int ret;
- if (attr == NULL) {
- errno = EINVAL;
- ret = -1;
- } else {
- ret = attr->m_type;
- }
- return(ret);
-}
-
-int
-pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type)
-{
- int ret;
- if (attr == NULL || *attr == NULL || type >= MUTEX_TYPE_MAX) {
- errno = EINVAL;
- ret = -1;
- } else {
- (*attr)->m_type = type;
- ret = 0;
- }
- return(ret);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_msync.c b/lib/libpthread/thread/thr_msync.c
deleted file mode 100644
index 2ae6ac75ab73..000000000000
--- a/lib/libpthread/thread/thr_msync.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * David Leonard <d@openbsd.org>, 1999. Public Domain.
- *
- * $OpenBSD: uthread_msync.c,v 1.2 1999/06/09 07:16:17 d Exp $
- *
- * $FreeBSD$
- */
-
-#include <sys/types.h>
-#include <sys/mman.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-_msync(void *addr, size_t len, int flags)
-{
- int ret;
-
- ret = _thread_sys_msync(addr, len, flags);
-
- return (ret);
-}
-
-int
-msync(void *addr, size_t len, int flags)
-{
- int ret;
-
- /*
- * XXX This is quite pointless unless we know how to get the
- * file descriptor associated with the memory, and lock it for
- * write. The only real use of this wrapper is to guarantee
- * a cancellation point, as per the standard. sigh.
- */
- _thread_enter_cancellation_point();
- ret = _msync(addr, len, flags);
- _thread_leave_cancellation_point();
-
- return ret;
-}
-#endif
diff --git a/lib/libpthread/thread/thr_multi_np.c b/lib/libpthread/thread/thr_multi_np.c
deleted file mode 100644
index 9a2f7c1ece49..000000000000
--- a/lib/libpthread/thread/thr_multi_np.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <string.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_multi_np()
-{
- /* Return to multi-threaded scheduling mode: */
- _thread_single = NULL;
- return(0);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_mutex.c b/lib/libpthread/thread/thr_mutex.c
deleted file mode 100644
index 6d75ea52752e..000000000000
--- a/lib/libpthread/thread/thr_mutex.c
+++ /dev/null
@@ -1,1404 +0,0 @@
-/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <stdlib.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/param.h>
-#include <sys/queue.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-#if defined(_PTHREADS_INVARIANTS)
-#define _MUTEX_INIT_LINK(m) do { \
- (m)->m_qe.tqe_prev = NULL; \
- (m)->m_qe.tqe_next = NULL; \
-} while (0)
-#define _MUTEX_ASSERT_IS_OWNED(m) do { \
- if ((m)->m_qe.tqe_prev == NULL) \
- PANIC("mutex is not on list"); \
-} while (0)
-#define _MUTEX_ASSERT_NOT_OWNED(m) do { \
- if (((m)->m_qe.tqe_prev != NULL) || \
- ((m)->m_qe.tqe_next != NULL)) \
- PANIC("mutex is on list"); \
-} while (0)
-#else
-#define _MUTEX_INIT_LINK(m)
-#define _MUTEX_ASSERT_IS_OWNED(m)
-#define _MUTEX_ASSERT_NOT_OWNED(m)
-#endif
-
-/*
- * Prototypes
- */
-static inline int mutex_self_trylock(pthread_mutex_t);
-static inline int mutex_self_lock(pthread_mutex_t);
-static inline int mutex_unlock_common(pthread_mutex_t *, int);
-static void mutex_priority_adjust(pthread_mutex_t);
-static void mutex_rescan_owned (pthread_t, pthread_mutex_t);
-static inline pthread_t mutex_queue_deq(pthread_mutex_t);
-static inline void mutex_queue_remove(pthread_mutex_t, pthread_t);
-static inline void mutex_queue_enq(pthread_mutex_t, pthread_t);
-
-
-static spinlock_t static_init_lock = _SPINLOCK_INITIALIZER;
-
-/* Reinitialize a mutex to defaults. */
-int
-_mutex_reinit(pthread_mutex_t * mutex)
-{
- int ret = 0;
-
- if (mutex == NULL)
- ret = EINVAL;
- else if (*mutex == NULL)
- ret = pthread_mutex_init(mutex, NULL);
- else {
- /*
- * Initialize the mutex structure:
- */
- (*mutex)->m_type = PTHREAD_MUTEX_DEFAULT;
- (*mutex)->m_protocol = PTHREAD_PRIO_NONE;
- TAILQ_INIT(&(*mutex)->m_queue);
- (*mutex)->m_owner = NULL;
- (*mutex)->m_data.m_count = 0;
- (*mutex)->m_flags &= MUTEX_FLAGS_PRIVATE;
- (*mutex)->m_flags |= MUTEX_FLAGS_INITED;
- (*mutex)->m_refcount = 0;
- (*mutex)->m_prio = 0;
- (*mutex)->m_saved_prio = 0;
- _MUTEX_INIT_LINK(*mutex);
- memset(&(*mutex)->lock, 0, sizeof((*mutex)->lock));
- }
- return (ret);
-}
-
-int
-pthread_mutex_init(pthread_mutex_t * mutex,
- const pthread_mutexattr_t * mutex_attr)
-{
- enum pthread_mutextype type;
- int protocol;
- int ceiling;
- pthread_mutex_t pmutex;
- int ret = 0;
-
- if (mutex == NULL)
- ret = EINVAL;
-
- /* Check if default mutex attributes: */
- else if (mutex_attr == NULL || *mutex_attr == NULL) {
- /* Default to a (error checking) POSIX mutex: */
- type = PTHREAD_MUTEX_ERRORCHECK;
- protocol = PTHREAD_PRIO_NONE;
- ceiling = PTHREAD_MAX_PRIORITY;
- }
-
- /* Check mutex type: */
- else if (((*mutex_attr)->m_type < PTHREAD_MUTEX_ERRORCHECK) ||
- ((*mutex_attr)->m_type >= MUTEX_TYPE_MAX))
- /* Return an invalid argument error: */
- ret = EINVAL;
-
- /* Check mutex protocol: */
- else if (((*mutex_attr)->m_protocol < PTHREAD_PRIO_NONE) ||
- ((*mutex_attr)->m_protocol > PTHREAD_MUTEX_RECURSIVE))
- /* Return an invalid argument error: */
- ret = EINVAL;
-
- else {
- /* Use the requested mutex type and protocol: */
- type = (*mutex_attr)->m_type;
- protocol = (*mutex_attr)->m_protocol;
- ceiling = (*mutex_attr)->m_ceiling;
- }
-
- /* Check no errors so far: */
- if (ret == 0) {
- if ((pmutex = (pthread_mutex_t)
- malloc(sizeof(struct pthread_mutex))) == NULL)
- ret = ENOMEM;
- else {
- /* Reset the mutex flags: */
- pmutex->m_flags = 0;
-
- /* Process according to mutex type: */
- switch (type) {
- /* case PTHREAD_MUTEX_DEFAULT: */
- case PTHREAD_MUTEX_ERRORCHECK:
- case PTHREAD_MUTEX_NORMAL:
- /* Nothing to do here. */
- break;
-
- /* Single UNIX Spec 2 recursive mutex: */
- case PTHREAD_MUTEX_RECURSIVE:
- /* Reset the mutex count: */
- pmutex->m_data.m_count = 0;
- break;
-
- /* Trap invalid mutex types: */
- default:
- /* Return an invalid argument error: */
- ret = EINVAL;
- break;
- }
- if (ret == 0) {
- /* Initialise the rest of the mutex: */
- TAILQ_INIT(&pmutex->m_queue);
- pmutex->m_flags |= MUTEX_FLAGS_INITED;
- pmutex->m_owner = NULL;
- pmutex->m_type = type;
- pmutex->m_protocol = protocol;
- pmutex->m_refcount = 0;
- if (protocol == PTHREAD_PRIO_PROTECT)
- pmutex->m_prio = ceiling;
- else
- pmutex->m_prio = 0;
- pmutex->m_saved_prio = 0;
- _MUTEX_INIT_LINK(pmutex);
- memset(&pmutex->lock, 0, sizeof(pmutex->lock));
- *mutex = pmutex;
- } else {
- free(pmutex);
- *mutex = NULL;
- }
- }
- }
- /* Return the completion status: */
- return(ret);
-}
-
-int
-pthread_mutex_destroy(pthread_mutex_t * mutex)
-{
- int ret = 0;
-
- if (mutex == NULL || *mutex == NULL)
- ret = EINVAL;
- else {
- /* Lock the mutex structure: */
- _SPINLOCK(&(*mutex)->lock);
-
- /*
- * Check to see if this mutex is in use:
- */
- if (((*mutex)->m_owner != NULL) ||
- (TAILQ_FIRST(&(*mutex)->m_queue) != NULL) ||
- ((*mutex)->m_refcount != 0)) {
- ret = EBUSY;
-
- /* Unlock the mutex structure: */
- _SPINUNLOCK(&(*mutex)->lock);
- }
- else {
- /*
- * Free the memory allocated for the mutex
- * structure:
- */
- _MUTEX_ASSERT_NOT_OWNED(*mutex);
- free(*mutex);
-
- /*
- * Leave the caller's pointer NULL now that
- * the mutex has been destroyed:
- */
- *mutex = NULL;
- }
- }
-
- /* Return the completion status: */
- return (ret);
-}
-
-static int
-init_static(pthread_mutex_t *mutex)
-{
- int ret;
-
- _SPINLOCK(&static_init_lock);
-
- if (*mutex == NULL)
- ret = pthread_mutex_init(mutex, NULL);
- else
- ret = 0;
-
- _SPINUNLOCK(&static_init_lock);
-
- return(ret);
-}
-
-int
-pthread_mutex_trylock(pthread_mutex_t * mutex)
-{
- int ret = 0;
-
- if (mutex == NULL)
- ret = EINVAL;
-
- /*
- * If the mutex is statically initialized, perform the dynamic
- * initialization:
- */
- else if (*mutex != NULL || (ret = init_static(mutex)) == 0) {
- /*
- * Defer signals to protect the scheduling queues from
- * access by the signal handler:
- */
- _thread_kern_sig_defer();
-
- /* Lock the mutex structure: */
- _SPINLOCK(&(*mutex)->lock);
-
- /*
- * If the mutex was statically allocated, properly
- * initialize the tail queue.
- */
- if (((*mutex)->m_flags & MUTEX_FLAGS_INITED) == 0) {
- TAILQ_INIT(&(*mutex)->m_queue);
- _MUTEX_INIT_LINK(*mutex);
- (*mutex)->m_flags |= MUTEX_FLAGS_INITED;
- }
-
- /* Process according to mutex type: */
- switch ((*mutex)->m_protocol) {
- /* Default POSIX mutex: */
- case PTHREAD_PRIO_NONE:
- /* Check if this mutex is not locked: */
- if ((*mutex)->m_owner == NULL) {
- /* Lock the mutex for the running thread: */
- (*mutex)->m_owner = _thread_run;
-
- /* Add to the list of owned mutexes: */
- _MUTEX_ASSERT_NOT_OWNED(*mutex);
- TAILQ_INSERT_TAIL(&_thread_run->mutexq,
- (*mutex), m_qe);
- } else if ((*mutex)->m_owner == _thread_run)
- ret = mutex_self_trylock(*mutex);
- else
- /* Return a busy error: */
- ret = EBUSY;
- break;
-
- /* POSIX priority inheritence mutex: */
- case PTHREAD_PRIO_INHERIT:
- /* Check if this mutex is not locked: */
- if ((*mutex)->m_owner == NULL) {
- /* Lock the mutex for the running thread: */
- (*mutex)->m_owner = _thread_run;
-
- /* Track number of priority mutexes owned: */
- _thread_run->priority_mutex_count++;
-
- /*
- * The mutex takes on the attributes of the
- * running thread when there are no waiters.
- */
- (*mutex)->m_prio = _thread_run->active_priority;
- (*mutex)->m_saved_prio =
- _thread_run->inherited_priority;
-
- /* Add to the list of owned mutexes: */
- _MUTEX_ASSERT_NOT_OWNED(*mutex);
- TAILQ_INSERT_TAIL(&_thread_run->mutexq,
- (*mutex), m_qe);
- } else if ((*mutex)->m_owner == _thread_run)
- ret = mutex_self_trylock(*mutex);
- else
- /* Return a busy error: */
- ret = EBUSY;
- break;
-
- /* POSIX priority protection mutex: */
- case PTHREAD_PRIO_PROTECT:
- /* Check for a priority ceiling violation: */
- if (_thread_run->active_priority > (*mutex)->m_prio)
- ret = EINVAL;
-
- /* Check if this mutex is not locked: */
- else if ((*mutex)->m_owner == NULL) {
- /* Lock the mutex for the running thread: */
- (*mutex)->m_owner = _thread_run;
-
- /* Track number of priority mutexes owned: */
- _thread_run->priority_mutex_count++;
-
- /*
- * The running thread inherits the ceiling
- * priority of the mutex and executes at that
- * priority.
- */
- _thread_run->active_priority = (*mutex)->m_prio;
- (*mutex)->m_saved_prio =
- _thread_run->inherited_priority;
- _thread_run->inherited_priority =
- (*mutex)->m_prio;
-
- /* Add to the list of owned mutexes: */
- _MUTEX_ASSERT_NOT_OWNED(*mutex);
- TAILQ_INSERT_TAIL(&_thread_run->mutexq,
- (*mutex), m_qe);
- } else if ((*mutex)->m_owner == _thread_run)
- ret = mutex_self_trylock(*mutex);
- else
- /* Return a busy error: */
- ret = EBUSY;
- break;
-
- /* Trap invalid mutex types: */
- default:
- /* Return an invalid argument error: */
- ret = EINVAL;
- break;
- }
-
- /* Unlock the mutex structure: */
- _SPINUNLOCK(&(*mutex)->lock);
-
- /*
- * Undefer and handle pending signals, yielding if
- * necessary:
- */
- _thread_kern_sig_undefer();
- }
-
- /* Return the completion status: */
- return (ret);
-}
-
-int
-pthread_mutex_lock(pthread_mutex_t * mutex)
-{
- int ret = 0;
-
- if (mutex == NULL)
- ret = EINVAL;
-
- /*
- * If the mutex is statically initialized, perform the dynamic
- * initialization:
- */
- else if (*mutex != NULL || (ret = init_static(mutex)) == 0) {
- /*
- * Defer signals to protect the scheduling queues from
- * access by the signal handler:
- */
- _thread_kern_sig_defer();
-
- /* Lock the mutex structure: */
- _SPINLOCK(&(*mutex)->lock);
-
- /*
- * If the mutex was statically allocated, properly
- * initialize the tail queue.
- */
- if (((*mutex)->m_flags & MUTEX_FLAGS_INITED) == 0) {
- TAILQ_INIT(&(*mutex)->m_queue);
- (*mutex)->m_flags |= MUTEX_FLAGS_INITED;
- _MUTEX_INIT_LINK(*mutex);
- }
-
- /* Reset the interrupted flag: */
- _thread_run->interrupted = 0;
-
- /* Process according to mutex type: */
- switch ((*mutex)->m_protocol) {
- /* Default POSIX mutex: */
- case PTHREAD_PRIO_NONE:
- if ((*mutex)->m_owner == NULL) {
- /* Lock the mutex for this thread: */
- (*mutex)->m_owner = _thread_run;
-
- /* Add to the list of owned mutexes: */
- _MUTEX_ASSERT_NOT_OWNED(*mutex);
- TAILQ_INSERT_TAIL(&_thread_run->mutexq,
- (*mutex), m_qe);
-
- } else if ((*mutex)->m_owner == _thread_run)
- ret = mutex_self_lock(*mutex);
- else {
- /*
- * Join the queue of threads waiting to lock
- * the mutex:
- */
- mutex_queue_enq(*mutex, _thread_run);
-
- /*
- * Keep a pointer to the mutex this thread
- * is waiting on:
- */
- _thread_run->data.mutex = *mutex;
-
- /*
- * Unlock the mutex structure and schedule the
- * next thread:
- */
- _thread_kern_sched_state_unlock(PS_MUTEX_WAIT,
- &(*mutex)->lock, __FILE__, __LINE__);
-
- /* Lock the mutex structure again: */
- _SPINLOCK(&(*mutex)->lock);
- }
- break;
-
- /* POSIX priority inheritence mutex: */
- case PTHREAD_PRIO_INHERIT:
- /* Check if this mutex is not locked: */
- if ((*mutex)->m_owner == NULL) {
- /* Lock the mutex for this thread: */
- (*mutex)->m_owner = _thread_run;
-
- /* Track number of priority mutexes owned: */
- _thread_run->priority_mutex_count++;
-
- /*
- * The mutex takes on attributes of the
- * running thread when there are no waiters.
- */
- (*mutex)->m_prio = _thread_run->active_priority;
- (*mutex)->m_saved_prio =
- _thread_run->inherited_priority;
- _thread_run->inherited_priority =
- (*mutex)->m_prio;
-
- /* Add to the list of owned mutexes: */
- _MUTEX_ASSERT_NOT_OWNED(*mutex);
- TAILQ_INSERT_TAIL(&_thread_run->mutexq,
- (*mutex), m_qe);
-
- } else if ((*mutex)->m_owner == _thread_run)
- ret = mutex_self_lock(*mutex);
- else {
- /*
- * Join the queue of threads waiting to lock
- * the mutex:
- */
- mutex_queue_enq(*mutex, _thread_run);
-
- /*
- * Keep a pointer to the mutex this thread
- * is waiting on:
- */
- _thread_run->data.mutex = *mutex;
-
- if (_thread_run->active_priority >
- (*mutex)->m_prio)
- /* Adjust priorities: */
- mutex_priority_adjust(*mutex);
-
- /*
- * Unlock the mutex structure and schedule the
- * next thread:
- */
- _thread_kern_sched_state_unlock(PS_MUTEX_WAIT,
- &(*mutex)->lock, __FILE__, __LINE__);
-
- /* Lock the mutex structure again: */
- _SPINLOCK(&(*mutex)->lock);
- }
- break;
-
- /* POSIX priority protection mutex: */
- case PTHREAD_PRIO_PROTECT:
- /* Check for a priority ceiling violation: */
- if (_thread_run->active_priority > (*mutex)->m_prio)
- ret = EINVAL;
-
- /* Check if this mutex is not locked: */
- else if ((*mutex)->m_owner == NULL) {
- /*
- * Lock the mutex for the running
- * thread:
- */
- (*mutex)->m_owner = _thread_run;
-
- /* Track number of priority mutexes owned: */
- _thread_run->priority_mutex_count++;
-
- /*
- * The running thread inherits the ceiling
- * priority of the mutex and executes at that
- * priority:
- */
- _thread_run->active_priority = (*mutex)->m_prio;
- (*mutex)->m_saved_prio =
- _thread_run->inherited_priority;
- _thread_run->inherited_priority =
- (*mutex)->m_prio;
-
- /* Add to the list of owned mutexes: */
- _MUTEX_ASSERT_NOT_OWNED(*mutex);
- TAILQ_INSERT_TAIL(&_thread_run->mutexq,
- (*mutex), m_qe);
- } else if ((*mutex)->m_owner == _thread_run)
- ret = mutex_self_lock(*mutex);
- else {
- /*
- * Join the queue of threads waiting to lock
- * the mutex:
- */
- mutex_queue_enq(*mutex, _thread_run);
-
- /*
- * Keep a pointer to the mutex this thread
- * is waiting on:
- */
- _thread_run->data.mutex = *mutex;
-
- /* Clear any previous error: */
- _thread_run->error = 0;
-
- /*
- * Unlock the mutex structure and schedule the
- * next thread:
- */
- _thread_kern_sched_state_unlock(PS_MUTEX_WAIT,
- &(*mutex)->lock, __FILE__, __LINE__);
-
- /* Lock the mutex structure again: */
- _SPINLOCK(&(*mutex)->lock);
-
- /*
- * The threads priority may have changed while
- * waiting for the mutex causing a ceiling
- * violation.
- */
- ret = _thread_run->error;
- _thread_run->error = 0;
- }
- break;
-
- /* Trap invalid mutex types: */
- default:
- /* Return an invalid argument error: */
- ret = EINVAL;
- break;
- }
-
- /*
- * Check to see if this thread was interrupted and
- * is still in the mutex queue of waiting threads:
- */
- if (_thread_run->interrupted != 0)
- mutex_queue_remove(*mutex, _thread_run);
-
- /* Unlock the mutex structure: */
- _SPINUNLOCK(&(*mutex)->lock);
-
- /*
- * Undefer and handle pending signals, yielding if
- * necessary:
- */
- _thread_kern_sig_undefer();
-
- if (_thread_run->interrupted != 0 &&
- _thread_run->continuation != NULL)
- _thread_run->continuation((void *) _thread_run);
- }
-
- /* Return the completion status: */
- return (ret);
-}
-
-int
-pthread_mutex_unlock(pthread_mutex_t * mutex)
-{
- return (mutex_unlock_common(mutex, /* add reference */ 0));
-}
-
-int
-_mutex_cv_unlock(pthread_mutex_t * mutex)
-{
- return (mutex_unlock_common(mutex, /* add reference */ 1));
-}
-
-int
-_mutex_cv_lock(pthread_mutex_t * mutex)
-{
- int ret;
- if ((ret = pthread_mutex_lock(mutex)) == 0)
- (*mutex)->m_refcount--;
- return (ret);
-}
-
-static inline int
-mutex_self_trylock(pthread_mutex_t mutex)
-{
- int ret = 0;
-
- switch (mutex->m_type) {
-
- /* case PTHREAD_MUTEX_DEFAULT: */
- case PTHREAD_MUTEX_ERRORCHECK:
- case PTHREAD_MUTEX_NORMAL:
- /*
- * POSIX specifies that mutexes should return EDEADLK if a
- * recursive lock is detected.
- */
- ret = EBUSY;
- break;
-
- case PTHREAD_MUTEX_RECURSIVE:
- /* Increment the lock count: */
- mutex->m_data.m_count++;
- break;
-
- default:
- /* Trap invalid mutex types; */
- ret = EINVAL;
- }
-
- return(ret);
-}
-
-static inline int
-mutex_self_lock(pthread_mutex_t mutex)
-{
- int ret = 0;
-
- switch (mutex->m_type) {
- /* case PTHREAD_MUTEX_DEFAULT: */
- case PTHREAD_MUTEX_ERRORCHECK:
- /*
- * POSIX specifies that mutexes should return EDEADLK if a
- * recursive lock is detected.
- */
- ret = EDEADLK;
- break;
-
- case PTHREAD_MUTEX_NORMAL:
- /*
- * What SS2 define as a 'normal' mutex. Intentionally
- * deadlock on attempts to get a lock you already own.
- */
- _thread_kern_sched_state_unlock(PS_DEADLOCK,
- &mutex->lock, __FILE__, __LINE__);
- break;
-
- case PTHREAD_MUTEX_RECURSIVE:
- /* Increment the lock count: */
- mutex->m_data.m_count++;
- break;
-
- default:
- /* Trap invalid mutex types; */
- ret = EINVAL;
- }
-
- return(ret);
-}
-
-static inline int
-mutex_unlock_common(pthread_mutex_t * mutex, int add_reference)
-{
- int ret = 0;
-
- if (mutex == NULL || *mutex == NULL) {
- ret = EINVAL;
- } else {
- /*
- * Defer signals to protect the scheduling queues from
- * access by the signal handler:
- */
- _thread_kern_sig_defer();
-
- /* Lock the mutex structure: */
- _SPINLOCK(&(*mutex)->lock);
-
- /* Process according to mutex type: */
- switch ((*mutex)->m_protocol) {
- /* Default POSIX mutex: */
- case PTHREAD_PRIO_NONE:
- /*
- * Check if the running thread is not the owner of the
- * mutex:
- */
- if ((*mutex)->m_owner != _thread_run) {
- /*
- * Return an invalid argument error for no
- * owner and a permission error otherwise:
- */
- ret = (*mutex)->m_owner == NULL ? EINVAL : EPERM;
- }
- else if (((*mutex)->m_type == PTHREAD_MUTEX_RECURSIVE) &&
- ((*mutex)->m_data.m_count > 1)) {
- /* Decrement the count: */
- (*mutex)->m_data.m_count--;
- } else {
- /*
- * Clear the count in case this is recursive
- * mutex.
- */
- (*mutex)->m_data.m_count = 0;
-
- /* Remove the mutex from the threads queue. */
- _MUTEX_ASSERT_IS_OWNED(*mutex);
- TAILQ_REMOVE(&(*mutex)->m_owner->mutexq,
- (*mutex), m_qe);
- _MUTEX_INIT_LINK(*mutex);
-
- /*
- * Get the next thread from the queue of
- * threads waiting on the mutex:
- */
- if (((*mutex)->m_owner =
- mutex_queue_deq(*mutex)) != NULL) {
- /*
- * Allow the new owner of the mutex to
- * run:
- */
- PTHREAD_NEW_STATE((*mutex)->m_owner,
- PS_RUNNING);
-
- /*
- * Add the mutex to the threads list of
- * owned mutexes:
- */
- TAILQ_INSERT_TAIL(&(*mutex)->m_owner->mutexq,
- (*mutex), m_qe);
-
- /*
- * The owner is no longer waiting for
- * this mutex:
- */
- (*mutex)->m_owner->data.mutex = NULL;
- }
- }
- break;
-
- /* POSIX priority inheritence mutex: */
- case PTHREAD_PRIO_INHERIT:
- /*
- * Check if the running thread is not the owner of the
- * mutex:
- */
- if ((*mutex)->m_owner != _thread_run) {
- /*
- * Return an invalid argument error for no
- * owner and a permission error otherwise:
- */
- ret = (*mutex)->m_owner == NULL ? EINVAL : EPERM;
- }
- else if (((*mutex)->m_type == PTHREAD_MUTEX_RECURSIVE) &&
- ((*mutex)->m_data.m_count > 1)) {
- /* Decrement the count: */
- (*mutex)->m_data.m_count--;
- } else {
- /*
- * Clear the count in case this is recursive
- * mutex.
- */
- (*mutex)->m_data.m_count = 0;
-
- /*
- * Restore the threads inherited priority and
- * recompute the active priority (being careful
- * not to override changes in the threads base
- * priority subsequent to locking the mutex).
- */
- _thread_run->inherited_priority =
- (*mutex)->m_saved_prio;
- _thread_run->active_priority =
- MAX(_thread_run->inherited_priority,
- _thread_run->base_priority);
-
- /*
- * This thread now owns one less priority mutex.
- */
- _thread_run->priority_mutex_count--;
-
- /* Remove the mutex from the threads queue. */
- _MUTEX_ASSERT_IS_OWNED(*mutex);
- TAILQ_REMOVE(&(*mutex)->m_owner->mutexq,
- (*mutex), m_qe);
- _MUTEX_INIT_LINK(*mutex);
-
- /*
- * Get the next thread from the queue of threads
- * waiting on the mutex:
- */
- if (((*mutex)->m_owner =
- mutex_queue_deq(*mutex)) == NULL)
- /* This mutex has no priority. */
- (*mutex)->m_prio = 0;
- else {
- /*
- * Track number of priority mutexes owned:
- */
- (*mutex)->m_owner->priority_mutex_count++;
-
- /*
- * Add the mutex to the threads list
- * of owned mutexes:
- */
- TAILQ_INSERT_TAIL(&(*mutex)->m_owner->mutexq,
- (*mutex), m_qe);
-
- /*
- * The owner is no longer waiting for
- * this mutex:
- */
- (*mutex)->m_owner->data.mutex = NULL;
-
- /*
- * Set the priority of the mutex. Since
- * our waiting threads are in descending
- * priority order, the priority of the
- * mutex becomes the active priority of
- * the thread we just dequeued.
- */
- (*mutex)->m_prio =
- (*mutex)->m_owner->active_priority;
-
- /*
- * Save the owning threads inherited
- * priority:
- */
- (*mutex)->m_saved_prio =
- (*mutex)->m_owner->inherited_priority;
-
- /*
- * The owning threads inherited priority
- * now becomes his active priority (the
- * priority of the mutex).
- */
- (*mutex)->m_owner->inherited_priority =
- (*mutex)->m_prio;
-
- /*
- * Allow the new owner of the mutex to
- * run:
- */
- PTHREAD_NEW_STATE((*mutex)->m_owner,
- PS_RUNNING);
- }
- }
- break;
-
- /* POSIX priority ceiling mutex: */
- case PTHREAD_PRIO_PROTECT:
- /*
- * Check if the running thread is not the owner of the
- * mutex:
- */
- if ((*mutex)->m_owner != _thread_run) {
- /*
- * Return an invalid argument error for no
- * owner and a permission error otherwise:
- */
- ret = (*mutex)->m_owner == NULL ? EINVAL : EPERM;
- }
- else if (((*mutex)->m_type == PTHREAD_MUTEX_RECURSIVE) &&
- ((*mutex)->m_data.m_count > 1)) {
- /* Decrement the count: */
- (*mutex)->m_data.m_count--;
- } else {
- /*
- * Clear the count in case this is recursive
- * mutex.
- */
- (*mutex)->m_data.m_count = 0;
-
- /*
- * Restore the threads inherited priority and
- * recompute the active priority (being careful
- * not to override changes in the threads base
- * priority subsequent to locking the mutex).
- */
- _thread_run->inherited_priority =
- (*mutex)->m_saved_prio;
- _thread_run->active_priority =
- MAX(_thread_run->inherited_priority,
- _thread_run->base_priority);
-
- /*
- * This thread now owns one less priority mutex.
- */
- _thread_run->priority_mutex_count--;
-
- /* Remove the mutex from the threads queue. */
- _MUTEX_ASSERT_IS_OWNED(*mutex);
- TAILQ_REMOVE(&(*mutex)->m_owner->mutexq,
- (*mutex), m_qe);
- _MUTEX_INIT_LINK(*mutex);
-
- /*
- * Enter a loop to find a waiting thread whose
- * active priority will not cause a ceiling
- * violation:
- */
- while ((((*mutex)->m_owner =
- mutex_queue_deq(*mutex)) != NULL) &&
- ((*mutex)->m_owner->active_priority >
- (*mutex)->m_prio)) {
- /*
- * Either the mutex ceiling priority
- * been lowered and/or this threads
- * priority has been raised subsequent
- * to this thread being queued on the
- * waiting list.
- */
- (*mutex)->m_owner->error = EINVAL;
- PTHREAD_NEW_STATE((*mutex)->m_owner,
- PS_RUNNING);
- /*
- * The thread is no longer waiting for
- * this mutex:
- */
- (*mutex)->m_owner->data.mutex = NULL;
- }
-
- /* Check for a new owner: */
- if ((*mutex)->m_owner != NULL) {
- /*
- * Track number of priority mutexes owned:
- */
- (*mutex)->m_owner->priority_mutex_count++;
-
- /*
- * Add the mutex to the threads list
- * of owned mutexes:
- */
- TAILQ_INSERT_TAIL(&(*mutex)->m_owner->mutexq,
- (*mutex), m_qe);
-
- /*
- * The owner is no longer waiting for
- * this mutex:
- */
- (*mutex)->m_owner->data.mutex = NULL;
-
- /*
- * Save the owning threads inherited
- * priority:
- */
- (*mutex)->m_saved_prio =
- (*mutex)->m_owner->inherited_priority;
-
- /*
- * The owning thread inherits the
- * ceiling priority of the mutex and
- * executes at that priority:
- */
- (*mutex)->m_owner->inherited_priority =
- (*mutex)->m_prio;
- (*mutex)->m_owner->active_priority =
- (*mutex)->m_prio;
-
- /*
- * Allow the new owner of the mutex to
- * run:
- */
- PTHREAD_NEW_STATE((*mutex)->m_owner,
- PS_RUNNING);
- }
- }
- break;
-
- /* Trap invalid mutex types: */
- default:
- /* Return an invalid argument error: */
- ret = EINVAL;
- break;
- }
-
- if ((ret == 0) && (add_reference != 0)) {
- /* Increment the reference count: */
- (*mutex)->m_refcount++;
- }
-
- /* Unlock the mutex structure: */
- _SPINUNLOCK(&(*mutex)->lock);
-
- /*
- * Undefer and handle pending signals, yielding if
- * necessary:
- */
- _thread_kern_sig_undefer();
- }
-
- /* Return the completion status: */
- return (ret);
-}
-
-
-/*
- * This function is called when a change in base priority occurs for
- * a thread that is holding or waiting for a priority protection or
- * inheritence mutex. A change in a threads base priority can effect
- * changes to active priorities of other threads and to the ordering
- * of mutex locking by waiting threads.
- *
- * This must be called while thread scheduling is deferred.
- */
-void
-_mutex_notify_priochange(pthread_t pthread)
-{
- /* Adjust the priorites of any owned priority mutexes: */
- if (pthread->priority_mutex_count > 0) {
- /*
- * Rescan the mutexes owned by this thread and correct
- * their priorities to account for this threads change
- * in priority. This has the side effect of changing
- * the threads active priority.
- */
- mutex_rescan_owned(pthread, /* rescan all owned */ NULL);
- }
-
- /*
- * If this thread is waiting on a priority inheritence mutex,
- * check for priority adjustments. A change in priority can
- * also effect a ceiling violation(*) for a thread waiting on
- * a priority protection mutex; we don't perform the check here
- * as it is done in pthread_mutex_unlock.
- *
- * (*) It should be noted that a priority change to a thread
- * _after_ taking and owning a priority ceiling mutex
- * does not affect ownership of that mutex; the ceiling
- * priority is only checked before mutex ownership occurs.
- */
- if (pthread->state == PS_MUTEX_WAIT) {
- /* Lock the mutex structure: */
- _SPINLOCK(&pthread->data.mutex->lock);
-
- /*
- * Check to make sure this thread is still in the same state
- * (the spinlock above can yield the CPU to another thread):
- */
- if (pthread->state == PS_MUTEX_WAIT) {
- /*
- * Remove and reinsert this thread into the list of
- * waiting threads to preserve decreasing priority
- * order.
- */
- mutex_queue_remove(pthread->data.mutex, pthread);
- mutex_queue_enq(pthread->data.mutex, pthread);
-
- if (pthread->data.mutex->m_protocol ==
- PTHREAD_PRIO_INHERIT) {
- /* Adjust priorities: */
- mutex_priority_adjust(pthread->data.mutex);
- }
- }
-
- /* Unlock the mutex structure: */
- _SPINUNLOCK(&pthread->data.mutex->lock);
- }
-}
-
-/*
- * Called when a new thread is added to the mutex waiting queue or
- * when a threads priority changes that is already in the mutex
- * waiting queue.
- */
-static void
-mutex_priority_adjust(pthread_mutex_t mutex)
-{
- pthread_t pthread_next, pthread = mutex->m_owner;
- int temp_prio;
- pthread_mutex_t m = mutex;
-
- /*
- * Calculate the mutex priority as the maximum of the highest
- * active priority of any waiting threads and the owning threads
- * active priority(*).
- *
- * (*) Because the owning threads current active priority may
- * reflect priority inherited from this mutex (and the mutex
- * priority may have changed) we must recalculate the active
- * priority based on the threads saved inherited priority
- * and its base priority.
- */
- pthread_next = TAILQ_FIRST(&m->m_queue); /* should never be NULL */
- temp_prio = MAX(pthread_next->active_priority,
- MAX(m->m_saved_prio, pthread->base_priority));
-
- /* See if this mutex really needs adjusting: */
- if (temp_prio == m->m_prio)
- /* No need to propagate the priority: */
- return;
-
- /* Set new priority of the mutex: */
- m->m_prio = temp_prio;
-
- while (m != NULL) {
- /*
- * Save the threads priority before rescanning the
- * owned mutexes:
- */
- temp_prio = pthread->active_priority;
-
- /*
- * Fix the priorities for all the mutexes this thread has
- * locked since taking this mutex. This also has a
- * potential side-effect of changing the threads priority.
- */
- mutex_rescan_owned(pthread, m);
-
- /*
- * If the thread is currently waiting on a mutex, check
- * to see if the threads new priority has affected the
- * priority of the mutex.
- */
- if ((temp_prio != pthread->active_priority) &&
- (pthread->state == PS_MUTEX_WAIT) &&
- (pthread->data.mutex->m_protocol == PTHREAD_PRIO_INHERIT)) {
- /* Grab the mutex this thread is waiting on: */
- m = pthread->data.mutex;
-
- /*
- * The priority for this thread has changed. Remove
- * and reinsert this thread into the list of waiting
- * threads to preserve decreasing priority order.
- */
- mutex_queue_remove(m, pthread);
- mutex_queue_enq(m, pthread);
-
- /* Grab the waiting thread with highest priority: */
- pthread_next = TAILQ_FIRST(&m->m_queue);
-
- /*
- * Calculate the mutex priority as the maximum of the
- * highest active priority of any waiting threads and
- * the owning threads active priority.
- */
- temp_prio = MAX(pthread_next->active_priority,
- MAX(m->m_saved_prio, m->m_owner->base_priority));
-
- if (temp_prio != m->m_prio) {
- /*
- * The priority needs to be propagated to the
- * mutex this thread is waiting on and up to
- * the owner of that mutex.
- */
- m->m_prio = temp_prio;
- pthread = m->m_owner;
- }
- else
- /* We're done: */
- m = NULL;
-
- }
- else
- /* We're done: */
- m = NULL;
- }
-}
-
-static void
-mutex_rescan_owned(pthread_t pthread, pthread_mutex_t mutex)
-{
- int active_prio, inherited_prio;
- pthread_mutex_t m;
- pthread_t pthread_next;
-
- /*
- * Start walking the mutexes the thread has taken since
- * taking this mutex.
- */
- if (mutex == NULL) {
- /*
- * A null mutex means start at the beginning of the owned
- * mutex list.
- */
- m = TAILQ_FIRST(&pthread->mutexq);
-
- /* There is no inherited priority yet. */
- inherited_prio = 0;
- }
- else {
- /*
- * The caller wants to start after a specific mutex. It
- * is assumed that this mutex is a priority inheritence
- * mutex and that its priority has been correctly
- * calculated.
- */
- m = TAILQ_NEXT(mutex, m_qe);
-
- /* Start inheriting priority from the specified mutex. */
- inherited_prio = mutex->m_prio;
- }
- active_prio = MAX(inherited_prio, pthread->base_priority);
-
- while (m != NULL) {
- /*
- * We only want to deal with priority inheritence
- * mutexes. This might be optimized by only placing
- * priority inheritence mutexes into the owned mutex
- * list, but it may prove to be useful having all
- * owned mutexes in this list. Consider a thread
- * exiting while holding mutexes...
- */
- if (m->m_protocol == PTHREAD_PRIO_INHERIT) {
- /*
- * Fix the owners saved (inherited) priority to
- * reflect the priority of the previous mutex.
- */
- m->m_saved_prio = inherited_prio;
-
- if ((pthread_next = TAILQ_FIRST(&m->m_queue)) != NULL)
- /* Recalculate the priority of the mutex: */
- m->m_prio = MAX(active_prio,
- pthread_next->active_priority);
- else
- m->m_prio = active_prio;
-
- /* Recalculate new inherited and active priorities: */
- inherited_prio = m->m_prio;
- active_prio = MAX(m->m_prio, pthread->base_priority);
- }
-
- /* Advance to the next mutex owned by this thread: */
- m = TAILQ_NEXT(m, m_qe);
- }
-
- /*
- * Fix the threads inherited priority and recalculate its
- * active priority.
- */
- pthread->inherited_priority = inherited_prio;
- active_prio = MAX(inherited_prio, pthread->base_priority);
-
- if (active_prio != pthread->active_priority) {
- /*
- * If this thread is in the priority queue, it must be
- * removed and reinserted for its new priority.
- */
- if (pthread->flags & PTHREAD_FLAGS_IN_PRIOQ) {
- /*
- * Remove the thread from the priority queue
- * before changing its priority:
- */
- PTHREAD_PRIOQ_REMOVE(pthread);
-
- /*
- * POSIX states that if the priority is being
- * lowered, the thread must be inserted at the
- * head of the queue for its priority if it owns
- * any priority protection or inheritence mutexes.
- */
- if ((active_prio < pthread->active_priority) &&
- (pthread->priority_mutex_count > 0)) {
- /* Set the new active priority. */
- pthread->active_priority = active_prio;
-
- PTHREAD_PRIOQ_INSERT_HEAD(pthread);
- }
- else {
- /* Set the new active priority. */
- pthread->active_priority = active_prio;
-
- PTHREAD_PRIOQ_INSERT_TAIL(pthread);
- }
- }
- else {
- /* Set the new active priority. */
- pthread->active_priority = active_prio;
- }
- }
-}
-
-void
-_mutex_unlock_private(pthread_t pthread)
-{
- struct pthread_mutex *m, *m_next;
-
- for (m = TAILQ_FIRST(&pthread->mutexq); m != NULL; m = m_next) {
- m_next = TAILQ_NEXT(m, m_qe);
- if ((m->m_flags & MUTEX_FLAGS_PRIVATE) != 0)
- pthread_mutex_unlock(&m);
- }
-}
-
-/*
- * Dequeue a waiting thread from the head of a mutex queue in descending
- * priority order.
- */
-static inline pthread_t
-mutex_queue_deq(pthread_mutex_t mutex)
-{
- pthread_t pthread;
-
- while ((pthread = TAILQ_FIRST(&mutex->m_queue)) != NULL) {
- TAILQ_REMOVE(&mutex->m_queue, pthread, qe);
- pthread->flags &= ~PTHREAD_FLAGS_IN_MUTEXQ;
-
- /*
- * Only exit the loop if the thread hasn't been
- * cancelled.
- */
- if (pthread->interrupted == 0)
- break;
- }
-
- return(pthread);
-}
-
-/*
- * Remove a waiting thread from a mutex queue in descending priority order.
- */
-static inline void
-mutex_queue_remove(pthread_mutex_t mutex, pthread_t pthread)
-{
- if ((pthread->flags & PTHREAD_FLAGS_IN_MUTEXQ) != 0) {
- TAILQ_REMOVE(&mutex->m_queue, pthread, qe);
- pthread->flags &= ~PTHREAD_FLAGS_IN_MUTEXQ;
- }
-}
-
-/*
- * Enqueue a waiting thread to a queue in descending priority order.
- */
-static inline void
-mutex_queue_enq(pthread_mutex_t mutex, pthread_t pthread)
-{
- pthread_t tid = TAILQ_LAST(&mutex->m_queue, mutex_head);
-
- /*
- * For the common case of all threads having equal priority,
- * we perform a quick check against the priority of the thread
- * at the tail of the queue.
- */
- if ((tid == NULL) || (pthread->active_priority <= tid->active_priority))
- TAILQ_INSERT_TAIL(&mutex->m_queue, pthread, qe);
- else {
- tid = TAILQ_FIRST(&mutex->m_queue);
- while (pthread->active_priority <= tid->active_priority)
- tid = TAILQ_NEXT(tid, qe);
- TAILQ_INSERT_BEFORE(tid, pthread, qe);
- }
- pthread->flags |= PTHREAD_FLAGS_IN_MUTEXQ;
-}
-
-#endif
diff --git a/lib/libpthread/thread/thr_mutex_prioceiling.c b/lib/libpthread/thread/thr_mutex_prioceiling.c
deleted file mode 100644
index c193c82a9c80..000000000000
--- a/lib/libpthread/thread/thr_mutex_prioceiling.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>.
- * 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 Daniel Eischen.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_mutexattr_getprioceiling(pthread_mutexattr_t *mattr, int *prioceiling)
-{
- int ret = 0;
-
- if ((mattr == NULL) || (*mattr == NULL))
- ret = EINVAL;
- else if ((*mattr)->m_protocol != PTHREAD_PRIO_PROTECT)
- ret = EINVAL;
- else
- *prioceiling = (*mattr)->m_ceiling;
-
- return(ret);
-}
-
-int
-pthread_mutexattr_setprioceiling(pthread_mutexattr_t *mattr, int prioceiling)
-{
- int ret = 0;
-
- if ((mattr == NULL) || (*mattr == NULL))
- ret = EINVAL;
- else if ((*mattr)->m_protocol != PTHREAD_PRIO_PROTECT)
- ret = EINVAL;
- else
- (*mattr)->m_ceiling = prioceiling;
-
- return(ret);
-}
-
-int
-pthread_mutex_getprioceiling(pthread_mutex_t *mutex,
- int *prioceiling)
-{
- int ret;
-
- if ((mutex == NULL) || (*mutex == NULL))
- ret = EINVAL;
- else if ((*mutex)->m_protocol != PTHREAD_PRIO_PROTECT)
- ret = EINVAL;
- else
- ret = (*mutex)->m_prio;
-
- return(ret);
-}
-
-int
-pthread_mutex_setprioceiling(pthread_mutex_t *mutex,
- int prioceiling, int *old_ceiling)
-{
- int ret = 0;
-
- if ((mutex == NULL) || (*mutex == NULL))
- ret = EINVAL;
- else if ((*mutex)->m_protocol != PTHREAD_PRIO_PROTECT)
- ret = EINVAL;
- else {
- /* Lock the mutex: */
- if ((ret = pthread_mutex_lock(mutex)) == 0) {
- /* Return the old ceiling and set the new ceiling: */
- *old_ceiling = (*mutex)->m_prio;
- (*mutex)->m_prio = prioceiling;
-
- /* Unlock the mutex: */
- ret = pthread_mutex_unlock(mutex);
- }
- }
- return(ret);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_mutex_protocol.c b/lib/libpthread/thread/thr_mutex_protocol.c
deleted file mode 100644
index 9847ae529eb8..000000000000
--- a/lib/libpthread/thread/thr_mutex_protocol.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>.
- * 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 Daniel Eischen.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_mutexattr_getprotocol(pthread_mutexattr_t *mattr, int *protocol)
-{
- int ret = 0;
-
- if ((mattr == NULL) || (*mattr == NULL))
- ret = EINVAL;
- else
- *protocol = (*mattr)->m_protocol;
-
- return(ret);
-}
-
-int
-pthread_mutexattr_setprotocol(pthread_mutexattr_t *mattr, int protocol)
-{
- int ret = 0;
-
- if ((mattr == NULL) || (*mattr == NULL) ||
- (protocol < PTHREAD_PRIO_NONE) || (protocol > PTHREAD_PRIO_PROTECT))
- ret = EINVAL;
- else {
- (*mattr)->m_protocol = protocol;
- (*mattr)->m_ceiling = PTHREAD_MAX_PRIORITY;
- }
- return(ret);
-}
-
-#endif
diff --git a/lib/libpthread/thread/thr_mutexattr_destroy.c b/lib/libpthread/thread/thr_mutexattr_destroy.c
deleted file mode 100644
index 6eed2a256019..000000000000
--- a/lib/libpthread/thread/thr_mutexattr_destroy.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <stdlib.h>
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_mutexattr_destroy(pthread_mutexattr_t *attr)
-{
- int ret;
- if (attr == NULL || *attr == NULL) {
- ret = EINVAL;
- } else {
- free(*attr);
- *attr = NULL;
- ret = 0;
- }
- return(ret);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_nanosleep.c b/lib/libpthread/thread/thr_nanosleep.c
deleted file mode 100644
index 3bbc9a64fce6..000000000000
--- a/lib/libpthread/thread/thr_nanosleep.c
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <stdio.h>
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-_nanosleep(const struct timespec * time_to_sleep,
- struct timespec * time_remaining)
-{
- int ret = 0;
- struct timespec current_time;
- struct timespec current_time1;
- struct timespec remaining_time;
- struct timeval tv;
-
- /* Check if the time to sleep is legal: */
- if (time_to_sleep == NULL || time_to_sleep->tv_sec < 0 ||
- time_to_sleep->tv_nsec < 0 || time_to_sleep->tv_nsec >= 1000000000) {
- /* Return an EINVAL error : */
- errno = EINVAL;
- ret = -1;
- } else {
- /* Get the current time: */
- gettimeofday(&tv, NULL);
- TIMEVAL_TO_TIMESPEC(&tv, &current_time);
-
- /* Calculate the time for the current thread to wake up: */
- _thread_run->wakeup_time.tv_sec = current_time.tv_sec + time_to_sleep->tv_sec;
- _thread_run->wakeup_time.tv_nsec = current_time.tv_nsec + time_to_sleep->tv_nsec;
-
- /* Check if the nanosecond field has overflowed: */
- if (_thread_run->wakeup_time.tv_nsec >= 1000000000) {
- /* Wrap the nanosecond field: */
- _thread_run->wakeup_time.tv_sec += 1;
- _thread_run->wakeup_time.tv_nsec -= 1000000000;
- }
- _thread_run->interrupted = 0;
-
- /* Reschedule the current thread to sleep: */
- _thread_kern_sched_state(PS_SLEEP_WAIT, __FILE__, __LINE__);
-
- /* Get the current time: */
- gettimeofday(&tv, NULL);
- TIMEVAL_TO_TIMESPEC(&tv, &current_time1);
-
- /* Calculate the remaining time to sleep: */
- remaining_time.tv_sec = time_to_sleep->tv_sec + current_time.tv_sec - current_time1.tv_sec;
- remaining_time.tv_nsec = time_to_sleep->tv_nsec + current_time.tv_nsec - current_time1.tv_nsec;
-
- /* Check if the nanosecond field has underflowed: */
- if (remaining_time.tv_nsec < 0) {
- /* Handle the underflow: */
- remaining_time.tv_sec -= 1;
- remaining_time.tv_nsec += 1000000000;
- }
-
- /* Check if the nanosecond field has overflowed: */
- if (remaining_time.tv_nsec >= 1000000000) {
- /* Handle the overflow: */
- remaining_time.tv_sec += 1;
- remaining_time.tv_nsec -= 1000000000;
- }
-
- /* Check if the sleep was longer than the required time: */
- if (remaining_time.tv_sec < 0) {
- /* Reset the time left: */
- remaining_time.tv_sec = 0;
- remaining_time.tv_nsec = 0;
- }
-
- /* Check if the time remaining is to be returned: */
- if (time_remaining != NULL) {
- /* Return the actual time slept: */
- time_remaining->tv_sec = remaining_time.tv_sec;
- time_remaining->tv_nsec = remaining_time.tv_nsec;
- }
-
- /* Check if the sleep was interrupted: */
- if (_thread_run->interrupted) {
- /* Return an EINTR error : */
- errno = EINTR;
- ret = -1;
- }
- }
- return (ret);
-}
-
-int
-nanosleep(const struct timespec * time_to_sleep, struct timespec *
- time_remaining)
-{
- int ret;
-
- _thread_enter_cancellation_point();
- ret = _nanosleep(time_to_sleep, time_remaining);
- _thread_leave_cancellation_point();
-
- return ret;
-}
-#endif
diff --git a/lib/libpthread/thread/thr_once.c b/lib/libpthread/thread/thr_once.c
deleted file mode 100644
index ea56d82c4d83..000000000000
--- a/lib/libpthread/thread/thr_once.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_once(pthread_once_t * once_control, void (*init_routine) (void))
-{
- if (once_control->state == PTHREAD_NEEDS_INIT) {
- pthread_mutex_lock(&(once_control->mutex));
- if (once_control->state == PTHREAD_NEEDS_INIT) {
- init_routine();
- once_control->state = PTHREAD_DONE_INIT;
- }
- pthread_mutex_unlock(&(once_control->mutex));
- }
- return (0);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_open.c b/lib/libpthread/thread/thr_open.c
deleted file mode 100644
index e7fef91f8e5d..000000000000
--- a/lib/libpthread/thread/thr_open.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- *
- */
-#include <stdarg.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <dirent.h>
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-_open(const char *path, int flags,...)
-{
- int fd;
- int mode = 0;
- va_list ap;
-
- /* Check if the file is being created: */
- if (flags & O_CREAT) {
- /* Get the creation mode: */
- va_start(ap, flags);
- mode = va_arg(ap, int);
- va_end(ap);
- }
- /* Open the file: */
- if ((fd = _thread_sys_open(path, flags, mode)) < 0) {
- }
- /* Initialise the file descriptor table entry: */
- else if (_thread_fd_table_init(fd) != 0) {
- /* Quietly close the file: */
- _thread_sys_close(fd);
-
- /* Reset the file descriptor: */
- fd = -1;
- }
-
- /* Return the file descriptor or -1 on error: */
- return (fd);
-}
-
-int
-open(const char *path, int flags,...)
-{
- int ret;
- int mode = 0;
- va_list ap;
-
- _thread_enter_cancellation_point();
-
- /* Check if the file is being created: */
- if (flags & O_CREAT) {
- /* Get the creation mode: */
- va_start(ap, flags);
- mode = va_arg(ap, int);
- va_end(ap);
- }
-
- ret = _open(path, flags, mode);
- _thread_leave_cancellation_point();
-
- return ret;
-}
-#endif
diff --git a/lib/libpthread/thread/thr_pause.c b/lib/libpthread/thread/thr_pause.c
deleted file mode 100644
index a841556dc895..000000000000
--- a/lib/libpthread/thread/thr_pause.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2000 Jason Evans <jasone@canonware.com>.
- * 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(s), this list of conditions and the following disclaimer as
- * the first lines of this file unmodified other than the possible
- * addition of one or more copyright notices.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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.
- *
- * $FreeBSD$
- */
-
-#include <unistd.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pause(void)
-{
- int ret;
-
- _thread_enter_cancellation_point();
- ret = __pause();
- _thread_leave_cancellation_point();
-
- return ret;
-}
-#endif
diff --git a/lib/libpthread/thread/thr_poll.c b/lib/libpthread/thread/thr_poll.c
deleted file mode 100644
index 3717273da084..000000000000
--- a/lib/libpthread/thread/thr_poll.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (c) 1999 Daniel Eischen <eischen@vigrid.com>
- * 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 Daniel Eischen.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <unistd.h>
-#include <errno.h>
-#include <string.h>
-#include <poll.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/fcntl.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-
-int
-_poll(struct pollfd *fds, unsigned int nfds, int timeout)
-{
- struct timespec ts;
- int numfds = nfds;
- int i, ret = 0;
- struct pthread_poll_data data;
-
- if (numfds > _thread_dtablesize) {
- numfds = _thread_dtablesize;
- }
- /* Check if a timeout was specified: */
- if (timeout == INFTIM) {
- /* Wait for ever: */
- _thread_kern_set_timeout(NULL);
- } else if (timeout > 0) {
- /* Convert the timeout in msec to a timespec: */
- ts.tv_sec = timeout / 1000;
- ts.tv_nsec = (timeout % 1000) * 1000000;
-
- /* Set the wake up time: */
- _thread_kern_set_timeout(&ts);
- } else if (timeout < 0) {
- /* a timeout less than zero but not == INFTIM is invalid */
- errno = EINVAL;
- return (-1);
- }
-
- if (((ret = _thread_sys_poll(fds, numfds, 0)) == 0) && (timeout != 0)) {
- data.nfds = numfds;
- data.fds = fds;
-
- /*
- * Clear revents in case of a timeout which leaves fds
- * unchanged:
- */
- for (i = 0; i < numfds; i++) {
- fds[i].revents = 0;
- }
-
- _thread_run->data.poll_data = &data;
- _thread_run->interrupted = 0;
- _thread_kern_sched_state(PS_POLL_WAIT, __FILE__, __LINE__);
- if (_thread_run->interrupted) {
- errno = EINTR;
- ret = -1;
- } else {
- ret = data.nfds;
- }
- }
-
- return (ret);
-}
-
-__strong_reference(_poll, poll);
-#endif
diff --git a/lib/libpthread/thread/thr_priority_queue.c b/lib/libpthread/thread/thr_priority_queue.c
deleted file mode 100644
index 1b9fcba09573..000000000000
--- a/lib/libpthread/thread/thr_priority_queue.c
+++ /dev/null
@@ -1,335 +0,0 @@
-/*
- * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>.
- * 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 Daniel Eischen.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <stdlib.h>
-#include <sys/queue.h>
-#include <string.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-/* Prototypes: */
-static void pq_insert_prio_list(pq_queue_t *pq, int prio);
-
-#if defined(_PTHREADS_INVARIANTS)
-
-static int _pq_active = 0;
-
-#define _PQ_IN_SCHEDQ (PTHREAD_FLAGS_IN_PRIOQ | PTHREAD_FLAGS_IN_WAITQ | PTHREAD_FLAGS_IN_WORKQ)
-
-#define _PQ_SET_ACTIVE() _pq_active = 1
-#define _PQ_CLEAR_ACTIVE() _pq_active = 0
-#define _PQ_ASSERT_ACTIVE(msg) do { \
- if (_pq_active == 0) \
- PANIC(msg); \
-} while (0)
-#define _PQ_ASSERT_INACTIVE(msg) do { \
- if (_pq_active != 0) \
- PANIC(msg); \
-} while (0)
-#define _PQ_ASSERT_IN_WAITQ(thrd, msg) do { \
- if (((thrd)->flags & PTHREAD_FLAGS_IN_WAITQ) == 0) \
- PANIC(msg); \
-} while (0)
-#define _PQ_ASSERT_IN_PRIOQ(thrd, msg) do { \
- if (((thrd)->flags & PTHREAD_FLAGS_IN_PRIOQ) == 0) \
- PANIC(msg); \
-} while (0)
-#define _PQ_ASSERT_NOT_QUEUED(thrd, msg) do { \
- if ((thrd)->flags & _PQ_IN_SCHEDQ) \
- PANIC(msg); \
-} while (0)
-
-#else
-
-#define _PQ_SET_ACTIVE()
-#define _PQ_CLEAR_ACTIVE()
-#define _PQ_ASSERT_ACTIVE(msg)
-#define _PQ_ASSERT_INACTIVE(msg)
-#define _PQ_ASSERT_IN_WAITQ(thrd, msg)
-#define _PQ_ASSERT_IN_PRIOQ(thrd, msg)
-#define _PQ_ASSERT_NOT_QUEUED(thrd, msg)
-#define _PQ_CHECK_PRIO()
-
-#endif
-
-
-int
-_pq_alloc(pq_queue_t *pq, int minprio, int maxprio)
-{
- int ret = 0;
- int prioslots = maxprio - minprio + 1;
-
- if (pq == NULL)
- ret = -1;
-
- /* Create the priority queue with (maxprio - minprio + 1) slots: */
- else if ((pq->pq_lists =
- (pq_list_t *) malloc(sizeof(pq_list_t) * prioslots)) == NULL)
- ret = -1;
-
- else {
- /* Remember the queue size: */
- pq->pq_size = prioslots;
-
- ret = _pq_init(pq);
-
- }
- return (ret);
-}
-
-int
-_pq_init(pq_queue_t *pq)
-{
- int i, ret = 0;
-
- if ((pq == NULL) || (pq->pq_lists == NULL))
- ret = -1;
-
- else {
- /* Initialize the queue for each priority slot: */
- for (i = 0; i < pq->pq_size; i++) {
- TAILQ_INIT(&pq->pq_lists[i].pl_head);
- pq->pq_lists[i].pl_prio = i;
- pq->pq_lists[i].pl_queued = 0;
- }
-
- /* Initialize the priority queue: */
- TAILQ_INIT(&pq->pq_queue);
- _PQ_CLEAR_ACTIVE();
- }
- return (ret);
-}
-
-void
-_pq_remove(pq_queue_t *pq, pthread_t pthread)
-{
- int prio = pthread->active_priority;
-
- /*
- * Make some assertions when debugging is enabled:
- */
- _PQ_ASSERT_INACTIVE("_pq_remove: pq_active");
- _PQ_SET_ACTIVE();
- _PQ_ASSERT_IN_PRIOQ(pthread, "_pq_remove: Not in priority queue");
-
- /*
- * Remove this thread from priority list. Note that if
- * the priority list becomes empty, it is not removed
- * from the priority queue because another thread may be
- * added to the priority list (resulting in a needless
- * removal/insertion). Priority lists are only removed
- * from the priority queue when _pq_first is called.
- */
- TAILQ_REMOVE(&pq->pq_lists[prio].pl_head, pthread, pqe);
-
- /* This thread is now longer in the priority queue. */
- pthread->flags &= ~PTHREAD_FLAGS_IN_PRIOQ;
-
- _PQ_CLEAR_ACTIVE();
-}
-
-
-void
-_pq_insert_head(pq_queue_t *pq, pthread_t pthread)
-{
- int prio = pthread->active_priority;
-
- /*
- * Make some assertions when debugging is enabled:
- */
- _PQ_ASSERT_INACTIVE("_pq_insert_head: pq_active");
- _PQ_SET_ACTIVE();
- _PQ_ASSERT_NOT_QUEUED(pthread,
- "_pq_insert_head: Already in priority queue");
-
- TAILQ_INSERT_HEAD(&pq->pq_lists[prio].pl_head, pthread, pqe);
- if (pq->pq_lists[prio].pl_queued == 0)
- /* Insert the list into the priority queue: */
- pq_insert_prio_list(pq, prio);
-
- /* Mark this thread as being in the priority queue. */
- pthread->flags |= PTHREAD_FLAGS_IN_PRIOQ;
-
- _PQ_CLEAR_ACTIVE();
-}
-
-
-void
-_pq_insert_tail(pq_queue_t *pq, pthread_t pthread)
-{
- int prio = pthread->active_priority;
-
- /*
- * Make some assertions when debugging is enabled:
- */
- _PQ_ASSERT_INACTIVE("_pq_insert_tail: pq_active");
- _PQ_SET_ACTIVE();
- _PQ_ASSERT_NOT_QUEUED(pthread,
- "_pq_insert_tail: Already in priority queue");
-
- TAILQ_INSERT_TAIL(&pq->pq_lists[prio].pl_head, pthread, pqe);
- if (pq->pq_lists[prio].pl_queued == 0)
- /* Insert the list into the priority queue: */
- pq_insert_prio_list(pq, prio);
-
- /* Mark this thread as being in the priority queue. */
- pthread->flags |= PTHREAD_FLAGS_IN_PRIOQ;
-
- _PQ_CLEAR_ACTIVE();
-}
-
-
-pthread_t
-_pq_first(pq_queue_t *pq)
-{
- pq_list_t *pql;
- pthread_t pthread = NULL;
-
- /*
- * Make some assertions when debugging is enabled:
- */
- _PQ_ASSERT_INACTIVE("_pq_first: pq_active");
- _PQ_SET_ACTIVE();
-
- while (((pql = TAILQ_FIRST(&pq->pq_queue)) != NULL) &&
- (pthread == NULL)) {
- if ((pthread = TAILQ_FIRST(&pql->pl_head)) == NULL) {
- /*
- * The priority list is empty; remove the list
- * from the queue.
- */
- TAILQ_REMOVE(&pq->pq_queue, pql, pl_link);
-
- /* Mark the list as not being in the queue: */
- pql->pl_queued = 0;
- }
- }
-
- _PQ_CLEAR_ACTIVE();
- return (pthread);
-}
-
-
-static void
-pq_insert_prio_list(pq_queue_t *pq, int prio)
-{
- pq_list_t *pql;
-
- /*
- * Make some assertions when debugging is enabled:
- */
- _PQ_ASSERT_ACTIVE("pq_insert_prio_list: pq_active");
-
- /*
- * The priority queue is in descending priority order. Start at
- * the beginning of the queue and find the list before which the
- * new list should be inserted.
- */
- pql = TAILQ_FIRST(&pq->pq_queue);
- while ((pql != NULL) && (pql->pl_prio > prio))
- pql = TAILQ_NEXT(pql, pl_link);
-
- /* Insert the list: */
- if (pql == NULL)
- TAILQ_INSERT_TAIL(&pq->pq_queue, &pq->pq_lists[prio], pl_link);
- else
- TAILQ_INSERT_BEFORE(pql, &pq->pq_lists[prio], pl_link);
-
- /* Mark this list as being in the queue: */
- pq->pq_lists[prio].pl_queued = 1;
-}
-
-#if defined(_PTHREADS_INVARIANTS)
-void
-_waitq_insert(pthread_t pthread)
-{
- pthread_t tid;
-
- /*
- * Make some assertions when debugging is enabled:
- */
- _PQ_ASSERT_INACTIVE("_waitq_insert: pq_active");
- _PQ_SET_ACTIVE();
- _PQ_ASSERT_NOT_QUEUED(pthread, "_waitq_insert: Already in queue");
-
- if (pthread->wakeup_time.tv_sec == -1)
- TAILQ_INSERT_TAIL(&_waitingq, pthread, pqe);
- else {
- tid = TAILQ_FIRST(&_waitingq);
- while ((tid != NULL) && (tid->wakeup_time.tv_sec != -1) &&
- ((tid->wakeup_time.tv_sec < pthread->wakeup_time.tv_sec) ||
- ((tid->wakeup_time.tv_sec == pthread->wakeup_time.tv_sec) &&
- (tid->wakeup_time.tv_nsec <= pthread->wakeup_time.tv_nsec))))
- tid = TAILQ_NEXT(tid, pqe);
- if (tid == NULL)
- TAILQ_INSERT_TAIL(&_waitingq, pthread, pqe);
- else
- TAILQ_INSERT_BEFORE(tid, pthread, pqe);
- }
- pthread->flags |= PTHREAD_FLAGS_IN_WAITQ;
-
- _PQ_CLEAR_ACTIVE();
-}
-
-void
-_waitq_remove(pthread_t pthread)
-{
- /*
- * Make some assertions when debugging is enabled:
- */
- _PQ_ASSERT_INACTIVE("_waitq_remove: pq_active");
- _PQ_SET_ACTIVE();
- _PQ_ASSERT_IN_WAITQ(pthread, "_waitq_remove: Not in queue");
-
- TAILQ_REMOVE(&_waitingq, pthread, pqe);
- pthread->flags &= ~PTHREAD_FLAGS_IN_WAITQ;
-
- _PQ_CLEAR_ACTIVE();
-}
-
-void
-_waitq_setactive(void)
-{
- _PQ_ASSERT_INACTIVE("_waitq_setactive: pq_active");
- _PQ_SET_ACTIVE();
-}
-
-void
-_waitq_clearactive(void)
-{
- _PQ_ASSERT_ACTIVE("_waitq_clearactive: ! pq_active");
- _PQ_CLEAR_ACTIVE();
-}
-#endif
-#endif
diff --git a/lib/libpthread/thread/thr_private.h b/lib/libpthread/thread/thr_private.h
deleted file mode 100644
index 962eb86957af..000000000000
--- a/lib/libpthread/thread/thr_private.h
+++ /dev/null
@@ -1,1254 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * Private thread definitions for the uthread kernel.
- *
- * $FreeBSD$
- */
-
-#ifndef _PTHREAD_PRIVATE_H
-#define _PTHREAD_PRIVATE_H
-
-/*
- * Evaluate the storage class specifier.
- */
-#ifdef GLOBAL_PTHREAD_PRIVATE
-#define SCLASS
-#else
-#define SCLASS extern
-#endif
-
-/*
- * Include files.
- */
-#include <setjmp.h>
-#include <signal.h>
-#include <sys/queue.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sched.h>
-#include <spinlock.h>
-#include <pthread_np.h>
-
-/*
- * Kernel fatal error handler macro.
- */
-#define PANIC(string) _thread_exit(__FILE__,__LINE__,string)
-
-/* Output debug messages like this: */
-#define stdout_debug(_x) _thread_sys_write(1,_x,strlen(_x));
-#define stderr_debug(_x) _thread_sys_write(2,_x,strlen(_x));
-
-
-/*
- * Priority queue manipulation macros (using pqe link):
- */
-#define PTHREAD_PRIOQ_INSERT_HEAD(thrd) _pq_insert_head(&_readyq,thrd)
-#define PTHREAD_PRIOQ_INSERT_TAIL(thrd) _pq_insert_tail(&_readyq,thrd)
-#define PTHREAD_PRIOQ_REMOVE(thrd) _pq_remove(&_readyq,thrd)
-#define PTHREAD_PRIOQ_FIRST() _pq_first(&_readyq)
-
-/*
- * Waiting queue manipulation macros (using pqe link):
- */
-#if defined(_PTHREADS_INVARIANTS)
-#define PTHREAD_WAITQ_REMOVE(thrd) _waitq_remove(thrd)
-#define PTHREAD_WAITQ_INSERT(thrd) _waitq_insert(thrd)
-#define PTHREAD_WAITQ_CLEARACTIVE() _waitq_clearactive()
-#define PTHREAD_WAITQ_SETACTIVE() _waitq_setactive()
-#else
-#define PTHREAD_WAITQ_REMOVE(thrd) do { \
- TAILQ_REMOVE(&_waitingq,thrd,pqe); \
- (thrd)->flags &= ~PTHREAD_FLAGS_IN_WAITQ; \
-} while (0)
-
-#define PTHREAD_WAITQ_INSERT(thrd) do { \
- if ((thrd)->wakeup_time.tv_sec == -1) \
- TAILQ_INSERT_TAIL(&_waitingq,thrd,pqe); \
- else { \
- pthread_t tid = TAILQ_FIRST(&_waitingq); \
- while ((tid != NULL) && (tid->wakeup_time.tv_sec != -1) && \
- ((tid->wakeup_time.tv_sec < (thrd)->wakeup_time.tv_sec) || \
- ((tid->wakeup_time.tv_sec == (thrd)->wakeup_time.tv_sec) && \
- (tid->wakeup_time.tv_nsec <= (thrd)->wakeup_time.tv_nsec)))) \
- tid = TAILQ_NEXT(tid, pqe); \
- if (tid == NULL) \
- TAILQ_INSERT_TAIL(&_waitingq,thrd,pqe); \
- else \
- TAILQ_INSERT_BEFORE(tid,thrd,pqe); \
- } \
- (thrd)->flags | PTHREAD_FLAGS_IN_WAITQ; \
-} while (0)
-#define PTHREAD_WAITQ_CLEARACTIVE()
-#define PTHREAD_WAITQ_SETACTIVE()
-#endif
-
-/*
- * Work queue manipulation macros (using qe link):
- */
-#define PTHREAD_WORKQ_INSERT(thrd) do { \
- TAILQ_INSERT_TAIL(&_workq,thrd,qe); \
- (thrd)->flags |= PTHREAD_FLAGS_IN_WORKQ; \
-} while (0)
-#define PTHREAD_WORKQ_REMOVE(thrd) do { \
- TAILQ_REMOVE(&_workq,thrd,qe); \
- (thrd)->flags &= ~PTHREAD_FLAGS_IN_WORKQ; \
-} while (0)
-
-
-/*
- * State change macro without scheduling queue change:
- */
-#define PTHREAD_SET_STATE(thrd, newstate) do { \
- (thrd)->state = newstate; \
- (thrd)->fname = __FILE__; \
- (thrd)->lineno = __LINE__; \
-} while (0)
-
-/*
- * State change macro with scheduling queue change - This must be
- * called with preemption deferred (see thread_kern_sched_[un]defer).
- */
-#if defined(_PTHREADS_INVARIANTS)
-#define PTHREAD_NEW_STATE(thrd, newstate) do { \
- if (_thread_kern_new_state != 0) \
- PANIC("Recursive PTHREAD_NEW_STATE"); \
- _thread_kern_new_state = 1; \
- if ((thrd)->state != newstate) { \
- if ((thrd)->state == PS_RUNNING) { \
- PTHREAD_PRIOQ_REMOVE(thrd); \
- PTHREAD_WAITQ_INSERT(thrd); \
- } else if (newstate == PS_RUNNING) { \
- PTHREAD_WAITQ_REMOVE(thrd); \
- PTHREAD_PRIOQ_INSERT_TAIL(thrd); \
- } \
- } \
- _thread_kern_new_state = 0; \
- PTHREAD_SET_STATE(thrd, newstate); \
-} while (0)
-#else
-#define PTHREAD_NEW_STATE(thrd, newstate) do { \
- if ((thrd)->state != newstate) { \
- if ((thrd)->state == PS_RUNNING) { \
- PTHREAD_PRIOQ_REMOVE(thrd); \
- PTHREAD_WAITQ_INSERT(thrd); \
- } else if (newstate == PS_RUNNING) { \
- PTHREAD_WAITQ_REMOVE(thrd); \
- PTHREAD_PRIOQ_INSERT_TAIL(thrd); \
- } \
- } \
- PTHREAD_SET_STATE(thrd, newstate); \
-} while (0)
-#endif
-
-/*
- * Define the signals to be used for scheduling.
- */
-#if defined(_PTHREADS_COMPAT_SCHED)
-#define _ITIMER_SCHED_TIMER ITIMER_VIRTUAL
-#define _SCHED_SIGNAL SIGVTALRM
-#else
-#define _ITIMER_SCHED_TIMER ITIMER_PROF
-#define _SCHED_SIGNAL SIGPROF
-#endif
-
-/*
- * Priority queues.
- *
- * XXX It'd be nice if these were contained in uthread_priority_queue.[ch].
- */
-typedef struct pq_list {
- TAILQ_HEAD(, pthread) pl_head; /* list of threads at this priority */
- TAILQ_ENTRY(pq_list) pl_link; /* link for queue of priority lists */
- int pl_prio; /* the priority of this list */
- int pl_queued; /* is this in the priority queue */
-} pq_list_t;
-
-typedef struct pq_queue {
- TAILQ_HEAD(, pq_list) pq_queue; /* queue of priority lists */
- pq_list_t *pq_lists; /* array of all priority lists */
- int pq_size; /* number of priority lists */
-} pq_queue_t;
-
-
-/*
- * TailQ initialization values.
- */
-#define TAILQ_INITIALIZER { NULL, NULL }
-
-/*
- * Mutex definitions.
- */
-union pthread_mutex_data {
- void *m_ptr;
- int m_count;
-};
-
-struct pthread_mutex {
- enum pthread_mutextype m_type;
- int m_protocol;
- TAILQ_HEAD(mutex_head, pthread) m_queue;
- struct pthread *m_owner;
- union pthread_mutex_data m_data;
- long m_flags;
- int m_refcount;
-
- /*
- * Used for priority inheritence and protection.
- *
- * m_prio - For priority inheritence, the highest active
- * priority (threads locking the mutex inherit
- * this priority). For priority protection, the
- * ceiling priority of this mutex.
- * m_saved_prio - mutex owners inherited priority before
- * taking the mutex, restored when the owner
- * unlocks the mutex.
- */
- int m_prio;
- int m_saved_prio;
-
- /*
- * Link for list of all mutexes a thread currently owns.
- */
- TAILQ_ENTRY(pthread_mutex) m_qe;
-
- /*
- * Lock for accesses to this structure.
- */
- spinlock_t lock;
-};
-
-/*
- * Flags for mutexes.
- */
-#define MUTEX_FLAGS_PRIVATE 0x01
-#define MUTEX_FLAGS_INITED 0x02
-#define MUTEX_FLAGS_BUSY 0x04
-
-/*
- * Static mutex initialization values.
- */
-#define PTHREAD_MUTEX_STATIC_INITIALIZER \
- { PTHREAD_MUTEX_DEFAULT, PTHREAD_PRIO_NONE, TAILQ_INITIALIZER, \
- NULL, { NULL }, MUTEX_FLAGS_PRIVATE, 0, 0, 0, TAILQ_INITIALIZER, \
- _SPINLOCK_INITIALIZER }
-
-struct pthread_mutex_attr {
- enum pthread_mutextype m_type;
- int m_protocol;
- int m_ceiling;
- long m_flags;
-};
-
-/*
- * Condition variable definitions.
- */
-enum pthread_cond_type {
- COND_TYPE_FAST,
- COND_TYPE_MAX
-};
-
-struct pthread_cond {
- enum pthread_cond_type c_type;
- TAILQ_HEAD(cond_head, pthread) c_queue;
- pthread_mutex_t c_mutex;
- void *c_data;
- long c_flags;
-
- /*
- * Lock for accesses to this structure.
- */
- spinlock_t lock;
-};
-
-struct pthread_cond_attr {
- enum pthread_cond_type c_type;
- long c_flags;
-};
-
-/*
- * Flags for condition variables.
- */
-#define COND_FLAGS_PRIVATE 0x01
-#define COND_FLAGS_INITED 0x02
-#define COND_FLAGS_BUSY 0x04
-
-/*
- * Static cond initialization values.
- */
-#define PTHREAD_COND_STATIC_INITIALIZER \
- { COND_TYPE_FAST, TAILQ_INITIALIZER, NULL, NULL, \
- 0, _SPINLOCK_INITIALIZER }
-
-/*
- * Semaphore definitions.
- */
-struct sem {
-#define SEM_MAGIC ((u_int32_t) 0x09fa4012)
- u_int32_t magic;
- pthread_mutex_t lock;
- pthread_cond_t gtzero;
- u_int32_t count;
- u_int32_t nwaiters;
-};
-
-/*
- * Cleanup definitions.
- */
-struct pthread_cleanup {
- struct pthread_cleanup *next;
- void (*routine) ();
- void *routine_arg;
-};
-
-struct pthread_attr {
- int sched_policy;
- int sched_inherit;
- int sched_interval;
- int prio;
- int suspend;
- int flags;
- void *arg_attr;
- void (*cleanup_attr) ();
- void *stackaddr_attr;
- size_t stacksize_attr;
-};
-
-/*
- * Thread creation state attributes.
- */
-#define PTHREAD_CREATE_RUNNING 0
-#define PTHREAD_CREATE_SUSPENDED 1
-
-/*
- * Miscellaneous definitions.
- */
-#define PTHREAD_STACK_DEFAULT 65536
-/*
- * Size of red zone at the end of each stack. In actuality, this "red zone" is
- * merely an unmapped region, except in the case of the initial stack. Since
- * mmap() makes it possible to specify the maximum growth of a MAP_STACK region,
- * an unmapped gap between thread stacks achieves the same effect as explicitly
- * mapped red zones.
- */
-#define PTHREAD_STACK_GUARD PAGE_SIZE
-
-/*
- * Maximum size of initial thread's stack. This perhaps deserves to be larger
- * than the stacks of other threads, since many applications are likely to run
- * almost entirely on this stack.
- */
-#define PTHREAD_STACK_INITIAL 0x100000
-/* Address immediately beyond the beginning of the initial thread stack. */
-#define PTHREAD_DEFAULT_PRIORITY 64
-#define PTHREAD_MAX_PRIORITY 126
-#define PTHREAD_MIN_PRIORITY 0
-#define _POSIX_THREAD_ATTR_STACKSIZE
-
-/*
- * Clock resolution in nanoseconds.
- */
-#define CLOCK_RES_NSEC 10000000
-
-/*
- * Time slice period in microseconds.
- */
-#define TIMESLICE_USEC 100000
-
-struct pthread_key {
- spinlock_t lock;
- volatile int allocated;
- volatile int count;
- void (*destructor) ();
-};
-
-struct pthread_rwlockattr {
- int pshared;
-};
-
-struct pthread_rwlock {
- pthread_mutex_t lock; /* monitor lock */
- int state; /* 0 = idle >0 = # of readers -1 = writer */
- pthread_cond_t read_signal;
- pthread_cond_t write_signal;
- int blocked_writers;
-};
-
-/*
- * Thread states.
- */
-enum pthread_state {
- PS_RUNNING,
- PS_SIGTHREAD,
- PS_MUTEX_WAIT,
- PS_COND_WAIT,
- PS_FDLR_WAIT,
- PS_FDLW_WAIT,
- PS_FDR_WAIT,
- PS_FDW_WAIT,
- PS_FILE_WAIT,
- PS_POLL_WAIT,
- PS_SELECT_WAIT,
- PS_SLEEP_WAIT,
- PS_WAIT_WAIT,
- PS_SIGSUSPEND,
- PS_SIGWAIT,
- PS_SPINBLOCK,
- PS_JOIN,
- PS_SUSPENDED,
- PS_DEAD,
- PS_DEADLOCK,
- PS_STATE_MAX
-};
-
-
-/*
- * File descriptor locking definitions.
- */
-#define FD_READ 0x1
-#define FD_WRITE 0x2
-#define FD_RDWR (FD_READ | FD_WRITE)
-
-/*
- * File descriptor table structure.
- */
-struct fd_table_entry {
- /*
- * Lock for accesses to this file descriptor table
- * entry. This is passed to _spinlock() to provide atomic
- * access to this structure. It does *not* represent the
- * state of the lock on the file descriptor.
- */
- spinlock_t lock;
- TAILQ_HEAD(, pthread) r_queue; /* Read queue. */
- TAILQ_HEAD(, pthread) w_queue; /* Write queue. */
- struct pthread *r_owner; /* Ptr to thread owning read lock. */
- struct pthread *w_owner; /* Ptr to thread owning write lock. */
- char *r_fname; /* Ptr to read lock source file name */
- int r_lineno; /* Read lock source line number. */
- char *w_fname; /* Ptr to write lock source file name */
- int w_lineno; /* Write lock source line number. */
- int r_lockcount; /* Count for FILE read locks. */
- int w_lockcount; /* Count for FILE write locks. */
- int flags; /* Flags used in open. */
-};
-
-struct pthread_poll_data {
- int nfds;
- struct pollfd *fds;
-};
-
-union pthread_wait_data {
- pthread_mutex_t mutex;
- pthread_cond_t cond;
- const sigset_t *sigwait; /* Waiting on a signal in sigwait */
- struct {
- short fd; /* Used when thread waiting on fd */
- short branch; /* Line number, for debugging. */
- char *fname; /* Source file name for debugging.*/
- } fd;
- struct pthread_poll_data * poll_data;
- spinlock_t *spinlock;
-};
-
-/*
- * Define a continuation routine that can be used to perform a
- * transfer of control:
- */
-typedef void (*thread_continuation_t) (void *);
-
-/*
- * Thread structure.
- */
-struct pthread {
- /*
- * Magic value to help recognize a valid thread structure
- * from an invalid one:
- */
-#define PTHREAD_MAGIC ((u_int32_t) 0xd09ba115)
- u_int32_t magic;
- char *name;
- u_int64_t uniqueid; /* for gdb */
-
- /*
- * Lock for accesses to this thread structure.
- */
- spinlock_t lock;
-
- /* Queue entry for list of all threads: */
- TAILQ_ENTRY(pthread) tle;
-
- /* Queue entry for list of dead threads: */
- TAILQ_ENTRY(pthread) dle;
-
- /*
- * Thread start routine, argument, stack pointer and thread
- * attributes.
- */
- void *(*start_routine)(void *);
- void *arg;
- void *stack;
- struct pthread_attr attr;
-
-#if (defined(__FreeBSD__) || defined(__NetBSD__)) && defined(__i386__)
- /*
- * Saved floating point registers on systems where they are not
- * saved in the signal context.
- */
- char saved_fp[108];
-#endif
-
- /*
- * Saved signal context used in call to sigreturn by
- * _thread_kern_sched if sig_saved is TRUE.
- */
- ucontext_t saved_sigcontext;
-
- /*
- * Saved jump buffer used in call to longjmp by _thread_kern_sched
- * if sig_saved is FALSE.
- */
- jmp_buf saved_jmp_buf;
- jmp_buf *sighandler_jmp_buf;
-
- /*
- * Saved jump buffers for use when doing nested [sig|_]longjmp()s, as
- * when doing signal delivery.
- */
- union {
- jmp_buf jmp;
- sigjmp_buf sigjmp;
- } nested_jmp;
- int longjmp_val;
-
-#define JMPFLAGS_NONE 0x00
-#define JMPFLAGS_LONGJMP 0x01
-#define JMPFLAGS__LONGJMP 0x02
-#define JMPFLAGS_SIGLONGJMP 0x04
-#define JMPFLAGS_DEFERRED 0x08
- int jmpflags;
-
- /*
- * TRUE if the last state saved was a signal context. FALSE if the
- * last state saved was a jump buffer.
- */
- int sig_saved;
-
- /*
- * Used for tracking delivery of nested signal handlers.
- */
- int signal_nest_level;
-
- /*
- * Cancelability flags - the lower 2 bits are used by cancel
- * definitions in pthread.h
- */
-#define PTHREAD_AT_CANCEL_POINT 0x0004
-#define PTHREAD_CANCELLING 0x0008
-#define PTHREAD_CANCEL_NEEDED 0x0010
- int cancelflags;
-
- thread_continuation_t continuation;
-
- /*
- * Current signal mask and pending signals.
- */
- sigset_t sigmask;
- sigset_t sigpend;
-
- /* Thread state: */
- enum pthread_state state;
- enum pthread_state oldstate;
-
- /* Time that this thread was last made active. */
- struct timeval last_active;
-
- /* Time that this thread was last made inactive. */
- struct timeval last_inactive;
-
- /*
- * Number of microseconds accumulated by this thread when
- * time slicing is active.
- */
- long slice_usec;
-
- /*
- * Incremental priority accumulated by thread while it is ready to
- * run but is denied being run.
- */
- int inc_prio;
-
- /*
- * Time to wake up thread. This is used for sleeping threads and
- * for any operation which may time out (such as select).
- */
- struct timespec wakeup_time;
-
- /* TRUE if operation has timed out. */
- int timeout;
-
- /*
- * Error variable used instead of errno. The function __error()
- * returns a pointer to this.
- */
- int error;
-
- /* Join queue head and link for waiting threads: */
- TAILQ_HEAD(join_head, pthread) join_queue;
-
- /*
- * The current thread can belong to only one scheduling queue at
- * a time (ready or waiting queue). It can also belong to (only)
- * one of:
- *
- * o A queue of threads waiting for a mutex
- * o A queue of threads waiting for a condition variable
- * o A queue of threads waiting for another thread to terminate
- * (the join queue above)
- * o A queue of threads waiting for a file descriptor lock
- * o A queue of threads needing work done by the kernel thread
- * (waiting for a spinlock or file I/O)
- *
- * Use pqe for the scheduling queue link (both ready and waiting),
- * and qe for other links.
- */
-
- /* Priority queue entry for this thread: */
- TAILQ_ENTRY(pthread) pqe;
-
- /* Queue entry for this thread: */
- TAILQ_ENTRY(pthread) qe;
-
- /* Wait data. */
- union pthread_wait_data data;
-
- /*
- * Allocated for converting select into poll.
- */
- struct pthread_poll_data poll_data;
-
- /*
- * Set to TRUE if a blocking operation was
- * interrupted by a signal:
- */
- int interrupted;
-
- /* Signal number when in state PS_SIGWAIT: */
- int signo;
-
- /*
- * Set to non-zero when this thread has deferred signals.
- * We allow for recursive deferral.
- */
- int sig_defer_count;
-
- /*
- * Set to TRUE if this thread should yield after undeferring
- * signals.
- */
- int yield_on_sig_undefer;
-
- /* Miscellaneous flags; only set with signals deferred. */
- int flags;
-#define PTHREAD_FLAGS_PRIVATE 0x0001
-#define PTHREAD_EXITING 0x0002
-#define PTHREAD_FLAGS_IN_CONDQ 0x0004 /* in condition queue using qe link*/
-#define PTHREAD_FLAGS_IN_WORKQ 0x0008 /* in work queue using qe link */
-#define PTHREAD_FLAGS_IN_WAITQ 0x0010 /* in waiting queue using pqe link */
-#define PTHREAD_FLAGS_IN_PRIOQ 0x0020 /* in priority queue using pqe link */
-#define PTHREAD_FLAGS_IN_MUTEXQ 0x0040 /* in mutex queue using qe link */
-#define PTHREAD_FLAGS_IN_FILEQ 0x0080 /* in file lock queue using qe link */
-#define PTHREAD_FLAGS_IN_FDQ 0x0100 /* in fd lock queue using qe link */
-#define PTHREAD_FLAGS_TRACE 0x0200 /* for debugging purposes */
-
- /*
- * Base priority is the user setable and retrievable priority
- * of the thread. It is only affected by explicit calls to
- * set thread priority and upon thread creation via a thread
- * attribute or default priority.
- */
- char base_priority;
-
- /*
- * Inherited priority is the priority a thread inherits by
- * taking a priority inheritence or protection mutex. It
- * is not affected by base priority changes. Inherited
- * priority defaults to and remains 0 until a mutex is taken
- * that is being waited on by any other thread whose priority
- * is non-zero.
- */
- char inherited_priority;
-
- /*
- * Active priority is always the maximum of the threads base
- * priority and inherited priority. When there is a change
- * in either the base or inherited priority, the active
- * priority must be recalculated.
- */
- char active_priority;
-
- /* Number of priority ceiling or protection mutexes owned. */
- int priority_mutex_count;
-
- /*
- * Queue of currently owned mutexes.
- */
- TAILQ_HEAD(, pthread_mutex) mutexq;
-
- void *ret;
- const void **specific_data;
- int specific_data_count;
-
- /* Cleanup handlers Link List */
- struct pthread_cleanup *cleanup;
- char *fname; /* Ptr to source file name */
- int lineno; /* Source line number. */
-};
-
-/* Spare thread stack. */
-struct stack {
- SLIST_ENTRY(stack) qe; /* Queue entry for this stack. */
-};
-
-/*
- * Global variables for the uthread kernel.
- */
-
-/* Kernel thread structure used when there are no running threads: */
-SCLASS struct pthread _thread_kern_thread;
-
-/* Ptr to the thread structure for the running thread: */
-SCLASS struct pthread * volatile _thread_run
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= &_thread_kern_thread;
-#else
-;
-#endif
-
-/* Ptr to the thread structure for the last user thread to run: */
-SCLASS struct pthread * volatile _last_user_thread
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= &_thread_kern_thread;
-#else
-;
-#endif
-
-/*
- * Ptr to the thread running in single-threaded mode or NULL if
- * running multi-threaded (default POSIX behaviour).
- */
-SCLASS struct pthread * volatile _thread_single
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= NULL;
-#else
-;
-#endif
-
-/* List of all threads: */
-SCLASS TAILQ_HEAD(, pthread) _thread_list
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= TAILQ_HEAD_INITIALIZER(_thread_list);
-#else
-;
-#endif
-
-/*
- * Array of kernel pipe file descriptors that are used to ensure that
- * no signals are missed in calls to _select.
- */
-SCLASS int _thread_kern_pipe[2]
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= {
- -1,
- -1
-};
-#else
-;
-#endif
-SCLASS int volatile _queue_signals
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= 0;
-#else
-;
-#endif
-SCLASS int _thread_kern_in_sched
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= 0;
-#else
-;
-#endif
-
-/* Last time that an incremental priority update was performed: */
-SCLASS struct timeval kern_inc_prio_time
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= { 0, 0 };
-#else
-;
-#endif
-
-/* Dead threads: */
-SCLASS TAILQ_HEAD(, pthread) _dead_list
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= TAILQ_HEAD_INITIALIZER(_dead_list);
-#else
-;
-#endif
-
-/* Initial thread: */
-SCLASS struct pthread *_thread_initial
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= NULL;
-#else
-;
-#endif
-
-/* Default thread attributes: */
-SCLASS struct pthread_attr pthread_attr_default
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= { SCHED_RR, 0, TIMESLICE_USEC, PTHREAD_DEFAULT_PRIORITY, PTHREAD_CREATE_RUNNING,
- PTHREAD_CREATE_JOINABLE, NULL, NULL, NULL, PTHREAD_STACK_DEFAULT };
-#else
-;
-#endif
-
-/* Default mutex attributes: */
-SCLASS struct pthread_mutex_attr pthread_mutexattr_default
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= { PTHREAD_MUTEX_DEFAULT, PTHREAD_PRIO_NONE, 0, 0 };
-#else
-;
-#endif
-
-/* Default condition variable attributes: */
-SCLASS struct pthread_cond_attr pthread_condattr_default
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= { COND_TYPE_FAST, 0 };
-#else
-;
-#endif
-
-/*
- * Standard I/O file descriptors need special flag treatment since
- * setting one to non-blocking does all on *BSD. Sigh. This array
- * is used to store the initial flag settings.
- */
-SCLASS int _pthread_stdio_flags[3];
-
-/* File table information: */
-SCLASS struct fd_table_entry **_thread_fd_table
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= NULL;
-#else
-;
-#endif
-
-/* Table for polling file descriptors: */
-SCLASS struct pollfd *_thread_pfd_table
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= NULL;
-#else
-;
-#endif
-
-SCLASS const int dtablecount
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= 4096/sizeof(struct fd_table_entry);
-#else
-;
-#endif
-SCLASS int _thread_dtablesize /* Descriptor table size. */
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= 0;
-#else
-;
-#endif
-
-SCLASS int _clock_res_nsec /* Clock resolution in nsec. */
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= CLOCK_RES_NSEC;
-#else
-;
-#endif
-
-/* Garbage collector mutex and condition variable. */
-SCLASS pthread_mutex_t _gc_mutex
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= NULL
-#endif
-;
-SCLASS pthread_cond_t _gc_cond
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= NULL
-#endif
-;
-
-/*
- * Array of signal actions for this process.
- */
-SCLASS struct sigaction _thread_sigact[NSIG];
-
-/*
- * Pending signals for this process.
- */
-SCLASS sigset_t _process_sigpending;
-
-/*
- * Scheduling queues:
- */
-SCLASS pq_queue_t _readyq;
-SCLASS TAILQ_HEAD(, pthread) _waitingq;
-
-/*
- * Work queue:
- */
-SCLASS TAILQ_HEAD(, pthread) _workq;
-
-/* Tracks the number of threads blocked while waiting for a spinlock. */
-SCLASS volatile int _spinblock_count
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= 0
-#endif
-;
-
-/* Indicates that the signal queue needs to be checked. */
-SCLASS volatile int _sigq_check_reqd
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= 0
-#endif
-;
-
-/* Thread switch hook. */
-SCLASS pthread_switch_routine_t _sched_switch_hook
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= NULL
-#endif
-;
-
-/*
- * Spare stack queue. Stacks of default size are cached in order to reduce
- * thread creation time. Spare stacks are used in LIFO order to increase cache
- * locality.
- */
-SCLASS SLIST_HEAD(, stack) _stackq;
-
-/*
- * Base address of next unallocated default-size {stack, red zone}. Stacks are
- * allocated contiguously, starting below the bottom of the main stack. When a
- * new stack is created, a red zone is created (actually, the red zone is simply
- * left unmapped) below the bottom of the stack, such that the stack will not be
- * able to grow all the way to the top of the next stack. This isn't
- * fool-proof. It is possible for a stack to grow by a large amount, such that
- * it grows into the next stack, and as long as the memory within the red zone
- * is never accessed, nothing will prevent one thread stack from trouncing all
- * over the next.
- */
-SCLASS void * _next_stack
-#ifdef GLOBAL_PTHREAD_PRIVATE
-/* main stack top - main stack size - stack size - (red zone + main stack red zone) */
-= (void *) USRSTACK - PTHREAD_STACK_INITIAL - PTHREAD_STACK_DEFAULT - (2 * PTHREAD_STACK_GUARD)
-#endif
-;
-
-/* Used for _PTHREADS_INVARIANTS checking. */
-SCLASS int _thread_kern_new_state
-#ifdef GLOBAL_PTHREAD_PRIVATE
-= 0
-#endif
-;
-
-/* Undefine the storage class specifier: */
-#undef SCLASS
-
-#ifdef _LOCK_DEBUG
-#define _FD_LOCK(_fd,_type,_ts) _thread_fd_lock_debug(_fd, _type, \
- _ts, __FILE__, __LINE__)
-#define _FD_UNLOCK(_fd,_type) _thread_fd_unlock_debug(_fd, _type, \
- __FILE__, __LINE__)
-#else
-#define _FD_LOCK(_fd,_type,_ts) _thread_fd_lock(_fd, _type, _ts)
-#define _FD_UNLOCK(_fd,_type) _thread_fd_unlock(_fd, _type)
-#endif
-
-/*
- * Function prototype definitions.
- */
-__BEGIN_DECLS
-char *__ttyname_basic(int);
-char *__ttyname_r_basic(int, char *, size_t);
-char *ttyname_r(int, char *, size_t);
-int _find_dead_thread(pthread_t);
-int _find_thread(pthread_t);
-void _funlock_owned(pthread_t);
-int _thread_create(pthread_t *,const pthread_attr_t *,void *(*start_routine)(void *),void *,pthread_t);
-int _thread_fd_lock(int, int, struct timespec *);
-int _thread_fd_lock_debug(int, int, struct timespec *,char *fname,int lineno);
-void _dispatch_signals(void);
-int _mutex_cv_lock(pthread_mutex_t *);
-int _mutex_cv_unlock(pthread_mutex_t *);
-void _mutex_notify_priochange(pthread_t);
-int _mutex_reinit(pthread_mutex_t *);
-void _mutex_unlock_private(pthread_t);
-int _cond_reinit(pthread_cond_t *);
-int _pq_alloc(struct pq_queue *, int, int);
-int _pq_init(struct pq_queue *);
-void _pq_remove(struct pq_queue *pq, struct pthread *);
-void _pq_insert_head(struct pq_queue *pq, struct pthread *);
-void _pq_insert_tail(struct pq_queue *pq, struct pthread *);
-struct pthread *_pq_first(struct pq_queue *pq);
-#if defined(_PTHREADS_INVARIANTS)
-void _waitq_insert(pthread_t pthread);
-void _waitq_remove(pthread_t pthread);
-void _waitq_setactive(void);
-void _waitq_clearactive(void);
-#endif
-void _thread_exit(char *, int, char *);
-void _thread_exit_cleanup(void);
-void _thread_fd_unlock(int, int);
-void _thread_fd_unlock_debug(int, int, char *, int);
-void _thread_fd_unlock_owned(pthread_t);
-void *_thread_cleanup(pthread_t);
-void _thread_cleanupspecific(void);
-void _thread_dump_info(void);
-void _thread_init(void);
-void _thread_kern_sched(ucontext_t *);
-void _thread_kern_sched_state(enum pthread_state,char *fname,int lineno);
-void _thread_kern_sched_state_unlock(enum pthread_state state,
- spinlock_t *lock, char *fname, int lineno);
-void _thread_kern_set_timeout(struct timespec *);
-void _thread_kern_sig_defer(void);
-void _thread_kern_sig_undefer(void);
-void _thread_sig_handler(int, int, ucontext_t *);
-pthread_t _thread_sig_handle(int, ucontext_t *);
-void _thread_sig_init(void);
-void _thread_sig_send(pthread_t pthread, int sig);
-void _thread_sig_deliver(pthread_t pthread, int sig);
-void _thread_start(void);
-void _thread_start_sig_handler(void);
-void _thread_seterrno(pthread_t,int);
-int _thread_fd_table_init(int fd);
-pthread_addr_t _thread_gc(pthread_addr_t);
-void _thread_enter_cancellation_point(void);
-void _thread_leave_cancellation_point(void);
-void _thread_cancellation_point(void);
-
-/* #include <signal.h> */
-int _thread_sys_sigaction(int, const struct sigaction *, struct sigaction *);
-int _thread_sys_sigpending(sigset_t *);
-int _thread_sys_sigprocmask(int, const sigset_t *, sigset_t *);
-int _thread_sys_sigsuspend(const sigset_t *);
-int _thread_sys_siginterrupt(int, int);
-int _thread_sys_sigpause(int);
-int _thread_sys_sigreturn(ucontext_t *);
-int _thread_sys_sigstack(const struct sigstack *, struct sigstack *);
-int _thread_sys_sigvec(int, struct sigvec *, struct sigvec *);
-void _thread_sys_psignal(unsigned int, const char *);
-void (*_thread_sys_signal(int, void (*)(int)))(int);
-
-/* #include <sys/stat.h> */
-#ifdef _SYS_STAT_H_
-int _thread_sys_fchmod(int, mode_t);
-int _thread_sys_fstat(int, struct stat *);
-int _thread_sys_fchflags(int, u_long);
-#endif
-
-/* #include <sys/mount.h> */
-#ifdef _SYS_MOUNT_H_
-int _thread_sys_fstatfs(int, struct statfs *);
-#endif
-int _thread_sys_pipe(int *);
-
-/* #include <sys/socket.h> */
-#ifdef _SYS_SOCKET_H_
-int _thread_sys_accept(int, struct sockaddr *, int *);
-int _thread_sys_bind(int, const struct sockaddr *, int);
-int _thread_sys_connect(int, const struct sockaddr *, int);
-int _thread_sys_getpeername(int, struct sockaddr *, int *);
-int _thread_sys_getsockname(int, struct sockaddr *, int *);
-int _thread_sys_getsockopt(int, int, int, void *, int *);
-int _thread_sys_listen(int, int);
-int _thread_sys_setsockopt(int, int, int, const void *, int);
-int _thread_sys_shutdown(int, int);
-int _thread_sys_socket(int, int, int);
-int _thread_sys_socketpair(int, int, int, int *);
-ssize_t _thread_sys_recv(int, void *, size_t, int);
-ssize_t _thread_sys_recvfrom(int, void *, size_t, int, struct sockaddr *, int *);
-ssize_t _thread_sys_recvmsg(int, struct msghdr *, int);
-ssize_t _thread_sys_send(int, const void *, size_t, int);
-ssize_t _thread_sys_sendmsg(int, const struct msghdr *, int);
-ssize_t _thread_sys_sendto(int, const void *,size_t, int, const struct sockaddr *, int);
-#endif
-
-/* #include <stdio.h> */
-#ifdef _STDIO_H_
-FILE *_thread_sys_fdopen(int, const char *);
-FILE *_thread_sys_fopen(const char *, const char *);
-FILE *_thread_sys_freopen(const char *, const char *, FILE *);
-FILE *_thread_sys_popen(const char *, const char *);
-FILE *_thread_sys_tmpfile(void);
-char *_thread_sys_ctermid(char *);
-char *_thread_sys_cuserid(char *);
-char *_thread_sys_fgetln(FILE *, size_t *);
-char *_thread_sys_fgets(char *, int, FILE *);
-char *_thread_sys_gets(char *);
-char *_thread_sys_tempnam(const char *, const char *);
-char *_thread_sys_tmpnam(char *);
-int _thread_sys_fclose(FILE *);
-int _thread_sys_feof(FILE *);
-int _thread_sys_ferror(FILE *);
-int _thread_sys_fflush(FILE *);
-int _thread_sys_fgetc(FILE *);
-int _thread_sys_fgetpos(FILE *, fpos_t *);
-int _thread_sys_fileno(FILE *);
-int _thread_sys_fprintf(FILE *, const char *, ...);
-int _thread_sys_fpurge(FILE *);
-int _thread_sys_fputc(int, FILE *);
-int _thread_sys_fputs(const char *, FILE *);
-int _thread_sys_fscanf(FILE *, const char *, ...);
-int _thread_sys_fseek(FILE *, long, int);
-int _thread_sys_fsetpos(FILE *, const fpos_t *);
-int _thread_sys_getc(FILE *);
-int _thread_sys_getchar(void);
-int _thread_sys_getw(FILE *);
-int _thread_sys_pclose(FILE *);
-int _thread_sys_printf(const char *, ...);
-int _thread_sys_putc(int, FILE *);
-int _thread_sys_putchar(int);
-int _thread_sys_puts(const char *);
-int _thread_sys_putw(int, FILE *);
-int _thread_sys_remove(const char *);
-int _thread_sys_rename (const char *, const char *);
-int _thread_sys_scanf(const char *, ...);
-int _thread_sys_setlinebuf(FILE *);
-int _thread_sys_setvbuf(FILE *, char *, int, size_t);
-int _thread_sys_snprintf(char *, size_t, const char *, ...);
-int _thread_sys_sprintf(char *, const char *, ...);
-int _thread_sys_sscanf(const char *, const char *, ...);
-int _thread_sys_ungetc(int, FILE *);
-int _thread_sys_vfprintf(FILE *, const char *, _BSD_VA_LIST_);
-int _thread_sys_vprintf(const char *, _BSD_VA_LIST_);
-int _thread_sys_vscanf(const char *, _BSD_VA_LIST_);
-int _thread_sys_vsnprintf(char *, size_t, const char *, _BSD_VA_LIST_);
-int _thread_sys_vsprintf(char *, const char *, _BSD_VA_LIST_);
-int _thread_sys_vsscanf(const char *, const char *, _BSD_VA_LIST_);
-long _thread_sys_ftell(FILE *);
-size_t _thread_sys_fread(void *, size_t, size_t, FILE *);
-size_t _thread_sys_fwrite(const void *, size_t, size_t, FILE *);
-void _thread_sys_clearerr(FILE *);
-void _thread_sys_perror(const char *);
-void _thread_sys_rewind(FILE *);
-void _thread_sys_setbuf(FILE *, char *);
-void _thread_sys_setbuffer(FILE *, char *, int);
-#endif
-
-/* #include <unistd.h> */
-#ifdef _UNISTD_H_
-char *_thread_sys_ttyname(int);
-int _thread_sys_close(int);
-int _thread_sys_dup(int);
-int _thread_sys_dup2(int, int);
-int _thread_sys_exect(const char *, char * const *, char * const *);
-int _thread_sys_execve(const char *, char * const *, char * const *);
-int _thread_sys_fchdir(int);
-int _thread_sys_fchown(int, uid_t, gid_t);
-int _thread_sys_fsync(int);
-int _thread_sys_ftruncate(int, off_t);
-int _thread_sys_pause(void);
-int _thread_sys_pipe(int *);
-int _thread_sys_select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
-off_t _thread_sys_lseek(int, off_t, int);
-pid_t _thread_sys_fork(void);
-pid_t _thread_sys_tcgetpgrp(int);
-ssize_t _thread_sys_read(int, void *, size_t);
-ssize_t _thread_sys_write(int, const void *, size_t);
-void _thread_sys__exit(int);
-#endif
-
-/* #include <fcntl.h> */
-#ifdef _SYS_FCNTL_H_
-int _thread_sys_creat(const char *, mode_t);
-int _thread_sys_fcntl(int, int, ...);
-int _thread_sys_flock(int, int);
-int _thread_sys_open(const char *, int, ...);
-#endif
-
-/* #include <sys/ioctl.h> */
-#ifdef _SYS_IOCTL_H_
-int _thread_sys_ioctl(int, unsigned long, ...);
-#endif
-
-/* #include <dirent.h> */
-#ifdef _DIRENT_H_
-DIR *___thread_sys_opendir2(const char *, int);
-DIR *_thread_sys_opendir(const char *);
-int _thread_sys_alphasort(const void *, const void *);
-int _thread_sys_scandir(const char *, struct dirent ***,
- int (*)(struct dirent *), int (*)(const void *, const void *));
-int _thread_sys_closedir(DIR *);
-int _thread_sys_getdirentries(int, char *, int, long *);
-long _thread_sys_telldir(const DIR *);
-struct dirent *_thread_sys_readdir(DIR *);
-void _thread_sys_rewinddir(DIR *);
-void _thread_sys_seekdir(DIR *, long);
-#endif
-
-/* #include <sys/uio.h> */
-#ifdef _SYS_UIO_H_
-ssize_t _thread_sys_readv(int, const struct iovec *, int);
-ssize_t _thread_sys_writev(int, const struct iovec *, int);
-#endif
-
-/* #include <sys/wait.h> */
-#ifdef WNOHANG
-pid_t _thread_sys_wait(int *);
-pid_t _thread_sys_waitpid(pid_t, int *, int);
-pid_t _thread_sys_wait3(int *, int, struct rusage *);
-pid_t _thread_sys_wait4(pid_t, int *, int, struct rusage *);
-#endif
-
-/* #include <poll.h> */
-#ifdef _SYS_POLL_H_
-int _thread_sys_poll(struct pollfd *, unsigned, int);
-#endif
-
-/* #include <sys/mman.h> */
-#ifdef _SYS_MMAN_H_
-int _thread_sys_msync(void *, size_t, int);
-#endif
-
-/* #include <setjmp.h> */
-#ifdef _SETJMP_H_
-extern void __siglongjmp(sigjmp_buf, int) __dead2;
-extern void __longjmp(jmp_buf, int) __dead2;
-extern void ___longjmp(jmp_buf, int) __dead2;
-#endif
-__END_DECLS
-
-#endif /* !_PTHREAD_PRIVATE_H */
diff --git a/lib/libpthread/thread/thr_read.c b/lib/libpthread/thread/thr_read.c
deleted file mode 100644
index b4d96943328a..000000000000
--- a/lib/libpthread/thread/thr_read.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- *
- */
-#include <sys/types.h>
-#include <sys/fcntl.h>
-#include <sys/uio.h>
-#include <errno.h>
-#include <unistd.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-ssize_t
-_read(int fd, void *buf, size_t nbytes)
-{
- int ret;
- int type;
-
- /* POSIX says to do just this: */
- if (nbytes == 0) {
- return (0);
- }
-
- /* Lock the file descriptor for read: */
- if ((ret = _FD_LOCK(fd, FD_READ, NULL)) == 0) {
- /* Get the read/write mode type: */
- type = _thread_fd_table[fd]->flags & O_ACCMODE;
-
- /* Check if the file is not open for read: */
- if (type != O_RDONLY && type != O_RDWR) {
- /* File is not open for read: */
- errno = EBADF;
- _FD_UNLOCK(fd, FD_READ);
- return (-1);
- }
-
- /* Perform a non-blocking read syscall: */
- while ((ret = _thread_sys_read(fd, buf, nbytes)) < 0) {
- if ((_thread_fd_table[fd]->flags & O_NONBLOCK) == 0 &&
- (errno == EWOULDBLOCK || errno == EAGAIN)) {
- _thread_run->data.fd.fd = fd;
- _thread_kern_set_timeout(NULL);
-
- /* Reset the interrupted operation flag: */
- _thread_run->interrupted = 0;
-
- _thread_kern_sched_state(PS_FDR_WAIT,
- __FILE__, __LINE__);
-
- /*
- * Check if the operation was
- * interrupted by a signal
- */
- if (_thread_run->interrupted) {
- errno = EINTR;
- ret = -1;
- break;
- }
- } else {
- break;
- }
- }
- _FD_UNLOCK(fd, FD_READ);
- }
- return (ret);
-}
-
-ssize_t
-read(int fd, void *buf, size_t nbytes)
-{
- ssize_t ret;
-
- _thread_enter_cancellation_point();
- ret = _read(fd, buf, nbytes);
- _thread_leave_cancellation_point();
-
- return ret;
-}
-#endif
diff --git a/lib/libpthread/thread/thr_readv.c b/lib/libpthread/thread/thr_readv.c
deleted file mode 100644
index d8e02c0a3a05..000000000000
--- a/lib/libpthread/thread/thr_readv.c
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- *
- */
-#include <sys/types.h>
-#include <sys/fcntl.h>
-#include <sys/uio.h>
-#include <errno.h>
-#include <unistd.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-ssize_t
-_readv(int fd, const struct iovec * iov, int iovcnt)
-{
- int ret;
- int type;
-
- /* Lock the file descriptor for read: */
- if ((ret = _FD_LOCK(fd, FD_READ, NULL)) == 0) {
- /* Get the read/write mode type: */
- type = _thread_fd_table[fd]->flags & O_ACCMODE;
-
- /* Check if the file is not open for read: */
- if (type != O_RDONLY && type != O_RDWR) {
- /* File is not open for read: */
- errno = EBADF;
- _FD_UNLOCK(fd, FD_READ);
- return (-1);
- }
-
- /* Perform a non-blocking readv syscall: */
- while ((ret = _thread_sys_readv(fd, iov, iovcnt)) < 0) {
- if ((_thread_fd_table[fd]->flags & O_NONBLOCK) == 0 &&
- (errno == EWOULDBLOCK || errno == EAGAIN)) {
- _thread_run->data.fd.fd = fd;
- _thread_kern_set_timeout(NULL);
-
- /* Reset the interrupted operation flag: */
- _thread_run->interrupted = 0;
-
- _thread_kern_sched_state(PS_FDR_WAIT,
- __FILE__, __LINE__);
-
- /*
- * Check if the operation was
- * interrupted by a signal
- */
- if (_thread_run->interrupted) {
- errno = EINTR;
- ret = -1;
- break;
- }
- } else {
- break;
- }
- }
- _FD_UNLOCK(fd, FD_READ);
- }
- return (ret);
-}
-
-__strong_reference(_readv, readv);
-#endif
diff --git a/lib/libpthread/thread/thr_resume_np.c b/lib/libpthread/thread/thr_resume_np.c
deleted file mode 100644
index 98ec7186d8f9..000000000000
--- a/lib/libpthread/thread/thr_resume_np.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-/* Resume a thread: */
-int
-pthread_resume_np(pthread_t thread)
-{
- int ret;
-
- /* Find the thread in the list of active threads: */
- if ((ret = _find_thread(thread)) == 0) {
- /* The thread exists. Is it suspended? */
- if (thread->state != PS_SUSPENDED) {
- /*
- * Defer signals to protect the scheduling queues
- * from access by the signal handler:
- */
- _thread_kern_sig_defer();
-
- /* Allow the thread to run. */
- PTHREAD_NEW_STATE(thread,PS_RUNNING);
-
- /*
- * Undefer and handle pending signals, yielding if
- * necessary:
- */
- _thread_kern_sig_undefer();
- }
- }
- return(ret);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_rwlock.c b/lib/libpthread/thread/thr_rwlock.c
deleted file mode 100644
index 648e8a394eeb..000000000000
--- a/lib/libpthread/thread/thr_rwlock.c
+++ /dev/null
@@ -1,335 +0,0 @@
-/*-
- * Copyright (c) 1998 Alex Nash
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#ifdef _THREAD_SAFE
-#include <errno.h>
-#include <limits.h>
-#include <stdlib.h>
-
-#include <pthread.h>
-#include "pthread_private.h"
-
-/* maximum number of times a read lock may be obtained */
-#define MAX_READ_LOCKS (INT_MAX - 1)
-
-static int init_static (pthread_rwlock_t *rwlock);
-
-static spinlock_t static_init_lock = _SPINLOCK_INITIALIZER;
-
-static int
-init_static (pthread_rwlock_t *rwlock)
-{
- int ret;
-
- _SPINLOCK(&static_init_lock);
-
- if (*rwlock == NULL)
- ret = pthread_rwlock_init(rwlock, NULL);
- else
- ret = 0;
-
- _SPINUNLOCK(&static_init_lock);
-
- return(ret);
-}
-
-int
-pthread_rwlock_destroy (pthread_rwlock_t *rwlock)
-{
- int ret;
-
- if (rwlock == NULL)
- ret = EINVAL;
- else {
- pthread_rwlock_t prwlock;
-
- prwlock = *rwlock;
-
- pthread_mutex_destroy(&prwlock->lock);
- pthread_cond_destroy(&prwlock->read_signal);
- pthread_cond_destroy(&prwlock->write_signal);
- free(prwlock);
-
- *rwlock = NULL;
-
- ret = 0;
- }
-
- return(ret);
-}
-
-int
-pthread_rwlock_init (pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr)
-{
- pthread_rwlock_t prwlock;
- int ret;
-
- /* allocate rwlock object */
- prwlock = (pthread_rwlock_t)malloc(sizeof(struct pthread_rwlock));
-
- if (prwlock == NULL)
- return(ENOMEM);
-
- /* initialize the lock */
- if ((ret = pthread_mutex_init(&prwlock->lock, NULL)) != 0)
- free(prwlock);
- else {
- /* initialize the read condition signal */
- ret = pthread_cond_init(&prwlock->read_signal, NULL);
-
- if (ret != 0) {
- pthread_mutex_destroy(&prwlock->lock);
- free(prwlock);
- } else {
- /* initialize the write condition signal */
- ret = pthread_cond_init(&prwlock->write_signal, NULL);
-
- if (ret != 0) {
- pthread_cond_destroy(&prwlock->read_signal);
- pthread_mutex_destroy(&prwlock->lock);
- free(prwlock);
- } else {
- /* success */
- prwlock->state = 0;
- prwlock->blocked_writers = 0;
-
- *rwlock = prwlock;
- }
- }
- }
-
- return(ret);
-}
-
-int
-pthread_rwlock_rdlock (pthread_rwlock_t *rwlock)
-{
- pthread_rwlock_t prwlock;
- int ret;
-
- if (rwlock == NULL)
- return(EINVAL);
-
- prwlock = *rwlock;
-
- /* check for static initialization */
- if (prwlock == NULL) {
- if ((ret = init_static(rwlock)) != 0)
- return(ret);
-
- prwlock = *rwlock;
- }
-
- /* grab the monitor lock */
- if ((ret = pthread_mutex_lock(&prwlock->lock)) != 0)
- return(ret);
-
- /* give writers priority over readers */
- while (prwlock->blocked_writers || prwlock->state < 0) {
- ret = pthread_cond_wait(&prwlock->read_signal, &prwlock->lock);
-
- if (ret != 0) {
- /* can't do a whole lot if this fails */
- pthread_mutex_unlock(&prwlock->lock);
- return(ret);
- }
- }
-
- /* check lock count */
- if (prwlock->state == MAX_READ_LOCKS)
- ret = EAGAIN;
- else
- ++prwlock->state; /* indicate we are locked for reading */
-
- /*
- * Something is really wrong if this call fails. Returning
- * error won't do because we've already obtained the read
- * lock. Decrementing 'state' is no good because we probably
- * don't have the monitor lock.
- */
- pthread_mutex_unlock(&prwlock->lock);
-
- return(ret);
-}
-
-int
-pthread_rwlock_tryrdlock (pthread_rwlock_t *rwlock)
-{
- pthread_rwlock_t prwlock;
- int ret;
-
- if (rwlock == NULL)
- return(EINVAL);
-
- prwlock = *rwlock;
-
- /* check for static initialization */
- if (prwlock == NULL) {
- if ((ret = init_static(rwlock)) != 0)
- return(ret);
-
- prwlock = *rwlock;
- }
-
- /* grab the monitor lock */
- if ((ret = pthread_mutex_lock(&prwlock->lock)) != 0)
- return(ret);
-
- /* give writers priority over readers */
- if (prwlock->blocked_writers || prwlock->state < 0)
- ret = EWOULDBLOCK;
- else if (prwlock->state == MAX_READ_LOCKS)
- ret = EAGAIN; /* too many read locks acquired */
- else
- ++prwlock->state; /* indicate we are locked for reading */
-
- /* see the comment on this in pthread_rwlock_rdlock */
- pthread_mutex_unlock(&prwlock->lock);
-
- return(ret);
-}
-
-int
-pthread_rwlock_trywrlock (pthread_rwlock_t *rwlock)
-{
- pthread_rwlock_t prwlock;
- int ret;
-
- if (rwlock == NULL)
- return(EINVAL);
-
- prwlock = *rwlock;
-
- /* check for static initialization */
- if (prwlock == NULL) {
- if ((ret = init_static(rwlock)) != 0)
- return(ret);
-
- prwlock = *rwlock;
- }
-
- /* grab the monitor lock */
- if ((ret = pthread_mutex_lock(&prwlock->lock)) != 0)
- return(ret);
-
- if (prwlock->state != 0)
- ret = EWOULDBLOCK;
- else
- /* indicate we are locked for writing */
- prwlock->state = -1;
-
- /* see the comment on this in pthread_rwlock_rdlock */
- pthread_mutex_unlock(&prwlock->lock);
-
- return(ret);
-}
-
-int
-pthread_rwlock_unlock (pthread_rwlock_t *rwlock)
-{
- pthread_rwlock_t prwlock;
- int ret;
-
- if (rwlock == NULL)
- return(EINVAL);
-
- prwlock = *rwlock;
-
- if (prwlock == NULL)
- return(EINVAL);
-
- /* grab the monitor lock */
- if ((ret = pthread_mutex_lock(&prwlock->lock)) != 0)
- return(ret);
-
- if (prwlock->state > 0) {
- if (--prwlock->state == 0 && prwlock->blocked_writers)
- ret = pthread_cond_signal(&prwlock->write_signal);
- } else if (prwlock->state < 0) {
- prwlock->state = 0;
-
- if (prwlock->blocked_writers)
- ret = pthread_cond_signal(&prwlock->write_signal);
- else
- ret = pthread_cond_broadcast(&prwlock->read_signal);
- } else
- ret = EINVAL;
-
- /* see the comment on this in pthread_rwlock_rdlock */
- pthread_mutex_unlock(&prwlock->lock);
-
- return(ret);
-}
-
-int
-pthread_rwlock_wrlock (pthread_rwlock_t *rwlock)
-{
- pthread_rwlock_t prwlock;
- int ret;
-
- if (rwlock == NULL)
- return(EINVAL);
-
- prwlock = *rwlock;
-
- /* check for static initialization */
- if (prwlock == NULL) {
- if ((ret = init_static(rwlock)) != 0)
- return(ret);
-
- prwlock = *rwlock;
- }
-
- /* grab the monitor lock */
- if ((ret = pthread_mutex_lock(&prwlock->lock)) != 0)
- return(ret);
-
- while (prwlock->state != 0) {
- ++prwlock->blocked_writers;
-
- ret = pthread_cond_wait(&prwlock->write_signal, &prwlock->lock);
-
- if (ret != 0) {
- --prwlock->blocked_writers;
- pthread_mutex_unlock(&prwlock->lock);
- return(ret);
- }
-
- --prwlock->blocked_writers;
- }
-
- /* indicate we are locked for writing */
- prwlock->state = -1;
-
- /* see the comment on this in pthread_rwlock_rdlock */
- pthread_mutex_unlock(&prwlock->lock);
-
- return(ret);
-}
-
-#endif /* _THREAD_SAFE */
diff --git a/lib/libpthread/thread/thr_rwlockattr.c b/lib/libpthread/thread/thr_rwlockattr.c
deleted file mode 100644
index 37eb3eae66a9..000000000000
--- a/lib/libpthread/thread/thr_rwlockattr.c
+++ /dev/null
@@ -1,95 +0,0 @@
-/*-
- * Copyright (c) 1998 Alex Nash
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#ifdef _THREAD_SAFE
-#include <errno.h>
-#include <stdlib.h>
-
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_rwlockattr_destroy(pthread_rwlockattr_t *rwlockattr)
-{
- pthread_rwlockattr_t prwlockattr;
-
- if (rwlockattr == NULL)
- return(EINVAL);
-
- prwlockattr = *rwlockattr;
-
- if (prwlockattr == NULL)
- return(EINVAL);
-
- free(prwlockattr);
-
- return(0);
-}
-
-int
-pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *rwlockattr,
- int *pshared)
-{
- *pshared = (*rwlockattr)->pshared;
-
- return(0);
-}
-
-int
-pthread_rwlockattr_init(pthread_rwlockattr_t *rwlockattr)
-{
- pthread_rwlockattr_t prwlockattr;
-
- if (rwlockattr == NULL)
- return(EINVAL);
-
- prwlockattr = (pthread_rwlockattr_t)
- malloc(sizeof(struct pthread_rwlockattr));
-
- if (prwlockattr == NULL)
- return(ENOMEM);
-
- prwlockattr->pshared = PTHREAD_PROCESS_PRIVATE;
- *rwlockattr = prwlockattr;
-
- return(0);
-}
-
-int
-pthread_rwlockattr_setpshared(pthread_rwlockattr_t *rwlockattr, int pshared)
-{
- /* Only PTHREAD_PROCESS_PRIVATE is supported. */
- if (pshared != PTHREAD_PROCESS_PRIVATE)
- return(EINVAL);
-
- (*rwlockattr)->pshared = pshared;
-
- return(0);
-}
-
-#endif /* _THREAD_SAFE */
diff --git a/lib/libpthread/thread/thr_select.c b/lib/libpthread/thread/thr_select.c
deleted file mode 100644
index 0a7c0d405c22..000000000000
--- a/lib/libpthread/thread/thr_select.c
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <unistd.h>
-#include <errno.h>
-#include <poll.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/fcntl.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-_select(int numfds, fd_set * readfds, fd_set * writefds, fd_set * exceptfds,
- struct timeval * timeout)
-{
- struct timespec ts;
- int i, ret = 0, f_wait = 1;
- int pfd_index, got_one = 0, fd_count = 0;
- struct pthread_poll_data data;
-
- if (numfds > _thread_dtablesize) {
- numfds = _thread_dtablesize;
- }
- /* Check if a timeout was specified: */
- if (timeout) {
- if (timeout->tv_sec < 0 ||
- timeout->tv_usec < 0 || timeout->tv_usec >= 1000000) {
- errno = EINVAL;
- return (-1);
- }
-
- /* Convert the timeval to a timespec: */
- TIMEVAL_TO_TIMESPEC(timeout, &ts);
-
- /* Set the wake up time: */
- _thread_kern_set_timeout(&ts);
- if (ts.tv_sec == 0 && ts.tv_nsec == 0)
- f_wait = 0;
- } else {
- /* Wait for ever: */
- _thread_kern_set_timeout(NULL);
- }
-
- /* Count the number of file descriptors to be polled: */
- if (readfds || writefds || exceptfds) {
- for (i = 0; i < numfds; i++) {
- if ((readfds && FD_ISSET(i, readfds)) ||
- (exceptfds && FD_ISSET(i, exceptfds)) ||
- (writefds && FD_ISSET(i, writefds))) {
- fd_count++;
- }
- }
- }
-
- /*
- * Allocate memory for poll data if it hasn't already been
- * allocated or if previously allocated memory is insufficient.
- */
- if ((_thread_run->poll_data.fds == NULL) ||
- (_thread_run->poll_data.nfds < fd_count)) {
- data.fds = (struct pollfd *) realloc(_thread_run->poll_data.fds,
- sizeof(struct pollfd) * MAX(128, fd_count));
- if (data.fds == NULL) {
- errno = ENOMEM;
- ret = -1;
- }
- else {
- /*
- * Note that the threads poll data always
- * indicates what is allocated, not what is
- * currently being polled.
- */
- _thread_run->poll_data.fds = data.fds;
- _thread_run->poll_data.nfds = MAX(128, fd_count);
- }
- }
- if (ret == 0) {
- /* Setup the wait data. */
- data.fds = _thread_run->poll_data.fds;
- data.nfds = fd_count;
-
- /*
- * Setup the array of pollfds. Optimize this by
- * running the loop in reverse and stopping when
- * the number of selected file descriptors is reached.
- */
- for (i = numfds - 1, pfd_index = fd_count - 1;
- (i >= 0) && (pfd_index >= 0); i--) {
- data.fds[pfd_index].events = 0;
- if (readfds && FD_ISSET(i, readfds)) {
- data.fds[pfd_index].events = POLLRDNORM;
- }
- if (exceptfds && FD_ISSET(i, exceptfds)) {
- data.fds[pfd_index].events |= POLLRDBAND;
- }
- if (writefds && FD_ISSET(i, writefds)) {
- data.fds[pfd_index].events |= POLLWRNORM;
- }
- if (data.fds[pfd_index].events != 0) {
- /*
- * Set the file descriptor to be polled and
- * clear revents in case of a timeout which
- * leaves fds unchanged:
- */
- data.fds[pfd_index].fd = i;
- data.fds[pfd_index].revents = 0;
- pfd_index--;
- }
- }
- if (((ret = _thread_sys_poll(data.fds, data.nfds, 0)) == 0) &&
- (f_wait != 0)) {
- _thread_run->data.poll_data = &data;
- _thread_run->interrupted = 0;
- _thread_kern_sched_state(PS_SELECT_WAIT, __FILE__, __LINE__);
- if (_thread_run->interrupted) {
- errno = EINTR;
- data.nfds = 0;
- ret = -1;
- } else
- ret = data.nfds;
- }
- }
-
- if (ret >= 0) {
- numfds = 0;
- for (i = 0; i < fd_count; i++) {
- /*
- * Check the results of the poll and clear
- * this file descriptor from the fdset if
- * the requested event wasn't ready.
- */
- got_one = 0;
- if (readfds != NULL) {
- if (FD_ISSET(data.fds[i].fd, readfds)) {
- if (data.fds[i].revents & (POLLIN |
- POLLRDNORM))
- got_one = 1;
- else
- FD_CLR(data.fds[i].fd, readfds);
- }
- }
- if (writefds != NULL) {
- if (FD_ISSET(data.fds[i].fd, writefds)) {
- if (data.fds[i].revents & (POLLOUT |
- POLLWRNORM | POLLWRBAND))
- got_one = 1;
- else
- FD_CLR(data.fds[i].fd,
- writefds);
- }
- }
- if (exceptfds != NULL) {
- if (FD_ISSET(data.fds[i].fd, exceptfds)) {
- if (data.fds[i].revents & (POLLRDBAND |
- POLLPRI | POLLHUP | POLLERR |
- POLLNVAL))
- got_one = 1;
- else
- FD_CLR(data.fds[i].fd,
- exceptfds);
- }
- }
- if (got_one)
- numfds++;
- }
- ret = numfds;
- }
-
- return (ret);
-}
-
-__strong_reference(_select, select);
-#endif
diff --git a/lib/libpthread/thread/thr_self.c b/lib/libpthread/thread/thr_self.c
deleted file mode 100644
index 81ec427a3f04..000000000000
--- a/lib/libpthread/thread/thr_self.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-pthread_t
-pthread_self(void)
-{
- /* Return the running thread pointer: */
- return (_thread_run);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_sem.c b/lib/libpthread/thread/thr_sem.c
deleted file mode 100644
index d893c9405582..000000000000
--- a/lib/libpthread/thread/thr_sem.c
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * Copyright (C) 2000 Jason Evans <jasone@canonware.com>.
- * 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(s), this list of conditions and the following disclaimer as
- * the first lines of this file unmodified other than the possible
- * addition of one or more copyright notices.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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.
- *
- * $FreeBSD$
- */
-
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <semaphore.h>
-#include <pthread.h>
-#include "pthread_private.h"
-
-#define _SEM_CHECK_VALIDITY(sem) \
- if ((*(sem))->magic != SEM_MAGIC) { \
- errno = EINVAL; \
- retval = -1; \
- goto RETURN; \
- }
-
-int
-sem_init(sem_t *sem, int pshared, unsigned int value)
-{
- int retval;
-
- /*
- * Range check the arguments.
- */
- if (pshared != 0) {
- /*
- * The user wants a semaphore that can be shared among
- * processes, which this implementation can't do. Sounds like a
- * permissions problem to me (yeah right).
- */
- errno = EPERM;
- retval = -1;
- goto RETURN;
- }
-
- if (value > SEM_VALUE_MAX) {
- errno = EINVAL;
- retval = -1;
- goto RETURN;
- }
-
- *sem = (sem_t)malloc(sizeof(struct sem));
- if (*sem == NULL) {
- errno = ENOSPC;
- retval = -1;
- goto RETURN;
- }
-
- /*
- * Initialize the semaphore.
- */
- if (pthread_mutex_init(&(*sem)->lock, NULL) != 0) {
- free(*sem);
- errno = ENOSPC;
- retval = -1;
- goto RETURN;
- }
-
- if (pthread_cond_init(&(*sem)->gtzero, NULL) != 0) {
- pthread_mutex_destroy(&(*sem)->lock);
- free(*sem);
- errno = ENOSPC;
- retval = -1;
- goto RETURN;
- }
-
- (*sem)->count = (u_int32_t)value;
- (*sem)->nwaiters = 0;
- (*sem)->magic = SEM_MAGIC;
-
- retval = 0;
- RETURN:
- return retval;
-}
-
-int
-sem_destroy(sem_t *sem)
-{
- int retval;
-
- _SEM_CHECK_VALIDITY(sem);
-
- /* Make sure there are no waiters. */
- pthread_mutex_lock(&(*sem)->lock);
- if ((*sem)->nwaiters > 0) {
- pthread_mutex_unlock(&(*sem)->lock);
- errno = EBUSY;
- retval = -1;
- goto RETURN;
- }
- pthread_mutex_unlock(&(*sem)->lock);
-
- pthread_mutex_destroy(&(*sem)->lock);
- pthread_cond_destroy(&(*sem)->gtzero);
- (*sem)->magic = 0;
-
- free(*sem);
-
- retval = 0;
- RETURN:
- return retval;
-}
-
-sem_t *
-sem_open(const char *name, int oflag, ...)
-{
- errno = ENOSYS;
- return SEM_FAILED;
-}
-
-int
-sem_close(sem_t *sem)
-{
- errno = ENOSYS;
- return -1;
-}
-
-int
-sem_unlink(const char *name)
-{
- errno = ENOSYS;
- return -1;
-}
-
-int
-sem_wait(sem_t *sem)
-{
- int retval;
-
- _thread_enter_cancellation_point();
-
- _SEM_CHECK_VALIDITY(sem);
-
- pthread_mutex_lock(&(*sem)->lock);
-
- while ((*sem)->count == 0) {
- (*sem)->nwaiters++;
- pthread_cond_wait(&(*sem)->gtzero, &(*sem)->lock);
- (*sem)->nwaiters--;
- }
- (*sem)->count--;
-
- pthread_mutex_unlock(&(*sem)->lock);
-
- retval = 0;
- RETURN:
- _thread_leave_cancellation_point();
- return retval;
-}
-
-int
-sem_trywait(sem_t *sem)
-{
- int retval;
-
- _SEM_CHECK_VALIDITY(sem);
-
- pthread_mutex_lock(&(*sem)->lock);
-
- if ((*sem)->count > 0) {
- (*sem)->count--;
- retval = 0;
- } else {
- errno = EAGAIN;
- retval = -1;
- }
-
- pthread_mutex_unlock(&(*sem)->lock);
-
- RETURN:
- return retval;
-}
-
-int
-sem_post(sem_t *sem)
-{
- int retval;
-
- _SEM_CHECK_VALIDITY(sem);
-
- pthread_mutex_lock(&(*sem)->lock);
-
- (*sem)->count++;
- if ((*sem)->nwaiters > 0) {
- /*
- * We must use pthread_cond_broadcast() rather than
- * pthread_cond_signal() in order to assure that the highest
- * priority thread is run by the scheduler, since
- * pthread_cond_signal() signals waiting threads in FIFO order.
- */
- pthread_cond_broadcast(&(*sem)->gtzero);
- }
-
- pthread_mutex_unlock(&(*sem)->lock);
-
- retval = 0;
- RETURN:
- return retval;
-}
-
-int
-sem_getvalue(sem_t *sem, int *sval)
-{
- int retval;
-
- _SEM_CHECK_VALIDITY(sem);
-
- pthread_mutex_lock(&(*sem)->lock);
- *sval = (int)(*sem)->count;
- pthread_mutex_unlock(&(*sem)->lock);
-
- retval = 0;
- RETURN:
- return retval;
-}
-#endif
diff --git a/lib/libpthread/thread/thr_seterrno.c b/lib/libpthread/thread/thr_seterrno.c
deleted file mode 100644
index 1934aac7222a..000000000000
--- a/lib/libpthread/thread/thr_seterrno.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-/*
- * This function needs to reference the global error variable which is
- * normally hidden from the user.
- */
-#ifdef errno
-#undef errno;
-#endif
-extern int errno;
-
-void
-_thread_seterrno(pthread_t thread, int error)
-{
- /* Check for the initial thread: */
- if (thread == _thread_initial)
- /* The initial thread always uses the global error variable: */
- errno = error;
- else
- /*
- * Threads other than the initial thread always use the error
- * field in the thread structureL
- */
- thread->error = error;
-}
-#endif
diff --git a/lib/libpthread/thread/thr_setprio.c b/lib/libpthread/thread/thr_setprio.c
deleted file mode 100644
index c630db52d8f9..000000000000
--- a/lib/libpthread/thread/thr_setprio.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_setprio(pthread_t pthread, int prio)
-{
- int ret, policy;
- struct sched_param param;
-
- if ((ret = pthread_getschedparam(pthread, &policy, &param)) == 0) {
- param.sched_priority = prio;
- ret = pthread_setschedparam(pthread, policy, &param);
- }
-
- /* Return the error status: */
- return (ret);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_setschedparam.c b/lib/libpthread/thread/thr_setschedparam.c
deleted file mode 100644
index f080d5ddba57..000000000000
--- a/lib/libpthread/thread/thr_setschedparam.c
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>.
- * 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 Daniel Eischen.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#include <sys/param.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_setschedparam(pthread_t pthread, int policy,
- const struct sched_param *param)
-{
- int old_prio, in_readyq = 0, ret = 0;
-
- if ((param == NULL) || (param->sched_priority < PTHREAD_MIN_PRIORITY) ||
- (param->sched_priority > PTHREAD_MAX_PRIORITY) ||
- (policy < SCHED_FIFO) || (policy > SCHED_RR))
- /* Return an invalid argument error: */
- ret = EINVAL;
-
- /* Find the thread in the list of active threads: */
- else if ((ret = _find_thread(pthread)) == 0) {
- /*
- * Defer signals to protect the scheduling queues from
- * access by the signal handler:
- */
- _thread_kern_sig_defer();
-
- if (param->sched_priority != pthread->base_priority) {
- /*
- * Remove the thread from its current priority
- * queue before any adjustments are made to its
- * active priority:
- */
- old_prio = pthread->active_priority;
- if ((pthread->flags & PTHREAD_FLAGS_IN_PRIOQ) != 0) {
- in_readyq = 1;
- PTHREAD_PRIOQ_REMOVE(pthread);
- }
-
- /* Set the thread base priority: */
- pthread->base_priority = param->sched_priority;
-
- /* Recalculate the active priority: */
- pthread->active_priority = MAX(pthread->base_priority,
- pthread->inherited_priority);
-
- if (in_readyq) {
- if ((pthread->priority_mutex_count > 0) &&
- (old_prio > pthread->active_priority)) {
- /*
- * POSIX states that if the priority is
- * being lowered, the thread must be
- * inserted at the head of the queue for
- * its priority if it owns any priority
- * protection or inheritence mutexes.
- */
- PTHREAD_PRIOQ_INSERT_HEAD(pthread);
- }
- else
- PTHREAD_PRIOQ_INSERT_TAIL(pthread);
- }
-
- /*
- * Check for any mutex priority adjustments. This
- * includes checking for a priority mutex on which
- * this thread is waiting.
- */
- _mutex_notify_priochange(pthread);
- }
-
- /* Set the scheduling policy: */
- pthread->attr.sched_policy = policy;
-
- /*
- * Undefer and handle pending signals, yielding if
- * necessary:
- */
- _thread_kern_sig_undefer();
- }
- return(ret);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_sig.c b/lib/libpthread/thread/thr_sig.c
deleted file mode 100644
index dc6d209f85b0..000000000000
--- a/lib/libpthread/thread/thr_sig.c
+++ /dev/null
@@ -1,759 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/signalvar.h>
-#include <signal.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <setjmp.h>
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-/* Prototypes: */
-static void thread_sig_check_state(pthread_t pthread, int sig);
-static void thread_sig_finish_longjmp(void *arg);
-static void handle_state_change(pthread_t pthread);
-
-
-/* Static variables: */
-static spinlock_t signal_lock = _SPINLOCK_INITIALIZER;
-static unsigned int pending_sigs[NSIG];
-static unsigned int handled_sigs[NSIG];
-static int volatile check_pending = 0;
-static int volatile check_waiting = 0;
-
-/* Initialize signal handling facility: */
-void
-_thread_sig_init(void)
-{
- int i;
-
- /* Clear pending and handled signal counts: */
- for (i = 1; i < NSIG; i++) {
- pending_sigs[i - 1] = 0;
- handled_sigs[i - 1] = 0;
- }
-
- /* Clear the lock: */
- signal_lock.access_lock = 0;
-
- /* Clear the process pending signals: */
- sigemptyset(&_process_sigpending);
-}
-
-void
-_thread_sig_handler(int sig, int code, ucontext_t * scp)
-{
- pthread_t pthread, pthread_next;
- int i;
- char c;
-
- /* Check if an interval timer signal: */
- if (sig == _SCHED_SIGNAL) {
- if (_thread_kern_in_sched != 0) {
- /*
- * The scheduler is already running; ignore this
- * signal.
- */
- }
- /*
- * Check if the scheduler interrupt has come when
- * the currently running thread has deferred thread
- * signals.
- */
- else if (_thread_run->sig_defer_count > 0)
- _thread_run->yield_on_sig_undefer = 1;
-
- else {
- /*
- * Schedule the next thread. This function is not
- * expected to return because it will do a longjmp
- * instead.
- */
- _thread_kern_sched(scp);
-
- /*
- * This point should not be reached, so abort the
- * process:
- */
- PANIC("Returned to signal function from scheduler");
- }
- }
- /*
- * Check if the kernel has been interrupted while the scheduler
- * is accessing the scheduling queues or if there is a currently
- * running thread that has deferred signals.
- */
- else if ((_queue_signals != 0) || ((_thread_kern_in_sched == 0) &&
- (_thread_run->sig_defer_count > 0))) {
- /* Cast the signal number to a character variable: */
- c = sig;
-
- /*
- * Write the signal number to the kernel pipe so that it will
- * be ready to read when this signal handler returns.
- */
- _thread_sys_write(_thread_kern_pipe[1], &c, 1);
-
- /* Indicate that there are queued signals in the pipe. */
- _sigq_check_reqd = 1;
- } else {
- if (_atomic_lock(&signal_lock.access_lock)) {
- /* There is another signal handler running: */
- pending_sigs[sig - 1]++;
- check_pending = 1;
- }
- else {
- /* It's safe to handle the signal now. */
- pthread = _thread_sig_handle(sig, scp);
-
- /* Reset the pending and handled count back to 0: */
- pending_sigs[sig - 1] = 0;
- handled_sigs[sig - 1] = 0;
-
- if (pthread == NULL)
- signal_lock.access_lock = 0;
- else {
- sigaddset(&pthread->sigmask, sig);
-
- /*
- * Make sure not to deliver the same signal to
- * the thread twice. sigpend is potentially
- * modified by the call chain
- * _thread_sig_handle() -->
- * thread_sig_check_state(), which can happen
- * just above.
- */
- if (sigismember(&pthread->sigpend, sig))
- sigdelset(&pthread->sigpend, sig);
-
- signal_lock.access_lock = 0;
- _thread_sig_deliver(pthread, sig);
- sigdelset(&pthread->sigmask, sig);
- }
- }
-
- /* Enter a loop to process pending signals: */
- while ((check_pending != 0) &&
- (_atomic_lock(&signal_lock.access_lock) == 0)) {
- check_pending = 0;
- for (i = 1; i < NSIG; i++) {
- if (pending_sigs[i - 1] > handled_sigs[i - 1]) {
- pending_sigs[i - 1] = handled_sigs[i - 1];
- pthread = _thread_sig_handle(i, scp);
- if (pthread != NULL) {
- sigaddset(&pthread->sigmask, i);
- /* Save the old state: */
- pthread->oldstate = pthread->state;
- signal_lock.access_lock = 0;
- _thread_sig_deliver(pthread, i);
- sigdelset(&pthread->sigmask, i);
- if (_atomic_lock(&signal_lock.access_lock)) {
- check_pending = 1;
- /*
- * Have the lock holder take care
- * of any state changes:
- */
- if (pthread->state != pthread->oldstate)
- check_waiting = 1;
- return;
- }
- if (pthread->state != pthread->oldstate)
- handle_state_change(pthread);
- }
- }
- }
- while (check_waiting != 0) {
- check_waiting = 0;
- /*
- * Enter a loop to wake up all threads waiting
- * for a process to complete:
- */
- for (pthread = TAILQ_FIRST(&_waitingq);
- pthread != NULL; pthread = pthread_next) {
- pthread_next = TAILQ_NEXT(pthread, pqe);
- if (pthread->state == PS_RUNNING)
- handle_state_change(pthread);
- }
- }
- /* Release the lock: */
- signal_lock.access_lock = 0;
- }
-
- /*
- * Check to see if the current thread performed a
- * [sig|_]longjmp() out of a signal handler.
- */
- if ((_thread_run->jmpflags & (JMPFLAGS_LONGJMP |
- JMPFLAGS__LONGJMP)) != 0) {
- _thread_run->jmpflags = JMPFLAGS_NONE;
- __longjmp(_thread_run->nested_jmp.jmp,
- _thread_run->longjmp_val);
- } else if ((_thread_run->jmpflags & JMPFLAGS_SIGLONGJMP) != 0) {
- _thread_run->jmpflags = JMPFLAGS_NONE;
- __siglongjmp(_thread_run->nested_jmp.sigjmp,
- _thread_run->longjmp_val);
- }
- }
-}
-
-pthread_t
-_thread_sig_handle(int sig, ucontext_t * scp)
-{
- int i, handler_installed;
- pthread_t pthread, pthread_next;
- pthread_t suspended_thread, signaled_thread;
-
- /* Check if the signal requires a dump of thread information: */
- if (sig == SIGINFO)
- /* Dump thread information to file: */
- _thread_dump_info();
-
- /* Check if an interval timer signal: */
- else if (sig == _SCHED_SIGNAL) {
- /*
- * This shouldn't ever occur (should this panic?).
- */
- } else {
- /* Check if a child has terminated: */
- if (sig == SIGCHLD) {
- /*
- * Go through the file list and set all files
- * to non-blocking again in case the child
- * set some of them to block. Sigh.
- */
- for (i = 0; i < _thread_dtablesize; i++) {
- /* Check if this file is used: */
- if (_thread_fd_table[i] != NULL) {
- /*
- * Set the file descriptor to
- * non-blocking:
- */
- _thread_sys_fcntl(i, F_SETFL,
- _thread_fd_table[i]->flags |
- O_NONBLOCK);
- }
- }
- /*
- * Enter a loop to wake up all threads waiting
- * for a process to complete:
- */
- for (pthread = TAILQ_FIRST(&_waitingq);
- pthread != NULL; pthread = pthread_next) {
- /*
- * Grab the next thread before possibly
- * destroying the link entry:
- */
- pthread_next = TAILQ_NEXT(pthread, pqe);
-
- /*
- * If this thread is waiting for a child
- * process to complete, wake it up:
- */
- if (pthread->state == PS_WAIT_WAIT) {
- /* Make the thread runnable: */
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
-
- /* Return the signal number: */
- pthread->signo = sig;
- }
- }
- }
-
- /*
- * POSIX says that pending SIGCONT signals are
- * discarded when one of these signals occurs.
- */
- if (sig == SIGTSTP || sig == SIGTTIN || sig == SIGTTOU) {
- /*
- * Enter a loop to discard pending SIGCONT
- * signals:
- */
- TAILQ_FOREACH(pthread, &_thread_list, tle) {
- sigdelset(&pthread->sigpend,SIGCONT);
- }
- }
-
- /*
- * Enter a loop to look for threads that have the signal
- * unmasked. POSIX specifies that a thread in a sigwait
- * will get the signal over any other threads. Second
- * preference will be threads in in a sigsuspend. If
- * none of the above, then the signal is delivered to the
- * first thread we find. Note that if a custom handler
- * is not installed, the signal only affects threads in
- * sigwait.
- */
- suspended_thread = NULL;
- signaled_thread = NULL;
- if ((_thread_sigact[sig - 1].sa_handler == SIG_IGN) ||
- (_thread_sigact[sig - 1].sa_handler == SIG_DFL))
- handler_installed = 0;
- else
- handler_installed = 1;
-
- for (pthread = TAILQ_FIRST(&_waitingq);
- pthread != NULL; pthread = pthread_next) {
- /*
- * Grab the next thread before possibly destroying
- * the link entry.
- */
- pthread_next = TAILQ_NEXT(pthread, pqe);
-
- if ((pthread->state == PS_SIGWAIT) &&
- sigismember(pthread->data.sigwait, sig)) {
- /* Change the state of the thread to run: */
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
-
- /* Return the signal number: */
- pthread->signo = sig;
-
- /*
- * POSIX doesn't doesn't specify which thread
- * will get the signal if there are multiple
- * waiters, so we give it to the first thread
- * we find.
- *
- * Do not attempt to deliver this signal
- * to other threads.
- */
- return (NULL);
- }
- else if ((handler_installed != 0) &&
- !sigismember(&pthread->sigmask, sig)) {
- if (pthread->state == PS_SIGSUSPEND) {
- if (suspended_thread == NULL)
- suspended_thread = pthread;
- } else if (signaled_thread == NULL)
- signaled_thread = pthread;
- }
- }
-
- /*
- * Only perform wakeups and signal delivery if there is a
- * custom handler installed:
- */
- if (handler_installed != 0) {
- /*
- * If we didn't find a thread in the waiting queue,
- * check the all threads queue:
- */
- if (suspended_thread == NULL &&
- signaled_thread == NULL) {
- /*
- * Enter a loop to look for other threads
- * capable of receiving the signal:
- */
- TAILQ_FOREACH(pthread, &_thread_list, tle) {
- if (!sigismember(&pthread->sigmask,
- sig)) {
- signaled_thread = pthread;
- break;
- }
- }
- }
-
- if (suspended_thread == NULL &&
- signaled_thread == NULL)
- /*
- * Add it to the set of signals pending
- * on the process:
- */
- sigaddset(&_process_sigpending, sig);
- else {
- /*
- * We only deliver the signal to one thread;
- * give preference to the suspended thread:
- */
- if (suspended_thread != NULL)
- pthread = suspended_thread;
- else
- pthread = signaled_thread;
-
- /*
- * Perform any state changes due to signal
- * arrival:
- */
- thread_sig_check_state(pthread, sig);
- return (pthread);
- }
- }
- }
-
- /* Returns nothing. */
- return (NULL);
-}
-
-static void
-thread_sig_finish_longjmp(void *arg)
-{
- /*
- * Check to see if the current thread performed a [_]longjmp() out of a
- * signal handler.
- */
- if ((_thread_run->jmpflags & (JMPFLAGS_LONGJMP | JMPFLAGS__LONGJMP))
- != 0) {
- _thread_run->jmpflags = JMPFLAGS_NONE;
- _thread_run->continuation = NULL;
- __longjmp(_thread_run->nested_jmp.jmp,
- _thread_run->longjmp_val);
- }
- /*
- * Check to see if the current thread performed a siglongjmp
- * out of a signal handler:
- */
- else if ((_thread_run->jmpflags & JMPFLAGS_SIGLONGJMP) != 0) {
- _thread_run->jmpflags = JMPFLAGS_NONE;
- _thread_run->continuation = NULL;
- __siglongjmp(_thread_run->nested_jmp.sigjmp,
- _thread_run->longjmp_val);
- }
-}
-
-static void
-handle_state_change(pthread_t pthread)
-{
- /*
- * We should only need to handle threads whose state was
- * changed to running:
- */
- if (pthread->state == PS_RUNNING) {
- switch (pthread->oldstate) {
- /*
- * States which do not change when a signal is trapped:
- */
- case PS_DEAD:
- case PS_DEADLOCK:
- case PS_RUNNING:
- case PS_SIGTHREAD:
- case PS_STATE_MAX:
- break;
-
- /*
- * States which need to return to critical sections
- * before they can switch contexts:
- */
- case PS_COND_WAIT:
- case PS_FDLR_WAIT:
- case PS_FDLW_WAIT:
- case PS_FILE_WAIT:
- case PS_JOIN:
- case PS_MUTEX_WAIT:
- /* Indicate that the thread was interrupted: */
- pthread->interrupted = 1;
- /*
- * Defer the [sig|_]longjmp until leaving the critical
- * region:
- */
- pthread->jmpflags |= JMPFLAGS_DEFERRED;
-
- /* Set the continuation routine: */
- pthread->continuation = thread_sig_finish_longjmp;
- /* FALLTHROUGH */
- case PS_FDR_WAIT:
- case PS_FDW_WAIT:
- case PS_POLL_WAIT:
- case PS_SELECT_WAIT:
- case PS_SIGSUSPEND:
- case PS_SIGWAIT:
- case PS_SLEEP_WAIT:
- case PS_SPINBLOCK:
- case PS_SUSPENDED:
- case PS_WAIT_WAIT:
- if ((pthread->flags & PTHREAD_FLAGS_IN_WAITQ) != 0) {
- PTHREAD_WAITQ_REMOVE(pthread);
- if (pthread->flags & PTHREAD_FLAGS_IN_WORKQ)
- PTHREAD_WORKQ_REMOVE(pthread);
- }
- break;
- }
-
- if ((pthread->flags & PTHREAD_FLAGS_IN_PRIOQ) == 0)
- PTHREAD_PRIOQ_INSERT_TAIL(pthread);
- }
-}
-
-
-/* Perform thread specific actions in response to a signal: */
-static void
-thread_sig_check_state(pthread_t pthread, int sig)
-{
- /*
- * Process according to thread state:
- */
- switch (pthread->state) {
- /*
- * States which do not change when a signal is trapped:
- */
- case PS_COND_WAIT:
- case PS_DEAD:
- case PS_DEADLOCK:
- case PS_FILE_WAIT:
- case PS_JOIN:
- case PS_MUTEX_WAIT:
- case PS_RUNNING:
- case PS_STATE_MAX:
- case PS_SIGTHREAD:
- case PS_SPINBLOCK:
- case PS_SUSPENDED:
- /* Increment the pending signal count. */
- sigaddset(&pthread->sigpend,sig);
- break;
-
- case PS_SIGWAIT:
- /* Wake up the thread if the signal is blocked. */
- if (sigismember(pthread->data.sigwait, sig)) {
- /* Change the state of the thread to run: */
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
-
- /* Return the signal number: */
- pthread->signo = sig;
- } else
- /* Increment the pending signal count. */
- sigaddset(&pthread->sigpend,sig);
- break;
-
- /*
- * The wait state is a special case due to the handling of
- * SIGCHLD signals.
- */
- case PS_WAIT_WAIT:
- /*
- * Check for signals other than the death of a child
- * process:
- */
- if (sig != SIGCHLD)
- /* Flag the operation as interrupted: */
- pthread->interrupted = 1;
-
- /* Change the state of the thread to run: */
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
-
- /* Return the signal number: */
- pthread->signo = sig;
- break;
-
- /*
- * States that are interrupted by the occurrence of a signal
- * other than the scheduling alarm:
- */
- case PS_FDLR_WAIT:
- case PS_FDLW_WAIT:
- case PS_FDR_WAIT:
- case PS_FDW_WAIT:
- case PS_POLL_WAIT:
- case PS_SLEEP_WAIT:
- case PS_SELECT_WAIT:
- if ((_thread_sigact[sig - 1].sa_flags & SA_RESTART) == 0) {
- /* Flag the operation as interrupted: */
- pthread->interrupted = 1;
-
- if (pthread->flags & PTHREAD_FLAGS_IN_WORKQ)
- PTHREAD_WORKQ_REMOVE(pthread);
-
- /* Change the state of the thread to run: */
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
-
- /* Return the signal number: */
- pthread->signo = sig;
- }
- break;
-
- case PS_SIGSUSPEND:
- /*
- * Only wake up the thread if there is a handler installed
- * for the signal.
- */
- if (_thread_sigact[sig - 1].sa_handler != SIG_DFL) {
- /* Change the state of the thread to run: */
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
-
- /* Return the signal number: */
- pthread->signo = sig;
- }
- break;
- }
-}
-
-/* Send a signal to a specific thread (ala pthread_kill): */
-void
-_thread_sig_send(pthread_t pthread, int sig)
-{
- /*
- * Check that the signal is not being ignored:
- */
- if (_thread_sigact[sig - 1].sa_handler != SIG_IGN) {
- if (pthread->state == PS_SIGWAIT &&
- sigismember(pthread->data.sigwait, sig)) {
- /* Change the state of the thread to run: */
- PTHREAD_NEW_STATE(pthread,PS_RUNNING);
-
- /* Return the signal number: */
- pthread->signo = sig;
- } else if (pthread->state != PS_SIGWAIT &&
- !sigismember(&pthread->sigmask, sig)) {
- /* Perform any state changes due to signal arrival: */
- thread_sig_check_state(pthread, sig);
- }
-
- /* Increment the pending signal count. */
- sigaddset(&pthread->sigpend,sig);
- }
-}
-
-/* Dispatch pending signals to the running thread: */
-void
-_dispatch_signals()
-{
- sigset_t sigset;
- int i;
-
- /*
- * Check if there are pending signals for the running
- * thread or process that aren't blocked:
- */
- sigset = _thread_run->sigpend;
- SIGSETOR(sigset, _process_sigpending);
- SIGSETNAND(sigset, _thread_run->sigmask);
- if (SIGNOTEMPTY(sigset)) {
- /*
- * Enter a loop to calculate deliverable pending signals
- * before actually delivering them. The pending signals
- * must be removed from the pending signal sets before
- * calling the signal handler because the handler may
- * call library routines that again check for and deliver
- * pending signals.
- */
- for (i = 1; i < NSIG; i++) {
- /*
- * Check that a custom handler is installed
- * and if the signal is not blocked:
- */
- if (_thread_sigact[i - 1].sa_handler != SIG_DFL &&
- _thread_sigact[i - 1].sa_handler != SIG_IGN &&
- sigismember(&sigset, i)) {
- if (sigismember(&_thread_run->sigpend,i))
- /* Clear the thread pending signal: */
- sigdelset(&_thread_run->sigpend,i);
- else
- /* Clear the process pending signal: */
- sigdelset(&_process_sigpending,i);
- }
- else
- /* Remove the signal if it can't be handled: */
- sigdelset(&sigset, i);
- }
-
- /* Now deliver the signals: */
- for (i = 1; i < NSIG; i++) {
- if (sigismember(&sigset, i))
- /* Deliver the signal to the running thread: */
- _thread_sig_deliver(_thread_run, i);
- }
- }
-}
-
-/* Deliver a signal to a thread: */
-void
-_thread_sig_deliver(pthread_t pthread, int sig)
-{
- sigset_t mask;
- pthread_t pthread_saved;
- jmp_buf jb, *saved_sighandler_jmp_buf;
-
- /*
- * Check that a custom handler is installed
- * and if the signal is not blocked:
- */
- if (_thread_sigact[sig - 1].sa_handler != SIG_DFL &&
- _thread_sigact[sig - 1].sa_handler != SIG_IGN) {
- /* Save the current thread: */
- pthread_saved = _thread_run;
-
- /* Save the threads signal mask: */
- mask = pthread->sigmask;
-
- /*
- * Add the current signal and signal handler
- * mask to the thread's current signal mask:
- */
- SIGSETOR(pthread->sigmask, _thread_sigact[sig - 1].sa_mask);
- sigaddset(&pthread->sigmask, sig);
-
- /* Current thread inside critical region? */
- if (_thread_run->sig_defer_count > 0)
- pthread->sig_defer_count++;
-
- /* Increment the number of nested signals being handled. */
- pthread->signal_nest_level++;
-
- /*
- * The jump buffer is allocated off the stack and the current
- * jump buffer is saved. If the signal handler tries to
- * [sig|_]longjmp(), our version of [sig|_]longjmp() will copy
- * the user supplied jump buffer into
- * _thread_run->nested_jmp.[sig]jmp and _longjmp() back to here.
- */
- saved_sighandler_jmp_buf = pthread->sighandler_jmp_buf;
- pthread->sighandler_jmp_buf = &jb;
-
- _thread_run = pthread;
-
- if (_setjmp(jb) == 0) {
- /*
- * Dispatch the signal via the custom signal
- * handler:
- */
- (*(_thread_sigact[sig - 1].sa_handler))(sig);
- }
-
- _thread_run = pthread_saved;
-
- pthread->sighandler_jmp_buf = saved_sighandler_jmp_buf;
-
- /* Decrement the signal nest level. */
- pthread->signal_nest_level--;
-
- /* Current thread inside critical region? */
- if (_thread_run->sig_defer_count > 0)
- pthread->sig_defer_count--;
-
- /* Restore the threads signal mask: */
- pthread->sigmask = mask;
- }
-}
-#endif
diff --git a/lib/libpthread/thread/thr_sigaction.c b/lib/libpthread/thread/thr_sigaction.c
deleted file mode 100644
index 319999bf3047..000000000000
--- a/lib/libpthread/thread/thr_sigaction.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <signal.h>
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-_sigaction(int sig, const struct sigaction * act, struct sigaction * oact)
-{
- int ret = 0;
- struct sigaction gact;
-
- /* Check if the signal number is out of range: */
- if (sig < 1 || sig > NSIG) {
- /* Return an invalid argument: */
- errno = EINVAL;
- ret = -1;
- } else {
- /*
- * Check if the existing signal action structure contents are
- * to be returned:
- */
- if (oact != NULL) {
- /* Return the existing signal action contents: */
- oact->sa_handler = _thread_sigact[sig - 1].sa_handler;
- oact->sa_mask = _thread_sigact[sig - 1].sa_mask;
- oact->sa_flags = _thread_sigact[sig - 1].sa_flags;
- }
-
- /* Check if a signal action was supplied: */
- if (act != NULL) {
- /* Set the new signal handler: */
- _thread_sigact[sig - 1].sa_mask = act->sa_mask;
- _thread_sigact[sig - 1].sa_flags = act->sa_flags;
- _thread_sigact[sig - 1].sa_handler = act->sa_handler;
- }
-
- /*
- * Check if the kernel needs to be advised of a change
- * in signal action:
- */
- if (act != NULL && sig != _SCHED_SIGNAL && sig != SIGCHLD &&
- sig != SIGINFO) {
- /* Initialise the global signal action structure: */
- gact.sa_mask = act->sa_mask;
- gact.sa_flags = 0;
-
- /* Ensure the scheduling signal is masked: */
- sigaddset(&gact.sa_mask, _SCHED_SIGNAL);
-
- /*
- * Check if the signal handler is being set to
- * the default or ignore handlers:
- */
- if (act->sa_handler == SIG_DFL ||
- act->sa_handler == SIG_IGN)
- /* Specify the built in handler: */
- gact.sa_handler = act->sa_handler;
- else
- /*
- * Specify the thread kernel signal
- * handler:
- */
- gact.sa_handler = (void (*) ()) _thread_sig_handler;
-
- /* Change the signal action in the kernel: */
- if (_thread_sys_sigaction(sig,&gact,NULL) != 0)
- ret = -1;
- }
- }
-
- /* Return the completion status: */
- return (ret);
-}
-
-__strong_reference(_sigaction, sigaction);
-#endif
diff --git a/lib/libpthread/thread/thr_sigmask.c b/lib/libpthread/thread/thr_sigmask.c
deleted file mode 100644
index b880d9c748c8..000000000000
--- a/lib/libpthread/thread/thr_sigmask.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/signalvar.h>
-#include <errno.h>
-#include <signal.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-pthread_sigmask(int how, const sigset_t *set, sigset_t *oset)
-{
- int ret = 0;
-
- /* Check if the existing signal process mask is to be returned: */
- if (oset != NULL) {
- /* Return the current mask: */
- *oset = _thread_run->sigmask;
- }
- /* Check if a new signal set was provided by the caller: */
- if (set != NULL) {
- /* Process according to what to do: */
- switch (how) {
- /* Block signals: */
- case SIG_BLOCK:
- /* Add signals to the existing mask: */
- SIGSETOR(_thread_run->sigmask, *set);
- break;
-
- /* Unblock signals: */
- case SIG_UNBLOCK:
- /* Clear signals from the existing mask: */
- SIGSETNAND(_thread_run->sigmask, *set);
- break;
-
- /* Set the signal process mask: */
- case SIG_SETMASK:
- /* Set the new mask: */
- _thread_run->sigmask = *set;
- break;
-
- /* Trap invalid actions: */
- default:
- /* Return an invalid argument: */
- errno = EINVAL;
- ret = -1;
- break;
- }
-
- /*
- * Dispatch signals to the running thread that are pending
- * and now unblocked:
- */
- _dispatch_signals();
- }
-
- /* Return the completion status: */
- return (ret);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_sigpending.c b/lib/libpthread/thread/thr_sigpending.c
deleted file mode 100644
index a118347ca974..000000000000
--- a/lib/libpthread/thread/thr_sigpending.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 1999 Daniel Eischen <eischen@vigrid.com>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <signal.h>
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-_sigpending(sigset_t * set)
-{
- int ret = 0;
-
- /* Check for a null signal set pointer: */
- if (set == NULL) {
- /* Return an invalid argument: */
- ret = EINVAL;
- }
- else {
- *set = _thread_run->sigpend;
- }
- /* Return the completion status: */
- return (ret);
-}
-
-__strong_reference(_sigpending, sigpending);
-#endif
diff --git a/lib/libpthread/thread/thr_sigprocmask.c b/lib/libpthread/thread/thr_sigprocmask.c
deleted file mode 100644
index 6addb4a948e9..000000000000
--- a/lib/libpthread/thread/thr_sigprocmask.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/signalvar.h>
-#include <signal.h>
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-_sigprocmask(int how, const sigset_t * set, sigset_t * oset)
-{
- int ret = 0;
-
- /* Check if the existing signal process mask is to be returned: */
- if (oset != NULL) {
- /* Return the current mask: */
- *oset = _thread_run->sigmask;
- }
- /* Check if a new signal set was provided by the caller: */
- if (set != NULL) {
- /* Process according to what to do: */
- switch (how) {
- /* Block signals: */
- case SIG_BLOCK:
- /* Add signals to the existing mask: */
- SIGSETOR(_thread_run->sigmask, *set);
- break;
-
- /* Unblock signals: */
- case SIG_UNBLOCK:
- /* Clear signals from the existing mask: */
- SIGSETNAND(_thread_run->sigmask, *set);
- break;
-
- /* Set the signal process mask: */
- case SIG_SETMASK:
- /* Set the new mask: */
- _thread_run->sigmask = *set;
- break;
-
- /* Trap invalid actions: */
- default:
- /* Return an invalid argument: */
- errno = EINVAL;
- ret = -1;
- break;
- }
-
- /*
- * Dispatch signals to the running thread that are pending
- * and now unblocked:
- */
- _dispatch_signals();
- }
- /* Return the completion status: */
- return (ret);
-}
-
-__strong_reference(_sigprocmask, sigprocmask);
-#endif
diff --git a/lib/libpthread/thread/thr_sigsuspend.c b/lib/libpthread/thread/thr_sigsuspend.c
deleted file mode 100644
index 28959c8e094a..000000000000
--- a/lib/libpthread/thread/thr_sigsuspend.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <signal.h>
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-_sigsuspend(const sigset_t * set)
-{
- int ret = -1;
- sigset_t oset;
-
- /* Check if a new signal set was provided by the caller: */
- if (set != NULL) {
- /* Save the current signal mask: */
- oset = _thread_run->sigmask;
-
- /* Change the caller's mask: */
- _thread_run->sigmask = *set;
-
- /* Wait for a signal: */
- _thread_kern_sched_state(PS_SIGSUSPEND, __FILE__, __LINE__);
-
- /* Always return an interrupted error: */
- errno = EINTR;
-
- /* Restore the signal mask: */
- _thread_run->sigmask = oset;
- } else {
- /* Return an invalid argument error: */
- errno = EINVAL;
- }
-
- /* Return the completion status: */
- return (ret);
-}
-
-int
-sigsuspend(const sigset_t * set)
-{
- int ret;
-
- _thread_enter_cancellation_point();
- ret = _sigsuspend(set);
- _thread_leave_cancellation_point();
-
- return ret;
-}
-#endif
diff --git a/lib/libpthread/thread/thr_sigwait.c b/lib/libpthread/thread/thr_sigwait.c
deleted file mode 100644
index a50968768082..000000000000
--- a/lib/libpthread/thread/thr_sigwait.c
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <signal.h>
-#include <sys/param.h>
-#include <sys/signalvar.h>
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-sigwait(const sigset_t * set, int *sig)
-{
- int ret = 0;
- int i;
- sigset_t tempset, waitset;
- struct sigaction act;
-
- _thread_enter_cancellation_point();
- /*
- * Specify the thread kernel signal handler.
- */
- act.sa_handler = (void (*) ()) _thread_sig_handler;
- act.sa_flags = SA_RESTART;
- act.sa_mask = *set;
-
- /* Ensure the scheduling signal is masked: */
- sigaddset(&act.sa_mask, _SCHED_SIGNAL);
-
- /*
- * Initialize the set of signals that will be waited on:
- */
- waitset = *set;
-
- /* These signals can't be waited on. */
- sigdelset(&waitset, SIGKILL);
- sigdelset(&waitset, SIGSTOP);
- sigdelset(&waitset, _SCHED_SIGNAL);
- sigdelset(&waitset, SIGCHLD);
- sigdelset(&waitset, SIGINFO);
-
- /* Check to see if a pending signal is in the wait mask. */
- tempset = _thread_run->sigpend;
- SIGSETOR(tempset, _process_sigpending);
- SIGSETAND(tempset, waitset);
- if (SIGNOTEMPTY(tempset)) {
- /* Enter a loop to find a pending signal: */
- for (i = 1; i < NSIG; i++) {
- if (sigismember (&tempset, i))
- break;
- }
-
- /* Clear the pending signal: */
- if (sigismember(&_thread_run->sigpend,i))
- sigdelset(&_thread_run->sigpend,i);
- else
- sigdelset(&_process_sigpending,i);
-
- /* Return the signal number to the caller: */
- *sig = i;
-
- _thread_leave_cancellation_point();
- return (0);
- }
-
- /*
- * Enter a loop to find the signals that are SIG_DFL. For
- * these signals we must install a dummy signal handler in
- * order for the kernel to pass them in to us. POSIX says
- * that the _application_ must explicitly install a dummy
- * handler for signals that are SIG_IGN in order to sigwait
- * on them. Note that SIG_IGN signals are left in the
- * mask because a subsequent sigaction could enable an
- * ignored signal.
- */
- for (i = 1; i < NSIG; i++) {
- if (sigismember(&waitset, i) &&
- (_thread_sigact[i - 1].sa_handler == SIG_DFL)) {
- if (_thread_sys_sigaction(i,&act,NULL) != 0)
- ret = -1;
- }
- }
- if (ret == 0) {
- /*
- * Save the wait signal mask. The wait signal
- * mask is independent of the threads signal mask
- * and requires separate storage.
- */
- _thread_run->data.sigwait = &waitset;
-
- /* Wait for a signal: */
- _thread_kern_sched_state(PS_SIGWAIT, __FILE__, __LINE__);
-
- /* Return the signal number to the caller: */
- *sig = _thread_run->signo;
-
- /*
- * Probably unnecessary, but since it's in a union struct
- * we don't know how it could be used in the future.
- */
- _thread_run->data.sigwait = NULL;
- }
-
- /* Restore the sigactions: */
- act.sa_handler = SIG_DFL;
- for (i = 1; i < NSIG; i++) {
- if (sigismember(&waitset, i) &&
- (_thread_sigact[i - 1].sa_handler == SIG_DFL)) {
- if (_thread_sys_sigaction(i,&act,NULL) != 0)
- ret = -1;
- }
- }
-
- _thread_leave_cancellation_point();
-
- /* Return the completion status: */
- return (ret);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_single_np.c b/lib/libpthread/thread/thr_single_np.c
deleted file mode 100644
index d6ecb48b4259..000000000000
--- a/lib/libpthread/thread/thr_single_np.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <string.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int pthread_single_np()
-{
- /* Enter single-threaded (non-POSIX) scheduling mode: */
- _thread_single = _thread_run;
- return(0);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_sleep.c b/lib/libpthread/thread/thr_sleep.c
deleted file mode 100644
index 34a592587024..000000000000
--- a/lib/libpthread/thread/thr_sleep.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2000 Jason Evans <jasone@canonware.com>.
- * 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(s), this list of conditions and the following disclaimer as
- * the first lines of this file unmodified other than the possible
- * addition of one or more copyright notices.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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.
- *
- * $FreeBSD$
- */
-
-#include <unistd.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-unsigned int
-sleep(unsigned int seconds)
-{
- unsigned int ret;
-
- _thread_enter_cancellation_point();
- ret = __sleep(seconds);
- _thread_leave_cancellation_point();
-
- return ret;
-}
-#endif
diff --git a/lib/libpthread/thread/thr_spec.c b/lib/libpthread/thread/thr_spec.c
deleted file mode 100644
index 1485cbb7e9d9..000000000000
--- a/lib/libpthread/thread/thr_spec.c
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <signal.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-/* Static variables: */
-static struct pthread_key key_table[PTHREAD_KEYS_MAX];
-
-int
-pthread_key_create(pthread_key_t * key, void (*destructor) (void *))
-{
- for ((*key) = 0; (*key) < PTHREAD_KEYS_MAX; (*key)++) {
- /* Lock the key table entry: */
- _SPINLOCK(&key_table[*key].lock);
-
- if (key_table[(*key)].allocated == 0) {
- key_table[(*key)].allocated = 1;
- key_table[(*key)].destructor = destructor;
-
- /* Unlock the key table entry: */
- _SPINUNLOCK(&key_table[*key].lock);
- return (0);
- }
-
- /* Unlock the key table entry: */
- _SPINUNLOCK(&key_table[*key].lock);
- }
- return (EAGAIN);
-}
-
-int
-pthread_key_delete(pthread_key_t key)
-{
- int ret = 0;
-
- if (key < PTHREAD_KEYS_MAX) {
- /* Lock the key table entry: */
- _SPINLOCK(&key_table[key].lock);
-
- if (key_table[key].allocated)
- key_table[key].allocated = 0;
- else
- ret = EINVAL;
-
- /* Unlock the key table entry: */
- _SPINUNLOCK(&key_table[key].lock);
- } else
- ret = EINVAL;
- return (ret);
-}
-
-void
-_thread_cleanupspecific(void)
-{
- void *data = NULL;
- int key;
- int itr;
- void (*destructor)( void *);
-
- for (itr = 0; itr < PTHREAD_DESTRUCTOR_ITERATIONS; itr++) {
- for (key = 0; key < PTHREAD_KEYS_MAX; key++) {
- if (_thread_run->specific_data_count) {
- /* Lock the key table entry: */
- _SPINLOCK(&key_table[key].lock);
- destructor = NULL;
-
- if (key_table[key].allocated) {
- if (_thread_run->specific_data[key]) {
- data = (void *) _thread_run->specific_data[key];
- _thread_run->specific_data[key] = NULL;
- _thread_run->specific_data_count--;
- destructor = key_table[key].destructor;
- }
- }
-
- /* Unlock the key table entry: */
- _SPINUNLOCK(&key_table[key].lock);
-
- /*
- * If there is a destructore, call it
- * with the key table entry unlocked:
- */
- if (destructor)
- destructor(data);
- } else {
- free(_thread_run->specific_data);
- _thread_run->specific_data = NULL;
- return;
- }
- }
- }
- free(_thread_run->specific_data);
- _thread_run->specific_data = NULL;
-}
-
-static inline const void **
-pthread_key_allocate_data(void)
-{
- const void **new_data;
- if ((new_data = (const void **) malloc(sizeof(void *) * PTHREAD_KEYS_MAX)) != NULL) {
- memset((void *) new_data, 0, sizeof(void *) * PTHREAD_KEYS_MAX);
- }
- return (new_data);
-}
-
-int
-pthread_setspecific(pthread_key_t key, const void *value)
-{
- pthread_t pthread;
- int ret = 0;
-
- /* Point to the running thread: */
- pthread = _thread_run;
-
- if ((pthread->specific_data) ||
- (pthread->specific_data = pthread_key_allocate_data())) {
- if (key < PTHREAD_KEYS_MAX) {
- if (key_table[key].allocated) {
- if (pthread->specific_data[key] == NULL) {
- if (value != NULL)
- pthread->specific_data_count++;
- } else {
- if (value == NULL)
- pthread->specific_data_count--;
- }
- pthread->specific_data[key] = value;
- ret = 0;
- } else
- ret = EINVAL;
- } else
- ret = EINVAL;
- } else
- ret = ENOMEM;
- return (ret);
-}
-
-void *
-pthread_getspecific(pthread_key_t key)
-{
- pthread_t pthread;
- void *data;
-
- /* Point to the running thread: */
- pthread = _thread_run;
-
- /* Check if there is specific data: */
- if (pthread->specific_data != NULL && key < PTHREAD_KEYS_MAX) {
- /* Check if this key has been used before: */
- if (key_table[key].allocated) {
- /* Return the value: */
- data = (void *) pthread->specific_data[key];
- } else {
- /*
- * This key has not been used before, so return NULL
- * instead:
- */
- data = NULL;
- }
- } else
- /* No specific data has been created, so just return NULL: */
- data = NULL;
- return (data);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_spinlock.c b/lib/libpthread/thread/thr_spinlock.c
deleted file mode 100644
index e797f90a90fa..000000000000
--- a/lib/libpthread/thread/thr_spinlock.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (c) 1997 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- *
- */
-
-#include <stdio.h>
-#include <sched.h>
-#include <unistd.h>
-#include <pthread.h>
-#include <string.h>
-#include "pthread_private.h"
-
-extern char *__progname;
-
-/*
- * Lock a location for the running thread. Yield to allow other
- * threads to run if this thread is blocked because the lock is
- * not available. Note that this function does not sleep. It
- * assumes that the lock will be available very soon.
- */
-void
-_spinlock(spinlock_t *lck)
-{
- /*
- * Try to grab the lock and loop if another thread grabs
- * it before we do.
- */
- while(_atomic_lock(&lck->access_lock)) {
- /* Block the thread until the lock. */
- _thread_run->data.spinlock = lck;
- _thread_kern_sched_state(PS_SPINBLOCK, __FILE__, __LINE__);
- }
-
- /* The running thread now owns the lock: */
- lck->lock_owner = (long) _thread_run;
-}
-
-/*
- * Lock a location for the running thread. Yield to allow other
- * threads to run if this thread is blocked because the lock is
- * not available. Note that this function does not sleep. It
- * assumes that the lock will be available very soon.
- *
- * This function checks if the running thread has already locked the
- * location, warns if this occurs and creates a thread dump before
- * returning.
- */
-void
-_spinlock_debug(spinlock_t *lck, char *fname, int lineno)
-{
- int cnt = 0;
-
- /*
- * Try to grab the lock and loop if another thread grabs
- * it before we do.
- */
- while(_atomic_lock(&lck->access_lock)) {
- cnt++;
- if (cnt > 100) {
- char str[256];
- snprintf(str, sizeof(str), "%s - Warning: Thread %p attempted to lock %p from %s (%d) was left locked from %s (%d)\n", __progname, _thread_run, lck, fname, lineno, lck->fname, lck->lineno);
- _thread_sys_write(2,str,strlen(str));
- __sleep(1);
- cnt = 0;
- }
-
- /* Block the thread until the lock. */
- _thread_run->data.spinlock = lck;
- _thread_kern_sched_state(PS_SPINBLOCK, fname, lineno);
- }
-
- /* The running thread now owns the lock: */
- lck->lock_owner = (long) _thread_run;
- lck->fname = fname;
- lck->lineno = lineno;
-}
diff --git a/lib/libpthread/thread/thr_suspend_np.c b/lib/libpthread/thread/thr_suspend_np.c
deleted file mode 100644
index ea9b1f857af5..000000000000
--- a/lib/libpthread/thread/thr_suspend_np.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-/* Suspend a thread: */
-int
-pthread_suspend_np(pthread_t thread)
-{
- int ret;
-
- /* Find the thread in the list of active threads: */
- if ((ret = _find_thread(thread)) == 0) {
- /* The thread exists. Is it running? */
- if (thread->state != PS_RUNNING &&
- thread->state != PS_SUSPENDED) {
- /* The thread operation has been interrupted */
- _thread_seterrno(thread,EINTR);
- thread->interrupted = 1;
- }
-
- /*
- * Defer signals to protect the scheduling queues from
- * access by the signal handler:
- */
- _thread_kern_sig_defer();
-
- /* Suspend the thread. */
- PTHREAD_NEW_STATE(thread,PS_SUSPENDED);
-
- /*
- * Undefer and handle pending signals, yielding if
- * necessary:
- */
- _thread_kern_sig_undefer();
- }
- return(ret);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_switch_np.c b/lib/libpthread/thread/thr_switch_np.c
deleted file mode 100644
index 9b83545fdd7e..000000000000
--- a/lib/libpthread/thread/thr_switch_np.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 1998 Daniel Eischen <eischen@vigrid.com>.
- * 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 Daniel Eischen.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include <pthread_np.h>
-#include "pthread_private.h"
-
-
-int
-pthread_switch_add_np(pthread_switch_routine_t routine)
-{
- int ret = 0;
-
- if (routine == NULL)
- /* Return an invalid argument error: */
- ret = EINVAL;
- else
- /* Shouldn't need a lock to protect this assigment. */
- _sched_switch_hook = routine;
-
- return(ret);
-}
-
-int
-pthread_switch_delete_np(pthread_switch_routine_t routine)
-{
- int ret = 0;
-
- if (routine != _sched_switch_hook)
- /* Return an invalid argument error: */
- ret = EINVAL;
- else
- /* Shouldn't need a lock to protect this assigment. */
- _sched_switch_hook = NULL;
-
- return(ret);
-}
-#endif
diff --git a/lib/libpthread/thread/thr_system.c b/lib/libpthread/thread/thr_system.c
deleted file mode 100644
index 9265975b0a0f..000000000000
--- a/lib/libpthread/thread/thr_system.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2000 Jason Evans <jasone@canonware.com>.
- * 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(s), this list of conditions and the following disclaimer as
- * the first lines of this file unmodified other than the possible
- * addition of one or more copyright notices.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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.
- *
- * $FreeBSD$
- */
-
-#include <stdlib.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-system(const char *string)
-{
- int ret;
-
- _thread_enter_cancellation_point();
- ret = __system(string);
- _thread_leave_cancellation_point();
-
- return ret;
-}
-#endif
diff --git a/lib/libpthread/thread/thr_tcdrain.c b/lib/libpthread/thread/thr_tcdrain.c
deleted file mode 100644
index d040599ed521..000000000000
--- a/lib/libpthread/thread/thr_tcdrain.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2000 Jason Evans <jasone@canonware.com>.
- * 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(s), this list of conditions and the following disclaimer as
- * the first lines of this file unmodified other than the possible
- * addition of one or more copyright notices.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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.
- *
- * $FreeBSD$
- */
-
-#include <termios.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-tcdrain(int fd)
-{
- int ret;
-
- _thread_enter_cancellation_point();
- ret = __tcdrain(fd);
- _thread_leave_cancellation_point();
-
- return ret;
-}
-#endif
diff --git a/lib/libpthread/thread/thr_vfork.c b/lib/libpthread/thread/thr_vfork.c
deleted file mode 100644
index bbfcf002bc02..000000000000
--- a/lib/libpthread/thread/thr_vfork.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <unistd.h>
-#ifdef _THREAD_SAFE
-
-int
-vfork(void)
-{
- return (fork());
-}
-#endif
diff --git a/lib/libpthread/thread/thr_wait.c b/lib/libpthread/thread/thr_wait.c
deleted file mode 100644
index abc19cc7cc04..000000000000
--- a/lib/libpthread/thread/thr_wait.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2000 Jason Evans <jasone@canonware.com>.
- * 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(s), this list of conditions and the following disclaimer as
- * the first lines of this file unmodified other than the possible
- * addition of one or more copyright notices.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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.
- *
- * $FreeBSD$
- */
-
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-pid_t
-wait(int *istat)
-{
- pid_t ret;
-
- _thread_enter_cancellation_point();
- ret = __wait(istat);
- _thread_leave_cancellation_point();
-
- return ret;
-}
-#endif
diff --git a/lib/libpthread/thread/thr_wait4.c b/lib/libpthread/thread/thr_wait4.c
deleted file mode 100644
index 083c230ec88c..000000000000
--- a/lib/libpthread/thread/thr_wait4.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <errno.h>
-#include <sys/wait.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-pid_t
-_wait4(pid_t pid, int *istat, int options, struct rusage * rusage)
-{
- pid_t ret;
-
- _thread_kern_sig_defer();
-
- /* Perform a non-blocking wait4 syscall: */
- while ((ret = _thread_sys_wait4(pid, istat, options | WNOHANG, rusage)) == 0 && (options & WNOHANG) == 0) {
- /* Reset the interrupted operation flag: */
- _thread_run->interrupted = 0;
-
- /* Schedule the next thread while this one waits: */
- _thread_kern_sched_state(PS_WAIT_WAIT, __FILE__, __LINE__);
-
- /* Check if this call was interrupted by a signal: */
- if (_thread_run->interrupted) {
- errno = EINTR;
- ret = -1;
- break;
- }
- }
-
- _thread_kern_sig_undefer();
-
- return (ret);
-}
-
-__strong_reference(_wait4, wait4);
-#endif
diff --git a/lib/libpthread/thread/thr_waitpid.c b/lib/libpthread/thread/thr_waitpid.c
deleted file mode 100644
index a8472959e741..000000000000
--- a/lib/libpthread/thread/thr_waitpid.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2000 Jason Evans <jasone@canonware.com>.
- * 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(s), this list of conditions and the following disclaimer as
- * the first lines of this file unmodified other than the possible
- * addition of one or more copyright notices.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/types.h>
-#include <sys/wait.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-pid_t
-waitpid(pid_t wpid, int *status, int options)
-{
- pid_t ret;
-
- _thread_enter_cancellation_point();
- ret = __waitpid(wpid, status, options);
- _thread_leave_cancellation_point();
-
- return ret;
-}
-#endif
diff --git a/lib/libpthread/thread/thr_write.c b/lib/libpthread/thread/thr_write.c
deleted file mode 100644
index 6408a64830c2..000000000000
--- a/lib/libpthread/thread/thr_write.c
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- *
- */
-#include <sys/types.h>
-#include <sys/fcntl.h>
-#include <sys/uio.h>
-#include <errno.h>
-#include <unistd.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-ssize_t
-_write(int fd, const void *buf, size_t nbytes)
-{
- int blocking;
- int type;
- ssize_t n;
- ssize_t num = 0;
- ssize_t ret;
-
- /* POSIX says to do just this: */
- if (nbytes == 0)
- return (0);
-
- /* Lock the file descriptor for write: */
- if ((ret = _FD_LOCK(fd, FD_WRITE, NULL)) == 0) {
- /* Get the read/write mode type: */
- type = _thread_fd_table[fd]->flags & O_ACCMODE;
-
- /* Check if the file is not open for write: */
- if (type != O_WRONLY && type != O_RDWR) {
- /* File is not open for write: */
- errno = EBADF;
- _FD_UNLOCK(fd, FD_WRITE);
- return (-1);
- }
-
- /* Check if file operations are to block */
- blocking = ((_thread_fd_table[fd]->flags & O_NONBLOCK) == 0);
-
- /*
- * Loop while no error occurs and until the expected number
- * of bytes are written if performing a blocking write:
- */
- while (ret == 0) {
- /* Perform a non-blocking write syscall: */
- n = _thread_sys_write(fd, buf + num, nbytes - num);
-
- /* Check if one or more bytes were written: */
- if (n > 0)
- /*
- * Keep a count of the number of bytes
- * written:
- */
- num += n;
-
- /*
- * If performing a blocking write, check if the
- * write would have blocked or if some bytes
- * were written but there are still more to
- * write:
- */
- if (blocking && ((n < 0 && (errno == EWOULDBLOCK ||
- errno == EAGAIN)) || (n >= 0 && num < nbytes))) {
- _thread_run->data.fd.fd = fd;
- _thread_kern_set_timeout(NULL);
-
- /* Reset the interrupted operation flag: */
- _thread_run->interrupted = 0;
-
- _thread_kern_sched_state(PS_FDW_WAIT,
- __FILE__, __LINE__);
-
- /*
- * Check if the operation was
- * interrupted by a signal
- */
- if (_thread_run->interrupted) {
- /* Return an error: */
- ret = -1;
- }
-
- /*
- * If performing a non-blocking write or if an
- * error occurred, just return whatever the write
- * syscall did:
- */
- } else if (!blocking || n < 0) {
- /* A non-blocking call might return zero: */
- ret = n;
- break;
-
- /* Check if the write has completed: */
- } else if (num >= nbytes)
- /* Return the number of bytes written: */
- ret = num;
- }
- _FD_UNLOCK(fd, FD_RDWR);
- }
- return (ret);
-}
-
-ssize_t
-write(int fd, const void *buf, size_t nbytes)
-{
- ssize_t ret;
-
- _thread_enter_cancellation_point();
- ret = _write(fd, buf, nbytes);
- _thread_leave_cancellation_point();
-
- return ret;
-}
-#endif
diff --git a/lib/libpthread/thread/thr_writev.c b/lib/libpthread/thread/thr_writev.c
deleted file mode 100644
index 5f3146887765..000000000000
--- a/lib/libpthread/thread/thr_writev.c
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- *
- */
-#include <sys/types.h>
-#include <sys/fcntl.h>
-#include <sys/uio.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-ssize_t
-_writev(int fd, const struct iovec * iov, int iovcnt)
-{
- int blocking;
- int idx = 0;
- int type;
- ssize_t cnt;
- ssize_t n;
- ssize_t num = 0;
- ssize_t ret;
- struct iovec liov[20];
- struct iovec *p_iov = liov;
-
- /* Check if the array size exceeds to compiled in size: */
- if (iovcnt > (sizeof(liov) / sizeof(struct iovec))) {
- /* Allocate memory for the local array: */
- if ((p_iov = (struct iovec *)
- malloc(iovcnt * sizeof(struct iovec))) == NULL) {
- /* Insufficient memory: */
- errno = ENOMEM;
- return (-1);
- }
- }
-
- /* Copy the caller's array so that it can be modified locally: */
- memcpy(p_iov,iov,iovcnt * sizeof(struct iovec));
-
- /* Lock the file descriptor for write: */
- if ((ret = _FD_LOCK(fd, FD_WRITE, NULL)) == 0) {
- /* Get the read/write mode type: */
- type = _thread_fd_table[fd]->flags & O_ACCMODE;
-
- /* Check if the file is not open for write: */
- if (type != O_WRONLY && type != O_RDWR) {
- /* File is not open for write: */
- errno = EBADF;
- _FD_UNLOCK(fd, FD_WRITE);
- return (-1);
- }
-
- /* Check if file operations are to block */
- blocking = ((_thread_fd_table[fd]->flags & O_NONBLOCK) == 0);
-
- /*
- * Loop while no error occurs and until the expected number
- * of bytes are written if performing a blocking write:
- */
- while (ret == 0) {
- /* Perform a non-blocking write syscall: */
- n = _thread_sys_writev(fd, &p_iov[idx], iovcnt - idx);
-
- /* Check if one or more bytes were written: */
- if (n > 0) {
- /*
- * Keep a count of the number of bytes
- * written:
- */
- num += n;
-
- /*
- * Enter a loop to check if a short write
- * occurred and move the index to the
- * array entry where the short write
- * ended:
- */
- cnt = n;
- while (cnt > 0 && idx < iovcnt) {
- /*
- * If the residual count exceeds
- * the size of this vector, then
- * it was completely written:
- */
- if (cnt >= p_iov[idx].iov_len)
- /*
- * Decrement the residual
- * count and increment the
- * index to the next array
- * entry:
- */
- cnt -= p_iov[idx++].iov_len;
- else {
- /*
- * This entry was only
- * partially written, so
- * adjust it's length
- * and base pointer ready
- * for the next write:
- */
- p_iov[idx].iov_len -= cnt;
- p_iov[idx].iov_base += cnt;
- cnt = 0;
- }
- }
- } else if (n == 0) {
- /*
- * Avoid an infinite loop if the last iov_len is
- * 0.
- */
- while (idx < iovcnt && p_iov[idx].iov_len == 0)
- idx++;
-
- if (idx == iovcnt) {
- ret = num;
- break;
- }
- }
-
- /*
- * If performing a blocking write, check if the
- * write would have blocked or if some bytes
- * were written but there are still more to
- * write:
- */
- if (blocking && ((n < 0 && (errno == EWOULDBLOCK ||
- errno == EAGAIN)) || (n >= 0 && idx < iovcnt))) {
- _thread_run->data.fd.fd = fd;
- _thread_kern_set_timeout(NULL);
-
- /* Reset the interrupted operation flag: */
- _thread_run->interrupted = 0;
-
- _thread_kern_sched_state(PS_FDW_WAIT,
- __FILE__, __LINE__);
-
- /*
- * Check if the operation was
- * interrupted by a signal
- */
- if (_thread_run->interrupted) {
- /* Return an error: */
- ret = -1;
- }
-
- /*
- * If performing a non-blocking write or if an
- * error occurred, just return whatever the write
- * syscall did:
- */
- } else if (!blocking || n < 0) {
- /* A non-blocking call might return zero: */
- ret = n;
- break;
-
- /* Check if the write has completed: */
- } else if (idx == iovcnt)
- /* Return the number of bytes written: */
- ret = num;
- }
- _FD_UNLOCK(fd, FD_RDWR);
- }
-
- /* If memory was allocated for the array, free it: */
- if (p_iov != liov)
- free(p_iov);
-
- return (ret);
-}
-
-__strong_reference(_writev, writev);
-#endif
diff --git a/lib/libpthread/thread/thr_yield.c b/lib/libpthread/thread/thr_yield.c
deleted file mode 100644
index 064dd826d34c..000000000000
--- a/lib/libpthread/thread/thr_yield.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#ifdef _THREAD_SAFE
-#include <pthread.h>
-#include "pthread_private.h"
-
-int
-sched_yield(void)
-{
- /* Reset the accumulated time slice value for the current thread: */
- _thread_run->slice_usec = -1;
-
- /* Schedule the next thread: */
- _thread_kern_sched(NULL);
-
- /* Always return no error. */
- return(0);
-}
-
-/* Draft 4 yield */
-void
-pthread_yield(void)
-{
- /* Reset the accumulated time slice value for the current thread: */
- _thread_run->slice_usec = -1;
-
- /* Schedule the next thread: */
- _thread_kern_sched(NULL);
-
- /* Nothing to return. */
- return;
-}
-#endif
diff --git a/lib/libstand/gzipfs.c b/lib/libstand/gzipfs.c
deleted file mode 100644
index b0e30073cd7e..000000000000
--- a/lib/libstand/gzipfs.c
+++ /dev/null
@@ -1,318 +0,0 @@
-/*
- * Copyright (c) 1998 Michael Smith.
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- *
- */
-
-#include "stand.h"
-
-#include <sys/stat.h>
-#include <string.h>
-#include <zlib.h>
-
-#define Z_BUFSIZE 2048 /* XXX larger? */
-
-struct z_file
-{
- int zf_rawfd;
- z_stream zf_zstream;
- char zf_buf[Z_BUFSIZE];
-};
-
-static int zf_fill(struct z_file *z);
-static int zf_open(const char *path, struct open_file *f);
-static int zf_close(struct open_file *f);
-static int zf_read(struct open_file *f, void *buf, size_t size, size_t *resid);
-static off_t zf_seek(struct open_file *f, off_t offset, int where);
-static int zf_stat(struct open_file *f, struct stat *sb);
-
-struct fs_ops zipfs_fsops = {
- "zip",
- zf_open,
- zf_close,
- zf_read,
- null_write,
- zf_seek,
- zf_stat
-};
-
-#if 0
-void *
-calloc(int items, size_t size)
-{
- return(malloc(items * size));
-}
-#endif
-
-static int
-zf_fill(struct z_file *zf)
-{
- int result;
- int req;
-
- req = Z_BUFSIZE - zf->zf_zstream.avail_in;
- result = 0;
-
- /* If we need more */
- if (req > 0) {
- /* move old data to bottom of buffer */
- if (req < Z_BUFSIZE)
- bcopy(zf->zf_buf + req, zf->zf_buf, Z_BUFSIZE - req);
-
- /* read to fill buffer and update availibility data */
- result = read(zf->zf_rawfd, zf->zf_buf + zf->zf_zstream.avail_in, req);
- zf->zf_zstream.next_in = zf->zf_buf;
- if (result >= 0)
- zf->zf_zstream.avail_in += result;
- }
- return(result);
-}
-
-/*
- * Adapted from get_byte/check_header in libz
- *
- * Returns 0 if the header is OK, nonzero if not.
- */
-static int
-get_byte(struct z_file *zf)
-{
- if ((zf->zf_zstream.avail_in == 0) && (zf_fill(zf) == -1))
- return(-1);
- zf->zf_zstream.avail_in--;
- return(*(zf->zf_zstream.next_in)++);
-}
-
-static int gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */
-
-/* gzip flag byte */
-#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */
-#define HEAD_CRC 0x02 /* bit 1 set: header CRC present */
-#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
-#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
-#define COMMENT 0x10 /* bit 4 set: file comment present */
-#define RESERVED 0xE0 /* bits 5..7: reserved */
-
-static int
-check_header(struct z_file *zf)
-{
- int method; /* method byte */
- int flags; /* flags byte */
- uInt len;
- int c;
-
- /* Check the gzip magic header */
- for (len = 0; len < 2; len++) {
- c = get_byte(zf);
- if (c != gz_magic[len]) {
- return(1);
- }
- }
- method = get_byte(zf);
- flags = get_byte(zf);
- if (method != Z_DEFLATED || (flags & RESERVED) != 0) {
- return(1);
- }
-
- /* Discard time, xflags and OS code: */
- for (len = 0; len < 6; len++) (void)get_byte(zf);
-
- if ((flags & EXTRA_FIELD) != 0) { /* skip the extra field */
- len = (uInt)get_byte(zf);
- len += ((uInt)get_byte(zf))<<8;
- /* len is garbage if EOF but the loop below will quit anyway */
- while (len-- != 0 && get_byte(zf) != -1) ;
- }
- if ((flags & ORIG_NAME) != 0) { /* skip the original file name */
- while ((c = get_byte(zf)) != 0 && c != -1) ;
- }
- if ((flags & COMMENT) != 0) { /* skip the .gz file comment */
- while ((c = get_byte(zf)) != 0 && c != -1) ;
- }
- if ((flags & HEAD_CRC) != 0) { /* skip the header crc */
- for (len = 0; len < 2; len++) c = get_byte(zf);
- }
- /* if there's data left, we're in business */
- return((c == -1) ? 1 : 0);
-}
-
-static int
-zf_open(const char *fname, struct open_file *f)
-{
- static char *zfname;
- int rawfd;
- struct z_file *zf;
- char *cp;
- int error;
- struct stat sb;
-
- /* Have to be in "just read it" mode */
- if (f->f_flags != F_READ)
- return(EPERM);
-
- /* If the name already ends in .gz, ignore it */
- if ((cp = strrchr(fname, '.')) && !strcmp(cp, ".gz"))
- return(ENOENT);
-
- /* Construct new name */
- zfname = malloc(strlen(fname) + 4);
- sprintf(zfname, "%s.gz", fname);
-
- /* Try to open the compressed datafile */
- rawfd = open(zfname, O_RDONLY);
- free(zfname);
- if (rawfd == -1)
- return(ENOENT);
-
- if (fstat(rawfd, &sb) < 0) {
- printf("zf_open: stat failed\n");
- close(rawfd);
- return(ENOENT);
- }
- if (!S_ISREG(sb.st_mode)) {
- printf("zf_open: not a file\n");
- close(rawfd);
- return(EISDIR); /* best guess */
- }
-
- /* Allocate a z_file structure, populate it */
- zf = malloc(sizeof(struct z_file));
- bzero(zf, sizeof(struct z_file));
- zf->zf_rawfd = rawfd;
-
- /* Verify that the file is gzipped (XXX why do this afterwards?) */
- if (check_header(zf)) {
- close(zf->zf_rawfd);
- inflateEnd(&(zf->zf_zstream));
- free(zf);
- return(EFTYPE);
- }
-
- /* Initialise the inflation engine */
- if ((error = inflateInit2(&(zf->zf_zstream), -15)) != Z_OK) {
- printf("zf_open: inflateInit returned %d : %s\n", error, zf->zf_zstream.msg);
- close(zf->zf_rawfd);
- free(zf);
- return(EIO);
- }
-
- /* Looks OK, we'll take it */
- f->f_fsdata = zf;
- return(0);
-}
-
-static int
-zf_close(struct open_file *f)
-{
- struct z_file *zf = (struct z_file *)f->f_fsdata;
-
- inflateEnd(&(zf->zf_zstream));
- close(zf->zf_rawfd);
- free(zf);
- return(0);
-}
-
-static int
-zf_read(struct open_file *f, void *buf, size_t size, size_t *resid)
-{
- struct z_file *zf = (struct z_file *)f->f_fsdata;
- int error;
-
- zf->zf_zstream.next_out = buf; /* where and how much */
- zf->zf_zstream.avail_out = size;
-
- while (zf->zf_zstream.avail_out) {
- if ((zf->zf_zstream.avail_in == 0) && (zf_fill(zf) == -1)) {
- printf("zf_read: fill error\n");
- return(-1);
- }
- if (zf->zf_zstream.avail_in == 0) { /* oops, unexpected EOF */
- printf("zf_read: unexpected EOF\n");
- break;
- }
-
- error = inflate(&zf->zf_zstream, Z_SYNC_FLUSH); /* decompression pass */
- if (error == Z_STREAM_END) { /* EOF, all done */
- break;
- }
- if (error != Z_OK) { /* argh, decompression error */
- printf("inflate: %s\n", zf->zf_zstream.msg);
- errno = EIO;
- return(-1);
- }
- }
- if (resid != NULL)
- *resid = zf->zf_zstream.avail_out;
- return(0);
-}
-
-static off_t
-zf_seek(struct open_file *f, off_t offset, int where)
-{
- struct z_file *zf = (struct z_file *)f->f_fsdata;
- off_t target;
- char discard[16];
-
- switch (where) {
- case SEEK_SET:
- target = offset;
- break;
- case SEEK_CUR:
- target = offset + zf->zf_zstream.total_out;
- break;
- default:
- target = -1;
- }
-
- /* Can we get there from here? */
- if (target < zf->zf_zstream.total_out) {
- errno = EOFFSET;
- return -1;
- }
-
- /* skip forwards if required */
- while (target > zf->zf_zstream.total_out) {
- if (zf_read(f, discard, min(sizeof(discard), target - zf->zf_zstream.total_out), NULL) == -1)
- return(-1);
- }
- /* This is where we are (be honest if we overshot) */
- return (zf->zf_zstream.total_out);
-}
-
-
-static int
-zf_stat(struct open_file *f, struct stat *sb)
-{
- struct z_file *zf = (struct z_file *)f->f_fsdata;
- int result;
-
- /* stat as normal, but indicate that size is unknown */
- if ((result = fstat(zf->zf_rawfd, sb)) == 0)
- sb->st_size = -1;
- return(result);
-}
-
-
-
diff --git a/lib/libutil/pw_util.c b/lib/libutil/pw_util.c
deleted file mode 100644
index 207da8f0d5bf..000000000000
--- a/lib/libutil/pw_util.c
+++ /dev/null
@@ -1,262 +0,0 @@
-/*-
- * Copyright (c) 1990, 1993, 1994
- * 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-#if 0
-static const char sccsid[] = "@(#)pw_util.c 8.3 (Berkeley) 4/2/94";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-/*
- * This file is used by all the "password" programs; vipw(8), chpass(1),
- * and passwd(1).
- */
-
-#include <sys/param.h>
-#include <sys/errno.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-
-#include <err.h>
-#include <fcntl.h>
-#include <paths.h>
-#include <pwd.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "pw_util.h"
-
-extern char *tempname;
-static pid_t editpid = -1;
-static int lockfd;
-char *mppath = _PATH_PWD;
-char *masterpasswd = _PATH_MASTERPASSWD;
-
-void
-pw_cont(sig)
- int sig;
-{
-
- if (editpid != -1)
- kill(editpid, sig);
-}
-
-void
-pw_init()
-{
- struct rlimit rlim;
-
- /* Unlimited resource limits. */
- rlim.rlim_cur = rlim.rlim_max = RLIM_INFINITY;
- (void)setrlimit(RLIMIT_CPU, &rlim);
- (void)setrlimit(RLIMIT_FSIZE, &rlim);
- (void)setrlimit(RLIMIT_STACK, &rlim);
- (void)setrlimit(RLIMIT_DATA, &rlim);
- (void)setrlimit(RLIMIT_RSS, &rlim);
-
- /* Don't drop core (not really necessary, but GP's). */
- rlim.rlim_cur = rlim.rlim_max = 0;
- (void)setrlimit(RLIMIT_CORE, &rlim);
-
- /* Turn off signals. */
- (void)signal(SIGALRM, SIG_IGN);
- (void)signal(SIGHUP, SIG_IGN);
- (void)signal(SIGINT, SIG_IGN);
- (void)signal(SIGPIPE, SIG_IGN);
- (void)signal(SIGQUIT, SIG_IGN);
- (void)signal(SIGTERM, SIG_IGN);
- (void)signal(SIGCONT, pw_cont);
-
- /* Create with exact permissions. */
- (void)umask(0);
-}
-
-int
-pw_lock()
-{
- /*
- * If the master password file doesn't exist, the system is hosed.
- * Might as well try to build one. Set the close-on-exec bit so
- * that users can't get at the encrypted passwords while editing.
- * Open should allow flock'ing the file; see 4.4BSD. XXX
- */
- for (;;) {
- struct stat st;
-
- lockfd = open(masterpasswd, O_RDONLY, 0);
- if (lockfd < 0 || fcntl(lockfd, F_SETFD, 1) == -1)
- err(1, "%s", masterpasswd);
- if (flock(lockfd, LOCK_EX|LOCK_NB))
- errx(1, "the password db file is busy");
-
- /*
- * If the password file was replaced while we were trying to
- * get the lock, our hardlink count will be 0 and we have to
- * close and retry.
- */
- if (fstat(lockfd, &st) < 0)
- errx(1, "fstat() failed");
- if (st.st_nlink != 0)
- break;
- close(lockfd);
- lockfd = -1;
- }
- return (lockfd);
-}
-
-int
-pw_tmp()
-{
- static char path[MAXPATHLEN];
- int fd;
- char *p;
-
- strncpy(path, masterpasswd, MAXPATHLEN - 1);
- path[MAXPATHLEN] = '\0';
-
- if ((p = strrchr(path, '/')))
- ++p;
- else
- p = path;
- strcpy(p, "pw.XXXXXX");
- if ((fd = mkstemp(path)) == -1)
- err(1, "%s", path);
- tempname = path;
- return (fd);
-}
-
-int
-pw_mkdb(username)
-char *username;
-{
- int pstat;
- pid_t pid;
-
- (void)fflush(stderr);
- if (!(pid = fork())) {
- if(!username) {
- warnx("rebuilding the database...");
- execl(_PATH_PWD_MKDB, "pwd_mkdb", "-p", "-d", mppath,
- tempname, NULL);
- } else {
- warnx("updating the database...");
- execl(_PATH_PWD_MKDB, "pwd_mkdb", "-p", "-d", mppath,
- "-u", username, tempname, NULL);
- }
- pw_error(_PATH_PWD_MKDB, 1, 1);
- }
- pid = waitpid(pid, &pstat, 0);
- if (pid == -1 || !WIFEXITED(pstat) || WEXITSTATUS(pstat) != 0)
- return (0);
- warnx("done");
- return (1);
-}
-
-void
-pw_edit(notsetuid)
- int notsetuid;
-{
- int pstat;
- char *p, *editor;
-
- if (!(editor = getenv("EDITOR")))
- editor = _PATH_VI;
- if ((p = strrchr(editor, '/')))
- ++p;
- else
- p = editor;
-
- if (!(editpid = fork())) {
- if (notsetuid) {
- (void)setgid(getgid());
- (void)setuid(getuid());
- }
- errno = 0;
- execlp(editor, p, tempname, NULL);
- _exit(errno);
- }
- for (;;) {
- editpid = waitpid(editpid, (int *)&pstat, WUNTRACED);
- errno = WEXITSTATUS(pstat);
- if (editpid == -1)
- pw_error(editor, 1, 1);
- else if (WIFSTOPPED(pstat))
- raise(WSTOPSIG(pstat));
- else if (WIFEXITED(pstat) && errno == 0)
- break;
- else
- pw_error(editor, 1, 1);
- }
- editpid = -1;
-}
-
-void
-pw_prompt()
-{
- int c, first;
-
- (void)printf("re-edit the password file? [y]: ");
- (void)fflush(stdout);
- first = c = getchar();
- while (c != '\n' && c != EOF)
- c = getchar();
- if (first == 'n')
- pw_error(NULL, 0, 0);
-}
-
-void
-pw_error(name, err, eval)
- char *name;
- int err, eval;
-{
-#ifdef YP
- extern int _use_yp;
-#endif /* YP */
- if (err)
- warn(name);
-#ifdef YP
- if (_use_yp)
- warnx("NIS information unchanged");
- else
-#endif /* YP */
- warnx("%s: unchanged", masterpasswd);
- (void)unlink(tempname);
- exit(eval);
-}
diff --git a/lib/msun/bsdsrc/b_exp.c b/lib/msun/bsdsrc/b_exp.c
deleted file mode 100644
index fa6ea75735c5..000000000000
--- a/lib/msun/bsdsrc/b_exp.c
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Copyright (c) 1985, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-static char sccsid[] = "@(#)exp.c 8.1 (Berkeley) 6/4/93";
-#endif /* not lint */
-
-/* EXP(X)
- * RETURN THE EXPONENTIAL OF X
- * DOUBLE PRECISION (IEEE 53 bits, VAX D FORMAT 56 BITS)
- * CODED IN C BY K.C. NG, 1/19/85;
- * REVISED BY K.C. NG on 2/6/85, 2/15/85, 3/7/85, 3/24/85, 4/16/85, 6/14/86.
- *
- * Required system supported functions:
- * scalb(x,n)
- * copysign(x,y)
- * finite(x)
- *
- * Method:
- * 1. Argument Reduction: given the input x, find r and integer k such
- * that
- * x = k*ln2 + r, |r| <= 0.5*ln2 .
- * r will be represented as r := z+c for better accuracy.
- *
- * 2. Compute exp(r) by
- *
- * exp(r) = 1 + r + r*R1/(2-R1),
- * where
- * R1 = x - x^2*(p1+x^2*(p2+x^2*(p3+x^2*(p4+p5*x^2)))).
- *
- * 3. exp(x) = 2^k * exp(r) .
- *
- * Special cases:
- * exp(INF) is INF, exp(NaN) is NaN;
- * exp(-INF)= 0;
- * for finite argument, only exp(0)=1 is exact.
- *
- * Accuracy:
- * exp(x) returns the exponential of x nearly rounded. In a test run
- * with 1,156,000 random arguments on a VAX, the maximum observed
- * error was 0.869 ulps (units in the last place).
- *
- * Constants:
- * The hexadecimal values are the intended ones for the following constants.
- * The decimal values may be used, provided that the compiler will convert
- * from decimal to binary accurately enough to produce the hexadecimal values
- * shown.
- */
-
-#include "mathimpl.h"
-
-vc(ln2hi, 6.9314718055829871446E-1 ,7217,4031,0000,f7d0, 0, .B17217F7D00000)
-vc(ln2lo, 1.6465949582897081279E-12 ,bcd5,2ce7,d9cc,e4f1, -39, .E7BCD5E4F1D9CC)
-vc(lnhuge, 9.4961163736712506989E1 ,ec1d,43bd,9010,a73e, 7, .BDEC1DA73E9010)
-vc(lntiny,-9.5654310917272452386E1 ,4f01,c3bf,33af,d72e, 7,-.BF4F01D72E33AF)
-vc(invln2, 1.4426950408889634148E0 ,aa3b,40b8,17f1,295c, 1, .B8AA3B295C17F1)
-vc(p1, 1.6666666666666602251E-1 ,aaaa,3f2a,a9f1,aaaa, -2, .AAAAAAAAAAA9F1)
-vc(p2, -2.7777777777015591216E-3 ,0b60,bc36,ec94,b5f5, -8,-.B60B60B5F5EC94)
-vc(p3, 6.6137563214379341918E-5 ,b355,398a,f15f,792e, -13, .8AB355792EF15F)
-vc(p4, -1.6533902205465250480E-6 ,ea0e,b6dd,5f84,2e93, -19,-.DDEA0E2E935F84)
-vc(p5, 4.1381367970572387085E-8 ,bb4b,3431,2683,95f5, -24, .B1BB4B95F52683)
-
-#ifdef vccast
-#define ln2hi vccast(ln2hi)
-#define ln2lo vccast(ln2lo)
-#define lnhuge vccast(lnhuge)
-#define lntiny vccast(lntiny)
-#define invln2 vccast(invln2)
-#define p1 vccast(p1)
-#define p2 vccast(p2)
-#define p3 vccast(p3)
-#define p4 vccast(p4)
-#define p5 vccast(p5)
-#endif
-
-ic(p1, 1.6666666666666601904E-1, -3, 1.555555555553E)
-ic(p2, -2.7777777777015593384E-3, -9, -1.6C16C16BEBD93)
-ic(p3, 6.6137563214379343612E-5, -14, 1.1566AAF25DE2C)
-ic(p4, -1.6533902205465251539E-6, -20, -1.BBD41C5D26BF1)
-ic(p5, 4.1381367970572384604E-8, -25, 1.6376972BEA4D0)
-ic(ln2hi, 6.9314718036912381649E-1, -1, 1.62E42FEE00000)
-ic(ln2lo, 1.9082149292705877000E-10,-33, 1.A39EF35793C76)
-ic(lnhuge, 7.1602103751842355450E2, 9, 1.6602B15B7ECF2)
-ic(lntiny,-7.5137154372698068983E2, 9, -1.77AF8EBEAE354)
-ic(invln2, 1.4426950408889633870E0, 0, 1.71547652B82FE)
-
-double exp(x)
-double x;
-{
- double z,hi,lo,c;
- int k;
-
-#if !defined(vax)&&!defined(tahoe)
- if(x!=x) return(x); /* x is NaN */
-#endif /* !defined(vax)&&!defined(tahoe) */
- if( x <= lnhuge ) {
- if( x >= lntiny ) {
-
- /* argument reduction : x --> x - k*ln2 */
-
- k=invln2*x+copysign(0.5,x); /* k=NINT(x/ln2) */
-
- /* express x-k*ln2 as hi-lo and let x=hi-lo rounded */
-
- hi=x-k*ln2hi;
- x=hi-(lo=k*ln2lo);
-
- /* return 2^k*[1+x+x*c/(2+c)] */
- z=x*x;
- c= x - z*(p1+z*(p2+z*(p3+z*(p4+z*p5))));
- return scalb(1.0+(hi-(lo-(x*c)/(2.0-c))),k);
-
- }
- /* end of x > lntiny */
-
- else
- /* exp(-big#) underflows to zero */
- if(finite(x)) return(scalb(1.0,-5000));
-
- /* exp(-INF) is zero */
- else return(0.0);
- }
- /* end of x < lnhuge */
-
- else
- /* exp(INF) is INF, exp(+big#) overflows to INF */
- return( finite(x) ? scalb(1.0,5000) : x);
-}
-
-/* returns exp(r = x + c) for |c| < |x| with no overlap. */
-
-double __exp__D(x, c)
-double x, c;
-{
- double z,hi,lo, t;
- int k;
-
-#if !defined(vax)&&!defined(tahoe)
- if (x!=x) return(x); /* x is NaN */
-#endif /* !defined(vax)&&!defined(tahoe) */
- if ( x <= lnhuge ) {
- if ( x >= lntiny ) {
-
- /* argument reduction : x --> x - k*ln2 */
- z = invln2*x;
- k = z + copysign(.5, x);
-
- /* express (x+c)-k*ln2 as hi-lo and let x=hi-lo rounded */
-
- hi=(x-k*ln2hi); /* Exact. */
- x= hi - (lo = k*ln2lo-c);
- /* return 2^k*[1+x+x*c/(2+c)] */
- z=x*x;
- c= x - z*(p1+z*(p2+z*(p3+z*(p4+z*p5))));
- c = (x*c)/(2.0-c);
-
- return scalb(1.+(hi-(lo - c)), k);
- }
- /* end of x > lntiny */
-
- else
- /* exp(-big#) underflows to zero */
- if(finite(x)) return(scalb(1.0,-5000));
-
- /* exp(-INF) is zero */
- else return(0.0);
- }
- /* end of x < lnhuge */
-
- else
- /* exp(INF) is INF, exp(+big#) overflows to INF */
- return( finite(x) ? scalb(1.0,5000) : x);
-}
diff --git a/lib/msun/bsdsrc/b_log.c b/lib/msun/bsdsrc/b_log.c
deleted file mode 100644
index 908b8544f93c..000000000000
--- a/lib/msun/bsdsrc/b_log.c
+++ /dev/null
@@ -1,486 +0,0 @@
-/*
- * 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-static char sccsid[] = "@(#)log.c 8.2 (Berkeley) 11/30/93";
-#endif /* not lint */
-
-#include <math.h>
-#include <errno.h>
-
-#include "mathimpl.h"
-
-/* Table-driven natural logarithm.
- *
- * This code was derived, with minor modifications, from:
- * Peter Tang, "Table-Driven Implementation of the
- * Logarithm in IEEE Floating-Point arithmetic." ACM Trans.
- * Math Software, vol 16. no 4, pp 378-400, Dec 1990).
- *
- * Calculates log(2^m*F*(1+f/F)), |f/j| <= 1/256,
- * where F = j/128 for j an integer in [0, 128].
- *
- * log(2^m) = log2_hi*m + log2_tail*m
- * since m is an integer, the dominant term is exact.
- * m has at most 10 digits (for subnormal numbers),
- * and log2_hi has 11 trailing zero bits.
- *
- * log(F) = logF_hi[j] + logF_lo[j] is in tabular form in log_table.h
- * logF_hi[] + 512 is exact.
- *
- * log(1+f/F) = 2*f/(2*F + f) + 1/12 * (2*f/(2*F + f))**3 + ...
- * the leading term is calculated to extra precision in two
- * parts, the larger of which adds exactly to the dominant
- * m and F terms.
- * There are two cases:
- * 1. when m, j are non-zero (m | j), use absolute
- * precision for the leading term.
- * 2. when m = j = 0, |1-x| < 1/256, and log(x) ~= (x-1).
- * In this case, use a relative precision of 24 bits.
- * (This is done differently in the original paper)
- *
- * Special cases:
- * 0 return signalling -Inf
- * neg return signalling NaN
- * +Inf return +Inf
-*/
-
-#if defined(vax) || defined(tahoe)
-#define _IEEE 0
-#define TRUNC(x) x = (double) (float) (x)
-#else
-#define _IEEE 1
-#define endian (((*(int *) &one)) ? 1 : 0)
-#define TRUNC(x) *(((int *) &x) + endian) &= 0xf8000000
-#define infnan(x) 0.0
-#endif
-
-#define N 128
-
-/* Table of log(Fj) = logF_head[j] + logF_tail[j], for Fj = 1+j/128.
- * Used for generation of extend precision logarithms.
- * The constant 35184372088832 is 2^45, so the divide is exact.
- * It ensures correct reading of logF_head, even for inaccurate
- * decimal-to-binary conversion routines. (Everybody gets the
- * right answer for integers less than 2^53.)
- * Values for log(F) were generated using error < 10^-57 absolute
- * with the bc -l package.
-*/
-static double A1 = .08333333333333178827;
-static double A2 = .01250000000377174923;
-static double A3 = .002232139987919447809;
-static double A4 = .0004348877777076145742;
-
-static double logF_head[N+1] = {
- 0.,
- .007782140442060381246,
- .015504186535963526694,
- .023167059281547608406,
- .030771658666765233647,
- .038318864302141264488,
- .045809536031242714670,
- .053244514518837604555,
- .060624621816486978786,
- .067950661908525944454,
- .075223421237524235039,
- .082443669210988446138,
- .089612158689760690322,
- .096729626458454731618,
- .103796793681567578460,
- .110814366340264314203,
- .117783035656430001836,
- .124703478501032805070,
- .131576357788617315236,
- .138402322859292326029,
- .145182009844575077295,
- .151916042025732167530,
- .158605030176659056451,
- .165249572895390883786,
- .171850256926518341060,
- .178407657472689606947,
- .184922338493834104156,
- .191394852999565046047,
- .197825743329758552135,
- .204215541428766300668,
- .210564769107350002741,
- .216873938300523150246,
- .223143551314024080056,
- .229374101064877322642,
- .235566071312860003672,
- .241719936886966024758,
- .247836163904594286577,
- .253915209980732470285,
- .259957524436686071567,
- .265963548496984003577,
- .271933715484010463114,
- .277868451003087102435,
- .283768173130738432519,
- .289633292582948342896,
- .295464212893421063199,
- .301261330578199704177,
- .307025035294827830512,
- .312755710004239517729,
- .318453731118097493890,
- .324119468654316733591,
- .329753286372579168528,
- .335355541920762334484,
- .340926586970454081892,
- .346466767346100823488,
- .351976423156884266063,
- .357455888922231679316,
- .362905493689140712376,
- .368325561158599157352,
- .373716409793814818840,
- .379078352934811846353,
- .384411698910298582632,
- .389716751140440464951,
- .394993808240542421117,
- .400243164127459749579,
- .405465108107819105498,
- .410659924985338875558,
- .415827895143593195825,
- .420969294644237379543,
- .426084395310681429691,
- .431173464818130014464,
- .436236766774527495726,
- .441274560805140936281,
- .446287102628048160113,
- .451274644139630254358,
- .456237433481874177232,
- .461175715122408291790,
- .466089729924533457960,
- .470979715219073113985,
- .475845904869856894947,
- .480688529345570714212,
- .485507815781602403149,
- .490303988045525329653,
- .495077266798034543171,
- .499827869556611403822,
- .504556010751912253908,
- .509261901790523552335,
- .513945751101346104405,
- .518607764208354637958,
- .523248143765158602036,
- .527867089620485785417,
- .532464798869114019908,
- .537041465897345915436,
- .541597282432121573947,
- .546132437597407260909,
- .550647117952394182793,
- .555141507540611200965,
- .559615787935399566777,
- .564070138285387656651,
- .568504735352689749561,
- .572919753562018740922,
- .577315365035246941260,
- .581691739635061821900,
- .586049045003164792433,
- .590387446602107957005,
- .594707107746216934174,
- .599008189645246602594,
- .603290851438941899687,
- .607555250224322662688,
- .611801541106615331955,
- .616029877215623855590,
- .620240409751204424537,
- .624433288012369303032,
- .628608659422752680256,
- .632766669570628437213,
- .636907462236194987781,
- .641031179420679109171,
- .645137961373620782978,
- .649227946625615004450,
- .653301272011958644725,
- .657358072709030238911,
- .661398482245203922502,
- .665422632544505177065,
- .669430653942981734871,
- .673422675212350441142,
- .677398823590920073911,
- .681359224807238206267,
- .685304003098281100392,
- .689233281238557538017,
- .693147180560117703862
-};
-
-static double logF_tail[N+1] = {
- 0.,
- -.00000000000000543229938420049,
- .00000000000000172745674997061,
- -.00000000000001323017818229233,
- -.00000000000001154527628289872,
- -.00000000000000466529469958300,
- .00000000000005148849572685810,
- -.00000000000002532168943117445,
- -.00000000000005213620639136504,
- -.00000000000001819506003016881,
- .00000000000006329065958724544,
- .00000000000008614512936087814,
- -.00000000000007355770219435028,
- .00000000000009638067658552277,
- .00000000000007598636597194141,
- .00000000000002579999128306990,
- -.00000000000004654729747598444,
- -.00000000000007556920687451336,
- .00000000000010195735223708472,
- -.00000000000017319034406422306,
- -.00000000000007718001336828098,
- .00000000000010980754099855238,
- -.00000000000002047235780046195,
- -.00000000000008372091099235912,
- .00000000000014088127937111135,
- .00000000000012869017157588257,
- .00000000000017788850778198106,
- .00000000000006440856150696891,
- .00000000000016132822667240822,
- -.00000000000007540916511956188,
- -.00000000000000036507188831790,
- .00000000000009120937249914984,
- .00000000000018567570959796010,
- -.00000000000003149265065191483,
- -.00000000000009309459495196889,
- .00000000000017914338601329117,
- -.00000000000001302979717330866,
- .00000000000023097385217586939,
- .00000000000023999540484211737,
- .00000000000015393776174455408,
- -.00000000000036870428315837678,
- .00000000000036920375082080089,
- -.00000000000009383417223663699,
- .00000000000009433398189512690,
- .00000000000041481318704258568,
- -.00000000000003792316480209314,
- .00000000000008403156304792424,
- -.00000000000034262934348285429,
- .00000000000043712191957429145,
- -.00000000000010475750058776541,
- -.00000000000011118671389559323,
- .00000000000037549577257259853,
- .00000000000013912841212197565,
- .00000000000010775743037572640,
- .00000000000029391859187648000,
- -.00000000000042790509060060774,
- .00000000000022774076114039555,
- .00000000000010849569622967912,
- -.00000000000023073801945705758,
- .00000000000015761203773969435,
- .00000000000003345710269544082,
- -.00000000000041525158063436123,
- .00000000000032655698896907146,
- -.00000000000044704265010452446,
- .00000000000034527647952039772,
- -.00000000000007048962392109746,
- .00000000000011776978751369214,
- -.00000000000010774341461609578,
- .00000000000021863343293215910,
- .00000000000024132639491333131,
- .00000000000039057462209830700,
- -.00000000000026570679203560751,
- .00000000000037135141919592021,
- -.00000000000017166921336082431,
- -.00000000000028658285157914353,
- -.00000000000023812542263446809,
- .00000000000006576659768580062,
- -.00000000000028210143846181267,
- .00000000000010701931762114254,
- .00000000000018119346366441110,
- .00000000000009840465278232627,
- -.00000000000033149150282752542,
- -.00000000000018302857356041668,
- -.00000000000016207400156744949,
- .00000000000048303314949553201,
- -.00000000000071560553172382115,
- .00000000000088821239518571855,
- -.00000000000030900580513238244,
- -.00000000000061076551972851496,
- .00000000000035659969663347830,
- .00000000000035782396591276383,
- -.00000000000046226087001544578,
- .00000000000062279762917225156,
- .00000000000072838947272065741,
- .00000000000026809646615211673,
- -.00000000000010960825046059278,
- .00000000000002311949383800537,
- -.00000000000058469058005299247,
- -.00000000000002103748251144494,
- -.00000000000023323182945587408,
- -.00000000000042333694288141916,
- -.00000000000043933937969737844,
- .00000000000041341647073835565,
- .00000000000006841763641591466,
- .00000000000047585534004430641,
- .00000000000083679678674757695,
- -.00000000000085763734646658640,
- .00000000000021913281229340092,
- -.00000000000062242842536431148,
- -.00000000000010983594325438430,
- .00000000000065310431377633651,
- -.00000000000047580199021710769,
- -.00000000000037854251265457040,
- .00000000000040939233218678664,
- .00000000000087424383914858291,
- .00000000000025218188456842882,
- -.00000000000003608131360422557,
- -.00000000000050518555924280902,
- .00000000000078699403323355317,
- -.00000000000067020876961949060,
- .00000000000016108575753932458,
- .00000000000058527188436251509,
- -.00000000000035246757297904791,
- -.00000000000018372084495629058,
- .00000000000088606689813494916,
- .00000000000066486268071468700,
- .00000000000063831615170646519,
- .00000000000025144230728376072,
- -.00000000000017239444525614834
-};
-
-double
-#ifdef _ANSI_SOURCE
-log(double x)
-#else
-log(x) double x;
-#endif
-{
- int m, j;
- double F, f, g, q, u, u2, v, zero = 0.0, one = 1.0;
- volatile double u1;
-
- /* Catch special cases */
- if (x <= 0)
- if (_IEEE && x == zero) /* log(0) = -Inf */
- return (-one/zero);
- else if (_IEEE) /* log(neg) = NaN */
- return (zero/zero);
- else if (x == zero) /* NOT REACHED IF _IEEE */
- return (infnan(-ERANGE));
- else
- return (infnan(EDOM));
- else if (!finite(x))
- if (_IEEE) /* x = NaN, Inf */
- return (x+x);
- else
- return (infnan(ERANGE));
-
- /* Argument reduction: 1 <= g < 2; x/2^m = g; */
- /* y = F*(1 + f/F) for |f| <= 2^-8 */
-
- m = logb(x);
- g = ldexp(x, -m);
- if (_IEEE && m == -1022) {
- j = logb(g), m += j;
- g = ldexp(g, -j);
- }
- j = N*(g-1) + .5;
- F = (1.0/N) * j + 1; /* F*128 is an integer in [128, 512] */
- f = g - F;
-
- /* Approximate expansion for log(1+f/F) ~= u + q */
- g = 1/(2*F+f);
- u = 2*f*g;
- v = u*u;
- q = u*v*(A1 + v*(A2 + v*(A3 + v*A4)));
-
- /* case 1: u1 = u rounded to 2^-43 absolute. Since u < 2^-8,
- * u1 has at most 35 bits, and F*u1 is exact, as F has < 8 bits.
- * It also adds exactly to |m*log2_hi + log_F_head[j] | < 750
- */
- if (m | j)
- u1 = u + 513, u1 -= 513;
-
- /* case 2: |1-x| < 1/256. The m- and j- dependent terms are zero;
- * u1 = u to 24 bits.
- */
- else
- u1 = u, TRUNC(u1);
- u2 = (2.0*(f - F*u1) - u1*f) * g;
- /* u1 + u2 = 2f/(2F+f) to extra precision. */
-
- /* log(x) = log(2^m*F*(1+f/F)) = */
- /* (m*log2_hi+logF_head[j]+u1) + (m*log2_lo+logF_tail[j]+q); */
- /* (exact) + (tiny) */
-
- u1 += m*logF_head[N] + logF_head[j]; /* exact */
- u2 = (u2 + logF_tail[j]) + q; /* tiny */
- u2 += logF_tail[N]*m;
- return (u1 + u2);
-}
-
-/*
- * Extra precision variant, returning struct {double a, b;};
- * log(x) = a+b to 63 bits, with a is rounded to 26 bits.
- */
-struct Double
-#ifdef _ANSI_SOURCE
-__log__D(double x)
-#else
-__log__D(x) double x;
-#endif
-{
- int m, j;
- double F, f, g, q, u, v, u2, one = 1.0;
- volatile double u1;
- struct Double r;
-
- /* Argument reduction: 1 <= g < 2; x/2^m = g; */
- /* y = F*(1 + f/F) for |f| <= 2^-8 */
-
- m = logb(x);
- g = ldexp(x, -m);
- if (_IEEE && m == -1022) {
- j = logb(g), m += j;
- g = ldexp(g, -j);
- }
- j = N*(g-1) + .5;
- F = (1.0/N) * j + 1;
- f = g - F;
-
- g = 1/(2*F+f);
- u = 2*f*g;
- v = u*u;
- q = u*v*(A1 + v*(A2 + v*(A3 + v*A4)));
- if (m | j)
- u1 = u + 513, u1 -= 513;
- else
- u1 = u, TRUNC(u1);
- u2 = (2.0*(f - F*u1) - u1*f) * g;
-
- u1 += m*logF_head[N] + logF_head[j];
-
- u2 += logF_tail[j]; u2 += q;
- u2 += logF_tail[N]*m;
- r.a = u1 + u2; /* Only difference is here */
- TRUNC(r.a);
- r.b = (u1 - r.a) + u2;
- return (r);
-}
diff --git a/lib/msun/bsdsrc/b_tgamma.c b/lib/msun/bsdsrc/b_tgamma.c
deleted file mode 100644
index 5d270f05170e..000000000000
--- a/lib/msun/bsdsrc/b_tgamma.c
+++ /dev/null
@@ -1,336 +0,0 @@
-/*-
- * 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-static char sccsid[] = "@(#)gamma.c 8.1 (Berkeley) 6/4/93";
-#endif /* not lint */
-
-/*
- * This code by P. McIlroy, Oct 1992;
- *
- * The financial support of UUNET Communications Services is greatfully
- * acknowledged.
- */
-
-#include <math.h>
-#include "mathimpl.h"
-#include <errno.h>
-
-/* METHOD:
- * x < 0: Use reflection formula, G(x) = pi/(sin(pi*x)*x*G(x))
- * At negative integers, return +Inf, and set errno.
- *
- * x < 6.5:
- * Use argument reduction G(x+1) = xG(x) to reach the
- * range [1.066124,2.066124]. Use a rational
- * approximation centered at the minimum (x0+1) to
- * ensure monotonicity.
- *
- * x >= 6.5: Use the asymptotic approximation (Stirling's formula)
- * adjusted for equal-ripples:
- *
- * log(G(x)) ~= (x-.5)*(log(x)-1) + .5(log(2*pi)-1) + 1/x*P(1/(x*x))
- *
- * Keep extra precision in multiplying (x-.5)(log(x)-1), to
- * avoid premature round-off.
- *
- * Special values:
- * non-positive integer: Set overflow trap; return +Inf;
- * x > 171.63: Set overflow trap; return +Inf;
- * NaN: Set invalid trap; return NaN
- *
- * Accuracy: Gamma(x) is accurate to within
- * x > 0: error provably < 0.9ulp.
- * Maximum observed in 1,000,000 trials was .87ulp.
- * x < 0:
- * Maximum observed error < 4ulp in 1,000,000 trials.
- */
-
-static double neg_gam __P((double));
-static double small_gam __P((double));
-static double smaller_gam __P((double));
-static struct Double large_gam __P((double));
-static struct Double ratfun_gam __P((double, double));
-
-/*
- * Rational approximation, A0 + x*x*P(x)/Q(x), on the interval
- * [1.066.., 2.066..] accurate to 4.25e-19.
- */
-#define LEFT -.3955078125 /* left boundary for rat. approx */
-#define x0 .461632144968362356785 /* xmin - 1 */
-
-#define a0_hi 0.88560319441088874992
-#define a0_lo -.00000000000000004996427036469019695
-#define P0 6.21389571821820863029017800727e-01
-#define P1 2.65757198651533466104979197553e-01
-#define P2 5.53859446429917461063308081748e-03
-#define P3 1.38456698304096573887145282811e-03
-#define P4 2.40659950032711365819348969808e-03
-#define Q0 1.45019531250000000000000000000e+00
-#define Q1 1.06258521948016171343454061571e+00
-#define Q2 -2.07474561943859936441469926649e-01
-#define Q3 -1.46734131782005422506287573015e-01
-#define Q4 3.07878176156175520361557573779e-02
-#define Q5 5.12449347980666221336054633184e-03
-#define Q6 -1.76012741431666995019222898833e-03
-#define Q7 9.35021023573788935372153030556e-05
-#define Q8 6.13275507472443958924745652239e-06
-/*
- * Constants for large x approximation (x in [6, Inf])
- * (Accurate to 2.8*10^-19 absolute)
- */
-#define lns2pi_hi 0.418945312500000
-#define lns2pi_lo -.000006779295327258219670263595
-#define Pa0 8.33333333333333148296162562474e-02
-#define Pa1 -2.77777777774548123579378966497e-03
-#define Pa2 7.93650778754435631476282786423e-04
-#define Pa3 -5.95235082566672847950717262222e-04
-#define Pa4 8.41428560346653702135821806252e-04
-#define Pa5 -1.89773526463879200348872089421e-03
-#define Pa6 5.69394463439411649408050664078e-03
-#define Pa7 -1.44705562421428915453880392761e-02
-
-static const double zero = 0., one = 1.0, tiny = 1e-300;
-static int endian;
-/*
- * TRUNC sets trailing bits in a floating-point number to zero.
- * is a temporary variable.
- */
-#if defined(vax) || defined(tahoe)
-#define _IEEE 0
-#define TRUNC(x) x = (double) (float) (x)
-#else
-#define _IEEE 1
-#define TRUNC(x) *(((int *) &x) + endian) &= 0xf8000000
-#define infnan(x) 0.0
-#endif
-
-double
-gamma(x)
- double x;
-{
- struct Double u;
- endian = (*(int *) &one) ? 1 : 0;
-
- if (x >= 6) {
- if(x > 171.63)
- return(one/zero);
- u = large_gam(x);
- return(__exp__D(u.a, u.b));
- } else if (x >= 1.0 + LEFT + x0)
- return (small_gam(x));
- else if (x > 1.e-17)
- return (smaller_gam(x));
- else if (x > -1.e-17) {
- if (x == 0.0)
- if (!_IEEE) return (infnan(ERANGE));
- else return (one/x);
- one+1e-20; /* Raise inexact flag. */
- return (one/x);
- } else if (!finite(x)) {
- if (_IEEE) /* x = NaN, -Inf */
- return (x*x);
- else
- return (infnan(EDOM));
- } else
- return (neg_gam(x));
-}
-/*
- * Accurate to max(ulp(1/128) absolute, 2^-66 relative) error.
- */
-static struct Double
-large_gam(x)
- double x;
-{
- double z, p;
- int i;
- struct Double t, u, v;
-
- z = one/(x*x);
- p = Pa0+z*(Pa1+z*(Pa2+z*(Pa3+z*(Pa4+z*(Pa5+z*(Pa6+z*Pa7))))));
- p = p/x;
-
- u = __log__D(x);
- u.a -= one;
- v.a = (x -= .5);
- TRUNC(v.a);
- v.b = x - v.a;
- t.a = v.a*u.a; /* t = (x-.5)*(log(x)-1) */
- t.b = v.b*u.a + x*u.b;
- /* return t.a + t.b + lns2pi_hi + lns2pi_lo + p */
- t.b += lns2pi_lo; t.b += p;
- u.a = lns2pi_hi + t.b; u.a += t.a;
- u.b = t.a - u.a;
- u.b += lns2pi_hi; u.b += t.b;
- return (u);
-}
-/*
- * Good to < 1 ulp. (provably .90 ulp; .87 ulp on 1,000,000 runs.)
- * It also has correct monotonicity.
- */
-static double
-small_gam(x)
- double x;
-{
- double y, ym1, t, x1;
- struct Double yy, r;
- y = x - one;
- ym1 = y - one;
- if (y <= 1.0 + (LEFT + x0)) {
- yy = ratfun_gam(y - x0, 0);
- return (yy.a + yy.b);
- }
- r.a = y;
- TRUNC(r.a);
- yy.a = r.a - one;
- y = ym1;
- yy.b = r.b = y - yy.a;
- /* Argument reduction: G(x+1) = x*G(x) */
- for (ym1 = y-one; ym1 > LEFT + x0; y = ym1--, yy.a--) {
- t = r.a*yy.a;
- r.b = r.a*yy.b + y*r.b;
- r.a = t;
- TRUNC(r.a);
- r.b += (t - r.a);
- }
- /* Return r*gamma(y). */
- yy = ratfun_gam(y - x0, 0);
- y = r.b*(yy.a + yy.b) + r.a*yy.b;
- y += yy.a*r.a;
- return (y);
-}
-/*
- * Good on (0, 1+x0+LEFT]. Accurate to 1ulp.
- */
-static double
-smaller_gam(x)
- double x;
-{
- double t, d;
- struct Double r, xx;
- if (x < x0 + LEFT) {
- t = x, TRUNC(t);
- d = (t+x)*(x-t);
- t *= t;
- xx.a = (t + x), TRUNC(xx.a);
- xx.b = x - xx.a; xx.b += t; xx.b += d;
- t = (one-x0); t += x;
- d = (one-x0); d -= t; d += x;
- x = xx.a + xx.b;
- } else {
- xx.a = x, TRUNC(xx.a);
- xx.b = x - xx.a;
- t = x - x0;
- d = (-x0 -t); d += x;
- }
- r = ratfun_gam(t, d);
- d = r.a/x, TRUNC(d);
- r.a -= d*xx.a; r.a -= d*xx.b; r.a += r.b;
- return (d + r.a/x);
-}
-/*
- * returns (z+c)^2 * P(z)/Q(z) + a0
- */
-static struct Double
-ratfun_gam(z, c)
- double z, c;
-{
- int i;
- double p, q;
- struct Double r, t;
-
- q = Q0 +z*(Q1+z*(Q2+z*(Q3+z*(Q4+z*(Q5+z*(Q6+z*(Q7+z*Q8)))))));
- p = P0 + z*(P1 + z*(P2 + z*(P3 + z*P4)));
-
- /* return r.a + r.b = a0 + (z+c)^2*p/q, with r.a truncated to 26 bits. */
- p = p/q;
- t.a = z, TRUNC(t.a); /* t ~= z + c */
- t.b = (z - t.a) + c;
- t.b *= (t.a + z);
- q = (t.a *= t.a); /* t = (z+c)^2 */
- TRUNC(t.a);
- t.b += (q - t.a);
- r.a = p, TRUNC(r.a); /* r = P/Q */
- r.b = p - r.a;
- t.b = t.b*p + t.a*r.b + a0_lo;
- t.a *= r.a; /* t = (z+c)^2*(P/Q) */
- r.a = t.a + a0_hi, TRUNC(r.a);
- r.b = ((a0_hi-r.a) + t.a) + t.b;
- return (r); /* r = a0 + t */
-}
-
-static double
-neg_gam(x)
- double x;
-{
- int sgn = 1;
- struct Double lg, lsine;
- double y, z;
-
- y = floor(x + .5);
- if (y == x) /* Negative integer. */
- if(!_IEEE)
- return (infnan(ERANGE));
- else
- return (one/zero);
- z = fabs(x - y);
- y = .5*ceil(x);
- if (y == ceil(y))
- sgn = -1;
- if (z < .25)
- z = sin(M_PI*z);
- else
- z = cos(M_PI*(0.5-z));
- /* Special case: G(1-x) = Inf; G(x) may be nonzero. */
- if (x < -170) {
- if (x < -190)
- return ((double)sgn*tiny*tiny);
- y = one - x; /* exact: 128 < |x| < 255 */
- lg = large_gam(y);
- lsine = __log__D(M_PI/z); /* = TRUNC(log(u)) + small */
- lg.a -= lsine.a; /* exact (opposite signs) */
- lg.b -= lsine.b;
- y = -(lg.a + lg.b);
- z = (y + lg.a) + lg.b;
- y = __exp__D(y, z);
- if (sgn < 0) y = -y;
- return (y);
- }
- y = one-x;
- if (one-y == x)
- y = gamma(y);
- else /* 1-x is inexact */
- y = -x*gamma(-x);
- if (sgn < 0) y = -y;
- return (M_PI / (y*z));
-}
diff --git a/lib/msun/bsdsrc/mathimpl.h b/lib/msun/bsdsrc/mathimpl.h
deleted file mode 100644
index 6a2a37d9f811..000000000000
--- a/lib/msun/bsdsrc/mathimpl.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)mathimpl.h 8.1 (Berkeley) 6/4/93
- */
-
-#include <sys/cdefs.h>
-#include <math.h>
-
-#if defined(vax)||defined(tahoe)
-
-/* Deal with different ways to concatenate in cpp */
-# ifdef __STDC__
-# define cat3(a,b,c) a ## b ## c
-# else
-# define cat3(a,b,c) a/**/b/**/c
-# endif
-
-/* Deal with vax/tahoe byte order issues */
-# ifdef vax
-# define cat3t(a,b,c) cat3(a,b,c)
-# else
-# define cat3t(a,b,c) cat3(a,c,b)
-# endif
-
-# define vccast(name) (*(const double *)(cat3(name,,x)))
-
- /*
- * Define a constant to high precision on a Vax or Tahoe.
- *
- * Args are the name to define, the decimal floating point value,
- * four 16-bit chunks of the float value in hex
- * (because the vax and tahoe differ in float format!), the power
- * of 2 of the hex-float exponent, and the hex-float mantissa.
- * Most of these arguments are not used at compile time; they are
- * used in a post-check to make sure the constants were compiled
- * correctly.
- *
- * People who want to use the constant will have to do their own
- * #define foo vccast(foo)
- * since CPP cannot do this for them from inside another macro (sigh).
- * We define "vccast" if this needs doing.
- */
-# define vc(name, value, x1,x2,x3,x4, bexp, xval) \
- const static long cat3(name,,x)[] = {cat3t(0x,x1,x2), cat3t(0x,x3,x4)};
-
-# define ic(name, value, bexp, xval) ;
-
-#else /* vax or tahoe */
-
- /* Hooray, we have an IEEE machine */
-# undef vccast
-# define vc(name, value, x1,x2,x3,x4, bexp, xval) ;
-
-# define ic(name, value, bexp, xval) \
- const static double name = value;
-
-#endif /* defined(vax)||defined(tahoe) */
-
-
-/*
- * Functions internal to the math package, yet not static.
- */
-extern double __exp__E();
-extern double __log__L();
-
-struct Double {double a, b;};
-double __exp__D __P((double, double));
-struct Double __log__D __P((double));
diff --git a/lib/ncurses/form/Makefile b/lib/ncurses/form/Makefile
deleted file mode 100644
index aeb6e1d01974..000000000000
--- a/lib/ncurses/form/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-# Makefile for libform
-# $FreeBSD$
-
-NCURSES=${.CURDIR}/../../contrib/ncurses
-
-.PATH: ${NCURSES}/form
-.PATH: ${NCURSES}/menu
-
-LIB= form
-
-SRCS= fty_regex.c fty_num.c fty_int.c fty_ipv4.c fty_enum.c fty_alpha.c \
- fty_alnum.c \
- frm_data.c frm_win.c frm_user.c frm_opts.c frm_hook.c frm_req_name.c \
- fld_user.c fld_type.c fld_stat.c fld_def.c frm_def.c frm_driver.c
-INCS= ${NCURSES}/form/form.h
-
-CFLAGS+=-I${.CURDIR}/../libncurses -I${NCURSES}/form -I${NCURSES}/menu \
- -I${NCURSES}/include -Wall -DNDEBUG -DHAVE_CONFIG_H
-
-.include <bsd.lib.mk>
diff --git a/lib/ncurses/menu/Makefile b/lib/ncurses/menu/Makefile
deleted file mode 100644
index e6ed97e0db7d..000000000000
--- a/lib/ncurses/menu/Makefile
+++ /dev/null
@@ -1,19 +0,0 @@
-# Makefile for libmenu
-# $FreeBSD$
-
-NCURSES=${.CURDIR}/../../contrib/ncurses
-
-.PATH: ${NCURSES}/menu
-
-LIB= menu
-
-SRCS= m_attribs.c m_cursor.c m_driver.c m_format.c m_global.c m_hook.c \
- m_item_cur.c m_item_nam.c m_item_new.c m_item_opt.c m_item_use.c \
- m_item_val.c m_item_vis.c m_items.c m_new.c m_opts.c m_post.c \
- m_req_name.c m_spacing.c m_userptr.c m_win.c
-INCS= ${NCURSES}/menu/menu.h ${NCURSES}/menu/eti.h
-
-CFLAGS+= -I${.CURDIR}/../libncurses -I${NCURSES}/menu -I${NCURSES}/include \
- -Wall -DNDEBUG -DHAVE_CONFIG_H
-
-.include <bsd.lib.mk>
diff --git a/lib/ncurses/ncurses/Makefile b/lib/ncurses/ncurses/Makefile
deleted file mode 100644
index 7d0962354f76..000000000000
--- a/lib/ncurses/ncurses/Makefile
+++ /dev/null
@@ -1,534 +0,0 @@
-# $FreeBSD$
-
-NCURSES=${.CURDIR}/../../contrib/ncurses
-
-LIB= ncurses
-SHLIB_MAJOR=5
-SHLIB_MINOR=0
-
-# Should be elsewhere
-AWK?= awk
-TERMINFODIR?= ${DESTDIR}/usr/share/misc
-
-NCURSES_MAJOR!=egrep 'NCURSES_MAJOR[ ]*=' ${NCURSES}/dist.mk | sed -e 's/^[^0-9]*//'
-NCURSES_MINOR!=egrep 'NCURSES_MINOR[ ]*=' ${NCURSES}/dist.mk | sed -e 's/^[^0-9]*//'
-NCURSES_PATCH!=egrep 'NCURSES_PATCH[ ]*=' ${NCURSES}/dist.mk | sed -e 's/^[^0-9]*//'
-
-# From autoconf (!)
-NCURSES_CONST=
-NCURSES_XNAMES= 0
-OSPEED_INCLUDES=\#include <termios.h>
-OSPEED_TYPE= speed_t
-BUILTIN_BOOL= 1
-BOOL_TYPE= 0
-TYPE_OF_BOOL= char
-TYPEOF_CHTYPE= long
-WIDEC_SHIFT= 8
-SHIFT_LIMIT= 32
-ONEUL= 1UL
-
-.PATH: ${NCURSES}/ncurses
-.PATH: ${NCURSES}/ncurses/base
-.PATH: ${NCURSES}/ncurses/tinfo
-.PATH: ${NCURSES}/ncurses/tty
-.PATH: ${NCURSES}/ncurses/trace
-.PATH: ${NCURSES}/include
-.PATH: ${NCURSES}/man
-
-INCS= -I. -I${.CURDIR} -I${NCURSES}/ncurses -I${NCURSES}/include
-CFLAGS+=${INCS} -Wall -DFREEBSD_NATIVE -DNDEBUG -DHAVE_CONFIG_H -DTERMIOS
-
-GENSRC= \
- codes.c \
- expanded.c \
- fallback.c \
- lib_gen.c \
- lib_keyname.c \
- names.c \
- unctrl.c
-
-GENHDR= \
- curses.h \
- hashsize.h \
- init_keytry.h \
- nomacros.h \
- parametrized.h \
- term.h \
- termcap.h \
- unctrl.h
-
-# Installed
-HEADERS=curses.h term.h termcap.h unctrl.h
-
-# Components of names.c and codes.c
-NAMESRC=boolnames boolfnames numnames numfnames strnames strfnames
-CODESRC=boolcodes numcodes strcodes
-
-SRCS= ${GENHDR} ${GENSRC} \
- access.c \
- add_tries.c \
- alloc_entry.c \
- alloc_ttype.c \
- captoinfo.c \
- comp_captab.c \
- comp_error.c \
- comp_expand.c \
- comp_hash.c \
- comp_parse.c \
- comp_scan.c \
- define_key.c \
- doalloc.c \
- free_ttype.c \
- getenv_num.c \
- hardscroll.c \
- hashmap.c \
- home_terminfo.c \
- init_keytry.c \
- keybound.c \
- keyok.c \
- lib_acs.c \
- lib_addch.c \
- lib_addstr.c \
- lib_baudrate.c \
- lib_beep.c \
- lib_bkgd.c \
- lib_box.c \
- lib_chgat.c \
- lib_clear.c \
- lib_clearok.c \
- lib_clrbot.c \
- lib_clreol.c \
- lib_color.c \
- lib_colorset.c \
- lib_cur_term.c \
- lib_data.c \
- lib_delch.c \
- lib_delwin.c \
- lib_dft_fgbg.c \
- lib_echo.c \
- lib_endwin.c \
- lib_erase.c \
- lib_flash.c \
- lib_freeall.c \
- lib_getch.c \
- lib_getstr.c \
- lib_has_cap.c \
- lib_hline.c \
- lib_immedok.c \
- lib_inchstr.c \
- lib_initscr.c \
- lib_insch.c \
- lib_insdel.c \
- lib_insstr.c \
- lib_instr.c \
- lib_isendwin.c \
- lib_kernel.c \
- lib_leaveok.c \
- lib_longname.c \
- lib_mouse.c \
- lib_move.c \
- lib_mvcur.c \
- lib_mvwin.c \
- lib_napms.c \
- lib_newterm.c \
- lib_newwin.c \
- lib_nl.c \
- lib_options.c \
- lib_overlay.c \
- lib_pad.c \
- lib_print.c \
- lib_printw.c \
- lib_raw.c \
- lib_redrawln.c \
- lib_refresh.c \
- lib_restart.c \
- lib_scanw.c \
- lib_screen.c \
- lib_scroll.c \
- lib_scrollok.c \
- lib_scrreg.c \
- lib_set_term.c \
- lib_setup.c \
- lib_slk.c \
- lib_slkatr_set.c \
- lib_slkatrof.c \
- lib_slkatron.c \
- lib_slkatrset.c \
- lib_slkattr.c \
- lib_slkclear.c \
- lib_slkcolor.c \
- lib_slkinit.c \
- lib_slklab.c \
- lib_slkrefr.c \
- lib_slkset.c \
- lib_slktouch.c \
- lib_termcap.c \
- lib_termname.c \
- lib_ti.c \
- lib_touch.c \
- lib_tparm.c \
- lib_tputs.c \
- lib_trace.c \
- lib_traceatr.c \
- lib_tracebits.c \
- lib_tracechr.c \
- lib_tracedmp.c \
- lib_tracemse.c \
- lib_tstp.c \
- lib_ttyflags.c \
- lib_twait.c \
- lib_ungetch.c \
- lib_vidattr.c \
- lib_vline.c \
- lib_wattroff.c \
- lib_wattron.c \
- lib_winch.c \
- lib_window.c \
- memmove.c \
- name_match.c \
- nc_panel.c \
- parse_entry.c \
- read_entry.c \
- resizeterm.c \
- safe_sprintf.c \
- setbuf.c \
- sigaction.c \
- trace_buf.c \
- trace_tries.c \
- trace_xnames.c \
- tries.c \
- tty_update.c \
- version.c \
- vsscanf.c \
- wresize.c \
- write_entry.c \
-
-# From our old libtermcap.
-# Used instead of the hideous read_termcap.c abomination.
-SRCS+= termcap.c
-
-CLEANFILES+= ${GENSRC} ${GENHDR} keys.tries make_hash term.h.new \
- make_keys MKterm.h.awk comp_captab.c \
- namehdr nameftr codeftr ${NAMESRC} ${CODESRC}
-
-SYMLINKS+=libncurses.a ${LIBDIR}/libcurses.a
-SYMLINKS+=libncurses.a ${LIBDIR}/libtermcap.a
-SYMLINKS+=libncurses.a ${LIBDIR}/libtermlib.a
-SYMLINKS+=libncurses.a ${LIBDIR}/libmytinfo.a
-SYMLINKS+=libncurses.a ${LIBDIR}/libtinfo.a
-.if !defined(NOPIC)
-.if ${OBJFORMAT} == aout
-SYMLINKS+=libncurses.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
- libcurses.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
-SYMLINKS+=libncurses.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
- libtermcap.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
-SYMLINKS+=libncurses.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
- libtermlib.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
-SYMLINKS+=libncurses.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
- libmytinfo.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
-SYMLINKS+=libncurses.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \
- libtinfo.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
-.else
-# no need for major at all, it's an ld-time redirection only
-SYMLINKS+=libncurses.so ${SHLIBDIR}/libcurses.so
-SYMLINKS+=libncurses.so ${SHLIBDIR}/libtermcap.so
-SYMLINKS+=libncurses.so ${SHLIBDIR}/libtermlib.so
-SYMLINKS+=libncurses.so ${SHLIBDIR}/libmytinfo.so
-SYMLINKS+=libncurses.so ${SHLIBDIR}/libtinfo.so
-.endif
-.endif
-.if !defined(NOPROFILE)
-SYMLINKS+=libncurses_p.a ${LIBDIR}/libcurses_p.a
-SYMLINKS+=libncurses_p.a ${LIBDIR}/libtermcap_p.a
-SYMLINKS+=libncurses_p.a ${LIBDIR}/libtermlib_p.a
-SYMLINKS+=libncurses_p.a ${LIBDIR}/libmytinfo_p.a
-SYMLINKS+=libncurses_p.a ${LIBDIR}/libtinfo_p.a
-.endif
-
-DOCSDIR= /usr/share/doc/ncurses
-DOCS= ncurses-intro.html hackguide.html
-
-beforeinstall: ${HEADERS}
- ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 444 ${HEADERS} \
- ${DESTDIR}/usr/include
- rm -f ${DESTDIR}/usr/include/ncurses.h
- ln -s curses.h ${DESTDIR}/usr/include/ncurses.h
-
-.if !defined(NOHTML)
-afterinstall:
-.for file in ${DOCS}
- cd ${.CURDIR}/../../contrib/ncurses/misc ; \
- ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 444 ${file} \
- ${DESTDIR}${DOCSDIR}
-.endfor
-.endif
-
-# Generated source
-namehdr nameftr codeftr ${NAMESRC} ${CODESRC}: MKnames.awk Caps
- ${AWK} -f ${NCURSES}/ncurses/tinfo/MKnames.awk ${NCURSES}/include/Caps
-
-.ORDER: namehdr ${NAMESRC} ${CODESRC} nameftr codeftr names.c codes.c
-
-names.c: namehdr ${NAMESRC} nameftr
- cat namehdr ${NAMESRC} nameftr > $@
-
-codes.c: namehdr ${CODESRC} codeftr
- cat namehdr ${CODESRC} codeftr > $@
-
-lib_gen.c: MKlib_gen.sh curses.h
- sh ${NCURSES}/ncurses/base/MKlib_gen.sh "${CC} -E ${INCS}" \
- "${AWK}" < curses.h >$@
-
-lib_keyname.c: keys.list MKkeyname.awk
- ${AWK} -f ${NCURSES}/ncurses/base/MKkeyname.awk \
- ${NCURSES}/ncurses/tinfo/keys.list > lib_keyname.c
-
-unctrl.c: MKunctrl.awk
- echo | ${AWK} -f ${NCURSES}/ncurses/base/MKunctrl.awk > unctrl.c
-
-comp_captab.c: MKcaptab.awk Caps make_hash
- sh ${NCURSES}/ncurses/tinfo/MKcaptab.awk "${AWK}" \
- ${NCURSES}/include/Caps > comp_captab.c
-
-expanded.c: MKexpanded.sh
- sh ${NCURSES}/ncurses/tty/MKexpanded.sh "${CC} -E" ${CFLAGS} >expanded.c
-
-fallback.c: MKfallback.sh
- sh ${NCURSES}/ncurses/tinfo/MKfallback.sh > fallback.c
-
-# Generated headers
-nomacros.h: MKlib_gen.sh curses.h
- sh ${NCURSES}/ncurses/base/MKlib_gen.sh "${CC} -E ${INCS}" \
- "${AWK}" < curses.h | fgrep undef > $@
-
-init_keytry.h: keys.list make_keys
- ./make_keys ${NCURSES}/ncurses/tinfo/keys.list > init_keytry.h
-
-hashsize.h: MKhashsize.sh Caps
- sh ${NCURSES}/include/MKhashsize.sh ${NCURSES}/include/Caps > $@
-
-parametrized.h: MKparametrized.sh Caps
- AWK=${AWK} sh ${NCURSES}/include/MKparametrized.sh \
- ${NCURSES}/include/Caps > $@
-
-term.h: MKterm.h.awk edit_cfg.sh Caps
- ${AWK} -f MKterm.h.awk ${NCURSES}/include/Caps > $@.new
- sh ${NCURSES}/include/edit_cfg.sh ${.CURDIR}/ncurses_cfg.h $@.new
- mv -f $@.new $@
-
-# Build tools
-build-tools: make_hash make_keys
-
-make_keys: make_keys.c names.c curses.h
- ${CC} -o $@ ${CFLAGS} ${NCURSES}/ncurses/tinfo/make_keys.c
-
-make_hash: comp_hash.c hashsize.h curses.h
- ${CC} -o $@ ${CFLAGS} -DMAIN_PROGRAM \
- ${NCURSES}/ncurses/tinfo/comp_hash.c
-
-# ./configure generated
-MKterm.h.awk: MKterm.h.awk.in
- sed <${NCURSES}/include/$@.in >$@ \
- -e "/@NCURSES_MAJOR@/s//${NCURSES_MAJOR}/" \
- -e "/@NCURSES_MINOR@/s//${NCURSES_MINOR}/" \
- -e "/@NCURSES_CONST@/s//${NCURSES_CONST}/" \
- -e "/@NCURSES_XNAMES@/s//${NCURSES_XNAMES}/"
-
-termcap.h: termcap.h.in
- sed <${NCURSES}/include/$@.in >$@ \
- -e "/@NCURSES_MAJOR@/s//${NCURSES_MAJOR}/" \
- -e "/@NCURSES_MINOR@/s//${NCURSES_MINOR}/" \
- -e "/@NCURSES_CONST@/s//${NCURSES_CONST}/" \
- -e "/@OSPEED_INCLUDES@/s//${OSPEED_INCLUDES}/" \
- -e "/@OSPEED_TYPE@/s//${OSPEED_TYPE}/"
-
-curses.h: curses.h.in
- sed <${NCURSES}/include/$@.in >$@ \
- -e "/@NCURSES_MAJOR@/s//${NCURSES_MAJOR}/" \
- -e "/@NCURSES_MINOR@/s//${NCURSES_MINOR}/" \
- -e "/@NCURSES_PATCH@/s//${NCURSES_PATCH}/" \
- -e "/@NCURSES_CONST@/s//${NCURSES_CONST}/" \
- -e "s/@cf_cv_builtin_bool@/${BUILTIN_BOOL}/g" \
- -e "s/@cf_cv_cc_bool_type@/${BOOL_TYPE}/g" \
- -e "s/@cf_cv_type_of_bool@/${TYPE_OF_BOOL}/g" \
- -e "s/@cf_cv_typeof_chtype@/${TYPEOF_CHTYPE}/g" \
- -e "s/@cf_cv_widec_shift@/${WIDEC_SHIFT}/g" \
- -e "s/@cf_cv_shift_limit@/${SHIFT_LIMIT}/g" \
- -e "s/@cf_cv_1UL@/${ONEUL}/g"
-
-unctrl.h: unctrl.h.in
- sed <${NCURSES}/include/$@.in >$@ \
- -e "/@NCURSES_MAJOR@/s//${NCURSES_MAJOR}/" \
- -e "/@NCURSES_MINOR@/s//${NCURSES_MINOR}/"
-
-# MAN page gunk
-terminfo.5: MKterminfo.sh terminfo.head Caps
- sh ${NCURSES}/man/MKterminfo.sh ${NCURSES}/man/terminfo.head \
- ${NCURSES}/include/Caps ${NCURSES}/man/terminfo.tail >$@
-
-CLEANFILES+= terminfo.5
-MANFILTER= sed -e 's\#@DATADIR@\#${TERMINFODIR}/terminfo\#g'
-
-MAN3x= curs_addch.3x curs_addchstr.3x curs_addstr.3x curs_attr.3x \
- curs_beep.3x curs_bkgd.3x curs_border.3x curs_clear.3x curs_color.3x \
- curs_delch.3x curs_deleteln.3x curs_getch.3x curs_getstr.3x \
- curs_getyx.3x curs_inch.3x curs_inchstr.3x curs_initscr.3x \
- curs_inopts.3x curs_insch.3x curs_insstr.3x curs_instr.3x \
- curs_kernel.3x curs_mouse.3x curs_move.3x curs_outopts.3x \
- curs_overlay.3x curs_pad.3x curs_print.3x curs_printw.3x \
- curs_refresh.3x curs_scanw.3x curs_scr_dump.3x curs_scroll.3x \
- curs_slk.3x curs_termattrs.3x curs_termcap.3x curs_terminfo.3x \
- curs_touch.3x curs_util.3x curs_window.3x define_key.3x \
- dft_fgbg.3x keybound.3x keyok.3x ncurses.3x resizeterm.3x wresize.3x
-MAN5= term.5 terminfo.5
-MAN7= term.7
-
-# Generate the MAN3 list from MAN3x
-.for page in ${MAN3x}
-CLEANFILES+=${page:T:S/3x$/3/g}
-MAN3+=${page:T:S/3x$/3/g}
-all-man: ${page:T:S/3x$/3/g}
-${page:T:S/3x$/3/g}: ${page}
- ln -s ${.ALLSRC} ${.TARGET}
-.endfor
-
-MLINKS+=ncurses.3 curses.3
-MLINKS+=curs_addch.3 addch.3 curs_addch.3 echochar.3 curs_addch.3 mvaddch.3 \
- curs_addch.3 mvwaddch.3 curs_addch.3 waddch.3 curs_addch.3 wechochar.3
-MLINKS+=curs_addchstr.3 addchnstr.3 curs_addchstr.3 addchstr.3 \
- curs_addchstr.3 mvaddchnstr.3 curs_addchstr.3 mvaddchstr.3 \
- curs_addchstr.3 mvwaddchnstr.3 curs_addchstr.3 mvwaddchstr.3 \
- curs_addchstr.3 waddchnstr.3 curs_addchstr.3 waddchstr.3
-MLINKS+=curs_addstr.3 addnstr.3 curs_addstr.3 addstr.3 \
- curs_addstr.3 mvaddnstr.3 curs_addstr.3 mvaddstr.3 \
- curs_addstr.3 mvwaddnstr.3 curs_addstr.3 mvwaddstr.3 \
- curs_addstr.3 waddnstr.3 curs_addstr.3 waddstr.3
-MLINKS+=curs_attr.3 attr_get.3 curs_attr.3 attr_off.3 curs_attr.3 attr_on.3 \
- curs_attr.3 attr_set.3 curs_attr.3 attroff.3 curs_attr.3 attron.3 \
- curs_attr.3 attrset.3 curs_attr.3 chgat.3 curs_attr.3 color_set.3 \
- curs_attr.3 mvchgat.3 curs_attr.3 mvwchgat.3 curs_attr.3 standend.3 \
- curs_attr.3 standout.3 curs_attr.3 wattr_get.3 curs_attr.3 wattr_off.3 \
- curs_attr.3 wattr_on.3 curs_attr.3 wattr_set.3 curs_attr.3 wattroff.3 \
- curs_attr.3 wattron.3 curs_attr.3 wattrset.3 curs_attr.3 wchgat.3 \
- curs_attr.3 wcolor_set.3 curs_attr.3 wstandend.3 \
- curs_attr.3 wstandout.3
-MLINKS+=curs_beep.3 beep.3 curs_beep.3 flash.3
-MLINKS+=curs_bkgd.3 bkgd.3 curs_bkgd.3 bkgdset.3 curs_bkgd.3 getbkgd.3 \
- curs_bkgd.3 wbkgd.3 curs_bkgd.3 wbkgdset.3
-MLINKS+=curs_border.3 border.3 curs_border.3 box.3 curs_border.3 hline.3 \
- curs_border.3 mvhline.3 curs_border.3 mvwhline.3 \
- curs_border.3 mvwvline.3 curs_border.3 vline.3 curs_border.3 wborder.3 \
- curs_border.3 whline.3 curs_border.3 wvline.3
-MLINKS+=curs_clear.3 clear.3 curs_clear.3 clrtobot.3 curs_clear.3 clrtoeol.3 \
- curs_clear.3 erase.3 curs_clear.3 wclear.3 curs_clear.3 wclrtobot.3 \
- curs_clear.3 wclrtoeol.3 curs_clear.3 werase.3
-MLINKS+=curs_color.3 can_change_color.3 curs_color.3 color_content.3 \
- curs_color.3 has_colors.3 curs_color.3 init_color.3 \
- curs_color.3 init_pair.3 curs_color.3 pair_content.3 \
- curs_color.3 start_color.3
-MLINKS+=curs_delch.3 delch.3 curs_delch.3 mvdelch.3 curs_delch.3 mvwdelch.3 \
- curs_delch.3 wdelch.3
-MLINKS+=curs_deleteln.3 deleteln.3 curs_deleteln.3 insdelln.3 \
- curs_deleteln.3 insertln.3 curs_deleteln.3 wdeleteln.3 \
- curs_deleteln.3 winsdelln.3 curs_deleteln.3 winsertln.3
-MLINKS+=curs_getch.3 getch.3 curs_getch.3 has_key.3 curs_getch.3 mvgetch.3 \
- curs_getch.3 mvwgetch.3 curs_getch.3 ungetch.3 curs_getch.3 wgetch.3
-MLINKS+=curs_getstr.3 getnstr.3 curs_getstr.3 getstr.3 \
- curs_getstr.3 mvgetnstr.3 curs_getstr.3 mvgetstr.3 \
- curs_getstr.3 mvwgetnstr.3 curs_getstr.3 mvwgetstr.3 \
- curs_getstr.3 wgetnstr.3 curs_getstr.3 wgetstr.3
-MLINKS+=curs_getyx.3 getbegyx.3 curs_getyx.3 getmaxyx.3 \
- curs_getyx.3 getparyx.3 curs_getyx.3 getyx.3
-MLINKS+=curs_inch.3 inch.3 curs_inch.3 mvinch.3 curs_inch.3 mvwinch.3 \
- curs_inch.3 winch.3
-MLINKS+=curs_inchstr.3 inchnstr.3 curs_inchstr.3 inchstr.3 \
- curs_inchstr.3 mvinchnstr.3 curs_inchstr.3 mvinchstr.3 \
- curs_inchstr.3 mvwinchnstr.3 curs_inchstr.3 mvwinchstr.3 \
- curs_inchstr.3 winchnstr.3 curs_inchstr.3 winchstr.3
-MLINKS+=curs_initscr.3 delscreen.3 curs_initscr.3 endwin.3 \
- curs_initscr.3 initscr.3 curs_initscr.3 isendwin.3 \
- curs_initscr.3 newterm.3 curs_initscr.3 set_term.3
-MLINKS+=curs_inopts.3 cbreak.3 curs_inopts.3 echo.3 curs_inopts.3 halfdelay.3 \
- curs_inopts.3 intrflush.3 curs_inopts.3 keypad.3 curs_inopts.3 meta.3 \
- curs_inopts.3 nocbreak.3 curs_inopts.3 nodelay.3 \
- curs_inopts.3 noecho.3 curs_inopts.3 noqiflush.3 curs_inopts.3 noraw.3 \
- curs_inopts.3 notimeout.3 curs_inopts.3 qiflush.3 curs_inopts.3 raw.3 \
- curs_inopts.3 timeout.3 curs_inopts.3 typeahead.3 \
- curs_inopts.3 wtimeout.3
-MLINKS+=curs_insch.3 insch.3 curs_insch.3 mvinsch.3 curs_insch.3 mvwinsch.3 \
- curs_insch.3 winsch.3
-MLINKS+=curs_insstr.3 insnstr.3 curs_insstr.3 insstr.3 \
- curs_insstr.3 mvinsnstr.3 curs_insstr.3 mvinsstr.3 \
- curs_insstr.3 mvwinsnstr.3 curs_insstr.3 mvwinsstr.3 \
- curs_insstr.3 winsnstr.3 curs_insstr.3 winsstr.3
-MLINKS+=curs_instr.3 innstr.3 curs_instr.3 instr.3 curs_instr.3 mvinnstr.3 \
- curs_instr.3 mvinstr.3 curs_instr.3 mvwinnstr.3 \
- curs_instr.3 mvwinstr.3 curs_instr.3 winnstr.3 curs_instr.3 winstr.3
-MLINKS+=curs_kernel.3 curs_set.3 curs_kernel.3 def_prog_mode.3 \
- curs_kernel.3 def_shell_mode.3 curs_kernel.3 getsyx.3 \
- curs_kernel.3 napms.3 curs_kernel.3 reset_prog_mode.3 \
- curs_kernel.3 reset_shell_mode.3 curs_kernel.3 resetty.3 \
- curs_kernel.3 ripoffline.3 curs_kernel.3 savetty.3 \
- curs_kernel.3 setsyx.3
-MLINKS+=curs_mouse.3 getmouse.3 curs_mouse.3 mouseinterval.3 \
- curs_mouse.3 mousemask.3 curs_mouse.3 ungetmouse.3 \
- curs_mouse.3 wenclose.3 curs_mouse.3 wmouse_trafo.3
-MLINKS+=curs_move.3 move.3 curs_move.3 wmove.3
-MLINKS+=curs_outopts.3 clearok.3 curs_outopts.3 idcok.3 curs_outopts.3 idlok.3 \
- curs_outopts.3 immedok.3 curs_outopts.3 leaveok.3 curs_outopts.3 nl.3 \
- curs_outopts.3 nonl.3 curs_outopts.3 scrollok.3 \
- curs_outopts.3 setscrreg.3 curs_outopts.3 wsetscrreg.3
-MLINKS+=curs_overlay.3 copywin.3 curs_overlay.3 overlay.3 \
- curs_overlay.3 overwrite.3
-MLINKS+=curs_pad.3 newpad.3 curs_pad.3 pechochar.3 curs_pad.3 pnoutrefresh.3 \
- curs_pad.3 prefresh.3 curs_pad.3 subpad.3
-MLINKS+=curs_print.3 mcprint.3
-MLINKS+=curs_printw.3 mvprintw.3 curs_printw.3 mvwprintw.3 \
- curs_printw.3 printw.3 curs_printw.3 vw_printw.3 \
- curs_printw.3 vwprintw.3 curs_printw.3 wprintw.3
-MLINKS+=curs_refresh.3 doupdate.3 curs_refresh.3 redrawwin.3 \
- curs_refresh.3 refresh.3 curs_refresh.3 wnoutrefresh.3 \
- curs_refresh.3 wredrawln.3 curs_refresh.3 wrefresh.3
-MLINKS+=curs_scanw.3 mvscanw.3 curs_scanw.3 mvwscanw.3 curs_scanw.3 scanw.3 \
- curs_scanw.3 vw_scanw.3 curs_scanw.3 vwscanw.3 curs_scanw.3 wscanw.3
-MLINKS+=curs_scr_dump.3 scr_dump.3 curs_scr_dump.3 scr_init.3 \
- curs_scr_dump.3 scr_restore.3 curs_scr_dump.3 scr_set.3
-MLINKS+=curs_scroll.3 scrl.3 curs_scroll.3 scroll.3 curs_scroll.3 wscrl.3
-MLINKS+=curs_slk.3 slk_attr.3 curs_slk.3 slk_attr_off.3 \
- curs_slk.3 slk_attr_on.3 curs_slk.3 slk_attr_set.3 \
- curs_slk.3 slk_attroff.3 curs_slk.3 slk_attron.3 \
- curs_slk.3 slk_attrset.3 curs_slk.3 slk_clear.3 \
- curs_slk.3 slk_color.3 curs_slk.3 slk_init.3 curs_slk.3 slk_label.3 \
- curs_slk.3 slk_noutrefresh.3 curs_slk.3 slk_refresh.3 \
- curs_slk.3 slk_restore.3 curs_slk.3 slk_set.3 curs_slk.3 slk_touch.3
-MLINKS+=curs_termattrs.3 baudrate.3 curs_termattrs.3 erasechar.3 \
- curs_termattrs.3 has_ic.3 curs_termattrs.3 has_il.3 \
- curs_termattrs.3 killchar.3 curs_termattrs.3 longname.3 \
- curs_termattrs.3 termattrs.3 curs_termattrs.3 termname.3
-MLINKS+=curs_termcap.3 tgetent.3 curs_termcap.3 tgetflag.3 \
- curs_termcap.3 tgetnum.3 curs_termcap.3 tgetstr.3 \
- curs_termcap.3 tgoto.3 curs_termcap.3 tputs.3
-MLINKS+=curs_terminfo.3 del_curterm.3 curs_terminfo.3 mvcur.3 \
- curs_terminfo.3 putp.3 curs_terminfo.3 restartterm.3 \
- curs_terminfo.3 set_curterm.3 curs_terminfo.3 setterm.3 \
- curs_terminfo.3 setupterm.3 curs_terminfo.3 tigetflag.3 \
- curs_terminfo.3 tigetnum.3 curs_terminfo.3 tigetstr.3 \
- curs_terminfo.3 tparm.3 curs_terminfo.3 tputs.3 \
- curs_terminfo.3 vidattr.3 curs_terminfo.3 vidputs.3
-MLINKS+=curs_touch.3 is_linetouched.3 curs_touch.3 is_wintouched.3 \
- curs_touch.3 touchline.3 curs_touch.3 touchwin.3 \
- curs_touch.3 untouchwin.3 curs_touch.3 wtouchln.3
-MLINKS+=curs_util.3 delay_output.3 curs_util.3 filter.3 \
- curs_util.3 flushinp.3 curs_util.3 getwin.3 \
- curs_util.3 keyname.3 curs_util.3 putwin.3 \
- curs_util.3 unctrl.3 curs_util.3 use_env.3
-MLINKS+=curs_window.3 delwin.3 curs_window.3 derwin.3 curs_window.3 dupwin.3 \
- curs_window.3 mvderwin.3 curs_window.3 mvwin.3 curs_window.3 newwin.3 \
- curs_window.3 subwin.3 curs_window.3 syncok.3 \
- curs_window.3 wcursyncup.3 curs_window.3 wsyncdown.3 \
- curs_window.3 wsyncup.3
-MLINKS+=dft_fgbg.3 use_default_colors.3
-
-.include <bsd.lib.mk>
-
-.SUFFIXES: .3x .3
diff --git a/lib/ncurses/ncurses/ncurses_cfg.h b/lib/ncurses/ncurses/ncurses_cfg.h
deleted file mode 100644
index a14d5ba57363..000000000000
--- a/lib/ncurses/ncurses/ncurses_cfg.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/* include/ncurses_cfg.h. Generated automatically by configure. */
-/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
- * *
- * Permission is hereby granted, free of charge, to any person obtaining a *
- * copy of this software and associated documentation files (the *
- * "Software"), to deal in the Software without restriction, including *
- * without limitation the rights to use, copy, modify, merge, publish, *
- * distribute, distribute with modifications, sublicense, and/or sell *
- * copies of the Software, and to permit persons to whom the Software is *
- * furnished to do so, subject to the following conditions: *
- * *
- * The above copyright notice and this permission notice shall be included *
- * in all copies or substantial portions of the Software. *
- * *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
- * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
- * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
- * *
- * Except as contained in this notice, the name(s) of the above copyright *
- * holders shall not be used in advertising or otherwise to promote the *
- * sale, use or other dealings in this Software without prior written *
- * authorization. *
- ****************************************************************************/
-
-/****************************************************************************
- * Author: Thomas E. Dickey <dickey@clark.net> 1997 *
- ****************************************************************************/
-/*
- * Id: ncurses_cfg.hin,v 1.2 1998/02/11 12:13:46 tom Exp
- *
- * This is a template-file used to generate the "ncurses_cfg.h" file.
- *
- * Rather than list every definition, the configuration script substitutes
- * the definitions that it finds using 'sed'. You need a patch (971222)
- * to autoconf 2.12 to do this.
- */
-#ifndef NC_CONFIG_H
-#define NC_CONFIG_H
-
-#define BSD_TPUTS 1
-#define CC_HAS_INLINE_FUNCS 1
-#define CC_HAS_PROTOS 1
-#define ETIP_NEEDS_ 1
-#define GCC_NORETURN __dead2
-#define GCC_PRINTF 1
-#define GCC_SCANF 1
-#define GCC_UNUSED __unused
-#define HAVE_BIG_CORE 1
-#define HAVE_BSD_CGETENT 1
-#define HAVE_DIRENT_H 1
-#define HAVE_ERRNO 1
-#define HAVE_FCNTL_H 1
-#define HAVE_FORM_H 1
-#define HAVE_GETCWD 1
-#define HAVE_GETTIMEOFDAY 1
-#define HAVE_GETTTYNAM 1
-#define HAVE_ISASCII 1
-#define HAVE_LIBFORM 1
-#define HAVE_LIBMENU 1
-#define HAVE_LIBPANEL 1
-#define HAVE_LIMITS_H 1
-#define HAVE_LINK 1
-#define HAVE_LOCALE_H 1
-#define HAVE_LONG_FILE_NAMES 1
-#define HAVE_MEMCCPY 1
-#define HAVE_MENU_H 1
-#define HAVE_NANOSLEEP 1
-#define HAVE_NC_ALLOC_H 1
-#define HAVE_PANEL_H 1
-#define HAVE_POLL 1
-#define HAVE_POLL_H 1
-#define HAVE_REGEX_H_FUNCS 1
-#define HAVE_REMOVE 1
-#define HAVE_SELECT 1
-#define HAVE_SETBUF 1
-#define HAVE_SETBUFFER 1
-#define HAVE_SETVBUF 1
-#define HAVE_SIGACTION 1
-#define HAVE_SIGVEC 1
-#define HAVE_SIZECHANGE 1
-#define HAVE_STRDUP 1
-#define HAVE_STRSTR 1
-#define HAVE_SYMLINK 1
-#define HAVE_SYS_IOCTL_H 1
-#define HAVE_SYS_PARAM_H 1
-#define HAVE_SYS_SELECT_H 1
-#define HAVE_SYS_TIMES_H 1
-#define HAVE_SYS_TIME_H 1
-#define HAVE_SYS_TIME_SELECT 1
-#define HAVE_TCGETATTR 1
-#define HAVE_TCGETPGRP 1
-#define HAVE_TERMIOS_H 1
-#define HAVE_TIMES 1
-#define HAVE_TTYENT_H 1
-#define HAVE_TYPEINFO 1
-#define HAVE_UNISTD_H 1
-#define HAVE_USLEEP 1
-#define HAVE_VSNPRINTF 1
-#define HAVE_VSSCANF 1
-#define NCURSES_EXT_FUNCS 1
-#define NCURSES_NO_PADDING 1
-#define NDEBUG 1
-#define RETSIGTYPE void
-#define STDC_HEADERS 1
-#define SYSTEM_NAME "FreeBSD"
-#define TERMINFO_DIRS "/usr/share/misc/terminfo"
-#define TYPEOF_CHTYPE long
-#define USE_DATABASE 1
-#define USE_GETCAP 1
-#define USE_HASHMAP 1
-#define USE_SIGWINCH 1
-
- /* The C compiler may not treat these properly but C++ has to */
-#ifdef __cplusplus
-#undef const
-#undef inline
-#else
-#if defined(lint) || defined(TRACE)
-#undef inline
-#define inline /* nothing */
-#endif
-#endif
-
-#endif /* NC_CONFIG_H */
diff --git a/lib/ncurses/ncurses/pathnames.h b/lib/ncurses/ncurses/pathnames.h
deleted file mode 100644
index 5cac36f3651f..000000000000
--- a/lib/ncurses/ncurses/pathnames.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 1989, 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)pathnames.h 8.1 (Berkeley) 6/4/93
- * $FreeBSD$
- */
-
-#define _PATH_DEF ".termcap /usr/share/misc/termcap"
-#define _PATH_DEF_SEC "/usr/share/misc/termcap"
diff --git a/lib/ncurses/ncurses/termcap.c b/lib/ncurses/ncurses/termcap.c
deleted file mode 100644
index 9469bea29a0c..000000000000
--- a/lib/ncurses/ncurses/termcap.c
+++ /dev/null
@@ -1,265 +0,0 @@
-/* A portion of this file is from ncurses: */
-/***************************************************************************
-* COPYRIGHT NOTICE *
-****************************************************************************
-* ncurses is copyright (C) 1992-1995 *
-* Zeyd M. Ben-Halim *
-* zmbenhal@netcom.com *
-* Eric S. Raymond *
-* esr@snark.thyrsus.com *
-* *
-* Permission is hereby granted to reproduce and distribute ncurses *
-* by any means and for any fee, whether alone or as part of a *
-* larger distribution, in source or in binary form, PROVIDED *
-* this notice is included with any such distribution, and is not *
-* removed from any of its header files. Mention of ncurses in any *
-* applications linked with it is highly appreciated. *
-* *
-* ncurses comes AS IS with no warranty, implied or expressed. *
-* *
-***************************************************************************/
-
-#include <curses.priv.h>
-
-#include <string.h>
-#include <term.h>
-#include <tic.h>
-#include <term_entry.h>
-
-/* The rest is from BSD */
-/*
- * Copyright (c) 1980, 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- */
-
-#ifndef lint
-static const char sccsid[] = "@(#)termcap.c 8.1 (Berkeley) 6/4/93";
-#endif /* not lint */
-
-#include <stdio.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/param.h>
-#include "pathnames.h"
-
-#define PBUFSIZ MAXPATHLEN /* max length of filename path */
-#define PVECSIZ 32 /* max number of names in path */
-#define TBUFSIZ 1024 /* max length of _nc_tgetent buffer */
-
-char _nc_termcap[TBUFSIZ + 1]; /* Last getcap, provided to tgetent() emul */
-
-/*
- * termcap - routines for dealing with the terminal capability data base
- *
- * BUG: Should use a "last" pointer in tbuf, so that searching
- * for capabilities alphabetically would not be a n**2/2
- * process when large numbers of capabilities are given.
- * Note: If we add a last pointer now we will screw up the
- * tc capability. We really should compile termcap.
- *
- * Essentially all the work here is scanning and decoding escapes
- * in string capabilities. We don't use stdio because the editor
- * doesn't, and because living w/o it is not hard.
- */
-
-/*
- * Get an entry for terminal name in buffer _nc_termcap from the termcap
- * file.
- */
-int
-_nc_read_termcap_entry(const char *const name, TERMTYPE *const tp)
-{
- ENTRY *ep;
- register char *p;
- register char *cp;
- char *dummy;
- char **fname;
- char *home;
- int i;
- char pathbuf[PBUFSIZ]; /* holds raw path of filenames */
- char *pathvec[PVECSIZ]; /* to point to names in pathbuf */
- char **pvec; /* holds usable tail of path vector */
- char *termpath;
-
- _nc_termcap[0] = '\0'; /* in case */
- dummy = NULL;
- fname = pathvec;
- pvec = pathvec;
- p = pathbuf;
- cp = getenv("TERMCAP");
- /*
- * TERMCAP can have one of two things in it. It can be the
- * name of a file to use instead of /etc/termcap. In this
- * case it better start with a "/". Or it can be an entry to
- * use so we don't have to read the file. In this case it
- * has to already have the newlines crunched out. If TERMCAP
- * does not hold a file name then a path of names is searched
- * instead. The path is found in the TERMPATH variable, or
- * becomes "$HOME/.termcap /etc/termcap" if no TERMPATH exists.
- */
- if (!cp || *cp != '/') { /* no TERMCAP or it holds an entry */
- if ( (termpath = getenv("TERMPATH")) )
- strncpy(pathbuf, termpath, PBUFSIZ);
- else {
- if ( (home = getenv("HOME")) ) {/* set up default */
- strncpy(pathbuf, home, PBUFSIZ - 1); /* $HOME first */
- pathbuf[PBUFSIZ - 2] = '\0'; /* -2 because we add a slash */
- p += strlen(pathbuf); /* path, looking in */
- *p++ = '/';
- } /* if no $HOME look in current directory */
- strncpy(p, _PATH_DEF, PBUFSIZ - (p - pathbuf));
- }
- }
- else /* user-defined name in TERMCAP */
- strncpy(pathbuf, cp, PBUFSIZ); /* still can be tokenized */
-
- /* For safety */
- if (issetugid())
- strcpy(pathbuf, _PATH_DEF_SEC);
-
- pathbuf[PBUFSIZ - 1] = '\0';
-
- *fname++ = pathbuf; /* tokenize path into vector of names */
- while (*++p)
- if (*p == ' ' || *p == ':') {
- *p = '\0';
- while (*++p)
- if (*p != ' ' && *p != ':')
- break;
- if (*p == '\0')
- break;
- *fname++ = p;
- if (fname >= pathvec + PVECSIZ) {
- fname--;
- break;
- }
- }
- *fname = (char *) 0; /* mark end of vector */
- if (cp && *cp && *cp != '/')
- if (cgetset(cp) < 0)
- return(-2);
-
- i = cgetent(&dummy, pathvec, (char *)name);
-
- if (i == 0) {
- char *pd, *ps, *tok, *s, *tcs;
- size_t len;
-
- pd = _nc_termcap;
- ps = dummy;
- if ((tok = strchr(ps, ':')) == NULL) {
- len = strlen(ps);
- if (len >= TBUFSIZ)
- i = -1;
- else
- strcpy(pd, ps);
- goto done;
- }
- len = tok - ps + 1;
- if (pd + len + 1 - _nc_termcap >= TBUFSIZ) {
- i = -1;
- goto done;
- }
- memcpy(pd, ps, len);
- ps += len;
- pd += len;
- *pd = '\0';
- tcs = pd - 1;
- for (;;) {
- while ((tok = strsep(&ps, ":")) != NULL &&
- (*tok == '\0' || *tok == '\\' || !isgraph(*tok)))
- ;
- if (tok == NULL)
- break;
- for (s = tcs; s != NULL && s[1] != '\0';
- s = strchr(s, ':')) {
- s++;
- if (s[0] == tok[0] && s[1] == tok[1])
- goto skip_it;
- }
- len = strlen(tok);
- if (pd + len + 1 - _nc_termcap >= TBUFSIZ) {
- i = -1;
- break;
- }
- memcpy(pd, tok, len);
- pd += len;
- *pd++ = ':';
- *pd = '\0';
- skip_it: ;
- }
- }
-done:
- if (dummy)
- free(dummy);
-
-
-/*
- * From here on is ncurses-specific glue code
- */
-
- if (i < 0)
- return(ERR);
-
- _nc_set_source("TERMCAP");
- _nc_read_entry_source((FILE *)NULL, _nc_termcap, FALSE, TRUE, NULLHOOK);
-
- if (_nc_head == (ENTRY *)NULL)
- return(ERR);
-
- /* resolve all use references */
- _nc_resolve_uses();
-
- for_entry_list(ep)
- if (_nc_name_match(ep->tterm.term_names, name, "|:"))
- {
- /*
- * Make a local copy of the terminal capabilities. free
- * all entry storage except the string table for the
- * loaded type (which we disconnected from the list by
- * NULLing out ep->tterm.str_table above).
- */
- memcpy(tp, &ep->tterm, sizeof(TERMTYPE));
- ep->tterm.str_table = (char *)NULL;
- _nc_free_entries(_nc_head);
- _nc_head = _nc_tail = NULL; /* do not reuse! */
-
- return 1; /* OK */
- }
-
- _nc_free_entries(_nc_head);
- _nc_head = _nc_tail = NULL; /* do not reuse! */
- return(0); /* not found */
-}
diff --git a/lib/ncurses/panel/Makefile b/lib/ncurses/panel/Makefile
deleted file mode 100644
index cbe2ebbe58f1..000000000000
--- a/lib/ncurses/panel/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-# Makefile for libpanel
-# $FreeBSD$
-
-NCURSES=${.CURDIR}/../../contrib/ncurses
-
-.PATH: ${NCURSES}/panel
-
-LIB= panel
-
-SRCS= panel.c
-INCS= ${NCURSES}/panel/panel.h
-
-CFLAGS+= -I${.CURDIR}/../libncurses -I${NCURSES}/panel -I${NCURSES}/include \
- -Wall -DNDEBUG -DHAVE_CONFIG_H
-
-.include <bsd.lib.mk>
diff --git a/libexec/rtld-elf/alpha/lockdflt.c b/libexec/rtld-elf/alpha/lockdflt.c
deleted file mode 100644
index 4233b369099e..000000000000
--- a/libexec/rtld-elf/alpha/lockdflt.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/*-
- * Copyright 1999, 2000 John D. Polstra.
- * 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Default thread locking implementation for the dynamic linker. It
- * is used until the client registers a different implementation with
- * dllockinit(). The default implementation does mutual exclusion by
- * blocking almost all signals. This is based on the observation that
- * most userland thread packages use signals to support preemption.
- */
-
-#include <dlfcn.h>
-#include <signal.h>
-#include <stdlib.h>
-
-#include "debug.h"
-#include "rtld.h"
-
-typedef struct Struct_LockDflt {
- sigset_t lock_mask;
- sigset_t old_mask;
- int depth;
-} LockDflt;
-
-void
-lockdflt_acquire(void *lock)
-{
- LockDflt *l = (LockDflt *)lock;
- sigprocmask(SIG_BLOCK, &l->lock_mask, &l->old_mask);
- assert(l->depth == 0);
- l->depth++;
-}
-
-void *
-lockdflt_create(void *context)
-{
- LockDflt *l;
-
- l = NEW(LockDflt);
- l->depth = 0;
- sigfillset(&l->lock_mask);
- sigdelset(&l->lock_mask, SIGTRAP);
- sigdelset(&l->lock_mask, SIGABRT);
- sigdelset(&l->lock_mask, SIGBUS);
- sigdelset(&l->lock_mask, SIGSEGV);
- sigdelset(&l->lock_mask, SIGKILL);
- sigdelset(&l->lock_mask, SIGSTOP);
- return l;
-}
-
-void
-lockdflt_destroy(void *lock)
-{
- LockDflt *l = (LockDflt *)lock;
- free(l);
-}
-
-void
-lockdflt_release(void *lock)
-{
- LockDflt *l = (LockDflt *)lock;
- assert(l->depth == 1);
- l->depth--;
- sigprocmask(SIG_SETMASK, &l->old_mask, NULL);
-}
diff --git a/libexec/rtld-elf/amd64/Makefile.inc b/libexec/rtld-elf/amd64/Makefile.inc
deleted file mode 100644
index ba39193cf89a..000000000000
--- a/libexec/rtld-elf/amd64/Makefile.inc
+++ /dev/null
@@ -1,5 +0,0 @@
-CFLAGS+= -elf
-LDFLAGS+= -elf
-# Uncomment this to build the dynamic linker as an executable instead
-# of a shared library:
-#LDSCRIPT= ${.CURDIR}/${MACHINE_ARCH}/elf_rtld.x
diff --git a/libexec/rtld-elf/amd64/elf_rtld.x b/libexec/rtld-elf/amd64/elf_rtld.x
deleted file mode 100644
index e19168cb8808..000000000000
--- a/libexec/rtld-elf/amd64/elf_rtld.x
+++ /dev/null
@@ -1,131 +0,0 @@
-OUTPUT_FORMAT("elf32-i386", "elf32-i386",
- "elf32-i386")
-OUTPUT_ARCH(i386)
-ENTRY(_start)
-SEARCH_DIR(/usr/lib); SEARCH_DIR(/usr/obj/usr/src/tmp/usr/i386-unknown-freebsdelf/lib);
-/* Do we need any of these for elf?
- __DYNAMIC = 0; */
-SECTIONS
-{
- /* Read-only sections, merged into text segment: */
- . = 0x08000000 + SIZEOF_HEADERS;
- .interp : { *(.interp) }
- .hash : { *(.hash) }
- .dynsym : { *(.dynsym) }
- .dynstr : { *(.dynstr) }
- .gnu.version : { *(.gnu.version) }
- .gnu.version_d : { *(.gnu.version_d) }
- .gnu.version_r : { *(.gnu.version_r) }
- .rel.text :
- { *(.rel.text) *(.rel.gnu.linkonce.t*) }
- .rela.text :
- { *(.rela.text) *(.rela.gnu.linkonce.t*) }
- .rel.data :
- { *(.rel.data) *(.rel.gnu.linkonce.d*) }
- .rela.data :
- { *(.rela.data) *(.rela.gnu.linkonce.d*) }
- .rel.rodata :
- { *(.rel.rodata) *(.rel.gnu.linkonce.r*) }
- .rela.rodata :
- { *(.rela.rodata) *(.rela.gnu.linkonce.r*) }
- .rel.got : { *(.rel.got) }
- .rela.got : { *(.rela.got) }
- .rel.ctors : { *(.rel.ctors) }
- .rela.ctors : { *(.rela.ctors) }
- .rel.dtors : { *(.rel.dtors) }
- .rela.dtors : { *(.rela.dtors) }
- .rel.init : { *(.rel.init) }
- .rela.init : { *(.rela.init) }
- .rel.fini : { *(.rel.fini) }
- .rela.fini : { *(.rela.fini) }
- .rel.bss : { *(.rel.bss) }
- .rela.bss : { *(.rela.bss) }
- .rel.plt : { *(.rel.plt) }
- .rela.plt : { *(.rela.plt) }
- .init : { *(.init) } =0x9090
- .plt : { *(.plt) }
- .text :
- {
- *(.text)
- *(.stub)
- /* .gnu.warning sections are handled specially by elf32.em. */
- *(.gnu.warning)
- *(.gnu.linkonce.t*)
- } =0x9090
- _etext = .;
- PROVIDE (etext = .);
- .fini : { *(.fini) } =0x9090
- .rodata : { *(.rodata) *(.gnu.linkonce.r*) }
- .rodata1 : { *(.rodata1) }
- /* Adjust the address for the data segment. We want to adjust up to
- the same address within the page on the next page up. */
- . = ALIGN(0x1000) + (. & (0x1000 - 1));
- .data :
- {
- *(.data)
- *(.gnu.linkonce.d*)
- CONSTRUCTORS
- }
- .data1 : { *(.data1) }
- .ctors :
- {
- *(.ctors)
- }
- .dtors :
- {
- *(.dtors)
- }
- .got : { *(.got.plt) *(.got) }
- .dynamic : { *(.dynamic) }
- /* We want the small data sections together, so single-instruction offsets
- can access them all, and initialized data all before uninitialized, so
- we can shorten the on-disk segment size. */
- .sdata : { *(.sdata) }
- _edata = .;
- PROVIDE (edata = .);
- __bss_start = .;
- .sbss : { *(.sbss) *(.scommon) }
- .bss :
- {
- *(.dynbss)
- *(.bss)
- *(COMMON)
- }
- . = ALIGN(32 / 8);
- _end = . ;
- PROVIDE (end = .);
- /* Stabs debugging sections. */
- .stab 0 : { *(.stab) }
- .stabstr 0 : { *(.stabstr) }
- .stab.excl 0 : { *(.stab.excl) }
- .stab.exclstr 0 : { *(.stab.exclstr) }
- .stab.index 0 : { *(.stab.index) }
- .stab.indexstr 0 : { *(.stab.indexstr) }
- .comment 0 : { *(.comment) }
- /* DWARF debug sections.
- Symbols in the DWARF debugging sections are relative to the beginning
- of the section so we begin them at 0. */
- /* DWARF 1 */
- .debug 0 : { *(.debug) }
- .line 0 : { *(.line) }
- /* GNU DWARF 1 extensions */
- .debug_srcinfo 0 : { *(.debug_srcinfo) }
- .debug_sfnames 0 : { *(.debug_sfnames) }
- /* DWARF 1.1 and DWARF 2 */
- .debug_aranges 0 : { *(.debug_aranges) }
- .debug_pubnames 0 : { *(.debug_pubnames) }
- /* DWARF 2 */
- .debug_info 0 : { *(.debug_info) }
- .debug_abbrev 0 : { *(.debug_abbrev) }
- .debug_line 0 : { *(.debug_line) }
- .debug_frame 0 : { *(.debug_frame) }
- .debug_str 0 : { *(.debug_str) }
- .debug_loc 0 : { *(.debug_loc) }
- .debug_macinfo 0 : { *(.debug_macinfo) }
- /* SGI/MIPS DWARF 2 extensions */
- .debug_weaknames 0 : { *(.debug_weaknames) }
- .debug_funcnames 0 : { *(.debug_funcnames) }
- .debug_typenames 0 : { *(.debug_typenames) }
- .debug_varnames 0 : { *(.debug_varnames) }
- /* These must appear regardless of . */
-}
diff --git a/libexec/rtld-elf/amd64/lockdflt.c b/libexec/rtld-elf/amd64/lockdflt.c
deleted file mode 100644
index 4233b369099e..000000000000
--- a/libexec/rtld-elf/amd64/lockdflt.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/*-
- * Copyright 1999, 2000 John D. Polstra.
- * 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Default thread locking implementation for the dynamic linker. It
- * is used until the client registers a different implementation with
- * dllockinit(). The default implementation does mutual exclusion by
- * blocking almost all signals. This is based on the observation that
- * most userland thread packages use signals to support preemption.
- */
-
-#include <dlfcn.h>
-#include <signal.h>
-#include <stdlib.h>
-
-#include "debug.h"
-#include "rtld.h"
-
-typedef struct Struct_LockDflt {
- sigset_t lock_mask;
- sigset_t old_mask;
- int depth;
-} LockDflt;
-
-void
-lockdflt_acquire(void *lock)
-{
- LockDflt *l = (LockDflt *)lock;
- sigprocmask(SIG_BLOCK, &l->lock_mask, &l->old_mask);
- assert(l->depth == 0);
- l->depth++;
-}
-
-void *
-lockdflt_create(void *context)
-{
- LockDflt *l;
-
- l = NEW(LockDflt);
- l->depth = 0;
- sigfillset(&l->lock_mask);
- sigdelset(&l->lock_mask, SIGTRAP);
- sigdelset(&l->lock_mask, SIGABRT);
- sigdelset(&l->lock_mask, SIGBUS);
- sigdelset(&l->lock_mask, SIGSEGV);
- sigdelset(&l->lock_mask, SIGKILL);
- sigdelset(&l->lock_mask, SIGSTOP);
- return l;
-}
-
-void
-lockdflt_destroy(void *lock)
-{
- LockDflt *l = (LockDflt *)lock;
- free(l);
-}
-
-void
-lockdflt_release(void *lock)
-{
- LockDflt *l = (LockDflt *)lock;
- assert(l->depth == 1);
- l->depth--;
- sigprocmask(SIG_SETMASK, &l->old_mask, NULL);
-}
diff --git a/libexec/rtld-elf/amd64/reloc.c b/libexec/rtld-elf/amd64/reloc.c
deleted file mode 100644
index 360733a71109..000000000000
--- a/libexec/rtld-elf/amd64/reloc.c
+++ /dev/null
@@ -1,248 +0,0 @@
-/*-
- * Copyright 1996, 1997, 1998, 1999 John D. Polstra.
- * 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Dynamic linker for ELF.
- *
- * John Polstra <jdp@polstra.com>.
- */
-
-#include <sys/param.h>
-#include <sys/mman.h>
-
-#include <dlfcn.h>
-#include <err.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "debug.h"
-#include "rtld.h"
-
-/*
- * Process the special R_386_COPY relocations in the main program. These
- * copy data from a shared object into a region in the main program's BSS
- * segment.
- *
- * Returns 0 on success, -1 on failure.
- */
-int
-do_copy_relocations(Obj_Entry *dstobj)
-{
- const Elf_Rel *rellim;
- const Elf_Rel *rel;
-
- assert(dstobj->mainprog); /* COPY relocations are invalid elsewhere */
-
- rellim = (const Elf_Rel *) ((caddr_t) dstobj->rel + dstobj->relsize);
- for (rel = dstobj->rel; rel < rellim; rel++) {
- if (ELF_R_TYPE(rel->r_info) == R_386_COPY) {
- void *dstaddr;
- const Elf_Sym *dstsym;
- const char *name;
- unsigned long hash;
- size_t size;
- const void *srcaddr;
- const Elf_Sym *srcsym;
- Obj_Entry *srcobj;
-
- dstaddr = (void *) (dstobj->relocbase + rel->r_offset);
- dstsym = dstobj->symtab + ELF_R_SYM(rel->r_info);
- name = dstobj->strtab + dstsym->st_name;
- hash = elf_hash(name);
- size = dstsym->st_size;
-
- for (srcobj = dstobj->next; srcobj != NULL; srcobj = srcobj->next)
- if ((srcsym = symlook_obj(name, hash, srcobj, false)) != NULL)
- break;
-
- if (srcobj == NULL) {
- _rtld_error("Undefined symbol \"%s\" referenced from COPY"
- " relocation in %s", name, dstobj->path);
- return -1;
- }
-
- srcaddr = (const void *) (srcobj->relocbase + srcsym->st_value);
- memcpy(dstaddr, srcaddr, size);
- }
- }
-
- return 0;
-}
-
-/* Initialize the special GOT entries. */
-void
-init_pltgot(Obj_Entry *obj)
-{
- if (obj->pltgot != NULL) {
- obj->pltgot[1] = (Elf_Addr) obj;
- obj->pltgot[2] = (Elf_Addr) &_rtld_bind_start;
- }
-}
-
-/* Process the non-PLT relocations. */
-int
-reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld)
-{
- const Elf_Rel *rellim;
- const Elf_Rel *rel;
-
- rellim = (const Elf_Rel *) ((caddr_t) obj->rel + obj->relsize);
- for (rel = obj->rel; rel < rellim; rel++) {
- Elf_Addr *where = (Elf_Addr *) (obj->relocbase + rel->r_offset);
-
- switch (ELF_R_TYPE(rel->r_info)) {
-
- case R_386_NONE:
- break;
-
- case R_386_32:
- {
- const Elf_Sym *def;
- const Obj_Entry *defobj;
-
- def = find_symdef(ELF_R_SYM(rel->r_info), obj, &defobj,
- false);
- if (def == NULL)
- return -1;
-
- *where += (Elf_Addr) (defobj->relocbase + def->st_value);
- }
- break;
-
- case R_386_PC32:
- /*
- * I don't think the dynamic linker should ever see this
- * type of relocation. But the binutils-2.6 tools sometimes
- * generate it.
- */
- {
- const Elf_Sym *def;
- const Obj_Entry *defobj;
-
- def = find_symdef(ELF_R_SYM(rel->r_info), obj, &defobj,
- false);
- if (def == NULL)
- return -1;
-
- *where +=
- (Elf_Addr) (defobj->relocbase + def->st_value) -
- (Elf_Addr) where;
- }
- break;
-
- case R_386_COPY:
- /*
- * These are deferred until all other relocations have
- * been done. All we do here is make sure that the COPY
- * relocation is not in a shared library. They are allowed
- * only in executable files.
- */
- if (!obj->mainprog) {
- _rtld_error("%s: Unexpected R_386_COPY relocation"
- " in shared library", obj->path);
- return -1;
- }
- break;
-
- case R_386_GLOB_DAT:
- {
- const Elf_Sym *def;
- const Obj_Entry *defobj;
-
- def = find_symdef(ELF_R_SYM(rel->r_info), obj, &defobj,
- false);
- if (def == NULL)
- return -1;
-
- *where = (Elf_Addr) (defobj->relocbase + def->st_value);
- }
- break;
-
- case R_386_RELATIVE:
- *where += (Elf_Addr) obj->relocbase;
- break;
-
- default:
- _rtld_error("%s: Unsupported relocation type %d"
- " in non-PLT relocations\n", obj->path,
- ELF_R_TYPE(rel->r_info));
- return -1;
- }
- }
- return 0;
-}
-
-/* Process the PLT relocations. */
-int
-reloc_plt(Obj_Entry *obj)
-{
- const Elf_Rel *rellim;
- const Elf_Rel *rel;
-
- rellim = (const Elf_Rel *)((char *)obj->pltrel + obj->pltrelsize);
- for (rel = obj->pltrel; rel < rellim; rel++) {
- Elf_Addr *where;
-
- assert(ELF_R_TYPE(rel->r_info) == R_386_JMP_SLOT);
-
- /* Relocate the GOT slot pointing into the PLT. */
- where = (Elf_Addr *)(obj->relocbase + rel->r_offset);
- *where += (Elf_Addr)obj->relocbase;
- }
- return 0;
-}
-
-/* Relocate the jump slots in an object. */
-int
-reloc_jmpslots(Obj_Entry *obj)
-{
- const Elf_Rel *rellim;
- const Elf_Rel *rel;
-
- if (obj->jmpslots_done)
- return 0;
- rellim = (const Elf_Rel *)((char *)obj->pltrel + obj->pltrelsize);
- for (rel = obj->pltrel; rel < rellim; rel++) {
- Elf_Addr *where;
- const Elf_Sym *def;
- const Obj_Entry *defobj;
-
- assert(ELF_R_TYPE(rel->r_info) == R_386_JMP_SLOT);
- where = (Elf_Addr *)(obj->relocbase + rel->r_offset);
- def = find_symdef(ELF_R_SYM(rel->r_info), obj, &defobj, true);
- if (def == NULL)
- return -1;
- reloc_jmpslot(where, (Elf_Addr)(defobj->relocbase + def->st_value));
- }
- obj->jmpslots_done = true;
- return 0;
-}
diff --git a/libexec/rtld-elf/amd64/rtld_machdep.h b/libexec/rtld-elf/amd64/rtld_machdep.h
deleted file mode 100644
index b44129ae53e8..000000000000
--- a/libexec/rtld-elf/amd64/rtld_machdep.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*-
- * Copyright (c) 1999 John D. Polstra.
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#ifndef RTLD_MACHDEP_H
-#define RTLD_MACHDEP_H 1
-
-/* Return the address of the .dynamic section in the dynamic linker. */
-#define rtld_dynamic(obj) \
- ((const Elf_Dyn *)((obj)->relocbase + (Elf_Addr)&_DYNAMIC))
-
-/* Fixup the jump slot at "where" to transfer control to "target". */
-#define reloc_jmpslot(where, target) \
- do { \
- dbg("reloc_jmpslot: *%p = %p", (void *)(where), \
- (void *)(target)); \
- (*(Elf_Addr *)(where) = (Elf_Addr)(target)); \
- } while (0)
-
-#endif
diff --git a/libexec/rtld-elf/amd64/rtld_start.S b/libexec/rtld-elf/amd64/rtld_start.S
deleted file mode 100644
index 76f1392625d7..000000000000
--- a/libexec/rtld-elf/amd64/rtld_start.S
+++ /dev/null
@@ -1,88 +0,0 @@
-/*-
- * Copyright 1996-1998 John D. Polstra.
- * 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.
- *
- * $FreeBSD$
- */
-
- .text
- .align 4
- .globl .rtld_start
- .type .rtld_start,@function
-.rtld_start:
- xorl %ebp,%ebp # Clear frame pointer for good form
- movl %esp,%eax # Save initial stack pointer
- subl $8,%esp # A place to store exit procedure addr
- movl %esp,%ebx # save address of exit proc
- movl %esp,%ecx # construct address of obj_main
- addl $4,%ecx
- pushl %ecx # Pass address of obj_main
- pushl %ebx # Pass address of exit proc
- pushl %eax # Pass initial stack pointer to rtld
- call _rtld@PLT # Call rtld(sp); returns entry point
- addl $12,%esp # Remove arguments from stack
- popl %edx # Get exit procedure address
- addl $4,%esp # Ignore obj_main
-/*
- * At this point, %eax contains the entry point of the main program, and
- * %edx contains a pointer to a termination function that should be
- * registered with atexit(). (crt1.o registers it.)
- */
-.globl .rtld_goto_main
-.rtld_goto_main: # This symbol exists just to make debugging easier.
- jmp *%eax # Enter main program
-
-
-/*
- * Binder entry point. Control is transferred to here by code in the PLT.
- * On entry, there are two arguments on the stack. In ascending address
- * order, they are (1) "obj", a pointer to the calling object's Obj_Entry,
- * and (2) "reloff", the byte offset of the appropriate relocation entry
- * in the PLT relocation table.
- *
- * We are careful to preserve all registers, even the the caller-save
- * registers. That is because this code may be invoked by low-level
- * assembly-language code that is not ABI-compliant.
- */
- .align 4
- .globl _rtld_bind_start
- .type _rtld_bind_start,@function
-_rtld_bind_start:
- pushf # Save eflags
- pushl %eax # Save %eax
- pushl %edx # Save %edx
- pushl %ecx # Save %ecx
- pushl 20(%esp) # Copy reloff argument
- pushl 20(%esp) # Copy obj argument
-
- call _rtld_bind@PLT # Transfer control to the binder
- /* Now %eax contains the entry point of the function being called. */
-
- addl $8,%esp # Discard binder arguments
- movl %eax,20(%esp) # Store target over obj argument
- popl %ecx # Restore %ecx
- popl %edx # Restore %edx
- popl %eax # Restore %eax
- popf # Restore eflags
- leal 4(%esp),%esp # Discard reloff, do not change eflags
- ret # "Return" to target address
diff --git a/libexec/rtld-elf/i386/lockdflt.c b/libexec/rtld-elf/i386/lockdflt.c
deleted file mode 100644
index 4233b369099e..000000000000
--- a/libexec/rtld-elf/i386/lockdflt.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/*-
- * Copyright 1999, 2000 John D. Polstra.
- * 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Default thread locking implementation for the dynamic linker. It
- * is used until the client registers a different implementation with
- * dllockinit(). The default implementation does mutual exclusion by
- * blocking almost all signals. This is based on the observation that
- * most userland thread packages use signals to support preemption.
- */
-
-#include <dlfcn.h>
-#include <signal.h>
-#include <stdlib.h>
-
-#include "debug.h"
-#include "rtld.h"
-
-typedef struct Struct_LockDflt {
- sigset_t lock_mask;
- sigset_t old_mask;
- int depth;
-} LockDflt;
-
-void
-lockdflt_acquire(void *lock)
-{
- LockDflt *l = (LockDflt *)lock;
- sigprocmask(SIG_BLOCK, &l->lock_mask, &l->old_mask);
- assert(l->depth == 0);
- l->depth++;
-}
-
-void *
-lockdflt_create(void *context)
-{
- LockDflt *l;
-
- l = NEW(LockDflt);
- l->depth = 0;
- sigfillset(&l->lock_mask);
- sigdelset(&l->lock_mask, SIGTRAP);
- sigdelset(&l->lock_mask, SIGABRT);
- sigdelset(&l->lock_mask, SIGBUS);
- sigdelset(&l->lock_mask, SIGSEGV);
- sigdelset(&l->lock_mask, SIGKILL);
- sigdelset(&l->lock_mask, SIGSTOP);
- return l;
-}
-
-void
-lockdflt_destroy(void *lock)
-{
- LockDflt *l = (LockDflt *)lock;
- free(l);
-}
-
-void
-lockdflt_release(void *lock)
-{
- LockDflt *l = (LockDflt *)lock;
- assert(l->depth == 1);
- l->depth--;
- sigprocmask(SIG_SETMASK, &l->old_mask, NULL);
-}
diff --git a/release/alpha/dokern.sh b/release/alpha/dokern.sh
deleted file mode 100755
index 295888be2a9d..000000000000
--- a/release/alpha/dokern.sh
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/bin/sh
-
-ARCH="`uname -m`"
-
-# First check for the standard x86 PC class.
-if [ "${ARCH}" = "i386" ]; then
-
-sed -e '/pty/d' \
- -e '/pass/d' \
- -e '/apm0/d' \
- -e '/ppp/d' \
- -e '/gzip/d' \
- -e '/splash/d' \
- -e '/IPv6/d' \
- -e '/PROCFS/d' \
- -e '/KTRACE/d' \
- -e '/SYSVMSG/d' \
- -e '/maxusers/d' \
- -e 's/GENERIC/BOOTMFS/g'
-
-echo "options NETGRAPH"
-echo "options NETGRAPH_PPPOE"
-echo "options NETGRAPH_SOCKET"
-
-# Otherwise maybe it's an alpha, and it has big binaries.
-elif [ "${ARCH}" = "alpha" ]; then
-
-sed -e '/pty/d' \
- -e '/pass/d' \
- -e '/apm0/d' \
- -e '/ppp/d' \
- -e '/gzip/d' \
- -e '/splash/d' \
- -e '/IPv6/d' \
- -e '/PROCFS/d' \
- -e '/KTRACE/d' \
- -e '/SYSV/d' \
- -e '/maxusers/d' \
- -e 's/GENERIC/BOOTMFS/g'
-fi
-
-# reset maxusers to something lower
-echo "maxusers 5"
-
-echo "options NFS_NOSERVER"
-echo "options SCSI_NO_OP_STRINGS"
-echo "options SCSI_NO_SENSE_STRINGS"
diff --git a/release/alpha/fixit_crunch.conf b/release/alpha/fixit_crunch.conf
deleted file mode 100644
index f07a1184d513..000000000000
--- a/release/alpha/fixit_crunch.conf
+++ /dev/null
@@ -1,38 +0,0 @@
-# $FreeBSD$
-
-# first, we list the source dirs that our programs reside in. These are
-# searched in order listed to find the dir containing each program.
-
-srcdirs /usr/src/bin /usr/src/sbin /usr/src/usr.bin /usr/src/usr.sbin
-srcdirs /usr/src/gnu/usr.bin /usr/src/usr.bin/vi
-srcdirs /usr/src/sbin/i386
-
-# second, we list all the programs we want to include in our crunched binary.
-# The order doesn't matter. Any program that needs hard links to it gets an
-# `ln' directive.
-
-# /bin stuff
-
-progs cat chmod chroot cp dd df echo expr kill ln ls mkdir
-progs mv rm rmdir sleep sync
-
-# /sbin stuff
-
-progs chown clri disklabel dmesg fdisk
-progs mknod mount reboot restore swapon umount
-
-progs mount_msdos mount_cd9660
-
-ln restore rrestore
-ln chown chgrp
-
-# /usr/bin stuff
-
-progs ftp more telnet vi grep
-ln vi view
-ln vi ex
-
-# finally, we specify the libraries to link in with our binary
-
-libs -lcrypt -ltelnet -lutil -ll -lm
-libs -lcurses -ltermcap -ledit -lgnuregex -lkvm -lz
diff --git a/release/amd64/dokern.sh b/release/amd64/dokern.sh
deleted file mode 100755
index 295888be2a9d..000000000000
--- a/release/amd64/dokern.sh
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/bin/sh
-
-ARCH="`uname -m`"
-
-# First check for the standard x86 PC class.
-if [ "${ARCH}" = "i386" ]; then
-
-sed -e '/pty/d' \
- -e '/pass/d' \
- -e '/apm0/d' \
- -e '/ppp/d' \
- -e '/gzip/d' \
- -e '/splash/d' \
- -e '/IPv6/d' \
- -e '/PROCFS/d' \
- -e '/KTRACE/d' \
- -e '/SYSVMSG/d' \
- -e '/maxusers/d' \
- -e 's/GENERIC/BOOTMFS/g'
-
-echo "options NETGRAPH"
-echo "options NETGRAPH_PPPOE"
-echo "options NETGRAPH_SOCKET"
-
-# Otherwise maybe it's an alpha, and it has big binaries.
-elif [ "${ARCH}" = "alpha" ]; then
-
-sed -e '/pty/d' \
- -e '/pass/d' \
- -e '/apm0/d' \
- -e '/ppp/d' \
- -e '/gzip/d' \
- -e '/splash/d' \
- -e '/IPv6/d' \
- -e '/PROCFS/d' \
- -e '/KTRACE/d' \
- -e '/SYSV/d' \
- -e '/maxusers/d' \
- -e 's/GENERIC/BOOTMFS/g'
-fi
-
-# reset maxusers to something lower
-echo "maxusers 5"
-
-echo "options NFS_NOSERVER"
-echo "options SCSI_NO_OP_STRINGS"
-echo "options SCSI_NO_SENSE_STRINGS"
diff --git a/release/i386/dokern.sh b/release/i386/dokern.sh
deleted file mode 100755
index 295888be2a9d..000000000000
--- a/release/i386/dokern.sh
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/bin/sh
-
-ARCH="`uname -m`"
-
-# First check for the standard x86 PC class.
-if [ "${ARCH}" = "i386" ]; then
-
-sed -e '/pty/d' \
- -e '/pass/d' \
- -e '/apm0/d' \
- -e '/ppp/d' \
- -e '/gzip/d' \
- -e '/splash/d' \
- -e '/IPv6/d' \
- -e '/PROCFS/d' \
- -e '/KTRACE/d' \
- -e '/SYSVMSG/d' \
- -e '/maxusers/d' \
- -e 's/GENERIC/BOOTMFS/g'
-
-echo "options NETGRAPH"
-echo "options NETGRAPH_PPPOE"
-echo "options NETGRAPH_SOCKET"
-
-# Otherwise maybe it's an alpha, and it has big binaries.
-elif [ "${ARCH}" = "alpha" ]; then
-
-sed -e '/pty/d' \
- -e '/pass/d' \
- -e '/apm0/d' \
- -e '/ppp/d' \
- -e '/gzip/d' \
- -e '/splash/d' \
- -e '/IPv6/d' \
- -e '/PROCFS/d' \
- -e '/KTRACE/d' \
- -e '/SYSV/d' \
- -e '/maxusers/d' \
- -e 's/GENERIC/BOOTMFS/g'
-fi
-
-# reset maxusers to something lower
-echo "maxusers 5"
-
-echo "options NFS_NOSERVER"
-echo "options SCSI_NO_OP_STRINGS"
-echo "options SCSI_NO_SENSE_STRINGS"
diff --git a/release/pc98/dokern.sh b/release/pc98/dokern.sh
deleted file mode 100755
index 295888be2a9d..000000000000
--- a/release/pc98/dokern.sh
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/bin/sh
-
-ARCH="`uname -m`"
-
-# First check for the standard x86 PC class.
-if [ "${ARCH}" = "i386" ]; then
-
-sed -e '/pty/d' \
- -e '/pass/d' \
- -e '/apm0/d' \
- -e '/ppp/d' \
- -e '/gzip/d' \
- -e '/splash/d' \
- -e '/IPv6/d' \
- -e '/PROCFS/d' \
- -e '/KTRACE/d' \
- -e '/SYSVMSG/d' \
- -e '/maxusers/d' \
- -e 's/GENERIC/BOOTMFS/g'
-
-echo "options NETGRAPH"
-echo "options NETGRAPH_PPPOE"
-echo "options NETGRAPH_SOCKET"
-
-# Otherwise maybe it's an alpha, and it has big binaries.
-elif [ "${ARCH}" = "alpha" ]; then
-
-sed -e '/pty/d' \
- -e '/pass/d' \
- -e '/apm0/d' \
- -e '/ppp/d' \
- -e '/gzip/d' \
- -e '/splash/d' \
- -e '/IPv6/d' \
- -e '/PROCFS/d' \
- -e '/KTRACE/d' \
- -e '/SYSV/d' \
- -e '/maxusers/d' \
- -e 's/GENERIC/BOOTMFS/g'
-fi
-
-# reset maxusers to something lower
-echo "maxusers 5"
-
-echo "options NFS_NOSERVER"
-echo "options SCSI_NO_OP_STRINGS"
-echo "options SCSI_NO_SENSE_STRINGS"
diff --git a/release/picobsd/build/write_mfs_in_kernel.c b/release/picobsd/build/write_mfs_in_kernel.c
deleted file mode 100644
index 379112459ee8..000000000000
--- a/release/picobsd/build/write_mfs_in_kernel.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * ----------------------------------------------------------------------------
- * "THE BEER-WARE LICENSE" (Revision 42):
- * <phk@login.dknet.dk> wrote this file. As long as you retain this notice you
- * can do whatever you want with this stuff. If we meet some day, and you think
- * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
- * ----------------------------------------------------------------------------
- *
- * $FreeBSD$
- *
- * This program patches a filesystem into a kernel made with MD_ROOT
- * option.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <ufs/ffs/fs.h>
-
-static int force = 0; /* don't check for zeros, may corrupt kernel */
-
-int
-main(int argc, char **argv)
-{
- unsigned char *buf_kernel, *buf_fs, *p,*q, *prog;
- int fd_kernel, fd_fs, ch, errs=0;
- struct stat st_kernel, st_fs;
- u_long l;
-
- prog= *argv;
- while ((ch = getopt(argc, argv, "f")) != EOF)
- switch(ch) {
- case 'f':
- force = 1 - force;
- break;
- default:
- errs++;
- }
- argc -= optind;
- argv += optind;
-
- if (errs || argc != 2) {
- fprintf(stderr,"Usage:\n\t%s [-f] kernel fs\n", prog);
- exit(2);
- }
- --argv; /* original prog did not use getopt(3) */
- fd_kernel = open(argv[1],O_RDWR);
- if (fd_kernel < 0) { perror(argv[1]); exit(2); }
- fstat(fd_kernel,&st_kernel);
- fd_fs = open(argv[2],O_RDONLY);
- if (fd_fs < 0) { perror(argv[2]); exit(2); }
- fstat(fd_fs,&st_fs);
- buf_kernel = malloc(st_kernel.st_size);
- if (!buf_kernel) { perror("malloc"); exit(2); }
- buf_fs = malloc(st_fs.st_size);
- if (!buf_fs) { perror("malloc"); exit(2); }
- if (st_kernel.st_size != read(fd_kernel,buf_kernel,st_kernel.st_size))
- { perror(argv[1]); exit(2); }
- if (st_fs.st_size != read(fd_fs,buf_fs,st_fs.st_size))
- { perror(argv[2]); exit(2); }
- for(l=0,p=buf_kernel; l < st_kernel.st_size - st_fs.st_size ; l++,p++ )
- if(*p == 'M' && !strcmp(p,"MFS Filesystem goes here"))
- goto found;
- fprintf(stderr,"MFS filesystem signature not found in %s\n",argv[1]);
- exit(1);
-found:
- if (!force)
- for(l=0,q= p + SBOFF; l < st_fs.st_size - SBOFF ; l++,q++ )
- if (*q)
- goto fail;
- memcpy(p+SBOFF,buf_fs+SBOFF,st_fs.st_size-SBOFF);
- lseek(fd_kernel,0L,SEEK_SET);
- if (st_kernel.st_size != write(fd_kernel,buf_kernel,st_kernel.st_size))
- { perror(argv[1]); exit(2); }
- exit(0);
-fail:
- l += SBOFF;
- fprintf(stderr,"Obstruction in kernel after %ld bytes (%ld Kbyte)\n",
- l, l/1024);
- fprintf(stderr,"Filesystem is %ld bytes (%ld Kbyte)\n",
- (u_long)st_fs.st_size, (u_long)st_fs.st_size/1024);
- exit(1);
-}
-
-/*
- * I added a '-f' option to force writing the image into the kernel, even when
- * there is already data (i.e. not zero) in the written area. This is useful
- * to rewrite a changed MD-image. Beware: If the written image is larger than
- * the space reserved in the kernel (with option MD_ROOT) then
- * THIS WILL CORRUPT THE KERNEL!
- *
- */
diff --git a/release/scripts/base-install.sh b/release/scripts/base-install.sh
deleted file mode 100755
index 6b32b033a842..000000000000
--- a/release/scripts/base-install.sh
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/sh
-#
-if [ "`id -u`" != "0" ]; then
- echo "Sorry, this must be done as root."
- exit 1
-fi
-
-echo "You are about to extract the base distribution into ${DESTDIR:-/} - are you SURE"
-echo -n "you want to do this over your installed system (y/n)? "
-read ans
-if [ "$ans" = "y" ]; then
- cat bin.?? | tar --unlink -xpzf - -C ${DESTDIR:-/}
-fi
diff --git a/sbin/bsdlabel/Makefile b/sbin/bsdlabel/Makefile
deleted file mode 100644
index bf77cff4c2cf..000000000000
--- a/sbin/bsdlabel/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-# @(#)Makefile 8.2 (Berkeley) 3/17/94
-
-PROG= disklabel
-SRCS= disklabel.c dkcksum.c
-MAN8= disklabel.8
-MAN5= disklabel.5
-
-.include <bsd.prog.mk>
diff --git a/sbin/bsdlabel/bsdlabel.5 b/sbin/bsdlabel/bsdlabel.5
deleted file mode 100644
index 3583c5907ecc..000000000000
--- a/sbin/bsdlabel/bsdlabel.5
+++ /dev/null
@@ -1,543 +0,0 @@
-.\" Copyright (c) 1987, 1991, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" This code is derived from software contributed to Berkeley by
-.\" Symmetric Computer Systems.
-.\"
-.\" 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 University of
-.\" California, Berkeley and its contributors.
-.\" 4. 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.
-.\"
-.\" @(#)disklabel.5.5 8.1 (Berkeley) 6/5/93
-.\" $FreeBSD$
-.\"
-.Dd June 5, 1993
-.Dt DISKLABEL 5
-.Os
-.Sh NAME
-.Nm disklabel
-.Nd disk pack label
-.Sh SYNOPSIS
-.Fd #include <sys/disklabel.h>
-.Sh DESCRIPTION
-Each disk or disk pack on a system may contain a disk label
-which provides detailed information
-about the geometry of the disk and the partitions into which the disk
-is divided.
-It should be initialized when the disk is formatted,
-and may be changed later with the
-.Xr disklabel 8
-program.
-This information is used by the system disk driver and by the bootstrap
-program to determine how to program the drive
-and where to find the filesystems on the disk partitions.
-Additional information is used by the filesystem in order
-to use the disk most efficiently and to locate important filesystem information.
-The description of each partition contains an identifier for the partition
-type (standard filesystem, swap area, etc.).
-The filesystem updates the in-core copy of the label if it contains
-incomplete information about the filesystem.
-.Pp
-The label is located in sector number
-.Dv LABELSECTOR
-of the drive, usually sector 0 where it may be found
-without any information about the disk geometry.
-It is at an offset
-.Dv LABELOFFSET
-from the beginning of the sector, to allow room for the initial bootstrap.
-The disk sector containing the label is normally made read-only
-so that it is not accidentally overwritten by pack-to-pack copies
-or swap operations;
-the
-.Dv DIOCWLABEL
-.Xr ioctl 2 ,
-which is done as needed by the
-.Xr disklabel 8
-program.
-.Pp
-A copy of the in-core label for a disk can be obtained with the
-.Dv DIOCGDINFO
-.Xr ioctl 2 ;
-this works with a file descriptor for a block or character (``raw'') device
-for any partition of the disk.
-The in-core copy of the label is set by the
-.Dv DIOCSDINFO
-.Xr ioctl 2 .
-The offset of a partition cannot generally be changed while it is open,
-nor can it be made smaller while it is open.
-One exception is that any change is allowed if no label was found
-on the disk, and the driver was able to construct only a skeletal label
-without partition information.
-Finally, the
-.Dv DIOCWDINFO
-.Xr ioctl 2
-operation sets the in-core label and then updates the on-disk label;
-there must be an existing label on the disk for this operation to succeed.
-Thus, the initial label for a disk or disk pack must be installed
-by writing to the raw disk.
-All of these operations are normally done using
-.Xr disklabel 8 .
-.Pp
-The format of the disk label, as specified in
-.Pa <sys/disklabel.h> ,
-is
-.Bd -literal
-#ifndef _SYS_DISKLABEL_H_
-#define _SYS_DISKLABEL_H_
-
-#ifndef _KERNEL
-#include <sys/types.h>
-#endif
-#include <sys/ioccom.h>
-
-/*
- * Disk description table, see disktab(5)
- */
-#define _PATH_DISKTAB "/etc/disktab"
-#define DISKTAB "/etc/disktab" /* deprecated */
-
-/*
- * Each disk has a label which includes information about the hardware
- * disk geometry, filesystem partitions, and drive specific information.
- * The label is in block 0 or 1, possibly offset from the beginning
- * to leave room for a bootstrap, etc.
- */
-
-/* XXX these should be defined per controller (or drive) elsewhere, not here! */
-#ifdef __i386__
-#define LABELSECTOR 1 /* sector containing label */
-#define LABELOFFSET 0 /* offset of label in sector */
-#endif
-
-#ifdef __alpha__
-#define LABELSECTOR 0
-#define LABELOFFSET 64
-#endif
-
-#ifndef LABELSECTOR
-#define LABELSECTOR 0 /* sector containing label */
-#endif
-
-#ifndef LABELOFFSET
-#define LABELOFFSET 64 /* offset of label in sector */
-#endif
-
-#define DISKMAGIC ((u_int32_t)0x82564557) /* The disk magic number */
-#ifndef MAXPARTITIONS
-#define MAXPARTITIONS 8
-#endif
-
-#define LABEL_PART 2 /* partition containing label */
-#define RAW_PART 2 /* partition containing whole disk */
-#define SWAP_PART 1 /* partition normally containing swap */
-
-#ifndef LOCORE
-struct disklabel {
- u_int32_t d_magic; /* the magic number */
- u_int16_t d_type; /* drive type */
- u_int16_t d_subtype; /* controller/d_type specific */
- char d_typename[16]; /* type name, e.g. "eagle" */
-
- /*
- * d_packname contains the pack identifier and is returned when
- * the disklabel is read off the disk or in-core copy.
- * d_boot0 and d_boot1 are the (optional) names of the
- * primary (block 0) and secondary (block 1-15) bootstraps
- * as found in /boot. These are returned when using
- * getdiskbyname(3) to retrieve the values from /etc/disktab.
- */
- union {
- char un_d_packname[16]; /* pack identifier */
- struct {
- char *un_d_boot0; /* primary bootstrap name */
- char *un_d_boot1; /* secondary bootstrap name */
- } un_b;
- } d_un;
-#define d_packname d_un.un_d_packname
-#define d_boot0 d_un.un_b.un_d_boot0
-#define d_boot1 d_un.un_b.un_d_boot1
-
- /* disk geometry: */
- u_int32_t d_secsize; /* # of bytes per sector */
- u_int32_t d_nsectors; /* # of data sectors per track */
- u_int32_t d_ntracks; /* # of tracks per cylinder */
- u_int32_t d_ncylinders; /* # of data cylinders per unit */
- u_int32_t d_secpercyl; /* # of data sectors per cylinder */
- u_int32_t d_secperunit; /* # of data sectors per unit */
-
- /*
- * Spares (bad sector replacements) below are not counted in
- * d_nsectors or d_secpercyl. Spare sectors are assumed to
- * be physical sectors which occupy space at the end of each
- * track and/or cylinder.
- */
- u_int16_t d_sparespertrack; /* # of spare sectors per track */
- u_int16_t d_sparespercyl; /* # of spare sectors per cylinder */
- /*
- * Alternate cylinders include maintenance, replacement, configuration
- * description areas, etc.
- */
- u_int32_t d_acylinders; /* # of alt. cylinders per unit */
-
- /* hardware characteristics: */
- /*
- * d_interleave, d_trackskew and d_cylskew describe perturbations
- * in the media format used to compensate for a slow controller.
- * Interleave is physical sector interleave, set up by the
- * formatter or controller when formatting. When interleaving is
- * in use, logically adjacent sectors are not physically
- * contiguous, but instead are separated by some number of
- * sectors. It is specified as the ratio of physical sectors
- * traversed per logical sector. Thus an interleave of 1:1
- * implies contiguous layout, while 2:1 implies that logical
- * sector 0 is separated by one sector from logical sector 1.
- * d_trackskew is the offset of sector 0 on track N relative to
- * sector 0 on track N-1 on the same cylinder. Finally, d_cylskew
- * is the offset of sector 0 on cylinder N relative to sector 0
- * on cylinder N-1.
- */
- u_int16_t d_rpm; /* rotational speed */
- u_int16_t d_interleave; /* hardware sector interleave */
- u_int16_t d_trackskew; /* sector 0 skew, per track */
- u_int16_t d_cylskew; /* sector 0 skew, per cylinder */
- u_int32_t d_headswitch; /* head switch time, usec */
- u_int32_t d_trkseek; /* track-to-track seek, usec */
- u_int32_t d_flags; /* generic flags */
-#define NDDATA 5
- u_int32_t d_drivedata[NDDATA]; /* drive-type specific information */
-#define NSPARE 5
- u_int32_t d_spare[NSPARE]; /* reserved for future use */
- u_int32_t d_magic2; /* the magic number (again) */
- u_int16_t d_checksum; /* xor of data incl. partitions */
-
- /* filesystem and partition information: */
- u_int16_t d_npartitions; /* number of partitions in following */
- u_int32_t d_bbsize; /* size of boot area at sn0, bytes */
- u_int32_t d_sbsize; /* max size of fs superblock, bytes */
- struct partition { /* the partition table */
- u_int32_t p_size; /* number of sectors in partition */
- u_int32_t p_offset; /* starting sector */
- u_int32_t p_fsize; /* filesystem basic fragment size */
- u_int8_t p_fstype; /* filesystem type, see below */
- u_int8_t p_frag; /* filesystem fragments per block */
- union {
- u_int16_t cpg; /* UFS: FS cylinders per group */
- u_int16_t sgs; /* LFS: FS segment shift */
- } __partition_u1;
-#define p_cpg __partition_u1.cpg
-#define p_sgs __partition_u1.sgs
- } d_partitions[MAXPARTITIONS]; /* actually may be more */
-};
-#else /* LOCORE */
- /*
- * offsets for asm boot files.
- */
- .set d_secsize,40
- .set d_nsectors,44
- .set d_ntracks,48
- .set d_ncylinders,52
- .set d_secpercyl,56
- .set d_secperunit,60
- .set d_end_,276 /* size of disk label */
-#endif /* LOCORE */
-
-/* d_type values: */
-#define DTYPE_SMD 1 /* SMD, XSMD; VAX hp/up */
-#define DTYPE_MSCP 2 /* MSCP */
-#define DTYPE_DEC 3 /* other DEC (rk, rl) */
-#define DTYPE_SCSI 4 /* SCSI */
-#define DTYPE_ESDI 5 /* ESDI interface */
-#define DTYPE_ST506 6 /* ST506 etc. */
-#define DTYPE_HPIB 7 /* CS/80 on HP-IB */
-#define DTYPE_HPFL 8 /* HP Fiber-link */
-#define DTYPE_FLOPPY 10 /* floppy */
-#define DTYPE_CCD 11 /* concatenated disk */
-#define DTYPE_VINUM 12 /* vinum volume */
-#define DTYPE_DOC2K 13 /* Msys DiskOnChip */
-
-#if defined(PC98) && !defined(PC98_ATCOMPAT)
-#define DSTYPE_SEC256 0x80 /* physical sector size=256 */
-#endif
-
-#ifdef DKTYPENAMES
-static char *dktypenames[] = {
- "unknown",
- "SMD",
- "MSCP",
- "old DEC",
- "SCSI",
- "ESDI",
- "ST506",
- "HP-IB",
- "HP-FL",
- "type 9",
- "floppy",
- "CCD",
- "Vinum",
- "DOC2K",
- NULL
-};
-#define DKMAXTYPES (sizeof(dktypenames) / sizeof(dktypenames[0]) - 1)
-#endif
-
-/*
- * Filesystem type and version.
- * Used to interpret other filesystem-specific
- * per-partition information.
- */
-#define FS_UNUSED 0 /* unused */
-#define FS_SWAP 1 /* swap */
-#define FS_V6 2 /* Sixth Edition */
-#define FS_V7 3 /* Seventh Edition */
-#define FS_SYSV 4 /* System V */
-#define FS_V71K 5 /* V7 with 1K blocks (4.1, 2.9) */
-#define FS_V8 6 /* Eighth Edition, 4K blocks */
-#define FS_BSDFFS 7 /* 4.2BSD fast file system */
-#define FS_MSDOS 8 /* MSDOS file system */
-#define FS_BSDLFS 9 /* 4.4BSD log-structured file system */
-#define FS_OTHER 10 /* in use, but unknown/unsupported */
-#define FS_HPFS 11 /* OS/2 high-performance file system */
-#define FS_ISO9660 12 /* ISO 9660, normally CD-ROM */
-#define FS_BOOT 13 /* partition contains bootstrap */
-#define FS_VINUM 14 /* Vinum drive */
-
-#ifdef DKTYPENAMES
-static char *fstypenames[] = {
- "unused",
- "swap",
- "Version 6",
- "Version 7",
- "System V",
- "4.1BSD",
- "Eighth Edition",
- "4.2BSD",
- "MSDOS",
- "4.4LFS",
- "unknown",
- "HPFS",
- "ISO9660",
- "boot",
- "vinum",
- NULL
-};
-#define FSMAXTYPES (sizeof(fstypenames) / sizeof(fstypenames[0]) - 1)
-#endif
-
-/*
- * flags shared by various drives:
- */
-#define D_REMOVABLE 0x01 /* removable media */
-#define D_ECC 0x02 /* supports ECC */
-#define D_BADSECT 0x04 /* supports bad sector forw. */
-#define D_RAMDISK 0x08 /* disk emulator */
-#define D_CHAIN 0x10 /* can do back-back transfers */
-
-/*
- * Drive data for SMD.
- */
-#define d_smdflags d_drivedata[0]
-#define D_SSE 0x1 /* supports skip sectoring */
-#define d_mindist d_drivedata[1]
-#define d_maxdist d_drivedata[2]
-#define d_sdist d_drivedata[3]
-
-/*
- * Drive data for ST506.
- */
-#define d_precompcyl d_drivedata[0]
-#define d_gap3 d_drivedata[1] /* used only when formatting */
-
-/*
- * Drive data for SCSI.
- */
-#define d_blind d_drivedata[0]
-
-#ifndef LOCORE
-/*
- * Structure used to perform a format or other raw operation, returning
- * data and/or register values. Register identification and format
- * are device- and driver-dependent.
- */
-struct format_op {
- char *df_buf;
- int df_count; /* value-result */
- daddr_t df_startblk;
- int df_reg[8]; /* result */
-};
-
-/*
- * Structure used internally to retrieve information about a partition
- * on a disk.
- */
-struct partinfo {
- struct disklabel *disklab;
- struct partition *part;
-};
-
-/* DOS partition table -- located in boot block */
-
-#if defined(PC98) && !defined(PC98_ATCOMPAT)
-#define DOSBBSECTOR 0 /* DOS boot block relative sector number */
-#define DOSLABELSECTOR 1 /* 0: 256b/s, 1: 512b/s */
-#define DOSPARTOFF 0
-#define NDOSPART 16
-#define DOSPTYP_386BSD 0x94 /* 386BSD partition type */
-#define MBR_PTYPE_FreeBSD 0x94 /* FreeBSD partition type */
-
-struct dos_partition {
- unsigned char dp_mid;
-#define DOSMID_386BSD (0x14|0x80) /* 386bsd|bootable */
- unsigned char dp_sid;
-#define DOSSID_386BSD (0x44|0x80) /* 386bsd|active */
- unsigned char dp_dum1;
- unsigned char dp_dum2;
- unsigned char dp_ipl_sct;
- unsigned char dp_ipl_head;
- unsigned short dp_ipl_cyl;
- unsigned char dp_ssect; /* starting sector */
- unsigned char dp_shd; /* starting head */
- unsigned short dp_scyl; /* starting cylinder */
- unsigned char dp_esect; /* end sector */
- unsigned char dp_ehd; /* end head */
- unsigned short dp_ecyl; /* end cylinder */
- unsigned char dp_name[16];
-};
-
-#else /* IBMPC */
-#define DOSBBSECTOR 0 /* DOS boot block relative sector number */
-#define DOSPARTOFF 446
-#define NDOSPART 4
-#define DOSPTYP_386BSD 0xa5 /* 386BSD partition type */
-
-struct dos_partition {
- unsigned char dp_flag; /* bootstrap flags */
- unsigned char dp_shd; /* starting head */
- unsigned char dp_ssect; /* starting sector */
- unsigned char dp_scyl; /* starting cylinder */
- unsigned char dp_typ; /* partition type */
- unsigned char dp_ehd; /* end head */
- unsigned char dp_esect; /* end sector */
- unsigned char dp_ecyl; /* end cylinder */
- u_int32_t dp_start; /* absolute starting sector number */
- u_int32_t dp_size; /* partition size in sectors */
-};
-#endif
-
-#define DPSECT(s) ((s) & 0x3f) /* isolate relevant bits of sector */
-#define DPCYL(c, s) ((c) + (((s) & 0xc0)<<2)) /* and those that are cylinder */
-
-/*
- * Disk-specific ioctls.
- */
- /* get and set disklabel; DIOCGPART used internally */
-#define DIOCGDINFO _IOR('d', 101, struct disklabel)/* get */
-#define DIOCSDINFO _IOW('d', 102, struct disklabel)/* set */
-#define DIOCWDINFO _IOW('d', 103, struct disklabel)/* set, update disk */
-#define DIOCGPART _IOW('d', 104, struct partinfo) /* get partition */
-
-#define DIOCWLABEL _IOW('d', 109, int) /* write en/disable label */
-
-#ifdef _KERNEL
-
-/*
- * XXX encoding of disk minor numbers, should be elsewhere.
- *
- * See <sys/reboot.h> for a possibly better encoding.
- *
- * "cpio -H newc" can be used to back up device files with large minor
- * numbers (but not ones >= 2^31). Old cpio formats and all tar formats
- * don't have enough bits, and cpio and tar don't notice the lossage.
- * There are also some sign extension bugs.
- */
-
-/*
- 3 2 1 0
- 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
- _________________________________________________________________
- | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
- -----------------------------------------------------------------
- | TYPE |UNIT_2 | SLICE | MAJOR? | UNIT |PART |
- -----------------------------------------------------------------
-*/
-#define dkmakeminor(unit, slice, part) \
- (((slice) << 16) | (((unit) & 0x1e0) << 16) | \
- (((unit) & 0x1f) << 3) | (part))
-static __inline dev_t
-dkmodpart(dev_t dev, int part)
-{
- return (makedev(major(dev), (minor(dev) & ~7) | part));
-}
-
-static __inline dev_t
-dkmodslice(dev_t dev, int slice)
-{
- return (makedev(major(dev), (minor(dev) & ~0x1f0000) | (slice << 16)));
-}
-
-#define dkpart(dev) (minor(dev) & 7)
-#define dkslice(dev) ((minor(dev) >> 16) & 0x1f)
-#define dktype(dev) ((minor(dev) >> 25) & 0x7f)
-
-static __inline u_int
-dkunit(dev_t dev)
-{
- return (((minor(dev) >> 16) & 0x1e0) | ((minor(dev) >> 3) & 0x1f));
-}
-
-struct buf;
-struct buf_queue_head;
-
-int bounds_check_with_label __P((struct buf *bp, struct disklabel *lp,
- int wlabel));
-void diskerr __P((struct buf *bp, char *what, int pri, int blkdone,
- struct disklabel *lp));
-void disksort __P((struct buf *ap, struct buf *bp));
-u_int dkcksum __P((struct disklabel *lp));
-char *readdisklabel __P((dev_t dev, struct disklabel *lp));
-void bufqdisksort __P((struct buf_queue_head *ap, struct buf *bp));
-int setdisklabel __P((struct disklabel *olp, struct disklabel *nlp,
- u_long openmask));
-int writedisklabel __P((dev_t dev, struct disklabel *lp));
-#ifdef __alpha__
-void alpha_fix_srm_checksum __P((struct buf *bp));
-#endif
-
-#endif /* _KERNEL */
-
-#endif /* LOCORE */
-
-#ifndef _KERNEL
-__BEGIN_DECLS
-struct disklabel *getdiskbyname __P((const char *));
-__END_DECLS
-#endif
-
-#endif /* !_SYS_DISKLABEL_H_ */
-.Ed
-.Sh SEE ALSO
-.Xr disktab 5 ,
-.Xr disklabel 8
diff --git a/sbin/bsdlabel/bsdlabel.8 b/sbin/bsdlabel/bsdlabel.8
deleted file mode 100644
index 4649a2e65b0d..000000000000
--- a/sbin/bsdlabel/bsdlabel.8
+++ /dev/null
@@ -1,577 +0,0 @@
-.\" Copyright (c) 1987, 1988, 1991, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" This code is derived from software contributed to Berkeley by
-.\" Symmetric Computer Systems.
-.\"
-.\" 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 University of
-.\" California, Berkeley and its contributors.
-.\" 4. 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.
-.\"
-.\" @(#)disklabel.8 8.2 (Berkeley) 4/19/94
-.\" $FreeBSD$
-.\"
-.Dd July 30, 1999
-.Dt DISKLABEL 8
-.Os FreeBSD
-.Sh NAME
-.Nm disklabel
-.Nd read and write disk pack label
-.Sh SYNOPSIS
-.Nm disklabel
-.Op Fl r
-.Ar disk
-.Nm disklabel
-.Fl w
-.Op Fl r
-.Ar disk Ar disktype
-.Oo Ar packid Oc
-.Nm disklabel
-.Fl e
-.Op Fl r
-.Ar disk
-.Nm disklabel
-.Fl R
-.Op Fl r
-.Ar disk Ar protofile
-.Nm disklabel
-.Op Fl NW
-.Ar disk
-.sp
-.Nm disklabel
-.Fl B
-.Oo
-.Fl b Ar boot1
-.Fl s Ar boot2
-.Oc
-.Ar disk
-.Oo Ar disktype Oc
-.Nm disklabel
-.Fl w
-.Fl B
-.Oo
-.Fl b Ar boot1
-.Fl s Ar boot2
-.Oc
-.Ar disk Ar disktype
-.Oo Ar packid Oc
-.Nm disklabel
-.Fl R
-.Fl B
-.Oo
-.Fl b Ar boot1
-.Fl s Ar boot2
-.Oc
-.Ar disk Ar protofile
-.Oo Ar disktype Oc
-.Sh DESCRIPTION
-.Nm Disklabel
-installs, examines or modifes the label on a disk drive or pack. When writing
-the label, it can be used to change the drive identification, the disk
-partitions on the drive, or to replace a damaged label. There are several forms
-of the command that read (display), install or edit the label on a disk. In
-addition,
-.Nm
-can install bootstrap code.
-.Ss Raw or in-core label
-.Pp
-The disk label is resident close to or at the beginning of each disk partition.
-For faster access, the kernel maintains a copy in core at all times. By
-default, most
-.Nm
-access the in-core copy of the label. To access the raw (on-disk) copy, use the
-.Fl r
-option. This option allows a label to be installed on a disk without kernel
-support for a label, such as when labels are first installed on a system; it
-must be used when first installing a label on a disk. The specific effect of
-.Fl r
-is described under each command.
-.Pp
-.Ss Disk device name
-.Pp
-All
-.Nm disklabel
-forms require a disk device name, which should always be the raw
-.if t ``complete'' (or ``c'')
-.if n "complete" (or "c")
-partition, for example
-.Pa /dev/rda0c .
-.Nm
-understands the abbreviation
-.Pa da0 ,
-which it converts internally to
-.Pa /dev/rda0c .
-.Ss Reading the disk label
-.Pp
-To examine or save the label on a disk drive, use
-.Nm
-without options:
-.Pp
-.Nm disklabel
-.Op Fl r
-.Ar disk
-.Pp
-.Ar disk
-represents the raw disk in question, and may be in the form
-.Pa da0
-or
-.Pa /dev/rda0c .
-It will display all of the parameters associated with the drive and its
-partition layout. Unless the
-.Fl r
-flag is given,
-the kernel's in-core copy of the label is displayed;
-if the disk has no label, or the partition types on the disk are incorrect,
-the kernel may have constructed or modified the label.
-If the
-.Fl r
-flag is given,
-.Nm
-reads the label from the raw disk and displays it.
-.Ss Writing a standard label
-.Pp
-To write a standard label, use the form
-.Pp
-.Nm disklabel
-.Fl w
-.Op Fl r
-.Ar disk Ar disktype
-.Oo Ar packid Oc
-.Pp
-The required arguments to
-.Nm
-are the drive to be labeled and the drive type as described in the
-.Pa disktab(5)
-file. The drive parameters and partitions are taken from that file. If
-different disks of the same physical type are to have different partitions, it
-will be necessary to have separate disktab entries describing each, or to edit
-the label after installation as described below. The optional argument is a
-pack identification string, up to 16 characters long. The pack id must be
-quoted if it contains blanks. If the
-.Fl r
-flag is given, the disk sectors containing the label and bootstrap
-will be written directly.
-A side-effect of this is that any existing bootstrap code will be overwritten
-and the disk rendered unbootable. See the boot options below for a method of
-writing the label and the bootstrap at the same time.
-If
-.Fl r
-is not specified,
-the existing label will be updated via the in-core copy and any bootstrap
-code will be unaffected.
-If the disk does not already have a label, the
-.Fl r
-flag must be used.
-In either case, the kernel's in-core label is replaced.
-.Pp
-For a virgin disk that is not known to
-.Xr disktab 5 ,
-.Ar disktype
-can be specified as
-.Dq auto .
-In this case, the driver is requested to produce a virgin label for the
-disk. This might or might not be successful, depending on whether the
-driver for the disk is able to get the required data without reading
-anything from the disk at all. It will likely succeed for all SCSI
-disks, most IDE disks, and vnode devices. Writing a label to the
-disk is the only supported operation, and the
-.Ar disk
-itself must be provided as the canonical name, i.e. not as a full
-path name.
-.Ss Editing an existing disk label
-.Pp
-To edit an existing disk label, use the form
-.Pp
-.Nm disklabel
-.Fl e
-.Op Fl r
-.Ar disk
-.Pp
-This command reads the label from the in-core kernel copy, or directly from the
-disk if the
-.Fl r
-flag is also specified. The label is written to a file in ASCII and then
-supplied to an editor for changes. If no editor is specified in an
-.Ev EDITOR
-environment variable,
-.Xr vi 1
-is used. When the editor terminates, the label file is used to rewrite the disk
-label. Existing bootstrap code is unchanged regardless of whether
-.Fl r
-was specified.
-.Ss Restoring a disk label from a file
-.Pp
-To restore a disk label from a file, use the form
-.Pp
-.Nm disklabel
-.Fl R
-.Op Fl r
-.Ar disk Ar protofile
-.Pp
-.Nm
-is capable of restoring a disk label that was previously saved in a file ASCII.
-The prototype file used to create the label should be in the same format as that
-produced when reading or editing a label. Comments are delimited by
-.Ar \&#
-and newline. As when writing a new label, any existing bootstrap code will be
-clobbered if
-.Fl r
-is specified and will be unaffected otherwise. See the boot options below for a
-method of restoring the label and writing the bootstrap at the same time.
-.Ss Enabling and disabling writing to the disk label area
-.Pp
-By default, it is not possible to write to the disk label area at the beginning
-of a disk. The disk driver silently ignores any attempt to do so. If you need
-to write to this area (for example, to obliterate the label), use the form
-.Pp
-.Nm disklabel
-.Op Fl W
-.Ar disk
-.Pp
-To disallow writing to the label area after previously allowing it, use the
-command
-.Pp
-.Nm disklabel
-.Op Fl N
-.Ar disk
-.Ss Installing bootstraps
-.Pp
-The final three forms of
-.Nm
-are used to install bootstrap code:
-.Pp
-.Nm disklabel
-.Fl B
-.Oo
-.Fl b Ar boot1
-.Fl s Ar boot2
-.Oc
-.Ar disk
-.Oo Ar disktype Oc
-.Pp
-This form installs the bootstrap only. It does not change the disk label.
-.Pp
-.Nm disklabel
-.Fl w
-.Fl B
-.Oo
-.Fl b Ar boot1
-.Fl s Ar boot2
-.Oc
-.Ar disk Ar disktype
-.Oo Ar packid Oc
-.Pp
-.if t This form corresponds to the ``write label'' command described above.
-.if n This form corresponds to the "write label" command described above.
-In addition to writing a new volume label, it also installs the bootstrap.
-.Pp
-.Nm disklabel
-.Fl R
-.Fl B
-.Oo
-.Fl b Ar boot1
-.Fl s Ar boot2
-.Oc
-.Ar disk Ar protofile
-.Oo Ar disktype Oc
-.Pp
-.if t This form corresponds to the ``restore label'' command described above.
-.if n This form corresponds to the "restore label" command described above.
-In addition to restoring the volume label, it also installs the bootstrap.
-.Pp
-The bootstrap commands always access the disk directly, so it is not necessary
-to specify the
-.Fl r
-flag.
-.Pp
-The bootstrap code is comprised of two boot programs. Specify the name of the
-boot programs to be installed in one of these ways:
-.Bl -enum
-.It
-Specify the names explicitly with the
-.Fl b
-and
-.Fl s
-flags.
-.Fl b
-indicates the primary boot program and
-.Fl s
-the secondary boot program. The boot programs are located in
-.Pa /boot .
-.It
-If the
-.Fl b
-and
-.Fl s
-flags are not specified, but
-.Ar disktype
-was specified, the names of the programs are taken from the
-.if t ``b0'' and ``b1''
-.if n "b0" and "b1"
-parameters of the
-.Xr disktab 5
-entry for the disk if the disktab entry exists and includes those parameters.
-.It
-Otherwise, the default boot image names are used:
-.Pa /boot/boot1
-and
-.Pa /boot/boot2
-for the standard stage1 and stage2 boot images (details may vary
-on architectures like the Alpha, where only a single-stage boot is used).
-.El
-.Sh FILES
-.Bl -tag -width Pa -compact
-.It Pa /etc/disktab
-.It Pa /boot/
-.It Pa /boot/boot<n>
-.El
-.Sh SAVED FILE FORMAT
-.Nm
-uses an ASCII version of the label when examining, editing or restoring a disk
-label. The format is:
-.Bd -literal -offset 4n
-# /dev/rda1c:
-type: SCSI
-disk: sd0s1
-label:
-flags:
-bytes/sector: 512
-sectors/track: 51
-tracks/cylinder: 19
-sectors/cylinder: 969
-cylinders: 1211
-sectors/unit: 1173930
-rpm: 3600
-interleave: 1
-trackskew: 0
-cylinderskew: 0
-headswitch: 0 # milliseconds
-track-to-track seek: 0 # milliseconds
-drivedata: 0
-
-8 partitions:
-# size offset fstype [fsize bsize bps/cpg]
- a: 81920 0 4.2BSD 1024 8192 16 # (Cyl. 0 - 84*)
- b: 160000 81920 swap # (Cyl. 84* - 218*)
- c: 1173930 0 unused 0 0 # (Cyl. 0 - 1211*)
- h: 962010 211920 vinum # (Cyl. 218*- 1211*)
-.Ed
-.Pp
-Lines starting with a # mark are comments. Most of the other specifications are
-no longer used. The ones which must still be set correctly are:
-.Pp
-.Bl -hang -width 20n
-.It Nm label
-is an optional label, set by the
-.Ar packid
-option when writing a label.
-.It Nm flags
-Flags may be
-.Ar removable ,
-.Ar ecc
-or
-.Ar badsect .
-.Ar removable
-is set for removable media drives, but no current FreeBSD driver evaluates this
-flag.
-.Ar ecc
-is no longer supported;
-.Ar badsect
-specifies that the drive can perform bad sector remapping.
-.It Nm sectors/unit
-describes the total size of the disk. This value must be correct.
-.It Nm the partition table
-This is the UNIX partition table, not the Microsoft partition table described in
-.Xr fdisk 8 .
-.El
-.Pp
-The partition table can have up to 8 entries. It contains the following
-information:
-.Bl -hang -width 10n
-.It identifier
-The partition identifier is a single letter in the range
-.Nm a
-to
-.Nm h .
-By convention, partition
-.Nm c
-is reserved to describe the entire disk.
-.It size
-is the size of the partition in sectors.
-.It offset
-is the offset of the start of the partition from the beginning of the drive.
-.It fstype
-describes the purpose of the partition. The example shows most normal usages.
-For UFS file systems, use type 4.2BSD. See
-.Pa /usr/include/sys/disklabel.h
-for a complete list.
-.It fsize
-For file systems only, the fragment size.
-.It bsize
-For file systems only, the block size.
-.It bps/cpg
-For UFS file systems, the number of cylinders in a cylinder group. For LFS file
-systems, the segment shift value.
-.El
-The remainder of the line is a comment and shows the cylinder allocations based
-on the obsolete (but possibly correct) geometry information about the drive.
-The asterisk (*) indicates that the partition does not begin or end exactly on a
-cylinder boundary.
-.Sh EXAMPLES
-.Dl disklabel da0
-.Pp
-Display the in-core label for
-.Pa da0
-as obtained via
-.Pa /dev/rda0c .
-.Pp
-.Dl disklabel da0 > savedlabel
-.Pp
-Save the in-core label for
-.Pa da0
-into the file
-.Pa savedlabel .
-This file can be used with the
-.Fl R
-flag to restore the label at a later date.
-.Pp
-.Dl disklabel -w -r /dev/rda0c da2212 foo
-.Pp
-Create a label for
-.Pa da0
-based on information for
-.if t ``da2212'' found in
-.if n "da2212" found in
-.Pa /etc/disktab .
-Any existing bootstrap code will be clobbered.
-.Pp
-.Dl disklabel -e -r da0
-.Pp
-Read the on-disk label for
-.Pa da0 ,
-edit it and reinstall in-core as well as on-disk. Existing bootstrap code is
-unaffected.
-.Pp
-.Dl disklabel -r -w da0 auto
-.Pp
-Try to auto-detect the required information from
-.Pa da0 ,
-and write a new label to the disk. Use another disklabel -e command to edit the
-partitioning and file system information.
-.Pp
-.Dl disklabel -R da0 savedlabel
-.Pp
-Restore the on-disk and in-core label for
-.Pa da0
-from information in
-.Pa savedlabel .
-Existing bootstrap code is unaffected.
-.Pp
-.Dl disklabel -B da0
-.Pp
-Install a new bootstrap on
-.Pa da0 .
-The boot code comes from
-.Pa /boot/boot1
-and possibly
-.Pa /boot/boot2 .
-On-disk and in-core labels are unchanged.
-.Pp
-.Dl disklabel -w -B /dev/rda0c -b newboot1 -s newboot da2212
-.Pp
-Install a new label and bootstrap.
-.if t The label is derived from disktab information for ``da2212'' and
-.if n The label is derived from disktab information for "da2212" and
-installed both in-core and on-disk.
-The bootstrap code comes from the files
-.Pa /boot/newboot1
-and
-.Pa /boot/newboot2 .
-.Sh SEE ALSO
-.Xr disklabel 5 ,
-.Xr disktab 5 ,
-.Xr boot0cfg 8 ,
-.Xr fdisk 8
-.Sh DIAGNOSTICS
-The kernel device drivers will not allow the size of a disk partition
-to be decreased or the offset of a partition to be changed while it is open.
-Some device drivers create a label containing only a single large partition
-if a disk is unlabeled; thus, the label must be written to the
-.if t ``a''
-.if n "a"
-partition of the disk while it is open. This sometimes requires the desired
-label to be set in two steps, the first one creating at least one other
-partition, and the second setting the label on the new partition while shrinking
-the
-.if t ``a''
-.if n "a"
-partition.
-.Pp
-On some machines the bootstrap code may not fit entirely in the area
-allocated for it by some filesystems.
-As a result, it may not be possible to have filesystems on some partitions
-.if t of a ``bootable'' disk.
-.if n of a "bootable" disk.
-When installing bootstrap code,
-.Nm
-checks for these cases.
-If the installed boot code would overlap a partition of type FS_UNUSED
-it is marked as type FS_BOOT.
-The
-.Xr newfs 8
-utility will disallow creation of filesystems on FS_BOOT partitions.
-Conversely, if a partition has a type other than FS_UNUSED or FS_BOOT,
-.Nm
-will not install bootstrap code that overlaps it.
-.Sh BUGS
-When a disk name is given without a full pathname,
-.if t the constructed device name uses the ``c'' partition.
-.if n the constructed device name uses the "c" partition.
-.Pp
-For the i386 architecture, the primary bootstrap sector contains
-an embedded
-.Em fdisk
-table.
-.Nm Disklabel
-takes care to not clobber it when installing a bootstrap only
-.Pq Fl B ,
-or when editing an existing label
-.Pq Fl e ,
-but it unconditionally writes the primary bootstrap program onto
-the disk for
-.Fl w
-or
-.Fl R ,
-thus replacing the
-.Em fdisk
-table by the dummy one in the bootstrap program. This is only of
-concern if the disk is fully dedicated, so that the BSD disklabel
-starts at absolute block 0 on the disk.
-.Pp
-.Nm
-does not perform adequate error checking. No warning is given if partitions
-overlap, nor if space remains unused.
diff --git a/sbin/bsdlabel/bsdlabel.c b/sbin/bsdlabel/bsdlabel.c
deleted file mode 100644
index 3918ff921e1c..000000000000
--- a/sbin/bsdlabel/bsdlabel.c
+++ /dev/null
@@ -1,1462 +0,0 @@
-/*
- * Copyright (c) 1987, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Symmetric Computer Systems.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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 lint
-static const char copyright[] =
-"@(#) Copyright (c) 1987, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)disklabel.c 8.2 (Berkeley) 1/7/94";
-/* from static char sccsid[] = "@(#)disklabel.c 1.2 (Symmetric) 11/28/85"; */
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <sys/param.h>
-#include <sys/errno.h>
-#include <sys/file.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#define DKTYPENAMES
-#include <sys/disklabel.h>
-#include <ufs/ffs/fs.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <signal.h>
-#include <stdarg.h>
-#include <ctype.h>
-#include <err.h>
-#include "pathnames.h"
-
-/*
- * Disklabel: read and write disklabels.
- * The label is usually placed on one of the first sectors of the disk.
- * Many machines also place a bootstrap in the same area,
- * in which case the label is embedded in the bootstrap.
- * The bootstrap source must leave space at the proper offset
- * for the label on such machines.
- */
-
-#ifndef BBSIZE
-#define BBSIZE 8192 /* size of boot area, with label */
-#endif
-
-#ifdef tahoe
-#define NUMBOOT 0
-#else
-#if defined(__alpha__) || defined(hp300) || defined(hp800)
-#define NUMBOOT 1
-#else
-#define NUMBOOT 2
-#endif
-#endif
-
-void makelabel __P((char *, char *, struct disklabel *));
-int writelabel __P((int, char *, struct disklabel *));
-void l_perror __P((char *));
-struct disklabel * readlabel __P((int));
-struct disklabel * makebootarea __P((char *, struct disklabel *, int));
-void display __P((FILE *, struct disklabel *));
-int edit __P((struct disklabel *, int));
-int editit __P((void));
-char * skip __P((char *));
-char * word __P((char *));
-int getasciilabel __P((FILE *, struct disklabel *));
-int checklabel __P((struct disklabel *));
-void setbootflag __P((struct disklabel *));
-void Warning (char *, ...);
-void usage __P((void));
-extern u_short dkcksum __P((struct disklabel *));
-struct disklabel * getvirginlabel __P((void));
-
-#define DEFEDITOR _PATH_VI
-#define streq(a,b) (strcmp(a,b) == 0)
-
-char *dkname;
-char *specname;
-char tmpfil[] = PATH_TMPFILE;
-
-char namebuf[BBSIZE], *np = namebuf;
-struct disklabel lab;
-char bootarea[BBSIZE];
-
-#if NUMBOOT > 0
-int installboot; /* non-zero if we should install a boot program */
-char *bootbuf; /* pointer to buffer with remainder of boot prog */
-int bootsize; /* size of remaining boot program */
-char *xxboot; /* primary boot */
-char *bootxx; /* secondary boot */
-char boot0[MAXPATHLEN];
-char boot1[MAXPATHLEN];
-#endif
-
-enum {
- UNSPEC, EDIT, NOWRITE, READ, RESTORE, WRITE, WRITEABLE, WRITEBOOT
-} op = UNSPEC;
-
-int rflag;
-
-#ifdef DEBUG
-int debug;
-#define OPTIONS "BNRWb:ders:w"
-#else
-#define OPTIONS "BNRWb:ers:w"
-#endif
-
-int
-main(argc, argv)
- int argc;
- char *argv[];
-{
- register struct disklabel *lp;
- FILE *t;
- int ch, f = 0, flag, error = 0;
- char *name = 0;
-
- while ((ch = getopt(argc, argv, OPTIONS)) != -1)
- switch (ch) {
-#if NUMBOOT > 0
- case 'B':
- ++installboot;
- break;
- case 'b':
- xxboot = optarg;
- break;
-#if NUMBOOT > 1
- case 's':
- bootxx = optarg;
- break;
-#endif
-#endif
- case 'N':
- if (op != UNSPEC)
- usage();
- op = NOWRITE;
- break;
- case 'R':
- if (op != UNSPEC)
- usage();
- op = RESTORE;
- break;
- case 'W':
- if (op != UNSPEC)
- usage();
- op = WRITEABLE;
- break;
- case 'e':
- if (op != UNSPEC)
- usage();
- op = EDIT;
- break;
- case 'r':
- ++rflag;
- break;
- case 'w':
- if (op != UNSPEC)
- usage();
- op = WRITE;
- break;
-#ifdef DEBUG
- case 'd':
- debug++;
- break;
-#endif
- case '?':
- default:
- usage();
- }
- argc -= optind;
- argv += optind;
-#if NUMBOOT > 0
- if (installboot) {
- rflag++;
- if (op == UNSPEC)
- op = WRITEBOOT;
- } else {
- if (op == UNSPEC)
- op = READ;
- xxboot = bootxx = 0;
- }
-#else
- if (op == UNSPEC)
- op = READ;
-#endif
- if (argc < 1)
- usage();
-
- dkname = argv[0];
- if (dkname[0] != '/') {
- (void)sprintf(np, "%sr%s%c", _PATH_DEV, dkname, 'a' + RAW_PART);
- specname = np;
- np += strlen(specname) + 1;
- } else
- specname = dkname;
- f = open(specname, op == READ ? O_RDONLY : O_RDWR);
- if (f < 0 && errno == ENOENT && dkname[0] != '/') {
- (void)sprintf(specname, "%sr%s", _PATH_DEV, dkname);
- np = namebuf + strlen(specname) + 1;
- f = open(specname, op == READ ? O_RDONLY : O_RDWR);
- }
- if (f < 0)
- err(4, "%s", specname);
-
- switch(op) {
-
- case UNSPEC:
- break;
-
- case EDIT:
- if (argc != 1)
- usage();
- lp = readlabel(f);
- error = edit(lp, f);
- break;
-
- case NOWRITE:
- flag = 0;
- if (ioctl(f, DIOCWLABEL, (char *)&flag) < 0)
- err(4, "ioctl DIOCWLABEL");
- break;
-
- case READ:
- if (argc != 1)
- usage();
- lp = readlabel(f);
- display(stdout, lp);
- error = checklabel(lp);
- break;
-
- case RESTORE:
-#if NUMBOOT > 0
- if (installboot && argc == 3) {
- makelabel(argv[2], 0, &lab);
- argc--;
-
- /*
- * We only called makelabel() for its side effect
- * of setting the bootstrap file names. Discard
- * all changes to `lab' so that all values in the
- * final label come from the ASCII label.
- */
- bzero((char *)&lab, sizeof(lab));
- }
-#endif
- if (argc != 2)
- usage();
- if (!(t = fopen(argv[1], "r")))
- err(4, "%s", argv[1]);
- if (!getasciilabel(t, &lab))
- exit(1);
- lp = makebootarea(bootarea, &lab, f);
- *lp = lab;
- error = writelabel(f, bootarea, lp);
- break;
-
- case WRITE:
- if (argc == 3) {
- name = argv[2];
- argc--;
- }
- if (argc != 2)
- usage();
- makelabel(argv[1], name, &lab);
- lp = makebootarea(bootarea, &lab, f);
- *lp = lab;
- if (checklabel(lp) == 0)
- error = writelabel(f, bootarea, lp);
- break;
-
- case WRITEABLE:
- flag = 1;
- if (ioctl(f, DIOCWLABEL, (char *)&flag) < 0)
- err(4, "ioctl DIOCWLABEL");
- break;
-
-#if NUMBOOT > 0
- case WRITEBOOT:
- {
- struct disklabel tlab;
-
- lp = readlabel(f);
- tlab = *lp;
- if (argc == 2)
- makelabel(argv[1], 0, &lab);
- lp = makebootarea(bootarea, &lab, f);
- *lp = tlab;
- if (checklabel(lp) == 0)
- error = writelabel(f, bootarea, lp);
- break;
- }
-#endif
- }
- exit(error);
-}
-
-/*
- * Construct a prototype disklabel from /etc/disktab. As a side
- * effect, set the names of the primary and secondary boot files
- * if specified.
- */
-void
-makelabel(type, name, lp)
- char *type, *name;
- register struct disklabel *lp;
-{
- register struct disklabel *dp;
-
- if (strcmp(type, "auto") == 0)
- dp = getvirginlabel();
- else
- dp = getdiskbyname(type);
- if (dp == NULL)
- errx(1, "%s: unknown disk type", type);
- *lp = *dp;
-#if NUMBOOT > 0
- /*
- * Set bootstrap name(s).
- * 1. If set from command line, use those,
- * 2. otherwise, check if disktab specifies them (b0 or b1),
- * 3. otherwise, makebootarea() will choose ones based on the name
- * of the disk special file. E.g. /dev/ra0 -> raboot, bootra
- */
- if (!xxboot && lp->d_boot0) {
- if (*lp->d_boot0 != '/')
- (void)sprintf(boot0, "%s/%s",
- _PATH_BOOTDIR, lp->d_boot0);
- else
- (void)strcpy(boot0, lp->d_boot0);
- xxboot = boot0;
- }
-#if NUMBOOT > 1
- if (!bootxx && lp->d_boot1) {
- if (*lp->d_boot1 != '/')
- (void)sprintf(boot1, "%s/%s",
- _PATH_BOOTDIR, lp->d_boot1);
- else
- (void)strcpy(boot1, lp->d_boot1);
- bootxx = boot1;
- }
-#endif
-#endif
- /* d_packname is union d_boot[01], so zero */
- bzero(lp->d_packname, sizeof(lp->d_packname));
- if (name)
- (void)strncpy(lp->d_packname, name, sizeof(lp->d_packname));
-}
-
-int
-writelabel(f, boot, lp)
- int f;
- char *boot;
- register struct disklabel *lp;
-{
- int flag;
-#ifdef __alpha__
- u_long *p, sum;
- int i;
-#endif
-#ifdef vax
- register int i;
-#endif
-
- setbootflag(lp);
- lp->d_magic = DISKMAGIC;
- lp->d_magic2 = DISKMAGIC;
- lp->d_checksum = 0;
- lp->d_checksum = dkcksum(lp);
- if (rflag) {
- /*
- * First set the kernel disk label,
- * then write a label to the raw disk.
- * If the SDINFO ioctl fails because it is unimplemented,
- * keep going; otherwise, the kernel consistency checks
- * may prevent us from changing the current (in-core)
- * label.
- */
- if (ioctl(f, DIOCSDINFO, lp) < 0 &&
- errno != ENODEV && errno != ENOTTY) {
- l_perror("ioctl DIOCSDINFO");
- return (1);
- }
- (void)lseek(f, (off_t)0, SEEK_SET);
-
-#ifdef __alpha__
- /*
- * Generate the bootblock checksum for the SRM console.
- */
- for (p = (u_long *)boot, i = 0, sum = 0; i < 63; i++)
- sum += p[i];
- p[63] = sum;
-#endif
-
- /*
- * write enable label sector before write (if necessary),
- * disable after writing.
- */
- flag = 1;
- if (ioctl(f, DIOCWLABEL, &flag) < 0)
- warn("ioctl DIOCWLABEL");
- if (write(f, boot, lp->d_bbsize) != lp->d_bbsize) {
- warn("write");
- return (1);
- }
-#if NUMBOOT > 0
- /*
- * Output the remainder of the disklabel
- */
- if (bootbuf && write(f, bootbuf, bootsize) != bootsize) {
- warn("write");
- return(1);
- }
-#endif
- flag = 0;
- (void) ioctl(f, DIOCWLABEL, &flag);
- } else if (ioctl(f, DIOCWDINFO, lp) < 0) {
- l_perror("ioctl DIOCWDINFO");
- return (1);
- }
-#ifdef vax
- if (lp->d_type == DTYPE_SMD && lp->d_flags & D_BADSECT) {
- daddr_t alt;
-
- alt = lp->d_ncylinders * lp->d_secpercyl - lp->d_nsectors;
- for (i = 1; i < 11 && i < lp->d_nsectors; i += 2) {
- (void)lseek(f, (off_t)((alt + i) * lp->d_secsize),
- SEEK_SET);
- if (write(f, boot, lp->d_secsize) < lp->d_secsize)
- warn("alternate label %d write", i/2);
- }
- }
-#endif
- return (0);
-}
-
-void
-l_perror(s)
- char *s;
-{
- switch (errno) {
-
- case ESRCH:
- warnx("%s: no disk label on disk;", s);
- fprintf(stderr,
- "use \"disklabel -r\" to install initial label\n");
- break;
-
- case EINVAL:
- warnx("%s: label magic number or checksum is wrong!", s);
- fprintf(stderr, "(disklabel or kernel is out of date?)\n");
- break;
-
- case EBUSY:
- warnx("%s: open partition would move or shrink", s);
- break;
-
- case EXDEV:
- warnx("%s: '%c' partition must start at beginning of disk",
- s, 'a' + RAW_PART);
- break;
-
- default:
- warn((char *)NULL);
- break;
- }
-}
-
-/*
- * Fetch disklabel for disk.
- * Use ioctl to get label unless -r flag is given.
- */
-struct disklabel *
-readlabel(f)
- int f;
-{
- register struct disklabel *lp;
-
- if (rflag) {
- if (read(f, bootarea, BBSIZE) < BBSIZE)
- err(4, "%s", specname);
- for (lp = (struct disklabel *)bootarea;
- lp <= (struct disklabel *)(bootarea + BBSIZE - sizeof(*lp));
- lp = (struct disklabel *)((char *)lp + 16))
- if (lp->d_magic == DISKMAGIC &&
- lp->d_magic2 == DISKMAGIC)
- break;
- if (lp > (struct disklabel *)(bootarea+BBSIZE-sizeof(*lp)) ||
- lp->d_magic != DISKMAGIC || lp->d_magic2 != DISKMAGIC ||
- dkcksum(lp) != 0)
- errx(1,
- "bad pack magic number (label is damaged, or pack is unlabeled)");
- } else {
- lp = &lab;
- if (ioctl(f, DIOCGDINFO, lp) < 0)
- err(4, "ioctl DIOCGDINFO");
- }
- return (lp);
-}
-
-/*
- * Construct a bootarea (d_bbsize bytes) in the specified buffer ``boot''
- * Returns a pointer to the disklabel portion of the bootarea.
- */
-struct disklabel *
-makebootarea(boot, dp, f)
- char *boot;
- register struct disklabel *dp;
- int f;
-{
- struct disklabel *lp;
- register char *p;
- int b;
-#if NUMBOOT > 0
- char *dkbasename;
- struct stat sb;
-#endif
-#ifdef __alpha__
- u_long *bootinfo;
- int n;
-#endif
-#ifdef __i386__
- char *tmpbuf;
- int i, found;
-#endif
-
- /* XXX */
- if (dp->d_secsize == 0) {
- dp->d_secsize = DEV_BSIZE;
- dp->d_bbsize = BBSIZE;
- }
- lp = (struct disklabel *)
- (boot + (LABELSECTOR * dp->d_secsize) + LABELOFFSET);
- bzero((char *)lp, sizeof *lp);
-#if NUMBOOT > 0
- /*
- * If we are not installing a boot program but we are installing a
- * label on disk then we must read the current bootarea so we don't
- * clobber the existing boot.
- */
- if (!installboot) {
- if (rflag) {
- if (read(f, boot, BBSIZE) < BBSIZE)
- err(4, "%s", specname);
- bzero((char *)lp, sizeof *lp);
- }
- return (lp);
- }
- /*
- * We are installing a boot program. Determine the name(s) and
- * read them into the appropriate places in the boot area.
- */
- if (!xxboot || !bootxx) {
- dkbasename = np;
- if ((p = rindex(dkname, '/')) == NULL)
- p = dkname;
- else
- p++;
- while (*p && !isdigit(*p))
- *np++ = *p++;
- *np++ = '\0';
-
- if (!xxboot) {
- (void)sprintf(boot0, "%s/boot1", _PATH_BOOTDIR);
- xxboot = boot0;
- }
-#if NUMBOOT > 1
- if (!bootxx) {
- (void)sprintf(boot1, "%s/boot2", _PATH_BOOTDIR);
- bootxx = boot1;
- }
-#endif
- }
-#ifdef DEBUG
- if (debug)
- fprintf(stderr, "bootstraps: xxboot = %s, bootxx = %s\n",
- xxboot, bootxx ? bootxx : "NONE");
-#endif
-
- /*
- * Strange rules:
- * 1. One-piece bootstrap (hp300/hp800)
- * up to d_bbsize bytes of ``xxboot'' go in bootarea, the rest
- * is remembered and written later following the bootarea.
- * 2. Two-piece bootstraps (vax/i386?/mips?)
- * up to d_secsize bytes of ``xxboot'' go in first d_secsize
- * bytes of bootarea, remaining d_bbsize-d_secsize filled
- * from ``bootxx''.
- */
- b = open(xxboot, O_RDONLY);
- if (b < 0)
- err(4, "%s", xxboot);
-#if NUMBOOT > 1
-#ifdef __i386__
- /*
- * XXX Botch alert.
- * The i386 has the so-called fdisk table embedded into the
- * primary bootstrap. We take care to not clobber it, but
- * only if it does already contain some data. (Otherwise,
- * the xxboot provides a template.)
- */
- if ((tmpbuf = (char *)malloc((int)dp->d_secsize)) == 0)
- err(4, "%s", xxboot);
- memcpy((void *)tmpbuf, (void *)boot, (int)dp->d_secsize);
-#endif /* i386 */
- if (read(b, boot, (int)dp->d_secsize) < 0)
- err(4, "%s", xxboot);
- (void)close(b);
-#ifdef __i386__
- for (i = DOSPARTOFF, found = 0;
- !found && i < DOSPARTOFF + NDOSPART*sizeof(struct dos_partition);
- i++)
- found = tmpbuf[i] != 0;
- if (found)
- memcpy((void *)&boot[DOSPARTOFF],
- (void *)&tmpbuf[DOSPARTOFF],
- NDOSPART * sizeof(struct dos_partition));
- free(tmpbuf);
-#endif /* i386 */
- b = open(bootxx, O_RDONLY);
- if (b < 0)
- err(4, "%s", bootxx);
- if (fstat(b, &sb) != 0)
- err(4, "%s", bootxx);
- if (dp->d_secsize + sb.st_size > dp->d_bbsize)
- errx(4, "%s too large", bootxx);
- if (read(b, &boot[dp->d_secsize],
- (int)(dp->d_bbsize-dp->d_secsize)) < 0)
- err(4, "%s", bootxx);
-#else /* !(NUMBOOT > 1) */
-#ifdef __alpha__
- /*
- * On the alpha, the primary bootstrap starts at the
- * second sector of the boot area. The first sector
- * contains the label and must be edited to contain the
- * size and location of the primary bootstrap.
- */
- n = read(b, boot + dp->d_secsize, (int)dp->d_bbsize);
- if (n < 0)
- err(4, "%s", xxboot);
- bootinfo = (u_long *)(boot + 480);
- bootinfo[0] = (n + dp->d_secsize - 1) / dp->d_secsize;
- bootinfo[1] = 1; /* start at sector 1 */
- bootinfo[2] = 0; /* flags (must be zero) */
-#else /* !__alpha__ */
- if (read(b, boot, (int)dp->d_bbsize) < 0)
- err(4, "%s", xxboot);
-#endif /* __alpha__ */
- if (fstat(b, &sb) != 0)
- err(4, "%s", xxboot);
- bootsize = (int)sb.st_size - dp->d_bbsize;
- if (bootsize > 0) {
- /* XXX assume d_secsize is a power of two */
- bootsize = (bootsize + dp->d_secsize-1) & ~(dp->d_secsize-1);
- bootbuf = (char *)malloc((size_t)bootsize);
- if (bootbuf == 0)
- err(4, "%s", xxboot);
- if (read(b, bootbuf, bootsize) < 0) {
- free(bootbuf);
- err(4, "%s", xxboot);
- }
- }
-#endif /* NUMBOOT > 1 */
- (void)close(b);
-#endif /* NUMBOOT > 0 */
- /*
- * Make sure no part of the bootstrap is written in the area
- * reserved for the label.
- */
- for (p = (char *)lp; p < (char *)lp + sizeof(struct disklabel); p++)
- if (*p)
- errx(2, "bootstrap doesn't leave room for disk label");
- return (lp);
-}
-
-void
-display(f, lp)
- FILE *f;
- register struct disklabel *lp;
-{
- register int i, j;
- register struct partition *pp;
-
- fprintf(f, "# %s:\n", specname);
- if ((unsigned) lp->d_type < DKMAXTYPES)
- fprintf(f, "type: %s\n", dktypenames[lp->d_type]);
- else
- fprintf(f, "type: %u\n", lp->d_type);
- fprintf(f, "disk: %.*s\n", (int)sizeof(lp->d_typename),
- lp->d_typename);
- fprintf(f, "label: %.*s\n", (int)sizeof(lp->d_packname),
- lp->d_packname);
- fprintf(f, "flags:");
- if (lp->d_flags & D_REMOVABLE)
- fprintf(f, " removeable");
- if (lp->d_flags & D_ECC)
- fprintf(f, " ecc");
- if (lp->d_flags & D_BADSECT)
- fprintf(f, " badsect");
- fprintf(f, "\n");
- fprintf(f, "bytes/sector: %lu\n", (u_long)lp->d_secsize);
- fprintf(f, "sectors/track: %lu\n", (u_long)lp->d_nsectors);
- fprintf(f, "tracks/cylinder: %lu\n", (u_long)lp->d_ntracks);
- fprintf(f, "sectors/cylinder: %lu\n", (u_long)lp->d_secpercyl);
- fprintf(f, "cylinders: %lu\n", (u_long)lp->d_ncylinders);
- fprintf(f, "sectors/unit: %lu\n", (u_long)lp->d_secperunit);
- fprintf(f, "rpm: %u\n", lp->d_rpm);
- fprintf(f, "interleave: %u\n", lp->d_interleave);
- fprintf(f, "trackskew: %u\n", lp->d_trackskew);
- fprintf(f, "cylinderskew: %u\n", lp->d_cylskew);
- fprintf(f, "headswitch: %lu\t\t# milliseconds\n",
- (u_long)lp->d_headswitch);
- fprintf(f, "track-to-track seek: %ld\t# milliseconds\n",
- (u_long)lp->d_trkseek);
- fprintf(f, "drivedata: ");
- for (i = NDDATA - 1; i >= 0; i--)
- if (lp->d_drivedata[i])
- break;
- if (i < 0)
- i = 0;
- for (j = 0; j <= i; j++)
- fprintf(f, "%lu ", (u_long)lp->d_drivedata[j]);
- fprintf(f, "\n\n%u partitions:\n", lp->d_npartitions);
- fprintf(f,
- "# size offset fstype [fsize bsize bps/cpg]\n");
- pp = lp->d_partitions;
- for (i = 0; i < lp->d_npartitions; i++, pp++) {
- if (pp->p_size) {
- fprintf(f, " %c: %8lu %8lu ", 'a' + i,
- (u_long)pp->p_size, (u_long)pp->p_offset);
- if ((unsigned) pp->p_fstype < FSMAXTYPES)
- fprintf(f, "%8.8s", fstypenames[pp->p_fstype]);
- else
- fprintf(f, "%8d", pp->p_fstype);
- switch (pp->p_fstype) {
-
- case FS_UNUSED: /* XXX */
- fprintf(f, " %5lu %5lu %5.5s ",
- (u_long)pp->p_fsize,
- (u_long)(pp->p_fsize * pp->p_frag), "");
- break;
-
- case FS_BSDFFS:
- fprintf(f, " %5lu %5lu %5u ",
- (u_long)pp->p_fsize,
- (u_long)(pp->p_fsize * pp->p_frag),
- pp->p_cpg);
- break;
-
- case FS_BSDLFS:
- fprintf(f, " %5lu %5lu %5d",
- (u_long)pp->p_fsize,
- (u_long)(pp->p_fsize * pp->p_frag),
- pp->p_cpg);
- break;
-
- default:
- fprintf(f, "%20.20s", "");
- break;
- }
- fprintf(f, "\t# (Cyl. %4lu",
- (u_long)(pp->p_offset / lp->d_secpercyl));
- if (pp->p_offset % lp->d_secpercyl)
- putc('*', f);
- else
- putc(' ', f);
- fprintf(f, "- %lu",
- (u_long)((pp->p_offset + pp->p_size +
- lp->d_secpercyl - 1) /
- lp->d_secpercyl - 1));
- if (pp->p_size % lp->d_secpercyl)
- putc('*', f);
- fprintf(f, ")\n");
- }
- }
- fflush(f);
-}
-
-int
-edit(lp, f)
- struct disklabel *lp;
- int f;
-{
- register int c, fd;
- struct disklabel label;
- FILE *fp;
-
- if ((fd = mkstemp(tmpfil)) == -1 ||
- (fp = fdopen(fd, "w")) == NULL) {
- warnx("can't create %s", tmpfil);
- return (1);
- }
- display(fp, lp);
- fclose(fp);
- for (;;) {
- if (!editit())
- break;
- fp = fopen(tmpfil, "r");
- if (fp == NULL) {
- warnx("can't reopen %s for reading", tmpfil);
- break;
- }
- bzero((char *)&label, sizeof(label));
- if (getasciilabel(fp, &label)) {
- *lp = label;
- if (writelabel(f, bootarea, lp) == 0) {
- fclose(fp);
- (void) unlink(tmpfil);
- return (0);
- }
- }
- fclose(fp);
- printf("re-edit the label? [y]: "); fflush(stdout);
- c = getchar();
- if (c != EOF && c != (int)'\n')
- while (getchar() != (int)'\n')
- ;
- if (c == (int)'n')
- break;
- }
- (void) unlink(tmpfil);
- return (1);
-}
-
-int
-editit()
-{
- register int pid, xpid;
- int stat, omask;
-
- omask = sigblock(sigmask(SIGINT)|sigmask(SIGQUIT)|sigmask(SIGHUP));
- while ((pid = fork()) < 0) {
- extern int errno;
-
- if (errno == EPROCLIM) {
- warnx("you have too many processes");
- return(0);
- }
- if (errno != EAGAIN) {
- warn("fork");
- return(0);
- }
- sleep(1);
- }
- if (pid == 0) {
- register char *ed;
-
- sigsetmask(omask);
- setgid(getgid());
- setuid(getuid());
- if ((ed = getenv("EDITOR")) == (char *)0)
- ed = DEFEDITOR;
- execlp(ed, ed, tmpfil, 0);
- err(1, "%s", ed);
- }
- while ((xpid = wait(&stat)) >= 0)
- if (xpid == pid)
- break;
- sigsetmask(omask);
- return(!stat);
-}
-
-char *
-skip(cp)
- register char *cp;
-{
-
- while (*cp != '\0' && isspace(*cp))
- cp++;
- if (*cp == '\0' || *cp == '#')
- return ((char *)NULL);
- return (cp);
-}
-
-char *
-word(cp)
- register char *cp;
-{
- register char c;
-
- while (*cp != '\0' && !isspace(*cp) && *cp != '#')
- cp++;
- if ((c = *cp) != '\0') {
- *cp++ = '\0';
- if (c != '#')
- return (skip(cp));
- }
- return ((char *)NULL);
-}
-
-/*
- * Read an ascii label in from fd f,
- * in the same format as that put out by display(),
- * and fill in lp.
- */
-int
-getasciilabel(f, lp)
- FILE *f;
- register struct disklabel *lp;
-{
- register char **cpp, *cp;
- register struct partition *pp;
- char *tp, *s, line[BUFSIZ];
- int v, lineno = 0, errors = 0;
-
- lp->d_bbsize = BBSIZE; /* XXX */
- lp->d_sbsize = SBSIZE; /* XXX */
- while (fgets(line, sizeof(line) - 1, f)) {
- lineno++;
- if ((cp = index(line,'\n')) != 0)
- *cp = '\0';
- cp = skip(line);
- if (cp == NULL)
- continue;
- tp = index(cp, ':');
- if (tp == NULL) {
- fprintf(stderr, "line %d: syntax error\n", lineno);
- errors++;
- continue;
- }
- *tp++ = '\0', tp = skip(tp);
- if (streq(cp, "type")) {
- if (tp == NULL)
- tp = "unknown";
- cpp = dktypenames;
- for (; cpp < &dktypenames[DKMAXTYPES]; cpp++)
- if ((s = *cpp) && streq(s, tp)) {
- lp->d_type = cpp - dktypenames;
- goto next;
- }
- v = atoi(tp);
- if ((unsigned)v >= DKMAXTYPES)
- fprintf(stderr, "line %d:%s %d\n", lineno,
- "Warning, unknown disk type", v);
- lp->d_type = v;
- continue;
- }
- if (streq(cp, "flags")) {
- for (v = 0; (cp = tp) && *cp != '\0';) {
- tp = word(cp);
- if (streq(cp, "removeable"))
- v |= D_REMOVABLE;
- else if (streq(cp, "ecc"))
- v |= D_ECC;
- else if (streq(cp, "badsect"))
- v |= D_BADSECT;
- else {
- fprintf(stderr,
- "line %d: %s: bad flag\n",
- lineno, cp);
- errors++;
- }
- }
- lp->d_flags = v;
- continue;
- }
- if (streq(cp, "drivedata")) {
- register int i;
-
- for (i = 0; (cp = tp) && *cp != '\0' && i < NDDATA;) {
- lp->d_drivedata[i++] = atoi(cp);
- tp = word(cp);
- }
- continue;
- }
- if (sscanf(cp, "%d partitions", &v) == 1) {
- if (v == 0 || (unsigned)v > MAXPARTITIONS) {
- fprintf(stderr,
- "line %d: bad # of partitions\n", lineno);
- lp->d_npartitions = MAXPARTITIONS;
- errors++;
- } else
- lp->d_npartitions = v;
- continue;
- }
- if (tp == NULL)
- tp = "";
- if (streq(cp, "disk")) {
- strncpy(lp->d_typename, tp, sizeof (lp->d_typename));
- continue;
- }
- if (streq(cp, "label")) {
- strncpy(lp->d_packname, tp, sizeof (lp->d_packname));
- continue;
- }
- if (streq(cp, "bytes/sector")) {
- v = atoi(tp);
- if (v <= 0 || (v % DEV_BSIZE) != 0) {
- fprintf(stderr,
- "line %d: %s: bad sector size\n",
- lineno, tp);
- errors++;
- } else
- lp->d_secsize = v;
- continue;
- }
- if (streq(cp, "sectors/track")) {
- v = atoi(tp);
- if (v <= 0) {
- fprintf(stderr, "line %d: %s: bad %s\n",
- lineno, tp, cp);
- errors++;
- } else
- lp->d_nsectors = v;
- continue;
- }
- if (streq(cp, "sectors/cylinder")) {
- v = atoi(tp);
- if (v <= 0) {
- fprintf(stderr, "line %d: %s: bad %s\n",
- lineno, tp, cp);
- errors++;
- } else
- lp->d_secpercyl = v;
- continue;
- }
- if (streq(cp, "tracks/cylinder")) {
- v = atoi(tp);
- if (v <= 0) {
- fprintf(stderr, "line %d: %s: bad %s\n",
- lineno, tp, cp);
- errors++;
- } else
- lp->d_ntracks = v;
- continue;
- }
- if (streq(cp, "cylinders")) {
- v = atoi(tp);
- if (v <= 0) {
- fprintf(stderr, "line %d: %s: bad %s\n",
- lineno, tp, cp);
- errors++;
- } else
- lp->d_ncylinders = v;
- continue;
- }
- if (streq(cp, "sectors/unit")) {
- v = atoi(tp);
- if (v <= 0) {
- fprintf(stderr, "line %d: %s: bad %s\n",
- lineno, tp, cp);
- errors++;
- } else
- lp->d_secperunit = v;
- continue;
- }
- if (streq(cp, "rpm")) {
- v = atoi(tp);
- if (v <= 0) {
- fprintf(stderr, "line %d: %s: bad %s\n",
- lineno, tp, cp);
- errors++;
- } else
- lp->d_rpm = v;
- continue;
- }
- if (streq(cp, "interleave")) {
- v = atoi(tp);
- if (v <= 0) {
- fprintf(stderr, "line %d: %s: bad %s\n",
- lineno, tp, cp);
- errors++;
- } else
- lp->d_interleave = v;
- continue;
- }
- if (streq(cp, "trackskew")) {
- v = atoi(tp);
- if (v < 0) {
- fprintf(stderr, "line %d: %s: bad %s\n",
- lineno, tp, cp);
- errors++;
- } else
- lp->d_trackskew = v;
- continue;
- }
- if (streq(cp, "cylinderskew")) {
- v = atoi(tp);
- if (v < 0) {
- fprintf(stderr, "line %d: %s: bad %s\n",
- lineno, tp, cp);
- errors++;
- } else
- lp->d_cylskew = v;
- continue;
- }
- if (streq(cp, "headswitch")) {
- v = atoi(tp);
- if (v < 0) {
- fprintf(stderr, "line %d: %s: bad %s\n",
- lineno, tp, cp);
- errors++;
- } else
- lp->d_headswitch = v;
- continue;
- }
- if (streq(cp, "track-to-track seek")) {
- v = atoi(tp);
- if (v < 0) {
- fprintf(stderr, "line %d: %s: bad %s\n",
- lineno, tp, cp);
- errors++;
- } else
- lp->d_trkseek = v;
- continue;
- }
- if ('a' <= *cp && *cp <= 'z' && cp[1] == '\0') {
- unsigned part = *cp - 'a';
-
- if (part > lp->d_npartitions) {
- fprintf(stderr,
- "line %d: bad partition name\n", lineno);
- errors++;
- continue;
- }
- pp = &lp->d_partitions[part];
-#define NXTNUM(n) { \
- if (tp == NULL) { \
- fprintf(stderr, "line %d: too few numeric fields\n", lineno); \
- errors++; \
- break; \
- } else { \
- cp = tp, tp = word(cp); \
- if (tp == NULL) \
- tp = cp; \
- (n) = atoi(cp); \
- } \
- }
-
- NXTNUM(v);
- if (v < 0) {
- fprintf(stderr,
- "line %d: %s: bad partition size\n",
- lineno, cp);
- errors++;
- } else
- pp->p_size = v;
- NXTNUM(v);
- if (v < 0) {
- fprintf(stderr,
- "line %d: %s: bad partition offset\n",
- lineno, cp);
- errors++;
- } else
- pp->p_offset = v;
- cp = tp, tp = word(cp);
- cpp = fstypenames;
- for (; cpp < &fstypenames[FSMAXTYPES]; cpp++)
- if ((s = *cpp) && streq(s, cp)) {
- pp->p_fstype = cpp - fstypenames;
- goto gottype;
- }
- if (isdigit(*cp))
- v = atoi(cp);
- else
- v = FSMAXTYPES;
- if ((unsigned)v >= FSMAXTYPES) {
- fprintf(stderr, "line %d: %s %s\n", lineno,
- "Warning, unknown filesystem type", cp);
- v = FS_UNUSED;
- }
- pp->p_fstype = v;
- gottype:
-
- switch (pp->p_fstype) {
-
- case FS_UNUSED: /* XXX */
- NXTNUM(pp->p_fsize);
- if (pp->p_fsize == 0)
- break;
- NXTNUM(v);
- pp->p_frag = v / pp->p_fsize;
- break;
-
- case FS_BSDFFS:
- NXTNUM(pp->p_fsize);
- if (pp->p_fsize == 0)
- break;
- NXTNUM(v);
- pp->p_frag = v / pp->p_fsize;
- NXTNUM(pp->p_cpg);
- break;
-
- case FS_BSDLFS:
- NXTNUM(pp->p_fsize);
- if (pp->p_fsize == 0)
- break;
- NXTNUM(v);
- pp->p_frag = v / pp->p_fsize;
- NXTNUM(pp->p_cpg);
- break;
-
- default:
- break;
- }
- continue;
- }
- fprintf(stderr, "line %d: %s: Unknown disklabel field\n",
- lineno, cp);
- errors++;
- next:
- ;
- }
- errors += checklabel(lp);
- return (errors == 0);
-}
-
-/*
- * Check disklabel for errors and fill in
- * derived fields according to supplied values.
- */
-int
-checklabel(lp)
- register struct disklabel *lp;
-{
- register struct partition *pp;
- int i, errors = 0;
- char part;
-
- if (lp->d_secsize == 0) {
- fprintf(stderr, "sector size 0\n");
- return (1);
- }
- if (lp->d_nsectors == 0) {
- fprintf(stderr, "sectors/track 0\n");
- return (1);
- }
- if (lp->d_ntracks == 0) {
- fprintf(stderr, "tracks/cylinder 0\n");
- return (1);
- }
- if (lp->d_ncylinders == 0) {
- fprintf(stderr, "cylinders/unit 0\n");
- errors++;
- }
- if (lp->d_rpm == 0)
- Warning("revolutions/minute 0");
- if (lp->d_secpercyl == 0)
- lp->d_secpercyl = lp->d_nsectors * lp->d_ntracks;
- if (lp->d_secperunit == 0)
- lp->d_secperunit = lp->d_secpercyl * lp->d_ncylinders;
- if (lp->d_bbsize == 0) {
- fprintf(stderr, "boot block size 0\n");
- errors++;
- } else if (lp->d_bbsize % lp->d_secsize)
- Warning("boot block size %% sector-size != 0");
- if (lp->d_sbsize == 0) {
- fprintf(stderr, "super block size 0\n");
- errors++;
- } else if (lp->d_sbsize % lp->d_secsize)
- Warning("super block size %% sector-size != 0");
- if (lp->d_npartitions > MAXPARTITIONS)
- Warning("number of partitions (%lu) > MAXPARTITIONS (%d)",
- (u_long)lp->d_npartitions, MAXPARTITIONS);
- for (i = 0; i < lp->d_npartitions; i++) {
- part = 'a' + i;
- pp = &lp->d_partitions[i];
- if (pp->p_size == 0 && pp->p_offset != 0)
- Warning("partition %c: size 0, but offset %lu",
- part, (u_long)pp->p_offset);
-#ifdef notdef
- if (pp->p_size % lp->d_secpercyl)
- Warning("partition %c: size %% cylinder-size != 0",
- part);
- if (pp->p_offset % lp->d_secpercyl)
- Warning("partition %c: offset %% cylinder-size != 0",
- part);
-#endif
- if (pp->p_offset > lp->d_secperunit) {
- fprintf(stderr,
- "partition %c: offset past end of unit\n", part);
- errors++;
- }
- if (pp->p_offset + pp->p_size > lp->d_secperunit) {
- fprintf(stderr,
- "partition %c: partition extends past end of unit\n",
- part);
- errors++;
- }
- }
- for (; i < MAXPARTITIONS; i++) {
- part = 'a' + i;
- pp = &lp->d_partitions[i];
- if (pp->p_size || pp->p_offset)
- Warning("unused partition %c: size %d offset %lu",
- 'a' + i, pp->p_size, (u_long)pp->p_offset);
- }
- return (errors);
-}
-
-/*
- * When operating on a "virgin" disk, try getting an initial label
- * from the associated device driver. This might work for all device
- * drivers that are able to fetch some initial device parameters
- * without even having access to a (BSD) disklabel, like SCSI disks,
- * most IDE drives, or vn devices.
- *
- * The device name must be given in its "canonical" form.
- */
-struct disklabel *
-getvirginlabel(void)
-{
- static struct disklabel lab;
- char namebuf[BBSIZE];
- int f;
-
- if (dkname[0] == '/') {
- warnx("\"auto\" requires the usage of a canonical disk name");
- return (NULL);
- }
- (void)snprintf(namebuf, BBSIZE, "%sr%s", _PATH_DEV, dkname);
- if ((f = open(namebuf, O_RDONLY)) == -1) {
- warn("cannot open %s", namebuf);
- return (NULL);
- }
- if (ioctl(f, DIOCGDINFO, &lab) < 0) {
- warn("ioctl DIOCGDINFO");
- close(f);
- return (NULL);
- }
- close(f);
- lab.d_boot0 = NULL;
- lab.d_boot1 = NULL;
- return (&lab);
-}
-
-/*
- * If we are installing a boot program that doesn't fit in d_bbsize
- * we need to mark those partitions that the boot overflows into.
- * This allows newfs to prevent creation of a filesystem where it might
- * clobber bootstrap code.
- */
-void
-setbootflag(lp)
- register struct disklabel *lp;
-{
- register struct partition *pp;
- int i, errors = 0;
- char part;
- u_long boffset;
-
- if (bootbuf == 0)
- return;
- boffset = bootsize / lp->d_secsize;
- for (i = 0; i < lp->d_npartitions; i++) {
- part = 'a' + i;
- pp = &lp->d_partitions[i];
- if (pp->p_size == 0)
- continue;
- if (boffset <= pp->p_offset) {
- if (pp->p_fstype == FS_BOOT)
- pp->p_fstype = FS_UNUSED;
- } else if (pp->p_fstype != FS_BOOT) {
- if (pp->p_fstype != FS_UNUSED) {
- fprintf(stderr,
- "boot overlaps used partition %c\n",
- part);
- errors++;
- } else {
- pp->p_fstype = FS_BOOT;
- Warning("boot overlaps partition %c, %s",
- part, "marked as FS_BOOT");
- }
- }
- }
- if (errors)
- errx(4, "cannot install boot program");
-}
-
-/*VARARGS1*/
-void
-Warning(char *fmt, ...)
-{
- va_list ap;
-
- fprintf(stderr, "Warning, ");
- va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
- fprintf(stderr, "\n");
- va_end(ap);
-}
-
-void
-usage()
-{
-#if NUMBOOT > 0
- fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
- "usage: disklabel [-r] disk",
- "\t\t(to read label)",
- " disklabel -w [-r] disk type [ packid ]",
- "\t\t(to write label with existing boot program)",
- " disklabel -e [-r] disk",
- "\t\t(to edit label)",
- " disklabel -R [-r] disk protofile",
- "\t\t(to restore label with existing boot program)",
-#if NUMBOOT > 1
- " disklabel -B [ -b boot1 [ -s boot2 ] ] disk [ type ]",
- "\t\t(to install boot program with existing label)",
- " disklabel -w -B [ -b boot1 [ -s boot2 ] ] disk type [ packid ]",
- "\t\t(to write label and boot program)",
- " disklabel -R -B [ -b boot1 [ -s boot2 ] ] disk protofile [ type ]",
- "\t\t(to restore label and boot program)",
-#else
- " disklabel -B [ -b bootprog ] disk [ type ]",
- "\t\t(to install boot program with existing on-disk label)",
- " disklabel -w -B [ -b bootprog ] disk type [ packid ]",
- "\t\t(to write label and install boot program)",
- " disklabel -R -B [ -b bootprog ] disk protofile [ type ]",
- "\t\t(to restore label and install boot program)",
-#endif
- " disklabel [-NW] disk",
- "\t\t(to write disable/enable label)");
-#else
- fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
- "usage: disklabel [-r] disk", "(to read label)",
- " disklabel -w [-r] disk type [ packid ]",
- "\t\t(to write label)",
- " disklabel -e [-r] disk",
- "\t\t(to edit label)",
- " disklabel -R [-r] disk protofile",
- "\t\t(to restore label)",
- " disklabel [-NW] disk",
- "\t\t(to write disable/enable label)");
-#endif
- exit(1);
-}
diff --git a/sbin/bsdlabel/dkcksum.c b/sbin/bsdlabel/dkcksum.c
deleted file mode 100644
index 3a58aa23044b..000000000000
--- a/sbin/bsdlabel/dkcksum.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*-
- * Copyright (c) 1991, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-#if 0
-static char sccsid[] = "@(#)dkcksum.c 8.1 (Berkeley) 6/5/93";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <sys/types.h>
-#include <sys/disklabel.h>
-
-u_short
-dkcksum(lp)
- register struct disklabel *lp;
-{
- register u_short *start, *end;
- register u_short sum = 0;
-
- start = (u_short *)lp;
- end = (u_short *)&lp->d_partitions[lp->d_npartitions];
- while (start < end)
- sum ^= *start++;
- return (sum);
-}
diff --git a/sbin/bsdlabel/pathnames.h b/sbin/bsdlabel/pathnames.h
deleted file mode 100644
index c09d4692c94a..000000000000
--- a/sbin/bsdlabel/pathnames.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 1989, 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)pathnames.h 8.1 (Berkeley) 6/5/93
- * $FreeBSD$
- */
-
-#include <paths.h>
-
-#define _PATH_BOOTDIR "/boot"
-#define PATH_TMPFILE "/tmp/EdDk.XXXXXXXXXX"
diff --git a/sbin/camcontrol/util.c b/sbin/camcontrol/util.c
deleted file mode 100644
index 32f5c78688d4..000000000000
--- a/sbin/camcontrol/util.c
+++ /dev/null
@@ -1,503 +0,0 @@
-/*
- * Written By Julian ELischer
- * Copyright julian Elischer 1993.
- * Permission is granted to use or redistribute this file in any way as long
- * as this notice remains. Julian Elischer does not guarantee that this file
- * is totally correct for any given task and users of this file must
- * accept responsibility for any damage that occurs from the application of this
- * file.
- *
- * (julian@tfs.com julian@dialix.oz.au)
- *
- * User SCSI hooks added by Peter Dufault:
- *
- * Copyright (c) 1994 HD Associates
- * (contact: dufault@hda.com)
- * 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 HD Associates
- * may not be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES ``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 HD ASSOCIATES 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.
- */
-/*
- * Taken from the original scsi(8) program.
- * from: scsi.c,v 1.17 1998/01/12 07:57:57 charnier Exp $";
- */
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <ctype.h>
-#include <err.h>
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <sys/file.h>
-#include <signal.h>
-#include <unistd.h>
-
-#include <cam/cam.h>
-#include <cam/cam_ccb.h>
-#include <camlib.h>
-#include "camcontrol.h"
-
-int verbose = 0;
-
-/* iget: Integer argument callback
- */
-int
-iget(void *hook, char *name)
-{
- struct get_hook *h = (struct get_hook *)hook;
- int arg;
-
- if (h->got >= h->argc)
- {
- fprintf(stderr, "Expecting an integer argument.\n");
- usage(0);
- exit(1);
- }
- arg = strtol(h->argv[h->got], 0, 0);
- h->got++;
-
- if (verbose && name && *name)
- printf("%s: %d\n", name, arg);
-
- return arg;
-}
-
-/* cget: char * argument callback
- */
-char *
-cget(void *hook, char *name)
-{
- struct get_hook *h = (struct get_hook *)hook;
- char *arg;
-
- if (h->got >= h->argc)
- {
- fprintf(stderr, "Expecting a character pointer argument.\n");
- usage(0);
- exit(1);
- }
- arg = h->argv[h->got];
- h->got++;
-
- if (verbose && name)
- printf("cget: %s: %s", name, arg);
-
- return arg;
-}
-
-/* arg_put: "put argument" callback
- */
-void
-arg_put(void *hook, int letter, void *arg, int count, char *name)
-{
- if (verbose && name && *name)
- printf("%s: ", name);
-
- switch(letter)
- {
- case 'i':
- case 'b':
- printf("%d ", (intptr_t)arg);
- break;
-
- case 'c':
- case 'z':
- {
- char *p;
-
- p = malloc(count + 1);
-
- bzero(p, count +1);
- strncpy(p, (char *)arg, count);
- if (letter == 'z')
- {
- int i;
- for (i = count - 1; i >= 0; i--)
- if (p[i] == ' ')
- p[i] = 0;
- else
- break;
- }
- printf("%s ", p);
-
- free(p);
- }
-
- break;
-
- default:
- printf("Unknown format letter: '%c'\n", letter);
- }
- if (verbose)
- putchar('\n');
-}
-
-#define START_ENTRY '{'
-#define END_ENTRY '}'
-
-static void
-skipwhite(FILE *f)
-{
- int c;
-
-skip_again:
-
- while (isspace(c = getc(f)))
- ;
-
- if (c == '#') {
- while ((c = getc(f)) != '\n' && c != EOF)
- ;
- goto skip_again;
- }
-
- ungetc(c, f);
-}
-
-/* mode_lookup: Lookup a format description for a given page.
- */
-char *mode_db = "/usr/share/misc/scsi_modes";
-static char *
-mode_lookup(int page)
-{
- char *new_db;
- FILE *modes;
- int match, next, found, c;
- static char fmt[4096]; /* XXX This should be with strealloc */
- int page_desc;
- new_db = getenv("SCSI_MODES");
-
- if (new_db)
- mode_db = new_db;
-
- modes = fopen(mode_db, "r");
- if (modes == 0)
- return 0;
-
- next = 0;
- found = 0;
-
- while (!found) {
-
- skipwhite(modes);
-
- if (fscanf(modes, "%i", &page_desc) != 1)
- break;
-
- if (page_desc == page)
- found = 1;
-
- skipwhite(modes);
- if (getc(modes) != START_ENTRY)
- errx(1, "expected %c", START_ENTRY);
-
- match = 1;
- while (match != 0) {
- c = getc(modes);
- if (c == EOF) {
- warnx("expected %c", END_ENTRY);
- }
-
- if (c == START_ENTRY) {
- match++;
- }
- if (c == END_ENTRY) {
- match--;
- if (match == 0)
- break;
- }
- if (found && c != '\n') {
- if (next >= sizeof(fmt))
- errx(1, "buffer overflow");
-
- fmt[next++] = (u_char)c;
- }
- }
- }
- fmt[next] = 0;
-
- return (found) ? fmt : 0;
-}
-
-/* -------- edit: Mode Select Editor ---------
- */
-struct editinfo
-{
- int can_edit;
- int default_value;
-} editinfo[64]; /* XXX Bogus fixed size */
-
-static int editind;
-volatile int edit_opened;
-static FILE *edit_file;
-static char edit_name[L_tmpnam];
-
-static inline void
-edit_rewind(void)
-{
- editind = 0;
-}
-
-static void
-edit_done(void)
-{
- int opened;
-
- sigset_t all, prev;
- sigfillset(&all);
-
- (void)sigprocmask(SIG_SETMASK, &all, &prev);
-
- opened = (int)edit_opened;
- edit_opened = 0;
-
- (void)sigprocmask(SIG_SETMASK, &prev, 0);
-
- if (opened)
- {
- if (fclose(edit_file))
- warn("%s", edit_name);
- if (unlink(edit_name))
- warn("%s", edit_name);
- }
-}
-
-static void
-edit_init(void)
-{
- int fd;
-
- edit_rewind();
- strlcpy(edit_name, "/tmp/camXXXXXX", sizeof(edit_name));
- if ((fd = mkstemp(edit_name)) == -1)
- errx(1, "mkstemp failed");
- if ((edit_file = fdopen(fd, "w")) == 0)
- err(1, "%s", edit_name);
- edit_opened = 1;
-
- atexit(edit_done);
-}
-
-static void
-edit_check(void *hook, int letter, void *arg, int count, char *name)
-{
- if (letter != 'i' && letter != 'b')
- errx(1, "can't edit format %c", letter);
-
- if (editind >= sizeof(editinfo) / sizeof(editinfo[0]))
- errx(1, "edit table overflow");
-
- editinfo[editind].can_edit = (arg != NULL);
- editind++;
-}
-
-static void
-edit_defaults(void *hook, int letter, void *arg, int count, char *name)
-{
- if (letter != 'i' && letter != 'b')
- errx(1, "can't edit format %c", letter);
-
- editinfo[editind].default_value = (intptr_t)arg; /* truncated */
- editind++;
-}
-
-static void
-edit_report(void *hook, int letter, void *arg, int count, char *name)
-{
- if (editinfo[editind].can_edit) {
- if (letter != 'i' && letter != 'b')
- errx(1, "can't report format %c", letter);
-
- fprintf(edit_file, "%s: %d\n", name, (intptr_t)arg);
- }
-
- editind++;
-}
-
-static int
-edit_get(void *hook, char *name)
-{
- int arg = editinfo[editind].default_value;
-
- if (editinfo[editind].can_edit) {
- char line[80];
- if (fgets(line, sizeof(line), edit_file) == 0)
- err(1, "fgets");
-
- line[strlen(line) - 1] = 0;
-
- if (strncmp(name, line, strlen(name)) != 0)
- errx(1, "expected \"%s\" and read \"%s\"", name, line);
-
- arg = strtoul(line + strlen(name) + 2, 0, 0);
- }
-
- editind++;
- return arg;
-}
-
-static void
-edit_edit(void)
-{
- char *system_line;
- char *editor = getenv("EDITOR");
- if (!editor)
- editor = "vi";
-
- fclose(edit_file);
-
- system_line = malloc(strlen(editor) + strlen(edit_name) + 6);
- sprintf(system_line, "%s %s", editor, edit_name);
- system(system_line);
- free(system_line);
-
- if ((edit_file = fopen(edit_name, "r")) == 0)
- err(1, "%s", edit_name);
-}
-
-void
-mode_edit(struct cam_device *device, int page, int page_control, int dbd,
- int edit, int retry_count, int timeout)
-{
- int i;
- u_char data[255];
- u_char *mode_pars;
- struct mode_header
- {
- u_char mdl; /* Mode data length */
- u_char medium_type;
- u_char dev_spec_par;
- u_char bdl; /* Block descriptor length */
- };
-
- struct mode_page_header
- {
- u_char page_code;
- u_char page_length;
- };
-
- struct mode_header *mh;
- struct mode_page_header *mph;
-
- char *fmt = mode_lookup(page);
- if (!fmt && verbose) {
- fprintf(stderr,
- "No mode data base entry in \"%s\" for page %d; "
- " binary %s only.\n",
- mode_db, page, (edit ? "edit" : "display"));
- }
-
- if (edit) {
- if (!fmt)
- errx(1, "can't edit without a format");
-
- if (page_control != 0 && page_control != 3)
- errx(1, "it only makes sense to edit page 0 "
- "(current) or page 3 (saved values)");
-
- verbose = 1;
-
- mode_sense(device, page, 1, dbd, retry_count, timeout,
- data, sizeof(data));
-
- mh = (struct mode_header *)data;
- mph = (struct mode_page_header *)
- (((char *)mh) + sizeof(*mh) + mh->bdl);
-
- mode_pars = (char *)mph + sizeof(*mph);
-
- edit_init();
- buff_decode_visit(mode_pars, mh->mdl, fmt, edit_check, 0);
-
- mode_sense(device, page, 0, dbd, retry_count, timeout,
- data, sizeof(data));
-
- edit_rewind();
- buff_decode_visit(mode_pars, mh->mdl, fmt, edit_defaults, 0);
-
- edit_rewind();
- buff_decode_visit(mode_pars, mh->mdl, fmt, edit_report, 0);
-
- edit_edit();
-
- edit_rewind();
- buff_encode_visit(mode_pars, mh->mdl, fmt, edit_get, 0);
-
- /* Eliminate block descriptors:
- */
- bcopy((char *)mph, ((char *)mh) + sizeof(*mh),
- sizeof(*mph) + mph->page_length);
-
- mh->bdl = mh->dev_spec_par = 0;
- mph = (struct mode_page_header *) (((char *)mh) + sizeof(*mh));
- mode_pars = ((char *)mph) + 2;
-
-#if 0
- /* Turn this on to see what you're sending to the
- * device:
- */
- edit_rewind();
- buff_decode_visit(mode_pars, mh->mdl, fmt, arg_put, 0);
-#endif
-
- edit_done();
-
- /* Make it permanent if pageselect is three.
- */
-
- mph->page_code &= ~0xC0; /* Clear PS and RESERVED */
- mh->mdl = 0; /* Reserved for mode select */
-
- mode_select(device, (page_control == 3), retry_count,
- timeout, (u_int8_t *)mh, sizeof(*mh) + mh->bdl +
- sizeof(*mph) + mph->page_length);
-
- return;
- }
-
- mode_sense(device, page, page_control, dbd, retry_count, timeout,
- data, sizeof(data));
-
- /* Skip over the block descriptors.
- */
- mh = (struct mode_header *)data;
- mph = (struct mode_page_header *)(((char *)mh) + sizeof(*mh) + mh->bdl);
- mode_pars = (char *)mph + sizeof(*mph);
-
- if (!fmt) {
- for (i = 0; i < mh->mdl; i++) {
- printf("%02x%c",mode_pars[i],
- (((i + 1) % 8) == 0) ? '\n' : ' ');
- }
- putc('\n', stdout);
- } else {
- verbose = 1;
- buff_decode_visit(mode_pars, mh->mdl, fmt, arg_put, NULL);
- }
-}
diff --git a/sbin/cxconfig/Makefile b/sbin/cxconfig/Makefile
deleted file mode 100644
index 59c828d15608..000000000000
--- a/sbin/cxconfig/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-PROG = cxconfig
-MAN8 = cxconfig.8
-
-.include <bsd.prog.mk>
diff --git a/sbin/cxconfig/cxconfig.8 b/sbin/cxconfig/cxconfig.8
deleted file mode 100644
index 066c4e95e9a0..000000000000
--- a/sbin/cxconfig/cxconfig.8
+++ /dev/null
@@ -1,324 +0,0 @@
-.\" $FreeBSD$
-.Dd December 2, 1994
-.Dt CXCONFIG 8
-.Os FreeBSD
-.Sh NAME
-.Nm cxconfig
-.Nd channel options management utility for Cronyx-Sigma adapter
-.Sh SYNOPSIS
-.Nm cxconfig
-.Op Fl a
-.Op Ar <channel> Op Ar <option>...
-.Sh DESCRIPTION
-The
-.Nm
-utility is used for configuring the channel options of
-the Cronyx-Sigma adapter.
-.Pp
-To change channel options the channel should be free: the corresponding
-network interface in ``down'' state, the asynchronous terminal device
-.Pa /dev/tty*
-closed.
-Generally, the channel options are set up during the operating
-system startup, for example from the
-.Pa /etc/rc
-file.
-.Pp
-Note, that not all options have a sense for every particular
-case, and an attempt to set some of them can hang up the channel or
-the whole adapter.
-.Pp
-The following option is available:
-.Bl -tag -width indent
-.It Fl a
-Display full information.
-.El
-.Sh "Channel options"
-.Bl -tag -width 10n
-.It ispeed=#
-Set the receiver baud rate to the number given.
-The maximal value is 256000 bits/sec.
-In the synchronous mode the receiver baud rate is significant
-only when DPLL mode is used.
-.It ospeed=#
-Set the transmitter baud rate to the number given.
-The maximal value is 256000 bits/sec.
-In the synchronous mode the transmitter baud rate is significant
-only in the case of the internal clock source.
-If receiver and transmitter have equal data rate, then it could
-be set by specifying only the numerical argument.
-.It async
-Set the asynchronous channel mode.
-.It "hdlc, bisync, bsc, x.21, x21
-Set the synchronous channel mode: HDLC, Bisync (BSC) or X.21.
-.It ppp
-Set the link-level protocol: PpP/HDLC. The built-in simplified synchronous PPP
-implementation is used (see RFC-1548, RFC-1549).
-.It cisco
-Set the link-level protocol: Cisco/HDLC (see RFC-1547).
-This protocol is intended for compatibility with old models of Cisco routers,
-and with early versions of BSD/386 drivers.
-The extensive usage of this protocol is not recommended.
-.It ext
-Use the external link-level protocol suite (for BSD/386 only).
-.It "+keepalive, -keepalive"
-Enable the automatic line state control sub-protocol.
-This setting is not significant when the external link-level protocol is used.
-.It "+autorts, -autorts"
-Enable the automatic RTS signal control.
-When enabled, the RTS signal goes up only when both halves of
-the receiver ring buffer are free and ready for receive,
-and goes down when one or both buffers are busy.
-.It "port=rs232, port=rs449, port=v35
-Set the zero channel hardware interface type.
-.El
-.Sh "Common options"
-.Bl -tag -width 10n
-.It "nrz, nrzi, manchester"
-Set the data line signal encoding.
-In the case of
-.Em NRZ
-encoding the zero bit is transmitted by the zero signal
-level, the one bit - by the positive signal level.
-In the case of
-.Em NRZI
-encoding the zero bit is transmitted by the change of
-the signal level, the one bit - by the constant signal level.
-In the case of
-.Em Manchester
-encoding the zero bit is encoded as 01 value,
-the one bit - as 10 value.
-.It "+dpll, -dpll"
-Enable the digital phase locked loop mode (DPLL).
-When enabled, the receiver timing clock signal
-is derived from the received data.
-.It "+lloop, -lloop"
-Set the local loopback mode.
-.It "+extclock, -extclock"
-Set the timing clock source of synchronous channels. There are
-two possible variants:
-.Em "external clock"
-source or
-.Em "internal clock"
-generation.
-.Pp
-.Em "External clock"
-mode is the most common method for connecting
-external modem hardware. In this mode the external timing
-signal is received on TXCIN pin of the connector, and it is
-used as a synchronization clock for transmitting data (TXD).
-.Pp
-In the case of
-.Em "internal clock"
-mode the transmitted data (TXD)
-are synchronized using the internal on-board timing generator,
-the internally generated timing signal is driven on the TXCOUT
-pin, and the signal on the TXCIN pin is ignored. This mode
-is used for direct terminal-to-terminal communication,
-e.g. for connecting two computers together in a synchronous mode
-via relatively short cable. This method should also be used
-for testing channels with an external loopback connector.
-.It fifo=#
-FIFO threshold level setup for receiver and transmitter.
-.It rfifo=#
-Hardware RTS/CTS flow control FIFO threshold setup.
-.It "+ctsup, -ctsup"
-Enable/disable interrupts on CTS (Clear To Send) signal setup (0 to 1 transition).
-.It "+ctsdown, -ctsdown"
-Enable/disable interrupts on CTS (Clear To Send) signal clear (1 to 0 transition).
-.It "+cdup, -cdup"
-Enable/disable interrupts on CD (Carrier Detect) signal setup (0 to 1 transition).
-.It "+cddown, -cddown"
-Enable/disable interrupts on CD (Carrier Detect) signal clear (1 to 0 transition).
-.It "+dsrup, -dsrup"
-Enable/disable interrupts on DSR (Data Set Ready) signal setup (0 to 1 transition).
-.It "+dsrdown, -dsrdown"
-Enable/disable interrupts on DSR (Data Set Ready) signal clear (1 to 0 transition).
-.El
-.Sh "Asynchronous mode options"
-.Bl -tag -width 10n
-.It cs#
-Select character size: 5, 6, 7 or 8 bits.
-.It "parodd, pareven
-Parity mode: odd or even.
-.It "+ignpar, -ignpar
-Disable/enable parity detection.
-.It nopar
-Disable parity bit generation.
-.It forcepar
-Force parity: even - 0, odd - 1.
-.It "stopb1, stopb1.5, stopb2
-Use 1 or 1.5 or 2 stop bits per character.
-.It "+dsr, -dsr"
-Use the DSR input signal as receiver enable/disable.
-.It "+cts, -cts"
-Use the CTS input signal as transmitter enable/disable.
-.It "+rts, -rts"
-Drive the RTS output signal as transmitter ready.
-.It "+rloop, -rloop"
-Set the remote loopback mode.
-.It "+etc, -etc"
-Enable the embedded transmit commands mode.
-.It "+ixon, -ixon"
-Enable the hardware XON/XOFF flow control support.
-.It "+ixany, -ixany"
-Use the hardware IXANY mode support.
-.It "+sdt, -sdt"
-Detect the spec. characters SCHR1 and SCHR2 in the receive data.
-.It "+flowct, -flowct"
-Receive the flow control spec. characters as data.
-.It "+rdt, -rdt"
-Detect the spec. characters in range SCRL..SCRH in the receive data.
-.It "+exdt, -exdt"
-Detect the spec. characters SCHR3 and SCHR4 in the receive data.
-.It "parintr, parnull, parign, pardisc, parffnull
-Action on parity errors:
-.Pp
-.Bl -tag -width parffnullxxx -compact
-.It Mode
-Action
-.It parintr
-Generate the receiver error interrupt
-.It parnull
-Input the NUL character
-.It parign
-Ignore the error, receive as good data
-.It pardisc
-Ignore the character
-.It parffnull
-Input the sequence <0xFF, NUL, character>
-.El
-.It "brkintr, brknull, brkdisc
-Line break state action:
-.Pp
-.Bl -tag -width parffnullxxx -compact
-.It Mode
-Action
-.It brkintr
-Generate the receiver error interrupt
-.It brknull
-Input the NUL character
-.It brkdisc
-Ignore the line break state
-.El
-.It "+inlcr, -inlcr"
-Translate received NL characters to CR.
-.It "+icrnl, -icrnl"
-Translate received CR characters to NL.
-.It "+igncr, -igncr"
-Ignore received CR characters.
-.It "+ocrnl, -ocrnl"
-Translate transmitted CR characters to NL.
-.It "+onlcr, -onlcr"
-Translate transmitted NL characters to CR.
-.It "+fcerr, -fcerr"
-Process (don't process) the characters, received with errors,
-for special character/flow control matching.
-.It "+lnext, -lnext"
-Enable the LNEXT character option: the character following
-the LNEXT character is not processed for special character/flow
-control matching.
-.It "+istrip, -istrip"
-Strip input characters to seven bits.
-.It schr1=#
-The XON flow control character value.
-.It schr2=#
-The XOFF flow control character value.
-.It schr3=#
-The SCHR3 spec. character value.
-.It schr4=#
-The SCHR4 spec. character value.
-.It "scrl=#, scrh=#
-The spec. character range (inclusive).
-.It lnext=#
-The LNEXT spec. character value.
-.El
-.Sh "HDLC mode options"
-.Bl -tag -width 10n
-.It if#
-The minimum number of flags transmitted before a frame is started.
-.It noaddr
-No frame address recognition.
-.It "addrlen1, addrlen2"
-Address field length: 1 or 2 bytes.
-.It "addr1, addr2"
-Addressing mode: 4x1 bytes or 2x2 bytes.
-Registers RFAR1..RFAR4 should contain the address to be matched.
-.It "+clrdet, -clrdet"
-Enable/disable clear detect for X.21 protocol support.
-.It "+dsr, -dsr"
-Use the DSR input signal as receiver enable/disable.
-.It "+cts, -cts"
-Use the CTS input signal as transmitter enable/disable.
-.It "+rts, -rts"
-Drive the RTS output signal as transmitter ready.
-.It "+fcs, -fcs"
-Enable/disable the frame checksum generation and checking.
-.It "crc-16, crc-v.41
-Select the CRC polynomial: CRC-16 (x^16+x^15+x^2+1)
-or CRC V.41 (x^16+x^12+x^5+1).
-.It "fcs-crc-16, fcs-v.41
-Frame checksum preset: all zeros (CRC-16) or all ones (CRC V.41).
-.It "+crcinv, -crcinv"
-Invert (ie. CRC V.41) or don't invert (ie. CRC-16) the transmitted frame checksum.
-.It "+fcsapd, -fcsapd"
-Pass the received CRC to the host at the end of receiver data buffer.
-.It "idlemark, idleflag
-Idle mode: idle in mark (transmit all ones) or idle in flag (transmit flag).
-.It "+syn, -syn"
-Enable/disable sending pad characters before sending flag when coming out
-of the idle mode.
-.It pad#
-The number of synchronous characters sent (0..4).
-.It "syn=0xaa, syn=0x00
-Send sync pattern.
-.It "rfar1=#, rfar2=#, rfar3=#, rfar4=#
-Frame address registers for address recognition.
-.El
-.Sh EXAMPLES
-Set up the channel 7 of the adapter Sigma-400 under
-.Bx Free .
-Physical 4-wire leased line with Zelax+ M115 short-range modems.
-Synchronous mode, 128000 bits/sec, interface RS-232,
-protocol PpP/HDLC without keepalive support, NRZI encoding,
-DPLL mode, no flow control:
-.Bd -literal
-cxconfig cx7 128000 hdlc ppp -keepalive nrzi -cts +dpll -extclock
-ifconfig cx7 158.250.244.2 158.250.244.1 up
-.Ed
-.Pp
-Set up the channel 0 of the adapter Sigma-100 under
-.Bx Free .
-Attachment to the near computer by short cable, internal clock source.
-Synchronous mode, 256000 bits/sec, interface RS-232,
-protocol Cisco/HDLC with keepalive support:
-.Bd -literal
-cxconfig cx0 hdlc 256000 cisco +keepalive -extclock
-ifconfig cx0 200.1.1.1 200.1.1.2 up
-.Ed
-.Pp
-Set up the channel 1 of the adapter Sigma-840 under BSD/386.
-Synchronous 64 kbit/sec leased line, external clock source.
-Synchronous mode, interface V.35, external protocol suite:
-.Bd -literal
-cxconfig cx1 hdlc ext
-ifconfig cx1 193.124.254.50 193.124.254.49 multicast up
-.Ed
-.Pp
-Set up the channel 0 of the adapter Sigma-840 under
-.Bx Free .
-Attachment to the Cisco-4000 router by null-modem cable, internal clock source.
-Synchronous mode, 64000 bits/sec, interface RS-232,
-protocol PpP/HDLC with keepalive support and flow control,
-LCP and IPCP protocols (see RFC-1548 and RFC-1332) debug tracing enabled:
-.Bd -literal
-cxconfig cx0 hdlc 64000 port=rs232 ppp +keepalive -extclock +cts
-ifconfig cx0 100.0.0.2 100.0.0.1 debug up
-.Ed
-.Sh FILES
-.Bl -tag -width /dev/cronyx -compact
-.Pa /dev/cronyx
-the special device file for adapter options management
-.El
-.Sh SEE ALSO
-.Xr cx 4
diff --git a/sbin/cxconfig/cxconfig.c b/sbin/cxconfig/cxconfig.c
deleted file mode 100644
index 3ae000d58f4b..000000000000
--- a/sbin/cxconfig/cxconfig.c
+++ /dev/null
@@ -1,749 +0,0 @@
-/*
- * Cronyx-Sigma adapter configuration utility for Unix.
- *
- * Copyright (C) 1994 Cronyx Ltd.
- * Author: Serge Vakulenko, <vak@zebub.msk.su>
- *
- * This software is distributed with NO WARRANTIES, not even the implied
- * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Authors grant any other persons or organisations permission to use
- * or modify this software as long as this message is kept with the software,
- * all derivative works or modified versions.
- *
- * Version 1.9, Wed Oct 4 18:58:15 MSK 1995
- *
- * Usage:
- * cxconfig [-a]
- * -- print status of all channels
- * cxconfig [-a] <channel>
- * -- print status of the channel
- * cxconfig <channel> <option>...
- * -- set channel options
- */
-
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <err.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <machine/cronyx.h>
-#include <net/if.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#define NBRD 3
-#define CXDEV "/dev/cronyx"
-#define atoi(a) strtol((a), (char**)0, 0)
-
-cx_options_t o;
-cx_stat_t st;
-int aflag;
-int sflag;
-
-char *symbol (unsigned char sym)
-{
- static char buf[40];
-
- if (sym < ' ')
- sprintf (buf, "^%c", sym+0100);
- else if (sym == '\\')
- strcat (buf, "\\\\");
- else if (sym < 127)
- sprintf (buf, "%c", sym);
- else
- sprintf (buf, "\\%03o", sym);
- return (buf);
-}
-
-unsigned char atosym (char *s)
-{
- if (*s == '^')
- return (*++s & 037);
- if (*s == '\\')
- return (strtol (++s, 0, 8));
- return (*s);
-}
-
-void usage ()
-{
- fprintf (stderr,
- "Cronyx-Sigma Adapter Configuration Utility, Version 1.0\n");
- fprintf (stderr, "Copyright (C) 1994 Cronyx Ltd.\n");
- fprintf (stderr, "usage: cxconfig [-a] [<channel> [<option>...]]\n");
- exit (1);
-}
-
-char *chantype (int type)
-{
- switch (type) {
- case T_NONE: return ("none");
- case T_ASYNC: return ("RS-232");
- case T_UNIV_RS232: return ("RS-232");
- case T_UNIV_RS449: return ("RS-232/RS-449");
- case T_UNIV_V35: return ("RS-232/V.35");
- case T_SYNC_RS232: return ("RS-232");
- case T_SYNC_V35: return ("V.35");
- case T_SYNC_RS449: return ("RS-449");
- }
-}
-
-char *chanmode (int mode)
-{
- switch (mode) {
- case M_ASYNC: return ("Async");
- case M_HDLC: return ("HDLC");
- case M_BISYNC: return ("Bisync");
- case M_X21: return ("X.21");
- default: return ("???");
- }
-}
-
-void getchan (int channel)
-{
- int s = open (CXDEV, 0);
- if (s < 0)
- err (1, "%s", CXDEV);
- o.board = channel/NCHAN;
- o.channel = channel%NCHAN;
- if (ioctl (s, CXIOCGETMODE, (caddr_t)&o) < 0)
- err (1, "CXIOCGETMODE");
- close (s);
- if (o.type == T_NONE)
- errx (1, "cx%d: channel %d not configured", o.board,
- o.channel);
-}
-
-int printstats (int channel, int hflag)
-{
- int s, res;
-
- s = open (CXDEV, 0);
- if (s < 0)
- err (1, "%s", CXDEV);
- st.board = channel/NCHAN;
- st.channel = channel%NCHAN;
- res = ioctl (s, CXIOCGETSTAT, (caddr_t)&st);
- close (s);
- if (res < 0)
- return (-1);
-
- if (hflag)
- printf ("Chan Rintr Tintr Mintr Ibytes Ipkts Ierrs Obytes Opkts Oerrs\n");
- printf ("cx%-2d %7ld %7ld %7ld %8ld %7ld %7ld %8ld %7ld %7ld\n",
- channel, st.rintr, st.tintr, st.mintr, st.ibytes, st.ipkts,
- st.ierrs, st.obytes, st.opkts, st.oerrs);
- return (0);
-}
-
-void printallstats ()
-{
- int b, c;
-
- printf ("Chan Rintr Tintr Mintr Ibytes Ipkts Ierrs Obytes Opkts Oerrs\n");
- for (b=0; b<NBRD; ++b)
- for (c=0; c<NCHAN; ++c)
- printstats (b*NCHAN + c, 0);
-}
-
-void setchan (int channel)
-{
- int s = open (CXDEV, 0);
- if (s < 0)
- err (1, "%s", CXDEV);
- o.board = channel/NCHAN;
- o.channel = channel%NCHAN;
- if (ioctl (s, CXIOCSETMODE, (caddr_t)&o) < 0)
- err (1, "CXIOCSETMODE");
- close (s);
-}
-
-void printopt ()
-{
- /* Common channel options */
- /* channel option register 4 */
- printf ("\t");
- printf ("fifo=%d ", o.opt.cor4.thr); /* FIFO threshold */
- printf ("%cctsdown ", o.opt.cor4.cts_zd ? '+' : '-'); /* detect 1 to 0 transition on the CTS */
- printf ("%ccddown ", o.opt.cor4.cd_zd ? '+' : '-'); /* detect 1 to 0 transition on the CD */
- printf ("%cdsrdown ", o.opt.cor4.dsr_zd ? '+' : '-'); /* detect 1 to 0 transition on the DSR */
- printf ("\n");
-
- /* channel option register 5 */
- printf ("\t");
- printf ("rfifo=%d ", o.opt.cor5.rx_thr); /* receive flow control FIFO threshold */
- printf ("%cctsup ", o.opt.cor5.cts_od ? '+' : '-'); /* detect 0 to 1 transition on the CTS */
- printf ("%ccdup ", o.opt.cor5.cd_od ? '+' : '-'); /* detect 0 to 1 transition on the CD */
- printf ("%cdsrup ", o.opt.cor5.dsr_od ? '+' : '-'); /* detect 0 to 1 transition on the DSR */
- printf ("\n");
-
- /* receive clock option register */
- printf ("\t");
- printf ("%s ", o.opt.rcor.encod == ENCOD_NRZ ? "nrz" : /* signal encoding */
- o.opt.rcor.encod == ENCOD_NRZI ? "nrzi" :
- o.opt.rcor.encod == ENCOD_MANCHESTER ? "manchester" : "???");
- printf ("%cdpll ", o.opt.rcor.dpll ? '+' : '-'); /* DPLL enable */
-
- /* transmit clock option register */
- printf ("%clloop ", o.opt.tcor.llm ? '+' : '-'); /* local loopback mode */
- printf ("%cextclock ", o.opt.tcor.ext1x ? '+' : '-'); /* external 1x clock mode */
- printf ("\n");
-
- switch (o.mode) {
- case M_ASYNC: /* async mode options */
- /* channel option register 1 */
- printf ("\t");
- printf ("cs%d ", o.aopt.cor1.charlen+1); /* character length, 5..8 */
- printf ("par%s ", o.aopt.cor1.parity ? "odd" : "even"); /* parity */
- printf ("%cignpar ", o.aopt.cor1.ignpar ? '+' : '-'); /* ignore parity */
- if (o.aopt.cor1.parmode != PARM_NORMAL) /* parity mode */
- printf ("%s ", o.aopt.cor1.parmode == PARM_NOPAR ? "nopar" :
- o.aopt.cor1.parmode == PARM_FORCE ? "forcepar" : "???");
- printf ("\n");
-
- /* channel option register 2 */
- printf ("\t");
- printf ("%cdsr ", o.aopt.cor2.dsrae ? '+' : '-'); /* DSR automatic enable */
- printf ("%ccts ", o.aopt.cor2.ctsae ? '+' : '-'); /* CTS automatic enable */
- printf ("%crts ", o.aopt.cor2.rtsao ? '+' : '-'); /* RTS automatic output enable */
- printf ("%crloop ", o.aopt.cor2.rlm ? '+' : '-'); /* remote loopback mode enable */
- printf ("%cetc ", o.aopt.cor2.etc ? '+' : '-'); /* embedded transmitter cmd enable */
- printf ("%cxon ", o.aopt.cor2.ixon ? '+' : '-'); /* in-band XON/XOFF enable */
- printf ("%cxany ", o.aopt.cor2.ixany ? '+' : '-'); /* XON on any character */
- printf ("\n");
-
- /* option register 3 */
- printf ("\t");
- printf ("%s ", o.aopt.cor3.stopb == STOPB_1 ? "stopb1" : /* stop bit length */
- o.aopt.cor3.stopb == STOPB_15 ? "stopb1.5" :
- o.aopt.cor3.stopb == STOPB_2 ? "stopb2" : "???");
- printf ("%csdt ", o.aopt.cor3.scde ? '+' : '-'); /* special char detection enable */
- printf ("%cflowct ", o.aopt.cor3.flowct ? '+' : '-'); /* flow control transparency mode */
- printf ("%crdt ", o.aopt.cor3.rngde ? '+' : '-'); /* range detect enable */
- printf ("%cexdt ", o.aopt.cor3.escde ? '+' : '-'); /* extended spec. char detect enable */
- printf ("\n");
-
- /* channel option register 6 */
- printf ("\t");
- printf ("%s ", o.aopt.cor6.parerr == PERR_INTR ? "parintr" : /* parity/framing error actions */
- o.aopt.cor6.parerr == PERR_NULL ? "parnull" :
- o.aopt.cor6.parerr == PERR_IGNORE ? "parign" :
- o.aopt.cor6.parerr == PERR_DISCARD ? "pardisc" :
- o.aopt.cor6.parerr == PERR_FFNULL ? "parffnull" : "???");
- printf ("%s ", o.aopt.cor6.brk == BRK_INTR ? "brkintr" : /* action on break condition */
- o.aopt.cor6.brk == BRK_NULL ? "brknull" :
- o.aopt.cor6.brk == BRK_DISCARD ? "brkdisc" : "???");
- printf ("%cinlcr ", o.aopt.cor6.inlcr ? '+' : '-'); /* translate NL to CR on input */
- printf ("%cicrnl ", o.aopt.cor6.icrnl ? '+' : '-'); /* translate CR to NL on input */
- printf ("%cigncr ", o.aopt.cor6.igncr ? '+' : '-'); /* discard CR on input */
- printf ("\n");
-
- /* channel option register 7 */
- printf ("\t");
- printf ("%cocrnl ", o.aopt.cor7.ocrnl ? '+' : '-'); /* translate CR to NL on output */
- printf ("%conlcr ", o.aopt.cor7.onlcr ? '+' : '-'); /* translate NL to CR on output */
- printf ("%cfcerr ", o.aopt.cor7.fcerr ? '+' : '-'); /* process flow ctl err chars enable */
- printf ("%clnext ", o.aopt.cor7.lnext ? '+' : '-'); /* LNext option enable */
- printf ("%cistrip ", o.aopt.cor7.istrip ? '+' : '-'); /* strip 8-bit on input */
- printf ("\n");
-
- printf ("\t");
- printf ("schr1=%s ", symbol (o.aopt.schr1)); /* special character register 1 (XON) */
- printf ("schr2=%s ", symbol (o.aopt.schr2)); /* special character register 2 (XOFF) */
- printf ("schr3=%s ", symbol (o.aopt.schr3)); /* special character register 3 */
- printf ("schr4=%s ", symbol (o.aopt.schr4)); /* special character register 4 */
- printf ("scrl=%s ", symbol (o.aopt.scrl)); /* special character range low */
- printf ("scrh=%s ", symbol (o.aopt.scrh)); /* special character range high */
- printf ("lnext=%s ", symbol (o.aopt.lnxt)); /* LNext character */
- printf ("\n");
- break;
-
- case M_HDLC: /* hdlc mode options */
- /* hdlc channel option register 1 */
- printf ("\t");
- printf ("if%d ", o.hopt.cor1.ifflags); /* number of inter-frame flags sent */
- printf ("%s ", o.hopt.cor1.admode == ADMODE_NOADDR ? "noaddr" : /* addressing mode */
- o.hopt.cor1.admode == ADMODE_4_1 ? "addr1" :
- o.hopt.cor1.admode == ADMODE_2_2 ? "addr2" : "???");
- printf ("%cclrdet ", o.hopt.cor1.clrdet ? '+' : '-'); /* clear detect for X.21 data transfer phase */
- printf ("addrlen%d ", o.hopt.cor1.aflo + 1); /* address field length option */
- printf ("\n");
-
- /* hdlc channel option register 2 */
- printf ("\t");
- printf ("%cdsr ", o.hopt.cor2.dsrae ? '+' : '-'); /* DSR automatic enable */
- printf ("%ccts ", o.hopt.cor2.ctsae ? '+' : '-'); /* CTS automatic enable */
- printf ("%crts ", o.hopt.cor2.rtsao ? '+' : '-'); /* RTS automatic output enable */
- printf ("%ccrcinv ", o.hopt.cor2.crcninv ? '-' : '+'); /* CRC invertion option */
- printf ("%cfcsapd ", o.hopt.cor2.fcsapd ? '+' : '-'); /* FCS append */
- printf ("\n");
-
- /* hdlc channel option register 3 */
- printf ("\t");
- printf ("pad%d ", o.hopt.cor3.padcnt); /* pad character count */
- printf ("idle%s ", o.hopt.cor3.idle ? "mark" : "flag"); /* idle mode */
- printf ("%cfcs ", o.hopt.cor3.nofcs ? '-' : '+'); /* FCS disable */
- printf ("fcs-%s ", o.hopt.cor3.fcspre ? "crc-16" : "v.41"); /* FCS preset */
- printf ("syn=%s ", o.hopt.cor3.syncpat ? "0xAA" : "0x00"); /* send sync pattern */
- printf ("%csyn ", o.hopt.cor3.sndpad ? '+' : '-'); /* send pad characters before flag enable */
- printf ("\n");
-
- printf ("\t");
- printf ("rfar1=0x%02x ", o.hopt.rfar1); /* receive frame address register 1 */
- printf ("rfar2=0x%02x ", o.hopt.rfar2); /* receive frame address register 2 */
- printf ("rfar3=0x%02x ", o.hopt.rfar3); /* receive frame address register 3 */
- printf ("rfar4=0x%02x ", o.hopt.rfar4); /* receive frame address register 4 */
- printf ("crc-%s ", o.hopt.cpsr ? "16" : "v.41"); /* CRC polynomial select */
- printf ("\n");
- break;
-
- case M_BISYNC: /* bisync mode options */
- /* channel option register 1 */
- printf ("\t");
- printf ("cs%d ", o.bopt.cor1.charlen+1); /* character length, 5..8 */
- printf ("par%s ", o.bopt.cor1.parity ? "odd" : "even"); /* parity */
- printf ("%cignpar ", o.bopt.cor1.ignpar ? '+' : '-'); /* ignore parity */
- if (o.bopt.cor1.parmode != PARM_NORMAL) /* parity mode */
- printf ("%s ", o.bopt.cor1.parmode == PARM_NOPAR ? "nopar" :
- o.bopt.cor1.parmode == PARM_FORCE ? "forcepar" : "???");
- printf ("\n");
-
- /* channel option register 2 */
- printf ("\t");
- printf ("syn%d ", o.bopt.cor2.syns+2); /* number of extra SYN chars before a frame */
- printf ("%ccrcinv ", o.bopt.cor2.crcninv ? '-' : '+'); /* CRC invertion option */
- printf ("%s ", o.bopt.cor2.ebcdic ? "ebcdic" : "ascii"); /* use EBCDIC as char set (instead of ASCII) */
- printf ("%cbccapd ", o.bopt.cor2.bcc ? '+' : '-'); /* BCC append enable */
- printf ("%s ", o.bopt.cor2.lrc ? "lrc" : "crc-16"); /* longitudinal redundancy check */
- printf ("\n");
-
- /* channel option register 3 */
- printf ("\t");
- printf ("pad%d ", o.bopt.cor3.padcnt); /* pad character count */
- printf ("idle%s ", o.bopt.cor3.idle ? "mark" : "syn"); /* idle mode */
- printf ("%cfcs ", o.bopt.cor3.nofcs ? '-' : '+'); /* FCS disable */
- printf ("fcs-%s ", o.bopt.cor3.fcspre ? "crc-16" : "v.41"); /* FCS preset */
- printf ("syn=%s ", o.bopt.cor3.padpat ? "0x55" : "0xAA"); /* send sync pattern */
- printf ("%csyn ", o.bopt.cor3.sndpad ? '+' : '-'); /* send pad characters before flag enable */
- printf ("\n");
-
- /* channel option register 6 */
- printf ("\t");
- printf ("specterm=%s ", symbol (o.bopt.cor6.specterm)); /* special termination character */
-
- printf ("crc-%s ", o.bopt.cpsr ? "16" : "v.41"); /* CRC polynomial select */
- printf ("\n");
- break;
-
- case M_X21: /* x.21 mode options */
- /* channel option register 1 */
- printf ("\t");
- printf ("cs%d ", o.xopt.cor1.charlen+1); /* character length, 5..8 */
- printf ("par%s ", o.xopt.cor1.parity ? "odd" : "even"); /* parity */
- printf ("%cignpar ", o.xopt.cor1.ignpar ? '+' : '-'); /* ignore parity */
- if (o.xopt.cor1.parmode != PARM_NORMAL) /* parity mode */
- printf ("%s ", o.xopt.cor1.parmode == PARM_NOPAR ? "nopar" :
- o.xopt.cor1.parmode == PARM_FORCE ? "forcepar" : "???");
- printf ("\n");
-
- /* channel option register 2 */
- printf ("\t");
- printf ("%cetc ", o.xopt.cor2.etc ? '+' : '-'); /* embedded transmitter cmd enable */
-
- /* channel option register 3 */
- printf ("%csdt ", o.xopt.cor3.scde ? '+' : '-'); /* special char detection enable */
- printf ("%cstripsyn ", o.xopt.cor3.stripsyn ? '+' : '-'); /* treat SYN chars as special condition */
- printf ("%cssdt ", o.xopt.cor3.ssde ? '+' : '-'); /* steady state detect enable */
- printf ("syn%c ", o.xopt.cor3.syn ? '1' : '2'); /* the number of SYN chars on receive */
- printf ("\n");
-
- /* channel option register 6 */
- printf ("\t");
- printf ("syn=%s ", symbol (o.xopt.cor6.synchar)); /* syn character */
-
- printf ("schr1=%s ", symbol (o.xopt.schr1)); /* special character register 1 */
- printf ("schr2=%s ", symbol (o.xopt.schr2)); /* special character register 2 */
- printf ("schr3=%s ", symbol (o.xopt.schr3)); /* special character register 3 */
- printf ("\n");
- break;
- }
-}
-
-void printchan (int channel)
-{
- printf ("cx%d (%s) %s", channel, chantype (o.type), chanmode (o.mode));
- if (o.txbaud == o.rxbaud)
- printf (" %d", o.rxbaud);
- else
- printf (" ospeed=%d ispeed=%d", o.txbaud, o.rxbaud);
- if ((o.channel == 0 || o.channel == 8) &&
- (o.type == T_UNIV_V35 || o.type == T_UNIV_RS449))
- printf (" port=%s", o.iftype ? (o.type == T_UNIV_V35 ?
- "v35" : "rs449") : "rs232");
- printf (o.sopt.ext ? " ext" : o.sopt.cisco ? " cisco" : " ppp");
- printf (" %ckeepalive", o.sopt.keepalive ? '+' : '-');
- printf (" %cautorts", o.sopt.norts ? '-' : '+');
- if (*o.master)
- printf (" master=%s", o.master);
- printf ("\n");
- if (aflag)
- printopt ();
-}
-
-void printall ()
-{
- struct ifconf ifc;
- struct ifreq *ifr;
- char buf[BUFSIZ], *cp;
- int s, c;
-
- s = socket (AF_INET, SOCK_DGRAM, 0);
- if (s < 0)
- err (1, "socket");
- ifc.ifc_len = sizeof (buf);
- ifc.ifc_buf = buf;
- if (ioctl (s, SIOCGIFCONF, (caddr_t)&ifc) < 0)
- err (1, "SIOCGIFCONF");
- close (s);
- s = open (CXDEV, 0);
- if (s < 0)
- err (1, "%s", CXDEV);
-
- ifr = ifc.ifc_req;
-#define max(a,b) ((a)>(b) ? (a) : (b))
-#define size(p) max((p).sa_len, sizeof(p))
- for (cp=buf; cp<buf+ifc.ifc_len; cp+=sizeof(ifr->ifr_name)+size(ifr->ifr_addr)) {
- ifr = (struct ifreq*) cp;
- if (ifr->ifr_addr.sa_family != AF_LINK)
- continue;
- if (strncmp (ifr->ifr_name, "cx", 2) != 0)
- continue;
- c = atoi (ifr->ifr_name + 2);
- o.board = c/NCHAN;
- o.channel = c%NCHAN;
- if (ioctl (s, CXIOCGETMODE, (caddr_t)&o) < 0)
- err (1, "CXIOCGETMODE");
- printchan (c);
- }
- close (s);
-}
-
-void set_interface_type (char *type)
-{
- if (o.channel != 0 && o.channel != 8) {
- printf ("interface option is applicable only for channels 0 and 8\n");
- exit (1);
- }
- if (o.type != T_UNIV_V35 && o.type != T_UNIV_RS449) {
- printf ("interface option is applicable only for universal channels\n");
- exit (1);
- }
- if (! strcasecmp (type, "port=rs232"))
- o.iftype = 0;
- else
- o.iftype = 1;
-}
-
-void set_master (char *ifname)
-{
- if (o.type == T_ASYNC) {
- printf ("master option is not applicable for async channels\n");
- exit (1);
- }
- strcpy (o.master, ifname);
-}
-
-void set_async_opt (char *opt)
-{
- /* channel option register 1 */
- if (! strncasecmp (opt, "cs", 2)) o.aopt.cor1.charlen = atoi (opt + 2) - 1;
- else if (! strcasecmp (opt, "parodd")) o.aopt.cor1.parity = 1;
- else if (! strcasecmp (opt, "pareven")) o.aopt.cor1.parity = 0;
- else if (! strcasecmp (opt, "-ignpar")) o.aopt.cor1.ignpar = 0;
- else if (! strcasecmp (opt, "+ignpar")) o.aopt.cor1.ignpar = 1;
- else if (! strcasecmp (opt, "nopar")) o.aopt.cor1.parmode = PARM_NOPAR;
- else if (! strcasecmp (opt, "forcepar")) o.aopt.cor1.parmode = PARM_FORCE;
-
- /* channel option register 2 */
- else if (! strcasecmp (opt, "-dsr")) o.aopt.cor2.dsrae = 0;
- else if (! strcasecmp (opt, "+dsr")) o.aopt.cor2.dsrae = 1;
- else if (! strcasecmp (opt, "-cts")) o.aopt.cor2.ctsae = 0;
- else if (! strcasecmp (opt, "+cts")) o.aopt.cor2.ctsae = 1;
- else if (! strcasecmp (opt, "-rts")) o.aopt.cor2.rtsao = 0;
- else if (! strcasecmp (opt, "+rts")) o.aopt.cor2.rtsao = 1;
- else if (! strcasecmp (opt, "-rloop")) o.aopt.cor2.rlm = 0;
- else if (! strcasecmp (opt, "+rloop")) o.aopt.cor2.rlm = 1;
- else if (! strcasecmp (opt, "-etc")) o.aopt.cor2.etc = 0;
- else if (! strcasecmp (opt, "+etc")) o.aopt.cor2.etc = 1;
- else if (! strcasecmp (opt, "-ixon")) o.aopt.cor2.ixon = 0;
- else if (! strcasecmp (opt, "+ixon")) o.aopt.cor2.ixon = 1;
- else if (! strcasecmp (opt, "-ixany")) o.aopt.cor2.ixany = 0;
- else if (! strcasecmp (opt, "+ixany")) o.aopt.cor2.ixany = 1;
-
- /* option register 3 */
- else if (! strcasecmp (opt, "stopb1")) o.aopt.cor3.stopb = STOPB_1;
- else if (! strcasecmp (opt, "stopb1.5")) o.aopt.cor3.stopb = STOPB_15;
- else if (! strcasecmp (opt, "stopb2")) o.aopt.cor3.stopb = STOPB_2;
- else if (! strcasecmp (opt, "-sdt")) o.aopt.cor3.scde = 0;
- else if (! strcasecmp (opt, "+sdt")) o.aopt.cor3.scde = 1;
- else if (! strcasecmp (opt, "-flowct")) o.aopt.cor3.flowct = 0;
- else if (! strcasecmp (opt, "+flowct")) o.aopt.cor3.flowct = 1;
- else if (! strcasecmp (opt, "-rdt")) o.aopt.cor3.rngde = 0;
- else if (! strcasecmp (opt, "+rdt")) o.aopt.cor3.rngde = 1;
- else if (! strcasecmp (opt, "-exdt")) o.aopt.cor3.escde = 0;
- else if (! strcasecmp (opt, "+exdt")) o.aopt.cor3.escde = 1;
-
- /* channel option register 6 */
- else if (! strcasecmp (opt, "parintr")) o.aopt.cor6.parerr = PERR_INTR;
- else if (! strcasecmp (opt, "parnull")) o.aopt.cor6.parerr = PERR_NULL;
- else if (! strcasecmp (opt, "parign")) o.aopt.cor6.parerr = PERR_IGNORE;
- else if (! strcasecmp (opt, "pardisc")) o.aopt.cor6.parerr = PERR_DISCARD;
- else if (! strcasecmp (opt, "parffnull")) o.aopt.cor6.parerr = PERR_FFNULL;
- else if (! strcasecmp (opt, "brkintr")) o.aopt.cor6.brk = BRK_INTR;
- else if (! strcasecmp (opt, "brknull")) o.aopt.cor6.brk = BRK_NULL;
- else if (! strcasecmp (opt, "brkdisc")) o.aopt.cor6.brk = BRK_DISCARD;
- else if (! strcasecmp (opt, "-inlcr")) o.aopt.cor6.inlcr = 0;
- else if (! strcasecmp (opt, "+inlcr")) o.aopt.cor6.inlcr = 1;
- else if (! strcasecmp (opt, "-icrnl")) o.aopt.cor6.icrnl = 0;
- else if (! strcasecmp (opt, "+icrnl")) o.aopt.cor6.icrnl = 1;
- else if (! strcasecmp (opt, "-igncr")) o.aopt.cor6.igncr = 0;
- else if (! strcasecmp (opt, "+igncr")) o.aopt.cor6.igncr = 1;
-
- /* channel option register 7 */
- else if (! strcasecmp (opt, "-ocrnl")) o.aopt.cor7.ocrnl = 0;
- else if (! strcasecmp (opt, "+ocrnl")) o.aopt.cor7.ocrnl = 1;
- else if (! strcasecmp (opt, "-onlcr")) o.aopt.cor7.onlcr = 0;
- else if (! strcasecmp (opt, "+onlcr")) o.aopt.cor7.onlcr = 1;
- else if (! strcasecmp (opt, "-fcerr")) o.aopt.cor7.fcerr = 0;
- else if (! strcasecmp (opt, "+fcerr")) o.aopt.cor7.fcerr = 1;
- else if (! strcasecmp (opt, "-lnext")) o.aopt.cor7.lnext = 0;
- else if (! strcasecmp (opt, "+lnext")) o.aopt.cor7.lnext = 1;
- else if (! strcasecmp (opt, "-istrip")) o.aopt.cor7.istrip = 0;
- else if (! strcasecmp (opt, "+istrip")) o.aopt.cor7.istrip = 1;
-
- else if (! strncasecmp (opt, "schr1=", 6)) o.aopt.schr1 = atosym (opt+6);
- else if (! strncasecmp (opt, "schr2=", 6)) o.aopt.schr2 = atosym (opt+6);
- else if (! strncasecmp (opt, "schr3=", 6)) o.aopt.schr3 = atosym (opt+6);
- else if (! strncasecmp (opt, "schr4=", 6)) o.aopt.schr4 = atosym (opt+6);
- else if (! strncasecmp (opt, "scrl=", 5)) o.aopt.scrl = atosym (opt+5);
- else if (! strncasecmp (opt, "scrh=", 5)) o.aopt.scrh = atosym (opt+5);
- else if (! strncasecmp (opt, "lnext=", 6)) o.aopt.lnxt = atosym (opt+6);
- else
- usage ();
-}
-
-void set_hdlc_opt (char *opt)
-{
- /* hdlc channel option register 1 */
- if (! strncasecmp (opt, "if", 2)) o.hopt.cor1.ifflags = atoi (opt + 2);
- else if (! strcasecmp (opt, "noaddr")) o.hopt.cor1.admode = ADMODE_NOADDR;
- else if (! strcasecmp (opt, "addr1")) o.hopt.cor1.admode = ADMODE_4_1;
- else if (! strcasecmp (opt, "addr2")) o.hopt.cor1.admode = ADMODE_2_2;
- else if (! strcasecmp (opt, "-clrdet")) o.hopt.cor1.clrdet = 0;
- else if (! strcasecmp (opt, "+clrdet")) o.hopt.cor1.clrdet = 1;
- else if (! strcasecmp (opt, "addrlen1")) o.hopt.cor1.aflo = 0;
- else if (! strcasecmp (opt, "addrlen2")) o.hopt.cor1.aflo = 1;
-
- /* hdlc channel option register 2 */
- else if (! strcasecmp (opt, "-dsr")) o.hopt.cor2.dsrae = 0;
- else if (! strcasecmp (opt, "+dsr")) o.hopt.cor2.dsrae = 1;
- else if (! strcasecmp (opt, "-cts")) o.hopt.cor2.ctsae = 0;
- else if (! strcasecmp (opt, "+cts")) o.hopt.cor2.ctsae = 1;
- else if (! strcasecmp (opt, "-rts")) o.hopt.cor2.rtsao = 0;
- else if (! strcasecmp (opt, "+rts")) o.hopt.cor2.rtsao = 1;
- else if (! strcasecmp (opt, "-fcsapd")) o.hopt.cor2.fcsapd = 0;
- else if (! strcasecmp (opt, "+fcsapd")) o.hopt.cor2.fcsapd = 1;
- else if (! strcasecmp (opt, "-crcinv")) o.hopt.cor2.crcninv = 1;
- else if (! strcasecmp (opt, "+crcinv")) o.hopt.cor2.crcninv = 0;
-
- /* hdlc channel option register 3 */
- else if (! strncasecmp (opt, "pad", 3)) o.hopt.cor3.padcnt = atoi (opt + 3);
- else if (! strcasecmp (opt, "idlemark")) o.hopt.cor3.idle = 1;
- else if (! strcasecmp (opt, "idleflag")) o.hopt.cor3.idle = 0;
- else if (! strcasecmp (opt, "-fcs")) o.hopt.cor3.nofcs = 1;
- else if (! strcasecmp (opt, "+fcs")) o.hopt.cor3.nofcs = 0;
- else if (! strcasecmp (opt, "fcs-crc-16")) o.hopt.cor3.fcspre = 1;
- else if (! strcasecmp (opt, "fcs-v.41")) o.hopt.cor3.fcspre = 0;
- else if (! strcasecmp (opt, "syn=0xaa")) o.hopt.cor3.syncpat = 1;
- else if (! strcasecmp (opt, "syn=0x00")) o.hopt.cor3.syncpat = 0;
- else if (! strcasecmp (opt, "-syn")) o.hopt.cor3.sndpad = 0;
- else if (! strcasecmp (opt, "+syn")) o.hopt.cor3.sndpad = 1;
-
- else if (! strncasecmp (opt, "rfar1=", 6)) o.hopt.rfar1 = atoi (opt + 6);
- else if (! strncasecmp (opt, "rfar2=", 6)) o.hopt.rfar2 = atoi (opt + 6);
- else if (! strncasecmp (opt, "rfar3=", 6)) o.hopt.rfar3 = atoi (opt + 6);
- else if (! strncasecmp (opt, "rfar4=", 6)) o.hopt.rfar4 = atoi (opt + 6);
- else if (! strcasecmp (opt, "crc-16")) o.hopt.cpsr = 1;
- else if (! strcasecmp (opt, "crc-v.41")) o.hopt.cpsr = 0;
- else usage ();
-}
-
-void set_bisync_opt (char *opt)
-{
- usage ();
-}
-
-void set_x21_opt (char *opt)
-{
- usage ();
-}
-
-int main (int argc, char **argv)
-{
- int channel;
-
- for (--argc, ++argv; argc>0 && **argv=='-'; --argc, ++argv)
- if (! strcasecmp (*argv, "-a"))
- ++aflag;
- else if (! strcasecmp (*argv, "-s"))
- ++sflag;
- else
- usage ();
-
- if (argc <= 0) {
- if (sflag)
- printallstats ();
- else
- printall ();
- return (0);
- }
-
- if (argv[0][0]=='c' && argv[0][1]=='x')
- *argv += 2;
- if (**argv<'0' || **argv>'9')
- usage ();
- channel = atoi (*argv);
- --argc, ++argv;
-
- if (sflag) {
- if (printstats (channel, 1) < 0)
- printf ("channel cx%d not available\n", channel);
- return (0);
- }
-
- getchan (channel);
-
- if (argc <= 0) {
- printchan (channel);
- return (0);
- }
-
- for (; argc>0; --argc, ++argv)
- if (**argv == '(')
- continue;
- else if (! strncasecmp (*argv, "ispeed=", 7))
- o.rxbaud = atoi (*argv+7);
- else if (! strncasecmp (*argv, "ospeed=", 7))
- o.txbaud = atoi (*argv+7);
- else if (! strcasecmp (*argv, "async"))
- o.mode = M_ASYNC;
- else if (! strcasecmp (*argv, "hdlc"))
- o.mode = M_HDLC;
- else if (! strcasecmp (*argv, "bisync") ||
- ! strcasecmp (*argv, "bsc"))
- o.mode = M_BISYNC;
- else if (! strcasecmp (*argv, "x.21") ||
- ! strcasecmp (*argv, "x21"))
- o.mode = M_X21;
- else if (**argv>='0' && **argv<='9')
- o.txbaud = o.rxbaud = atoi (*argv);
- else if (! strcasecmp (*argv, "cisco")) {
- o.sopt.cisco = 1;
- o.sopt.ext = 0;
- } else if (! strcasecmp (*argv, "ppp")) {
- o.sopt.cisco = 0;
- o.sopt.ext = 0;
- } else if (! strcasecmp (*argv, "ext"))
- o.sopt.ext = 1;
- else if (! strcasecmp (*argv, "+keepalive"))
- o.sopt.keepalive = 1;
- else if (! strcasecmp (*argv, "-keepalive"))
- o.sopt.keepalive = 0;
- else if (! strcasecmp (*argv, "+autorts"))
- o.sopt.norts = 0;
- else if (! strcasecmp (*argv, "-autorts"))
- o.sopt.norts = 1;
- else if (! strcasecmp (*argv, "port=rs232") ||
- ! strcasecmp (*argv, "port=rs449") ||
- ! strcasecmp (*argv, "port=v35"))
- set_interface_type (*argv);
- else if (! strncasecmp (*argv, "master=",7))
- set_master (*argv+7);
-
- /*
- * Common channel options
- */
- /* channel option register 4 */
- else if (! strcasecmp (*argv, "-ctsdown"))
- o.opt.cor4.cts_zd = 0;
- else if (! strcasecmp (*argv, "+ctsdown"))
- o.opt.cor4.cts_zd = 1;
- else if (! strcasecmp (*argv, "-cddown"))
- o.opt.cor4.cd_zd = 0;
- else if (! strcasecmp (*argv, "+cddown"))
- o.opt.cor4.cd_zd = 1;
- else if (! strcasecmp (*argv, "-dsrdown"))
- o.opt.cor4.dsr_zd = 0;
- else if (! strcasecmp (*argv, "+dsrdown"))
- o.opt.cor4.dsr_zd = 1;
- else if (! strncasecmp (*argv, "fifo=", 5))
- o.opt.cor4.thr = atoi (*argv + 5);
-
- /* channel option register 5 */
- else if (! strcasecmp (*argv, "-ctsup"))
- o.opt.cor5.cts_od = 0;
- else if (! strcasecmp (*argv, "+ctsup"))
- o.opt.cor5.cts_od = 1;
- else if (! strcasecmp (*argv, "-cdup"))
- o.opt.cor5.cd_od = 0;
- else if (! strcasecmp (*argv, "+cdup"))
- o.opt.cor5.cd_od = 1;
- else if (! strcasecmp (*argv, "-dsrup"))
- o.opt.cor5.dsr_od = 0;
- else if (! strcasecmp (*argv, "+dsrup"))
- o.opt.cor5.dsr_od = 1;
- else if (! strncasecmp (*argv, "rfifo=", 6))
- o.opt.cor5.rx_thr = atoi (*argv + 6);
-
- /* receive clock option register */
- else if (! strcasecmp (*argv, "nrz"))
- o.opt.rcor.encod = ENCOD_NRZ;
- else if (! strcasecmp (*argv, "nrzi"))
- o.opt.rcor.encod = ENCOD_NRZI;
- else if (! strcasecmp (*argv, "manchester"))
- o.opt.rcor.encod = ENCOD_MANCHESTER;
- else if (! strcasecmp (*argv, "-dpll"))
- o.opt.rcor.dpll = 0;
- else if (! strcasecmp (*argv, "+dpll"))
- o.opt.rcor.dpll = 1;
-
- /* transmit clock option register */
- else if (! strcasecmp (*argv, "-lloop"))
- o.opt.tcor.llm = 0;
- else if (! strcasecmp (*argv, "+lloop"))
- o.opt.tcor.llm = 1;
- else if (! strcasecmp (*argv, "-extclock"))
- o.opt.tcor.ext1x = 0;
- else if (! strcasecmp (*argv, "+extclock"))
- o.opt.tcor.ext1x = 1;
-
- /*
- * Mode dependent channel options
- */
- else switch (o.mode) {
- case M_ASYNC: set_async_opt (*argv); break;
- case M_HDLC: set_hdlc_opt (*argv); break;
- case M_BISYNC: set_bisync_opt (*argv); break;
- case M_X21: set_x21_opt (*argv); break;
- }
-
- setchan (channel);
- return (0);
-}
diff --git a/sbin/fdisk/Makefile b/sbin/fdisk/Makefile
deleted file mode 100644
index 4a14439057c3..000000000000
--- a/sbin/fdisk/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-# $FreeBSD$
-
-PROG= fdisk
-MAN8= fdisk.8
-
-.include <bsd.prog.mk>
diff --git a/sbin/fdisk/fdisk.8 b/sbin/fdisk/fdisk.8
deleted file mode 100644
index 0bbbb5f15fc5..000000000000
--- a/sbin/fdisk/fdisk.8
+++ /dev/null
@@ -1,437 +0,0 @@
-.\" $FreeBSD$
-.\"
-.Dd October 4, 1996
-.Dt FDISK 8
-.\".Os BSD 4
-.Sh NAME
-.Nm fdisk
-.Nd PC partition table maintenance program
-.Sh SYNOPSIS
-.Nm fdisk
-.Op Fl BIaistu
-.Op Fl b Ar bootcode
-.Op Fl 1234
-.Op Ar disk
-.Bl -tag -width time
-.Nm fdisk
-.Fl f Ar configfile
-.Op Fl itv
-.Op Ar disk
-.Sh PROLOGUE
-In order for the BIOS to boot the kernel,
-certain conventions must be adhered to.
-Sector 0 of the disk must contain boot code,
-a partition table,
-and a magic number.
-BIOS partitions can be used to break the disk up into several pieces.
-The BIOS brings in sector 0 and verifies the magic number. The sector
-0 boot code then searches the partition table to determine which
-partition is marked
-.Em active .
-This boot code then brings in the bootstrap from the
-.Em active
-partition and, if marked bootable, runs it.
-Under DOS,
-you can have one or more partitions with one
-.Em active .
-The DOS
-.Nm
-program can be used to divide space on the disk into partitions and set one
-.Em active .
-.Sh DESCRIPTION
-The
-.Bx Free
-program
-.Nm
-serves a similar purpose to the DOS program. The first form is used to
-display partition information or to interactively edit the partition
-table. The second is used to write a partition table using a
-.Ar configfile
-and is designed to be used by other scripts/programs.
-.Pp
-Options are:
-.It Fl a
-Change the active partition only. Ignored if
-.Fl f
-is given.
-.It Fl b Ar bootcode
-Get the boot code from the file
-.Ar bootcode .
-.It Fl B
-Reinitialize the boot code contained in sector 0 of the disk. Ignored
-if
-.Fl f
-is given.
-.It Fl I
-Initialize the contents of sector 0 with one FreeBSD slice covering the entire disk.
-.It Fl f Ar configfile
-Set partition values using the file
-.Ar configfile .
-The
-.Ar configfile
-always modifies existing partitions, unless
-.Fl i
-is also given, in which case all existing partitions are deleted (marked
-as "unused") before the
-.Ar configfile
-is read. The
-.Ar configfile
-can be "-", in which case
-.Ar stdin
-is read. See
-.Sx CONFIGURATION FILE ,
-below, for file syntax.
-.Pp
-.Em WARNING Ns :
-when
-.Fl f
-is used, you are not asked if you really want to write the partition
-table (as you are in the interactive mode). Use with caution!
-.It Fl i
-Initialize sector 0 of the disk. This implies
-.Fl u ,
-unless
-.Fl f
-is given.
-.It Fl s
-Print summary information and exit.
-.It Fl t
-Test mode; do not write partition values. Generally used with the
-.Fl f
-option to see what would be written to the partition table. Implies
-.Fl v .
-.It Fl u
-Is used for updating (editing) sector 0 of the disk. Ignored if
-.Fl f
-is given.
-.It Fl v
-Be verbose. When
-.Fl f
-is used,
-.Nm
-prints out the partition table that is written to the disk.
-.It Fl 1234
-Operate on a single fdisk entry only. Ignored if
-.Fl f
-is given.
-.El
-.Pp
-The final disk name can be provided as a
-.Sq bare
-disk name only, e.g.
-.Ql da0 ,
-or as a fully qualified device node under
-.Pa /dev .
-If omitted, the disks
-.Ql wd0 ,
-.Ql da0 ,
-and
-.Ql od0
-are being searched in that order, until one is
-being found responding.
-.Pp
-When called with no arguments, it prints the sector 0 partition table.
-An example follows:
-
-.Bd -literal
- ******* Working on device /dev/rwd0 *******
- parameters extracted from in-core disklabel are:
- cylinders=769 heads=15 sectors/track=33 (495 blks/cyl)
-
- parameters to be used for BIOS calculations are:
- cylinders=769 heads=15 sectors/track=33 (495 blks/cyl)
-
- Warning: BIOS sector numbering starts with sector 1
- Information from DOS bootblock is:
- The data for partition 1 is:
- sysid 165,(FreeBSD/NetBSD/386BSD)
- start 495, size 380160 (185 Meg), flag 0
- beg: cyl 1/ sector 1/ head 0;
- end: cyl 768/ sector 33/ head 14
- The data for partition 2 is:
- sysid 164,(unknown)
- start 378180, size 2475 (1 Meg), flag 0
- beg: cyl 764/ sector 1/ head 0;
- end: cyl 768/ sector 33/ head 14
- The data for partition 3 is:
- <UNUSED>
- The data for partition 4 is:
- sysid 99,(ISC UNIX, other System V/386, GNU HURD or Mach)
- start 380656, size 224234 (109 Meg), flag 80
- beg: cyl 769/ sector 2/ head 0;
- end: cyl 197/ sector 33/ head 14
-.Ed
-.Pp
-The disk is divided into three partitions that happen to fill the disk.
-The second partition overlaps the end of the first.
-(Used for debugging purposes)
-.Bl -tag -width "cyl, sector and head"
-.It Em "sysid"
-is used to label the partition.
-.Bx Free
-reserves the
-magic number 165 decimal (A5 in hex).
-.It Em "start and size"
-fields provide the start address
-and size of a partition in sectors.
-.It Em "flag 80"
-specifies that this is the active partition.
-.It Em "cyl, sector and head"
-fields are used to specify the beginning address
-and end address for the partition.
-.It Em "Note:"
-these numbers are calculated using BIOS's understanding of the disk geometry
-and saved in the bootblock.
-.El
-.Pp
-The flags
-.Fl i
-or
-.Fl u
-are used to indicate that the partition data is to be updated, unless the
-.Fl f
-option is used. If the
-.Fl f
-option is not used, the
-.Nm
-program will enter a conversational mode.
-This mode is designed not to change any data unless you explicitly tell it to.
-.Nm Fdisk
-selects defaults for its questions to guarantee the above behavior.
-.Pp
-It displays each partition
-and ask if you want to edit it.
-If you say yes,
-it will step through each field showing the old value
-and asking for a new one.
-When you are done with a partition,
-.Nm
-will display it and ask if it is correct.
-.Nm Fdisk
-will then proceed to the next entry.
-.Pp
-Getting the
-.Em cyl, sector,
-and
-.Em head
-fields correct is tricky.
-So by default,
-they will be calculated for you;
-you can specify them if you choose.
-.Pp
-After all the partitions are processed,
-you are given the option to change the
-.Em active
-partition.
-Finally,
-when the all the data for the first sector has been accumulated,
-you are asked if you really want to rewrite sector 0.
-Only if you answer yes,
-will the data be written to disk.
-.Pp
-The difference between the
-.Fl u
-flag and
-.Fl i
-flag is that
-the
-.Fl u
-flag just edits the fields as they appear on the disk.
-While the
-.Fl i
-flag is used to "initialize" sector 0;
-it will setup the last BIOS partition to use the whole disk for
-.Bx Free ;
-and make it active.
-.Sh NOTES
-The automatic calculation of starting cylinder etc. uses
-a set of figures that represent what the BIOS thinks is the
-geometry of the drive.
-These figures are by default taken from the incore disklabel,
-but the program initially gives you an opportunity to change them.
-This allows the user to create a bootblock that can work with drives
-that use geometry translation under the BIOS.
-.Pp
-If you hand craft your disk layout,
-please make sure that the
-.Bx Free
-partition starts on a cylinder boundary.
-A number of decisions made later may assume this.
-(This might not be necessary later.)
-.Pp
-Editing an existing partition will most likely cause you to
-lose all the data in that partition.
-.Pp
-You should run this program interactively once or twice to see how it
-works. This is completely safe as long as you answer the last question
-in the negative. There are subtleties that the program detects that are
-not fully explained in this manual page.
-.Sh CONFIGURATION FILE
-When the
-.Fl f
-option is given, a disk's partition table can be written using values
-from a
-.Ar configfile .
-The syntax of this file is very simple. Each line is either a comment or
-a specification, and whitespace (except for newlines) are ignored:
-.Bl -tag -width Ds
-.It Xo
-.Ic #
-.No Ar comment ...
-.Xc
-Lines beginning with a "#" are comments and are ignored.
-.It Xo
-.Ic g
-.No Ar spec1
-.No Ar spec2
-.No Ar spec3
-.Xc
-Set the BIOS geometry used in partition calculations. There must be
-three values specified, with a letter preceding each number:
-.Bl -tag -width Ds
-.Sm off
-.It Cm c No Ar num
-.Sm on
-Set the number of cylinders to
-.Ar num .
-.Sm off
-.It Cm h No Ar num
-.Sm on
-Set the number of heads to
-.Ar num .
-.Sm off
-.It Cm s No Ar num
-.Sm on
-Set the number of sectors/track to
-.Ar num .
-.El
-.Pp
-These specs can occur in any order, as the leading letter determines
-which value is which; however, all three must be specified.
-.Pp
-This line must occur before any lines that specify partition
-information.
-.Pp
-It is an error if the following is not true:
-.Pp
-.nf
- 1 <= number of cylinders
- 1 <= number of heads <= 256
- 1 <= number of sectors/track < 64
-.fi
-.Pp
-The number of cylinders should be less than or equal to 1024, but this
-is not enforced, although a warning will be output. Note that bootable
-.Bx Free
-partitions (the "/" filesystem) must lie completely within the
-first 1024 cylinders; if this is not true, booting may fail.
-Non-bootable partitions do not have this restriction.
-.Pp
-Example (all of these are equivalent), for a disk with 1019 cylinders,
-39 heads, and 63 sectors:
-.Pp
-.nf
- g c1019 h39 s63
- g h39 c1019 s63
- g s63 h39 c1019
-.fi
-.It Xo
-.Ic p
-.No Ar partition
-.No Ar type
-.No Ar start
-.No Ar length
-.Xc
-Set the partition given by
-.Ar partition
-(1-4) to type
-.Ar type ,
-starting at sector
-.Ar start
-for
-.Ar length
-sectors.
-.Pp
-Only those partitions explicitly mentioned by these lines are modified;
-any partition not referenced by a "p" line will not be modified.
-However, if an invalid partition table is present, or the
-.Fl i
-option is specified, all existing partition entries will be cleared
-(marked as unused), and these "p" lines will have to be used to
-explicitly set partition information. If multiple partitions need to be
-set, multiple "p" lines must be specified; one for each partition.
-.Pp
-These partition lines must occur after any geometry specification lines,
-if one is present.
-.Pp
-The
-.Ar type
-is 165 for
-.Bx Free
-partitions. Specifying a partition type of zero is
-the same as clearing the partition and marking it as unused; however,
-dummy values (such as "0") must still be specified for
-.Ar start
-and
-.Ar length .
-.Pp
-Note: the start offset will be rounded upwards to a head boundary if
-necessary, and the end offset will be rounded downwards to a cylinder
-boundary if necessary.
-.Pp
-Example: to clear partition 4 and mark it as unused:
-.Pp
-.nf
- p 4 0 0 0
-.fi
-.Pp
-Example: to set partition 1 to a
-.Bx Free
-partition, starting at sector 1
-for 2503871 sectors (note: these numbers will be rounded upwards and
-downwards to correspond to head and cylinder boundaries):
-.Pp
-.nf
- p 1 165 1 2503871
-.fi
-.It Xo
-.Ic a
-.No Ar partition
-.Xc
-Make
-.Ar partition
-the active partition. Can occur anywhere in the config file, but only
-one must be present.
-.Pp
-Example: to make partition 1 the active partition:
-.Pp
-.nf
- a 1
-.fi
-
-.El
-.Pp
-.Sh FILES
-.Bl -tag -width /boot/mbr -compact
-.It Pa /boot/mbr
-The default boot code
-.El
-.Sh SEE ALSO
-.Xr disklabel 8
-.Sh BUGS
-The default boot code will not necessarily handle all partition types
-correctly, in particular those introduced since MS-DOS 6.x.
-.Pp
-The entire program should be made more user-friendly.
-.Pp
-Throughout this man page, the term
-.Sq partition
-is used where it should actually be
-.Sq slice ,
-in order to conform with the terms used elsewhere.
-.Pp
-You cannot use this command to completely dedicate a disk to
-.Bx Free .
-The
-.Xr disklabel 8
-command must be used for this.
diff --git a/sbin/fdisk/fdisk.c b/sbin/fdisk/fdisk.c
deleted file mode 100644
index 2f34c010b532..000000000000
--- a/sbin/fdisk/fdisk.c
+++ /dev/null
@@ -1,1345 +0,0 @@
-/*
- * 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.
- */
-
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <sys/disklabel.h>
-#include <sys/stat.h>
-#include <ctype.h>
-#include <fcntl.h>
-#include <err.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-int iotest;
-
-#define LBUF 100
-static char lbuf[LBUF];
-
-/*
- *
- * Ported to 386bsd by Julian Elischer Thu Oct 15 20:26:46 PDT 1992
- *
- * 14-Dec-89 Robert Baron (rvb) at Carnegie-Mellon University
- * Copyright (c) 1989 Robert. V. Baron
- * Created.
- */
-
-#define Decimal(str, ans, tmp) if (decimal(str, &tmp, ans)) ans = tmp
-#define Hex(str, ans, tmp) if (hex(str, &tmp, ans)) ans = tmp
-#define String(str, ans, len) {char *z = ans; char **dflt = &z; if (string(str, dflt)) strncpy(ans, *dflt, len); }
-
-#define RoundCyl(x) ((((x) + cylsecs - 1) / cylsecs) * cylsecs)
-
-#define MAX_SEC_SIZE 2048 /* maximum section size that is supported */
-#define MIN_SEC_SIZE 512 /* the sector size to start sensing at */
-int secsize = 0; /* the sensed sector size */
-
-const char *disk;
-const char *disks[] =
-{
- "/dev/rad0", "/dev/rwd0", "/dev/rda0", "/dev/rod0", 0
-};
-
-struct disklabel disklabel; /* disk parameters */
-
-int cyls, sectors, heads, cylsecs, disksecs;
-
-struct mboot
-{
- unsigned char padding[2]; /* force the longs to be long aligned */
- unsigned char bootinst[DOSPARTOFF];
- struct dos_partition parts[4];
- unsigned short int signature;
- /* room to read in MBRs that are bigger then DEV_BSIZE */
- unsigned char large_sector_overflow[MAX_SEC_SIZE-MIN_SEC_SIZE];
-};
-struct mboot mboot;
-
-#define ACTIVE 0x80
-#define BOOT_MAGIC 0xAA55
-
-int dos_cyls;
-int dos_heads;
-int dos_sectors;
-int dos_cylsecs;
-
-#define DOSSECT(s,c) ((s & 0x3f) | ((c >> 2) & 0xc0))
-#define DOSCYL(c) (c & 0xff)
-static int partition = -1;
-
-
-#define MAX_ARGS 10
-
-static int current_line_number;
-
-static int geom_processed = 0;
-static int part_processed = 0;
-static int active_processed = 0;
-
-
-typedef struct cmd {
- char cmd;
- int n_args;
- struct arg {
- char argtype;
- int arg_val;
- } args[MAX_ARGS];
-} CMD;
-
-
-static int B_flag = 0; /* replace boot code */
-static int I_flag = 0; /* use entire disk for FreeBSD */
-static int a_flag = 0; /* set active partition */
-static char *b_flag = NULL; /* path to boot code */
-static int i_flag = 0; /* replace partition data */
-static int u_flag = 0; /* update partition data */
-static int s_flag = 0; /* Print a summary and exit */
-static int t_flag = 0; /* test only, if f_flag is given */
-static char *f_flag = NULL; /* Read config info from file */
-static int v_flag = 0; /* Be verbose */
-
-struct part_type
-{
- unsigned char type;
- char *name;
-}part_types[] =
-{
- {0x00, "unused"}
- ,{0x01, "Primary DOS with 12 bit FAT"}
- ,{0x02, "XENIX / filesystem"}
- ,{0x03, "XENIX /usr filesystem"}
- ,{0x04, "Primary DOS with 16 bit FAT (<= 32MB)"}
- ,{0x05, "Extended DOS"}
- ,{0x06, "Primary 'big' DOS (> 32MB)"}
- ,{0x07, "OS/2 HPFS, NTFS, QNX or Advanced UNIX"}
- ,{0x08, "AIX filesystem"}
- ,{0x09, "AIX boot partition or Coherent"}
- ,{0x0A, "OS/2 Boot Manager or OPUS"}
- ,{0x0B, "DOS or Windows 95 with 32 bit FAT"}
- ,{0x0C, "DOS or Windows 95 with 32 bit FAT, LBA"}
- ,{0x0E, "Primary 'big' DOS (> 32MB, LBA)"}
- ,{0x0F, "Extended DOS, LBA"}
- ,{0x10, "OPUS"}
- ,{0x40, "VENIX 286"}
- ,{0x50, "DM"}
- ,{0x51, "DM"}
- ,{0x52, "CP/M or Microport SysV/AT"}
- ,{0x56, "GB"}
- ,{0x61, "Speed"}
- ,{0x63, "ISC UNIX, other System V/386, GNU HURD or Mach"}
- ,{0x64, "Novell Netware 2.xx"}
- ,{0x65, "Novell Netware 3.xx"}
- ,{0x75, "PCIX"}
- ,{0x80, "Minix 1.1 ... 1.4a"}
- ,{0x81, "Minix 1.4b ... 1.5.10"}
- ,{0x82, "Linux swap or Solaris x86"}
- ,{0x83, "Linux filesystem"}
- ,{0x93, "Amoeba filesystem"}
- ,{0x94, "Amoeba bad block table"}
- ,{0x9F, "BSD/OS"}
- ,{0xA5, "FreeBSD/NetBSD/386BSD"}
- ,{0xA6, "OpenBSD"}
- ,{0xA7, "NEXTSTEP"}
- ,{0xA9, "NetBSD"}
- ,{0xB7, "BSDI BSD/386 filesystem"}
- ,{0xB8, "BSDI BSD/386 swap"}
- ,{0xDB, "Concurrent CPM or C.DOS or CTOS"}
- ,{0xE1, "Speed"}
- ,{0xE3, "Speed"}
- ,{0xE4, "Speed"}
- ,{0xF1, "Speed"}
- ,{0xF2, "DOS 3.3+ Secondary"}
- ,{0xF4, "Speed"}
- ,{0xFF, "BBT (Bad Blocks Table)"}
-};
-
-static void print_s0(int which);
-static void print_part(int i);
-static void init_sector0(unsigned long start);
-static void init_boot(void);
-static void change_part(int i);
-static void print_params();
-static void change_active(int which);
-static void change_code();
-static void get_params_to_use();
-static void dos(int sec, int size, unsigned char *c, unsigned char *s,
- unsigned char *h);
-static int open_disk(int u_flag);
-static ssize_t read_disk(off_t sector, void *buf);
-static ssize_t write_disk(off_t sector, void *buf);
-static int get_params();
-static int read_s0();
-static int write_s0();
-static int ok(char *str);
-static int decimal(char *str, int *num, int deflt);
-static char *get_type(int type);
-static int read_config(char *config_file);
-static void reset_boot(void);
-static void usage(void);
-#if 0
-static int hex(char *str, int *num, int deflt);
-static int string(char *str, char **ans);
-#endif
-
-
-int
-main(int argc, char *argv[])
-{
- int c, i;
-
- while ((c = getopt(argc, argv, "BIab:f:istuv1234")) != -1)
- switch (c) {
- case 'B':
- B_flag = 1;
- break;
- case 'I':
- I_flag = 1;
- break;
- case 'a':
- a_flag = 1;
- break;
- case 'b':
- b_flag = optarg;
- break;
- case 'f':
- f_flag = optarg;
- break;
- case 'i':
- i_flag = 1;
- break;
- case 's':
- s_flag = 1;
- break;
- case 't':
- t_flag = 1;
- break;
- case 'u':
- u_flag = 1;
- break;
- case 'v':
- v_flag = 1;
- break;
- case '1':
- case '2':
- case '3':
- case '4':
- partition = c - '0';
- break;
- default:
- usage();
- }
- if (f_flag || i_flag)
- u_flag = 1;
- if (t_flag)
- v_flag = 1;
- argc -= optind;
- argv += optind;
-
- if (argc > 0)
- {
- static char realname[12];
-
- if(strncmp(argv[0], "/dev", 4) == 0)
- disk = argv[0];
- else
- {
- snprintf(realname, 12, "/dev/%s", argv[0]);
- disk = realname;
- }
-
- if (open_disk(u_flag) < 0)
- err(1, "cannot open disk %s", disk);
- }
- else
- {
- int rv = 0;
-
- for(i = 0; disks[i]; i++)
- {
- disk = disks[i];
- rv = open_disk(u_flag);
- if(rv != -2) break;
- }
- if(rv < 0)
- err(1, "cannot open any disk");
- }
- if (s_flag)
- {
- int i;
- struct dos_partition *partp;
-
- if (read_s0())
- err(1, "read_s0");
- printf("%s: %d cyl %d hd %d sec\n", disk, dos_cyls, dos_heads,
- dos_sectors);
- printf("Part %11s %11s Type Flags\n", "Start", "Size");
- for (i = 0; i < NDOSPART; i++) {
- partp = ((struct dos_partition *) &mboot.parts) + i;
- if (partp->dp_start == 0 && partp->dp_size == 0)
- continue;
- printf("%4d: %11lu %11lu 0x%02x 0x%02x\n", i + 1,
- (u_long) partp->dp_start,
- (u_long) partp->dp_size, partp->dp_typ,
- partp->dp_flag);
- }
- exit(0);
- }
-
- printf("******* Working on device %s *******\n",disk);
-
- if (I_flag)
- {
- struct dos_partition *partp;
-
- read_s0();
- reset_boot();
- partp = (struct dos_partition *) (&mboot.parts[0]);
- partp->dp_typ = DOSPTYP_386BSD;
- partp->dp_flag = ACTIVE;
- partp->dp_start = dos_sectors;
- partp->dp_size = disksecs - dos_sectors;
-
- dos(partp->dp_start, partp->dp_size,
- &partp->dp_scyl, &partp->dp_ssect, &partp->dp_shd);
- dos(partp->dp_start + partp->dp_size - 1, partp->dp_size,
- &partp->dp_ecyl, &partp->dp_esect, &partp->dp_ehd);
- if (v_flag)
- print_s0(-1);
- write_s0();
- exit(0);
- }
- if (f_flag)
- {
- if (read_s0() || i_flag)
- {
- reset_boot();
- }
-
- if (!read_config(f_flag))
- {
- exit(1);
- }
- if (v_flag)
- {
- print_s0(-1);
- }
- if (!t_flag)
- {
- write_s0();
- }
- }
- else
- {
- if(u_flag)
- {
- get_params_to_use();
- }
- else
- {
- print_params();
- }
-
- if (read_s0())
- init_sector0(1);
-
- printf("Media sector size is %d\n", secsize);
- printf("Warning: BIOS sector numbering starts with sector 1\n");
- printf("Information from DOS bootblock is:\n");
- if (partition == -1)
- for (i = 1; i <= NDOSPART; i++)
- change_part(i);
- else
- change_part(partition);
-
- if (u_flag || a_flag)
- change_active(partition);
-
- if (B_flag)
- change_code();
-
- if (u_flag || a_flag || B_flag) {
- if (!t_flag)
- {
- printf("\nWe haven't changed the partition table yet. ");
- printf("This is your last chance.\n");
- }
- print_s0(-1);
- if (!t_flag)
- {
- if (ok("Should we write new partition table?"))
- write_s0();
- }
- else
- {
- printf("\n-t flag specified -- partition table not written.\n");
- }
- }
- }
-
- exit(0);
-}
-
-static void
-usage()
-{
- fprintf(stderr, "%s%s",
- "usage: fdisk [-Baeitu] [-b bootcode] [-1234] [disk]\n",
- " fdisk -f configfile [-itv] [disk]\n");
- exit(1);
-}
-
-static void
-print_s0(int which)
-{
-int i;
-
- print_params();
- printf("Information from DOS bootblock is:\n");
- if (which == -1)
- for (i = 1; i <= NDOSPART; i++)
- printf("%d: ", i), print_part(i);
- else
- print_part(which);
-}
-
-static struct dos_partition mtpart = { 0 };
-
-static void
-print_part(int i)
-{
- struct dos_partition *partp;
- u_int64_t part_mb;
-
- partp = ((struct dos_partition *) &mboot.parts) + i - 1;
-
- if (!bcmp(partp, &mtpart, sizeof (struct dos_partition))) {
- printf("<UNUSED>\n");
- return;
- }
- /*
- * Be careful not to overflow.
- */
- part_mb = partp->dp_size;
- part_mb *= secsize;
- part_mb /= (1024 * 1024);
- printf("sysid %d,(%s)\n", partp->dp_typ, get_type(partp->dp_typ));
- printf(" start %lu, size %lu (%qd Meg), flag %x%s\n",
- (u_long)partp->dp_start,
- (u_long)partp->dp_size,
- part_mb,
- partp->dp_flag,
- partp->dp_flag == ACTIVE ? " (active)" : "");
- printf("\tbeg: cyl %d/ sector %d/ head %d;\n\tend: cyl %d/ sector %d/ head %d\n"
- ,DPCYL(partp->dp_scyl, partp->dp_ssect)
- ,DPSECT(partp->dp_ssect)
- ,partp->dp_shd
- ,DPCYL(partp->dp_ecyl, partp->dp_esect)
- ,DPSECT(partp->dp_esect)
- ,partp->dp_ehd);
-}
-
-
-static void
-init_boot(void)
-{
- const char *fname;
- int fd;
-
- fname = b_flag ? b_flag : "/boot/mbr";
- if ((fd = open(fname, O_RDONLY)) == -1 ||
- read(fd, mboot.bootinst, DOSPARTOFF) == -1 ||
- close(fd))
- err(1, "%s", fname);
- mboot.signature = BOOT_MAGIC;
-}
-
-
-static void
-init_sector0(unsigned long start)
-{
-struct dos_partition *partp = (struct dos_partition *) (&mboot.parts[3]);
-unsigned long size = disksecs - start;
-
- init_boot();
-
- partp->dp_typ = DOSPTYP_386BSD;
- partp->dp_flag = ACTIVE;
- partp->dp_start = start;
- partp->dp_size = size;
-
- dos(partp->dp_start, partp->dp_size,
- &partp->dp_scyl, &partp->dp_ssect, &partp->dp_shd);
- dos(partp->dp_start + partp->dp_size - 1, partp->dp_size,
- &partp->dp_ecyl, &partp->dp_esect, &partp->dp_ehd);
-}
-
-static void
-change_part(int i)
-{
-struct dos_partition *partp = ((struct dos_partition *) &mboot.parts) + i - 1;
-
- printf("The data for partition %d is:\n", i);
- print_part(i);
-
- if (u_flag && ok("Do you want to change it?")) {
- int tmp;
-
- if (i_flag) {
- bzero((char *)partp, sizeof (struct dos_partition));
- if (i == 4) {
- init_sector0(1);
- printf("\nThe static data for the DOS partition 4 has been reinitialized to:\n");
- print_part(i);
- }
- }
-
- do {
- Decimal("sysid (165=FreeBSD)", partp->dp_typ, tmp);
- Decimal("start", partp->dp_start, tmp);
- Decimal("size", partp->dp_size, tmp);
-
- if (ok("Explicitly specify beg/end address ?"))
- {
- int tsec,tcyl,thd;
- tcyl = DPCYL(partp->dp_scyl,partp->dp_ssect);
- thd = partp->dp_shd;
- tsec = DPSECT(partp->dp_ssect);
- Decimal("beginning cylinder", tcyl, tmp);
- Decimal("beginning head", thd, tmp);
- Decimal("beginning sector", tsec, tmp);
- partp->dp_scyl = DOSCYL(tcyl);
- partp->dp_ssect = DOSSECT(tsec,tcyl);
- partp->dp_shd = thd;
-
- tcyl = DPCYL(partp->dp_ecyl,partp->dp_esect);
- thd = partp->dp_ehd;
- tsec = DPSECT(partp->dp_esect);
- Decimal("ending cylinder", tcyl, tmp);
- Decimal("ending head", thd, tmp);
- Decimal("ending sector", tsec, tmp);
- partp->dp_ecyl = DOSCYL(tcyl);
- partp->dp_esect = DOSSECT(tsec,tcyl);
- partp->dp_ehd = thd;
- } else {
- dos(partp->dp_start, partp->dp_size,
- &partp->dp_scyl, &partp->dp_ssect, &partp->dp_shd);
- dos(partp->dp_start + partp->dp_size - 1, partp->dp_size,
- &partp->dp_ecyl, &partp->dp_esect, &partp->dp_ehd);
- }
-
- print_part(i);
- } while (!ok("Are we happy with this entry?"));
- }
-}
-
-static void
-print_params()
-{
- printf("parameters extracted from in-core disklabel are:\n");
- printf("cylinders=%d heads=%d sectors/track=%d (%d blks/cyl)\n\n"
- ,cyls,heads,sectors,cylsecs);
- if((dos_sectors > 63) || (dos_cyls > 1023) || (dos_heads > 255))
- printf("Figures below won't work with BIOS for partitions not in cyl 1\n");
- printf("parameters to be used for BIOS calculations are:\n");
- printf("cylinders=%d heads=%d sectors/track=%d (%d blks/cyl)\n\n"
- ,dos_cyls,dos_heads,dos_sectors,dos_cylsecs);
-}
-
-static void
-change_active(int which)
-{
-int i;
-int active = 4, tmp;
-struct dos_partition *partp = ((struct dos_partition *) &mboot.parts);
-
- if (a_flag && which != -1)
- active = which;
- if (!ok("Do you want to change the active partition?"))
- return;
-setactive:
- active = 4;
- do {
- Decimal("active partition", active, tmp);
- if (active < 1 || 4 < active) {
- printf("Active partition number must be in range 1-4."
- " Try again.\n");
- goto setactive;
- }
- } while (!ok("Are you happy with this choice"));
- for (i = 0; i < NDOSPART; i++)
- partp[i].dp_flag = 0;
- if (active > 0 && active <= NDOSPART)
- partp[active-1].dp_flag = ACTIVE;
-}
-
-static void
-change_code()
-{
- if (ok("Do you want to change the boot code?"))
- init_boot();
-
-}
-
-void
-get_params_to_use()
-{
- int tmp;
- print_params();
- if (ok("Do you want to change our idea of what BIOS thinks ?"))
- {
- do
- {
- Decimal("BIOS's idea of #cylinders", dos_cyls, tmp);
- Decimal("BIOS's idea of #heads", dos_heads, tmp);
- Decimal("BIOS's idea of #sectors", dos_sectors, tmp);
- dos_cylsecs = dos_heads * dos_sectors;
- print_params();
- }
- while(!ok("Are you happy with this choice"));
- }
-}
-
-
-/***********************************************\
-* Change real numbers into strange dos numbers *
-\***********************************************/
-static void
-dos(sec, size, c, s, h)
-int sec, size;
-unsigned char *c, *s, *h;
-{
-int cy;
-int hd;
-
- if (sec == 0 && size == 0) {
- *s = *c = *h = 0;
- return;
- }
-
- cy = sec / ( dos_cylsecs );
- sec = sec - cy * ( dos_cylsecs );
-
- hd = sec / dos_sectors;
- sec = (sec - hd * dos_sectors) + 1;
-
- *h = hd;
- *c = cy & 0xff;
- *s = (sec & 0x3f) | ( (cy & 0x300) >> 2);
-}
-
-int fd;
-
- /* Getting device status */
-
-static int
-open_disk(int u_flag)
-{
-struct stat st;
-
- if (stat(disk, &st) == -1) {
- warnx("can't get file status of %s", disk);
- return -1;
- }
- if ( !(st.st_mode & S_IFCHR) )
- warnx("device %s is not character special", disk);
- if ((fd = open(disk,
- a_flag || I_flag || B_flag || u_flag ? O_RDWR : O_RDONLY)) == -1) {
- if(errno == ENXIO)
- return -2;
- warnx("can't open device %s", disk);
- return -1;
- }
- if (get_params(0) == -1) {
- warnx("can't get disk parameters on %s", disk);
- return -1;
- }
- return fd;
-}
-
-static ssize_t
-read_disk(off_t sector, void *buf)
-{
- lseek(fd,(sector * 512), 0);
- if( secsize == 0 )
- for( secsize = MIN_SEC_SIZE; secsize <= MAX_SEC_SIZE; secsize *= 2 )
- {
- /* try the read */
- int size = read(fd, buf, secsize);
- if( size == secsize )
- /* it worked so return */
- return secsize;
- }
- else
- return read( fd, buf, secsize );
-
- /* we failed to read at any of the sizes */
- return -1;
-}
-
-static ssize_t
-write_disk(off_t sector, void *buf)
-{
- lseek(fd,(sector * 512), 0);
- /* write out in the size that the read_disk found worked */
- return write(fd, buf, secsize);
-}
-
-static int
-get_params()
-{
-
- if (ioctl(fd, DIOCGDINFO, &disklabel) == -1) {
- warnx("can't get disk parameters on %s; supplying dummy ones", disk);
- dos_cyls = cyls = 1;
- dos_heads = heads = 1;
- dos_sectors = sectors = 1;
- dos_cylsecs = cylsecs = heads * sectors;
- disksecs = cyls * heads * sectors;
- return disksecs;
- }
-
- dos_cyls = cyls = disklabel.d_ncylinders;
- dos_heads = heads = disklabel.d_ntracks;
- dos_sectors = sectors = disklabel.d_nsectors;
- dos_cylsecs = cylsecs = heads * sectors;
- disksecs = cyls * heads * sectors;
-
- return (disksecs);
-}
-
-
-static int
-read_s0()
-{
- if (read_disk(0, (char *) mboot.bootinst) == -1) {
- warnx("can't read fdisk partition table");
- return -1;
- }
- if (mboot.signature != BOOT_MAGIC) {
- warnx("invalid fdisk partition table found");
- /* So should we initialize things */
- return -1;
- }
- return 0;
-}
-
-static int
-write_s0()
-{
-#ifdef NOT_NOW
- int flag;
-#endif
- if (iotest) {
- print_s0(-1);
- return 0;
- }
- /*
- * write enable label sector before write (if necessary),
- * disable after writing.
- * needed if the disklabel protected area also protects
- * sector 0. (e.g. empty disk)
- */
-#ifdef NOT_NOW
- flag = 1;
- if (ioctl(fd, DIOCWLABEL, &flag) < 0)
- warn("ioctl DIOCWLABEL");
-#endif
- if (write_disk(0, (char *) mboot.bootinst) == -1) {
- warn("can't write fdisk partition table");
- return -1;
-#ifdef NOT_NOW
- flag = 0;
- (void) ioctl(fd, DIOCWLABEL, &flag);
-#endif
- }
- return(0);
-}
-
-
-static int
-ok(str)
-char *str;
-{
- printf("%s [n] ", str);
- fgets(lbuf, LBUF, stdin);
- lbuf[strlen(lbuf)-1] = 0;
-
- if (*lbuf &&
- (!strcmp(lbuf, "yes") || !strcmp(lbuf, "YES") ||
- !strcmp(lbuf, "y") || !strcmp(lbuf, "Y")))
- return 1;
- else
- return 0;
-}
-
-static int
-decimal(char *str, int *num, int deflt)
-{
-int acc = 0, c;
-char *cp;
-
- while (1) {
- printf("Supply a decimal value for \"%s\" [%d] ", str, deflt);
- fgets(lbuf, LBUF, stdin);
- lbuf[strlen(lbuf)-1] = 0;
-
- if (!*lbuf)
- return 0;
-
- cp = lbuf;
- while ((c = *cp) && (c == ' ' || c == '\t')) cp++;
- if (!c)
- return 0;
- while ((c = *cp++)) {
- if (c <= '9' && c >= '0')
- acc = acc * 10 + c - '0';
- else
- break;
- }
- if (c == ' ' || c == '\t')
- while ((c = *cp) && (c == ' ' || c == '\t')) cp++;
- if (!c) {
- *num = acc;
- return 1;
- } else
- printf("%s is an invalid decimal number. Try again.\n",
- lbuf);
- }
-
-}
-
-#if 0
-static int
-hex(char *str, int *num, int deflt)
-{
-int acc = 0, c;
-char *cp;
-
- while (1) {
- printf("Supply a hex value for \"%s\" [%x] ", str, deflt);
- fgets(lbuf, LBUF, stdin);
- lbuf[strlen(lbuf)-1] = 0;
-
- if (!*lbuf)
- return 0;
-
- cp = lbuf;
- while ((c = *cp) && (c == ' ' || c == '\t')) cp++;
- if (!c)
- return 0;
- while ((c = *cp++)) {
- if (c <= '9' && c >= '0')
- acc = (acc << 4) + c - '0';
- else if (c <= 'f' && c >= 'a')
- acc = (acc << 4) + c - 'a' + 10;
- else if (c <= 'F' && c >= 'A')
- acc = (acc << 4) + c - 'A' + 10;
- else
- break;
- }
- if (c == ' ' || c == '\t')
- while ((c = *cp) && (c == ' ' || c == '\t')) cp++;
- if (!c) {
- *num = acc;
- return 1;
- } else
- printf("%s is an invalid hex number. Try again.\n",
- lbuf);
- }
-
-}
-
-static int
-string(char *str, char **ans)
-{
-int c;
-char *cp = lbuf;
-
- while (1) {
- printf("Supply a string value for \"%s\" [%s] ", str, *ans);
- fgets(lbuf, LBUF, stdin);
- lbuf[strlen(lbuf)-1] = 0;
-
- if (!*lbuf)
- return 0;
-
- while ((c = *cp) && (c == ' ' || c == '\t')) cp++;
- if (c == '"') {
- c = *++cp;
- *ans = cp;
- while ((c = *cp) && c != '"') cp++;
- } else {
- *ans = cp;
- while ((c = *cp) && c != ' ' && c != '\t') cp++;
- }
-
- if (c)
- *cp = 0;
- return 1;
- }
-}
-#endif
-
-static char *
-get_type(int type)
-{
- int numentries = (sizeof(part_types)/sizeof(struct part_type));
- int counter = 0;
- struct part_type *ptr = part_types;
-
-
- while(counter < numentries)
- {
- if(ptr->type == type)
- {
- return(ptr->name);
- }
- ptr++;
- counter++;
- }
- return("unknown");
-}
-
-
-static void
-parse_config_line(line, command)
- char *line;
- CMD *command;
-{
- char *cp, *end;
-
- cp = line;
- while (1) /* dirty trick used to insure one exit point for this
- function */
- {
- memset(command, 0, sizeof(*command));
-
- while (isspace(*cp)) ++cp;
- if (*cp == '\0' || *cp == '#')
- {
- break;
- }
- command->cmd = *cp++;
-
- /*
- * Parse args
- */
- while (1)
- {
- while (isspace(*cp)) ++cp;
- if (*cp == '#')
- {
- break; /* found comment */
- }
- if (isalpha(*cp))
- {
- command->args[command->n_args].argtype = *cp++;
- }
- if (!isdigit(*cp))
- {
- break; /* assume end of line */
- }
- end = NULL;
- command->args[command->n_args].arg_val = strtol(cp, &end, 0);
- if (cp == end)
- {
- break; /* couldn't parse number */
- }
- cp = end;
- command->n_args++;
- }
- break;
- }
-}
-
-
-static int
-process_geometry(command)
- CMD *command;
-{
- int status = 1, i;
-
- while (1)
- {
- geom_processed = 1;
- if (part_processed)
- {
- warnx(
- "ERROR line %d: the geometry specification line must occur before\n\
- all partition specifications",
- current_line_number);
- status = 0;
- break;
- }
- if (command->n_args != 3)
- {
- warnx("ERROR line %d: incorrect number of geometry args",
- current_line_number);
- status = 0;
- break;
- }
- dos_cyls = -1;
- dos_heads = -1;
- dos_sectors = -1;
- for (i = 0; i < 3; ++i)
- {
- switch (command->args[i].argtype)
- {
- case 'c':
- dos_cyls = command->args[i].arg_val;
- break;
- case 'h':
- dos_heads = command->args[i].arg_val;
- break;
- case 's':
- dos_sectors = command->args[i].arg_val;
- break;
- default:
- warnx(
- "ERROR line %d: unknown geometry arg type: '%c' (0x%02x)",
- current_line_number, command->args[i].argtype,
- command->args[i].argtype);
- status = 0;
- break;
- }
- }
- if (status == 0)
- {
- break;
- }
-
- dos_cylsecs = dos_heads * dos_sectors;
-
- /*
- * Do sanity checks on parameter values
- */
- if (dos_cyls < 0)
- {
- warnx("ERROR line %d: number of cylinders not specified",
- current_line_number);
- status = 0;
- }
- if (dos_cyls == 0 || dos_cyls > 1024)
- {
- warnx(
- "WARNING line %d: number of cylinders (%d) may be out-of-range\n\
- (must be within 1-1024 for normal BIOS operation, unless the entire disk\n\
- is dedicated to FreeBSD)",
- current_line_number, dos_cyls);
- }
-
- if (dos_heads < 0)
- {
- warnx("ERROR line %d: number of heads not specified",
- current_line_number);
- status = 0;
- }
- else if (dos_heads < 1 || dos_heads > 256)
- {
- warnx("ERROR line %d: number of heads must be within (1-256)",
- current_line_number);
- status = 0;
- }
-
- if (dos_sectors < 0)
- {
- warnx("ERROR line %d: number of sectors not specified",
- current_line_number);
- status = 0;
- }
- else if (dos_sectors < 1 || dos_sectors > 63)
- {
- warnx("ERROR line %d: number of sectors must be within (1-63)",
- current_line_number);
- status = 0;
- }
-
- break;
- }
- return (status);
-}
-
-
-static int
-process_partition(command)
- CMD *command;
-{
- int status = 0, partition;
- unsigned long chunks, adj_size, max_end;
- struct dos_partition *partp;
-
- while (1)
- {
- part_processed = 1;
- if (command->n_args != 4)
- {
- warnx("ERROR line %d: incorrect number of partition args",
- current_line_number);
- break;
- }
- partition = command->args[0].arg_val;
- if (partition < 1 || partition > 4)
- {
- warnx("ERROR line %d: invalid partition number %d",
- current_line_number, partition);
- break;
- }
- partp = ((struct dos_partition *) &mboot.parts) + partition - 1;
- bzero((char *)partp, sizeof (struct dos_partition));
- partp->dp_typ = command->args[1].arg_val;
- partp->dp_start = command->args[2].arg_val;
- partp->dp_size = command->args[3].arg_val;
- max_end = partp->dp_start + partp->dp_size;
-
- if (partp->dp_typ == 0)
- {
- /*
- * Get out, the partition is marked as unused.
- */
- /*
- * Insure that it's unused.
- */
- bzero((char *)partp, sizeof (struct dos_partition));
- status = 1;
- break;
- }
-
- /*
- * Adjust start upwards, if necessary, to fall on an head boundary.
- */
- if (partp->dp_start % dos_sectors != 0)
- {
- adj_size =
- (partp->dp_start / dos_sectors + 1) * dos_sectors;
- if (adj_size > max_end)
- {
- /*
- * Can't go past end of partition
- */
- warnx(
- "ERROR line %d: unable to adjust start of partition %d to fall on\n\
- a cylinder boundary",
- current_line_number, partition);
- break;
- }
- warnx(
- "WARNING: adjusting start offset of partition '%d' from %lu\n\
- to %lu, to round to an head boundary",
- partition, (u_long)partp->dp_start, adj_size);
- partp->dp_start = adj_size;
- }
-
- /*
- * Adjust size downwards, if necessary, to fall on a cylinder
- * boundary.
- */
- chunks =
- ((partp->dp_start + partp->dp_size) / dos_cylsecs) * dos_cylsecs;
- adj_size = chunks - partp->dp_start;
- if (adj_size != partp->dp_size)
- {
- warnx(
- "WARNING: adjusting size of partition '%d' from %lu to %lu,\n\
- to round to a cylinder boundary",
- partition, (u_long)partp->dp_size, adj_size);
- if (chunks > 0)
- {
- partp->dp_size = adj_size;
- }
- else
- {
- partp->dp_size = 0;
- }
- }
- if (partp->dp_size < 1)
- {
- warnx("ERROR line %d: size for partition '%d' is zero",
- current_line_number, partition);
- break;
- }
-
- dos(partp->dp_start, partp->dp_size,
- &partp->dp_scyl, &partp->dp_ssect, &partp->dp_shd);
- dos(partp->dp_start+partp->dp_size - 1, partp->dp_size,
- &partp->dp_ecyl, &partp->dp_esect, &partp->dp_ehd);
- status = 1;
- break;
- }
- return (status);
-}
-
-
-static int
-process_active(command)
- CMD *command;
-{
- int status = 0, partition, i;
- struct dos_partition *partp;
-
- while (1)
- {
- active_processed = 1;
- if (command->n_args != 1)
- {
- warnx("ERROR line %d: incorrect number of active args",
- current_line_number);
- status = 0;
- break;
- }
- partition = command->args[0].arg_val;
- if (partition < 1 || partition > 4)
- {
- warnx("ERROR line %d: invalid partition number %d",
- current_line_number, partition);
- break;
- }
- /*
- * Reset active partition
- */
- partp = ((struct dos_partition *) &mboot.parts);
- for (i = 0; i < NDOSPART; i++)
- partp[i].dp_flag = 0;
- partp[partition-1].dp_flag = ACTIVE;
-
- status = 1;
- break;
- }
- return (status);
-}
-
-
-static int
-process_line(line)
- char *line;
-{
- CMD command;
- int status = 1;
-
- while (1)
- {
- parse_config_line(line, &command);
- switch (command.cmd)
- {
- case 0:
- /*
- * Comment or blank line
- */
- break;
- case 'g':
- /*
- * Set geometry
- */
- status = process_geometry(&command);
- break;
- case 'p':
- status = process_partition(&command);
- break;
- case 'a':
- status = process_active(&command);
- break;
- default:
- status = 0;
- break;
- }
- break;
- }
- return (status);
-}
-
-
-static int
-read_config(config_file)
- char *config_file;
-{
- FILE *fp = NULL;
- int status = 1;
- char buf[1010];
-
- while (1) /* dirty trick used to insure one exit point for this
- function */
- {
- if (strcmp(config_file, "-") != 0)
- {
- /*
- * We're not reading from stdin
- */
- if ((fp = fopen(config_file, "r")) == NULL)
- {
- status = 0;
- break;
- }
- }
- else
- {
- fp = stdin;
- }
- current_line_number = 0;
- while (!feof(fp))
- {
- if (fgets(buf, sizeof(buf), fp) == NULL)
- {
- break;
- }
- ++current_line_number;
- status = process_line(buf);
- if (status == 0)
- {
- break;
- }
- }
- break;
- }
- if (fp)
- {
- /*
- * It doesn't matter if we're reading from stdin, as we've reached EOF
- */
- fclose(fp);
- }
- return (status);
-}
-
-
-static void
-reset_boot(void)
-{
- int i;
- struct dos_partition *partp;
-
- init_boot();
- for (i = 0; i < 4; ++i)
- {
- partp = ((struct dos_partition *) &mboot.parts) + i;
- bzero((char *)partp, sizeof (struct dos_partition));
- }
-}
diff --git a/sbin/fsck_ffs/Makefile b/sbin/fsck_ffs/Makefile
deleted file mode 100644
index 3155b1a466ea..000000000000
--- a/sbin/fsck_ffs/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
-# @(#)Makefile 8.2 (Berkeley) 4/27/95
-
-PROG= fsck
-MAN8= fsck.8
-SRCS= dir.c inode.c main.c pass1.c pass1b.c pass2.c pass3.c pass4.c \
- pass5.c preen.c setup.c utilities.c ffs_subr.c ffs_tables.c
-CFLAGS+=-W
-.PATH: ${.CURDIR}/../../sys/ufs/ffs
-
-.include <bsd.prog.mk>
diff --git a/sbin/fsck_ffs/SMM.doc/0.t b/sbin/fsck_ffs/SMM.doc/0.t
deleted file mode 100644
index 528dd96a7d8d..000000000000
--- a/sbin/fsck_ffs/SMM.doc/0.t
+++ /dev/null
@@ -1,150 +0,0 @@
-.\" Copyright (c) 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. 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, Berkeley and its contributors.
-.\" 4. 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.
-.\"
-.\" @(#)0.t 8.1 (Berkeley) 6/8/93
-.\"
-.if n .ND
-.TL
-Fsck \- The UNIX\(dg File System Check Program
-.EH 'SMM:3-%''The \s-2UNIX\s+2 File System Check Program'
-.OH 'The \s-2UNIX\s+2 File System Check Program''SMM:3-%'
-.AU
-Marshall Kirk McKusick
-.AI
-Computer Systems Research Group
-Computer Science Division
-Department of Electrical Engineering and Computer Science
-University of California, Berkeley
-Berkeley, CA 94720
-.AU
-T. J. Kowalski
-.AI
-Bell Laboratories
-Murray Hill, New Jersey 07974
-.AB
-.FS
-\(dgUNIX is a trademark of Bell Laboratories.
-.FE
-.FS
-This work was done under grants from
-the National Science Foundation under grant MCS80-05144,
-and the Defense Advance Research Projects Agency (DoD) under
-Arpa Order No. 4031 monitored by Naval Electronic System Command under
-Contract No. N00039-82-C-0235.
-.FE
-This document reflects the use of
-.I fsck
-with the 4.2BSD and 4.3BSD file system organization. This
-is a revision of the
-original paper written by
-T. J. Kowalski.
-.PP
-File System Check Program (\fIfsck\fR)
-is an interactive file system check and repair program.
-.I Fsck
-uses the redundant structural information in the
-UNIX file system to perform several consistency checks.
-If an inconsistency is detected, it is reported
-to the operator, who may elect to fix or ignore
-each inconsistency.
-These inconsistencies result from the permanent interruption
-of the file system updates, which are performed every
-time a file is modified.
-Unless there has been a hardware failure,
-.I fsck
-is able to repair corrupted file systems
-using procedures based upon the order in which UNIX honors
-these file system update requests.
-.PP
-The purpose of this document is to describe the normal updating
-of the file system,
-to discuss the possible causes of file system corruption,
-and to present the corrective actions implemented
-by
-.I fsck.
-Both the program and the interaction between the
-program and the operator are described.
-.sp 2
-.LP
-Revised October 7, 1996
-.AE
-.LP
-.bp
-.ce
-.B "TABLE OF CONTENTS"
-.LP
-.sp 1
-.nf
-.B "1. Introduction"
-.LP
-.sp .5v
-.nf
-.B "2. Overview of the file system
-2.1. Superblock
-2.2. Summary Information
-2.3. Cylinder groups
-2.4. Fragments
-2.5. Updates to the file system
-.LP
-.sp .5v
-.nf
-.B "3. Fixing corrupted file systems
-3.1. Detecting and correcting corruption
-3.2. Super block checking
-3.3. Free block checking
-3.4. Checking the inode state
-3.5. Inode links
-3.6. Inode data size
-3.7. Checking the data associated with an inode
-3.8. File system connectivity
-.LP
-.sp .5v
-.nf
-.B Acknowledgements
-.LP
-.sp .5v
-.nf
-.B References
-.LP
-.sp .5v
-.nf
-.B "4. Appendix A
-4.1. Conventions
-4.2. Initialization
-4.3. Phase 1 - Check Blocks and Sizes
-4.4. Phase 1b - Rescan for more Dups
-4.5. Phase 2 - Check Pathnames
-4.6. Phase 3 - Check Connectivity
-4.7. Phase 4 - Check Reference Counts
-4.8. Phase 5 - Check Cyl groups
-4.9. Cleanup
-.ds RH Introduction
-.bp
diff --git a/sbin/fsck_ffs/SMM.doc/1.t b/sbin/fsck_ffs/SMM.doc/1.t
deleted file mode 100644
index 4d2f5357131b..000000000000
--- a/sbin/fsck_ffs/SMM.doc/1.t
+++ /dev/null
@@ -1,83 +0,0 @@
-.\" Copyright (c) 1982, 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. 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, Berkeley and its contributors.
-.\" 4. 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.
-.\"
-.\" @(#)1.t 8.1 (Berkeley) 6/5/93
-.\"
-.ds RH Introduction
-.NH
-Introduction
-.PP
-This document reflects the use of
-.I fsck
-with the 4.2BSD and 4.3BSD file system organization. This
-is a revision of the
-original paper written by
-T. J. Kowalski.
-.PP
-When a UNIX
-operating system is brought up, a consistency
-check of the file systems should always be performed.
-This precautionary measure helps to insure
-a reliable environment for file storage on disk.
-If an inconsistency is discovered,
-corrective action must be taken.
-.I Fsck
-runs in two modes.
-Normally it is run non-interactively by the system after
-a normal boot.
-When running in this mode,
-it will only make changes to the file system that are known
-to always be correct.
-If an unexpected inconsistency is found
-.I fsck
-will exit with a non-zero exit status,
-leaving the system running single-user.
-Typically the operator then runs
-.I fsck
-interactively.
-When running in this mode,
-each problem is listed followed by a suggested corrective action.
-The operator must decide whether or not the suggested correction
-should be made.
-.PP
-The purpose of this memo is to dispel the
-mystique surrounding
-file system inconsistencies.
-It first describes the updating of the file system
-(the calm before the storm) and
-then describes file system corruption (the storm).
-Finally,
-the set of deterministic corrective actions
-used by
-.I fsck
-(the Coast Guard
-to the rescue) is presented.
-.ds RH Overview of the File System
diff --git a/sbin/fsck_ffs/SMM.doc/2.t b/sbin/fsck_ffs/SMM.doc/2.t
deleted file mode 100644
index 7d00ceaa4efd..000000000000
--- a/sbin/fsck_ffs/SMM.doc/2.t
+++ /dev/null
@@ -1,265 +0,0 @@
-.\" Copyright (c) 1982, 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. 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, Berkeley and its contributors.
-.\" 4. 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.
-.\"
-.\" @(#)2.t 8.1 (Berkeley) 6/5/93
-.\"
-.ds RH Overview of the file system
-.NH
-Overview of the file system
-.PP
-The file system is discussed in detail in [Mckusick84];
-this section gives a brief overview.
-.NH 2
-Superblock
-.PP
-A file system is described by its
-.I "super-block" .
-The super-block is built when the file system is created (\c
-.I newfs (8))
-and never changes.
-The super-block
-contains the basic parameters of the file system,
-such as the number of data blocks it contains
-and a count of the maximum number of files.
-Because the super-block contains critical data,
-.I newfs
-replicates it to protect against catastrophic loss.
-The
-.I "default super block"
-always resides at a fixed offset from the beginning
-of the file system's disk partition.
-The
-.I "redundant super blocks"
-are not referenced unless a head crash
-or other hard disk error causes the default super-block
-to be unusable.
-The redundant blocks are sprinkled throughout the disk partition.
-.PP
-Within the file system are files.
-Certain files are distinguished as directories and contain collections
-of pointers to files that may themselves be directories.
-Every file has a descriptor associated with it called an
-.I "inode".
-The inode contains information describing ownership of the file,
-time stamps indicating modification and access times for the file,
-and an array of indices pointing to the data blocks for the file.
-In this section,
-we assume that the first 12 blocks
-of the file are directly referenced by values stored
-in the inode structure itself\(dg.
-.FS
-\(dgThe actual number may vary from system to system, but is usually in
-the range 5-13.
-.FE
-The inode structure may also contain references to indirect blocks
-containing further data block indices.
-In a file system with a 4096 byte block size, a singly indirect
-block contains 1024 further block addresses,
-a doubly indirect block contains 1024 addresses of further single indirect
-blocks,
-and a triply indirect block contains 1024 addresses of further doubly indirect
-blocks (the triple indirect block is never needed in practice).
-.PP
-In order to create files with up to
-2\(ua32 bytes,
-using only two levels of indirection,
-the minimum size of a file system block is 4096 bytes.
-The size of file system blocks can be any power of two
-greater than or equal to 4096.
-The block size of the file system is maintained in the super-block,
-so it is possible for file systems of different block sizes
-to be accessible simultaneously on the same system.
-The block size must be decided when
-.I newfs
-creates the file system;
-the block size cannot be subsequently
-changed without rebuilding the file system.
-.NH 2
-Summary information
-.PP
-Associated with the super block is non replicated
-.I "summary information" .
-The summary information changes
-as the file system is modified.
-The summary information contains
-the number of blocks, fragments, inodes and directories in the file system.
-.NH 2
-Cylinder groups
-.PP
-The file system partitions the disk into one or more areas called
-.I "cylinder groups".
-A cylinder group is comprised of one or more consecutive
-cylinders on a disk.
-Each cylinder group includes inode slots for files, a
-.I "block map"
-describing available blocks in the cylinder group,
-and summary information describing the usage of data blocks
-within the cylinder group.
-A fixed number of inodes is allocated for each cylinder group
-when the file system is created.
-The current policy is to allocate one inode for each 2048
-bytes of disk space;
-this is expected to be far more inodes than will ever be needed.
-.PP
-All the cylinder group bookkeeping information could be
-placed at the beginning of each cylinder group.
-However if this approach were used,
-all the redundant information would be on the top platter.
-A single hardware failure that destroyed the top platter
-could cause the loss of all copies of the redundant super-blocks.
-Thus the cylinder group bookkeeping information
-begins at a floating offset from the beginning of the cylinder group.
-The offset for
-the
-.I "i+1" st
-cylinder group is about one track further
-from the beginning of the cylinder group
-than it was for the
-.I "i" th
-cylinder group.
-In this way,
-the redundant
-information spirals down into the pack;
-any single track, cylinder,
-or platter can be lost without losing all copies of the super-blocks.
-Except for the first cylinder group,
-the space between the beginning of the cylinder group
-and the beginning of the cylinder group information stores data.
-.NH 2
-Fragments
-.PP
-To avoid waste in storing small files,
-the file system space allocator divides a single
-file system block into one or more
-.I "fragments".
-The fragmentation of the file system is specified
-when the file system is created;
-each file system block can be optionally broken into
-2, 4, or 8 addressable fragments.
-The lower bound on the size of these fragments is constrained
-by the disk sector size;
-typically 512 bytes is the lower bound on fragment size.
-The block map associated with each cylinder group
-records the space availability at the fragment level.
-Aligned fragments are examined
-to determine block availability.
-.PP
-On a file system with a block size of 4096 bytes
-and a fragment size of 1024 bytes,
-a file is represented by zero or more 4096 byte blocks of data,
-and possibly a single fragmented block.
-If a file system block must be fragmented to obtain
-space for a small amount of data,
-the remainder of the block is made available for allocation
-to other files.
-For example,
-consider an 11000 byte file stored on
-a 4096/1024 byte file system.
-This file uses two full size blocks and a 3072 byte fragment.
-If no fragments with at least 3072 bytes
-are available when the file is created,
-a full size block is split yielding the necessary 3072 byte
-fragment and an unused 1024 byte fragment.
-This remaining fragment can be allocated to another file, as needed.
-.NH 2
-Updates to the file system
-.PP
-Every working day hundreds of files
-are created, modified, and removed.
-Every time a file is modified,
-the operating system performs a
-series of file system updates.
-These updates, when written on disk, yield a consistent file system.
-The file system stages
-all modifications of critical information;
-modification can
-either be completed or cleanly backed out after a crash.
-Knowing the information that is first written to the file system,
-deterministic procedures can be developed to
-repair a corrupted file system.
-To understand this process,
-the order that the update
-requests were being honored must first be understood.
-.PP
-When a user program does an operation to change the file system,
-such as a
-.I write ,
-the data to be written is copied into an internal
-.I "in-core"
-buffer in the kernel.
-Normally, the disk update is handled asynchronously;
-the user process is allowed to proceed even though
-the data has not yet been written to the disk.
-The data,
-along with the inode information reflecting the change,
-is eventually written out to disk.
-The real disk write may not happen until long after the
-.I write
-system call has returned.
-Thus at any given time, the file system,
-as it resides on the disk,
-lags the state of the file system represented by the in-core information.
-.PP
-The disk information is updated to reflect the in-core information
-when the buffer is required for another use,
-when a
-.I sync (2)
-is done (at 30 second intervals) by
-.I "/etc/update" "(8),"
-or by manual operator intervention with the
-.I sync (8)
-command.
-If the system is halted without writing out the in-core information,
-the file system on the disk will be in an inconsistent state.
-.PP
-If all updates are done asynchronously, several serious
-inconsistencies can arise.
-One inconsistency is that a block may be claimed by two inodes.
-Such an inconsistency can occur when the system is halted before
-the pointer to the block in the old inode has been cleared
-in the copy of the old inode on the disk,
-and after the pointer to the block in the new inode has been written out
-to the copy of the new inode on the disk.
-Here,
-there is no deterministic method for deciding
-which inode should really claim the block.
-A similar problem can arise with a multiply claimed inode.
-.PP
-The problem with asynchronous inode updates
-can be avoided by doing all inode deallocations synchronously.
-Consequently,
-inodes and indirect blocks are written to the disk synchronously
-(\fIi.e.\fP the process blocks until the information is
-really written to disk)
-when they are being deallocated.
-Similarly inodes are kept consistent by synchronously
-deleting, adding, or changing directory entries.
-.ds RH Fixing corrupted file systems
diff --git a/sbin/fsck_ffs/SMM.doc/3.t b/sbin/fsck_ffs/SMM.doc/3.t
deleted file mode 100644
index bb6f05b8c038..000000000000
--- a/sbin/fsck_ffs/SMM.doc/3.t
+++ /dev/null
@@ -1,452 +0,0 @@
-.\" Copyright (c) 1982, 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. 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, Berkeley and its contributors.
-.\" 4. 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.
-.\"
-.\" @(#)3.t 8.1 (Berkeley) 6/5/93
-.\"
-.ds RH Fixing corrupted file systems
-.NH
-Fixing corrupted file systems
-.PP
-A file system
-can become corrupted in several ways.
-The most common of these ways are
-improper shutdown procedures
-and hardware failures.
-.PP
-File systems may become corrupted during an
-.I "unclean halt" .
-This happens when proper shutdown
-procedures are not observed,
-physically write-protecting a mounted file system,
-or a mounted file system is taken off-line.
-The most common operator procedural failure is forgetting to
-.I sync
-the system before halting the CPU.
-.PP
-File systems may become further corrupted if proper startup
-procedures are not observed, e.g.,
-not checking a file system for inconsistencies,
-and not repairing inconsistencies.
-Allowing a corrupted file system to be used (and, thus, to be modified
-further) can be disastrous.
-.PP
-Any piece of hardware can fail at any time.
-Failures
-can be as subtle as a bad block
-on a disk pack, or as blatant as a non-functional disk-controller.
-.NH 2
-Detecting and correcting corruption
-.PP
-Normally
-.I fsck
-is run non-interactively.
-In this mode it will only fix
-corruptions that are expected to occur from an unclean halt.
-These actions are a proper subset of the actions that
-.I fsck
-will take when it is running interactively.
-Throughout this paper we assume that
-.I fsck
-is being run interactively,
-and all possible errors can be encountered.
-When an inconsistency is discovered in this mode,
-.I fsck
-reports the inconsistency for the operator to
-chose a corrective action.
-.PP
-A quiescent\(dd
-.FS
-\(dd I.e., unmounted and not being written on.
-.FE
-file system may be checked for structural integrity
-by performing consistency checks on the
-redundant data intrinsic to a file system.
-The redundant data is either read from
-the file system,
-or computed from other known values.
-The file system
-.B must
-be in a quiescent state when
-.I fsck
-is run,
-since
-.I fsck
-is a multi-pass program.
-.PP
-In the following sections,
-we discuss methods to discover inconsistencies
-and possible corrective actions
-for the cylinder group blocks, the inodes, the indirect blocks, and
-the data blocks containing directory entries.
-.NH 2
-Super-block checking
-.PP
-The most commonly corrupted item in a file system
-is the summary information
-associated with the super-block.
-The summary information is prone to corruption
-because it is modified with every change to the file
-system's blocks or inodes,
-and is usually corrupted
-after an unclean halt.
-.PP
-The super-block is checked for inconsistencies
-involving file-system size, number of inodes,
-free-block count, and the free-inode count.
-The file-system size must be larger than the
-number of blocks used by the super-block
-and the number of blocks used by the list of inodes.
-The file-system size and layout information
-are the most critical pieces of information for
-.I fsck .
-While there is no way to actually check these sizes,
-since they are statically determined by
-.I newfs ,
-.I fsck
-can check that these sizes are within reasonable bounds.
-All other file system checks require that these sizes be correct.
-If
-.I fsck
-detects corruption in the static parameters of the default super-block,
-.I fsck
-requests the operator to specify the location of an alternate super-block.
-.NH 2
-Free block checking
-.PP
-.I Fsck
-checks that all the blocks
-marked as free in the cylinder group block maps
-are not claimed by any files.
-When all the blocks have been initially accounted for,
-.I fsck
-checks that
-the number of free blocks
-plus the number of blocks claimed by the inodes
-equals the total number of blocks in the file system.
-.PP
-If anything is wrong with the block allocation maps,
-.I fsck
-will rebuild them,
-based on the list it has computed of allocated blocks.
-.PP
-The summary information associated with the super-block
-counts the total number of free blocks within the file system.
-.I Fsck
-compares this count to the
-number of free blocks it found within the file system.
-If the two counts do not agree, then
-.I fsck
-replaces the incorrect count in the summary information
-by the actual free-block count.
-.PP
-The summary information
-counts the total number of free inodes within the file system.
-.I Fsck
-compares this count to the number
-of free inodes it found within the file system.
-If the two counts do not agree, then
-.I fsck
-replaces the incorrect count in the
-summary information by the actual free-inode count.
-.NH 2
-Checking the inode state
-.PP
-An individual inode is not as likely to be corrupted as
-the allocation information.
-However, because of the great number of active inodes,
-a few of the inodes are usually corrupted.
-.PP
-The list of inodes in the file system
-is checked sequentially starting with inode 2
-(inode 0 marks unused inodes;
-inode 1 is saved for future generations)
-and progressing through the last inode in the file system.
-The state of each inode is checked for
-inconsistencies involving format and type,
-link count,
-duplicate blocks,
-bad blocks,
-and inode size.
-.PP
-Each inode contains a mode word.
-This mode word describes the type and state of the inode.
-Inodes must be one of six types:
-regular inode, directory inode, symbolic link inode,
-special block inode, special character inode, or socket inode.
-Inodes may be found in one of three allocation states:
-unallocated, allocated, and neither unallocated nor allocated.
-This last state suggests an incorrectly formated inode.
-An inode can get in this state if
-bad data is written into the inode list.
-The only possible corrective action is for
-.I fsck
-is to clear the inode.
-.NH 2
-Inode links
-.PP
-Each inode counts the
-total number of directory entries
-linked to the inode.
-.I Fsck
-verifies the link count of each inode
-by starting at the root of the file system,
-and descending through the directory structure.
-The actual link count for each inode
-is calculated during the descent.
-.PP
-If the stored link count is non-zero and the actual
-link count is zero,
-then no directory entry appears for the inode.
-If this happens,
-.I fsck
-will place the disconnected file in the
-.I lost+found
-directory.
-If the stored and actual link counts are non-zero and unequal,
-a directory entry may have been added or removed without the inode being
-updated.
-If this happens,
-.I fsck
-replaces the incorrect stored link count by the actual link count.
-.PP
-Each inode contains a list,
-or pointers to
-lists (indirect blocks),
-of all the blocks claimed by the inode.
-Since indirect blocks are owned by an inode,
-inconsistencies in indirect blocks directly
-affect the inode that owns it.
-.PP
-.I Fsck
-compares each block number claimed by an inode
-against a list of already allocated blocks.
-If another inode already claims a block number,
-then the block number is added to a list of
-.I "duplicate blocks" .
-Otherwise, the list of allocated blocks
-is updated to include the block number.
-.PP
-If there are any duplicate blocks,
-.I fsck
-will perform a partial second
-pass over the inode list
-to find the inode of the duplicated block.
-The second pass is needed,
-since without examining the files associated with
-these inodes for correct content,
-not enough information is available
-to determine which inode is corrupted and should be cleared.
-If this condition does arise
-(only hardware failure will cause it),
-then the inode with the earliest
-modify time is usually incorrect,
-and should be cleared.
-If this happens,
-.I fsck
-prompts the operator to clear both inodes.
-The operator must decide which one should be kept
-and which one should be cleared.
-.PP
-.I Fsck
-checks the range of each block number claimed by an inode.
-If the block number is
-lower than the first data block in the file system,
-or greater than the last data block,
-then the block number is a
-.I "bad block number" .
-Many bad blocks in an inode are usually caused by
-an indirect block that was not written to the file system,
-a condition which can only occur if there has been a hardware failure.
-If an inode contains bad block numbers,
-.I fsck
-prompts the operator to clear it.
-.NH 2
-Inode data size
-.PP
-Each inode contains a count of the number of data blocks
-that it contains.
-The number of actual data blocks
-is the sum of the allocated data blocks
-and the indirect blocks.
-.I Fsck
-computes the actual number of data blocks
-and compares that block count against
-the actual number of blocks the inode claims.
-If an inode contains an incorrect count
-.I fsck
-prompts the operator to fix it.
-.PP
-Each inode contains a thirty-two bit size field.
-The size is the number of data bytes
-in the file associated with the inode.
-The consistency of the byte size field is roughly checked
-by computing from the size field the maximum number of blocks
-that should be associated with the inode,
-and comparing that expected block count against
-the actual number of blocks the inode claims.
-.NH 2
-Checking the data associated with an inode
-.PP
-An inode can directly or indirectly
-reference three kinds of data blocks.
-All referenced blocks must be the same kind.
-The three types of data blocks are:
-plain data blocks, symbolic link data blocks, and directory data blocks.
-Plain data blocks
-contain the information stored in a file;
-symbolic link data blocks
-contain the path name stored in a link.
-Directory data blocks contain directory entries.
-.I Fsck
-can only check the validity of directory data blocks.
-.PP
-Each directory data block is checked for
-several types of inconsistencies.
-These inconsistencies include
-directory inode numbers pointing to unallocated inodes,
-directory inode numbers that are greater than
-the number of inodes in the file system,
-incorrect directory inode numbers for ``\fB.\fP'' and ``\fB..\fP'',
-and directories that are not attached to the file system.
-If the inode number in a directory data block
-references an unallocated inode,
-then
-.I fsck
-will remove that directory entry.
-Again,
-this condition can only arise when there has been a hardware failure.
-.PP
-.I Fsck
-also checks for directories with unallocated blocks (holes).
-Such directories should never be created.
-When found,
-.I fsck
-will prompt the user to adjust the length of the offending directory
-which is done by shortening the size of the directory to the end of the
-last allocated block preceeding the hole.
-Unfortunately, this means that another Phase 1 run has to be done.
-.I Fsck
-will remind the user to rerun fsck after repairing a
-directory containing an unallocated block.
-.PP
-If a directory entry inode number references
-outside the inode list, then
-.I fsck
-will remove that directory entry.
-This condition occurs if bad data is written into a directory data block.
-.PP
-The directory inode number entry for ``\fB.\fP''
-must be the first entry in the directory data block.
-The inode number for ``\fB.\fP''
-must reference itself;
-e.g., it must equal the inode number
-for the directory data block.
-The directory inode number entry
-for ``\fB..\fP'' must be
-the second entry in the directory data block.
-Its value must equal the inode number for the
-parent of the directory entry
-(or the inode number of the directory
-data block if the directory is the
-root directory).
-If the directory inode numbers are
-incorrect,
-.I fsck
-will replace them with the correct values.
-If there are multiple hard links to a directory,
-the first one encountered is considered the real parent
-to which ``\fB..\fP'' should point;
-\fIfsck\fP recommends deletion for the subsequently discovered names.
-.NH 2
-File system connectivity
-.PP
-.I Fsck
-checks the general connectivity of the file system.
-If directories are not linked into the file system, then
-.I fsck
-links the directory back into the file system in the
-.I lost+found
-directory.
-This condition only occurs when there has been a hardware failure.
-.ds RH "References"
-.SH
-\s+2Acknowledgements\s0
-.PP
-I thank Bill Joy, Sam Leffler, Robert Elz and Dennis Ritchie
-for their suggestions and help in implementing the new file system.
-Thanks also to Robert Henry for his editorial input to
-get this document together.
-Finally we thank our sponsors,
-the National Science Foundation under grant MCS80-05144,
-and the Defense Advance Research Projects Agency (DoD) under
-Arpa Order No. 4031 monitored by Naval Electronic System Command under
-Contract No. N00039-82-C-0235. (Kirk McKusick, July 1983)
-.PP
-I would like to thank Larry A. Wehr for advice that lead
-to the first version of
-.I fsck
-and Rick B. Brandt for adapting
-.I fsck
-to
-UNIX/TS. (T. Kowalski, July 1979)
-.sp 2
-.SH
-\s+2References\s0
-.LP
-.IP [Dolotta78] 20
-Dolotta, T. A., and Olsson, S. B. eds.,
-.I "UNIX User's Manual, Edition 1.1\^" ,
-January 1978.
-.IP [Joy83] 20
-Joy, W., Cooper, E., Fabry, R., Leffler, S., McKusick, M., and Mosher, D.
-4.2BSD System Manual,
-.I "University of California at Berkeley" ,
-.I "Computer Systems Research Group Technical Report"
-#4, 1982.
-.IP [McKusick84] 20
-McKusick, M., Joy, W., Leffler, S., and Fabry, R.
-A Fast File System for UNIX,
-\fIACM Transactions on Computer Systems 2\fP, 3.
-pp. 181-197, August 1984.
-.IP [Ritchie78] 20
-Ritchie, D. M., and Thompson, K.,
-The UNIX Time-Sharing System,
-.I "The Bell System Technical Journal"
-.B 57 ,
-6 (July-August 1978, Part 2), pp. 1905-29.
-.IP [Thompson78] 20
-Thompson, K.,
-UNIX Implementation,
-.I "The Bell System Technical Journal\^"
-.B 57 ,
-6 (July-August 1978, Part 2), pp. 1931-46.
-.ds RH Appendix A \- Fsck Error Conditions
-.bp
diff --git a/sbin/fsck_ffs/SMM.doc/4.t b/sbin/fsck_ffs/SMM.doc/4.t
deleted file mode 100644
index 5ea8179fa904..000000000000
--- a/sbin/fsck_ffs/SMM.doc/4.t
+++ /dev/null
@@ -1,1424 +0,0 @@
-.\" Copyright (c) 1982, 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. 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, Berkeley and its contributors.
-.\" 4. 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.
-.\"
-.\" @(#)4.t 8.1 (Berkeley) 6/5/93
-.\"
-.ds RH Appendix A \- Fsck Error Conditions
-.NH
-Appendix A \- Fsck Error Conditions
-.NH 2
-Conventions
-.PP
-.I Fsck
-is
-a multi-pass file system check program.
-Each file system pass invokes a different Phase of the
-.I fsck
-program.
-After the initial setup,
-.I fsck
-performs successive Phases over each file system,
-checking blocks and sizes,
-path-names,
-connectivity,
-reference counts,
-and the map of free blocks,
-(possibly rebuilding it),
-and performs some cleanup.
-.LP
-Normally
-.I fsck
-is run non-interactively to
-.I preen
-the file systems after an unclean halt.
-While preen'ing a file system,
-it will only fix corruptions that are expected
-to occur from an unclean halt.
-These actions are a proper subset of the actions that
-.I fsck
-will take when it is running interactively.
-Throughout this appendix many errors have several options
-that the operator can take.
-When an inconsistency is detected,
-.I fsck
-reports the error condition to the operator.
-If a response is required,
-.I fsck
-prints a prompt message and
-waits for a response.
-When preen'ing most errors are fatal.
-For those that are expected,
-the response taken is noted.
-This appendix explains the meaning of each error condition,
-the possible responses, and the related error conditions.
-.LP
-The error conditions are organized by the
-.I Phase
-of the
-.I fsck
-program in which they can occur.
-The error conditions that may occur
-in more than one Phase
-will be discussed in initialization.
-.NH 2
-Initialization
-.PP
-Before a file system check can be performed, certain
-tables have to be set up and certain files opened.
-This section concerns itself with the opening of files and
-the initialization of tables.
-This section lists error conditions resulting from
-command line options,
-memory requests,
-opening of files,
-status of files,
-file system size checks,
-and creation of the scratch file.
-All the initialization errors are fatal
-when the file system is being preen'ed.
-.sp
-.LP
-.B "\fIC\fP option?"
-.br
-\fIC\fP is not a legal option to
-.I fsck ;
-legal options are \-b, \-c, \-y, \-n, and \-p.
-.I Fsck
-terminates on this error condition.
-See the
-.I fsck (8)
-manual entry for further detail.
-.sp
-.LP
-.B "cannot alloc NNN bytes for blockmap"
-.br
-.B "cannot alloc NNN bytes for freemap"
-.br
-.B "cannot alloc NNN bytes for statemap"
-.br
-.B "cannot alloc NNN bytes for lncntp"
-.br
-.I Fsck 's
-request for memory for its virtual
-memory tables failed.
-This should never happen.
-.I Fsck
-terminates on this error condition.
-See a guru.
-.sp
-.LP
-.B "Can't open checklist file: \fIF\fP"
-.br
-The file system checklist file
-\fIF\fP (usually
-.I /etc/fstab )
-can not be opened for reading.
-.I Fsck
-terminates on this error condition.
-Check access modes of \fIF\fP.
-.sp
-.LP
-.B "Can't stat root"
-.br
-.I Fsck 's
-request for statistics about the root directory ``/'' failed.
-This should never happen.
-.I Fsck
-terminates on this error condition.
-See a guru.
-.sp
-.LP
-.B "Can't stat \fIF\fP"
-.br
-.B "Can't make sense out of name \fIF\fP"
-.br
-.I Fsck 's
-request for statistics about the file system \fIF\fP failed.
-When running manually,
-it ignores this file system
-and continues checking the next file system given.
-Check access modes of \fIF\fP.
-.sp
-.LP
-.B "Can't open \fIF\fP"
-.br
-.I Fsck 's
-request attempt to open the file system \fIF\fP failed.
-When running manually, it ignores this file system
-and continues checking the next file system given.
-Check access modes of \fIF\fP.
-.sp
-.LP
-.B "\fIF\fP: (NO WRITE)"
-.br
-Either the \-n flag was specified or
-.I fsck 's
-attempt to open the file system \fIF\fP for writing failed.
-When running manually,
-all the diagnostics are printed out,
-but no modifications are attempted to fix them.
-.sp
-.LP
-.B "file is not a block or character device; OK"
-.br
-You have given
-.I fsck
-a regular file name by mistake.
-Check the type of the file specified.
-.LP
-Possible responses to the OK prompt are:
-.IP YES
-ignore this error condition.
-.IP NO
-ignore this file system and continues checking
-the next file system given.
-.sp
-.LP
-.B "UNDEFINED OPTIMIZATION IN SUPERBLOCK (SET TO DEFAULT)"
-.br
-The superblock optimization parameter is neither OPT_TIME
-nor OPT_SPACE.
-.LP
-Possible responses to the SET TO DEFAULT prompt are:
-.IP YES
-The superblock is set to request optimization to minimize
-running time of the system.
-(If optimization to minimize disk space utilization is
-desired, it can be set using \fItunefs\fP(8).)
-.IP NO
-ignore this error condition.
-.sp
-.LP
-.B "IMPOSSIBLE MINFREE=\fID\fP IN SUPERBLOCK (SET TO DEFAULT)"
-.br
-The superblock minimum space percentage is greater than 99%
-or less then 0%.
-.LP
-Possible responses to the SET TO DEFAULT prompt are:
-.IP YES
-The minfree parameter is set to 10%.
-(If some other percentage is desired,
-it can be set using \fItunefs\fP(8).)
-.IP NO
-ignore this error condition.
-.sp
-.LP
-.B "IMPOSSIBLE INTERLEAVE=\fID\fP IN SUPERBLOCK (SET TO DEFAULT)"
-.br
-The file system interleave is less than or equal to zero.
-.LP
-Possible responses to the SET TO DEFAULT prompt are:
-.IP YES
-The interleave parameter is set to 1.
-.IP NO
-ignore this error condition.
-.sp
-.LP
-.B "IMPOSSIBLE NPSECT=\fID\fP IN SUPERBLOCK (SET TO DEFAULT)"
-.br
-The number of physical sectors per track is less than the number
-of usable sectors per track.
-.LP
-Possible responses to the SET TO DEFAULT prompt are:
-.IP YES
-The npsect parameter is set to the number of usable sectors per track.
-.IP NO
-ignore this error condition.
-.sp
-.LP
-One of the following messages will appear:
-.br
-.B "MAGIC NUMBER WRONG"
-.br
-.B "NCG OUT OF RANGE"
-.br
-.B "CPG OUT OF RANGE"
-.br
-.B "NCYL DOES NOT JIVE WITH NCG*CPG"
-.br
-.B "SIZE PREPOSTEROUSLY LARGE"
-.br
-.B "TRASHED VALUES IN SUPER BLOCK"
-.br
-and will be followed by the message:
-.br
-.B "\fIF\fP: BAD SUPER BLOCK: \fIB\fP"
-.br
-.B "USE -b OPTION TO FSCK TO SPECIFY LOCATION OF AN ALTERNATE"
-.br
-.B "SUPER-BLOCK TO SUPPLY NEEDED INFORMATION; SEE fsck(8)."
-.br
-The super block has been corrupted.
-An alternative super block must be selected from among those
-listed by
-.I newfs
-(8) when the file system was created.
-For file systems with a blocksize less than 32K,
-specifying \-b 32 is a good first choice.
-.sp
-.LP
-.B "INTERNAL INCONSISTENCY: \fIM\fP"
-.br
-.I Fsck 's
-has had an internal panic, whose message is specified as \fIM\fP.
-This should never happen.
-See a guru.
-.sp
-.LP
-.B "CAN NOT SEEK: BLK \fIB\fP (CONTINUE)"
-.br
-.I Fsck 's
-request for moving to a specified block number \fIB\fP in
-the file system failed.
-This should never happen.
-See a guru.
-.LP
-Possible responses to the CONTINUE prompt are:
-.IP YES
-attempt to continue to run the file system check.
-Often,
-however the problem will persist.
-This error condition will not allow a complete check of the file system.
-A second run of
-.I fsck
-should be made to re-check this file system.
-If the block was part of the virtual memory buffer
-cache,
-.I fsck
-will terminate with the message ``Fatal I/O error''.
-.IP NO
-terminate the program.
-.sp
-.LP
-.B "CAN NOT READ: BLK \fIB\fP (CONTINUE)"
-.br
-.I Fsck 's
-request for reading a specified block number \fIB\fP in
-the file system failed.
-This should never happen.
-See a guru.
-.LP
-Possible responses to the CONTINUE prompt are:
-.IP YES
-attempt to continue to run the file system check.
-It will retry the read and print out the message:
-.br
-.B "THE FOLLOWING SECTORS COULD NOT BE READ: \fIN\fP"
-.br
-where \fIN\fP indicates the sectors that could not be read.
-If
-.I fsck
-ever tries to write back one of the blocks on which the read failed
-it will print the message:
-.br
-.B "WRITING ZERO'ED BLOCK \fIN\fP TO DISK"
-.br
-where \fIN\fP indicates the sector that was written with zero's.
-If the disk is experiencing hardware problems, the problem will persist.
-This error condition will not allow a complete check of the file system.
-A second run of
-.I fsck
-should be made to re-check this file system.
-If the block was part of the virtual memory buffer
-cache,
-.I fsck
-will terminate with the message ``Fatal I/O error''.
-.IP NO
-terminate the program.
-.sp
-.LP
-.B "CAN NOT WRITE: BLK \fIB\fP (CONTINUE)"
-.br
-.I Fsck 's
-request for writing a specified block number \fIB\fP
-in the file system failed.
-The disk is write-protected;
-check the write protect lock on the drive.
-If that is not the problem, see a guru.
-.LP
-Possible responses to the CONTINUE prompt are:
-.IP YES
-attempt to continue to run the file system check.
-The write operation will be retried with the failed blocks
-indicated by the message:
-.br
-.B "THE FOLLOWING SECTORS COULD NOT BE WRITTEN: \fIN\fP"
-.br
-where \fIN\fP indicates the sectors that could not be written.
-If the disk is experiencing hardware problems, the problem will persist.
-This error condition will not allow a complete check of the file system.
-A second run of
-.I fsck
-should be made to re-check this file system.
-If the block was part of the virtual memory buffer
-cache,
-.I fsck
-will terminate with the message ``Fatal I/O error''.
-.IP NO
-terminate the program.
-.sp
-.LP
-.B "bad inode number DDD to ginode"
-.br
-An internal error has attempted to read non-existent inode \fIDDD\fP.
-This error causes
-.I fsck
-to exit.
-See a guru.
-.NH 2
-Phase 1 \- Check Blocks and Sizes
-.PP
-This phase concerns itself with
-the inode list.
-This section lists error conditions resulting from
-checking inode types,
-setting up the zero-link-count table,
-examining inode block numbers for bad or duplicate blocks,
-checking inode size,
-and checking inode format.
-All errors in this phase except
-.B "INCORRECT BLOCK COUNT"
-and
-.B "PARTIALLY TRUNCATED INODE"
-are fatal if the file system is being preen'ed.
-.sp
-.LP
-.B "UNKNOWN FILE TYPE I=\fII\fP (CLEAR)"
-.br
-The mode word of the inode \fII\fP indicates that the inode is not a
-special block inode, special character inode, socket inode, regular inode,
-symbolic link, or directory inode.
-.LP
-Possible responses to the CLEAR prompt are:
-.IP YES
-de-allocate inode \fII\fP by zeroing its contents.
-This will always invoke the UNALLOCATED error condition in Phase 2
-for each directory entry pointing to this inode.
-.IP NO
-ignore this error condition.
-.sp
-.LP
-.B "PARTIALLY TRUNCATED INODE I=\fII\fP (SALVAGE)"
-.br
-.I Fsck
-has found inode \fII\fP whose size is shorter than the number of
-blocks allocated to it.
-This condition should only occur if the system crashes while in the
-midst of truncating a file.
-When preen'ing the file system,
-.I fsck
-completes the truncation to the specified size.
-.LP
-Possible responses to SALVAGE are:
-.IP YES
-complete the truncation to the size specified in the inode.
-.IP NO
-ignore this error condition.
-.sp
-.LP
-.B "LINK COUNT TABLE OVERFLOW (CONTINUE)"
-.br
-An internal table for
-.I fsck
-containing allocated inodes with a link count of
-zero cannot allocate more memory.
-Increase the virtual memory for
-.I fsck .
-.LP
-Possible responses to the CONTINUE prompt are:
-.IP YES
-continue with the program.
-This error condition will not allow a complete check of the file system.
-A second run of
-.I fsck
-should be made to re-check this file system.
-If another allocated inode with a zero link count is found,
-this error condition is repeated.
-.IP NO
-terminate the program.
-.sp
-.LP
-.B "\fIB\fP BAD I=\fII\fP"
-.br
-Inode \fII\fP contains block number \fIB\fP with a number
-lower than the number of the first data block in the file system or
-greater than the number of the last block
-in the file system.
-This error condition may invoke the
-.B "EXCESSIVE BAD BLKS"
-error condition in Phase 1 (see next paragraph) if
-inode \fII\fP has too many block numbers outside the file system range.
-This error condition will always invoke the
-.B "BAD/DUP"
-error condition in Phase 2 and Phase 4.
-.sp
-.LP
-.B "EXCESSIVE BAD BLKS I=\fII\fP (CONTINUE)"
-.br
-There is more than a tolerable number (usually 10) of blocks with a number
-lower than the number of the first data block in the file system or greater than
-the number of last block in the file system associated with inode \fII\fP.
-.LP
-Possible responses to the CONTINUE prompt are:
-.IP YES
-ignore the rest of the blocks in this inode
-and continue checking with the next inode in the file system.
-This error condition will not allow a complete check of the file system.
-A second run of
-.I fsck
-should be made to re-check this file system.
-.IP NO
-terminate the program.
-.sp
-.LP
-.B "BAD STATE DDD TO BLKERR"
-.br
-An internal error has scrambled
-.I fsck 's
-state map to have the impossible value \fIDDD\fP.
-.I Fsck
-exits immediately.
-See a guru.
-.sp
-.LP
-.B "\fIB\fP DUP I=\fII\fP"
-.br
-Inode \fII\fP contains block number \fIB\fP that is already claimed by
-another inode.
-This error condition may invoke the
-.B "EXCESSIVE DUP BLKS"
-error condition in Phase 1 if
-inode \fII\fP has too many block numbers claimed by other inodes.
-This error condition will always invoke Phase 1b and the
-.B "BAD/DUP"
-error condition in Phase 2 and Phase 4.
-.sp
-.LP
-.B "EXCESSIVE DUP BLKS I=\fII\fP (CONTINUE)"
-.br
-There is more than a tolerable number (usually 10) of blocks claimed by other
-inodes.
-.LP
-Possible responses to the CONTINUE prompt are:
-.IP YES
-ignore the rest of the blocks in this inode
-and continue checking with the next inode in the file system.
-This error condition will not allow a complete check of the file system.
-A second run of
-.I fsck
-should be made to re-check this file system.
-.IP NO
-terminate the program.
-.sp
-.LP
-.B "DUP TABLE OVERFLOW (CONTINUE)"
-.br
-An internal table in
-.I fsck
-containing duplicate block numbers cannot allocate any more space.
-Increase the amount of virtual memory available to
-.I fsck .
-.LP
-Possible responses to the CONTINUE prompt are:
-.IP YES
-continue with the program.
-This error condition will not allow a complete check of the file system.
-A second run of
-.I fsck
-should be made to re-check this file system.
-If another duplicate block is found, this error condition will repeat.
-.IP NO
-terminate the program.
-.sp
-.LP
-.B "PARTIALLY ALLOCATED INODE I=\fII\fP (CLEAR)"
-.br
-Inode \fII\fP is neither allocated nor unallocated.
-.LP
-Possible responses to the CLEAR prompt are:
-.IP YES
-de-allocate inode \fII\fP by zeroing its contents.
-.IP NO
-ignore this error condition.
-.sp
-.LP
-.B "INCORRECT BLOCK COUNT I=\fII\fP (\fIX\fP should be \fIY\fP) (CORRECT)"
-.br
-The block count for inode \fII\fP is \fIX\fP blocks,
-but should be \fIY\fP blocks.
-When preen'ing the count is corrected.
-.LP
-Possible responses to the CORRECT prompt are:
-.IP YES
-replace the block count of inode \fII\fP with \fIY\fP.
-.IP NO
-ignore this error condition.
-.NH 2
-Phase 1B: Rescan for More Dups
-.PP
-When a duplicate block is found in the file system, the file system is
-rescanned to find the inode that previously claimed that block.
-This section lists the error condition when the duplicate block is found.
-.sp
-.LP
-.B "\fIB\fP DUP I=\fII\fP"
-.br
-Inode \fII\fP contains block number \fIB\fP that
-is already claimed by another inode.
-This error condition will always invoke the
-.B "BAD/DUP"
-error condition in Phase 2.
-You can determine which inodes have overlapping blocks by examining
-this error condition and the DUP error condition in Phase 1.
-.NH 2
-Phase 2 \- Check Pathnames
-.PP
-This phase concerns itself with removing directory entries
-pointing to
-error conditioned inodes
-from Phase 1 and Phase 1b.
-This section lists error conditions resulting from
-root inode mode and status,
-directory inode pointers in range,
-and directory entries pointing to bad inodes,
-and directory integrity checks.
-All errors in this phase are fatal if the file system is being preen'ed,
-except for directories not being a multiple of the blocks size
-and extraneous hard links.
-.sp
-.LP
-.B "ROOT INODE UNALLOCATED (ALLOCATE)"
-.br
-The root inode (usually inode number 2) has no allocate mode bits.
-This should never happen.
-.LP
-Possible responses to the ALLOCATE prompt are:
-.IP YES
-allocate inode 2 as the root inode.
-The files and directories usually found in the root will be recovered
-in Phase 3 and put into
-.I lost+found .
-If the attempt to allocate the root fails,
-.I fsck
-will exit with the message:
-.br
-.B "CANNOT ALLOCATE ROOT INODE" .
-.IP NO
-.I fsck
-will exit.
-.sp
-.LP
-.B "ROOT INODE NOT DIRECTORY (REALLOCATE)"
-.br
-The root inode (usually inode number 2)
-is not directory inode type.
-.LP
-Possible responses to the REALLOCATE prompt are:
-.IP YES
-clear the existing contents of the root inode
-and reallocate it.
-The files and directories usually found in the root will be recovered
-in Phase 3 and put into
-.I lost+found .
-If the attempt to allocate the root fails,
-.I fsck
-will exit with the message:
-.br
-.B "CANNOT ALLOCATE ROOT INODE" .
-.IP NO
-.I fsck
-will then prompt with
-.B "FIX"
-.LP
-Possible responses to the FIX prompt are:
-.IP YES
-replace the root inode's type to be a directory.
-If the root inode's data blocks are not directory blocks,
-many error conditions will be produced.
-.IP NO
-terminate the program.
-.sp
-.LP
-.B "DUPS/BAD IN ROOT INODE (REALLOCATE)"
-.br
-Phase 1 or Phase 1b have found duplicate blocks
-or bad blocks in the root inode (usually inode number 2) for the file system.
-.LP
-Possible responses to the REALLOCATE prompt are:
-.IP YES
-clear the existing contents of the root inode
-and reallocate it.
-The files and directories usually found in the root will be recovered
-in Phase 3 and put into
-.I lost+found .
-If the attempt to allocate the root fails,
-.I fsck
-will exit with the message:
-.br
-.B "CANNOT ALLOCATE ROOT INODE" .
-.IP NO
-.I fsck
-will then prompt with
-.B "CONTINUE" .
-.LP
-Possible responses to the CONTINUE prompt are:
-.IP YES
-ignore the
-.B "DUPS/BAD"
-error condition in the root inode and
-attempt to continue to run the file system check.
-If the root inode is not correct,
-then this may result in many other error conditions.
-.IP NO
-terminate the program.
-.sp
-.LP
-.B "NAME TOO LONG \fIF\fP"
-.br
-An excessively long path name has been found.
-This usually indicates loops in the file system name space.
-This can occur if the super user has made circular links to directories.
-The offending links must be removed (by a guru).
-.sp
-.LP
-.B "I OUT OF RANGE I=\fII\fP NAME=\fIF\fP (REMOVE)"
-.br
-A directory entry \fIF\fP has an inode number \fII\fP that is greater than
-the end of the inode list.
-.LP
-Possible responses to the REMOVE prompt are:
-.IP YES
-the directory entry \fIF\fP is removed.
-.IP NO
-ignore this error condition.
-.sp
-.LP
-.B "UNALLOCATED I=\fII\fP OWNER=\fIO\fP MODE=\fIM\fP SIZE=\fIS\fP MTIME=\fIT\fP \fItype\fP=\fIF\fP (REMOVE)"
-.br
-A directory or file entry \fIF\fP points to an unallocated inode \fII\fP.
-The owner \fIO\fP, mode \fIM\fP, size \fIS\fP, modify time \fIT\fP,
-and name \fIF\fP are printed.
-.LP
-Possible responses to the REMOVE prompt are:
-.IP YES
-the directory entry \fIF\fP is removed.
-.IP NO
-ignore this error condition.
-.sp
-.LP
-.B "DUP/BAD I=\fII\fP OWNER=\fIO\fP MODE=\fIM\fP SIZE=\fIS\fP MTIME=\fIT\fP \fItype\fP=\fIF\fP (REMOVE)"
-.br
-Phase 1 or Phase 1b have found duplicate blocks or bad blocks
-associated with directory or file entry \fIF\fP, inode \fII\fP.
-The owner \fIO\fP, mode \fIM\fP, size \fIS\fP, modify time \fIT\fP,
-and directory name \fIF\fP are printed.
-.LP
-Possible responses to the REMOVE prompt are:
-.IP YES
-the directory entry \fIF\fP is removed.
-.IP NO
-ignore this error condition.
-.sp
-.LP
-.B "ZERO LENGTH DIRECTORY I=\fII\fP OWNER=\fIO\fP MODE=\fIM\fP SIZE=\fIS\fP MTIME=\fIT\fP DIR=\fIF\fP (REMOVE)"
-.br
-A directory entry \fIF\fP has a size \fIS\fP that is zero.
-The owner \fIO\fP, mode \fIM\fP, size \fIS\fP, modify time \fIT\fP,
-and directory name \fIF\fP are printed.
-.LP
-Possible responses to the REMOVE prompt are:
-.IP YES
-the directory entry \fIF\fP is removed;
-this will always invoke the BAD/DUP error condition in Phase 4.
-.IP NO
-ignore this error condition.
-.sp
-.LP
-.B "DIRECTORY TOO SHORT I=\fII\fP OWNER=\fIO\fP MODE=\fIM\fP SIZE=\fIS\fP MTIME=\fIT\fP DIR=\fIF\fP (FIX)"
-.br
-A directory \fIF\fP has been found whose size \fIS\fP
-is less than the minimum size directory.
-The owner \fIO\fP, mode \fIM\fP, size \fIS\fP, modify time \fIT\fP,
-and directory name \fIF\fP are printed.
-.LP
-Possible responses to the FIX prompt are:
-.IP YES
-increase the size of the directory to the minimum directory size.
-.IP NO
-ignore this directory.
-.sp
-.LP
-.B "DIRECTORY \fIF\fP LENGTH \fIS\fP NOT MULTIPLE OF \fIB\fP (ADJUST)
-.br
-A directory \fIF\fP has been found with size \fIS\fP that is not
-a multiple of the directory blocksize \fIB\fP.
-.LP
-Possible responses to the ADJUST prompt are:
-.IP YES
-the length is rounded up to the appropriate block size.
-This error can occur on 4.2BSD file systems.
-Thus when preen'ing the file system only a warning is printed
-and the directory is adjusted.
-.IP NO
-ignore the error condition.
-.sp
-.LP
-.B "DIRECTORY CORRUPTED I=\fII\fP OWNER=\fIO\fP MODE=\fIM\fP SIZE=\fIS\fP MTIME=\fIT\fP DIR=\fIF\fP (SALVAGE)"
-.br
-A directory with an inconsistent internal state has been found.
-.LP
-Possible responses to the FIX prompt are:
-.IP YES
-throw away all entries up to the next directory boundary (usually 512-byte)
-boundary.
-This drastic action can throw away up to 42 entries,
-and should be taken only after other recovery efforts have failed.
-.IP NO
-skip up to the next directory boundary and resume reading,
-but do not modify the directory.
-.sp
-.LP
-.B "BAD INODE NUMBER FOR `.' I=\fII\fP OWNER=\fIO\fP MODE=\fIM\fP SIZE=\fIS\fP MTIME=\fIT\fP DIR=\fIF\fP (FIX)"
-.br
-A directory \fII\fP has been found whose inode number for `.' does
-does not equal \fII\fP.
-.LP
-Possible responses to the FIX prompt are:
-.IP YES
-change the inode number for `.' to be equal to \fII\fP.
-.IP NO
-leave the inode number for `.' unchanged.
-.sp
-.LP
-.B "MISSING `.' I=\fII\fP OWNER=\fIO\fP MODE=\fIM\fP SIZE=\fIS\fP MTIME=\fIT\fP DIR=\fIF\fP (FIX)"
-.br
-A directory \fII\fP has been found whose first entry is unallocated.
-.LP
-Possible responses to the FIX prompt are:
-.IP YES
-build an entry for `.' with inode number equal to \fII\fP.
-.IP NO
-leave the directory unchanged.
-.sp
-.LP
-.B "MISSING `.' I=\fII\fP OWNER=\fIO\fP MODE=\fIM\fP SIZE=\fIS\fP MTIME=\fIT\fP DIR=\fIF\fP"
-.br
-.B "CANNOT FIX, FIRST ENTRY IN DIRECTORY CONTAINS \fIF\fP"
-.br
-A directory \fII\fP has been found whose first entry is \fIF\fP.
-.I Fsck
-cannot resolve this problem.
-The file system should be mounted and the offending entry \fIF\fP
-moved elsewhere.
-The file system should then be unmounted and
-.I fsck
-should be run again.
-.sp
-.LP
-.B "MISSING `.' I=\fII\fP OWNER=\fIO\fP MODE=\fIM\fP SIZE=\fIS\fP MTIME=\fIT\fP DIR=\fIF\fP"
-.br
-.B "CANNOT FIX, INSUFFICIENT SPACE TO ADD `.'"
-.br
-A directory \fII\fP has been found whose first entry is not `.'.
-.I Fsck
-cannot resolve this problem as it should never happen.
-See a guru.
-.sp
-.LP
-.B "EXTRA `.' ENTRY I=\fII\fP OWNER=\fIO\fP MODE=\fIM\fP SIZE=\fIS\fP MTIME=\fIT\fP DIR=\fIF\fP (FIX)"
-.br
-A directory \fII\fP has been found that has more than one entry for `.'.
-.LP
-Possible responses to the FIX prompt are:
-.IP YES
-remove the extra entry for `.'.
-.IP NO
-leave the directory unchanged.
-.sp
-.LP
-.B "BAD INODE NUMBER FOR `..' I=\fII\fP OWNER=\fIO\fP MODE=\fIM\fP SIZE=\fIS\fP MTIME=\fIT\fP DIR=\fIF\fP (FIX)"
-.br
-A directory \fII\fP has been found whose inode number for `..' does
-does not equal the parent of \fII\fP.
-.LP
-Possible responses to the FIX prompt are:
-.IP YES
-change the inode number for `..' to be equal to the parent of \fII\fP
-(``\fB..\fP'' in the root inode points to itself).
-.IP NO
-leave the inode number for `..' unchanged.
-.sp
-.LP
-.B "MISSING `..' I=\fII\fP OWNER=\fIO\fP MODE=\fIM\fP SIZE=\fIS\fP MTIME=\fIT\fP DIR=\fIF\fP (FIX)"
-.br
-A directory \fII\fP has been found whose second entry is unallocated.
-.LP
-Possible responses to the FIX prompt are:
-.IP YES
-build an entry for `..' with inode number equal to the parent of \fII\fP
-(``\fB..\fP'' in the root inode points to itself).
-.IP NO
-leave the directory unchanged.
-.sp
-.LP
-.B "MISSING `..' I=\fII\fP OWNER=\fIO\fP MODE=\fIM\fP SIZE=\fIS\fP MTIME=\fIT\fP DIR=\fIF\fP"
-.br
-.B "CANNOT FIX, SECOND ENTRY IN DIRECTORY CONTAINS \fIF\fP"
-.br
-A directory \fII\fP has been found whose second entry is \fIF\fP.
-.I Fsck
-cannot resolve this problem.
-The file system should be mounted and the offending entry \fIF\fP
-moved elsewhere.
-The file system should then be unmounted and
-.I fsck
-should be run again.
-.sp
-.LP
-.B "MISSING `..' I=\fII\fP OWNER=\fIO\fP MODE=\fIM\fP SIZE=\fIS\fP MTIME=\fIT\fP DIR=\fIF\fP"
-.br
-.B "CANNOT FIX, INSUFFICIENT SPACE TO ADD `..'"
-.br
-A directory \fII\fP has been found whose second entry is not `..'.
-.I Fsck
-cannot resolve this problem.
-The file system should be mounted and the second entry in the directory
-moved elsewhere.
-The file system should then be unmounted and
-.I fsck
-should be run again.
-.sp
-.LP
-.B "EXTRA `..' ENTRY I=\fII\fP OWNER=\fIO\fP MODE=\fIM\fP SIZE=\fIS\fP MTIME=\fIT\fP DIR=\fIF\fP (FIX)"
-.br
-A directory \fII\fP has been found that has more than one entry for `..'.
-.LP
-Possible responses to the FIX prompt are:
-.IP YES
-remove the extra entry for `..'.
-.IP NO
-leave the directory unchanged.
-.sp
-.LP
-.B "\fIN\fP IS AN EXTRANEOUS HARD LINK TO A DIRECTORY \fID\fP (REMOVE)
-.br
-.I Fsck
-has found a hard link, \fIN\fP, to a directory, \fID\fP.
-When preen'ing the extraneous links are ignored.
-.LP
-Possible responses to the REMOVE prompt are:
-.IP YES
-delete the extraneous entry, \fIN\fP.
-.IP NO
-ignore the error condition.
-.sp
-.LP
-.B "BAD INODE \fIS\fP TO DESCEND"
-.br
-An internal error has caused an impossible state \fIS\fP to be passed to the
-routine that descends the file system directory structure.
-.I Fsck
-exits.
-See a guru.
-.sp
-.LP
-.B "BAD RETURN STATE \fIS\fP FROM DESCEND"
-.br
-An internal error has caused an impossible state \fIS\fP to be returned
-from the routine that descends the file system directory structure.
-.I Fsck
-exits.
-See a guru.
-.sp
-.LP
-.B "BAD STATE \fIS\fP FOR ROOT INODE"
-.br
-An internal error has caused an impossible state \fIS\fP to be assigned
-to the root inode.
-.I Fsck
-exits.
-See a guru.
-.NH 2
-Phase 3 \- Check Connectivity
-.PP
-This phase concerns itself with the directory connectivity seen in
-Phase 2.
-This section lists error conditions resulting from
-unreferenced directories,
-and missing or full
-.I lost+found
-directories.
-.sp
-.LP
-.B "UNREF DIR I=\fII\fP OWNER=\fIO\fP MODE=\fIM\fP SIZE=\fIS\fP MTIME=\fIT\fP (RECONNECT)"
-.br
-The directory inode \fII\fP was not connected to a directory entry
-when the file system was traversed.
-The owner \fIO\fP, mode \fIM\fP, size \fIS\fP, and
-modify time \fIT\fP of directory inode \fII\fP are printed.
-When preen'ing, the directory is reconnected if its size is non-zero,
-otherwise it is cleared.
-.LP
-Possible responses to the RECONNECT prompt are:
-.IP YES
-reconnect directory inode \fII\fP to the file system in the
-directory for lost files (usually \fIlost+found\fP).
-This may invoke the
-.I lost+found
-error condition in Phase 3
-if there are problems connecting directory inode \fII\fP to \fIlost+found\fP.
-This may also invoke the CONNECTED error condition in Phase 3 if the link
-was successful.
-.IP NO
-ignore this error condition.
-This will always invoke the UNREF error condition in Phase 4.
-.sp
-.LP
-.B "NO lost+found DIRECTORY (CREATE)"
-.br
-There is no
-.I lost+found
-directory in the root directory of the file system;
-When preen'ing
-.I fsck
-tries to create a \fIlost+found\fP directory.
-.LP
-Possible responses to the CREATE prompt are:
-.IP YES
-create a \fIlost+found\fP directory in the root of the file system.
-This may raise the message:
-.br
-.B "NO SPACE LEFT IN / (EXPAND)"
-.br
-See below for the possible responses.
-Inability to create a \fIlost+found\fP directory generates the message:
-.br
-.B "SORRY. CANNOT CREATE lost+found DIRECTORY"
-.br
-and aborts the attempt to linkup the lost inode.
-This will always invoke the UNREF error condition in Phase 4.
-.IP NO
-abort the attempt to linkup the lost inode.
-This will always invoke the UNREF error condition in Phase 4.
-.sp
-.LP
-.B "lost+found IS NOT A DIRECTORY (REALLOCATE)"
-.br
-The entry for
-.I lost+found
-is not a directory.
-.LP
-Possible responses to the REALLOCATE prompt are:
-.IP YES
-allocate a directory inode, and change \fIlost+found\fP to reference it.
-The previous inode reference by the \fIlost+found\fP name is not cleared.
-Thus it will either be reclaimed as an UNREF'ed inode or have its
-link count ADJUST'ed later in this Phase.
-Inability to create a \fIlost+found\fP directory generates the message:
-.br
-.B "SORRY. CANNOT CREATE lost+found DIRECTORY"
-.br
-and aborts the attempt to linkup the lost inode.
-This will always invoke the UNREF error condition in Phase 4.
-.IP NO
-abort the attempt to linkup the lost inode.
-This will always invoke the UNREF error condition in Phase 4.
-.sp
-.LP
-.B "NO SPACE LEFT IN /lost+found (EXPAND)"
-.br
-There is no space to add another entry to the
-.I lost+found
-directory in the root directory
-of the file system.
-When preen'ing the
-.I lost+found
-directory is expanded.
-.LP
-Possible responses to the EXPAND prompt are:
-.IP YES
-the
-.I lost+found
-directory is expanded to make room for the new entry.
-If the attempted expansion fails
-.I fsck
-prints the message:
-.br
-.B "SORRY. NO SPACE IN lost+found DIRECTORY"
-.br
-and aborts the attempt to linkup the lost inode.
-This will always invoke the UNREF error condition in Phase 4.
-Clean out unnecessary entries in
-.I lost+found .
-This error is fatal if the file system is being preen'ed.
-.IP NO
-abort the attempt to linkup the lost inode.
-This will always invoke the UNREF error condition in Phase 4.
-.sp
-.LP
-.B "DIR I=\fII1\fP CONNECTED. PARENT WAS I=\fII2\fP"
-.br
-This is an advisory message indicating a directory inode \fII1\fP was
-successfully connected to the
-.I lost+found
-directory.
-The parent inode \fII2\fP of the directory inode \fII1\fP is
-replaced by the inode number of the
-.I lost+found
-directory.
-.sp
-.LP
-.B "DIRECTORY \fIF\fP LENGTH \fIS\fP NOT MULTIPLE OF \fIB\fP (ADJUST)
-.br
-A directory \fIF\fP has been found with size \fIS\fP that is not
-a multiple of the directory blocksize \fIB\fP
-(this can reoccur in Phase 3 if it is not adjusted in Phase 2).
-.LP
-Possible responses to the ADJUST prompt are:
-.IP YES
-the length is rounded up to the appropriate block size.
-This error can occur on 4.2BSD file systems.
-Thus when preen'ing the file system only a warning is printed
-and the directory is adjusted.
-.IP NO
-ignore the error condition.
-.sp
-.LP
-.B "BAD INODE \fIS\fP TO DESCEND"
-.br
-An internal error has caused an impossible state \fIS\fP to be passed to the
-routine that descends the file system directory structure.
-.I Fsck
-exits.
-See a guru.
-.NH 2
-Phase 4 \- Check Reference Counts
-.PP
-This phase concerns itself with the link count information
-seen in Phase 2 and Phase 3.
-This section lists error conditions resulting from
-unreferenced files,
-missing or full
-.I lost+found
-directory,
-incorrect link counts for files, directories, symbolic links, or special files,
-unreferenced files, symbolic links, and directories,
-and bad or duplicate blocks in files, symbolic links, and directories.
-All errors in this phase are correctable if the file system is being preen'ed
-except running out of space in the \fIlost+found\fP directory.
-.sp
-.LP
-.B "UNREF FILE I=\fII\fP OWNER=\fIO\fP MODE=\fIM\fP SIZE=\fIS\fP MTIME=\fIT\fP (RECONNECT)"
-.br
-Inode \fII\fP was not connected to a directory entry
-when the file system was traversed.
-The owner \fIO\fP, mode \fIM\fP, size \fIS\fP, and
-modify time \fIT\fP of inode \fII\fP are printed.
-When preen'ing the file is cleared if either its size or its
-link count is zero,
-otherwise it is reconnected.
-.LP
-Possible responses to the RECONNECT prompt are:
-.IP YES
-reconnect inode \fII\fP to the file system in the directory for
-lost files (usually \fIlost+found\fP).
-This may invoke the
-.I lost+found
-error condition in Phase 4
-if there are problems connecting inode \fII\fP to
-.I lost+found .
-.IP NO
-ignore this error condition.
-This will always invoke the CLEAR error condition in Phase 4.
-.sp
-.LP
-.B "(CLEAR)"
-.br
-The inode mentioned in the immediately previous error condition can not be
-reconnected.
-This cannot occur if the file system is being preen'ed,
-since lack of space to reconnect files is a fatal error.
-.LP
-Possible responses to the CLEAR prompt are:
-.IP YES
-de-allocate the inode mentioned in the immediately previous error condition by zeroing its contents.
-.IP NO
-ignore this error condition.
-.sp
-.LP
-.B "NO lost+found DIRECTORY (CREATE)"
-.br
-There is no
-.I lost+found
-directory in the root directory of the file system;
-When preen'ing
-.I fsck
-tries to create a \fIlost+found\fP directory.
-.LP
-Possible responses to the CREATE prompt are:
-.IP YES
-create a \fIlost+found\fP directory in the root of the file system.
-This may raise the message:
-.br
-.B "NO SPACE LEFT IN / (EXPAND)"
-.br
-See below for the possible responses.
-Inability to create a \fIlost+found\fP directory generates the message:
-.br
-.B "SORRY. CANNOT CREATE lost+found DIRECTORY"
-.br
-and aborts the attempt to linkup the lost inode.
-This will always invoke the UNREF error condition in Phase 4.
-.IP NO
-abort the attempt to linkup the lost inode.
-This will always invoke the UNREF error condition in Phase 4.
-.sp
-.LP
-.B "lost+found IS NOT A DIRECTORY (REALLOCATE)"
-.br
-The entry for
-.I lost+found
-is not a directory.
-.LP
-Possible responses to the REALLOCATE prompt are:
-.IP YES
-allocate a directory inode, and change \fIlost+found\fP to reference it.
-The previous inode reference by the \fIlost+found\fP name is not cleared.
-Thus it will either be reclaimed as an UNREF'ed inode or have its
-link count ADJUST'ed later in this Phase.
-Inability to create a \fIlost+found\fP directory generates the message:
-.br
-.B "SORRY. CANNOT CREATE lost+found DIRECTORY"
-.br
-and aborts the attempt to linkup the lost inode.
-This will always invoke the UNREF error condition in Phase 4.
-.IP NO
-abort the attempt to linkup the lost inode.
-This will always invoke the UNREF error condition in Phase 4.
-.sp
-.LP
-.B "NO SPACE LEFT IN /lost+found (EXPAND)"
-.br
-There is no space to add another entry to the
-.I lost+found
-directory in the root directory
-of the file system.
-When preen'ing the
-.I lost+found
-directory is expanded.
-.LP
-Possible responses to the EXPAND prompt are:
-.IP YES
-the
-.I lost+found
-directory is expanded to make room for the new entry.
-If the attempted expansion fails
-.I fsck
-prints the message:
-.br
-.B "SORRY. NO SPACE IN lost+found DIRECTORY"
-.br
-and aborts the attempt to linkup the lost inode.
-This will always invoke the UNREF error condition in Phase 4.
-Clean out unnecessary entries in
-.I lost+found .
-This error is fatal if the file system is being preen'ed.
-.IP NO
-abort the attempt to linkup the lost inode.
-This will always invoke the UNREF error condition in Phase 4.
-.sp
-.LP
-.B "LINK COUNT \fItype\fP I=\fII\fP OWNER=\fIO\fP MODE=\fIM\fP SIZE=\fIS\fP MTIME=\fIT\fP COUNT=\fIX\fP SHOULD BE \fIY\fP (ADJUST)"
-.br
-The link count for inode \fII\fP,
-is \fIX\fP but should be \fIY\fP.
-The owner \fIO\fP, mode \fIM\fP, size \fIS\fP, and modify time \fIT\fP
-are printed.
-When preen'ing the link count is adjusted unless the number of references
-is increasing, a condition that should never occur unless precipitated
-by a hardware failure.
-When the number of references is increasing under preen mode,
-.I fsck
-exits with the message:
-.br
-.B "LINK COUNT INCREASING"
-.LP
-Possible responses to the ADJUST prompt are:
-.IP YES
-replace the link count of file inode \fII\fP with \fIY\fP.
-.IP NO
-ignore this error condition.
-.sp
-.LP
-.B "UNREF \fItype\fP I=\fII\fP OWNER=\fIO\fP MODE=\fIM\fP SIZE=\fIS\fP MTIME=\fIT\fP (CLEAR)"
-.br
-Inode \fII\fP, was not connected to a directory entry when the
-file system was traversed.
-The owner \fIO\fP, mode \fIM\fP, size \fIS\fP,
-and modify time \fIT\fP of inode \fII\fP
-are printed.
-When preen'ing,
-this is a file that was not connected because its size or link count was zero,
-hence it is cleared.
-.LP
-Possible responses to the CLEAR prompt are:
-.IP YES
-de-allocate inode \fII\fP by zeroing its contents.
-.IP NO
-ignore this error condition.
-.sp
-.LP
-.B "BAD/DUP \fItype\fP I=\fII\fP OWNER=\fIO\fP MODE=\fIM\fP SIZE=\fIS\fP MTIME=\fIT\fP (CLEAR)"
-.br
-Phase 1 or Phase 1b have found duplicate blocks
-or bad blocks associated with
-inode \fII\fP.
-The owner \fIO\fP, mode \fIM\fP, size \fIS\fP,
-and modify time \fIT\fP of inode \fII\fP
-are printed.
-This error cannot arise when the file system is being preen'ed,
-as it would have caused a fatal error earlier.
-.LP
-Possible responses to the CLEAR prompt are:
-.IP YES
-de-allocate inode \fII\fP by zeroing its contents.
-.IP NO
-ignore this error condition.
-.NH 2
-Phase 5 - Check Cyl groups
-.PP
-This phase concerns itself with the free-block and used-inode maps.
-This section lists error conditions resulting from
-allocated blocks in the free-block maps,
-free blocks missing from free-block maps,
-and the total free-block count incorrect.
-It also lists error conditions resulting from
-free inodes in the used-inode maps,
-allocated inodes missing from used-inode maps,
-and the total used-inode count incorrect.
-.sp
-.LP
-.B "CG \fIC\fP: BAD MAGIC NUMBER"
-.br
-The magic number of cylinder group \fIC\fP is wrong.
-This usually indicates that the cylinder group maps have been destroyed.
-When running manually the cylinder group is marked as needing
-to be reconstructed.
-This error is fatal if the file system is being preen'ed.
-.sp
-.LP
-.B "BLK(S) MISSING IN BIT MAPS (SALVAGE)"
-.br
-A cylinder group block map is missing some free blocks.
-During preen'ing the maps are reconstructed.
-.LP
-Possible responses to the SALVAGE prompt are:
-.IP YES
-reconstruct the free block map.
-.IP NO
-ignore this error condition.
-.sp
-.LP
-.B "SUMMARY INFORMATION BAD (SALVAGE)"
-.br
-The summary information was found to be incorrect.
-When preen'ing,
-the summary information is recomputed.
-.LP
-Possible responses to the SALVAGE prompt are:
-.IP YES
-reconstruct the summary information.
-.IP NO
-ignore this error condition.
-.sp
-.LP
-.B "FREE BLK COUNT(S) WRONG IN SUPERBLOCK (SALVAGE)"
-.br
-The superblock free block information was found to be incorrect.
-When preen'ing,
-the superblock free block information is recomputed.
-.LP
-Possible responses to the SALVAGE prompt are:
-.IP YES
-reconstruct the superblock free block information.
-.IP NO
-ignore this error condition.
-.NH 2
-Cleanup
-.PP
-Once a file system has been checked, a few cleanup functions are performed.
-This section lists advisory messages about
-the file system
-and modify status of the file system.
-.sp
-.LP
-.B "\fIV\fP files, \fIW\fP used, \fIX\fP free (\fIY\fP frags, \fIZ\fP blocks)"
-.br
-This is an advisory message indicating that
-the file system checked contained
-\fIV\fP files using
-\fIW\fP fragment sized blocks leaving
-\fIX\fP fragment sized blocks free in the file system.
-The numbers in parenthesis breaks the free count down into
-\fIY\fP free fragments and
-\fIZ\fP free full sized blocks.
-.sp
-.LP
-.B "***** REBOOT UNIX *****"
-.br
-This is an advisory message indicating that
-the root file system has been modified by
-.I fsck.
-If UNIX is not rebooted immediately,
-the work done by
-.I fsck
-may be undone by the in-core copies of tables
-UNIX keeps.
-When preen'ing,
-.I fsck
-will exit with a code of 4.
-The standard auto-reboot script distributed with 4.3BSD
-interprets an exit code of 4 by issuing a reboot system call.
-.sp
-.LP
-.B "***** FILE SYSTEM WAS MODIFIED *****"
-.br
-This is an advisory message indicating that
-the current file system was modified by
-.I fsck.
-If this file system is mounted or is the current root file system,
-.I fsck
-should be halted and UNIX rebooted.
-If UNIX is not rebooted immediately,
-the work done by
-.I fsck
-may be undone by the in-core copies of tables
-UNIX keeps.
diff --git a/sbin/fsck_ffs/SMM.doc/Makefile b/sbin/fsck_ffs/SMM.doc/Makefile
deleted file mode 100644
index 26823bcc94f2..000000000000
--- a/sbin/fsck_ffs/SMM.doc/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-# @(#)Makefile 8.1 (Berkeley) 6/8/93
-
-DIR= smm/03.fsck
-SRCS= 0.t 1.t 2.t 3.t 4.t
-MACROS= -ms
-
-.include <bsd.doc.mk>
diff --git a/sbin/fsck_ffs/dir.c b/sbin/fsck_ffs/dir.c
deleted file mode 100644
index f5fb6a0ef30a..000000000000
--- a/sbin/fsck_ffs/dir.c
+++ /dev/null
@@ -1,769 +0,0 @@
-/*
- * Copyright (c) 1980, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-#if 0
-static const char sccsid[] = "@(#)dir.c 8.8 (Berkeley) 4/28/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <sys/param.h>
-#include <sys/time.h>
-
-#include <ufs/ufs/dinode.h>
-#include <ufs/ufs/dir.h>
-#include <ufs/ffs/fs.h>
-
-#include <err.h>
-#include <string.h>
-
-#include "fsck.h"
-
-char *lfname = "lost+found";
-int lfmode = 01777;
-struct dirtemplate emptydir = { 0, DIRBLKSIZ };
-struct dirtemplate dirhead = {
- 0, 12, DT_DIR, 1, ".",
- 0, DIRBLKSIZ - 12, DT_DIR, 2, ".."
-};
-struct odirtemplate odirhead = {
- 0, 12, 1, ".",
- 0, DIRBLKSIZ - 12, 2, ".."
-};
-
-static int chgino __P((struct inodesc *));
-static int dircheck __P((struct inodesc *, struct direct *));
-static int expanddir __P((struct dinode *dp, char *name));
-static void freedir __P((ino_t ino, ino_t parent));
-static struct direct *fsck_readdir __P((struct inodesc *));
-static struct bufarea *getdirblk __P((ufs_daddr_t blkno, long size));
-static int lftempname __P((char *bufp, ino_t ino));
-static int mkentry __P((struct inodesc *));
-
-/*
- * Propagate connected state through the tree.
- */
-void
-propagate()
-{
- register struct inoinfo **inpp, *inp;
- struct inoinfo **inpend;
- long change;
-
- inpend = &inpsort[inplast];
- do {
- change = 0;
- for (inpp = inpsort; inpp < inpend; inpp++) {
- inp = *inpp;
- if (inp->i_parent == 0)
- continue;
- if (inoinfo(inp->i_parent)->ino_state == DFOUND &&
- inoinfo(inp->i_number)->ino_state == DSTATE) {
- inoinfo(inp->i_number)->ino_state = DFOUND;
- change++;
- }
- }
- } while (change > 0);
-}
-
-/*
- * Scan each entry in a directory block.
- */
-int
-dirscan(idesc)
- register struct inodesc *idesc;
-{
- register struct direct *dp;
- register struct bufarea *bp;
- int dsize, n;
- long blksiz;
- char dbuf[DIRBLKSIZ];
-
- if (idesc->id_type != DATA)
- errx(EEXIT, "wrong type to dirscan %d", idesc->id_type);
- if (idesc->id_entryno == 0 &&
- (idesc->id_filesize & (DIRBLKSIZ - 1)) != 0)
- idesc->id_filesize = roundup(idesc->id_filesize, DIRBLKSIZ);
- blksiz = idesc->id_numfrags * sblock.fs_fsize;
- if (chkrange(idesc->id_blkno, idesc->id_numfrags)) {
- idesc->id_filesize -= blksiz;
- return (SKIP);
- }
- idesc->id_loc = 0;
- for (dp = fsck_readdir(idesc); dp != NULL; dp = fsck_readdir(idesc)) {
- dsize = dp->d_reclen;
- if (dsize > sizeof(dbuf))
- dsize = sizeof(dbuf);
- memmove(dbuf, dp, (size_t)dsize);
-# if (BYTE_ORDER == LITTLE_ENDIAN)
- if (!newinofmt) {
- struct direct *tdp = (struct direct *)dbuf;
- u_char tmp;
-
- tmp = tdp->d_namlen;
- tdp->d_namlen = tdp->d_type;
- tdp->d_type = tmp;
- }
-# endif
- idesc->id_dirp = (struct direct *)dbuf;
- if ((n = (*idesc->id_func)(idesc)) & ALTERED) {
-# if (BYTE_ORDER == LITTLE_ENDIAN)
- if (!newinofmt && !doinglevel2) {
- struct direct *tdp;
- u_char tmp;
-
- tdp = (struct direct *)dbuf;
- tmp = tdp->d_namlen;
- tdp->d_namlen = tdp->d_type;
- tdp->d_type = tmp;
- }
-# endif
- bp = getdirblk(idesc->id_blkno, blksiz);
- memmove(bp->b_un.b_buf + idesc->id_loc - dsize, dbuf,
- (size_t)dsize);
- dirty(bp);
- sbdirty();
- }
- if (n & STOP)
- return (n);
- }
- return (idesc->id_filesize > 0 ? KEEPON : STOP);
-}
-
-/*
- * get next entry in a directory.
- */
-static struct direct *
-fsck_readdir(idesc)
- register struct inodesc *idesc;
-{
- register struct direct *dp, *ndp;
- register struct bufarea *bp;
- long size, blksiz, fix, dploc;
-
- blksiz = idesc->id_numfrags * sblock.fs_fsize;
- bp = getdirblk(idesc->id_blkno, blksiz);
- if (idesc->id_loc % DIRBLKSIZ == 0 && idesc->id_filesize > 0 &&
- idesc->id_loc < blksiz) {
- dp = (struct direct *)(bp->b_un.b_buf + idesc->id_loc);
- if (dircheck(idesc, dp))
- goto dpok;
- if (idesc->id_fix == IGNORE)
- return (0);
- fix = dofix(idesc, "DIRECTORY CORRUPTED");
- bp = getdirblk(idesc->id_blkno, blksiz);
- dp = (struct direct *)(bp->b_un.b_buf + idesc->id_loc);
- dp->d_reclen = DIRBLKSIZ;
- dp->d_ino = 0;
- dp->d_type = 0;
- dp->d_namlen = 0;
- dp->d_name[0] = '\0';
- if (fix)
- dirty(bp);
- idesc->id_loc += DIRBLKSIZ;
- idesc->id_filesize -= DIRBLKSIZ;
- return (dp);
- }
-dpok:
- if (idesc->id_filesize <= 0 || idesc->id_loc >= blksiz)
- return NULL;
- dploc = idesc->id_loc;
- dp = (struct direct *)(bp->b_un.b_buf + dploc);
- idesc->id_loc += dp->d_reclen;
- idesc->id_filesize -= dp->d_reclen;
- if ((idesc->id_loc % DIRBLKSIZ) == 0)
- return (dp);
- ndp = (struct direct *)(bp->b_un.b_buf + idesc->id_loc);
- if (idesc->id_loc < blksiz && idesc->id_filesize > 0 &&
- dircheck(idesc, ndp) == 0) {
- size = DIRBLKSIZ - (idesc->id_loc % DIRBLKSIZ);
- idesc->id_loc += size;
- idesc->id_filesize -= size;
- if (idesc->id_fix == IGNORE)
- return (0);
- fix = dofix(idesc, "DIRECTORY CORRUPTED");
- bp = getdirblk(idesc->id_blkno, blksiz);
- dp = (struct direct *)(bp->b_un.b_buf + dploc);
- dp->d_reclen += size;
- if (fix)
- dirty(bp);
- }
- return (dp);
-}
-
-/*
- * Verify that a directory entry is valid.
- * This is a superset of the checks made in the kernel.
- */
-static int
-dircheck(idesc, dp)
- struct inodesc *idesc;
- register struct direct *dp;
-{
- register int size;
- register char *cp;
- u_char namlen, type;
- int spaceleft;
-
- spaceleft = DIRBLKSIZ - (idesc->id_loc % DIRBLKSIZ);
- if (dp->d_reclen == 0 ||
- dp->d_reclen > spaceleft ||
- (dp->d_reclen & 0x3) != 0)
- return (0);
- if (dp->d_ino == 0)
- return (1);
- size = DIRSIZ(!newinofmt, dp);
-# if (BYTE_ORDER == LITTLE_ENDIAN)
- if (!newinofmt) {
- type = dp->d_namlen;
- namlen = dp->d_type;
- } else {
- namlen = dp->d_namlen;
- type = dp->d_type;
- }
-# else
- namlen = dp->d_namlen;
- type = dp->d_type;
-# endif
- if (dp->d_reclen < size ||
- idesc->id_filesize < size ||
- namlen > MAXNAMLEN ||
- type > 15)
- return (0);
- for (cp = dp->d_name, size = 0; size < namlen; size++)
- if (*cp == '\0' || (*cp++ == '/'))
- return (0);
- if (*cp != '\0')
- return (0);
- return (1);
-}
-
-void
-direrror(ino, errmesg)
- ino_t ino;
- char *errmesg;
-{
-
- fileerror(ino, ino, errmesg);
-}
-
-void
-fileerror(cwd, ino, errmesg)
- ino_t cwd, ino;
- char *errmesg;
-{
- register struct dinode *dp;
- char pathbuf[MAXPATHLEN + 1];
-
- pwarn("%s ", errmesg);
- pinode(ino);
- printf("\n");
- getpathname(pathbuf, cwd, ino);
- if (ino < ROOTINO || ino > maxino) {
- pfatal("NAME=%s\n", pathbuf);
- return;
- }
- dp = ginode(ino);
- if (ftypeok(dp))
- pfatal("%s=%s\n",
- (dp->di_mode & IFMT) == IFDIR ? "DIR" : "FILE", pathbuf);
- else
- pfatal("NAME=%s\n", pathbuf);
-}
-
-void
-adjust(idesc, lcnt)
- register struct inodesc *idesc;
- int lcnt;
-{
- struct dinode *dp;
- int saveresolved;
-
- dp = ginode(idesc->id_number);
- if (dp->di_nlink == lcnt) {
- /*
- * If we have not hit any unresolved problems, are running
- * in preen mode, and are on a filesystem using soft updates,
- * then just toss any partially allocated files.
- */
- if (resolved && preen && usedsoftdep) {
- clri(idesc, "UNREF", 1);
- return;
- } else {
- /*
- * The filesystem can be marked clean even if
- * a file is not linked up, but is cleared.
- * Hence, resolved should not be cleared when
- * linkup is answered no, but clri is answered yes.
- */
- saveresolved = resolved;
- if (linkup(idesc->id_number, (ino_t)0, NULL) == 0) {
- resolved = saveresolved;
- clri(idesc, "UNREF", 0);
- return;
- }
- /*
- * Account for the new reference created by linkup().
- */
- dp = ginode(idesc->id_number);
- lcnt--;
- }
- }
- if (lcnt != 0) {
- pwarn("LINK COUNT %s", (lfdir == idesc->id_number) ? lfname :
- ((dp->di_mode & IFMT) == IFDIR ? "DIR" : "FILE"));
- pinode(idesc->id_number);
- printf(" COUNT %d SHOULD BE %d",
- dp->di_nlink, dp->di_nlink - lcnt);
- if (preen || usedsoftdep) {
- if (lcnt < 0) {
- printf("\n");
- pfatal("LINK COUNT INCREASING");
- }
- if (preen)
- printf(" (ADJUSTED)\n");
- }
- if (preen || reply("ADJUST") == 1) {
- dp->di_nlink -= lcnt;
- inodirty();
- }
- }
-}
-
-static int
-mkentry(idesc)
- struct inodesc *idesc;
-{
- register struct direct *dirp = idesc->id_dirp;
- struct direct newent;
- int newlen, oldlen;
-
- newent.d_namlen = strlen(idesc->id_name);
- newlen = DIRSIZ(0, &newent);
- if (dirp->d_ino != 0)
- oldlen = DIRSIZ(0, dirp);
- else
- oldlen = 0;
- if (dirp->d_reclen - oldlen < newlen)
- return (KEEPON);
- newent.d_reclen = dirp->d_reclen - oldlen;
- dirp->d_reclen = oldlen;
- dirp = (struct direct *)(((char *)dirp) + oldlen);
- dirp->d_ino = idesc->id_parent; /* ino to be entered is in id_parent */
- dirp->d_reclen = newent.d_reclen;
- if (newinofmt)
- dirp->d_type = inoinfo(idesc->id_parent)->ino_type;
- else
- dirp->d_type = 0;
- dirp->d_namlen = newent.d_namlen;
- memmove(dirp->d_name, idesc->id_name, (size_t)newent.d_namlen + 1);
-# if (BYTE_ORDER == LITTLE_ENDIAN)
- /*
- * If the entry was split, dirscan() will only reverse the byte
- * order of the original entry, and not the new one, before
- * writing it back out. So, we reverse the byte order here if
- * necessary.
- */
- if (oldlen != 0 && !newinofmt && !doinglevel2) {
- u_char tmp;
-
- tmp = dirp->d_namlen;
- dirp->d_namlen = dirp->d_type;
- dirp->d_type = tmp;
- }
-# endif
- return (ALTERED|STOP);
-}
-
-static int
-chgino(idesc)
- struct inodesc *idesc;
-{
- register struct direct *dirp = idesc->id_dirp;
-
- if (memcmp(dirp->d_name, idesc->id_name, (int)dirp->d_namlen + 1))
- return (KEEPON);
- dirp->d_ino = idesc->id_parent;
- if (newinofmt)
- dirp->d_type = inoinfo(idesc->id_parent)->ino_type;
- else
- dirp->d_type = 0;
- return (ALTERED|STOP);
-}
-
-int
-linkup(orphan, parentdir, name)
- ino_t orphan;
- ino_t parentdir;
- char *name;
-{
- register struct dinode *dp;
- int lostdir;
- ino_t oldlfdir;
- struct inodesc idesc;
- char tempname[BUFSIZ];
-
- memset(&idesc, 0, sizeof(struct inodesc));
- dp = ginode(orphan);
- lostdir = (dp->di_mode & IFMT) == IFDIR;
- pwarn("UNREF %s ", lostdir ? "DIR" : "FILE");
- pinode(orphan);
- if (preen && dp->di_size == 0)
- return (0);
- if (preen)
- printf(" (RECONNECTED)\n");
- else
- if (reply("RECONNECT") == 0)
- return (0);
- if (lfdir == 0) {
- dp = ginode(ROOTINO);
- idesc.id_name = lfname;
- idesc.id_type = DATA;
- idesc.id_func = findino;
- idesc.id_number = ROOTINO;
- if ((ckinode(dp, &idesc) & FOUND) != 0) {
- lfdir = idesc.id_parent;
- } else {
- pwarn("NO lost+found DIRECTORY");
- if (preen || reply("CREATE")) {
- lfdir = allocdir(ROOTINO, (ino_t)0, lfmode);
- if (lfdir != 0) {
- if (makeentry(ROOTINO, lfdir, lfname) != 0) {
- numdirs++;
- if (preen)
- printf(" (CREATED)\n");
- } else {
- freedir(lfdir, ROOTINO);
- lfdir = 0;
- if (preen)
- printf("\n");
- }
- }
- }
- }
- if (lfdir == 0) {
- pfatal("SORRY. CANNOT CREATE lost+found DIRECTORY");
- printf("\n\n");
- return (0);
- }
- }
- dp = ginode(lfdir);
- if ((dp->di_mode & IFMT) != IFDIR) {
- pfatal("lost+found IS NOT A DIRECTORY");
- if (reply("REALLOCATE") == 0)
- return (0);
- oldlfdir = lfdir;
- if ((lfdir = allocdir(ROOTINO, (ino_t)0, lfmode)) == 0) {
- pfatal("SORRY. CANNOT CREATE lost+found DIRECTORY\n\n");
- return (0);
- }
- if ((changeino(ROOTINO, lfname, lfdir) & ALTERED) == 0) {
- pfatal("SORRY. CANNOT CREATE lost+found DIRECTORY\n\n");
- return (0);
- }
- inodirty();
- idesc.id_type = ADDR;
- idesc.id_func = pass4check;
- idesc.id_number = oldlfdir;
- adjust(&idesc, inoinfo(oldlfdir)->ino_linkcnt + 1);
- inoinfo(oldlfdir)->ino_linkcnt = 0;
- dp = ginode(lfdir);
- }
- if (inoinfo(lfdir)->ino_state != DFOUND) {
- pfatal("SORRY. NO lost+found DIRECTORY\n\n");
- return (0);
- }
- (void)lftempname(tempname, orphan);
- if (makeentry(lfdir, orphan, (name ? name : tempname)) == 0) {
- pfatal("SORRY. NO SPACE IN lost+found DIRECTORY");
- printf("\n\n");
- return (0);
- }
- inoinfo(orphan)->ino_linkcnt--;
- if (lostdir) {
- if ((changeino(orphan, "..", lfdir) & ALTERED) == 0 &&
- parentdir != (ino_t)-1)
- (void)makeentry(orphan, lfdir, "..");
- dp = ginode(lfdir);
- dp->di_nlink++;
- inodirty();
- inoinfo(lfdir)->ino_linkcnt++;
- pwarn("DIR I=%lu CONNECTED. ", orphan);
- if (parentdir != (ino_t)-1) {
- printf("PARENT WAS I=%lu\n", (u_long)parentdir);
- /*
- * The parent directory, because of the ordering
- * guarantees, has had the link count incremented
- * for the child, but no entry was made. This
- * fixes the parent link count so that fsck does
- * not need to be rerun.
- */
- inoinfo(parentdir)->ino_linkcnt++;
- }
- if (preen == 0)
- printf("\n");
- }
- return (1);
-}
-
-/*
- * fix an entry in a directory.
- */
-int
-changeino(dir, name, newnum)
- ino_t dir;
- char *name;
- ino_t newnum;
-{
- struct inodesc idesc;
-
- memset(&idesc, 0, sizeof(struct inodesc));
- idesc.id_type = DATA;
- idesc.id_func = chgino;
- idesc.id_number = dir;
- idesc.id_fix = DONTKNOW;
- idesc.id_name = name;
- idesc.id_parent = newnum; /* new value for name */
- return (ckinode(ginode(dir), &idesc));
-}
-
-/*
- * make an entry in a directory
- */
-int
-makeentry(parent, ino, name)
- ino_t parent, ino;
- char *name;
-{
- struct dinode *dp;
- struct inodesc idesc;
- char pathbuf[MAXPATHLEN + 1];
-
- if (parent < ROOTINO || parent >= maxino ||
- ino < ROOTINO || ino >= maxino)
- return (0);
- memset(&idesc, 0, sizeof(struct inodesc));
- idesc.id_type = DATA;
- idesc.id_func = mkentry;
- idesc.id_number = parent;
- idesc.id_parent = ino; /* this is the inode to enter */
- idesc.id_fix = DONTKNOW;
- idesc.id_name = name;
- dp = ginode(parent);
- if (dp->di_size % DIRBLKSIZ) {
- dp->di_size = roundup(dp->di_size, DIRBLKSIZ);
- inodirty();
- }
- if ((ckinode(dp, &idesc) & ALTERED) != 0)
- return (1);
- getpathname(pathbuf, parent, parent);
- dp = ginode(parent);
- if (expanddir(dp, pathbuf) == 0)
- return (0);
- return (ckinode(dp, &idesc) & ALTERED);
-}
-
-/*
- * Attempt to expand the size of a directory
- */
-static int
-expanddir(dp, name)
- register struct dinode *dp;
- char *name;
-{
- ufs_daddr_t lastbn, newblk;
- register struct bufarea *bp;
- char *cp, firstblk[DIRBLKSIZ];
-
- lastbn = lblkno(&sblock, dp->di_size);
- if (lastbn >= NDADDR - 1 || dp->di_db[lastbn] == 0 || dp->di_size == 0)
- return (0);
- if ((newblk = allocblk(sblock.fs_frag)) == 0)
- return (0);
- dp->di_db[lastbn + 1] = dp->di_db[lastbn];
- dp->di_db[lastbn] = newblk;
- dp->di_size += sblock.fs_bsize;
- dp->di_blocks += btodb(sblock.fs_bsize);
- bp = getdirblk(dp->di_db[lastbn + 1],
- (long)dblksize(&sblock, dp, lastbn + 1));
- if (bp->b_errs)
- goto bad;
- memmove(firstblk, bp->b_un.b_buf, DIRBLKSIZ);
- bp = getdirblk(newblk, sblock.fs_bsize);
- if (bp->b_errs)
- goto bad;
- memmove(bp->b_un.b_buf, firstblk, DIRBLKSIZ);
- for (cp = &bp->b_un.b_buf[DIRBLKSIZ];
- cp < &bp->b_un.b_buf[sblock.fs_bsize];
- cp += DIRBLKSIZ)
- memmove(cp, &emptydir, sizeof emptydir);
- dirty(bp);
- bp = getdirblk(dp->di_db[lastbn + 1],
- (long)dblksize(&sblock, dp, lastbn + 1));
- if (bp->b_errs)
- goto bad;
- memmove(bp->b_un.b_buf, &emptydir, sizeof emptydir);
- pwarn("NO SPACE LEFT IN %s", name);
- if (preen)
- printf(" (EXPANDED)\n");
- else if (reply("EXPAND") == 0)
- goto bad;
- dirty(bp);
- inodirty();
- return (1);
-bad:
- dp->di_db[lastbn] = dp->di_db[lastbn + 1];
- dp->di_db[lastbn + 1] = 0;
- dp->di_size -= sblock.fs_bsize;
- dp->di_blocks -= btodb(sblock.fs_bsize);
- freeblk(newblk, sblock.fs_frag);
- return (0);
-}
-
-/*
- * allocate a new directory
- */
-ino_t
-allocdir(parent, request, mode)
- ino_t parent, request;
- int mode;
-{
- ino_t ino;
- char *cp;
- struct dinode *dp;
- register struct bufarea *bp;
- struct dirtemplate *dirp;
-
- ino = allocino(request, IFDIR|mode);
- if (newinofmt)
- dirp = &dirhead;
- else
- dirp = (struct dirtemplate *)&odirhead;
- dirp->dot_ino = ino;
- dirp->dotdot_ino = parent;
- dp = ginode(ino);
- bp = getdirblk(dp->di_db[0], sblock.fs_fsize);
- if (bp->b_errs) {
- freeino(ino);
- return (0);
- }
- memmove(bp->b_un.b_buf, dirp, sizeof(struct dirtemplate));
- for (cp = &bp->b_un.b_buf[DIRBLKSIZ];
- cp < &bp->b_un.b_buf[sblock.fs_fsize];
- cp += DIRBLKSIZ)
- memmove(cp, &emptydir, sizeof emptydir);
- dirty(bp);
- dp->di_nlink = 2;
- inodirty();
- if (ino == ROOTINO) {
- inoinfo(ino)->ino_linkcnt = dp->di_nlink;
- cacheino(dp, ino);
- return(ino);
- }
- if (inoinfo(parent)->ino_state != DSTATE &&
- inoinfo(parent)->ino_state != DFOUND) {
- freeino(ino);
- return (0);
- }
- cacheino(dp, ino);
- inoinfo(ino)->ino_state = inoinfo(parent)->ino_state;
- if (inoinfo(ino)->ino_state == DSTATE) {
- inoinfo(ino)->ino_linkcnt = dp->di_nlink;
- inoinfo(parent)->ino_linkcnt++;
- }
- dp = ginode(parent);
- dp->di_nlink++;
- inodirty();
- return (ino);
-}
-
-/*
- * free a directory inode
- */
-static void
-freedir(ino, parent)
- ino_t ino, parent;
-{
- struct dinode *dp;
-
- if (ino != parent) {
- dp = ginode(parent);
- dp->di_nlink--;
- inodirty();
- }
- freeino(ino);
-}
-
-/*
- * generate a temporary name for the lost+found directory.
- */
-static int
-lftempname(bufp, ino)
- char *bufp;
- ino_t ino;
-{
- register ino_t in;
- register char *cp;
- int namlen;
-
- cp = bufp + 2;
- for (in = maxino; in > 0; in /= 10)
- cp++;
- *--cp = 0;
- namlen = cp - bufp;
- in = ino;
- while (cp > bufp) {
- *--cp = (in % 10) + '0';
- in /= 10;
- }
- *cp = '#';
- return (namlen);
-}
-
-/*
- * Get a directory block.
- * Insure that it is held until another is requested.
- */
-static struct bufarea *
-getdirblk(blkno, size)
- ufs_daddr_t blkno;
- long size;
-{
-
- if (pdirbp != 0)
- pdirbp->b_flags &= ~B_INUSE;
- pdirbp = getdatablk(blkno, size);
- return (pdirbp);
-}
diff --git a/sbin/fsck_ffs/fsck.h b/sbin/fsck_ffs/fsck.h
deleted file mode 100644
index 9d59c8ff2526..000000000000
--- a/sbin/fsck_ffs/fsck.h
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- * Copyright (c) 1980, 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)fsck.h 8.4 (Berkeley) 5/9/95
- * $FreeBSD$
- */
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-#define MAXDUP 10 /* limit on dup blks (per inode) */
-#define MAXBAD 10 /* limit on bad blks (per inode) */
-#define MAXBUFSPACE 40*1024 /* maximum space to allocate to buffers */
-#define INOBUFSIZE 56*1024 /* size of buffer to read inodes in pass1 */
-
-/*
- * Each inode on the filesystem is described by the following structure.
- * The linkcnt is initially set to the value in the inode. Each time it
- * is found during the descent in passes 2, 3, and 4 the count is
- * decremented. Any inodes whose count is non-zero after pass 4 needs to
- * have its link count adjusted by the value remaining in ino_linkcnt.
- */
-struct inostat {
- char ino_state; /* state of inode, see below */
- char ino_type; /* type of inode */
- short ino_linkcnt; /* number of links not found */
-};
-/*
- * Inode states.
- */
-#define USTATE 01 /* inode not allocated */
-#define FSTATE 02 /* inode is file */
-#define DSTATE 03 /* inode is directory */
-#define DFOUND 04 /* directory found during descent */
-#define DCLEAR 05 /* directory is to be cleared */
-#define FCLEAR 06 /* file is to be cleared */
-/*
- * Inode state information is contained on per cylinder group lists
- * which are described by the following structure.
- */
-struct inostatlist {
- long il_numalloced; /* number of inodes allocated in this cg */
- struct inostat *il_stat;/* inostat info for this cylinder group */
-} *inostathead;
-
-/*
- * buffer cache structure.
- */
-struct bufarea {
- struct bufarea *b_next; /* free list queue */
- struct bufarea *b_prev; /* free list queue */
- ufs_daddr_t b_bno;
- int b_size;
- int b_errs;
- int b_flags;
- union {
- char *b_buf; /* buffer space */
- ufs_daddr_t *b_indir; /* indirect block */
- struct fs *b_fs; /* super block */
- struct cg *b_cg; /* cylinder group */
- struct dinode *b_dinode; /* inode block */
- } b_un;
- char b_dirty;
-};
-
-#define B_INUSE 1
-
-#define MINBUFS 5 /* minimum number of buffers required */
-struct bufarea bufhead; /* head of list of other blks in filesys */
-struct bufarea sblk; /* file system superblock */
-struct bufarea cgblk; /* cylinder group blocks */
-struct bufarea *pdirbp; /* current directory contents */
-struct bufarea *pbp; /* current inode block */
-
-#define dirty(bp) (bp)->b_dirty = 1
-#define initbarea(bp) \
- (bp)->b_dirty = 0; \
- (bp)->b_bno = (ufs_daddr_t)-1; \
- (bp)->b_flags = 0;
-
-#define sbdirty() sblk.b_dirty = 1
-#define cgdirty() cgblk.b_dirty = 1
-#define sblock (*sblk.b_un.b_fs)
-#define cgrp (*cgblk.b_un.b_cg)
-
-enum fixstate {DONTKNOW, NOFIX, FIX, IGNORE};
-
-struct inodesc {
- enum fixstate id_fix; /* policy on fixing errors */
- int (*id_func)(); /* function to be applied to blocks of inode */
- ino_t id_number; /* inode number described */
- ino_t id_parent; /* for DATA nodes, their parent */
- ufs_daddr_t id_blkno; /* current block number being examined */
- int id_numfrags; /* number of frags contained in block */
- quad_t id_filesize; /* for DATA nodes, the size of the directory */
- int id_loc; /* for DATA nodes, current location in dir */
- int id_entryno; /* for DATA nodes, current entry number */
- struct direct *id_dirp; /* for DATA nodes, ptr to current entry */
- char *id_name; /* for DATA nodes, name to find or enter */
- char id_type; /* type of descriptor, DATA or ADDR */
-};
-/* file types */
-#define DATA 1
-#define ADDR 2
-
-/*
- * Linked list of duplicate blocks.
- *
- * The list is composed of two parts. The first part of the
- * list (from duplist through the node pointed to by muldup)
- * contains a single copy of each duplicate block that has been
- * found. The second part of the list (from muldup to the end)
- * contains duplicate blocks that have been found more than once.
- * To check if a block has been found as a duplicate it is only
- * necessary to search from duplist through muldup. To find the
- * total number of times that a block has been found as a duplicate
- * the entire list must be searched for occurences of the block
- * in question. The following diagram shows a sample list where
- * w (found twice), x (found once), y (found three times), and z
- * (found once) are duplicate block numbers:
- *
- * w -> y -> x -> z -> y -> w -> y
- * ^ ^
- * | |
- * duplist muldup
- */
-struct dups {
- struct dups *next;
- ufs_daddr_t dup;
-};
-struct dups *duplist; /* head of dup list */
-struct dups *muldup; /* end of unique duplicate dup block numbers */
-
-/*
- * Linked list of inodes with zero link counts.
- */
-struct zlncnt {
- struct zlncnt *next;
- ino_t zlncnt;
-};
-struct zlncnt *zlnhead; /* head of zero link count list */
-
-/*
- * Inode cache data structures.
- */
-struct inoinfo {
- struct inoinfo *i_nexthash; /* next entry in hash chain */
- ino_t i_number; /* inode number of this entry */
- ino_t i_parent; /* inode number of parent */
- ino_t i_dotdot; /* inode number of `..' */
- size_t i_isize; /* size of inode */
- u_int i_numblks; /* size of block array in bytes */
- ufs_daddr_t i_blks[1]; /* actually longer */
-} **inphead, **inpsort;
-long numdirs, dirhash, listmax, inplast;
-long countdirs; /* number of directories we actually found */
-
-char *cdevname; /* name of device being checked */
-long dev_bsize; /* computed value of DEV_BSIZE */
-long secsize; /* actual disk sector size */
-char fflag; /* force check, ignore clean flag */
-char nflag; /* assume a no response */
-char yflag; /* assume a yes response */
-int bflag; /* location of alternate super block */
-int debug; /* output debugging info */
-int cvtlevel; /* convert to newer file system format */
-int doinglevel1; /* converting to new cylinder group format */
-int doinglevel2; /* converting to new inode format */
-int newinofmt; /* filesystem has new inode format */
-char usedsoftdep; /* just fix soft dependency inconsistencies */
-char preen; /* just fix normal inconsistencies */
-char rerun; /* rerun fsck. Only used in non-preen mode */
-int returntosingle; /* 1 => return to single user mode on exit */
-char resolved; /* cleared if unresolved changes => not clean */
-char havesb; /* superblock has been read */
-int fsmodified; /* 1 => write done to file system */
-int fsreadfd; /* file descriptor for reading file system */
-int fswritefd; /* file descriptor for writing file system */
-
-ufs_daddr_t maxfsblock; /* number of blocks in the file system */
-char *blockmap; /* ptr to primary blk allocation map */
-ino_t maxino; /* number of inodes in file system */
-
-ino_t lfdir; /* lost & found directory inode number */
-char *lfname; /* lost & found directory name */
-int lfmode; /* lost & found directory creation mode */
-
-ufs_daddr_t n_blks; /* number of blocks in use */
-ufs_daddr_t n_files; /* number of files in use */
-
-#define clearinode(dp) (*(dp) = zino)
-struct dinode zino;
-
-#define setbmap(blkno) setbit(blockmap, blkno)
-#define testbmap(blkno) isset(blockmap, blkno)
-#define clrbmap(blkno) clrbit(blockmap, blkno)
-
-#define STOP 0x01
-#define SKIP 0x02
-#define KEEPON 0x04
-#define ALTERED 0x08
-#define FOUND 0x10
-
-#define EEXIT 8 /* Standard error exit. */
-
-struct fstab;
-
-
-void adjust __P((struct inodesc *, int lcnt));
-ufs_daddr_t allocblk __P((long frags));
-ino_t allocdir __P((ino_t parent, ino_t request, int mode));
-ino_t allocino __P((ino_t request, int type));
-void blkerror __P((ino_t ino, char *type, ufs_daddr_t blk));
-char *blockcheck __P((char *name));
-int bread __P((int fd, char *buf, ufs_daddr_t blk, long size));
-void bufinit __P((void));
-void bwrite __P((int fd, char *buf, ufs_daddr_t blk, long size));
-void cacheino __P((struct dinode *dp, ino_t inumber));
-void catch __P((int));
-void catchquit __P((int));
-int changeino __P((ino_t dir, char *name, ino_t newnum));
-int checkfstab __P((int preen, int maxrun,
- int (*docheck)(struct fstab *),
- int (*chkit)(char *, char *, long, int)));
-int chkrange __P((ufs_daddr_t blk, int cnt));
-void ckfini __P((int markclean));
-int ckinode __P((struct dinode *dp, struct inodesc *));
-void clri __P((struct inodesc *, char *type, int flag));
-int clearentry __P((struct inodesc *));
-void direrror __P((ino_t ino, char *errmesg));
-int dirscan __P((struct inodesc *));
-int dofix __P((struct inodesc *, char *msg));
-void ffs_clrblock __P((struct fs *, u_char *, ufs_daddr_t));
-void ffs_fragacct __P((struct fs *, int, int32_t [], int));
-int ffs_isblock __P((struct fs *, u_char *, ufs_daddr_t));
-void ffs_setblock __P((struct fs *, u_char *, ufs_daddr_t));
-void fileerror __P((ino_t cwd, ino_t ino, char *errmesg));
-int findino __P((struct inodesc *));
-int findname __P((struct inodesc *));
-void flush __P((int fd, struct bufarea *bp));
-void freeblk __P((ufs_daddr_t blkno, long frags));
-void freeino __P((ino_t ino));
-void freeinodebuf __P((void));
-int ftypeok __P((struct dinode *dp));
-void getblk __P((struct bufarea *bp, ufs_daddr_t blk, long size));
-struct bufarea *getdatablk __P((ufs_daddr_t blkno, long size));
-struct inoinfo *getinoinfo __P((ino_t inumber));
-struct dinode *getnextinode __P((ino_t inumber));
-void getpathname __P((char *namebuf, ino_t curdir, ino_t ino));
-struct dinode *ginode __P((ino_t inumber));
-void inocleanup __P((void));
-void inodirty __P((void));
-struct inostat *inoinfo __P((ino_t inum));
-int linkup __P((ino_t orphan, ino_t parentdir, char *name));
-int makeentry __P((ino_t parent, ino_t ino, char *name));
-void panic __P((const char *fmt, ...));
-void pass1 __P((void));
-void pass1b __P((void));
-int pass1check __P((struct inodesc *));
-void pass2 __P((void));
-void pass3 __P((void));
-void pass4 __P((void));
-int pass4check __P((struct inodesc *));
-void pass5 __P((void));
-void pfatal __P((const char *fmt, ...));
-void pinode __P((ino_t ino));
-void propagate __P((void));
-void pwarn __P((const char *fmt, ...));
-int reply __P((char *question));
-void setinodebuf __P((ino_t));
-int setup __P((char *dev));
-void voidquit __P((int));
diff --git a/sbin/fsck_ffs/fsck_ffs.8 b/sbin/fsck_ffs/fsck_ffs.8
deleted file mode 100644
index 59d7fa8d1a47..000000000000
--- a/sbin/fsck_ffs/fsck_ffs.8
+++ /dev/null
@@ -1,321 +0,0 @@
-.\"
-.\" Copyright (c) 1980, 1989, 1991, 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. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgment:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. 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.
-.\"
-.\" @(#)fsck.8 8.4 (Berkeley) 5/9/95
-.\" $FreeBSD$
-.\"
-.Dd November 15, 1996
-.Dt FSCK 8
-.Os BSD 4
-.Sh NAME
-.Nm fsck
-.Nd filesystem consistency check and interactive repair
-.Sh SYNOPSIS
-.Nm fsck
-.Fl p
-.Op Fl f
-.Op Fl m Ar mode
-.Op Ar filesystem
-.Ar ...
-.Nm fsck
-.Op Fl ny
-.Op Fl b Ar block#
-.Op Fl c Ar level
-.Op Fl l Ar maxparallel
-.Op Fl m Ar mode
-.Op Ar filesystem
-.Ar ...
-.Sh DESCRIPTION
-The first form of
-.Nm
-preens a standard set of filesystems or the specified filesystems.
-It is normally used in the script
-.Pa /etc/rc
-during automatic reboot.
-Here
-.Nm
-reads the table
-.Pa /etc/fstab
-to determine which filesystems to check.
-Only partitions in fstab that are mounted ``rw,'' ``rq'' or ``ro''
-and that have non-zero pass number are checked.
-Filesystems with pass number 1 (normally just the root filesystem)
-are checked one at a time.
-When pass 1 completes, all remaining filesystems are checked,
-running one process per disk drive.
-The disk drive containing each filesystem is inferred from the longest prefix
-of the device name that ends in a digit; the remaining characters are assumed
-to be the partition designator.
-.Pp
-In "preen" mode the clean flag of each filesystem's superblock is examined
-and only those filesystems that
-are not marked clean are checked.
-Filesystems are marked clean when they are unmounted,
-when they have been mounted read-only, or when
-.Nm
-runs on them successfully.
-If the
-.Fl f
-option is specified, the filesystems
-will be checked regardless of the state of their clean flag.
-.Pp
-The kernel takes care that only a restricted class of innocuous filesystem
-inconsistencies can happen unless hardware or software failures intervene.
-These are limited to the following:
-.Pp
-.Bl -item -compact -offset indent
-.It
-Unreferenced inodes
-.It
-Link counts in inodes too large
-.It
-Missing blocks in the free map
-.It
-Blocks in the free map also in files
-.It
-Counts in the super-block wrong
-.El
-.Pp
-These are the only inconsistencies that
-.Nm
-with the
-.Fl p
-option will correct; if it encounters other inconsistencies, it exits
-with an abnormal return status and an automatic reboot will then fail.
-For each corrected inconsistency one or more lines will be printed
-identifying the filesystem on which the correction will take place,
-and the nature of the correction. After successfully correcting a filesystem,
-.Nm
-will print the number of files on that filesystem,
-the number of used and free blocks,
-and the percentage of fragmentation.
-.Pp
-If sent a
-.Dv QUIT
-signal,
-.Nm
-will finish the filesystem checks, then exit with an abnormal
-return status that causes an automatic reboot to fail.
-This is useful when you want to finish the filesystem checks during an
-automatic reboot,
-but do not want the machine to come up multiuser after the checks complete.
-.Pp
-Without the
-.Fl p
-option,
-.Nm
-audits and interactively repairs inconsistent conditions for filesystems.
-If the filesystem is inconsistent the operator is prompted for concurrence
-before each correction is attempted.
-It should be noted that some of the corrective actions which are not
-correctable under the
-.Fl p
-option will result in some loss of data.
-The amount and severity of data lost may be determined from the diagnostic
-output.
-The default action for each consistency correction
-is to wait for the operator to respond
-.Li yes
-or
-.Li no .
-If the operator does not have write permission on the filesystem
-.Nm
-will default to a
-.Fl n
-action.
-.Pp
-.Nm Fsck
-has more consistency checks than
-its predecessors
-.Em check , dcheck , fcheck ,
-and
-.Em icheck
-combined.
-.Pp
-The following flags are interpreted by
-.Nm Ns .
-.Bl -tag -width indent
-.It Fl b
-Use the block specified immediately after the flag as
-the super block for the filesystem. Block 32 is usually
-an alternate super block.
-.It Fl c
-Convert the filesystem to the specified level.
-Note that the level of a filesystem can only be raised.
-.Bl -tag -width indent
-There are currently four levels defined:
-.It 0
-The filesystem is in the old (static table) format.
-.It 1
-The filesystem is in the new (dynamic table) format.
-.It 2
-The filesystem supports 32-bit uid's and gid's,
-short symbolic links are stored in the inode,
-and directories have an added field showing the file type.
-.It 3
-If maxcontig is greater than one,
-build the free segment maps to aid in finding contiguous sets of blocks.
-If maxcontig is equal to one, delete any existing segment maps.
-.El
-.Pp
-In interactive mode,
-.Nm
-will list the conversion to be made
-and ask whether the conversion should be done.
-If a negative answer is given,
-no further operations are done on the filesystem.
-In preen mode,
-the conversion is listed and done if
-possible without user interaction.
-Conversion in preen mode is best used when all the filesystems
-are being converted at once.
-The format of a filesystem can be determined from the
-first line of output from
-.Xr dumpfs 8 .
-.It Fl f
-Force
-.Nm fsck
-to check
-.Sq clean
-filesystems when preening.
-.It Fl l
-Limit the number of parallel checks to the number specified in the following
-argument.
-By default, the limit is the number of disks, running one process per disk.
-If a smaller limit is given, the disks are checked round-robin, one filesystem
-at a time.
-.It Fl m
-Use the mode specified in octal immediately after the flag as the
-permission bits to use when creating the
-.Pa lost+found
-directory rather than the default 1777.
-In particular, systems that do not wish to have lost files accessible
-by all users on the system should use a more restrictive
-set of permissions such as 700.
-.It Fl n
-Assume a no response to all questions asked by
-.Nm
-except for
-.Ql CONTINUE? ,
-which is assumed to be affirmative;
-do not open the filesystem for writing.
-.It Fl p
-Preen filesystems (see above).
-.It Fl y
-Assume a yes response to all questions asked by
-.Nm Ns ;
-this should be used with great caution as this is a free license
-to continue after essentially unlimited trouble has been encountered.
-.El
-.Pp
-If no filesystems are given to
-.Nm
-then a default list of filesystems is read from
-the file
-.Pa /etc/fstab .
-.Pp
-.Bl -enum -indent indent -compact
-Inconsistencies checked are as follows:
-.It
-Blocks claimed by more than one inode or the free map.
-.It
-Blocks claimed by an inode outside the range of the filesystem.
-.It
-Incorrect link counts.
-.It
-Size checks:
-.Bl -item -indent indent -compact
-.It
-Directory size not a multiple of DIRBLKSIZ.
-.It
-Partially truncated file.
-.El
-.It
-Bad inode format.
-.It
-Blocks not accounted for anywhere.
-.It
-Directory checks:
-.Bl -item -indent indent -compact
-.It
-File pointing to unallocated inode.
-.It
-Inode number out of range.
-.It
-Directories with unallocated blocks (holes).
-.It
-Dot or dot-dot not the first two entries of a directory
-or having the wrong inode number.
-.El
-.It
-Super Block checks:
-.Bl -item -indent indent -compact
-.It
-More blocks for inodes than there are in the filesystem.
-.It
-Bad free block map format.
-.It
-Total free block and/or free inode count incorrect.
-.El
-.El
-.Pp
-Orphaned files and directories (allocated but unreferenced) are,
-with the operator's concurrence, reconnected by
-placing them in the
-.Pa lost+found
-directory.
-The name assigned is the inode number.
-If the
-.Pa lost+found
-directory does not exist, it is created.
-If there is insufficient space its size is increased.
-.Pp
-Because of inconsistencies between the block device and the buffer cache,
-the raw device should always be used.
-.Sh FILES
-.Bl -tag -width /etc/fstab -compact
-.It Pa /etc/fstab
-contains default list of filesystems to check.
-.El
-.Sh DIAGNOSTICS
-The diagnostics produced by
-.Nm
-are fully enumerated and explained in Appendix A of
-.Rs
-.%T "Fsck \- The UNIX File System Check Program"
-.Re
-.Sh SEE ALSO
-.Xr fs 5 ,
-.Xr fstab 5 ,
-.Xr fsdb 8 ,
-.Xr newfs 8 ,
-.Xr reboot 8
diff --git a/sbin/fsck_ffs/inode.c b/sbin/fsck_ffs/inode.c
deleted file mode 100644
index dbf86f760f81..000000000000
--- a/sbin/fsck_ffs/inode.c
+++ /dev/null
@@ -1,666 +0,0 @@
-/*
- * Copyright (c) 1980, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-#if 0
-static const char sccsid[] = "@(#)inode.c 8.8 (Berkeley) 4/28/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <sys/param.h>
-#include <sys/time.h>
-
-#include <ufs/ufs/dinode.h>
-#include <ufs/ufs/dir.h>
-#include <ufs/ffs/fs.h>
-
-#include <err.h>
-#include <pwd.h>
-#include <string.h>
-
-#include "fsck.h"
-
-static ino_t startinum;
-
-static int iblock __P((struct inodesc *, long ilevel, quad_t isize));
-
-int
-ckinode(dp, idesc)
- struct dinode *dp;
- register struct inodesc *idesc;
-{
- ufs_daddr_t *ap;
- int ret;
- long n, ndb, offset;
- struct dinode dino;
- quad_t remsize, sizepb;
- mode_t mode;
- char pathbuf[MAXPATHLEN + 1];
-
- if (idesc->id_fix != IGNORE)
- idesc->id_fix = DONTKNOW;
- idesc->id_entryno = 0;
- idesc->id_filesize = dp->di_size;
- mode = dp->di_mode & IFMT;
- if (mode == IFBLK || mode == IFCHR || (mode == IFLNK &&
- dp->di_size < (unsigned)sblock.fs_maxsymlinklen))
- return (KEEPON);
- dino = *dp;
- ndb = howmany(dino.di_size, sblock.fs_bsize);
- for (ap = &dino.di_db[0]; ap < &dino.di_db[NDADDR]; ap++) {
- if (--ndb == 0 && (offset = blkoff(&sblock, dino.di_size)) != 0)
- idesc->id_numfrags =
- numfrags(&sblock, fragroundup(&sblock, offset));
- else
- idesc->id_numfrags = sblock.fs_frag;
- if (*ap == 0) {
- if (idesc->id_type == DATA && ndb >= 0) {
- /* An empty block in a directory XXX */
- getpathname(pathbuf, idesc->id_number,
- idesc->id_number);
- pfatal("DIRECTORY %s: CONTAINS EMPTY BLOCKS",
- pathbuf);
- if (reply("ADJUST LENGTH") == 1) {
- dp = ginode(idesc->id_number);
- dp->di_size = (ap - &dino.di_db[0]) *
- sblock.fs_bsize;
- printf(
- "YOU MUST RERUN FSCK AFTERWARDS\n");
- rerun = 1;
- inodirty();
-
- }
- }
- continue;
- }
- idesc->id_blkno = *ap;
- if (idesc->id_type == ADDR)
- ret = (*idesc->id_func)(idesc);
- else
- ret = dirscan(idesc);
- if (ret & STOP)
- return (ret);
- }
- idesc->id_numfrags = sblock.fs_frag;
- remsize = dino.di_size - sblock.fs_bsize * NDADDR;
- sizepb = sblock.fs_bsize;
- for (ap = &dino.di_ib[0], n = 1; n <= NIADDR; ap++, n++) {
- if (*ap) {
- idesc->id_blkno = *ap;
- ret = iblock(idesc, n, remsize);
- if (ret & STOP)
- return (ret);
- } else {
- if (idesc->id_type == DATA && remsize > 0) {
- /* An empty block in a directory XXX */
- getpathname(pathbuf, idesc->id_number,
- idesc->id_number);
- pfatal("DIRECTORY %s: CONTAINS EMPTY BLOCKS",
- pathbuf);
- if (reply("ADJUST LENGTH") == 1) {
- dp = ginode(idesc->id_number);
- dp->di_size -= remsize;
- remsize = 0;
- printf(
- "YOU MUST RERUN FSCK AFTERWARDS\n");
- rerun = 1;
- inodirty();
- break;
- }
- }
- }
- sizepb *= NINDIR(&sblock);
- remsize -= sizepb;
- }
- return (KEEPON);
-}
-
-static int
-iblock(idesc, ilevel, isize)
- struct inodesc *idesc;
- long ilevel;
- quad_t isize;
-{
- ufs_daddr_t *ap;
- ufs_daddr_t *aplim;
- struct bufarea *bp;
- int i, n, (*func)(), nif;
- quad_t sizepb;
- char buf[BUFSIZ];
- char pathbuf[MAXPATHLEN + 1];
- struct dinode *dp;
-
- if (idesc->id_type == ADDR) {
- func = idesc->id_func;
- if (((n = (*func)(idesc)) & KEEPON) == 0)
- return (n);
- } else
- func = dirscan;
- if (chkrange(idesc->id_blkno, idesc->id_numfrags))
- return (SKIP);
- bp = getdatablk(idesc->id_blkno, sblock.fs_bsize);
- ilevel--;
- for (sizepb = sblock.fs_bsize, i = 0; i < ilevel; i++)
- sizepb *= NINDIR(&sblock);
- nif = howmany(isize , sizepb);
- if (nif > NINDIR(&sblock))
- nif = NINDIR(&sblock);
- if (idesc->id_func == pass1check && nif < NINDIR(&sblock)) {
- aplim = &bp->b_un.b_indir[NINDIR(&sblock)];
- for (ap = &bp->b_un.b_indir[nif]; ap < aplim; ap++) {
- if (*ap == 0)
- continue;
- (void)sprintf(buf, "PARTIALLY TRUNCATED INODE I=%lu",
- (u_long)idesc->id_number);
- if (dofix(idesc, buf)) {
- *ap = 0;
- dirty(bp);
- }
- }
- flush(fswritefd, bp);
- }
- aplim = &bp->b_un.b_indir[nif];
- for (ap = bp->b_un.b_indir; ap < aplim; ap++) {
- if (*ap) {
- idesc->id_blkno = *ap;
- if (ilevel == 0)
- n = (*func)(idesc);
- else
- n = iblock(idesc, ilevel, isize);
- if (n & STOP) {
- bp->b_flags &= ~B_INUSE;
- return (n);
- }
- } else {
- if (idesc->id_type == DATA && isize > 0) {
- /* An empty block in a directory XXX */
- getpathname(pathbuf, idesc->id_number,
- idesc->id_number);
- pfatal("DIRECTORY %s: CONTAINS EMPTY BLOCKS",
- pathbuf);
- if (reply("ADJUST LENGTH") == 1) {
- dp = ginode(idesc->id_number);
- dp->di_size -= isize;
- isize = 0;
- printf(
- "YOU MUST RERUN FSCK AFTERWARDS\n");
- rerun = 1;
- inodirty();
- bp->b_flags &= ~B_INUSE;
- return(STOP);
- }
- }
- }
- isize -= sizepb;
- }
- bp->b_flags &= ~B_INUSE;
- return (KEEPON);
-}
-
-/*
- * Check that a block in a legal block number.
- * Return 0 if in range, 1 if out of range.
- */
-int
-chkrange(blk, cnt)
- ufs_daddr_t blk;
- int cnt;
-{
- register int c;
-
- if (cnt <= 0 || blk <= 0 || blk > maxfsblock ||
- cnt - 1 > maxfsblock - blk)
- return (1);
- if (cnt > sblock.fs_frag ||
- fragnum(&sblock, blk) + cnt > sblock.fs_frag) {
- if (debug)
- printf("bad size: blk %ld, offset %ld, size %ld\n",
- blk, fragnum(&sblock, blk), cnt);
- return (1);
- }
- c = dtog(&sblock, blk);
- if (blk < cgdmin(&sblock, c)) {
- if ((blk + cnt) > cgsblock(&sblock, c)) {
- if (debug) {
- printf("blk %ld < cgdmin %ld;",
- (long)blk, (long)cgdmin(&sblock, c));
- printf(" blk + cnt %ld > cgsbase %ld\n",
- (long)(blk + cnt),
- (long)cgsblock(&sblock, c));
- }
- return (1);
- }
- } else {
- if ((blk + cnt) > cgbase(&sblock, c+1)) {
- if (debug) {
- printf("blk %ld >= cgdmin %ld;",
- (long)blk, (long)cgdmin(&sblock, c));
- printf(" blk + cnt %ld > sblock.fs_fpg %ld\n",
- (long)(blk + cnt), (long)sblock.fs_fpg);
- }
- return (1);
- }
- }
- return (0);
-}
-
-/*
- * General purpose interface for reading inodes.
- */
-struct dinode *
-ginode(inumber)
- ino_t inumber;
-{
- ufs_daddr_t iblk;
-
- if (inumber < ROOTINO || inumber > maxino)
- errx(EEXIT, "bad inode number %d to ginode", inumber);
- if (startinum == 0 ||
- inumber < startinum || inumber >= startinum + INOPB(&sblock)) {
- iblk = ino_to_fsba(&sblock, inumber);
- if (pbp != 0)
- pbp->b_flags &= ~B_INUSE;
- pbp = getdatablk(iblk, sblock.fs_bsize);
- startinum = (inumber / INOPB(&sblock)) * INOPB(&sblock);
- }
- return (&pbp->b_un.b_dinode[inumber % INOPB(&sblock)]);
-}
-
-/*
- * Special purpose version of ginode used to optimize first pass
- * over all the inodes in numerical order.
- */
-ino_t nextino, lastinum;
-long readcnt, readpercg, fullcnt, inobufsize, partialcnt, partialsize;
-struct dinode *inodebuf;
-
-struct dinode *
-getnextinode(inumber)
- ino_t inumber;
-{
- long size;
- ufs_daddr_t dblk;
- static struct dinode *dp;
-
- if (inumber != nextino++ || inumber > maxino)
- errx(EEXIT, "bad inode number %d to nextinode", inumber);
- if (inumber >= lastinum) {
- readcnt++;
- dblk = fsbtodb(&sblock, ino_to_fsba(&sblock, lastinum));
- if (readcnt % readpercg == 0) {
- size = partialsize;
- lastinum += partialcnt;
- } else {
- size = inobufsize;
- lastinum += fullcnt;
- }
- /*
- * If bread returns an error, it will already have zeroed
- * out the buffer, so we do not need to do so here.
- */
- (void)bread(fsreadfd, (char *)inodebuf, dblk, size);
- dp = inodebuf;
- }
- return (dp++);
-}
-
-void
-setinodebuf(inum)
- ino_t inum;
-{
-
- if (inum % sblock.fs_ipg != 0)
- errx(EEXIT, "bad inode number %d to setinodebuf", inum);
- startinum = 0;
- nextino = inum;
- lastinum = inum;
- readcnt = 0;
- if (inodebuf != NULL)
- return;
- inobufsize = blkroundup(&sblock, INOBUFSIZE);
- fullcnt = inobufsize / sizeof(struct dinode);
- readpercg = sblock.fs_ipg / fullcnt;
- partialcnt = sblock.fs_ipg % fullcnt;
- partialsize = partialcnt * sizeof(struct dinode);
- if (partialcnt != 0) {
- readpercg++;
- } else {
- partialcnt = fullcnt;
- partialsize = inobufsize;
- }
- if ((inodebuf = (struct dinode *)malloc((unsigned)inobufsize)) == NULL)
- errx(EEXIT, "cannot allocate space for inode buffer");
-}
-
-void
-freeinodebuf()
-{
-
- if (inodebuf != NULL)
- free((char *)inodebuf);
- inodebuf = NULL;
-}
-
-/*
- * Routines to maintain information about directory inodes.
- * This is built during the first pass and used during the
- * second and third passes.
- *
- * Enter inodes into the cache.
- */
-void
-cacheino(dp, inumber)
- register struct dinode *dp;
- ino_t inumber;
-{
- register struct inoinfo *inp;
- struct inoinfo **inpp;
- int blks;
-
- blks = howmany(dp->di_size, sblock.fs_bsize);
- if (blks > NDADDR)
- blks = NDADDR + NIADDR;
- inp = (struct inoinfo *)
- malloc(sizeof(*inp) + (blks - 1) * sizeof(ufs_daddr_t));
- if (inp == NULL)
- errx(EEXIT, "cannot increase directory list");
- inpp = &inphead[inumber % dirhash];
- inp->i_nexthash = *inpp;
- *inpp = inp;
- inp->i_parent = inumber == ROOTINO ? ROOTINO : (ino_t)0;
- inp->i_dotdot = (ino_t)0;
- inp->i_number = inumber;
- inp->i_isize = dp->di_size;
- inp->i_numblks = blks * sizeof(ufs_daddr_t);
- memmove(&inp->i_blks[0], &dp->di_db[0], (size_t)inp->i_numblks);
- if (inplast == listmax) {
- listmax += 100;
- inpsort = (struct inoinfo **)realloc((char *)inpsort,
- (unsigned)listmax * sizeof(struct inoinfo *));
- if (inpsort == NULL)
- errx(EEXIT, "cannot increase directory list");
- }
- inpsort[inplast++] = inp;
-}
-
-/*
- * Look up an inode cache structure.
- */
-struct inoinfo *
-getinoinfo(inumber)
- ino_t inumber;
-{
- register struct inoinfo *inp;
-
- for (inp = inphead[inumber % dirhash]; inp; inp = inp->i_nexthash) {
- if (inp->i_number != inumber)
- continue;
- return (inp);
- }
- errx(EEXIT, "cannot find inode %d", inumber);
- return ((struct inoinfo *)0);
-}
-
-/*
- * Clean up all the inode cache structure.
- */
-void
-inocleanup()
-{
- register struct inoinfo **inpp;
-
- if (inphead == NULL)
- return;
- for (inpp = &inpsort[inplast - 1]; inpp >= inpsort; inpp--)
- free((char *)(*inpp));
- free((char *)inphead);
- free((char *)inpsort);
- inphead = inpsort = NULL;
-}
-
-void
-inodirty()
-{
-
- dirty(pbp);
-}
-
-void
-clri(idesc, type, flag)
- register struct inodesc *idesc;
- char *type;
- int flag;
-{
- register struct dinode *dp;
-
- dp = ginode(idesc->id_number);
- if (flag == 1) {
- pwarn("%s %s", type,
- (dp->di_mode & IFMT) == IFDIR ? "DIR" : "FILE");
- pinode(idesc->id_number);
- }
- if (preen || reply("CLEAR") == 1) {
- if (preen)
- printf(" (CLEARED)\n");
- n_files--;
- (void)ckinode(dp, idesc);
- clearinode(dp);
- inoinfo(idesc->id_number)->ino_state = USTATE;
- inodirty();
- }
-}
-
-int
-findname(idesc)
- struct inodesc *idesc;
-{
- register struct direct *dirp = idesc->id_dirp;
-
- if (dirp->d_ino != idesc->id_parent || idesc->id_entryno < 2) {
- idesc->id_entryno++;
- return (KEEPON);
- }
- memmove(idesc->id_name, dirp->d_name, (size_t)dirp->d_namlen + 1);
- return (STOP|FOUND);
-}
-
-int
-findino(idesc)
- struct inodesc *idesc;
-{
- register struct direct *dirp = idesc->id_dirp;
-
- if (dirp->d_ino == 0)
- return (KEEPON);
- if (strcmp(dirp->d_name, idesc->id_name) == 0 &&
- dirp->d_ino >= ROOTINO && dirp->d_ino <= maxino) {
- idesc->id_parent = dirp->d_ino;
- return (STOP|FOUND);
- }
- return (KEEPON);
-}
-
-int
-clearentry(idesc)
- struct inodesc *idesc;
-{
- register struct direct *dirp = idesc->id_dirp;
-
- if (dirp->d_ino != idesc->id_parent || idesc->id_entryno < 2) {
- idesc->id_entryno++;
- return (KEEPON);
- }
- dirp->d_ino = 0;
- return (STOP|FOUND|ALTERED);
-}
-
-void
-pinode(ino)
- ino_t ino;
-{
- register struct dinode *dp;
- register char *p;
- struct passwd *pw;
- time_t t;
-
- printf(" I=%lu ", (u_long)ino);
- if (ino < ROOTINO || ino > maxino)
- return;
- dp = ginode(ino);
- printf(" OWNER=");
- if ((pw = getpwuid((int)dp->di_uid)) != 0)
- printf("%s ", pw->pw_name);
- else
- printf("%u ", (unsigned)dp->di_uid);
- printf("MODE=%o\n", dp->di_mode);
- if (preen)
- printf("%s: ", cdevname);
- printf("SIZE=%qu ", dp->di_size);
- t = dp->di_mtime;
- p = ctime(&t);
- printf("MTIME=%12.12s %4.4s ", &p[4], &p[20]);
-}
-
-void
-blkerror(ino, type, blk)
- ino_t ino;
- char *type;
- ufs_daddr_t blk;
-{
-
- pfatal("%ld %s I=%lu", blk, type, ino);
- printf("\n");
- switch (inoinfo(ino)->ino_state) {
-
- case FSTATE:
- inoinfo(ino)->ino_state = FCLEAR;
- return;
-
- case DSTATE:
- inoinfo(ino)->ino_state = DCLEAR;
- return;
-
- case FCLEAR:
- case DCLEAR:
- return;
-
- default:
- errx(EEXIT, "BAD STATE %d TO BLKERR", inoinfo(ino)->ino_state);
- /* NOTREACHED */
- }
-}
-
-/*
- * allocate an unused inode
- */
-ino_t
-allocino(request, type)
- ino_t request;
- int type;
-{
- register ino_t ino;
- register struct dinode *dp;
- struct cg *cgp = &cgrp;
- int cg;
-
- if (request == 0)
- request = ROOTINO;
- else if (inoinfo(request)->ino_state != USTATE)
- return (0);
- for (ino = request; ino < maxino; ino++)
- if (inoinfo(ino)->ino_state == USTATE)
- break;
- if (ino == maxino)
- return (0);
- cg = ino_to_cg(&sblock, ino);
- getblk(&cgblk, cgtod(&sblock, cg), sblock.fs_cgsize);
- if (!cg_chkmagic(cgp))
- pfatal("CG %d: BAD MAGIC NUMBER\n", cg);
- setbit(cg_inosused(cgp), ino % sblock.fs_ipg);
- cgp->cg_cs.cs_nifree--;
- switch (type & IFMT) {
- case IFDIR:
- inoinfo(ino)->ino_state = DSTATE;
- cgp->cg_cs.cs_ndir++;
- break;
- case IFREG:
- case IFLNK:
- inoinfo(ino)->ino_state = FSTATE;
- break;
- default:
- return (0);
- }
- cgdirty();
- dp = ginode(ino);
- dp->di_db[0] = allocblk((long)1);
- if (dp->di_db[0] == 0) {
- inoinfo(ino)->ino_state = USTATE;
- return (0);
- }
- dp->di_mode = type;
- dp->di_flags = 0;
- dp->di_atime = time(NULL);
- dp->di_mtime = dp->di_ctime = dp->di_atime;
- dp->di_mtimensec = dp->di_ctimensec = dp->di_atimensec = 0;
- dp->di_size = sblock.fs_fsize;
- dp->di_blocks = btodb(sblock.fs_fsize);
- n_files++;
- inodirty();
- if (newinofmt)
- inoinfo(ino)->ino_type = IFTODT(type);
- return (ino);
-}
-
-/*
- * deallocate an inode
- */
-void
-freeino(ino)
- ino_t ino;
-{
- struct inodesc idesc;
- struct dinode *dp;
-
- memset(&idesc, 0, sizeof(struct inodesc));
- idesc.id_type = ADDR;
- idesc.id_func = pass4check;
- idesc.id_number = ino;
- dp = ginode(ino);
- (void)ckinode(dp, &idesc);
- clearinode(dp);
- inodirty();
- inoinfo(ino)->ino_state = USTATE;
- n_files--;
-}
diff --git a/sbin/fsck_ffs/main.c b/sbin/fsck_ffs/main.c
deleted file mode 100644
index 6463990b5e6f..000000000000
--- a/sbin/fsck_ffs/main.c
+++ /dev/null
@@ -1,417 +0,0 @@
-/*
- * Copyright (c) 1980, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-static const char copyright[] =
-"@(#) Copyright (c) 1980, 1986, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/14/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/mount.h>
-#include <sys/resource.h>
-
-#include <ufs/ufs/dinode.h>
-#include <ufs/ufs/ufsmount.h>
-#include <ufs/ffs/fs.h>
-
-#include <err.h>
-#include <errno.h>
-#include <fstab.h>
-#include <paths.h>
-
-#include "fsck.h"
-
-static int argtoi __P((int flag, char *req, char *str, int base));
-static int docheck __P((struct fstab *fsp));
-static int checkfilesys __P((char *filesys, char *mntpt, long auxdata,
- int child));
-static struct statfs *getmntpt __P((const char *));
-int main __P((int argc, char *argv[]));
-
-int
-main(argc, argv)
- int argc;
- char *argv[];
-{
- int ch;
- int ret, maxrun = 0;
- struct rlimit rlimit;
-
- sync();
- while ((ch = getopt(argc, argv, "dfpnNyYb:c:l:m:")) != -1) {
- switch (ch) {
- case 'p':
- preen++;
- break;
-
- case 'b':
- bflag = argtoi('b', "number", optarg, 10);
- printf("Alternate super block location: %d\n", bflag);
- break;
-
- case 'c':
- cvtlevel = argtoi('c', "conversion level", optarg, 10);
- break;
-
- case 'd':
- debug++;
- break;
-
- case 'f':
- fflag++;
- break;
-
- case 'l':
- maxrun = argtoi('l', "number", optarg, 10);
- break;
-
- case 'm':
- lfmode = argtoi('m', "mode", optarg, 8);
- if (lfmode &~ 07777)
- errx(EEXIT, "bad mode to -m: %o", lfmode);
- printf("** lost+found creation mode %o\n", lfmode);
- break;
-
- case 'n':
- case 'N':
- nflag++;
- yflag = 0;
- break;
-
- case 'y':
- case 'Y':
- yflag++;
- nflag = 0;
- break;
-
- default:
- errx(EEXIT, "%c option?", ch);
- }
- }
- argc -= optind;
- argv += optind;
- if (signal(SIGINT, SIG_IGN) != SIG_IGN)
- (void)signal(SIGINT, catch);
- if (preen)
- (void)signal(SIGQUIT, catchquit);
- /*
- * Push up our allowed memory limit so we can cope
- * with huge filesystems.
- */
- if (getrlimit(RLIMIT_DATA, &rlimit) == 0) {
- rlimit.rlim_cur = rlimit.rlim_max;
- (void)setrlimit(RLIMIT_DATA, &rlimit);
- }
- if (argc) {
- while (argc-- > 0) {
- char *path = blockcheck(*argv);
-
- if (path == NULL)
- pfatal("Can't check %s\n", *argv);
- else
- (void)checkfilesys(path, 0, 0L, 0);
- ++argv;
- }
- exit(0);
- }
- ret = checkfstab(preen, maxrun, docheck, checkfilesys);
- if (returntosingle)
- exit(2);
- exit(ret);
-}
-
-static int
-argtoi(flag, req, str, base)
- int flag;
- char *req, *str;
- int base;
-{
- char *cp;
- int ret;
-
- ret = (int)strtol(str, &cp, base);
- if (cp == str || *cp)
- errx(EEXIT, "-%c flag requires a %s", flag, req);
- return (ret);
-}
-
-/*
- * Determine whether a filesystem should be checked.
- */
-static int
-docheck(fsp)
- register struct fstab *fsp;
-{
-
- if (strcmp(fsp->fs_vfstype, "ufs") ||
- (strcmp(fsp->fs_type, FSTAB_RW) &&
- strcmp(fsp->fs_type, FSTAB_RO)) ||
- fsp->fs_passno == 0)
- return (0);
- return (1);
-}
-
-/*
- * Check the specified filesystem.
- */
-/* ARGSUSED */
-static int
-checkfilesys(filesys, mntpt, auxdata, child)
- char *filesys, *mntpt;
- long auxdata;
- int child;
-{
- ufs_daddr_t n_ffree, n_bfree;
- struct dups *dp;
- struct statfs *mntbuf;
- struct zlncnt *zlnp;
- int cylno;
-
- if (preen && child)
- (void)signal(SIGQUIT, voidquit);
- cdevname = filesys;
- if (debug && preen)
- pwarn("starting\n");
- switch (setup(filesys)) {
- case 0:
- if (preen)
- pfatal("CAN'T CHECK FILE SYSTEM.");
- return (0);
- case -1:
- pwarn("clean, %ld free ", sblock.fs_cstotal.cs_nffree +
- sblock.fs_frag * sblock.fs_cstotal.cs_nbfree);
- printf("(%d frags, %d blocks, %.1f%% fragmentation)\n",
- sblock.fs_cstotal.cs_nffree, sblock.fs_cstotal.cs_nbfree,
- sblock.fs_cstotal.cs_nffree * 100.0 / sblock.fs_dsize);
- return (0);
- }
-
- /*
- * Get the mount point information of the filesystem, if
- * it is available.
- */
- mntbuf = getmntpt(filesys);
-
- /*
- * Cleared if any questions answered no. Used to decide if
- * the superblock should be marked clean.
- */
- resolved = 1;
- /*
- * 1: scan inodes tallying blocks used
- */
- if (preen == 0) {
- printf("** Last Mounted on %s\n", sblock.fs_fsmnt);
- if (mntbuf != NULL && mntbuf->f_flags & MNT_ROOTFS)
- printf("** Root file system\n");
- printf("** Phase 1 - Check Blocks and Sizes\n");
- }
- pass1();
-
- /*
- * 1b: locate first references to duplicates, if any
- */
- if (duplist) {
- if (preen || usedsoftdep)
- pfatal("INTERNAL ERROR: dups with -p");
- printf("** Phase 1b - Rescan For More DUPS\n");
- pass1b();
- }
-
- /*
- * 2: traverse directories from root to mark all connected directories
- */
- if (preen == 0)
- printf("** Phase 2 - Check Pathnames\n");
- pass2();
-
- /*
- * 3: scan inodes looking for disconnected directories
- */
- if (preen == 0)
- printf("** Phase 3 - Check Connectivity\n");
- pass3();
-
- /*
- * 4: scan inodes looking for disconnected files; check reference counts
- */
- if (preen == 0)
- printf("** Phase 4 - Check Reference Counts\n");
- pass4();
-
- /*
- * 5: check and repair resource counts in cylinder groups
- */
- if (preen == 0)
- printf("** Phase 5 - Check Cyl groups\n");
- pass5();
-
- /*
- * print out summary statistics
- */
- n_ffree = sblock.fs_cstotal.cs_nffree;
- n_bfree = sblock.fs_cstotal.cs_nbfree;
- pwarn("%ld files, %ld used, %ld free ",
- n_files, n_blks, n_ffree + sblock.fs_frag * n_bfree);
- printf("(%d frags, %d blocks, %.1f%% fragmentation)\n",
- n_ffree, n_bfree, n_ffree * 100.0 / sblock.fs_dsize);
- if (debug &&
- (n_files -= maxino - ROOTINO - sblock.fs_cstotal.cs_nifree))
- printf("%d files missing\n", n_files);
- if (debug) {
- n_blks += sblock.fs_ncg *
- (cgdmin(&sblock, 0) - cgsblock(&sblock, 0));
- n_blks += cgsblock(&sblock, 0) - cgbase(&sblock, 0);
- n_blks += howmany(sblock.fs_cssize, sblock.fs_fsize);
- if (n_blks -= maxfsblock - (n_ffree + sblock.fs_frag * n_bfree))
- printf("%d blocks missing\n", n_blks);
- if (duplist != NULL) {
- printf("The following duplicate blocks remain:");
- for (dp = duplist; dp; dp = dp->next)
- printf(" %d,", dp->dup);
- printf("\n");
- }
- if (zlnhead != NULL) {
- printf("The following zero link count inodes remain:");
- for (zlnp = zlnhead; zlnp; zlnp = zlnp->next)
- printf(" %u,", zlnp->zlncnt);
- printf("\n");
- }
- }
- zlnhead = (struct zlncnt *)0;
- duplist = (struct dups *)0;
- muldup = (struct dups *)0;
- inocleanup();
- if (fsmodified) {
- sblock.fs_time = time(NULL);
- sbdirty();
- }
- if (cvtlevel && sblk.b_dirty) {
- /*
- * Write out the duplicate super blocks
- */
- for (cylno = 0; cylno < sblock.fs_ncg; cylno++)
- bwrite(fswritefd, (char *)&sblock,
- fsbtodb(&sblock, cgsblock(&sblock, cylno)), SBSIZE);
- }
- if (rerun)
- resolved = 0;
-
- /*
- * Check to see if the filesystem is mounted read-write.
- */
- if (mntbuf != NULL && (mntbuf->f_flags & MNT_RDONLY) == 0)
- resolved = 0;
- ckfini(resolved);
-
- for (cylno = 0; cylno < sblock.fs_ncg; cylno++)
- if (inostathead[cylno].il_stat != NULL)
- free((char *)inostathead[cylno].il_stat);
- free((char *)inostathead);
- inostathead = NULL;
- if (fsmodified && !preen)
- printf("\n***** FILE SYSTEM WAS MODIFIED *****\n");
- if (rerun)
- printf("\n***** PLEASE RERUN FSCK *****\n");
- if (mntbuf != NULL) {
- struct ufs_args args;
- int ret;
- /*
- * We modified a mounted filesystem. Do a mount update on
- * it unless it is read-write, so we can continue using it
- * as safely as possible.
- */
- if (mntbuf->f_flags & MNT_RDONLY) {
- args.fspec = 0;
- args.export.ex_flags = 0;
- args.export.ex_root = 0;
- ret = mount("ufs", mntbuf->f_mntonname,
- mntbuf->f_flags | MNT_UPDATE | MNT_RELOAD, &args);
- if (ret == 0)
- return (0);
- pwarn("mount reload of '%s' failed: %s\n\n",
- mntbuf->f_mntonname, strerror(errno));
- }
- if (!fsmodified)
- return (0);
- if (!preen)
- printf("\n***** REBOOT NOW *****\n");
- sync();
- return (4);
- }
- return (0);
-}
-
-/*
- * Get the directory that the device is mounted on.
- */
-static struct statfs *
-getmntpt(name)
- const char *name;
-{
- struct stat devstat, mntdevstat;
- char device[sizeof(_PATH_DEV) - 1 + MNAMELEN];
- char *devname;
- struct statfs *mntbuf;
- int i, mntsize;
-
- if (stat(name, &devstat) != 0 ||
- !(S_ISCHR(devstat.st_mode) || S_ISBLK(devstat.st_mode)))
- return (NULL);
- mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
- for (i = 0; i < mntsize; i++) {
- if (strcmp(mntbuf[i].f_fstypename, "ufs") != 0)
- continue;
- devname = mntbuf[i].f_mntfromname;
- if (*devname != '/') {
- strcpy(device, _PATH_DEV);
- strcat(device, devname);
- devname = device;
- }
- if (stat(devname, &mntdevstat) == 0 &&
- mntdevstat.st_rdev == devstat.st_rdev)
- return (&mntbuf[i]);
- }
- return (NULL);
-}
diff --git a/sbin/fsck_ffs/pass1.c b/sbin/fsck_ffs/pass1.c
deleted file mode 100644
index dd09b009705e..000000000000
--- a/sbin/fsck_ffs/pass1.c
+++ /dev/null
@@ -1,406 +0,0 @@
-/*
- * Copyright (c) 1980, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-#if 0
-static const char sccsid[] = "@(#)pass1.c 8.6 (Berkeley) 4/28/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <sys/param.h>
-
-#include <ufs/ufs/dinode.h>
-#include <ufs/ufs/dir.h>
-#include <ufs/ffs/fs.h>
-
-#include <err.h>
-#include <string.h>
-
-#include "fsck.h"
-
-static ufs_daddr_t badblk;
-static ufs_daddr_t dupblk;
-static ino_t lastino; /* last inode in use */
-
-static void checkinode __P((ino_t inumber, struct inodesc *));
-
-void
-pass1()
-{
- u_int8_t *cp;
- ino_t inumber;
- int c, i, cgd, inosused;
- struct inostat *info;
- struct inodesc idesc;
-
- /*
- * Set file system reserved blocks in used block map.
- */
- for (c = 0; c < sblock.fs_ncg; c++) {
- cgd = cgdmin(&sblock, c);
- if (c == 0) {
- i = cgbase(&sblock, c);
- cgd += howmany(sblock.fs_cssize, sblock.fs_fsize);
- } else
- i = cgsblock(&sblock, c);
- for (; i < cgd; i++)
- setbmap(i);
- }
- /*
- * Find all allocated blocks.
- */
- memset(&idesc, 0, sizeof(struct inodesc));
- idesc.id_type = ADDR;
- idesc.id_func = pass1check;
- n_files = n_blks = 0;
- for (c = 0; c < sblock.fs_ncg; c++) {
- inumber = c * sblock.fs_ipg;
- setinodebuf(inumber);
- inosused = sblock.fs_ipg;
- /*
- * If we are using soft updates, then we can trust the
- * cylinder group inode allocation maps to tell us which
- * inodes are allocated. We will scan the used inode map
- * to find the inodes that are really in use, and then
- * read only those inodes in from disk.
- */
- if (preen && usedsoftdep) {
- getblk(&cgblk, cgtod(&sblock, c), sblock.fs_cgsize);
- if (!cg_chkmagic(&cgrp))
- pfatal("CG %d: BAD MAGIC NUMBER\n", c);
- cp = &cg_inosused(&cgrp)[(sblock.fs_ipg - 1) / NBBY];
- for ( ; inosused > 0; inosused -= NBBY, cp--) {
- if (*cp == 0)
- continue;
- for (i = 1 << (NBBY - 1); i > 0; i >>= 1) {
- if (*cp & i)
- break;
- inosused--;
- }
- break;
- }
- if (inosused < 0)
- inosused = 0;
- }
- /*
- * Allocate inoinfo structures for the allocated inodes.
- */
- inostathead[c].il_numalloced = inosused;
- if (inosused == 0) {
- inostathead[c].il_stat = 0;
- continue;
- }
- info = calloc((unsigned)inosused, sizeof(struct inostat));
- if (info == NULL)
- pfatal("cannot alloc %u bytes for inoinfo\n",
- (unsigned)(sizeof(struct inostat) * inosused));
- inostathead[c].il_stat = info;
- /*
- * Scan the allocated inodes.
- */
- for (i = 0; i < inosused; i++, inumber++) {
- if (inumber < ROOTINO) {
- (void)getnextinode(inumber);
- continue;
- }
- checkinode(inumber, &idesc);
- }
- lastino += 1;
- if (inosused < sblock.fs_ipg || inumber == lastino)
- continue;
- /*
- * If we were not able to determine in advance which inodes
- * were in use, then reduce the size of the inoinfo structure
- * to the size necessary to describe the inodes that we
- * really found.
- */
- inosused = lastino - (c * sblock.fs_ipg);
- if (inosused < 0)
- inosused = 0;
- inostathead[c].il_numalloced = inosused;
- if (inosused == 0) {
- free(inostathead[c].il_stat);
- inostathead[c].il_stat = 0;
- continue;
- }
- info = calloc((unsigned)inosused, sizeof(struct inostat));
- if (info == NULL)
- pfatal("cannot alloc %u bytes for inoinfo\n",
- (unsigned)(sizeof(struct inostat) * inosused));
- memmove(info, inostathead[c].il_stat, inosused * sizeof(*info));
- free(inostathead[c].il_stat);
- inostathead[c].il_stat = info;
- }
- freeinodebuf();
-}
-
-static void
-checkinode(inumber, idesc)
- ino_t inumber;
- register struct inodesc *idesc;
-{
- register struct dinode *dp;
- struct zlncnt *zlnp;
- int ndb, j;
- mode_t mode;
- char *symbuf;
-
- dp = getnextinode(inumber);
- mode = dp->di_mode & IFMT;
- if (mode == 0) {
- if (memcmp(dp->di_db, zino.di_db,
- NDADDR * sizeof(ufs_daddr_t)) ||
- memcmp(dp->di_ib, zino.di_ib,
- NIADDR * sizeof(ufs_daddr_t)) ||
- dp->di_mode || dp->di_size) {
- pfatal("PARTIALLY ALLOCATED INODE I=%lu", inumber);
- if (reply("CLEAR") == 1) {
- dp = ginode(inumber);
- clearinode(dp);
- inodirty();
- }
- }
- inoinfo(inumber)->ino_state = USTATE;
- return;
- }
- lastino = inumber;
- if (/* dp->di_size < 0 || */
- dp->di_size + sblock.fs_bsize - 1 < dp->di_size ||
- (mode == IFDIR && dp->di_size > MAXDIRSIZE)) {
- if (debug)
- printf("bad size %qu:", dp->di_size);
- goto unknown;
- }
- if (!preen && mode == IFMT && reply("HOLD BAD BLOCK") == 1) {
- dp = ginode(inumber);
- dp->di_size = sblock.fs_fsize;
- dp->di_mode = IFREG|0600;
- inodirty();
- }
- ndb = howmany(dp->di_size, sblock.fs_bsize);
- if (ndb < 0) {
- if (debug)
- printf("bad size %qu ndb %d:",
- dp->di_size, ndb);
- goto unknown;
- }
- if (mode == IFBLK || mode == IFCHR)
- ndb++;
- if (mode == IFLNK) {
- if (doinglevel2 &&
- dp->di_size > 0 && dp->di_size < MAXSYMLINKLEN &&
- dp->di_blocks != 0) {
- symbuf = alloca(secsize);
- if (bread(fsreadfd, symbuf,
- fsbtodb(&sblock, dp->di_db[0]),
- (long)secsize) != 0)
- errx(EEXIT, "cannot read symlink");
- if (debug) {
- symbuf[dp->di_size] = 0;
- printf("convert symlink %lu(%s) of size %ld\n",
- (u_long)inumber, symbuf, (long)dp->di_size);
- }
- dp = ginode(inumber);
- memmove(dp->di_shortlink, symbuf, (long)dp->di_size);
- dp->di_blocks = 0;
- inodirty();
- }
- /*
- * Fake ndb value so direct/indirect block checks below
- * will detect any garbage after symlink string.
- */
- if (dp->di_size < sblock.fs_maxsymlinklen) {
- ndb = howmany(dp->di_size, sizeof(ufs_daddr_t));
- if (ndb > NDADDR) {
- j = ndb - NDADDR;
- for (ndb = 1; j > 1; j--)
- ndb *= NINDIR(&sblock);
- ndb += NDADDR;
- }
- }
- }
- for (j = ndb; j < NDADDR; j++)
- if (dp->di_db[j] != 0) {
- if (debug)
- printf("bad direct addr: %ld\n",
- (long)dp->di_db[j]);
- goto unknown;
- }
- for (j = 0, ndb -= NDADDR; ndb > 0; j++)
- ndb /= NINDIR(&sblock);
- for (; j < NIADDR; j++)
- if (dp->di_ib[j] != 0) {
- if (debug)
- printf("bad indirect addr: %ld\n",
- (long)dp->di_ib[j]);
- goto unknown;
- }
- if (ftypeok(dp) == 0)
- goto unknown;
- n_files++;
- inoinfo(inumber)->ino_linkcnt = dp->di_nlink;
- if (dp->di_nlink <= 0) {
- zlnp = (struct zlncnt *)malloc(sizeof *zlnp);
- if (zlnp == NULL) {
- pfatal("LINK COUNT TABLE OVERFLOW");
- if (reply("CONTINUE") == 0) {
- ckfini(0);
- exit(EEXIT);
- }
- } else {
- zlnp->zlncnt = inumber;
- zlnp->next = zlnhead;
- zlnhead = zlnp;
- }
- }
- if (mode == IFDIR) {
- if (dp->di_size == 0)
- inoinfo(inumber)->ino_state = DCLEAR;
- else
- inoinfo(inumber)->ino_state = DSTATE;
- cacheino(dp, inumber);
- countdirs++;
- } else
- inoinfo(inumber)->ino_state = FSTATE;
- inoinfo(inumber)->ino_type = IFTODT(mode);
- if (doinglevel2 &&
- (dp->di_ouid != (u_short)-1 || dp->di_ogid != (u_short)-1)) {
- dp = ginode(inumber);
- dp->di_uid = dp->di_ouid;
- dp->di_ouid = -1;
- dp->di_gid = dp->di_ogid;
- dp->di_ogid = -1;
- inodirty();
- }
- badblk = dupblk = 0;
- idesc->id_number = inumber;
- (void)ckinode(dp, idesc);
- idesc->id_entryno *= btodb(sblock.fs_fsize);
- if (dp->di_blocks != idesc->id_entryno) {
- pwarn("INCORRECT BLOCK COUNT I=%lu (%ld should be %ld)",
- inumber, dp->di_blocks, idesc->id_entryno);
- if (preen)
- printf(" (CORRECTED)\n");
- else if (reply("CORRECT") == 0)
- return;
- dp = ginode(inumber);
- dp->di_blocks = idesc->id_entryno;
- inodirty();
- }
- return;
-unknown:
- pfatal("UNKNOWN FILE TYPE I=%lu", inumber);
- inoinfo(inumber)->ino_state = FCLEAR;
- if (reply("CLEAR") == 1) {
- inoinfo(inumber)->ino_state = USTATE;
- dp = ginode(inumber);
- clearinode(dp);
- inodirty();
- }
-}
-
-int
-pass1check(idesc)
- register struct inodesc *idesc;
-{
- int res = KEEPON;
- int anyout, nfrags;
- ufs_daddr_t blkno = idesc->id_blkno;
- register struct dups *dlp;
- struct dups *new;
-
- if ((anyout = chkrange(blkno, idesc->id_numfrags)) != 0) {
- blkerror(idesc->id_number, "BAD", blkno);
- if (badblk++ >= MAXBAD) {
- pwarn("EXCESSIVE BAD BLKS I=%lu",
- idesc->id_number);
- if (preen)
- printf(" (SKIPPING)\n");
- else if (reply("CONTINUE") == 0) {
- ckfini(0);
- exit(EEXIT);
- }
- return (STOP);
- }
- }
- for (nfrags = idesc->id_numfrags; nfrags > 0; blkno++, nfrags--) {
- if (anyout && chkrange(blkno, 1)) {
- res = SKIP;
- } else if (!testbmap(blkno)) {
- n_blks++;
- setbmap(blkno);
- } else {
- blkerror(idesc->id_number, "DUP", blkno);
- if (dupblk++ >= MAXDUP) {
- pwarn("EXCESSIVE DUP BLKS I=%lu",
- idesc->id_number);
- if (preen)
- printf(" (SKIPPING)\n");
- else if (reply("CONTINUE") == 0) {
- ckfini(0);
- exit(EEXIT);
- }
- return (STOP);
- }
- new = (struct dups *)malloc(sizeof(struct dups));
- if (new == NULL) {
- pfatal("DUP TABLE OVERFLOW.");
- if (reply("CONTINUE") == 0) {
- ckfini(0);
- exit(EEXIT);
- }
- return (STOP);
- }
- new->dup = blkno;
- if (muldup == 0) {
- duplist = muldup = new;
- new->next = 0;
- } else {
- new->next = muldup->next;
- muldup->next = new;
- }
- for (dlp = duplist; dlp != muldup; dlp = dlp->next)
- if (dlp->dup == blkno)
- break;
- if (dlp == muldup && dlp->dup != blkno)
- muldup = new;
- }
- /*
- * count the number of blocks found in id_entryno
- */
- idesc->id_entryno++;
- }
- return (res);
-}
diff --git a/sbin/fsck_ffs/pass1b.c b/sbin/fsck_ffs/pass1b.c
deleted file mode 100644
index 7ef662f27364..000000000000
--- a/sbin/fsck_ffs/pass1b.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (c) 1980, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-#if 0
-static const char sccsid[] = "@(#)pass1b.c 8.4 (Berkeley) 4/28/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <sys/param.h>
-
-#include <ufs/ufs/dinode.h>
-#include <ufs/ffs/fs.h>
-
-#include <string.h>
-
-#include "fsck.h"
-
-static struct dups *duphead;
-static int pass1bcheck __P((struct inodesc *));
-
-void
-pass1b()
-{
- register int c, i;
- register struct dinode *dp;
- struct inodesc idesc;
- ino_t inumber;
-
- memset(&idesc, 0, sizeof(struct inodesc));
- idesc.id_type = ADDR;
- idesc.id_func = pass1bcheck;
- duphead = duplist;
- inumber = 0;
- for (c = 0; c < sblock.fs_ncg; c++) {
- for (i = 0; i < sblock.fs_ipg; i++, inumber++) {
- if (inumber < ROOTINO)
- continue;
- dp = ginode(inumber);
- if (dp == NULL)
- continue;
- idesc.id_number = inumber;
- if (inoinfo(inumber)->ino_state != USTATE &&
- (ckinode(dp, &idesc) & STOP))
- return;
- }
- }
-}
-
-static int
-pass1bcheck(idesc)
- register struct inodesc *idesc;
-{
- register struct dups *dlp;
- int nfrags, res = KEEPON;
- ufs_daddr_t blkno = idesc->id_blkno;
-
- for (nfrags = idesc->id_numfrags; nfrags > 0; blkno++, nfrags--) {
- if (chkrange(blkno, 1))
- res = SKIP;
- for (dlp = duphead; dlp; dlp = dlp->next) {
- if (dlp->dup == blkno) {
- blkerror(idesc->id_number, "DUP", blkno);
- dlp->dup = duphead->dup;
- duphead->dup = blkno;
- duphead = duphead->next;
- }
- if (dlp == muldup)
- break;
- }
- if (muldup == 0 || duphead == muldup->next)
- return (STOP);
- }
- return (res);
-}
diff --git a/sbin/fsck_ffs/pass2.c b/sbin/fsck_ffs/pass2.c
deleted file mode 100644
index 088ecffb9817..000000000000
--- a/sbin/fsck_ffs/pass2.c
+++ /dev/null
@@ -1,486 +0,0 @@
-/*
- * Copyright (c) 1980, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-#if 0
-static const char sccsid[] = "@(#)pass2.c 8.9 (Berkeley) 4/28/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <sys/param.h>
-
-#include <ufs/ufs/dinode.h>
-#include <ufs/ufs/dir.h>
-
-#include <err.h>
-#include <string.h>
-
-#include "fsck.h"
-
-#define MINDIRSIZE (sizeof (struct dirtemplate))
-
-static int blksort __P((const void *, const void *));
-static int pass2check __P((struct inodesc *));
-
-void
-pass2()
-{
- register struct dinode *dp;
- register struct inoinfo **inpp, *inp;
- struct inoinfo **inpend;
- struct inodesc curino;
- struct dinode dino;
- char pathbuf[MAXPATHLEN + 1];
-
- switch (inoinfo(ROOTINO)->ino_state) {
-
- case USTATE:
- pfatal("ROOT INODE UNALLOCATED");
- if (reply("ALLOCATE") == 0) {
- ckfini(0);
- exit(EEXIT);
- }
- if (allocdir(ROOTINO, ROOTINO, 0755) != ROOTINO)
- errx(EEXIT, "CANNOT ALLOCATE ROOT INODE");
- break;
-
- case DCLEAR:
- pfatal("DUPS/BAD IN ROOT INODE");
- if (reply("REALLOCATE")) {
- freeino(ROOTINO);
- if (allocdir(ROOTINO, ROOTINO, 0755) != ROOTINO)
- errx(EEXIT, "CANNOT ALLOCATE ROOT INODE");
- break;
- }
- if (reply("CONTINUE") == 0) {
- ckfini(0);
- exit(EEXIT);
- }
- break;
-
- case FSTATE:
- case FCLEAR:
- pfatal("ROOT INODE NOT DIRECTORY");
- if (reply("REALLOCATE")) {
- freeino(ROOTINO);
- if (allocdir(ROOTINO, ROOTINO, 0755) != ROOTINO)
- errx(EEXIT, "CANNOT ALLOCATE ROOT INODE");
- break;
- }
- if (reply("FIX") == 0) {
- ckfini(0);
- exit(EEXIT);
- }
- dp = ginode(ROOTINO);
- dp->di_mode &= ~IFMT;
- dp->di_mode |= IFDIR;
- inodirty();
- break;
-
- case DSTATE:
- break;
-
- default:
- errx(EEXIT, "BAD STATE %d FOR ROOT INODE",
- inoinfo(ROOTINO)->ino_state);
- }
- inoinfo(ROOTINO)->ino_state = DFOUND;
- if (newinofmt) {
- inoinfo(WINO)->ino_state = FSTATE;
- inoinfo(WINO)->ino_type = DT_WHT;
- }
- /*
- * Sort the directory list into disk block order.
- */
- qsort((char *)inpsort, (size_t)inplast, sizeof *inpsort, blksort);
- /*
- * Check the integrity of each directory.
- */
- memset(&curino, 0, sizeof(struct inodesc));
- curino.id_type = DATA;
- curino.id_func = pass2check;
- dp = &dino;
- inpend = &inpsort[inplast];
- for (inpp = inpsort; inpp < inpend; inpp++) {
- inp = *inpp;
- if (inp->i_isize == 0)
- continue;
- if (inp->i_isize < MINDIRSIZE) {
- direrror(inp->i_number, "DIRECTORY TOO SHORT");
- inp->i_isize = roundup(MINDIRSIZE, DIRBLKSIZ);
- if (reply("FIX") == 1) {
- dp = ginode(inp->i_number);
- dp->di_size = inp->i_isize;
- inodirty();
- dp = &dino;
- }
- } else if ((inp->i_isize & (DIRBLKSIZ - 1)) != 0) {
- getpathname(pathbuf, inp->i_number, inp->i_number);
- if (usedsoftdep)
- pfatal("%s %s: LENGTH %d NOT MULTIPLE OF %d",
- "DIRECTORY", pathbuf, inp->i_isize,
- DIRBLKSIZ);
- else
- pwarn("%s %s: LENGTH %d NOT MULTIPLE OF %d",
- "DIRECTORY", pathbuf, inp->i_isize,
- DIRBLKSIZ);
- if (preen)
- printf(" (ADJUSTED)\n");
- inp->i_isize = roundup(inp->i_isize, DIRBLKSIZ);
- if (preen || reply("ADJUST") == 1) {
- dp = ginode(inp->i_number);
- dp->di_size = roundup(inp->i_isize, DIRBLKSIZ);
- inodirty();
- dp = &dino;
- }
- }
- memset(&dino, 0, sizeof(struct dinode));
- dino.di_mode = IFDIR;
- dp->di_size = inp->i_isize;
- memmove(&dp->di_db[0], &inp->i_blks[0], (size_t)inp->i_numblks);
- curino.id_number = inp->i_number;
- curino.id_parent = inp->i_parent;
- (void)ckinode(dp, &curino);
- }
- /*
- * Now that the parents of all directories have been found,
- * make another pass to verify the value of `..'
- */
- for (inpp = inpsort; inpp < inpend; inpp++) {
- inp = *inpp;
- if (inp->i_parent == 0 || inp->i_isize == 0)
- continue;
- if (inoinfo(inp->i_parent)->ino_state == DFOUND &&
- inoinfo(inp->i_number)->ino_state == DSTATE)
- inoinfo(inp->i_number)->ino_state = DFOUND;
- if (inp->i_dotdot == inp->i_parent ||
- inp->i_dotdot == (ino_t)-1)
- continue;
- if (inp->i_dotdot == 0) {
- inp->i_dotdot = inp->i_parent;
- fileerror(inp->i_parent, inp->i_number, "MISSING '..'");
- if (reply("FIX") == 0)
- continue;
- (void)makeentry(inp->i_number, inp->i_parent, "..");
- inoinfo(inp->i_parent)->ino_linkcnt--;
- continue;
- }
- fileerror(inp->i_parent, inp->i_number,
- "BAD INODE NUMBER FOR '..'");
- if (reply("FIX") == 0)
- continue;
- inoinfo(inp->i_dotdot)->ino_linkcnt++;
- inoinfo(inp->i_parent)->ino_linkcnt--;
- inp->i_dotdot = inp->i_parent;
- (void)changeino(inp->i_number, "..", inp->i_parent);
- }
- /*
- * Mark all the directories that can be found from the root.
- */
- propagate();
-}
-
-static int
-pass2check(idesc)
- struct inodesc *idesc;
-{
- register struct direct *dirp = idesc->id_dirp;
- register struct inoinfo *inp;
- int n, entrysize, ret = 0;
- struct dinode *dp;
- char *errmsg;
- struct direct proto;
- char namebuf[MAXPATHLEN + 1];
- char pathbuf[MAXPATHLEN + 1];
-
- /*
- * If converting, set directory entry type.
- */
- if (doinglevel2 && dirp->d_ino > 0 && dirp->d_ino < maxino) {
- dirp->d_type = inoinfo(dirp->d_ino)->ino_type;
- ret |= ALTERED;
- }
- /*
- * check for "."
- */
- if (idesc->id_entryno != 0)
- goto chk1;
- if (dirp->d_ino != 0 && strcmp(dirp->d_name, ".") == 0) {
- if (dirp->d_ino != idesc->id_number) {
- direrror(idesc->id_number, "BAD INODE NUMBER FOR '.'");
- dirp->d_ino = idesc->id_number;
- if (reply("FIX") == 1)
- ret |= ALTERED;
- }
- if (newinofmt && dirp->d_type != DT_DIR) {
- direrror(idesc->id_number, "BAD TYPE VALUE FOR '.'");
- dirp->d_type = DT_DIR;
- if (reply("FIX") == 1)
- ret |= ALTERED;
- }
- goto chk1;
- }
- direrror(idesc->id_number, "MISSING '.'");
- proto.d_ino = idesc->id_number;
- if (newinofmt)
- proto.d_type = DT_DIR;
- else
- proto.d_type = 0;
- proto.d_namlen = 1;
- (void)strcpy(proto.d_name, ".");
-# if BYTE_ORDER == LITTLE_ENDIAN
- if (!newinofmt) {
- u_char tmp;
-
- tmp = proto.d_type;
- proto.d_type = proto.d_namlen;
- proto.d_namlen = tmp;
- }
-# endif
- entrysize = DIRSIZ(0, &proto);
- if (dirp->d_ino != 0 && strcmp(dirp->d_name, "..") != 0) {
- pfatal("CANNOT FIX, FIRST ENTRY IN DIRECTORY CONTAINS %s\n",
- dirp->d_name);
- } else if (dirp->d_reclen < entrysize) {
- pfatal("CANNOT FIX, INSUFFICIENT SPACE TO ADD '.'\n");
- } else if (dirp->d_reclen < 2 * entrysize) {
- proto.d_reclen = dirp->d_reclen;
- memmove(dirp, &proto, (size_t)entrysize);
- if (reply("FIX") == 1)
- ret |= ALTERED;
- } else {
- n = dirp->d_reclen - entrysize;
- proto.d_reclen = entrysize;
- memmove(dirp, &proto, (size_t)entrysize);
- idesc->id_entryno++;
- inoinfo(dirp->d_ino)->ino_linkcnt--;
- dirp = (struct direct *)((char *)(dirp) + entrysize);
- memset(dirp, 0, (size_t)n);
- dirp->d_reclen = n;
- if (reply("FIX") == 1)
- ret |= ALTERED;
- }
-chk1:
- if (idesc->id_entryno > 1)
- goto chk2;
- inp = getinoinfo(idesc->id_number);
- proto.d_ino = inp->i_parent;
- if (newinofmt)
- proto.d_type = DT_DIR;
- else
- proto.d_type = 0;
- proto.d_namlen = 2;
- (void)strcpy(proto.d_name, "..");
-# if BYTE_ORDER == LITTLE_ENDIAN
- if (!newinofmt) {
- u_char tmp;
-
- tmp = proto.d_type;
- proto.d_type = proto.d_namlen;
- proto.d_namlen = tmp;
- }
-# endif
- entrysize = DIRSIZ(0, &proto);
- if (idesc->id_entryno == 0) {
- n = DIRSIZ(0, dirp);
- if (dirp->d_reclen < n + entrysize)
- goto chk2;
- proto.d_reclen = dirp->d_reclen - n;
- dirp->d_reclen = n;
- idesc->id_entryno++;
- inoinfo(dirp->d_ino)->ino_linkcnt--;
- dirp = (struct direct *)((char *)(dirp) + n);
- memset(dirp, 0, (size_t)proto.d_reclen);
- dirp->d_reclen = proto.d_reclen;
- }
- if (dirp->d_ino != 0 && strcmp(dirp->d_name, "..") == 0) {
- inp->i_dotdot = dirp->d_ino;
- if (newinofmt && dirp->d_type != DT_DIR) {
- direrror(idesc->id_number, "BAD TYPE VALUE FOR '..'");
- dirp->d_type = DT_DIR;
- if (reply("FIX") == 1)
- ret |= ALTERED;
- }
- goto chk2;
- }
- if (dirp->d_ino != 0 && strcmp(dirp->d_name, ".") != 0) {
- fileerror(inp->i_parent, idesc->id_number, "MISSING '..'");
- pfatal("CANNOT FIX, SECOND ENTRY IN DIRECTORY CONTAINS %s\n",
- dirp->d_name);
- inp->i_dotdot = (ino_t)-1;
- } else if (dirp->d_reclen < entrysize) {
- fileerror(inp->i_parent, idesc->id_number, "MISSING '..'");
- pfatal("CANNOT FIX, INSUFFICIENT SPACE TO ADD '..'\n");
- inp->i_dotdot = (ino_t)-1;
- } else if (inp->i_parent != 0) {
- /*
- * We know the parent, so fix now.
- */
- inp->i_dotdot = inp->i_parent;
- fileerror(inp->i_parent, idesc->id_number, "MISSING '..'");
- proto.d_reclen = dirp->d_reclen;
- memmove(dirp, &proto, (size_t)entrysize);
- if (reply("FIX") == 1)
- ret |= ALTERED;
- }
- idesc->id_entryno++;
- if (dirp->d_ino != 0)
- inoinfo(dirp->d_ino)->ino_linkcnt--;
- return (ret|KEEPON);
-chk2:
- if (dirp->d_ino == 0)
- return (ret|KEEPON);
- if (dirp->d_namlen <= 2 &&
- dirp->d_name[0] == '.' &&
- idesc->id_entryno >= 2) {
- if (dirp->d_namlen == 1) {
- direrror(idesc->id_number, "EXTRA '.' ENTRY");
- dirp->d_ino = 0;
- if (reply("FIX") == 1)
- ret |= ALTERED;
- return (KEEPON | ret);
- }
- if (dirp->d_name[1] == '.') {
- direrror(idesc->id_number, "EXTRA '..' ENTRY");
- dirp->d_ino = 0;
- if (reply("FIX") == 1)
- ret |= ALTERED;
- return (KEEPON | ret);
- }
- }
- idesc->id_entryno++;
- n = 0;
- if (dirp->d_ino > maxino) {
- fileerror(idesc->id_number, dirp->d_ino, "I OUT OF RANGE");
- n = reply("REMOVE");
- } else if (newinofmt &&
- ((dirp->d_ino == WINO && dirp->d_type != DT_WHT) ||
- (dirp->d_ino != WINO && dirp->d_type == DT_WHT))) {
- fileerror(idesc->id_number, dirp->d_ino, "BAD WHITEOUT ENTRY");
- dirp->d_ino = WINO;
- dirp->d_type = DT_WHT;
- if (reply("FIX") == 1)
- ret |= ALTERED;
- } else {
-again:
- switch (inoinfo(dirp->d_ino)->ino_state) {
- case USTATE:
- if (idesc->id_entryno <= 2)
- break;
- fileerror(idesc->id_number, dirp->d_ino, "UNALLOCATED");
- n = reply("REMOVE");
- break;
-
- case DCLEAR:
- case FCLEAR:
- if (idesc->id_entryno <= 2)
- break;
- if (inoinfo(dirp->d_ino)->ino_state == FCLEAR)
- errmsg = "DUP/BAD";
- else if (!preen && !usedsoftdep)
- errmsg = "ZERO LENGTH DIRECTORY";
- else {
- n = 1;
- break;
- }
- fileerror(idesc->id_number, dirp->d_ino, errmsg);
- if ((n = reply("REMOVE")) == 1)
- break;
- dp = ginode(dirp->d_ino);
- inoinfo(dirp->d_ino)->ino_state =
- (dp->di_mode & IFMT) == IFDIR ? DSTATE : FSTATE;
- inoinfo(dirp->d_ino)->ino_linkcnt = dp->di_nlink;
- goto again;
-
- case DSTATE:
- if (inoinfo(idesc->id_number)->ino_state == DFOUND)
- inoinfo(dirp->d_ino)->ino_state = DFOUND;
- /* fall through */
-
- case DFOUND:
- inp = getinoinfo(dirp->d_ino);
- if (inp->i_parent != 0 && idesc->id_entryno > 2) {
- getpathname(pathbuf, idesc->id_number,
- idesc->id_number);
- getpathname(namebuf, dirp->d_ino, dirp->d_ino);
- pwarn("%s %s %s\n", pathbuf,
- "IS AN EXTRANEOUS HARD LINK TO DIRECTORY",
- namebuf);
- if (preen) {
- printf(" (REMOVED)\n");
- n = 1;
- break;
- }
- if ((n = reply("REMOVE")) == 1)
- break;
- }
- if (idesc->id_entryno > 2)
- inp->i_parent = idesc->id_number;
- /* fall through */
-
- case FSTATE:
- if (newinofmt &&
- dirp->d_type != inoinfo(dirp->d_ino)->ino_type) {
- fileerror(idesc->id_number, dirp->d_ino,
- "BAD TYPE VALUE");
- dirp->d_type = inoinfo(dirp->d_ino)->ino_type;
- if (reply("FIX") == 1)
- ret |= ALTERED;
- }
- inoinfo(dirp->d_ino)->ino_linkcnt--;
- break;
-
- default:
- errx(EEXIT, "BAD STATE %d FOR INODE I=%d",
- inoinfo(dirp->d_ino)->ino_state, dirp->d_ino);
- }
- }
- if (n == 0)
- return (ret|KEEPON);
- dirp->d_ino = 0;
- return (ret|KEEPON|ALTERED);
-}
-
-/*
- * Routine to sort disk blocks.
- */
-static int
-blksort(arg1, arg2)
- const void *arg1, *arg2;
-{
-
- return ((*(struct inoinfo **)arg1)->i_blks[0] -
- (*(struct inoinfo **)arg2)->i_blks[0]);
-}
diff --git a/sbin/fsck_ffs/pass3.c b/sbin/fsck_ffs/pass3.c
deleted file mode 100644
index 80e38e9cbf4f..000000000000
--- a/sbin/fsck_ffs/pass3.c
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (c) 1980, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-#if 0
-static const char sccsid[] = "@(#)pass3.c 8.2 (Berkeley) 4/27/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <sys/param.h>
-
-#include <ufs/ufs/dinode.h>
-#include <ufs/ufs/dir.h>
-#include <ufs/ffs/fs.h>
-
-#include <string.h>
-
-#include "fsck.h"
-
-void
-pass3()
-{
- struct inoinfo *inp;
- int loopcnt, inpindex, state;
- ino_t orphan;
- struct inodesc idesc;
- char namebuf[MAXNAMLEN+1];
-
- for (inpindex = inplast - 1; inpindex >= 0; inpindex--) {
- inp = inpsort[inpindex];
- state = inoinfo(inp->i_number)->ino_state;
- if (inp->i_number == ROOTINO ||
- (inp->i_parent != 0 && state != DSTATE))
- continue;
- if (state == DCLEAR)
- continue;
- /*
- * If we are running with soft updates and we come
- * across unreferenced directories, we just leave
- * them in DSTATE which will cause them to be pitched
- * in pass 4.
- */
- if (preen && resolved && usedsoftdep && state == DSTATE) {
- if (inp->i_dotdot >= ROOTINO)
- inoinfo(inp->i_dotdot)->ino_linkcnt++;
- continue;
- }
- for (loopcnt = 0; ; loopcnt++) {
- orphan = inp->i_number;
- if (inp->i_parent == 0 ||
- inoinfo(inp->i_parent)->ino_state != DSTATE ||
- loopcnt > countdirs)
- break;
- inp = getinoinfo(inp->i_parent);
- }
- if (loopcnt <= countdirs) {
- if (linkup(orphan, inp->i_dotdot, NULL)) {
- inp->i_parent = inp->i_dotdot = lfdir;
- inoinfo(lfdir)->ino_linkcnt--;
- }
- inoinfo(orphan)->ino_state = DFOUND;
- propagate();
- continue;
- }
- pfatal("ORPHANED DIRECTORY LOOP DETECTED I=%lu", orphan);
- if (reply("RECONNECT") == 0)
- continue;
- memset(&idesc, 0, sizeof(struct inodesc));
- idesc.id_type = DATA;
- idesc.id_number = inp->i_parent;
- idesc.id_parent = orphan;
- idesc.id_func = findname;
- idesc.id_name = namebuf;
- if ((ckinode(ginode(inp->i_parent), &idesc) & FOUND) == 0)
- pfatal("COULD NOT FIND NAME IN PARENT DIRECTORY");
- if (linkup(orphan, inp->i_parent, namebuf)) {
- idesc.id_func = clearentry;
- if (ckinode(ginode(inp->i_parent), &idesc) & FOUND)
- inoinfo(orphan)->ino_linkcnt++;
- inp->i_parent = inp->i_dotdot = lfdir;
- inoinfo(lfdir)->ino_linkcnt--;
- }
- inoinfo(orphan)->ino_state = DFOUND;
- propagate();
- }
-}
diff --git a/sbin/fsck_ffs/pass4.c b/sbin/fsck_ffs/pass4.c
deleted file mode 100644
index 0012c50adc7e..000000000000
--- a/sbin/fsck_ffs/pass4.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright (c) 1980, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-#if 0
-static const char sccsid[] = "@(#)pass4.c 8.4 (Berkeley) 4/28/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <sys/param.h>
-
-#include <ufs/ufs/dinode.h>
-#include <ufs/ffs/fs.h>
-
-#include <err.h>
-#include <string.h>
-
-#include "fsck.h"
-
-void
-pass4()
-{
- register ino_t inumber;
- register struct zlncnt *zlnp;
- struct dinode *dp;
- struct inodesc idesc;
- int i, n, cg;
-
- memset(&idesc, 0, sizeof(struct inodesc));
- idesc.id_type = ADDR;
- idesc.id_func = pass4check;
- for (cg = 0; cg < sblock.fs_ncg; cg++) {
- inumber = cg * sblock.fs_ipg;
- for (i = 0; i < inostathead[cg].il_numalloced; i++, inumber++) {
- if (inumber < ROOTINO)
- continue;
- idesc.id_number = inumber;
- switch (inoinfo(inumber)->ino_state) {
-
- case FSTATE:
- case DFOUND:
- n = inoinfo(inumber)->ino_linkcnt;
- if (n) {
- adjust(&idesc, (short)n);
- break;
- }
- for (zlnp = zlnhead; zlnp; zlnp = zlnp->next) {
- if (zlnp->zlncnt == inumber) {
- zlnp->zlncnt = zlnhead->zlncnt;
- zlnp = zlnhead;
- zlnhead = zlnhead->next;
- free((char *)zlnp);
- clri(&idesc, "UNREF", 1);
- break;
- }
- }
- break;
-
- case DSTATE:
- clri(&idesc, "UNREF", 1);
- break;
-
- case DCLEAR:
- dp = ginode(inumber);
- if (dp->di_size == 0) {
- clri(&idesc, "ZERO LENGTH", 1);
- break;
- }
- /* fall through */
- case FCLEAR:
- clri(&idesc, "BAD/DUP", 1);
- break;
-
- case USTATE:
- break;
-
- default:
- errx(EEXIT, "BAD STATE %d FOR INODE I=%d",
- inoinfo(inumber)->ino_state, inumber);
- }
- }
- }
-}
-
-int
-pass4check(idesc)
- register struct inodesc *idesc;
-{
- register struct dups *dlp;
- int nfrags, res = KEEPON;
- ufs_daddr_t blkno = idesc->id_blkno;
-
- for (nfrags = idesc->id_numfrags; nfrags > 0; blkno++, nfrags--) {
- if (chkrange(blkno, 1)) {
- res = SKIP;
- } else if (testbmap(blkno)) {
- for (dlp = duplist; dlp; dlp = dlp->next) {
- if (dlp->dup != blkno)
- continue;
- dlp->dup = duplist->dup;
- dlp = duplist;
- duplist = duplist->next;
- free((char *)dlp);
- break;
- }
- if (dlp == 0) {
- clrbmap(blkno);
- n_blks--;
- }
- }
- }
- return (res);
-}
diff --git a/sbin/fsck_ffs/pass5.c b/sbin/fsck_ffs/pass5.c
deleted file mode 100644
index d5edaace1690..000000000000
--- a/sbin/fsck_ffs/pass5.c
+++ /dev/null
@@ -1,361 +0,0 @@
-/*
- * Copyright (c) 1980, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-#if 0
-static const char sccsid[] = "@(#)pass5.c 8.9 (Berkeley) 4/28/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <sys/param.h>
-
-#include <ufs/ufs/dinode.h>
-#include <ufs/ffs/fs.h>
-
-#include <err.h>
-#include <string.h>
-
-#include "fsck.h"
-
-void
-pass5()
-{
- int c, blk, frags, basesize, sumsize, mapsize, savednrpos = 0;
- int inomapsize, blkmapsize;
- struct fs *fs = &sblock;
- struct cg *cg = &cgrp;
- ufs_daddr_t dbase, dmax;
- ufs_daddr_t d;
- long i, j, k;
- struct csum *cs;
- struct csum cstotal;
- struct inodesc idesc[3];
- char buf[MAXBSIZE];
- register struct cg *newcg = (struct cg *)buf;
- struct ocg *ocg = (struct ocg *)buf;
-
- inoinfo(WINO)->ino_state = USTATE;
- memset(newcg, 0, (size_t)fs->fs_cgsize);
- newcg->cg_niblk = fs->fs_ipg;
- if (cvtlevel >= 3) {
- if (fs->fs_maxcontig < 2 && fs->fs_contigsumsize > 0) {
- if (preen)
- pwarn("DELETING CLUSTERING MAPS\n");
- if (preen || reply("DELETE CLUSTERING MAPS")) {
- fs->fs_contigsumsize = 0;
- doinglevel1 = 1;
- sbdirty();
- }
- }
- if (fs->fs_maxcontig > 1) {
- char *doit = 0;
-
- if (fs->fs_contigsumsize < 1) {
- doit = "CREAT";
- } else if (fs->fs_contigsumsize < fs->fs_maxcontig &&
- fs->fs_contigsumsize < FS_MAXCONTIG) {
- doit = "EXPAND";
- }
- if (doit) {
- i = fs->fs_contigsumsize;
- fs->fs_contigsumsize =
- MIN(fs->fs_maxcontig, FS_MAXCONTIG);
- if (CGSIZE(fs) > fs->fs_bsize) {
- pwarn("CANNOT %s CLUSTER MAPS\n", doit);
- fs->fs_contigsumsize = i;
- } else if (preen ||
- reply("CREATE CLUSTER MAPS")) {
- if (preen)
- pwarn("%sING CLUSTER MAPS\n",
- doit);
- fs->fs_cgsize =
- fragroundup(fs, CGSIZE(fs));
- doinglevel1 = 1;
- sbdirty();
- }
- }
- }
- }
- switch ((int)fs->fs_postblformat) {
-
- case FS_42POSTBLFMT:
- basesize = (char *)(&ocg->cg_btot[0]) -
- (char *)(&ocg->cg_firstfield);
- sumsize = &ocg->cg_iused[0] - (u_int8_t *)(&ocg->cg_btot[0]);
- mapsize = &ocg->cg_free[howmany(fs->fs_fpg, NBBY)] -
- (u_char *)&ocg->cg_iused[0];
- blkmapsize = howmany(fs->fs_fpg, NBBY);
- inomapsize = &ocg->cg_free[0] - (u_char *)&ocg->cg_iused[0];
- ocg->cg_magic = CG_MAGIC;
- savednrpos = fs->fs_nrpos;
- fs->fs_nrpos = 8;
- break;
-
- case FS_DYNAMICPOSTBLFMT:
- newcg->cg_btotoff =
- &newcg->cg_space[0] - (u_char *)(&newcg->cg_firstfield);
- newcg->cg_boff =
- newcg->cg_btotoff + fs->fs_cpg * sizeof(int32_t);
- newcg->cg_iusedoff = newcg->cg_boff +
- fs->fs_cpg * fs->fs_nrpos * sizeof(u_int16_t);
- newcg->cg_freeoff =
- newcg->cg_iusedoff + howmany(fs->fs_ipg, NBBY);
- inomapsize = newcg->cg_freeoff - newcg->cg_iusedoff;
- newcg->cg_nextfreeoff = newcg->cg_freeoff +
- howmany(fs->fs_cpg * fs->fs_spc / NSPF(fs), NBBY);
- blkmapsize = newcg->cg_nextfreeoff - newcg->cg_freeoff;
- if (fs->fs_contigsumsize > 0) {
- newcg->cg_clustersumoff = newcg->cg_nextfreeoff -
- sizeof(u_int32_t);
- newcg->cg_clustersumoff =
- roundup(newcg->cg_clustersumoff, sizeof(u_int32_t));
- newcg->cg_clusteroff = newcg->cg_clustersumoff +
- (fs->fs_contigsumsize + 1) * sizeof(u_int32_t);
- newcg->cg_nextfreeoff = newcg->cg_clusteroff +
- howmany(fs->fs_cpg * fs->fs_spc / NSPB(fs), NBBY);
- }
- newcg->cg_magic = CG_MAGIC;
- basesize = &newcg->cg_space[0] -
- (u_char *)(&newcg->cg_firstfield);
- sumsize = newcg->cg_iusedoff - newcg->cg_btotoff;
- mapsize = newcg->cg_nextfreeoff - newcg->cg_iusedoff;
- break;
-
- default:
- inomapsize = blkmapsize = sumsize = 0; /* keep lint happy */
- errx(EEXIT, "UNKNOWN ROTATIONAL TABLE FORMAT %d",
- fs->fs_postblformat);
- }
- memset(&idesc[0], 0, sizeof idesc);
- for (i = 0; i < 3; i++) {
- idesc[i].id_type = ADDR;
- if (doinglevel2)
- idesc[i].id_fix = FIX;
- }
- memset(&cstotal, 0, sizeof(struct csum));
- j = blknum(fs, fs->fs_size + fs->fs_frag - 1);
- for (i = fs->fs_size; i < j; i++)
- setbmap(i);
- for (c = 0; c < fs->fs_ncg; c++) {
- getblk(&cgblk, cgtod(fs, c), fs->fs_cgsize);
- if (!cg_chkmagic(cg))
- pfatal("CG %d: BAD MAGIC NUMBER\n", c);
- dbase = cgbase(fs, c);
- dmax = dbase + fs->fs_fpg;
- if (dmax > fs->fs_size)
- dmax = fs->fs_size;
- newcg->cg_time = cg->cg_time;
- newcg->cg_cgx = c;
- if (c == fs->fs_ncg - 1)
- newcg->cg_ncyl = fs->fs_ncyl % fs->fs_cpg;
- else
- newcg->cg_ncyl = fs->fs_cpg;
- newcg->cg_ndblk = dmax - dbase;
- if (fs->fs_contigsumsize > 0)
- newcg->cg_nclusterblks = newcg->cg_ndblk / fs->fs_frag;
- newcg->cg_cs.cs_ndir = 0;
- newcg->cg_cs.cs_nffree = 0;
- newcg->cg_cs.cs_nbfree = 0;
- newcg->cg_cs.cs_nifree = fs->fs_ipg;
- if (cg->cg_rotor < newcg->cg_ndblk)
- newcg->cg_rotor = cg->cg_rotor;
- else
- newcg->cg_rotor = 0;
- if (cg->cg_frotor < newcg->cg_ndblk)
- newcg->cg_frotor = cg->cg_frotor;
- else
- newcg->cg_frotor = 0;
- if (cg->cg_irotor < newcg->cg_niblk)
- newcg->cg_irotor = cg->cg_irotor;
- else
- newcg->cg_irotor = 0;
- memset(&newcg->cg_frsum[0], 0, sizeof newcg->cg_frsum);
- memset(&cg_blktot(newcg)[0], 0,
- (size_t)(sumsize + mapsize));
- if (fs->fs_postblformat == FS_42POSTBLFMT)
- ocg->cg_magic = CG_MAGIC;
- j = fs->fs_ipg * c;
- for (i = 0; i < inostathead[c].il_numalloced; j++, i++) {
- switch (inoinfo(j)->ino_state) {
-
- case USTATE:
- break;
-
- case DSTATE:
- case DCLEAR:
- case DFOUND:
- newcg->cg_cs.cs_ndir++;
- /* fall through */
-
- case FSTATE:
- case FCLEAR:
- newcg->cg_cs.cs_nifree--;
- setbit(cg_inosused(newcg), i);
- break;
-
- default:
- if (j < ROOTINO)
- break;
- errx(EEXIT, "BAD STATE %d FOR INODE I=%ld",
- inoinfo(j)->ino_state, j);
- }
- }
- if (c == 0)
- for (i = 0; i < ROOTINO; i++) {
- setbit(cg_inosused(newcg), i);
- newcg->cg_cs.cs_nifree--;
- }
- for (i = 0, d = dbase;
- d < dmax;
- d += fs->fs_frag, i += fs->fs_frag) {
- frags = 0;
- for (j = 0; j < fs->fs_frag; j++) {
- if (testbmap(d + j))
- continue;
- setbit(cg_blksfree(newcg), i + j);
- frags++;
- }
- if (frags == fs->fs_frag) {
- newcg->cg_cs.cs_nbfree++;
- j = cbtocylno(fs, i);
- cg_blktot(newcg)[j]++;
- cg_blks(fs, newcg, j)[cbtorpos(fs, i)]++;
- if (fs->fs_contigsumsize > 0)
- setbit(cg_clustersfree(newcg),
- i / fs->fs_frag);
- } else if (frags > 0) {
- newcg->cg_cs.cs_nffree += frags;
- blk = blkmap(fs, cg_blksfree(newcg), i);
- ffs_fragacct(fs, blk, newcg->cg_frsum, 1);
- }
- }
- if (fs->fs_contigsumsize > 0) {
- int32_t *sump = cg_clustersum(newcg);
- u_char *mapp = cg_clustersfree(newcg);
- int map = *mapp++;
- int bit = 1;
- int run = 0;
-
- for (i = 0; i < newcg->cg_nclusterblks; i++) {
- if ((map & bit) != 0) {
- run++;
- } else if (run != 0) {
- if (run > fs->fs_contigsumsize)
- run = fs->fs_contigsumsize;
- sump[run]++;
- run = 0;
- }
- if ((i & (NBBY - 1)) != (NBBY - 1)) {
- bit <<= 1;
- } else {
- map = *mapp++;
- bit = 1;
- }
- }
- if (run != 0) {
- if (run > fs->fs_contigsumsize)
- run = fs->fs_contigsumsize;
- sump[run]++;
- }
- }
- cstotal.cs_nffree += newcg->cg_cs.cs_nffree;
- cstotal.cs_nbfree += newcg->cg_cs.cs_nbfree;
- cstotal.cs_nifree += newcg->cg_cs.cs_nifree;
- cstotal.cs_ndir += newcg->cg_cs.cs_ndir;
- cs = &fs->fs_cs(fs, c);
- if (memcmp(&newcg->cg_cs, cs, sizeof *cs) != 0 &&
- dofix(&idesc[0], "FREE BLK COUNT(S) WRONG IN SUPERBLK")) {
- memmove(cs, &newcg->cg_cs, sizeof *cs);
- sbdirty();
- }
- if (doinglevel1) {
- memmove(cg, newcg, (size_t)fs->fs_cgsize);
- cgdirty();
- continue;
- }
- if ((memcmp(newcg, cg, basesize) != 0 ||
- memcmp(&cg_blktot(newcg)[0],
- &cg_blktot(cg)[0], sumsize) != 0) &&
- dofix(&idesc[2], "SUMMARY INFORMATION BAD")) {
- memmove(cg, newcg, (size_t)basesize);
- memmove(&cg_blktot(cg)[0],
- &cg_blktot(newcg)[0], (size_t)sumsize);
- cgdirty();
- }
- if (usedsoftdep) {
- for (i = 0; i < inomapsize; i++) {
- j = cg_inosused(newcg)[i];
- if ((cg_inosused(cg)[i] & j) == j)
- continue;
- for (k = 0; k < NBBY; k++) {
- if ((j & (1 << k)) == 0)
- continue;
- if (cg_inosused(cg)[i] & (1 << k))
- continue;
- pwarn("ALLOCATED INODE %d MARKED FREE\n",
- c * fs->fs_ipg + i * NBBY + k);
- }
- }
- for (i = 0; i < blkmapsize; i++) {
- j = cg_blksfree(cg)[i];
- if ((cg_blksfree(newcg)[i] & j) == j)
- continue;
- for (k = 0; k < NBBY; k++) {
- if ((j & (1 << k)) == 0)
- continue;
- if (cg_blksfree(newcg)[i] & (1 << k))
- continue;
- pwarn("ALLOCATED FRAG %d MARKED FREE\n",
- c * fs->fs_fpg + i * NBBY + k);
- }
- }
- }
- if (memcmp(cg_inosused(newcg), cg_inosused(cg), mapsize) != 0 &&
- dofix(&idesc[1], "BLK(S) MISSING IN BIT MAPS")) {
- memmove(cg_inosused(cg), cg_inosused(newcg),
- (size_t)mapsize);
- cgdirty();
- }
- }
- if (fs->fs_postblformat == FS_42POSTBLFMT)
- fs->fs_nrpos = savednrpos;
- if (memcmp(&cstotal, &fs->fs_cstotal, sizeof *cs) != 0
- && dofix(&idesc[0], "FREE BLK COUNT(S) WRONG IN SUPERBLK")) {
- memmove(&fs->fs_cstotal, &cstotal, sizeof *cs);
- fs->fs_ronly = 0;
- fs->fs_fmod = 0;
- sbdirty();
- }
-}
diff --git a/sbin/fsck_ffs/preen.c b/sbin/fsck_ffs/preen.c
deleted file mode 100644
index e43aada8d10d..000000000000
--- a/sbin/fsck_ffs/preen.c
+++ /dev/null
@@ -1,332 +0,0 @@
-/*
- * 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-#if 0
-static const char sccsid[] = "@(#)preen.c 8.5 (Berkeley) 4/28/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-
-#include <ufs/ufs/dinode.h>
-
-#include <ctype.h>
-#include <errno.h>
-#include <fstab.h>
-#include <string.h>
-
-#include "fsck.h"
-
-struct part {
- struct part *next; /* forward link of partitions on disk */
- char *name; /* device name */
- char *fsname; /* mounted filesystem name */
- long auxdata; /* auxillary data for application */
-} *badlist, **badnext = &badlist;
-
-struct disk {
- char *name; /* disk base name */
- struct disk *next; /* forward link for list of disks */
- struct part *part; /* head of list of partitions on disk */
- int pid; /* If != 0, pid of proc working on */
-} *disks;
-
-int nrun, ndisks;
-
-static void addpart __P((char *name, char *fsname, long auxdata));
-static struct disk *finddisk __P((char *name));
-static int startdisk __P((struct disk *dk,
- int (*checkit)(char *, char *, long, int)));
-
-int
-checkfstab(preen, maxrun, docheck, chkit)
- int preen;
- int maxrun;
- int (*docheck)(struct fstab *);
- int (*chkit)(char *, char *, long, int);
-{
- register struct fstab *fsp;
- register struct disk *dk, *nextdisk;
- register struct part *pt;
- int ret, pid, retcode, passno, sumstatus, status;
- long auxdata;
- char *name;
-
- sumstatus = 0;
- for (passno = 1; passno <= 2; passno++) {
- if (setfsent() == 0) {
- fprintf(stderr, "Can't open checklist file: %s\n",
- _PATH_FSTAB);
- return (8);
- }
- while ((fsp = getfsent()) != 0) {
- if ((auxdata = (*docheck)(fsp)) == 0)
- continue;
- if (preen == 0 ||
- (passno == 1 && fsp->fs_passno == 1)) {
- if ((name = blockcheck(fsp->fs_spec)) != 0) {
- if ((sumstatus = (*chkit)(name,
- fsp->fs_file, auxdata, 0)) != 0)
- return (sumstatus);
- } else if (preen)
- return (8);
- } else if (passno == 2 && fsp->fs_passno > 1) {
- if ((name = blockcheck(fsp->fs_spec)) == NULL) {
- fprintf(stderr, "BAD DISK NAME %s\n",
- fsp->fs_spec);
- sumstatus |= 8;
- continue;
- }
- addpart(name, fsp->fs_file, auxdata);
- }
- }
- if (preen == 0)
- return (0);
- }
- if (preen) {
- if (maxrun == 0)
- maxrun = ndisks;
- if (maxrun > ndisks)
- maxrun = ndisks;
- nextdisk = disks;
- for (passno = 0; passno < maxrun; ++passno) {
- while ((ret = startdisk(nextdisk, chkit)) && nrun > 0)
- sleep(10);
- if (ret)
- return (ret);
- nextdisk = nextdisk->next;
- }
- while ((pid = wait(&status)) != -1) {
- for (dk = disks; dk; dk = dk->next)
- if (dk->pid == pid)
- break;
- if (dk == 0) {
- printf("Unknown pid %d\n", pid);
- continue;
- }
- if (WIFEXITED(status))
- retcode = WEXITSTATUS(status);
- else
- retcode = 0;
- if (WIFSIGNALED(status)) {
- printf("%s (%s): EXITED WITH SIGNAL %d\n",
- dk->part->name, dk->part->fsname,
- WTERMSIG(status));
- retcode = 8;
- }
- if (retcode != 0) {
- sumstatus |= retcode;
- *badnext = dk->part;
- badnext = &dk->part->next;
- dk->part = dk->part->next;
- *badnext = NULL;
- } else
- dk->part = dk->part->next;
- dk->pid = 0;
- nrun--;
- if (dk->part == NULL)
- ndisks--;
-
- if (nextdisk == NULL) {
- if (dk->part) {
- while ((ret = startdisk(dk, chkit)) &&
- nrun > 0)
- sleep(10);
- if (ret)
- return (ret);
- }
- } else if (nrun < maxrun && nrun < ndisks) {
- for ( ;; ) {
- if ((nextdisk = nextdisk->next) == NULL)
- nextdisk = disks;
- if (nextdisk->part != NULL &&
- nextdisk->pid == 0)
- break;
- }
- while ((ret = startdisk(nextdisk, chkit)) &&
- nrun > 0)
- sleep(10);
- if (ret)
- return (ret);
- }
- }
- }
- if (sumstatus) {
- if (badlist == 0)
- return (sumstatus);
- fprintf(stderr, "THE FOLLOWING FILE SYSTEM%s HAD AN %s\n\t",
- badlist->next ? "S" : "", "UNEXPECTED INCONSISTENCY:");
- for (pt = badlist; pt; pt = pt->next)
- fprintf(stderr, "%s (%s)%s", pt->name, pt->fsname,
- pt->next ? ", " : "\n");
- return (sumstatus);
- }
- (void)endfsent();
- return (0);
-}
-
-static struct disk *
-finddisk(name)
- char *name;
-{
- register struct disk *dk, **dkp;
- register char *p;
- size_t len;
-
- p = strrchr(name, '/');
- p = p == NULL ? name : p + 1;
- while (*p != '\0' && !isdigit((u_char)*p))
- p++;
- while (isdigit((u_char)*p))
- p++;
- len = (size_t)(p - name);
- for (dk = disks, dkp = &disks; dk; dkp = &dk->next, dk = dk->next) {
- if (strncmp(dk->name, name, len) == 0 &&
- dk->name[len] == 0)
- return (dk);
- }
- if ((*dkp = (struct disk *)malloc(sizeof(struct disk))) == NULL) {
- fprintf(stderr, "out of memory");
- exit (8);
- }
- dk = *dkp;
- if ((dk->name = malloc(len + 1)) == NULL) {
- fprintf(stderr, "out of memory");
- exit (8);
- }
- (void)strncpy(dk->name, name, len);
- dk->name[len] = '\0';
- dk->part = NULL;
- dk->next = NULL;
- dk->pid = 0;
- ndisks++;
- return (dk);
-}
-
-static void
-addpart(name, fsname, auxdata)
- char *name, *fsname;
- long auxdata;
-{
- struct disk *dk = finddisk(name);
- register struct part *pt, **ppt = &dk->part;
-
- for (pt = dk->part; pt; ppt = &pt->next, pt = pt->next)
- if (strcmp(pt->name, name) == 0) {
- printf("%s in fstab more than once!\n", name);
- return;
- }
- if ((*ppt = (struct part *)malloc(sizeof(struct part))) == NULL) {
- fprintf(stderr, "out of memory");
- exit (8);
- }
- pt = *ppt;
- if ((pt->name = malloc(strlen(name) + 1)) == NULL) {
- fprintf(stderr, "out of memory");
- exit (8);
- }
- (void)strcpy(pt->name, name);
- if ((pt->fsname = malloc(strlen(fsname) + 1)) == NULL) {
- fprintf(stderr, "out of memory");
- exit (8);
- }
- (void)strcpy(pt->fsname, fsname);
- pt->next = NULL;
- pt->auxdata = auxdata;
-}
-
-static int
-startdisk(dk, checkit)
- register struct disk *dk;
- int (*checkit)(char *, char *, long, int);
-{
- register struct part *pt = dk->part;
-
- dk->pid = fork();
- if (dk->pid < 0) {
- perror("fork");
- return (8);
- }
- if (dk->pid == 0)
- exit((*checkit)(pt->name, pt->fsname, pt->auxdata, 1));
- nrun++;
- return (0);
-}
-
-char *
-blockcheck(origname)
- char *origname;
-{
- struct stat stslash, stblock, stchar;
- char *newname, *raw;
- struct fstab *fsinfo;
- int retried = 0, len;
-
- newname = origname;
-retry:
- if (stat(newname, &stblock) < 0) {
- printf("Can't stat %s: %s\n", newname, strerror(errno));
- return (origname);
- }
- switch(stblock.st_mode & S_IFMT) {
- case S_IFCHR:
- case S_IFBLK:
- return(newname);
- case S_IFDIR:
- if (retried)
- break;
-
- len = strlen(origname) - 1;
- if (len > 0 && origname[len] == '/')
- /* remove trailing slash */
- origname[len] = '\0';
- if ((fsinfo = getfsfile(origname)) == NULL) {
- printf("Can't resolve %s to character special device",
- origname);
- return (0);
- }
- newname = fsinfo->fs_spec;
- retried++;
- goto retry;
- }
- /*
- * Not a block or character device, just return name and
- * let the user decide whether to use it.
- */
- return (origname);
-}
diff --git a/sbin/fsck_ffs/setup.c b/sbin/fsck_ffs/setup.c
deleted file mode 100644
index 49bbc8d99883..000000000000
--- a/sbin/fsck_ffs/setup.c
+++ /dev/null
@@ -1,513 +0,0 @@
-/*
- * Copyright (c) 1980, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-#if 0
-static const char sccsid[] = "@(#)setup.c 8.10 (Berkeley) 5/9/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#define DKTYPENAMES
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <sys/disklabel.h>
-#include <sys/file.h>
-
-#include <ufs/ufs/dinode.h>
-#include <ufs/ffs/fs.h>
-
-#include <ctype.h>
-#include <err.h>
-#include <errno.h>
-#include <string.h>
-
-#include "fsck.h"
-
-struct bufarea asblk;
-#define altsblock (*asblk.b_un.b_fs)
-#define POWEROF2(num) (((num) & ((num) - 1)) == 0)
-
-static void badsb __P((int listerr, char *s));
-static int calcsb __P((char *dev, int devfd, struct fs *fs));
-static struct disklabel *getdisklabel __P((char *s, int fd));
-static int readsb __P((int listerr));
-
-/*
- * Read in a superblock finding an alternate if necessary.
- * Return 1 if successful, 0 if unsuccessful, -1 if filesystem
- * is already clean (preen mode only).
- */
-int
-setup(dev)
- char *dev;
-{
- long cg, size, asked, i, j;
- long skipclean, bmapsize;
- struct disklabel *lp;
- off_t sizepb;
- struct stat statb;
- struct fs proto;
-
- havesb = 0;
- fswritefd = -1;
- skipclean = fflag ? 0 : preen;
- if (stat(dev, &statb) < 0) {
- printf("Can't stat %s: %s\n", dev, strerror(errno));
- return (0);
- }
- if ((statb.st_mode & S_IFMT) != S_IFCHR &&
- (statb.st_mode & S_IFMT) != S_IFBLK) {
- pfatal("%s is not a disk device", dev);
- if (reply("CONTINUE") == 0)
- return (0);
- }
- if ((fsreadfd = open(dev, O_RDONLY)) < 0) {
- printf("Can't open %s: %s\n", dev, strerror(errno));
- return (0);
- }
- if (preen == 0)
- printf("** %s", dev);
- if (nflag || (fswritefd = open(dev, O_WRONLY)) < 0) {
- fswritefd = -1;
- if (preen)
- pfatal("NO WRITE ACCESS");
- printf(" (NO WRITE)");
- }
- if (preen == 0)
- printf("\n");
- fsmodified = 0;
- lfdir = 0;
- initbarea(&sblk);
- initbarea(&asblk);
- sblk.b_un.b_buf = malloc(SBSIZE);
- asblk.b_un.b_buf = malloc(SBSIZE);
- if (sblk.b_un.b_buf == NULL || asblk.b_un.b_buf == NULL)
- errx(EEXIT, "cannot allocate space for superblock");
- if ((lp = getdisklabel(NULL, fsreadfd)))
- dev_bsize = secsize = lp->d_secsize;
- else
- dev_bsize = secsize = DEV_BSIZE;
- /*
- * Read in the superblock, looking for alternates if necessary
- */
- if (readsb(1) == 0) {
- skipclean = 0;
- if (bflag || preen || calcsb(dev, fsreadfd, &proto) == 0)
- return(0);
- if (reply("LOOK FOR ALTERNATE SUPERBLOCKS") == 0)
- return (0);
- for (cg = 0; cg < proto.fs_ncg; cg++) {
- bflag = fsbtodb(&proto, cgsblock(&proto, cg));
- if (readsb(0) != 0)
- break;
- }
- if (cg >= proto.fs_ncg) {
- printf("%s %s\n%s %s\n%s %s\n",
- "SEARCH FOR ALTERNATE SUPER-BLOCK",
- "FAILED. YOU MUST USE THE",
- "-b OPTION TO FSCK TO SPECIFY THE",
- "LOCATION OF AN ALTERNATE",
- "SUPER-BLOCK TO SUPPLY NEEDED",
- "INFORMATION; SEE fsck(8).");
- bflag = 0;
- return(0);
- }
- pwarn("USING ALTERNATE SUPERBLOCK AT %d\n", bflag);
- bflag = 0;
- }
- if (skipclean && sblock.fs_clean) {
- pwarn("FILESYSTEM CLEAN; SKIPPING CHECKS\n");
- return (-1);
- }
- maxfsblock = sblock.fs_size;
- maxino = sblock.fs_ncg * sblock.fs_ipg;
- /*
- * Check and potentially fix certain fields in the super block.
- */
- if (sblock.fs_optim != FS_OPTTIME && sblock.fs_optim != FS_OPTSPACE) {
- pfatal("UNDEFINED OPTIMIZATION IN SUPERBLOCK");
- if (reply("SET TO DEFAULT") == 1) {
- sblock.fs_optim = FS_OPTTIME;
- sbdirty();
- }
- }
- if ((sblock.fs_minfree < 0 || sblock.fs_minfree > 99)) {
- pfatal("IMPOSSIBLE MINFREE=%d IN SUPERBLOCK",
- sblock.fs_minfree);
- if (reply("SET TO DEFAULT") == 1) {
- sblock.fs_minfree = 10;
- sbdirty();
- }
- }
- if (sblock.fs_interleave < 1 ||
- sblock.fs_interleave > sblock.fs_nsect) {
- pwarn("IMPOSSIBLE INTERLEAVE=%d IN SUPERBLOCK",
- sblock.fs_interleave);
- sblock.fs_interleave = 1;
- if (preen)
- printf(" (FIXED)\n");
- if (preen || reply("SET TO DEFAULT") == 1) {
- sbdirty();
- dirty(&asblk);
- }
- }
- if (sblock.fs_npsect < sblock.fs_nsect ||
- sblock.fs_npsect > sblock.fs_nsect*2) {
- pwarn("IMPOSSIBLE NPSECT=%d IN SUPERBLOCK",
- sblock.fs_npsect);
- sblock.fs_npsect = sblock.fs_nsect;
- if (preen)
- printf(" (FIXED)\n");
- if (preen || reply("SET TO DEFAULT") == 1) {
- sbdirty();
- dirty(&asblk);
- }
- }
- if (sblock.fs_inodefmt >= FS_44INODEFMT) {
- newinofmt = 1;
- } else {
- sblock.fs_qbmask = ~sblock.fs_bmask;
- sblock.fs_qfmask = ~sblock.fs_fmask;
- newinofmt = 0;
- }
- /*
- * Convert to new inode format.
- */
- if (cvtlevel >= 2 && sblock.fs_inodefmt < FS_44INODEFMT) {
- if (preen)
- pwarn("CONVERTING TO NEW INODE FORMAT\n");
- else if (!reply("CONVERT TO NEW INODE FORMAT"))
- return(0);
- doinglevel2++;
- sblock.fs_inodefmt = FS_44INODEFMT;
- sizepb = sblock.fs_bsize;
- sblock.fs_maxfilesize = sblock.fs_bsize * NDADDR - 1;
- for (i = 0; i < NIADDR; i++) {
- sizepb *= NINDIR(&sblock);
- sblock.fs_maxfilesize += sizepb;
- }
- sblock.fs_maxsymlinklen = MAXSYMLINKLEN;
- sblock.fs_qbmask = ~sblock.fs_bmask;
- sblock.fs_qfmask = ~sblock.fs_fmask;
- sbdirty();
- dirty(&asblk);
- }
- /*
- * Convert to new cylinder group format.
- */
- if (cvtlevel >= 1 && sblock.fs_postblformat == FS_42POSTBLFMT) {
- if (preen)
- pwarn("CONVERTING TO NEW CYLINDER GROUP FORMAT\n");
- else if (!reply("CONVERT TO NEW CYLINDER GROUP FORMAT"))
- return(0);
- doinglevel1++;
- sblock.fs_postblformat = FS_DYNAMICPOSTBLFMT;
- sblock.fs_nrpos = 8;
- sblock.fs_postbloff =
- (char *)(&sblock.fs_opostbl[0][0]) -
- (char *)(&sblock.fs_firstfield);
- sblock.fs_rotbloff = &sblock.fs_space[0] -
- (u_char *)(&sblock.fs_firstfield);
- sblock.fs_cgsize =
- fragroundup(&sblock, CGSIZE(&sblock));
- sbdirty();
- dirty(&asblk);
- }
- if (asblk.b_dirty && !bflag) {
- memmove(&altsblock, &sblock, (size_t)sblock.fs_sbsize);
- flush(fswritefd, &asblk);
- }
- /*
- * read in the summary info.
- */
- asked = 0;
- for (i = 0, j = 0; i < sblock.fs_cssize; i += sblock.fs_bsize, j++) {
- size = sblock.fs_cssize - i < sblock.fs_bsize ?
- sblock.fs_cssize - i : sblock.fs_bsize;
- sblock.fs_csp[j] = (struct csum *)calloc(1, (unsigned)size);
- if (bread(fsreadfd, (char *)sblock.fs_csp[j],
- fsbtodb(&sblock, sblock.fs_csaddr + j * sblock.fs_frag),
- size) != 0 && !asked) {
- pfatal("BAD SUMMARY INFORMATION");
- if (reply("CONTINUE") == 0) {
- ckfini(0);
- exit(EEXIT);
- }
- asked++;
- }
- }
- /*
- * allocate and initialize the necessary maps
- */
- bmapsize = roundup(howmany(maxfsblock, NBBY), sizeof(short));
- blockmap = calloc((unsigned)bmapsize, sizeof (char));
- if (blockmap == NULL) {
- printf("cannot alloc %u bytes for blockmap\n",
- (unsigned)bmapsize);
- goto badsb;
- }
- inostathead = calloc((unsigned)(sblock.fs_ncg),
- sizeof(struct inostatlist));
- if (inostathead == NULL) {
- printf("cannot alloc %u bytes for inostathead\n",
- (unsigned)(sizeof(struct inostatlist) * (sblock.fs_ncg)));
- goto badsb;
- }
- numdirs = sblock.fs_cstotal.cs_ndir;
- dirhash = numdirs;
- if (numdirs == 0) {
- printf("numdirs is zero, try using an alternate superblock\n");
- goto badsb;
- }
- inplast = 0;
- listmax = numdirs + 10;
- inpsort = (struct inoinfo **)calloc((unsigned)listmax,
- sizeof(struct inoinfo *));
- inphead = (struct inoinfo **)calloc((unsigned)numdirs,
- sizeof(struct inoinfo *));
- if (inpsort == NULL || inphead == NULL) {
- printf("cannot alloc %u bytes for inphead\n",
- (unsigned)numdirs * sizeof(struct inoinfo *));
- goto badsb;
- }
- bufinit();
- if (sblock.fs_flags & FS_DOSOFTDEP)
- usedsoftdep = 1;
- else
- usedsoftdep = 0;
- return (1);
-
-badsb:
- ckfini(0);
- return (0);
-}
-
-/*
- * Read in the super block and its summary info.
- */
-static int
-readsb(listerr)
- int listerr;
-{
- ufs_daddr_t super = bflag ? bflag : SBOFF / dev_bsize;
-
- if (bread(fsreadfd, (char *)&sblock, super, (long)SBSIZE) != 0)
- return (0);
- sblk.b_bno = super;
- sblk.b_size = SBSIZE;
- /*
- * run a few consistency checks of the super block
- */
- if (sblock.fs_magic != FS_MAGIC)
- { badsb(listerr, "MAGIC NUMBER WRONG"); return (0); }
- if (sblock.fs_ncg < 1)
- { badsb(listerr, "NCG OUT OF RANGE"); return (0); }
- if (sblock.fs_cpg < 1)
- { badsb(listerr, "CPG OUT OF RANGE"); return (0); }
- if (sblock.fs_ncg * sblock.fs_cpg < sblock.fs_ncyl ||
- (sblock.fs_ncg - 1) * sblock.fs_cpg >= sblock.fs_ncyl)
- { badsb(listerr, "NCYL LESS THAN NCG*CPG"); return (0); }
- if (sblock.fs_sbsize > SBSIZE)
- { badsb(listerr, "SIZE PREPOSTEROUSLY LARGE"); return (0); }
- /*
- * Compute block size that the filesystem is based on,
- * according to fsbtodb, and adjust superblock block number
- * so we can tell if this is an alternate later.
- */
- super *= dev_bsize;
- dev_bsize = sblock.fs_fsize / fsbtodb(&sblock, 1);
- sblk.b_bno = super / dev_bsize;
- if (bflag) {
- havesb = 1;
- return (1);
- }
- /*
- * Set all possible fields that could differ, then do check
- * of whole super block against an alternate super block.
- * When an alternate super-block is specified this check is skipped.
- */
- getblk(&asblk, cgsblock(&sblock, sblock.fs_ncg - 1), sblock.fs_sbsize);
- if (asblk.b_errs)
- return (0);
- altsblock.fs_firstfield = sblock.fs_firstfield;
- altsblock.fs_unused_1 = sblock.fs_unused_1;
- altsblock.fs_time = sblock.fs_time;
- altsblock.fs_cstotal = sblock.fs_cstotal;
- altsblock.fs_cgrotor = sblock.fs_cgrotor;
- altsblock.fs_fmod = sblock.fs_fmod;
- altsblock.fs_clean = sblock.fs_clean;
- altsblock.fs_ronly = sblock.fs_ronly;
- altsblock.fs_flags = sblock.fs_flags;
- altsblock.fs_maxcontig = sblock.fs_maxcontig;
- altsblock.fs_minfree = sblock.fs_minfree;
- altsblock.fs_optim = sblock.fs_optim;
- altsblock.fs_rotdelay = sblock.fs_rotdelay;
- altsblock.fs_maxbpg = sblock.fs_maxbpg;
- memmove(altsblock.fs_csp, sblock.fs_csp, sizeof sblock.fs_csp);
- altsblock.fs_maxcluster = sblock.fs_maxcluster;
- memmove(altsblock.fs_fsmnt, sblock.fs_fsmnt, sizeof sblock.fs_fsmnt);
- memmove(altsblock.fs_sparecon,
- sblock.fs_sparecon, sizeof sblock.fs_sparecon);
- /*
- * The following should not have to be copied.
- */
- altsblock.fs_fsbtodb = sblock.fs_fsbtodb;
- altsblock.fs_interleave = sblock.fs_interleave;
- altsblock.fs_npsect = sblock.fs_npsect;
- altsblock.fs_nrpos = sblock.fs_nrpos;
- altsblock.fs_state = sblock.fs_state;
- altsblock.fs_qbmask = sblock.fs_qbmask;
- altsblock.fs_qfmask = sblock.fs_qfmask;
- altsblock.fs_state = sblock.fs_state;
- altsblock.fs_maxfilesize = sblock.fs_maxfilesize;
- if (memcmp(&sblock, &altsblock, (int)sblock.fs_sbsize)) {
- if (debug) {
- long *nlp, *olp, *endlp;
-
- printf("superblock mismatches\n");
- nlp = (long *)&altsblock;
- olp = (long *)&sblock;
- endlp = olp + (sblock.fs_sbsize / sizeof *olp);
- for ( ; olp < endlp; olp++, nlp++) {
- if (*olp == *nlp)
- continue;
- printf(
- "offset %d, original %ld, alternate %ld\n",
- olp - (long *)&sblock, *olp, *nlp);
- }
- }
- badsb(listerr,
- "VALUES IN SUPER BLOCK DISAGREE WITH THOSE IN FIRST ALTERNATE");
- return (0);
- }
- havesb = 1;
- return (1);
-}
-
-static void
-badsb(listerr, s)
- int listerr;
- char *s;
-{
-
- if (!listerr)
- return;
- if (preen)
- printf("%s: ", cdevname);
- pfatal("BAD SUPER BLOCK: %s\n", s);
-}
-
-/*
- * Calculate a prototype superblock based on information in the disk label.
- * When done the cgsblock macro can be calculated and the fs_ncg field
- * can be used. Do NOT attempt to use other macros without verifying that
- * their needed information is available!
- */
-static int
-calcsb(dev, devfd, fs)
- char *dev;
- int devfd;
- register struct fs *fs;
-{
- register struct disklabel *lp;
- register struct partition *pp;
- register char *cp;
- int i;
-
- cp = strchr(dev, '\0') - 1;
- if (cp == (char *)-1 || ((*cp < 'a' || *cp > 'h') && !isdigit(*cp))) {
- pfatal("%s: CANNOT FIGURE OUT FILE SYSTEM PARTITION\n", dev);
- return (0);
- }
- lp = getdisklabel(dev, devfd);
- if (isdigit(*cp))
- pp = &lp->d_partitions[0];
- else
- pp = &lp->d_partitions[*cp - 'a'];
- if (pp->p_fstype != FS_BSDFFS) {
- pfatal("%s: NOT LABELED AS A BSD FILE SYSTEM (%s)\n",
- dev, pp->p_fstype < FSMAXTYPES ?
- fstypenames[pp->p_fstype] : "unknown");
- return (0);
- }
- if (pp->p_fsize == 0 || pp->p_frag == 0 ||
- pp->p_cpg == 0 || pp->p_size == 0) {
- pfatal("%s: %s: type %s fsize %d, frag %d, cpg %d, size %d\n",
- dev, "INCOMPLETE LABEL", fstypenames[pp->p_fstype],
- pp->p_fsize, pp->p_frag, pp->p_cpg, pp->p_size);
- return (0);
- }
- memset(fs, 0, sizeof(struct fs));
- fs->fs_fsize = pp->p_fsize;
- fs->fs_frag = pp->p_frag;
- fs->fs_cpg = pp->p_cpg;
- fs->fs_size = pp->p_size;
- fs->fs_ntrak = lp->d_ntracks;
- fs->fs_nsect = lp->d_nsectors;
- fs->fs_spc = lp->d_secpercyl;
- fs->fs_nspf = fs->fs_fsize / lp->d_secsize;
- fs->fs_sblkno = roundup(
- howmany(lp->d_bbsize + lp->d_sbsize, fs->fs_fsize),
- fs->fs_frag);
- fs->fs_cgmask = 0xffffffff;
- for (i = fs->fs_ntrak; i > 1; i >>= 1)
- fs->fs_cgmask <<= 1;
- if (!POWEROF2(fs->fs_ntrak))
- fs->fs_cgmask <<= 1;
- fs->fs_cgoffset = roundup(
- howmany(fs->fs_nsect, NSPF(fs)), fs->fs_frag);
- fs->fs_fpg = (fs->fs_cpg * fs->fs_spc) / NSPF(fs);
- fs->fs_ncg = howmany(fs->fs_size / fs->fs_spc, fs->fs_cpg);
- for (fs->fs_fsbtodb = 0, i = NSPF(fs); i > 1; i >>= 1)
- fs->fs_fsbtodb++;
- dev_bsize = lp->d_secsize;
- return (1);
-}
-
-static struct disklabel *
-getdisklabel(s, fd)
- char *s;
- int fd;
-{
- static struct disklabel lab;
-
- if (ioctl(fd, DIOCGDINFO, (char *)&lab) < 0) {
- if (s == NULL)
- return ((struct disklabel *)NULL);
- pwarn("ioctl (GCINFO): %s\n", strerror(errno));
- errx(EEXIT, "%s: can't read disk label", s);
- }
- return (&lab);
-}
diff --git a/sbin/fsck_ffs/utilities.c b/sbin/fsck_ffs/utilities.c
deleted file mode 100644
index 1efdabcd11d0..000000000000
--- a/sbin/fsck_ffs/utilities.c
+++ /dev/null
@@ -1,683 +0,0 @@
-/*
- * Copyright (c) 1980, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-#if 0
-static const char sccsid[] = "@(#)utilities.c 8.6 (Berkeley) 5/19/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <sys/param.h>
-
-#include <ufs/ufs/dinode.h>
-#include <ufs/ufs/dir.h>
-#include <ufs/ffs/fs.h>
-
-#include <err.h>
-#include <string.h>
-
-#include "fsck.h"
-
-long diskreads, totalreads; /* Disk cache statistics */
-
-static void rwerror __P((char *mesg, ufs_daddr_t blk));
-
-int
-ftypeok(dp)
- struct dinode *dp;
-{
- switch (dp->di_mode & IFMT) {
-
- case IFDIR:
- case IFREG:
- case IFBLK:
- case IFCHR:
- case IFLNK:
- case IFSOCK:
- case IFIFO:
- return (1);
-
- default:
- if (debug)
- printf("bad file type 0%o\n", dp->di_mode);
- return (0);
- }
-}
-
-int
-reply(question)
- char *question;
-{
- int persevere;
- char c;
-
- if (preen)
- pfatal("INTERNAL ERROR: GOT TO reply()");
- persevere = !strcmp(question, "CONTINUE");
- printf("\n");
- if (!persevere && (nflag || fswritefd < 0)) {
- printf("%s? no\n\n", question);
- resolved = 0;
- return (0);
- }
- if (yflag || (persevere && nflag)) {
- printf("%s? yes\n\n", question);
- return (1);
- }
- do {
- printf("%s? [yn] ", question);
- (void) fflush(stdout);
- c = getc(stdin);
- while (c != '\n' && getc(stdin) != '\n') {
- if (feof(stdin)) {
- resolved = 0;
- return (0);
- }
- }
- } while (c != 'y' && c != 'Y' && c != 'n' && c != 'N');
- printf("\n");
- if (c == 'y' || c == 'Y')
- return (1);
- resolved = 0;
- return (0);
-}
-
-/*
- * Look up state information for an inode.
- */
-struct inostat *
-inoinfo(inum)
- ino_t inum;
-{
- static struct inostat unallocated = { USTATE, 0, 0 };
- struct inostatlist *ilp;
- int iloff;
-
- if (inum > maxino)
- errx(EEXIT, "inoinfo: inumber %d out of range", inum);
- ilp = &inostathead[inum / sblock.fs_ipg];
- iloff = inum % sblock.fs_ipg;
- if (iloff >= ilp->il_numalloced)
- return (&unallocated);
- return (&ilp->il_stat[iloff]);
-}
-
-/*
- * Malloc buffers and set up cache.
- */
-void
-bufinit()
-{
- register struct bufarea *bp;
- long bufcnt, i;
- char *bufp;
-
- pbp = pdirbp = (struct bufarea *)0;
- bufp = malloc((unsigned int)sblock.fs_bsize);
- if (bufp == 0)
- errx(EEXIT, "cannot allocate buffer pool");
- cgblk.b_un.b_buf = bufp;
- initbarea(&cgblk);
- bufhead.b_next = bufhead.b_prev = &bufhead;
- bufcnt = MAXBUFSPACE / sblock.fs_bsize;
- if (bufcnt < MINBUFS)
- bufcnt = MINBUFS;
- for (i = 0; i < bufcnt; i++) {
- bp = (struct bufarea *)malloc(sizeof(struct bufarea));
- bufp = malloc((unsigned int)sblock.fs_bsize);
- if (bp == NULL || bufp == NULL) {
- if (i >= MINBUFS)
- break;
- errx(EEXIT, "cannot allocate buffer pool");
- }
- bp->b_un.b_buf = bufp;
- bp->b_prev = &bufhead;
- bp->b_next = bufhead.b_next;
- bufhead.b_next->b_prev = bp;
- bufhead.b_next = bp;
- initbarea(bp);
- }
- bufhead.b_size = i; /* save number of buffers */
-}
-
-/*
- * Manage a cache of directory blocks.
- */
-struct bufarea *
-getdatablk(blkno, size)
- ufs_daddr_t blkno;
- long size;
-{
- register struct bufarea *bp;
-
- for (bp = bufhead.b_next; bp != &bufhead; bp = bp->b_next)
- if (bp->b_bno == fsbtodb(&sblock, blkno))
- goto foundit;
- for (bp = bufhead.b_prev; bp != &bufhead; bp = bp->b_prev)
- if ((bp->b_flags & B_INUSE) == 0)
- break;
- if (bp == &bufhead)
- errx(EEXIT, "deadlocked buffer pool");
- getblk(bp, blkno, size);
- /* fall through */
-foundit:
- totalreads++;
- bp->b_prev->b_next = bp->b_next;
- bp->b_next->b_prev = bp->b_prev;
- bp->b_prev = &bufhead;
- bp->b_next = bufhead.b_next;
- bufhead.b_next->b_prev = bp;
- bufhead.b_next = bp;
- bp->b_flags |= B_INUSE;
- return (bp);
-}
-
-void
-getblk(bp, blk, size)
- register struct bufarea *bp;
- ufs_daddr_t blk;
- long size;
-{
- ufs_daddr_t dblk;
-
- dblk = fsbtodb(&sblock, blk);
- if (bp->b_bno != dblk) {
- flush(fswritefd, bp);
- diskreads++;
- bp->b_errs = bread(fsreadfd, bp->b_un.b_buf, dblk, size);
- bp->b_bno = dblk;
- bp->b_size = size;
- }
-}
-
-void
-flush(fd, bp)
- int fd;
- register struct bufarea *bp;
-{
- register int i, j;
-
- if (!bp->b_dirty)
- return;
- if (bp->b_errs != 0)
- pfatal("WRITING %sZERO'ED BLOCK %d TO DISK\n",
- (bp->b_errs == bp->b_size / dev_bsize) ? "" : "PARTIALLY ",
- bp->b_bno);
- bp->b_dirty = 0;
- bp->b_errs = 0;
- bwrite(fd, bp->b_un.b_buf, bp->b_bno, (long)bp->b_size);
- if (bp != &sblk)
- return;
- for (i = 0, j = 0; i < sblock.fs_cssize; i += sblock.fs_bsize, j++) {
- bwrite(fswritefd, (char *)sblock.fs_csp[j],
- fsbtodb(&sblock, sblock.fs_csaddr + j * sblock.fs_frag),
- sblock.fs_cssize - i < sblock.fs_bsize ?
- sblock.fs_cssize - i : sblock.fs_bsize);
- }
-}
-
-static void
-rwerror(mesg, blk)
- char *mesg;
- ufs_daddr_t blk;
-{
-
- if (preen == 0)
- printf("\n");
- pfatal("CANNOT %s: BLK %ld", mesg, blk);
- if (reply("CONTINUE") == 0)
- exit(EEXIT);
-}
-
-void
-ckfini(markclean)
- int markclean;
-{
- register struct bufarea *bp, *nbp;
- int ofsmodified, cnt = 0;
-
- if (fswritefd < 0) {
- (void)close(fsreadfd);
- return;
- }
- flush(fswritefd, &sblk);
- if (havesb && sblk.b_bno != SBOFF / dev_bsize &&
- !preen && reply("UPDATE STANDARD SUPERBLOCK")) {
- sblk.b_bno = SBOFF / dev_bsize;
- sbdirty();
- flush(fswritefd, &sblk);
- }
- flush(fswritefd, &cgblk);
- free(cgblk.b_un.b_buf);
- for (bp = bufhead.b_prev; bp && bp != &bufhead; bp = nbp) {
- cnt++;
- flush(fswritefd, bp);
- nbp = bp->b_prev;
- free(bp->b_un.b_buf);
- free((char *)bp);
- }
- if (bufhead.b_size != cnt)
- errx(EEXIT, "panic: lost %d buffers", bufhead.b_size - cnt);
- pbp = pdirbp = (struct bufarea *)0;
- if (sblock.fs_clean != markclean) {
- sblock.fs_clean = markclean;
- sbdirty();
- ofsmodified = fsmodified;
- flush(fswritefd, &sblk);
- fsmodified = ofsmodified;
- if (!preen) {
- printf("\n***** FILE SYSTEM MARKED %s *****\n",
- markclean ? "CLEAN" : "DIRTY");
- if (!markclean)
- rerun = 1;
- }
- } else if (!preen && !markclean) {
- printf("\n***** FILE SYSTEM STILL DIRTY *****\n");
- rerun = 1;
- }
- if (debug)
- printf("cache missed %ld of %ld (%d%%)\n", diskreads,
- totalreads, (int)(diskreads * 100 / totalreads));
- (void)close(fsreadfd);
- (void)close(fswritefd);
-}
-
-int
-bread(fd, buf, blk, size)
- int fd;
- char *buf;
- ufs_daddr_t blk;
- long size;
-{
- char *cp;
- int i, errs;
- off_t offset;
-
- offset = blk;
- offset *= dev_bsize;
- if (lseek(fd, offset, 0) < 0)
- rwerror("SEEK", blk);
- else if (read(fd, buf, (int)size) == size)
- return (0);
- rwerror("READ", blk);
- if (lseek(fd, offset, 0) < 0)
- rwerror("SEEK", blk);
- errs = 0;
- memset(buf, 0, (size_t)size);
- printf("THE FOLLOWING DISK SECTORS COULD NOT BE READ:");
- for (cp = buf, i = 0; i < size; i += secsize, cp += secsize) {
- if (read(fd, cp, (int)secsize) != secsize) {
- (void)lseek(fd, offset + i + secsize, 0);
- if (secsize != dev_bsize && dev_bsize != 1)
- printf(" %ld (%ld),",
- (blk * dev_bsize + i) / secsize,
- blk + i / dev_bsize);
- else
- printf(" %ld,", blk + i / dev_bsize);
- errs++;
- }
- }
- printf("\n");
- if (errs)
- resolved = 0;
- return (errs);
-}
-
-void
-bwrite(fd, buf, blk, size)
- int fd;
- char *buf;
- ufs_daddr_t blk;
- long size;
-{
- int i;
- char *cp;
- off_t offset;
-
- if (fd < 0)
- return;
- offset = blk;
- offset *= dev_bsize;
- if (lseek(fd, offset, 0) < 0)
- rwerror("SEEK", blk);
- else if (write(fd, buf, (int)size) == size) {
- fsmodified = 1;
- return;
- }
- resolved = 0;
- rwerror("WRITE", blk);
- if (lseek(fd, offset, 0) < 0)
- rwerror("SEEK", blk);
- printf("THE FOLLOWING SECTORS COULD NOT BE WRITTEN:");
- for (cp = buf, i = 0; i < size; i += dev_bsize, cp += dev_bsize)
- if (write(fd, cp, (int)dev_bsize) != dev_bsize) {
- (void)lseek(fd, offset + i + dev_bsize, 0);
- printf(" %ld,", blk + i / dev_bsize);
- }
- printf("\n");
- return;
-}
-
-/*
- * allocate a data block with the specified number of fragments
- */
-ufs_daddr_t
-allocblk(frags)
- long frags;
-{
- int i, j, k, cg, baseblk;
- struct cg *cgp = &cgrp;
-
- if (frags <= 0 || frags > sblock.fs_frag)
- return (0);
- for (i = 0; i < maxfsblock - sblock.fs_frag; i += sblock.fs_frag) {
- for (j = 0; j <= sblock.fs_frag - frags; j++) {
- if (testbmap(i + j))
- continue;
- for (k = 1; k < frags; k++)
- if (testbmap(i + j + k))
- break;
- if (k < frags) {
- j += k;
- continue;
- }
- cg = dtog(&sblock, i + j);
- getblk(&cgblk, cgtod(&sblock, cg), sblock.fs_cgsize);
- if (!cg_chkmagic(cgp))
- pfatal("CG %d: BAD MAGIC NUMBER\n", cg);
- baseblk = dtogd(&sblock, i + j);
- for (k = 0; k < frags; k++) {
- setbmap(i + j + k);
- clrbit(cg_blksfree(cgp), baseblk + k);
- }
- n_blks += frags;
- if (frags == sblock.fs_frag)
- cgp->cg_cs.cs_nbfree--;
- else
- cgp->cg_cs.cs_nffree -= frags;
- cgdirty();
- return (i + j);
- }
- }
- return (0);
-}
-
-/*
- * Free a previously allocated block
- */
-void
-freeblk(blkno, frags)
- ufs_daddr_t blkno;
- long frags;
-{
- struct inodesc idesc;
-
- idesc.id_blkno = blkno;
- idesc.id_numfrags = frags;
- (void)pass4check(&idesc);
-}
-
-/*
- * Find a pathname
- */
-void
-getpathname(namebuf, curdir, ino)
- char *namebuf;
- ino_t curdir, ino;
-{
- int len;
- register char *cp;
- struct inodesc idesc;
- static int busy = 0;
-
- if (curdir == ino && ino == ROOTINO) {
- (void)strcpy(namebuf, "/");
- return;
- }
- if (busy ||
- (inoinfo(curdir)->ino_state != DSTATE &&
- inoinfo(curdir)->ino_state != DFOUND)) {
- (void)strcpy(namebuf, "?");
- return;
- }
- busy = 1;
- memset(&idesc, 0, sizeof(struct inodesc));
- idesc.id_type = DATA;
- idesc.id_fix = IGNORE;
- cp = &namebuf[MAXPATHLEN - 1];
- *cp = '\0';
- if (curdir != ino) {
- idesc.id_parent = curdir;
- goto namelookup;
- }
- while (ino != ROOTINO) {
- idesc.id_number = ino;
- idesc.id_func = findino;
- idesc.id_name = "..";
- if ((ckinode(ginode(ino), &idesc) & FOUND) == 0)
- break;
- namelookup:
- idesc.id_number = idesc.id_parent;
- idesc.id_parent = ino;
- idesc.id_func = findname;
- idesc.id_name = namebuf;
- if ((ckinode(ginode(idesc.id_number), &idesc)&FOUND) == 0)
- break;
- len = strlen(namebuf);
- cp -= len;
- memmove(cp, namebuf, (size_t)len);
- *--cp = '/';
- if (cp < &namebuf[MAXNAMLEN])
- break;
- ino = idesc.id_number;
- }
- busy = 0;
- if (ino != ROOTINO)
- *--cp = '?';
- memmove(namebuf, cp, (size_t)(&namebuf[MAXPATHLEN] - cp));
-}
-
-void
-catch(sig)
- int sig;
-{
- if (!doinglevel2)
- ckfini(0);
- exit(12);
-}
-
-/*
- * When preening, allow a single quit to signal
- * a special exit after filesystem checks complete
- * so that reboot sequence may be interrupted.
- */
-void
-catchquit(sig)
- int sig;
-{
- printf("returning to single-user after filesystem check\n");
- returntosingle = 1;
- (void)signal(SIGQUIT, SIG_DFL);
-}
-
-/*
- * Ignore a single quit signal; wait and flush just in case.
- * Used by child processes in preen.
- */
-void
-voidquit(sig)
- int sig;
-{
-
- sleep(1);
- (void)signal(SIGQUIT, SIG_IGN);
- (void)signal(SIGQUIT, SIG_DFL);
-}
-
-/*
- * determine whether an inode should be fixed.
- */
-int
-dofix(idesc, msg)
- register struct inodesc *idesc;
- char *msg;
-{
-
- switch (idesc->id_fix) {
-
- case DONTKNOW:
- if (idesc->id_type == DATA)
- direrror(idesc->id_number, msg);
- else
- pwarn(msg);
- if (preen) {
- printf(" (SALVAGED)\n");
- idesc->id_fix = FIX;
- return (ALTERED);
- }
- if (reply("SALVAGE") == 0) {
- idesc->id_fix = NOFIX;
- return (0);
- }
- idesc->id_fix = FIX;
- return (ALTERED);
-
- case FIX:
- return (ALTERED);
-
- case NOFIX:
- case IGNORE:
- return (0);
-
- default:
- errx(EEXIT, "UNKNOWN INODESC FIX MODE %d", idesc->id_fix);
- }
- /* NOTREACHED */
- return (0);
-}
-
-#if __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-/*
- * An unexpected inconsistency occured.
- * Die if preening or filesystem is running with soft dependency protocol,
- * otherwise just print message and continue.
- */
-void
-#if __STDC__
-pfatal(const char *fmt, ...)
-#else
-pfatal(fmt, va_alist)
- char *fmt;
- va_dcl
-#endif
-{
- va_list ap;
-#if __STDC__
- va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
- if (!preen) {
- (void)vfprintf(stderr, fmt, ap);
- va_end(ap);
- if (usedsoftdep)
- (void)fprintf(stderr,
- "\nUNEXPECTED SOFT UPDATE INCONSISTENCY\n");
- return;
- }
- if (cdevname == NULL)
- cdevname = "fsck";
- (void)fprintf(stderr, "%s: ", cdevname);
- (void)vfprintf(stderr, fmt, ap);
- (void)fprintf(stderr,
- "\n%s: UNEXPECTED%sINCONSISTENCY; RUN fsck MANUALLY.\n",
- cdevname, usedsoftdep ? " SOFT UPDATE " : " ");
- ckfini(0);
- exit(EEXIT);
-}
-
-/*
- * Pwarn just prints a message when not preening or running soft dependency
- * protocol, or a warning (preceded by filename) when preening.
- */
-void
-#if __STDC__
-pwarn(const char *fmt, ...)
-#else
-pwarn(fmt, va_alist)
- char *fmt;
- va_dcl
-#endif
-{
- va_list ap;
-#if __STDC__
- va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
- if (preen)
- (void)fprintf(stderr, "%s: ", cdevname);
- (void)vfprintf(stderr, fmt, ap);
- va_end(ap);
-}
-
-/*
- * Stub for routines from kernel.
- */
-void
-#if __STDC__
-panic(const char *fmt, ...)
-#else
-panic(fmt, va_alist)
- char *fmt;
- va_dcl
-#endif
-{
- va_list ap;
-#if __STDC__
- va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
- pfatal("INTERNAL INCONSISTENCY:");
- (void)vfprintf(stderr, fmt, ap);
- va_end(ap);
- exit(EEXIT);
-}
diff --git a/sbin/fsck_ifs/Makefile b/sbin/fsck_ifs/Makefile
deleted file mode 100644
index 3155b1a466ea..000000000000
--- a/sbin/fsck_ifs/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
-# @(#)Makefile 8.2 (Berkeley) 4/27/95
-
-PROG= fsck
-MAN8= fsck.8
-SRCS= dir.c inode.c main.c pass1.c pass1b.c pass2.c pass3.c pass4.c \
- pass5.c preen.c setup.c utilities.c ffs_subr.c ffs_tables.c
-CFLAGS+=-W
-.PATH: ${.CURDIR}/../../sys/ufs/ffs
-
-.include <bsd.prog.mk>
diff --git a/sbin/fsck_ifs/dir.c b/sbin/fsck_ifs/dir.c
deleted file mode 100644
index f5fb6a0ef30a..000000000000
--- a/sbin/fsck_ifs/dir.c
+++ /dev/null
@@ -1,769 +0,0 @@
-/*
- * Copyright (c) 1980, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-#if 0
-static const char sccsid[] = "@(#)dir.c 8.8 (Berkeley) 4/28/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <sys/param.h>
-#include <sys/time.h>
-
-#include <ufs/ufs/dinode.h>
-#include <ufs/ufs/dir.h>
-#include <ufs/ffs/fs.h>
-
-#include <err.h>
-#include <string.h>
-
-#include "fsck.h"
-
-char *lfname = "lost+found";
-int lfmode = 01777;
-struct dirtemplate emptydir = { 0, DIRBLKSIZ };
-struct dirtemplate dirhead = {
- 0, 12, DT_DIR, 1, ".",
- 0, DIRBLKSIZ - 12, DT_DIR, 2, ".."
-};
-struct odirtemplate odirhead = {
- 0, 12, 1, ".",
- 0, DIRBLKSIZ - 12, 2, ".."
-};
-
-static int chgino __P((struct inodesc *));
-static int dircheck __P((struct inodesc *, struct direct *));
-static int expanddir __P((struct dinode *dp, char *name));
-static void freedir __P((ino_t ino, ino_t parent));
-static struct direct *fsck_readdir __P((struct inodesc *));
-static struct bufarea *getdirblk __P((ufs_daddr_t blkno, long size));
-static int lftempname __P((char *bufp, ino_t ino));
-static int mkentry __P((struct inodesc *));
-
-/*
- * Propagate connected state through the tree.
- */
-void
-propagate()
-{
- register struct inoinfo **inpp, *inp;
- struct inoinfo **inpend;
- long change;
-
- inpend = &inpsort[inplast];
- do {
- change = 0;
- for (inpp = inpsort; inpp < inpend; inpp++) {
- inp = *inpp;
- if (inp->i_parent == 0)
- continue;
- if (inoinfo(inp->i_parent)->ino_state == DFOUND &&
- inoinfo(inp->i_number)->ino_state == DSTATE) {
- inoinfo(inp->i_number)->ino_state = DFOUND;
- change++;
- }
- }
- } while (change > 0);
-}
-
-/*
- * Scan each entry in a directory block.
- */
-int
-dirscan(idesc)
- register struct inodesc *idesc;
-{
- register struct direct *dp;
- register struct bufarea *bp;
- int dsize, n;
- long blksiz;
- char dbuf[DIRBLKSIZ];
-
- if (idesc->id_type != DATA)
- errx(EEXIT, "wrong type to dirscan %d", idesc->id_type);
- if (idesc->id_entryno == 0 &&
- (idesc->id_filesize & (DIRBLKSIZ - 1)) != 0)
- idesc->id_filesize = roundup(idesc->id_filesize, DIRBLKSIZ);
- blksiz = idesc->id_numfrags * sblock.fs_fsize;
- if (chkrange(idesc->id_blkno, idesc->id_numfrags)) {
- idesc->id_filesize -= blksiz;
- return (SKIP);
- }
- idesc->id_loc = 0;
- for (dp = fsck_readdir(idesc); dp != NULL; dp = fsck_readdir(idesc)) {
- dsize = dp->d_reclen;
- if (dsize > sizeof(dbuf))
- dsize = sizeof(dbuf);
- memmove(dbuf, dp, (size_t)dsize);
-# if (BYTE_ORDER == LITTLE_ENDIAN)
- if (!newinofmt) {
- struct direct *tdp = (struct direct *)dbuf;
- u_char tmp;
-
- tmp = tdp->d_namlen;
- tdp->d_namlen = tdp->d_type;
- tdp->d_type = tmp;
- }
-# endif
- idesc->id_dirp = (struct direct *)dbuf;
- if ((n = (*idesc->id_func)(idesc)) & ALTERED) {
-# if (BYTE_ORDER == LITTLE_ENDIAN)
- if (!newinofmt && !doinglevel2) {
- struct direct *tdp;
- u_char tmp;
-
- tdp = (struct direct *)dbuf;
- tmp = tdp->d_namlen;
- tdp->d_namlen = tdp->d_type;
- tdp->d_type = tmp;
- }
-# endif
- bp = getdirblk(idesc->id_blkno, blksiz);
- memmove(bp->b_un.b_buf + idesc->id_loc - dsize, dbuf,
- (size_t)dsize);
- dirty(bp);
- sbdirty();
- }
- if (n & STOP)
- return (n);
- }
- return (idesc->id_filesize > 0 ? KEEPON : STOP);
-}
-
-/*
- * get next entry in a directory.
- */
-static struct direct *
-fsck_readdir(idesc)
- register struct inodesc *idesc;
-{
- register struct direct *dp, *ndp;
- register struct bufarea *bp;
- long size, blksiz, fix, dploc;
-
- blksiz = idesc->id_numfrags * sblock.fs_fsize;
- bp = getdirblk(idesc->id_blkno, blksiz);
- if (idesc->id_loc % DIRBLKSIZ == 0 && idesc->id_filesize > 0 &&
- idesc->id_loc < blksiz) {
- dp = (struct direct *)(bp->b_un.b_buf + idesc->id_loc);
- if (dircheck(idesc, dp))
- goto dpok;
- if (idesc->id_fix == IGNORE)
- return (0);
- fix = dofix(idesc, "DIRECTORY CORRUPTED");
- bp = getdirblk(idesc->id_blkno, blksiz);
- dp = (struct direct *)(bp->b_un.b_buf + idesc->id_loc);
- dp->d_reclen = DIRBLKSIZ;
- dp->d_ino = 0;
- dp->d_type = 0;
- dp->d_namlen = 0;
- dp->d_name[0] = '\0';
- if (fix)
- dirty(bp);
- idesc->id_loc += DIRBLKSIZ;
- idesc->id_filesize -= DIRBLKSIZ;
- return (dp);
- }
-dpok:
- if (idesc->id_filesize <= 0 || idesc->id_loc >= blksiz)
- return NULL;
- dploc = idesc->id_loc;
- dp = (struct direct *)(bp->b_un.b_buf + dploc);
- idesc->id_loc += dp->d_reclen;
- idesc->id_filesize -= dp->d_reclen;
- if ((idesc->id_loc % DIRBLKSIZ) == 0)
- return (dp);
- ndp = (struct direct *)(bp->b_un.b_buf + idesc->id_loc);
- if (idesc->id_loc < blksiz && idesc->id_filesize > 0 &&
- dircheck(idesc, ndp) == 0) {
- size = DIRBLKSIZ - (idesc->id_loc % DIRBLKSIZ);
- idesc->id_loc += size;
- idesc->id_filesize -= size;
- if (idesc->id_fix == IGNORE)
- return (0);
- fix = dofix(idesc, "DIRECTORY CORRUPTED");
- bp = getdirblk(idesc->id_blkno, blksiz);
- dp = (struct direct *)(bp->b_un.b_buf + dploc);
- dp->d_reclen += size;
- if (fix)
- dirty(bp);
- }
- return (dp);
-}
-
-/*
- * Verify that a directory entry is valid.
- * This is a superset of the checks made in the kernel.
- */
-static int
-dircheck(idesc, dp)
- struct inodesc *idesc;
- register struct direct *dp;
-{
- register int size;
- register char *cp;
- u_char namlen, type;
- int spaceleft;
-
- spaceleft = DIRBLKSIZ - (idesc->id_loc % DIRBLKSIZ);
- if (dp->d_reclen == 0 ||
- dp->d_reclen > spaceleft ||
- (dp->d_reclen & 0x3) != 0)
- return (0);
- if (dp->d_ino == 0)
- return (1);
- size = DIRSIZ(!newinofmt, dp);
-# if (BYTE_ORDER == LITTLE_ENDIAN)
- if (!newinofmt) {
- type = dp->d_namlen;
- namlen = dp->d_type;
- } else {
- namlen = dp->d_namlen;
- type = dp->d_type;
- }
-# else
- namlen = dp->d_namlen;
- type = dp->d_type;
-# endif
- if (dp->d_reclen < size ||
- idesc->id_filesize < size ||
- namlen > MAXNAMLEN ||
- type > 15)
- return (0);
- for (cp = dp->d_name, size = 0; size < namlen; size++)
- if (*cp == '\0' || (*cp++ == '/'))
- return (0);
- if (*cp != '\0')
- return (0);
- return (1);
-}
-
-void
-direrror(ino, errmesg)
- ino_t ino;
- char *errmesg;
-{
-
- fileerror(ino, ino, errmesg);
-}
-
-void
-fileerror(cwd, ino, errmesg)
- ino_t cwd, ino;
- char *errmesg;
-{
- register struct dinode *dp;
- char pathbuf[MAXPATHLEN + 1];
-
- pwarn("%s ", errmesg);
- pinode(ino);
- printf("\n");
- getpathname(pathbuf, cwd, ino);
- if (ino < ROOTINO || ino > maxino) {
- pfatal("NAME=%s\n", pathbuf);
- return;
- }
- dp = ginode(ino);
- if (ftypeok(dp))
- pfatal("%s=%s\n",
- (dp->di_mode & IFMT) == IFDIR ? "DIR" : "FILE", pathbuf);
- else
- pfatal("NAME=%s\n", pathbuf);
-}
-
-void
-adjust(idesc, lcnt)
- register struct inodesc *idesc;
- int lcnt;
-{
- struct dinode *dp;
- int saveresolved;
-
- dp = ginode(idesc->id_number);
- if (dp->di_nlink == lcnt) {
- /*
- * If we have not hit any unresolved problems, are running
- * in preen mode, and are on a filesystem using soft updates,
- * then just toss any partially allocated files.
- */
- if (resolved && preen && usedsoftdep) {
- clri(idesc, "UNREF", 1);
- return;
- } else {
- /*
- * The filesystem can be marked clean even if
- * a file is not linked up, but is cleared.
- * Hence, resolved should not be cleared when
- * linkup is answered no, but clri is answered yes.
- */
- saveresolved = resolved;
- if (linkup(idesc->id_number, (ino_t)0, NULL) == 0) {
- resolved = saveresolved;
- clri(idesc, "UNREF", 0);
- return;
- }
- /*
- * Account for the new reference created by linkup().
- */
- dp = ginode(idesc->id_number);
- lcnt--;
- }
- }
- if (lcnt != 0) {
- pwarn("LINK COUNT %s", (lfdir == idesc->id_number) ? lfname :
- ((dp->di_mode & IFMT) == IFDIR ? "DIR" : "FILE"));
- pinode(idesc->id_number);
- printf(" COUNT %d SHOULD BE %d",
- dp->di_nlink, dp->di_nlink - lcnt);
- if (preen || usedsoftdep) {
- if (lcnt < 0) {
- printf("\n");
- pfatal("LINK COUNT INCREASING");
- }
- if (preen)
- printf(" (ADJUSTED)\n");
- }
- if (preen || reply("ADJUST") == 1) {
- dp->di_nlink -= lcnt;
- inodirty();
- }
- }
-}
-
-static int
-mkentry(idesc)
- struct inodesc *idesc;
-{
- register struct direct *dirp = idesc->id_dirp;
- struct direct newent;
- int newlen, oldlen;
-
- newent.d_namlen = strlen(idesc->id_name);
- newlen = DIRSIZ(0, &newent);
- if (dirp->d_ino != 0)
- oldlen = DIRSIZ(0, dirp);
- else
- oldlen = 0;
- if (dirp->d_reclen - oldlen < newlen)
- return (KEEPON);
- newent.d_reclen = dirp->d_reclen - oldlen;
- dirp->d_reclen = oldlen;
- dirp = (struct direct *)(((char *)dirp) + oldlen);
- dirp->d_ino = idesc->id_parent; /* ino to be entered is in id_parent */
- dirp->d_reclen = newent.d_reclen;
- if (newinofmt)
- dirp->d_type = inoinfo(idesc->id_parent)->ino_type;
- else
- dirp->d_type = 0;
- dirp->d_namlen = newent.d_namlen;
- memmove(dirp->d_name, idesc->id_name, (size_t)newent.d_namlen + 1);
-# if (BYTE_ORDER == LITTLE_ENDIAN)
- /*
- * If the entry was split, dirscan() will only reverse the byte
- * order of the original entry, and not the new one, before
- * writing it back out. So, we reverse the byte order here if
- * necessary.
- */
- if (oldlen != 0 && !newinofmt && !doinglevel2) {
- u_char tmp;
-
- tmp = dirp->d_namlen;
- dirp->d_namlen = dirp->d_type;
- dirp->d_type = tmp;
- }
-# endif
- return (ALTERED|STOP);
-}
-
-static int
-chgino(idesc)
- struct inodesc *idesc;
-{
- register struct direct *dirp = idesc->id_dirp;
-
- if (memcmp(dirp->d_name, idesc->id_name, (int)dirp->d_namlen + 1))
- return (KEEPON);
- dirp->d_ino = idesc->id_parent;
- if (newinofmt)
- dirp->d_type = inoinfo(idesc->id_parent)->ino_type;
- else
- dirp->d_type = 0;
- return (ALTERED|STOP);
-}
-
-int
-linkup(orphan, parentdir, name)
- ino_t orphan;
- ino_t parentdir;
- char *name;
-{
- register struct dinode *dp;
- int lostdir;
- ino_t oldlfdir;
- struct inodesc idesc;
- char tempname[BUFSIZ];
-
- memset(&idesc, 0, sizeof(struct inodesc));
- dp = ginode(orphan);
- lostdir = (dp->di_mode & IFMT) == IFDIR;
- pwarn("UNREF %s ", lostdir ? "DIR" : "FILE");
- pinode(orphan);
- if (preen && dp->di_size == 0)
- return (0);
- if (preen)
- printf(" (RECONNECTED)\n");
- else
- if (reply("RECONNECT") == 0)
- return (0);
- if (lfdir == 0) {
- dp = ginode(ROOTINO);
- idesc.id_name = lfname;
- idesc.id_type = DATA;
- idesc.id_func = findino;
- idesc.id_number = ROOTINO;
- if ((ckinode(dp, &idesc) & FOUND) != 0) {
- lfdir = idesc.id_parent;
- } else {
- pwarn("NO lost+found DIRECTORY");
- if (preen || reply("CREATE")) {
- lfdir = allocdir(ROOTINO, (ino_t)0, lfmode);
- if (lfdir != 0) {
- if (makeentry(ROOTINO, lfdir, lfname) != 0) {
- numdirs++;
- if (preen)
- printf(" (CREATED)\n");
- } else {
- freedir(lfdir, ROOTINO);
- lfdir = 0;
- if (preen)
- printf("\n");
- }
- }
- }
- }
- if (lfdir == 0) {
- pfatal("SORRY. CANNOT CREATE lost+found DIRECTORY");
- printf("\n\n");
- return (0);
- }
- }
- dp = ginode(lfdir);
- if ((dp->di_mode & IFMT) != IFDIR) {
- pfatal("lost+found IS NOT A DIRECTORY");
- if (reply("REALLOCATE") == 0)
- return (0);
- oldlfdir = lfdir;
- if ((lfdir = allocdir(ROOTINO, (ino_t)0, lfmode)) == 0) {
- pfatal("SORRY. CANNOT CREATE lost+found DIRECTORY\n\n");
- return (0);
- }
- if ((changeino(ROOTINO, lfname, lfdir) & ALTERED) == 0) {
- pfatal("SORRY. CANNOT CREATE lost+found DIRECTORY\n\n");
- return (0);
- }
- inodirty();
- idesc.id_type = ADDR;
- idesc.id_func = pass4check;
- idesc.id_number = oldlfdir;
- adjust(&idesc, inoinfo(oldlfdir)->ino_linkcnt + 1);
- inoinfo(oldlfdir)->ino_linkcnt = 0;
- dp = ginode(lfdir);
- }
- if (inoinfo(lfdir)->ino_state != DFOUND) {
- pfatal("SORRY. NO lost+found DIRECTORY\n\n");
- return (0);
- }
- (void)lftempname(tempname, orphan);
- if (makeentry(lfdir, orphan, (name ? name : tempname)) == 0) {
- pfatal("SORRY. NO SPACE IN lost+found DIRECTORY");
- printf("\n\n");
- return (0);
- }
- inoinfo(orphan)->ino_linkcnt--;
- if (lostdir) {
- if ((changeino(orphan, "..", lfdir) & ALTERED) == 0 &&
- parentdir != (ino_t)-1)
- (void)makeentry(orphan, lfdir, "..");
- dp = ginode(lfdir);
- dp->di_nlink++;
- inodirty();
- inoinfo(lfdir)->ino_linkcnt++;
- pwarn("DIR I=%lu CONNECTED. ", orphan);
- if (parentdir != (ino_t)-1) {
- printf("PARENT WAS I=%lu\n", (u_long)parentdir);
- /*
- * The parent directory, because of the ordering
- * guarantees, has had the link count incremented
- * for the child, but no entry was made. This
- * fixes the parent link count so that fsck does
- * not need to be rerun.
- */
- inoinfo(parentdir)->ino_linkcnt++;
- }
- if (preen == 0)
- printf("\n");
- }
- return (1);
-}
-
-/*
- * fix an entry in a directory.
- */
-int
-changeino(dir, name, newnum)
- ino_t dir;
- char *name;
- ino_t newnum;
-{
- struct inodesc idesc;
-
- memset(&idesc, 0, sizeof(struct inodesc));
- idesc.id_type = DATA;
- idesc.id_func = chgino;
- idesc.id_number = dir;
- idesc.id_fix = DONTKNOW;
- idesc.id_name = name;
- idesc.id_parent = newnum; /* new value for name */
- return (ckinode(ginode(dir), &idesc));
-}
-
-/*
- * make an entry in a directory
- */
-int
-makeentry(parent, ino, name)
- ino_t parent, ino;
- char *name;
-{
- struct dinode *dp;
- struct inodesc idesc;
- char pathbuf[MAXPATHLEN + 1];
-
- if (parent < ROOTINO || parent >= maxino ||
- ino < ROOTINO || ino >= maxino)
- return (0);
- memset(&idesc, 0, sizeof(struct inodesc));
- idesc.id_type = DATA;
- idesc.id_func = mkentry;
- idesc.id_number = parent;
- idesc.id_parent = ino; /* this is the inode to enter */
- idesc.id_fix = DONTKNOW;
- idesc.id_name = name;
- dp = ginode(parent);
- if (dp->di_size % DIRBLKSIZ) {
- dp->di_size = roundup(dp->di_size, DIRBLKSIZ);
- inodirty();
- }
- if ((ckinode(dp, &idesc) & ALTERED) != 0)
- return (1);
- getpathname(pathbuf, parent, parent);
- dp = ginode(parent);
- if (expanddir(dp, pathbuf) == 0)
- return (0);
- return (ckinode(dp, &idesc) & ALTERED);
-}
-
-/*
- * Attempt to expand the size of a directory
- */
-static int
-expanddir(dp, name)
- register struct dinode *dp;
- char *name;
-{
- ufs_daddr_t lastbn, newblk;
- register struct bufarea *bp;
- char *cp, firstblk[DIRBLKSIZ];
-
- lastbn = lblkno(&sblock, dp->di_size);
- if (lastbn >= NDADDR - 1 || dp->di_db[lastbn] == 0 || dp->di_size == 0)
- return (0);
- if ((newblk = allocblk(sblock.fs_frag)) == 0)
- return (0);
- dp->di_db[lastbn + 1] = dp->di_db[lastbn];
- dp->di_db[lastbn] = newblk;
- dp->di_size += sblock.fs_bsize;
- dp->di_blocks += btodb(sblock.fs_bsize);
- bp = getdirblk(dp->di_db[lastbn + 1],
- (long)dblksize(&sblock, dp, lastbn + 1));
- if (bp->b_errs)
- goto bad;
- memmove(firstblk, bp->b_un.b_buf, DIRBLKSIZ);
- bp = getdirblk(newblk, sblock.fs_bsize);
- if (bp->b_errs)
- goto bad;
- memmove(bp->b_un.b_buf, firstblk, DIRBLKSIZ);
- for (cp = &bp->b_un.b_buf[DIRBLKSIZ];
- cp < &bp->b_un.b_buf[sblock.fs_bsize];
- cp += DIRBLKSIZ)
- memmove(cp, &emptydir, sizeof emptydir);
- dirty(bp);
- bp = getdirblk(dp->di_db[lastbn + 1],
- (long)dblksize(&sblock, dp, lastbn + 1));
- if (bp->b_errs)
- goto bad;
- memmove(bp->b_un.b_buf, &emptydir, sizeof emptydir);
- pwarn("NO SPACE LEFT IN %s", name);
- if (preen)
- printf(" (EXPANDED)\n");
- else if (reply("EXPAND") == 0)
- goto bad;
- dirty(bp);
- inodirty();
- return (1);
-bad:
- dp->di_db[lastbn] = dp->di_db[lastbn + 1];
- dp->di_db[lastbn + 1] = 0;
- dp->di_size -= sblock.fs_bsize;
- dp->di_blocks -= btodb(sblock.fs_bsize);
- freeblk(newblk, sblock.fs_frag);
- return (0);
-}
-
-/*
- * allocate a new directory
- */
-ino_t
-allocdir(parent, request, mode)
- ino_t parent, request;
- int mode;
-{
- ino_t ino;
- char *cp;
- struct dinode *dp;
- register struct bufarea *bp;
- struct dirtemplate *dirp;
-
- ino = allocino(request, IFDIR|mode);
- if (newinofmt)
- dirp = &dirhead;
- else
- dirp = (struct dirtemplate *)&odirhead;
- dirp->dot_ino = ino;
- dirp->dotdot_ino = parent;
- dp = ginode(ino);
- bp = getdirblk(dp->di_db[0], sblock.fs_fsize);
- if (bp->b_errs) {
- freeino(ino);
- return (0);
- }
- memmove(bp->b_un.b_buf, dirp, sizeof(struct dirtemplate));
- for (cp = &bp->b_un.b_buf[DIRBLKSIZ];
- cp < &bp->b_un.b_buf[sblock.fs_fsize];
- cp += DIRBLKSIZ)
- memmove(cp, &emptydir, sizeof emptydir);
- dirty(bp);
- dp->di_nlink = 2;
- inodirty();
- if (ino == ROOTINO) {
- inoinfo(ino)->ino_linkcnt = dp->di_nlink;
- cacheino(dp, ino);
- return(ino);
- }
- if (inoinfo(parent)->ino_state != DSTATE &&
- inoinfo(parent)->ino_state != DFOUND) {
- freeino(ino);
- return (0);
- }
- cacheino(dp, ino);
- inoinfo(ino)->ino_state = inoinfo(parent)->ino_state;
- if (inoinfo(ino)->ino_state == DSTATE) {
- inoinfo(ino)->ino_linkcnt = dp->di_nlink;
- inoinfo(parent)->ino_linkcnt++;
- }
- dp = ginode(parent);
- dp->di_nlink++;
- inodirty();
- return (ino);
-}
-
-/*
- * free a directory inode
- */
-static void
-freedir(ino, parent)
- ino_t ino, parent;
-{
- struct dinode *dp;
-
- if (ino != parent) {
- dp = ginode(parent);
- dp->di_nlink--;
- inodirty();
- }
- freeino(ino);
-}
-
-/*
- * generate a temporary name for the lost+found directory.
- */
-static int
-lftempname(bufp, ino)
- char *bufp;
- ino_t ino;
-{
- register ino_t in;
- register char *cp;
- int namlen;
-
- cp = bufp + 2;
- for (in = maxino; in > 0; in /= 10)
- cp++;
- *--cp = 0;
- namlen = cp - bufp;
- in = ino;
- while (cp > bufp) {
- *--cp = (in % 10) + '0';
- in /= 10;
- }
- *cp = '#';
- return (namlen);
-}
-
-/*
- * Get a directory block.
- * Insure that it is held until another is requested.
- */
-static struct bufarea *
-getdirblk(blkno, size)
- ufs_daddr_t blkno;
- long size;
-{
-
- if (pdirbp != 0)
- pdirbp->b_flags &= ~B_INUSE;
- pdirbp = getdatablk(blkno, size);
- return (pdirbp);
-}
diff --git a/sbin/fsck_ifs/fsck.h b/sbin/fsck_ifs/fsck.h
deleted file mode 100644
index 9d59c8ff2526..000000000000
--- a/sbin/fsck_ifs/fsck.h
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- * Copyright (c) 1980, 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)fsck.h 8.4 (Berkeley) 5/9/95
- * $FreeBSD$
- */
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-#define MAXDUP 10 /* limit on dup blks (per inode) */
-#define MAXBAD 10 /* limit on bad blks (per inode) */
-#define MAXBUFSPACE 40*1024 /* maximum space to allocate to buffers */
-#define INOBUFSIZE 56*1024 /* size of buffer to read inodes in pass1 */
-
-/*
- * Each inode on the filesystem is described by the following structure.
- * The linkcnt is initially set to the value in the inode. Each time it
- * is found during the descent in passes 2, 3, and 4 the count is
- * decremented. Any inodes whose count is non-zero after pass 4 needs to
- * have its link count adjusted by the value remaining in ino_linkcnt.
- */
-struct inostat {
- char ino_state; /* state of inode, see below */
- char ino_type; /* type of inode */
- short ino_linkcnt; /* number of links not found */
-};
-/*
- * Inode states.
- */
-#define USTATE 01 /* inode not allocated */
-#define FSTATE 02 /* inode is file */
-#define DSTATE 03 /* inode is directory */
-#define DFOUND 04 /* directory found during descent */
-#define DCLEAR 05 /* directory is to be cleared */
-#define FCLEAR 06 /* file is to be cleared */
-/*
- * Inode state information is contained on per cylinder group lists
- * which are described by the following structure.
- */
-struct inostatlist {
- long il_numalloced; /* number of inodes allocated in this cg */
- struct inostat *il_stat;/* inostat info for this cylinder group */
-} *inostathead;
-
-/*
- * buffer cache structure.
- */
-struct bufarea {
- struct bufarea *b_next; /* free list queue */
- struct bufarea *b_prev; /* free list queue */
- ufs_daddr_t b_bno;
- int b_size;
- int b_errs;
- int b_flags;
- union {
- char *b_buf; /* buffer space */
- ufs_daddr_t *b_indir; /* indirect block */
- struct fs *b_fs; /* super block */
- struct cg *b_cg; /* cylinder group */
- struct dinode *b_dinode; /* inode block */
- } b_un;
- char b_dirty;
-};
-
-#define B_INUSE 1
-
-#define MINBUFS 5 /* minimum number of buffers required */
-struct bufarea bufhead; /* head of list of other blks in filesys */
-struct bufarea sblk; /* file system superblock */
-struct bufarea cgblk; /* cylinder group blocks */
-struct bufarea *pdirbp; /* current directory contents */
-struct bufarea *pbp; /* current inode block */
-
-#define dirty(bp) (bp)->b_dirty = 1
-#define initbarea(bp) \
- (bp)->b_dirty = 0; \
- (bp)->b_bno = (ufs_daddr_t)-1; \
- (bp)->b_flags = 0;
-
-#define sbdirty() sblk.b_dirty = 1
-#define cgdirty() cgblk.b_dirty = 1
-#define sblock (*sblk.b_un.b_fs)
-#define cgrp (*cgblk.b_un.b_cg)
-
-enum fixstate {DONTKNOW, NOFIX, FIX, IGNORE};
-
-struct inodesc {
- enum fixstate id_fix; /* policy on fixing errors */
- int (*id_func)(); /* function to be applied to blocks of inode */
- ino_t id_number; /* inode number described */
- ino_t id_parent; /* for DATA nodes, their parent */
- ufs_daddr_t id_blkno; /* current block number being examined */
- int id_numfrags; /* number of frags contained in block */
- quad_t id_filesize; /* for DATA nodes, the size of the directory */
- int id_loc; /* for DATA nodes, current location in dir */
- int id_entryno; /* for DATA nodes, current entry number */
- struct direct *id_dirp; /* for DATA nodes, ptr to current entry */
- char *id_name; /* for DATA nodes, name to find or enter */
- char id_type; /* type of descriptor, DATA or ADDR */
-};
-/* file types */
-#define DATA 1
-#define ADDR 2
-
-/*
- * Linked list of duplicate blocks.
- *
- * The list is composed of two parts. The first part of the
- * list (from duplist through the node pointed to by muldup)
- * contains a single copy of each duplicate block that has been
- * found. The second part of the list (from muldup to the end)
- * contains duplicate blocks that have been found more than once.
- * To check if a block has been found as a duplicate it is only
- * necessary to search from duplist through muldup. To find the
- * total number of times that a block has been found as a duplicate
- * the entire list must be searched for occurences of the block
- * in question. The following diagram shows a sample list where
- * w (found twice), x (found once), y (found three times), and z
- * (found once) are duplicate block numbers:
- *
- * w -> y -> x -> z -> y -> w -> y
- * ^ ^
- * | |
- * duplist muldup
- */
-struct dups {
- struct dups *next;
- ufs_daddr_t dup;
-};
-struct dups *duplist; /* head of dup list */
-struct dups *muldup; /* end of unique duplicate dup block numbers */
-
-/*
- * Linked list of inodes with zero link counts.
- */
-struct zlncnt {
- struct zlncnt *next;
- ino_t zlncnt;
-};
-struct zlncnt *zlnhead; /* head of zero link count list */
-
-/*
- * Inode cache data structures.
- */
-struct inoinfo {
- struct inoinfo *i_nexthash; /* next entry in hash chain */
- ino_t i_number; /* inode number of this entry */
- ino_t i_parent; /* inode number of parent */
- ino_t i_dotdot; /* inode number of `..' */
- size_t i_isize; /* size of inode */
- u_int i_numblks; /* size of block array in bytes */
- ufs_daddr_t i_blks[1]; /* actually longer */
-} **inphead, **inpsort;
-long numdirs, dirhash, listmax, inplast;
-long countdirs; /* number of directories we actually found */
-
-char *cdevname; /* name of device being checked */
-long dev_bsize; /* computed value of DEV_BSIZE */
-long secsize; /* actual disk sector size */
-char fflag; /* force check, ignore clean flag */
-char nflag; /* assume a no response */
-char yflag; /* assume a yes response */
-int bflag; /* location of alternate super block */
-int debug; /* output debugging info */
-int cvtlevel; /* convert to newer file system format */
-int doinglevel1; /* converting to new cylinder group format */
-int doinglevel2; /* converting to new inode format */
-int newinofmt; /* filesystem has new inode format */
-char usedsoftdep; /* just fix soft dependency inconsistencies */
-char preen; /* just fix normal inconsistencies */
-char rerun; /* rerun fsck. Only used in non-preen mode */
-int returntosingle; /* 1 => return to single user mode on exit */
-char resolved; /* cleared if unresolved changes => not clean */
-char havesb; /* superblock has been read */
-int fsmodified; /* 1 => write done to file system */
-int fsreadfd; /* file descriptor for reading file system */
-int fswritefd; /* file descriptor for writing file system */
-
-ufs_daddr_t maxfsblock; /* number of blocks in the file system */
-char *blockmap; /* ptr to primary blk allocation map */
-ino_t maxino; /* number of inodes in file system */
-
-ino_t lfdir; /* lost & found directory inode number */
-char *lfname; /* lost & found directory name */
-int lfmode; /* lost & found directory creation mode */
-
-ufs_daddr_t n_blks; /* number of blocks in use */
-ufs_daddr_t n_files; /* number of files in use */
-
-#define clearinode(dp) (*(dp) = zino)
-struct dinode zino;
-
-#define setbmap(blkno) setbit(blockmap, blkno)
-#define testbmap(blkno) isset(blockmap, blkno)
-#define clrbmap(blkno) clrbit(blockmap, blkno)
-
-#define STOP 0x01
-#define SKIP 0x02
-#define KEEPON 0x04
-#define ALTERED 0x08
-#define FOUND 0x10
-
-#define EEXIT 8 /* Standard error exit. */
-
-struct fstab;
-
-
-void adjust __P((struct inodesc *, int lcnt));
-ufs_daddr_t allocblk __P((long frags));
-ino_t allocdir __P((ino_t parent, ino_t request, int mode));
-ino_t allocino __P((ino_t request, int type));
-void blkerror __P((ino_t ino, char *type, ufs_daddr_t blk));
-char *blockcheck __P((char *name));
-int bread __P((int fd, char *buf, ufs_daddr_t blk, long size));
-void bufinit __P((void));
-void bwrite __P((int fd, char *buf, ufs_daddr_t blk, long size));
-void cacheino __P((struct dinode *dp, ino_t inumber));
-void catch __P((int));
-void catchquit __P((int));
-int changeino __P((ino_t dir, char *name, ino_t newnum));
-int checkfstab __P((int preen, int maxrun,
- int (*docheck)(struct fstab *),
- int (*chkit)(char *, char *, long, int)));
-int chkrange __P((ufs_daddr_t blk, int cnt));
-void ckfini __P((int markclean));
-int ckinode __P((struct dinode *dp, struct inodesc *));
-void clri __P((struct inodesc *, char *type, int flag));
-int clearentry __P((struct inodesc *));
-void direrror __P((ino_t ino, char *errmesg));
-int dirscan __P((struct inodesc *));
-int dofix __P((struct inodesc *, char *msg));
-void ffs_clrblock __P((struct fs *, u_char *, ufs_daddr_t));
-void ffs_fragacct __P((struct fs *, int, int32_t [], int));
-int ffs_isblock __P((struct fs *, u_char *, ufs_daddr_t));
-void ffs_setblock __P((struct fs *, u_char *, ufs_daddr_t));
-void fileerror __P((ino_t cwd, ino_t ino, char *errmesg));
-int findino __P((struct inodesc *));
-int findname __P((struct inodesc *));
-void flush __P((int fd, struct bufarea *bp));
-void freeblk __P((ufs_daddr_t blkno, long frags));
-void freeino __P((ino_t ino));
-void freeinodebuf __P((void));
-int ftypeok __P((struct dinode *dp));
-void getblk __P((struct bufarea *bp, ufs_daddr_t blk, long size));
-struct bufarea *getdatablk __P((ufs_daddr_t blkno, long size));
-struct inoinfo *getinoinfo __P((ino_t inumber));
-struct dinode *getnextinode __P((ino_t inumber));
-void getpathname __P((char *namebuf, ino_t curdir, ino_t ino));
-struct dinode *ginode __P((ino_t inumber));
-void inocleanup __P((void));
-void inodirty __P((void));
-struct inostat *inoinfo __P((ino_t inum));
-int linkup __P((ino_t orphan, ino_t parentdir, char *name));
-int makeentry __P((ino_t parent, ino_t ino, char *name));
-void panic __P((const char *fmt, ...));
-void pass1 __P((void));
-void pass1b __P((void));
-int pass1check __P((struct inodesc *));
-void pass2 __P((void));
-void pass3 __P((void));
-void pass4 __P((void));
-int pass4check __P((struct inodesc *));
-void pass5 __P((void));
-void pfatal __P((const char *fmt, ...));
-void pinode __P((ino_t ino));
-void propagate __P((void));
-void pwarn __P((const char *fmt, ...));
-int reply __P((char *question));
-void setinodebuf __P((ino_t));
-int setup __P((char *dev));
-void voidquit __P((int));
diff --git a/sbin/fsck_ifs/fsck_ifs.8 b/sbin/fsck_ifs/fsck_ifs.8
deleted file mode 100644
index 59d7fa8d1a47..000000000000
--- a/sbin/fsck_ifs/fsck_ifs.8
+++ /dev/null
@@ -1,321 +0,0 @@
-.\"
-.\" Copyright (c) 1980, 1989, 1991, 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. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgment:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. 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.
-.\"
-.\" @(#)fsck.8 8.4 (Berkeley) 5/9/95
-.\" $FreeBSD$
-.\"
-.Dd November 15, 1996
-.Dt FSCK 8
-.Os BSD 4
-.Sh NAME
-.Nm fsck
-.Nd filesystem consistency check and interactive repair
-.Sh SYNOPSIS
-.Nm fsck
-.Fl p
-.Op Fl f
-.Op Fl m Ar mode
-.Op Ar filesystem
-.Ar ...
-.Nm fsck
-.Op Fl ny
-.Op Fl b Ar block#
-.Op Fl c Ar level
-.Op Fl l Ar maxparallel
-.Op Fl m Ar mode
-.Op Ar filesystem
-.Ar ...
-.Sh DESCRIPTION
-The first form of
-.Nm
-preens a standard set of filesystems or the specified filesystems.
-It is normally used in the script
-.Pa /etc/rc
-during automatic reboot.
-Here
-.Nm
-reads the table
-.Pa /etc/fstab
-to determine which filesystems to check.
-Only partitions in fstab that are mounted ``rw,'' ``rq'' or ``ro''
-and that have non-zero pass number are checked.
-Filesystems with pass number 1 (normally just the root filesystem)
-are checked one at a time.
-When pass 1 completes, all remaining filesystems are checked,
-running one process per disk drive.
-The disk drive containing each filesystem is inferred from the longest prefix
-of the device name that ends in a digit; the remaining characters are assumed
-to be the partition designator.
-.Pp
-In "preen" mode the clean flag of each filesystem's superblock is examined
-and only those filesystems that
-are not marked clean are checked.
-Filesystems are marked clean when they are unmounted,
-when they have been mounted read-only, or when
-.Nm
-runs on them successfully.
-If the
-.Fl f
-option is specified, the filesystems
-will be checked regardless of the state of their clean flag.
-.Pp
-The kernel takes care that only a restricted class of innocuous filesystem
-inconsistencies can happen unless hardware or software failures intervene.
-These are limited to the following:
-.Pp
-.Bl -item -compact -offset indent
-.It
-Unreferenced inodes
-.It
-Link counts in inodes too large
-.It
-Missing blocks in the free map
-.It
-Blocks in the free map also in files
-.It
-Counts in the super-block wrong
-.El
-.Pp
-These are the only inconsistencies that
-.Nm
-with the
-.Fl p
-option will correct; if it encounters other inconsistencies, it exits
-with an abnormal return status and an automatic reboot will then fail.
-For each corrected inconsistency one or more lines will be printed
-identifying the filesystem on which the correction will take place,
-and the nature of the correction. After successfully correcting a filesystem,
-.Nm
-will print the number of files on that filesystem,
-the number of used and free blocks,
-and the percentage of fragmentation.
-.Pp
-If sent a
-.Dv QUIT
-signal,
-.Nm
-will finish the filesystem checks, then exit with an abnormal
-return status that causes an automatic reboot to fail.
-This is useful when you want to finish the filesystem checks during an
-automatic reboot,
-but do not want the machine to come up multiuser after the checks complete.
-.Pp
-Without the
-.Fl p
-option,
-.Nm
-audits and interactively repairs inconsistent conditions for filesystems.
-If the filesystem is inconsistent the operator is prompted for concurrence
-before each correction is attempted.
-It should be noted that some of the corrective actions which are not
-correctable under the
-.Fl p
-option will result in some loss of data.
-The amount and severity of data lost may be determined from the diagnostic
-output.
-The default action for each consistency correction
-is to wait for the operator to respond
-.Li yes
-or
-.Li no .
-If the operator does not have write permission on the filesystem
-.Nm
-will default to a
-.Fl n
-action.
-.Pp
-.Nm Fsck
-has more consistency checks than
-its predecessors
-.Em check , dcheck , fcheck ,
-and
-.Em icheck
-combined.
-.Pp
-The following flags are interpreted by
-.Nm Ns .
-.Bl -tag -width indent
-.It Fl b
-Use the block specified immediately after the flag as
-the super block for the filesystem. Block 32 is usually
-an alternate super block.
-.It Fl c
-Convert the filesystem to the specified level.
-Note that the level of a filesystem can only be raised.
-.Bl -tag -width indent
-There are currently four levels defined:
-.It 0
-The filesystem is in the old (static table) format.
-.It 1
-The filesystem is in the new (dynamic table) format.
-.It 2
-The filesystem supports 32-bit uid's and gid's,
-short symbolic links are stored in the inode,
-and directories have an added field showing the file type.
-.It 3
-If maxcontig is greater than one,
-build the free segment maps to aid in finding contiguous sets of blocks.
-If maxcontig is equal to one, delete any existing segment maps.
-.El
-.Pp
-In interactive mode,
-.Nm
-will list the conversion to be made
-and ask whether the conversion should be done.
-If a negative answer is given,
-no further operations are done on the filesystem.
-In preen mode,
-the conversion is listed and done if
-possible without user interaction.
-Conversion in preen mode is best used when all the filesystems
-are being converted at once.
-The format of a filesystem can be determined from the
-first line of output from
-.Xr dumpfs 8 .
-.It Fl f
-Force
-.Nm fsck
-to check
-.Sq clean
-filesystems when preening.
-.It Fl l
-Limit the number of parallel checks to the number specified in the following
-argument.
-By default, the limit is the number of disks, running one process per disk.
-If a smaller limit is given, the disks are checked round-robin, one filesystem
-at a time.
-.It Fl m
-Use the mode specified in octal immediately after the flag as the
-permission bits to use when creating the
-.Pa lost+found
-directory rather than the default 1777.
-In particular, systems that do not wish to have lost files accessible
-by all users on the system should use a more restrictive
-set of permissions such as 700.
-.It Fl n
-Assume a no response to all questions asked by
-.Nm
-except for
-.Ql CONTINUE? ,
-which is assumed to be affirmative;
-do not open the filesystem for writing.
-.It Fl p
-Preen filesystems (see above).
-.It Fl y
-Assume a yes response to all questions asked by
-.Nm Ns ;
-this should be used with great caution as this is a free license
-to continue after essentially unlimited trouble has been encountered.
-.El
-.Pp
-If no filesystems are given to
-.Nm
-then a default list of filesystems is read from
-the file
-.Pa /etc/fstab .
-.Pp
-.Bl -enum -indent indent -compact
-Inconsistencies checked are as follows:
-.It
-Blocks claimed by more than one inode or the free map.
-.It
-Blocks claimed by an inode outside the range of the filesystem.
-.It
-Incorrect link counts.
-.It
-Size checks:
-.Bl -item -indent indent -compact
-.It
-Directory size not a multiple of DIRBLKSIZ.
-.It
-Partially truncated file.
-.El
-.It
-Bad inode format.
-.It
-Blocks not accounted for anywhere.
-.It
-Directory checks:
-.Bl -item -indent indent -compact
-.It
-File pointing to unallocated inode.
-.It
-Inode number out of range.
-.It
-Directories with unallocated blocks (holes).
-.It
-Dot or dot-dot not the first two entries of a directory
-or having the wrong inode number.
-.El
-.It
-Super Block checks:
-.Bl -item -indent indent -compact
-.It
-More blocks for inodes than there are in the filesystem.
-.It
-Bad free block map format.
-.It
-Total free block and/or free inode count incorrect.
-.El
-.El
-.Pp
-Orphaned files and directories (allocated but unreferenced) are,
-with the operator's concurrence, reconnected by
-placing them in the
-.Pa lost+found
-directory.
-The name assigned is the inode number.
-If the
-.Pa lost+found
-directory does not exist, it is created.
-If there is insufficient space its size is increased.
-.Pp
-Because of inconsistencies between the block device and the buffer cache,
-the raw device should always be used.
-.Sh FILES
-.Bl -tag -width /etc/fstab -compact
-.It Pa /etc/fstab
-contains default list of filesystems to check.
-.El
-.Sh DIAGNOSTICS
-The diagnostics produced by
-.Nm
-are fully enumerated and explained in Appendix A of
-.Rs
-.%T "Fsck \- The UNIX File System Check Program"
-.Re
-.Sh SEE ALSO
-.Xr fs 5 ,
-.Xr fstab 5 ,
-.Xr fsdb 8 ,
-.Xr newfs 8 ,
-.Xr reboot 8
diff --git a/sbin/fsck_ifs/inode.c b/sbin/fsck_ifs/inode.c
deleted file mode 100644
index dbf86f760f81..000000000000
--- a/sbin/fsck_ifs/inode.c
+++ /dev/null
@@ -1,666 +0,0 @@
-/*
- * Copyright (c) 1980, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-#if 0
-static const char sccsid[] = "@(#)inode.c 8.8 (Berkeley) 4/28/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <sys/param.h>
-#include <sys/time.h>
-
-#include <ufs/ufs/dinode.h>
-#include <ufs/ufs/dir.h>
-#include <ufs/ffs/fs.h>
-
-#include <err.h>
-#include <pwd.h>
-#include <string.h>
-
-#include "fsck.h"
-
-static ino_t startinum;
-
-static int iblock __P((struct inodesc *, long ilevel, quad_t isize));
-
-int
-ckinode(dp, idesc)
- struct dinode *dp;
- register struct inodesc *idesc;
-{
- ufs_daddr_t *ap;
- int ret;
- long n, ndb, offset;
- struct dinode dino;
- quad_t remsize, sizepb;
- mode_t mode;
- char pathbuf[MAXPATHLEN + 1];
-
- if (idesc->id_fix != IGNORE)
- idesc->id_fix = DONTKNOW;
- idesc->id_entryno = 0;
- idesc->id_filesize = dp->di_size;
- mode = dp->di_mode & IFMT;
- if (mode == IFBLK || mode == IFCHR || (mode == IFLNK &&
- dp->di_size < (unsigned)sblock.fs_maxsymlinklen))
- return (KEEPON);
- dino = *dp;
- ndb = howmany(dino.di_size, sblock.fs_bsize);
- for (ap = &dino.di_db[0]; ap < &dino.di_db[NDADDR]; ap++) {
- if (--ndb == 0 && (offset = blkoff(&sblock, dino.di_size)) != 0)
- idesc->id_numfrags =
- numfrags(&sblock, fragroundup(&sblock, offset));
- else
- idesc->id_numfrags = sblock.fs_frag;
- if (*ap == 0) {
- if (idesc->id_type == DATA && ndb >= 0) {
- /* An empty block in a directory XXX */
- getpathname(pathbuf, idesc->id_number,
- idesc->id_number);
- pfatal("DIRECTORY %s: CONTAINS EMPTY BLOCKS",
- pathbuf);
- if (reply("ADJUST LENGTH") == 1) {
- dp = ginode(idesc->id_number);
- dp->di_size = (ap - &dino.di_db[0]) *
- sblock.fs_bsize;
- printf(
- "YOU MUST RERUN FSCK AFTERWARDS\n");
- rerun = 1;
- inodirty();
-
- }
- }
- continue;
- }
- idesc->id_blkno = *ap;
- if (idesc->id_type == ADDR)
- ret = (*idesc->id_func)(idesc);
- else
- ret = dirscan(idesc);
- if (ret & STOP)
- return (ret);
- }
- idesc->id_numfrags = sblock.fs_frag;
- remsize = dino.di_size - sblock.fs_bsize * NDADDR;
- sizepb = sblock.fs_bsize;
- for (ap = &dino.di_ib[0], n = 1; n <= NIADDR; ap++, n++) {
- if (*ap) {
- idesc->id_blkno = *ap;
- ret = iblock(idesc, n, remsize);
- if (ret & STOP)
- return (ret);
- } else {
- if (idesc->id_type == DATA && remsize > 0) {
- /* An empty block in a directory XXX */
- getpathname(pathbuf, idesc->id_number,
- idesc->id_number);
- pfatal("DIRECTORY %s: CONTAINS EMPTY BLOCKS",
- pathbuf);
- if (reply("ADJUST LENGTH") == 1) {
- dp = ginode(idesc->id_number);
- dp->di_size -= remsize;
- remsize = 0;
- printf(
- "YOU MUST RERUN FSCK AFTERWARDS\n");
- rerun = 1;
- inodirty();
- break;
- }
- }
- }
- sizepb *= NINDIR(&sblock);
- remsize -= sizepb;
- }
- return (KEEPON);
-}
-
-static int
-iblock(idesc, ilevel, isize)
- struct inodesc *idesc;
- long ilevel;
- quad_t isize;
-{
- ufs_daddr_t *ap;
- ufs_daddr_t *aplim;
- struct bufarea *bp;
- int i, n, (*func)(), nif;
- quad_t sizepb;
- char buf[BUFSIZ];
- char pathbuf[MAXPATHLEN + 1];
- struct dinode *dp;
-
- if (idesc->id_type == ADDR) {
- func = idesc->id_func;
- if (((n = (*func)(idesc)) & KEEPON) == 0)
- return (n);
- } else
- func = dirscan;
- if (chkrange(idesc->id_blkno, idesc->id_numfrags))
- return (SKIP);
- bp = getdatablk(idesc->id_blkno, sblock.fs_bsize);
- ilevel--;
- for (sizepb = sblock.fs_bsize, i = 0; i < ilevel; i++)
- sizepb *= NINDIR(&sblock);
- nif = howmany(isize , sizepb);
- if (nif > NINDIR(&sblock))
- nif = NINDIR(&sblock);
- if (idesc->id_func == pass1check && nif < NINDIR(&sblock)) {
- aplim = &bp->b_un.b_indir[NINDIR(&sblock)];
- for (ap = &bp->b_un.b_indir[nif]; ap < aplim; ap++) {
- if (*ap == 0)
- continue;
- (void)sprintf(buf, "PARTIALLY TRUNCATED INODE I=%lu",
- (u_long)idesc->id_number);
- if (dofix(idesc, buf)) {
- *ap = 0;
- dirty(bp);
- }
- }
- flush(fswritefd, bp);
- }
- aplim = &bp->b_un.b_indir[nif];
- for (ap = bp->b_un.b_indir; ap < aplim; ap++) {
- if (*ap) {
- idesc->id_blkno = *ap;
- if (ilevel == 0)
- n = (*func)(idesc);
- else
- n = iblock(idesc, ilevel, isize);
- if (n & STOP) {
- bp->b_flags &= ~B_INUSE;
- return (n);
- }
- } else {
- if (idesc->id_type == DATA && isize > 0) {
- /* An empty block in a directory XXX */
- getpathname(pathbuf, idesc->id_number,
- idesc->id_number);
- pfatal("DIRECTORY %s: CONTAINS EMPTY BLOCKS",
- pathbuf);
- if (reply("ADJUST LENGTH") == 1) {
- dp = ginode(idesc->id_number);
- dp->di_size -= isize;
- isize = 0;
- printf(
- "YOU MUST RERUN FSCK AFTERWARDS\n");
- rerun = 1;
- inodirty();
- bp->b_flags &= ~B_INUSE;
- return(STOP);
- }
- }
- }
- isize -= sizepb;
- }
- bp->b_flags &= ~B_INUSE;
- return (KEEPON);
-}
-
-/*
- * Check that a block in a legal block number.
- * Return 0 if in range, 1 if out of range.
- */
-int
-chkrange(blk, cnt)
- ufs_daddr_t blk;
- int cnt;
-{
- register int c;
-
- if (cnt <= 0 || blk <= 0 || blk > maxfsblock ||
- cnt - 1 > maxfsblock - blk)
- return (1);
- if (cnt > sblock.fs_frag ||
- fragnum(&sblock, blk) + cnt > sblock.fs_frag) {
- if (debug)
- printf("bad size: blk %ld, offset %ld, size %ld\n",
- blk, fragnum(&sblock, blk), cnt);
- return (1);
- }
- c = dtog(&sblock, blk);
- if (blk < cgdmin(&sblock, c)) {
- if ((blk + cnt) > cgsblock(&sblock, c)) {
- if (debug) {
- printf("blk %ld < cgdmin %ld;",
- (long)blk, (long)cgdmin(&sblock, c));
- printf(" blk + cnt %ld > cgsbase %ld\n",
- (long)(blk + cnt),
- (long)cgsblock(&sblock, c));
- }
- return (1);
- }
- } else {
- if ((blk + cnt) > cgbase(&sblock, c+1)) {
- if (debug) {
- printf("blk %ld >= cgdmin %ld;",
- (long)blk, (long)cgdmin(&sblock, c));
- printf(" blk + cnt %ld > sblock.fs_fpg %ld\n",
- (long)(blk + cnt), (long)sblock.fs_fpg);
- }
- return (1);
- }
- }
- return (0);
-}
-
-/*
- * General purpose interface for reading inodes.
- */
-struct dinode *
-ginode(inumber)
- ino_t inumber;
-{
- ufs_daddr_t iblk;
-
- if (inumber < ROOTINO || inumber > maxino)
- errx(EEXIT, "bad inode number %d to ginode", inumber);
- if (startinum == 0 ||
- inumber < startinum || inumber >= startinum + INOPB(&sblock)) {
- iblk = ino_to_fsba(&sblock, inumber);
- if (pbp != 0)
- pbp->b_flags &= ~B_INUSE;
- pbp = getdatablk(iblk, sblock.fs_bsize);
- startinum = (inumber / INOPB(&sblock)) * INOPB(&sblock);
- }
- return (&pbp->b_un.b_dinode[inumber % INOPB(&sblock)]);
-}
-
-/*
- * Special purpose version of ginode used to optimize first pass
- * over all the inodes in numerical order.
- */
-ino_t nextino, lastinum;
-long readcnt, readpercg, fullcnt, inobufsize, partialcnt, partialsize;
-struct dinode *inodebuf;
-
-struct dinode *
-getnextinode(inumber)
- ino_t inumber;
-{
- long size;
- ufs_daddr_t dblk;
- static struct dinode *dp;
-
- if (inumber != nextino++ || inumber > maxino)
- errx(EEXIT, "bad inode number %d to nextinode", inumber);
- if (inumber >= lastinum) {
- readcnt++;
- dblk = fsbtodb(&sblock, ino_to_fsba(&sblock, lastinum));
- if (readcnt % readpercg == 0) {
- size = partialsize;
- lastinum += partialcnt;
- } else {
- size = inobufsize;
- lastinum += fullcnt;
- }
- /*
- * If bread returns an error, it will already have zeroed
- * out the buffer, so we do not need to do so here.
- */
- (void)bread(fsreadfd, (char *)inodebuf, dblk, size);
- dp = inodebuf;
- }
- return (dp++);
-}
-
-void
-setinodebuf(inum)
- ino_t inum;
-{
-
- if (inum % sblock.fs_ipg != 0)
- errx(EEXIT, "bad inode number %d to setinodebuf", inum);
- startinum = 0;
- nextino = inum;
- lastinum = inum;
- readcnt = 0;
- if (inodebuf != NULL)
- return;
- inobufsize = blkroundup(&sblock, INOBUFSIZE);
- fullcnt = inobufsize / sizeof(struct dinode);
- readpercg = sblock.fs_ipg / fullcnt;
- partialcnt = sblock.fs_ipg % fullcnt;
- partialsize = partialcnt * sizeof(struct dinode);
- if (partialcnt != 0) {
- readpercg++;
- } else {
- partialcnt = fullcnt;
- partialsize = inobufsize;
- }
- if ((inodebuf = (struct dinode *)malloc((unsigned)inobufsize)) == NULL)
- errx(EEXIT, "cannot allocate space for inode buffer");
-}
-
-void
-freeinodebuf()
-{
-
- if (inodebuf != NULL)
- free((char *)inodebuf);
- inodebuf = NULL;
-}
-
-/*
- * Routines to maintain information about directory inodes.
- * This is built during the first pass and used during the
- * second and third passes.
- *
- * Enter inodes into the cache.
- */
-void
-cacheino(dp, inumber)
- register struct dinode *dp;
- ino_t inumber;
-{
- register struct inoinfo *inp;
- struct inoinfo **inpp;
- int blks;
-
- blks = howmany(dp->di_size, sblock.fs_bsize);
- if (blks > NDADDR)
- blks = NDADDR + NIADDR;
- inp = (struct inoinfo *)
- malloc(sizeof(*inp) + (blks - 1) * sizeof(ufs_daddr_t));
- if (inp == NULL)
- errx(EEXIT, "cannot increase directory list");
- inpp = &inphead[inumber % dirhash];
- inp->i_nexthash = *inpp;
- *inpp = inp;
- inp->i_parent = inumber == ROOTINO ? ROOTINO : (ino_t)0;
- inp->i_dotdot = (ino_t)0;
- inp->i_number = inumber;
- inp->i_isize = dp->di_size;
- inp->i_numblks = blks * sizeof(ufs_daddr_t);
- memmove(&inp->i_blks[0], &dp->di_db[0], (size_t)inp->i_numblks);
- if (inplast == listmax) {
- listmax += 100;
- inpsort = (struct inoinfo **)realloc((char *)inpsort,
- (unsigned)listmax * sizeof(struct inoinfo *));
- if (inpsort == NULL)
- errx(EEXIT, "cannot increase directory list");
- }
- inpsort[inplast++] = inp;
-}
-
-/*
- * Look up an inode cache structure.
- */
-struct inoinfo *
-getinoinfo(inumber)
- ino_t inumber;
-{
- register struct inoinfo *inp;
-
- for (inp = inphead[inumber % dirhash]; inp; inp = inp->i_nexthash) {
- if (inp->i_number != inumber)
- continue;
- return (inp);
- }
- errx(EEXIT, "cannot find inode %d", inumber);
- return ((struct inoinfo *)0);
-}
-
-/*
- * Clean up all the inode cache structure.
- */
-void
-inocleanup()
-{
- register struct inoinfo **inpp;
-
- if (inphead == NULL)
- return;
- for (inpp = &inpsort[inplast - 1]; inpp >= inpsort; inpp--)
- free((char *)(*inpp));
- free((char *)inphead);
- free((char *)inpsort);
- inphead = inpsort = NULL;
-}
-
-void
-inodirty()
-{
-
- dirty(pbp);
-}
-
-void
-clri(idesc, type, flag)
- register struct inodesc *idesc;
- char *type;
- int flag;
-{
- register struct dinode *dp;
-
- dp = ginode(idesc->id_number);
- if (flag == 1) {
- pwarn("%s %s", type,
- (dp->di_mode & IFMT) == IFDIR ? "DIR" : "FILE");
- pinode(idesc->id_number);
- }
- if (preen || reply("CLEAR") == 1) {
- if (preen)
- printf(" (CLEARED)\n");
- n_files--;
- (void)ckinode(dp, idesc);
- clearinode(dp);
- inoinfo(idesc->id_number)->ino_state = USTATE;
- inodirty();
- }
-}
-
-int
-findname(idesc)
- struct inodesc *idesc;
-{
- register struct direct *dirp = idesc->id_dirp;
-
- if (dirp->d_ino != idesc->id_parent || idesc->id_entryno < 2) {
- idesc->id_entryno++;
- return (KEEPON);
- }
- memmove(idesc->id_name, dirp->d_name, (size_t)dirp->d_namlen + 1);
- return (STOP|FOUND);
-}
-
-int
-findino(idesc)
- struct inodesc *idesc;
-{
- register struct direct *dirp = idesc->id_dirp;
-
- if (dirp->d_ino == 0)
- return (KEEPON);
- if (strcmp(dirp->d_name, idesc->id_name) == 0 &&
- dirp->d_ino >= ROOTINO && dirp->d_ino <= maxino) {
- idesc->id_parent = dirp->d_ino;
- return (STOP|FOUND);
- }
- return (KEEPON);
-}
-
-int
-clearentry(idesc)
- struct inodesc *idesc;
-{
- register struct direct *dirp = idesc->id_dirp;
-
- if (dirp->d_ino != idesc->id_parent || idesc->id_entryno < 2) {
- idesc->id_entryno++;
- return (KEEPON);
- }
- dirp->d_ino = 0;
- return (STOP|FOUND|ALTERED);
-}
-
-void
-pinode(ino)
- ino_t ino;
-{
- register struct dinode *dp;
- register char *p;
- struct passwd *pw;
- time_t t;
-
- printf(" I=%lu ", (u_long)ino);
- if (ino < ROOTINO || ino > maxino)
- return;
- dp = ginode(ino);
- printf(" OWNER=");
- if ((pw = getpwuid((int)dp->di_uid)) != 0)
- printf("%s ", pw->pw_name);
- else
- printf("%u ", (unsigned)dp->di_uid);
- printf("MODE=%o\n", dp->di_mode);
- if (preen)
- printf("%s: ", cdevname);
- printf("SIZE=%qu ", dp->di_size);
- t = dp->di_mtime;
- p = ctime(&t);
- printf("MTIME=%12.12s %4.4s ", &p[4], &p[20]);
-}
-
-void
-blkerror(ino, type, blk)
- ino_t ino;
- char *type;
- ufs_daddr_t blk;
-{
-
- pfatal("%ld %s I=%lu", blk, type, ino);
- printf("\n");
- switch (inoinfo(ino)->ino_state) {
-
- case FSTATE:
- inoinfo(ino)->ino_state = FCLEAR;
- return;
-
- case DSTATE:
- inoinfo(ino)->ino_state = DCLEAR;
- return;
-
- case FCLEAR:
- case DCLEAR:
- return;
-
- default:
- errx(EEXIT, "BAD STATE %d TO BLKERR", inoinfo(ino)->ino_state);
- /* NOTREACHED */
- }
-}
-
-/*
- * allocate an unused inode
- */
-ino_t
-allocino(request, type)
- ino_t request;
- int type;
-{
- register ino_t ino;
- register struct dinode *dp;
- struct cg *cgp = &cgrp;
- int cg;
-
- if (request == 0)
- request = ROOTINO;
- else if (inoinfo(request)->ino_state != USTATE)
- return (0);
- for (ino = request; ino < maxino; ino++)
- if (inoinfo(ino)->ino_state == USTATE)
- break;
- if (ino == maxino)
- return (0);
- cg = ino_to_cg(&sblock, ino);
- getblk(&cgblk, cgtod(&sblock, cg), sblock.fs_cgsize);
- if (!cg_chkmagic(cgp))
- pfatal("CG %d: BAD MAGIC NUMBER\n", cg);
- setbit(cg_inosused(cgp), ino % sblock.fs_ipg);
- cgp->cg_cs.cs_nifree--;
- switch (type & IFMT) {
- case IFDIR:
- inoinfo(ino)->ino_state = DSTATE;
- cgp->cg_cs.cs_ndir++;
- break;
- case IFREG:
- case IFLNK:
- inoinfo(ino)->ino_state = FSTATE;
- break;
- default:
- return (0);
- }
- cgdirty();
- dp = ginode(ino);
- dp->di_db[0] = allocblk((long)1);
- if (dp->di_db[0] == 0) {
- inoinfo(ino)->ino_state = USTATE;
- return (0);
- }
- dp->di_mode = type;
- dp->di_flags = 0;
- dp->di_atime = time(NULL);
- dp->di_mtime = dp->di_ctime = dp->di_atime;
- dp->di_mtimensec = dp->di_ctimensec = dp->di_atimensec = 0;
- dp->di_size = sblock.fs_fsize;
- dp->di_blocks = btodb(sblock.fs_fsize);
- n_files++;
- inodirty();
- if (newinofmt)
- inoinfo(ino)->ino_type = IFTODT(type);
- return (ino);
-}
-
-/*
- * deallocate an inode
- */
-void
-freeino(ino)
- ino_t ino;
-{
- struct inodesc idesc;
- struct dinode *dp;
-
- memset(&idesc, 0, sizeof(struct inodesc));
- idesc.id_type = ADDR;
- idesc.id_func = pass4check;
- idesc.id_number = ino;
- dp = ginode(ino);
- (void)ckinode(dp, &idesc);
- clearinode(dp);
- inodirty();
- inoinfo(ino)->ino_state = USTATE;
- n_files--;
-}
diff --git a/sbin/fsck_ifs/main.c b/sbin/fsck_ifs/main.c
deleted file mode 100644
index 6463990b5e6f..000000000000
--- a/sbin/fsck_ifs/main.c
+++ /dev/null
@@ -1,417 +0,0 @@
-/*
- * Copyright (c) 1980, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-static const char copyright[] =
-"@(#) Copyright (c) 1980, 1986, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/14/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/mount.h>
-#include <sys/resource.h>
-
-#include <ufs/ufs/dinode.h>
-#include <ufs/ufs/ufsmount.h>
-#include <ufs/ffs/fs.h>
-
-#include <err.h>
-#include <errno.h>
-#include <fstab.h>
-#include <paths.h>
-
-#include "fsck.h"
-
-static int argtoi __P((int flag, char *req, char *str, int base));
-static int docheck __P((struct fstab *fsp));
-static int checkfilesys __P((char *filesys, char *mntpt, long auxdata,
- int child));
-static struct statfs *getmntpt __P((const char *));
-int main __P((int argc, char *argv[]));
-
-int
-main(argc, argv)
- int argc;
- char *argv[];
-{
- int ch;
- int ret, maxrun = 0;
- struct rlimit rlimit;
-
- sync();
- while ((ch = getopt(argc, argv, "dfpnNyYb:c:l:m:")) != -1) {
- switch (ch) {
- case 'p':
- preen++;
- break;
-
- case 'b':
- bflag = argtoi('b', "number", optarg, 10);
- printf("Alternate super block location: %d\n", bflag);
- break;
-
- case 'c':
- cvtlevel = argtoi('c', "conversion level", optarg, 10);
- break;
-
- case 'd':
- debug++;
- break;
-
- case 'f':
- fflag++;
- break;
-
- case 'l':
- maxrun = argtoi('l', "number", optarg, 10);
- break;
-
- case 'm':
- lfmode = argtoi('m', "mode", optarg, 8);
- if (lfmode &~ 07777)
- errx(EEXIT, "bad mode to -m: %o", lfmode);
- printf("** lost+found creation mode %o\n", lfmode);
- break;
-
- case 'n':
- case 'N':
- nflag++;
- yflag = 0;
- break;
-
- case 'y':
- case 'Y':
- yflag++;
- nflag = 0;
- break;
-
- default:
- errx(EEXIT, "%c option?", ch);
- }
- }
- argc -= optind;
- argv += optind;
- if (signal(SIGINT, SIG_IGN) != SIG_IGN)
- (void)signal(SIGINT, catch);
- if (preen)
- (void)signal(SIGQUIT, catchquit);
- /*
- * Push up our allowed memory limit so we can cope
- * with huge filesystems.
- */
- if (getrlimit(RLIMIT_DATA, &rlimit) == 0) {
- rlimit.rlim_cur = rlimit.rlim_max;
- (void)setrlimit(RLIMIT_DATA, &rlimit);
- }
- if (argc) {
- while (argc-- > 0) {
- char *path = blockcheck(*argv);
-
- if (path == NULL)
- pfatal("Can't check %s\n", *argv);
- else
- (void)checkfilesys(path, 0, 0L, 0);
- ++argv;
- }
- exit(0);
- }
- ret = checkfstab(preen, maxrun, docheck, checkfilesys);
- if (returntosingle)
- exit(2);
- exit(ret);
-}
-
-static int
-argtoi(flag, req, str, base)
- int flag;
- char *req, *str;
- int base;
-{
- char *cp;
- int ret;
-
- ret = (int)strtol(str, &cp, base);
- if (cp == str || *cp)
- errx(EEXIT, "-%c flag requires a %s", flag, req);
- return (ret);
-}
-
-/*
- * Determine whether a filesystem should be checked.
- */
-static int
-docheck(fsp)
- register struct fstab *fsp;
-{
-
- if (strcmp(fsp->fs_vfstype, "ufs") ||
- (strcmp(fsp->fs_type, FSTAB_RW) &&
- strcmp(fsp->fs_type, FSTAB_RO)) ||
- fsp->fs_passno == 0)
- return (0);
- return (1);
-}
-
-/*
- * Check the specified filesystem.
- */
-/* ARGSUSED */
-static int
-checkfilesys(filesys, mntpt, auxdata, child)
- char *filesys, *mntpt;
- long auxdata;
- int child;
-{
- ufs_daddr_t n_ffree, n_bfree;
- struct dups *dp;
- struct statfs *mntbuf;
- struct zlncnt *zlnp;
- int cylno;
-
- if (preen && child)
- (void)signal(SIGQUIT, voidquit);
- cdevname = filesys;
- if (debug && preen)
- pwarn("starting\n");
- switch (setup(filesys)) {
- case 0:
- if (preen)
- pfatal("CAN'T CHECK FILE SYSTEM.");
- return (0);
- case -1:
- pwarn("clean, %ld free ", sblock.fs_cstotal.cs_nffree +
- sblock.fs_frag * sblock.fs_cstotal.cs_nbfree);
- printf("(%d frags, %d blocks, %.1f%% fragmentation)\n",
- sblock.fs_cstotal.cs_nffree, sblock.fs_cstotal.cs_nbfree,
- sblock.fs_cstotal.cs_nffree * 100.0 / sblock.fs_dsize);
- return (0);
- }
-
- /*
- * Get the mount point information of the filesystem, if
- * it is available.
- */
- mntbuf = getmntpt(filesys);
-
- /*
- * Cleared if any questions answered no. Used to decide if
- * the superblock should be marked clean.
- */
- resolved = 1;
- /*
- * 1: scan inodes tallying blocks used
- */
- if (preen == 0) {
- printf("** Last Mounted on %s\n", sblock.fs_fsmnt);
- if (mntbuf != NULL && mntbuf->f_flags & MNT_ROOTFS)
- printf("** Root file system\n");
- printf("** Phase 1 - Check Blocks and Sizes\n");
- }
- pass1();
-
- /*
- * 1b: locate first references to duplicates, if any
- */
- if (duplist) {
- if (preen || usedsoftdep)
- pfatal("INTERNAL ERROR: dups with -p");
- printf("** Phase 1b - Rescan For More DUPS\n");
- pass1b();
- }
-
- /*
- * 2: traverse directories from root to mark all connected directories
- */
- if (preen == 0)
- printf("** Phase 2 - Check Pathnames\n");
- pass2();
-
- /*
- * 3: scan inodes looking for disconnected directories
- */
- if (preen == 0)
- printf("** Phase 3 - Check Connectivity\n");
- pass3();
-
- /*
- * 4: scan inodes looking for disconnected files; check reference counts
- */
- if (preen == 0)
- printf("** Phase 4 - Check Reference Counts\n");
- pass4();
-
- /*
- * 5: check and repair resource counts in cylinder groups
- */
- if (preen == 0)
- printf("** Phase 5 - Check Cyl groups\n");
- pass5();
-
- /*
- * print out summary statistics
- */
- n_ffree = sblock.fs_cstotal.cs_nffree;
- n_bfree = sblock.fs_cstotal.cs_nbfree;
- pwarn("%ld files, %ld used, %ld free ",
- n_files, n_blks, n_ffree + sblock.fs_frag * n_bfree);
- printf("(%d frags, %d blocks, %.1f%% fragmentation)\n",
- n_ffree, n_bfree, n_ffree * 100.0 / sblock.fs_dsize);
- if (debug &&
- (n_files -= maxino - ROOTINO - sblock.fs_cstotal.cs_nifree))
- printf("%d files missing\n", n_files);
- if (debug) {
- n_blks += sblock.fs_ncg *
- (cgdmin(&sblock, 0) - cgsblock(&sblock, 0));
- n_blks += cgsblock(&sblock, 0) - cgbase(&sblock, 0);
- n_blks += howmany(sblock.fs_cssize, sblock.fs_fsize);
- if (n_blks -= maxfsblock - (n_ffree + sblock.fs_frag * n_bfree))
- printf("%d blocks missing\n", n_blks);
- if (duplist != NULL) {
- printf("The following duplicate blocks remain:");
- for (dp = duplist; dp; dp = dp->next)
- printf(" %d,", dp->dup);
- printf("\n");
- }
- if (zlnhead != NULL) {
- printf("The following zero link count inodes remain:");
- for (zlnp = zlnhead; zlnp; zlnp = zlnp->next)
- printf(" %u,", zlnp->zlncnt);
- printf("\n");
- }
- }
- zlnhead = (struct zlncnt *)0;
- duplist = (struct dups *)0;
- muldup = (struct dups *)0;
- inocleanup();
- if (fsmodified) {
- sblock.fs_time = time(NULL);
- sbdirty();
- }
- if (cvtlevel && sblk.b_dirty) {
- /*
- * Write out the duplicate super blocks
- */
- for (cylno = 0; cylno < sblock.fs_ncg; cylno++)
- bwrite(fswritefd, (char *)&sblock,
- fsbtodb(&sblock, cgsblock(&sblock, cylno)), SBSIZE);
- }
- if (rerun)
- resolved = 0;
-
- /*
- * Check to see if the filesystem is mounted read-write.
- */
- if (mntbuf != NULL && (mntbuf->f_flags & MNT_RDONLY) == 0)
- resolved = 0;
- ckfini(resolved);
-
- for (cylno = 0; cylno < sblock.fs_ncg; cylno++)
- if (inostathead[cylno].il_stat != NULL)
- free((char *)inostathead[cylno].il_stat);
- free((char *)inostathead);
- inostathead = NULL;
- if (fsmodified && !preen)
- printf("\n***** FILE SYSTEM WAS MODIFIED *****\n");
- if (rerun)
- printf("\n***** PLEASE RERUN FSCK *****\n");
- if (mntbuf != NULL) {
- struct ufs_args args;
- int ret;
- /*
- * We modified a mounted filesystem. Do a mount update on
- * it unless it is read-write, so we can continue using it
- * as safely as possible.
- */
- if (mntbuf->f_flags & MNT_RDONLY) {
- args.fspec = 0;
- args.export.ex_flags = 0;
- args.export.ex_root = 0;
- ret = mount("ufs", mntbuf->f_mntonname,
- mntbuf->f_flags | MNT_UPDATE | MNT_RELOAD, &args);
- if (ret == 0)
- return (0);
- pwarn("mount reload of '%s' failed: %s\n\n",
- mntbuf->f_mntonname, strerror(errno));
- }
- if (!fsmodified)
- return (0);
- if (!preen)
- printf("\n***** REBOOT NOW *****\n");
- sync();
- return (4);
- }
- return (0);
-}
-
-/*
- * Get the directory that the device is mounted on.
- */
-static struct statfs *
-getmntpt(name)
- const char *name;
-{
- struct stat devstat, mntdevstat;
- char device[sizeof(_PATH_DEV) - 1 + MNAMELEN];
- char *devname;
- struct statfs *mntbuf;
- int i, mntsize;
-
- if (stat(name, &devstat) != 0 ||
- !(S_ISCHR(devstat.st_mode) || S_ISBLK(devstat.st_mode)))
- return (NULL);
- mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
- for (i = 0; i < mntsize; i++) {
- if (strcmp(mntbuf[i].f_fstypename, "ufs") != 0)
- continue;
- devname = mntbuf[i].f_mntfromname;
- if (*devname != '/') {
- strcpy(device, _PATH_DEV);
- strcat(device, devname);
- devname = device;
- }
- if (stat(devname, &mntdevstat) == 0 &&
- mntdevstat.st_rdev == devstat.st_rdev)
- return (&mntbuf[i]);
- }
- return (NULL);
-}
diff --git a/sbin/fsck_ifs/pass1.c b/sbin/fsck_ifs/pass1.c
deleted file mode 100644
index dd09b009705e..000000000000
--- a/sbin/fsck_ifs/pass1.c
+++ /dev/null
@@ -1,406 +0,0 @@
-/*
- * Copyright (c) 1980, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-#if 0
-static const char sccsid[] = "@(#)pass1.c 8.6 (Berkeley) 4/28/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <sys/param.h>
-
-#include <ufs/ufs/dinode.h>
-#include <ufs/ufs/dir.h>
-#include <ufs/ffs/fs.h>
-
-#include <err.h>
-#include <string.h>
-
-#include "fsck.h"
-
-static ufs_daddr_t badblk;
-static ufs_daddr_t dupblk;
-static ino_t lastino; /* last inode in use */
-
-static void checkinode __P((ino_t inumber, struct inodesc *));
-
-void
-pass1()
-{
- u_int8_t *cp;
- ino_t inumber;
- int c, i, cgd, inosused;
- struct inostat *info;
- struct inodesc idesc;
-
- /*
- * Set file system reserved blocks in used block map.
- */
- for (c = 0; c < sblock.fs_ncg; c++) {
- cgd = cgdmin(&sblock, c);
- if (c == 0) {
- i = cgbase(&sblock, c);
- cgd += howmany(sblock.fs_cssize, sblock.fs_fsize);
- } else
- i = cgsblock(&sblock, c);
- for (; i < cgd; i++)
- setbmap(i);
- }
- /*
- * Find all allocated blocks.
- */
- memset(&idesc, 0, sizeof(struct inodesc));
- idesc.id_type = ADDR;
- idesc.id_func = pass1check;
- n_files = n_blks = 0;
- for (c = 0; c < sblock.fs_ncg; c++) {
- inumber = c * sblock.fs_ipg;
- setinodebuf(inumber);
- inosused = sblock.fs_ipg;
- /*
- * If we are using soft updates, then we can trust the
- * cylinder group inode allocation maps to tell us which
- * inodes are allocated. We will scan the used inode map
- * to find the inodes that are really in use, and then
- * read only those inodes in from disk.
- */
- if (preen && usedsoftdep) {
- getblk(&cgblk, cgtod(&sblock, c), sblock.fs_cgsize);
- if (!cg_chkmagic(&cgrp))
- pfatal("CG %d: BAD MAGIC NUMBER\n", c);
- cp = &cg_inosused(&cgrp)[(sblock.fs_ipg - 1) / NBBY];
- for ( ; inosused > 0; inosused -= NBBY, cp--) {
- if (*cp == 0)
- continue;
- for (i = 1 << (NBBY - 1); i > 0; i >>= 1) {
- if (*cp & i)
- break;
- inosused--;
- }
- break;
- }
- if (inosused < 0)
- inosused = 0;
- }
- /*
- * Allocate inoinfo structures for the allocated inodes.
- */
- inostathead[c].il_numalloced = inosused;
- if (inosused == 0) {
- inostathead[c].il_stat = 0;
- continue;
- }
- info = calloc((unsigned)inosused, sizeof(struct inostat));
- if (info == NULL)
- pfatal("cannot alloc %u bytes for inoinfo\n",
- (unsigned)(sizeof(struct inostat) * inosused));
- inostathead[c].il_stat = info;
- /*
- * Scan the allocated inodes.
- */
- for (i = 0; i < inosused; i++, inumber++) {
- if (inumber < ROOTINO) {
- (void)getnextinode(inumber);
- continue;
- }
- checkinode(inumber, &idesc);
- }
- lastino += 1;
- if (inosused < sblock.fs_ipg || inumber == lastino)
- continue;
- /*
- * If we were not able to determine in advance which inodes
- * were in use, then reduce the size of the inoinfo structure
- * to the size necessary to describe the inodes that we
- * really found.
- */
- inosused = lastino - (c * sblock.fs_ipg);
- if (inosused < 0)
- inosused = 0;
- inostathead[c].il_numalloced = inosused;
- if (inosused == 0) {
- free(inostathead[c].il_stat);
- inostathead[c].il_stat = 0;
- continue;
- }
- info = calloc((unsigned)inosused, sizeof(struct inostat));
- if (info == NULL)
- pfatal("cannot alloc %u bytes for inoinfo\n",
- (unsigned)(sizeof(struct inostat) * inosused));
- memmove(info, inostathead[c].il_stat, inosused * sizeof(*info));
- free(inostathead[c].il_stat);
- inostathead[c].il_stat = info;
- }
- freeinodebuf();
-}
-
-static void
-checkinode(inumber, idesc)
- ino_t inumber;
- register struct inodesc *idesc;
-{
- register struct dinode *dp;
- struct zlncnt *zlnp;
- int ndb, j;
- mode_t mode;
- char *symbuf;
-
- dp = getnextinode(inumber);
- mode = dp->di_mode & IFMT;
- if (mode == 0) {
- if (memcmp(dp->di_db, zino.di_db,
- NDADDR * sizeof(ufs_daddr_t)) ||
- memcmp(dp->di_ib, zino.di_ib,
- NIADDR * sizeof(ufs_daddr_t)) ||
- dp->di_mode || dp->di_size) {
- pfatal("PARTIALLY ALLOCATED INODE I=%lu", inumber);
- if (reply("CLEAR") == 1) {
- dp = ginode(inumber);
- clearinode(dp);
- inodirty();
- }
- }
- inoinfo(inumber)->ino_state = USTATE;
- return;
- }
- lastino = inumber;
- if (/* dp->di_size < 0 || */
- dp->di_size + sblock.fs_bsize - 1 < dp->di_size ||
- (mode == IFDIR && dp->di_size > MAXDIRSIZE)) {
- if (debug)
- printf("bad size %qu:", dp->di_size);
- goto unknown;
- }
- if (!preen && mode == IFMT && reply("HOLD BAD BLOCK") == 1) {
- dp = ginode(inumber);
- dp->di_size = sblock.fs_fsize;
- dp->di_mode = IFREG|0600;
- inodirty();
- }
- ndb = howmany(dp->di_size, sblock.fs_bsize);
- if (ndb < 0) {
- if (debug)
- printf("bad size %qu ndb %d:",
- dp->di_size, ndb);
- goto unknown;
- }
- if (mode == IFBLK || mode == IFCHR)
- ndb++;
- if (mode == IFLNK) {
- if (doinglevel2 &&
- dp->di_size > 0 && dp->di_size < MAXSYMLINKLEN &&
- dp->di_blocks != 0) {
- symbuf = alloca(secsize);
- if (bread(fsreadfd, symbuf,
- fsbtodb(&sblock, dp->di_db[0]),
- (long)secsize) != 0)
- errx(EEXIT, "cannot read symlink");
- if (debug) {
- symbuf[dp->di_size] = 0;
- printf("convert symlink %lu(%s) of size %ld\n",
- (u_long)inumber, symbuf, (long)dp->di_size);
- }
- dp = ginode(inumber);
- memmove(dp->di_shortlink, symbuf, (long)dp->di_size);
- dp->di_blocks = 0;
- inodirty();
- }
- /*
- * Fake ndb value so direct/indirect block checks below
- * will detect any garbage after symlink string.
- */
- if (dp->di_size < sblock.fs_maxsymlinklen) {
- ndb = howmany(dp->di_size, sizeof(ufs_daddr_t));
- if (ndb > NDADDR) {
- j = ndb - NDADDR;
- for (ndb = 1; j > 1; j--)
- ndb *= NINDIR(&sblock);
- ndb += NDADDR;
- }
- }
- }
- for (j = ndb; j < NDADDR; j++)
- if (dp->di_db[j] != 0) {
- if (debug)
- printf("bad direct addr: %ld\n",
- (long)dp->di_db[j]);
- goto unknown;
- }
- for (j = 0, ndb -= NDADDR; ndb > 0; j++)
- ndb /= NINDIR(&sblock);
- for (; j < NIADDR; j++)
- if (dp->di_ib[j] != 0) {
- if (debug)
- printf("bad indirect addr: %ld\n",
- (long)dp->di_ib[j]);
- goto unknown;
- }
- if (ftypeok(dp) == 0)
- goto unknown;
- n_files++;
- inoinfo(inumber)->ino_linkcnt = dp->di_nlink;
- if (dp->di_nlink <= 0) {
- zlnp = (struct zlncnt *)malloc(sizeof *zlnp);
- if (zlnp == NULL) {
- pfatal("LINK COUNT TABLE OVERFLOW");
- if (reply("CONTINUE") == 0) {
- ckfini(0);
- exit(EEXIT);
- }
- } else {
- zlnp->zlncnt = inumber;
- zlnp->next = zlnhead;
- zlnhead = zlnp;
- }
- }
- if (mode == IFDIR) {
- if (dp->di_size == 0)
- inoinfo(inumber)->ino_state = DCLEAR;
- else
- inoinfo(inumber)->ino_state = DSTATE;
- cacheino(dp, inumber);
- countdirs++;
- } else
- inoinfo(inumber)->ino_state = FSTATE;
- inoinfo(inumber)->ino_type = IFTODT(mode);
- if (doinglevel2 &&
- (dp->di_ouid != (u_short)-1 || dp->di_ogid != (u_short)-1)) {
- dp = ginode(inumber);
- dp->di_uid = dp->di_ouid;
- dp->di_ouid = -1;
- dp->di_gid = dp->di_ogid;
- dp->di_ogid = -1;
- inodirty();
- }
- badblk = dupblk = 0;
- idesc->id_number = inumber;
- (void)ckinode(dp, idesc);
- idesc->id_entryno *= btodb(sblock.fs_fsize);
- if (dp->di_blocks != idesc->id_entryno) {
- pwarn("INCORRECT BLOCK COUNT I=%lu (%ld should be %ld)",
- inumber, dp->di_blocks, idesc->id_entryno);
- if (preen)
- printf(" (CORRECTED)\n");
- else if (reply("CORRECT") == 0)
- return;
- dp = ginode(inumber);
- dp->di_blocks = idesc->id_entryno;
- inodirty();
- }
- return;
-unknown:
- pfatal("UNKNOWN FILE TYPE I=%lu", inumber);
- inoinfo(inumber)->ino_state = FCLEAR;
- if (reply("CLEAR") == 1) {
- inoinfo(inumber)->ino_state = USTATE;
- dp = ginode(inumber);
- clearinode(dp);
- inodirty();
- }
-}
-
-int
-pass1check(idesc)
- register struct inodesc *idesc;
-{
- int res = KEEPON;
- int anyout, nfrags;
- ufs_daddr_t blkno = idesc->id_blkno;
- register struct dups *dlp;
- struct dups *new;
-
- if ((anyout = chkrange(blkno, idesc->id_numfrags)) != 0) {
- blkerror(idesc->id_number, "BAD", blkno);
- if (badblk++ >= MAXBAD) {
- pwarn("EXCESSIVE BAD BLKS I=%lu",
- idesc->id_number);
- if (preen)
- printf(" (SKIPPING)\n");
- else if (reply("CONTINUE") == 0) {
- ckfini(0);
- exit(EEXIT);
- }
- return (STOP);
- }
- }
- for (nfrags = idesc->id_numfrags; nfrags > 0; blkno++, nfrags--) {
- if (anyout && chkrange(blkno, 1)) {
- res = SKIP;
- } else if (!testbmap(blkno)) {
- n_blks++;
- setbmap(blkno);
- } else {
- blkerror(idesc->id_number, "DUP", blkno);
- if (dupblk++ >= MAXDUP) {
- pwarn("EXCESSIVE DUP BLKS I=%lu",
- idesc->id_number);
- if (preen)
- printf(" (SKIPPING)\n");
- else if (reply("CONTINUE") == 0) {
- ckfini(0);
- exit(EEXIT);
- }
- return (STOP);
- }
- new = (struct dups *)malloc(sizeof(struct dups));
- if (new == NULL) {
- pfatal("DUP TABLE OVERFLOW.");
- if (reply("CONTINUE") == 0) {
- ckfini(0);
- exit(EEXIT);
- }
- return (STOP);
- }
- new->dup = blkno;
- if (muldup == 0) {
- duplist = muldup = new;
- new->next = 0;
- } else {
- new->next = muldup->next;
- muldup->next = new;
- }
- for (dlp = duplist; dlp != muldup; dlp = dlp->next)
- if (dlp->dup == blkno)
- break;
- if (dlp == muldup && dlp->dup != blkno)
- muldup = new;
- }
- /*
- * count the number of blocks found in id_entryno
- */
- idesc->id_entryno++;
- }
- return (res);
-}
diff --git a/sbin/fsck_ifs/pass1b.c b/sbin/fsck_ifs/pass1b.c
deleted file mode 100644
index 7ef662f27364..000000000000
--- a/sbin/fsck_ifs/pass1b.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (c) 1980, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-#if 0
-static const char sccsid[] = "@(#)pass1b.c 8.4 (Berkeley) 4/28/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <sys/param.h>
-
-#include <ufs/ufs/dinode.h>
-#include <ufs/ffs/fs.h>
-
-#include <string.h>
-
-#include "fsck.h"
-
-static struct dups *duphead;
-static int pass1bcheck __P((struct inodesc *));
-
-void
-pass1b()
-{
- register int c, i;
- register struct dinode *dp;
- struct inodesc idesc;
- ino_t inumber;
-
- memset(&idesc, 0, sizeof(struct inodesc));
- idesc.id_type = ADDR;
- idesc.id_func = pass1bcheck;
- duphead = duplist;
- inumber = 0;
- for (c = 0; c < sblock.fs_ncg; c++) {
- for (i = 0; i < sblock.fs_ipg; i++, inumber++) {
- if (inumber < ROOTINO)
- continue;
- dp = ginode(inumber);
- if (dp == NULL)
- continue;
- idesc.id_number = inumber;
- if (inoinfo(inumber)->ino_state != USTATE &&
- (ckinode(dp, &idesc) & STOP))
- return;
- }
- }
-}
-
-static int
-pass1bcheck(idesc)
- register struct inodesc *idesc;
-{
- register struct dups *dlp;
- int nfrags, res = KEEPON;
- ufs_daddr_t blkno = idesc->id_blkno;
-
- for (nfrags = idesc->id_numfrags; nfrags > 0; blkno++, nfrags--) {
- if (chkrange(blkno, 1))
- res = SKIP;
- for (dlp = duphead; dlp; dlp = dlp->next) {
- if (dlp->dup == blkno) {
- blkerror(idesc->id_number, "DUP", blkno);
- dlp->dup = duphead->dup;
- duphead->dup = blkno;
- duphead = duphead->next;
- }
- if (dlp == muldup)
- break;
- }
- if (muldup == 0 || duphead == muldup->next)
- return (STOP);
- }
- return (res);
-}
diff --git a/sbin/fsck_ifs/pass2.c b/sbin/fsck_ifs/pass2.c
deleted file mode 100644
index 088ecffb9817..000000000000
--- a/sbin/fsck_ifs/pass2.c
+++ /dev/null
@@ -1,486 +0,0 @@
-/*
- * Copyright (c) 1980, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-#if 0
-static const char sccsid[] = "@(#)pass2.c 8.9 (Berkeley) 4/28/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <sys/param.h>
-
-#include <ufs/ufs/dinode.h>
-#include <ufs/ufs/dir.h>
-
-#include <err.h>
-#include <string.h>
-
-#include "fsck.h"
-
-#define MINDIRSIZE (sizeof (struct dirtemplate))
-
-static int blksort __P((const void *, const void *));
-static int pass2check __P((struct inodesc *));
-
-void
-pass2()
-{
- register struct dinode *dp;
- register struct inoinfo **inpp, *inp;
- struct inoinfo **inpend;
- struct inodesc curino;
- struct dinode dino;
- char pathbuf[MAXPATHLEN + 1];
-
- switch (inoinfo(ROOTINO)->ino_state) {
-
- case USTATE:
- pfatal("ROOT INODE UNALLOCATED");
- if (reply("ALLOCATE") == 0) {
- ckfini(0);
- exit(EEXIT);
- }
- if (allocdir(ROOTINO, ROOTINO, 0755) != ROOTINO)
- errx(EEXIT, "CANNOT ALLOCATE ROOT INODE");
- break;
-
- case DCLEAR:
- pfatal("DUPS/BAD IN ROOT INODE");
- if (reply("REALLOCATE")) {
- freeino(ROOTINO);
- if (allocdir(ROOTINO, ROOTINO, 0755) != ROOTINO)
- errx(EEXIT, "CANNOT ALLOCATE ROOT INODE");
- break;
- }
- if (reply("CONTINUE") == 0) {
- ckfini(0);
- exit(EEXIT);
- }
- break;
-
- case FSTATE:
- case FCLEAR:
- pfatal("ROOT INODE NOT DIRECTORY");
- if (reply("REALLOCATE")) {
- freeino(ROOTINO);
- if (allocdir(ROOTINO, ROOTINO, 0755) != ROOTINO)
- errx(EEXIT, "CANNOT ALLOCATE ROOT INODE");
- break;
- }
- if (reply("FIX") == 0) {
- ckfini(0);
- exit(EEXIT);
- }
- dp = ginode(ROOTINO);
- dp->di_mode &= ~IFMT;
- dp->di_mode |= IFDIR;
- inodirty();
- break;
-
- case DSTATE:
- break;
-
- default:
- errx(EEXIT, "BAD STATE %d FOR ROOT INODE",
- inoinfo(ROOTINO)->ino_state);
- }
- inoinfo(ROOTINO)->ino_state = DFOUND;
- if (newinofmt) {
- inoinfo(WINO)->ino_state = FSTATE;
- inoinfo(WINO)->ino_type = DT_WHT;
- }
- /*
- * Sort the directory list into disk block order.
- */
- qsort((char *)inpsort, (size_t)inplast, sizeof *inpsort, blksort);
- /*
- * Check the integrity of each directory.
- */
- memset(&curino, 0, sizeof(struct inodesc));
- curino.id_type = DATA;
- curino.id_func = pass2check;
- dp = &dino;
- inpend = &inpsort[inplast];
- for (inpp = inpsort; inpp < inpend; inpp++) {
- inp = *inpp;
- if (inp->i_isize == 0)
- continue;
- if (inp->i_isize < MINDIRSIZE) {
- direrror(inp->i_number, "DIRECTORY TOO SHORT");
- inp->i_isize = roundup(MINDIRSIZE, DIRBLKSIZ);
- if (reply("FIX") == 1) {
- dp = ginode(inp->i_number);
- dp->di_size = inp->i_isize;
- inodirty();
- dp = &dino;
- }
- } else if ((inp->i_isize & (DIRBLKSIZ - 1)) != 0) {
- getpathname(pathbuf, inp->i_number, inp->i_number);
- if (usedsoftdep)
- pfatal("%s %s: LENGTH %d NOT MULTIPLE OF %d",
- "DIRECTORY", pathbuf, inp->i_isize,
- DIRBLKSIZ);
- else
- pwarn("%s %s: LENGTH %d NOT MULTIPLE OF %d",
- "DIRECTORY", pathbuf, inp->i_isize,
- DIRBLKSIZ);
- if (preen)
- printf(" (ADJUSTED)\n");
- inp->i_isize = roundup(inp->i_isize, DIRBLKSIZ);
- if (preen || reply("ADJUST") == 1) {
- dp = ginode(inp->i_number);
- dp->di_size = roundup(inp->i_isize, DIRBLKSIZ);
- inodirty();
- dp = &dino;
- }
- }
- memset(&dino, 0, sizeof(struct dinode));
- dino.di_mode = IFDIR;
- dp->di_size = inp->i_isize;
- memmove(&dp->di_db[0], &inp->i_blks[0], (size_t)inp->i_numblks);
- curino.id_number = inp->i_number;
- curino.id_parent = inp->i_parent;
- (void)ckinode(dp, &curino);
- }
- /*
- * Now that the parents of all directories have been found,
- * make another pass to verify the value of `..'
- */
- for (inpp = inpsort; inpp < inpend; inpp++) {
- inp = *inpp;
- if (inp->i_parent == 0 || inp->i_isize == 0)
- continue;
- if (inoinfo(inp->i_parent)->ino_state == DFOUND &&
- inoinfo(inp->i_number)->ino_state == DSTATE)
- inoinfo(inp->i_number)->ino_state = DFOUND;
- if (inp->i_dotdot == inp->i_parent ||
- inp->i_dotdot == (ino_t)-1)
- continue;
- if (inp->i_dotdot == 0) {
- inp->i_dotdot = inp->i_parent;
- fileerror(inp->i_parent, inp->i_number, "MISSING '..'");
- if (reply("FIX") == 0)
- continue;
- (void)makeentry(inp->i_number, inp->i_parent, "..");
- inoinfo(inp->i_parent)->ino_linkcnt--;
- continue;
- }
- fileerror(inp->i_parent, inp->i_number,
- "BAD INODE NUMBER FOR '..'");
- if (reply("FIX") == 0)
- continue;
- inoinfo(inp->i_dotdot)->ino_linkcnt++;
- inoinfo(inp->i_parent)->ino_linkcnt--;
- inp->i_dotdot = inp->i_parent;
- (void)changeino(inp->i_number, "..", inp->i_parent);
- }
- /*
- * Mark all the directories that can be found from the root.
- */
- propagate();
-}
-
-static int
-pass2check(idesc)
- struct inodesc *idesc;
-{
- register struct direct *dirp = idesc->id_dirp;
- register struct inoinfo *inp;
- int n, entrysize, ret = 0;
- struct dinode *dp;
- char *errmsg;
- struct direct proto;
- char namebuf[MAXPATHLEN + 1];
- char pathbuf[MAXPATHLEN + 1];
-
- /*
- * If converting, set directory entry type.
- */
- if (doinglevel2 && dirp->d_ino > 0 && dirp->d_ino < maxino) {
- dirp->d_type = inoinfo(dirp->d_ino)->ino_type;
- ret |= ALTERED;
- }
- /*
- * check for "."
- */
- if (idesc->id_entryno != 0)
- goto chk1;
- if (dirp->d_ino != 0 && strcmp(dirp->d_name, ".") == 0) {
- if (dirp->d_ino != idesc->id_number) {
- direrror(idesc->id_number, "BAD INODE NUMBER FOR '.'");
- dirp->d_ino = idesc->id_number;
- if (reply("FIX") == 1)
- ret |= ALTERED;
- }
- if (newinofmt && dirp->d_type != DT_DIR) {
- direrror(idesc->id_number, "BAD TYPE VALUE FOR '.'");
- dirp->d_type = DT_DIR;
- if (reply("FIX") == 1)
- ret |= ALTERED;
- }
- goto chk1;
- }
- direrror(idesc->id_number, "MISSING '.'");
- proto.d_ino = idesc->id_number;
- if (newinofmt)
- proto.d_type = DT_DIR;
- else
- proto.d_type = 0;
- proto.d_namlen = 1;
- (void)strcpy(proto.d_name, ".");
-# if BYTE_ORDER == LITTLE_ENDIAN
- if (!newinofmt) {
- u_char tmp;
-
- tmp = proto.d_type;
- proto.d_type = proto.d_namlen;
- proto.d_namlen = tmp;
- }
-# endif
- entrysize = DIRSIZ(0, &proto);
- if (dirp->d_ino != 0 && strcmp(dirp->d_name, "..") != 0) {
- pfatal("CANNOT FIX, FIRST ENTRY IN DIRECTORY CONTAINS %s\n",
- dirp->d_name);
- } else if (dirp->d_reclen < entrysize) {
- pfatal("CANNOT FIX, INSUFFICIENT SPACE TO ADD '.'\n");
- } else if (dirp->d_reclen < 2 * entrysize) {
- proto.d_reclen = dirp->d_reclen;
- memmove(dirp, &proto, (size_t)entrysize);
- if (reply("FIX") == 1)
- ret |= ALTERED;
- } else {
- n = dirp->d_reclen - entrysize;
- proto.d_reclen = entrysize;
- memmove(dirp, &proto, (size_t)entrysize);
- idesc->id_entryno++;
- inoinfo(dirp->d_ino)->ino_linkcnt--;
- dirp = (struct direct *)((char *)(dirp) + entrysize);
- memset(dirp, 0, (size_t)n);
- dirp->d_reclen = n;
- if (reply("FIX") == 1)
- ret |= ALTERED;
- }
-chk1:
- if (idesc->id_entryno > 1)
- goto chk2;
- inp = getinoinfo(idesc->id_number);
- proto.d_ino = inp->i_parent;
- if (newinofmt)
- proto.d_type = DT_DIR;
- else
- proto.d_type = 0;
- proto.d_namlen = 2;
- (void)strcpy(proto.d_name, "..");
-# if BYTE_ORDER == LITTLE_ENDIAN
- if (!newinofmt) {
- u_char tmp;
-
- tmp = proto.d_type;
- proto.d_type = proto.d_namlen;
- proto.d_namlen = tmp;
- }
-# endif
- entrysize = DIRSIZ(0, &proto);
- if (idesc->id_entryno == 0) {
- n = DIRSIZ(0, dirp);
- if (dirp->d_reclen < n + entrysize)
- goto chk2;
- proto.d_reclen = dirp->d_reclen - n;
- dirp->d_reclen = n;
- idesc->id_entryno++;
- inoinfo(dirp->d_ino)->ino_linkcnt--;
- dirp = (struct direct *)((char *)(dirp) + n);
- memset(dirp, 0, (size_t)proto.d_reclen);
- dirp->d_reclen = proto.d_reclen;
- }
- if (dirp->d_ino != 0 && strcmp(dirp->d_name, "..") == 0) {
- inp->i_dotdot = dirp->d_ino;
- if (newinofmt && dirp->d_type != DT_DIR) {
- direrror(idesc->id_number, "BAD TYPE VALUE FOR '..'");
- dirp->d_type = DT_DIR;
- if (reply("FIX") == 1)
- ret |= ALTERED;
- }
- goto chk2;
- }
- if (dirp->d_ino != 0 && strcmp(dirp->d_name, ".") != 0) {
- fileerror(inp->i_parent, idesc->id_number, "MISSING '..'");
- pfatal("CANNOT FIX, SECOND ENTRY IN DIRECTORY CONTAINS %s\n",
- dirp->d_name);
- inp->i_dotdot = (ino_t)-1;
- } else if (dirp->d_reclen < entrysize) {
- fileerror(inp->i_parent, idesc->id_number, "MISSING '..'");
- pfatal("CANNOT FIX, INSUFFICIENT SPACE TO ADD '..'\n");
- inp->i_dotdot = (ino_t)-1;
- } else if (inp->i_parent != 0) {
- /*
- * We know the parent, so fix now.
- */
- inp->i_dotdot = inp->i_parent;
- fileerror(inp->i_parent, idesc->id_number, "MISSING '..'");
- proto.d_reclen = dirp->d_reclen;
- memmove(dirp, &proto, (size_t)entrysize);
- if (reply("FIX") == 1)
- ret |= ALTERED;
- }
- idesc->id_entryno++;
- if (dirp->d_ino != 0)
- inoinfo(dirp->d_ino)->ino_linkcnt--;
- return (ret|KEEPON);
-chk2:
- if (dirp->d_ino == 0)
- return (ret|KEEPON);
- if (dirp->d_namlen <= 2 &&
- dirp->d_name[0] == '.' &&
- idesc->id_entryno >= 2) {
- if (dirp->d_namlen == 1) {
- direrror(idesc->id_number, "EXTRA '.' ENTRY");
- dirp->d_ino = 0;
- if (reply("FIX") == 1)
- ret |= ALTERED;
- return (KEEPON | ret);
- }
- if (dirp->d_name[1] == '.') {
- direrror(idesc->id_number, "EXTRA '..' ENTRY");
- dirp->d_ino = 0;
- if (reply("FIX") == 1)
- ret |= ALTERED;
- return (KEEPON | ret);
- }
- }
- idesc->id_entryno++;
- n = 0;
- if (dirp->d_ino > maxino) {
- fileerror(idesc->id_number, dirp->d_ino, "I OUT OF RANGE");
- n = reply("REMOVE");
- } else if (newinofmt &&
- ((dirp->d_ino == WINO && dirp->d_type != DT_WHT) ||
- (dirp->d_ino != WINO && dirp->d_type == DT_WHT))) {
- fileerror(idesc->id_number, dirp->d_ino, "BAD WHITEOUT ENTRY");
- dirp->d_ino = WINO;
- dirp->d_type = DT_WHT;
- if (reply("FIX") == 1)
- ret |= ALTERED;
- } else {
-again:
- switch (inoinfo(dirp->d_ino)->ino_state) {
- case USTATE:
- if (idesc->id_entryno <= 2)
- break;
- fileerror(idesc->id_number, dirp->d_ino, "UNALLOCATED");
- n = reply("REMOVE");
- break;
-
- case DCLEAR:
- case FCLEAR:
- if (idesc->id_entryno <= 2)
- break;
- if (inoinfo(dirp->d_ino)->ino_state == FCLEAR)
- errmsg = "DUP/BAD";
- else if (!preen && !usedsoftdep)
- errmsg = "ZERO LENGTH DIRECTORY";
- else {
- n = 1;
- break;
- }
- fileerror(idesc->id_number, dirp->d_ino, errmsg);
- if ((n = reply("REMOVE")) == 1)
- break;
- dp = ginode(dirp->d_ino);
- inoinfo(dirp->d_ino)->ino_state =
- (dp->di_mode & IFMT) == IFDIR ? DSTATE : FSTATE;
- inoinfo(dirp->d_ino)->ino_linkcnt = dp->di_nlink;
- goto again;
-
- case DSTATE:
- if (inoinfo(idesc->id_number)->ino_state == DFOUND)
- inoinfo(dirp->d_ino)->ino_state = DFOUND;
- /* fall through */
-
- case DFOUND:
- inp = getinoinfo(dirp->d_ino);
- if (inp->i_parent != 0 && idesc->id_entryno > 2) {
- getpathname(pathbuf, idesc->id_number,
- idesc->id_number);
- getpathname(namebuf, dirp->d_ino, dirp->d_ino);
- pwarn("%s %s %s\n", pathbuf,
- "IS AN EXTRANEOUS HARD LINK TO DIRECTORY",
- namebuf);
- if (preen) {
- printf(" (REMOVED)\n");
- n = 1;
- break;
- }
- if ((n = reply("REMOVE")) == 1)
- break;
- }
- if (idesc->id_entryno > 2)
- inp->i_parent = idesc->id_number;
- /* fall through */
-
- case FSTATE:
- if (newinofmt &&
- dirp->d_type != inoinfo(dirp->d_ino)->ino_type) {
- fileerror(idesc->id_number, dirp->d_ino,
- "BAD TYPE VALUE");
- dirp->d_type = inoinfo(dirp->d_ino)->ino_type;
- if (reply("FIX") == 1)
- ret |= ALTERED;
- }
- inoinfo(dirp->d_ino)->ino_linkcnt--;
- break;
-
- default:
- errx(EEXIT, "BAD STATE %d FOR INODE I=%d",
- inoinfo(dirp->d_ino)->ino_state, dirp->d_ino);
- }
- }
- if (n == 0)
- return (ret|KEEPON);
- dirp->d_ino = 0;
- return (ret|KEEPON|ALTERED);
-}
-
-/*
- * Routine to sort disk blocks.
- */
-static int
-blksort(arg1, arg2)
- const void *arg1, *arg2;
-{
-
- return ((*(struct inoinfo **)arg1)->i_blks[0] -
- (*(struct inoinfo **)arg2)->i_blks[0]);
-}
diff --git a/sbin/fsck_ifs/pass3.c b/sbin/fsck_ifs/pass3.c
deleted file mode 100644
index 80e38e9cbf4f..000000000000
--- a/sbin/fsck_ifs/pass3.c
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (c) 1980, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-#if 0
-static const char sccsid[] = "@(#)pass3.c 8.2 (Berkeley) 4/27/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <sys/param.h>
-
-#include <ufs/ufs/dinode.h>
-#include <ufs/ufs/dir.h>
-#include <ufs/ffs/fs.h>
-
-#include <string.h>
-
-#include "fsck.h"
-
-void
-pass3()
-{
- struct inoinfo *inp;
- int loopcnt, inpindex, state;
- ino_t orphan;
- struct inodesc idesc;
- char namebuf[MAXNAMLEN+1];
-
- for (inpindex = inplast - 1; inpindex >= 0; inpindex--) {
- inp = inpsort[inpindex];
- state = inoinfo(inp->i_number)->ino_state;
- if (inp->i_number == ROOTINO ||
- (inp->i_parent != 0 && state != DSTATE))
- continue;
- if (state == DCLEAR)
- continue;
- /*
- * If we are running with soft updates and we come
- * across unreferenced directories, we just leave
- * them in DSTATE which will cause them to be pitched
- * in pass 4.
- */
- if (preen && resolved && usedsoftdep && state == DSTATE) {
- if (inp->i_dotdot >= ROOTINO)
- inoinfo(inp->i_dotdot)->ino_linkcnt++;
- continue;
- }
- for (loopcnt = 0; ; loopcnt++) {
- orphan = inp->i_number;
- if (inp->i_parent == 0 ||
- inoinfo(inp->i_parent)->ino_state != DSTATE ||
- loopcnt > countdirs)
- break;
- inp = getinoinfo(inp->i_parent);
- }
- if (loopcnt <= countdirs) {
- if (linkup(orphan, inp->i_dotdot, NULL)) {
- inp->i_parent = inp->i_dotdot = lfdir;
- inoinfo(lfdir)->ino_linkcnt--;
- }
- inoinfo(orphan)->ino_state = DFOUND;
- propagate();
- continue;
- }
- pfatal("ORPHANED DIRECTORY LOOP DETECTED I=%lu", orphan);
- if (reply("RECONNECT") == 0)
- continue;
- memset(&idesc, 0, sizeof(struct inodesc));
- idesc.id_type = DATA;
- idesc.id_number = inp->i_parent;
- idesc.id_parent = orphan;
- idesc.id_func = findname;
- idesc.id_name = namebuf;
- if ((ckinode(ginode(inp->i_parent), &idesc) & FOUND) == 0)
- pfatal("COULD NOT FIND NAME IN PARENT DIRECTORY");
- if (linkup(orphan, inp->i_parent, namebuf)) {
- idesc.id_func = clearentry;
- if (ckinode(ginode(inp->i_parent), &idesc) & FOUND)
- inoinfo(orphan)->ino_linkcnt++;
- inp->i_parent = inp->i_dotdot = lfdir;
- inoinfo(lfdir)->ino_linkcnt--;
- }
- inoinfo(orphan)->ino_state = DFOUND;
- propagate();
- }
-}
diff --git a/sbin/fsck_ifs/pass4.c b/sbin/fsck_ifs/pass4.c
deleted file mode 100644
index 0012c50adc7e..000000000000
--- a/sbin/fsck_ifs/pass4.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright (c) 1980, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-#if 0
-static const char sccsid[] = "@(#)pass4.c 8.4 (Berkeley) 4/28/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <sys/param.h>
-
-#include <ufs/ufs/dinode.h>
-#include <ufs/ffs/fs.h>
-
-#include <err.h>
-#include <string.h>
-
-#include "fsck.h"
-
-void
-pass4()
-{
- register ino_t inumber;
- register struct zlncnt *zlnp;
- struct dinode *dp;
- struct inodesc idesc;
- int i, n, cg;
-
- memset(&idesc, 0, sizeof(struct inodesc));
- idesc.id_type = ADDR;
- idesc.id_func = pass4check;
- for (cg = 0; cg < sblock.fs_ncg; cg++) {
- inumber = cg * sblock.fs_ipg;
- for (i = 0; i < inostathead[cg].il_numalloced; i++, inumber++) {
- if (inumber < ROOTINO)
- continue;
- idesc.id_number = inumber;
- switch (inoinfo(inumber)->ino_state) {
-
- case FSTATE:
- case DFOUND:
- n = inoinfo(inumber)->ino_linkcnt;
- if (n) {
- adjust(&idesc, (short)n);
- break;
- }
- for (zlnp = zlnhead; zlnp; zlnp = zlnp->next) {
- if (zlnp->zlncnt == inumber) {
- zlnp->zlncnt = zlnhead->zlncnt;
- zlnp = zlnhead;
- zlnhead = zlnhead->next;
- free((char *)zlnp);
- clri(&idesc, "UNREF", 1);
- break;
- }
- }
- break;
-
- case DSTATE:
- clri(&idesc, "UNREF", 1);
- break;
-
- case DCLEAR:
- dp = ginode(inumber);
- if (dp->di_size == 0) {
- clri(&idesc, "ZERO LENGTH", 1);
- break;
- }
- /* fall through */
- case FCLEAR:
- clri(&idesc, "BAD/DUP", 1);
- break;
-
- case USTATE:
- break;
-
- default:
- errx(EEXIT, "BAD STATE %d FOR INODE I=%d",
- inoinfo(inumber)->ino_state, inumber);
- }
- }
- }
-}
-
-int
-pass4check(idesc)
- register struct inodesc *idesc;
-{
- register struct dups *dlp;
- int nfrags, res = KEEPON;
- ufs_daddr_t blkno = idesc->id_blkno;
-
- for (nfrags = idesc->id_numfrags; nfrags > 0; blkno++, nfrags--) {
- if (chkrange(blkno, 1)) {
- res = SKIP;
- } else if (testbmap(blkno)) {
- for (dlp = duplist; dlp; dlp = dlp->next) {
- if (dlp->dup != blkno)
- continue;
- dlp->dup = duplist->dup;
- dlp = duplist;
- duplist = duplist->next;
- free((char *)dlp);
- break;
- }
- if (dlp == 0) {
- clrbmap(blkno);
- n_blks--;
- }
- }
- }
- return (res);
-}
diff --git a/sbin/fsck_ifs/pass5.c b/sbin/fsck_ifs/pass5.c
deleted file mode 100644
index d5edaace1690..000000000000
--- a/sbin/fsck_ifs/pass5.c
+++ /dev/null
@@ -1,361 +0,0 @@
-/*
- * Copyright (c) 1980, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-#if 0
-static const char sccsid[] = "@(#)pass5.c 8.9 (Berkeley) 4/28/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <sys/param.h>
-
-#include <ufs/ufs/dinode.h>
-#include <ufs/ffs/fs.h>
-
-#include <err.h>
-#include <string.h>
-
-#include "fsck.h"
-
-void
-pass5()
-{
- int c, blk, frags, basesize, sumsize, mapsize, savednrpos = 0;
- int inomapsize, blkmapsize;
- struct fs *fs = &sblock;
- struct cg *cg = &cgrp;
- ufs_daddr_t dbase, dmax;
- ufs_daddr_t d;
- long i, j, k;
- struct csum *cs;
- struct csum cstotal;
- struct inodesc idesc[3];
- char buf[MAXBSIZE];
- register struct cg *newcg = (struct cg *)buf;
- struct ocg *ocg = (struct ocg *)buf;
-
- inoinfo(WINO)->ino_state = USTATE;
- memset(newcg, 0, (size_t)fs->fs_cgsize);
- newcg->cg_niblk = fs->fs_ipg;
- if (cvtlevel >= 3) {
- if (fs->fs_maxcontig < 2 && fs->fs_contigsumsize > 0) {
- if (preen)
- pwarn("DELETING CLUSTERING MAPS\n");
- if (preen || reply("DELETE CLUSTERING MAPS")) {
- fs->fs_contigsumsize = 0;
- doinglevel1 = 1;
- sbdirty();
- }
- }
- if (fs->fs_maxcontig > 1) {
- char *doit = 0;
-
- if (fs->fs_contigsumsize < 1) {
- doit = "CREAT";
- } else if (fs->fs_contigsumsize < fs->fs_maxcontig &&
- fs->fs_contigsumsize < FS_MAXCONTIG) {
- doit = "EXPAND";
- }
- if (doit) {
- i = fs->fs_contigsumsize;
- fs->fs_contigsumsize =
- MIN(fs->fs_maxcontig, FS_MAXCONTIG);
- if (CGSIZE(fs) > fs->fs_bsize) {
- pwarn("CANNOT %s CLUSTER MAPS\n", doit);
- fs->fs_contigsumsize = i;
- } else if (preen ||
- reply("CREATE CLUSTER MAPS")) {
- if (preen)
- pwarn("%sING CLUSTER MAPS\n",
- doit);
- fs->fs_cgsize =
- fragroundup(fs, CGSIZE(fs));
- doinglevel1 = 1;
- sbdirty();
- }
- }
- }
- }
- switch ((int)fs->fs_postblformat) {
-
- case FS_42POSTBLFMT:
- basesize = (char *)(&ocg->cg_btot[0]) -
- (char *)(&ocg->cg_firstfield);
- sumsize = &ocg->cg_iused[0] - (u_int8_t *)(&ocg->cg_btot[0]);
- mapsize = &ocg->cg_free[howmany(fs->fs_fpg, NBBY)] -
- (u_char *)&ocg->cg_iused[0];
- blkmapsize = howmany(fs->fs_fpg, NBBY);
- inomapsize = &ocg->cg_free[0] - (u_char *)&ocg->cg_iused[0];
- ocg->cg_magic = CG_MAGIC;
- savednrpos = fs->fs_nrpos;
- fs->fs_nrpos = 8;
- break;
-
- case FS_DYNAMICPOSTBLFMT:
- newcg->cg_btotoff =
- &newcg->cg_space[0] - (u_char *)(&newcg->cg_firstfield);
- newcg->cg_boff =
- newcg->cg_btotoff + fs->fs_cpg * sizeof(int32_t);
- newcg->cg_iusedoff = newcg->cg_boff +
- fs->fs_cpg * fs->fs_nrpos * sizeof(u_int16_t);
- newcg->cg_freeoff =
- newcg->cg_iusedoff + howmany(fs->fs_ipg, NBBY);
- inomapsize = newcg->cg_freeoff - newcg->cg_iusedoff;
- newcg->cg_nextfreeoff = newcg->cg_freeoff +
- howmany(fs->fs_cpg * fs->fs_spc / NSPF(fs), NBBY);
- blkmapsize = newcg->cg_nextfreeoff - newcg->cg_freeoff;
- if (fs->fs_contigsumsize > 0) {
- newcg->cg_clustersumoff = newcg->cg_nextfreeoff -
- sizeof(u_int32_t);
- newcg->cg_clustersumoff =
- roundup(newcg->cg_clustersumoff, sizeof(u_int32_t));
- newcg->cg_clusteroff = newcg->cg_clustersumoff +
- (fs->fs_contigsumsize + 1) * sizeof(u_int32_t);
- newcg->cg_nextfreeoff = newcg->cg_clusteroff +
- howmany(fs->fs_cpg * fs->fs_spc / NSPB(fs), NBBY);
- }
- newcg->cg_magic = CG_MAGIC;
- basesize = &newcg->cg_space[0] -
- (u_char *)(&newcg->cg_firstfield);
- sumsize = newcg->cg_iusedoff - newcg->cg_btotoff;
- mapsize = newcg->cg_nextfreeoff - newcg->cg_iusedoff;
- break;
-
- default:
- inomapsize = blkmapsize = sumsize = 0; /* keep lint happy */
- errx(EEXIT, "UNKNOWN ROTATIONAL TABLE FORMAT %d",
- fs->fs_postblformat);
- }
- memset(&idesc[0], 0, sizeof idesc);
- for (i = 0; i < 3; i++) {
- idesc[i].id_type = ADDR;
- if (doinglevel2)
- idesc[i].id_fix = FIX;
- }
- memset(&cstotal, 0, sizeof(struct csum));
- j = blknum(fs, fs->fs_size + fs->fs_frag - 1);
- for (i = fs->fs_size; i < j; i++)
- setbmap(i);
- for (c = 0; c < fs->fs_ncg; c++) {
- getblk(&cgblk, cgtod(fs, c), fs->fs_cgsize);
- if (!cg_chkmagic(cg))
- pfatal("CG %d: BAD MAGIC NUMBER\n", c);
- dbase = cgbase(fs, c);
- dmax = dbase + fs->fs_fpg;
- if (dmax > fs->fs_size)
- dmax = fs->fs_size;
- newcg->cg_time = cg->cg_time;
- newcg->cg_cgx = c;
- if (c == fs->fs_ncg - 1)
- newcg->cg_ncyl = fs->fs_ncyl % fs->fs_cpg;
- else
- newcg->cg_ncyl = fs->fs_cpg;
- newcg->cg_ndblk = dmax - dbase;
- if (fs->fs_contigsumsize > 0)
- newcg->cg_nclusterblks = newcg->cg_ndblk / fs->fs_frag;
- newcg->cg_cs.cs_ndir = 0;
- newcg->cg_cs.cs_nffree = 0;
- newcg->cg_cs.cs_nbfree = 0;
- newcg->cg_cs.cs_nifree = fs->fs_ipg;
- if (cg->cg_rotor < newcg->cg_ndblk)
- newcg->cg_rotor = cg->cg_rotor;
- else
- newcg->cg_rotor = 0;
- if (cg->cg_frotor < newcg->cg_ndblk)
- newcg->cg_frotor = cg->cg_frotor;
- else
- newcg->cg_frotor = 0;
- if (cg->cg_irotor < newcg->cg_niblk)
- newcg->cg_irotor = cg->cg_irotor;
- else
- newcg->cg_irotor = 0;
- memset(&newcg->cg_frsum[0], 0, sizeof newcg->cg_frsum);
- memset(&cg_blktot(newcg)[0], 0,
- (size_t)(sumsize + mapsize));
- if (fs->fs_postblformat == FS_42POSTBLFMT)
- ocg->cg_magic = CG_MAGIC;
- j = fs->fs_ipg * c;
- for (i = 0; i < inostathead[c].il_numalloced; j++, i++) {
- switch (inoinfo(j)->ino_state) {
-
- case USTATE:
- break;
-
- case DSTATE:
- case DCLEAR:
- case DFOUND:
- newcg->cg_cs.cs_ndir++;
- /* fall through */
-
- case FSTATE:
- case FCLEAR:
- newcg->cg_cs.cs_nifree--;
- setbit(cg_inosused(newcg), i);
- break;
-
- default:
- if (j < ROOTINO)
- break;
- errx(EEXIT, "BAD STATE %d FOR INODE I=%ld",
- inoinfo(j)->ino_state, j);
- }
- }
- if (c == 0)
- for (i = 0; i < ROOTINO; i++) {
- setbit(cg_inosused(newcg), i);
- newcg->cg_cs.cs_nifree--;
- }
- for (i = 0, d = dbase;
- d < dmax;
- d += fs->fs_frag, i += fs->fs_frag) {
- frags = 0;
- for (j = 0; j < fs->fs_frag; j++) {
- if (testbmap(d + j))
- continue;
- setbit(cg_blksfree(newcg), i + j);
- frags++;
- }
- if (frags == fs->fs_frag) {
- newcg->cg_cs.cs_nbfree++;
- j = cbtocylno(fs, i);
- cg_blktot(newcg)[j]++;
- cg_blks(fs, newcg, j)[cbtorpos(fs, i)]++;
- if (fs->fs_contigsumsize > 0)
- setbit(cg_clustersfree(newcg),
- i / fs->fs_frag);
- } else if (frags > 0) {
- newcg->cg_cs.cs_nffree += frags;
- blk = blkmap(fs, cg_blksfree(newcg), i);
- ffs_fragacct(fs, blk, newcg->cg_frsum, 1);
- }
- }
- if (fs->fs_contigsumsize > 0) {
- int32_t *sump = cg_clustersum(newcg);
- u_char *mapp = cg_clustersfree(newcg);
- int map = *mapp++;
- int bit = 1;
- int run = 0;
-
- for (i = 0; i < newcg->cg_nclusterblks; i++) {
- if ((map & bit) != 0) {
- run++;
- } else if (run != 0) {
- if (run > fs->fs_contigsumsize)
- run = fs->fs_contigsumsize;
- sump[run]++;
- run = 0;
- }
- if ((i & (NBBY - 1)) != (NBBY - 1)) {
- bit <<= 1;
- } else {
- map = *mapp++;
- bit = 1;
- }
- }
- if (run != 0) {
- if (run > fs->fs_contigsumsize)
- run = fs->fs_contigsumsize;
- sump[run]++;
- }
- }
- cstotal.cs_nffree += newcg->cg_cs.cs_nffree;
- cstotal.cs_nbfree += newcg->cg_cs.cs_nbfree;
- cstotal.cs_nifree += newcg->cg_cs.cs_nifree;
- cstotal.cs_ndir += newcg->cg_cs.cs_ndir;
- cs = &fs->fs_cs(fs, c);
- if (memcmp(&newcg->cg_cs, cs, sizeof *cs) != 0 &&
- dofix(&idesc[0], "FREE BLK COUNT(S) WRONG IN SUPERBLK")) {
- memmove(cs, &newcg->cg_cs, sizeof *cs);
- sbdirty();
- }
- if (doinglevel1) {
- memmove(cg, newcg, (size_t)fs->fs_cgsize);
- cgdirty();
- continue;
- }
- if ((memcmp(newcg, cg, basesize) != 0 ||
- memcmp(&cg_blktot(newcg)[0],
- &cg_blktot(cg)[0], sumsize) != 0) &&
- dofix(&idesc[2], "SUMMARY INFORMATION BAD")) {
- memmove(cg, newcg, (size_t)basesize);
- memmove(&cg_blktot(cg)[0],
- &cg_blktot(newcg)[0], (size_t)sumsize);
- cgdirty();
- }
- if (usedsoftdep) {
- for (i = 0; i < inomapsize; i++) {
- j = cg_inosused(newcg)[i];
- if ((cg_inosused(cg)[i] & j) == j)
- continue;
- for (k = 0; k < NBBY; k++) {
- if ((j & (1 << k)) == 0)
- continue;
- if (cg_inosused(cg)[i] & (1 << k))
- continue;
- pwarn("ALLOCATED INODE %d MARKED FREE\n",
- c * fs->fs_ipg + i * NBBY + k);
- }
- }
- for (i = 0; i < blkmapsize; i++) {
- j = cg_blksfree(cg)[i];
- if ((cg_blksfree(newcg)[i] & j) == j)
- continue;
- for (k = 0; k < NBBY; k++) {
- if ((j & (1 << k)) == 0)
- continue;
- if (cg_blksfree(newcg)[i] & (1 << k))
- continue;
- pwarn("ALLOCATED FRAG %d MARKED FREE\n",
- c * fs->fs_fpg + i * NBBY + k);
- }
- }
- }
- if (memcmp(cg_inosused(newcg), cg_inosused(cg), mapsize) != 0 &&
- dofix(&idesc[1], "BLK(S) MISSING IN BIT MAPS")) {
- memmove(cg_inosused(cg), cg_inosused(newcg),
- (size_t)mapsize);
- cgdirty();
- }
- }
- if (fs->fs_postblformat == FS_42POSTBLFMT)
- fs->fs_nrpos = savednrpos;
- if (memcmp(&cstotal, &fs->fs_cstotal, sizeof *cs) != 0
- && dofix(&idesc[0], "FREE BLK COUNT(S) WRONG IN SUPERBLK")) {
- memmove(&fs->fs_cstotal, &cstotal, sizeof *cs);
- fs->fs_ronly = 0;
- fs->fs_fmod = 0;
- sbdirty();
- }
-}
diff --git a/sbin/fsck_ifs/preen.c b/sbin/fsck_ifs/preen.c
deleted file mode 100644
index e43aada8d10d..000000000000
--- a/sbin/fsck_ifs/preen.c
+++ /dev/null
@@ -1,332 +0,0 @@
-/*
- * 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-#if 0
-static const char sccsid[] = "@(#)preen.c 8.5 (Berkeley) 4/28/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-
-#include <ufs/ufs/dinode.h>
-
-#include <ctype.h>
-#include <errno.h>
-#include <fstab.h>
-#include <string.h>
-
-#include "fsck.h"
-
-struct part {
- struct part *next; /* forward link of partitions on disk */
- char *name; /* device name */
- char *fsname; /* mounted filesystem name */
- long auxdata; /* auxillary data for application */
-} *badlist, **badnext = &badlist;
-
-struct disk {
- char *name; /* disk base name */
- struct disk *next; /* forward link for list of disks */
- struct part *part; /* head of list of partitions on disk */
- int pid; /* If != 0, pid of proc working on */
-} *disks;
-
-int nrun, ndisks;
-
-static void addpart __P((char *name, char *fsname, long auxdata));
-static struct disk *finddisk __P((char *name));
-static int startdisk __P((struct disk *dk,
- int (*checkit)(char *, char *, long, int)));
-
-int
-checkfstab(preen, maxrun, docheck, chkit)
- int preen;
- int maxrun;
- int (*docheck)(struct fstab *);
- int (*chkit)(char *, char *, long, int);
-{
- register struct fstab *fsp;
- register struct disk *dk, *nextdisk;
- register struct part *pt;
- int ret, pid, retcode, passno, sumstatus, status;
- long auxdata;
- char *name;
-
- sumstatus = 0;
- for (passno = 1; passno <= 2; passno++) {
- if (setfsent() == 0) {
- fprintf(stderr, "Can't open checklist file: %s\n",
- _PATH_FSTAB);
- return (8);
- }
- while ((fsp = getfsent()) != 0) {
- if ((auxdata = (*docheck)(fsp)) == 0)
- continue;
- if (preen == 0 ||
- (passno == 1 && fsp->fs_passno == 1)) {
- if ((name = blockcheck(fsp->fs_spec)) != 0) {
- if ((sumstatus = (*chkit)(name,
- fsp->fs_file, auxdata, 0)) != 0)
- return (sumstatus);
- } else if (preen)
- return (8);
- } else if (passno == 2 && fsp->fs_passno > 1) {
- if ((name = blockcheck(fsp->fs_spec)) == NULL) {
- fprintf(stderr, "BAD DISK NAME %s\n",
- fsp->fs_spec);
- sumstatus |= 8;
- continue;
- }
- addpart(name, fsp->fs_file, auxdata);
- }
- }
- if (preen == 0)
- return (0);
- }
- if (preen) {
- if (maxrun == 0)
- maxrun = ndisks;
- if (maxrun > ndisks)
- maxrun = ndisks;
- nextdisk = disks;
- for (passno = 0; passno < maxrun; ++passno) {
- while ((ret = startdisk(nextdisk, chkit)) && nrun > 0)
- sleep(10);
- if (ret)
- return (ret);
- nextdisk = nextdisk->next;
- }
- while ((pid = wait(&status)) != -1) {
- for (dk = disks; dk; dk = dk->next)
- if (dk->pid == pid)
- break;
- if (dk == 0) {
- printf("Unknown pid %d\n", pid);
- continue;
- }
- if (WIFEXITED(status))
- retcode = WEXITSTATUS(status);
- else
- retcode = 0;
- if (WIFSIGNALED(status)) {
- printf("%s (%s): EXITED WITH SIGNAL %d\n",
- dk->part->name, dk->part->fsname,
- WTERMSIG(status));
- retcode = 8;
- }
- if (retcode != 0) {
- sumstatus |= retcode;
- *badnext = dk->part;
- badnext = &dk->part->next;
- dk->part = dk->part->next;
- *badnext = NULL;
- } else
- dk->part = dk->part->next;
- dk->pid = 0;
- nrun--;
- if (dk->part == NULL)
- ndisks--;
-
- if (nextdisk == NULL) {
- if (dk->part) {
- while ((ret = startdisk(dk, chkit)) &&
- nrun > 0)
- sleep(10);
- if (ret)
- return (ret);
- }
- } else if (nrun < maxrun && nrun < ndisks) {
- for ( ;; ) {
- if ((nextdisk = nextdisk->next) == NULL)
- nextdisk = disks;
- if (nextdisk->part != NULL &&
- nextdisk->pid == 0)
- break;
- }
- while ((ret = startdisk(nextdisk, chkit)) &&
- nrun > 0)
- sleep(10);
- if (ret)
- return (ret);
- }
- }
- }
- if (sumstatus) {
- if (badlist == 0)
- return (sumstatus);
- fprintf(stderr, "THE FOLLOWING FILE SYSTEM%s HAD AN %s\n\t",
- badlist->next ? "S" : "", "UNEXPECTED INCONSISTENCY:");
- for (pt = badlist; pt; pt = pt->next)
- fprintf(stderr, "%s (%s)%s", pt->name, pt->fsname,
- pt->next ? ", " : "\n");
- return (sumstatus);
- }
- (void)endfsent();
- return (0);
-}
-
-static struct disk *
-finddisk(name)
- char *name;
-{
- register struct disk *dk, **dkp;
- register char *p;
- size_t len;
-
- p = strrchr(name, '/');
- p = p == NULL ? name : p + 1;
- while (*p != '\0' && !isdigit((u_char)*p))
- p++;
- while (isdigit((u_char)*p))
- p++;
- len = (size_t)(p - name);
- for (dk = disks, dkp = &disks; dk; dkp = &dk->next, dk = dk->next) {
- if (strncmp(dk->name, name, len) == 0 &&
- dk->name[len] == 0)
- return (dk);
- }
- if ((*dkp = (struct disk *)malloc(sizeof(struct disk))) == NULL) {
- fprintf(stderr, "out of memory");
- exit (8);
- }
- dk = *dkp;
- if ((dk->name = malloc(len + 1)) == NULL) {
- fprintf(stderr, "out of memory");
- exit (8);
- }
- (void)strncpy(dk->name, name, len);
- dk->name[len] = '\0';
- dk->part = NULL;
- dk->next = NULL;
- dk->pid = 0;
- ndisks++;
- return (dk);
-}
-
-static void
-addpart(name, fsname, auxdata)
- char *name, *fsname;
- long auxdata;
-{
- struct disk *dk = finddisk(name);
- register struct part *pt, **ppt = &dk->part;
-
- for (pt = dk->part; pt; ppt = &pt->next, pt = pt->next)
- if (strcmp(pt->name, name) == 0) {
- printf("%s in fstab more than once!\n", name);
- return;
- }
- if ((*ppt = (struct part *)malloc(sizeof(struct part))) == NULL) {
- fprintf(stderr, "out of memory");
- exit (8);
- }
- pt = *ppt;
- if ((pt->name = malloc(strlen(name) + 1)) == NULL) {
- fprintf(stderr, "out of memory");
- exit (8);
- }
- (void)strcpy(pt->name, name);
- if ((pt->fsname = malloc(strlen(fsname) + 1)) == NULL) {
- fprintf(stderr, "out of memory");
- exit (8);
- }
- (void)strcpy(pt->fsname, fsname);
- pt->next = NULL;
- pt->auxdata = auxdata;
-}
-
-static int
-startdisk(dk, checkit)
- register struct disk *dk;
- int (*checkit)(char *, char *, long, int);
-{
- register struct part *pt = dk->part;
-
- dk->pid = fork();
- if (dk->pid < 0) {
- perror("fork");
- return (8);
- }
- if (dk->pid == 0)
- exit((*checkit)(pt->name, pt->fsname, pt->auxdata, 1));
- nrun++;
- return (0);
-}
-
-char *
-blockcheck(origname)
- char *origname;
-{
- struct stat stslash, stblock, stchar;
- char *newname, *raw;
- struct fstab *fsinfo;
- int retried = 0, len;
-
- newname = origname;
-retry:
- if (stat(newname, &stblock) < 0) {
- printf("Can't stat %s: %s\n", newname, strerror(errno));
- return (origname);
- }
- switch(stblock.st_mode & S_IFMT) {
- case S_IFCHR:
- case S_IFBLK:
- return(newname);
- case S_IFDIR:
- if (retried)
- break;
-
- len = strlen(origname) - 1;
- if (len > 0 && origname[len] == '/')
- /* remove trailing slash */
- origname[len] = '\0';
- if ((fsinfo = getfsfile(origname)) == NULL) {
- printf("Can't resolve %s to character special device",
- origname);
- return (0);
- }
- newname = fsinfo->fs_spec;
- retried++;
- goto retry;
- }
- /*
- * Not a block or character device, just return name and
- * let the user decide whether to use it.
- */
- return (origname);
-}
diff --git a/sbin/fsck_ifs/setup.c b/sbin/fsck_ifs/setup.c
deleted file mode 100644
index 49bbc8d99883..000000000000
--- a/sbin/fsck_ifs/setup.c
+++ /dev/null
@@ -1,513 +0,0 @@
-/*
- * Copyright (c) 1980, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-#if 0
-static const char sccsid[] = "@(#)setup.c 8.10 (Berkeley) 5/9/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#define DKTYPENAMES
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <sys/disklabel.h>
-#include <sys/file.h>
-
-#include <ufs/ufs/dinode.h>
-#include <ufs/ffs/fs.h>
-
-#include <ctype.h>
-#include <err.h>
-#include <errno.h>
-#include <string.h>
-
-#include "fsck.h"
-
-struct bufarea asblk;
-#define altsblock (*asblk.b_un.b_fs)
-#define POWEROF2(num) (((num) & ((num) - 1)) == 0)
-
-static void badsb __P((int listerr, char *s));
-static int calcsb __P((char *dev, int devfd, struct fs *fs));
-static struct disklabel *getdisklabel __P((char *s, int fd));
-static int readsb __P((int listerr));
-
-/*
- * Read in a superblock finding an alternate if necessary.
- * Return 1 if successful, 0 if unsuccessful, -1 if filesystem
- * is already clean (preen mode only).
- */
-int
-setup(dev)
- char *dev;
-{
- long cg, size, asked, i, j;
- long skipclean, bmapsize;
- struct disklabel *lp;
- off_t sizepb;
- struct stat statb;
- struct fs proto;
-
- havesb = 0;
- fswritefd = -1;
- skipclean = fflag ? 0 : preen;
- if (stat(dev, &statb) < 0) {
- printf("Can't stat %s: %s\n", dev, strerror(errno));
- return (0);
- }
- if ((statb.st_mode & S_IFMT) != S_IFCHR &&
- (statb.st_mode & S_IFMT) != S_IFBLK) {
- pfatal("%s is not a disk device", dev);
- if (reply("CONTINUE") == 0)
- return (0);
- }
- if ((fsreadfd = open(dev, O_RDONLY)) < 0) {
- printf("Can't open %s: %s\n", dev, strerror(errno));
- return (0);
- }
- if (preen == 0)
- printf("** %s", dev);
- if (nflag || (fswritefd = open(dev, O_WRONLY)) < 0) {
- fswritefd = -1;
- if (preen)
- pfatal("NO WRITE ACCESS");
- printf(" (NO WRITE)");
- }
- if (preen == 0)
- printf("\n");
- fsmodified = 0;
- lfdir = 0;
- initbarea(&sblk);
- initbarea(&asblk);
- sblk.b_un.b_buf = malloc(SBSIZE);
- asblk.b_un.b_buf = malloc(SBSIZE);
- if (sblk.b_un.b_buf == NULL || asblk.b_un.b_buf == NULL)
- errx(EEXIT, "cannot allocate space for superblock");
- if ((lp = getdisklabel(NULL, fsreadfd)))
- dev_bsize = secsize = lp->d_secsize;
- else
- dev_bsize = secsize = DEV_BSIZE;
- /*
- * Read in the superblock, looking for alternates if necessary
- */
- if (readsb(1) == 0) {
- skipclean = 0;
- if (bflag || preen || calcsb(dev, fsreadfd, &proto) == 0)
- return(0);
- if (reply("LOOK FOR ALTERNATE SUPERBLOCKS") == 0)
- return (0);
- for (cg = 0; cg < proto.fs_ncg; cg++) {
- bflag = fsbtodb(&proto, cgsblock(&proto, cg));
- if (readsb(0) != 0)
- break;
- }
- if (cg >= proto.fs_ncg) {
- printf("%s %s\n%s %s\n%s %s\n",
- "SEARCH FOR ALTERNATE SUPER-BLOCK",
- "FAILED. YOU MUST USE THE",
- "-b OPTION TO FSCK TO SPECIFY THE",
- "LOCATION OF AN ALTERNATE",
- "SUPER-BLOCK TO SUPPLY NEEDED",
- "INFORMATION; SEE fsck(8).");
- bflag = 0;
- return(0);
- }
- pwarn("USING ALTERNATE SUPERBLOCK AT %d\n", bflag);
- bflag = 0;
- }
- if (skipclean && sblock.fs_clean) {
- pwarn("FILESYSTEM CLEAN; SKIPPING CHECKS\n");
- return (-1);
- }
- maxfsblock = sblock.fs_size;
- maxino = sblock.fs_ncg * sblock.fs_ipg;
- /*
- * Check and potentially fix certain fields in the super block.
- */
- if (sblock.fs_optim != FS_OPTTIME && sblock.fs_optim != FS_OPTSPACE) {
- pfatal("UNDEFINED OPTIMIZATION IN SUPERBLOCK");
- if (reply("SET TO DEFAULT") == 1) {
- sblock.fs_optim = FS_OPTTIME;
- sbdirty();
- }
- }
- if ((sblock.fs_minfree < 0 || sblock.fs_minfree > 99)) {
- pfatal("IMPOSSIBLE MINFREE=%d IN SUPERBLOCK",
- sblock.fs_minfree);
- if (reply("SET TO DEFAULT") == 1) {
- sblock.fs_minfree = 10;
- sbdirty();
- }
- }
- if (sblock.fs_interleave < 1 ||
- sblock.fs_interleave > sblock.fs_nsect) {
- pwarn("IMPOSSIBLE INTERLEAVE=%d IN SUPERBLOCK",
- sblock.fs_interleave);
- sblock.fs_interleave = 1;
- if (preen)
- printf(" (FIXED)\n");
- if (preen || reply("SET TO DEFAULT") == 1) {
- sbdirty();
- dirty(&asblk);
- }
- }
- if (sblock.fs_npsect < sblock.fs_nsect ||
- sblock.fs_npsect > sblock.fs_nsect*2) {
- pwarn("IMPOSSIBLE NPSECT=%d IN SUPERBLOCK",
- sblock.fs_npsect);
- sblock.fs_npsect = sblock.fs_nsect;
- if (preen)
- printf(" (FIXED)\n");
- if (preen || reply("SET TO DEFAULT") == 1) {
- sbdirty();
- dirty(&asblk);
- }
- }
- if (sblock.fs_inodefmt >= FS_44INODEFMT) {
- newinofmt = 1;
- } else {
- sblock.fs_qbmask = ~sblock.fs_bmask;
- sblock.fs_qfmask = ~sblock.fs_fmask;
- newinofmt = 0;
- }
- /*
- * Convert to new inode format.
- */
- if (cvtlevel >= 2 && sblock.fs_inodefmt < FS_44INODEFMT) {
- if (preen)
- pwarn("CONVERTING TO NEW INODE FORMAT\n");
- else if (!reply("CONVERT TO NEW INODE FORMAT"))
- return(0);
- doinglevel2++;
- sblock.fs_inodefmt = FS_44INODEFMT;
- sizepb = sblock.fs_bsize;
- sblock.fs_maxfilesize = sblock.fs_bsize * NDADDR - 1;
- for (i = 0; i < NIADDR; i++) {
- sizepb *= NINDIR(&sblock);
- sblock.fs_maxfilesize += sizepb;
- }
- sblock.fs_maxsymlinklen = MAXSYMLINKLEN;
- sblock.fs_qbmask = ~sblock.fs_bmask;
- sblock.fs_qfmask = ~sblock.fs_fmask;
- sbdirty();
- dirty(&asblk);
- }
- /*
- * Convert to new cylinder group format.
- */
- if (cvtlevel >= 1 && sblock.fs_postblformat == FS_42POSTBLFMT) {
- if (preen)
- pwarn("CONVERTING TO NEW CYLINDER GROUP FORMAT\n");
- else if (!reply("CONVERT TO NEW CYLINDER GROUP FORMAT"))
- return(0);
- doinglevel1++;
- sblock.fs_postblformat = FS_DYNAMICPOSTBLFMT;
- sblock.fs_nrpos = 8;
- sblock.fs_postbloff =
- (char *)(&sblock.fs_opostbl[0][0]) -
- (char *)(&sblock.fs_firstfield);
- sblock.fs_rotbloff = &sblock.fs_space[0] -
- (u_char *)(&sblock.fs_firstfield);
- sblock.fs_cgsize =
- fragroundup(&sblock, CGSIZE(&sblock));
- sbdirty();
- dirty(&asblk);
- }
- if (asblk.b_dirty && !bflag) {
- memmove(&altsblock, &sblock, (size_t)sblock.fs_sbsize);
- flush(fswritefd, &asblk);
- }
- /*
- * read in the summary info.
- */
- asked = 0;
- for (i = 0, j = 0; i < sblock.fs_cssize; i += sblock.fs_bsize, j++) {
- size = sblock.fs_cssize - i < sblock.fs_bsize ?
- sblock.fs_cssize - i : sblock.fs_bsize;
- sblock.fs_csp[j] = (struct csum *)calloc(1, (unsigned)size);
- if (bread(fsreadfd, (char *)sblock.fs_csp[j],
- fsbtodb(&sblock, sblock.fs_csaddr + j * sblock.fs_frag),
- size) != 0 && !asked) {
- pfatal("BAD SUMMARY INFORMATION");
- if (reply("CONTINUE") == 0) {
- ckfini(0);
- exit(EEXIT);
- }
- asked++;
- }
- }
- /*
- * allocate and initialize the necessary maps
- */
- bmapsize = roundup(howmany(maxfsblock, NBBY), sizeof(short));
- blockmap = calloc((unsigned)bmapsize, sizeof (char));
- if (blockmap == NULL) {
- printf("cannot alloc %u bytes for blockmap\n",
- (unsigned)bmapsize);
- goto badsb;
- }
- inostathead = calloc((unsigned)(sblock.fs_ncg),
- sizeof(struct inostatlist));
- if (inostathead == NULL) {
- printf("cannot alloc %u bytes for inostathead\n",
- (unsigned)(sizeof(struct inostatlist) * (sblock.fs_ncg)));
- goto badsb;
- }
- numdirs = sblock.fs_cstotal.cs_ndir;
- dirhash = numdirs;
- if (numdirs == 0) {
- printf("numdirs is zero, try using an alternate superblock\n");
- goto badsb;
- }
- inplast = 0;
- listmax = numdirs + 10;
- inpsort = (struct inoinfo **)calloc((unsigned)listmax,
- sizeof(struct inoinfo *));
- inphead = (struct inoinfo **)calloc((unsigned)numdirs,
- sizeof(struct inoinfo *));
- if (inpsort == NULL || inphead == NULL) {
- printf("cannot alloc %u bytes for inphead\n",
- (unsigned)numdirs * sizeof(struct inoinfo *));
- goto badsb;
- }
- bufinit();
- if (sblock.fs_flags & FS_DOSOFTDEP)
- usedsoftdep = 1;
- else
- usedsoftdep = 0;
- return (1);
-
-badsb:
- ckfini(0);
- return (0);
-}
-
-/*
- * Read in the super block and its summary info.
- */
-static int
-readsb(listerr)
- int listerr;
-{
- ufs_daddr_t super = bflag ? bflag : SBOFF / dev_bsize;
-
- if (bread(fsreadfd, (char *)&sblock, super, (long)SBSIZE) != 0)
- return (0);
- sblk.b_bno = super;
- sblk.b_size = SBSIZE;
- /*
- * run a few consistency checks of the super block
- */
- if (sblock.fs_magic != FS_MAGIC)
- { badsb(listerr, "MAGIC NUMBER WRONG"); return (0); }
- if (sblock.fs_ncg < 1)
- { badsb(listerr, "NCG OUT OF RANGE"); return (0); }
- if (sblock.fs_cpg < 1)
- { badsb(listerr, "CPG OUT OF RANGE"); return (0); }
- if (sblock.fs_ncg * sblock.fs_cpg < sblock.fs_ncyl ||
- (sblock.fs_ncg - 1) * sblock.fs_cpg >= sblock.fs_ncyl)
- { badsb(listerr, "NCYL LESS THAN NCG*CPG"); return (0); }
- if (sblock.fs_sbsize > SBSIZE)
- { badsb(listerr, "SIZE PREPOSTEROUSLY LARGE"); return (0); }
- /*
- * Compute block size that the filesystem is based on,
- * according to fsbtodb, and adjust superblock block number
- * so we can tell if this is an alternate later.
- */
- super *= dev_bsize;
- dev_bsize = sblock.fs_fsize / fsbtodb(&sblock, 1);
- sblk.b_bno = super / dev_bsize;
- if (bflag) {
- havesb = 1;
- return (1);
- }
- /*
- * Set all possible fields that could differ, then do check
- * of whole super block against an alternate super block.
- * When an alternate super-block is specified this check is skipped.
- */
- getblk(&asblk, cgsblock(&sblock, sblock.fs_ncg - 1), sblock.fs_sbsize);
- if (asblk.b_errs)
- return (0);
- altsblock.fs_firstfield = sblock.fs_firstfield;
- altsblock.fs_unused_1 = sblock.fs_unused_1;
- altsblock.fs_time = sblock.fs_time;
- altsblock.fs_cstotal = sblock.fs_cstotal;
- altsblock.fs_cgrotor = sblock.fs_cgrotor;
- altsblock.fs_fmod = sblock.fs_fmod;
- altsblock.fs_clean = sblock.fs_clean;
- altsblock.fs_ronly = sblock.fs_ronly;
- altsblock.fs_flags = sblock.fs_flags;
- altsblock.fs_maxcontig = sblock.fs_maxcontig;
- altsblock.fs_minfree = sblock.fs_minfree;
- altsblock.fs_optim = sblock.fs_optim;
- altsblock.fs_rotdelay = sblock.fs_rotdelay;
- altsblock.fs_maxbpg = sblock.fs_maxbpg;
- memmove(altsblock.fs_csp, sblock.fs_csp, sizeof sblock.fs_csp);
- altsblock.fs_maxcluster = sblock.fs_maxcluster;
- memmove(altsblock.fs_fsmnt, sblock.fs_fsmnt, sizeof sblock.fs_fsmnt);
- memmove(altsblock.fs_sparecon,
- sblock.fs_sparecon, sizeof sblock.fs_sparecon);
- /*
- * The following should not have to be copied.
- */
- altsblock.fs_fsbtodb = sblock.fs_fsbtodb;
- altsblock.fs_interleave = sblock.fs_interleave;
- altsblock.fs_npsect = sblock.fs_npsect;
- altsblock.fs_nrpos = sblock.fs_nrpos;
- altsblock.fs_state = sblock.fs_state;
- altsblock.fs_qbmask = sblock.fs_qbmask;
- altsblock.fs_qfmask = sblock.fs_qfmask;
- altsblock.fs_state = sblock.fs_state;
- altsblock.fs_maxfilesize = sblock.fs_maxfilesize;
- if (memcmp(&sblock, &altsblock, (int)sblock.fs_sbsize)) {
- if (debug) {
- long *nlp, *olp, *endlp;
-
- printf("superblock mismatches\n");
- nlp = (long *)&altsblock;
- olp = (long *)&sblock;
- endlp = olp + (sblock.fs_sbsize / sizeof *olp);
- for ( ; olp < endlp; olp++, nlp++) {
- if (*olp == *nlp)
- continue;
- printf(
- "offset %d, original %ld, alternate %ld\n",
- olp - (long *)&sblock, *olp, *nlp);
- }
- }
- badsb(listerr,
- "VALUES IN SUPER BLOCK DISAGREE WITH THOSE IN FIRST ALTERNATE");
- return (0);
- }
- havesb = 1;
- return (1);
-}
-
-static void
-badsb(listerr, s)
- int listerr;
- char *s;
-{
-
- if (!listerr)
- return;
- if (preen)
- printf("%s: ", cdevname);
- pfatal("BAD SUPER BLOCK: %s\n", s);
-}
-
-/*
- * Calculate a prototype superblock based on information in the disk label.
- * When done the cgsblock macro can be calculated and the fs_ncg field
- * can be used. Do NOT attempt to use other macros without verifying that
- * their needed information is available!
- */
-static int
-calcsb(dev, devfd, fs)
- char *dev;
- int devfd;
- register struct fs *fs;
-{
- register struct disklabel *lp;
- register struct partition *pp;
- register char *cp;
- int i;
-
- cp = strchr(dev, '\0') - 1;
- if (cp == (char *)-1 || ((*cp < 'a' || *cp > 'h') && !isdigit(*cp))) {
- pfatal("%s: CANNOT FIGURE OUT FILE SYSTEM PARTITION\n", dev);
- return (0);
- }
- lp = getdisklabel(dev, devfd);
- if (isdigit(*cp))
- pp = &lp->d_partitions[0];
- else
- pp = &lp->d_partitions[*cp - 'a'];
- if (pp->p_fstype != FS_BSDFFS) {
- pfatal("%s: NOT LABELED AS A BSD FILE SYSTEM (%s)\n",
- dev, pp->p_fstype < FSMAXTYPES ?
- fstypenames[pp->p_fstype] : "unknown");
- return (0);
- }
- if (pp->p_fsize == 0 || pp->p_frag == 0 ||
- pp->p_cpg == 0 || pp->p_size == 0) {
- pfatal("%s: %s: type %s fsize %d, frag %d, cpg %d, size %d\n",
- dev, "INCOMPLETE LABEL", fstypenames[pp->p_fstype],
- pp->p_fsize, pp->p_frag, pp->p_cpg, pp->p_size);
- return (0);
- }
- memset(fs, 0, sizeof(struct fs));
- fs->fs_fsize = pp->p_fsize;
- fs->fs_frag = pp->p_frag;
- fs->fs_cpg = pp->p_cpg;
- fs->fs_size = pp->p_size;
- fs->fs_ntrak = lp->d_ntracks;
- fs->fs_nsect = lp->d_nsectors;
- fs->fs_spc = lp->d_secpercyl;
- fs->fs_nspf = fs->fs_fsize / lp->d_secsize;
- fs->fs_sblkno = roundup(
- howmany(lp->d_bbsize + lp->d_sbsize, fs->fs_fsize),
- fs->fs_frag);
- fs->fs_cgmask = 0xffffffff;
- for (i = fs->fs_ntrak; i > 1; i >>= 1)
- fs->fs_cgmask <<= 1;
- if (!POWEROF2(fs->fs_ntrak))
- fs->fs_cgmask <<= 1;
- fs->fs_cgoffset = roundup(
- howmany(fs->fs_nsect, NSPF(fs)), fs->fs_frag);
- fs->fs_fpg = (fs->fs_cpg * fs->fs_spc) / NSPF(fs);
- fs->fs_ncg = howmany(fs->fs_size / fs->fs_spc, fs->fs_cpg);
- for (fs->fs_fsbtodb = 0, i = NSPF(fs); i > 1; i >>= 1)
- fs->fs_fsbtodb++;
- dev_bsize = lp->d_secsize;
- return (1);
-}
-
-static struct disklabel *
-getdisklabel(s, fd)
- char *s;
- int fd;
-{
- static struct disklabel lab;
-
- if (ioctl(fd, DIOCGDINFO, (char *)&lab) < 0) {
- if (s == NULL)
- return ((struct disklabel *)NULL);
- pwarn("ioctl (GCINFO): %s\n", strerror(errno));
- errx(EEXIT, "%s: can't read disk label", s);
- }
- return (&lab);
-}
diff --git a/sbin/fsck_ifs/utilities.c b/sbin/fsck_ifs/utilities.c
deleted file mode 100644
index 1efdabcd11d0..000000000000
--- a/sbin/fsck_ifs/utilities.c
+++ /dev/null
@@ -1,683 +0,0 @@
-/*
- * Copyright (c) 1980, 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-#if 0
-static const char sccsid[] = "@(#)utilities.c 8.6 (Berkeley) 5/19/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <sys/param.h>
-
-#include <ufs/ufs/dinode.h>
-#include <ufs/ufs/dir.h>
-#include <ufs/ffs/fs.h>
-
-#include <err.h>
-#include <string.h>
-
-#include "fsck.h"
-
-long diskreads, totalreads; /* Disk cache statistics */
-
-static void rwerror __P((char *mesg, ufs_daddr_t blk));
-
-int
-ftypeok(dp)
- struct dinode *dp;
-{
- switch (dp->di_mode & IFMT) {
-
- case IFDIR:
- case IFREG:
- case IFBLK:
- case IFCHR:
- case IFLNK:
- case IFSOCK:
- case IFIFO:
- return (1);
-
- default:
- if (debug)
- printf("bad file type 0%o\n", dp->di_mode);
- return (0);
- }
-}
-
-int
-reply(question)
- char *question;
-{
- int persevere;
- char c;
-
- if (preen)
- pfatal("INTERNAL ERROR: GOT TO reply()");
- persevere = !strcmp(question, "CONTINUE");
- printf("\n");
- if (!persevere && (nflag || fswritefd < 0)) {
- printf("%s? no\n\n", question);
- resolved = 0;
- return (0);
- }
- if (yflag || (persevere && nflag)) {
- printf("%s? yes\n\n", question);
- return (1);
- }
- do {
- printf("%s? [yn] ", question);
- (void) fflush(stdout);
- c = getc(stdin);
- while (c != '\n' && getc(stdin) != '\n') {
- if (feof(stdin)) {
- resolved = 0;
- return (0);
- }
- }
- } while (c != 'y' && c != 'Y' && c != 'n' && c != 'N');
- printf("\n");
- if (c == 'y' || c == 'Y')
- return (1);
- resolved = 0;
- return (0);
-}
-
-/*
- * Look up state information for an inode.
- */
-struct inostat *
-inoinfo(inum)
- ino_t inum;
-{
- static struct inostat unallocated = { USTATE, 0, 0 };
- struct inostatlist *ilp;
- int iloff;
-
- if (inum > maxino)
- errx(EEXIT, "inoinfo: inumber %d out of range", inum);
- ilp = &inostathead[inum / sblock.fs_ipg];
- iloff = inum % sblock.fs_ipg;
- if (iloff >= ilp->il_numalloced)
- return (&unallocated);
- return (&ilp->il_stat[iloff]);
-}
-
-/*
- * Malloc buffers and set up cache.
- */
-void
-bufinit()
-{
- register struct bufarea *bp;
- long bufcnt, i;
- char *bufp;
-
- pbp = pdirbp = (struct bufarea *)0;
- bufp = malloc((unsigned int)sblock.fs_bsize);
- if (bufp == 0)
- errx(EEXIT, "cannot allocate buffer pool");
- cgblk.b_un.b_buf = bufp;
- initbarea(&cgblk);
- bufhead.b_next = bufhead.b_prev = &bufhead;
- bufcnt = MAXBUFSPACE / sblock.fs_bsize;
- if (bufcnt < MINBUFS)
- bufcnt = MINBUFS;
- for (i = 0; i < bufcnt; i++) {
- bp = (struct bufarea *)malloc(sizeof(struct bufarea));
- bufp = malloc((unsigned int)sblock.fs_bsize);
- if (bp == NULL || bufp == NULL) {
- if (i >= MINBUFS)
- break;
- errx(EEXIT, "cannot allocate buffer pool");
- }
- bp->b_un.b_buf = bufp;
- bp->b_prev = &bufhead;
- bp->b_next = bufhead.b_next;
- bufhead.b_next->b_prev = bp;
- bufhead.b_next = bp;
- initbarea(bp);
- }
- bufhead.b_size = i; /* save number of buffers */
-}
-
-/*
- * Manage a cache of directory blocks.
- */
-struct bufarea *
-getdatablk(blkno, size)
- ufs_daddr_t blkno;
- long size;
-{
- register struct bufarea *bp;
-
- for (bp = bufhead.b_next; bp != &bufhead; bp = bp->b_next)
- if (bp->b_bno == fsbtodb(&sblock, blkno))
- goto foundit;
- for (bp = bufhead.b_prev; bp != &bufhead; bp = bp->b_prev)
- if ((bp->b_flags & B_INUSE) == 0)
- break;
- if (bp == &bufhead)
- errx(EEXIT, "deadlocked buffer pool");
- getblk(bp, blkno, size);
- /* fall through */
-foundit:
- totalreads++;
- bp->b_prev->b_next = bp->b_next;
- bp->b_next->b_prev = bp->b_prev;
- bp->b_prev = &bufhead;
- bp->b_next = bufhead.b_next;
- bufhead.b_next->b_prev = bp;
- bufhead.b_next = bp;
- bp->b_flags |= B_INUSE;
- return (bp);
-}
-
-void
-getblk(bp, blk, size)
- register struct bufarea *bp;
- ufs_daddr_t blk;
- long size;
-{
- ufs_daddr_t dblk;
-
- dblk = fsbtodb(&sblock, blk);
- if (bp->b_bno != dblk) {
- flush(fswritefd, bp);
- diskreads++;
- bp->b_errs = bread(fsreadfd, bp->b_un.b_buf, dblk, size);
- bp->b_bno = dblk;
- bp->b_size = size;
- }
-}
-
-void
-flush(fd, bp)
- int fd;
- register struct bufarea *bp;
-{
- register int i, j;
-
- if (!bp->b_dirty)
- return;
- if (bp->b_errs != 0)
- pfatal("WRITING %sZERO'ED BLOCK %d TO DISK\n",
- (bp->b_errs == bp->b_size / dev_bsize) ? "" : "PARTIALLY ",
- bp->b_bno);
- bp->b_dirty = 0;
- bp->b_errs = 0;
- bwrite(fd, bp->b_un.b_buf, bp->b_bno, (long)bp->b_size);
- if (bp != &sblk)
- return;
- for (i = 0, j = 0; i < sblock.fs_cssize; i += sblock.fs_bsize, j++) {
- bwrite(fswritefd, (char *)sblock.fs_csp[j],
- fsbtodb(&sblock, sblock.fs_csaddr + j * sblock.fs_frag),
- sblock.fs_cssize - i < sblock.fs_bsize ?
- sblock.fs_cssize - i : sblock.fs_bsize);
- }
-}
-
-static void
-rwerror(mesg, blk)
- char *mesg;
- ufs_daddr_t blk;
-{
-
- if (preen == 0)
- printf("\n");
- pfatal("CANNOT %s: BLK %ld", mesg, blk);
- if (reply("CONTINUE") == 0)
- exit(EEXIT);
-}
-
-void
-ckfini(markclean)
- int markclean;
-{
- register struct bufarea *bp, *nbp;
- int ofsmodified, cnt = 0;
-
- if (fswritefd < 0) {
- (void)close(fsreadfd);
- return;
- }
- flush(fswritefd, &sblk);
- if (havesb && sblk.b_bno != SBOFF / dev_bsize &&
- !preen && reply("UPDATE STANDARD SUPERBLOCK")) {
- sblk.b_bno = SBOFF / dev_bsize;
- sbdirty();
- flush(fswritefd, &sblk);
- }
- flush(fswritefd, &cgblk);
- free(cgblk.b_un.b_buf);
- for (bp = bufhead.b_prev; bp && bp != &bufhead; bp = nbp) {
- cnt++;
- flush(fswritefd, bp);
- nbp = bp->b_prev;
- free(bp->b_un.b_buf);
- free((char *)bp);
- }
- if (bufhead.b_size != cnt)
- errx(EEXIT, "panic: lost %d buffers", bufhead.b_size - cnt);
- pbp = pdirbp = (struct bufarea *)0;
- if (sblock.fs_clean != markclean) {
- sblock.fs_clean = markclean;
- sbdirty();
- ofsmodified = fsmodified;
- flush(fswritefd, &sblk);
- fsmodified = ofsmodified;
- if (!preen) {
- printf("\n***** FILE SYSTEM MARKED %s *****\n",
- markclean ? "CLEAN" : "DIRTY");
- if (!markclean)
- rerun = 1;
- }
- } else if (!preen && !markclean) {
- printf("\n***** FILE SYSTEM STILL DIRTY *****\n");
- rerun = 1;
- }
- if (debug)
- printf("cache missed %ld of %ld (%d%%)\n", diskreads,
- totalreads, (int)(diskreads * 100 / totalreads));
- (void)close(fsreadfd);
- (void)close(fswritefd);
-}
-
-int
-bread(fd, buf, blk, size)
- int fd;
- char *buf;
- ufs_daddr_t blk;
- long size;
-{
- char *cp;
- int i, errs;
- off_t offset;
-
- offset = blk;
- offset *= dev_bsize;
- if (lseek(fd, offset, 0) < 0)
- rwerror("SEEK", blk);
- else if (read(fd, buf, (int)size) == size)
- return (0);
- rwerror("READ", blk);
- if (lseek(fd, offset, 0) < 0)
- rwerror("SEEK", blk);
- errs = 0;
- memset(buf, 0, (size_t)size);
- printf("THE FOLLOWING DISK SECTORS COULD NOT BE READ:");
- for (cp = buf, i = 0; i < size; i += secsize, cp += secsize) {
- if (read(fd, cp, (int)secsize) != secsize) {
- (void)lseek(fd, offset + i + secsize, 0);
- if (secsize != dev_bsize && dev_bsize != 1)
- printf(" %ld (%ld),",
- (blk * dev_bsize + i) / secsize,
- blk + i / dev_bsize);
- else
- printf(" %ld,", blk + i / dev_bsize);
- errs++;
- }
- }
- printf("\n");
- if (errs)
- resolved = 0;
- return (errs);
-}
-
-void
-bwrite(fd, buf, blk, size)
- int fd;
- char *buf;
- ufs_daddr_t blk;
- long size;
-{
- int i;
- char *cp;
- off_t offset;
-
- if (fd < 0)
- return;
- offset = blk;
- offset *= dev_bsize;
- if (lseek(fd, offset, 0) < 0)
- rwerror("SEEK", blk);
- else if (write(fd, buf, (int)size) == size) {
- fsmodified = 1;
- return;
- }
- resolved = 0;
- rwerror("WRITE", blk);
- if (lseek(fd, offset, 0) < 0)
- rwerror("SEEK", blk);
- printf("THE FOLLOWING SECTORS COULD NOT BE WRITTEN:");
- for (cp = buf, i = 0; i < size; i += dev_bsize, cp += dev_bsize)
- if (write(fd, cp, (int)dev_bsize) != dev_bsize) {
- (void)lseek(fd, offset + i + dev_bsize, 0);
- printf(" %ld,", blk + i / dev_bsize);
- }
- printf("\n");
- return;
-}
-
-/*
- * allocate a data block with the specified number of fragments
- */
-ufs_daddr_t
-allocblk(frags)
- long frags;
-{
- int i, j, k, cg, baseblk;
- struct cg *cgp = &cgrp;
-
- if (frags <= 0 || frags > sblock.fs_frag)
- return (0);
- for (i = 0; i < maxfsblock - sblock.fs_frag; i += sblock.fs_frag) {
- for (j = 0; j <= sblock.fs_frag - frags; j++) {
- if (testbmap(i + j))
- continue;
- for (k = 1; k < frags; k++)
- if (testbmap(i + j + k))
- break;
- if (k < frags) {
- j += k;
- continue;
- }
- cg = dtog(&sblock, i + j);
- getblk(&cgblk, cgtod(&sblock, cg), sblock.fs_cgsize);
- if (!cg_chkmagic(cgp))
- pfatal("CG %d: BAD MAGIC NUMBER\n", cg);
- baseblk = dtogd(&sblock, i + j);
- for (k = 0; k < frags; k++) {
- setbmap(i + j + k);
- clrbit(cg_blksfree(cgp), baseblk + k);
- }
- n_blks += frags;
- if (frags == sblock.fs_frag)
- cgp->cg_cs.cs_nbfree--;
- else
- cgp->cg_cs.cs_nffree -= frags;
- cgdirty();
- return (i + j);
- }
- }
- return (0);
-}
-
-/*
- * Free a previously allocated block
- */
-void
-freeblk(blkno, frags)
- ufs_daddr_t blkno;
- long frags;
-{
- struct inodesc idesc;
-
- idesc.id_blkno = blkno;
- idesc.id_numfrags = frags;
- (void)pass4check(&idesc);
-}
-
-/*
- * Find a pathname
- */
-void
-getpathname(namebuf, curdir, ino)
- char *namebuf;
- ino_t curdir, ino;
-{
- int len;
- register char *cp;
- struct inodesc idesc;
- static int busy = 0;
-
- if (curdir == ino && ino == ROOTINO) {
- (void)strcpy(namebuf, "/");
- return;
- }
- if (busy ||
- (inoinfo(curdir)->ino_state != DSTATE &&
- inoinfo(curdir)->ino_state != DFOUND)) {
- (void)strcpy(namebuf, "?");
- return;
- }
- busy = 1;
- memset(&idesc, 0, sizeof(struct inodesc));
- idesc.id_type = DATA;
- idesc.id_fix = IGNORE;
- cp = &namebuf[MAXPATHLEN - 1];
- *cp = '\0';
- if (curdir != ino) {
- idesc.id_parent = curdir;
- goto namelookup;
- }
- while (ino != ROOTINO) {
- idesc.id_number = ino;
- idesc.id_func = findino;
- idesc.id_name = "..";
- if ((ckinode(ginode(ino), &idesc) & FOUND) == 0)
- break;
- namelookup:
- idesc.id_number = idesc.id_parent;
- idesc.id_parent = ino;
- idesc.id_func = findname;
- idesc.id_name = namebuf;
- if ((ckinode(ginode(idesc.id_number), &idesc)&FOUND) == 0)
- break;
- len = strlen(namebuf);
- cp -= len;
- memmove(cp, namebuf, (size_t)len);
- *--cp = '/';
- if (cp < &namebuf[MAXNAMLEN])
- break;
- ino = idesc.id_number;
- }
- busy = 0;
- if (ino != ROOTINO)
- *--cp = '?';
- memmove(namebuf, cp, (size_t)(&namebuf[MAXPATHLEN] - cp));
-}
-
-void
-catch(sig)
- int sig;
-{
- if (!doinglevel2)
- ckfini(0);
- exit(12);
-}
-
-/*
- * When preening, allow a single quit to signal
- * a special exit after filesystem checks complete
- * so that reboot sequence may be interrupted.
- */
-void
-catchquit(sig)
- int sig;
-{
- printf("returning to single-user after filesystem check\n");
- returntosingle = 1;
- (void)signal(SIGQUIT, SIG_DFL);
-}
-
-/*
- * Ignore a single quit signal; wait and flush just in case.
- * Used by child processes in preen.
- */
-void
-voidquit(sig)
- int sig;
-{
-
- sleep(1);
- (void)signal(SIGQUIT, SIG_IGN);
- (void)signal(SIGQUIT, SIG_DFL);
-}
-
-/*
- * determine whether an inode should be fixed.
- */
-int
-dofix(idesc, msg)
- register struct inodesc *idesc;
- char *msg;
-{
-
- switch (idesc->id_fix) {
-
- case DONTKNOW:
- if (idesc->id_type == DATA)
- direrror(idesc->id_number, msg);
- else
- pwarn(msg);
- if (preen) {
- printf(" (SALVAGED)\n");
- idesc->id_fix = FIX;
- return (ALTERED);
- }
- if (reply("SALVAGE") == 0) {
- idesc->id_fix = NOFIX;
- return (0);
- }
- idesc->id_fix = FIX;
- return (ALTERED);
-
- case FIX:
- return (ALTERED);
-
- case NOFIX:
- case IGNORE:
- return (0);
-
- default:
- errx(EEXIT, "UNKNOWN INODESC FIX MODE %d", idesc->id_fix);
- }
- /* NOTREACHED */
- return (0);
-}
-
-#if __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-/*
- * An unexpected inconsistency occured.
- * Die if preening or filesystem is running with soft dependency protocol,
- * otherwise just print message and continue.
- */
-void
-#if __STDC__
-pfatal(const char *fmt, ...)
-#else
-pfatal(fmt, va_alist)
- char *fmt;
- va_dcl
-#endif
-{
- va_list ap;
-#if __STDC__
- va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
- if (!preen) {
- (void)vfprintf(stderr, fmt, ap);
- va_end(ap);
- if (usedsoftdep)
- (void)fprintf(stderr,
- "\nUNEXPECTED SOFT UPDATE INCONSISTENCY\n");
- return;
- }
- if (cdevname == NULL)
- cdevname = "fsck";
- (void)fprintf(stderr, "%s: ", cdevname);
- (void)vfprintf(stderr, fmt, ap);
- (void)fprintf(stderr,
- "\n%s: UNEXPECTED%sINCONSISTENCY; RUN fsck MANUALLY.\n",
- cdevname, usedsoftdep ? " SOFT UPDATE " : " ");
- ckfini(0);
- exit(EEXIT);
-}
-
-/*
- * Pwarn just prints a message when not preening or running soft dependency
- * protocol, or a warning (preceded by filename) when preening.
- */
-void
-#if __STDC__
-pwarn(const char *fmt, ...)
-#else
-pwarn(fmt, va_alist)
- char *fmt;
- va_dcl
-#endif
-{
- va_list ap;
-#if __STDC__
- va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
- if (preen)
- (void)fprintf(stderr, "%s: ", cdevname);
- (void)vfprintf(stderr, fmt, ap);
- va_end(ap);
-}
-
-/*
- * Stub for routines from kernel.
- */
-void
-#if __STDC__
-panic(const char *fmt, ...)
-#else
-panic(fmt, va_alist)
- char *fmt;
- va_dcl
-#endif
-{
- va_list ap;
-#if __STDC__
- va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
- pfatal("INTERNAL INCONSISTENCY:");
- (void)vfprintf(stderr, fmt, ap);
- va_end(ap);
- exit(EEXIT);
-}
diff --git a/sbin/mount_ifs/Makefile b/sbin/mount_ifs/Makefile
deleted file mode 100644
index 96c996db24fe..000000000000
--- a/sbin/mount_ifs/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-# @(#)Makefile 8.6 (Berkeley) 5/8/95
-# $FreeBSD$
-
-PROG= mount
-SRCS= mount.c mount_ufs.c getmntopts.c vfslist.c
-MAN8= mount.8
-# We do NOT install the getmntopts.3 man page.
-
-.include <bsd.prog.mk>
diff --git a/sbin/mount_ifs/extern.h b/sbin/mount_ifs/extern.h
deleted file mode 100644
index bc11a037ecfd..000000000000
--- a/sbin/mount_ifs/extern.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*-
- * Copyright (c) 1997 FreeBSD Inc.
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-/* vfslist.c */
-int checkvfsname __P((const char *, const char **));
-const char **makevfslist __P((char *));
-
-/* mount_ufs.c */
-int mount_ufs __P((int, char *const *));
diff --git a/sbin/mount_ifs/getmntopts.3 b/sbin/mount_ifs/getmntopts.3
deleted file mode 100644
index 84ad24f598a7..000000000000
--- a/sbin/mount_ifs/getmntopts.3
+++ /dev/null
@@ -1,180 +0,0 @@
-.\" Copyright (c) 1994
-.\" 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. 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, Berkeley and its contributors.
-.\" 4. 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.
-.\"
-.\" @(#)getmntopts.3 8.3 (Berkeley) 3/30/95
-.\" $FreeBSD$
-.\"
-.Dd March 30, 1995
-.Dt GETMNTOPTS 3
-.Os BSD 4.4
-.Sh NAME
-.Nm getmntopts
-.Nd scan mount options
-.Sh SYNOPSIS
-.Fd #include <mntopts.h>
-.Ft void
-.Fn getmntopts "char *options" "struct mntopt *mopts" "int *flagp" "int *altflagp"
-.Sh DESCRIPTION
-The
-.Nm getmntopts
-function takes a comma separated option list and a list
-of valid option names, and computes the bitmask
-corresponding to the requested set of options.
-.Pp
-The string
-.Dv options
-is broken down into a sequence of comma separated tokens.
-Each token is looked up in the table described by
-.Dv mopts
-and the bits in
-the word referenced by either
-.Dv flagp
-or
-.Dv altflagp
-(depending on the
-.Dv m_altloc
-field of the option's table entry)
-are updated.
-The flag words are not initialized by
-.Nm getmntopt .
-The table,
-.Dv mopts ,
-has the following format:
-.Bd -literal
-struct mntopt {
- char *m_option; /* option name */
- int m_inverse; /* is this a negative option, e.g. "dev" */
- int m_flag; /* bit to set, e.g. MNT_RDONLY */
- int m_altloc; /* non-zero to use altflagp rather than flagp */
-};
-.Ed
-.Pp
-The members of this structure are:
-.Bl -tag -width m_inverse
-.It Fa m_option
-the option name,
-for example
-.Dq suid .
-.It Fa m_inverse
-tells
-.Nm getmntopts
-that the name has the inverse meaning of the
-bit.
-For example,
-.Dq suid
-is the string, whereas the
-mount flag is
-.Dv MNT_NOSUID .
-In this case, the sense of the string and the flag
-are inverted, so the
-.Dv m_inverse
-flag should be set.
-.It Fa m_flag
-the value of the bit to be set or cleared in
-the flag word when the option is recognized.
-The bit is set when the option is discovered,
-but cleared if the option name was preceded
-by the letters
-.Dq no .
-The
-.Dv m_inverse
-flag causes these two operations to be reversed.
-.It Fa m_altloc
-the bit should be set or cleared in
-.Dv altflagp
-rather than
-.Dv flagp .
-.El
-.Pp
-Each of the user visible
-.Dv MNT_
-flags has a corresponding
-.Dv MOPT_
-macro which defines an appropriate
-.Li "struct mntopt"
-entry.
-To simplify the program interface and ensure consistency across all
-programs, a general purpose macro,
-.Dv MOPT_STDOPTS ,
-is defined which
-contains an entry for all the generic VFS options.
-In addition, the macros
-.Dv MOPT_FORCE
-and
-.Dv MOPT_UPDATE
-exist to enable the
-.Dv MNT_FORCE
-and
-.Dv MNT_UPDATE
-flags to be set.
-Finally, the table must be terminated by an entry with a NULL
-first element.
-.Sh EXAMPLES
-Most commands will use the standard option set.
-Local filesystems which support the
-.Dv MNT_UPDATE
-flag, would also have an
-.Dv MOPT_UPDATE
-entry.
-This can be declared and used as follows:
-.Bd -literal
-#include "mntopts.h"
-
-struct mntopt mopts[] = {
- MOPT_STDOPTS,
- MOPT_UPDATE,
- { NULL }
-};
-
- ...
- mntflags = mntaltflags = 0;
- ...
- getmntopts(options, mopts, &mntflags, &mntaltflags);
- ...
-.Ed
-.Sh DIAGNOSTICS
-If the external integer variable
-.Dv getmnt_silent
-is non-zero then the
-.Nm getmntopts
-function displays an error message and exits if an
-unrecognized option is encountered.
-By default
-.Dv getmnt_silent
-is zero.
-.Sh SEE ALSO
-.Xr err 3 ,
-.Xr mount 8
-.Sh HISTORY
-The
-.Fn getmntopts
-function appeared in
-.Bx 4.4 .
diff --git a/sbin/mount_ifs/getmntopts.c b/sbin/mount_ifs/getmntopts.c
deleted file mode 100644
index ffc18bfac219..000000000000
--- a/sbin/mount_ifs/getmntopts.c
+++ /dev/null
@@ -1,147 +0,0 @@
-/*-
- * Copyright (c) 1994
- * 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-#if 0
-static char sccsid[] = "@(#)getmntopts.c 8.3 (Berkeley) 3/29/95";
-#else
-static const char rcsid[] =
- "$FreeBSD$";
-#endif
-#endif /* not lint */
-
-#include <sys/param.h>
-#include <sys/stat.h>
-
-#include <err.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sysexits.h>
-
-#include "mntopts.h"
-
-int getmnt_silent = 0;
-
-void
-getmntopts(options, m0, flagp, altflagp)
- const char *options;
- const struct mntopt *m0;
- int *flagp;
- int *altflagp;
-{
- const struct mntopt *m;
- int negative, len;
- char *opt, *optbuf, *p;
- int *thisflagp;
-
- /* Copy option string, since it is about to be torn asunder... */
- if ((optbuf = strdup(options)) == NULL)
- err(1, NULL);
-
- for (opt = optbuf; (opt = strtok(opt, ",")) != NULL; opt = NULL) {
- /* Check for "no" prefix. */
- if (opt[0] == 'n' && opt[1] == 'o') {
- negative = 1;
- opt += 2;
- } else
- negative = 0;
-
- /*
- * for options with assignments in them (ie. quotas)
- * ignore the assignment as it's handled elsewhere
- */
- p = strchr(opt, '=');
- if (p)
- *++p = '\0';
-
- /* Scan option table. */
- for (m = m0; m->m_option != NULL; ++m) {
- len = strlen(m->m_option);
- if (strncasecmp(opt, m->m_option, len) == 0)
- if ( m->m_option[len] == '\0'
- || m->m_option[len] == '='
- )
- break;
- }
-
- /* Save flag, or fail if option is not recognized. */
- if (m->m_option) {
- thisflagp = m->m_altloc ? altflagp : flagp;
- if (negative == m->m_inverse)
- *thisflagp |= m->m_flag;
- else
- *thisflagp &= ~m->m_flag;
- } else if (!getmnt_silent) {
- errx(1, "-o %s: option not supported", opt);
- }
- }
-
- free(optbuf);
-}
-
-void
-rmslashes(rrpin, rrpout)
- char *rrpin;
- char *rrpout;
-{
- char *rrpoutstart;
-
- *rrpout = *rrpin;
- for (rrpoutstart = rrpout; *rrpin != '\0'; *rrpout++ = *rrpin++) {
-
- /* skip all double slashes */
- while (*rrpin == '/' && *(rrpin + 1) == '/')
- rrpin++;
- }
-
- /* remove trailing slash if necessary */
- if (rrpout - rrpoutstart > 1 && *(rrpout - 1) == '/')
- *(rrpout - 1) = '\0';
- else
- *rrpout = '\0';
-}
-
-void
-checkpath(path, resolved)
- const char *path;
- char *resolved;
-{
- struct stat sb;
-
- if (realpath(path, resolved) != NULL && stat(resolved, &sb) == 0) {
- if (!S_ISDIR(sb.st_mode))
- errx(EX_USAGE, "%s: not a directory", resolved);
- } else
- errx(EX_USAGE, "%s: %s", resolved, strerror(errno));
-}
diff --git a/sbin/mount_ifs/mntopts.h b/sbin/mount_ifs/mntopts.h
deleted file mode 100644
index 73c3c15a838f..000000000000
--- a/sbin/mount_ifs/mntopts.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*-
- * Copyright (c) 1994
- * 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)mntopts.h 8.7 (Berkeley) 3/29/95
- * $FreeBSD$
- */
-
-struct mntopt {
- const char *m_option; /* option name */
- int m_inverse; /* if a negative option, e.g. "dev" */
- int m_flag; /* bit to set, e.g. MNT_RDONLY */
- int m_altloc; /* 1 => set bit in altflags */
-};
-
-/* User-visible MNT_ flags. */
-#define MOPT_ASYNC { "async", 0, MNT_ASYNC, 0 }
-#define MOPT_NOATIME { "atime", 1, MNT_NOATIME, 0 }
-#define MOPT_NODEV { "dev", 1, MNT_NODEV, 0 }
-#define MOPT_NOEXEC { "exec", 1, MNT_NOEXEC, 0 }
-#define MOPT_NOSUID { "suid", 1, MNT_NOSUID, 0 }
-#define MOPT_NOSYMFOLLOW { "symfollow", 1, MNT_NOSYMFOLLOW, 0 }
-#define MOPT_RDONLY { "rdonly", 0, MNT_RDONLY, 0 }
-#define MOPT_SYNC { "sync", 0, MNT_SYNCHRONOUS, 0 }
-#define MOPT_UNION { "union", 0, MNT_UNION, 0 }
-#define MOPT_USERQUOTA { "userquota", 0, 0, 0 }
-#define MOPT_GROUPQUOTA { "groupquota", 0, 0, 0 }
-#define MOPT_NOCLUSTERR { "clusterr", 1, MNT_NOCLUSTERR, 0 }
-#define MOPT_NOCLUSTERW { "clusterw", 1, MNT_NOCLUSTERW, 0 }
-#define MOPT_SUIDDIR { "suiddir", 0, MNT_SUIDDIR, 0 }
-
-/* Control flags. */
-#define MOPT_FORCE { "force", 0, MNT_FORCE, 0 }
-#define MOPT_UPDATE { "update", 0, MNT_UPDATE, 0 }
-#define MOPT_RO { "ro", 0, MNT_RDONLY, 0 }
-#define MOPT_RW { "rw", 1, MNT_RDONLY, 0 }
-
-/* This is parsed by mount(8), but is ignored by specific mount_*(8)s. */
-#define MOPT_AUTO { "auto", 0, 0, 0 }
-
-#define MOPT_FSTAB_COMPAT \
- MOPT_RO, \
- MOPT_RW, \
- MOPT_AUTO
-
-/* Standard options which all mounts can understand. */
-#define MOPT_STDOPTS \
- MOPT_USERQUOTA, \
- MOPT_GROUPQUOTA, \
- MOPT_FSTAB_COMPAT, \
- MOPT_NOATIME, \
- MOPT_NODEV, \
- MOPT_NOEXEC, \
- MOPT_SUIDDIR, /* must be before MOPT_NOSUID */ \
- MOPT_NOSUID, \
- MOPT_NOSYMFOLLOW, \
- MOPT_RDONLY, \
- MOPT_UNION, \
- MOPT_NOCLUSTERR, \
- MOPT_NOCLUSTERW
-
-void getmntopts __P((const char *, const struct mntopt *, int *, int *));
-void rmslashes __P((char *, char *));
-void checkpath __P((const char *, char resolved_path[]));
-extern int getmnt_silent;
diff --git a/sbin/mount_ifs/mount.8 b/sbin/mount_ifs/mount.8
deleted file mode 100644
index 9ac9e0c2c9fe..000000000000
--- a/sbin/mount_ifs/mount.8
+++ /dev/null
@@ -1,381 +0,0 @@
-.\" Copyright (c) 1980, 1989, 1991, 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. 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, Berkeley and its contributors.
-.\" 4. 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.
-.\"
-.\" @(#)mount.8 8.8 (Berkeley) 6/16/94
-.\" $FreeBSD$
-.\"
-.Dd June 16, 1994
-.Dt MOUNT 8
-.Os BSD 4
-.Sh NAME
-.Nm mount
-.Nd mount file systems
-.Sh SYNOPSIS
-.Nm mount
-.Op Fl adfpruvw
-.Op Fl t Ar ufs | lfs | external_type
-.Nm mount
-.Op Fl dfpruvw
-.Ar special | node
-.Nm mount
-.Op Fl dfpruvw
-.Op Fl o Ar options
-.Op Fl t Ar ufs | lfs | external_type
-.Ar special node
-.Sh DESCRIPTION
-The
-.Nm
-command
-calls the
-.Xr mount 2
-system call to prepare and graft a
-.Ar "special device"
-or the remote node (rhost:path) on to the file system tree at the point
-.Ar node .
-If either
-.Ar special
-or
-.Ar node
-are not provided, the appropriate information is taken from the
-.Xr fstab 5
-file.
-.Pp
-The system maintains a list of currently mounted file systems.
-If no arguments are given to
-.Nm mount ,
-this list is printed.
-.Pp
-The options are as follows:
-.Bl -tag -width indent
-.It Fl a
-All the filesystems described in
-.Xr fstab 5
-are mounted.
-Exceptions are those marked as ``noauto'', excluded by the
-.Fl t
-flag (see below), or if they are already mounted (except the
-root filesystem which is always remounted to preserve
-traditional single user mode behavior).
-.It Fl d
-Causes everything to be done except for the actual system call.
-This option is useful in conjunction with the
-.Fl v
-flag to
-determine what the
-.Nm
-command is trying to do.
-.It Fl f
-Forces the revocation of write access when trying to downgrade
-a filesystem mount status from read-write to read-only.
-Also
-forces the R/W mount of an unclean filesystem (dangerous; use with
-caution).
-.It Fl o
-Options are specified with a
-.Fl o
-flag followed by a comma separated string of options.
-In case of conflicting options being specified, the rightmost option
-takes effect.
-The following options are available:
-.Bl -tag -width indent
-.It async
-All
-.Tn I/O
-to the file system should be done asynchronously.
-This is a
-.Em dangerous
-flag to set,
-and should not be used unless you are prepared to recreate the file
-system should your system crash.
-.It current
-When used with the
-.Fl u
-flag, this is the same as specifying the options currently in effect for
-the mounted filesystem.
-.It force
-The same as
-.Fl f ;
-forces the revocation of write access when trying to downgrade
-a filesystem mount status from read-write to read-only.
-Also
-forces the R/W mount of an unclean filesystem (dangerous; use with caution).
-.It fstab
-When used with the
-.Fl u
-flag, this is the same as specifying all the options listed in the
-.Xr fstab 5
-file for the filesystem.
-.It noasync
-Metadata I/O should be done synchronously, while data I/O should be done
-asynchronously. This is the default.
-.It noatime
-Do not update the file access time when reading from a file.
-This option
-is useful on filesystems where there are large numbers of files and
-performance is more critical than updating the file access time (which is
-rarely ever important). This option is currently only supported on local
-filesystems.
-.It noauto
-This filesystem should be skipped when mount is run with the
-.Fl a
-flag.
-.It noclusterr
-Disable read clustering.
-.It noclusterw
-Disable write clustering.
-.It nodev
-Do not interpret character or block special devices on the file system.
-This option is useful for a server that has file systems containing
-special devices for architectures other than its own.
-.It noexec
-Do not allow execution of any binaries on the mounted file system.
-This option is useful for a server that has file systems containing
-binaries for architectures other than its own.
-.It nosuid
-Do not allow set-user-identifier or set-group-identifier bits to take effect.
-Note: this option is worthless if a public available suid or sgid
-wrapper like
-.Xr suidperl 1
-is installed on your system.
-.It nosymfollow
-Do not follow symlinks
-on the mounted file system.
-.It rdonly
-The same as
-.Fl r ;
-mount the file system read-only (even the super-user may not write it).
-.It sync
-All
-.Tn I/O
-to the file system should be done synchronously.
-.It suiddir
-A directory on the mounted filesystem will respond to the SUID bit
-being set, by setting the owner of any new files to be the same
-as the owner of the directory.
-New directories will inherit the bit from their parents.
-Execute bits are removed from
-the file, and it will not be given to root.
-.Pp
-This feature is designed for use on fileservers serving PC users via
-ftp, SAMBA, or netatalk.
-It provides security holes for shell users and as
-such should not be used on shell machines, especially on home directories.
-This option requires the SUIDDIR
-option in the kernel to work.
-Only UFS filesystems support this option.
-See
-.Xr chmod 2
-for more information.
-.It update
-The same as
-.Fl u ;
-indicate that the status of an already mounted file system should be changed.
-.It union
-Causes the namespace at the mount point to appear as the union
-of the mounted filesystem root and the existing directory.
-Lookups will be done in the mounted filesystem first.
-If those operations fail due to a non-existent file the underlying
-directory is then accessed.
-All creates are done in the mounted filesystem.
-.El
-.Pp
-Any additional options specific to a filesystem type that is not
-one of the internally known types (see the
-.Fl t
-option) may be passed as a comma separated list; these options are
-distinguished by a leading
-.Dq \&-
-(dash).
-Options that take a value are specified using the syntax -option=value.
-For example, the
-.Nm
-command:
-.Bd -literal -offset indent
-mount -t mfs -o nosuid,-N,-s=4000 /dev/dk0b /tmp
-.Ed
-.Pp
-causes
-.Nm
-to execute the equivalent of:
-.Bd -literal -offset indent
-/sbin/mount_mfs -o nosuid -N -s 4000 /dev/dk0b /tmp
-.Ed
-.It Fl p
-Print mount information in fstab format.
-Implies also the
-.Fl v
-option.
-.It Fl r
-The file system is to be mounted read-only.
-Mount the file system read-only (even the super-user may not write it).
-The same as the
-.Dq rdonly
-argument to the
-.Fl o
-option.
-.It Fl t Ar "ufs \\*(Ba lfs \\*(Ba external type"
-The argument following the
-.Fl t
-is used to indicate the file system type.
-The type
-.Ar ufs
-is the default.
-The
-.Fl t
-option can be used
-to indicate that the actions should only be taken on
-filesystems of the specified type.
-More than one type may be specified in a comma separated list.
-The list of filesystem types can be prefixed with
-.Dq no
-to specify the filesystem types for which action should
-.Em not
-be taken.
-For example, the
-.Nm
-command:
-.Bd -literal -offset indent
-mount -a -t nonfs,mfs
-.Ed
-.Pp
-mounts all filesystems except those of type
-.Tn NFS
-and
-.Tn MFS .
-.Pp
-If the type is not one of the internally known types,
-.Nm
-will attempt to execute a program in
-.Pa /sbin/mount_ Ns Em XXX
-where
-.Em XXX
-is replaced by the type name.
-For example, nfs filesystems are mounted by the program
-.Pa /sbin/mount_nfs .
-.Pp
-Most filesystems will be dynamically loaded by their mount programs
-if not already present in the kernel, using the
-.Xr vfsload 3
-subroutine. Because this mechanism requires writable temporary space,
-the filesystem type containing
-.Pa /tmp
-must be compiled into the kernel, and the filesystems containing
-.Pa /tmp
-and
-.Pa /usr/bin/ld
-must be listed in
-.Pa /etc/fstab
-before any filesystems which might be dynamically loaded.
-.It Fl u
-The
-.Fl u
-flag indicates that the status of an already mounted file
-system should be changed.
-Any of the options discussed above (the
-.Fl o
-option)
-may be changed;
-also a file system can be changed from read-only to read-write
-or vice versa.
-An attempt to change from read-write to read-only will fail if any
-files on the filesystem are currently open for writing unless the
-.Fl f
-flag is also specified.
-The set of options is determined by applying the options specified
-in the argument to
-.Fl o
-and finally applying the
-.Fl r
-or
-.Fl w
-option.
-.It Fl v
-Verbose mode.
-.It Fl w
-The file system object is to be read and write.
-.Pp
-The options specific to NFS filesystems are described in the
-.Xr mount_nfs 8
-manual page.
-.Sh DIAGNOSTICS
-Various, most of them are self-explanatory.
-.Pp
-.Dl XXXXX filesystem is not available
-.Pp
-The kernel doesn't support the respective filesystem type. Note that
-support for a particular filesystem might be provided either on a static
-(kernel compile-time), or dynamic basis (loaded as a kernel module by
-.Xr kldload 8 ).
-Normally,
-.Nm
-or its subprocesses attempt to dynamically load a filesystem module if
-it hasn't been configured statically, using
-.Xr vfsload 3 .
-In this case, the above error message can also mean that you didn't
-have permission to load the module.
-.Sh FILES
-.Bl -tag -width /etc/fstab -compact
-.It Pa /etc/fstab
-file system table
-.El
-.Sh SEE ALSO
-.Xr mount 2 ,
-.Xr vfsload 3 ,
-.Xr fstab 5 ,
-.Xr kldload 8 ,
-.Xr mount_cd9660 8 ,
-.Xr mount_devfs 8 ,
-.Xr mount_fdesc 8 ,
-.Xr mount_kernfs 8 ,
-.Xr mount_lfs 8 ,
-.Xr mount_mfs 8 ,
-.Xr mount_msdos 8 ,
-.Xr mount_nfs 8 ,
-.Xr mount_null 8 ,
-.Xr mount_portal 8 ,
-.Xr mount_procfs 8 ,
-.Xr mount_umap 8 ,
-.Xr mount_union 8 ,
-.Xr umount 8
-.Sh BUGS
-It is possible for a corrupted file system to cause a crash.
-.Sh CAVEATS
-After a successful mount, the permissions on the original mount point
-determine if
-.Pa ".."
-is accessible from the mounted file system. The minimum permissions for
-the mount point for traversal across the mount point in both
-directions to be possible for all users is 0111 (execute for all).
-.Sh HISTORY
-A
-.Nm
-command appeared in
-.At v1 .
diff --git a/sbin/mount_ifs/mount.c b/sbin/mount_ifs/mount.c
deleted file mode 100644
index 65bcb5d1f0c6..000000000000
--- a/sbin/mount_ifs/mount.c
+++ /dev/null
@@ -1,745 +0,0 @@
-/*-
- * Copyright (c) 1980, 1989, 1993, 1994
- * 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-static const char copyright[] =
-"@(#) Copyright (c) 1980, 1989, 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)mount.c 8.25 (Berkeley) 5/8/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <sys/param.h>
-#include <sys/mount.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-
-#include <err.h>
-#include <errno.h>
-#include <fstab.h>
-#include <pwd.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "extern.h"
-#include "mntopts.h"
-#include "pathnames.h"
-
-/* `meta' options */
-#define MOUNT_META_OPTION_FSTAB "fstab"
-#define MOUNT_META_OPTION_CURRENT "current"
-
-int debug, fstab_style, verbose;
-
-char *catopt __P((char *, const char *));
-struct statfs
- *getmntpt __P((const char *));
-int hasopt __P((const char *, const char *));
-int ismounted __P((struct fstab *, struct statfs *, int));
-int isremountable __P((const char *));
-void mangle __P((char *, int *, const char **));
-char *update_options __P((char *, char *, int));
-int mountfs __P((const char *, const char *, const char *,
- int, const char *, const char *));
-void remopt __P((char *, const char *));
-void prmount __P((struct statfs *));
-void putfsent __P((const struct statfs *));
-void usage __P((void));
-char *flags2opts __P((int));
-
-/* Map from mount options to printable formats. */
-static struct opt {
- int o_opt;
- const char *o_name;
-} optnames[] = {
- { MNT_ASYNC, "asynchronous" },
- { MNT_EXPORTED, "NFS exported" },
- { MNT_LOCAL, "local" },
- { MNT_NOATIME, "noatime" },
- { MNT_NODEV, "nodev" },
- { MNT_NOEXEC, "noexec" },
- { MNT_NOSUID, "nosuid" },
- { MNT_NOSYMFOLLOW, "nosymfollow" },
- { MNT_QUOTA, "with quotas" },
- { MNT_RDONLY, "read-only" },
- { MNT_SYNCHRONOUS, "synchronous" },
- { MNT_UNION, "union" },
- { MNT_NOCLUSTERR, "noclusterr" },
- { MNT_NOCLUSTERW, "noclusterw" },
- { MNT_SUIDDIR, "suiddir" },
- { MNT_SOFTDEP, "soft-updates" },
- { 0, NULL }
-};
-
-/*
- * List of VFS types that can be remounted without becoming mounted on top
- * of each other.
- * XXX Is this list correct?
- */
-static const char *
-remountable_fs_names[] = {
- "ufs", "ffs", "lfs", "ext2fs",
- 0
-};
-
-int
-main(argc, argv)
- int argc;
- char * const argv[];
-{
- const char *mntfromname, **vfslist, *vfstype;
- struct fstab *fs;
- struct statfs *mntbuf;
- FILE *mountdfp;
- pid_t pid;
- int all, ch, i, init_flags, mntsize, rval, have_fstab;
- char *options;
-
- all = init_flags = 0;
- options = NULL;
- vfslist = NULL;
- vfstype = "ufs";
- while ((ch = getopt(argc, argv, "adfo:prwt:uv")) != -1)
- switch (ch) {
- case 'a':
- all = 1;
- break;
- case 'd':
- debug = 1;
- break;
- case 'f':
- init_flags |= MNT_FORCE;
- break;
- case 'o':
- if (*optarg)
- options = catopt(options, optarg);
- break;
- case 'p':
- fstab_style = 1;
- verbose = 1;
- break;
- case 'r':
- init_flags |= MNT_RDONLY;
- break;
- case 't':
- if (vfslist != NULL)
- errx(1, "only one -t option may be specified");
- vfslist = makevfslist(optarg);
- vfstype = optarg;
- break;
- case 'u':
- init_flags |= MNT_UPDATE;
- break;
- case 'v':
- verbose = 1;
- break;
- case 'w':
- init_flags &= ~MNT_RDONLY;
- break;
- case '?':
- default:
- usage();
- /* NOTREACHED */
- }
- argc -= optind;
- argv += optind;
-
-#define BADTYPE(type) \
- (strcmp(type, FSTAB_RO) && \
- strcmp(type, FSTAB_RW) && strcmp(type, FSTAB_RQ))
-
- rval = 0;
- switch (argc) {
- case 0:
- if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0)
- err(1, "getmntinfo");
- if (all) {
- while ((fs = getfsent()) != NULL) {
- if (BADTYPE(fs->fs_type))
- continue;
- if (checkvfsname(fs->fs_vfstype, vfslist))
- continue;
- if (hasopt(fs->fs_mntops, "noauto"))
- continue;
- if (!(init_flags & MNT_UPDATE) &&
- ismounted(fs, mntbuf, mntsize))
- continue;
- if (mountfs(fs->fs_vfstype, fs->fs_spec,
- fs->fs_file, init_flags, options,
- fs->fs_mntops))
- rval = 1;
- }
- } else if (fstab_style) {
- for (i = 0; i < mntsize; i++) {
- if (checkvfsname(mntbuf[i].f_fstypename, vfslist))
- continue;
- putfsent(&mntbuf[i]);
- }
- } else {
- for (i = 0; i < mntsize; i++) {
- if (checkvfsname(mntbuf[i].f_fstypename,
- vfslist))
- continue;
- prmount(&mntbuf[i]);
- }
- }
- exit(rval);
- case 1:
- if (vfslist != NULL)
- usage();
-
- if (init_flags & MNT_UPDATE) {
- mntfromname = NULL;
- have_fstab = 0;
- if ((mntbuf = getmntpt(*argv)) == NULL)
- errx(1, "not currently mounted %s", *argv);
- /*
- * Only get the mntflags from fstab if both mntpoint
- * and mntspec are identical. Also handle the special
- * case where just '/' is mounted and 'spec' is not
- * identical with the one from fstab ('/dev' is missing
- * in the spec-string at boot-time).
- */
- if ((fs = getfsfile(mntbuf->f_mntonname)) != NULL) {
- if (strcmp(fs->fs_spec,
- mntbuf->f_mntfromname) == 0 &&
- strcmp(fs->fs_file,
- mntbuf->f_mntonname) == 0) {
- have_fstab = 1;
- mntfromname = mntbuf->f_mntfromname;
- } else if (argv[0][0] == '/' &&
- argv[0][1] == '\0') {
- fs = getfsfile("/");
- have_fstab = 1;
- mntfromname = fs->fs_spec;
- }
- }
- if (have_fstab) {
- options = update_options(options, fs->fs_mntops,
- mntbuf->f_flags);
- } else {
- mntfromname = mntbuf->f_mntfromname;
- options = update_options(options, NULL,
- mntbuf->f_flags);
- }
- rval = mountfs(mntbuf->f_fstypename, mntfromname,
- mntbuf->f_mntonname, init_flags, options, 0);
- break;
- }
- rmslashes(*argv, *argv);
- if ((fs = getfsfile(*argv)) == NULL &&
- (fs = getfsspec(*argv)) == NULL)
- errx(1, "%s: unknown special file or file system",
- *argv);
- if (BADTYPE(fs->fs_type))
- errx(1, "%s has unknown file system type",
- *argv);
- rval = mountfs(fs->fs_vfstype, fs->fs_spec, fs->fs_file,
- init_flags, options, fs->fs_mntops);
- break;
- case 2:
- /*
- * If -t flag has not been specified, the path cannot be
- * found, spec contains either a ':' or a '@', and the
- * spec is not a file with those characters, then assume
- * that an NFS filesystem is being specified ala Sun.
- */
- if (vfslist == NULL && strpbrk(argv[0], ":@") != NULL &&
- access(argv[0], 0) == -1)
- vfstype = "nfs";
- rval = mountfs(vfstype,
- argv[0], argv[1], init_flags, options, NULL);
- break;
- default:
- usage();
- /* NOTREACHED */
- }
-
- /*
- * If the mount was successfully, and done by root, tell mountd the
- * good news. Pid checks are probably unnecessary, but don't hurt.
- */
- if (rval == 0 && getuid() == 0 &&
- (mountdfp = fopen(_PATH_MOUNTDPID, "r")) != NULL) {
- if (fscanf(mountdfp, "%d", &pid) == 1 &&
- pid > 0 && kill(pid, SIGHUP) == -1 && errno != ESRCH)
- err(1, "signal mountd");
- (void)fclose(mountdfp);
- }
-
- exit(rval);
-}
-
-int
-ismounted(fs, mntbuf, mntsize)
- struct fstab *fs;
- struct statfs *mntbuf;
- int mntsize;
-{
- int i;
-
- if (fs->fs_file[0] == '/' && fs->fs_file[1] == '\0')
- /* the root file system can always be remounted */
- return (0);
-
- for (i = mntsize - 1; i >= 0; --i)
- if (strcmp(fs->fs_file, mntbuf[i].f_mntonname) == 0 &&
- (!isremountable(fs->fs_vfstype) ||
- strcmp(fs->fs_spec, mntbuf[i].f_mntfromname) == 0))
- return (1);
- return (0);
-}
-
-int
-isremountable(vfsname)
- const char *vfsname;
-{
- const char **cp;
-
- for (cp = remountable_fs_names; *cp; cp++)
- if (strcmp(*cp, vfsname) == 0)
- return (1);
- return (0);
-}
-
-int
-hasopt(mntopts, option)
- const char *mntopts, *option;
-{
- int negative, found;
- char *opt, *optbuf;
-
- if (option[0] == 'n' && option[1] == 'o') {
- negative = 1;
- option += 2;
- } else
- negative = 0;
- optbuf = strdup(mntopts);
- found = 0;
- for (opt = optbuf; (opt = strtok(opt, ",")) != NULL; opt = NULL) {
- if (opt[0] == 'n' && opt[1] == 'o') {
- if (!strcasecmp(opt + 2, option))
- found = negative;
- } else if (!strcasecmp(opt, option))
- found = !negative;
- }
- free(optbuf);
- return (found);
-}
-
-int
-mountfs(vfstype, spec, name, flags, options, mntopts)
- const char *vfstype, *spec, *name, *options, *mntopts;
- int flags;
-{
- /* List of directories containing mount_xxx subcommands. */
- static const char *edirs[] = {
- _PATH_SBIN,
- _PATH_USRSBIN,
- NULL
- };
- const char *argv[100], **edir;
- struct statfs sf;
- pid_t pid;
- int argc, i, status;
- char *optbuf, execname[MAXPATHLEN + 1], mntpath[MAXPATHLEN];
-
-#if __GNUC__
- (void)&optbuf;
- (void)&name;
-#endif
-
- /* resolve the mountpoint with realpath(3) */
- (void)checkpath(name, mntpath);
- name = mntpath;
-
- if (mntopts == NULL)
- mntopts = "";
- if (options == NULL) {
- if (*mntopts == '\0') {
- options = "rw";
- } else {
- options = mntopts;
- mntopts = "";
- }
- }
- optbuf = catopt(strdup(mntopts), options);
-
- if (strcmp(name, "/") == 0)
- flags |= MNT_UPDATE;
- if (flags & MNT_FORCE)
- optbuf = catopt(optbuf, "force");
- if (flags & MNT_RDONLY)
- optbuf = catopt(optbuf, "ro");
- /*
- * XXX
- * The mount_mfs (newfs) command uses -o to select the
- * optimization mode. We don't pass the default "-o rw"
- * for that reason.
- */
- if (flags & MNT_UPDATE)
- optbuf = catopt(optbuf, "update");
-
- argc = 0;
- argv[argc++] = vfstype;
- mangle(optbuf, &argc, argv);
- argv[argc++] = spec;
- argv[argc++] = name;
- argv[argc] = NULL;
-
- if (debug) {
- (void)printf("exec: mount_%s", vfstype);
- for (i = 1; i < argc; i++)
- (void)printf(" %s", argv[i]);
- (void)printf("\n");
- return (0);
- }
-
- switch (pid = fork()) {
- case -1: /* Error. */
- warn("fork");
- free(optbuf);
- return (1);
- case 0: /* Child. */
- if (strcmp(vfstype, "ufs") == 0)
- exit(mount_ufs(argc, (char * const *) argv));
-
- /* Go find an executable. */
- for (edir = edirs; *edir; edir++) {
- (void)snprintf(execname,
- sizeof(execname), "%s/mount_%s", *edir, vfstype);
- execv(execname, (char * const *)argv);
- }
- if (errno == ENOENT) {
- int len = 0;
- char *cp;
- for (edir = edirs; *edir; edir++)
- len += strlen(*edir) + 2; /* ", " */
- if ((cp = malloc(len)) == NULL)
- errx(1, "malloc failed");
- cp[0] = '\0';
- for (edir = edirs; *edir; edir++) {
- strcat(cp, *edir);
- if (edir[1] != NULL)
- strcat(cp, ", ");
- }
- warn("exec mount_%s not found in %s", vfstype, cp);
- }
- exit(1);
- /* NOTREACHED */
- default: /* Parent. */
- free(optbuf);
-
- if (waitpid(pid, &status, 0) < 0) {
- warn("waitpid");
- return (1);
- }
-
- if (WIFEXITED(status)) {
- if (WEXITSTATUS(status) != 0)
- return (WEXITSTATUS(status));
- } else if (WIFSIGNALED(status)) {
- warnx("%s: %s", name, sys_siglist[WTERMSIG(status)]);
- return (1);
- }
-
- if (verbose) {
- if (statfs(name, &sf) < 0) {
- warn("statfs %s", name);
- return (1);
- }
- if (fstab_style)
- putfsent(&sf);
- else
- prmount(&sf);
- }
- break;
- }
-
- return (0);
-}
-
-void
-prmount(sfp)
- struct statfs *sfp;
-{
- int flags;
- struct opt *o;
- struct passwd *pw;
-
- (void)printf("%s on %s (%s", sfp->f_mntfromname, sfp->f_mntonname,
- sfp->f_fstypename);
-
- flags = sfp->f_flags & MNT_VISFLAGMASK;
- for (o = optnames; flags && o->o_opt; o++)
- if (flags & o->o_opt) {
- (void)printf(", %s", o->o_name);
- flags &= ~o->o_opt;
- }
- if (sfp->f_owner) {
- (void)printf(", mounted by ");
- if ((pw = getpwuid(sfp->f_owner)) != NULL)
- (void)printf("%s", pw->pw_name);
- else
- (void)printf("%d", sfp->f_owner);
- }
- if (sfp->f_syncwrites != 0 || sfp->f_asyncwrites != 0)
- (void)printf(", writes: sync %ld async %ld",
- sfp->f_syncwrites, sfp->f_asyncwrites);
- if (sfp->f_syncreads != 0 || sfp->f_asyncreads != 0)
- (void)printf(", reads: sync %ld async %ld",
- sfp->f_syncreads, sfp->f_asyncreads);
- (void)printf(")\n");
-}
-
-struct statfs *
-getmntpt(name)
- const char *name;
-{
- struct statfs *mntbuf;
- int i, mntsize;
-
- mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
- for (i = mntsize - 1; i >= 0; i--) {
- if (strcmp(mntbuf[i].f_mntfromname, name) == 0 ||
- strcmp(mntbuf[i].f_mntonname, name) == 0)
- return (&mntbuf[i]);
- }
- return (NULL);
-}
-
-char *
-catopt(s0, s1)
- char *s0;
- const char *s1;
-{
- size_t i;
- char *cp;
-
- if (s1 == NULL || *s1 == '\0')
- return s0;
-
- if (s0 && *s0) {
- i = strlen(s0) + strlen(s1) + 1 + 1;
- if ((cp = malloc(i)) == NULL)
- errx(1, "malloc failed");
- (void)snprintf(cp, i, "%s,%s", s0, s1);
- } else
- cp = strdup(s1);
-
- if (s0)
- free(s0);
- return (cp);
-}
-
-void
-mangle(options, argcp, argv)
- char *options;
- int *argcp;
- const char **argv;
-{
- char *p, *s;
- int argc;
-
- argc = *argcp;
- for (s = options; (p = strsep(&s, ",")) != NULL;)
- if (*p != '\0') {
- if (*p == '-') {
- argv[argc++] = p;
- p = strchr(p, '=');
- if (p) {
- *p = '\0';
- argv[argc++] = p+1;
- }
- } else if (strcmp(p, "rw") != 0) {
- argv[argc++] = "-o";
- argv[argc++] = p;
- }
- }
-
- *argcp = argc;
-}
-
-
-char *
-update_options(opts, fstab, curflags)
- char *opts;
- char *fstab;
- int curflags;
-{
- char *o, *p;
- char *cur;
- char *expopt, *newopt, *tmpopt;
-
- if (opts == NULL)
- return strdup("");
-
- /* remove meta options from list */
- remopt(fstab, MOUNT_META_OPTION_FSTAB);
- remopt(fstab, MOUNT_META_OPTION_CURRENT);
- cur = flags2opts(curflags);
-
- /*
- * Expand all meta-options passed to us first.
- */
- expopt = NULL;
- for (p = opts; (o = strsep(&p, ",")) != NULL;) {
- if (strcmp(MOUNT_META_OPTION_FSTAB, o) == 0)
- expopt = catopt(expopt, fstab);
- else if (strcmp(MOUNT_META_OPTION_CURRENT, o) == 0)
- expopt = catopt(expopt, cur);
- else
- expopt = catopt(expopt, o);
- }
- free(cur);
- free(opts);
-
- /*
- * Remove previous contradictory arguments. Given option "foo" we
- * remove all the "nofoo" options. Given "nofoo" we remove "nonofoo"
- * and "foo" - so we can deal with possible options like "notice".
- */
- newopt = NULL;
- for (p = expopt; (o = strsep(&p, ",")) != NULL;) {
- if ((tmpopt = malloc( strlen(o) + 2 + 1 )) == NULL)
- errx(1, "malloc failed");
-
- strcpy(tmpopt, "no");
- strcat(tmpopt, o);
- remopt(newopt, tmpopt);
- free(tmpopt);
-
- if (strncmp("no", o, 2) == 0)
- remopt(newopt, o+2);
-
- newopt = catopt(newopt, o);
- }
- free(expopt);
-
- return newopt;
-}
-
-void
-remopt(string, opt)
- char *string;
- const char *opt;
-{
- char *o, *p, *r;
-
- if (string == NULL || *string == '\0' || opt == NULL || *opt == '\0')
- return;
-
- r = string;
-
- for (p = string; (o = strsep(&p, ",")) != NULL;) {
- if (strcmp(opt, o) != 0) {
- if (*r == ',' && *o != '\0')
- r++;
- while ((*r++ = *o++) != '\0')
- ;
- *--r = ',';
- }
- }
- *r = '\0';
-}
-
-void
-usage()
-{
-
- (void)fprintf(stderr, "%s\n%s\n%s\n",
-"usage: mount [-dfpruvw] [-o options] [-t ufs | external_type] special node",
-" mount [-adfpruvw] [-t ufs | external_type]",
-" mount [-dfpruvw] special | node");
- exit(1);
-}
-
-void
-putfsent(ent)
- const struct statfs *ent;
-{
- struct fstab *fst;
- char *opts;
-
- opts = flags2opts(ent->f_flags);
- printf("%s\t%s\t%s %s", ent->f_mntfromname, ent->f_mntonname,
- ent->f_fstypename, opts);
- free(opts);
-
- if ((fst = getfsspec(ent->f_mntfromname)))
- printf("\t%u %u\n", fst->fs_freq, fst->fs_passno);
- else if ((fst = getfsfile(ent->f_mntonname)))
- printf("\t%u %u\n", fst->fs_freq, fst->fs_passno);
- else if (strcmp(ent->f_fstypename, "ufs") == 0) {
- if (strcmp(ent->f_mntonname, "/") == 0)
- printf("\t1 1\n");
- else
- printf("\t2 2\n");
- } else
- printf("\t0 0\n");
-}
-
-
-char *
-flags2opts(flags)
- int flags;
-{
- char *res;
-
- res = NULL;
-
- res = catopt(res, (flags & MNT_RDONLY) ? "ro" : "rw");
-
- if (flags & MNT_SYNCHRONOUS) res = catopt(res, "sync");
- if (flags & MNT_NOEXEC) res = catopt(res, "noexec");
- if (flags & MNT_NOSUID) res = catopt(res, "nosuid");
- if (flags & MNT_NODEV) res = catopt(res, "nodev");
- if (flags & MNT_UNION) res = catopt(res, "union");
- if (flags & MNT_ASYNC) res = catopt(res, "async");
- if (flags & MNT_NOATIME) res = catopt(res, "noatime");
- if (flags & MNT_NOCLUSTERR) res = catopt(res, "noclusterr");
- if (flags & MNT_NOCLUSTERW) res = catopt(res, "noclusterw");
- if (flags & MNT_NOSYMFOLLOW) res = catopt(res, "nosymfollow");
- if (flags & MNT_SUIDDIR) res = catopt(res, "suiddir");
-
- return res;
-}
diff --git a/sbin/mount_ifs/mount_ufs.c b/sbin/mount_ifs/mount_ufs.c
deleted file mode 100644
index 3c0b6fcb711f..000000000000
--- a/sbin/mount_ifs/mount_ufs.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/*-
- * Copyright (c) 1993, 1994
- * 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-static const char copyright[] =
-"@(#) Copyright (c) 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)mount_ufs.c 8.4 (Berkeley) 4/26/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <sys/param.h>
-#include <sys/mount.h>
-
-#include <err.h>
-#include <errno.h>
-#include <stdio.h>
-#include <unistd.h>
-
-#include <ufs/ufs/ufsmount.h>
-
-#include "extern.h"
-#include "mntopts.h"
-
-static void ufs_usage __P((void));
-
-static struct mntopt mopts[] = {
- MOPT_STDOPTS,
- MOPT_ASYNC,
- MOPT_FORCE,
- MOPT_SYNC,
- MOPT_UPDATE,
- { NULL }
-};
-
-int
-mount_ufs(argc, argv)
- int argc;
- char * const argv[];
-{
- extern int optreset;
- struct ufs_args args;
- int ch, mntflags;
- char *fs_name;
- struct vfsconf vfc;
- int error = 0;
-
- mntflags = 0;
- optind = optreset = 1; /* Reset for parse of new argv. */
- while ((ch = getopt(argc, argv, "o:")) != -1)
- switch (ch) {
- case 'o':
- getmntopts(optarg, mopts, &mntflags, 0);
- break;
- case '?':
- default:
- ufs_usage();
- }
- argc -= optind;
- argv += optind;
-
- if (argc != 2)
- ufs_usage();
-
- args.fspec = argv[0]; /* The name of the device file. */
- fs_name = argv[1]; /* The mount point. */
-
-#define DEFAULT_ROOTUID -2
- args.export.ex_root = DEFAULT_ROOTUID;
- if (mntflags & MNT_RDONLY)
- args.export.ex_flags = MNT_EXRDONLY;
- else
- args.export.ex_flags = 0;
-
- error = getvfsbyname("ufs", &vfc);
- if (error && vfsisloadable("ufs")) {
- if (vfsload("ufs")) {
- warn("vfsload(ufs)");
- return (1);
- }
- endvfsent(); /* flush old table */
- error = getvfsbyname("ufs", &vfc);
- }
- if (error) {
- warnx("ufs filesystem is not available");
- return (1);
- }
-
- if (mount(vfc.vfc_name, fs_name, mntflags, &args) < 0) {
- switch (errno) {
- case EMFILE:
- warnx("%s on %s: mount table full",
- args.fspec, fs_name);
- break;
- case EINVAL:
- if (mntflags & MNT_UPDATE)
- warnx(
- "%s on %s: specified device does not match mounted device",
- args.fspec, fs_name);
- else
- warnx("%s on %s: incorrect super block",
- args.fspec, fs_name);
- break;
- default:
- warn(NULL);
- break;
- }
- return (1);
- }
- return (0);
-}
-
-static void
-ufs_usage()
-{
- (void)fprintf(stderr, "usage: mount_ufs [-o options] special node\n");
- exit(1);
-}
diff --git a/sbin/mount_ifs/pathnames.h b/sbin/mount_ifs/pathnames.h
deleted file mode 100644
index 45a4a010c1cf..000000000000
--- a/sbin/mount_ifs/pathnames.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 1989, 1993, 1994
- * 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)pathnames.h 8.2 (Berkeley) 3/27/94
- */
-
-#define _PATH_SBIN "/sbin"
-#define _PATH_USRSBIN "/usr/sbin"
-#define _PATH_MOUNTDPID "/var/run/mountd.pid"
diff --git a/sbin/mount_ifs/vfslist.c b/sbin/mount_ifs/vfslist.c
deleted file mode 100644
index d8201882eb33..000000000000
--- a/sbin/mount_ifs/vfslist.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/*-
- * Copyright (c) 1995
- * 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-#if 0
-static char sccsid[] = "@(#)vfslist.c 8.1 (Berkeley) 5/8/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <err.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "extern.h"
-
-static int skipvfs;
-
-int
-checkvfsname(vfsname, vfslist)
- const char *vfsname;
- const char **vfslist;
-{
-
- if (vfslist == NULL)
- return (0);
- while (*vfslist != NULL) {
- if (strcmp(vfsname, *vfslist) == 0)
- return (skipvfs);
- ++vfslist;
- }
- return (!skipvfs);
-}
-
-const char **
-makevfslist(fslist)
- char *fslist;
-{
- const char **av;
- int i;
- char *nextcp;
-
- if (fslist == NULL)
- return (NULL);
- if (fslist[0] == 'n' && fslist[1] == 'o') {
- fslist += 2;
- skipvfs = 1;
- }
- for (i = 0, nextcp = fslist; *nextcp; nextcp++)
- if (*nextcp == ',')
- i++;
- if ((av = malloc((size_t)(i + 2) * sizeof(char *))) == NULL) {
- warnx("malloc failed");
- return (NULL);
- }
- nextcp = fslist;
- i = 0;
- av[i++] = nextcp;
- while ((nextcp = strchr(nextcp, ',')) != NULL) {
- *nextcp++ = '\0';
- av[i++] = nextcp;
- }
- av[i++] = NULL;
- return (av);
-}
diff --git a/sbin/mount_msdosfs/Makefile b/sbin/mount_msdosfs/Makefile
deleted file mode 100644
index f40994e7af13..000000000000
--- a/sbin/mount_msdosfs/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# $FreeBSD$
-#
-
-PROG= mount_msdos
-SRCS= mount_msdos.c getmntopts.c
-MAN8= mount_msdos.8
-DPADD= ${LIBUTIL}
-LDADD= -lutil
-
-MOUNT= ${.CURDIR}/../mount
-CFLAGS+= -I${MOUNT}
-.PATH: ${MOUNT}
-
-TABDIR= ${DESTDIR}/usr/libdata/msdosfs
-TABLES= iso22dos koi2dos
-
-afterinstall:
- cd ${.CURDIR} && \
- ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m ${SHAREMODE} \
- ${TABLES} ${TABDIR}
-
-.include <bsd.prog.mk>
diff --git a/sbin/mount_msdosfs/iso22dos b/sbin/mount_msdosfs/iso22dos
deleted file mode 100644
index 1f48193e473e..000000000000
--- a/sbin/mount_msdosfs/iso22dos
+++ /dev/null
@@ -1,58 +0,0 @@
-# $FreeBSD$
-#
-# u2w: 16 rows of Latin2 -> Unicode conversion table (upper half)
-#
-0x0080 0x0081 0x0082 0x0083 0x0084 0x0085 0x0086 0x0087
-0x0088 0x0089 0x008a 0x008b 0x008c 0x008d 0x008e 0x008f
-0x0090 0x0091 0x0092 0x0093 0x0094 0x0095 0x0096 0x0097
-0x0098 0x0099 0x009a 0x009b 0x009c 0x009d 0x009e 0x009f
-0x00a0 0x0104 0x02d8 0x0141 0x00a4 0x013d 0x015a 0x00a7
-0x00a8 0x0160 0x015e 0x0164 0x0179 0x00ad 0x017d 0x017b
-0x00b0 0x0105 0x02db 0x0142 0x00b4 0x013e 0x015b 0x02c7
-0x00b8 0x0161 0x015f 0x0165 0x017a 0x02dd 0x017e 0x017c
-0x0154 0x00c1 0x00c2 0x0102 0x00c4 0x0139 0x0106 0x00c7
-0x010c 0x00c9 0x0118 0x00cb 0x011a 0x00cd 0x00ce 0x010e
-0x0110 0x0143 0x0147 0x00d3 0x00d4 0x0150 0x00d6 0x00d7
-0x0158 0x016e 0x00da 0x0170 0x00dc 0x00dd 0x0162 0x00df
-0x0155 0x00e1 0x00e2 0x0103 0x00e4 0x013a 0x0107 0x00e7
-0x010d 0x00e9 0x0119 0x00eb 0x011b 0x00ed 0x00ee 0x010f
-0x0111 0x0144 0x0148 0x00f3 0x00f4 0x0151 0x00f6 0x00f7
-0x0159 0x016f 0x00fa 0x0171 0x00fc 0x00fd 0x0163 0x02d9
-#
-# d2u: 16 rows of CP852 -> Latin2 conversion table (upper half)
-#
-0xc7 0xfc 0xe9 0xe2 0xe4 0xf9 0xe6 0xe7
-0xb3 0xeb 0xd5 0xf5 0xee 0xac 0xc4 0xc6
-0xc9 0xc5 0xe5 0xf4 0xf6 0xa5 0xb5 0xa6
-0xb6 0xd6 0xdc 0xab 0xbb 0xa3 0xd7 0xe8
-0xe1 0xed 0xf3 0xfa 0xa1 0xb1 0xae 0xbe
-0xca 0xea 0x3f 0xbc 0xc8 0xba 0x3f 0x3f
-0x3f 0x3f 0x3f 0x3f 0x3f 0xc1 0xc2 0xcc
-0xaa 0x3f 0x3f 0x3f 0x3f 0xaf 0xbf 0x3f
-0x3f 0x3f 0x3f 0x3f 0x3f 0x3f 0xc3 0xe3
-0x3f 0x3f 0x3f 0x3f 0x3f 0x3f 0x3f 0xa4
-0xf0 0xd0 0xcf 0xcb 0xef 0xd2 0xcd 0xce
-0xec 0x3f 0x3f 0x3f 0x3f 0xde 0xd9 0x3f
-0xd3 0xdf 0xd4 0xd1 0xf1 0xf2 0xa9 0xb9
-0xc0 0xda 0xe0 0xdb 0xfd 0xdd 0xfe 0xb4
-0xad 0xbd 0xb2 0xb7 0xa2 0xa7 0xf7 0xb8
-0xb0 0xa8 0xff 0xfb 0xd8 0xf8 0x3f 0xa0
-#
-# u2d: 16 rows of Latin2 -> CP852 conversion table (upper half)
-#
-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
-0xff 0xa4 0xf4 0x9d 0xcf 0x95 0x97 0xf5
-0xf9 0xe6 0xb8 0x9b 0x8d 0xf0 0xa6 0xbd
-0xf8 0xa5 0xf2 0x88 0xef 0x96 0x98 0xf3
-0xf7 0xe7 0xad 0x9c 0xab 0xf1 0xa7 0xbe
-0xe8 0xb5 0xb6 0xc6 0x8e 0x91 0x8f 0x80
-0xac 0x90 0xa8 0xd3 0xb7 0xd6 0xd7 0xd2
-0xd1 0xe3 0xd5 0xe0 0xe2 0x8a 0x99 0x9e
-0xfc 0xde 0xe9 0xeb 0x9a 0xed 0xdd 0xe1
-0xea 0xa0 0x83 0xc7 0x84 0x92 0x86 0x87
-0x9f 0x82 0xa9 0x89 0xd8 0xa1 0x8c 0xd4
-0xd0 0xe4 0xe5 0xa2 0x93 0x8b 0x94 0xf6
-0xfd 0x85 0xa3 0xfb 0x81 0xec 0xee 0xfa
diff --git a/sbin/mount_msdosfs/koi2dos b/sbin/mount_msdosfs/koi2dos
deleted file mode 100644
index 4adb4259a26c..000000000000
--- a/sbin/mount_msdosfs/koi2dos
+++ /dev/null
@@ -1,58 +0,0 @@
-# $FreeBSD$
-#
-# u2w: 16 rows of KOI8-R -> Unicode conversion table (upper half)
-#
-0x2500 0x2502 0x250c 0x2510 0x2514 0x2518 0x251c 0x2524
-0x252c 0x2534 0x253c 0x2580 0x2584 0x2588 0x258c 0x2590
-0x2591 0x2592 0x2593 0x2320 0x25a0 0x2219 0x221a 0x2248
-0x2264 0x2265 0x00a0 0x2321 0x00b0 0x00b2 0x00b7 0x00f7
-0x2550 0x2551 0x2552 0x0451 0x2553 0x2554 0x2555 0x2556
-0x2557 0x2558 0x2559 0x255a 0x255b 0x255c 0x255d 0x255e
-0x255f 0x2560 0x2561 0x0401 0x2562 0x2563 0x2564 0x2565
-0x2566 0x2567 0x2568 0x2569 0x256a 0x256b 0x256c 0x00a9
-0x044e 0x0430 0x0431 0x0446 0x0434 0x0435 0x0444 0x0433
-0x0445 0x0438 0x0439 0x043a 0x043b 0x043c 0x043d 0x043e
-0x043f 0x044f 0x0440 0x0441 0x0442 0x0443 0x0436 0x0432
-0x044c 0x044b 0x0437 0x0448 0x044d 0x0449 0x0447 0x044a
-0x042e 0x0410 0x0411 0x0426 0x0414 0x0415 0x0424 0x0413
-0x0425 0x0418 0x0419 0x041a 0x041b 0x041c 0x041d 0x041e
-0x041f 0x042f 0x0420 0x0421 0x0422 0x0423 0x0416 0x0412
-0x042c 0x042b 0x0417 0x0428 0x042d 0x0429 0x0427 0x042a
-#
-# d2u: 16 rows of CP866 -> KOI8-R conversion table (upper half)
-#
-0xe1 0xe2 0xf7 0xe7 0xe4 0xe5 0xf6 0xfa
-0xe9 0xea 0xeb 0xec 0xed 0xee 0xef 0xf0
-0xf2 0xf3 0xf4 0xf5 0xe6 0xe8 0xe3 0xfe
-0xfb 0xfd 0xff 0xf9 0xf8 0xfc 0xe0 0xf1
-0xc1 0xc2 0xd7 0xc7 0xc4 0xc5 0xd6 0xda
-0xc9 0xca 0xcb 0xcc 0xcd 0xce 0xcf 0xd0
-0x90 0x91 0x92 0x81 0x87 0xb2 0xb4 0xa7
-0xa6 0xb5 0xa1 0xa8 0xae 0xad 0xac 0x83
-0x84 0x89 0x88 0x86 0x80 0x8a 0xaf 0xb0
-0xab 0xa5 0xbb 0xb8 0xb1 0xa0 0xbe 0xb9
-0xba 0xb6 0xb7 0xaa 0xa9 0xa2 0xa4 0xbd
-0xbc 0x85 0x82 0x8d 0x8c 0x8e 0x8f 0x8b
-0xd2 0xd3 0xd4 0xd5 0xc6 0xc8 0xc3 0xde
-0xdb 0xdd 0xdf 0xd9 0xd8 0xdc 0xc0 0xd1
-0xb3 0xa3 229 197 73 105 245 213
-0x9c 0x95 0x9e 0x96 78 210 0x94 0x9a
-#
-# u2d: 16 rows of KOI8-R -> CP866 conversion table (upper half)
-#
-0xc4 0xb3 0xda 0xbf 0xc0 0xd9 0xc3 0xb4
-0xc2 0xc1 0xc5 0xdf 0xdc 0xdb 0xdd 0xde
-0xb0 0xb1 0xb2 179 0xfe 0xf9 0xfb 61
- 60 62 0xff 179 0xf8 50 0xfa 58
-0xcd 0xba 0xd5 0xf1 0xd6 0xc9 0xb8 0xb7
-0xbb 0xd4 0xd3 0xc8 0xbe 0xbd 0xbc 0xc6
-0xc7 0xcc 0xb5 0xf0 0xb6 0xb9 0xd1 0xd2
-0xcb 0xcf 0xd0 0xca 0xd8 0xd7 0xce 99
-0xee 0xa0 0xa1 0xe6 0xa4 0xa5 0xe4 0xa3
-0xe5 0xa8 0xa9 0xaa 0xab 0xac 0xad 0xae
-0xaf 0xef 0xe0 0xe1 0xe2 0xe3 0xa6 0xa2
-0xec 0xeb 0xa7 0xe8 0xed 0xe9 0xe7 0xea
-0x9e 0x80 0x81 0x96 0x84 0x85 0x94 0x83
-0x95 0x88 0x89 0x8a 0x8b 0x8c 0x8d 0x8e
-0x8f 0x9f 0x90 0x91 0x92 0x93 0x86 0x82
-0x9c 0x9b 0x87 0x98 0x9d 0x99 0x97 0x9a
diff --git a/sbin/mount_msdosfs/mount_msdosfs.8 b/sbin/mount_msdosfs/mount_msdosfs.8
deleted file mode 100644
index 8083d2f5f8f3..000000000000
--- a/sbin/mount_msdosfs/mount_msdosfs.8
+++ /dev/null
@@ -1,215 +0,0 @@
-.\" $NetBSD: mount_msdos.8,v 1.13 1998/02/06 05:57:00 perry Exp $
-.\"
-.\" Copyright (c) 1993,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 acknowledgment:
-.\" This product includes software developed by Christopher G. Demetriou.
-.\" 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd April 7, 1994
-.Dt MOUNT_MSDOS 8
-.Os
-.Sh NAME
-.Nm mount_msdos
-.Nd mount an MS-DOS file system
-.Sh SYNOPSIS
-.Nm mount_msdos
-.Op Fl o Ar options
-.Op Fl u Ar uid
-.Op Fl g Ar gid
-.Op Fl m Ar mask
-.Op Fl s
-.Op Fl l
-.Op Fl 9
-.\".Op Fl G
-.Op Fl L Ar locale
-.Op Fl W Ar table
-.Pa special
-.Pa node
-.Sh DESCRIPTION
-The
-.Nm
-command attaches the MS-DOS filesystem residing on
-the device
-.Pa special
-to the global filesystem namespace at the location
-indicated by
-.Pa node .
-This command is normally executed by
-.Xr mount 8
-at boot time, but can be used by any user to mount an
-MS-DOS file system on any directory that they own (provided,
-of course, that they have appropriate access to the device that
-contains the file system).
-.Pp
-The options are as follows:
-.Bl -tag -width Ds
-.It Fl o Ar options
-Use the specified mount
-.Ar options ,
-as described in
-.Xr mount 8 ,
-or one of the MSDOS filesystem-specific options
-.Ar shortnames ,
-.Ar longnames
-or
-.Ar nowin95 ,
-all of which can be used to affect Windows name translation in the
-underlying filesystem.
-.It Fl u Ar uid
-Set the owner of the files in the file system to
-.Ar uid .
-The default owner is the owner of the directory
-on which the file system is being mounted.
-.It Fl g Ar gid
-Set the group of the files in the file system to
-.Ar gid .
-The default group is the group of the directory
-on which the file system is being mounted.
-.It Fl m Ar mask
-Specify the maximum file permissions for files
-in the file system.
-(For example, a
-.Ar mask
-of
-.Li 755
-specifies that, by default, the owner should have
-read, write, and execute permissions for files, but
-others should only have read and execute permissions.
-See
-.Xr chmod 1
-for more information about octal file modes.)
-Only the nine low-order bits of
-.Ar mask
-are used.
-The default
-.Ar mask
-is taken from the
-directory on which the file system is being mounted.
-.It Fl s
-Force behaviour to
-ignore and not generate Win'95 long filenames.
-.It Fl l
-Force listing and generation of
-Win'95 long filenames
-and separate creation/modification/access dates.
-.Pp
-If neither
-.Fl s
-nor
-.Fl l
-are given,
-.Nm
-searches the root directory of the filesystem to
-be mounted for any existing Win'95 long filenames.
-If no such entries are found, but short DOS filenames are found,
-.Fl s
-is the default.
-Otherwise
-.Fl l
-is assumed.
-.It Fl 9
-Ignore the special Win'95 directory entries even
-if deleting or renaming a file.
-This forces
-.Fl s .
-.\".It Fl G
-.\"This option causes the filesystem to be interpreted as an Atari-Gemdos
-.\"filesystem. The differences to the MS-DOS filesystem are minimal and
-.\"limited to the boot block. This option enforces
-.\".Fl s .
-.It Fl L Ar locale
-Specify locale name used for internal uppercase and lowercase conversions
-for DOS and Win'95 names.
-By default ISO 8859-1 assumed as local character set.
-.It Fl W Ar table
-Specify text file with 3 conversion tables:
-.Bl -enum
-.It
-Local character set to Unicode conversion table (upper half) for Win'95 long
-names, 128 Unicode codes separated by 8 per row.
-If some code not present in Unicode, use
-0x003F code ('?') as replacement.
-.It
-DOS to local character set conversion table (upper half) for DOS names,
-128 character codes separated by 8 per row.
-Code 0x3F ('?') used for impossible translations.
-.It
-Local character set to DOS conversion table (upper half) for DOS names,
-128 character codes separated by 8 per row.
-Some codes have special meaning:
-.Bl -hang
-.It 0x00
-character disallowed in DOS file name;
-.It 0x01
-character should be replaced by '_' in DOS file name;
-.It 0x02
-character should be skipped in DOS file name;
-.El
-.El
-.Pp
-By default ISO 8859-1 assumed as local character set.
-If file path isn't absolute,
-.Pa /usr/libdata/msdosfs/
-prefix prepended.
-.El
-.Sh FILES
-.Bl -tag -width /usr/libdata/msdosfs -compact
-.It Pa /usr/libdata/msdosfs
-default place for character sets conversion tables
-.El
-.Sh SEE ALSO
-.Xr mount 2 ,
-.Xr unmount 2 ,
-.Xr fstab 5 ,
-.Xr mount 8
-.Sh CAVEATS
-The use of the
-.Fl 9
-flag could result in damaged filesystems,
-albeit the damage is in part taken care of by
-procedures similar to the ones used in Win'95.
-.Pp
-.Fx 2.1
-and earlier versions could not handle cluster sizes larger than 16K.
-Just mounting an MS-DOS file system could cause corruption to any
-mounted file system.
-Cluster sizes larger than 16K are unavoidable for file system sizes
-larger than 1G, and also occur when filesystems larger than 1G are
-shrunk to smaller than 1G using FIPS.
-.Sh HISTORY
-The
-.Nm
-utility first appeared in
-.Fx 2.0 .
-Its predecessor, the
-.Nm mount_pcfs
-utility appeared in
-.Fx 1.0 ,
-and was abandoned in favor
-of the more aptly-named
-.Nm Ns .
diff --git a/sbin/mount_msdosfs/mount_msdosfs.c b/sbin/mount_msdosfs/mount_msdosfs.c
deleted file mode 100644
index d2bcb2632e8b..000000000000
--- a/sbin/mount_msdosfs/mount_msdosfs.c
+++ /dev/null
@@ -1,339 +0,0 @@
-/* $NetBSD: mount_msdos.c,v 1.18 1997/09/16 12:24:18 lukem 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 lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <sys/param.h>
-#include <sys/mount.h>
-#include <sys/stat.h>
-
-#include <msdosfs/msdosfsmount.h>
-
-#include <ctype.h>
-#include <err.h>
-#include <grp.h>
-#include <locale.h>
-#include <pwd.h>
-#include <stdio.h>
-/* must be after stdio to declare fparseln */
-#include <libutil.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sysexits.h>
-#include <unistd.h>
-
-#include "mntopts.h"
-
-/*
- * XXX - no way to specify "foo=<bar>"-type options; that's what we'd
- * want for "-u", "-g", "-m", "-L", and "-W".
- */
-static struct mntopt mopts[] = {
- MOPT_STDOPTS,
- MOPT_FORCE,
- MOPT_SYNC,
- MOPT_UPDATE,
-#ifdef MSDOSFSMNT_GEMDOSFS
- { "gemdosfs", 0, MSDOSFSMNT_GEMDOSFS, 1 },
-#endif
- { "shortnames", 0, MSDOSFSMNT_SHORTNAME, 1 },
- { "longnames", 0, MSDOSFSMNT_LONGNAME, 1 },
- { "nowin95", 0, MSDOSFSMNT_NOWIN95, 1 },
- { NULL }
-};
-
-static gid_t a_gid __P((char *));
-static uid_t a_uid __P((char *));
-static mode_t a_mask __P((char *));
-static void usage __P((void)) __dead2;
-static void load_u2wtable __P((struct msdosfs_args *, char *));
-static void load_ultable __P((struct msdosfs_args *, char *));
-
-int
-main(argc, argv)
- int argc;
- char **argv;
-{
- struct msdosfs_args args;
- struct stat sb;
- int c, error, mntflags, set_gid, set_uid, set_mask;
- char *dev, *dir, mntpath[MAXPATHLEN];
- struct vfsconf vfc;
-
- mntflags = set_gid = set_uid = set_mask = 0;
- (void)memset(&args, '\0', sizeof(args));
- args.magic = MSDOSFS_ARGSMAGIC;
-
- while ((c = getopt(argc, argv, "sl9u:g:m:o:L:W:")) != -1) {
- switch (c) {
-#ifdef MSDOSFSMNT_GEMDOSFS
- case 'G':
- args.flags |= MSDOSFSMNT_GEMDOSFS;
- break;
-#endif
- case 's':
- args.flags |= MSDOSFSMNT_SHORTNAME;
- break;
- case 'l':
- args.flags |= MSDOSFSMNT_LONGNAME;
- break;
- case '9':
- args.flags |= MSDOSFSMNT_NOWIN95;
- break;
- case 'u':
- args.uid = a_uid(optarg);
- set_uid = 1;
- break;
- case 'g':
- args.gid = a_gid(optarg);
- set_gid = 1;
- break;
- case 'm':
- args.mask = a_mask(optarg);
- set_mask = 1;
- break;
- case 'L':
- load_ultable(&args, optarg);
- args.flags |= MSDOSFSMNT_ULTABLE;
- break;
- case 'W':
- load_u2wtable(&args, optarg);
- args.flags |= MSDOSFSMNT_U2WTABLE;
- break;
- case 'o':
- getmntopts(optarg, mopts, &mntflags, &args.flags);
- break;
- case '?':
- default:
- usage();
- break;
- }
- }
-
- if (optind + 2 != argc)
- usage();
-
- dev = argv[optind];
- dir = argv[optind + 1];
-
- /*
- * Resolve the mountpoint with realpath(3) and remove unnecessary
- * slashes from the devicename if there are any.
- */
- (void)checkpath(dir, mntpath);
- (void)rmslashes(dev, dev);
-
- args.fspec = dev;
- args.export.ex_root = -2; /* unchecked anyway on DOS fs */
- if (mntflags & MNT_RDONLY)
- args.export.ex_flags = MNT_EXRDONLY;
- else
- args.export.ex_flags = 0;
- if (!set_gid || !set_uid || !set_mask) {
- if (stat(mntpath, &sb) == -1)
- err(EX_OSERR, "stat %s", mntpath);
-
- if (!set_uid)
- args.uid = sb.st_uid;
- if (!set_gid)
- args.gid = sb.st_gid;
- if (!set_mask)
- args.mask = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
- }
-
- error = getvfsbyname("msdos", &vfc);
- if (error && vfsisloadable("msdos")) {
- if (vfsload("msdos"))
- err(EX_OSERR, "vfsload(msdos)");
- endvfsent(); /* clear cache */
- error = getvfsbyname("msdos", &vfc);
- }
- if (error)
- errx(EX_OSERR, "msdos filesystem is not available");
-
- if (mount(vfc.vfc_name, mntpath, mntflags, &args) < 0)
- err(EX_OSERR, "%s", dev);
-
- exit (0);
-}
-
-gid_t
-a_gid(s)
- char *s;
-{
- struct group *gr;
- char *gname;
- gid_t gid;
-
- if ((gr = getgrnam(s)) != NULL)
- gid = gr->gr_gid;
- else {
- for (gname = s; *s && isdigit(*s); ++s);
- if (!*s)
- gid = atoi(gname);
- else
- errx(EX_NOUSER, "unknown group id: %s", gname);
- }
- return (gid);
-}
-
-uid_t
-a_uid(s)
- char *s;
-{
- struct passwd *pw;
- char *uname;
- uid_t uid;
-
- if ((pw = getpwnam(s)) != NULL)
- uid = pw->pw_uid;
- else {
- for (uname = s; *s && isdigit(*s); ++s);
- if (!*s)
- uid = atoi(uname);
- else
- errx(EX_NOUSER, "unknown user id: %s", uname);
- }
- return (uid);
-}
-
-mode_t
-a_mask(s)
- char *s;
-{
- int done, rv;
- char *ep;
-
- done = 0;
- rv = -1;
- if (*s >= '0' && *s <= '7') {
- done = 1;
- rv = strtol(optarg, &ep, 8);
- }
- if (!done || rv < 0 || *ep)
- errx(EX_USAGE, "invalid file mode: %s", s);
- return (rv);
-}
-
-void
-usage()
-{
- fprintf(stderr, "%s\n%s\n",
- "usage: mount_msdos [-o options] [-u user] [-g group] [-m mask]",
- " [-s] [-l] [-9] [-L locale] [-W table] bdev dir");
- exit(EX_USAGE);
-}
-
-void
-load_u2wtable (pargs, name)
- struct msdosfs_args *pargs;
- char *name;
-{
- FILE *f;
- int i, j, code[8];
- size_t line = 0;
- char buf[128];
- char *fn, *s, *p;
-
- if (*name == '/')
- fn = name;
- else {
- snprintf(buf, sizeof(buf), "/usr/libdata/msdosfs/%s", name);
- buf[127] = '\0';
- fn = buf;
- }
- if ((f = fopen(fn, "r")) == NULL)
- err(EX_NOINPUT, "%s", fn);
- p = NULL;
- for (i = 0; i < 16; i++) {
- do {
- if (p != NULL) free(p);
- if ((p = s = fparseln(f, NULL, &line, NULL, 0)) == NULL)
- errx(EX_DATAERR, "can't read u2w table row %d near line %d", i, line);
- while (isspace((unsigned char)*s))
- s++;
- } while (*s == '\0');
- if (sscanf(s, "%i%i%i%i%i%i%i%i",
-code, code + 1, code + 2, code + 3, code + 4, code + 5, code + 6, code + 7) != 8)
- errx(EX_DATAERR, "u2w table: missing item(s) in row %d, line %d", i, line);
- for (j = 0; j < 8; j++)
- pargs->u2w[i * 8 + j] = code[j];
- }
- for (i = 0; i < 16; i++) {
- do {
- free(p);
- if ((p = s = fparseln(f, NULL, &line, NULL, 0)) == NULL)
- errx(EX_DATAERR, "can't read d2u table row %d near line %d", i, line);
- while (isspace((unsigned char)*s))
- s++;
- } while (*s == '\0');
- if (sscanf(s, "%i%i%i%i%i%i%i%i",
-code, code + 1, code + 2, code + 3, code + 4, code + 5, code + 6, code + 7) != 8)
- errx(EX_DATAERR, "d2u table: missing item(s) in row %d, line %d", i, line);
- for (j = 0; j < 8; j++)
- pargs->d2u[i * 8 + j] = code[j];
- }
- for (i = 0; i < 16; i++) {
- do {
- free(p);
- if ((p = s = fparseln(f, NULL, &line, NULL, 0)) == NULL)
- errx(EX_DATAERR, "can't read u2d table row %d near line %d", i, line);
- while (isspace((unsigned char)*s))
- s++;
- } while (*s == '\0');
- if (sscanf(s, "%i%i%i%i%i%i%i%i",
-code, code + 1, code + 2, code + 3, code + 4, code + 5, code + 6, code + 7) != 8)
- errx(EX_DATAERR, "u2d table: missing item(s) in row %d, line %d", i, line);
- for (j = 0; j < 8; j++)
- pargs->u2d[i * 8 + j] = code[j];
- }
- free(p);
- fclose(f);
-}
-
-void
-load_ultable (pargs, name)
- struct msdosfs_args *pargs;
- char *name;
-{
- int i;
-
- if (setlocale(LC_CTYPE, name) == NULL)
- err(EX_CONFIG, name);
- for (i = 0; i < 128; i++) {
- pargs->ul[i] = tolower(i | 0x80);
- pargs->lu[i] = toupper(i | 0x80);
- }
-}
diff --git a/sbin/mount_nullfs/Makefile b/sbin/mount_nullfs/Makefile
deleted file mode 100644
index 3f8b3ef94b02..000000000000
--- a/sbin/mount_nullfs/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# @(#)Makefile 8.3 (Berkeley) 3/27/94
-
-PROG= mount_null
-SRCS= mount_null.c getmntopts.c
-MAN8= mount_null.8
-
-MOUNT= ${.CURDIR}/../mount
-CFLAGS+= -I${.CURDIR}/../../sys -I${MOUNT}
-.PATH: ${MOUNT}
-
-.include <bsd.prog.mk>
diff --git a/sbin/mount_nullfs/mount_nullfs.8 b/sbin/mount_nullfs/mount_nullfs.8
deleted file mode 100644
index 83e279c307ef..000000000000
--- a/sbin/mount_nullfs/mount_nullfs.8
+++ /dev/null
@@ -1,245 +0,0 @@
-.\"
-.\" Copyright (c) 1992, 1993, 1994
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" This code is derived from software donated to Berkeley by
-.\" John Heidemann of the UCLA Ficus project.
-.\"
-.\"
-.\" 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 the University of
-.\" California, Berkeley and its contributors.
-.\" 4. 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.
-.\"
-.\" @(#)mount_null.8 8.6 (Berkeley) 5/1/95
-.\" $FreeBSD$
-.\"
-.Dd May 1, 1995
-.Dt MOUNT_NULL 8
-.Os BSD 4.4
-.Sh NAME
-.Nm mount_null
-.Nd mount a loopback filesystem sub-tree;
-demonstrate the use of a null file system layer
-.Sh SYNOPSIS
-.Nm mount_null
-.Op Fl o Ar options
-.Ar target
-.Ar mount-point
-.Sh DESCRIPTION
-The
-.Nm
-command creates a
-null layer, duplicating a sub-tree of the file system
-name space under another part of the global file system namespace.
-This allows existing files and directories to be accessed
-using a different pathname.
-.Pp
-The primary differences between a virtual copy of the filesystem
-and a symbolic link are that
-.Xr getcwd 3
-functions correctly in the virtual copy, and that other filesystems
-may be mounted on the virtual copy without affecting the original.
-A different device number for the virtual copy is returned by
-.Xr stat 2 ,
-but in other respects it is indistinguishable from the original.
-.Pp
-The
-.Nm
-filesystem differs from a traditional
-loopback file system in two respects: it is implemented using
-a stackable layers techniques, and it's
-.Do
-null-node
-.Dc s
-stack above
-all lower-layer vnodes, not just over directory vnodes.
-.Pp
-The options are as follows:
-.Bl -tag -width indent
-.It Fl o
-Options are specified with a
-.Fl o
-flag followed by a comma separated string of options.
-See the
-.Xr mount 8
-man page for possible options and their meanings.
-.El
-.Pp
-The null layer has two purposes.
-First, it serves as a demonstration of layering by providing a layer
-which does nothing.
-(It actually does everything the loopback file system does,
-which is slightly more than nothing.)
-Second, the null layer can serve as a prototype layer.
-Since it provides all necessary layer framework,
-new file system layers can be created very easily be starting
-with a null layer.
-.Pp
-The remainder of this man page examines the null layer as a basis
-for constructing new layers.
-.\"
-.\"
-.Sh INSTANTIATING NEW NULL LAYERS
-New null layers are created with
-.Xr mount_null 8 .
-.Xr Mount_null 8
-takes two arguments, the pathname
-of the lower vfs (target-pn) and the pathname where the null
-layer will appear in the namespace (mount-point-pn). After
-the null layer is put into place, the contents
-of target-pn subtree will be aliased under mount-point-pn.
-.\"
-.\"
-.Sh OPERATION OF A NULL LAYER
-The null layer is the minimum file system layer,
-simply bypassing all possible operations to the lower layer
-for processing there. The majority of its activity centers
-on the bypass routine, though which nearly all vnode operations
-pass.
-.Pp
-The bypass routine accepts arbitrary vnode operations for
-handling by the lower layer. It begins by examining vnode
-operation arguments and replacing any null-nodes by their
-lower-layer equivalents. It then invokes the operation
-on the lower layer. Finally, it replaces the null-nodes
-in the arguments and, if a vnode is returned by the operation,
-stacks a null-node on top of the returned vnode.
-.Pp
-Although bypass handles most operations,
-.Em vop_getattr ,
-.Em vop_inactive ,
-.Em vop_reclaim ,
-and
-.Em vop_print
-are not bypassed.
-.Em Vop_getattr
-must change the fsid being returned.
-.Em Vop_inactive
-and vop_reclaim are not bypassed so that
-they can handle freeing null-layer specific data.
-.Em Vop_print
-is not bypassed to avoid excessive debugging
-information.
-.\"
-.\"
-.Sh INSTANTIATING VNODE STACKS
-Mounting associates the null layer with a lower layer,
-in effect stacking two VFSes. Vnode stacks are instead
-created on demand as files are accessed.
-.Pp
-The initial mount creates a single vnode stack for the
-root of the new null layer. All other vnode stacks
-are created as a result of vnode operations on
-this or other null vnode stacks.
-.Pp
-New vnode stacks come into existence as a result of
-an operation which returns a vnode.
-The bypass routine stacks a null-node above the new
-vnode before returning it to the caller.
-.Pp
-For example, imagine mounting a null layer with
-.Bd -literal -offset indent
-mount_null /usr/include /dev/layer/null
-.Ed
-Changing directory to
-.Pa /dev/layer/null
-will assign
-the root null-node (which was created when the null layer was mounted).
-Now consider opening
-.Pa sys .
-A vop_lookup would be
-done on the root null-node. This operation would bypass through
-to the lower layer which would return a vnode representing
-the UFS
-.Pa sys .
-Null_bypass then builds a null-node
-aliasing the UFS
-.Pa sys
-and returns this to the caller.
-Later operations on the null-node
-.Pa sys
-will repeat this
-process when constructing other vnode stacks.
-.\"
-.\"
-.Sh CREATING OTHER FILE SYSTEM LAYERS
-One of the easiest ways to construct new file system layers is to make
-a copy of the null layer, rename all files and variables, and
-then begin modifying the copy.
-.Xr Sed 1
-can be used to easily rename
-all variables.
-.Pp
-The umap layer is an example of a layer descended from the
-null layer.
-.\"
-.\"
-.Sh INVOKING OPERATIONS ON LOWER LAYERS
-There are two techniques to invoke operations on a lower layer
-when the operation cannot be completely bypassed. Each method
-is appropriate in different situations. In both cases,
-it is the responsibility of the aliasing layer to make
-the operation arguments "correct" for the lower layer
-by mapping an vnode arguments to the lower layer.
-.Pp
-The first approach is to call the aliasing layer's bypass routine.
-This method is most suitable when you wish to invoke the operation
-currently being handled on the lower layer. It has the advantage
-the bypass routine already must do argument mapping.
-An example of this is
-.Em null_getattrs
-in the null layer.
-.Pp
-A second approach is to directly invoked vnode operations on
-the lower layer with the
-.Em VOP_OPERATIONNAME
-interface.
-The advantage of this method is that it is easy to invoke
-arbitrary operations on the lower layer. The disadvantage
-is that vnodes arguments must be manually mapped.
-.\"
-.\"
-.Sh SEE ALSO
-.Xr mount 8
-.sp
-UCLA Technical Report CSD-910056,
-.Em "Stackable Layers: an Architecture for File System Development" .
-.Sh BUGS
-
-THIS FILESYSTEM TYPE IS NOT YET FULLY SUPPORTED (READ: IT DOESN'T WORK)
-AND USING IT MAY, IN FACT, DESTROY DATA ON YOUR SYSTEM. USE AT YOUR
-OWN RISK. BEWARE OF DOG. SLIPPERY WHEN WET.
-
-This code also needs an owner in order to be less dangerous - serious
-hackers can apply by sending mail to hackers@freebsd.org and announcing
-their intent to take it over.
-
-.Sh HISTORY
-The
-.Nm
-utility first appeared in
-.Bx 4.4 .
diff --git a/sbin/mount_nullfs/mount_nullfs.c b/sbin/mount_nullfs/mount_nullfs.c
deleted file mode 100644
index cf6120863bac..000000000000
--- a/sbin/mount_nullfs/mount_nullfs.c
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (c) 1992, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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 lint
-static const char copyright[] =
-"@(#) Copyright (c) 1992, 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)mount_null.c 8.6 (Berkeley) 4/26/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <sys/param.h>
-#include <sys/mount.h>
-#include <miscfs/nullfs/null.h>
-
-#include <err.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sysexits.h>
-#include <unistd.h>
-
-#include "mntopts.h"
-
-struct mntopt mopts[] = {
- MOPT_STDOPTS,
- { NULL }
-};
-
-int subdir __P((const char *, const char *));
-static void usage __P((void)) __dead2;
-
-int
-main(argc, argv)
- int argc;
- char *argv[];
-{
- struct null_args args;
- int ch, mntflags;
- char source[MAXPATHLEN];
- char target[MAXPATHLEN];
- struct vfsconf vfc;
- int error;
-
- mntflags = 0;
- while ((ch = getopt(argc, argv, "o:")) != -1)
- switch(ch) {
- case 'o':
- getmntopts(optarg, mopts, &mntflags, 0);
- break;
- case '?':
- default:
- usage();
- }
- argc -= optind;
- argv += optind;
-
- if (argc != 2)
- usage();
-
- /* resolve target and source with realpath(3) */
- (void)checkpath(argv[0], target);
- (void)checkpath(argv[1], source);
-
- if (subdir(target, source) || subdir(source, target))
- errx(EX_USAGE, "%s (%s) and %s are not distinct paths",
- argv[0], target, argv[1]);
-
- args.target = target;
-
- error = getvfsbyname("null", &vfc);
- if (error && vfsisloadable("null")) {
- if(vfsload("null"))
- err(EX_OSERR, "vfsload(null)");
- endvfsent();
- error = getvfsbyname("null", &vfc);
- }
- if (error)
- errx(EX_OSERR, "null/loopback filesystem is not available");
-
- if (mount(vfc.vfc_name, source, mntflags, &args))
- err(1, NULL);
- exit(0);
-}
-
-int
-subdir(p, dir)
- const char *p;
- const char *dir;
-{
- int l;
-
- l = strlen(dir);
- if (l <= 1)
- return (1);
-
- if ((strncmp(p, dir, l) == 0) && (p[l] == '/' || p[l] == '\0'))
- return (1);
-
- return (0);
-}
-
-static void
-usage()
-{
- (void)fprintf(stderr,
- "usage: mount_null [-o options] target_fs mount_point\n");
- exit(1);
-}
diff --git a/sbin/mount_portalfs/Makefile b/sbin/mount_portalfs/Makefile
deleted file mode 100644
index 23a5bd771be8..000000000000
--- a/sbin/mount_portalfs/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-# From: @(#)Makefile 8.3 (Berkeley) 3/27/94
-# $FreeBSD$
-
-PROG= mount_portal
-SRCS= mount_portal.c activate.c conf.c getmntopts.c pt_conf.c \
- pt_exec.c pt_file.c pt_tcp.c pt_tcplisten.c
-MAN8= mount_portal.8
-
-MOUNT= ${.CURDIR}/../mount
-CFLAGS+= -I${.CURDIR}/../../sys -I${MOUNT}
-.PATH: ${MOUNT}
-
-.include <bsd.prog.mk>
diff --git a/sbin/mount_portalfs/activate.c b/sbin/mount_portalfs/activate.c
deleted file mode 100644
index 56464981471c..000000000000
--- a/sbin/mount_portalfs/activate.c
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- * All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)activate.c 8.3 (Berkeley) 4/28/95
- */
-
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <errno.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/socket.h>
-#include <sys/syslog.h>
-#include <sys/uio.h>
-
-#include "portald.h"
-
-/*
- * Scan the providers list and call the
- * appropriate function.
- */
-static int activate_argv(pcr, key, v, so, fdp)
-struct portal_cred *pcr;
-char *key;
-char **v;
-int so;
-int *fdp;
-{
- provider *pr;
-
- for (pr = providers; pr->pr_match; pr++)
- if (strcmp(v[0], pr->pr_match) == 0)
- return ((*pr->pr_func)(pcr, key, v, so, fdp));
-
- return (ENOENT);
-}
-
-static int get_request(so, pcr, key, klen)
-int so;
-struct portal_cred *pcr;
-char *key;
-int klen;
-{
- struct iovec iov[2];
- struct msghdr msg;
- int n;
-
- iov[0].iov_base = (caddr_t) pcr;
- iov[0].iov_len = sizeof(*pcr);
- iov[1].iov_base = key;
- iov[1].iov_len = klen;
-
- memset(&msg, 0, sizeof(msg));
- msg.msg_iov = iov;
- msg.msg_iovlen = 2;
-
- n = recvmsg(so, &msg, 0);
- if (n < 0)
- return (errno);
-
- if (n <= sizeof(*pcr))
- return (EINVAL);
-
- n -= sizeof(*pcr);
- key[n] = '\0';
-
- return (0);
-}
-
-static void send_reply(so, fd, error)
-int so;
-int fd;
-int error;
-{
- int n;
- struct iovec iov;
- struct msghdr msg;
- struct {
- struct cmsghdr cmsg;
- int fd;
- } ctl;
-
- /*
- * Line up error code. Don't worry about byte ordering
- * because we must be sending to the local machine.
- */
- iov.iov_base = (caddr_t) &error;
- iov.iov_len = sizeof(error);
-
- /*
- * Build a msghdr
- */
- memset(&msg, 0, sizeof(msg));
- msg.msg_iov = &iov;
- msg.msg_iovlen = 1;
-
- /*
- * If there is a file descriptor to send then
- * construct a suitable rights control message.
- */
- if (fd >= 0) {
- ctl.fd = fd;
- ctl.cmsg.cmsg_len = sizeof(ctl);
- ctl.cmsg.cmsg_level = SOL_SOCKET;
- ctl.cmsg.cmsg_type = SCM_RIGHTS;
- msg.msg_control = (caddr_t) &ctl;
- msg.msg_controllen = ctl.cmsg.cmsg_len;
- }
-
- /*
- * Send to kernel...
- */
- if ((n = sendmsg(so, &msg, 0)) < 0)
- syslog(LOG_ERR, "send: %s", strerror(errno));
-#ifdef DEBUG
- fprintf(stderr, "sent %d bytes\n", n);
-#endif
- sleep(1); /*XXX*/
-#ifdef notdef
- if (shutdown(so, 2) < 0)
- syslog(LOG_ERR, "shutdown: %s", strerror(errno));
-#endif
- /*
- * Throw away the open file descriptor
- */
- (void) close(fd);
-}
-
-void activate(q, so)
-qelem *q;
-int so;
-{
- struct portal_cred pcred;
- char key[MAXPATHLEN+1];
- int error;
- char **v;
- int fd = -1;
-
- /*
- * Read the key from the socket
- */
- error = get_request(so, &pcred, key, sizeof(key));
- if (error) {
- syslog(LOG_ERR, "activate: recvmsg: %s", strerror(error));
- goto drop;
- }
-
-#ifdef DEBUG
- fprintf(stderr, "lookup key %s\n", key);
-#endif
-
- /*
- * Find a match in the configuration file
- */
- v = conf_match(q, key);
-
- /*
- * If a match existed, then find an appropriate portal
- * otherwise simply return ENOENT.
- */
- if (v) {
- error = activate_argv(&pcred, key, v, so, &fd);
- if (error)
- fd = -1;
- else if (fd < 0)
- error = -1;
- } else {
- error = ENOENT;
- }
-
- if (error >= 0)
- send_reply(so, fd, error);
-
-drop:;
- close(so);
-}
diff --git a/sbin/mount_portalfs/conf.c b/sbin/mount_portalfs/conf.c
deleted file mode 100644
index d5833e4b2136..000000000000
--- a/sbin/mount_portalfs/conf.c
+++ /dev/null
@@ -1,340 +0,0 @@
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- * All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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 8.2 (Berkeley) 3/27/94
- */
-
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <errno.h>
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <regex.h>
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/syslog.h>
-
-#include "portald.h"
-
-#define ALLOC(ty) (xmalloc(sizeof(ty)))
-
-typedef struct path path;
-struct path {
- qelem p_q; /* 2-way linked list */
- int p_lno; /* Line number of this record */
- char *p_args; /* copy of arg string (malloc) */
- char *p_key; /* Pathname to match (also p_argv[0]) */
- regex_t p_rx; /* RE to match against pathname () */
- int p_rxvalid; /* non-zero if valid regular expression */
- int p_argc; /* number of elements in arg string */
- char **p_argv; /* argv[] pointers into arg string (malloc) */
-};
-
-static char *conf_file; /* XXX for regerror */
-static path *curp; /* XXX for regerror */
-
-/*
- * Add an element to a 2-way list,
- * just after (pred)
- */
-static void ins_que(elem, pred)
-qelem *elem, *pred;
-{
- qelem *p = pred->q_forw;
- elem->q_back = pred;
- elem->q_forw = p;
- pred->q_forw = elem;
- p->q_back = elem;
-}
-
-/*
- * Remove an element from a 2-way list
- */
-static void rem_que(elem)
-qelem *elem;
-{
- qelem *p = elem->q_forw;
- qelem *p2 = elem->q_back;
- p2->q_forw = p;
- p->q_back = p2;
-}
-
-/*
- * Error checking malloc
- */
-static void *xmalloc(siz)
-unsigned siz;
-{
- void *p = malloc(siz);
- if (p)
- return (p);
- syslog(LOG_ALERT, "malloc: failed to get %d bytes", siz);
- exit(1);
-}
-
-/*
- * Insert the path in the list.
- * If there is already an element with the same key then
- * the *second* one is ignored (return 0). If the key is
- * not found then the path is added to the end of the list
- * and 1 is returned.
- */
-static int pinsert(p0, q0)
-path *p0;
-qelem *q0;
-{
- qelem *q;
-
- if (p0->p_argc == 0)
- return (0);
-
- for (q = q0->q_forw; q != q0; q = q->q_forw) {
- path *p = (path *) q;
- if (strcmp(p->p_key, p0->p_key) == 0)
- return (0);
- }
- ins_que(&p0->p_q, q0->q_back);
- return (1);
-
-}
-
-static path *palloc(cline, lno)
-char *cline;
-int lno;
-{
- int c;
- char *s;
- char *key;
- path *p;
- char **ap;
-
- /*
- * Implement comment chars
- */
- s = strchr(cline, '#');
- if (s)
- *s = 0;
-
- /*
- * Do a pass through the string to count the number
- * of arguments
- */
- c = 0;
- key = strdup(cline);
- for (s = key; s != NULL; ) {
- char *val;
- while ((val = strsep(&s, " \t\n")) != NULL && *val == '\0')
- ;
- if (val)
- c++;
- }
- c++;
- free(key);
-
- if (c <= 1)
- return (0);
-
- /*
- * Now do another pass and generate a new path structure
- */
- p = ALLOC(path);
- p->p_argc = 0;
- p->p_argv = xmalloc(c * sizeof(char *));
- p->p_args = strdup(cline);
- ap = p->p_argv;
- for (s = p->p_args; s != NULL; ) {
- char *val;
- while ((val = strsep(&s, " \t\n")) != NULL && *val == '\0')
- ;
- if (val) {
- *ap++ = val;
- p->p_argc++;
- }
- }
- *ap = 0;
-
-#ifdef DEBUG
- for (c = 0; c < p->p_argc; c++)
- printf("%sv[%d] = %s\n", c?"\t":"", c, p->p_argv[c]);
-#endif
-
- p->p_key = p->p_argv[0];
- if (strpbrk(p->p_key, RE_CHARS)) {
- int val;
-
- curp = p; /* XXX */
- val = regcomp(&p->p_rx, p->p_key, REG_EXTENDED | REG_NOSUB);
- if (val) {
- char errbuf[_POSIX2_LINE_MAX];
- regerror(val, &p->p_rx, errbuf, sizeof errbuf);
- syslog(LOG_ERR, "%s:%d: regcomp %s: %s",
- conf_file, curp->p_lno, curp->p_key, errbuf);
- regfree(&p->p_rx);
- p->p_rxvalid = 0;
- } else {
- p->p_rxvalid = 1;
- }
- curp = 0; /* XXX */
- } else {
- p->p_rxvalid = 0;
- }
- p->p_lno = lno;
-
- return (p);
-}
-
-/*
- * Free a path structure
- */
-static void pfree(p)
-path *p;
-{
- free(p->p_args);
- if (p->p_rxvalid) {
- regfree(&p->p_rx);
- }
- free((char *) p->p_argv);
- free((char *) p);
-}
-
-/*
- * Discard all currently held path structures on q0.
- * and add all the ones on xq.
- */
-static void preplace(q0, xq)
-qelem *q0;
-qelem *xq;
-{
- /*
- * While the list is not empty,
- * take the first element off the list
- * and free it.
- */
- while (q0->q_forw != q0) {
- qelem *q = q0->q_forw;
- rem_que(q);
- pfree((path *) q);
- }
- while (xq->q_forw != xq) {
- qelem *q = xq->q_forw;
- rem_que(q);
- ins_que(q, q0);
- }
-}
-
-/*
- * Read the lines from the configuration file and
- * add them to the list of paths.
- */
-static void readfp(q0, fp)
-qelem *q0;
-FILE *fp;
-{
- char cline[LINE_MAX];
- int nread = 0;
- qelem q;
-
- /*
- * Make a new empty list.
- */
- q.q_forw = q.q_back = &q;
-
- /*
- * Read the lines from the configuration file.
- */
- while (fgets(cline, sizeof(cline), fp)) {
- path *p = palloc(cline, nread+1);
- if (p && !pinsert(p, &q))
- pfree(p);
- nread++;
- }
-
- /*
- * If some records were read, then throw
- * away the old list and replace with the
- * new one.
- */
- if (nread)
- preplace(q0, &q);
-}
-
-/*
- * Read the configuration file (conf) and replace
- * the existing path list with the new version.
- * If the file is not readable, then no changes take place
- */
-void conf_read(q, conf)
-qelem *q;
-char *conf;
-{
- FILE *fp = fopen(conf, "r");
- if (fp) {
- conf_file = conf; /* XXX */
- readfp(q, fp);
- conf_file = 0; /* XXX */
- (void) fclose(fp);
- } else {
- syslog(LOG_ERR, "open config file \"%s\": %s", conf, strerror(errno));
- }
-}
-
-
-char **conf_match(q0, key)
-qelem *q0;
-char *key;
-{
- qelem *q;
-
- for (q = q0->q_forw; q != q0; q = q->q_forw) {
- path *p = (path *) q;
- if (p->p_rxvalid) {
- if (!regexec(&p->p_rx, key, 0, 0, 0)) {
- return p->p_argv + 1;
- }
- } else {
- if (strncmp(p->p_key, key, strlen(p->p_key)) == 0)
- return (p->p_argv+1);
- }
- }
-
- return (0);
-}
diff --git a/sbin/mount_portalfs/mount_portalfs.8 b/sbin/mount_portalfs/mount_portalfs.8
deleted file mode 100644
index 306a220c8aff..000000000000
--- a/sbin/mount_portalfs/mount_portalfs.8
+++ /dev/null
@@ -1,152 +0,0 @@
-.\"
-.\" Copyright (c) 1993, 1994
-.\" The Regents of the University of California. All rights reserved.
-.\" All rights reserved.
-.\"
-.\" This code is derived from software donated to Berkeley by
-.\" Jan-Simon Pendry.
-.\"
-.\" 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 the University of
-.\" California, Berkeley and its contributors.
-.\" 4. 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.
-.\"
-.\" @(#)mount_portal.8 8.3 (Berkeley) 3/27/94
-.\" $FreeBSD$
-.\"
-.Dd March 27, 1994
-.Dt MOUNT_PORTAL 8
-.Os BSD 4.4
-.Sh NAME
-.Nm mount_portal
-.Nd mount the portal daemon
-.Sh SYNOPSIS
-.Nm mount_portal
-.Op Fl o Ar options
-.Ar /etc/portal.conf
-.Ar mount_point
-.Sh DESCRIPTION
-The
-.Nm
-command attaches an instance of the portal daemon
-to the global filesystem namespace.
-The conventional mount point is
-.Pa /p .
-.\" .PA /dev .
-This command is normally executed by
-.Xr mount 8
-at boot time.
-.Pp
-The options are as follows:
-.Bl -tag -width indent
-.It Fl o
-Options are specified with a
-.Fl o
-flag followed by a comma separated string of options.
-See the
-.Xr mount 8
-man page for possible options and their meanings.
-.El
-.Pp
-The portal daemon provides an
-.Em open
-service.
-Objects opened under the portal mount point are
-dynamically created by the portal daemon according
-to rules specified in the named configuration file.
-Using this mechanism allows descriptors such as sockets
-to be made available in the filesystem namespace.
-.Pp
-The portal daemon works by being passed the full pathname
-of the object being opened.
-The daemon creates an appropriate descriptor according
-to the rules in the configuration file, and then passes the descriptor back
-to the calling process as the result of the open system call.
-.Sh NAMESPACE
-By convention, the portal daemon divides the namespace into sub-namespaces,
-each of which handles objects of a particular type.
-.Pp
-The following sub-namespaces are currently implemented:
-.Pa tcplisten ,
-.Pa tcp
-and
-.Pa fs .
-The
-.Pa tcplisten
-namespace takes a slash separated hostname and port and creates a TCP/IP
-socket bound to the given hostname-port pair.
-The hostname may be
-specified as "ANY" to allow any other host to connect to the socket.
-A
-port number of 0 will dynamically allocate a port, this can be
-discovered by calling
-.Xr getsockname 2
-with the returned file descriptor.
-Privileged ports can only be bound to
-by the super-user.
-The
-.Pa tcp
-namespace takes a hostname and a port (slash separated) and
-creates an open TCP/IP connection.
-The
-.Pa fs
-namespace opens the named file, starting back at the root directory.
-This can be used to provide a controlled escape path from
-a chrooted environment.
-.Sh "CONFIGURATION FILE"
-The configuration file contains a list of rules.
-Each rule takes one line and consists of two or more
-whitespace separated fields.
-A hash (``#'') character causes the remainder of a line to
-be ignored. Blank lines are ignored.
-.Pp
-The first field is a pathname prefix to match
-against the requested pathname.
-If a match is found, the second field
-tells the daemon what type of object to create.
-Subsequent fields are passed to the creation function.
-.Bd -literal
-# @(#)portal.conf 5.1 (Berkeley) 7/13/92
-tcplisten/ tcplisten tcplisten/
-tcp/ tcp tcp/
-fs/ file fs/
-.Ed
-.Sh FILES
-.Bl -tag -width /p/* -compact
-.It Pa /p/*
-.El
-.Sh SEE ALSO
-.Xr mount 2 ,
-.Xr unmount 2 ,
-.Xr fstab 5 ,
-.Xr mount 8
-.Sh CAVEATS
-This filesystem may not be NFS-exported.
-.Sh HISTORY
-The
-.Nm
-utility first appeared in
-.Bx 4.4 .
diff --git a/sbin/mount_portalfs/mount_portalfs.c b/sbin/mount_portalfs/mount_portalfs.c
deleted file mode 100644
index 48cf609df74e..000000000000
--- a/sbin/mount_portalfs/mount_portalfs.c
+++ /dev/null
@@ -1,295 +0,0 @@
-/*
- * Copyright (c) 1992, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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 lint
-char copyright[] =
-"@(#) Copyright (c) 1992, 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)mount_portal.c 8.6 (Berkeley) 4/26/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <sys/param.h>
-#include <sys/wait.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <sys/stat.h>
-#include <sys/syslog.h>
-#include <sys/mount.h>
-
-#include <err.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sysexits.h>
-#include <unistd.h>
-
-#include "mntopts.h"
-#include "pathnames.h"
-#include "portald.h"
-
-struct mntopt mopts[] = {
- MOPT_STDOPTS,
- { NULL }
-};
-
-static void usage __P((void)) __dead2;
-
-static sig_atomic_t readcf; /* Set when SIGHUP received */
-
-static void sighup(sig)
-int sig;
-{
- readcf ++;
-}
-
-static void sigchld(sig)
-int sig;
-{
- pid_t pid;
-
- while ((pid = waitpid((pid_t) -1, (int *) 0, WNOHANG)) > 0)
- ;
- /* wrtp - waitpid _doesn't_ return 0 when no children! */
-#ifdef notdef
- if (pid < 0 && errno != ECHILD)
- syslog(LOG_WARNING, "waitpid: %s", strerror(errno));
-#endif
-}
-
-int
-main(argc, argv)
- int argc;
- char *argv[];
-{
- struct portal_args args;
- struct sockaddr_un un;
- char *conf;
- char mountpt[MAXPATHLEN];
- int mntflags = 0;
- char tag[32];
- struct vfsconf vfc;
- mode_t um;
-
- qelem q;
- int rc;
- int so;
- int error = 0;
-
- /*
- * Crack command line args
- */
- int ch;
-
- while ((ch = getopt(argc, argv, "o:")) != -1) {
- switch (ch) {
- case 'o':
- getmntopts(optarg, mopts, &mntflags, 0);
- break;
- default:
- error = 1;
- break;
- }
- }
-
- if (optind != (argc - 2))
- error = 1;
-
- if (error)
- usage();
-
- /*
- * Get config file and mount point
- */
- conf = argv[optind];
-
- /* resolve the mountpoint with realpath(3) */
- (void)checkpath(argv[optind+1], mountpt);
-
- /*
- * Construct the listening socket
- */
- un.sun_family = AF_UNIX;
- if (sizeof(_PATH_TMPPORTAL) >= sizeof(un.sun_path)) {
- errx(EX_SOFTWARE, "portal socket name too long");
- }
- strcpy(un.sun_path, _PATH_TMPPORTAL);
- mktemp(un.sun_path);
- un.sun_len = strlen(un.sun_path);
-
- so = socket(AF_UNIX, SOCK_STREAM, 0);
- if (so < 0) {
- err(EX_OSERR, "socket");
- }
- um = umask(077);
- (void) unlink(un.sun_path);
- if (bind(so, (struct sockaddr *) &un, sizeof(un)) < 0)
- err(1, NULL);
-
- (void) unlink(un.sun_path);
- (void) umask(um);
-
- (void) listen(so, 5);
-
- args.pa_socket = so;
- sprintf(tag, "portal:%d", getpid());
- args.pa_config = tag;
-
- error = getvfsbyname("portal", &vfc);
- if (error && vfsisloadable("portal")) {
- if (vfsload("portal"))
- err(EX_OSERR, "vfsload(portal)");
- endvfsent();
- error = getvfsbyname("portal", &vfc);
- }
- if (error)
- errx(EX_OSERR, "portal filesystem is not available");
-
- rc = mount(vfc.vfc_name, mountpt, mntflags, &args);
- if (rc < 0)
- err(1, NULL);
-
- /*
- * Everything is ready to go - now is a good time to fork
- */
-#ifndef DEBUG
- daemon(0, 0);
-#endif
-
- /*
- * Start logging (and change name)
- */
- openlog("portald", LOG_CONS|LOG_PID, LOG_DAEMON);
-
- q.q_forw = q.q_back = &q;
- readcf = 1;
-
- signal(SIGCHLD, sigchld);
- signal(SIGHUP, sighup);
-
- /*
- * Just loop waiting for new connections and activating them
- */
- for (;;) {
- struct sockaddr_un un2;
- int len2 = sizeof(un2);
- int so2;
- pid_t pid;
- fd_set fdset;
- int rc;
-
- /*
- * Check whether we need to re-read the configuration file
- */
- if (readcf) {
-#ifdef DEBUG
- printf ("re-reading configuration file\n");
-#endif
- readcf = 0;
- conf_read(&q, conf);
- continue;
- }
-
- /*
- * Accept a new connection
- * Will get EINTR if a signal has arrived, so just
- * ignore that error code
- */
- FD_ZERO(&fdset);
- FD_SET(so, &fdset);
- rc = select(so+1, &fdset, (fd_set *) 0, (fd_set *) 0, (struct timeval *) 0);
- if (rc < 0) {
- if (errno == EINTR)
- continue;
- syslog(LOG_ERR, "select: %s", strerror(errno));
- exit(EX_OSERR);
- }
- if (rc == 0)
- break;
- so2 = accept(so, (struct sockaddr *) &un2, &len2);
- if (so2 < 0) {
- /*
- * The unmount function does a shutdown on the socket
- * which will generated ECONNABORTED on the accept.
- */
- if (errno == ECONNABORTED)
- break;
- if (errno != EINTR) {
- syslog(LOG_ERR, "accept: %s", strerror(errno));
- exit(EX_OSERR);
- }
- continue;
- }
-
- /*
- * Now fork a new child to deal with the connection
- */
- eagain:;
- switch (pid = fork()) {
- case -1:
- if (errno == EAGAIN) {
- sleep(1);
- goto eagain;
- }
- syslog(LOG_ERR, "fork: %s", strerror(errno));
- break;
- case 0:
- (void) close(so);
- activate(&q, so2);
- exit(0);
- default:
- (void) close(so2);
- break;
- }
- }
- syslog(LOG_INFO, "%s unmounted", mountpt);
- exit(0);
-}
-
-static void
-usage()
-{
- (void)fprintf(stderr,
- "usage: mount_portal [-o options] config mount-point\n");
- exit(EX_USAGE);
-}
diff --git a/sbin/mount_portalfs/pathnames.h b/sbin/mount_portalfs/pathnames.h
deleted file mode 100644
index 16720853c70a..000000000000
--- a/sbin/mount_portalfs/pathnames.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- * All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)pathnames.h 8.1 (Berkeley) 6/5/93
- *
- * $FreeBSD$
- */
-
-#include <paths.h>
-
-#define _PATH_TMPPORTAL "/tmp/portalXXXXXXXXXX" /* Scratch socket name */
diff --git a/sbin/mount_portalfs/portal.conf b/sbin/mount_portalfs/portal.conf
deleted file mode 100644
index 53a07a92231c..000000000000
--- a/sbin/mount_portalfs/portal.conf
+++ /dev/null
@@ -1,7 +0,0 @@
-# @(#)portal.conf 8.1 (Berkeley) 6/5/93
-# $FreeBSD$
-tcplisten/ tcplisten tcplisten/
-tcp/ tcp tcp/
-fs/ file fs/
-pipe/ pipe
-foo/ exec ./bar bar baz
diff --git a/sbin/mount_portalfs/portald.h b/sbin/mount_portalfs/portald.h
deleted file mode 100644
index 4131834c5575..000000000000
--- a/sbin/mount_portalfs/portald.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- * All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)portald.h 8.1 (Berkeley) 6/5/93
- *
- * $FreeBSD$
- */
-
-#include <sys/cdefs.h>
-#include <miscfs/portal/portal.h>
-
-/*
- * Meta-chars in an RE. Paths in the config file containing
- * any of these characters will be matched using regexec, other
- * paths will be prefix-matched.
- */
-#define RE_CHARS ".|()[]*+?\\^$"
-
-typedef struct qelem qelem;
-
-struct qelem {
- qelem *q_forw;
- qelem *q_back;
-};
-
-typedef struct provider provider;
-struct provider {
- char *pr_match;
- int (*pr_func) __P((struct portal_cred *,
- char *key, char **v, int so, int *fdp));
-};
-extern provider providers[];
-
-/*
- * Portal providers
- */
-extern int portal_exec __P((struct portal_cred *,
- char *key, char **v, int so, int *fdp));
-extern int portal_file __P((struct portal_cred *,
- char *key, char **v, int so, int *fdp));
-extern int portal_tcp __P((struct portal_cred *,
- char *key, char **v, int so, int *fdp));
-extern int portal_tcplisten __P((struct portal_cred *,
- char *key, char **v, int so, int *fdp));
-
-/*
- * Global functions
- */
-extern void activate __P((qelem *q, int so));
-extern char **conf_match __P((qelem *q, char *key));
-extern void conf_read __P((qelem *q, char *conf));
diff --git a/sbin/mount_portalfs/pt_conf.c b/sbin/mount_portalfs/pt_conf.c
deleted file mode 100644
index f158a73dd03d..000000000000
--- a/sbin/mount_portalfs/pt_conf.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- * All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)pt_conf.c 8.1 (Berkeley) 6/5/93
- */
-
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include "portald.h"
-
-provider providers[] = {
- { "exec", portal_exec },
- { "file", portal_file },
- { "tcp", portal_tcp },
- { "tcplisten", portal_tcplisten },
- { 0, 0 }
-};
diff --git a/sbin/mount_portalfs/pt_exec.c b/sbin/mount_portalfs/pt_exec.c
deleted file mode 100644
index 359c78e92164..000000000000
--- a/sbin/mount_portalfs/pt_exec.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- * All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)pt_exec.c 8.1 (Berkeley) 6/5/93
- */
-
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/param.h>
-
-#include "portald.h"
-
-int portal_exec(pcr, key, v, so, fdp)
-struct portal_cred *pcr;
-char *key;
-char **v;
-int so;
-int *fdp;
-{
- return (ENOEXEC);
-}
-
diff --git a/sbin/mount_portalfs/pt_file.c b/sbin/mount_portalfs/pt_file.c
deleted file mode 100644
index f22ebd7d2b51..000000000000
--- a/sbin/mount_portalfs/pt_file.c
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- * All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)pt_file.c 8.3 (Berkeley) 7/3/94
- */
-
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <errno.h>
-#include <fcntl.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/syslog.h>
-
-#include "portald.h"
-
-int portal_file(pcr, key, v, so, fdp)
-struct portal_cred *pcr;
-char *key;
-char **v;
-int so;
-int *fdp;
-{
- int fd;
- char pbuf[MAXPATHLEN];
- int error;
- gid_t gidset[NGROUPS];
- int i;
-
- pbuf[0] = '/';
- strcpy(pbuf+1, key + (v[1] ? strlen(v[1]) : 0));
-
-#ifdef DEBUG
- printf("path = %s, uid = %d, gid = %d\n", pbuf, pcr->pcr_uid, pcr->pcr_groups[0]);
- printf ("fflag = %x, oflag = %x\n", pcr->pcr_flag, (pcr->pcr_flag)-1);
-#endif
-
- for (i = 0; i < pcr->pcr_ngroups; i++)
- gidset[i] = pcr->pcr_groups[i];
-
- if (setgroups(pcr->pcr_ngroups, gidset) < 0)
- return (errno);
-
- if (seteuid(pcr->pcr_uid) < 0)
- return (errno);
-
- /* dmb convert kernel flags to oflags, see <fcntl.h> */
- fd = open(pbuf, (pcr->pcr_flag)-1, 0777);
- if (fd < 0)
- error = errno;
- else
- error = 0;
-
- if (seteuid((uid_t) 0) < 0) { /* XXX - should reset gidset too */
- error = errno;
- syslog(LOG_ERR, "setcred: %s", strerror(error));
- if (fd >= 0) {
- (void) close(fd);
- fd = -1;
- }
- }
-
- if (error == 0)
- *fdp = fd;
-
-#ifdef DEBUG
- fprintf(stderr, "pt_file returns *fdp = %d, error = %d\n", *fdp, error);
-#endif
-
- return (error);
-}
diff --git a/sbin/mount_portalfs/pt_tcp.c b/sbin/mount_portalfs/pt_tcp.c
deleted file mode 100644
index 49056163aae3..000000000000
--- a/sbin/mount_portalfs/pt_tcp.c
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright (c) 1992, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- * All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)pt_tcp.c 8.5 (Berkeley) 4/28/95
- */
-
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <errno.h>
-#include <stdlib.h>
-#include <strings.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/syslog.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-
-#include "portald.h"
-
-/*
- * Key will be tcp/host/port[/"priv"]
- * Create a TCP socket connected to the
- * requested host and port.
- * Some trailing suffix values have special meanings.
- * An unrecognized suffix is an error.
- */
-int portal_tcp(pcr, key, v, kso, fdp)
- struct portal_cred *pcr;
- char *key;
- char **v;
- int kso;
- int *fdp;
-{
- char host[MAXHOSTNAMELEN];
- char port[MAXHOSTNAMELEN];
- char *p = key + (v[1] ? strlen(v[1]) : 0);
- char *q;
- struct hostent *hp;
- struct servent *sp;
- struct in_addr **ipp;
- struct in_addr *ip[2];
- struct in_addr ina;
- u_short s_port;
- int priv = 0;
- struct sockaddr_in sain;
-
- q = strchr(p, '/');
- if (q == 0 || q - p >= sizeof(host))
- return (EINVAL);
- *q = '\0';
- strcpy(host, p);
- p = q + 1;
-
- q = strchr(p, '/');
- if (q)
- *q = '\0';
- if (strlen(p) >= sizeof(port))
- return (EINVAL);
- strcpy(port, p);
- if (q) {
- p = q + 1;
- if (strcmp(p, "priv") == 0) {
- if (pcr->pcr_uid == 0)
- priv = 1;
- else
- return (EPERM);
- } else {
- return (EINVAL);
- }
- }
-
- hp = gethostbyname(host);
- if (hp != 0) {
- ipp = (struct in_addr **) hp->h_addr_list;
- } else {
- ina.s_addr = inet_addr(host);
- if (ina.s_addr == INADDR_NONE)
- return (EINVAL);
- ip[0] = &ina;
- ip[1] = 0;
- ipp = ip;
- }
-#ifdef DEBUG
- printf ("inet address for %s is %s\n", host, inet_ntoa(*ipp[0]));
-#endif
-
- sp = getservbyname(port, "tcp");
- if (sp != NULL) {
- s_port = (u_short)sp->s_port;
- } else {
- s_port = strtoul(port, &p, 0);
- if (s_port == 0 || *p != '\0')
- return (EINVAL);
- s_port = htons(s_port);
- }
-#ifdef DEBUG
- printf ("port number for %s is %d\n", port, (int)ntohs(s_port));
-#endif
-
- memset(&sain, 0, sizeof(sain));
- sain.sin_len = sizeof(sain);
- sain.sin_family = AF_INET;
- sain.sin_port = s_port;
-
- while (ipp[0]) {
- int so;
-
- if (priv)
- so = rresvport((int *) 0);
- else
- so = socket(AF_INET, SOCK_STREAM, 0);
- if (so < 0) {
- syslog(LOG_ERR, "socket: %m");
- return (errno);
- }
-
- sain.sin_addr = *ipp[0];
- if (connect(so, (struct sockaddr *) &sain, sizeof(sain)) == 0) {
- *fdp = so;
- return (0);
- }
- (void) close(so);
-
- ipp++;
- }
-
- return (errno);
-}
diff --git a/sbin/mount_portalfs/pt_tcplisten.c b/sbin/mount_portalfs/pt_tcplisten.c
deleted file mode 100644
index 43a20c5aa92c..000000000000
--- a/sbin/mount_portalfs/pt_tcplisten.c
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- * All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * Modified by Duncan Barclay.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)pt_tcp.c 8.3 (Berkeley) 3/27/94
- *
- * pt_tcp.c,v 1.1.1.1 1994/05/26 06:34:34 rgrimes Exp
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <strings.h>
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/syslog.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-
-#include "portald.h"
-
-/*
- * Key will be tcplisten/host/port
- *
- * Create a TCP socket bound to the requested host and port.
- * If the host is "ANY" the receving address will be set to INADDR_ANY.
- * If the port is 0 the caller must find out the returned port number
- * using a call to getsockname.
- *
- * XXX! The owner of the socket will be root rather then the user. This
- * may cause remote auth (identd) to return unexpected results.
- *
- */
-int portal_tcplisten(pcr, key, v, kso, fdp)
- struct portal_cred *pcr;
- char *key;
- char **v;
- int kso;
- int *fdp;
-{
- char host[MAXHOSTNAMELEN];
- char port[MAXHOSTNAMELEN];
- char *p = key + (v[1] ? strlen(v[1]) : 0);
- char *q;
- struct hostent *hp;
- struct servent *sp;
- struct in_addr **ipp;
- struct in_addr *ip[2];
- struct in_addr ina;
- u_short s_port;
- int any = 0;
- struct sockaddr_in sain;
-
- q = strchr(p, '/');
- if (q == 0 || q - p >= sizeof(host))
- return (EINVAL);
- *q = '\0';
- snprintf(host, sizeof(host), "%s", p);
- p = q + 1;
-
- q = strchr(p, '/');
- if (q)
- *q = '\0';
- if (strlen(p) >= sizeof(port))
- return (EINVAL);
- snprintf(port, sizeof(port), "%s", p);
-
- if (strcmp(host, "ANY") == 0) {
- any = 1;
- } else {
- hp = gethostbyname(host);
- if (hp != 0) {
- ipp = (struct in_addr **) hp->h_addr_list;
- } else {
- ina.s_addr = inet_addr(host);
- if (ina.s_addr == INADDR_NONE)
- return (EINVAL);
- ip[0] = &ina;
- ip[1] = 0;
- ipp = ip;
- }
- }
-#ifdef DEBUG
- if (any)
- printf("INADDR_ANY to be used for hostname\n");
- else
- printf("inet address for %s is %s\n", host, inet_ntoa(*ipp[0]));
-#endif
-
- sp = getservbyname(port, "tcp");
- if (sp != NULL) {
- s_port = (u_short) sp->s_port;
- } else {
- s_port = strtoul(port, &p, 0);
- if (*p != '\0')
- return (EINVAL);
- s_port = htons(s_port);
- }
- if ((ntohs(s_port) != 0) &&
- (ntohs(s_port) <= IPPORT_RESERVED) &&
- (pcr->pcr_uid != 0))
- return (EPERM);
-#ifdef DEBUG
- printf("port number for %s is %d\n", port, ntohs(s_port));
-#endif
-
- memset(&sain, 0, sizeof(sain));
- sain.sin_len = sizeof(sain);
- sain.sin_family = AF_INET;
- sain.sin_port = s_port;
-
- if (any) {
- int so;
- int sock;
-
- so = socket(AF_INET, SOCK_STREAM, 0);
- if (so < 0) {
- syslog(LOG_ERR, "socket: %m");
- return (errno);
- }
-
- sain.sin_addr.s_addr = INADDR_ANY;
- if (bind(so, (struct sockaddr *) &sain, sizeof(sain)) == 0) {
- listen(so, 1);
- if ((sock = accept(so, (struct sockaddr *)0, (int *)0)) == -1) {
- syslog(LOG_ERR, "accept: %m");
- (void) close(so);
- return (errno);
- }
- *fdp = sock;
- (void) close(so);
- return (0);
- }
- syslog(LOG_ERR, "bind: %m");
- (void) close(so);
- return (errno);
- }
-
- while (ipp[0]) {
- int so;
- int sock;
-
- so = socket(AF_INET, SOCK_STREAM, 0);
- if (so < 0) {
- syslog(LOG_ERR, "socket: %m");
- return (errno);
- }
-
- sain.sin_addr = *ipp[0];
- if (bind(so, (struct sockaddr *) &sain, sizeof(sain)) == 0) {
- listen(so, 1);
- if ((sock = accept(so, (struct sockaddr *)0, (int *)0)) == -1) {
- syslog(LOG_ERR, "accept: %m");
- (void) close(so);
- return (errno);
- }
- *fdp = sock;
- (void) close(so);
- return (0);
- }
- (void) close(so);
-
- ipp++;
- }
-
- syslog(LOG_ERR, "bind: %m");
- return (errno);
-
-}
diff --git a/sbin/mount_umapfs/Makefile b/sbin/mount_umapfs/Makefile
deleted file mode 100644
index 780b52cf7277..000000000000
--- a/sbin/mount_umapfs/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# @(#)Makefile 8.3 (Berkeley) 3/27/94
-
-PROG= mount_umap
-SRCS= mount_umap.c getmntopts.c
-MAN8= mount_umap.8
-
-MOUNT= ${.CURDIR}/../mount
-CFLAGS+= -I${.CURDIR}/../../sys -I${MOUNT}
-.PATH: ${MOUNT}
-
-.include <bsd.prog.mk>
diff --git a/sbin/mount_umapfs/mount_umapfs.8 b/sbin/mount_umapfs/mount_umapfs.8
deleted file mode 100644
index 4c6abfa3e438..000000000000
--- a/sbin/mount_umapfs/mount_umapfs.8
+++ /dev/null
@@ -1,140 +0,0 @@
-.\" Copyright (c) 1992, 1993, 1994
-.\" The Regents of the University of California. All rights reserved.
-.\" All rights reserved.
-.\"
-.\" This code is derived from software donated to Berkeley by
-.\" Jan-Simon Pendry and from John Heidemann of the UCLA Ficus project.
-.\"
-.\" 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 the University of
-.\" California, Berkeley and its contributors.
-.\" 4. 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.
-.\"
-.\" @(#)mount_umap.8 8.4 (Berkeley) 5/1/95
-.\" $FreeBSD$
-.\"
-.Dd May 1, 1995
-.Dt MOUNT_UMAP 8
-.Os BSD 4.4
-.Sh NAME
-.Nm mount_umap
-.Nd sample file system layer
-.Sh SYNOPSIS
-.Nm mount_umap
-.Op Fl o Ar options
-.Fl u Ar uid-mapfile
-.Fl g Ar gid-mapfile
-.Ar target
-.Ar mount-point
-.Sh DESCRIPTION
-The
-.Nm
-command is used to mount a sub-tree of an existing file system
-that uses a different set of uids and gids than the local system.
-Such a file system could be mounted from a remote site via NFS or
-it could be a file system on removable media brought from some
-foreign location that uses a different password file.
-.Pp
-The
-.Nm
-command uses a set of files provided by the user to make correspondences
-between uids and gids in the sub-tree's original environment and
-some other set of ids in the local environment. For instance, user
-smith might have uid 1000 in the original environment, while having
-uid 2000 in the local environment. The
-.Nm
-command allows the subtree from smith's original environment to be
-mapped in such a way that all files with owning uid 1000 look like
-they are actually owned by uid 2000.
-.Pp
-The options are as follows:
-.Bl -tag -width indent
-.It Fl o
-Options are specified with a
-.Fl o
-flag followed by a comma separated string of options.
-See the
-.Xr mount 8
-man page for possible options and their meanings.
-.It Ar target
-Should be the current location of the sub-tree in the
-local system's name space.
-.It Ar mount-point
-Should be a directory
-where the mapped subtree is to be placed.
-.It Fl u Ar uid-mapfile
-.It Fl g Ar gid-mapfile
-Describe the mappings to be made between identifiers.
-Briefly, the format of these files is a count of the number of
-mappings on the first line, with each subsequent line containing
-a single mapping. Each of these mappings consists of an id in
-the local environment and the corresponding id from the original environment,
-separated by white space.
-.Ar Uid-mapfile
-should contain all uid
-mappings, and
-.Ar gid-mapfile
-should contain all gid mappings.
-Any uids not mapped in
-.Ar uid-mapfile
-will be treated as user NOBODY,
-and any gids not mapped in
-.Ar gid-mapfile
-will be treated as group
-NULLGROUP. At most 64 uids can be mapped for a given subtree, and
-at most 16 groups can be mapped by a given subtree.
-.El
-.Pp
-The mapfiles can be located anywhere in the file hierarchy, but they
-must be owned by root, and they must be writable only by root.
-.Nm Mount_umap
-will refuse to map the sub-tree if the ownership or permissions on
-these files are improper. It will also balk if the count of mappings
-in the first line of the map files is not correct.
-.Pp
-The layer created by the
-.Nm
-command is meant to serve as a simple example of file system layering.
-It is not meant for production use. The implementation is not very
-sophisticated.
-.Sh SEE ALSO
-.Xr mount 8 ,
-.Xr mount_null 8
-.Sh BUGS
-
-THIS FILESYSTEM TYPE IS NOT YET FULLY SUPPORTED (READ: IT DOESN'T WORK)
-AND USING IT MAY, IN FACT, DESTROY DATA ON YOUR SYSTEM. USE AT YOUR
-OWN RISK. BEWARE OF DOG. SLIPPERY WHEN WET.
-
-This code also needs an owner in order to be less dangerous - serious
-hackers can apply by sending mail to hackers@freebsd.org and announcing
-their intent to take it over.
-
-.Sh HISTORY
-The
-.Nm
-utility first appeared in
-.Bx 4.4 .
diff --git a/sbin/mount_umapfs/mount_umapfs.c b/sbin/mount_umapfs/mount_umapfs.c
deleted file mode 100644
index 0aa7b8c075a3..000000000000
--- a/sbin/mount_umapfs/mount_umapfs.c
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Copyright (c) 1992, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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 lint
-static const char copyright[] =
-"@(#) Copyright (c) 1992, 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)mount_umap.c 8.5 (Berkeley) 4/26/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <sys/param.h>
-#include <sys/mount.h>
-#include <sys/stat.h>
-
-#include <miscfs/umapfs/umap.h>
-
-#include <err.h>
-#include <stdio.h>
-#include <string.h>
-#include <sysexits.h>
-#include <unistd.h>
-
-#include "mntopts.h"
-
-#define ROOTUSER 0
-/*
- * This define controls whether any user but the superuser can own and
- * write mapfiles. If other users can, system security can be gravely
- * compromised. If this is not a concern, undefine SECURITY.
- */
-#define MAPSECURITY 1
-
-/*
- * This routine provides the user interface to mounting a umap layer.
- * It takes 4 mandatory parameters. The mandatory arguments are the place
- * where the next lower level is mounted, the place where the umap layer is to
- * be mounted, the name of the user mapfile, and the name of the group
- * mapfile. The routine checks the ownerships and permissions on the
- * mapfiles, then opens and reads them. Then it calls mount(), which
- * will, in turn, call the umap version of mount.
- */
-
-static struct mntopt mopts[] = {
- MOPT_STDOPTS,
- { NULL }
-};
-
-static void usage __P((void)) __dead2;
-
-int
-main(argc, argv)
- int argc;
- char *argv[];
-{
- static char not[] = "; not mounted";
- struct stat statbuf;
- struct umap_args args;
- FILE *fp, *gfp;
- u_long gmapdata[GMAPFILEENTRIES][2], mapdata[MAPFILEENTRIES][2];
- int ch, count, gnentries, mntflags, nentries;
- char *gmapfile, *mapfile, buf[20];
- char source[MAXPATHLEN], target[MAXPATHLEN];
- struct vfsconf vfc;
- int error;
-
- mntflags = 0;
- mapfile = gmapfile = NULL;
- while ((ch = getopt(argc, argv, "g:o:u:")) != -1)
- switch (ch) {
- case 'g':
- gmapfile = optarg;
- break;
- case 'o':
- getmntopts(optarg, mopts, &mntflags, 0);
- break;
- case 'u':
- mapfile = optarg;
- break;
- case '?':
- default:
- usage();
- }
- argc -= optind;
- argv += optind;
-
- if (argc != 2 || mapfile == NULL || gmapfile == NULL)
- usage();
-
- /* resolve both target and source with realpath(3) */
- (void)checkpath(argv[0], source);
- (void)checkpath(argv[1], target);
-
- /* Read in uid mapping data. */
- if ((fp = fopen(mapfile, "r")) == NULL)
- err(EX_NOINPUT, "%s%s", mapfile, not);
-
-#ifdef MAPSECURITY
- /*
- * Check that group and other don't have write permissions on
- * this mapfile, and that the mapfile belongs to root.
- */
- if (fstat(fileno(fp), &statbuf))
- err(EX_OSERR, "%s%s", mapfile, not);
- if (statbuf.st_mode & S_IWGRP || statbuf.st_mode & S_IWOTH) {
- strmode(statbuf.st_mode, buf);
- err(EX_NOPERM, "%s: improper write permissions (%s)%s",
- mapfile, buf, not);
- }
- if (statbuf.st_uid != ROOTUSER)
- errx(EX_NOPERM, "%s does not belong to root%s", mapfile, not);
-#endif /* MAPSECURITY */
-
- if ((fscanf(fp, "%d\n", &nentries)) != 1)
- errx(EX_DATAERR, "%s: nentries not found%s", mapfile, not);
- if (nentries > MAPFILEENTRIES)
- errx(EX_DATAERR,
- "maximum number of entries is %d%s", MAPFILEENTRIES, not);
-#if 0
- (void)printf("reading %d entries\n", nentries);
-#endif
- for (count = 0; count < nentries; ++count) {
- if ((fscanf(fp, "%lu %lu\n",
- &(mapdata[count][0]), &(mapdata[count][1]))) != 2) {
- if (ferror(fp))
- err(EX_OSERR, "%s%s", mapfile, not);
- if (feof(fp))
- errx(EX_DATAERR, "%s: unexpected end-of-file%s",
- mapfile, not);
- errx(EX_DATAERR, "%s: illegal format (line %d)%s",
- mapfile, count + 2, not);
- }
-#if 0
- /* Fix a security hole. */
- if (mapdata[count][1] == 0)
- errx(1, "mapping id 0 not permitted (line %d)%s",
- count + 2, not);
-#endif
- }
-
- /* Read in gid mapping data. */
- if ((gfp = fopen(gmapfile, "r")) == NULL)
- err(EX_NOINPUT, "%s%s", gmapfile, not);
-
-#ifdef MAPSECURITY
- /*
- * Check that group and other don't have write permissions on
- * this group mapfile, and that the file belongs to root.
- */
- if (fstat(fileno(gfp), &statbuf))
- err(EX_OSERR, "%s%s", gmapfile, not);
- if (statbuf.st_mode & S_IWGRP || statbuf.st_mode & S_IWOTH) {
- strmode(statbuf.st_mode, buf);
- err(EX_NOPERM, "%s: improper write permissions (%s)%s",
- gmapfile, buf, not);
- }
- if (statbuf.st_uid != ROOTUSER)
- errx(EX_NOPERM, "%s does not belong to root%s", gmapfile, not);
-#endif /* MAPSECURITY */
-
- if ((fscanf(gfp, "%d\n", &gnentries)) != 1)
- errx(EX_DATAERR, "%s: nentries not found%s", gmapfile, not);
- if (gnentries > MAPFILEENTRIES)
- errx(EX_DATAERR,
- "maximum number of entries is %d%s", GMAPFILEENTRIES, not);
-#if 0
- (void)printf("reading %d group entries\n", gnentries);
-#endif
-
- for (count = 0; count < gnentries; ++count)
- if ((fscanf(gfp, "%lu %lu\n",
- &(gmapdata[count][0]), &(gmapdata[count][1]))) != 2) {
- if (ferror(gfp))
- err(EX_OSERR, "%s%s", gmapfile, not);
- if (feof(gfp))
- errx(EX_DATAERR, "%s: unexpected end-of-file%s",
- gmapfile, not);
- errx(EX_DATAERR, "%s: illegal format (line %d)%s",
- gmapfile, count + 2, not);
- }
-
-
- /* Setup mount call args. */
- args.target = source;
- args.nentries = nentries;
- args.mapdata = mapdata;
- args.gnentries = gnentries;
- args.gmapdata = gmapdata;
-
- error = getvfsbyname("umap", &vfc);
- if (error && vfsisloadable("umap")) {
- if(vfsload("umap"))
- err(1, "vfsload(umap)");
- endvfsent();
- error = getvfsbyname("umap", &vfc);
- }
- if (error)
- errx(1, "umap filesystem is not available");
-
- if (mount(vfc.vfc_name, argv[1], mntflags, &args))
- err(1, NULL);
- exit(0);
-}
-
-void
-usage()
-{
- (void)fprintf(stderr,
-"usage: mount_umap [-o options] -u usermap -g groupmap target_fs mount_point\n");
- exit(EX_USAGE);
-}
diff --git a/sbin/mount_umapfs/sample.group.mapfile b/sbin/mount_umapfs/sample.group.mapfile
deleted file mode 100644
index 69d3d77c6363..000000000000
--- a/sbin/mount_umapfs/sample.group.mapfile
+++ /dev/null
@@ -1,2 +0,0 @@
-1
-1200 1200
diff --git a/sbin/mount_umapfs/sample.user.mapfile b/sbin/mount_umapfs/sample.user.mapfile
deleted file mode 100644
index 03c59e9e7569..000000000000
--- a/sbin/mount_umapfs/sample.user.mapfile
+++ /dev/null
@@ -1,3 +0,0 @@
-2
-5217 5217
-3 3
diff --git a/sbin/mount_umapfs/umap_manual b/sbin/mount_umapfs/umap_manual
deleted file mode 100644
index 50a8ce55700b..000000000000
--- a/sbin/mount_umapfs/umap_manual
+++ /dev/null
@@ -1,175 +0,0 @@
-
-\appendix
-\section{The umap Layer} \label{sect:umap}
-
-\subsection{Introduction}
-
-Normally, the file system is expected to span a single administrative domain.
-An administrative domain, for these purposes, is a machine or set of
-machines that share common password file information, usually through
-the yellow pages mechanism. File hierarchies that span more
-than one domain leads to certain problems, since the same numerical
-UID in one domain may correspond to a different user in another domain.
-If the system administrator is very careful to ensure that both domains
-contain identical user ID information, the umap layer can be used to
-run between those domains without changes
-
-The umap layer is a file system layer that sits on top of the normal
-file layer. The umap layer maps Unix-style UIDs from
-one domain into the UIDs in the other domain. By setting up the mappings
-properly, the same user with different UIDs in two domains can be seen
-as the same user, from the system point of view, or, conversely, two
-different users with the same UID in the two domains can be distinguished.
-
-First, we define some terms. ``User'' refers to the human (or daemon) that
-has privileges to login, run programs, and access files. ``UID''refers to
-the numerical identifier that uniquely identifies the user within a
-single domain. ``Login name'' refers to the character string the user
-types to log into the system. ``GID'' refers to the numerical group
-identifier used by Unix systems to identify groups of users. ``Group
-name'' is the character string name attached to a particular GID in the
-local {\sf /etc/groups} file or the yellow pages groups file.
-
-In order for the umap layer to work properly, all users
-in either domain must have password file entries in both domains.
-They do not, however, have to have the same numerical UID, nor even the
-same character string login name (the latter is highly recommended,
-if possible, however). Any user not having a UID in one domain will be
-treated as the special user NOBODY by the other domain, probably with
-undesirable consequences. Any user not owning any files in the shared
-sub-trees need not be given a UID in the other domain.
-
-Groups work similarly. The umap layer can translate group ID's between
-domains in the same manner as UID's. Again, any group that wishes to
-participate must have a group ID in both domains,
-though it need not be the same GID in both. If a group in one domain is not
-known in the other domain, that group will be treated as being NULLGROUP.
-The umap layer has no provisions for enrolling UID's from other domains
-as group members, but, since each user from each domain must have some
-UID in every domain, the UID in the local domain can be used to enroll
-the user in the local groups.
-
-NOBODY and NULLGROUP are special reserved UID's and GID's, respectively.
-NOBODY is user 32767. NULLGROUP is group 65534. If the system administrator
-wants to have an appropriate text string appear when these UID's are
-encountered by programs like {\sf ls -l}, he should add these values to
-the password and {\sf /etc/groups} file, or to the appropriate yellow pages.
-If these IDs are already in use in that domain, different values can be
-used for NOBODY and NULLGROUP, but that will require a recompilation of
-the umap layer code and, as a result, the entire kernel. These
-values are defined in the {\sf umap\_info.h} file, kept with the rest of the
-umap source code.
-
-When the umap layer is in use, one of the participating domains is declared
-to be the master. All UID and GID information stored for participating files
-will be stored in vnodes using its mappings, no matter what site the copies of
-the files are stored at. The master domain therefore need not run a copy
-of the umap layer, as it already has all of the correct mappings. All
-other domains must run a umap layer on top of any other layers they use.
-
-\subsection{Setting Up a umap Layer}
-
-The system administrator of a system needing to use the umap layer
-must take several actions.
-First, he must create files containing the necessary UID
-and GID mappings. There is a separate file for user and group IDs. The
-format of the files is the same. The first line contains the total number
-of entries in the file. Each subsequent line contains one mapping. A
-mapping line consists of two numerical UIDs, separated by white space.
-The first is the UID of a user on the local machine. The second is the
-UID for the same user on the master machine. The maximum number of users
-that can be mapped for a single shared sub-tree is 64. The maximum number of
-groups that can be mapped for a single sub-tree is 16. These constants
-are set in the {\sf umap\_info.h} file, and can be changed, but changing them
-requires recompilation. Separate mapping files can be used for each shared
-subtree, or the same mapping files can be shared by several sub-trees.
-
-Below is a sample UID mapping file. There are four entries. UID 5 is mapped
-to 5, 521 to 521, and 7000 to 7000. UID 2002 is mapped to 604. On this
-machine, the UID's for users 5, 521, and 7000 are the same as on the master,
-but UID 2002 is for a user whose UID on the master machine is 604. All
-files in the sub-tree belonging to that user have UID 604 in their inodes,
-even on this machine, but the umap layer will ensure that anyone running
-under UID 2002 will have all files in this sub-tree owned by 604 treated as if
-they were owned by 2002. An {\sf ls -l} on a file owned by 604 in this sub-tree
-will show the login name associated with UID 2002 as the owner.
-
-\noindent4\newline
-5 5\newline
-521 521\newline
-2002 604\newline
-7000 7000\newline
-
-The user and group mapping files should be owned by the root user, and
-should be writable only by that user. If they are not owned by root, or
-are writable by some other user, the umap mounting command will abort.
-
-Normally, the sub-tree is grafted directly into the place in
-the file hierarchy where the it should appear to users. Using the umap
-layer requires that the sub-tree be grafted somewhere else, and
-the umap layer be mounted in the desired position in the file hierarchy.
-Depending on the situation, the underlying sub-tree can be wherever is
-convenient.
-
-\subsection{Troubleshooting umap Layer Problems}
-
-The umap layer code was not built with special convenience or
-robustness in mind, as it is expected to be superseded with a better
-user ID mapping strategy in the near future. As a result, it is not
-very forgiving of errors in being set up. Here are some possible
-problems, and what to do about them.
-
-\begin{itemize}
-
-
-\item{Problem: A file belongs to NOBODY, or group NULLGROUP.
-
-Fixes: The mapping files don't know about this file's real user or group.
-Either they are not in the mapping files, or the counts on the number of
-entries in the mapping files are too low, so entries at the end (including
-these) are being ignored. Add the entries or fix the counts, and either
-unmount and remount the sub-tree, or reboot.}
-
-\item{Problem: A normal operation does not work.
-
-Fixes: Possibly, some mapping has not been set properly. Check to
-see which files are used by the operation and who they appear to be
-owned by. If they are owned by NOBODY or some other suspicious user,
-there may be a problem in the mapping files. Be sure to check groups,
-too. As above, if the counts of mappings in the mapping files are lower
-than the actual numbers of pairs, pairs at the end of the file will be
-ignored. If any changes are made in the mapping files, you will need to
-either unmount and remount or reboot before they will take effect.
-
-Another possible problem can arise because not all Unix utilities
-rely exclusively on numeric UID for identification. For instance,
-SCCS saves the login name in files. If a user's login name on two machines
-isn't the same, SCCS may veto an operation even though Unix file permissions,
-as checked by the umap layer, may say it's OK. There's not much to be
-done in such cases, unless the login name can be changed or one fiddles
-improperly with SCCS information. There may be other, undiscovered cases
-where similar problems arise, some of which may be even harder to handle.}
-
-\item{Problem: Someone has access permissions he should not have.
-
-Fixes: This is probably caused by a mistake in the mapping files. Check
-both user and group mapping files. If any changes are made in the mapping
-files, you will need to unmount and remount the sub-tree or reboot before they
-will take effect.}
-
-\item{Problem: {\sf ls -l} (or a similar program) shows the wrong user for a file.
-
-Fixes: Probably a mistake in the mapping files. In particular, if
-two local UIDs are mapped to a single master UID, stat calls will assign
-ownership to the first local UID occurring in the file, which may or may
-not be what was intended. (Generally speaking, mapping two local UIDs to
-a single master UID is a bad idea, but the software will not prevent it.
-Similarly, mapping a single local UID to two master UIDs is a bad idea,
-but will not be prevented. In this case, only the first mapping of the
-local UID will be done. The second, and all subsequent ones, will be
-ignored.) If any changes are made in the mapping files, you will need to
-unmount and remount the sub-tree or reboot before they will take effect.}
-
-\end{itemize}
-
-\end{document}
diff --git a/sbin/mount_unionfs/Makefile b/sbin/mount_unionfs/Makefile
deleted file mode 100644
index e213137f1686..000000000000
--- a/sbin/mount_unionfs/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# @(#)Makefile 8.3 (Berkeley) 3/27/94
-
-PROG= mount_union
-SRCS= mount_union.c getmntopts.c
-MAN8= mount_union.8
-
-MOUNT= ${.CURDIR}/../mount
-CFLAGS+= -I${.CURDIR}/../../sys -I${MOUNT}
-.PATH: ${MOUNT}
-
-.include <bsd.prog.mk>
diff --git a/sbin/mount_unionfs/mount_unionfs.8 b/sbin/mount_unionfs/mount_unionfs.8
deleted file mode 100644
index 08a48044cdce..000000000000
--- a/sbin/mount_unionfs/mount_unionfs.8
+++ /dev/null
@@ -1,212 +0,0 @@
-.\" Copyright (c) 1994
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" This code is derived from software donated to Berkeley by
-.\" Jan-Simon Pendry.
-.\"
-.\" 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 the University of
-.\" California, Berkeley and its contributors.
-.\" 4. 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.
-.\"
-.\" @(#)mount_union.8 8.6 (Berkeley) 3/27/94
-.\" $FreeBSD$
-.\"
-.Dd March 27, 1994
-.Dt MOUNT_UNION 8
-.Os BSD 4.4
-.Sh NAME
-.Nm mount_union
-.Nd mount union filesystems
-.Sh SYNOPSIS
-.Nm mount_union
-.Op Fl br
-.Op Fl o Ar options
-.Ar directory
-.Ar uniondir
-.Sh DESCRIPTION
-The
-.Nm
-command
-attaches
-.Ar directory
-above
-.Ar uniondir
-in such a way that the contents of both directory trees remain visible.
-By default,
-.Ar directory
-becomes the
-.Em upper
-layer and
-.Ar uniondir
-becomes the
-.Em lower
-layer.
-.Pp
-The options are as follows:
-.Bl -tag -width indent
-.It Fl b
-Invert the default position, so that
-.Ar directory
-becomes the lower layer and
-.Ar uniondir
-becomes the upper layer.
-However,
-.Ar uniondir
-remains the mount point.
-.It Fl o
-Options are specified with a
-.Fl o
-flag followed by a comma separated string of options.
-See the
-.Xr mount 8
-man page for possible options and their meanings.
-.It Fl r
-Hide the lower layer completely in the same way as mounting with
-.Xr mount_null 8 .
-.El
-.Pp
-To enforce filesystem security, the user mounting the filesystem
-must be superuser or else have write permission on the mounted-on
-directory.
-.Pp
-Filenames are looked up in the upper layer and then in the
-lower layer.
-If a directory is found in the lower layer, and there is no entry
-in the upper layer, then a
-.Em shadow
-directory will be created in the upper layer.
-It will be owned by the user who originally did the union mount,
-with mode
-.Dq rwxrwxrwx
-(0777) modified by the umask in effect at that time.
-.Pp
-If a file exists in the upper layer then there is no way to access
-a file with the same name in the lower layer.
-If necessary, a combination of loopback and union mounts can be made
-which will still allow the lower files to be accessed by a different
-pathname.
-.Pp
-Except in the case of a directory,
-access to an object is granted via the normal filesystem access checks.
-For directories, the current user must have access to both the upper
-and lower directories (should they both exist).
-.Pp
-Requests to create or modify objects in
-.Ar uniondir
-are passed to the upper layer with the exception of a few special cases.
-An attempt to open for writing a file which exists in the lower layer
-causes a copy of the
-.Em entire
-file to be made to the upper layer, and then for the upper layer copy
-to be opened.
-Similarly, an attempt to truncate a lower layer file to zero length
-causes an empty file to be created in the upper layer.
-Any other operation which would ultimately require modification to
-the lower layer fails with
-.Dv EROFS .
-.Pp
-The union filesystem manipulates the namespace, rather than
-individual filesystems.
-The union operation applies recursively down the directory tree
-now rooted at
-.Ar uniondir .
-Thus any filesystems which are mounted under
-.Ar uniondir
-will take part in the union operation.
-This differs from the
-.Em union
-option to
-.Xr mount 8
-which only applies the union operation to the mount point itself,
-and then only for lookups.
-.Sh EXAMPLES
-The commands
-.Bd -literal -offset indent
-mount -t cd9660 -o ro /dev/cd0a /usr/src
-mount -t union /var/obj /usr/src
-.Ed
-.Pp
-mount the CD-ROM drive
-.Pa /dev/cd0a
-on
-.Pa /usr/src
-and then attaches
-.Pa /var/obj
-on top.
-For most purposes the effect of this is to make the
-source tree appear writable
-even though it is stored on a CD-ROM.
-.Pp
-The command
-.Bd -literal -offset indent
-mount -t union -o -b /sys $HOME/sys
-.Ed
-.Pp
-attaches the system source tree below the
-.Pa sys
-directory in the user's home directory.
-This allows individual users to make private changes
-to the source, and build new kernels, without those
-changes becoming visible to other users.
-Note that the files in the lower layer remain
-accessible via
-.Pa /sys .
-.Sh SEE ALSO
-.Xr intro 2 ,
-.Xr mount 2 ,
-.Xr unmount 2 ,
-.Xr fstab 5 ,
-.Xr mount 8 ,
-.Xr mount_null 8
-.Sh BUGS
-
-THIS FILESYSTEM TYPE IS NOT YET FULLY SUPPORTED (READ: IT DOESN'T WORK)
-AND USING IT MAY, IN FACT, DESTROY DATA ON YOUR SYSTEM. USE AT YOUR
-OWN RISK. BEWARE OF DOG. SLIPPERY WHEN WET.
-
-This code also needs an owner in order to be less dangerous - serious
-hackers can apply by sending mail to hackers@freebsd.org and announcing
-their intent to take it over.
-
-Without whiteout support from the filesystem backing the upper layer,
-there is no way that delete and rename operations on lower layer
-objects can be done.
-.Dv EROFS
-is returned for this kind of operations along with any others
-which would make modifications to the lower layer, such as
-.Xr chmod 1 .
-.Pp
-Running
-.Xr find 1
-over a union tree has the side-effect of creating
-a tree of shadow directories in the upper layer.
-.Sh HISTORY
-The
-.Nm
-command first appeared in
-.Bx 4.4 .
-It first worked in FreeBSD-(fill this in).
diff --git a/sbin/mount_unionfs/mount_unionfs.c b/sbin/mount_unionfs/mount_unionfs.c
deleted file mode 100644
index 1d5d3ebc504c..000000000000
--- a/sbin/mount_unionfs/mount_unionfs.c
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright (c) 1992, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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 lint
-static const char copyright[] =
-"@(#) Copyright (c) 1992, 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)mount_union.c 8.5 (Berkeley) 3/27/94";
-#else
-static const char rcsid[] =
- "$FreeBSD$";
-#endif
-#endif /* not lint */
-
-#include <sys/param.h>
-#include <sys/mount.h>
-
-#include <miscfs/union/union.h>
-
-#include <err.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sysexits.h>
-#include <unistd.h>
-
-#include "mntopts.h"
-
-static struct mntopt mopts[] = {
- MOPT_STDOPTS,
- { NULL }
-};
-
-static int subdir __P((const char *, const char *));
-static void usage __P((void)) __dead2;
-
-int
-main(argc, argv)
- int argc;
- char *argv[];
-{
- struct union_args args;
- int ch, mntflags;
- char source[MAXPATHLEN];
- char target[MAXPATHLEN];
- struct vfsconf vfc;
- int error;
-
- mntflags = 0;
- args.mntflags = UNMNT_ABOVE;
- while ((ch = getopt(argc, argv, "bo:r")) != -1)
- switch (ch) {
- case 'b':
- args.mntflags &= ~UNMNT_OPMASK;
- args.mntflags |= UNMNT_BELOW;
- break;
- case 'o':
- getmntopts(optarg, mopts, &mntflags, 0);
- break;
- case 'r':
- args.mntflags &= ~UNMNT_OPMASK;
- args.mntflags |= UNMNT_REPLACE;
- break;
- case '?':
- default:
- usage();
- /* NOTREACHED */
- }
- argc -= optind;
- argv += optind;
-
- if (argc != 2)
- usage();
-
- /* resolve both target and source with realpath(3) */
- (void)checkpath(argv[0], target);
- (void)checkpath(argv[1], source);
-
- if (subdir(target, source) || subdir(source, target))
- errx(EX_USAGE, "%s (%s) and %s (%s) are not distinct paths",
- argv[0], target, argv[1], source);
-
- args.target = target;
-
- error = getvfsbyname("union", &vfc);
- if (error && vfsisloadable("union")) {
- if (vfsload("union"))
- err(EX_OSERR, "vfsload(union)");
- endvfsent(); /* flush cache */
- error = getvfsbyname("union", &vfc);
- }
- if (error)
- errx(EX_OSERR, "union filesystem is not available");
-
- if (mount(vfc.vfc_name, source, mntflags, &args))
- err(EX_OSERR, "%s", target);
- exit(0);
-}
-
-int
-subdir(p, dir)
- const char *p;
- const char *dir;
-{
- int l;
-
- l = strlen(dir);
- if (l <= 1)
- return (1);
-
- if ((strncmp(p, dir, l) == 0) && (p[l] == '/' || p[l] == '\0'))
- return (1);
-
- return (0);
-}
-
-void
-usage()
-{
- (void)fprintf(stderr,
- "usage: mount_union [-br] [-o options] target_fs mount_point\n");
- exit(EX_USAGE);
-}
diff --git a/sbin/nextboot/Makefile b/sbin/nextboot/Makefile
deleted file mode 100644
index 7ac235fae497..000000000000
--- a/sbin/nextboot/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-# @(#)Makefile 1.1 (Julian Elischer) 3/28/93
-#
-#
-
-PROG= nextboot
-SRCS= nextboot.c
-MAN8= nextboot.8
-
-.include <bsd.prog.mk>
diff --git a/sbin/nextboot/nextboot.8 b/sbin/nextboot/nextboot.8
deleted file mode 100644
index bd7348158d60..000000000000
--- a/sbin/nextboot/nextboot.8
+++ /dev/null
@@ -1,115 +0,0 @@
-.\" $FreeBSD$
-.Dd July 9, 1996
-.Dt NEXTBOOT 8
-.\".Os BSD 4
-.Sh NAME
-.Nm nextboot
-.Nd install a default bootstring block on the boot disk
-.Sh SYNOPSIS
-.Nm nextboot
-.Op Fl b
-.Ar filename bootstring
-.Ar
-.Nm nextboot
-.Op Fl ed
-.Ar filename
-.Sh DESCRIPTION
-The
-.Bx Free
-program
-.Nm
-controls the actions of the boot blocks at the time of the next boot.
-If compiled with the correct option,
-the boot blocks will check the nameblock for a magic number and a
-default name to use for booting.
-If compiled to do so they will also
-delete the name from the block, ensuring that if the boot should fail,
-then it will not be tried again.
-It is the job of
-.Pa /etc/rc
-to use
-.Nm
-to re-install the string if that boot is found to have succeeded.
-This allows a one-time only boot string to be used for such applications
-as remote debugging, and installation of new, untrusted kernels.
-The nameblock is defined at compile time to be the second physical block
-on the disk.
-.Pp
-The following options are available:
-.Bl -tag -width indent
-.It Fl b
-Is used for bootstrapping (initially configuring) the nameblock.
-Without
-this,
-.Nm
-will refuse to write to a block that does not already contain the magic
-number.
-.It Fl d
-Disable (temporarily) an existing name block by changing a bit
-in the magic number.
-.It Fl e
-Restore the good magic number on a block disabled by
-.Fl d .
-.El
-.Pp
-The
-.Fl e
-and
-.Fl d
-flags are mutually exclusive.
-.Sh DESCRIPTION
-.Nm Nextboot
-first checks that the disk has an fdisk table and checks that none of the
-partitions defined in that table include the nameblock.
-If the name block is
-shown to be unused, it will install the bootstrings given as arguments,
-one after the other, each preceded by a small magic number, and NULL
-terminated.
-The end of the list of strings is delimited by a sequence of
-0xff bytes.
-If the boot blocks are compiled to write back the nameblock
-after each boot, it will zero out the supplied names as it uses them,
-one per boot,
-until it reaches the 0xff, at which time it will revert to the compiled in
-boot string.
-At this time the nameblock will contain only zeroed out names.
-.Pp
-An example of usage might be:
-.Bd -literal
- nextboot -b /dev/rwd0 1:sd(0,a)/kernel.experimental wd(0,a)/kernel.old
-.Ed
-.Pp
-Which would instruct the boot blocks at the next boot,
-to try boot the experimental kernel off the SCSI disk.
-If for any reason this failed, the next boot attempt would
-boot the kernel
-.Pa /kernel.old
-off the IDE drive. (Assuming the write-back option were enabled) If this
-in turn failed.
-The compiled in default would be used.
-.Pp
-If the write-back feature is disabled, the nextboot program is a convenient way
-to change the default boot string.
-Note, that should the file specified in
-the nameblock be non-existent, then the name compiled into the boot blocks
-will be used for the boot rather than the next name in the nameblock.
-The
-nameblock is only consulted
-.Em once
-per boot.
-.Sh SEE ALSO
-.Xr boot 8 ,
-.Xr disklabel 8 ,
-.Xr fdisk 8
-.Sh BUGS
-This program works only in conjunction with the legacy boot code.
-.Pp
-The entire program should be made more user-friendly.
-The option of whether to write back or not should be stored on the
-disk and not a compile time option.
-I want to rethink this at some
-later stage to make it co-exist with disks that do not have
-a fdisk partitioning table (i.e. purely disklabel'd systems).
-.Pp
-Whether to write back or not should be specified at run-time in the nameblock
-so that the boot blocks need not be altered to get this feature.
diff --git a/sbin/nextboot/nextboot.c b/sbin/nextboot/nextboot.c
deleted file mode 100644
index 5893ca38a8a8..000000000000
--- a/sbin/nextboot/nextboot.c
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * Copyright (c) 1996 Whistle Communications
- * 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.
- *
- * Whistle Communications allows free use of this software in its "as is"
- * condition. Whistle Communications disclaims any liability of any kind for
- * any damages whatsoever resulting from the use of this software.
- */
-
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <sys/types.h>
-#include <sys/disklabel.h>
-#include <fcntl.h>
-#include <err.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-
-struct mboot
-{
- unsigned char padding[2]; /* force the longs to be long aligned */
- unsigned char bootinst[DOSPARTOFF];
- struct dos_partition parts[4];
- unsigned short int signature;
-};
-struct mboot mboot;
-
-#define NAMEBLOCK 1 /* 2nd block */
-#define BLOCKSIZE 512
-#define ENABLE_MAGIC 0xfadefeed
-#define DISABLE_MAGIC 0xfadefade
-static int bflag;
-static int eflag;
-static int dflag;
-
-#define BOOT_MAGIC 0xAA55
-
-static void
-usage(void) {
- fprintf (stderr, "%s\n%s\n",
- "usage: nextboot [-b] device bootstring [bootstring] ...",
- " nextboot {-e,-d} device");
- exit(1);
-}
-
-int
-main (int argc, char** argv)
-{
- int fd = -1;
- char namebuf[1024], *cp = namebuf;
- int i,j;
- int ch;
- int part;
-
- bflag = 0;
- while ((ch = getopt(argc, argv, "bde")) != -1) {
- switch(ch) {
- case 'b':
- bflag = 1;
- break;
- case 'd':
- dflag = 1;
- break;
- case 'e':
- eflag = 1;
- break;
- case '?':
- default:
- usage();
- }
- }
- argc -= optind;
- argv += optind;
-
- if ( (dflag + eflag + bflag) > 1 ) {
- usage();
- }
- if (dflag + eflag){
- if(argc != 1 ) {
- usage();
- }
- } else {
- if (argc <2) {
- usage();
- }
- }
- if ((fd = open(argv[0], O_RDWR, 0)) < 0)
- errx(1, "can't open %s", argv[0]);
-
- argc--;
- argv++;
-
- /*******************************************
- * Check that we have an MBR
- */
- if (lseek(fd,0,0) == -1)
- err(1, "lseek");
- if (read (fd,&mboot.bootinst[0],BLOCKSIZE ) != BLOCKSIZE)
- err(1, "read0");
- if (mboot.signature != (unsigned short)BOOT_MAGIC)
- errx(1, "no fdisk part.. not touching block 1");
-
- /*******************************************
- * And check that none of the partitions in it cover the name block;
- */
- for ( part = 0; part < 4; part++) {
- if( mboot.parts[part].dp_size
- && (mboot.parts[part].dp_start <= NAMEBLOCK)
- && (mboot.parts[part].dp_start
- + mboot.parts[part].dp_size > NAMEBLOCK))
- errx(1,
- "name sector lies within a Bios partition: aborting write");
- }
-
-
- /*******************************************
- * Now check the name sector itself to see if it's been initialized.
- */
- if (lseek(fd,NAMEBLOCK * BLOCKSIZE,0) == -1)
- err(1, "lseek");
- if (read(fd,namebuf,BLOCKSIZE) != BLOCKSIZE)
- err(1, "read1");
- /*******************************************
- * check if we are just enabling or disabling
- * Remember the flags are exclusive..
- */
- if(!bflag) { /* don't care what's there if bflag is set */
- switch(*(unsigned long *)cp)
- {
- case DISABLE_MAGIC:
- case ENABLE_MAGIC:
- break;
- default:
- errx(1, "namesector not initialized, use the -b flag");
- }
- }
-
-
- /*******************************************
- * If the z or r flag is set, damage or restore the magic number..
- * to disable/enable the feature
- */
- if(dflag) {
- *(unsigned long *)cp = DISABLE_MAGIC;
- } else {
- *(unsigned long *)cp = ENABLE_MAGIC;
- }
- if ((!dflag) && (!eflag)) {
- /*******************************************
- * Create a new namesector in ram
- */
- cp += 4;
- for ( i = 0 ; i < argc ; i++ ) {
- *cp++ = 'D';
- *cp++ = 'N';
- j = strlen(argv[i]);
- strncpy(cp,argv[i],j);
- cp += j;
- *cp++ = 0;
- }
- *cp++ = 0xff;
- *cp++ = 0xff;
- *cp++ = 0xff;
- namebuf[BLOCKSIZE-1] = 0; /* paranoid */
- namebuf[BLOCKSIZE] = 0xff;
- }
-
- /*******************************************
- * write it to disk.
- */
- if (lseek(fd,NAMEBLOCK * BLOCKSIZE,0) == -1)
- err(1, "lseek");
- if(write (fd,namebuf,BLOCKSIZE ) != BLOCKSIZE)
- err(1, "write");
-
-#if 0
- /*******************************************
- * just to be safe/paranoid.. read it back..
- * and print it..
- */
- if (lseek(fd,NAMEBLOCK * BLOCKSIZE,0) == -1)
- err(1, "lseek (second)");
- read (fd,namebuf,512);
- for (i = 0;i< 16;i++) {
- for ( j = 0; j < 16; j++) {
- printf("%02x ",(unsigned char )namebuf[(i*16) + j ]);
- }
- printf("\n");
- }
-#endif
- exit(0);
-}
diff --git a/sbin/quotacheck/preen.c b/sbin/quotacheck/preen.c
deleted file mode 100644
index e43aada8d10d..000000000000
--- a/sbin/quotacheck/preen.c
+++ /dev/null
@@ -1,332 +0,0 @@
-/*
- * 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-#if 0
-static const char sccsid[] = "@(#)preen.c 8.5 (Berkeley) 4/28/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-
-#include <ufs/ufs/dinode.h>
-
-#include <ctype.h>
-#include <errno.h>
-#include <fstab.h>
-#include <string.h>
-
-#include "fsck.h"
-
-struct part {
- struct part *next; /* forward link of partitions on disk */
- char *name; /* device name */
- char *fsname; /* mounted filesystem name */
- long auxdata; /* auxillary data for application */
-} *badlist, **badnext = &badlist;
-
-struct disk {
- char *name; /* disk base name */
- struct disk *next; /* forward link for list of disks */
- struct part *part; /* head of list of partitions on disk */
- int pid; /* If != 0, pid of proc working on */
-} *disks;
-
-int nrun, ndisks;
-
-static void addpart __P((char *name, char *fsname, long auxdata));
-static struct disk *finddisk __P((char *name));
-static int startdisk __P((struct disk *dk,
- int (*checkit)(char *, char *, long, int)));
-
-int
-checkfstab(preen, maxrun, docheck, chkit)
- int preen;
- int maxrun;
- int (*docheck)(struct fstab *);
- int (*chkit)(char *, char *, long, int);
-{
- register struct fstab *fsp;
- register struct disk *dk, *nextdisk;
- register struct part *pt;
- int ret, pid, retcode, passno, sumstatus, status;
- long auxdata;
- char *name;
-
- sumstatus = 0;
- for (passno = 1; passno <= 2; passno++) {
- if (setfsent() == 0) {
- fprintf(stderr, "Can't open checklist file: %s\n",
- _PATH_FSTAB);
- return (8);
- }
- while ((fsp = getfsent()) != 0) {
- if ((auxdata = (*docheck)(fsp)) == 0)
- continue;
- if (preen == 0 ||
- (passno == 1 && fsp->fs_passno == 1)) {
- if ((name = blockcheck(fsp->fs_spec)) != 0) {
- if ((sumstatus = (*chkit)(name,
- fsp->fs_file, auxdata, 0)) != 0)
- return (sumstatus);
- } else if (preen)
- return (8);
- } else if (passno == 2 && fsp->fs_passno > 1) {
- if ((name = blockcheck(fsp->fs_spec)) == NULL) {
- fprintf(stderr, "BAD DISK NAME %s\n",
- fsp->fs_spec);
- sumstatus |= 8;
- continue;
- }
- addpart(name, fsp->fs_file, auxdata);
- }
- }
- if (preen == 0)
- return (0);
- }
- if (preen) {
- if (maxrun == 0)
- maxrun = ndisks;
- if (maxrun > ndisks)
- maxrun = ndisks;
- nextdisk = disks;
- for (passno = 0; passno < maxrun; ++passno) {
- while ((ret = startdisk(nextdisk, chkit)) && nrun > 0)
- sleep(10);
- if (ret)
- return (ret);
- nextdisk = nextdisk->next;
- }
- while ((pid = wait(&status)) != -1) {
- for (dk = disks; dk; dk = dk->next)
- if (dk->pid == pid)
- break;
- if (dk == 0) {
- printf("Unknown pid %d\n", pid);
- continue;
- }
- if (WIFEXITED(status))
- retcode = WEXITSTATUS(status);
- else
- retcode = 0;
- if (WIFSIGNALED(status)) {
- printf("%s (%s): EXITED WITH SIGNAL %d\n",
- dk->part->name, dk->part->fsname,
- WTERMSIG(status));
- retcode = 8;
- }
- if (retcode != 0) {
- sumstatus |= retcode;
- *badnext = dk->part;
- badnext = &dk->part->next;
- dk->part = dk->part->next;
- *badnext = NULL;
- } else
- dk->part = dk->part->next;
- dk->pid = 0;
- nrun--;
- if (dk->part == NULL)
- ndisks--;
-
- if (nextdisk == NULL) {
- if (dk->part) {
- while ((ret = startdisk(dk, chkit)) &&
- nrun > 0)
- sleep(10);
- if (ret)
- return (ret);
- }
- } else if (nrun < maxrun && nrun < ndisks) {
- for ( ;; ) {
- if ((nextdisk = nextdisk->next) == NULL)
- nextdisk = disks;
- if (nextdisk->part != NULL &&
- nextdisk->pid == 0)
- break;
- }
- while ((ret = startdisk(nextdisk, chkit)) &&
- nrun > 0)
- sleep(10);
- if (ret)
- return (ret);
- }
- }
- }
- if (sumstatus) {
- if (badlist == 0)
- return (sumstatus);
- fprintf(stderr, "THE FOLLOWING FILE SYSTEM%s HAD AN %s\n\t",
- badlist->next ? "S" : "", "UNEXPECTED INCONSISTENCY:");
- for (pt = badlist; pt; pt = pt->next)
- fprintf(stderr, "%s (%s)%s", pt->name, pt->fsname,
- pt->next ? ", " : "\n");
- return (sumstatus);
- }
- (void)endfsent();
- return (0);
-}
-
-static struct disk *
-finddisk(name)
- char *name;
-{
- register struct disk *dk, **dkp;
- register char *p;
- size_t len;
-
- p = strrchr(name, '/');
- p = p == NULL ? name : p + 1;
- while (*p != '\0' && !isdigit((u_char)*p))
- p++;
- while (isdigit((u_char)*p))
- p++;
- len = (size_t)(p - name);
- for (dk = disks, dkp = &disks; dk; dkp = &dk->next, dk = dk->next) {
- if (strncmp(dk->name, name, len) == 0 &&
- dk->name[len] == 0)
- return (dk);
- }
- if ((*dkp = (struct disk *)malloc(sizeof(struct disk))) == NULL) {
- fprintf(stderr, "out of memory");
- exit (8);
- }
- dk = *dkp;
- if ((dk->name = malloc(len + 1)) == NULL) {
- fprintf(stderr, "out of memory");
- exit (8);
- }
- (void)strncpy(dk->name, name, len);
- dk->name[len] = '\0';
- dk->part = NULL;
- dk->next = NULL;
- dk->pid = 0;
- ndisks++;
- return (dk);
-}
-
-static void
-addpart(name, fsname, auxdata)
- char *name, *fsname;
- long auxdata;
-{
- struct disk *dk = finddisk(name);
- register struct part *pt, **ppt = &dk->part;
-
- for (pt = dk->part; pt; ppt = &pt->next, pt = pt->next)
- if (strcmp(pt->name, name) == 0) {
- printf("%s in fstab more than once!\n", name);
- return;
- }
- if ((*ppt = (struct part *)malloc(sizeof(struct part))) == NULL) {
- fprintf(stderr, "out of memory");
- exit (8);
- }
- pt = *ppt;
- if ((pt->name = malloc(strlen(name) + 1)) == NULL) {
- fprintf(stderr, "out of memory");
- exit (8);
- }
- (void)strcpy(pt->name, name);
- if ((pt->fsname = malloc(strlen(fsname) + 1)) == NULL) {
- fprintf(stderr, "out of memory");
- exit (8);
- }
- (void)strcpy(pt->fsname, fsname);
- pt->next = NULL;
- pt->auxdata = auxdata;
-}
-
-static int
-startdisk(dk, checkit)
- register struct disk *dk;
- int (*checkit)(char *, char *, long, int);
-{
- register struct part *pt = dk->part;
-
- dk->pid = fork();
- if (dk->pid < 0) {
- perror("fork");
- return (8);
- }
- if (dk->pid == 0)
- exit((*checkit)(pt->name, pt->fsname, pt->auxdata, 1));
- nrun++;
- return (0);
-}
-
-char *
-blockcheck(origname)
- char *origname;
-{
- struct stat stslash, stblock, stchar;
- char *newname, *raw;
- struct fstab *fsinfo;
- int retried = 0, len;
-
- newname = origname;
-retry:
- if (stat(newname, &stblock) < 0) {
- printf("Can't stat %s: %s\n", newname, strerror(errno));
- return (origname);
- }
- switch(stblock.st_mode & S_IFMT) {
- case S_IFCHR:
- case S_IFBLK:
- return(newname);
- case S_IFDIR:
- if (retried)
- break;
-
- len = strlen(origname) - 1;
- if (len > 0 && origname[len] == '/')
- /* remove trailing slash */
- origname[len] = '\0';
- if ((fsinfo = getfsfile(origname)) == NULL) {
- printf("Can't resolve %s to character special device",
- origname);
- return (0);
- }
- newname = fsinfo->fs_spec;
- retried++;
- goto retry;
- }
- /*
- * Not a block or character device, just return name and
- * let the user decide whether to use it.
- */
- return (origname);
-}
diff --git a/sbin/setkey/Makefile b/sbin/setkey/Makefile
deleted file mode 100644
index 918dbf4cb71c..000000000000
--- a/sbin/setkey/Makefile
+++ /dev/null
@@ -1,56 +0,0 @@
-# Copyright (C) 1995, 1996, 1997, 1998, and 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:
-# 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 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
-# ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT 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.
-# $FreeBSD$
-
-PROG= setkey
-SRCS= setkey.c parse.y token.l
-CFLAGS+=-g
-LDADD+= -ll -ly
-CLEANFILES+= y.tab.c y.tab.h key_test.o keytest
-YFLAGS+=-d
-
-SCRIPTS= scriptdump
-
-BINOWN = root
-BINGRP = bin
-BINMODE = 555
-
-all: ${PROG} scriptdump
-
-SRCS+=y.tab.h
-y.tab.h: parse.y
-CFLAGS+=-DIPSEC_DEBUG -DINET6 -DYY_NO_UNPUT -I${.OBJDIR}
-LDADD+= -lipsec
-CLEANFILES+= scriptdump y.tab.h
-
-MAN8= setkey.8
-LOCALPREFIX= /usr/local
-
-scriptdump: scriptdump.pl
- sed -e 's#@LOCALPREFIX@#${LOCALPREFIX}#' < $> > scriptdump
-
-.include <bsd.prog.mk>
diff --git a/sbin/setkey/parse.y b/sbin/setkey/parse.y
deleted file mode 100644
index 761c34d6e6d8..000000000000
--- a/sbin/setkey/parse.y
+++ /dev/null
@@ -1,787 +0,0 @@
-/*
- * Copyright (C) 1995, 1996, 1997, 1998, and 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:
- * 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 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
- * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT 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.
- *
- * $FreeBSD$
- */
-/* KAME $Id: parse.y,v 1.7 1999/10/27 17:08:57 sakane Exp $ */
-
-%{
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/socket.h>
-
-#include <net/route.h>
-#include <netinet/in.h>
-#include <net/pfkeyv2.h>
-#include <netkey/key_var.h>
-#include <netinet6/ipsec.h>
-#include <arpa/inet.h>
-
-#include <string.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <errno.h>
-#include <netdb.h>
-
-#include "vchar.h"
-
-#define ATOX(c) \
- (isdigit(c) ? (c - '0') : (isupper(c) ? (c - 'A' + 10) : (c - 'a' + 10) ))
-
-u_int p_type;
-u_int32_t p_spi;
-struct sockaddr *p_src, *p_dst;
-u_int p_prefs, p_prefd, p_upper;
-u_int p_satype, p_ext, p_alg_enc, p_alg_auth, p_replay, p_mode;
-u_int p_key_enc_len, p_key_auth_len;
-caddr_t p_key_enc, p_key_auth;
-time_t p_lt_hard, p_lt_soft;
-
-u_int p_policy_len;
-char *p_policy;
-
-/* temporary buffer */
-static struct sockaddr *pp_addr;
-static u_int pp_prefix;
-static u_int pp_port;
-static caddr_t pp_key;
-
-extern u_char m_buf[BUFSIZ];
-extern int m_len;
-extern char cmdarg[8192];
-extern int f_debug;
-
-int setkeymsg __P((void));
-static int setvarbuf __P((int *, struct sadb_ext *, int, caddr_t, int));
-void parse_init __P((void));
-void free_buffer __P((void));
-
-extern int setkeymsg __P((void));
-extern int sendkeymsg __P((void));
-
-extern int yylex __P((void));
-extern void yyerror __P((char *));
-%}
-
-%union {
- unsigned long num;
- vchar_t val;
-}
-
-%token EOT
-%token ADD GET DELETE FLUSH DUMP
-%token IP4_ADDRESS IP6_ADDRESS PREFIX PORT PORTANY
-%token UP_PROTO PR_ESP PR_AH PR_IPCOMP
-%token F_PROTOCOL F_AUTH F_ENC F_REPLAY F_COMP F_RAWCPI
-%token F_MODE MODE
-%token F_EXT EXTENSION
-%token ALG_AUTH ALG_ENC ALG_ENC_DESDERIV ALG_ENC_DES32IV ALG_COMP
-%token F_LIFETIME_HARD F_LIFETIME_SOFT
-%token DECSTRING QUOTEDSTRING HEXSTRING ANY
- /* SPD management */
-%token SPDADD SPDDELETE SPDDUMP SPDFLUSH
-%token F_POLICY PL_REQUESTS
-
-%%
-commands
- : /*NOTHING*/
- | commands command
- {
- if (f_debug) {
- printf("cmdarg:\n%s\n", cmdarg);
- } else {
- setkeymsg();
- sendkeymsg();
- }
- free_buffer();
- parse_init();
- }
- ;
-
-command
- : add_command
- | get_command
- | delete_command
- | flush_command
- | dump_command
- | spdadd_command
- | spddelete_command
- | spddump_command
- | spdflush_command
- ;
- /* commands concerned with management, there is in tail of this file. */
-
- /* add command */
-add_command
- : ADD { p_type = SADB_ADD; }
- sa_selector_spec extension_spec algorithm_spec EOT
- ;
-
- /* delete */
-delete_command
- : DELETE { p_type = SADB_DELETE; }
- sa_selector_spec extension_spec EOT
- ;
-
- /* get command */
-get_command
- : GET { p_type = SADB_GET; }
- sa_selector_spec extension_spec EOT
- ;
-
- /* flush */
-flush_command
- : FLUSH { p_type = SADB_FLUSH; }
- protocol_spec EOT
- ;
-
- /* dump */
-dump_command
- : DUMP { p_type = SADB_DUMP; }
- protocol_spec EOT
- ;
-
- /* sa_selector_spec */
-sa_selector_spec
- : ipaddress { p_src = pp_addr; }
- ipaddress { p_dst = pp_addr; }
- protocol_spec spi
- ;
-
-protocol_spec
- : /*NOTHING*/ { p_satype = SADB_SATYPE_UNSPEC; }
- | PR_ESP
- {
- p_satype = SADB_SATYPE_ESP;
- if ($1.num == 1)
- p_ext |= SADB_X_EXT_OLD;
- else
- p_ext &= ~SADB_X_EXT_OLD;
- }
- | PR_AH
- {
- p_satype = SADB_SATYPE_AH;
- if ($1.num == 1)
- p_ext |= SADB_X_EXT_OLD;
- else
- p_ext &= ~SADB_X_EXT_OLD;
- }
- | PR_IPCOMP
- {
- p_satype = SADB_X_SATYPE_IPCOMP;
- }
- ;
-
-spi
- : DECSTRING { p_spi = $1.num; }
- | HEXSTRING
- {
- caddr_t bp;
- caddr_t yp = $1.val.buf;
- char buf0[4], buf[4];
- int i, j;
-
- /* sanity check */
- if ($1.val.len > 4) {
- yyerror("SPI too big.");
- free($1.val.buf);
- return -1;
- }
-
- bp = buf0;
- while (*yp) {
- *bp = (ATOX(yp[0]) << 4) | ATOX(yp[1]);
- yp += 2, bp++;
- }
-
- /* initialize */
- for (i = 0; i < 4; i++) buf[i] = 0;
-
- for (j = $1.val.len - 1, i = 3; j >= 0; j--, i--)
- buf[i] = buf0[j];
-
- /* XXX: endian */
- p_spi = ntohl(*(u_int32_t *)buf);
-
- free($1.val.buf);
- }
- ;
-
-algorithm_spec
- : esp_spec
- | ah_spec
- | ipcomp_spec
- ;
-
-esp_spec
- : F_ENC enc_alg enc_key F_AUTH auth_alg auth_key
- | F_ENC enc_alg enc_key
- ;
-
-ah_spec
- : F_AUTH auth_alg auth_key
- ;
-
-ipcomp_spec
- : F_COMP ALG_COMP { p_alg_enc = $2.num; }
- | F_COMP ALG_COMP { p_alg_enc = $2.num; }
- F_RAWCPI { p_ext |= SADB_X_EXT_RAWCPI; }
- ;
-
-enc_alg
- : ALG_ENC { p_alg_enc = $1.num; }
- | ALG_ENC_DESDERIV
- {
- p_alg_enc = $1.num;
- if (p_ext & SADB_X_EXT_OLD) {
- yyerror("algorithm mismatched.");
- return -1;
- }
- p_ext |= SADB_X_EXT_DERIV;
- }
- | ALG_ENC_DES32IV
- {
- p_alg_enc = $1.num;
- if (!(p_ext & SADB_X_EXT_OLD)) {
- yyerror("algorithm mismatched.");
- return -1;
- }
- p_ext |= SADB_X_EXT_IV4B;
- }
- ;
-
-enc_key
- : /*NOTHING*/
- {
- if (p_alg_enc != SADB_EALG_NULL) {
- yyerror("no key found.");
- return -1;
- }
- }
- | key_string
- {
- p_key_enc_len = $1.val.len;
- p_key_enc = pp_key;
-
- if (ipsec_check_keylen(SADB_EXT_SUPPORTED_ENCRYPT,
- p_alg_enc,
- PFKEY_UNUNIT64(p_key_enc_len)) < 0) {
- yyerror(ipsec_strerror());
- return -1;
- }
- }
- ;
-
-auth_alg
- : ALG_AUTH { p_alg_auth = $1.num; }
- ;
-
-auth_key
- : /*NOTHING*/
- {
- if (p_alg_auth != SADB_AALG_NULL) {
- yyerror("no key found.");
- return -1;
- }
- }
- | key_string
- {
- p_key_auth_len = $1.val.len;
- p_key_auth = pp_key;
-
- if (ipsec_check_keylen(SADB_EXT_SUPPORTED_AUTH,
- p_alg_auth,
- PFKEY_UNUNIT64(p_key_auth_len)) < 0) {
- yyerror(ipsec_strerror());
- return -1;
- }
- }
- ;
-
-key_string
- : QUOTEDSTRING
- {
- pp_key = $1.val.buf;
- /* free pp_key later */
- }
- | HEXSTRING
- {
- caddr_t bp;
- caddr_t yp = $1.val.buf;
-
- if ((pp_key = malloc($1.val.len)) == 0) {
- free($1.val.buf);
- yyerror(strerror(errno));
- return -1;
- }
- memset(pp_key, 0, $1.val.len);
-
- bp = pp_key;
- while (*yp) {
- *bp = (ATOX(yp[0]) << 4) | ATOX(yp[1]);
- yp += 2, bp++;
- }
-
- free($1.val.buf);
- }
- ;
-
-extension_spec
- : /*NOTHING*/
- | extension_spec extension
- ;
-
-extension
- : F_EXT EXTENSION { p_ext |= $1.num; }
- | F_MODE MODE { p_mode = $2.num; }
- | F_MODE ANY { p_mode = IPSEC_MODE_ANY; }
- | F_REPLAY DECSTRING
- {
- if (p_ext & SADB_X_EXT_OLD) {
- yyerror("replay prevention "
- "only use on new spec.");
- return -1;
- }
- p_replay = $2.num;
- }
- | F_LIFETIME_HARD DECSTRING { p_lt_hard = $2.num; }
- | F_LIFETIME_SOFT DECSTRING { p_lt_soft = $2.num; }
- ;
-
- /* definition about command for SPD management */
- /* spdadd */
-spdadd_command
- : SPDADD
- {
- p_type = SADB_X_SPDADD;
- p_satype = SADB_SATYPE_UNSPEC;
- }
- sp_selector_spec policy_spec EOT
- ;
-
-spddelete_command:
- SPDDELETE
- {
- p_type = SADB_X_SPDDELETE;
- p_satype = SADB_SATYPE_UNSPEC;
- }
- sp_selector_spec EOT
- ;
-
-spddump_command:
- SPDDUMP
- {
- p_type = SADB_X_SPDDUMP;
- p_satype = SADB_SATYPE_UNSPEC;
- }
- EOT
- ;
-
-spdflush_command:
- SPDFLUSH
- {
- p_type = SADB_X_SPDFLUSH;
- p_satype = SADB_SATYPE_UNSPEC;
- }
- EOT
- ;
-
- /* sp_selector_spec */
-sp_selector_spec
- : ipaddress { p_src = pp_addr; }
- prefix { p_prefs = pp_prefix; }
- port { _INPORTBYSA(p_src) = htons(pp_port); }
- ipaddress { p_dst = pp_addr; }
- prefix { p_prefd = pp_prefix; }
- port { _INPORTBYSA(p_dst) = htons(pp_port); }
- upper_spec
- ;
-
-ipaddress
- : IP4_ADDRESS
- {
- struct sockaddr_in *in;
- u_int sa_len = $1.val.len;
-
- if ((in = (struct sockaddr_in *)malloc(sa_len)) == 0) {
- yyerror(strerror(errno));
- free($1.val.buf);
- return -1;
- }
- memset((caddr_t)in, 0, sa_len);
-
- in->sin_family = PF_INET;
- in->sin_len = sa_len;
- in->sin_port = IPSEC_PORT_ANY;
- (void)inet_pton(PF_INET, $1.val.buf, &in->sin_addr);
-
- pp_addr = (struct sockaddr *)in;
- free($1.val.buf);
- }
- | IP6_ADDRESS
- {
-#ifdef INET6
- struct sockaddr_in6 *in6;
- u_int sa_len = $1.val.len;
- struct addrinfo hints, *res;
- int ret_gai;
-
- if ((in6 = (struct sockaddr_in6 *)malloc(sa_len)) == 0) {
- free($1.val.buf);
- yyerror(strerror(errno));
- return -1;
- }
- memset((caddr_t)in6, 0, sa_len);
-
- bzero(&hints, sizeof(struct addrinfo));
- hints.ai_flags = AI_NUMERICHOST;
- hints.ai_family = AF_INET6;
- ret_gai = getaddrinfo($1.val.buf, NULL, &hints, &res);
- if (ret_gai) {
- free($1.val.buf);
- free(in6);
- yyerror(gai_strerror(ret_gai));
- if (ret_gai == EAI_SYSTEM)
- yyerror(strerror(errno));
- return -1;
- }
- (void)memcpy(in6, res->ai_addr, res->ai_addrlen);
-
- /*
- * XXX: If the scope of the destination is link-local,
- * embed the scope-id(in this case, interface index)
- * into the address.
- */
- if (IN6_IS_ADDR_LINKLOCAL(&in6->sin6_addr) &&
- in6->sin6_scope_id != 0)
- *(u_short *)&in6->sin6_addr.s6_addr[2] =
- htons(in6->sin6_scope_id & 0xffff);
-
- freeaddrinfo(res);
-
- pp_addr = (struct sockaddr *)in6;
-#else
- yyerror("IPv6 address not supported");
-#endif
- free($1.val.buf);
- }
- ;
-
-prefix
- : /*NOTHING*/ { pp_prefix = ~0; }
- | PREFIX { pp_prefix = $1.num; }
- ;
-
-port
- : /*NOTHING*/ { pp_port = IPSEC_PORT_ANY; }
- | PORT { pp_port = $1.num; }
- | PORTANY { pp_port = IPSEC_PORT_ANY; }
- ;
-
-upper_spec
- : DECSTRING { p_upper = $1.num; }
- | UP_PROTO { p_upper = $1.num; }
- | PR_ESP { p_upper = IPPROTO_ESP; };
- | PR_AH { p_upper = IPPROTO_AH; };
- | PR_IPCOMP { p_upper = IPPROTO_IPCOMP; };
- | ANY { p_upper = IPSEC_ULPROTO_ANY; }
- ;
-
-policy_spec
- : F_POLICY policy_requests
- {
- p_policy = ipsec_set_policy($2.val.buf, $2.val.len);
- if (p_policy == NULL) {
- free($2.val.buf);
- p_policy = NULL;
- yyerror(ipsec_strerror());
- return -1;
- }
-
- p_policy_len = ipsec_get_policylen(p_policy);
-
- free($2.val.buf);
- }
- ;
-
-policy_requests:
- /*NOTHING*/
- | PL_REQUESTS { $$ = $1; }
- ;
-
-%%
-
-int
-setkeymsg()
-{
- struct sadb_msg m_msg;
-
- m_msg.sadb_msg_version = PF_KEY_V2;
- m_msg.sadb_msg_type = p_type;
- m_msg.sadb_msg_errno = 0;
- m_msg.sadb_msg_satype = p_satype;
- m_msg.sadb_msg_mode = p_mode;
- m_msg.sadb_msg_reserved = 0;
- m_msg.sadb_msg_seq = 0;
- m_msg.sadb_msg_pid = getpid();
-
- m_len = sizeof(struct sadb_msg);
- memcpy(m_buf, &m_msg, m_len);
-
- switch (p_type) {
- case SADB_FLUSH:
- case SADB_DUMP:
- break;
-
- case SADB_ADD:
- /* set encryption algorithm, if present. */
- if (p_satype != SADB_X_SATYPE_IPCOMP && p_alg_enc != SADB_EALG_NONE) {
- struct sadb_key m_key;
-
- m_key.sadb_key_len =
- PFKEY_UNIT64(sizeof(m_key)
- + PFKEY_ALIGN8(p_key_enc_len));
- m_key.sadb_key_exttype = SADB_EXT_KEY_ENCRYPT;
- m_key.sadb_key_bits = p_key_enc_len * 8;
- m_key.sadb_key_reserved = 0;
-
- setvarbuf(&m_len,
- (struct sadb_ext *)&m_key, sizeof(m_key),
- (caddr_t)p_key_enc, p_key_enc_len);
- }
-
- /* set authentication algorithm, if present. */
- if (p_alg_auth != SADB_AALG_NONE) {
- struct sadb_key m_key;
-
- m_key.sadb_key_len =
- PFKEY_UNIT64(sizeof(m_key)
- + PFKEY_ALIGN8(p_key_auth_len));
- m_key.sadb_key_exttype = SADB_EXT_KEY_AUTH;
- m_key.sadb_key_bits = p_key_auth_len * 8;
- m_key.sadb_key_reserved = 0;
-
- setvarbuf(&m_len,
- (struct sadb_ext *)&m_key, sizeof(m_key),
- (caddr_t)p_key_auth, p_key_auth_len);
- }
-
- /* set lifetime for HARD */
- if (p_lt_hard != 0) {
- struct sadb_lifetime m_lt;
- u_int len = sizeof(struct sadb_lifetime);
-
- m_lt.sadb_lifetime_len = PFKEY_UNIT64(len);
- m_lt.sadb_lifetime_exttype = SADB_EXT_LIFETIME_HARD;
- m_lt.sadb_lifetime_allocations = 0;
- m_lt.sadb_lifetime_bytes = 0;
- m_lt.sadb_lifetime_addtime = p_lt_hard;
- m_lt.sadb_lifetime_usetime = 0;
-
- memcpy(m_buf + m_len, &m_lt, len);
- m_len += len;
- }
-
- /* set lifetime for SOFT */
- if (p_lt_soft != 0) {
- struct sadb_lifetime m_lt;
- u_int len = sizeof(struct sadb_lifetime);
-
- m_lt.sadb_lifetime_len = PFKEY_UNIT64(len);
- m_lt.sadb_lifetime_exttype = SADB_EXT_LIFETIME_SOFT;
- m_lt.sadb_lifetime_allocations = 0;
- m_lt.sadb_lifetime_bytes = 0;
- m_lt.sadb_lifetime_addtime = p_lt_soft;
- m_lt.sadb_lifetime_usetime = 0;
-
- memcpy(m_buf + m_len, &m_lt, len);
- m_len += len;
- }
- /* FALLTHROUGH */
-
- case SADB_DELETE:
- case SADB_GET:
- {
- struct sadb_sa m_sa;
- struct sadb_address m_addr;
- u_int len;
-
- len = sizeof(struct sadb_sa);
- m_sa.sadb_sa_len = PFKEY_UNIT64(len);
- m_sa.sadb_sa_exttype = SADB_EXT_SA;
- m_sa.sadb_sa_spi = htonl(p_spi);
- m_sa.sadb_sa_replay = p_replay;
- m_sa.sadb_sa_state = 0;
- m_sa.sadb_sa_auth = p_alg_auth;
- m_sa.sadb_sa_encrypt = p_alg_enc;
- m_sa.sadb_sa_flags = p_ext;
-
- memcpy(m_buf + m_len, &m_sa, len);
- m_len += len;
-
- /* set src */
- m_addr.sadb_address_len =
- PFKEY_UNIT64(sizeof(m_addr)
- + PFKEY_ALIGN8(p_src->sa_len));
- m_addr.sadb_address_exttype = SADB_EXT_ADDRESS_SRC;
- m_addr.sadb_address_proto = IPSEC_ULPROTO_ANY;
- m_addr.sadb_address_prefixlen =
- _INALENBYAF(p_src->sa_family) << 3;
- m_addr.sadb_address_reserved = 0;
-
- setvarbuf(&m_len,
- (struct sadb_ext *)&m_addr, sizeof(m_addr),
- (caddr_t)p_src, p_src->sa_len);
-
- /* set dst */
- m_addr.sadb_address_len =
- PFKEY_UNIT64(sizeof(m_addr)
- + PFKEY_ALIGN8(p_dst->sa_len));
- m_addr.sadb_address_exttype = SADB_EXT_ADDRESS_DST;
- m_addr.sadb_address_proto = IPSEC_ULPROTO_ANY;
- m_addr.sadb_address_prefixlen =
- _INALENBYAF(p_dst->sa_family) << 3;
- m_addr.sadb_address_reserved = 0;
-
- setvarbuf(&m_len,
- (struct sadb_ext *)&m_addr, sizeof(m_addr),
- (caddr_t)p_dst, p_dst->sa_len);
- }
- break;
-
- /* for SPD management */
- case SADB_X_SPDFLUSH:
- case SADB_X_SPDDUMP:
- break;
-
- case SADB_X_SPDADD:
- {
- memcpy(m_buf + m_len, p_policy, p_policy_len);
- m_len += p_policy_len;
- free(p_policy);
- p_policy = NULL;
- }
- /* FALLTHROUGH */
-
- case SADB_X_SPDDELETE:
- {
- struct sadb_address m_addr;
-
- /* set src */
- m_addr.sadb_address_len =
- PFKEY_UNIT64(sizeof(m_addr)
- + PFKEY_ALIGN8(p_src->sa_len));
- m_addr.sadb_address_exttype = SADB_EXT_ADDRESS_SRC;
- m_addr.sadb_address_proto = p_upper;
- m_addr.sadb_address_prefixlen =
- (p_prefs != ~0 ? p_prefs :
- _INALENBYAF(p_src->sa_family) << 3);
- m_addr.sadb_address_reserved = 0;
-
- setvarbuf(&m_len,
- (struct sadb_ext *)&m_addr, sizeof(m_addr),
- (caddr_t)p_src, p_src->sa_len);
-
- /* set dst */
- m_addr.sadb_address_len =
- PFKEY_UNIT64(sizeof(m_addr)
- + PFKEY_ALIGN8(p_dst->sa_len));
- m_addr.sadb_address_exttype = SADB_EXT_ADDRESS_DST;
- m_addr.sadb_address_proto = p_upper;
- m_addr.sadb_address_prefixlen =
- (p_prefd != ~0 ? p_prefd :
- _INALENBYAF(p_dst->sa_family) << 3);
- m_addr.sadb_address_reserved = 0;
-
- setvarbuf(&m_len,
- (struct sadb_ext *)&m_addr, sizeof(m_addr),
- (caddr_t)p_dst, p_dst->sa_len);
- }
- break;
- }
-
- ((struct sadb_msg *)m_buf)->sadb_msg_len = PFKEY_UNIT64(m_len);
-
- return 0;
-}
-
-static int
-setvarbuf(off, ebuf, elen, vbuf, vlen)
- caddr_t vbuf;
- struct sadb_ext *ebuf;
- int *off, elen, vlen;
-{
- memset(m_buf + *off, 0, PFKEY_UNUNIT64(ebuf->sadb_ext_len));
- memcpy(m_buf + *off, (caddr_t)ebuf, elen);
- memcpy(m_buf + *off + elen, vbuf, vlen);
- (*off) += PFKEY_ALIGN8(elen + vlen);
-
- return 0;
-}
-
-void
-parse_init()
-{
- p_type = 0;
- p_spi = 0;
-
- p_src = 0, p_dst = 0;
- pp_prefix = p_prefs = p_prefd = ~0;
- pp_port = IPSEC_PORT_ANY;
- p_upper = 0;
-
- p_satype = 0;
- p_ext = SADB_X_EXT_NONE;
- p_alg_enc = SADB_EALG_NONE;
- p_alg_auth = SADB_AALG_NONE;
- p_mode = IPSEC_MODE_ANY;
- p_replay = 4;
- p_key_enc_len = p_key_auth_len = 0;
- p_key_enc = p_key_auth = 0;
- p_lt_hard = p_lt_soft = 0;
-
- p_policy_len = 0;
- p_policy = NULL;
-
- memset(cmdarg, 0, sizeof(cmdarg));
-
- return;
-}
-
-void
-free_buffer()
-{
- if (p_src) free(p_src);
- if (p_dst) free(p_dst);
- if (p_key_enc) free(p_key_enc);
- if (p_key_auth) free(p_key_auth);
-
- return;
-}
-
diff --git a/sbin/setkey/sample.cf b/sbin/setkey/sample.cf
deleted file mode 100644
index 886c449a35f1..000000000000
--- a/sbin/setkey/sample.cf
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright (C) 1995, 1996, 1997, 1998, and 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:
-# 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 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
-# ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT 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.
-#
-# $FreeBSD$
-
-# There are sample scripts for IPsec configuration by manual keying.
-# A security association is uniquely identified by a triple consisting
-# of a Security Parameter Index (SPI), an IP Destination Address, and a
-# security protocol (AH or ESP) identifier. You must take care of these
-# parameters when you configure by manual keying.
-
-# ESP transport mode is recommended for TCP port number 110 between
-# Host-A and Host-B. Encryption algorithm is blowfish-cbc whose key
-# is "kamekame", and authentication algorithm is hmac-sha1 whose key
-# is "this is the test key".
-#
-# ============ ESP ============
-# | |
-# Host-A Host-B
-# fec0::10 -------------------- fec0::11
-#
-# At Host-A and Host-B,
-spdadd fec0::10[any] fec0::11[110] tcp -P out ipsec
- esp/transport/fec0::10-fec0::11/use ;
-spdadd fec0::11[110] fec0::10[any] tcp -P in ipsec
- esp/transport/fec0::11-fec0::10/use ;
-add fec0::10 fec0::11 esp 0x10001
- -m transport
- -E blowfish-cbc "kamekame"
- -A hmac-sha1 "this is the test key" ;
-add fec0::11 fec0::10 esp 0x10002
- -m transport
- -E blowfish-cbc "kamekame"
- -A hmac-sha1 "this is the test key" ;
-
-# "[any]" is wildcard of port number. Note that "[0]" is the number of
-# zero in port number.
-
-# Security protocol is old AH tunnel mode, i.e. RFC1826, with keyed-md5
-# whose key is "this is the test" as authentication algorithm.
-# That protocol takes place between Gateway-A and Gateway-B.
-#
-# ======= AH =======
-# | |
-# Network-A Gateway-A Gateway-B Network-B
-# 10.0.1.0/24 ---- 172.16.0.1 ----- 172.16.0.2 ---- 10.0.2.0/24
-#
-# At Gateway-A:
-spdadd 10.0.1.0/24 10.0.2.0/24 any -P out ipsec
- ah/tunnel/172.16.0.1-172.16.0.2/require ;
-spdadd 10.0.2.0/24 10.0.1.0/24 any -P in ipsec
- ah/tunnel/172.16.0.2-172.16.0.1/require ;
-add 172.16.0.1 172.16.0.2 ah-old 0x10003
- -m any
- -A keyed-md5 "this is the test" ;
-add 172.16.0.2 172.16.0.1 ah-old 0x10004
- -m any
- -A keyed-md5 "this is the test" ;
-
-# If port number field is omitted such above then "[any]" is employed.
-# -m specifies the mode of SA to be used. "-m any" means wildcard of
-# mode of security protocol. You can use this SAs for both tunnel and
-# transport mode.
-
-# At Gateway-B. Attention to the selector and peer's IP address for tunnel.
-spdadd 10.0.2.0/24 10.0.1.0/24 any -P out ipsec
- ah/tunnel/172.16.0.2-172.16.0.1/require ;
-spdadd 10.0.1.0/24 10.0.2.0/24 any -P in ipsec
- ah/tunnel/172.16.0.1-172.16.0.2/require ;
-add 172.16.0.1 172.16.0.2 ah-old 0x10003
- -m tunnel
- -A keyed-md5 "this is the test" ;
-add 172.16.0.2 172.16.0.1 ah-old 0x10004
- -m tunnel
- -A keyed-md5 "this is the test" ;
-
-# AH transport mode followed by ESP tunnel mode is required between
-# Gateway-A and Gateway-B.
-# Encryption algorithm is 3des-cbc, and authentication algorithm for ESP
-# is hmac-sha1. Authentication algorithm for AH is hmac-md5.
-#
-# ========== AH =========
-# | ======= ESP ===== |
-# | | | |
-# Network-A Gateway-A Gateway-B Network-B
-# fec0:0:0:1::/64 --- fec0:0:0:1::1 ---- fec0:0:0:2::1 --- fec0:0:0:2::/64
-#
-# At Gateway-A:
-spdadd fec0:0:0:1::/64 fec0:0:0:2::/64 any -P out ipsec
- esp/tunnel/fec0:0:0:1::1-fec0:0:0:2::1/require
- ah/transport/fec0:0:0:1::1-fec0:0:0:2::1/require ;
-spdadd fec0:0:0:2::/64 fec0:0:0:1::/64 any -P in ipsec
- esp/tunnel/fec0:0:0:2::1-fec0:0:0:1::1/require
- ah/transport/fec0:0:0:2::1-fec0:0:0:1::1/require ;
-add fec0:0:0:1::1 fec0:0:0:2::1 esp 0x10001
- -m tunnel
- -E 3des-cbc "kamekame12341234kame1234"
- -A hmac-sha1 "this is the test key" ;
-add fec0:0:0:1::1 fec0:0:0:2::1 ah 0x10001
- -m transport
- -A hmac-md5 "this is the test" ;
-add fec0:0:0:2::1 fec0:0:0:1::1 esp 0x10001
- -m tunnel
- -E 3des-cbc "kamekame12341234kame1234"
- -A hmac-sha1 "this is the test key" ;
-add fec0:0:0:2::1 fec0:0:0:1::1 ah 0x10001
- -m transport
- -A hmac-md5 "this is the test" ;
-
-# ESP tunnel mode is required between Host-A and Gateway-A.
-# Encryption algorithm is cast128-cbc, and authentication algorithm
-# for ESP is hmac-sha1.
-# ESP transport mode is recommended between Host-A and Host-B.
-# Encryption algorithm is rc5-cbc, and authentication algorithm
-# for ESP is hmac-md5.
-#
-# ================== ESP =================
-# | ======= ESP ======= |
-# | | | |
-# Host-A Gateway-A Host-B
-# fec0:0:0:1::1 ---- fec0:0:0:2::1 ---- fec0:0:0:2::2
-#
-# At Host-A:
-spdadd fec0:0:0:1::1[any] fec0:0:0:2::2[80] tcp -P out ipsec
- esp/transport/fec0:0:0:1::1-fec0:0:0:2::2/use
- esp/tunnel/fec0:0:0:1::1-fec0:0:0:2::1/require ;
-spdadd fec0:0:0:2::1[80] fec0:0:0:1::1[any] tcp -P in ipsec
- esp/transport/fec0:0:0:2::2-fec0:0:0:1::1/use
- esp/tunnel/fec0:0:0:2::1-fec0:0:0:1::1/require ;
-add fec0:0:0:1::1 fec0:0:0:2::2 esp 0x10001
- -m transport
- -E cast128-cbc "12341234"
- -A hmac-sha1 "this is the test key" ;
-add fec0:0:0:1::1 fec0:0:0:2::1 esp 0x10002
- -E rc5-cbc "kamekame"
- -A hmac-md5 "this is the test" ;
-add fec0:0:0:2::2 fec0:0:0:1::1 esp 0x10003
- -m transport
- -E cast128-cbc "12341234"
- -A hmac-sha1 "this is the test key" ;
-add fec0:0:0:2::1 fec0:0:0:1::1 esp 0x10004
- -E rc5-cbc "kamekame"
- -A hmac-md5 "this is the test" ;
-
-# By "get" command, you can get a entry of either SP or SA.
-get fec0:0:0:1::1 fec0:0:0:2::2 ah 0x10004 ;
-
-# Also delete command, you can delete a entry of either SP or SA.
-spddelete out fec0:0:0:1::/64 fec0:0:0:2:/64 any ;
-delete fec0:0:0:1::1 fec0:0:0:2::2 ah 0x10004 ;
-
-# By dump command, you can dump all entry of either SP or SA.
-dump ;
-spddump ;
-dump esp ;
-flush esp ;
-
-# By flush command, you can flush all entry of either SP or SA.
-flush ;
-spdflush ;
-
-# "flush" and "dump" commands can specify a security protocol.
-dump esp ;
-flush ah ;
-
-# XXX
-add ::1 ::1 esp 10001 -m transport -E simple ;
-add ::1 ::1 esp 10002 -m transport -E des-deriv "12341234" ;
-add ::1 ::1 esp-old 10003 -m transport -E des-32iv "12341234" ;
-add ::1 ::1 esp 10004 -m transport -E simple -A null ;
-add ::1 ::1 esp 10005 -m transport -E simple -A hmac-md5 "1234123412341234" ;
-add ::1 ::1 esp 10006 -m tunnel -E simple -A hmac-sha1 "12341234123412341234" ;
-add ::1 ::1 esp 10007 -m transport -E simple -A keyed-md5 "1234123412341234" ;
-add ::1 ::1 esp 10008 -m any -E simple -A keyed-sha1 "12341234123412341234" ;
-add ::1 ::1 esp 10009 -m transport -E des-cbc "testtest" ;
-add ::1 ::1 esp 10010 -m transport -E 3des-cbc "testtest12341234testtest" ;
-add ::1 ::1 esp 10011 -m tunnel -E cast128-cbc "testtest1234" ;
-add ::1 ::1 esp 10012 -m tunnel -E blowfish-cbc "testtest1234" ;
-add ::1 ::1 esp 10013 -m tunnel -E rc5-cbc "testtest1234" ;
-add ::1 ::1 esp 10014 -m any -E rc5-cbc "testtest1234" ;
-add ::1 ::1 esp 10015 -m transport -f zero-pad -E simple ;
-add ::1 ::1 esp 10016 -m tunnel -f random-pad -r 8 -lh 100 -ls 80 -E simple ;
-add ::1 ::1 esp 10017 -m transport -f seq-pad -f cyclic-seq -E simple ;
-add ::1 ::1 esp 10018 -m transport -E simple ;
-#add ::1 ::1 ah 20000 -m transport -A null ;
-add ::1 ::1 ah 20001 -m any -A hmac-md5 "1234123412341234";
-add ::1 ::1 ah 20002 -m tunnel -A hmac-sha1 "12341234123412341234";
-add ::1 ::1 ah 20003 -m transport -A keyed-md5 "1234123412341234";
-add ::1 ::1 ah-old 20004 -m transport -A keyed-md5 "1234123412341234";
-add ::1 ::1 ah 20005 -m transport -A keyed-sha1 "12341234123412341234";
-#add ::1 ::1 ipcomp 30000 -C oui ;
-add ::1 ::1 ipcomp 30001 -C deflate ;
-#add ::1 ::1 ipcomp 30002 -C lzs ;
-
-# enjoy.
diff --git a/sbin/setkey/scriptdump.pl b/sbin/setkey/scriptdump.pl
deleted file mode 100644
index 5df9b4f4fd7b..000000000000
--- a/sbin/setkey/scriptdump.pl
+++ /dev/null
@@ -1,54 +0,0 @@
-#! @LOCALPREFIX@/bin/perl
-# $FreeBSD$
-
-if ($< != 0) {
- print STDERR "must be root to invoke this\n";
- exit 1;
-}
-
-$mode = 'add';
-while ($i = shift @ARGV) {
- if ($i eq '-d') {
- $mode = 'delete';
- } else {
- print STDERR "usage: scriptdump [-d]\n";
- exit 1;
- }
-}
-
-open(IN, "setkey -D |") || die;
-foreach $_ (<IN>) {
- if (/^[^\t]/) {
- ($src, $dst) = split(/\s+/, $_);
- } elsif (/^\t(esp|ah) mode=(\S+) spi=(\d+).*replay=(\d+)/) {
- ($proto, $ipsecmode, $spi, $replay) = ($1, $2, $3, $4);
- } elsif (/^\tE: (\S+) (.*)/) {
- $ealgo = $1;
- $ekey = $2;
- $ekey =~ s/\s//g;
- $ekey =~ s/^/0x/g;
- } elsif (/^\tA: (\S+) (.*)/) {
- $aalgo = $1;
- $akey = $2;
- $akey =~ s/\s//g;
- $akey =~ s/^/0x/g;
- } elsif (/^\tstate=/) {
- print "$mode $src $dst $proto $spi -m $ipsecmode";
- print " -r $replay" if $replay;
- if ($mode eq 'add') {
- if ($proto eq 'esp') {
- print " -E $ealgo $ekey" if $ealgo;
- print " -A $aalgo $akey" if $aalgo;
- } elsif ($proto eq 'ah') {
- print " -A $aalgo $akey" if $aalgo;
- }
- }
- print ";\n";
-
- $src = $dst = $upper = $proxy = '';
- $ealgo = $ekey = $aalgo = $akey = '';
- }
-}
-close(IN);
-
-exit 0;
diff --git a/sbin/setkey/setkey.8 b/sbin/setkey/setkey.8
deleted file mode 100644
index d43744f56435..000000000000
--- a/sbin/setkey/setkey.8
+++ /dev/null
@@ -1,552 +0,0 @@
-.\" Copyright (C) 1995, 1996, 1997, 1998, and 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:
-.\" 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 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
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT 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.
-.\"
-.\" $Id: setkey.8,v 1.14 1999/10/27 17:08:58 sakane Exp $
-.\" $FreeBSD$
-.\"
-.Dd May 17, 1998
-.Dt SETKEY 8
-.Os KAME
-.\"
-.Sh NAME
-.Nm setkey
-.Nd manually manipulate the SA/SP database.
-.\"
-.Sh SYNOPSIS
-.Nm setkey
-.Op Fl dv
-.Fl c
-.Nm setkey
-.Op Fl dv
-.Fl f Ar filename
-.Nm setkey
-.Op Fl adPlv
-.Fl D
-.Nm setkey
-.Op Fl dPv
-.Fl F
-.Nm setkey
-.Op Fl h
-.Fl x
-.\"
-.Sh DESCRIPTION
-.Nm
-updates, or lists the content of, Security Association Database (SAD) entries
-in the kernel as well as Security Policy Database (SPD) entries.
-.Pp
-.Nm
-takes a series of operation from standard input
-.Po
-if invoked with
-.Fl c
-.Pc
-or file named
-.Ar filename
-.Po
-if invoked with
-.Fl f Ar filename
-.Pc .
-.Bl -tag -width Ds
-.It Fl D
-Dump the SAD entries.
-If with
-.Fl P ,
-the SPD entries are dumped.
-.It Fl F
-Flush the SAD.
-If with
-.Fl P ,
-the SPD are flushed.
-.It Fl a
-.Nm
-usually do not display dead SAD entries on
-.Fl D .
-With
-.Fl a ,
-dead SAD entries will be displayed as well.
-Dead SAD entries are kept in the kernel,
-when they are referenced from any of SPD entries in the kernel.
-.It Fl d
-Enable debugging messages.
-.It Fl x
-Loop forever and dump all the messages transmitted to
-.Dv PF_KEY
-socket.
-.It Fl h
-Add hexadecimal dump on
-.Fl x
-mode.
-The order is significant.
-.It Fl l
-Loop forever with short output on
-.Fl D .
-.It Fl v
-Be verbose.
-.Dv PF_KEY
-socket
-.Po
-including messages sent from other processes
-.Pc .
-.El
-.Pp
-Operation has the following grammar.
-Note that lines, that start with a
-hashmark ('#') are treated as comment lines.
-Description of meta-arguments follows.
-.Bl -tag -width Ds
-.It Xo
-.Li add
-.Ar src Ar dst Ar protocol Ar spi
-.Op Ar extensions
-.Ar algorithm...
-.Li ;
-.Xc
-Add a SAD entry.
-.\"
-.It Xo
-.Li get
-.Ar src Ar dst Ar protocol Ar spi
-.Op Ar mode
-.Li ;
-.Xc
-Show a SAD entry.
-.\"
-.It Xo
-.Li delete
-.Ar src Ar dst Ar protocol Ar spi
-.Op Ar mode
-.Li ;
-.Xc
-Remove a SAD entry.
-.\"
-.It Xo
-.Li flush
-.Op Ar protocol
-.Li ;
-.Xc
-Clear all SAD entries that matches the options.
-.\"
-.It Xo
-.Li dump
-.Op Ar protocol
-.Li ;
-.Xc
-Dumps all SAD entries that matches the options.
-.\"
-.It Xo
-.Li spdadd
-.Ar src_range Ar dst_range Ar upperspec Ar policy
-.Li ;
-.Xc
-Add a SPD entry.
-.\"
-.It Xo
-.Li spddelete
-.Ar src_range Ar dst_range Ar upperspec
-.Li ;
-.Xc
-Delete a SPD entry.
-.\"
-.It Xo
-.Li spdflush
-.Li ;
-.Xc
-Clear all SPD entries.
-.\"
-.It Xo
-.Li spddump
-.Li ;
-.Xc
-Dumps all SPD entries.
-.El
-.\"
-.Pp
-Meta-arguments are as follows:
-.Bl -tag -compact -width Ds
-.It Ar src
-.It Ar dst
-Source/destination of the secure communication is specified as
-IPv4/v6 address.
-.Nm
-does not consult hostname-to-address for arguments
-.Ar src
-and
-.Ar dst .
-They must be in numeric form.
-.\"
-.Pp
-.It Ar protocol
-.Ar protocol
-is one of following:
-.Bl -tag -width Fl -compact
-.It Li esp
-ESP based on rfc2405
-.It Li esp-old
-ESP based on rfc1827
-.It Li ah
-AH based on rfc2402
-.It Li ah-old
-AH based on rfc1826
-.It Li ipcomp
-IPCOMP
-.El
-.\"
-.Pp
-.It Ar spi
-Security Parameter Index (SPI) for the SA and SPD.
-It must be decimal number or hexadecimal number
-.Po
-with
-.Li 0x
-attached
-.Pc .
-.\"
-.Pp
-.It Ar extensions
-takes some of the following:
-.Bl -tag -width Fl -compact
-.It Fl m Ar mode
-Specify an security protocol mode for use. By default,
-.Li any .
-.Ar mode
-is one of following:
-.Li transport , tunnel
-or
-.Li any .
-.It Fl r Ar size
-Specify window size of bytes for replay prevention.
-.Ar size
-must be decimal number in 32-bit word. If
-.Ar size
-is zero or not specified, replay check don't take place.
-.It Fl f Ar pad_option
-.Ar pad_option
-is one of following:
-.Li zero-pad , random-pad
-or
-.Li seq-pad
-.It Fl f Li cyclic-seq
-Allow cyclic sequence number.
-.It Fl lh Ar time
-.It Fl ls Ar time
-Specify hard/soft lifetime.
-.El
-.\"
-.Pp
-.It Ar algorithm
-.Bl -tag -width Fl -compact
-.It Fl E Ar ealgo Ar key
-Specify encryption algorithm.
-.It Fl A Ar ealgo Ar key
-Specify authentication algorithm.
-If
-.Fl A
-is used for esp, it will be treated as ESP payload authentication algorithm.
-.It Fl C Ar calgo Op Fl R
-Specify compression algorithm.
-If
-.Fl R
-is specified with
-.Li ipcomp
-line, the kernel will use well-known IPComp CPI
-.Pq compression parameter index
-on IPComp CPI field on packets, and
-.Ar spi
-field will be ignored.
-.Ar spi
-field is only for kernel internal use in this case.
-.\"Therefore, compression protocol number will appear on IPComp CPI field.
-If
-.Fl R
-is not used,
-the value on
-.Ar spi
-field will appear on IPComp CPI field on outgoing packets.
-.Ar spi
-field needs to be smaller than
-.Li 0x10000
-in this case.
-.El
-.Pp
-.Li esp
-SAs accept
-.Fl E
-and
-.Fl A .
-.Li esp-old
-SAs accept
-.Fl E
-only.
-.Li ah
-and
-.Li ah-old
-SAs accept
-.Fl A
-only.
-.Li ipcomp
-SAs accept
-.Fl C
-only.
-.Pp
-.Ar key
-must be double-quoted character string or a series of hexadecimal digits.
-.Pp
-Possible values for
-.Ar ealgo ,
-.Ar aalgo
-and
-.Ar calgo
-are specified in separate section.
-.\"
-.It Ar src_range
-.It Ar dst_range
-These are selection of the secure communication is specified as
-IPv4/v6 address or IPv4/v6 address range, and it may accompany
-TCP/UDP port specification.
-This takes the following form:
-.Bd -literal -offset
-.Ar address
-.Ar address/prefixlen
-.Ar address[port]
-.Ar address/prefixlen[port]
-.Ed
-.Pp
-.Ar prefixlen
-and
-.Ar port
-must be decimal number.
-The square bracket around
-.Ar port
-is really necessary.
-They are not manpage metacharacters.
-.Pp
-.Nm
-does not consult hostname-to-address for arguments
-.Ar src
-and
-.Ar dst .
-They must be in numeric form.
-.\"
-.It Ar upperspec
-Upper-layer protocol to be used.
-Currently
-.Li tcp ,
-.Li udp
-and
-.Li any
-can be specified.
-.Li any
-stands for
-.Dq any protocol .
-.Pp
-NOTE:
-.Ar upperspec
-does not work against forwarding case at this moment,
-as it requires extra reassembly at forwarding node
-.Pq not implemented as this moment .
-.\"
-.It Ar policy
-.Ar policy
-is the one of following:
-.Bd -literal -offset
-.Xo
-.Fl P
-.Ar direction
-.Li discard
-.Xc
-.Xo
-.Fl P
-.Ar direction
-.Li none
-.Xc
-.Xo
-.Fl P
-.Ar direction
-.Li ipsec
-.Ar protocol/mode/src-dst/level
-.Xc
-.Ed
-.Pp
-You must specify the direction of its policy as
-.Ar direction .
-Either
-.Li out
-or
-.Li in
-are used.
-.Li discard
-means the packet matching indexes will be discarded.
-.Li none
-means that IPsec operation will not take place onto the packet.
-.Li ipsec
-means that IPsec operation will take place onto the packet.
-Either
-.Li ah ,
-.Li esp
-or
-.Li ipcomp
-is to be set as
-.Ar protocol .
-.Ar mode
-is either
-.Li transport
-or
-.Li tunnel .
-You must specify the end-points addresses of the SA as
-.Ar src
-and
-.Ar dst
-with
-.Sq -
-between these addresses which is used to specify the SA to use.
-.Ar level
-is to be one of the following:
-.Li default , use
-or
-.Li require .
-.Li default
-means kernel consults to the system wide default against protocol you
-specified, e.g.
-.Li esp_trans_deflev
-sysctl variable, when kernel processes the packet.
-.Li use
-means that kernel use a SA if it's available,
-otherwise kernel keeps normal operation.
-.Li require
-means SA is required whenever kernel deals with the packet.
-Note that
-.Dq Li discard
-and
-.Dq Li none
-are not in the syntax described in
-.Xr ipsec_set_policy 3 .
-There are little differences in the syntax.
-See
-.Xr ipsec_set_policy 3
-for detail.
-.Pp
-.El
-.Pp
-.\"
-.Sh ALGORITHMS
-The following list shows the supported algorithms.
-.Sy protocol
-and
-.Sy algorithm
-are almost orthogonal.
-Following are the list of authentication algorithms that can be used as
-.Ar aalgo
-in
-.Fl A Ar aalgo
-of
-.Ar protocol
-parameter:
-.Pp
-.Bd -literal -offset indent
-algorithm keylen (bits) comment
-hmac-md5 128 ah: rfc2403
- 128 ah-old: rfc2085
-hmac-sha1 160 ah: rfc2404
- 160 ah-old: 128bit ICV (no document)
-keyed-md5 128 ah: 96bit ICV (no document)
- 128 ah-old: rfc1828
-keyed-sha1 160 ah: 96bit ICV (no document)
- 160 ah-old: 128bit ICV (no document)
-null 0 to 2048 for debugging
-.Ed
-.Pp
-Following are the list of encryption algorithms that can be used as
-.Ar ealgo
-in
-.Fl E Ar ealgo
-of
-.Ar protocol
-parameter:
-.Pp
-.Bd -literal -offset indent
-algorithm keylen (bits) comment
-des-cbc 64 esp-old: rfc1829, esp: rfc2405
-3des-cbc 192 rfc2451
-simple 0 to 2048 rfc2410
-blowfish-cbc 40 to 448 rfc2451
-cast128-cbc 40 to 128 rfc2451
-rc5-cbc 40 to 2040 rfc2451
-des-deriv 64 ipsec-ciph-des-derived-01 (expired)
-3des-deriv 192 no document
-.Ed
-.Pp
-Following are the list of compression algorithms that can be used as
-.Ar calgo
-in
-.Fl C Ar calgo
-of
-.Ar protocol
-parameter:
-.Pp
-.Bd -literal -offset indent
-algorithm comment
-deflate rfc2394
-lzs rfc2395
-.Ed
-.\"
-.Sh EXAMPLES
-.Bd -literal -offset
-add 3ffe:501:4819::1 3ffe:501:481d::1 esp 123457
- -E des-cbc "ESP SA!!" ;
-
-add 3ffe:501:4819::1 3ffe:501:481d::1 ah 123456
- -A hmac-sha1 "AH SA configuration!" ;
-
-add 10.0.11.41 10.0.11.33 esp 0x10001
- -E des-cbc "ESP with"
- -A hmac-md5 "authentication!!" ;
-
-get 3ffe:501:4819::1 3ffe:501:481d::1 ah 123456 ;
-
-flush ;
-
-dump esp ;
-
-spdadd 10.0.11.41/32[21] 10.0.11.33/32[any] any
- -P out ipsec esp/tunnel/192.168.0.1-192.168.1.2/require ;
-
-.Ed
-.\"
-.Sh RETURN VALUES
-The command exits with 0 on success, and non-zero on errors.
-.\"
-.Sh SEE ALSO
-.Xr ipsec_set_policy 3 ,
-.Xr sysctl 8
-.\"
-.Sh HISTORY
-The
-.Nm
-command first appeared in WIDE Hydrangea IPv6 protocol stack kit.
-The command was completely re-designed in June 1998.
-.\"
-.\" .Sh BUGS
diff --git a/sbin/setkey/setkey.c b/sbin/setkey/setkey.c
deleted file mode 100644
index 73edc3f2bbc2..000000000000
--- a/sbin/setkey/setkey.c
+++ /dev/null
@@ -1,566 +0,0 @@
-/*
- * Copyright (C) 1995, 1996, 1997, 1998, and 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:
- * 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 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
- * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT 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.
- *
- * $FreeBSD$
- */
-/* KAME $Id: setkey.c,v 1.5 1999/10/26 09:39:37 sakane Exp $ */
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <err.h>
-#include <net/route.h>
-#include <netinet/in.h>
-#include <net/pfkeyv2.h>
-#include <netkey/keydb.h>
-#include <netkey/key_debug.h>
-#include <netinet6/ipsec.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <limits.h>
-#include <string.h>
-#include <ctype.h>
-#include <unistd.h>
-#include <errno.h>
-#include <netdb.h>
-
-void Usage __P((void));
-int main __P((int, char **));
-int get_supported __P((void));
-void sendkeyshort __P((u_int));
-void promisc __P((void));
-int sendkeymsg __P((void));
-int postproc __P((struct sadb_msg *, int));
-const char *numstr __P((int));
-void shortdump_hdr __P((void));
-void shortdump __P((struct sadb_msg *));
-
-#define MODE_SCRIPT 1
-#define MODE_CMDDUMP 2
-#define MODE_CMDFLUSH 3
-
-int so;
-
-int f_forever = 0;
-int f_all = 0;
-int f_debug = 0;
-int f_verbose = 0;
-int f_mode = 0;
-int f_cmddump = 0;
-int f_policy = 0;
-int f_promisc = 0;
-int f_hexdump = 0;
-char *pname;
-
-u_char m_buf[BUFSIZ];
-u_int m_len;
-
-extern int lineno;
-
-extern int parse __P((FILE **));
-
-void
-Usage()
-{
- printf("Usage:\t%s [-dv] -c\n", pname);
- printf("\t%s [-dv] -f (file)\n", pname);
- printf("\t%s [-Padlv] -D\n", pname);
- printf("\t%s [-Pdv] -F\n", pname);
- printf("\t%s [-h] -x\n", pname);
- pfkey_close(so);
- exit(0);
-}
-
-int
-main(ac, av)
- int ac;
- char **av;
-{
- FILE *fp = stdin;
- int c;
-
- pname = *av;
-
- if (ac == 1) Usage();
-
- while ((c = getopt(ac, av, "acdf:hlvxDFP")) != EOF) {
- switch (c) {
- case 'c':
- f_mode = MODE_SCRIPT;
- fp = stdin;
- break;
- case 'f':
- f_mode = MODE_SCRIPT;
- if ((fp = fopen(optarg, "r")) == NULL) {
- err(-1, "fopen");
- /*NOTREACHED*/
- }
- break;
- case 'D':
- f_mode = MODE_CMDDUMP;
- break;
- case 'F':
- f_mode = MODE_CMDFLUSH;
- break;
- case 'a':
- f_all = 1;
- break;
- case 'l':
- f_forever = 1;
- break;
- case 'h':
- f_hexdump = 1;
- break;
- case 'x':
- f_promisc = 1;
- promisc();
- /*NOTREACHED*/
- case 'P':
- f_policy = 1;
- break;
- case 'd':
- f_debug = 1;
- break;
- case 'v':
- f_verbose = 1;
- break;
- default:
- Usage();
- /*NOTREACHED*/
- }
- }
-
- switch (f_mode) {
- case MODE_CMDDUMP:
- sendkeyshort(f_policy ? SADB_X_SPDDUMP: SADB_DUMP);
- break;
- case MODE_CMDFLUSH:
- sendkeyshort(f_policy ? SADB_X_SPDFLUSH: SADB_FLUSH);
- pfkey_close(so);
- break;
- case MODE_SCRIPT:
- if (get_supported() < 0) {
- errx(-1, "%s", ipsec_strerror());
- /*NOTREACHED*/
- }
- parse(&fp);
- break;
- default:
- Usage();
- }
-
- exit(0);
-}
-
-int
-get_supported()
-{
- int so;
-
- if ((so = pfkey_open()) < 0) {
- perror("pfkey_open");
- return -1;
- }
-
- /* debug mode ? */
- if (f_debug)
- return 0;
-
- if (pfkey_send_register(so, PF_UNSPEC) < 0)
- return -1;
-
- if (pfkey_recv_register(so) < 0)
- return -1;
-
- return 0;
-}
-
-void
-sendkeyshort(type)
- u_int type;
-{
- struct sadb_msg *m_msg = (struct sadb_msg *)m_buf;
-
- m_len = sizeof(struct sadb_msg);
-
- m_msg->sadb_msg_version = PF_KEY_V2;
- m_msg->sadb_msg_type = type;
- m_msg->sadb_msg_errno = 0;
- m_msg->sadb_msg_satype = SADB_SATYPE_UNSPEC;
- m_msg->sadb_msg_len = PFKEY_UNIT64(m_len);
- m_msg->sadb_msg_reserved = 0;
- m_msg->sadb_msg_reserved = 0;
- m_msg->sadb_msg_seq = 0;
- m_msg->sadb_msg_pid = getpid();
-
- sendkeymsg();
-
- return;
-}
-
-void
-promisc()
-{
- struct sadb_msg *m_msg = (struct sadb_msg *)m_buf;
- u_char rbuf[1024 * 32]; /* XXX: Enough ? Should I do MSG_PEEK ? */
- int so, len;
-
- m_len = sizeof(struct sadb_msg);
-
- m_msg->sadb_msg_version = PF_KEY_V2;
- m_msg->sadb_msg_type = SADB_X_PROMISC;
- m_msg->sadb_msg_errno = 0;
- m_msg->sadb_msg_satype = 1;
- m_msg->sadb_msg_len = PFKEY_UNIT64(m_len);
- m_msg->sadb_msg_reserved = 0;
- m_msg->sadb_msg_reserved = 0;
- m_msg->sadb_msg_seq = 0;
- m_msg->sadb_msg_pid = getpid();
-
- if ((so = socket(PF_KEY, SOCK_RAW, PF_KEY_V2)) < 0) {
- err(1, "socket(PF_KEY)");
- /*NOTREACHED*/
- }
-
- if ((len = send(so, m_buf, m_len, 0)) < 0) {
- err(1, "send");
- /*NOTREACHED*/
- }
-
- while (1) {
- struct sadb_msg *base;
-
- if ((len = recv(so, rbuf, sizeof(*base), MSG_PEEK)) < 0) {
- err(1, "recv");
- /*NOTREACHED*/
- }
-
- if (len != sizeof(*base))
- continue;
-
- base = (struct sadb_msg *)rbuf;
- if ((len = recv(so, rbuf, PFKEY_UNUNIT64(base->sadb_msg_len),
- 0)) < 0) {
- err(1, "recv");
- /*NOTREACHED*/
- }
- if (f_hexdump) {
- int i;
- for (i = 0; i < len; i++) {
- if (i % 16 == 0)
- printf("%08x: ", i);
- printf("%02x ", rbuf[i] & 0xff);
- if (i % 16 == 15)
- printf("\n");
- }
- if (len % 16)
- printf("\n");
- }
- /* adjust base pointer for promisc mode */
- if (base->sadb_msg_type == SADB_X_PROMISC) {
- if (sizeof(*base) < len)
- base++;
- else
- base = NULL;
- }
- if (base) {
- kdebug_sadb(base);
- printf("\n");
- fflush(stdout);
- }
- }
-}
-
-int
-sendkeymsg()
-{
- int so;
-
- u_char rbuf[1024 * 32]; /* XXX: Enough ? Should I do MSG_PEEK ? */
- int len;
- struct sadb_msg *msg;
-
- if ((so = pfkey_open()) < 0) {
- perror("pfkey_open");
- return -1;
- }
-
- {
- struct timeval tv;
- tv.tv_sec = 1;
- tv.tv_usec = 0;
- if (setsockopt(so, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) < 0) {
- perror("setsockopt");
- goto end;
- }
- }
-
- if (f_forever)
- shortdump_hdr();
-again:
- if (f_verbose)
- kdebug_sadb((struct sadb_msg *)m_buf);
-
- if ((len = send(so, m_buf, m_len, 0)) < 0) {
- perror("send");
- goto end;
- }
-
- msg = (struct sadb_msg *)rbuf;
- do {
- if ((len = recv(so, rbuf, sizeof(rbuf), 0)) < 0) {
- perror("recv");
- goto end;
- }
-
- if (PFKEY_UNUNIT64(msg->sadb_msg_len) != len) {
- warnx("invalid keymsg length");
- break;
- }
-
- if (f_verbose)
- kdebug_sadb((struct sadb_msg *)rbuf);
- if (postproc(msg, len) < 0)
- break;
- } while (msg->sadb_msg_errno || msg->sadb_msg_seq);
-
- if (f_forever) {
- fflush(stdout);
- sleep(1);
- goto again;
- }
-
-end:
- pfkey_close(so);
- return(0);
-}
-
-int
-postproc(msg, len)
- struct sadb_msg *msg;
- int len;
-{
-
- if (msg->sadb_msg_errno != 0) {
- char inf[80];
- char *errmsg = NULL;
-
- if (f_mode == MODE_SCRIPT)
- snprintf(inf, sizeof(inf), "The result of line %d: ", lineno);
- else
- inf[0] = '\0';
-
- switch (msg->sadb_msg_errno) {
- case ENOENT:
- switch (msg->sadb_msg_type) {
- case SADB_DELETE:
- case SADB_GET:
- case SADB_X_SPDDELETE:
- errmsg = "No entry";
- break;
- case SADB_DUMP:
- errmsg = "No SAD entries";
- break;
- case SADB_X_SPDDUMP:
- errmsg = "No SPD entries";
- break;
- }
- break;
- default:
- errmsg = strerror(msg->sadb_msg_errno);
- }
- printf("%s%s.\n", inf, errmsg);
- return(-1);
- }
-
- switch (msg->sadb_msg_type) {
- case SADB_GET:
- pfkey_sadump(msg);
- break;
-
- case SADB_DUMP:
- /* filter out DEAD SAs */
- if (!f_all) {
- caddr_t mhp[SADB_EXT_MAX + 1];
- struct sadb_sa *sa;
- pfkey_align(msg, mhp);
- pfkey_check(mhp);
- if ((sa = (struct sadb_sa *)mhp[SADB_EXT_SA]) != NULL) {
- if (sa->sadb_sa_state == SADB_SASTATE_DEAD)
- break;
- }
- }
- if (f_forever)
- shortdump(msg);
- else
- pfkey_sadump(msg);
- msg = (struct sadb_msg *)((caddr_t)msg +
- PFKEY_UNUNIT64(msg->sadb_msg_len));
- if (f_verbose)
- kdebug_sadb((struct sadb_msg *)msg);
- break;
-
- case SADB_X_SPDDUMP:
- pfkey_spdump(msg);
- if (msg->sadb_msg_seq == 0) break;
- msg = (struct sadb_msg *)((caddr_t)msg +
- PFKEY_UNUNIT64(msg->sadb_msg_len));
- if (f_verbose)
- kdebug_sadb((struct sadb_msg *)msg);
- break;
- }
-
- return(0);
-}
-
-/*------------------------------------------------------------*/
-static char *satype[] = {
- NULL, NULL, "ah", "esp"
-};
-static char *sastate[] = {
- "L", "M", "D", "d"
-};
-static char *ipproto[] = {
-/*0*/ "ip", "icmp", "igmp", "ggp", "ip4",
- NULL, "tcp", NULL, "egp", NULL,
-/*10*/ NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, "udp", NULL, NULL,
-/*20*/ NULL, NULL, "idp", NULL, NULL,
- NULL, NULL, NULL, NULL, "tp",
-/*30*/ NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL,
-/*40*/ NULL, "ip6", NULL, "rt6", "frag6",
- NULL, "rsvp", "gre", NULL, NULL,
-/*50*/ "esp", "ah", NULL, NULL, NULL,
- NULL, NULL, NULL, "icmp6", "none",
-/*60*/ "dst6",
-};
-
-#define STR_OR_ID(x, tab) \
- (((x) < sizeof(tab)/sizeof(tab[0]) && tab[(x)]) ? tab[(x)] : numstr(x))
-
-const char *
-numstr(x)
- int x;
-{
- static char buf[20];
- snprintf(buf, sizeof(buf), "#%d", x);
- return buf;
-}
-
-void
-shortdump_hdr()
-{
- printf("%-4s %-3s %-1s %-8s %-7s %s -> %s\n",
- "time", "p", "s", "spi", "ltime", "src", "dst");
-}
-
-void
-shortdump(msg)
- struct sadb_msg *msg;
-{
- caddr_t mhp[SADB_EXT_MAX + 1];
- char buf[1024], pbuf[10];
- struct sadb_sa *sa;
- struct sadb_address *saddr;
- struct sadb_lifetime *lts, *lth, *ltc;
- struct sockaddr *s;
- u_int t;
- time_t cur = time(0);
-
- pfkey_align(msg, mhp);
- pfkey_check(mhp);
-
- printf("%02lu%02lu", (u_long)(cur % 3600) / 60, (u_long)(cur % 60));
-
- printf(" %-3s", STR_OR_ID(msg->sadb_msg_satype, satype));
-
- if ((sa = (struct sadb_sa *)mhp[SADB_EXT_SA]) != NULL) {
- printf(" %-1s", STR_OR_ID(sa->sadb_sa_state, sastate));
- printf(" %08x", (u_int32_t)ntohl(sa->sadb_sa_spi));
- } else
- printf("%-1s %-8s", "?", "?");
-
- lts = (struct sadb_lifetime *)mhp[SADB_EXT_LIFETIME_SOFT];
- lth = (struct sadb_lifetime *)mhp[SADB_EXT_LIFETIME_HARD];
- ltc = (struct sadb_lifetime *)mhp[SADB_EXT_LIFETIME_CURRENT];
- if (lts && lth && ltc) {
- if (ltc->sadb_lifetime_addtime == 0)
- t = (u_long)0;
- else
- t = (u_long)(cur - ltc->sadb_lifetime_addtime);
- if (t >= 1000)
- strcpy(buf, " big/");
- else
- snprintf(buf, sizeof(buf), " %3lu/", (u_long)t);
- printf("%s", buf);
-
- t = (u_long)lth->sadb_lifetime_addtime;
- if (t >= 1000)
- strcpy(buf, "big");
- else
- snprintf(buf, sizeof(buf), "%-3lu", (u_long)t);
- printf("%s", buf);
- } else
- printf(" ???/???");
-
- printf(" ");
-
- if ((saddr = (struct sadb_address *)mhp[SADB_EXT_ADDRESS_SRC]) != NULL) {
- if (saddr->sadb_address_proto)
- printf("%s ", STR_OR_ID(saddr->sadb_address_proto, ipproto));
- s = (struct sockaddr *)(saddr + 1);
- getnameinfo(s, s->sa_len, buf, sizeof(buf),
- pbuf, sizeof(pbuf), NI_NUMERICHOST|NI_NUMERICSERV);
- if (strcmp(pbuf, "0") != 0)
- printf("%s[%s]", buf, pbuf);
- else
- printf("%s", buf);
- } else
- printf("?");
-
- printf(" -> ");
-
- if ((saddr = (struct sadb_address *)mhp[SADB_EXT_ADDRESS_DST]) != NULL) {
- if (saddr->sadb_address_proto)
- printf("%s ", STR_OR_ID(saddr->sadb_address_proto, ipproto));
-
- s = (struct sockaddr *)(saddr + 1);
- getnameinfo(s, s->sa_len, buf, sizeof(buf),
- pbuf, sizeof(pbuf), NI_NUMERICHOST|NI_NUMERICSERV);
- if (strcmp(pbuf, "0") != 0)
- printf("%s[%s]", buf, pbuf);
- else
- printf("%s", buf);
- } else
- printf("?");
-
- printf("\n");
-}
diff --git a/sbin/setkey/test-pfkey.c b/sbin/setkey/test-pfkey.c
deleted file mode 100644
index 849aba355a99..000000000000
--- a/sbin/setkey/test-pfkey.c
+++ /dev/null
@@ -1,480 +0,0 @@
-/*
- * Copyright (C) 1995, 1996, 1997, 1998, and 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:
- * 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 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
- * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT 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.
- *
- * $FreeBSD$
- */
-/* KAME $Id: test-pfkey.c,v 1.2 1999/10/26 08:09:17 itojun Exp $ */
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/socket.h>
-#include <net/route.h>
-#include <net/pfkeyv2.h>
-#include <netinet/in.h>
-#include <netkey/keydb.h>
-#include <netkey/key_var.h>
-#include <netkey/key_debug.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <limits.h>
-#include <string.h>
-#include <ctype.h>
-#include <unistd.h>
-#include <errno.h>
-
-u_char m_buf[BUFSIZ];
-u_int m_len;
-char *pname;
-
-void Usage __P((void));
-int sendkeymsg __P((void));
-void key_setsadbmsg __P((u_int));
-void key_setsadbsens __P((void));
-void key_setsadbprop __P((void));
-void key_setsadbid __P((u_int, caddr_t));
-void key_setsadblft __P((u_int, u_int));
-void key_setspirange __P((void));
-void key_setsadbkey __P((u_int, caddr_t));
-void key_setsadbsa __P((void));
-void key_setsadbaddr __P((u_int, u_int, caddr_t));
-void key_setsadbextbuf __P((caddr_t, int, caddr_t, int, caddr_t, int));
-
-void
-Usage()
-{
- printf("Usage:\t%s number\n", pname);
- exit(0);
-}
-
-int
-main(ac, av)
- int ac;
- char **av;
-{
- pname = *av;
-
- if (ac == 1) Usage();
-
- key_setsadbmsg(atoi(*(av+1)));
- sendkeymsg();
-
- exit(0);
-}
-
-/* %%% */
-int
-sendkeymsg()
-{
- u_char rbuf[1024 * 32]; /* XXX: Enough ? Should I do MSG_PEEK ? */
- int so, len;
-
- if ((so = socket(PF_KEY, SOCK_RAW, PF_KEY_V2)) < 0) {
- perror("socket(PF_KEY)");
- goto end;
- }
-
- pfkey_sadump((struct sadb_msg *)m_buf);
-
- if ((len = send(so, m_buf, m_len, 0)) < 0) {
- perror("send");
- goto end;
- }
-
- if ((len = recv(so, rbuf, sizeof(rbuf), 0)) < 0) {
- perror("recv");
- goto end;
- }
-
- pfkey_sadump((struct sadb_msg *)rbuf);
-
-end:
- (void)close(so);
- return(0);
-}
-
-void
-key_setsadbmsg(type)
- u_int type;
-{
- struct sadb_msg m_msg;
-
- m_msg.sadb_msg_version = PF_KEY_V2;
- m_msg.sadb_msg_type = type;
- m_msg.sadb_msg_errno = 0;
- m_msg.sadb_msg_satype = SADB_SATYPE_ESP;
- m_msg.sadb_msg_reserved = 0;
- m_msg.sadb_msg_seq = 0;
- m_msg.sadb_msg_pid = getpid();
-
- m_len = sizeof(struct sadb_msg);
- memcpy(m_buf, &m_msg, m_len);
-
- switch (type) {
- case SADB_GETSPI:
- /*<base, address(SD), SPI range>*/
- key_setsadbaddr(SADB_EXT_ADDRESS_SRC, AF_INET, "10.0.3.4");
- key_setsadbaddr(SADB_EXT_ADDRESS_DST, AF_INET, "127.0.0.1");
- key_setspirange();
- /*<base, SA(*), address(SD)>*/
- break;
-
- case SADB_ADD:
- /* <base, SA, (lifetime(HSC),) address(SD), (address(P),)
- key(AE), (identity(SD),) (sensitivity)> */
- key_setsadbaddr(SADB_EXT_ADDRESS_PROXY, AF_INET6, "3ffe::1");
- case SADB_UPDATE:
- key_setsadbsa();
- key_setsadblft(SADB_EXT_LIFETIME_HARD, 10);
- key_setsadblft(SADB_EXT_LIFETIME_SOFT, 5);
- key_setsadbaddr(SADB_EXT_ADDRESS_SRC, AF_INET, "192.168.1.1");
- key_setsadbaddr(SADB_EXT_ADDRESS_DST, AF_INET, "10.0.3.4");
- /* XXX key_setsadbkey(SADB_EXT_KEY_AUTH, "abcde"); */
- key_setsadbkey(SADB_EXT_KEY_AUTH, "1234567812345678");
- key_setsadbkey(SADB_EXT_KEY_ENCRYPT, "12345678");
- key_setsadbid(SADB_EXT_IDENTITY_SRC, "hoge1234@hoge.com");
- key_setsadbid(SADB_EXT_IDENTITY_DST, "hage5678@hage.net");
- key_setsadbsens();
- /* <base, SA, (lifetime(HSC),) address(SD), (address(P),)
- (identity(SD),) (sensitivity)> */
- break;
-
- case SADB_DELETE:
- /* <base, SA(*), address(SDP)> */
- key_setsadbsa();
- key_setsadbaddr(SADB_EXT_ADDRESS_SRC, AF_INET, "192.168.1.1");
- key_setsadbaddr(SADB_EXT_ADDRESS_DST, AF_INET, "10.0.3.4");
- key_setsadbaddr(SADB_EXT_ADDRESS_PROXY, AF_INET6, "3ffe::1");
- /* <base, SA(*), address(SDP)> */
- break;
-
- case SADB_GET:
- /* <base, SA(*), address(SDP)> */
- key_setsadbsa();
- key_setsadbaddr(SADB_EXT_ADDRESS_SRC, AF_INET, "192.168.1.1");
- key_setsadbaddr(SADB_EXT_ADDRESS_DST, AF_INET, "10.0.3.4");
- key_setsadbaddr(SADB_EXT_ADDRESS_PROXY, AF_INET6, "3ffe::1");
- /* <base, SA, (lifetime(HSC),) address(SD), (address(P),)
- key(AE), (identity(SD),) (sensitivity)> */
- break;
-
- case SADB_ACQUIRE:
- /* <base, address(SD), (address(P),) (identity(SD),)
- (sensitivity,) proposal> */
- key_setsadbaddr(SADB_EXT_ADDRESS_SRC, AF_INET, "192.168.1.1");
- key_setsadbaddr(SADB_EXT_ADDRESS_DST, AF_INET, "10.0.3.4");
- key_setsadbaddr(SADB_EXT_ADDRESS_PROXY, AF_INET6, "3ffe::1");
- key_setsadbid(SADB_EXT_IDENTITY_SRC, "hoge1234@hoge.com");
- key_setsadbid(SADB_EXT_IDENTITY_DST, "hage5678@hage.net");
- key_setsadbsens();
- key_setsadbprop();
- /* <base, address(SD), (address(P),) (identity(SD),)
- (sensitivity,) proposal> */
- break;
-
- case SADB_REGISTER:
- /* <base> */
- /* <base, supported> */
- break;
-
- case SADB_EXPIRE:
- case SADB_FLUSH:
- break;
-
- case SADB_DUMP:
- break;
-
- case SADB_X_PROMISC:
- /* <base> */
- /* <base, base(, others)> */
- break;
-
- case SADB_X_PCHANGE:
- break;
-
- /* for SPD management */
- case SADB_X_SPDFLUSH:
- case SADB_X_SPDDUMP:
- break;
-
- case SADB_X_SPDADD:
- case SADB_X_SPDDELETE:
- key_setsadbaddr(SADB_EXT_ADDRESS_SRC, AF_INET, "192.168.1.1");
- key_setsadbaddr(SADB_EXT_ADDRESS_DST, AF_INET, "10.0.3.4");
- break;
- }
-
- ((struct sadb_msg *)m_buf)->sadb_msg_len = PFKEY_UNIT64(m_len);
-
- return;
-}
-
-void
-key_setsadbsens()
-{
- struct sadb_sens m_sens;
- u_char buf[64];
- u_int s, i, slen, ilen, len;
-
- /* make sens & integ */
- s = htonl(0x01234567);
- i = htonl(0x89abcdef);
- slen = sizeof(s);
- ilen = sizeof(i);
- memcpy(buf, &s, slen);
- memcpy(buf + slen, &i, ilen);
-
- len = sizeof(m_sens) + PFKEY_ALIGN8(slen) + PFKEY_ALIGN8(ilen);
- m_sens.sadb_sens_len = PFKEY_UNIT64(len);
- m_sens.sadb_sens_exttype = SADB_EXT_SENSITIVITY;
- m_sens.sadb_sens_dpd = 1;
- m_sens.sadb_sens_sens_level = 2;
- m_sens.sadb_sens_sens_len = PFKEY_ALIGN8(slen);
- m_sens.sadb_sens_integ_level = 3;
- m_sens.sadb_sens_integ_len = PFKEY_ALIGN8(ilen);
- m_sens.sadb_sens_reserved = 0;
-
- key_setsadbextbuf(m_buf, m_len,
- (caddr_t)&m_sens, sizeof(struct sadb_sens),
- buf, slen + ilen);
- m_len += len;
-
- return;
-}
-
-void
-key_setsadbprop()
-{
- struct sadb_prop m_prop;
- struct sadb_comb *m_comb;
- u_char buf[256];
- u_int len = sizeof(m_prop) + sizeof(m_comb) * 2;
-
- /* make prop & comb */
- m_prop.sadb_prop_len = PFKEY_UNIT64(len);
- m_prop.sadb_prop_exttype = SADB_EXT_PROPOSAL;
- m_prop.sadb_prop_replay = 0;
- m_prop.sadb_prop_reserved[0] = 0;
- m_prop.sadb_prop_reserved[1] = 0;
- m_prop.sadb_prop_reserved[2] = 0;
-
- /* the 1st is ESP DES-CBC HMAC-MD5 */
- m_comb = (struct sadb_comb *)buf;
- m_comb->sadb_comb_auth = SADB_AALG_MD5HMAC;
- m_comb->sadb_comb_encrypt = SADB_EALG_DESCBC;
- m_comb->sadb_comb_flags = 0;
- m_comb->sadb_comb_auth_minbits = 8;
- m_comb->sadb_comb_auth_maxbits = 96;
- m_comb->sadb_comb_encrypt_minbits = 64;
- m_comb->sadb_comb_encrypt_maxbits = 64;
- m_comb->sadb_comb_reserved = 0;
- m_comb->sadb_comb_soft_allocations = 0;
- m_comb->sadb_comb_hard_allocations = 0;
- m_comb->sadb_comb_soft_bytes = 0;
- m_comb->sadb_comb_hard_bytes = 0;
- m_comb->sadb_comb_soft_addtime = 0;
- m_comb->sadb_comb_hard_addtime = 0;
- m_comb->sadb_comb_soft_usetime = 0;
- m_comb->sadb_comb_hard_usetime = 0;
-
- /* the 2st is ESP 3DES-CBC and AH HMAC-SHA1 */
- m_comb = (struct sadb_comb *)(buf + sizeof(*m_comb));
- m_comb->sadb_comb_auth = SADB_AALG_SHA1HMAC;
- m_comb->sadb_comb_encrypt = SADB_EALG_3DESCBC;
- m_comb->sadb_comb_flags = 0;
- m_comb->sadb_comb_auth_minbits = 8;
- m_comb->sadb_comb_auth_maxbits = 96;
- m_comb->sadb_comb_encrypt_minbits = 64;
- m_comb->sadb_comb_encrypt_maxbits = 64;
- m_comb->sadb_comb_reserved = 0;
- m_comb->sadb_comb_soft_allocations = 0;
- m_comb->sadb_comb_hard_allocations = 0;
- m_comb->sadb_comb_soft_bytes = 0;
- m_comb->sadb_comb_hard_bytes = 0;
- m_comb->sadb_comb_soft_addtime = 0;
- m_comb->sadb_comb_hard_addtime = 0;
- m_comb->sadb_comb_soft_usetime = 0;
- m_comb->sadb_comb_hard_usetime = 0;
-
- key_setsadbextbuf(m_buf, m_len,
- (caddr_t)&m_prop, sizeof(struct sadb_prop),
- buf, sizeof(*m_comb) * 2);
- m_len += len;
-
- return;
-}
-
-void
-key_setsadbid(ext, str)
- u_int ext;
- caddr_t str;
-{
- struct sadb_ident m_id;
- u_int idlen = strlen(str), len;
-
- len = sizeof(m_id) + PFKEY_ALIGN8(idlen);
- m_id.sadb_ident_len = PFKEY_UNIT64(len);
- m_id.sadb_ident_exttype = ext;
- m_id.sadb_ident_type = SADB_IDENTTYPE_USERFQDN;
- m_id.sadb_ident_reserved = 0;
- m_id.sadb_ident_id = getpid();
-
- key_setsadbextbuf(m_buf, m_len,
- (caddr_t)&m_id, sizeof(struct sadb_ident),
- str, idlen);
- m_len += len;
-
- return;
-}
-
-void
-key_setsadblft(ext, time)
- u_int ext, time;
-{
- struct sadb_lifetime m_lft;
-
- m_lft.sadb_lifetime_len = PFKEY_UNIT64(sizeof(m_lft));
- m_lft.sadb_lifetime_exttype = ext;
- m_lft.sadb_lifetime_allocations = 0x2;
- m_lft.sadb_lifetime_bytes = 0x1000;
- m_lft.sadb_lifetime_addtime = time;
- m_lft.sadb_lifetime_usetime = 0x0020;
-
- memcpy(m_buf + m_len, &m_lft, sizeof(struct sadb_lifetime));
- m_len += sizeof(struct sadb_lifetime);
-
- return;
-}
-
-void
-key_setspirange()
-{
- struct sadb_spirange m_spi;
-
- m_spi.sadb_spirange_len = PFKEY_UNIT64(sizeof(m_spi));
- m_spi.sadb_spirange_exttype = SADB_EXT_SPIRANGE;
- m_spi.sadb_spirange_min = 0x00001000;
- m_spi.sadb_spirange_max = 0x00002000;
- m_spi.sadb_spirange_reserved = 0;
-
- memcpy(m_buf + m_len, &m_spi, sizeof(struct sadb_spirange));
- m_len += sizeof(struct sadb_spirange);
-
- return;
-}
-
-void
-key_setsadbkey(ext, str)
- u_int ext;
- caddr_t str;
-{
- struct sadb_key m_key;
- u_int keylen = strlen(str);
- u_int len;
-
- len = sizeof(struct sadb_key) + PFKEY_ALIGN8(keylen);
- m_key.sadb_key_len = PFKEY_UNIT64(len);
- m_key.sadb_key_exttype = ext;
- m_key.sadb_key_bits = keylen * 8;
- m_key.sadb_key_reserved = 0;
-
- key_setsadbextbuf(m_buf, m_len,
- (caddr_t)&m_key, sizeof(struct sadb_key),
- str, keylen);
- m_len += len;
-
- return;
-}
-
-void
-key_setsadbsa()
-{
- struct sadb_sa m_sa;
-
- m_sa.sadb_sa_len = PFKEY_UNIT64(sizeof(struct sadb_sa));
- m_sa.sadb_sa_exttype = SADB_EXT_SA;
- m_sa.sadb_sa_spi = htonl(0x12345678);
- m_sa.sadb_sa_replay = 4;
- m_sa.sadb_sa_state = 0;
- m_sa.sadb_sa_auth = SADB_AALG_MD5HMAC;
- m_sa.sadb_sa_encrypt = SADB_EALG_DESCBC;
- m_sa.sadb_sa_flags = 0;
-
- memcpy(m_buf + m_len, &m_sa, sizeof(struct sadb_sa));
- m_len += sizeof(struct sadb_sa);
-
- return;
-}
-
-void
-key_setsadbaddr(ext, af, str)
- u_int ext, af;
- caddr_t str;
-{
- struct sadb_address m_addr;
- u_char abuf[64];
- struct sockaddr *a = (struct sockaddr *)abuf;
- u_int len;
-
- /* make sockaddr buffer */
- memset(abuf, 0, sizeof(abuf));
- a->sa_len = _SALENBYAF(af);
- a->sa_family = af;
- _INPORTBYSA(a) =
- (ext == SADB_EXT_ADDRESS_PROXY ? 0 : htons(0x1234));
- if (inet_pton(af, str, _INADDRBYSA(a)) != 1)
- ; /* XXX do something */
-
- len = sizeof(struct sadb_address) + PFKEY_ALIGN8(a->sa_len);
- m_addr.sadb_address_len = PFKEY_UNIT64(len);
- m_addr.sadb_address_exttype = ext;
- m_addr.sadb_address_proto =
- (ext == SADB_EXT_ADDRESS_PROXY ? 0 : IPPROTO_TCP);
- m_addr.sadb_address_prefixlen = _INALENBYAF(af);
- m_addr.sadb_address_reserved = 0;
-
- key_setsadbextbuf(m_buf, m_len,
- (caddr_t)&m_addr, sizeof(struct sadb_address),
- abuf, a->sa_len);
- m_len += len;
-
- return;
-}
-
-void
-key_setsadbextbuf(dst, off, ebuf, elen, vbuf, vlen)
- caddr_t dst, ebuf, vbuf;
- int off, elen, vlen;
-{
- memset(dst + off, 0, elen + vlen);
- memcpy(dst + off, (caddr_t)ebuf, elen);
- memcpy(dst + off + elen, vbuf, vlen);
-
- return;
-}
-
diff --git a/sbin/setkey/test-policy.c b/sbin/setkey/test-policy.c
deleted file mode 100644
index 27cd478fc939..000000000000
--- a/sbin/setkey/test-policy.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright (C) 1995, 1996, 1997, 1998, and 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:
- * 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 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
- * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netinet6/in6.h>
-#include <netkey/keyv2.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <netinet6/ipsec.h>
-
-char *requests[] = {
-"must_error", /* must be error */
-"ipsec must_error", /* must be error */
-"ipsec esp/must_error", /* must be error */
-"discard",
-"none",
-"entrust",
-"bypass", /* may be error */
-"ipsec esp", /* must be error */
-"ipsec ah/require",
-"ipsec ah/use/",
-"ipsec esp/require ah/default/203.178.141.194",
-"ipsec ah/use/203.178.141.195 esp/use/203.178.141.194",
-"ipsec esp/elf.wide.ydc.co.jp esp/www.wide.ydc.co.jp"
-"
-ipsec esp/require ah/use esp/require/10.0.0.1
-ah/use/3ffe:501:481d::1 ah/use/3ffe:501:481d::1 ah/use/3ffe:501:481d::1
-ah/use/3ffe:501:481d::1 ah/use/3ffe:501:481d::1 ah/use/3ffe:501:481d::1
-ah/use/3ffe:501:481d::1 ah/use/3ffe:501:481d::1 ah/use/3ffe:501:481d::1
-ah/use/3ffe:501:481d::1 ah/use/3ffe:501:481d::1 ah/use/3ffe:501:481d::1
-ah/use/3ffe:501:481d::1 ah/use/3ffe:501:481d::1 ah/use/3ffe:501:481d::1
-ah/use/3ffe:501:481d::1 ah/use/3ffe:501:481d::1 ah/use/3ffe:501:481d::1
-ah/use/3ffe:501:481d::1 ah/use/3ffe:501:481d::1 ah/use/3ffe:501:481d::1
-ah/use/3ffe:501:481d::1 ah/use/3ffe:501:481d::1ah/use/3ffe:501:481d::1
-",
-};
-
-u_char *p_secpolicy;
-
-int test(char *buf, int family);
-char *setpolicy(char *req);
-
-main()
-{
- int i;
- char *buf;
-
- for (i = 0; i < sizeof(requests)/sizeof(requests[0]); i++) {
- printf("* requests:[%s]\n", requests[i]);
- if ((buf = setpolicy(requests[i])) == NULL)
- continue;
- printf("\tsetlen:%d\n", PFKEY_EXTLEN(buf));
-
- printf("\tPF_INET:\n");
- test(buf, PF_INET);
-
- printf("\tPF_INET6:\n");
- test(buf, PF_INET6);
- free(buf);
- }
-}
-
-int test(char *policy, int family)
-{
- int so, proto, optname;
- int len;
- char getbuf[1024];
-
- switch (family) {
- case PF_INET:
- proto = IPPROTO_IP;
- optname = IP_IPSEC_POLICY;
- break;
- case PF_INET6:
- proto = IPPROTO_IPV6;
- optname = IPV6_IPSEC_POLICY;
- break;
- }
-
- if ((so = socket(family, SOCK_DGRAM, 0)) < 0)
- perror("socket");
-
- if (setsockopt(so, proto, optname, policy, PFKEY_EXTLEN(policy)) < 0)
- perror("setsockopt");
-
- len = sizeof(getbuf);
- memset(getbuf, 0, sizeof(getbuf));
- if (getsockopt(so, proto, optname, getbuf, &len) < 0)
- perror("getsockopt");
-
- {
- char *buf = NULL;
-
- printf("\tgetlen:%d\n", len);
-
- if ((buf = ipsec_dump_policy(getbuf, NULL)) == NULL)
- ipsec_strerror();
- else
- printf("\t[%s]\n", buf);
-
- free(buf);
- }
-
- close (so);
-}
-
-char *setpolicy(char *req)
-{
- int len;
- char *buf;
-
- if ((len = ipsec_get_policylen(req)) < 0) {
- printf("ipsec_get_policylen: %s\n", ipsec_strerror());
- return NULL;
- }
-
- if ((buf = malloc(len)) == NULL) {
- perror("malloc");
- return NULL;
- }
-
- if ((len = ipsec_set_policy(buf, len, req)) < 0) {
- printf("ipsec_set_policy: %s\n", ipsec_strerror());
- free(buf);
- return NULL;
- }
-
- return buf;
-}
diff --git a/sbin/setkey/token.l b/sbin/setkey/token.l
deleted file mode 100644
index 0154beef4388..000000000000
--- a/sbin/setkey/token.l
+++ /dev/null
@@ -1,322 +0,0 @@
-/*
- * Copyright (C) 1995, 1996, 1997, 1998, and 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:
- * 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 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
- * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT 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.
- *
- * $FreeBSD$
- */
-
-%{
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/socket.h>
-#include <net/route.h>
-#include <net/pfkeyv2.h>
-#include <netkey/keydb.h>
-#include <netkey/key_debug.h>
-#include <netinet/in.h>
-#include <netinet6/ipsec.h>
-
-#include <stdlib.h>
-#include <limits.h>
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-#include "vchar.h"
-#include "y.tab.h"
-
-#define DECHO \
- if (f_debug) {printf("<%d>", yy_start); ECHO ; printf("\n"); }
-
-#define CMDARG \
-{ \
- char *__buf__ = strdup(yytext), *__p__; \
- for (__p__ = __buf__; *__p__ != NULL; __p__++) \
- if (*__p__ == '\n' || *__p__ == '\t') \
- *__p__ = ' '; \
- strcat(cmdarg, __buf__); \
- free(__buf__); \
-}
-
-#define PREPROC DECHO CMDARG
-
-int lineno = 1;
-char cmdarg[8192]; /* XXX: BUFSIZ is the better ? */
-
-extern u_char m_buf[BUFSIZ];
-extern u_int m_len;
-extern int f_debug;
-
-int yylex __P((void));
-void yyerror __P((char *s));
-extern void parse_init __P((void));
-int parse __P((FILE **));
-int yyparse __P((void));
-
-%}
-
-/* common section */
-nl \n
-ws [ \t]+
-digit [0-9]
-letter [0-9A-Za-z]
-hexdigit [0-9A-Fa-f]
-/*octet (([01]?{digit}?{digit})|((2([0-4]{digit}))|(25[0-5])))*/
-special [()+\|\?\*,]
-dot \.
-comma \,
-hyphen \-
-colon \:
-slash \/
-bcl \{
-ecl \}
-blcl \[
-elcl \]
-percent \%
-semi \;
-usec {dot}{digit}{1,6}
-comment \#.*
-ccomment "/*"
-bracketstring \<[^>]*\>
-quotedstring \"[^"]*\"
-decstring {digit}+
-hexpair {hexdigit}{hexdigit}
-hexstring 0[xX]{hexdigit}+
-octetstring {octet}({dot}{octet})+
-ipaddress {ipv4addr}|{ipv6addr}
-ipv4addr {digit}{1,3}({dot}{digit}{1,3}){0,3}
-ipv6addr {hexdigit}{0,4}({colon}{hexdigit}{0,4}){2,7}(%{letter}{letter}+)?
-ipaddrmask {slash}{digit}{1,3}
-ipaddrport {blcl}{decstring}{elcl}
-keyword {letter}{letter}+
-name {letter}(({letter}|{digit}|{hyphen})*({letter}|{digit}))*
-hostname {name}(({dot}{name})+{dot}?)?
-
-%s S_PL
-
-%%
-
-add { PREPROC; return(ADD); }
-delete { PREPROC; return(DELETE); }
-get { PREPROC; return(GET); }
-flush { PREPROC; return(FLUSH); }
-dump { PREPROC; return(DUMP); }
-
- /* for management SPD */
-spdadd { PREPROC; return(SPDADD); }
-spddelete { PREPROC; return(SPDDELETE); }
-spddump { PREPROC; return(SPDDUMP); }
-spdflush { PREPROC; return(SPDFLUSH); }
-{hyphen}P { BEGIN S_PL; PREPROC; return(F_POLICY); }
-<S_PL>[a-zA-Z0-9:\.\-_/ \n\t][a-zA-Z0-9:\.\-_/ \n\t]* {
- yymore();
-
- /* count up for nl */
- {
- char *p;
- for (p = yytext; *p != NULL; p++)
- if (*p == '\n')
- lineno++;
- }
-
- yylval.val.len = strlen(yytext);
- yylval.val.buf = strdup(yytext);
-
- return(PL_REQUESTS);
-}
-<S_PL>{semi} { PREPROC; BEGIN INITIAL; return(EOT); }
-
- /* security protocols */
-ah { PREPROC; yylval.num = 0; return(PR_AH); }
-esp { PREPROC; yylval.num = 0; return(PR_ESP); }
-ah-old { PREPROC; yylval.num = 1; return(PR_AH); }
-esp-old { PREPROC; yylval.num = 1; return(PR_ESP); }
-ipcomp { PREPROC; yylval.num = 0; return(PR_IPCOMP); }
-
- /* authentication alogorithm */
-{hyphen}A { PREPROC; return(F_AUTH); }
-hmac-md5 { PREPROC; yylval.num = SADB_AALG_MD5HMAC; return(ALG_AUTH); }
-hmac-sha1 { PREPROC; yylval.num = SADB_AALG_SHA1HMAC; return(ALG_AUTH); }
-keyed-md5 { PREPROC; yylval.num = SADB_AALG_MD5; return(ALG_AUTH); }
-keyed-sha1 { PREPROC; yylval.num = SADB_AALG_SHA; return(ALG_AUTH); }
-null { PREPROC; yylval.num = SADB_AALG_NULL; return(ALG_AUTH); }
-
- /* encryption alogorithm */
-{hyphen}E { PREPROC; return(F_ENC); }
-des-cbc { PREPROC; yylval.num = SADB_EALG_DESCBC; return(ALG_ENC); }
-3des-cbc { PREPROC; yylval.num = SADB_EALG_3DESCBC; return(ALG_ENC); }
-simple { PREPROC; yylval.num = SADB_EALG_NULL; return(ALG_ENC); }
-blowfish-cbc { PREPROC; yylval.num = SADB_EALG_BLOWFISHCBC; return(ALG_ENC); }
-cast128-cbc { PREPROC; yylval.num = SADB_EALG_CAST128CBC; return(ALG_ENC); }
-rc5-cbc { PREPROC; yylval.num = SADB_EALG_RC5CBC; return(ALG_ENC); }
-des-deriv { PREPROC; yylval.num = SADB_EALG_DESCBC; return(ALG_ENC_DESDERIV); }
-des-32iv { PREPROC; yylval.num = SADB_EALG_DESCBC; return(ALG_ENC_DES32IV); }
-
- /* compression algorithms */
-{hyphen}C { PREPROC; return(F_COMP); }
-oui { PREPROC; yylval.num = SADB_X_CALG_OUI; return(ALG_COMP); }
-deflate { PREPROC; yylval.num = SADB_X_CALG_DEFLATE; return(ALG_COMP); }
-lzs { PREPROC; yylval.num = SADB_X_CALG_LZS; return(ALG_COMP); }
-{hyphen}R { PREPROC; return(F_RAWCPI); }
-
- /* extension */
-{hyphen}m { PREPROC; return(F_MODE); }
-transport { PREPROC; yylval.num = IPSEC_MODE_TRANSPORT; return(MODE); }
-tunnel { PREPROC; yylval.num = IPSEC_MODE_TUNNEL; return(MODE); }
-{hyphen}f { PREPROC; return(F_EXT); }
-random-pad { PREPROC; yylval.num = SADB_X_EXT_PRAND; return(EXTENSION); }
-seq-pad { PREPROC; yylval.num = SADB_X_EXT_PSEQ; return(EXTENSION); }
-zero-pad { PREPROC; yylval.num = SADB_X_EXT_PZERO; return(EXTENSION); }
-cyclic-seq { PREPROC; yylval.num = SADB_X_EXT_CYCSEQ; return(EXTENSION); }
-{hyphen}r { PREPROC; return(F_REPLAY); }
-{hyphen}lh { PREPROC; return(F_LIFETIME_HARD); }
-{hyphen}ls { PREPROC; return(F_LIFETIME_SOFT); }
-
-
- /* upper layer protocols */
-icmp { PREPROC; yylval.num = IPPROTO_ICMP; return(UP_PROTO); }
-icmp6 { PREPROC; yylval.num = IPPROTO_ICMPV6; return(UP_PROTO); }
-tcp { PREPROC; yylval.num = IPPROTO_TCP; return(UP_PROTO); }
-udp { PREPROC; yylval.num = IPPROTO_UDP; return(UP_PROTO); }
-
- /* ... */
-any { PREPROC; return(ANY); }
-{ws} { PREPROC; }
-{nl} { lineno++; }
-{comment}
-{semi} { PREPROC; return(EOT); }
-
- /* parameter */
-{decstring} {
- char *bp;
-
- PREPROC;
- yylval.num = strtol(yytext, &bp, 10);
- return(DECSTRING);
- }
-
-{ipv4addr} {
- /*
- * I can't supprt the type without dot,
- * because it's umbiguous against {decstring}.
- * e.g. 127
- */
- PREPROC;
-
- yylval.val.len = sizeof(struct sockaddr_in);
- yylval.val.buf = strdup(yytext);
-
- return(IP4_ADDRESS);
- }
-
-{ipv6addr} {
-#ifdef INET6
- PREPROC;
-
- yylval.val.len = sizeof(struct sockaddr_in6);
- yylval.val.buf = strdup(yytext);
-
- return(IP6_ADDRESS);
-#else
- yyerror("IPv6 address not supported");
-#endif
- }
-
-{ipaddrmask} {
- PREPROC;
- yytext++;
- yylval.num = atoi(yytext);
- return(PREFIX);
- }
-
-{ipaddrport} {
- char *p = yytext;
- PREPROC;
- while (*++p != ']') ;
- *p = NULL;
- yytext++;
- yylval.num = atoi(yytext);
- return(PORT);
- }
-
-{blcl}any{elcl} {
- char *p = yytext;
- PREPROC;
- return(PORTANY);
- }
-
-{hexstring} {
- int len = yyleng - 2; /* (str - "0x") */
- PREPROC;
- yylval.val.len = (len & 1) + (len / 2);
- /* fixed string if length is odd. */
- if (len & 1) {
- yytext[1] = '0';
- yylval.val.buf = strdup(yytext + 1);
- } else
- yylval.val.buf = strdup(yytext + 2);
-
- return(HEXSTRING);
- }
-
-{quotedstring} {
- char *p = yytext;
- PREPROC;
- while (*++p != '"') ;
- *p = NULL;
- yytext++;
- yylval.val.len = yyleng - 2;
- yylval.val.buf = strdup(yytext);
-
- return(QUOTEDSTRING);
- }
-
-. { yyerror("Syntax error"); }
-
-%%
-
-void
-yyerror(char *s)
-{
- printf("line %d: %s at [%s]\n", lineno, s, yytext);
-}
-
-int
-parse(fp)
- FILE **fp;
-{
- yyin = *fp;
-
- parse_init();
-
- if (yyparse()) {
- printf("parse failed, line %d.\n", lineno);
- return(-1);
- }
-
- return(0);
-}
-
diff --git a/sbin/setkey/vchar.h b/sbin/setkey/vchar.h
deleted file mode 100644
index 977f5f0f60d4..000000000000
--- a/sbin/setkey/vchar.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 1995, 1996, 1997, 1998, and 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:
- * 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 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
- * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT 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.
- *
- * $FreeBSD$
- */
-
-typedef struct {
- u_int len;
- caddr_t buf;
-} vchar_t;
diff --git a/secure/lib/libcrypto/opensslconf-amd64.h b/secure/lib/libcrypto/opensslconf-amd64.h
deleted file mode 100644
index 03894d577ae2..000000000000
--- a/secure/lib/libcrypto/opensslconf-amd64.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/* $FreeBSD$ */
-
-/* crypto/opensslconf.h */
-/* WARNING: This file is autogenerated by Configure */
-
-/* Generate 80386 code? */
-#undef I386_ONLY
-
-#if !(defined(VMS) || defined(__VMS)) /* VMS uses logical names instead */
-#if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR)
-#define OPENSSLDIR "/usr/local/ssl"
-#endif
-#endif
-
-#define OPENSSL_UNISTD <unistd.h>
-
-#if defined(HEADER_IDEA_H) && !defined(IDEA_INT)
-#define IDEA_INT unsigned int
-#endif
-
-#if defined(HEADER_MD2_H) && !defined(MD2_INT)
-#define MD2_INT unsigned int
-#endif
-
-#if defined(HEADER_RC2_H) && !defined(RC2_INT)
-/* I need to put in a mod for the alpha - eay */
-#define RC2_INT unsigned int
-#endif
-
-#if defined(HEADER_RC4_H) && !defined(RC4_INT)
-/* using int types make the structure larger but make the code faster
- * on most boxes I have tested - up to %20 faster. */
-#define RC4_INT unsigned int
-#endif
-
-#if defined(HEADER_DES_H) && !defined(DES_LONG)
-/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
- * %20 speed up (longs are 8 bytes, int's are 4). */
-#ifndef DES_LONG
-#define DES_LONG unsigned int
-#endif
-#endif
-
-#if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H)
-#define CONFIG_HEADER_BN_H
-#undef BN_LLONG
-
-/* Should we define BN_DIV2W here? */
-
-/* Only one for the following should be defined */
-/* The prime number generation stuff may not work when
- * EIGHT_BIT but I don't care since I've only used this mode
- * for debuging the bignum libraries */
-#define SIXTY_FOUR_BIT_LONG
-#undef SIXTY_FOUR_BIT
-#undef THIRTY_TWO_BIT
-#undef SIXTEEN_BIT
-#undef EIGHT_BIT
-#endif
-
-#if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H)
-#define CONFIG_HEADER_RC4_LOCL_H
-/* if this is defined data[i] is used instead of *data, this is a %20
- * speedup on x86 */
-#undef RC4_INDEX
-#endif
-
-#if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H)
-#define CONFIG_HEADER_BF_LOCL_H
-#undef BF_PTR
-#endif /* HEADER_BF_LOCL_H */
-
-#if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H)
-#define CONFIG_HEADER_DES_LOCL_H
-#ifndef DES_DEFAULT_OPTIONS
-/* the following is tweaked from a config script, that is why it is a
- * protected undef/define */
-#ifndef DES_PTR
-#define DES_PTR
-#endif
-
-/* This helps C compiler generate the correct code for multiple functional
- * units. It reduces register dependancies at the expense of 2 more
- * registers */
-#ifndef DES_RISC1
-#undef DES_RISC1
-#endif
-
-#ifndef DES_RISC2
-#define DES_RISC2
-#endif
-
-#if defined(DES_RISC1) && defined(DES_RISC2)
-YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!
-#endif
-
-/* Unroll the inner loop, this sometimes helps, sometimes hinders.
- * Very mucy CPU dependant */
-#ifndef DES_UNROLL
-#undef DES_UNROLL
-#endif
-
-/* These default values were supplied by
- * Peter Gutman <pgut001@cs.auckland.ac.nz>
- * They are only used if nothing else has been defined */
-#if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL)
-/* Special defines which change the way the code is built depending on the
- CPU and OS. For SGI machines you can use _MIPS_SZLONG (32 or 64) to find
- even newer MIPS CPU's, but at the moment one size fits all for
- optimization options. Older Sparc's work better with only UNROLL, but
- there's no way to tell at compile time what it is you're running on */
-
-#if defined( sun ) /* Newer Sparc's */
-# define DES_PTR
-# define DES_RISC1
-# define DES_UNROLL
-#elif defined( __ultrix ) /* Older MIPS */
-# define DES_PTR
-# define DES_RISC2
-# define DES_UNROLL
-#elif defined( __osf1__ ) /* Alpha */
-# define DES_PTR
-# define DES_RISC2
-#elif defined ( _AIX ) /* RS6000 */
- /* Unknown */
-#elif defined( __hpux ) /* HP-PA */
- /* Unknown */
-#elif defined( __aux ) /* 68K */
- /* Unknown */
-#elif defined( __dgux ) /* 88K (but P6 in latest boxes) */
-# define DES_UNROLL
-#elif defined( __sgi ) /* Newer MIPS */
-# define DES_PTR
-# define DES_RISC2
-# define DES_UNROLL
-#elif defined( i386 ) /* x86 boxes, should be gcc */
-# define DES_PTR
-# define DES_RISC1
-# define DES_UNROLL
-#endif /* Systems-specific speed defines */
-#endif
-
-#endif /* DES_DEFAULT_OPTIONS */
-#endif /* HEADER_DES_LOCL_H */
diff --git a/secure/usr.sbin/sendmail/Makefile b/secure/usr.sbin/sendmail/Makefile
deleted file mode 100644
index a1ea19470526..000000000000
--- a/secure/usr.sbin/sendmail/Makefile
+++ /dev/null
@@ -1,50 +0,0 @@
-# @(#)Makefile 8.8 (Berkeley) 3/28/97
-# $FreeBSD$
-
-SMDIR= ${.CURDIR}/../../contrib/sendmail/src
-.PATH: ${SMDIR}
-
-BINDIR?=/usr/libexec/sendmail
-
-PROG= sendmail
-
-# Define the database format to use for aliases et al.
-DBMDEF= -DNEWDB
-
-# If you don't want NIS alias/map support, comment out this line
-NIS= -DNIS
-
-# Map extensions
-MAPS= -DMAP_REGEX
-
-CFLAGS+=-I${SMDIR} ${DBMDEF} ${NIS} -DTCPWRAPPERS ${MAPS}
-CFLAGS+=-D_FFR_MAX_MIME_HEADER_LENGTH
-CFLAGS+=-D_FFR_MAX_HEADERS_LENGTH
-
-SRCS= alias.c arpadate.c clock.c collect.c conf.c control.c convtime.c \
- daemon.c deliver.c domain.c envelope.c err.c headers.c macro.c \
- main.c map.c mci.c mime.c parseaddr.c queue.c readcf.c recipient.c \
- safefile.c savemail.c snprintf.c srvrsmtp.c stab.c stats.c \
- sysexits.c trace.c udb.c usersmtp.c util.c version.c
-DPADD= ${LIBUTIL} ${LIBWRAP}
-LDADD= -lutil -lwrap
-MAN1= mailq.1 newaliases.1
-MAN5= aliases.5
-MAN8= sendmail.8
-BINMODE=4555
-
-beforeinstall:
- ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 644 /dev/null \
- ${DESTDIR}/var/log/sendmail.st
- ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 444 ${SMDIR}/sendmail.hf \
- ${DESTDIR}/usr/share/misc
-
-afterinstall:
- @if [ -d ${DESTDIR}/etc/mail -a -f ${DESTDIR}/etc/sendmail.cf -a \
- ! -f ${DESTDIR}/etc/mail/sendmail.cf ]; then \
- set -x; \
- mv -f ${DESTDIR}/etc/sendmail.cf \
- ${DESTDIR}/etc/mail/sendmail.cf; \
- fi
-
-.include <bsd.prog.mk>
diff --git a/share/colldef/cs_CZ.ISO8859-2.src b/share/colldef/cs_CZ.ISO8859-2.src
deleted file mode 100644
index e8392c7fc4fb..000000000000
--- a/share/colldef/cs_CZ.ISO8859-2.src
+++ /dev/null
@@ -1,52 +0,0 @@
-# Latin2 (for Czech; partially according to CSN 97 6030)
-# by Rudolf Cejka <cejkar@dcse.fee.vutbr.cz>
-#
-# $FreeBSD$
-#
-charmap map.ISO_8859-2
-substitute <ss> with "ss"
-order \
-# spaces
- <SP>;<NS>;\
-# capital and small
- (A,a,<A'>,<a'>,<A/>>,<a/>>,<A(>,<a(>,<A:>,<a:>,<A;>,<a;>);\
- (B,b);\
- (C,c,<C'>,<c'>,<C,>,<c,>);\
- (<C<>,<c<>);\
- (D,d,<D<>,<d<>,<D//>,<d//>);\
- (E,e,<E'>,<e'>,<E<>,<e<>,<E:>,<e:>,<E;>,<e;>);\
- (F,f);\
- (G,g);\
- (H,h);\
- (CH,Ch,ch);\
- (I,i,<I'>,<i'>,<I/>>,<i/>>);\
- (J,j);\
- (K,k);\
- (L,l,<L'>,<l'>,<L<>,<l<>,<L//>,<l//>);\
- (M,m);\
- (N,n,<N'>,<n'>,<N<>,<n<>);\
- (O,o,<O'>,<o'>,<O/>>,<o/>>,<O:>,<o:>,<O">,<o">);\
- (P,p);\
- (Q,q);\
- (R,r,<R'>,<r'>);\
- (<R<>,<r<>);\
- (S,s,<S'>,<s'>,<S,>,<s,>);\
- (<S<>,<s<>);\
- (T,t,<T<>,<t<>,<T,>,<t,>);\
- (U,u,<U'>,<u'>,<U0>,<u0>,<U:>,<u:>,<U">,<u">);\
- (V,v);\
- (W,w);\
- (X,x);\
- (Y,y,<Y'>,<y'>);\
- (Z,z,<Z.>,<z.>,<Z'>,<z'>);\
- (<Z<>,<z<>);\
-# digits
- 0;...;9;\
-# symbols
- .;\,;\;;?;!;:;';`;\";\
- <-->;-;|;/;\\;\(;\);[;];\<;>;\{;\};\
- &;<SE>;%;<DO>;<At>;\
- _;=;^;<-:>;+;<*X>;*;<Nb>;~;<DG>;<Cu>;\
- <'.>;<''>;<'<>;<'(>;<':>;<'">;<',>;<';>;\
-# controls
- <NU>;...;<US>;<DT>;<PA>;...;<AC>
diff --git a/share/colldef/de_DE.ISO8859-1.src b/share/colldef/de_DE.ISO8859-1.src
deleted file mode 100644
index 52d155d75a54..000000000000
--- a/share/colldef/de_DE.ISO8859-1.src
+++ /dev/null
@@ -1,39 +0,0 @@
-# German/ISO 8859-1 (backward compatible with ASCII)
-#
-# $FreeBSD$
-#
-charmap map.ISO_8859-1
-substitute <ss> with "ss"
-order \
-# controls
- <NU>;...;<US>;<PA>;...;<AC>;\
-#
- <NS>;<SP>;!;<!I>;\";<<<>;</>/>>;<Nb>;\
- <Cu>;<Ct>;<DO>;<Pd>;<Ye>;\
- %;&;<',>;';\(;\);*;+;<+->;<-:>;<*X>;\,;<-->;-;.;/;\
-# digits
- (0,<14>,<12>,<34>);(1,<1S>);(2,<2S>);(3,<3S>);4;...;9;\
-#
- :;\;;\<;=;>;?;<?I>;<SE>;<PI>;<Co>;<Rg>;<At>;\
-# capital
- (A,<A'>,<A!>,<A/>>,<AA>,<A:>,<A?>,<AE>);\
- B;(C,<C,>);D;(E,<E'>,<E!>,<E/>>,<E:>);\
- F;G;H;(I,<I'>,<I!>,<I/>>,<I:>);\
- J;...;M;(N,<N?>);(O,<O'>,<O!>,<O/>>,<O:>,<O?>,<O//>);\
- P;...;T;(U,<U'>,<U!>,<U/>>,<U:>);\
- V;W;X;(Y,<Y'>);Z;\
- <D->;<TH>;\
-#
- [;\\;];^;<':>;_;<'m>;<''>;`;\
-# small
- (a,<a'>,<a!>,<a/>>,<aa>,<a:>,<a?>,<ae>);\
- b;(c,<c,>);d;(e,<e'>,<e!>,<e/>>,<e:>);\
- f;g;h;(i,<i'>,<i!>,<i/>>,<i:>);\
- j;...;m;(n,<n?>);(o,<o'>,<o!>,<o/>>,<o:>,<o?>,<o//>);\
- p;...;t;(u,<u'>,<u!>,<u/>>,<u:>);\
- v;w;x;(y,<y'>,<y:>);z;\
- <d->;<th>;\
-#
- \{;<NO>;|;<BB>;\};~;<.M>;<DG>;<My>;<DT>;\
-# remains
- <-a>;<-o>
diff --git a/share/colldef/de_DE.ISO8859-15.src b/share/colldef/de_DE.ISO8859-15.src
deleted file mode 100644
index f5d609346cc7..000000000000
--- a/share/colldef/de_DE.ISO8859-15.src
+++ /dev/null
@@ -1,39 +0,0 @@
-# German/ISO 8859-1 (backward compatible with ASCII)
-#
-# $FreeBSD$
-#
-charmap map.DIS_8859-15
-substitute <ss> with "ss"
-order \
-# controls
- <NU>;...;<US>;<PA>;...;<AC>;\
-#
- <NS>;<SP>;!;<!I>;\";<<<>;</>/>>;<Nb>;\
- <Eu>;<Ct>;<DO>;<Pd>;<Ye>;\
- %;&;';\(;\);*;+;<+->;<-:>;<*X>;\,;<-->;-;.;/;\
-# digits
- 0;(1,<1S>);(2,<2S>);(3,<3S>);4;...;9;\
-#
- :;\;;\<;=;>;?;<?I>;<SE>;<PI>;<Co>;<Rg>;<At>;\
-# capital
- (A,<A'>,<A!>,<A/>>,<AA>,<A:>,<A?>,<AE>);\
- B;(C,<C,>);D;(E,<E'>,<E!>,<E/>>,<E:>);\
- F;G;H;(I,<I'>,<I!>,<I/>>,<I:>);\
- J;...;M;(N,<N?>);(O,<O'>,<O!>,<O/>>,<O:>,<O?>,<O//>,<OE>);\
- P;...;R;(S,<S<>);T;(U,<U'>,<U!>,<U/>>,<U:>);\
- V;W;X;(Y,<Y'>,<Y:>);(Z,<Z<>);\
- <D->;<TH>;\
-#
- [;\\;];^;_;<'m>;`;\
-# small
- (a,<a'>,<a!>,<a/>>,<aa>,<a:>,<a?>,<ae>);\
- b;(c,<c,>);d;(e,<e'>,<e!>,<e/>>,<e:>);\
- f;g;h;(i,<i'>,<i!>,<i/>>,<i:>);\
- j;...;m;(n,<n?>);(o,<o'>,<o!>,<o/>>,<o:>,<o?>,<o//>,<oe>);\
- p;...;r;(s,<s<>);t;(u,<u'>,<u!>,<u/>>,<u:>);\
- v;w;x;(y,<y'>,<y:>);(z,<z<>);\
- <d->;<th>;\
-#
- \{;<NO>;|;\};~;<.M>;<DG>;<My>;<DT>;\
-# remains
- <-a>;<-o>
diff --git a/share/colldef/de_DE.ISO_8859-15.src b/share/colldef/de_DE.ISO_8859-15.src
deleted file mode 100644
index f5d609346cc7..000000000000
--- a/share/colldef/de_DE.ISO_8859-15.src
+++ /dev/null
@@ -1,39 +0,0 @@
-# German/ISO 8859-1 (backward compatible with ASCII)
-#
-# $FreeBSD$
-#
-charmap map.DIS_8859-15
-substitute <ss> with "ss"
-order \
-# controls
- <NU>;...;<US>;<PA>;...;<AC>;\
-#
- <NS>;<SP>;!;<!I>;\";<<<>;</>/>>;<Nb>;\
- <Eu>;<Ct>;<DO>;<Pd>;<Ye>;\
- %;&;';\(;\);*;+;<+->;<-:>;<*X>;\,;<-->;-;.;/;\
-# digits
- 0;(1,<1S>);(2,<2S>);(3,<3S>);4;...;9;\
-#
- :;\;;\<;=;>;?;<?I>;<SE>;<PI>;<Co>;<Rg>;<At>;\
-# capital
- (A,<A'>,<A!>,<A/>>,<AA>,<A:>,<A?>,<AE>);\
- B;(C,<C,>);D;(E,<E'>,<E!>,<E/>>,<E:>);\
- F;G;H;(I,<I'>,<I!>,<I/>>,<I:>);\
- J;...;M;(N,<N?>);(O,<O'>,<O!>,<O/>>,<O:>,<O?>,<O//>,<OE>);\
- P;...;R;(S,<S<>);T;(U,<U'>,<U!>,<U/>>,<U:>);\
- V;W;X;(Y,<Y'>,<Y:>);(Z,<Z<>);\
- <D->;<TH>;\
-#
- [;\\;];^;_;<'m>;`;\
-# small
- (a,<a'>,<a!>,<a/>>,<aa>,<a:>,<a?>,<ae>);\
- b;(c,<c,>);d;(e,<e'>,<e!>,<e/>>,<e:>);\
- f;g;h;(i,<i'>,<i!>,<i/>>,<i:>);\
- j;...;m;(n,<n?>);(o,<o'>,<o!>,<o/>>,<o:>,<o?>,<o//>,<oe>);\
- p;...;r;(s,<s<>);t;(u,<u'>,<u!>,<u/>>,<u:>);\
- v;w;x;(y,<y'>,<y:>);(z,<z<>);\
- <d->;<th>;\
-#
- \{;<NO>;|;\};~;<.M>;<DG>;<My>;<DT>;\
-# remains
- <-a>;<-o>
diff --git a/share/colldef/es_ES.ISO8859-1.src b/share/colldef/es_ES.ISO8859-1.src
deleted file mode 100644
index 7c2b21fc5955..000000000000
--- a/share/colldef/es_ES.ISO8859-1.src
+++ /dev/null
@@ -1,38 +0,0 @@
-# Espan~ol (backward compatible with ASCII)
-#
-# $FreeBSD$
-#
-charmap map.ISO_8859-1
-order \
-# controls
- <NU>;...;<US>;<PA>;...;<AC>;\
-#
- <NS>;<SP>;!;<!I>;\";<<<>;</>/>>;<Nb>;\
- <Cu>;<Ct>;<DO>;<Pd>;<Ye>;\
- %;&;<',>;';\(;\);*;+;<+->;<-:>;<*X>;\,;<-->;-;.;/;\
-# digits
- (0,<14>,<12>,<34>);(1,<1S>);(2,<2S>);(3,<3S>);4;...;9;\
-#
- :;\;;\<;=;>;?;<?I>;<SE>;<PI>;<Co>;<Rg>;<At>;\
-# capital
- (A,<A'>,<A!>,<A/>>,<AA>,<A:>,<A?>,<AE>);\
- B;(C,<C,>);{CH,Ch};D;(E,<E'>,<E!>,<E/>>,<E:>);\
- F;G;H;(I,<I'>,<I!>,<I/>>,<I:>);\
- J;...;K;L;{LL,Ll};M;(N,<N?>);(O,<O'>,<O!>,<O/>>,<O:>,<O?>,<O//>);\
- P;Q;R;{RR,Rr};S;T;(U,<U'>,<U!>,<U/>>,<U:>);\
- V;W;X;(Y,<Y'>);Z;\
- <D->;<TH>;\
-#
- [;\\;];^;<':>;_;<'m>;<''>;`;\
-# small
- (a,<a'>,<a!>,<a/>>,<aa>,<a:>,<a?>,<ae>);\
- b;(c,<c,>);ch;d;(e,<e'>,<e!>,<e/>>,<e:>);\
- f;g;h;(i,<i'>,<i!>,<i/>>,<i:>);\
- j;...;k;l;ll;m;(n,<n?>);(o,<o'>,<o!>,<o/>>,<o:>,<o?>,<o//>);\
- p;q;r;rr;s;t;(u,<u'>,<u!>,<u/>>,<u:>);\
- v;w;x;(y,<y'>,<y:>);z;\
- <d->;<th>;<ss>;\
-#
- \{;<NO>;|;<BB>;\};~;<.M>;<DG>;<My>;<DT>;\
-# remains
- <-a>;<-o>
diff --git a/share/colldef/es_ES.ISO8859-15.src b/share/colldef/es_ES.ISO8859-15.src
deleted file mode 100644
index 002b63503d5a..000000000000
--- a/share/colldef/es_ES.ISO8859-15.src
+++ /dev/null
@@ -1,38 +0,0 @@
-# Espan~ol (backward compatible with ASCII)
-#
-# $FreeBSD$
-#
-charmap map.DIS_8859-15
-order \
-# controls
- <NU>;...;<US>;<PA>;...;<AC>;\
-#
- <NS>;<SP>;!;<!I>;\";<<<>;</>/>>;<Nb>;\
- <Eu>;<Ct>;<DO>;<Pd>;<Ye>;\
- %;&;';\(;\);*;+;<+->;<-:>;<*X>;\,;<-->;-;.;/;\
-# digits
- 0;(1,<1S>);(2,<2S>);(3,<3S>);4;...;9;\
-#
- :;\;;\<;=;>;?;<?I>;<SE>;<PI>;<Co>;<Rg>;<At>;\
-# capital
- (A,<A'>,<A!>,<A/>>,<AA>,<A:>,<A?>,<AE>);\
- B;(C,<C,>);{CH,Ch};D;(E,<E'>,<E!>,<E/>>,<E:>);\
- F;G;H;(I,<I'>,<I!>,<I/>>,<I:>);\
- J;...;K;L;{LL,Ll};M;(N,<N?>);(O,<O'>,<O!>,<O/>>,<O:>,<O?>,<O//>,<OE>);\
- P;Q;R;{RR,Rr};(S,<S<>);T;(U,<U'>,<U!>,<U/>>,<U:>);\
- V;W;X;(Y,<Y'>,<Y:>);(Z,<Z<>);\
- <D->;<TH>;\
-#
- [;\\;];^;_;<'m>;`;\
-# small
- (a,<a'>,<a!>,<a/>>,<aa>,<a:>,<a?>,<ae>);\
- b;(c,<c,>);ch;d;(e,<e'>,<e!>,<e/>>,<e:>);\
- f;g;h;(i,<i'>,<i!>,<i/>>,<i:>);\
- j;...;k;l;ll;m;(n,<n?>);(o,<o'>,<o!>,<o/>>,<o:>,<o?>,<o//>,<oe>);\
- p;q;r;rr;(s,<s<>);t;(u,<u'>,<u!>,<u/>>,<u:>);\
- v;w;x;(y,<y'>,<y:>);(z,<z<>);\
- <d->;<th>;<ss>;\
-#
- \{;<NO>;|;\};~;<.M>;<DG>;<My>;<DT>;\
-# remains
- <-a>;<-o>
diff --git a/share/colldef/es_ES.ISO_8859-15.src b/share/colldef/es_ES.ISO_8859-15.src
deleted file mode 100644
index 002b63503d5a..000000000000
--- a/share/colldef/es_ES.ISO_8859-15.src
+++ /dev/null
@@ -1,38 +0,0 @@
-# Espan~ol (backward compatible with ASCII)
-#
-# $FreeBSD$
-#
-charmap map.DIS_8859-15
-order \
-# controls
- <NU>;...;<US>;<PA>;...;<AC>;\
-#
- <NS>;<SP>;!;<!I>;\";<<<>;</>/>>;<Nb>;\
- <Eu>;<Ct>;<DO>;<Pd>;<Ye>;\
- %;&;';\(;\);*;+;<+->;<-:>;<*X>;\,;<-->;-;.;/;\
-# digits
- 0;(1,<1S>);(2,<2S>);(3,<3S>);4;...;9;\
-#
- :;\;;\<;=;>;?;<?I>;<SE>;<PI>;<Co>;<Rg>;<At>;\
-# capital
- (A,<A'>,<A!>,<A/>>,<AA>,<A:>,<A?>,<AE>);\
- B;(C,<C,>);{CH,Ch};D;(E,<E'>,<E!>,<E/>>,<E:>);\
- F;G;H;(I,<I'>,<I!>,<I/>>,<I:>);\
- J;...;K;L;{LL,Ll};M;(N,<N?>);(O,<O'>,<O!>,<O/>>,<O:>,<O?>,<O//>,<OE>);\
- P;Q;R;{RR,Rr};(S,<S<>);T;(U,<U'>,<U!>,<U/>>,<U:>);\
- V;W;X;(Y,<Y'>,<Y:>);(Z,<Z<>);\
- <D->;<TH>;\
-#
- [;\\;];^;_;<'m>;`;\
-# small
- (a,<a'>,<a!>,<a/>>,<aa>,<a:>,<a?>,<ae>);\
- b;(c,<c,>);ch;d;(e,<e'>,<e!>,<e/>>,<e:>);\
- f;g;h;(i,<i'>,<i!>,<i/>>,<i:>);\
- j;...;k;l;ll;m;(n,<n?>);(o,<o'>,<o!>,<o/>>,<o:>,<o?>,<o//>,<oe>);\
- p;q;r;rr;(s,<s<>);t;(u,<u'>,<u!>,<u/>>,<u:>);\
- v;w;x;(y,<y'>,<y:>);(z,<z<>);\
- <d->;<th>;<ss>;\
-#
- \{;<NO>;|;\};~;<.M>;<DG>;<My>;<DT>;\
-# remains
- <-a>;<-o>
diff --git a/share/colldef/is_IS.ISO8859-1.src b/share/colldef/is_IS.ISO8859-1.src
deleted file mode 100644
index 50cd9a95ca8f..000000000000
--- a/share/colldef/is_IS.ISO8859-1.src
+++ /dev/null
@@ -1,38 +0,0 @@
-# icelandic (backward compatible with ASCII)
-#
-# $FreeBSD$
-#
-charmap map.ISO_8859-1
-order \
-# controls
- <NU>;...;<US>;<PA>;...;<AC>;\
-#
- <NS>;<SP>;!;<!I>;\";<<<>;</>/>>;<Nb>;\
- <Cu>;<Ct>;<DO>;<Pd>;<Ye>;\
- %;&;<',>;';\(;\);*;+;<+->;<-:>;<*X>;\,;<-->;-;.;/;\
-# digits
- (0,<14>,<12>,<34>);(1,<1S>);(2,<2S>);(3,<3S>);4;...;9;\
-#
- :;\;;\<;=;>;?;<?I>;<SE>;<PI>;<Co>;<Rg>;<At>;\
-# capital
- (A,<A'>,<A!>,<A/>>,<AA>,<A:>,<A?>);\
- B;(C,<C,>);(D,<D->);(E,<E'>,<E!>,<E/>>,<E:>);\
- F;G;H;(I,<I'>,<I!>,<I/>>,<I:>);\
- J;...;M;(N,<N?>);(O,<O'>,<O!>,<O/>>,<O?>,<O//>);\
- P;...;T;(U,<U'>,<U!>,<U/>>,<U:>);\
- V;W;X;(Y,<Y'>);Z;\
- <TH>;<AE>;<O:>;\
-#
- [;\\;];^;<':>;_;<'m>;<''>;`;\
-# small
- (a,<a'>,<a!>,<a/>>,<aa>,<a:>,<a?>);\
- b;(c,<c,>);(d,<d->);(e,<e'>,<e!>,<e/>>,<e:>);\
- f;g;h;(i,<i'>,<i!>,<i/>>,<i:>);\
- j;...;m;(n,<n?>);(o,<o'>,<o!>,<o/>>,<o?>,<o//>);\
- p;...;t;(u,<u'>,<u!>,<u/>>,<u:>);\
- v;w;x;(y,<y'>,<y:>);z;\
- <th>;<ae>;<o:>;<ss>;\
-#
- \{;<NO>;|;<BB>;\};~;<.M>;<DG>;<My>;<DT>;\
-# remains
- <-a>;<-o>
diff --git a/share/colldef/is_IS.ISO8859-15.src b/share/colldef/is_IS.ISO8859-15.src
deleted file mode 100644
index fe4dd9beae88..000000000000
--- a/share/colldef/is_IS.ISO8859-15.src
+++ /dev/null
@@ -1,38 +0,0 @@
-# icelandic (backward compatible with ASCII)
-#
-# $FreeBSD$
-#
-charmap map.DIS_8859-15
-order \
-# controls
- <NU>;...;<US>;<PA>;...;<AC>;\
-#
- <NS>;<SP>;!;<!I>;\";<<<>;</>/>>;<Nb>;\
- <Eu>;<Ct>;<DO>;<Pd>;<Ye>;\
- %;&;';\(;\);*;+;<+->;<-:>;<*X>;\,;<-->;-;.;/;\
-# digits
- 0;(1,<1S>);(2,<2S>);(3,<3S>);4;...;9;\
-#
- :;\;;\<;=;>;?;<?I>;<SE>;<PI>;<Co>;<Rg>;<At>;\
-# capital
- (A,<A'>,<A!>,<A/>>,<AA>,<A:>,<A?>);\
- B;(C,<C,>);(D,<D->);(E,<E'>,<E!>,<E/>>,<E:>);\
- F;G;H;(I,<I'>,<I!>,<I/>>,<I:>);\
- J;...;M;(N,<N?>);(O,<O'>,<O!>,<O/>>,<O?>,<O//>,<OE>);\
- P;...;R;(S,<S<>);T;(U,<U'>,<U!>,<U/>>,<U:>);\
- V;W;X;(Y,<Y'>,<Y:>);(Z,<Z<>);\
- <TH>;<AE>;<O:>;\
-#
- [;\\;];^;_;<'m>;`;\
-# small
- (a,<a'>,<a!>,<a/>>,<aa>,<a:>,<a?>);\
- b;(c,<c,>);(d,<d->);(e,<e'>,<e!>,<e/>>,<e:>);\
- f;g;h;(i,<i'>,<i!>,<i/>>,<i:>);\
- j;...;m;(n,<n?>);(o,<o'>,<o!>,<o/>>,<o?>,<o//>,<oe>);\
- p;...;r;(s,<s<>);t;(u,<u'>,<u!>,<u/>>,<u:>);\
- v;w;x;(y,<y'>,<y:>);(z,<z<>);\
- <th>;<ae>;<o:>;<ss>;\
-#
- \{;<NO>;|;\};~;<.M>;<DG>;<My>;<DT>;\
-# remains
- <-a>;<-o>
diff --git a/share/colldef/is_IS.ISO_8859-15.src b/share/colldef/is_IS.ISO_8859-15.src
deleted file mode 100644
index fe4dd9beae88..000000000000
--- a/share/colldef/is_IS.ISO_8859-15.src
+++ /dev/null
@@ -1,38 +0,0 @@
-# icelandic (backward compatible with ASCII)
-#
-# $FreeBSD$
-#
-charmap map.DIS_8859-15
-order \
-# controls
- <NU>;...;<US>;<PA>;...;<AC>;\
-#
- <NS>;<SP>;!;<!I>;\";<<<>;</>/>>;<Nb>;\
- <Eu>;<Ct>;<DO>;<Pd>;<Ye>;\
- %;&;';\(;\);*;+;<+->;<-:>;<*X>;\,;<-->;-;.;/;\
-# digits
- 0;(1,<1S>);(2,<2S>);(3,<3S>);4;...;9;\
-#
- :;\;;\<;=;>;?;<?I>;<SE>;<PI>;<Co>;<Rg>;<At>;\
-# capital
- (A,<A'>,<A!>,<A/>>,<AA>,<A:>,<A?>);\
- B;(C,<C,>);(D,<D->);(E,<E'>,<E!>,<E/>>,<E:>);\
- F;G;H;(I,<I'>,<I!>,<I/>>,<I:>);\
- J;...;M;(N,<N?>);(O,<O'>,<O!>,<O/>>,<O?>,<O//>,<OE>);\
- P;...;R;(S,<S<>);T;(U,<U'>,<U!>,<U/>>,<U:>);\
- V;W;X;(Y,<Y'>,<Y:>);(Z,<Z<>);\
- <TH>;<AE>;<O:>;\
-#
- [;\\;];^;_;<'m>;`;\
-# small
- (a,<a'>,<a!>,<a/>>,<aa>,<a:>,<a?>);\
- b;(c,<c,>);(d,<d->);(e,<e'>,<e!>,<e/>>,<e:>);\
- f;g;h;(i,<i'>,<i!>,<i/>>,<i:>);\
- j;...;m;(n,<n?>);(o,<o'>,<o!>,<o/>>,<o?>,<o//>,<oe>);\
- p;...;r;(s,<s<>);t;(u,<u'>,<u!>,<u/>>,<u:>);\
- v;w;x;(y,<y'>,<y:>);(z,<z<>);\
- <th>;<ae>;<o:>;<ss>;\
-#
- \{;<NO>;|;\};~;<.M>;<DG>;<My>;<DT>;\
-# remains
- <-a>;<-o>
diff --git a/share/colldef/la_LN.ISO8859-1.src b/share/colldef/la_LN.ISO8859-1.src
deleted file mode 100644
index 99b7d08ddb00..000000000000
--- a/share/colldef/la_LN.ISO8859-1.src
+++ /dev/null
@@ -1,38 +0,0 @@
-# latin1 (backward compatible with ASCII)
-#
-# $FreeBSD$
-#
-charmap map.ISO_8859-1
-order \
-# controls
- <NU>;...;<US>;<PA>;...;<AC>;\
-#
- <NS>;<SP>;!;<!I>;\";<<<>;</>/>>;<Nb>;\
- <Cu>;<Ct>;<DO>;<Pd>;<Ye>;\
- %;&;<',>;';\(;\);*;+;<+->;<-:>;<*X>;\,;<-->;-;.;/;\
-# digits
- (0,<14>,<12>,<34>);(1,<1S>);(2,<2S>);(3,<3S>);4;...;9;\
-#
- :;\;;\<;=;>;?;<?I>;<SE>;<PI>;<Co>;<Rg>;<At>;\
-# capital
- (A,<A'>,<A!>,<A/>>,<AA>,<A:>,<A?>,<AE>);\
- B;(C,<C,>);D;(E,<E'>,<E!>,<E/>>,<E:>);\
- F;G;H;(I,<I'>,<I!>,<I/>>,<I:>);\
- J;...;M;(N,<N?>);(O,<O'>,<O!>,<O/>>,<O:>,<O?>,<O//>);\
- P;...;T;(U,<U'>,<U!>,<U/>>,<U:>);\
- V;W;X;(Y,<Y'>);Z;\
- <D->;<TH>;\
-#
- [;\\;];^;<':>;_;<'m>;<''>;`;\
-# small
- (a,<a'>,<a!>,<a/>>,<aa>,<a:>,<a?>,<ae>);\
- b;(c,<c,>);d;(e,<e'>,<e!>,<e/>>,<e:>);\
- f;g;h;(i,<i'>,<i!>,<i/>>,<i:>);\
- j;...;m;(n,<n?>);(o,<o'>,<o!>,<o/>>,<o:>,<o?>,<o//>);\
- p;...;t;(u,<u'>,<u!>,<u/>>,<u:>);\
- v;w;x;(y,<y'>,<y:>);z;\
- <d->;<th>;<ss>;\
-#
- \{;<NO>;|;<BB>;\};~;<.M>;<DG>;<My>;<DT>;\
-# remains
- <-a>;<-o>
diff --git a/share/colldef/la_LN.ISO8859-15.src b/share/colldef/la_LN.ISO8859-15.src
deleted file mode 100644
index 449ce85e6336..000000000000
--- a/share/colldef/la_LN.ISO8859-15.src
+++ /dev/null
@@ -1,38 +0,0 @@
-# latin1 (backward compatible with ASCII)
-#
-# $FreeBSD$
-#
-charmap map.DIS_8859-15
-order \
-# controls
- <NU>;...;<US>;<PA>;...;<AC>;\
-#
- <NS>;<SP>;!;<!I>;\";<<<>;</>/>>;<Nb>;\
- <Eu>;<Ct>;<DO>;<Pd>;<Ye>;\
- %;&;';\(;\);*;+;<+->;<-:>;<*X>;\,;<-->;-;.;/;\
-# digits
- 0;(1,<1S>);(2,<2S>);(3,<3S>);4;...;9;\
-#
- :;\;;\<;=;>;?;<?I>;<SE>;<PI>;<Co>;<Rg>;<At>;\
-# capital
- (A,<A'>,<A!>,<A/>>,<AA>,<A:>,<A?>,<AE>);\
- B;(C,<C,>);D;(E,<E'>,<E!>,<E/>>,<E:>);\
- F;G;H;(I,<I'>,<I!>,<I/>>,<I:>);\
- J;...;M;(N,<N?>);(O,<O'>,<O!>,<O/>>,<O:>,<O?>,<O//>,<OE>);\
- P;...;R;(S,<S<>);T;(U,<U'>,<U!>,<U/>>,<U:>);\
- V;W;X;(Y,<Y'>,<Y:>);(Z,<Z<>);\
- <D->;<TH>;\
-#
- [;\\;];^;_;<'m>;`;\
-# small
- (a,<a'>,<a!>,<a/>>,<aa>,<a:>,<a?>,<ae>);\
- b;(c,<c,>);d;(e,<e'>,<e!>,<e/>>,<e:>);\
- f;g;h;(i,<i'>,<i!>,<i/>>,<i:>);\
- j;...;m;(n,<n?>);(o,<o'>,<o!>,<o/>>,<o:>,<o?>,<o//>,<oe>);\
- p;...;r;(s,<s<>);t;(u,<u'>,<u!>,<u/>>,<u:>);\
- v;w;x;(y,<y'>,<y:>);(z,<z<>);\
- <d->;<th>;<ss>;\
-#
- \{;<NO>;|;\};~;<.M>;<DG>;<My>;<DT>;\
-# remains
- <-a>;<-o>
diff --git a/share/colldef/la_LN.ISO8859-2.src b/share/colldef/la_LN.ISO8859-2.src
deleted file mode 100644
index aee3671f0966..000000000000
--- a/share/colldef/la_LN.ISO8859-2.src
+++ /dev/null
@@ -1,36 +0,0 @@
-# latin2 (backward compatible with ASCII)
-#
-# $FreeBSD$
-#
-charmap map.ISO_8859-2
-order \
-# controls
- <NU>;...;<US>;<PA>;...;<AC>;\
-#
- <NS>;<SP>;!;\";<Nb>;\
- <Cu>;<DO>;\
- %;&;<',>;<';>;';\(;\);*;+;<-:>;<*X>;\,;<-->;-;.;<'.>;/;\
-# digits
- 0;...;9;\
-#
- :;\;;\<;=;>;?;<SE>;<At>;\
-# capital
- (A,<A'>,<A/>>,<A:>,<A;>,<A(>);\
- B;(C,<C,>,<C'>,<C<>);(D,<D<>,<D//>);(E,<E'>,<E:>,<E;>,<E<>);\
- F;G;H;(I,<I'>,<I/>>);\
- J;K;(L,<L//>,<L<>,<L'>);M;(N,<N'>,<N<>);(O,<O'>,<O/>>,<O:>,<O">);\
- P;Q;(R,<R'>,<R<>);(S,<S'>,<S<>,<S,>);(T,<T<>,<T,>);\
- (U,<U'>,<U:>,<U0>,<U">);\
- V;W;X;(Y,<Y'>);(Z,<Z'>,<Z<>,<Z.>);\
-#
- [;\\;];^;<':>;<'">;<'<>;<'(>;_;<''>;`;\
-# small
- (a,<a'>,<a/>>,<a:>,<a;>,<a(>);\
- b;(c,<c,>,<c'>,<c<>);(d,<d<>,<d//>);(e,<e'>,<e:>,<e;>,<e<>);\
- f;g;h;(i,<i'>,<i/>>);\
- j;k;(l,<l//>,<l<>,<l'>);m;(n,<n'>,<n<>);(o,<o'>,<o/>>,<o:>,<o">);\
- p;q;(r,<r'>,<r<>);(s,<s'>,<s<>,<s,>,<ss>);(t,<t<>,<t,>);\
- (u,<u'>,<u:>,<u0>,<u">);\
- v;w;x;(y,<y'>);(z,<z'>,<z<>,<z.>);\
-#
- \{;|;\};~;<DG>;<DT>
diff --git a/share/colldef/la_LN.ISO8859-4.src b/share/colldef/la_LN.ISO8859-4.src
deleted file mode 100644
index 776d0e342daf..000000000000
--- a/share/colldef/la_LN.ISO8859-4.src
+++ /dev/null
@@ -1,36 +0,0 @@
-# latin4 (backward compatible with ASCII)
-#
-# $FreeBSD$
-#
-charmap map.ISO_8859-4
-order \
-# controls
- <NU>;...;<US>;<PA>;...;<AC>;\
-#
- <NS>;<SP>;!;\";<Nb>;\
- <Cu>;<DO>;\
- %;&;<',>;<';>;';\(;\);*;+;<-:>;<*X>;\,;<-->;-;.;<'.>;/;\
-# digits
- 0;...;9;\
-#
- :;\;;\<;=;>;?;<SE>;<At>;\
-# capital
- (A,<A'>,<A/>>,<AA>,<A:>,<A;>,<A?>,<A->,<AE>);\
- B;(C,<C<>);(D,<D//>);(E,<E'>,<E:>,<E.>,<E;>,<E->);\
- F;(G,<G,>);H;(I,<I'>,<I/>>,<I?>,<I;>,<I->);\
- J;(K,<K,>);(L,<L,>);M;(N,<N,>);<NG>;(O,<O/>>,<O:>,<O?>,<O//>,<O->);\
- P;Q;(R,<R,>);(S,<S<>);(T,<T//>);\
- (U,<U'>,<U/>>,<U:>,<U;>,<U?>,<U->);\
- V;W;X;Y;(Z,<Z<>);\
-#
- [;\\;];^;<':>;<'<>;_;<'m>;<''>;`;\
-# small
- (a,<a'>,<a/>>,<aa>,<a:>,<a?>,<a;>,<a->,<ae>);\
- b;(c,<c<>);(d,<d//>);(e,<e'>,<e:>,<e.>,<e;>,<e->);\
- f;(g,<g,>);h;(i,<i'>,<i/>>,<i?>,<i;>,<i->);\
- j;(k,<k,>);<kk>;(l,<l,>);m;(n,<n,>);<ng>;(o,<o/>>,<o:>,<o?>,<o//>,<o->);\
- p;q;(r,<r,>);(s,<s<>,<ss>);(t,<t//>);\
- (u,<u'>,<u/>>,<u:>,<u;>,<u?>,<u->);\
- v;w;x;y;(z,<z<>);\
-#
- \{;|;\};~;<DG>;<DT>
diff --git a/share/colldef/la_LN.ISO_8859-15.src b/share/colldef/la_LN.ISO_8859-15.src
deleted file mode 100644
index 449ce85e6336..000000000000
--- a/share/colldef/la_LN.ISO_8859-15.src
+++ /dev/null
@@ -1,38 +0,0 @@
-# latin1 (backward compatible with ASCII)
-#
-# $FreeBSD$
-#
-charmap map.DIS_8859-15
-order \
-# controls
- <NU>;...;<US>;<PA>;...;<AC>;\
-#
- <NS>;<SP>;!;<!I>;\";<<<>;</>/>>;<Nb>;\
- <Eu>;<Ct>;<DO>;<Pd>;<Ye>;\
- %;&;';\(;\);*;+;<+->;<-:>;<*X>;\,;<-->;-;.;/;\
-# digits
- 0;(1,<1S>);(2,<2S>);(3,<3S>);4;...;9;\
-#
- :;\;;\<;=;>;?;<?I>;<SE>;<PI>;<Co>;<Rg>;<At>;\
-# capital
- (A,<A'>,<A!>,<A/>>,<AA>,<A:>,<A?>,<AE>);\
- B;(C,<C,>);D;(E,<E'>,<E!>,<E/>>,<E:>);\
- F;G;H;(I,<I'>,<I!>,<I/>>,<I:>);\
- J;...;M;(N,<N?>);(O,<O'>,<O!>,<O/>>,<O:>,<O?>,<O//>,<OE>);\
- P;...;R;(S,<S<>);T;(U,<U'>,<U!>,<U/>>,<U:>);\
- V;W;X;(Y,<Y'>,<Y:>);(Z,<Z<>);\
- <D->;<TH>;\
-#
- [;\\;];^;_;<'m>;`;\
-# small
- (a,<a'>,<a!>,<a/>>,<aa>,<a:>,<a?>,<ae>);\
- b;(c,<c,>);d;(e,<e'>,<e!>,<e/>>,<e:>);\
- f;g;h;(i,<i'>,<i!>,<i/>>,<i:>);\
- j;...;m;(n,<n?>);(o,<o'>,<o!>,<o/>>,<o:>,<o?>,<o//>,<oe>);\
- p;...;r;(s,<s<>);t;(u,<u'>,<u!>,<u/>>,<u:>);\
- v;w;x;(y,<y'>,<y:>);(z,<z<>);\
- <d->;<th>;<ss>;\
-#
- \{;<NO>;|;\};~;<.M>;<DG>;<My>;<DT>;\
-# remains
- <-a>;<-o>
diff --git a/share/colldef/lt_LT.ISO8859-4.src b/share/colldef/lt_LT.ISO8859-4.src
deleted file mode 100644
index 712b5f09e507..000000000000
--- a/share/colldef/lt_LT.ISO8859-4.src
+++ /dev/null
@@ -1,36 +0,0 @@
-# Lithuanian (backward compatible with ASCII)
-#
-# $FreeBSD$
-#
-charmap map.ISO_8859-4
-order \
-# controls
- <NU>;...;<US>;<PA>;...;<AC>;\
-#
- <NS>;<SP>;!;\";<Nb>;\
- <Cu>;<DO>;\
- %;&;<',>;<';>;';\(;\);*;+;<-:>;<*X>;\,;<-->;-;.;<'.>;/;\
-# digits
- 0;...;9;\
-#
- :;\;;\<;=;>;?;<SE>;<At>;\
-# capital
- (A,<A'>,<A/>>,<AA>,<A:>,<A;>,<A?>,<A->,<AE>);\
- B;(C,<C<>);(D,<D//>);(E,<E'>,<E:>,<E;>,<E->,<E.>);\
- F;(G,<G,>);H;(I,<I'>,<I/>>,<I?>,<I;>,<I->);Y;\
- J;(K,<K,>);(L,<L,>);M;(N,<N,>);<NG>;(O,<O/>>,<O:>,<O?>,<O//>,<O->);\
- P;Q;(R,<R,>);(S,<S<>);(T,<T//>);\
- (U,<U'>,<U/>>,<U:>,<U;>,<U?>,<U->);\
- V;W;X;(Z,<Z<>);\
-#
- [;\\;];^;<':>;<'<>;_;<'m>;<''>;`;\
-# small
- (a,<a'>,<a/>>,<aa>,<a:>,<a?>,<a;>,<a->,<ae>);\
- b;(c,<c<>);(d,<d//>);(e,<e'>,<e:>,<e;>,<e->,<e.>);\
- f;(g,<g,>);h;(i,<i'>,<i/>>,<i?>,<i;>,<i->);y;\
- j;(k,<k,>);<kk>;(l,<l,>);m;(n,<n,>);<ng>;(o,<o/>>,<o:>,<o?>,<o//>,<o->);\
- p;q;(r,<r,>);(s,<s<>,<ss>);(t,<t//>);\
- (u,<u'>,<u/>>,<u:>,<u;>,<u?>,<u->);\
- v;w;x;(z,<z<>);\
-#
- \{;|;\};~;<DG>;<DT>
diff --git a/share/colldef/map.ISO_8859-15 b/share/colldef/map.ISO_8859-15
deleted file mode 100644
index 041dd5a1311b..000000000000
--- a/share/colldef/map.ISO_8859-15
+++ /dev/null
@@ -1,174 +0,0 @@
-NU \x00
-SH \x01
-SX \x02
-EX \x03
-ET \x04
-EQ \x05
-AK \x06
-BL \x07
-BS \x08
-HT \x09
-LF \x0a
-VT \x0b
-FF \x0c
-CR \x0d
-SO \x0e
-SI \x0f
-DL \x10
-D1 \x11
-D2 \x12
-D3 \x13
-D4 \x14
-NK \x15
-SY \x16
-EB \x17
-CN \x18
-EM \x19
-SB \x1a
-EC \x1b
-FS \x1c
-GS \x1d
-RS \x1e
-US \x1f
-SP \x20
-Nb \x23
-DO \x24
-At \x40
-<( \x5b
-// \x5c
-)> \x5d
-'> \x5e
-'! \x60
-(! \x7b
-!! \x7c
-!) \x7d
-'? \x7e
-DT \x7f
-PA \x80
-HO \x81
-BH \x82
-NH \x83
-IN \x84
-NL \x85
-SA \x86
-ES \x87
-HS \x88
-HJ \x89
-VS \x8a
-PD \x8b
-PU \x8c
-RI \x8d
-S2 \x8e
-S3 \x8f
-DC \x90
-P1 \x91
-P2 \x92
-TS \x93
-CC \x94
-MW \x95
-SG \x96
-EG \x97
-SS \x98
-GC \x99
-SC \x9a
-CI \x9b
-ST \x9c
-OC \x9d
-PM \x9e
-AC \x9f
-NS \xa0
-!I \xa1
-Ct \xa2
-Pd \xa3
-Eu \xa4
-Ye \xa5
-S< \xa6
-SE \xa7
-s< \xa8
-Co \xa9
--a \xaa
-<< \xab
-NO \xac
--- \xad
-Rg \xae
-'m \xaf
-DG \xb0
-+- \xb1
-2S \xb2
-3S \xb3
-Z< \xb4
-My \xb5
-PI \xb6
-.M \xb7
-z< \xb8
-1S \xb9
--o \xba
->> \xbb
-OE \xbc
-oe \xbd
-Y: \xbe
-?I \xbf
-A! \xc0
-A' \xc1
-A> \xc2
-A? \xc3
-A: \xc4
-AA \xc5
-AE \xc6
-C, \xc7
-E! \xc8
-E' \xc9
-E> \xca
-E: \xcb
-I! \xcc
-I' \xcd
-I> \xce
-I: \xcf
-D- \xd0
-N? \xd1
-O! \xd2
-O' \xd3
-O> \xd4
-O? \xd5
-O: \xd6
-*X \xd7
-O/ \xd8
-U! \xd9
-U' \xda
-U> \xdb
-U: \xdc
-Y' \xdd
-TH \xde
-ss \xdf
-a! \xe0
-a' \xe1
-a> \xe2
-a? \xe3
-a: \xe4
-aa \xe5
-ae \xe6
-c, \xe7
-e! \xe8
-e' \xe9
-e> \xea
-e: \xeb
-i! \xec
-i' \xed
-i> \xee
-i: \xef
-d- \xf0
-n? \xf1
-o! \xf2
-o' \xf3
-o> \xf4
-o? \xf5
-o: \xf6
--: \xf7
-o/ \xf8
-u! \xf9
-u' \xfa
-u> \xfb
-u: \xfc
-y' \xfd
-th \xfe
-y: \xff
diff --git a/share/colldef/ru_RU.ISO8859-5.src b/share/colldef/ru_RU.ISO8859-5.src
deleted file mode 100644
index 459851da7f19..000000000000
--- a/share/colldef/ru_RU.ISO8859-5.src
+++ /dev/null
@@ -1,37 +0,0 @@
-# Russian part of ISO8859-5 (backward compatible with ASCII)
-#
-# $FreeBSD$
-#
-charmap map.ISO_8859-5
-order \
-# controls
- <NU>;...;<US>;\
-#
- <NS>;<SP>;!;\";<Nb>;<DO>;\
- %;&;';\(;\);*;+;\,;-;.;/;\
-# digits
- 0;...;9;\
-#
- :;\;;\<;=;>;?;<At>;\
-# capital
- A;...;Z;\
- <A=>;<B=>;<V=>;<G=>;<D=>;<E=>;<IO>;<Z%>;<Z=>;\
- <I=>;<J=>;<K=>;<L=>;<M=>;<N=>;<O=>;<P=>;<R=>;\
- <S=>;<T=>;<U=>;<F=>;<H=>;<C=>;<C%>;<S%>;<Sc>;\
- <=">;<Y=>;<%">;<JE>;<JU>;<JA>;\
-#
- [;\\;];^;_;`;\
-# small
- a;...;z;\
- <a=>;<b=>;<v=>;<g=>;<d=>;<e=>;<io>;<z%>;<z=>;\
- <i=>;<j=>;<k=>;<l=>;<m=>;<n=>;<o=>;<p=>;<r=>;\
- <s=>;<t=>;<u=>;<f=>;<h=>;<c=>;<c%>;<s%>;<sc>;\
- <='>;<y=>;<%'>;<je>;<ju>;<ja>;\
-#
- \{;|;\};~;<DT>;<PA>;<HO>;<BH>;<NH>;<IN>;<NL>;\
- <SA>;<ES>;<HS>;<HJ>;<VS>;<PD>;<PU>;<RI>;<S2>;\
- <S3>;<DC>;<P1>;<P2>;<TS>;<CC>;<MW>;<SG>;<EG>;\
- <SS>;<GC>;<SC>;<CI>;<ST>;<OC>;<PM>;<AC>;<D%>;\
- <G%>;<IE>;<DS>;<II>;<YI>;<J%>;<LJ>;<NJ>;<Ts>;\
- <KJ>;<-->;<V%>;<DZ>;<N0>;<d%>;<g%>;<ie>;<ds>;\
- <ii>;<yi>;<j%>;<lj>;<nj>;<ts>;<kj>;<SE>;<v%>;<dz>
diff --git a/share/colldef/ru_RU.ISO_8859-5.src b/share/colldef/ru_RU.ISO_8859-5.src
deleted file mode 100644
index 459851da7f19..000000000000
--- a/share/colldef/ru_RU.ISO_8859-5.src
+++ /dev/null
@@ -1,37 +0,0 @@
-# Russian part of ISO8859-5 (backward compatible with ASCII)
-#
-# $FreeBSD$
-#
-charmap map.ISO_8859-5
-order \
-# controls
- <NU>;...;<US>;\
-#
- <NS>;<SP>;!;\";<Nb>;<DO>;\
- %;&;';\(;\);*;+;\,;-;.;/;\
-# digits
- 0;...;9;\
-#
- :;\;;\<;=;>;?;<At>;\
-# capital
- A;...;Z;\
- <A=>;<B=>;<V=>;<G=>;<D=>;<E=>;<IO>;<Z%>;<Z=>;\
- <I=>;<J=>;<K=>;<L=>;<M=>;<N=>;<O=>;<P=>;<R=>;\
- <S=>;<T=>;<U=>;<F=>;<H=>;<C=>;<C%>;<S%>;<Sc>;\
- <=">;<Y=>;<%">;<JE>;<JU>;<JA>;\
-#
- [;\\;];^;_;`;\
-# small
- a;...;z;\
- <a=>;<b=>;<v=>;<g=>;<d=>;<e=>;<io>;<z%>;<z=>;\
- <i=>;<j=>;<k=>;<l=>;<m=>;<n=>;<o=>;<p=>;<r=>;\
- <s=>;<t=>;<u=>;<f=>;<h=>;<c=>;<c%>;<s%>;<sc>;\
- <='>;<y=>;<%'>;<je>;<ju>;<ja>;\
-#
- \{;|;\};~;<DT>;<PA>;<HO>;<BH>;<NH>;<IN>;<NL>;\
- <SA>;<ES>;<HS>;<HJ>;<VS>;<PD>;<PU>;<RI>;<S2>;\
- <S3>;<DC>;<P1>;<P2>;<TS>;<CC>;<MW>;<SG>;<EG>;\
- <SS>;<GC>;<SC>;<CI>;<ST>;<OC>;<PM>;<AC>;<D%>;\
- <G%>;<IE>;<DS>;<II>;<YI>;<J%>;<LJ>;<NJ>;<Ts>;\
- <KJ>;<-->;<V%>;<DZ>;<N0>;<d%>;<g%>;<ie>;<ds>;\
- <ii>;<yi>;<j%>;<lj>;<nj>;<ts>;<kj>;<SE>;<v%>;<dz>
diff --git a/share/colldef/sv_SE.ISO8859-1.src b/share/colldef/sv_SE.ISO8859-1.src
deleted file mode 100644
index de5fa347e098..000000000000
--- a/share/colldef/sv_SE.ISO8859-1.src
+++ /dev/null
@@ -1,40 +0,0 @@
-# Swedish/ISO 8859-1 (backward compatible with ASCII)
-#
-# (Based on the German de_DE.ISO_8859-1)
-#
-# $FreeBSD$
-#
-charmap map.ISO_8859-1
-order \
-# controls
- <NU>;...;<US>;<PA>;...;<AC>;\
-#
- <NS>;<SP>;!;<!I>;\";<<<>;</>/>>;<Nb>;\
- <Cu>;<Ct>;<DO>;<Pd>;<Ye>;\
- %;&;<',>;';\(;\);*;+;<+->;<-:>;<*X>;\,;<-->;-;.;/;\
-# digits
- (0,<14>,<12>,<34>);(1,<1S>);(2,<2S>);(3,<3S>);4;...;9;\
-#
- :;\;;\<;=;>;?;<?I>;<SE>;<PI>;<Co>;<Rg>;<At>;\
-# capital
- (A,<A'>,<A!>,<A/>>,<A?>);\
- B;(C,<C,>);(D,<D->);(E,<E'>,<E!>,<E/>>,<E:>);\
- F;G;H;(I,<I'>,<I!>,<I/>>,<I:>);\
- J;...;M;(N,<N?>);(O,<O'>,<O!>,<O?>,<O/>>);\
- P;...;T;(U,<U'>,<U!>,<U/>>,<U:>);\
- (V,W);X;(Y,<Y'>);Z;<AA>;(<A:>,<AE>);(<O:>,<O//>);\
- <TH>;\
-#
- [;\\;];^;<':>;_;<'m>;<''>;`;\
-# small
- (a,<a'>,<a!>,<a/>>,<a?>);\
- b;(c,<c,>);(d,<d->);(e,<e'>,<e!>,<e/>>,<e:>);\
- f;g;h;(i,<i'>,<i!>,<i/>>,<i:>);\
- j;...;m;(n,<n?>);(o,<o'>,<o!>,<o?>,<o/>>);\
- p;...;t;(u,<u'>,<u!>,<u/>>,<u:>);\
- (v,w);x;(y,<y'>,<y:>);z;<aa>;(<a:>,<ae>);(<o:>,<o//>);\
- <th>;\
-#
- \{;<NO>;|;<BB>;\};~;<.M>;<DG>;<My>;<DT>;\
-# remains
- <-a>;<ss>;<-o>
diff --git a/share/colldef/sv_SE.ISO8859-15.src b/share/colldef/sv_SE.ISO8859-15.src
deleted file mode 100644
index d8ebb758e323..000000000000
--- a/share/colldef/sv_SE.ISO8859-15.src
+++ /dev/null
@@ -1,40 +0,0 @@
-# Swedish/DIS 8859-15 (backward compatible with ASCII)
-#
-# (Based on the German de_DE.DIS_8859-15)
-#
-# $FreeBSD$
-#
-charmap map.DIS_8859-15
-order \
-# controls
- <NU>;...;<US>;<PA>;...;<AC>;\
-#
- <NS>;<SP>;!;<!I>;\";<<<>;</>/>>;<Nb>;\
- <Eu>;<Ct>;<DO>;<Pd>;<Ye>;\
- %;&;';\(;\);*;+;<+->;<-:>;<*X>;\,;<-->;-;.;/;\
-# digits
- 0;(1,<1S>);(2,<2S>);(3,<3S>);4;...;9;\
-#
- :;\;;\<;=;>;?;<?I>;<SE>;<PI>;<Co>;<Rg>;<At>;\
-# capital
- (A,<A'>,<A!>,<A/>>,<A?>);\
- B;(C,<C,>);(D,<D->);(E,<E'>,<E!>,<E/>>,<E:>);\
- F;G;H;(I,<I'>,<I!>,<I/>>,<I:>);\
- J;...;M;(N,<N?>);(O,<O'>,<O!>,<O?>,<O/>>,<OE>);\
- P;Q;R;(S,<S<>);T;(U,<U'>,<U!>,<U/>>,<U:>);\
- (V,W);X;(Y,<Y'>,<Y:>);(Z,<Z<>);<AA>;(<A:>,<AE>);(<O:>,<O//>);\
- <TH>;\
-#
- [;\\;];^;_;<'m>;`;\
-# small
- (a,<a'>,<a!>,<a/>>,<a?>);\
- b;(c,<c,>);(d,<d->);(e,<e'>,<e!>,<e/>>,<e:>);\
- f;g;h;(i,<i'>,<i!>,<i/>>,<i:>);\
- j;...;m;(n,<n?>);(o,<o'>,<o!>,<o?>,<o/>>,<oe>);\
- p;q;r;(s,<s<>,<ss>);t;(u,<u'>,<u!>,<u/>>,<u:>);\
- (v,w);x;(y,<y'>,<y:>);(z,<z<>);<aa>;(<a:>,<ae>);(<o:>,<o//>);\
- <th>;\
-#
- \{;<NO>;|;\};~;<.M>;<DG>;<My>;<DT>;\
-# remains
- <-a>;<-o>
diff --git a/share/colldef/sv_SE.ISO_8859-15.src b/share/colldef/sv_SE.ISO_8859-15.src
deleted file mode 100644
index d8ebb758e323..000000000000
--- a/share/colldef/sv_SE.ISO_8859-15.src
+++ /dev/null
@@ -1,40 +0,0 @@
-# Swedish/DIS 8859-15 (backward compatible with ASCII)
-#
-# (Based on the German de_DE.DIS_8859-15)
-#
-# $FreeBSD$
-#
-charmap map.DIS_8859-15
-order \
-# controls
- <NU>;...;<US>;<PA>;...;<AC>;\
-#
- <NS>;<SP>;!;<!I>;\";<<<>;</>/>>;<Nb>;\
- <Eu>;<Ct>;<DO>;<Pd>;<Ye>;\
- %;&;';\(;\);*;+;<+->;<-:>;<*X>;\,;<-->;-;.;/;\
-# digits
- 0;(1,<1S>);(2,<2S>);(3,<3S>);4;...;9;\
-#
- :;\;;\<;=;>;?;<?I>;<SE>;<PI>;<Co>;<Rg>;<At>;\
-# capital
- (A,<A'>,<A!>,<A/>>,<A?>);\
- B;(C,<C,>);(D,<D->);(E,<E'>,<E!>,<E/>>,<E:>);\
- F;G;H;(I,<I'>,<I!>,<I/>>,<I:>);\
- J;...;M;(N,<N?>);(O,<O'>,<O!>,<O?>,<O/>>,<OE>);\
- P;Q;R;(S,<S<>);T;(U,<U'>,<U!>,<U/>>,<U:>);\
- (V,W);X;(Y,<Y'>,<Y:>);(Z,<Z<>);<AA>;(<A:>,<AE>);(<O:>,<O//>);\
- <TH>;\
-#
- [;\\;];^;_;<'m>;`;\
-# small
- (a,<a'>,<a!>,<a/>>,<a?>);\
- b;(c,<c,>);(d,<d->);(e,<e'>,<e!>,<e/>>,<e:>);\
- f;g;h;(i,<i'>,<i!>,<i/>>,<i:>);\
- j;...;m;(n,<n?>);(o,<o'>,<o!>,<o?>,<o/>>,<oe>);\
- p;q;r;(s,<s<>,<ss>);t;(u,<u'>,<u!>,<u/>>,<u:>);\
- (v,w);x;(y,<y'>,<y:>);(z,<z<>);<aa>;(<a:>,<ae>);(<o:>,<o//>);\
- <th>;\
-#
- \{;<NO>;|;\};~;<.M>;<DG>;<My>;<DT>;\
-# remains
- <-a>;<-o>
diff --git a/share/examples/etc/make.conf b/share/examples/etc/make.conf
deleted file mode 100644
index 3a6e5880a16e..000000000000
--- a/share/examples/etc/make.conf
+++ /dev/null
@@ -1,227 +0,0 @@
-# $FreeBSD$
-#
-# This file, if present, will be read by make (see /usr/share/mk/sys.mk).
-# It allows you to override macro definitions to make without changing
-# your source tree, or anything the source tree installs.
-#
-# This file must be in valid Makefile syntax.
-#
-# You have to find the things you can put here in the Makefiles and
-# documentation of the source tree.
-#
-# One, and probably the most common, use could be:
-#
-#CFLAGS= -O -pipe
-#
-#
-# Avoid compiling profiled libraries
-#NOPROFILE= true
-#
-# Compare before install
-#INSTALL=install -C
-#
-# To avoid building perl
-#NOPERL= true
-#
-# To avoid building the suid perl
-#NOSUIDPERL= true
-#
-# To build perl with thread support
-#PERL_THREADED= true
-#
-# To avoid building various parts of the base system:
-#NO_CVS= true # do not build CVS
-#NO_FORTRAN= true # do not build g77 and related libraries
-#NO_OBJC= true # do not build Objective C support
-#NO_OPENSSH= true # do not build OpenSSH
-#NO_OPENSSL= true # do not build OpenSSL (implies NO_OPENSSH)
-#NO_SENDMAIL= true # do not build sendmail and related programs
-#NOCRYPT= true # do not build any crypto code
-#NODESCRYPTLINKS=true # do not replace libcrypt -> libscrypt links
-#NOGAMES= true # do not build games (games/ subdir)
-#NOINFO= true # do not make or install info files
-#NOLIBC_R= true # do not build libc_r (re-entrant version of libc)
-#NOSECURE= true # do not build crypto code in secure/ subdir
-#NOSHARE= true # do not go into the share subdir
-#
-# To tell the base system that you are using RSAREF (from ports).
-# (This needs revisiting) - it is very likely that this is too
-# heavily tied to USA_RESIDENT==YES.
-#RSAREF= YES
-#
-# To avoid running MAKEDEV all on /dev during install:
-#NO_MAKEDEV= true
-#
-# To compile just the kernel with special optimisations, you should use
-# this instead of CFLAGS (which is not applicable to kernel builds anyway):
-#
-#COPTFLAGS= -O -pipe
-#
-# To compile and install the 4.4 lite libm instead of the default use:
-#
-#WANT_CSRG_LIBM= yes
-#
-# If you do not want unformatted manual pages to be compressed
-# when they are installed:
-#
-#NOMANCOMPRESS= true
-#
-#
-# If you want the "compat" shared libraries installed as part of your normal
-# builds, uncomment these:
-#
-#COMPAT1X= yes
-#COMPAT20= yes
-#COMPAT21= yes
-#COMPAT22= yes
-#COMPAT3X= yes
-#
-#
-# If you do not want additional documentation (some of which are
-# a few hundred KB's) for ports to be installed:
-#
-#NOPORTDOCS= true
-#
-#
-# Default format for system documentation, depends on your printer.
-# Set this to "ascii" for simple printers or screen
-#
-#PRINTERDEVICE= ps
-#
-#
-# How long to wait for a console keypress before booting the default kernel.
-# This value is approximately in milliseconds. Keypresses are accepted by the
-# BIOS before booting from disk, making it possible to give custom boot
-# parameters even when this is set to 0.
-#
-#BOOTWAIT=0
-#BOOTWAIT=30000
-#
-# By default, the system will always use the keyboard/video card as system
-# console. However, the boot blocks may be dynamically configured to use a
-# serial port in addition to or instead of the keyboard/video console.
-#
-# By default we use COM1 as our serial console port *if* we're going to use
-# a serial port as our console at all. Alter as necessary.
-#
-# COM1: = 0x3F8, COM2: = 0x2F8, COM3: = 0x3E8, COM4: = 0x2E8
-#
-#BOOT_COMCONSOLE_PORT= 0x3F8
-#
-# The default serial console speed is 9600. Set the speed to a larger value
-# for better interactive response.
-#
-#BOOT_COMCONSOLE_SPEED= 115200
-#
-#
-# By default, this points to /usr/X11R6 for XFree86 releases 3.0 or earlier.
-# If you have a XFree86 from before 3.0 that has the X distribution in
-# /usr/X386, you want to uncomment this.
-#
-#X11BASE= /usr/X386
-#
-#
-# If you have Motif on your system, uncomment this.
-#
-#HAVE_MOTIF= yes
-#MOTIF_STATIC= yes
-#
-# If the default location of the Motif library (specified below) is NOT
-# appropriate for you, uncomment this and change it to the correct value.
-# If your motif is in ${X11BASE}/lib, you don't need to touch this line.
-#
-#MOTIFLIB= -L${X11BASE}/lib -lXm
-#
-#
-# If you're resident in the USA, this will help various ports to determine
-# whether or not they should attempt to comply with the various U.S.
-# export regulations on certain types of software which do not apply to
-# anyone else in the world.
-#
-#USA_RESIDENT= YES
-#
-# Next one will help ports developers to debug
-#
-#FORCE_PKG_REGISTER= YES
-#
-#
-# Port master sites.
-#
-# If you want your port fetches to go somewhere else than the default
-# (specified below) in case the distfile/patchfile was not found,
-# uncomment this and change it to a location nearest you. (Don't
-# remove the "/${DIST_SUBDIR}/" part.)
-#
-#MASTER_SITE_BACKUP?= \
-# ftp://ftp.freebsd.org/pub/FreeBSD/ports/distfiles/${DIST_SUBDIR}/
-#
-# If you want your port fetches to check the above site first (before
-# the MASTER_SITES specified in the port Makefiles), uncomment the
-# line below. You can also change the right side to point to wherever
-# you want.
-#
-#MASTER_SITE_OVERRIDE?= ${MASTER_SITE_BACKUP}
-#
-# Some ports use a special variable to point to a collection of
-# mirrors of well-known software archives. If you have a mirror close
-# to you, uncomment any of the following lines and change it to that
-# address. (Don't remove the "/%SUBDIR%/" part.)
-#
-# Note: the right hand sides of the following lines are only for your
-# information. For a full list of default sites, take a look at
-# bsd.port.mk.
-#
-#MASTER_SITE_XCONTRIB= ftp://ftp.x.org/contrib/%SUBDIR%/
-#MASTER_SITE_GNU= ftp://prep.ai.mit.edu/pub/gnu/%SUBDIR%/
-#MASTER_SITE_PERL_CPAN= ftp://ftp.digital.com/pub/plan/perl/CPAN/modules/by-module/%SUBDIR%/
-#MASTER_SITE_TEX_CTAN= ftp://ftp.tex.ac.uk/tex-archive/%SUBDIR%/
-#MASTER_SITE_SUNSITE= ftp://metalab.unc.edu/pub/Linux/%SUBDIR%/
-#MASTER_SITE_KDE= ftp://ftp.kde.org/pub/kde/%SUBDIR%/
-#MASTER_SITE_COMP_SOURCES= ftp://gatekeeper.dec.com/pub/usenet/comp.sources.%SUBDIR%/
-#MASTER_SITE_GNOME= ftp://ftp.gnome.org/pub/GNOME/sources/%SUBDIR%/
-#MASTER_SITE_AFTERSTEP= ftp://ftp.afterstep.org/%SUBDIR%/
-#MASTER_SITE_WINDOWMAKER= ftp://ftp.windowmaker.org/pub/%SUBDIR%/
-#
-#
-# Kerberos IV
-# If you want KerberosIV (KTH eBones), define this:
-#
-#MAKE_KERBEROS4= yes
-#
-#
-# Kerberos 5
-# If you want KerberosIV (KTH Heimdal), define this:
-# ** WARNING **
-# ** WARNING ** This is very experimental at this stage. If you
-# ** WARNING ** need stable Kerberos5, rather use the port(s).
-# ** WARNING **
-#
-#MAKE_KERBEROS5= yes
-#
-#
-# Kerberos5
-# If you want to install MIT Kerberos5 port somewhere other than /usr/local,
-# define this (this is also used to tell ssh1 that kerberos is needed):
-#
-#KRB5_HOME= /usr/local
-#
-#
-# CVSup update flags. Edit SUPFILE settings to reflect whichever distribution
-# file(s) you use on your site (see /usr/share/examples/cvsup/README for more
-# information on CVSup and these files). To use, do "make update" in /usr/src.
-#
-#SUP_UPDATE= yes
-#
-#SUP= /usr/local/bin/cvsup
-#SUPFLAGS= -g -L 2
-#SUPFILE= /usr/share/examples/cvsup/standard-supfile
-#SUPFILE1= /usr/share/examples/cvsup/secure-supfile
-#PORTSSUPFILE= /usr/share/examples/cvsup/ports-supfile
-#DOCSUPFILE= /usr/share/examples/cvsup/doc-supfile
-#
-# top(1) uses a hash table for the user names. The size of this hash
-# can be tuned to match the number of local users. The table size should
-# be a prime number approximately twice as large as the number of lines in
-# /etc/passwd. The default number is 20011.
-#
-#TOP_TABLE_SIZE= 101
diff --git a/share/examples/pppd/ppp.deny.sample b/share/examples/pppd/ppp.deny.sample
deleted file mode 100644
index 6d06f4fac32e..000000000000
--- a/share/examples/pppd/ppp.deny.sample
+++ /dev/null
@@ -1,17 +0,0 @@
-# $FreeBSD$
-#
-# list of users disallowed any pppd access via 'system
-# password login'.
-# read by pppd(8).
-root
-toor
-daemon
-operator
-bin
-games
-news
-man
-ftp
-uucp
-xten
-ingres
diff --git a/share/examples/pppd/ppp.shells.sample b/share/examples/pppd/ppp.shells.sample
deleted file mode 100644
index 7d26d62a5054..000000000000
--- a/share/examples/pppd/ppp.shells.sample
+++ /dev/null
@@ -1,13 +0,0 @@
-# $FreeBSD$
-#
-# List of acceptable shells for pppd(8).
-# Pppd will not accept a system password login
-# by a user whose shell is not listed below.
-
-/bin/sh
-/bin/csh
-/usr/local/bin/ksh
-/usr/local/bin/zsh
-/usr/local/bin/bash
-/usr/local/bin/tcsh
-/usr/local/bin/ppplogin.sh
diff --git a/share/man/man3/pthread_cancel.3 b/share/man/man3/pthread_cancel.3
deleted file mode 100644
index dd03f613ab12..000000000000
--- a/share/man/man3/pthread_cancel.3
+++ /dev/null
@@ -1,78 +0,0 @@
-.\" $FreeBSD$
-.Dd January 17, 1999
-.Dt PTHREAD_CANCEL 3
-.Os
-.Sh NAME
-.Nm pthread_cancel
-.Nd cancel execution of a thread
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_cancel "pthread_t thread"
-.Sh DESCRIPTION
-The
-.Fn pthread_cancel
-function requests that
-.Fa thread
-be canceled.
-The target thread's cancelability state and type determines
-when the cancellation takes effect.
-When the cancellation is acted on,
-the cancellation cleanup handlers for
-.Fa thread
-are called.
-When the last cancellation cleanup handler returns,
-the thread-specific data destructor functions will be called for
-.Fa thread .
-When the last destructor function returns,
-.Fa thread
-will be terminated.
-.Pp
-The cancellation processing in the target thread runs asynchronously with
-respect to the calling thread returning from
-.Fn pthread_cancel .
-.Pp
-A status of
-.Dv PTHREAD_CANCELED
-is made available to any threads joining with the target.
-The symbolic
-constant
-.Dv PTHREAD_CANCELED
-expands to a constant expression of type
-.Ft "(void *)" ,
-whose value matches no pointer to an object in memory nor the value
-.Dv NULL .
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_cancel
-functions will return zero.
-Otherwise an error number will be returned to
-indicate the error.
-.Sh ERRORS
-.Fn pthread_cancel
-will fail if:
-.Bl -tag -width Er
-.It Bq Er ESRCH
-No thread could be found corresponding to that specified by the given
-thread ID.
-.El
-.Sh SEE ALSO
-.Xr pthread_cleanup_pop 3 ,
-.Xr pthread_cleanup_push 3 ,
-.Xr pthread_exit 3 ,
-.Xr pthread_join 3 ,
-.Xr pthread_setcancelstate 3 ,
-.Xr pthread_setcanceltype 3 ,
-.Xr pthread_testcancel 3
-.Sh STANDARDS
-.Fn pthread_cancel
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
-.Sh AUTHORS
-This man page was written by
-.An David Leonard Aq d@openbsd.org
-for the
-.Ox
-implementation of
-.Fn pthread_cancel .
diff --git a/share/man/man3/pthread_cleanup_pop.3 b/share/man/man3/pthread_cleanup_pop.3
deleted file mode 100644
index 009a85e91d9a..000000000000
--- a/share/man/man3/pthread_cleanup_pop.3
+++ /dev/null
@@ -1,63 +0,0 @@
-.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com>
-.\" 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 author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd July 30, 1998
-.Dt PTHREAD_CLEANUP_POP 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_cleanup_pop
-.Nd call the first cleanup routine
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft void
-.Fn pthread_cleanup_pop "int execute"
-.Sh DESCRIPTION
-The
-.Fn pthread_cleanup_pop
-function pops the top cleanup routine off of the current threads cleanup
-routine stack, and, if
-.Fa execute
-is non-zero, it will execute the function.
-If there is no cleanup routine
-then
-.Fn pthread_cleanup_pop
-does nothing.
-.Sh RETURN VALUES
-.Fn pthread_cleanup_pop
-does not return any value.
-.Sh ERRORS
-None
-.Sh SEE ALSO
-.Xr pthread_cleanup_push 3 ,
-.Xr pthread_exit 3
-.Sh STANDARDS
-.Fn pthread_cleanup_pop
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/share/man/man3/pthread_cleanup_push.3 b/share/man/man3/pthread_cleanup_push.3
deleted file mode 100644
index 4f260affbc32..000000000000
--- a/share/man/man3/pthread_cleanup_push.3
+++ /dev/null
@@ -1,65 +0,0 @@
-.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com>
-.\" 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 author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd July 30, 1998
-.Dt PTHREAD_CLEANUP_PUSH 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_cleanup_push
-.Nd add a cleanup function for thread exit
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft void
-.Fn pthread_cleanup_push "void (*cleanup_routine)(void *)" "void *arg"
-.Sh DESCRIPTION
-The
-.Fn pthread_cleanup_push
-function adds
-.Fa cleanup_routine
-to the top of the stack of cleanup handlers that
-get called when the current thread exits.
-.Pp
-When
-.Fn pthread_cleanup_push
-is called, it is passed
-.Fa arg
-as its only argument.
-.Sh RETURN VALUES
-.Fn pthread_cleanup_push
-does not return any value.
-.Sh ERRORS
-None
-.Sh SEE ALSO
-.Xr pthread_cleanup_pop 3 ,
-.Xr pthread_exit 3
-.Sh STANDARDS
-.Fn pthread_cleanup_push
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/share/man/man3/pthread_cond_broadcast.3 b/share/man/man3/pthread_cond_broadcast.3
deleted file mode 100644
index 6112695c9893..000000000000
--- a/share/man/man3/pthread_cond_broadcast.3
+++ /dev/null
@@ -1,70 +0,0 @@
-.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com>
-.\" 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 author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd July 28, 1998
-.Dt PTHREAD_COND_BROADCAST 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_cond_broadcast
-.Nd unblock all threads waiting for a condition variable
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_cond_broadcast "pthread_cond_t *cond"
-.Sh DESCRIPTION
-The
-.Fn pthread_cond_broadcast
-function unblocks all threads waiting for the condition variable
-.Fa cond .
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_cond_broadcast
-function will return zero, otherwise an error number will be returned
-to indicate the error.
-.Sh ERRORS
-.Fn pthread_cond_broadcast
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The value specified by
-.Fa cond
-is invalid.
-.El
-.Pp
-.Sh SEE ALSO
-.Xr pthread_cond_destroy 3 ,
-.Xr pthread_cond_init 3 ,
-.Xr pthread_cond_signal 3 ,
-.Xr pthread_cond_timedwait 3 ,
-.Xr pthread_cond_wait 3
-.Sh STANDARDS
-.Fn pthread_cond_broadcast
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/share/man/man3/pthread_cond_destroy.3 b/share/man/man3/pthread_cond_destroy.3
deleted file mode 100644
index a9c4a9dbbdf7..000000000000
--- a/share/man/man3/pthread_cond_destroy.3
+++ /dev/null
@@ -1,74 +0,0 @@
-.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com>
-.\" 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 author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd July 28, 1998
-.Dt PTHREAD_COND_DESTROY 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_cond_destroy
-.Nd destroy a condition variable
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_cond_destroy "pthread_cond_t *cond"
-.Sh DESCRIPTION
-The
-.Fn pthread_cond_destroy
-function frees the resources allocated by the condition variable
-.Fa cond .
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_cond_destroy
-function will return zero, otherwise an error number will be returned
-to indicate the error.
-.Sh ERRORS
-.Fn pthread_cond_destroy
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The value specified by
-.Fa cond
-is invalid.
-.It Bq Er EBUSY
-The variable
-.Fa cond
-is locked by another thread.
-.El
-.Pp
-.Sh SEE ALSO
-.Xr pthread_cond_broadcast 3 ,
-.Xr pthread_cond_init 3 ,
-.Xr pthread_cond_signal 3 ,
-.Xr pthread_cond_timedwait 3 ,
-.Xr pthread_cond_wait 3
-.Sh STANDARDS
-.Fn pthread_cond_destroy
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/share/man/man3/pthread_cond_init.3 b/share/man/man3/pthread_cond_init.3
deleted file mode 100644
index 2783672ce3d9..000000000000
--- a/share/man/man3/pthread_cond_init.3
+++ /dev/null
@@ -1,79 +0,0 @@
-.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com>
-.\" 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 author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd July 28, 1998
-.Dt PTHREAD_COND_INIT 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_cond_init
-.Nd create a condition variable
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_cond_init "pthread_cond_t *cond" "const pthread_condattr_t *attr"
-.Sh DESCRIPTION
-The
-.Fn pthread_cond_init
-function creates a new condition variable, with attributes specified with
-.Fa attr .
-If
-.Fa attr
-is NULL the default attributes are used.
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_cond_init
-function will return zero and put the new condition variable id into
-.Fa cond ,
-otherwise an error number will be returned to indicate the error.
-.Sh ERRORS
-.Fn pthread_cond_init
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The value specified by
-.Fa attr
-is invalid.
-.It Bq Er ENOMEM
-The process cannot allocate enough memory to create another condition
-variable.
-.It Bq Er EAGAIN
-The temporarily lacks the resources to create another condition variable.
-.El
-.Pp
-.Sh SEE ALSO
-.Xr pthread_cond_broadcast 3 ,
-.Xr pthread_cond_destroy 3 ,
-.Xr pthread_cond_signal 3 ,
-.Xr pthread_cond_timedwait 3 ,
-.Xr pthread_cond_wait 3
-.Sh STANDARDS
-.Fn pthread_cond_init
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/share/man/man3/pthread_cond_signal.3 b/share/man/man3/pthread_cond_signal.3
deleted file mode 100644
index e3a22f88cf6c..000000000000
--- a/share/man/man3/pthread_cond_signal.3
+++ /dev/null
@@ -1,70 +0,0 @@
-.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com>
-.\" 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 author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd July 28, 1998
-.Dt PTHREAD_COND_SIGNAL 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_cond_signal
-.Nd unblock a thread waiting for a condition variable
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_cond_signal "pthread_cond_t *cond"
-.Sh DESCRIPTION
-The
-.Fn pthread_cond_signal
-function unblocks one thread waiting for the condition variable
-.Fa cond .
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_cond_signal
-function will return zero, otherwise an error number will be returned
-to indicate the error.
-.Sh ERRORS
-.Fn pthread_cond_signal
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The value specified by
-.Fa cond
-is invalid.
-.El
-.Pp
-.Sh SEE ALSO
-.Xr pthread_cond_broadcast 3 ,
-.Xr pthread_cond_destroy 3 ,
-.Xr pthread_cond_init 3 ,
-.Xr pthread_cond_timedwait 3 ,
-.Xr pthread_cond_wait 3
-.Sh STANDARDS
-.Fn pthread_cond_signal
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/share/man/man3/pthread_cond_timedwait.3 b/share/man/man3/pthread_cond_timedwait.3
deleted file mode 100644
index 15f4bb3d64c3..000000000000
--- a/share/man/man3/pthread_cond_timedwait.3
+++ /dev/null
@@ -1,89 +0,0 @@
-.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com>
-.\" 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 author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd July 28, 1998
-.Dt PTHREAD_COND_TIMEDWAIT 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_cond_timedwait
-.Nd wait on a condition variable for a specific amount of time
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_cond_timedwait "pthread_cond_t *cond" "pthread_mutex_t *mutex" "const struct timespec *abstime"
-.Sh DESCRIPTION
-The
-.Fn pthread_cond_timedwait
-function atomically blocks the current thread waiting on the condition
-variable specified by
-.Fa cond ,
-and unblocks the mutex specified by
-.Fa mutex .
-The waiting thread unblocks only after another thread calls
-.Xr pthread_cond_signal 3 ,
-or
-.Xr pthread_cond_broadcast 3
-with the same condition variable, or if the system time reaches the
-time specified in
-.Fa abstime ,
-and the current thread requires the lock on
-.Fa mutex .
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_cond_timedwait
-function will return zero.
-Otherwise an error number will be returned to
-indicate the error.
-.Sh ERRORS
-.Fn pthread_cond_timedwait
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The value specified by
-.Fa cond ,
-.Fa mutex
-or
-.Fa abstime
-is invalid.
-.It Bq Er ETIMEDOUT
-The system time has reached or exceeded the time specified in
-.Fa abstime .
-.El
-.Pp
-.Sh SEE ALSO
-.Xr pthread_cond_broadcast 3 ,
-.Xr pthread_cond_destroy 3 ,
-.Xr pthread_cond_init 3 ,
-.Xr pthread_cond_signal 3 ,
-.Xr pthread_cond_wait 3
-.Sh STANDARDS
-.Fn pthread_cond_timedwait
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/share/man/man3/pthread_cond_wait.3 b/share/man/man3/pthread_cond_wait.3
deleted file mode 100644
index e93114c7d924..000000000000
--- a/share/man/man3/pthread_cond_wait.3
+++ /dev/null
@@ -1,82 +0,0 @@
-.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com>
-.\" 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 author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd July 28, 1998
-.Dt PTHREAD_COND_WAIT 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_cond_wait
-.Nd wait on a condition variable
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_cond_wait "pthread_cond_t *cond" "pthread_mutex_t *mutex"
-.Sh DESCRIPTION
-The
-.Fn pthread_cond_wait
-function atomically blocks the current thread waiting on the condition
-variable specified by
-.Fa cond ,
-and unblocks the mutex specified by
-.Fa mutex .
-The waiting thread unblocks only after another thread calls
-.Xr pthread_cond_signal 3 , or
-.Xr pthread_cond_broadcast 3
-with the same condition variable, and the current thread requires the lock
-on
-.Fa mutex .
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_cond_wait
-function will return zero.
-Otherwise an error number will be returned to
-indicate the error.
-.Sh ERRORS
-.Fn pthread_cond_wait
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The value specified by
-.Fa cond
-or the value specified by
-.Fa mutex
-is invalid.
-.El
-.Pp
-.Sh SEE ALSO
-.Xr pthread_cond_broadcast 3 ,
-.Xr pthread_cond_destroy 3 ,
-.Xr pthread_cond_init 3 ,
-.Xr pthread_cond_signal 3 ,
-.Xr pthread_cond_timedwait 3
-.Sh STANDARDS
-.Fn pthread_cond_wait
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/share/man/man3/pthread_create.3 b/share/man/man3/pthread_create.3
deleted file mode 100644
index 3e1ed04e80aa..000000000000
--- a/share/man/man3/pthread_create.3
+++ /dev/null
@@ -1,121 +0,0 @@
-.\" Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>.
-.\" 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 John Birrell.
-.\" 4. Neither the name of the author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd April 4, 1996
-.Dt PTHREAD_CREATE 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_create
-.Nd create a new thread
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_create "pthread_t *thread" "const pthread_attr_t *attr" "void *(*start_routine)(void *)" "void *arg"
-.Sh DESCRIPTION
-The
-.Fn pthread_create
-function is used to create a new thread, with attributes specified by
-.Fa attr ,
-within a process.
-If
-.Fa attr
-is NULL, the default attributes are used.
-If the attributes specified by
-.Fa attr
-are modified later, the thread's attributes are not affected.
-Upon
-successful completion
-.Fn pthread_create
-will store the ID of the created thread in the location specified by
-.Fa thread .
-.Pp
-The thread is created executing
-.Fa start_routine
-with
-.Fa arg
-as its sole argument.
-If the
-.Fa start_routine
-returns, the effect is as if there was an implicit call to
-.Fn pthread_exit
-using the return value of
-.Fa start_routine
-as the exit status.
-Note that the thread in which
-.Fn main
-was originally invoked differs from this.
-When it returns from
-.Fn main ,
-the effect is as if there was an implicit call to
-.Fn exit
-using the return value of
-.Fn main
-as the exit status.
-.Pp
-The signal state of the new thread is initialized as:
-.Bl -bullet -offset indent
-.It
-The signal mask is inherited from the creating thread.
-.It
-The set of signals pending for the new thread is empty.
-.El
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_create
-function will return zero.
-Otherwise an error number will be returned to
-indicate the error.
-.Sh ERRORS
-.Fn pthread_create
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EAGAIN
-The system lacked the necessary resources to create another thread, or
-the system-imposed limit on the total number of threads in a process
-[PTHREAD_THREADS_MAX] would be exceeded.
-.It Bq Er EINVAL
-The value specified by
-.Fa attr
-is invalid.
-.El
-.Pp
-.Sh SEE ALSO
-.Xr fork 2 ,
-.Xr pthread_cleanup_pop 3 ,
-.Xr pthread_cleanup_push 3 ,
-.Xr pthread_exit 3 ,
-.Xr pthread_join 3
-.Sh STANDARDS
-.Fn pthread_create
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/share/man/man3/pthread_detach.3 b/share/man/man3/pthread_detach.3
deleted file mode 100644
index 120248d19d98..000000000000
--- a/share/man/man3/pthread_detach.3
+++ /dev/null
@@ -1,89 +0,0 @@
-.\" Copyright (c) 1996-1998 John Birrell <jb@cimlogic.com.au>.
-.\" 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 John Birrell.
-.\" 4. Neither the name of the author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd April 4, 1996
-.Dt PTHREAD_DETACH 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_detach
-.Nd detach a thread
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_detach "pthread_t thread"
-.Sh DESCRIPTION
-The
-.Fn pthread_detach
-function is used to indicate to the implementation that storage for the
-thread
-.Fa thread
-can be reclaimed when the thread terminates.
-If
-.Fa thread
-has not terminated,
-.Fn pthread_detach
-will not cause it to terminate.
-The effect of multiple
-.Fn pthread_detach
-calls on the same target thread is unspecified.
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_detach
-function will return zero.
-Otherwise an error number will be returned to
-indicate the error.
-Note that the function does not change the value
-of errno as it did for some drafts of the standard.
-These early drafts
-also passed a pointer to pthread_t as the argument.
-Beware!
-.Sh ERRORS
-.Fn pthread_detach
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The implementation has detected that the value specified by
-.Fa thread
-does not refer to a joinable thread.
-.It Bq Er ESRCH
-No thread could be found corresponding to that specified by the given
-thread ID,
-.Fa thread .
-.El
-.Pp
-.Sh SEE ALSO
-.Xr pthread_join 3
-.Sh STANDARDS
-.Fn pthread_detach
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/share/man/man3/pthread_equal.3 b/share/man/man3/pthread_equal.3
deleted file mode 100644
index 5d443b3cb2c6..000000000000
--- a/share/man/man3/pthread_equal.3
+++ /dev/null
@@ -1,68 +0,0 @@
-.\" Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>.
-.\" 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 John Birrell.
-.\" 4. Neither the name of the author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd April 4, 1996
-.Dt PTHREAD_EQUAL 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_equal
-.Nd compare thread IDs
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_equal "pthread_t t1" "pthread_t t2"
-.Sh DESCRIPTION
-The
-.Fn pthread_equal
-function compares the thread IDs
-.Fa t1
-and
-.Fa t2 .
-.Sh RETURN VALUES
-The
-.Fn pthread_equal
-function will non-zero if the thread IDs
-.Fa t1
-and
-.Fa t2
-correspond to the same thread, otherwise it will return zero.
-.Sh ERRORS
-None.
-.Pp
-.Sh SEE ALSO
-.Xr pthread_create 3 ,
-.Xr pthread_exit 3
-.Sh STANDARDS
-.Fn pthread_equal
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/share/man/man3/pthread_exit.3 b/share/man/man3/pthread_exit.3
deleted file mode 100644
index a5ff1b96ea9d..000000000000
--- a/share/man/man3/pthread_exit.3
+++ /dev/null
@@ -1,105 +0,0 @@
-.\" Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>.
-.\" 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 John Birrell.
-.\" 4. Neither the name of the author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd April 4, 1996
-.Dt PTHREAD_EXIT 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_exit
-.Nd terminate the calling thread
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft void
-.Fn pthread_exit "void *value_ptr"
-.Sh DESCRIPTION
-The
-.Fn pthread_exit
-function terminates the calling thread and makes the value
-.Fa value_ptr
-available to any successful join with the terminating thread.
-Any
-cancellation cleanup handlers that have been pushed and are not yet popped
-are popped in the reverse order that they were pushed and then executed.
-After all cancellation handlers have been executed, if the thread has any
-thread-specific data, appropriate destructor functions are called in an
-unspecified order.
-Thread termination does not release any application
-visible process resources, including, but not limited to, mutexes and
-file descriptors, nor does it perform any process level cleanup
-actions, including, but not limited to, calling
-.Fn atexit
-routines that may exist.
-.Pp
-An implicit call to
-.Fn pthread_exit
-is made when a thread other than the thread in which
-.Fn main
-was first invoked returns from the start routine that was used to create
-it. The function's return value serves as the thread's exit status.
-.Pp
-The behavior of
-.Fn pthread_exit
-is undefied if called from a cancellation handler or destructor function
-that was invoked as the result of an implicit or explicit call to
-.Fn pthread_exit .
-.Pp
-After a thread has terminated, the result of access to local (auto)
-variables of the thread is undefined.
-Thus, references to local variables
-of the exiting thread should not be used for the
-.Fn pthread_exit
-.Fa value_ptr
-parameter value.
-.Pp
-The process will exit with an exit status of 0 after the last thread has
-been terminated.
-The behavior is as if the implementation called
-.Fn exit
-with a zero argument at thread termination time.
-.Pp
-.Sh RETURN VALUES
-The
-.Fn pthread_exit
-function cannot return to its caller.
-.Sh ERRORS
-None.
-.Pp
-.Sh SEE ALSO
-.Xr _exit 2 ,
-.Xr exit 3 ,
-.Xr pthread_create 3 ,
-.Xr pthread_join 3
-.Sh STANDARDS
-.Fn pthread_exit
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/share/man/man3/pthread_getspecific.3 b/share/man/man3/pthread_getspecific.3
deleted file mode 100644
index a56254108f6e..000000000000
--- a/share/man/man3/pthread_getspecific.3
+++ /dev/null
@@ -1,82 +0,0 @@
-.\" Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>.
-.\" 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 John Birrell.
-.\" 4. Neither the name of the author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd April 4, 1996
-.Dt PTHREAD_GETSPECIFIC 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_getspecific
-.Nd get a thread-specific data value
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft void *
-.Fn pthread_getspecific "pthread_key_t key"
-.Sh DESCRIPTION
-The
-.Fn pthread_getspecific
-function returns the value currently bound to the specified
-.Fa key
-on behalf of the calling thread.
-.Pp
-The effect of calling
-.Fn pthread_getspecific
-with a
-.Fa key
-value not obtained from
-.Fn pthread_key_create
-or after
-.Fa key
-has been deleted with
-.Fn pthread_key_delete
-is undefined.
-.Pp
-.Fn pthread_getspecific
-may be called from a thread-specific data destructor function.
-.Sh RETURN VALUES
-The
-.Fn pthread_getspecific
-function will return the thread-specific data value associated with the given
-.Fa key .
-If no thread-specific data value is associated with
-.Fa key ,
-then the value NULL is returned.
-.Sh ERRORS
-None.
-.Sh SEE ALSO
-.Xr pthread_key_create 3 ,
-.Xr pthread_key_delete 3 ,
-.Xr pthread_setspecific 3
-.Sh STANDARDS
-.Fn pthread_getspecific
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/share/man/man3/pthread_join.3 b/share/man/man3/pthread_join.3
deleted file mode 100644
index 2e5ae40c105a..000000000000
--- a/share/man/man3/pthread_join.3
+++ /dev/null
@@ -1,105 +0,0 @@
-.\" Copyright (c) 1996-1998 John Birrell <jb@cimlogic.com.au>.
-.\" 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 John Birrell.
-.\" 4. Neither the name of the author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd April 4, 1996
-.Dt PTHREAD_JOIN 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_join
-.Nd wait for thread termination
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_join "pthread_t thread" "void **value_ptr"
-.Sh DESCRIPTION
-The
-.Fn pthread_join
-function suspends execution of the calling thread until the target
-.Fa thread
-terminates unless the target
-.Fa thread
-has already terminated.
-.Pp
-On return from a successful
-.Fn pthread_join
-call with a non-NULL
-.Fa value_ptr
-argument, the value passed to
-.Fn pthread_exit
-by the terminating thread is stored in the location referenced by
-.Fa value_ptr .
-When a
-.Fn pthread_join
-returns successfully, the target thread has been terminated.
-The results
-of multiple simultaneous calls to
-.Fn pthread_join
-specifying the same target thread are undefined.
-If the thread calling
-.Fn pthread_join
-is cancelled, then the target thread is not detached.
-.Pp
-A thread that has exited but remains unjoined counts against
-[_POSIX_THREAD_THREADS_MAX].
-.Pp
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_join
-function will return zero.
-Otherwise an error number will be returned to
-indicate the error.
-.Sh ERRORS
-.Fn pthread_join
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The implementation has detected that the value specified by
-.Fa thread
-does not refer to a joinable thread.
-.It Bq Er ESRCH
-No thread could be found corresponding to that specified by the given
-thread ID,
-.Fa thread .
-.It Bq Er EDEADLK
-A deadlock was detected or the value of
-.Fa thread
-specifies the calling thread.
-.El
-.Pp
-.Sh SEE ALSO
-.Xr wait 2 ,
-.Xr pthread_create 3
-.Sh STANDARDS
-.Fn pthread_join
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/share/man/man3/pthread_key_create.3 b/share/man/man3/pthread_key_create.3
deleted file mode 100644
index 376ecf2fb542..000000000000
--- a/share/man/man3/pthread_key_create.3
+++ /dev/null
@@ -1,107 +0,0 @@
-.\" Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>.
-.\" 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 John Birrell.
-.\" 4. Neither the name of the author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd April 4, 1996
-.Dt PTHREAD_KEY_CREATE 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_key_create
-.Nd thread-specific data key creation
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_key_create "pthread_key_t *key" "void (*destructor)(void *)"
-.Sh DESCRIPTION
-The
-.Fn pthread_key_create
-function creates a thread-specific data key visible to all threads in the
-process.
-Key values provided by
-.Fn pthread_key_create
-are opaque objects used to locate thread-specific data.
-Although the same
-key value may be used by different threads, the values bound to the key
-by
-.Fn pthread_setspecific
-are maintained on a per-thread basis and persist for the life of the calling
-thread.
-.Pp
-Upon key creation, the value NULL is associated with the new key in all
-active threads.
-Upon thread creation, the value NULL is associated with all
-defined keys in the new thread.
-.Pp
-An optional destructor function may be associated with each key value.
-At
-thread exit, if a key value has a non-NULL destructor pointer, and the
-thread has a non-NULL value associated with the key, the function pointed
-to is called with the current associated value as its sole argument.
-The
-order of destructor calls is unspecified if more than one destructor exists
-for a thread when it exits.
-.Pp
-If, after all the destructors have been called for all non-NULL values
-with associated destructors, there are still some non-NULL values with
-associated destructors, then the process is repeated.
-If, after at least
-[PTHREAD_DESTRUCTOR_ITERATIONS] iterations of destructor calls for
-outstanding non-NULL values, there are still some non-NULL values with
-associated destructors, the implementation stops calling destructors.
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_key_create
-function will store the newly created key value at the location specified by
-.Fa key
-and returns zero.
-Otherwise an error number will be returned to indicate
-the error.
-.Sh ERRORS
-.Fn pthread_key_create
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EAGAIN
-The system lacked the necessary resources to create another thread-specific
-data key, or the system-imposed limit on the total number of keys per process
-[PTHREAD_KEYS_MAX] would be exceeded.
-.It Bq Er ENOMEM
-Insufficient memory exists to create the key.
-.El
-.Pp
-.Sh SEE ALSO
-.Xr pthread_getspecific 3 ,
-.Xr pthread_key_delete 3 ,
-.Xr pthread_setspecific 3
-.Sh STANDARDS
-.Fn pthread_key_create
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/share/man/man3/pthread_key_delete.3 b/share/man/man3/pthread_key_delete.3
deleted file mode 100644
index 25f110f3be0b..000000000000
--- a/share/man/man3/pthread_key_delete.3
+++ /dev/null
@@ -1,98 +0,0 @@
-.\" Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>.
-.\" 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 John Birrell.
-.\" 4. Neither the name of the author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd April 4, 1996
-.Dt PTHREAD_KEY_DELETE 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_key_delete
-.Nd delete a thread-specific data key
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_key_delete "pthread_key_t key"
-.Sh DESCRIPTION
-The
-.Fn pthread_key_delete
-function deletes a thread-specific data key previously returned by
-.Fn pthread_key_create .
-The thread-specific data values associated with
-.Fa key
-need not be NULL at the time that
-.Fn pthread_key_delete
-is called.
-It is the responsibility of the application to free any
-application storage or perform any cleanup actions for data structures
-related to the deleted key or associated thread-specific data in any threads;
-this cleanup can be done either before or after
-.Fn pthread_key_delete
-is called.
-Any attempt to use
-.Fa key
-following the call to
-.Fn pthread_key_delete
-results in undefined behavior.
-.Pp
-The
-.Fn pthread_key_delete
-function is callable from within destructor functions.
-Destructor functions
-are not invoked by
-.Fn pthread_key_delete .
-Any destructor function that may have been associated with
-.Fa key
-will no longer be called upon thread exit.
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_key_delete
-function will return zero.
-Otherwise an error number will be returned to
-indicate the error.
-.Sh ERRORS
-.Fn pthread_key_delete
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The
-.Fa key
-value is invalid.
-.El
-.Pp
-.Sh SEE ALSO
-.Xr pthread_getspecific 3 ,
-.Xr pthread_key_create 3 ,
-.Xr pthread_setspecific 3
-.Sh STANDARDS
-.Fn pthread_key_delete
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/share/man/man3/pthread_mutex_destroy.3 b/share/man/man3/pthread_mutex_destroy.3
deleted file mode 100644
index 517d6ebadf5d..000000000000
--- a/share/man/man3/pthread_mutex_destroy.3
+++ /dev/null
@@ -1,72 +0,0 @@
-.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com>
-.\" 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 author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd July 29, 1998
-.Dt PTHREAD_MUTEX_DESTROY 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_mutex_destroy
-.Nd free resources allocated for a mutex
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_mutex_destroy "pthread_mutex_t *mutex"
-.Sh DESCRIPTION
-The
-.Fn pthread_mutex_destroy
-function frees the resources allocated for
-.Fa mutex .
-.Sh RETURN VALUES
-If successful,
-.Fn pthread_mutex_destroy
-will return zero, otherwise an error number will be returned to
-indicate the error.
-.Sh ERRORS
-.Fn pthread_mutex_destroy
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The value specified by
-.Fa mutex
-is invalid.
-.It Bq Er EBUSY
-.Fa Mutex
-is locked by another thread.
-.El
-.Pp
-.Sh SEE ALSO
-.Xr pthread_mutex_init 3 ,
-.Xr pthread_mutex_lock 3 ,
-.Xr pthread_mutex_trylock 3 ,
-.Xr pthread_mutex_unlock 3
-.Sh STANDARDS
-.Fn pthread_mutex_destroy
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/share/man/man3/pthread_mutex_init.3 b/share/man/man3/pthread_mutex_init.3
deleted file mode 100644
index 926b034b6011..000000000000
--- a/share/man/man3/pthread_mutex_init.3
+++ /dev/null
@@ -1,77 +0,0 @@
-.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com>
-.\" 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 author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd July 29, 1998
-.Dt PTHREAD_MUTEX_INIT 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_mutex_init
-.Nd create a mutex
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_mutex_init "pthread_mutex_t *mutex" "const pthread_mutexattr_t *attr"
-.Sh DESCRIPTION
-The
-.Fn pthread_mutex_init
-function creates a new mutex, with attributes specified with
-.Fa attr .
-If
-.Fa attr
-is NULL the default attributes are used.
-.Sh RETURN VALUES
-If successful,
-.Fn pthread_mutex_init
-will return zero and put the new mutex id into
-.Fa mutex ,
-otherwise an error number will be returned to indicate the error.
-.Sh ERRORS
-.Fn pthread_mutex_init
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The value specified by
-.Fa attr
-is invalid.
-.It Bq Er ENOMEM
-The process cannot allocate enough memory to create another mutex.
-.It Bq Er EAGAIN
-The temporarily lacks the resources to create another mutex.
-.El
-.Pp
-.Sh SEE ALSO
-.Xr pthread_mutex_destroy 3 ,
-.Xr pthread_mutex_lock 3 ,
-.Xr pthread_mutex_trylock 3 ,
-.Xr pthread_mutex_unlock 3
-.Sh STANDARDS
-.Fn pthread_mutex_init
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/share/man/man3/pthread_mutex_lock.3 b/share/man/man3/pthread_mutex_lock.3
deleted file mode 100644
index 36473733ce11..000000000000
--- a/share/man/man3/pthread_mutex_lock.3
+++ /dev/null
@@ -1,74 +0,0 @@
-.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com>
-.\" 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 author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd July 30, 1998
-.Dt PTHREAD_MUTEX_LOCK 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_mutex_lock
-.Nd lock a mutex
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_mutex_lock "pthread_mutex_t *mutex"
-.Sh DESCRIPTION
-The
-.Fn pthread_mutex_lock
-function locks
-.Fa mutex .
-If the mutex is already locked, the calling thread will block until the
-mutex becomes available.
-.Sh RETURN VALUES
-If successful,
-.Fn pthread_mutex_lock
-will return zero, otherwise an error number will be returned to
-indicate the error.
-.Sh ERRORS
-.Fn pthread_mutex_lock
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The value specified by
-.Fa mutex
-is invalid.
-.It Bq Er EDEADLK
-A deadlock would occur if the thread blocked waiting for
-.Fa mutex .
-.El
-.Pp
-.Sh SEE ALSO
-.Xr pthread_mutex_destroy 3 ,
-.Xr pthread_mutex_init 3 ,
-.Xr pthread_mutex_trylock 3 ,
-.Xr pthread_mutex_unlock 3
-.Sh STANDARDS
-.Fn pthread_mutex_lock
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/share/man/man3/pthread_mutex_trylock.3 b/share/man/man3/pthread_mutex_trylock.3
deleted file mode 100644
index 30faaa81bd4d..000000000000
--- a/share/man/man3/pthread_mutex_trylock.3
+++ /dev/null
@@ -1,75 +0,0 @@
-.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com>
-.\" 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 author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd July 30, 1998
-.Dt PTHREAD_MUTEX_TRYLOCK 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_mutex_trylock
-.Nd attempt to lock a mutex without blocking
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_mutex_trylock "pthread_mutex_t *mutex"
-.Sh DESCRIPTION
-The
-.Fn pthread_mutex_trylock
-function locks
-.Fa mutex .
-If the mutex is already locked,
-.Fn pthread_mutex_trylock
-will not block waiting for the mutex, but will return an error condition.
-.Sh RETURN VALUES
-If successful,
-.Fn pthread_mutex_trylock
-will return zero, otherwise an error number will be returned to
-indicate the error.
-.Sh ERRORS
-.Fn pthread_mutex_trylock
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The value specified by
-.Fa mutex
-is invalid.
-.It Bq Er EBUSY
-.Fa Mutex
-is already locked.
-.El
-.Pp
-.Sh SEE ALSO
-.Xr pthread_mutex_destroy 3 ,
-.Xr pthread_mutex_init 3 ,
-.Xr pthread_mutex_lock 3 ,
-.Xr pthread_mutex_unlock 3
-.Sh STANDARDS
-.Fn pthread_mutex_trylock
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/share/man/man3/pthread_mutex_unlock.3 b/share/man/man3/pthread_mutex_unlock.3
deleted file mode 100644
index 27a4c337fe37..000000000000
--- a/share/man/man3/pthread_mutex_unlock.3
+++ /dev/null
@@ -1,74 +0,0 @@
-.\" Copyright (c) 1997 Brian Cully <shmit@kublai.com>
-.\" 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 author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd July 30, 1998
-.Dt PTHREAD_MUTEX_UNLOCK 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_mutex_unlock
-.Nd unlock a mutex
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_mutex_unlock "pthread_mutex_t *mutex"
-.Sh DESCRIPTION
-If the current thread holds the lock on
-.Fa mutex ,
-then the
-.Fn pthread_mutex_unlock
-function unlocks
-.Fa mutex .
-.Sh RETURN VALUES
-If successful,
-.Fn pthread_mutex_unlock
-will return zero, otherwise an error number will be returned to
-indicate the error.
-.Sh ERRORS
-.Fn pthread_mutex_trylock
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The value specified by
-.Fa mutex
-is invalid.
-.It Bq Er EPERM
-The current thread does not hold a lock on
-.Fa mutex .
-.El
-.Pp
-.Sh SEE ALSO
-.Xr pthread_mutex_destroy 3 ,
-.Xr pthread_mutex_init 3 ,
-.Xr pthread_mutex_lock 3 ,
-.Xr pthread_mutex_trylock 3
-.Sh STANDARDS
-.Fn pthread_mutex_unlock
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/share/man/man3/pthread_once.3 b/share/man/man3/pthread_once.3
deleted file mode 100644
index 8cd894abbd19..000000000000
--- a/share/man/man3/pthread_once.3
+++ /dev/null
@@ -1,106 +0,0 @@
-.\" Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>.
-.\" 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 John Birrell.
-.\" 4. Neither the name of the author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd April 4, 1996
-.Dt PTHREAD_ONCE 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_once
-.Nd dynamic package initialization
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Pp
-pthread_once
-.Fa once_control
-= PTHREAD_ONCE_INIT;
-.Ft int
-.Fn pthread_once "pthread_once_t *once_control" "void (*init_routine)(void)"
-.Sh DESCRIPTION
-The first call to
-.Fn pthread_once
-by any thread in a process, with a given
-.Fa once_control ,
-will call the
-.Fn init_routine
-with no arguments.
-Subsequent calls to
-.Fn pthread_once
-with the same
-.Fa once_control
-will not call the
-.Fn init_routine .
-On return from
-.Fn pthread_once ,
-it is guaranteed that
-.Fn init_routine
-has completed.
-The
-.Fa once_control
-parameter is used to determine whether the associated initialization
-routine has been called.
-.Pp
-The function
-.Fn pthread_once
-is not a cancellation point.
-However, if
-.Fn init_routine
-is a cancellation point and is cancelled, the effect on
-.Fa once_control is as if
-.Fn pthread_once
-was never called.
-.Pp
-The constant
-.Fa PTHREAD_ONCE_INIT
-is defined by header
-.Aq Pa pthread.h .
-.Pp
-The behavior of
-.Fn pthread_once
-is undefined if
-.Fa once_control
-has automatic storage duration or is not initialized by
-.Fa PTHREAD_ONCE_INIT .
-.Pp
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_once
-function will return zero.
-Otherwise an error number will be returned to
-indicate the error.
-.Sh ERRORS
-None.
-.Pp
-.Sh STANDARDS
-.Fn pthread_once
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/share/man/man3/pthread_rwlock_destroy.3 b/share/man/man3/pthread_rwlock_destroy.3
deleted file mode 100644
index 14691c44bbf8..000000000000
--- a/share/man/man3/pthread_rwlock_destroy.3
+++ /dev/null
@@ -1,80 +0,0 @@
-.\" Copyright (c) 1998 Alex Nash
-.\" 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 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd August 4, 1998
-.Dt PTHREAD_RWLOCK_DESTROY 3
-.Os
-.Sh NAME
-.Nm pthread_rwlock_destroy
-.Nd destroy a read/write lock
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_rwlock_destroy "pthread_rwlock_t *lock"
-.Sh DESCRIPTION
-The
-.Fn pthread_rwlock_destroy
-function is used to destroy a read/write lock previously created with
-.Fn pthread_rwlock_init .
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_rwlock_destroy
-function will return zero. Otherwise an error number will be returned
-to indicate the error.
-.Sh SEE ALSO
-.Xr pthread_rwlock_init 3
-.Sh STANDARDS
-The
-.Fn pthread_rwlock_destroy
-function is expected to conform to
-.St -susv2 .
-.Sh ERRORS
-The
-.Fn pthread_rwlock_destroy
-function will fail if:
-.Bl -tag -width Er
-.It Bq Er EPERM
-The caller does not have the privilege to perform the operation.
-.El
-.Pp
-The
-.Fn pthread_rwlock_destroy
-function may fail if:
-.Bl -tag -width Er
-.It Bq Er EBUSY
-The system has detected an attempt to destroy the object referenced by
-.Fa lock
-while it is locked.
-.It Bq Er EINVAL
-The value specified by
-.Fa lock
-is invalid.
-.El
-.Sh HISTORY
-The
-.Fn pthread_rwlock_destroy
-function first appeared in
-.Fx 3.0 .
diff --git a/share/man/man3/pthread_rwlock_init.3 b/share/man/man3/pthread_rwlock_init.3
deleted file mode 100644
index 306af61bbeb4..000000000000
--- a/share/man/man3/pthread_rwlock_init.3
+++ /dev/null
@@ -1,99 +0,0 @@
-.\" Copyright (c) 1998 Alex Nash
-.\" 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 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd August 4, 1998
-.Dt PTHREAD_RWLOCK_INIT 3
-.Os
-.Sh NAME
-.Nm pthread_rwlock_init
-.Nd initialize a read/write lock
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_rwlock_init "pthread_rwlock_t *lock" "const pthread_rwlockattr_t *attr"
-.Sh DESCRIPTION
-The
-.Fn pthread_rwlock_init
-function is used to initialize a read/write lock, with attributes
-specified by
-.Fa attr .
-If
-.Fa attr
-is NULL, the default read/write lock attributes are used.
-.Pp
-The results of calling
-.Fn pthread_rwlock_init
-with an already initialized lock are undefined.
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_rwlock_init
-function will return zero. Otherwise an error number will be returned
-to indicate the error.
-.Sh SEE ALSO
-.Xr pthread_rwlock_destroy 3 ,
-.Xr pthread_rwlockattr_init 3 ,
-.Xr pthread_rwlockattr_setpshared 3
-.Sh STANDARDS
-The
-.Fn pthread_rwlock_init
-function is expected to conform to
-.St -susv2 .
-.Sh ERRORS
-The
-.Fn pthread_rwlock_init
-function will fail if:
-.Bl -tag -width Er
-.It Bq Er EAGAIN
-The system lacked the necessary resources (other than memory) to
-initialize the lock.
-.It Bq Er ENOMEM
-Insufficient memory exists to initialize the lock.
-.It Bq Er EPERM
-The caller does not have sufficient privilege to perform the
-operation.
-.El
-.Pp
-The
-.Fn pthread_rwlock_init
-function may fail if:
-.Bl -tag -width Er
-.It Bq Er EBUSY
-The system has detected an attempt to re-initialize the object
-referenced by
-.Fa lock ,
-a previously initialized but not yet destroyed read/write lock.
-.It Bq Er EINVAL
-The value specified by
-.Fa attr
-is invalid.
-.El
-.Sh HISTORY
-The
-.Fn pthread_rwlock_init
-function first appeared in
-.Fx 3.0 .
-.Sh BUGS
-The PTHREAD_PROCESS_SHARED attribute is not supported.
diff --git a/share/man/man3/pthread_rwlock_rdlock.3 b/share/man/man3/pthread_rwlock_rdlock.3
deleted file mode 100644
index bea219de0100..000000000000
--- a/share/man/man3/pthread_rwlock_rdlock.3
+++ /dev/null
@@ -1,122 +0,0 @@
-.\" Copyright (c) 1998 Alex Nash
-.\" 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 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd August 4, 1998
-.Dt PTHREAD_RWLOCK_RDLOCK 3
-.Os
-.Sh NAME
-.Nm pthread_rwlock_rdlock ,
-.Nm pthread_rwlock_tryrdlock
-.Nd acquire a read/write lock for reading
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_rwlock_rdlock "pthread_rwlock_t *lock"
-.Ft int
-.Fn pthread_rwlock_tryrdlock "pthread_rwlock_t *lock"
-.Sh DESCRIPTION
-The
-.Fn pthread_rwlock_rdlock
-function acquires a read lock on
-.Fa lock
-provided that
-.Fa lock
-is not presently held for writing and no writer threads are
-presently blocked on the lock. If the read lock cannot be
-immediately acquired, the calling thread blocks until it can
-acquire the lock.
-.Pp
-The
-.Fn pthread_rwlock_tryrdlock
-function performs the same action, but does not block if the lock
-cannot be immediately obtained (i.e. the lock is held for writing
-or there are waiting writers).
-.Pp
-A thread may hold multiple concurrent read locks. If so,
-.Fn pthread_rwlock_unlock
-must be called once for each lock obtained.
-.Pp
-The results of acquiring a read lock while the calling thread holds
-a write lock are undefined.
-.Sh IMPLEMENTATION NOTES
-To prevent writer starvation, writers are favored over readers.
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_rwlock_rdlock
-and
-.Fn pthread_rwlock_tryrdlock
-functions will return zero. Otherwise an error number will be returned
-to indicate the error.
-.Sh SEE ALSO
-.Xr pthread_rwlock_init 3 ,
-.Xr pthread_rwlock_trywrlock 3 ,
-.Xr pthread_rwlock_unlock 3 ,
-.Xr pthread_rwlock_wrlock 3
-.Sh STANDARDS
-The
-.Fn pthread_rwlock_rdlock
-and
-.Fn pthread_rwlock_tryrdlock
-functions are expected to conform to
-.St -susv2 .
-.Sh ERRORS
-The
-.Fn pthread_rwlock_tryrdlock
-function will fail if:
-.Bl -tag -width Er
-.It Bq Er EBUSY
-The lock could not be acquired because a writer holds the lock or
-was blocked on it.
-.El
-.Pp
-The
-.Fn pthread_rwlock_rdlock
-and
-.Fn pthread_rwlock_tryrdlock
-functions may fail if:
-.Bl -tag -width Er
-.It Bq Er EAGAIN
-The lock could not be acquired because the maximum number of read locks
-against
-.Fa lock
-has been exceeded.
-.It Bq Er EDEADLK
-The current thread already owns
-.Fa lock
-for writing.
-.It Bq Er EINVAL
-The value specified by
-.Fa lock
-is invalid.
-.It Bq Er ENOMEM
-Insufficient memory exists to initialize the lock (applies to
-statically initialized locks only).
-.El
-.Sh HISTORY
-The
-.Fn pthread_rwlock_rdlock
-function first appeared in
-.Fx 3.0 .
diff --git a/share/man/man3/pthread_rwlock_unlock.3 b/share/man/man3/pthread_rwlock_unlock.3
deleted file mode 100644
index 7ad52b257120..000000000000
--- a/share/man/man3/pthread_rwlock_unlock.3
+++ /dev/null
@@ -1,79 +0,0 @@
-.\" Copyright (c) 1998 Alex Nash
-.\" 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 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd August 4, 1998
-.Dt PTHREAD_RWLOCK_UNLOCK 3
-.Os
-.Sh NAME
-.Nm pthread_rwlock_unlock
-.Nd release a read/write lock
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_rwlock_unlock "pthread_rwlock_t *lock"
-.Sh DESCRIPTION
-The
-.Fn pthread_rwlock_unlock
-function is used to release the read/write lock previously obtained by
-.Fn pthread_rwlock_rdlock ,
-.Fn pthread_rwlock_wrlock ,
-.Fn pthread_rwlock_tryrdlock ,
-or
-.Fn pthread_rwlock_trywrlock .
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_rwlock_unlock
-function will return zero. Otherwise an error number will be returned
-to indicate the error.
-.Pp
-The results are undefined if
-.Fa lock
-is not held by the calling thread.
-.Sh SEE ALSO
-.Xr pthread_rwlock_rdlock 3 ,
-.Xr pthread_rwlock_wrlock 3
-.Sh STANDARDS
-The
-.Fn pthread_rwlock_unlock
-function is expected to conform to
-.St -susv2 .
-.Sh ERRORS
-The
-.Fn pthread_rwlock_unlock
-function may fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The value specified by
-.Fa lock
-is invalid.
-.It Bq Er EPERM
-The current thread does not own the read/write lock.
-.El
-.Sh HISTORY
-The
-.Fn pthread_rwlock_unlock
-function first appeared in
-.Fx 3.0 .
diff --git a/share/man/man3/pthread_rwlock_wrlock.3 b/share/man/man3/pthread_rwlock_wrlock.3
deleted file mode 100644
index b6a2312a79d6..000000000000
--- a/share/man/man3/pthread_rwlock_wrlock.3
+++ /dev/null
@@ -1,102 +0,0 @@
-.\" Copyright (c) 1998 Alex Nash
-.\" 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 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd August 4, 1998
-.Dt PTHREAD_RWLOCK_WRLOCK 3
-.Os
-.Sh NAME
-.Nm pthread_rwlock_wrlock ,
-.Nm pthread_rwlock_trywrlock
-.Nd acquire a read/write lock for writing
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_rwlock_wrlock "pthread_rwlock_t *lock"
-.Ft int
-.Fn pthread_rwlock_trywrlock "pthread_rwlock_t *lock"
-.Sh DESCRIPTION
-The
-.Fn pthread_rwlock_wrlock
-function blocks until a write lock can be acquired against
-.Fa lock .
-The
-.Fn pthread_rwlock_trywrlock
-function performs the same action, but does not block if the lock
-cannot be immediately obtained.
-.Pp
-The results are undefined if the calling thread already holds the
-lock at the time the call is made.
-.Sh IMPLEMENTATION NOTES
-To prevent writer starvation, writers are favored over readers.
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_rwlock_wrlock
-and
-.Fn pthread_rwlock_trywrlock
-functions will return zero. Otherwise an error number will be returned
-to indicate the error.
-.Sh SEE ALSO
-.Xr pthread_rwlock_trywrlock 3 ,
-.Xr pthread_rwlock_unlock 3 ,
-.Xr pthread_rwlock_wrlock 3
-.Sh STANDARDS
-The
-.Fn pthread_rwlock_wrlock
-and
-.Fn pthread_rwlock_trywrlock
-functions are expected to conform to
-.St -susv2 .
-.Sh ERRORS
-The
-.Fn pthread_rwlock_trywrlock
-function will fail if:
-.Bl -tag -width Er
-.It Bq Er EBUSY
-The calling thread is not able to acquire the lock without blocking.
-.El
-.Pp
-The
-.Fn pthread_rwlock_wrlock
-and
-.Fn pthread_rwlock_trywrlock
-functions may fail if:
-.Bl -tag -width Er
-.It Bq Er EDEADLK
-The calling thread already owns the read/write lock (for reading
-or writing).
-.It Bq Er EINVAL
-The value specified by
-.Fa lock
-is invalid.
-.It Bq Er ENOMEM
-Insufficient memory exists to initialize the lock (applies to
-statically initialized locks only).
-.El
-.Sh HISTORY
-The
-.Fn pthread_rwlock_wrlock
-function first appeared in
-.Fx 3.0 .
diff --git a/share/man/man3/pthread_rwlockattr_destroy.3 b/share/man/man3/pthread_rwlockattr_destroy.3
deleted file mode 100644
index 2d67041ba161..000000000000
--- a/share/man/man3/pthread_rwlockattr_destroy.3
+++ /dev/null
@@ -1,68 +0,0 @@
-.\" Copyright (c) 1998 Alex Nash
-.\" 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 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd August 4, 1998
-.Dt PTHREAD_RWLOCKATTR_DESTROY 3
-.Os
-.Sh NAME
-.Nm pthread_rwlockattr_destroy
-.Nd destroy a read/write lock
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_rwlockattr_destroy "pthread_rwlockattr_t *attr"
-.Sh DESCRIPTION
-The
-.Fn pthread_rwlockattr_destroy
-function is used to destroy a read/write lock attribute object
-previously created with
-.Fn pthread_rwlockattr_init .
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_rwlockattr_destroy
-function will return zero. Otherwise an error number will be returned
-to indicate the error.
-.Sh SEE ALSO
-.Xr pthread_rwlockattr_init 3
-.Sh STANDARDS
-The
-.Fn pthread_rwlockattr_destroy
-function is expected to conform to
-.St -susv2 .
-.Sh ERRORS
-.Fn pthread_rwlockattr_destroy
-may fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The value specified by
-.Fa attr
-is invalid.
-.El
-.Sh HISTORY
-The
-.Fn pthread_rwlockattr_destroy
-function first appeared in
-.Fx 3.0 .
diff --git a/share/man/man3/pthread_rwlockattr_getpshared.3 b/share/man/man3/pthread_rwlockattr_getpshared.3
deleted file mode 100644
index d2028dc58c6d..000000000000
--- a/share/man/man3/pthread_rwlockattr_getpshared.3
+++ /dev/null
@@ -1,80 +0,0 @@
-.\" Copyright (c) 1998 Alex Nash
-.\" 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 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd March 22, 1999
-.Dt PTHREAD_RWLOCKATTR_GETPSHARED 3
-.Os
-.Sh NAME
-.Nm pthread_rwlockattr_getpshared
-.Nd get the process shared attribute
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_rwlockattr_getpshared "const pthread_rwlockattr_t *attr" "int *pshared"
-.Sh DESCRIPTION
-The
-.Fn pthread_rwlockattr_getpshared
-function is used to get the process shared setting of a read/write
-lock attribute object. The setting is returned via
-.Fa pshared ,
-and may be one of two values:
-.Bl -hang -offset flag -width 123456789012345678901234
-.It Ar PTHREAD_PROCESS_SHARED
-Any thread of any process that has access to the memory where the
-read/write lock resides can manipulate the lock.
-.It Ar PTHREAD_PROCESS_PRIVATE
-Only threads created within the same process as the thread that
-initialized the read/write lock can manipulate the lock. This is
-the default value.
-.El
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_rwlockattr_getpshared
-function will return zero. Otherwise an error number will be returned
-to indicate the error.
-.Sh SEE ALSO
-.Xr pthread_rwlock_init 3 ,
-.Xr pthread_rwlockattr_init 3 ,
-.Xr pthread_rwlockattr_setpshared 3
-.Sh STANDARDS
-The
-.Fn pthread_rwlockattr_getpshared
-function is expected to conform to
-.St -susv2 .
-.Sh ERRORS
-.Fn pthread_rwlockattr_getpshared
-may fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The value specified by
-.Fa attr
-is invalid.
-.El
-.Sh HISTORY
-The
-.Fn pthread_rwlockattr_getpshared
-function first appeared in
-.Fx 3.0 .
diff --git a/share/man/man3/pthread_rwlockattr_init.3 b/share/man/man3/pthread_rwlockattr_init.3
deleted file mode 100644
index ac191260c66d..000000000000
--- a/share/man/man3/pthread_rwlockattr_init.3
+++ /dev/null
@@ -1,67 +0,0 @@
-.\" Copyright (c) 1998 Alex Nash
-.\" 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 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd August 4, 1998
-.Dt PTHREAD_RWLOCKATTR_INIT 3
-.Os
-.Sh NAME
-.Nm pthread_rwlockattr_init
-.Nd initialize a read/write lock
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_rwlockattr_init "pthread_rwlockattr_t *attr"
-.Sh DESCRIPTION
-The
-.Fn pthread_rwlockattr_init
-function is used to initialize a read/write lock attributes object.
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_rwlockattr_init
-function will return zero. Otherwise an error number will be returned
-to indicate the error.
-.Sh SEE ALSO
-.Xr pthread_rwlock_init 3 ,
-.Xr pthread_rwlockattr_destroy 3 ,
-.Xr pthread_rwlockattr_getpshared 3 ,
-.Xr pthread_rwlockattr_setpshared 3
-.Sh STANDARDS
-The
-.Fn pthread_rwlockattr_init
-function is expected to conform to
-.St -susv2 .
-.Sh ERRORS
-.Fn pthread_rwlockattr_init
-will fail if:
-.Bl -tag -width Er
-.It Bq Er ENOMEM
-Insufficient memory exists to initialize the attribute object.
-.El
-.Sh HISTORY
-The
-.Fn pthread_rwlockattr_init
-function first appeared in
-.Fx 3.0 .
diff --git a/share/man/man3/pthread_rwlockattr_setpshared.3 b/share/man/man3/pthread_rwlockattr_setpshared.3
deleted file mode 100644
index 4e4b15812c26..000000000000
--- a/share/man/man3/pthread_rwlockattr_setpshared.3
+++ /dev/null
@@ -1,86 +0,0 @@
-.\" Copyright (c) 1998 Alex Nash
-.\" 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 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd August 4, 1998
-.Dt PTHREAD_RWLOCKATTR_SETPSHARED 3
-.Os
-.Sh NAME
-.Nm pthread_rwlockattr_setpshared
-.Nd set the process shared attribute
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_rwlockattr_setpshared "pthread_rwlockattr_t *attr" "int pshared"
-.Sh DESCRIPTION
-The
-.Fn pthread_rwlockattr_setpshared
-function sets the process shared attribute of
-.Fa attr
-to the value referenced by
-.Fa pshared .
-.Fa pshared
-may be one of two values:
-.Bl -hang -offset flag -width 123456789012345678901234
-.It Ar PTHREAD_PROCESS_SHARED
-Any thread of any process that has access to the memory where the
-read/write lock resides can manipulate the lock.
-.It Ar PTHREAD_PROCESS_PRIVATE
-Only threads created within the same process as the thread that
-initialized the read/write lock can manipulate the lock. This is
-the default value.
-.El
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_rwlockattr_setpshared
-function will return zero. Otherwise an error number will be returned
-to indicate the error.
-.Sh SEE ALSO
-.Xr pthread_rwlock_init 3 ,
-.Xr pthread_rwlockattr_init 3 ,
-.Xr pthread_rwlockattr_setpshared 3
-.Sh STANDARDS
-The
-.Fn pthread_rwlockattr_setpshared
-function is expected to conform to
-.St -susv2 .
-.Sh ERRORS
-.Fn pthread_rwlockattr_setpshared
-will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The value specified by
-.Fa attr
-or
-.Fa pshared
-is invalid.
-.El
-.Sh HISTORY
-The
-.Fn pthread_rwlockattr_setpshared
-function first appeared in
-.Fx 3.0 .
-.Sh BUGS
-The PTHREAD_PROCESS_SHARED attribute is not supported.
diff --git a/share/man/man3/pthread_self.3 b/share/man/man3/pthread_self.3
deleted file mode 100644
index be524b9345b9..000000000000
--- a/share/man/man3/pthread_self.3
+++ /dev/null
@@ -1,61 +0,0 @@
-.\" Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>.
-.\" 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 John Birrell.
-.\" 4. Neither the name of the author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd April 4, 1996
-.Dt PTHREAD_SELF 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_self
-.Nd get the calling thread's ID
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft pthread_t
-.Fn pthread_self "void"
-.Sh DESCRIPTION
-The
-.Fn pthread_self
-function returns the thread ID of the calling thread.
-.Sh RETURN VALUES
-The
-.Fn pthread_self
-function returns the thread ID of the calling thread.
-.Sh ERRORS
-None.
-.Pp
-.Sh SEE ALSO
-.Xr pthread_create 3 ,
-.Xr pthread_equal 3
-.Sh STANDARDS
-.Fn pthread_self
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/share/man/man3/pthread_setspecific.3 b/share/man/man3/pthread_setspecific.3
deleted file mode 100644
index ca141deb3c81..000000000000
--- a/share/man/man3/pthread_setspecific.3
+++ /dev/null
@@ -1,95 +0,0 @@
-.\" Copyright (c) 1996 John Birrell <jb@cimlogic.com.au>.
-.\" 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 John Birrell.
-.\" 4. Neither the name of the author nor the names of any co-contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd April 4, 1996
-.Dt PTHREAD_SETSPECIFIC 3
-.Os BSD 4
-.Sh NAME
-.Nm pthread_setspecific
-.Nd set a thread-specific data value
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_setspecific "pthread_key_t key" "const void *value"
-.Sh DESCRIPTION
-The
-.Fn pthread_setspecific
-function associates a thread-specific value with a
-.Fa key
-obtained via a previous call to
-.Fn pthread_key_create .
-Different threads man bind different values to the same key.
-These values are
-typically pointers to blocks of dynamically allocated memory that have been
-reserved for use by the calling thread.
-.Pp
-The effect of calling
-.Fn pthread_setspecific
-with a key value not obtained from
-.Fn pthread_key_create
-or after
-.Fa key
-has been deleted with
-.Fn pthread_key_delete
-is undefined.
-.Pp
-.Fn pthread_setspecific
-may be called from a thread-specific data destructor function, however this
-may result in lost storage or infinite loops.
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_setspecific
-function will return zero.
-Otherwise an error number will be returned to
-indicate the error.
-.Sh ERRORS
-.Fn pthread_setspecific
-will fail if:
-.Bl -tag -width Er
-.It Bq Er ENOMEM
-Insufficient memory exists to associate the value with the
-.Fa key .
-.It Bq Er EINVAL
-The
-.Fa key
-value is invalid.
-.El
-.Pp
-.Sh SEE ALSO
-.Xr pthread_getspecific 3 ,
-.Xr pthread_key_create 3 ,
-.Xr pthread_key_delete 3
-.Sh STANDARDS
-.Fn pthread_setspecific
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
diff --git a/share/man/man3/pthread_testcancel.3 b/share/man/man3/pthread_testcancel.3
deleted file mode 100644
index d911d2c647f3..000000000000
--- a/share/man/man3/pthread_testcancel.3
+++ /dev/null
@@ -1,197 +0,0 @@
-.\" $FreeBSD$
-.Dd January 17, 1999
-.Dt PTHREAD_TESTCANCEL 3
-.Os
-.Sh NAME
-.Nm pthread_setcancelstate ,
-.Nm pthread_setcanceltype ,
-.Nm pthread_testcancel
-.Nd set cancelability state
-.Sh SYNOPSIS
-.Fd #include <pthread.h>
-.Ft int
-.Fn pthread_setcancelstate "int state" "int *oldstate"
-.Ft int
-.Fn pthread_setcanceltype "int type" "int *oldtype"
-.Ft void
-.Fn pthread_testcancel "void"
-.Sh DESCRIPTION
-The
-.Fn pthread_setcancelstate
-function atomically both sets the calling thread's cancelability state
-to the indicated
-.Fa state
-and returns the previous cancelability state at the location referenced by
-.Fa oldstate .
-Legal values for
-.Fa state
-are
-.Dv PTHREAD_CANCEL_ENABLE
-and
-.Dv PTHREAD_CANCEL_DISABLE .
-.Pp
-The
-.Fn pthread_setcanceltype
-function atomically both sets the calling thread's cancelability type
-to the indicated
-.Fa type
-and returns the previous cancelability type at the location referenced by
-.Fa oldtype .
-Legal values for
-.Fa type
-are
-.Dv PTHREAD_CANCEL_DEFERRED
-and
-.Dv PTHREAD_CANCEL_ASYNCHRONOUS .
-.Pp
-The cancelability state and type of any newly created threads, including the
-thread in which
-.Fn main
-was first invoked, are
-.Dv PTHREAD_CANCEL_ENABLE
-and
-.Dv PTHREAD_CANCEL_DEFERRED
-respectively.
-.Pp
-The
-.Fn pthread_testcancel
-function creates a cancellation point in the calling thread.
-The
-.Fn pthread_testcancel
-function has no effect if cancelability is disabled.
-.Pp
-.Ss Cancelability States
-The cancelability state of a thread determines the action taken upon
-receipt of a cancellation request.
-The thread may control cancellation in
-a number of ways.
-.Pp
-Each thread maintains its own
-.Dq cancelability state
-which may be encoded in two bits:
-.Bl -hang
-.It Em Cancelability Enable
-When cancelability is
-.Dv PTHREAD_CANCEL_DISABLE ,
-cancellation requests against the target thread are held pending.
-.It Em Cancelability Type
-When cancelability is enabled and the cancelability type is
-.Dv PTHREAD_CANCEL_ASYNCHRONOUS ,
-new or pending cancellation requests may be acted upon at any time.
-When cancelability is enabled and the cancelability type is
-.Dv PTHREAD_CANCEL_DEFERRED ,
-cancellation requests are held pending until a cancellation point (see
-below) is reached.
-If cancelability is disabled, the setting of the
-cancelability type has no immediate effect as all cancellation requests
-are held pending; however, once cancelability is enabled again the new
-type will be in effect.
-.El
-.Ss Cancellation Points
-Cancellation points will occur when a thread is executing the following
-functions:
-.Fn close ,
-.Fn creat ,
-.Fn fcntl ,
-.Fn fsync ,
-.Fn msync ,
-.Fn nanosleep ,
-.Fn open ,
-.Fn pause ,
-.Fn pthread_cond_timedwait ,
-.Fn pthread_cond_wait ,
-.Fn pthread_join ,
-.Fn pthread_testcancel ,
-.Fn read ,
-.Fn sigwaitinfo ,
-.Fn sigsuspend ,
-.Fn sigwait ,
-.Fn sleep ,
-.Fn system ,
-.Fn tcdrain ,
-.Fn wait ,
-.Fn waitpid ,
-.Fn write .
-.Sh RETURN VALUES
-If successful, the
-.Fn pthread_setcancelstate
-and
-.Fn pthread_setcanceltype
-functions will return zero.
-Otherwise, an error number shall be returned to
-indicate the error.
-.Pp
-The
-.Fn pthread_setcancelstate
-and
-.Fn pthread_setcanceltype
-functions are used to control the points at which a thread may be
-asynchronously canceled.
-For cancellation control to be usable in modular
-fashion, some rules must be followed.
-.Pp
-For purposes of this discussion, consider an object to be a generalization
-of a procedure.
-It is a set of procedures and global variables written as
-a unit and called by clients not known by the object.
-Objects may depend
-on other objects.
-.Pp
-First, cancelability should only be disabled on entry to an object, never
-explicitly enabled.
-On exit from an object, the cancelability state should
-always be restored to its value on entry to the object.
-.Pp
-This follows from a modularity argument: if the client of an object (or the
-client of an object that uses that object) has disabled cancelability, it is
-because the client doesn't want to have to worry about how to clean up if the
-thread is canceled while executing some sequence of actions.
-If an object
-is called in such a state and it enables cancelability and a cancellation
-request is pending for that thread, then the thread will be canceled,
-contrary to the wish of the client that disabled.
-.Pp
-Second, the cancelability type may be explicitly set to either
-.Em deferred
-or
-.Em asynchronous
-upon entry to an object.
-But as with the cancelability state, on exit from
-an object that cancelability type should always be restored to its value on
-entry to the object.
-.Pp
-Finally, only functions that are cancel-safe may be called from a thread that
-is asynchronously cancelable.
-.Sh ERRORS
-The function
-.Fn pthread_setcancelstate
-may fail with:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The specified state is not
-.Dv PTHREAD_CANCEL_ENABLE
-or
-.Dv PTHREAD_CANCEL_DISABLE .
-.El
-.Pp
-The function
-.Fn pthread_setcanceltype
-may fail with:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The specified state is not
-.Dv PTHREAD_CANCEL_DEFERRED
-or
-.Dv PTHREAD_CANCEL_ASYNCHRONOUS .
-.El
-.Sh SEE ALSO
-.Xr pthread_cancel 3
-.Sh STANDARDS
-.Fn pthread_testcancel
-conforms to ISO/IEC 9945-1 ANSI/IEEE
-.Pq Dq Tn POSIX
-Std 1003.1 Second Edition 1996-07-12.
-.Sh AUTHORS
-This man page was written by
-.An David Leonard <d@openbsd.org>
-for the OpenBSD implementation of pthread_cancel.
diff --git a/share/man/man4/bktr.4 b/share/man/man4/bktr.4
deleted file mode 100644
index 01e857d60615..000000000000
--- a/share/man/man4/bktr.4
+++ /dev/null
@@ -1,194 +0,0 @@
-.\"
-.\" $FreeBSD$
-.\"
-.Dd January 28, 1998
-.Dt BKTR 4 i386
-.Os FreeBSD 2.2
-.Sh NAME
-.Nm brooktree
-.Nd video capture driver
-.Sh SYNOPSIS
-.Nm device bktr
-.Pp
-.Nm device iicbus
-.Nm device iicbb
-.Nm device smbus
-.Sh DESCRIPTION
-The
-.Nm bktr
-driver provides support for PCI
-.Em video
-capture and
-.Em VBI
-capture on low cost, high performance boards. The driver based on
-the Matrox Meteor driver and uses the same API. The bktr driver should support most video cards
-based on the
-.Em Brooktree Bt848/849/878/879 Video Capture Chip.
-The driver also supports
-.Em FM Radio
-if the Tuner supports it.
-.Pp
-Specifically, the following cards are known to work:
-.br
-.Em Hauppage Wincast TV and WinTV/PCI
-.br
-.Em STB TV PCI Television Tuner
-.br
-.Em Miro PC TV
-.br
-.Em Intel Smart Video Recorder III
-.br
-.Em AverMedia cards
-.br
-.Em Video Highway XTreme
-.br
-.Em VideoLogic Captivator PCI
-.Pp
-The driver currently supports the following features:
-.br
-.in +0.5i
-PCI to PCI dma transfer
-.br
-clipping
-.br
-yuv
-.br
-rgb16
-.br
-rgb24
-.br
-rgb32
-.in -0.5i
-.Pp
-On these cards, tuners and other components are interconnected with an I2C bus.
-The Brooktree848 chips act as a master device on the bus to control them.
-Therefore,
-.Xr iicbus 4 ,
-.Xr iicbb 4
-and
-.Xr smbus 4
-controller declarations are mandatory to activate bktr support.
-.Pp
-The following kernel parameters may be used to further configure the driver:
-.Pp
-.Em options "BROOKTREE_ALLOC_PAGES=xxx"
-specifies the number of contiguous pages to allocate when successfully
-probed. The default number of pages allocated by the kernel is 216.
-This means that there are (216*4096) bytes available for use.
-.Pp
-.Em options BROOKTREE_SYSTEM_DEFAULT=BROOKTREE_PAL
-.br
-.Em options BROOKTREE_SYSTEM_DEFAULT=BROOKTREE_NTSC
-.br
-One of these options can be used to set the default video format for the driver.
-This fixed random hangs and lockups with the VideoLogic Captivator PCI card.
-.br
-.Pp
-The following sysctls may be used to further configure the driver:
-.Pp
-.Em sysctl hw.bt848.card=nnnn
-This can be used to override the card make which was detected at boot time.
-'nnnn' is set to an integer from 1 to 13 taken from the following table:
-.br
-MIRO 1
-.br
-HAUPPAUGE 2
-.br
-STB 3
-.br
-INTEL 4
-.br
-IMS_TURBO 5
-.br
-AVER_MEDIA 6
-.br
-OSPREY 7
-.br
-NEC_PK 8
-.br
-IO_GV 9
-.br
-FLYVIDEO 10
-.br
-ZOLTRIX 11
-.br
-KISS 12
-.br
-VIDEO_HIGHWAY_XTREME 13
-.br
-.Pp
-.Em sysctl hw.bt848.tuner=nnnn
-This can be used to override the tuner make which was detected at boot time.
-'nnnn' is set to an integer from 1 to 13 taken from the following table:
-.br
-NO_TUNER 0
-.br
-TEMIC_NTSC 1
-.br
-TEMIC_PAL 2
-.br
-TEMIC_SECAM 3
-.br
-PHILIPS_NTSC 4
-.br
-PHILIPS_PAL 5
-.br
-PHILIPS_SECAM 6
-.br
-TEMIC_PALI 7
-.br
-PHILIPS_PALI 8
-.br
-PHILIPS_FR1236_NTSC 9 /* These have FM Radio support */
-.br
-PHILIPS_FR1216_PAL 10 /* These have FM Radio support */
-.br
-PHILIPS_FR1236_SECAM 11 /* These have FM Radio support */
-.br
-ALPS_TSCH5 12
-.br
-ALPS_TSBH1 13
-.br
-.Pp
-.Sh AUTHORS
-This driver is based on the work of
-.An Jim Lowe Aq james@miller.cs.uwm.edu ,
-.An Mark Tinguely Aq tinguely@plains.nodak.edu ,
-.An Amancio Hasty Aq hasty@star-gate.com ,
-.An Roger Hardiman Aq roger@freebsd.org
-and a bunch of other people.
-.Sh FILES
-.Bl -tag -width /usr/share/examples/meteor -compact
-.It Pa /usr/share/examples/meteor
-Examples of what you can do with the (similarly designed) Meteor driver.
-.It Pa /usr/ports/graphics/fxtv
-A TV and Camera display program utilizing the bktr driver - requires that
-.Em The X Window System
-and
-.Em The Ports Collection
-also be installed.
-.It Pa /usr/ports/misc/alevt
-A program to capture and display Teletext (VideoText) pages - requires that
-.Em The X Window System
-and
-.Em The Ports Collection
-also be installed.
-.It Pa /usr/ports/audio/xmradio
-An FM Radio Tuner for cards which have an FM Radio tuner fitted. - requires that
-.Em The X Window System
-and
-.Em The Ports Collection
-also be installed.
-It also requires
-.Em Motif
-or the
-.Em lesstif
-port.
-.El
-.Sh SEE ALSO
-.Xr meteor 4
-.Sh HISTORY
-The
-.Nm
-driver first appeared in
-.Fx 2.2 .
diff --git a/share/man/man4/cy.4 b/share/man/man4/cy.4
deleted file mode 100644
index ac072b47493f..000000000000
--- a/share/man/man4/cy.4
+++ /dev/null
@@ -1,221 +0,0 @@
-.\" Copyright (c) 1990, 1991 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. 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, Berkeley and its contributors.
-.\" 4. 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: @(#)dca.4 5.2 (Berkeley) 3/27/91
-.\" from: com.4,v 1.1 1993/08/06 11:19:07 cgd Exp
-.\" from: sio.4,v 1.16 1995/06/26 06:05:30 bde Exp $
-.\" $FreeBSD$
-.\"
-.Dd June 14, 1999
-.Dt CY 4 i386
-.Os FreeBSD
-.Sh NAME
-.Nm cy
-.Nd Cyclades Cyclom-Y serial driver
-.Sh SYNOPSIS
-.Cd "options CY_PCI_FASTINTR"
-.Cd "device cy0 at isa? irq 10 iomem 0xd4000 iosiz 0x2000"
-.Cd "device cy1 at isa? irq 11 iomem 0xd6000 iosiz 0x2000"
-.Pp
-Minor numbering:
-.Pp
-.Bd -literal
-0b\fIMMMMMMMMMMMMMMMMxxxxxxxxOLIMMMMM\fR
- call\fBO\fRut
- \fBL\fRock
- \fBI\fRnitial
- \fBMMMMMMMMMMMMMMMM MMMMMM\fRinor
-.Ed
-.Sh DESCRIPTION
-The
-.Nm cy
-driver provides support for Cirrus Logic CD1400-based
-.Tn EIA
-.Tn RS-232C
-.Pf ( Tn CCITT
-.Tn V.24 )
-communications interfaces (ports) on Cyclades Cyclom-Y boards.
-Each CD1400 provides 4 ports.
-Cyclom-Y boards with various numbers of CD1400's are available.
-This driver supports up to 8 CD1400's (32 ports) per board.
-.Pp
-Input and output for each line may set independently
-to the following speeds:
-50, 75, 110, 134.5, 150, 300, 600, 1200, 1800, 2400, 4800, 9600,
-19200, 38400, 57600, or 115200 bps.
-Other speeds of up to 150000 are supported by the termios interface
-but not by the sgttyb compatibility interface.
-The CD1400 is not fast enough to handle speeds above 115200 bps
-effectively.
-It can transmit on a single line at slightly more than 115200 bps,
-but when 4 lines are active in both directions its limit is about
-90000 bps on each line.
-.\" XXX the following should be true for all serial drivers and
-.\" should not be repeated in the man pages for all serial drivers.
-.\" It was copied from sio.4. The only change was s/sio/cy/g.
-.Pp
-Serial ports controlled by the
-.Nm cy
-driver can be used for both `callin' and `callout'.
-For each port there is a callin device and a callout device.
-The minor number of the callout device is 128 higher
-than that of the corresponding callin port.
-The callin device is general purpose.
-Processes opening it normally wait for carrier
-and for the callout device to become inactive.
-The callout device is used to steal the port from
-processes waiting for carrier on the callin device.
-Processes opening it do not wait for carrier
-and put any processes waiting for carrier on the callin device into
-a deeper sleep so that they do not conflict with the callout session.
-The callout device is abused for handling programs that are supposed
-to work on general ports and need to open the port without waiting
-but are too stupid to do so.
-.Pp
-The
-.Nm cy
-driver also supports an initial-state and a lock-state control
-device for each of the callin and the callout "data" devices.
-The minor number of the initial-state device is 32 higher
-than that of the corresponding data device.
-The minor number of the lock-state device is 64 higher
-than that of the corresponding data device.
-The termios settings of a data device are copied
-from those of the corresponding initial-state device
-on first opens and are not inherited from previous opens.
-Use
-.Xr stty 1
-in the normal way on the initial-state devices to program
-initial termios states suitable for your setup.
-.Pp
-The lock termios state acts as flags to disable changing
-the termios state. E.g., to lock a flag variable such as
-CRTSCTS, use
-.Em "stty crtscts"
-on the lock-state device. Speeds and special characters
-may be locked by setting the corresponding value in the lock-state
-device to any nonzero value.
-.Pp
-Correct programs talking to correctly wired external devices
-work with almost arbitrary initial states and almost no locking,
-but other setups may benefit from changing some of the default
-initial state and locking the state.
-In particular, the initial states for non (POSIX) standard flags
-should be set to suit the devices attached and may need to be
-locked to prevent buggy programs from changing them.
-E.g., CRTSCTS should be locked on for devices that support
-RTS/CTS handshaking at all times and off for devices that don't
-support it at all. CLOCAL should be locked on for devices
-that don't support carrier. HUPCL may be locked off if you don't
-want to hang up for some reason. In general, very bad things happen
-if something is locked to the wrong state, and things should not
-be locked for devices that support more than one setting. The
-CLOCAL flag on callin ports should be locked off for logins
-to avoid certain security holes, but this needs to be done by
-getty if the callin port is used for anything else.
-.Ss Kernel Configuration Options
-The
-.Em CY_PCI_FASTINTR
-option should be used to avoid suboptimal interrupt handling for
-PCI Cyclades boards.
-The PCI BIOS must be configured with the
-.Nm
-interrupt not shared with any other active device
-for this option to work.
-This option is not the default because it is currently harmful in
-certain cases where it does not work.
-.Sh FILES
-.\" XXX more cloning: s/d/c/g and add a ? for the card number.
-.Bl -tag -width /dev/ttyic?? -compact
-.It Pa /dev/ttyc??
-for callin ports
-.It Pa /dev/ttyic??
-.It Pa /dev/ttylc??
-corresponding callin initial-state and lock-state devices
-.Pp
-.\" XXX more cloning: s/a/c/g. No consistency :-(.
-.It Pa /dev/cuac??
-for callout ports
-.It Pa /dev/cuaic??
-.It Pa /dev/cualc??
-corresponding callout initial-state and lock-state devices
-.El
-.Pp
-.Bl -tag -width /etc/rc.serial -compact
-.It Pa /etc/rc.serial
-examples of setting the initial-state and lock-state devices
-.El
-.Pp
-The first question mark in these device names is short for the
-card number
-(a decimal number between 0 and 65535 inclusive).
-The second question mark is short for the port number
-(a letter in the range [0-9a-v]).
-.Sh DIAGNOSTICS
-.Bl -diag
-.\" XXX back to s/sio/cy/g.
-.It cy%d: silo overflow.
-Problem in the interrupt handler.
-.El
-.Bl -diag
-.It cy%d: interrupt-level buffer overflow.
-Problem in the bottom half of the driver.
-.El
-.Bl -diag
-.It cy%d: tty-level buffer overflow.
-Problem in the application.
-Input has arrived faster than the given module could process it
-and some has been lost.
-.El
-.\" .Bl -diag
-.\" .It sio%d: reduced fifo trigger level to %d.
-.\" Attempting to avoid further silo overflows.
-.\" .El
-.Sh SEE ALSO
-.Xr stty 1 ,
-.Xr termios 4 ,
-.Xr tty 4 ,
-.Xr comcontrol 8 ,
-.Xr pstat 8
-.Sh HISTORY
-The
-.Nm
-driver is derived from the
-.Nm sio
-driver and the NetBSD
-.Nm
-driver and is
-.Ud
-.Sh BUGS
-Serial consoles are not implemented.
diff --git a/share/man/man4/ed.4 b/share/man/man4/ed.4
deleted file mode 100644
index 1138ccd022a3..000000000000
--- a/share/man/man4/ed.4
+++ /dev/null
@@ -1,196 +0,0 @@
-.\"
-.\" Copyright (c) 1994, David Greenman
-.\" 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 David Greenman.
-.\" 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 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd October 28, 1995
-.Dt ED 4 i386
-.Os FreeBSD
-.Sh NAME
-.Nm ed
-.Nd high performance ethernet device driver
-.Sh SYNOPSIS
-.Cd "device ed0 at isa? port 0x280 irq 10 iomem 0xd8000"
-.Cd "device ed1 at isa? port 0x300 irq 5 flags 0x4 iosiz 16384 iomem 0xd8000"
-.Sh DESCRIPTION
-The
-.Nm ed
-driver provides support for 8 and 16bit ISA ethernet cards that are based on
-the National Semiconductor DS8390 and similar NICs manufactured by other companies.
-.Pp
-It supports all 80x3 series ISA ethernet cards manufactured by Western Digital and SMC,
-the SMC Ultra, the 3Com 3c503, the Novell NE1000/NE2000, and HP PC Lan+.
-.Pp
-The
-.Nm
-driver uses a unique multi-buffering mechanism to achieve high transmit performance.
-When using 16bit ISA cards, as high as 97% of the theoretical maximum performance of
-the IEEE 802.3 CSMA ethernet is possible.
-.Pp
-In addition to the standard port and irq specifications, the
-.Nm
-driver also supports a number of
-.Em flags
-which can force 8/16bit mode, enable/disable multi-buffering, and select the default
-interface type (AUI/BNC, and for cards with twisted pair, AUI/10BaseT).
-.Pp
-The
-.Em flags
-are a bit field, and are summarized as follows:
-.Pp
-.Bl -hang -offset indent
-.It Em 0x01
-Disable tranceiver.
-On those cards which support it, this flag causes the tranceiver to
-be disabled and the AUI connection to be used by default.
-.It Em 0x02
-Force 8bit mode.
-This flag forces the card to 8bit mode regardless of how the
-card identifies itself.
-This may be needed for some clones which incorrectly
-identify themselves as 16bit, even though they only have an 8bit interface.
-.It Em 0x04
-Force 16bit mode.
-This flag forces the card to 16bit mode regardless of how the
-card identifies itself.
-This may be needed for some clones which incorrectly
-identify themselves as 8bit, even though they have a 16bit ISA interface.
-.It Em 0x08
-Disable transmitter multi-buffering.
-This flag disables the use of multiple
-transmit buffers and may be necessary in rare cases where packets are sent out
-faster than a machine on the other end can handle (as evidenced by severe packet
-lossage). Some
-.Pf ( No non- Ns Tn FreeBSD
-:-)) machines have terrible ethernet performance
-and simply can't cope with 1100K+ data rates.
-Use of this flag also provides
-one more packet worth of receiver buffering, and on 8bit cards, this may help
-reduce receiver lossage.
-.El
-.Pp
-When using a 3c503 card, the AUI connection may be selected by specifying the
-.Em link2
-option to
-.Xr ifconfig 8
-(BNC is the default).
-.Sh DIAGNOSTICS
-.Bl -diag
-.It "ed%d: kernel configured irq %d doesn't match board configured irq %d."
-The irq number that was specified in the kernel config file (and then compiled
-into the kernel) differs from the irq that has been set on the interface card.
-.It "ed%d: failed to clear shared memory at %x - check configuration."
-When the card was probed at system boot time, the
-.Nm ed
-driver found that it could not clear the card's shared memory.
-This is most commonly
-caused by a BIOS extension ROM being configured in the same address space as the
-ethernet card's shared memory.
-Either find the offending card and change its BIOS
-ROM to be at an address that doesn't conflict, or change the
-.Em iomem
-option in the kernel config file so that the card's shared memory is mapped at a
-non-conflicting address.
-.It "ed%d: Invalid irq configuration (%d) must be 2-5 for 3c503."
-The irq number that was specified in the kernel config file is not valid for
-the 3Com 3c503 card.
-The 3c503 can only be assigned to irqs 2 through 5.
-.It "ed%d: Cannot find start of RAM."
-.It "ed%d: Cannot find any RAM, start : %d, x = %d."
-The probe of a Gateway card was unsuccessful in configuring the card's packet memory.
-This likely indicates that the card was improperly recognized as a Gateway or that
-the card is defective.
-.It "ed: packets buffered, but transmitter idle."
-Indicates a logic problem in the driver.
-Should never happen.
-.It "ed%d: device timeout"
-Indicates that an expected transmitter interrupt didn't occur.
-Usually caused by an
-interrupt conflict with another card on the ISA bus.
-.It "ed%d: NIC memory corrupt - invalid packet length %d."
-Indicates that a packet was received with a packet length that was either larger than
-the maximum size or smaller than the minimum size allowed by the IEEE 802.3 standard.
-Usually
-caused by a conflict with another card on the ISA bus, but in some cases may also
-indicate faulty cabling.
-.It "ed%d: remote transmit DMA failed to complete."
-This indicates that a programmed I/O transfer to an NE1000 or NE2000 style card
-has failed to properly complete.
-Usually caused by the ISA bus speed being set
-too fast.
-.El
-.Sh CAVEATS
-Early revision DS8390 chips have problems.
-They lock up whenever the receive
-ring-buffer overflows.
-They occasionally switch the byte order
-of the length field in the packet ring header (several different causes
-of this related to an off-by-one byte alignment) - resulting in "NIC
-memory corrupt - invalid packet length" messages.
-The card is reset
-whenever these problems occur, but otherwise there is no problem with
-recovering from these conditions.
-.Pp
-The NIC memory access to 3Com and Novell cards is much slower than it is on
-WD/SMC cards; it's less than 1MB/second on 8bit boards and less than 2MB/second
-on the 16bit cards.
-This can lead to ring-buffer overruns resulting in
-dropped packets during heavy network traffic.
-.Pp
-16bit Compex cards identify themselves as being 8bit.
-While these cards will
-work in 8bit mode, much higher performance can be achieved by specifying
-.Em "flags 0x04"
-(force 16bit mode) in your kernel config file.
-In addition, you should also specify
-.Em "iosize 16384"
-to take advantage of the extra 8k of shared memory that 16bit mode provides.
-.Sh BUGS
-The
-.Nm ed
-driver is a bit too aggressive about resetting the card whenever any bad
-packets are received.
-As a result, it may throw out some good packets which
-have been received but not yet transfered from the card to main memory.
-.Sh SEE ALSO
-.Xr arp 4 ,
-.Xr netintro 4 ,
-.Xr ifconfig 8 ,
-.Xr ng_ether 8
-.Sh HISTORY
-The
-.Nm ed
-device driver first appeared in
-.Fx 1.0 .
-.Sh AUTHORS
-The
-.Nm
-device driver and this manual page were written by
-.An David Greenman .
diff --git a/share/man/man4/ef.4 b/share/man/man4/ef.4
deleted file mode 100644
index 6165e063ab62..000000000000
--- a/share/man/man4/ef.4
+++ /dev/null
@@ -1,103 +0,0 @@
-.\"
-.\" Copyright (c) 1999, Boris Popov
-.\" 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 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd June 20, 1999
-.Dt EF 4
-.Os BSD
-.Sh NAME
-.Nm ef
-.Nd
-pseudo-device driver provides support for multiple ethernet frame types.
-.Sh SYNOPSIS
-.Cd "kldload if_ef.ko"
-.Sh DESCRIPTION
-The
-.Nm
-pseudo-device driver clones each ethernet type device with four
-additional interfaces. Each of them capable to send or receive only
-one predefined frame type.
-.Pp
-Names for the new interfaces created by adding
-.Ar fN
-suffix to an existing device name. Where
-.Ar N
-is a device unit which can have one of the following values:
-.Bd -literal -offset indent
-0 interface with an Ethernet_II frame
-1 interface with a Novell Ethernet_802.3 frame
-2 interface with an Ethernet_802.2 frame
-3 interface with an Ethernet_802.2/SNAP frame support.
-.Ed
-.Pp
-For example, device
-.Ar ed0
-will be populated with four devices:
-.Ar ed0f0 ,
-.Ar ed0f1 ,
-.Ar ed0f2
-and
-.Ar ed0f3 .
-.Pp
-After that, each device can be configured as usually:
-.Dl # ifconfig ed0f1 ipx 0x105
-This will configure IPX protocol with network number
-.Ar 0x105
-and
-.Ar Ethernet_802.3
-frame type.
-.Pp
-Please note that it is impossible to configure IPX protocol on the 'raw'
-.Ar ed0
-device after
-.Ar if_ef.ko
-driver loaded.
-.Sh EXAMPLES
-The
-.Nm
-driver can be loaded via
-.Xr loader.conf 5
-file:
-.Dl if_ef_load="YES"
-.Pp
-In this case an ordinary interface configuration commands can be used
-in
-.Xr rc.conf 5
-file:
-.Dl network_interfaces="ed2 lo0 tun0 ed2f0 ed2f1"
-.Dl ifconfig_ed2f0_ipx="ipx 0x101"
-.Dl ifconfig_ed2f1_ipx="ipx 0x102"
-.Sh DIAGNOSTICS
-None.
-.Sh CAVEATS
-Avoid to configuring 'raw' ethernet device for IPX protocol after
-.Nm
-driver is loaded.
-.Sh SEE ALSO
-.Xr ipx 3 ,
-.Xr ifconfig 8
-.Sh AUTHOR
-Boris Popov.
diff --git a/share/man/man4/en.4 b/share/man/man4/en.4
deleted file mode 100644
index 1fef5526cbd9..000000000000
--- a/share/man/man4/en.4
+++ /dev/null
@@ -1,63 +0,0 @@
-.\" $FreeBSD$
-.\"
-.Dd December 29, 1997
-.Dt EN 4 i386
-.Os BSD
-.Sh NAME
-.Nm en
-.Nd
-device driver for Midway-based ATM interfaces
-.Sh SYNOPSIS
-.Cd "device en"
-.Cd "pseudo-device atm"
-.Sh DESCRIPTION
-The
-.Nm
-device driver supports Midway-based ATM interfaces including the
-Efficient Networks, Inc. ENI-155 and Adaptec ANA-59x0.
-Midway is an ALL5 SAR (Segmentation and Reassenbly) chip.
-.Pp
-The driver only supports ATM PVCs. SVC or ATM-ARP is not supported.
-.Pp
-To configure the card for IP, use something like:
-.Dl # ifconfig en0 128.252.200.1 netmask 0xffffff00 up
-To add a PVC to a host you must use the ``route'' command:
-.Dl # route add -iface <remote IP address> -link en0:z.0.x.y
-where x and y are the byte encoding of the VCI to use, and z is the
-byte encoding of the following flags.
-.Dl 0x01 (use AAL5),
-.Dl 0x02 (if using AAL5, use a LLCSNAP header)
-Thus, parameter 3 means AAL5 and LLC/SNAP encapsulation.
-Note that BPF works only with LLC/SNAP encapsulation.
-.Sh EXAMPLES
-Suppose you have 2 hosts 128.252.200.1 and 128.252.200.2 connected
-by ATM through PVC # 201 (0xc9).
-To enable the link use the following commands:
-.Dl on host 128.252.200.1:
-.Dl # ifconfig en0 128.252.200.1 netmask 0xffffff00 up
-.Dl # route add -iface 128.252.200.2 -link en0:3.0.0.c9
-.Pp
-.Dl on host 128.252.200.2:
-.Dl # ifconfig en0 128.252.200.2 netmask 0xffffff00 up
-.Dl # route add -iface 128.252.200.1 -link en0:3.0.0.c9
-.Sh DIAGNOSTICS
-.Bl -diag
-.It "en0 <Efficient Networks ENI-155p> rev 0 int a irq 5 on pci0:16"
-.It "en0: ATM midway v0, board IDs 6.0, Utopia (pipelined), 512KB on-board RAM"
-.It "en0: maximum DMA burst length = 64 bytes"
-.It "en0: 7 32KB receive buffers, 8 32KB transmit buffers allocated"
-.El
-.Sh CAVEATS
-The driver extensively uses DMA on PCI.
-The first
-generation PCI chipsets do not work or exhibit poor performance.
-.Sh SEE ALSO
-.Xr ifconfig 8 ,
-.Xr pvcsif 8 ,
-.Xr pvctxctl 8 ,
-.Xr route 8
-.Sh AUTHORS
-.An Chuck Cranor
-of Washington University implemented EN driver
-in 1996 for
-.Nx .
diff --git a/share/man/man4/netgraph.4 b/share/man/man4/netgraph.4
deleted file mode 100644
index b4c0addcd9b3..000000000000
--- a/share/man/man4/netgraph.4
+++ /dev/null
@@ -1,1056 +0,0 @@
-.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
-.\" All rights reserved.
-.\"
-.\" Subject to the following obligations and disclaimer of warranty, use and
-.\" redistribution of this software, in source or object code forms, with or
-.\" without modifications are expressly permitted by Whistle Communications;
-.\" provided, however, that:
-.\" 1. Any and all reproductions of the source or object code must include the
-.\" copyright notice above and the following disclaimer of warranties; and
-.\" 2. No rights are granted, in any manner or form, to use Whistle
-.\" Communications, Inc. trademarks, including the mark "WHISTLE
-.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
-.\" such appears in the above copyright notice or in the software.
-.\"
-.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
-.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
-.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
-.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
-.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
-.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
-.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
-.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
-.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
-.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
-.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
-.\" OF SUCH DAMAGE.
-.\"
-.\" Authors: Julian Elischer <julian@whistle.com>
-.\" Archie Cobbs <archie@whistle.com>
-.\"
-.\" $FreeBSD$
-.\" $Whistle: netgraph.4,v 1.7 1999/01/28 23:54:52 julian Exp $
-.\"
-.Dd January 19, 1999
-.Dt NETGRAPH 4
-.Os FreeBSD
-.Sh NAME
-.Nm netgraph
-.Nd graph based kernel networking subsystem
-.Sh DESCRIPTION
-The
-.Nm
-system provides a uniform and modular system for the implementation
-of kernel objects which perform various networking functions. The objects,
-known as
-.Em nodes ,
-can be arranged into arbitrarily complicated graphs. Nodes have
-.Em hooks
-which are used to connect two nodes together, forming the edges in the graph.
-Nodes communicate along the edges to process data, implement protocols, etc.
-.Pp
-The aim of
-.Nm
-is to supplement rather than replace the existing kernel networking
-infrastructure. It provides:
-.Pp
-.Bl -bullet -compact -offset 2n
-.It
-A flexible way of combining protocol and link level drivers
-.It
-A modular way to implement new protocols
-.It
-A common framework for kernel entities to inter-communicate
-.It
-A reasonably fast, kernel-based implementation
-.El
-.Sh Nodes and Types
-The most fundamental concept in
-.Nm
-is that of a
-.Em node .
-All nodes implement a number of predefined methods which allow them
-to interact with other nodes in a well defined manner.
-.Pp
-Each node has a
-.Em type ,
-which is a static property of the node determined at node creation time.
-A node's type is described by a unique
-.Tn ASCII
-type name.
-The type implies what the node does and how it may be connected
-to other nodes.
-.Pp
-In object-oriented language, types are classes and nodes are instances
-of their respective class. All node types are subclasses of the generic node
-type, and hence inherit certain common functionality and capabilities
-(e.g., the ability to have an
-.Tn ASCII
-name).
-.Pp
-Nodes may be assigned a globally unique
-.Tn ASCII
-name which can be
-used to refer to the node.
-The name must not contain the characters
-.Dq \&.
-or
-.Dq \&:
-and is limited to
-.Dv "NG_NODELEN + 1"
-characters (including NUL byte).
-.Pp
-Each node instance has a unique
-.Em ID number
-which is expressed as a 32-bit hex value. This value may be used to
-refer to a node when there is no
-.Tn ASCII
-name assigned to it.
-.Sh Hooks
-Nodes are connected to other nodes by connecting a pair of
-.Em hooks ,
-one from each node. Data flows bidirectionally between nodes along
-connected pairs of hooks. A node may have as many hooks as it
-needs, and may assign whatever meaning it wants to a hook.
-.Pp
-Hooks have these properties:
-.Pp
-.Bl -bullet -compact -offset 2n
-.It
-A hook has an
-.Tn ASCII
-name which is unique among all hooks
-on that node (other hooks on other nodes may have the same name).
-The name must not contain a
-.Dq \&.
-or a
-.Dq \&:
-and is
-limited to
-.Dv "NG_HOOKLEN + 1"
-characters (including NUL byte).
-.It
-A hook is always connected to another hook. That is, hooks are
-created at the time they are connected, and breaking an edge by
-removing either hook destroys both hooks.
-.El
-.Pp
-A node may decide to assign special meaning to some hooks.
-For example, connecting to the hook named
-.Dq debug
-might trigger
-the node to start sending debugging information to that hook.
-.Sh Data Flow
-Two types of information flow between nodes: data messages and
-control messages. Data messages are passed in mbuf chains along the edges
-in the graph, one edge at a time. The first mbuf in a chain must have the
-.Dv M_PKTHDR
-flag set. Each node decides how to handle data coming in on its hooks.
-.Pp
-Control messages are type-specific C structures sent from one node
-directly to some arbitrary other node. Control messages have a common
-header format, followed by type-specific data, and are binary structures
-for efficiency. However, node types also may support conversion of the
-type specific data between binary and
-.Tn ASCII
-for debugging and human interface purposes (see the
-.Dv NGM_ASCII2BINARY
-and
-.Dv NGM_BINARY2ASCII
-generic control messages below). Nodes are not required to support
-these conversions.
-.Pp
-There are two ways to address a control message. If
-there is a sequence of edges connecting the two nodes, the message
-may be
-.Dq source routed
-by specifying the corresponding sequence
-of hooks as the destination address for the message (relative
-addressing). Otherwise, the recipient node global
-.Tn ASCII
-name
-(or equivalent ID based name) is used as the destination address
-for the message (absolute addressing). The two types of addressing
-may be combined, by specifying an absolute start node and a sequence
-of hooks.
-.Pp
-Messages often represent commands that are followed by a reply message
-in the reverse direction. To facilitate this, the recipient of a
-control message is supplied with a
-.Dq return address
-that is suitable
-for addressing a reply.
-.Pp
-Each control message contains a 32 bit value called a
-.Em typecookie
-indicating the type of the message, i.e., how to interpret it.
-Typically each type defines a unique typecookie for the messages
-that it understands. However, a node may choose to recognize and
-implement more than one type of message.
-.Sh Netgraph is Functional
-In order to minimize latency, most
-.Nm
-operations are functional.
-That is, data and control messages are delivered by making function
-calls rather than by using queues and mailboxes. For example, if node
-A wishes to send a data mbuf to neighboring node B, it calls the
-generic
-.Nm
-data delivery function. This function in turn locates
-node B and calls B's
-.Dq receive data
-method. While this mode of operation
-results in good performance, it has a few implications for node
-developers:
-.Pp
-.Bl -bullet -compact -offset 2n
-.It
-Whenever a node delivers a data or control message, the node
-may need to allow for the possibility of receiving a returning message
-before the original delivery function call returns.
-.It
-Netgraph nodes and support routines generally run at
-.Fn splnet .
-However, some nodes may want to send data and control messages
-from a different priority level. Netgraph supplies queueing routines which
-utilize the NETISR system to move message delivery to
-.Fn splnet .
-Note that messages are always received at
-.Fn splnet .
-.It
-It's possible for an infinite loop to occur if the graph contains cycles.
-.El
-.Pp
-So far, these issues have not proven problematical in practice.
-.Sh Interaction With Other Parts of the Kernel
-A node may have a hidden interaction with other components of the
-kernel outside of the
-.Nm
-subsystem, such as device hardware,
-kernel protocol stacks, etc. In fact, one of the benefits of
-.Nm
-is the ability to join disparate kernel networking entities together in a
-consistent communication framework.
-.Pp
-An example is the node type
-.Em socket
-which is both a netgraph node and a
-.Xr socket 2
-BSD socket in the protocol family
-.Dv PF_NETGRAPH .
-Socket nodes allow user processes to participate in
-.Nm Ns .
-Other nodes communicate with socket nodes using the usual methods, and the
-node hides the fact that it is also passing information to and from a
-cooperating user process.
-.Pp
-Another example is a device driver that presents
-a node interface to the hardware.
-.Sh Node Methods
-Nodes are notified of the following actions via function calls
-to the following node methods (all at
-.Fn splnet )
-and may accept or reject that action (by returning the appropriate
-error code):
-.Bl -tag -width xxx
-.It Creation of a new node
-The constructor for the type is called. If creation of a new node is
-allowed, the constructor must call the generic node creation
-function (in object-oriented terms, the superclass constructor)
-and then allocate any special resources it needs. For nodes that
-correspond to hardware, this is typically done during the device
-attach routine. Often a global
-.Tn ASCII
-name corresponding to the
-device name is assigned here as well.
-.It Creation of a new hook
-The hook is created and tentatively
-linked to the node, and the node is told about the name that will be
-used to describe this hook. The node sets up any special data structures
-it needs, or may reject the connection, based on the name of the hook.
-.It Successful connection of two hooks
-After both ends have accepted their
-hooks, and the links have been made, the nodes get a chance to
-find out who their peer is across the link and can then decide to reject
-the connection. Tear-down is automatic.
-.It Destruction of a hook
-The node is notified of a broken connection. The node may consider some hooks
-to be critical to operation and others to be expendable: the disconnection
-of one hook may be an acceptable event while for another it
-may effect a total shutdown for the node.
-.It Shutdown of a node
-This method allows a node to clean up
-and to ensure that any actions that need to be performed
-at this time are taken. The method must call the generic (i.e., superclass)
-node destructor to get rid of the generic components of the node.
-Some nodes (usually associated with a piece of hardware) may be
-.Em persistent
-in that a shutdown breaks all edges and resets the node,
-but doesn't remove it, in which case the generic destructor is not called.
-.El
-.Sh Sending and Receiving Data
-Three other methods are also supported by all nodes:
-.Bl -tag -width xxx
-.It Receive data message
-An mbuf chain is passed to the node.
-The node is notified on which hook the data arrived,
-and can use this information in its processing decision.
-The node must must always
-.Fn m_freem
-the mbuf chain on completion or error, or pass it on to another node
-(or kernel module) which will then be responsible for freeing it.
-.Pp
-In addition to the mbuf chain itself there is also a pointer to a
-structure describing meta-data about the message
-(e.g. priority information). This pointer may be
-.Dv NULL
-if there is no additional information. The format for this information is
-described in
-.Pa netgraph.h .
-The memory for meta-data must allocated via
-.Fn malloc
-with type
-.Dv M_NETGRAPH .
-As with the data itself, it is the receiver's responsibility to
-.Fn free
-the meta-data. If the mbuf chain is freed the meta-data must
-be freed at the same time. If the meta-data is freed but the
-real data on is passed on, then a
-.Dv NULL
-pointer must be substituted.
-.Pp
-The receiving node may decide to defer the data by queueing it in the
-.Nm
-NETISR system (see below).
-.Pp
-The structure and use of meta-data is still experimental, but is presently used in
-frame-relay to indicate that management packets should be queued for transmission
-at a higher priority than data packets. This is required for
-conformance with Frame Relay standards.
-.Pp
-.It Receive queued data message
-Usually this will be the same function as
-.Em Receive data message.
-This is the entry point called when a data message is being handed to
-the node after having been queued in the NETISR system.
-This allows a node to decide in the
-.Em Receive data message
-method that a message should be deferred and queued,
-and be sure that when it is processed from the queue,
-it will not be queued again.
-.It Receive control message
-This method is called when a control message is addressed to the node.
-A return address is always supplied, giving the address of the node
-that originated the message so a reply message can be sent anytime later.
-.Pp
-It is possible for a synchronous reply to be made, and in fact this
-is more common in practice.
-This is done by setting a pointer (supplied as an extra function parameter)
-to point to the reply.
-Then when the control message delivery function returns,
-the caller can check if this pointer has been made non-NULL,
-and if so then it points to the reply message allocated via
-.Fn malloc
-and containing the synchronous response. In both directions,
-(request and response) it is up to the
-receiver of that message to
-.Fn free
-the control message buffer. All control messages and replies are
-allocated with
-.Fn malloc
-type
-.Dv M_NETGRAPH .
-.El
-.Pp
-Much use has been made of reference counts, so that nodes being
-free'd of all references are automatically freed, and this behaviour
-has been tested and debugged to present a consistent and trustworthy
-framework for the
-.Dq type module
-writer to use.
-.Sh Addressing
-The
-.Nm
-framework provides an unambiguous and simple to use method of specifically
-addressing any single node in the graph. The naming of a node is
-independent of its type, in that another node, or external component
-need not know anything about the node's type in order to address it so as
-to send it a generic message type. Node and hook names should be
-chosen so as to make addresses meaningful.
-.Pp
-Addresses are either absolute or relative. An absolute address begins
-with a node name, (or ID), followed by a colon, followed by a sequence of hook
-names separated by periods. This addresses the node reached by starting
-at the named node and following the specified sequence of hooks.
-A relative address includes only the sequence of hook names, implicitly
-starting hook traversal at the local node.
-.Pp
-There are a couple of special possibilities for the node name.
-The name
-.Dq \&.
-(referred to as
-.Dq \&.: )
-always refers to the local node.
-Also, nodes that have no global name may be addressed by their ID numbers,
-by enclosing the hex representation of the ID number within square brackets.
-Here are some examples of valid netgraph addresses:
-.Bd -literal -offset 4n -compact
-
- .:
- foo:
- .:hook1
- foo:hook1.hook2
- [f057cd80]:hook1
-.Ed
-.Pp
-Consider the following set of nodes might be created for a site with
-a single physical frame relay line having two active logical DLCI channels,
-with RFC-1490 frames on DLCI 16 and PPP frames over DLCI 20:
-.Pp
-.Bd -literal
-[type SYNC ] [type FRAME] [type RFC1490]
-[ "Frame1" ](uplink)<-->(data)[<un-named>](dlci16)<-->(mux)[<un-named> ]
-[ A ] [ B ](dlci20)<---+ [ C ]
- |
- | [ type PPP ]
- +>(mux)[<un-named>]
- [ D ]
-.Ed
-.Pp
-One could always send a control message to node C from anywhere
-by using the name
-.Em "Frame1:uplink.dlci16" .
-Similarly,
-.Em "Frame1:uplink.dlci20"
-could reliably be used to reach node D, and node A could refer
-to node B as
-.Em ".:uplink" ,
-or simply
-.Em "uplink" .
-Conversely, B can refer to A as
-.Em "data" .
-The address
-.Em "mux.data"
-could be used by both nodes C and D to address a message to node A.
-.Pp
-Note that this is only for
-.Em control messages .
-Data messages are routed one hop at a time, by specifying the departing
-hook, with each node making the next routing decision. So when B
-receives a frame on hook
-.Em data
-it decodes the frame relay header to determine the DLCI,
-and then forwards the unwrapped frame to either C or D.
-.Pp
-A similar graph might be used to represent multi-link PPP running
-over an ISDN line:
-.Pp
-.Bd -literal
-[ type BRI ](B1)<--->(link1)[ type MPP ]
-[ "ISDN1" ](B2)<--->(link2)[ (no name) ]
-[ ](D) <-+
- |
- +----------------+
- |
- +->(switch)[ type Q.921 ](term1)<---->(datalink)[ type Q.931 ]
- [ (no name) ] [ (no name) ]
-.Ed
-.Sh Netgraph Structures
-Interesting members of the node and hook structures are shown below:
-.Bd -literal
-struct ng_node {
- char *name; /* Optional globally unique name */
- void *private; /* Node implementation private info */
- struct ng_type *type; /* The type of this node */
- int refs; /* Number of references to this struct */
- int numhooks; /* Number of connected hooks */
- hook_p hooks; /* Linked list of (connected) hooks */
-};
-typedef struct ng_node *node_p;
-
-struct ng_hook {
- char *name; /* This node's name for this hook */
- void *private; /* Node implementation private info */
- int refs; /* Number of references to this struct */
- struct ng_node *node; /* The node this hook is attached to */
- struct ng_hook *peer; /* The other hook in this connected pair */
- struct ng_hook *next; /* Next in list of hooks for this node */
-};
-typedef struct ng_hook *hook_p;
-.Ed
-.Pp
-The maintenance of the name pointers, reference counts, and linked list
-of hooks for each node is handled automatically by the
-.Nm
-subsystem.
-Typically a node's private info contains a back-pointer to the node or hook
-structure, which counts as a new reference that must be registered by
-incrementing
-.Dv "node->refs" .
-.Pp
-From a hook you can obtain the corresponding node, and from
-a node the list of all active hooks.
-.Pp
-Node types are described by these structures:
-.Bd -literal
-/** How to convert a control message from binary <-> ASCII */
-struct ng_cmdlist {
- u_int32_t cookie; /* typecookie */
- int cmd; /* command number */
- const char *name; /* command name */
- const struct ng_parse_type *mesgType; /* args if !NGF_RESP */
- const struct ng_parse_type *respType; /* args if NGF_RESP */
-};
-
-struct ng_type {
- u_int32_t version; /* Must equal NG_VERSION */
- const char *name; /* Unique type name */
-
- /* Module event handler */
- modeventhand_t mod_event; /* Handle load/unload (optional) */
-
- /* Constructor */
- int (*constructor)(node_p *node); /* Create a new node */
-
- /** Methods using the node **/
- int (*rcvmsg)(node_p node, /* Receive control message */
- struct ng_mesg *msg, /* The message */
- const char *retaddr, /* Return address */
- struct ng_mesg **resp); /* Synchronous response */
- int (*shutdown)(node_p node); /* Shutdown this node */
- int (*newhook)(node_p node, /* create a new hook */
- hook_p hook, /* Pre-allocated struct */
- const char *name); /* Name for new hook */
-
- /** Methods using the hook **/
- int (*connect)(hook_p hook); /* Confirm new hook attachment */
- int (*rcvdata)(hook_p hook, /* Receive data on a hook */
- struct mbuf *m, /* The data in an mbuf */
- meta_p meta); /* Meta-data, if any */
- int (*disconnect)(hook_p hook); /* Notify disconnection of hook */
-
- /** How to convert control messages binary <-> ASCII */
- const struct ng_cmdlist *cmdlist; /* Optional; may be NULL */
-};
-.Ed
-.Pp
-Control messages have the following structure:
-.Bd -literal
-#define NG_CMDSTRLEN 15 /* Max command string (16 with null) */
-
-struct ng_mesg {
- struct ng_msghdr {
- u_char version; /* Must equal NG_VERSION */
- u_char spare; /* Pad to 2 bytes */
- u_short arglen; /* Length of cmd/resp data */
- u_long flags; /* Message status flags */
- u_long token; /* Reply should have the same token */
- u_long typecookie; /* Node type understanding this message */
- u_long cmd; /* Command identifier */
- u_char cmdstr[NG_CMDSTRLEN+1]; /* Cmd string (for debug) */
- } header;
- char data[0]; /* Start of cmd/resp data */
-};
-
-#define NG_VERSION 1 /* Netgraph version */
-#define NGF_ORIG 0x0000 /* Command */
-#define NGF_RESP 0x0001 /* Response */
-.Ed
-.Pp
-Control messages have the fixed header shown above, followed by a
-variable length data section which depends on the type cookie
-and the command. Each field is explained below:
-.Bl -tag -width xxx
-.It Dv version
-Indicates the version of netgraph itself. The current version is
-.Dv NG_VERSION .
-.It Dv arglen
-This is the length of any extra arguments, which begin at
-.Dv data .
-.It Dv flags
-Indicates whether this is a command or a response control message.
-.It Dv token
-The
-.Dv token
-is a means by which a sender can match a reply message to the
-corresponding command message; the reply always has the same token.
-.Pp
-.It Dv typecookie
-The corresponding node type's unique 32-bit value.
-If a node doesn't recognize the type cookie it must reject the message
-by returning
-.Er EINVAL .
-.Pp
-Each type should have an include file that defines the commands,
-argument format, and cookie for its own messages.
-The typecookie
-insures that the same header file was included by both sender and
-receiver; when an incompatible change in the header file is made,
-the typecookie
-.Em must
-be changed.
-The de facto method for generating unique type cookies is to take the
-seconds from the epoch at the time the header file is written
-(i.e., the output of
-.Dv "date -u +'%s'" ) .
-.Pp
-There is a predefined typecookie
-.Dv NGM_GENERIC_COOKIE
-for the
-.Dq generic
-node type, and
-a corresponding set of generic messages which all nodes understand.
-The handling of these messages is automatic.
-.It Dv command
-The identifier for the message command. This is type specific,
-and is defined in the same header file as the typecookie.
-.It Dv cmdstr
-Room for a short human readable version of
-.Dq command
-(for debugging purposes only).
-.El
-.Pp
-Some modules may choose to implement messages from more than one
-of the header files and thus recognize more than one type cookie.
-.Sh Control Message ASCII Form
-Control messages are in binary format for efficiency. However, for
-debugging and human interface purposes, and if the node type supports
-it, control messages may be converted to and from an equivalent
-.Tn ASCII
-form. The
-.Tn ASCII
-form is similar to the binary form, with two exceptions:
-.Pp
-.Bl -tag -compact -width xxx
-.It o
-The
-.Dv cmdstr
-header field must contain the
-.Tn ASCII
-name of the command, corresponding to the
-.Dv cmd
-header field.
-.It o
-The
-.Dv args
-field contains a NUL-terminated
-.Tn ASCII
-string version of the message arguments.
-.El
-.Pp
-In general, the arguments field of a control messgage can be any
-arbitrary C data type. Netgraph includes parsing routines to support
-some pre-defined datatypes in
-.Tn ASCII
-with this simple syntax:
-.Pp
-.Bl -tag -compact -width xxx
-.It o
-Integer types are represented by base 8, 10, or 16 numbers.
-.It o
-Strings are enclosed in double quotes and respect the normal
-C language backslash escapes.
-.It o
-IP addresses have the obvious form.
-.It o
-Arrays are enclosed in square brackets, with the elements listed
-consecutively starting at index zero. An element may have an optional
-index and equals sign preceeding it. Whenever an element
-does not have an explicit index, the index is implicitly the previous
-element's index plus one.
-.It o
-Structures are enclosed in curly braces, and each field is specified
-in the form
-.Dq fieldname=value .
-.It o
-Any array element or structure field whose value is equal to its
-.Dq default value
-may be omitted. For integer types, the default value
-is usually zero; for string types, the empty string.
-.It o
-Array elements and structure fields may be specified in any order.
-.El
-.Pp
-Each node type may define its own arbitrary types by providing
-the necessary routines to parse and unparse.
-.Tn ASCII
-forms defined
-for a specific node type are documented in the documentation for
-that node type.
-.Sh Generic Control Messages
-There are a number of standard predefined messages that will work
-for any node, as they are supported directly by the framework itself.
-These are defined in
-.Pa ng_message.h
-along with the basic layout of messages and other similar information.
-.Bl -tag -width xxx
-.It Dv NGM_CONNECT
-Connect to another node, using the supplied hook names on either end.
-.It Dv NGM_MKPEER
-Construct a node of the given type and then connect to it using the
-supplied hook names.
-.It Dv NGM_SHUTDOWN
-The target node should disconnect from all its neighbours and shut down.
-Persistent nodes such as those representing physical hardware
-might not disappear from the node namespace, but only reset themselves.
-The node must disconnect all of its hooks.
-This may result in neighbors shutting themselves down, and possibly a
-cascading shutdown of the entire connected graph.
-.It Dv NGM_NAME
-Assign a name to a node. Nodes can exist without having a name, and this
-is the default for nodes created using the
-.Dv NGM_MKPEER
-method. Such nodes can only be addressed relatively or by their ID number.
-.It Dv NGM_RMHOOK
-Ask the node to break a hook connection to one of its neighbours.
-Both nodes will have their
-.Dq disconnect
-method invoked.
-Either node may elect to totally shut down as a result.
-.It Dv NGM_NODEINFO
-Asks the target node to describe itself. The four returned fields
-are the node name (if named), the node type, the node ID and the
-number of hooks attached. The ID is an internal number unique to that node.
-.It Dv NGM_LISTHOOKS
-This returns the information given by
-.Dv NGM_NODEINFO ,
-but in addition
-includes an array of fields describing each link, and the description for
-the node at the far end of that link.
-.It Dv NGM_LISTNAMES
-This returns an array of node descriptions (as for
-.Dv NGM_NODEINFO ")"
-where each entry of the array describes a named node.
-All named nodes will be described.
-.It Dv NGM_LISTNODES
-This is the same as
-.Dv NGM_LISTNAMES
-except that all nodes are listed regardless of whether they have a name or not.
-.It Dv NGM_LISTTYPES
-This returns a list of all currently installed netgraph types.
-.It Dv NGM_TEXT_STATUS
-The node may return a text formatted status message.
-The status information is determined entirely by the node type.
-It is the only "generic" message
-that requires any support within the node itself and as such the node may
-elect to not support this message. The text response must be less than
-.Dv NG_TEXTRESPONSE
-bytes in length (presently 1024). This can be used to return general
-status information in human readable form.
-.It Dv NGM_BINARY2ASCII
-This message converts a binary control message to its
-.Tn ASCII
-form.
-The entire control message to be converted is contained within the
-arguments field of the
-.Dv Dv NGM_BINARY2ASCII
-message itself. If successful, the reply will contain the same control
-message in
-.Tn ASCII
-form.
-A node will typically only know how to translate messages that it
-itself understands, so the target node of the
-.Dv NGM_BINARY2ASCII
-is often the same node that would actually receive that message.
-.It Dv NGM_ASCII2BINARY
-The opposite of
-.Dv NGM_BINARY2ASCII .
-The entire control message to be converted, in
-.Tn ASCII
-form, is contained
-in the arguments section of the
-.Dv NGM_ASCII2BINARY
-and need only have the
-.Dv flags ,
-.Dv cmdstr ,
-and
-.Dv arglen
-header fields filled in, plus the NUL-terminated string version of
-the arguments in the arguments field. If successful, the reply
-contains the binary version of the control message.
-.El
-.Sh Metadata
-Data moving through the
-.Nm
-system can be accompanied by meta-data that describes some
-aspect of that data. The form of the meta-data is a fixed header,
-which contains enough information for most uses, and can optionally
-be supplemented by trailing
-.Em option
-structures, which contain a
-.Em cookie
-(see the section on control messages), an identifier, a length and optional
-data. If a node does not recognize the cookie associated with an option,
-it should ignore that option.
-.Pp
-Meta data might include such things as priority, discard eligibility,
-or special processing requirements. It might also mark a packet for
-debug status, etc. The use of meta-data is still experimental.
-.Sh INITIALIZATION
-The base
-.Nm
-code may either be statically compiled
-into the kernel or else loaded dynamically as a KLD via
-.Xr kldload 8 .
-In the former case, include
-.Bd -literal -offset 4n -compact
-
- options NETGRAPH
-
-.Ed
-in your kernel configuration file. You may also include selected
-node types in the kernel compilation, for example:
-.Bd -literal -offset 4n -compact
-
- options NETGRAPH
- options NETGRAPH_SOCKET
- options NETGRAPH_ECHO
-
-.Ed
-.Pp
-Once the
-.Nm
-subsystem is loaded, individual node types may be loaded at any time
-as KLD modules via
-.Xr kldload 8 .
-Moreover,
-.Nm
-knows how to automatically do this; when a request to create a new
-node of unknown type
-.Em type
-is made,
-.Nm
-will attempt to load the KLD module
-.Pa ng_type.ko .
-.Pp
-Types can also be installed at boot time, as certain device drivers
-may want to export each instance of the device as a netgraph node.
-.Pp
-In general, new types can be installed at any time from within the
-kernel by calling
-.Fn ng_newtype ,
-supplying a pointer to the type's
-.Dv struct ng_type
-structure.
-.Pp
-The
-.Fn NETGRAPH_INIT
-macro automates this process by using a linker set.
-.Sh EXISTING NODE TYPES
-Several node types currently exist. Each is fully documented
-in its own man page:
-.Bl -tag -width xxx
-.It SOCKET
-The socket type implements two new sockets in the new protocol domain
-.Dv PF_NETGRAPH .
-The new sockets protocols are
-.Dv NG_DATA
-and
-.Dv NG_CONTROL ,
-both of type
-.Dv SOCK_DGRAM .
-Typically one of each is associated with a socket node.
-When both sockets have closed, the node will shut down. The
-.Dv NG_DATA
-socket is used for sending and receiving data, while the
-.Dv NG_CONTROL
-socket is used for sending and receiving control messages.
-Data and control messages are passed using the
-.Xr sendto 2
-and
-.Xr recvfrom 2
-calls, using a
-.Dv struct sockaddr_ng
-socket address.
-.Pp
-.It HOLE
-Responds only to generic messages and is a
-.Dq black hole
-for data, Useful for testing. Always accepts new hooks.
-.Pp
-.It ECHO
-Responds only to generic messages and always echoes data back through the
-hook from which it arrived. Returns any non generic messages as their
-own response. Useful for testing. Always accepts new hooks.
-.Pp
-.It TEE
-This node is useful for
-.Dq snooping .
-It has 4 hooks:
-.Dv left ,
-.Dv right ,
-.Dv left2right ,
-and
-.Dv right2left .
-Data entering from the right is passed to the left and duplicated on
-.Dv right2left,
-and data entering from the left is passed to the right and
-duplicated on
-.Dv left2right .
-Data entering from
-.Dv left2right
-is sent to the right and data from
-.Dv right2left
-to left.
-.Pp
-.It RFC1490 MUX
-Encapsulates/de-encapsulates frames encoded according to RFC 1490.
-Has a hook for the encapsulated packets
-.Pq Dq downstream
-and one hook
-for each protocol (i.e., IP, PPP, etc.).
-.Pp
-.It FRAME RELAY MUX
-Encapsulates/de-encapsulates Frame Relay frames.
-Has a hook for the encapsulated packets
-.Pq Dq downstream
-and one hook
-for each DLCI.
-.Pp
-.It FRAME RELAY LMI
-Automatically handles frame relay
-.Dq LMI
-(link management interface) operations and packets.
-Automatically probes and detects which of several LMI standards
-is in use at the exchange.
-.Pp
-.It TTY
-This node is also a line discipline. It simply converts between mbuf
-frames and sequential serial data, allowing a tty to appear as a netgraph
-node. It has a programmable
-.Dq hotkey
-character.
-.Pp
-.It ASYNC
-This node encapsulates and de-encapsulates asynchronous frames
-according to RFC 1662. This is used in conjunction with the TTY node
-type for supporting PPP links over asynchronous serial lines.
-.Pp
-.It INTERFACE
-This node is also a system networking interface. It has hooks representing
-each protocol family (IP, AppleTalk, IPX, etc.) and appears in the output of
-.Xr ifconfig 8 .
-The interfaces are named
-.Em ng0 ,
-.Em ng1 ,
-etc.
-.El
-.Sh NOTES
-Whether a named node exists can be checked by trying to send a control message
-to it (e.g.,
-.Dv NGM_NODEINFO
-).
-If it does not exist,
-.Er ENOENT
-will be returned.
-.Pp
-All data messages are mbuf chains with the M_PKTHDR flag set.
-.Pp
-Nodes are responsible for freeing what they allocate.
-There are three exceptions:
-.Bl -tag -width xxxx
-.It 1
-Mbufs sent across a data link are never to be freed by the sender.
-.It 2
-Any meta-data information traveling with the data has the same restriction.
-It might be freed by any node the data passes through, and a
-.Dv NULL
-passed onwards, but the caller will never free it.
-Two macros
-.Fn NG_FREE_META "meta"
-and
-.Fn NG_FREE_DATA "m" "meta"
-should be used if possible to free data and meta data (see
-.Pa netgraph.h ) .
-.It 3
-Messages sent using
-.Fn ng_send_message
-are freed by the callee. As in the case above, the addresses
-associated with the message are freed by whatever allocated them so the
-recipient should copy them if it wants to keep that information.
-.El
-.Sh FILES
-.Bl -tag -width xxxxx -compact
-.It Pa /sys/netgraph/netgraph.h
-Definitions for use solely within the kernel by
-.Nm
-nodes.
-.It Pa /sys/netgraph/ng_message.h
-Definitions needed by any file that needs to deal with
-.Nm
-messages.
-.It Pa /sys/netgraph/ng_socket.h
-Definitions needed to use
-.Nm
-socket type nodes.
-.It Pa /sys/netgraph/ng_{type}.h
-Definitions needed to use
-.Nm
-{type}
-nodes, including the type cookie definition.
-.It Pa /modules/netgraph.ko
-Netgraph subsystem loadable KLD module.
-.It Pa /modules/ng_{type}.ko
-Loadable KLD module for node type {type}.
-.El
-.Sh USER MODE SUPPORT
-There is a library for supporting user-mode programs that wish
-to interact with the netgraph system. See
-.Xr netgraph 3
-for details.
-.Pp
-Two user-mode support programs,
-.Xr ngctl 8
-and
-.Xr nghook 8 ,
-are available to assist manual configuration and debugging.
-.Pp
-There are a few useful techniques for debugging new node types.
-First, implementing new node types in user-mode first
-makes debugging easier.
-The
-.Em tee
-node type is also useful for debugging, especially in conjunction with
-.Xr ngctl 8
-and
-.Xr nghook 8 .
-.Sh SEE ALSO
-.Xr socket 2 ,
-.Xr netgraph 3 ,
-.Xr ngctl 8 ,
-.Xr nghook 8 ,
-.Xr ng_async 8 ,
-.Xr ng_cisco 8 ,
-.Xr ng_echo 8 ,
-.Xr ng_frame_relay 8 ,
-.Xr ng_hole 8 ,
-.Xr ng_iface 8 ,
-.Xr ng_ksocket 8 ,
-.Xr ng_lmi 8 ,
-.Xr ng_ppp 8 ,
-.Xr ng_pppoe 8 ,
-.Xr ng_rfc1490 8 ,
-.Xr ng_socket 8 ,
-.Xr ng_tee 8 ,
-.Xr ng_tty 8 ,
-.Xr ng_UI 8 ,
-.Xr ng_vjc 8 ,
-.Xr ng_{type} 8 .
-.Sh HISTORY
-The
-.Nm
-system was designed and first implemented at Whistle Communications, Inc.
-in a version of
-.Fx 2.2
-customized for the Whistle InterJet.
-It first made its debut in the main tree in
-.Fx 3.4 .
-.Sh AUTHORS
-.An Julian Elischer Aq julian@whistle.com ,
-with contributions by
-.An Archie Cobbs Aq archie@whistle.com .
diff --git a/share/man/man4/ng_UI.4 b/share/man/man4/ng_UI.4
deleted file mode 100644
index ab551bb28f69..000000000000
--- a/share/man/man4/ng_UI.4
+++ /dev/null
@@ -1,91 +0,0 @@
-.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
-.\" All rights reserved.
-.\"
-.\" Subject to the following obligations and disclaimer of warranty, use and
-.\" redistribution of this software, in source or object code forms, with or
-.\" without modifications are expressly permitted by Whistle Communications;
-.\" provided, however, that:
-.\" 1. Any and all reproductions of the source or object code must include the
-.\" copyright notice above and the following disclaimer of warranties; and
-.\" 2. No rights are granted, in any manner or form, to use Whistle
-.\" Communications, Inc. trademarks, including the mark "WHISTLE
-.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
-.\" such appears in the above copyright notice or in the software.
-.\"
-.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
-.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
-.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
-.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
-.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
-.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
-.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
-.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
-.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
-.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
-.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
-.\" OF SUCH DAMAGE.
-.\"
-.\" Author: Archie Cobbs <archie@whistle.com>
-.\"
-.\" $FreeBSD$
-.\" $Whistle: ng_UI.8,v 1.4 1999/01/25 02:37:56 archie Exp $
-.\"
-.Dd January 19, 1999
-.Dt NG_UI 8
-.Os FreeBSD
-.Sh NAME
-.Nm ng_UI
-.Nd UI netgraph node type
-.Sh SYNOPSIS
-.Fd #include <netgraph/ng_UI.h>
-.Sh DESCRIPTION
-The
-.Nm UI
-node type has two hooks,
-.Dv upstream
-and
-.Dv downstream .
-Packets received on
-.Dv downstream
-must have 0x03 (indicating unnumbered information) as their first byte;
-if not the packet is dropped. This byte is then stripped and the
-remainder of the packet sent out on
-.Dv upstream .
-.Pp
-Conversely, packets received on
-.Dv upstream
-will have a 0x03 byte prepended to them before being forwarded out on the
-.Dv downstream
-hook.
-.Sh HOOKS
-This node type supports the following hooks:
-.Pp
-.Bl -tag -width foobar
-.It Dv downstream
-Downstream connection. Packets on this side of the node have a 0x03 as
-their first byte.
-.It Dv upstream
-Upstream connection. Packets on this side of the node have the
-initial 0x03 byte stripped off.
-.El
-.Sh CONTROL MESSAGES
-This node type supports only the generic control messages.
-.Sh SHUTDOWN
-This node shuts down upon receipt of a
-.Dv NGM_SHUTDOWN
-control message, or when both hooks have been disconnected.
-.Sh SEE ALSO
-.Xr netgraph 4 ,
-.Xr ngctl 8 .
-.Sh HISTORY
-The
-.Nm
-node type was implemented in
-.Fx 4.0 .
-.Sh AUTHORS
-.An Julian Elischer Aq julian@whistle.com
diff --git a/share/man/man4/ng_async.4 b/share/man/man4/ng_async.4
deleted file mode 100644
index 6f9693e177a0..000000000000
--- a/share/man/man4/ng_async.4
+++ /dev/null
@@ -1,169 +0,0 @@
-.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
-.\" All rights reserved.
-.\"
-.\" Subject to the following obligations and disclaimer of warranty, use and
-.\" redistribution of this software, in source or object code forms, with or
-.\" without modifications are expressly permitted by Whistle Communications;
-.\" provided, however, that:
-.\" 1. Any and all reproductions of the source or object code must include the
-.\" copyright notice above and the following disclaimer of warranties; and
-.\" 2. No rights are granted, in any manner or form, to use Whistle
-.\" Communications, Inc. trademarks, including the mark "WHISTLE
-.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
-.\" such appears in the above copyright notice or in the software.
-.\"
-.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
-.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
-.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
-.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
-.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
-.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
-.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
-.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
-.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
-.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
-.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
-.\" OF SUCH DAMAGE.
-.\"
-.\" Author: Archie Cobbs <archie@whistle.com>
-.\"
-.\" $FreeBSD$
-.\" $Whistle: ng_async.8,v 1.6 1999/01/25 23:46:25 archie Exp $
-.\"
-.Dd January 19, 1999
-.Dt NG_ASYNC 8
-.Os FreeBSD
-.Sh NAME
-.Nm ng_async
-.Nd asynchronous framing netgraph node type
-.Sh SYNOPSIS
-.Fd #include <netgraph/ng_async.h>
-.Sh DESCRIPTION
-The
-.Nm async
-node type performs conversion between synchronous frames and
-asynchronous frames, as defined for the PPP protocol in RFC 1662.
-Asynchronous framing uses flag bytes and octet-stuffing
-to simulate a frame oriented connection over an octet-oriented
-asynchronous serial line.
-.Pp
-The node transmits and receives asynchronous data on the
-.Dv async
-hook. Mbuf boundaries of incoming data are ignored.
-Once a complete packet has been received, it is decoded and
-stripped of all framing bytes, and transmitted out the
-.Dv sync
-hook as a single frame.
-.Pp
-Synchronous frames are transmitted and received on the
-.Dv sync
-hook.
-Packets received on this hook are encoded as asynchronous frames
-and sent out on
-.Dv async .
-Received packets should start with the address and control fields,
-or the PPP protocol field if address and control field compression
-is employed, and contain no checksum field. If the first four bytes are
-.Dv "0xff 0x03 0xc0 0x21"
-(an LCP protocol frame) then complete control character escaping
-is enabled for that frame (in PPP, LCP packets are always sent with
-no address and control field compression and all control characters
-escaped).
-.Pp
-This node supports
-.Dq flag sharing
-for packets transmitted on
-.Dv async .
-This is an optimization where the trailing flag byte
-of one frame is shared with the opening flag byte of the next.
-Flag sharing between frames is disabled after one second of transmit
-idle time.
-.Sh HOOKS
-This node type supports the following hooks:
-.Pp
-.Bl -tag -width foobar
-.It Dv async
-Asynchronous connection.
-Typically this hook would be connected to a
-.Xr ng_tty 8
-node, which handles transmission of serial data over a tty device.
-.It Dv sync
-Synchronous connection. This hook sends and receives synchronous frames.
-For PPP, these frames should contain address, control, and protocol fields,
-but no checksum field.
-Typically this hook would be connected to an individual link hook of a
-.Xr ng_ppp 8
-type node.
-.El
-.Sh CONTROL MESSAGES
-This node type supports the generic control messages, plus the following:
-.Bl -tag -width foo
-.It Dv NGM_ASYNC_CMD_GET_STATS
-This command returns a
-.Dv "struct ng_async_stat"
-containing node statistics for packet, octet, and error counts.
-.It Dv NGM_ASYNC_CMD_CLR_STATS
-Clears the node statistics.
-.It Dv NGM_ASYNC_CMD_SET_CONFIG
-Sets the node configuration, which is described by a
-.Dv "struct ng_async_cfg" :
-.Bd -literal -offset 4n
-struct ng_async_cfg {
- u_char enabled; /* Turn encoding on/off */
- u_int16_t amru; /* Max receive async frame len */
- u_int16_t smru; /* Max receive sync frame len */
- u_int32_t accm; /* ACCM encoding */
-};
-.Ed
-.Pp
-The
-.Dv enabled
-field enables or disables all encoding/decoding functions (default disabled).
-When disabled, the node operates in simple
-.Dq pass through
-mode.
-The
-.Dv amru
-and
-.Dv smru
-fields are the asynchronous and synchronous MRU (maximum receive unit) values,
-respectively. These both default to 1600; note that the async MRU
-applies to the incoming frame length after asynchronous decoding.
-The
-.Dv accm
-field is the asynchronous character control map, which controls the escaping
-of characters 0x00 thorough 0x1f (default 0xffffffff).
-.It Dv NGM_ASYNC_CMD_GET_CONFIG
-This command returns the current configuration structure.
-.El
-.Sh SHUTDOWN
-This node shuts down upon receipt of a
-.Dv NGM_SHUTDOWN
-control message, or when all hooks have been disconnected.
-.Sh SEE ALSO
-.Xr netgraph 4 ,
-.Xr ng_ppp 8 ,
-.Xr ng_tty 8 ,
-.Xr ngctl 8 .
-.Rs
-.%A W. Simpson
-.%T "PPP in HDLC-link Framing"
-.%O RFC 1662
-.Re
-.Rs
-.%A W. Simpson
-.%T "The Point-to-Point Protocol (PPP)"
-.%O RFC 1661
-.Re
-.Sh HISTORY
-The
-.Nm
-node type was implemented in
-.Fx 4.0 .
-.Sh AUTHORS
-.An Archie Cobbs Aq archie@whistle.com
diff --git a/share/man/man4/ng_bpf.4 b/share/man/man4/ng_bpf.4
deleted file mode 100644
index ef33495f855b..000000000000
--- a/share/man/man4/ng_bpf.4
+++ /dev/null
@@ -1,154 +0,0 @@
-.\" Copyright (c) 1999 Whistle Communications, Inc.
-.\" All rights reserved.
-.\"
-.\" Subject to the following obligations and disclaimer of warranty, use and
-.\" redistribution of this software, in source or object code forms, with or
-.\" without modifications are expressly permitted by Whistle Communications;
-.\" provided, however, that:
-.\" 1. Any and all reproductions of the source or object code must include the
-.\" copyright notice above and the following disclaimer of warranties; and
-.\" 2. No rights are granted, in any manner or form, to use Whistle
-.\" Communications, Inc. trademarks, including the mark "WHISTLE
-.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
-.\" such appears in the above copyright notice or in the software.
-.\"
-.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
-.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
-.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
-.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
-.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
-.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
-.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
-.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
-.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
-.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
-.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
-.\" OF SUCH DAMAGE.
-.\"
-.\" Author: Archie Cobbs <archie@whistle.com>
-.\"
-.\" $FreeBSD$
-.\" $Whistle: ng_bpf.8,v 1.2 1999/12/03 01:57:12 archie Exp $
-.\"
-.Dd December 2, 1999
-.Dt NG_BPF 8
-.Os FreeBSD
-.Sh NAME
-.Nm ng_bpf
-.Nd Berkeley packet filter netgraph node type
-.Sh SYNOPSIS
-.Fd #include <net/bpf.h>
-.Fd #include <netgraph/ng_bpf.h>
-.Sh DESCRIPTION
-The
-.Nm bpf
-node type allows Berkeley Packet Filter (see
-.Xr bpf 4 )
-filters to be applied to data travelling through a Netgraph network.
-Each node allows an arbitrary number of connections to arbitrarily
-named hooks. With each hook is associated a
-.Xf bpf 4
-filter program which is applied to incoming data only, a destination hook
-for matching packets, a destination hook for non-matching packets,
-and various statistics counters.
-.Pp
-A
-.Xr bpf 4
-program returns an unsigned integer, which is normally interpreted as
-the length of the prefix of the packet to return. In the context of this
-node type, returning zero is considered a non-match, in which case the
-entire packet is delivered out the non-match destination hook.
-Returning a value greater than zero causes the packet to be truncated
-to that length and delivered out the match destination hook.
-Either or both destination hooks may be the empty string, or may
-not exist, in which case the packet is dropped.
-.Pp
-New hooks are initially configured to drop all packets.
-A new filter may be installed using the
-.Dv NGM_BPF_SET_FILTER
-control message.
-.Sh HOOKS
-This node type supports any number of hooks having arbitrary names.
-.Sh CONTROL MESSAGES
-This node type supports the generic control messages, plus the following:
-.Bl -tag -width foo
-.It Dv NGM_BPF_SET_FILTER
-This command sets the filter program that will be applied to incoming
-data on a hook. The following structure must be supplied as an argument:
-.Bd -literal -offset 4n
-struct ngm_bpf_hookprog {
- char thisHook[NG_HOOKLEN+1]; /* name of hook */
- char ifMatch[NG_HOOKLEN+1]; /* match dest hook */
- char ifNotMatch[NG_HOOKLEN+1]; /* !match dest hook */
- int32_t bpf_prog_len; /* #isns in program */
- struct bpf_insn bpf_prog[0]; /* bpf program */
-};
-.Ed
-.Pp
-The hook to be updated is specified in
-.Dv thisHook .
-The BPF program is the sequence of instructions in the
-.Dv bpf_prog
-array; there must be
-.Dv bpf_prog_len
-of them.
-Matching and non-matching incoming packets are delivered out the hooks named
-.Dv ifMatch
-and
-.Dv ifNotMatch ,
-respectively. The program must be a valid
-.Xr bpf 4
-program or else
-.Er EINVAL
-is returned.
-.It Dv NGM_BPF_GET_FILTER
-This command takes an
-.Tn ASCII
-string argument, the hook name, and returns the
-corresponding
-.Dv "struct ngm_bpf_hookprog"
-as shown above.
-.It Dv NGM_BPF_GET_STATS
-This command takes an
-.Tn ASCII
-string argument, the hook name, and returns the
-statistics associated with the hook as a
-.Dv "struct ng_bpf_hookstat" .
-.It Dv NGM_BPF_CLR_STATS
-This command takes an
-.Tn ASCII
-string argument, the hook name, and clears the
-statistics associated with the hook.
-.It Dv NGM_BPF_GETCLR_STATS
-This command is identical to
-.Dv NGM_BPF_GET_STATS ,
-except that the statistics are also atomically cleared.
-.El
-.Sh SHUTDOWN
-This node shuts down upon receipt of a
-.Dv NGM_SHUTDOWN
-control message, or when all hooks have been disconnected.
-.Sh BUGS
-When built as a loadable kernel module, this module includes the file
-.Pa net/bpf_filter.c .
-Although loading the module should fail if
-.Pa net/bpf_filter.c
-already exists in the kernel, currently it does not, and the duplicate
-copies of the file do not interfere.
-However, this may change in the future.
-.Sh HISTORY
-The
-.Nm
-node type was implemented in
-.Fx 4.0 .
-.Sh SEE ALSO
-.Xr netgraph 4 ,
-.Xr bpf 4 ,
-.Xr ngctl 8 .
-.Sh AUTHORS
-.An Archie Cobbs Aq archie@whistle.com
diff --git a/share/man/man4/ng_cisco.4 b/share/man/man4/ng_cisco.4
deleted file mode 100644
index 03ffcb4f8547..000000000000
--- a/share/man/man4/ng_cisco.4
+++ /dev/null
@@ -1,171 +0,0 @@
-.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
-.\" All rights reserved.
-.\"
-.\" Subject to the following obligations and disclaimer of warranty, use and
-.\" redistribution of this software, in source or object code forms, with or
-.\" without modifications are expressly permitted by Whistle Communications;
-.\" provided, however, that:
-.\" 1. Any and all reproductions of the source or object code must include the
-.\" copyright notice above and the following disclaimer of warranties; and
-.\" 2. No rights are granted, in any manner or form, to use Whistle
-.\" Communications, Inc. trademarks, including the mark "WHISTLE
-.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
-.\" such appears in the above copyright notice or in the software.
-.\"
-.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
-.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
-.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
-.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
-.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
-.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
-.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
-.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
-.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
-.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
-.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
-.\" OF SUCH DAMAGE.
-.\"
-.\" Author: Archie Cobbs <archie@whistle.com>
-.\"
-.\" $FreeBSD$
-.\" $Whistle: ng_cisco.8,v 1.5 1999/01/25 23:46:26 archie Exp $
-.\"
-.Dd January 19, 1999
-.Dt NG_CISCO 8
-.Os FreeBSD
-.Sh NAME
-.Nm ng_cisco
-.Nd Cisco HDLC protocol netgraph node type
-.Sh SYNOPSIS
-.Fd #include <netinet/in.h>
-.Fd #include <netgraph/ng_cisco.h>
-.Sh DESCRIPTION
-The
-.Nm cisco
-node type performs encapsulation and de-encapsulation of packets
-using the Cisco HDLC protocol. This is a fairly simple
-protocol for the transmission of packets across
-high speed synchronous lines. Each packet is prepended with
-an Ethertype, indicating the protocol. There is also a
-.Dq keep alive
-and an
-.Dq inquire
-capability.
-.Pp
-The
-.Dv downstream
-hook should connect to the synchronous line. On the other side
-of the node are the
-.Dv inet ,
-.Dv atalk ,
-and
-.Dv ipx
-hooks, which transmit and receive raw IP, AppleTalk, and IPX packets,
-respectively. Typically these hooks would connect to the corresponding
-hooks on an
-.Xr ng_iface 8
-type node.
-.Sh IP Configuration
-In order to function properly for IP traffic, the node must be informed
-of the local IP address and netmask setting. This is because the protocol
-includes an
-.Dq inquire
-packet which we must be prepared to answer.
-There are two ways to accomplish this, manually and automatically.
-.Pp
-Whenever such an inquire packet is received, the node sends a
-.Dv NGM_CISCO_GET_IPADDR
-control message to the peer node connected to the
-.Dv inet
-hook (if any).
-If the peer responds, then that response is used. This is the automatic method.
-.Pp
-If the peer does not respond, the node falls back on its cached value
-for the IP address and netmask. This cached value can be set at any time
-with a
-.Dv NGM_CISCO_SET_IPADDR
-message, and this is the manual method.
-.Pp
-If the
-.Dv inet
-hook is connected to the
-.Dv inet
-hook of an
-.Xr ng_iface 8
-node, as is usually the case, then configuration is automatic as the
-.Xr ng_iface 8
-understands the
-.Dv NGM_CISCO_GET_IPADDR
-message.
-.Sh HOOKS
-This node type supports the following hooks:
-.Pp
-.Bl -tag -width foobarbazio
-.It Dv downstream
-The connection to the synchronous line.
-.It Dv inet
-IP hook.
-.It Dv atalk
-AppleTalk hook.
-.It Dv ipx
-IPX hook
-.El
-.Sh CONTROL MESSAGES
-This node type supports the generic control messages, plus the following:
-.Bl -tag -width foo
-.It Dv NGM_CISCO_SET_IPADDR
-This command takes an array of two
-.Dv "struct in_addr"
-arguments. The first is the IP address of the corresponding interface
-and the second is the netmask.
-.It Dv NGM_CISCO_GET_IPADDR
-This command returns the IP configuration in the same format used by
-.Dv NGM_CISCO_SET_IPADDR .
-This command is also
-.Em sent
-by this node type to the
-.Dv inet
-peer whenever an IP address inquiry packet is received.
-.It Dv NGM_CISCO_GET_STATUS
-Returns a
-.Dv "struct ngciscostat" :
-.Bd -literal -offset 4n
-struct ngciscostat {
- u_int32_t seq_retries; /* # unack'd retries */
- u_int32_t keepalive_period; /* in seconds */
-};
-.Ed
-.El
-.Sh SHUTDOWN
-This node shuts down upon receipt of a
-.Dv NGM_SHUTDOWN
-control message, or when all hooks have been disconnected.
-.Sh BUGS
-Not all of the functionality has been implemented. For example,
-the node does not support querying the remote end for its IP address
-and netmask.
-.Sh SEE ALSO
-.Xr netgraph 4 ,
-.Xr ng_iface 8 ,
-.Xr ngctl 8 .
-.Rs
-.%A D. Perkins
-.%T "Requirements for an Internet Standard Point-to-Point Protocol"
-.%O RFC 1547
-.Re
-.Sh LEGAL
-.Tn Cisco
-is a trademark of Cisco Systems, Inc.
-.Sh HISTORY
-The
-.Nm
-node type was implemented in
-.Fx 4.0 .
-.Sh AUTHORS
-.An Julian Elischer Aq julian@whistle.com ,
-.An Archie Cobbs Aq archie@whistle.com
diff --git a/share/man/man4/ng_echo.4 b/share/man/man4/ng_echo.4
deleted file mode 100644
index bdef682362e7..000000000000
--- a/share/man/man4/ng_echo.4
+++ /dev/null
@@ -1,73 +0,0 @@
-.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
-.\" All rights reserved.
-.\"
-.\" Subject to the following obligations and disclaimer of warranty, use and
-.\" redistribution of this software, in source or object code forms, with or
-.\" without modifications are expressly permitted by Whistle Communications;
-.\" provided, however, that:
-.\" 1. Any and all reproductions of the source or object code must include the
-.\" copyright notice above and the following disclaimer of warranties; and
-.\" 2. No rights are granted, in any manner or form, to use Whistle
-.\" Communications, Inc. trademarks, including the mark "WHISTLE
-.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
-.\" such appears in the above copyright notice or in the software.
-.\"
-.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
-.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
-.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
-.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
-.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
-.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
-.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
-.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
-.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
-.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
-.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
-.\" OF SUCH DAMAGE.
-.\"
-.\" Author: Archie Cobbs <archie@whistle.com>
-.\"
-.\" $FreeBSD$
-.\" $Whistle: ng_echo.8,v 1.4 1999/01/25 23:46:26 archie Exp $
-.\"
-.Dd January 19, 1999
-.Dt NG_ECHO 8
-.Os FreeBSD
-.Sh NAME
-.Nm ng_echo
-.Nd netgraph echo node type
-.Sh SYNOPSIS
-.Fd #include <netgraph/ng_echo.h>
-.Sh DESCRIPTION
-The
-.Nm echo
-node type reflects all data and control messages back to the sender.
-This node type is used for testing and debugging.
-.Sh HOOKS
-A
-.Nm echo
-node accepts any request to connect, regardless of the hook name,
-as long as the name is unique.
-.Sh CONTROL MESSAGES
-This node type supports only the generic control messages.
-Any other control messages are reflected back to the sender.
-.Sh SHUTDOWN
-This node shuts down upon receipt of a
-.Dv NGM_SHUTDOWN
-control message, or when all hooks have been disconnected.
-.Sh SEE ALSO
-.Xr netgraph 4 ,
-.Xr ng_hole 8 ,
-.Xr ngctl 8 .
-.Sh HISTORY
-The
-.Nm
-node type was implemented in
-.Fx 4.0 .
-.Sh AUTHORS
-.An Julian Elischer Aq julian@whistle.com
diff --git a/share/man/man4/ng_ether.4 b/share/man/man4/ng_ether.4
deleted file mode 100644
index 165c348ea0e7..000000000000
--- a/share/man/man4/ng_ether.4
+++ /dev/null
@@ -1,114 +0,0 @@
-.\" Copyright (c) 2000 Whistle Communications, Inc.
-.\" All rights reserved.
-.\"
-.\" Subject to the following obligations and disclaimer of warranty, use and
-.\" redistribution of this software, in source or object code forms, with or
-.\" without modifications are expressly permitted by Whistle Communications;
-.\" provided, however, that:
-.\" 1. Any and all reproductions of the source or object code must include the
-.\" copyright notice above and the following disclaimer of warranties; and
-.\" 2. No rights are granted, in any manner or form, to use Whistle
-.\" Communications, Inc. trademarks, including the mark "WHISTLE
-.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
-.\" such appears in the above copyright notice or in the software.
-.\"
-.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
-.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
-.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
-.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
-.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
-.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
-.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
-.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
-.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
-.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
-.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
-.\" OF SUCH DAMAGE.
-.\"
-.\" Author: Archie Cobbs <archie@whistle.com>
-.\"
-.\" $FreeBSD$
-.\"
-.Dd January 25, 2000
-.Dt NG_ETHER 8
-.Os FreeBSD
-.Sh NAME
-.Nm ng_ether
-.Nd Ethernet netgraph node type
-.Sh SYNOPSIS
-.Fd #include <netgraph/ng_ether.h>
-.Sh DESCRIPTION
-The
-.Nm ether
-netgraph node type allows Ethernet interfaces to interact with
-the
-.Xr netgraph 4
-networking subsystem. The kernel must be compiled with
-.Bd -literal
- options NETGRAPH
-.Ed
-.Pp
-for this functionality to be enabled.
-This causes a netgraph node to be automatically created for each Ethernet
-interface in the system. The node will have a name equal to
-the name of the interface, and it will be persistent.
-.Pp
-The Ethernet interface continues to function normally until a connection
-is made to one of the two supported hooks,
-.Dv orphans
-or
-.Dv divert .
-The
-.Dv orphans
-hook is used to receive Ethernet frames received by the device and
-having an unknown or unsupported Ethertype.
-The
-.Dv divert
-hook is used to divert
-.Em all
-Ethernet frames received by the device; the interface will otherwise
-appear to go silent until this hook is disconnected.
-.Pp
-Either hook may be used to transmit Ethernet frames by transmitting packets
-to the hook. In all cases, frames are raw Ethernet frames with the standard
-14 byte Ethernet header (but no checksum).
-.Sh HOOKS
-This node type supports the following hooks:
-.Pp
-.Bl -tag -width orphans
-.It Dv orphans
-This hook transmits Ethernet frames received by the device and
-having an unknown or unsupported Ethertype. Frames received on
-this hook are written as-is out on the wire.
-.It Dv divert
-When connected, this hook transmits all Ethernet frames received by the device.
-Frames received on this hook are written as-is out on the wire.
-.El
-.Sh CONTROL MESSAGES
-This node type supports only the generic control messages.
-.Sh SHUTDOWN
-This node is persistent. Upon receipt of a
-.Dv NGM_SHUTDOWN
-control message, all hooks are disconnected.
-.Sh EXAMPLE
-This command will dump all packets received by the
-.Dv fxp0
-interface to standard output as decoded hex and ASCII:
-.Bl -literal
-
- nghook -a fxp0: divert
-.El
-.Sh SEE ALSO
-.Xr arp 4 ,
-.Xr netgraph 4 ,
-.Xr netintro 4 ,
-.Xr ifconfig 8 ,
-.Xr nghook 8 ,
-.Xr ngctl 8
-.Sh AUTHOR
-.An Julian Elischer Aq julian@freebsd.org
diff --git a/share/man/man4/ng_frame_relay.4 b/share/man/man4/ng_frame_relay.4
deleted file mode 100644
index 7686d0ee8acb..000000000000
--- a/share/man/man4/ng_frame_relay.4
+++ /dev/null
@@ -1,98 +0,0 @@
-.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
-.\" All rights reserved.
-.\"
-.\" Subject to the following obligations and disclaimer of warranty, use and
-.\" redistribution of this software, in source or object code forms, with or
-.\" without modifications are expressly permitted by Whistle Communications;
-.\" provided, however, that:
-.\" 1. Any and all reproductions of the source or object code must include the
-.\" copyright notice above and the following disclaimer of warranties; and
-.\" 2. No rights are granted, in any manner or form, to use Whistle
-.\" Communications, Inc. trademarks, including the mark "WHISTLE
-.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
-.\" such appears in the above copyright notice or in the software.
-.\"
-.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
-.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
-.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
-.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
-.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
-.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
-.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
-.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
-.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
-.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
-.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
-.\" OF SUCH DAMAGE.
-.\"
-.\" Author: Archie Cobbs <archie@whistle.com>
-.\"
-.\" $FreeBSD$
-.\" $Whistle: ng_frame_relay.8,v 1.4 1999/01/25 23:46:26 archie Exp $
-.\"
-.Dd January 19, 1999
-.Dt NG_FRAME_RELAY 8
-.Os FreeBSD
-.Sh NAME
-.Nm ng_frame_relay
-.Nd frame relay netgraph node type
-.Sh SYNOPSIS
-.Fd #include <netgraph/ng_frame_relay.h>
-.Sh DESCRIPTION
-The
-.Nm frame_relay
-node type performs encapsulation, de-encapsulation, and multiplexing
-of packets using the frame relay protocol. It supports up to 1024 DLCI's.
-The LMI protocol is handled by a separate node type (see
-.Xr ng_lmi 8 ).
-.Pp
-The
-.Dv downstream
-hook should be connected to the synchronous line, i.e., the switch.
-Then hooks
-.Dv dlci0 ,
-.Dv dlci1 ,
-through
-.Dv dlci1023
-are available to connect to each of the DLCI channels.
-.Sh HOOKS
-This node type supports the following hooks:
-.Pp
-.Bl -tag -width foobar
-.It Dv downstream
-The connection to the synchronous line.
-.It Dv dlciX
-Here X is a decimal number from 0 to 1023. This hook corresponds
-to the DLCI X frame relay virtual channel.
-.El
-.Sh CONTROL MESSAGES
-This node type supports only the generic control messages.
-.Sh SHUTDOWN
-This node shuts down upon receipt of a
-.Dv NGM_SHUTDOWN
-control message, or when all hooks have been disconnected.
-.Sh BUGS
-Technically, frames on DLCI X should not be transmitted to the switch
-until the LMI protocol entity on both ends has configured DLCI X as active.
-The
-.Nm
-node type ignores this restriction, and will always pass data received
-on a DLCI hook to
-.Dv downstream .
-Instead, it should query the LMI node first.
-.Sh SEE ALSO
-.Xr netgraph 4 ,
-.Xr ng_lmi 8 ,
-.Xr ngctl 8 .
-.Sh HISTORY
-The
-.Nm
-node type was implemented in
-.Fx 4.0 .
-.Sh AUTHORS
-.An Julian Elischer Aq julian@whistle.com
diff --git a/share/man/man4/ng_hole.4 b/share/man/man4/ng_hole.4
deleted file mode 100644
index f1a701474092..000000000000
--- a/share/man/man4/ng_hole.4
+++ /dev/null
@@ -1,73 +0,0 @@
-.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
-.\" All rights reserved.
-.\"
-.\" Subject to the following obligations and disclaimer of warranty, use and
-.\" redistribution of this software, in source or object code forms, with or
-.\" without modifications are expressly permitted by Whistle Communications;
-.\" provided, however, that:
-.\" 1. Any and all reproductions of the source or object code must include the
-.\" copyright notice above and the following disclaimer of warranties; and
-.\" 2. No rights are granted, in any manner or form, to use Whistle
-.\" Communications, Inc. trademarks, including the mark "WHISTLE
-.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
-.\" such appears in the above copyright notice or in the software.
-.\"
-.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
-.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
-.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
-.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
-.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
-.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
-.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
-.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
-.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
-.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
-.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
-.\" OF SUCH DAMAGE.
-.\"
-.\" Author: Archie Cobbs <archie@whistle.com>
-.\"
-.\" $FreeBSD$
-.\" $Whistle: ng_hole.8,v 1.4 1999/01/25 23:46:26 archie Exp $
-.\"
-.Dd January 19, 1999
-.Dt NG_HOLE 8
-.Os FreeBSD
-.Sh NAME
-.Nm ng_hole
-.Nd netgraph discard node type
-.Sh SYNOPSIS
-.Fd #include <netgraph/ng_hole.h>
-.Sh DESCRIPTION
-The
-.Nm hole
-node type silently discards all data and control messages it receives.
-This type is used for testing and debugging.
-.Sh HOOKS
-A
-.Nm
-node accepts any request to connect, regardless of the hook name,
-as long as the name is unique.
-.Sh CONTROL MESSAGES
-This node type supports only the generic control messages.
-Other control messages are silently discarded.
-.Sh SHUTDOWN
-This node shuts down upon receipt of a
-.Dv NGM_SHUTDOWN
-control message, or when all hooks have been disconnected.
-.Sh SEE ALSO
-.Xr netgraph 4 ,
-.Xr ng_echo 8 ,
-.Xr ngctl 8 .
-.Sh HISTORY
-The
-.Nm
-node type was implemented in
-.Fx 4.0 .
-.Sh AUTHORS
-.An Julian Elischer Aq julian@whistle.com
diff --git a/share/man/man4/ng_iface.4 b/share/man/man4/ng_iface.4
deleted file mode 100644
index 40c6f8812b1e..000000000000
--- a/share/man/man4/ng_iface.4
+++ /dev/null
@@ -1,134 +0,0 @@
-.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
-.\" All rights reserved.
-.\"
-.\" Subject to the following obligations and disclaimer of warranty, use and
-.\" redistribution of this software, in source or object code forms, with or
-.\" without modifications are expressly permitted by Whistle Communications;
-.\" provided, however, that:
-.\" 1. Any and all reproductions of the source or object code must include the
-.\" copyright notice above and the following disclaimer of warranties; and
-.\" 2. No rights are granted, in any manner or form, to use Whistle
-.\" Communications, Inc. trademarks, including the mark "WHISTLE
-.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
-.\" such appears in the above copyright notice or in the software.
-.\"
-.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
-.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
-.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
-.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
-.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
-.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
-.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
-.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
-.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
-.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
-.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
-.\" OF SUCH DAMAGE.
-.\"
-.\" Author: Archie Cobbs <archie@whistle.com>
-.\"
-.\" $FreeBSD$
-.\" $Whistle: ng_iface.8,v 1.5 1999/01/25 23:46:26 archie Exp $
-.\"
-.Dd January 19, 1999
-.Dt NG_IFACE 8
-.Os FreeBSD
-.Sh NAME
-.Nm ng_iface
-.Nd interface netgraph node type
-.Sh SYNOPSIS
-.Fd #include <netgraph/ng_iface.h>
-.Sh DESCRIPTION
-An
-.Nm iface
-node is both a netgraph node and a system networking interface. When an
-.Nm
-node is created, a new point-to-point interface appears which is accessible via
-.Xr ifconfig 8 .
-The new interfaces are named
-.Dv ng0 ,
-.Dv ng1 ,
-etc. The node is assigned the same name as its interface, unless the name
-already exists, in which case the node remains unnamed.
-.Pp
-An
-.Nm
-node has a single hook corresponding to each supported protocol.
-Packets transmitted via the interface flow out the corresponding
-protocol-specific hook.
-Similarly, packets received on a hook appear on the interface as
-packets received in the corresponding protocol.
-.Pp
-The currently supported protocols are IP, IPX, AppleTalk, and NS.
-In the KLD module, only support for IP is compiled in by default.
-.Pp
-An
-.Nm
-node supports the Berkeley Packet Filter (BPF).
-.Sh HOOKS
-This node type supports the following hooks:
-.Pp
-.Bl -tag -width foobar
-.It Dv inet
-Transmission and reception of IP packets.
-.It Dv ipx
-Transmission and reception of IPX packets.
-.It Dv atalk
-Transmission and reception of AppleTalk packets.
-.It Dv ns
-Transmission and reception of NS packets.
-.El
-.Sh CONTROL MESSAGES
-This node type supports the generic control messages, plus the following:
-.Bl -tag -width foo
-.It Dv NGM_IFACE_GET_IFNAME
-Returns the name of the interface corresponding to this node in a
-.Dv "struct ng_iface_ifname" :
-.Bd -literal -offset 4n
-struct ng_iface_ifname {
- char ngif_name[NG_IFACE_IFACE_NAME_MAX + 1];
-};
-.Ed
-.It Dv NGM_IFACE_GET_IFADDRS
-Returns the list of addresses associated with this interface.
-The list is returned in the same format as the
-.Dv SIOCGIFCONF
-.Fn ioctl .
-.It Dv NGM_CISCO_GET_IPADDR
-This message is defined by the
-.Xr ng_cisco 8
-node type; see
-.Xr ng_cisco 8
-for a description.
-.El
-.Sh SHUTDOWN
-Because it is currently not possible to remove a system networking
-interface in
-.Fx ,
-.Nm
-nodes are
-.Em persistent.
-That is, once created they are never destroyed.
-The receipt of a
-.Dv NGM_SHUTDOWN
-control message disconnects all hooks but does not remove the node.
-.Sh SEE ALSO
-.Xr bpf 4 ,
-.Xr netgraph 4 ,
-.Xr ifconfig 8 ,
-.Xr ng_cisco 8 ,
-.Xr ng_ppp 8 ,
-.Xr ng_rfc1490 8 ,
-.Xr ngctl 8 .
-.Sh HISTORY
-The
-.Nm
-node type was implemented in
-.Fx 4.0 .
-.Sh AUTHORS
-.An Archie Cobbs Aq archie@whistle.com
diff --git a/share/man/man4/ng_ksocket.4 b/share/man/man4/ng_ksocket.4
deleted file mode 100644
index ff0abc7a77fd..000000000000
--- a/share/man/man4/ng_ksocket.4
+++ /dev/null
@@ -1,187 +0,0 @@
-.\" Copyright (c) 1999 Whistle Communications, Inc.
-.\" All rights reserved.
-.\"
-.\" Subject to the following obligations and disclaimer of warranty, use and
-.\" redistribution of this software, in source or object code forms, with or
-.\" without modifications are expressly permitted by Whistle Communications;
-.\" provided, however, that:
-.\" 1. Any and all reproductions of the source or object code must include the
-.\" copyright notice above and the following disclaimer of warranties; and
-.\" 2. No rights are granted, in any manner or form, to use Whistle
-.\" Communications, Inc. trademarks, including the mark "WHISTLE
-.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
-.\" such appears in the above copyright notice or in the software.
-.\"
-.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
-.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
-.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
-.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
-.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
-.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
-.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
-.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
-.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
-.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
-.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
-.\" OF SUCH DAMAGE.
-.\"
-.\" Author: Archie Cobbs <archie@whistle.com>
-.\"
-.\" $FreeBSD$
-.\"
-.Dd November 15, 1999
-.Dt NG_KSOCKET 8
-.Os FreeBSD
-.Sh NAME
-.Nm ng_ksocket
-.Nd kernel socket netgraph node type
-.Sh SYNOPSIS
-.Fd #include <netgraph/ng_ksocket.h>
-.Sh DESCRIPTION
-A
-.Nm ksocket
-node is both a netgraph node and a BSD socket. The
-.Nm
-node type allows one to open a socket inside the kernel and have
-it appear as a Netgraph node. The
-.Nm
-node type is the reverse of the socket node type (see
-.Xr ng_socket 8 ) :
-whereas the socket node type enables the user-level manipulation (via
-a socket) of what is normally a kernel-level entity (the associated
-Netgraph node), the
-.Nm
-node type enables the kernel-level manipulation (via a Netgraph node) of
-what is normally a user-level entity (the associated socket).
-.Pp
-A
-.Nm
-node allows at most one hook connection. Connecting to the node is
-equivalent to opening the associated socket. The name given to the hook
-determines what kind of socket the node will open (see below).
-When the hook is disconnected and/or the node is shutdown, the
-associated socket is closed.
-.Sh HOOKS
-This node type supports a single hook connection at a time.
-The name of the hook must be of the form
-.Dv Em <family>/<type>/<proto> ,
-where the
-.Dv Em family ,
-.Dv Em type ,
-and
-.Dv Em proto
-are the decimal equivalent of the same arguments to
-.Xr socket 2 .
-Alternately, aliases for the commonly used values are accepted as
-well. For example
-.Dv inet/dgram/udp
-is a more readable but equivalent version of
-.Dv 2/2/17 .
-.Sh CONTROL MESSAGES
-This node type supports the generic control messages, plus the following:
-.Bl -tag -width foo
-.It Dv NGM_KSOCKET_BIND
-This functions exactly like the
-.Xr bind 2
-system call. The
-.Dv "struct sockaddr"
-socket address parameter should be supplied as an argument.
-.It Dv NGM_KSOCKET_LISTEN
-This functions exactly like the
-.Xr listen 2
-system call. The backlog paramter (a single 32 bit
-.Dv int )
-should be supplied as an argument.
-.It Dv NGM_KSOCKET_CONNECT
-This functions exactly like the
-.Xr connect 2
-system call. The
-.Dv "struct sockaddr"
-destination address parameter should be supplied as an argument.
-.It Dv NGM_KSOCKET_ACCEPT
-Currently unimplemented.
-.It Dv NGM_KSOCKET_GETNAME
-Equivalent to the
-.Xr getname 2
-system call. The name is returned as a
-.Dv "struct sockaddr"
-in the arguments field of the reply.
-.It Dv NGM_KSOCKET_GETPEERNAME
-Equivalent to the
-.Xr getpeername 2
-system call. The name is returned as a
-.Dv "struct sockaddr"
-in the arguments field of the reply.
-.It Dv NGM_KSOCKET_SETOPT
-Equivalent to the
-.Xr setsockopt 2
-system call, except that the option name, level, and value are passed in a
-.Dv "struct ng_ksocket_sockopt" .
-.It Dv NGM_KSOCKET_GETOPT
-Equivalent to the
-.Xr getsockopt 2
-system call, except that the option is passed in a
-.Dv "struct ng_ksocket_sockopt" .
-When sending this command, the
-.Dv value
-field should be empty; upon return, it will contain the
-retrieved value.
-.El
-.Pp
-.Sh ASCII FORM CONTROL MESSAGES
-For control messages that pass a
-.Dv "struct sockaddr"
-in the argument field, the normal
-.Tn ASCII
-equivalent of the C structure
-is an acceptable form. For the
-.Dv PF_INET
-and
-.Dv PF_LOCAL
-address families, a more convenient form is also used, which is
-the protocol family name, followed by a slash, followed by the actual
-address. For
-.Dv PF_INET ,
-the address is an IP address followed by an optional colon and port number.
-For
-.Dv PF_LOCAL ,
-the address is the pathname as a doubly quoted string.
-.Pp
-Examples:
-.Bl -tag -width XXXXXXXXXX
-.It Dv PF_LOCAL
-inet/192.168.1.1:1234
-.It Dv PF_INET
-local/"/tmp/foo.socket"
-.It Other
-.Dv "{ family=16 len=16 data=[0x70 0x00 0x01 0x23] }"
-.El
-.Pp
-For control messages that pass a
-.Dv "struct ng_ksocket_sockopt" ,
-the normal
-.Tn ASCII
-form for that structure is used. In the future, more
-convenient encoding of the more common socket options may be supported.
-.Sh SHUTDOWN
-This node shuts down upon receipt of a
-.Dv NGM_SHUTDOWN
-control message, or when the hook is disconnected.
-Shutdown of the node closes the associated socket.
-.Sh SEE ALSO
-.Xr socket 2 ,
-.Xr netgraph 4 ,
-.Xr ng_socket 8 ,
-.Xr ngctl 8 .
-.Sh HISTORY
-The
-.Nm
-node type was implemented in
-.Fx 4.0 .
-.Sh AUTHORS
-.An Archie Cobbs Aq archie@whistle.com
diff --git a/share/man/man4/ng_lmi.4 b/share/man/man4/ng_lmi.4
deleted file mode 100644
index d03c0188226c..000000000000
--- a/share/man/man4/ng_lmi.4
+++ /dev/null
@@ -1,135 +0,0 @@
-.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
-.\" All rights reserved.
-.\"
-.\" Subject to the following obligations and disclaimer of warranty, use and
-.\" redistribution of this software, in source or object code forms, with or
-.\" without modifications are expressly permitted by Whistle Communications;
-.\" provided, however, that:
-.\" 1. Any and all reproductions of the source or object code must include the
-.\" copyright notice above and the following disclaimer of warranties; and
-.\" 2. No rights are granted, in any manner or form, to use Whistle
-.\" Communications, Inc. trademarks, including the mark "WHISTLE
-.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
-.\" such appears in the above copyright notice or in the software.
-.\"
-.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
-.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
-.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
-.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
-.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
-.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
-.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
-.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
-.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
-.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
-.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
-.\" OF SUCH DAMAGE.
-.\"
-.\" Author: Archie Cobbs <archie@whistle.com>
-.\"
-.\" $FreeBSD$
-.\" $Whistle: ng_lmi.8,v 1.4 1999/01/25 23:46:27 archie Exp $
-.\"
-.Dd January 19, 1999
-.Dt NG_LMI 8
-.Os FreeBSD
-.Sh NAME
-.Nm ng_lmi
-.Nd frame relay LMI protocol netgraph node type
-.Sh SYNOPSIS
-.Fd #include <netgraph/ng_lmi.h>
-.Sh DESCRIPTION
-The
-.Nm lmi
-node type performs the frame relay LMI protocol. It supports
-the ITU Annex A, ANSI Annex D, and Group-of-four LMI types.
-It also supports auto-detection of the LMI type.
-.Pp
-To enable a specific LMI type, connect the corresponding hook (
-.Dv annexA ,
-.Dv annexD ,
-or
-.Dv group4 ")"
-to DLCI 0 or 1023 of a
-.Xr ng_frame_relay 8
-node.
-Typically, Annex A and Annex D live on DLCI 0 while Group-of-four
-lives on DLCI 1023.
-.Pp
-To enable LMI type auto-detection, connect the
-.Dv auto0
-hook to DLCI 0 and the
-.Dv auto1023
-hook to DLCI 1023. The node will attempt to automatically determine
-which LMI type is running at the switch, and go into that mode.
-.Pp
-Only one fixed LMI type, or auto-detection, can be active at any given time.
-.Pp
-The
-.Dv NGM_LMI_GET_STATUS
-control message can be used at any time to query the current status
-of the LMI protocol and each DLCI channel. This node also supports the
-.Dv NGM_TEXT_STATUS
-control message.
-.Sh HOOKS
-This node type supports the following hooks:
-.Pp
-.Bl -tag -width foobarbaz
-.It Dv annexA
-ITU Annex A LMI hook.
-.It Dv annexD
-ANSI Annex D LMI hook.
-.It Dv group4
-Group-of-four LMI hook.
-.It Dv auto0
-Auto-detection hook for DLCI 0.
-.It Dv auto1023
-Auto-detection hook for DLCI 1023.
-.El
-.Sh CONTROL MESSAGES
-This node type supports the generic control messages, plus the following:
-.Bl -tag -width foo
-.It Dv NGM_LMI_GET_STATUS
-This command returns status information in a
-.Dv "struct nglmistat" :
-.Bd -literal -offset 4n
-#define NGM_LMI_STAT_ARYSIZE (1024/8)
-
-struct nglmistat {
- u_char proto[12]; /* Active proto (same as hook name) */
- u_char hook[12]; /* Active hook */
- u_char fixed; /* If set to fixed LMI mode */
- u_char autod; /* If currently auto-detecting */
- u_char seen[NGM_LMI_STAT_ARYSIZE]; /* bitmap DLCIs seen */
- u_char up[NGM_LMI_STAT_ARYSIZE]; /* bitmap DLCIs up */
-};
-.Ed
-.It Dv NGM_TEXT_STATUS
-This generic message returns is a human-readable version of the node status.
-.El
-.Sh SHUTDOWN
-This node shuts down upon receipt of a
-.Dv NGM_SHUTDOWN
-control message, or when all hooks have been disconnected.
-.Sh SEE ALSO
-.Xr netgraph 4 ,
-.Xr ng_frame_relay 8 ,
-.Xr ngctl 8 .
-.Rs
-.%T "ANSI T1.617-1991 Annex D"
-.Re
-.Rs
-.%T "ITU-T Q.933 Digital Subscriber Signaling System No. 1 - Signaling Specification for Frame Mode Basic Call Control, Annex A"
-.Re
-.Sh HISTORY
-The
-.Nm
-node type was implemented in
-.Fx 4.0 .
-.Sh AUTHORS
-.An Julian Elischer Aq julian@whistle.com
diff --git a/share/man/man4/ng_ppp.4 b/share/man/man4/ng_ppp.4
deleted file mode 100644
index 96045e0d1df3..000000000000
--- a/share/man/man4/ng_ppp.4
+++ /dev/null
@@ -1,386 +0,0 @@
-.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
-.\" All rights reserved.
-.\"
-.\" Subject to the following obligations and disclaimer of warranty, use and
-.\" redistribution of this software, in source or object code forms, with or
-.\" without modifications are expressly permitted by Whistle Communications;
-.\" provided, however, that:
-.\" 1. Any and all reproductions of the source or object code must include the
-.\" copyright notice above and the following disclaimer of warranties; and
-.\" 2. No rights are granted, in any manner or form, to use Whistle
-.\" Communications, Inc. trademarks, including the mark "WHISTLE
-.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
-.\" such appears in the above copyright notice or in the software.
-.\"
-.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
-.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
-.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
-.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
-.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
-.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
-.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
-.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
-.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
-.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
-.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
-.\" OF SUCH DAMAGE.
-.\"
-.\" Author: Archie Cobbs <archie@whistle.com>
-.\"
-.\" $FreeBSD$
-.\" $Whistle: ng_ppp.8,v 1.3 1999/01/25 23:46:27 archie Exp $
-.\"
-.Dd January 19, 1999
-.Dt NG_PPP 8
-.Os FreeBSD
-.Sh NAME
-.Nm ng_ppp
-.Nd PPP protocol netgraph node type
-.Sh SYNOPSIS
-.Fd #include <netgraph/ng_ppp.h>
-.Sh DESCRIPTION
-The
-.Nm ppp
-node type performs multiplexing for the PPP protocol. It handles
-only packets that contain data, and forwards protocol negotiation
-and control packets to a separate controlling entity (e.g., a
-user-land daemon). This approach combines the fast dispatch of
-kernel implementations with the configuration flexibility of a
-user-land implementations. The PPP node type directly supports
-multi-link PPP, Van Jacobsen compression, PPP compression, PPP
-encryption, and the IP, IPX, and AppleTalk protocols. A single
-PPP node corresponds to one PPP multi-link bundle.
-.Pp
-There is a separate hook for each PPP link in the bundle, plus
-several hooks corresponding to the directly supported protocols.
-For compression and encryption, separate attached nodes are required
-to do the actual work. The node type used will of course depend
-on the algorithm negotiated. There is also a
-.Dv bypass
-hook which is used to handle any protocol not directly supported
-by the node. This includes all of the control protocols: LCP, IPCP,
-CCP, etc. Typically this node is connected to a user-land daemon
-via a
-.Xr ng_socket 8
-type node.
-.Sh ENABLING FUNCTIONALITY
-In general, the PPP node enables a specific link or functionality when
-(a) a
-.Dv NGM_PPP_SET_CONFIG
-message has been received which enables it, and
-(b) the corresponding hook(s) are connected.
-This allows the controlling entity to use either method (a) or (b)
-(or both) to control the node's behavior.
-When a link is connected but disabled, traffic can still flow on
-the link via the
-.Dv bypass
-hook (see below).
-.Sh LINK HOOKS
-During normal operation, the individual PPP links are connected to hooks
-.Dv link0 ,
-.Dv link1 ,
-etc. Up to
-.Dv NG_PPP_MAX_LINKS
-links are supported.
-These device-independent hooks transmit and receive full PPP
-frames, which include the PPP protocol, address, control, and
-information fields, but no checksum or other link-specific fields.
-.Pp
-On outgoing frames, when protocol compression
-has been enabled and the protocol number is suitable for compression,
-the protocol field will be compressed (i.e., sent as one byte
-instead of two). Either compressed or uncompressed protocol fields
-are accepted on incoming frames. Similarly, if address and control
-field compression has been enabled for the link, the address and
-control fields will be omitted (except for LCP frames as required
-by the standards). Incoming frames have the address and control fields
-stripped automatically if present.
-.Pp
-Since all negotiation is handled outside the PPP node, the links
-should not be connected and enabled until the corresponding link
-has reached the network phase (i.e., LCP negotiation and authentication
-have completed successfully) and the PPP node has been informed of
-the link parameters via the
-.Dv NGM_PPP_LINK_CONFIG
-message.
-.Pp
-When a link is connected but disabled, all received frames are forwarded
-directly out the
-.Dv bypass
-hook, and conversely, frames may be transmitted via the
-.Dv bypass
-hook as well. This mode is appropriate for the link authentication phase.
-As soon as the link is enabled, the PPP node will
-begin processing frames received on the link.
-.Sh COMPRESSION AND ENCRYPTION
-Compression is supported via two hooks,
-.Dv compress
-and
-.Dv decompress .
-When enabled and connected, the PPP node writes outgoing frames on the
-.Dv comp
-hook and expects to receive back the compressed frame on the same hook.
-Similarly, the
-.Dv decompress
-hook is used to uncompress incoming frames when decompression is
-negotiated (compression and decompression are independently negotiable).
-The type of node attached to these hooks should correspond
-to the type of compression negotiated, e.g., Deflate, Predictor-1, etc.
-.Pp
-Encryption works exactly analogously via the
-.Dv encrypt
-and
-.Dv decrypt
-nodes. Data is always compressed before being encrypted,
-and decrypted before being decompressed.
-.Pp
-Only bundle-level compression and encryption is directly supported;
-link-level compression and encryption can be handled transparently
-by downstream nodes.
-.Sh VAN JACOBSEN COMPRESSION
-When all of the
-.Dv vjc_ip ,
-.Dv vjc_vjcomp ,
-.Dv vjc_vjuncomp ,
-and
-.Dv vjc_vjip
-hooks are connected, and the corresponding configuration flag is
-enabled, Van Jacobsen compression and/or decompression will become active.
-Normally these hooks connect to the corresponding hooks of a single
-.Xr ng_vjc 8
-node. The PPP node is compatible with the
-.Dq pass through
-modes of the
-.Xr ng_vjc 8
-node type.
-.Sh BYPASS HOOK
-When a frame is received on a link with an unsupported protocol,
-or a protocol which is disabled or for which the corresponding hook
-is unconnected, the PPP node forwards the frame out the
-.Dv bypass
-hook, prepended with a four byte prefix. This first two bytes of
-the prefix indicate the link number on which the frame was received
-(in network order).
-For such frames received over the bundle (i.e., encapsulated in the
-multi-link protocol), the special link number
-.Dv NG_PPP_BUNDLE_LINKNUM
-is used. After the two byte link number is the two byte PPP protocol number
-(also in network order).
-The PPP protocol number is two bytes long even if the original frame
-was protocol compressed.
-.Pp
-Conversely, any data written to the
-.Dv bypass
-hook is assumed to be in this same format. The four byte header is
-stripped off, the PPP protocol number is prepended (possibly compressed),
-and the frame is delivered over the desired link.
-If the link number is
-.Dv NG_PPP_BUNDLE_LINKNUM
-the frame will be delivered over the multi-link bundle; or, if multi-link
-is disabled, over the (single) PPP link.
-.Pp
-Typically when the controlling entity receives a packet on the bypass
-hook it responds either by dropping the frame (if it's not ready for
-the protocol) or with an LCP protocol reject (if it doesn't recognize
-or expect the protocol).
-.Sh MULTILINK OPERATION
-To enable multi-link PPP, the corresponding configuration flag must be set
-and at least one link connected. The PPP node will not allow more than
-one link to be connected if multi-link is not enabled, nor will it allow
-certain multi-link settings to be changed while multi-link operation is
-active (e.g., short sequence number header format).
-.Pp
-Because packets are sent as fragments across multiple individual links,
-it is important that when a link goes down the PPP node is notified
-immediately, either by disconnecting the corresponding hook or disabling
-the link via the
-.Dv NGM_PPP_SET_CONFIG
-control message.
-.Pp
-Each link has configuration parameters for latency (specified in
-milliseconds) and bandwidth (specified in tens of bytes per second).
-The PPP node can be configured for
-.Em round-robin
-or
-.Em optimized
-packet delivery.
-.Pp
-When configured for round-robin delivery, the latency and bandwidth
-values are ignored and the PPP node simply sends each frame as a
-single fragment, alternating frames across all the links in the
-bundle. This scheme has the advantage that even if one link fails
-silently, some packets will still get through. It has the disadvantage
-of sub-optimal overall bundle latency, which is important for
-interactive response time, and sub-optimal overall bundle bandwidth
-when links with different bandwidths exist in the same bundle.
-.Pp
-When configured for optimal delivery, the PPP node distributes the
-packet across the links in a way that minimizes the time it takes
-for the completed packet to be received by the far end. This
-involves taking into account each link's latency, bandwidth, and
-current queue length. Therefore these numbers should be
-configured as accurately as possible. The algorithm does require
-some computation, so may not be appropriate for very slow machines
-and/or very fast links.
-.Pp
-As a special case, if all links have identical latency and bandwidth,
-then the above algorithm is disabled (because it is unnecessary)
-and the PPP node simply fragments frames into equal sized portions
-across all of the links.
-.Sh HOOKS
-This node type supports the following hooks:
-.Pp
-.Bl -tag -compact -width vjc_vjuncomp
-.It Dv link<N>
-Individual PPP link number
-.Dv <N>
-.It Dv compress
-Connection to compression engine
-.It Dv decompress
-Connection to decompression engine
-.It Dv encrypt
-Connection to encryption engine
-.It Dv decrypt
-Connection to decryption engine
-.It Dv vjc_ip
-Connection to
-.Xr ng_vjc 8
-.Dv ip
-hook
-.It Dv vjc_vjcomp
-Connection to
-.Xr ng_vjc 8
-.Dv vjcomp
-hook
-.It Dv vjc_vjuncomp
-Connection to
-.Xr ng_vjc 8
-.Dv vjuncomp
-hook
-.It Dv vjc_vjip
-Connection to
-.Xr ng_vjc 8
-.Dv vjip
-hook
-.It Dv inet
-IP packet data
-.It Dv atalk
-AppleTalk packet data
-.It Dv ipx
-IPX packet data
-.It Dv bypass
-Bypass hook; frames have a four byte header consisting of
-a link number and a PPP protocol number.
-.El
-.Pp
-.Sh CONTROL MESSAGES
-This node type supports the generic control messages, plus the following:
-.Bl -tag -width foo
-.It Dv NGM_PPP_SET_CONFIG
-This command configures all aspects of the node. This includes enabling
-multi-link PPP, encryption, compression, Van Jacobsen compression, and IP,
-AppleTalk, and IPX packet delivery. It includes per-link configuration,
-including enabling the link, setting latency and bandwidth parameters,
-and enabling protocol field compression. Note that no link or functionality
-is active until the corresponding hook is also connected.
-This command takes a
-.Dv "struct ng_ppp_node_config"
-as an argument:
-.Bd -literal -offset 0
-/* Per-link config structure */
-struct ng_ppp_link_config {
- u_char enableLink; /* enable this link */
- u_char enableProtoComp;/* enable protocol field compression */
- u_char enableACFComp; /* enable addr/ctrl field compression */
- u_int16_t mru; /* peer MRU */
- u_int32_t latency; /* link latency (in milliseconds) */
- u_int32_t bandwidth; /* link bandwidth (in bytes/second) */
-};
-
-/* Node config structure */
-struct ng_ppp_node_config {
- u_int16_t mrru; /* multilink peer MRRU */
- u_char enableMultilink; /* enable multilink */
- u_char recvShortSeq; /* recv multilink short seq # */
- u_char xmitShortSeq; /* xmit multilink short seq # */
- u_char enableRoundRobin; /* xmit whole packets */
- u_char enableIP; /* enable IP data flow */
- u_char enableAtalk; /* enable AppleTalk data flow */
- u_char enableIPX; /* enable IPX data flow */
- u_char enableCompression; /* enable PPP compression */
- u_char enableDecompression; /* enable PPP decompression */
- u_char enableEncryption; /* enable PPP encryption */
- u_char enableDecryption; /* enable PPP decryption */
- u_char enableVJCompression; /* enable VJ compression */
- u_char enableVJDecompression; /* enable VJ decompression */
- struct ng_ppp_link_config /* per link config params */
- links[NG_PPP_MAX_LINKS];
-};
-.Ed
-.Pp
-.It Dv NGM_PPP_GET_CONFIG
-Returns the current configuration as a
-.Dv "struct ng_ppp_node_config" .
-.It Dv NGM_PPP_GET_LINK_STATS
-This command takes a two byte link number as an argument and returns a
-.Dv "struct ng_ppp_link_stat"
-containing statistics for the corresponding link. Here
-.Dv NG_PPP_BUNDLE_LINKNUM
-is a valid link number corresponding to the multi-link bundle.
-.It Dv NGM_PPP_CLR_LINK_STATS
-This command takes a two byte link number as an argument and
-clears the statistics for that link.
-.It Dv NGM_PPP_GETCLR_LINK_STATS
-Same as
-.Dv NGM_PPP_GET_LINK_STATS ,
-but also atomically clears the statistics as well.
-.El
-.Pp
-This node type also accepts the control messages accepted by the
-.Xr ng_vjc 8
-node type. When received, these messages are simply forwarded to
-the adjacent
-.Xr ng_vjc 8
-node, if any. This is particularly useful when the individual
-PPP links are able to generate
-.Dv NGM_VJC_RECV_ERROR
-messages (see
-.Xr ng_vjc 8
-for a description).
-.Sh SHUTDOWN
-This node shuts down upon receipt of a
-.Dv NGM_SHUTDOWN
-control message, or when all hooks have been disconnected.
-.Sh SEE ALSO
-.Xr netgraph 4 ,
-.Xr ng_async 8 ,
-.Xr ng_iface 8 ,
-.Xr ng_vjc 8 ,
-.Xr ng_pppoe 8 ,
-.Xr ngctl 8 .
-.Rs
-.%A W. Simpson
-.%T "The Point-to-Point Protocol (PPP)"
-.%O RFC 1661
-.Re
-.Rs
-.%A K. Sklower
-.%A B. Lloyd
-.%A G. McGregor
-.%A D. Carr
-.%A T. Coradetti
-.%T "The PPP Multilink Protocol (MP)"
-.%O RFC 1990
-.Re
-.Sh HISTORY
-The
-.Nm
-node type was implemented in
-.Fx 4.0 .
-.Sh AUTHORS
-.An Archie Cobbs Aq archie@whistle.com
diff --git a/share/man/man4/ng_pppoe.4 b/share/man/man4/ng_pppoe.4
deleted file mode 100644
index 60c40691e5ed..000000000000
--- a/share/man/man4/ng_pppoe.4
+++ /dev/null
@@ -1,404 +0,0 @@
-.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
-.\" All rights reserved.
-.\"
-.\" Subject to the following obligations and disclaimer of warranty, use and
-.\" redistribution of this software, in source or object code forms, with or
-.\" without modifications are expressly permitted by Whistle Communications;
-.\" provided, however, that:
-.\" 1. Any and all reproductions of the source or object code must include the
-.\" copyright notice above and the following disclaimer of warranties; and
-.\" 2. No rights are granted, in any manner or form, to use Whistle
-.\" Communications, Inc. trademarks, including the mark "WHISTLE
-.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
-.\" such appears in the above copyright notice or in the software.
-.\"
-.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
-.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
-.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
-.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
-.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
-.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
-.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
-.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
-.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
-.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
-.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
-.\" OF SUCH DAMAGE.
-.\"
-.\" Author: Archie Cobbs <archie@whistle.com>
-.\"
-.\" $FreeBSD$
-.\" $Whistle: ng_pppoe.8,v 1.1 1999/01/25 23:46:27 archie Exp $
-.\"
-.Dd October 28, 1999
-.Dt NG_PPPOE 8
-.Os FreeBSD
-.Sh NAME
-.Nm ng_pppoe
-.Nd RFC 2516 PPPOE protocol netgraph node type
-.Sh SYNOPSIS
-.Fd #include <net/ethernet.h>
-.Fd #include <netgraph/ng_pppoe.h>
-.Sh DESCRIPTION
-The
-.Nm pppoe
-node type performs the PPPoE protocol. It is used in conjunction with the
-.Xr netgraph 4
-extensions to the Ethernet framework to divert and inject Ethernet packets
-to and from a PPP agent (which is not specified).
-.Pp
-The
-.Dv NGM_PPPOE_GET_STATUS
-control message can be used at any time to query the current status
-of the PPPOE module. The only statistics presently available are the
-total packet counts for input and output. This node does not yet support
-the
-.Dv NGM_TEXT_STATUS
-control message.
-.Sh HOOKS
-This node type supports the following hooks:
-.Pp
-.Bl -tag -width foobarbaz
-.It Dv ethernet
-The hook that should normally be connected to an Ethernet node.
-.It Dv debug
-Presently no use.
-.It Dv [unspecified]
-Any other name is assumed to be a session hook that will be connected to
-a PPP client agent, or a ppp server agent.
-.El
-.Sh CONTROL MESSAGES
-This node type supports the generic control messages, plus the following:
-.Bl -tag -width foo
-.It Dv NGM_PPPOE_GET_STATUS
-This command returns status information in a
-.Dv "struct ngpppoestat" :
-.Bd -literal -offset 4n
-struct ngpppoestat {
- u_int packets_in; /* packets in from ethernet */
- u_int packets_out; /* packets out towards ethernet */
-};
-.Ed
-.It Dv NGM_TEXT_STATUS
-This generic message returns is a human-readable version of the node status.
-(not yet)
-.It Dv NGM_PPPOE_CONNECT
-Tell a nominated newly created hook that it's session should enter
-the state machine in a manner to become a client. It must be newly created and
-a service name can be given as an argument. It is legal to specify a zero length
-service name. This is common on some DSL setups. A session request packet
-will be broadcast on the Ethernet.
-This command uses the
-.Dv ngpppoe_init_data
-structure shown below.
-.It Dv NGM_PPPOE_LISTEN
-Tell a nominated newly created hook that it's session should enter
-the state machine in a manner to become a server listener. The argument
-given is the name of the service to listen on behalf of. A zero length service
-length will match all requests for service. A matching service request
-packet will be passed unmodified back to the process responsible
-for starting the service. It can then examine it and pass it on to
-the session that is started to answer the request.
-This command uses the
-.Dv ngpppoe_init_data
-structure shown below.
-.It Dv NGM_PPPOE_OFFER
-Tell a nominated newly created hook that it's session should enter
-the state machine in a manner to become a server. The argument
-given is the name of the service to offer. A zero length service
-is legal. The State machine will progress to a state where it will await
-a request packet to be forwarded to it from the startup server,
-which in turn probably received it from a LISTEN mode hook ( see above).
-This is so
-that information that is required for the session that is embedded in
-the original session request packet, is made available to the state machine
-that eventually answers the request. When the Session request packet is
-received, the session negotiation will proceed.
-This command uses the
-.Dv ngpppoe_init_data
-structure shown below.
-.Pp
-The three commands above use a common data structure:
-.Bd -literal -offset 4n
-struct ngpppoe_init_data {
- char hook[NG_HOOKLEN + 1]; /* hook to monitor on */
- u_int16_t data_len; /* service name length */
- char data[0]; /* init data goes here */
-};
-.Ed
-.It Dv NGM_PPPOE_SUCCESS
-This command is sent to the node that started this session with one of the
-above messages, and reports a state change. This message reports
-successful Session negotiation. It uses the structure shown below, and
-reports back the hook name corresponding to the successful session.
-.It Dv NGM_NGM_PPPOE_FAIL
-This command is sent to the node that started this session with one of the
-above messages, and reports a state change. This message reports
-failed Session negotiation. It uses the structure shown below, and
-reports back the hook name corresponding to the failed session.
-The hook will probably have been removed immediately after sending this message
-.It Dv NGM_NGM_PPPOE_CLOSE
-This command is sent to the node that started this session with one of the
-above messages, and reports a state change. This message reports
-a request to close a session. It uses the structure shown below, and
-reports back the hook name corresponding to the closed session.
-The hook will probably have been removed immediately after sending this
-message. At present this message is not yet used and a 'failed' message
-will be received at closure instead.
-.Pp
-The three commands above use a common data structure:
-.Bd -literal -offset 4n
-struct ngpppoe_sts {
- char hook[NG_HOOKLEN + 1]; /* hook associated with event session */
-};
-
-.El
-.Sh SHUTDOWN
-This node shuts down upon receipt of a
-.Dv NGM_SHUTDOWN
-control message, when all session have been disconnected or when the
-.Dv ethernet
-hook is disconnected.
-.Sh EXAMPLES
-The following code uses
-.Dv libnetgraph
-to set up a
-.Nm
-node and connect it to both a socket node and an Ethernet node. It can handle
-the case of when a
-.Nm
-node is already attached to the Ethernet. It then starts a client session.
-.Bd -literal
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <unistd.h>
-#include <sysexits.h>
-#include <errno.h>
-#include <err.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/select.h>
-#include <net/ethernet.h>
-
-#include <netgraph.h>
-#include <netgraph/ng_ether.h>
-#include <netgraph/ng_pppoe.h>
-#include <netgraph/ng_socket.h>
-static int setup(char *ethername, char *service, char *sessname,
- int *dfd, int *cfd);
-
-int
-main()
-{
- int fd1, fd2;
- setup("xl0", NULL, "fred", &fd1, &fd2);
- sleep (30);
-}
-
-static int
-setup(char *ethername, char *service, char *sessname,
- int *dfd, int *cfd)
-{
- struct ngm_connect ngc; /* connect */
- struct ngm_mkpeer mkp; /* mkpeer */
- /******** nodeinfo stuff **********/
- u_char rbuf[2 * 1024];
- struct ng_mesg *const resp = (struct ng_mesg *) rbuf;
- struct hooklist *const hlist
- = (struct hooklist *) resp->data;
- struct nodeinfo *const ninfo = &hlist->nodeinfo;
- int ch, no_hooks = 0;
- struct linkinfo *link;
- struct nodeinfo *peer;
- /****message to connect pppoe session*****/
- struct {
- struct ngPPPoE_init_data idata;
- char service[100];
- } message;
- /********tracking our little graph ********/
- char path[100];
- char source_ID[NG_NODELEN + 1];
- char pppoe_node_name[100];
- int k;
-
- /*
- * Create the data and control sockets
- */
- if (NgMkSockNode(NULL, cfd, dfd) < 0) {
- return (errno);
- }
- /*
- * find the ether node of the name requested by asking it for
- * it's inquiry information.
- */
- if (strlen(ethername) > 16)
- return (EINVAL);
- sprintf(path, "%s:", ethername);
- if (NgSendMsg(*cfd, path, NGM_GENERIC_COOKIE,
- NGM_LISTHOOKS, NULL, 0) < 0) {
- return (errno);
- }
- /*
- * the command was accepted so it exists. Await the reply (It's
- * almost certainly already waiting).
- */
- if (NgRecvMsg(*cfd, resp, sizeof(rbuf), NULL) < 0) {
- return (errno);
- }
- /**
- * The following is available about the node:
- * ninfo->name (string)
- * ninfo->type (string)
- * ninfo->id (u_int32_t)
- * ninfo->hooks (u_int32_t) (count of hooks)
- * check it is the correct type. and get it's ID for use
- * with mkpeer later.
- */
- if (strncmp(ninfo->type, NG_ETHER_NODE_TYPE,
- strlen(NG_ETHER_NODE_TYPE)) != 0) {
- return (EPROTOTYPE);
- }
- sprintf(source_ID, "[%08x]:", ninfo->id);
-
- /*
- * look for a hook already attached.
- */
- for (k = 0; k < ninfo->hooks; k++) {
- /**
- * The following are available about each hook.
- * link->ourhook (string)
- * link->peerhook (string)
- * peer->name (string)
- * peer->type (string)
- * peer->id (u_int32_t)
- * peer->hooks (u_int32_t)
- */
- link = &hlist->link[k];
- peer = &hlist->link[k].nodeinfo;
-
- /* Ignore debug hooks */
- if (strcmp("debug", link->ourhook) == 0)
- continue;
-
- /* If the orphans hook is attached, use that */
- if (strcmp(NG_ETHER_HOOK_ORPHAN,
- link->ourhook) == 0) {
- break;
- }
- /* the other option is the 'divert' hook */
- if (strcmp("NG_ETHER_HOOK_DIVERT",
- link->ourhook) == 0) {
- break;
- }
- }
-
- /*
- * See if we found a hook there.
- */
- if (k < ninfo->hooks) {
- if (strcmp(peer->type, NG_PPPOE_NODE_TYPE) == 0) {
- /*
- * If it's a type pppoe, we skip making one
- * ourself, but we continue, using
- * the existing one.
- */
- sprintf(pppoe_node_name, "[%08x]:", peer->id);
- } else {
- /*
- * There is already someone hogging the data,
- * return an error. Some day we'll try
- * daisy-chaining..
- */
- return (EBUSY);
- }
- } else {
-
- /*
- * Try make a node of type pppoe against node "ID"
- * On hook NG_ETHER_HOOK_ORPHAN.
- */
- snprintf(mkp.type, sizeof(mkp.type),
- "%s", NG_PPPOE_NODE_TYPE);
- snprintf(mkp.ourhook, sizeof(mkp.ourhook),
- "%s", NG_ETHER_HOOK_ORPHAN);
- snprintf(mkp.peerhook, sizeof(mkp.peerhook),
- "%s", NG_PPPOE_HOOK_ETHERNET);
- /* Send message */
- if (NgSendMsg(*cfd, source_ID, NGM_GENERIC_COOKIE,
- NGM_MKPEER, &mkp, sizeof(mkp)) < 0) {
- return (errno);
- }
- /*
- * Work out a name for the new node.
- */
- sprintf(pppoe_node_name, "%s:%s",
- source_ID, NG_ETHER_HOOK_ORPHAN);
- }
- /*
- * We now have a pppoe node attached to the ethernet
- * card. The Ethernet is addressed as ethername: The pppoe
- * node is addressed as pppoe_node_name: attach to it.
- * Connect socket node to specified node Use the same hook
- * name on both ends of the link.
- */
- snprintf(ngc.path, sizeof(ngc.path), "%s", pppoe_node_name);
- snprintf(ngc.ourhook, sizeof(ngc.ourhook), "%s", sessname);
- snprintf(ngc.peerhook, sizeof(ngc.peerhook), "%s", sessname);
-
- if (NgSendMsg(*cfd, ".:", NGM_GENERIC_COOKIE,
- NGM_CONNECT, &ngc, sizeof(ngc)) < 0) {
- return (errno);
- }
- /*
- * Send it a message telling it to start up.
- */
- bzero(&message, sizeof(message));
- snprintf(message.idata.hook, sizeof(message.idata.hook),
- "%s", sessname);
- if (service == NULL) {
- message.idata.data_len = 0;
- } else {
- snprintf(message.idata.data,
- sizeof(message.idata.data), "%s", service);
- message.idata.data_len = strlen(service);
- }
- /* Tell session/hook to start up as a client */
- if (NgSendMsg(*cfd, ngc.path,
- NGM_PPPOE_COOKIE, NGM_PPPOE_CONNECT, &message.idata,
- sizeof(message.idata) + message.idata.data_len) < 0) {
- return (errno);
- }
- return (0);
-}
-.Ed
-.Sh SEE ALSO
-.Xr netgraph 3 ,
-.Xr netgraph 4 ,
-.Xr ng_socket 8 ,
-.Xr ng_ppp 8 ,
-.Xr ngctl 8 .
-.Rs
-.%A L. Mamakos
-.%A K. Lidl
-.%A J. Evarts
-.%A D. Carrel
-.%A D. Simone
-.%A R. Wheeler
-.%T "A Method for transmitting PPP over Ethernet (PPPoE)"
-.%O RFC 2516
-.Re
-.Sh HISTORY
-The
-.Nm
-node type was implemented in
-.Fx 4.0 .
-.Sh AUTHORS
-.An Julian Elischer Aq julian@whistle.com
diff --git a/share/man/man4/ng_pptpgre.4 b/share/man/man4/ng_pptpgre.4
deleted file mode 100644
index 2b59eaa6e833..000000000000
--- a/share/man/man4/ng_pptpgre.4
+++ /dev/null
@@ -1,141 +0,0 @@
-.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
-.\" All rights reserved.
-.\"
-.\" Subject to the following obligations and disclaimer of warranty, use and
-.\" redistribution of this software, in source or object code forms, with or
-.\" without modifications are expressly permitted by Whistle Communications;
-.\" provided, however, that:
-.\" 1. Any and all reproductions of the source or object code must include the
-.\" copyright notice above and the following disclaimer of warranties; and
-.\" 2. No rights are granted, in any manner or form, to use Whistle
-.\" Communications, Inc. trademarks, including the mark "WHISTLE
-.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
-.\" such appears in the above copyright notice or in the software.
-.\"
-.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
-.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
-.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
-.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
-.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
-.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
-.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
-.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
-.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
-.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
-.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
-.\" OF SUCH DAMAGE.
-.\"
-.\" Author: Archie Cobbs <archie@whistle.com>
-.\"
-.\" $FreeBSD$
-.\" $Whistle: ng_pptpgre.8,v 1.2 1999/12/08 00:20:53 archie Exp $
-.\"
-.Dd November 29, 1999
-.Dt NG_PPTPGRE 8
-.Os FreeBSD
-.Sh NAME
-.Nm ng_pptpgre
-.Nd PPTP GRE protocol netgraph node type
-.Sh SYNOPSIS
-.Fd #include <netgraph/ng_pptpgre.h>
-.Sh DESCRIPTION
-The
-.Nm pptpgre
-node type performs Generic Routing Encapsulation (GRE) over IP
-for the PPTP protocol as specified by RFC 2637. This involves packet
-encapsulation, sequencing, acknowlegement, and an adaptive timeout
-sliding window mechanism. This node type does not handle any of
-the TCP control protocol or call negotiation defined by PPTP.
-.Pp
-The typical use for this node type would be to connect the
-.Dv upper
-hook to one of the link hooks of a
-.Xr ng_ppp 8
-node, and the
-.Dv lower
-hook to the
-.Dv "inet/raw/gre"
-hook of a
-.Xr ng_ksocket 8
-node.
-.Sh HOOKS
-This node type supports the following hooks:
-.Pp
-.Bl -tag -compact -width vjc_vjuncomp
-.It Dv upper
-Connection to the upper protocol layers
-.It Dv lower
-Connection to the lower protocol layers
-.El
-.Pp
-.Sh CONTROL MESSAGES
-This node type supports the generic control messages, plus the following:
-.Bl -tag -width foo
-.It Dv NGM_PPTPGRE_SET_CONFIG
-This command resets and configures the node for a session.
-This command takes a
-.Dv "struct ng_pptpgre_conf"
-as an argument:
-.Bd -literal -offset 0
-/* Configuration for a session */
-struct ng_pptpgre_conf {
- u_char enabled; /* enables traffic flow */
- u_char enableDelayedAck; /* enables delayed acks */
- u_int16_t cid; /* my call id */
- u_int16_t peerCid; /* peer call id */
- u_int16_t recvWin; /* peer recv window size */
- u_int16_t peerPpd; /* peer packet processing delay
- (in 1/10 of a second) */
-};
-
-.Ed
-The
-.Dv enabled
-field enables traffic flow through the node. The
-.Dv enableDelayedAck
-field enables delayed acknowledgement (maximum 250 miliseconds), which
-is a useful optimization and should generally be turned on.
-The remaining fields are as supplied by the PPTP virtual call setup process.
-.It Dv NGM_PPTPGRE_GET_CONFIG
-Returns the current configuration as a
-.Dv "struct ng_pptpgre_conf" .
-.El
-.Sh SHUTDOWN
-This node shuts down upon receipt of a
-.Dv NGM_SHUTDOWN
-control message, or when both hooks have been disconnected.
-.Sh SEE ALSO
-.Xr netgraph 4 ,
-.Xr ng_ksocket 8 ,
-.Xr ng_ppp 8 ,
-.Xr ngctl 8 .
-.Rs
-.%A K. Hamzeh
-.%A G. Pall
-.%A W. Verthein
-.%A J. Taarud
-.%A W. Little
-.%A G. Zorn
-.%T "Point-to-Point Tunneling Protocol (PPTP)"
-.%O RFC 2637
-.Re
-.Rs
-.%A S. Hanks
-.%A T. \&Li
-.%A D. Farinacci
-.%A P. Traina
-.%T "Generic Routing Encapsulation over IPv4 networks"
-.%O RFC 1702
-.Re
-.Sh HISTORY
-The
-.Nm
-node type was implemented in
-.Fx 4.0 .
-.Sh AUTHORS
-.An Archie Cobbs Aq archie@whistle.com
diff --git a/share/man/man4/ng_rfc1490.4 b/share/man/man4/ng_rfc1490.4
deleted file mode 100644
index f8d3e015f625..000000000000
--- a/share/man/man4/ng_rfc1490.4
+++ /dev/null
@@ -1,114 +0,0 @@
-.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
-.\" All rights reserved.
-.\"
-.\" Subject to the following obligations and disclaimer of warranty, use and
-.\" redistribution of this software, in source or object code forms, with or
-.\" without modifications are expressly permitted by Whistle Communications;
-.\" provided, however, that:
-.\" 1. Any and all reproductions of the source or object code must include the
-.\" copyright notice above and the following disclaimer of warranties; and
-.\" 2. No rights are granted, in any manner or form, to use Whistle
-.\" Communications, Inc. trademarks, including the mark "WHISTLE
-.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
-.\" such appears in the above copyright notice or in the software.
-.\"
-.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
-.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
-.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
-.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
-.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
-.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
-.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
-.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
-.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
-.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
-.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
-.\" OF SUCH DAMAGE.
-.\"
-.\" Author: Archie Cobbs <archie@whistle.com>
-.\"
-.\" $FreeBSD$
-.\" $Whistle: ng_rfc1490.8,v 1.4 1999/01/25 23:46:27 archie Exp $
-.\"
-.Dd January 19, 1999
-.Dt NG_RFC1490 8
-.Os FreeBSD
-.Sh NAME
-.Nm ng_rfc1490
-.Nd RFC 1490 netgraph node type
-.Sh SYNOPSIS
-.Fd #include <netgraph/ng_rfc1490.h>
-.Sh DESCRIPTION
-The
-.Nm rfc1490
-node type performs protocol encapsulation, de-encapsulation, and
-multiplexing according to RFC 1490 (which has since been updated by RFC 2427).
-This particular type of encapsulation is often used on top of frame relay
-DLCI channels.
-.Pp
-The
-.Dv downstream
-hook is used to transmit and receive encapsulated frames. On the other
-side of the node, the
-.Dv inet
-and
-.Dv ppp
-hooks are used to transmit and receive raw IP frames and PPP frames,
-respectively. PPP frames are transmitted and received according to
-RFC 1973; in particular, frames appearing on the
-.Dv ppp
-hook begin with the PPP protocol number.
-.Pp
-Typically the
-.Dv inet
-hook is connected to the
-.Dv inet
-hook of an
-.Xr ng_iface 8
-node.
-.Sh HOOKS
-This node type supports the following hooks:
-.Pp
-.Bl -tag -width foobarbazum
-.It Dv downstream
-Connects to the RFC 1490 peer entity.
-.It Dv inet
-Transmits and receives raw IP frames.
-.It Dv ppp
-Transmits and receives PPP frames.
-.El
-.Sh CONTROL MESSAGES
-This node type only supports the generic control messages.
-.Sh SHUTDOWN
-This node shuts down upon receipt of a
-.Dv NGM_SHUTDOWN
-control message, or when all hooks have been disconnected.
-.Sh BUGS
-Not all of RFC 1490 is implemented.
-.Sh SEE ALSO
-.Xr netgraph 4 ,
-.Xr ng_frame_relay 8 ,
-.Xr ng_iface 8 ,
-.Xr ngctl 8 .
-.Rs
-.%A C. Brown, A. Malis
-.%T "Multiprotocol Interconnect over Frame Relay"
-.%O RFC 2427
-.Re
-.Rs
-.%A W. Simpson
-.%T "PPP in Frame Relay"
-.%O RFC 1973
-.Re
-.Sh HISTORY
-The
-.Nm
-node type was implemented in
-.Fx 4.0 .
-.Sh AUTHORS
-.An Julian Elischer Aq julian@whistle.com
diff --git a/share/man/man4/ng_socket.4 b/share/man/man4/ng_socket.4
deleted file mode 100644
index 2a43b6a30e88..000000000000
--- a/share/man/man4/ng_socket.4
+++ /dev/null
@@ -1,178 +0,0 @@
-.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
-.\" All rights reserved.
-.\"
-.\" Subject to the following obligations and disclaimer of warranty, use and
-.\" redistribution of this software, in source or object code forms, with or
-.\" without modifications are expressly permitted by Whistle Communications;
-.\" provided, however, that:
-.\" 1. Any and all reproductions of the source or object code must include the
-.\" copyright notice above and the following disclaimer of warranties; and
-.\" 2. No rights are granted, in any manner or form, to use Whistle
-.\" Communications, Inc. trademarks, including the mark "WHISTLE
-.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
-.\" such appears in the above copyright notice or in the software.
-.\"
-.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
-.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
-.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
-.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
-.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
-.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
-.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
-.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
-.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
-.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
-.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
-.\" OF SUCH DAMAGE.
-.\"
-.\" Author: Archie Cobbs <archie@whistle.com>
-.\"
-.\" $FreeBSD$
-.\" $Whistle: ng_socket.8,v 1.5 1999/01/25 23:46:27 archie Exp $
-.\"
-.Dd January 19, 1999
-.Dt NG_SOCKET 8
-.Os FreeBSD
-.Sh NAME
-.Nm ng_socket
-.Nd netgraph socket node type
-.Sh SYNOPSIS
-.Fd #include <netgraph/ng_message.h>
-.Fd #include <netgraph/ng_socket.h>
-.Sh DESCRIPTION
-A
-.Nm socket
-node is both a BSD socket and a netgraph node. The
-.Nm
-node type allows user-mode processes to participate in the kernel
-.Xr netgraph 4
-networking subsystem using the BSD socket interface. The process must have
-root privileges to be able to create netgraph sockets however once created,
-any process that has one may use it.
-.Pp
-A new
-.Nm
-node is created by creating a new socket of type
-.Dv NG_CONTROL
-in the protocol family
-.Dv PF_NETGRAPH ,
-using the
-.Xr socket 2
-system call.
-Any control messages received by the node
-and not having a cookie value of
-.Dv NGM_SOCKET_COOKIE
-are received by the process, using
-.Xr recvfrom 2 ;
-the socket address argument is a
-.Dv "struct sockaddr_ng"
-containing the sender's netgraph address. Conversely, control messages
-can be sent to any node by calling
-.Xr sendto 2 ,
-supplying the recipient's address in a
-.Dv "struct sockaddr_ng" .
-The
-.Xr bind 2
-system call may be used to assign a global netgraph name to the node.
-.Pp
-To transmit and receive netgraph data packets, a
-.Dv NG_DATA
-socket must also be created using
-.Xr socket 2
-and associated with a
-.Nm
-node.
-.Dv NG_DATA sockets do not automatically
-have nodes associated with them; they are bound to a specific node via the
-.Xr connect 2
-system call. The address argument is the netgraph address of the
-.Nm
-node already created. Once a data socket is associated with a node,
-any data packets received by the node are read using
-.Xr recvfrom 2
-and any packets to be sent out from the node are written using
-.Xr sendto 2 .
-In the case of data sockets, the
-.Dv "struct sockaddr_ng"
-contains the name of the
-.Em hook
-on which the data was received or should be sent.
-.Pp
-As a special case, to allow netgraph data sockets to be used as stdin or stdout
-on naive programs, a
-.Xr sendto 2
-with a NULL sockaddr pointer, a
-.Xr send 2
-or a
-.Xr write 2
-will succeed in the case where there is exactly ONE hook attached to
-the socket node, (and thus the path is unambiguous).
-.Pp
-There is a user library that simplifies using netgraph sockets; see
-.Xr netgraph 3 .
-.Sh HOOKS
-This node type supports hooks with arbitrary names (as long as
-they are unique) and always accepts hook connection requests.
-.Sh CONTROL MESSAGES
-This node type supports the generic control messages, plus the following:
-.Bl -tag -width foo
-.It Dv NGM_SOCK_CMD_NOLINGER
-When the last hook is removed from this node, it will shut down as
-if it had received a
-.Dv NGM_SHUTDOWN
-message. Attempts to access the sockets associated will return
-.Er ENOTCONN .
-.It Dv NGM_SOCK_CMD_LINGER
-This is the default mode. When the last hook is removed, the node will
-continue to exist, ready to accept new hooks until it
-is explicitly shut down.
-.El
-.Pp
-All other messages
-with neither the
-.Dv NGM_SOCKET_COOKIE
-or
-.Dv NGM_GENERIC_COOKIE
-will be passed unaltered up the
-.Dv NG_CONTROL
-socket.
-.Sh SHUTDOWN
-This node type shuts down and disappears when both the associated
-.Dv NG_CONTROL
-and
-.Dv NG_DATA
-sockets have been closed, or a
-.Dv NGM_SHUTDOWN
-control message is received. In the latter case, attempts to write
-to the still-open sockets will return
-.Er ENOTCONN .
-If the
-.Dv NGM_SOCK_CMD_NOLINGER
-message has been received, closure of the last hook will also initiate
-a shutdown of the node.
-.Sh BUGS
-It is not possible to reject the connection of a hook, though any
-data received on that hook can certainly be ignored.
-.Pp
-The controlling process is not notified of all events that an in-kernel node
-would be notified of, e.g. a new hook, or hook removal. We should define
-some node-initiated messages for this purpose (to be sent up the control
-socket).
-.Sh SEE ALSO
-.Xr socket 2 ,
-.Xr netgraph 3 ,
-.Xr netgraph 4 ,
-.Xr ng_ksocket 8 ,
-.Xr ngctl 8 .
-.Sh HISTORY
-The
-.Nm
-node type was implemented in
-.Fx 4.0 .
-.Sh AUTHORS
-.An Julian Elischer Aq julian@whistle.com
diff --git a/share/man/man4/ng_tee.4 b/share/man/man4/ng_tee.4
deleted file mode 100644
index 6116d27d9a16..000000000000
--- a/share/man/man4/ng_tee.4
+++ /dev/null
@@ -1,124 +0,0 @@
-.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
-.\" All rights reserved.
-.\"
-.\" Subject to the following obligations and disclaimer of warranty, use and
-.\" redistribution of this software, in source or object code forms, with or
-.\" without modifications are expressly permitted by Whistle Communications;
-.\" provided, however, that:
-.\" 1. Any and all reproductions of the source or object code must include the
-.\" copyright notice above and the following disclaimer of warranties; and
-.\" 2. No rights are granted, in any manner or form, to use Whistle
-.\" Communications, Inc. trademarks, including the mark "WHISTLE
-.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
-.\" such appears in the above copyright notice or in the software.
-.\"
-.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
-.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
-.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
-.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
-.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
-.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
-.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
-.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
-.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
-.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
-.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
-.\" OF SUCH DAMAGE.
-.\"
-.\" Author: Archie Cobbs <archie@whistle.com>
-.\"
-.\" $FreeBSD$
-.\" $Whistle: ng_tee.8,v 1.4 1999/01/25 23:46:27 archie Exp $
-.\"
-.Dd January 19, 1999
-.Dt NG_TEE 8
-.Os FreeBSD
-.Sh NAME
-.Nm ng_tee
-.Nd netgraph ``tee'' node type
-.Sh SYNOPSIS
-.Fd #include <netgraph/ng_tee.h>
-.Sh DESCRIPTION
-The
-.Nm tee
-node type has a purpose similar to the
-.Xr tee 1
-command.
-.Nm Tee
-nodes are useful for debugging or
-.Dq snooping
-on a connection
-between two netgraph nodes.
-.Nm Tee
-nodes have four hooks,
-.Dv right ,
-.Dv left ,
-.Dv right2left ,
-and
-.Dv left2right .
-All data received on
-.Dv right
-is sent unmodified to
-.Em both
-hooks
-.Dv left
-and
-.Dv right2left .
-Similarly, all data received on
-.Dv left
-is sent unmodified to both
-.Dv right
-and
-.Dv left2right .
-.Pp
-Packets may also be received on
-.Dv right2left
-and
-.Dv left2right ;
-if so, they are forwarded unchanged out hooks
-.Dv left
-and
-.Dv right ,
-respectively.
-.Sh HOOKS
-This node type supports the following hooks:
-.Pp
-.Bl -tag -width foobarbarfoo
-.It Dv right
-The connection to the node on the right.
-.It Dv left
-The connection to the node on the left.
-.It Dv right2left
-Tap for right to left traffic.
-.It Dv left2right
-Tap for left to right traffic.
-.El
-.Sh CONTROL MESSAGES
-This node type supports the generic control messages, plus the following.
-.Bl -tag -width foo
-.It Dv NGM_TEE_GET_STATS
-Get statistics, returned as a
-.Dv "struct ng_tee_stats" .
-.It Dv NGM_TEE_CLR_STATS
-Clear statistics.
-.El
-.Sh SHUTDOWN
-This node shuts down upon receipt of a
-.Dv NGM_SHUTDOWN
-control message, or when all hooks have been disconnected.
-.Sh SEE ALSO
-.Xr tee 1 ,
-.Xr netgraph 4 ,
-.Xr ngctl 8 .
-.Sh HISTORY
-The
-.Nm
-node type was implemented in
-.Fx 4.0 .
-.Sh AUTHORS
-.An Julian Elischer Aq julian@whistle.com
diff --git a/share/man/man4/ng_tty.4 b/share/man/man4/ng_tty.4
deleted file mode 100644
index de4a4c20d731..000000000000
--- a/share/man/man4/ng_tty.4
+++ /dev/null
@@ -1,139 +0,0 @@
-.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
-.\" All rights reserved.
-.\"
-.\" Subject to the following obligations and disclaimer of warranty, use and
-.\" redistribution of this software, in source or object code forms, with or
-.\" without modifications are expressly permitted by Whistle Communications;
-.\" provided, however, that:
-.\" 1. Any and all reproductions of the source or object code must include the
-.\" copyright notice above and the following disclaimer of warranties; and
-.\" 2. No rights are granted, in any manner or form, to use Whistle
-.\" Communications, Inc. trademarks, including the mark "WHISTLE
-.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
-.\" such appears in the above copyright notice or in the software.
-.\"
-.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
-.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
-.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
-.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
-.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
-.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
-.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
-.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
-.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
-.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
-.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
-.\" OF SUCH DAMAGE.
-.\"
-.\" Author: Archie Cobbs <archie@whistle.com>
-.\"
-.\" $FreeBSD$
-.\" $Whistle: ng_tty.8,v 1.5 1999/01/25 23:46:28 archie Exp $
-.\"
-.Dd January 19, 1999
-.Dt NG_TTY 8
-.Os FreeBSD
-.Sh NAME
-.Nm ng_tty
-.Nd netgraph node type that is also a line discipline
-.Sh SYNOPSIS
-.Fd #include <sys/ttycom.h>
-.Fd #include <netgraph/ng_message.h>
-.Fd #include <netgraph/ng_tty.h>
-.Sh DESCRIPTION
-The
-.Nm tty
-node type is both a netgraph node type and a line discipline.
-A new node is created when the corresponding line discipline,
-.Dv NETGRAPHDISC ,
-is registered on a tty device (see
-.Xr tty 4 ) .
-.Pp
-The node has a single hook called
-.Dv hook .
-Incoming bytes received on the tty device are sent out on this hook,
-and frames received on
-.Dv hook
-are transmitted out on the tty device.
-No modification to the data is performed in either direction.
-While the line discipline is installed on a tty, the normal
-read and write operations are unavailable, returning
-.Er EIO .
-.Pp
-The node supports an optional
-.Dq hot character .
-If set to non-zero, incoming
-data from the tty device is queued until this character is seen.
-This avoids sending lots of mbufs containing a small number of bytes,
-but introduces potentially infinite latency.
-The default hot character is 0x7e, consistent with
-.Dv hook
-being connected to a
-.Xr ng_async 8
-type node. The hot character has no effect on the transmission of data.
-.Pp
-The node will attempt to give itself the same netgraph name as the name
-of the tty device.
-In any case, information about the node is available via the netgraph
-.Xr ioctl 2
-command
-.Dv NGIOCGINFO .
-This command returns a
-.Dv "struct nodeinfo"
-similar to the
-.Dv NGM_NODEINFO
-netgraph control message.
-.Sh HOOKS
-This node type supports the following hooks:
-.Pp
-.Bl -tag -width foobar
-.It Dv hook
-.Xr tty 4
-serial data contained in
-.Dv mbuf
-structures, with arbitrary inter-frame boundaries.
-.El
-.Sh CONTROL MESSAGES
-This node type supports the generic control messages, plus the following:
-.Bl -tag -width foo
-.It Dv NGM_TTY_SET_HOTCHAR
-This command takes an integer argument and sets the hot character
-from the lower 8 bits. A hot character of zero disables queueing,
-so that all received data is forwarded immediately.
-.It Dv NGM_TTY_GET_HOTCHAR
-Returns an integer containing the current hot character in the lower
-eight bits.
-.Sh SHUTDOWN
-This node shuts down when the corresponding device is closed
-(or the line discipline is uninstalled on the device).
-The
-.Dv NGM_SHUTDOWN
-control message is not valid, and always returns the error
-.Er EOPNOTSUPP .
-.Sh BUGS
-The serial driver code also has a notion of a
-.Dq hot character .
-Unfortunately, this value is statically defined in terms of the
-line discipline and cannot be changed.
-Therefore, if a hot character other than 0x7e (the default) is set for the
-.Nm
-node, the node has no way to convey this information to the
-serial driver, and sub-optimal performance may result.
-.Sh SEE ALSO
-.Xr ioctl 2 ,
-.Xr netgraph 4 ,
-.Xr tty 4 ,
-.Xr ng_async 8 ,
-.Xr ngctl 8 .
-.Sh HISTORY
-The
-.Nm
-node type was implemented in
-.Fx 4.0 .
-.Sh AUTHORS
-.An Archie Cobbs Aq archie@whistle.com
diff --git a/share/man/man4/ng_vjc.4 b/share/man/man4/ng_vjc.4
deleted file mode 100644
index 618489fdd501..000000000000
--- a/share/man/man4/ng_vjc.4
+++ /dev/null
@@ -1,223 +0,0 @@
-.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
-.\" All rights reserved.
-.\"
-.\" Subject to the following obligations and disclaimer of warranty, use and
-.\" redistribution of this software, in source or object code forms, with or
-.\" without modifications are expressly permitted by Whistle Communications;
-.\" provided, however, that:
-.\" 1. Any and all reproductions of the source or object code must include the
-.\" copyright notice above and the following disclaimer of warranties; and
-.\" 2. No rights are granted, in any manner or form, to use Whistle
-.\" Communications, Inc. trademarks, including the mark "WHISTLE
-.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
-.\" such appears in the above copyright notice or in the software.
-.\"
-.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
-.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
-.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
-.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
-.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
-.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
-.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
-.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
-.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
-.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
-.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
-.\" OF SUCH DAMAGE.
-.\"
-.\" Author: Archie Cobbs <archie@whistle.com>
-.\"
-.\" $FreeBSD$
-.\" $Whistle: ng_vjc.8,v 1.4 1999/01/25 23:46:28 archie Exp $
-.\"
-.Dd January 19, 1999
-.Dt NG_VJC 8
-.Os FreeBSD
-.Sh NAME
-.Nm ng_vjc
-.Nd Van Jacobsen compression netgraph node type
-.Sh SYNOPSIS
-.Fd #include <net/slcompress.h>
-.Fd #include <netgraph/ng_vjc.h>
-.Sh DESCRIPTION
-The
-.Nm vjc
-node type performs Van Jacobsen compression, which is used
-over PPP, SLIP, and other point-to-point IP connections to
-compress TCP packet headers. The
-.Dv ip
-hook represents the uncompressed side of the node, while the
-.Dv vjcomp ,
-.Dv vjuncomp ,
-and
-.Dv vjip
-hooks represent the compressed side of the node. Packets received on the
-.Dv ip
-will be compressed or passed through as appropriate. Packets received
-on the other three hooks will be uncompressed as appropriate.
-This node also supports
-.Dq always pass through
-mode in either direction.
-.Pp
-Van Jacobsen compression only applies to TCP packets.
-Only
-.Dq normal
-(i.e., common case) TCP packets are actually compressed.
-These are output on the
-.Dv vjcomp
-hook. Other TCP packets are run through the state machine but not
-compressed; these appear on the
-.Dv vjuncomp
-hook.
-Other non-TCP IP packets are forwarded unchanged to
-.Dv vjip .
-.Pp
-When connecting to a
-.Xr ng_ppp 8
-node, the
-.Dv ip ,
-.Dv vjuncomp ,
-.Dv vjcomp ,
-and
-.Dv vjip
-hooks should be connected to the
-.Xr ng_ppp 8
-node's
-.Dv vjc_ip ,
-.Dv vjc_vjcomp ,
-.Dv vjc_vjuncomp ,
-and
-.Dv vjc_ip
-hooks, respectively.
-.Sh HOOKS
-This node type supports the following hooks:
-.Pp
-.Bl -tag -width foobarbazi
-.It Dv ip
-Upstream (uncompressed) IP packets.
-.It Dv vjcomp
-Downstream compressed TCP packets.
-.It Dv vjuncomp
-Downstream uncompressed TCP packets.
-.It Dv vjip
-Downstream uncompressed IP packets.
-.Sh CONTROL MESSAGES
-This node type supports the generic control messages, plus the following:
-.Bl -tag -width foo
-.It Dv NGM_VJC_SET_CONFIG
-This command resets the compression state and configures it according
-to the supplied
-.Dv "struct ngm_vjc_config"
-argument. This structure contains the following fields:
-.Bd -literal -offset 4n
-struct ngm_vjc_config {
- u_char enableComp; /* Enable compression */
- u_char enableDecomp; /* Enable decompression */
- u_char maxChannel; /* Number of outgoing channels - 1 */
- u_char compressCID; /* OK to compress outgoing CID's */
-};
-.Ed
-.Pp
-When
-.Dv enableComp
-is set to zero, all packets received on the
-.Dv ip
-hook are forwarded unchanged out the
-.Dv vjip
-hook. Similarly, when
-.Dv enableDecomp
-is set to zero, all packets received on the
-.Dv vjip
-hook are forwarded unchanged out the
-.Dv ip
-hook, and packets are not accepted on the
-.Dv vjcomp
-and
-.Dv vjuncomp
-hooks.
-When a node is first created,
-both compression and decompression are disabled and the node is
-therefore operating in bi-directional
-.Dq pass through
-mode.
-.Pp
-When enabling compression,
-.Dv maxChannel
-should be set to the number of outgoing compression channels minus one,
-and is a value between 3 and 15, inclusive. The
-.Dv compressCID
-field indicates whether it is OK to compress the CID header field for
-outgoing compressed TCP packets. This value should be zero unless
-either (a) it is not possible for an outgoing frame to be lost, or
-(b) lost frames can be reliably detected and immediately
-reported to the peer's decompression engine (see
-.Dv NGM_VJC_RECV_ERROR
-below).
-.It Dv NGM_VJC_GET_STATE
-This command returns the node's current state described by the
-.Dv "struct slcompress"
-structure, which is defined in
-.Pa net/slcompress.h .
-.It Dv NGM_VJC_CLR_STATS
-Clears the node statistics counters. Statistics are also cleared whenever the
-.Dv enableComp
-or
-.Dv enableDecomp
-fields are changed from zero to one by a
-.Dv NGM_VJC_SET_CONFIG
-control message.
-.It Dv NGM_VJC_RECV_ERROR
-When the peer has CID header field compression enabled,
-this message must be sent to the local
-.Nm vjc
-node immediately
-after detecting that a received frame has been lost, due to a bad
-checksum or for any other reason. Failing to do this can result
-in corrupted TCP stream data.
-.Sh SHUTDOWN
-This node shuts down upon receipt of a
-.Dv NGM_SHUTDOWN
-control message, or when all hooks have been disconnected.
-.Sh BUGS
-Because the initialization routine in the kernel implementation of
-Van Jacobsen compression initializes both compression and decompression
-at once, this node does not allow compression and decompression to
-be enabled in separate operations. In order to enable one when
-the other is already enabled, first both must be disabled, then
-both enabled. This of course resets the node state. This restriction
-may be lifted in a later version.
-.Pp
-When built as a loadable kernel module, this module includes the file
-.Pa net/slcompress.c .
-Although loading the module should fail if
-.Pa net/slcompress.c
-already exists in the kernel, currently it does not, and the duplicate
-copies of the file do not interfere.
-However, this may change in the future.
-.Sh SEE ALSO
-.Xr netgraph 4 ,
-.Xr ng_ppp 8 ,
-.Xr ng_iface 8 ,
-.Xr ngctl 8 .
-.Rs
-.%A V. Jacobsen
-.%T "Compressing TCP/IP Headers"
-.%O RFC 1144
-.Re
-.Rs
-.%A G. McGregor
-.%T "The PPP Internet Control Protocol (IPCP)"
-.%O RFC 1332
-.Re
-.Sh HISTORY
-The
-.Nm
-node type was implemented in
-.Fx 4.0 .
-.Sh AUTHORS
-.An Archie Cobbs Aq archie@whistle.com
diff --git a/share/man/man4/snd_csa.4 b/share/man/man4/snd_csa.4
deleted file mode 100644
index dfb60f57a387..000000000000
--- a/share/man/man4/snd_csa.4
+++ /dev/null
@@ -1,63 +0,0 @@
-.\"
-.\" Copyright (c) 1999 Seigo Tanimura
-.\" 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 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd December 18, 1999
-.Dt CSA 4
-.Os FreeBSD
-.Sh NAME
-.Nm csa
-.Nd Crystal Semiconductor CS461x/462x/428x PCI bridge device driver
-.Sh SYNOPSIS
-.Cd "device csa"
-.Sh DESCRIPTION
-The
-.Nm
-bridge driver allows the generic audio drivers including
-.Xr pcm 4
-to attach to the following PCI sound cards:
-.Bl -bullet -tag -width 2m indent
-.It
-Crystal Semiconductor CS461x/462x Audio Accelerator
-.It
-Crystal Semiconductor CS428x Audio Controller
-.El
-.Pp
-Some onboard CS4610 chips accompany with not CS4297 AC97
-codec but CS423x ISA codec.
-Such the configuration is not
-sypported by
-.Nm
-yet.
-.Sh HISTORY
-The
-.Nm
-device driver first appeared in
-.Fx 4.0 .
-.Sh SEE ALSO
-.Xr pcm 4
-.Sh AUTHOR
-.An Seigo Tanimura Aq tanimura@r.dl.itc.u-tokyo.ac.jp
diff --git a/share/man/man4/snd_gusc.4 b/share/man/man4/snd_gusc.4
deleted file mode 100644
index f8504e693a21..000000000000
--- a/share/man/man4/snd_gusc.4
+++ /dev/null
@@ -1,74 +0,0 @@
-.\"
-.\" Copyright (c) 1999 Seigo Tanimura
-.\" 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 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd December 18, 1999
-.Dt GUSC 4
-.Os FreeBSD
-.Sh NAME
-.Nm gusc
-.Nd Gravis UltraSound ISA bridge device driver
-.Sh SYNOPSIS
-For PnP cards:
-.Cd "device gusc"
-.Pp
-For non-PnP cards:
-.Cd "device gusc0 at isa? port 0x220 irq 5 drq 1 flags 0x13"
-.Sh DESCRIPTION
-The
-.Nm
-bridge driver allows the generic audio drivers including
-.Xr pcm 4
-to attach to the following ISA sound cards:
-.Bl -bullet -tag -width 2m indent
-.It
-Gravis UltraSound PnP
-.It
-Gravis UltraSound MAX
-.El
-.Pp
-The value of flags specifies the secondary DMA channel.
-If the secondary
-DMA channel is C, set the flags to (C | 0x10). For a sound card without the
-secondary DMA channel, the flags should be set to zero.
-.Sh DIAGNOSTICS
-.Bl -tag -width 2m % begin list
-.It xxx: gus pcm not attached, out of memory
-.Pp
-There are not enough memory to drive the device.
-.El
-.Sh HISTORY
-The
-.Nm
-device driver first appeared in
-.Fx 4.0 .
-.Sh SEE ALSO
-.Xr pcm 4
-.Sh AUTHORS
-.An Ville-Pertti Keinonen Aq will@iki.fi
-.An Seigo Tanimura Aq tanimura@r.dl.itc.u-tokyo.ac.jp
-.Sh BUGS
-Recording pcm sound data is not supported yet.
diff --git a/share/man/man4/snd_sbc.4 b/share/man/man4/snd_sbc.4
deleted file mode 100644
index 1e3f2159f95e..000000000000
--- a/share/man/man4/snd_sbc.4
+++ /dev/null
@@ -1,77 +0,0 @@
-.\"
-.\" Copyright (c) 1999 Seigo Tanimura
-.\" 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 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd December 18, 1999
-.Dt SBC 4
-.Os FreeBSD
-.Sh NAME
-.Nm sbc
-.Nd Creative Sound Blaster ISA and compatible bridge device driver
-.Sh SYNOPSIS
-For PnP cards:
-.Cd "device sbc"
-.Pp
-For non-PnP cards:
-.Cd "device sbc0 at isa? port 0x220 irq 5 drq 1 flags 0x15"
-.Sh DESCRIPTION
-The
-.Nm
-bridge driver allows the generic audio drivers including
-.Xr pcm 4
-to attach to the following ISA sound cards:
-.Bl -bullet -tag -width 2m indent
-.It
-Creative SB16, SB32, SB AWE64 (including Gold) and ViBRA16
-.It
-Advance Asound 100, 110 and Logic ALS120
-.It
-ESS ES1868, ES1869, ES1879 and ES1888
-.El
-.Pp
-The value of flags specifies the secondary DMA channel.
-If the secondary
-DMA channel is C, set the flags to (C | 0x10). For a sound card without the
-secondary DMA channel, the flags should be set to zero.
-.Sh DIAGNOSTICS
-.Bl -tag -width 2m % begin list
-.It sb_dspwr(XX) timed out.
-.Pp
-A command to the DSP has timed out.
-Check the I/O port configuration.
-.It bad irq XX (5/7/9/10 valid)
-.Pp
-The IRQ given to the driver is not valid.
-.El
-.Sh HISTORY
-The
-.Nm
-device driver first appeared in
-.Fx 4.0 .
-.Sh SEE ALSO
-.Xr pcm 4
-.Sh AUTHOR
-.An Seigo Tanimura Aq tanimura@r.dl.itc.u-tokyo.ac.jp
diff --git a/share/man/man4/spkr.4 b/share/man/man4/spkr.4
deleted file mode 100644
index 71c24f0e841e..000000000000
--- a/share/man/man4/spkr.4
+++ /dev/null
@@ -1,237 +0,0 @@
-.\"
-.\" $FreeBSD$
-.\"
-.Dd November 7, 1993
-.Dt SPKR 4 i386
-.Os FreeBSD
-.Sh NAME
-.Nm speaker ,
-.Nm spkr
-.Nd console speaker device driver
-.Sh SYNOPSIS
-.Cd pseudo-device speaker
-.Fd #include <machine/speaker.h>
-.Sh DESCRIPTION
-The speaker device driver allows applications to control the PC console
-speaker on an
-.Tn IBM-PC Ns --compatible
-machine running
-.Tn FreeBSD .
-.Pp
-Only one process may have this device open at any given time;
-.Xr open 2
-and
-.Xr close 2
-are used to lock and relinquish it.
-An attempt to open when
-another process has the device locked will return -1 with an
-.Er EBUSY
-error
-indication.
-Writes to the device are interpreted as `play strings' in a
-simple ASCII melody notation.
-An
-.Xr ioctl 2
-request
-for tone generation at arbitrary
-frequencies is also supported.
-.Pp
-Sound-generation does not monopolize the processor; in fact, the driver
-spends most of its time sleeping while the PC hardware is emitting
-tones.
-Other processes may emit beeps while the driver is running.
-.Pp
-Applications may call
-.Xr ioctl 2
-on a speaker file descriptor to control the
-speaker driver directly; definitions for the
-.Xr ioctl 2
-interface are in
-.Pa /usr/include/machine/speaker.h .
-The
-.Li tone_t
-structure used in these calls has two fields,
-specifying a frequency (in Hz) and a duration (in 1/100ths of a second).
-A frequency of zero is interpreted as a rest.
-.Pp
-At present there are two such
-.Xr ioctl 2
-calls.
-.Dv SPKRTONE
-accepts a pointer to a
-single tone structure as third argument and plays it.
-.Dv SPKRTUNE
-accepts a
-pointer to the first of an array of tone structures and plays them in
-continuous sequence; this array must be terminated by a final member with
-a zero duration.
-.Pp
-The play-string language is modelled on the PLAY statement conventions of
-.Tn IBM
-Advanced BASIC 2.0. The
-.Li MB ,
-.Li MF ,
-and
-.Li X
-primitives of PLAY are not
-useful in a timesharing environment and are omitted.
-The `octave-tracking'
-feature and the slur mark are new.
-.Pp
-There are 84 accessible notes numbered 1-84 in 7 octaves, each running from
-C to B, numbered 0-6; the scale is equal-tempered A440 and octave 3 starts
-with middle C. By default, the play function emits half-second notes with the
-last 1/16th second being `rest time'.
-.Pp
-Play strings are interpreted left to right as a series of play command groups;
-letter case is ignored.
-Play command groups are as follows:
-.Bl -tag -width CDEFGABxx
-.It Li CDEFGAB
-Letters A through G cause the corresponding note to be played in the
-current octave. A note letter may optionally be followed by an
-.Dq Em "accidental sign" ,
-one of # + or -; the first two of these cause it to be sharped one
-half-tone, the last causes it to be flatted one half-tone. It may
-also be followed by a time value number and by sustain dots (see
-below). Time values are interpreted as for the L command below.
-.It Ns Li O Sy n
-If
-.Sy n
-is numeric, this sets the current octave.
-.Sy n
-may also be one of
-.Li L
-or
-.Li N
-to enable or disable octave-tracking (it is disabled by default).
-When octave-tracking is on, interpretation of a pair of letter notes
-will change octaves if necessary in order to make the smallest
-possible jump between notes.
-Thus ``olbc'' will be played as
-``olb>c'', and ``olcb'' as ``olc<b''. Octave locking is disabled for
-one letter note following >, < and O[0123456]. (The octave-locking
-feature is not supported in
-.Tn IBM
-BASIC.)
-.It Li >
-Bump the current octave up one.
-.It Li <
-Drop the current octave down one.
-.It Ns Li N Sy n
-Play note
-.Sy n ,
-.Sy n
-being 1 to 84 or 0 for a rest of current time value.
-May be followed by sustain dots.
-.It Ns Li L Sy n
-Sets the current time value for notes. The default is
-.Li L4 ,
-quarter or crotchet notes.
-The lowest possible value is 1; values up
-to 64 are accepted.
-.Li L1
-sets whole notes,
-.Li L2
-sets half notes,
-.Li L4
-sets quarter notes, etc.
-.It Ns Li P Sy n
-Pause (rest), with
-.Sy n
-interpreted as for
-.Ns Li L Sy n .
-May be followed by
-sustain dots. May also be written
-.Li ~ .
-.It Ns Li T Sy n
-Sets the number of quarter notes per minute; default is 120. Musical
-names for common tempi are:
-
-.Bd -literal -offset indent
- Tempo Beats Per Minute
-very slow Larghissimo
- Largo 40-60
- Larghetto 60-66
- Grave
- Lento
- Adagio 66-76
-slow Adagietto
- Andante 76-108
-medium Andantino
- Moderato 108-120
-fast Allegretto
- Allegro 120-168
- Vivace
- Veloce
- Presto 168-208
-very fast Prestissimo
-.Ed
-.It Li M[LNS]
-Set articulation.
-.Li MN
-.Ns No ( Li N
-for normal) is the default; the last 1/8th of
-the note's value is rest time.
-You can set
-.Li ML
-for legato (no rest space) or
-.Li MS
-for staccato (1/4 rest space).
-.El
-.Pp
-Notes (that is,
-.Li CDEFGAB
-or
-.Li N
-command character groups) may be followed by
-sustain dots.
-Each dot causes the note's value to be lengthened by one-half
-for each one.
-Thus, a note dotted once is held for 3/2 of its undotted value;
-dotted twice, it is held 9/4, and three times would give 27/8.
-.Pp
-A note and its sustain dots may also be followed by a slur mark (underscore).
-This causes the normal micro-rest after the note to be filled in, slurring it
-to the next one. (The slur feature is not supported in
-.Tn IBM
-BASIC.)
-.Pp
-Whitespace in play strings is simply skipped and may be used to separate
-melody sections.
-.Sh BUGS
-Due to roundoff in the pitch tables and slop in the tone-generation and timer
-hardware (neither of which was designed for precision), neither pitch accuracy
-nor timings will be mathematically exact.
-There is no volume control.
-.Pp
-The action of two or more sustain dots does not reflect standard musical
-notation, in which each dot adds half the value of the previous dot
-modifier, not half the value of the note as modified. Thus, a note dotted
-once is held for 3/2 of its undotted value; dotted twice, it is held 7/4,
-and three times would give 15/8. The multiply-by-3/2 interpretation,
-however, is specified in the
-.Tn IBM
-BASIC manual and has been retained for
-compatibility.
-.Pp
-In play strings which are very long (longer than your system's physical I/O
-blocks) note suffixes or numbers may occasionally be parsed incorrectly due
-to crossing a block boundary.
-.Sh FILES
-.Bl -tag -width /dev/speakerxx
-.It Pa /dev/speaker
-speaker device file
-.El
-.Sh SEE ALSO
-.Xr spkrtest 8
-.Sh AUTHORS
-.An Eric S. Raymond Aq esr@snark.thyrsus.com
-June 1990
-.Sh "PORTED BY"
-.An Andrew A. Chernov Aq ache@astral.msk.su
-.Sh HISTORY
-The
-.Nm
-device appeared in
-.Fx 1.0 .
diff --git a/share/man/man4/sym.4 b/share/man/man4/sym.4
deleted file mode 100644
index 99ca5225cdea..000000000000
--- a/share/man/man4/sym.4
+++ /dev/null
@@ -1,270 +0,0 @@
-.\"
-.\" Device driver optimized for the Symbios/LSI 53C896/53C895A/53C1010
-.\" PCI-SCSI controllers.
-.\"
-.\" Copyright (C) 1999-2000 Gerard Roudier <groudier@club-internet.fr>
-.\"
-.\" This driver also supports the following Symbios/LSI PCI-SCSI chips:
-.\" 53C810A, 53C825A, 53C860, 53C875, 53C876, 53C885, 53C895.
-.\"
-.\" but does not support earlier chips as the following ones:
-.\" 53C810, 53C815, 53C825.
-.\"
-.\" This driver for FreeBSD-CAM is derived from the Linux sym53c8xx driver.
-.\" Copyright (C) 1998-1999 Gerard Roudier
-.\"
-.\" The sym53c8xx driver is derived from the ncr53c8xx driver that had been
-.\" a port of the FreeBSD ncr driver to Linux-1.2.13.
-.\"
-.\" The original ncr driver has been written for 386bsd and FreeBSD by
-.\" Wolfgang Stanglmeier <wolf@cologne.de>
-.\" Stefan Esser <se@mi.Uni-Koeln.de>
-.\" Copyright (C) 1994 Wolfgang Stanglmeier
-.\"
-.\" The initialization code, and part of the code that addresses
-.\" FreeBSD-CAM services is based on the aic7xxx driver for FreeBSD-CAM
-.\" written by Justin T. Gibbs.
-.\"
-.\" Other major contributions:
-.\"
-.\" NVRAM detection and reading.
-.\" Copyright (C) 1997 Richard Waltham <dormouse@farsrobt.demon.co.uk>
-.\"
-.\" ----------------------------------------------------------------------------
-.\"
-.\" 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 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd January 12, 2000
-.Dt SYM 4 i386
-.Os FreeBSD
-.Sh NAME
-.Nm sym
-.Nd Symbios/LSI Logic PCI-SCSI host adapter driver
-.Sh SYNOPSIS
-For any number of cards:
-.Cd device sym
-.Pp
-To disable PCI parity checking (needed for broken bridges)
-.Cd options SYM_SETUP_PCI_PARITY=<boolean>
-.Pp
-To control driver probing against HVD buses
-.Cd options SYM_SETUP_SCSI_DIFF=<bit combination>
-.Pp
-To control chip attachment balancing between the ncr driver and this driver
-.Cd options SYM_SETUP_LP_PROBE_MAP=<bit combination>
-.Sh DESCRIPTION
-This driver provides support for the Symbios/LSI Logic
-.Tn 53C810A,
-.Tn 53C825A,
-.Tn 53C860,
-.Tn 53C875,
-.Tn 53C876,
-.Tn 53C895,
-.Tn 53C895A,
-.Tn 53C896,
-.Tn 53C897,
-.Tn 53C1510D,
-and
-.Tn 53C1010
-PCI-SCSI controllers.
-.Pp
-Driver features include support for wide SCSI busses, fast10, fast20,
-fast40 and fast80-dt synchronous data transfers depending on controller
-capabilities.
-It also provides generic SCSI features as tagged command
-queuing and auto-request sense.
-This driver is configured by default
-for a maximum of 446 outstanding commands per bus, 8 LUNs per target
-and 64 tagged tasks per LUN.
-These numbers are not so limited by design,
-as have been considered reasonable values for current SCSI technology.
-These values can be increased by changing appropriate
-constants in driver header files (not recommended).
-.Pp
-This driver requires the PCI-SCSI chip to implement LOAD/STORE SCRIPTS
-instructions and therefore it does not provide support for 53C810 revid < 16,
-53C825 revid < 16 and all 53C815 revisions.
-The generic
-.Nm ncr
-driver can be used to support these early chips.
-.Pp
-By default, when both the
-.Nm ncr
-and
-.Nm
-drivers are configured, the
-.Nm
-driver takes precedence over the
-.Nm ncr
-driver for all chips that are supported by
-both drivers.
-As result, the
-.Nm ncr
-driver does only attach the 53C8XX
-chips that donnot support LOAD/STORE (i.e.: 53C810, 53C815 and 53C825).
-User can change the balancing of chip types between drivers by defining
-the
-.Ar SYM_SETUP_LP_PROBE_MAP
-kernel configuration option as follows:
-.Bl -column "Bit " "53C8XXA, 53C8XX, 53C8XX, 53C8XX, 53C8XX, 53C8XX"
-.Em Bit Devices attached by ncr instead
-1 53C810a, 53C860
-2 53C825a, 53C875, 53C876, 53C885, 53C895
-4 53C895a, 53C896, 53C897, 53C1510d
-.El
-.Ed
-.Pp
-For example, if
-.Ar SYM_SETUP_LP_PROBE_MAP
-is supplied with value 7, all the
-above chips will be attached by the
-.Nm ncr
-driver and the
-.Nm
-driver will only
-attach the 53C1010 Ultra-3 controllers.
-.Pp
-HVD/LVD capable controllers (895, 895A, 896, 897 and 1010) report
-the actual bus mode from the STEST4 chip IO registers.
-This feature
-allows to safely probe against bus mode and to set up the chip
-accordingly.
-By default the driver only supports HVD for these chips.
-For other chips that can support HVD but not LVD, the driver has to probe
-implementation dependent registers (GPIO) in order to detect HVD bus mode.
-Only HVD implementations that conform with Symbios Logic recommendation can
-be detected by the driver.
-When the
-.Ar SYM_SETUP_SCSI_DIFF
-kernel is provided
-as value 1, the driver will also probe against HVD for 825a, 875, 876 and
-885 chips, assuming Symbios Logic compatible implementation of HVD.
-.Pp
-When supplied as 0, the
-.Ar SYM_SETUP_PCI_PARITY
-kernel configuration option
-indicates the driver not to enable PCI parity checking.
-PCI parity
-checking should not be an option for PCI-SCSI controllers, but some
-systems have been reported to fail using 53C8XX chips due to spurious or
-permanent PCI parity errors detected.
-This option is supplied for
-convenience but it is not recommended nor supported.
-.Pp
-This driver offers other options that are not currently exported to user.
-They are defined and documented in the sym_conf.h driver file.
-It is not
-recommended to change these options unless absolute need.
-Some of these
-options are planned to be exported through SYSCTL or equivalent mechanism
-in a further driver release and therefore, no compatibility is guaranteed.
-.Pp
-At initialization, the driver tries to detect and read user settings from
-controller NVRAM.
-The Symbios/Logic NVRAM layout and the Tekram NVRAM
-layout are currently supported.
-If the reading of the NVRAM succeeds, the
-following settings are taken into account and reported to CAM:
-.Pp
-.Bl -column "SCSI parity checking " "Symbios " "Tekram"
-.Em Host settings Symbios Tekram
-SCSI parity checking Y N
-Host SCSI ident Y Y
-Verbose messages Y N
-Scan targets hi-lo Y N
-Avoid SCSI bus reset Y N
-.Pp
-.El
-.Bl -column "Synchronous period " "Symbios " "Tekram"
-.Em Device settings Symbios Tekram
-Synchronous period Y Y
-SCSI bus width Y Y
-Queue tag enable Y Y
-Number of tags NA Y
-Disconnect enable Y Y
-Scan at boot time Y N
-Scan LUN Y N
-.El
-.Pp
-Devices that are configured as disabled for 'scan' in the NVRAM are not
-reported to CAM at system start-up.
-They can be discovered later using
-the
-.Nm camcontrol rescan
-command.
-.Pp
-The table below summarizes the main features and capabilities of the
-NCR/Symbios/LSI Logic 53C8XX family of PCI-SCSI controllers.
-.Pp
-.Bl -column sym53c1510d "Sync " "Width " "SRAM " "PCI64"
-.Em Chip Sync Width SRAM PCI64 Supported
-sym53c810 10MHz 8Bit N N N
-sym53c810a 10MHz 8Bit N N Y
-sym53c815 10MHz 8Bit N N N
-sym53c825 10MHz 16Bit N N N
-sym53c825a 10MHz 16Bit 4KB N Y
-sym53c860 20MHz 8Bit N N Y
-sym53c875 20MHz 16Bit 4KB N Y
-sym53c876 20MHz 16Bit 4KB N Y
-sym53c885 20MHz 16Bit 4KB N Y
-sym53c895 40MHz 16Bit 4KB N Y
-sym53c895A 40MHz 16Bit 8KB N Y
-sym53c896 40MHz 16Bit 8KB Y Y
-sym53c897 40MHz 16Bit 8KB Y Y
-sym53c1510D 40MHz 16Bit 4KB Y Y
-sym53c1010 80MHz 16Bit 8KB Y Y
-.El
-.Pp
-.Sh BUGS
-No known bugs.
-.Sh SEE ALSO
-.Xr cd 4 ,
-.Xr da 4 ,
-.Xr ncr 4 ,
-.Xr sa 4 ,
-.Xr scsi 4 ,
-.Xr camcontrol 8
-.Sh AUTHORS
-The
-.Nm
-driver has been written by Gerard Roudier and is derived from the
-Linux sym53c8xx driver from the same author.
-The sym53c8xx driver is derived from the ncr53c8xx driver that had been
-a port of the
-.Fx
-.Nm ncr
-driver to Linux-1.2.13.
-The original
-.Nm ncr
-driver was written for 386BSD and
-.Fx
-by Wolfgang Stanglmeier and Stefan Esser.
-.Sh HISTORY
-The
-.Nm
-driver appeared in
-.Fx 4.0 .
-
diff --git a/share/man/man4/tx.4 b/share/man/man4/tx.4
deleted file mode 100644
index 9496be43d521..000000000000
--- a/share/man/man4/tx.4
+++ /dev/null
@@ -1,92 +0,0 @@
-.\"
-.\" Copyright (c) 1998 Semen Ustimenko
-.\"
-.\" 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 DEVELOPERS ``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 DEVELOPERS 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd January 28, 1997
-.Dt TX 4 i386
-.Os FreeBSD
-.Sh NAME
-.Nm tx
-.Nd
-SMC9432TX Fast Ethernet device driver
-.Sh SYNOPSIS
-.Cd "device tx"
-.Sh DESCRIPTION
-The
-.Nm
-driver provides support for the Ethernet adapters based on the
-SMC 83c170 (EPIC) chips.
-.Pp
-The
-.Nm
-driver supports the following media types:
-.Pp
-.Bl -tag -width xxxxxxxxxxxxxxx
-.It autoselect
-Enable autonegotiation (default)
-.It 100baseTX
-Set 100Mbps (fast ethernet) operation
-.It 10baseT/UTP
-Set 10Mbps on 10baseT port
-.El
-.Pp
-The
-.Nm
-driver supports the following media options:
-.Pp
-.Bl -tag -width xxxxxxxxxxxxxxx
-.It full-duplex
-Set full-duplex operation
-.El
-.Pp
-The old ``ifconfig tx0 linkN'' method of configuration is not supported.
-.Sh DIAGNOSTICS
-.Bl -diag
-.It "tx%d: device timeout %d packets"
-The device stops responding.
-Device and driver reset follows this error.
-.It "tx%d: PCI fatal error occured (%s)"
-One of following errors occured: PCI Target Abort, PCI Master Abort, Data
-Parity Error or Address Parity Error.
-Device and driver reset follows this error.
-.It "tx%d: WARNING! no link established"
-No media connected.
-Displayed at startup only.
-.It "tx%d: cannot allocate mbuf header/cluster"
-Cannot allocate memory for received packet.
-Packet thrown away.
-.It "tx%d: can't stop %s DMA"
-While reseting, driver failed to stop device correctly.
-.El
-.Sh BUGS
-.Pp
-The multicast packets filtering is not supported.
-Only one PHY was really tested (Quality Semiconductor QS6612).
-.Sh SEE ALSO
-.Xr arp 4 ,
-.Xr netintro 4 ,
-.Xr ifconfig 8 ,
-.Xr ng_ether 8
diff --git a/share/man/man5/fdescfs.5 b/share/man/man5/fdescfs.5
deleted file mode 100644
index 8493398f1635..000000000000
--- a/share/man/man5/fdescfs.5
+++ /dev/null
@@ -1,150 +0,0 @@
-.\" Copyright (c) 1996
-.\" Mike Pritchard <mpp@FreeBSD.org>. All rights reserved.
-.\"
-.\" Copyright (c) 1992, 1993, 1994
-.\" The Regents of the University of California. All rights reserved.
-.\" All rights reserved.
-.\"
-.\" This code is derived from software donated to Berkeley by
-.\" Jan-Simon Pendry.
-.\"
-.\" 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 the University of
-.\" California, Berkeley and its contributors.
-.\" 4. 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd December 14, 1996
-.Dt FDESC 5
-.Os BSD 4.4
-.Sh NAME
-.Nm fdesc
-.Nd file-descriptor file system
-.Sh SYNOPSIS
-fdesc /dev fdesc rw 0 0
-.Sh DESCRIPTION
-The file-descriptor file system, or
-.Nm fdesc ,
-provides access to the per-process file descriptor
-namespace in the global filesystem namespace.
-The conventional mount point is
-.Pa /dev
-and the filesystem should be union mounted in order to augment,
-rather than replace, the existing entries in
-.Pa /dev .
-.Pp
-The contents of the mount point are
-.Pa fd ,
-.Pa stderr ,
-.Pa stdin ,
-.Pa stdout
-and
-.Pa tty .
-.Pp
-.Pa fd
-is a directory whose contents
-appear as a list of numbered files
-which correspond to the open files of the process reading the
-directory.
-The files
-.Pa /dev/fd/0
-through
-.Pa /dev/fd/#
-refer to file descriptors which can be accessed through the file
-system.
-If the file descriptor is open and the mode the file is being opened
-with is a subset of the mode of the existing descriptor, the call:
-.Bd -literal -offset indent
-fd = open("/dev/fd/0", mode);
-.Ed
-.Pp
-and the call:
-.Bd -literal -offset indent
-fd = fcntl(0, F_DUPFD, 0);
-.Ed
-.Pp
-are equivalent.
-.Pp
-The files
-.Pa /dev/stdin ,
-.Pa /dev/stdout
-and
-.Pa /dev/stderr
-appear as symlinks to the relevant entry in the
-.Pa /dev/fd
-sub-directory.
-Opening them is equivalent to the following calls:
-.Bd -literal -offset indent
-fd = fcntl(STDIN_FILENO, F_DUPFD, 0);
-fd = fcntl(STDOUT_FILENO, F_DUPFD, 0);
-fd = fcntl(STDERR_FILENO, F_DUPFD, 0);
-.Ed
-.Pp
-Flags to the
-.Xr open 2
-call other than
-.Dv O_RDONLY ,
-.Dv O_WRONLY
-and
-.Dv O_RDWR
-are ignored.
-.Pp
-The
-.Pa /dev/tty
-entry is an indirect reference to the current process's controlling terminal.
-It appears as a named pipe (FIFO) but behaves in exactly the same way as
-the real controlling terminal device.
-.Sh FILES
-.Bl -tag -width /dev/stderr -compact
-.It Pa /dev/fd/#
-.It Pa /dev/stdin
-.It Pa /dev/stdout
-.It Pa /dev/stderr
-.It Pa /dev/tty
-.El
-.Sh SEE ALSO
-.Xr tty 4 ,
-.Xr mount_devfs 8 ,
-.Xr mount_fdesc 8
-.Sh HISTORY
-The
-.Nm
-filesystem first appeared in
-.Bx 4.4 .
-The
-.Nm
-manual page first appeared in
-.Fx 2.2 .
-.Sh AUTHORS
-The
-.Nm
-manual page was written by
-.An Mike Pritchard Aq mpp@FreeBSD.org ,
-and was based on the
-.Xr mount_fdesc 8
-manual page written by
-.An Jan-Simon Pendry .
diff --git a/share/man/man8/yp.8 b/share/man/man8/yp.8
deleted file mode 100644
index dda8944bb79e..000000000000
--- a/share/man/man8/yp.8
+++ /dev/null
@@ -1,535 +0,0 @@
-.\" Copyright (c) 1992/3 Theo de Raadt <deraadt@fsa.ca>
-.\" 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.
-.\"
-.\" from: @(#)yp.8 1.0 (deraadt) 4/26/93
-.\" $FreeBSD$
-.\"
-.Dd April 5, 1993
-.Dt YP 4
-.Os BSD 4.2
-.Sh NAME
-.Nm yp
-.Nd description of the YP/NIS system
-.Sh SYNOPSIS
-.Nm yp
-.Sh DESCRIPTION
-The
-.Nm YP
-subsystem allows network management of passwd, group, netgroup, hosts,
-services, rpc, bootparams and ethers file
-entries through the functions
-.Xr getpwent 3 ,
-.Xr getgrent 3 ,
-.Xr getnetgrent 3 ,
-.Xr gethostent 3 ,
-.Xr getnetent 3 ,
-.Xr getrpcent 3 ,
-and
-.Xr ethers 3 .
-The
-.Xr bootparamd 8
-daemon makes direct
-.Tn NIS
-library calls since there are no
-functions in the standard C library for reading bootparams.
-.Tn NIS
-support for the hosts, services and rpc databases is enabled by
-uncommenting the
-.Em nis
-line in
-.Pa /etc/host.conf .
-.Tn NIS
-support for the remaining services is
-activated by adding a special '+' entry to the appropriate file.
-.Pp
-The
-.Nm YP
-subsystem is started automatically in
-.Pa /etc/rc
-if it has been initialized in
-.Pa /etc/rc.conf
-and if the directory
-.Pa /var/yp
-exists (which it does in the default distribution). The default
-.Tn NIS
-domain must also be set with the
-.Xr domainname 1
-command, which will happen automatically at system startup if it is
-specified in
-.Pa /etc/rc.conf .
-.Pp
-.Tn NIS
-is an
-.Tn RPC Ns -based
-client/server system that allows a group of
-machines within an
-.Tn NIS
-domain to share a common set of configuration files.
-This permits a system
-administrator to set up
-.Tn NIS
-client systems with only minimal configuration
-data and add, remove or modify configuration data from a single location.
-.Pp
-The canonical copies of all
-.Tn NIS
-information are stored on a single machine
-called the
-.Em Tn NIS master server .
-The databases used to store the information are called
-.Em Tn NIS maps .
-In
-.Bx Free ,
-these maps are stored in
-.Pa /var/yp/[domainname]
-where
-.Pa [domainname]
-is the name of the
-.Tn NIS
-domain being served.
-A single
-.Tn NIS
-server can
-support several domains at once, therefore it is possible to have several
-such directories, one for each supported domain.
-Each domain will have
-its own independent set of maps.
-.Pp
-In
-.Bx Free ,
-the
-.Tn NIS
-maps are Berkeley DB hashed database files (the
-same format used for the
-.Xr passwd 5
-database files). Other operating systems that support
-.Tn NIS
-use old-style
-ndbm databases instead (largely because Sun Microsystems originally based
-their
-.Tn NIS
-implementation on ndbm, and other vendors have simply licensed
-Sun's code rather than design their own implementation with a different
-database format). On these systems, the databases are generally split
-into
-.Em .dir
-and
-.Em .pag
-files which the ndbm code uses to hold separate parts of the hash
-database.
-The Berkeley DB hash method instead uses a single file for
-both pieces of information.
-This means that while you may have
-.Pa passwd.byname.dir
-and
-.Pa passwd.byname.pag
-files on other operating systems (both of which are really parts of the
-same map),
-.Bx Free
-will have only one file called
-.Pa passwd.byname .
-The difference in format is not significant: only the
-.Tn NIS
-server,
-.Xr ypserv 8 ,
-and related tools need to know the database format of the
-.Tn NIS
-maps.
-Client
-.Tn NIS
-systems receive all
-.Tn NIS
-data in
-.Tn ASCII
-form.
-.Pp
-There are three main types of
-.Tn NIS
-systems:
-.Bl -enum -offset indent
-.It
-.Pa Tn NIS clients ,
-which query
-.Tn NIS
-servers for information.
-.It
-.Pa Tn NIS master servers ,
-which maintain the canonical copies of all
-.Tn NIS
-maps.
-.It
-.Pa Tn NIS slave servers ,
-which maintain backup copies of
-.Tn NIS
-maps that are periodically
-updated by the master.
-.El
-.Pp
-An
-.Tn NIS
-client establishes what is called a
-.Em binding
-to a particular
-.Tn NIS
-server using the
-.Xr ypbind 8
-daemon.
-.Xr Ypbind 8
-checks the system's default domain (as set by the
-.Xr domainname 1
-command) and begins broadcasting
-.Tn RPC
-requests on the local network.
-These requests specify the name of the domain for which
-.Xr ypbind 8
-is attempting to establish a binding.
-If a server that has been
-configured to serve the requested domain receives one of the broadcasts,
-it will respond to
-.Xr ypbind 8 ,
-which will record the server's address.
-If there are several servers
-available (a master and several slaves, for example),
-.Xr ypbind 8
-will use the address of the first one to respond.
-From that point
-on, the client system will direct all of its
-.Tn NIS
-requests to that server.
-.Xr Ypbind 8
-will occasionally ``ping'' the server to make sure it's still up
-and running.
-If it fails to receive a reply to one of its pings
-within a reasonable amount of time,
-.Xr ypbind 8
-will mark the domain as unbound and begin broadcasting again in the
-hopes of locating another server.
-.Pp
-.Tn NIS
-master and slave servers handle all
-.Tn NIS
-requests with the
-.Xr ypserv 8
-daemon.
-.Xr Ypserv 8
-is responsible for receiving incoming requests from
-.Tn NIS
-clients,
-translating the requested domain and map name to a path to the
-corresponding database file and transmitting data from the database
-back to the client.
-There is a specific set of requests that
-.Xr ypserv 8
-is designed to handle, most of which are implemented as functions
-within the standard C library:
-.Bl -bullet -offset indent
-.It
-.Fn yp_order
--- check the creation date of a particular map
-.It
-.Fn yp_master
--- obtain the name of the
-.Tn NIS
-master server for a given
-map/domain
-.It
-.Fn yp_match
--- lookup the data corresponding to a given in key in a particular
-map/domain
-.It
-.Fn yp_first
--- obtain the first key/data pair in a particular map/domain
-.It
-.Fn yp_next
--- pass
-.Xr ypserv 8
-a key in a particular map/domain and have it return the
-key/data pair immediately following it (the functions
-.Fn yp_first
-and
-.Fn yp_next
-can be used to do a sequential search of an
-.Tn NIS
-map)
-.It
-.Fn yp_all
--- retrieve the entire contents of a map
-.El
-.Pp
-There are a few other requests which
-.Xr ypserv 8
-is capable of handling (i.e. acknowledge whether or not you can handle
-a particular domain (YPPROC_DOMAIN), or acknowledge only if you can
-handle the domain and be silent otherwise (YPPROC_DOMAIN_NONACK)) but
-these requests are usually generated only by
-.Xr ypbind 8
-and are not meant to be used by standard utilities.
-.Pp
-On networks with a large number of hosts, it is often a good idea to
-use a master server and several slaves rather than just a single master
-server.
-A slave server provides the exact same information as a master
-server: whenever the maps on the master server are updated, the new
-data should be propagated to the slave systems using the
-.Xr yppush 8
-command.
-The
-.Tn NIS
-Makefile
-.Pf ( Pa /var/yp/Makefile )
-will do this automatically if the administrator comments out the
-line which says
-.Em NOPUSH=true
-(NOPUSH is set to true by default because the default configuration is
-for a small network with only one
-.Tn NIS
-server). The
-.Xr yppush 8
-command will initiate a transaction between the master and slave
-during which the slave will transfer the specified maps from the
-master server using
-.Xr ypxfr 8 .
-(The slave server calls
-.Xr ypxfr 8
-automatically from within
-.Xr ypserv 8 ;
-therefore it is not usually necessary for the administrator
-to use it directly.
-It can be run manually if
-desired, however.)
-Maintaining
-slave servers helps improve
-.Tn NIS
-performance on large
-networks by:
-.Pp
-.Bl -bullet -offset indent
-.It
-Providing backup services in the event that the
-.Tn NIS
-master crashes
-or becomes unreachable
-.It
-Spreading the client load out over several machines instead of
-causing the master to become overloaded
-.It
-Allowing a single
-.Tn NIS
-domain to extend beyond
-a local network (the
-.Xr ypbind 8
-daemon might not be able to locate a server automatically if it resides on
-a network outside the reach of its broadcasts.
-It is possible to force
-.Xr ypbind 8
-to bind to a particular server with
-.Xr ypset 8
-but this is sometimes inconvenient.
-This problem can be avoided simply by
-placing a slave server on the local network.)
-.El
-.Pp
-The
-.Bx Free
-.Xr ypserv 8
-is specially designed to provided enhanced security (compared to
-other
-.Tn NIS
-implementations) when used exclusively with
-.Bx Free
-client
-systems.
-The
-.Bx Free
-password database system (which is derived directly
-from
-.Bx 4.4 )
-includes support for
-.Em "shadow passwords" .
-The standard password database does not contain users' encrypted
-passwords: these are instead stored (along with other information)
-is a separate database which is accessible only by the super-user.
-If the encrypted password database were made available as an
-.Tn NIS
-map, this security feature would be totally disabled, since any user
-is allowed to retrieve
-.Tn NIS
-data.
-.Pp
-To help prevent this,
-.Bx Free Ns 's
-.Tn NIS
-server handles the shadow password maps
-.Pf ( Pa master.passwd.byname
-and
-.Pa master.passwd.byuid )
-in a special way: the server will only provide access to these
-maps in response to requests that originate on privileged ports.
-Since only the super-user is allowed to bind to a privileged port,
-the server assumes that all such requests come from privileged
-users.
-All other requests are denied: requests from non-privileged
-ports will receive only an error code from the server.
-Additionally,
-.Bx Free Ns 's
-.Xr ypserv 8
-includes support for Wietse Venema's tcp wrapper package; with tcp
-wrapper support enabled, the administrator can configure
-.Xr ypserv 8
-to respond only to selected client machines.
-.Pp
-While these enhancements provide better security than stock
-.Tn NIS Ns ,
-they are by no means 100% effective.
-It is still possible for
-someone with access to your network to spoof the server into disclosing
-the shadow password maps.
-.Pp
-On the client side,
-.Bx Free Ns 's
-.Fn getpwent 3
-functions will automatically search for the
-.Pa master.passwd
-maps and use them if they exist.
-If they do, they will be used, and
-all fields in these special maps (class, password age and account
-expiration) will be decoded.
-If they aren't found, the standard
-.Pa passwd
-maps will be used instead.
-.Sh COMPATIBILITY
-Some systems, such as SunOS 4.x, need
-.Tn NIS
-to be running in order
-for their hostname resolution functions (
-.Fn gethostbyname ,
-.Fn gethostbyaddr ,
-etc) to work properly.
-On these systems,
-.Xr ypserv 8
-performs
-.Tn DNS
-lookups when asked to return information about
-a host that doesn't exist in its
-.Pa hosts.byname
-or
-.Pa hosts.byaddr
-maps.
-.Bx Free Ns 's
-resolver uses
-.Tn DNS
-by default (it can be made to use
-.Tn NIS Ns ,
-if desired), therefore its
-.Tn NIS
-server doesn't do
-.Tn DNS
-lookups
-by default.
-However,
-.Xr ypserv 8
-can be made to perform
-.Tn DNS
-lookups if it is started with a special
-flag.
-It can also be made to register itself as an
-.Tn NIS
-v1 server
-in order to placate certain systems that insist on the presence of
-a v1 server
-.Pf ( Bx Free
-uses only
-.Tn NIS
-v2, but many other systems,
-including
-.Tn SunOS
-4.x, search for both a v1 and v2 server when binding).
-.Bx Free Ns 's
-.Xr ypserv 8
-does not actually handle
-.Tn NIS
-v1 requests, but this ``kludge mode''
-is useful for silencing stubborn systems that search for both
-a v1 and v2 server.
-.Pp
-(Please see the
-.Xr ypserv 8
-manual page for a detailed description of these special features
-and flags.)
-.Sh BUGS
-While
-.Bx Free
-now has both
-.Tn NIS
-client and server capabilities, it does not yet have support for
-.Xr ypupdated 8
-or the
-.Fn yp_update
-function.
-Both of these require secure
-.Tn RPC Ns ,
-which
-.Bx Free
-doesn't
-support yet either.
-.Pp
-The
-.Xr getservent 3
-and
-.Xr getprotoent 3
-functions do not yet have
-.Tn NIS
-support.
-Fortunately, these files
-don't need to be updated that often.
-.Pp
-Many more manual pages should be written, especially
-.Xr ypclnt 3 .
-For the time being, seek out a local Sun machine and read the
-manuals for there.
-.Pp
-Neither Sun nor this author have found a clean way to handle
-the problems that occur when ypbind cannot find its server
-upon bootup.
-.Sh HISTORY
-The
-.Nm YP
-subsystem was written from the ground up by
-.An Theo de Raadt
-to be compatible to Sun's implementation.
-Bug fixes, improvements
-and
-.Tn NIS
-server support were later added by
-.An Bill Paul Ns .
-The server-side code was originally written by
-.An Peter Eriksson
-and
-.An Tobias Reber
-and is subject to the GNU Public License.
-No Sun code was
-referenced.
diff --git a/share/man/man9/VOP_VPTOFH.9 b/share/man/man9/VOP_VPTOFH.9
deleted file mode 100644
index ade15c061fe5..000000000000
--- a/share/man/man9/VOP_VPTOFH.9
+++ /dev/null
@@ -1,61 +0,0 @@
-.\" -*- nroff -*-
-.\"
-.\" Copyright (c) 1996 Doug Rabson
-.\"
-.\" All rights reserved.
-.\"
-.\" This program is free software.
-.\"
-.\" 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 DEVELOPERS ``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 DEVELOPERS 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd July 24, 1996
-.Os
-.Dt VFS_VPTOFH 9
-.Sh NAME
-.Nm VFS_VPTOFH
-.Nd turn a vnode into an NFS filehandle
-.Sh SYNOPSIS
-.Fd #include <sys/param.h>
-.Fd #include <sys/mount.h>
-.Fd #include <sys/vnode.h>
-.Ft int
-.Fn VFS_VPTOFH "struct vnode *vp" "struct fid *fhp"
-.Sh DESCRIPTION
-This is used by the NFS server to create an opaque filehandle which
-uniquely identifies the file and which can be used by an NFS client
-to access the file in the future.
-.Pp
-Its arguments are:
-.Bl -tag -width fhp
-.It Ar vp
-The vnode to make a filehandle for.
-.It Ar fhp
-Return parameter for the filehandle.
-.El
-.Sh SEE ALSO
-.Xr VFS 9 ,
-.Xr VFS_FHTOVP 9 ,
-.Xr vnode 9
-.Sh AUTHORS
-This man page was written by
-.An Doug Rabson .
diff --git a/share/me/orig_me.7 b/share/me/orig_me.7
deleted file mode 100644
index cdeba3803015..000000000000
--- a/share/me/orig_me.7
+++ /dev/null
@@ -1,318 +0,0 @@
-.\" Copyright (c) 1980, 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. 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, Berkeley and its contributors.
-.\" 4. 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.
-.\"
-.\" @(#)me.7 8.1 (Berkeley) 6/5/93
-.\" $FreeBSD$
-.\"
-.hc %
-.TH ME 7 "June 5, 1993"
-.UC 3
-.SH NAME
-me \- macros for formatting papers
-.SH SYNOPSIS
-.B "nroff \-me"
-[ options ]
-file ...
-.br
-.B "troff \-me"
-[ options ]
-file ...
-.SH DESCRIPTION
-This package of
-.I nroff
-and
-.I troff
-macro definitions provides a canned formatting
-facility for tech%nical papers in various formats.
-When producing 2-column output on a terminal, filter
-the output through
-.IR col (1).
-.PP
-The macro requests are defined below.
-Many
-.I nroff
-and
-.I troff
-requests are unsafe in conjunction with
-this package, however, these requests may be used with
-impunity after the first .pp:
-.nf
-.IP
-.ta \w'.sz +n 'u
-\&.bp begin new page
-\&.br break output line here
-\&.sp n insert n spacing lines
-\&.ls n (line spacing) n=1 single, n=2 double space
-\&.na no alignment of right margin
-\&.ce n center next n lines
-\&.ul n underline next n lines
-\&.sz +n add n to point size
-.fi
-.PP
-Output of the
-.I eqn,
-.I neqn,
-.I refer,
-and
-.IR tbl (1)
-preprocessors
-for equations and tables is acceptable as input.
-.SH FILES
-/usr/share/tmac/tmac.e
-.br
-/usr/share/me/*
-.SH "SEE ALSO"
-eqn(1), troff(1), refer(1), tbl(1)
-.br
-\-me Reference Manual, Eric P. Allman
-.br
-Writing Papers with Nroff Using \-me
-.tr &.
-.SH REQUESTS
-In the following list,
-\*(lqinitialization\*(rq
-refers to the first .pp, .lp, .ip, .np, .sh, or .uh macro.
-This list is incomplete;
-see
-.I "The \-me Reference Manual"
-for interesting details.
-.PP
-.ta \w'.eh \'x\'y\'z\' 'u +\w'Initial 'u +\w'Cause 'u
-.br
-.di x
- \ka
-.br
-.di
-.in \nau
-.ti 0
-Request Initial Cause Explanation
-.ti 0
- Value Break
-.br
-.in \nau
-.ti 0
-\&.(c - yes Begin centered block
-.ti 0
-\&.(d - no Begin delayed text
-.ti 0
-\&.(f - no Begin footnote
-.ti 0
-\&.(l - yes Begin list
-.ti 0
-\&.(q - yes Begin major quote
-.ti 0
-\&.(x \fIx\fR - no Begin indexed item in index
-.I x
-.ti 0
-\&.(z - no Begin floating keep
-.ti 0
-\&.)c - yes End centered block
-.ti 0
-\&.)d - yes End delayed text
-.ti 0
-\&.)f - yes End footnote
-.ti 0
-\&.)l - yes End list
-.ti 0
-\&.)q - yes End major quote
-.ti 0
-\&.)x - yes End index item
-.ti 0
-\&.)z - yes End floating keep
-.ti 0
-\&.++ \fIm H\fR - no Define paper section.
-.I m
-defines the part of the paper, and can be
-.B C
-(chapter),
-.B A
-(appendix),
-.B P
-(preliminary, e.g., abstract, table of contents, etc.),
-.B B
-(bibliography),
-.B RC
-(chapters renumbered from page one each chapter),
-or
-.B RA
-(appendix renumbered from page one).
-.ti 0
-\&.+c \fIT\fR - yes Begin chapter (or appendix, etc., as
-set by .++).
-.I T
-is the chapter title.
-.ti 0
-\&.1c 1 yes One column format on a new page.
-.ti 0
-\&.2c 1 yes Two column format.
-.ti 0
-\&.EN - yes Space after equation
-produced by
-.I eqn
-or
-.IR neqn .
-.ti 0
-\&.EQ \fIx y\fR - yes Precede equation; break out and
-add space.
-Equation number is
-.IR y .
-The optional argument \fIx\fR
-may be
-.I I
-to indent equation (default),
-.I L
-to left-adjust the equation, or
-.I C
-to center the equation.
-.ti 0
-\&.GE - yes End \fIgremlin\fP picture.
-.ti 0
-\&.GS - yes Begin \fIgremlin\fP picture.
-.ti 0
-\&.PE - yes End \fIpic\fP picture.
-.ti 0
-\&.PS - yes Begin \fIpic\fP picture.
-.ti 0
-\&.TE - yes End table.
-.ti 0
-\&.TH - yes End heading section of table.
-.ti 0
-\&.TS \fIx\fR - yes Begin table; if \fIx\fR is
-.I H
-table has repeated heading.
-.ti 0
-\&.ac \fIA N\fR - no Set up for ACM style output.
-.I A
-is the Author's name(s),
-.I N
-is the total number of pages.
-Must be given before the first initialization.
-.ti 0
-\&.b \fIx\fR no no Print
-.I x
-in boldface; if no argument switch to boldface.
-.ti 0
-\&.ba \fI+n\fR 0 yes Augments the base indent by
-.I n.
-This indent is used to set the indent on regular text
-(like paragraphs).
-.ti 0
-\&.bc no yes Begin new column
-.ti 0
-\&.bi \fIx\fR no no Print
-.I x
-in bold italics (nofill only)
-.ti 0
-\&.bu - yes Begin bulleted paragraph
-.ti 0
-\&.bx \fIx\fR no no Print \fIx\fR in a box (nofill only).
-.ti 0
-\&.ef \fI\'x\'y\'z\'\fR \'\'\'\' no Set even footer to x y z
-.ti 0
-\&.eh \fI\'x\'y\'z\'\fR \'\'\'\' no Set even header to x y z
-.ti 0
-\&.fo \fI\'x\'y\'z\'\fR \'\'\'\' no Set footer to x y z
-.ti 0
-\&.hx - no Suppress headers and footers on next page.
-.ti 0
-\&.he \fI\'x\'y\'z\'\fR \'\'\'\' no Set header to x y z
-.ti 0
-\&.hl - yes Draw a horizontal line
-.ti 0
-\&.i \fIx\fR no no Italicize
-.I x;
-if
-.I x
-missing, italic text follows.
-.ti 0
-\&.ip \fIx y\fR no yes Start indented paragraph,
-with hanging tag
-.IR x .
-Indentation is
-.I y
-ens (default 5).
-.ti 0
-\&.lp yes yes Start left-blocked paragraph.
-.ti 0
-\&.lo - no Read in a file of local macros of the
-form
-.BI \&.* x.
-Must be given before initialization.
-.ti 0
-\&.np 1 yes Start numbered paragraph.
-.ti 0
-\&.of \fI\'x\'y\'z\'\fR \'\'\'\' no Set odd footer to x y z
-.ti 0
-\&.oh \fI\'x\'y\'z\'\fR \'\'\'\' no Set odd header to x y z
-.ti 0
-\&.pd - yes Print delayed text.
-.ti 0
-\&.pp no yes Begin paragraph.
-First line indented.
-.ti 0
-\&.r yes no Roman text follows.
-.ti 0
-\&.re - no Reset tabs to default values.
-.ti 0
-\&.sc no no Read in a file of special characters
-and diacritical marks.
-Must be given before initialization.
-.ti 0
-\&.sh \fIn x\fR - yes Section head follows,
-font automatically bold.
-.I n
-is level of section,
-.I x
-is title of section.
-.ti 0
-\&.sk no no Leave the next page blank.
-Only one page is remembered ahead.
-.ti 0
-\&.sm \fIx\fR - no Set
-.I x
-in a smaller pointsize.
-.ti 0
-\&.sz \fI+n\fR 10p no Augment the point size by
-.I n
-points.
-.ti 0
-\&.th no no Produce the paper in thesis format.
-Must be given before initialization.
-.ti 0
-\&.tp no yes Begin title page.
-.ti 0
-\&.u \fIx\fR - no Underline argument (even in \fItroff\fR).
-(Nofill only).
-.ti 0
-\&.uh - yes Like .sh but unnumbered.
-.ti 0
-\&.xp \fIx\fR - no Print index
-.I x.
diff --git a/share/mklocale/ja_JP.eucJP.src b/share/mklocale/ja_JP.eucJP.src
deleted file mode 100644
index 88fdc91ddcd5..000000000000
--- a/share/mklocale/ja_JP.eucJP.src
+++ /dev/null
@@ -1,158 +0,0 @@
-# @(#)Japanese 8.1 (Berkeley) 6/6/93
-
-/*
- * Japanese LOCALE_CTYPE definitions using EUC of JIS character sets
- */
-
-ENCODING "EUC"
-
-/* JIS JIS JIS */
-/* X201 X208 X201 */
-/* 00-7f 84-fe */
-
-VARIABLE 1 0x0000 2 0x8080 2 0x0080 3 0x8000 0x8080
-
-/*
- * Code Set 1
- */
-ALPHA 'A' - 'Z' 'a' - 'z'
-CONTROL 0x00 - 0x1f 0x7f
-DIGIT '0' - '9'
-GRAPH 0x21 - 0x7e
-LOWER 'a' - 'z'
-PUNCT 0x21 - 0x2f 0x3a - 0x40 0x5b - 0x60 0x7b - 0x7e
-SPACE 0x09 - 0x0d 0x20
-UPPER 'A' - 'Z'
-XDIGIT '0' - '9' 'a' - 'f' 'A' - 'F'
-BLANK ' ' '\t'
-PRINT 0x20 - 0x7e
-
-MAPLOWER < 'A' - 'Z' : 'a' >
-MAPLOWER < 'a' - 'z' : 'a' >
-MAPUPPER < 'A' - 'Z' : 'A' >
-MAPUPPER < 'a' - 'z' : 'A' >
-TODIGIT < '0' - '9' : 0 >
-TODIGIT < 'A' - 'F' : 10 >
-TODIGIT < 'a' - 'f' : 10 >
-
-/*
- * Code Set 2
- */
-
-SPACE 0xa1a1
-PHONOGRAM 0xa1bc
-SPECIAL 0xa1a2 - 0xa1fe
-PUNCT 0xa1a2 - 0xa1f8 /* A few too many in here... */
-
-SPECIAL 0xa2a1 - 0xa2ae 0xa2ba - 0xa2c1 0xa2ca - 0xa2d0 0xa2dc - 0xa2ea
-SPECIAL 0xa2f2 - 0xa2f9 0xa2fe
-
-DIGIT 0xa3b0 - 0xa3b9
-UPPER 0xa3c1 - 0xa3da /* Romaji */
-LOWER 0xa3e1 - 0xa3fa /* Romaji */
-MAPLOWER < 0xa3c1 - 0xa3da : 0xa3e1 > /* English */
-MAPLOWER < 0xa3e1 - 0xa3fa : 0xa3e1 > /* English */
-MAPUPPER < 0xa3c1 - 0xa3da : 0xa3c1 >
-MAPUPPER < 0xa3e1 - 0xa3fa : 0xa3c1 >
-
-XDIGIT 0xa3c1 - 0xa3c6 0xa3e1 - 0xa3e6
-
-TODIGIT < 0xa3b0 - 0xa3b9 : 0 >
-TODIGIT < 0xa3c1 - 0xa3c6 : 10 >
-TODIGIT < 0xa3e1 - 0xa3e6 : 10 >
-
-PHONOGRAM 0xa4a1 - 0xa4f3
-PHONOGRAM 0xa5a1 - 0xa5f6
-
-UPPER 0xa6a1 - 0xa6b8 /* Greek */
-LOWER 0xa6c1 - 0xa6d8 /* Greek */
-MAPLOWER < 0xa6a1 - 0xa6b8 : 0xa6c1 >
-MAPLOWER < 0xa6c1 - 0xa6d8 : 0xa6c1 >
-MAPUPPER < 0xa6a1 - 0xa6b8 : 0xa6a1 >
-MAPUPPER < 0xa6c1 - 0xa6d8 : 0xa6a1 >
-
-UPPER 0xa7a1 - 0xa7c1 /* Cyrillic */
-LOWER 0xa7d1 - 0xa7f1 /* Cyrillic */
-MAPLOWER < 0xa7a1 - 0xa7c1 : 0xa7d1 >
-MAPLOWER < 0xa7d1 - 0xa7f1 : 0xa7d1 >
-MAPUPPER < 0xa7a1 - 0xa7c1 : 0xa7a1 >
-MAPUPPER < 0xa7d1 - 0xa7f1 : 0xa7a1 >
-
-SPECIAL 0xa8a1 - 0xa8c0
-
-IDEOGRAM 0xb0a1 - 0xb0fe
-IDEOGRAM 0xb1a1 - 0xb1fe
-IDEOGRAM 0xb2a1 - 0xb2fe
-IDEOGRAM 0xb3a1 - 0xb3fe
-IDEOGRAM 0xb4a1 - 0xb4fe
-IDEOGRAM 0xb5a1 - 0xb5fe
-IDEOGRAM 0xb6a1 - 0xb6fe
-IDEOGRAM 0xb7a1 - 0xb7fe
-IDEOGRAM 0xb8a1 - 0xb8fe
-IDEOGRAM 0xb9a1 - 0xb9fe
-IDEOGRAM 0xbaa1 - 0xbafe
-IDEOGRAM 0xbba1 - 0xbbfe
-IDEOGRAM 0xbca1 - 0xbcfe
-IDEOGRAM 0xbda1 - 0xbdfe
-IDEOGRAM 0xbea1 - 0xbefe
-IDEOGRAM 0xbfa1 - 0xbffe
-IDEOGRAM 0xc0a1 - 0xc0fe
-IDEOGRAM 0xc1a1 - 0xc1fe
-IDEOGRAM 0xc2a1 - 0xc2fe
-IDEOGRAM 0xc3a1 - 0xc3fe
-IDEOGRAM 0xc4a1 - 0xc4fe
-IDEOGRAM 0xc5a1 - 0xc5fe
-IDEOGRAM 0xc6a1 - 0xc6fe
-IDEOGRAM 0xc7a1 - 0xc7fe
-IDEOGRAM 0xc8a1 - 0xc8fe
-IDEOGRAM 0xc9a1 - 0xc9fe
-IDEOGRAM 0xcaa1 - 0xcafe
-IDEOGRAM 0xcba1 - 0xcbfe
-IDEOGRAM 0xcca1 - 0xccfe
-IDEOGRAM 0xcda1 - 0xcdfe
-IDEOGRAM 0xcea1 - 0xcefe
-IDEOGRAM 0xcfa1 - 0xcfd3
-IDEOGRAM 0xd0a1 - 0xd0fe
-IDEOGRAM 0xd1a1 - 0xd1fe
-IDEOGRAM 0xd2a1 - 0xd2fe
-IDEOGRAM 0xd3a1 - 0xd3fe
-IDEOGRAM 0xd4a1 - 0xd4fe
-IDEOGRAM 0xd5a1 - 0xd5fe
-IDEOGRAM 0xd6a1 - 0xd6fe
-IDEOGRAM 0xd7a1 - 0xd7fe
-IDEOGRAM 0xd8a1 - 0xd8fe
-IDEOGRAM 0xd9a1 - 0xd9fe
-IDEOGRAM 0xdaa1 - 0xdafe
-IDEOGRAM 0xdba1 - 0xdbfe
-IDEOGRAM 0xdca1 - 0xdcfe
-IDEOGRAM 0xdda1 - 0xddfe
-IDEOGRAM 0xdea1 - 0xdefe
-IDEOGRAM 0xdfa1 - 0xdffe
-IDEOGRAM 0xe0a1 - 0xe0fe
-IDEOGRAM 0xe1a1 - 0xe1fe
-IDEOGRAM 0xe2a1 - 0xe2fe
-IDEOGRAM 0xe3a1 - 0xe3fe
-IDEOGRAM 0xe4a1 - 0xe4fe
-IDEOGRAM 0xe5a1 - 0xe5fe
-IDEOGRAM 0xe6a1 - 0xe6fe
-IDEOGRAM 0xe7a1 - 0xe7fe
-IDEOGRAM 0xe8a1 - 0xe8fe
-IDEOGRAM 0xe9a1 - 0xe9fe
-IDEOGRAM 0xeaa1 - 0xeafe
-IDEOGRAM 0xeba1 - 0xebfe
-IDEOGRAM 0xeca1 - 0xecfe
-IDEOGRAM 0xeda1 - 0xedfe
-IDEOGRAM 0xeea1 - 0xeefe
-IDEOGRAM 0xefa1 - 0xeffe
-IDEOGRAM 0xf0a1 - 0xf0fe
-IDEOGRAM 0xf1a1 - 0xf1fe
-IDEOGRAM 0xf2a1 - 0xf2fe
-IDEOGRAM 0xf3a1 - 0xf3fe
-IDEOGRAM 0xf4a1 - 0xf4a4
-
-/*
- * This is for Code Set 3, half-width kana
- */
-SPECIAL 0xa1 - 0xdf
-PHONOGRAM 0xa1 - 0xdf
-CONTROL 0x84 - 0x97 0x9b - 0x9f 0xe0 - 0xfe
diff --git a/share/mklocale/ko_KR.eucKR.src b/share/mklocale/ko_KR.eucKR.src
deleted file mode 100644
index ce54ab32c9fb..000000000000
--- a/share/mklocale/ko_KR.eucKR.src
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Korean LC_CTYPE definitions using EUC-KR character sets
- * (ko_KR.EUC.src)
- *
- * Choi Jun Ho, junker@jazz.snu.ac.kr
- * NARAE, Seoul National Univ., CS Dept.
- * Last Updated on Mar 24 1997
- *
- * It is based on manpage mklocale(1), euc(4), ja_JP.EUC.src.
- *
- */
-
-ENCODING "EUC"
-
-/* EUC-KR(KS C 5601.1992)
- * 0xa1a1-0xfefe
- * byte 1: 0xa1-0xfe
- * byte 2: 0xa1-0xfe
- */
-
-/* We have only codeset 1 and 2, so others are dummy.
- But it must be defined to work in 2.2 xpg4 locale routine...
- */
-VARIABLE 1 0x0000 2 0x8080 2 0x0080 3 0x8000 0x8080
-
-/*
- * Code Set 1, US-ASCII equivalent
- */
-ALPHA 'A' - 'Z' 'a' - 'z'
-CONTROL 0x00 - 0x1f 0x7f
-DIGIT '0' - '9'
-GRAPH 0x21 - 0x7e
-LOWER 'a' - 'z'
-PUNCT 0x21 - 0x2f 0x3a - 0x40 0x5b - 0x60 0x7b - 0x7e
-SPACE 0x09 - 0x0d 0x20
-UPPER 'A' - 'Z'
-XDIGIT '0' - '9' 'a' - 'f' 'A' - 'F'
-BLANK ' ' '\t'
-PRINT 0x20 - 0x7e
-
-MAPLOWER < 'A' - 'Z' : 'a' > < 'a' - 'z' : 'a' >
-MAPUPPER < 'A' - 'Z' : 'A' > < 'a' - 'z' : 'A' >
-TODIGIT < '0' - '9' : 0 >
-TODIGIT < 'A' - 'F' : 10 > < 'a' - 'f' : 10 >
-
-/*
- * Code Set 2, EUC-KR
- */
-ALPHA 0xa3c1 - 0xa3da 0xa3e1 - 0xa3fa
-DIGIT 0xa3b0 - 0xa3b9
-UPPER 0xa3c1 - 0xa3da
-LOWER 0xa3e1 - 0xa3fa
-PUNCT 0xa3a1 - 0xa3af 0xa3ba - 0xa3c0 0xa3db - 0xa3e0 0xa3fb - 0xa3fe
-SPACE 0xa1a1
-XDIGIT 0xa3b0 - 0xa3b9 0xa3c1 - 0xa3c6 0xa3e1 - 0xa3e6
-BLANK 0xa1a1
-PRINT 0xa1a1 - 0xfefe
-SPECIAL 0xa1a2 - 0xa2e5
-
-MAPLOWER < 0xa3c1 - 0xa3da : 0xa3e1 > < 0xa3e1 - 0xa3fa : 0xa3e1 >
-MAPUPPER < 0xa3c1 - 0xa3da : 0xa3c1 > < 0xa3b0 - 0xa3b9 : 0xa3c1 >
-TODIGIT < 0xa3b0 - 0xa3b9 : 0 >
-TODIGIT < 0xa3c1 - 0xa3c6 : 10 > < 0xa3e1 - 0xa3e6 : 10 >
-
-
-UPPER 0xa5c1 - 0xa5d8 /* Greek */
-LOWER 0xa5e1 - 0xa5f8 /* Greek */
-MAPLOWER < 0xa5c1 - 0xa5d8 : 0xa5e1 > < 0xa5e1 - 0xa5f8 : 0xa5e1 >
-MAPUPPER < 0xa5c1 - 0xa5d8 : 0xa5c1 > < 0xa5e1 - 0xa5f8 : 0xa5c1 >
-
-UPPER 0xaca1 - 0xacc1 /* Cyrillic */
-LOWER 0xacd1 - 0xacf1 /* Cyrillic */
-MAPLOWER < 0xaca1 - 0xacc1 : 0xacd1 > < 0xacd1 - 0xacf1 : 0xacd1 >
-MAPUPPER < 0xaca1 - 0xacc1 : 0xaca1 > < 0xacd1 - 0xacf1 : 0xaca1 >
-
-DIGIT 0xa5a1 - 0xa5aa 0xa5b0 - 0xa5b9 /* Greek Digit */
-SPECIAL 0xa6a1 - 0xa6e4 0xa7a1 - 0xa7ef /* Symbols */
-SPECIAL 0xa8a1 - 0xa8fe 0xa9a1 - 0xa9fe /* Circle Symbols */
-
-PHONOGRAM 0xa4a1 - 0xa4fe /* Full-width Hangul glyph */
-PHONOGRAM 0xaaa1 - 0xaaf3 /* Full-width Hirakana */
-PHONOGRAM 0xaba1 - 0xabf6 /* Full-width Katakana */
-
-PHONOGRAM 0xb0a1 - 0xb0fe 0xb1a1 - 0xb1fe 0xb2a1 - 0xb2fe
-PHONOGRAM 0xb3a1 - 0xb3fe 0xb4a1 - 0xb4fe 0xb5a1 - 0xb5fe
-PHONOGRAM 0xb6a1 - 0xb6fe 0xb7a1 - 0xb7fe 0xb8a1 - 0xb8fe
-PHONOGRAM 0xb9a1 - 0xb9fe 0xbaa1 - 0xbafe 0xbba1 - 0xbbfe
-PHONOGRAM 0xbca1 - 0xbcfe 0xbda1 - 0xbdfe 0xbea1 - 0xbefe
-PHONOGRAM 0xbfa1 - 0xbffe 0xc0a1 - 0xc0fe 0xc1a1 - 0xc1fe
-PHONOGRAM 0xc2a1 - 0xc2fe 0xc3a1 - 0xc3fe 0xc4a1 - 0xc4fe
-PHONOGRAM 0xc5a1 - 0xc5fe 0xc6a1 - 0xc6fe 0xc7a1 - 0xc7fe
-PHONOGRAM 0xc8a1 - 0xc8fe /* Hangul composed */
-
-IDEOGRAM 0xcaa1 - 0xcafe 0xcba1 - 0xcbfe 0xcca1 - 0xccfe
-IDEOGRAM 0xcda1 - 0xcdfe 0xcea1 - 0xcefe 0xcfa1 - 0xcffe
-IDEOGRAM 0xd0a1 - 0xd0fe 0xd1a1 - 0xd1fe 0xd2a1 - 0xd2fe
-IDEOGRAM 0xd3a1 - 0xd3fe 0xd4a1 - 0xd4fe 0xd5a1 - 0xd5fe
-IDEOGRAM 0xd6a1 - 0xd6fe 0xd7a1 - 0xd7fe 0xd8a1 - 0xd8fe
-IDEOGRAM 0xd9a1 - 0xd9fe 0xdaa1 - 0xdafe 0xdba1 - 0xdbfe
-IDEOGRAM 0xdca1 - 0xdcfe 0xdda1 - 0xddfe 0xdea1 - 0xdefe
-IDEOGRAM 0xdfa1 - 0xdffe 0xe0a1 - 0xe0fe 0xe1a1 - 0xe1fe
-IDEOGRAM 0xe2a1 - 0xe2fe 0xe3a1 - 0xe3fe 0xe4a1 - 0xe4fe
-IDEOGRAM 0xe5a1 - 0xe5fe 0xe6a1 - 0xe6fe 0xe7a1 - 0xe7fe
-IDEOGRAM 0xe8a1 - 0xe8fe 0xe9a1 - 0xe9fe 0xeaa1 - 0xeafe
-IDEOGRAM 0xeba1 - 0xebfe 0xeca1 - 0xecfe 0xeda1 - 0xedfe
-IDEOGRAM 0xeea1 - 0xeefe 0xefa1 - 0xeffe 0xf0a1 - 0xf0fe
-IDEOGRAM 0xf1a1 - 0xf1fe 0xf2a1 - 0xf2fe 0xf3a1 - 0xf3fe
-IDEOGRAM 0xf4a1 - 0xf4fe 0xf5a1 - 0xf5fe 0xf6a1 - 0xf6fe
-IDEOGRAM 0xf7a1 - 0xf7fe 0xf8a1 - 0xf8fe 0xf9a1 - 0xf9fe
-IDEOGRAM 0xfaa1 - 0xfafe 0xfba1 - 0xfbfe 0xfca1 - 0xfcfe
-IDEOGRAM 0xfda1 - 0xfdfe /* Hanja */
-
-/* We don't have codeset 3 and 4.
- So codeset 3 is only dummy definition
- */
-PRINT 0xa1 - 0xfe
-SPECIAL 0xa1 - 0xfe
-
-/* End of LC_CTYPE definition */
diff --git a/share/mklocale/la_LN.ISO8859-1.src b/share/mklocale/la_LN.ISO8859-1.src
deleted file mode 100644
index 82faff3ed02a..000000000000
--- a/share/mklocale/la_LN.ISO8859-1.src
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Standard LOCALE_CTYPE for the iso_8859_1 Locale
- */
-ENCODING "NONE"
-VARIABLE ISO 8859-1 Latin-1 character set
-
-#
-# This is a comment
-#
-ALPHA 'A' - 'Z' 'a' - 'z' 0xc0 - 0xd6 0xd8 - 0xf6 0xf8 - 0xff
-CONTROL 0x00 - 0x1f 0x7f - 0x9f
-DIGIT '0' - '9'
-GRAPH 0x21 - 0x7e 0xa1 - 0xff
-LOWER 'a' - 'z' 0xdf - 0xf6 0xf8 - 0xff
-PUNCT 0x21 - 0x2f 0x3a - 0x40 0x5b - 0x60 0x7b - 0x7e 0xa1 - 0xbf 0xd7 0xf7
-SPACE 0x09 - 0x0d ' ' 0xa0
-UPPER 'A' - 'Z' 0xc0 - 0xd6 0xd8 - 0xde
-XDIGIT '0' - '9' 'a' - 'f' 'A' - 'F'
-BLANK ' ' '\t' 0xa0
-PRINT 0x20 - 0x7e 0xa0 - 0xff
-# IDEOGRAM
-# SPECIAL
-# PHONEGRAM
-
-MAPLOWER <'A' - 'Z' : 'a'>
-MAPLOWER <'a' - 'z' : 'a'>
-MAPLOWER <0xc0 - 0xd6 : 0xe0>
-MAPLOWER <0xd8 - 0xde : 0xf8>
-MAPLOWER <0xdf - 0xf6 : 0xdf>
-MAPLOWER <0xf8 - 0xff : 0xf8>
-MAPUPPER <'A' - 'Z' : 'A'>
-MAPUPPER <'a' - 'z' : 'A'>
-MAPUPPER <0xc0 - 0xd6 : 0xc0>
-MAPUPPER <0xd8 - 0xde : 0xd8>
-MAPUPPER <0xe0 - 0xf6 : 0xc0>
-MAPUPPER <0xf8 - 0xfe : 0xd8>
-TODIGIT <'0' - '9' : 0>
-TODIGIT <'A' - 'F' : 10>
-TODIGIT <'a' - 'f' : 10>
diff --git a/share/mklocale/la_LN.ISO8859-15.src b/share/mklocale/la_LN.ISO8859-15.src
deleted file mode 100644
index 7d89e03673b9..000000000000
--- a/share/mklocale/la_LN.ISO8859-15.src
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Standard LOCALE_CTYPE for the dis_8859_15 Locale
- */
-ENCODING "NONE"
-VARIABLE DIS 8859-15 Latin-9 character set
-
-#
-# This is a comment
-#
-ALPHA 'A' - 'Z' 'a' - 'z' 0xa6 0xa8 0xb4 0xb8 0xbc - 0xbe 0xc0 - 0xd6 0xd8 - 0xf6 0xf8 - 0xff
-CONTROL 0x00 - 0x1f 0x7f - 0x9f
-DIGIT '0' - '9'
-GRAPH 0x21 - 0x7e 0xa1 - 0xff
-LOWER 'a' - 'z' 0xa8 0xb8 0xbd 0xdf - 0xf6 0xf8 - 0xff
-PUNCT 0x21 - 0x2f 0x3a - 0x40 0x5b - 0x60 0x7b - 0x7e 0xa1 - 0xa5 0xa7 0xa9 - 0xb3 0xb5 - 0xb7 0xb9 - 0xbb 0xbf 0xd7 0xf7
-SPACE 0x09 - 0x0d ' ' 0xa0
-UPPER 'A' - 'Z' 0xa6 0xb4 0xbc 0xc0 - 0xd6 0xd8 - 0xde
-XDIGIT '0' - '9' 'a' - 'f' 'A' - 'F'
-BLANK ' ' '\t' 0xa0
-PRINT 0x20 - 0x7e 0xa0 - 0xff
-# IDEOGRAM
-# SPECIAL
-# PHONEGRAM
-
-MAPLOWER <'A' - 'Z' : 'a'>
-MAPLOWER <'a' - 'z' : 'a'>
-MAPLOWER <0xa6 - 0xa6 : 0xa8>
-MAPLOWER <0xb4 - 0xb4 : 0xb8>
-MAPLOWER <0xbc - 0xbc : 0xbd>
-MAPLOWER <0xbe - 0xbe : 0xff>
-MAPLOWER <0xc0 - 0xd6 : 0xe0>
-MAPLOWER <0xd8 - 0xde : 0xf8>
-MAPLOWER <0xdf - 0xf6 : 0xdf>
-MAPLOWER <0xf8 - 0xff : 0xf8>
-MAPUPPER <'A' - 'Z' : 'A'>
-MAPUPPER <'a' - 'z' : 'A'>
-MAPUPPER <0xa8 - 0xa8 : 0xa6>
-MAPUPPER <0xb8 - 0xb8 : 0xb4>
-MAPUPPER <0xbd - 0xbd : 0xbc>
-MAPUPPER <0xc0 - 0xd6 : 0xc0>
-MAPUPPER <0xd8 - 0xde : 0xd8>
-MAPUPPER <0xe0 - 0xf6 : 0xc0>
-MAPUPPER <0xf8 - 0xfe : 0xd8>
-MAPUPPER <0xff - 0xff : 0xbe>
-TODIGIT <'0' - '9' : 0>
-TODIGIT <'A' - 'F' : 10>
-TODIGIT <'a' - 'f' : 10>
diff --git a/share/mklocale/la_LN.ISO8859-2.src b/share/mklocale/la_LN.ISO8859-2.src
deleted file mode 100644
index a9fa03fc89e5..000000000000
--- a/share/mklocale/la_LN.ISO8859-2.src
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * LOCALE_CTYPE for the iso_8859_2 Locale
- *
- * $FreeBSD$
- */
-
-ENCODING "NONE"
-VARIABLE ISO 8859-2 Latin-2 character set
-
-#
-# This is a comment
-#
-ALPHA 'A' - 'Z' 'a' - 'z'
- 0xa1 0xa3 0xa5 0xa6 0xa9 - 0xac 0xae 0xaf
- 0xb1 0xb3 0xb5 0xb6 0xb9 - 0xbc 0xbe 0xbf
- 0xc0 - 0xd6 0xd8 - 0xf6 0xf8 - 0xfe
-CONTROL 0x00 - 0x1f 0x7f - 0x9f
-DIGIT '0' - '9'
-GRAPH 0x21 - 0x7e 0xa0 - 0xff
-LOWER 'a' - 'z'
- 0xb1 0xb3 0xb5 0xb6 0xb9 - 0xbc 0xbe 0xbf
- 0xdf - 0xf6 0xf8 - 0xfe
-PUNCT 0x21 - 0x2f 0x3a - 0x40 0x5b - 0x60 0x7b - 0x7e
- 0xa2 0xa4 0xa7 0xa8 0xad 0xb0 0xb2 0xb4 0xb7 0xb8 0xbd
- 0xd7 0xf7 0xff
-SPACE 0x09 - 0x0d 0x20 0xa0
-UPPER 'A' - 'Z'
- 0xa1 0xa3 0xa5 0xa6 0xa9 - 0xac 0xae 0xaf
- 0xc0 - 0xd6 0xd8 - 0xde
-XDIGIT 'a' - 'f' 'A' - 'F'
-BLANK ' ' '\t' 0xa0
-PRINT 0x20 - 0x7e 0xa0 - 0xff
-# IDEOGRAM
-# SPECIAL
-# PHONEGRAM
-
-MAPLOWER <'A' - 'Z' : 'a'>
-MAPLOWER <'a' - 'z' : 'a'>
-MAPLOWER <0xa1 0xb1>
-MAPLOWER <0xa3 0xb3>
-MAPLOWER <0xa5 0xb5>
-MAPLOWER <0xa6 0xb6>
-MAPLOWER <0xa9 - 0xac : 0xb9>
-MAPLOWER <0xae 0xbe>
-MAPLOWER <0xaf 0xbf>
-MAPLOWER <0xb1 0xb1>
-MAPLOWER <0xb3 0xb3>
-MAPLOWER <0xb5 0xb5>
-MAPLOWER <0xb6 0xb6>
-MAPLOWER <0xb9 - 0xbc : 0xb9>
-MAPLOWER <0xbe 0xbe>
-MAPLOWER <0xbf 0xbf>
-MAPLOWER <0xc0 - 0xd6 : 0xe0>
-MAPLOWER <0xd8 - 0xde : 0xf8>
-MAPLOWER <0xdf - 0xf6 : 0xdf>
-MAPLOWER <0xf8 - 0xfe : 0xf8>
-MAPUPPER <'A' - 'Z' : 'A'>
-MAPUPPER <'a' - 'z' : 'A'>
-MAPUPPER <0xa1 0xa1>
-MAPUPPER <0xa3 0xa3>
-MAPUPPER <0xa5 0xa5>
-MAPUPPER <0xa6 0xa6>
-MAPUPPER <0xa9 - 0xac : 0xa9>
-MAPUPPER <0xae 0xae>
-MAPUPPER <0xaf 0xaf>
-MAPUPPER <0xb1 0xa1>
-MAPUPPER <0xb3 0xa3>
-MAPUPPER <0xb5 0xa5>
-MAPUPPER <0xb6 0xa6>
-MAPUPPER <0xb9 - 0xbc : 0xa9>
-MAPUPPER <0xbe 0xae>
-MAPUPPER <0xbf 0xaf>
-MAPUPPER <0xc0 - 0xd6 : 0xc0>
-MAPUPPER <0xd8 - 0xdf : 0xd8>
-MAPUPPER <0xe0 - 0xf6 : 0xc0>
-MAPUPPER <0xf8 - 0xfe : 0xd8>
-TODIGIT <'0' - '9' : 0>
-TODIGIT <'A' - 'F' : 10>
-TODIGIT <'a' - 'f' : 10>
diff --git a/share/mklocale/la_LN.ISO8859-4.src b/share/mklocale/la_LN.ISO8859-4.src
deleted file mode 100644
index c3130a2cca59..000000000000
--- a/share/mklocale/la_LN.ISO8859-4.src
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * LOCALE_CTYPE for the iso_8859_4 Locale
- *
- * $FreeBSD$
- */
-
-ENCODING "NONE"
-VARIABLE ISO 8859-4 Latin-4 character set
-
-#
-# This is a comment
-#
-ALPHA 'A' - 'Z' 'a' - 'z'
- 0xa1 - 0xa3 0xa5 0xa6 0xa9 - 0xac 0xae
- 0xb1 0xb3 0xb5 0xb6 0xb9 - 0xd6 0xd8 - 0xf6 0xf8 - 0xfe
-CONTROL 0x00 - 0x1f 0x7f - 0x9f
-DIGIT '0' - '9'
-GRAPH 0x21 - 0x7e 0xa0 - 0xff
-LOWER 'a' - 'z'
- 0xa2 0xb1 0xb3 0xb5 0xb6 0xb9 - 0xbc 0xbe 0xbf
- 0xdf - 0xf6 0xf8 - 0xfe
-PUNCT 0x21 - 0x2f 0x3a - 0x40 0x5b - 0x60 0x7b - 0x7e
- 0xa4 0xa7 0xa8 0xad 0xaf 0xb0 0xb2 0xb4 0xb7 0xb8
- 0xd7 0xf7 0xff
-SPACE 0x09 - 0x0d 0x20 0xa0
-UPPER 'A' - 'Z'
- 0xa1 0xa3 0xa5 0xa6 0xa9 - 0xac 0xae
- 0xc0 - 0xd6 0xd8 - 0xde
-XDIGIT 'a' - 'f' 'A' - 'F'
-BLANK ' ' '\t' 0xa0
-PRINT 0x20 - 0x7e 0xa0 - 0xff
-# IDEOGRAM
-# SPECIAL
-# PHONEGRAM
-
-MAPLOWER <'A' - 'Z' : 'a'>
-MAPLOWER <'a' - 'z' : 'a'>
-MAPLOWER <0xa1 0xb1>
-MAPLOWER <0xa2 0xa2>
-MAPLOWER <0xa3 0xb3>
-MAPLOWER <0xa5 0xb5>
-MAPLOWER <0xa6 0xb6>
-MAPLOWER <0xa9 - 0xac : 0xb9>
-MAPLOWER <0xae 0xbe>
-MAPLOWER <0xb1 0xb1>
-MAPLOWER <0xb3 0xb3>
-MAPLOWER <0xb5 0xb5>
-MAPLOWER <0xb6 0xb6>
-MAPLOWER <0xb9 - 0xbc : 0xb9>
-MAPLOWER <0xbd 0xbf>
-MAPLOWER <0xbe 0xbe>
-MAPLOWER <0xbf 0xbf>
-MAPLOWER <0xc0 - 0xd6 : 0xe0>
-MAPLOWER <0xd8 - 0xde : 0xf8>
-MAPLOWER <0xdf - 0xf6 : 0xdf>
-MAPLOWER <0xf8 - 0xfe : 0xf8>
-MAPUPPER <'A' - 'Z' : 'A'>
-MAPUPPER <'a' - 'z' : 'A'>
-MAPUPPER <0xa1 0xa1>
-MAPUPPER <0xa3 0xa3>
-MAPUPPER <0xa5 0xa5>
-MAPUPPER <0xa6 0xa6>
-MAPUPPER <0xa9 - 0xac : 0xa9>
-MAPUPPER <0xae 0xae>
-MAPUPPER <0xb1 0xa1>
-MAPUPPER <0xb3 0xa3>
-MAPUPPER <0xb5 0xa5>
-MAPUPPER <0xb6 0xa6>
-MAPUPPER <0xb9 - 0xbc : 0xa9>
-MAPUPPER <0xbd 0xbd>
-MAPUPPER <0xbe 0xae>
-MAPUPPER <0xbf 0xbd>
-MAPUPPER <0xc0 - 0xd6 : 0xc0>
-MAPUPPER <0xd8 - 0xde : 0xd8>
-MAPUPPER <0xe0 - 0xf6 : 0xc0>
-MAPUPPER <0xf8 - 0xfe : 0xd8>
-TODIGIT <'0' - '9' : 0>
-TODIGIT <'A' - 'F' : 10>
-TODIGIT <'a' - 'f' : 10>
diff --git a/share/mklocale/la_LN.ISO_8859-15.src b/share/mklocale/la_LN.ISO_8859-15.src
deleted file mode 100644
index 7d89e03673b9..000000000000
--- a/share/mklocale/la_LN.ISO_8859-15.src
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Standard LOCALE_CTYPE for the dis_8859_15 Locale
- */
-ENCODING "NONE"
-VARIABLE DIS 8859-15 Latin-9 character set
-
-#
-# This is a comment
-#
-ALPHA 'A' - 'Z' 'a' - 'z' 0xa6 0xa8 0xb4 0xb8 0xbc - 0xbe 0xc0 - 0xd6 0xd8 - 0xf6 0xf8 - 0xff
-CONTROL 0x00 - 0x1f 0x7f - 0x9f
-DIGIT '0' - '9'
-GRAPH 0x21 - 0x7e 0xa1 - 0xff
-LOWER 'a' - 'z' 0xa8 0xb8 0xbd 0xdf - 0xf6 0xf8 - 0xff
-PUNCT 0x21 - 0x2f 0x3a - 0x40 0x5b - 0x60 0x7b - 0x7e 0xa1 - 0xa5 0xa7 0xa9 - 0xb3 0xb5 - 0xb7 0xb9 - 0xbb 0xbf 0xd7 0xf7
-SPACE 0x09 - 0x0d ' ' 0xa0
-UPPER 'A' - 'Z' 0xa6 0xb4 0xbc 0xc0 - 0xd6 0xd8 - 0xde
-XDIGIT '0' - '9' 'a' - 'f' 'A' - 'F'
-BLANK ' ' '\t' 0xa0
-PRINT 0x20 - 0x7e 0xa0 - 0xff
-# IDEOGRAM
-# SPECIAL
-# PHONEGRAM
-
-MAPLOWER <'A' - 'Z' : 'a'>
-MAPLOWER <'a' - 'z' : 'a'>
-MAPLOWER <0xa6 - 0xa6 : 0xa8>
-MAPLOWER <0xb4 - 0xb4 : 0xb8>
-MAPLOWER <0xbc - 0xbc : 0xbd>
-MAPLOWER <0xbe - 0xbe : 0xff>
-MAPLOWER <0xc0 - 0xd6 : 0xe0>
-MAPLOWER <0xd8 - 0xde : 0xf8>
-MAPLOWER <0xdf - 0xf6 : 0xdf>
-MAPLOWER <0xf8 - 0xff : 0xf8>
-MAPUPPER <'A' - 'Z' : 'A'>
-MAPUPPER <'a' - 'z' : 'A'>
-MAPUPPER <0xa8 - 0xa8 : 0xa6>
-MAPUPPER <0xb8 - 0xb8 : 0xb4>
-MAPUPPER <0xbd - 0xbd : 0xbc>
-MAPUPPER <0xc0 - 0xd6 : 0xc0>
-MAPUPPER <0xd8 - 0xde : 0xd8>
-MAPUPPER <0xe0 - 0xf6 : 0xc0>
-MAPUPPER <0xf8 - 0xfe : 0xd8>
-MAPUPPER <0xff - 0xff : 0xbe>
-TODIGIT <'0' - '9' : 0>
-TODIGIT <'A' - 'F' : 10>
-TODIGIT <'a' - 'f' : 10>
diff --git a/share/mklocale/la_LN.US-ASCII.src b/share/mklocale/la_LN.US-ASCII.src
deleted file mode 100644
index 95cbeeb9fe09..000000000000
--- a/share/mklocale/la_LN.US-ASCII.src
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Standard LOCALE_CTYPE for the ASCII Locale
- */
-ENCODING "NONE"
-VARIABLE Strict 7bit ASCII locale
-
-ALPHA 'A' - 'Z' 'a' - 'z'
-CONTROL 0x00 - 0x1f 0x7f
-DIGIT '0' - '9'
-GRAPH 0x21 - 0x7e
-LOWER 'a' - 'z'
-PUNCT 0x21 - 0x2f 0x3a - 0x40 0x5b - 0x60 0x7b - 0x7e
-SPACE 0x09 - 0x0d 0x20
-UPPER 'A' - 'Z'
-XDIGIT '0' - '9' 'a' - 'f' 'A' - 'F'
-BLANK ' ' '\t'
-PRINT 0x20 - 0x7e
-# IDEOGRAM
-# SPECIAL
-# PHONEGRAM
-
-MAPLOWER <'A' - 'Z' : 'a'>
-MAPLOWER <'a' - 'z' : 'a'>
-MAPUPPER <'A' - 'Z' : 'A'>
-MAPUPPER <'a' - 'z' : 'A'>
-TODIGIT <'0' - '9' : 0>
-TODIGIT <'A' - 'F' : 10>
-TODIGIT <'a' - 'f' : 10>
diff --git a/share/mklocale/ru_RU.CP866.src b/share/mklocale/ru_RU.CP866.src
deleted file mode 100644
index 659482bf6dba..000000000000
--- a/share/mklocale/ru_RU.CP866.src
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * LOCALE_CTYPE for Russian Alternative character set (CP866)
- */
-ENCODING "NONE"
-VARIABLE Russian Alternative charset (CP866) by ache@astral.msk.su
-
-#
-# This is a comment
-#
-ALPHA 'A' - 'Z' 'a' - 'z' 0x80 - 0xaf 0xe0 - 0xf1
-CONTROL 0x00 - 0x1f 0x7f
-DIGIT '0' - '9'
-GRAPH 0x21 - 0x7e 0x80 - 0xff
-LOWER 'a' - 'z' 0xa0 - 0xaf 0xe0 - 0xef 0xf1
-PUNCT 0x21 - 0x2f 0x3a - 0x40 0x5b - 0x60 0x7b - 0x7e
-SPACE 0x09 - 0x0d 0x20
-UPPER 'A' - 'Z' 0x80 - 0x9f 0xf0
-XDIGIT '0' - '9' 'a' - 'f' 'A' - 'F'
-BLANK ' ' '\t'
-PRINT 0x20 - 0x7e 0x80 - 0xff
-# IDEOGRAM
-# SPECIAL
-# PHONEGRAM
-
-MAPLOWER <'A' - 'Z' : 'a'>
-MAPLOWER <'a' - 'z' : 'a'>
-MAPLOWER <0x80 - 0x8f : 0xa0>
-MAPLOWER <0x90 - 0x9f : 0xe0>
-MAPLOWER <0xf0 0xf1>
-MAPLOWER <0xa0 - 0xaf : 0xa0>
-MAPLOWER <0xe0 - 0xef : 0xe0>
-MAPLOWER <0xf1 0xf1>
-MAPUPPER <'A' - 'Z' : 'A'>
-MAPUPPER <'a' - 'z' : 'A'>
-MAPUPPER <0x80 - 0x9f : 0x80>
-MAPUPPER <0xf0 0xf0>
-MAPUPPER <0xa0 - 0xaf : 0x80>
-MAPUPPER <0xe0 - 0xef : 0x90>
-MAPUPPER <0xf1 0xf0>
-TODIGIT <'0' - '9' : 0>
-TODIGIT <'A' - 'F' : 10>
-TODIGIT <'a' - 'f' : 10>
diff --git a/share/mklocale/ru_RU.ISO8859-5.src b/share/mklocale/ru_RU.ISO8859-5.src
deleted file mode 100644
index 68b39e77842e..000000000000
--- a/share/mklocale/ru_RU.ISO8859-5.src
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * LOCALE_CTYPE for Russian part of ISO8859-5 set
- *
- * $FreeBSD$
- */
-
-ENCODING "NONE"
-VARIABLE Russian part of ISO8859-5 character set by nms@ethereal.ru
-
-ALPHA 'A' - 'Z' 'a' - 'z' \
- 0xd0 0xd1 0xd2 0xd3 0xd4 0xd5 0xf1 0xd6 \
- 0xd7 0xd8 0xd9 0xda 0xdb 0xdc 0xdd 0xde \
- 0xdf 0xe0 0xe1 0xe2 0xe3 0xe4 0xe5 0xe6 \
- 0xe7 0xe8 0xe9 0xea 0xeb 0xec 0xed 0xee 0xef \
- 0xb0 0xb1 0xb2 0xb3 0xb4 0xb5 0xa1 0xb6 \
- 0xb7 0xb8 0xb9 0xba 0xbb 0xbc 0xbd 0xbe \
- 0xbf 0xc0 0xc1 0xc2 0xc3 0xc4 0xc5 0xc6 \
- 0xc7 0xc8 0xc9 0xca 0xcb 0xcc 0xcd 0xce 0xcf
-BLANK ' ' '\t'
-CONTROL 0x00 - 0x1f 0x7f
-DIGIT '0' - '9'
-GRAPH 0x21 - 0x7e
-LOWER 'a' - 'z' \
- 0xd0 0xd1 0xd2 0xd3 0xd4 0xd5 0xf1 0xd6 \
- 0xd7 0xd8 0xd9 0xda 0xdb 0xdc 0xdd 0xde \
- 0xdf 0xe0 0xe1 0xe2 0xe3 0xe4 0xe5 0xe6 \
- 0xe7 0xe8 0xe9 0xea 0xeb 0xec 0xed 0xee 0xef
-PRINT 0x20 - 0x7e
-PUNCT 0x21 - 0x2f 0x3a - 0x40 0x5b - 0x60 0x7b - 0x7e
-SPACE 0x09 - 0x0d 0x20
-UPPER 'A' - 'Z' \
- 0xb0 0xb1 0xb2 0xb3 0xb4 0xb5 0xa1 0xb6 \
- 0xb7 0xb8 0xb9 0xba 0xbb 0xbc 0xbd 0xbe \
- 0xbf 0xc0 0xc1 0xc2 0xc3 0xc4 0xc5 0xc6 \
- 0xc7 0xc8 0xc9 0xca 0xcb 0xcc 0xcd 0xce 0xcf
-XDIGIT '0' - '9' 'a' - 'f' 'A' - 'F'
-
-# IDEOGRAM
-# SPECIAL
-# PHONEGRAM
-
-MAPLOWER <'A' - 'Z' : 'a'>
-MAPLOWER <'a' - 'z' : 'a'>
-
-MAPLOWER <0xb0 0xd0>
-MAPLOWER <0xb1 0xd1>
-MAPLOWER <0xb2 0xd2>
-MAPLOWER <0xb3 0xd3>
-MAPLOWER <0xb4 0xd4>
-MAPLOWER <0xb5 0xd5>
-MAPLOWER <0xa1 0xf1>
-MAPLOWER <0xb6 0xd6>
-MAPLOWER <0xb7 0xd7>
-MAPLOWER <0xb8 0xd8>
-MAPLOWER <0xb9 0xd9>
-MAPLOWER <0xba 0xda>
-MAPLOWER <0xbb 0xdb>
-MAPLOWER <0xbc 0xdc>
-MAPLOWER <0xbd 0xdd>
-MAPLOWER <0xbe 0xde>
-MAPLOWER <0xbf 0xdf>
-MAPLOWER <0xc0 0xe0>
-MAPLOWER <0xc1 0xe1>
-MAPLOWER <0xc2 0xe2>
-MAPLOWER <0xc3 0xe3>
-MAPLOWER <0xc4 0xe4>
-MAPLOWER <0xc5 0xe5>
-MAPLOWER <0xc6 0xe6>
-MAPLOWER <0xc7 0xe7>
-MAPLOWER <0xc8 0xe8>
-MAPLOWER <0xc9 0xe9>
-MAPLOWER <0xca 0xea>
-MAPLOWER <0xcb 0xeb>
-MAPLOWER <0xcc 0xec>
-MAPLOWER <0xcd 0xed>
-MAPLOWER <0xce 0xee>
-MAPLOWER <0xcf 0xef>
-
-MAPLOWER <0xd0 0xd0>
-MAPLOWER <0xd1 0xd1>
-MAPLOWER <0xd2 0xd2>
-MAPLOWER <0xd3 0xd3>
-MAPLOWER <0xd4 0xd4>
-MAPLOWER <0xd5 0xd5>
-MAPLOWER <0xf1 0xf1>
-MAPLOWER <0xd6 0xd6>
-MAPLOWER <0xd7 0xd7>
-MAPLOWER <0xd8 0xd8>
-MAPLOWER <0xd9 0xd9>
-MAPLOWER <0xda 0xda>
-MAPLOWER <0xdb 0xdb>
-MAPLOWER <0xdc 0xdc>
-MAPLOWER <0xdd 0xdd>
-MAPLOWER <0xde 0xde>
-MAPLOWER <0xdf 0xdf>
-MAPLOWER <0xe0 0xe0>
-MAPLOWER <0xe1 0xe1>
-MAPLOWER <0xe2 0xe2>
-MAPLOWER <0xe3 0xe3>
-MAPLOWER <0xe4 0xe4>
-MAPLOWER <0xe5 0xe5>
-MAPLOWER <0xe6 0xe6>
-MAPLOWER <0xe7 0xe7>
-MAPLOWER <0xe8 0xe8>
-MAPLOWER <0xe9 0xe9>
-MAPLOWER <0xea 0xea>
-MAPLOWER <0xeb 0xeb>
-MAPLOWER <0xec 0xec>
-MAPLOWER <0xed 0xed>
-MAPLOWER <0xee 0xee>
-MAPLOWER <0xef 0xef>
-
-MAPUPPER <'A' - 'Z' : 'A'>
-MAPUPPER <'a' - 'z' : 'A'>
-
-MAPUPPER <0xd0 0xb0>
-MAPUPPER <0xd1 0xb1>
-MAPUPPER <0xd2 0xb2>
-MAPUPPER <0xd3 0xb3>
-MAPUPPER <0xd4 0xb4>
-MAPUPPER <0xd5 0xb5>
-MAPUPPER <0xf1 0xa1>
-MAPUPPER <0xd6 0xb6>
-MAPUPPER <0xd7 0xb7>
-MAPUPPER <0xd8 0xb8>
-MAPUPPER <0xd9 0xb9>
-MAPUPPER <0xda 0xba>
-MAPUPPER <0xdb 0xbb>
-MAPUPPER <0xdc 0xbc>
-MAPUPPER <0xdd 0xbd>
-MAPUPPER <0xde 0xbe>
-MAPUPPER <0xdf 0xbf>
-MAPUPPER <0xe0 0xc0>
-MAPUPPER <0xe1 0xc1>
-MAPUPPER <0xe2 0xc2>
-MAPUPPER <0xe3 0xc3>
-MAPUPPER <0xe4 0xc4>
-MAPUPPER <0xe5 0xc5>
-MAPUPPER <0xe6 0xc6>
-MAPUPPER <0xe7 0xc7>
-MAPUPPER <0xe8 0xc8>
-MAPUPPER <0xe9 0xc9>
-MAPUPPER <0xea 0xca>
-MAPUPPER <0xeb 0xcb>
-MAPUPPER <0xec 0xcc>
-MAPUPPER <0xed 0xcd>
-MAPUPPER <0xee 0xce>
-MAPUPPER <0xef 0xcf>
-
-MAPUPPER <0xb0 0xb0>
-MAPUPPER <0xb1 0xb1>
-MAPUPPER <0xb2 0xb2>
-MAPUPPER <0xb3 0xb3>
-MAPUPPER <0xb4 0xb4>
-MAPUPPER <0xb5 0xb5>
-MAPUPPER <0xa1 0xa1>
-MAPUPPER <0xb6 0xb6>
-MAPUPPER <0xb7 0xb7>
-MAPUPPER <0xb8 0xb8>
-MAPUPPER <0xb9 0xb9>
-MAPUPPER <0xba 0xba>
-MAPUPPER <0xbb 0xbb>
-MAPUPPER <0xbc 0xbc>
-MAPUPPER <0xbd 0xbd>
-MAPUPPER <0xbe 0xbe>
-MAPUPPER <0xbf 0xbf>
-MAPUPPER <0xc0 0xc0>
-MAPUPPER <0xc1 0xc1>
-MAPUPPER <0xc2 0xc2>
-MAPUPPER <0xc3 0xc3>
-MAPUPPER <0xc4 0xc4>
-MAPUPPER <0xc5 0xc5>
-MAPUPPER <0xc6 0xc6>
-MAPUPPER <0xc7 0xc7>
-MAPUPPER <0xc8 0xc8>
-MAPUPPER <0xc9 0xc9>
-MAPUPPER <0xca 0xca>
-MAPUPPER <0xcb 0xcb>
-MAPUPPER <0xcc 0xcc>
-MAPUPPER <0xcd 0xcd>
-MAPUPPER <0xce 0xce>
-MAPUPPER <0xcf 0xcf>
-
-TODIGIT <'0' - '9' : 0>
-TODIGIT <'A' - 'F' : 10>
-TODIGIT <'a' - 'f' : 10>
diff --git a/share/mklocale/ru_RU.ISO_8859-5.src b/share/mklocale/ru_RU.ISO_8859-5.src
deleted file mode 100644
index 68b39e77842e..000000000000
--- a/share/mklocale/ru_RU.ISO_8859-5.src
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * LOCALE_CTYPE for Russian part of ISO8859-5 set
- *
- * $FreeBSD$
- */
-
-ENCODING "NONE"
-VARIABLE Russian part of ISO8859-5 character set by nms@ethereal.ru
-
-ALPHA 'A' - 'Z' 'a' - 'z' \
- 0xd0 0xd1 0xd2 0xd3 0xd4 0xd5 0xf1 0xd6 \
- 0xd7 0xd8 0xd9 0xda 0xdb 0xdc 0xdd 0xde \
- 0xdf 0xe0 0xe1 0xe2 0xe3 0xe4 0xe5 0xe6 \
- 0xe7 0xe8 0xe9 0xea 0xeb 0xec 0xed 0xee 0xef \
- 0xb0 0xb1 0xb2 0xb3 0xb4 0xb5 0xa1 0xb6 \
- 0xb7 0xb8 0xb9 0xba 0xbb 0xbc 0xbd 0xbe \
- 0xbf 0xc0 0xc1 0xc2 0xc3 0xc4 0xc5 0xc6 \
- 0xc7 0xc8 0xc9 0xca 0xcb 0xcc 0xcd 0xce 0xcf
-BLANK ' ' '\t'
-CONTROL 0x00 - 0x1f 0x7f
-DIGIT '0' - '9'
-GRAPH 0x21 - 0x7e
-LOWER 'a' - 'z' \
- 0xd0 0xd1 0xd2 0xd3 0xd4 0xd5 0xf1 0xd6 \
- 0xd7 0xd8 0xd9 0xda 0xdb 0xdc 0xdd 0xde \
- 0xdf 0xe0 0xe1 0xe2 0xe3 0xe4 0xe5 0xe6 \
- 0xe7 0xe8 0xe9 0xea 0xeb 0xec 0xed 0xee 0xef
-PRINT 0x20 - 0x7e
-PUNCT 0x21 - 0x2f 0x3a - 0x40 0x5b - 0x60 0x7b - 0x7e
-SPACE 0x09 - 0x0d 0x20
-UPPER 'A' - 'Z' \
- 0xb0 0xb1 0xb2 0xb3 0xb4 0xb5 0xa1 0xb6 \
- 0xb7 0xb8 0xb9 0xba 0xbb 0xbc 0xbd 0xbe \
- 0xbf 0xc0 0xc1 0xc2 0xc3 0xc4 0xc5 0xc6 \
- 0xc7 0xc8 0xc9 0xca 0xcb 0xcc 0xcd 0xce 0xcf
-XDIGIT '0' - '9' 'a' - 'f' 'A' - 'F'
-
-# IDEOGRAM
-# SPECIAL
-# PHONEGRAM
-
-MAPLOWER <'A' - 'Z' : 'a'>
-MAPLOWER <'a' - 'z' : 'a'>
-
-MAPLOWER <0xb0 0xd0>
-MAPLOWER <0xb1 0xd1>
-MAPLOWER <0xb2 0xd2>
-MAPLOWER <0xb3 0xd3>
-MAPLOWER <0xb4 0xd4>
-MAPLOWER <0xb5 0xd5>
-MAPLOWER <0xa1 0xf1>
-MAPLOWER <0xb6 0xd6>
-MAPLOWER <0xb7 0xd7>
-MAPLOWER <0xb8 0xd8>
-MAPLOWER <0xb9 0xd9>
-MAPLOWER <0xba 0xda>
-MAPLOWER <0xbb 0xdb>
-MAPLOWER <0xbc 0xdc>
-MAPLOWER <0xbd 0xdd>
-MAPLOWER <0xbe 0xde>
-MAPLOWER <0xbf 0xdf>
-MAPLOWER <0xc0 0xe0>
-MAPLOWER <0xc1 0xe1>
-MAPLOWER <0xc2 0xe2>
-MAPLOWER <0xc3 0xe3>
-MAPLOWER <0xc4 0xe4>
-MAPLOWER <0xc5 0xe5>
-MAPLOWER <0xc6 0xe6>
-MAPLOWER <0xc7 0xe7>
-MAPLOWER <0xc8 0xe8>
-MAPLOWER <0xc9 0xe9>
-MAPLOWER <0xca 0xea>
-MAPLOWER <0xcb 0xeb>
-MAPLOWER <0xcc 0xec>
-MAPLOWER <0xcd 0xed>
-MAPLOWER <0xce 0xee>
-MAPLOWER <0xcf 0xef>
-
-MAPLOWER <0xd0 0xd0>
-MAPLOWER <0xd1 0xd1>
-MAPLOWER <0xd2 0xd2>
-MAPLOWER <0xd3 0xd3>
-MAPLOWER <0xd4 0xd4>
-MAPLOWER <0xd5 0xd5>
-MAPLOWER <0xf1 0xf1>
-MAPLOWER <0xd6 0xd6>
-MAPLOWER <0xd7 0xd7>
-MAPLOWER <0xd8 0xd8>
-MAPLOWER <0xd9 0xd9>
-MAPLOWER <0xda 0xda>
-MAPLOWER <0xdb 0xdb>
-MAPLOWER <0xdc 0xdc>
-MAPLOWER <0xdd 0xdd>
-MAPLOWER <0xde 0xde>
-MAPLOWER <0xdf 0xdf>
-MAPLOWER <0xe0 0xe0>
-MAPLOWER <0xe1 0xe1>
-MAPLOWER <0xe2 0xe2>
-MAPLOWER <0xe3 0xe3>
-MAPLOWER <0xe4 0xe4>
-MAPLOWER <0xe5 0xe5>
-MAPLOWER <0xe6 0xe6>
-MAPLOWER <0xe7 0xe7>
-MAPLOWER <0xe8 0xe8>
-MAPLOWER <0xe9 0xe9>
-MAPLOWER <0xea 0xea>
-MAPLOWER <0xeb 0xeb>
-MAPLOWER <0xec 0xec>
-MAPLOWER <0xed 0xed>
-MAPLOWER <0xee 0xee>
-MAPLOWER <0xef 0xef>
-
-MAPUPPER <'A' - 'Z' : 'A'>
-MAPUPPER <'a' - 'z' : 'A'>
-
-MAPUPPER <0xd0 0xb0>
-MAPUPPER <0xd1 0xb1>
-MAPUPPER <0xd2 0xb2>
-MAPUPPER <0xd3 0xb3>
-MAPUPPER <0xd4 0xb4>
-MAPUPPER <0xd5 0xb5>
-MAPUPPER <0xf1 0xa1>
-MAPUPPER <0xd6 0xb6>
-MAPUPPER <0xd7 0xb7>
-MAPUPPER <0xd8 0xb8>
-MAPUPPER <0xd9 0xb9>
-MAPUPPER <0xda 0xba>
-MAPUPPER <0xdb 0xbb>
-MAPUPPER <0xdc 0xbc>
-MAPUPPER <0xdd 0xbd>
-MAPUPPER <0xde 0xbe>
-MAPUPPER <0xdf 0xbf>
-MAPUPPER <0xe0 0xc0>
-MAPUPPER <0xe1 0xc1>
-MAPUPPER <0xe2 0xc2>
-MAPUPPER <0xe3 0xc3>
-MAPUPPER <0xe4 0xc4>
-MAPUPPER <0xe5 0xc5>
-MAPUPPER <0xe6 0xc6>
-MAPUPPER <0xe7 0xc7>
-MAPUPPER <0xe8 0xc8>
-MAPUPPER <0xe9 0xc9>
-MAPUPPER <0xea 0xca>
-MAPUPPER <0xeb 0xcb>
-MAPUPPER <0xec 0xcc>
-MAPUPPER <0xed 0xcd>
-MAPUPPER <0xee 0xce>
-MAPUPPER <0xef 0xcf>
-
-MAPUPPER <0xb0 0xb0>
-MAPUPPER <0xb1 0xb1>
-MAPUPPER <0xb2 0xb2>
-MAPUPPER <0xb3 0xb3>
-MAPUPPER <0xb4 0xb4>
-MAPUPPER <0xb5 0xb5>
-MAPUPPER <0xa1 0xa1>
-MAPUPPER <0xb6 0xb6>
-MAPUPPER <0xb7 0xb7>
-MAPUPPER <0xb8 0xb8>
-MAPUPPER <0xb9 0xb9>
-MAPUPPER <0xba 0xba>
-MAPUPPER <0xbb 0xbb>
-MAPUPPER <0xbc 0xbc>
-MAPUPPER <0xbd 0xbd>
-MAPUPPER <0xbe 0xbe>
-MAPUPPER <0xbf 0xbf>
-MAPUPPER <0xc0 0xc0>
-MAPUPPER <0xc1 0xc1>
-MAPUPPER <0xc2 0xc2>
-MAPUPPER <0xc3 0xc3>
-MAPUPPER <0xc4 0xc4>
-MAPUPPER <0xc5 0xc5>
-MAPUPPER <0xc6 0xc6>
-MAPUPPER <0xc7 0xc7>
-MAPUPPER <0xc8 0xc8>
-MAPUPPER <0xc9 0xc9>
-MAPUPPER <0xca 0xca>
-MAPUPPER <0xcb 0xcb>
-MAPUPPER <0xcc 0xcc>
-MAPUPPER <0xcd 0xcd>
-MAPUPPER <0xce 0xce>
-MAPUPPER <0xcf 0xcf>
-
-TODIGIT <'0' - '9' : 0>
-TODIGIT <'A' - 'F' : 10>
-TODIGIT <'a' - 'f' : 10>
diff --git a/share/mklocale/ru_RU.KOI8-R.src b/share/mklocale/ru_RU.KOI8-R.src
deleted file mode 100644
index b9582fe8cfbb..000000000000
--- a/share/mklocale/ru_RU.KOI8-R.src
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * LOCALE_CTYPE for Russian koi8-r character set (RFC1489)
- */
-ENCODING "NONE"
-VARIABLE Russian koi8-r character set by ache@astral.msk.su
-
-#
-# This is a comment
-#
-ALPHA 'A' - 'Z' 'a' - 'z' 0xa3 0xb3 0xc0 - 0xff
-CONTROL 0x00 - 0x1f 0x7f
-DIGIT '0' - '9'
-GRAPH 0x21 - 0x7e 0x80 - 0x99 0x9b - 0xff
-LOWER 'a' - 'z' 0xa3 0xc0 - 0xdf
-PUNCT 0x21 - 0x2f 0x3a - 0x40 0x5b - 0x60 0x7b - 0x7e
-SPACE 0x09 - 0x0d 0x20 0x9a
-UPPER 'A' - 'Z' 0xb3 0xe0 - 0xff
-XDIGIT '0' - '9' 'a' - 'f' 'A' - 'F'
-BLANK ' ' '\t' 0x9a
-PRINT 0x20 - 0x7e 0x80 - 0xff
-# IDEOGRAM
-# SPECIAL
-# PHONEGRAM
-
-MAPLOWER <'A' - 'Z' : 'a'>
-MAPLOWER <'a' - 'z' : 'a'>
-MAPLOWER <0xb3 0xa3>
-MAPLOWER <0xa3 0xa3>
-MAPLOWER <0xe0 - 0xff : 0xc0>
-MAPLOWER <0xc0 - 0xdf : 0xc0>
-MAPUPPER <'A' - 'Z' : 'A'>
-MAPUPPER <'a' - 'z' : 'A'>
-MAPUPPER <0xb3 0xb3>
-MAPUPPER <0xa3 0xb3>
-MAPUPPER <0xe0 - 0xff : 0xe0>
-MAPUPPER <0xc0 - 0xdf : 0xe0>
-TODIGIT <'0' - '9' : 0>
-TODIGIT <'A' - 'F' : 10>
-TODIGIT <'a' - 'f' : 10>
diff --git a/share/mklocale/zh_CN.eucCN.src b/share/mklocale/zh_CN.eucCN.src
deleted file mode 100644
index b298ef5de562..000000000000
--- a/share/mklocale/zh_CN.eucCN.src
+++ /dev/null
@@ -1,167 +0,0 @@
-/*-
- * Copyright (c) 1998, Luoqi Chen
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-ENCODING "EUC"
-VARIABLE 1 0x0000 2 0x8080 2 0x0080 3 0x8000 0x8080
-
-/*
- * Code Set 1
- */
-ALPHA 'A' - 'Z' 'a' - 'z'
-CONTROL 0x00 - 0x1f 0x7f
-DIGIT '0' - '9'
-GRAPH 0x21 - 0x7e
-LOWER 'a' - 'z'
-PUNCT 0x21 - 0x2f 0x3a - 0x40 0x5b - 0x60 0x7b - 0x7e
-SPACE 0x09 - 0x0d 0x20
-UPPER 'A' - 'Z'
-XDIGIT '0' - '9' 'a' - 'f' 'A' - 'F'
-BLANK ' ' '\t'
-PRINT 0x20 - 0x7e
-
-MAPLOWER < 'A' - 'Z' : 'a' > < 'a' - 'z' : 'a' >
-MAPUPPER < 'A' - 'Z' : 'A' > < 'a' - 'z' : 'A' >
-TODIGIT < '0' - '9' : 0 >
-TODIGIT < 'A' - 'F' : 10 > < 'a' - 'f' : 10 >
-
-/*
- * Code Set 2
- */
-SPACE 0xa1a1
-BLANK 0xa1a1
-PUNCT 0xa1a2 - 0xa1fe
-
-DIGIT 0xa2b1 - 0xa2e2 0xa2e5 - 0xa2ee 0xa2f1 - 0xa2fc
-
-TODIGIT < 0xa2b1 - 0xa2c4 : 0 >
-TODIGIT < 0xa2c5 - 0xa2d8 : 0 >
-TODIGIT < 0xa2d9 - 0xa2e2 : 0 >
-TODIGIT < 0xa2e5 - 0xa2ee : 0 >
-TODIGIT < 0xa2f1 - 0xa2fc : 0 >
-
-ALPHA 0xa3c1 - 0xa3da 0xa3e1 - 0xa3fa
-DIGIT 0xa3b0 - 0xa3b9
-UPPER 0xa3c1 - 0xa3da
-LOWER 0xa3e1 - 0xa3fa
-PUNCT 0xa3a1 - 0xa3af 0xa3ba - 0xa3c0 0xa3db - 0xa3e0 0xa3fb - 0xa3fe
-XDIGIT 0xa3b0 - 0xa3b9 0xa3c1 - 0xa3c6 0xa3e1 - 0xa3e6
-
-MAPLOWER < 0xa3c1 - 0xa3da : 0xa3e1 > < 0xa3e1 - 0xa3fa : 0xa3e1 >
-MAPUPPER < 0xa3c1 - 0xa3da : 0xa3c1 > < 0xa3b0 - 0xa3b9 : 0xa3c1 >
-TODIGIT < 0xa3b0 - 0xa3b9 : 0 >
-TODIGIT < 0xa3c1 - 0xa3c6 : 10 > < 0xa3e1 - 0xa3e6 : 10 >
-
-PHONOGRAM 0xa4a1 - 0xa4f3 /* Hiragana */
-PHONOGRAM 0xa5a1 - 0xa5f6 /* Katakana */
-
-UPPER 0xa6a1 - 0xa6b8 /* Greek */
-LOWER 0xa6c1 - 0xa6d8 /* Greek */
-MAPLOWER < 0xa6a1 - 0xa6b8 : 0xa6c1 > < 0xa6c1 - 0xa6d8 : 0xa6c1 >
-MAPUPPER < 0xa6a1 - 0xa6b8 : 0xa6a1 > < 0xa6c1 - 0xa6d8 : 0xa6a1 >
-
-UPPER 0xa7a1 - 0xa7c1 /* Cyrillic */
-LOWER 0xa7d1 - 0xa7f1 /* Cyrillic */
-MAPLOWER < 0xa7a1 - 0xa7c1 : 0xa7d1 > < 0xa7d1 - 0xa7f1 : 0xa7d1 >
-MAPUPPER < 0xa7a1 - 0xa7c1 : 0xa7a1 > < 0xa7d1 - 0xa7f1 : 0xa7a1 >
-
-SPECIAL 0xa8a1 - 0xa8ba
-PHONOGRAM 0xa8c5 - 0xa8e9 /* Pin yin */
-SPECIAL 0xa9a4 - 0xa9ef /* Box drawings */
-
-IDEOGRAM 0xb0a1 - 0xb0fe
-IDEOGRAM 0xb1a1 - 0xb1fe
-IDEOGRAM 0xb2a1 - 0xb2fe
-IDEOGRAM 0xb3a1 - 0xb3fe
-IDEOGRAM 0xb4a1 - 0xb4fe
-IDEOGRAM 0xb5a1 - 0xb5fe
-IDEOGRAM 0xb6a1 - 0xb6fe
-IDEOGRAM 0xb7a1 - 0xb7fe
-IDEOGRAM 0xb8a1 - 0xb8fe
-IDEOGRAM 0xb9a1 - 0xb9fe
-IDEOGRAM 0xbaa1 - 0xbafe
-IDEOGRAM 0xbba1 - 0xbbfe
-IDEOGRAM 0xbca1 - 0xbcfe
-IDEOGRAM 0xbda1 - 0xbdfe
-IDEOGRAM 0xbea1 - 0xbefe
-IDEOGRAM 0xbfa1 - 0xbffe
-IDEOGRAM 0xc0a1 - 0xc0fe
-IDEOGRAM 0xc1a1 - 0xc1fe
-IDEOGRAM 0xc2a1 - 0xc2fe
-IDEOGRAM 0xc3a1 - 0xc3fe
-IDEOGRAM 0xc4a1 - 0xc4fe
-IDEOGRAM 0xc5a1 - 0xc5fe
-IDEOGRAM 0xc6a1 - 0xc6fe
-IDEOGRAM 0xc7a1 - 0xc7fe
-IDEOGRAM 0xc8a1 - 0xc8fe
-IDEOGRAM 0xc9a1 - 0xc9fe
-IDEOGRAM 0xcaa1 - 0xcafe
-IDEOGRAM 0xcba1 - 0xcbfe
-IDEOGRAM 0xcca1 - 0xccfe
-IDEOGRAM 0xcda1 - 0xcdfe
-IDEOGRAM 0xcea1 - 0xcefe
-IDEOGRAM 0xcfa1 - 0xcfd3
-IDEOGRAM 0xd0a1 - 0xd0fe
-IDEOGRAM 0xd1a1 - 0xd1fe
-IDEOGRAM 0xd2a1 - 0xd2fe
-IDEOGRAM 0xd3a1 - 0xd3fe
-IDEOGRAM 0xd4a1 - 0xd4fe
-IDEOGRAM 0xd5a1 - 0xd5fe
-IDEOGRAM 0xd6a1 - 0xd6fe
-IDEOGRAM 0xd7a1 - 0xd7fe
-IDEOGRAM 0xd8a1 - 0xd8fe
-IDEOGRAM 0xd9a1 - 0xd9fe
-IDEOGRAM 0xdaa1 - 0xdafe
-IDEOGRAM 0xdba1 - 0xdbfe
-IDEOGRAM 0xdca1 - 0xdcfe
-IDEOGRAM 0xdda1 - 0xddfe
-IDEOGRAM 0xdea1 - 0xdefe
-IDEOGRAM 0xdfa1 - 0xdffe
-IDEOGRAM 0xe0a1 - 0xe0fe
-IDEOGRAM 0xe1a1 - 0xe1fe
-IDEOGRAM 0xe2a1 - 0xe2fe
-IDEOGRAM 0xe3a1 - 0xe3fe
-IDEOGRAM 0xe4a1 - 0xe4fe
-IDEOGRAM 0xe5a1 - 0xe5fe
-IDEOGRAM 0xe6a1 - 0xe6fe
-IDEOGRAM 0xe7a1 - 0xe7fe
-IDEOGRAM 0xe8a1 - 0xe8fe
-IDEOGRAM 0xe9a1 - 0xe9fe
-IDEOGRAM 0xeaa1 - 0xeafe
-IDEOGRAM 0xeba1 - 0xebfe
-IDEOGRAM 0xeca1 - 0xecfe
-IDEOGRAM 0xeda1 - 0xedfe
-IDEOGRAM 0xeea1 - 0xeefe
-IDEOGRAM 0xefa1 - 0xeffe
-IDEOGRAM 0xf0a1 - 0xf0fe
-IDEOGRAM 0xf1a1 - 0xf1fe
-IDEOGRAM 0xf2a1 - 0xf2fe
-IDEOGRAM 0xf3a1 - 0xf3fe
-IDEOGRAM 0xf4a1 - 0xf4fe
-IDEOGRAM 0xf5a1 - 0xf5fe
-IDEOGRAM 0xf6a1 - 0xf6fe
-IDEOGRAM 0xf7a1 - 0xf7fe
diff --git a/share/syscons/keymaps/pl_PL.ISO8859-2.kbd b/share/syscons/keymaps/pl_PL.ISO8859-2.kbd
deleted file mode 100644
index 791b8889947a..000000000000
--- a/share/syscons/keymaps/pl_PL.ISO8859-2.kbd
+++ /dev/null
@@ -1,115 +0,0 @@
-# Polish ISO-8859-2 keymap by Krzysztof Mlynarski (17:46 27-04-1996 MET DST)
-# (krzysio@hydra.mimuw.edu.pl)
-# alt
-# scan cntrl alt alt cntrl lock
-# code base shift cntrl shift alt shift cntrl shift state
-# ------------------------------------------------------------------
- 000 nop nop nop nop nop nop nop nop O
- 001 esc esc esc esc esc esc debug esc O
- 002 '1' '!' nop nop '1' '!' nop nop O
- 003 '2' '@' nul nul '2' '@' nul nul O
- 004 '3' '#' nop nop '3' '#' nop nop O
- 005 '4' '$' nop nop '4' '$' nop nop O
- 006 '5' '%' nop nop '5' '%' nop nop O
- 007 '6' '^' rs rs '6' '^' rs rs O
- 008 '7' '&' nop nop '7' '&' nop nop O
- 009 '8' '*' nop nop '8' '*' nop nop O
- 010 '9' '(' nop nop '9' '(' nop nop O
- 011 '0' ')' nop nop '0' ')' nop nop O
- 012 '-' '_' us us '-' '_' us us O
- 013 '=' '+' nop nop '=' '+' nop nop O
- 014 bs bs del del bs bs del del O
- 015 ht btab nop nop ht btab nop nop O
- 016 'q' 'Q' dc1 dc1 'q' 'Q' dc1 dc1 C
- 017 'w' 'W' etb etb 'w' 'W' etb etb C
- 018 'e' 'E' enq enq 234 202 enq enq C
- 019 'r' 'R' dc2 dc2 'r' 'R' dc2 dc2 C
- 020 't' 'T' dc4 dc4 't' 'T' dc4 dc4 C
- 021 'y' 'Y' em em 'y' 'Y' em em C
- 022 'u' 'U' nak nak 'u' 'U' nak nak C
- 023 'i' 'I' ht ht 'i' 'I' ht ht C
- 024 'o' 'O' si si 243 211 si si C
- 025 'p' 'P' dle dle 'p' 'P' dle dle C
- 026 '[' '{' esc esc '[' '{' esc esc O
- 027 ']' '}' gs gs ']' '}' gs gs O
- 028 cr cr nl nl cr cr nl nl O
- 029 lctrl lctrl lctrl lctrl lctrl lctrl lctrl lctrl O
- 030 'a' 'A' soh soh 177 161 soh soh C
- 031 's' 'S' dc3 dc3 182 166 dc3 dc3 C
- 032 'd' 'D' eot eot 'd' 'D' eot eot C
- 033 'f' 'F' ack ack 'f' 'F' ack ack C
- 034 'g' 'G' bel bel 'g' 'G' bel bel C
- 035 'h' 'H' bs bs 'h' 'H' bs bs C
- 036 'j' 'J' nl nl 'j' 'J' nl nl C
- 037 'k' 'K' vt vt 'k' 'K' vt vt C
- 038 'l' 'L' ff ff 179 163 ff ff C
- 039 ';' ':' nop nop ';' ':' nop nop O
- 040 ''' '"' nop nop ''' '"' nop nop O
- 041 '`' '~' nop nop '`' '~' nop nop O
- 042 lshift lshift lshift lshift lshift lshift lshift lshift O
- 043 '\' '|' fs fs '\' '|' fs fs O
- 044 'z' 'Z' sub sub 191 175 sub sub C
- 045 'x' 'X' can can 188 172 can can C
- 046 'c' 'C' etx etx 230 198 etx etx C
- 047 'v' 'V' syn syn 'v' 'V' syn syn C
- 048 'b' 'B' stx stx 'b' 'B' stx stx C
- 049 'n' 'N' so so 241 209 so so C
- 050 'm' 'M' cr cr 'm' 'M' cr cr C
- 051 ',' '<' nop nop ',' '<' nop nop O
- 052 '.' '>' nop nop '.' '>' nop nop O
- 053 '/' '?' nop nop '/' '?' nop nop O
- 054 rshift rshift rshift rshift rshift rshift rshift rshift O
- 055 '*' '*' '*' '*' '*' '*' '*' '*' O
- 056 lalt lalt lalt lalt lalt lalt lalt lalt O
- 057 ' ' ' ' nul ' ' ' ' ' ' susp ' ' O
- 058 clock clock clock clock clock clock clock clock O
- 059 fkey01 fkey13 fkey25 fkey37 scr01 scr11 scr01 scr11 O
- 060 fkey02 fkey14 fkey26 fkey38 scr02 scr12 scr02 scr12 O
- 061 fkey03 fkey15 fkey27 fkey39 scr03 scr13 scr03 scr13 O
- 062 fkey04 fkey16 fkey28 fkey40 scr04 scr14 scr04 scr14 O
- 063 fkey05 fkey17 fkey29 fkey41 scr05 scr15 scr05 scr15 O
- 064 fkey06 fkey18 fkey30 fkey42 scr06 scr16 scr06 scr16 O
- 065 fkey07 fkey19 fkey31 fkey43 scr07 scr07 scr07 scr07 O
- 066 fkey08 fkey20 fkey32 fkey44 scr08 scr08 scr08 scr08 O
- 067 fkey09 fkey21 fkey33 fkey45 scr09 scr09 scr09 scr09 O
- 068 fkey10 fkey22 fkey34 fkey46 scr10 scr10 scr10 scr10 O
- 069 nlock nlock nlock nlock nlock nlock nlock nlock O
- 070 slock slock slock slock slock slock slock slock O
- 071 fkey49 '7' '7' '7' '7' '7' '7' '7' N
- 072 fkey50 '8' '8' '8' '8' '8' '8' '8' N
- 073 fkey51 '9' '9' '9' '9' '9' '9' '9' N
- 074 fkey52 '-' '-' '-' '-' '-' '-' '-' N
- 075 fkey53 '4' '4' '4' '4' '4' '4' '4' N
- 076 fkey54 '5' '5' '5' '5' '5' '5' '5' N
- 077 fkey55 '6' '6' '6' '6' '6' '6' '6' N
- 078 fkey56 '+' '+' '+' '+' '+' '+' '+' N
- 079 fkey57 '1' '1' '1' '1' '1' '1' '1' N
- 080 fkey58 '2' '2' '2' '2' '2' '2' '2' N
- 081 fkey59 '3' '3' '3' '3' '3' '3' '3' N
- 082 fkey60 '0' '0' '0' '0' '0' '0' '0' N
- 083 del '.' '.' '.' '.' '.' boot boot N
- 084 nop nop nop nop nop nop nop nop O
- 085 nop nop nop nop nop nop nop nop O
- 086 nop nop nop nop nop nop nop nop O
- 087 fkey11 fkey23 fkey35 fkey47 scr11 scr11 scr11 scr11 O
- 088 fkey12 fkey24 fkey36 fkey48 scr12 scr12 scr12 scr12 O
- 089 cr cr cr cr cr cr cr cr O
- 090 rctrl rctrl rctrl rctrl rctrl rctrl rctrl rctrl O
- 091 '/' '/' '/' '/' '/' '/' '/' '/' O
- 092 nscr nscr debug debug nop nop nop nop O
- 093 ralt ralt ralt ralt ralt ralt ralt ralt O
- 094 fkey49 fkey49 fkey49 fkey49 fkey49 fkey49 fkey49 fkey49 O
- 095 fkey50 fkey50 fkey50 fkey50 fkey50 fkey50 fkey50 fkey50 O
- 096 fkey51 fkey51 fkey51 fkey51 fkey51 fkey51 fkey51 fkey51 O
- 097 fkey53 fkey53 fkey53 fkey53 fkey53 fkey53 fkey53 fkey53 O
- 098 fkey55 fkey55 fkey55 fkey55 fkey55 fkey55 fkey55 fkey55 O
- 099 fkey57 fkey57 fkey57 fkey57 fkey57 fkey57 fkey57 fkey57 O
- 100 fkey58 fkey58 fkey58 fkey58 fkey58 fkey58 fkey58 fkey58 O
- 101 fkey59 fkey59 fkey59 fkey59 fkey59 fkey59 fkey59 fkey59 O
- 102 fkey60 fkey60 fkey60 fkey60 fkey60 fkey60 fkey60 fkey60 O
- 103 fkey61 fkey61 fkey61 fkey61 fkey61 fkey61 boot fkey61 O
- 104 slock saver slock saver susp nop susp nop O
- 105 fkey62 fkey62 fkey62 fkey62 fkey62 fkey62 fkey62 fkey62 O
- 106 fkey63 fkey63 fkey63 fkey63 fkey63 fkey63 fkey63 fkey63 O
- 107 fkey64 fkey64 fkey64 fkey64 fkey64 fkey64 fkey64 fkey64 O
- 108 nop nop nop nop nop nop nop nop O
diff --git a/share/syscons/keymaps/uk.cp850-ctrl.kbd b/share/syscons/keymaps/uk.cp850-ctrl.kbd
deleted file mode 100644
index 012ba0962266..000000000000
--- a/share/syscons/keymaps/uk.cp850-ctrl.kbd
+++ /dev/null
@@ -1,113 +0,0 @@
-# alt
-# scan cntrl alt alt cntrl lock
-# code base shift cntrl shift alt shift cntrl shift state
-# ------------------------------------------------------------------
- 000 nop nop nop nop nop nop nop nop O
- 001 esc esc esc esc esc esc debug esc O
- 002 '1' '!' nop nop '1' '!' nop nop O
- 003 '2' '"' nul nul '2' '"' nul nul O
- 004 '3' 156 nop nop '3' 156 nop nop O
- 005 '4' '$' nop nop '4' '$' nop nop O
- 006 '5' '%' nop nop '5' '%' nop nop O
- 007 '6' '^' rs rs '6' '^' rs rs O
- 008 '7' '&' nop nop '7' '&' nop nop O
- 009 '8' '*' nop nop '8' '*' nop nop O
- 010 '9' '(' nop nop '9' '(' nop nop O
- 011 '0' ')' nop nop '0' ')' nop nop O
- 012 '-' '_' us us '-' '_' us us O
- 013 '=' '+' nop nop '=' '+' nop nop O
- 014 bs bs del del bs bs del del O
- 015 ht btab nop nop ht btab nop nop O
- 016 'q' 'Q' dc1 dc1 'q' 'Q' dc1 dc1 C
- 017 'w' 'W' etb etb 'w' 'W' etb etb C
- 018 'e' 'E' enq enq 'e' 'E' enq enq C
- 019 'r' 'R' dc2 dc2 'r' 'R' dc2 dc2 C
- 020 't' 'T' dc4 dc4 't' 'T' dc4 dc4 C
- 021 'y' 'Y' em em 'y' 'Y' em em C
- 022 'u' 'U' nak nak 'u' 'U' nak nak C
- 023 'i' 'I' ht ht 'i' 'I' ht ht C
- 024 'o' 'O' si si 'o' 'O' si si C
- 025 'p' 'P' dle dle 'p' 'P' dle dle C
- 026 '[' '{' esc esc '[' '{' esc esc O
- 027 ']' '}' gs gs ']' '}' gs gs O
- 028 cr cr nl nl cr cr nl nl O
- 029 lctrl lctrl lctrl lctrl lctrl lctrl lctrl lctrl O
- 030 'a' 'A' soh soh 'a' 'A' soh soh C
- 031 's' 'S' dc3 dc3 's' 'S' dc3 dc3 C
- 032 'd' 'D' eot eot 'd' 'D' eot eot C
- 033 'f' 'F' ack ack 'f' 'F' ack ack C
- 034 'g' 'G' bel bel 'g' 'G' bel bel C
- 035 'h' 'H' bs bs 'h' 'H' bs bs C
- 036 'j' 'J' nl nl 'j' 'J' nl nl C
- 037 'k' 'K' vt vt 'k' 'K' vt vt C
- 038 'l' 'L' ff ff 'l' 'L' ff ff C
- 039 ';' ':' nop nop ';' ':' nop nop O
- 040 ''' '@' nul nul ''' '@' nul nul O
- 041 '`' 170 nop nop '|' '|' nop nop O
- 042 lshift lshift lshift lshift lshift lshift lshift lshift O
- 043 '#' '~' nop nop '#' '~' nop nop O
- 044 'z' 'Z' sub sub 'z' 'Z' sub sub C
- 045 'x' 'X' can can 'x' 'X' can can C
- 046 'c' 'C' etx etx 'c' 'C' etx etx C
- 047 'v' 'V' syn syn 'v' 'V' syn syn C
- 048 'b' 'B' stx stx 'b' 'B' stx stx C
- 049 'n' 'N' so so 'n' 'N' so so C
- 050 'm' 'M' cr cr 'm' 'M' cr cr C
- 051 ',' '<' nop nop ',' '<' nop nop O
- 052 '.' '>' nop nop '.' '>' nop nop O
- 053 '/' '?' nop nop '/' '?' nop nop O
- 054 rshift rshift rshift rshift rshift rshift rshift rshift O
- 055 '*' '*' '*' '*' '*' '*' '*' '*' O
- 056 lalt lalt lalt lalt lalt lalt lalt lalt O
- 057 ' ' ' ' nul ' ' ' ' ' ' susp ' ' O
- 058 clock clock clock clock clock clock clock clock O
- 059 fkey01 fkey13 fkey25 fkey37 scr01 scr11 scr01 scr11 O
- 060 fkey02 fkey14 fkey26 fkey38 scr02 scr12 scr02 scr12 O
- 061 fkey03 fkey15 fkey27 fkey39 scr03 scr13 scr03 scr13 O
- 062 fkey04 fkey16 fkey28 fkey40 scr04 scr14 scr04 scr14 O
- 063 fkey05 fkey17 fkey29 fkey41 scr05 scr15 scr05 scr15 O
- 064 fkey06 fkey18 fkey30 fkey42 scr06 scr16 scr06 scr16 O
- 065 fkey07 fkey19 fkey31 fkey43 scr07 scr07 scr07 scr07 O
- 066 fkey08 fkey20 fkey32 fkey44 scr08 scr08 scr08 scr08 O
- 067 fkey09 fkey21 fkey33 fkey45 scr09 scr09 scr09 scr09 O
- 068 fkey10 fkey22 fkey34 fkey46 scr10 scr10 scr10 scr10 O
- 069 nlock nlock nlock nlock nlock nlock nlock nlock O
- 070 slock slock slock slock slock slock slock slock O
- 071 fkey49 '7' '7' '7' '7' '7' '7' '7' N
- 072 fkey50 '8' '8' '8' '8' '8' '8' '8' N
- 073 fkey51 '9' '9' '9' '9' '9' '9' '9' N
- 074 fkey52 '-' '-' '-' '-' '-' '-' '-' N
- 075 fkey53 '4' '4' '4' '4' '4' '4' '4' N
- 076 fkey54 '5' '5' '5' '5' '5' '5' '5' N
- 077 fkey55 '6' '6' '6' '6' '6' '6' '6' N
- 078 fkey56 '+' '+' '+' '+' '+' '+' '+' N
- 079 fkey57 '1' '1' '1' '1' '1' '1' '1' N
- 080 fkey58 '2' '2' '2' '2' '2' '2' '2' N
- 081 fkey59 '3' '3' '3' '3' '3' '3' '3' N
- 082 fkey60 '0' '0' '0' '0' '0' '0' '0' N
- 083 del '.' '.' '.' '.' '.' boot boot N
- 084 nop nop nop nop nop nop nop nop O
- 085 nop nop nop nop nop nop nop nop O
- 086 '\' '|' fs fs '\' '|' fs fs O
- 087 fkey11 fkey23 fkey35 fkey47 scr11 scr11 scr11 scr11 O
- 088 fkey12 fkey24 fkey36 fkey48 scr12 scr12 scr12 scr12 O
- 089 cr cr nl nl cr cr nl nl O
- 090 rctrl rctrl rctrl rctrl rctrl rctrl rctrl rctrl O
- 091 '/' '/' '/' '/' '/' '/' '/' '/' N
- 092 nscr nscr debug debug nop nop nop nop O
- 093 ralt ralt ralt ralt ralt ralt ralt ralt O
- 094 fkey49 fkey49 fkey49 fkey49 fkey49 fkey49 fkey49 fkey49 O
- 095 fkey50 fkey50 fkey50 fkey50 fkey50 fkey50 fkey50 fkey50 O
- 096 fkey51 fkey51 fkey51 fkey51 fkey51 fkey51 fkey51 fkey51 O
- 097 fkey53 fkey53 fkey53 fkey53 fkey53 fkey53 fkey53 fkey53 O
- 098 fkey55 fkey55 fkey55 fkey55 fkey55 fkey55 fkey55 fkey55 O
- 099 fkey57 fkey57 fkey57 fkey57 fkey57 fkey57 fkey57 fkey57 O
- 100 fkey58 fkey58 fkey58 fkey58 fkey58 fkey58 fkey58 fkey58 O
- 101 fkey59 fkey59 fkey59 fkey59 fkey59 fkey59 fkey59 fkey59 O
- 102 fkey60 fkey60 fkey60 fkey60 fkey60 fkey60 fkey60 fkey60 O
- 103 fkey61 fkey61 fkey61 fkey61 fkey61 fkey61 boot fkey61 O
- 104 slock saver slock saver susp nop susp nop O
- 105 fkey62 fkey62 fkey62 fkey62 fkey62 fkey62 fkey62 fkey62 O
- 106 fkey63 fkey63 fkey63 fkey63 fkey63 fkey63 fkey63 fkey63 O
- 107 fkey64 fkey64 fkey64 fkey64 fkey64 fkey64 fkey64 fkey64 O
- 108 nop nop nop nop nop nop nop nop O
diff --git a/share/syscons/keymaps/uk.iso-ctrl.kbd b/share/syscons/keymaps/uk.iso-ctrl.kbd
deleted file mode 100644
index a4614b48d9ad..000000000000
--- a/share/syscons/keymaps/uk.iso-ctrl.kbd
+++ /dev/null
@@ -1,113 +0,0 @@
-# alt
-# scan cntrl alt alt cntrl lock
-# code base shift cntrl shift alt shift cntrl shift state
-# ------------------------------------------------------------------
- 000 nop nop nop nop nop nop nop nop O
- 001 esc esc esc esc esc esc debug esc O
- 002 '1' '!' nop nop '`' '`' nop nop O
- 003 '2' '"' nul nul '@' '@' nul nul O
- 004 '3' 163 nop nop '#' '#' nop nop O
- 005 '4' '$' nop nop '4' '$' nop nop O
- 006 '5' '%' nop nop '5' '%' nop nop O
- 007 '6' '^' rs rs '^' '^' rs rs O
- 008 '7' '&' nop nop '[' '[' esc esc O
- 009 '8' '*' nop nop '8' '*' nop nop O
- 010 '9' '(' nop nop ']' ']' gs gs O
- 011 '0' ')' nop nop '{' '{' nop nop O
- 012 '-' '_' us us '|' '|' us us O
- 013 '=' '+' nop nop '}' '}' nop nop O
- 014 bs bs del del bs bs del del O
- 015 ht btab nop nop ht btab nop nop O
- 016 'q' 'Q' dc1 dc1 'q' 'Q' dc1 dc1 C
- 017 'w' 'W' etb etb 'w' 'W' etb etb C
- 018 'e' 'E' enq enq 'e' 'E' enq enq C
- 019 'r' 'R' dc2 dc2 'r' 'R' dc2 dc2 C
- 020 't' 'T' dc4 dc4 't' 'T' dc4 dc4 C
- 021 'y' 'Y' em em 'y' 'Y' em em C
- 022 'u' 'U' nak nak 'u' 'U' nak nak C
- 023 'i' 'I' ht ht 'i' 'I' ht ht C
- 024 'o' 'O' si si 'o' 'O' si si C
- 025 'p' 'P' dle dle 'p' 'P' dle dle C
- 026 '[' '{' esc esc '[' '{' esc esc O
- 027 ']' '}' gs gs ']' '}' gs gs O
- 028 cr cr nl nl cr cr nl nl O
- 029 lctrl lctrl lctrl lctrl lctrl lctrl lctrl lctrl O
- 030 'a' 'A' soh soh 'a' 'A' soh soh C
- 031 's' 'S' dc3 dc3 's' 'S' dc3 dc3 C
- 032 'd' 'D' eot eot 'd' 'D' eot eot C
- 033 'f' 'F' ack ack 'f' 'F' ack ack C
- 034 'g' 'G' bel bel 'g' 'G' bel bel C
- 035 'h' 'H' bs bs 'h' 'H' bs bs C
- 036 'j' 'J' nl nl 'j' 'J' nl nl C
- 037 'k' 'K' vt vt 'k' 'K' vt vt C
- 038 'l' 'L' ff ff 'l' 'L' ff ff C
- 039 ';' ':' nop nop ';' ':' nop nop O
- 040 ''' '@' nul nul ''' '@' nul nul O
- 041 '`' 172 nop nop '|' '|' nop nop O
- 042 lshift lshift lshift lshift lshift lshift lshift lshift O
- 043 '#' '~' nop nop '~' '~' nop nop O
- 044 'z' 'Z' sub sub 'z' 'Z' sub sub C
- 045 'x' 'X' can can 'x' 'X' can can C
- 046 'c' 'C' etx etx 'c' 'C' etx etx C
- 047 'v' 'V' syn syn 'v' 'V' syn syn C
- 048 'b' 'B' stx stx 'b' 'B' stx stx C
- 049 'n' 'N' so so 'n' 'N' so so C
- 050 'm' 'M' cr cr 'm' 'M' cr cr C
- 051 ',' '<' nop nop ',' '<' nop nop O
- 052 '.' '>' nop nop '.' '>' nop nop O
- 053 '/' '?' nop nop '/' '?' nop nop O
- 054 rshift rshift rshift rshift rshift rshift rshift rshift O
- 055 '*' '*' '*' '*' '*' '*' '*' '*' O
- 056 lalt lalt lalt lalt lalt lalt lalt lalt O
- 057 ' ' ' ' nul ' ' ' ' ' ' susp ' ' O
- 058 clock clock clock clock clock clock clock clock O
- 059 fkey01 fkey13 fkey25 fkey37 scr01 scr11 scr01 scr11 O
- 060 fkey02 fkey14 fkey26 fkey38 scr02 scr12 scr02 scr12 O
- 061 fkey03 fkey15 fkey27 fkey39 scr03 scr13 scr03 scr13 O
- 062 fkey04 fkey16 fkey28 fkey40 scr04 scr14 scr04 scr14 O
- 063 fkey05 fkey17 fkey29 fkey41 scr05 scr15 scr05 scr15 O
- 064 fkey06 fkey18 fkey30 fkey42 scr06 scr16 scr06 scr16 O
- 065 fkey07 fkey19 fkey31 fkey43 scr07 scr07 scr07 scr07 O
- 066 fkey08 fkey20 fkey32 fkey44 scr08 scr08 scr08 scr08 O
- 067 fkey09 fkey21 fkey33 fkey45 scr09 scr09 scr09 scr09 O
- 068 fkey10 fkey22 fkey34 fkey46 scr10 scr10 scr10 scr10 O
- 069 nlock nlock nlock nlock nlock nlock nlock nlock O
- 070 slock slock slock slock slock slock slock slock O
- 071 fkey49 '7' '7' '7' '7' '7' '7' '7' N
- 072 fkey50 '8' '8' '8' '8' '8' '8' '8' N
- 073 fkey51 '9' '9' '9' '9' '9' '9' '9' N
- 074 fkey52 '-' '-' '-' '-' '-' '-' '-' N
- 075 fkey53 '4' '4' '4' '4' '4' '4' '4' N
- 076 fkey54 '5' '5' '5' '5' '5' '5' '5' N
- 077 fkey55 '6' '6' '6' '6' '6' '6' '6' N
- 078 fkey56 '+' '+' '+' '+' '+' '+' '+' N
- 079 fkey57 '1' '1' '1' '1' '1' '1' '1' N
- 080 fkey58 '2' '2' '2' '2' '2' '2' '2' N
- 081 fkey59 '3' '3' '3' '3' '3' '3' '3' N
- 082 fkey60 '0' '0' '0' '0' '0' '0' '0' N
- 083 del '.' '.' '.' '.' '.' boot boot N
- 084 nop nop nop nop nop nop nop nop O
- 085 nop nop nop nop nop nop nop nop O
- 086 '\' '|' fs fs '\' '|' fs fs O
- 087 fkey11 fkey23 fkey35 fkey47 scr11 scr11 scr11 scr11 O
- 088 fkey12 fkey24 fkey36 fkey48 scr12 scr12 scr12 scr12 O
- 089 cr cr nl nl cr cr nl nl O
- 090 rctrl rctrl rctrl rctrl rctrl rctrl rctrl rctrl O
- 091 '/' '/' '/' '/' '/' '/' '/' '/' N
- 092 nscr nscr debug debug nop nop nop nop O
- 093 ralt ralt ralt ralt ralt ralt ralt ralt O
- 094 fkey49 fkey49 fkey49 fkey49 fkey49 fkey49 fkey49 fkey49 O
- 095 fkey50 fkey50 fkey50 fkey50 fkey50 fkey50 fkey50 fkey50 O
- 096 fkey51 fkey51 fkey51 fkey51 fkey51 fkey51 fkey51 fkey51 O
- 097 fkey53 fkey53 fkey53 fkey53 fkey53 fkey53 fkey53 fkey53 O
- 098 fkey55 fkey55 fkey55 fkey55 fkey55 fkey55 fkey55 fkey55 O
- 099 fkey57 fkey57 fkey57 fkey57 fkey57 fkey57 fkey57 fkey57 O
- 100 fkey58 fkey58 fkey58 fkey58 fkey58 fkey58 fkey58 fkey58 O
- 101 fkey59 fkey59 fkey59 fkey59 fkey59 fkey59 fkey59 fkey59 O
- 102 fkey60 fkey60 fkey60 fkey60 fkey60 fkey60 fkey60 fkey60 O
- 103 fkey61 fkey61 fkey61 fkey61 fkey61 fkey61 boot fkey61 O
- 104 slock saver slock saver susp nop susp nop O
- 105 fkey62 fkey62 fkey62 fkey62 fkey62 fkey62 fkey62 fkey62 O
- 106 fkey63 fkey63 fkey63 fkey63 fkey63 fkey63 fkey63 fkey63 O
- 107 fkey64 fkey64 fkey64 fkey64 fkey64 fkey64 fkey64 fkey64 O
- 108 nop nop nop nop nop nop nop nop O
diff --git a/share/timedef/cs_CZ.ISO8859-2.src b/share/timedef/cs_CZ.ISO8859-2.src
deleted file mode 100644
index d665e3d175ba..000000000000
--- a/share/timedef/cs_CZ.ISO8859-2.src
+++ /dev/null
@@ -1,104 +0,0 @@
-# Czech month and day names
-# by Rudolf Cejka <cejkar@dcse.fee.vutbr.cz>
-#
-# $FreeBSD$
-#
-# WARNING: spaces may be essential at the end of lines
-# WARNING: empty lines are essential too
-#
-# Short months names
-#
-led
-úno
-bøe
-dub
-kvì
-èrv
-èvc
-srp
-záø
-øíj
-lis
-pro
-#
-# Long months names
-#
-ledna
-února
-bøezna
-dubna
-kvìtna
-èervna
-èervence
-srpna
-záøí
-øíjna
-listopadu
-prosince
-#
-# Short weekdays names
-#
-ne
-po
-út
-st
-èt
-pá
-so
-#
-# Long weekdays names
-#
-nedìle
-pondìlí
-úterý
-støeda
-ètvrtek
-pátek
-sobota
-#
-# X_fmt
-#
-%H:%M:%S
-#
-# x_fmt
-#
-%y/%m/%d
-#
-# c_fmt
-#
-%a %b %e %X %Y
-#
-# am
-#
-dp
-#
-# pm
-#
-od
-#
-# date_fmt
-#
-%a %e. %B %Y %X %Z
-#
-# Long month names in alternative form
-#
-leden
-únor
-bøezen
-duben
-kvìten
-èerven
-èervenec
-srpen
-záøí
-øíjen
-listopad
-prosinec
-#
-# Ef_fmt
-#
-%e %b
-#
-# EF_fmt
-#
-%e. %B
diff --git a/share/timedef/da_DK.ISO8859-1.src b/share/timedef/da_DK.ISO8859-1.src
deleted file mode 100644
index 2390991adc47..000000000000
--- a/share/timedef/da_DK.ISO8859-1.src
+++ /dev/null
@@ -1,101 +0,0 @@
-# $FreeBSD$
-#
-# WARNING: spaces may be essential at the end of lines
-# WARNING: empty lines are essential too
-#
-# Short months names
-#
-Jan
-Feb
-Mar
-Apr
-Maj
-Jun
-Jul
-Aug
-Sep
-Okt
-Nov
-Dec
-#
-# Long months names
-#
-Januar
-Februar
-Marts
-April
-Maj
-Juni
-Juli
-August
-September
-Oktober
-November
-December
-#
-# Short weekdays names
-# (padded with a space to conform with other languages)
-Søn
-Man
-Tir
-Ons
-Tor
-Fre
-Lør
-#
-# Long weekdays names
-#
-Søndag
-Mandag
-Tirsdag
-Onsdag
-Torsdag
-Fredag
-Lørdag
-#
-# X_fmt
-#
-%H:%M:%S
-#
-# x_fmt
-#
-%d.%m.%y
-#
-# c_fmt
-#
-%a %e %b %X %Y
-#
-# am
-#
-am
-#
-# pm
-#
-pm
-#
-# date_fmt
-#
-%a %e %b %Y %X %Z
-#
-# Long months names (alternative)
-#
-Januar
-Februar
-Marts
-April
-Maj
-Juni
-Juli
-August
-September
-Oktober
-November
-December
-#
-# Ef_fmt
-#
-%e %b
-#
-# EF_fmt
-#
-%e %B
diff --git a/share/timedef/de_AT.ISO8859-1.src b/share/timedef/de_AT.ISO8859-1.src
deleted file mode 100644
index e41381baae33..000000000000
--- a/share/timedef/de_AT.ISO8859-1.src
+++ /dev/null
@@ -1,101 +0,0 @@
-# $FreeBSD$
-#
-# WARNING: spaces may be essential at the end of lines
-# WARNING: empty lines are essential too
-#
-# Short months names
-#
-Jan
-Feb
-Mär
-Apr
-Mai
-Jun
-Jul
-Aug
-Sep
-Okt
-Nov
-Dez
-#
-# Long months names
-#
-Jänner
-Februar
-März
-April
-Mai
-Juni
-Juli
-August
-September
-Oktober
-November
-Dezember
-#
-# Short weekdays names
-# (padded with a space to conform with other languages)
-So
-Mo
-Di
-Mi
-Do
-Fr
-Sa
-#
-# Long weekdays names
-#
-Sonntag
-Montag
-Dienstag
-Mittwoch
-Donnerstag
-Freitag
-Samstag
-#
-# X_fmt
-#
-%H:%M:%S
-#
-# x_fmt
-#
-%d.%m.%y
-#
-# c_fmt
-#
-%a %e %b %X %Y
-#
-# am
-#
-am
-#
-# pm
-#
-pm
-#
-# date_fmt
-#
-%a %e %b %Y %X %Z
-#
-# Long months names (alternative)
-#
-Jänner
-Februar
-März
-April
-Mai
-Juni
-Juli
-August
-September
-Oktober
-November
-Dezember
-#
-# Ef_fmt
-#
-%e %b
-#
-# EF_fmt
-#
-%e %B
diff --git a/share/timedef/de_DE.ISO8859-1.src b/share/timedef/de_DE.ISO8859-1.src
deleted file mode 100644
index 24d3918beae9..000000000000
--- a/share/timedef/de_DE.ISO8859-1.src
+++ /dev/null
@@ -1,101 +0,0 @@
-# $FreeBSD$
-#
-# WARNING: spaces may be essential at the end of lines
-# WARNING: empty lines are essential too
-#
-# Short months names
-#
-Jan
-Feb
-Mär
-Apr
-Mai
-Jun
-Jul
-Aug
-Sep
-Okt
-Nov
-Dez
-#
-# Long months names
-#
-Januar
-Februar
-März
-April
-Mai
-Juni
-Juli
-August
-September
-Oktober
-November
-Dezember
-#
-# Short weekdays names
-# (padded with a space to conform with other languages)
-So
-Mo
-Di
-Mi
-Do
-Fr
-Sa
-#
-# Long weekdays names
-#
-Sonntag
-Montag
-Dienstag
-Mittwoch
-Donnerstag
-Freitag
-Samstag
-#
-# X_fmt
-#
-%H:%M:%S
-#
-# x_fmt
-#
-%d.%m.%y
-#
-# c_fmt
-#
-%a %e %b %X %Y
-#
-# am
-#
-am
-#
-# pm
-#
-pm
-#
-# date_fmt
-#
-%a %e %b %Y %X %Z
-#
-# Long months names (alternative)
-#
-Januar
-Februar
-März
-April
-Mai
-Juni
-Juli
-August
-September
-Oktober
-November
-Dezember
-#
-# Ef_fmt
-#
-%e %b
-#
-# EF_fmt
-#
-%e %B
diff --git a/share/timedef/en_GB.ISO8859-1.src b/share/timedef/en_GB.ISO8859-1.src
deleted file mode 100644
index 74783600eaa0..000000000000
--- a/share/timedef/en_GB.ISO8859-1.src
+++ /dev/null
@@ -1,101 +0,0 @@
-# $FreeBSD$
-#
-# WARNING: spaces may be essential at the end of lines
-# WARNING: empty lines are essential too
-#
-# Short month names
-#
-Jan
-Feb
-Mar
-Apr
-May
-Jun
-Jul
-Aug
-Sep
-Oct
-Nov
-Dec
-#
-# Long month names
-#
-January
-February
-March
-April
-May
-June
-July
-August
-September
-October
-November
-December
-#
-# Short weekday names
-#
-Sun
-Mon
-Tue
-Wed
-Thu
-Fri
-Sat
-#
-# Long weekday names
-#
-Sunday
-Monday
-Tuesday
-Wednesday
-Thursday
-Friday
-Saturday
-#
-# X_fmt
-#
-%H:%M:%S
-#
-# x_fmt
-#
-%d/%m/%y
-#
-# c_fmt
-#
-%a %e %b %X %Y
-#
-# am
-#
-am
-#
-# pm
-#
-pm
-#
-# date_fmt
-#
-%a %e %b %Y %X %Z
-#
-# Long months names (alternative)
-#
-January
-February
-March
-April
-May
-June
-July
-August
-September
-October
-November
-December
-#
-# Ef_fmt
-#
-%e %b
-#
-# EF_fmt
-#
-%e %B
diff --git a/share/timedef/en_US.ISO8859-1.src b/share/timedef/en_US.ISO8859-1.src
deleted file mode 100644
index b60daa1af999..000000000000
--- a/share/timedef/en_US.ISO8859-1.src
+++ /dev/null
@@ -1,101 +0,0 @@
-# $FreeBSD$
-#
-# WARNING: spaces may be essential at the end of lines
-# WARNING: empty lines are essential too
-#
-# Short month names
-#
-Jan
-Feb
-Mar
-Apr
-May
-Jun
-Jul
-Aug
-Sep
-Oct
-Nov
-Dec
-#
-# Long month names
-#
-January
-February
-March
-April
-May
-June
-July
-August
-September
-October
-November
-December
-#
-# Short weekday names
-#
-Sun
-Mon
-Tue
-Wed
-Thu
-Fri
-Sat
-#
-# Long weekday names
-#
-Sunday
-Monday
-Tuesday
-Wednesday
-Thursday
-Friday
-Saturday
-#
-# X_fmt
-#
-%H:%M:%S
-#
-# x_fmt
-#
-%m/%d/%y
-#
-# c_fmt
-#
-%a %b %e %X %Y
-#
-# am
-#
-AM
-#
-# pm
-#
-PM
-#
-# date_fmt
-#
-%a %b %e %X %Z %Y
-#
-# Long months names (alternative)
-#
-January
-February
-March
-April
-May
-June
-July
-August
-September
-October
-November
-December
-#
-# Ef_fmt
-#
-%b %e
-#
-# EF_fmt
-#
-%B %e
diff --git a/share/timedef/es_ES.ISO8859-1.src b/share/timedef/es_ES.ISO8859-1.src
deleted file mode 100644
index 44d99823993e..000000000000
--- a/share/timedef/es_ES.ISO8859-1.src
+++ /dev/null
@@ -1,101 +0,0 @@
-# $FreeBSD$
-#
-# WARNING: spaces may be essential at the end of lines
-# WARNING: empty lines are essential too
-#
-# Short months names
-#
-ene
-feb
-mar
-abr
-may
-jun
-jul
-ago
-sep
-oct
-nov
-dic
-#
-# Long months names
-#
-enero
-febrero
-marzo
-abril
-mayo
-junio
-julio
-agosto
-septiembre
-octubre
-noviembre
-diciembre
-#
-# Short weekdays names
-#
-dom
-lun
-mar
-mié
-jue
-vie
-sáb
-#
-# Long weekdays names
-#
-domingo
-lunes
-martes
-miércoles
-jueves
-viernes
-sábado
-#
-# X_fmt
-#
-%H:%M:%S
-#
-# x_fmt
-#
-%d/%m/%y
-#
-# c_fmt
-#
-%a %e %b %X %Y
-#
-# am
-#
-AM
-#
-# pm
-#
-PM
-#
-# date_fmt
-#
-%A, %e de %B de %Y, %X %Z
-#
-# Long months names (alternative)
-#
-enero
-febrero
-marzo
-abril
-mayo
-junio
-julio
-agosto
-septiembre
-octubre
-noviembre
-diciembre
-#
-# Ef_fmt
-#
-%e %b
-#
-# EF_fmt
-#
-%e %B
diff --git a/share/timedef/fi_FI.ISO8859-1.src b/share/timedef/fi_FI.ISO8859-1.src
deleted file mode 100644
index e395727fb6cf..000000000000
--- a/share/timedef/fi_FI.ISO8859-1.src
+++ /dev/null
@@ -1,100 +0,0 @@
-# $FreeBSD$
-# WARNING: spaces may be essential at the end of lines
-# WARNING: empty lines are essential too
-#
-# Short month names
-#
-Tam
-Hel
-Maa
-Huh
-Tou
-Kes
-Hei
-Elo
-Syy
-Lok
-Mar
-Jou
-#
-# Long month names
-#
-Tammikuu
-Helmikuu
-Maaliskuu
-Huhtikuu
-Toukokuu
-Kesäkuu
-Heinäkuu
-Elokuu
-Syyskuu
-Lokakuu
-Marraskuu
-Joulukuu
-#
-# Short weekday names
-# (padded with a space to conform with other languages)
-Su
-Ma
-Ti
-Ke
-To
-Pe
-La
-#
-# Long weekday names
-#
-Sunnuntai
-Maanantai
-Tiistai
-Keskiviikko
-Torstai
-Perjantai
-Lauantai
-#
-# X_fmt
-#
-%H:%M:%S
-#
-# x_fmt
-#
-%d.%m.%y
-#
-# c_fmt
-#
-%a %e %b %X %Y
-#
-# am
-#
-am
-#
-# pm
-#
-pm
-#
-# date_fmt
-#
-%a %e %b %Y %X %Z
-#
-# Long months names (alternative)
-#
-Tammikuu
-Helmikuu
-Maaliskuu
-Huhtikuu
-Toukokuu
-Kesäkuu
-Heinäkuu
-Elokuu
-Syyskuu
-Lokakuu
-Marraskuu
-Joulukuu
-#
-# Ef_fmt
-#
-%e %b
-#
-# EF_fmt
-#
-%e %B
diff --git a/share/timedef/fr_FR.ISO8859-1.src b/share/timedef/fr_FR.ISO8859-1.src
deleted file mode 100644
index bb388da5b48b..000000000000
--- a/share/timedef/fr_FR.ISO8859-1.src
+++ /dev/null
@@ -1,101 +0,0 @@
-# $FreeBSD$
-#
-# WARNING: spaces may be essential at the end of lines
-# WARNING: empty lines are essential too
-#
-# Short months names
-#
-jan
-fév
-mar
-avr
-mai
-jui
-jul
-aoû
-sep
-oct
-nov
-déc
-#
-# Long months names
-#
-janvier
-février
-mars
-avril
-mai
-juin
-juillet
-août
-septembre
-octobre
-novembre
-décembre
-#
-# Short weekdays names
-#
-Dim
-Lun
-Mar
-Mer
-Jeu
-Ven
-Sam
-#
-# Long weekdays names
-#
-Dimanche
-Lundi
-Mardi
-Mercredi
-Jeudi
-Vendredi
-Samedi
-#
-# X_fmt
-#
-%H:%M:%S
-#
-# x_fmt
-#
-%d.%m.%y
-#
-# c_fmt
-#
-%a %e %b %X %Y
-#
-# am
-#
-
-#
-# pm
-#
-pm
-#
-# date_fmt
-#
-%a %e %b %Y %X %Z
-#
-# Long months names (alternative)
-#
-janvier
-février
-mars
-avril
-mai
-juin
-juillet
-août
-septembre
-octobre
-novembre
-décembre
-#
-# Ef_fmt
-#
-%e %b
-#
-# EF_fmt
-#
-%e %B
diff --git a/share/timedef/hr_HR.ISO8859-2.src b/share/timedef/hr_HR.ISO8859-2.src
deleted file mode 100644
index 6b42bceaaca6..000000000000
--- a/share/timedef/hr_HR.ISO8859-2.src
+++ /dev/null
@@ -1,101 +0,0 @@
-# $FreeBSD$
-#
-# WARNING: spaces may be essential at the end of lines
-# WARNING: empty lines are essential too
-#
-# Short months names
-#
-Sij
-Vel
-O¾u
-Tra
-Svi
-Lip
-Srp
-Kol
-Ruj
-Lis
-Stu
-Pro
-#
-# Long months names
-#
-Sijeèanj
-Veljaèa
-O¾ujak
-Travanj
-Svibanj
-Lipanj
-Srpanj
-Kolovoz
-Rujan
-Listopad
-Studeni
-Prosinac
-#
-# Short weekdays names
-# (padded with a space to conform with other languages)
-Ne
-Po
-Ut
-Sr
-Èe
-Pe
-Su
-#
-# Long weekdays names
-#
-Nedjelja
-Ponedjeljak
-Utorak
-Srijeda
-Èetvrtak
-Petak
-Subota
-#
-# X_fmt
-#
-%H:%M:%S
-#
-# x_fmt
-#
-%d.%m.%y
-#
-# c_fmt
-#
-%a %e %b %X %Y
-#
-# am
-#
-am
-#
-# pm
-#
-pm
-#
-# date_fmt
-#
-%a %e %b %Y %X %Z
-#
-# Long months names (alternative)
-#
-Sijeèanj
-Veljaèa
-O¾ujak
-Travanj
-Svibanj
-Lipanj
-Srpanj
-Kolovoz
-Rujan
-Listopad
-Studeni
-Prosinac
-#
-# Ef_fmt
-#
-%e %b
-#
-# EF_fmt
-#
-%e %B
diff --git a/share/timedef/hu_HU.ISO8859-2.src b/share/timedef/hu_HU.ISO8859-2.src
deleted file mode 100644
index 894fb07dd3ce..000000000000
--- a/share/timedef/hu_HU.ISO8859-2.src
+++ /dev/null
@@ -1,101 +0,0 @@
-# This is a Hungarian LC_TIME file for ISO 8859-2 code-table
-# Made by Gabor Zahemszky <zgabor@CoDe.hu>
-# $FreeBSD$
-#
-# Short month names
-#
-Jan
-Feb
-Már
-Ápr
-Máj
-Jún
-Júl
-Aug
-Sze
-Okt
-Nov
-Dec
-#
-# Long month names
-#
-Január
-Február
-Március
-Április
-Május
-Június
-Július
-Augusztus
-Szeptember
-Október
-November
-December
-#
-# Short weekday names
-# (padded with spaces to comform with other languages)
-#
-Vas
-Hét
-Ked
-Sze
-Csü
-Pén
-Szo
-#
-# Long weekday names
-#
-Vasárnap
-Hétfõ
-Kedd
-Szerda
-Csütörtök
-Péntek
-Szombat
-#
-# X_fmt
-#
-%H:%M:%S
-#
-# x_fmt
-#
-%Y/%m/%d
-#
-# c_fmt
-#
-%a %b %e %X %Y
-#
-# am
-#
-de
-#
-# pm
-#
-du
-#
-# date_fmt
-#
-%Y %b %e %a %X %Z
-#
-# Long months names (alternative)
-#
-Január
-Február
-Március
-Április
-Május
-Június
-Július
-Augusztus
-Szeptember
-Október
-November
-December
-#
-# Ef_fmt
-#
-%b %e
-#
-# EF_fmt
-#
-%B %e
diff --git a/share/timedef/is_IS.ISO8859-1.src b/share/timedef/is_IS.ISO8859-1.src
deleted file mode 100644
index 129b1b15c939..000000000000
--- a/share/timedef/is_IS.ISO8859-1.src
+++ /dev/null
@@ -1,101 +0,0 @@
-# $FreeBSD$
-#
-# WARNING: spaces may be essential at the end of lines
-# WARNING: empty lines are essential too
-#
-# Short month names
-#
-jan
-feb
-mar
-apr
-maí
-jún
-júl
-ágú
-sep
-okt
-nóv
-des
-#
-# Long month names
-#
-janúar
-febrúar
-mars
-apríl
-maí
-júní
-júlí
-ágúst
-september
-október
-nóvember
-desember
-#
-# Short weekday names
-#
-sun
-mán
-þri
-mið
-fim
-fös
-lau
-#
-# Long weekday names
-#
-sunnudagur
-mánudagur
-þriðjudagur
-miðvikudagur
-fimmtudagur
-föstudagur
-laugardagur
-#
-# X_fmt
-#
-%H:%M:%S
-#
-# x_fmt
-#
-%d.%m.%y
-#
-# c_fmt
-#
-%a %e %b %X %Y
-#
-# am
-#
-fh
-#
-# pm
-#
-eh
-#
-# date_fmt
-#
-%a %e %b %Y %X %Z
-#
-# Long months names (alternative)
-#
-janúar
-febrúar
-mars
-apríl
-maí
-júní
-júlí
-ágúst
-september
-október
-nóvember
-desember
-#
-# Ef_fmt
-#
-%e %b
-#
-# EF_fmt
-#
-%e %B
diff --git a/share/timedef/it_IT.ISO8859-1.src b/share/timedef/it_IT.ISO8859-1.src
deleted file mode 100644
index d15762e0508d..000000000000
--- a/share/timedef/it_IT.ISO8859-1.src
+++ /dev/null
@@ -1,101 +0,0 @@
-# $FreeBSD$
-#
-# WARNING: spaces may be essential at the end of lines
-# WARNING: empty lines are essential too
-#
-# Short month names
-#
-Gen
-Feb
-Mar
-Apr
-Mag
-Giu
-Lug
-Ago
-Set
-Ott
-Nov
-Dic
-#
-# Long month names
-#
-Gennaio
-Febbraio
-Marzo
-Aprile
-Maggio
-Giugno
-Luglio
-Agosto
-Settembre
-Ottobre
-Novembre
-Dicembre
-#
-# Short weekday names
-#
-Dom
-Lun
-Mar
-Mer
-Gio
-Ven
-Sab
-#
-# Long weekday names
-#
-Domenica
-Lunedi
-Martedi
-Mercoledi
-Giovedi
-Venerdi
-Sabato
-#
-# X_fmt
-#
-%H:%M:%S
-#
-# x_fmt
-#
-%d.%m.%y
-#
-# c_fmt
-#
-%a %e %b %X %Y
-#
-# am
-#
-am
-#
-# pm
-#
-pm
-#
-# date_fmt
-#
-%a %e %b %Y %X %Z
-#
-# Long months names (alternative)
-#
-Gennaio
-Febbraio
-Marzo
-Aprile
-Maggio
-Giugno
-Luglio
-Agosto
-Settembre
-Ottobre
-Novembre
-Dicembre
-#
-# Ef_fmt
-#
-%e %b
-#
-# EF_fmt
-#
-%e %B
diff --git a/share/timedef/ja_JP.eucJP.src b/share/timedef/ja_JP.eucJP.src
deleted file mode 100644
index 402679128953..000000000000
--- a/share/timedef/ja_JP.eucJP.src
+++ /dev/null
@@ -1,109 +0,0 @@
-# $FreeBSD$
-#
-# WARNING: spaces may be essential at the end of lines
-# WARNING: empty lines are essential too
-#
-# Short month names
-# it must be 3 char
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
-#
-# Long month names
-#
-1·î
-2·î
-3·î
-4·î
-5·î
-6·î
-7·î
-8·î
-9·î
-10·î
-11·î
-12·î
-#
-# Short weekday names
-#
-# it must be 3 char also
-# two char is our weekday name, and be careful one space is in the last
-Æü
-·î
-²Ð
-¿å
-ÌÚ
-¶â
-ÅÚ
-#
-# Long weekday names
-#
-ÆüÍËÆü
-·îÍËÆü
-²ÐÍËÆü
-¿åÍËÆü
-ÌÚÍËÆü
-¶âÍËÆü
-ÅÚÍËÆü
-#
-# X_fmt
-#
-%H»þ%Mʬ%SÉÃ
-#
-# x_fmt
-#
-%y/%m/%d
-#
-# c_fmt
-#
-# just following tradition...
-# %a %b %e %H:%M:%S %Y
-%a %b/%e %T %Y
-#
-# am
-#
-# it must be 2 char
-#¸áÁ°
-AM
-#
-# pm
-#
-# it must be 2 char
-#¸á¸å
-PM
-#
-# date_fmt
-#
-%Yǯ %B%eÆü %A %X %Z
-#
-# Long months names (alternative)
-#
-1·î
-2·î
-3·î
-4·î
-5·î
-6·î
-7·î
-8·î
-9·î
-10·î
-11·î
-12·î
-#
-# Ef_fmt
-#
-%b/%e
-#
-# EF_fmt
-#
-%B %e
diff --git a/share/timedef/ko_KR.eucKR.src b/share/timedef/ko_KR.eucKR.src
deleted file mode 100644
index cd0826e92056..000000000000
--- a/share/timedef/ko_KR.eucKR.src
+++ /dev/null
@@ -1,112 +0,0 @@
-# $FreeBSD$
-#
-# Choi Jun Ho <jazz.snu.ac.kr>
-# 27 Mar 1997
-#
-# WARNING: spaces may be essential at the end of lines
-# WARNING: empty lines are essential too
-#
-# Short month names
-# it must be 3 char
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
-#
-# Long month names
-#
-1¿ù
-2¿ù
-3¿ù
-4¿ù
-5¿ù
-6¿ù
-7¿ù
-8¿ù
-9¿ù
-10¿ù
-11¿ù
-12¿ù
-#
-# Short weekday names
-#
-# it must be 3 char also
-# two char is our weekday name, and be careful one space is in the last
-ÀÏ
-¿ù
-È­
-¼ö
-¸ñ
-±Ý
-Åä
-#
-# Long weekday names
-#
-ÀÏ¿äÀÏ
-¿ù¿äÀÏ
-È­¿äÀÏ
-¼ö¿äÀÏ
-¸ñ¿äÀÏ
-±Ý¿äÀÏ
-Åä¿äÀÏ
-#
-# X_fmt
-#
-%H½Ã %MºÐ %SÃÊ
-#
-# x_fmt
-#
-%y/%m/%d
-#
-# c_fmt
-#
-# just following tradition...
-# %Y³â %b¿ù %eÀÏ %a¿äÀÏ %X
-%a %b %e %H:%M:%S %Y
-#
-# am
-#
-# it must be 2 char
-#¿ÀÀü
-AM
-#
-# pm
-#
-# it must be 2 char
-#¿ÀÈÄ
-PM
-#
-# date_fmt
-#
-%Y³â %b¿ù %eÀÏ %a¿äÀÏ %X %Z
-#
-# Long months names (alternative)
-#
-1¿ù
-2¿ù
-3¿ù
-4¿ù
-5¿ù
-6¿ù
-7¿ù
-8¿ù
-9¿ù
-10¿ù
-11¿ù
-12¿ù
-#
-# Ef_fmt
-#
-%b %e
-#
-# EF_fmt
-#
-%B %e
diff --git a/share/timedef/la_LN.ISO8859-1.src b/share/timedef/la_LN.ISO8859-1.src
deleted file mode 100644
index a890691693d0..000000000000
--- a/share/timedef/la_LN.ISO8859-1.src
+++ /dev/null
@@ -1,103 +0,0 @@
-# $FreeBSD$
-# This is Latin. The week with seven days was introduced in the
-# Roman Empire 321 AD. (Konstantin I)
-#
-# WARNING: spaces may be essential at the end of lines
-# WARNING: empty lines are essential too
-#
-# Short month names
-#
-Ian
-Feb
-Mar
-Apr
-Mai
-Iun
-Iul
-Aug
-Sep
-Oct
-Nov
-Dec
-#
-# Long month names
-#
-Ianuarius
-Februarius
-Martius
-Aprilis
-Maius
-Iunius
-Iulius
-Augustus
-September
-October
-November
-December
-#
-# Short weekday names
-#
-Sol
-Lun
-Mar
-Mer
-Iov
-Ven
-Sat
-#
-# Long weekday names
-#
-dies Solis
-dies Lunae
-dies Martis
-dies Mercurii
-dies Iovis
-dies Veneris
-dies Saturni
-#
-# X_fmt
-#
-%H:%M:%S
-#
-# x_fmt
-#
-%d.%m.%y
-#
-# c_fmt
-#
-%a %e %b %X %Y
-#
-# am
-#
-am
-#
-# pm
-#
-pm
-#
-# date_fmt
-#
-%a %e %b %Y %X %Z
-#
-# Long months names (alternative)
-#
-Ianuarius
-Februarius
-Martius
-Aprilis
-Maius
-Iunius
-Iulius
-Augustus
-September
-October
-November
-December
-#
-# Ef_fmt
-#
-%e %b
-#
-# EF_fmt
-#
-%e %B
diff --git a/share/timedef/lt_LT.ISO8859-4.src b/share/timedef/lt_LT.ISO8859-4.src
deleted file mode 100644
index bb7a7e5e907b..000000000000
--- a/share/timedef/lt_LT.ISO8859-4.src
+++ /dev/null
@@ -1,100 +0,0 @@
-# $FreeBSD$
-# WARNING: spaces may be essential at the end of lines
-# WARNING: empty lines are essential too
-#
-# Short month names
-#
-Sau
-Vas
-Kov
-Bal
-Geg
-Bir
-Lie
-Rgp
-Rgs
-Spa
-Lap
-Grd
-#
-# Long month names
-#
-sausio
-vasario
-kovo
-baland¾io
-gegu¾ìs
-bir¾elio
-liepos
-rugpjþèio
-rugsìjo
-spalio
-lapkrièio
-gruod¾io
-#
-# Short weekday names
-# (padded with a space to conform with other languages)
-Sk
-Pr
-An
-Tr
-Kt
-Pn
-©t
-#
-# Long weekday names
-#
-Sekmadienis
-Pirmadienis
-Antradienis
-Treèiadienis
-Ketvirtadienis
-Penktadienis
-©e¹tadienis
-#
-# X_fmt
-#
-%H:%M:%S
-#
-# x_fmt
-#
-%Y.%m.%d
-#
-# c_fmt
-# %A, %Y m. %B %e d. %T
-%a %b %e %X %Y
-#
-# am
-#
-
-#
-# pm
-#
-
-#
-# date_fmt
-#
-%A, %Y m. %B %e d. %T %Z
-#
-# Long month names in alternative form
-#
-sausio
-vasario
-kovo
-baland¾io
-gegu¾ìs
-bir¾elio
-liepos
-rugpjþèio
-rugsìjo
-spalio
-lapkrièio
-gruod¾io
-#
-# Ef_fmt
-#
-%b %e
-#
-# EF_fmt
-#
-%B %e
diff --git a/share/timedef/nl_NL.ISO8859-1.src b/share/timedef/nl_NL.ISO8859-1.src
deleted file mode 100644
index 315ec98de9e3..000000000000
--- a/share/timedef/nl_NL.ISO8859-1.src
+++ /dev/null
@@ -1,101 +0,0 @@
-# $FreeBSD$
-#
-# WARNING: spaces may be essential at the end of lines
-# WARNING: empty lines are essential too
-#
-# Short month names
-#
-jan
-feb
-mrt
-apr
-mei
-jun
-jul
-aug
-sep
-okt
-nov
-dec
-#
-# Long month names
-#
-januari
-februari
-maart
-april
-mei
-juni
-juli
-augustus
-september
-oktober
-november
-december
-#
-# Short weekday names
-# (padded with a space to conform with other languages)
-zo
-ma
-di
-wo
-do
-vr
-za
-#
-# Long weekday names
-#
-zondag
-maandag
-dinsdag
-woensdag
-donderdag
-vrijdag
-zaterdag
-#
-# X_fmt
-#
-%H:%M:%S
-#
-# x_fmt
-#
-%d-%m-%Y
-#
-# c_fmt
-#
-%a %e %b %X %Y
-#
-# am
-#
-am
-#
-# pm
-#
-pm
-#
-# date_fmt
-#
-%a %e %b %Y %X %Z
-#
-# Long months names (alternative)
-#
-januari
-februari
-maart
-april
-mei
-juni
-juli
-augustus
-september
-oktober
-november
-december
-#
-# Ef_fmt
-#
-%e %b
-#
-# EF_fmt
-#
-%e %B
diff --git a/share/timedef/no_NO.ISO8859-1.src b/share/timedef/no_NO.ISO8859-1.src
deleted file mode 100644
index c182f9c312fe..000000000000
--- a/share/timedef/no_NO.ISO8859-1.src
+++ /dev/null
@@ -1,101 +0,0 @@
-# $FreeBSD$
-#
-# WARNING: spaces may be essential at the end of lines
-# WARNING: empty lines are essential too
-#
-# Short months names
-#
-jan
-feb
-mar
-apr
-mai
-jun
-jul
-aug
-sep
-okt
-nov
-des
-#
-# Long months names
-#
-januar
-februar
-mars
-april
-mai
-juni
-juli
-august
-september
-oktober
-november
-desember
-#
-# Short weekdays names
-# (padded with a space to conform with other languages)
-søn
-man
-tir
-ons
-tor
-fre
-lør
-#
-# Long weekdays names
-#
-søndag
-mandag
-tirsdag
-onsdag
-torsdag
-fredag
-lørdag
-#
-# X_fmt
-#
-%H:%M:%S
-#
-# x_fmt
-#
-%d.%m.%y
-#
-# c_fmt
-#
-%a %e %b %X %Y
-#
-# am
-#
-am
-#
-# pm
-#
-pm
-#
-# date_fmt
-#
-%a %e %b %Y %X %Z
-#
-# Long months names (alternative)
-#
-januar
-februar
-mars
-april
-mai
-juni
-juli
-august
-september
-oktober
-november
-desember
-#
-# Ef_fmt
-#
-%e %b
-#
-# EF_fmt
-#
-%e %B
diff --git a/share/timedef/pl_PL.ISO8859-2.src b/share/timedef/pl_PL.ISO8859-2.src
deleted file mode 100644
index 7dfafee56fdf..000000000000
--- a/share/timedef/pl_PL.ISO8859-2.src
+++ /dev/null
@@ -1,98 +0,0 @@
-# $FreeBSD$
-#
-# Short month names
-#
-Sty
-Lut
-Mar
-Kwi
-Maj
-Cze
-Lip
-Sie
-Wrz
-Paz
-Lis
-Gru
-#
-# Long month names
-#
-Styczeñ
-Luty
-Marzec
-Kwiecieñ
-Maj
-Czerwiec
-Lipiec
-Sierpieñ
-Wrzesieñ
-Pa¼dziernik
-Listopad
-Grudzieñ
-#
-# Short weekday names
-#
-Ndz
-Pon
-Wto
-¦ro
-Czw
-Pi±
-Sob
-#
-# Long weekday names
-#
-Niedziela
-Poniedzia³ek
-Wtorek
-¦roda
-Czwartek
-Pi±tek
-Sobota
-#
-# X_fmt
-#
-%H:%M:%S
-#
-# x_fmt
-#
-%y.%m.%d
-#
-# c_fmt
-#
-%a %e %b %X %Y
-#
-# am
-#
-
-#
-# pm
-#
-
-#
-# date_fmt
-#
-%a %e %b %X %Y %Z
-#
-# Long months names (alternative)
-#
-Styczeñ
-Luty
-Marzec
-Kwiecieñ
-Maj
-Czerwiec
-Lipiec
-Sierpieñ
-Wrzesieñ
-Pa¼dziernik
-Listopad
-Grudzieñ
-#
-# Ef_fmt
-#
-%e %b
-#
-# EF_fmt
-#
-%e %B
diff --git a/share/timedef/pt_PT.ISO8859-1.src b/share/timedef/pt_PT.ISO8859-1.src
deleted file mode 100644
index a201701e061e..000000000000
--- a/share/timedef/pt_PT.ISO8859-1.src
+++ /dev/null
@@ -1,102 +0,0 @@
-# $FreeBSD$
-#
-# WARNING: spaces may be essential at the end of lines
-# WARNING: empty lines are essential too
-# In Portugal we don't use the 12 + am/pm but the 24h format
-#
-# Short months names
-#
-Jan
-Fev
-Mar
-Abr
-Mai
-Jun
-Jul
-Ago
-Set
-Out
-Nov
-Dez
-#
-# Long months names
-#
-Janeiro
-Fevereiro
-Março
-Abril
-Maio
-Junho
-Julho
-Agosto
-Setembro
-Outubro
-Novembro
-Dezembro
-#
-# Short weekdays names
-# (padded with a space to conform with other languages)
-Dom
-Seg
-Ter
-Qua
-Qui
-Sex
-Sáb
-#
-# Long weekdays names
-#
-Domingo
-Segunda Feira
-Terça Feira
-Quarta Feira
-Quinta Feira
-Sexta Feira
-Sábado
-#
-# X_fmt
-#
-%H:%M:%S
-#
-# x_fmt
-#
-%d.%m.%y
-#
-# c_fmt
-#
-%a %e %b %X %Y
-#
-# am
-#
-
-#
-# pm
-#
-pm
-#
-# date_fmt
-#
-%a %e %b %Y %X %Z
-#
-# Long months names (alternative)
-#
-Janeiro
-Fevereiro
-Março
-Abril
-Maio
-Junho
-Julho
-Agosto
-Setembro
-Outubro
-Novembro
-Dezembro
-#
-# Ef_fmt
-#
-%e %b
-#
-# EF_fmt
-#
-%e %B
diff --git a/share/timedef/ru_RU.CP866.src b/share/timedef/ru_RU.CP866.src
deleted file mode 100644
index 0c8a1816c74a..000000000000
--- a/share/timedef/ru_RU.CP866.src
+++ /dev/null
@@ -1,101 +0,0 @@
-# $FreeBSD$
-#
-# WARNING: spaces may be essential at the end of lines
-# WARNING: empty lines are essential too
-#
-# Short months names
-#
-ï­¢
-䥢
-¬ à
- ¯à
-¬ ©
-¨î­
-¨î«
- ¢£
-ᥭ
-®ªâ
-­®ï
-¤¥ª
-#
-# Long months names
-#
-ï­¢ àï
-䥢ࠫï
-¬ àâ 
- ¯à¥«ï
-¬ ï
-¨î­ï
-¨î«ï
- ¢£ãáâ 
-ᥭâï¡àï
-®ªâï¡àï
-­®ï¡àï
-¤¥ª ¡àï
-#
-# Short weekdays names
-#
-¢á
-¯­
-¢â
-áà
-çâ
-¯â
-á¡
-#
-# Long weekdays names
-#
-¢®áªà¥á¥­ì¥
-¯®­¥¤¥«ì­¨ª
-¢â®à­¨ª
-á। 
-ç¥â¢¥à£
-¯ïâ­¨æ 
-áã¡¡®â 
-#
-# X_fmt
-#
-%H:%M:%S
-#
-# x_fmt
-#
-%d.%m.%y
-#
-# c_fmt
-#
-%a %e %b %X %Y
-#
-# am
-# (two spaces)
-
-#
-# pm
-#
-¯¯
-#
-# date_fmt
-#
-%a %e %b %Y %X %Z
-#
-# Long month names in alternative form
-#
-ï­¢ àì
-䥢ࠫì
-¬ àâ
- ¯à¥«ì
-¬ ©
-¨î­ì
-¨î«ì
- ¢£ãáâ
-ᥭâï¡àì
-®ªâï¡àì
-­®ï¡àì
-¤¥ª ¡àì
-#
-# Ef_fmt
-#
-%e %b
-#
-# EF_fmt
-#
-%e %B
diff --git a/share/timedef/ru_RU.ISO8859-5.src b/share/timedef/ru_RU.ISO8859-5.src
deleted file mode 100644
index e52afaaae207..000000000000
--- a/share/timedef/ru_RU.ISO8859-5.src
+++ /dev/null
@@ -1,101 +0,0 @@
-# $FreeBSD$
-#
-# WARNING: spaces may be essential at the end of lines
-# WARNING: empty lines are essential too
-#
-# Short months names
-#
-ïÝÒ
-äÕÒ
-ÜÐà
-Ðßà
-ÜÐÙ
-ØîÝ
-ØîÛ
-ÐÒÓ
-áÕÝ
-ÞÚâ
-ÝÞï
-ÔÕÚ
-#
-# Long months names
-#
-ïÝÒÐàï
-äÕÒàÐÛï
-ÜÐàâÐ
-ÐßàÕÛï
-ÜÐï
-ØîÝï
-ØîÛï
-ÐÒÓãáâÐ
-áÕÝâïÑàï
-ÞÚâïÑàï
-ÝÞïÑàï
-ÔÕÚÐÑàï
-#
-# Short weekdays names
-#
-Òá
-ßÝ
-Òâ
-áà
-çâ
-ßâ
-áÑ
-#
-# Long weekdays names
-#
-ÒÞáÚàÕáÕÝìÕ
-ßÞÝÕÔÕÛìÝØÚ
-ÒâÞàÝØÚ
-áàÕÔÐ
-çÕâÒÕàÓ
-ßïâÝØæÐ
-áãÑÑÞâÐ
-#
-# X_fmt
-#
-%H:%M:%S
-#
-# x_fmt
-#
-%d.%m.%y
-#
-# c_fmt
-#
-%a %e %b %X %Y
-#
-# am
-# (two spaces)
-
-#
-# pm
-#
-ßß
-#
-# date_fmt
-#
-%a %e %b %Y %X %Z
-#
-# Long month names in alternative form
-#
-ïÝÒÐàì
-äÕÒàÐÛì
-ÜÐàâ
-ÐßàÕÛì
-ÜÐÙ
-ØîÝì
-ØîÛì
-ÐÒÓãáâ
-áÕÝâïÑàì
-ÞÚâïÑàì
-ÝÞïÑàì
-ÔÕÚÐÑàì
-#
-# Ef_fmt
-#
-%e %b
-#
-# EF_fmt
-#
-%e %B
diff --git a/share/timedef/ru_RU.ISO_8859-5.src b/share/timedef/ru_RU.ISO_8859-5.src
deleted file mode 100644
index e52afaaae207..000000000000
--- a/share/timedef/ru_RU.ISO_8859-5.src
+++ /dev/null
@@ -1,101 +0,0 @@
-# $FreeBSD$
-#
-# WARNING: spaces may be essential at the end of lines
-# WARNING: empty lines are essential too
-#
-# Short months names
-#
-ïÝÒ
-äÕÒ
-ÜÐà
-Ðßà
-ÜÐÙ
-ØîÝ
-ØîÛ
-ÐÒÓ
-áÕÝ
-ÞÚâ
-ÝÞï
-ÔÕÚ
-#
-# Long months names
-#
-ïÝÒÐàï
-äÕÒàÐÛï
-ÜÐàâÐ
-ÐßàÕÛï
-ÜÐï
-ØîÝï
-ØîÛï
-ÐÒÓãáâÐ
-áÕÝâïÑàï
-ÞÚâïÑàï
-ÝÞïÑàï
-ÔÕÚÐÑàï
-#
-# Short weekdays names
-#
-Òá
-ßÝ
-Òâ
-áà
-çâ
-ßâ
-áÑ
-#
-# Long weekdays names
-#
-ÒÞáÚàÕáÕÝìÕ
-ßÞÝÕÔÕÛìÝØÚ
-ÒâÞàÝØÚ
-áàÕÔÐ
-çÕâÒÕàÓ
-ßïâÝØæÐ
-áãÑÑÞâÐ
-#
-# X_fmt
-#
-%H:%M:%S
-#
-# x_fmt
-#
-%d.%m.%y
-#
-# c_fmt
-#
-%a %e %b %X %Y
-#
-# am
-# (two spaces)
-
-#
-# pm
-#
-ßß
-#
-# date_fmt
-#
-%a %e %b %Y %X %Z
-#
-# Long month names in alternative form
-#
-ïÝÒÐàì
-äÕÒàÐÛì
-ÜÐàâ
-ÐßàÕÛì
-ÜÐÙ
-ØîÝì
-ØîÛì
-ÐÒÓãáâ
-áÕÝâïÑàì
-ÞÚâïÑàì
-ÝÞïÑàì
-ÔÕÚÐÑàì
-#
-# Ef_fmt
-#
-%e %b
-#
-# EF_fmt
-#
-%e %B
diff --git a/share/timedef/ru_RU.KOI8-R.src b/share/timedef/ru_RU.KOI8-R.src
deleted file mode 100644
index bce56a367ba7..000000000000
--- a/share/timedef/ru_RU.KOI8-R.src
+++ /dev/null
@@ -1,101 +0,0 @@
-# $FreeBSD$
-#
-# WARNING: spaces may be essential at the end of lines
-# WARNING: empty lines are essential too
-#
-# Short months names
-#
-ÑÎ×
-ÆÅ×
-ÍÁÒ
-ÁÐÒ
-ÍÁÊ
-ÉÀÎ
-ÉÀÌ
-Á×Ç
-ÓÅÎ
-ÏËÔ
-ÎÏÑ
-ÄÅË
-#
-# Long months names
-#
-ÑÎ×ÁÒÑ
-ÆÅ×ÒÁÌÑ
-ÍÁÒÔÁ
-ÁÐÒÅÌÑ
-ÍÁÑ
-ÉÀÎÑ
-ÉÀÌÑ
-Á×ÇÕÓÔÁ
-ÓÅÎÔÑÂÒÑ
-ÏËÔÑÂÒÑ
-ÎÏÑÂÒÑ
-ÄÅËÁÂÒÑ
-#
-# Short weekdays names
-#
-×Ó
-ÐÎ
-×Ô
-ÓÒ
-ÞÔ
-ÐÔ
-ÓÂ
-#
-# Long weekdays names
-#
-×ÏÓËÒÅÓÅÎØÅ
-ÐÏÎÅÄÅÌØÎÉË
-×ÔÏÒÎÉË
-ÓÒÅÄÁ
-ÞÅÔ×ÅÒÇ
-ÐÑÔÎÉÃÁ
-ÓÕÂÂÏÔÁ
-#
-# X_fmt
-#
-%H:%M:%S
-#
-# x_fmt
-#
-%d.%m.%y
-#
-# c_fmt
-#
-%a %e %b %X %Y
-#
-# am
-# (two spaces)
-
-#
-# pm
-#
-ÐÐ
-#
-# date_fmt
-#
-%a %e %b %Y %X %Z
-#
-# Long month names in alternative form
-#
-ÑÎ×ÁÒØ
-ÆÅ×ÒÁÌØ
-ÍÁÒÔ
-ÁÐÒÅÌØ
-ÍÁÊ
-ÉÀÎØ
-ÉÀÌØ
-Á×ÇÕÓÔ
-ÓÅÎÔÑÂÒØ
-ÏËÔÑÂÒØ
-ÎÏÑÂÒØ
-ÄÅËÁÂÒØ
-#
-# Ef_fmt
-#
-%e %b
-#
-# EF_fmt
-#
-%e %B
diff --git a/share/timedef/sl_SI.ISO8859-2.src b/share/timedef/sl_SI.ISO8859-2.src
deleted file mode 100644
index aeeb33cc2188..000000000000
--- a/share/timedef/sl_SI.ISO8859-2.src
+++ /dev/null
@@ -1,101 +0,0 @@
-# $FreeBSD$
-#
-# WARNING: spaces may be essential at the end of lines
-# WARNING: empty lines are essential too
-#
-# Short months names
-#
-Jan
-Feb
-Mar
-Apr
-Maj
-Jun
-Jul
-Avg
-Sep
-Okt
-Nov
-Dec
-#
-# Long months names
-#
-Januar
-Februar
-Marec
-April
-Maj
-Junij
-Julij
-Avgust
-September
-Oktober
-November
-December
-#
-# Short weekdays names
-#
-Ned
-Pon
-Tor
-Sre
-Èet
-Pet
-Sob
-#
-# Long weekdays names
-#
-Nedelja
-Ponedeljek
-Torek
-Sreda
-Èetrtek
-Petek
-Sobota
-#
-# X_fmt
-#
-%H:%M:%S
-#
-# x_fmt
-#
-%d.%m.%y
-#
-# c_fmt
-#
-%a %e %b %X %Y
-#
-# am
-#
-am
-#
-# pm
-#
-pm
-#
-# date_fmt
-#
-%a %e %b %Y %X %Z
-#
-# Long months names (alternative)
-#
-Januar
-Februar
-Marec
-April
-Maj
-Junij
-Julij
-Avgust
-September
-Oktober
-November
-December
-#
-# Ef_fmt
-#
-%e %b
-#
-# EF_fmt
-#
-%e %B
diff --git a/share/timedef/sv_SE.ISO8859-1.src b/share/timedef/sv_SE.ISO8859-1.src
deleted file mode 100644
index 1b5f9d1b015d..000000000000
--- a/share/timedef/sv_SE.ISO8859-1.src
+++ /dev/null
@@ -1,100 +0,0 @@
-# $FreeBSD$
-# WARNING: spaces may be essential at the end of lines
-# WARNING: empty lines are essential too
-#
-# Short month names
-#
-Jan
-Feb
-Mar
-Apr
-Maj
-Jun
-Jul
-Aug
-Sep
-Okt
-Nov
-Dec
-#
-# Long month names
-#
-Januari
-Februari
-Mars
-April
-Maj
-Juni
-Juli
-Augusti
-September
-Oktober
-November
-December
-#
-# Short weekday names
-# (padded with a space to conform with other languages)
-Sön
-Mån
-Tis
-Ons
-Tor
-Fre
-Lör
-#
-# Long weekday names
-#
-Söndag
-Måndag
-Tisdag
-Onsdag
-Torsdag
-Fredag
-Lördag
-#
-# X_fmt
-#
-%H:%M:%S
-#
-# x_fmt
-#
-%d.%m.%y
-#
-# c_fmt
-#
-%a %e %b %X %Y
-#
-# am
-#
-am
-#
-# pm
-#
-pm
-#
-# date_fmt
-#
-%a %e %b %Y %X %Z
-#
-# Long month names (alternative)
-#
-Januari
-Februari
-Mars
-April
-Maj
-Juni
-Juli
-Augusti
-September
-Oktober
-November
-December
-#
-# Ef_fmt
-#
-%e %b
-#
-# EF_fmt
-#
-%e %B
diff --git a/share/timedef/zh_CN.eucCN.src b/share/timedef/zh_CN.eucCN.src
deleted file mode 100644
index d2d864f78b4d..000000000000
--- a/share/timedef/zh_CN.eucCN.src
+++ /dev/null
@@ -1,101 +0,0 @@
-# $FreeBSD$
-#
-# WARNING: spaces may be essential at the end of lines
-# WARNING: empty lines are essential too
-#
-# Short month names
-#
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-10
-11
-12
-#
-# Long month names
-#
-Ò»ÔÂ
-¶þÔÂ
-ÈýÔÂ
-ËÄÔÂ
-ÎåÔÂ
-ÁùÔÂ
-ÆßÔÂ
-°ËÔÂ
-¾ÅÔÂ
-Ê®ÔÂ
-ʮһÔÂ
-Ê®¶þÔÂ
-#
-# Short weekday names
-#
-ÖÜÈÕ
-ÖÜÒ»
-Öܶþ
-ÖÜÈý
-ÖÜËÄ
-ÖÜÎå
-ÖÜÁù
-#
-# Long weekday names
-#
-ÐÇÆÚÈÕ
-ÐÇÆÚÒ»
-ÐÇÆÚ¶þ
-ÐÇÆÚÈý
-ÐÇÆÚËÄ
-ÐÇÆÚÎå
-ÐÇÆÚÁù
-#
-# X_fmt
-#
-%Hʱ%M·Ö%SÃë
-#
-# x_fmt
-#
-%y/%m/%d
-#
-# c_fmt
-#
-%a %b/%e %T %Y
-#
-# am
-#
-ÉÏÎç
-#
-# pm
-#
-ÏÂÎç
-#
-# date_fmt
-#
-%YÄê%bÔÂ%eÈÕ %A %X %Z
-#
-# Long month names (alternative)
-#
-Ò»ÔÂ
-¶þÔÂ
-ÈýÔÂ
-ËÄÔÂ
-ÎåÔÂ
-ÁùÔÂ
-ÆßÔÂ
-°ËÔÂ
-¾ÅÔÂ
-Ê®ÔÂ
-ʮһÔÂ
-Ê®¶þÔÂ
-#
-# Ef_fmt
-#
-%b/%e
-#
-# EF_fmt
-#
-%B %e
diff --git a/sys/alpha/conf/NOTES b/sys/alpha/conf/NOTES
deleted file mode 100644
index dcedd7d76ac7..000000000000
--- a/sys/alpha/conf/NOTES
+++ /dev/null
@@ -1,162 +0,0 @@
-#
-# GENERIC -- Generic kernel configuration file for FreeBSD/alpha
-#
-# For more information on this file, please read the handbook section on
-# Kernel Configuration Files:
-#
-# http://www.freebsd.org/handbook/kernelconfig-config.html
-#
-# The handbook is also available locally in /usr/share/doc/handbook
-# if you've installed the doc distribution, otherwise always see the
-# FreeBSD World Wide Web server (http://www.FreeBSD.ORG/) for the
-# latest information.
-#
-# An exhaustive list of options and more detailed explanations of the
-# device lines is also present in the ../../i386/conf/LINT configuration file.
-# If you are in doubt as to the purpose or necessity of a line, check first
-# in LINT. Please note that this is the i386 LINT, but it still contains
-# valuable info for alpha too
-#
-# For hardware specific information check HARDWARE.TXT
-#
-# $FreeBSD$
-
-machine alpha
-cpu EV4
-cpu EV5
-ident GENERIC
-maxusers 32
-
-#makeoptions DEBUG=-g #Build kernel with gdb(1) debug symbols
-
-# Platforms supported
-options DEC_AXPPCI_33 # UDB, Multia, AXPpci33, Noname
-options DEC_EB164 # EB164, PC164, PC164LX, PC164SX
-options DEC_EB64PLUS # EB64+, Aspen Alpine, etc
-options DEC_2100_A50 # AlphaStation 200, 250, 255, 400
-options DEC_KN20AA # AlphaStation 500, 600
-options DEC_ST550 # Personal Workstation 433, 500, 600
-options DEC_ST6600 # xp1000, dp264, ds20, ds10, family
-options DEC_3000_300 # DEC3000/300* Pelic* family
-options DEC_3000_500 # DEC3000/[4-9]00 Flamingo/Sandpiper family
-options DEC_1000A # AlphaServer 1000, 1000A, 800
-
-options INET #InterNETworking
-options INET6 #IPv6 communications protocols
-options FFS #Berkeley Fast Filesystem
-options FFS_ROOT #FFS usable as root device [keep this!]
-options MFS #Memory Filesystem
-options MD_ROOT #MD is a potential root device
-options NFS #Network Filesystem
-options NFS_ROOT #NFS usable as root device
-options MSDOSFS #MSDOS Filesystem
-options CD9660 #ISO 9660 Filesystem
-options CD9660_ROOT #CD-ROM usable as root device
-options PROCFS #Process filesystem
-options COMPAT_43 #Compatible with BSD 4.3 [KEEP THIS!]
-options SCSI_DELAY=15000 #Delay (in ms) before probing SCSI
-options UCONSOLE #Allow users to grab the console
-options KTRACE #ktrace(1) syscall trace support
-options SYSVSHM #SYSV-style shared memory
-options SYSVMSG #SYSV-style message queues
-options SYSVSEM #SYSV-style semaphores
-options P1003_1B #Posix P1003_1B real-time extentions
-options _KPOSIX_PRIORITY_SCHEDULING
-options ICMP_BANDLIM #Rate limit bad replies
-
-# Standard busses
-device isa
-device pci
-
-# Floppy drives
-device fdc0 at isa? port IO_FD1 irq 6 drq 2
-device fd0 at fdc0 drive 0
-
-# ATA and ATAPI devices
-device ata
-device atadisk # ATA disk drives
-device atapicd # ATAPI CDROM drives
-device atapifd # ATAPI floppy drives
-device atapist # ATAPI tape drives
-
-# SCSI Controllers
-device ahc # AHA2940 and onboard AIC7xxx devices
-#device esp # 53C94 & friends, not CAM-ified
-device isp # Qlogic family
-device ncr # NCR/Symbios Logic
-device sym # NCR/Symbios Logic (newer chipsets)
-
-# SCSI peripherals
-device scbus # SCSI bus (required)
-device da # Direct Access (disks)
-device sa # Sequential Access (tape etc)
-device cd # CD
-device pass # Passthrough device (direct SCSI access)
-
-# atkbdc0 controls both the keyboard and the PS/2 mouse
-device atkbdc0 at isa? port IO_KBD
-device atkbd0 at atkbdc? irq 1
-device psm0 at atkbdc? irq 12
-
-device vga0 at isa?
-
-# splash screen/screen saver
-pseudo-device splash
-
-# syscons is the default console driver, resembling an SCO console
-device sc0 at isa?
-
-# real time clock
-device mcclock0 at isa? port 0x70
-
-# Serial (COM) ports
-device sio0 at isa? port IO_COM1 irq 4
-device sio1 at isa? port IO_COM2 irq 3 flags 0x50
-
-# PCI Ethernet NICs.
-device de # DEC/Intel DC21x4x (``Tulip'')
-device fxp # Intel EtherExpress PRO/100B (82557, 82558)
-device le # Lance
-device wx # Intel Gigabit Ethernet Card (``Wiseman'')
-
-# PCI Ethernet NICs that use the common MII bus controller code.
-device miibus # MII bus support
-device dc # DEC/Intel 21143 and workalikes
-device rl # RealTek 8129/8139
-device sf # Adaptec AIC-6915 (``Starfire'')
-device sis # Silicon Integrated Systems SiS 900/SiS 7016
-device ste # Sundance ST201 (D-Link DFE-550TX)
-device tl # Texas Instruments ThunderLAN
-device vr # VIA Rhine, Rhine II
-device wb # Winbond W89C840F
-device xl # 3Com 3c90x (``Boomerang'', ``Cyclone'')
-
-# Pseudo devices - the number indicates how many units to allocated.
-pseudo-device loop # Network loopback
-pseudo-device ether # Ethernet support
-pseudo-device sl 1 # Kernel SLIP
-pseudo-device ppp 1 # Kernel PPP
-pseudo-device tun # Packet tunnel.
-pseudo-device pty # Pseudo-ttys (telnet etc)
-pseudo-device md # Memory "disks"
-pseudo-device gif 4 # IPv6 and IPv4 tunneling
-pseudo-device faith 1 # IPv6-to-IPv4 relaying/(translation)
-
-# The `bpf' pseudo-device enables the Berkeley Packet Filter.
-# Be aware of the administrative consequences of enabling this!
-pseudo-device bpf #Berkeley packet filter
-
-# USB support
-#device uhci # UHCI PCI->USB interface
-#device ohci # OHCI PCI->USB interface
-#device usb # USB Bus (required)
-#device ugen # Generic
-#device uhid # "Human Interface Devices"
-#device ukbd # Keyboard
-#device ulpt # Printer
-#device umass # Disks/Mass storage - Requires scbus and da0
-#device ums # Mouse
-# USB Ethernet
-#device aue # ADMtek USB ethernet
-#device cue # CATC USB ethernet
-#device kue # Kawasaki LSI USB ethernet
diff --git a/sys/alpha/include/_limits.h b/sys/alpha/include/_limits.h
deleted file mode 100644
index 99ca2d89843f..000000000000
--- a/sys/alpha/include/_limits.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/* $FreeBSD$ */
-/* From: NetBSD: limits.h,v 1.3 1997/04/06 08:47:31 cgd 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. 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, Berkeley and its contributors.
- * 4. 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
- */
-
-#define CHAR_BIT 8 /* number of bits in a char */
-#define MB_LEN_MAX 6 /* Allow 31 bit UTF2 */
-
-/*
- * According to ANSI (section 2.2.4.2), the values below must be usable by
- * #if preprocessing directives. Additionally, the expression must have the
- * same type as would an expression that is an object of the corresponding
- * type converted according to the integral promotions. The subtraction for
- * INT_MIN and LONG_MIN is so the value is not unsigned; 2147483648 is an
- * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2).
- * These numbers work for pcc as well. The UINT_MAX and ULONG_MAX values
- * are written as hex so that GCC will be quiet about large integer constants.
- */
-#define SCHAR_MAX 0x7f /* max value for a signed char */
-#define SCHAR_MIN (-0x7f-1) /* min value for a signed char */
-
-#define UCHAR_MAX 0xffU /* max value for an unsigned char */
-#define CHAR_MAX 0x7f /* max value for a char */
-#define CHAR_MIN (-0x7f-1) /* min value for a char */
-
-#define USHRT_MAX 0xffffU /* max value for an unsigned short */
-#define SHRT_MAX 0x7fff /* max value for a short */
-#define SHRT_MIN (-0x7fff-1) /* min value for a short */
-
-#define UINT_MAX 0xffffffffU /* max value for an unsigned int */
-#define INT_MAX 0x7fffffff /* max value for an int */
-#define INT_MIN (-0x7fffffff-1) /* min value for an int */
-
-#define ULONG_MAX 0xffffffffffffffffUL /* max for an unsigned long */
-#define LONG_MAX 0x7fffffffffffffffL /* max for a long */
-#define LONG_MIN (-0x7fffffffffffffffL-1) /* min for a long */
-
-#if !defined(_ANSI_SOURCE)
-#define SSIZE_MAX LONG_MAX /* max value for a ssize_t */
-
-#if !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE)
-#define SIZE_T_MAX ULONG_MAX /* max value for a size_t */
-
-/* Quads and longs are the same on the alpha */
-#define UQUAD_MAX (ULONG_MAX) /* max value for a uquad_t */
-#define QUAD_MAX (LONG_MAX) /* max value for a quad_t */
-#define QUAD_MIN (LONG_MIN) /* min value for a quad_t */
-
-#endif /* !_POSIX_SOURCE && !_XOPEN_SOURCE */
-#endif /* !_ANSI_SOURCE */
-
-#if (!defined(_ANSI_SOURCE)&&!defined(_POSIX_SOURCE)) || defined(_XOPEN_SOURCE)
-#define LONG_BIT 64
-#define WORD_BIT 32
-
-#define DBL_DIG 15
-#define DBL_MAX 1.7976931348623157E+308
-#define DBL_MIN 2.2250738585072014E-308
-
-#define FLT_DIG 6
-#define FLT_MAX 3.40282347E+38F
-#define FLT_MIN 1.17549435E-38F
-#endif
diff --git a/sys/alpha/linux/Makefile b/sys/alpha/linux/Makefile
deleted file mode 100644
index c062c96ec177..000000000000
--- a/sys/alpha/linux/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-# Makefile for syscall tables
-#
-# $FreeBSD$
-
-all:
- @echo "make linux_sysent.c only"
-
-linux_sysent.c linux_syscall.h linux_proto.h: ../../kern/makesyscalls.sh \
- syscalls.master syscalls.conf
- -mv -f linux_sysent.c linux_sysent.c.bak
- -mv -f linux_syscall.h linux_syscall.h.bak
- -mv -f linux_proto.h linux_proto.h.bak
- sh ../../kern/makesyscalls.sh syscalls.master syscalls.conf
diff --git a/sys/alpha/linux/linux.h b/sys/alpha/linux/linux.h
deleted file mode 100644
index 528a5914134c..000000000000
--- a/sys/alpha/linux/linux.h
+++ /dev/null
@@ -1,416 +0,0 @@
-/*-
- * Copyright (c) 1994-1996 Søren Schmidt
- * 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
- * in this position and unchanged.
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _I386_LINUX_LINUX_H_
-#define _I386_LINUX_LINUX_H_
-
-#include <i386/linux/linux_syscall.h>
-
-#ifdef MALLOC_DECLARE
-MALLOC_DECLARE(M_LINUX);
-#endif
-
-/*
- * Miscellaneous
- */
-#define LINUX_NAME_MAX 255
-#define LINUX_MAX_UTSNAME 65
-
-/* Scheduling policies */
-#define LINUX_SCHED_OTHER 0
-#define LINUX_SCHED_FIFO 1
-#define LINUX_SCHED_RR 2
-
-/* Resource limits */
-#define LINUX_RLIMIT_CPU 0
-#define LINUX_RLIMIT_FSIZE 1
-#define LINUX_RLIMIT_DATA 2
-#define LINUX_RLIMIT_STACK 3
-#define LINUX_RLIMIT_CORE 4
-#define LINUX_RLIMIT_RSS 5
-#define LINUX_RLIMIT_NPROC 6
-#define LINUX_RLIMIT_NOFILE 7
-#define LINUX_RLIMIT_MEMLOCK 8
-#define LINUX_RLIMIT_AS 9 /* address space limit */
-
-#define LINUX_RLIM_NLIMITS 10
-
-/* mmap options */
-#define LINUX_MAP_SHARED 0x0001
-#define LINUX_MAP_PRIVATE 0x0002
-#define LINUX_MAP_FIXED 0x0010
-#define LINUX_MAP_ANON 0x0020
-#define LINUX_MAP_GROWSDOWN 0x0100
-
-typedef char * linux_caddr_t;
-typedef long linux_clock_t;
-typedef u_short linux_dev_t;
-typedef u_short linux_gid_t;
-typedef u_long linux_ino_t;
-typedef int linux_key_t; /* XXX */
-typedef u_short linux_mode_t;
-typedef u_short linux_nlink_t;
-typedef long linux_off_t;
-typedef int linux_pid_t;
-typedef u_int linux_size_t;
-typedef long linux_time_t;
-typedef u_short linux_uid_t;
-
-typedef struct {
- long val[2];
-} linux_fsid_t;
-
-struct linux_new_utsname {
- char sysname[LINUX_MAX_UTSNAME];
- char nodename[LINUX_MAX_UTSNAME];
- char release[LINUX_MAX_UTSNAME];
- char version[LINUX_MAX_UTSNAME];
- char machine[LINUX_MAX_UTSNAME];
- char domainname[LINUX_MAX_UTSNAME];
-};
-
-/*
- * Signalling
- */
-#define LINUX_SIGHUP 1
-#define LINUX_SIGINT 2
-#define LINUX_SIGQUIT 3
-#define LINUX_SIGILL 4
-#define LINUX_SIGTRAP 5
-#define LINUX_SIGABRT 6
-#define LINUX_SIGIOT LINUX_SIGABRT
-#define LINUX_SIGBUS 7
-#define LINUX_SIGFPE 8
-#define LINUX_SIGKILL 9
-#define LINUX_SIGUSR1 10
-#define LINUX_SIGSEGV 11
-#define LINUX_SIGUSR2 12
-#define LINUX_SIGPIPE 13
-#define LINUX_SIGALRM 14
-#define LINUX_SIGTERM 15
-#define LINUX_SIGSTKFLT 16
-#define LINUX_SIGCHLD 17
-#define LINUX_SIGCONT 18
-#define LINUX_SIGSTOP 19
-#define LINUX_SIGTSTP 20
-#define LINUX_SIGTTIN 21
-#define LINUX_SIGTTOU 22
-#define LINUX_SIGURG 23
-#define LINUX_SIGXCPU 24
-#define LINUX_SIGXFSZ 25
-#define LINUX_SIGVTALRM 26
-#define LINUX_SIGPROF 27
-#define LINUX_SIGWINCH 28
-#define LINUX_SIGIO 29
-#define LINUX_SIGPOLL LINUX_SIGIO
-#define LINUX_SIGPWR 30
-#define LINUX_SIGUNUSED 31
-
-#define LINUX_NSIG 64
-#define LINUX_SIGTBLSZ 31
-
-/* sigaction flags */
-#define LINUX_SA_NOCLDSTOP 0x00000001
-#define LINUX_SA_NOCLDWAIT 0x00000002
-#define LINUX_SA_SIGINFO 0x00000004
-#define LINUX_SA_RESTORER 0x04000000
-#define LINUX_SA_ONSTACK 0x08000000
-#define LINUX_SA_RESTART 0x10000000
-#define LINUX_SA_INTERRUPT 0x20000000
-#define LINUX_SA_NOMASK 0x40000000
-#define LINUX_SA_ONESHOT 0x80000000
-
-/* sigprocmask actions */
-#define LINUX_SIG_BLOCK 0
-#define LINUX_SIG_UNBLOCK 1
-#define LINUX_SIG_SETMASK 2
-
-/* sigset_t macros */
-#define LINUX_SIGEMPTYSET(set) (set).__bits[0] = (set).__bits[1] = 0
-#define LINUX_SIGISMEMBER(set, sig) SIGISMEMBER(set, sig)
-#define LINUX_SIGADDSET(set, sig) SIGADDSET(set, sig)
-
-typedef void (*linux_handler_t)(int);
-typedef u_long linux_osigset_t;
-
-typedef struct {
- u_int __bits[2];
-} linux_sigset_t;
-
-typedef struct {
- linux_handler_t lsa_handler;
- linux_osigset_t lsa_mask;
- u_long lsa_flags;
- void (*lsa_restorer)(void);
-} linux_osigaction_t;
-
-typedef struct {
- linux_handler_t lsa_handler;
- u_long lsa_flags;
- void (*lsa_restorer)(void);
- linux_sigset_t lsa_mask;
-} linux_sigaction_t;
-
-typedef struct {
- void *ss_sp;
- int ss_flags;
- linux_size_t ss_size;
-} linux_stack_t;
-
-/* The Linux sigcontext, pretty much a standard 386 trapframe. */
-struct linux_sigcontext {
- int sc_gs;
- int sc_fs;
- int sc_es;
- int sc_ds;
- int sc_edi;
- int sc_esi;
- int sc_ebp;
- int sc_esp;
- int sc_ebx;
- int sc_edx;
- int sc_ecx;
- int sc_eax;
- int sc_trapno;
- int sc_err;
- int sc_eip;
- int sc_cs;
- int sc_eflags;
- int sc_esp_at_signal;
- int sc_ss;
- int sc_387;
- int sc_mask;
- int sc_cr2;
-};
-
-/*
- * We make the stack look like Linux expects it when calling a signal
- * handler, but use the BSD way of calling the handler and sigreturn().
- * This means that we need to pass the pointer to the handler too.
- * It is appended to the frame to not interfere with the rest of it.
- */
-struct linux_sigframe {
- int sf_sig;
- struct linux_sigcontext sf_sc;
- linux_handler_t sf_handler;
-};
-
-extern int bsd_to_linux_signal[];
-extern int linux_to_bsd_signal[];
-
-/*
- * Pluggable ioctl handlers
- */
-struct linker_set;
-struct linux_ioctl_args;
-struct proc;
-
-typedef int linux_ioctl_function_t(struct proc *, struct linux_ioctl_args *);
-
-struct linux_ioctl_handler {
- linux_ioctl_function_t *func;
- int low, high;
-};
-
-int linux_ioctl_register_handler(struct linux_ioctl_handler *h);
-int linux_ioctl_register_handlers(struct linker_set *s);
-int linux_ioctl_unregister_handler(struct linux_ioctl_handler *h);
-int linux_ioctl_unregister_handlers(struct linker_set *s);
-
-/*
- * open/fcntl flags
- */
-#define LINUX_O_RDONLY 00
-#define LINUX_O_WRONLY 01
-#define LINUX_O_RDWR 02
-#define LINUX_O_CREAT 0100
-#define LINUX_O_EXCL 0200
-#define LINUX_O_NOCTTY 0400
-#define LINUX_O_TRUNC 01000
-#define LINUX_O_APPEND 02000
-#define LINUX_O_NONBLOCK 04000
-#define LINUX_O_NDELAY LINUX_O_NONBLOCK
-#define LINUX_O_SYNC 010000
-#define LINUX_FASYNC 020000
-
-#define LINUX_F_DUPFD 0
-#define LINUX_F_GETFD 1
-#define LINUX_F_SETFD 2
-#define LINUX_F_GETFL 3
-#define LINUX_F_SETFL 4
-#define LINUX_F_GETLK 5
-#define LINUX_F_SETLK 6
-#define LINUX_F_SETLKW 7
-#define LINUX_F_SETOWN 8
-#define LINUX_F_GETOWN 9
-
-#define LINUX_F_RDLCK 0
-#define LINUX_F_WRLCK 1
-#define LINUX_F_UNLCK 2
-
-/*
- * SystemV IPC defines
- */
-#define LINUX_SEMOP 1
-#define LINUX_SEMGET 2
-#define LINUX_SEMCTL 3
-#define LINUX_MSGSND 11
-#define LINUX_MSGRCV 12
-#define LINUX_MSGGET 13
-#define LINUX_MSGCTL 14
-#define LINUX_SHMAT 21
-#define LINUX_SHMDT 22
-#define LINUX_SHMGET 23
-#define LINUX_SHMCTL 24
-
-#define LINUX_IPC_RMID 0
-#define LINUX_IPC_SET 1
-#define LINUX_IPC_STAT 2
-#define LINUX_IPC_INFO 3
-
-#define LINUX_SHM_LOCK 11
-#define LINUX_SHM_UNLOCK 12
-#define LINUX_SHM_STAT 13
-#define LINUX_SHM_INFO 14
-
-#define LINUX_SHM_RDONLY 0x1000
-#define LINUX_SHM_RND 0x2000
-#define LINUX_SHM_REMAP 0x4000
-
-/* semctl commands */
-#define LINUX_GETPID 11
-#define LINUX_GETVAL 12
-#define LINUX_GETALL 13
-#define LINUX_GETNCNT 14
-#define LINUX_GETZCNT 15
-#define LINUX_SETVAL 16
-#define LINUX_SETALL 17
-
-/*
- * Socket defines
- */
-#define LINUX_SOCKET 1
-#define LINUX_BIND 2
-#define LINUX_CONNECT 3
-#define LINUX_LISTEN 4
-#define LINUX_ACCEPT 5
-#define LINUX_GETSOCKNAME 6
-#define LINUX_GETPEERNAME 7
-#define LINUX_SOCKETPAIR 8
-#define LINUX_SEND 9
-#define LINUX_RECV 10
-#define LINUX_SENDTO 11
-#define LINUX_RECVFROM 12
-#define LINUX_SHUTDOWN 13
-#define LINUX_SETSOCKOPT 14
-#define LINUX_GETSOCKOPT 15
-#define LINUX_SENDMSG 16
-#define LINUX_RECVMSG 17
-
-#define LINUX_AF_UNSPEC 0
-#define LINUX_AF_UNIX 1
-#define LINUX_AF_INET 2
-#define LINUX_AF_AX25 3
-#define LINUX_AF_IPX 4
-#define LINUX_AF_APPLETALK 5
-
-#define LINUX_SOL_SOCKET 1
-#define LINUX_SOL_IP 0
-#define LINUX_SOL_IPX 256
-#define LINUX_SOL_AX25 257
-#define LINUX_SOL_TCP 6
-#define LINUX_SOL_UDP 17
-
-#define LINUX_SO_DEBUG 1
-#define LINUX_SO_REUSEADDR 2
-#define LINUX_SO_TYPE 3
-#define LINUX_SO_ERROR 4
-#define LINUX_SO_DONTROUTE 5
-#define LINUX_SO_BROADCAST 6
-#define LINUX_SO_SNDBUF 7
-#define LINUX_SO_RCVBUF 8
-#define LINUX_SO_KEEPALIVE 9
-#define LINUX_SO_OOBINLINE 10
-#define LINUX_SO_NO_CHECK 11
-#define LINUX_SO_PRIORITY 12
-#define LINUX_SO_LINGER 13
-
-#define LINUX_IP_TOS 1
-#define LINUX_IP_TTL 2
-#define LINUX_IP_HDRINCL 3
-#define LINUX_IP_OPTIONS 4
-
-#define LINUX_IP_MULTICAST_IF 32
-#define LINUX_IP_MULTICAST_TTL 33
-#define LINUX_IP_MULTICAST_LOOP 34
-#define LINUX_IP_ADD_MEMBERSHIP 35
-#define LINUX_IP_DROP_MEMBERSHIP 36
-
-struct linux_sockaddr {
- u_short sa_family;
- char sa_data[14];
-};
-
-struct linux_ifmap {
- u_long mem_start;
- u_long mem_end;
- u_short base_addr;
- u_char irq;
- u_char dma;
- u_char port;
-};
-
-#define LINUX_IFHWADDRLEN 6
-#define LINUX_IFNAMSIZ 16
-
-struct linux_ifreq {
- union {
- char ifrn_name[LINUX_IFNAMSIZ];
- } ifr_ifrn;
-
- union {
- struct linux_sockaddr ifru_addr;
- struct linux_sockaddr ifru_dstaddr;
- struct linux_sockaddr ifru_broadaddr;
- struct linux_sockaddr ifru_netmask;
- struct linux_sockaddr ifru_hwaddr;
- short ifru_flags;
- int ifru_metric;
- int ifru_mtu;
- struct linux_ifmap ifru_map;
- char ifru_slave[LINUX_IFNAMSIZ]; /* Just fits the size */
- linux_caddr_t ifru_data;
- } ifr_ifru;
-};
-
-#define ifr_name ifr_ifrn.ifrn_name /* interface name */
-#define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */
-
-#endif /* !_I386_LINUX_LINUX_H_ */
diff --git a/sys/alpha/linux/linux_dummy.c b/sys/alpha/linux/linux_dummy.c
deleted file mode 100644
index 4124e990b6ca..000000000000
--- a/sys/alpha/linux/linux_dummy.c
+++ /dev/null
@@ -1,114 +0,0 @@
-/*-
- * Copyright (c) 1994-1995 Søren Schmidt
- * 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
- * in this position and unchanged.
- * 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 withough 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/proc.h>
-
-#include <i386/linux/linux.h>
-#include <i386/linux/linux_proto.h>
-
-#define DUMMY(s) \
-int \
-linux_ ## s(struct proc *p, struct linux_ ## s ## _args *args) \
-{ \
- return (unsupported_msg(p, #s)); \
-} \
-struct __hack
-
-static int
-unsupported_msg(struct proc *p, const char *fname)
-{
- printf("linux: syscall %s is obsoleted or not implemented (pid=%ld)\n",
- fname, (long)p->p_pid);
- return (ENOSYS);
-}
-
-DUMMY(setup);
-DUMMY(break);
-DUMMY(stat);
-DUMMY(mount);
-DUMMY(umount);
-DUMMY(stime);
-DUMMY(ptrace);
-DUMMY(fstat);
-DUMMY(stty);
-DUMMY(gtty);
-DUMMY(ftime);
-DUMMY(prof);
-DUMMY(umount2);
-DUMMY(lock);
-DUMMY(mpx);
-DUMMY(ulimit);
-DUMMY(olduname);
-DUMMY(ksyslog);
-DUMMY(uname);
-DUMMY(vhangup);
-DUMMY(idle);
-DUMMY(vm86old);
-DUMMY(swapoff);
-DUMMY(sysinfo);
-DUMMY(adjtimex);
-DUMMY(create_module);
-DUMMY(init_module);
-DUMMY(delete_module);
-DUMMY(get_kernel_syms);
-DUMMY(quotactl);
-DUMMY(bdflush);
-DUMMY(sysfs);
-DUMMY(afs_syscall);
-DUMMY(setfsuid);
-DUMMY(setfsgid);
-DUMMY(getsid);
-DUMMY(sysctl);
-DUMMY(getresuid);
-DUMMY(vm86);
-DUMMY(query_module);
-DUMMY(nfsservctl);
-DUMMY(getresgid);
-DUMMY(prctl);
-DUMMY(rt_sigreturn);
-DUMMY(rt_sigpending);
-DUMMY(rt_sigtimedwait);
-DUMMY(rt_sigqueueinfo);
-DUMMY(pread);
-DUMMY(pwrite);
-DUMMY(capget);
-DUMMY(capset);
-DUMMY(sendfile);
-DUMMY(getpmsg);
-DUMMY(putpmsg);
-DUMMY(ugetrlimit);
-DUMMY(mmap2);
-DUMMY(truncate64);
-DUMMY(ftruncate64);
-DUMMY(stat64);
-DUMMY(lstat64);
-DUMMY(fstat64);
diff --git a/sys/alpha/linux/linux_genassym.c b/sys/alpha/linux/linux_genassym.c
deleted file mode 100644
index 25e20af9c790..000000000000
--- a/sys/alpha/linux/linux_genassym.c
+++ /dev/null
@@ -1,13 +0,0 @@
-/* $FreeBSD$ */
-
-#include <stddef.h>
-
-#include <sys/param.h>
-#include <sys/assym.h>
-
-#include <i386/linux/linux.h>
-
-ASSYM(LINUX_SIGF_HANDLER, offsetof(struct linux_sigframe, sf_handler));
-ASSYM(LINUX_SIGF_SC, offsetof(struct linux_sigframe, sf_sc));
-ASSYM(LINUX_SC_GS, offsetof(struct linux_sigcontext, sc_gs));
-ASSYM(LINUX_SC_EFLAGS, offsetof(struct linux_sigcontext, sc_eflags));
diff --git a/sys/alpha/linux/linux_ioctl.h b/sys/alpha/linux/linux_ioctl.h
deleted file mode 100644
index 1ed49012547f..000000000000
--- a/sys/alpha/linux/linux_ioctl.h
+++ /dev/null
@@ -1,437 +0,0 @@
-/*-
- * Copyright (c) 1999 Marcel Moolenaar
- * 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
- * in this position and unchanged.
- * 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 withough 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _LINUX_IOCTL_H_
-#define _LINUX_IOCTL_H_
-
-/*
- * disk
- */
-#define LINUX_BLKROSET 0x125d
-#define LINUX_BLKROGET 0x125e
-#define LINUX_BLKRRPART 0x125f
-#define LINUX_BLKGETSIZE 0x1260
-#define LINUX_BLKFLSBUF 0x1261
-#define LINUX_BLKRASET 0x1262
-#define LINUX_BLKRAGET 0x1263
-#define LINUX_BLKFRASET 0x1264
-#define LINUX_BLKFRAGET 0x1265
-#define LINUX_BLKSECTSET 0x1266
-#define LINUX_BLKSECTGET 0x1267
-#define LINUX_BLKSSZGET 0x1268
-
-#define LINUX_IOCTL_DISK_MIN LINUX_BLKROSET
-#define LINUX_IOCTL_DISK_MAX LINUX_BLKSSZGET
-
-/*
- * cdrom
- */
-#define LINUX_CDROMPAUSE 0x5301
-#define LINUX_CDROMRESUME 0x5302
-#define LINUX_CDROMPLAYMSF 0x5303
-#define LINUX_CDROMPLAYTRKIND 0x5304
-#define LINUX_CDROMREADTOCHDR 0x5305
-#define LINUX_CDROMREADTOCENTRY 0x5306
-#define LINUX_CDROMSTOP 0x5307
-#define LINUX_CDROMSTART 0x5308
-#define LINUX_CDROMEJECT 0x5309
-#define LINUX_CDROMVOLCTRL 0x530a
-#define LINUX_CDROMSUBCHNL 0x530b
-#define LINUX_CDROMREADMODE2 0x530c
-#define LINUX_CDROMREADMODE1 0x530d
-#define LINUX_CDROMREADAUDIO 0x530e
-#define LINUX_CDROMEJECT_SW 0x530f
-#define LINUX_CDROMMULTISESSION 0x5310
-#define LINUX_CDROM_GET_UPC 0x5311
-#define LINUX_CDROMRESET 0x5312
-#define LINUX_CDROMVOLREAD 0x5313
-#define LINUX_CDROMREADRAW 0x5314
-#define LINUX_CDROMREADCOOKED 0x5315
-#define LINUX_CDROMSEEK 0x5316
-#define LINUX_CDROMPLAYBLK 0x5317
-#define LINUX_CDROMREADALL 0x5318
-#define LINUX_CDROMCLOSETRAY 0x5319
-#define LINUX_CDROMLOADFROMSLOT 0x531a
-
-#define LINUX_IOCTL_CDROM_MIN LINUX_CDROMPAUSE
-#define LINUX_IOCTL_CDROM_MAX LINUX_CDROMLOADFROMSLOT
-
-#define LINUX_CDROM_LBA 0x01
-#define LINUX_CDROM_MSF 0x02
-
-/*
- * console
- */
-#define LINUX_KIOCSOUND 0x4B2F
-#define LINUX_KDMKTONE 0x4B30
-#define LINUX_KDGETLED 0x4B31
-#define LINUX_KDSETLED 0x4B32
-#define LINUX_KDSETMODE 0x4B3A
-#define LINUX_KDGETMODE 0x4B3B
-#define LINUX_KDGKBMODE 0x4B44
-#define LINUX_KDSKBMODE 0x4B45
-#define LINUX_VT_OPENQRY 0x5600
-#define LINUX_VT_GETMODE 0x5601
-#define LINUX_VT_SETMODE 0x5602
-#define LINUX_VT_GETSTATE 0x5603
-#define LINUX_VT_RELDISP 0x5605
-#define LINUX_VT_ACTIVATE 0x5606
-#define LINUX_VT_WAITACTIVE 0x5607
-
-#define LINUX_IOCTL_CONSOLE_MIN LINUX_KIOCSOUND
-#define LINUX_IOCTL_CONSOLE_MAX LINUX_VT_WAITACTIVE
-
-#define LINUX_LED_SCR 0x01
-#define LINUX_LED_NUM 0x02
-#define LINUX_LED_CAP 0x04
-
-#define LINUX_KD_TEXT 0x0
-#define LINUX_KD_GRAPHICS 0x1
-#define LINUX_KD_TEXT0 0x2
-#define LINUX_KD_TEXT1 0x3
-
-#define LINUX_KBD_RAW 0
-#define LINUX_KBD_XLATE 1
-#define LINUX_KBD_MEDIUMRAW 2
-
-/*
- * socket
- */
-#define LINUX_FIOSETOWN 0x8901
-#define LINUX_SIOCSPGRP 0x8902
-#define LINUX_FIOGETOWN 0x8903
-#define LINUX_SIOCGPGRP 0x8904
-#define LINUX_SIOCATMARK 0x8905
-#define LINUX_SIOCGSTAMP 0x8906
-#define LINUX_SIOCGIFCONF 0x8912
-#define LINUX_SIOCGIFFLAGS 0x8913
-#define LINUX_SIOCGIFADDR 0x8915
-#define LINUX_SIOCGIFDSTADDR 0x8917
-#define LINUX_SIOCGIFBRDADDR 0x8919
-#define LINUX_SIOCGIFNETMASK 0x891b
-#define LINUX_SIOCGIFHWADDR 0x8927
-#define LINUX_SIOCADDMULTI 0x8931
-#define LINUX_SIOCDELMULTI 0x8932
-
-#define LINUX_IOCTL_SOCKET_MIN LINUX_FIOSETOWN
-#define LINUX_IOCTL_SOCKET_MAX LINUX_SIOCDELMULTI
-
-/*
- * sound
- */
-#define LINUX_SOUND_MIXER_WRITE_VOLUME 0x4d00
-#define LINUX_SOUND_MIXER_WRITE_BASS 0x4d01
-#define LINUX_SOUND_MIXER_WRITE_TREBLE 0x4d02
-#define LINUX_SOUND_MIXER_WRITE_SYNTH 0x4d03
-#define LINUX_SOUND_MIXER_WRITE_PCM 0x4d04
-#define LINUX_SOUND_MIXER_WRITE_SPEAKER 0x4d05
-#define LINUX_SOUND_MIXER_WRITE_LINE 0x4d06
-#define LINUX_SOUND_MIXER_WRITE_MIC 0x4d07
-#define LINUX_SOUND_MIXER_WRITE_CD 0x4d08
-#define LINUX_SOUND_MIXER_WRITE_IMIX 0x4d09
-#define LINUX_SOUND_MIXER_WRITE_ALTPCM 0x4d0A
-#define LINUX_SOUND_MIXER_WRITE_RECLEV 0x4d0B
-#define LINUX_SOUND_MIXER_WRITE_IGAIN 0x4d0C
-#define LINUX_SOUND_MIXER_WRITE_OGAIN 0x4d0D
-#define LINUX_SOUND_MIXER_WRITE_LINE1 0x4d0E
-#define LINUX_SOUND_MIXER_WRITE_LINE2 0x4d0F
-#define LINUX_SOUND_MIXER_WRITE_LINE3 0x4d10
-#define LINUX_OSS_GETVERSION 0x4d76
-#define LINUX_SOUND_MIXER_READ_DEVMASK 0x4dfe
-#define LINUX_SNDCTL_DSP_RESET 0x5000
-#define LINUX_SNDCTL_DSP_SYNC 0x5001
-#define LINUX_SNDCTL_DSP_SPEED 0x5002
-#define LINUX_SNDCTL_DSP_STEREO 0x5003
-#define LINUX_SNDCTL_DSP_GETBLKSIZE 0x5004
-#define LINUX_SNDCTL_DSP_SETBLKSIZE LINUX_SNDCTL_DSP_GETBLKSIZE
-#define LINUX_SNDCTL_DSP_SETFMT 0x5005
-#define LINUX_SOUND_PCM_WRITE_CHANNELS 0x5006
-#define LINUX_SOUND_PCM_WRITE_FILTER 0x5007
-#define LINUX_SNDCTL_DSP_POST 0x5008
-#define LINUX_SNDCTL_DSP_SUBDIVIDE 0x5009
-#define LINUX_SNDCTL_DSP_SETFRAGMENT 0x500A
-#define LINUX_SNDCTL_DSP_GETFMTS 0x500B
-#define LINUX_SNDCTL_DSP_GETOSPACE 0x500C
-#define LINUX_SNDCTL_DSP_GETISPACE 0x500D
-#define LINUX_SNDCTL_DSP_NONBLOCK 0x500E
-#define LINUX_SNDCTL_DSP_GETCAPS 0x500F
-#define LINUX_SNDCTL_DSP_GETTRIGGER 0x5010
-#define LINUX_SNDCTL_DSP_SETTRIGGER LINUX_SNDCTL_DSP_GETTRIGGER
-#define LINUX_SNDCTL_DSP_GETIPTR 0x5011
-#define LINUX_SNDCTL_DSP_GETOPTR 0x5012
-#define LINUX_SNDCTL_DSP_GETODELAY 0x5017
-#define LINUX_SNDCTL_SEQ_RESET 0x5100
-#define LINUX_SNDCTL_SEQ_SYNC 0x5101
-#define LINUX_SNDCTL_SYNTH_INFO 0x5102
-#define LINUX_SNDCTL_SEQ_CTRLRATE 0x5103
-#define LINUX_SNDCTL_SEQ_GETOUTCOUNT 0x5104
-#define LINUX_SNDCTL_SEQ_GETINCOUNT 0x5105
-#define LINUX_SNDCTL_SEQ_PERCMODE 0x5106
-#define LINUX_SNDCTL_FM_LOAD_INSTR 0x5107
-#define LINUX_SNDCTL_SEQ_TESTMIDI 0x5108
-#define LINUX_SNDCTL_SEQ_RESETSAMPLES 0x5109
-#define LINUX_SNDCTL_SEQ_NRSYNTHS 0x510A
-#define LINUX_SNDCTL_SEQ_NRMIDIS 0x510B
-#define LINUX_SNDCTL_MIDI_INFO 0x510C
-#define LINUX_SNDCTL_SEQ_TRESHOLD 0x510D
-#define LINUX_SNDCTL_SYNTH_MEMAVL 0x510E
-
-#define LINUX_IOCTL_SOUND_MIN LINUX_SOUND_MIXER_WRITE_VOLUME
-#define LINUX_IOCTL_SOUND_MAX LINUX_SNDCTL_SYNTH_MEMAVL
-
-/*
- * termio
- */
-#define LINUX_TCGETS 0x5401
-#define LINUX_TCSETS 0x5402
-#define LINUX_TCSETSW 0x5403
-#define LINUX_TCSETSF 0x5404
-#define LINUX_TCGETA 0x5405
-#define LINUX_TCSETA 0x5406
-#define LINUX_TCSETAW 0x5407
-#define LINUX_TCSETAF 0x5408
-#define LINUX_TCSBRK 0x5409
-#define LINUX_TCXONC 0x540A
-#define LINUX_TCFLSH 0x540B
-#define LINUX_TIOCEXCL 0x540C
-#define LINUX_TIOCNXCL 0x540D
-#define LINUX_TIOCSCTTY 0x540E
-#define LINUX_TIOCGPGRP 0x540F
-#define LINUX_TIOCSPGRP 0x5410
-#define LINUX_TIOCOUTQ 0x5411
-#define LINUX_TIOCSTI 0x5412
-#define LINUX_TIOCGWINSZ 0x5413
-#define LINUX_TIOCSWINSZ 0x5414
-#define LINUX_TIOCMGET 0x5415
-#define LINUX_TIOCMBIS 0x5416
-#define LINUX_TIOCMBIC 0x5417
-#define LINUX_TIOCMSET 0x5418
-#define LINUX_TIOCGSOFTCAR 0x5419
-#define LINUX_TIOCSSOFTCAR 0x541A
-#define LINUX_FIONREAD 0x541B
-#define LINUX_TIOCINQ FIONREAD
-#define LINUX_TIOCLINUX 0x541C
-#define LINUX_TIOCCONS 0x541D
-#define LINUX_TIOCGSERIAL 0x541E
-#define LINUX_TIOCSSERIAL 0x541F
-#define LINUX_TIOCPKT 0x5420
-#define LINUX_FIONBIO 0x5421
-#define LINUX_TIOCNOTTY 0x5422
-#define LINUX_TIOCSETD 0x5423
-#define LINUX_TIOCGETD 0x5424
-#define LINUX_TCSBRKP 0x5425
-#define LINUX_TIOCTTYGSTRUCT 0x5426
-#define LINUX_FIONCLEX 0x5450
-#define LINUX_FIOCLEX 0x5451
-#define LINUX_FIOASYNC 0x5452
-#define LINUX_TIOCSERCONFIG 0x5453
-#define LINUX_TIOCSERGWILD 0x5454
-#define LINUX_TIOCSERSWILD 0x5455
-#define LINUX_TIOCGLCKTRMIOS 0x5456
-#define LINUX_TIOCSLCKTRMIOS 0x5457
-
-#define LINUX_IOCTL_TERMIO_MIN LINUX_TCGETS
-#define LINUX_IOCTL_TERMIO_MAX LINUX_TIOCSLCKTRMIOS
-
-/* arguments for tcflow() and LINUX_TCXONC */
-#define LINUX_TCOOFF 0
-#define LINUX_TCOON 1
-#define LINUX_TCIOFF 2
-#define LINUX_TCION 3
-
-/* arguments for tcflush() and LINUX_TCFLSH */
-#define LINUX_TCIFLUSH 0
-#define LINUX_TCOFLUSH 1
-#define LINUX_TCIOFLUSH 2
-
-/* line disciplines */
-#define LINUX_N_TTY 0
-#define LINUX_N_SLIP 1
-#define LINUX_N_MOUSE 2
-#define LINUX_N_PPP 3
-
-/* Linux termio c_cc values */
-#define LINUX_VINTR 0
-#define LINUX_VQUIT 1
-#define LINUX_VERASE 2
-#define LINUX_VKILL 3
-#define LINUX_VEOF 4
-#define LINUX_VTIME 5
-#define LINUX_VMIN 6
-#define LINUX_VSWTC 7
-#define LINUX_NCC 8
-
-/* Linux termios c_cc values */
-#define LINUX_VSTART 8
-#define LINUX_VSTOP 9
-#define LINUX_VSUSP 10
-#define LINUX_VEOL 11
-#define LINUX_VREPRINT 12
-#define LINUX_VDISCARD 13
-#define LINUX_VWERASE 14
-#define LINUX_VLNEXT 15
-#define LINUX_VEOL2 16
-#define LINUX_NCCS 19
-
-#define LINUX_POSIX_VDISABLE '\0'
-
-/* Linux c_iflag masks */
-#define LINUX_IGNBRK 0x0000001
-#define LINUX_BRKINT 0x0000002
-#define LINUX_IGNPAR 0x0000004
-#define LINUX_PARMRK 0x0000008
-#define LINUX_INPCK 0x0000010
-#define LINUX_ISTRIP 0x0000020
-#define LINUX_INLCR 0x0000040
-#define LINUX_IGNCR 0x0000080
-#define LINUX_ICRNL 0x0000100
-#define LINUX_IUCLC 0x0000200
-#define LINUX_IXON 0x0000400
-#define LINUX_IXANY 0x0000800
-#define LINUX_IXOFF 0x0001000
-#define LINUX_IMAXBEL 0x0002000
-
-/* Linux c_oflag masks */
-#define LINUX_OPOST 0x0000001
-#define LINUX_OLCUC 0x0000002
-#define LINUX_ONLCR 0x0000004
-#define LINUX_OCRNL 0x0000008
-#define LINUX_ONOCR 0x0000010
-#define LINUX_ONLRET 0x0000020
-#define LINUX_OFILL 0x0000040
-#define LINUX_OFDEL 0x0000080
-#define LINUX_NLDLY 0x0000100
-
-#define LINUX_NL0 0x0000000
-#define LINUX_NL1 0x0000100
-#define LINUX_CRDLY 0x0000600
-#define LINUX_CR0 0x0000000
-#define LINUX_CR1 0x0000200
-#define LINUX_CR2 0x0000400
-#define LINUX_CR3 0x0000600
-#define LINUX_TABDLY 0x0001800
-#define LINUX_TAB0 0x0000000
-#define LINUX_TAB1 0x0000800
-#define LINUX_TAB2 0x0001000
-#define LINUX_TAB3 0x0001800
-#define LINUX_XTABS 0x0001800
-#define LINUX_BSDLY 0x0002000
-#define LINUX_BS0 0x0000000
-#define LINUX_BS1 0x0002000
-#define LINUX_VTDLY 0x0004000
-#define LINUX_VT0 0x0000000
-#define LINUX_VT1 0x0004000
-#define LINUX_FFDLY 0x0008000
-#define LINUX_FF0 0x0000000
-#define LINUX_FF1 0x0008000
-
-#define LINUX_CBAUD 0x0000100f
-#define LINUX_B0 0x00000000
-#define LINUX_B50 0x00000001
-#define LINUX_B75 0x00000002
-#define LINUX_B110 0x00000003
-#define LINUX_B134 0x00000004
-#define LINUX_B150 0x00000005
-#define LINUX_B200 0x00000006
-#define LINUX_B300 0x00000007
-#define LINUX_B600 0x00000008
-#define LINUX_B1200 0x00000009
-#define LINUX_B1800 0x0000000a
-#define LINUX_B2400 0x0000000b
-#define LINUX_B4800 0x0000000c
-#define LINUX_B9600 0x0000000d
-#define LINUX_B19200 0x0000000e
-#define LINUX_B38400 0x0000000f
-#define LINUX_EXTA LINUX_B19200
-#define LINUX_EXTB LINUX_B38400
-#define LINUX_CBAUDEX 0x00001000
-#define LINUX_B57600 0x00001001
-#define LINUX_B115200 0x00001002
-
-#define LINUX_CSIZE 0x00000030
-#define LINUX_CS5 0x00000000
-#define LINUX_CS6 0x00000010
-#define LINUX_CS7 0x00000020
-#define LINUX_CS8 0x00000030
-#define LINUX_CSTOPB 0x00000040
-#define LINUX_CREAD 0x00000080
-#define LINUX_PARENB 0x00000100
-#define LINUX_PARODD 0x00000200
-#define LINUX_HUPCL 0x00000400
-#define LINUX_CLOCAL 0x00000800
-#define LINUX_CRTSCTS 0x80000000
-
-/* Linux c_lflag masks */
-#define LINUX_ISIG 0x00000001
-#define LINUX_ICANON 0x00000002
-#define LINUX_XCASE 0x00000004
-#define LINUX_ECHO 0x00000008
-#define LINUX_ECHOE 0x00000010
-#define LINUX_ECHOK 0x00000020
-#define LINUX_ECHONL 0x00000040
-#define LINUX_NOFLSH 0x00000080
-#define LINUX_TOSTOP 0x00000100
-#define LINUX_ECHOCTL 0x00000200
-#define LINUX_ECHOPRT 0x00000400
-#define LINUX_ECHOKE 0x00000800
-#define LINUX_FLUSHO 0x00001000
-#define LINUX_PENDIN 0x00002000
-#define LINUX_IEXTEN 0x00008000
-
-/* serial_struct values for TIOC[GS]SERIAL ioctls */
-#define LINUX_ASYNC_CLOSING_WAIT_INF 0
-#define LINUX_ASYNC_CLOSING_WAIT_NONE 65535
-
-#define LINUX_PORT_UNKNOWN 0
-#define LINUX_PORT_8250 1
-#define LINUX_PORT_16450 2
-#define LINUX_PORT_16550 3
-#define LINUX_PORT_16550A 4
-#define LINUX_PORT_CIRRUS 5
-#define LINUX_PORT_16650 6
-
-#define LINUX_PORT_MAX 6
-
-#define LINUX_ASYNC_HUP_NOTIFY 0x0001
-#define LINUX_ASYNC_FOURPORT 0x0002
-#define LINUX_ASYNC_SAK 0x0004
-#define LINUX_ASYNC_SPLIT_TERMIOS 0x0008
-#define LINUX_ASYNC_SPD_MASK 0x0030
-#define LINUX_ASYNC_SPD_HI 0x0010
-#define LINUX_ASYNC_SPD_VHI 0x0020
-#define LINUX_ASYNC_SPD_CUST 0x0030
-#define LINUX_ASYNC_SKIP_TEST 0x0040
-#define LINUX_ASYNC_AUTO_IRQ 0x0080
-#define LINUX_ASYNC_SESSION_LOCKOUT 0x0100
-#define LINUX_ASYNC_PGRP_LOCKOUT 0x0200
-#define LINUX_ASYNC_CALLOUT_NOHUP 0x0400
-#define LINUX_ASYNC_FLAGS 0x0FFF
-
-#endif /* !_LINUX_IOCTL_H_ */
diff --git a/sys/alpha/linux/linux_sysvec.c b/sys/alpha/linux/linux_sysvec.c
deleted file mode 100644
index 39f3000153d2..000000000000
--- a/sys/alpha/linux/linux_sysvec.c
+++ /dev/null
@@ -1,511 +0,0 @@
-/*-
- * Copyright (c) 1994-1996 Søren Schmidt
- * 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
- * in this position and unchanged.
- * 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 withough 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.
- *
- * $FreeBSD$
- */
-
-/* XXX we use functions that might not exist. */
-#include "opt_compat.h"
-
-#ifndef COMPAT_43
-#error "Unable to compile Linux-emulator due to missing COMPAT_43 option!"
-#endif
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/buf.h>
-#include <sys/proc.h>
-#include <sys/sysent.h>
-#include <sys/imgact.h>
-#include <sys/imgact_aout.h>
-#include <sys/imgact_elf.h>
-#include <sys/signalvar.h>
-#include <sys/malloc.h>
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <vm/vm_page.h>
-#include <vm/vm_extern.h>
-#include <sys/exec.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <machine/cpu.h>
-
-#include <i386/linux/linux.h>
-#include <i386/linux/linux_proto.h>
-
-MALLOC_DEFINE(M_LINUX, "linux", "Linux mode structures");
-
-extern char linux_sigcode[];
-extern int linux_szsigcode;
-
-extern struct sysent linux_sysent[LINUX_SYS_MAXSYSCALL];
-
-extern struct linker_set linux_ioctl_handler_set;
-
-static int linux_fixup __P((register_t **stack_base,
- struct image_params *iparams));
-static int elf_linux_fixup __P((register_t **stack_base,
- struct image_params *iparams));
-static void linux_prepsyscall __P((struct trapframe *tf, int *args,
- u_int *code, caddr_t *params));
-static void linux_sendsig __P((sig_t catcher, int sig, sigset_t *mask,
- u_long code));
-
-/*
- * Linux syscalls return negative errno's, we do positive and map them
- */
-static int bsd_to_linux_errno[ELAST + 1] = {
- -0, -1, -2, -3, -4, -5, -6, -7, -8, -9,
- -10, -35, -12, -13, -14, -15, -16, -17, -18, -19,
- -20, -21, -22, -23, -24, -25, -26, -27, -28, -29,
- -30, -31, -32, -33, -34, -11,-115,-114, -88, -89,
- -90, -91, -92, -93, -94, -95, -96, -97, -98, -99,
- -100,-101,-102,-103,-104,-105,-106,-107,-108,-109,
- -110,-111, -40, -36,-112,-113, -39, -11, -87,-122,
- -116, -66, -6, -6, -6, -6, -6, -37, -38, -9,
- -6, -6, -43, -42, -75, -6, -84
-};
-
-int bsd_to_linux_signal[LINUX_SIGTBLSZ] = {
- LINUX_SIGHUP, LINUX_SIGINT, LINUX_SIGQUIT, LINUX_SIGILL,
- LINUX_SIGTRAP, LINUX_SIGABRT, 0, LINUX_SIGFPE,
- LINUX_SIGKILL, LINUX_SIGBUS, LINUX_SIGSEGV, 0,
- LINUX_SIGPIPE, LINUX_SIGALRM, LINUX_SIGTERM, LINUX_SIGURG,
- LINUX_SIGSTOP, LINUX_SIGTSTP, LINUX_SIGCONT, LINUX_SIGCHLD,
- LINUX_SIGTTIN, LINUX_SIGTTOU, LINUX_SIGIO, LINUX_SIGXCPU,
- LINUX_SIGXFSZ, LINUX_SIGVTALRM, LINUX_SIGPROF, LINUX_SIGWINCH,
- 0, LINUX_SIGUSR1, LINUX_SIGUSR2
-};
-
-int linux_to_bsd_signal[LINUX_SIGTBLSZ] = {
- SIGHUP, SIGINT, SIGQUIT, SIGILL,
- SIGTRAP, SIGABRT, SIGBUS, SIGFPE,
- SIGKILL, SIGUSR1, SIGSEGV, SIGUSR2,
- SIGPIPE, SIGALRM, SIGTERM, SIGBUS,
- SIGCHLD, SIGCONT, SIGSTOP, SIGTSTP,
- SIGTTIN, SIGTTOU, SIGURG, SIGXCPU,
- SIGXFSZ, SIGVTALRM, SIGPROF, SIGWINCH,
- SIGIO, SIGURG, 0
-};
-
-/*
- * If FreeBSD & Linux have a difference of opinion about what a trap
- * means, deal with it here.
- */
-static int
-translate_traps(int signal, int trap_code)
-{
- if (signal != SIGBUS)
- return signal;
- switch (trap_code) {
- case T_PROTFLT:
- case T_TSSFLT:
- case T_DOUBLEFLT:
- case T_PAGEFLT:
- return SIGSEGV;
- default:
- return signal;
- }
-}
-
-static int
-linux_fixup(register_t **stack_base, struct image_params *imgp)
-{
- register_t *argv, *envp;
-
- argv = *stack_base;
- envp = *stack_base + (imgp->argc + 1);
- (*stack_base)--;
- **stack_base = (intptr_t)(void *)envp;
- (*stack_base)--;
- **stack_base = (intptr_t)(void *)argv;
- (*stack_base)--;
- **stack_base = imgp->argc;
- return 0;
-}
-
-static int
-elf_linux_fixup(register_t **stack_base, struct image_params *imgp)
-{
- Elf32_Auxargs *args = (Elf32_Auxargs *)imgp->auxargs;
- register_t *pos;
-
- pos = *stack_base + (imgp->argc + imgp->envc + 2);
-
- if (args->trace) {
- AUXARGS_ENTRY(pos, AT_DEBUG, 1);
- }
- if (args->execfd != -1) {
- AUXARGS_ENTRY(pos, AT_EXECFD, args->execfd);
- }
- AUXARGS_ENTRY(pos, AT_PHDR, args->phdr);
- AUXARGS_ENTRY(pos, AT_PHENT, args->phent);
- AUXARGS_ENTRY(pos, AT_PHNUM, args->phnum);
- AUXARGS_ENTRY(pos, AT_PAGESZ, args->pagesz);
- AUXARGS_ENTRY(pos, AT_FLAGS, args->flags);
- AUXARGS_ENTRY(pos, AT_ENTRY, args->entry);
- AUXARGS_ENTRY(pos, AT_BASE, args->base);
- AUXARGS_ENTRY(pos, AT_UID, imgp->proc->p_cred->p_ruid);
- AUXARGS_ENTRY(pos, AT_EUID, imgp->proc->p_cred->p_svuid);
- AUXARGS_ENTRY(pos, AT_GID, imgp->proc->p_cred->p_rgid);
- AUXARGS_ENTRY(pos, AT_EGID, imgp->proc->p_cred->p_svgid);
- AUXARGS_ENTRY(pos, AT_NULL, 0);
-
- free(imgp->auxargs, M_TEMP);
- imgp->auxargs = NULL;
-
- (*stack_base)--;
- **stack_base = (long)imgp->argc;
- return 0;
-}
-
-extern int _ucodesel, _udatasel;
-
-/*
- * Send an interrupt to process.
- *
- * Stack is set up to allow sigcode stored
- * in u. to call routine, followed by kcall
- * to sigreturn routine below. After sigreturn
- * resets the signal mask, the stack, and the
- * frame pointer, it returns to the user
- * specified pc, psl.
- */
-
-static void
-linux_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
-{
- register struct proc *p = curproc;
- register struct trapframe *regs;
- struct linux_sigframe *fp, frame;
- struct sigacts *psp = p->p_sigacts;
- int oonstack;
-
- regs = p->p_md.md_regs;
- oonstack = p->p_sigstk.ss_flags & SS_ONSTACK;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): linux_sendsig(%p, %d, %p, %lu)\n",
- (long)p->p_pid, catcher, sig, (void*)mask, code);
-#endif
- /*
- * Allocate space for the signal handler context.
- */
- if ((p->p_flag & P_ALTSTACK) && !oonstack &&
- SIGISMEMBER(psp->ps_sigonstack, sig)) {
- fp = (struct linux_sigframe *)(p->p_sigstk.ss_sp +
- p->p_sigstk.ss_size - sizeof(struct linux_sigframe));
- p->p_sigstk.ss_flags |= SS_ONSTACK;
- } else {
- fp = (struct linux_sigframe *)regs->tf_esp - 1;
- }
-
- /*
- * grow() will return FALSE if the fp will not fit inside the stack
- * and the stack can not be grown. useracc will return FALSE
- * if access is denied.
- */
- if ((grow_stack (p, (int)fp) == FALSE) ||
- !useracc((caddr_t)fp, sizeof (struct linux_sigframe),
- VM_PROT_WRITE)) {
- /*
- * Process has trashed its stack; give it an illegal
- * instruction to halt it in its tracks.
- */
- SIGACTION(p, SIGILL) = SIG_DFL;
- SIGDELSET(p->p_sigignore, SIGILL);
- SIGDELSET(p->p_sigcatch, SIGILL);
- SIGDELSET(p->p_sigmask, SIGILL);
- psignal(p, SIGILL);
- return;
- }
-
- /*
- * Build the argument list for the signal handler.
- */
- if (p->p_sysent->sv_sigtbl)
- if (sig <= p->p_sysent->sv_sigsize)
- sig = p->p_sysent->sv_sigtbl[_SIG_IDX(sig)];
-
- frame.sf_handler = catcher;
- frame.sf_sig = sig;
-
- /*
- * Build the signal context to be used by sigreturn.
- */
- frame.sf_sc.sc_mask = mask->__bits[0];
- frame.sf_sc.sc_gs = rgs();
- frame.sf_sc.sc_fs = regs->tf_fs;
- frame.sf_sc.sc_es = regs->tf_es;
- frame.sf_sc.sc_ds = regs->tf_ds;
- frame.sf_sc.sc_edi = regs->tf_edi;
- frame.sf_sc.sc_esi = regs->tf_esi;
- frame.sf_sc.sc_ebp = regs->tf_ebp;
- frame.sf_sc.sc_ebx = regs->tf_ebx;
- frame.sf_sc.sc_edx = regs->tf_edx;
- frame.sf_sc.sc_ecx = regs->tf_ecx;
- frame.sf_sc.sc_eax = regs->tf_eax;
- frame.sf_sc.sc_eip = regs->tf_eip;
- frame.sf_sc.sc_cs = regs->tf_cs;
- frame.sf_sc.sc_eflags = regs->tf_eflags;
- frame.sf_sc.sc_esp_at_signal = regs->tf_esp;
- frame.sf_sc.sc_ss = regs->tf_ss;
- frame.sf_sc.sc_err = regs->tf_err;
- frame.sf_sc.sc_trapno = code; /* XXX ???? */
-
- if (copyout(&frame, fp, sizeof(frame)) != 0) {
- /*
- * Process has trashed its stack; give it an illegal
- * instruction to halt it in its tracks.
- */
- sigexit(p, SIGILL);
- /* NOTREACHED */
- }
-
- /*
- * Build context to run handler in.
- */
- regs->tf_esp = (int)fp;
- regs->tf_eip = PS_STRINGS - *(p->p_sysent->sv_szsigcode);
- regs->tf_eflags &= ~PSL_VM;
- regs->tf_cs = _ucodesel;
- regs->tf_ds = _udatasel;
- regs->tf_es = _udatasel;
- regs->tf_fs = _udatasel;
- load_gs(_udatasel);
- regs->tf_ss = _udatasel;
-}
-
-/*
- * System call to cleanup state after a signal
- * has been taken. Reset signal mask and
- * stack state from context left by sendsig (above).
- * Return to previous pc and psl as specified by
- * context left by sendsig. Check carefully to
- * make sure that the user has not modified the
- * psl to gain improper privileges or to cause
- * a machine fault.
- */
-int
-linux_sigreturn(p, args)
- struct proc *p;
- struct linux_sigreturn_args *args;
-{
- struct linux_sigcontext *scp, context;
- register struct trapframe *regs;
- int eflags;
-
- regs = p->p_md.md_regs;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): linux_sigreturn(%p)\n",
- (long)p->p_pid, (void *)args->scp);
-#endif
- /*
- * The trampoline code hands us the context.
- * It is unsafe to keep track of it ourselves, in the event that a
- * program jumps out of a signal handler.
- */
- scp = SCARG(args,scp);
- if (copyin((caddr_t)scp, &context, sizeof(*scp)) != 0)
- return (EFAULT);
-
- /*
- * Check for security violations.
- */
-#define EFLAGS_SECURE(ef, oef) ((((ef) ^ (oef)) & ~PSL_USERCHANGE) == 0)
- eflags = context.sc_eflags;
- /*
- * XXX do allow users to change the privileged flag PSL_RF. The
- * cpu sets PSL_RF in tf_eflags for faults. Debuggers should
- * sometimes set it there too. tf_eflags is kept in the signal
- * context during signal handling and there is no other place
- * to remember it, so the PSL_RF bit may be corrupted by the
- * signal handler without us knowing. Corruption of the PSL_RF
- * bit at worst causes one more or one less debugger trap, so
- * allowing it is fairly harmless.
- */
- if (!EFLAGS_SECURE(eflags & ~PSL_RF, regs->tf_eflags & ~PSL_RF)) {
- return(EINVAL);
- }
-
- /*
- * Don't allow users to load a valid privileged %cs. Let the
- * hardware check for invalid selectors, excess privilege in
- * other selectors, invalid %eip's and invalid %esp's.
- */
-#define CS_SECURE(cs) (ISPL(cs) == SEL_UPL)
- if (!CS_SECURE(context.sc_cs)) {
- trapsignal(p, SIGBUS, T_PROTFLT);
- return(EINVAL);
- }
-
- p->p_sigstk.ss_flags &= ~SS_ONSTACK;
- SIGSETOLD(p->p_sigmask, context.sc_mask);
- SIG_CANTMASK(p->p_sigmask);
-
- /*
- * Restore signal context.
- */
- /* %gs was restored by the trampoline. */
- regs->tf_fs = context.sc_fs;
- regs->tf_es = context.sc_es;
- regs->tf_ds = context.sc_ds;
- regs->tf_edi = context.sc_edi;
- regs->tf_esi = context.sc_esi;
- regs->tf_ebp = context.sc_ebp;
- regs->tf_ebx = context.sc_ebx;
- regs->tf_edx = context.sc_edx;
- regs->tf_ecx = context.sc_ecx;
- regs->tf_eax = context.sc_eax;
- regs->tf_eip = context.sc_eip;
- regs->tf_cs = context.sc_cs;
- regs->tf_eflags = eflags;
- regs->tf_esp = context.sc_esp_at_signal;
- regs->tf_ss = context.sc_ss;
-
- return (EJUSTRETURN);
-}
-
-static void
-linux_prepsyscall(struct trapframe *tf, int *args, u_int *code, caddr_t *params)
-{
- args[0] = tf->tf_ebx;
- args[1] = tf->tf_ecx;
- args[2] = tf->tf_edx;
- args[3] = tf->tf_esi;
- args[4] = tf->tf_edi;
- *params = NULL; /* no copyin */
-}
-
-struct sysentvec linux_sysvec = {
- LINUX_SYS_MAXSYSCALL,
- linux_sysent,
- 0xff,
- LINUX_SIGTBLSZ,
- bsd_to_linux_signal,
- ELAST + 1,
- bsd_to_linux_errno,
- translate_traps,
- linux_fixup,
- linux_sendsig,
- linux_sigcode,
- &linux_szsigcode,
- linux_prepsyscall,
- "Linux a.out",
- aout_coredump
-};
-
-struct sysentvec elf_linux_sysvec = {
- LINUX_SYS_MAXSYSCALL,
- linux_sysent,
- 0xff,
- LINUX_SIGTBLSZ,
- bsd_to_linux_signal,
- ELAST + 1,
- bsd_to_linux_errno,
- translate_traps,
- elf_linux_fixup,
- linux_sendsig,
- linux_sigcode,
- &linux_szsigcode,
- linux_prepsyscall,
- "Linux ELF",
- elf_coredump
-};
-
-static Elf32_Brandinfo linux_brand = {
- "Linux",
- "/compat/linux",
- "/lib/ld-linux.so.1",
- &elf_linux_sysvec
- };
-
-static Elf32_Brandinfo linux_glibc2brand = {
- "Linux",
- "/compat/linux",
- "/lib/ld-linux.so.2",
- &elf_linux_sysvec
- };
-
-Elf32_Brandinfo *linux_brandlist[] = {
- &linux_brand,
- &linux_glibc2brand,
- NULL
- };
-
-static int
-linux_elf_modevent(module_t mod, int type, void *data)
-{
- Elf32_Brandinfo **brandinfo;
- int error;
-
- error = 0;
-
- switch(type) {
- case MOD_LOAD:
- for (brandinfo = &linux_brandlist[0]; *brandinfo != NULL;
- ++brandinfo)
- if (elf_insert_brand_entry(*brandinfo) < 0)
- error = EINVAL;
- if (error)
- printf("cannot insert Linux elf brand handler\n");
- else {
- linux_ioctl_register_handlers(&linux_ioctl_handler_set);
- if (bootverbose)
- printf("Linux-ELF exec handler installed\n");
- }
- break;
- case MOD_UNLOAD:
- linux_ioctl_unregister_handlers(&linux_ioctl_handler_set);
- for (brandinfo = &linux_brandlist[0]; *brandinfo != NULL;
- ++brandinfo)
- if (elf_brand_inuse(*brandinfo))
- error = EBUSY;
-
- if (error == 0) {
- for (brandinfo = &linux_brandlist[0];
- *brandinfo != NULL; ++brandinfo)
- if (elf_remove_brand_entry(*brandinfo) < 0)
- error = EINVAL;
- }
- if (error)
- printf("Could not deinstall ELF interpreter entry\n");
- else if (bootverbose)
- printf("Linux-elf exec handler removed\n");
- break;
- default:
- break;
- }
- return error;
-}
-static moduledata_t linux_elf_mod = {
- "linuxelf",
- linux_elf_modevent,
- 0
-};
-DECLARE_MODULE(linuxelf, linux_elf_mod, SI_SUB_EXEC, SI_ORDER_ANY);
diff --git a/sys/alpha/linux/syscalls.master b/sys/alpha/linux/syscalls.master
deleted file mode 100644
index e276c9309f5e..000000000000
--- a/sys/alpha/linux/syscalls.master
+++ /dev/null
@@ -1,286 +0,0 @@
- $FreeBSD$
-
-; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
-; System call name/number master file (or rather, slave, from LINUX).
-; Processed to created linux_sysent.c, linux_syscalls.c and linux_syscall.h.
-
-; Columns: number type nargs namespc name alt{name,tag,rtyp}/comments
-; number system call number, must be in order
-; type one of STD, OBSOL, UNIMPL, COMPAT
-; namespc one of POSIX, BSD, STD, NOHIDE (I dont care :-) -Peter
-; name psuedo-prototype of syscall routine
-; If one of the following alts is different, then all appear:
-; altname name of system call if different
-; alttag name of args struct tag if different from [o]`name'"_args"
-; altrtyp return type if not int (bogus - syscalls always return int)
-; for UNIMPL/OBSOL, name continues with comments
-
-; types:
-; STD always included
-; COMPAT included on COMPAT #ifdef
-; LIBCOMPAT included on COMPAT #ifdef, and placed in syscall.h
-; OBSOL obsolete, not included in system, only specifies name
-; UNIMPL not implemented, placeholder only
-
-#include "opt_compat.h"
-#include <sys/param.h>
-#include <sys/sysent.h>
-#include <sys/sysproto.h>
-#include <i386/linux/linux.h>
-#include <i386/linux/linux_proto.h>
-
-; #ifdef's, etc. may be included, and are copied to the output files.
-
-0 STD LINUX { int linux_setup(void); }
-1 NOPROTO LINUX { int exit(int rval); }
-2 STD LINUX { int linux_fork(void); }
-3 NOPROTO LINUX { int read(int fd, char *buf, u_int nbyte); }
-4 NOPROTO LINUX { int write(int fd, char *buf, u_int nbyte); }
-5 STD LINUX { int linux_open(char *path, int flags, int mode); }
-6 NOPROTO LINUX { int close(int fd); }
-7 STD LINUX { int linux_waitpid(int pid, int *status, \
- int options); }
-8 STD LINUX { int linux_creat(char *path, int mode); }
-9 STD LINUX { int linux_link(char *path, char *to); }
-10 STD LINUX { int linux_unlink(char *path); }
-11 STD LINUX { int linux_execve(char *path, char **argp, \
- char **envp); }
-12 STD LINUX { int linux_chdir(char *path); }
-13 STD LINUX { int linux_time(linux_time_t *tm); }
-14 STD LINUX { int linux_mknod(char *path, int mode, int dev); }
-15 STD LINUX { int linux_chmod(char *path, int mode); }
-16 STD LINUX { int linux_lchown(char *path, int uid, int gid); }
-17 STD LINUX { int linux_break(char *nsize); }
-18 STD LINUX { int linux_stat(char *path, struct ostat *up); }
-19 STD LINUX { int linux_lseek(int fdes, long off, int whence); }
-20 NOPROTO LINUX { int getpid(void); }
-21 STD LINUX { int linux_mount(void); }
-22 STD LINUX { int linux_umount(void); }
-23 NOPROTO LINUX { int setuid(uid_t uid); }
-24 NOPROTO LINUX { int getuid(void); }
-25 STD LINUX { int linux_stime(void); }
-26 STD LINUX { int linux_ptrace(void); }
-27 STD LINUX { int linux_alarm(unsigned int secs); }
-28 STD LINUX { int linux_fstat(int fd, struct ostat *up); }
-29 STD LINUX { int linux_pause(void); }
-30 STD LINUX { int linux_utime(char *fname, \
- struct linux_utimbuf *times); }
-31 STD LINUX { int linux_stty(void); }
-32 STD LINUX { int linux_gtty(void); }
-33 STD LINUX { int linux_access(char *path, int flags); }
-34 STD LINUX { int linux_nice(int inc); }
-35 STD LINUX { int linux_ftime(void); }
-36 NOPROTO LINUX { int sync(void); }
-37 STD LINUX { int linux_kill(int pid, int signum); }
-38 STD LINUX { int linux_rename(char *from, char *to); }
-39 STD LINUX { int linux_mkdir(char *path, int mode); }
-40 STD LINUX { int linux_rmdir(char *path); }
-41 NOPROTO LINUX { int dup(u_int fd); }
-42 STD LINUX { int linux_pipe(int *pipefds); }
-43 STD LINUX { int linux_times(struct linux_times_argv *buf); }
-44 STD LINUX { int linux_prof(void); }
-45 STD LINUX { int linux_brk(char *dsend); }
-46 NOPROTO LINUX { int setgid(gid_t gid); }
-47 NOPROTO LINUX { int getgid(void); }
-48 STD LINUX { int linux_signal(int sig, linux_handler_t handler); }
-49 NOPROTO LINUX { int geteuid(void); }
-50 NOPROTO LINUX { int getegid(void); }
-51 NOPROTO LINUX { int acct(char *path); }
-52 STD LINUX { int linux_umount2(void); }
-53 STD LINUX { int linux_lock(void); }
-54 STD LINUX { int linux_ioctl(int fd, u_long cmd, int arg); }
-55 STD LINUX { int linux_fcntl(int fd, int cmd, int arg); }
-56 STD LINUX { int linux_mpx(void); }
-57 NOPROTO LINUX { int setpgid(int pid, int pgid); }
-58 STD LINUX { int linux_ulimit(void); }
-59 STD LINUX { int linux_olduname(void); }
-60 NOPROTO LINUX { int umask(int newmask); }
-61 NOPROTO LINUX { int chroot(char *path); }
-62 STD LINUX { int linux_ustat(linux_dev_t dev, \
- struct linux_ustat *ubuf); }
-63 NOPROTO LINUX { int dup2(u_int from, u_int to); }
-64 NOPROTO LINUX { int getppid(void); }
-65 NOPROTO LINUX { int getpgrp(void); }
-66 NOPROTO LINUX { int setsid(void); }
-67 STD LINUX { int linux_sigaction(int sig, \
- linux_osigaction_t *nsa, \
- linux_osigaction_t *osa); }
-68 STD LINUX { int linux_siggetmask(void); }
-69 STD LINUX { int linux_sigsetmask(linux_osigset_t mask); }
-70 NOPROTO LINUX { int setreuid(int ruid, int euid); }
-71 NOPROTO LINUX { int setregid(int rgid, int egid); }
-72 STD LINUX { int linux_sigsuspend(int restart, \
- linux_osigset_t oldmask, \
- linux_osigset_t mask); }
-73 STD LINUX { int linux_sigpending(linux_osigset_t *mask); }
-74 NOPROTO LINUX { int osethostname(char *hostname, u_int len); }
-75 STD LINUX { int linux_setrlimit(u_int resource, \
- struct ogetrlimit *rlim); }
-76 STD LINUX { int linux_getrlimit(u_int resource, \
- struct ogetrlimit *rlim); }
-77 NOPROTO LINUX { int getrusage(int who, struct rusage *rusage); }
-78 NOPROTO LINUX { int gettimeofday(struct timeval *tp, \
- struct timezone *tzp); }
-79 NOPROTO LINUX { int settimeofday(struct timeval *tp, \
- struct timezone *tzp); }
-80 STD LINUX { int linux_getgroups(u_int gidsetsize, \
- linux_gid_t *gidset); }
-81 STD LINUX { int linux_setgroups(u_int gidsetsize, \
- linux_gid_t *gidset); }
-82 STD LINUX { int linux_select(struct linux_select_argv *ptr); }
-83 STD LINUX { int linux_symlink(char *path, char *to); }
-84 NOPROTO LINUX { int ostat(char *path, struct ostat *up); }
-85 STD LINUX { int linux_readlink(char *name, char *buf, \
- int count); }
-86 STD LINUX { int linux_uselib(char *library); }
-87 NOPROTO LINUX { int swapon(char *name); }
-88 NOPROTO LINUX { int reboot(int opt); }
-89 STD LINUX { int linux_readdir(int fd, \
- struct linux_dirent *dent, \
- unsigned int count); }
-90 STD LINUX { int linux_mmap(struct linux_mmap_argv *ptr); }
-91 NOPROTO LINUX { int munmap(caddr_t addr, int len); }
-92 STD LINUX { int linux_truncate(char *path, long length); }
-93 NOPROTO LINUX { int oftruncate(int fd, long length); }
-94 NOPROTO LINUX { int fchmod(int fd, int mode); }
-95 NOPROTO LINUX { int fchown(int fd, int uid, int gid); }
-96 NOPROTO LINUX { int getpriority(int which, int who); }
-97 NOPROTO LINUX { int setpriority(int which, int who, int prio); }
-98 NOPROTO LINUX { int profil(caddr_t samples, u_int size, \
- u_int offset, u_int scale); }
-99 STD LINUX { int linux_statfs(char *path, \
- struct linux_statfs_buf *buf); }
-100 STD LINUX { int linux_fstatfs(int fd, \
- struct linux_statfs_buf *buf); }
-101 STD LINUX { int linux_ioperm(unsigned int start, \
- unsigned int length, int enable); }
-102 STD LINUX { int linux_socketcall(int what, void *args); }
-103 STD LINUX { int linux_ksyslog(int what); }
-104 STD LINUX { int linux_setitimer(u_int which, \
- struct itimerval *itv, \
- struct itimerval *oitv); }
-105 STD LINUX { int linux_getitimer(u_int which, \
- struct itimerval *itv); }
-106 STD LINUX { int linux_newstat(char *path, \
- struct linux_newstat *buf); }
-107 STD LINUX { int linux_newlstat(char *path, \
- struct linux_newstat *buf); }
-108 STD LINUX { int linux_newfstat(int fd, \
- struct linux_newstat *buf); }
-109 STD LINUX { int linux_uname(void); }
-110 STD LINUX { int linux_iopl(int level); }
-111 STD LINUX { int linux_vhangup(void); }
-112 STD LINUX { int linux_idle(void); }
-113 STD LINUX { int linux_vm86old(void); }
-114 STD LINUX { int linux_wait4(int pid, int *status, \
- int options, struct rusage *rusage); }
-115 STD LINUX { int linux_swapoff(void); }
-116 STD LINUX { int linux_sysinfo(void); }
-117 STD LINUX { int linux_ipc(int what, int arg1, int arg2, \
- int arg3, caddr_t ptr); }
-118 NOPROTO LINUX { int fsync(int fd); }
-119 STD LINUX { int linux_sigreturn(struct linux_sigcontext *scp); }
-120 STD LINUX { int linux_clone(int flags, void *stack); }
-121 NOPROTO LINUX { int setdomainname(char *name, int len); }
-122 STD LINUX { int linux_newuname(struct linux_new_utsname *buf); }
-123 STD LINUX { int linux_modify_ldt(int func, void *ptr, \
- size_t bytecount); }
-124 STD LINUX { int linux_adjtimex(void); }
-125 NOPROTO LINUX { int mprotect(caddr_t addr, int len, int prot); }
-126 STD LINUX { int linux_sigprocmask(int how, \
- linux_osigset_t *mask, \
- linux_osigset_t *omask); }
-127 STD LINUX { int linux_create_module(void); }
-128 STD LINUX { int linux_init_module(void); }
-129 STD LINUX { int linux_delete_module(void); }
-130 STD LINUX { int linux_get_kernel_syms(void); }
-131 STD LINUX { int linux_quotactl(void); }
-132 STD LINUX { int linux_getpgid(int pid); }
-133 NOPROTO LINUX { int fchdir(int fd); }
-134 STD LINUX { int linux_bdflush(void); }
-135 STD LINUX { int linux_sysfs(int option, u_long arg1, \
- u_long arg2); }
-136 STD LINUX { int linux_personality(int per); }
-137 STD LINUX { int linux_afs_syscall(void); }
-138 STD LINUX { int linux_setfsuid(linux_uid_t uid); }
-139 STD LINUX { int linux_setfsgid(linux_gid_t gid); }
-140 STD LINUX { int linux_llseek(int fd, u_int32_t ohigh, \
- u_int32_t olow, caddr_t res, int whence); }
-141 STD LINUX { int linux_getdents(int fd, void *dent, \
- unsigned count); }
-142 STD LINUX { int linux_newselect(int nfds, fd_set *readfds, \
- fd_set *writefds, fd_set *exceptfds, \
- struct timeval *timeout); }
-143 NOPROTO LINUX { int flock(int fd, int how); }
-144 STD LINUX { int linux_msync(caddr_t addr, int len, int fl); }
-145 NOPROTO LINUX { int readv(int fd, struct iovec *iovp, \
- u_int iovcnt); }
-146 NOPROTO LINUX { int writev(int fd, struct iovec *iovp, \
- u_int iovcnt); }
-147 STD LINUX { int linux_getsid(linux_pid_t pid); }
-148 STD LINUX { int linux_fdatasync(int fd); }
-149 STD LINUX { int linux_sysctl(void); }
-150 NOPROTO BSD { int mlock(const void *addr, size_t len); }
-151 NOPROTO BSD { int munlock(const void *addr, size_t len); }
-152 NOPROTO BSD { int mlockall(int how); }
-153 NOPROTO BSD { int munlockall(void); }
-154 NOPROTO POSIX { int sched_setparam (pid_t pid, \
- const struct sched_param *param); }
-155 NOPROTO POSIX { int sched_getparam (pid_t pid, \
- struct sched_param *param); }
-156 STD POSIX { int linux_sched_setscheduler(pid_t pid, int policy, \
- const struct sched_param *param); }
-157 STD POSIX { int linux_sched_getscheduler(pid_t pid); }
-158 NOPROTO POSIX { int sched_yield (void); }
-159 NOPROTO POSIX { int sched_get_priority_max (int policy); }
-160 NOPROTO POSIX { int sched_get_priority_min (int policy); }
-161 NOPROTO POSIX { int sched_rr_get_interval (pid_t pid, \
- struct timespec *interval); }
-162 NOPROTO POSIX { int nanosleep(const struct timespec *rqtp, \
- struct timespec *rmtp); }
-163 STD LINUX { int linux_mremap(caddr_t addr, int old_len, \
- int new_len, int flags); }
-164 NOPROTO LINUX { int setresuid(int ruid, int euid, int suid); }
-165 STD LINUX { int linux_getresuid(linux_uid_t *ruid, \
- linux_uid_t *euid, linux_uid_t *suid); }
-166 STD LINUX { int linux_vm86(void); }
-167 STD LINUX { int linux_query_module(void); }
-168 NOPROTO LINUX { int poll(struct pollfd*, unsigned int nfds, \
- long timeout); }
-169 STD LINUX { int linux_nfsservctl(void); }
-170 NOPROTO LINUX { int setresgid(int rgid, int egid, int sgid); }
-171 STD LINUX { int linux_getresgid(linux_gid_t *rgid, \
- linux_gid_t *egid, linux_gid_t *sgid); }
-172 STD LINUX { int linux_prctl(void); }
-173 STD LINUX { int linux_rt_sigreturn(void); }
-174 STD LINUX { int linux_rt_sigaction(int sig, \
- linux_sigaction_t *act, \
- linux_sigaction_t *oact, \
- size_t sigsetsize); }
-175 STD LINUX { int linux_rt_sigprocmask(int how, \
- linux_sigset_t *mask, linux_sigset_t *omask, \
- size_t sigsetsize); }
-176 STD LINUX { int linux_rt_sigpending(void); }
-177 STD LINUX { int linux_rt_sigtimedwait(void); }
-178 STD LINUX { int linux_rt_sigqueueinfo(void); }
-179 STD LINUX { int linux_rt_sigsuspend(linux_sigset_t *newset, \
- size_t sigsetsize); }
-180 STD LINUX { int linux_pread(void); }
-181 STD LINUX { int linux_pwrite(void); }
-182 STD LINUX { int linux_chown(char *path, int uid, int gid); }
-183 STD LINUX { int linux_getcwd(char *buf, unsigned long bufsize); }
-184 STD LINUX { int linux_capget(void); }
-185 STD LINUX { int linux_capset(void); }
-186 STD LINUX { int linux_sigaltstack(const linux_stack_t *uss, \
- linux_stack_t *uoss); }
-187 STD LINUX { int linux_sendfile(void); }
-188 STD LINUX { int linux_getpmsg(void); }
-189 STD LINUX { int linux_putpmsg(void); }
-190 STD LINUX { int linux_vfork(void); }
-191 STD LINUX { int linux_ugetrlimit(void); }
-192 STD LINUX { int linux_mmap2(void); }
-193 STD LINUX { int linux_truncate64(void); }
-194 STD LINUX { int linux_ftruncate64(void); }
-195 STD LINUX { int linux_stat64(void); }
-196 STD LINUX { int linux_lstat64(void); }
-197 STD LINUX { int linux_fstat64(void); }
diff --git a/sys/amd64/Makefile b/sys/amd64/Makefile
deleted file mode 100644
index bc97ebfda4ac..000000000000
--- a/sys/amd64/Makefile
+++ /dev/null
@@ -1,39 +0,0 @@
-# $FreeBSD$
-# @(#)Makefile 8.1 (Berkeley) 6/11/93
-
-# Makefile for i386 links, tags file
-
-# SYS is normally set in Make.tags.inc
-# SYS=/sys
-
-TAGDIR= i386
-
-.include "../kern/Make.tags.inc"
-
-all:
- @echo "make links or tags only"
-
-# Directories in which to place i386 tags links
-DI386= apm conf eisa i386 ibcs2 include isa linux
-
-links::
- -for i in ${COMMDIR1}; do \
- (cd $$i && { rm -f tags; ln -s ../${TAGDIR}/tags tags; }) done
- -for i in ${COMMDIR2}; do \
- (cd $$i && { rm -f tags; ln -s ../../${TAGDIR}/tags tags; }) done
- -for i in ${DI386}; do \
- (cd $$i && { rm -f tags; ln -s ../tags tags; }) done
-
-SI386= ${SYS}/i386/apm/*.[ch] ${SYS}/i386/eisa/*.[ch] \
- ${SYS}/i386/i386/*.[ch] ${SYS}/i386/ibcs2/*.[ch] \
- ${SYS}/i386/include/*.[ch] ${SYS}/i386/isa/*.[ch] \
- ${SYS}/i386/linux/*.[ch]
-AI386= ${SYS}/i386/i386/*.s
-
-tags::
- -ctags -wdt ${COMM} ${SI386}
- egrep "^ENTRY(.*)|^ALTENTRY(.*)" ${AI386} | \
- sed "s;\([^:]*\):\([^(]*\)(\([^, )]*\)\(.*\);\3 \1 /^\2(\3\4$$/;" \
- >> tags
- sort -o tags tags
- chmod 444 tags
diff --git a/sys/amd64/amd64/amd64-gdbstub.c b/sys/amd64/amd64/amd64-gdbstub.c
deleted file mode 100644
index a2323ce90f49..000000000000
--- a/sys/amd64/amd64/amd64-gdbstub.c
+++ /dev/null
@@ -1,617 +0,0 @@
-/****************************************************************************
-
- THIS SOFTWARE IS NOT COPYRIGHTED
-
- HP offers the following for use in the public domain. HP makes no
- warranty with regard to the software or its performance and the
- user accepts the software "AS IS" with all faults.
-
- HP DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, WITH REGARD
- TO THIS SOFTWARE INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-
-****************************************************************************/
-
-/****************************************************************************
- * Header: remcom.c,v 1.34 91/03/09 12:29:49 glenne Exp $
- *
- * Module name: remcom.c $
- * Revision: 1.34 $
- * Date: 91/03/09 12:29:49 $
- * Contributor: Lake Stevens Instrument Division$
- *
- * Description: low level support for gdb debugger. $
- *
- * Considerations: only works on target hardware $
- *
- * Written by: Glenn Engel $
- * ModuleState: Experimental $
- *
- * NOTES: See Below $
- *
- * Modified for FreeBSD by Stu Grossman.
- *
- * To enable debugger support, two things need to happen. One, a
- * call to set_debug_traps() is necessary in order to allow any breakpoints
- * or error conditions to be properly intercepted and reported to gdb.
- * Two, a breakpoint needs to be generated to begin communication. This
- * is most easily accomplished by a call to breakpoint(). Breakpoint()
- * simulates a breakpoint by executing a trap #1.
- *
- * The external function exceptionHandler() is
- * used to attach a specific handler to a specific 386 vector number.
- * It should use the same privilege level it runs at. It should
- * install it as an interrupt gate so that interrupts are masked
- * while the handler runs.
- * Also, need to assign exceptionHook and oldExceptionHook.
- *
- * Because gdb will sometimes write to the stack area to execute function
- * calls, this program cannot rely on using the supervisor stack so it
- * uses its own stack area reserved in the int array remcomStack.
- *
- *************
- *
- * The following gdb commands are supported:
- *
- * command function Return value
- *
- * g return the value of the CPU registers hex data or ENN
- * G set the value of the CPU registers OK or ENN
- *
- * mAA..AA,LLLL Read LLLL bytes at address AA..AA hex data or ENN
- * MAA..AA,LLLL: Write LLLL bytes at address AA.AA OK or ENN
- *
- * c Resume at current address SNN ( signal NN)
- * cAA..AA Continue at address AA..AA SNN
- *
- * s Step one instruction SNN
- * sAA..AA Step one instruction from AA..AA SNN
- *
- * k kill
- *
- * ? What was the last sigval ? SNN (signal NN)
- *
- * D detach OK
- *
- * All commands and responses are sent with a packet which includes a
- * checksum. A packet consists of
- *
- * $<packet info>#<checksum>.
- *
- * where
- * <packet info> :: <characters representing the command or response>
- * <checksum> :: < two hex digits computed as modulo 256 sum of <packetinfo>>
- *
- * When a packet is received, it is first acknowledged with either '+' or '-'.
- * '+' indicates a successful transfer. '-' indicates a failed transfer.
- *
- * Example:
- *
- * Host: Reply:
- * $m0,10#2a +$00010203040506070809101112131415#42
- *
- ****************************************************************************/
-
-#include <sys/param.h>
-#include <sys/reboot.h>
-#include <sys/systm.h>
-#include <sys/cons.h>
-
-#include <ddb/ddb.h>
-
-#include <setjmp.h>
-
-#include "sio.h"
-#include "opt_ddb.h"
-
-void gdb_handle_exception (db_regs_t *, int, int);
-
-#if NSIO == 0
-void
-gdb_handle_exception (db_regs_t *raw_regs, int type, int code)
-{
-}
-#else
-/************************************************************************/
-
-extern jmp_buf db_jmpbuf;
-
-/************************************************************************/
-/* BUFMAX defines the maximum number of characters in inbound/outbound buffers*/
-/* at least NUMREGBYTES*2 are needed for register packets */
-#define BUFMAX 400
-
-/* Create private copies of common functions used by the stub. This prevents
- nasty interactions between app code and the stub (for instance if user steps
- into strlen, etc..) */
-
-#define strlen gdb_strlen
-#define strcpy gdb_strcpy
-
-static int
-strlen (const char *s)
-{
- const char *s1 = s;
-
- while (*s1++ != '\000');
-
- return s1 - s;
-}
-
-static char *
-strcpy (char *dst, const char *src)
-{
- char *retval = dst;
-
- while ((*dst++ = *src++) != '\000');
-
- return retval;
-}
-
-static int
-putDebugChar (int c) /* write a single character */
-{
- if (gdbdev == NODEV)
- return 0;
- (*gdb_putc)(gdbdev, c);
- return 1;
-}
-
-static int
-getDebugChar (void) /* read and return a single char */
-{
- if (gdbdev == NODEV)
- return -1;
- return (*gdb_getc)(gdbdev);
-}
-
-static const char hexchars[]="0123456789abcdef";
-
-static int
-hex(char ch)
-{
- if ((ch >= 'a') && (ch <= 'f')) return (ch-'a'+10);
- if ((ch >= '0') && (ch <= '9')) return (ch-'0');
- if ((ch >= 'A') && (ch <= 'F')) return (ch-'A'+10);
- return (-1);
-}
-
-/* scan for the sequence $<data>#<checksum> */
-static void
-getpacket (char *buffer)
-{
- unsigned char checksum;
- unsigned char xmitcsum;
- int i;
- int count;
- unsigned char ch;
-
- do
- {
- /* wait around for the start character, ignore all other characters */
-
- while ((ch = (getDebugChar () & 0x7f)) != '$');
-
- checksum = 0;
- xmitcsum = -1;
-
- count = 0;
-
- /* now, read until a # or end of buffer is found */
-
- while (count < BUFMAX)
- {
- ch = getDebugChar () & 0x7f;
- if (ch == '#')
- break;
- checksum = checksum + ch;
- buffer[count] = ch;
- count = count + 1;
- }
- buffer[count] = 0;
-
- if (ch == '#')
- {
- xmitcsum = hex (getDebugChar () & 0x7f) << 4;
- xmitcsum += hex (getDebugChar () & 0x7f);
-
- if (checksum != xmitcsum)
- putDebugChar ('-'); /* failed checksum */
- else
- {
- putDebugChar ('+'); /* successful transfer */
- /* if a sequence char is present, reply the sequence ID */
- if (buffer[2] == ':')
- {
- putDebugChar (buffer[0]);
- putDebugChar (buffer[1]);
-
- /* remove sequence chars from buffer */
-
- count = strlen (buffer);
- for (i=3; i <= count; i++)
- buffer[i-3] = buffer[i];
- }
- }
- }
- }
- while (checksum != xmitcsum);
-}
-
-/* send the packet in buffer. */
-
-static void
-putpacket (char *buffer)
-{
- unsigned char checksum;
- int count;
- unsigned char ch;
-
- /* $<packet info>#<checksum>. */
- do
- {
-/*
- * This is a non-standard hack to allow use of the serial console for
- * operation as well as debugging. Simply turn on 'remotechat' in gdb.
- *
- * This extension is not part of the Cygnus protocol, is kinda gross,
- * but gets the job done.
- */
-#ifdef GDB_REMOTE_CHAT
- putDebugChar ('|');
- putDebugChar ('|');
- putDebugChar ('|');
- putDebugChar ('|');
-#endif
- putDebugChar ('$');
- checksum = 0;
- count = 0;
-
- while ((ch=buffer[count]) != 0)
- {
- putDebugChar (ch);
- checksum += ch;
- count += 1;
- }
-
- putDebugChar ('#');
- putDebugChar (hexchars[checksum >> 4]);
- putDebugChar (hexchars[checksum & 0xf]);
- }
- while ((getDebugChar () & 0x7f) != '+');
-}
-
-static char remcomInBuffer[BUFMAX];
-static char remcomOutBuffer[BUFMAX];
-
-static int
-get_char (vm_offset_t addr)
-{
- char data;
-
- if (setjmp (db_jmpbuf))
- return -1;
-
- db_read_bytes (addr, 1, &data);
-
- return data & 0xff;
-}
-
-static int
-set_char (vm_offset_t addr, int val)
-{
- char data;
-
- if (setjmp (db_jmpbuf))
- return -1;
-
- data = val;
-
- db_write_bytes (addr, 1, &data);
- return 0;
-}
-
-/* convert the memory pointed to by mem into hex, placing result in buf */
-/* return a pointer to the last char put in buf (null) */
-
-static char *
-mem2hex (vm_offset_t mem, char *buf, int count)
-{
- int i;
- int ch;
-
- for (i=0;i<count;i++) {
- ch = get_char (mem++);
- if (ch == -1)
- return NULL;
- *buf++ = hexchars[ch >> 4];
- *buf++ = hexchars[ch % 16];
- }
- *buf = 0;
- return(buf);
-}
-
-/* convert the hex array pointed to by buf into binary to be placed in mem */
-/* return a pointer to the character AFTER the last byte written */
-static char *
-hex2mem (char *buf, vm_offset_t mem, int count)
-{
- int i;
- int ch;
- int rv;
-
- for (i=0;i<count;i++) {
- ch = hex(*buf++) << 4;
- ch = ch + hex(*buf++);
- rv = set_char (mem++, ch);
- if (rv == -1)
- return NULL;
- }
- return(buf);
-}
-
-/* this function takes the 386 exception vector and attempts to
- translate this number into a unix compatible signal value */
-static int
-computeSignal (int exceptionVector)
-{
- int sigval;
- switch (exceptionVector & ~T_USER)
- {
- case 0: sigval = 8; break; /* divide by zero */
- case 1: sigval = 5; break; /* debug exception */
- case 3: sigval = 5; break; /* breakpoint */
- case 4: sigval = 16; break; /* into instruction (overflow) */
- case 5: sigval = 16; break; /* bound instruction */
- case 6: sigval = 4; break; /* Invalid opcode */
- case 7: sigval = 8; break; /* coprocessor not available */
- case 8: sigval = 7; break; /* double fault */
- case 9: sigval = 11; break; /* coprocessor segment overrun */
- case 10: sigval = 5; break; /* Invalid TSS (also single-step) */
- case 11: sigval = 11; break; /* Segment not present */
- case 12: sigval = 11; break; /* stack exception */
- case 13: sigval = 11; break; /* general protection */
- case 14: sigval = 11; break; /* page fault */
- case 16: sigval = 7; break; /* coprocessor error */
- default:
- sigval = 7; /* "software generated"*/
- }
- return (sigval);
-}
-
-/*
- * While we find nice hex chars, build an int.
- * Return number of chars processed.
- */
-
-static int
-hexToInt(char **ptr, int *intValue)
-{
- int numChars = 0;
- int hexValue;
-
- *intValue = 0;
-
- while (**ptr)
- {
- hexValue = hex(**ptr);
- if (hexValue >=0)
- {
- *intValue = (*intValue <<4) | hexValue;
- numChars ++;
- }
- else
- break;
-
- (*ptr)++;
- }
-
- return (numChars);
-}
-
-#define NUMREGBYTES (sizeof registers)
-#define PC 8
-#define SP 4
-#define FP 5
-#define NUM_REGS 14
-
-/*
- * This function does all command procesing for interfacing to gdb.
- */
-void
-gdb_handle_exception (db_regs_t *raw_regs, int type, int code)
-{
- int sigval;
- int addr, length;
- char * ptr;
- struct i386regs {
- unsigned int eax;
- unsigned int ecx;
- unsigned int edx;
- unsigned int ebx;
- unsigned int esp;
- unsigned int ebp;
- unsigned int esi;
- unsigned int edi;
- unsigned int eip;
- unsigned int eflags;
- unsigned int cs;
- unsigned int ss;
- unsigned int ds;
- unsigned int es;
- };
- struct i386regs registers;
-
- registers.eax = raw_regs->tf_eax;
- registers.ebx = raw_regs->tf_ebx;
- registers.ecx = raw_regs->tf_ecx;
- registers.edx = raw_regs->tf_edx;
-
- registers.esp = raw_regs->tf_esp;
- registers.ebp = raw_regs->tf_ebp;
- registers.esi = raw_regs->tf_esi;
- registers.edi = raw_regs->tf_edi;
-
- registers.eip = raw_regs->tf_eip;
- registers.eflags = raw_regs->tf_eflags;
-
- registers.cs = raw_regs->tf_cs;
- registers.ss = raw_regs->tf_ss;
- registers.ds = raw_regs->tf_ds;
- registers.es = raw_regs->tf_es;
-
- /* reply to host that an exception has occurred */
- sigval = computeSignal (type);
- ptr = remcomOutBuffer;
-
- *ptr++ = 'T';
- *ptr++ = hexchars[sigval >> 4];
- *ptr++ = hexchars[sigval & 0xf];
-
- *ptr++ = hexchars[PC >> 4];
- *ptr++ = hexchars[PC & 0xf];
- *ptr++ = ':';
- ptr = mem2hex ((vm_offset_t)&registers.eip, ptr, 4);
- *ptr++ = ';';
-
- *ptr++ = hexchars[FP >> 4];
- *ptr++ = hexchars[FP & 0xf];
- *ptr++ = ':';
- ptr = mem2hex ((vm_offset_t)&registers.ebp, ptr, 4);
- *ptr++ = ';';
-
- *ptr++ = hexchars[SP >> 4];
- *ptr++ = hexchars[SP & 0xf];
- *ptr++ = ':';
- ptr = mem2hex ((vm_offset_t)&registers.esp, ptr, 4);
- *ptr++ = ';';
-
- *ptr++ = 0;
-
- putpacket (remcomOutBuffer);
-
- while (1)
- {
- remcomOutBuffer[0] = 0;
-
- getpacket (remcomInBuffer);
- switch (remcomInBuffer[0])
- {
- case '?':
- remcomOutBuffer[0] = 'S';
- remcomOutBuffer[1] = hexchars[sigval >> 4];
- remcomOutBuffer[2] = hexchars[sigval % 16];
- remcomOutBuffer[3] = 0;
- break;
-
- case 'D': /* detach; say OK and turn off gdb */
- putpacket(remcomOutBuffer);
- boothowto &= ~RB_GDB;
- return;
-
- case 'g': /* return the value of the CPU registers */
- mem2hex ((vm_offset_t)&registers, remcomOutBuffer, NUMREGBYTES);
- break;
-
- case 'G': /* set the value of the CPU registers - return OK */
- hex2mem (&remcomInBuffer[1], (vm_offset_t)&registers, NUMREGBYTES);
- strcpy (remcomOutBuffer, "OK");
- break;
-
- case 'P': /* Set the value of one register */
- {
- int regno;
-
- ptr = &remcomInBuffer[1];
-
- if (hexToInt (&ptr, &regno)
- && *ptr++ == '='
- && regno < NUM_REGS)
- {
- hex2mem (ptr, (vm_offset_t)&registers + regno * 4, 4);
- strcpy(remcomOutBuffer,"OK");
- }
- else
- strcpy (remcomOutBuffer, "P01");
- break;
- }
- case 'm': /* mAA..AA,LLLL Read LLLL bytes at address AA..AA */
- /* Try to read %x,%x. */
-
- ptr = &remcomInBuffer[1];
-
- if (hexToInt (&ptr, &addr)
- && *(ptr++) == ','
- && hexToInt (&ptr, &length))
- {
- if (mem2hex((vm_offset_t) addr, remcomOutBuffer, length) == NULL)
- strcpy (remcomOutBuffer, "E03");
- break;
- }
- else
- strcpy (remcomOutBuffer, "E01");
- break;
-
- case 'M': /* MAA..AA,LLLL: Write LLLL bytes at address AA.AA return OK */
-
- /* Try to read '%x,%x:'. */
-
- ptr = &remcomInBuffer[1];
-
- if (hexToInt(&ptr,&addr)
- && *(ptr++) == ','
- && hexToInt(&ptr, &length)
- && *(ptr++) == ':')
- {
- if (hex2mem(ptr, (vm_offset_t) addr, length) == NULL)
- strcpy (remcomOutBuffer, "E03");
- else
- strcpy (remcomOutBuffer, "OK");
- }
- else
- strcpy (remcomOutBuffer, "E02");
- break;
-
- /* cAA..AA Continue at address AA..AA(optional) */
- /* sAA..AA Step one instruction from AA..AA(optional) */
- case 'c' :
- case 's' :
- /* try to read optional parameter, pc unchanged if no parm */
-
- ptr = &remcomInBuffer[1];
- if (hexToInt(&ptr,&addr))
- registers.eip = addr;
-
-
- /* set the trace bit if we're stepping */
- if (remcomInBuffer[0] == 's')
- registers.eflags |= PSL_T;
- else
- registers.eflags &= ~PSL_T;
-
- raw_regs->tf_eax = registers.eax;
- raw_regs->tf_ebx = registers.ebx;
- raw_regs->tf_ecx = registers.ecx;
- raw_regs->tf_edx = registers.edx;
-
- raw_regs->tf_esp = registers.esp;
- raw_regs->tf_ebp = registers.ebp;
- raw_regs->tf_esi = registers.esi;
- raw_regs->tf_edi = registers.edi;
-
- raw_regs->tf_eip = registers.eip;
- raw_regs->tf_eflags = registers.eflags;
-
- raw_regs->tf_cs = registers.cs;
- raw_regs->tf_ss = registers.ss;
- raw_regs->tf_ds = registers.ds;
- raw_regs->tf_es = registers.es;
- return;
-
- } /* switch */
-
- /* reply to the request */
- putpacket (remcomOutBuffer);
- }
-}
-#endif /* NSIO > 0 */
diff --git a/sys/amd64/amd64/amd64_mem.c b/sys/amd64/amd64/amd64_mem.c
deleted file mode 100644
index 90b72b4fcecd..000000000000
--- a/sys/amd64/amd64/amd64_mem.c
+++ /dev/null
@@ -1,588 +0,0 @@
-/*-
- * Copyright (c) 1999 Michael Smith <msmith@freebsd.org>
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include "opt_smp.h"
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/malloc.h>
-#include <sys/memrange.h>
-
-#include <machine/md_var.h>
-#include <machine/specialreg.h>
-
-#ifdef SMP
-#include <machine/smp.h>
-#endif
-
-/*
- * i686 memory range operations
- *
- * This code will probably be impenetrable without reference to the
- * Intel Pentium Pro documentation.
- */
-
-static char *mem_owner_bios = "BIOS";
-
-#define MR686_FIXMTRR (1<<0)
-
-#define mrwithin(mr, a) \
- (((a) >= (mr)->mr_base) && ((a) < ((mr)->mr_base + (mr)->mr_len)))
-#define mroverlap(mra, mrb) \
- (mrwithin(mra, mrb->mr_base) || mrwithin(mrb, mra->mr_base))
-
-#define mrvalid(base, len) \
- ((!(base & ((1 << 12) - 1))) && /* base is multiple of 4k */ \
- ((len) >= (1 << 12)) && /* length is >= 4k */ \
- powerof2((len)) && /* ... and power of two */ \
- !((base) & ((len) - 1))) /* range is not discontiuous */
-
-#define mrcopyflags(curr, new) (((curr) & ~MDF_ATTRMASK) | ((new) & MDF_ATTRMASK))
-
-static void i686_mrinit(struct mem_range_softc *sc);
-static int i686_mrset(struct mem_range_softc *sc,
- struct mem_range_desc *mrd,
- int *arg);
-static void i686_mrAPinit(struct mem_range_softc *sc);
-
-static struct mem_range_ops i686_mrops = {
- i686_mrinit,
- i686_mrset,
- i686_mrAPinit
-};
-
-/* XXX for AP startup hook */
-static u_int64_t mtrrcap, mtrrdef;
-
-static struct mem_range_desc *mem_range_match(struct mem_range_softc *sc,
- struct mem_range_desc *mrd);
-static void i686_mrfetch(struct mem_range_softc *sc);
-static int i686_mtrrtype(int flags);
-static void i686_mrstore(struct mem_range_softc *sc);
-static void i686_mrstoreone(void *arg);
-static struct mem_range_desc *i686_mtrrfixsearch(struct mem_range_softc *sc,
- u_int64_t addr);
-static int i686_mrsetlow(struct mem_range_softc *sc,
- struct mem_range_desc *mrd,
- int *arg);
-static int i686_mrsetvariable(struct mem_range_softc *sc,
- struct mem_range_desc *mrd,
- int *arg);
-
-/* i686 MTRR type to memory range type conversion */
-static int i686_mtrrtomrt[] = {
- MDF_UNCACHEABLE,
- MDF_WRITECOMBINE,
- 0,
- 0,
- MDF_WRITETHROUGH,
- MDF_WRITEPROTECT,
- MDF_WRITEBACK
-};
-
-/*
- * i686 MTRR conflict matrix for overlapping ranges
- *
- * Specifically, this matrix allows writeback and uncached ranges
- * to overlap (the overlapped region is uncached). The array index
- * is the translated i686 code for the flags (because they map well).
- */
-static int i686_mtrrconflict[] = {
- MDF_WRITECOMBINE | MDF_WRITETHROUGH | MDF_WRITEPROTECT,
- MDF_ATTRMASK,
- 0,
- 0,
- MDF_ATTRMASK,
- MDF_ATTRMASK,
- MDF_WRITECOMBINE | MDF_WRITETHROUGH | MDF_WRITEPROTECT
-};
-
-/*
- * Look for an exactly-matching range.
- */
-static struct mem_range_desc *
-mem_range_match(struct mem_range_softc *sc, struct mem_range_desc *mrd)
-{
- struct mem_range_desc *cand;
- int i;
-
- for (i = 0, cand = sc->mr_desc; i < sc->mr_ndesc; i++, cand++)
- if ((cand->mr_base == mrd->mr_base) &&
- (cand->mr_len == mrd->mr_len))
- return(cand);
- return(NULL);
-}
-
-/*
- * Fetch the current mtrr settings from the current CPU (assumed to all
- * be in sync in the SMP case). Note that if we are here, we assume
- * that MTRRs are enabled, and we may or may not have fixed MTRRs.
- */
-static void
-i686_mrfetch(struct mem_range_softc *sc)
-{
- struct mem_range_desc *mrd;
- u_int64_t msrv;
- int i, j, msr;
-
- mrd = sc->mr_desc;
-
- /* Get fixed-range MTRRs */
- if (sc->mr_cap & MR686_FIXMTRR) {
- msr = MSR_MTRR64kBase;
- for (i = 0; i < (MTRR_N64K / 8); i++, msr++) {
- msrv = rdmsr(msr);
- for (j = 0; j < 8; j++, mrd++) {
- mrd->mr_flags = (mrd->mr_flags & ~MDF_ATTRMASK) |
- i686_mtrrtomrt[msrv & 0xff] |
- MDF_ACTIVE;
- if (mrd->mr_owner[0] == 0)
- strcpy(mrd->mr_owner, mem_owner_bios);
- msrv = msrv >> 8;
- }
- }
- msr = MSR_MTRR16kBase;
- for (i = 0; i < (MTRR_N16K / 8); i++, msr++) {
- msrv = rdmsr(msr);
- for (j = 0; j < 8; j++, mrd++) {
- mrd->mr_flags = (mrd->mr_flags & ~MDF_ATTRMASK) |
- i686_mtrrtomrt[msrv & 0xff] |
- MDF_ACTIVE;
- if (mrd->mr_owner[0] == 0)
- strcpy(mrd->mr_owner, mem_owner_bios);
- msrv = msrv >> 8;
- }
- }
- msr = MSR_MTRR4kBase;
- for (i = 0; i < (MTRR_N4K / 8); i++, msr++) {
- msrv = rdmsr(msr);
- for (j = 0; j < 8; j++, mrd++) {
- mrd->mr_flags = (mrd->mr_flags & ~MDF_ATTRMASK) |
- i686_mtrrtomrt[msrv & 0xff] |
- MDF_ACTIVE;
- if (mrd->mr_owner[0] == 0)
- strcpy(mrd->mr_owner, mem_owner_bios);
- msrv = msrv >> 8;
- }
- }
- }
-
- /* Get remainder which must be variable MTRRs */
- msr = MSR_MTRRVarBase;
- for (; (mrd - sc->mr_desc) < sc->mr_ndesc; msr += 2, mrd++) {
- msrv = rdmsr(msr);
- mrd->mr_flags = (mrd->mr_flags & ~MDF_ATTRMASK) |
- i686_mtrrtomrt[msrv & 0xff];
- mrd->mr_base = msrv & 0x0000000ffffff000LL;
- msrv = rdmsr(msr + 1);
- mrd->mr_flags = (msrv & 0x800) ?
- (mrd->mr_flags | MDF_ACTIVE) :
- (mrd->mr_flags & ~MDF_ACTIVE);
- /* Compute the range from the mask. Ick. */
- mrd->mr_len = (~(msrv & 0x0000000ffffff000LL) & 0x0000000fffffffffLL) + 1;
- if (!mrvalid(mrd->mr_base, mrd->mr_len))
- mrd->mr_flags |= MDF_BOGUS;
- /* If unclaimed and active, must be the BIOS */
- if ((mrd->mr_flags & MDF_ACTIVE) && (mrd->mr_owner[0] == 0))
- strcpy(mrd->mr_owner, mem_owner_bios);
- }
-}
-
-/*
- * Return the MTRR memory type matching a region's flags
- */
-static int
-i686_mtrrtype(int flags)
-{
- int i;
-
- flags &= MDF_ATTRMASK;
-
- for (i = 0; i < (sizeof(i686_mtrrtomrt) / sizeof(i686_mtrrtomrt[0])); i++) {
- if (i686_mtrrtomrt[i] == 0)
- continue;
- if (flags == i686_mtrrtomrt[i])
- return(i);
- }
- return(-1);
-}
-
-/*
- * Update running CPU(s) MTRRs to match the ranges in the descriptor
- * list.
- *
- * XXX Must be called with interrupts enabled.
- */
-static void
-i686_mrstore(struct mem_range_softc *sc)
-{
-#ifdef SMP
- /*
- * We should use all_but_self_ipi() to call other CPUs into a
- * locking gate, then call a target function to do this work.
- * The "proper" solution involves a generalised locking gate
- * implementation, not ready yet.
- */
- smp_rendezvous(NULL, i686_mrstoreone, NULL, (void *)sc);
-#else
- disable_intr(); /* disable interrupts */
- i686_mrstoreone((void *)sc);
- enable_intr();
-#endif
-}
-
-/*
- * Update the current CPU's MTRRs with those represented in the
- * descriptor list. Note that we do this wholesale rather than
- * just stuffing one entry; this is simpler (but slower, of course).
- */
-static void
-i686_mrstoreone(void *arg)
-{
- struct mem_range_softc *sc = (struct mem_range_softc *)arg;
- struct mem_range_desc *mrd;
- u_int64_t msrv;
- int i, j, msr;
- u_int cr4save;
-
- mrd = sc->mr_desc;
-
- cr4save = rcr4(); /* save cr4 */
- if (cr4save & CR4_PGE)
- load_cr4(cr4save & ~CR4_PGE);
- load_cr0((rcr0() & ~CR0_NW) | CR0_CD); /* disable caches (CD = 1, NW = 0) */
- wbinvd(); /* flush caches, TLBs */
- wrmsr(MSR_MTRRdefType, rdmsr(MSR_MTRRdefType) & ~0x800); /* disable MTRRs (E = 0) */
-
- /* Set fixed-range MTRRs */
- if (sc->mr_cap & MR686_FIXMTRR) {
- msr = MSR_MTRR64kBase;
- for (i = 0; i < (MTRR_N64K / 8); i++, msr++) {
- msrv = 0;
- for (j = 7; j >= 0; j--) {
- msrv = msrv << 8;
- msrv |= (i686_mtrrtype((mrd + j)->mr_flags) & 0xff);
- }
- wrmsr(msr, msrv);
- mrd += 8;
- }
- msr = MSR_MTRR16kBase;
- for (i = 0; i < (MTRR_N16K / 8); i++, msr++) {
- msrv = 0;
- for (j = 7; j >= 0; j--) {
- msrv = msrv << 8;
- msrv |= (i686_mtrrtype((mrd + j)->mr_flags) & 0xff);
- }
- wrmsr(msr, msrv);
- mrd += 8;
- }
- msr = MSR_MTRR4kBase;
- for (i = 0; i < (MTRR_N4K / 8); i++, msr++) {
- msrv = 0;
- for (j = 7; j >= 0; j--) {
- msrv = msrv << 8;
- msrv |= (i686_mtrrtype((mrd + j)->mr_flags) & 0xff);
- }
- wrmsr(msr, msrv);
- mrd += 8;
- }
- }
-
- /* Set remainder which must be variable MTRRs */
- msr = MSR_MTRRVarBase;
- for (; (mrd - sc->mr_desc) < sc->mr_ndesc; msr += 2, mrd++) {
- /* base/type register */
- if (mrd->mr_flags & MDF_ACTIVE) {
- msrv = mrd->mr_base & 0x0000000ffffff000LL;
- msrv |= (i686_mtrrtype(mrd->mr_flags) & 0xff);
- } else {
- msrv = 0;
- }
- wrmsr(msr, msrv);
-
- /* mask/active register */
- if (mrd->mr_flags & MDF_ACTIVE) {
- msrv = 0x800 | (~(mrd->mr_len - 1) & 0x0000000ffffff000LL);
- } else {
- msrv = 0;
- }
- wrmsr(msr + 1, msrv);
- }
- wbinvd(); /* flush caches, TLBs */
- wrmsr(MSR_MTRRdefType, rdmsr(MSR_MTRRdefType) | 0x800); /* restore MTRR state */
- load_cr0(rcr0() & ~(CR0_CD | CR0_NW)); /* enable caches CD = 0 and NW = 0 */
- load_cr4(cr4save); /* restore cr4 */
-}
-
-/*
- * Hunt for the fixed MTRR referencing (addr)
- */
-static struct mem_range_desc *
-i686_mtrrfixsearch(struct mem_range_softc *sc, u_int64_t addr)
-{
- struct mem_range_desc *mrd;
- int i;
-
- for (i = 0, mrd = sc->mr_desc; i < (MTRR_N64K + MTRR_N16K + MTRR_N4K); i++, mrd++)
- if ((addr >= mrd->mr_base) && (addr < (mrd->mr_base + mrd->mr_len)))
- return(mrd);
- return(NULL);
-}
-
-/*
- * Try to satisfy the given range request by manipulating the fixed MTRRs that
- * cover low memory.
- *
- * Note that we try to be generous here; we'll bloat the range out to the
- * next higher/lower boundary to avoid the consumer having to know too much
- * about the mechanisms here.
- *
- * XXX note that this will have to be updated when we start supporting "busy" ranges.
- */
-static int
-i686_mrsetlow(struct mem_range_softc *sc, struct mem_range_desc *mrd, int *arg)
-{
- struct mem_range_desc *first_md, *last_md, *curr_md;
-
- /* range check */
- if (((first_md = i686_mtrrfixsearch(sc, mrd->mr_base)) == NULL) ||
- ((last_md = i686_mtrrfixsearch(sc, mrd->mr_base + mrd->mr_len - 1)) == NULL))
- return(EINVAL);
-
- /* set flags, clear set-by-firmware flag */
- for (curr_md = first_md; curr_md <= last_md; curr_md++) {
- curr_md->mr_flags = mrcopyflags(curr_md->mr_flags & ~MDF_FIRMWARE, mrd->mr_flags);
- bcopy(mrd->mr_owner, curr_md->mr_owner, sizeof(mrd->mr_owner));
- }
-
- return(0);
-}
-
-
-/*
- * Modify/add a variable MTRR to satisfy the request.
- *
- * XXX needs to be updated to properly support "busy" ranges.
- */
-static int
-i686_mrsetvariable(struct mem_range_softc *sc, struct mem_range_desc *mrd, int *arg)
-{
- struct mem_range_desc *curr_md, *free_md;
- int i;
-
- /*
- * Scan the currently active variable descriptors, look for
- * one we exactly match (straight takeover) and for possible
- * accidental overlaps.
- * Keep track of the first empty variable descriptor in case we
- * can't perform a takeover.
- */
- i = (sc->mr_cap & MR686_FIXMTRR) ? MTRR_N64K + MTRR_N16K + MTRR_N4K : 0;
- curr_md = sc->mr_desc + i;
- free_md = NULL;
- for (; i < sc->mr_ndesc; i++, curr_md++) {
- if (curr_md->mr_flags & MDF_ACTIVE) {
- /* exact match? */
- if ((curr_md->mr_base == mrd->mr_base) &&
- (curr_md->mr_len == mrd->mr_len)) {
- /* whoops, owned by someone */
- if (curr_md->mr_flags & MDF_BUSY)
- return(EBUSY);
- /* Ok, just hijack this entry */
- free_md = curr_md;
- break;
- }
- /* non-exact overlap ? */
- if (mroverlap(curr_md, mrd)) {
- /* between conflicting region types? */
- if ((i686_mtrrconflict[i686_mtrrtype(curr_md->mr_flags)] & mrd->mr_flags) ||
- (i686_mtrrconflict[i686_mtrrtype(mrd->mr_flags)] & curr_md->mr_flags))
- return(EINVAL);
- }
- } else if (free_md == NULL) {
- free_md = curr_md;
- }
- }
- /* got somewhere to put it? */
- if (free_md == NULL)
- return(ENOSPC);
-
- /* Set up new descriptor */
- free_md->mr_base = mrd->mr_base;
- free_md->mr_len = mrd->mr_len;
- free_md->mr_flags = mrcopyflags(MDF_ACTIVE, mrd->mr_flags);
- bcopy(mrd->mr_owner, free_md->mr_owner, sizeof(mrd->mr_owner));
- return(0);
-}
-
-/*
- * Handle requests to set memory range attributes by manipulating MTRRs.
- *
- */
-static int
-i686_mrset(struct mem_range_softc *sc, struct mem_range_desc *mrd, int *arg)
-{
- struct mem_range_desc *targ;
- int error = 0;
-
- switch(*arg) {
- case MEMRANGE_SET_UPDATE:
- /* make sure that what's being asked for is even possible at all */
- if (!mrvalid(mrd->mr_base, mrd->mr_len) ||
- (i686_mtrrtype(mrd->mr_flags & MDF_ATTRMASK) == -1))
- return(EINVAL);
-
-#define FIXTOP ((MTRR_N64K * 0x10000) + (MTRR_N16K * 0x4000) + (MTRR_N4K * 0x1000))
-
- /* are the "low memory" conditions applicable? */
- if ((sc->mr_cap & MR686_FIXMTRR) &&
- ((mrd->mr_base + mrd->mr_len) <= FIXTOP)) {
- if ((error = i686_mrsetlow(sc, mrd, arg)) != 0)
- return(error);
- } else {
- /* it's time to play with variable MTRRs */
- if ((error = i686_mrsetvariable(sc, mrd, arg)) != 0)
- return(error);
- }
- break;
-
- case MEMRANGE_SET_REMOVE:
- if ((targ = mem_range_match(sc, mrd)) == NULL)
- return(ENOENT);
- if (targ->mr_flags & MDF_FIXACTIVE)
- return(EPERM);
- if (targ->mr_flags & MDF_BUSY)
- return(EBUSY);
- targ->mr_flags &= ~MDF_ACTIVE;
- targ->mr_owner[0] = 0;
- break;
-
- default:
- return(EOPNOTSUPP);
- }
-
- /* update the hardware */
- i686_mrstore(sc);
- i686_mrfetch(sc); /* refetch to see where we're at */
- return(0);
-}
-
-/*
- * Work out how many ranges we support, initialise storage for them,
- * fetch the initial settings.
- */
-static void
-i686_mrinit(struct mem_range_softc *sc)
-{
- struct mem_range_desc *mrd;
- int nmdesc = 0;
- int i;
-
- mtrrcap = rdmsr(MSR_MTRRcap);
- mtrrdef = rdmsr(MSR_MTRRdefType);
-
- /* For now, bail out if MTRRs are not enabled */
- if (!(mtrrdef & 0x800)) {
- if (bootverbose)
- printf("CPU supports MTRRs but not enabled\n");
- return;
- }
- nmdesc = mtrrcap & 0xff;
- printf("Pentium Pro MTRR support enabled\n");
-
- /* If fixed MTRRs supported and enabled */
- if ((mtrrcap & 0x100) && (mtrrdef & 0x400)) {
- sc->mr_cap = MR686_FIXMTRR;
- nmdesc += MTRR_N64K + MTRR_N16K + MTRR_N4K;
- }
-
- sc->mr_desc =
- (struct mem_range_desc *)malloc(nmdesc * sizeof(struct mem_range_desc),
- M_MEMDESC, M_WAITOK);
- bzero(sc->mr_desc, nmdesc * sizeof(struct mem_range_desc));
- sc->mr_ndesc = nmdesc;
-
- mrd = sc->mr_desc;
-
- /* Populate the fixed MTRR entries' base/length */
- if (sc->mr_cap & MR686_FIXMTRR) {
- for (i = 0; i < MTRR_N64K; i++, mrd++) {
- mrd->mr_base = i * 0x10000;
- mrd->mr_len = 0x10000;
- mrd->mr_flags = MDF_FIXBASE | MDF_FIXLEN | MDF_FIXACTIVE;
- }
- for (i = 0; i < MTRR_N16K; i++, mrd++) {
- mrd->mr_base = i * 0x4000 + 0x80000;
- mrd->mr_len = 0x4000;
- mrd->mr_flags = MDF_FIXBASE | MDF_FIXLEN | MDF_FIXACTIVE;
- }
- for (i = 0; i < MTRR_N4K; i++, mrd++) {
- mrd->mr_base = i * 0x1000 + 0xc0000;
- mrd->mr_len = 0x1000;
- mrd->mr_flags = MDF_FIXBASE | MDF_FIXLEN | MDF_FIXACTIVE;
- }
- }
-
- /*
- * Get current settings, anything set now is considered to have
- * been set by the firmware. (XXX has something already played here?)
- */
- i686_mrfetch(sc);
- mrd = sc->mr_desc;
- for (i = 0; i < sc->mr_ndesc; i++, mrd++) {
- if (mrd->mr_flags & MDF_ACTIVE)
- mrd->mr_flags |= MDF_FIRMWARE;
- }
-}
-
-/*
- * Initialise MTRRs on an AP after the BSP has run the init code.
- */
-static void
-i686_mrAPinit(struct mem_range_softc *sc)
-{
- i686_mrstoreone((void *)sc); /* set MTRRs to match BSP */
- wrmsr(MSR_MTRRdefType, mtrrdef); /* set MTRR behaviour to match BSP */
-}
-
-static void
-i686_mem_drvinit(void *unused)
-{
- /* Try for i686 MTRRs */
- if ((cpu_feature & CPUID_MTRR) &&
- ((cpu_id & 0xf00) == 0x600) &&
- ((strcmp(cpu_vendor, "GenuineIntel") == 0) ||
- (strcmp(cpu_vendor, "AuthenticAMD") == 0))) {
- mem_range_softc.mr_op = &i686_mrops;
- }
-}
-
-SYSINIT(i686memdev,SI_SUB_DRIVERS,SI_ORDER_FIRST,i686_mem_drvinit,NULL)
-
-
diff --git a/sys/amd64/amd64/apic_vector.S b/sys/amd64/amd64/apic_vector.S
deleted file mode 100644
index ca909d907e69..000000000000
--- a/sys/amd64/amd64/apic_vector.S
+++ /dev/null
@@ -1,1061 +0,0 @@
-/*
- * from: vector.s, 386BSD 0.1 unknown origin
- * $FreeBSD$
- */
-
-
-#include <machine/apic.h>
-#include <machine/smp.h>
-
-#include "i386/isa/intr_machdep.h"
-
-
-#ifdef FAST_SIMPLELOCK
-
-#define GET_FAST_INTR_LOCK \
- pushl $_fast_intr_lock ; /* address of lock */ \
- call _s_lock ; /* MP-safe */ \
- addl $4,%esp
-
-#define REL_FAST_INTR_LOCK \
- movl $0, _fast_intr_lock
-
-#else /* FAST_SIMPLELOCK */
-
-#define GET_FAST_INTR_LOCK \
- call _get_isrlock
-
-#define REL_FAST_INTR_LOCK \
- movl $_mp_lock, %edx ; /* GIANT_LOCK */ \
- call _MPrellock_edx
-
-#endif /* FAST_SIMPLELOCK */
-
-/* convert an absolute IRQ# into a bitmask */
-#define IRQ_BIT(irq_num) (1 << (irq_num))
-
-/* make an index into the IO APIC from the IRQ# */
-#define REDTBL_IDX(irq_num) (0x10 + ((irq_num) * 2))
-
-
-/*
- * Macros for interrupt interrupt entry, call to handler, and exit.
- */
-
-#ifdef FAST_WITHOUTCPL
-
-/*
- */
-#define FAST_INTR(irq_num, vec_name) \
- .text ; \
- SUPERALIGN_TEXT ; \
-IDTVEC(vec_name) ; \
- pushl %eax ; /* save only call-used registers */ \
- pushl %ecx ; \
- pushl %edx ; \
- pushl %ds ; \
- MAYBE_PUSHL_ES ; \
- pushl %fs ; \
- movl $KDSEL,%eax ; \
- movl %ax,%ds ; \
- MAYBE_MOVW_AX_ES ; \
- movl $KPSEL,%eax ; \
- movl %ax,%fs ; \
- FAKE_MCOUNT((5+ACTUALLY_PUSHED)*4(%esp)) ; \
- pushl _intr_unit + (irq_num) * 4 ; \
- GET_FAST_INTR_LOCK ; \
- call *_intr_handler + (irq_num) * 4 ; /* do the work ASAP */ \
- REL_FAST_INTR_LOCK ; \
- addl $4, %esp ; \
- movl $0, lapic_eoi ; \
- lock ; \
- incl _cnt+V_INTR ; /* book-keeping can wait */ \
- movl _intr_countp + (irq_num) * 4, %eax ; \
- lock ; \
- incl (%eax) ; \
- MEXITCOUNT ; \
- popl %fs ; \
- MAYBE_POPL_ES ; \
- popl %ds ; \
- popl %edx ; \
- popl %ecx ; \
- popl %eax ; \
- iret
-
-#else /* FAST_WITHOUTCPL */
-
-#define FAST_INTR(irq_num, vec_name) \
- .text ; \
- SUPERALIGN_TEXT ; \
-IDTVEC(vec_name) ; \
- pushl %eax ; /* save only call-used registers */ \
- pushl %ecx ; \
- pushl %edx ; \
- pushl %ds ; \
- MAYBE_PUSHL_ES ; \
- pushl %fs ; \
- movl $KDSEL, %eax ; \
- movl %ax, %ds ; \
- MAYBE_MOVW_AX_ES ; \
- movl $KPSEL, %eax ; \
- movl %ax, %fs ; \
- FAKE_MCOUNT((5+ACTUALLY_PUSHED)*4(%esp)) ; \
- GET_FAST_INTR_LOCK ; \
- pushl _intr_unit + (irq_num) * 4 ; \
- call *_intr_handler + (irq_num) * 4 ; /* do the work ASAP */ \
- addl $4, %esp ; \
- movl $0, lapic_eoi ; \
- lock ; \
- incl _cnt+V_INTR ; /* book-keeping can wait */ \
- movl _intr_countp + (irq_num) * 4,%eax ; \
- lock ; \
- incl (%eax) ; \
- movl _cpl, %eax ; /* unmasking pending HWIs or SWIs? */ \
- notl %eax ; \
- andl _ipending, %eax ; \
- jne 2f ; /* yes, maybe handle them */ \
-1: ; \
- MEXITCOUNT ; \
- REL_FAST_INTR_LOCK ; \
- popl %fs ; \
- MAYBE_POPL_ES ; \
- popl %ds ; \
- popl %edx ; \
- popl %ecx ; \
- popl %eax ; \
- iret ; \
-; \
- ALIGN_TEXT ; \
-2: ; \
- cmpb $3, _intr_nesting_level ; /* enough stack? */ \
- jae 1b ; /* no, return */ \
- movl _cpl, %eax ; \
- /* XXX next line is probably unnecessary now. */ \
- movl $HWI_MASK|SWI_MASK, _cpl ; /* limit nesting ... */ \
- lock ; \
- incb _intr_nesting_level ; /* ... really limit it ... */ \
- sti ; /* to do this as early as possible */ \
- popl %fs ; /* discard most of thin frame ... */ \
- MAYBE_POPL_ES ; /* discard most of thin frame ... */ \
- popl %ecx ; /* ... original %ds ... */ \
- popl %edx ; \
- xchgl %eax, 4(%esp) ; /* orig %eax; save cpl */ \
- pushal ; /* build fat frame (grrr) ... */ \
- pushl %ecx ; /* ... actually %ds ... */ \
- pushl %es ; \
- pushl %fs ;
- movl $KDSEL, %eax ; \
- movl %ax, %es ; \
- movl $KPSEL, %eax ;
- movl %ax, %fs ;
- movl (3+8+0)*4(%esp), %ecx ; /* %ecx from thin frame ... */ \
- movl %ecx, (3+6)*4(%esp) ; /* ... to fat frame ... */ \
- movl (3+8+1)*4(%esp), %eax ; /* ... cpl from thin frame */ \
- pushl %eax ; \
- subl $4, %esp ; /* junk for unit number */ \
- MEXITCOUNT ; \
- jmp _doreti
-
-#endif /** FAST_WITHOUTCPL */
-
-
-/*
- *
- */
-#define PUSH_FRAME \
- pushl $0 ; /* dummy error code */ \
- pushl $0 ; /* dummy trap type */ \
- pushal ; \
- pushl %ds ; /* save data and extra segments ... */ \
- pushl %es ; \
- pushl %fs
-
-#define POP_FRAME \
- popl %fs ; \
- popl %es ; \
- popl %ds ; \
- popal ; \
- addl $4+4,%esp
-
-#define IOAPICADDR(irq_num) CNAME(int_to_apicintpin) + 16 * (irq_num) + 8
-#define REDIRIDX(irq_num) CNAME(int_to_apicintpin) + 16 * (irq_num) + 12
-
-#define MASK_IRQ(irq_num) \
- IMASK_LOCK ; /* into critical reg */ \
- testl $IRQ_BIT(irq_num), _apic_imen ; \
- jne 7f ; /* masked, don't mask */ \
- orl $IRQ_BIT(irq_num), _apic_imen ; /* set the mask bit */ \
- movl IOAPICADDR(irq_num), %ecx ; /* ioapic addr */ \
- movl REDIRIDX(irq_num), %eax ; /* get the index */ \
- movl %eax, (%ecx) ; /* write the index */ \
- movl IOAPIC_WINDOW(%ecx), %eax ; /* current value */ \
- orl $IOART_INTMASK, %eax ; /* set the mask */ \
- movl %eax, IOAPIC_WINDOW(%ecx) ; /* new value */ \
-7: ; /* already masked */ \
- IMASK_UNLOCK
-/*
- * Test to see whether we are handling an edge or level triggered INT.
- * Level-triggered INTs must still be masked as we don't clear the source,
- * and the EOI cycle would cause redundant INTs to occur.
- */
-#define MASK_LEVEL_IRQ(irq_num) \
- testl $IRQ_BIT(irq_num), _apic_pin_trigger ; \
- jz 9f ; /* edge, don't mask */ \
- MASK_IRQ(irq_num) ; \
-9:
-
-
-#ifdef APIC_INTR_REORDER
-#define EOI_IRQ(irq_num) \
- movl _apic_isrbit_location + 8 * (irq_num), %eax ; \
- movl (%eax), %eax ; \
- testl _apic_isrbit_location + 4 + 8 * (irq_num), %eax ; \
- jz 9f ; /* not active */ \
- movl $0, lapic_eoi ; \
- APIC_ITRACE(apic_itrace_eoi, irq_num, APIC_ITRACE_EOI) ; \
-9:
-
-#else
-#define EOI_IRQ(irq_num) \
- testl $IRQ_BIT(irq_num), lapic_isr1; \
- jz 9f ; /* not active */ \
- movl $0, lapic_eoi; \
- APIC_ITRACE(apic_itrace_eoi, irq_num, APIC_ITRACE_EOI) ; \
-9:
-#endif
-
-
-/*
- * Test to see if the source is currntly masked, clear if so.
- */
-#define UNMASK_IRQ(irq_num) \
- IMASK_LOCK ; /* into critical reg */ \
- testl $IRQ_BIT(irq_num), _apic_imen ; \
- je 7f ; /* bit clear, not masked */ \
- andl $~IRQ_BIT(irq_num), _apic_imen ;/* clear mask bit */ \
- movl IOAPICADDR(irq_num),%ecx ; /* ioapic addr */ \
- movl REDIRIDX(irq_num), %eax ; /* get the index */ \
- movl %eax,(%ecx) ; /* write the index */ \
- movl IOAPIC_WINDOW(%ecx),%eax ; /* current value */ \
- andl $~IOART_INTMASK,%eax ; /* clear the mask */ \
- movl %eax,IOAPIC_WINDOW(%ecx) ; /* new value */ \
-7: ; \
- IMASK_UNLOCK
-
-#ifdef INTR_SIMPLELOCK
-#define ENLOCK
-#define DELOCK
-#define LATELOCK call _get_isrlock
-#else
-#define ENLOCK \
- ISR_TRYLOCK ; /* XXX this is going away... */ \
- testl %eax, %eax ; /* did we get it? */ \
- jz 3f
-#define DELOCK ISR_RELLOCK
-#define LATELOCK
-#endif
-
-#ifdef APIC_INTR_DIAGNOSTIC
-#ifdef APIC_INTR_DIAGNOSTIC_IRQ
-log_intr_event:
- pushf
- cli
- pushl $CNAME(apic_itrace_debuglock)
- call CNAME(s_lock_np)
- addl $4, %esp
- movl CNAME(apic_itrace_debugbuffer_idx), %ecx
- andl $32767, %ecx
- movl _cpuid, %eax
- shll $8, %eax
- orl 8(%esp), %eax
- movw %ax, CNAME(apic_itrace_debugbuffer)(,%ecx,2)
- incl %ecx
- andl $32767, %ecx
- movl %ecx, CNAME(apic_itrace_debugbuffer_idx)
- pushl $CNAME(apic_itrace_debuglock)
- call CNAME(s_unlock_np)
- addl $4, %esp
- popf
- ret
-
-
-#define APIC_ITRACE(name, irq_num, id) \
- lock ; /* MP-safe */ \
- incl CNAME(name) + (irq_num) * 4 ; \
- pushl %eax ; \
- pushl %ecx ; \
- pushl %edx ; \
- movl $(irq_num), %eax ; \
- cmpl $APIC_INTR_DIAGNOSTIC_IRQ, %eax ; \
- jne 7f ; \
- pushl $id ; \
- call log_intr_event ; \
- addl $4, %esp ; \
-7: ; \
- popl %edx ; \
- popl %ecx ; \
- popl %eax
-#else
-#define APIC_ITRACE(name, irq_num, id) \
- lock ; /* MP-safe */ \
- incl CNAME(name) + (irq_num) * 4
-#endif
-
-#define APIC_ITRACE_ENTER 1
-#define APIC_ITRACE_EOI 2
-#define APIC_ITRACE_TRYISRLOCK 3
-#define APIC_ITRACE_GOTISRLOCK 4
-#define APIC_ITRACE_ENTER2 5
-#define APIC_ITRACE_LEAVE 6
-#define APIC_ITRACE_UNMASK 7
-#define APIC_ITRACE_ACTIVE 8
-#define APIC_ITRACE_MASKED 9
-#define APIC_ITRACE_NOISRLOCK 10
-#define APIC_ITRACE_MASKED2 11
-#define APIC_ITRACE_SPLZ 12
-#define APIC_ITRACE_DORETI 13
-
-#else
-#define APIC_ITRACE(name, irq_num, id)
-#endif
-
-#ifdef CPL_AND_CML
-
-#define INTR(irq_num, vec_name, maybe_extra_ipending) \
- .text ; \
- SUPERALIGN_TEXT ; \
-/* _XintrNN: entry point used by IDT/HWIs & splz_unpend via _vec[]. */ \
-IDTVEC(vec_name) ; \
- PUSH_FRAME ; \
- movl $KDSEL, %eax ; /* reload with kernel's data segment */ \
- movl %ax, %ds ; \
- movl %ax, %es ; \
- movl $KPSEL, %eax ; \
- movl %ax, %fs ; \
-; \
- maybe_extra_ipending ; \
-; \
- APIC_ITRACE(apic_itrace_enter, irq_num, APIC_ITRACE_ENTER) ; \
- lock ; /* MP-safe */ \
- btsl $(irq_num), iactive ; /* lazy masking */ \
- jc 1f ; /* already active */ \
-; \
- MASK_LEVEL_IRQ(irq_num) ; \
- EOI_IRQ(irq_num) ; \
-0: ; \
- APIC_ITRACE(apic_itrace_tryisrlock, irq_num, APIC_ITRACE_TRYISRLOCK) ;\
- ENLOCK ; \
-; \
- APIC_ITRACE(apic_itrace_gotisrlock, irq_num, APIC_ITRACE_GOTISRLOCK) ;\
- AVCPL_LOCK ; /* MP-safe */ \
- testl $IRQ_BIT(irq_num), _cpl ; \
- jne 2f ; /* this INT masked */ \
- testl $IRQ_BIT(irq_num), _cml ; \
- jne 2f ; /* this INT masked */ \
- orl $IRQ_BIT(irq_num), _cil ; \
- AVCPL_UNLOCK ; \
-; \
- incb _intr_nesting_level ; \
-; \
- /* entry point used by doreti_unpend for HWIs. */ \
-__CONCAT(Xresume,irq_num): ; \
- FAKE_MCOUNT(13*4(%esp)) ; /* XXX avoid dbl cnt */ \
- lock ; incl _cnt+V_INTR ; /* tally interrupts */ \
- movl _intr_countp + (irq_num) * 4, %eax ; \
- lock ; incl (%eax) ; \
-; \
- AVCPL_LOCK ; /* MP-safe */ \
- movl _cml, %eax ; \
- pushl %eax ; \
- orl _intr_mask + (irq_num) * 4, %eax ; \
- movl %eax, _cml ; \
- AVCPL_UNLOCK ; \
-; \
- pushl _intr_unit + (irq_num) * 4 ; \
- incl _inside_intr ; \
- APIC_ITRACE(apic_itrace_enter2, irq_num, APIC_ITRACE_ENTER2) ; \
- sti ; \
- call *_intr_handler + (irq_num) * 4 ; \
- cli ; \
- APIC_ITRACE(apic_itrace_leave, irq_num, APIC_ITRACE_LEAVE) ; \
- decl _inside_intr ; \
-; \
- lock ; andl $~IRQ_BIT(irq_num), iactive ; \
- lock ; andl $~IRQ_BIT(irq_num), _cil ; \
- UNMASK_IRQ(irq_num) ; \
- APIC_ITRACE(apic_itrace_unmask, irq_num, APIC_ITRACE_UNMASK) ; \
- sti ; /* doreti repeats cli/sti */ \
- MEXITCOUNT ; \
- LATELOCK ; \
- jmp _doreti ; \
-; \
- ALIGN_TEXT ; \
-1: ; /* active */ \
- APIC_ITRACE(apic_itrace_active, irq_num, APIC_ITRACE_ACTIVE) ; \
- MASK_IRQ(irq_num) ; \
- EOI_IRQ(irq_num) ; \
- AVCPL_LOCK ; /* MP-safe */ \
- lock ; \
- orl $IRQ_BIT(irq_num), _ipending ; \
- AVCPL_UNLOCK ; \
- lock ; \
- btsl $(irq_num), iactive ; /* still active */ \
- jnc 0b ; /* retry */ \
- POP_FRAME ; \
- iret ; \
-; \
- ALIGN_TEXT ; \
-2: ; /* masked by cpl|cml */ \
- APIC_ITRACE(apic_itrace_masked, irq_num, APIC_ITRACE_MASKED) ; \
- lock ; \
- orl $IRQ_BIT(irq_num), _ipending ; \
- AVCPL_UNLOCK ; \
- DELOCK ; /* XXX this is going away... */ \
- POP_FRAME ; \
- iret ; \
- ALIGN_TEXT ; \
-3: ; /* other cpu has isr lock */ \
- APIC_ITRACE(apic_itrace_noisrlock, irq_num, APIC_ITRACE_NOISRLOCK) ;\
- AVCPL_LOCK ; /* MP-safe */ \
- lock ; \
- orl $IRQ_BIT(irq_num), _ipending ; \
- testl $IRQ_BIT(irq_num), _cpl ; \
- jne 4f ; /* this INT masked */ \
- testl $IRQ_BIT(irq_num), _cml ; \
- jne 4f ; /* this INT masked */ \
- orl $IRQ_BIT(irq_num), _cil ; \
- AVCPL_UNLOCK ; \
- call forward_irq ; /* forward irq to lock holder */ \
- POP_FRAME ; /* and return */ \
- iret ; \
- ALIGN_TEXT ; \
-4: ; /* blocked */ \
- APIC_ITRACE(apic_itrace_masked2, irq_num, APIC_ITRACE_MASKED2) ;\
- AVCPL_UNLOCK ; \
- POP_FRAME ; /* and return */ \
- iret
-
-#else /* CPL_AND_CML */
-
-
-#define INTR(irq_num, vec_name, maybe_extra_ipending) \
- .text ; \
- SUPERALIGN_TEXT ; \
-/* _XintrNN: entry point used by IDT/HWIs & splz_unpend via _vec[]. */ \
-IDTVEC(vec_name) ; \
- PUSH_FRAME ; \
- movl $KDSEL, %eax ; /* reload with kernel's data segment */ \
- movl %ax, %ds ; \
- movl %ax, %es ; \
- movl $KPSEL, %eax ; \
- movl %ax, %fs ; \
-; \
- maybe_extra_ipending ; \
-; \
- APIC_ITRACE(apic_itrace_enter, irq_num, APIC_ITRACE_ENTER) ; \
- lock ; /* MP-safe */ \
- btsl $(irq_num), iactive ; /* lazy masking */ \
- jc 1f ; /* already active */ \
-; \
- MASK_LEVEL_IRQ(irq_num) ; \
- EOI_IRQ(irq_num) ; \
-0: ; \
- APIC_ITRACE(apic_itrace_tryisrlock, irq_num, APIC_ITRACE_TRYISRLOCK) ;\
- ISR_TRYLOCK ; /* XXX this is going away... */ \
- testl %eax, %eax ; /* did we get it? */ \
- jz 3f ; /* no */ \
-; \
- APIC_ITRACE(apic_itrace_gotisrlock, irq_num, APIC_ITRACE_GOTISRLOCK) ;\
- AVCPL_LOCK ; /* MP-safe */ \
- testl $IRQ_BIT(irq_num), _cpl ; \
- jne 2f ; /* this INT masked */ \
- AVCPL_UNLOCK ; \
-; \
- incb _intr_nesting_level ; \
-; \
- /* entry point used by doreti_unpend for HWIs. */ \
-__CONCAT(Xresume,irq_num): ; \
- FAKE_MCOUNT(13*4(%esp)) ; /* XXX avoid dbl cnt */ \
- lock ; incl _cnt+V_INTR ; /* tally interrupts */ \
- movl _intr_countp + (irq_num) * 4, %eax ; \
- lock ; incl (%eax) ; \
-; \
- AVCPL_LOCK ; /* MP-safe */ \
- movl _cpl, %eax ; \
- pushl %eax ; \
- orl _intr_mask + (irq_num) * 4, %eax ; \
- movl %eax, _cpl ; \
- lock ; \
- andl $~IRQ_BIT(irq_num), _ipending ; \
- AVCPL_UNLOCK ; \
-; \
- pushl _intr_unit + (irq_num) * 4 ; \
- APIC_ITRACE(apic_itrace_enter2, irq_num, APIC_ITRACE_ENTER2) ; \
- sti ; \
- call *_intr_handler + (irq_num) * 4 ; \
- cli ; \
- APIC_ITRACE(apic_itrace_leave, irq_num, APIC_ITRACE_LEAVE) ; \
-; \
- lock ; andl $~IRQ_BIT(irq_num), iactive ; \
- UNMASK_IRQ(irq_num) ; \
- APIC_ITRACE(apic_itrace_unmask, irq_num, APIC_ITRACE_UNMASK) ; \
- sti ; /* doreti repeats cli/sti */ \
- MEXITCOUNT ; \
- jmp _doreti ; \
-; \
- ALIGN_TEXT ; \
-1: ; /* active */ \
- APIC_ITRACE(apic_itrace_active, irq_num, APIC_ITRACE_ACTIVE) ; \
- MASK_IRQ(irq_num) ; \
- EOI_IRQ(irq_num) ; \
- AVCPL_LOCK ; /* MP-safe */ \
- lock ; \
- orl $IRQ_BIT(irq_num), _ipending ; \
- AVCPL_UNLOCK ; \
- lock ; \
- btsl $(irq_num), iactive ; /* still active */ \
- jnc 0b ; /* retry */ \
- POP_FRAME ; \
- iret ; /* XXX: iactive bit might be 0 now */ \
- ALIGN_TEXT ; \
-2: ; /* masked by cpl, leave iactive set */ \
- APIC_ITRACE(apic_itrace_masked, irq_num, APIC_ITRACE_MASKED) ; \
- lock ; \
- orl $IRQ_BIT(irq_num), _ipending ; \
- AVCPL_UNLOCK ; \
- ISR_RELLOCK ; /* XXX this is going away... */ \
- POP_FRAME ; \
- iret ; \
- ALIGN_TEXT ; \
-3: ; /* other cpu has isr lock */ \
- APIC_ITRACE(apic_itrace_noisrlock, irq_num, APIC_ITRACE_NOISRLOCK) ;\
- AVCPL_LOCK ; /* MP-safe */ \
- lock ; \
- orl $IRQ_BIT(irq_num), _ipending ; \
- testl $IRQ_BIT(irq_num), _cpl ; \
- jne 4f ; /* this INT masked */ \
- AVCPL_UNLOCK ; \
- call forward_irq ; /* forward irq to lock holder */ \
- POP_FRAME ; /* and return */ \
- iret ; \
- ALIGN_TEXT ; \
-4: ; /* blocked */ \
- APIC_ITRACE(apic_itrace_masked2, irq_num, APIC_ITRACE_MASKED2) ;\
- AVCPL_UNLOCK ; \
- POP_FRAME ; /* and return */ \
- iret
-
-#endif /* CPL_AND_CML */
-
-
-/*
- * Handle "spurious INTerrupts".
- * Notes:
- * This is different than the "spurious INTerrupt" generated by an
- * 8259 PIC for missing INTs. See the APIC documentation for details.
- * This routine should NOT do an 'EOI' cycle.
- */
- .text
- SUPERALIGN_TEXT
- .globl _Xspuriousint
-_Xspuriousint:
-
- /* No EOI cycle used here */
-
- iret
-
-
-/*
- * Handle TLB shootdowns.
- */
- .text
- SUPERALIGN_TEXT
- .globl _Xinvltlb
-_Xinvltlb:
- pushl %eax
-
-#ifdef COUNT_XINVLTLB_HITS
- pushl %fs
- movl $KPSEL, %eax
- movl %ax, %fs
- movl _cpuid, %eax
- popl %fs
- ss
- incl _xhits(,%eax,4)
-#endif /* COUNT_XINVLTLB_HITS */
-
- movl %cr3, %eax /* invalidate the TLB */
- movl %eax, %cr3
-
- ss /* stack segment, avoid %ds load */
- movl $0, lapic_eoi /* End Of Interrupt to APIC */
-
- popl %eax
- iret
-
-
-#ifdef BETTER_CLOCK
-
-/*
- * Executed by a CPU when it receives an Xcpucheckstate IPI from another CPU,
- *
- * - Stores current cpu state in checkstate_cpustate[cpuid]
- * 0 == user, 1 == sys, 2 == intr
- * - Stores current process in checkstate_curproc[cpuid]
- *
- * - Signals its receipt by setting bit cpuid in checkstate_probed_cpus.
- *
- * stack: 0->ds, 4->fs, 8->ebx, 12->eax, 16->eip, 20->cs, 24->eflags
- */
-
- .text
- SUPERALIGN_TEXT
- .globl _Xcpucheckstate
- .globl _checkstate_cpustate
- .globl _checkstate_curproc
- .globl _checkstate_pc
-_Xcpucheckstate:
- pushl %eax
- pushl %ebx
- pushl %ds /* save current data segment */
- pushl %fs
-
- movl $KDSEL, %eax
- movl %ax, %ds /* use KERNEL data segment */
- movl $KPSEL, %eax
- movl %ax, %fs
-
- movl $0, lapic_eoi /* End Of Interrupt to APIC */
-
- movl $0, %ebx
- movl 20(%esp), %eax
- andl $3, %eax
- cmpl $3, %eax
- je 1f
- testl $PSL_VM, 24(%esp)
- jne 1f
- incl %ebx /* system or interrupt */
-#ifdef CPL_AND_CML
- cmpl $0, _inside_intr
- je 1f
- incl %ebx /* interrupt */
-#endif
-1:
- movl _cpuid, %eax
- movl %ebx, _checkstate_cpustate(,%eax,4)
- movl _curproc, %ebx
- movl %ebx, _checkstate_curproc(,%eax,4)
- movl 16(%esp), %ebx
- movl %ebx, _checkstate_pc(,%eax,4)
-
- lock /* checkstate_probed_cpus |= (1<<id) */
- btsl %eax, _checkstate_probed_cpus
-
- popl %fs
- popl %ds /* restore previous data segment */
- popl %ebx
- popl %eax
- iret
-
-#endif /* BETTER_CLOCK */
-
-/*
- * Executed by a CPU when it receives an Xcpuast IPI from another CPU,
- *
- * - Signals its receipt by clearing bit cpuid in checkstate_need_ast.
- *
- * - We need a better method of triggering asts on other cpus.
- */
-
- .text
- SUPERALIGN_TEXT
- .globl _Xcpuast
-_Xcpuast:
- PUSH_FRAME
- movl $KDSEL, %eax
- movl %ax, %ds /* use KERNEL data segment */
- movl %ax, %es
- movl $KPSEL, %eax
- movl %ax, %fs
-
- movl _cpuid, %eax
- lock /* checkstate_need_ast &= ~(1<<id) */
- btrl %eax, _checkstate_need_ast
- movl $0, lapic_eoi /* End Of Interrupt to APIC */
-
- lock
- btsl %eax, _checkstate_pending_ast
- jc 1f
-
- FAKE_MCOUNT(13*4(%esp))
-
- /*
- * Giant locks do not come cheap.
- * A lot of cycles are going to be wasted here.
- */
- call _get_isrlock
-
- AVCPL_LOCK
-#ifdef CPL_AND_CML
- movl _cml, %eax
-#else
- movl _cpl, %eax
-#endif
- pushl %eax
- movl $1, _astpending /* XXX */
- AVCPL_UNLOCK
- lock
- incb _intr_nesting_level
- sti
-
- pushl $0
-
- movl _cpuid, %eax
- lock
- btrl %eax, _checkstate_pending_ast
- lock
- btrl %eax, CNAME(resched_cpus)
- jnc 2f
- movl $1, CNAME(want_resched)
- lock
- incl CNAME(want_resched_cnt)
-2:
- lock
- incl CNAME(cpuast_cnt)
- MEXITCOUNT
- jmp _doreti
-1:
- /* We are already in the process of delivering an ast for this CPU */
- POP_FRAME
- iret
-
-
-/*
- * Executed by a CPU when it receives an XFORWARD_IRQ IPI.
- */
-
- .text
- SUPERALIGN_TEXT
- .globl _Xforward_irq
-_Xforward_irq:
- PUSH_FRAME
- movl $KDSEL, %eax
- movl %ax, %ds /* use KERNEL data segment */
- movl %ax, %es
- movl $KPSEL, %eax
- movl %ax, %fs
-
- movl $0, lapic_eoi /* End Of Interrupt to APIC */
-
- FAKE_MCOUNT(13*4(%esp))
-
- ISR_TRYLOCK
- testl %eax,%eax /* Did we get the lock ? */
- jz 1f /* No */
-
- lock
- incl CNAME(forward_irq_hitcnt)
- cmpb $4, _intr_nesting_level
- jae 2f
-
- AVCPL_LOCK
-#ifdef CPL_AND_CML
- movl _cml, %eax
-#else
- movl _cpl, %eax
-#endif
- pushl %eax
- AVCPL_UNLOCK
- lock
- incb _intr_nesting_level
- sti
-
- pushl $0
-
- MEXITCOUNT
- jmp _doreti /* Handle forwarded interrupt */
-1:
- lock
- incl CNAME(forward_irq_misscnt)
- call forward_irq /* Oops, we've lost the isr lock */
- MEXITCOUNT
- POP_FRAME
- iret
-2:
- lock
- incl CNAME(forward_irq_toodeepcnt)
-3:
- ISR_RELLOCK
- MEXITCOUNT
- POP_FRAME
- iret
-
-/*
- *
- */
-forward_irq:
- MCOUNT
- cmpl $0,_invltlb_ok
- jz 4f
-
- cmpl $0, CNAME(forward_irq_enabled)
- jz 4f
-
- movl _mp_lock,%eax
- cmpl $FREE_LOCK,%eax
- jne 1f
- movl $0, %eax /* Pick CPU #0 if noone has lock */
-1:
- shrl $24,%eax
- movl _cpu_num_to_apic_id(,%eax,4),%ecx
- shll $24,%ecx
- movl lapic_icr_hi, %eax
- andl $~APIC_ID_MASK, %eax
- orl %ecx, %eax
- movl %eax, lapic_icr_hi
-
-2:
- movl lapic_icr_lo, %eax
- andl $APIC_DELSTAT_MASK,%eax
- jnz 2b
- movl lapic_icr_lo, %eax
- andl $APIC_RESV2_MASK, %eax
- orl $(APIC_DEST_DESTFLD|APIC_DELMODE_FIXED|XFORWARD_IRQ_OFFSET), %eax
- movl %eax, lapic_icr_lo
-3:
- movl lapic_icr_lo, %eax
- andl $APIC_DELSTAT_MASK,%eax
- jnz 3b
-4:
- ret
-
-/*
- * Executed by a CPU when it receives an Xcpustop IPI from another CPU,
- *
- * - Signals its receipt.
- * - Waits for permission to restart.
- * - Signals its restart.
- */
-
- .text
- SUPERALIGN_TEXT
- .globl _Xcpustop
-_Xcpustop:
- pushl %ebp
- movl %esp, %ebp
- pushl %eax
- pushl %ecx
- pushl %edx
- pushl %ds /* save current data segment */
- pushl %fs
-
- movl $KDSEL, %eax
- movl %ax, %ds /* use KERNEL data segment */
- movl $KPSEL, %eax
- movl %ax, %fs
-
- movl $0, lapic_eoi /* End Of Interrupt to APIC */
-
- movl _cpuid, %eax
- imull $PCB_SIZE, %eax
- leal CNAME(stoppcbs)(%eax), %eax
- pushl %eax
- call CNAME(savectx) /* Save process context */
- addl $4, %esp
-
-
- movl _cpuid, %eax
-
- lock
- btsl %eax, _stopped_cpus /* stopped_cpus |= (1<<id) */
-1:
- btl %eax, _started_cpus /* while (!(started_cpus & (1<<id))) */
- jnc 1b
-
- lock
- btrl %eax, _started_cpus /* started_cpus &= ~(1<<id) */
- lock
- btrl %eax, _stopped_cpus /* stopped_cpus &= ~(1<<id) */
-
- test %eax, %eax
- jnz 2f
-
- movl CNAME(cpustop_restartfunc), %eax
- test %eax, %eax
- jz 2f
- movl $0, CNAME(cpustop_restartfunc) /* One-shot */
-
- call %eax
-2:
- popl %fs
- popl %ds /* restore previous data segment */
- popl %edx
- popl %ecx
- popl %eax
- movl %ebp, %esp
- popl %ebp
- iret
-
-
-MCOUNT_LABEL(bintr)
- FAST_INTR(0,fastintr0)
- FAST_INTR(1,fastintr1)
- FAST_INTR(2,fastintr2)
- FAST_INTR(3,fastintr3)
- FAST_INTR(4,fastintr4)
- FAST_INTR(5,fastintr5)
- FAST_INTR(6,fastintr6)
- FAST_INTR(7,fastintr7)
- FAST_INTR(8,fastintr8)
- FAST_INTR(9,fastintr9)
- FAST_INTR(10,fastintr10)
- FAST_INTR(11,fastintr11)
- FAST_INTR(12,fastintr12)
- FAST_INTR(13,fastintr13)
- FAST_INTR(14,fastintr14)
- FAST_INTR(15,fastintr15)
- FAST_INTR(16,fastintr16)
- FAST_INTR(17,fastintr17)
- FAST_INTR(18,fastintr18)
- FAST_INTR(19,fastintr19)
- FAST_INTR(20,fastintr20)
- FAST_INTR(21,fastintr21)
- FAST_INTR(22,fastintr22)
- FAST_INTR(23,fastintr23)
-#define CLKINTR_PENDING movl $1,CNAME(clkintr_pending)
- INTR(0,intr0, CLKINTR_PENDING)
- INTR(1,intr1,)
- INTR(2,intr2,)
- INTR(3,intr3,)
- INTR(4,intr4,)
- INTR(5,intr5,)
- INTR(6,intr6,)
- INTR(7,intr7,)
- INTR(8,intr8,)
- INTR(9,intr9,)
- INTR(10,intr10,)
- INTR(11,intr11,)
- INTR(12,intr12,)
- INTR(13,intr13,)
- INTR(14,intr14,)
- INTR(15,intr15,)
- INTR(16,intr16,)
- INTR(17,intr17,)
- INTR(18,intr18,)
- INTR(19,intr19,)
- INTR(20,intr20,)
- INTR(21,intr21,)
- INTR(22,intr22,)
- INTR(23,intr23,)
-MCOUNT_LABEL(eintr)
-
-/*
- * Executed by a CPU when it receives a RENDEZVOUS IPI from another CPU.
- *
- * - Calls the generic rendezvous action function.
- */
- .text
- SUPERALIGN_TEXT
- .globl _Xrendezvous
-_Xrendezvous:
- PUSH_FRAME
- movl $KDSEL, %eax
- movl %ax, %ds /* use KERNEL data segment */
- movl %ax, %es
- movl $KPSEL, %eax
- movl %ax, %fs
-
- call _smp_rendezvous_action
-
- movl $0, lapic_eoi /* End Of Interrupt to APIC */
- POP_FRAME
- iret
-
-
- .data
-/*
- * Addresses of interrupt handlers.
- * XresumeNN: Resumption addresses for HWIs.
- */
- .globl _ihandlers
-_ihandlers:
-/*
- * used by:
- * ipl.s: doreti_unpend
- */
- .long Xresume0, Xresume1, Xresume2, Xresume3
- .long Xresume4, Xresume5, Xresume6, Xresume7
- .long Xresume8, Xresume9, Xresume10, Xresume11
- .long Xresume12, Xresume13, Xresume14, Xresume15
- .long Xresume16, Xresume17, Xresume18, Xresume19
- .long Xresume20, Xresume21, Xresume22, Xresume23
-/*
- * used by:
- * ipl.s: doreti_unpend
- * apic_ipl.s: splz_unpend
- */
- .long _swi_null, swi_net, _swi_null, _swi_null
- .long _swi_vm, _swi_null, _softclock, _swi_null
-
-imasks: /* masks for interrupt handlers */
- .space NHWI*4 /* padding; HWI masks are elsewhere */
-
- .long SWI_TTY_MASK, SWI_NET_MASK, SWI_CAMNET_MASK, SWI_CAMBIO_MASK
- .long SWI_VM_MASK, 0, SWI_CLOCK_MASK, 0
-
-/* active flag for lazy masking */
-iactive:
- .long 0
-
-#ifdef COUNT_XINVLTLB_HITS
- .globl _xhits
-_xhits:
- .space (NCPU * 4), 0
-#endif /* COUNT_XINVLTLB_HITS */
-
-/* variables used by stop_cpus()/restart_cpus()/Xcpustop */
- .globl _stopped_cpus, _started_cpus
-_stopped_cpus:
- .long 0
-_started_cpus:
- .long 0
-
-#ifdef BETTER_CLOCK
- .globl _checkstate_probed_cpus
-_checkstate_probed_cpus:
- .long 0
-#endif /* BETTER_CLOCK */
- .globl _checkstate_need_ast
-_checkstate_need_ast:
- .long 0
-_checkstate_pending_ast:
- .long 0
- .globl CNAME(forward_irq_misscnt)
- .globl CNAME(forward_irq_toodeepcnt)
- .globl CNAME(forward_irq_hitcnt)
- .globl CNAME(resched_cpus)
- .globl CNAME(want_resched_cnt)
- .globl CNAME(cpuast_cnt)
- .globl CNAME(cpustop_restartfunc)
-CNAME(forward_irq_misscnt):
- .long 0
-CNAME(forward_irq_hitcnt):
- .long 0
-CNAME(forward_irq_toodeepcnt):
- .long 0
-CNAME(resched_cpus):
- .long 0
-CNAME(want_resched_cnt):
- .long 0
-CNAME(cpuast_cnt):
- .long 0
-CNAME(cpustop_restartfunc):
- .long 0
-
-
-
- .globl _apic_pin_trigger
-_apic_pin_trigger:
- .long 0
-
- .text
diff --git a/sys/amd64/amd64/atomic.c b/sys/amd64/amd64/atomic.c
deleted file mode 100644
index c19ba9e027b2..000000000000
--- a/sys/amd64/amd64/atomic.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*-
- * Copyright (c) 1999 Peter Jeremy
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-/* This file creates publically callable functions to perform various
- * simple arithmetic on memory which is atomic in the presence of
- * interrupts and multiple processors.
- */
-#include <sys/types.h>
-
-/* Firstly make atomic.h generate prototypes as it will for kernel modules */
-#define KLD_MODULE
-#include <machine/atomic.h>
-#undef _MACHINE_ATOMIC_H_ /* forget we included it */
-#undef KLD_MODULE
-#undef ATOMIC_ASM
-
-/* Make atomic.h generate public functions */
-#define static
-#undef __inline
-#define __inline
-
-#include <machine/atomic.h>
diff --git a/sys/amd64/amd64/autoconf.c b/sys/amd64/amd64/autoconf.c
deleted file mode 100644
index 46f35c4a6679..000000000000
--- a/sys/amd64/amd64/autoconf.c
+++ /dev/null
@@ -1,326 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)autoconf.c 7.1 (Berkeley) 5/9/91
- * $FreeBSD$
- */
-
-/*
- * Setup the system to run on the current machine.
- *
- * Configure() is called at boot time and initializes the vba
- * device tables and the memory controller monitoring. Available
- * devices are determined (from possibilities mentioned in ioconf.c),
- * and the drivers are initialized.
- */
-#include "opt_bootp.h"
-#include "opt_ffs.h"
-#include "opt_cd9660.h"
-#include "opt_nfs.h"
-#include "opt_nfsroot.h"
-#include "opt_bus.h"
-#include "opt_rootdevname.h"
-
-#include "isa.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/conf.h>
-#include <sys/disklabel.h>
-#include <sys/diskslice.h>
-#include <sys/reboot.h>
-#include <sys/kernel.h>
-#include <sys/malloc.h>
-#include <sys/mount.h>
-#include <sys/cons.h>
-
-#include <machine/bootinfo.h>
-#include <machine/ipl.h>
-#include <machine/md_var.h>
-#ifdef APIC_IO
-#include <machine/smp.h>
-#else
-#include <i386/isa/icu.h>
-#endif /* APIC_IO */
-
-#if NISA > 0
-#include <isa/isavar.h>
-
-device_t isa_bus_device = 0;
-#endif
-
-static void configure_first __P((void *));
-static void configure __P((void *));
-static void configure_final __P((void *));
-
-#if defined(FFS) && defined(FFS_ROOT)
-static void setroot __P((void));
-#endif
-
-SYSINIT(configure1, SI_SUB_CONFIGURE, SI_ORDER_FIRST, configure_first, NULL);
-/* SI_ORDER_SECOND is hookable */
-SYSINIT(configure2, SI_SUB_CONFIGURE, SI_ORDER_THIRD, configure, NULL);
-/* SI_ORDER_MIDDLE is hookable */
-SYSINIT(configure3, SI_SUB_CONFIGURE, SI_ORDER_ANY, configure_final, NULL);
-
-dev_t rootdev = NODEV;
-dev_t dumpdev = NODEV;
-
-device_t nexus_dev;
-
-/*
- * Determine i/o configuration for a machine.
- */
-static void
-configure_first(dummy)
- void *dummy;
-{
-}
-
-static void
-configure(dummy)
- void *dummy;
-{
-
- /*
- * Activate the ICU's. Note that we are explicitly at splhigh()
- * at present as we have no way to disable stray PCI level triggered
- * interrupts until the devices have had a driver attached. This
- * is particularly a problem when the interrupts are shared. For
- * example, if IRQ 10 is shared between a disk and network device
- * and the disk device generates an interrupt, if we "activate"
- * IRQ 10 when the network driver is set up, then we will get
- * recursive interrupt 10's as nothing will know how to turn off
- * the disk device's interrupt.
- *
- * Having the ICU's active means we can probe interrupt routing to
- * see if a device causes the corresponding pending bit to be set.
- *
- * This is all rather inconvenient.
- */
-#ifdef APIC_IO
- bsp_apic_configure();
- enable_intr();
-#else
- enable_intr();
- INTREN(IRQ_SLAVE);
-#endif /* APIC_IO */
-
- /* nexus0 is the top of the i386 device tree */
- device_add_child(root_bus, "nexus", 0);
-
- /* initialize new bus architecture */
- root_bus_configure();
-
-#if NISA > 0
- /*
- * Explicitly probe and attach ISA last. The isa bus saves
- * it's device node at attach time for us here.
- */
- if (isa_bus_device)
- isa_probe_children(isa_bus_device);
-#endif
-
- /*
- * Now we're ready to handle (pending) interrupts.
- * XXX this is slightly misplaced.
- */
- spl0();
-
- /*
- * Allow lowering of the ipl to the lowest kernel level if we
- * panic (or call tsleep() before clearing `cold'). No level is
- * completely safe (since a panic may occur in a critical region
- * at splhigh()), but we want at least bio interrupts to work.
- */
- safepri = cpl;
-}
-
-static void
-configure_final(dummy)
- void *dummy;
-{
- int i;
-
- cninit_finish();
-
- if (bootverbose) {
-
-#ifdef APIC_IO
- imen_dump();
-#endif /* APIC_IO */
-
- /*
- * Print out the BIOS's idea of the disk geometries.
- */
- printf("BIOS Geometries:\n");
- for (i = 0; i < N_BIOS_GEOM; i++) {
- unsigned long bios_geom;
- int max_cylinder, max_head, max_sector;
-
- bios_geom = bootinfo.bi_bios_geom[i];
-
- /*
- * XXX the bootstrap punts a 1200K floppy geometry
- * when the get-disk-geometry interrupt fails. Skip
- * drives that have this geometry.
- */
- if (bios_geom == 0x4f010f)
- continue;
-
- printf(" %x:%08lx ", i, bios_geom);
- max_cylinder = bios_geom >> 16;
- max_head = (bios_geom >> 8) & 0xff;
- max_sector = bios_geom & 0xff;
- printf(
- "0..%d=%d cylinders, 0..%d=%d heads, 1..%d=%d sectors\n",
- max_cylinder, max_cylinder + 1,
- max_head, max_head + 1,
- max_sector, max_sector);
- }
- printf(" %d accounted for\n", bootinfo.bi_n_bios_used);
-
- printf("Device configuration finished.\n");
- }
- cold = 0;
-}
-
-#ifdef BOOTP
-extern void bootpc_init(void);
-#endif
-/*
- * Do legacy root filesystem discovery.
- */
-void
-cpu_rootconf()
-{
-#ifdef BOOTP
- bootpc_init();
-#endif
-#if defined(NFS) && defined(NFS_ROOT)
-#if !defined(BOOTP_NFSROOT)
- if (nfs_diskless_valid)
-#endif
- rootdevnames[0] = "nfs:";
-#endif
-#if defined(FFS) && defined(FFS_ROOT)
- if (!rootdevnames[0])
- setroot();
-#endif
-}
-SYSINIT(cpu_rootconf, SI_SUB_ROOT_CONF, SI_ORDER_FIRST, cpu_rootconf, NULL)
-
-u_long bootdev = 0; /* not a dev_t - encoding is different */
-
-#if defined(FFS) && defined(FFS_ROOT)
-#define FDMAJOR 2
-#define FDUNITSHIFT 6
-
-/*
- * Attempt to find the device from which we were booted.
- * If we can do so, and not instructed not to do so,
- * set rootdevs[] and rootdevnames[] to correspond to the
- * boot device(s).
- *
- * This code survives in order to allow the system to be
- * booted from legacy environments that do not correctly
- * populate the kernel environment. There are significant
- * restrictions on the bootability of the system in this
- * situation; it can only be mounting root from a 'da'
- * 'wd' or 'fd' device, and the root filesystem must be ufs.
- */
-static void
-setroot()
-{
- int majdev, mindev, unit, slice, part;
- dev_t newrootdev, dev;
- char partname[2];
- char *sname;
-
- if ((bootdev & B_MAGICMASK) != B_DEVMAGIC) {
- printf("no B_DEVMAGIC (bootdev=%#lx)\n", bootdev);
- return;
- }
- majdev = B_TYPE(bootdev);
- dev = makebdev(majdev, 0);
- if (devsw(dev) == NULL) {
- printf("no devsw (majdev=%d bootdev=%#lx)\n", majdev, bootdev);
- return;
- }
- unit = B_UNIT(bootdev);
- slice = B_SLICE(bootdev);
- if (slice == WHOLE_DISK_SLICE)
- slice = COMPATIBILITY_SLICE;
- if (slice < 0 || slice >= MAX_SLICES) {
- printf("bad slice\n");
- return;
- }
-
- /*
- * XXX kludge for inconsistent unit numbering and lack of slice
- * support for floppies.
- */
- if (majdev == FDMAJOR) {
- slice = COMPATIBILITY_SLICE;
- part = RAW_PART;
- mindev = unit << FDUNITSHIFT;
- } else {
- part = B_PARTITION(bootdev);
- mindev = dkmakeminor(unit, slice, part);
- }
-
- newrootdev = makebdev(majdev, mindev);
- sname = dsname(newrootdev, unit, slice, part, partname);
- rootdevnames[0] = malloc(strlen(sname) + 6, M_DEVBUF, M_NOWAIT);
- sprintf(rootdevnames[0], "ufs:%s%s", sname, partname);
-
- /*
- * For properly dangerously dedicated disks (ones with a historical
- * bogus partition table), the boot blocks will give slice = 4, but
- * the kernel will only provide the compatibility slice since it
- * knows that slice 4 is not a real slice. Arrange to try mounting
- * the compatibility slice as root if mounting the slice passed by
- * the boot blocks fails. This handles the dangerously dedicated
- * case and perhaps others.
- */
- if (slice == COMPATIBILITY_SLICE)
- return;
- slice = COMPATIBILITY_SLICE;
- sname = dsname(newrootdev, unit, slice, part, partname);
- rootdevnames[1] = malloc(strlen(sname) + 6, M_DEVBUF, M_NOWAIT);
- sprintf(rootdevnames[1], "ufs:%s%s", sname, partname);
-}
-#endif
diff --git a/sys/amd64/amd64/bios.c b/sys/amd64/amd64/bios.c
deleted file mode 100644
index f70959c7339b..000000000000
--- a/sys/amd64/amd64/bios.c
+++ /dev/null
@@ -1,627 +0,0 @@
-/*-
- * Copyright (c) 1997 Michael Smith
- * Copyright (c) 1998 Jonathan Lemon
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Code for dealing with the BIOS in x86 PC systems.
- */
-
-#include "opt_pnp.h"
-
-#include "isa.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/malloc.h>
-#include <sys/bus.h>
-#include <vm/vm.h>
-#include <vm/pmap.h>
-#include <machine/md_var.h>
-#include <machine/segments.h>
-#include <machine/stdarg.h>
-#include <machine/vmparam.h>
-#include <machine/pc/bios.h>
-#include <isa/pnpreg.h>
-#include <isa/pnpvar.h>
-#if NISA > 0
-#include <isa/isavar.h>
-#endif
-
-#define BIOS_START 0xe0000
-#define BIOS_SIZE 0x20000
-
-/* exported lookup results */
-struct bios32_SDentry PCIbios = {entry : 0};
-struct PnPBIOS_table *PnPBIOStable = 0;
-
-static u_int bios32_SDCI = 0;
-
-/* start fairly early */
-static void bios32_init(void *junk);
-SYSINIT(bios32, SI_SUB_CPU, SI_ORDER_ANY, bios32_init, NULL);
-
-/*
- * bios32_init
- *
- * Locate various bios32 entities.
- */
-static void
-bios32_init(void *junk)
-{
- u_long sigaddr;
- struct bios32_SDheader *sdh;
- struct PnPBIOS_table *pt;
- u_int8_t ck, *cv;
- int i;
-
- /*
- * BIOS32 Service Directory
- */
-
- /* look for the signature */
- if ((sigaddr = bios_sigsearch(0, "_32_", 4, 16, 0)) != 0) {
-
- /* get a virtual pointer to the structure */
- sdh = (struct bios32_SDheader *)(uintptr_t)BIOS_PADDRTOVADDR(sigaddr);
- for (cv = (u_int8_t *)sdh, ck = 0, i = 0; i < (sdh->len * 16); i++) {
- ck += cv[i];
- }
- /* If checksum is OK, enable use of the entrypoint */
- if ((ck == 0) && (sdh->entry < (BIOS_START + BIOS_SIZE))) {
- bios32_SDCI = BIOS_PADDRTOVADDR(sdh->entry);
- if (bootverbose) {
- printf("bios32: Found BIOS32 Service Directory header at %p\n", sdh);
- printf("bios32: Entry = 0x%x (%x) Rev = %d Len = %d\n",
- sdh->entry, bios32_SDCI, sdh->revision, sdh->len);
- }
- /* See if there's a PCI BIOS entrypoint here */
- PCIbios.ident.id = 0x49435024; /* PCI systems should have this */
- if (!bios32_SDlookup(&PCIbios) && bootverbose)
- printf("pcibios: PCI BIOS entry at 0x%x\n", PCIbios.entry);
- } else {
- printf("bios32: Bad BIOS32 Service Directory\n");
- }
- }
-
- /*
- * PnP BIOS
- */
- if ((sigaddr = bios_sigsearch(0, "$PnP", 4, 16, 0)) != 0) {
-
- /* get a virtual pointer to the structure */
- pt = (struct PnPBIOS_table *)(uintptr_t)BIOS_PADDRTOVADDR(sigaddr);
- for (cv = (u_int8_t *)pt, ck = 0, i = 0; i < pt->len; i++) {
- ck += cv[i];
- }
- /* If checksum is OK, enable use of the entrypoint */
- if (ck == 0) {
- PnPBIOStable = pt;
- if (bootverbose) {
- printf("pnpbios: Found PnP BIOS data at %p\n", pt);
- printf("pnpbios: Entry = %x:%x Rev = %d.%d\n",
- pt->pmentrybase, pt->pmentryoffset, pt->version >> 4, pt->version & 0xf);
- if ((pt->control & 0x3) == 0x01)
- printf("pnpbios: Event flag at %x\n", pt->evflagaddr);
- if (pt->oemdevid != 0)
- printf("pnpbios: OEM ID %x\n", pt->oemdevid);
-
- }
- } else {
- printf("pnpbios: Bad PnP BIOS data checksum\n");
- }
- }
-
- if (bootverbose) {
- /* look for other know signatures */
- printf("Other BIOS signatures found:\n");
- printf("ACPI: %08x\n", bios_sigsearch(0, "RSD PTR ", 8, 16, 0));
- }
-}
-
-/*
- * bios32_SDlookup
- *
- * Query the BIOS32 Service Directory for the service named in (ent),
- * returns nonzero if the lookup fails. The caller must fill in
- * (ent->ident), the remainder are populated on a successful lookup.
- */
-int
-bios32_SDlookup(struct bios32_SDentry *ent)
-{
- struct bios_regs args;
-
- if (bios32_SDCI == 0)
- return (1);
-
- args.eax = ent->ident.id; /* set up arguments */
- args.ebx = args.ecx = args.edx = 0;
- bios32(&args, bios32_SDCI, GSEL(GCODE_SEL, SEL_KPL));
- if ((args.eax & 0xff) == 0) { /* success? */
- ent->base = args.ebx;
- ent->len = args.ecx;
- ent->entry = args.edx;
- return (0); /* all OK */
- }
- return (1); /* failed */
-}
-
-
-/*
- * bios_sigsearch
- *
- * Search some or all of the BIOS region for a signature string.
- *
- * (start) Optional offset returned from this function
- * (for searching for multiple matches), or NULL
- * to start the search from the base of the BIOS.
- * Note that this will be a _physical_ address in
- * the range 0xe0000 - 0xfffff.
- * (sig) is a pointer to the byte(s) of the signature.
- * (siglen) number of bytes in the signature.
- * (paralen) signature paragraph (alignment) size.
- * (sigofs) offset of the signature within the paragraph.
- *
- * Returns the _physical_ address of the found signature, 0 if the
- * signature was not found.
- */
-
-u_int32_t
-bios_sigsearch(u_int32_t start, u_char *sig, int siglen, int paralen, int sigofs)
-{
- u_char *sp, *end;
-
- /* compute the starting address */
- if ((start >= BIOS_START) && (start <= (BIOS_START + BIOS_SIZE))) {
- sp = (char *)BIOS_PADDRTOVADDR(start);
- } else if (start == 0) {
- sp = (char *)BIOS_PADDRTOVADDR(BIOS_START);
- } else {
- return 0; /* bogus start address */
- }
-
- /* compute the end address */
- end = (u_char *)BIOS_PADDRTOVADDR(BIOS_START + BIOS_SIZE);
-
- /* loop searching */
- while ((sp + sigofs + siglen) < end) {
-
- /* compare here */
- if (!bcmp(sp + sigofs, sig, siglen)) {
- /* convert back to physical address */
- return((u_int32_t)BIOS_VADDRTOPADDR(sp));
- }
- sp += paralen;
- }
- return(0);
-}
-
-/*
- * do not staticize, used by bioscall.s
- */
-union {
- struct {
- u_short offset;
- u_short segment;
- } vec16;
- struct {
- u_int offset;
- u_short segment;
- } vec32;
-} bioscall_vector; /* bios jump vector */
-
-void
-set_bios_selectors(struct bios_segments *seg, int flags)
-{
- struct soft_segment_descriptor ssd = {
- 0, /* segment base address (overwritten) */
- 0, /* length (overwritten) */
- SDT_MEMERA, /* segment type (overwritten) */
- 0, /* priority level */
- 1, /* descriptor present */
- 0, 0,
- 1, /* descriptor size (overwritten) */
- 0 /* granularity == byte units */
- };
- union descriptor *p_gdt;
-
-#ifdef SMP
- p_gdt = &gdt[cpuid];
-#else
- p_gdt = gdt;
-#endif
-
- ssd.ssd_base = seg->code32.base;
- ssd.ssd_limit = seg->code32.limit;
- ssdtosd(&ssd, &p_gdt[GBIOSCODE32_SEL].sd);
-
- ssd.ssd_def32 = 0;
- if (flags & BIOSCODE_FLAG) {
- ssd.ssd_base = seg->code16.base;
- ssd.ssd_limit = seg->code16.limit;
- ssdtosd(&ssd, &p_gdt[GBIOSCODE16_SEL].sd);
- }
-
- ssd.ssd_type = SDT_MEMRWA;
- if (flags & BIOSDATA_FLAG) {
- ssd.ssd_base = seg->data.base;
- ssd.ssd_limit = seg->data.limit;
- ssdtosd(&ssd, &p_gdt[GBIOSDATA_SEL].sd);
- }
-
- if (flags & BIOSUTIL_FLAG) {
- ssd.ssd_base = seg->util.base;
- ssd.ssd_limit = seg->util.limit;
- ssdtosd(&ssd, &p_gdt[GBIOSUTIL_SEL].sd);
- }
-
- if (flags & BIOSARGS_FLAG) {
- ssd.ssd_base = seg->args.base;
- ssd.ssd_limit = seg->args.limit;
- ssdtosd(&ssd, &p_gdt[GBIOSARGS_SEL].sd);
- }
-}
-
-extern int vm86pa;
-extern void bios16_jmp(void);
-
-/*
- * this routine is really greedy with selectors, and uses 5:
- *
- * 32-bit code selector: to return to kernel
- * 16-bit code selector: for running code
- * data selector: for 16-bit data
- * util selector: extra utility selector
- * args selector: to handle pointers
- *
- * the util selector is set from the util16 entry in bios16_args, if a
- * "U" specifier is seen.
- *
- * See <machine/pc/bios.h> for description of format specifiers
- */
-int
-bios16(struct bios_args *args, char *fmt, ...)
-{
- char *p, *stack, *stack_top;
- va_list ap;
- int flags = BIOSCODE_FLAG | BIOSDATA_FLAG;
- u_int i, arg_start, arg_end;
- u_int *pte, *ptd;
-
- arg_start = 0xffffffff;
- arg_end = 0;
-
- /*
- * Some BIOS entrypoints attempt to copy the largest-case
- * argument frame (in order to generalise handling for
- * different entry types). If our argument frame is
- * smaller than this, the BIOS will reach off the top of
- * our constructed stack segment. Pad the top of the stack
- * with some garbage to avoid this.
- */
- stack = (caddr_t)PAGE_SIZE - 32;
-
- va_start(ap, fmt);
- for (p = fmt; p && *p; p++) {
- switch (*p) {
- case 'p': /* 32-bit pointer */
- i = va_arg(ap, u_int);
- arg_start = min(arg_start, i);
- arg_end = max(arg_end, i);
- flags |= BIOSARGS_FLAG;
- stack -= 4;
- break;
-
- case 'i': /* 32-bit integer */
- i = va_arg(ap, u_int);
- stack -= 4;
- break;
-
- case 'U': /* 16-bit selector */
- flags |= BIOSUTIL_FLAG;
- /* FALLTHROUGH */
- case 'D': /* 16-bit selector */
- case 'C': /* 16-bit selector */
- stack -= 2;
- break;
-
- case 's': /* 16-bit integer */
- i = va_arg(ap, u_short);
- stack -= 2;
- break;
-
- default:
- return (EINVAL);
- }
- }
-
- if (flags & BIOSARGS_FLAG) {
- if (arg_end - arg_start > ctob(16))
- return (EACCES);
- args->seg.args.base = arg_start;
- args->seg.args.limit = 0xffff;
- }
-
- args->seg.code32.base = (u_int)&bios16_jmp & PG_FRAME;
- args->seg.code32.limit = 0xffff;
-
- ptd = (u_int *)rcr3();
- if (ptd == IdlePTD) {
- /*
- * no page table, so create one and install it.
- */
- pte = (u_int *)malloc(PAGE_SIZE, M_TEMP, M_WAITOK);
- ptd = (u_int *)((u_int)ptd + KERNBASE);
- *ptd = vtophys(pte) | PG_RW | PG_V;
- } else {
- /*
- * this is a user-level page table
- */
- pte = (u_int *)&PTmap;
- }
- /*
- * install pointer to page 0. we don't need to flush the tlb,
- * since there should not be a previous mapping for page 0.
- */
- *pte = (vm86pa - PAGE_SIZE) | PG_RW | PG_V;
-
- stack_top = stack;
- va_start(ap, fmt);
- for (p = fmt; p && *p; p++) {
- switch (*p) {
- case 'p': /* 32-bit pointer */
- i = va_arg(ap, u_int);
- *(u_int *)stack = (i - arg_start) |
- (GSEL(GBIOSARGS_SEL, SEL_KPL) << 16);
- stack += 4;
- break;
-
- case 'i': /* 32-bit integer */
- i = va_arg(ap, u_int);
- *(u_int *)stack = i;
- stack += 4;
- break;
-
- case 'U': /* 16-bit selector */
- *(u_short *)stack = GSEL(GBIOSUTIL_SEL, SEL_KPL);
- stack += 2;
- break;
-
- case 'D': /* 16-bit selector */
- *(u_short *)stack = GSEL(GBIOSDATA_SEL, SEL_KPL);
- stack += 2;
- break;
-
- case 'C': /* 16-bit selector */
- *(u_short *)stack = GSEL(GBIOSCODE16_SEL, SEL_KPL);
- stack += 2;
- break;
-
- case 's': /* 16-bit integer */
- i = va_arg(ap, u_short);
- *(u_short *)stack = i;
- stack += 2;
- break;
-
- default:
- return (EINVAL);
- }
- }
-
- set_bios_selectors(&args->seg, flags);
- bioscall_vector.vec16.offset = (u_short)args->entry;
- bioscall_vector.vec16.segment = GSEL(GBIOSCODE16_SEL, SEL_KPL);
-
- i = bios16_call(&args->r, stack_top);
-
- if (pte == (u_int *)&PTmap) {
- *pte = 0; /* remove entry */
- } else {
- *ptd = 0; /* remove page table */
- free(pte, M_TEMP); /* ... and free it */
- }
-
- /*
- * XXX only needs to be invlpg(0) but that doesn't work on the 386
- */
- invltlb();
-
- return (i);
-}
-
-#ifdef PNPBIOS /* remove conditional later */
-
-/*
- * PnP BIOS interface; enumerate devices only known to the system
- * BIOS and save information about them for later use.
- */
-
-struct pnp_sysdev
-{
- u_int16_t size;
- u_int8_t handle;
- u_int32_t devid;
- u_int8_t type[3];
- u_int16_t attrib;
-#define PNPATTR_NODISABLE (1<<0) /* can't be disabled */
-#define PNPATTR_NOCONFIG (1<<1) /* can't be configured */
-#define PNPATTR_OUTPUT (1<<2) /* can be primary output */
-#define PNPATTR_INPUT (1<<3) /* can be primary input */
-#define PNPATTR_BOOTABLE (1<<4) /* can be booted from */
-#define PNPATTR_DOCK (1<<5) /* is a docking station */
-#define PNPATTR_REMOVEABLE (1<<6) /* device is removeable */
-#define PNPATTR_CONFIG_STATIC 0x00
-#define PNPATTR_CONFIG_DYNAMIC 0x07
-#define PNPATTR_CONFIG_DYNONLY 0x17
- /* device-specific data comes here */
- u_int8_t devdata[0];
-} __attribute__ ((packed));
-
-/* We have to cluster arguments within a 64k range for the bios16 call */
-struct pnp_sysdevargs
-{
- u_int16_t next;
- struct pnp_sysdev node;
-};
-
-/*
- * This function is called after the bus has assigned resource
- * locations for a logical device.
- */
-static void
-pnpbios_set_config(void *arg, struct isa_config *config, int enable)
-{
-}
-
-/*
- * Quiz the PnP BIOS, build a list of PNP IDs and resource data.
- */
-static void
-pnpbios_identify(driver_t *driver, device_t parent)
-{
- struct PnPBIOS_table *pt = PnPBIOStable;
- struct bios_args args;
- struct pnp_sysdev *pd;
- struct pnp_sysdevargs *pda;
- u_int16_t ndevs, bigdev;
- int error, currdev;
- u_int8_t *devnodebuf, tag;
- u_int32_t *devid, *compid;
- int idx, left;
- device_t dev;
-
- /* no PnP BIOS information */
- if (pt == NULL)
- return;
-
- bzero(&args, sizeof(args));
- args.seg.code16.base = BIOS_PADDRTOVADDR(pt->pmentrybase);
- args.seg.code16.limit = 0xffff; /* XXX ? */
- args.seg.data.base = BIOS_PADDRTOVADDR(pt->pmdataseg);
- args.seg.data.limit = 0xffff;
- args.entry = pt->pmentryoffset;
-
- if ((error = bios16(&args, PNP_COUNT_DEVNODES, &ndevs, &bigdev)) || (args.r.eax & 0xff))
- printf("pnpbios: error %d/%x getting device count/size limit\n", error, args.r.eax);
- ndevs &= 0xff; /* clear high byte garbage */
- if (bootverbose)
- printf("pnpbios: %d devices, largest %d bytes\n", ndevs, bigdev);
-
- devnodebuf = malloc(bigdev + (sizeof(struct pnp_sysdevargs) - sizeof(struct pnp_sysdev)),
- M_DEVBUF, M_NOWAIT);
- pda = (struct pnp_sysdevargs *)devnodebuf;
- pd = &pda->node;
-
- for (currdev = 0, left = ndevs; (currdev != 0xff) && (left > 0); left--) {
-
- bzero(pd, bigdev);
- pda->next = currdev;
- /* get current configuration */
- if ((error = bios16(&args, PNP_GET_DEVNODE, &pda->next, &pda->node, (u_int16_t)1))) {
- printf("pnpbios: error %d making BIOS16 call\n", error);
- break;
- }
- if ((error = (args.r.eax & 0xff))) {
- if (bootverbose)
- printf("pnpbios: %s 0x%x fetching node %d\n", error & 0x80 ? "error" : "warning", error, currdev);
- if (error & 0x80)
- break;
- }
- currdev = pda->next;
- if (pd->size < sizeof(struct pnp_sysdev)) {
- printf("pnpbios: bogus system node data, aborting scan\n");
- break;
- }
-
- /* Add the device and parse its resources */
- dev = BUS_ADD_CHILD(parent, ISA_ORDER_PNP, NULL, -1);
- isa_set_vendorid(dev, pd->devid);
- isa_set_logicalid(dev, pd->devid);
- ISA_SET_CONFIG_CALLBACK(parent, dev, pnpbios_set_config, 0);
- pnp_parse_resources(dev, &pd->devdata[0],
- pd->size - sizeof(struct pnp_sysdev));
- if (!device_get_desc(dev))
- device_set_desc_copy(dev, pnp_eisaformat(pd->devid));
-
- /* Find device IDs */
- devid = &pd->devid;
- compid = NULL;
-
- /* look for a compatible device ID too */
- left = pd->size - sizeof(struct pnp_sysdev);
- idx = 0;
- while (idx < left) {
- tag = pd->devdata[idx++];
- if (PNP_RES_TYPE(tag) == 0) {
- /* Small resource */
- switch (PNP_SRES_NUM(tag)) {
- case PNP_TAG_COMPAT_DEVICE:
- compid = (u_int32_t *)(pd->devdata + idx);
- if (bootverbose)
- printf("pnpbios: node %d compat ID 0x%08x\n", pd->handle, *compid);
- /* FALLTHROUGH */
- case PNP_TAG_END:
- idx = left;
- break;
- default:
- idx += PNP_SRES_LEN(tag);
- break;
- }
- } else
- /* Large resource, skip it */
- idx += *(u_int16_t *)(pd->devdata + idx) + 2;
- }
- if (bootverbose) {
- printf("pnpbios: handle %d device ID %s (%08x)",
- pd->handle, pnp_eisaformat(*devid), *devid);
- if (compid != NULL)
- printf(" compat ID %s (%08x)",
- pnp_eisaformat(*compid), *compid);
- printf("\n");
- }
- }
-}
-
-static device_method_t pnpbios_methods[] = {
- /* Device interface */
- DEVMETHOD(device_identify, pnpbios_identify),
-
- { 0, 0 }
-};
-
-static driver_t pnpbios_driver = {
- "pnpbios",
- pnpbios_methods,
- 1, /* no softc */
-};
-
-static devclass_t pnpbios_devclass;
-
-DRIVER_MODULE(pnpbios, isa, pnpbios_driver, pnpbios_devclass, 0, 0);
-
-#endif /* PNPBIOS */
diff --git a/sys/amd64/amd64/busdma_machdep.c b/sys/amd64/amd64/busdma_machdep.c
deleted file mode 100644
index 0868b7c196dd..000000000000
--- a/sys/amd64/amd64/busdma_machdep.c
+++ /dev/null
@@ -1,663 +0,0 @@
-/*
- * Copyright (c) 1997, 1998 Justin T. Gibbs.
- * 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,
- * without modification, immediately at the beginning of the file.
- * 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 BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/malloc.h>
-
-#include <vm/vm.h>
-#include <vm/vm_page.h>
-
-#include <machine/bus.h>
-#include <machine/md_var.h>
-
-#define MAX(a,b) (((a) > (b)) ? (a) : (b))
-#define MIN(a,b) (((a) < (b)) ? (a) : (b))
-#define MAX_BPAGES 128
-
-struct bus_dma_tag {
- bus_dma_tag_t parent;
- bus_size_t alignment;
- bus_size_t boundary;
- bus_addr_t lowaddr;
- bus_addr_t highaddr;
- bus_dma_filter_t *filter;
- void *filterarg;
- bus_size_t maxsize;
- u_int nsegments;
- bus_size_t maxsegsz;
- int flags;
- int ref_count;
- int map_count;
-};
-
-struct bounce_page {
- vm_offset_t vaddr; /* kva of bounce buffer */
- bus_addr_t busaddr; /* Physical address */
- vm_offset_t datavaddr; /* kva of client data */
- bus_size_t datacount; /* client data count */
- STAILQ_ENTRY(bounce_page) links;
-};
-
-int busdma_swi_pending;
-
-static STAILQ_HEAD(bp_list, bounce_page) bounce_page_list;
-static int free_bpages;
-static int reserved_bpages;
-static int active_bpages;
-static int total_bpages;
-static bus_addr_t bounce_lowaddr = BUS_SPACE_MAXADDR;
-
-struct bus_dmamap {
- struct bp_list bpages;
- int pagesneeded;
- int pagesreserved;
- bus_dma_tag_t dmat;
- void *buf; /* unmapped buffer pointer */
- bus_size_t buflen; /* unmapped buffer length */
- bus_dmamap_callback_t *callback;
- void *callback_arg;
- STAILQ_ENTRY(bus_dmamap) links;
-};
-
-static STAILQ_HEAD(, bus_dmamap) bounce_map_waitinglist;
-static STAILQ_HEAD(, bus_dmamap) bounce_map_callbacklist;
-static struct bus_dmamap nobounce_dmamap;
-
-static int alloc_bounce_pages(bus_dma_tag_t dmat, u_int numpages);
-static int reserve_bounce_pages(bus_dma_tag_t dmat, bus_dmamap_t map);
-static vm_offset_t add_bounce_page(bus_dma_tag_t dmat, bus_dmamap_t map,
- vm_offset_t vaddr, bus_size_t size);
-static void free_bounce_page(bus_dma_tag_t dmat, struct bounce_page *bpage);
-static __inline int run_filter(bus_dma_tag_t dmat, bus_addr_t paddr);
-
-static __inline int
-run_filter(bus_dma_tag_t dmat, bus_addr_t paddr)
-{
- int retval;
-
- retval = 0;
- do {
- if (paddr > dmat->lowaddr
- && paddr <= dmat->highaddr
- && (dmat->filter == NULL
- || (*dmat->filter)(dmat->filterarg, paddr) != 0))
- retval = 1;
-
- dmat = dmat->parent;
- } while (retval == 0 && dmat != NULL);
- return (retval);
-}
-
-#define BUS_DMA_MIN_ALLOC_COMP BUS_DMA_BUS4
-/*
- * Allocate a device specific dma_tag.
- */
-int
-bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment,
- bus_size_t boundary, bus_addr_t lowaddr,
- bus_addr_t highaddr, bus_dma_filter_t *filter,
- void *filterarg, bus_size_t maxsize, int nsegments,
- bus_size_t maxsegsz, int flags, bus_dma_tag_t *dmat)
-{
- bus_dma_tag_t newtag;
- int error = 0;
-
- /* Return a NULL tag on failure */
- *dmat = NULL;
-
- newtag = (bus_dma_tag_t)malloc(sizeof(*newtag), M_DEVBUF, M_NOWAIT);
- if (newtag == NULL)
- return (ENOMEM);
-
- newtag->parent = parent;
- newtag->alignment = alignment;
- newtag->boundary = boundary;
- newtag->lowaddr = trunc_page((vm_offset_t)lowaddr) + (PAGE_SIZE - 1);
- newtag->highaddr = trunc_page((vm_offset_t)highaddr) + (PAGE_SIZE - 1);
- newtag->filter = filter;
- newtag->filterarg = filterarg;
- newtag->maxsize = maxsize;
- newtag->nsegments = nsegments;
- newtag->maxsegsz = maxsegsz;
- newtag->flags = flags;
- newtag->ref_count = 1; /* Count ourself */
- newtag->map_count = 0;
-
- /* Take into account any restrictions imposed by our parent tag */
- if (parent != NULL) {
- newtag->lowaddr = MIN(parent->lowaddr, newtag->lowaddr);
- newtag->highaddr = MAX(parent->highaddr, newtag->highaddr);
- /*
- * XXX Not really correct??? Probably need to honor boundary
- * all the way up the inheritence chain.
- */
- newtag->boundary = MAX(parent->boundary, newtag->boundary);
- if (newtag->filter == NULL) {
- /*
- * Short circuit looking at our parent directly
- * since we have encapsulated all of its information
- */
- newtag->filter = parent->filter;
- newtag->filterarg = parent->filterarg;
- newtag->parent = parent->parent;
- }
- if (newtag->parent != NULL) {
- parent->ref_count++;
- }
- }
-
- if (newtag->lowaddr < ptoa(Maxmem) && (flags & BUS_DMA_ALLOCNOW) != 0) {
- /* Must bounce */
-
- if (lowaddr > bounce_lowaddr) {
- /*
- * Go through the pool and kill any pages
- * that don't reside below lowaddr.
- */
- panic("bus_dma_tag_create: page reallocation "
- "not implemented");
- }
- if (ptoa(total_bpages) < maxsize) {
- int pages;
-
- pages = atop(maxsize) - total_bpages;
-
- /* Add pages to our bounce pool */
- if (alloc_bounce_pages(newtag, pages) < pages)
- error = ENOMEM;
- }
- /* Performed initial allocation */
- newtag->flags |= BUS_DMA_MIN_ALLOC_COMP;
- }
-
- if (error != 0) {
- free(newtag, M_DEVBUF);
- } else {
- *dmat = newtag;
- }
- return (error);
-}
-
-int
-bus_dma_tag_destroy(bus_dma_tag_t dmat)
-{
- if (dmat != NULL) {
-
- if (dmat->map_count != 0)
- return (EBUSY);
-
- while (dmat != NULL) {
- bus_dma_tag_t parent;
-
- parent = dmat->parent;
- dmat->ref_count--;
- if (dmat->ref_count == 0) {
- free(dmat, M_DEVBUF);
- /*
- * Last reference count, so
- * release our reference
- * count on our parent.
- */
- dmat = parent;
- } else
- dmat = NULL;
- }
- }
- return (0);
-}
-
-/*
- * Allocate a handle for mapping from kva/uva/physical
- * address space into bus device space.
- */
-int
-bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp)
-{
- int error;
-
- error = 0;
-
- if (dmat->lowaddr < ptoa(Maxmem)) {
- /* Must bounce */
- int maxpages;
-
- *mapp = (bus_dmamap_t)malloc(sizeof(**mapp), M_DEVBUF,
- M_NOWAIT);
- if (*mapp == NULL) {
- return (ENOMEM);
- } else {
- /* Initialize the new map */
- bzero(*mapp, sizeof(**mapp));
- STAILQ_INIT(&((*mapp)->bpages));
- }
- /*
- * Attempt to add pages to our pool on a per-instance
- * basis up to a sane limit.
- */
- maxpages = MIN(MAX_BPAGES, Maxmem - atop(dmat->lowaddr));
- if ((dmat->flags & BUS_DMA_MIN_ALLOC_COMP) == 0
- || (dmat->map_count > 0
- && total_bpages < maxpages)) {
- int pages;
-
- if (dmat->lowaddr > bounce_lowaddr) {
- /*
- * Go through the pool and kill any pages
- * that don't reside below lowaddr.
- */
- panic("bus_dmamap_create: page reallocation "
- "not implemented");
- }
- pages = atop(dmat->maxsize);
- pages = MIN(maxpages - total_bpages, pages);
- error = alloc_bounce_pages(dmat, pages);
-
- if ((dmat->flags & BUS_DMA_MIN_ALLOC_COMP) == 0) {
- if (error == 0)
- dmat->flags |= BUS_DMA_MIN_ALLOC_COMP;
- } else {
- error = 0;
- }
- }
- } else {
- *mapp = NULL;
- }
- if (error == 0)
- dmat->map_count++;
- return (error);
-}
-
-/*
- * Destroy a handle for mapping from kva/uva/physical
- * address space into bus device space.
- */
-int
-bus_dmamap_destroy(bus_dma_tag_t dmat, bus_dmamap_t map)
-{
- if (map != NULL) {
- if (STAILQ_FIRST(&map->bpages) != NULL)
- return (EBUSY);
- free(map, M_DEVBUF);
- }
- dmat->map_count--;
- return (0);
-}
-
-
-/*
- * Allocate a piece of memory that can be efficiently mapped into
- * bus device space based on the constraints lited in the dma tag.
- * A dmamap to for use with dmamap_load is also allocated.
- */
-int
-bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
- bus_dmamap_t *mapp)
-{
- /* If we succeed, no mapping/bouncing will be required */
- *mapp = NULL;
-
- if ((dmat->maxsize <= PAGE_SIZE) && dmat->lowaddr >= ptoa(Maxmem)) {
- *vaddr = malloc(dmat->maxsize, M_DEVBUF,
- (flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK);
- } else {
- /*
- * XXX Use Contigmalloc until it is merged into this facility
- * and handles multi-seg allocations. Nobody is doing
- * multi-seg allocations yet though.
- */
- *vaddr = contigmalloc(dmat->maxsize, M_DEVBUF,
- (flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK,
- 0ul, dmat->lowaddr, dmat->alignment? dmat->alignment : 1ul,
- dmat->boundary);
- }
- if (*vaddr == NULL)
- return (ENOMEM);
- return (0);
-}
-
-/*
- * Free a piece of memory and it's allociated dmamap, that was allocated
- * via bus_dmamem_alloc.
- */
-void
-bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map)
-{
- /*
- * dmamem does not need to be bounced, so the map should be
- * NULL
- */
- if (map != NULL)
- panic("bus_dmamem_free: Invalid map freed\n");
- /* XXX There is no "contigfree" and "free" doesn't work */
- if ((dmat->maxsize <= PAGE_SIZE) && dmat->lowaddr >= ptoa(Maxmem))
- free(vaddr, M_DEVBUF);
-}
-
-#define BUS_DMAMAP_NSEGS ((BUS_SPACE_MAXSIZE / PAGE_SIZE) + 1)
-
-/*
- * Map the buffer buf into bus space using the dmamap map.
- */
-int
-bus_dmamap_load(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf,
- bus_size_t buflen, bus_dmamap_callback_t *callback,
- void *callback_arg, int flags)
-{
- vm_offset_t vaddr;
- vm_offset_t paddr;
-#ifdef __GNUC__
- bus_dma_segment_t dm_segments[dmat->nsegments];
-#else
- bus_dma_segment_t dm_segments[BUS_DMAMAP_NSEGS];
-#endif
- bus_dma_segment_t *sg;
- int seg;
- int error;
- vm_offset_t nextpaddr;
-
- if (map == NULL)
- map = &nobounce_dmamap;
-
- error = 0;
- /*
- * If we are being called during a callback, pagesneeded will
- * be non-zero, so we can avoid doing the work twice.
- */
- if (dmat->lowaddr < ptoa(Maxmem) && map->pagesneeded == 0) {
- vm_offset_t vendaddr;
-
- /*
- * Count the number of bounce pages
- * needed in order to complete this transfer
- */
- vaddr = trunc_page((vm_offset_t)buf);
- vendaddr = (vm_offset_t)buf + buflen;
-
- while (vaddr < vendaddr) {
- paddr = pmap_kextract(vaddr);
- if (run_filter(dmat, paddr) != 0) {
-
- map->pagesneeded++;
- }
- vaddr += PAGE_SIZE;
- }
- }
-
- /* Reserve Necessary Bounce Pages */
- if (map->pagesneeded != 0) {
- int s;
-
- s = splhigh();
- if (reserve_bounce_pages(dmat, map) != 0) {
-
- /* Queue us for resources */
- map->dmat = dmat;
- map->buf = buf;
- map->buflen = buflen;
- map->callback = callback;
- map->callback_arg = callback_arg;
-
- STAILQ_INSERT_TAIL(&bounce_map_waitinglist, map, links);
- splx(s);
-
- return (EINPROGRESS);
- }
- splx(s);
- }
-
- vaddr = (vm_offset_t)buf;
- sg = &dm_segments[0];
- seg = 1;
- sg->ds_len = 0;
-
- nextpaddr = 0;
- do {
- bus_size_t size;
-
- paddr = pmap_kextract(vaddr);
- size = PAGE_SIZE - (paddr & PAGE_MASK);
- if (size > buflen)
- size = buflen;
-
- if (map->pagesneeded != 0 && run_filter(dmat, paddr)) {
- paddr = add_bounce_page(dmat, map, vaddr, size);
- }
-
- if (sg->ds_len == 0) {
- sg->ds_addr = paddr;
- sg->ds_len = size;
- } else if (paddr == nextpaddr) {
- sg->ds_len += size;
- } else {
- /* Go to the next segment */
- sg++;
- seg++;
- if (seg > dmat->nsegments)
- break;
- sg->ds_addr = paddr;
- sg->ds_len = size;
- }
- vaddr += size;
- nextpaddr = paddr + size;
- buflen -= size;
-
- } while (buflen > 0);
-
- if (buflen != 0) {
- printf("bus_dmamap_load: Too many segs! buf_len = 0x%lx\n",
- (u_long)buflen);
- error = EFBIG;
- }
-
- (*callback)(callback_arg, dm_segments, seg, error);
-
- return (0);
-}
-
-/*
- * Release the mapping held by map.
- */
-void
-_bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map)
-{
- struct bounce_page *bpage;
-
- while ((bpage = STAILQ_FIRST(&map->bpages)) != NULL) {
- STAILQ_REMOVE_HEAD(&map->bpages, links);
- free_bounce_page(dmat, bpage);
- }
-}
-
-void
-_bus_dmamap_sync(bus_dma_tag_t dmat, bus_dmamap_t map, bus_dmasync_op_t op)
-{
- struct bounce_page *bpage;
-
- if ((bpage = STAILQ_FIRST(&map->bpages)) != NULL) {
-
- /*
- * Handle data bouncing. We might also
- * want to add support for invalidating
- * the caches on broken hardware
- */
- switch (op) {
- case BUS_DMASYNC_PREWRITE:
- while (bpage != NULL) {
- bcopy((void *)bpage->datavaddr,
- (void *)bpage->vaddr,
- bpage->datacount);
- bpage = STAILQ_NEXT(bpage, links);
- }
- break;
-
- case BUS_DMASYNC_POSTREAD:
- while (bpage != NULL) {
- bcopy((void *)bpage->vaddr,
- (void *)bpage->datavaddr,
- bpage->datacount);
- bpage = STAILQ_NEXT(bpage, links);
- }
- break;
- case BUS_DMASYNC_PREREAD:
- case BUS_DMASYNC_POSTWRITE:
- /* No-ops */
- break;
- }
- }
-}
-
-static int
-alloc_bounce_pages(bus_dma_tag_t dmat, u_int numpages)
-{
- int count;
-
- count = 0;
- if (total_bpages == 0) {
- STAILQ_INIT(&bounce_page_list);
- STAILQ_INIT(&bounce_map_waitinglist);
- STAILQ_INIT(&bounce_map_callbacklist);
- }
-
- while (numpages > 0) {
- struct bounce_page *bpage;
- int s;
-
- bpage = (struct bounce_page *)malloc(sizeof(*bpage), M_DEVBUF,
- M_NOWAIT);
-
- if (bpage == NULL)
- break;
- bzero(bpage, sizeof(*bpage));
- bpage->vaddr = (vm_offset_t)contigmalloc(PAGE_SIZE, M_DEVBUF,
- M_NOWAIT, 0ul,
- dmat->lowaddr,
- PAGE_SIZE,
- 0);
- if (bpage->vaddr == NULL) {
- free(bpage, M_DEVBUF);
- break;
- }
- bpage->busaddr = pmap_kextract(bpage->vaddr);
- s = splhigh();
- STAILQ_INSERT_TAIL(&bounce_page_list, bpage, links);
- total_bpages++;
- free_bpages++;
- splx(s);
- count++;
- numpages--;
- }
- return (count);
-}
-
-static int
-reserve_bounce_pages(bus_dma_tag_t dmat, bus_dmamap_t map)
-{
- int pages;
-
- pages = MIN(free_bpages, map->pagesneeded - map->pagesreserved);
- free_bpages -= pages;
- reserved_bpages += pages;
- map->pagesreserved += pages;
- pages = map->pagesneeded - map->pagesreserved;
-
- return (pages);
-}
-
-static vm_offset_t
-add_bounce_page(bus_dma_tag_t dmat, bus_dmamap_t map, vm_offset_t vaddr,
- bus_size_t size)
-{
- int s;
- struct bounce_page *bpage;
-
- if (map->pagesneeded == 0)
- panic("add_bounce_page: map doesn't need any pages");
- map->pagesneeded--;
-
- if (map->pagesreserved == 0)
- panic("add_bounce_page: map doesn't need any pages");
- map->pagesreserved--;
-
- s = splhigh();
- bpage = STAILQ_FIRST(&bounce_page_list);
- if (bpage == NULL)
- panic("add_bounce_page: free page list is empty");
-
- STAILQ_REMOVE_HEAD(&bounce_page_list, links);
- reserved_bpages--;
- active_bpages++;
- splx(s);
-
- bpage->datavaddr = vaddr;
- bpage->datacount = size;
- STAILQ_INSERT_TAIL(&(map->bpages), bpage, links);
- return (bpage->busaddr);
-}
-
-static void
-free_bounce_page(bus_dma_tag_t dmat, struct bounce_page *bpage)
-{
- int s;
- struct bus_dmamap *map;
-
- bpage->datavaddr = 0;
- bpage->datacount = 0;
-
- s = splhigh();
- STAILQ_INSERT_HEAD(&bounce_page_list, bpage, links);
- free_bpages++;
- active_bpages--;
- if ((map = STAILQ_FIRST(&bounce_map_waitinglist)) != NULL) {
- if (reserve_bounce_pages(map->dmat, map) == 0) {
- STAILQ_REMOVE_HEAD(&bounce_map_waitinglist, links);
- STAILQ_INSERT_TAIL(&bounce_map_callbacklist,
- map, links);
- busdma_swi_pending = 1;
- setsoftvm();
- }
- }
- splx(s);
-}
-
-void
-busdma_swi()
-{
- int s;
- struct bus_dmamap *map;
-
- s = splhigh();
- while ((map = STAILQ_FIRST(&bounce_map_callbacklist)) != NULL) {
- STAILQ_REMOVE_HEAD(&bounce_map_callbacklist, links);
- splx(s);
- bus_dmamap_load(map->dmat, map, map->buf, map->buflen,
- map->callback, map->callback_arg, /*flags*/0);
- s = splhigh();
- }
- splx(s);
-}
diff --git a/sys/amd64/amd64/cpu_switch.S b/sys/amd64/amd64/cpu_switch.S
deleted file mode 100644
index f3982ae688f0..000000000000
--- a/sys/amd64/amd64/cpu_switch.S
+++ /dev/null
@@ -1,578 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- */
-
-#include "npx.h"
-#include "opt_user_ldt.h"
-
-#include <sys/rtprio.h>
-
-#include <machine/asmacros.h>
-
-#ifdef SMP
-#include <machine/pmap.h>
-#include <machine/apic.h>
-#include <machine/smptests.h> /** GRAB_LOPRIO */
-#include <machine/ipl.h>
-#include <machine/lock.h>
-#endif /* SMP */
-
-#include "assym.s"
-
-
-/*****************************************************************************/
-/* Scheduling */
-/*****************************************************************************/
-
- .data
-
- .globl _hlt_vector
-_hlt_vector: .long _default_halt /* pointer to halt routine */
-
- .globl _panic
-
- .globl _want_resched
-_want_resched: .long 0 /* we need to re-run the scheduler */
-#if defined(SWTCH_OPTIM_STATS)
- .globl _swtch_optim_stats, _tlb_flush_count
-_swtch_optim_stats: .long 0 /* number of _swtch_optims */
-_tlb_flush_count: .long 0
-#endif
-
- .text
-
-/*
- * When no processes are on the runq, cpu_switch() branches to _idle
- * to wait for something to come ready.
- */
- ALIGN_TEXT
- .type _idle,@function
-_idle:
- xorl %ebp,%ebp
- movl %ebp,_switchtime
-
-#ifdef SMP
-
- /* when called, we have the mplock, intr disabled */
- /* use our idleproc's "context" */
- movl _IdlePTD, %ecx
- movl %cr3, %eax
- cmpl %ecx, %eax
- je 2f
-#if defined(SWTCH_OPTIM_STATS)
- decl _swtch_optim_stats
- incl _tlb_flush_count
-#endif
- movl %ecx, %cr3
-2:
- /* Keep space for nonexisting return addr, or profiling bombs */
- movl $gd_idlestack_top-4, %ecx
- addl %fs:0, %ecx
- movl %ecx, %esp
-
- /* update common_tss.tss_esp0 pointer */
- movl %ecx, _common_tss + TSS_ESP0
-
- movl _cpuid, %esi
- btrl %esi, _private_tss
- jae 1f
-
- movl $gd_common_tssd, %edi
- addl %fs:0, %edi
-
- /* move correct tss descriptor into GDT slot, then reload tr */
- movl _tss_gdt, %ebx /* entry in GDT */
- movl 0(%edi), %eax
- movl %eax, 0(%ebx)
- movl 4(%edi), %eax
- movl %eax, 4(%ebx)
- movl $GPROC0_SEL*8, %esi /* GSEL(entry, SEL_KPL) */
- ltr %si
-1:
-
- sti
-
- /*
- * XXX callers of cpu_switch() do a bogus splclock(). Locking should
- * be left to cpu_switch().
- */
- call _spl0
-
- cli
-
- /*
- * _REALLY_ free the lock, no matter how deep the prior nesting.
- * We will recover the nesting on the way out when we have a new
- * proc to load.
- *
- * XXX: we had damn well better be sure we had it before doing this!
- */
- movl $FREE_LOCK, %eax
- movl %eax, _mp_lock
-
- /* do NOT have lock, intrs disabled */
- .globl idle_loop
-idle_loop:
-
- cmpl $0,_smp_active
- jne 1f
- cmpl $0,_cpuid
- je 1f
- jmp 2f
-
-1:
- call _procrunnable
- testl %eax,%eax
- jnz 3f
-
- cmpl $0,_do_page_zero_idle
- je 2f
-
- /* XXX appears to cause panics */
- /*
- * Inside zero_idle we enable interrupts and grab the mplock
- * as needed. It needs to be careful about entry/exit mutexes.
- */
- call _vm_page_zero_idle /* internal locking */
- testl %eax, %eax
- jnz idle_loop
-2:
-
- /* enable intrs for a halt */
- movl $0, lapic_tpr /* 1st candidate for an INT */
- call *_hlt_vector /* wait for interrupt */
- cli
- jmp idle_loop
-
-3:
- movl $LOPRIO_LEVEL, lapic_tpr /* arbitrate for INTs */
- call _get_mplock
- call _procrunnable
- testl %eax,%eax
- CROSSJUMP(jnz, sw1a, jz)
- call _rel_mplock
- jmp idle_loop
-
-#else /* !SMP */
-
- movl $HIDENAME(tmpstk),%esp
-#if defined(OVERLY_CONSERVATIVE_PTD_MGMT)
-#if defined(SWTCH_OPTIM_STATS)
- incl _swtch_optim_stats
-#endif
- movl _IdlePTD, %ecx
- movl %cr3, %eax
- cmpl %ecx, %eax
- je 2f
-#if defined(SWTCH_OPTIM_STATS)
- decl _swtch_optim_stats
- incl _tlb_flush_count
-#endif
- movl %ecx, %cr3
-2:
-#endif
-
- /* update common_tss.tss_esp0 pointer */
- movl %esp, _common_tss + TSS_ESP0
-
- movl $0, %esi
- btrl %esi, _private_tss
- jae 1f
-
- movl $_common_tssd, %edi
-
- /* move correct tss descriptor into GDT slot, then reload tr */
- movl _tss_gdt, %ebx /* entry in GDT */
- movl 0(%edi), %eax
- movl %eax, 0(%ebx)
- movl 4(%edi), %eax
- movl %eax, 4(%ebx)
- movl $GPROC0_SEL*8, %esi /* GSEL(entry, SEL_KPL) */
- ltr %si
-1:
-
- sti
-
- /*
- * XXX callers of cpu_switch() do a bogus splclock(). Locking should
- * be left to cpu_switch().
- */
- call _spl0
-
- ALIGN_TEXT
-idle_loop:
- cli
- call _procrunnable
- testl %eax,%eax
- CROSSJUMP(jnz, sw1a, jz)
- call _vm_page_zero_idle
- testl %eax, %eax
- jnz idle_loop
- call *_hlt_vector /* wait for interrupt */
- jmp idle_loop
-
-#endif /* SMP */
-
-CROSSJUMPTARGET(_idle)
-
-ENTRY(default_halt)
- sti
-#ifndef SMP
- hlt /* XXX: until a wakeup IPI */
-#endif
- ret
-
-/*
- * cpu_switch()
- */
-ENTRY(cpu_switch)
-
- /* switch to new process. first, save context as needed */
- movl _curproc,%ecx
-
- /* if no process to save, don't bother */
- testl %ecx,%ecx
- je sw1
-
-#ifdef SMP
- movb P_ONCPU(%ecx), %al /* save "last" cpu */
- movb %al, P_LASTCPU(%ecx)
- movb $0xff, P_ONCPU(%ecx) /* "leave" the cpu */
-#endif /* SMP */
- movl P_VMSPACE(%ecx), %edx
-#ifdef SMP
- movl _cpuid, %eax
-#else
- xorl %eax, %eax
-#endif /* SMP */
- btrl %eax, VM_PMAP+PM_ACTIVE(%edx)
-
- movl P_ADDR(%ecx),%edx
-
- movl (%esp),%eax /* Hardware registers */
- movl %eax,PCB_EIP(%edx)
- movl %ebx,PCB_EBX(%edx)
- movl %esp,PCB_ESP(%edx)
- movl %ebp,PCB_EBP(%edx)
- movl %esi,PCB_ESI(%edx)
- movl %edi,PCB_EDI(%edx)
- movl %gs,PCB_GS(%edx)
-
- /* test if debug regisers should be saved */
- movb PCB_FLAGS(%edx),%al
- andb $PCB_DBREGS,%al
- jz 1f /* no, skip over */
- movl %dr7,%eax /* yes, do the save */
- movl %eax,PCB_DR7(%edx)
- andl $0x0000ff00, %eax /* disable all watchpoints */
- movl %eax,%dr7
- movl %dr6,%eax
- movl %eax,PCB_DR6(%edx)
- movl %dr3,%eax
- movl %eax,PCB_DR3(%edx)
- movl %dr2,%eax
- movl %eax,PCB_DR2(%edx)
- movl %dr1,%eax
- movl %eax,PCB_DR1(%edx)
- movl %dr0,%eax
- movl %eax,PCB_DR0(%edx)
-1:
-
-#ifdef SMP
- movl _mp_lock, %eax
- /* XXX FIXME: we should be saving the local APIC TPR */
-#ifdef DIAGNOSTIC
- cmpl $FREE_LOCK, %eax /* is it free? */
- je badsw4 /* yes, bad medicine! */
-#endif /* DIAGNOSTIC */
- andl $COUNT_FIELD, %eax /* clear CPU portion */
- movl %eax, PCB_MPNEST(%edx) /* store it */
-#endif /* SMP */
-
-#if NNPX > 0
- /* have we used fp, and need a save? */
- cmpl %ecx,_npxproc
- jne 1f
- addl $PCB_SAVEFPU,%edx /* h/w bugs make saving complicated */
- pushl %edx
- call _npxsave /* do it in a big C function */
- popl %eax
-1:
-#endif /* NNPX > 0 */
-
- movl $0,_curproc /* out of process */
-
- /* save is done, now choose a new process or idle */
-sw1:
- cli
-
-#ifdef SMP
- /* Stop scheduling if smp_active goes zero and we are not BSP */
- cmpl $0,_smp_active
- jne 1f
- cmpl $0,_cpuid
- CROSSJUMP(je, _idle, jne) /* wind down */
-1:
-#endif
-
-sw1a:
- call _chooseproc /* trash ecx, edx, ret eax*/
- testl %eax,%eax
- CROSSJUMP(je, _idle, jne) /* if no proc, idle */
- movl %eax,%ecx
-
- movl $0,%eax
- movl %eax,_want_resched
-
-#ifdef DIAGNOSTIC
- cmpl %eax,P_WCHAN(%ecx)
- jne badsw1
- cmpb $SRUN,P_STAT(%ecx)
- jne badsw2
-#endif
-
- movl P_ADDR(%ecx),%edx
-
-#if defined(SWTCH_OPTIM_STATS)
- incl _swtch_optim_stats
-#endif
- /* switch address space */
- movl %cr3,%ebx
- cmpl PCB_CR3(%edx),%ebx
- je 4f
-#if defined(SWTCH_OPTIM_STATS)
- decl _swtch_optim_stats
- incl _tlb_flush_count
-#endif
- movl PCB_CR3(%edx),%ebx
- movl %ebx,%cr3
-4:
-
-#ifdef SMP
- movl _cpuid, %esi
-#else
- xorl %esi, %esi
-#endif
- cmpl $0, PCB_EXT(%edx) /* has pcb extension? */
- je 1f
- btsl %esi, _private_tss /* mark use of private tss */
- movl PCB_EXT(%edx), %edi /* new tss descriptor */
- jmp 2f
-1:
-
- /* update common_tss.tss_esp0 pointer */
- movl %edx, %ebx /* pcb */
- addl $(UPAGES * PAGE_SIZE - 16), %ebx
- movl %ebx, _common_tss + TSS_ESP0
-
- btrl %esi, _private_tss
- jae 3f
-#ifdef SMP
- movl $gd_common_tssd, %edi
- addl %fs:0, %edi
-#else
- movl $_common_tssd, %edi
-#endif
-2:
- /* move correct tss descriptor into GDT slot, then reload tr */
- movl _tss_gdt, %ebx /* entry in GDT */
- movl 0(%edi), %eax
- movl %eax, 0(%ebx)
- movl 4(%edi), %eax
- movl %eax, 4(%ebx)
- movl $GPROC0_SEL*8, %esi /* GSEL(entry, SEL_KPL) */
- ltr %si
-3:
- movl P_VMSPACE(%ecx), %ebx
-#ifdef SMP
- movl _cpuid, %eax
-#else
- xorl %eax, %eax
-#endif
- btsl %eax, VM_PMAP+PM_ACTIVE(%ebx)
-
- /* restore context */
- movl PCB_EBX(%edx),%ebx
- movl PCB_ESP(%edx),%esp
- movl PCB_EBP(%edx),%ebp
- movl PCB_ESI(%edx),%esi
- movl PCB_EDI(%edx),%edi
- movl PCB_EIP(%edx),%eax
- movl %eax,(%esp)
-
-#ifdef SMP
-#ifdef GRAB_LOPRIO /* hold LOPRIO for INTs */
-#ifdef CHEAP_TPR
- movl $0, lapic_tpr
-#else
- andl $~APIC_TPR_PRIO, lapic_tpr
-#endif /** CHEAP_TPR */
-#endif /** GRAB_LOPRIO */
- movl _cpuid,%eax
- movb %al, P_ONCPU(%ecx)
-#endif /* SMP */
- movl %edx, _curpcb
- movl %ecx, _curproc /* into next process */
-
-#ifdef SMP
- movl _cpu_lockid, %eax
- orl PCB_MPNEST(%edx), %eax /* add next count from PROC */
- movl %eax, _mp_lock /* load the mp_lock */
- /* XXX FIXME: we should be restoring the local APIC TPR */
-#endif /* SMP */
-
-#ifdef USER_LDT
- cmpl $0, PCB_USERLDT(%edx)
- jnz 1f
- movl __default_ldt,%eax
- cmpl _currentldt,%eax
- je 2f
- lldt __default_ldt
- movl %eax,_currentldt
- jmp 2f
-1: pushl %edx
- call _set_user_ldt
- popl %edx
-2:
-#endif
-
- /* This must be done after loading the user LDT. */
- .globl cpu_switch_load_gs
-cpu_switch_load_gs:
- movl PCB_GS(%edx),%gs
-
- /* test if debug regisers should be restored */
- movb PCB_FLAGS(%edx),%al
- andb $PCB_DBREGS,%al
- jz 1f /* no, skip over */
- movl PCB_DR6(%edx),%eax /* yes, do the restore */
- movl %eax,%dr6
- movl PCB_DR3(%edx),%eax
- movl %eax,%dr3
- movl PCB_DR2(%edx),%eax
- movl %eax,%dr2
- movl PCB_DR1(%edx),%eax
- movl %eax,%dr1
- movl PCB_DR0(%edx),%eax
- movl %eax,%dr0
- movl PCB_DR7(%edx),%eax
- movl %eax,%dr7
-1:
-
- sti
- ret
-
-CROSSJUMPTARGET(sw1a)
-
-#ifdef DIAGNOSTIC
-badsw1:
- pushl $sw0_1
- call _panic
-
-sw0_1: .asciz "cpu_switch: has wchan"
-
-badsw2:
- pushl $sw0_2
- call _panic
-
-sw0_2: .asciz "cpu_switch: not SRUN"
-#endif
-
-#if defined(SMP) && defined(DIAGNOSTIC)
-badsw4:
- pushl $sw0_4
- call _panic
-
-sw0_4: .asciz "cpu_switch: do not have lock"
-#endif /* SMP && DIAGNOSTIC */
-
-/*
- * savectx(pcb)
- * Update pcb, saving current processor state.
- */
-ENTRY(savectx)
- /* fetch PCB */
- movl 4(%esp),%ecx
-
- /* caller's return address - child won't execute this routine */
- movl (%esp),%eax
- movl %eax,PCB_EIP(%ecx)
-
- movl %ebx,PCB_EBX(%ecx)
- movl %esp,PCB_ESP(%ecx)
- movl %ebp,PCB_EBP(%ecx)
- movl %esi,PCB_ESI(%ecx)
- movl %edi,PCB_EDI(%ecx)
- movl %gs,PCB_GS(%ecx)
-
-#if NNPX > 0
- /*
- * If npxproc == NULL, then the npx h/w state is irrelevant and the
- * state had better already be in the pcb. This is true for forks
- * but not for dumps (the old book-keeping with FP flags in the pcb
- * always lost for dumps because the dump pcb has 0 flags).
- *
- * If npxproc != NULL, then we have to save the npx h/w state to
- * npxproc's pcb and copy it to the requested pcb, or save to the
- * requested pcb and reload. Copying is easier because we would
- * have to handle h/w bugs for reloading. We used to lose the
- * parent's npx state for forks by forgetting to reload.
- */
- movl _npxproc,%eax
- testl %eax,%eax
- je 1f
-
- pushl %ecx
- movl P_ADDR(%eax),%eax
- leal PCB_SAVEFPU(%eax),%eax
- pushl %eax
- pushl %eax
- call _npxsave
- addl $4,%esp
- popl %eax
- popl %ecx
-
- pushl $PCB_SAVEFPU_SIZE
- leal PCB_SAVEFPU(%ecx),%ecx
- pushl %ecx
- pushl %eax
- call _bcopy
- addl $12,%esp
-#endif /* NNPX > 0 */
-
-1:
- ret
diff --git a/sys/amd64/amd64/db_disasm.c b/sys/amd64/amd64/db_disasm.c
deleted file mode 100644
index 16e8106d5e73..000000000000
--- a/sys/amd64/amd64/db_disasm.c
+++ /dev/null
@@ -1,1406 +0,0 @@
-/*
- * Mach Operating System
- * Copyright (c) 1991,1990 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
- * 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Instruction disassembler.
- */
-#include <sys/param.h>
-
-#include <ddb/ddb.h>
-#include <ddb/db_access.h>
-#include <ddb/db_sym.h>
-
-/*
- * Size attributes
- */
-#define BYTE 0
-#define WORD 1
-#define LONG 2
-#define QUAD 3
-#define SNGL 4
-#define DBLR 5
-#define EXTR 6
-#define SDEP 7
-#define NONE 8
-
-/*
- * Addressing modes
- */
-#define E 1 /* general effective address */
-#define Eind 2 /* indirect address (jump, call) */
-#define Ew 3 /* address, word size */
-#define Eb 4 /* address, byte size */
-#define R 5 /* register, in 'reg' field */
-#define Rw 6 /* word register, in 'reg' field */
-#define Ri 7 /* register in instruction */
-#define S 8 /* segment reg, in 'reg' field */
-#define Si 9 /* segment reg, in instruction */
-#define A 10 /* accumulator */
-#define BX 11 /* (bx) */
-#define CL 12 /* cl, for shifts */
-#define DX 13 /* dx, for IO */
-#define SI 14 /* si */
-#define DI 15 /* di */
-#define CR 16 /* control register */
-#define DR 17 /* debug register */
-#define TR 18 /* test register */
-#define I 19 /* immediate, unsigned */
-#define Is 20 /* immediate, signed */
-#define Ib 21 /* byte immediate, unsigned */
-#define Ibs 22 /* byte immediate, signed */
-#define Iw 23 /* word immediate, unsigned */
-#define O 25 /* direct address */
-#define Db 26 /* byte displacement from EIP */
-#define Dl 27 /* long displacement from EIP */
-#define o1 28 /* constant 1 */
-#define o3 29 /* constant 3 */
-#define OS 30 /* immediate offset/segment */
-#define ST 31 /* FP stack top */
-#define STI 32 /* FP stack */
-#define X 33 /* extended FP op */
-#define XA 34 /* for 'fstcw %ax' */
-#define El 35 /* address, long size */
-#define Ril 36 /* long register in instruction */
-#define Iba 37 /* byte immediate, don't print if 0xa */
-
-struct inst {
- const char * i_name; /* name */
- short i_has_modrm; /* has regmodrm byte */
- short i_size; /* operand size */
- int i_mode; /* addressing modes */
- const void * i_extra; /* pointer to extra opcode table */
-};
-
-#define op1(x) (x)
-#define op2(x,y) ((x)|((y)<<8))
-#define op3(x,y,z) ((x)|((y)<<8)|((z)<<16))
-
-struct finst {
- const char * f_name; /* name for memory instruction */
- int f_size; /* size for memory instruction */
- int f_rrmode; /* mode for rr instruction */
- const void * f_rrname; /* name for rr instruction
- (or pointer to table) */
-};
-
-static const char * const db_Grp6[] = {
- "sldt",
- "str",
- "lldt",
- "ltr",
- "verr",
- "verw",
- "",
- ""
-};
-
-static const char * const db_Grp7[] = {
- "sgdt",
- "sidt",
- "lgdt",
- "lidt",
- "smsw",
- "",
- "lmsw",
- "invlpg"
-};
-
-static const char * const db_Grp8[] = {
- "",
- "",
- "",
- "",
- "bt",
- "bts",
- "btr",
- "btc"
-};
-
-static const char * const db_Grp9[] = {
- "",
- "cmpxchg8b",
- "",
- "",
- "",
- "",
- "",
- ""
-};
-
-static const struct inst db_inst_0f0x[] = {
-/*00*/ { "", TRUE, NONE, op1(Ew), db_Grp6 },
-/*01*/ { "", TRUE, NONE, op1(Ew), db_Grp7 },
-/*02*/ { "lar", TRUE, LONG, op2(E,R), 0 },
-/*03*/ { "lsl", TRUE, LONG, op2(E,R), 0 },
-/*04*/ { "", FALSE, NONE, 0, 0 },
-/*05*/ { "", FALSE, NONE, 0, 0 },
-/*06*/ { "clts", FALSE, NONE, 0, 0 },
-/*07*/ { "", FALSE, NONE, 0, 0 },
-
-/*08*/ { "invd", FALSE, NONE, 0, 0 },
-/*09*/ { "wbinvd",FALSE, NONE, 0, 0 },
-/*0a*/ { "", FALSE, NONE, 0, 0 },
-/*0b*/ { "", FALSE, NONE, 0, 0 },
-/*0c*/ { "", FALSE, NONE, 0, 0 },
-/*0d*/ { "", FALSE, NONE, 0, 0 },
-/*0e*/ { "", FALSE, NONE, 0, 0 },
-/*0f*/ { "", FALSE, NONE, 0, 0 },
-};
-
-static const struct inst db_inst_0f2x[] = {
-/*20*/ { "mov", TRUE, LONG, op2(CR,El), 0 },
-/*21*/ { "mov", TRUE, LONG, op2(DR,El), 0 },
-/*22*/ { "mov", TRUE, LONG, op2(El,CR), 0 },
-/*23*/ { "mov", TRUE, LONG, op2(El,DR), 0 },
-/*24*/ { "mov", TRUE, LONG, op2(TR,El), 0 },
-/*25*/ { "", FALSE, NONE, 0, 0 },
-/*26*/ { "mov", TRUE, LONG, op2(El,TR), 0 },
-/*27*/ { "", FALSE, NONE, 0, 0 },
-
-/*28*/ { "", FALSE, NONE, 0, 0 },
-/*29*/ { "", FALSE, NONE, 0, 0 },
-/*2a*/ { "", FALSE, NONE, 0, 0 },
-/*2b*/ { "", FALSE, NONE, 0, 0 },
-/*2c*/ { "", FALSE, NONE, 0, 0 },
-/*2d*/ { "", FALSE, NONE, 0, 0 },
-/*2e*/ { "", FALSE, NONE, 0, 0 },
-/*2f*/ { "", FALSE, NONE, 0, 0 },
-};
-
-static const struct inst db_inst_0f3x[] = {
-/*30*/ { "wrmsr", FALSE, NONE, 0, 0 },
-/*31*/ { "rdtsc", FALSE, NONE, 0, 0 },
-/*32*/ { "rdmsr", FALSE, NONE, 0, 0 },
-/*33*/ { "rdpmc", FALSE, NONE, 0, 0 },
-/*34*/ { "", FALSE, NONE, 0, 0 },
-/*35*/ { "", FALSE, NONE, 0, 0 },
-/*36*/ { "", FALSE, NONE, 0, 0 },
-/*37*/ { "", FALSE, NONE, 0, 0 },
-
-/*38*/ { "", FALSE, NONE, 0, 0 },
-/*39*/ { "", FALSE, NONE, 0, 0 },
-/*3a*/ { "", FALSE, NONE, 0, 0 },
-/*3b*/ { "", FALSE, NONE, 0, 0 },
-/*3c*/ { "", FALSE, NONE, 0, 0 },
-/*3d*/ { "", FALSE, NONE, 0, 0 },
-/*3e*/ { "", FALSE, NONE, 0, 0 },
-/*3f*/ { "", FALSE, NONE, 0, 0 },
-};
-
-static const struct inst db_inst_0f8x[] = {
-/*80*/ { "jo", FALSE, NONE, op1(Dl), 0 },
-/*81*/ { "jno", FALSE, NONE, op1(Dl), 0 },
-/*82*/ { "jb", FALSE, NONE, op1(Dl), 0 },
-/*83*/ { "jnb", FALSE, NONE, op1(Dl), 0 },
-/*84*/ { "jz", FALSE, NONE, op1(Dl), 0 },
-/*85*/ { "jnz", FALSE, NONE, op1(Dl), 0 },
-/*86*/ { "jbe", FALSE, NONE, op1(Dl), 0 },
-/*87*/ { "jnbe", FALSE, NONE, op1(Dl), 0 },
-
-/*88*/ { "js", FALSE, NONE, op1(Dl), 0 },
-/*89*/ { "jns", FALSE, NONE, op1(Dl), 0 },
-/*8a*/ { "jp", FALSE, NONE, op1(Dl), 0 },
-/*8b*/ { "jnp", FALSE, NONE, op1(Dl), 0 },
-/*8c*/ { "jl", FALSE, NONE, op1(Dl), 0 },
-/*8d*/ { "jnl", FALSE, NONE, op1(Dl), 0 },
-/*8e*/ { "jle", FALSE, NONE, op1(Dl), 0 },
-/*8f*/ { "jnle", FALSE, NONE, op1(Dl), 0 },
-};
-
-static const struct inst db_inst_0f9x[] = {
-/*90*/ { "seto", TRUE, NONE, op1(Eb), 0 },
-/*91*/ { "setno", TRUE, NONE, op1(Eb), 0 },
-/*92*/ { "setb", TRUE, NONE, op1(Eb), 0 },
-/*93*/ { "setnb", TRUE, NONE, op1(Eb), 0 },
-/*94*/ { "setz", TRUE, NONE, op1(Eb), 0 },
-/*95*/ { "setnz", TRUE, NONE, op1(Eb), 0 },
-/*96*/ { "setbe", TRUE, NONE, op1(Eb), 0 },
-/*97*/ { "setnbe",TRUE, NONE, op1(Eb), 0 },
-
-/*98*/ { "sets", TRUE, NONE, op1(Eb), 0 },
-/*99*/ { "setns", TRUE, NONE, op1(Eb), 0 },
-/*9a*/ { "setp", TRUE, NONE, op1(Eb), 0 },
-/*9b*/ { "setnp", TRUE, NONE, op1(Eb), 0 },
-/*9c*/ { "setl", TRUE, NONE, op1(Eb), 0 },
-/*9d*/ { "setnl", TRUE, NONE, op1(Eb), 0 },
-/*9e*/ { "setle", TRUE, NONE, op1(Eb), 0 },
-/*9f*/ { "setnle",TRUE, NONE, op1(Eb), 0 },
-};
-
-static const struct inst db_inst_0fax[] = {
-/*a0*/ { "push", FALSE, NONE, op1(Si), 0 },
-/*a1*/ { "pop", FALSE, NONE, op1(Si), 0 },
-/*a2*/ { "cpuid", FALSE, NONE, 0, 0 },
-/*a3*/ { "bt", TRUE, LONG, op2(R,E), 0 },
-/*a4*/ { "shld", TRUE, LONG, op3(Ib,R,E), 0 },
-/*a5*/ { "shld", TRUE, LONG, op3(CL,R,E), 0 },
-/*a6*/ { "", FALSE, NONE, 0, 0 },
-/*a7*/ { "", FALSE, NONE, 0, 0 },
-
-/*a8*/ { "push", FALSE, NONE, op1(Si), 0 },
-/*a9*/ { "pop", FALSE, NONE, op1(Si), 0 },
-/*aa*/ { "rsm", FALSE, NONE, 0, 0 },
-/*ab*/ { "bts", TRUE, LONG, op2(R,E), 0 },
-/*ac*/ { "shrd", TRUE, LONG, op3(Ib,R,E), 0 },
-/*ad*/ { "shrd", TRUE, LONG, op3(CL,R,E), 0 },
-/*a6*/ { "", FALSE, NONE, 0, 0 },
-/*a7*/ { "imul", TRUE, LONG, op2(E,R), 0 },
-};
-
-static const struct inst db_inst_0fbx[] = {
-/*b0*/ { "cmpxchg",TRUE, BYTE, op2(R, E), 0 },
-/*b0*/ { "cmpxchg",TRUE, LONG, op2(R, E), 0 },
-/*b2*/ { "lss", TRUE, LONG, op2(E, R), 0 },
-/*b3*/ { "btr", TRUE, LONG, op2(R, E), 0 },
-/*b4*/ { "lfs", TRUE, LONG, op2(E, R), 0 },
-/*b5*/ { "lgs", TRUE, LONG, op2(E, R), 0 },
-/*b6*/ { "movzb", TRUE, LONG, op2(Eb, R), 0 },
-/*b7*/ { "movzw", TRUE, LONG, op2(Ew, R), 0 },
-
-/*b8*/ { "", FALSE, NONE, 0, 0 },
-/*b9*/ { "", FALSE, NONE, 0, 0 },
-/*ba*/ { "", TRUE, LONG, op2(Ib, E), db_Grp8 },
-/*bb*/ { "btc", TRUE, LONG, op2(R, E), 0 },
-/*bc*/ { "bsf", TRUE, LONG, op2(E, R), 0 },
-/*bd*/ { "bsr", TRUE, LONG, op2(E, R), 0 },
-/*be*/ { "movsb", TRUE, LONG, op2(Eb, R), 0 },
-/*bf*/ { "movsw", TRUE, LONG, op2(Ew, R), 0 },
-};
-
-static const struct inst db_inst_0fcx[] = {
-/*c0*/ { "xadd", TRUE, BYTE, op2(R, E), 0 },
-/*c1*/ { "xadd", TRUE, LONG, op2(R, E), 0 },
-/*c2*/ { "", FALSE, NONE, 0, 0 },
-/*c3*/ { "", FALSE, NONE, 0, 0 },
-/*c4*/ { "", FALSE, NONE, 0, 0 },
-/*c5*/ { "", FALSE, NONE, 0, 0 },
-/*c6*/ { "", FALSE, NONE, 0, 0 },
-/*c7*/ { "", TRUE, NONE, op1(E), db_Grp9 },
-/*c8*/ { "bswap", FALSE, LONG, op1(Ril), 0 },
-/*c9*/ { "bswap", FALSE, LONG, op1(Ril), 0 },
-/*ca*/ { "bswap", FALSE, LONG, op1(Ril), 0 },
-/*cb*/ { "bswap", FALSE, LONG, op1(Ril), 0 },
-/*cc*/ { "bswap", FALSE, LONG, op1(Ril), 0 },
-/*cd*/ { "bswap", FALSE, LONG, op1(Ril), 0 },
-/*ce*/ { "bswap", FALSE, LONG, op1(Ril), 0 },
-/*cf*/ { "bswap", FALSE, LONG, op1(Ril), 0 },
-};
-
-static const struct inst * const db_inst_0f[] = {
- db_inst_0f0x,
- 0,
- db_inst_0f2x,
- db_inst_0f3x,
- 0,
- 0,
- 0,
- 0,
- db_inst_0f8x,
- db_inst_0f9x,
- db_inst_0fax,
- db_inst_0fbx,
- db_inst_0fcx,
- 0,
- 0,
- 0
-};
-
-static const char * const db_Esc92[] = {
- "fnop", "", "", "", "", "", "", ""
-};
-static const char * const db_Esc94[] = {
- "fchs", "fabs", "", "", "ftst", "fxam", "", ""
-};
-static const char * const db_Esc95[] = {
- "fld1", "fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz",""
-};
-static const char * const db_Esc96[] = {
- "f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp",
- "fincstp"
-};
-static const char * const db_Esc97[] = {
- "fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos"
-};
-
-static const char * const db_Esca5[] = {
- "", "fucompp","", "", "", "", "", ""
-};
-
-static const char * const db_Escb4[] = {
- "fneni","fndisi", "fnclex","fninit","fsetpm", "", "", ""
-};
-
-static const char * const db_Esce3[] = {
- "", "fcompp","", "", "", "", "", ""
-};
-
-static const char * const db_Escf4[] = {
- "fnstsw","", "", "", "", "", "", ""
-};
-
-static const struct finst db_Esc8[] = {
-/*0*/ { "fadd", SNGL, op2(STI,ST), 0 },
-/*1*/ { "fmul", SNGL, op2(STI,ST), 0 },
-/*2*/ { "fcom", SNGL, op2(STI,ST), 0 },
-/*3*/ { "fcomp", SNGL, op2(STI,ST), 0 },
-/*4*/ { "fsub", SNGL, op2(STI,ST), 0 },
-/*5*/ { "fsubr", SNGL, op2(STI,ST), 0 },
-/*6*/ { "fdiv", SNGL, op2(STI,ST), 0 },
-/*7*/ { "fdivr", SNGL, op2(STI,ST), 0 },
-};
-
-static const struct finst db_Esc9[] = {
-/*0*/ { "fld", SNGL, op1(STI), 0 },
-/*1*/ { "", NONE, op1(STI), "fxch" },
-/*2*/ { "fst", SNGL, op1(X), db_Esc92 },
-/*3*/ { "fstp", SNGL, 0, 0 },
-/*4*/ { "fldenv", NONE, op1(X), db_Esc94 },
-/*5*/ { "fldcw", NONE, op1(X), db_Esc95 },
-/*6*/ { "fnstenv",NONE, op1(X), db_Esc96 },
-/*7*/ { "fnstcw", NONE, op1(X), db_Esc97 },
-};
-
-static const struct finst db_Esca[] = {
-/*0*/ { "fiadd", LONG, 0, 0 },
-/*1*/ { "fimul", LONG, 0, 0 },
-/*2*/ { "ficom", LONG, 0, 0 },
-/*3*/ { "ficomp", LONG, 0, 0 },
-/*4*/ { "fisub", LONG, 0, 0 },
-/*5*/ { "fisubr", LONG, op1(X), db_Esca5 },
-/*6*/ { "fidiv", LONG, 0, 0 },
-/*7*/ { "fidivr", LONG, 0, 0 }
-};
-
-static const struct finst db_Escb[] = {
-/*0*/ { "fild", LONG, 0, 0 },
-/*1*/ { "", NONE, 0, 0 },
-/*2*/ { "fist", LONG, 0, 0 },
-/*3*/ { "fistp", LONG, 0, 0 },
-/*4*/ { "", WORD, op1(X), db_Escb4 },
-/*5*/ { "fld", EXTR, 0, 0 },
-/*6*/ { "", WORD, 0, 0 },
-/*7*/ { "fstp", EXTR, 0, 0 },
-};
-
-static const struct finst db_Escc[] = {
-/*0*/ { "fadd", DBLR, op2(ST,STI), 0 },
-/*1*/ { "fmul", DBLR, op2(ST,STI), 0 },
-/*2*/ { "fcom", DBLR, 0, 0 },
-/*3*/ { "fcomp", DBLR, 0, 0 },
-/*4*/ { "fsub", DBLR, op2(ST,STI), "fsubr" },
-/*5*/ { "fsubr", DBLR, op2(ST,STI), "fsub" },
-/*6*/ { "fdiv", DBLR, op2(ST,STI), "fdivr" },
-/*7*/ { "fdivr", DBLR, op2(ST,STI), "fdiv" },
-};
-
-static const struct finst db_Escd[] = {
-/*0*/ { "fld", DBLR, op1(STI), "ffree" },
-/*1*/ { "", NONE, 0, 0 },
-/*2*/ { "fst", DBLR, op1(STI), 0 },
-/*3*/ { "fstp", DBLR, op1(STI), 0 },
-/*4*/ { "frstor", NONE, op1(STI), "fucom" },
-/*5*/ { "", NONE, op1(STI), "fucomp" },
-/*6*/ { "fnsave", NONE, 0, 0 },
-/*7*/ { "fnstsw", NONE, 0, 0 },
-};
-
-static const struct finst db_Esce[] = {
-/*0*/ { "fiadd", WORD, op2(ST,STI), "faddp" },
-/*1*/ { "fimul", WORD, op2(ST,STI), "fmulp" },
-/*2*/ { "ficom", WORD, 0, 0 },
-/*3*/ { "ficomp", WORD, op1(X), db_Esce3 },
-/*4*/ { "fisub", WORD, op2(ST,STI), "fsubrp" },
-/*5*/ { "fisubr", WORD, op2(ST,STI), "fsubp" },
-/*6*/ { "fidiv", WORD, op2(ST,STI), "fdivrp" },
-/*7*/ { "fidivr", WORD, op2(ST,STI), "fdivp" },
-};
-
-static const struct finst db_Escf[] = {
-/*0*/ { "fild", WORD, 0, 0 },
-/*1*/ { "", NONE, 0, 0 },
-/*2*/ { "fist", WORD, 0, 0 },
-/*3*/ { "fistp", WORD, 0, 0 },
-/*4*/ { "fbld", NONE, op1(XA), db_Escf4 },
-/*5*/ { "fild", QUAD, 0, 0 },
-/*6*/ { "fbstp", NONE, 0, 0 },
-/*7*/ { "fistp", QUAD, 0, 0 },
-};
-
-static const struct finst * const db_Esc_inst[] = {
- db_Esc8, db_Esc9, db_Esca, db_Escb,
- db_Escc, db_Escd, db_Esce, db_Escf
-};
-
-static const char * const db_Grp1[] = {
- "add",
- "or",
- "adc",
- "sbb",
- "and",
- "sub",
- "xor",
- "cmp"
-};
-
-static const char * const db_Grp2[] = {
- "rol",
- "ror",
- "rcl",
- "rcr",
- "shl",
- "shr",
- "shl",
- "sar"
-};
-
-static const struct inst db_Grp3[] = {
- { "test", TRUE, NONE, op2(I,E), 0 },
- { "test", TRUE, NONE, op2(I,E), 0 },
- { "not", TRUE, NONE, op1(E), 0 },
- { "neg", TRUE, NONE, op1(E), 0 },
- { "mul", TRUE, NONE, op2(E,A), 0 },
- { "imul", TRUE, NONE, op2(E,A), 0 },
- { "div", TRUE, NONE, op2(E,A), 0 },
- { "idiv", TRUE, NONE, op2(E,A), 0 },
-};
-
-static const struct inst db_Grp4[] = {
- { "inc", TRUE, BYTE, op1(E), 0 },
- { "dec", TRUE, BYTE, op1(E), 0 },
- { "", TRUE, NONE, 0, 0 },
- { "", TRUE, NONE, 0, 0 },
- { "", TRUE, NONE, 0, 0 },
- { "", TRUE, NONE, 0, 0 },
- { "", TRUE, NONE, 0, 0 },
- { "", TRUE, NONE, 0, 0 }
-};
-
-static const struct inst db_Grp5[] = {
- { "inc", TRUE, LONG, op1(E), 0 },
- { "dec", TRUE, LONG, op1(E), 0 },
- { "call", TRUE, LONG, op1(Eind),0 },
- { "lcall", TRUE, LONG, op1(Eind),0 },
- { "jmp", TRUE, LONG, op1(Eind),0 },
- { "ljmp", TRUE, LONG, op1(Eind),0 },
- { "push", TRUE, LONG, op1(E), 0 },
- { "", TRUE, NONE, 0, 0 }
-};
-
-static const struct inst db_inst_table[256] = {
-/*00*/ { "add", TRUE, BYTE, op2(R, E), 0 },
-/*01*/ { "add", TRUE, LONG, op2(R, E), 0 },
-/*02*/ { "add", TRUE, BYTE, op2(E, R), 0 },
-/*03*/ { "add", TRUE, LONG, op2(E, R), 0 },
-/*04*/ { "add", FALSE, BYTE, op2(I, A), 0 },
-/*05*/ { "add", FALSE, LONG, op2(Is, A), 0 },
-/*06*/ { "push", FALSE, NONE, op1(Si), 0 },
-/*07*/ { "pop", FALSE, NONE, op1(Si), 0 },
-
-/*08*/ { "or", TRUE, BYTE, op2(R, E), 0 },
-/*09*/ { "or", TRUE, LONG, op2(R, E), 0 },
-/*0a*/ { "or", TRUE, BYTE, op2(E, R), 0 },
-/*0b*/ { "or", TRUE, LONG, op2(E, R), 0 },
-/*0c*/ { "or", FALSE, BYTE, op2(I, A), 0 },
-/*0d*/ { "or", FALSE, LONG, op2(I, A), 0 },
-/*0e*/ { "push", FALSE, NONE, op1(Si), 0 },
-/*0f*/ { "", FALSE, NONE, 0, 0 },
-
-/*10*/ { "adc", TRUE, BYTE, op2(R, E), 0 },
-/*11*/ { "adc", TRUE, LONG, op2(R, E), 0 },
-/*12*/ { "adc", TRUE, BYTE, op2(E, R), 0 },
-/*13*/ { "adc", TRUE, LONG, op2(E, R), 0 },
-/*14*/ { "adc", FALSE, BYTE, op2(I, A), 0 },
-/*15*/ { "adc", FALSE, LONG, op2(Is, A), 0 },
-/*16*/ { "push", FALSE, NONE, op1(Si), 0 },
-/*17*/ { "pop", FALSE, NONE, op1(Si), 0 },
-
-/*18*/ { "sbb", TRUE, BYTE, op2(R, E), 0 },
-/*19*/ { "sbb", TRUE, LONG, op2(R, E), 0 },
-/*1a*/ { "sbb", TRUE, BYTE, op2(E, R), 0 },
-/*1b*/ { "sbb", TRUE, LONG, op2(E, R), 0 },
-/*1c*/ { "sbb", FALSE, BYTE, op2(I, A), 0 },
-/*1d*/ { "sbb", FALSE, LONG, op2(Is, A), 0 },
-/*1e*/ { "push", FALSE, NONE, op1(Si), 0 },
-/*1f*/ { "pop", FALSE, NONE, op1(Si), 0 },
-
-/*20*/ { "and", TRUE, BYTE, op2(R, E), 0 },
-/*21*/ { "and", TRUE, LONG, op2(R, E), 0 },
-/*22*/ { "and", TRUE, BYTE, op2(E, R), 0 },
-/*23*/ { "and", TRUE, LONG, op2(E, R), 0 },
-/*24*/ { "and", FALSE, BYTE, op2(I, A), 0 },
-/*25*/ { "and", FALSE, LONG, op2(I, A), 0 },
-/*26*/ { "", FALSE, NONE, 0, 0 },
-/*27*/ { "daa", FALSE, NONE, 0, 0 },
-
-/*28*/ { "sub", TRUE, BYTE, op2(R, E), 0 },
-/*29*/ { "sub", TRUE, LONG, op2(R, E), 0 },
-/*2a*/ { "sub", TRUE, BYTE, op2(E, R), 0 },
-/*2b*/ { "sub", TRUE, LONG, op2(E, R), 0 },
-/*2c*/ { "sub", FALSE, BYTE, op2(I, A), 0 },
-/*2d*/ { "sub", FALSE, LONG, op2(Is, A), 0 },
-/*2e*/ { "", FALSE, NONE, 0, 0 },
-/*2f*/ { "das", FALSE, NONE, 0, 0 },
-
-/*30*/ { "xor", TRUE, BYTE, op2(R, E), 0 },
-/*31*/ { "xor", TRUE, LONG, op2(R, E), 0 },
-/*32*/ { "xor", TRUE, BYTE, op2(E, R), 0 },
-/*33*/ { "xor", TRUE, LONG, op2(E, R), 0 },
-/*34*/ { "xor", FALSE, BYTE, op2(I, A), 0 },
-/*35*/ { "xor", FALSE, LONG, op2(I, A), 0 },
-/*36*/ { "", FALSE, NONE, 0, 0 },
-/*37*/ { "aaa", FALSE, NONE, 0, 0 },
-
-/*38*/ { "cmp", TRUE, BYTE, op2(R, E), 0 },
-/*39*/ { "cmp", TRUE, LONG, op2(R, E), 0 },
-/*3a*/ { "cmp", TRUE, BYTE, op2(E, R), 0 },
-/*3b*/ { "cmp", TRUE, LONG, op2(E, R), 0 },
-/*3c*/ { "cmp", FALSE, BYTE, op2(I, A), 0 },
-/*3d*/ { "cmp", FALSE, LONG, op2(Is, A), 0 },
-/*3e*/ { "", FALSE, NONE, 0, 0 },
-/*3f*/ { "aas", FALSE, NONE, 0, 0 },
-
-/*40*/ { "inc", FALSE, LONG, op1(Ri), 0 },
-/*41*/ { "inc", FALSE, LONG, op1(Ri), 0 },
-/*42*/ { "inc", FALSE, LONG, op1(Ri), 0 },
-/*43*/ { "inc", FALSE, LONG, op1(Ri), 0 },
-/*44*/ { "inc", FALSE, LONG, op1(Ri), 0 },
-/*45*/ { "inc", FALSE, LONG, op1(Ri), 0 },
-/*46*/ { "inc", FALSE, LONG, op1(Ri), 0 },
-/*47*/ { "inc", FALSE, LONG, op1(Ri), 0 },
-
-/*48*/ { "dec", FALSE, LONG, op1(Ri), 0 },
-/*49*/ { "dec", FALSE, LONG, op1(Ri), 0 },
-/*4a*/ { "dec", FALSE, LONG, op1(Ri), 0 },
-/*4b*/ { "dec", FALSE, LONG, op1(Ri), 0 },
-/*4c*/ { "dec", FALSE, LONG, op1(Ri), 0 },
-/*4d*/ { "dec", FALSE, LONG, op1(Ri), 0 },
-/*4e*/ { "dec", FALSE, LONG, op1(Ri), 0 },
-/*4f*/ { "dec", FALSE, LONG, op1(Ri), 0 },
-
-/*50*/ { "push", FALSE, LONG, op1(Ri), 0 },
-/*51*/ { "push", FALSE, LONG, op1(Ri), 0 },
-/*52*/ { "push", FALSE, LONG, op1(Ri), 0 },
-/*53*/ { "push", FALSE, LONG, op1(Ri), 0 },
-/*54*/ { "push", FALSE, LONG, op1(Ri), 0 },
-/*55*/ { "push", FALSE, LONG, op1(Ri), 0 },
-/*56*/ { "push", FALSE, LONG, op1(Ri), 0 },
-/*57*/ { "push", FALSE, LONG, op1(Ri), 0 },
-
-/*58*/ { "pop", FALSE, LONG, op1(Ri), 0 },
-/*59*/ { "pop", FALSE, LONG, op1(Ri), 0 },
-/*5a*/ { "pop", FALSE, LONG, op1(Ri), 0 },
-/*5b*/ { "pop", FALSE, LONG, op1(Ri), 0 },
-/*5c*/ { "pop", FALSE, LONG, op1(Ri), 0 },
-/*5d*/ { "pop", FALSE, LONG, op1(Ri), 0 },
-/*5e*/ { "pop", FALSE, LONG, op1(Ri), 0 },
-/*5f*/ { "pop", FALSE, LONG, op1(Ri), 0 },
-
-/*60*/ { "pusha", FALSE, LONG, 0, 0 },
-/*61*/ { "popa", FALSE, LONG, 0, 0 },
-/*62*/ { "bound", TRUE, LONG, op2(E, R), 0 },
-/*63*/ { "arpl", TRUE, NONE, op2(Rw,Ew), 0 },
-
-/*64*/ { "", FALSE, NONE, 0, 0 },
-/*65*/ { "", FALSE, NONE, 0, 0 },
-/*66*/ { "", FALSE, NONE, 0, 0 },
-/*67*/ { "", FALSE, NONE, 0, 0 },
-
-/*68*/ { "push", FALSE, LONG, op1(I), 0 },
-/*69*/ { "imul", TRUE, LONG, op3(I,E,R), 0 },
-/*6a*/ { "push", FALSE, LONG, op1(Ibs), 0 },
-/*6b*/ { "imul", TRUE, LONG, op3(Ibs,E,R),0 },
-/*6c*/ { "ins", FALSE, BYTE, op2(DX, DI), 0 },
-/*6d*/ { "ins", FALSE, LONG, op2(DX, DI), 0 },
-/*6e*/ { "outs", FALSE, BYTE, op2(SI, DX), 0 },
-/*6f*/ { "outs", FALSE, LONG, op2(SI, DX), 0 },
-
-/*70*/ { "jo", FALSE, NONE, op1(Db), 0 },
-/*71*/ { "jno", FALSE, NONE, op1(Db), 0 },
-/*72*/ { "jb", FALSE, NONE, op1(Db), 0 },
-/*73*/ { "jnb", FALSE, NONE, op1(Db), 0 },
-/*74*/ { "jz", FALSE, NONE, op1(Db), 0 },
-/*75*/ { "jnz", FALSE, NONE, op1(Db), 0 },
-/*76*/ { "jbe", FALSE, NONE, op1(Db), 0 },
-/*77*/ { "jnbe", FALSE, NONE, op1(Db), 0 },
-
-/*78*/ { "js", FALSE, NONE, op1(Db), 0 },
-/*79*/ { "jns", FALSE, NONE, op1(Db), 0 },
-/*7a*/ { "jp", FALSE, NONE, op1(Db), 0 },
-/*7b*/ { "jnp", FALSE, NONE, op1(Db), 0 },
-/*7c*/ { "jl", FALSE, NONE, op1(Db), 0 },
-/*7d*/ { "jnl", FALSE, NONE, op1(Db), 0 },
-/*7e*/ { "jle", FALSE, NONE, op1(Db), 0 },
-/*7f*/ { "jnle", FALSE, NONE, op1(Db), 0 },
-
-/*80*/ { "", TRUE, BYTE, op2(I, E), db_Grp1 },
-/*81*/ { "", TRUE, LONG, op2(I, E), db_Grp1 },
-/*82*/ { "", TRUE, BYTE, op2(I, E), db_Grp1 },
-/*83*/ { "", TRUE, LONG, op2(Ibs,E), db_Grp1 },
-/*84*/ { "test", TRUE, BYTE, op2(R, E), 0 },
-/*85*/ { "test", TRUE, LONG, op2(R, E), 0 },
-/*86*/ { "xchg", TRUE, BYTE, op2(R, E), 0 },
-/*87*/ { "xchg", TRUE, LONG, op2(R, E), 0 },
-
-/*88*/ { "mov", TRUE, BYTE, op2(R, E), 0 },
-/*89*/ { "mov", TRUE, LONG, op2(R, E), 0 },
-/*8a*/ { "mov", TRUE, BYTE, op2(E, R), 0 },
-/*8b*/ { "mov", TRUE, LONG, op2(E, R), 0 },
-/*8c*/ { "mov", TRUE, NONE, op2(S, Ew), 0 },
-/*8d*/ { "lea", TRUE, LONG, op2(E, R), 0 },
-/*8e*/ { "mov", TRUE, NONE, op2(Ew, S), 0 },
-/*8f*/ { "pop", TRUE, LONG, op1(E), 0 },
-
-/*90*/ { "nop", FALSE, NONE, 0, 0 },
-/*91*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 },
-/*92*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 },
-/*93*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 },
-/*94*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 },
-/*95*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 },
-/*96*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 },
-/*97*/ { "xchg", FALSE, LONG, op2(A, Ri), 0 },
-
-/*98*/ { "cbw", FALSE, SDEP, 0, "cwde" }, /* cbw/cwde */
-/*99*/ { "cwd", FALSE, SDEP, 0, "cdq" }, /* cwd/cdq */
-/*9a*/ { "lcall", FALSE, NONE, op1(OS), 0 },
-/*9b*/ { "wait", FALSE, NONE, 0, 0 },
-/*9c*/ { "pushf", FALSE, LONG, 0, 0 },
-/*9d*/ { "popf", FALSE, LONG, 0, 0 },
-/*9e*/ { "sahf", FALSE, NONE, 0, 0 },
-/*9f*/ { "lahf", FALSE, NONE, 0, 0 },
-
-/*a0*/ { "mov", FALSE, BYTE, op2(O, A), 0 },
-/*a1*/ { "mov", FALSE, LONG, op2(O, A), 0 },
-/*a2*/ { "mov", FALSE, BYTE, op2(A, O), 0 },
-/*a3*/ { "mov", FALSE, LONG, op2(A, O), 0 },
-/*a4*/ { "movs", FALSE, BYTE, op2(SI,DI), 0 },
-/*a5*/ { "movs", FALSE, LONG, op2(SI,DI), 0 },
-/*a6*/ { "cmps", FALSE, BYTE, op2(SI,DI), 0 },
-/*a7*/ { "cmps", FALSE, LONG, op2(SI,DI), 0 },
-
-/*a8*/ { "test", FALSE, BYTE, op2(I, A), 0 },
-/*a9*/ { "test", FALSE, LONG, op2(I, A), 0 },
-/*aa*/ { "stos", FALSE, BYTE, op1(DI), 0 },
-/*ab*/ { "stos", FALSE, LONG, op1(DI), 0 },
-/*ac*/ { "lods", FALSE, BYTE, op1(SI), 0 },
-/*ad*/ { "lods", FALSE, LONG, op1(SI), 0 },
-/*ae*/ { "scas", FALSE, BYTE, op1(SI), 0 },
-/*af*/ { "scas", FALSE, LONG, op1(SI), 0 },
-
-/*b0*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 },
-/*b1*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 },
-/*b2*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 },
-/*b3*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 },
-/*b4*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 },
-/*b5*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 },
-/*b6*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 },
-/*b7*/ { "mov", FALSE, BYTE, op2(I, Ri), 0 },
-
-/*b8*/ { "mov", FALSE, LONG, op2(I, Ri), 0 },
-/*b9*/ { "mov", FALSE, LONG, op2(I, Ri), 0 },
-/*ba*/ { "mov", FALSE, LONG, op2(I, Ri), 0 },
-/*bb*/ { "mov", FALSE, LONG, op2(I, Ri), 0 },
-/*bc*/ { "mov", FALSE, LONG, op2(I, Ri), 0 },
-/*bd*/ { "mov", FALSE, LONG, op2(I, Ri), 0 },
-/*be*/ { "mov", FALSE, LONG, op2(I, Ri), 0 },
-/*bf*/ { "mov", FALSE, LONG, op2(I, Ri), 0 },
-
-/*c0*/ { "", TRUE, BYTE, op2(Ib, E), db_Grp2 },
-/*c1*/ { "", TRUE, LONG, op2(Ib, E), db_Grp2 },
-/*c2*/ { "ret", FALSE, NONE, op1(Iw), 0 },
-/*c3*/ { "ret", FALSE, NONE, 0, 0 },
-/*c4*/ { "les", TRUE, LONG, op2(E, R), 0 },
-/*c5*/ { "lds", TRUE, LONG, op2(E, R), 0 },
-/*c6*/ { "mov", TRUE, BYTE, op2(I, E), 0 },
-/*c7*/ { "mov", TRUE, LONG, op2(I, E), 0 },
-
-/*c8*/ { "enter", FALSE, NONE, op2(Iw, Ib), 0 },
-/*c9*/ { "leave", FALSE, NONE, 0, 0 },
-/*ca*/ { "lret", FALSE, NONE, op1(Iw), 0 },
-/*cb*/ { "lret", FALSE, NONE, 0, 0 },
-/*cc*/ { "int", FALSE, NONE, op1(o3), 0 },
-/*cd*/ { "int", FALSE, NONE, op1(Ib), 0 },
-/*ce*/ { "into", FALSE, NONE, 0, 0 },
-/*cf*/ { "iret", FALSE, NONE, 0, 0 },
-
-/*d0*/ { "", TRUE, BYTE, op2(o1, E), db_Grp2 },
-/*d1*/ { "", TRUE, LONG, op2(o1, E), db_Grp2 },
-/*d2*/ { "", TRUE, BYTE, op2(CL, E), db_Grp2 },
-/*d3*/ { "", TRUE, LONG, op2(CL, E), db_Grp2 },
-/*d4*/ { "aam", FALSE, NONE, op1(Iba), 0 },
-/*d5*/ { "aad", FALSE, NONE, op1(Iba), 0 },
-/*d6*/ { ".byte\t0xd6", FALSE, NONE, 0, 0 },
-/*d7*/ { "xlat", FALSE, BYTE, op1(BX), 0 },
-
-/*d8*/ { "", TRUE, NONE, 0, db_Esc8 },
-/*d9*/ { "", TRUE, NONE, 0, db_Esc9 },
-/*da*/ { "", TRUE, NONE, 0, db_Esca },
-/*db*/ { "", TRUE, NONE, 0, db_Escb },
-/*dc*/ { "", TRUE, NONE, 0, db_Escc },
-/*dd*/ { "", TRUE, NONE, 0, db_Escd },
-/*de*/ { "", TRUE, NONE, 0, db_Esce },
-/*df*/ { "", TRUE, NONE, 0, db_Escf },
-
-/*e0*/ { "loopne",FALSE, NONE, op1(Db), 0 },
-/*e1*/ { "loope", FALSE, NONE, op1(Db), 0 },
-/*e2*/ { "loop", FALSE, NONE, op1(Db), 0 },
-/*e3*/ { "jcxz", FALSE, SDEP, op1(Db), "jecxz" },
-/*e4*/ { "in", FALSE, BYTE, op2(Ib, A), 0 },
-/*e5*/ { "in", FALSE, LONG, op2(Ib, A) , 0 },
-/*e6*/ { "out", FALSE, BYTE, op2(A, Ib), 0 },
-/*e7*/ { "out", FALSE, LONG, op2(A, Ib) , 0 },
-
-/*e8*/ { "call", FALSE, NONE, op1(Dl), 0 },
-/*e9*/ { "jmp", FALSE, NONE, op1(Dl), 0 },
-/*ea*/ { "ljmp", FALSE, NONE, op1(OS), 0 },
-/*eb*/ { "jmp", FALSE, NONE, op1(Db), 0 },
-/*ec*/ { "in", FALSE, BYTE, op2(DX, A), 0 },
-/*ed*/ { "in", FALSE, LONG, op2(DX, A) , 0 },
-/*ee*/ { "out", FALSE, BYTE, op2(A, DX), 0 },
-/*ef*/ { "out", FALSE, LONG, op2(A, DX) , 0 },
-
-/*f0*/ { "", FALSE, NONE, 0, 0 },
-/*f1*/ { ".byte\t0xf1", FALSE, NONE, 0, 0 },
-/*f2*/ { "", FALSE, NONE, 0, 0 },
-/*f3*/ { "", FALSE, NONE, 0, 0 },
-/*f4*/ { "hlt", FALSE, NONE, 0, 0 },
-/*f5*/ { "cmc", FALSE, NONE, 0, 0 },
-/*f6*/ { "", TRUE, BYTE, 0, db_Grp3 },
-/*f7*/ { "", TRUE, LONG, 0, db_Grp3 },
-
-/*f8*/ { "clc", FALSE, NONE, 0, 0 },
-/*f9*/ { "stc", FALSE, NONE, 0, 0 },
-/*fa*/ { "cli", FALSE, NONE, 0, 0 },
-/*fb*/ { "sti", FALSE, NONE, 0, 0 },
-/*fc*/ { "cld", FALSE, NONE, 0, 0 },
-/*fd*/ { "std", FALSE, NONE, 0, 0 },
-/*fe*/ { "", TRUE, NONE, 0, db_Grp4 },
-/*ff*/ { "", TRUE, NONE, 0, db_Grp5 },
-};
-
-static const struct inst db_bad_inst =
- { "???", FALSE, NONE, 0, 0 }
-;
-
-#define f_mod(byte) ((byte)>>6)
-#define f_reg(byte) (((byte)>>3)&0x7)
-#define f_rm(byte) ((byte)&0x7)
-
-#define sib_ss(byte) ((byte)>>6)
-#define sib_index(byte) (((byte)>>3)&0x7)
-#define sib_base(byte) ((byte)&0x7)
-
-struct i_addr {
- int is_reg; /* if reg, reg number is in 'disp' */
- int disp;
- const char * base;
- const char * index;
- int ss;
-};
-
-static const char * const db_index_reg_16[8] = {
- "%bx,%si",
- "%bx,%di",
- "%bp,%si",
- "%bp,%di",
- "%si",
- "%di",
- "%bp",
- "%bx"
-};
-
-static const char * const db_reg[3][8] = {
- { "%al", "%cl", "%dl", "%bl", "%ah", "%ch", "%dh", "%bh" },
- { "%ax", "%cx", "%dx", "%bx", "%sp", "%bp", "%si", "%di" },
- { "%eax", "%ecx", "%edx", "%ebx", "%esp", "%ebp", "%esi", "%edi" }
-};
-
-static const char * const db_seg_reg[8] = {
- "%es", "%cs", "%ss", "%ds", "%fs", "%gs", "", ""
-};
-
-/*
- * lengths for size attributes
- */
-static const int db_lengths[] = {
- 1, /* BYTE */
- 2, /* WORD */
- 4, /* LONG */
- 8, /* QUAD */
- 4, /* SNGL */
- 8, /* DBLR */
- 10, /* EXTR */
-};
-
-#define get_value_inc(result, loc, size, is_signed) \
- result = db_get_value((loc), (size), (is_signed)); \
- (loc) += (size);
-
-static db_addr_t
- db_disasm_esc __P((db_addr_t loc, int inst, int short_addr,
- int size, const char *seg));
-static void db_print_address __P((const char *seg, int size,
- struct i_addr *addrp));
-static db_addr_t
- db_read_address __P((db_addr_t loc, int short_addr,
- int regmodrm, struct i_addr *addrp));
-
-/*
- * Read address at location and return updated location.
- */
-static db_addr_t
-db_read_address(loc, short_addr, regmodrm, addrp)
- db_addr_t loc;
- int short_addr;
- int regmodrm;
- struct i_addr * addrp; /* out */
-{
- int mod, rm, sib, index, disp;
-
- mod = f_mod(regmodrm);
- rm = f_rm(regmodrm);
-
- if (mod == 3) {
- addrp->is_reg = TRUE;
- addrp->disp = rm;
- return (loc);
- }
- addrp->is_reg = FALSE;
- addrp->index = 0;
-
- if (short_addr) {
- addrp->index = 0;
- addrp->ss = 0;
- switch (mod) {
- case 0:
- if (rm == 6) {
- get_value_inc(disp, loc, 2, FALSE);
- addrp->disp = disp;
- addrp->base = 0;
- }
- else {
- addrp->disp = 0;
- addrp->base = db_index_reg_16[rm];
- }
- break;
- case 1:
- get_value_inc(disp, loc, 1, TRUE);
- disp &= 0xFFFF;
- addrp->disp = disp;
- addrp->base = db_index_reg_16[rm];
- break;
- case 2:
- get_value_inc(disp, loc, 2, FALSE);
- addrp->disp = disp;
- addrp->base = db_index_reg_16[rm];
- break;
- }
- }
- else {
- if (mod != 3 && rm == 4) {
- get_value_inc(sib, loc, 1, FALSE);
- rm = sib_base(sib);
- index = sib_index(sib);
- if (index != 4)
- addrp->index = db_reg[LONG][index];
- addrp->ss = sib_ss(sib);
- }
-
- switch (mod) {
- case 0:
- if (rm == 5) {
- get_value_inc(addrp->disp, loc, 4, FALSE);
- addrp->base = 0;
- }
- else {
- addrp->disp = 0;
- addrp->base = db_reg[LONG][rm];
- }
- break;
-
- case 1:
- get_value_inc(disp, loc, 1, TRUE);
- addrp->disp = disp;
- addrp->base = db_reg[LONG][rm];
- break;
-
- case 2:
- get_value_inc(disp, loc, 4, FALSE);
- addrp->disp = disp;
- addrp->base = db_reg[LONG][rm];
- break;
- }
- }
- return (loc);
-}
-
-static void
-db_print_address(seg, size, addrp)
- const char * seg;
- int size;
- struct i_addr * addrp;
-{
- if (addrp->is_reg) {
- db_printf("%s", db_reg[size][addrp->disp]);
- return;
- }
-
- if (seg) {
- db_printf("%s:", seg);
- }
-
- db_printsym((db_addr_t)addrp->disp, DB_STGY_ANY);
- if (addrp->base != 0 || addrp->index != 0) {
- db_printf("(");
- if (addrp->base)
- db_printf("%s", addrp->base);
- if (addrp->index)
- db_printf(",%s,%d", addrp->index, 1<<addrp->ss);
- db_printf(")");
- }
-}
-
-/*
- * Disassemble floating-point ("escape") instruction
- * and return updated location.
- */
-static db_addr_t
-db_disasm_esc(loc, inst, short_addr, size, seg)
- db_addr_t loc;
- int inst;
- int short_addr;
- int size;
- const char * seg;
-{
- int regmodrm;
- const struct finst * fp;
- int mod;
- struct i_addr address;
- const char * name;
-
- get_value_inc(regmodrm, loc, 1, FALSE);
- fp = &db_Esc_inst[inst - 0xd8][f_reg(regmodrm)];
- mod = f_mod(regmodrm);
- if (mod != 3) {
- if (*fp->f_name == '\0') {
- db_printf("<bad instruction>");
- return (loc);
- }
- /*
- * Normal address modes.
- */
- loc = db_read_address(loc, short_addr, regmodrm, &address);
- db_printf(fp->f_name);
- switch(fp->f_size) {
- case SNGL:
- db_printf("s");
- break;
- case DBLR:
- db_printf("l");
- break;
- case EXTR:
- db_printf("t");
- break;
- case WORD:
- db_printf("s");
- break;
- case LONG:
- db_printf("l");
- break;
- case QUAD:
- db_printf("q");
- break;
- default:
- break;
- }
- db_printf("\t");
- db_print_address(seg, BYTE, &address);
- }
- else {
- /*
- * 'reg-reg' - special formats
- */
- switch (fp->f_rrmode) {
- case op2(ST,STI):
- name = (fp->f_rrname) ? fp->f_rrname : fp->f_name;
- db_printf("%s\t%%st,%%st(%d)",name,f_rm(regmodrm));
- break;
- case op2(STI,ST):
- name = (fp->f_rrname) ? fp->f_rrname : fp->f_name;
- db_printf("%s\t%%st(%d),%%st",name, f_rm(regmodrm));
- break;
- case op1(STI):
- name = (fp->f_rrname) ? fp->f_rrname : fp->f_name;
- db_printf("%s\t%%st(%d)",name, f_rm(regmodrm));
- break;
- case op1(X):
- name = ((const char * const *)fp->f_rrname)[f_rm(regmodrm)];
- if (*name == '\0')
- goto bad;
- db_printf("%s", name);
- break;
- case op1(XA):
- name = ((const char * const *)fp->f_rrname)[f_rm(regmodrm)];
- if (*name == '\0')
- goto bad;
- db_printf("%s\t%%ax", name);
- break;
- default:
- bad:
- db_printf("<bad instruction>");
- break;
- }
- }
-
- return (loc);
-}
-
-/*
- * Disassemble instruction at 'loc'. 'altfmt' specifies an
- * (optional) alternate format. Return address of start of
- * next instruction.
- */
-db_addr_t
-db_disasm(loc, altfmt)
- db_addr_t loc;
- boolean_t altfmt;
-{
- int inst;
- int size;
- int short_addr;
- const char * seg;
- const struct inst * ip;
- const char * i_name;
- int i_size;
- int i_mode;
- int regmodrm = 0;
- boolean_t first;
- int displ;
- int prefix;
- int imm;
- int imm2;
- int len;
- struct i_addr address;
-
- get_value_inc(inst, loc, 1, FALSE);
- short_addr = FALSE;
- size = LONG;
- seg = 0;
-
- /*
- * Get prefixes
- */
- prefix = TRUE;
- do {
- switch (inst) {
- case 0x66: /* data16 */
- size = WORD;
- break;
- case 0x67:
- short_addr = TRUE;
- break;
- case 0x26:
- seg = "%es";
- break;
- case 0x36:
- seg = "%ss";
- break;
- case 0x2e:
- seg = "%cs";
- break;
- case 0x3e:
- seg = "%ds";
- break;
- case 0x64:
- seg = "%fs";
- break;
- case 0x65:
- seg = "%gs";
- break;
- case 0xf0:
- db_printf("lock ");
- break;
- case 0xf2:
- db_printf("repne ");
- break;
- case 0xf3:
- db_printf("repe "); /* XXX repe VS rep */
- break;
- default:
- prefix = FALSE;
- break;
- }
- if (prefix) {
- get_value_inc(inst, loc, 1, FALSE);
- }
- } while (prefix);
-
- if (inst >= 0xd8 && inst <= 0xdf) {
- loc = db_disasm_esc(loc, inst, short_addr, size, seg);
- db_printf("\n");
- return (loc);
- }
-
- if (inst == 0x0f) {
- get_value_inc(inst, loc, 1, FALSE);
- ip = db_inst_0f[inst>>4];
- if (ip == 0) {
- ip = &db_bad_inst;
- }
- else {
- ip = &ip[inst&0xf];
- }
- }
- else
- ip = &db_inst_table[inst];
-
- if (ip->i_has_modrm) {
- get_value_inc(regmodrm, loc, 1, FALSE);
- loc = db_read_address(loc, short_addr, regmodrm, &address);
- }
-
- i_name = ip->i_name;
- i_size = ip->i_size;
- i_mode = ip->i_mode;
-
- if (ip->i_extra == db_Grp1 || ip->i_extra == db_Grp2 ||
- ip->i_extra == db_Grp6 || ip->i_extra == db_Grp7 ||
- ip->i_extra == db_Grp8 || ip->i_extra == db_Grp9) {
- i_name = ((const char * const *)ip->i_extra)[f_reg(regmodrm)];
- }
- else if (ip->i_extra == db_Grp3) {
- ip = ip->i_extra;
- ip = &ip[f_reg(regmodrm)];
- i_name = ip->i_name;
- i_mode = ip->i_mode;
- }
- else if (ip->i_extra == db_Grp4 || ip->i_extra == db_Grp5) {
- ip = ip->i_extra;
- ip = &ip[f_reg(regmodrm)];
- i_name = ip->i_name;
- i_mode = ip->i_mode;
- i_size = ip->i_size;
- }
-
- if (i_size == SDEP) {
- if (size == WORD)
- db_printf(i_name);
- else
- db_printf((const char *)ip->i_extra);
- }
- else {
- db_printf(i_name);
- if (i_size != NONE) {
- if (i_size == BYTE) {
- db_printf("b");
- size = BYTE;
- }
- else if (i_size == WORD) {
- db_printf("w");
- size = WORD;
- }
- else if (size == WORD)
- db_printf("w");
- else
- db_printf("l");
- }
- }
- db_printf("\t");
- for (first = TRUE;
- i_mode != 0;
- i_mode >>= 8, first = FALSE)
- {
- if (!first)
- db_printf(",");
-
- switch (i_mode & 0xFF) {
-
- case E:
- db_print_address(seg, size, &address);
- break;
-
- case Eind:
- db_printf("*");
- db_print_address(seg, size, &address);
- break;
-
- case El:
- db_print_address(seg, LONG, &address);
- break;
-
- case Ew:
- db_print_address(seg, WORD, &address);
- break;
-
- case Eb:
- db_print_address(seg, BYTE, &address);
- break;
-
- case R:
- db_printf("%s", db_reg[size][f_reg(regmodrm)]);
- break;
-
- case Rw:
- db_printf("%s", db_reg[WORD][f_reg(regmodrm)]);
- break;
-
- case Ri:
- db_printf("%s", db_reg[size][f_rm(inst)]);
- break;
-
- case Ril:
- db_printf("%s", db_reg[LONG][f_rm(inst)]);
- break;
-
- case S:
- db_printf("%s", db_seg_reg[f_reg(regmodrm)]);
- break;
-
- case Si:
- db_printf("%s", db_seg_reg[f_reg(inst)]);
- break;
-
- case A:
- db_printf("%s", db_reg[size][0]); /* acc */
- break;
-
- case BX:
- if (seg)
- db_printf("%s:", seg);
- db_printf("(%s)", short_addr ? "%bx" : "%ebx");
- break;
-
- case CL:
- db_printf("%%cl");
- break;
-
- case DX:
- db_printf("%%dx");
- break;
-
- case SI:
- if (seg)
- db_printf("%s:", seg);
- db_printf("(%s)", short_addr ? "%si" : "%esi");
- break;
-
- case DI:
- db_printf("%%es:(%s)", short_addr ? "%di" : "%edi");
- break;
-
- case CR:
- db_printf("%%cr%d", f_reg(regmodrm));
- break;
-
- case DR:
- db_printf("%%dr%d", f_reg(regmodrm));
- break;
-
- case TR:
- db_printf("%%tr%d", f_reg(regmodrm));
- break;
-
- case I:
- len = db_lengths[size];
- get_value_inc(imm, loc, len, FALSE);
- db_printf("$%#r", imm);
- break;
-
- case Is:
- len = db_lengths[size];
- get_value_inc(imm, loc, len, FALSE);
- db_printf("$%+#r", imm);
- break;
-
- case Ib:
- get_value_inc(imm, loc, 1, FALSE);
- db_printf("$%#r", imm);
- break;
-
- case Iba:
- get_value_inc(imm, loc, 1, FALSE);
- if (imm != 0x0a)
- db_printf("$%#r", imm);
- break;
-
- case Ibs:
- get_value_inc(imm, loc, 1, TRUE);
- if (size == WORD)
- imm &= 0xFFFF;
- db_printf("$%+#r", imm);
- break;
-
- case Iw:
- get_value_inc(imm, loc, 2, FALSE);
- db_printf("$%#r", imm);
- break;
-
- case O:
- len = (short_addr ? 2 : 4);
- get_value_inc(displ, loc, len, FALSE);
- if (seg)
- db_printf("%s:%+#r",seg, displ);
- else
- db_printsym((db_addr_t)displ, DB_STGY_ANY);
- break;
-
- case Db:
- get_value_inc(displ, loc, 1, TRUE);
- displ += loc;
- if (size == WORD)
- displ &= 0xFFFF;
- db_printsym((db_addr_t)displ, DB_STGY_XTRN);
- break;
-
- case Dl:
- len = db_lengths[size];
- get_value_inc(displ, loc, len, FALSE);
- displ += loc;
- if (size == WORD)
- displ &= 0xFFFF;
- db_printsym((db_addr_t)displ, DB_STGY_XTRN);
- break;
-
- case o1:
- db_printf("$1");
- break;
-
- case o3:
- db_printf("$3");
- break;
-
- case OS:
- len = db_lengths[size];
- get_value_inc(imm, loc, len, FALSE); /* offset */
- get_value_inc(imm2, loc, 2, FALSE); /* segment */
- db_printf("$%#r,%#r", imm2, imm);
- break;
- }
- }
- db_printf("\n");
- return (loc);
-}
diff --git a/sys/amd64/amd64/db_interface.c b/sys/amd64/amd64/db_interface.c
deleted file mode 100644
index 839d9b7c603d..000000000000
--- a/sys/amd64/amd64/db_interface.c
+++ /dev/null
@@ -1,321 +0,0 @@
-/*
- * Mach Operating System
- * Copyright (c) 1991,1990 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
- * 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Interface to new debugger.
- */
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/reboot.h>
-#include <sys/cons.h>
-
-#include <machine/cpu.h>
-#ifdef SMP
-#include <machine/smp.h>
-#include <machine/smptests.h> /** CPUSTOP_ON_DDBBREAK */
-#endif
-
-#include <vm/vm.h>
-#include <vm/pmap.h>
-
-#include <ddb/ddb.h>
-
-#include <setjmp.h>
-
-static jmp_buf *db_nofault = 0;
-extern jmp_buf db_jmpbuf;
-
-extern void gdb_handle_exception __P((db_regs_t *, int, int));
-
-int db_active;
-db_regs_t ddb_regs;
-
-static jmp_buf db_global_jmpbuf;
-static int db_global_jmpbuf_valid;
-
-#ifdef __GNUC__
-#define rss() ({u_short ss; __asm __volatile("movl %%ss,%0" : "=r" (ss)); ss;})
-#endif
-
-/*
- * kdb_trap - field a TRACE or BPT trap
- */
-int
-kdb_trap(type, code, regs)
- int type, code;
- register struct i386_saved_state *regs;
-{
- volatile int ddb_mode = !(boothowto & RB_GDB);
-
- /*
- * XXX try to do nothing if the console is in graphics mode.
- * Handle trace traps (and hardware breakpoints...) by ignoring
- * them except for forgetting about them. Return 0 for other
- * traps to say that we haven't done anything. The trap handler
- * will usually panic. We should handle breakpoint traps for
- * our breakpoints by disarming our breakpoints and fixing up
- * %eip.
- */
- if (cons_unavail && ddb_mode) {
- if (type == T_TRCTRAP) {
- regs->tf_eflags &= ~PSL_T;
- return (1);
- }
- return (0);
- }
-
- switch (type) {
- case T_BPTFLT: /* breakpoint */
- case T_TRCTRAP: /* debug exception */
- break;
-
- default:
- /*
- * XXX this is almost useless now. In most cases,
- * trap_fatal() has already printed a much more verbose
- * message. However, it is dangerous to print things in
- * trap_fatal() - printf() might be reentered and trap.
- * The debugger should be given control first.
- */
- if (ddb_mode)
- db_printf("kernel: type %d trap, code=%x\n", type, code);
-
- if (db_nofault) {
- jmp_buf *no_fault = db_nofault;
- db_nofault = 0;
- longjmp(*no_fault, 1);
- }
- }
-
- /*
- * This handles unexpected traps in ddb commands, including calls to
- * non-ddb functions. db_nofault only applies to memory accesses by
- * internal ddb commands.
- */
- if (db_global_jmpbuf_valid)
- longjmp(db_global_jmpbuf, 1);
-
- /*
- * XXX We really should switch to a local stack here.
- */
- ddb_regs = *regs;
-
- /*
- * If in kernel mode, esp and ss are not saved, so dummy them up.
- */
- if (ISPL(regs->tf_cs) == 0) {
- ddb_regs.tf_esp = (int)&regs->tf_esp;
- ddb_regs.tf_ss = rss();
- }
-
-#ifdef SMP
-#ifdef CPUSTOP_ON_DDBBREAK
-
-#if defined(VERBOSE_CPUSTOP_ON_DDBBREAK)
- db_printf("\nCPU%d stopping CPUs: 0x%08x\n", cpuid, other_cpus);
-#endif /* VERBOSE_CPUSTOP_ON_DDBBREAK */
-
- /* We stop all CPUs except ourselves (obviously) */
- stop_cpus(other_cpus);
-
-#if defined(VERBOSE_CPUSTOP_ON_DDBBREAK)
- db_printf(" stopped\n");
-#endif /* VERBOSE_CPUSTOP_ON_DDBBREAK */
-
-#endif /* CPUSTOP_ON_DDBBREAK */
-#endif /* SMP */
-
- (void) setjmp(db_global_jmpbuf);
- db_global_jmpbuf_valid = TRUE;
- db_active++;
- if (ddb_mode) {
- cndbctl(TRUE);
- db_trap(type, code);
- cndbctl(FALSE);
- } else
- gdb_handle_exception(&ddb_regs, type, code);
- db_active--;
- db_global_jmpbuf_valid = FALSE;
-
-#ifdef SMP
-#ifdef CPUSTOP_ON_DDBBREAK
-
-#if defined(VERBOSE_CPUSTOP_ON_DDBBREAK)
- db_printf("\nCPU%d restarting CPUs: 0x%08x\n", cpuid, stopped_cpus);
-#endif /* VERBOSE_CPUSTOP_ON_DDBBREAK */
-
- /* Restart all the CPUs we previously stopped */
- if (stopped_cpus != other_cpus && smp_started != 0) {
- db_printf("whoa, other_cpus: 0x%08x, stopped_cpus: 0x%08x\n",
- other_cpus, stopped_cpus);
- panic("stop_cpus() failed");
- }
- restart_cpus(stopped_cpus);
-
-#if defined(VERBOSE_CPUSTOP_ON_DDBBREAK)
- db_printf(" restarted\n");
-#endif /* VERBOSE_CPUSTOP_ON_DDBBREAK */
-
-#endif /* CPUSTOP_ON_DDBBREAK */
-#endif /* SMP */
-
- regs->tf_eip = ddb_regs.tf_eip;
- regs->tf_eflags = ddb_regs.tf_eflags;
- regs->tf_eax = ddb_regs.tf_eax;
- regs->tf_ecx = ddb_regs.tf_ecx;
- regs->tf_edx = ddb_regs.tf_edx;
- regs->tf_ebx = ddb_regs.tf_ebx;
-
- /*
- * If in user mode, the saved ESP and SS were valid, restore them.
- */
- if (ISPL(regs->tf_cs)) {
- regs->tf_esp = ddb_regs.tf_esp;
- regs->tf_ss = ddb_regs.tf_ss & 0xffff;
- }
-
- regs->tf_ebp = ddb_regs.tf_ebp;
- regs->tf_esi = ddb_regs.tf_esi;
- regs->tf_edi = ddb_regs.tf_edi;
- regs->tf_es = ddb_regs.tf_es & 0xffff;
- regs->tf_fs = ddb_regs.tf_fs & 0xffff;
- regs->tf_cs = ddb_regs.tf_cs & 0xffff;
- regs->tf_ds = ddb_regs.tf_ds & 0xffff;
- return (1);
-}
-
-/*
- * Read bytes from kernel address space for debugger.
- */
-void
-db_read_bytes(addr, size, data)
- vm_offset_t addr;
- register size_t size;
- register char *data;
-{
- register char *src;
-
- db_nofault = &db_jmpbuf;
-
- src = (char *)addr;
- while (size-- > 0)
- *data++ = *src++;
-
- db_nofault = 0;
-}
-
-/*
- * Write bytes to kernel address space for debugger.
- */
-void
-db_write_bytes(addr, size, data)
- vm_offset_t addr;
- register size_t size;
- register char *data;
-{
- register char *dst;
-
- unsigned *ptep0 = NULL;
- unsigned oldmap0 = 0;
- vm_offset_t addr1;
- unsigned *ptep1 = NULL;
- unsigned oldmap1 = 0;
-
- db_nofault = &db_jmpbuf;
-
- if (addr > trunc_page((vm_offset_t)btext) - size &&
- addr < round_page((vm_offset_t)etext)) {
-
- ptep0 = pmap_pte(kernel_pmap, addr);
- oldmap0 = *ptep0;
- *ptep0 |= PG_RW;
-
- /* Map another page if the data crosses a page boundary. */
- if ((*ptep0 & PG_PS) == 0) {
- addr1 = trunc_page(addr + size - 1);
- if (trunc_page(addr) != addr1) {
- ptep1 = pmap_pte(kernel_pmap, addr1);
- oldmap1 = *ptep1;
- *ptep1 |= PG_RW;
- }
- } else {
- addr1 = trunc_4mpage(addr + size - 1);
- if (trunc_4mpage(addr) != addr1) {
- ptep1 = pmap_pte(kernel_pmap, addr1);
- oldmap1 = *ptep1;
- *ptep1 |= PG_RW;
- }
- }
-
- invltlb();
- }
-
- dst = (char *)addr;
-
- while (size-- > 0)
- *dst++ = *data++;
-
- db_nofault = 0;
-
- if (ptep0) {
- *ptep0 = oldmap0;
-
- if (ptep1)
- *ptep1 = oldmap1;
-
- invltlb();
- }
-}
-
-/*
- * XXX
- * Move this to machdep.c and allow it to be called if any debugger is
- * installed.
- */
-void
-Debugger(msg)
- const char *msg;
-{
- static volatile u_char in_Debugger;
-
- /*
- * XXX
- * Do nothing if the console is in graphics mode. This is
- * OK if the call is for the debugger hotkey but not if the call
- * is a weak form of panicing.
- */
- if (cons_unavail && !(boothowto & RB_GDB))
- return;
-
- if (!in_Debugger) {
- in_Debugger = 1;
- db_printf("Debugger(\"%s\")\n", msg);
- breakpoint();
- in_Debugger = 0;
- }
-}
diff --git a/sys/amd64/amd64/db_trace.c b/sys/amd64/amd64/db_trace.c
deleted file mode 100644
index 074b4e639bcb..000000000000
--- a/sys/amd64/amd64/db_trace.c
+++ /dev/null
@@ -1,338 +0,0 @@
-/*
- * Mach Operating System
- * Copyright (c) 1991,1990 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
- * 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-
-#include <machine/cpu.h>
-
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <vm/pmap.h>
-#include <ddb/ddb.h>
-
-#include <ddb/db_access.h>
-#include <ddb/db_sym.h>
-#include <ddb/db_variables.h>
-
-/*
- * Machine register set.
- */
-struct db_variable db_regs[] = {
- { "cs", &ddb_regs.tf_cs, FCN_NULL },
- { "ds", &ddb_regs.tf_ds, FCN_NULL },
- { "es", &ddb_regs.tf_es, FCN_NULL },
- { "fs", &ddb_regs.tf_fs, FCN_NULL },
-#if 0
- { "gs", &ddb_regs.tf_gs, FCN_NULL },
-#endif
- { "ss", &ddb_regs.tf_ss, FCN_NULL },
- { "eax", &ddb_regs.tf_eax, FCN_NULL },
- { "ecx", &ddb_regs.tf_ecx, FCN_NULL },
- { "edx", &ddb_regs.tf_edx, FCN_NULL },
- { "ebx", &ddb_regs.tf_ebx, FCN_NULL },
- { "esp", &ddb_regs.tf_esp, FCN_NULL },
- { "ebp", &ddb_regs.tf_ebp, FCN_NULL },
- { "esi", &ddb_regs.tf_esi, FCN_NULL },
- { "edi", &ddb_regs.tf_edi, FCN_NULL },
- { "eip", &ddb_regs.tf_eip, FCN_NULL },
- { "efl", &ddb_regs.tf_eflags, FCN_NULL },
-};
-struct db_variable *db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]);
-
-/*
- * Stack trace.
- */
-#define INKERNEL(va) (((vm_offset_t)(va)) >= USRSTACK)
-
-struct i386_frame {
- struct i386_frame *f_frame;
- int f_retaddr;
- int f_arg0;
-};
-
-#define NORMAL 0
-#define TRAP 1
-#define INTERRUPT 2
-#define SYSCALL 3
-
-static void db_nextframe __P((struct i386_frame **, db_addr_t *));
-static int db_numargs __P((struct i386_frame *));
-static void db_print_stack_entry __P((const char *, int, char **, int *, db_addr_t));
-
-/*
- * Figure out how many arguments were passed into the frame at "fp".
- */
-static int
-db_numargs(fp)
- struct i386_frame *fp;
-{
- int *argp;
- int inst;
- int args;
-
- argp = (int *)db_get_value((int)&fp->f_retaddr, 4, FALSE);
- /*
- * XXX etext is wrong for LKMs. We should attempt to interpret
- * the instruction at the return address in all cases. This
- * may require better fault handling.
- */
- if (argp < (int *)btext || argp >= (int *)etext) {
- args = 5;
- } else {
- inst = db_get_value((int)argp, 4, FALSE);
- if ((inst & 0xff) == 0x59) /* popl %ecx */
- args = 1;
- else if ((inst & 0xffff) == 0xc483) /* addl $Ibs, %esp */
- args = ((inst >> 16) & 0xff) / 4;
- else
- args = 5;
- }
- return (args);
-}
-
-static void
-db_print_stack_entry(name, narg, argnp, argp, callpc)
- const char *name;
- int narg;
- char **argnp;
- int *argp;
- db_addr_t callpc;
-{
- db_printf("%s(", name);
- while (narg) {
- if (argnp)
- db_printf("%s=", *argnp++);
- db_printf("%r", db_get_value((int)argp, 4, FALSE));
- argp++;
- if (--narg != 0)
- db_printf(",");
- }
- db_printf(") at ");
- db_printsym(callpc, DB_STGY_PROC);
- db_printf("\n");
-}
-
-/*
- * Figure out the next frame up in the call stack.
- */
-static void
-db_nextframe(fp, ip)
- struct i386_frame **fp; /* in/out */
- db_addr_t *ip; /* out */
-{
- struct trapframe *tf;
- int frame_type;
- int eip, esp, ebp;
- db_expr_t offset;
- const char *sym, *name;
-
- eip = db_get_value((int) &(*fp)->f_retaddr, 4, FALSE);
- ebp = db_get_value((int) &(*fp)->f_frame, 4, FALSE);
-
- /*
- * Figure out frame type.
- */
-
- frame_type = NORMAL;
-
- sym = db_search_symbol(eip, DB_STGY_ANY, &offset);
- db_symbol_values(sym, &name, NULL);
- if (name != NULL) {
- if (!strcmp(name, "calltrap")) {
- frame_type = TRAP;
- } else if (!strncmp(name, "Xresume", 7)) {
- frame_type = INTERRUPT;
- } else if (!strcmp(name, "_Xsyscall")) {
- frame_type = SYSCALL;
- }
- }
-
- /*
- * Normal frames need no special processing.
- */
- if (frame_type == NORMAL) {
- *ip = (db_addr_t) eip;
- *fp = (struct i386_frame *) ebp;
- return;
- }
-
- db_print_stack_entry(name, 0, 0, 0, eip);
-
- /*
- * Point to base of trapframe which is just above the
- * current frame.
- */
- tf = (struct trapframe *) ((int)*fp + 8);
-
- esp = (ISPL(tf->tf_cs) == SEL_UPL) ? tf->tf_esp : (int)&tf->tf_esp;
- switch (frame_type) {
- case TRAP:
- if (INKERNEL((int) tf)) {
- eip = tf->tf_eip;
- ebp = tf->tf_ebp;
- db_printf(
- "--- trap %#r, eip = %#r, esp = %#r, ebp = %#r ---\n",
- tf->tf_trapno, eip, esp, ebp);
- }
- break;
- case SYSCALL:
- if (INKERNEL((int) tf)) {
- eip = tf->tf_eip;
- ebp = tf->tf_ebp;
- db_printf(
- "--- syscall %#r, eip = %#r, esp = %#r, ebp = %#r ---\n",
- tf->tf_eax, eip, esp, ebp);
- }
- break;
- case INTERRUPT:
- tf = (struct trapframe *)((int)*fp + 16);
- if (INKERNEL((int) tf)) {
- eip = tf->tf_eip;
- ebp = tf->tf_ebp;
- db_printf(
- "--- interrupt, eip = %#r, esp = %#r, ebp = %#r ---\n",
- eip, esp, ebp);
- }
- break;
- default:
- break;
- }
-
- *ip = (db_addr_t) eip;
- *fp = (struct i386_frame *) ebp;
-}
-
-void
-db_stack_trace_cmd(addr, have_addr, count, modif)
- db_expr_t addr;
- boolean_t have_addr;
- db_expr_t count;
- char *modif;
-{
- struct i386_frame *frame;
- int *argp;
- db_addr_t callpc;
- boolean_t first;
-
- if (count == -1)
- count = 65535;
-
- if (!have_addr) {
- frame = (struct i386_frame *)ddb_regs.tf_ebp;
- if (frame == NULL)
- frame = (struct i386_frame *)(ddb_regs.tf_esp - 4);
- callpc = (db_addr_t)ddb_regs.tf_eip;
- } else {
- frame = (struct i386_frame *)addr;
- callpc = (db_addr_t)db_get_value((int)&frame->f_retaddr, 4, FALSE);
- }
-
- first = TRUE;
- while (count--) {
- struct i386_frame *actframe;
- int narg;
- const char * name;
- db_expr_t offset;
- c_db_sym_t sym;
-#define MAXNARG 16
- char *argnames[MAXNARG], **argnp = NULL;
-
- sym = db_search_symbol(callpc, DB_STGY_ANY, &offset);
- db_symbol_values(sym, &name, NULL);
-
- /*
- * Attempt to determine a (possibly fake) frame that gives
- * the caller's pc. It may differ from `frame' if the
- * current function never sets up a standard frame or hasn't
- * set one up yet or has just discarded one. The last two
- * cases can be guessed fairly reliably for code generated
- * by gcc. The first case is too much trouble to handle in
- * general because the amount of junk on the stack depends
- * on the pc (the special handling of "calltrap", etc. in
- * db_nextframe() works because the `next' pc is special).
- */
- actframe = frame;
- if (first && !have_addr) {
- int instr;
-
- instr = db_get_value(callpc, 4, FALSE);
- if ((instr & 0x00ffffff) == 0x00e58955) {
- /* pushl %ebp; movl %esp, %ebp */
- actframe = (struct i386_frame *)
- (ddb_regs.tf_esp - 4);
- } else if ((instr & 0x0000ffff) == 0x0000e589) {
- /* movl %esp, %ebp */
- actframe = (struct i386_frame *)
- ddb_regs.tf_esp;
- if (ddb_regs.tf_ebp == 0) {
- /* Fake the caller's frame better. */
- frame = actframe;
- }
- } else if ((instr & 0x000000ff) == 0x000000c3) {
- /* ret */
- actframe = (struct i386_frame *)
- (ddb_regs.tf_esp - 4);
- } else if (offset == 0) {
- /* Probably a symbol in assembler code. */
- actframe = (struct i386_frame *)
- (ddb_regs.tf_esp - 4);
- }
- }
- first = FALSE;
-
- argp = &actframe->f_arg0;
- narg = MAXNARG;
- if (sym != NULL && db_sym_numargs(sym, &narg, argnames)) {
- argnp = argnames;
- } else {
- narg = db_numargs(frame);
- }
-
- db_print_stack_entry(name, narg, argnp, argp, callpc);
-
- if (actframe != frame) {
- /* `frame' belongs to caller. */
- callpc = (db_addr_t)
- db_get_value((int)&actframe->f_retaddr, 4, FALSE);
- continue;
- }
-
- db_nextframe(&frame, &callpc);
-
- if (INKERNEL((int) callpc) && !INKERNEL((int) frame)) {
- sym = db_search_symbol(callpc, DB_STGY_ANY, &offset);
- db_symbol_values(sym, &name, NULL);
- db_print_stack_entry(name, 0, 0, 0, callpc);
- break;
- }
- if (!INKERNEL((int) frame)) {
- break;
- }
- }
-}
diff --git a/sys/amd64/amd64/elf_machdep.c b/sys/amd64/amd64/elf_machdep.c
deleted file mode 100644
index 577aeac1c45c..000000000000
--- a/sys/amd64/amd64/elf_machdep.c
+++ /dev/null
@@ -1,120 +0,0 @@
-/*-
- * Copyright 1996-1998 John D. Polstra.
- * 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/linker.h>
-#include <machine/elf.h>
-
-/* Process one elf relocation with addend. */
-int
-elf_reloc(linker_file_t lf, const void *data, int type, const char *sym)
-{
- Elf_Addr relocbase = (Elf_Addr) lf->address;
- Elf_Addr *where;
- Elf_Addr addr;
- Elf_Addr addend;
- Elf_Word rtype;
- const Elf_Rel *rel;
- const Elf_Rela *rela;
-
- switch (type) {
- case ELF_RELOC_REL:
- rel = (const Elf_Rel *)data;
- where = (Elf_Addr *) (relocbase + rel->r_offset);
- addend = *where;
- rtype = ELF_R_TYPE(rel->r_info);
- break;
- case ELF_RELOC_RELA:
- rela = (const Elf_Rela *)data;
- where = (Elf_Addr *) (relocbase + rela->r_offset);
- addend = rela->r_addend;
- rtype = ELF_R_TYPE(rela->r_info);
- break;
- default:
- panic("unknown reloc type %d\n", type);
- }
-
- switch (rtype) {
-
- case R_386_NONE: /* none */
- break;
-
- case R_386_32: /* S + A */
- if (sym == NULL)
- return -1;
- addr = (Elf_Addr)linker_file_lookup_symbol(lf, sym, 1);
- if (addr == 0)
- return -1;
- addr += addend;
- if (*where != addr)
- *where = addr;
- break;
-
- case R_386_PC32: /* S + A - P */
- if (sym == NULL)
- return -1;
- addr = (Elf_Addr)linker_file_lookup_symbol(lf, sym, 1);
- if (addr == 0)
- return -1;
- addr += addend - (Elf_Addr)where;
- if (*where != addr)
- *where = addr;
- break;
-
- case R_386_COPY: /* none */
- /*
- * There shouldn't be copy relocations in kernel
- * objects.
- */
- printf("kldload: unexpected R_COPY relocation\n");
- return -1;
- break;
-
- case R_386_GLOB_DAT: /* S */
- if (sym == NULL)
- return -1;
- addr = (Elf_Addr)linker_file_lookup_symbol(lf, sym, 1);
- if (addr == 0)
- return -1;
- if (*where != addr)
- *where = addr;
- break;
-
- case R_386_RELATIVE: /* B + A */
- addr = relocbase + addend;
- if (*where != addr)
- *where = addr;
- break;
-
- default:
- printf("kldload: unexpected relocation type %d\n",
- rtype);
- return -1;
- }
- return(0);
-}
diff --git a/sys/amd64/amd64/exception.S b/sys/amd64/amd64/exception.S
deleted file mode 100644
index 7042d58f79cb..000000000000
--- a/sys/amd64/amd64/exception.S
+++ /dev/null
@@ -1,363 +0,0 @@
-/*-
- * Copyright (c) 1990 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- */
-
-#include "npx.h"
-
-#include <machine/asmacros.h>
-#include <machine/ipl.h>
-#include <machine/lock.h>
-#include <machine/psl.h>
-#include <machine/trap.h>
-#ifdef SMP
-#include <machine/smptests.h> /** CPL_AND_CML, REAL_ */
-#endif
-
-#include "assym.s"
-
-#ifndef SMP
-#define ECPL_LOCK /* make these nops */
-#define ECPL_UNLOCK
-#define ICPL_LOCK
-#define ICPL_UNLOCK
-#define FAST_ICPL_UNLOCK
-#define AICPL_LOCK
-#define AICPL_UNLOCK
-#define AVCPL_LOCK
-#define AVCPL_UNLOCK
-#endif /* SMP */
-
-#ifdef SMP
-#define MOVL_KPSEL_EAX movl $KPSEL,%eax
-#else
-#define MOVL_KPSEL_EAX
-#endif
-#define SEL_RPL_MASK 0x0003
-
- .text
-
-/*****************************************************************************/
-/* Trap handling */
-/*****************************************************************************/
-/*
- * Trap and fault vector routines
- */
-#define IDTVEC(name) ALIGN_TEXT; .globl __CONCAT(_X,name); \
- .type __CONCAT(_X,name),@function; __CONCAT(_X,name):
-#define TRAP(a) pushl $(a) ; jmp _alltraps
-
-/*
- * XXX - debugger traps are now interrupt gates so at least bdb doesn't lose
- * control. The sti's give the standard losing behaviour for ddb and kgdb.
- */
-#ifdef BDE_DEBUGGER
-#define BDBTRAP(name) \
- ss ; \
- cmpb $0,_bdb_exists ; \
- je 1f ; \
- testb $SEL_RPL_MASK,4(%esp) ; \
- jne 1f ; \
- ss ; \
- .globl __CONCAT(__CONCAT(bdb_,name),_ljmp); \
-__CONCAT(__CONCAT(bdb_,name),_ljmp): \
- ljmp $0,$0 ; \
-1:
-#else
-#define BDBTRAP(name)
-#endif
-
-#define BPTTRAP(a) testl $PSL_I,4+8(%esp) ; je 1f ; sti ; 1: ; TRAP(a)
-
-MCOUNT_LABEL(user)
-MCOUNT_LABEL(btrap)
-
-IDTVEC(div)
- pushl $0; TRAP(T_DIVIDE)
-IDTVEC(dbg)
- BDBTRAP(dbg)
- pushl $0; BPTTRAP(T_TRCTRAP)
-IDTVEC(nmi)
- pushl $0; TRAP(T_NMI)
-IDTVEC(bpt)
- BDBTRAP(bpt)
- pushl $0; BPTTRAP(T_BPTFLT)
-IDTVEC(ofl)
- pushl $0; TRAP(T_OFLOW)
-IDTVEC(bnd)
- pushl $0; TRAP(T_BOUND)
-IDTVEC(ill)
- pushl $0; TRAP(T_PRIVINFLT)
-IDTVEC(dna)
- pushl $0; TRAP(T_DNA)
-IDTVEC(fpusegm)
- pushl $0; TRAP(T_FPOPFLT)
-IDTVEC(tss)
- TRAP(T_TSSFLT)
-IDTVEC(missing)
- TRAP(T_SEGNPFLT)
-IDTVEC(stk)
- TRAP(T_STKFLT)
-IDTVEC(prot)
- TRAP(T_PROTFLT)
-IDTVEC(page)
- TRAP(T_PAGEFLT)
-IDTVEC(mchk)
- pushl $0; TRAP(T_MCHK)
-IDTVEC(rsvd)
- pushl $0; TRAP(T_RESERVED)
-
-IDTVEC(fpu)
-#if NNPX > 0
- /*
- * Handle like an interrupt (except for accounting) so that we can
- * call npx_intr to clear the error. It would be better to handle
- * npx interrupts as traps. Nested interrupts would probably have
- * to be converted to ASTs.
- */
- pushl $0 /* dummy error code */
- pushl $0 /* dummy trap type */
- pushal
- pushl %ds
- pushl %es /* now stack frame is a trap frame */
- pushl %fs
- movl $KDSEL,%eax
- movl %ax,%ds
- movl %ax,%es
- MOVL_KPSEL_EAX
- movl %ax,%fs
- FAKE_MCOUNT(13*4(%esp))
-
-#ifdef SMP
- MPLOCKED incl _cnt+V_TRAP
- FPU_LOCK
- ECPL_LOCK
-#ifdef CPL_AND_CML
- movl _cml,%eax
- pushl %eax /* save original cml */
-#else
- movl _cpl,%eax
- pushl %eax /* save original cpl */
-#endif /* CPL_AND_CML */
- ECPL_UNLOCK
- pushl $0 /* dummy unit to finish intr frame */
-#else /* SMP */
- movl _cpl,%eax
- pushl %eax
- pushl $0 /* dummy unit to finish intr frame */
- incl _cnt+V_TRAP
-#endif /* SMP */
-
- call _npx_intr
-
- incb _intr_nesting_level
- MEXITCOUNT
- jmp _doreti
-#else /* NNPX > 0 */
- pushl $0; TRAP(T_ARITHTRAP)
-#endif /* NNPX > 0 */
-
-IDTVEC(align)
- TRAP(T_ALIGNFLT)
-
- SUPERALIGN_TEXT
- .globl _alltraps
- .type _alltraps,@function
-_alltraps:
- pushal
- pushl %ds
- pushl %es
- pushl %fs
-alltraps_with_regs_pushed:
- movl $KDSEL,%eax
- movl %ax,%ds
- movl %ax,%es
- MOVL_KPSEL_EAX
- movl %ax,%fs
- FAKE_MCOUNT(13*4(%esp))
-calltrap:
- FAKE_MCOUNT(_btrap) /* init "from" _btrap -> calltrap */
- MPLOCKED incl _cnt+V_TRAP
- ALIGN_LOCK
- ECPL_LOCK
-#ifdef CPL_AND_CML
- movl _cml,%ebx /* keep orig. cml here during trap() */
-#else
- movl _cpl,%ebx /* keep orig. cpl here during trap() */
-#endif
- ECPL_UNLOCK
- call _trap
-
- /*
- * Return via _doreti to handle ASTs. Have to change trap frame
- * to interrupt frame.
- */
- pushl %ebx /* cpl to restore */
- subl $4,%esp /* dummy unit to finish intr frame */
- MPLOCKED incb _intr_nesting_level
- MEXITCOUNT
- jmp _doreti
-
-/*
- * Call gate entry for syscall.
- * The intersegment call has been set up to specify one dummy parameter.
- * This leaves a place to put eflags so that the call frame can be
- * converted to a trap frame. Note that the eflags is (semi-)bogusly
- * pushed into (what will be) tf_err and then copied later into the
- * final spot. It has to be done this way because esp can't be just
- * temporarily altered for the pushfl - an interrupt might come in
- * and clobber the saved cs/eip.
- */
-/*
- * THis first callgate is used for the old a.out binaries
- */
- SUPERALIGN_TEXT
-IDTVEC(syscall)
- pushfl /* save eflags in tf_err for now */
- subl $4,%esp /* skip over tf_trapno */
- pushal
- pushl %ds
- pushl %es
- pushl %fs
- movl $KDSEL,%eax /* switch to kernel segments */
- movl %ax,%ds
- movl %ax,%es
- MOVL_KPSEL_EAX
- movl %ax,%fs
- movl TF_ERR(%esp),%eax /* copy saved eflags to final spot */
- movl %eax,TF_EFLAGS(%esp)
- movl $7,TF_ERR(%esp) /* sizeof "lcall 7,0" */
- FAKE_MCOUNT(13*4(%esp))
- MPLOCKED incl _cnt+V_SYSCALL
- SYSCALL_LOCK
- call _syscall
-
- /*
- * Return via _doreti to handle ASTs.
- */
- pushl $0 /* cpl to restore */
- subl $4,%esp /* dummy unit to finish intr frame */
- movb $1,_intr_nesting_level
- MEXITCOUNT
- jmp _doreti
-
-/*
- * Call gate entry for FreeBSD ELF and Linux/NetBSD syscall (int 0x80)
- */
- SUPERALIGN_TEXT
-IDTVEC(int0x80_syscall)
- subl $8,%esp /* skip over tf_trapno and tf_err */
- pushal
- pushl %ds
- pushl %es
- pushl %fs
- movl $KDSEL,%eax /* switch to kernel segments */
- movl %ax,%ds
- movl %ax,%es
- MOVL_KPSEL_EAX
- movl %ax,%fs
- movl $2,TF_ERR(%esp) /* sizeof "int 0x80" */
- FAKE_MCOUNT(13*4(%esp))
- MPLOCKED incl _cnt+V_SYSCALL
- ALTSYSCALL_LOCK
- call _syscall
-
- /*
- * Return via _doreti to handle ASTs.
- */
- pushl $0 /* cpl to restore */
- subl $4,%esp /* dummy unit to finish intr frame */
- movb $1,_intr_nesting_level
- MEXITCOUNT
- jmp _doreti
-
-ENTRY(fork_trampoline)
- call _spl0
-
-#ifdef SMP
- cmpl $0,_switchtime
- jne 1f
- movl $gd_switchtime,%eax
- addl %fs:0,%eax
- pushl %eax
- call _microuptime
- popl %edx
- movl _ticks,%eax
- movl %eax,_switchticks
-1:
-#endif
-
- /*
- * cpu_set_fork_handler intercepts this function call to
- * have this call a non-return function to stay in kernel mode.
- * initproc has its own fork handler, but it does return.
- */
- pushl %ebx /* arg1 */
- call %esi /* function */
- addl $4,%esp
- /* cut from syscall */
-
- /*
- * Return via _doreti to handle ASTs.
- */
- pushl $0 /* cpl to restore */
- subl $4,%esp /* dummy unit to finish intr frame */
- movb $1,_intr_nesting_level
- MEXITCOUNT
- jmp _doreti
-
-
-/*
- * Include vm86 call routines, which want to call _doreti.
- */
-#include "i386/i386/vm86bios.s"
-
-/*
- * Include what was once config+isa-dependent code.
- * XXX it should be in a stand-alone file. It's still icu-dependent and
- * belongs in i386/isa.
- */
-#include "i386/isa/vector.s"
-
-/*
- * Include what was once icu-dependent code.
- * XXX it should be merged into this file (also move the definition of
- * imen to vector.s or isa.c).
- * Before including it, set up a normal asm environment so that vector.s
- * doesn't have to know that stuff is included after it.
- */
- .data
- ALIGN_DATA
- .text
- SUPERALIGN_TEXT
-#include "i386/isa/ipl.s"
diff --git a/sys/amd64/amd64/exception.s b/sys/amd64/amd64/exception.s
deleted file mode 100644
index 7042d58f79cb..000000000000
--- a/sys/amd64/amd64/exception.s
+++ /dev/null
@@ -1,363 +0,0 @@
-/*-
- * Copyright (c) 1990 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- */
-
-#include "npx.h"
-
-#include <machine/asmacros.h>
-#include <machine/ipl.h>
-#include <machine/lock.h>
-#include <machine/psl.h>
-#include <machine/trap.h>
-#ifdef SMP
-#include <machine/smptests.h> /** CPL_AND_CML, REAL_ */
-#endif
-
-#include "assym.s"
-
-#ifndef SMP
-#define ECPL_LOCK /* make these nops */
-#define ECPL_UNLOCK
-#define ICPL_LOCK
-#define ICPL_UNLOCK
-#define FAST_ICPL_UNLOCK
-#define AICPL_LOCK
-#define AICPL_UNLOCK
-#define AVCPL_LOCK
-#define AVCPL_UNLOCK
-#endif /* SMP */
-
-#ifdef SMP
-#define MOVL_KPSEL_EAX movl $KPSEL,%eax
-#else
-#define MOVL_KPSEL_EAX
-#endif
-#define SEL_RPL_MASK 0x0003
-
- .text
-
-/*****************************************************************************/
-/* Trap handling */
-/*****************************************************************************/
-/*
- * Trap and fault vector routines
- */
-#define IDTVEC(name) ALIGN_TEXT; .globl __CONCAT(_X,name); \
- .type __CONCAT(_X,name),@function; __CONCAT(_X,name):
-#define TRAP(a) pushl $(a) ; jmp _alltraps
-
-/*
- * XXX - debugger traps are now interrupt gates so at least bdb doesn't lose
- * control. The sti's give the standard losing behaviour for ddb and kgdb.
- */
-#ifdef BDE_DEBUGGER
-#define BDBTRAP(name) \
- ss ; \
- cmpb $0,_bdb_exists ; \
- je 1f ; \
- testb $SEL_RPL_MASK,4(%esp) ; \
- jne 1f ; \
- ss ; \
- .globl __CONCAT(__CONCAT(bdb_,name),_ljmp); \
-__CONCAT(__CONCAT(bdb_,name),_ljmp): \
- ljmp $0,$0 ; \
-1:
-#else
-#define BDBTRAP(name)
-#endif
-
-#define BPTTRAP(a) testl $PSL_I,4+8(%esp) ; je 1f ; sti ; 1: ; TRAP(a)
-
-MCOUNT_LABEL(user)
-MCOUNT_LABEL(btrap)
-
-IDTVEC(div)
- pushl $0; TRAP(T_DIVIDE)
-IDTVEC(dbg)
- BDBTRAP(dbg)
- pushl $0; BPTTRAP(T_TRCTRAP)
-IDTVEC(nmi)
- pushl $0; TRAP(T_NMI)
-IDTVEC(bpt)
- BDBTRAP(bpt)
- pushl $0; BPTTRAP(T_BPTFLT)
-IDTVEC(ofl)
- pushl $0; TRAP(T_OFLOW)
-IDTVEC(bnd)
- pushl $0; TRAP(T_BOUND)
-IDTVEC(ill)
- pushl $0; TRAP(T_PRIVINFLT)
-IDTVEC(dna)
- pushl $0; TRAP(T_DNA)
-IDTVEC(fpusegm)
- pushl $0; TRAP(T_FPOPFLT)
-IDTVEC(tss)
- TRAP(T_TSSFLT)
-IDTVEC(missing)
- TRAP(T_SEGNPFLT)
-IDTVEC(stk)
- TRAP(T_STKFLT)
-IDTVEC(prot)
- TRAP(T_PROTFLT)
-IDTVEC(page)
- TRAP(T_PAGEFLT)
-IDTVEC(mchk)
- pushl $0; TRAP(T_MCHK)
-IDTVEC(rsvd)
- pushl $0; TRAP(T_RESERVED)
-
-IDTVEC(fpu)
-#if NNPX > 0
- /*
- * Handle like an interrupt (except for accounting) so that we can
- * call npx_intr to clear the error. It would be better to handle
- * npx interrupts as traps. Nested interrupts would probably have
- * to be converted to ASTs.
- */
- pushl $0 /* dummy error code */
- pushl $0 /* dummy trap type */
- pushal
- pushl %ds
- pushl %es /* now stack frame is a trap frame */
- pushl %fs
- movl $KDSEL,%eax
- movl %ax,%ds
- movl %ax,%es
- MOVL_KPSEL_EAX
- movl %ax,%fs
- FAKE_MCOUNT(13*4(%esp))
-
-#ifdef SMP
- MPLOCKED incl _cnt+V_TRAP
- FPU_LOCK
- ECPL_LOCK
-#ifdef CPL_AND_CML
- movl _cml,%eax
- pushl %eax /* save original cml */
-#else
- movl _cpl,%eax
- pushl %eax /* save original cpl */
-#endif /* CPL_AND_CML */
- ECPL_UNLOCK
- pushl $0 /* dummy unit to finish intr frame */
-#else /* SMP */
- movl _cpl,%eax
- pushl %eax
- pushl $0 /* dummy unit to finish intr frame */
- incl _cnt+V_TRAP
-#endif /* SMP */
-
- call _npx_intr
-
- incb _intr_nesting_level
- MEXITCOUNT
- jmp _doreti
-#else /* NNPX > 0 */
- pushl $0; TRAP(T_ARITHTRAP)
-#endif /* NNPX > 0 */
-
-IDTVEC(align)
- TRAP(T_ALIGNFLT)
-
- SUPERALIGN_TEXT
- .globl _alltraps
- .type _alltraps,@function
-_alltraps:
- pushal
- pushl %ds
- pushl %es
- pushl %fs
-alltraps_with_regs_pushed:
- movl $KDSEL,%eax
- movl %ax,%ds
- movl %ax,%es
- MOVL_KPSEL_EAX
- movl %ax,%fs
- FAKE_MCOUNT(13*4(%esp))
-calltrap:
- FAKE_MCOUNT(_btrap) /* init "from" _btrap -> calltrap */
- MPLOCKED incl _cnt+V_TRAP
- ALIGN_LOCK
- ECPL_LOCK
-#ifdef CPL_AND_CML
- movl _cml,%ebx /* keep orig. cml here during trap() */
-#else
- movl _cpl,%ebx /* keep orig. cpl here during trap() */
-#endif
- ECPL_UNLOCK
- call _trap
-
- /*
- * Return via _doreti to handle ASTs. Have to change trap frame
- * to interrupt frame.
- */
- pushl %ebx /* cpl to restore */
- subl $4,%esp /* dummy unit to finish intr frame */
- MPLOCKED incb _intr_nesting_level
- MEXITCOUNT
- jmp _doreti
-
-/*
- * Call gate entry for syscall.
- * The intersegment call has been set up to specify one dummy parameter.
- * This leaves a place to put eflags so that the call frame can be
- * converted to a trap frame. Note that the eflags is (semi-)bogusly
- * pushed into (what will be) tf_err and then copied later into the
- * final spot. It has to be done this way because esp can't be just
- * temporarily altered for the pushfl - an interrupt might come in
- * and clobber the saved cs/eip.
- */
-/*
- * THis first callgate is used for the old a.out binaries
- */
- SUPERALIGN_TEXT
-IDTVEC(syscall)
- pushfl /* save eflags in tf_err for now */
- subl $4,%esp /* skip over tf_trapno */
- pushal
- pushl %ds
- pushl %es
- pushl %fs
- movl $KDSEL,%eax /* switch to kernel segments */
- movl %ax,%ds
- movl %ax,%es
- MOVL_KPSEL_EAX
- movl %ax,%fs
- movl TF_ERR(%esp),%eax /* copy saved eflags to final spot */
- movl %eax,TF_EFLAGS(%esp)
- movl $7,TF_ERR(%esp) /* sizeof "lcall 7,0" */
- FAKE_MCOUNT(13*4(%esp))
- MPLOCKED incl _cnt+V_SYSCALL
- SYSCALL_LOCK
- call _syscall
-
- /*
- * Return via _doreti to handle ASTs.
- */
- pushl $0 /* cpl to restore */
- subl $4,%esp /* dummy unit to finish intr frame */
- movb $1,_intr_nesting_level
- MEXITCOUNT
- jmp _doreti
-
-/*
- * Call gate entry for FreeBSD ELF and Linux/NetBSD syscall (int 0x80)
- */
- SUPERALIGN_TEXT
-IDTVEC(int0x80_syscall)
- subl $8,%esp /* skip over tf_trapno and tf_err */
- pushal
- pushl %ds
- pushl %es
- pushl %fs
- movl $KDSEL,%eax /* switch to kernel segments */
- movl %ax,%ds
- movl %ax,%es
- MOVL_KPSEL_EAX
- movl %ax,%fs
- movl $2,TF_ERR(%esp) /* sizeof "int 0x80" */
- FAKE_MCOUNT(13*4(%esp))
- MPLOCKED incl _cnt+V_SYSCALL
- ALTSYSCALL_LOCK
- call _syscall
-
- /*
- * Return via _doreti to handle ASTs.
- */
- pushl $0 /* cpl to restore */
- subl $4,%esp /* dummy unit to finish intr frame */
- movb $1,_intr_nesting_level
- MEXITCOUNT
- jmp _doreti
-
-ENTRY(fork_trampoline)
- call _spl0
-
-#ifdef SMP
- cmpl $0,_switchtime
- jne 1f
- movl $gd_switchtime,%eax
- addl %fs:0,%eax
- pushl %eax
- call _microuptime
- popl %edx
- movl _ticks,%eax
- movl %eax,_switchticks
-1:
-#endif
-
- /*
- * cpu_set_fork_handler intercepts this function call to
- * have this call a non-return function to stay in kernel mode.
- * initproc has its own fork handler, but it does return.
- */
- pushl %ebx /* arg1 */
- call %esi /* function */
- addl $4,%esp
- /* cut from syscall */
-
- /*
- * Return via _doreti to handle ASTs.
- */
- pushl $0 /* cpl to restore */
- subl $4,%esp /* dummy unit to finish intr frame */
- movb $1,_intr_nesting_level
- MEXITCOUNT
- jmp _doreti
-
-
-/*
- * Include vm86 call routines, which want to call _doreti.
- */
-#include "i386/i386/vm86bios.s"
-
-/*
- * Include what was once config+isa-dependent code.
- * XXX it should be in a stand-alone file. It's still icu-dependent and
- * belongs in i386/isa.
- */
-#include "i386/isa/vector.s"
-
-/*
- * Include what was once icu-dependent code.
- * XXX it should be merged into this file (also move the definition of
- * imen to vector.s or isa.c).
- * Before including it, set up a normal asm environment so that vector.s
- * doesn't have to know that stuff is included after it.
- */
- .data
- ALIGN_DATA
- .text
- SUPERALIGN_TEXT
-#include "i386/isa/ipl.s"
diff --git a/sys/amd64/amd64/fpu.c b/sys/amd64/amd64/fpu.c
deleted file mode 100644
index 30914d017355..000000000000
--- a/sys/amd64/amd64/fpu.c
+++ /dev/null
@@ -1,928 +0,0 @@
-/*-
- * Copyright (c) 1990 William Jolitz.
- * 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. 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, Berkeley and its contributors.
- * 4. 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: @(#)npx.c 7.2 (Berkeley) 5/12/91
- * $FreeBSD$
- */
-
-#include "opt_debug_npx.h"
-#include "opt_math_emulate.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/kernel.h>
-#include <sys/malloc.h>
-#include <sys/module.h>
-#include <sys/sysctl.h>
-#include <sys/proc.h>
-#include <machine/bus.h>
-#include <sys/rman.h>
-#ifdef NPX_DEBUG
-#include <sys/syslog.h>
-#endif
-#include <sys/signalvar.h>
-
-#ifndef SMP
-#include <machine/asmacros.h>
-#endif
-#include <machine/cputypes.h>
-#include <machine/frame.h>
-#include <machine/ipl.h>
-#include <machine/md_var.h>
-#include <machine/pcb.h>
-#include <machine/psl.h>
-#ifndef SMP
-#include <machine/clock.h>
-#endif
-#include <machine/resource.h>
-#include <machine/specialreg.h>
-#include <machine/segments.h>
-
-#ifndef SMP
-#include <i386/isa/icu.h>
-#include <i386/isa/intr_machdep.h>
-#include <i386/isa/isa.h>
-#endif
-
-/*
- * 387 and 287 Numeric Coprocessor Extension (NPX) Driver.
- */
-
-/* Configuration flags. */
-#define NPX_DISABLE_I586_OPTIMIZED_BCOPY (1 << 0)
-#define NPX_DISABLE_I586_OPTIMIZED_BZERO (1 << 1)
-#define NPX_DISABLE_I586_OPTIMIZED_COPYIO (1 << 2)
-#define NPX_PREFER_EMULATOR (1 << 3)
-
-#ifdef __GNUC__
-
-#define fldcw(addr) __asm("fldcw %0" : : "m" (*(addr)))
-#define fnclex() __asm("fnclex")
-#define fninit() __asm("fninit")
-#define fnop() __asm("fnop")
-#define fnsave(addr) __asm __volatile("fnsave %0" : "=m" (*(addr)))
-#define fnstcw(addr) __asm __volatile("fnstcw %0" : "=m" (*(addr)))
-#define fnstsw(addr) __asm __volatile("fnstsw %0" : "=m" (*(addr)))
-#define fp_divide_by_0() __asm("fldz; fld1; fdiv %st,%st(1); fnop")
-#define frstor(addr) __asm("frstor %0" : : "m" (*(addr)))
-#define start_emulating() __asm("smsw %%ax; orb %0,%%al; lmsw %%ax" \
- : : "n" (CR0_TS) : "ax")
-#define stop_emulating() __asm("clts")
-
-#else /* not __GNUC__ */
-
-void fldcw __P((caddr_t addr));
-void fnclex __P((void));
-void fninit __P((void));
-void fnop __P((void));
-void fnsave __P((caddr_t addr));
-void fnstcw __P((caddr_t addr));
-void fnstsw __P((caddr_t addr));
-void fp_divide_by_0 __P((void));
-void frstor __P((caddr_t addr));
-void start_emulating __P((void));
-void stop_emulating __P((void));
-
-#endif /* __GNUC__ */
-
-typedef u_char bool_t;
-
-static int npx_attach __P((device_t dev));
- void npx_intr __P((void *));
-static void npx_identify __P((driver_t *driver, device_t parent));
-static int npx_probe __P((device_t dev));
-static int npx_probe1 __P((device_t dev));
-#ifdef I586_CPU
-static long timezero __P((const char *funcname,
- void (*func)(void *buf, size_t len)));
-#endif /* I586_CPU */
-
-int hw_float; /* XXX currently just alias for npx_exists */
-
-SYSCTL_INT(_hw,HW_FLOATINGPT, floatingpoint,
- CTLFLAG_RD, &hw_float, 0,
- "Floatingpoint instructions executed in hardware");
-
-#ifndef SMP
-static u_int npx0_imask = SWI_CLOCK_MASK;
-static struct gate_descriptor npx_idt_probeintr;
-static int npx_intrno;
-static volatile u_int npx_intrs_while_probing;
-static volatile u_int npx_traps_while_probing;
-#endif
-
-static bool_t npx_ex16;
-static bool_t npx_exists;
-static bool_t npx_irq13;
-static int npx_irq; /* irq number */
-
-#ifndef SMP
-/*
- * Special interrupt handlers. Someday intr0-intr15 will be used to count
- * interrupts. We'll still need a special exception 16 handler. The busy
- * latch stuff in probeintr() can be moved to npxprobe().
- */
-inthand_t probeintr;
-__asm(" \n\
- .text \n\
- .p2align 2,0x90 \n\
- .type " __XSTRING(CNAME(probeintr)) ",@function \n\
-" __XSTRING(CNAME(probeintr)) ": \n\
- ss \n\
- incl " __XSTRING(CNAME(npx_intrs_while_probing)) " \n\
- pushl %eax \n\
- movb $0x20,%al # EOI (asm in strings loses cpp features) \n\
- outb %al,$0xa0 # IO_ICU2 \n\
- outb %al,$0x20 # IO_ICU1 \n\
- movb $0,%al \n\
- outb %al,$0xf0 # clear BUSY# latch \n\
- popl %eax \n\
- iret \n\
-");
-
-inthand_t probetrap;
-__asm(" \n\
- .text \n\
- .p2align 2,0x90 \n\
- .type " __XSTRING(CNAME(probetrap)) ",@function \n\
-" __XSTRING(CNAME(probetrap)) ": \n\
- ss \n\
- incl " __XSTRING(CNAME(npx_traps_while_probing)) " \n\
- fnclex \n\
- iret \n\
-");
-#endif /* SMP */
-
-/*
- * Identify routine. Create a connection point on our parent for probing.
- */
-static void
-npx_identify(driver, parent)
- driver_t *driver;
- device_t parent;
-{
- device_t child;
-
- child = BUS_ADD_CHILD(parent, 0, "npx", 0);
- if (child == NULL)
- panic("npx_identify");
-}
-
-/*
- * Probe routine. Initialize cr0 to give correct behaviour for [f]wait
- * whether the device exists or not (XXX should be elsewhere). Set flags
- * to tell npxattach() what to do. Modify device struct if npx doesn't
- * need to use interrupts. Return 1 if device exists.
- */
-static int
-npx_probe(dev)
- device_t dev;
-{
-#ifdef SMP
-
- if (resource_int_value("npx", 0, "irq", &npx_irq) != 0)
- npx_irq = 13;
- return npx_probe1(dev);
-
-#else /* SMP */
-
- int result;
- u_long save_eflags;
- u_char save_icu1_mask;
- u_char save_icu2_mask;
- struct gate_descriptor save_idt_npxintr;
- struct gate_descriptor save_idt_npxtrap;
- /*
- * This routine is now just a wrapper for npxprobe1(), to install
- * special npx interrupt and trap handlers, to enable npx interrupts
- * and to disable other interrupts. Someday isa_configure() will
- * install suitable handlers and run with interrupts enabled so we
- * won't need to do so much here.
- */
- if (resource_int_value("npx", 0, "irq", &npx_irq) != 0)
- npx_irq = 13;
- npx_intrno = NRSVIDT + npx_irq;
- save_eflags = read_eflags();
- disable_intr();
- save_icu1_mask = inb(IO_ICU1 + 1);
- save_icu2_mask = inb(IO_ICU2 + 1);
- save_idt_npxintr = idt[npx_intrno];
- save_idt_npxtrap = idt[16];
- outb(IO_ICU1 + 1, ~IRQ_SLAVE);
- outb(IO_ICU2 + 1, ~(1 << (npx_irq - 8)));
- setidt(16, probetrap, SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(npx_intrno, probeintr, SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- npx_idt_probeintr = idt[npx_intrno];
- enable_intr();
- result = npx_probe1(dev);
- disable_intr();
- outb(IO_ICU1 + 1, save_icu1_mask);
- outb(IO_ICU2 + 1, save_icu2_mask);
- idt[npx_intrno] = save_idt_npxintr;
- idt[16] = save_idt_npxtrap;
- write_eflags(save_eflags);
- return (result);
-
-#endif /* SMP */
-}
-
-static int
-npx_probe1(dev)
- device_t dev;
-{
-#ifndef SMP
- u_short control;
- u_short status;
-#endif
-
- /*
- * Partially reset the coprocessor, if any. Some BIOS's don't reset
- * it after a warm boot.
- */
- outb(0xf1, 0); /* full reset on some systems, NOP on others */
- outb(0xf0, 0); /* clear BUSY# latch */
- /*
- * Prepare to trap all ESC (i.e., NPX) instructions and all WAIT
- * instructions. We must set the CR0_MP bit and use the CR0_TS
- * bit to control the trap, because setting the CR0_EM bit does
- * not cause WAIT instructions to trap. It's important to trap
- * WAIT instructions - otherwise the "wait" variants of no-wait
- * control instructions would degenerate to the "no-wait" variants
- * after FP context switches but work correctly otherwise. It's
- * particularly important to trap WAITs when there is no NPX -
- * otherwise the "wait" variants would always degenerate.
- *
- * Try setting CR0_NE to get correct error reporting on 486DX's.
- * Setting it should fail or do nothing on lesser processors.
- */
- load_cr0(rcr0() | CR0_MP | CR0_NE);
- /*
- * But don't trap while we're probing.
- */
- stop_emulating();
- /*
- * Finish resetting the coprocessor, if any. If there is an error
- * pending, then we may get a bogus IRQ13, but probeintr() will handle
- * it OK. Bogus halts have never been observed, but we enabled
- * IRQ13 and cleared the BUSY# latch early to handle them anyway.
- */
- fninit();
-
-#ifdef SMP
- /*
- * Exception 16 MUST work for SMP.
- */
- npx_irq13 = 0;
- npx_ex16 = hw_float = npx_exists = 1;
- device_set_desc(dev, "math processor");
- return (0);
-
-#else /* !SMP */
- device_set_desc(dev, "math processor");
-
- /*
- * Don't use fwait here because it might hang.
- * Don't use fnop here because it usually hangs if there is no FPU.
- */
- DELAY(1000); /* wait for any IRQ13 */
-#ifdef DIAGNOSTIC
- if (npx_intrs_while_probing != 0)
- printf("fninit caused %u bogus npx interrupt(s)\n",
- npx_intrs_while_probing);
- if (npx_traps_while_probing != 0)
- printf("fninit caused %u bogus npx trap(s)\n",
- npx_traps_while_probing);
-#endif
- /*
- * Check for a status of mostly zero.
- */
- status = 0x5a5a;
- fnstsw(&status);
- if ((status & 0xb8ff) == 0) {
- /*
- * Good, now check for a proper control word.
- */
- control = 0x5a5a;
- fnstcw(&control);
- if ((control & 0x1f3f) == 0x033f) {
- hw_float = npx_exists = 1;
- /*
- * We have an npx, now divide by 0 to see if exception
- * 16 works.
- */
- control &= ~(1 << 2); /* enable divide by 0 trap */
- fldcw(&control);
- npx_traps_while_probing = npx_intrs_while_probing = 0;
- fp_divide_by_0();
- if (npx_traps_while_probing != 0) {
- /*
- * Good, exception 16 works.
- */
- npx_ex16 = 1;
- return (0);
- }
- if (npx_intrs_while_probing != 0) {
- int rid;
- struct resource *r;
- void *intr;
- /*
- * Bad, we are stuck with IRQ13.
- */
- npx_irq13 = 1;
- /*
- * npxattach would be too late to set npx0_imask
- */
- npx0_imask |= (1 << npx_irq);
-
- /*
- * We allocate these resources permanently,
- * so there is no need to keep track of them.
- */
- rid = 0;
- r = bus_alloc_resource(dev, SYS_RES_IOPORT,
- &rid, IO_NPX, IO_NPX,
- IO_NPXSIZE, RF_ACTIVE);
- if (r == 0)
- panic("npx: can't get ports");
- rid = 0;
- r = bus_alloc_resource(dev, SYS_RES_IRQ,
- &rid, npx_irq, npx_irq,
- 1, RF_ACTIVE);
- if (r == 0)
- panic("npx: can't get IRQ");
- BUS_SETUP_INTR(device_get_parent(dev),
- dev, r, INTR_TYPE_MISC,
- npx_intr, 0, &intr);
- if (intr == 0)
- panic("npx: can't create intr");
-
- return (0);
- }
- /*
- * Worse, even IRQ13 is broken. Use emulator.
- */
- }
- }
- /*
- * Probe failed, but we want to get to npxattach to initialize the
- * emulator and say that it has been installed. XXX handle devices
- * that aren't really devices better.
- */
- return (0);
-#endif /* SMP */
-}
-
-/*
- * Attach routine - announce which it is, and wire into system
- */
-int
-npx_attach(dev)
- device_t dev;
-{
- int flags;
-
- if (resource_int_value("npx", 0, "flags", &flags) != 0)
- flags = 0;
-
- if (flags)
- device_printf(dev, "flags 0x%x ", flags);
- if (npx_irq13) {
- device_printf(dev, "using IRQ 13 interface\n");
- } else {
-#if defined(MATH_EMULATE) || defined(GPL_MATH_EMULATE)
- if (npx_ex16) {
- if (!(flags & NPX_PREFER_EMULATOR))
- device_printf(dev, "INT 16 interface\n");
- else {
- device_printf(dev, "FPU exists, but flags request "
- "emulator\n");
- hw_float = npx_exists = 0;
- }
- } else if (npx_exists) {
- device_printf(dev, "error reporting broken; using 387 emulator\n");
- hw_float = npx_exists = 0;
- } else
- device_printf(dev, "387 emulator\n");
-#else
- if (npx_ex16) {
- device_printf(dev, "INT 16 interface\n");
- if (flags & NPX_PREFER_EMULATOR) {
- device_printf(dev, "emulator requested, but none compiled "
- "into kernel, using FPU\n");
- }
- } else
- device_printf(dev, "no 387 emulator in kernel and no FPU!\n");
-#endif
- }
- npxinit(__INITIAL_NPXCW__);
-
-#ifdef I586_CPU
- if (cpu_class == CPUCLASS_586 && npx_ex16 && npx_exists &&
- timezero("i586_bzero()", i586_bzero) <
- timezero("bzero()", bzero) * 4 / 5) {
- if (!(flags & NPX_DISABLE_I586_OPTIMIZED_BCOPY)) {
- bcopy_vector = i586_bcopy;
- ovbcopy_vector = i586_bcopy;
- }
- if (!(flags & NPX_DISABLE_I586_OPTIMIZED_BZERO))
- bzero = i586_bzero;
- if (!(flags & NPX_DISABLE_I586_OPTIMIZED_COPYIO)) {
- copyin_vector = i586_copyin;
- copyout_vector = i586_copyout;
- }
- }
-#endif
-
- return (0); /* XXX unused */
-}
-
-/*
- * Initialize floating point unit.
- */
-void
-npxinit(control)
- u_short control;
-{
- struct save87 dummy;
-
- if (!npx_exists)
- return;
- /*
- * fninit has the same h/w bugs as fnsave. Use the detoxified
- * fnsave to throw away any junk in the fpu. npxsave() initializes
- * the fpu and sets npxproc = NULL as important side effects.
- */
- npxsave(&dummy);
- stop_emulating();
- fldcw(&control);
- if (curpcb != NULL)
- fnsave(&curpcb->pcb_savefpu);
- start_emulating();
-}
-
-/*
- * Free coprocessor (if we have it).
- */
-void
-npxexit(p)
- struct proc *p;
-{
-
- if (p == npxproc)
- npxsave(&curpcb->pcb_savefpu);
-#ifdef NPX_DEBUG
- if (npx_exists) {
- u_int masked_exceptions;
-
- masked_exceptions = curpcb->pcb_savefpu.sv_env.en_cw
- & curpcb->pcb_savefpu.sv_env.en_sw & 0x7f;
- /*
- * Log exceptions that would have trapped with the old
- * control word (overflow, divide by 0, and invalid operand).
- */
- if (masked_exceptions & 0x0d)
- log(LOG_ERR,
- "pid %d (%s) exited with masked floating point exceptions 0x%02x\n",
- p->p_pid, p->p_comm, masked_exceptions);
- }
-#endif
-}
-
-/*
- * The following mechanism is used to ensure that the FPE_... value
- * that is passed as a trapcode to the signal handler of the user
- * process does not have more than one bit set.
- *
- * Multiple bits may be set if the user process modifies the control
- * word while a status word bit is already set. While this is a sign
- * of bad coding, we have no choise than to narrow them down to one
- * bit, since we must not send a trapcode that is not exactly one of
- * the FPE_ macros.
- *
- * The mechanism has a static table with 127 entries. Each combination
- * of the 7 FPU status word exception bits directly translates to a
- * position in this table, where a single FPE_... value is stored.
- * This FPE_... value stored there is considered the "most important"
- * of the exception bits and will be sent as the signal code. The
- * precedence of the bits is based upon Intel Document "Numerical
- * Applications", Chapter "Special Computational Situations".
- *
- * The macro to choose one of these values does these steps: 1) Throw
- * away status word bits that cannot be masked. 2) Throw away the bits
- * currently masked in the control word, assuming the user isn't
- * interested in them anymore. 3) Reinsert status word bit 7 (stack
- * fault) if it is set, which cannot be masked but must be presered.
- * 4) Use the remaining bits to point into the trapcode table.
- *
- * The 6 maskable bits in order of their preference, as stated in the
- * above referenced Intel manual:
- * 1 Invalid operation (FP_X_INV)
- * 1a Stack underflow
- * 1b Stack overflow
- * 1c Operand of unsupported format
- * 1d SNaN operand.
- * 2 QNaN operand (not an exception, irrelavant here)
- * 3 Any other invalid-operation not mentioned above or zero divide
- * (FP_X_INV, FP_X_DZ)
- * 4 Denormal operand (FP_X_DNML)
- * 5 Numeric over/underflow (FP_X_OFL, FP_X_UFL)
- * 6 Inexact result (FP_X_IMP)
- */
-static char fpetable[128] = {
- 0,
- FPE_FLTINV, /* 1 - INV */
- FPE_FLTUND, /* 2 - DNML */
- FPE_FLTINV, /* 3 - INV | DNML */
- FPE_FLTDIV, /* 4 - DZ */
- FPE_FLTINV, /* 5 - INV | DZ */
- FPE_FLTDIV, /* 6 - DNML | DZ */
- FPE_FLTINV, /* 7 - INV | DNML | DZ */
- FPE_FLTOVF, /* 8 - OFL */
- FPE_FLTINV, /* 9 - INV | OFL */
- FPE_FLTUND, /* A - DNML | OFL */
- FPE_FLTINV, /* B - INV | DNML | OFL */
- FPE_FLTDIV, /* C - DZ | OFL */
- FPE_FLTINV, /* D - INV | DZ | OFL */
- FPE_FLTDIV, /* E - DNML | DZ | OFL */
- FPE_FLTINV, /* F - INV | DNML | DZ | OFL */
- FPE_FLTUND, /* 10 - UFL */
- FPE_FLTINV, /* 11 - INV | UFL */
- FPE_FLTUND, /* 12 - DNML | UFL */
- FPE_FLTINV, /* 13 - INV | DNML | UFL */
- FPE_FLTDIV, /* 14 - DZ | UFL */
- FPE_FLTINV, /* 15 - INV | DZ | UFL */
- FPE_FLTDIV, /* 16 - DNML | DZ | UFL */
- FPE_FLTINV, /* 17 - INV | DNML | DZ | UFL */
- FPE_FLTOVF, /* 18 - OFL | UFL */
- FPE_FLTINV, /* 19 - INV | OFL | UFL */
- FPE_FLTUND, /* 1A - DNML | OFL | UFL */
- FPE_FLTINV, /* 1B - INV | DNML | OFL | UFL */
- FPE_FLTDIV, /* 1C - DZ | OFL | UFL */
- FPE_FLTINV, /* 1D - INV | DZ | OFL | UFL */
- FPE_FLTDIV, /* 1E - DNML | DZ | OFL | UFL */
- FPE_FLTINV, /* 1F - INV | DNML | DZ | OFL | UFL */
- FPE_FLTRES, /* 20 - IMP */
- FPE_FLTINV, /* 21 - INV | IMP */
- FPE_FLTUND, /* 22 - DNML | IMP */
- FPE_FLTINV, /* 23 - INV | DNML | IMP */
- FPE_FLTDIV, /* 24 - DZ | IMP */
- FPE_FLTINV, /* 25 - INV | DZ | IMP */
- FPE_FLTDIV, /* 26 - DNML | DZ | IMP */
- FPE_FLTINV, /* 27 - INV | DNML | DZ | IMP */
- FPE_FLTOVF, /* 28 - OFL | IMP */
- FPE_FLTINV, /* 29 - INV | OFL | IMP */
- FPE_FLTUND, /* 2A - DNML | OFL | IMP */
- FPE_FLTINV, /* 2B - INV | DNML | OFL | IMP */
- FPE_FLTDIV, /* 2C - DZ | OFL | IMP */
- FPE_FLTINV, /* 2D - INV | DZ | OFL | IMP */
- FPE_FLTDIV, /* 2E - DNML | DZ | OFL | IMP */
- FPE_FLTINV, /* 2F - INV | DNML | DZ | OFL | IMP */
- FPE_FLTUND, /* 30 - UFL | IMP */
- FPE_FLTINV, /* 31 - INV | UFL | IMP */
- FPE_FLTUND, /* 32 - DNML | UFL | IMP */
- FPE_FLTINV, /* 33 - INV | DNML | UFL | IMP */
- FPE_FLTDIV, /* 34 - DZ | UFL | IMP */
- FPE_FLTINV, /* 35 - INV | DZ | UFL | IMP */
- FPE_FLTDIV, /* 36 - DNML | DZ | UFL | IMP */
- FPE_FLTINV, /* 37 - INV | DNML | DZ | UFL | IMP */
- FPE_FLTOVF, /* 38 - OFL | UFL | IMP */
- FPE_FLTINV, /* 39 - INV | OFL | UFL | IMP */
- FPE_FLTUND, /* 3A - DNML | OFL | UFL | IMP */
- FPE_FLTINV, /* 3B - INV | DNML | OFL | UFL | IMP */
- FPE_FLTDIV, /* 3C - DZ | OFL | UFL | IMP */
- FPE_FLTINV, /* 3D - INV | DZ | OFL | UFL | IMP */
- FPE_FLTDIV, /* 3E - DNML | DZ | OFL | UFL | IMP */
- FPE_FLTINV, /* 3F - INV | DNML | DZ | OFL | UFL | IMP */
- FPE_FLTSUB, /* 40 - STK */
- FPE_FLTSUB, /* 41 - INV | STK */
- FPE_FLTUND, /* 42 - DNML | STK */
- FPE_FLTSUB, /* 43 - INV | DNML | STK */
- FPE_FLTDIV, /* 44 - DZ | STK */
- FPE_FLTSUB, /* 45 - INV | DZ | STK */
- FPE_FLTDIV, /* 46 - DNML | DZ | STK */
- FPE_FLTSUB, /* 47 - INV | DNML | DZ | STK */
- FPE_FLTOVF, /* 48 - OFL | STK */
- FPE_FLTSUB, /* 49 - INV | OFL | STK */
- FPE_FLTUND, /* 4A - DNML | OFL | STK */
- FPE_FLTSUB, /* 4B - INV | DNML | OFL | STK */
- FPE_FLTDIV, /* 4C - DZ | OFL | STK */
- FPE_FLTSUB, /* 4D - INV | DZ | OFL | STK */
- FPE_FLTDIV, /* 4E - DNML | DZ | OFL | STK */
- FPE_FLTSUB, /* 4F - INV | DNML | DZ | OFL | STK */
- FPE_FLTUND, /* 50 - UFL | STK */
- FPE_FLTSUB, /* 51 - INV | UFL | STK */
- FPE_FLTUND, /* 52 - DNML | UFL | STK */
- FPE_FLTSUB, /* 53 - INV | DNML | UFL | STK */
- FPE_FLTDIV, /* 54 - DZ | UFL | STK */
- FPE_FLTSUB, /* 55 - INV | DZ | UFL | STK */
- FPE_FLTDIV, /* 56 - DNML | DZ | UFL | STK */
- FPE_FLTSUB, /* 57 - INV | DNML | DZ | UFL | STK */
- FPE_FLTOVF, /* 58 - OFL | UFL | STK */
- FPE_FLTSUB, /* 59 - INV | OFL | UFL | STK */
- FPE_FLTUND, /* 5A - DNML | OFL | UFL | STK */
- FPE_FLTSUB, /* 5B - INV | DNML | OFL | UFL | STK */
- FPE_FLTDIV, /* 5C - DZ | OFL | UFL | STK */
- FPE_FLTSUB, /* 5D - INV | DZ | OFL | UFL | STK */
- FPE_FLTDIV, /* 5E - DNML | DZ | OFL | UFL | STK */
- FPE_FLTSUB, /* 5F - INV | DNML | DZ | OFL | UFL | STK */
- FPE_FLTRES, /* 60 - IMP | STK */
- FPE_FLTSUB, /* 61 - INV | IMP | STK */
- FPE_FLTUND, /* 62 - DNML | IMP | STK */
- FPE_FLTSUB, /* 63 - INV | DNML | IMP | STK */
- FPE_FLTDIV, /* 64 - DZ | IMP | STK */
- FPE_FLTSUB, /* 65 - INV | DZ | IMP | STK */
- FPE_FLTDIV, /* 66 - DNML | DZ | IMP | STK */
- FPE_FLTSUB, /* 67 - INV | DNML | DZ | IMP | STK */
- FPE_FLTOVF, /* 68 - OFL | IMP | STK */
- FPE_FLTSUB, /* 69 - INV | OFL | IMP | STK */
- FPE_FLTUND, /* 6A - DNML | OFL | IMP | STK */
- FPE_FLTSUB, /* 6B - INV | DNML | OFL | IMP | STK */
- FPE_FLTDIV, /* 6C - DZ | OFL | IMP | STK */
- FPE_FLTSUB, /* 6D - INV | DZ | OFL | IMP | STK */
- FPE_FLTDIV, /* 6E - DNML | DZ | OFL | IMP | STK */
- FPE_FLTSUB, /* 6F - INV | DNML | DZ | OFL | IMP | STK */
- FPE_FLTUND, /* 70 - UFL | IMP | STK */
- FPE_FLTSUB, /* 71 - INV | UFL | IMP | STK */
- FPE_FLTUND, /* 72 - DNML | UFL | IMP | STK */
- FPE_FLTSUB, /* 73 - INV | DNML | UFL | IMP | STK */
- FPE_FLTDIV, /* 74 - DZ | UFL | IMP | STK */
- FPE_FLTSUB, /* 75 - INV | DZ | UFL | IMP | STK */
- FPE_FLTDIV, /* 76 - DNML | DZ | UFL | IMP | STK */
- FPE_FLTSUB, /* 77 - INV | DNML | DZ | UFL | IMP | STK */
- FPE_FLTOVF, /* 78 - OFL | UFL | IMP | STK */
- FPE_FLTSUB, /* 79 - INV | OFL | UFL | IMP | STK */
- FPE_FLTUND, /* 7A - DNML | OFL | UFL | IMP | STK */
- FPE_FLTSUB, /* 7B - INV | DNML | OFL | UFL | IMP | STK */
- FPE_FLTDIV, /* 7C - DZ | OFL | UFL | IMP | STK */
- FPE_FLTSUB, /* 7D - INV | DZ | OFL | UFL | IMP | STK */
- FPE_FLTDIV, /* 7E - DNML | DZ | OFL | UFL | IMP | STK */
- FPE_FLTSUB, /* 7F - INV | DNML | DZ | OFL | UFL | IMP | STK */
-};
-
-/*
- * Preserve the FP status word, clear FP exceptions, then generate a SIGFPE.
- *
- * Clearing exceptions is necessary mainly to avoid IRQ13 bugs. We now
- * depend on longjmp() restoring a usable state. Restoring the state
- * or examining it might fail if we didn't clear exceptions.
- *
- * The error code chosen will be one of the FPE_... macros. It will be
- * sent as the second argument to old BSD-style signal handlers and as
- * "siginfo_t->si_code" (second argument) to SA_SIGINFO signal handlers.
- *
- * XXX the FP state is not preserved across signal handlers. So signal
- * handlers cannot afford to do FP unless they preserve the state or
- * longjmp() out. Both preserving the state and longjmp()ing may be
- * destroyed by IRQ13 bugs. Clearing FP exceptions is not an acceptable
- * solution for signals other than SIGFPE.
- */
-void
-npx_intr(dummy)
- void *dummy;
-{
- int code;
- u_short control;
- struct intrframe *frame;
-
- if (npxproc == NULL || !npx_exists) {
- printf("npxintr: npxproc = %p, curproc = %p, npx_exists = %d\n",
- npxproc, curproc, npx_exists);
- panic("npxintr from nowhere");
- }
- if (npxproc != curproc) {
- printf("npxintr: npxproc = %p, curproc = %p, npx_exists = %d\n",
- npxproc, curproc, npx_exists);
- panic("npxintr from non-current process");
- }
-
- outb(0xf0, 0);
- fnstsw(&curpcb->pcb_savefpu.sv_ex_sw);
- fnstcw(&control);
- fnclex();
-
- /*
- * Pass exception to process.
- */
- frame = (struct intrframe *)&dummy; /* XXX */
- if ((ISPL(frame->if_cs) == SEL_UPL) || (frame->if_eflags & PSL_VM)) {
- /*
- * Interrupt is essentially a trap, so we can afford to call
- * the SIGFPE handler (if any) as soon as the interrupt
- * returns.
- *
- * XXX little or nothing is gained from this, and plenty is
- * lost - the interrupt frame has to contain the trap frame
- * (this is otherwise only necessary for the rescheduling trap
- * in doreti, and the frame for that could easily be set up
- * just before it is used).
- */
- curproc->p_md.md_regs = INTR_TO_TRAPFRAME(frame);
- /*
- * Encode the appropriate code for detailed information on
- * this exception.
- */
- code =
- fpetable[(curpcb->pcb_savefpu.sv_ex_sw & ~control & 0x3f) |
- (curpcb->pcb_savefpu.sv_ex_sw & 0x40)];
- trapsignal(curproc, SIGFPE, code);
- } else {
- /*
- * Nested interrupt. These losers occur when:
- * o an IRQ13 is bogusly generated at a bogus time, e.g.:
- * o immediately after an fnsave or frstor of an
- * error state.
- * o a couple of 386 instructions after
- * "fstpl _memvar" causes a stack overflow.
- * These are especially nasty when combined with a
- * trace trap.
- * o an IRQ13 occurs at the same time as another higher-
- * priority interrupt.
- *
- * Treat them like a true async interrupt.
- */
- psignal(curproc, SIGFPE);
- }
-}
-
-/*
- * Implement device not available (DNA) exception
- *
- * It would be better to switch FP context here (if curproc != npxproc)
- * and not necessarily for every context switch, but it is too hard to
- * access foreign pcb's.
- */
-int
-npxdna()
-{
- if (!npx_exists)
- return (0);
- if (npxproc != NULL) {
- printf("npxdna: npxproc = %p, curproc = %p\n",
- npxproc, curproc);
- panic("npxdna");
- }
- stop_emulating();
- /*
- * Record new context early in case frstor causes an IRQ13.
- */
- npxproc = curproc;
- curpcb->pcb_savefpu.sv_ex_sw = 0;
- /*
- * The following frstor may cause an IRQ13 when the state being
- * restored has a pending error. The error will appear to have been
- * triggered by the current (npx) user instruction even when that
- * instruction is a no-wait instruction that should not trigger an
- * error (e.g., fnclex). On at least one 486 system all of the
- * no-wait instructions are broken the same as frstor, so our
- * treatment does not amplify the breakage. On at least one
- * 386/Cyrix 387 system, fnclex works correctly while frstor and
- * fnsave are broken, so our treatment breaks fnclex if it is the
- * first FPU instruction after a context switch.
- */
- frstor(&curpcb->pcb_savefpu);
-
- return (1);
-}
-
-/*
- * Wrapper for fnsave instruction to handle h/w bugs. If there is an error
- * pending, then fnsave generates a bogus IRQ13 on some systems. Force
- * any IRQ13 to be handled immediately, and then ignore it. This routine is
- * often called at splhigh so it must not use many system services. In
- * particular, it's much easier to install a special handler than to
- * guarantee that it's safe to use npxintr() and its supporting code.
- */
-void
-npxsave(addr)
- struct save87 *addr;
-{
-#ifdef SMP
-
- stop_emulating();
- fnsave(addr);
- /* fnop(); */
- start_emulating();
- npxproc = NULL;
-
-#else /* SMP */
-
- u_char icu1_mask;
- u_char icu2_mask;
- u_char old_icu1_mask;
- u_char old_icu2_mask;
- struct gate_descriptor save_idt_npxintr;
-
- disable_intr();
- old_icu1_mask = inb(IO_ICU1 + 1);
- old_icu2_mask = inb(IO_ICU2 + 1);
- save_idt_npxintr = idt[npx_intrno];
- outb(IO_ICU1 + 1, old_icu1_mask & ~(IRQ_SLAVE | npx0_imask));
- outb(IO_ICU2 + 1, old_icu2_mask & ~(npx0_imask >> 8));
- idt[npx_intrno] = npx_idt_probeintr;
- enable_intr();
- stop_emulating();
- fnsave(addr);
- fnop();
- start_emulating();
- npxproc = NULL;
- disable_intr();
- icu1_mask = inb(IO_ICU1 + 1); /* masks may have changed */
- icu2_mask = inb(IO_ICU2 + 1);
- outb(IO_ICU1 + 1,
- (icu1_mask & ~npx0_imask) | (old_icu1_mask & npx0_imask));
- outb(IO_ICU2 + 1,
- (icu2_mask & ~(npx0_imask >> 8))
- | (old_icu2_mask & (npx0_imask >> 8)));
- idt[npx_intrno] = save_idt_npxintr;
- enable_intr(); /* back to usual state */
-
-#endif /* SMP */
-}
-
-#ifdef I586_CPU
-static long
-timezero(funcname, func)
- const char *funcname;
- void (*func) __P((void *buf, size_t len));
-
-{
- void *buf;
-#define BUFSIZE 1000000
- long usec;
- struct timeval finish, start;
-
- buf = malloc(BUFSIZE, M_TEMP, M_NOWAIT);
- if (buf == NULL)
- return (BUFSIZE);
- microtime(&start);
- (*func)(buf, BUFSIZE);
- microtime(&finish);
- usec = 1000000 * (finish.tv_sec - start.tv_sec) +
- finish.tv_usec - start.tv_usec;
- if (usec <= 0)
- usec = 1;
- if (bootverbose)
- printf("%s bandwidth = %ld bytes/sec\n",
- funcname, (long)(BUFSIZE * (int64_t)1000000 / usec));
- free(buf, M_TEMP);
- return (usec);
-}
-#endif /* I586_CPU */
-
-static device_method_t npx_methods[] = {
- /* Device interface */
- DEVMETHOD(device_identify, npx_identify),
- DEVMETHOD(device_probe, npx_probe),
- DEVMETHOD(device_attach, npx_attach),
- DEVMETHOD(device_detach, bus_generic_detach),
- DEVMETHOD(device_shutdown, bus_generic_shutdown),
- DEVMETHOD(device_suspend, bus_generic_suspend),
- DEVMETHOD(device_resume, bus_generic_resume),
-
- { 0, 0 }
-};
-
-static driver_t npx_driver = {
- "npx",
- npx_methods,
- 1, /* no softc */
-};
-
-static devclass_t npx_devclass;
-
-/*
- * We prefer to attach to the root nexus so that the usual case (exception 16)
- * doesn't describe the processor as being `on isa'.
- */
-DRIVER_MODULE(npx, nexus, npx_driver, npx_devclass, 0, 0);
diff --git a/sys/amd64/amd64/genassym.c b/sys/amd64/amd64/genassym.c
deleted file mode 100644
index 3e843db516bd..000000000000
--- a/sys/amd64/amd64/genassym.c
+++ /dev/null
@@ -1,212 +0,0 @@
-/*-
- * Copyright (c) 1982, 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)genassym.c 5.11 (Berkeley) 5/10/91
- * $FreeBSD$
- */
-
-#include "opt_user_ldt.h"
-
-#include <stddef.h>
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/assym.h>
-#include <sys/buf.h>
-#include <sys/proc.h>
-#include <sys/errno.h>
-#include <sys/mount.h>
-#include <sys/socket.h>
-#include <sys/resourcevar.h>
-#include <machine/frame.h>
-#include <machine/bootinfo.h>
-#include <machine/tss.h>
-#include <sys/vmmeter.h>
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <vm/pmap.h>
-#include <vm/vm_map.h>
-#include <sys/user.h>
-#include <net/if.h>
-#include <netinet/in.h>
-#include <nfs/nfsv2.h>
-#include <nfs/rpcv2.h>
-#include <nfs/nfs.h>
-#include <nfs/nfsdiskless.h>
-#ifdef SMP
-#include <machine/apic.h>
-#endif
-#include <machine/segments.h>
-#include <machine/sigframe.h>
-#include <machine/globaldata.h>
-#include <machine/vm86.h>
-
-ASSYM(P_VMSPACE, offsetof(struct proc, p_vmspace));
-ASSYM(VM_PMAP, offsetof(struct vmspace, vm_pmap));
-ASSYM(PM_ACTIVE, offsetof(struct pmap, pm_active));
-ASSYM(P_ADDR, offsetof(struct proc, p_addr));
-ASSYM(P_STAT, offsetof(struct proc, p_stat));
-ASSYM(P_WCHAN, offsetof(struct proc, p_wchan));
-
-#ifdef SMP
-ASSYM(P_ONCPU, offsetof(struct proc, p_oncpu));
-ASSYM(P_LASTCPU, offsetof(struct proc, p_lastcpu));
-#endif
-
-ASSYM(SSLEEP, SSLEEP);
-ASSYM(SRUN, SRUN);
-ASSYM(V_TRAP, offsetof(struct vmmeter, v_trap));
-ASSYM(V_SYSCALL, offsetof(struct vmmeter, v_syscall));
-ASSYM(V_INTR, offsetof(struct vmmeter, v_intr));
-ASSYM(UPAGES, UPAGES);
-ASSYM(PAGE_SIZE, PAGE_SIZE);
-ASSYM(NPTEPG, NPTEPG);
-ASSYM(NPDEPG, NPDEPG);
-ASSYM(PDESIZE, PDESIZE);
-ASSYM(PTESIZE, PTESIZE);
-ASSYM(PAGE_SHIFT, PAGE_SHIFT);
-ASSYM(PAGE_MASK, PAGE_MASK);
-ASSYM(PDRSHIFT, PDRSHIFT);
-ASSYM(USRSTACK, USRSTACK);
-ASSYM(VM_MAXUSER_ADDRESS, VM_MAXUSER_ADDRESS);
-ASSYM(KERNBASE, KERNBASE);
-ASSYM(MCLBYTES, MCLBYTES);
-ASSYM(PCB_CR3, offsetof(struct pcb, pcb_cr3));
-ASSYM(PCB_EDI, offsetof(struct pcb, pcb_edi));
-ASSYM(PCB_ESI, offsetof(struct pcb, pcb_esi));
-ASSYM(PCB_EBP, offsetof(struct pcb, pcb_ebp));
-ASSYM(PCB_ESP, offsetof(struct pcb, pcb_esp));
-ASSYM(PCB_EBX, offsetof(struct pcb, pcb_ebx));
-ASSYM(PCB_EIP, offsetof(struct pcb, pcb_eip));
-ASSYM(TSS_ESP0, offsetof(struct i386tss, tss_esp0));
-
-#ifdef USER_LDT
-ASSYM(PCB_USERLDT, offsetof(struct pcb, pcb_ldt));
-#endif
-
-ASSYM(PCB_GS, offsetof(struct pcb, pcb_gs));
-ASSYM(PCB_DR0, offsetof(struct pcb, pcb_dr0));
-ASSYM(PCB_DR1, offsetof(struct pcb, pcb_dr1));
-ASSYM(PCB_DR2, offsetof(struct pcb, pcb_dr2));
-ASSYM(PCB_DR3, offsetof(struct pcb, pcb_dr3));
-ASSYM(PCB_DR6, offsetof(struct pcb, pcb_dr6));
-ASSYM(PCB_DR7, offsetof(struct pcb, pcb_dr7));
-ASSYM(PCB_DBREGS, PCB_DBREGS);
-ASSYM(PCB_EXT, offsetof(struct pcb, pcb_ext));
-
-#ifdef SMP
-ASSYM(PCB_MPNEST, offsetof(struct pcb, pcb_mpnest));
-#endif
-
-ASSYM(PCB_SPARE, offsetof(struct pcb, __pcb_spare));
-ASSYM(PCB_FLAGS, offsetof(struct pcb, pcb_flags));
-ASSYM(PCB_SAVEFPU, offsetof(struct pcb, pcb_savefpu));
-ASSYM(PCB_SAVEFPU_SIZE, sizeof(struct save87));
-ASSYM(PCB_ONFAULT, offsetof(struct pcb, pcb_onfault));
-
-#ifdef SMP
-ASSYM(PCB_SIZE, sizeof(struct pcb));
-#endif
-
-ASSYM(TF_TRAPNO, offsetof(struct trapframe, tf_trapno));
-ASSYM(TF_ERR, offsetof(struct trapframe, tf_err));
-ASSYM(TF_CS, offsetof(struct trapframe, tf_cs));
-ASSYM(TF_EFLAGS, offsetof(struct trapframe, tf_eflags));
-ASSYM(SIGF_HANDLER, offsetof(struct sigframe, sf_ahu.sf_handler));
-ASSYM(SIGF_SC, offsetof(struct osigframe, sf_siginfo.si_sc));
-ASSYM(SIGF_UC, offsetof(struct sigframe, sf_uc));
-ASSYM(SC_PS, offsetof(struct osigcontext, sc_ps));
-ASSYM(SC_FS, offsetof(struct osigcontext, sc_fs));
-ASSYM(SC_GS, offsetof(struct osigcontext, sc_gs));
-ASSYM(SC_TRAPNO, offsetof(struct osigcontext, sc_trapno));
-ASSYM(UC_EFLAGS, offsetof(ucontext_t, uc_mcontext.mc_eflags));
-ASSYM(UC_GS, offsetof(ucontext_t, uc_mcontext.mc_gs));
-ASSYM(B_READ, B_READ);
-ASSYM(ENOENT, ENOENT);
-ASSYM(EFAULT, EFAULT);
-ASSYM(ENAMETOOLONG, ENAMETOOLONG);
-ASSYM(MAXPATHLEN, MAXPATHLEN);
-ASSYM(BOOTINFO_SIZE, sizeof(struct bootinfo));
-ASSYM(BI_VERSION, offsetof(struct bootinfo, bi_version));
-ASSYM(BI_KERNELNAME, offsetof(struct bootinfo, bi_kernelname));
-ASSYM(BI_NFS_DISKLESS, offsetof(struct bootinfo, bi_nfs_diskless));
-ASSYM(BI_ENDCOMMON, offsetof(struct bootinfo, bi_endcommon));
-ASSYM(NFSDISKLESS_SIZE, sizeof(struct nfs_diskless));
-ASSYM(BI_SIZE, offsetof(struct bootinfo, bi_size));
-ASSYM(BI_SYMTAB, offsetof(struct bootinfo, bi_symtab));
-ASSYM(BI_ESYMTAB, offsetof(struct bootinfo, bi_esymtab));
-ASSYM(BI_KERNEND, offsetof(struct bootinfo, bi_kernend));
-ASSYM(GD_SIZEOF, sizeof(struct globaldata));
-ASSYM(GD_CURPROC, offsetof(struct globaldata, gd_curproc));
-ASSYM(GD_NPXPROC, offsetof(struct globaldata, gd_npxproc));
-ASSYM(GD_CURPCB, offsetof(struct globaldata, gd_curpcb));
-ASSYM(GD_COMMON_TSS, offsetof(struct globaldata, gd_common_tss));
-ASSYM(GD_SWITCHTIME, offsetof(struct globaldata, gd_switchtime));
-ASSYM(GD_SWITCHTICKS, offsetof(struct globaldata, gd_switchticks));
-ASSYM(GD_COMMON_TSSD, offsetof(struct globaldata, gd_common_tssd));
-ASSYM(GD_TSS_GDT, offsetof(struct globaldata, gd_tss_gdt));
-
-#ifdef USER_LDT
-ASSYM(GD_CURRENTLDT, offsetof(struct globaldata, gd_currentldt));
-#endif
-
-#ifdef SMP
-ASSYM(GD_CPUID, offsetof(struct globaldata, gd_cpuid));
-ASSYM(GD_CPU_LOCKID, offsetof(struct globaldata, gd_cpu_lockid));
-ASSYM(GD_OTHER_CPUS, offsetof(struct globaldata, gd_other_cpus));
-ASSYM(GD_SS_EFLAGS, offsetof(struct globaldata, gd_ss_eflags));
-ASSYM(GD_INSIDE_INTR, offsetof(struct globaldata, gd_inside_intr));
-ASSYM(GD_PRV_CMAP1, offsetof(struct globaldata, gd_prv_CMAP1));
-ASSYM(GD_PRV_CMAP2, offsetof(struct globaldata, gd_prv_CMAP2));
-ASSYM(GD_PRV_CMAP3, offsetof(struct globaldata, gd_prv_CMAP3));
-ASSYM(GD_PRV_PMAP1, offsetof(struct globaldata, gd_prv_PMAP1));
-ASSYM(GD_PRV_CADDR1, offsetof(struct globaldata, gd_prv_CADDR1));
-ASSYM(GD_PRV_CADDR2, offsetof(struct globaldata, gd_prv_CADDR2));
-ASSYM(GD_PRV_CADDR3, offsetof(struct globaldata, gd_prv_CADDR3));
-ASSYM(GD_PRV_PADDR1, offsetof(struct globaldata, gd_prv_PADDR1));
-ASSYM(PS_IDLESTACK, offsetof(struct privatespace, idlestack));
-ASSYM(PS_IDLESTACK_TOP, sizeof(struct privatespace));
-#endif
-
-ASSYM(KCSEL, GSEL(GCODE_SEL, SEL_KPL));
-ASSYM(KDSEL, GSEL(GDATA_SEL, SEL_KPL));
-
-#ifdef SMP
-ASSYM(KPSEL, GSEL(GPRIV_SEL, SEL_KPL));
-#endif
-
-ASSYM(BC32SEL, GSEL(GBIOSCODE32_SEL, SEL_KPL));
-ASSYM(GPROC0_SEL, GPROC0_SEL);
-ASSYM(VM86_FRAMESIZE, sizeof(struct vm86frame));
diff --git a/sys/amd64/amd64/identcpu.c b/sys/amd64/amd64/identcpu.c
deleted file mode 100644
index 8928fc901d02..000000000000
--- a/sys/amd64/amd64/identcpu.c
+++ /dev/null
@@ -1,993 +0,0 @@
-/*
- * Copyright (c) 1992 Terrence R. Lambert.
- * Copyright (c) 1982, 1987, 1990 The Regents of the University of California.
- * Copyright (c) 1997 KATO Takenori.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: Id: machdep.c,v 1.193 1996/06/18 01:22:04 bde Exp
- * $FreeBSD$
- */
-
-#include "opt_cpu.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/sysctl.h>
-
-#include <machine/asmacros.h>
-#include <machine/clock.h>
-#include <machine/cputypes.h>
-#include <machine/segments.h>
-#include <machine/specialreg.h>
-#include <machine/md_var.h>
-
-#include <i386/isa/intr_machdep.h>
-
-#define IDENTBLUE_CYRIX486 0
-#define IDENTBLUE_IBMCPU 1
-#define IDENTBLUE_CYRIXM2 2
-
-/* XXX - should be in header file: */
-void printcpuinfo(void);
-void finishidentcpu(void);
-void earlysetcpuclass(void);
-#if defined(I586_CPU) && defined(CPU_WT_ALLOC)
-void enable_K5_wt_alloc(void);
-void enable_K6_wt_alloc(void);
-void enable_K6_2_wt_alloc(void);
-#endif
-void panicifcpuunsupported(void);
-
-static void identifycyrix(void);
-static void print_AMD_features(u_int *regs);
-static void print_AMD_info(u_int amd_maxregs);
-static void print_AMD_assoc(int i);
-static void do_cpuid(u_int ax, u_int *p);
-
-u_int cyrix_did; /* Device ID of Cyrix CPU */
-int cpu_class = CPUCLASS_386; /* least common denominator */
-char machine[] = "i386";
-SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD,
- machine, 0, "Machine class");
-
-static char cpu_model[128];
-SYSCTL_STRING(_hw, HW_MODEL, model, CTLFLAG_RD,
- cpu_model, 0, "Machine model");
-
-static struct cpu_nameclass i386_cpus[] = {
- { "Intel 80286", CPUCLASS_286 }, /* CPU_286 */
- { "i386SX", CPUCLASS_386 }, /* CPU_386SX */
- { "i386DX", CPUCLASS_386 }, /* CPU_386 */
- { "i486SX", CPUCLASS_486 }, /* CPU_486SX */
- { "i486DX", CPUCLASS_486 }, /* CPU_486 */
- { "Pentium", CPUCLASS_586 }, /* CPU_586 */
- { "Cyrix 486", CPUCLASS_486 }, /* CPU_486DLC */
- { "Pentium Pro", CPUCLASS_686 }, /* CPU_686 */
- { "Cyrix 5x86", CPUCLASS_486 }, /* CPU_M1SC */
- { "Cyrix 6x86", CPUCLASS_486 }, /* CPU_M1 */
- { "Blue Lightning", CPUCLASS_486 }, /* CPU_BLUE */
- { "Cyrix 6x86MX", CPUCLASS_686 }, /* CPU_M2 */
- { "NexGen 586", CPUCLASS_386 }, /* CPU_NX586 (XXX) */
- { "Cyrix 486S/DX", CPUCLASS_486 }, /* CPU_CY486DX */
- { "Pentium II", CPUCLASS_686 }, /* CPU_PII */
- { "Pentium III", CPUCLASS_686 }, /* CPU_PIII */
-};
-
-static void
-do_cpuid(u_int ax, u_int *p)
-{
- __asm __volatile(
- ".byte 0x0f, 0xa2;"
- "movl %%eax, (%2);"
- "movl %%ebx, 4(%2);"
- "movl %%ecx, 8(%2);"
- "movl %%edx, 12(%2);"
- : "=a" (ax)
- : "0" (ax), "S" (p)
- : "bx", "cx", "dx"
- );
-}
-
-#if defined(I586_CPU) && !defined(NO_F00F_HACK)
-int has_f00f_bug = 0;
-#endif
-
-void
-printcpuinfo(void)
-{
-
- u_int regs[4], nreg = 0;
- cpu_class = i386_cpus[cpu].cpu_class;
- printf("CPU: ");
- strncpy(cpu_model, i386_cpus[cpu].cpu_name, sizeof cpu_model);
-
-#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)
- if (strcmp(cpu_vendor,"GenuineIntel") == 0) {
- if ((cpu_id & 0xf00) > 0x300) {
- cpu_model[0] = '\0';
-
- switch (cpu_id & 0x3000) {
- case 0x1000:
- strcpy(cpu_model, "Overdrive ");
- break;
- case 0x2000:
- strcpy(cpu_model, "Dual ");
- break;
- }
-
- switch (cpu_id & 0xf00) {
- case 0x400:
- strcat(cpu_model, "i486 ");
- break;
- case 0x500:
- /* Check the particular flavor of 586 */
- strcat(cpu_model, "Pentium");
- switch (cpu_id & 0xf0) {
- case 0x00:
- strcat(cpu_model, " A-step");
- break;
- case 0x10:
- strcat(cpu_model, "/P5");
- break;
- case 0x20:
- strcat(cpu_model, "/P54C");
- break;
- case 0x30:
- strcat(cpu_model, "/P54T Overdrive");
- break;
- case 0x40:
- strcat(cpu_model, "/P55C");
- break;
- case 0x70:
- strcat(cpu_model, "/P54C");
- break;
- case 0x80:
- strcat(cpu_model, "/P55C (quarter-micron)");
- break;
- default:
- /* nothing */
- break;
- }
-#if defined(I586_CPU) && !defined(NO_F00F_HACK)
- /*
- * XXX - If/when Intel fixes the bug, this
- * should also check the version of the
- * CPU, not just that it's a Pentium.
- */
- has_f00f_bug = 1;
-#endif
- break;
- case 0x600:
- /* Check the particular flavor of 686 */
- switch (cpu_id & 0xf0) {
- case 0x00:
- strcat(cpu_model, "Pentium Pro A-step");
- break;
- case 0x10:
- strcat(cpu_model, "Pentium Pro");
- break;
- case 0x30:
- case 0x50:
- case 0x60:
- strcat(cpu_model,
- "Pentium II/Pentium II Xeon/Celeron");
- cpu = CPU_PII;
- break;
- case 0x70:
- case 0x80:
- strcat(cpu_model,
- "Pentium III/Pentium III Xeon");
- cpu = CPU_PIII;
- break;
- default:
- strcat(cpu_model, "Unknown 80686");
- break;
- }
- break;
- default:
- strcat(cpu_model, "unknown");
- break;
- }
-
- switch (cpu_id & 0xff0) {
- case 0x400:
- strcat(cpu_model, "DX"); break;
- case 0x410:
- strcat(cpu_model, "DX"); break;
- case 0x420:
- strcat(cpu_model, "SX"); break;
- case 0x430:
- strcat(cpu_model, "DX2"); break;
- case 0x440:
- strcat(cpu_model, "SL"); break;
- case 0x450:
- strcat(cpu_model, "SX2"); break;
- case 0x470:
- strcat(cpu_model, "DX2 Write-Back Enhanced");
- break;
- case 0x480:
- strcat(cpu_model, "DX4"); break;
- break;
- }
- }
- } else if (strcmp(cpu_vendor,"AuthenticAMD") == 0) {
- /*
- * Values taken from AMD Processor Recognition
- * http://www.amd.com/K6/k6docs/pdf/20734g.pdf
- * (also describes ``Features'' encodings.
- */
- strcpy(cpu_model, "AMD ");
- switch (cpu_id & 0xFF0) {
- case 0x410:
- strcat(cpu_model, "Standard Am486DX");
- break;
- case 0x430:
- strcat(cpu_model, "Am486DX2/4 Write-Through");
- break;
- case 0x470:
- strcat(cpu_model, "Enhanced Am486DX4 Write-Back");
- break;
- case 0x480:
- strcat(cpu_model, "Enhanced Am486DX4 Write-Through");
- break;
- case 0x490:
- strcat(cpu_model, "Enhanced Am486DX4 Write-Back");
- break;
- case 0x4E0:
- strcat(cpu_model, "Am5x86 Write-Through");
- break;
- case 0x4F0:
- strcat(cpu_model, "Am5x86 Write-Back");
- break;
- case 0x500:
- strcat(cpu_model, "K5 model 0");
- tsc_is_broken = 1;
- break;
- case 0x510:
- strcat(cpu_model, "K5 model 1");
- break;
- case 0x520:
- strcat(cpu_model, "K5 PR166 (model 2)");
- break;
- case 0x530:
- strcat(cpu_model, "K5 PR200 (model 3)");
- break;
- case 0x560:
- strcat(cpu_model, "K6");
- break;
- case 0x570:
- strcat(cpu_model, "K6 266 (model 1)");
- break;
- case 0x580:
- strcat(cpu_model, "K6-2");
- break;
- case 0x590:
- strcat(cpu_model, "K6-III");
- break;
- default:
- strcat(cpu_model, "Unknown");
- break;
- }
-#if defined(I586_CPU) && defined(CPU_WT_ALLOC)
- if ((cpu_id & 0xf00) == 0x500) {
- if (((cpu_id & 0x0f0) > 0)
- && ((cpu_id & 0x0f0) < 0x60)
- && ((cpu_id & 0x00f) > 3))
- enable_K5_wt_alloc();
- else if (((cpu_id & 0x0f0) > 0x80)
- || (((cpu_id & 0x0f0) == 0x80)
- && (cpu_id & 0x00f) > 0x07))
- enable_K6_2_wt_alloc();
- else if ((cpu_id & 0x0f0) > 0x50)
- enable_K6_wt_alloc();
- }
-#endif
- do_cpuid(0x80000000, regs);
- nreg = regs[0];
- if (nreg >= 0x80000004) {
- do_cpuid(0x80000002, regs);
- memcpy(cpu_model, regs, sizeof regs);
- do_cpuid(0x80000003, regs);
- memcpy(cpu_model+16, regs, sizeof regs);
- do_cpuid(0x80000004, regs);
- memcpy(cpu_model+32, regs, sizeof regs);
- }
- } else if (strcmp(cpu_vendor,"CyrixInstead") == 0) {
- strcpy(cpu_model, "Cyrix ");
- switch (cpu_id & 0xff0) {
- case 0x440:
- strcat(cpu_model, "MediaGX");
- break;
- case 0x520:
- strcat(cpu_model, "6x86");
- break;
- case 0x540:
- cpu_class = CPUCLASS_586;
- strcat(cpu_model, "GXm");
- break;
- case 0x600:
- strcat(cpu_model, "6x86MX");
- break;
- default:
- /*
- * Even though CPU supports the cpuid
- * instruction, it can be disabled.
- * Therefore, this routine supports all Cyrix
- * CPUs.
- */
- switch (cyrix_did & 0xf0) {
- case 0x00:
- switch (cyrix_did & 0x0f) {
- case 0x00:
- strcat(cpu_model, "486SLC");
- break;
- case 0x01:
- strcat(cpu_model, "486DLC");
- break;
- case 0x02:
- strcat(cpu_model, "486SLC2");
- break;
- case 0x03:
- strcat(cpu_model, "486DLC2");
- break;
- case 0x04:
- strcat(cpu_model, "486SRx");
- break;
- case 0x05:
- strcat(cpu_model, "486DRx");
- break;
- case 0x06:
- strcat(cpu_model, "486SRx2");
- break;
- case 0x07:
- strcat(cpu_model, "486DRx2");
- break;
- case 0x08:
- strcat(cpu_model, "486SRu");
- break;
- case 0x09:
- strcat(cpu_model, "486DRu");
- break;
- case 0x0a:
- strcat(cpu_model, "486SRu2");
- break;
- case 0x0b:
- strcat(cpu_model, "486DRu2");
- break;
- default:
- strcat(cpu_model, "Unknown");
- break;
- }
- break;
- case 0x10:
- switch (cyrix_did & 0x0f) {
- case 0x00:
- strcat(cpu_model, "486S");
- break;
- case 0x01:
- strcat(cpu_model, "486S2");
- break;
- case 0x02:
- strcat(cpu_model, "486Se");
- break;
- case 0x03:
- strcat(cpu_model, "486S2e");
- break;
- case 0x0a:
- strcat(cpu_model, "486DX");
- break;
- case 0x0b:
- strcat(cpu_model, "486DX2");
- break;
- case 0x0f:
- strcat(cpu_model, "486DX4");
- break;
- default:
- strcat(cpu_model, "Unknown");
- break;
- }
- break;
- case 0x20:
- if ((cyrix_did & 0x0f) < 8)
- strcat(cpu_model, "6x86"); /* Where did you get it? */
- else
- strcat(cpu_model, "5x86");
- break;
- case 0x30:
- strcat(cpu_model, "6x86");
- break;
- case 0x40:
- if ((cyrix_did & 0xf000) == 0x3000) {
- cpu_class = CPUCLASS_586;
- strcat(cpu_model, "GXm");
- } else
- strcat(cpu_model, "MediaGX");
- break;
- case 0x50:
- strcat(cpu_model, "6x86MX");
- break;
- case 0xf0:
- switch (cyrix_did & 0x0f) {
- case 0x0d:
- strcat(cpu_model, "Overdrive CPU");
- case 0x0e:
- strcpy(cpu_model, "Texas Instruments 486SXL");
- break;
- case 0x0f:
- strcat(cpu_model, "486SLC/DLC");
- break;
- default:
- strcat(cpu_model, "Unknown");
- break;
- }
- break;
- default:
- strcat(cpu_model, "Unknown");
- break;
- }
- break;
- }
- } else if (strcmp(cpu_vendor, "RiseRiseRise") == 0) {
- strcpy(cpu_model, "Rise ");
- switch (cpu_id & 0xff0) {
- case 0x500:
- strcat(cpu_model, "mP6");
- break;
- default:
- strcat(cpu_model, "Unknown");
- }
- } else if (strcmp(cpu_vendor, "CentaurHauls") == 0) {
- strcpy(cpu_model, "IDT ");
- switch (cpu_id & 0xff0) {
- case 0x540:
- strcat(cpu_model, "WinChip C6");
- tsc_is_broken = 1;
- break;
- case 0x580:
- strcat(cpu_model, "WinChip 2");
- break;
- default:
- strcat(cpu_model, "Unknown");
- }
- } else if (strcmp(cpu_vendor, "IBM") == 0)
- strcpy(cpu_model, "Blue Lightning CPU");
-#endif
-
- printf("%s (", cpu_model);
- switch(cpu_class) {
- case CPUCLASS_286:
- printf("286");
- break;
-#if defined(I386_CPU)
- case CPUCLASS_386:
- printf("386");
- break;
-#endif
-#if defined(I486_CPU)
- case CPUCLASS_486:
- printf("486");
- bzero = i486_bzero;
- break;
-#endif
-#if defined(I586_CPU)
- case CPUCLASS_586:
- printf("%d.%02d-MHz ",
- (tsc_freq + 4999) / 1000000,
- ((tsc_freq + 4999) / 10000) % 100);
- printf("586");
- break;
-#endif
-#if defined(I686_CPU)
- case CPUCLASS_686:
- printf("%d.%02d-MHz ",
- (tsc_freq + 4999) / 1000000,
- ((tsc_freq + 4999) / 10000) % 100);
- printf("686");
- break;
-#endif
- default:
- printf("unknown"); /* will panic below... */
- }
- printf("-class CPU)\n");
-#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)
- if(*cpu_vendor)
- printf(" Origin = \"%s\"",cpu_vendor);
- if(cpu_id)
- printf(" Id = 0x%x", cpu_id);
-
- if (strcmp(cpu_vendor, "GenuineIntel") == 0 ||
- strcmp(cpu_vendor, "AuthenticAMD") == 0 ||
- strcmp(cpu_vendor, "RiseRiseRise") == 0 ||
- strcmp(cpu_vendor, "CentaurHauls") == 0 ||
- ((strcmp(cpu_vendor, "CyrixInstead") == 0) &&
- ((cpu_id & 0xf00) > 0x500))) {
- printf(" Stepping = %u", cpu_id & 0xf);
- if (strcmp(cpu_vendor, "CyrixInstead") == 0)
- printf(" DIR=0x%04x", cyrix_did);
- if (cpu_high > 0) {
- /*
- * Here we should probably set up flags indicating
- * whether or not various features are available.
- * The interesting ones are probably VME, PSE, PAE,
- * and PGE. The code already assumes without bothering
- * to check that all CPUs >= Pentium have a TSC and
- * MSRs.
- */
- printf("\n Features=0x%b", cpu_feature,
- "\020"
- "\001FPU" /* Integral FPU */
- "\002VME" /* Extended VM86 mode support */
- "\003DE"
- "\004PSE" /* 4MByte page tables */
- "\005TSC" /* Timestamp counter */
- "\006MSR" /* Machine specific registers */
- "\007PAE" /* Physical address extension */
- "\010MCE" /* Machine Check support */
- "\011CX8" /* CMPEXCH8 instruction */
- "\012APIC" /* SMP local APIC */
- "\013oldMTRR"
- "\014SEP"
- "\015MTRR"
- "\016PGE" /* PG_G (global bit) support */
- "\017MCA"
- "\020CMOV" /* CMOV instruction */
- "\021PAT" /* Page attributes table */
- "\022PSE36" /* 36 bit address space support */
- "\023PN" /* Processor Serial number */
- "\024<b19>"
- "\025<b20>"
- "\026<b21>"
- "\027<b22>"
- "\030MMX" /* MMX instructions */
- "\031FXSR" /* FXSAVE/FXRSTOR */
- "\032XMM" /* Katami SIMD/MMX2 instructions */
- "\033<b26>"
- "\034<b27>"
- "\035<b28>"
- "\036<b29>"
- "\037<b30>"
- "\040<b31>"
- );
- }
- if (strcmp(cpu_vendor, "AuthenticAMD") == 0 &&
- nreg >= 0x80000001)
- print_AMD_features(regs);
- } else if (strcmp(cpu_vendor, "CyrixInstead") == 0) {
- printf(" DIR=0x%04x", cyrix_did);
- printf(" Stepping=%u", (cyrix_did & 0xf000) >> 12);
- printf(" Revision=%u", (cyrix_did & 0x0f00) >> 8);
-#ifndef CYRIX_CACHE_REALLY_WORKS
- if (cpu == CPU_M1 && (cyrix_did & 0xff00) < 0x1700)
- printf("\n CPU cache: write-through mode");
-#endif
- }
- /* Avoid ugly blank lines: only print newline when we have to. */
- if (*cpu_vendor || cpu_id)
- printf("\n");
-
-#endif
- if (!bootverbose)
- return;
-
- if (strcmp(cpu_vendor, "AuthenticAMD") == 0)
- print_AMD_info(nreg);
-#ifdef I686_CPU
- /*
- * XXX - Do PPro CPUID level=2 stuff here?
- *
- * No, but maybe in a print_Intel_info() function called from here.
- */
-#endif
-}
-
-void
-panicifcpuunsupported(void)
-{
-
- /*
- * Now that we have told the user what they have,
- * let them know if that machine type isn't configured.
- */
- switch (cpu_class) {
- case CPUCLASS_286: /* a 286 should not make it this far, anyway */
-#if !defined(I386_CPU) && !defined(I486_CPU) && !defined(I586_CPU) && !defined(I686_CPU)
-#error This kernel is not configured for one of the supported CPUs
-#endif
-#if !defined(I386_CPU)
- case CPUCLASS_386:
-#endif
-#if !defined(I486_CPU)
- case CPUCLASS_486:
-#endif
-#if !defined(I586_CPU)
- case CPUCLASS_586:
-#endif
-#if !defined(I686_CPU)
- case CPUCLASS_686:
-#endif
- panic("CPU class not configured");
- default:
- break;
- }
-}
-
-
-static volatile u_int trap_by_rdmsr;
-
-/*
- * Special exception 6 handler.
- * The rdmsr instruction generates invalid opcodes fault on 486-class
- * Cyrix CPU. Stacked eip register points the rdmsr instruction in the
- * function identblue() when this handler is called. Stacked eip should
- * be advanced.
- */
-inthand_t bluetrap6;
-__asm
-("
- .text
- .p2align 2,0x90
- .type " __XSTRING(CNAME(bluetrap6)) ",@function
-" __XSTRING(CNAME(bluetrap6)) ":
- ss
- movl $0xa8c1d," __XSTRING(CNAME(trap_by_rdmsr)) "
- addl $2, (%esp) # I know rdmsr is a 2-bytes instruction.
- iret
-");
-
-/*
- * Special exception 13 handler.
- * Accessing non-existent MSR generates general protection fault.
- */
-inthand_t bluetrap13;
-__asm
-("
- .text
- .p2align 2,0x90
- .type " __XSTRING(CNAME(bluetrap13)) ",@function
-" __XSTRING(CNAME(bluetrap13)) ":
- ss
- movl $0xa89c4," __XSTRING(CNAME(trap_by_rdmsr)) "
- popl %eax # discard errorcode.
- addl $2, (%esp) # I know rdmsr is a 2-bytes instruction.
- iret
-");
-
-/*
- * Distinguish IBM Blue Lightning CPU from Cyrix CPUs that does not
- * support cpuid instruction. This function should be called after
- * loading interrupt descriptor table register.
- *
- * I don't like this method that handles fault, but I couldn't get
- * information for any other methods. Does blue giant know?
- */
-static int
-identblue(void)
-{
-
- trap_by_rdmsr = 0;
-
- /*
- * Cyrix 486-class CPU does not support rdmsr instruction.
- * The rdmsr instruction generates invalid opcode fault, and exception
- * will be trapped by bluetrap6() on Cyrix 486-class CPU. The
- * bluetrap6() set the magic number to trap_by_rdmsr.
- */
- setidt(6, bluetrap6, SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-
- /*
- * Certain BIOS disables cpuid instructnion of Cyrix 6x86MX CPU.
- * In this case, rdmsr generates general protection fault, and
- * exception will be trapped by bluetrap13().
- */
- setidt(13, bluetrap13, SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-
- rdmsr(0x1002); /* Cyrix CPU generates fault. */
-
- if (trap_by_rdmsr == 0xa8c1d)
- return IDENTBLUE_CYRIX486;
- else if (trap_by_rdmsr == 0xa89c4)
- return IDENTBLUE_CYRIXM2;
- return IDENTBLUE_IBMCPU;
-}
-
-
-/*
- * identifycyrix() set lower 16 bits of cyrix_did as follows:
- *
- * F E D C B A 9 8 7 6 5 4 3 2 1 0
- * +-------+-------+---------------+
- * | SID | RID | Device ID |
- * | (DIR 1) | (DIR 0) |
- * +-------+-------+---------------+
- */
-static void
-identifycyrix(void)
-{
- u_int eflags;
- int ccr2_test = 0, dir_test = 0;
- u_char ccr2, ccr3;
-
- eflags = read_eflags();
- disable_intr();
-
- ccr2 = read_cyrix_reg(CCR2);
- write_cyrix_reg(CCR2, ccr2 ^ CCR2_LOCK_NW);
- read_cyrix_reg(CCR2);
- if (read_cyrix_reg(CCR2) != ccr2)
- ccr2_test = 1;
- write_cyrix_reg(CCR2, ccr2);
-
- ccr3 = read_cyrix_reg(CCR3);
- write_cyrix_reg(CCR3, ccr3 ^ CCR3_MAPEN3);
- read_cyrix_reg(CCR3);
- if (read_cyrix_reg(CCR3) != ccr3)
- dir_test = 1; /* CPU supports DIRs. */
- write_cyrix_reg(CCR3, ccr3);
-
- if (dir_test) {
- /* Device ID registers are available. */
- cyrix_did = read_cyrix_reg(DIR1) << 8;
- cyrix_did += read_cyrix_reg(DIR0);
- } else if (ccr2_test)
- cyrix_did = 0x0010; /* 486S A-step */
- else
- cyrix_did = 0x00ff; /* Old 486SLC/DLC and TI486SXLC/SXL */
-
- write_eflags(eflags);
-}
-
-/*
- * Final stage of CPU identification. -- Should I check TI?
- */
-void
-finishidentcpu(void)
-{
- int isblue = 0;
- u_char ccr3;
- u_int regs[4];
-
- if (strcmp(cpu_vendor, "CyrixInstead") == 0) {
- if (cpu == CPU_486) {
- /*
- * These conditions are equivalent to:
- * - CPU does not support cpuid instruction.
- * - Cyrix/IBM CPU is detected.
- */
- isblue = identblue();
- if (isblue == IDENTBLUE_IBMCPU) {
- strcpy(cpu_vendor, "IBM");
- cpu = CPU_BLUE;
- return;
- }
- }
- switch (cpu_id & 0xf00) {
- case 0x600:
- /*
- * Cyrix's datasheet does not describe DIRs.
- * Therefor, I assume it does not have them
- * and use the result of the cpuid instruction.
- * XXX they seem to have it for now at least. -Peter
- */
- identifycyrix();
- cpu = CPU_M2;
- break;
- default:
- identifycyrix();
- /*
- * This routine contains a trick.
- * Don't check (cpu_id & 0x00f0) == 0x50 to detect M2, now.
- */
- switch (cyrix_did & 0x00f0) {
- case 0x00:
- case 0xf0:
- cpu = CPU_486DLC;
- break;
- case 0x10:
- cpu = CPU_CY486DX;
- break;
- case 0x20:
- if ((cyrix_did & 0x000f) < 8)
- cpu = CPU_M1;
- else
- cpu = CPU_M1SC;
- break;
- case 0x30:
- cpu = CPU_M1;
- break;
- case 0x40:
- /* MediaGX CPU */
- cpu = CPU_M1SC;
- break;
- default:
- /* M2 and later CPUs are treated as M2. */
- cpu = CPU_M2;
-
- /*
- * enable cpuid instruction.
- */
- ccr3 = read_cyrix_reg(CCR3);
- write_cyrix_reg(CCR3, CCR3_MAPEN0);
- write_cyrix_reg(CCR4, read_cyrix_reg(CCR4) | CCR4_CPUID);
- write_cyrix_reg(CCR3, ccr3);
-
- do_cpuid(0, regs);
- cpu_high = regs[0]; /* eax */
- do_cpuid(1, regs);
- cpu_id = regs[0]; /* eax */
- cpu_feature = regs[3]; /* edx */
- break;
- }
- }
- } else if (cpu == CPU_486 && *cpu_vendor == '\0') {
- /*
- * There are BlueLightning CPUs that do not change
- * undefined flags by dividing 5 by 2. In this case,
- * the CPU identification routine in locore.s leaves
- * cpu_vendor null string and puts CPU_486 into the
- * cpu.
- */
- isblue = identblue();
- if (isblue == IDENTBLUE_IBMCPU) {
- strcpy(cpu_vendor, "IBM");
- cpu = CPU_BLUE;
- return;
- }
- }
-}
-
-/*
- * This routine is called specifically to set up cpu_class before
- * startrtclock() uses it. Probably this should be rearranged so that
- * startrtclock() doesn't need to run until after identifycpu() has been
- * called. Another alternative formulation would be for this routine
- * to do all the identification work, and make identifycpu() into a
- * printing-only routine.
- */
-void
-earlysetcpuclass(void)
-{
-
- cpu_class = i386_cpus[cpu].cpu_class;
-}
-
-static void
-print_AMD_assoc(int i)
-{
- if (i == 255)
- printf(", fully associative\n");
- else
- printf(", %d-way associative\n", i);
-}
-
-static void
-print_AMD_info(u_int amd_maxregs)
-{
- quad_t amd_whcr;
-
- if (amd_maxregs >= 0x80000005) {
- u_int regs[4];
-
- do_cpuid(0x80000005, regs);
- printf("Data TLB: %d entries", (regs[1] >> 16) & 0xff);
- print_AMD_assoc(regs[1] >> 24);
- printf("Instruction TLB: %d entries", regs[1] & 0xff);
- print_AMD_assoc((regs[1] >> 8) & 0xff);
- printf("L1 data cache: %d kbytes", regs[2] >> 24);
- printf(", %d bytes/line", regs[2] & 0xff);
- printf(", %d lines/tag", (regs[2] >> 8) & 0xff);
- print_AMD_assoc((regs[2] >> 16) & 0xff);
- printf("L1 instruction cache: %d kbytes", regs[3] >> 24);
- printf(", %d bytes/line", regs[3] & 0xff);
- printf(", %d lines/tag", (regs[3] >> 8) & 0xff);
- print_AMD_assoc((regs[3] >> 16) & 0xff);
- if (amd_maxregs >= 0x80000006) { /* K6-III only */
- do_cpuid(0x80000006, regs);
- printf("L2 internal cache: %d kbytes", regs[2] >> 16);
- printf(", %d bytes/line", regs[2] & 0xff);
- printf(", %d lines/tag", (regs[2] >> 8) & 0x0f);
- print_AMD_assoc((regs[2] >> 12) & 0x0f);
- }
- }
- if (((cpu_id & 0xf00) == 0x500)
- && (((cpu_id & 0x0f0) > 0x80)
- || (((cpu_id & 0x0f0) == 0x80)
- && (cpu_id & 0x00f) > 0x07))) {
- /* K6-2(new core [Stepping 8-F]), K6-III or later */
- amd_whcr = rdmsr(0xc0000082);
- if (!(amd_whcr & (0x3ff << 22))) {
- printf("Write Allocate Disable\n");
- } else {
- printf("Write Allocate Enable Limit: %dM bytes\n",
- (u_int32_t)((amd_whcr & (0x3ff << 22)) >> 22) * 4);
- printf("Write Allocate 15-16M bytes: %s\n",
- (amd_whcr & (1 << 16)) ? "Enable" : "Disable");
- }
- } else if (((cpu_id & 0xf00) == 0x500)
- && ((cpu_id & 0x0f0) > 0x50)) {
- /* K6, K6-2(old core) */
- amd_whcr = rdmsr(0xc0000082);
- if (!(amd_whcr & (0x7f << 1))) {
- printf("Write Allocate Disable\n");
- } else {
- printf("Write Allocate Enable Limit: %dM bytes\n",
- (u_int32_t)((amd_whcr & (0x7f << 1)) >> 1) * 4);
- printf("Write Allocate 15-16M bytes: %s\n",
- (amd_whcr & 0x0001) ? "Enable" : "Disable");
- printf("Hardware Write Allocate Control: %s\n",
- (amd_whcr & 0x0100) ? "Enable" : "Disable");
- }
- }
-}
-
-static void
-print_AMD_features(u_int *regs)
-{
- do_cpuid(0x80000001, regs);
- printf("\n AMD Features=0x%b", regs[3] &~ cpu_feature,
- "\020" /* in hex */
- "\001FPU"
- "\002VME"
- "\003DE"
- "\004PSE"
- "\005TSC"
- "\006MSR"
- "\007<b6>"
- "\010MCE"
- "\011CX8"
- "\012<b9>"
- "\013<b10>"
- "\014SYSCALL"
- "\015<b12>"
- "\016PGE"
- "\017<b14>"
- "\020ICMOV"
- "\021FCMOV"
- "\022<b17>"
- "\023<b18>"
- "\024<b19>"
- "\025<b20>"
- "\026<b21>"
- "\027AMIE" /* AMD MMX Instruction Extensions */
- "\030MMX"
- "\031<b24>"
- "\032<b25>"
- "\033<b26>"
- "\034<b27>"
- "\035<b28>"
- "\036<b29>"
- "\037DSP" /* AMD 3DNow! Instruction Extensions */
- "\0403DNow!"
- );
-}
diff --git a/sys/amd64/amd64/initcpu.c b/sys/amd64/amd64/initcpu.c
deleted file mode 100644
index a56bb36d91a5..000000000000
--- a/sys/amd64/amd64/initcpu.c
+++ /dev/null
@@ -1,762 +0,0 @@
-/*
- * Copyright (c) KATO Takenori, 1997, 1998.
- *
- * All rights reserved. Unpublished rights reserved under the copyright
- * laws of Japan.
- *
- * 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 as
- * the first lines of this file unmodified.
- * 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.
- *
- * $FreeBSD$
- */
-
-#include "opt_cpu.h"
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-
-#include <machine/cputypes.h>
-#include <machine/md_var.h>
-#include <machine/specialreg.h>
-
-void initializecpu(void);
-#if defined(I586_CPU) && defined(CPU_WT_ALLOC)
-void enable_K5_wt_alloc(void);
-void enable_K6_wt_alloc(void);
-void enable_K6_2_wt_alloc(void);
-#endif
-
-#ifdef I486_CPU
-static void init_5x86(void);
-static void init_bluelightning(void);
-static void init_486dlc(void);
-static void init_cy486dx(void);
-#ifdef CPU_I486_ON_386
-static void init_i486_on_386(void);
-#endif
-static void init_6x86(void);
-#endif /* I486_CPU */
-
-#ifdef I686_CPU
-static void init_6x86MX(void);
-static void init_ppro(void);
-#endif
-
-#ifdef I486_CPU
-/*
- * IBM Blue Lightning
- */
-static void
-init_bluelightning(void)
-{
- u_long eflags;
-
-#if defined(PC98) && !defined(CPU_UPGRADE_HW_CACHE)
- need_post_dma_flush = 1;
-#endif
-
- eflags = read_eflags();
- disable_intr();
-
- load_cr0(rcr0() | CR0_CD | CR0_NW);
- invd();
-
-#ifdef CPU_BLUELIGHTNING_FPU_OP_CACHE
- wrmsr(0x1000, 0x9c92LL); /* FP operand can be cacheable on Cyrix FPU */
-#else
- wrmsr(0x1000, 0x1c92LL); /* Intel FPU */
-#endif
- /* Enables 13MB and 0-640KB cache. */
- wrmsr(0x1001, (0xd0LL << 32) | 0x3ff);
-#ifdef CPU_BLUELIGHTNING_3X
- wrmsr(0x1002, 0x04000000LL); /* Enables triple-clock mode. */
-#else
- wrmsr(0x1002, 0x03000000LL); /* Enables double-clock mode. */
-#endif
-
- /* Enable caching in CR0. */
- load_cr0(rcr0() & ~(CR0_CD | CR0_NW)); /* CD = 0 and NW = 0 */
- invd();
- write_eflags(eflags);
-}
-
-/*
- * Cyrix 486SLC/DLC/SR/DR series
- */
-static void
-init_486dlc(void)
-{
- u_long eflags;
- u_char ccr0;
-
- eflags = read_eflags();
- disable_intr();
- invd();
-
- ccr0 = read_cyrix_reg(CCR0);
-#ifndef CYRIX_CACHE_WORKS
- ccr0 |= CCR0_NC1 | CCR0_BARB;
- write_cyrix_reg(CCR0, ccr0);
- invd();
-#else
- ccr0 &= ~CCR0_NC0;
-#ifndef CYRIX_CACHE_REALLY_WORKS
- ccr0 |= CCR0_NC1 | CCR0_BARB;
-#else
- ccr0 |= CCR0_NC1;
-#endif
-#ifdef CPU_DIRECT_MAPPED_CACHE
- ccr0 |= CCR0_CO; /* Direct mapped mode. */
-#endif
- write_cyrix_reg(CCR0, ccr0);
-
- /* Clear non-cacheable region. */
- write_cyrix_reg(NCR1+2, NCR_SIZE_0K);
- write_cyrix_reg(NCR2+2, NCR_SIZE_0K);
- write_cyrix_reg(NCR3+2, NCR_SIZE_0K);
- write_cyrix_reg(NCR4+2, NCR_SIZE_0K);
-
- write_cyrix_reg(0, 0); /* dummy write */
-
- /* Enable caching in CR0. */
- load_cr0(rcr0() & ~(CR0_CD | CR0_NW)); /* CD = 0 and NW = 0 */
- invd();
-#endif /* !CYRIX_CACHE_WORKS */
- write_eflags(eflags);
-}
-
-
-/*
- * Cyrix 486S/DX series
- */
-static void
-init_cy486dx(void)
-{
- u_long eflags;
- u_char ccr2;
-
- eflags = read_eflags();
- disable_intr();
- invd();
-
- ccr2 = read_cyrix_reg(CCR2);
-#ifdef CPU_SUSP_HLT
- ccr2 |= CCR2_SUSP_HLT;
-#endif
- write_cyrix_reg(CCR2, ccr2);
- write_eflags(eflags);
-}
-
-
-/*
- * Cyrix 5x86
- */
-static void
-init_5x86(void)
-{
- u_long eflags;
- u_char ccr2, ccr3, ccr4, pcr0;
-
- eflags = read_eflags();
- disable_intr();
-
- load_cr0(rcr0() | CR0_CD | CR0_NW);
- wbinvd();
-
- (void)read_cyrix_reg(CCR3); /* dummy */
-
- /* Initialize CCR2. */
- ccr2 = read_cyrix_reg(CCR2);
- ccr2 |= CCR2_WB;
-#ifdef CPU_SUSP_HLT
- ccr2 |= CCR2_SUSP_HLT;
-#else
- ccr2 &= ~CCR2_SUSP_HLT;
-#endif
- ccr2 |= CCR2_WT1;
- write_cyrix_reg(CCR2, ccr2);
-
- /* Initialize CCR4. */
- ccr3 = read_cyrix_reg(CCR3);
- write_cyrix_reg(CCR3, CCR3_MAPEN0);
-
- ccr4 = read_cyrix_reg(CCR4);
- ccr4 |= CCR4_DTE;
- ccr4 |= CCR4_MEM;
-#ifdef CPU_FASTER_5X86_FPU
- ccr4 |= CCR4_FASTFPE;
-#else
- ccr4 &= ~CCR4_FASTFPE;
-#endif
- ccr4 &= ~CCR4_IOMASK;
- /********************************************************************
- * WARNING: The "BIOS Writers Guide" mentions that I/O recovery time
- * should be 0 for errata fix.
- ********************************************************************/
-#ifdef CPU_IORT
- ccr4 |= CPU_IORT & CCR4_IOMASK;
-#endif
- write_cyrix_reg(CCR4, ccr4);
-
- /* Initialize PCR0. */
- /****************************************************************
- * WARNING: RSTK_EN and LOOP_EN could make your system unstable.
- * BTB_EN might make your system unstable.
- ****************************************************************/
- pcr0 = read_cyrix_reg(PCR0);
-#ifdef CPU_RSTK_EN
- pcr0 |= PCR0_RSTK;
-#else
- pcr0 &= ~PCR0_RSTK;
-#endif
-#ifdef CPU_BTB_EN
- pcr0 |= PCR0_BTB;
-#else
- pcr0 &= ~PCR0_BTB;
-#endif
-#ifdef CPU_LOOP_EN
- pcr0 |= PCR0_LOOP;
-#else
- pcr0 &= ~PCR0_LOOP;
-#endif
-
- /****************************************************************
- * WARNING: if you use a memory mapped I/O device, don't use
- * DISABLE_5X86_LSSER option, which may reorder memory mapped
- * I/O access.
- * IF YOUR MOTHERBOARD HAS PCI BUS, DON'T DISABLE LSSER.
- ****************************************************************/
-#ifdef CPU_DISABLE_5X86_LSSER
- pcr0 &= ~PCR0_LSSER;
-#else
- pcr0 |= PCR0_LSSER;
-#endif
- write_cyrix_reg(PCR0, pcr0);
-
- /* Restore CCR3. */
- write_cyrix_reg(CCR3, ccr3);
-
- (void)read_cyrix_reg(0x80); /* dummy */
-
- /* Unlock NW bit in CR0. */
- write_cyrix_reg(CCR2, read_cyrix_reg(CCR2) & ~CCR2_LOCK_NW);
- load_cr0((rcr0() & ~CR0_CD) | CR0_NW); /* CD = 0, NW = 1 */
- /* Lock NW bit in CR0. */
- write_cyrix_reg(CCR2, read_cyrix_reg(CCR2) | CCR2_LOCK_NW);
-
- write_eflags(eflags);
-}
-
-#ifdef CPU_I486_ON_386
-/*
- * There are i486 based upgrade products for i386 machines.
- * In this case, BIOS doesn't enables CPU cache.
- */
-void
-init_i486_on_386(void)
-{
- u_long eflags;
-
-#if defined(PC98) && !defined(CPU_UPGRADE_HW_CACHE)
- need_post_dma_flush = 1;
-#endif
-
- eflags = read_eflags();
- disable_intr();
-
- load_cr0(rcr0() & ~(CR0_CD | CR0_NW)); /* CD = 0, NW = 0 */
-
- write_eflags(eflags);
-}
-#endif
-
-/*
- * Cyrix 6x86
- *
- * XXX - What should I do here? Please let me know.
- */
-static void
-init_6x86(void)
-{
- u_long eflags;
- u_char ccr3, ccr4;
-
- eflags = read_eflags();
- disable_intr();
-
- load_cr0(rcr0() | CR0_CD | CR0_NW);
- wbinvd();
-
- /* Initialize CCR0. */
- write_cyrix_reg(CCR0, read_cyrix_reg(CCR0) | CCR0_NC1);
-
- /* Initialize CCR1. */
-#ifdef CPU_CYRIX_NO_LOCK
- write_cyrix_reg(CCR1, read_cyrix_reg(CCR1) | CCR1_NO_LOCK);
-#else
- write_cyrix_reg(CCR1, read_cyrix_reg(CCR1) & ~CCR1_NO_LOCK);
-#endif
-
- /* Initialize CCR2. */
-#ifdef CPU_SUSP_HLT
- write_cyrix_reg(CCR2, read_cyrix_reg(CCR2) | CCR2_SUSP_HLT);
-#else
- write_cyrix_reg(CCR2, read_cyrix_reg(CCR2) & ~CCR2_SUSP_HLT);
-#endif
-
- ccr3 = read_cyrix_reg(CCR3);
- write_cyrix_reg(CCR3, CCR3_MAPEN0);
-
- /* Initialize CCR4. */
- ccr4 = read_cyrix_reg(CCR4);
- ccr4 |= CCR4_DTE;
- ccr4 &= ~CCR4_IOMASK;
-#ifdef CPU_IORT
- write_cyrix_reg(CCR4, ccr4 | (CPU_IORT & CCR4_IOMASK));
-#else
- write_cyrix_reg(CCR4, ccr4 | 7);
-#endif
-
- /* Initialize CCR5. */
-#ifdef CPU_WT_ALLOC
- write_cyrix_reg(CCR5, read_cyrix_reg(CCR5) | CCR5_WT_ALLOC);
-#endif
-
- /* Restore CCR3. */
- write_cyrix_reg(CCR3, ccr3);
-
- /* Unlock NW bit in CR0. */
- write_cyrix_reg(CCR2, read_cyrix_reg(CCR2) & ~CCR2_LOCK_NW);
-
- /*
- * Earlier revision of the 6x86 CPU could crash the system if
- * L1 cache is in write-back mode.
- */
- if ((cyrix_did & 0xff00) > 0x1600)
- load_cr0(rcr0() & ~(CR0_CD | CR0_NW)); /* CD = 0 and NW = 0 */
- else {
- /* Revision 2.6 and lower. */
-#ifdef CYRIX_CACHE_REALLY_WORKS
- load_cr0(rcr0() & ~(CR0_CD | CR0_NW)); /* CD = 0 and NW = 0 */
-#else
- load_cr0((rcr0() & ~CR0_CD) | CR0_NW); /* CD = 0 and NW = 1 */
-#endif
- }
-
- /* Lock NW bit in CR0. */
- write_cyrix_reg(CCR2, read_cyrix_reg(CCR2) | CCR2_LOCK_NW);
-
- write_eflags(eflags);
-}
-#endif /* I486_CPU */
-
-#ifdef I686_CPU
-/*
- * Cyrix 6x86MX (code-named M2)
- *
- * XXX - What should I do here? Please let me know.
- */
-static void
-init_6x86MX(void)
-{
- u_long eflags;
- u_char ccr3, ccr4;
-
- eflags = read_eflags();
- disable_intr();
-
- load_cr0(rcr0() | CR0_CD | CR0_NW);
- wbinvd();
-
- /* Initialize CCR0. */
- write_cyrix_reg(CCR0, read_cyrix_reg(CCR0) | CCR0_NC1);
-
- /* Initialize CCR1. */
-#ifdef CPU_CYRIX_NO_LOCK
- write_cyrix_reg(CCR1, read_cyrix_reg(CCR1) | CCR1_NO_LOCK);
-#else
- write_cyrix_reg(CCR1, read_cyrix_reg(CCR1) & ~CCR1_NO_LOCK);
-#endif
-
- /* Initialize CCR2. */
-#ifdef CPU_SUSP_HLT
- write_cyrix_reg(CCR2, read_cyrix_reg(CCR2) | CCR2_SUSP_HLT);
-#else
- write_cyrix_reg(CCR2, read_cyrix_reg(CCR2) & ~CCR2_SUSP_HLT);
-#endif
-
- ccr3 = read_cyrix_reg(CCR3);
- write_cyrix_reg(CCR3, CCR3_MAPEN0);
-
- /* Initialize CCR4. */
- ccr4 = read_cyrix_reg(CCR4);
- ccr4 &= ~CCR4_IOMASK;
-#ifdef CPU_IORT
- write_cyrix_reg(CCR4, ccr4 | (CPU_IORT & CCR4_IOMASK));
-#else
- write_cyrix_reg(CCR4, ccr4 | 7);
-#endif
-
- /* Initialize CCR5. */
-#ifdef CPU_WT_ALLOC
- write_cyrix_reg(CCR5, read_cyrix_reg(CCR5) | CCR5_WT_ALLOC);
-#endif
-
- /* Restore CCR3. */
- write_cyrix_reg(CCR3, ccr3);
-
- /* Unlock NW bit in CR0. */
- write_cyrix_reg(CCR2, read_cyrix_reg(CCR2) & ~CCR2_LOCK_NW);
-
- load_cr0(rcr0() & ~(CR0_CD | CR0_NW)); /* CD = 0 and NW = 0 */
-
- /* Lock NW bit in CR0. */
- write_cyrix_reg(CCR2, read_cyrix_reg(CCR2) | CCR2_LOCK_NW);
-
- write_eflags(eflags);
-}
-
-static void
-init_ppro(void)
-{
-#ifndef SMP
- u_int64_t apicbase;
-
- /*
- * Local APIC should be diabled in UP kernel.
- */
- apicbase = rdmsr(0x1b);
- apicbase &= ~0x800LL;
- wrmsr(0x1b, apicbase);
-#endif
-}
-#endif /* I686_CPU */
-
-void
-initializecpu(void)
-{
-
- switch (cpu) {
-#ifdef I486_CPU
- case CPU_BLUE:
- init_bluelightning();
- break;
- case CPU_486DLC:
- init_486dlc();
- break;
- case CPU_CY486DX:
- init_cy486dx();
- break;
- case CPU_M1SC:
- init_5x86();
- break;
-#ifdef CPU_I486_ON_386
- case CPU_486:
- init_i486_on_386();
- break;
-#endif
- case CPU_M1:
- init_6x86();
- break;
-#endif /* I486_CPU */
-#ifdef I686_CPU
- case CPU_M2:
- init_6x86MX();
- break;
- case CPU_686:
- if (strcmp(cpu_vendor, "GenuineIntel") == 0 &&
- (cpu_id & 0xff0) == 0x610)
- init_ppro();
- break;
-#endif
- default:
- break;
- }
-
-#if defined(PC98) && !defined(CPU_UPGRADE_HW_CACHE)
- /*
- * OS should flush L1 cahce by itself because no PC-98 supports
- * non-Intel CPUs. Use wbinvd instruction before DMA transfer
- * when need_pre_dma_flush = 1, use invd instruction after DMA
- * transfer when need_post_dma_flush = 1. If your CPU upgrade
- * product support hardware cache control, you can add
- * UPGRADE_CPU_HW_CACHE option in your kernel configuration file.
- * This option elminate unneeded cache flush instruction.
- */
- if (strcmp(cpu_vendor, "CyrixInstead") == 0) {
- switch (cpu) {
-#ifdef I486_CPU
- case CPU_486DLC:
- need_post_dma_flush = 1;
- break;
- case CPU_M1SC:
- need_pre_dma_flush = 1;
- break;
-#endif
- default:
- break;
- }
- } else if (strcmp(cpu_vendor, "AuthenticAMD") == 0) {
- switch (cpu_id & 0xFF0) {
- case 0x470: /* Enhanced Am486DX2 WB */
- case 0x490: /* Enhanced Am486DX4 WB */
- case 0x4F0: /* Am5x86 WB */
- need_pre_dma_flush = 1;
- break;
- }
- } else if (strcmp(cpu_vendor, "IBM") == 0) {
- need_post_dma_flush = 1;
- } else {
-#ifdef CPU_I486_ON_386
- need_pre_dma_flush = 1;
-#endif
- }
-#endif /* PC98 && !UPGRADE_CPU_HW_CACHE */
-}
-
-#if defined(I586_CPU) && defined(CPU_WT_ALLOC)
-/*
- * Enable write allocate feature of AMD processors.
- * Following two functions require the Maxmem variable being set.
- */
-void
-enable_K5_wt_alloc(void)
-{
- u_int64_t msr;
-
- /*
- * Write allocate is supported only on models 1, 2, and 3, with
- * a stepping of 4 or greater.
- */
- if (((cpu_id & 0xf0) > 0) && ((cpu_id & 0x0f) > 3)) {
- disable_intr();
- msr = rdmsr(0x83); /* HWCR */
- wrmsr(0x83, msr & !(0x10));
-
- /*
- * We have to tell the chip where the top of memory is,
- * since video cards could have frame bufferes there,
- * memory-mapped I/O could be there, etc.
- */
- if(Maxmem > 0)
- msr = Maxmem / 16;
- else
- msr = 0;
- msr |= AMD_WT_ALLOC_TME | AMD_WT_ALLOC_FRE;
-#ifdef PC98
- if (!(inb(0x43b) & 4)) {
- wrmsr(0x86, 0x0ff00f0);
- msr |= AMD_WT_ALLOC_PRE;
- }
-#else
- /*
- * There is no way to know wheter 15-16M hole exists or not.
- * Therefore, we disable write allocate for this range.
- */
- wrmsr(0x86, 0x0ff00f0);
- msr |= AMD_WT_ALLOC_PRE;
-#endif
- wrmsr(0x85, msr);
-
- msr=rdmsr(0x83);
- wrmsr(0x83, msr|0x10); /* enable write allocate */
-
- enable_intr();
- }
-}
-
-void
-enable_K6_wt_alloc(void)
-{
- quad_t size;
- u_int64_t whcr;
- u_long eflags;
-
- eflags = read_eflags();
- disable_intr();
- wbinvd();
-
-#ifdef CPU_DISABLE_CACHE
- /*
- * Certain K6-2 box becomes unstable when write allocation is
- * enabled.
- */
- /*
- * The AMD-K6 processer provides the 64-bit Test Register 12(TR12),
- * but only the Cache Inhibit(CI) (bit 3 of TR12) is suppported.
- * All other bits in TR12 have no effect on the processer's operation.
- * The I/O Trap Restart function (bit 9 of TR12) is always enabled
- * on the AMD-K6.
- */
- wrmsr(0x0000000e, (u_int64_t)0x0008);
-#endif
- /* Don't assume that memory size is aligned with 4M. */
- if (Maxmem > 0)
- size = ((Maxmem >> 8) + 3) >> 2;
- else
- size = 0;
-
- /* Limit is 508M bytes. */
- if (size > 0x7f)
- size = 0x7f;
- whcr = (rdmsr(0xc0000082) & ~(0x7fLL << 1)) | (size << 1);
-
-#if defined(PC98) || defined(NO_MEMORY_HOLE)
- if (whcr & (0x7fLL << 1)) {
-#ifdef PC98
- /*
- * If bit 2 of port 0x43b is 0, disable wrte allocate for the
- * 15-16M range.
- */
- if (!(inb(0x43b) & 4))
- whcr &= ~0x0001LL;
- else
-#endif
- whcr |= 0x0001LL;
- }
-#else
- /*
- * There is no way to know wheter 15-16M hole exists or not.
- * Therefore, we disable write allocate for this range.
- */
- whcr &= ~0x0001LL;
-#endif
- wrmsr(0x0c0000082, whcr);
-
- write_eflags(eflags);
- enable_intr();
-}
-
-void
-enable_K6_2_wt_alloc(void)
-{
- quad_t size;
- u_int64_t whcr;
- u_long eflags;
-
- eflags = read_eflags();
- disable_intr();
- wbinvd();
-
-#ifdef CPU_DISABLE_CACHE
- /*
- * Certain K6-2 box becomes unstable when write allocation is
- * enabled.
- */
- /*
- * The AMD-K6 processer provides the 64-bit Test Register 12(TR12),
- * but only the Cache Inhibit(CI) (bit 3 of TR12) is suppported.
- * All other bits in TR12 have no effect on the processer's operation.
- * The I/O Trap Restart function (bit 9 of TR12) is always enabled
- * on the AMD-K6.
- */
- wrmsr(0x0000000e, (u_int64_t)0x0008);
-#endif
- /* Don't assume that memory size is aligned with 4M. */
- if (Maxmem > 0)
- size = ((Maxmem >> 8) + 3) >> 2;
- else
- size = 0;
-
- /* Limit is 4092M bytes. */
- if (size > 0x3fff)
- size = 0x3ff;
- whcr = (rdmsr(0xc0000082) & ~(0x3ffLL << 22)) | (size << 22);
-
-#if defined(PC98) || defined(NO_MEMORY_HOLE)
- if (whcr & (0x3ffLL << 22)) {
-#ifdef PC98
- /*
- * If bit 2 of port 0x43b is 0, disable wrte allocate for the
- * 15-16M range.
- */
- if (!(inb(0x43b) & 4))
- whcr &= ~(1LL << 16);
- else
-#endif
- whcr |= 1LL << 16;
- }
-#else
- /*
- * There is no way to know wheter 15-16M hole exists or not.
- * Therefore, we disable write allocate for this range.
- */
- whcr &= ~(1LL << 16);
-#endif
- wrmsr(0x0c0000082, whcr);
-
- write_eflags(eflags);
- enable_intr();
-}
-#endif /* I585_CPU && CPU_WT_ALLOC */
-
-#include "opt_ddb.h"
-#ifdef DDB
-#include <ddb/ddb.h>
-
-DB_SHOW_COMMAND(cyrixreg, cyrixreg)
-{
- u_long eflags;
- u_int cr0;
- u_char ccr1, ccr2, ccr3;
- u_char ccr0 = 0, ccr4 = 0, ccr5 = 0, pcr0 = 0;
-
- cr0 = rcr0();
- if (strcmp(cpu_vendor,"CyrixInstead") == 0) {
- eflags = read_eflags();
- disable_intr();
-
-
- if ((cpu != CPU_M1SC) && (cpu != CPU_CY486DX)) {
- ccr0 = read_cyrix_reg(CCR0);
- }
- ccr1 = read_cyrix_reg(CCR1);
- ccr2 = read_cyrix_reg(CCR2);
- ccr3 = read_cyrix_reg(CCR3);
- if ((cpu == CPU_M1SC) || (cpu == CPU_M1) || (cpu == CPU_M2)) {
- write_cyrix_reg(CCR3, CCR3_MAPEN0);
- ccr4 = read_cyrix_reg(CCR4);
- if ((cpu == CPU_M1) || (cpu == CPU_M2))
- ccr5 = read_cyrix_reg(CCR5);
- else
- pcr0 = read_cyrix_reg(PCR0);
- write_cyrix_reg(CCR3, ccr3); /* Restore CCR3. */
- }
- write_eflags(eflags);
-
- if ((cpu != CPU_M1SC) && (cpu != CPU_CY486DX))
- printf("CCR0=%x, ", (u_int)ccr0);
-
- printf("CCR1=%x, CCR2=%x, CCR3=%x",
- (u_int)ccr1, (u_int)ccr2, (u_int)ccr3);
- if ((cpu == CPU_M1SC) || (cpu == CPU_M1) || (cpu == CPU_M2)) {
- printf(", CCR4=%x, ", (u_int)ccr4);
- if (cpu == CPU_M1SC)
- printf("PCR0=%x\n", pcr0);
- else
- printf("CCR5=%x\n", ccr5);
- }
- }
- printf("CR0=%x\n", cr0);
-}
-#endif /* DDB */
diff --git a/sys/amd64/amd64/legacy.c b/sys/amd64/amd64/legacy.c
deleted file mode 100644
index f5554f8beac1..000000000000
--- a/sys/amd64/amd64/legacy.c
+++ /dev/null
@@ -1,434 +0,0 @@
-/*
- * Copyright 1998 Massachusetts Institute of Technology
- *
- * Permission to use, copy, modify, and distribute this software and
- * its documentation for any purpose and without fee is hereby
- * granted, provided that both the above copyright notice and this
- * permission notice appear in all copies, that both the above
- * copyright notice and this permission notice appear in all
- * supporting documentation, and that the name of M.I.T. not be used
- * in advertising or publicity pertaining to distribution of the
- * software without specific, written prior permission. M.I.T. makes
- * no representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied
- * warranty.
- *
- * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS
- * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
- * SHALL M.I.T. 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.
- *
- * $FreeBSD$
- */
-
-/*
- * This code implements a `root nexus' for Intel Architecture
- * machines. The function of the root nexus is to serve as an
- * attachment point for both processors and buses, and to manage
- * resources which are common to all of them. In particular,
- * this code implements the core resource managers for interrupt
- * requests, DMA requests (which rightfully should be a part of the
- * ISA code but it's easier to do it here for now), I/O port addresses,
- * and I/O memory address space.
- */
-
-#include "opt_smp.h"
-#include "mca.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <machine/bus.h>
-#include <sys/rman.h>
-
-#include <machine/vmparam.h>
-#include <vm/vm.h>
-#include <vm/pmap.h>
-#include <machine/pmap.h>
-
-#include <machine/resource.h>
-#ifdef APIC_IO
-#include <machine/smp.h>
-#include <machine/mpapic.h>
-#endif
-
-#ifdef PC98
-#include <pc98/pc98/pc98.h>
-#else
-#include <i386/isa/isa.h>
-#endif
-#include <i386/isa/intr_machdep.h>
-
-static struct rman irq_rman, drq_rman, port_rman, mem_rman;
-
-static int nexus_probe(device_t);
-static int nexus_attach(device_t);
-static int nexus_print_child(device_t, device_t);
-static device_t nexus_add_child(device_t bus, int order, const char *name,
- int unit);
-static struct resource *nexus_alloc_resource(device_t, device_t, int, int *,
- u_long, u_long, u_long, u_int);
-static int nexus_activate_resource(device_t, device_t, int, int,
- struct resource *);
-static int nexus_deactivate_resource(device_t, device_t, int, int,
- struct resource *);
-static int nexus_release_resource(device_t, device_t, int, int,
- struct resource *);
-static int nexus_setup_intr(device_t, device_t, struct resource *, int flags,
- void (*)(void *), void *, void **);
-static int nexus_teardown_intr(device_t, device_t, struct resource *,
- void *);
-
-static device_method_t nexus_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, nexus_probe),
- DEVMETHOD(device_attach, nexus_attach),
- DEVMETHOD(device_detach, bus_generic_detach),
- DEVMETHOD(device_shutdown, bus_generic_shutdown),
- DEVMETHOD(device_suspend, bus_generic_suspend),
- DEVMETHOD(device_resume, bus_generic_resume),
-
- /* Bus interface */
- DEVMETHOD(bus_print_child, nexus_print_child),
- DEVMETHOD(bus_add_child, nexus_add_child),
- DEVMETHOD(bus_read_ivar, bus_generic_read_ivar),
- DEVMETHOD(bus_write_ivar, bus_generic_write_ivar),
- DEVMETHOD(bus_alloc_resource, nexus_alloc_resource),
- DEVMETHOD(bus_release_resource, nexus_release_resource),
- DEVMETHOD(bus_activate_resource, nexus_activate_resource),
- DEVMETHOD(bus_deactivate_resource, nexus_deactivate_resource),
- DEVMETHOD(bus_setup_intr, nexus_setup_intr),
- DEVMETHOD(bus_teardown_intr, nexus_teardown_intr),
-
- { 0, 0 }
-};
-
-static driver_t nexus_driver = {
- "nexus",
- nexus_methods,
- 1, /* no softc */
-};
-static devclass_t nexus_devclass;
-
-DRIVER_MODULE(nexus, root, nexus_driver, nexus_devclass, 0, 0);
-
-static int
-nexus_probe(device_t dev)
-{
-
- device_quiet(dev); /* suppress attach message for neatness */
-
- /*
- * IRQ's are on the mainboard on old systems, but on the ISA part
- * of PCI->ISA bridges. There would be multiple sets of IRQs on
- * multi-ISA-bus systems. PCI interrupts are routed to the ISA
- * component, so in a way, PCI can be a partial child of an ISA bus(!).
- * APIC interrupts are global though.
- * In the non-APIC case, disallow the use of IRQ 2.
- */
- irq_rman.rm_start = 0;
- irq_rman.rm_type = RMAN_ARRAY;
- irq_rman.rm_descr = "Interrupt request lines";
-#ifdef APIC_IO
- irq_rman.rm_end = APIC_INTMAPSIZE - 1;
- if (rman_init(&irq_rman)
- || rman_manage_region(&irq_rman,
- irq_rman.rm_start, irq_rman.rm_end))
- panic("nexus_probe irq_rman");
-#else
- irq_rman.rm_end = 15;
- if (rman_init(&irq_rman)
- || rman_manage_region(&irq_rman, irq_rman.rm_start, 1)
- || rman_manage_region(&irq_rman, 3, irq_rman.rm_end))
- panic("nexus_probe irq_rman");
-#endif
-
- /*
- * ISA DMA on PCI systems is implemented in the ISA part of each
- * PCI->ISA bridge and the channels can be duplicated if there are
- * multiple bridges. (eg: laptops with docking stations)
- */
- drq_rman.rm_start = 0;
- drq_rman.rm_end = 7;
- drq_rman.rm_type = RMAN_ARRAY;
- drq_rman.rm_descr = "DMA request lines";
- /* XXX drq 0 not available on some machines */
- if (rman_init(&drq_rman)
- || rman_manage_region(&drq_rman, 0, 7))
- panic("nexus_probe drq_rman");
-
- /*
- * However, IO ports and Memory truely are global at this level,
- * as are APIC interrupts (however many IO APICS there turn out
- * to be on large systems..)
- */
- port_rman.rm_start = 0;
- port_rman.rm_end = 0xffff;
- port_rman.rm_type = RMAN_ARRAY;
- port_rman.rm_descr = "I/O ports";
- if (rman_init(&port_rman)
- || rman_manage_region(&port_rman, 0, 0xffff))
- panic("nexus_probe port_rman");
-
- mem_rman.rm_start = 0;
- mem_rman.rm_end = ~0u;
- mem_rman.rm_type = RMAN_ARRAY;
- mem_rman.rm_descr = "I/O memory addresses";
- if (rman_init(&mem_rman)
- || rman_manage_region(&mem_rman, 0, ~0))
- panic("nexus_probe mem_rman");
-
- return bus_generic_probe(dev);
-}
-
-static int
-nexus_attach(device_t dev)
-{
- device_t child;
-
- /*
- * First, deal with the children we know about already
- */
- bus_generic_attach(dev);
- /*
- * And if we didn't see EISA or ISA on a pci bridge, create some
- * connection points now so they show up "on motherboard".
- */
- if (!devclass_get_device(devclass_find("eisa"), 0)) {
- child = device_add_child(dev, "eisa", 0);
- if (child == NULL)
- panic("nexus_attach eisa");
- device_probe_and_attach(child);
- }
-#if NMCA > 0
- if (!devclass_get_device(devclass_find("mca"), 0)) {
- child = device_add_child(dev, "mca", 0);
- if (child == 0)
- panic("nexus_probe mca");
- device_probe_and_attach(child);
- }
-#endif
- if (!devclass_get_device(devclass_find("isa"), 0)) {
- child = device_add_child(dev, "isa", 0);
- if (child == NULL)
- panic("nexus_attach isa");
- device_probe_and_attach(child);
- }
-
- return 0;
-}
-
-static int
-nexus_print_child(device_t bus, device_t child)
-{
- int retval = 0;
-
- retval += bus_print_child_header(bus, child);
- retval += printf(" on motherboard\n");
-
- return (retval);
-}
-
-static device_t
-nexus_add_child(device_t bus, int order, const char *name, int unit)
-{
- return device_add_child_ordered(bus, order, name, unit);
-}
-
-/*
- * Allocate a resource on behalf of child. NB: child is usually going to be a
- * child of one of our descendants, not a direct child of nexus0.
- * (Exceptions include npx.)
- */
-static struct resource *
-nexus_alloc_resource(device_t bus, device_t child, int type, int *rid,
- u_long start, u_long end, u_long count, u_int flags)
-{
- struct resource *rv;
- struct rman *rm;
- int needactivate = flags & RF_ACTIVE;
-
- flags &= ~RF_ACTIVE;
-
- switch (type) {
- case SYS_RES_IRQ:
- rm = &irq_rman;
- break;
-
- case SYS_RES_DRQ:
- rm = &drq_rman;
- break;
-
- case SYS_RES_IOPORT:
- rm = &port_rman;
- break;
-
- case SYS_RES_MEMORY:
- rm = &mem_rman;
- break;
-
- default:
- return 0;
- }
-
- rv = rman_reserve_resource(rm, start, end, count, flags, child);
- if (rv == 0)
- return 0;
-
- if (type == SYS_RES_MEMORY) {
- rman_set_bustag(rv, I386_BUS_SPACE_MEM);
- } else if (type == SYS_RES_IOPORT) {
- rman_set_bustag(rv, I386_BUS_SPACE_IO);
- rman_set_bushandle(rv, rv->r_start);
- }
-
- if (needactivate) {
- if (bus_activate_resource(child, type, *rid, rv)) {
- rman_release_resource(rv);
- return 0;
- }
- }
-
- return rv;
-}
-
-static int
-nexus_activate_resource(device_t bus, device_t child, int type, int rid,
- struct resource *r)
-{
- /*
- * If this is a memory resource, map it into the kernel.
- */
- if (rman_get_bustag(r) == I386_BUS_SPACE_MEM) {
- caddr_t vaddr = 0;
-
- if (r->r_end < 1024 * 1024) {
- /*
- * The first 1Mb is mapped at KERNBASE.
- */
- vaddr = (caddr_t)(uintptr_t)(KERNBASE + r->r_start);
- } else {
- u_int32_t paddr;
- u_int32_t psize;
- u_int32_t poffs;
-
- paddr = r->r_start;
- psize = r->r_end - r->r_start;
-
- poffs = paddr - trunc_page(paddr);
- vaddr = (caddr_t) pmap_mapdev(paddr-poffs, psize+poffs) + poffs;
- }
- rman_set_virtual(r, vaddr);
- rman_set_bushandle(r, (bus_space_handle_t) vaddr);
- }
- return (rman_activate_resource(r));
-}
-
-static int
-nexus_deactivate_resource(device_t bus, device_t child, int type, int rid,
- struct resource *r)
-{
- /*
- * If this is a memory resource, unmap it.
- */
- if ((rman_get_bustag(r) == I386_BUS_SPACE_MEM) && (r->r_end >= 1024 * 1024)) {
- u_int32_t psize;
-
- psize = r->r_end - r->r_start;
- pmap_unmapdev((vm_offset_t)rman_get_virtual(r), psize);
- }
-
- return (rman_deactivate_resource(r));
-}
-
-static int
-nexus_release_resource(device_t bus, device_t child, int type, int rid,
- struct resource *r)
-{
- if (r->r_flags & RF_ACTIVE) {
- int error = bus_deactivate_resource(child, type, rid, r);
- if (error)
- return error;
- }
- return (rman_release_resource(r));
-}
-
-/*
- * Currently this uses the really grody interface from kern/kern_intr.c
- * (which really doesn't belong in kern/anything.c). Eventually, all of
- * the code in kern_intr.c and machdep_intr.c should get moved here, since
- * this is going to be the official interface.
- */
-static int
-nexus_setup_intr(device_t bus, device_t child, struct resource *irq,
- int flags, void (*ihand)(void *), void *arg, void **cookiep)
-{
- intrmask_t *mask;
- driver_t *driver;
- int error, icflags;
-
- /* somebody tried to setup an irq that failed to allocate! */
- if (irq == NULL)
- panic("nexus_setup_intr: NULL irq resource!");
-
- *cookiep = 0;
- if (irq->r_flags & RF_SHAREABLE)
- icflags = 0;
- else
- icflags = INTR_EXCL;
-
- driver = device_get_driver(child);
- switch (flags) {
- case INTR_TYPE_TTY:
- mask = &tty_imask;
- break;
- case (INTR_TYPE_TTY | INTR_TYPE_FAST):
- mask = &tty_imask;
- icflags |= INTR_FAST;
- break;
- case INTR_TYPE_BIO:
- mask = &bio_imask;
- break;
- case INTR_TYPE_NET:
- mask = &net_imask;
- break;
- case INTR_TYPE_CAM:
- mask = &cam_imask;
- break;
- case INTR_TYPE_MISC:
- mask = 0;
- break;
- default:
- panic("still using grody create_intr interface");
- }
-
- /*
- * We depend here on rman_activate_resource() being idempotent.
- */
- error = rman_activate_resource(irq);
- if (error)
- return (error);
-
- *cookiep = inthand_add(device_get_nameunit(child), irq->r_start,
- ihand, arg, mask, icflags);
- if (*cookiep == NULL)
- error = EINVAL; /* XXX ??? */
-
- return (error);
-}
-
-static int
-nexus_teardown_intr(device_t dev, device_t child, struct resource *r, void *ih)
-{
- return (inthand_remove(ih));
-}
diff --git a/sys/amd64/amd64/locore.S b/sys/amd64/amd64/locore.S
deleted file mode 100644
index ae2a665caf39..000000000000
--- a/sys/amd64/amd64/locore.S
+++ /dev/null
@@ -1,1014 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)locore.s 7.3 (Berkeley) 5/13/91
- * $FreeBSD$
- *
- * originally from: locore.s, by William F. Jolitz
- *
- * Substantially rewritten by David Greenman, Rod Grimes,
- * Bruce Evans, Wolfgang Solfrank, Poul-Henning Kamp
- * and many others.
- */
-
-#include "opt_bootp.h"
-#include "opt_ddb.h"
-#include "opt_nfsroot.h"
-#include "opt_userconfig.h"
-
-#include <sys/syscall.h>
-#include <sys/reboot.h>
-
-#include <machine/asmacros.h>
-#include <machine/cputypes.h>
-#include <machine/psl.h>
-#include <machine/pmap.h>
-#include <machine/specialreg.h>
-
-#include "assym.s"
-
-/*
- * XXX
- *
- * Note: This version greatly munged to avoid various assembler errors
- * that may be fixed in newer versions of gas. Perhaps newer versions
- * will have more pleasant appearance.
- */
-
-/*
- * PTmap is recursive pagemap at top of virtual address space.
- * Within PTmap, the page directory can be found (third indirection).
- */
- .globl _PTmap,_PTD,_PTDpde
- .set _PTmap,(PTDPTDI << PDRSHIFT)
- .set _PTD,_PTmap + (PTDPTDI * PAGE_SIZE)
- .set _PTDpde,_PTD + (PTDPTDI * PDESIZE)
-
-/*
- * APTmap, APTD is the alternate recursive pagemap.
- * It's used when modifying another process's page tables.
- */
- .globl _APTmap,_APTD,_APTDpde
- .set _APTmap,APTDPTDI << PDRSHIFT
- .set _APTD,_APTmap + (APTDPTDI * PAGE_SIZE)
- .set _APTDpde,_PTD + (APTDPTDI * PDESIZE)
-
-/*
- * Globals
- */
- .data
- ALIGN_DATA /* just to be sure */
-
- .globl HIDENAME(tmpstk)
- .space 0x2000 /* space for tmpstk - temporary stack */
-HIDENAME(tmpstk):
-
- .globl _boothowto,_bootdev
-
- .globl _cpu,_cpu_vendor,_cpu_id,_bootinfo
- .globl _cpu_high, _cpu_feature
-
-_cpu: .long 0 /* are we 386, 386sx, or 486 */
-_cpu_id: .long 0 /* stepping ID */
-_cpu_high: .long 0 /* highest arg to CPUID */
-_cpu_feature: .long 0 /* features */
-_cpu_vendor: .space 20 /* CPU origin code */
-_bootinfo: .space BOOTINFO_SIZE /* bootinfo that we can handle */
-
-_KERNend: .long 0 /* phys addr end of kernel (just after bss) */
-physfree: .long 0 /* phys addr of next free page */
-
-#ifdef SMP
- .globl _cpu0prvpage
-cpu0pp: .long 0 /* phys addr cpu0 private pg */
-_cpu0prvpage: .long 0 /* relocated version */
-
- .globl _SMPpt
-SMPptpa: .long 0 /* phys addr SMP page table */
-_SMPpt: .long 0 /* relocated version */
-#endif /* SMP */
-
- .globl _IdlePTD
-_IdlePTD: .long 0 /* phys addr of kernel PTD */
-
-#ifdef SMP
- .globl _KPTphys
-#endif
-_KPTphys: .long 0 /* phys addr of kernel page tables */
-
- .globl _proc0paddr
-_proc0paddr: .long 0 /* address of proc 0 address space */
-p0upa: .long 0 /* phys addr of proc0's UPAGES */
-
-vm86phystk: .long 0 /* PA of vm86/bios stack */
-
- .globl _vm86paddr, _vm86pa
-_vm86paddr: .long 0 /* address of vm86 region */
-_vm86pa: .long 0 /* phys addr of vm86 region */
-
-#ifdef BDE_DEBUGGER
- .globl _bdb_exists /* flag to indicate BDE debugger is present */
-_bdb_exists: .long 0
-#endif
-
-#ifdef PC98
- .globl _pc98_system_parameter
-_pc98_system_parameter:
- .space 0x240
-#endif
-
-/**********************************************************************
- *
- * Some handy macros
- *
- */
-
-#define R(foo) ((foo)-KERNBASE)
-
-#define ALLOCPAGES(foo) \
- movl R(physfree), %esi ; \
- movl $((foo)*PAGE_SIZE), %eax ; \
- addl %esi, %eax ; \
- movl %eax, R(physfree) ; \
- movl %esi, %edi ; \
- movl $((foo)*PAGE_SIZE),%ecx ; \
- xorl %eax,%eax ; \
- cld ; \
- rep ; \
- stosb
-
-/*
- * fillkpt
- * eax = page frame address
- * ebx = index into page table
- * ecx = how many pages to map
- * base = base address of page dir/table
- * prot = protection bits
- */
-#define fillkpt(base, prot) \
- shll $2,%ebx ; \
- addl base,%ebx ; \
- orl $PG_V,%eax ; \
- orl prot,%eax ; \
-1: movl %eax,(%ebx) ; \
- addl $PAGE_SIZE,%eax ; /* increment physical address */ \
- addl $4,%ebx ; /* next pte */ \
- loop 1b
-
-/*
- * fillkptphys(prot)
- * eax = physical address
- * ecx = how many pages to map
- * prot = protection bits
- */
-#define fillkptphys(prot) \
- movl %eax, %ebx ; \
- shrl $PAGE_SHIFT, %ebx ; \
- fillkpt(R(_KPTphys), prot)
-
- .text
-/**********************************************************************
- *
- * This is where the bootblocks start us, set the ball rolling...
- *
- */
-NON_GPROF_ENTRY(btext)
-
-#ifdef PC98
- /* save SYSTEM PARAMETER for resume (NS/T or other) */
- movl $0xa1400,%esi
- movl $R(_pc98_system_parameter),%edi
- movl $0x0240,%ecx
- cld
- rep
- movsb
-#else /* IBM-PC */
-#ifdef BDE_DEBUGGER
-#ifdef BIOS_STEALS_3K
- cmpl $0x0375c339,0x95504
-#else
- cmpl $0x0375c339,0x96104 /* XXX - debugger signature */
-#endif
- jne 1f
- movb $1,R(_bdb_exists)
-1:
-#endif
-/* Tell the bios to warmboot next time */
- movw $0x1234,0x472
-#endif /* PC98 */
-
-/* Set up a real frame in case the double return in newboot is executed. */
- pushl %ebp
- movl %esp, %ebp
-
-/* Don't trust what the BIOS gives for eflags. */
- pushl $PSL_KERNEL
- popfl
-
-/*
- * Don't trust what the BIOS gives for %fs and %gs. Trust the bootstrap
- * to set %cs, %ds, %es and %ss.
- */
- mov %ds, %ax
- mov %ax, %fs
- mov %ax, %gs
-
- call recover_bootinfo
-
-/* Get onto a stack that we can trust. */
-/*
- * XXX this step is delayed in case recover_bootinfo needs to return via
- * the old stack, but it need not be, since recover_bootinfo actually
- * returns via the old frame.
- */
- movl $R(HIDENAME(tmpstk)),%esp
-
-#ifdef PC98
- /* pc98_machine_type & M_EPSON_PC98 */
- testb $0x02,R(_pc98_system_parameter)+220
- jz 3f
- /* epson_machine_id <= 0x0b */
- cmpb $0x0b,R(_pc98_system_parameter)+224
- ja 3f
-
- /* count up memory */
- movl $0x100000,%eax /* next, talley remaining memory */
- movl $0xFFF-0x100,%ecx
-1: movl 0(%eax),%ebx /* save location to check */
- movl $0xa55a5aa5,0(%eax) /* write test pattern */
- cmpl $0xa55a5aa5,0(%eax) /* does not check yet for rollover */
- jne 2f
- movl %ebx,0(%eax) /* restore memory */
- addl $PAGE_SIZE,%eax
- loop 1b
-2: subl $0x100000,%eax
- shrl $17,%eax
- movb %al,R(_pc98_system_parameter)+1
-3:
-#endif
-
- call identify_cpu
-
-/* clear bss */
-/*
- * XXX this should be done a little earlier.
- *
- * XXX we don't check that there is memory for our bss and page tables
- * before using it.
- *
- * XXX the boot program somewhat bogusly clears the bss. We still have
- * to do it in case we were unzipped by kzipboot. Then the boot program
- * only clears kzipboot's bss.
- *
- * XXX the gdt and idt are still somewhere in the boot program. We
- * depend on the convention that the boot program is below 1MB and we
- * are above 1MB to keep the gdt and idt away from the bss and page
- * tables. The idt is only used if BDE_DEBUGGER is enabled.
- */
- movl $R(_end),%ecx
- movl $R(_edata),%edi
- subl %edi,%ecx
- xorl %eax,%eax
- cld
- rep
- stosb
-
- call create_pagetables
-
-/*
- * If the CPU has support for VME, turn it on.
- */
- testl $CPUID_VME, R(_cpu_feature)
- jz 1f
- movl %cr4, %eax
- orl $CR4_VME, %eax
- movl %eax, %cr4
-1:
-
-#ifdef BDE_DEBUGGER
-/*
- * Adjust as much as possible for paging before enabling paging so that the
- * adjustments can be traced.
- */
- call bdb_prepare_paging
-#endif
-
-/* Now enable paging */
- movl R(_IdlePTD), %eax
- movl %eax,%cr3 /* load ptd addr into mmu */
- movl %cr0,%eax /* get control word */
- orl $CR0_PE|CR0_PG,%eax /* enable paging */
- movl %eax,%cr0 /* and let's page NOW! */
-
-#ifdef BDE_DEBUGGER
-/*
- * Complete the adjustments for paging so that we can keep tracing through
- * initi386() after the low (physical) addresses for the gdt and idt become
- * invalid.
- */
- call bdb_commit_paging
-#endif
-
- pushl $begin /* jump to high virtualized address */
- ret
-
-/* now running relocated at KERNBASE where the system is linked to run */
-begin:
- /* set up bootstrap stack */
- movl _proc0paddr,%esp /* location of in-kernel pages */
- addl $UPAGES*PAGE_SIZE,%esp /* bootstrap stack end location */
- xorl %eax,%eax /* mark end of frames */
- movl %eax,%ebp
- movl _proc0paddr,%eax
- movl _IdlePTD, %esi
- movl %esi,PCB_CR3(%eax)
-
- movl physfree, %esi
- pushl %esi /* value of first for init386(first) */
- call _init386 /* wire 386 chip for unix operation */
- popl %esi
-
- .globl __ucodesel,__udatasel
-
- pushl $0 /* unused */
- pushl __udatasel /* ss */
- pushl $0 /* esp - filled in by execve() */
- pushl $PSL_USER /* eflags (IOPL 0, int enab) */
- pushl __ucodesel /* cs */
- pushl $0 /* eip - filled in by execve() */
- subl $(13*4),%esp /* space for rest of registers */
-
- pushl %esp /* call main with frame pointer */
- call _mi_startup /* autoconfiguration, mountroot etc */
-
- hlt /* never returns to here */
-
-/*
- * When starting init, call this to configure the process for user
- * mode. This will be inherited by other processes.
- */
-NON_GPROF_ENTRY(prepare_usermode)
- /*
- * Now we've run main() and determined what cpu-type we are, we can
- * enable write protection and alignment checking on i486 cpus and
- * above.
- */
-#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)
- cmpl $CPUCLASS_386,_cpu_class
- je 1f
- movl %cr0,%eax /* get control word */
- orl $CR0_WP|CR0_AM,%eax /* enable i486 features */
- movl %eax,%cr0 /* and do it */
-1:
-#endif
- /*
- * on return from main(), we are process 1
- * set up address space and stack so that we can 'return' to user mode
- */
- movl __ucodesel,%eax
- movl __udatasel,%ecx
-
-#if 0 /* ds/es/fs are in trap frame */
- movl %cx,%ds
- movl %cx,%es
- movl %cx,%fs
-#endif
- movl %cx,%gs /* and ds to gs */
- ret /* goto user! */
-
-
-/*
- * Signal trampoline, copied to top of user stack
- */
-NON_GPROF_ENTRY(sigcode)
- call SIGF_HANDLER(%esp) /* call signal handler */
- lea SIGF_UC(%esp),%eax /* get ucontext_t */
- pushl %eax
- testl $PSL_VM,UC_EFLAGS(%eax)
- jne 9f
- movl UC_GS(%eax),%gs /* restore %gs */
-9:
- movl $SYS_sigreturn,%eax
- pushl %eax /* junk to fake return addr. */
- int $0x80 /* enter kernel with args */
-0: jmp 0b
-
- ALIGN_TEXT
-_osigcode:
- call SIGF_HANDLER(%esp) /* call signal handler */
- lea SIGF_SC(%esp),%eax /* get sigcontext */
- pushl %eax
- testl $PSL_VM,SC_PS(%eax)
- jne 9f
- movl SC_GS(%eax),%gs /* restore %gs */
-9:
- movl $0x01d516,SC_TRAPNO(%eax) /* magic: 0ldSiG */
- movl $SYS_sigreturn,%eax
- pushl %eax /* junk to fake return addr. */
- int $0x80 /* enter kernel with args */
-0: jmp 0b
-
- ALIGN_TEXT
-_esigcode:
-
- .data
- .globl _szsigcode, _szosigcode
-_szsigcode:
- .long _esigcode-_sigcode
-_szosigcode:
- .long _esigcode-_osigcode
- .text
-
-/**********************************************************************
- *
- * Recover the bootinfo passed to us from the boot program
- *
- */
-recover_bootinfo:
- /*
- * This code is called in different ways depending on what loaded
- * and started the kernel. This is used to detect how we get the
- * arguments from the other code and what we do with them.
- *
- * Old disk boot blocks:
- * (*btext)(howto, bootdev, cyloffset, esym);
- * [return address == 0, and can NOT be returned to]
- * [cyloffset was not supported by the FreeBSD boot code
- * and always passed in as 0]
- * [esym is also known as total in the boot code, and
- * was never properly supported by the FreeBSD boot code]
- *
- * Old diskless netboot code:
- * (*btext)(0,0,0,0,&nfsdiskless,0,0,0);
- * [return address != 0, and can NOT be returned to]
- * If we are being booted by this code it will NOT work,
- * so we are just going to halt if we find this case.
- *
- * New uniform boot code:
- * (*btext)(howto, bootdev, 0, 0, 0, &bootinfo)
- * [return address != 0, and can be returned to]
- *
- * There may seem to be a lot of wasted arguments in here, but
- * that is so the newer boot code can still load very old kernels
- * and old boot code can load new kernels.
- */
-
- /*
- * The old style disk boot blocks fake a frame on the stack and
- * did an lret to get here. The frame on the stack has a return
- * address of 0.
- */
- cmpl $0,4(%ebp)
- je olddiskboot
-
- /*
- * We have some form of return address, so this is either the
- * old diskless netboot code, or the new uniform code. That can
- * be detected by looking at the 5th argument, if it is 0
- * we are being booted by the new uniform boot code.
- */
- cmpl $0,24(%ebp)
- je newboot
-
- /*
- * Seems we have been loaded by the old diskless boot code, we
- * don't stand a chance of running as the diskless structure
- * changed considerably between the two, so just halt.
- */
- hlt
-
- /*
- * We have been loaded by the new uniform boot code.
- * Let's check the bootinfo version, and if we do not understand
- * it we return to the loader with a status of 1 to indicate this error
- */
-newboot:
- movl 28(%ebp),%ebx /* &bootinfo.version */
- movl BI_VERSION(%ebx),%eax
- cmpl $1,%eax /* We only understand version 1 */
- je 1f
- movl $1,%eax /* Return status */
- leave
- /*
- * XXX this returns to our caller's caller (as is required) since
- * we didn't set up a frame and our caller did.
- */
- ret
-
-1:
- /*
- * If we have a kernelname copy it in
- */
- movl BI_KERNELNAME(%ebx),%esi
- cmpl $0,%esi
- je 2f /* No kernelname */
- movl $MAXPATHLEN,%ecx /* Brute force!!! */
- movl $R(_kernelname),%edi
- cmpb $'/',(%esi) /* Make sure it starts with a slash */
- je 1f
- movb $'/',(%edi)
- incl %edi
- decl %ecx
-1:
- cld
- rep
- movsb
-
-2:
- /*
- * Determine the size of the boot loader's copy of the bootinfo
- * struct. This is impossible to do properly because old versions
- * of the struct don't contain a size field and there are 2 old
- * versions with the same version number.
- */
- movl $BI_ENDCOMMON,%ecx /* prepare for sizeless version */
- testl $RB_BOOTINFO,8(%ebp) /* bi_size (and bootinfo) valid? */
- je got_bi_size /* no, sizeless version */
- movl BI_SIZE(%ebx),%ecx
-got_bi_size:
-
- /*
- * Copy the common part of the bootinfo struct
- */
- movl %ebx,%esi
- movl $R(_bootinfo),%edi
- cmpl $BOOTINFO_SIZE,%ecx
- jbe got_common_bi_size
- movl $BOOTINFO_SIZE,%ecx
-got_common_bi_size:
- cld
- rep
- movsb
-
-#ifdef NFS_ROOT
-#ifndef BOOTP_NFSV3
- /*
- * If we have a nfs_diskless structure copy it in
- */
- movl BI_NFS_DISKLESS(%ebx),%esi
- cmpl $0,%esi
- je olddiskboot
- movl $R(_nfs_diskless),%edi
- movl $NFSDISKLESS_SIZE,%ecx
- cld
- rep
- movsb
- movl $R(_nfs_diskless_valid),%edi
- movl $1,(%edi)
-#endif
-#endif
-
- /*
- * The old style disk boot.
- * (*btext)(howto, bootdev, cyloffset, esym);
- * Note that the newer boot code just falls into here to pick
- * up howto and bootdev, cyloffset and esym are no longer used
- */
-olddiskboot:
- movl 8(%ebp),%eax
- movl %eax,R(_boothowto)
- movl 12(%ebp),%eax
- movl %eax,R(_bootdev)
-
- ret
-
-
-/**********************************************************************
- *
- * Identify the CPU and initialize anything special about it
- *
- */
-identify_cpu:
-
- /* Try to toggle alignment check flag; does not exist on 386. */
- pushfl
- popl %eax
- movl %eax,%ecx
- orl $PSL_AC,%eax
- pushl %eax
- popfl
- pushfl
- popl %eax
- xorl %ecx,%eax
- andl $PSL_AC,%eax
- pushl %ecx
- popfl
-
- testl %eax,%eax
- jnz try486
-
- /* NexGen CPU does not have aligment check flag. */
- pushfl
- movl $0x5555, %eax
- xorl %edx, %edx
- movl $2, %ecx
- clc
- divl %ecx
- jz trynexgen
- popfl
- movl $CPU_386,R(_cpu)
- jmp 3f
-
-trynexgen:
- popfl
- movl $CPU_NX586,R(_cpu)
- movl $0x4778654e,R(_cpu_vendor) # store vendor string
- movl $0x72446e65,R(_cpu_vendor+4)
- movl $0x6e657669,R(_cpu_vendor+8)
- movl $0,R(_cpu_vendor+12)
- jmp 3f
-
-try486: /* Try to toggle identification flag; does not exist on early 486s. */
- pushfl
- popl %eax
- movl %eax,%ecx
- xorl $PSL_ID,%eax
- pushl %eax
- popfl
- pushfl
- popl %eax
- xorl %ecx,%eax
- andl $PSL_ID,%eax
- pushl %ecx
- popfl
-
- testl %eax,%eax
- jnz trycpuid
- movl $CPU_486,R(_cpu)
-
- /*
- * Check Cyrix CPU
- * Cyrix CPUs do not change the undefined flags following
- * execution of the divide instruction which divides 5 by 2.
- *
- * Note: CPUID is enabled on M2, so it passes another way.
- */
- pushfl
- movl $0x5555, %eax
- xorl %edx, %edx
- movl $2, %ecx
- clc
- divl %ecx
- jnc trycyrix
- popfl
- jmp 3f /* You may use Intel CPU. */
-
-trycyrix:
- popfl
- /*
- * IBM Bluelighting CPU also doesn't change the undefined flags.
- * Because IBM doesn't disclose the information for Bluelighting
- * CPU, we couldn't distinguish it from Cyrix's (including IBM
- * brand of Cyrix CPUs).
- */
- movl $0x69727943,R(_cpu_vendor) # store vendor string
- movl $0x736e4978,R(_cpu_vendor+4)
- movl $0x64616574,R(_cpu_vendor+8)
- jmp 3f
-
-trycpuid: /* Use the `cpuid' instruction. */
- xorl %eax,%eax
- .byte 0x0f,0xa2 # cpuid 0
- movl %eax,R(_cpu_high) # highest capability
- movl %ebx,R(_cpu_vendor) # store vendor string
- movl %edx,R(_cpu_vendor+4)
- movl %ecx,R(_cpu_vendor+8)
- movb $0,R(_cpu_vendor+12)
-
- movl $1,%eax
- .byte 0x0f,0xa2 # cpuid 1
- movl %eax,R(_cpu_id) # store cpu_id
- movl %edx,R(_cpu_feature) # store cpu_feature
- rorl $8,%eax # extract family type
- andl $15,%eax
- cmpl $5,%eax
- jae 1f
-
- /* less than Pentium; must be 486 */
- movl $CPU_486,R(_cpu)
- jmp 3f
-1:
- /* a Pentium? */
- cmpl $5,%eax
- jne 2f
- movl $CPU_586,R(_cpu)
- jmp 3f
-2:
- /* Greater than Pentium...call it a Pentium Pro */
- movl $CPU_686,R(_cpu)
-3:
- ret
-
-
-/**********************************************************************
- *
- * Create the first page directory and its page tables.
- *
- */
-
-create_pagetables:
-
- testl $CPUID_PGE, R(_cpu_feature)
- jz 1f
- movl %cr4, %eax
- orl $CR4_PGE, %eax
- movl %eax, %cr4
-1:
-
-/* Find end of kernel image (rounded up to a page boundary). */
- movl $R(_end),%esi
-
-/* include symbols if loaded and useful */
-#ifdef DDB
- movl R(_bootinfo+BI_ESYMTAB),%edi
- testl %edi,%edi
- je over_symalloc
- movl %edi,%esi
- movl $KERNBASE,%edi
- addl %edi,R(_bootinfo+BI_SYMTAB)
- addl %edi,R(_bootinfo+BI_ESYMTAB)
-over_symalloc:
-#endif
-
-/* If we are told where the end of the kernel space is, believe it. */
- movl R(_bootinfo+BI_KERNEND),%edi
- testl %edi,%edi
- je no_kernend
- movl %edi,%esi
-no_kernend:
-
- addl $PAGE_MASK,%esi
- andl $~PAGE_MASK,%esi
- movl %esi,R(_KERNend) /* save end of kernel */
- movl %esi,R(physfree) /* next free page is at end of kernel */
-
-/* Allocate Kernel Page Tables */
- ALLOCPAGES(NKPT)
- movl %esi,R(_KPTphys)
-
-/* Allocate Page Table Directory */
- ALLOCPAGES(1)
- movl %esi,R(_IdlePTD)
-
-/* Allocate UPAGES */
- ALLOCPAGES(UPAGES)
- movl %esi,R(p0upa)
- addl $KERNBASE, %esi
- movl %esi, R(_proc0paddr)
-
- ALLOCPAGES(1) /* vm86/bios stack */
- movl %esi,R(vm86phystk)
-
- ALLOCPAGES(3) /* pgtable + ext + IOPAGES */
- movl %esi,R(_vm86pa)
- addl $KERNBASE, %esi
- movl %esi, R(_vm86paddr)
-
-#ifdef SMP
-/* Allocate cpu0's private data page */
- ALLOCPAGES(1)
- movl %esi,R(cpu0pp)
- addl $KERNBASE, %esi
- movl %esi, R(_cpu0prvpage) /* relocated to KVM space */
-
-/* Allocate SMP page table page */
- ALLOCPAGES(1)
- movl %esi,R(SMPptpa)
- addl $KERNBASE, %esi
- movl %esi, R(_SMPpt) /* relocated to KVM space */
-#endif /* SMP */
-
-/* Map read-only from zero to the end of the kernel text section */
- xorl %eax, %eax
-#ifdef BDE_DEBUGGER
-/* If the debugger is present, actually map everything read-write. */
- cmpl $0,R(_bdb_exists)
- jne map_read_write
-#endif
- xorl %edx,%edx
-
-#if !defined(SMP)
- testl $CPUID_PGE, R(_cpu_feature)
- jz 2f
- orl $PG_G,%edx
-#endif
-
-2: movl $R(_etext),%ecx
- addl $PAGE_MASK,%ecx
- shrl $PAGE_SHIFT,%ecx
- fillkptphys(%edx)
-
-/* Map read-write, data, bss and symbols */
- movl $R(_etext),%eax
- addl $PAGE_MASK, %eax
- andl $~PAGE_MASK, %eax
-map_read_write:
- movl $PG_RW,%edx
-#if !defined(SMP)
- testl $CPUID_PGE, R(_cpu_feature)
- jz 1f
- orl $PG_G,%edx
-#endif
-
-1: movl R(_KERNend),%ecx
- subl %eax,%ecx
- shrl $PAGE_SHIFT,%ecx
- fillkptphys(%edx)
-
-/* Map page directory. */
- movl R(_IdlePTD), %eax
- movl $1, %ecx
- fillkptphys($PG_RW)
-
-/* Map proc0's UPAGES in the physical way ... */
- movl R(p0upa), %eax
- movl $UPAGES, %ecx
- fillkptphys($PG_RW)
-
-/* Map ISA hole */
- movl $ISA_HOLE_START, %eax
- movl $ISA_HOLE_LENGTH>>PAGE_SHIFT, %ecx
- fillkptphys($PG_RW)
-
-/* Map space for the vm86 region */
- movl R(vm86phystk), %eax
- movl $4, %ecx
- fillkptphys($PG_RW)
-
-/* Map page 0 into the vm86 page table */
- movl $0, %eax
- movl $0, %ebx
- movl $1, %ecx
- fillkpt(R(_vm86pa), $PG_RW|PG_U)
-
-/* ...likewise for the ISA hole */
- movl $ISA_HOLE_START, %eax
- movl $ISA_HOLE_START>>PAGE_SHIFT, %ebx
- movl $ISA_HOLE_LENGTH>>PAGE_SHIFT, %ecx
- fillkpt(R(_vm86pa), $PG_RW|PG_U)
-
-#ifdef SMP
-/* Map cpu0's private page into global kmem (4K @ cpu0prvpage) */
- movl R(cpu0pp), %eax
- movl $1, %ecx
- fillkptphys($PG_RW)
-
-/* Map SMP page table page into global kmem FWIW */
- movl R(SMPptpa), %eax
- movl $1, %ecx
- fillkptphys($PG_RW)
-
-/* Map the private page into the SMP page table */
- movl R(cpu0pp), %eax
- movl $0, %ebx /* pte offset = 0 */
- movl $1, %ecx /* one private page coming right up */
- fillkpt(R(SMPptpa), $PG_RW)
-
-/* ... and put the page table table in the pde. */
- movl R(SMPptpa), %eax
- movl $MPPTDI, %ebx
- movl $1, %ecx
- fillkpt(R(_IdlePTD), $PG_RW)
-
-/* Fakeup VA for the local apic to allow early traps. */
- ALLOCPAGES(1)
- movl %esi, %eax
- movl $(NPTEPG-1), %ebx /* pte offset = NTEPG-1 */
- movl $1, %ecx /* one private pt coming right up */
- fillkpt(R(SMPptpa), $PG_RW)
-
-/* Initialize mp lock to allow early traps */
- movl $1, R(_mp_lock)
-#endif /* SMP */
-
-/* install a pde for temporary double map of bottom of VA */
- movl R(_KPTphys), %eax
- xorl %ebx, %ebx
- movl $1, %ecx
- fillkpt(R(_IdlePTD), $PG_RW)
-
-/* install pde's for pt's */
- movl R(_KPTphys), %eax
- movl $KPTDI, %ebx
- movl $NKPT, %ecx
- fillkpt(R(_IdlePTD), $PG_RW)
-
-/* install a pde recursively mapping page directory as a page table */
- movl R(_IdlePTD), %eax
- movl $PTDPTDI, %ebx
- movl $1,%ecx
- fillkpt(R(_IdlePTD), $PG_RW)
-
- ret
-
-#ifdef BDE_DEBUGGER
-bdb_prepare_paging:
- cmpl $0,R(_bdb_exists)
- je bdb_prepare_paging_exit
-
- subl $6,%esp
-
- /*
- * Copy and convert debugger entries from the bootstrap gdt and idt
- * to the kernel gdt and idt. Everything is still in low memory.
- * Tracing continues to work after paging is enabled because the
- * low memory addresses remain valid until everything is relocated.
- * However, tracing through the setidt() that initializes the trace
- * trap will crash.
- */
- sgdt (%esp)
- movl 2(%esp),%esi /* base address of bootstrap gdt */
- movl $R(_gdt),%edi
- movl %edi,2(%esp) /* prepare to load kernel gdt */
- movl $8*18/4,%ecx
- cld
- rep /* copy gdt */
- movsl
- movl $R(_gdt),-8+2(%edi) /* adjust gdt self-ptr */
- movb $0x92,-8+5(%edi)
- lgdt (%esp)
-
- sidt (%esp)
- movl 2(%esp),%esi /* base address of current idt */
- movl 8+4(%esi),%eax /* convert dbg descriptor to ... */
- movw 8(%esi),%ax
- movl %eax,R(bdb_dbg_ljmp+1) /* ... immediate offset ... */
- movl 8+2(%esi),%eax
- movw %ax,R(bdb_dbg_ljmp+5) /* ... and selector for ljmp */
- movl 24+4(%esi),%eax /* same for bpt descriptor */
- movw 24(%esi),%ax
- movl %eax,R(bdb_bpt_ljmp+1)
- movl 24+2(%esi),%eax
- movw %ax,R(bdb_bpt_ljmp+5)
- movl R(_idt),%edi
- movl %edi,2(%esp) /* prepare to load kernel idt */
- movl $8*4/4,%ecx
- cld
- rep /* copy idt */
- movsl
- lidt (%esp)
-
- addl $6,%esp
-
-bdb_prepare_paging_exit:
- ret
-
-/* Relocate debugger gdt entries and gdt and idt pointers. */
-bdb_commit_paging:
- cmpl $0,_bdb_exists
- je bdb_commit_paging_exit
-
- movl $_gdt+8*9,%eax /* adjust slots 9-17 */
- movl $9,%ecx
-reloc_gdt:
- movb $KERNBASE>>24,7(%eax) /* top byte of base addresses, was 0, */
- addl $8,%eax /* now KERNBASE>>24 */
- loop reloc_gdt
-
- subl $6,%esp
- sgdt (%esp)
- addl $KERNBASE,2(%esp)
- lgdt (%esp)
- sidt (%esp)
- addl $KERNBASE,2(%esp)
- lidt (%esp)
- addl $6,%esp
-
- int $3
-
-bdb_commit_paging_exit:
- ret
-
-#endif /* BDE_DEBUGGER */
diff --git a/sys/amd64/amd64/locore.s b/sys/amd64/amd64/locore.s
deleted file mode 100644
index ae2a665caf39..000000000000
--- a/sys/amd64/amd64/locore.s
+++ /dev/null
@@ -1,1014 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)locore.s 7.3 (Berkeley) 5/13/91
- * $FreeBSD$
- *
- * originally from: locore.s, by William F. Jolitz
- *
- * Substantially rewritten by David Greenman, Rod Grimes,
- * Bruce Evans, Wolfgang Solfrank, Poul-Henning Kamp
- * and many others.
- */
-
-#include "opt_bootp.h"
-#include "opt_ddb.h"
-#include "opt_nfsroot.h"
-#include "opt_userconfig.h"
-
-#include <sys/syscall.h>
-#include <sys/reboot.h>
-
-#include <machine/asmacros.h>
-#include <machine/cputypes.h>
-#include <machine/psl.h>
-#include <machine/pmap.h>
-#include <machine/specialreg.h>
-
-#include "assym.s"
-
-/*
- * XXX
- *
- * Note: This version greatly munged to avoid various assembler errors
- * that may be fixed in newer versions of gas. Perhaps newer versions
- * will have more pleasant appearance.
- */
-
-/*
- * PTmap is recursive pagemap at top of virtual address space.
- * Within PTmap, the page directory can be found (third indirection).
- */
- .globl _PTmap,_PTD,_PTDpde
- .set _PTmap,(PTDPTDI << PDRSHIFT)
- .set _PTD,_PTmap + (PTDPTDI * PAGE_SIZE)
- .set _PTDpde,_PTD + (PTDPTDI * PDESIZE)
-
-/*
- * APTmap, APTD is the alternate recursive pagemap.
- * It's used when modifying another process's page tables.
- */
- .globl _APTmap,_APTD,_APTDpde
- .set _APTmap,APTDPTDI << PDRSHIFT
- .set _APTD,_APTmap + (APTDPTDI * PAGE_SIZE)
- .set _APTDpde,_PTD + (APTDPTDI * PDESIZE)
-
-/*
- * Globals
- */
- .data
- ALIGN_DATA /* just to be sure */
-
- .globl HIDENAME(tmpstk)
- .space 0x2000 /* space for tmpstk - temporary stack */
-HIDENAME(tmpstk):
-
- .globl _boothowto,_bootdev
-
- .globl _cpu,_cpu_vendor,_cpu_id,_bootinfo
- .globl _cpu_high, _cpu_feature
-
-_cpu: .long 0 /* are we 386, 386sx, or 486 */
-_cpu_id: .long 0 /* stepping ID */
-_cpu_high: .long 0 /* highest arg to CPUID */
-_cpu_feature: .long 0 /* features */
-_cpu_vendor: .space 20 /* CPU origin code */
-_bootinfo: .space BOOTINFO_SIZE /* bootinfo that we can handle */
-
-_KERNend: .long 0 /* phys addr end of kernel (just after bss) */
-physfree: .long 0 /* phys addr of next free page */
-
-#ifdef SMP
- .globl _cpu0prvpage
-cpu0pp: .long 0 /* phys addr cpu0 private pg */
-_cpu0prvpage: .long 0 /* relocated version */
-
- .globl _SMPpt
-SMPptpa: .long 0 /* phys addr SMP page table */
-_SMPpt: .long 0 /* relocated version */
-#endif /* SMP */
-
- .globl _IdlePTD
-_IdlePTD: .long 0 /* phys addr of kernel PTD */
-
-#ifdef SMP
- .globl _KPTphys
-#endif
-_KPTphys: .long 0 /* phys addr of kernel page tables */
-
- .globl _proc0paddr
-_proc0paddr: .long 0 /* address of proc 0 address space */
-p0upa: .long 0 /* phys addr of proc0's UPAGES */
-
-vm86phystk: .long 0 /* PA of vm86/bios stack */
-
- .globl _vm86paddr, _vm86pa
-_vm86paddr: .long 0 /* address of vm86 region */
-_vm86pa: .long 0 /* phys addr of vm86 region */
-
-#ifdef BDE_DEBUGGER
- .globl _bdb_exists /* flag to indicate BDE debugger is present */
-_bdb_exists: .long 0
-#endif
-
-#ifdef PC98
- .globl _pc98_system_parameter
-_pc98_system_parameter:
- .space 0x240
-#endif
-
-/**********************************************************************
- *
- * Some handy macros
- *
- */
-
-#define R(foo) ((foo)-KERNBASE)
-
-#define ALLOCPAGES(foo) \
- movl R(physfree), %esi ; \
- movl $((foo)*PAGE_SIZE), %eax ; \
- addl %esi, %eax ; \
- movl %eax, R(physfree) ; \
- movl %esi, %edi ; \
- movl $((foo)*PAGE_SIZE),%ecx ; \
- xorl %eax,%eax ; \
- cld ; \
- rep ; \
- stosb
-
-/*
- * fillkpt
- * eax = page frame address
- * ebx = index into page table
- * ecx = how many pages to map
- * base = base address of page dir/table
- * prot = protection bits
- */
-#define fillkpt(base, prot) \
- shll $2,%ebx ; \
- addl base,%ebx ; \
- orl $PG_V,%eax ; \
- orl prot,%eax ; \
-1: movl %eax,(%ebx) ; \
- addl $PAGE_SIZE,%eax ; /* increment physical address */ \
- addl $4,%ebx ; /* next pte */ \
- loop 1b
-
-/*
- * fillkptphys(prot)
- * eax = physical address
- * ecx = how many pages to map
- * prot = protection bits
- */
-#define fillkptphys(prot) \
- movl %eax, %ebx ; \
- shrl $PAGE_SHIFT, %ebx ; \
- fillkpt(R(_KPTphys), prot)
-
- .text
-/**********************************************************************
- *
- * This is where the bootblocks start us, set the ball rolling...
- *
- */
-NON_GPROF_ENTRY(btext)
-
-#ifdef PC98
- /* save SYSTEM PARAMETER for resume (NS/T or other) */
- movl $0xa1400,%esi
- movl $R(_pc98_system_parameter),%edi
- movl $0x0240,%ecx
- cld
- rep
- movsb
-#else /* IBM-PC */
-#ifdef BDE_DEBUGGER
-#ifdef BIOS_STEALS_3K
- cmpl $0x0375c339,0x95504
-#else
- cmpl $0x0375c339,0x96104 /* XXX - debugger signature */
-#endif
- jne 1f
- movb $1,R(_bdb_exists)
-1:
-#endif
-/* Tell the bios to warmboot next time */
- movw $0x1234,0x472
-#endif /* PC98 */
-
-/* Set up a real frame in case the double return in newboot is executed. */
- pushl %ebp
- movl %esp, %ebp
-
-/* Don't trust what the BIOS gives for eflags. */
- pushl $PSL_KERNEL
- popfl
-
-/*
- * Don't trust what the BIOS gives for %fs and %gs. Trust the bootstrap
- * to set %cs, %ds, %es and %ss.
- */
- mov %ds, %ax
- mov %ax, %fs
- mov %ax, %gs
-
- call recover_bootinfo
-
-/* Get onto a stack that we can trust. */
-/*
- * XXX this step is delayed in case recover_bootinfo needs to return via
- * the old stack, but it need not be, since recover_bootinfo actually
- * returns via the old frame.
- */
- movl $R(HIDENAME(tmpstk)),%esp
-
-#ifdef PC98
- /* pc98_machine_type & M_EPSON_PC98 */
- testb $0x02,R(_pc98_system_parameter)+220
- jz 3f
- /* epson_machine_id <= 0x0b */
- cmpb $0x0b,R(_pc98_system_parameter)+224
- ja 3f
-
- /* count up memory */
- movl $0x100000,%eax /* next, talley remaining memory */
- movl $0xFFF-0x100,%ecx
-1: movl 0(%eax),%ebx /* save location to check */
- movl $0xa55a5aa5,0(%eax) /* write test pattern */
- cmpl $0xa55a5aa5,0(%eax) /* does not check yet for rollover */
- jne 2f
- movl %ebx,0(%eax) /* restore memory */
- addl $PAGE_SIZE,%eax
- loop 1b
-2: subl $0x100000,%eax
- shrl $17,%eax
- movb %al,R(_pc98_system_parameter)+1
-3:
-#endif
-
- call identify_cpu
-
-/* clear bss */
-/*
- * XXX this should be done a little earlier.
- *
- * XXX we don't check that there is memory for our bss and page tables
- * before using it.
- *
- * XXX the boot program somewhat bogusly clears the bss. We still have
- * to do it in case we were unzipped by kzipboot. Then the boot program
- * only clears kzipboot's bss.
- *
- * XXX the gdt and idt are still somewhere in the boot program. We
- * depend on the convention that the boot program is below 1MB and we
- * are above 1MB to keep the gdt and idt away from the bss and page
- * tables. The idt is only used if BDE_DEBUGGER is enabled.
- */
- movl $R(_end),%ecx
- movl $R(_edata),%edi
- subl %edi,%ecx
- xorl %eax,%eax
- cld
- rep
- stosb
-
- call create_pagetables
-
-/*
- * If the CPU has support for VME, turn it on.
- */
- testl $CPUID_VME, R(_cpu_feature)
- jz 1f
- movl %cr4, %eax
- orl $CR4_VME, %eax
- movl %eax, %cr4
-1:
-
-#ifdef BDE_DEBUGGER
-/*
- * Adjust as much as possible for paging before enabling paging so that the
- * adjustments can be traced.
- */
- call bdb_prepare_paging
-#endif
-
-/* Now enable paging */
- movl R(_IdlePTD), %eax
- movl %eax,%cr3 /* load ptd addr into mmu */
- movl %cr0,%eax /* get control word */
- orl $CR0_PE|CR0_PG,%eax /* enable paging */
- movl %eax,%cr0 /* and let's page NOW! */
-
-#ifdef BDE_DEBUGGER
-/*
- * Complete the adjustments for paging so that we can keep tracing through
- * initi386() after the low (physical) addresses for the gdt and idt become
- * invalid.
- */
- call bdb_commit_paging
-#endif
-
- pushl $begin /* jump to high virtualized address */
- ret
-
-/* now running relocated at KERNBASE where the system is linked to run */
-begin:
- /* set up bootstrap stack */
- movl _proc0paddr,%esp /* location of in-kernel pages */
- addl $UPAGES*PAGE_SIZE,%esp /* bootstrap stack end location */
- xorl %eax,%eax /* mark end of frames */
- movl %eax,%ebp
- movl _proc0paddr,%eax
- movl _IdlePTD, %esi
- movl %esi,PCB_CR3(%eax)
-
- movl physfree, %esi
- pushl %esi /* value of first for init386(first) */
- call _init386 /* wire 386 chip for unix operation */
- popl %esi
-
- .globl __ucodesel,__udatasel
-
- pushl $0 /* unused */
- pushl __udatasel /* ss */
- pushl $0 /* esp - filled in by execve() */
- pushl $PSL_USER /* eflags (IOPL 0, int enab) */
- pushl __ucodesel /* cs */
- pushl $0 /* eip - filled in by execve() */
- subl $(13*4),%esp /* space for rest of registers */
-
- pushl %esp /* call main with frame pointer */
- call _mi_startup /* autoconfiguration, mountroot etc */
-
- hlt /* never returns to here */
-
-/*
- * When starting init, call this to configure the process for user
- * mode. This will be inherited by other processes.
- */
-NON_GPROF_ENTRY(prepare_usermode)
- /*
- * Now we've run main() and determined what cpu-type we are, we can
- * enable write protection and alignment checking on i486 cpus and
- * above.
- */
-#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)
- cmpl $CPUCLASS_386,_cpu_class
- je 1f
- movl %cr0,%eax /* get control word */
- orl $CR0_WP|CR0_AM,%eax /* enable i486 features */
- movl %eax,%cr0 /* and do it */
-1:
-#endif
- /*
- * on return from main(), we are process 1
- * set up address space and stack so that we can 'return' to user mode
- */
- movl __ucodesel,%eax
- movl __udatasel,%ecx
-
-#if 0 /* ds/es/fs are in trap frame */
- movl %cx,%ds
- movl %cx,%es
- movl %cx,%fs
-#endif
- movl %cx,%gs /* and ds to gs */
- ret /* goto user! */
-
-
-/*
- * Signal trampoline, copied to top of user stack
- */
-NON_GPROF_ENTRY(sigcode)
- call SIGF_HANDLER(%esp) /* call signal handler */
- lea SIGF_UC(%esp),%eax /* get ucontext_t */
- pushl %eax
- testl $PSL_VM,UC_EFLAGS(%eax)
- jne 9f
- movl UC_GS(%eax),%gs /* restore %gs */
-9:
- movl $SYS_sigreturn,%eax
- pushl %eax /* junk to fake return addr. */
- int $0x80 /* enter kernel with args */
-0: jmp 0b
-
- ALIGN_TEXT
-_osigcode:
- call SIGF_HANDLER(%esp) /* call signal handler */
- lea SIGF_SC(%esp),%eax /* get sigcontext */
- pushl %eax
- testl $PSL_VM,SC_PS(%eax)
- jne 9f
- movl SC_GS(%eax),%gs /* restore %gs */
-9:
- movl $0x01d516,SC_TRAPNO(%eax) /* magic: 0ldSiG */
- movl $SYS_sigreturn,%eax
- pushl %eax /* junk to fake return addr. */
- int $0x80 /* enter kernel with args */
-0: jmp 0b
-
- ALIGN_TEXT
-_esigcode:
-
- .data
- .globl _szsigcode, _szosigcode
-_szsigcode:
- .long _esigcode-_sigcode
-_szosigcode:
- .long _esigcode-_osigcode
- .text
-
-/**********************************************************************
- *
- * Recover the bootinfo passed to us from the boot program
- *
- */
-recover_bootinfo:
- /*
- * This code is called in different ways depending on what loaded
- * and started the kernel. This is used to detect how we get the
- * arguments from the other code and what we do with them.
- *
- * Old disk boot blocks:
- * (*btext)(howto, bootdev, cyloffset, esym);
- * [return address == 0, and can NOT be returned to]
- * [cyloffset was not supported by the FreeBSD boot code
- * and always passed in as 0]
- * [esym is also known as total in the boot code, and
- * was never properly supported by the FreeBSD boot code]
- *
- * Old diskless netboot code:
- * (*btext)(0,0,0,0,&nfsdiskless,0,0,0);
- * [return address != 0, and can NOT be returned to]
- * If we are being booted by this code it will NOT work,
- * so we are just going to halt if we find this case.
- *
- * New uniform boot code:
- * (*btext)(howto, bootdev, 0, 0, 0, &bootinfo)
- * [return address != 0, and can be returned to]
- *
- * There may seem to be a lot of wasted arguments in here, but
- * that is so the newer boot code can still load very old kernels
- * and old boot code can load new kernels.
- */
-
- /*
- * The old style disk boot blocks fake a frame on the stack and
- * did an lret to get here. The frame on the stack has a return
- * address of 0.
- */
- cmpl $0,4(%ebp)
- je olddiskboot
-
- /*
- * We have some form of return address, so this is either the
- * old diskless netboot code, or the new uniform code. That can
- * be detected by looking at the 5th argument, if it is 0
- * we are being booted by the new uniform boot code.
- */
- cmpl $0,24(%ebp)
- je newboot
-
- /*
- * Seems we have been loaded by the old diskless boot code, we
- * don't stand a chance of running as the diskless structure
- * changed considerably between the two, so just halt.
- */
- hlt
-
- /*
- * We have been loaded by the new uniform boot code.
- * Let's check the bootinfo version, and if we do not understand
- * it we return to the loader with a status of 1 to indicate this error
- */
-newboot:
- movl 28(%ebp),%ebx /* &bootinfo.version */
- movl BI_VERSION(%ebx),%eax
- cmpl $1,%eax /* We only understand version 1 */
- je 1f
- movl $1,%eax /* Return status */
- leave
- /*
- * XXX this returns to our caller's caller (as is required) since
- * we didn't set up a frame and our caller did.
- */
- ret
-
-1:
- /*
- * If we have a kernelname copy it in
- */
- movl BI_KERNELNAME(%ebx),%esi
- cmpl $0,%esi
- je 2f /* No kernelname */
- movl $MAXPATHLEN,%ecx /* Brute force!!! */
- movl $R(_kernelname),%edi
- cmpb $'/',(%esi) /* Make sure it starts with a slash */
- je 1f
- movb $'/',(%edi)
- incl %edi
- decl %ecx
-1:
- cld
- rep
- movsb
-
-2:
- /*
- * Determine the size of the boot loader's copy of the bootinfo
- * struct. This is impossible to do properly because old versions
- * of the struct don't contain a size field and there are 2 old
- * versions with the same version number.
- */
- movl $BI_ENDCOMMON,%ecx /* prepare for sizeless version */
- testl $RB_BOOTINFO,8(%ebp) /* bi_size (and bootinfo) valid? */
- je got_bi_size /* no, sizeless version */
- movl BI_SIZE(%ebx),%ecx
-got_bi_size:
-
- /*
- * Copy the common part of the bootinfo struct
- */
- movl %ebx,%esi
- movl $R(_bootinfo),%edi
- cmpl $BOOTINFO_SIZE,%ecx
- jbe got_common_bi_size
- movl $BOOTINFO_SIZE,%ecx
-got_common_bi_size:
- cld
- rep
- movsb
-
-#ifdef NFS_ROOT
-#ifndef BOOTP_NFSV3
- /*
- * If we have a nfs_diskless structure copy it in
- */
- movl BI_NFS_DISKLESS(%ebx),%esi
- cmpl $0,%esi
- je olddiskboot
- movl $R(_nfs_diskless),%edi
- movl $NFSDISKLESS_SIZE,%ecx
- cld
- rep
- movsb
- movl $R(_nfs_diskless_valid),%edi
- movl $1,(%edi)
-#endif
-#endif
-
- /*
- * The old style disk boot.
- * (*btext)(howto, bootdev, cyloffset, esym);
- * Note that the newer boot code just falls into here to pick
- * up howto and bootdev, cyloffset and esym are no longer used
- */
-olddiskboot:
- movl 8(%ebp),%eax
- movl %eax,R(_boothowto)
- movl 12(%ebp),%eax
- movl %eax,R(_bootdev)
-
- ret
-
-
-/**********************************************************************
- *
- * Identify the CPU and initialize anything special about it
- *
- */
-identify_cpu:
-
- /* Try to toggle alignment check flag; does not exist on 386. */
- pushfl
- popl %eax
- movl %eax,%ecx
- orl $PSL_AC,%eax
- pushl %eax
- popfl
- pushfl
- popl %eax
- xorl %ecx,%eax
- andl $PSL_AC,%eax
- pushl %ecx
- popfl
-
- testl %eax,%eax
- jnz try486
-
- /* NexGen CPU does not have aligment check flag. */
- pushfl
- movl $0x5555, %eax
- xorl %edx, %edx
- movl $2, %ecx
- clc
- divl %ecx
- jz trynexgen
- popfl
- movl $CPU_386,R(_cpu)
- jmp 3f
-
-trynexgen:
- popfl
- movl $CPU_NX586,R(_cpu)
- movl $0x4778654e,R(_cpu_vendor) # store vendor string
- movl $0x72446e65,R(_cpu_vendor+4)
- movl $0x6e657669,R(_cpu_vendor+8)
- movl $0,R(_cpu_vendor+12)
- jmp 3f
-
-try486: /* Try to toggle identification flag; does not exist on early 486s. */
- pushfl
- popl %eax
- movl %eax,%ecx
- xorl $PSL_ID,%eax
- pushl %eax
- popfl
- pushfl
- popl %eax
- xorl %ecx,%eax
- andl $PSL_ID,%eax
- pushl %ecx
- popfl
-
- testl %eax,%eax
- jnz trycpuid
- movl $CPU_486,R(_cpu)
-
- /*
- * Check Cyrix CPU
- * Cyrix CPUs do not change the undefined flags following
- * execution of the divide instruction which divides 5 by 2.
- *
- * Note: CPUID is enabled on M2, so it passes another way.
- */
- pushfl
- movl $0x5555, %eax
- xorl %edx, %edx
- movl $2, %ecx
- clc
- divl %ecx
- jnc trycyrix
- popfl
- jmp 3f /* You may use Intel CPU. */
-
-trycyrix:
- popfl
- /*
- * IBM Bluelighting CPU also doesn't change the undefined flags.
- * Because IBM doesn't disclose the information for Bluelighting
- * CPU, we couldn't distinguish it from Cyrix's (including IBM
- * brand of Cyrix CPUs).
- */
- movl $0x69727943,R(_cpu_vendor) # store vendor string
- movl $0x736e4978,R(_cpu_vendor+4)
- movl $0x64616574,R(_cpu_vendor+8)
- jmp 3f
-
-trycpuid: /* Use the `cpuid' instruction. */
- xorl %eax,%eax
- .byte 0x0f,0xa2 # cpuid 0
- movl %eax,R(_cpu_high) # highest capability
- movl %ebx,R(_cpu_vendor) # store vendor string
- movl %edx,R(_cpu_vendor+4)
- movl %ecx,R(_cpu_vendor+8)
- movb $0,R(_cpu_vendor+12)
-
- movl $1,%eax
- .byte 0x0f,0xa2 # cpuid 1
- movl %eax,R(_cpu_id) # store cpu_id
- movl %edx,R(_cpu_feature) # store cpu_feature
- rorl $8,%eax # extract family type
- andl $15,%eax
- cmpl $5,%eax
- jae 1f
-
- /* less than Pentium; must be 486 */
- movl $CPU_486,R(_cpu)
- jmp 3f
-1:
- /* a Pentium? */
- cmpl $5,%eax
- jne 2f
- movl $CPU_586,R(_cpu)
- jmp 3f
-2:
- /* Greater than Pentium...call it a Pentium Pro */
- movl $CPU_686,R(_cpu)
-3:
- ret
-
-
-/**********************************************************************
- *
- * Create the first page directory and its page tables.
- *
- */
-
-create_pagetables:
-
- testl $CPUID_PGE, R(_cpu_feature)
- jz 1f
- movl %cr4, %eax
- orl $CR4_PGE, %eax
- movl %eax, %cr4
-1:
-
-/* Find end of kernel image (rounded up to a page boundary). */
- movl $R(_end),%esi
-
-/* include symbols if loaded and useful */
-#ifdef DDB
- movl R(_bootinfo+BI_ESYMTAB),%edi
- testl %edi,%edi
- je over_symalloc
- movl %edi,%esi
- movl $KERNBASE,%edi
- addl %edi,R(_bootinfo+BI_SYMTAB)
- addl %edi,R(_bootinfo+BI_ESYMTAB)
-over_symalloc:
-#endif
-
-/* If we are told where the end of the kernel space is, believe it. */
- movl R(_bootinfo+BI_KERNEND),%edi
- testl %edi,%edi
- je no_kernend
- movl %edi,%esi
-no_kernend:
-
- addl $PAGE_MASK,%esi
- andl $~PAGE_MASK,%esi
- movl %esi,R(_KERNend) /* save end of kernel */
- movl %esi,R(physfree) /* next free page is at end of kernel */
-
-/* Allocate Kernel Page Tables */
- ALLOCPAGES(NKPT)
- movl %esi,R(_KPTphys)
-
-/* Allocate Page Table Directory */
- ALLOCPAGES(1)
- movl %esi,R(_IdlePTD)
-
-/* Allocate UPAGES */
- ALLOCPAGES(UPAGES)
- movl %esi,R(p0upa)
- addl $KERNBASE, %esi
- movl %esi, R(_proc0paddr)
-
- ALLOCPAGES(1) /* vm86/bios stack */
- movl %esi,R(vm86phystk)
-
- ALLOCPAGES(3) /* pgtable + ext + IOPAGES */
- movl %esi,R(_vm86pa)
- addl $KERNBASE, %esi
- movl %esi, R(_vm86paddr)
-
-#ifdef SMP
-/* Allocate cpu0's private data page */
- ALLOCPAGES(1)
- movl %esi,R(cpu0pp)
- addl $KERNBASE, %esi
- movl %esi, R(_cpu0prvpage) /* relocated to KVM space */
-
-/* Allocate SMP page table page */
- ALLOCPAGES(1)
- movl %esi,R(SMPptpa)
- addl $KERNBASE, %esi
- movl %esi, R(_SMPpt) /* relocated to KVM space */
-#endif /* SMP */
-
-/* Map read-only from zero to the end of the kernel text section */
- xorl %eax, %eax
-#ifdef BDE_DEBUGGER
-/* If the debugger is present, actually map everything read-write. */
- cmpl $0,R(_bdb_exists)
- jne map_read_write
-#endif
- xorl %edx,%edx
-
-#if !defined(SMP)
- testl $CPUID_PGE, R(_cpu_feature)
- jz 2f
- orl $PG_G,%edx
-#endif
-
-2: movl $R(_etext),%ecx
- addl $PAGE_MASK,%ecx
- shrl $PAGE_SHIFT,%ecx
- fillkptphys(%edx)
-
-/* Map read-write, data, bss and symbols */
- movl $R(_etext),%eax
- addl $PAGE_MASK, %eax
- andl $~PAGE_MASK, %eax
-map_read_write:
- movl $PG_RW,%edx
-#if !defined(SMP)
- testl $CPUID_PGE, R(_cpu_feature)
- jz 1f
- orl $PG_G,%edx
-#endif
-
-1: movl R(_KERNend),%ecx
- subl %eax,%ecx
- shrl $PAGE_SHIFT,%ecx
- fillkptphys(%edx)
-
-/* Map page directory. */
- movl R(_IdlePTD), %eax
- movl $1, %ecx
- fillkptphys($PG_RW)
-
-/* Map proc0's UPAGES in the physical way ... */
- movl R(p0upa), %eax
- movl $UPAGES, %ecx
- fillkptphys($PG_RW)
-
-/* Map ISA hole */
- movl $ISA_HOLE_START, %eax
- movl $ISA_HOLE_LENGTH>>PAGE_SHIFT, %ecx
- fillkptphys($PG_RW)
-
-/* Map space for the vm86 region */
- movl R(vm86phystk), %eax
- movl $4, %ecx
- fillkptphys($PG_RW)
-
-/* Map page 0 into the vm86 page table */
- movl $0, %eax
- movl $0, %ebx
- movl $1, %ecx
- fillkpt(R(_vm86pa), $PG_RW|PG_U)
-
-/* ...likewise for the ISA hole */
- movl $ISA_HOLE_START, %eax
- movl $ISA_HOLE_START>>PAGE_SHIFT, %ebx
- movl $ISA_HOLE_LENGTH>>PAGE_SHIFT, %ecx
- fillkpt(R(_vm86pa), $PG_RW|PG_U)
-
-#ifdef SMP
-/* Map cpu0's private page into global kmem (4K @ cpu0prvpage) */
- movl R(cpu0pp), %eax
- movl $1, %ecx
- fillkptphys($PG_RW)
-
-/* Map SMP page table page into global kmem FWIW */
- movl R(SMPptpa), %eax
- movl $1, %ecx
- fillkptphys($PG_RW)
-
-/* Map the private page into the SMP page table */
- movl R(cpu0pp), %eax
- movl $0, %ebx /* pte offset = 0 */
- movl $1, %ecx /* one private page coming right up */
- fillkpt(R(SMPptpa), $PG_RW)
-
-/* ... and put the page table table in the pde. */
- movl R(SMPptpa), %eax
- movl $MPPTDI, %ebx
- movl $1, %ecx
- fillkpt(R(_IdlePTD), $PG_RW)
-
-/* Fakeup VA for the local apic to allow early traps. */
- ALLOCPAGES(1)
- movl %esi, %eax
- movl $(NPTEPG-1), %ebx /* pte offset = NTEPG-1 */
- movl $1, %ecx /* one private pt coming right up */
- fillkpt(R(SMPptpa), $PG_RW)
-
-/* Initialize mp lock to allow early traps */
- movl $1, R(_mp_lock)
-#endif /* SMP */
-
-/* install a pde for temporary double map of bottom of VA */
- movl R(_KPTphys), %eax
- xorl %ebx, %ebx
- movl $1, %ecx
- fillkpt(R(_IdlePTD), $PG_RW)
-
-/* install pde's for pt's */
- movl R(_KPTphys), %eax
- movl $KPTDI, %ebx
- movl $NKPT, %ecx
- fillkpt(R(_IdlePTD), $PG_RW)
-
-/* install a pde recursively mapping page directory as a page table */
- movl R(_IdlePTD), %eax
- movl $PTDPTDI, %ebx
- movl $1,%ecx
- fillkpt(R(_IdlePTD), $PG_RW)
-
- ret
-
-#ifdef BDE_DEBUGGER
-bdb_prepare_paging:
- cmpl $0,R(_bdb_exists)
- je bdb_prepare_paging_exit
-
- subl $6,%esp
-
- /*
- * Copy and convert debugger entries from the bootstrap gdt and idt
- * to the kernel gdt and idt. Everything is still in low memory.
- * Tracing continues to work after paging is enabled because the
- * low memory addresses remain valid until everything is relocated.
- * However, tracing through the setidt() that initializes the trace
- * trap will crash.
- */
- sgdt (%esp)
- movl 2(%esp),%esi /* base address of bootstrap gdt */
- movl $R(_gdt),%edi
- movl %edi,2(%esp) /* prepare to load kernel gdt */
- movl $8*18/4,%ecx
- cld
- rep /* copy gdt */
- movsl
- movl $R(_gdt),-8+2(%edi) /* adjust gdt self-ptr */
- movb $0x92,-8+5(%edi)
- lgdt (%esp)
-
- sidt (%esp)
- movl 2(%esp),%esi /* base address of current idt */
- movl 8+4(%esi),%eax /* convert dbg descriptor to ... */
- movw 8(%esi),%ax
- movl %eax,R(bdb_dbg_ljmp+1) /* ... immediate offset ... */
- movl 8+2(%esi),%eax
- movw %ax,R(bdb_dbg_ljmp+5) /* ... and selector for ljmp */
- movl 24+4(%esi),%eax /* same for bpt descriptor */
- movw 24(%esi),%ax
- movl %eax,R(bdb_bpt_ljmp+1)
- movl 24+2(%esi),%eax
- movw %ax,R(bdb_bpt_ljmp+5)
- movl R(_idt),%edi
- movl %edi,2(%esp) /* prepare to load kernel idt */
- movl $8*4/4,%ecx
- cld
- rep /* copy idt */
- movsl
- lidt (%esp)
-
- addl $6,%esp
-
-bdb_prepare_paging_exit:
- ret
-
-/* Relocate debugger gdt entries and gdt and idt pointers. */
-bdb_commit_paging:
- cmpl $0,_bdb_exists
- je bdb_commit_paging_exit
-
- movl $_gdt+8*9,%eax /* adjust slots 9-17 */
- movl $9,%ecx
-reloc_gdt:
- movb $KERNBASE>>24,7(%eax) /* top byte of base addresses, was 0, */
- addl $8,%eax /* now KERNBASE>>24 */
- loop reloc_gdt
-
- subl $6,%esp
- sgdt (%esp)
- addl $KERNBASE,2(%esp)
- lgdt (%esp)
- sidt (%esp)
- addl $KERNBASE,2(%esp)
- lidt (%esp)
- addl $6,%esp
-
- int $3
-
-bdb_commit_paging_exit:
- ret
-
-#endif /* BDE_DEBUGGER */
diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c
deleted file mode 100644
index c204fbeeb72e..000000000000
--- a/sys/amd64/amd64/machdep.c
+++ /dev/null
@@ -1,2445 +0,0 @@
-/*-
- * Copyright (c) 1992 Terrence R. Lambert.
- * Copyright (c) 1982, 1987, 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)machdep.c 7.4 (Berkeley) 6/3/91
- * $FreeBSD$
- */
-
-#include "apm.h"
-#include "ether.h"
-#include "npx.h"
-#include "opt_atalk.h"
-#include "opt_compat.h"
-#include "opt_cpu.h"
-#include "opt_ddb.h"
-#include "opt_inet.h"
-#include "opt_ipx.h"
-#include "opt_maxmem.h"
-#include "opt_msgbuf.h"
-#include "opt_perfmon.h"
-#include "opt_smp.h"
-#include "opt_sysvipc.h"
-#include "opt_user_ldt.h"
-#include "opt_userconfig.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/sysproto.h>
-#include <sys/signalvar.h>
-#include <sys/kernel.h>
-#include <sys/linker.h>
-#include <sys/malloc.h>
-#include <sys/proc.h>
-#include <sys/buf.h>
-#include <sys/reboot.h>
-#include <sys/callout.h>
-#include <sys/mbuf.h>
-#include <sys/msgbuf.h>
-#include <sys/sysent.h>
-#include <sys/sysctl.h>
-#include <sys/vmmeter.h>
-#include <sys/bus.h>
-
-#ifdef SYSVSHM
-#include <sys/shm.h>
-#endif
-
-#ifdef SYSVMSG
-#include <sys/msg.h>
-#endif
-
-#ifdef SYSVSEM
-#include <sys/sem.h>
-#endif
-
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <sys/lock.h>
-#include <vm/vm_kern.h>
-#include <vm/vm_object.h>
-#include <vm/vm_page.h>
-#include <vm/vm_map.h>
-#include <vm/vm_pager.h>
-#include <vm/vm_extern.h>
-
-#include <sys/user.h>
-#include <sys/exec.h>
-#include <sys/cons.h>
-
-#include <ddb/ddb.h>
-
-#include <net/netisr.h>
-
-#include <machine/cpu.h>
-#include <machine/reg.h>
-#include <machine/clock.h>
-#include <machine/specialreg.h>
-#include <machine/bootinfo.h>
-#include <machine/ipl.h>
-#include <machine/md_var.h>
-#include <machine/pcb_ext.h> /* pcb.h included via sys/user.h */
-#ifdef SMP
-#include <machine/smp.h>
-#include <machine/globaldata.h>
-#endif
-#ifdef PERFMON
-#include <machine/perfmon.h>
-#endif
-
-#ifdef OLD_BUS_ARCH
-#include <i386/isa/isa_device.h>
-#endif
-#include <i386/isa/intr_machdep.h>
-#include <isa/rtc.h>
-#include <machine/vm86.h>
-#include <machine/random.h>
-#include <sys/ptrace.h>
-#include <machine/sigframe.h>
-
-extern void init386 __P((int first));
-extern void dblfault_handler __P((void));
-
-extern void printcpuinfo(void); /* XXX header file */
-extern void earlysetcpuclass(void); /* same header file */
-extern void finishidentcpu(void);
-extern void panicifcpuunsupported(void);
-extern void initializecpu(void);
-
-static void cpu_startup __P((void *));
-SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, NULL)
-
-static MALLOC_DEFINE(M_MBUF, "mbuf", "mbuf");
-
-int _udatasel, _ucodesel;
-u_int atdevbase;
-
-#if defined(SWTCH_OPTIM_STATS)
-extern int swtch_optim_stats;
-SYSCTL_INT(_debug, OID_AUTO, swtch_optim_stats,
- CTLFLAG_RD, &swtch_optim_stats, 0, "");
-SYSCTL_INT(_debug, OID_AUTO, tlb_flush_count,
- CTLFLAG_RD, &tlb_flush_count, 0, "");
-#endif
-
-#ifdef PC98
-static int ispc98 = 1;
-#else
-static int ispc98 = 0;
-#endif
-SYSCTL_INT(_machdep, OID_AUTO, ispc98, CTLFLAG_RD, &ispc98, 0, "");
-
-int physmem = 0;
-int cold = 1;
-
-static int
-sysctl_hw_physmem SYSCTL_HANDLER_ARGS
-{
- int error = sysctl_handle_int(oidp, 0, ctob(physmem), req);
- return (error);
-}
-
-SYSCTL_PROC(_hw, HW_PHYSMEM, physmem, CTLTYPE_INT|CTLFLAG_RD,
- 0, 0, sysctl_hw_physmem, "I", "");
-
-static int
-sysctl_hw_usermem SYSCTL_HANDLER_ARGS
-{
- int error = sysctl_handle_int(oidp, 0,
- ctob(physmem - cnt.v_wire_count), req);
- return (error);
-}
-
-SYSCTL_PROC(_hw, HW_USERMEM, usermem, CTLTYPE_INT|CTLFLAG_RD,
- 0, 0, sysctl_hw_usermem, "I", "");
-
-static int
-sysctl_hw_availpages SYSCTL_HANDLER_ARGS
-{
- int error = sysctl_handle_int(oidp, 0,
- i386_btop(avail_end - avail_start), req);
- return (error);
-}
-
-SYSCTL_PROC(_hw, OID_AUTO, availpages, CTLTYPE_INT|CTLFLAG_RD,
- 0, 0, sysctl_hw_availpages, "I", "");
-
-static int
-sysctl_machdep_msgbuf SYSCTL_HANDLER_ARGS
-{
- int error;
-
- /* Unwind the buffer, so that it's linear (possibly starting with
- * some initial nulls).
- */
- error=sysctl_handle_opaque(oidp,msgbufp->msg_ptr+msgbufp->msg_bufr,
- msgbufp->msg_size-msgbufp->msg_bufr,req);
- if(error) return(error);
- if(msgbufp->msg_bufr>0) {
- error=sysctl_handle_opaque(oidp,msgbufp->msg_ptr,
- msgbufp->msg_bufr,req);
- }
- return(error);
-}
-
-SYSCTL_PROC(_machdep, OID_AUTO, msgbuf, CTLTYPE_STRING|CTLFLAG_RD,
- 0, 0, sysctl_machdep_msgbuf, "A","Contents of kernel message buffer");
-
-static int msgbuf_clear;
-
-static int
-sysctl_machdep_msgbuf_clear SYSCTL_HANDLER_ARGS
-{
- int error;
- error = sysctl_handle_int(oidp, oidp->oid_arg1, oidp->oid_arg2,
- req);
- if (!error && req->newptr) {
- /* Clear the buffer and reset write pointer */
- bzero(msgbufp->msg_ptr,msgbufp->msg_size);
- msgbufp->msg_bufr=msgbufp->msg_bufx=0;
- msgbuf_clear=0;
- }
- return (error);
-}
-
-SYSCTL_PROC(_machdep, OID_AUTO, msgbuf_clear, CTLTYPE_INT|CTLFLAG_RW,
- &msgbuf_clear, 0, sysctl_machdep_msgbuf_clear, "I",
- "Clear kernel message buffer");
-
-int bootverbose = 0, Maxmem = 0;
-long dumplo;
-
-vm_offset_t phys_avail[10];
-
-/* must be 2 less so 0 0 can signal end of chunks */
-#define PHYS_AVAIL_ARRAY_END ((sizeof(phys_avail) / sizeof(vm_offset_t)) - 2)
-
-static vm_offset_t buffer_sva, buffer_eva;
-vm_offset_t clean_sva, clean_eva;
-static vm_offset_t pager_sva, pager_eva;
-
-#define offsetof(type, member) ((size_t)(&((type *)0)->member))
-
-static void
-cpu_startup(dummy)
- void *dummy;
-{
- register unsigned i;
- register caddr_t v;
- vm_offset_t maxaddr;
- vm_size_t size = 0;
- int firstaddr;
- vm_offset_t minaddr;
-
- if (boothowto & RB_VERBOSE)
- bootverbose++;
-
- /*
- * Good {morning,afternoon,evening,night}.
- */
- printf(version);
- earlysetcpuclass();
- startrtclock();
- printcpuinfo();
- panicifcpuunsupported();
-#ifdef PERFMON
- perfmon_init();
-#endif
- printf("real memory = %u (%uK bytes)\n", ptoa(Maxmem), ptoa(Maxmem) / 1024);
- /*
- * Display any holes after the first chunk of extended memory.
- */
- if (bootverbose) {
- int indx;
-
- printf("Physical memory chunk(s):\n");
- for (indx = 0; phys_avail[indx + 1] != 0; indx += 2) {
- int size1 = phys_avail[indx + 1] - phys_avail[indx];
-
- printf("0x%08x - 0x%08x, %u bytes (%u pages)\n",
- phys_avail[indx], phys_avail[indx + 1] - 1, size1,
- size1 / PAGE_SIZE);
- }
- }
-
- /*
- * Calculate callout wheel size
- */
- for (callwheelsize = 1, callwheelbits = 0;
- callwheelsize < ncallout;
- callwheelsize <<= 1, ++callwheelbits)
- ;
- callwheelmask = callwheelsize - 1;
-
- /*
- * Allocate space for system data structures.
- * The first available kernel virtual address is in "v".
- * As pages of kernel virtual memory are allocated, "v" is incremented.
- * As pages of memory are allocated and cleared,
- * "firstaddr" is incremented.
- * An index into the kernel page table corresponding to the
- * virtual memory address maintained in "v" is kept in "mapaddr".
- */
-
- /*
- * Make two passes. The first pass calculates how much memory is
- * needed and allocates it. The second pass assigns virtual
- * addresses to the various data structures.
- */
- firstaddr = 0;
-again:
- v = (caddr_t)firstaddr;
-
-#define valloc(name, type, num) \
- (name) = (type *)v; v = (caddr_t)((name)+(num))
-#define valloclim(name, type, num, lim) \
- (name) = (type *)v; v = (caddr_t)((lim) = ((name)+(num)))
-
- valloc(callout, struct callout, ncallout);
- valloc(callwheel, struct callout_tailq, callwheelsize);
-#ifdef SYSVSHM
- valloc(shmsegs, struct shmid_ds, shminfo.shmmni);
-#endif
-#ifdef SYSVSEM
- valloc(sema, struct semid_ds, seminfo.semmni);
- valloc(sem, struct sem, seminfo.semmns);
- /* This is pretty disgusting! */
- valloc(semu, int, (seminfo.semmnu * seminfo.semusz) / sizeof(int));
-#endif
-#ifdef SYSVMSG
- valloc(msgpool, char, msginfo.msgmax);
- valloc(msgmaps, struct msgmap, msginfo.msgseg);
- valloc(msghdrs, struct msg, msginfo.msgtql);
- valloc(msqids, struct msqid_ds, msginfo.msgmni);
-#endif
-
- if (nbuf == 0) {
- nbuf = 50;
- if (physmem > 1024)
- nbuf += min((physmem - 1024) / 8, 2048);
- if (physmem > 16384)
- nbuf += (physmem - 16384) / 20;
- }
- nswbuf = max(min(nbuf/4, 256), 16);
-
- valloc(swbuf, struct buf, nswbuf);
- valloc(buf, struct buf, nbuf);
- v = bufhashinit(v);
-
- /*
- * End of first pass, size has been calculated so allocate memory
- */
- if (firstaddr == 0) {
- size = (vm_size_t)(v - firstaddr);
- firstaddr = (int)kmem_alloc(kernel_map, round_page(size));
- if (firstaddr == 0)
- panic("startup: no room for tables");
- goto again;
- }
-
- /*
- * End of second pass, addresses have been assigned
- */
- if ((vm_size_t)(v - firstaddr) != size)
- panic("startup: table size inconsistency");
-
- clean_map = kmem_suballoc(kernel_map, &clean_sva, &clean_eva,
- (nbuf*BKVASIZE) + (nswbuf*MAXPHYS) + pager_map_size);
- buffer_map = kmem_suballoc(clean_map, &buffer_sva, &buffer_eva,
- (nbuf*BKVASIZE));
- pager_map = kmem_suballoc(clean_map, &pager_sva, &pager_eva,
- (nswbuf*MAXPHYS) + pager_map_size);
- pager_map->system_map = 1;
- exec_map = kmem_suballoc(kernel_map, &minaddr, &maxaddr,
- (16*(ARG_MAX+(PAGE_SIZE*3))));
-
- /*
- * Finally, allocate mbuf pool. Since mclrefcnt is an off-size
- * we use the more space efficient malloc in place of kmem_alloc.
- */
- {
- vm_offset_t mb_map_size;
-
- mb_map_size = nmbufs * MSIZE + nmbclusters * MCLBYTES;
- mb_map_size = roundup2(mb_map_size, max(MCLBYTES, PAGE_SIZE));
- mclrefcnt = malloc(mb_map_size / MCLBYTES, M_MBUF, M_NOWAIT);
- bzero(mclrefcnt, mb_map_size / MCLBYTES);
- mb_map = kmem_suballoc(kmem_map, (vm_offset_t *)&mbutl, &maxaddr,
- mb_map_size);
- mb_map->system_map = 1;
- }
-
- /*
- * Initialize callouts
- */
- SLIST_INIT(&callfree);
- for (i = 0; i < ncallout; i++) {
- callout_init(&callout[i]);
- callout[i].c_flags = CALLOUT_LOCAL_ALLOC;
- SLIST_INSERT_HEAD(&callfree, &callout[i], c_links.sle);
- }
-
- for (i = 0; i < callwheelsize; i++) {
- TAILQ_INIT(&callwheel[i]);
- }
-
-#if defined(USERCONFIG)
- userconfig();
- cninit(); /* the preferred console may have changed */
-#endif
-
- printf("avail memory = %u (%uK bytes)\n", ptoa(cnt.v_free_count),
- ptoa(cnt.v_free_count) / 1024);
-
- /*
- * Set up buffers, so they can be used to read disk labels.
- */
- bufinit();
- vm_pager_bufferinit();
-
-#ifdef SMP
- /*
- * OK, enough kmem_alloc/malloc state should be up, lets get on with it!
- */
- mp_start(); /* fire up the APs and APICs */
- mp_announce();
-#endif /* SMP */
-}
-
-int
-register_netisr(num, handler)
- int num;
- netisr_t *handler;
-{
-
- if (num < 0 || num >= (sizeof(netisrs)/sizeof(*netisrs)) ) {
- printf("register_netisr: bad isr number: %d\n", num);
- return (EINVAL);
- }
- netisrs[num] = handler;
- return (0);
-}
-
-int
-unregister_netisr(num)
- int num;
-{
-
- if (num < 0 || num >= (sizeof(netisrs)/sizeof(*netisrs)) ) {
- printf("unregister_netisr: bad isr number: %d\n", num);
- return (EINVAL);
- }
- netisrs[num] = NULL;
- return (0);
-}
-
-/*
- * Send an interrupt to process.
- *
- * Stack is set up to allow sigcode stored
- * at top to call routine, followed by kcall
- * to sigreturn routine below. After sigreturn
- * resets the signal mask, the stack, and the
- * frame pointer, it returns to the user
- * specified pc, psl.
- */
-static void
-osendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
-{
- register struct proc *p = curproc;
- register struct trapframe *regs;
- register struct osigframe *fp;
- struct osigframe sf;
- struct sigacts *psp = p->p_sigacts;
- int oonstack;
-
- regs = p->p_md.md_regs;
- oonstack = (p->p_sigstk.ss_flags & SS_ONSTACK) ? 1 : 0;
-
- /* Allocate and validate space for the signal handler context. */
- if ((p->p_flag & P_ALTSTACK) && !oonstack &&
- SIGISMEMBER(psp->ps_sigonstack, sig)) {
- fp = (struct osigframe *)(p->p_sigstk.ss_sp +
- p->p_sigstk.ss_size - sizeof(struct osigframe));
- p->p_sigstk.ss_flags |= SS_ONSTACK;
- }
- else
- fp = (struct osigframe *)regs->tf_esp - 1;
-
- /*
- * grow() will return FALSE if the fp will not fit inside the stack
- * and the stack can not be grown. useracc will return FALSE
- * if access is denied.
- */
- if (grow_stack(p, (int)fp) == FALSE ||
- !useracc((caddr_t)fp, sizeof(struct osigframe), VM_PROT_WRITE)) {
- /*
- * Process has trashed its stack; give it an illegal
- * instruction to halt it in its tracks.
- */
- SIGACTION(p, SIGILL) = SIG_DFL;
- SIGDELSET(p->p_sigignore, SIGILL);
- SIGDELSET(p->p_sigcatch, SIGILL);
- SIGDELSET(p->p_sigmask, SIGILL);
- psignal(p, SIGILL);
- return;
- }
-
- /* Translate the signal if appropriate */
- if (p->p_sysent->sv_sigtbl) {
- if (sig <= p->p_sysent->sv_sigsize)
- sig = p->p_sysent->sv_sigtbl[_SIG_IDX(sig)];
- }
-
- /* Build the argument list for the signal handler. */
- sf.sf_signum = sig;
- sf.sf_scp = (register_t)&fp->sf_siginfo.si_sc;
- if (SIGISMEMBER(p->p_sigacts->ps_siginfo, sig)) {
- /* Signal handler installed with SA_SIGINFO. */
- sf.sf_arg2 = (register_t)&fp->sf_siginfo;
- sf.sf_siginfo.si_signo = sig;
- sf.sf_siginfo.si_code = code;
- sf.sf_ahu.sf_action = (__osiginfohandler_t *)catcher;
- }
- else {
- /* Old FreeBSD-style arguments. */
- sf.sf_arg2 = code;
- sf.sf_addr = regs->tf_err;
- sf.sf_ahu.sf_handler = catcher;
- }
-
- /* save scratch registers */
- sf.sf_siginfo.si_sc.sc_eax = regs->tf_eax;
- sf.sf_siginfo.si_sc.sc_ebx = regs->tf_ebx;
- sf.sf_siginfo.si_sc.sc_ecx = regs->tf_ecx;
- sf.sf_siginfo.si_sc.sc_edx = regs->tf_edx;
- sf.sf_siginfo.si_sc.sc_esi = regs->tf_esi;
- sf.sf_siginfo.si_sc.sc_edi = regs->tf_edi;
- sf.sf_siginfo.si_sc.sc_cs = regs->tf_cs;
- sf.sf_siginfo.si_sc.sc_ds = regs->tf_ds;
- sf.sf_siginfo.si_sc.sc_ss = regs->tf_ss;
- sf.sf_siginfo.si_sc.sc_es = regs->tf_es;
- sf.sf_siginfo.si_sc.sc_fs = regs->tf_fs;
- sf.sf_siginfo.si_sc.sc_gs = rgs();
- sf.sf_siginfo.si_sc.sc_isp = regs->tf_isp;
-
- /* Build the signal context to be used by sigreturn. */
- sf.sf_siginfo.si_sc.sc_onstack = oonstack;
- SIG2OSIG(*mask, sf.sf_siginfo.si_sc.sc_mask);
- sf.sf_siginfo.si_sc.sc_sp = regs->tf_esp;
- sf.sf_siginfo.si_sc.sc_fp = regs->tf_ebp;
- sf.sf_siginfo.si_sc.sc_pc = regs->tf_eip;
- sf.sf_siginfo.si_sc.sc_ps = regs->tf_eflags;
- sf.sf_siginfo.si_sc.sc_trapno = regs->tf_trapno;
- sf.sf_siginfo.si_sc.sc_err = regs->tf_err;
-
- /*
- * If we're a vm86 process, we want to save the segment registers.
- * We also change eflags to be our emulated eflags, not the actual
- * eflags.
- */
- if (regs->tf_eflags & PSL_VM) {
- struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs;
- struct vm86_kernel *vm86 = &p->p_addr->u_pcb.pcb_ext->ext_vm86;
-
- sf.sf_siginfo.si_sc.sc_gs = tf->tf_vm86_gs;
- sf.sf_siginfo.si_sc.sc_fs = tf->tf_vm86_fs;
- sf.sf_siginfo.si_sc.sc_es = tf->tf_vm86_es;
- sf.sf_siginfo.si_sc.sc_ds = tf->tf_vm86_ds;
-
- if (vm86->vm86_has_vme == 0)
- sf.sf_siginfo.si_sc.sc_ps =
- (tf->tf_eflags & ~(PSL_VIF | PSL_VIP))
- | (vm86->vm86_eflags & (PSL_VIF | PSL_VIP));
- /* see sendsig for comment */
- tf->tf_eflags &= ~(PSL_VM|PSL_NT|PSL_T|PSL_VIF|PSL_VIP);
- }
-
- /* Copy the sigframe out to the user's stack. */
- if (copyout(&sf, fp, sizeof(struct osigframe)) != 0) {
- /*
- * Something is wrong with the stack pointer.
- * ...Kill the process.
- */
- sigexit(p, SIGILL);
- }
-
- regs->tf_esp = (int)fp;
- regs->tf_eip = PS_STRINGS - szosigcode;
- regs->tf_cs = _ucodesel;
- regs->tf_ds = _udatasel;
- regs->tf_es = _udatasel;
- regs->tf_fs = _udatasel;
- load_gs(_udatasel);
- regs->tf_ss = _udatasel;
-}
-
-void
-sendsig(catcher, sig, mask, code)
- sig_t catcher;
- int sig;
- sigset_t *mask;
- u_long code;
-{
- struct proc *p = curproc;
- struct trapframe *regs;
- struct sigacts *psp = p->p_sigacts;
- struct sigframe sf, *sfp;
- int oonstack;
-
- if (SIGISMEMBER(psp->ps_osigset, sig)) {
- osendsig(catcher, sig, mask, code);
- return;
- }
-
- regs = p->p_md.md_regs;
- oonstack = (p->p_sigstk.ss_flags & SS_ONSTACK) ? 1 : 0;
-
- /* save user context */
- bzero(&sf, sizeof(struct sigframe));
- sf.sf_uc.uc_sigmask = *mask;
- sf.sf_uc.uc_stack = p->p_sigstk;
- sf.sf_uc.uc_mcontext.mc_onstack = oonstack;
- sf.sf_uc.uc_mcontext.mc_gs = rgs();
- bcopy(regs, &sf.sf_uc.uc_mcontext.mc_fs, sizeof(struct trapframe));
-
- /* Allocate and validate space for the signal handler context. */
- if ((p->p_flag & P_ALTSTACK) != 0 && !oonstack &&
- SIGISMEMBER(psp->ps_sigonstack, sig)) {
- sfp = (struct sigframe *)(p->p_sigstk.ss_sp +
- p->p_sigstk.ss_size - sizeof(struct sigframe));
- p->p_sigstk.ss_flags |= SS_ONSTACK;
- }
- else
- sfp = (struct sigframe *)regs->tf_esp - 1;
-
- /*
- * grow() will return FALSE if the sfp will not fit inside the stack
- * and the stack can not be grown. useracc will return FALSE if
- * access is denied.
- */
- if (grow_stack(p, (int)sfp) == FALSE ||
- !useracc((caddr_t)sfp, sizeof(struct sigframe), VM_PROT_WRITE)) {
- /*
- * Process has trashed its stack; give it an illegal
- * instruction to halt it in its tracks.
- */
-#ifdef DEBUG
- printf("process %d has trashed its stack\n", p->p_pid);
-#endif
- SIGACTION(p, SIGILL) = SIG_DFL;
- SIGDELSET(p->p_sigignore, SIGILL);
- SIGDELSET(p->p_sigcatch, SIGILL);
- SIGDELSET(p->p_sigmask, SIGILL);
- psignal(p, SIGILL);
- return;
- }
-
- /* Translate the signal is appropriate */
- if (p->p_sysent->sv_sigtbl) {
- if (sig <= p->p_sysent->sv_sigsize)
- sig = p->p_sysent->sv_sigtbl[_SIG_IDX(sig)];
- }
-
- /* Build the argument list for the signal handler. */
- sf.sf_signum = sig;
- sf.sf_ucontext = (register_t)&sfp->sf_uc;
- if (SIGISMEMBER(p->p_sigacts->ps_siginfo, sig)) {
- /* Signal handler installed with SA_SIGINFO. */
- sf.sf_siginfo = (register_t)&sfp->sf_si;
- sf.sf_ahu.sf_action = (__siginfohandler_t *)catcher;
-
- /* fill siginfo structure */
- sf.sf_si.si_signo = sig;
- sf.sf_si.si_code = code;
- sf.sf_si.si_addr = (void*)regs->tf_err;
- }
- else {
- /* Old FreeBSD-style arguments. */
- sf.sf_siginfo = code;
- sf.sf_addr = regs->tf_err;
- sf.sf_ahu.sf_handler = catcher;
- }
-
- /*
- * If we're a vm86 process, we want to save the segment registers.
- * We also change eflags to be our emulated eflags, not the actual
- * eflags.
- */
- if (regs->tf_eflags & PSL_VM) {
- struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs;
- struct vm86_kernel *vm86 = &p->p_addr->u_pcb.pcb_ext->ext_vm86;
-
- sf.sf_uc.uc_mcontext.mc_gs = tf->tf_vm86_gs;
- sf.sf_uc.uc_mcontext.mc_fs = tf->tf_vm86_fs;
- sf.sf_uc.uc_mcontext.mc_es = tf->tf_vm86_es;
- sf.sf_uc.uc_mcontext.mc_ds = tf->tf_vm86_ds;
-
- if (vm86->vm86_has_vme == 0)
- sf.sf_uc.uc_mcontext.mc_eflags =
- (tf->tf_eflags & ~(PSL_VIF | PSL_VIP)) |
- (vm86->vm86_eflags & (PSL_VIF | PSL_VIP));
-
- /*
- * We should never have PSL_T set when returning from vm86
- * mode. It may be set here if we deliver a signal before
- * getting to vm86 mode, so turn it off.
- *
- * Clear PSL_NT to inhibit T_TSSFLT faults on return from
- * syscalls made by the signal handler. This just avoids
- * wasting time for our lazy fixup of such faults. PSL_NT
- * does nothing in vm86 mode, but vm86 programs can set it
- * almost legitimately in probes for old cpu types.
- */
- tf->tf_eflags &= ~(PSL_VM|PSL_NT|PSL_T|PSL_VIF|PSL_VIP);
- }
-
- /*
- * Copy the sigframe out to the user's stack.
- */
- if (copyout(&sf, sfp, sizeof(struct sigframe)) != 0) {
- /*
- * Something is wrong with the stack pointer.
- * ...Kill the process.
- */
- sigexit(p, SIGILL);
- }
-
- regs->tf_esp = (int)sfp;
- regs->tf_eip = PS_STRINGS - *(p->p_sysent->sv_szsigcode);
- regs->tf_cs = _ucodesel;
- regs->tf_ds = _udatasel;
- regs->tf_es = _udatasel;
- regs->tf_fs = _udatasel;
- load_gs(_udatasel);
- regs->tf_ss = _udatasel;
-}
-
-/*
- * System call to cleanup state after a signal
- * has been taken. Reset signal mask and
- * stack state from context left by sendsig (above).
- * Return to previous pc and psl as specified by
- * context left by sendsig. Check carefully to
- * make sure that the user has not modified the
- * state to gain improper privileges.
- */
-#define EFL_SECURE(ef, oef) ((((ef) ^ (oef)) & ~PSL_USERCHANGE) == 0)
-#define CS_SECURE(cs) (ISPL(cs) == SEL_UPL)
-
-int
-osigreturn(p, uap)
- struct proc *p;
- struct osigreturn_args /* {
- struct osigcontext *sigcntxp;
- } */ *uap;
-{
- register struct osigcontext *scp;
- register struct trapframe *regs = p->p_md.md_regs;
- int eflags;
-
- scp = uap->sigcntxp;
-
- if (!useracc((caddr_t)scp, sizeof (struct osigcontext), VM_PROT_READ))
- return(EFAULT);
-
- eflags = scp->sc_ps;
- if (eflags & PSL_VM) {
- struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs;
- struct vm86_kernel *vm86;
-
- /*
- * if pcb_ext == 0 or vm86_inited == 0, the user hasn't
- * set up the vm86 area, and we can't enter vm86 mode.
- */
- if (p->p_addr->u_pcb.pcb_ext == 0)
- return (EINVAL);
- vm86 = &p->p_addr->u_pcb.pcb_ext->ext_vm86;
- if (vm86->vm86_inited == 0)
- return (EINVAL);
-
- /* go back to user mode if both flags are set */
- if ((eflags & PSL_VIP) && (eflags & PSL_VIF))
- trapsignal(p, SIGBUS, 0);
-
- if (vm86->vm86_has_vme) {
- eflags = (tf->tf_eflags & ~VME_USERCHANGE) |
- (eflags & VME_USERCHANGE) | PSL_VM;
- } else {
- vm86->vm86_eflags = eflags; /* save VIF, VIP */
- eflags = (tf->tf_eflags & ~VM_USERCHANGE) | (eflags & VM_USERCHANGE) | PSL_VM;
- }
- tf->tf_vm86_ds = scp->sc_ds;
- tf->tf_vm86_es = scp->sc_es;
- tf->tf_vm86_fs = scp->sc_fs;
- tf->tf_vm86_gs = scp->sc_gs;
- tf->tf_ds = _udatasel;
- tf->tf_es = _udatasel;
- tf->tf_fs = _udatasel;
- } else {
- /*
- * Don't allow users to change privileged or reserved flags.
- */
- /*
- * XXX do allow users to change the privileged flag PSL_RF.
- * The cpu sets PSL_RF in tf_eflags for faults. Debuggers
- * should sometimes set it there too. tf_eflags is kept in
- * the signal context during signal handling and there is no
- * other place to remember it, so the PSL_RF bit may be
- * corrupted by the signal handler without us knowing.
- * Corruption of the PSL_RF bit at worst causes one more or
- * one less debugger trap, so allowing it is fairly harmless.
- */
- if (!EFL_SECURE(eflags & ~PSL_RF, regs->tf_eflags & ~PSL_RF)) {
- return(EINVAL);
- }
-
- /*
- * Don't allow users to load a valid privileged %cs. Let the
- * hardware check for invalid selectors, excess privilege in
- * other selectors, invalid %eip's and invalid %esp's.
- */
- if (!CS_SECURE(scp->sc_cs)) {
- trapsignal(p, SIGBUS, T_PROTFLT);
- return(EINVAL);
- }
- regs->tf_ds = scp->sc_ds;
- regs->tf_es = scp->sc_es;
- regs->tf_fs = scp->sc_fs;
- }
-
- /* restore scratch registers */
- regs->tf_eax = scp->sc_eax;
- regs->tf_ebx = scp->sc_ebx;
- regs->tf_ecx = scp->sc_ecx;
- regs->tf_edx = scp->sc_edx;
- regs->tf_esi = scp->sc_esi;
- regs->tf_edi = scp->sc_edi;
- regs->tf_cs = scp->sc_cs;
- regs->tf_ss = scp->sc_ss;
- regs->tf_isp = scp->sc_isp;
-
- if (scp->sc_onstack & 01)
- p->p_sigstk.ss_flags |= SS_ONSTACK;
- else
- p->p_sigstk.ss_flags &= ~SS_ONSTACK;
-
- SIGSETOLD(p->p_sigmask, scp->sc_mask);
- SIG_CANTMASK(p->p_sigmask);
- regs->tf_ebp = scp->sc_fp;
- regs->tf_esp = scp->sc_sp;
- regs->tf_eip = scp->sc_pc;
- regs->tf_eflags = eflags;
- return(EJUSTRETURN);
-}
-
-int
-sigreturn(p, uap)
- struct proc *p;
- struct sigreturn_args /* {
- ucontext_t *sigcntxp;
- } */ *uap;
-{
- struct trapframe *regs;
- ucontext_t *ucp;
- int cs, eflags;
-
- ucp = uap->sigcntxp;
-
- if (!useracc((caddr_t)ucp, sizeof(struct osigcontext), VM_PROT_READ))
- return (EFAULT);
- if (((struct osigcontext *)ucp)->sc_trapno == 0x01d516)
- return (osigreturn(p, (struct osigreturn_args *)uap));
-
- /*
- * Since ucp is not an osigcontext but a ucontext_t, we have to
- * check again if all of it is accessible. A ucontext_t is
- * much larger, so instead of just checking for the pointer
- * being valid for the size of an osigcontext, now check for
- * it being valid for a whole, new-style ucontext_t.
- */
- if (!useracc((caddr_t)ucp, sizeof(ucontext_t), VM_PROT_READ))
- return (EFAULT);
-
- regs = p->p_md.md_regs;
- eflags = ucp->uc_mcontext.mc_eflags;
-
- if (eflags & PSL_VM) {
- struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs;
- struct vm86_kernel *vm86;
-
- /*
- * if pcb_ext == 0 or vm86_inited == 0, the user hasn't
- * set up the vm86 area, and we can't enter vm86 mode.
- */
- if (p->p_addr->u_pcb.pcb_ext == 0)
- return (EINVAL);
- vm86 = &p->p_addr->u_pcb.pcb_ext->ext_vm86;
- if (vm86->vm86_inited == 0)
- return (EINVAL);
-
- /* go back to user mode if both flags are set */
- if ((eflags & PSL_VIP) && (eflags & PSL_VIF))
- trapsignal(p, SIGBUS, 0);
-
- if (vm86->vm86_has_vme) {
- eflags = (tf->tf_eflags & ~VME_USERCHANGE) |
- (eflags & VME_USERCHANGE) | PSL_VM;
- } else {
- vm86->vm86_eflags = eflags; /* save VIF, VIP */
- eflags = (tf->tf_eflags & ~VM_USERCHANGE) | (eflags & VM_USERCHANGE) | PSL_VM;
- }
- bcopy(&ucp->uc_mcontext.mc_fs, tf, sizeof(struct trapframe));
- tf->tf_eflags = eflags;
- tf->tf_vm86_ds = tf->tf_ds;
- tf->tf_vm86_es = tf->tf_es;
- tf->tf_vm86_fs = tf->tf_fs;
- tf->tf_vm86_gs = ucp->uc_mcontext.mc_gs;
- tf->tf_ds = _udatasel;
- tf->tf_es = _udatasel;
- tf->tf_fs = _udatasel;
- } else {
- /*
- * Don't allow users to change privileged or reserved flags.
- */
- /*
- * XXX do allow users to change the privileged flag PSL_RF.
- * The cpu sets PSL_RF in tf_eflags for faults. Debuggers
- * should sometimes set it there too. tf_eflags is kept in
- * the signal context during signal handling and there is no
- * other place to remember it, so the PSL_RF bit may be
- * corrupted by the signal handler without us knowing.
- * Corruption of the PSL_RF bit at worst causes one more or
- * one less debugger trap, so allowing it is fairly harmless.
- */
- if (!EFL_SECURE(eflags & ~PSL_RF, regs->tf_eflags & ~PSL_RF)) {
- printf("sigreturn: eflags = 0x%x\n", eflags);
- return(EINVAL);
- }
-
- /*
- * Don't allow users to load a valid privileged %cs. Let the
- * hardware check for invalid selectors, excess privilege in
- * other selectors, invalid %eip's and invalid %esp's.
- */
- cs = ucp->uc_mcontext.mc_cs;
- if (!CS_SECURE(cs)) {
- printf("sigreturn: cs = 0x%x\n", cs);
- trapsignal(p, SIGBUS, T_PROTFLT);
- return(EINVAL);
- }
- bcopy(&ucp->uc_mcontext.mc_fs, regs, sizeof(struct trapframe));
- }
-
- if (ucp->uc_mcontext.mc_onstack & 1)
- p->p_sigstk.ss_flags |= SS_ONSTACK;
- else
- p->p_sigstk.ss_flags &= ~SS_ONSTACK;
-
- p->p_sigmask = ucp->uc_sigmask;
- SIG_CANTMASK(p->p_sigmask);
- return(EJUSTRETURN);
-}
-
-/*
- * Machine dependent boot() routine
- *
- * I haven't seen anything to put here yet
- * Possibly some stuff might be grafted back here from boot()
- */
-void
-cpu_boot(int howto)
-{
-}
-
-/*
- * Shutdown the CPU as much as possible
- */
-void
-cpu_halt(void)
-{
- for (;;)
- __asm__ ("hlt");
-}
-
-/*
- * Clear registers on exec
- */
-void
-setregs(p, entry, stack, ps_strings)
- struct proc *p;
- u_long entry;
- u_long stack;
- u_long ps_strings;
-{
- struct trapframe *regs = p->p_md.md_regs;
- struct pcb *pcb = &p->p_addr->u_pcb;
-
-#ifdef USER_LDT
- /* was i386_user_cleanup() in NetBSD */
- user_ldt_free(pcb);
-#endif
-
- bzero((char *)regs, sizeof(struct trapframe));
- regs->tf_eip = entry;
- regs->tf_esp = stack;
- regs->tf_eflags = PSL_USER | (regs->tf_eflags & PSL_T);
- regs->tf_ss = _udatasel;
- regs->tf_ds = _udatasel;
- regs->tf_es = _udatasel;
- regs->tf_fs = _udatasel;
- regs->tf_cs = _ucodesel;
-
- /* PS_STRINGS value for BSD/OS binaries. It is 0 for non-BSD/OS. */
- regs->tf_ebx = ps_strings;
-
- /* reset %gs as well */
- if (pcb == curpcb)
- load_gs(_udatasel);
- else
- pcb->pcb_gs = _udatasel;
-
- /*
- * Reset the hardware debug registers if they were in use.
- * They won't have any meaning for the newly exec'd process.
- */
- if (pcb->pcb_flags & PCB_DBREGS) {
- pcb->pcb_dr0 = 0;
- pcb->pcb_dr1 = 0;
- pcb->pcb_dr2 = 0;
- pcb->pcb_dr3 = 0;
- pcb->pcb_dr6 = 0;
- pcb->pcb_dr7 = 0;
- if (pcb == curpcb) {
- /*
- * Clear the debug registers on the running
- * CPU, otherwise they will end up affecting
- * the next process we switch to.
- */
- reset_dbregs();
- }
- pcb->pcb_flags &= ~PCB_DBREGS;
- }
-
- /*
- * Initialize the math emulator (if any) for the current process.
- * Actually, just clear the bit that says that the emulator has
- * been initialized. Initialization is delayed until the process
- * traps to the emulator (if it is done at all) mainly because
- * emulators don't provide an entry point for initialization.
- */
- p->p_addr->u_pcb.pcb_flags &= ~FP_SOFTFP;
-
- /*
- * Arrange to trap the next npx or `fwait' instruction (see npx.c
- * for why fwait must be trapped at least if there is an npx or an
- * emulator). This is mainly to handle the case where npx0 is not
- * configured, since the npx routines normally set up the trap
- * otherwise. It should be done only at boot time, but doing it
- * here allows modifying `npx_exists' for testing the emulator on
- * systems with an npx.
- */
- load_cr0(rcr0() | CR0_MP | CR0_TS);
-
-#if NNPX > 0
- /* Initialize the npx (if any) for the current process. */
- npxinit(__INITIAL_NPXCW__);
-#endif
-
- /*
- * XXX - Linux emulator
- * Make sure sure edx is 0x0 on entry. Linux binaries depend
- * on it.
- */
- p->p_retval[1] = 0;
-}
-
-static int
-sysctl_machdep_adjkerntz SYSCTL_HANDLER_ARGS
-{
- int error;
- error = sysctl_handle_int(oidp, oidp->oid_arg1, oidp->oid_arg2,
- req);
- if (!error && req->newptr)
- resettodr();
- return (error);
-}
-
-SYSCTL_PROC(_machdep, CPU_ADJKERNTZ, adjkerntz, CTLTYPE_INT|CTLFLAG_RW,
- &adjkerntz, 0, sysctl_machdep_adjkerntz, "I", "");
-
-SYSCTL_INT(_machdep, CPU_DISRTCSET, disable_rtc_set,
- CTLFLAG_RW, &disable_rtc_set, 0, "");
-
-SYSCTL_STRUCT(_machdep, CPU_BOOTINFO, bootinfo,
- CTLFLAG_RD, &bootinfo, bootinfo, "");
-
-SYSCTL_INT(_machdep, CPU_WALLCLOCK, wall_cmos_clock,
- CTLFLAG_RW, &wall_cmos_clock, 0, "");
-
-/*
- * Initialize 386 and configure to run kernel
- */
-
-/*
- * Initialize segments & interrupt table
- */
-
-int _default_ldt;
-#ifdef SMP
-union descriptor gdt[NGDT * NCPU]; /* global descriptor table */
-#else
-union descriptor gdt[NGDT]; /* global descriptor table */
-#endif
-static struct gate_descriptor idt0[NIDT];
-struct gate_descriptor *idt = &idt0[0]; /* interrupt descriptor table */
-union descriptor ldt[NLDT]; /* local descriptor table */
-#ifdef SMP
-/* table descriptors - used to load tables by microp */
-struct region_descriptor r_gdt, r_idt;
-#endif
-
-#ifndef SMP
-extern struct segment_descriptor common_tssd, *tss_gdt;
-#endif
-int private_tss; /* flag indicating private tss */
-
-#if defined(I586_CPU) && !defined(NO_F00F_HACK)
-extern int has_f00f_bug;
-#endif
-
-static struct i386tss dblfault_tss;
-static char dblfault_stack[PAGE_SIZE];
-
-extern struct user *proc0paddr;
-
-
-/* software prototypes -- in more palatable form */
-struct soft_segment_descriptor gdt_segs[] = {
-/* GNULL_SEL 0 Null Descriptor */
-{ 0x0, /* segment base address */
- 0x0, /* length */
- 0, /* segment type */
- 0, /* segment descriptor priority level */
- 0, /* segment descriptor present */
- 0, 0,
- 0, /* default 32 vs 16 bit size */
- 0 /* limit granularity (byte/page units)*/ },
-/* GCODE_SEL 1 Code Descriptor for kernel */
-{ 0x0, /* segment base address */
- 0xfffff, /* length - all address space */
- SDT_MEMERA, /* segment type */
- 0, /* segment descriptor priority level */
- 1, /* segment descriptor present */
- 0, 0,
- 1, /* default 32 vs 16 bit size */
- 1 /* limit granularity (byte/page units)*/ },
-/* GDATA_SEL 2 Data Descriptor for kernel */
-{ 0x0, /* segment base address */
- 0xfffff, /* length - all address space */
- SDT_MEMRWA, /* segment type */
- 0, /* segment descriptor priority level */
- 1, /* segment descriptor present */
- 0, 0,
- 1, /* default 32 vs 16 bit size */
- 1 /* limit granularity (byte/page units)*/ },
-/* GPRIV_SEL 3 SMP Per-Processor Private Data Descriptor */
-{ 0x0, /* segment base address */
- 0xfffff, /* length - all address space */
- SDT_MEMRWA, /* segment type */
- 0, /* segment descriptor priority level */
- 1, /* segment descriptor present */
- 0, 0,
- 1, /* default 32 vs 16 bit size */
- 1 /* limit granularity (byte/page units)*/ },
-/* GPROC0_SEL 4 Proc 0 Tss Descriptor */
-{
- 0x0, /* segment base address */
- sizeof(struct i386tss)-1,/* length - all address space */
- SDT_SYS386TSS, /* segment type */
- 0, /* segment descriptor priority level */
- 1, /* segment descriptor present */
- 0, 0,
- 0, /* unused - default 32 vs 16 bit size */
- 0 /* limit granularity (byte/page units)*/ },
-/* GLDT_SEL 5 LDT Descriptor */
-{ (int) ldt, /* segment base address */
- sizeof(ldt)-1, /* length - all address space */
- SDT_SYSLDT, /* segment type */
- SEL_UPL, /* segment descriptor priority level */
- 1, /* segment descriptor present */
- 0, 0,
- 0, /* unused - default 32 vs 16 bit size */
- 0 /* limit granularity (byte/page units)*/ },
-/* GUSERLDT_SEL 6 User LDT Descriptor per process */
-{ (int) ldt, /* segment base address */
- (512 * sizeof(union descriptor)-1), /* length */
- SDT_SYSLDT, /* segment type */
- 0, /* segment descriptor priority level */
- 1, /* segment descriptor present */
- 0, 0,
- 0, /* unused - default 32 vs 16 bit size */
- 0 /* limit granularity (byte/page units)*/ },
-/* GTGATE_SEL 7 Null Descriptor - Placeholder */
-{ 0x0, /* segment base address */
- 0x0, /* length - all address space */
- 0, /* segment type */
- 0, /* segment descriptor priority level */
- 0, /* segment descriptor present */
- 0, 0,
- 0, /* default 32 vs 16 bit size */
- 0 /* limit granularity (byte/page units)*/ },
-/* GBIOSLOWMEM_SEL 8 BIOS access to realmode segment 0x40, must be #8 in GDT */
-{ 0x400, /* segment base address */
- 0xfffff, /* length */
- SDT_MEMRWA, /* segment type */
- 0, /* segment descriptor priority level */
- 1, /* segment descriptor present */
- 0, 0,
- 1, /* default 32 vs 16 bit size */
- 1 /* limit granularity (byte/page units)*/ },
-/* GPANIC_SEL 9 Panic Tss Descriptor */
-{ (int) &dblfault_tss, /* segment base address */
- sizeof(struct i386tss)-1,/* length - all address space */
- SDT_SYS386TSS, /* segment type */
- 0, /* segment descriptor priority level */
- 1, /* segment descriptor present */
- 0, 0,
- 0, /* unused - default 32 vs 16 bit size */
- 0 /* limit granularity (byte/page units)*/ },
-/* GBIOSCODE32_SEL 10 BIOS 32-bit interface (32bit Code) */
-{ 0, /* segment base address (overwritten) */
- 0xfffff, /* length */
- SDT_MEMERA, /* segment type */
- 0, /* segment descriptor priority level */
- 1, /* segment descriptor present */
- 0, 0,
- 0, /* default 32 vs 16 bit size */
- 1 /* limit granularity (byte/page units)*/ },
-/* GBIOSCODE16_SEL 11 BIOS 32-bit interface (16bit Code) */
-{ 0, /* segment base address (overwritten) */
- 0xfffff, /* length */
- SDT_MEMERA, /* segment type */
- 0, /* segment descriptor priority level */
- 1, /* segment descriptor present */
- 0, 0,
- 0, /* default 32 vs 16 bit size */
- 1 /* limit granularity (byte/page units)*/ },
-/* GBIOSDATA_SEL 12 BIOS 32-bit interface (Data) */
-{ 0, /* segment base address (overwritten) */
- 0xfffff, /* length */
- SDT_MEMRWA, /* segment type */
- 0, /* segment descriptor priority level */
- 1, /* segment descriptor present */
- 0, 0,
- 1, /* default 32 vs 16 bit size */
- 1 /* limit granularity (byte/page units)*/ },
-/* GBIOSUTIL_SEL 13 BIOS 16-bit interface (Utility) */
-{ 0, /* segment base address (overwritten) */
- 0xfffff, /* length */
- SDT_MEMRWA, /* segment type */
- 0, /* segment descriptor priority level */
- 1, /* segment descriptor present */
- 0, 0,
- 0, /* default 32 vs 16 bit size */
- 1 /* limit granularity (byte/page units)*/ },
-/* GBIOSARGS_SEL 14 BIOS 16-bit interface (Arguments) */
-{ 0, /* segment base address (overwritten) */
- 0xfffff, /* length */
- SDT_MEMRWA, /* segment type */
- 0, /* segment descriptor priority level */
- 1, /* segment descriptor present */
- 0, 0,
- 0, /* default 32 vs 16 bit size */
- 1 /* limit granularity (byte/page units)*/ },
-};
-
-static struct soft_segment_descriptor ldt_segs[] = {
- /* Null Descriptor - overwritten by call gate */
-{ 0x0, /* segment base address */
- 0x0, /* length - all address space */
- 0, /* segment type */
- 0, /* segment descriptor priority level */
- 0, /* segment descriptor present */
- 0, 0,
- 0, /* default 32 vs 16 bit size */
- 0 /* limit granularity (byte/page units)*/ },
- /* Null Descriptor - overwritten by call gate */
-{ 0x0, /* segment base address */
- 0x0, /* length - all address space */
- 0, /* segment type */
- 0, /* segment descriptor priority level */
- 0, /* segment descriptor present */
- 0, 0,
- 0, /* default 32 vs 16 bit size */
- 0 /* limit granularity (byte/page units)*/ },
- /* Null Descriptor - overwritten by call gate */
-{ 0x0, /* segment base address */
- 0x0, /* length - all address space */
- 0, /* segment type */
- 0, /* segment descriptor priority level */
- 0, /* segment descriptor present */
- 0, 0,
- 0, /* default 32 vs 16 bit size */
- 0 /* limit granularity (byte/page units)*/ },
- /* Code Descriptor for user */
-{ 0x0, /* segment base address */
- 0xfffff, /* length - all address space */
- SDT_MEMERA, /* segment type */
- SEL_UPL, /* segment descriptor priority level */
- 1, /* segment descriptor present */
- 0, 0,
- 1, /* default 32 vs 16 bit size */
- 1 /* limit granularity (byte/page units)*/ },
- /* Null Descriptor - overwritten by call gate */
-{ 0x0, /* segment base address */
- 0x0, /* length - all address space */
- 0, /* segment type */
- 0, /* segment descriptor priority level */
- 0, /* segment descriptor present */
- 0, 0,
- 0, /* default 32 vs 16 bit size */
- 0 /* limit granularity (byte/page units)*/ },
- /* Data Descriptor for user */
-{ 0x0, /* segment base address */
- 0xfffff, /* length - all address space */
- SDT_MEMRWA, /* segment type */
- SEL_UPL, /* segment descriptor priority level */
- 1, /* segment descriptor present */
- 0, 0,
- 1, /* default 32 vs 16 bit size */
- 1 /* limit granularity (byte/page units)*/ },
-};
-
-void
-setidt(idx, func, typ, dpl, selec)
- int idx;
- inthand_t *func;
- int typ;
- int dpl;
- int selec;
-{
- struct gate_descriptor *ip;
-
- ip = idt + idx;
- ip->gd_looffset = (int)func;
- ip->gd_selector = selec;
- ip->gd_stkcpy = 0;
- ip->gd_xx = 0;
- ip->gd_type = typ;
- ip->gd_dpl = dpl;
- ip->gd_p = 1;
- ip->gd_hioffset = ((int)func)>>16 ;
-}
-
-#define IDTVEC(name) __CONCAT(X,name)
-
-extern inthand_t
- IDTVEC(div), IDTVEC(dbg), IDTVEC(nmi), IDTVEC(bpt), IDTVEC(ofl),
- IDTVEC(bnd), IDTVEC(ill), IDTVEC(dna), IDTVEC(fpusegm),
- IDTVEC(tss), IDTVEC(missing), IDTVEC(stk), IDTVEC(prot),
- IDTVEC(page), IDTVEC(mchk), IDTVEC(rsvd), IDTVEC(fpu), IDTVEC(align),
- IDTVEC(syscall), IDTVEC(int0x80_syscall);
-
-void
-sdtossd(sd, ssd)
- struct segment_descriptor *sd;
- struct soft_segment_descriptor *ssd;
-{
- ssd->ssd_base = (sd->sd_hibase << 24) | sd->sd_lobase;
- ssd->ssd_limit = (sd->sd_hilimit << 16) | sd->sd_lolimit;
- ssd->ssd_type = sd->sd_type;
- ssd->ssd_dpl = sd->sd_dpl;
- ssd->ssd_p = sd->sd_p;
- ssd->ssd_def32 = sd->sd_def32;
- ssd->ssd_gran = sd->sd_gran;
-}
-
-#define PHYSMAP_SIZE (2 * 8)
-
-/*
- * Populate the (physmap) array with base/bound pairs describing the
- * available physical memory in the system, then test this memory and
- * build the phys_avail array describing the actually-available memory.
- *
- * If we cannot accurately determine the physical memory map, then use
- * value from the 0xE801 call, and failing that, the RTC.
- *
- * Total memory size may be set by the kernel environment variable
- * hw.physmem or the compile-time define MAXMEM.
- */
-static void
-getmemsize(int first)
-{
- int i, physmap_idx, pa_indx;
- u_int basemem, extmem;
- struct vm86frame vmf;
- struct vm86context vmc;
- vm_offset_t pa, physmap[PHYSMAP_SIZE];
- pt_entry_t pte;
- const char *cp;
- struct {
- u_int64_t base;
- u_int64_t length;
- u_int32_t type;
- } *smap;
-
- bzero(&vmf, sizeof(struct vm86frame));
- bzero(physmap, sizeof(physmap));
-
- /*
- * Perform "base memory" related probes & setup
- */
- vm86_intcall(0x12, &vmf);
- basemem = vmf.vmf_ax;
- if (basemem > 640) {
- printf("Preposterous BIOS basemem of %uK, truncating to 640K\n",
- basemem);
- basemem = 640;
- }
-
- /*
- * XXX if biosbasemem is now < 640, there is a `hole'
- * between the end of base memory and the start of
- * ISA memory. The hole may be empty or it may
- * contain BIOS code or data. Map it read/write so
- * that the BIOS can write to it. (Memory from 0 to
- * the physical end of the kernel is mapped read-only
- * to begin with and then parts of it are remapped.
- * The parts that aren't remapped form holes that
- * remain read-only and are unused by the kernel.
- * The base memory area is below the physical end of
- * the kernel and right now forms a read-only hole.
- * The part of it from PAGE_SIZE to
- * (trunc_page(biosbasemem * 1024) - 1) will be
- * remapped and used by the kernel later.)
- *
- * This code is similar to the code used in
- * pmap_mapdev, but since no memory needs to be
- * allocated we simply change the mapping.
- */
- for (pa = trunc_page(basemem * 1024);
- pa < ISA_HOLE_START; pa += PAGE_SIZE) {
- pte = (pt_entry_t)vtopte(pa + KERNBASE);
- *pte = pa | PG_RW | PG_V;
- }
-
- /*
- * if basemem != 640, map pages r/w into vm86 page table so
- * that the bios can scribble on it.
- */
- pte = (pt_entry_t)vm86paddr;
- for (i = basemem / 4; i < 160; i++)
- pte[i] = (i << PAGE_SHIFT) | PG_V | PG_RW | PG_U;
-
- /*
- * map page 1 R/W into the kernel page table so we can use it
- * as a buffer. The kernel will unmap this page later.
- */
- pte = (pt_entry_t)vtopte(KERNBASE + (1 << PAGE_SHIFT));
- *pte = (1 << PAGE_SHIFT) | PG_RW | PG_V;
-
- /*
- * get memory map with INT 15:E820
- */
-#define SMAPSIZ sizeof(*smap)
-#define SMAP_SIG 0x534D4150 /* 'SMAP' */
-
- vmc.npages = 0;
- smap = (void *)vm86_addpage(&vmc, 1, KERNBASE + (1 << PAGE_SHIFT));
- vm86_getptr(&vmc, (vm_offset_t)smap, &vmf.vmf_es, &vmf.vmf_di);
-
- physmap_idx = 0;
- vmf.vmf_ebx = 0;
- do {
- vmf.vmf_eax = 0xE820;
- vmf.vmf_edx = SMAP_SIG;
- vmf.vmf_ecx = SMAPSIZ;
- i = vm86_datacall(0x15, &vmf, &vmc);
- if (i || vmf.vmf_eax != SMAP_SIG)
- break;
- if (boothowto & RB_VERBOSE)
- printf("SMAP type=%02x base=%08x %08x len=%08x %08x\n",
- smap->type,
- *(u_int32_t *)((char *)&smap->base + 4),
- (u_int32_t)smap->base,
- *(u_int32_t *)((char *)&smap->length + 4),
- (u_int32_t)smap->length);
-
- if (smap->type != 0x01)
- goto next_run;
-
- if (smap->length == 0)
- goto next_run;
-
- if (smap->base >= 0xffffffff) {
- printf("%uK of memory above 4GB ignored\n",
- (u_int)(smap->length / 1024));
- goto next_run;
- }
-
- for (i = 0; i <= physmap_idx; i += 2) {
- if (smap->base < physmap[i + 1]) {
- if (boothowto & RB_VERBOSE)
- printf(
- "Overlapping or non-montonic memory region, ignoring second region\n");
- goto next_run;
- }
- }
-
- if (smap->base == physmap[physmap_idx + 1]) {
- physmap[physmap_idx + 1] += smap->length;
- goto next_run;
- }
-
- physmap_idx += 2;
- if (physmap_idx == PHYSMAP_SIZE) {
- printf(
- "Too many segments in the physical address map, giving up\n");
- break;
- }
- physmap[physmap_idx] = smap->base;
- physmap[physmap_idx + 1] = smap->base + smap->length;
-next_run:
- } while (vmf.vmf_ebx != 0);
-
- if (physmap[1] != 0)
- goto physmap_done;
-
- /*
- * If we failed above, try memory map with INT 15:E801
- */
- vmf.vmf_ax = 0xE801;
- if (vm86_intcall(0x15, &vmf) == 0) {
- extmem = vmf.vmf_cx + vmf.vmf_dx * 64;
- } else {
-#if 0
- vmf.vmf_ah = 0x88;
- vm86_intcall(0x15, &vmf);
- extmem = vmf.vmf_ax;
-#else
- /*
- * Prefer the RTC value for extended memory.
- */
- extmem = rtcin(RTC_EXTLO) + (rtcin(RTC_EXTHI) << 8);
-#endif
- }
-
- /*
- * Special hack for chipsets that still remap the 384k hole when
- * there's 16MB of memory - this really confuses people that
- * are trying to use bus mastering ISA controllers with the
- * "16MB limit"; they only have 16MB, but the remapping puts
- * them beyond the limit.
- *
- * If extended memory is between 15-16MB (16-17MB phys address range),
- * chop it to 15MB.
- */
- if ((extmem > 15 * 1024) && (extmem < 16 * 1024))
- extmem = 15 * 1024;
-
- physmap[0] = 0;
- physmap[1] = basemem * 1024;
- physmap_idx = 2;
- physmap[physmap_idx] = 0x100000;
- physmap[physmap_idx + 1] = physmap[physmap_idx] + extmem * 1024;
-
-physmap_done:
- /*
- * Now, physmap contains a map of physical memory.
- */
-
-#ifdef SMP
- /* make hole for AP bootstrap code */
- physmap[1] = mp_bootaddress(physmap[1] / 1024);
-
- /* look for the MP hardware - needed for apic addresses */
- mp_probe();
-#endif
-
- /*
- * Maxmem isn't the "maximum memory", it's one larger than the
- * highest page of the physical address space. It should be
- * called something like "Maxphyspage". We may adjust this
- * based on ``hw.physmem'' and the results of the memory test.
- */
- Maxmem = atop(physmap[physmap_idx + 1]);
-
-#ifdef MAXMEM
- Maxmem = MAXMEM / 4;
-#endif
-
- /*
- * hw.maxmem is a size in bytes; we also allow k, m, and g suffixes
- * for the appropriate modifiers. This overrides MAXMEM.
- */
- if ((cp = getenv("hw.physmem")) != NULL) {
- u_int64_t AllowMem, sanity;
- char *ep;
-
- sanity = AllowMem = strtouq(cp, &ep, 0);
- if ((ep != cp) && (*ep != 0)) {
- switch(*ep) {
- case 'g':
- case 'G':
- AllowMem <<= 10;
- case 'm':
- case 'M':
- AllowMem <<= 10;
- case 'k':
- case 'K':
- AllowMem <<= 10;
- break;
- default:
- AllowMem = sanity = 0;
- }
- if (AllowMem < sanity)
- AllowMem = 0;
- }
- if (AllowMem == 0)
- printf("Ignoring invalid memory size of '%s'\n", cp);
- else
- Maxmem = atop(AllowMem);
- }
-
- if (atop(physmap[physmap_idx + 1]) != Maxmem &&
- (boothowto & RB_VERBOSE))
- printf("Physical memory use set to %uK\n", Maxmem * 4);
-
- /*
- * If Maxmem has been increased beyond what the system has detected,
- * extend the last memory segment to the new limit.
- */
- if (atop(physmap[physmap_idx + 1]) < Maxmem)
- physmap[physmap_idx + 1] = ptoa(Maxmem);
-
- /* call pmap initialization to make new kernel address space */
- pmap_bootstrap(first, 0);
-
- /*
- * Size up each available chunk of physical memory.
- */
- physmap[0] = PAGE_SIZE; /* mask off page 0 */
- pa_indx = 0;
- phys_avail[pa_indx++] = physmap[0];
- phys_avail[pa_indx] = physmap[0];
-#if 0
- pte = (pt_entry_t)vtopte(KERNBASE);
-#else
- pte = (pt_entry_t)CMAP1;
-#endif
-
- /*
- * physmap is in bytes, so when converting to page boundaries,
- * round up the start address and round down the end address.
- */
- for (i = 0; i <= physmap_idx; i += 2) {
- vm_offset_t end;
-
- end = ptoa(Maxmem);
- if (physmap[i + 1] < end)
- end = trunc_page(physmap[i + 1]);
- for (pa = round_page(physmap[i]); pa < end; pa += PAGE_SIZE) {
- int tmp, page_bad;
-#if 0
- int *ptr = 0;
-#else
- int *ptr = (int *)CADDR1;
-#endif
-
- /*
- * block out kernel memory as not available.
- */
- if (pa >= 0x100000 && pa < first)
- continue;
-
- page_bad = FALSE;
-
- /*
- * map page into kernel: valid, read/write,non-cacheable
- */
- *pte = pa | PG_V | PG_RW | PG_N;
- invltlb();
-
- tmp = *(int *)ptr;
- /*
- * Test for alternating 1's and 0's
- */
- *(volatile int *)ptr = 0xaaaaaaaa;
- if (*(volatile int *)ptr != 0xaaaaaaaa) {
- page_bad = TRUE;
- }
- /*
- * Test for alternating 0's and 1's
- */
- *(volatile int *)ptr = 0x55555555;
- if (*(volatile int *)ptr != 0x55555555) {
- page_bad = TRUE;
- }
- /*
- * Test for all 1's
- */
- *(volatile int *)ptr = 0xffffffff;
- if (*(volatile int *)ptr != 0xffffffff) {
- page_bad = TRUE;
- }
- /*
- * Test for all 0's
- */
- *(volatile int *)ptr = 0x0;
- if (*(volatile int *)ptr != 0x0) {
- page_bad = TRUE;
- }
- /*
- * Restore original value.
- */
- *(int *)ptr = tmp;
-
- /*
- * Adjust array of valid/good pages.
- */
- if (page_bad == TRUE) {
- continue;
- }
- /*
- * If this good page is a continuation of the
- * previous set of good pages, then just increase
- * the end pointer. Otherwise start a new chunk.
- * Note that "end" points one higher than end,
- * making the range >= start and < end.
- * If we're also doing a speculative memory
- * test and we at or past the end, bump up Maxmem
- * so that we keep going. The first bad page
- * will terminate the loop.
- */
- if (phys_avail[pa_indx] == pa) {
- phys_avail[pa_indx] += PAGE_SIZE;
- } else {
- pa_indx++;
- if (pa_indx == PHYS_AVAIL_ARRAY_END) {
- printf("Too many holes in the physical address space, giving up\n");
- pa_indx--;
- break;
- }
- phys_avail[pa_indx++] = pa; /* start */
- phys_avail[pa_indx] = pa + PAGE_SIZE; /* end */
- }
- physmem++;
- }
- }
- *pte = 0;
- invltlb();
-
- /*
- * XXX
- * The last chunk must contain at least one page plus the message
- * buffer to avoid complicating other code (message buffer address
- * calculation, etc.).
- */
- while (phys_avail[pa_indx - 1] + PAGE_SIZE +
- round_page(MSGBUF_SIZE) >= phys_avail[pa_indx]) {
- physmem -= atop(phys_avail[pa_indx] - phys_avail[pa_indx - 1]);
- phys_avail[pa_indx--] = 0;
- phys_avail[pa_indx--] = 0;
- }
-
- Maxmem = atop(phys_avail[pa_indx]);
-
- /* Trim off space for the message buffer. */
- phys_avail[pa_indx] -= round_page(MSGBUF_SIZE);
-
- avail_end = phys_avail[pa_indx];
-}
-
-void
-init386(first)
- int first;
-{
- int x;
- struct gate_descriptor *gdp;
- int gsel_tss;
-#ifndef SMP
- /* table descriptors - used to load tables by microp */
- struct region_descriptor r_gdt, r_idt;
-#endif
- int off;
-
- /*
- * Prevent lowering of the ipl if we call tsleep() early.
- */
- safepri = cpl;
-
- proc0.p_addr = proc0paddr;
-
- atdevbase = ISA_HOLE_START + KERNBASE;
-
- if (bootinfo.bi_modulep) {
- preload_metadata = (caddr_t)bootinfo.bi_modulep + KERNBASE;
- preload_bootstrap_relocate(KERNBASE);
- }
- if (bootinfo.bi_envp)
- kern_envp = (caddr_t)bootinfo.bi_envp + KERNBASE;
-
- /*
- * make gdt memory segments, the code segment goes up to end of the
- * page with etext in it, the data segment goes to the end of
- * the address space
- */
- /*
- * XXX text protection is temporarily (?) disabled. The limit was
- * i386_btop(round_page(etext)) - 1.
- */
- gdt_segs[GCODE_SEL].ssd_limit = i386_btop(0) - 1;
- gdt_segs[GDATA_SEL].ssd_limit = i386_btop(0) - 1;
-#ifdef SMP
- gdt_segs[GPRIV_SEL].ssd_limit =
- i386_btop(sizeof(struct privatespace)) - 1;
- gdt_segs[GPRIV_SEL].ssd_base = (int) &SMP_prvspace[0];
- gdt_segs[GPROC0_SEL].ssd_base =
- (int) &SMP_prvspace[0].globaldata.gd_common_tss;
- SMP_prvspace[0].globaldata.gd_prvspace = &SMP_prvspace[0];
-#else
- gdt_segs[GPRIV_SEL].ssd_limit = i386_btop(0) - 1;
- gdt_segs[GPROC0_SEL].ssd_base = (int) &common_tss;
-#endif
-
- for (x = 0; x < NGDT; x++) {
-#ifdef BDE_DEBUGGER
- /* avoid overwriting db entries with APM ones */
- if (x >= GAPMCODE32_SEL && x <= GAPMDATA_SEL)
- continue;
-#endif
- ssdtosd(&gdt_segs[x], &gdt[x].sd);
- }
-
- r_gdt.rd_limit = NGDT * sizeof(gdt[0]) - 1;
- r_gdt.rd_base = (int) gdt;
- lgdt(&r_gdt);
-
- /* make ldt memory segments */
- /*
- * The data segment limit must not cover the user area because we
- * don't want the user area to be writable in copyout() etc. (page
- * level protection is lost in kernel mode on 386's). Also, we
- * don't want the user area to be writable directly (page level
- * protection of the user area is not available on 486's with
- * CR0_WP set, because there is no user-read/kernel-write mode).
- *
- * XXX - VM_MAXUSER_ADDRESS is an end address, not a max. And it
- * should be spelled ...MAX_USER...
- */
-#define VM_END_USER_RW_ADDRESS VM_MAXUSER_ADDRESS
- /*
- * The code segment limit has to cover the user area until we move
- * the signal trampoline out of the user area. This is safe because
- * the code segment cannot be written to directly.
- */
-#define VM_END_USER_R_ADDRESS (VM_END_USER_RW_ADDRESS + UPAGES * PAGE_SIZE)
- ldt_segs[LUCODE_SEL].ssd_limit = i386_btop(VM_END_USER_R_ADDRESS) - 1;
- ldt_segs[LUDATA_SEL].ssd_limit = i386_btop(VM_END_USER_RW_ADDRESS) - 1;
- for (x = 0; x < sizeof ldt_segs / sizeof ldt_segs[0]; x++)
- ssdtosd(&ldt_segs[x], &ldt[x].sd);
-
- _default_ldt = GSEL(GLDT_SEL, SEL_KPL);
- lldt(_default_ldt);
-#ifdef USER_LDT
- currentldt = _default_ldt;
-#endif
-
- /* exceptions */
- for (x = 0; x < NIDT; x++)
- setidt(x, &IDTVEC(rsvd), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(0, &IDTVEC(div), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(1, &IDTVEC(dbg), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(2, &IDTVEC(nmi), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(3, &IDTVEC(bpt), SDT_SYS386TGT, SEL_UPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(4, &IDTVEC(ofl), SDT_SYS386TGT, SEL_UPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(5, &IDTVEC(bnd), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(6, &IDTVEC(ill), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(7, &IDTVEC(dna), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(8, 0, SDT_SYSTASKGT, SEL_KPL, GSEL(GPANIC_SEL, SEL_KPL));
- setidt(9, &IDTVEC(fpusegm), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(10, &IDTVEC(tss), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(11, &IDTVEC(missing), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(12, &IDTVEC(stk), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(13, &IDTVEC(prot), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(14, &IDTVEC(page), SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(15, &IDTVEC(rsvd), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(16, &IDTVEC(fpu), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(17, &IDTVEC(align), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(18, &IDTVEC(mchk), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(0x80, &IDTVEC(int0x80_syscall),
- SDT_SYS386TGT, SEL_UPL, GSEL(GCODE_SEL, SEL_KPL));
-
- r_idt.rd_limit = sizeof(idt0) - 1;
- r_idt.rd_base = (int) idt;
- lidt(&r_idt);
-
- /*
- * Initialize the console before we print anything out.
- */
- cninit();
-
-#include "isa.h"
-#if NISA >0
- isa_defaultirq();
-#endif
- rand_initialize();
-
-#ifdef DDB
- kdb_init();
- if (boothowto & RB_KDB)
- Debugger("Boot flags requested debugger");
-#endif
-
- finishidentcpu(); /* Final stage of CPU initialization */
- setidt(6, &IDTVEC(ill), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(13, &IDTVEC(prot), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- initializecpu(); /* Initialize CPU registers */
-
- /* make an initial tss so cpu can get interrupt stack on syscall! */
- common_tss.tss_esp0 = (int) proc0.p_addr + UPAGES*PAGE_SIZE - 16;
- common_tss.tss_ss0 = GSEL(GDATA_SEL, SEL_KPL) ;
- gsel_tss = GSEL(GPROC0_SEL, SEL_KPL);
- private_tss = 0;
- tss_gdt = &gdt[GPROC0_SEL].sd;
- common_tssd = *tss_gdt;
- common_tss.tss_ioopt = (sizeof common_tss) << 16;
- ltr(gsel_tss);
-
- dblfault_tss.tss_esp = dblfault_tss.tss_esp0 = dblfault_tss.tss_esp1 =
- dblfault_tss.tss_esp2 = (int) &dblfault_stack[sizeof(dblfault_stack)];
- dblfault_tss.tss_ss = dblfault_tss.tss_ss0 = dblfault_tss.tss_ss1 =
- dblfault_tss.tss_ss2 = GSEL(GDATA_SEL, SEL_KPL);
- dblfault_tss.tss_cr3 = (int)IdlePTD;
- dblfault_tss.tss_eip = (int) dblfault_handler;
- dblfault_tss.tss_eflags = PSL_KERNEL;
- dblfault_tss.tss_ds = dblfault_tss.tss_es =
- dblfault_tss.tss_gs = GSEL(GDATA_SEL, SEL_KPL);
- dblfault_tss.tss_fs = GSEL(GPRIV_SEL, SEL_KPL);
- dblfault_tss.tss_cs = GSEL(GCODE_SEL, SEL_KPL);
- dblfault_tss.tss_ldt = GSEL(GLDT_SEL, SEL_KPL);
-
- vm86_initialize();
- getmemsize(first);
-
- /* now running on new page tables, configured,and u/iom is accessible */
-
- /* Map the message buffer. */
- for (off = 0; off < round_page(MSGBUF_SIZE); off += PAGE_SIZE)
- pmap_kenter((vm_offset_t)msgbufp + off, avail_end + off);
-
- msgbufinit(msgbufp, MSGBUF_SIZE);
-
- /* make a call gate to reenter kernel with */
- gdp = &ldt[LSYS5CALLS_SEL].gd;
-
- x = (int) &IDTVEC(syscall);
- gdp->gd_looffset = x++;
- gdp->gd_selector = GSEL(GCODE_SEL,SEL_KPL);
- gdp->gd_stkcpy = 1;
- gdp->gd_type = SDT_SYS386CGT;
- gdp->gd_dpl = SEL_UPL;
- gdp->gd_p = 1;
- gdp->gd_hioffset = ((int) &IDTVEC(syscall)) >>16;
-
- /* XXX does this work? */
- ldt[LBSDICALLS_SEL] = ldt[LSYS5CALLS_SEL];
- ldt[LSOL26CALLS_SEL] = ldt[LSYS5CALLS_SEL];
-
- /* transfer to user mode */
-
- _ucodesel = LSEL(LUCODE_SEL, SEL_UPL);
- _udatasel = LSEL(LUDATA_SEL, SEL_UPL);
-
- /* setup proc 0's pcb */
- proc0.p_addr->u_pcb.pcb_flags = 0;
- proc0.p_addr->u_pcb.pcb_cr3 = (int)IdlePTD;
-#ifdef SMP
- proc0.p_addr->u_pcb.pcb_mpnest = 1;
-#endif
- proc0.p_addr->u_pcb.pcb_ext = 0;
-}
-
-#if defined(I586_CPU) && !defined(NO_F00F_HACK)
-static void f00f_hack(void *unused);
-SYSINIT(f00f_hack, SI_SUB_INTRINSIC, SI_ORDER_FIRST, f00f_hack, NULL);
-
-static void
-f00f_hack(void *unused) {
- struct gate_descriptor *new_idt;
-#ifndef SMP
- struct region_descriptor r_idt;
-#endif
- vm_offset_t tmp;
-
- if (!has_f00f_bug)
- return;
-
- printf("Intel Pentium detected, installing workaround for F00F bug\n");
-
- r_idt.rd_limit = sizeof(idt0) - 1;
-
- tmp = kmem_alloc(kernel_map, PAGE_SIZE * 2);
- if (tmp == 0)
- panic("kmem_alloc returned 0");
- if (((unsigned int)tmp & (PAGE_SIZE-1)) != 0)
- panic("kmem_alloc returned non-page-aligned memory");
- /* Put the first seven entries in the lower page */
- new_idt = (struct gate_descriptor*)(tmp + PAGE_SIZE - (7*8));
- bcopy(idt, new_idt, sizeof(idt0));
- r_idt.rd_base = (int)new_idt;
- lidt(&r_idt);
- idt = new_idt;
- if (vm_map_protect(kernel_map, tmp, tmp + PAGE_SIZE,
- VM_PROT_READ, FALSE) != KERN_SUCCESS)
- panic("vm_map_protect failed");
- return;
-}
-#endif /* defined(I586_CPU) && !NO_F00F_HACK */
-
-int
-ptrace_set_pc(p, addr)
- struct proc *p;
- unsigned long addr;
-{
- p->p_md.md_regs->tf_eip = addr;
- return (0);
-}
-
-int
-ptrace_single_step(p)
- struct proc *p;
-{
- p->p_md.md_regs->tf_eflags |= PSL_T;
- return (0);
-}
-
-int ptrace_read_u_check(p, addr, len)
- struct proc *p;
- vm_offset_t addr;
- size_t len;
-{
- vm_offset_t gap;
-
- if ((vm_offset_t) (addr + len) < addr)
- return EPERM;
- if ((vm_offset_t) (addr + len) <= sizeof(struct user))
- return 0;
-
- gap = (char *) p->p_md.md_regs - (char *) p->p_addr;
-
- if ((vm_offset_t) addr < gap)
- return EPERM;
- if ((vm_offset_t) (addr + len) <=
- (vm_offset_t) (gap + sizeof(struct trapframe)))
- return 0;
- return EPERM;
-}
-
-int ptrace_write_u(p, off, data)
- struct proc *p;
- vm_offset_t off;
- long data;
-{
- struct trapframe frame_copy;
- vm_offset_t min;
- struct trapframe *tp;
-
- /*
- * Privileged kernel state is scattered all over the user area.
- * Only allow write access to parts of regs and to fpregs.
- */
- min = (char *)p->p_md.md_regs - (char *)p->p_addr;
- if (off >= min && off <= min + sizeof(struct trapframe) - sizeof(int)) {
- tp = p->p_md.md_regs;
- frame_copy = *tp;
- *(int *)((char *)&frame_copy + (off - min)) = data;
- if (!EFL_SECURE(frame_copy.tf_eflags, tp->tf_eflags) ||
- !CS_SECURE(frame_copy.tf_cs))
- return (EINVAL);
- *(int*)((char *)p->p_addr + off) = data;
- return (0);
- }
- min = offsetof(struct user, u_pcb) + offsetof(struct pcb, pcb_savefpu);
- if (off >= min && off <= min + sizeof(struct save87) - sizeof(int)) {
- *(int*)((char *)p->p_addr + off) = data;
- return (0);
- }
- return (EFAULT);
-}
-
-int
-fill_regs(p, regs)
- struct proc *p;
- struct reg *regs;
-{
- struct pcb *pcb;
- struct trapframe *tp;
-
- tp = p->p_md.md_regs;
- regs->r_fs = tp->tf_fs;
- regs->r_es = tp->tf_es;
- regs->r_ds = tp->tf_ds;
- regs->r_edi = tp->tf_edi;
- regs->r_esi = tp->tf_esi;
- regs->r_ebp = tp->tf_ebp;
- regs->r_ebx = tp->tf_ebx;
- regs->r_edx = tp->tf_edx;
- regs->r_ecx = tp->tf_ecx;
- regs->r_eax = tp->tf_eax;
- regs->r_eip = tp->tf_eip;
- regs->r_cs = tp->tf_cs;
- regs->r_eflags = tp->tf_eflags;
- regs->r_esp = tp->tf_esp;
- regs->r_ss = tp->tf_ss;
- pcb = &p->p_addr->u_pcb;
- regs->r_gs = pcb->pcb_gs;
- return (0);
-}
-
-int
-set_regs(p, regs)
- struct proc *p;
- struct reg *regs;
-{
- struct pcb *pcb;
- struct trapframe *tp;
-
- tp = p->p_md.md_regs;
- if (!EFL_SECURE(regs->r_eflags, tp->tf_eflags) ||
- !CS_SECURE(regs->r_cs))
- return (EINVAL);
- tp->tf_fs = regs->r_fs;
- tp->tf_es = regs->r_es;
- tp->tf_ds = regs->r_ds;
- tp->tf_edi = regs->r_edi;
- tp->tf_esi = regs->r_esi;
- tp->tf_ebp = regs->r_ebp;
- tp->tf_ebx = regs->r_ebx;
- tp->tf_edx = regs->r_edx;
- tp->tf_ecx = regs->r_ecx;
- tp->tf_eax = regs->r_eax;
- tp->tf_eip = regs->r_eip;
- tp->tf_cs = regs->r_cs;
- tp->tf_eflags = regs->r_eflags;
- tp->tf_esp = regs->r_esp;
- tp->tf_ss = regs->r_ss;
- pcb = &p->p_addr->u_pcb;
- pcb->pcb_gs = regs->r_gs;
- return (0);
-}
-
-int
-fill_fpregs(p, fpregs)
- struct proc *p;
- struct fpreg *fpregs;
-{
- bcopy(&p->p_addr->u_pcb.pcb_savefpu, fpregs, sizeof *fpregs);
- return (0);
-}
-
-int
-set_fpregs(p, fpregs)
- struct proc *p;
- struct fpreg *fpregs;
-{
- bcopy(fpregs, &p->p_addr->u_pcb.pcb_savefpu, sizeof *fpregs);
- return (0);
-}
-
-int
-fill_dbregs(p, dbregs)
- struct proc *p;
- struct dbreg *dbregs;
-{
- struct pcb *pcb;
-
- pcb = &p->p_addr->u_pcb;
- dbregs->dr0 = pcb->pcb_dr0;
- dbregs->dr1 = pcb->pcb_dr1;
- dbregs->dr2 = pcb->pcb_dr2;
- dbregs->dr3 = pcb->pcb_dr3;
- dbregs->dr4 = 0;
- dbregs->dr5 = 0;
- dbregs->dr6 = pcb->pcb_dr6;
- dbregs->dr7 = pcb->pcb_dr7;
- return (0);
-}
-
-int
-set_dbregs(p, dbregs)
- struct proc *p;
- struct dbreg *dbregs;
-{
- struct pcb *pcb;
-
- pcb = &p->p_addr->u_pcb;
-
- /*
- * Don't let a process set a breakpoint that is not within the
- * process's address space. If a process could do this, it
- * could halt the system by setting a breakpoint in the kernel
- * (if ddb was enabled). Thus, we need to check to make sure
- * that no breakpoints are being enabled for addresses outside
- * process's address space, unless, perhaps, we were called by
- * uid 0.
- *
- * XXX - what about when the watched area of the user's
- * address space is written into from within the kernel
- * ... wouldn't that still cause a breakpoint to be generated
- * from within kernel mode?
- */
-
- if (p->p_ucred->cr_uid != 0) {
- if (dbregs->dr7 & 0x3) {
- /* dr0 is enabled */
- if (dbregs->dr0 >= VM_MAXUSER_ADDRESS)
- return (EINVAL);
- }
-
- if (dbregs->dr7 & (0x3<<2)) {
- /* dr1 is enabled */
- if (dbregs->dr1 >= VM_MAXUSER_ADDRESS)
- return (EINVAL);
- }
-
- if (dbregs->dr7 & (0x3<<4)) {
- /* dr2 is enabled */
- if (dbregs->dr2 >= VM_MAXUSER_ADDRESS)
- return (EINVAL);
- }
-
- if (dbregs->dr7 & (0x3<<6)) {
- /* dr3 is enabled */
- if (dbregs->dr3 >= VM_MAXUSER_ADDRESS)
- return (EINVAL);
- }
- }
-
- pcb->pcb_dr0 = dbregs->dr0;
- pcb->pcb_dr1 = dbregs->dr1;
- pcb->pcb_dr2 = dbregs->dr2;
- pcb->pcb_dr3 = dbregs->dr3;
- pcb->pcb_dr6 = dbregs->dr6;
- pcb->pcb_dr7 = dbregs->dr7;
-
- pcb->pcb_flags |= PCB_DBREGS;
-
- return (0);
-}
-
-/*
- * Return > 0 if a hardware breakpoint has been hit, and the
- * breakpoint was in user space. Return 0, otherwise.
- */
-int
-user_dbreg_trap(void)
-{
- u_int32_t dr7, dr6; /* debug registers dr6 and dr7 */
- u_int32_t bp; /* breakpoint bits extracted from dr6 */
- int nbp; /* number of breakpoints that triggered */
- caddr_t addr[4]; /* breakpoint addresses */
- int i;
-
- dr7 = rdr7();
- if ((dr7 & 0x000000ff) == 0) {
- /*
- * all GE and LE bits in the dr7 register are zero,
- * thus the trap couldn't have been caused by the
- * hardware debug registers
- */
- return 0;
- }
-
- nbp = 0;
- dr6 = rdr6();
- bp = dr6 & 0x0000000f;
-
- if (!bp) {
- /*
- * None of the breakpoint bits are set meaning this
- * trap was not caused by any of the debug registers
- */
- return 0;
- }
-
- /*
- * at least one of the breakpoints were hit, check to see
- * which ones and if any of them are user space addresses
- */
-
- if (bp & 0x01) {
- addr[nbp++] = (caddr_t)rdr0();
- }
- if (bp & 0x02) {
- addr[nbp++] = (caddr_t)rdr1();
- }
- if (bp & 0x04) {
- addr[nbp++] = (caddr_t)rdr2();
- }
- if (bp & 0x08) {
- addr[nbp++] = (caddr_t)rdr3();
- }
-
- for (i=0; i<nbp; i++) {
- if (addr[i] <
- (caddr_t)VM_MAXUSER_ADDRESS) {
- /*
- * addr[i] is in user space
- */
- return nbp;
- }
- }
-
- /*
- * None of the breakpoints are in user space.
- */
- return 0;
-}
-
-
-#ifndef DDB
-void
-Debugger(const char *msg)
-{
- printf("Debugger(\"%s\") called.\n", msg);
-}
-#endif /* no DDB */
-
-#include <sys/disklabel.h>
-
-/*
- * Determine the size of the transfer, and make sure it is
- * within the boundaries of the partition. Adjust transfer
- * if needed, and signal errors or early completion.
- */
-int
-bounds_check_with_label(struct buf *bp, struct disklabel *lp, int wlabel)
-{
- struct partition *p = lp->d_partitions + dkpart(bp->b_dev);
- int labelsect = lp->d_partitions[0].p_offset;
- int maxsz = p->p_size,
- sz = (bp->b_bcount + DEV_BSIZE - 1) >> DEV_BSHIFT;
-
- /* overwriting disk label ? */
- /* XXX should also protect bootstrap in first 8K */
- if (bp->b_blkno + p->p_offset <= LABELSECTOR + labelsect &&
-#if LABELSECTOR != 0
- bp->b_blkno + p->p_offset + sz > LABELSECTOR + labelsect &&
-#endif
- (bp->b_flags & B_READ) == 0 && wlabel == 0) {
- bp->b_error = EROFS;
- goto bad;
- }
-
-#if defined(DOSBBSECTOR) && defined(notyet)
- /* overwriting master boot record? */
- if (bp->b_blkno + p->p_offset <= DOSBBSECTOR &&
- (bp->b_flags & B_READ) == 0 && wlabel == 0) {
- bp->b_error = EROFS;
- goto bad;
- }
-#endif
-
- /* beyond partition? */
- if (bp->b_blkno < 0 || bp->b_blkno + sz > maxsz) {
- /* if exactly at end of disk, return an EOF */
- if (bp->b_blkno == maxsz) {
- bp->b_resid = bp->b_bcount;
- return(0);
- }
- /* or truncate if part of it fits */
- sz = maxsz - bp->b_blkno;
- if (sz <= 0) {
- bp->b_error = EINVAL;
- goto bad;
- }
- bp->b_bcount = sz << DEV_BSHIFT;
- }
-
- bp->b_pblkno = bp->b_blkno + p->p_offset;
- return(1);
-
-bad:
- bp->b_flags |= B_ERROR;
- return(-1);
-}
-
-#ifdef DDB
-
-/*
- * Provide inb() and outb() as functions. They are normally only
- * available as macros calling inlined functions, thus cannot be
- * called inside DDB.
- *
- * The actual code is stolen from <machine/cpufunc.h>, and de-inlined.
- */
-
-#undef inb
-#undef outb
-
-/* silence compiler warnings */
-u_char inb(u_int);
-void outb(u_int, u_char);
-
-u_char
-inb(u_int port)
-{
- u_char data;
- /*
- * We use %%dx and not %1 here because i/o is done at %dx and not at
- * %edx, while gcc generates inferior code (movw instead of movl)
- * if we tell it to load (u_short) port.
- */
- __asm __volatile("inb %%dx,%0" : "=a" (data) : "d" (port));
- return (data);
-}
-
-void
-outb(u_int port, u_char data)
-{
- u_char al;
- /*
- * Use an unnecessary assignment to help gcc's register allocator.
- * This make a large difference for gcc-1.40 and a tiny difference
- * for gcc-2.6.0. For gcc-1.40, al had to be ``asm("ax")'' for
- * best results. gcc-2.6.0 can't handle this.
- */
- al = data;
- __asm __volatile("outb %0,%%dx" : : "a" (al), "d" (port));
-}
-
-#endif /* DDB */
diff --git a/sys/amd64/amd64/mem.c b/sys/amd64/amd64/mem.c
deleted file mode 100644
index bb96e18c1156..000000000000
--- a/sys/amd64/amd64/mem.c
+++ /dev/null
@@ -1,562 +0,0 @@
-/*-
- * Copyright (c) 1988 University of Utah.
- * Copyright (c) 1982, 1986, 1990 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, and code derived from software contributed to
- * Berkeley by William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: mem.c 1.13 89/10/08$
- * from: @(#)mem.c 7.2 (Berkeley) 5/9/91
- * $FreeBSD$
- */
-
-/*
- * Memory special file
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/conf.h>
-#include <sys/fcntl.h>
-#include <sys/buf.h>
-#include <sys/kernel.h>
-#include <sys/uio.h>
-#include <sys/ioccom.h>
-#include <sys/malloc.h>
-#include <sys/memrange.h>
-#include <sys/proc.h>
-#include <sys/signalvar.h>
-
-#include <machine/frame.h>
-#include <machine/random.h>
-#include <machine/psl.h>
-#include <machine/specialreg.h>
-#include <i386/isa/intr_machdep.h>
-
-#include <vm/vm.h>
-#include <vm/pmap.h>
-#include <vm/vm_extern.h>
-
-
-static d_open_t mmopen;
-static d_close_t mmclose;
-static d_read_t mmrw;
-static d_ioctl_t mmioctl;
-static d_mmap_t memmmap;
-static d_poll_t mmpoll;
-
-#define CDEV_MAJOR 2
-static struct cdevsw mem_cdevsw = {
- /* open */ mmopen,
- /* close */ mmclose,
- /* read */ mmrw,
- /* write */ mmrw,
- /* ioctl */ mmioctl,
- /* poll */ mmpoll,
- /* mmap */ memmmap,
- /* strategy */ nostrategy,
- /* name */ "mem",
- /* maj */ CDEV_MAJOR,
- /* dump */ nodump,
- /* psize */ nopsize,
- /* flags */ D_MEM,
- /* bmaj */ -1
-};
-
-static struct random_softc random_softc[16];
-static caddr_t zbuf;
-
-MALLOC_DEFINE(M_MEMDESC, "memdesc", "memory range descriptors");
-static int mem_ioctl __P((dev_t, u_long, caddr_t, int, struct proc *));
-static int random_ioctl __P((dev_t, u_long, caddr_t, int, struct proc *));
-
-struct mem_range_softc mem_range_softc;
-
-
-static int
-mmclose(dev, flags, fmt, p)
- dev_t dev;
- int flags;
- int fmt;
- struct proc *p;
-{
- switch (minor(dev)) {
- case 14:
- p->p_md.md_regs->tf_eflags &= ~PSL_IOPL;
- break;
- default:
- break;
- }
- return (0);
-}
-
-static int
-mmopen(dev, flags, fmt, p)
- dev_t dev;
- int flags;
- int fmt;
- struct proc *p;
-{
- int error;
-
- switch (minor(dev)) {
- case 0:
- case 1:
- if ((flags & FWRITE) && securelevel > 0)
- return (EPERM);
- break;
- case 14:
- error = suser(p);
- if (error != 0)
- return (error);
- if (securelevel > 0)
- return (EPERM);
- p->p_md.md_regs->tf_eflags |= PSL_IOPL;
- break;
- default:
- break;
- }
- return (0);
-}
-
-static int
-mmrw(dev, uio, flags)
- dev_t dev;
- struct uio *uio;
- int flags;
-{
- register int o;
- register u_int c, v;
- u_int poolsize;
- register struct iovec *iov;
- int error = 0;
- caddr_t buf = NULL;
-
- 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)) {
-
-/* minor device 0 is physical memory */
- case 0:
- v = uio->uio_offset;
- pmap_enter(kernel_pmap, (vm_offset_t)ptvmmap, v,
- uio->uio_rw == UIO_READ ? VM_PROT_READ : VM_PROT_WRITE,
- TRUE);
- o = (int)uio->uio_offset & PAGE_MASK;
- c = (u_int)(PAGE_SIZE - ((int)iov->iov_base & PAGE_MASK));
- c = min(c, (u_int)(PAGE_SIZE - o));
- c = min(c, (u_int)iov->iov_len);
- error = uiomove((caddr_t)&ptvmmap[o], (int)c, uio);
- pmap_remove(kernel_pmap, (vm_offset_t)ptvmmap,
- (vm_offset_t)&ptvmmap[PAGE_SIZE]);
- continue;
-
-/* minor device 1 is kernel memory */
- case 1: {
- vm_offset_t addr, eaddr;
- c = iov->iov_len;
-
- /*
- * Make sure that all of the pages are currently resident so
- * that we don't create any zero-fill pages.
- */
- addr = trunc_page(uio->uio_offset);
- eaddr = round_page(uio->uio_offset + c);
-
- if (addr < (vm_offset_t)VADDR(PTDPTDI, 0))
- return EFAULT;
- if (eaddr >= (vm_offset_t)VADDR(APTDPTDI, 0))
- return EFAULT;
- for (; addr < eaddr; addr += PAGE_SIZE)
- if (pmap_extract(kernel_pmap, addr) == 0)
- return EFAULT;
-
- if (!kernacc((caddr_t)(int)uio->uio_offset, c,
- uio->uio_rw == UIO_READ ?
- VM_PROT_READ : VM_PROT_WRITE))
- return (EFAULT);
- error = uiomove((caddr_t)(int)uio->uio_offset, (int)c, uio);
- continue;
- }
-
-/* minor device 2 is EOF/RATHOLE */
- case 2:
- if (uio->uio_rw == UIO_READ)
- return (0);
- c = iov->iov_len;
- break;
-
-/* minor device 3 (/dev/random) is source of filth on read, rathole on write */
- case 3:
- if (uio->uio_rw == UIO_WRITE) {
- c = iov->iov_len;
- break;
- }
- if (buf == NULL)
- buf = (caddr_t)
- malloc(PAGE_SIZE, M_TEMP, M_WAITOK);
- c = min(iov->iov_len, PAGE_SIZE);
- poolsize = read_random(buf, c);
- if (poolsize == 0) {
- if (buf)
- free(buf, M_TEMP);
- return (0);
- }
- c = min(c, poolsize);
- error = uiomove(buf, (int)c, uio);
- continue;
-
-/* minor device 4 (/dev/urandom) is source of muck on read, rathole on write */
- case 4:
- if (uio->uio_rw == UIO_WRITE) {
- c = iov->iov_len;
- break;
- }
- if (CURSIG(curproc) != 0) {
- /*
- * Use tsleep() to get the error code right.
- * It should return immediately.
- */
- error = tsleep(&random_softc[0],
- PZERO | PCATCH, "urand", 1);
- if (error != 0 && error != EWOULDBLOCK)
- continue;
- }
- if (buf == NULL)
- buf = (caddr_t)
- malloc(PAGE_SIZE, M_TEMP, M_WAITOK);
- c = min(iov->iov_len, PAGE_SIZE);
- poolsize = read_random_unlimited(buf, c);
- c = min(c, poolsize);
- error = uiomove(buf, (int)c, uio);
- continue;
-
-/* minor device 12 (/dev/zero) is source of nulls on read, rathole on write */
- case 12:
- if (uio->uio_rw == UIO_WRITE) {
- c = iov->iov_len;
- break;
- }
- if (zbuf == NULL) {
- zbuf = (caddr_t)
- malloc(PAGE_SIZE, M_TEMP, M_WAITOK);
- bzero(zbuf, PAGE_SIZE);
- }
- c = min(iov->iov_len, PAGE_SIZE);
- error = uiomove(zbuf, (int)c, uio);
- continue;
-
- default:
- return (ENXIO);
- }
- if (error)
- break;
- iov->iov_base += c;
- iov->iov_len -= c;
- uio->uio_offset += c;
- uio->uio_resid -= c;
- }
- if (buf)
- free(buf, M_TEMP);
- return (error);
-}
-
-
-
-
-/*******************************************************\
-* allow user processes to MMAP some memory sections *
-* instead of going through read/write *
-\*******************************************************/
-static int
-memmmap(dev_t dev, vm_offset_t offset, int nprot)
-{
- switch (minor(dev))
- {
-
-/* minor device 0 is physical memory */
- case 0:
- return i386_btop(offset);
-
-/* minor device 1 is kernel memory */
- case 1:
- return i386_btop(vtophys(offset));
-
- default:
- return -1;
- }
-}
-
-static int
-mmioctl(dev, cmd, data, flags, p)
- dev_t dev;
- u_long cmd;
- caddr_t data;
- int flags;
- struct proc *p;
-{
-
- switch (minor(dev)) {
- case 0:
- return mem_ioctl(dev, cmd, data, flags, p);
- case 3:
- case 4:
- return random_ioctl(dev, cmd, data, flags, p);
- }
- return (ENODEV);
-}
-
-/*
- * Operations for changing memory attributes.
- *
- * This is basically just an ioctl shim for mem_range_attr_get
- * and mem_range_attr_set.
- */
-static int
-mem_ioctl(dev, cmd, data, flags, p)
- dev_t dev;
- u_long cmd;
- caddr_t data;
- int flags;
- struct proc *p;
-{
- int nd, error = 0;
- struct mem_range_op *mo = (struct mem_range_op *)data;
- struct mem_range_desc *md;
-
- /* is this for us? */
- if ((cmd != MEMRANGE_GET) &&
- (cmd != MEMRANGE_SET))
- return (ENOTTY);
-
- /* any chance we can handle this? */
- if (mem_range_softc.mr_op == NULL)
- return (EOPNOTSUPP);
-
- /* do we have any descriptors? */
- if (mem_range_softc.mr_ndesc == 0)
- return (ENXIO);
-
- switch (cmd) {
- case MEMRANGE_GET:
- nd = imin(mo->mo_arg[0], mem_range_softc.mr_ndesc);
- if (nd > 0) {
- md = (struct mem_range_desc *)
- malloc(nd * sizeof(struct mem_range_desc),
- M_MEMDESC, M_WAITOK);
- error = mem_range_attr_get(md, &nd);
- if (!error)
- error = copyout(md, mo->mo_desc,
- nd * sizeof(struct mem_range_desc));
- free(md, M_MEMDESC);
- } else {
- nd = mem_range_softc.mr_ndesc;
- }
- mo->mo_arg[0] = nd;
- break;
-
- case MEMRANGE_SET:
- md = (struct mem_range_desc *)malloc(sizeof(struct mem_range_desc),
- M_MEMDESC, M_WAITOK);
- error = copyin(mo->mo_desc, md, sizeof(struct mem_range_desc));
- /* clamp description string */
- md->mr_owner[sizeof(md->mr_owner) - 1] = 0;
- if (error == 0)
- error = mem_range_attr_set(md, &mo->mo_arg[0]);
- free(md, M_MEMDESC);
- break;
- }
- return (error);
-}
-
-/*
- * Implementation-neutral, kernel-callable functions for manipulating
- * memory range attributes.
- */
-int
-mem_range_attr_get(mrd, arg)
- struct mem_range_desc *mrd;
- int *arg;
-{
- /* can we handle this? */
- if (mem_range_softc.mr_op == NULL)
- return (EOPNOTSUPP);
-
- if (*arg == 0) {
- *arg = mem_range_softc.mr_ndesc;
- } else {
- bcopy(mem_range_softc.mr_desc, mrd, (*arg) * sizeof(struct mem_range_desc));
- }
- return (0);
-}
-
-int
-mem_range_attr_set(mrd, arg)
- struct mem_range_desc *mrd;
- int *arg;
-{
- /* can we handle this? */
- if (mem_range_softc.mr_op == NULL)
- return (EOPNOTSUPP);
-
- return (mem_range_softc.mr_op->set(&mem_range_softc, mrd, arg));
-}
-
-#ifdef SMP
-void
-mem_range_AP_init(void)
-{
- if (mem_range_softc.mr_op && mem_range_softc.mr_op->initAP)
- return (mem_range_softc.mr_op->initAP(&mem_range_softc));
-}
-#endif
-
-static int
-random_ioctl(dev, cmd, data, flags, p)
- dev_t dev;
- u_long cmd;
- caddr_t data;
- int flags;
- struct proc *p;
-{
- static intrmask_t interrupt_allowed;
- intrmask_t interrupt_mask;
- int error, intr;
- struct random_softc *sc;
-
- /*
- * We're the random or urandom device. The only ioctls are for
- * selecting and inspecting which interrupts are used in the muck
- * gathering business.
- */
- if (cmd != MEM_SETIRQ && cmd != MEM_CLEARIRQ && cmd != MEM_RETURNIRQ)
- return (ENOTTY);
-
- /*
- * Even inspecting the state is privileged, since it gives a hint
- * about how easily the randomness might be guessed.
- */
- error = suser(p);
- if (error != 0)
- return (error);
-
- /*
- * XXX the data is 16-bit due to a historical botch, so we use
- * magic 16's instead of ICU_LEN and can't support 24 interrupts
- * under SMP.
- */
- intr = *(int16_t *)data;
- if (cmd != MEM_RETURNIRQ && (intr < 0 || intr >= 16))
- return (EINVAL);
-
- interrupt_mask = 1 << intr;
- sc = &random_softc[intr];
- switch (cmd) {
- case MEM_SETIRQ:
- if (interrupt_allowed & interrupt_mask)
- break;
- interrupt_allowed |= interrupt_mask;
- sc->sc_intr = intr;
- disable_intr();
- sc->sc_handler = intr_handler[intr];
- intr_handler[intr] = add_interrupt_randomness;
- sc->sc_arg = intr_unit[intr];
- intr_unit[intr] = sc;
- enable_intr();
- break;
- case MEM_CLEARIRQ:
- if (!(interrupt_allowed & interrupt_mask))
- break;
- interrupt_allowed &= ~interrupt_mask;
- disable_intr();
- intr_handler[intr] = sc->sc_handler;
- intr_unit[intr] = sc->sc_arg;
- enable_intr();
- break;
- case MEM_RETURNIRQ:
- *(u_int16_t *)data = interrupt_allowed;
- break;
- }
- return (0);
-}
-
-int
-mmpoll(dev, events, p)
- dev_t dev;
- int events;
- struct proc *p;
-{
- switch (minor(dev)) {
- case 3: /* /dev/random */
- return random_poll(dev, events, p);
- case 4: /* /dev/urandom */
- default:
- return seltrue(dev, events, p);
- }
-}
-
-int
-iszerodev(dev)
- dev_t dev;
-{
- return ((major(dev) == mem_cdevsw.d_maj)
- && minor(dev) == 12);
-}
-
-static void
-mem_drvinit(void *unused)
-{
-
- /* Initialise memory range handling */
- if (mem_range_softc.mr_op != NULL)
- mem_range_softc.mr_op->init(&mem_range_softc);
-
- make_dev(&mem_cdevsw, 0, UID_ROOT, GID_KMEM, 0640, "mem");
- make_dev(&mem_cdevsw, 1, UID_ROOT, GID_KMEM, 0640, "kmem");
- make_dev(&mem_cdevsw, 2, UID_ROOT, GID_WHEEL, 0666, "null");
- make_dev(&mem_cdevsw, 3, UID_ROOT, GID_WHEEL, 0644, "random");
- make_dev(&mem_cdevsw, 4, UID_ROOT, GID_WHEEL, 0644, "urandom");
- make_dev(&mem_cdevsw, 12, UID_ROOT, GID_WHEEL, 0666, "zero");
- make_dev(&mem_cdevsw, 14, UID_ROOT, GID_WHEEL, 0600, "io");
-}
-
-SYSINIT(memdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,mem_drvinit,NULL)
-
diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c
deleted file mode 100644
index 8e349a9800e4..000000000000
--- a/sys/amd64/amd64/mp_machdep.c
+++ /dev/null
@@ -1,2739 +0,0 @@
-/*
- * Copyright (c) 1996, by Steve Passe
- * 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 developer 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include "opt_smp.h"
-#include "opt_cpu.h"
-#include "opt_user_ldt.h"
-
-#ifdef SMP
-#include <machine/smptests.h>
-#else
-#error
-#endif
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/proc.h>
-#include <sys/sysctl.h>
-#include <sys/malloc.h>
-#include <sys/memrange.h>
-#ifdef BETTER_CLOCK
-#include <sys/dkstat.h>
-#endif
-#include <sys/cons.h> /* cngetc() */
-
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <vm/pmap.h>
-#include <vm/vm_kern.h>
-#include <vm/vm_extern.h>
-#ifdef BETTER_CLOCK
-#include <sys/lock.h>
-#include <vm/vm_map.h>
-#include <sys/user.h>
-#ifdef GPROF
-#include <sys/gmon.h>
-#endif
-#endif
-
-#include <machine/smp.h>
-#include <machine/apic.h>
-#include <machine/atomic.h>
-#include <machine/cpufunc.h>
-#include <machine/mpapic.h>
-#include <machine/psl.h>
-#include <machine/segments.h>
-#include <machine/smptests.h> /** TEST_DEFAULT_CONFIG, TEST_TEST1 */
-#include <machine/tss.h>
-#include <machine/specialreg.h>
-#include <machine/globaldata.h>
-
-#if defined(APIC_IO)
-#include <machine/md_var.h> /* setidt() */
-#include <i386/isa/icu.h> /* IPIs */
-#include <i386/isa/intr_machdep.h> /* IPIs */
-#endif /* APIC_IO */
-
-#if defined(TEST_DEFAULT_CONFIG)
-#define MPFPS_MPFB1 TEST_DEFAULT_CONFIG
-#else
-#define MPFPS_MPFB1 mpfps->mpfb1
-#endif /* TEST_DEFAULT_CONFIG */
-
-#define WARMBOOT_TARGET 0
-#define WARMBOOT_OFF (KERNBASE + 0x0467)
-#define WARMBOOT_SEG (KERNBASE + 0x0469)
-
-#ifdef PC98
-#define BIOS_BASE (0xe8000)
-#define BIOS_SIZE (0x18000)
-#else
-#define BIOS_BASE (0xf0000)
-#define BIOS_SIZE (0x10000)
-#endif
-#define BIOS_COUNT (BIOS_SIZE/4)
-
-#define CMOS_REG (0x70)
-#define CMOS_DATA (0x71)
-#define BIOS_RESET (0x0f)
-#define BIOS_WARM (0x0a)
-
-#define PROCENTRY_FLAG_EN 0x01
-#define PROCENTRY_FLAG_BP 0x02
-#define IOAPICENTRY_FLAG_EN 0x01
-
-
-/* MP Floating Pointer Structure */
-typedef struct MPFPS {
- char signature[4];
- void *pap;
- u_char length;
- u_char spec_rev;
- u_char checksum;
- u_char mpfb1;
- u_char mpfb2;
- u_char mpfb3;
- u_char mpfb4;
- u_char mpfb5;
-} *mpfps_t;
-
-/* MP Configuration Table Header */
-typedef struct MPCTH {
- char signature[4];
- u_short base_table_length;
- u_char spec_rev;
- u_char checksum;
- u_char oem_id[8];
- u_char product_id[12];
- void *oem_table_pointer;
- u_short oem_table_size;
- u_short entry_count;
- void *apic_address;
- u_short extended_table_length;
- u_char extended_table_checksum;
- u_char reserved;
-} *mpcth_t;
-
-
-typedef struct PROCENTRY {
- u_char type;
- u_char apic_id;
- u_char apic_version;
- u_char cpu_flags;
- u_long cpu_signature;
- u_long feature_flags;
- u_long reserved1;
- u_long reserved2;
-} *proc_entry_ptr;
-
-typedef struct BUSENTRY {
- u_char type;
- u_char bus_id;
- char bus_type[6];
-} *bus_entry_ptr;
-
-typedef struct IOAPICENTRY {
- u_char type;
- u_char apic_id;
- u_char apic_version;
- u_char apic_flags;
- void *apic_address;
-} *io_apic_entry_ptr;
-
-typedef struct INTENTRY {
- u_char type;
- u_char int_type;
- u_short int_flags;
- u_char src_bus_id;
- u_char src_bus_irq;
- u_char dst_apic_id;
- u_char dst_apic_int;
-} *int_entry_ptr;
-
-/* descriptions of MP basetable entries */
-typedef struct BASETABLE_ENTRY {
- u_char type;
- u_char length;
- char name[16];
-} basetable_entry;
-
-/*
- * this code MUST be enabled here and in mpboot.s.
- * it follows the very early stages of AP boot by placing values in CMOS ram.
- * it NORMALLY will never be needed and thus the primitive method for enabling.
- *
-#define CHECK_POINTS
- */
-
-#if defined(CHECK_POINTS) && !defined(PC98)
-#define CHECK_READ(A) (outb(CMOS_REG, (A)), inb(CMOS_DATA))
-#define CHECK_WRITE(A,D) (outb(CMOS_REG, (A)), outb(CMOS_DATA, (D)))
-
-#define CHECK_INIT(D); \
- CHECK_WRITE(0x34, (D)); \
- CHECK_WRITE(0x35, (D)); \
- CHECK_WRITE(0x36, (D)); \
- CHECK_WRITE(0x37, (D)); \
- CHECK_WRITE(0x38, (D)); \
- CHECK_WRITE(0x39, (D));
-
-#define CHECK_PRINT(S); \
- printf("%s: %d, %d, %d, %d, %d, %d\n", \
- (S), \
- CHECK_READ(0x34), \
- CHECK_READ(0x35), \
- CHECK_READ(0x36), \
- CHECK_READ(0x37), \
- CHECK_READ(0x38), \
- CHECK_READ(0x39));
-
-#else /* CHECK_POINTS */
-
-#define CHECK_INIT(D)
-#define CHECK_PRINT(S)
-
-#endif /* CHECK_POINTS */
-
-/*
- * Values to send to the POST hardware.
- */
-#define MP_BOOTADDRESS_POST 0x10
-#define MP_PROBE_POST 0x11
-#define MPTABLE_PASS1_POST 0x12
-
-#define MP_START_POST 0x13
-#define MP_ENABLE_POST 0x14
-#define MPTABLE_PASS2_POST 0x15
-
-#define START_ALL_APS_POST 0x16
-#define INSTALL_AP_TRAMP_POST 0x17
-#define START_AP_POST 0x18
-
-#define MP_ANNOUNCE_POST 0x19
-
-
-/** XXX FIXME: where does this really belong, isa.h/isa.c perhaps? */
-int current_postcode;
-
-/** XXX FIXME: what system files declare these??? */
-extern struct region_descriptor r_gdt, r_idt;
-
-int bsp_apic_ready = 0; /* flags useability of BSP apic */
-int mp_ncpus; /* # of CPUs, including BSP */
-int mp_naps; /* # of Applications processors */
-int mp_nbusses; /* # of busses */
-int mp_napics; /* # of IO APICs */
-int boot_cpu_id; /* designated BSP */
-vm_offset_t cpu_apic_address;
-vm_offset_t io_apic_address[NAPICID]; /* NAPICID is more than enough */
-extern int nkpt;
-
-u_int32_t cpu_apic_versions[NCPU];
-u_int32_t io_apic_versions[NAPIC];
-
-#ifdef APIC_INTR_DIAGNOSTIC
-int apic_itrace_enter[32];
-int apic_itrace_tryisrlock[32];
-int apic_itrace_gotisrlock[32];
-int apic_itrace_active[32];
-int apic_itrace_masked[32];
-int apic_itrace_noisrlock[32];
-int apic_itrace_masked2[32];
-int apic_itrace_unmask[32];
-int apic_itrace_noforward[32];
-int apic_itrace_leave[32];
-int apic_itrace_enter2[32];
-int apic_itrace_doreti[32];
-int apic_itrace_splz[32];
-int apic_itrace_eoi[32];
-#ifdef APIC_INTR_DIAGNOSTIC_IRQ
-unsigned short apic_itrace_debugbuffer[32768];
-int apic_itrace_debugbuffer_idx;
-struct simplelock apic_itrace_debuglock;
-#endif
-#endif
-
-#ifdef APIC_INTR_REORDER
-struct {
- volatile int *location;
- int bit;
-} apic_isrbit_location[32];
-#endif
-
-struct apic_intmapinfo int_to_apicintpin[APIC_INTMAPSIZE];
-
-/*
- * APIC ID logical/physical mapping structures.
- * We oversize these to simplify boot-time config.
- */
-int cpu_num_to_apic_id[NAPICID];
-int io_num_to_apic_id[NAPICID];
-int apic_id_to_logical[NAPICID];
-
-
-/* Bitmap of all available CPUs */
-u_int all_cpus;
-
-/* AP uses this during bootstrap. Do not staticize. */
-char *bootSTK;
-static int bootAP;
-
-/* Hotwire a 0->4MB V==P mapping */
-extern pt_entry_t *KPTphys;
-
-/* SMP page table page */
-extern pt_entry_t *SMPpt;
-
-struct pcb stoppcbs[NCPU];
-
-int smp_started; /* has the system started? */
-
-/*
- * Local data and functions.
- */
-
-static int mp_capable;
-static u_int boot_address;
-static u_int base_memory;
-
-static int picmode; /* 0: virtual wire mode, 1: PIC mode */
-static mpfps_t mpfps;
-static int search_for_sig(u_int32_t target, int count);
-static void mp_enable(u_int boot_addr);
-
-static int mptable_pass1(void);
-static int mptable_pass2(void);
-static void default_mp_table(int type);
-static void fix_mp_table(void);
-static void setup_apic_irq_mapping(void);
-static void init_locks(void);
-static int start_all_aps(u_int boot_addr);
-static void install_ap_tramp(u_int boot_addr);
-static int start_ap(int logicalCpu, u_int boot_addr);
-static int apic_int_is_bus_type(int intr, int bus_type);
-
-/*
- * Calculate usable address in base memory for AP trampoline code.
- */
-u_int
-mp_bootaddress(u_int basemem)
-{
- POSTCODE(MP_BOOTADDRESS_POST);
-
- base_memory = basemem * 1024; /* convert to bytes */
-
- boot_address = base_memory & ~0xfff; /* round down to 4k boundary */
- if ((base_memory - boot_address) < bootMP_size)
- boot_address -= 4096; /* not enough, lower by 4k */
-
- return boot_address;
-}
-
-
-/*
- * Look for an Intel MP spec table (ie, SMP capable hardware).
- */
-int
-mp_probe(void)
-{
- int x;
- u_long segment;
- u_int32_t target;
-
- POSTCODE(MP_PROBE_POST);
-
- /* see if EBDA exists */
- if ((segment = (u_long) * (u_short *) (KERNBASE + 0x40e)) != 0) {
- /* search first 1K of EBDA */
- target = (u_int32_t) (segment << 4);
- if ((x = search_for_sig(target, 1024 / 4)) >= 0)
- goto found;
- } else {
- /* last 1K of base memory, effective 'top of base' passed in */
- target = (u_int32_t) (base_memory - 0x400);
- if ((x = search_for_sig(target, 1024 / 4)) >= 0)
- goto found;
- }
-
- /* search the BIOS */
- target = (u_int32_t) BIOS_BASE;
- if ((x = search_for_sig(target, BIOS_COUNT)) >= 0)
- goto found;
-
- /* nothing found */
- mpfps = (mpfps_t)0;
- mp_capable = 0;
- return 0;
-
-found:
- /* calculate needed resources */
- mpfps = (mpfps_t)x;
- if (mptable_pass1())
- panic("you must reconfigure your kernel");
-
- /* flag fact that we are running multiple processors */
- mp_capable = 1;
- return 1;
-}
-
-
-/*
- * Startup the SMP processors.
- */
-void
-mp_start(void)
-{
- POSTCODE(MP_START_POST);
-
- /* look for MP capable motherboard */
- if (mp_capable)
- mp_enable(boot_address);
- else
- panic("MP hardware not found!");
-}
-
-
-/*
- * Print various information about the SMP system hardware and setup.
- */
-void
-mp_announce(void)
-{
- int x;
-
- POSTCODE(MP_ANNOUNCE_POST);
-
- printf("FreeBSD/SMP: Multiprocessor motherboard\n");
- printf(" cpu0 (BSP): apic id: %2d", CPU_TO_ID(0));
- printf(", version: 0x%08x", cpu_apic_versions[0]);
- printf(", at 0x%08x\n", cpu_apic_address);
- for (x = 1; x <= mp_naps; ++x) {
- printf(" cpu%d (AP): apic id: %2d", x, CPU_TO_ID(x));
- printf(", version: 0x%08x", cpu_apic_versions[x]);
- printf(", at 0x%08x\n", cpu_apic_address);
- }
-
-#if defined(APIC_IO)
- for (x = 0; x < mp_napics; ++x) {
- printf(" io%d (APIC): apic id: %2d", x, IO_TO_ID(x));
- printf(", version: 0x%08x", io_apic_versions[x]);
- printf(", at 0x%08x\n", io_apic_address[x]);
- }
-#else
- printf(" Warning: APIC I/O disabled\n");
-#endif /* APIC_IO */
-}
-
-/*
- * AP cpu's call this to sync up protected mode.
- */
-void
-init_secondary(void)
-{
- int gsel_tss;
- int x, myid = bootAP;
-
- gdt_segs[GPRIV_SEL].ssd_base = (int) &SMP_prvspace[myid];
- gdt_segs[GPROC0_SEL].ssd_base =
- (int) &SMP_prvspace[myid].globaldata.gd_common_tss;
- SMP_prvspace[myid].globaldata.gd_prvspace = &SMP_prvspace[myid];
-
- for (x = 0; x < NGDT; x++) {
- ssdtosd(&gdt_segs[x], &gdt[myid * NGDT + x].sd);
- }
-
- r_gdt.rd_limit = NGDT * sizeof(gdt[0]) - 1;
- r_gdt.rd_base = (int) &gdt[myid * NGDT];
- lgdt(&r_gdt); /* does magic intra-segment return */
-
- lidt(&r_idt);
-
- lldt(_default_ldt);
-#ifdef USER_LDT
- currentldt = _default_ldt;
-#endif
-
- gsel_tss = GSEL(GPROC0_SEL, SEL_KPL);
- gdt[myid * NGDT + GPROC0_SEL].sd.sd_type = SDT_SYS386TSS;
- common_tss.tss_esp0 = 0; /* not used until after switch */
- common_tss.tss_ss0 = GSEL(GDATA_SEL, SEL_KPL);
- common_tss.tss_ioopt = (sizeof common_tss) << 16;
- tss_gdt = &gdt[myid * NGDT + GPROC0_SEL].sd;
- common_tssd = *tss_gdt;
- ltr(gsel_tss);
-
- load_cr0(0x8005003b); /* XXX! */
-
- pmap_set_opt();
-}
-
-
-#if defined(APIC_IO)
-/*
- * Final configuration of the BSP's local APIC:
- * - disable 'pic mode'.
- * - disable 'virtual wire mode'.
- * - enable NMI.
- */
-void
-bsp_apic_configure(void)
-{
- u_char byte;
- u_int32_t temp;
-
- /* leave 'pic mode' if necessary */
- if (picmode) {
- outb(0x22, 0x70); /* select IMCR */
- byte = inb(0x23); /* current contents */
- byte |= 0x01; /* mask external INTR */
- outb(0x23, byte); /* disconnect 8259s/NMI */
- }
-
- /* mask lint0 (the 8259 'virtual wire' connection) */
- temp = lapic.lvt_lint0;
- temp |= APIC_LVT_M; /* set the mask */
- lapic.lvt_lint0 = temp;
-
- /* setup lint1 to handle NMI */
- temp = lapic.lvt_lint1;
- temp &= ~APIC_LVT_M; /* clear the mask */
- lapic.lvt_lint1 = temp;
-
- if (bootverbose)
- apic_dump("bsp_apic_configure()");
-}
-#endif /* APIC_IO */
-
-
-/*******************************************************************
- * local functions and data
- */
-
-/*
- * start the SMP system
- */
-static void
-mp_enable(u_int boot_addr)
-{
- int x;
-#if defined(APIC_IO)
- int apic;
- u_int ux;
-#endif /* APIC_IO */
-
- POSTCODE(MP_ENABLE_POST);
-
- /* turn on 4MB of V == P addressing so we can get to MP table */
- *(int *)PTD = PG_V | PG_RW | ((uintptr_t)(void *)KPTphys & PG_FRAME);
- invltlb();
-
- /* examine the MP table for needed info, uses physical addresses */
- x = mptable_pass2();
-
- *(int *)PTD = 0;
- invltlb();
-
- /* can't process default configs till the CPU APIC is pmapped */
- if (x)
- default_mp_table(x);
-
- /* post scan cleanup */
- fix_mp_table();
- setup_apic_irq_mapping();
-
-#if defined(APIC_IO)
-
- /* fill the LOGICAL io_apic_versions table */
- for (apic = 0; apic < mp_napics; ++apic) {
- ux = io_apic_read(apic, IOAPIC_VER);
- io_apic_versions[apic] = ux;
- }
-
- /* program each IO APIC in the system */
- for (apic = 0; apic < mp_napics; ++apic)
- if (io_apic_setup(apic) < 0)
- panic("IO APIC setup failure");
-
- /* install a 'Spurious INTerrupt' vector */
- setidt(XSPURIOUSINT_OFFSET, Xspuriousint,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-
- /* install an inter-CPU IPI for TLB invalidation */
- setidt(XINVLTLB_OFFSET, Xinvltlb,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-
-#ifdef BETTER_CLOCK
- /* install an inter-CPU IPI for reading processor state */
- setidt(XCPUCHECKSTATE_OFFSET, Xcpucheckstate,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-#endif
-
- /* install an inter-CPU IPI for all-CPU rendezvous */
- setidt(XRENDEZVOUS_OFFSET, Xrendezvous,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-
- /* install an inter-CPU IPI for forcing an additional software trap */
- setidt(XCPUAST_OFFSET, Xcpuast,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-
- /* install an inter-CPU IPI for interrupt forwarding */
- setidt(XFORWARD_IRQ_OFFSET, Xforward_irq,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-
- /* install an inter-CPU IPI for CPU stop/restart */
- setidt(XCPUSTOP_OFFSET, Xcpustop,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-
-#if defined(TEST_TEST1)
- /* install a "fake hardware INTerrupt" vector */
- setidt(XTEST1_OFFSET, Xtest1,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-#endif /** TEST_TEST1 */
-
-#endif /* APIC_IO */
-
- /* initialize all SMP locks */
- init_locks();
-
- /* start each Application Processor */
- start_all_aps(boot_addr);
-
- /*
- * The init process might be started on a different CPU now,
- * and the boot CPU might not call prepare_usermode to get
- * cr0 correctly configured. Thus we initialize cr0 here.
- */
- load_cr0(rcr0() | CR0_WP | CR0_AM);
-}
-
-
-/*
- * look for the MP spec signature
- */
-
-/* string defined by the Intel MP Spec as identifying the MP table */
-#define MP_SIG 0x5f504d5f /* _MP_ */
-#define NEXT(X) ((X) += 4)
-static int
-search_for_sig(u_int32_t target, int count)
-{
- int x;
- u_int32_t *addr = (u_int32_t *) (KERNBASE + target);
-
- for (x = 0; x < count; NEXT(x))
- if (addr[x] == MP_SIG)
- /* make array index a byte index */
- return (target + (x * sizeof(u_int32_t)));
-
- return -1;
-}
-
-
-static basetable_entry basetable_entry_types[] =
-{
- {0, 20, "Processor"},
- {1, 8, "Bus"},
- {2, 8, "I/O APIC"},
- {3, 8, "I/O INT"},
- {4, 8, "Local INT"}
-};
-
-typedef struct BUSDATA {
- u_char bus_id;
- enum busTypes bus_type;
-} bus_datum;
-
-typedef struct INTDATA {
- u_char int_type;
- u_short int_flags;
- u_char src_bus_id;
- u_char src_bus_irq;
- u_char dst_apic_id;
- u_char dst_apic_int;
- u_char int_vector;
-} io_int, local_int;
-
-typedef struct BUSTYPENAME {
- u_char type;
- char name[7];
-} bus_type_name;
-
-static bus_type_name bus_type_table[] =
-{
- {CBUS, "CBUS"},
- {CBUSII, "CBUSII"},
- {EISA, "EISA"},
- {MCA, "MCA"},
- {UNKNOWN_BUSTYPE, "---"},
- {ISA, "ISA"},
- {MCA, "MCA"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {PCI, "PCI"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {XPRESS, "XPRESS"},
- {UNKNOWN_BUSTYPE, "---"}
-};
-/* from MP spec v1.4, table 5-1 */
-static int default_data[7][5] =
-{
-/* nbus, id0, type0, id1, type1 */
- {1, 0, ISA, 255, 255},
- {1, 0, EISA, 255, 255},
- {1, 0, EISA, 255, 255},
- {1, 0, MCA, 255, 255},
- {2, 0, ISA, 1, PCI},
- {2, 0, EISA, 1, PCI},
- {2, 0, MCA, 1, PCI}
-};
-
-
-/* the bus data */
-static bus_datum bus_data[NBUS];
-
-/* the IO INT data, one entry per possible APIC INTerrupt */
-static io_int io_apic_ints[NINTR];
-
-static int nintrs;
-
-static int processor_entry __P((proc_entry_ptr entry, int cpu));
-static int bus_entry __P((bus_entry_ptr entry, int bus));
-static int io_apic_entry __P((io_apic_entry_ptr entry, int apic));
-static int int_entry __P((int_entry_ptr entry, int intr));
-static int lookup_bus_type __P((char *name));
-
-
-/*
- * 1st pass on motherboard's Intel MP specification table.
- *
- * initializes:
- * mp_ncpus = 1
- *
- * determines:
- * cpu_apic_address (common to all CPUs)
- * io_apic_address[N]
- * mp_naps
- * mp_nbusses
- * mp_napics
- * nintrs
- */
-static int
-mptable_pass1(void)
-{
- int x;
- mpcth_t cth;
- int totalSize;
- void* position;
- int count;
- int type;
- int mustpanic;
-
- POSTCODE(MPTABLE_PASS1_POST);
-
- mustpanic = 0;
-
- /* clear various tables */
- for (x = 0; x < NAPICID; ++x) {
- io_apic_address[x] = ~0; /* IO APIC address table */
- }
-
- /* init everything to empty */
- mp_naps = 0;
- mp_nbusses = 0;
- mp_napics = 0;
- nintrs = 0;
-
- /* check for use of 'default' configuration */
- if (MPFPS_MPFB1 != 0) {
- /* use default addresses */
- cpu_apic_address = DEFAULT_APIC_BASE;
- io_apic_address[0] = DEFAULT_IO_APIC_BASE;
-
- /* fill in with defaults */
- mp_naps = 2; /* includes BSP */
- mp_nbusses = default_data[MPFPS_MPFB1 - 1][0];
-#if defined(APIC_IO)
- mp_napics = 1;
- nintrs = 16;
-#endif /* APIC_IO */
- }
- else {
- if ((cth = mpfps->pap) == 0)
- panic("MP Configuration Table Header MISSING!");
-
- cpu_apic_address = (vm_offset_t) cth->apic_address;
-
- /* walk the table, recording info of interest */
- totalSize = cth->base_table_length - sizeof(struct MPCTH);
- position = (u_char *) cth + sizeof(struct MPCTH);
- count = cth->entry_count;
-
- while (count--) {
- switch (type = *(u_char *) position) {
- case 0: /* processor_entry */
- if (((proc_entry_ptr)position)->cpu_flags
- & PROCENTRY_FLAG_EN)
- ++mp_naps;
- break;
- case 1: /* bus_entry */
- ++mp_nbusses;
- break;
- case 2: /* io_apic_entry */
- if (((io_apic_entry_ptr)position)->apic_flags
- & IOAPICENTRY_FLAG_EN)
- io_apic_address[mp_napics++] =
- (vm_offset_t)((io_apic_entry_ptr)
- position)->apic_address;
- break;
- case 3: /* int_entry */
- ++nintrs;
- break;
- case 4: /* int_entry */
- break;
- default:
- panic("mpfps Base Table HOSED!");
- /* NOTREACHED */
- }
-
- totalSize -= basetable_entry_types[type].length;
- (u_char*)position += basetable_entry_types[type].length;
- }
- }
-
- /* qualify the numbers */
- if (mp_naps > NCPU) {
- printf("Warning: only using %d of %d available CPUs!\n",
- NCPU, mp_naps);
- mp_naps = NCPU;
- }
- if (mp_nbusses > NBUS) {
- printf("found %d busses, increase NBUS\n", mp_nbusses);
- mustpanic = 1;
- }
- if (mp_napics > NAPIC) {
- printf("found %d apics, increase NAPIC\n", mp_napics);
- mustpanic = 1;
- }
- if (nintrs > NINTR) {
- printf("found %d intrs, increase NINTR\n", nintrs);
- mustpanic = 1;
- }
-
- /*
- * Count the BSP.
- * This is also used as a counter while starting the APs.
- */
- mp_ncpus = 1;
-
- --mp_naps; /* subtract the BSP */
-
- return mustpanic;
-}
-
-
-/*
- * 2nd pass on motherboard's Intel MP specification table.
- *
- * sets:
- * boot_cpu_id
- * ID_TO_IO(N), phy APIC ID to log CPU/IO table
- * CPU_TO_ID(N), logical CPU to APIC ID table
- * IO_TO_ID(N), logical IO to APIC ID table
- * bus_data[N]
- * io_apic_ints[N]
- */
-static int
-mptable_pass2(void)
-{
- int x;
- mpcth_t cth;
- int totalSize;
- void* position;
- int count;
- int type;
- int apic, bus, cpu, intr;
-
- POSTCODE(MPTABLE_PASS2_POST);
-
- /* clear various tables */
- for (x = 0; x < NAPICID; ++x) {
- ID_TO_IO(x) = -1; /* phy APIC ID to log CPU/IO table */
- CPU_TO_ID(x) = -1; /* logical CPU to APIC ID table */
- IO_TO_ID(x) = -1; /* logical IO to APIC ID table */
- }
-
- /* clear bus data table */
- for (x = 0; x < NBUS; ++x)
- bus_data[x].bus_id = 0xff;
-
- /* clear IO APIC INT table */
- for (x = 0; x < NINTR; ++x) {
- io_apic_ints[x].int_type = 0xff;
- io_apic_ints[x].int_vector = 0xff;
- }
-
- /* setup the cpu/apic mapping arrays */
- boot_cpu_id = -1;
-
- /* record whether PIC or virtual-wire mode */
- picmode = (mpfps->mpfb2 & 0x80) ? 1 : 0;
-
- /* check for use of 'default' configuration */
- if (MPFPS_MPFB1 != 0)
- return MPFPS_MPFB1; /* return default configuration type */
-
- if ((cth = mpfps->pap) == 0)
- panic("MP Configuration Table Header MISSING!");
-
- /* walk the table, recording info of interest */
- totalSize = cth->base_table_length - sizeof(struct MPCTH);
- position = (u_char *) cth + sizeof(struct MPCTH);
- count = cth->entry_count;
- apic = bus = intr = 0;
- cpu = 1; /* pre-count the BSP */
-
- while (count--) {
- switch (type = *(u_char *) position) {
- case 0:
- if (processor_entry(position, cpu))
- ++cpu;
- break;
- case 1:
- if (bus_entry(position, bus))
- ++bus;
- break;
- case 2:
- if (io_apic_entry(position, apic))
- ++apic;
- break;
- case 3:
- if (int_entry(position, intr))
- ++intr;
- break;
- case 4:
- /* int_entry(position); */
- break;
- default:
- panic("mpfps Base Table HOSED!");
- /* NOTREACHED */
- }
-
- totalSize -= basetable_entry_types[type].length;
- (u_char *) position += basetable_entry_types[type].length;
- }
-
- if (boot_cpu_id == -1)
- panic("NO BSP found!");
-
- /* report fact that its NOT a default configuration */
- return 0;
-}
-
-
-void
-assign_apic_irq(int apic, int intpin, int irq)
-{
- int x;
-
- if (int_to_apicintpin[irq].ioapic != -1)
- panic("assign_apic_irq: inconsistent table");
-
- int_to_apicintpin[irq].ioapic = apic;
- int_to_apicintpin[irq].int_pin = intpin;
- int_to_apicintpin[irq].apic_address = ioapic[apic];
- int_to_apicintpin[irq].redirindex = IOAPIC_REDTBL + 2 * intpin;
-
- for (x = 0; x < nintrs; x++) {
- if ((io_apic_ints[x].int_type == 0 ||
- io_apic_ints[x].int_type == 3) &&
- io_apic_ints[x].int_vector == 0xff &&
- io_apic_ints[x].dst_apic_id == IO_TO_ID(apic) &&
- io_apic_ints[x].dst_apic_int == intpin)
- io_apic_ints[x].int_vector = irq;
- }
-}
-
-void
-revoke_apic_irq(int irq)
-{
- int x;
- int oldapic;
- int oldintpin;
-
- if (int_to_apicintpin[irq].ioapic == -1)
- panic("assign_apic_irq: inconsistent table");
-
- oldapic = int_to_apicintpin[irq].ioapic;
- oldintpin = int_to_apicintpin[irq].int_pin;
-
- int_to_apicintpin[irq].ioapic = -1;
- int_to_apicintpin[irq].int_pin = 0;
- int_to_apicintpin[irq].apic_address = NULL;
- int_to_apicintpin[irq].redirindex = 0;
-
- for (x = 0; x < nintrs; x++) {
- if ((io_apic_ints[x].int_type == 0 ||
- io_apic_ints[x].int_type == 3) &&
- io_apic_ints[x].int_vector == 0xff &&
- io_apic_ints[x].dst_apic_id == IO_TO_ID(oldapic) &&
- io_apic_ints[x].dst_apic_int == oldintpin)
- io_apic_ints[x].int_vector = 0xff;
- }
-}
-
-/*
- * parse an Intel MP specification table
- */
-static void
-fix_mp_table(void)
-{
- int x;
- int id;
- int bus_0 = 0; /* Stop GCC warning */
- int bus_pci = 0; /* Stop GCC warning */
- int num_pci_bus;
-
- /*
- * Fix mis-numbering of the PCI bus and its INT entries if the BIOS
- * did it wrong. The MP spec says that when more than 1 PCI bus
- * exists the BIOS must begin with bus entries for the PCI bus and use
- * actual PCI bus numbering. This implies that when only 1 PCI bus
- * exists the BIOS can choose to ignore this ordering, and indeed many
- * MP motherboards do ignore it. This causes a problem when the PCI
- * sub-system makes requests of the MP sub-system based on PCI bus
- * numbers. So here we look for the situation and renumber the
- * busses and associated INTs in an effort to "make it right".
- */
-
- /* find bus 0, PCI bus, count the number of PCI busses */
- for (num_pci_bus = 0, x = 0; x < mp_nbusses; ++x) {
- if (bus_data[x].bus_id == 0) {
- bus_0 = x;
- }
- if (bus_data[x].bus_type == PCI) {
- ++num_pci_bus;
- bus_pci = x;
- }
- }
- /*
- * bus_0 == slot of bus with ID of 0
- * bus_pci == slot of last PCI bus encountered
- */
-
- /* check the 1 PCI bus case for sanity */
- if (num_pci_bus == 1) {
-
- /* if it is number 0 all is well */
- if (bus_data[bus_pci].bus_id == 0)
- return;
-
- /* mis-numbered, swap with whichever bus uses slot 0 */
-
- /* swap the bus entry types */
- bus_data[bus_pci].bus_type = bus_data[bus_0].bus_type;
- bus_data[bus_0].bus_type = PCI;
-
- /* swap each relavant INTerrupt entry */
- id = bus_data[bus_pci].bus_id;
- for (x = 0; x < nintrs; ++x) {
- if (io_apic_ints[x].src_bus_id == id) {
- io_apic_ints[x].src_bus_id = 0;
- }
- else if (io_apic_ints[x].src_bus_id == 0) {
- io_apic_ints[x].src_bus_id = id;
- }
- }
- }
-}
-
-
-/* Assign low level interrupt handlers */
-static void
-setup_apic_irq_mapping(void)
-{
- int x;
- int int_vector;
-
- /* Clear array */
- for (x = 0; x < APIC_INTMAPSIZE; x++) {
- int_to_apicintpin[x].ioapic = -1;
- int_to_apicintpin[x].int_pin = 0;
- int_to_apicintpin[x].apic_address = NULL;
- int_to_apicintpin[x].redirindex = 0;
- }
-
- /* First assign ISA/EISA interrupts */
- for (x = 0; x < nintrs; x++) {
- int_vector = io_apic_ints[x].src_bus_irq;
- if (int_vector < APIC_INTMAPSIZE &&
- io_apic_ints[x].int_vector == 0xff &&
- int_to_apicintpin[int_vector].ioapic == -1 &&
- (apic_int_is_bus_type(x, ISA) ||
- apic_int_is_bus_type(x, EISA)) &&
- io_apic_ints[x].int_type == 0) {
- assign_apic_irq(ID_TO_IO(io_apic_ints[x].dst_apic_id),
- io_apic_ints[x].dst_apic_int,
- int_vector);
- }
- }
-
- /* Assign interrupts on first 24 intpins on IOAPIC #0 */
- for (x = 0; x < nintrs; x++) {
- int_vector = io_apic_ints[x].dst_apic_int;
- if (int_vector < APIC_INTMAPSIZE &&
- io_apic_ints[x].dst_apic_id == IO_TO_ID(0) &&
- io_apic_ints[x].int_vector == 0xff &&
- int_to_apicintpin[int_vector].ioapic == -1 &&
- (io_apic_ints[x].int_type == 0 ||
- io_apic_ints[x].int_type == 3)) {
- assign_apic_irq(0,
- io_apic_ints[x].dst_apic_int,
- int_vector);
- }
- }
- /*
- * Assign interrupts for remaining intpins.
- * Skip IOAPIC #0 intpin 0 if the type is ExtInt, since this indicates
- * that an entry for ISA/EISA irq 0 exist, and a fallback to mixed mode
- * due to 8254 interrupts not being delivered can reuse that low level
- * interrupt handler.
- */
- int_vector = 0;
- while (int_vector < APIC_INTMAPSIZE &&
- int_to_apicintpin[int_vector].ioapic != -1)
- int_vector++;
- for (x = 0; x < nintrs && int_vector < APIC_INTMAPSIZE; x++) {
- if ((io_apic_ints[x].int_type == 0 ||
- (io_apic_ints[x].int_type == 3 &&
- (io_apic_ints[x].dst_apic_id != IO_TO_ID(0) ||
- io_apic_ints[x].dst_apic_int != 0))) &&
- io_apic_ints[x].int_vector == 0xff) {
- assign_apic_irq(ID_TO_IO(io_apic_ints[x].dst_apic_id),
- io_apic_ints[x].dst_apic_int,
- int_vector);
- int_vector++;
- while (int_vector < APIC_INTMAPSIZE &&
- int_to_apicintpin[int_vector].ioapic != -1)
- int_vector++;
- }
- }
-}
-
-
-static int
-processor_entry(proc_entry_ptr entry, int cpu)
-{
- /* check for usability */
- if (!(entry->cpu_flags & PROCENTRY_FLAG_EN))
- return 0;
-
- /* check for BSP flag */
- if (entry->cpu_flags & PROCENTRY_FLAG_BP) {
- boot_cpu_id = entry->apic_id;
- CPU_TO_ID(0) = entry->apic_id;
- ID_TO_CPU(entry->apic_id) = 0;
- return 0; /* its already been counted */
- }
-
- /* add another AP to list, if less than max number of CPUs */
- else if (cpu < NCPU) {
- CPU_TO_ID(cpu) = entry->apic_id;
- ID_TO_CPU(entry->apic_id) = cpu;
- return 1;
- }
-
- return 0;
-}
-
-
-static int
-bus_entry(bus_entry_ptr entry, int bus)
-{
- int x;
- char c, name[8];
-
- /* encode the name into an index */
- for (x = 0; x < 6; ++x) {
- if ((c = entry->bus_type[x]) == ' ')
- break;
- name[x] = c;
- }
- name[x] = '\0';
-
- if ((x = lookup_bus_type(name)) == UNKNOWN_BUSTYPE)
- panic("unknown bus type: '%s'", name);
-
- bus_data[bus].bus_id = entry->bus_id;
- bus_data[bus].bus_type = x;
-
- return 1;
-}
-
-
-static int
-io_apic_entry(io_apic_entry_ptr entry, int apic)
-{
- if (!(entry->apic_flags & IOAPICENTRY_FLAG_EN))
- return 0;
-
- IO_TO_ID(apic) = entry->apic_id;
- ID_TO_IO(entry->apic_id) = apic;
-
- return 1;
-}
-
-
-static int
-lookup_bus_type(char *name)
-{
- int x;
-
- for (x = 0; x < MAX_BUSTYPE; ++x)
- if (strcmp(bus_type_table[x].name, name) == 0)
- return bus_type_table[x].type;
-
- return UNKNOWN_BUSTYPE;
-}
-
-
-static int
-int_entry(int_entry_ptr entry, int intr)
-{
- int apic;
-
- io_apic_ints[intr].int_type = entry->int_type;
- io_apic_ints[intr].int_flags = entry->int_flags;
- io_apic_ints[intr].src_bus_id = entry->src_bus_id;
- io_apic_ints[intr].src_bus_irq = entry->src_bus_irq;
- if (entry->dst_apic_id == 255) {
- /* This signal goes to all IO APICS. Select an IO APIC
- with sufficient number of interrupt pins */
- for (apic = 0; apic < mp_napics; apic++)
- if (((io_apic_read(apic, IOAPIC_VER) &
- IOART_VER_MAXREDIR) >> MAXREDIRSHIFT) >=
- entry->dst_apic_int)
- break;
- if (apic < mp_napics)
- io_apic_ints[intr].dst_apic_id = IO_TO_ID(apic);
- else
- io_apic_ints[intr].dst_apic_id = entry->dst_apic_id;
- } else
- io_apic_ints[intr].dst_apic_id = entry->dst_apic_id;
- io_apic_ints[intr].dst_apic_int = entry->dst_apic_int;
-
- return 1;
-}
-
-
-static int
-apic_int_is_bus_type(int intr, int bus_type)
-{
- int bus;
-
- for (bus = 0; bus < mp_nbusses; ++bus)
- if ((bus_data[bus].bus_id == io_apic_ints[intr].src_bus_id)
- && ((int) bus_data[bus].bus_type == bus_type))
- return 1;
-
- return 0;
-}
-
-
-/*
- * Given a traditional ISA INT mask, return an APIC mask.
- */
-u_int
-isa_apic_mask(u_int isa_mask)
-{
- int isa_irq;
- int apic_pin;
-
-#if defined(SKIP_IRQ15_REDIRECT)
- if (isa_mask == (1 << 15)) {
- printf("skipping ISA IRQ15 redirect\n");
- return isa_mask;
- }
-#endif /* SKIP_IRQ15_REDIRECT */
-
- isa_irq = ffs(isa_mask); /* find its bit position */
- if (isa_irq == 0) /* doesn't exist */
- return 0;
- --isa_irq; /* make it zero based */
-
- apic_pin = isa_apic_irq(isa_irq); /* look for APIC connection */
- if (apic_pin == -1)
- return 0;
-
- return (1 << apic_pin); /* convert pin# to a mask */
-}
-
-
-/*
- * Determine which APIC pin an ISA/EISA INT is attached to.
- */
-#define INTTYPE(I) (io_apic_ints[(I)].int_type)
-#define INTPIN(I) (io_apic_ints[(I)].dst_apic_int)
-#define INTIRQ(I) (io_apic_ints[(I)].int_vector)
-#define INTAPIC(I) (ID_TO_IO(io_apic_ints[(I)].dst_apic_id))
-
-#define SRCBUSIRQ(I) (io_apic_ints[(I)].src_bus_irq)
-int
-isa_apic_irq(int isa_irq)
-{
- int intr;
-
- for (intr = 0; intr < nintrs; ++intr) { /* check each record */
- if (INTTYPE(intr) == 0) { /* standard INT */
- if (SRCBUSIRQ(intr) == isa_irq) {
- if (apic_int_is_bus_type(intr, ISA) ||
- apic_int_is_bus_type(intr, EISA))
- return INTIRQ(intr); /* found */
- }
- }
- }
- return -1; /* NOT found */
-}
-
-
-/*
- * Determine which APIC pin a PCI INT is attached to.
- */
-#define SRCBUSID(I) (io_apic_ints[(I)].src_bus_id)
-#define SRCBUSDEVICE(I) ((io_apic_ints[(I)].src_bus_irq >> 2) & 0x1f)
-#define SRCBUSLINE(I) (io_apic_ints[(I)].src_bus_irq & 0x03)
-int
-pci_apic_irq(int pciBus, int pciDevice, int pciInt)
-{
- int intr;
-
- --pciInt; /* zero based */
-
- for (intr = 0; intr < nintrs; ++intr) /* check each record */
- if ((INTTYPE(intr) == 0) /* standard INT */
- && (SRCBUSID(intr) == pciBus)
- && (SRCBUSDEVICE(intr) == pciDevice)
- && (SRCBUSLINE(intr) == pciInt)) /* a candidate IRQ */
- if (apic_int_is_bus_type(intr, PCI))
- return INTIRQ(intr); /* exact match */
-
- return -1; /* NOT found */
-}
-
-int
-next_apic_irq(int irq)
-{
- int intr, ointr;
- int bus, bustype;
-
- bus = 0;
- bustype = 0;
- for (intr = 0; intr < nintrs; intr++) {
- if (INTIRQ(intr) != irq || INTTYPE(intr) != 0)
- continue;
- bus = SRCBUSID(intr);
- bustype = apic_bus_type(bus);
- if (bustype != ISA &&
- bustype != EISA &&
- bustype != PCI)
- continue;
- break;
- }
- if (intr >= nintrs) {
- return -1;
- }
- for (ointr = intr + 1; ointr < nintrs; ointr++) {
- if (INTTYPE(ointr) != 0)
- continue;
- if (bus != SRCBUSID(ointr))
- continue;
- if (bustype == PCI) {
- if (SRCBUSDEVICE(intr) != SRCBUSDEVICE(ointr))
- continue;
- if (SRCBUSLINE(intr) != SRCBUSLINE(ointr))
- continue;
- }
- if (bustype == ISA || bustype == EISA) {
- if (SRCBUSIRQ(intr) != SRCBUSIRQ(ointr))
- continue;
- }
- if (INTPIN(intr) == INTPIN(ointr))
- continue;
- break;
- }
- if (ointr >= nintrs) {
- return -1;
- }
- return INTIRQ(ointr);
-}
-#undef SRCBUSLINE
-#undef SRCBUSDEVICE
-#undef SRCBUSID
-#undef SRCBUSIRQ
-
-#undef INTPIN
-#undef INTIRQ
-#undef INTAPIC
-#undef INTTYPE
-
-
-/*
- * Reprogram the MB chipset to NOT redirect an ISA INTerrupt.
- *
- * XXX FIXME:
- * Exactly what this means is unclear at this point. It is a solution
- * for motherboards that redirect the MBIRQ0 pin. Generically a motherboard
- * could route any of the ISA INTs to upper (>15) IRQ values. But most would
- * NOT be redirected via MBIRQ0, thus "undirect()ing" them would NOT be an
- * option.
- */
-int
-undirect_isa_irq(int rirq)
-{
-#if defined(READY)
- if (bootverbose)
- printf("Freeing redirected ISA irq %d.\n", rirq);
- /** FIXME: tickle the MB redirector chip */
- return ???;
-#else
- if (bootverbose)
- printf("Freeing (NOT implemented) redirected ISA irq %d.\n", rirq);
- return 0;
-#endif /* READY */
-}
-
-
-/*
- * Reprogram the MB chipset to NOT redirect a PCI INTerrupt
- */
-int
-undirect_pci_irq(int rirq)
-{
-#if defined(READY)
- if (bootverbose)
- printf("Freeing redirected PCI irq %d.\n", rirq);
-
- /** FIXME: tickle the MB redirector chip */
- return ???;
-#else
- if (bootverbose)
- printf("Freeing (NOT implemented) redirected PCI irq %d.\n",
- rirq);
- return 0;
-#endif /* READY */
-}
-
-
-/*
- * given a bus ID, return:
- * the bus type if found
- * -1 if NOT found
- */
-int
-apic_bus_type(int id)
-{
- int x;
-
- for (x = 0; x < mp_nbusses; ++x)
- if (bus_data[x].bus_id == id)
- return bus_data[x].bus_type;
-
- return -1;
-}
-
-
-/*
- * given a LOGICAL APIC# and pin#, return:
- * the associated src bus ID if found
- * -1 if NOT found
- */
-int
-apic_src_bus_id(int apic, int pin)
-{
- int x;
-
- /* search each of the possible INTerrupt sources */
- for (x = 0; x < nintrs; ++x)
- if ((apic == ID_TO_IO(io_apic_ints[x].dst_apic_id)) &&
- (pin == io_apic_ints[x].dst_apic_int))
- return (io_apic_ints[x].src_bus_id);
-
- return -1; /* NOT found */
-}
-
-
-/*
- * given a LOGICAL APIC# and pin#, return:
- * the associated src bus IRQ if found
- * -1 if NOT found
- */
-int
-apic_src_bus_irq(int apic, int pin)
-{
- int x;
-
- for (x = 0; x < nintrs; x++)
- if ((apic == ID_TO_IO(io_apic_ints[x].dst_apic_id)) &&
- (pin == io_apic_ints[x].dst_apic_int))
- return (io_apic_ints[x].src_bus_irq);
-
- return -1; /* NOT found */
-}
-
-
-/*
- * given a LOGICAL APIC# and pin#, return:
- * the associated INTerrupt type if found
- * -1 if NOT found
- */
-int
-apic_int_type(int apic, int pin)
-{
- int x;
-
- /* search each of the possible INTerrupt sources */
- for (x = 0; x < nintrs; ++x)
- if ((apic == ID_TO_IO(io_apic_ints[x].dst_apic_id)) &&
- (pin == io_apic_ints[x].dst_apic_int))
- return (io_apic_ints[x].int_type);
-
- return -1; /* NOT found */
-}
-
-int
-apic_irq(int apic, int pin)
-{
- int x;
- int res;
-
- for (x = 0; x < nintrs; ++x)
- if ((apic == ID_TO_IO(io_apic_ints[x].dst_apic_id)) &&
- (pin == io_apic_ints[x].dst_apic_int)) {
- res = io_apic_ints[x].int_vector;
- if (res == 0xff)
- return -1;
- if (apic != int_to_apicintpin[res].ioapic)
- panic("apic_irq: inconsistent table");
- if (pin != int_to_apicintpin[res].int_pin)
- panic("apic_irq inconsistent table (2)");
- return res;
- }
- return -1;
-}
-
-
-/*
- * given a LOGICAL APIC# and pin#, return:
- * the associated trigger mode if found
- * -1 if NOT found
- */
-int
-apic_trigger(int apic, int pin)
-{
- int x;
-
- /* search each of the possible INTerrupt sources */
- for (x = 0; x < nintrs; ++x)
- if ((apic == ID_TO_IO(io_apic_ints[x].dst_apic_id)) &&
- (pin == io_apic_ints[x].dst_apic_int))
- return ((io_apic_ints[x].int_flags >> 2) & 0x03);
-
- return -1; /* NOT found */
-}
-
-
-/*
- * given a LOGICAL APIC# and pin#, return:
- * the associated 'active' level if found
- * -1 if NOT found
- */
-int
-apic_polarity(int apic, int pin)
-{
- int x;
-
- /* search each of the possible INTerrupt sources */
- for (x = 0; x < nintrs; ++x)
- if ((apic == ID_TO_IO(io_apic_ints[x].dst_apic_id)) &&
- (pin == io_apic_ints[x].dst_apic_int))
- return (io_apic_ints[x].int_flags & 0x03);
-
- return -1; /* NOT found */
-}
-
-
-/*
- * set data according to MP defaults
- * FIXME: probably not complete yet...
- */
-static void
-default_mp_table(int type)
-{
- int ap_cpu_id;
-#if defined(APIC_IO)
- u_int32_t ux;
- int io_apic_id;
- int pin;
-#endif /* APIC_IO */
-
-#if 0
- printf(" MP default config type: %d\n", type);
- switch (type) {
- case 1:
- printf(" bus: ISA, APIC: 82489DX\n");
- break;
- case 2:
- printf(" bus: EISA, APIC: 82489DX\n");
- break;
- case 3:
- printf(" bus: EISA, APIC: 82489DX\n");
- break;
- case 4:
- printf(" bus: MCA, APIC: 82489DX\n");
- break;
- case 5:
- printf(" bus: ISA+PCI, APIC: Integrated\n");
- break;
- case 6:
- printf(" bus: EISA+PCI, APIC: Integrated\n");
- break;
- case 7:
- printf(" bus: MCA+PCI, APIC: Integrated\n");
- break;
- default:
- printf(" future type\n");
- break;
- /* NOTREACHED */
- }
-#endif /* 0 */
-
- boot_cpu_id = (lapic.id & APIC_ID_MASK) >> 24;
- ap_cpu_id = (boot_cpu_id == 0) ? 1 : 0;
-
- /* BSP */
- CPU_TO_ID(0) = boot_cpu_id;
- ID_TO_CPU(boot_cpu_id) = 0;
-
- /* one and only AP */
- CPU_TO_ID(1) = ap_cpu_id;
- ID_TO_CPU(ap_cpu_id) = 1;
-
-#if defined(APIC_IO)
- /* one and only IO APIC */
- io_apic_id = (io_apic_read(0, IOAPIC_ID) & APIC_ID_MASK) >> 24;
-
- /*
- * sanity check, refer to MP spec section 3.6.6, last paragraph
- * necessary as some hardware isn't properly setting up the IO APIC
- */
-#if defined(REALLY_ANAL_IOAPICID_VALUE)
- if (io_apic_id != 2) {
-#else
- if ((io_apic_id == 0) || (io_apic_id == 1) || (io_apic_id == 15)) {
-#endif /* REALLY_ANAL_IOAPICID_VALUE */
- ux = io_apic_read(0, IOAPIC_ID); /* get current contents */
- ux &= ~APIC_ID_MASK; /* clear the ID field */
- ux |= 0x02000000; /* set it to '2' */
- io_apic_write(0, IOAPIC_ID, ux); /* write new value */
- ux = io_apic_read(0, IOAPIC_ID); /* re-read && test */
- if ((ux & APIC_ID_MASK) != 0x02000000)
- panic("can't control IO APIC ID, reg: 0x%08x", ux);
- io_apic_id = 2;
- }
- IO_TO_ID(0) = io_apic_id;
- ID_TO_IO(io_apic_id) = 0;
-#endif /* APIC_IO */
-
- /* fill out bus entries */
- switch (type) {
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- bus_data[0].bus_id = default_data[type - 1][1];
- bus_data[0].bus_type = default_data[type - 1][2];
- bus_data[1].bus_id = default_data[type - 1][3];
- bus_data[1].bus_type = default_data[type - 1][4];
- break;
-
- /* case 4: case 7: MCA NOT supported */
- default: /* illegal/reserved */
- panic("BAD default MP config: %d", type);
- /* NOTREACHED */
- }
-
-#if defined(APIC_IO)
- /* general cases from MP v1.4, table 5-2 */
- for (pin = 0; pin < 16; ++pin) {
- io_apic_ints[pin].int_type = 0;
- io_apic_ints[pin].int_flags = 0x05; /* edge/active-hi */
- io_apic_ints[pin].src_bus_id = 0;
- io_apic_ints[pin].src_bus_irq = pin; /* IRQ2 caught below */
- io_apic_ints[pin].dst_apic_id = io_apic_id;
- io_apic_ints[pin].dst_apic_int = pin; /* 1-to-1 */
- }
-
- /* special cases from MP v1.4, table 5-2 */
- if (type == 2) {
- io_apic_ints[2].int_type = 0xff; /* N/C */
- io_apic_ints[13].int_type = 0xff; /* N/C */
-#if !defined(APIC_MIXED_MODE)
- /** FIXME: ??? */
- panic("sorry, can't support type 2 default yet");
-#endif /* APIC_MIXED_MODE */
- }
- else
- io_apic_ints[2].src_bus_irq = 0; /* ISA IRQ0 is on APIC INT 2 */
-
- if (type == 7)
- io_apic_ints[0].int_type = 0xff; /* N/C */
- else
- io_apic_ints[0].int_type = 3; /* vectored 8259 */
-#endif /* APIC_IO */
-}
-
-
-/*
- * initialize all the SMP locks
- */
-
-/* critical region around IO APIC, apic_imen */
-struct simplelock imen_lock;
-
-/* critical region around splxx(), cpl, cml, cil, ipending */
-struct simplelock cpl_lock;
-
-/* Make FAST_INTR() routines sequential */
-struct simplelock fast_intr_lock;
-
-/* critical region around INTR() routines */
-struct simplelock intr_lock;
-
-/* lock regions protected in UP kernel via cli/sti */
-struct simplelock mpintr_lock;
-
-/* lock region used by kernel profiling */
-struct simplelock mcount_lock;
-
-#ifdef USE_COMLOCK
-/* locks com (tty) data/hardware accesses: a FASTINTR() */
-struct simplelock com_lock;
-#endif /* USE_COMLOCK */
-
-#ifdef USE_CLOCKLOCK
-/* lock regions around the clock hardware */
-struct simplelock clock_lock;
-#endif /* USE_CLOCKLOCK */
-
-/* lock around the MP rendezvous */
-static struct simplelock smp_rv_lock;
-
-static void
-init_locks(void)
-{
- /*
- * Get the initial mp_lock with a count of 1 for the BSP.
- * This uses a LOGICAL cpu ID, ie BSP == 0.
- */
- mp_lock = 0x00000001;
-
- /* ISR uses its own "giant lock" */
- isr_lock = FREE_LOCK;
-
-#if defined(APIC_INTR_DIAGNOSTIC) && defined(APIC_INTR_DIAGNOSTIC_IRQ)
- s_lock_init((struct simplelock*)&apic_itrace_debuglock);
-#endif
-
- s_lock_init((struct simplelock*)&mpintr_lock);
-
- s_lock_init((struct simplelock*)&mcount_lock);
-
- s_lock_init((struct simplelock*)&fast_intr_lock);
- s_lock_init((struct simplelock*)&intr_lock);
- s_lock_init((struct simplelock*)&imen_lock);
- s_lock_init((struct simplelock*)&cpl_lock);
- s_lock_init(&smp_rv_lock);
-
-#ifdef USE_COMLOCK
- s_lock_init((struct simplelock*)&com_lock);
-#endif /* USE_COMLOCK */
-#ifdef USE_CLOCKLOCK
- s_lock_init((struct simplelock*)&clock_lock);
-#endif /* USE_CLOCKLOCK */
-}
-
-
-/* Wait for all APs to be fully initialized */
-extern int wait_ap(unsigned int);
-
-/*
- * start each AP in our list
- */
-static int
-start_all_aps(u_int boot_addr)
-{
- int x, i, pg;
- u_char mpbiosreason;
- u_long mpbioswarmvec;
- struct globaldata *gd;
- char *stack;
-
- POSTCODE(START_ALL_APS_POST);
-
- /* initialize BSP's local APIC */
- apic_initialize();
- bsp_apic_ready = 1;
-
- /* install the AP 1st level boot code */
- install_ap_tramp(boot_addr);
-
-
- /* save the current value of the warm-start vector */
- mpbioswarmvec = *((u_long *) WARMBOOT_OFF);
-#ifndef PC98
- outb(CMOS_REG, BIOS_RESET);
- mpbiosreason = inb(CMOS_DATA);
-#endif
-
- /* record BSP in CPU map */
- all_cpus = 1;
-
- /* set up 0 -> 4MB P==V mapping for AP boot */
- *(int *)PTD = PG_V | PG_RW | ((uintptr_t)(void *)KPTphys & PG_FRAME);
- invltlb();
-
- /* start each AP */
- for (x = 1; x <= mp_naps; ++x) {
-
- /* This is a bit verbose, it will go away soon. */
-
- /* first page of AP's private space */
- pg = x * i386_btop(sizeof(struct privatespace));
-
- /* allocate a new private data page */
- gd = (struct globaldata *)kmem_alloc(kernel_map, PAGE_SIZE);
-
- /* wire it into the private page table page */
- SMPpt[pg] = (pt_entry_t)(PG_V | PG_RW | vtophys(gd));
-
- /* allocate and set up an idle stack data page */
- stack = (char *)kmem_alloc(kernel_map, UPAGES*PAGE_SIZE);
- for (i = 0; i < UPAGES; i++)
- SMPpt[pg + 5 + i] = (pt_entry_t)
- (PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack));
-
- SMPpt[pg + 1] = 0; /* *prv_CMAP1 */
- SMPpt[pg + 2] = 0; /* *prv_CMAP2 */
- SMPpt[pg + 3] = 0; /* *prv_CMAP3 */
- SMPpt[pg + 4] = 0; /* *prv_PMAP1 */
-
- /* prime data page for it to use */
- gd->gd_cpuid = x;
- gd->gd_cpu_lockid = x << 24;
- gd->gd_prv_CMAP1 = &SMPpt[pg + 1];
- gd->gd_prv_CMAP2 = &SMPpt[pg + 2];
- gd->gd_prv_CMAP3 = &SMPpt[pg + 3];
- gd->gd_prv_PMAP1 = &SMPpt[pg + 4];
- gd->gd_prv_CADDR1 = SMP_prvspace[x].CPAGE1;
- gd->gd_prv_CADDR2 = SMP_prvspace[x].CPAGE2;
- gd->gd_prv_CADDR3 = SMP_prvspace[x].CPAGE3;
- gd->gd_prv_PADDR1 = (unsigned *)SMP_prvspace[x].PPAGE1;
-
- /* setup a vector to our boot code */
- *((volatile u_short *) WARMBOOT_OFF) = WARMBOOT_TARGET;
- *((volatile u_short *) WARMBOOT_SEG) = (boot_addr >> 4);
-#ifndef PC98
- outb(CMOS_REG, BIOS_RESET);
- outb(CMOS_DATA, BIOS_WARM); /* 'warm-start' */
-#endif
-
- bootSTK = &SMP_prvspace[x].idlestack[UPAGES*PAGE_SIZE];
- bootAP = x;
-
- /* attempt to start the Application Processor */
- CHECK_INIT(99); /* setup checkpoints */
- if (!start_ap(x, boot_addr)) {
- printf("AP #%d (PHY# %d) failed!\n", x, CPU_TO_ID(x));
- CHECK_PRINT("trace"); /* show checkpoints */
- /* better panic as the AP may be running loose */
- printf("panic y/n? [y] ");
- if (cngetc() != 'n')
- panic("bye-bye");
- }
- CHECK_PRINT("trace"); /* show checkpoints */
-
- /* record its version info */
- cpu_apic_versions[x] = cpu_apic_versions[0];
-
- all_cpus |= (1 << x); /* record AP in CPU map */
- }
-
- /* build our map of 'other' CPUs */
- other_cpus = all_cpus & ~(1 << cpuid);
-
- /* fill in our (BSP) APIC version */
- cpu_apic_versions[0] = lapic.version;
-
- /* restore the warmstart vector */
- *(u_long *) WARMBOOT_OFF = mpbioswarmvec;
-#ifndef PC98
- outb(CMOS_REG, BIOS_RESET);
- outb(CMOS_DATA, mpbiosreason);
-#endif
-
- /*
- * Set up the idle context for the BSP. Similar to above except
- * that some was done by locore, some by pmap.c and some is implicit
- * because the BSP is cpu#0 and the page is initially zero, and also
- * because we can refer to variables by name on the BSP..
- */
-
- /* Allocate and setup BSP idle stack */
- stack = (char *)kmem_alloc(kernel_map, UPAGES * PAGE_SIZE);
- for (i = 0; i < UPAGES; i++)
- SMPpt[5 + i] = (pt_entry_t)
- (PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack));
-
- *(int *)PTD = 0;
- pmap_set_opt();
-
- /* number of APs actually started */
- return mp_ncpus - 1;
-}
-
-
-/*
- * load the 1st level AP boot code into base memory.
- */
-
-/* targets for relocation */
-extern void bigJump(void);
-extern void bootCodeSeg(void);
-extern void bootDataSeg(void);
-extern void MPentry(void);
-extern u_int MP_GDT;
-extern u_int mp_gdtbase;
-
-static void
-install_ap_tramp(u_int boot_addr)
-{
- int x;
- int size = *(int *) ((u_long) & bootMP_size);
- u_char *src = (u_char *) ((u_long) bootMP);
- u_char *dst = (u_char *) boot_addr + KERNBASE;
- u_int boot_base = (u_int) bootMP;
- u_int8_t *dst8;
- u_int16_t *dst16;
- u_int32_t *dst32;
-
- POSTCODE(INSTALL_AP_TRAMP_POST);
-
- for (x = 0; x < size; ++x)
- *dst++ = *src++;
-
- /*
- * modify addresses in code we just moved to basemem. unfortunately we
- * need fairly detailed info about mpboot.s for this to work. changes
- * to mpboot.s might require changes here.
- */
-
- /* boot code is located in KERNEL space */
- dst = (u_char *) boot_addr + KERNBASE;
-
- /* modify the lgdt arg */
- dst32 = (u_int32_t *) (dst + ((u_int) & mp_gdtbase - boot_base));
- *dst32 = boot_addr + ((u_int) & MP_GDT - boot_base);
-
- /* modify the ljmp target for MPentry() */
- dst32 = (u_int32_t *) (dst + ((u_int) bigJump - boot_base) + 1);
- *dst32 = ((u_int) MPentry - KERNBASE);
-
- /* modify the target for boot code segment */
- dst16 = (u_int16_t *) (dst + ((u_int) bootCodeSeg - boot_base));
- dst8 = (u_int8_t *) (dst16 + 1);
- *dst16 = (u_int) boot_addr & 0xffff;
- *dst8 = ((u_int) boot_addr >> 16) & 0xff;
-
- /* modify the target for boot data segment */
- dst16 = (u_int16_t *) (dst + ((u_int) bootDataSeg - boot_base));
- dst8 = (u_int8_t *) (dst16 + 1);
- *dst16 = (u_int) boot_addr & 0xffff;
- *dst8 = ((u_int) boot_addr >> 16) & 0xff;
-}
-
-
-/*
- * this function starts the AP (application processor) identified
- * by the APIC ID 'physicalCpu'. It does quite a "song and dance"
- * to accomplish this. This is necessary because of the nuances
- * of the different hardware we might encounter. It ain't pretty,
- * but it seems to work.
- */
-static int
-start_ap(int logical_cpu, u_int boot_addr)
-{
- int physical_cpu;
- int vector;
- int cpus;
- u_long icr_lo, icr_hi;
-
- POSTCODE(START_AP_POST);
-
- /* get the PHYSICAL APIC ID# */
- physical_cpu = CPU_TO_ID(logical_cpu);
-
- /* calculate the vector */
- vector = (boot_addr >> 12) & 0xff;
-
- /* used as a watchpoint to signal AP startup */
- cpus = mp_ncpus;
-
- /*
- * first we do an INIT/RESET IPI this INIT IPI might be run, reseting
- * and running the target CPU. OR this INIT IPI might be latched (P5
- * bug), CPU waiting for STARTUP IPI. OR this INIT IPI might be
- * ignored.
- */
-
- /* setup the address for the target AP */
- icr_hi = lapic.icr_hi & ~APIC_ID_MASK;
- icr_hi |= (physical_cpu << 24);
- lapic.icr_hi = icr_hi;
-
- /* do an INIT IPI: assert RESET */
- icr_lo = lapic.icr_lo & 0xfff00000;
- lapic.icr_lo = icr_lo | 0x0000c500;
-
- /* wait for pending status end */
- while (lapic.icr_lo & APIC_DELSTAT_MASK)
- /* spin */ ;
-
- /* do an INIT IPI: deassert RESET */
- lapic.icr_lo = icr_lo | 0x00008500;
-
- /* wait for pending status end */
- u_sleep(10000); /* wait ~10mS */
- while (lapic.icr_lo & APIC_DELSTAT_MASK)
- /* spin */ ;
-
- /*
- * next we do a STARTUP IPI: the previous INIT IPI might still be
- * latched, (P5 bug) this 1st STARTUP would then terminate
- * immediately, and the previously started INIT IPI would continue. OR
- * the previous INIT IPI has already run. and this STARTUP IPI will
- * run. OR the previous INIT IPI was ignored. and this STARTUP IPI
- * will run.
- */
-
- /* do a STARTUP IPI */
- lapic.icr_lo = icr_lo | 0x00000600 | vector;
- while (lapic.icr_lo & APIC_DELSTAT_MASK)
- /* spin */ ;
- u_sleep(200); /* wait ~200uS */
-
- /*
- * finally we do a 2nd STARTUP IPI: this 2nd STARTUP IPI should run IF
- * the previous STARTUP IPI was cancelled by a latched INIT IPI. OR
- * this STARTUP IPI will be ignored, as only ONE STARTUP IPI is
- * recognized after hardware RESET or INIT IPI.
- */
-
- lapic.icr_lo = icr_lo | 0x00000600 | vector;
- while (lapic.icr_lo & APIC_DELSTAT_MASK)
- /* spin */ ;
- u_sleep(200); /* wait ~200uS */
-
- /* wait for it to start */
- set_apic_timer(5000000);/* == 5 seconds */
- while (read_apic_timer())
- if (mp_ncpus > cpus)
- return 1; /* return SUCCESS */
-
- return 0; /* return FAILURE */
-}
-
-
-/*
- * Flush the TLB on all other CPU's
- *
- * XXX: Needs to handshake and wait for completion before proceding.
- */
-void
-smp_invltlb(void)
-{
-#if defined(APIC_IO)
- if (smp_started && invltlb_ok)
- all_but_self_ipi(XINVLTLB_OFFSET);
-#endif /* APIC_IO */
-}
-
-void
-invlpg(u_int addr)
-{
- __asm __volatile("invlpg (%0)"::"r"(addr):"memory");
-
- /* send a message to the other CPUs */
- smp_invltlb();
-}
-
-void
-invltlb(void)
-{
- u_long temp;
-
- /*
- * This should be implemented as load_cr3(rcr3()) when load_cr3() is
- * inlined.
- */
- __asm __volatile("movl %%cr3, %0; movl %0, %%cr3":"=r"(temp) :: "memory");
-
- /* send a message to the other CPUs */
- smp_invltlb();
-}
-
-
-/*
- * When called the executing CPU will send an IPI to all other CPUs
- * requesting that they halt execution.
- *
- * Usually (but not necessarily) called with 'other_cpus' as its arg.
- *
- * - Signals all CPUs in map to stop.
- * - Waits for each to stop.
- *
- * Returns:
- * -1: error
- * 0: NA
- * 1: ok
- *
- * XXX FIXME: this is not MP-safe, needs a lock to prevent multiple CPUs
- * from executing at same time.
- */
-int
-stop_cpus(u_int map)
-{
- if (!smp_started)
- return 0;
-
- /* send the Xcpustop IPI to all CPUs in map */
- selected_apic_ipi(map, XCPUSTOP_OFFSET, APIC_DELMODE_FIXED);
-
- while ((stopped_cpus & map) != map)
- /* spin */ ;
-
- return 1;
-}
-
-
-/*
- * Called by a CPU to restart stopped CPUs.
- *
- * Usually (but not necessarily) called with 'stopped_cpus' as its arg.
- *
- * - Signals all CPUs in map to restart.
- * - Waits for each to restart.
- *
- * Returns:
- * -1: error
- * 0: NA
- * 1: ok
- */
-int
-restart_cpus(u_int map)
-{
- if (!smp_started)
- return 0;
-
- started_cpus = map; /* signal other cpus to restart */
-
- while ((stopped_cpus & map) != 0) /* wait for each to clear its bit */
- /* spin */ ;
-
- return 1;
-}
-
-int smp_active = 0; /* are the APs allowed to run? */
-SYSCTL_INT(_machdep, OID_AUTO, smp_active, CTLFLAG_RW, &smp_active, 0, "");
-
-/* XXX maybe should be hw.ncpu */
-static int smp_cpus = 1; /* how many cpu's running */
-SYSCTL_INT(_machdep, OID_AUTO, smp_cpus, CTLFLAG_RD, &smp_cpus, 0, "");
-
-int invltlb_ok = 0; /* throttle smp_invltlb() till safe */
-SYSCTL_INT(_machdep, OID_AUTO, invltlb_ok, CTLFLAG_RW, &invltlb_ok, 0, "");
-
-/* Warning: Do not staticize. Used from swtch.s */
-int do_page_zero_idle = 1; /* bzero pages for fun and profit in idleloop */
-SYSCTL_INT(_machdep, OID_AUTO, do_page_zero_idle, CTLFLAG_RW,
- &do_page_zero_idle, 0, "");
-
-/* Is forwarding of a interrupt to the CPU holding the ISR lock enabled ? */
-int forward_irq_enabled = 1;
-SYSCTL_INT(_machdep, OID_AUTO, forward_irq_enabled, CTLFLAG_RW,
- &forward_irq_enabled, 0, "");
-
-/* Enable forwarding of a signal to a process running on a different CPU */
-static int forward_signal_enabled = 1;
-SYSCTL_INT(_machdep, OID_AUTO, forward_signal_enabled, CTLFLAG_RW,
- &forward_signal_enabled, 0, "");
-
-/* Enable forwarding of roundrobin to all other cpus */
-static int forward_roundrobin_enabled = 1;
-SYSCTL_INT(_machdep, OID_AUTO, forward_roundrobin_enabled, CTLFLAG_RW,
- &forward_roundrobin_enabled, 0, "");
-
-/*
- * This is called once the rest of the system is up and running and we're
- * ready to let the AP's out of the pen.
- */
-void ap_init(void);
-
-void
-ap_init()
-{
- u_int apic_id;
-
- /* BSP may have changed PTD while we're waiting for the lock */
- cpu_invltlb();
-
- smp_cpus++;
-
-#if defined(I586_CPU) && !defined(NO_F00F_HACK)
- lidt(&r_idt);
-#endif
-
- /* Build our map of 'other' CPUs. */
- other_cpus = all_cpus & ~(1 << cpuid);
-
- printf("SMP: AP CPU #%d Launched!\n", cpuid);
-
- /* XXX FIXME: i386 specific, and redundant: Setup the FPU. */
- load_cr0((rcr0() & ~CR0_EM) | CR0_MP | CR0_NE | CR0_TS);
-
- /* set up FPU state on the AP */
- npxinit(__INITIAL_NPXCW__);
-
- /* A quick check from sanity claus */
- apic_id = (apic_id_to_logical[(lapic.id & 0x0f000000) >> 24]);
- if (cpuid != apic_id) {
- printf("SMP: cpuid = %d\n", cpuid);
- printf("SMP: apic_id = %d\n", apic_id);
- printf("PTD[MPPTDI] = %p\n", (void *)PTD[MPPTDI]);
- panic("cpuid mismatch! boom!!");
- }
-
- /* Init local apic for irq's */
- apic_initialize();
-
- /* Set memory range attributes for this CPU to match the BSP */
- mem_range_AP_init();
-
- /*
- * Activate smp_invltlb, although strictly speaking, this isn't
- * quite correct yet. We should have a bitfield for cpus willing
- * to accept TLB flush IPI's or something and sync them.
- */
- if (smp_cpus == mp_ncpus) {
- invltlb_ok = 1;
- smp_started = 1; /* enable IPI's, tlb shootdown, freezes etc */
- smp_active = 1; /* historic */
- }
-}
-
-#ifdef BETTER_CLOCK
-
-#define CHECKSTATE_USER 0
-#define CHECKSTATE_SYS 1
-#define CHECKSTATE_INTR 2
-
-/* Do not staticize. Used from apic_vector.s */
-struct proc* checkstate_curproc[NCPU];
-int checkstate_cpustate[NCPU];
-u_long checkstate_pc[NCPU];
-
-extern long cp_time[CPUSTATES];
-
-#define PC_TO_INDEX(pc, prof) \
- ((int)(((u_quad_t)((pc) - (prof)->pr_off) * \
- (u_quad_t)((prof)->pr_scale)) >> 16) & ~1)
-
-static void
-addupc_intr_forwarded(struct proc *p, int id, int *astmap)
-{
- int i;
- struct uprof *prof;
- u_long pc;
-
- pc = checkstate_pc[id];
- prof = &p->p_stats->p_prof;
- if (pc >= prof->pr_off &&
- (i = PC_TO_INDEX(pc, prof)) < prof->pr_size) {
- if ((p->p_flag & P_OWEUPC) == 0) {
- prof->pr_addr = pc;
- prof->pr_ticks = 1;
- p->p_flag |= P_OWEUPC;
- }
- *astmap |= (1 << id);
- }
-}
-
-static void
-forwarded_statclock(int id, int pscnt, int *astmap)
-{
- struct pstats *pstats;
- long rss;
- struct rusage *ru;
- struct vmspace *vm;
- int cpustate;
- struct proc *p;
-#ifdef GPROF
- register struct gmonparam *g;
- int i;
-#endif
-
- p = checkstate_curproc[id];
- cpustate = checkstate_cpustate[id];
-
- switch (cpustate) {
- case CHECKSTATE_USER:
- if (p->p_flag & P_PROFIL)
- addupc_intr_forwarded(p, id, astmap);
- if (pscnt > 1)
- return;
- p->p_uticks++;
- if (p->p_nice > NZERO)
- cp_time[CP_NICE]++;
- else
- cp_time[CP_USER]++;
- break;
- case CHECKSTATE_SYS:
-#ifdef GPROF
- /*
- * Kernel statistics are just like addupc_intr, only easier.
- */
- g = &_gmonparam;
- if (g->state == GMON_PROF_ON) {
- i = checkstate_pc[id] - g->lowpc;
- if (i < g->textsize) {
- i /= HISTFRACTION * sizeof(*g->kcount);
- g->kcount[i]++;
- }
- }
-#endif
- if (pscnt > 1)
- return;
-
- if (!p)
- cp_time[CP_IDLE]++;
- else {
- p->p_sticks++;
- cp_time[CP_SYS]++;
- }
- break;
- case CHECKSTATE_INTR:
- default:
-#ifdef GPROF
- /*
- * Kernel statistics are just like addupc_intr, only easier.
- */
- g = &_gmonparam;
- if (g->state == GMON_PROF_ON) {
- i = checkstate_pc[id] - g->lowpc;
- if (i < g->textsize) {
- i /= HISTFRACTION * sizeof(*g->kcount);
- g->kcount[i]++;
- }
- }
-#endif
- if (pscnt > 1)
- return;
- if (p)
- p->p_iticks++;
- cp_time[CP_INTR]++;
- }
- if (p != NULL) {
- schedclock(p);
-
- /* Update resource usage integrals and maximums. */
- if ((pstats = p->p_stats) != NULL &&
- (ru = &pstats->p_ru) != NULL &&
- (vm = p->p_vmspace) != NULL) {
- ru->ru_ixrss += pgtok(vm->vm_tsize);
- ru->ru_idrss += pgtok(vm->vm_dsize);
- ru->ru_isrss += pgtok(vm->vm_ssize);
- rss = pgtok(vmspace_resident_count(vm));
- if (ru->ru_maxrss < rss)
- ru->ru_maxrss = rss;
- }
- }
-}
-
-void
-forward_statclock(int pscnt)
-{
- int map;
- int id;
- int i;
-
- /* Kludge. We don't yet have separate locks for the interrupts
- * and the kernel. This means that we cannot let the other processors
- * handle complex interrupts while inhibiting them from entering
- * the kernel in a non-interrupt context.
- *
- * What we can do, without changing the locking mechanisms yet,
- * is letting the other processors handle a very simple interrupt
- * (wich determines the processor states), and do the main
- * work ourself.
- */
-
- if (!smp_started || !invltlb_ok || cold || panicstr)
- return;
-
- /* Step 1: Probe state (user, cpu, interrupt, spinlock, idle ) */
-
- map = other_cpus & ~stopped_cpus ;
- checkstate_probed_cpus = 0;
- if (map != 0)
- selected_apic_ipi(map,
- XCPUCHECKSTATE_OFFSET, APIC_DELMODE_FIXED);
-
- i = 0;
- while (checkstate_probed_cpus != map) {
- /* spin */
- i++;
- if (i == 100000) {
-#ifdef BETTER_CLOCK_DIAGNOSTIC
- printf("forward_statclock: checkstate %x\n",
- checkstate_probed_cpus);
-#endif
- break;
- }
- }
-
- /*
- * Step 2: walk through other processors processes, update ticks and
- * profiling info.
- */
-
- map = 0;
- for (id = 0; id < mp_ncpus; id++) {
- if (id == cpuid)
- continue;
- if (((1 << id) & checkstate_probed_cpus) == 0)
- continue;
- forwarded_statclock(id, pscnt, &map);
- }
- if (map != 0) {
- checkstate_need_ast |= map;
- selected_apic_ipi(map, XCPUAST_OFFSET, APIC_DELMODE_FIXED);
- i = 0;
- while ((checkstate_need_ast & map) != 0) {
- /* spin */
- i++;
- if (i > 100000) {
-#ifdef BETTER_CLOCK_DIAGNOSTIC
- printf("forward_statclock: dropped ast 0x%x\n",
- checkstate_need_ast & map);
-#endif
- break;
- }
- }
- }
-}
-
-void
-forward_hardclock(int pscnt)
-{
- int map;
- int id;
- struct proc *p;
- struct pstats *pstats;
- int i;
-
- /* Kludge. We don't yet have separate locks for the interrupts
- * and the kernel. This means that we cannot let the other processors
- * handle complex interrupts while inhibiting them from entering
- * the kernel in a non-interrupt context.
- *
- * What we can do, without changing the locking mechanisms yet,
- * is letting the other processors handle a very simple interrupt
- * (wich determines the processor states), and do the main
- * work ourself.
- */
-
- if (!smp_started || !invltlb_ok || cold || panicstr)
- return;
-
- /* Step 1: Probe state (user, cpu, interrupt, spinlock, idle) */
-
- map = other_cpus & ~stopped_cpus ;
- checkstate_probed_cpus = 0;
- if (map != 0)
- selected_apic_ipi(map,
- XCPUCHECKSTATE_OFFSET, APIC_DELMODE_FIXED);
-
- i = 0;
- while (checkstate_probed_cpus != map) {
- /* spin */
- i++;
- if (i == 100000) {
-#ifdef BETTER_CLOCK_DIAGNOSTIC
- printf("forward_hardclock: checkstate %x\n",
- checkstate_probed_cpus);
-#endif
- break;
- }
- }
-
- /*
- * Step 2: walk through other processors processes, update virtual
- * timer and profiling timer. If stathz == 0, also update ticks and
- * profiling info.
- */
-
- map = 0;
- for (id = 0; id < mp_ncpus; id++) {
- if (id == cpuid)
- continue;
- if (((1 << id) & checkstate_probed_cpus) == 0)
- continue;
- p = checkstate_curproc[id];
- if (p) {
- pstats = p->p_stats;
- if (checkstate_cpustate[id] == CHECKSTATE_USER &&
- timevalisset(&pstats->p_timer[ITIMER_VIRTUAL].it_value) &&
- itimerdecr(&pstats->p_timer[ITIMER_VIRTUAL], tick) == 0) {
- psignal(p, SIGVTALRM);
- map |= (1 << id);
- }
- if (timevalisset(&pstats->p_timer[ITIMER_PROF].it_value) &&
- itimerdecr(&pstats->p_timer[ITIMER_PROF], tick) == 0) {
- psignal(p, SIGPROF);
- map |= (1 << id);
- }
- }
- if (stathz == 0) {
- forwarded_statclock( id, pscnt, &map);
- }
- }
- if (map != 0) {
- checkstate_need_ast |= map;
- selected_apic_ipi(map, XCPUAST_OFFSET, APIC_DELMODE_FIXED);
- i = 0;
- while ((checkstate_need_ast & map) != 0) {
- /* spin */
- i++;
- if (i > 100000) {
-#ifdef BETTER_CLOCK_DIAGNOSTIC
- printf("forward_hardclock: dropped ast 0x%x\n",
- checkstate_need_ast & map);
-#endif
- break;
- }
- }
- }
-}
-
-#endif /* BETTER_CLOCK */
-
-void
-forward_signal(struct proc *p)
-{
- int map;
- int id;
- int i;
-
- /* Kludge. We don't yet have separate locks for the interrupts
- * and the kernel. This means that we cannot let the other processors
- * handle complex interrupts while inhibiting them from entering
- * the kernel in a non-interrupt context.
- *
- * What we can do, without changing the locking mechanisms yet,
- * is letting the other processors handle a very simple interrupt
- * (wich determines the processor states), and do the main
- * work ourself.
- */
-
- if (!smp_started || !invltlb_ok || cold || panicstr)
- return;
- if (!forward_signal_enabled)
- return;
- while (1) {
- if (p->p_stat != SRUN)
- return;
- id = p->p_oncpu;
- if (id == 0xff)
- return;
- map = (1<<id);
- checkstate_need_ast |= map;
- selected_apic_ipi(map, XCPUAST_OFFSET, APIC_DELMODE_FIXED);
- i = 0;
- while ((checkstate_need_ast & map) != 0) {
- /* spin */
- i++;
- if (i > 100000) {
-#if 0
- printf("forward_signal: dropped ast 0x%x\n",
- checkstate_need_ast & map);
-#endif
- break;
- }
- }
- if (id == p->p_oncpu)
- return;
- }
-}
-
-void
-forward_roundrobin(void)
-{
- u_int map;
- int i;
-
- if (!smp_started || !invltlb_ok || cold || panicstr)
- return;
- if (!forward_roundrobin_enabled)
- return;
- resched_cpus |= other_cpus;
- map = other_cpus & ~stopped_cpus ;
-#if 1
- selected_apic_ipi(map, XCPUAST_OFFSET, APIC_DELMODE_FIXED);
-#else
- (void) all_but_self_ipi(XCPUAST_OFFSET);
-#endif
- i = 0;
- while ((checkstate_need_ast & map) != 0) {
- /* spin */
- i++;
- if (i > 100000) {
-#if 0
- printf("forward_roundrobin: dropped ast 0x%x\n",
- checkstate_need_ast & map);
-#endif
- break;
- }
- }
-}
-
-
-#ifdef APIC_INTR_REORDER
-/*
- * Maintain mapping from softintr vector to isr bit in local apic.
- */
-void
-set_lapic_isrloc(int intr, int vector)
-{
- if (intr < 0 || intr > 32)
- panic("set_apic_isrloc: bad intr argument: %d",intr);
- if (vector < ICU_OFFSET || vector > 255)
- panic("set_apic_isrloc: bad vector argument: %d",vector);
- apic_isrbit_location[intr].location = &lapic.isr0 + ((vector>>5)<<2);
- apic_isrbit_location[intr].bit = (1<<(vector & 31));
-}
-#endif
-
-/*
- * All-CPU rendezvous. CPUs are signalled, all execute the setup function
- * (if specified), rendezvous, execute the action function (if specified),
- * rendezvous again, execute the teardown function (if specified), and then
- * resume.
- *
- * Note that the supplied external functions _must_ be reentrant and aware
- * that they are running in parallel and in an unknown lock context.
- */
-static void (*smp_rv_setup_func)(void *arg);
-static void (*smp_rv_action_func)(void *arg);
-static void (*smp_rv_teardown_func)(void *arg);
-static void *smp_rv_func_arg;
-static volatile int smp_rv_waiters[2];
-
-void
-smp_rendezvous_action(void)
-{
- /* setup function */
- if (smp_rv_setup_func != NULL)
- smp_rv_setup_func(smp_rv_func_arg);
- /* spin on entry rendezvous */
- atomic_add_int(&smp_rv_waiters[0], 1);
- while (smp_rv_waiters[0] < mp_ncpus)
- ;
- /* action function */
- if (smp_rv_action_func != NULL)
- smp_rv_action_func(smp_rv_func_arg);
- /* spin on exit rendezvous */
- atomic_add_int(&smp_rv_waiters[1], 1);
- while (smp_rv_waiters[1] < mp_ncpus)
- ;
- /* teardown function */
- if (smp_rv_teardown_func != NULL)
- smp_rv_teardown_func(smp_rv_func_arg);
-}
-
-void
-smp_rendezvous(void (* setup_func)(void *),
- void (* action_func)(void *),
- void (* teardown_func)(void *),
- void *arg)
-{
- u_int efl;
-
- /* obtain rendezvous lock */
- s_lock(&smp_rv_lock); /* XXX sleep here? NOWAIT flag? */
-
- /* set static function pointers */
- smp_rv_setup_func = setup_func;
- smp_rv_action_func = action_func;
- smp_rv_teardown_func = teardown_func;
- smp_rv_func_arg = arg;
- smp_rv_waiters[0] = 0;
- smp_rv_waiters[1] = 0;
-
- /* disable interrupts on this CPU, save interrupt status */
- efl = read_eflags();
- write_eflags(efl & ~PSL_I);
-
- /* signal other processors, which will enter the IPI with interrupts off */
- all_but_self_ipi(XRENDEZVOUS_OFFSET);
-
- /* call executor function */
- smp_rendezvous_action();
-
- /* restore interrupt flag */
- write_eflags(efl);
-
- /* release lock */
- s_unlock(&smp_rv_lock);
-}
diff --git a/sys/amd64/amd64/mpboot.S b/sys/amd64/amd64/mpboot.S
deleted file mode 100644
index e3e11f0e37ca..000000000000
--- a/sys/amd64/amd64/mpboot.S
+++ /dev/null
@@ -1,317 +0,0 @@
-/*
- * Copyright (c) 1995, Jack F. Vogel
- * 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 Jack F. Vogel
- * 4. The name of the developer may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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.
- *
- * mpboot.s: FreeBSD machine support for the Intel MP Spec
- * multiprocessor systems.
- *
- * $FreeBSD$
- */
-
-#include <machine/asmacros.h> /* miscellaneous asm macros */
-#include <machine/apic.h>
-#include <machine/specialreg.h>
-
-#include "assym.s"
-
-/*
- * this code MUST be enabled here and in mp_machdep.c
- * it follows the very early stages of AP boot by placing values in CMOS ram.
- * it NORMALLY will never be needed and thus the primitive method for enabling.
- *
-#define CHECK_POINTS
- */
-
-#if defined(CHECK_POINTS) && !defined(PC98)
-
-#define CMOS_REG (0x70)
-#define CMOS_DATA (0x71)
-
-#define CHECKPOINT(A,D) \
- movb $(A),%al ; \
- outb %al,$CMOS_REG ; \
- movb $(D),%al ; \
- outb %al,$CMOS_DATA
-
-#else
-
-#define CHECKPOINT(A,D)
-
-#endif /* CHECK_POINTS */
-
-
-/*
- * the APs enter here from their trampoline code (bootMP, below)
- */
- .p2align 4
-
-NON_GPROF_ENTRY(MPentry)
- CHECKPOINT(0x36, 3)
- /* Now enable paging mode */
- movl _IdlePTD-KERNBASE, %eax
- movl %eax,%cr3
- movl %cr0,%eax
- orl $CR0_PE|CR0_PG,%eax /* enable paging */
- movl %eax,%cr0 /* let the games begin! */
- movl _bootSTK,%esp /* boot stack end loc. */
-
- pushl $mp_begin /* jump to high mem */
- ret
-
- /*
- * Wait for the booting CPU to signal startup
- */
-mp_begin: /* now running relocated at KERNBASE */
- CHECKPOINT(0x37, 4)
- call _init_secondary /* load i386 tables */
- CHECKPOINT(0x38, 5)
-
- /*
- * If the [BSP] CPU has support for VME, turn it on.
- */
- testl $CPUID_VME, _cpu_feature /* XXX WRONG! BSP! */
- jz 1f
- movl %cr4, %eax
- orl $CR4_VME, %eax
- movl %eax, %cr4
-1:
-
- /* disable the APIC, just to be SURE */
- movl lapic_svr, %eax /* get spurious vector reg. */
- andl $~APIC_SVR_SWEN, %eax /* clear software enable bit */
- movl %eax, lapic_svr
-
- /* signal our startup to the BSP */
- movl lapic_ver, %eax /* our version reg contents */
- movl %eax, _cpu_apic_versions /* into [ 0 ] */
- incl _mp_ncpus /* signal BSP */
-
- CHECKPOINT(0x39, 6)
-
- /* wait till we can get into the kernel */
- call _boot_get_mplock
-
- /* Now, let's prepare for some REAL WORK :-) */
- call _ap_init
-
- call _rel_mplock
-2:
- cmpl $0, CNAME(smp_started) /* Wait for last AP to be ready */
- jz 2b
- call _get_mplock
-
- /* let her rip! (loads new stack) */
- jmp _cpu_switch
-
-NON_GPROF_ENTRY(wait_ap)
- pushl %ebp
- movl %esp, %ebp
- call _rel_mplock
- movl %eax, 8(%ebp)
-1:
- cmpl $0, CNAME(smp_started)
- jnz 2f
- decl %eax
- cmpl $0, %eax
- jge 1b
-2:
- call _get_mplock
- movl %ebp, %esp
- popl %ebp
- ret
-
-
-/*
- * This is the embedded trampoline or bootstrap that is
- * copied into 'real-mode' low memory, it is where the
- * secondary processor "wakes up". When it is executed
- * the processor will eventually jump into the routine
- * MPentry, which resides in normal kernel text above
- * 1Meg. -jackv
- */
-
-#define data32 .byte 0x66
-#define addr32 .byte 0x67
-
- .data
- ALIGN_DATA /* just to be sure */
-
-BOOTMP1:
-
-NON_GPROF_ENTRY(bootMP)
- cli
- CHECKPOINT(0x34, 1)
- /* First guarantee a 'clean slate' */
- data32
- xorl %eax, %eax
- data32
- movl %eax, %ebx
- data32
- movl %eax, %ecx
- data32
- movl %eax, %edx
- data32
- movl %eax, %esi
- data32
- movl %eax, %edi
-
- /* set up data segments */
- mov %cs, %ax
- mov %ax, %ds
- mov %ax, %es
- mov %ax, %fs
- mov %ax, %gs
- mov %ax, %ss
- mov $(boot_stk-_bootMP), %sp
-
- /* Now load the global descriptor table */
- addr32
- data32
- lgdt MP_GDTptr-_bootMP
-
- /* Enable protected mode */
- data32
- movl %cr0, %eax
- data32
- orl $CR0_PE, %eax
- data32
- movl %eax, %cr0
-
- /*
- * make intrasegment jump to flush the processor pipeline and
- * reload CS register
- */
- data32
- pushl $0x18
- data32
- pushl $(protmode-_bootMP)
- data32
- lret
-
-protmode:
- CHECKPOINT(0x35, 2)
-
- /*
- * we are NOW running for the first time with %eip
- * having the full physical address, BUT we still
- * are using a segment descriptor with the origin
- * not matching the booting kernel.
- *
- * SO NOW... for the BIG Jump into kernel's segment
- * and physical text above 1 Meg.
- */
- mov $0x10, %ebx
- movw %bx, %ds
- movw %bx, %es
- movw %bx, %fs
- movw %bx, %gs
- movw %bx, %ss
-
- .globl _bigJump
-_bigJump:
- /* this will be modified by mpInstallTramp() */
- ljmp $0x08, $0 /* far jmp to MPentry() */
-
-dead: hlt /* We should never get here */
- jmp dead
-
-/*
- * MP boot strap Global Descriptor Table
- */
- .p2align 4
- .globl _MP_GDT
- .globl _bootCodeSeg
- .globl _bootDataSeg
-_MP_GDT:
-
-nulldesc: /* offset = 0x0 */
-
- .word 0x0
- .word 0x0
- .byte 0x0
- .byte 0x0
- .byte 0x0
- .byte 0x0
-
-kernelcode: /* offset = 0x08 */
-
- .word 0xffff /* segment limit 0..15 */
- .word 0x0000 /* segment base 0..15 */
- .byte 0x0 /* segment base 16..23; set for 0K */
- .byte 0x9f /* flags; Type */
- .byte 0xcf /* flags; Limit */
- .byte 0x0 /* segment base 24..32 */
-
-kerneldata: /* offset = 0x10 */
-
- .word 0xffff /* segment limit 0..15 */
- .word 0x0000 /* segment base 0..15 */
- .byte 0x0 /* segment base 16..23; set for 0k */
- .byte 0x93 /* flags; Type */
- .byte 0xcf /* flags; Limit */
- .byte 0x0 /* segment base 24..32 */
-
-bootcode: /* offset = 0x18 */
-
- .word 0xffff /* segment limit 0..15 */
-_bootCodeSeg: /* this will be modified by mpInstallTramp() */
- .word 0x0000 /* segment base 0..15 */
- .byte 0x00 /* segment base 16...23; set for 0x000xx000 */
- .byte 0x9e /* flags; Type */
- .byte 0xcf /* flags; Limit */
- .byte 0x0 /*segment base 24..32 */
-
-bootdata: /* offset = 0x20 */
-
- .word 0xffff
-_bootDataSeg: /* this will be modified by mpInstallTramp() */
- .word 0x0000 /* segment base 0..15 */
- .byte 0x00 /* segment base 16...23; set for 0x000xx000 */
- .byte 0x92
- .byte 0xcf
- .byte 0x0
-
-/*
- * GDT pointer for the lgdt call
- */
- .globl _mp_gdtbase
-
-MP_GDTptr:
-_mp_gdtlimit:
- .word 0x0028
-_mp_gdtbase: /* this will be modified by mpInstallTramp() */
- .long 0
-
- .space 0x100 /* space for boot_stk - 1st temporary stack */
-boot_stk:
-
-BOOTMP2:
- .globl _bootMP_size
-_bootMP_size:
- .long BOOTMP2 - BOOTMP1
diff --git a/sys/amd64/amd64/mptable.c b/sys/amd64/amd64/mptable.c
deleted file mode 100644
index 8e349a9800e4..000000000000
--- a/sys/amd64/amd64/mptable.c
+++ /dev/null
@@ -1,2739 +0,0 @@
-/*
- * Copyright (c) 1996, by Steve Passe
- * 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 developer 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include "opt_smp.h"
-#include "opt_cpu.h"
-#include "opt_user_ldt.h"
-
-#ifdef SMP
-#include <machine/smptests.h>
-#else
-#error
-#endif
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/proc.h>
-#include <sys/sysctl.h>
-#include <sys/malloc.h>
-#include <sys/memrange.h>
-#ifdef BETTER_CLOCK
-#include <sys/dkstat.h>
-#endif
-#include <sys/cons.h> /* cngetc() */
-
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <vm/pmap.h>
-#include <vm/vm_kern.h>
-#include <vm/vm_extern.h>
-#ifdef BETTER_CLOCK
-#include <sys/lock.h>
-#include <vm/vm_map.h>
-#include <sys/user.h>
-#ifdef GPROF
-#include <sys/gmon.h>
-#endif
-#endif
-
-#include <machine/smp.h>
-#include <machine/apic.h>
-#include <machine/atomic.h>
-#include <machine/cpufunc.h>
-#include <machine/mpapic.h>
-#include <machine/psl.h>
-#include <machine/segments.h>
-#include <machine/smptests.h> /** TEST_DEFAULT_CONFIG, TEST_TEST1 */
-#include <machine/tss.h>
-#include <machine/specialreg.h>
-#include <machine/globaldata.h>
-
-#if defined(APIC_IO)
-#include <machine/md_var.h> /* setidt() */
-#include <i386/isa/icu.h> /* IPIs */
-#include <i386/isa/intr_machdep.h> /* IPIs */
-#endif /* APIC_IO */
-
-#if defined(TEST_DEFAULT_CONFIG)
-#define MPFPS_MPFB1 TEST_DEFAULT_CONFIG
-#else
-#define MPFPS_MPFB1 mpfps->mpfb1
-#endif /* TEST_DEFAULT_CONFIG */
-
-#define WARMBOOT_TARGET 0
-#define WARMBOOT_OFF (KERNBASE + 0x0467)
-#define WARMBOOT_SEG (KERNBASE + 0x0469)
-
-#ifdef PC98
-#define BIOS_BASE (0xe8000)
-#define BIOS_SIZE (0x18000)
-#else
-#define BIOS_BASE (0xf0000)
-#define BIOS_SIZE (0x10000)
-#endif
-#define BIOS_COUNT (BIOS_SIZE/4)
-
-#define CMOS_REG (0x70)
-#define CMOS_DATA (0x71)
-#define BIOS_RESET (0x0f)
-#define BIOS_WARM (0x0a)
-
-#define PROCENTRY_FLAG_EN 0x01
-#define PROCENTRY_FLAG_BP 0x02
-#define IOAPICENTRY_FLAG_EN 0x01
-
-
-/* MP Floating Pointer Structure */
-typedef struct MPFPS {
- char signature[4];
- void *pap;
- u_char length;
- u_char spec_rev;
- u_char checksum;
- u_char mpfb1;
- u_char mpfb2;
- u_char mpfb3;
- u_char mpfb4;
- u_char mpfb5;
-} *mpfps_t;
-
-/* MP Configuration Table Header */
-typedef struct MPCTH {
- char signature[4];
- u_short base_table_length;
- u_char spec_rev;
- u_char checksum;
- u_char oem_id[8];
- u_char product_id[12];
- void *oem_table_pointer;
- u_short oem_table_size;
- u_short entry_count;
- void *apic_address;
- u_short extended_table_length;
- u_char extended_table_checksum;
- u_char reserved;
-} *mpcth_t;
-
-
-typedef struct PROCENTRY {
- u_char type;
- u_char apic_id;
- u_char apic_version;
- u_char cpu_flags;
- u_long cpu_signature;
- u_long feature_flags;
- u_long reserved1;
- u_long reserved2;
-} *proc_entry_ptr;
-
-typedef struct BUSENTRY {
- u_char type;
- u_char bus_id;
- char bus_type[6];
-} *bus_entry_ptr;
-
-typedef struct IOAPICENTRY {
- u_char type;
- u_char apic_id;
- u_char apic_version;
- u_char apic_flags;
- void *apic_address;
-} *io_apic_entry_ptr;
-
-typedef struct INTENTRY {
- u_char type;
- u_char int_type;
- u_short int_flags;
- u_char src_bus_id;
- u_char src_bus_irq;
- u_char dst_apic_id;
- u_char dst_apic_int;
-} *int_entry_ptr;
-
-/* descriptions of MP basetable entries */
-typedef struct BASETABLE_ENTRY {
- u_char type;
- u_char length;
- char name[16];
-} basetable_entry;
-
-/*
- * this code MUST be enabled here and in mpboot.s.
- * it follows the very early stages of AP boot by placing values in CMOS ram.
- * it NORMALLY will never be needed and thus the primitive method for enabling.
- *
-#define CHECK_POINTS
- */
-
-#if defined(CHECK_POINTS) && !defined(PC98)
-#define CHECK_READ(A) (outb(CMOS_REG, (A)), inb(CMOS_DATA))
-#define CHECK_WRITE(A,D) (outb(CMOS_REG, (A)), outb(CMOS_DATA, (D)))
-
-#define CHECK_INIT(D); \
- CHECK_WRITE(0x34, (D)); \
- CHECK_WRITE(0x35, (D)); \
- CHECK_WRITE(0x36, (D)); \
- CHECK_WRITE(0x37, (D)); \
- CHECK_WRITE(0x38, (D)); \
- CHECK_WRITE(0x39, (D));
-
-#define CHECK_PRINT(S); \
- printf("%s: %d, %d, %d, %d, %d, %d\n", \
- (S), \
- CHECK_READ(0x34), \
- CHECK_READ(0x35), \
- CHECK_READ(0x36), \
- CHECK_READ(0x37), \
- CHECK_READ(0x38), \
- CHECK_READ(0x39));
-
-#else /* CHECK_POINTS */
-
-#define CHECK_INIT(D)
-#define CHECK_PRINT(S)
-
-#endif /* CHECK_POINTS */
-
-/*
- * Values to send to the POST hardware.
- */
-#define MP_BOOTADDRESS_POST 0x10
-#define MP_PROBE_POST 0x11
-#define MPTABLE_PASS1_POST 0x12
-
-#define MP_START_POST 0x13
-#define MP_ENABLE_POST 0x14
-#define MPTABLE_PASS2_POST 0x15
-
-#define START_ALL_APS_POST 0x16
-#define INSTALL_AP_TRAMP_POST 0x17
-#define START_AP_POST 0x18
-
-#define MP_ANNOUNCE_POST 0x19
-
-
-/** XXX FIXME: where does this really belong, isa.h/isa.c perhaps? */
-int current_postcode;
-
-/** XXX FIXME: what system files declare these??? */
-extern struct region_descriptor r_gdt, r_idt;
-
-int bsp_apic_ready = 0; /* flags useability of BSP apic */
-int mp_ncpus; /* # of CPUs, including BSP */
-int mp_naps; /* # of Applications processors */
-int mp_nbusses; /* # of busses */
-int mp_napics; /* # of IO APICs */
-int boot_cpu_id; /* designated BSP */
-vm_offset_t cpu_apic_address;
-vm_offset_t io_apic_address[NAPICID]; /* NAPICID is more than enough */
-extern int nkpt;
-
-u_int32_t cpu_apic_versions[NCPU];
-u_int32_t io_apic_versions[NAPIC];
-
-#ifdef APIC_INTR_DIAGNOSTIC
-int apic_itrace_enter[32];
-int apic_itrace_tryisrlock[32];
-int apic_itrace_gotisrlock[32];
-int apic_itrace_active[32];
-int apic_itrace_masked[32];
-int apic_itrace_noisrlock[32];
-int apic_itrace_masked2[32];
-int apic_itrace_unmask[32];
-int apic_itrace_noforward[32];
-int apic_itrace_leave[32];
-int apic_itrace_enter2[32];
-int apic_itrace_doreti[32];
-int apic_itrace_splz[32];
-int apic_itrace_eoi[32];
-#ifdef APIC_INTR_DIAGNOSTIC_IRQ
-unsigned short apic_itrace_debugbuffer[32768];
-int apic_itrace_debugbuffer_idx;
-struct simplelock apic_itrace_debuglock;
-#endif
-#endif
-
-#ifdef APIC_INTR_REORDER
-struct {
- volatile int *location;
- int bit;
-} apic_isrbit_location[32];
-#endif
-
-struct apic_intmapinfo int_to_apicintpin[APIC_INTMAPSIZE];
-
-/*
- * APIC ID logical/physical mapping structures.
- * We oversize these to simplify boot-time config.
- */
-int cpu_num_to_apic_id[NAPICID];
-int io_num_to_apic_id[NAPICID];
-int apic_id_to_logical[NAPICID];
-
-
-/* Bitmap of all available CPUs */
-u_int all_cpus;
-
-/* AP uses this during bootstrap. Do not staticize. */
-char *bootSTK;
-static int bootAP;
-
-/* Hotwire a 0->4MB V==P mapping */
-extern pt_entry_t *KPTphys;
-
-/* SMP page table page */
-extern pt_entry_t *SMPpt;
-
-struct pcb stoppcbs[NCPU];
-
-int smp_started; /* has the system started? */
-
-/*
- * Local data and functions.
- */
-
-static int mp_capable;
-static u_int boot_address;
-static u_int base_memory;
-
-static int picmode; /* 0: virtual wire mode, 1: PIC mode */
-static mpfps_t mpfps;
-static int search_for_sig(u_int32_t target, int count);
-static void mp_enable(u_int boot_addr);
-
-static int mptable_pass1(void);
-static int mptable_pass2(void);
-static void default_mp_table(int type);
-static void fix_mp_table(void);
-static void setup_apic_irq_mapping(void);
-static void init_locks(void);
-static int start_all_aps(u_int boot_addr);
-static void install_ap_tramp(u_int boot_addr);
-static int start_ap(int logicalCpu, u_int boot_addr);
-static int apic_int_is_bus_type(int intr, int bus_type);
-
-/*
- * Calculate usable address in base memory for AP trampoline code.
- */
-u_int
-mp_bootaddress(u_int basemem)
-{
- POSTCODE(MP_BOOTADDRESS_POST);
-
- base_memory = basemem * 1024; /* convert to bytes */
-
- boot_address = base_memory & ~0xfff; /* round down to 4k boundary */
- if ((base_memory - boot_address) < bootMP_size)
- boot_address -= 4096; /* not enough, lower by 4k */
-
- return boot_address;
-}
-
-
-/*
- * Look for an Intel MP spec table (ie, SMP capable hardware).
- */
-int
-mp_probe(void)
-{
- int x;
- u_long segment;
- u_int32_t target;
-
- POSTCODE(MP_PROBE_POST);
-
- /* see if EBDA exists */
- if ((segment = (u_long) * (u_short *) (KERNBASE + 0x40e)) != 0) {
- /* search first 1K of EBDA */
- target = (u_int32_t) (segment << 4);
- if ((x = search_for_sig(target, 1024 / 4)) >= 0)
- goto found;
- } else {
- /* last 1K of base memory, effective 'top of base' passed in */
- target = (u_int32_t) (base_memory - 0x400);
- if ((x = search_for_sig(target, 1024 / 4)) >= 0)
- goto found;
- }
-
- /* search the BIOS */
- target = (u_int32_t) BIOS_BASE;
- if ((x = search_for_sig(target, BIOS_COUNT)) >= 0)
- goto found;
-
- /* nothing found */
- mpfps = (mpfps_t)0;
- mp_capable = 0;
- return 0;
-
-found:
- /* calculate needed resources */
- mpfps = (mpfps_t)x;
- if (mptable_pass1())
- panic("you must reconfigure your kernel");
-
- /* flag fact that we are running multiple processors */
- mp_capable = 1;
- return 1;
-}
-
-
-/*
- * Startup the SMP processors.
- */
-void
-mp_start(void)
-{
- POSTCODE(MP_START_POST);
-
- /* look for MP capable motherboard */
- if (mp_capable)
- mp_enable(boot_address);
- else
- panic("MP hardware not found!");
-}
-
-
-/*
- * Print various information about the SMP system hardware and setup.
- */
-void
-mp_announce(void)
-{
- int x;
-
- POSTCODE(MP_ANNOUNCE_POST);
-
- printf("FreeBSD/SMP: Multiprocessor motherboard\n");
- printf(" cpu0 (BSP): apic id: %2d", CPU_TO_ID(0));
- printf(", version: 0x%08x", cpu_apic_versions[0]);
- printf(", at 0x%08x\n", cpu_apic_address);
- for (x = 1; x <= mp_naps; ++x) {
- printf(" cpu%d (AP): apic id: %2d", x, CPU_TO_ID(x));
- printf(", version: 0x%08x", cpu_apic_versions[x]);
- printf(", at 0x%08x\n", cpu_apic_address);
- }
-
-#if defined(APIC_IO)
- for (x = 0; x < mp_napics; ++x) {
- printf(" io%d (APIC): apic id: %2d", x, IO_TO_ID(x));
- printf(", version: 0x%08x", io_apic_versions[x]);
- printf(", at 0x%08x\n", io_apic_address[x]);
- }
-#else
- printf(" Warning: APIC I/O disabled\n");
-#endif /* APIC_IO */
-}
-
-/*
- * AP cpu's call this to sync up protected mode.
- */
-void
-init_secondary(void)
-{
- int gsel_tss;
- int x, myid = bootAP;
-
- gdt_segs[GPRIV_SEL].ssd_base = (int) &SMP_prvspace[myid];
- gdt_segs[GPROC0_SEL].ssd_base =
- (int) &SMP_prvspace[myid].globaldata.gd_common_tss;
- SMP_prvspace[myid].globaldata.gd_prvspace = &SMP_prvspace[myid];
-
- for (x = 0; x < NGDT; x++) {
- ssdtosd(&gdt_segs[x], &gdt[myid * NGDT + x].sd);
- }
-
- r_gdt.rd_limit = NGDT * sizeof(gdt[0]) - 1;
- r_gdt.rd_base = (int) &gdt[myid * NGDT];
- lgdt(&r_gdt); /* does magic intra-segment return */
-
- lidt(&r_idt);
-
- lldt(_default_ldt);
-#ifdef USER_LDT
- currentldt = _default_ldt;
-#endif
-
- gsel_tss = GSEL(GPROC0_SEL, SEL_KPL);
- gdt[myid * NGDT + GPROC0_SEL].sd.sd_type = SDT_SYS386TSS;
- common_tss.tss_esp0 = 0; /* not used until after switch */
- common_tss.tss_ss0 = GSEL(GDATA_SEL, SEL_KPL);
- common_tss.tss_ioopt = (sizeof common_tss) << 16;
- tss_gdt = &gdt[myid * NGDT + GPROC0_SEL].sd;
- common_tssd = *tss_gdt;
- ltr(gsel_tss);
-
- load_cr0(0x8005003b); /* XXX! */
-
- pmap_set_opt();
-}
-
-
-#if defined(APIC_IO)
-/*
- * Final configuration of the BSP's local APIC:
- * - disable 'pic mode'.
- * - disable 'virtual wire mode'.
- * - enable NMI.
- */
-void
-bsp_apic_configure(void)
-{
- u_char byte;
- u_int32_t temp;
-
- /* leave 'pic mode' if necessary */
- if (picmode) {
- outb(0x22, 0x70); /* select IMCR */
- byte = inb(0x23); /* current contents */
- byte |= 0x01; /* mask external INTR */
- outb(0x23, byte); /* disconnect 8259s/NMI */
- }
-
- /* mask lint0 (the 8259 'virtual wire' connection) */
- temp = lapic.lvt_lint0;
- temp |= APIC_LVT_M; /* set the mask */
- lapic.lvt_lint0 = temp;
-
- /* setup lint1 to handle NMI */
- temp = lapic.lvt_lint1;
- temp &= ~APIC_LVT_M; /* clear the mask */
- lapic.lvt_lint1 = temp;
-
- if (bootverbose)
- apic_dump("bsp_apic_configure()");
-}
-#endif /* APIC_IO */
-
-
-/*******************************************************************
- * local functions and data
- */
-
-/*
- * start the SMP system
- */
-static void
-mp_enable(u_int boot_addr)
-{
- int x;
-#if defined(APIC_IO)
- int apic;
- u_int ux;
-#endif /* APIC_IO */
-
- POSTCODE(MP_ENABLE_POST);
-
- /* turn on 4MB of V == P addressing so we can get to MP table */
- *(int *)PTD = PG_V | PG_RW | ((uintptr_t)(void *)KPTphys & PG_FRAME);
- invltlb();
-
- /* examine the MP table for needed info, uses physical addresses */
- x = mptable_pass2();
-
- *(int *)PTD = 0;
- invltlb();
-
- /* can't process default configs till the CPU APIC is pmapped */
- if (x)
- default_mp_table(x);
-
- /* post scan cleanup */
- fix_mp_table();
- setup_apic_irq_mapping();
-
-#if defined(APIC_IO)
-
- /* fill the LOGICAL io_apic_versions table */
- for (apic = 0; apic < mp_napics; ++apic) {
- ux = io_apic_read(apic, IOAPIC_VER);
- io_apic_versions[apic] = ux;
- }
-
- /* program each IO APIC in the system */
- for (apic = 0; apic < mp_napics; ++apic)
- if (io_apic_setup(apic) < 0)
- panic("IO APIC setup failure");
-
- /* install a 'Spurious INTerrupt' vector */
- setidt(XSPURIOUSINT_OFFSET, Xspuriousint,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-
- /* install an inter-CPU IPI for TLB invalidation */
- setidt(XINVLTLB_OFFSET, Xinvltlb,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-
-#ifdef BETTER_CLOCK
- /* install an inter-CPU IPI for reading processor state */
- setidt(XCPUCHECKSTATE_OFFSET, Xcpucheckstate,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-#endif
-
- /* install an inter-CPU IPI for all-CPU rendezvous */
- setidt(XRENDEZVOUS_OFFSET, Xrendezvous,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-
- /* install an inter-CPU IPI for forcing an additional software trap */
- setidt(XCPUAST_OFFSET, Xcpuast,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-
- /* install an inter-CPU IPI for interrupt forwarding */
- setidt(XFORWARD_IRQ_OFFSET, Xforward_irq,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-
- /* install an inter-CPU IPI for CPU stop/restart */
- setidt(XCPUSTOP_OFFSET, Xcpustop,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-
-#if defined(TEST_TEST1)
- /* install a "fake hardware INTerrupt" vector */
- setidt(XTEST1_OFFSET, Xtest1,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-#endif /** TEST_TEST1 */
-
-#endif /* APIC_IO */
-
- /* initialize all SMP locks */
- init_locks();
-
- /* start each Application Processor */
- start_all_aps(boot_addr);
-
- /*
- * The init process might be started on a different CPU now,
- * and the boot CPU might not call prepare_usermode to get
- * cr0 correctly configured. Thus we initialize cr0 here.
- */
- load_cr0(rcr0() | CR0_WP | CR0_AM);
-}
-
-
-/*
- * look for the MP spec signature
- */
-
-/* string defined by the Intel MP Spec as identifying the MP table */
-#define MP_SIG 0x5f504d5f /* _MP_ */
-#define NEXT(X) ((X) += 4)
-static int
-search_for_sig(u_int32_t target, int count)
-{
- int x;
- u_int32_t *addr = (u_int32_t *) (KERNBASE + target);
-
- for (x = 0; x < count; NEXT(x))
- if (addr[x] == MP_SIG)
- /* make array index a byte index */
- return (target + (x * sizeof(u_int32_t)));
-
- return -1;
-}
-
-
-static basetable_entry basetable_entry_types[] =
-{
- {0, 20, "Processor"},
- {1, 8, "Bus"},
- {2, 8, "I/O APIC"},
- {3, 8, "I/O INT"},
- {4, 8, "Local INT"}
-};
-
-typedef struct BUSDATA {
- u_char bus_id;
- enum busTypes bus_type;
-} bus_datum;
-
-typedef struct INTDATA {
- u_char int_type;
- u_short int_flags;
- u_char src_bus_id;
- u_char src_bus_irq;
- u_char dst_apic_id;
- u_char dst_apic_int;
- u_char int_vector;
-} io_int, local_int;
-
-typedef struct BUSTYPENAME {
- u_char type;
- char name[7];
-} bus_type_name;
-
-static bus_type_name bus_type_table[] =
-{
- {CBUS, "CBUS"},
- {CBUSII, "CBUSII"},
- {EISA, "EISA"},
- {MCA, "MCA"},
- {UNKNOWN_BUSTYPE, "---"},
- {ISA, "ISA"},
- {MCA, "MCA"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {PCI, "PCI"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {XPRESS, "XPRESS"},
- {UNKNOWN_BUSTYPE, "---"}
-};
-/* from MP spec v1.4, table 5-1 */
-static int default_data[7][5] =
-{
-/* nbus, id0, type0, id1, type1 */
- {1, 0, ISA, 255, 255},
- {1, 0, EISA, 255, 255},
- {1, 0, EISA, 255, 255},
- {1, 0, MCA, 255, 255},
- {2, 0, ISA, 1, PCI},
- {2, 0, EISA, 1, PCI},
- {2, 0, MCA, 1, PCI}
-};
-
-
-/* the bus data */
-static bus_datum bus_data[NBUS];
-
-/* the IO INT data, one entry per possible APIC INTerrupt */
-static io_int io_apic_ints[NINTR];
-
-static int nintrs;
-
-static int processor_entry __P((proc_entry_ptr entry, int cpu));
-static int bus_entry __P((bus_entry_ptr entry, int bus));
-static int io_apic_entry __P((io_apic_entry_ptr entry, int apic));
-static int int_entry __P((int_entry_ptr entry, int intr));
-static int lookup_bus_type __P((char *name));
-
-
-/*
- * 1st pass on motherboard's Intel MP specification table.
- *
- * initializes:
- * mp_ncpus = 1
- *
- * determines:
- * cpu_apic_address (common to all CPUs)
- * io_apic_address[N]
- * mp_naps
- * mp_nbusses
- * mp_napics
- * nintrs
- */
-static int
-mptable_pass1(void)
-{
- int x;
- mpcth_t cth;
- int totalSize;
- void* position;
- int count;
- int type;
- int mustpanic;
-
- POSTCODE(MPTABLE_PASS1_POST);
-
- mustpanic = 0;
-
- /* clear various tables */
- for (x = 0; x < NAPICID; ++x) {
- io_apic_address[x] = ~0; /* IO APIC address table */
- }
-
- /* init everything to empty */
- mp_naps = 0;
- mp_nbusses = 0;
- mp_napics = 0;
- nintrs = 0;
-
- /* check for use of 'default' configuration */
- if (MPFPS_MPFB1 != 0) {
- /* use default addresses */
- cpu_apic_address = DEFAULT_APIC_BASE;
- io_apic_address[0] = DEFAULT_IO_APIC_BASE;
-
- /* fill in with defaults */
- mp_naps = 2; /* includes BSP */
- mp_nbusses = default_data[MPFPS_MPFB1 - 1][0];
-#if defined(APIC_IO)
- mp_napics = 1;
- nintrs = 16;
-#endif /* APIC_IO */
- }
- else {
- if ((cth = mpfps->pap) == 0)
- panic("MP Configuration Table Header MISSING!");
-
- cpu_apic_address = (vm_offset_t) cth->apic_address;
-
- /* walk the table, recording info of interest */
- totalSize = cth->base_table_length - sizeof(struct MPCTH);
- position = (u_char *) cth + sizeof(struct MPCTH);
- count = cth->entry_count;
-
- while (count--) {
- switch (type = *(u_char *) position) {
- case 0: /* processor_entry */
- if (((proc_entry_ptr)position)->cpu_flags
- & PROCENTRY_FLAG_EN)
- ++mp_naps;
- break;
- case 1: /* bus_entry */
- ++mp_nbusses;
- break;
- case 2: /* io_apic_entry */
- if (((io_apic_entry_ptr)position)->apic_flags
- & IOAPICENTRY_FLAG_EN)
- io_apic_address[mp_napics++] =
- (vm_offset_t)((io_apic_entry_ptr)
- position)->apic_address;
- break;
- case 3: /* int_entry */
- ++nintrs;
- break;
- case 4: /* int_entry */
- break;
- default:
- panic("mpfps Base Table HOSED!");
- /* NOTREACHED */
- }
-
- totalSize -= basetable_entry_types[type].length;
- (u_char*)position += basetable_entry_types[type].length;
- }
- }
-
- /* qualify the numbers */
- if (mp_naps > NCPU) {
- printf("Warning: only using %d of %d available CPUs!\n",
- NCPU, mp_naps);
- mp_naps = NCPU;
- }
- if (mp_nbusses > NBUS) {
- printf("found %d busses, increase NBUS\n", mp_nbusses);
- mustpanic = 1;
- }
- if (mp_napics > NAPIC) {
- printf("found %d apics, increase NAPIC\n", mp_napics);
- mustpanic = 1;
- }
- if (nintrs > NINTR) {
- printf("found %d intrs, increase NINTR\n", nintrs);
- mustpanic = 1;
- }
-
- /*
- * Count the BSP.
- * This is also used as a counter while starting the APs.
- */
- mp_ncpus = 1;
-
- --mp_naps; /* subtract the BSP */
-
- return mustpanic;
-}
-
-
-/*
- * 2nd pass on motherboard's Intel MP specification table.
- *
- * sets:
- * boot_cpu_id
- * ID_TO_IO(N), phy APIC ID to log CPU/IO table
- * CPU_TO_ID(N), logical CPU to APIC ID table
- * IO_TO_ID(N), logical IO to APIC ID table
- * bus_data[N]
- * io_apic_ints[N]
- */
-static int
-mptable_pass2(void)
-{
- int x;
- mpcth_t cth;
- int totalSize;
- void* position;
- int count;
- int type;
- int apic, bus, cpu, intr;
-
- POSTCODE(MPTABLE_PASS2_POST);
-
- /* clear various tables */
- for (x = 0; x < NAPICID; ++x) {
- ID_TO_IO(x) = -1; /* phy APIC ID to log CPU/IO table */
- CPU_TO_ID(x) = -1; /* logical CPU to APIC ID table */
- IO_TO_ID(x) = -1; /* logical IO to APIC ID table */
- }
-
- /* clear bus data table */
- for (x = 0; x < NBUS; ++x)
- bus_data[x].bus_id = 0xff;
-
- /* clear IO APIC INT table */
- for (x = 0; x < NINTR; ++x) {
- io_apic_ints[x].int_type = 0xff;
- io_apic_ints[x].int_vector = 0xff;
- }
-
- /* setup the cpu/apic mapping arrays */
- boot_cpu_id = -1;
-
- /* record whether PIC or virtual-wire mode */
- picmode = (mpfps->mpfb2 & 0x80) ? 1 : 0;
-
- /* check for use of 'default' configuration */
- if (MPFPS_MPFB1 != 0)
- return MPFPS_MPFB1; /* return default configuration type */
-
- if ((cth = mpfps->pap) == 0)
- panic("MP Configuration Table Header MISSING!");
-
- /* walk the table, recording info of interest */
- totalSize = cth->base_table_length - sizeof(struct MPCTH);
- position = (u_char *) cth + sizeof(struct MPCTH);
- count = cth->entry_count;
- apic = bus = intr = 0;
- cpu = 1; /* pre-count the BSP */
-
- while (count--) {
- switch (type = *(u_char *) position) {
- case 0:
- if (processor_entry(position, cpu))
- ++cpu;
- break;
- case 1:
- if (bus_entry(position, bus))
- ++bus;
- break;
- case 2:
- if (io_apic_entry(position, apic))
- ++apic;
- break;
- case 3:
- if (int_entry(position, intr))
- ++intr;
- break;
- case 4:
- /* int_entry(position); */
- break;
- default:
- panic("mpfps Base Table HOSED!");
- /* NOTREACHED */
- }
-
- totalSize -= basetable_entry_types[type].length;
- (u_char *) position += basetable_entry_types[type].length;
- }
-
- if (boot_cpu_id == -1)
- panic("NO BSP found!");
-
- /* report fact that its NOT a default configuration */
- return 0;
-}
-
-
-void
-assign_apic_irq(int apic, int intpin, int irq)
-{
- int x;
-
- if (int_to_apicintpin[irq].ioapic != -1)
- panic("assign_apic_irq: inconsistent table");
-
- int_to_apicintpin[irq].ioapic = apic;
- int_to_apicintpin[irq].int_pin = intpin;
- int_to_apicintpin[irq].apic_address = ioapic[apic];
- int_to_apicintpin[irq].redirindex = IOAPIC_REDTBL + 2 * intpin;
-
- for (x = 0; x < nintrs; x++) {
- if ((io_apic_ints[x].int_type == 0 ||
- io_apic_ints[x].int_type == 3) &&
- io_apic_ints[x].int_vector == 0xff &&
- io_apic_ints[x].dst_apic_id == IO_TO_ID(apic) &&
- io_apic_ints[x].dst_apic_int == intpin)
- io_apic_ints[x].int_vector = irq;
- }
-}
-
-void
-revoke_apic_irq(int irq)
-{
- int x;
- int oldapic;
- int oldintpin;
-
- if (int_to_apicintpin[irq].ioapic == -1)
- panic("assign_apic_irq: inconsistent table");
-
- oldapic = int_to_apicintpin[irq].ioapic;
- oldintpin = int_to_apicintpin[irq].int_pin;
-
- int_to_apicintpin[irq].ioapic = -1;
- int_to_apicintpin[irq].int_pin = 0;
- int_to_apicintpin[irq].apic_address = NULL;
- int_to_apicintpin[irq].redirindex = 0;
-
- for (x = 0; x < nintrs; x++) {
- if ((io_apic_ints[x].int_type == 0 ||
- io_apic_ints[x].int_type == 3) &&
- io_apic_ints[x].int_vector == 0xff &&
- io_apic_ints[x].dst_apic_id == IO_TO_ID(oldapic) &&
- io_apic_ints[x].dst_apic_int == oldintpin)
- io_apic_ints[x].int_vector = 0xff;
- }
-}
-
-/*
- * parse an Intel MP specification table
- */
-static void
-fix_mp_table(void)
-{
- int x;
- int id;
- int bus_0 = 0; /* Stop GCC warning */
- int bus_pci = 0; /* Stop GCC warning */
- int num_pci_bus;
-
- /*
- * Fix mis-numbering of the PCI bus and its INT entries if the BIOS
- * did it wrong. The MP spec says that when more than 1 PCI bus
- * exists the BIOS must begin with bus entries for the PCI bus and use
- * actual PCI bus numbering. This implies that when only 1 PCI bus
- * exists the BIOS can choose to ignore this ordering, and indeed many
- * MP motherboards do ignore it. This causes a problem when the PCI
- * sub-system makes requests of the MP sub-system based on PCI bus
- * numbers. So here we look for the situation and renumber the
- * busses and associated INTs in an effort to "make it right".
- */
-
- /* find bus 0, PCI bus, count the number of PCI busses */
- for (num_pci_bus = 0, x = 0; x < mp_nbusses; ++x) {
- if (bus_data[x].bus_id == 0) {
- bus_0 = x;
- }
- if (bus_data[x].bus_type == PCI) {
- ++num_pci_bus;
- bus_pci = x;
- }
- }
- /*
- * bus_0 == slot of bus with ID of 0
- * bus_pci == slot of last PCI bus encountered
- */
-
- /* check the 1 PCI bus case for sanity */
- if (num_pci_bus == 1) {
-
- /* if it is number 0 all is well */
- if (bus_data[bus_pci].bus_id == 0)
- return;
-
- /* mis-numbered, swap with whichever bus uses slot 0 */
-
- /* swap the bus entry types */
- bus_data[bus_pci].bus_type = bus_data[bus_0].bus_type;
- bus_data[bus_0].bus_type = PCI;
-
- /* swap each relavant INTerrupt entry */
- id = bus_data[bus_pci].bus_id;
- for (x = 0; x < nintrs; ++x) {
- if (io_apic_ints[x].src_bus_id == id) {
- io_apic_ints[x].src_bus_id = 0;
- }
- else if (io_apic_ints[x].src_bus_id == 0) {
- io_apic_ints[x].src_bus_id = id;
- }
- }
- }
-}
-
-
-/* Assign low level interrupt handlers */
-static void
-setup_apic_irq_mapping(void)
-{
- int x;
- int int_vector;
-
- /* Clear array */
- for (x = 0; x < APIC_INTMAPSIZE; x++) {
- int_to_apicintpin[x].ioapic = -1;
- int_to_apicintpin[x].int_pin = 0;
- int_to_apicintpin[x].apic_address = NULL;
- int_to_apicintpin[x].redirindex = 0;
- }
-
- /* First assign ISA/EISA interrupts */
- for (x = 0; x < nintrs; x++) {
- int_vector = io_apic_ints[x].src_bus_irq;
- if (int_vector < APIC_INTMAPSIZE &&
- io_apic_ints[x].int_vector == 0xff &&
- int_to_apicintpin[int_vector].ioapic == -1 &&
- (apic_int_is_bus_type(x, ISA) ||
- apic_int_is_bus_type(x, EISA)) &&
- io_apic_ints[x].int_type == 0) {
- assign_apic_irq(ID_TO_IO(io_apic_ints[x].dst_apic_id),
- io_apic_ints[x].dst_apic_int,
- int_vector);
- }
- }
-
- /* Assign interrupts on first 24 intpins on IOAPIC #0 */
- for (x = 0; x < nintrs; x++) {
- int_vector = io_apic_ints[x].dst_apic_int;
- if (int_vector < APIC_INTMAPSIZE &&
- io_apic_ints[x].dst_apic_id == IO_TO_ID(0) &&
- io_apic_ints[x].int_vector == 0xff &&
- int_to_apicintpin[int_vector].ioapic == -1 &&
- (io_apic_ints[x].int_type == 0 ||
- io_apic_ints[x].int_type == 3)) {
- assign_apic_irq(0,
- io_apic_ints[x].dst_apic_int,
- int_vector);
- }
- }
- /*
- * Assign interrupts for remaining intpins.
- * Skip IOAPIC #0 intpin 0 if the type is ExtInt, since this indicates
- * that an entry for ISA/EISA irq 0 exist, and a fallback to mixed mode
- * due to 8254 interrupts not being delivered can reuse that low level
- * interrupt handler.
- */
- int_vector = 0;
- while (int_vector < APIC_INTMAPSIZE &&
- int_to_apicintpin[int_vector].ioapic != -1)
- int_vector++;
- for (x = 0; x < nintrs && int_vector < APIC_INTMAPSIZE; x++) {
- if ((io_apic_ints[x].int_type == 0 ||
- (io_apic_ints[x].int_type == 3 &&
- (io_apic_ints[x].dst_apic_id != IO_TO_ID(0) ||
- io_apic_ints[x].dst_apic_int != 0))) &&
- io_apic_ints[x].int_vector == 0xff) {
- assign_apic_irq(ID_TO_IO(io_apic_ints[x].dst_apic_id),
- io_apic_ints[x].dst_apic_int,
- int_vector);
- int_vector++;
- while (int_vector < APIC_INTMAPSIZE &&
- int_to_apicintpin[int_vector].ioapic != -1)
- int_vector++;
- }
- }
-}
-
-
-static int
-processor_entry(proc_entry_ptr entry, int cpu)
-{
- /* check for usability */
- if (!(entry->cpu_flags & PROCENTRY_FLAG_EN))
- return 0;
-
- /* check for BSP flag */
- if (entry->cpu_flags & PROCENTRY_FLAG_BP) {
- boot_cpu_id = entry->apic_id;
- CPU_TO_ID(0) = entry->apic_id;
- ID_TO_CPU(entry->apic_id) = 0;
- return 0; /* its already been counted */
- }
-
- /* add another AP to list, if less than max number of CPUs */
- else if (cpu < NCPU) {
- CPU_TO_ID(cpu) = entry->apic_id;
- ID_TO_CPU(entry->apic_id) = cpu;
- return 1;
- }
-
- return 0;
-}
-
-
-static int
-bus_entry(bus_entry_ptr entry, int bus)
-{
- int x;
- char c, name[8];
-
- /* encode the name into an index */
- for (x = 0; x < 6; ++x) {
- if ((c = entry->bus_type[x]) == ' ')
- break;
- name[x] = c;
- }
- name[x] = '\0';
-
- if ((x = lookup_bus_type(name)) == UNKNOWN_BUSTYPE)
- panic("unknown bus type: '%s'", name);
-
- bus_data[bus].bus_id = entry->bus_id;
- bus_data[bus].bus_type = x;
-
- return 1;
-}
-
-
-static int
-io_apic_entry(io_apic_entry_ptr entry, int apic)
-{
- if (!(entry->apic_flags & IOAPICENTRY_FLAG_EN))
- return 0;
-
- IO_TO_ID(apic) = entry->apic_id;
- ID_TO_IO(entry->apic_id) = apic;
-
- return 1;
-}
-
-
-static int
-lookup_bus_type(char *name)
-{
- int x;
-
- for (x = 0; x < MAX_BUSTYPE; ++x)
- if (strcmp(bus_type_table[x].name, name) == 0)
- return bus_type_table[x].type;
-
- return UNKNOWN_BUSTYPE;
-}
-
-
-static int
-int_entry(int_entry_ptr entry, int intr)
-{
- int apic;
-
- io_apic_ints[intr].int_type = entry->int_type;
- io_apic_ints[intr].int_flags = entry->int_flags;
- io_apic_ints[intr].src_bus_id = entry->src_bus_id;
- io_apic_ints[intr].src_bus_irq = entry->src_bus_irq;
- if (entry->dst_apic_id == 255) {
- /* This signal goes to all IO APICS. Select an IO APIC
- with sufficient number of interrupt pins */
- for (apic = 0; apic < mp_napics; apic++)
- if (((io_apic_read(apic, IOAPIC_VER) &
- IOART_VER_MAXREDIR) >> MAXREDIRSHIFT) >=
- entry->dst_apic_int)
- break;
- if (apic < mp_napics)
- io_apic_ints[intr].dst_apic_id = IO_TO_ID(apic);
- else
- io_apic_ints[intr].dst_apic_id = entry->dst_apic_id;
- } else
- io_apic_ints[intr].dst_apic_id = entry->dst_apic_id;
- io_apic_ints[intr].dst_apic_int = entry->dst_apic_int;
-
- return 1;
-}
-
-
-static int
-apic_int_is_bus_type(int intr, int bus_type)
-{
- int bus;
-
- for (bus = 0; bus < mp_nbusses; ++bus)
- if ((bus_data[bus].bus_id == io_apic_ints[intr].src_bus_id)
- && ((int) bus_data[bus].bus_type == bus_type))
- return 1;
-
- return 0;
-}
-
-
-/*
- * Given a traditional ISA INT mask, return an APIC mask.
- */
-u_int
-isa_apic_mask(u_int isa_mask)
-{
- int isa_irq;
- int apic_pin;
-
-#if defined(SKIP_IRQ15_REDIRECT)
- if (isa_mask == (1 << 15)) {
- printf("skipping ISA IRQ15 redirect\n");
- return isa_mask;
- }
-#endif /* SKIP_IRQ15_REDIRECT */
-
- isa_irq = ffs(isa_mask); /* find its bit position */
- if (isa_irq == 0) /* doesn't exist */
- return 0;
- --isa_irq; /* make it zero based */
-
- apic_pin = isa_apic_irq(isa_irq); /* look for APIC connection */
- if (apic_pin == -1)
- return 0;
-
- return (1 << apic_pin); /* convert pin# to a mask */
-}
-
-
-/*
- * Determine which APIC pin an ISA/EISA INT is attached to.
- */
-#define INTTYPE(I) (io_apic_ints[(I)].int_type)
-#define INTPIN(I) (io_apic_ints[(I)].dst_apic_int)
-#define INTIRQ(I) (io_apic_ints[(I)].int_vector)
-#define INTAPIC(I) (ID_TO_IO(io_apic_ints[(I)].dst_apic_id))
-
-#define SRCBUSIRQ(I) (io_apic_ints[(I)].src_bus_irq)
-int
-isa_apic_irq(int isa_irq)
-{
- int intr;
-
- for (intr = 0; intr < nintrs; ++intr) { /* check each record */
- if (INTTYPE(intr) == 0) { /* standard INT */
- if (SRCBUSIRQ(intr) == isa_irq) {
- if (apic_int_is_bus_type(intr, ISA) ||
- apic_int_is_bus_type(intr, EISA))
- return INTIRQ(intr); /* found */
- }
- }
- }
- return -1; /* NOT found */
-}
-
-
-/*
- * Determine which APIC pin a PCI INT is attached to.
- */
-#define SRCBUSID(I) (io_apic_ints[(I)].src_bus_id)
-#define SRCBUSDEVICE(I) ((io_apic_ints[(I)].src_bus_irq >> 2) & 0x1f)
-#define SRCBUSLINE(I) (io_apic_ints[(I)].src_bus_irq & 0x03)
-int
-pci_apic_irq(int pciBus, int pciDevice, int pciInt)
-{
- int intr;
-
- --pciInt; /* zero based */
-
- for (intr = 0; intr < nintrs; ++intr) /* check each record */
- if ((INTTYPE(intr) == 0) /* standard INT */
- && (SRCBUSID(intr) == pciBus)
- && (SRCBUSDEVICE(intr) == pciDevice)
- && (SRCBUSLINE(intr) == pciInt)) /* a candidate IRQ */
- if (apic_int_is_bus_type(intr, PCI))
- return INTIRQ(intr); /* exact match */
-
- return -1; /* NOT found */
-}
-
-int
-next_apic_irq(int irq)
-{
- int intr, ointr;
- int bus, bustype;
-
- bus = 0;
- bustype = 0;
- for (intr = 0; intr < nintrs; intr++) {
- if (INTIRQ(intr) != irq || INTTYPE(intr) != 0)
- continue;
- bus = SRCBUSID(intr);
- bustype = apic_bus_type(bus);
- if (bustype != ISA &&
- bustype != EISA &&
- bustype != PCI)
- continue;
- break;
- }
- if (intr >= nintrs) {
- return -1;
- }
- for (ointr = intr + 1; ointr < nintrs; ointr++) {
- if (INTTYPE(ointr) != 0)
- continue;
- if (bus != SRCBUSID(ointr))
- continue;
- if (bustype == PCI) {
- if (SRCBUSDEVICE(intr) != SRCBUSDEVICE(ointr))
- continue;
- if (SRCBUSLINE(intr) != SRCBUSLINE(ointr))
- continue;
- }
- if (bustype == ISA || bustype == EISA) {
- if (SRCBUSIRQ(intr) != SRCBUSIRQ(ointr))
- continue;
- }
- if (INTPIN(intr) == INTPIN(ointr))
- continue;
- break;
- }
- if (ointr >= nintrs) {
- return -1;
- }
- return INTIRQ(ointr);
-}
-#undef SRCBUSLINE
-#undef SRCBUSDEVICE
-#undef SRCBUSID
-#undef SRCBUSIRQ
-
-#undef INTPIN
-#undef INTIRQ
-#undef INTAPIC
-#undef INTTYPE
-
-
-/*
- * Reprogram the MB chipset to NOT redirect an ISA INTerrupt.
- *
- * XXX FIXME:
- * Exactly what this means is unclear at this point. It is a solution
- * for motherboards that redirect the MBIRQ0 pin. Generically a motherboard
- * could route any of the ISA INTs to upper (>15) IRQ values. But most would
- * NOT be redirected via MBIRQ0, thus "undirect()ing" them would NOT be an
- * option.
- */
-int
-undirect_isa_irq(int rirq)
-{
-#if defined(READY)
- if (bootverbose)
- printf("Freeing redirected ISA irq %d.\n", rirq);
- /** FIXME: tickle the MB redirector chip */
- return ???;
-#else
- if (bootverbose)
- printf("Freeing (NOT implemented) redirected ISA irq %d.\n", rirq);
- return 0;
-#endif /* READY */
-}
-
-
-/*
- * Reprogram the MB chipset to NOT redirect a PCI INTerrupt
- */
-int
-undirect_pci_irq(int rirq)
-{
-#if defined(READY)
- if (bootverbose)
- printf("Freeing redirected PCI irq %d.\n", rirq);
-
- /** FIXME: tickle the MB redirector chip */
- return ???;
-#else
- if (bootverbose)
- printf("Freeing (NOT implemented) redirected PCI irq %d.\n",
- rirq);
- return 0;
-#endif /* READY */
-}
-
-
-/*
- * given a bus ID, return:
- * the bus type if found
- * -1 if NOT found
- */
-int
-apic_bus_type(int id)
-{
- int x;
-
- for (x = 0; x < mp_nbusses; ++x)
- if (bus_data[x].bus_id == id)
- return bus_data[x].bus_type;
-
- return -1;
-}
-
-
-/*
- * given a LOGICAL APIC# and pin#, return:
- * the associated src bus ID if found
- * -1 if NOT found
- */
-int
-apic_src_bus_id(int apic, int pin)
-{
- int x;
-
- /* search each of the possible INTerrupt sources */
- for (x = 0; x < nintrs; ++x)
- if ((apic == ID_TO_IO(io_apic_ints[x].dst_apic_id)) &&
- (pin == io_apic_ints[x].dst_apic_int))
- return (io_apic_ints[x].src_bus_id);
-
- return -1; /* NOT found */
-}
-
-
-/*
- * given a LOGICAL APIC# and pin#, return:
- * the associated src bus IRQ if found
- * -1 if NOT found
- */
-int
-apic_src_bus_irq(int apic, int pin)
-{
- int x;
-
- for (x = 0; x < nintrs; x++)
- if ((apic == ID_TO_IO(io_apic_ints[x].dst_apic_id)) &&
- (pin == io_apic_ints[x].dst_apic_int))
- return (io_apic_ints[x].src_bus_irq);
-
- return -1; /* NOT found */
-}
-
-
-/*
- * given a LOGICAL APIC# and pin#, return:
- * the associated INTerrupt type if found
- * -1 if NOT found
- */
-int
-apic_int_type(int apic, int pin)
-{
- int x;
-
- /* search each of the possible INTerrupt sources */
- for (x = 0; x < nintrs; ++x)
- if ((apic == ID_TO_IO(io_apic_ints[x].dst_apic_id)) &&
- (pin == io_apic_ints[x].dst_apic_int))
- return (io_apic_ints[x].int_type);
-
- return -1; /* NOT found */
-}
-
-int
-apic_irq(int apic, int pin)
-{
- int x;
- int res;
-
- for (x = 0; x < nintrs; ++x)
- if ((apic == ID_TO_IO(io_apic_ints[x].dst_apic_id)) &&
- (pin == io_apic_ints[x].dst_apic_int)) {
- res = io_apic_ints[x].int_vector;
- if (res == 0xff)
- return -1;
- if (apic != int_to_apicintpin[res].ioapic)
- panic("apic_irq: inconsistent table");
- if (pin != int_to_apicintpin[res].int_pin)
- panic("apic_irq inconsistent table (2)");
- return res;
- }
- return -1;
-}
-
-
-/*
- * given a LOGICAL APIC# and pin#, return:
- * the associated trigger mode if found
- * -1 if NOT found
- */
-int
-apic_trigger(int apic, int pin)
-{
- int x;
-
- /* search each of the possible INTerrupt sources */
- for (x = 0; x < nintrs; ++x)
- if ((apic == ID_TO_IO(io_apic_ints[x].dst_apic_id)) &&
- (pin == io_apic_ints[x].dst_apic_int))
- return ((io_apic_ints[x].int_flags >> 2) & 0x03);
-
- return -1; /* NOT found */
-}
-
-
-/*
- * given a LOGICAL APIC# and pin#, return:
- * the associated 'active' level if found
- * -1 if NOT found
- */
-int
-apic_polarity(int apic, int pin)
-{
- int x;
-
- /* search each of the possible INTerrupt sources */
- for (x = 0; x < nintrs; ++x)
- if ((apic == ID_TO_IO(io_apic_ints[x].dst_apic_id)) &&
- (pin == io_apic_ints[x].dst_apic_int))
- return (io_apic_ints[x].int_flags & 0x03);
-
- return -1; /* NOT found */
-}
-
-
-/*
- * set data according to MP defaults
- * FIXME: probably not complete yet...
- */
-static void
-default_mp_table(int type)
-{
- int ap_cpu_id;
-#if defined(APIC_IO)
- u_int32_t ux;
- int io_apic_id;
- int pin;
-#endif /* APIC_IO */
-
-#if 0
- printf(" MP default config type: %d\n", type);
- switch (type) {
- case 1:
- printf(" bus: ISA, APIC: 82489DX\n");
- break;
- case 2:
- printf(" bus: EISA, APIC: 82489DX\n");
- break;
- case 3:
- printf(" bus: EISA, APIC: 82489DX\n");
- break;
- case 4:
- printf(" bus: MCA, APIC: 82489DX\n");
- break;
- case 5:
- printf(" bus: ISA+PCI, APIC: Integrated\n");
- break;
- case 6:
- printf(" bus: EISA+PCI, APIC: Integrated\n");
- break;
- case 7:
- printf(" bus: MCA+PCI, APIC: Integrated\n");
- break;
- default:
- printf(" future type\n");
- break;
- /* NOTREACHED */
- }
-#endif /* 0 */
-
- boot_cpu_id = (lapic.id & APIC_ID_MASK) >> 24;
- ap_cpu_id = (boot_cpu_id == 0) ? 1 : 0;
-
- /* BSP */
- CPU_TO_ID(0) = boot_cpu_id;
- ID_TO_CPU(boot_cpu_id) = 0;
-
- /* one and only AP */
- CPU_TO_ID(1) = ap_cpu_id;
- ID_TO_CPU(ap_cpu_id) = 1;
-
-#if defined(APIC_IO)
- /* one and only IO APIC */
- io_apic_id = (io_apic_read(0, IOAPIC_ID) & APIC_ID_MASK) >> 24;
-
- /*
- * sanity check, refer to MP spec section 3.6.6, last paragraph
- * necessary as some hardware isn't properly setting up the IO APIC
- */
-#if defined(REALLY_ANAL_IOAPICID_VALUE)
- if (io_apic_id != 2) {
-#else
- if ((io_apic_id == 0) || (io_apic_id == 1) || (io_apic_id == 15)) {
-#endif /* REALLY_ANAL_IOAPICID_VALUE */
- ux = io_apic_read(0, IOAPIC_ID); /* get current contents */
- ux &= ~APIC_ID_MASK; /* clear the ID field */
- ux |= 0x02000000; /* set it to '2' */
- io_apic_write(0, IOAPIC_ID, ux); /* write new value */
- ux = io_apic_read(0, IOAPIC_ID); /* re-read && test */
- if ((ux & APIC_ID_MASK) != 0x02000000)
- panic("can't control IO APIC ID, reg: 0x%08x", ux);
- io_apic_id = 2;
- }
- IO_TO_ID(0) = io_apic_id;
- ID_TO_IO(io_apic_id) = 0;
-#endif /* APIC_IO */
-
- /* fill out bus entries */
- switch (type) {
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- bus_data[0].bus_id = default_data[type - 1][1];
- bus_data[0].bus_type = default_data[type - 1][2];
- bus_data[1].bus_id = default_data[type - 1][3];
- bus_data[1].bus_type = default_data[type - 1][4];
- break;
-
- /* case 4: case 7: MCA NOT supported */
- default: /* illegal/reserved */
- panic("BAD default MP config: %d", type);
- /* NOTREACHED */
- }
-
-#if defined(APIC_IO)
- /* general cases from MP v1.4, table 5-2 */
- for (pin = 0; pin < 16; ++pin) {
- io_apic_ints[pin].int_type = 0;
- io_apic_ints[pin].int_flags = 0x05; /* edge/active-hi */
- io_apic_ints[pin].src_bus_id = 0;
- io_apic_ints[pin].src_bus_irq = pin; /* IRQ2 caught below */
- io_apic_ints[pin].dst_apic_id = io_apic_id;
- io_apic_ints[pin].dst_apic_int = pin; /* 1-to-1 */
- }
-
- /* special cases from MP v1.4, table 5-2 */
- if (type == 2) {
- io_apic_ints[2].int_type = 0xff; /* N/C */
- io_apic_ints[13].int_type = 0xff; /* N/C */
-#if !defined(APIC_MIXED_MODE)
- /** FIXME: ??? */
- panic("sorry, can't support type 2 default yet");
-#endif /* APIC_MIXED_MODE */
- }
- else
- io_apic_ints[2].src_bus_irq = 0; /* ISA IRQ0 is on APIC INT 2 */
-
- if (type == 7)
- io_apic_ints[0].int_type = 0xff; /* N/C */
- else
- io_apic_ints[0].int_type = 3; /* vectored 8259 */
-#endif /* APIC_IO */
-}
-
-
-/*
- * initialize all the SMP locks
- */
-
-/* critical region around IO APIC, apic_imen */
-struct simplelock imen_lock;
-
-/* critical region around splxx(), cpl, cml, cil, ipending */
-struct simplelock cpl_lock;
-
-/* Make FAST_INTR() routines sequential */
-struct simplelock fast_intr_lock;
-
-/* critical region around INTR() routines */
-struct simplelock intr_lock;
-
-/* lock regions protected in UP kernel via cli/sti */
-struct simplelock mpintr_lock;
-
-/* lock region used by kernel profiling */
-struct simplelock mcount_lock;
-
-#ifdef USE_COMLOCK
-/* locks com (tty) data/hardware accesses: a FASTINTR() */
-struct simplelock com_lock;
-#endif /* USE_COMLOCK */
-
-#ifdef USE_CLOCKLOCK
-/* lock regions around the clock hardware */
-struct simplelock clock_lock;
-#endif /* USE_CLOCKLOCK */
-
-/* lock around the MP rendezvous */
-static struct simplelock smp_rv_lock;
-
-static void
-init_locks(void)
-{
- /*
- * Get the initial mp_lock with a count of 1 for the BSP.
- * This uses a LOGICAL cpu ID, ie BSP == 0.
- */
- mp_lock = 0x00000001;
-
- /* ISR uses its own "giant lock" */
- isr_lock = FREE_LOCK;
-
-#if defined(APIC_INTR_DIAGNOSTIC) && defined(APIC_INTR_DIAGNOSTIC_IRQ)
- s_lock_init((struct simplelock*)&apic_itrace_debuglock);
-#endif
-
- s_lock_init((struct simplelock*)&mpintr_lock);
-
- s_lock_init((struct simplelock*)&mcount_lock);
-
- s_lock_init((struct simplelock*)&fast_intr_lock);
- s_lock_init((struct simplelock*)&intr_lock);
- s_lock_init((struct simplelock*)&imen_lock);
- s_lock_init((struct simplelock*)&cpl_lock);
- s_lock_init(&smp_rv_lock);
-
-#ifdef USE_COMLOCK
- s_lock_init((struct simplelock*)&com_lock);
-#endif /* USE_COMLOCK */
-#ifdef USE_CLOCKLOCK
- s_lock_init((struct simplelock*)&clock_lock);
-#endif /* USE_CLOCKLOCK */
-}
-
-
-/* Wait for all APs to be fully initialized */
-extern int wait_ap(unsigned int);
-
-/*
- * start each AP in our list
- */
-static int
-start_all_aps(u_int boot_addr)
-{
- int x, i, pg;
- u_char mpbiosreason;
- u_long mpbioswarmvec;
- struct globaldata *gd;
- char *stack;
-
- POSTCODE(START_ALL_APS_POST);
-
- /* initialize BSP's local APIC */
- apic_initialize();
- bsp_apic_ready = 1;
-
- /* install the AP 1st level boot code */
- install_ap_tramp(boot_addr);
-
-
- /* save the current value of the warm-start vector */
- mpbioswarmvec = *((u_long *) WARMBOOT_OFF);
-#ifndef PC98
- outb(CMOS_REG, BIOS_RESET);
- mpbiosreason = inb(CMOS_DATA);
-#endif
-
- /* record BSP in CPU map */
- all_cpus = 1;
-
- /* set up 0 -> 4MB P==V mapping for AP boot */
- *(int *)PTD = PG_V | PG_RW | ((uintptr_t)(void *)KPTphys & PG_FRAME);
- invltlb();
-
- /* start each AP */
- for (x = 1; x <= mp_naps; ++x) {
-
- /* This is a bit verbose, it will go away soon. */
-
- /* first page of AP's private space */
- pg = x * i386_btop(sizeof(struct privatespace));
-
- /* allocate a new private data page */
- gd = (struct globaldata *)kmem_alloc(kernel_map, PAGE_SIZE);
-
- /* wire it into the private page table page */
- SMPpt[pg] = (pt_entry_t)(PG_V | PG_RW | vtophys(gd));
-
- /* allocate and set up an idle stack data page */
- stack = (char *)kmem_alloc(kernel_map, UPAGES*PAGE_SIZE);
- for (i = 0; i < UPAGES; i++)
- SMPpt[pg + 5 + i] = (pt_entry_t)
- (PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack));
-
- SMPpt[pg + 1] = 0; /* *prv_CMAP1 */
- SMPpt[pg + 2] = 0; /* *prv_CMAP2 */
- SMPpt[pg + 3] = 0; /* *prv_CMAP3 */
- SMPpt[pg + 4] = 0; /* *prv_PMAP1 */
-
- /* prime data page for it to use */
- gd->gd_cpuid = x;
- gd->gd_cpu_lockid = x << 24;
- gd->gd_prv_CMAP1 = &SMPpt[pg + 1];
- gd->gd_prv_CMAP2 = &SMPpt[pg + 2];
- gd->gd_prv_CMAP3 = &SMPpt[pg + 3];
- gd->gd_prv_PMAP1 = &SMPpt[pg + 4];
- gd->gd_prv_CADDR1 = SMP_prvspace[x].CPAGE1;
- gd->gd_prv_CADDR2 = SMP_prvspace[x].CPAGE2;
- gd->gd_prv_CADDR3 = SMP_prvspace[x].CPAGE3;
- gd->gd_prv_PADDR1 = (unsigned *)SMP_prvspace[x].PPAGE1;
-
- /* setup a vector to our boot code */
- *((volatile u_short *) WARMBOOT_OFF) = WARMBOOT_TARGET;
- *((volatile u_short *) WARMBOOT_SEG) = (boot_addr >> 4);
-#ifndef PC98
- outb(CMOS_REG, BIOS_RESET);
- outb(CMOS_DATA, BIOS_WARM); /* 'warm-start' */
-#endif
-
- bootSTK = &SMP_prvspace[x].idlestack[UPAGES*PAGE_SIZE];
- bootAP = x;
-
- /* attempt to start the Application Processor */
- CHECK_INIT(99); /* setup checkpoints */
- if (!start_ap(x, boot_addr)) {
- printf("AP #%d (PHY# %d) failed!\n", x, CPU_TO_ID(x));
- CHECK_PRINT("trace"); /* show checkpoints */
- /* better panic as the AP may be running loose */
- printf("panic y/n? [y] ");
- if (cngetc() != 'n')
- panic("bye-bye");
- }
- CHECK_PRINT("trace"); /* show checkpoints */
-
- /* record its version info */
- cpu_apic_versions[x] = cpu_apic_versions[0];
-
- all_cpus |= (1 << x); /* record AP in CPU map */
- }
-
- /* build our map of 'other' CPUs */
- other_cpus = all_cpus & ~(1 << cpuid);
-
- /* fill in our (BSP) APIC version */
- cpu_apic_versions[0] = lapic.version;
-
- /* restore the warmstart vector */
- *(u_long *) WARMBOOT_OFF = mpbioswarmvec;
-#ifndef PC98
- outb(CMOS_REG, BIOS_RESET);
- outb(CMOS_DATA, mpbiosreason);
-#endif
-
- /*
- * Set up the idle context for the BSP. Similar to above except
- * that some was done by locore, some by pmap.c and some is implicit
- * because the BSP is cpu#0 and the page is initially zero, and also
- * because we can refer to variables by name on the BSP..
- */
-
- /* Allocate and setup BSP idle stack */
- stack = (char *)kmem_alloc(kernel_map, UPAGES * PAGE_SIZE);
- for (i = 0; i < UPAGES; i++)
- SMPpt[5 + i] = (pt_entry_t)
- (PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack));
-
- *(int *)PTD = 0;
- pmap_set_opt();
-
- /* number of APs actually started */
- return mp_ncpus - 1;
-}
-
-
-/*
- * load the 1st level AP boot code into base memory.
- */
-
-/* targets for relocation */
-extern void bigJump(void);
-extern void bootCodeSeg(void);
-extern void bootDataSeg(void);
-extern void MPentry(void);
-extern u_int MP_GDT;
-extern u_int mp_gdtbase;
-
-static void
-install_ap_tramp(u_int boot_addr)
-{
- int x;
- int size = *(int *) ((u_long) & bootMP_size);
- u_char *src = (u_char *) ((u_long) bootMP);
- u_char *dst = (u_char *) boot_addr + KERNBASE;
- u_int boot_base = (u_int) bootMP;
- u_int8_t *dst8;
- u_int16_t *dst16;
- u_int32_t *dst32;
-
- POSTCODE(INSTALL_AP_TRAMP_POST);
-
- for (x = 0; x < size; ++x)
- *dst++ = *src++;
-
- /*
- * modify addresses in code we just moved to basemem. unfortunately we
- * need fairly detailed info about mpboot.s for this to work. changes
- * to mpboot.s might require changes here.
- */
-
- /* boot code is located in KERNEL space */
- dst = (u_char *) boot_addr + KERNBASE;
-
- /* modify the lgdt arg */
- dst32 = (u_int32_t *) (dst + ((u_int) & mp_gdtbase - boot_base));
- *dst32 = boot_addr + ((u_int) & MP_GDT - boot_base);
-
- /* modify the ljmp target for MPentry() */
- dst32 = (u_int32_t *) (dst + ((u_int) bigJump - boot_base) + 1);
- *dst32 = ((u_int) MPentry - KERNBASE);
-
- /* modify the target for boot code segment */
- dst16 = (u_int16_t *) (dst + ((u_int) bootCodeSeg - boot_base));
- dst8 = (u_int8_t *) (dst16 + 1);
- *dst16 = (u_int) boot_addr & 0xffff;
- *dst8 = ((u_int) boot_addr >> 16) & 0xff;
-
- /* modify the target for boot data segment */
- dst16 = (u_int16_t *) (dst + ((u_int) bootDataSeg - boot_base));
- dst8 = (u_int8_t *) (dst16 + 1);
- *dst16 = (u_int) boot_addr & 0xffff;
- *dst8 = ((u_int) boot_addr >> 16) & 0xff;
-}
-
-
-/*
- * this function starts the AP (application processor) identified
- * by the APIC ID 'physicalCpu'. It does quite a "song and dance"
- * to accomplish this. This is necessary because of the nuances
- * of the different hardware we might encounter. It ain't pretty,
- * but it seems to work.
- */
-static int
-start_ap(int logical_cpu, u_int boot_addr)
-{
- int physical_cpu;
- int vector;
- int cpus;
- u_long icr_lo, icr_hi;
-
- POSTCODE(START_AP_POST);
-
- /* get the PHYSICAL APIC ID# */
- physical_cpu = CPU_TO_ID(logical_cpu);
-
- /* calculate the vector */
- vector = (boot_addr >> 12) & 0xff;
-
- /* used as a watchpoint to signal AP startup */
- cpus = mp_ncpus;
-
- /*
- * first we do an INIT/RESET IPI this INIT IPI might be run, reseting
- * and running the target CPU. OR this INIT IPI might be latched (P5
- * bug), CPU waiting for STARTUP IPI. OR this INIT IPI might be
- * ignored.
- */
-
- /* setup the address for the target AP */
- icr_hi = lapic.icr_hi & ~APIC_ID_MASK;
- icr_hi |= (physical_cpu << 24);
- lapic.icr_hi = icr_hi;
-
- /* do an INIT IPI: assert RESET */
- icr_lo = lapic.icr_lo & 0xfff00000;
- lapic.icr_lo = icr_lo | 0x0000c500;
-
- /* wait for pending status end */
- while (lapic.icr_lo & APIC_DELSTAT_MASK)
- /* spin */ ;
-
- /* do an INIT IPI: deassert RESET */
- lapic.icr_lo = icr_lo | 0x00008500;
-
- /* wait for pending status end */
- u_sleep(10000); /* wait ~10mS */
- while (lapic.icr_lo & APIC_DELSTAT_MASK)
- /* spin */ ;
-
- /*
- * next we do a STARTUP IPI: the previous INIT IPI might still be
- * latched, (P5 bug) this 1st STARTUP would then terminate
- * immediately, and the previously started INIT IPI would continue. OR
- * the previous INIT IPI has already run. and this STARTUP IPI will
- * run. OR the previous INIT IPI was ignored. and this STARTUP IPI
- * will run.
- */
-
- /* do a STARTUP IPI */
- lapic.icr_lo = icr_lo | 0x00000600 | vector;
- while (lapic.icr_lo & APIC_DELSTAT_MASK)
- /* spin */ ;
- u_sleep(200); /* wait ~200uS */
-
- /*
- * finally we do a 2nd STARTUP IPI: this 2nd STARTUP IPI should run IF
- * the previous STARTUP IPI was cancelled by a latched INIT IPI. OR
- * this STARTUP IPI will be ignored, as only ONE STARTUP IPI is
- * recognized after hardware RESET or INIT IPI.
- */
-
- lapic.icr_lo = icr_lo | 0x00000600 | vector;
- while (lapic.icr_lo & APIC_DELSTAT_MASK)
- /* spin */ ;
- u_sleep(200); /* wait ~200uS */
-
- /* wait for it to start */
- set_apic_timer(5000000);/* == 5 seconds */
- while (read_apic_timer())
- if (mp_ncpus > cpus)
- return 1; /* return SUCCESS */
-
- return 0; /* return FAILURE */
-}
-
-
-/*
- * Flush the TLB on all other CPU's
- *
- * XXX: Needs to handshake and wait for completion before proceding.
- */
-void
-smp_invltlb(void)
-{
-#if defined(APIC_IO)
- if (smp_started && invltlb_ok)
- all_but_self_ipi(XINVLTLB_OFFSET);
-#endif /* APIC_IO */
-}
-
-void
-invlpg(u_int addr)
-{
- __asm __volatile("invlpg (%0)"::"r"(addr):"memory");
-
- /* send a message to the other CPUs */
- smp_invltlb();
-}
-
-void
-invltlb(void)
-{
- u_long temp;
-
- /*
- * This should be implemented as load_cr3(rcr3()) when load_cr3() is
- * inlined.
- */
- __asm __volatile("movl %%cr3, %0; movl %0, %%cr3":"=r"(temp) :: "memory");
-
- /* send a message to the other CPUs */
- smp_invltlb();
-}
-
-
-/*
- * When called the executing CPU will send an IPI to all other CPUs
- * requesting that they halt execution.
- *
- * Usually (but not necessarily) called with 'other_cpus' as its arg.
- *
- * - Signals all CPUs in map to stop.
- * - Waits for each to stop.
- *
- * Returns:
- * -1: error
- * 0: NA
- * 1: ok
- *
- * XXX FIXME: this is not MP-safe, needs a lock to prevent multiple CPUs
- * from executing at same time.
- */
-int
-stop_cpus(u_int map)
-{
- if (!smp_started)
- return 0;
-
- /* send the Xcpustop IPI to all CPUs in map */
- selected_apic_ipi(map, XCPUSTOP_OFFSET, APIC_DELMODE_FIXED);
-
- while ((stopped_cpus & map) != map)
- /* spin */ ;
-
- return 1;
-}
-
-
-/*
- * Called by a CPU to restart stopped CPUs.
- *
- * Usually (but not necessarily) called with 'stopped_cpus' as its arg.
- *
- * - Signals all CPUs in map to restart.
- * - Waits for each to restart.
- *
- * Returns:
- * -1: error
- * 0: NA
- * 1: ok
- */
-int
-restart_cpus(u_int map)
-{
- if (!smp_started)
- return 0;
-
- started_cpus = map; /* signal other cpus to restart */
-
- while ((stopped_cpus & map) != 0) /* wait for each to clear its bit */
- /* spin */ ;
-
- return 1;
-}
-
-int smp_active = 0; /* are the APs allowed to run? */
-SYSCTL_INT(_machdep, OID_AUTO, smp_active, CTLFLAG_RW, &smp_active, 0, "");
-
-/* XXX maybe should be hw.ncpu */
-static int smp_cpus = 1; /* how many cpu's running */
-SYSCTL_INT(_machdep, OID_AUTO, smp_cpus, CTLFLAG_RD, &smp_cpus, 0, "");
-
-int invltlb_ok = 0; /* throttle smp_invltlb() till safe */
-SYSCTL_INT(_machdep, OID_AUTO, invltlb_ok, CTLFLAG_RW, &invltlb_ok, 0, "");
-
-/* Warning: Do not staticize. Used from swtch.s */
-int do_page_zero_idle = 1; /* bzero pages for fun and profit in idleloop */
-SYSCTL_INT(_machdep, OID_AUTO, do_page_zero_idle, CTLFLAG_RW,
- &do_page_zero_idle, 0, "");
-
-/* Is forwarding of a interrupt to the CPU holding the ISR lock enabled ? */
-int forward_irq_enabled = 1;
-SYSCTL_INT(_machdep, OID_AUTO, forward_irq_enabled, CTLFLAG_RW,
- &forward_irq_enabled, 0, "");
-
-/* Enable forwarding of a signal to a process running on a different CPU */
-static int forward_signal_enabled = 1;
-SYSCTL_INT(_machdep, OID_AUTO, forward_signal_enabled, CTLFLAG_RW,
- &forward_signal_enabled, 0, "");
-
-/* Enable forwarding of roundrobin to all other cpus */
-static int forward_roundrobin_enabled = 1;
-SYSCTL_INT(_machdep, OID_AUTO, forward_roundrobin_enabled, CTLFLAG_RW,
- &forward_roundrobin_enabled, 0, "");
-
-/*
- * This is called once the rest of the system is up and running and we're
- * ready to let the AP's out of the pen.
- */
-void ap_init(void);
-
-void
-ap_init()
-{
- u_int apic_id;
-
- /* BSP may have changed PTD while we're waiting for the lock */
- cpu_invltlb();
-
- smp_cpus++;
-
-#if defined(I586_CPU) && !defined(NO_F00F_HACK)
- lidt(&r_idt);
-#endif
-
- /* Build our map of 'other' CPUs. */
- other_cpus = all_cpus & ~(1 << cpuid);
-
- printf("SMP: AP CPU #%d Launched!\n", cpuid);
-
- /* XXX FIXME: i386 specific, and redundant: Setup the FPU. */
- load_cr0((rcr0() & ~CR0_EM) | CR0_MP | CR0_NE | CR0_TS);
-
- /* set up FPU state on the AP */
- npxinit(__INITIAL_NPXCW__);
-
- /* A quick check from sanity claus */
- apic_id = (apic_id_to_logical[(lapic.id & 0x0f000000) >> 24]);
- if (cpuid != apic_id) {
- printf("SMP: cpuid = %d\n", cpuid);
- printf("SMP: apic_id = %d\n", apic_id);
- printf("PTD[MPPTDI] = %p\n", (void *)PTD[MPPTDI]);
- panic("cpuid mismatch! boom!!");
- }
-
- /* Init local apic for irq's */
- apic_initialize();
-
- /* Set memory range attributes for this CPU to match the BSP */
- mem_range_AP_init();
-
- /*
- * Activate smp_invltlb, although strictly speaking, this isn't
- * quite correct yet. We should have a bitfield for cpus willing
- * to accept TLB flush IPI's or something and sync them.
- */
- if (smp_cpus == mp_ncpus) {
- invltlb_ok = 1;
- smp_started = 1; /* enable IPI's, tlb shootdown, freezes etc */
- smp_active = 1; /* historic */
- }
-}
-
-#ifdef BETTER_CLOCK
-
-#define CHECKSTATE_USER 0
-#define CHECKSTATE_SYS 1
-#define CHECKSTATE_INTR 2
-
-/* Do not staticize. Used from apic_vector.s */
-struct proc* checkstate_curproc[NCPU];
-int checkstate_cpustate[NCPU];
-u_long checkstate_pc[NCPU];
-
-extern long cp_time[CPUSTATES];
-
-#define PC_TO_INDEX(pc, prof) \
- ((int)(((u_quad_t)((pc) - (prof)->pr_off) * \
- (u_quad_t)((prof)->pr_scale)) >> 16) & ~1)
-
-static void
-addupc_intr_forwarded(struct proc *p, int id, int *astmap)
-{
- int i;
- struct uprof *prof;
- u_long pc;
-
- pc = checkstate_pc[id];
- prof = &p->p_stats->p_prof;
- if (pc >= prof->pr_off &&
- (i = PC_TO_INDEX(pc, prof)) < prof->pr_size) {
- if ((p->p_flag & P_OWEUPC) == 0) {
- prof->pr_addr = pc;
- prof->pr_ticks = 1;
- p->p_flag |= P_OWEUPC;
- }
- *astmap |= (1 << id);
- }
-}
-
-static void
-forwarded_statclock(int id, int pscnt, int *astmap)
-{
- struct pstats *pstats;
- long rss;
- struct rusage *ru;
- struct vmspace *vm;
- int cpustate;
- struct proc *p;
-#ifdef GPROF
- register struct gmonparam *g;
- int i;
-#endif
-
- p = checkstate_curproc[id];
- cpustate = checkstate_cpustate[id];
-
- switch (cpustate) {
- case CHECKSTATE_USER:
- if (p->p_flag & P_PROFIL)
- addupc_intr_forwarded(p, id, astmap);
- if (pscnt > 1)
- return;
- p->p_uticks++;
- if (p->p_nice > NZERO)
- cp_time[CP_NICE]++;
- else
- cp_time[CP_USER]++;
- break;
- case CHECKSTATE_SYS:
-#ifdef GPROF
- /*
- * Kernel statistics are just like addupc_intr, only easier.
- */
- g = &_gmonparam;
- if (g->state == GMON_PROF_ON) {
- i = checkstate_pc[id] - g->lowpc;
- if (i < g->textsize) {
- i /= HISTFRACTION * sizeof(*g->kcount);
- g->kcount[i]++;
- }
- }
-#endif
- if (pscnt > 1)
- return;
-
- if (!p)
- cp_time[CP_IDLE]++;
- else {
- p->p_sticks++;
- cp_time[CP_SYS]++;
- }
- break;
- case CHECKSTATE_INTR:
- default:
-#ifdef GPROF
- /*
- * Kernel statistics are just like addupc_intr, only easier.
- */
- g = &_gmonparam;
- if (g->state == GMON_PROF_ON) {
- i = checkstate_pc[id] - g->lowpc;
- if (i < g->textsize) {
- i /= HISTFRACTION * sizeof(*g->kcount);
- g->kcount[i]++;
- }
- }
-#endif
- if (pscnt > 1)
- return;
- if (p)
- p->p_iticks++;
- cp_time[CP_INTR]++;
- }
- if (p != NULL) {
- schedclock(p);
-
- /* Update resource usage integrals and maximums. */
- if ((pstats = p->p_stats) != NULL &&
- (ru = &pstats->p_ru) != NULL &&
- (vm = p->p_vmspace) != NULL) {
- ru->ru_ixrss += pgtok(vm->vm_tsize);
- ru->ru_idrss += pgtok(vm->vm_dsize);
- ru->ru_isrss += pgtok(vm->vm_ssize);
- rss = pgtok(vmspace_resident_count(vm));
- if (ru->ru_maxrss < rss)
- ru->ru_maxrss = rss;
- }
- }
-}
-
-void
-forward_statclock(int pscnt)
-{
- int map;
- int id;
- int i;
-
- /* Kludge. We don't yet have separate locks for the interrupts
- * and the kernel. This means that we cannot let the other processors
- * handle complex interrupts while inhibiting them from entering
- * the kernel in a non-interrupt context.
- *
- * What we can do, without changing the locking mechanisms yet,
- * is letting the other processors handle a very simple interrupt
- * (wich determines the processor states), and do the main
- * work ourself.
- */
-
- if (!smp_started || !invltlb_ok || cold || panicstr)
- return;
-
- /* Step 1: Probe state (user, cpu, interrupt, spinlock, idle ) */
-
- map = other_cpus & ~stopped_cpus ;
- checkstate_probed_cpus = 0;
- if (map != 0)
- selected_apic_ipi(map,
- XCPUCHECKSTATE_OFFSET, APIC_DELMODE_FIXED);
-
- i = 0;
- while (checkstate_probed_cpus != map) {
- /* spin */
- i++;
- if (i == 100000) {
-#ifdef BETTER_CLOCK_DIAGNOSTIC
- printf("forward_statclock: checkstate %x\n",
- checkstate_probed_cpus);
-#endif
- break;
- }
- }
-
- /*
- * Step 2: walk through other processors processes, update ticks and
- * profiling info.
- */
-
- map = 0;
- for (id = 0; id < mp_ncpus; id++) {
- if (id == cpuid)
- continue;
- if (((1 << id) & checkstate_probed_cpus) == 0)
- continue;
- forwarded_statclock(id, pscnt, &map);
- }
- if (map != 0) {
- checkstate_need_ast |= map;
- selected_apic_ipi(map, XCPUAST_OFFSET, APIC_DELMODE_FIXED);
- i = 0;
- while ((checkstate_need_ast & map) != 0) {
- /* spin */
- i++;
- if (i > 100000) {
-#ifdef BETTER_CLOCK_DIAGNOSTIC
- printf("forward_statclock: dropped ast 0x%x\n",
- checkstate_need_ast & map);
-#endif
- break;
- }
- }
- }
-}
-
-void
-forward_hardclock(int pscnt)
-{
- int map;
- int id;
- struct proc *p;
- struct pstats *pstats;
- int i;
-
- /* Kludge. We don't yet have separate locks for the interrupts
- * and the kernel. This means that we cannot let the other processors
- * handle complex interrupts while inhibiting them from entering
- * the kernel in a non-interrupt context.
- *
- * What we can do, without changing the locking mechanisms yet,
- * is letting the other processors handle a very simple interrupt
- * (wich determines the processor states), and do the main
- * work ourself.
- */
-
- if (!smp_started || !invltlb_ok || cold || panicstr)
- return;
-
- /* Step 1: Probe state (user, cpu, interrupt, spinlock, idle) */
-
- map = other_cpus & ~stopped_cpus ;
- checkstate_probed_cpus = 0;
- if (map != 0)
- selected_apic_ipi(map,
- XCPUCHECKSTATE_OFFSET, APIC_DELMODE_FIXED);
-
- i = 0;
- while (checkstate_probed_cpus != map) {
- /* spin */
- i++;
- if (i == 100000) {
-#ifdef BETTER_CLOCK_DIAGNOSTIC
- printf("forward_hardclock: checkstate %x\n",
- checkstate_probed_cpus);
-#endif
- break;
- }
- }
-
- /*
- * Step 2: walk through other processors processes, update virtual
- * timer and profiling timer. If stathz == 0, also update ticks and
- * profiling info.
- */
-
- map = 0;
- for (id = 0; id < mp_ncpus; id++) {
- if (id == cpuid)
- continue;
- if (((1 << id) & checkstate_probed_cpus) == 0)
- continue;
- p = checkstate_curproc[id];
- if (p) {
- pstats = p->p_stats;
- if (checkstate_cpustate[id] == CHECKSTATE_USER &&
- timevalisset(&pstats->p_timer[ITIMER_VIRTUAL].it_value) &&
- itimerdecr(&pstats->p_timer[ITIMER_VIRTUAL], tick) == 0) {
- psignal(p, SIGVTALRM);
- map |= (1 << id);
- }
- if (timevalisset(&pstats->p_timer[ITIMER_PROF].it_value) &&
- itimerdecr(&pstats->p_timer[ITIMER_PROF], tick) == 0) {
- psignal(p, SIGPROF);
- map |= (1 << id);
- }
- }
- if (stathz == 0) {
- forwarded_statclock( id, pscnt, &map);
- }
- }
- if (map != 0) {
- checkstate_need_ast |= map;
- selected_apic_ipi(map, XCPUAST_OFFSET, APIC_DELMODE_FIXED);
- i = 0;
- while ((checkstate_need_ast & map) != 0) {
- /* spin */
- i++;
- if (i > 100000) {
-#ifdef BETTER_CLOCK_DIAGNOSTIC
- printf("forward_hardclock: dropped ast 0x%x\n",
- checkstate_need_ast & map);
-#endif
- break;
- }
- }
- }
-}
-
-#endif /* BETTER_CLOCK */
-
-void
-forward_signal(struct proc *p)
-{
- int map;
- int id;
- int i;
-
- /* Kludge. We don't yet have separate locks for the interrupts
- * and the kernel. This means that we cannot let the other processors
- * handle complex interrupts while inhibiting them from entering
- * the kernel in a non-interrupt context.
- *
- * What we can do, without changing the locking mechanisms yet,
- * is letting the other processors handle a very simple interrupt
- * (wich determines the processor states), and do the main
- * work ourself.
- */
-
- if (!smp_started || !invltlb_ok || cold || panicstr)
- return;
- if (!forward_signal_enabled)
- return;
- while (1) {
- if (p->p_stat != SRUN)
- return;
- id = p->p_oncpu;
- if (id == 0xff)
- return;
- map = (1<<id);
- checkstate_need_ast |= map;
- selected_apic_ipi(map, XCPUAST_OFFSET, APIC_DELMODE_FIXED);
- i = 0;
- while ((checkstate_need_ast & map) != 0) {
- /* spin */
- i++;
- if (i > 100000) {
-#if 0
- printf("forward_signal: dropped ast 0x%x\n",
- checkstate_need_ast & map);
-#endif
- break;
- }
- }
- if (id == p->p_oncpu)
- return;
- }
-}
-
-void
-forward_roundrobin(void)
-{
- u_int map;
- int i;
-
- if (!smp_started || !invltlb_ok || cold || panicstr)
- return;
- if (!forward_roundrobin_enabled)
- return;
- resched_cpus |= other_cpus;
- map = other_cpus & ~stopped_cpus ;
-#if 1
- selected_apic_ipi(map, XCPUAST_OFFSET, APIC_DELMODE_FIXED);
-#else
- (void) all_but_self_ipi(XCPUAST_OFFSET);
-#endif
- i = 0;
- while ((checkstate_need_ast & map) != 0) {
- /* spin */
- i++;
- if (i > 100000) {
-#if 0
- printf("forward_roundrobin: dropped ast 0x%x\n",
- checkstate_need_ast & map);
-#endif
- break;
- }
- }
-}
-
-
-#ifdef APIC_INTR_REORDER
-/*
- * Maintain mapping from softintr vector to isr bit in local apic.
- */
-void
-set_lapic_isrloc(int intr, int vector)
-{
- if (intr < 0 || intr > 32)
- panic("set_apic_isrloc: bad intr argument: %d",intr);
- if (vector < ICU_OFFSET || vector > 255)
- panic("set_apic_isrloc: bad vector argument: %d",vector);
- apic_isrbit_location[intr].location = &lapic.isr0 + ((vector>>5)<<2);
- apic_isrbit_location[intr].bit = (1<<(vector & 31));
-}
-#endif
-
-/*
- * All-CPU rendezvous. CPUs are signalled, all execute the setup function
- * (if specified), rendezvous, execute the action function (if specified),
- * rendezvous again, execute the teardown function (if specified), and then
- * resume.
- *
- * Note that the supplied external functions _must_ be reentrant and aware
- * that they are running in parallel and in an unknown lock context.
- */
-static void (*smp_rv_setup_func)(void *arg);
-static void (*smp_rv_action_func)(void *arg);
-static void (*smp_rv_teardown_func)(void *arg);
-static void *smp_rv_func_arg;
-static volatile int smp_rv_waiters[2];
-
-void
-smp_rendezvous_action(void)
-{
- /* setup function */
- if (smp_rv_setup_func != NULL)
- smp_rv_setup_func(smp_rv_func_arg);
- /* spin on entry rendezvous */
- atomic_add_int(&smp_rv_waiters[0], 1);
- while (smp_rv_waiters[0] < mp_ncpus)
- ;
- /* action function */
- if (smp_rv_action_func != NULL)
- smp_rv_action_func(smp_rv_func_arg);
- /* spin on exit rendezvous */
- atomic_add_int(&smp_rv_waiters[1], 1);
- while (smp_rv_waiters[1] < mp_ncpus)
- ;
- /* teardown function */
- if (smp_rv_teardown_func != NULL)
- smp_rv_teardown_func(smp_rv_func_arg);
-}
-
-void
-smp_rendezvous(void (* setup_func)(void *),
- void (* action_func)(void *),
- void (* teardown_func)(void *),
- void *arg)
-{
- u_int efl;
-
- /* obtain rendezvous lock */
- s_lock(&smp_rv_lock); /* XXX sleep here? NOWAIT flag? */
-
- /* set static function pointers */
- smp_rv_setup_func = setup_func;
- smp_rv_action_func = action_func;
- smp_rv_teardown_func = teardown_func;
- smp_rv_func_arg = arg;
- smp_rv_waiters[0] = 0;
- smp_rv_waiters[1] = 0;
-
- /* disable interrupts on this CPU, save interrupt status */
- efl = read_eflags();
- write_eflags(efl & ~PSL_I);
-
- /* signal other processors, which will enter the IPI with interrupts off */
- all_but_self_ipi(XRENDEZVOUS_OFFSET);
-
- /* call executor function */
- smp_rendezvous_action();
-
- /* restore interrupt flag */
- write_eflags(efl);
-
- /* release lock */
- s_unlock(&smp_rv_lock);
-}
diff --git a/sys/amd64/amd64/nexus.c b/sys/amd64/amd64/nexus.c
deleted file mode 100644
index f5554f8beac1..000000000000
--- a/sys/amd64/amd64/nexus.c
+++ /dev/null
@@ -1,434 +0,0 @@
-/*
- * Copyright 1998 Massachusetts Institute of Technology
- *
- * Permission to use, copy, modify, and distribute this software and
- * its documentation for any purpose and without fee is hereby
- * granted, provided that both the above copyright notice and this
- * permission notice appear in all copies, that both the above
- * copyright notice and this permission notice appear in all
- * supporting documentation, and that the name of M.I.T. not be used
- * in advertising or publicity pertaining to distribution of the
- * software without specific, written prior permission. M.I.T. makes
- * no representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied
- * warranty.
- *
- * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS
- * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
- * SHALL M.I.T. 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.
- *
- * $FreeBSD$
- */
-
-/*
- * This code implements a `root nexus' for Intel Architecture
- * machines. The function of the root nexus is to serve as an
- * attachment point for both processors and buses, and to manage
- * resources which are common to all of them. In particular,
- * this code implements the core resource managers for interrupt
- * requests, DMA requests (which rightfully should be a part of the
- * ISA code but it's easier to do it here for now), I/O port addresses,
- * and I/O memory address space.
- */
-
-#include "opt_smp.h"
-#include "mca.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <machine/bus.h>
-#include <sys/rman.h>
-
-#include <machine/vmparam.h>
-#include <vm/vm.h>
-#include <vm/pmap.h>
-#include <machine/pmap.h>
-
-#include <machine/resource.h>
-#ifdef APIC_IO
-#include <machine/smp.h>
-#include <machine/mpapic.h>
-#endif
-
-#ifdef PC98
-#include <pc98/pc98/pc98.h>
-#else
-#include <i386/isa/isa.h>
-#endif
-#include <i386/isa/intr_machdep.h>
-
-static struct rman irq_rman, drq_rman, port_rman, mem_rman;
-
-static int nexus_probe(device_t);
-static int nexus_attach(device_t);
-static int nexus_print_child(device_t, device_t);
-static device_t nexus_add_child(device_t bus, int order, const char *name,
- int unit);
-static struct resource *nexus_alloc_resource(device_t, device_t, int, int *,
- u_long, u_long, u_long, u_int);
-static int nexus_activate_resource(device_t, device_t, int, int,
- struct resource *);
-static int nexus_deactivate_resource(device_t, device_t, int, int,
- struct resource *);
-static int nexus_release_resource(device_t, device_t, int, int,
- struct resource *);
-static int nexus_setup_intr(device_t, device_t, struct resource *, int flags,
- void (*)(void *), void *, void **);
-static int nexus_teardown_intr(device_t, device_t, struct resource *,
- void *);
-
-static device_method_t nexus_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, nexus_probe),
- DEVMETHOD(device_attach, nexus_attach),
- DEVMETHOD(device_detach, bus_generic_detach),
- DEVMETHOD(device_shutdown, bus_generic_shutdown),
- DEVMETHOD(device_suspend, bus_generic_suspend),
- DEVMETHOD(device_resume, bus_generic_resume),
-
- /* Bus interface */
- DEVMETHOD(bus_print_child, nexus_print_child),
- DEVMETHOD(bus_add_child, nexus_add_child),
- DEVMETHOD(bus_read_ivar, bus_generic_read_ivar),
- DEVMETHOD(bus_write_ivar, bus_generic_write_ivar),
- DEVMETHOD(bus_alloc_resource, nexus_alloc_resource),
- DEVMETHOD(bus_release_resource, nexus_release_resource),
- DEVMETHOD(bus_activate_resource, nexus_activate_resource),
- DEVMETHOD(bus_deactivate_resource, nexus_deactivate_resource),
- DEVMETHOD(bus_setup_intr, nexus_setup_intr),
- DEVMETHOD(bus_teardown_intr, nexus_teardown_intr),
-
- { 0, 0 }
-};
-
-static driver_t nexus_driver = {
- "nexus",
- nexus_methods,
- 1, /* no softc */
-};
-static devclass_t nexus_devclass;
-
-DRIVER_MODULE(nexus, root, nexus_driver, nexus_devclass, 0, 0);
-
-static int
-nexus_probe(device_t dev)
-{
-
- device_quiet(dev); /* suppress attach message for neatness */
-
- /*
- * IRQ's are on the mainboard on old systems, but on the ISA part
- * of PCI->ISA bridges. There would be multiple sets of IRQs on
- * multi-ISA-bus systems. PCI interrupts are routed to the ISA
- * component, so in a way, PCI can be a partial child of an ISA bus(!).
- * APIC interrupts are global though.
- * In the non-APIC case, disallow the use of IRQ 2.
- */
- irq_rman.rm_start = 0;
- irq_rman.rm_type = RMAN_ARRAY;
- irq_rman.rm_descr = "Interrupt request lines";
-#ifdef APIC_IO
- irq_rman.rm_end = APIC_INTMAPSIZE - 1;
- if (rman_init(&irq_rman)
- || rman_manage_region(&irq_rman,
- irq_rman.rm_start, irq_rman.rm_end))
- panic("nexus_probe irq_rman");
-#else
- irq_rman.rm_end = 15;
- if (rman_init(&irq_rman)
- || rman_manage_region(&irq_rman, irq_rman.rm_start, 1)
- || rman_manage_region(&irq_rman, 3, irq_rman.rm_end))
- panic("nexus_probe irq_rman");
-#endif
-
- /*
- * ISA DMA on PCI systems is implemented in the ISA part of each
- * PCI->ISA bridge and the channels can be duplicated if there are
- * multiple bridges. (eg: laptops with docking stations)
- */
- drq_rman.rm_start = 0;
- drq_rman.rm_end = 7;
- drq_rman.rm_type = RMAN_ARRAY;
- drq_rman.rm_descr = "DMA request lines";
- /* XXX drq 0 not available on some machines */
- if (rman_init(&drq_rman)
- || rman_manage_region(&drq_rman, 0, 7))
- panic("nexus_probe drq_rman");
-
- /*
- * However, IO ports and Memory truely are global at this level,
- * as are APIC interrupts (however many IO APICS there turn out
- * to be on large systems..)
- */
- port_rman.rm_start = 0;
- port_rman.rm_end = 0xffff;
- port_rman.rm_type = RMAN_ARRAY;
- port_rman.rm_descr = "I/O ports";
- if (rman_init(&port_rman)
- || rman_manage_region(&port_rman, 0, 0xffff))
- panic("nexus_probe port_rman");
-
- mem_rman.rm_start = 0;
- mem_rman.rm_end = ~0u;
- mem_rman.rm_type = RMAN_ARRAY;
- mem_rman.rm_descr = "I/O memory addresses";
- if (rman_init(&mem_rman)
- || rman_manage_region(&mem_rman, 0, ~0))
- panic("nexus_probe mem_rman");
-
- return bus_generic_probe(dev);
-}
-
-static int
-nexus_attach(device_t dev)
-{
- device_t child;
-
- /*
- * First, deal with the children we know about already
- */
- bus_generic_attach(dev);
- /*
- * And if we didn't see EISA or ISA on a pci bridge, create some
- * connection points now so they show up "on motherboard".
- */
- if (!devclass_get_device(devclass_find("eisa"), 0)) {
- child = device_add_child(dev, "eisa", 0);
- if (child == NULL)
- panic("nexus_attach eisa");
- device_probe_and_attach(child);
- }
-#if NMCA > 0
- if (!devclass_get_device(devclass_find("mca"), 0)) {
- child = device_add_child(dev, "mca", 0);
- if (child == 0)
- panic("nexus_probe mca");
- device_probe_and_attach(child);
- }
-#endif
- if (!devclass_get_device(devclass_find("isa"), 0)) {
- child = device_add_child(dev, "isa", 0);
- if (child == NULL)
- panic("nexus_attach isa");
- device_probe_and_attach(child);
- }
-
- return 0;
-}
-
-static int
-nexus_print_child(device_t bus, device_t child)
-{
- int retval = 0;
-
- retval += bus_print_child_header(bus, child);
- retval += printf(" on motherboard\n");
-
- return (retval);
-}
-
-static device_t
-nexus_add_child(device_t bus, int order, const char *name, int unit)
-{
- return device_add_child_ordered(bus, order, name, unit);
-}
-
-/*
- * Allocate a resource on behalf of child. NB: child is usually going to be a
- * child of one of our descendants, not a direct child of nexus0.
- * (Exceptions include npx.)
- */
-static struct resource *
-nexus_alloc_resource(device_t bus, device_t child, int type, int *rid,
- u_long start, u_long end, u_long count, u_int flags)
-{
- struct resource *rv;
- struct rman *rm;
- int needactivate = flags & RF_ACTIVE;
-
- flags &= ~RF_ACTIVE;
-
- switch (type) {
- case SYS_RES_IRQ:
- rm = &irq_rman;
- break;
-
- case SYS_RES_DRQ:
- rm = &drq_rman;
- break;
-
- case SYS_RES_IOPORT:
- rm = &port_rman;
- break;
-
- case SYS_RES_MEMORY:
- rm = &mem_rman;
- break;
-
- default:
- return 0;
- }
-
- rv = rman_reserve_resource(rm, start, end, count, flags, child);
- if (rv == 0)
- return 0;
-
- if (type == SYS_RES_MEMORY) {
- rman_set_bustag(rv, I386_BUS_SPACE_MEM);
- } else if (type == SYS_RES_IOPORT) {
- rman_set_bustag(rv, I386_BUS_SPACE_IO);
- rman_set_bushandle(rv, rv->r_start);
- }
-
- if (needactivate) {
- if (bus_activate_resource(child, type, *rid, rv)) {
- rman_release_resource(rv);
- return 0;
- }
- }
-
- return rv;
-}
-
-static int
-nexus_activate_resource(device_t bus, device_t child, int type, int rid,
- struct resource *r)
-{
- /*
- * If this is a memory resource, map it into the kernel.
- */
- if (rman_get_bustag(r) == I386_BUS_SPACE_MEM) {
- caddr_t vaddr = 0;
-
- if (r->r_end < 1024 * 1024) {
- /*
- * The first 1Mb is mapped at KERNBASE.
- */
- vaddr = (caddr_t)(uintptr_t)(KERNBASE + r->r_start);
- } else {
- u_int32_t paddr;
- u_int32_t psize;
- u_int32_t poffs;
-
- paddr = r->r_start;
- psize = r->r_end - r->r_start;
-
- poffs = paddr - trunc_page(paddr);
- vaddr = (caddr_t) pmap_mapdev(paddr-poffs, psize+poffs) + poffs;
- }
- rman_set_virtual(r, vaddr);
- rman_set_bushandle(r, (bus_space_handle_t) vaddr);
- }
- return (rman_activate_resource(r));
-}
-
-static int
-nexus_deactivate_resource(device_t bus, device_t child, int type, int rid,
- struct resource *r)
-{
- /*
- * If this is a memory resource, unmap it.
- */
- if ((rman_get_bustag(r) == I386_BUS_SPACE_MEM) && (r->r_end >= 1024 * 1024)) {
- u_int32_t psize;
-
- psize = r->r_end - r->r_start;
- pmap_unmapdev((vm_offset_t)rman_get_virtual(r), psize);
- }
-
- return (rman_deactivate_resource(r));
-}
-
-static int
-nexus_release_resource(device_t bus, device_t child, int type, int rid,
- struct resource *r)
-{
- if (r->r_flags & RF_ACTIVE) {
- int error = bus_deactivate_resource(child, type, rid, r);
- if (error)
- return error;
- }
- return (rman_release_resource(r));
-}
-
-/*
- * Currently this uses the really grody interface from kern/kern_intr.c
- * (which really doesn't belong in kern/anything.c). Eventually, all of
- * the code in kern_intr.c and machdep_intr.c should get moved here, since
- * this is going to be the official interface.
- */
-static int
-nexus_setup_intr(device_t bus, device_t child, struct resource *irq,
- int flags, void (*ihand)(void *), void *arg, void **cookiep)
-{
- intrmask_t *mask;
- driver_t *driver;
- int error, icflags;
-
- /* somebody tried to setup an irq that failed to allocate! */
- if (irq == NULL)
- panic("nexus_setup_intr: NULL irq resource!");
-
- *cookiep = 0;
- if (irq->r_flags & RF_SHAREABLE)
- icflags = 0;
- else
- icflags = INTR_EXCL;
-
- driver = device_get_driver(child);
- switch (flags) {
- case INTR_TYPE_TTY:
- mask = &tty_imask;
- break;
- case (INTR_TYPE_TTY | INTR_TYPE_FAST):
- mask = &tty_imask;
- icflags |= INTR_FAST;
- break;
- case INTR_TYPE_BIO:
- mask = &bio_imask;
- break;
- case INTR_TYPE_NET:
- mask = &net_imask;
- break;
- case INTR_TYPE_CAM:
- mask = &cam_imask;
- break;
- case INTR_TYPE_MISC:
- mask = 0;
- break;
- default:
- panic("still using grody create_intr interface");
- }
-
- /*
- * We depend here on rman_activate_resource() being idempotent.
- */
- error = rman_activate_resource(irq);
- if (error)
- return (error);
-
- *cookiep = inthand_add(device_get_nameunit(child), irq->r_start,
- ihand, arg, mask, icflags);
- if (*cookiep == NULL)
- error = EINVAL; /* XXX ??? */
-
- return (error);
-}
-
-static int
-nexus_teardown_intr(device_t dev, device_t child, struct resource *r, void *ih)
-{
- return (inthand_remove(ih));
-}
diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c
deleted file mode 100644
index 96d880dfa8ed..000000000000
--- a/sys/amd64/amd64/pmap.c
+++ /dev/null
@@ -1,3514 +0,0 @@
-/*
- * Copyright (c) 1991 Regents of the University of California.
- * All rights reserved.
- * Copyright (c) 1994 John S. Dyson
- * All rights reserved.
- * Copyright (c) 1994 David Greenman
- * 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 and William Jolitz of UUNET Technologies Inc.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)pmap.c 7.7 (Berkeley) 5/12/91
- * $FreeBSD$
- */
-
-/*
- * Manages physical address maps.
- *
- * In addition to hardware address maps, this
- * module is called upon to provide software-use-only
- * maps which may or may not be stored in the same
- * form as hardware maps. These pseudo-maps are
- * used to store intermediate results from copy
- * operations to and from address spaces.
- *
- * Since the information managed by this module is
- * also stored by the logical address mapping module,
- * this module may throw away valid virtual-to-physical
- * mappings at almost any time. However, invalidations
- * of virtual-to-physical mappings must be done as
- * requested.
- *
- * In order to cope with hardware architectures which
- * make virtual-to-physical map invalidates expensive,
- * this module may delay invalidate or reduced protection
- * operations until such time as they are actually
- * necessary. This module is given full information as
- * to which processors are currently using which maps,
- * and to when physical maps must be made correct.
- */
-
-#include "opt_disable_pse.h"
-#include "opt_pmap.h"
-#include "opt_msgbuf.h"
-#include "opt_user_ldt.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/proc.h>
-#include <sys/msgbuf.h>
-#include <sys/vmmeter.h>
-#include <sys/mman.h>
-
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <sys/lock.h>
-#include <vm/vm_kern.h>
-#include <vm/vm_page.h>
-#include <vm/vm_map.h>
-#include <vm/vm_object.h>
-#include <vm/vm_extern.h>
-#include <vm/vm_pageout.h>
-#include <vm/vm_pager.h>
-#include <vm/vm_zone.h>
-
-#include <sys/user.h>
-
-#include <machine/cputypes.h>
-#include <machine/md_var.h>
-#include <machine/specialreg.h>
-#if defined(SMP) || defined(APIC_IO)
-#include <machine/smp.h>
-#include <machine/apic.h>
-#include <machine/segments.h>
-#include <machine/tss.h>
-#include <machine/globaldata.h>
-#endif /* SMP || APIC_IO */
-
-#define PMAP_KEEP_PDIRS
-#ifndef PMAP_SHPGPERPROC
-#define PMAP_SHPGPERPROC 200
-#endif
-
-#if defined(DIAGNOSTIC)
-#define PMAP_DIAGNOSTIC
-#endif
-
-#define MINPV 2048
-
-#if !defined(PMAP_DIAGNOSTIC)
-#define PMAP_INLINE __inline
-#else
-#define PMAP_INLINE
-#endif
-
-/*
- * Get PDEs and PTEs for user/kernel address space
- */
-#define pmap_pde(m, v) (&((m)->pm_pdir[(vm_offset_t)(v) >> PDRSHIFT]))
-#define pdir_pde(m, v) (m[(vm_offset_t)(v) >> PDRSHIFT])
-
-#define pmap_pde_v(pte) ((*(int *)pte & PG_V) != 0)
-#define pmap_pte_w(pte) ((*(int *)pte & PG_W) != 0)
-#define pmap_pte_m(pte) ((*(int *)pte & PG_M) != 0)
-#define pmap_pte_u(pte) ((*(int *)pte & PG_A) != 0)
-#define pmap_pte_v(pte) ((*(int *)pte & PG_V) != 0)
-
-#define pmap_pte_set_w(pte, v) ((v)?(*(int *)pte |= PG_W):(*(int *)pte &= ~PG_W))
-#define pmap_pte_set_prot(pte, v) ((*(int *)pte &= ~PG_PROT), (*(int *)pte |= (v)))
-
-/*
- * Given a map and a machine independent protection code,
- * convert to a vax protection code.
- */
-#define pte_prot(m, p) (protection_codes[p])
-static int protection_codes[8];
-
-#define pa_index(pa) atop((pa) - vm_first_phys)
-#define pa_to_pvh(pa) (&pv_table[pa_index(pa)])
-
-static struct pmap kernel_pmap_store;
-pmap_t kernel_pmap;
-
-vm_offset_t avail_start; /* PA of first available physical page */
-vm_offset_t avail_end; /* PA of last available physical page */
-vm_offset_t virtual_avail; /* VA of first avail page (after kernel bss) */
-vm_offset_t virtual_end; /* VA of last avail page (end of kernel AS) */
-static boolean_t pmap_initialized = FALSE; /* Has pmap_init completed? */
-static vm_offset_t vm_first_phys;
-static int pgeflag; /* PG_G or-in */
-static int pseflag; /* PG_PS or-in */
-static int pv_npg;
-
-static vm_object_t kptobj;
-
-static int nkpt;
-vm_offset_t kernel_vm_end;
-
-/*
- * Data for the pv entry allocation mechanism
- */
-static vm_zone_t pvzone;
-static struct vm_zone pvzone_store;
-static struct vm_object pvzone_obj;
-static int pv_entry_count=0, pv_entry_max=0, pv_entry_high_water=0;
-static int pmap_pagedaemon_waken = 0;
-static struct pv_entry *pvinit;
-
-/*
- * All those kernel PT submaps that BSD is so fond of
- */
-pt_entry_t *CMAP1 = 0;
-static pt_entry_t *CMAP2, *ptmmap;
-static pv_table_t *pv_table;
-caddr_t CADDR1 = 0, ptvmmap = 0;
-static caddr_t CADDR2;
-static pt_entry_t *msgbufmap;
-struct msgbuf *msgbufp=0;
-
-#ifdef SMP
-extern pt_entry_t *SMPpt;
-#else
-static pt_entry_t *PMAP1 = 0;
-static unsigned *PADDR1 = 0;
-#endif
-
-static PMAP_INLINE void free_pv_entry __P((pv_entry_t pv));
-static unsigned * get_ptbase __P((pmap_t pmap));
-static pv_entry_t get_pv_entry __P((void));
-static void i386_protection_init __P((void));
-static __inline void pmap_changebit __P((vm_offset_t pa, int bit, boolean_t setem));
-static void pmap_clearbit __P((vm_offset_t pa, int bit));
-
-static PMAP_INLINE int pmap_is_managed __P((vm_offset_t pa));
-static void pmap_remove_all __P((vm_offset_t pa));
-static vm_page_t pmap_enter_quick __P((pmap_t pmap, vm_offset_t va,
- vm_offset_t pa, vm_page_t mpte));
-static int pmap_remove_pte __P((struct pmap *pmap, unsigned *ptq,
- vm_offset_t sva));
-static void pmap_remove_page __P((struct pmap *pmap, vm_offset_t va));
-static int pmap_remove_entry __P((struct pmap *pmap, pv_table_t *pv,
- vm_offset_t va));
-static boolean_t pmap_testbit __P((vm_offset_t pa, int bit));
-static void pmap_insert_entry __P((pmap_t pmap, vm_offset_t va,
- vm_page_t mpte, vm_offset_t pa));
-
-static vm_page_t pmap_allocpte __P((pmap_t pmap, vm_offset_t va));
-
-static int pmap_release_free_page __P((pmap_t pmap, vm_page_t p));
-static vm_page_t _pmap_allocpte __P((pmap_t pmap, unsigned ptepindex));
-static unsigned * pmap_pte_quick __P((pmap_t pmap, vm_offset_t va));
-static vm_page_t pmap_page_lookup __P((vm_object_t object, vm_pindex_t pindex));
-static int pmap_unuse_pt __P((pmap_t, vm_offset_t, vm_page_t));
-static vm_offset_t pmap_kmem_choose(vm_offset_t addr);
-
-static unsigned pdir4mb;
-
-/*
- * Routine: pmap_pte
- * Function:
- * Extract the page table entry associated
- * with the given map/virtual_address pair.
- */
-
-PMAP_INLINE unsigned *
-pmap_pte(pmap, va)
- register pmap_t pmap;
- vm_offset_t va;
-{
- unsigned *pdeaddr;
-
- if (pmap) {
- pdeaddr = (unsigned *) pmap_pde(pmap, va);
- if (*pdeaddr & PG_PS)
- return pdeaddr;
- if (*pdeaddr) {
- return get_ptbase(pmap) + i386_btop(va);
- }
- }
- return (0);
-}
-
-/*
- * Move the kernel virtual free pointer to the next
- * 4MB. This is used to help improve performance
- * by using a large (4MB) page for much of the kernel
- * (.text, .data, .bss)
- */
-static vm_offset_t
-pmap_kmem_choose(vm_offset_t addr) {
- vm_offset_t newaddr = addr;
-#ifndef DISABLE_PSE
- if (cpu_feature & CPUID_PSE) {
- newaddr = (addr + (NBPDR - 1)) & ~(NBPDR - 1);
- }
-#endif
- return newaddr;
-}
-
-/*
- * Bootstrap the system enough to run with virtual memory.
- *
- * On the i386 this is called after mapping has already been enabled
- * and just syncs the pmap module with what has already been done.
- * [We can't call it easily with mapping off since the kernel is not
- * mapped with PA == VA, hence we would have to relocate every address
- * from the linked base (virtual) address "KERNBASE" to the actual
- * (physical) address starting relative to 0]
- */
-void
-pmap_bootstrap(firstaddr, loadaddr)
- vm_offset_t firstaddr;
- vm_offset_t loadaddr;
-{
- vm_offset_t va;
- pt_entry_t *pte;
-#ifdef SMP
- int i, j;
- struct globaldata *gd;
-#endif
-
- avail_start = firstaddr;
-
- /*
- * XXX The calculation of virtual_avail is wrong. It's NKPT*PAGE_SIZE too
- * large. It should instead be correctly calculated in locore.s and
- * not based on 'first' (which is a physical address, not a virtual
- * address, for the start of unused physical memory). The kernel
- * page tables are NOT double mapped and thus should not be included
- * in this calculation.
- */
- virtual_avail = (vm_offset_t) KERNBASE + firstaddr;
- virtual_avail = pmap_kmem_choose(virtual_avail);
-
- virtual_end = VM_MAX_KERNEL_ADDRESS;
-
- /*
- * Initialize protection array.
- */
- i386_protection_init();
-
- /*
- * The kernel's pmap is statically allocated so we don't have to use
- * pmap_create, which is unlikely to work correctly at this part of
- * the boot sequence (XXX and which no longer exists).
- */
- kernel_pmap = &kernel_pmap_store;
-
- kernel_pmap->pm_pdir = (pd_entry_t *) (KERNBASE + (u_int)IdlePTD);
- kernel_pmap->pm_count = 1;
- kernel_pmap->pm_active = -1; /* don't allow deactivation */
- TAILQ_INIT(&kernel_pmap->pm_pvlist);
- nkpt = NKPT;
-
- /*
- * Reserve some special page table entries/VA space for temporary
- * mapping of pages.
- */
-#define SYSMAP(c, p, v, n) \
- v = (c)va; va += ((n)*PAGE_SIZE); p = pte; pte += (n);
-
- va = virtual_avail;
- pte = (pt_entry_t *) pmap_pte(kernel_pmap, va);
-
- /*
- * CMAP1/CMAP2 are used for zeroing and copying pages.
- */
- SYSMAP(caddr_t, CMAP1, CADDR1, 1)
- SYSMAP(caddr_t, CMAP2, CADDR2, 1)
-
- /*
- * ptvmmap is used for reading arbitrary physical pages via /dev/mem.
- * XXX ptmmap is not used.
- */
- SYSMAP(caddr_t, ptmmap, ptvmmap, 1)
-
- /*
- * msgbufp is used to map the system message buffer.
- * XXX msgbufmap is not used.
- */
- SYSMAP(struct msgbuf *, msgbufmap, msgbufp,
- atop(round_page(MSGBUF_SIZE)))
-
-#if !defined(SMP)
- /*
- * ptemap is used for pmap_pte_quick
- */
- SYSMAP(unsigned *, PMAP1, PADDR1, 1);
-#endif
-
- virtual_avail = va;
-
- *(int *) CMAP1 = *(int *) CMAP2 = 0;
- *(int *) PTD = 0;
-
-
- pgeflag = 0;
-#if !defined(SMP)
- if (cpu_feature & CPUID_PGE) {
- pgeflag = PG_G;
- }
-#endif
-
-/*
- * Initialize the 4MB page size flag
- */
- pseflag = 0;
-/*
- * The 4MB page version of the initial
- * kernel page mapping.
- */
- pdir4mb = 0;
-
-#if !defined(DISABLE_PSE)
- if (cpu_feature & CPUID_PSE) {
- unsigned ptditmp;
- /*
- * Note that we have enabled PSE mode
- */
- pseflag = PG_PS;
- ptditmp = *((unsigned *)PTmap + i386_btop(KERNBASE));
- ptditmp &= ~(NBPDR - 1);
- ptditmp |= PG_V | PG_RW | PG_PS | PG_U | pgeflag;
- pdir4mb = ptditmp;
-
-#if !defined(SMP)
- /*
- * Enable the PSE mode.
- */
- load_cr4(rcr4() | CR4_PSE);
-
- /*
- * We can do the mapping here for the single processor
- * case. We simply ignore the old page table page from
- * now on.
- */
- /*
- * For SMP, we still need 4K pages to bootstrap APs,
- * PSE will be enabled as soon as all APs are up.
- */
- PTD[KPTDI] = (pd_entry_t) ptditmp;
- kernel_pmap->pm_pdir[KPTDI] = (pd_entry_t) ptditmp;
- invltlb();
-#endif
- }
-#endif
-
-#ifdef SMP
- if (cpu_apic_address == 0)
- panic("pmap_bootstrap: no local apic!");
-
- /* local apic is mapped on last page */
- SMPpt[NPTEPG - 1] = (pt_entry_t)(PG_V | PG_RW | PG_N | pgeflag |
- (cpu_apic_address & PG_FRAME));
-
- for (i = 0; i < mp_napics; i++) {
- for (j = 0; j < mp_napics; j++) {
- /* same page frame as a previous IO apic? */
- if (((vm_offset_t)SMPpt[NPTEPG-2-j] & PG_FRAME) ==
- (io_apic_address[0] & PG_FRAME)) {
- ioapic[i] = (ioapic_t *)((u_int)SMP_prvspace
- + (NPTEPG-2-j)*PAGE_SIZE);
- break;
- }
- /* use this slot if available */
- if (((vm_offset_t)SMPpt[NPTEPG-2-j] & PG_FRAME) == 0) {
- SMPpt[NPTEPG-2-j] = (pt_entry_t)(PG_V | PG_RW |
- pgeflag | (io_apic_address[i] & PG_FRAME));
- ioapic[i] = (ioapic_t *)((u_int)SMP_prvspace
- + (NPTEPG-2-j)*PAGE_SIZE);
- break;
- }
- }
- }
-
- /* BSP does this itself, AP's get it pre-set */
- gd = &SMP_prvspace[0].globaldata;
- gd->gd_prv_CMAP1 = &SMPpt[1];
- gd->gd_prv_CMAP2 = &SMPpt[2];
- gd->gd_prv_CMAP3 = &SMPpt[3];
- gd->gd_prv_PMAP1 = &SMPpt[4];
- gd->gd_prv_CADDR1 = SMP_prvspace[0].CPAGE1;
- gd->gd_prv_CADDR2 = SMP_prvspace[0].CPAGE2;
- gd->gd_prv_CADDR3 = SMP_prvspace[0].CPAGE3;
- gd->gd_prv_PADDR1 = (unsigned *)SMP_prvspace[0].PPAGE1;
-#endif
-
- invltlb();
-}
-
-#ifdef SMP
-/*
- * Set 4mb pdir for mp startup
- */
-void
-pmap_set_opt(void)
-{
- if (pseflag && (cpu_feature & CPUID_PSE)) {
- load_cr4(rcr4() | CR4_PSE);
- if (pdir4mb && cpuid == 0) { /* only on BSP */
- kernel_pmap->pm_pdir[KPTDI] =
- PTD[KPTDI] = (pd_entry_t)pdir4mb;
- cpu_invltlb();
- }
- }
-}
-#endif
-
-/*
- * Initialize the pmap module.
- * Called by vm_init, to initialize any structures that the pmap
- * system needs to map virtual memory.
- * pmap_init has been enhanced to support in a fairly consistant
- * way, discontiguous physical memory.
- */
-void
-pmap_init(phys_start, phys_end)
- vm_offset_t phys_start, phys_end;
-{
- vm_offset_t addr;
- vm_size_t s;
- int i;
- int initial_pvs;
-
- /*
- * object for kernel page table pages
- */
- kptobj = vm_object_allocate(OBJT_DEFAULT, NKPDE);
-
- /*
- * calculate the number of pv_entries needed
- */
- vm_first_phys = phys_avail[0];
- for (i = 0; phys_avail[i + 1]; i += 2);
- pv_npg = (phys_avail[(i - 2) + 1] - vm_first_phys) / PAGE_SIZE;
-
- /*
- * Allocate memory for random pmap data structures. Includes the
- * pv_head_table.
- */
- s = (vm_size_t) (sizeof(pv_table_t) * pv_npg);
- s = round_page(s);
-
- addr = (vm_offset_t) kmem_alloc(kernel_map, s);
- pv_table = (pv_table_t *) addr;
- for(i = 0; i < pv_npg; i++) {
- vm_offset_t pa;
- TAILQ_INIT(&pv_table[i].pv_list);
- pv_table[i].pv_list_count = 0;
- pa = vm_first_phys + i * PAGE_SIZE;
- pv_table[i].pv_vm_page = PHYS_TO_VM_PAGE(pa);
- }
-
- /*
- * init the pv free list
- */
- initial_pvs = pv_npg;
- if (initial_pvs < MINPV)
- initial_pvs = MINPV;
- pvzone = &pvzone_store;
- pvinit = (struct pv_entry *) kmem_alloc(kernel_map,
- initial_pvs * sizeof (struct pv_entry));
- zbootinit(pvzone, "PV ENTRY", sizeof (struct pv_entry), pvinit, pv_npg);
-
- /*
- * Now it is safe to enable pv_table recording.
- */
- pmap_initialized = TRUE;
-}
-
-/*
- * Initialize the address space (zone) for the pv_entries. Set a
- * high water mark so that the system can recover from excessive
- * numbers of pv entries.
- */
-void
-pmap_init2() {
- pv_entry_max = PMAP_SHPGPERPROC * maxproc + pv_npg;
- pv_entry_high_water = 9 * (pv_entry_max / 10);
- zinitna(pvzone, &pvzone_obj, NULL, 0, pv_entry_max, ZONE_INTERRUPT, 1);
-}
-
-/*
- * Used to map a range of physical addresses into kernel
- * virtual address space.
- *
- * For now, VM is already on, we only need to map the
- * specified memory.
- */
-vm_offset_t
-pmap_map(virt, start, end, prot)
- vm_offset_t virt;
- vm_offset_t start;
- vm_offset_t end;
- int prot;
-{
- while (start < end) {
- pmap_enter(kernel_pmap, virt, start, prot, FALSE);
- virt += PAGE_SIZE;
- start += PAGE_SIZE;
- }
- return (virt);
-}
-
-
-/***************************************************
- * Low level helper routines.....
- ***************************************************/
-
-#if defined(PMAP_DIAGNOSTIC)
-
-/*
- * This code checks for non-writeable/modified pages.
- * This should be an invalid condition.
- */
-static int
-pmap_nw_modified(pt_entry_t ptea) {
- int pte;
-
- pte = (int) ptea;
-
- if ((pte & (PG_M|PG_RW)) == PG_M)
- return 1;
- else
- return 0;
-}
-#endif
-
-
-/*
- * this routine defines the region(s) of memory that should
- * not be tested for the modified bit.
- */
-static PMAP_INLINE int
-pmap_track_modified( vm_offset_t va) {
- if ((va < clean_sva) || (va >= clean_eva))
- return 1;
- else
- return 0;
-}
-
-static PMAP_INLINE void
-invltlb_1pg( vm_offset_t va) {
-#if defined(I386_CPU)
- if (cpu_class == CPUCLASS_386) {
- invltlb();
- } else
-#endif
- {
- invlpg(va);
- }
-}
-
-static __inline void
-pmap_TLB_invalidate(pmap_t pmap, vm_offset_t va)
-{
-#if defined(SMP)
- if (pmap->pm_active & (1 << cpuid))
- cpu_invlpg((void *)va);
- if (pmap->pm_active & other_cpus)
- smp_invltlb();
-#else
- if (pmap->pm_active)
- invltlb_1pg(va);
-#endif
-}
-
-static __inline void
-pmap_TLB_invalidate_all(pmap_t pmap)
-{
-#if defined(SMP)
- if (pmap->pm_active & (1 << cpuid))
- cpu_invltlb();
- if (pmap->pm_active & other_cpus)
- smp_invltlb();
-#else
- if (pmap->pm_active)
- invltlb();
-#endif
-}
-
-static unsigned *
-get_ptbase(pmap)
- pmap_t pmap;
-{
- unsigned frame = (unsigned) pmap->pm_pdir[PTDPTDI] & PG_FRAME;
-
- /* are we current address space or kernel? */
- if (pmap == kernel_pmap || frame == (((unsigned) PTDpde) & PG_FRAME)) {
- return (unsigned *) PTmap;
- }
- /* otherwise, we are alternate address space */
- if (frame != (((unsigned) APTDpde) & PG_FRAME)) {
- APTDpde = (pd_entry_t) (frame | PG_RW | PG_V);
-#if defined(SMP)
- /* The page directory is not shared between CPUs */
- cpu_invltlb();
-#else
- invltlb();
-#endif
- }
- return (unsigned *) APTmap;
-}
-
-/*
- * Super fast pmap_pte routine best used when scanning
- * the pv lists. This eliminates many coarse-grained
- * invltlb calls. Note that many of the pv list
- * scans are across different pmaps. It is very wasteful
- * to do an entire invltlb for checking a single mapping.
- */
-
-static unsigned *
-pmap_pte_quick(pmap, va)
- register pmap_t pmap;
- vm_offset_t va;
-{
- unsigned pde, newpf;
- if ((pde = (unsigned) pmap->pm_pdir[va >> PDRSHIFT]) != 0) {
- unsigned frame = (unsigned) pmap->pm_pdir[PTDPTDI] & PG_FRAME;
- unsigned index = i386_btop(va);
- /* are we current address space or kernel? */
- if ((pmap == kernel_pmap) ||
- (frame == (((unsigned) PTDpde) & PG_FRAME))) {
- return (unsigned *) PTmap + index;
- }
- newpf = pde & PG_FRAME;
-#ifdef SMP
- if ( ((* (unsigned *) prv_PMAP1) & PG_FRAME) != newpf) {
- * (unsigned *) prv_PMAP1 = newpf | PG_RW | PG_V;
- cpu_invlpg(prv_PADDR1);
- }
- return prv_PADDR1 + ((unsigned) index & (NPTEPG - 1));
-#else
- if ( ((* (unsigned *) PMAP1) & PG_FRAME) != newpf) {
- * (unsigned *) PMAP1 = newpf | PG_RW | PG_V;
- invltlb_1pg((vm_offset_t) PADDR1);
- }
- return PADDR1 + ((unsigned) index & (NPTEPG - 1));
-#endif
- }
- return (0);
-}
-
-/*
- * Routine: pmap_extract
- * Function:
- * Extract the physical page address associated
- * with the given map/virtual_address pair.
- */
-vm_offset_t
-pmap_extract(pmap, va)
- register pmap_t pmap;
- vm_offset_t va;
-{
- vm_offset_t rtval;
- vm_offset_t pdirindex;
- pdirindex = va >> PDRSHIFT;
- if (pmap && (rtval = (unsigned) pmap->pm_pdir[pdirindex])) {
- unsigned *pte;
- if ((rtval & PG_PS) != 0) {
- rtval &= ~(NBPDR - 1);
- rtval |= va & (NBPDR - 1);
- return rtval;
- }
- pte = get_ptbase(pmap) + i386_btop(va);
- rtval = ((*pte & PG_FRAME) | (va & PAGE_MASK));
- return rtval;
- }
- return 0;
-
-}
-
-/*
- * determine if a page is managed (memory vs. device)
- */
-static PMAP_INLINE int
-pmap_is_managed(pa)
- vm_offset_t pa;
-{
- int i;
-
- if (!pmap_initialized)
- return 0;
-
- for (i = 0; phys_avail[i + 1]; i += 2) {
- if (pa < phys_avail[i + 1] && pa >= phys_avail[i])
- return 1;
- }
- return 0;
-}
-
-
-/***************************************************
- * Low level mapping routines.....
- ***************************************************/
-
-/*
- * add a wired page to the kva
- * note that in order for the mapping to take effect -- you
- * should do a invltlb after doing the pmap_kenter...
- */
-PMAP_INLINE void
-pmap_kenter(va, pa)
- vm_offset_t va;
- register vm_offset_t pa;
-{
- register unsigned *pte;
- unsigned npte, opte;
-
- npte = pa | PG_RW | PG_V | pgeflag;
- pte = (unsigned *)vtopte(va);
- opte = *pte;
- *pte = npte;
- if (opte)
- invltlb_1pg(va);
-}
-
-/*
- * remove a page from the kernel pagetables
- */
-PMAP_INLINE void
-pmap_kremove(va)
- vm_offset_t va;
-{
- register unsigned *pte;
-
- pte = (unsigned *)vtopte(va);
- *pte = 0;
- invltlb_1pg(va);
-}
-
-/*
- * Add a list of wired pages to the kva
- * this routine is only used for temporary
- * kernel mappings that do not need to have
- * page modification or references recorded.
- * Note that old mappings are simply written
- * over. The page *must* be wired.
- */
-void
-pmap_qenter(va, m, count)
- vm_offset_t va;
- vm_page_t *m;
- int count;
-{
- int i;
-
- for (i = 0; i < count; i++) {
- vm_offset_t tva = va + i * PAGE_SIZE;
- pmap_kenter(tva, VM_PAGE_TO_PHYS(m[i]));
- }
-}
-
-/*
- * this routine jerks page mappings from the
- * kernel -- it is meant only for temporary mappings.
- */
-void
-pmap_qremove(va, count)
- vm_offset_t va;
- int count;
-{
- vm_offset_t end_va;
-
- end_va = va + count*PAGE_SIZE;
-
- while (va < end_va) {
- unsigned *pte;
-
- pte = (unsigned *)vtopte(va);
- *pte = 0;
-#ifdef SMP
- cpu_invlpg((void *)va);
-#else
- invltlb_1pg(va);
-#endif
- va += PAGE_SIZE;
- }
-#ifdef SMP
- smp_invltlb();
-#endif
-}
-
-static vm_page_t
-pmap_page_lookup(object, pindex)
- vm_object_t object;
- vm_pindex_t pindex;
-{
- vm_page_t m;
-retry:
- m = vm_page_lookup(object, pindex);
- if (m && vm_page_sleep_busy(m, FALSE, "pplookp"))
- goto retry;
- return m;
-}
-
-/*
- * Create the UPAGES for a new process.
- * This routine directly affects the fork perf for a process.
- */
-void
-pmap_new_proc(p)
- struct proc *p;
-{
- int i, updateneeded;
- vm_object_t upobj;
- vm_page_t m;
- struct user *up;
- unsigned *ptek, oldpte;
-
- /*
- * allocate object for the upages
- */
- if ((upobj = p->p_upages_obj) == NULL) {
- upobj = vm_object_allocate( OBJT_DEFAULT, UPAGES);
- p->p_upages_obj = upobj;
- }
-
- /* get a kernel virtual address for the UPAGES for this proc */
- if ((up = p->p_addr) == NULL) {
- up = (struct user *) kmem_alloc_nofault(kernel_map,
- UPAGES * PAGE_SIZE);
-#if !defined(MAX_PERF)
- if (up == NULL)
- panic("pmap_new_proc: u_map allocation failed");
-#endif
- p->p_addr = up;
- }
-
- ptek = (unsigned *) vtopte((vm_offset_t) up);
-
- updateneeded = 0;
- for(i=0;i<UPAGES;i++) {
- /*
- * Get a kernel stack page
- */
- m = vm_page_grab(upobj, i, VM_ALLOC_NORMAL | VM_ALLOC_RETRY);
-
- /*
- * Wire the page
- */
- m->wire_count++;
- cnt.v_wire_count++;
-
- oldpte = *(ptek + i);
- /*
- * Enter the page into the kernel address space.
- */
- *(ptek + i) = VM_PAGE_TO_PHYS(m) | PG_RW | PG_V | pgeflag;
- if (oldpte) {
- if ((oldpte & PG_G) || (cpu_class > CPUCLASS_386)) {
- invlpg((vm_offset_t) up + i * PAGE_SIZE);
- } else {
- updateneeded = 1;
- }
- }
-
- vm_page_wakeup(m);
- vm_page_flag_clear(m, PG_ZERO);
- vm_page_flag_set(m, PG_MAPPED | PG_WRITEABLE);
- m->valid = VM_PAGE_BITS_ALL;
- }
- if (updateneeded)
- invltlb();
-}
-
-/*
- * Dispose the UPAGES for a process that has exited.
- * This routine directly impacts the exit perf of a process.
- */
-void
-pmap_dispose_proc(p)
- struct proc *p;
-{
- int i;
- vm_object_t upobj;
- vm_page_t m;
- unsigned *ptek, oldpte;
-
- upobj = p->p_upages_obj;
-
- ptek = (unsigned *) vtopte((vm_offset_t) p->p_addr);
- for(i=0;i<UPAGES;i++) {
-
- if ((m = vm_page_lookup(upobj, i)) == NULL)
- panic("pmap_dispose_proc: upage already missing???");
-
- vm_page_busy(m);
-
- oldpte = *(ptek + i);
- *(ptek + i) = 0;
- if ((oldpte & PG_G) || (cpu_class > CPUCLASS_386))
- invlpg((vm_offset_t) p->p_addr + i * PAGE_SIZE);
- vm_page_unwire(m, 0);
- vm_page_free(m);
- }
-#if defined(I386_CPU)
- if (cpu_class <= CPUCLASS_386)
- invltlb();
-#endif
-}
-
-/*
- * Allow the UPAGES for a process to be prejudicially paged out.
- */
-void
-pmap_swapout_proc(p)
- struct proc *p;
-{
- int i;
- vm_object_t upobj;
- vm_page_t m;
-
- upobj = p->p_upages_obj;
- /*
- * let the upages be paged
- */
- for(i=0;i<UPAGES;i++) {
- if ((m = vm_page_lookup(upobj, i)) == NULL)
- panic("pmap_swapout_proc: upage already missing???");
- vm_page_dirty(m);
- vm_page_unwire(m, 0);
- pmap_kremove( (vm_offset_t) p->p_addr + PAGE_SIZE * i);
- }
-}
-
-/*
- * Bring the UPAGES for a specified process back in.
- */
-void
-pmap_swapin_proc(p)
- struct proc *p;
-{
- int i,rv;
- vm_object_t upobj;
- vm_page_t m;
-
- upobj = p->p_upages_obj;
- for(i=0;i<UPAGES;i++) {
-
- m = vm_page_grab(upobj, i, VM_ALLOC_NORMAL | VM_ALLOC_RETRY);
-
- pmap_kenter(((vm_offset_t) p->p_addr) + i * PAGE_SIZE,
- VM_PAGE_TO_PHYS(m));
-
- if (m->valid != VM_PAGE_BITS_ALL) {
- rv = vm_pager_get_pages(upobj, &m, 1, 0);
-#if !defined(MAX_PERF)
- if (rv != VM_PAGER_OK)
- panic("pmap_swapin_proc: cannot get upages for proc: %d\n", p->p_pid);
-#endif
- m = vm_page_lookup(upobj, i);
- m->valid = VM_PAGE_BITS_ALL;
- }
-
- vm_page_wire(m);
- vm_page_wakeup(m);
- vm_page_flag_set(m, PG_MAPPED | PG_WRITEABLE);
- }
-}
-
-/***************************************************
- * Page table page management routines.....
- ***************************************************/
-
-/*
- * This routine unholds page table pages, and if the hold count
- * drops to zero, then it decrements the wire count.
- */
-static int
-_pmap_unwire_pte_hold(pmap_t pmap, vm_page_t m) {
-
- while (vm_page_sleep_busy(m, FALSE, "pmuwpt"))
- ;
-
- if (m->hold_count == 0) {
- vm_offset_t pteva;
- /*
- * unmap the page table page
- */
- pmap->pm_pdir[m->pindex] = 0;
- --pmap->pm_stats.resident_count;
- if ((((unsigned)pmap->pm_pdir[PTDPTDI]) & PG_FRAME) ==
- (((unsigned) PTDpde) & PG_FRAME)) {
- /*
- * Do a invltlb to make the invalidated mapping
- * take effect immediately.
- */
- pteva = UPT_MIN_ADDRESS + i386_ptob(m->pindex);
- pmap_TLB_invalidate(pmap, pteva);
- }
-
- if (pmap->pm_ptphint == m)
- pmap->pm_ptphint = NULL;
-
- /*
- * If the page is finally unwired, simply free it.
- */
- --m->wire_count;
- if (m->wire_count == 0) {
-
- vm_page_flash(m);
- vm_page_busy(m);
- vm_page_free_zero(m);
- --cnt.v_wire_count;
- }
- return 1;
- }
- return 0;
-}
-
-static PMAP_INLINE int
-pmap_unwire_pte_hold(pmap_t pmap, vm_page_t m) {
- vm_page_unhold(m);
- if (m->hold_count == 0)
- return _pmap_unwire_pte_hold(pmap, m);
- else
- return 0;
-}
-
-/*
- * After removing a page table entry, this routine is used to
- * conditionally free the page, and manage the hold/wire counts.
- */
-static int
-pmap_unuse_pt(pmap, va, mpte)
- pmap_t pmap;
- vm_offset_t va;
- vm_page_t mpte;
-{
- unsigned ptepindex;
- if (va >= UPT_MIN_ADDRESS)
- return 0;
-
- if (mpte == NULL) {
- ptepindex = (va >> PDRSHIFT);
- if (pmap->pm_ptphint &&
- (pmap->pm_ptphint->pindex == ptepindex)) {
- mpte = pmap->pm_ptphint;
- } else {
- mpte = pmap_page_lookup( pmap->pm_pteobj, ptepindex);
- pmap->pm_ptphint = mpte;
- }
- }
-
- return pmap_unwire_pte_hold(pmap, mpte);
-}
-
-void
-pmap_pinit0(pmap)
- struct pmap *pmap;
-{
- pmap->pm_pdir =
- (pd_entry_t *)kmem_alloc_pageable(kernel_map, PAGE_SIZE);
- pmap_kenter((vm_offset_t) pmap->pm_pdir, (vm_offset_t) IdlePTD);
- pmap->pm_count = 1;
- pmap->pm_active = 0;
- pmap->pm_ptphint = NULL;
- TAILQ_INIT(&pmap->pm_pvlist);
- bzero(&pmap->pm_stats, sizeof pmap->pm_stats);
-}
-
-/*
- * Initialize a preallocated and zeroed pmap structure,
- * such as one in a vmspace structure.
- */
-void
-pmap_pinit(pmap)
- register struct pmap *pmap;
-{
- vm_page_t ptdpg;
-
- /*
- * No need to allocate page table space yet but we do need a valid
- * page directory table.
- */
- if (pmap->pm_pdir == NULL)
- pmap->pm_pdir =
- (pd_entry_t *)kmem_alloc_pageable(kernel_map, PAGE_SIZE);
-
- /*
- * allocate object for the ptes
- */
- if (pmap->pm_pteobj == NULL)
- pmap->pm_pteobj = vm_object_allocate( OBJT_DEFAULT, PTDPTDI + 1);
-
- /*
- * allocate the page directory page
- */
- ptdpg = vm_page_grab( pmap->pm_pteobj, PTDPTDI,
- VM_ALLOC_NORMAL | VM_ALLOC_RETRY);
-
- ptdpg->wire_count = 1;
- ++cnt.v_wire_count;
-
-
- vm_page_flag_clear(ptdpg, PG_MAPPED | PG_BUSY); /* not usually mapped*/
- ptdpg->valid = VM_PAGE_BITS_ALL;
-
- pmap_kenter((vm_offset_t) pmap->pm_pdir, VM_PAGE_TO_PHYS(ptdpg));
- if ((ptdpg->flags & PG_ZERO) == 0)
- bzero(pmap->pm_pdir, PAGE_SIZE);
-
-#ifdef SMP
- pmap->pm_pdir[MPPTDI] = PTD[MPPTDI];
-#endif
-
- /* install self-referential address mapping entry */
- *(unsigned *) (pmap->pm_pdir + PTDPTDI) =
- VM_PAGE_TO_PHYS(ptdpg) | PG_V | PG_RW | PG_A | PG_M;
-
- pmap->pm_count = 1;
- pmap->pm_active = 0;
- pmap->pm_ptphint = NULL;
- TAILQ_INIT(&pmap->pm_pvlist);
- bzero(&pmap->pm_stats, sizeof pmap->pm_stats);
-}
-
-/*
- * Wire in kernel global address entries. To avoid a race condition
- * between pmap initialization and pmap_growkernel, this procedure
- * should be called after the vmspace is attached to the process
- * but before this pmap is activated.
- */
-void
-pmap_pinit2(pmap)
- struct pmap *pmap;
-{
- /* XXX copies current process, does not fill in MPPTDI */
- bcopy(PTD + KPTDI, pmap->pm_pdir + KPTDI, nkpt * PTESIZE);
-}
-
-static int
-pmap_release_free_page(pmap, p)
- struct pmap *pmap;
- vm_page_t p;
-{
- unsigned *pde = (unsigned *) pmap->pm_pdir;
- /*
- * This code optimizes the case of freeing non-busy
- * page-table pages. Those pages are zero now, and
- * might as well be placed directly into the zero queue.
- */
- if (vm_page_sleep_busy(p, FALSE, "pmaprl"))
- return 0;
-
- vm_page_busy(p);
-
- /*
- * Remove the page table page from the processes address space.
- */
- pde[p->pindex] = 0;
- pmap->pm_stats.resident_count--;
-
-#if !defined(MAX_PERF)
- if (p->hold_count) {
- panic("pmap_release: freeing held page table page");
- }
-#endif
- /*
- * Page directory pages need to have the kernel
- * stuff cleared, so they can go into the zero queue also.
- */
- if (p->pindex == PTDPTDI) {
- bzero(pde + KPTDI, nkpt * PTESIZE);
-#ifdef SMP
- pde[MPPTDI] = 0;
-#endif
- pde[APTDPTDI] = 0;
- pmap_kremove((vm_offset_t) pmap->pm_pdir);
- }
-
- if (pmap->pm_ptphint && (pmap->pm_ptphint->pindex == p->pindex))
- pmap->pm_ptphint = NULL;
-
- p->wire_count--;
- cnt.v_wire_count--;
- vm_page_free_zero(p);
- return 1;
-}
-
-/*
- * this routine is called if the page table page is not
- * mapped correctly.
- */
-static vm_page_t
-_pmap_allocpte(pmap, ptepindex)
- pmap_t pmap;
- unsigned ptepindex;
-{
- vm_offset_t pteva, ptepa;
- vm_page_t m;
-
- /*
- * Find or fabricate a new pagetable page
- */
- m = vm_page_grab(pmap->pm_pteobj, ptepindex,
- VM_ALLOC_ZERO | VM_ALLOC_RETRY);
-
- KASSERT(m->queue == PQ_NONE,
- ("_pmap_allocpte: %p->queue != PQ_NONE", m));
-
- if (m->wire_count == 0)
- cnt.v_wire_count++;
- m->wire_count++;
-
- /*
- * Increment the hold count for the page table page
- * (denoting a new mapping.)
- */
- m->hold_count++;
-
- /*
- * Map the pagetable page into the process address space, if
- * it isn't already there.
- */
-
- pmap->pm_stats.resident_count++;
-
- ptepa = VM_PAGE_TO_PHYS(m);
- pmap->pm_pdir[ptepindex] =
- (pd_entry_t) (ptepa | PG_U | PG_RW | PG_V | PG_A | PG_M);
-
- /*
- * Set the page table hint
- */
- pmap->pm_ptphint = m;
-
- /*
- * Try to use the new mapping, but if we cannot, then
- * do it with the routine that maps the page explicitly.
- */
- if ((m->flags & PG_ZERO) == 0) {
- if ((((unsigned)pmap->pm_pdir[PTDPTDI]) & PG_FRAME) ==
- (((unsigned) PTDpde) & PG_FRAME)) {
- pteva = UPT_MIN_ADDRESS + i386_ptob(ptepindex);
- bzero((caddr_t) pteva, PAGE_SIZE);
- } else {
- pmap_zero_page(ptepa);
- }
- }
-
- m->valid = VM_PAGE_BITS_ALL;
- vm_page_flag_clear(m, PG_ZERO);
- vm_page_flag_set(m, PG_MAPPED);
- vm_page_wakeup(m);
-
- return m;
-}
-
-static vm_page_t
-pmap_allocpte(pmap, va)
- pmap_t pmap;
- vm_offset_t va;
-{
- unsigned ptepindex;
- vm_offset_t ptepa;
- vm_page_t m;
-
- /*
- * Calculate pagetable page index
- */
- ptepindex = va >> PDRSHIFT;
-
- /*
- * Get the page directory entry
- */
- ptepa = (vm_offset_t) pmap->pm_pdir[ptepindex];
-
- /*
- * This supports switching from a 4MB page to a
- * normal 4K page.
- */
- if (ptepa & PG_PS) {
- pmap->pm_pdir[ptepindex] = 0;
- ptepa = 0;
- invltlb();
- }
-
- /*
- * If the page table page is mapped, we just increment the
- * hold count, and activate it.
- */
- if (ptepa) {
- /*
- * In order to get the page table page, try the
- * hint first.
- */
- if (pmap->pm_ptphint &&
- (pmap->pm_ptphint->pindex == ptepindex)) {
- m = pmap->pm_ptphint;
- } else {
- m = pmap_page_lookup( pmap->pm_pteobj, ptepindex);
- pmap->pm_ptphint = m;
- }
- m->hold_count++;
- return m;
- }
- /*
- * Here if the pte page isn't mapped, or if it has been deallocated.
- */
- return _pmap_allocpte(pmap, ptepindex);
-}
-
-
-/***************************************************
-* Pmap allocation/deallocation routines.
- ***************************************************/
-
-/*
- * Release any resources held by the given physical map.
- * Called when a pmap initialized by pmap_pinit is being released.
- * Should only be called if the map contains no valid mappings.
- */
-void
-pmap_release(pmap)
- register struct pmap *pmap;
-{
- vm_page_t p,n,ptdpg;
- vm_object_t object = pmap->pm_pteobj;
- int curgeneration;
-
-#if defined(DIAGNOSTIC)
- if (object->ref_count != 1)
- panic("pmap_release: pteobj reference count != 1");
-#endif
-
- ptdpg = NULL;
-retry:
- curgeneration = object->generation;
- for (p = TAILQ_FIRST(&object->memq); p != NULL; p = n) {
- n = TAILQ_NEXT(p, listq);
- if (p->pindex == PTDPTDI) {
- ptdpg = p;
- continue;
- }
- while (1) {
- if (!pmap_release_free_page(pmap, p) &&
- (object->generation != curgeneration))
- goto retry;
- }
- }
-
- if (ptdpg && !pmap_release_free_page(pmap, ptdpg))
- goto retry;
-}
-
-/*
- * grow the number of kernel page table entries, if needed
- */
-void
-pmap_growkernel(vm_offset_t addr)
-{
- struct proc *p;
- struct pmap *pmap;
- int s;
- vm_offset_t ptppaddr;
- vm_page_t nkpg;
- pd_entry_t newpdir;
-
- s = splhigh();
- if (kernel_vm_end == 0) {
- kernel_vm_end = KERNBASE;
- nkpt = 0;
- while (pdir_pde(PTD, kernel_vm_end)) {
- kernel_vm_end = (kernel_vm_end + PAGE_SIZE * NPTEPG) & ~(PAGE_SIZE * NPTEPG - 1);
- nkpt++;
- }
- }
- addr = (addr + PAGE_SIZE * NPTEPG) & ~(PAGE_SIZE * NPTEPG - 1);
- while (kernel_vm_end < addr) {
- if (pdir_pde(PTD, kernel_vm_end)) {
- kernel_vm_end = (kernel_vm_end + PAGE_SIZE * NPTEPG) & ~(PAGE_SIZE * NPTEPG - 1);
- continue;
- }
-
- /*
- * This index is bogus, but out of the way
- */
- nkpg = vm_page_alloc(kptobj, nkpt, VM_ALLOC_SYSTEM);
-#if !defined(MAX_PERF)
- if (!nkpg)
- panic("pmap_growkernel: no memory to grow kernel");
-#endif
-
- nkpt++;
-
- vm_page_wire(nkpg);
- ptppaddr = VM_PAGE_TO_PHYS(nkpg);
- pmap_zero_page(ptppaddr);
- newpdir = (pd_entry_t) (ptppaddr | PG_V | PG_RW | PG_A | PG_M);
- pdir_pde(PTD, kernel_vm_end) = newpdir;
-
- LIST_FOREACH(p, &allproc, p_list) {
- if (p->p_vmspace) {
- pmap = vmspace_pmap(p->p_vmspace);
- *pmap_pde(pmap, kernel_vm_end) = newpdir;
- }
- }
- *pmap_pde(kernel_pmap, kernel_vm_end) = newpdir;
- kernel_vm_end = (kernel_vm_end + PAGE_SIZE * NPTEPG) & ~(PAGE_SIZE * NPTEPG - 1);
- }
- splx(s);
-}
-
-/*
- * Retire the given physical map from service.
- * Should only be called if the map contains
- * no valid mappings.
- */
-void
-pmap_destroy(pmap)
- register pmap_t pmap;
-{
- int count;
-
- if (pmap == NULL)
- return;
-
- count = --pmap->pm_count;
- if (count == 0) {
- pmap_release(pmap);
-#if !defined(MAX_PERF)
- panic("destroying a pmap is not yet implemented");
-#endif
- }
-}
-
-/*
- * Add a reference to the specified pmap.
- */
-void
-pmap_reference(pmap)
- pmap_t pmap;
-{
- if (pmap != NULL) {
- pmap->pm_count++;
- }
-}
-
-/***************************************************
-* page management routines.
- ***************************************************/
-
-/*
- * free the pv_entry back to the free list
- */
-static PMAP_INLINE void
-free_pv_entry(pv)
- pv_entry_t pv;
-{
- pv_entry_count--;
- zfreei(pvzone, pv);
-}
-
-/*
- * get a new pv_entry, allocating a block from the system
- * when needed.
- * the memory allocation is performed bypassing the malloc code
- * because of the possibility of allocations at interrupt time.
- */
-static pv_entry_t
-get_pv_entry(void)
-{
- pv_entry_count++;
- if (pv_entry_high_water &&
- (pv_entry_count > pv_entry_high_water) &&
- (pmap_pagedaemon_waken == 0)) {
- pmap_pagedaemon_waken = 1;
- wakeup (&vm_pages_needed);
- }
- return zalloci(pvzone);
-}
-
-/*
- * This routine is very drastic, but can save the system
- * in a pinch.
- */
-void
-pmap_collect() {
- pv_table_t *ppv;
- int i;
- vm_offset_t pa;
- vm_page_t m;
- static int warningdone=0;
-
- if (pmap_pagedaemon_waken == 0)
- return;
-
- if (warningdone < 5) {
- printf("pmap_collect: collecting pv entries -- suggest increasing PMAP_SHPGPERPROC\n");
- warningdone++;
- }
-
- for(i = 0; i < pv_npg; i++) {
- if ((ppv = &pv_table[i]) == 0)
- continue;
- m = ppv->pv_vm_page;
- if ((pa = VM_PAGE_TO_PHYS(m)) == 0)
- continue;
- if (m->wire_count || m->hold_count || m->busy ||
- (m->flags & PG_BUSY))
- continue;
- pmap_remove_all(pa);
- }
- pmap_pagedaemon_waken = 0;
-}
-
-
-/*
- * If it is the first entry on the list, it is actually
- * in the header and we must copy the following entry up
- * to the header. Otherwise we must search the list for
- * the entry. In either case we free the now unused entry.
- */
-
-static int
-pmap_remove_entry(pmap, ppv, va)
- struct pmap *pmap;
- pv_table_t *ppv;
- vm_offset_t va;
-{
- pv_entry_t pv;
- int rtval;
- int s;
-
- s = splvm();
- if (ppv->pv_list_count < pmap->pm_stats.resident_count) {
- for (pv = TAILQ_FIRST(&ppv->pv_list);
- pv;
- pv = TAILQ_NEXT(pv, pv_list)) {
- if (pmap == pv->pv_pmap && va == pv->pv_va)
- break;
- }
- } else {
- for (pv = TAILQ_FIRST(&pmap->pm_pvlist);
- pv;
- pv = TAILQ_NEXT(pv, pv_plist)) {
- if (va == pv->pv_va)
- break;
- }
- }
-
- rtval = 0;
- if (pv) {
-
- rtval = pmap_unuse_pt(pmap, va, pv->pv_ptem);
- TAILQ_REMOVE(&ppv->pv_list, pv, pv_list);
- ppv->pv_list_count--;
- if (TAILQ_FIRST(&ppv->pv_list) == NULL)
- vm_page_flag_clear(ppv->pv_vm_page, PG_MAPPED | PG_WRITEABLE);
-
- TAILQ_REMOVE(&pmap->pm_pvlist, pv, pv_plist);
- free_pv_entry(pv);
- }
-
- splx(s);
- return rtval;
-}
-
-/*
- * Create a pv entry for page at pa for
- * (pmap, va).
- */
-static void
-pmap_insert_entry(pmap, va, mpte, pa)
- pmap_t pmap;
- vm_offset_t va;
- vm_page_t mpte;
- vm_offset_t pa;
-{
-
- int s;
- pv_entry_t pv;
- pv_table_t *ppv;
-
- s = splvm();
- pv = get_pv_entry();
- pv->pv_va = va;
- pv->pv_pmap = pmap;
- pv->pv_ptem = mpte;
-
- TAILQ_INSERT_TAIL(&pmap->pm_pvlist, pv, pv_plist);
-
- ppv = pa_to_pvh(pa);
- TAILQ_INSERT_TAIL(&ppv->pv_list, pv, pv_list);
- ppv->pv_list_count++;
-
- splx(s);
-}
-
-/*
- * pmap_remove_pte: do the things to unmap a page in a process
- */
-static int
-pmap_remove_pte(pmap, ptq, va)
- struct pmap *pmap;
- unsigned *ptq;
- vm_offset_t va;
-{
- unsigned oldpte;
- pv_table_t *ppv;
-
- oldpte = loadandclear(ptq);
- if (oldpte & PG_W)
- pmap->pm_stats.wired_count -= 1;
- /*
- * Machines that don't support invlpg, also don't support
- * PG_G.
- */
- if (oldpte & PG_G)
- invlpg(va);
- pmap->pm_stats.resident_count -= 1;
- if (oldpte & PG_MANAGED) {
- ppv = pa_to_pvh(oldpte);
- if (oldpte & PG_M) {
-#if defined(PMAP_DIAGNOSTIC)
- if (pmap_nw_modified((pt_entry_t) oldpte)) {
- printf(
- "pmap_remove: modified page not writable: va: 0x%x, pte: 0x%x\n",
- va, oldpte);
- }
-#endif
- if (pmap_track_modified(va))
- vm_page_dirty(ppv->pv_vm_page);
- }
- if (oldpte & PG_A)
- vm_page_flag_set(ppv->pv_vm_page, PG_REFERENCED);
- return pmap_remove_entry(pmap, ppv, va);
- } else {
- return pmap_unuse_pt(pmap, va, NULL);
- }
-
- return 0;
-}
-
-/*
- * Remove a single page from a process address space
- */
-static void
-pmap_remove_page(pmap, va)
- struct pmap *pmap;
- register vm_offset_t va;
-{
- register unsigned *ptq;
-
- /*
- * if there is no pte for this address, just skip it!!!
- */
- if (*pmap_pde(pmap, va) == 0) {
- return;
- }
-
- /*
- * get a local va for mappings for this pmap.
- */
- ptq = get_ptbase(pmap) + i386_btop(va);
- if (*ptq) {
- (void) pmap_remove_pte(pmap, ptq, va);
- pmap_TLB_invalidate(pmap, va);
- }
- return;
-}
-
-/*
- * Remove the given range of addresses from the specified map.
- *
- * It is assumed that the start and end are properly
- * rounded to the page size.
- */
-void
-pmap_remove(pmap, sva, eva)
- struct pmap *pmap;
- register vm_offset_t sva;
- register vm_offset_t eva;
-{
- register unsigned *ptbase;
- vm_offset_t pdnxt;
- vm_offset_t ptpaddr;
- vm_offset_t sindex, eindex;
- int anyvalid;
-
- if (pmap == NULL)
- return;
-
- if (pmap->pm_stats.resident_count == 0)
- return;
-
- /*
- * special handling of removing one page. a very
- * common operation and easy to short circuit some
- * code.
- */
- if (((sva + PAGE_SIZE) == eva) &&
- (((unsigned) pmap->pm_pdir[(sva >> PDRSHIFT)] & PG_PS) == 0)) {
- pmap_remove_page(pmap, sva);
- return;
- }
-
- anyvalid = 0;
-
- /*
- * Get a local virtual address for the mappings that are being
- * worked with.
- */
- ptbase = get_ptbase(pmap);
-
- sindex = i386_btop(sva);
- eindex = i386_btop(eva);
-
- for (; sindex < eindex; sindex = pdnxt) {
- unsigned pdirindex;
-
- /*
- * Calculate index for next page table.
- */
- pdnxt = ((sindex + NPTEPG) & ~(NPTEPG - 1));
- if (pmap->pm_stats.resident_count == 0)
- break;
-
- pdirindex = sindex / NPDEPG;
- if (((ptpaddr = (unsigned) pmap->pm_pdir[pdirindex]) & PG_PS) != 0) {
- pmap->pm_pdir[pdirindex] = 0;
- pmap->pm_stats.resident_count -= NBPDR / PAGE_SIZE;
- anyvalid++;
- continue;
- }
-
- /*
- * Weed out invalid mappings. Note: we assume that the page
- * directory table is always allocated, and in kernel virtual.
- */
- if (ptpaddr == 0)
- continue;
-
- /*
- * Limit our scan to either the end of the va represented
- * by the current page table page, or to the end of the
- * range being removed.
- */
- if (pdnxt > eindex) {
- pdnxt = eindex;
- }
-
- for ( ;sindex != pdnxt; sindex++) {
- vm_offset_t va;
- if (ptbase[sindex] == 0) {
- continue;
- }
- va = i386_ptob(sindex);
-
- anyvalid++;
- if (pmap_remove_pte(pmap,
- ptbase + sindex, va))
- break;
- }
- }
-
- if (anyvalid)
- pmap_TLB_invalidate_all(pmap);
-}
-
-/*
- * Routine: pmap_remove_all
- * Function:
- * Removes this physical page from
- * all physical maps in which it resides.
- * Reflects back modify bits to the pager.
- *
- * Notes:
- * Original versions of this routine were very
- * inefficient because they iteratively called
- * pmap_remove (slow...)
- */
-
-static void
-pmap_remove_all(pa)
- vm_offset_t pa;
-{
- register pv_entry_t pv;
- pv_table_t *ppv;
- register unsigned *pte, tpte;
- int s;
-
-#if defined(PMAP_DIAGNOSTIC)
- /*
- * XXX this makes pmap_page_protect(NONE) illegal for non-managed
- * pages!
- */
- if (!pmap_is_managed(pa)) {
- panic("pmap_page_protect: illegal for unmanaged page, va: 0x%x", pa);
- }
-#endif
-
- s = splvm();
- ppv = pa_to_pvh(pa);
- while ((pv = TAILQ_FIRST(&ppv->pv_list)) != NULL) {
- pv->pv_pmap->pm_stats.resident_count--;
-
- pte = pmap_pte_quick(pv->pv_pmap, pv->pv_va);
-
- tpte = loadandclear(pte);
- if (tpte & PG_W)
- pv->pv_pmap->pm_stats.wired_count--;
-
- if (tpte & PG_A)
- vm_page_flag_set(ppv->pv_vm_page, PG_REFERENCED);
-
- /*
- * Update the vm_page_t clean and reference bits.
- */
- if (tpte & PG_M) {
-#if defined(PMAP_DIAGNOSTIC)
- if (pmap_nw_modified((pt_entry_t) tpte)) {
- printf(
- "pmap_remove_all: modified page not writable: va: 0x%x, pte: 0x%x\n",
- pv->pv_va, tpte);
- }
-#endif
- if (pmap_track_modified(pv->pv_va))
- vm_page_dirty(ppv->pv_vm_page);
- }
- pmap_TLB_invalidate(pv->pv_pmap, pv->pv_va);
-
- TAILQ_REMOVE(&pv->pv_pmap->pm_pvlist, pv, pv_plist);
- TAILQ_REMOVE(&ppv->pv_list, pv, pv_list);
- ppv->pv_list_count--;
- pmap_unuse_pt(pv->pv_pmap, pv->pv_va, pv->pv_ptem);
- free_pv_entry(pv);
- }
-
- vm_page_flag_clear(ppv->pv_vm_page, PG_MAPPED | PG_WRITEABLE);
-
- splx(s);
-}
-
-/*
- * Set the physical protection on the
- * specified range of this map as requested.
- */
-void
-pmap_protect(pmap_t pmap, vm_offset_t sva, vm_offset_t eva, vm_prot_t prot)
-{
- register unsigned *ptbase;
- vm_offset_t pdnxt, ptpaddr;
- vm_pindex_t sindex, eindex;
- int anychanged;
-
-
- if (pmap == NULL)
- return;
-
- if ((prot & VM_PROT_READ) == VM_PROT_NONE) {
- pmap_remove(pmap, sva, eva);
- return;
- }
-
- if (prot & VM_PROT_WRITE)
- return;
-
- anychanged = 0;
-
- ptbase = get_ptbase(pmap);
-
- sindex = i386_btop(sva);
- eindex = i386_btop(eva);
-
- for (; sindex < eindex; sindex = pdnxt) {
-
- unsigned pdirindex;
-
- pdnxt = ((sindex + NPTEPG) & ~(NPTEPG - 1));
-
- pdirindex = sindex / NPDEPG;
- if (((ptpaddr = (unsigned) pmap->pm_pdir[pdirindex]) & PG_PS) != 0) {
- (unsigned) pmap->pm_pdir[pdirindex] &= ~(PG_M|PG_RW);
- pmap->pm_stats.resident_count -= NBPDR / PAGE_SIZE;
- anychanged++;
- continue;
- }
-
- /*
- * Weed out invalid mappings. Note: we assume that the page
- * directory table is always allocated, and in kernel virtual.
- */
- if (ptpaddr == 0)
- continue;
-
- if (pdnxt > eindex) {
- pdnxt = eindex;
- }
-
- for (; sindex != pdnxt; sindex++) {
-
- unsigned pbits;
- pv_table_t *ppv;
-
- pbits = ptbase[sindex];
-
- if (pbits & PG_MANAGED) {
- ppv = NULL;
- if (pbits & PG_A) {
- ppv = pa_to_pvh(pbits);
- vm_page_flag_set(ppv->pv_vm_page, PG_REFERENCED);
- pbits &= ~PG_A;
- }
- if (pbits & PG_M) {
- if (pmap_track_modified(i386_ptob(sindex))) {
- if (ppv == NULL)
- ppv = pa_to_pvh(pbits);
- vm_page_dirty(ppv->pv_vm_page);
- pbits &= ~PG_M;
- }
- }
- }
-
- pbits &= ~PG_RW;
-
- if (pbits != ptbase[sindex]) {
- ptbase[sindex] = pbits;
- anychanged = 1;
- }
- }
- }
- if (anychanged)
- pmap_TLB_invalidate_all(pmap);
-}
-
-/*
- * Insert the given physical page (p) at
- * the specified virtual address (v) in the
- * target physical map with the protection requested.
- *
- * If specified, the page will be wired down, meaning
- * that the related pte can not be reclaimed.
- *
- * NB: This is the only routine which MAY NOT lazy-evaluate
- * or lose information. That is, this routine must actually
- * insert this page into the given map NOW.
- */
-void
-pmap_enter(pmap_t pmap, vm_offset_t va, vm_offset_t pa, vm_prot_t prot,
- boolean_t wired)
-{
- register unsigned *pte;
- vm_offset_t opa;
- vm_offset_t origpte, newpte;
- vm_page_t mpte;
-
- if (pmap == NULL)
- return;
-
- va &= PG_FRAME;
-#ifdef PMAP_DIAGNOSTIC
- if (va > VM_MAX_KERNEL_ADDRESS)
- panic("pmap_enter: toobig");
- if ((va >= UPT_MIN_ADDRESS) && (va < UPT_MAX_ADDRESS))
- panic("pmap_enter: invalid to pmap_enter page table pages (va: 0x%x)", va);
-#endif
-
- mpte = NULL;
- /*
- * In the case that a page table page is not
- * resident, we are creating it here.
- */
- if (va < UPT_MIN_ADDRESS) {
- mpte = pmap_allocpte(pmap, va);
- }
-#if 0 && defined(PMAP_DIAGNOSTIC)
- else {
- vm_offset_t *pdeaddr = (vm_offset_t *)pmap_pde(pmap, va);
- if (((origpte = (vm_offset_t) *pdeaddr) & PG_V) == 0) {
- panic("pmap_enter: invalid kernel page table page(0), pdir=%p, pde=%p, va=%p\n",
- pmap->pm_pdir[PTDPTDI], origpte, va);
- }
- if (smp_active) {
- pdeaddr = (vm_offset_t *) IdlePTDS[cpuid];
- if (((newpte = pdeaddr[va >> PDRSHIFT]) & PG_V) == 0) {
- if ((vm_offset_t) my_idlePTD != (vm_offset_t) vtophys(pdeaddr))
- printf("pde mismatch: %x, %x\n", my_idlePTD, pdeaddr);
- printf("cpuid: %d, pdeaddr: 0x%x\n", cpuid, pdeaddr);
- panic("pmap_enter: invalid kernel page table page(1), pdir=%p, npde=%p, pde=%p, va=%p\n",
- pmap->pm_pdir[PTDPTDI], newpte, origpte, va);
- }
- }
- }
-#endif
-
- pte = pmap_pte(pmap, va);
-
-#if !defined(MAX_PERF)
- /*
- * Page Directory table entry not valid, we need a new PT page
- */
- if (pte == NULL) {
- panic("pmap_enter: invalid page directory, pdir=%p, va=0x%x\n",
- (void *)pmap->pm_pdir[PTDPTDI], va);
- }
-#endif
-
- origpte = *(vm_offset_t *)pte;
- pa &= PG_FRAME;
- opa = origpte & PG_FRAME;
-
-#if !defined(MAX_PERF)
- if (origpte & PG_PS)
- panic("pmap_enter: attempted pmap_enter on 4MB page");
-#endif
-
- /*
- * Mapping has not changed, must be protection or wiring change.
- */
- if (origpte && (opa == pa)) {
- /*
- * Wiring change, just update stats. We don't worry about
- * wiring PT pages as they remain resident as long as there
- * are valid mappings in them. Hence, if a user page is wired,
- * the PT page will be also.
- */
- if (wired && ((origpte & PG_W) == 0))
- pmap->pm_stats.wired_count++;
- else if (!wired && (origpte & PG_W))
- pmap->pm_stats.wired_count--;
-
-#if defined(PMAP_DIAGNOSTIC)
- if (pmap_nw_modified((pt_entry_t) origpte)) {
- printf(
- "pmap_enter: modified page not writable: va: 0x%x, pte: 0x%x\n",
- va, origpte);
- }
-#endif
-
- /*
- * Remove extra pte reference
- */
- if (mpte)
- mpte->hold_count--;
-
- if ((prot & VM_PROT_WRITE) && (origpte & PG_V)) {
- if ((origpte & PG_RW) == 0) {
- *pte |= PG_RW;
-#ifdef SMP
- cpu_invlpg((void *)va);
- if (pmap->pm_active & other_cpus)
- smp_invltlb();
-#else
- invltlb_1pg(va);
-#endif
- }
- return;
- }
-
- /*
- * We might be turning off write access to the page,
- * so we go ahead and sense modify status.
- */
- if (origpte & PG_MANAGED) {
- if ((origpte & PG_M) && pmap_track_modified(va)) {
- pv_table_t *ppv;
- ppv = pa_to_pvh(opa);
- vm_page_dirty(ppv->pv_vm_page);
- }
- pa |= PG_MANAGED;
- }
- goto validate;
- }
- /*
- * Mapping has changed, invalidate old range and fall through to
- * handle validating new mapping.
- */
- if (opa) {
- int err;
- err = pmap_remove_pte(pmap, pte, va);
-#if !defined(MAX_PERF)
- if (err)
- panic("pmap_enter: pte vanished, va: 0x%x", va);
-#endif
- }
-
- /*
- * Enter on the PV list if part of our managed memory Note that we
- * raise IPL while manipulating pv_table since pmap_enter can be
- * called at interrupt time.
- */
- if (pmap_is_managed(pa)) {
- pmap_insert_entry(pmap, va, mpte, pa);
- pa |= PG_MANAGED;
- }
-
- /*
- * Increment counters
- */
- pmap->pm_stats.resident_count++;
- if (wired)
- pmap->pm_stats.wired_count++;
-
-validate:
- /*
- * Now validate mapping with desired protection/wiring.
- */
- newpte = (vm_offset_t) (pa | pte_prot(pmap, prot) | PG_V);
-
- if (wired)
- newpte |= PG_W;
- if (va < UPT_MIN_ADDRESS)
- newpte |= PG_U;
- if (pmap == kernel_pmap)
- newpte |= pgeflag;
-
- /*
- * if the mapping or permission bits are different, we need
- * to update the pte.
- */
- if ((origpte & ~(PG_M|PG_A)) != newpte) {
- *pte = newpte | PG_A;
- if (origpte) {
-#ifdef SMP
- cpu_invlpg((void *)va);
- if (pmap->pm_active & other_cpus)
- smp_invltlb();
-#else
- invltlb_1pg(va);
-#endif
- }
- }
-}
-
-/*
- * this code makes some *MAJOR* assumptions:
- * 1. Current pmap & pmap exists.
- * 2. Not wired.
- * 3. Read access.
- * 4. No page table pages.
- * 5. Tlbflush is deferred to calling procedure.
- * 6. Page IS managed.
- * but is *MUCH* faster than pmap_enter...
- */
-
-static vm_page_t
-pmap_enter_quick(pmap, va, pa, mpte)
- register pmap_t pmap;
- vm_offset_t va;
- register vm_offset_t pa;
- vm_page_t mpte;
-{
- register unsigned *pte;
-
- /*
- * In the case that a page table page is not
- * resident, we are creating it here.
- */
- if (va < UPT_MIN_ADDRESS) {
- unsigned ptepindex;
- vm_offset_t ptepa;
-
- /*
- * Calculate pagetable page index
- */
- ptepindex = va >> PDRSHIFT;
- if (mpte && (mpte->pindex == ptepindex)) {
- mpte->hold_count++;
- } else {
-retry:
- /*
- * Get the page directory entry
- */
- ptepa = (vm_offset_t) pmap->pm_pdir[ptepindex];
-
- /*
- * If the page table page is mapped, we just increment
- * the hold count, and activate it.
- */
- if (ptepa) {
-#if !defined(MAX_PERF)
- if (ptepa & PG_PS)
- panic("pmap_enter_quick: unexpected mapping into 4MB page");
-#endif
- if (pmap->pm_ptphint &&
- (pmap->pm_ptphint->pindex == ptepindex)) {
- mpte = pmap->pm_ptphint;
- } else {
- mpte = pmap_page_lookup( pmap->pm_pteobj, ptepindex);
- pmap->pm_ptphint = mpte;
- }
- if (mpte == NULL)
- goto retry;
- mpte->hold_count++;
- } else {
- mpte = _pmap_allocpte(pmap, ptepindex);
- }
- }
- } else {
- mpte = NULL;
- }
-
- /*
- * This call to vtopte makes the assumption that we are
- * entering the page into the current pmap. In order to support
- * quick entry into any pmap, one would likely use pmap_pte_quick.
- * But that isn't as quick as vtopte.
- */
- pte = (unsigned *)vtopte(va);
- if (*pte) {
- if (mpte)
- pmap_unwire_pte_hold(pmap, mpte);
- return 0;
- }
-
- /*
- * Enter on the PV list if part of our managed memory Note that we
- * raise IPL while manipulating pv_table since pmap_enter can be
- * called at interrupt time.
- */
- pmap_insert_entry(pmap, va, mpte, pa);
-
- /*
- * Increment counters
- */
- pmap->pm_stats.resident_count++;
-
- /*
- * Now validate mapping with RO protection
- */
- *pte = pa | PG_V | PG_U | PG_MANAGED;
-
- return mpte;
-}
-
-#define MAX_INIT_PT (96)
-/*
- * pmap_object_init_pt preloads the ptes for a given object
- * into the specified pmap. This eliminates the blast of soft
- * faults on process startup and immediately after an mmap.
- */
-void
-pmap_object_init_pt(pmap, addr, object, pindex, size, limit)
- pmap_t pmap;
- vm_offset_t addr;
- vm_object_t object;
- vm_pindex_t pindex;
- vm_size_t size;
- int limit;
-{
- vm_offset_t tmpidx;
- int psize;
- vm_page_t p, mpte;
- int objpgs;
-
- if (pmap == NULL || object == NULL)
- return;
-
- /*
- * This code maps large physical mmap regions into the
- * processor address space. Note that some shortcuts
- * are taken, but the code works.
- */
- if (pseflag &&
- (object->type == OBJT_DEVICE) &&
- ((addr & (NBPDR - 1)) == 0) &&
- ((size & (NBPDR - 1)) == 0) ) {
- int i;
- vm_page_t m[1];
- unsigned int ptepindex;
- int npdes;
- vm_offset_t ptepa;
-
- if (pmap->pm_pdir[ptepindex = (addr >> PDRSHIFT)])
- return;
-
-retry:
- p = vm_page_lookup(object, pindex);
- if (p && vm_page_sleep_busy(p, FALSE, "init4p"))
- goto retry;
-
- if (p == NULL) {
- p = vm_page_alloc(object, pindex, VM_ALLOC_NORMAL);
- if (p == NULL)
- return;
- m[0] = p;
-
- if (vm_pager_get_pages(object, m, 1, 0) != VM_PAGER_OK) {
- vm_page_free(p);
- return;
- }
-
- p = vm_page_lookup(object, pindex);
- vm_page_wakeup(p);
- }
-
- ptepa = (vm_offset_t) VM_PAGE_TO_PHYS(p);
- if (ptepa & (NBPDR - 1)) {
- return;
- }
-
- p->valid = VM_PAGE_BITS_ALL;
-
- pmap->pm_stats.resident_count += size >> PAGE_SHIFT;
- npdes = size >> PDRSHIFT;
- for(i=0;i<npdes;i++) {
- pmap->pm_pdir[ptepindex] =
- (pd_entry_t) (ptepa | PG_U | PG_RW | PG_V | PG_PS);
- ptepa += NBPDR;
- ptepindex += 1;
- }
- vm_page_flag_set(p, PG_MAPPED);
- invltlb();
- return;
- }
-
- psize = i386_btop(size);
-
- if ((object->type != OBJT_VNODE) ||
- (limit && (psize > MAX_INIT_PT) &&
- (object->resident_page_count > MAX_INIT_PT))) {
- return;
- }
-
- if (psize + pindex > object->size)
- psize = object->size - pindex;
-
- mpte = NULL;
- /*
- * if we are processing a major portion of the object, then scan the
- * entire thing.
- */
- if (psize > (object->resident_page_count >> 2)) {
- objpgs = psize;
-
- for (p = TAILQ_FIRST(&object->memq);
- ((objpgs > 0) && (p != NULL));
- p = TAILQ_NEXT(p, listq)) {
-
- tmpidx = p->pindex;
- if (tmpidx < pindex) {
- continue;
- }
- tmpidx -= pindex;
- if (tmpidx >= psize) {
- continue;
- }
- if (((p->valid & VM_PAGE_BITS_ALL) == VM_PAGE_BITS_ALL) &&
- (p->busy == 0) &&
- (p->flags & (PG_BUSY | PG_FICTITIOUS)) == 0) {
- if ((p->queue - p->pc) == PQ_CACHE)
- vm_page_deactivate(p);
- vm_page_busy(p);
- mpte = pmap_enter_quick(pmap,
- addr + i386_ptob(tmpidx),
- VM_PAGE_TO_PHYS(p), mpte);
- vm_page_flag_set(p, PG_MAPPED);
- vm_page_wakeup(p);
- }
- objpgs -= 1;
- }
- } else {
- /*
- * else lookup the pages one-by-one.
- */
- for (tmpidx = 0; tmpidx < psize; tmpidx += 1) {
- p = vm_page_lookup(object, tmpidx + pindex);
- if (p &&
- ((p->valid & VM_PAGE_BITS_ALL) == VM_PAGE_BITS_ALL) &&
- (p->busy == 0) &&
- (p->flags & (PG_BUSY | PG_FICTITIOUS)) == 0) {
- if ((p->queue - p->pc) == PQ_CACHE)
- vm_page_deactivate(p);
- vm_page_busy(p);
- mpte = pmap_enter_quick(pmap,
- addr + i386_ptob(tmpidx),
- VM_PAGE_TO_PHYS(p), mpte);
- vm_page_flag_set(p, PG_MAPPED);
- vm_page_wakeup(p);
- }
- }
- }
- return;
-}
-
-/*
- * pmap_prefault provides a quick way of clustering
- * pagefaults into a processes address space. It is a "cousin"
- * of pmap_object_init_pt, except it runs at page fault time instead
- * of mmap time.
- */
-#define PFBAK 4
-#define PFFOR 4
-#define PAGEORDER_SIZE (PFBAK+PFFOR)
-
-static int pmap_prefault_pageorder[] = {
- -PAGE_SIZE, PAGE_SIZE,
- -2 * PAGE_SIZE, 2 * PAGE_SIZE,
- -3 * PAGE_SIZE, 3 * PAGE_SIZE
- -4 * PAGE_SIZE, 4 * PAGE_SIZE
-};
-
-void
-pmap_prefault(pmap, addra, entry)
- pmap_t pmap;
- vm_offset_t addra;
- vm_map_entry_t entry;
-{
- int i;
- vm_offset_t starta;
- vm_offset_t addr;
- vm_pindex_t pindex;
- vm_page_t m, mpte;
- vm_object_t object;
-
- if (!curproc || (pmap != vmspace_pmap(curproc->p_vmspace)))
- return;
-
- object = entry->object.vm_object;
-
- starta = addra - PFBAK * PAGE_SIZE;
- if (starta < entry->start) {
- starta = entry->start;
- } else if (starta > addra) {
- starta = 0;
- }
-
- mpte = NULL;
- for (i = 0; i < PAGEORDER_SIZE; i++) {
- vm_object_t lobject;
- unsigned *pte;
-
- addr = addra + pmap_prefault_pageorder[i];
- if (addr > addra + (PFFOR * PAGE_SIZE))
- addr = 0;
-
- if (addr < starta || addr >= entry->end)
- continue;
-
- if ((*pmap_pde(pmap, addr)) == NULL)
- continue;
-
- pte = (unsigned *) vtopte(addr);
- if (*pte)
- continue;
-
- pindex = ((addr - entry->start) + entry->offset) >> PAGE_SHIFT;
- lobject = object;
- for (m = vm_page_lookup(lobject, pindex);
- (!m && (lobject->type == OBJT_DEFAULT) && (lobject->backing_object));
- lobject = lobject->backing_object) {
- if (lobject->backing_object_offset & PAGE_MASK)
- break;
- pindex += (lobject->backing_object_offset >> PAGE_SHIFT);
- m = vm_page_lookup(lobject->backing_object, pindex);
- }
-
- /*
- * give-up when a page is not in memory
- */
- if (m == NULL)
- break;
-
- if (((m->valid & VM_PAGE_BITS_ALL) == VM_PAGE_BITS_ALL) &&
- (m->busy == 0) &&
- (m->flags & (PG_BUSY | PG_FICTITIOUS)) == 0) {
-
- if ((m->queue - m->pc) == PQ_CACHE) {
- vm_page_deactivate(m);
- }
- vm_page_busy(m);
- mpte = pmap_enter_quick(pmap, addr,
- VM_PAGE_TO_PHYS(m), mpte);
- vm_page_flag_set(m, PG_MAPPED);
- vm_page_wakeup(m);
- }
- }
-}
-
-/*
- * Routine: pmap_change_wiring
- * Function: Change the wiring attribute for a map/virtual-address
- * pair.
- * In/out conditions:
- * The mapping must already exist in the pmap.
- */
-void
-pmap_change_wiring(pmap, va, wired)
- register pmap_t pmap;
- vm_offset_t va;
- boolean_t wired;
-{
- register unsigned *pte;
-
- if (pmap == NULL)
- return;
-
- pte = pmap_pte(pmap, va);
-
- if (wired && !pmap_pte_w(pte))
- pmap->pm_stats.wired_count++;
- else if (!wired && pmap_pte_w(pte))
- pmap->pm_stats.wired_count--;
-
- /*
- * Wiring is not a hardware characteristic so there is no need to
- * invalidate TLB.
- */
- pmap_pte_set_w(pte, wired);
-}
-
-
-
-/*
- * Copy the range specified by src_addr/len
- * from the source map to the range dst_addr/len
- * in the destination map.
- *
- * This routine is only advisory and need not do anything.
- */
-
-void
-pmap_copy(dst_pmap, src_pmap, dst_addr, len, src_addr)
- pmap_t dst_pmap, src_pmap;
- vm_offset_t dst_addr;
- vm_size_t len;
- vm_offset_t src_addr;
-{
- vm_offset_t addr;
- vm_offset_t end_addr = src_addr + len;
- vm_offset_t pdnxt;
- unsigned src_frame, dst_frame;
-
- if (dst_addr != src_addr)
- return;
-
- src_frame = ((unsigned) src_pmap->pm_pdir[PTDPTDI]) & PG_FRAME;
- if (src_frame != (((unsigned) PTDpde) & PG_FRAME)) {
- return;
- }
-
- dst_frame = ((unsigned) dst_pmap->pm_pdir[PTDPTDI]) & PG_FRAME;
- if (dst_frame != (((unsigned) APTDpde) & PG_FRAME)) {
- APTDpde = (pd_entry_t) (dst_frame | PG_RW | PG_V);
-#if defined(SMP)
- /* The page directory is not shared between CPUs */
- cpu_invltlb();
-#else
- invltlb();
-#endif
- }
-
- for(addr = src_addr; addr < end_addr; addr = pdnxt) {
- unsigned *src_pte, *dst_pte;
- vm_page_t dstmpte, srcmpte;
- vm_offset_t srcptepaddr;
- unsigned ptepindex;
-
-#if !defined(MAX_PERF)
- if (addr >= UPT_MIN_ADDRESS)
- panic("pmap_copy: invalid to pmap_copy page tables\n");
-#endif
-
- /*
- * Don't let optional prefaulting of pages make us go
- * way below the low water mark of free pages or way
- * above high water mark of used pv entries.
- */
- if (cnt.v_free_count < cnt.v_free_reserved ||
- pv_entry_count > pv_entry_high_water)
- break;
-
- pdnxt = ((addr + PAGE_SIZE*NPTEPG) & ~(PAGE_SIZE*NPTEPG - 1));
- ptepindex = addr >> PDRSHIFT;
-
- srcptepaddr = (vm_offset_t) src_pmap->pm_pdir[ptepindex];
- if (srcptepaddr == 0)
- continue;
-
- if (srcptepaddr & PG_PS) {
- if (dst_pmap->pm_pdir[ptepindex] == 0) {
- dst_pmap->pm_pdir[ptepindex] = (pd_entry_t) srcptepaddr;
- dst_pmap->pm_stats.resident_count += NBPDR / PAGE_SIZE;
- }
- continue;
- }
-
- srcmpte = vm_page_lookup(src_pmap->pm_pteobj, ptepindex);
- if ((srcmpte == NULL) ||
- (srcmpte->hold_count == 0) || (srcmpte->flags & PG_BUSY))
- continue;
-
- if (pdnxt > end_addr)
- pdnxt = end_addr;
-
- src_pte = (unsigned *) vtopte(addr);
- dst_pte = (unsigned *) avtopte(addr);
- while (addr < pdnxt) {
- unsigned ptetemp;
- ptetemp = *src_pte;
- /*
- * we only virtual copy managed pages
- */
- if ((ptetemp & PG_MANAGED) != 0) {
- /*
- * We have to check after allocpte for the
- * pte still being around... allocpte can
- * block.
- */
- dstmpte = pmap_allocpte(dst_pmap, addr);
- if ((*dst_pte == 0) && (ptetemp = *src_pte)) {
- /*
- * Clear the modified and
- * accessed (referenced) bits
- * during the copy.
- */
- *dst_pte = ptetemp & ~(PG_M | PG_A);
- dst_pmap->pm_stats.resident_count++;
- pmap_insert_entry(dst_pmap, addr,
- dstmpte,
- (ptetemp & PG_FRAME));
- } else {
- pmap_unwire_pte_hold(dst_pmap, dstmpte);
- }
- if (dstmpte->hold_count >= srcmpte->hold_count)
- break;
- }
- addr += PAGE_SIZE;
- src_pte++;
- dst_pte++;
- }
- }
-}
-
-/*
- * Routine: pmap_kernel
- * Function:
- * Returns the physical map handle for the kernel.
- */
-pmap_t
-pmap_kernel()
-{
- return (kernel_pmap);
-}
-
-/*
- * pmap_zero_page zeros the specified hardware page by mapping
- * the page into KVM and using bzero to clear its contents.
- */
-void
-pmap_zero_page(phys)
- vm_offset_t phys;
-{
-#ifdef SMP
-#if !defined(MAX_PERF)
- if (*(int *) prv_CMAP3)
- panic("pmap_zero_page: prv_CMAP3 busy");
-#endif
-
- *(int *) prv_CMAP3 = PG_V | PG_RW | (phys & PG_FRAME) | PG_A | PG_M;
- cpu_invlpg(prv_CADDR3);
-
-#if defined(I686_CPU)
- if (cpu_class == CPUCLASS_686)
- i686_pagezero(prv_CADDR3);
- else
-#endif
- bzero(prv_CADDR3, PAGE_SIZE);
-
- *(int *) prv_CMAP3 = 0;
-#else
-#if !defined(MAX_PERF)
- if (*(int *) CMAP2)
- panic("pmap_zero_page: CMAP2 busy");
-#endif
-
- *(int *) CMAP2 = PG_V | PG_RW | (phys & PG_FRAME) | PG_A | PG_M;
- invltlb_1pg((vm_offset_t)CADDR2);
-
-#if defined(I686_CPU)
- if (cpu_class == CPUCLASS_686)
- i686_pagezero(CADDR2);
- else
-#endif
- bzero(CADDR2, PAGE_SIZE);
- *(int *) CMAP2 = 0;
-#endif
-}
-
-/*
- * pmap_zero_page_area zeros the specified hardware page by mapping
- * the page into KVM and using bzero to clear its contents.
- *
- * off and size may not cover an area beyond a single hardware page.
- */
-void
-pmap_zero_page_area(phys, off, size)
- vm_offset_t phys;
- int off;
- int size;
-{
-#ifdef SMP
-#if !defined(MAX_PERF)
- if (*(int *) prv_CMAP3)
- panic("pmap_zero_page: prv_CMAP3 busy");
-#endif
-
- *(int *) prv_CMAP3 = PG_V | PG_RW | (phys & PG_FRAME) | PG_A | PG_M;
- cpu_invlpg(prv_CADDR3);
-
-#if defined(I686_CPU)
- if (cpu_class == CPUCLASS_686 && off == 0 && size == PAGE_SIZE)
- i686_pagezero(prv_CADDR3);
- else
-#endif
- bzero((char *)prv_CADDR3 + off, size);
-
- *(int *) prv_CMAP3 = 0;
-#else
-#if !defined(MAX_PERF)
- if (*(int *) CMAP2)
- panic("pmap_zero_page: CMAP2 busy");
-#endif
-
- *(int *) CMAP2 = PG_V | PG_RW | (phys & PG_FRAME) | PG_A | PG_M;
- invltlb_1pg((vm_offset_t)CADDR2);
-
-#if defined(I686_CPU)
- if (cpu_class == CPUCLASS_686 && off == 0 && size == PAGE_SIZE)
- i686_pagezero(CADDR2);
- else
-#endif
- bzero((char *)CADDR2 + off, size);
- *(int *) CMAP2 = 0;
-#endif
-}
-
-/*
- * pmap_copy_page copies the specified (machine independent)
- * page by mapping the page into virtual memory and using
- * bcopy to copy the page, one machine dependent page at a
- * time.
- */
-void
-pmap_copy_page(src, dst)
- vm_offset_t src;
- vm_offset_t dst;
-{
-#ifdef SMP
-#if !defined(MAX_PERF)
- if (*(int *) prv_CMAP1)
- panic("pmap_copy_page: prv_CMAP1 busy");
- if (*(int *) prv_CMAP2)
- panic("pmap_copy_page: prv_CMAP2 busy");
-#endif
-
- *(int *) prv_CMAP1 = PG_V | (src & PG_FRAME) | PG_A;
- *(int *) prv_CMAP2 = PG_V | PG_RW | (dst & PG_FRAME) | PG_A | PG_M;
-
- cpu_invlpg(prv_CADDR1);
- cpu_invlpg(prv_CADDR2);
-
- bcopy(prv_CADDR1, prv_CADDR2, PAGE_SIZE);
-
- *(int *) prv_CMAP1 = 0;
- *(int *) prv_CMAP2 = 0;
-#else
-#if !defined(MAX_PERF)
- if (*(int *) CMAP1 || *(int *) CMAP2)
- panic("pmap_copy_page: CMAP busy");
-#endif
-
- *(int *) CMAP1 = PG_V | (src & PG_FRAME) | PG_A;
- *(int *) CMAP2 = PG_V | PG_RW | (dst & PG_FRAME) | PG_A | PG_M;
-#if defined(I386_CPU)
- if (cpu_class == CPUCLASS_386) {
- invltlb();
- } else
-#endif
- {
- invlpg((u_int)CADDR1);
- invlpg((u_int)CADDR2);
- }
-
- bcopy(CADDR1, CADDR2, PAGE_SIZE);
-
- *(int *) CMAP1 = 0;
- *(int *) CMAP2 = 0;
-#endif
-}
-
-
-/*
- * Routine: pmap_pageable
- * Function:
- * Make the specified pages (by pmap, offset)
- * pageable (or not) as requested.
- *
- * A page which is not pageable may not take
- * a fault; therefore, its page table entry
- * must remain valid for the duration.
- *
- * This routine is merely advisory; pmap_enter
- * will specify that these pages are to be wired
- * down (or not) as appropriate.
- */
-void
-pmap_pageable(pmap, sva, eva, pageable)
- pmap_t pmap;
- vm_offset_t sva, eva;
- boolean_t pageable;
-{
-}
-
-/*
- * this routine returns true if a physical page resides
- * in the given pmap.
- */
-boolean_t
-pmap_page_exists(pmap, pa)
- pmap_t pmap;
- vm_offset_t pa;
-{
- register pv_entry_t pv;
- pv_table_t *ppv;
- int s;
-
- if (!pmap_is_managed(pa))
- return FALSE;
-
- s = splvm();
-
- ppv = pa_to_pvh(pa);
- /*
- * Not found, check current mappings returning immediately if found.
- */
- for (pv = TAILQ_FIRST(&ppv->pv_list);
- pv;
- pv = TAILQ_NEXT(pv, pv_list)) {
- if (pv->pv_pmap == pmap) {
- splx(s);
- return TRUE;
- }
- }
- splx(s);
- return (FALSE);
-}
-
-#define PMAP_REMOVE_PAGES_CURPROC_ONLY
-/*
- * Remove all pages from specified address space
- * this aids process exit speeds. Also, this code
- * is special cased for current process only, but
- * can have the more generic (and slightly slower)
- * mode enabled. This is much faster than pmap_remove
- * in the case of running down an entire address space.
- */
-void
-pmap_remove_pages(pmap, sva, eva)
- pmap_t pmap;
- vm_offset_t sva, eva;
-{
- unsigned *pte, tpte;
- pv_table_t *ppv;
- pv_entry_t pv, npv;
- int s;
-
-#ifdef PMAP_REMOVE_PAGES_CURPROC_ONLY
- if (!curproc || (pmap != vmspace_pmap(curproc->p_vmspace))) {
- printf("warning: pmap_remove_pages called with non-current pmap\n");
- return;
- }
-#endif
-
- s = splvm();
- for(pv = TAILQ_FIRST(&pmap->pm_pvlist);
- pv;
- pv = npv) {
-
- if (pv->pv_va >= eva || pv->pv_va < sva) {
- npv = TAILQ_NEXT(pv, pv_plist);
- continue;
- }
-
-#ifdef PMAP_REMOVE_PAGES_CURPROC_ONLY
- pte = (unsigned *)vtopte(pv->pv_va);
-#else
- pte = pmap_pte_quick(pv->pv_pmap, pv->pv_va);
-#endif
- tpte = *pte;
-
-/*
- * We cannot remove wired pages from a process' mapping at this time
- */
- if (tpte & PG_W) {
- npv = TAILQ_NEXT(pv, pv_plist);
- continue;
- }
- *pte = 0;
-
- ppv = pa_to_pvh(tpte);
-
- KASSERT(ppv < &pv_table[pv_npg],
- ("pmap_remove_pages: bad tpte %x", tpte));
-
- pv->pv_pmap->pm_stats.resident_count--;
-
- /*
- * Update the vm_page_t clean and reference bits.
- */
- if (tpte & PG_M) {
- vm_page_dirty(ppv->pv_vm_page);
- }
-
-
- npv = TAILQ_NEXT(pv, pv_plist);
- TAILQ_REMOVE(&pv->pv_pmap->pm_pvlist, pv, pv_plist);
-
- ppv->pv_list_count--;
- TAILQ_REMOVE(&ppv->pv_list, pv, pv_list);
- if (TAILQ_FIRST(&ppv->pv_list) == NULL) {
- vm_page_flag_clear(ppv->pv_vm_page, PG_MAPPED | PG_WRITEABLE);
- }
-
- pmap_unuse_pt(pv->pv_pmap, pv->pv_va, pv->pv_ptem);
- free_pv_entry(pv);
- }
- splx(s);
- pmap_TLB_invalidate_all(pmap);
-}
-
-/*
- * pmap_testbit tests bits in pte's
- * note that the testbit/changebit routines are inline,
- * and a lot of things compile-time evaluate.
- */
-static boolean_t
-pmap_testbit(pa, bit)
- register vm_offset_t pa;
- int bit;
-{
- register pv_entry_t pv;
- pv_table_t *ppv;
- unsigned *pte;
- int s;
-
- if (!pmap_is_managed(pa))
- return FALSE;
-
- ppv = pa_to_pvh(pa);
- if (TAILQ_FIRST(&ppv->pv_list) == NULL)
- return FALSE;
-
- s = splvm();
-
- for (pv = TAILQ_FIRST(&ppv->pv_list);
- pv;
- pv = TAILQ_NEXT(pv, pv_list)) {
-
- /*
- * if the bit being tested is the modified bit, then
- * mark clean_map and ptes as never
- * modified.
- */
- if (bit & (PG_A|PG_M)) {
- if (!pmap_track_modified(pv->pv_va))
- continue;
- }
-
-#if defined(PMAP_DIAGNOSTIC)
- if (!pv->pv_pmap) {
- printf("Null pmap (tb) at va: 0x%x\n", pv->pv_va);
- continue;
- }
-#endif
- pte = pmap_pte_quick(pv->pv_pmap, pv->pv_va);
- if (*pte & bit) {
- splx(s);
- return TRUE;
- }
- }
- splx(s);
- return (FALSE);
-}
-
-/*
- * this routine is used to modify bits in ptes
- */
-static __inline void
-pmap_changebit(pa, bit, setem)
- vm_offset_t pa;
- int bit;
- boolean_t setem;
-{
- register pv_entry_t pv;
- pv_table_t *ppv;
- register unsigned *pte;
- int s;
-
- if (!pmap_is_managed(pa))
- return;
-
- s = splvm();
- ppv = pa_to_pvh(pa);
-
- /*
- * Loop over all current mappings setting/clearing as appropos If
- * setting RO do we need to clear the VAC?
- */
- for (pv = TAILQ_FIRST(&ppv->pv_list);
- pv;
- pv = TAILQ_NEXT(pv, pv_list)) {
-
- /*
- * don't write protect pager mappings
- */
- if (!setem && (bit == PG_RW)) {
- if (!pmap_track_modified(pv->pv_va))
- continue;
- }
-
-#if defined(PMAP_DIAGNOSTIC)
- if (!pv->pv_pmap) {
- printf("Null pmap (cb) at va: 0x%x\n", pv->pv_va);
- continue;
- }
-#endif
-
- pte = pmap_pte_quick(pv->pv_pmap, pv->pv_va);
-
- if (setem) {
- *(int *)pte |= bit;
- pmap_TLB_invalidate(pv->pv_pmap, pv->pv_va);
- } else {
- vm_offset_t pbits = *(vm_offset_t *)pte;
- if (pbits & bit) {
- if (bit == PG_RW) {
- if (pbits & PG_M) {
- vm_page_dirty(ppv->pv_vm_page);
- }
- *(int *)pte = pbits & ~(PG_M|PG_RW);
- } else {
- *(int *)pte = pbits & ~bit;
- }
- pmap_TLB_invalidate(pv->pv_pmap, pv->pv_va);
- }
- }
- }
- splx(s);
-}
-
-/*
- * pmap_clearbit:
- *
- * Clear a bit/bits in every pte mapping a given physical page. Making
- * this inline allows the pmap_changebit inline to be well optimized.
- */
-static __inline void
-pmap_clearbit(
- vm_offset_t pa,
- int bit)
-{
- pmap_changebit(pa, bit, FALSE);
-}
-
-/*
- * pmap_page_protect:
- *
- * Lower the permission for all mappings to a given page.
- */
-void
-pmap_page_protect(vm_offset_t phys, vm_prot_t prot)
-{
- if ((prot & VM_PROT_WRITE) == 0) {
- if (prot & (VM_PROT_READ | VM_PROT_EXECUTE)) {
- pmap_clearbit(phys, PG_RW);
- } else {
- pmap_remove_all(phys);
- }
- }
-}
-
-vm_offset_t
-pmap_phys_address(ppn)
- int ppn;
-{
- return (i386_ptob(ppn));
-}
-
-/*
- * pmap_ts_referenced:
- *
- * Return the count of reference bits for a page, clearing all of them.
- */
-int
-pmap_ts_referenced(vm_offset_t pa)
-{
- register pv_entry_t pv, pvf, pvn;
- pv_table_t *ppv;
- unsigned *pte;
- int s;
- int rtval = 0;
-
- if (!pmap_is_managed(pa))
- return (rtval);
-
- s = splvm();
-
- ppv = pa_to_pvh(pa);
-
- if ((pv = TAILQ_FIRST(&ppv->pv_list)) != NULL) {
-
- pvf = pv;
-
- do {
- pvn = TAILQ_NEXT(pv, pv_list);
-
- TAILQ_REMOVE(&ppv->pv_list, pv, pv_list);
-
- TAILQ_INSERT_TAIL(&ppv->pv_list, pv, pv_list);
-
- if (!pmap_track_modified(pv->pv_va))
- continue;
-
- pte = pmap_pte_quick(pv->pv_pmap, pv->pv_va);
-
- if (pte && (*pte & PG_A)) {
- *pte &= ~PG_A;
-
- pmap_TLB_invalidate(pv->pv_pmap, pv->pv_va);
-
- rtval++;
- if (rtval > 4) {
- break;
- }
- }
- } while ((pv = pvn) != NULL && pv != pvf);
- }
- splx(s);
-
- return (rtval);
-}
-
-/*
- * pmap_is_modified:
- *
- * Return whether or not the specified physical page was modified
- * in any physical maps.
- */
-boolean_t
-pmap_is_modified(vm_offset_t pa)
-{
- return pmap_testbit((pa), PG_M);
-}
-
-/*
- * Clear the modify bits on the specified physical page.
- */
-void
-pmap_clear_modify(vm_offset_t pa)
-{
- pmap_clearbit(pa, PG_M);
-}
-
-/*
- * pmap_clear_reference:
- *
- * Clear the reference bit on the specified physical page.
- */
-void
-pmap_clear_reference(vm_offset_t pa)
-{
- pmap_clearbit(pa, PG_A);
-}
-
-/*
- * Miscellaneous support routines follow
- */
-
-static void
-i386_protection_init()
-{
- register int *kp, prot;
-
- kp = protection_codes;
- for (prot = 0; prot < 8; prot++) {
- switch (prot) {
- case VM_PROT_NONE | VM_PROT_NONE | VM_PROT_NONE:
- /*
- * Read access is also 0. There isn't any execute bit,
- * so just make it readable.
- */
- case VM_PROT_READ | VM_PROT_NONE | VM_PROT_NONE:
- case VM_PROT_READ | VM_PROT_NONE | VM_PROT_EXECUTE:
- case VM_PROT_NONE | VM_PROT_NONE | VM_PROT_EXECUTE:
- *kp++ = 0;
- break;
- case VM_PROT_NONE | VM_PROT_WRITE | VM_PROT_NONE:
- case VM_PROT_NONE | VM_PROT_WRITE | VM_PROT_EXECUTE:
- case VM_PROT_READ | VM_PROT_WRITE | VM_PROT_NONE:
- case VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE:
- *kp++ = PG_RW;
- break;
- }
- }
-}
-
-/*
- * Map a set of physical memory pages into the kernel virtual
- * address space. Return a pointer to where it is mapped. This
- * routine is intended to be used for mapping device memory,
- * NOT real memory.
- */
-void *
-pmap_mapdev(pa, size)
- vm_offset_t pa;
- vm_size_t size;
-{
- vm_offset_t va, tmpva, offset;
- unsigned *pte;
-
- offset = pa & PAGE_MASK;
- size = roundup(offset + size, PAGE_SIZE);
-
- va = kmem_alloc_pageable(kernel_map, size);
-#if !defined(MAX_PERF)
- if (!va)
- panic("pmap_mapdev: Couldn't alloc kernel virtual memory");
-#endif
-
- pa = pa & PG_FRAME;
- for (tmpva = va; size > 0;) {
- pte = (unsigned *)vtopte(tmpva);
- *pte = pa | PG_RW | PG_V | pgeflag;
- size -= PAGE_SIZE;
- tmpva += PAGE_SIZE;
- pa += PAGE_SIZE;
- }
- invltlb();
-
- return ((void *)(va + offset));
-}
-
-void
-pmap_unmapdev(va, size)
- vm_offset_t va;
- vm_size_t size;
-{
- vm_offset_t base, offset;
-
- base = va & PG_FRAME;
- offset = va & PAGE_MASK;
- size = roundup(offset + size, PAGE_SIZE);
- kmem_free(kernel_map, base, size);
-}
-
-/*
- * perform the pmap work for mincore
- */
-int
-pmap_mincore(pmap, addr)
- pmap_t pmap;
- vm_offset_t addr;
-{
-
- unsigned *ptep, pte;
- vm_page_t m;
- int val = 0;
-
- ptep = pmap_pte(pmap, addr);
- if (ptep == 0) {
- return 0;
- }
-
- if ((pte = *ptep) != 0) {
- pv_table_t *ppv;
- vm_offset_t pa;
-
- val = MINCORE_INCORE;
- if ((pte & PG_MANAGED) == 0)
- return val;
-
- pa = pte & PG_FRAME;
-
- ppv = pa_to_pvh((pa & PG_FRAME));
- m = ppv->pv_vm_page;
-
- /*
- * Modified by us
- */
- if (pte & PG_M)
- val |= MINCORE_MODIFIED|MINCORE_MODIFIED_OTHER;
- /*
- * Modified by someone
- */
- else if (m->dirty || pmap_is_modified(pa))
- val |= MINCORE_MODIFIED_OTHER;
- /*
- * Referenced by us
- */
- if (pte & PG_A)
- val |= MINCORE_REFERENCED|MINCORE_REFERENCED_OTHER;
-
- /*
- * Referenced by someone
- */
- else if ((m->flags & PG_REFERENCED) || pmap_ts_referenced(pa)) {
- val |= MINCORE_REFERENCED_OTHER;
- vm_page_flag_set(m, PG_REFERENCED);
- }
- }
- return val;
-}
-
-void
-pmap_activate(struct proc *p)
-{
- pmap_t pmap;
-
- pmap = vmspace_pmap(p->p_vmspace);
-#if defined(SMP)
- pmap->pm_active |= 1 << cpuid;
-#else
- pmap->pm_active |= 1;
-#endif
-#if defined(SWTCH_OPTIM_STATS)
- tlb_flush_count++;
-#endif
- load_cr3(p->p_addr->u_pcb.pcb_cr3 = vtophys(pmap->pm_pdir));
-}
-
-vm_offset_t
-pmap_addr_hint(vm_object_t obj, vm_offset_t addr, vm_size_t size) {
-
- if ((obj == NULL) || (size < NBPDR) || (obj->type != OBJT_DEVICE)) {
- return addr;
- }
-
- addr = (addr + (NBPDR - 1)) & ~(NBPDR - 1);
- return addr;
-}
-
-
-#if defined(PMAP_DEBUG)
-pmap_pid_dump(int pid) {
- pmap_t pmap;
- struct proc *p;
- int npte = 0;
- int index;
- LIST_FOREACH(p, &allproc, p_list) {
- if (p->p_pid != pid)
- continue;
-
- if (p->p_vmspace) {
- int i,j;
- index = 0;
- pmap = vmspace_pmap(p->p_vmspace);
- for(i=0;i<1024;i++) {
- pd_entry_t *pde;
- unsigned *pte;
- unsigned base = i << PDRSHIFT;
-
- pde = &pmap->pm_pdir[i];
- if (pde && pmap_pde_v(pde)) {
- for(j=0;j<1024;j++) {
- unsigned va = base + (j << PAGE_SHIFT);
- if (va >= (vm_offset_t) VM_MIN_KERNEL_ADDRESS) {
- if (index) {
- index = 0;
- printf("\n");
- }
- return npte;
- }
- pte = pmap_pte_quick( pmap, va);
- if (pte && pmap_pte_v(pte)) {
- vm_offset_t pa;
- vm_page_t m;
- pa = *(int *)pte;
- m = PHYS_TO_VM_PAGE((pa & PG_FRAME));
- printf("va: 0x%x, pt: 0x%x, h: %d, w: %d, f: 0x%x",
- va, pa, m->hold_count, m->wire_count, m->flags);
- npte++;
- index++;
- if (index >= 2) {
- index = 0;
- printf("\n");
- } else {
- printf(" ");
- }
- }
- }
- }
- }
- }
- }
- return npte;
-}
-#endif
-
-#if defined(DEBUG)
-
-static void pads __P((pmap_t pm));
-void pmap_pvdump __P((vm_offset_t pa));
-
-/* print address space of pmap*/
-static void
-pads(pm)
- pmap_t pm;
-{
- unsigned va, i, j;
- unsigned *ptep;
-
- if (pm == kernel_pmap)
- return;
- for (i = 0; i < 1024; i++)
- if (pm->pm_pdir[i])
- for (j = 0; j < 1024; j++) {
- va = (i << PDRSHIFT) + (j << PAGE_SHIFT);
- if (pm == kernel_pmap && va < KERNBASE)
- continue;
- if (pm != kernel_pmap && va > UPT_MAX_ADDRESS)
- continue;
- ptep = pmap_pte_quick(pm, va);
- if (pmap_pte_v(ptep))
- printf("%x:%x ", va, *(int *) ptep);
- };
-
-}
-
-void
-pmap_pvdump(pa)
- vm_offset_t pa;
-{
- pv_table_t *ppv;
- register pv_entry_t pv;
-
- printf("pa %x", pa);
- ppv = pa_to_pvh(pa);
- for (pv = TAILQ_FIRST(&ppv->pv_list);
- pv;
- pv = TAILQ_NEXT(pv, pv_list)) {
-#ifdef used_to_be
- printf(" -> pmap %p, va %x, flags %x",
- (void *)pv->pv_pmap, pv->pv_va, pv->pv_flags);
-#endif
- printf(" -> pmap %p, va %x", (void *)pv->pv_pmap, pv->pv_va);
- pads(pv->pv_pmap);
- }
- printf(" ");
-}
-#endif
diff --git a/sys/amd64/amd64/prof_machdep.c b/sys/amd64/amd64/prof_machdep.c
deleted file mode 100644
index d934ee56eee6..000000000000
--- a/sys/amd64/amd64/prof_machdep.c
+++ /dev/null
@@ -1,355 +0,0 @@
-/*-
- * Copyright (c) 1996 Bruce D. Evans.
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#ifdef GUPROF
-#include "opt_i586_guprof.h"
-#include "opt_perfmon.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/gmon.h>
-#include <sys/kernel.h>
-#include <sys/sysctl.h>
-
-#include <machine/clock.h>
-#include <machine/perfmon.h>
-#include <machine/profile.h>
-#undef MCOUNT
-#endif
-
-#include <machine/asmacros.h>
-
-#ifdef PC98
-#include <pc98/pc98/pc98.h>
-#else
-#include <i386/isa/isa.h>
-#endif
-#include <i386/isa/timerreg.h>
-
-#ifdef GUPROF
-#define CPUTIME_CLOCK_UNINITIALIZED 0
-#define CPUTIME_CLOCK_I8254 1
-#define CPUTIME_CLOCK_TSC 2
-#define CPUTIME_CLOCK_I586_PMC 3
-#define CPUTIME_CLOCK_I8254_SHIFT 7
-
-int cputime_bias = 1; /* initialize for locality of reference */
-
-static int cputime_clock = CPUTIME_CLOCK_UNINITIALIZED;
-#ifdef I586_PMC_GUPROF
-static u_int cputime_clock_pmc_conf = I586_PMC_GUPROF;
-static int cputime_clock_pmc_init;
-static struct gmonparam saved_gmp;
-#endif
-#endif /* GUPROF */
-
-#ifdef __GNUC__
-__asm(" \n\
-GM_STATE = 0 \n\
-GMON_PROF_OFF = 3 \n\
- \n\
- .text \n\
- .p2align 4,0x90 \n\
- .globl __mcount \n\
- .type __mcount,@function \n\
-__mcount: \n\
- # \n\
- # Check that we are profiling. Do it early for speed. \n\
- # \n\
- cmpl $GMON_PROF_OFF," __XSTRING(CNAME(_gmonparam)) "+GM_STATE \n\
- je .mcount_exit \n\
- # \n\
- # __mcount is the same as [.]mcount except the caller \n\
- # hasn't changed the stack except to call here, so the \n\
- # caller's raddr is above our raddr. \n\
- # \n\
- movl 4(%esp),%edx \n\
- jmp .got_frompc \n\
- \n\
- .p2align 4,0x90 \n\
- .globl " __XSTRING(HIDENAME(mcount)) " \n\
-" __XSTRING(HIDENAME(mcount)) ": \n\
- cmpl $GMON_PROF_OFF," __XSTRING(CNAME(_gmonparam)) "+GM_STATE \n\
- je .mcount_exit \n\
- # \n\
- # The caller's stack frame has already been built, so \n\
- # %ebp is the caller's frame pointer. The caller's \n\
- # raddr is in the caller's frame following the caller's \n\
- # caller's frame pointer. \n\
- # \n\
- movl 4(%ebp),%edx \n\
-.got_frompc: \n\
- # \n\
- # Our raddr is the caller's pc. \n\
- # \n\
- movl (%esp),%eax \n\
- \n\
- pushfl \n\
- pushl %eax \n\
- pushl %edx \n\
- cli \n\
- call " __XSTRING(CNAME(mcount)) " \n\
- addl $8,%esp \n\
- popfl \n\
-.mcount_exit: \n\
- ret \n\
-");
-#else /* !__GNUC__ */
-#error
-#endif /* __GNUC__ */
-
-#ifdef GUPROF
-/*
- * [.]mexitcount saves the return register(s), loads selfpc and calls
- * mexitcount(selfpc) to do the work. Someday it should be in a machine
- * dependent file together with cputime(), __mcount and [.]mcount. cputime()
- * can't just be put in machdep.c because it has to be compiled without -pg.
- */
-#ifdef __GNUC__
-__asm(" \n\
- .text \n\
-# \n\
-# Dummy label to be seen when gprof -u hides [.]mexitcount. \n\
-# \n\
- .p2align 4,0x90 \n\
- .globl __mexitcount \n\
- .type __mexitcount,@function \n\
-__mexitcount: \n\
- nop \n\
- \n\
-GMON_PROF_HIRES = 4 \n\
- \n\
- .p2align 4,0x90 \n\
- .globl " __XSTRING(HIDENAME(mexitcount)) " \n\
-" __XSTRING(HIDENAME(mexitcount)) ": \n\
- cmpl $GMON_PROF_HIRES," __XSTRING(CNAME(_gmonparam)) "+GM_STATE \n\
- jne .mexitcount_exit \n\
- pushl %edx \n\
- pushl %eax \n\
- movl 8(%esp),%eax \n\
- pushfl \n\
- pushl %eax \n\
- cli \n\
- call " __XSTRING(CNAME(mexitcount)) " \n\
- addl $4,%esp \n\
- popfl \n\
- popl %eax \n\
- popl %edx \n\
-.mexitcount_exit: \n\
- ret \n\
-");
-#else /* !__GNUC__ */
-#error
-#endif /* __GNUC__ */
-
-/*
- * Return the time elapsed since the last call. The units are machine-
- * dependent.
- */
-int
-cputime()
-{
- u_int count;
- int delta;
-#if (defined(I586_CPU) || defined(I686_CPU)) && !defined(SMP) && \
- defined(PERFMON) && defined(I586_PMC_GUPROF)
- u_quad_t event_count;
-#endif
- u_char high, low;
- static u_int prev_count;
-
-#if (defined(I586_CPU) || defined(I686_CPU)) && !defined(SMP)
- if (cputime_clock == CPUTIME_CLOCK_TSC) {
- count = (u_int)rdtsc();
- delta = (int)(count - prev_count);
- prev_count = count;
- return (delta);
- }
-#if defined(PERFMON) && defined(I586_PMC_GUPROF)
- if (cputime_clock == CPUTIME_CLOCK_I586_PMC) {
- /*
- * XXX permon_read() should be inlined so that the
- * perfmon module doesn't need to be compiled with
- * profiling disabled and so that it is fast.
- */
- perfmon_read(0, &event_count);
-
- count = (u_int)event_count;
- delta = (int)(count - prev_count);
- prev_count = count;
- return (delta);
- }
-#endif /* PERFMON && I586_PMC_GUPROF */
-#endif /* (I586_CPU || I686_CPU) && !SMP */
-
- /*
- * Read the current value of the 8254 timer counter 0.
- */
- outb(TIMER_MODE, TIMER_SEL0 | TIMER_LATCH);
- low = inb(TIMER_CNTR0);
- high = inb(TIMER_CNTR0);
- count = ((high << 8) | low) << CPUTIME_CLOCK_I8254_SHIFT;
-
- /*
- * The timer counts down from TIMER_CNTR0_MAX to 0 and then resets.
- * While profiling is enabled, this routine is called at least twice
- * per timer reset (for mcounting and mexitcounting hardclock()),
- * so at most one reset has occurred since the last call, and one
- * has occurred iff the current count is larger than the previous
- * count. This allows counter underflow to be detected faster
- * than in microtime().
- */
- delta = prev_count - count;
- prev_count = count;
- if ((int) delta <= 0)
- return (delta + (timer0_max_count << CPUTIME_CLOCK_I8254_SHIFT));
- return (delta);
-}
-
-static int
-sysctl_machdep_cputime_clock SYSCTL_HANDLER_ARGS
-{
- int clock;
- int error;
-#if defined(PERFMON) && defined(I586_PMC_GUPROF)
- int event;
- struct pmc pmc;
-#endif
-
- clock = cputime_clock;
-#if defined(PERFMON) && defined(I586_PMC_GUPROF)
- if (clock == CPUTIME_CLOCK_I586_PMC) {
- pmc.pmc_val = cputime_clock_pmc_conf;
- clock += pmc.pmc_event;
- }
-#endif
- error = sysctl_handle_opaque(oidp, &clock, sizeof clock, req);
- if (error == 0 && req->newptr != NULL) {
-#if defined(PERFMON) && defined(I586_PMC_GUPROF)
- if (clock >= CPUTIME_CLOCK_I586_PMC) {
- event = clock - CPUTIME_CLOCK_I586_PMC;
- if (event >= 256)
- return (EINVAL);
- pmc.pmc_num = 0;
- pmc.pmc_event = event;
- pmc.pmc_unit = 0;
- pmc.pmc_flags = PMCF_E | PMCF_OS | PMCF_USR;
- pmc.pmc_mask = 0;
- cputime_clock_pmc_conf = pmc.pmc_val;
- cputime_clock = CPUTIME_CLOCK_I586_PMC;
- } else
-#endif
- {
- if (clock < 0 || clock >= CPUTIME_CLOCK_I586_PMC)
- return (EINVAL);
- cputime_clock = clock;
- }
- }
- return (error);
-}
-
-SYSCTL_PROC(_machdep, OID_AUTO, cputime_clock, CTLTYPE_INT | CTLFLAG_RW,
- 0, sizeof(u_int), sysctl_machdep_cputime_clock, "I", "");
-
-/*
- * The start and stop routines need not be here since we turn off profiling
- * before calling them. They are here for convenience.
- */
-
-void
-startguprof(gp)
- struct gmonparam *gp;
-{
- if (cputime_clock == CPUTIME_CLOCK_UNINITIALIZED) {
- cputime_clock = CPUTIME_CLOCK_I8254;
-#if (defined(I586_CPU) || defined(I686_CPU)) && !defined(SMP)
- if (tsc_freq != 0)
- cputime_clock = CPUTIME_CLOCK_TSC;
-#endif
- }
- gp->profrate = timer_freq << CPUTIME_CLOCK_I8254_SHIFT;
-#if (defined(I586_CPU) || defined(I686_CPU)) && !defined(SMP)
- if (cputime_clock == CPUTIME_CLOCK_TSC)
- gp->profrate = tsc_freq;
-#if defined(PERFMON) && defined(I586_PMC_GUPROF)
- else if (cputime_clock == CPUTIME_CLOCK_I586_PMC) {
- if (perfmon_avail() &&
- perfmon_setup(0, cputime_clock_pmc_conf) == 0) {
- if (perfmon_start(0) != 0)
- perfmon_fini(0);
- else {
- /* XXX 1 event == 1 us. */
- gp->profrate = 1000000;
-
- saved_gmp = *gp;
-
- /* Zap overheads. They are invalid. */
- gp->cputime_overhead = 0;
- gp->mcount_overhead = 0;
- gp->mcount_post_overhead = 0;
- gp->mcount_pre_overhead = 0;
- gp->mexitcount_overhead = 0;
- gp->mexitcount_post_overhead = 0;
- gp->mexitcount_pre_overhead = 0;
-
- cputime_clock_pmc_init = TRUE;
- }
- }
- }
-#endif /* PERFMON && I586_PMC_GUPROF */
-#endif /* (I586_CPU || I686_CPU) && !SMP */
- cputime_bias = 0;
- cputime();
-}
-
-void
-stopguprof(gp)
- struct gmonparam *gp;
-{
-#if defined(PERFMON) && defined(I586_PMC_GUPROF)
- if (cputime_clock_pmc_init) {
- *gp = saved_gmp;
- perfmon_fini(0);
- cputime_clock_pmc_init = FALSE;
- }
-#endif
-}
-
-#else /* !GUPROF */
-#ifdef __GNUC__
-__asm(" \n\
- .text \n\
- .p2align 4,0x90 \n\
- .globl " __XSTRING(HIDENAME(mexitcount)) " \n\
-" __XSTRING(HIDENAME(mexitcount)) ": \n\
- ret \n\
-");
-#else /* !__GNUC__ */
-#error
-#endif /* __GNUC__ */
-#endif /* GUPROF */
diff --git a/sys/amd64/amd64/support.S b/sys/amd64/amd64/support.S
deleted file mode 100644
index 394848cd047f..000000000000
--- a/sys/amd64/amd64/support.S
+++ /dev/null
@@ -1,1653 +0,0 @@
-/*-
- * Copyright (c) 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- */
-
-#include "opt_smp.h"
-#include "npx.h"
-
-#include <machine/asmacros.h>
-#include <machine/cputypes.h>
-#include <machine/pmap.h>
-#include <machine/specialreg.h>
-
-#include "assym.s"
-
-#define IDXSHIFT 10
-
- .data
- .globl _bcopy_vector
-_bcopy_vector:
- .long _generic_bcopy
- .globl _bzero
-_bzero:
- .long _generic_bzero
- .globl _copyin_vector
-_copyin_vector:
- .long _generic_copyin
- .globl _copyout_vector
-_copyout_vector:
- .long _generic_copyout
- .globl _ovbcopy_vector
-_ovbcopy_vector:
- .long _generic_bcopy
-#if defined(I586_CPU) && NNPX > 0
-kernel_fpu_lock:
- .byte 0xfe
- .space 3
-#endif
-
- .text
-
-/*
- * bcopy family
- * void bzero(void *buf, u_int len)
- */
-
-ENTRY(generic_bzero)
- pushl %edi
- movl 8(%esp),%edi
- movl 12(%esp),%ecx
- xorl %eax,%eax
- shrl $2,%ecx
- cld
- rep
- stosl
- movl 12(%esp),%ecx
- andl $3,%ecx
- rep
- stosb
- popl %edi
- ret
-
-#if defined(I486_CPU)
-ENTRY(i486_bzero)
- movl 4(%esp),%edx
- movl 8(%esp),%ecx
- xorl %eax,%eax
-/*
- * do 64 byte chunks first
- *
- * XXX this is probably over-unrolled at least for DX2's
- */
-2:
- cmpl $64,%ecx
- jb 3f
- movl %eax,(%edx)
- movl %eax,4(%edx)
- movl %eax,8(%edx)
- movl %eax,12(%edx)
- movl %eax,16(%edx)
- movl %eax,20(%edx)
- movl %eax,24(%edx)
- movl %eax,28(%edx)
- movl %eax,32(%edx)
- movl %eax,36(%edx)
- movl %eax,40(%edx)
- movl %eax,44(%edx)
- movl %eax,48(%edx)
- movl %eax,52(%edx)
- movl %eax,56(%edx)
- movl %eax,60(%edx)
- addl $64,%edx
- subl $64,%ecx
- jnz 2b
- ret
-
-/*
- * do 16 byte chunks
- */
- SUPERALIGN_TEXT
-3:
- cmpl $16,%ecx
- jb 4f
- movl %eax,(%edx)
- movl %eax,4(%edx)
- movl %eax,8(%edx)
- movl %eax,12(%edx)
- addl $16,%edx
- subl $16,%ecx
- jnz 3b
- ret
-
-/*
- * do 4 byte chunks
- */
- SUPERALIGN_TEXT
-4:
- cmpl $4,%ecx
- jb 5f
- movl %eax,(%edx)
- addl $4,%edx
- subl $4,%ecx
- jnz 4b
- ret
-
-/*
- * do 1 byte chunks
- * a jump table seems to be faster than a loop or more range reductions
- *
- * XXX need a const section for non-text
- */
- .data
-jtab:
- .long do0
- .long do1
- .long do2
- .long do3
-
- .text
- SUPERALIGN_TEXT
-5:
- jmp jtab(,%ecx,4)
-
- SUPERALIGN_TEXT
-do3:
- movw %ax,(%edx)
- movb %al,2(%edx)
- ret
-
- SUPERALIGN_TEXT
-do2:
- movw %ax,(%edx)
- ret
-
- SUPERALIGN_TEXT
-do1:
- movb %al,(%edx)
- ret
-
- SUPERALIGN_TEXT
-do0:
- ret
-#endif
-
-#if defined(I586_CPU) && NNPX > 0
-ENTRY(i586_bzero)
- movl 4(%esp),%edx
- movl 8(%esp),%ecx
-
- /*
- * The FPU register method is twice as fast as the integer register
- * method unless the target is in the L1 cache and we pre-allocate a
- * cache line for it (then the integer register method is 4-5 times
- * faster). However, we never pre-allocate cache lines, since that
- * would make the integer method 25% or more slower for the common
- * case when the target isn't in either the L1 cache or the L2 cache.
- * Thus we normally use the FPU register method unless the overhead
- * would be too large.
- */
- cmpl $256,%ecx /* empirical; clts, fninit, smsw cost a lot */
- jb intreg_i586_bzero
-
- /*
- * The FPU registers may belong to an application or to fastmove()
- * or to another invocation of bcopy() or ourself in a higher level
- * interrupt or trap handler. Preserving the registers is
- * complicated since we avoid it if possible at all levels. We
- * want to localize the complications even when that increases them.
- * Here the extra work involves preserving CR0_TS in TS.
- * `npxproc != NULL' is supposed to be the condition that all the
- * FPU resources belong to an application, but npxproc and CR0_TS
- * aren't set atomically enough for this condition to work in
- * interrupt handlers.
- *
- * Case 1: FPU registers belong to the application: we must preserve
- * the registers if we use them, so we only use the FPU register
- * method if the target size is large enough to amortize the extra
- * overhead for preserving them. CR0_TS must be preserved although
- * it is very likely to end up as set.
- *
- * Case 2: FPU registers belong to fastmove(): fastmove() currently
- * makes the registers look like they belong to an application so
- * that cpu_switch() and savectx() don't have to know about it, so
- * this case reduces to case 1.
- *
- * Case 3: FPU registers belong to the kernel: don't use the FPU
- * register method. This case is unlikely, and supporting it would
- * be more complicated and might take too much stack.
- *
- * Case 4: FPU registers don't belong to anyone: the FPU registers
- * don't need to be preserved, so we always use the FPU register
- * method. CR0_TS must be preserved although it is very likely to
- * always end up as clear.
- */
- cmpl $0,_npxproc
- je i586_bz1
- cmpl $256+184,%ecx /* empirical; not quite 2*108 more */
- jb intreg_i586_bzero
- sarb $1,kernel_fpu_lock
- jc intreg_i586_bzero
- smsw %ax
- clts
- subl $108,%esp
- fnsave 0(%esp)
- jmp i586_bz2
-
-i586_bz1:
- sarb $1,kernel_fpu_lock
- jc intreg_i586_bzero
- smsw %ax
- clts
- fninit /* XXX should avoid needing this */
-i586_bz2:
- fldz
-
- /*
- * Align to an 8 byte boundary (misalignment in the main loop would
- * cost a factor of >= 2). Avoid jumps (at little cost if it is
- * already aligned) by always zeroing 8 bytes and using the part up
- * to the _next_ alignment position.
- */
- fstl 0(%edx)
- addl %edx,%ecx /* part of %ecx -= new_%edx - %edx */
- addl $8,%edx
- andl $~7,%edx
- subl %edx,%ecx
-
- /*
- * Similarly align `len' to a multiple of 8.
- */
- fstl -8(%edx,%ecx)
- decl %ecx
- andl $~7,%ecx
-
- /*
- * This wouldn't be any faster if it were unrolled, since the loop
- * control instructions are much faster than the fstl and/or done
- * in parallel with it so their overhead is insignificant.
- */
-fpureg_i586_bzero_loop:
- fstl 0(%edx)
- addl $8,%edx
- subl $8,%ecx
- cmpl $8,%ecx
- jae fpureg_i586_bzero_loop
-
- cmpl $0,_npxproc
- je i586_bz3
- frstor 0(%esp)
- addl $108,%esp
- lmsw %ax
- movb $0xfe,kernel_fpu_lock
- ret
-
-i586_bz3:
- fstpl %st(0)
- lmsw %ax
- movb $0xfe,kernel_fpu_lock
- ret
-
-intreg_i586_bzero:
- /*
- * `rep stos' seems to be the best method in practice for small
- * counts. Fancy methods usually take too long to start up due
- * to cache and BTB misses.
- */
- pushl %edi
- movl %edx,%edi
- xorl %eax,%eax
- shrl $2,%ecx
- cld
- rep
- stosl
- movl 12(%esp),%ecx
- andl $3,%ecx
- jne 1f
- popl %edi
- ret
-
-1:
- rep
- stosb
- popl %edi
- ret
-#endif /* I586_CPU && NNPX > 0 */
-
-ENTRY(i686_pagezero)
- pushl %edi
- pushl %ebx
-
- movl 12(%esp), %edi
- movl $1024, %ecx
- cld
-
- ALIGN_TEXT
-1:
- xorl %eax, %eax
- repe
- scasl
- jnz 2f
-
- popl %ebx
- popl %edi
- ret
-
- ALIGN_TEXT
-
-2:
- incl %ecx
- subl $4, %edi
-
- movl %ecx, %edx
- cmpl $16, %ecx
-
- jge 3f
-
- movl %edi, %ebx
- andl $0x3f, %ebx
- shrl %ebx
- shrl %ebx
- movl $16, %ecx
- subl %ebx, %ecx
-
-3:
- subl %ecx, %edx
- rep
- stosl
-
- movl %edx, %ecx
- testl %edx, %edx
- jnz 1b
-
- popl %ebx
- popl %edi
- ret
-
-/* fillw(pat, base, cnt) */
-ENTRY(fillw)
- pushl %edi
- movl 8(%esp),%eax
- movl 12(%esp),%edi
- movl 16(%esp),%ecx
- cld
- rep
- stosw
- popl %edi
- ret
-
-ENTRY(bcopyb)
- pushl %esi
- pushl %edi
- movl 12(%esp),%esi
- movl 16(%esp),%edi
- movl 20(%esp),%ecx
- movl %edi,%eax
- subl %esi,%eax
- cmpl %ecx,%eax /* overlapping && src < dst? */
- jb 1f
- cld /* nope, copy forwards */
- rep
- movsb
- popl %edi
- popl %esi
- ret
-
- ALIGN_TEXT
-1:
- addl %ecx,%edi /* copy backwards. */
- addl %ecx,%esi
- decl %edi
- decl %esi
- std
- rep
- movsb
- popl %edi
- popl %esi
- cld
- ret
-
-ENTRY(bcopy)
- MEXITCOUNT
- jmp *_bcopy_vector
-
-ENTRY(ovbcopy)
- MEXITCOUNT
- jmp *_ovbcopy_vector
-
-/*
- * generic_bcopy(src, dst, cnt)
- * ws@tools.de (Wolfgang Solfrank, TooLs GmbH) +49-228-985800
- */
-ENTRY(generic_bcopy)
- pushl %esi
- pushl %edi
- movl 12(%esp),%esi
- movl 16(%esp),%edi
- movl 20(%esp),%ecx
-
- movl %edi,%eax
- subl %esi,%eax
- cmpl %ecx,%eax /* overlapping && src < dst? */
- jb 1f
-
- shrl $2,%ecx /* copy by 32-bit words */
- cld /* nope, copy forwards */
- rep
- movsl
- movl 20(%esp),%ecx
- andl $3,%ecx /* any bytes left? */
- rep
- movsb
- popl %edi
- popl %esi
- ret
-
- ALIGN_TEXT
-1:
- addl %ecx,%edi /* copy backwards */
- addl %ecx,%esi
- decl %edi
- decl %esi
- andl $3,%ecx /* any fractional bytes? */
- std
- rep
- movsb
- movl 20(%esp),%ecx /* copy remainder by 32-bit words */
- shrl $2,%ecx
- subl $3,%esi
- subl $3,%edi
- rep
- movsl
- popl %edi
- popl %esi
- cld
- ret
-
-#if defined(I586_CPU) && NNPX > 0
-ENTRY(i586_bcopy)
- pushl %esi
- pushl %edi
- movl 12(%esp),%esi
- movl 16(%esp),%edi
- movl 20(%esp),%ecx
-
- movl %edi,%eax
- subl %esi,%eax
- cmpl %ecx,%eax /* overlapping && src < dst? */
- jb 1f
-
- cmpl $1024,%ecx
- jb small_i586_bcopy
-
- sarb $1,kernel_fpu_lock
- jc small_i586_bcopy
- cmpl $0,_npxproc
- je i586_bc1
- smsw %dx
- clts
- subl $108,%esp
- fnsave 0(%esp)
- jmp 4f
-
-i586_bc1:
- smsw %dx
- clts
- fninit /* XXX should avoid needing this */
-
- ALIGN_TEXT
-4:
- pushl %ecx
-#define DCACHE_SIZE 8192
- cmpl $(DCACHE_SIZE-512)/2,%ecx
- jbe 2f
- movl $(DCACHE_SIZE-512)/2,%ecx
-2:
- subl %ecx,0(%esp)
- cmpl $256,%ecx
- jb 5f /* XXX should prefetch if %ecx >= 32 */
- pushl %esi
- pushl %ecx
- ALIGN_TEXT
-3:
- movl 0(%esi),%eax
- movl 32(%esi),%eax
- movl 64(%esi),%eax
- movl 96(%esi),%eax
- movl 128(%esi),%eax
- movl 160(%esi),%eax
- movl 192(%esi),%eax
- movl 224(%esi),%eax
- addl $256,%esi
- subl $256,%ecx
- cmpl $256,%ecx
- jae 3b
- popl %ecx
- popl %esi
-5:
- ALIGN_TEXT
-large_i586_bcopy_loop:
- fildq 0(%esi)
- fildq 8(%esi)
- fildq 16(%esi)
- fildq 24(%esi)
- fildq 32(%esi)
- fildq 40(%esi)
- fildq 48(%esi)
- fildq 56(%esi)
- fistpq 56(%edi)
- fistpq 48(%edi)
- fistpq 40(%edi)
- fistpq 32(%edi)
- fistpq 24(%edi)
- fistpq 16(%edi)
- fistpq 8(%edi)
- fistpq 0(%edi)
- addl $64,%esi
- addl $64,%edi
- subl $64,%ecx
- cmpl $64,%ecx
- jae large_i586_bcopy_loop
- popl %eax
- addl %eax,%ecx
- cmpl $64,%ecx
- jae 4b
-
- cmpl $0,_npxproc
- je i586_bc2
- frstor 0(%esp)
- addl $108,%esp
-i586_bc2:
- lmsw %dx
- movb $0xfe,kernel_fpu_lock
-
-/*
- * This is a duplicate of the main part of generic_bcopy. See the comments
- * there. Jumping into generic_bcopy would cost a whole 0-1 cycles and
- * would mess up high resolution profiling.
- */
- ALIGN_TEXT
-small_i586_bcopy:
- shrl $2,%ecx
- cld
- rep
- movsl
- movl 20(%esp),%ecx
- andl $3,%ecx
- rep
- movsb
- popl %edi
- popl %esi
- ret
-
- ALIGN_TEXT
-1:
- addl %ecx,%edi
- addl %ecx,%esi
- decl %edi
- decl %esi
- andl $3,%ecx
- std
- rep
- movsb
- movl 20(%esp),%ecx
- shrl $2,%ecx
- subl $3,%esi
- subl $3,%edi
- rep
- movsl
- popl %edi
- popl %esi
- cld
- ret
-#endif /* I586_CPU && NNPX > 0 */
-
-/*
- * Note: memcpy does not support overlapping copies
- */
-ENTRY(memcpy)
- pushl %edi
- pushl %esi
- movl 12(%esp),%edi
- movl 16(%esp),%esi
- movl 20(%esp),%ecx
- movl %edi,%eax
- shrl $2,%ecx /* copy by 32-bit words */
- cld /* nope, copy forwards */
- rep
- movsl
- movl 20(%esp),%ecx
- andl $3,%ecx /* any bytes left? */
- rep
- movsb
- popl %esi
- popl %edi
- ret
-
-
-/*****************************************************************************/
-/* copyout and fubyte family */
-/*****************************************************************************/
-/*
- * Access user memory from inside the kernel. These routines and possibly
- * the math- and DOS emulators should be the only places that do this.
- *
- * We have to access the memory with user's permissions, so use a segment
- * selector with RPL 3. For writes to user space we have to additionally
- * check the PTE for write permission, because the 386 does not check
- * write permissions when we are executing with EPL 0. The 486 does check
- * this if the WP bit is set in CR0, so we can use a simpler version here.
- *
- * These routines set curpcb->onfault for the time they execute. When a
- * protection violation occurs inside the functions, the trap handler
- * returns to *curpcb->onfault instead of the function.
- */
-
-/* copyout(from_kernel, to_user, len) */
-ENTRY(copyout)
- MEXITCOUNT
- jmp *_copyout_vector
-
-ENTRY(generic_copyout)
- movl _curpcb,%eax
- movl $copyout_fault,PCB_ONFAULT(%eax)
- pushl %esi
- pushl %edi
- pushl %ebx
- movl 16(%esp),%esi
- movl 20(%esp),%edi
- movl 24(%esp),%ebx
- testl %ebx,%ebx /* anything to do? */
- jz done_copyout
-
- /*
- * Check explicitly for non-user addresses. If 486 write protection
- * is being used, this check is essential because we are in kernel
- * mode so the h/w does not provide any protection against writing
- * kernel addresses.
- */
-
- /*
- * First, prevent address wrapping.
- */
- movl %edi,%eax
- addl %ebx,%eax
- jc copyout_fault
-/*
- * XXX STOP USING VM_MAXUSER_ADDRESS.
- * It is an end address, not a max, so every time it is used correctly it
- * looks like there is an off by one error, and of course it caused an off
- * by one error in several places.
- */
- cmpl $VM_MAXUSER_ADDRESS,%eax
- ja copyout_fault
-
-#if defined(I386_CPU)
-
-#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)
- cmpl $CPUCLASS_386,_cpu_class
- jne 3f
-#endif
-/*
- * We have to check each PTE for user write permission.
- * The checking may cause a page fault, so it is important to set
- * up everything for return via copyout_fault before here.
- */
- /* compute number of pages */
- movl %edi,%ecx
- andl $PAGE_MASK,%ecx
- addl %ebx,%ecx
- decl %ecx
- shrl $IDXSHIFT+2,%ecx
- incl %ecx
-
- /* compute PTE offset for start address */
- movl %edi,%edx
- shrl $IDXSHIFT,%edx
- andb $0xfc,%dl
-
-1:
- /* check PTE for each page */
- leal _PTmap(%edx),%eax
- shrl $IDXSHIFT,%eax
- andb $0xfc,%al
- testb $PG_V,_PTmap(%eax) /* PTE page must be valid */
- je 4f
- movb _PTmap(%edx),%al
- andb $PG_V|PG_RW|PG_U,%al /* page must be valid and user writable */
- cmpb $PG_V|PG_RW|PG_U,%al
- je 2f
-
-4:
- /* simulate a trap */
- pushl %edx
- pushl %ecx
- shll $IDXSHIFT,%edx
- pushl %edx
- call _trapwrite /* trapwrite(addr) */
- popl %edx
- popl %ecx
- popl %edx
-
- testl %eax,%eax /* if not ok, return EFAULT */
- jnz copyout_fault
-
-2:
- addl $4,%edx
- decl %ecx
- jnz 1b /* check next page */
-#endif /* I386_CPU */
-
- /* bcopy(%esi, %edi, %ebx) */
-3:
- movl %ebx,%ecx
-
-#if defined(I586_CPU) && NNPX > 0
- ALIGN_TEXT
-slow_copyout:
-#endif
- shrl $2,%ecx
- cld
- rep
- movsl
- movb %bl,%cl
- andb $3,%cl
- rep
- movsb
-
-done_copyout:
- popl %ebx
- popl %edi
- popl %esi
- xorl %eax,%eax
- movl _curpcb,%edx
- movl %eax,PCB_ONFAULT(%edx)
- ret
-
- ALIGN_TEXT
-copyout_fault:
- popl %ebx
- popl %edi
- popl %esi
- movl _curpcb,%edx
- movl $0,PCB_ONFAULT(%edx)
- movl $EFAULT,%eax
- ret
-
-#if defined(I586_CPU) && NNPX > 0
-ENTRY(i586_copyout)
- /*
- * Duplicated from generic_copyout. Could be done a bit better.
- */
- movl _curpcb,%eax
- movl $copyout_fault,PCB_ONFAULT(%eax)
- pushl %esi
- pushl %edi
- pushl %ebx
- movl 16(%esp),%esi
- movl 20(%esp),%edi
- movl 24(%esp),%ebx
- testl %ebx,%ebx /* anything to do? */
- jz done_copyout
-
- /*
- * Check explicitly for non-user addresses. If 486 write protection
- * is being used, this check is essential because we are in kernel
- * mode so the h/w does not provide any protection against writing
- * kernel addresses.
- */
-
- /*
- * First, prevent address wrapping.
- */
- movl %edi,%eax
- addl %ebx,%eax
- jc copyout_fault
-/*
- * XXX STOP USING VM_MAXUSER_ADDRESS.
- * It is an end address, not a max, so every time it is used correctly it
- * looks like there is an off by one error, and of course it caused an off
- * by one error in several places.
- */
- cmpl $VM_MAXUSER_ADDRESS,%eax
- ja copyout_fault
-
- /* bcopy(%esi, %edi, %ebx) */
-3:
- movl %ebx,%ecx
- /*
- * End of duplicated code.
- */
-
- cmpl $1024,%ecx
- jb slow_copyout
-
- pushl %ecx
- call _fastmove
- addl $4,%esp
- jmp done_copyout
-#endif /* I586_CPU && NNPX > 0 */
-
-/* copyin(from_user, to_kernel, len) */
-ENTRY(copyin)
- MEXITCOUNT
- jmp *_copyin_vector
-
-ENTRY(generic_copyin)
- movl _curpcb,%eax
- movl $copyin_fault,PCB_ONFAULT(%eax)
- pushl %esi
- pushl %edi
- movl 12(%esp),%esi /* caddr_t from */
- movl 16(%esp),%edi /* caddr_t to */
- movl 20(%esp),%ecx /* size_t len */
-
- /*
- * make sure address is valid
- */
- movl %esi,%edx
- addl %ecx,%edx
- jc copyin_fault
- cmpl $VM_MAXUSER_ADDRESS,%edx
- ja copyin_fault
-
-#if defined(I586_CPU) && NNPX > 0
- ALIGN_TEXT
-slow_copyin:
-#endif
- movb %cl,%al
- shrl $2,%ecx /* copy longword-wise */
- cld
- rep
- movsl
- movb %al,%cl
- andb $3,%cl /* copy remaining bytes */
- rep
- movsb
-
-#if defined(I586_CPU) && NNPX > 0
- ALIGN_TEXT
-done_copyin:
-#endif
- popl %edi
- popl %esi
- xorl %eax,%eax
- movl _curpcb,%edx
- movl %eax,PCB_ONFAULT(%edx)
- ret
-
- ALIGN_TEXT
-copyin_fault:
- popl %edi
- popl %esi
- movl _curpcb,%edx
- movl $0,PCB_ONFAULT(%edx)
- movl $EFAULT,%eax
- ret
-
-#if defined(I586_CPU) && NNPX > 0
-ENTRY(i586_copyin)
- /*
- * Duplicated from generic_copyin. Could be done a bit better.
- */
- movl _curpcb,%eax
- movl $copyin_fault,PCB_ONFAULT(%eax)
- pushl %esi
- pushl %edi
- movl 12(%esp),%esi /* caddr_t from */
- movl 16(%esp),%edi /* caddr_t to */
- movl 20(%esp),%ecx /* size_t len */
-
- /*
- * make sure address is valid
- */
- movl %esi,%edx
- addl %ecx,%edx
- jc copyin_fault
- cmpl $VM_MAXUSER_ADDRESS,%edx
- ja copyin_fault
- /*
- * End of duplicated code.
- */
-
- cmpl $1024,%ecx
- jb slow_copyin
-
- pushl %ebx /* XXX prepare for fastmove_fault */
- pushl %ecx
- call _fastmove
- addl $8,%esp
- jmp done_copyin
-#endif /* I586_CPU && NNPX > 0 */
-
-#if defined(I586_CPU) && NNPX > 0
-/* fastmove(src, dst, len)
- src in %esi
- dst in %edi
- len in %ecx XXX changed to on stack for profiling
- uses %eax and %edx for tmp. storage
- */
-/* XXX use ENTRY() to get profiling. fastmove() is actually a non-entry. */
-ENTRY(fastmove)
- pushl %ebp
- movl %esp,%ebp
- subl $PCB_SAVEFPU_SIZE+3*4,%esp
-
- movl 8(%ebp),%ecx
- cmpl $63,%ecx
- jbe fastmove_tail
-
- testl $7,%esi /* check if src addr is multiple of 8 */
- jnz fastmove_tail
-
- testl $7,%edi /* check if dst addr is multiple of 8 */
- jnz fastmove_tail
-
-/* if (npxproc != NULL) { */
- cmpl $0,_npxproc
- je 6f
-/* fnsave(&curpcb->pcb_savefpu); */
- movl _curpcb,%eax
- fnsave PCB_SAVEFPU(%eax)
-/* npxproc = NULL; */
- movl $0,_npxproc
-/* } */
-6:
-/* now we own the FPU. */
-
-/*
- * The process' FP state is saved in the pcb, but if we get
- * switched, the cpu_switch() will store our FP state in the
- * pcb. It should be possible to avoid all the copying for
- * this, e.g., by setting a flag to tell cpu_switch() to
- * save the state somewhere else.
- */
-/* tmp = curpcb->pcb_savefpu; */
- movl %ecx,-12(%ebp)
- movl %esi,-8(%ebp)
- movl %edi,-4(%ebp)
- movl %esp,%edi
- movl _curpcb,%esi
- addl $PCB_SAVEFPU,%esi
- cld
- movl $PCB_SAVEFPU_SIZE>>2,%ecx
- rep
- movsl
- movl -12(%ebp),%ecx
- movl -8(%ebp),%esi
- movl -4(%ebp),%edi
-/* stop_emulating(); */
- clts
-/* npxproc = curproc; */
- movl _curproc,%eax
- movl %eax,_npxproc
- movl _curpcb,%eax
- movl $fastmove_fault,PCB_ONFAULT(%eax)
-4:
- movl %ecx,-12(%ebp)
- cmpl $1792,%ecx
- jbe 2f
- movl $1792,%ecx
-2:
- subl %ecx,-12(%ebp)
- cmpl $256,%ecx
- jb 5f
- movl %ecx,-8(%ebp)
- movl %esi,-4(%ebp)
- ALIGN_TEXT
-3:
- movl 0(%esi),%eax
- movl 32(%esi),%eax
- movl 64(%esi),%eax
- movl 96(%esi),%eax
- movl 128(%esi),%eax
- movl 160(%esi),%eax
- movl 192(%esi),%eax
- movl 224(%esi),%eax
- addl $256,%esi
- subl $256,%ecx
- cmpl $256,%ecx
- jae 3b
- movl -8(%ebp),%ecx
- movl -4(%ebp),%esi
-5:
- ALIGN_TEXT
-fastmove_loop:
- fildq 0(%esi)
- fildq 8(%esi)
- fildq 16(%esi)
- fildq 24(%esi)
- fildq 32(%esi)
- fildq 40(%esi)
- fildq 48(%esi)
- fildq 56(%esi)
- fistpq 56(%edi)
- fistpq 48(%edi)
- fistpq 40(%edi)
- fistpq 32(%edi)
- fistpq 24(%edi)
- fistpq 16(%edi)
- fistpq 8(%edi)
- fistpq 0(%edi)
- addl $-64,%ecx
- addl $64,%esi
- addl $64,%edi
- cmpl $63,%ecx
- ja fastmove_loop
- movl -12(%ebp),%eax
- addl %eax,%ecx
- cmpl $64,%ecx
- jae 4b
-
-/* curpcb->pcb_savefpu = tmp; */
- movl %ecx,-12(%ebp)
- movl %esi,-8(%ebp)
- movl %edi,-4(%ebp)
- movl _curpcb,%edi
- addl $PCB_SAVEFPU,%edi
- movl %esp,%esi
- cld
- movl $PCB_SAVEFPU_SIZE>>2,%ecx
- rep
- movsl
- movl -12(%ebp),%ecx
- movl -8(%ebp),%esi
- movl -4(%ebp),%edi
-
-/* start_emulating(); */
- smsw %ax
- orb $CR0_TS,%al
- lmsw %ax
-/* npxproc = NULL; */
- movl $0,_npxproc
-
- ALIGN_TEXT
-fastmove_tail:
- movl _curpcb,%eax
- movl $fastmove_tail_fault,PCB_ONFAULT(%eax)
-
- movb %cl,%al
- shrl $2,%ecx /* copy longword-wise */
- cld
- rep
- movsl
- movb %al,%cl
- andb $3,%cl /* copy remaining bytes */
- rep
- movsb
-
- movl %ebp,%esp
- popl %ebp
- ret
-
- ALIGN_TEXT
-fastmove_fault:
- movl _curpcb,%edi
- addl $PCB_SAVEFPU,%edi
- movl %esp,%esi
- cld
- movl $PCB_SAVEFPU_SIZE>>2,%ecx
- rep
- movsl
-
- smsw %ax
- orb $CR0_TS,%al
- lmsw %ax
- movl $0,_npxproc
-
-fastmove_tail_fault:
- movl %ebp,%esp
- popl %ebp
- addl $8,%esp
- popl %ebx
- popl %edi
- popl %esi
- movl _curpcb,%edx
- movl $0,PCB_ONFAULT(%edx)
- movl $EFAULT,%eax
- ret
-#endif /* I586_CPU && NNPX > 0 */
-
-/*
- * fu{byte,sword,word} : fetch a byte (sword, word) from user memory
- */
-ENTRY(fuword)
- movl _curpcb,%ecx
- movl $fusufault,PCB_ONFAULT(%ecx)
- movl 4(%esp),%edx /* from */
-
- cmpl $VM_MAXUSER_ADDRESS-4,%edx /* verify address is valid */
- ja fusufault
-
- movl (%edx),%eax
- movl $0,PCB_ONFAULT(%ecx)
- ret
-
-/*
- * These two routines are called from the profiling code, potentially
- * at interrupt time. If they fail, that's okay, good things will
- * happen later. Fail all the time for now - until the trap code is
- * able to deal with this.
- */
-ALTENTRY(suswintr)
-ENTRY(fuswintr)
- movl $-1,%eax
- ret
-
-ENTRY(fusword)
- movl _curpcb,%ecx
- movl $fusufault,PCB_ONFAULT(%ecx)
- movl 4(%esp),%edx
-
- cmpl $VM_MAXUSER_ADDRESS-2,%edx
- ja fusufault
-
- movzwl (%edx),%eax
- movl $0,PCB_ONFAULT(%ecx)
- ret
-
-ENTRY(fubyte)
- movl _curpcb,%ecx
- movl $fusufault,PCB_ONFAULT(%ecx)
- movl 4(%esp),%edx
-
- cmpl $VM_MAXUSER_ADDRESS-1,%edx
- ja fusufault
-
- movzbl (%edx),%eax
- movl $0,PCB_ONFAULT(%ecx)
- ret
-
- ALIGN_TEXT
-fusufault:
- movl _curpcb,%ecx
- xorl %eax,%eax
- movl %eax,PCB_ONFAULT(%ecx)
- decl %eax
- ret
-
-/*
- * su{byte,sword,word}: write a byte (word, longword) to user memory
- */
-ENTRY(suword)
- movl _curpcb,%ecx
- movl $fusufault,PCB_ONFAULT(%ecx)
- movl 4(%esp),%edx
-
-#if defined(I386_CPU)
-
-#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)
- cmpl $CPUCLASS_386,_cpu_class
- jne 2f /* we only have to set the right segment selector */
-#endif /* I486_CPU || I586_CPU || I686_CPU */
-
- /* XXX - page boundary crossing is still not handled */
- movl %edx,%eax
- shrl $IDXSHIFT,%edx
- andb $0xfc,%dl
-
- leal _PTmap(%edx),%ecx
- shrl $IDXSHIFT,%ecx
- andb $0xfc,%cl
- testb $PG_V,_PTmap(%ecx) /* PTE page must be valid */
- je 4f
- movb _PTmap(%edx),%dl
- andb $PG_V|PG_RW|PG_U,%dl /* page must be valid and user writable */
- cmpb $PG_V|PG_RW|PG_U,%dl
- je 1f
-
-4:
- /* simulate a trap */
- pushl %eax
- call _trapwrite
- popl %edx /* remove junk parameter from stack */
- testl %eax,%eax
- jnz fusufault
-1:
- movl 4(%esp),%edx
-#endif
-
-2:
- cmpl $VM_MAXUSER_ADDRESS-4,%edx /* verify address validity */
- ja fusufault
-
- movl 8(%esp),%eax
- movl %eax,(%edx)
- xorl %eax,%eax
- movl _curpcb,%ecx
- movl %eax,PCB_ONFAULT(%ecx)
- ret
-
-ENTRY(susword)
- movl _curpcb,%ecx
- movl $fusufault,PCB_ONFAULT(%ecx)
- movl 4(%esp),%edx
-
-#if defined(I386_CPU)
-
-#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)
- cmpl $CPUCLASS_386,_cpu_class
- jne 2f
-#endif /* I486_CPU || I586_CPU || I686_CPU */
-
- /* XXX - page boundary crossing is still not handled */
- movl %edx,%eax
- shrl $IDXSHIFT,%edx
- andb $0xfc,%dl
-
- leal _PTmap(%edx),%ecx
- shrl $IDXSHIFT,%ecx
- andb $0xfc,%cl
- testb $PG_V,_PTmap(%ecx) /* PTE page must be valid */
- je 4f
- movb _PTmap(%edx),%dl
- andb $PG_V|PG_RW|PG_U,%dl /* page must be valid and user writable */
- cmpb $PG_V|PG_RW|PG_U,%dl
- je 1f
-
-4:
- /* simulate a trap */
- pushl %eax
- call _trapwrite
- popl %edx /* remove junk parameter from stack */
- testl %eax,%eax
- jnz fusufault
-1:
- movl 4(%esp),%edx
-#endif
-
-2:
- cmpl $VM_MAXUSER_ADDRESS-2,%edx /* verify address validity */
- ja fusufault
-
- movw 8(%esp),%ax
- movw %ax,(%edx)
- xorl %eax,%eax
- movl _curpcb,%ecx /* restore trashed register */
- movl %eax,PCB_ONFAULT(%ecx)
- ret
-
-ALTENTRY(suibyte)
-ENTRY(subyte)
- movl _curpcb,%ecx
- movl $fusufault,PCB_ONFAULT(%ecx)
- movl 4(%esp),%edx
-
-#if defined(I386_CPU)
-
-#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)
- cmpl $CPUCLASS_386,_cpu_class
- jne 2f
-#endif /* I486_CPU || I586_CPU || I686_CPU */
-
- movl %edx,%eax
- shrl $IDXSHIFT,%edx
- andb $0xfc,%dl
-
- leal _PTmap(%edx),%ecx
- shrl $IDXSHIFT,%ecx
- andb $0xfc,%cl
- testb $PG_V,_PTmap(%ecx) /* PTE page must be valid */
- je 4f
- movb _PTmap(%edx),%dl
- andb $PG_V|PG_RW|PG_U,%dl /* page must be valid and user writable */
- cmpb $PG_V|PG_RW|PG_U,%dl
- je 1f
-
-4:
- /* simulate a trap */
- pushl %eax
- call _trapwrite
- popl %edx /* remove junk parameter from stack */
- testl %eax,%eax
- jnz fusufault
-1:
- movl 4(%esp),%edx
-#endif
-
-2:
- cmpl $VM_MAXUSER_ADDRESS-1,%edx /* verify address validity */
- ja fusufault
-
- movb 8(%esp),%al
- movb %al,(%edx)
- xorl %eax,%eax
- movl _curpcb,%ecx /* restore trashed register */
- movl %eax,PCB_ONFAULT(%ecx)
- ret
-
-/*
- * copyinstr(from, to, maxlen, int *lencopied)
- * copy a string from from to to, stop when a 0 character is reached.
- * return ENAMETOOLONG if string is longer than maxlen, and
- * EFAULT on protection violations. If lencopied is non-zero,
- * return the actual length in *lencopied.
- */
-ENTRY(copyinstr)
- pushl %esi
- pushl %edi
- movl _curpcb,%ecx
- movl $cpystrflt,PCB_ONFAULT(%ecx)
-
- movl 12(%esp),%esi /* %esi = from */
- movl 16(%esp),%edi /* %edi = to */
- movl 20(%esp),%edx /* %edx = maxlen */
-
- movl $VM_MAXUSER_ADDRESS,%eax
-
- /* make sure 'from' is within bounds */
- subl %esi,%eax
- jbe cpystrflt
-
- /* restrict maxlen to <= VM_MAXUSER_ADDRESS-from */
- cmpl %edx,%eax
- jae 1f
- movl %eax,%edx
- movl %eax,20(%esp)
-1:
- incl %edx
- cld
-
-2:
- decl %edx
- jz 3f
-
- lodsb
- stosb
- orb %al,%al
- jnz 2b
-
- /* Success -- 0 byte reached */
- decl %edx
- xorl %eax,%eax
- jmp cpystrflt_x
-3:
- /* edx is zero - return ENAMETOOLONG or EFAULT */
- cmpl $VM_MAXUSER_ADDRESS,%esi
- jae cpystrflt
-4:
- movl $ENAMETOOLONG,%eax
- jmp cpystrflt_x
-
-cpystrflt:
- movl $EFAULT,%eax
-
-cpystrflt_x:
- /* set *lencopied and return %eax */
- movl _curpcb,%ecx
- movl $0,PCB_ONFAULT(%ecx)
- movl 20(%esp),%ecx
- subl %edx,%ecx
- movl 24(%esp),%edx
- testl %edx,%edx
- jz 1f
- movl %ecx,(%edx)
-1:
- popl %edi
- popl %esi
- ret
-
-
-/*
- * copystr(from, to, maxlen, int *lencopied)
- */
-ENTRY(copystr)
- pushl %esi
- pushl %edi
-
- movl 12(%esp),%esi /* %esi = from */
- movl 16(%esp),%edi /* %edi = to */
- movl 20(%esp),%edx /* %edx = maxlen */
- incl %edx
- cld
-1:
- decl %edx
- jz 4f
- lodsb
- stosb
- orb %al,%al
- jnz 1b
-
- /* Success -- 0 byte reached */
- decl %edx
- xorl %eax,%eax
- jmp 6f
-4:
- /* edx is zero -- return ENAMETOOLONG */
- movl $ENAMETOOLONG,%eax
-
-6:
- /* set *lencopied and return %eax */
- movl 20(%esp),%ecx
- subl %edx,%ecx
- movl 24(%esp),%edx
- testl %edx,%edx
- jz 7f
- movl %ecx,(%edx)
-7:
- popl %edi
- popl %esi
- ret
-
-ENTRY(bcmp)
- pushl %edi
- pushl %esi
- movl 12(%esp),%edi
- movl 16(%esp),%esi
- movl 20(%esp),%edx
- xorl %eax,%eax
-
- movl %edx,%ecx
- shrl $2,%ecx
- cld /* compare forwards */
- repe
- cmpsl
- jne 1f
-
- movl %edx,%ecx
- andl $3,%ecx
- repe
- cmpsb
- je 2f
-1:
- incl %eax
-2:
- popl %esi
- popl %edi
- ret
-
-
-/*
- * Handling of special 386 registers and descriptor tables etc
- */
-/* void lgdt(struct region_descriptor *rdp); */
-ENTRY(lgdt)
- /* reload the descriptor table */
- movl 4(%esp),%eax
- lgdt (%eax)
-
- /* flush the prefetch q */
- jmp 1f
- nop
-1:
- /* reload "stale" selectors */
- movl $KDSEL,%eax
- movl %ax,%ds
- movl %ax,%es
- movl %ax,%gs
- movl %ax,%ss
-#ifdef SMP
- movl $KPSEL,%eax
-#endif
- movl %ax,%fs
-
- /* reload code selector by turning return into intersegmental return */
- movl (%esp),%eax
- pushl %eax
- movl $KCSEL,4(%esp)
- lret
-
-/*
- * void lidt(struct region_descriptor *rdp);
- */
-ENTRY(lidt)
- movl 4(%esp),%eax
- lidt (%eax)
- ret
-
-/*
- * void lldt(u_short sel)
- */
-ENTRY(lldt)
- lldt 4(%esp)
- ret
-
-/*
- * void ltr(u_short sel)
- */
-ENTRY(ltr)
- ltr 4(%esp)
- ret
-
-/* ssdtosd(*ssdp,*sdp) */
-ENTRY(ssdtosd)
- pushl %ebx
- movl 8(%esp),%ecx
- movl 8(%ecx),%ebx
- shll $16,%ebx
- movl (%ecx),%edx
- roll $16,%edx
- movb %dh,%bl
- movb %dl,%bh
- rorl $8,%ebx
- movl 4(%ecx),%eax
- movw %ax,%dx
- andl $0xf0000,%eax
- orl %eax,%ebx
- movl 12(%esp),%ecx
- movl %edx,(%ecx)
- movl %ebx,4(%ecx)
- popl %ebx
- ret
-
-/* load_cr0(cr0) */
-ENTRY(load_cr0)
- movl 4(%esp),%eax
- movl %eax,%cr0
- ret
-
-/* rcr0() */
-ENTRY(rcr0)
- movl %cr0,%eax
- ret
-
-/* rcr3() */
-ENTRY(rcr3)
- movl %cr3,%eax
- ret
-
-/* void load_cr3(caddr_t cr3) */
-ENTRY(load_cr3)
-#if defined(SWTCH_OPTIM_STATS)
- incl _tlb_flush_count
-#endif
- movl 4(%esp),%eax
- movl %eax,%cr3
- ret
-
-/* rcr4() */
-ENTRY(rcr4)
- movl %cr4,%eax
- ret
-
-/* void load_cr4(caddr_t cr4) */
-ENTRY(load_cr4)
- movl 4(%esp),%eax
- movl %eax,%cr4
- ret
-
-/* void load_dr6(u_int dr6) */
-ENTRY(load_dr6)
- movl 4(%esp),%eax
- movl %eax,%dr6
- ret
-
-/* void reset_dbregs() */
-ENTRY(reset_dbregs)
- movl $0,%eax
- movl %eax,%dr7 /* disable all breapoints first */
- movl %eax,%dr0
- movl %eax,%dr1
- movl %eax,%dr2
- movl %eax,%dr3
- movl %eax,%dr6
- ret
-
-/*****************************************************************************/
-/* setjump, longjump */
-/*****************************************************************************/
-
-ENTRY(setjmp)
- movl 4(%esp),%eax
- movl %ebx,(%eax) /* save ebx */
- movl %esp,4(%eax) /* save esp */
- movl %ebp,8(%eax) /* save ebp */
- movl %esi,12(%eax) /* save esi */
- movl %edi,16(%eax) /* save edi */
- movl (%esp),%edx /* get rta */
- movl %edx,20(%eax) /* save eip */
- xorl %eax,%eax /* return(0); */
- ret
-
-ENTRY(longjmp)
- movl 4(%esp),%eax
- movl (%eax),%ebx /* restore ebx */
- movl 4(%eax),%esp /* restore esp */
- movl 8(%eax),%ebp /* restore ebp */
- movl 12(%eax),%esi /* restore esi */
- movl 16(%eax),%edi /* restore edi */
- movl 20(%eax),%edx /* get rta */
- movl %edx,(%esp) /* put in return frame */
- xorl %eax,%eax /* return(1); */
- incl %eax
- ret
-
-/*
- * Support for BB-profiling (gcc -a). The kernbb program will extract
- * the data from the kernel.
- */
-
- .data
- ALIGN_DATA
- .globl bbhead
-bbhead:
- .long 0
-
- .text
-NON_GPROF_ENTRY(__bb_init_func)
- movl 4(%esp),%eax
- movl $1,(%eax)
- movl bbhead,%edx
- movl %edx,16(%eax)
- movl %eax,bbhead
- .byte 0xc3 /* avoid macro for `ret' */
diff --git a/sys/amd64/amd64/support.s b/sys/amd64/amd64/support.s
deleted file mode 100644
index 394848cd047f..000000000000
--- a/sys/amd64/amd64/support.s
+++ /dev/null
@@ -1,1653 +0,0 @@
-/*-
- * Copyright (c) 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- */
-
-#include "opt_smp.h"
-#include "npx.h"
-
-#include <machine/asmacros.h>
-#include <machine/cputypes.h>
-#include <machine/pmap.h>
-#include <machine/specialreg.h>
-
-#include "assym.s"
-
-#define IDXSHIFT 10
-
- .data
- .globl _bcopy_vector
-_bcopy_vector:
- .long _generic_bcopy
- .globl _bzero
-_bzero:
- .long _generic_bzero
- .globl _copyin_vector
-_copyin_vector:
- .long _generic_copyin
- .globl _copyout_vector
-_copyout_vector:
- .long _generic_copyout
- .globl _ovbcopy_vector
-_ovbcopy_vector:
- .long _generic_bcopy
-#if defined(I586_CPU) && NNPX > 0
-kernel_fpu_lock:
- .byte 0xfe
- .space 3
-#endif
-
- .text
-
-/*
- * bcopy family
- * void bzero(void *buf, u_int len)
- */
-
-ENTRY(generic_bzero)
- pushl %edi
- movl 8(%esp),%edi
- movl 12(%esp),%ecx
- xorl %eax,%eax
- shrl $2,%ecx
- cld
- rep
- stosl
- movl 12(%esp),%ecx
- andl $3,%ecx
- rep
- stosb
- popl %edi
- ret
-
-#if defined(I486_CPU)
-ENTRY(i486_bzero)
- movl 4(%esp),%edx
- movl 8(%esp),%ecx
- xorl %eax,%eax
-/*
- * do 64 byte chunks first
- *
- * XXX this is probably over-unrolled at least for DX2's
- */
-2:
- cmpl $64,%ecx
- jb 3f
- movl %eax,(%edx)
- movl %eax,4(%edx)
- movl %eax,8(%edx)
- movl %eax,12(%edx)
- movl %eax,16(%edx)
- movl %eax,20(%edx)
- movl %eax,24(%edx)
- movl %eax,28(%edx)
- movl %eax,32(%edx)
- movl %eax,36(%edx)
- movl %eax,40(%edx)
- movl %eax,44(%edx)
- movl %eax,48(%edx)
- movl %eax,52(%edx)
- movl %eax,56(%edx)
- movl %eax,60(%edx)
- addl $64,%edx
- subl $64,%ecx
- jnz 2b
- ret
-
-/*
- * do 16 byte chunks
- */
- SUPERALIGN_TEXT
-3:
- cmpl $16,%ecx
- jb 4f
- movl %eax,(%edx)
- movl %eax,4(%edx)
- movl %eax,8(%edx)
- movl %eax,12(%edx)
- addl $16,%edx
- subl $16,%ecx
- jnz 3b
- ret
-
-/*
- * do 4 byte chunks
- */
- SUPERALIGN_TEXT
-4:
- cmpl $4,%ecx
- jb 5f
- movl %eax,(%edx)
- addl $4,%edx
- subl $4,%ecx
- jnz 4b
- ret
-
-/*
- * do 1 byte chunks
- * a jump table seems to be faster than a loop or more range reductions
- *
- * XXX need a const section for non-text
- */
- .data
-jtab:
- .long do0
- .long do1
- .long do2
- .long do3
-
- .text
- SUPERALIGN_TEXT
-5:
- jmp jtab(,%ecx,4)
-
- SUPERALIGN_TEXT
-do3:
- movw %ax,(%edx)
- movb %al,2(%edx)
- ret
-
- SUPERALIGN_TEXT
-do2:
- movw %ax,(%edx)
- ret
-
- SUPERALIGN_TEXT
-do1:
- movb %al,(%edx)
- ret
-
- SUPERALIGN_TEXT
-do0:
- ret
-#endif
-
-#if defined(I586_CPU) && NNPX > 0
-ENTRY(i586_bzero)
- movl 4(%esp),%edx
- movl 8(%esp),%ecx
-
- /*
- * The FPU register method is twice as fast as the integer register
- * method unless the target is in the L1 cache and we pre-allocate a
- * cache line for it (then the integer register method is 4-5 times
- * faster). However, we never pre-allocate cache lines, since that
- * would make the integer method 25% or more slower for the common
- * case when the target isn't in either the L1 cache or the L2 cache.
- * Thus we normally use the FPU register method unless the overhead
- * would be too large.
- */
- cmpl $256,%ecx /* empirical; clts, fninit, smsw cost a lot */
- jb intreg_i586_bzero
-
- /*
- * The FPU registers may belong to an application or to fastmove()
- * or to another invocation of bcopy() or ourself in a higher level
- * interrupt or trap handler. Preserving the registers is
- * complicated since we avoid it if possible at all levels. We
- * want to localize the complications even when that increases them.
- * Here the extra work involves preserving CR0_TS in TS.
- * `npxproc != NULL' is supposed to be the condition that all the
- * FPU resources belong to an application, but npxproc and CR0_TS
- * aren't set atomically enough for this condition to work in
- * interrupt handlers.
- *
- * Case 1: FPU registers belong to the application: we must preserve
- * the registers if we use them, so we only use the FPU register
- * method if the target size is large enough to amortize the extra
- * overhead for preserving them. CR0_TS must be preserved although
- * it is very likely to end up as set.
- *
- * Case 2: FPU registers belong to fastmove(): fastmove() currently
- * makes the registers look like they belong to an application so
- * that cpu_switch() and savectx() don't have to know about it, so
- * this case reduces to case 1.
- *
- * Case 3: FPU registers belong to the kernel: don't use the FPU
- * register method. This case is unlikely, and supporting it would
- * be more complicated and might take too much stack.
- *
- * Case 4: FPU registers don't belong to anyone: the FPU registers
- * don't need to be preserved, so we always use the FPU register
- * method. CR0_TS must be preserved although it is very likely to
- * always end up as clear.
- */
- cmpl $0,_npxproc
- je i586_bz1
- cmpl $256+184,%ecx /* empirical; not quite 2*108 more */
- jb intreg_i586_bzero
- sarb $1,kernel_fpu_lock
- jc intreg_i586_bzero
- smsw %ax
- clts
- subl $108,%esp
- fnsave 0(%esp)
- jmp i586_bz2
-
-i586_bz1:
- sarb $1,kernel_fpu_lock
- jc intreg_i586_bzero
- smsw %ax
- clts
- fninit /* XXX should avoid needing this */
-i586_bz2:
- fldz
-
- /*
- * Align to an 8 byte boundary (misalignment in the main loop would
- * cost a factor of >= 2). Avoid jumps (at little cost if it is
- * already aligned) by always zeroing 8 bytes and using the part up
- * to the _next_ alignment position.
- */
- fstl 0(%edx)
- addl %edx,%ecx /* part of %ecx -= new_%edx - %edx */
- addl $8,%edx
- andl $~7,%edx
- subl %edx,%ecx
-
- /*
- * Similarly align `len' to a multiple of 8.
- */
- fstl -8(%edx,%ecx)
- decl %ecx
- andl $~7,%ecx
-
- /*
- * This wouldn't be any faster if it were unrolled, since the loop
- * control instructions are much faster than the fstl and/or done
- * in parallel with it so their overhead is insignificant.
- */
-fpureg_i586_bzero_loop:
- fstl 0(%edx)
- addl $8,%edx
- subl $8,%ecx
- cmpl $8,%ecx
- jae fpureg_i586_bzero_loop
-
- cmpl $0,_npxproc
- je i586_bz3
- frstor 0(%esp)
- addl $108,%esp
- lmsw %ax
- movb $0xfe,kernel_fpu_lock
- ret
-
-i586_bz3:
- fstpl %st(0)
- lmsw %ax
- movb $0xfe,kernel_fpu_lock
- ret
-
-intreg_i586_bzero:
- /*
- * `rep stos' seems to be the best method in practice for small
- * counts. Fancy methods usually take too long to start up due
- * to cache and BTB misses.
- */
- pushl %edi
- movl %edx,%edi
- xorl %eax,%eax
- shrl $2,%ecx
- cld
- rep
- stosl
- movl 12(%esp),%ecx
- andl $3,%ecx
- jne 1f
- popl %edi
- ret
-
-1:
- rep
- stosb
- popl %edi
- ret
-#endif /* I586_CPU && NNPX > 0 */
-
-ENTRY(i686_pagezero)
- pushl %edi
- pushl %ebx
-
- movl 12(%esp), %edi
- movl $1024, %ecx
- cld
-
- ALIGN_TEXT
-1:
- xorl %eax, %eax
- repe
- scasl
- jnz 2f
-
- popl %ebx
- popl %edi
- ret
-
- ALIGN_TEXT
-
-2:
- incl %ecx
- subl $4, %edi
-
- movl %ecx, %edx
- cmpl $16, %ecx
-
- jge 3f
-
- movl %edi, %ebx
- andl $0x3f, %ebx
- shrl %ebx
- shrl %ebx
- movl $16, %ecx
- subl %ebx, %ecx
-
-3:
- subl %ecx, %edx
- rep
- stosl
-
- movl %edx, %ecx
- testl %edx, %edx
- jnz 1b
-
- popl %ebx
- popl %edi
- ret
-
-/* fillw(pat, base, cnt) */
-ENTRY(fillw)
- pushl %edi
- movl 8(%esp),%eax
- movl 12(%esp),%edi
- movl 16(%esp),%ecx
- cld
- rep
- stosw
- popl %edi
- ret
-
-ENTRY(bcopyb)
- pushl %esi
- pushl %edi
- movl 12(%esp),%esi
- movl 16(%esp),%edi
- movl 20(%esp),%ecx
- movl %edi,%eax
- subl %esi,%eax
- cmpl %ecx,%eax /* overlapping && src < dst? */
- jb 1f
- cld /* nope, copy forwards */
- rep
- movsb
- popl %edi
- popl %esi
- ret
-
- ALIGN_TEXT
-1:
- addl %ecx,%edi /* copy backwards. */
- addl %ecx,%esi
- decl %edi
- decl %esi
- std
- rep
- movsb
- popl %edi
- popl %esi
- cld
- ret
-
-ENTRY(bcopy)
- MEXITCOUNT
- jmp *_bcopy_vector
-
-ENTRY(ovbcopy)
- MEXITCOUNT
- jmp *_ovbcopy_vector
-
-/*
- * generic_bcopy(src, dst, cnt)
- * ws@tools.de (Wolfgang Solfrank, TooLs GmbH) +49-228-985800
- */
-ENTRY(generic_bcopy)
- pushl %esi
- pushl %edi
- movl 12(%esp),%esi
- movl 16(%esp),%edi
- movl 20(%esp),%ecx
-
- movl %edi,%eax
- subl %esi,%eax
- cmpl %ecx,%eax /* overlapping && src < dst? */
- jb 1f
-
- shrl $2,%ecx /* copy by 32-bit words */
- cld /* nope, copy forwards */
- rep
- movsl
- movl 20(%esp),%ecx
- andl $3,%ecx /* any bytes left? */
- rep
- movsb
- popl %edi
- popl %esi
- ret
-
- ALIGN_TEXT
-1:
- addl %ecx,%edi /* copy backwards */
- addl %ecx,%esi
- decl %edi
- decl %esi
- andl $3,%ecx /* any fractional bytes? */
- std
- rep
- movsb
- movl 20(%esp),%ecx /* copy remainder by 32-bit words */
- shrl $2,%ecx
- subl $3,%esi
- subl $3,%edi
- rep
- movsl
- popl %edi
- popl %esi
- cld
- ret
-
-#if defined(I586_CPU) && NNPX > 0
-ENTRY(i586_bcopy)
- pushl %esi
- pushl %edi
- movl 12(%esp),%esi
- movl 16(%esp),%edi
- movl 20(%esp),%ecx
-
- movl %edi,%eax
- subl %esi,%eax
- cmpl %ecx,%eax /* overlapping && src < dst? */
- jb 1f
-
- cmpl $1024,%ecx
- jb small_i586_bcopy
-
- sarb $1,kernel_fpu_lock
- jc small_i586_bcopy
- cmpl $0,_npxproc
- je i586_bc1
- smsw %dx
- clts
- subl $108,%esp
- fnsave 0(%esp)
- jmp 4f
-
-i586_bc1:
- smsw %dx
- clts
- fninit /* XXX should avoid needing this */
-
- ALIGN_TEXT
-4:
- pushl %ecx
-#define DCACHE_SIZE 8192
- cmpl $(DCACHE_SIZE-512)/2,%ecx
- jbe 2f
- movl $(DCACHE_SIZE-512)/2,%ecx
-2:
- subl %ecx,0(%esp)
- cmpl $256,%ecx
- jb 5f /* XXX should prefetch if %ecx >= 32 */
- pushl %esi
- pushl %ecx
- ALIGN_TEXT
-3:
- movl 0(%esi),%eax
- movl 32(%esi),%eax
- movl 64(%esi),%eax
- movl 96(%esi),%eax
- movl 128(%esi),%eax
- movl 160(%esi),%eax
- movl 192(%esi),%eax
- movl 224(%esi),%eax
- addl $256,%esi
- subl $256,%ecx
- cmpl $256,%ecx
- jae 3b
- popl %ecx
- popl %esi
-5:
- ALIGN_TEXT
-large_i586_bcopy_loop:
- fildq 0(%esi)
- fildq 8(%esi)
- fildq 16(%esi)
- fildq 24(%esi)
- fildq 32(%esi)
- fildq 40(%esi)
- fildq 48(%esi)
- fildq 56(%esi)
- fistpq 56(%edi)
- fistpq 48(%edi)
- fistpq 40(%edi)
- fistpq 32(%edi)
- fistpq 24(%edi)
- fistpq 16(%edi)
- fistpq 8(%edi)
- fistpq 0(%edi)
- addl $64,%esi
- addl $64,%edi
- subl $64,%ecx
- cmpl $64,%ecx
- jae large_i586_bcopy_loop
- popl %eax
- addl %eax,%ecx
- cmpl $64,%ecx
- jae 4b
-
- cmpl $0,_npxproc
- je i586_bc2
- frstor 0(%esp)
- addl $108,%esp
-i586_bc2:
- lmsw %dx
- movb $0xfe,kernel_fpu_lock
-
-/*
- * This is a duplicate of the main part of generic_bcopy. See the comments
- * there. Jumping into generic_bcopy would cost a whole 0-1 cycles and
- * would mess up high resolution profiling.
- */
- ALIGN_TEXT
-small_i586_bcopy:
- shrl $2,%ecx
- cld
- rep
- movsl
- movl 20(%esp),%ecx
- andl $3,%ecx
- rep
- movsb
- popl %edi
- popl %esi
- ret
-
- ALIGN_TEXT
-1:
- addl %ecx,%edi
- addl %ecx,%esi
- decl %edi
- decl %esi
- andl $3,%ecx
- std
- rep
- movsb
- movl 20(%esp),%ecx
- shrl $2,%ecx
- subl $3,%esi
- subl $3,%edi
- rep
- movsl
- popl %edi
- popl %esi
- cld
- ret
-#endif /* I586_CPU && NNPX > 0 */
-
-/*
- * Note: memcpy does not support overlapping copies
- */
-ENTRY(memcpy)
- pushl %edi
- pushl %esi
- movl 12(%esp),%edi
- movl 16(%esp),%esi
- movl 20(%esp),%ecx
- movl %edi,%eax
- shrl $2,%ecx /* copy by 32-bit words */
- cld /* nope, copy forwards */
- rep
- movsl
- movl 20(%esp),%ecx
- andl $3,%ecx /* any bytes left? */
- rep
- movsb
- popl %esi
- popl %edi
- ret
-
-
-/*****************************************************************************/
-/* copyout and fubyte family */
-/*****************************************************************************/
-/*
- * Access user memory from inside the kernel. These routines and possibly
- * the math- and DOS emulators should be the only places that do this.
- *
- * We have to access the memory with user's permissions, so use a segment
- * selector with RPL 3. For writes to user space we have to additionally
- * check the PTE for write permission, because the 386 does not check
- * write permissions when we are executing with EPL 0. The 486 does check
- * this if the WP bit is set in CR0, so we can use a simpler version here.
- *
- * These routines set curpcb->onfault for the time they execute. When a
- * protection violation occurs inside the functions, the trap handler
- * returns to *curpcb->onfault instead of the function.
- */
-
-/* copyout(from_kernel, to_user, len) */
-ENTRY(copyout)
- MEXITCOUNT
- jmp *_copyout_vector
-
-ENTRY(generic_copyout)
- movl _curpcb,%eax
- movl $copyout_fault,PCB_ONFAULT(%eax)
- pushl %esi
- pushl %edi
- pushl %ebx
- movl 16(%esp),%esi
- movl 20(%esp),%edi
- movl 24(%esp),%ebx
- testl %ebx,%ebx /* anything to do? */
- jz done_copyout
-
- /*
- * Check explicitly for non-user addresses. If 486 write protection
- * is being used, this check is essential because we are in kernel
- * mode so the h/w does not provide any protection against writing
- * kernel addresses.
- */
-
- /*
- * First, prevent address wrapping.
- */
- movl %edi,%eax
- addl %ebx,%eax
- jc copyout_fault
-/*
- * XXX STOP USING VM_MAXUSER_ADDRESS.
- * It is an end address, not a max, so every time it is used correctly it
- * looks like there is an off by one error, and of course it caused an off
- * by one error in several places.
- */
- cmpl $VM_MAXUSER_ADDRESS,%eax
- ja copyout_fault
-
-#if defined(I386_CPU)
-
-#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)
- cmpl $CPUCLASS_386,_cpu_class
- jne 3f
-#endif
-/*
- * We have to check each PTE for user write permission.
- * The checking may cause a page fault, so it is important to set
- * up everything for return via copyout_fault before here.
- */
- /* compute number of pages */
- movl %edi,%ecx
- andl $PAGE_MASK,%ecx
- addl %ebx,%ecx
- decl %ecx
- shrl $IDXSHIFT+2,%ecx
- incl %ecx
-
- /* compute PTE offset for start address */
- movl %edi,%edx
- shrl $IDXSHIFT,%edx
- andb $0xfc,%dl
-
-1:
- /* check PTE for each page */
- leal _PTmap(%edx),%eax
- shrl $IDXSHIFT,%eax
- andb $0xfc,%al
- testb $PG_V,_PTmap(%eax) /* PTE page must be valid */
- je 4f
- movb _PTmap(%edx),%al
- andb $PG_V|PG_RW|PG_U,%al /* page must be valid and user writable */
- cmpb $PG_V|PG_RW|PG_U,%al
- je 2f
-
-4:
- /* simulate a trap */
- pushl %edx
- pushl %ecx
- shll $IDXSHIFT,%edx
- pushl %edx
- call _trapwrite /* trapwrite(addr) */
- popl %edx
- popl %ecx
- popl %edx
-
- testl %eax,%eax /* if not ok, return EFAULT */
- jnz copyout_fault
-
-2:
- addl $4,%edx
- decl %ecx
- jnz 1b /* check next page */
-#endif /* I386_CPU */
-
- /* bcopy(%esi, %edi, %ebx) */
-3:
- movl %ebx,%ecx
-
-#if defined(I586_CPU) && NNPX > 0
- ALIGN_TEXT
-slow_copyout:
-#endif
- shrl $2,%ecx
- cld
- rep
- movsl
- movb %bl,%cl
- andb $3,%cl
- rep
- movsb
-
-done_copyout:
- popl %ebx
- popl %edi
- popl %esi
- xorl %eax,%eax
- movl _curpcb,%edx
- movl %eax,PCB_ONFAULT(%edx)
- ret
-
- ALIGN_TEXT
-copyout_fault:
- popl %ebx
- popl %edi
- popl %esi
- movl _curpcb,%edx
- movl $0,PCB_ONFAULT(%edx)
- movl $EFAULT,%eax
- ret
-
-#if defined(I586_CPU) && NNPX > 0
-ENTRY(i586_copyout)
- /*
- * Duplicated from generic_copyout. Could be done a bit better.
- */
- movl _curpcb,%eax
- movl $copyout_fault,PCB_ONFAULT(%eax)
- pushl %esi
- pushl %edi
- pushl %ebx
- movl 16(%esp),%esi
- movl 20(%esp),%edi
- movl 24(%esp),%ebx
- testl %ebx,%ebx /* anything to do? */
- jz done_copyout
-
- /*
- * Check explicitly for non-user addresses. If 486 write protection
- * is being used, this check is essential because we are in kernel
- * mode so the h/w does not provide any protection against writing
- * kernel addresses.
- */
-
- /*
- * First, prevent address wrapping.
- */
- movl %edi,%eax
- addl %ebx,%eax
- jc copyout_fault
-/*
- * XXX STOP USING VM_MAXUSER_ADDRESS.
- * It is an end address, not a max, so every time it is used correctly it
- * looks like there is an off by one error, and of course it caused an off
- * by one error in several places.
- */
- cmpl $VM_MAXUSER_ADDRESS,%eax
- ja copyout_fault
-
- /* bcopy(%esi, %edi, %ebx) */
-3:
- movl %ebx,%ecx
- /*
- * End of duplicated code.
- */
-
- cmpl $1024,%ecx
- jb slow_copyout
-
- pushl %ecx
- call _fastmove
- addl $4,%esp
- jmp done_copyout
-#endif /* I586_CPU && NNPX > 0 */
-
-/* copyin(from_user, to_kernel, len) */
-ENTRY(copyin)
- MEXITCOUNT
- jmp *_copyin_vector
-
-ENTRY(generic_copyin)
- movl _curpcb,%eax
- movl $copyin_fault,PCB_ONFAULT(%eax)
- pushl %esi
- pushl %edi
- movl 12(%esp),%esi /* caddr_t from */
- movl 16(%esp),%edi /* caddr_t to */
- movl 20(%esp),%ecx /* size_t len */
-
- /*
- * make sure address is valid
- */
- movl %esi,%edx
- addl %ecx,%edx
- jc copyin_fault
- cmpl $VM_MAXUSER_ADDRESS,%edx
- ja copyin_fault
-
-#if defined(I586_CPU) && NNPX > 0
- ALIGN_TEXT
-slow_copyin:
-#endif
- movb %cl,%al
- shrl $2,%ecx /* copy longword-wise */
- cld
- rep
- movsl
- movb %al,%cl
- andb $3,%cl /* copy remaining bytes */
- rep
- movsb
-
-#if defined(I586_CPU) && NNPX > 0
- ALIGN_TEXT
-done_copyin:
-#endif
- popl %edi
- popl %esi
- xorl %eax,%eax
- movl _curpcb,%edx
- movl %eax,PCB_ONFAULT(%edx)
- ret
-
- ALIGN_TEXT
-copyin_fault:
- popl %edi
- popl %esi
- movl _curpcb,%edx
- movl $0,PCB_ONFAULT(%edx)
- movl $EFAULT,%eax
- ret
-
-#if defined(I586_CPU) && NNPX > 0
-ENTRY(i586_copyin)
- /*
- * Duplicated from generic_copyin. Could be done a bit better.
- */
- movl _curpcb,%eax
- movl $copyin_fault,PCB_ONFAULT(%eax)
- pushl %esi
- pushl %edi
- movl 12(%esp),%esi /* caddr_t from */
- movl 16(%esp),%edi /* caddr_t to */
- movl 20(%esp),%ecx /* size_t len */
-
- /*
- * make sure address is valid
- */
- movl %esi,%edx
- addl %ecx,%edx
- jc copyin_fault
- cmpl $VM_MAXUSER_ADDRESS,%edx
- ja copyin_fault
- /*
- * End of duplicated code.
- */
-
- cmpl $1024,%ecx
- jb slow_copyin
-
- pushl %ebx /* XXX prepare for fastmove_fault */
- pushl %ecx
- call _fastmove
- addl $8,%esp
- jmp done_copyin
-#endif /* I586_CPU && NNPX > 0 */
-
-#if defined(I586_CPU) && NNPX > 0
-/* fastmove(src, dst, len)
- src in %esi
- dst in %edi
- len in %ecx XXX changed to on stack for profiling
- uses %eax and %edx for tmp. storage
- */
-/* XXX use ENTRY() to get profiling. fastmove() is actually a non-entry. */
-ENTRY(fastmove)
- pushl %ebp
- movl %esp,%ebp
- subl $PCB_SAVEFPU_SIZE+3*4,%esp
-
- movl 8(%ebp),%ecx
- cmpl $63,%ecx
- jbe fastmove_tail
-
- testl $7,%esi /* check if src addr is multiple of 8 */
- jnz fastmove_tail
-
- testl $7,%edi /* check if dst addr is multiple of 8 */
- jnz fastmove_tail
-
-/* if (npxproc != NULL) { */
- cmpl $0,_npxproc
- je 6f
-/* fnsave(&curpcb->pcb_savefpu); */
- movl _curpcb,%eax
- fnsave PCB_SAVEFPU(%eax)
-/* npxproc = NULL; */
- movl $0,_npxproc
-/* } */
-6:
-/* now we own the FPU. */
-
-/*
- * The process' FP state is saved in the pcb, but if we get
- * switched, the cpu_switch() will store our FP state in the
- * pcb. It should be possible to avoid all the copying for
- * this, e.g., by setting a flag to tell cpu_switch() to
- * save the state somewhere else.
- */
-/* tmp = curpcb->pcb_savefpu; */
- movl %ecx,-12(%ebp)
- movl %esi,-8(%ebp)
- movl %edi,-4(%ebp)
- movl %esp,%edi
- movl _curpcb,%esi
- addl $PCB_SAVEFPU,%esi
- cld
- movl $PCB_SAVEFPU_SIZE>>2,%ecx
- rep
- movsl
- movl -12(%ebp),%ecx
- movl -8(%ebp),%esi
- movl -4(%ebp),%edi
-/* stop_emulating(); */
- clts
-/* npxproc = curproc; */
- movl _curproc,%eax
- movl %eax,_npxproc
- movl _curpcb,%eax
- movl $fastmove_fault,PCB_ONFAULT(%eax)
-4:
- movl %ecx,-12(%ebp)
- cmpl $1792,%ecx
- jbe 2f
- movl $1792,%ecx
-2:
- subl %ecx,-12(%ebp)
- cmpl $256,%ecx
- jb 5f
- movl %ecx,-8(%ebp)
- movl %esi,-4(%ebp)
- ALIGN_TEXT
-3:
- movl 0(%esi),%eax
- movl 32(%esi),%eax
- movl 64(%esi),%eax
- movl 96(%esi),%eax
- movl 128(%esi),%eax
- movl 160(%esi),%eax
- movl 192(%esi),%eax
- movl 224(%esi),%eax
- addl $256,%esi
- subl $256,%ecx
- cmpl $256,%ecx
- jae 3b
- movl -8(%ebp),%ecx
- movl -4(%ebp),%esi
-5:
- ALIGN_TEXT
-fastmove_loop:
- fildq 0(%esi)
- fildq 8(%esi)
- fildq 16(%esi)
- fildq 24(%esi)
- fildq 32(%esi)
- fildq 40(%esi)
- fildq 48(%esi)
- fildq 56(%esi)
- fistpq 56(%edi)
- fistpq 48(%edi)
- fistpq 40(%edi)
- fistpq 32(%edi)
- fistpq 24(%edi)
- fistpq 16(%edi)
- fistpq 8(%edi)
- fistpq 0(%edi)
- addl $-64,%ecx
- addl $64,%esi
- addl $64,%edi
- cmpl $63,%ecx
- ja fastmove_loop
- movl -12(%ebp),%eax
- addl %eax,%ecx
- cmpl $64,%ecx
- jae 4b
-
-/* curpcb->pcb_savefpu = tmp; */
- movl %ecx,-12(%ebp)
- movl %esi,-8(%ebp)
- movl %edi,-4(%ebp)
- movl _curpcb,%edi
- addl $PCB_SAVEFPU,%edi
- movl %esp,%esi
- cld
- movl $PCB_SAVEFPU_SIZE>>2,%ecx
- rep
- movsl
- movl -12(%ebp),%ecx
- movl -8(%ebp),%esi
- movl -4(%ebp),%edi
-
-/* start_emulating(); */
- smsw %ax
- orb $CR0_TS,%al
- lmsw %ax
-/* npxproc = NULL; */
- movl $0,_npxproc
-
- ALIGN_TEXT
-fastmove_tail:
- movl _curpcb,%eax
- movl $fastmove_tail_fault,PCB_ONFAULT(%eax)
-
- movb %cl,%al
- shrl $2,%ecx /* copy longword-wise */
- cld
- rep
- movsl
- movb %al,%cl
- andb $3,%cl /* copy remaining bytes */
- rep
- movsb
-
- movl %ebp,%esp
- popl %ebp
- ret
-
- ALIGN_TEXT
-fastmove_fault:
- movl _curpcb,%edi
- addl $PCB_SAVEFPU,%edi
- movl %esp,%esi
- cld
- movl $PCB_SAVEFPU_SIZE>>2,%ecx
- rep
- movsl
-
- smsw %ax
- orb $CR0_TS,%al
- lmsw %ax
- movl $0,_npxproc
-
-fastmove_tail_fault:
- movl %ebp,%esp
- popl %ebp
- addl $8,%esp
- popl %ebx
- popl %edi
- popl %esi
- movl _curpcb,%edx
- movl $0,PCB_ONFAULT(%edx)
- movl $EFAULT,%eax
- ret
-#endif /* I586_CPU && NNPX > 0 */
-
-/*
- * fu{byte,sword,word} : fetch a byte (sword, word) from user memory
- */
-ENTRY(fuword)
- movl _curpcb,%ecx
- movl $fusufault,PCB_ONFAULT(%ecx)
- movl 4(%esp),%edx /* from */
-
- cmpl $VM_MAXUSER_ADDRESS-4,%edx /* verify address is valid */
- ja fusufault
-
- movl (%edx),%eax
- movl $0,PCB_ONFAULT(%ecx)
- ret
-
-/*
- * These two routines are called from the profiling code, potentially
- * at interrupt time. If they fail, that's okay, good things will
- * happen later. Fail all the time for now - until the trap code is
- * able to deal with this.
- */
-ALTENTRY(suswintr)
-ENTRY(fuswintr)
- movl $-1,%eax
- ret
-
-ENTRY(fusword)
- movl _curpcb,%ecx
- movl $fusufault,PCB_ONFAULT(%ecx)
- movl 4(%esp),%edx
-
- cmpl $VM_MAXUSER_ADDRESS-2,%edx
- ja fusufault
-
- movzwl (%edx),%eax
- movl $0,PCB_ONFAULT(%ecx)
- ret
-
-ENTRY(fubyte)
- movl _curpcb,%ecx
- movl $fusufault,PCB_ONFAULT(%ecx)
- movl 4(%esp),%edx
-
- cmpl $VM_MAXUSER_ADDRESS-1,%edx
- ja fusufault
-
- movzbl (%edx),%eax
- movl $0,PCB_ONFAULT(%ecx)
- ret
-
- ALIGN_TEXT
-fusufault:
- movl _curpcb,%ecx
- xorl %eax,%eax
- movl %eax,PCB_ONFAULT(%ecx)
- decl %eax
- ret
-
-/*
- * su{byte,sword,word}: write a byte (word, longword) to user memory
- */
-ENTRY(suword)
- movl _curpcb,%ecx
- movl $fusufault,PCB_ONFAULT(%ecx)
- movl 4(%esp),%edx
-
-#if defined(I386_CPU)
-
-#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)
- cmpl $CPUCLASS_386,_cpu_class
- jne 2f /* we only have to set the right segment selector */
-#endif /* I486_CPU || I586_CPU || I686_CPU */
-
- /* XXX - page boundary crossing is still not handled */
- movl %edx,%eax
- shrl $IDXSHIFT,%edx
- andb $0xfc,%dl
-
- leal _PTmap(%edx),%ecx
- shrl $IDXSHIFT,%ecx
- andb $0xfc,%cl
- testb $PG_V,_PTmap(%ecx) /* PTE page must be valid */
- je 4f
- movb _PTmap(%edx),%dl
- andb $PG_V|PG_RW|PG_U,%dl /* page must be valid and user writable */
- cmpb $PG_V|PG_RW|PG_U,%dl
- je 1f
-
-4:
- /* simulate a trap */
- pushl %eax
- call _trapwrite
- popl %edx /* remove junk parameter from stack */
- testl %eax,%eax
- jnz fusufault
-1:
- movl 4(%esp),%edx
-#endif
-
-2:
- cmpl $VM_MAXUSER_ADDRESS-4,%edx /* verify address validity */
- ja fusufault
-
- movl 8(%esp),%eax
- movl %eax,(%edx)
- xorl %eax,%eax
- movl _curpcb,%ecx
- movl %eax,PCB_ONFAULT(%ecx)
- ret
-
-ENTRY(susword)
- movl _curpcb,%ecx
- movl $fusufault,PCB_ONFAULT(%ecx)
- movl 4(%esp),%edx
-
-#if defined(I386_CPU)
-
-#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)
- cmpl $CPUCLASS_386,_cpu_class
- jne 2f
-#endif /* I486_CPU || I586_CPU || I686_CPU */
-
- /* XXX - page boundary crossing is still not handled */
- movl %edx,%eax
- shrl $IDXSHIFT,%edx
- andb $0xfc,%dl
-
- leal _PTmap(%edx),%ecx
- shrl $IDXSHIFT,%ecx
- andb $0xfc,%cl
- testb $PG_V,_PTmap(%ecx) /* PTE page must be valid */
- je 4f
- movb _PTmap(%edx),%dl
- andb $PG_V|PG_RW|PG_U,%dl /* page must be valid and user writable */
- cmpb $PG_V|PG_RW|PG_U,%dl
- je 1f
-
-4:
- /* simulate a trap */
- pushl %eax
- call _trapwrite
- popl %edx /* remove junk parameter from stack */
- testl %eax,%eax
- jnz fusufault
-1:
- movl 4(%esp),%edx
-#endif
-
-2:
- cmpl $VM_MAXUSER_ADDRESS-2,%edx /* verify address validity */
- ja fusufault
-
- movw 8(%esp),%ax
- movw %ax,(%edx)
- xorl %eax,%eax
- movl _curpcb,%ecx /* restore trashed register */
- movl %eax,PCB_ONFAULT(%ecx)
- ret
-
-ALTENTRY(suibyte)
-ENTRY(subyte)
- movl _curpcb,%ecx
- movl $fusufault,PCB_ONFAULT(%ecx)
- movl 4(%esp),%edx
-
-#if defined(I386_CPU)
-
-#if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)
- cmpl $CPUCLASS_386,_cpu_class
- jne 2f
-#endif /* I486_CPU || I586_CPU || I686_CPU */
-
- movl %edx,%eax
- shrl $IDXSHIFT,%edx
- andb $0xfc,%dl
-
- leal _PTmap(%edx),%ecx
- shrl $IDXSHIFT,%ecx
- andb $0xfc,%cl
- testb $PG_V,_PTmap(%ecx) /* PTE page must be valid */
- je 4f
- movb _PTmap(%edx),%dl
- andb $PG_V|PG_RW|PG_U,%dl /* page must be valid and user writable */
- cmpb $PG_V|PG_RW|PG_U,%dl
- je 1f
-
-4:
- /* simulate a trap */
- pushl %eax
- call _trapwrite
- popl %edx /* remove junk parameter from stack */
- testl %eax,%eax
- jnz fusufault
-1:
- movl 4(%esp),%edx
-#endif
-
-2:
- cmpl $VM_MAXUSER_ADDRESS-1,%edx /* verify address validity */
- ja fusufault
-
- movb 8(%esp),%al
- movb %al,(%edx)
- xorl %eax,%eax
- movl _curpcb,%ecx /* restore trashed register */
- movl %eax,PCB_ONFAULT(%ecx)
- ret
-
-/*
- * copyinstr(from, to, maxlen, int *lencopied)
- * copy a string from from to to, stop when a 0 character is reached.
- * return ENAMETOOLONG if string is longer than maxlen, and
- * EFAULT on protection violations. If lencopied is non-zero,
- * return the actual length in *lencopied.
- */
-ENTRY(copyinstr)
- pushl %esi
- pushl %edi
- movl _curpcb,%ecx
- movl $cpystrflt,PCB_ONFAULT(%ecx)
-
- movl 12(%esp),%esi /* %esi = from */
- movl 16(%esp),%edi /* %edi = to */
- movl 20(%esp),%edx /* %edx = maxlen */
-
- movl $VM_MAXUSER_ADDRESS,%eax
-
- /* make sure 'from' is within bounds */
- subl %esi,%eax
- jbe cpystrflt
-
- /* restrict maxlen to <= VM_MAXUSER_ADDRESS-from */
- cmpl %edx,%eax
- jae 1f
- movl %eax,%edx
- movl %eax,20(%esp)
-1:
- incl %edx
- cld
-
-2:
- decl %edx
- jz 3f
-
- lodsb
- stosb
- orb %al,%al
- jnz 2b
-
- /* Success -- 0 byte reached */
- decl %edx
- xorl %eax,%eax
- jmp cpystrflt_x
-3:
- /* edx is zero - return ENAMETOOLONG or EFAULT */
- cmpl $VM_MAXUSER_ADDRESS,%esi
- jae cpystrflt
-4:
- movl $ENAMETOOLONG,%eax
- jmp cpystrflt_x
-
-cpystrflt:
- movl $EFAULT,%eax
-
-cpystrflt_x:
- /* set *lencopied and return %eax */
- movl _curpcb,%ecx
- movl $0,PCB_ONFAULT(%ecx)
- movl 20(%esp),%ecx
- subl %edx,%ecx
- movl 24(%esp),%edx
- testl %edx,%edx
- jz 1f
- movl %ecx,(%edx)
-1:
- popl %edi
- popl %esi
- ret
-
-
-/*
- * copystr(from, to, maxlen, int *lencopied)
- */
-ENTRY(copystr)
- pushl %esi
- pushl %edi
-
- movl 12(%esp),%esi /* %esi = from */
- movl 16(%esp),%edi /* %edi = to */
- movl 20(%esp),%edx /* %edx = maxlen */
- incl %edx
- cld
-1:
- decl %edx
- jz 4f
- lodsb
- stosb
- orb %al,%al
- jnz 1b
-
- /* Success -- 0 byte reached */
- decl %edx
- xorl %eax,%eax
- jmp 6f
-4:
- /* edx is zero -- return ENAMETOOLONG */
- movl $ENAMETOOLONG,%eax
-
-6:
- /* set *lencopied and return %eax */
- movl 20(%esp),%ecx
- subl %edx,%ecx
- movl 24(%esp),%edx
- testl %edx,%edx
- jz 7f
- movl %ecx,(%edx)
-7:
- popl %edi
- popl %esi
- ret
-
-ENTRY(bcmp)
- pushl %edi
- pushl %esi
- movl 12(%esp),%edi
- movl 16(%esp),%esi
- movl 20(%esp),%edx
- xorl %eax,%eax
-
- movl %edx,%ecx
- shrl $2,%ecx
- cld /* compare forwards */
- repe
- cmpsl
- jne 1f
-
- movl %edx,%ecx
- andl $3,%ecx
- repe
- cmpsb
- je 2f
-1:
- incl %eax
-2:
- popl %esi
- popl %edi
- ret
-
-
-/*
- * Handling of special 386 registers and descriptor tables etc
- */
-/* void lgdt(struct region_descriptor *rdp); */
-ENTRY(lgdt)
- /* reload the descriptor table */
- movl 4(%esp),%eax
- lgdt (%eax)
-
- /* flush the prefetch q */
- jmp 1f
- nop
-1:
- /* reload "stale" selectors */
- movl $KDSEL,%eax
- movl %ax,%ds
- movl %ax,%es
- movl %ax,%gs
- movl %ax,%ss
-#ifdef SMP
- movl $KPSEL,%eax
-#endif
- movl %ax,%fs
-
- /* reload code selector by turning return into intersegmental return */
- movl (%esp),%eax
- pushl %eax
- movl $KCSEL,4(%esp)
- lret
-
-/*
- * void lidt(struct region_descriptor *rdp);
- */
-ENTRY(lidt)
- movl 4(%esp),%eax
- lidt (%eax)
- ret
-
-/*
- * void lldt(u_short sel)
- */
-ENTRY(lldt)
- lldt 4(%esp)
- ret
-
-/*
- * void ltr(u_short sel)
- */
-ENTRY(ltr)
- ltr 4(%esp)
- ret
-
-/* ssdtosd(*ssdp,*sdp) */
-ENTRY(ssdtosd)
- pushl %ebx
- movl 8(%esp),%ecx
- movl 8(%ecx),%ebx
- shll $16,%ebx
- movl (%ecx),%edx
- roll $16,%edx
- movb %dh,%bl
- movb %dl,%bh
- rorl $8,%ebx
- movl 4(%ecx),%eax
- movw %ax,%dx
- andl $0xf0000,%eax
- orl %eax,%ebx
- movl 12(%esp),%ecx
- movl %edx,(%ecx)
- movl %ebx,4(%ecx)
- popl %ebx
- ret
-
-/* load_cr0(cr0) */
-ENTRY(load_cr0)
- movl 4(%esp),%eax
- movl %eax,%cr0
- ret
-
-/* rcr0() */
-ENTRY(rcr0)
- movl %cr0,%eax
- ret
-
-/* rcr3() */
-ENTRY(rcr3)
- movl %cr3,%eax
- ret
-
-/* void load_cr3(caddr_t cr3) */
-ENTRY(load_cr3)
-#if defined(SWTCH_OPTIM_STATS)
- incl _tlb_flush_count
-#endif
- movl 4(%esp),%eax
- movl %eax,%cr3
- ret
-
-/* rcr4() */
-ENTRY(rcr4)
- movl %cr4,%eax
- ret
-
-/* void load_cr4(caddr_t cr4) */
-ENTRY(load_cr4)
- movl 4(%esp),%eax
- movl %eax,%cr4
- ret
-
-/* void load_dr6(u_int dr6) */
-ENTRY(load_dr6)
- movl 4(%esp),%eax
- movl %eax,%dr6
- ret
-
-/* void reset_dbregs() */
-ENTRY(reset_dbregs)
- movl $0,%eax
- movl %eax,%dr7 /* disable all breapoints first */
- movl %eax,%dr0
- movl %eax,%dr1
- movl %eax,%dr2
- movl %eax,%dr3
- movl %eax,%dr6
- ret
-
-/*****************************************************************************/
-/* setjump, longjump */
-/*****************************************************************************/
-
-ENTRY(setjmp)
- movl 4(%esp),%eax
- movl %ebx,(%eax) /* save ebx */
- movl %esp,4(%eax) /* save esp */
- movl %ebp,8(%eax) /* save ebp */
- movl %esi,12(%eax) /* save esi */
- movl %edi,16(%eax) /* save edi */
- movl (%esp),%edx /* get rta */
- movl %edx,20(%eax) /* save eip */
- xorl %eax,%eax /* return(0); */
- ret
-
-ENTRY(longjmp)
- movl 4(%esp),%eax
- movl (%eax),%ebx /* restore ebx */
- movl 4(%eax),%esp /* restore esp */
- movl 8(%eax),%ebp /* restore ebp */
- movl 12(%eax),%esi /* restore esi */
- movl 16(%eax),%edi /* restore edi */
- movl 20(%eax),%edx /* get rta */
- movl %edx,(%esp) /* put in return frame */
- xorl %eax,%eax /* return(1); */
- incl %eax
- ret
-
-/*
- * Support for BB-profiling (gcc -a). The kernbb program will extract
- * the data from the kernel.
- */
-
- .data
- ALIGN_DATA
- .globl bbhead
-bbhead:
- .long 0
-
- .text
-NON_GPROF_ENTRY(__bb_init_func)
- movl 4(%esp),%eax
- movl $1,(%eax)
- movl bbhead,%edx
- movl %edx,16(%eax)
- movl %eax,bbhead
- .byte 0xc3 /* avoid macro for `ret' */
diff --git a/sys/amd64/amd64/swtch.s b/sys/amd64/amd64/swtch.s
deleted file mode 100644
index f3982ae688f0..000000000000
--- a/sys/amd64/amd64/swtch.s
+++ /dev/null
@@ -1,578 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- */
-
-#include "npx.h"
-#include "opt_user_ldt.h"
-
-#include <sys/rtprio.h>
-
-#include <machine/asmacros.h>
-
-#ifdef SMP
-#include <machine/pmap.h>
-#include <machine/apic.h>
-#include <machine/smptests.h> /** GRAB_LOPRIO */
-#include <machine/ipl.h>
-#include <machine/lock.h>
-#endif /* SMP */
-
-#include "assym.s"
-
-
-/*****************************************************************************/
-/* Scheduling */
-/*****************************************************************************/
-
- .data
-
- .globl _hlt_vector
-_hlt_vector: .long _default_halt /* pointer to halt routine */
-
- .globl _panic
-
- .globl _want_resched
-_want_resched: .long 0 /* we need to re-run the scheduler */
-#if defined(SWTCH_OPTIM_STATS)
- .globl _swtch_optim_stats, _tlb_flush_count
-_swtch_optim_stats: .long 0 /* number of _swtch_optims */
-_tlb_flush_count: .long 0
-#endif
-
- .text
-
-/*
- * When no processes are on the runq, cpu_switch() branches to _idle
- * to wait for something to come ready.
- */
- ALIGN_TEXT
- .type _idle,@function
-_idle:
- xorl %ebp,%ebp
- movl %ebp,_switchtime
-
-#ifdef SMP
-
- /* when called, we have the mplock, intr disabled */
- /* use our idleproc's "context" */
- movl _IdlePTD, %ecx
- movl %cr3, %eax
- cmpl %ecx, %eax
- je 2f
-#if defined(SWTCH_OPTIM_STATS)
- decl _swtch_optim_stats
- incl _tlb_flush_count
-#endif
- movl %ecx, %cr3
-2:
- /* Keep space for nonexisting return addr, or profiling bombs */
- movl $gd_idlestack_top-4, %ecx
- addl %fs:0, %ecx
- movl %ecx, %esp
-
- /* update common_tss.tss_esp0 pointer */
- movl %ecx, _common_tss + TSS_ESP0
-
- movl _cpuid, %esi
- btrl %esi, _private_tss
- jae 1f
-
- movl $gd_common_tssd, %edi
- addl %fs:0, %edi
-
- /* move correct tss descriptor into GDT slot, then reload tr */
- movl _tss_gdt, %ebx /* entry in GDT */
- movl 0(%edi), %eax
- movl %eax, 0(%ebx)
- movl 4(%edi), %eax
- movl %eax, 4(%ebx)
- movl $GPROC0_SEL*8, %esi /* GSEL(entry, SEL_KPL) */
- ltr %si
-1:
-
- sti
-
- /*
- * XXX callers of cpu_switch() do a bogus splclock(). Locking should
- * be left to cpu_switch().
- */
- call _spl0
-
- cli
-
- /*
- * _REALLY_ free the lock, no matter how deep the prior nesting.
- * We will recover the nesting on the way out when we have a new
- * proc to load.
- *
- * XXX: we had damn well better be sure we had it before doing this!
- */
- movl $FREE_LOCK, %eax
- movl %eax, _mp_lock
-
- /* do NOT have lock, intrs disabled */
- .globl idle_loop
-idle_loop:
-
- cmpl $0,_smp_active
- jne 1f
- cmpl $0,_cpuid
- je 1f
- jmp 2f
-
-1:
- call _procrunnable
- testl %eax,%eax
- jnz 3f
-
- cmpl $0,_do_page_zero_idle
- je 2f
-
- /* XXX appears to cause panics */
- /*
- * Inside zero_idle we enable interrupts and grab the mplock
- * as needed. It needs to be careful about entry/exit mutexes.
- */
- call _vm_page_zero_idle /* internal locking */
- testl %eax, %eax
- jnz idle_loop
-2:
-
- /* enable intrs for a halt */
- movl $0, lapic_tpr /* 1st candidate for an INT */
- call *_hlt_vector /* wait for interrupt */
- cli
- jmp idle_loop
-
-3:
- movl $LOPRIO_LEVEL, lapic_tpr /* arbitrate for INTs */
- call _get_mplock
- call _procrunnable
- testl %eax,%eax
- CROSSJUMP(jnz, sw1a, jz)
- call _rel_mplock
- jmp idle_loop
-
-#else /* !SMP */
-
- movl $HIDENAME(tmpstk),%esp
-#if defined(OVERLY_CONSERVATIVE_PTD_MGMT)
-#if defined(SWTCH_OPTIM_STATS)
- incl _swtch_optim_stats
-#endif
- movl _IdlePTD, %ecx
- movl %cr3, %eax
- cmpl %ecx, %eax
- je 2f
-#if defined(SWTCH_OPTIM_STATS)
- decl _swtch_optim_stats
- incl _tlb_flush_count
-#endif
- movl %ecx, %cr3
-2:
-#endif
-
- /* update common_tss.tss_esp0 pointer */
- movl %esp, _common_tss + TSS_ESP0
-
- movl $0, %esi
- btrl %esi, _private_tss
- jae 1f
-
- movl $_common_tssd, %edi
-
- /* move correct tss descriptor into GDT slot, then reload tr */
- movl _tss_gdt, %ebx /* entry in GDT */
- movl 0(%edi), %eax
- movl %eax, 0(%ebx)
- movl 4(%edi), %eax
- movl %eax, 4(%ebx)
- movl $GPROC0_SEL*8, %esi /* GSEL(entry, SEL_KPL) */
- ltr %si
-1:
-
- sti
-
- /*
- * XXX callers of cpu_switch() do a bogus splclock(). Locking should
- * be left to cpu_switch().
- */
- call _spl0
-
- ALIGN_TEXT
-idle_loop:
- cli
- call _procrunnable
- testl %eax,%eax
- CROSSJUMP(jnz, sw1a, jz)
- call _vm_page_zero_idle
- testl %eax, %eax
- jnz idle_loop
- call *_hlt_vector /* wait for interrupt */
- jmp idle_loop
-
-#endif /* SMP */
-
-CROSSJUMPTARGET(_idle)
-
-ENTRY(default_halt)
- sti
-#ifndef SMP
- hlt /* XXX: until a wakeup IPI */
-#endif
- ret
-
-/*
- * cpu_switch()
- */
-ENTRY(cpu_switch)
-
- /* switch to new process. first, save context as needed */
- movl _curproc,%ecx
-
- /* if no process to save, don't bother */
- testl %ecx,%ecx
- je sw1
-
-#ifdef SMP
- movb P_ONCPU(%ecx), %al /* save "last" cpu */
- movb %al, P_LASTCPU(%ecx)
- movb $0xff, P_ONCPU(%ecx) /* "leave" the cpu */
-#endif /* SMP */
- movl P_VMSPACE(%ecx), %edx
-#ifdef SMP
- movl _cpuid, %eax
-#else
- xorl %eax, %eax
-#endif /* SMP */
- btrl %eax, VM_PMAP+PM_ACTIVE(%edx)
-
- movl P_ADDR(%ecx),%edx
-
- movl (%esp),%eax /* Hardware registers */
- movl %eax,PCB_EIP(%edx)
- movl %ebx,PCB_EBX(%edx)
- movl %esp,PCB_ESP(%edx)
- movl %ebp,PCB_EBP(%edx)
- movl %esi,PCB_ESI(%edx)
- movl %edi,PCB_EDI(%edx)
- movl %gs,PCB_GS(%edx)
-
- /* test if debug regisers should be saved */
- movb PCB_FLAGS(%edx),%al
- andb $PCB_DBREGS,%al
- jz 1f /* no, skip over */
- movl %dr7,%eax /* yes, do the save */
- movl %eax,PCB_DR7(%edx)
- andl $0x0000ff00, %eax /* disable all watchpoints */
- movl %eax,%dr7
- movl %dr6,%eax
- movl %eax,PCB_DR6(%edx)
- movl %dr3,%eax
- movl %eax,PCB_DR3(%edx)
- movl %dr2,%eax
- movl %eax,PCB_DR2(%edx)
- movl %dr1,%eax
- movl %eax,PCB_DR1(%edx)
- movl %dr0,%eax
- movl %eax,PCB_DR0(%edx)
-1:
-
-#ifdef SMP
- movl _mp_lock, %eax
- /* XXX FIXME: we should be saving the local APIC TPR */
-#ifdef DIAGNOSTIC
- cmpl $FREE_LOCK, %eax /* is it free? */
- je badsw4 /* yes, bad medicine! */
-#endif /* DIAGNOSTIC */
- andl $COUNT_FIELD, %eax /* clear CPU portion */
- movl %eax, PCB_MPNEST(%edx) /* store it */
-#endif /* SMP */
-
-#if NNPX > 0
- /* have we used fp, and need a save? */
- cmpl %ecx,_npxproc
- jne 1f
- addl $PCB_SAVEFPU,%edx /* h/w bugs make saving complicated */
- pushl %edx
- call _npxsave /* do it in a big C function */
- popl %eax
-1:
-#endif /* NNPX > 0 */
-
- movl $0,_curproc /* out of process */
-
- /* save is done, now choose a new process or idle */
-sw1:
- cli
-
-#ifdef SMP
- /* Stop scheduling if smp_active goes zero and we are not BSP */
- cmpl $0,_smp_active
- jne 1f
- cmpl $0,_cpuid
- CROSSJUMP(je, _idle, jne) /* wind down */
-1:
-#endif
-
-sw1a:
- call _chooseproc /* trash ecx, edx, ret eax*/
- testl %eax,%eax
- CROSSJUMP(je, _idle, jne) /* if no proc, idle */
- movl %eax,%ecx
-
- movl $0,%eax
- movl %eax,_want_resched
-
-#ifdef DIAGNOSTIC
- cmpl %eax,P_WCHAN(%ecx)
- jne badsw1
- cmpb $SRUN,P_STAT(%ecx)
- jne badsw2
-#endif
-
- movl P_ADDR(%ecx),%edx
-
-#if defined(SWTCH_OPTIM_STATS)
- incl _swtch_optim_stats
-#endif
- /* switch address space */
- movl %cr3,%ebx
- cmpl PCB_CR3(%edx),%ebx
- je 4f
-#if defined(SWTCH_OPTIM_STATS)
- decl _swtch_optim_stats
- incl _tlb_flush_count
-#endif
- movl PCB_CR3(%edx),%ebx
- movl %ebx,%cr3
-4:
-
-#ifdef SMP
- movl _cpuid, %esi
-#else
- xorl %esi, %esi
-#endif
- cmpl $0, PCB_EXT(%edx) /* has pcb extension? */
- je 1f
- btsl %esi, _private_tss /* mark use of private tss */
- movl PCB_EXT(%edx), %edi /* new tss descriptor */
- jmp 2f
-1:
-
- /* update common_tss.tss_esp0 pointer */
- movl %edx, %ebx /* pcb */
- addl $(UPAGES * PAGE_SIZE - 16), %ebx
- movl %ebx, _common_tss + TSS_ESP0
-
- btrl %esi, _private_tss
- jae 3f
-#ifdef SMP
- movl $gd_common_tssd, %edi
- addl %fs:0, %edi
-#else
- movl $_common_tssd, %edi
-#endif
-2:
- /* move correct tss descriptor into GDT slot, then reload tr */
- movl _tss_gdt, %ebx /* entry in GDT */
- movl 0(%edi), %eax
- movl %eax, 0(%ebx)
- movl 4(%edi), %eax
- movl %eax, 4(%ebx)
- movl $GPROC0_SEL*8, %esi /* GSEL(entry, SEL_KPL) */
- ltr %si
-3:
- movl P_VMSPACE(%ecx), %ebx
-#ifdef SMP
- movl _cpuid, %eax
-#else
- xorl %eax, %eax
-#endif
- btsl %eax, VM_PMAP+PM_ACTIVE(%ebx)
-
- /* restore context */
- movl PCB_EBX(%edx),%ebx
- movl PCB_ESP(%edx),%esp
- movl PCB_EBP(%edx),%ebp
- movl PCB_ESI(%edx),%esi
- movl PCB_EDI(%edx),%edi
- movl PCB_EIP(%edx),%eax
- movl %eax,(%esp)
-
-#ifdef SMP
-#ifdef GRAB_LOPRIO /* hold LOPRIO for INTs */
-#ifdef CHEAP_TPR
- movl $0, lapic_tpr
-#else
- andl $~APIC_TPR_PRIO, lapic_tpr
-#endif /** CHEAP_TPR */
-#endif /** GRAB_LOPRIO */
- movl _cpuid,%eax
- movb %al, P_ONCPU(%ecx)
-#endif /* SMP */
- movl %edx, _curpcb
- movl %ecx, _curproc /* into next process */
-
-#ifdef SMP
- movl _cpu_lockid, %eax
- orl PCB_MPNEST(%edx), %eax /* add next count from PROC */
- movl %eax, _mp_lock /* load the mp_lock */
- /* XXX FIXME: we should be restoring the local APIC TPR */
-#endif /* SMP */
-
-#ifdef USER_LDT
- cmpl $0, PCB_USERLDT(%edx)
- jnz 1f
- movl __default_ldt,%eax
- cmpl _currentldt,%eax
- je 2f
- lldt __default_ldt
- movl %eax,_currentldt
- jmp 2f
-1: pushl %edx
- call _set_user_ldt
- popl %edx
-2:
-#endif
-
- /* This must be done after loading the user LDT. */
- .globl cpu_switch_load_gs
-cpu_switch_load_gs:
- movl PCB_GS(%edx),%gs
-
- /* test if debug regisers should be restored */
- movb PCB_FLAGS(%edx),%al
- andb $PCB_DBREGS,%al
- jz 1f /* no, skip over */
- movl PCB_DR6(%edx),%eax /* yes, do the restore */
- movl %eax,%dr6
- movl PCB_DR3(%edx),%eax
- movl %eax,%dr3
- movl PCB_DR2(%edx),%eax
- movl %eax,%dr2
- movl PCB_DR1(%edx),%eax
- movl %eax,%dr1
- movl PCB_DR0(%edx),%eax
- movl %eax,%dr0
- movl PCB_DR7(%edx),%eax
- movl %eax,%dr7
-1:
-
- sti
- ret
-
-CROSSJUMPTARGET(sw1a)
-
-#ifdef DIAGNOSTIC
-badsw1:
- pushl $sw0_1
- call _panic
-
-sw0_1: .asciz "cpu_switch: has wchan"
-
-badsw2:
- pushl $sw0_2
- call _panic
-
-sw0_2: .asciz "cpu_switch: not SRUN"
-#endif
-
-#if defined(SMP) && defined(DIAGNOSTIC)
-badsw4:
- pushl $sw0_4
- call _panic
-
-sw0_4: .asciz "cpu_switch: do not have lock"
-#endif /* SMP && DIAGNOSTIC */
-
-/*
- * savectx(pcb)
- * Update pcb, saving current processor state.
- */
-ENTRY(savectx)
- /* fetch PCB */
- movl 4(%esp),%ecx
-
- /* caller's return address - child won't execute this routine */
- movl (%esp),%eax
- movl %eax,PCB_EIP(%ecx)
-
- movl %ebx,PCB_EBX(%ecx)
- movl %esp,PCB_ESP(%ecx)
- movl %ebp,PCB_EBP(%ecx)
- movl %esi,PCB_ESI(%ecx)
- movl %edi,PCB_EDI(%ecx)
- movl %gs,PCB_GS(%ecx)
-
-#if NNPX > 0
- /*
- * If npxproc == NULL, then the npx h/w state is irrelevant and the
- * state had better already be in the pcb. This is true for forks
- * but not for dumps (the old book-keeping with FP flags in the pcb
- * always lost for dumps because the dump pcb has 0 flags).
- *
- * If npxproc != NULL, then we have to save the npx h/w state to
- * npxproc's pcb and copy it to the requested pcb, or save to the
- * requested pcb and reload. Copying is easier because we would
- * have to handle h/w bugs for reloading. We used to lose the
- * parent's npx state for forks by forgetting to reload.
- */
- movl _npxproc,%eax
- testl %eax,%eax
- je 1f
-
- pushl %ecx
- movl P_ADDR(%eax),%eax
- leal PCB_SAVEFPU(%eax),%eax
- pushl %eax
- pushl %eax
- call _npxsave
- addl $4,%esp
- popl %eax
- popl %ecx
-
- pushl $PCB_SAVEFPU_SIZE
- leal PCB_SAVEFPU(%ecx),%ecx
- pushl %ecx
- pushl %eax
- call _bcopy
- addl $12,%esp
-#endif /* NNPX > 0 */
-
-1:
- ret
diff --git a/sys/amd64/amd64/sys_machdep.c b/sys/amd64/amd64/sys_machdep.c
deleted file mode 100644
index d722735f8b4c..000000000000
--- a/sys/amd64/amd64/sys_machdep.c
+++ /dev/null
@@ -1,502 +0,0 @@
-/*-
- * Copyright (c) 1990 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. 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, Berkeley and its contributors.
- * 4. 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: @(#)sys_machdep.c 5.5 (Berkeley) 1/19/91
- * $FreeBSD$
- *
- */
-
-#include "opt_user_ldt.h"
-#include "opt_smp.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/sysproto.h>
-#include <sys/malloc.h>
-#include <sys/proc.h>
-
-#include <vm/vm.h>
-#include <sys/lock.h>
-#include <vm/pmap.h>
-#include <vm/vm_map.h>
-#include <vm/vm_extern.h>
-
-#include <sys/user.h>
-
-#include <machine/cpu.h>
-#include <machine/pcb_ext.h> /* pcb.h included by sys/user.h */
-#include <machine/sysarch.h>
-#ifdef SMP
-#include <machine/smp.h>
-#endif
-
-#include <vm/vm_kern.h> /* for kernel_map */
-
-#define MAX_LD 8192
-#define LD_PER_PAGE 512
-#define NEW_MAX_LD(num) ((num + LD_PER_PAGE) & ~(LD_PER_PAGE-1))
-#define SIZE_FROM_LARGEST_LD(num) (NEW_MAX_LD(num) << 3)
-
-
-
-#ifdef USER_LDT
-static int i386_get_ldt __P((struct proc *, char *));
-static int i386_set_ldt __P((struct proc *, char *));
-#endif
-static int i386_get_ioperm __P((struct proc *, char *));
-static int i386_set_ioperm __P((struct proc *, char *));
-int i386_extend_pcb __P((struct proc *));
-
-#ifndef _SYS_SYSPROTO_H_
-struct sysarch_args {
- int op;
- char *parms;
-};
-#endif
-
-int
-sysarch(p, uap)
- struct proc *p;
- register struct sysarch_args *uap;
-{
- int error = 0;
-
- switch(uap->op) {
-#ifdef USER_LDT
- case I386_GET_LDT:
- error = i386_get_ldt(p, uap->parms);
- break;
-
- case I386_SET_LDT:
- error = i386_set_ldt(p, uap->parms);
- break;
-#endif
- case I386_GET_IOPERM:
- error = i386_get_ioperm(p, uap->parms);
- break;
- case I386_SET_IOPERM:
- error = i386_set_ioperm(p, uap->parms);
- break;
- case I386_VM86:
- error = vm86_sysarch(p, uap->parms);
- break;
- default:
- error = EOPNOTSUPP;
- break;
- }
- return (error);
-}
-
-int
-i386_extend_pcb(struct proc *p)
-{
- int i, offset;
- u_long *addr;
- struct pcb_ext *ext;
- struct soft_segment_descriptor ssd = {
- 0, /* segment base address (overwritten) */
- ctob(IOPAGES + 1) - 1, /* length */
- SDT_SYS386TSS, /* segment type */
- 0, /* priority level */
- 1, /* descriptor present */
- 0, 0,
- 0, /* default 32 size */
- 0 /* granularity */
- };
-
- ext = (struct pcb_ext *)kmem_alloc(kernel_map, ctob(IOPAGES+1));
- if (ext == 0)
- return (ENOMEM);
- p->p_addr->u_pcb.pcb_ext = ext;
- bzero(ext, sizeof(struct pcb_ext));
- ext->ext_tss.tss_esp0 = (unsigned)p->p_addr + ctob(UPAGES) - 16;
- ext->ext_tss.tss_ss0 = GSEL(GDATA_SEL, SEL_KPL);
- /*
- * The last byte of the i/o map must be followed by an 0xff byte.
- * We arbitrarily allocate 16 bytes here, to keep the starting
- * address on a doubleword boundary.
- */
- offset = PAGE_SIZE - 16;
- ext->ext_tss.tss_ioopt =
- (offset - ((unsigned)&ext->ext_tss - (unsigned)ext)) << 16;
- ext->ext_iomap = (caddr_t)ext + offset;
- ext->ext_vm86.vm86_intmap = (caddr_t)ext + offset - 32;
-
- addr = (u_long *)ext->ext_vm86.vm86_intmap;
- for (i = 0; i < (ctob(IOPAGES) + 32 + 16) / sizeof(u_long); i++)
- *addr++ = ~0;
-
- ssd.ssd_base = (unsigned)&ext->ext_tss;
- ssd.ssd_limit -= ((unsigned)&ext->ext_tss - (unsigned)ext);
- ssdtosd(&ssd, &ext->ext_tssd);
-
- /* switch to the new TSS after syscall completes */
- need_resched();
-
- return 0;
-}
-
-static int
-i386_set_ioperm(p, args)
- struct proc *p;
- char *args;
-{
- int i, error;
- struct i386_ioperm_args ua;
- char *iomap;
-
- if ((error = copyin(args, &ua, sizeof(struct i386_ioperm_args))) != 0)
- return (error);
-
- if ((error = suser(p)) != 0)
- return (error);
- if (securelevel > 0)
- return (EPERM);
- /*
- * XXX
- * While this is restricted to root, we should probably figure out
- * whether any other driver is using this i/o address, as so not to
- * cause confusion. This probably requires a global 'usage registry'.
- */
-
- if (p->p_addr->u_pcb.pcb_ext == 0)
- if ((error = i386_extend_pcb(p)) != 0)
- return (error);
- iomap = (char *)p->p_addr->u_pcb.pcb_ext->ext_iomap;
-
- if (ua.start + ua.length > IOPAGES * PAGE_SIZE * NBBY)
- return (EINVAL);
-
- for (i = ua.start; i < ua.start + ua.length; i++) {
- if (ua.enable)
- iomap[i >> 3] &= ~(1 << (i & 7));
- else
- iomap[i >> 3] |= (1 << (i & 7));
- }
- return (error);
-}
-
-static int
-i386_get_ioperm(p, args)
- struct proc *p;
- char *args;
-{
- int i, state, error;
- struct i386_ioperm_args ua;
- char *iomap;
-
- if ((error = copyin(args, &ua, sizeof(struct i386_ioperm_args))) != 0)
- return (error);
- if (ua.start >= IOPAGES * PAGE_SIZE * NBBY)
- return (EINVAL);
-
- if (p->p_addr->u_pcb.pcb_ext == 0) {
- ua.length = 0;
- goto done;
- }
-
- iomap = (char *)p->p_addr->u_pcb.pcb_ext->ext_iomap;
-
- i = ua.start;
- state = (iomap[i >> 3] >> (i & 7)) & 1;
- ua.enable = !state;
- ua.length = 1;
-
- for (i = ua.start + 1; i < IOPAGES * PAGE_SIZE * NBBY; i++) {
- if (state != ((iomap[i >> 3] >> (i & 7)) & 1))
- break;
- ua.length++;
- }
-
-done:
- error = copyout(&ua, args, sizeof(struct i386_ioperm_args));
- return (error);
-}
-
-#ifdef USER_LDT
-/*
- * Update the GDT entry pointing to the LDT to point to the LDT of the
- * current process. Do not staticize.
- */
-void
-set_user_ldt(struct pcb *pcb)
-{
- struct pcb_ldt *pcb_ldt;
-
- if (pcb != curpcb)
- return;
-
- pcb_ldt = pcb->pcb_ldt;
-#ifdef SMP
- gdt[cpuid * NGDT + GUSERLDT_SEL].sd = pcb_ldt->ldt_sd;
-#else
- gdt[GUSERLDT_SEL].sd = pcb_ldt->ldt_sd;
-#endif
- lldt(GSEL(GUSERLDT_SEL, SEL_KPL));
- currentldt = GSEL(GUSERLDT_SEL, SEL_KPL);
-}
-
-struct pcb_ldt *
-user_ldt_alloc(struct pcb *pcb, int len)
-{
- struct pcb_ldt *pcb_ldt, *new_ldt;
-
- MALLOC(new_ldt, struct pcb_ldt *, sizeof(struct pcb_ldt),
- M_SUBPROC, M_WAITOK);
- if (new_ldt == NULL)
- return NULL;
-
- new_ldt->ldt_len = len = NEW_MAX_LD(len);
- new_ldt->ldt_base = (caddr_t)kmem_alloc(kernel_map,
- len * sizeof(union descriptor));
- if (new_ldt->ldt_base == NULL) {
- FREE(new_ldt, M_SUBPROC);
- return NULL;
- }
- new_ldt->ldt_refcnt = 1;
- new_ldt->ldt_active = 0;
-
- gdt_segs[GUSERLDT_SEL].ssd_base = (unsigned)new_ldt->ldt_base;
- gdt_segs[GUSERLDT_SEL].ssd_limit = len * sizeof(union descriptor) - 1;
- ssdtosd(&gdt_segs[GUSERLDT_SEL], &new_ldt->ldt_sd);
-
- if ((pcb_ldt = pcb->pcb_ldt)) {
- if (len > pcb_ldt->ldt_len)
- len = pcb_ldt->ldt_len;
- bcopy(pcb_ldt->ldt_base, new_ldt->ldt_base,
- len * sizeof(union descriptor));
- } else {
- bcopy(ldt, new_ldt->ldt_base, sizeof(ldt));
- }
- return new_ldt;
-}
-
-void
-user_ldt_free(struct pcb *pcb)
-{
- struct pcb_ldt *pcb_ldt = pcb->pcb_ldt;
-
- if (pcb_ldt == NULL)
- return;
-
- if (pcb == curpcb) {
- lldt(_default_ldt);
- currentldt = _default_ldt;
- }
-
- if (--pcb_ldt->ldt_refcnt == 0) {
- kmem_free(kernel_map, (vm_offset_t)pcb_ldt->ldt_base,
- pcb_ldt->ldt_len * sizeof(union descriptor));
- FREE(pcb_ldt, M_SUBPROC);
- }
- pcb->pcb_ldt = NULL;
-}
-
-static int
-i386_get_ldt(p, args)
- struct proc *p;
- char *args;
-{
- int error = 0;
- struct pcb *pcb = &p->p_addr->u_pcb;
- struct pcb_ldt *pcb_ldt = pcb->pcb_ldt;
- int nldt, num;
- union descriptor *lp;
- int s;
- struct i386_ldt_args ua, *uap = &ua;
-
- if ((error = copyin(args, uap, sizeof(struct i386_ldt_args))) < 0)
- return(error);
-
-#ifdef DEBUG
- printf("i386_get_ldt: start=%d num=%d descs=%p\n",
- uap->start, uap->num, (void *)uap->descs);
-#endif
-
- /* verify range of LDTs exist */
- if ((uap->start < 0) || (uap->num <= 0))
- return(EINVAL);
-
- s = splhigh();
-
- if (pcb_ldt) {
- nldt = pcb_ldt->ldt_len;
- num = min(uap->num, nldt);
- lp = &((union descriptor *)(pcb_ldt->ldt_base))[uap->start];
- } else {
- nldt = sizeof(ldt)/sizeof(ldt[0]);
- num = min(uap->num, nldt);
- lp = &ldt[uap->start];
- }
- if (uap->start > nldt) {
- splx(s);
- return(EINVAL);
- }
-
- error = copyout(lp, uap->descs, num * sizeof(union descriptor));
- if (!error)
- p->p_retval[0] = num;
-
- splx(s);
- return(error);
-}
-
-static int
-i386_set_ldt(p, args)
- struct proc *p;
- char *args;
-{
- int error = 0, i, n;
- int largest_ld;
- struct pcb *pcb = &p->p_addr->u_pcb;
- struct pcb_ldt *pcb_ldt = pcb->pcb_ldt;
- int s;
- struct i386_ldt_args ua, *uap = &ua;
-
- if ((error = copyin(args, uap, sizeof(struct i386_ldt_args))) < 0)
- return(error);
-
-#ifdef DEBUG
- printf("i386_set_ldt: start=%d num=%d descs=%p\n",
- uap->start, uap->num, (void *)uap->descs);
-#endif
-
- /* verify range of descriptors to modify */
- if ((uap->start < 0) || (uap->start >= MAX_LD) || (uap->num < 0) ||
- (uap->num > MAX_LD))
- {
- return(EINVAL);
- }
- largest_ld = uap->start + uap->num - 1;
- if (largest_ld >= MAX_LD)
- return(EINVAL);
-
- /* allocate user ldt */
- if (!pcb_ldt || largest_ld >= pcb_ldt->ldt_len) {
- struct pcb_ldt *new_ldt = user_ldt_alloc(pcb, largest_ld);
- if (new_ldt == NULL)
- return ENOMEM;
- if (pcb_ldt) {
- pcb_ldt->ldt_sd = new_ldt->ldt_sd;
- kmem_free(kernel_map, (vm_offset_t)pcb_ldt->ldt_base,
- pcb_ldt->ldt_len * sizeof(union descriptor));
- pcb_ldt->ldt_base = new_ldt->ldt_base;
- pcb_ldt->ldt_len = new_ldt->ldt_len;
- FREE(new_ldt, M_SUBPROC);
- } else
- pcb->pcb_ldt = pcb_ldt = new_ldt;
-#ifdef SMP
- /* signal other cpus to reload ldt */
- smp_rendezvous(NULL, (void (*)(void *))set_user_ldt, NULL, pcb);
-#else
- set_user_ldt(pcb);
-#endif
- }
-
- /* Check descriptors for access violations */
- for (i = 0, n = uap->start; i < uap->num; i++, n++) {
- union descriptor desc, *dp;
- dp = &uap->descs[i];
- error = copyin(dp, &desc, sizeof(union descriptor));
- if (error)
- return(error);
-
- switch (desc.sd.sd_type) {
- case SDT_SYSNULL: /* system null */
- desc.sd.sd_p = 0;
- break;
- case SDT_SYS286TSS: /* system 286 TSS available */
- case SDT_SYSLDT: /* system local descriptor table */
- case SDT_SYS286BSY: /* system 286 TSS busy */
- case SDT_SYSTASKGT: /* system task gate */
- case SDT_SYS286IGT: /* system 286 interrupt gate */
- case SDT_SYS286TGT: /* system 286 trap gate */
- case SDT_SYSNULL2: /* undefined by Intel */
- case SDT_SYS386TSS: /* system 386 TSS available */
- case SDT_SYSNULL3: /* undefined by Intel */
- case SDT_SYS386BSY: /* system 386 TSS busy */
- case SDT_SYSNULL4: /* undefined by Intel */
- case SDT_SYS386IGT: /* system 386 interrupt gate */
- case SDT_SYS386TGT: /* system 386 trap gate */
- case SDT_SYS286CGT: /* system 286 call gate */
- case SDT_SYS386CGT: /* system 386 call gate */
- /* I can't think of any reason to allow a user proc
- * to create a segment of these types. They are
- * for OS use only.
- */
- return EACCES;
-
- /* memory segment types */
- case SDT_MEMEC: /* memory execute only conforming */
- case SDT_MEMEAC: /* memory execute only accessed conforming */
- case SDT_MEMERC: /* memory execute read conforming */
- case SDT_MEMERAC: /* memory execute read accessed conforming */
- /* Must be "present" if executable and conforming. */
- if (desc.sd.sd_p == 0)
- return (EACCES);
- break;
- case SDT_MEMRO: /* memory read only */
- case SDT_MEMROA: /* memory read only accessed */
- case SDT_MEMRW: /* memory read write */
- case SDT_MEMRWA: /* memory read write accessed */
- case SDT_MEMROD: /* memory read only expand dwn limit */
- case SDT_MEMRODA: /* memory read only expand dwn lim accessed */
- case SDT_MEMRWD: /* memory read write expand dwn limit */
- case SDT_MEMRWDA: /* memory read write expand dwn lim acessed */
- case SDT_MEME: /* memory execute only */
- case SDT_MEMEA: /* memory execute only accessed */
- case SDT_MEMER: /* memory execute read */
- case SDT_MEMERA: /* memory execute read accessed */
- break;
- default:
- return(EINVAL);
- /*NOTREACHED*/
- }
-
- /* Only user (ring-3) descriptors may be present. */
- if ((desc.sd.sd_p != 0) && (desc.sd.sd_dpl != SEL_UPL))
- return (EACCES);
- }
-
- s = splhigh();
-
- /* Fill in range */
- error = copyin(uap->descs,
- &((union descriptor *)(pcb_ldt->ldt_base))[uap->start],
- uap->num * sizeof(union descriptor));
- if (!error)
- p->p_retval[0] = uap->start;
-
- splx(s);
- return(error);
-}
-#endif /* USER_LDT */
diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c
deleted file mode 100644
index a8b73cf6a02b..000000000000
--- a/sys/amd64/amd64/trap.c
+++ /dev/null
@@ -1,1152 +0,0 @@
-/*-
- * Copyright (C) 1994, David Greenman
- * 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 University of Utah, and William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)trap.c 7.4 (Berkeley) 5/13/91
- * $FreeBSD$
- */
-
-/*
- * 386 Trap and System call handling
- */
-
-#include "opt_cpu.h"
-#include "opt_ddb.h"
-#include "opt_ktrace.h"
-#include "opt_clock.h"
-#include "opt_trap.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/proc.h>
-#include <sys/pioctl.h>
-#include <sys/kernel.h>
-#include <sys/resourcevar.h>
-#include <sys/signalvar.h>
-#include <sys/syscall.h>
-#include <sys/sysent.h>
-#include <sys/uio.h>
-#include <sys/vmmeter.h>
-#ifdef KTRACE
-#include <sys/ktrace.h>
-#endif
-
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <sys/lock.h>
-#include <vm/pmap.h>
-#include <vm/vm_kern.h>
-#include <vm/vm_map.h>
-#include <vm/vm_page.h>
-#include <vm/vm_extern.h>
-
-#include <machine/cpu.h>
-#include <machine/ipl.h>
-#include <machine/md_var.h>
-#include <machine/pcb.h>
-#ifdef SMP
-#include <machine/smp.h>
-#endif
-#include <machine/tss.h>
-
-#include <i386/isa/intr_machdep.h>
-
-#ifdef POWERFAIL_NMI
-#include <sys/syslog.h>
-#include <machine/clock.h>
-#endif
-
-#include <machine/vm86.h>
-
-#include <ddb/ddb.h>
-
-#include "isa.h"
-#include "npx.h"
-
-int (*pmath_emulate) __P((struct trapframe *));
-
-extern void trap __P((struct trapframe frame));
-extern int trapwrite __P((unsigned addr));
-extern void syscall __P((struct trapframe frame));
-
-static int trap_pfault __P((struct trapframe *, int, vm_offset_t));
-static void trap_fatal __P((struct trapframe *, vm_offset_t));
-void dblfault_handler __P((void));
-
-extern inthand_t IDTVEC(syscall);
-
-#define MAX_TRAP_MSG 28
-static char *trap_msg[] = {
- "", /* 0 unused */
- "privileged instruction fault", /* 1 T_PRIVINFLT */
- "", /* 2 unused */
- "breakpoint instruction fault", /* 3 T_BPTFLT */
- "", /* 4 unused */
- "", /* 5 unused */
- "arithmetic trap", /* 6 T_ARITHTRAP */
- "system forced exception", /* 7 T_ASTFLT */
- "", /* 8 unused */
- "general protection fault", /* 9 T_PROTFLT */
- "trace trap", /* 10 T_TRCTRAP */
- "", /* 11 unused */
- "page fault", /* 12 T_PAGEFLT */
- "", /* 13 unused */
- "alignment fault", /* 14 T_ALIGNFLT */
- "", /* 15 unused */
- "", /* 16 unused */
- "", /* 17 unused */
- "integer divide fault", /* 18 T_DIVIDE */
- "non-maskable interrupt trap", /* 19 T_NMI */
- "overflow trap", /* 20 T_OFLOW */
- "FPU bounds check fault", /* 21 T_BOUND */
- "FPU device not available", /* 22 T_DNA */
- "double fault", /* 23 T_DOUBLEFLT */
- "FPU operand fetch fault", /* 24 T_FPOPFLT */
- "invalid TSS fault", /* 25 T_TSSFLT */
- "segment not present fault", /* 26 T_SEGNPFLT */
- "stack fault", /* 27 T_STKFLT */
- "machine check trap", /* 28 T_MCHK */
-};
-
-static __inline void userret __P((struct proc *p, struct trapframe *frame,
- u_quad_t oticks));
-
-#if defined(I586_CPU) && !defined(NO_F00F_HACK)
-extern int has_f00f_bug;
-#endif
-
-static __inline void
-userret(p, frame, oticks)
- struct proc *p;
- struct trapframe *frame;
- u_quad_t oticks;
-{
- int sig, s;
-
- while ((sig = CURSIG(p)) != 0)
- postsig(sig);
-
-#if 0
- if (!want_resched &&
- (p->p_priority <= p->p_usrpri) &&
- (p->p_rtprio.type == RTP_PRIO_NORMAL)) {
- int newpriority;
- p->p_estcpu += 1;
- newpriority = PUSER + p->p_estcpu / 4 + 2 * p->p_nice;
- newpriority = min(newpriority, MAXPRI);
- p->p_usrpri = newpriority;
- }
-#endif
-
- p->p_priority = p->p_usrpri;
- if (want_resched) {
- /*
- * Since we are curproc, clock will normally just change
- * our priority without moving us from one queue to another
- * (since the running process is not on a queue.)
- * If that happened after we setrunqueue ourselves but before we
- * mi_switch()'ed, we might not be on the queue indicated by
- * our priority.
- */
- s = splhigh();
- setrunqueue(p);
- p->p_stats->p_ru.ru_nivcsw++;
- mi_switch();
- splx(s);
- while ((sig = CURSIG(p)) != 0)
- postsig(sig);
- }
- /*
- * Charge system time if profiling.
- */
- if (p->p_flag & P_PROFIL)
- addupc_task(p, frame->tf_eip,
- (u_int)(p->p_sticks - oticks) * psratio);
-
- curpriority = p->p_priority;
-}
-
-/*
- * Exception, fault, and trap interface to the FreeBSD kernel.
- * This common code is called from assembly language IDT gate entry
- * routines that prepare a suitable stack frame, and restore this
- * frame after the exception has been processed.
- */
-
-void
-trap(frame)
- struct trapframe frame;
-{
- struct proc *p = curproc;
- u_quad_t sticks = 0;
- int i = 0, ucode = 0, type, code;
- vm_offset_t eva;
-
- if (!(frame.tf_eflags & PSL_I)) {
- /*
- * Buggy application or kernel code has disabled interrupts
- * and then trapped. Enabling interrupts now is wrong, but
- * it is better than running with interrupts disabled until
- * they are accidentally enabled later.
- */
- type = frame.tf_trapno;
- if (ISPL(frame.tf_cs) == SEL_UPL || (frame.tf_eflags & PSL_VM))
- printf(
- "pid %ld (%s): trap %d with interrupts disabled\n",
- (long)curproc->p_pid, curproc->p_comm, type);
- else if (type != T_BPTFLT && type != T_TRCTRAP)
- /*
- * XXX not quite right, since this may be for a
- * multiple fault in user mode.
- */
- printf("kernel trap %d with interrupts disabled\n",
- type);
- enable_intr();
- }
-
- eva = 0;
- if (frame.tf_trapno == T_PAGEFLT) {
- /*
- * For some Cyrix CPUs, %cr2 is clobbered by interrupts.
- * This problem is worked around by using an interrupt
- * gate for the pagefault handler. We are finally ready
- * to read %cr2 and then must reenable interrupts.
- *
- * XXX this should be in the switch statement, but the
- * NO_FOOF_HACK and VM86 goto and ifdefs obfuscate the
- * flow of control too much for this to be obviously
- * correct.
- */
- eva = rcr2();
- enable_intr();
- }
-
-#if defined(I586_CPU) && !defined(NO_F00F_HACK)
-restart:
-#endif
- type = frame.tf_trapno;
- code = frame.tf_err;
-
- if (in_vm86call) {
- if (frame.tf_eflags & PSL_VM &&
- (type == T_PROTFLT || type == T_STKFLT)) {
- i = vm86_emulate((struct vm86frame *)&frame);
- if (i != 0)
- /*
- * returns to original process
- */
- vm86_trap((struct vm86frame *)&frame);
- return;
- }
- switch (type) {
- /*
- * these traps want either a process context, or
- * assume a normal userspace trap.
- */
- case T_PROTFLT:
- case T_SEGNPFLT:
- trap_fatal(&frame, eva);
- return;
- case T_TRCTRAP:
- type = T_BPTFLT; /* kernel breakpoint */
- /* FALL THROUGH */
- }
- goto kernel_trap; /* normal kernel trap handling */
- }
-
- if ((ISPL(frame.tf_cs) == SEL_UPL) || (frame.tf_eflags & PSL_VM)) {
- /* user trap */
-
- sticks = p->p_sticks;
- p->p_md.md_regs = &frame;
-
- switch (type) {
- case T_PRIVINFLT: /* privileged instruction fault */
- ucode = type;
- i = SIGILL;
- break;
-
- case T_BPTFLT: /* bpt instruction fault */
- case T_TRCTRAP: /* trace trap */
- frame.tf_eflags &= ~PSL_T;
- i = SIGTRAP;
- break;
-
- case T_ARITHTRAP: /* arithmetic trap */
- ucode = code;
- i = SIGFPE;
- break;
-
- case T_ASTFLT: /* Allow process switch */
- astoff();
- cnt.v_soft++;
- if (p->p_flag & P_OWEUPC) {
- p->p_flag &= ~P_OWEUPC;
- addupc_task(p, p->p_stats->p_prof.pr_addr,
- p->p_stats->p_prof.pr_ticks);
- }
- goto out;
-
- /*
- * The following two traps can happen in
- * vm86 mode, and, if so, we want to handle
- * them specially.
- */
- case T_PROTFLT: /* general protection fault */
- case T_STKFLT: /* stack fault */
- if (frame.tf_eflags & PSL_VM) {
- i = vm86_emulate((struct vm86frame *)&frame);
- if (i == 0)
- goto out;
- break;
- }
- /* FALL THROUGH */
-
- case T_SEGNPFLT: /* segment not present fault */
- case T_TSSFLT: /* invalid TSS fault */
- case T_DOUBLEFLT: /* double fault */
- default:
- ucode = code + BUS_SEGM_FAULT ;
- i = SIGBUS;
- break;
-
- case T_PAGEFLT: /* page fault */
- i = trap_pfault(&frame, TRUE, eva);
- if (i == -1)
- return;
-#if defined(I586_CPU) && !defined(NO_F00F_HACK)
- if (i == -2)
- goto restart;
-#endif
- if (i == 0)
- goto out;
-
- ucode = T_PAGEFLT;
- break;
-
- case T_DIVIDE: /* integer divide fault */
- ucode = FPE_INTDIV;
- i = SIGFPE;
- break;
-
-#if NISA > 0
- case T_NMI:
-#ifdef POWERFAIL_NMI
- goto handle_powerfail;
-#else /* !POWERFAIL_NMI */
-#ifdef DDB
- /* NMI can be hooked up to a pushbutton for debugging */
- printf ("NMI ... going to debugger\n");
- if (kdb_trap (type, 0, &frame))
- return;
-#endif /* DDB */
- /* machine/parity/power fail/"kitchen sink" faults */
- if (isa_nmi(code) == 0) return;
- panic("NMI indicates hardware failure");
-#endif /* POWERFAIL_NMI */
-#endif /* NISA > 0 */
-
- case T_OFLOW: /* integer overflow fault */
- ucode = FPE_INTOVF;
- i = SIGFPE;
- break;
-
- case T_BOUND: /* bounds check fault */
- ucode = FPE_FLTSUB;
- i = SIGFPE;
- break;
-
- case T_DNA:
-#if NNPX > 0
- /* if a transparent fault (due to context switch "late") */
- if (npxdna())
- return;
-#endif
- if (!pmath_emulate) {
- i = SIGFPE;
- ucode = FPE_FPU_NP_TRAP;
- break;
- }
- i = (*pmath_emulate)(&frame);
- if (i == 0) {
- if (!(frame.tf_eflags & PSL_T))
- return;
- frame.tf_eflags &= ~PSL_T;
- i = SIGTRAP;
- }
- /* else ucode = emulator_only_knows() XXX */
- break;
-
- case T_FPOPFLT: /* FPU operand fetch fault */
- ucode = T_FPOPFLT;
- i = SIGILL;
- break;
- }
- } else {
-kernel_trap:
- /* kernel trap */
-
- switch (type) {
- case T_PAGEFLT: /* page fault */
- (void) trap_pfault(&frame, FALSE, eva);
- return;
-
- case T_DNA:
-#if NNPX > 0
- /*
- * The kernel is apparently using npx for copying.
- * XXX this should be fatal unless the kernel has
- * registered such use.
- */
- if (npxdna())
- return;
-#endif
- break;
-
- case T_PROTFLT: /* general protection fault */
- case T_SEGNPFLT: /* segment not present fault */
- /*
- * Invalid segment selectors and out of bounds
- * %eip's and %esp's can be set up in user mode.
- * This causes a fault in kernel mode when the
- * kernel tries to return to user mode. We want
- * to get this fault so that we can fix the
- * problem here and not have to check all the
- * selectors and pointers when the user changes
- * them.
- */
-#define MAYBE_DORETI_FAULT(where, whereto) \
- do { \
- if (frame.tf_eip == (int)where) { \
- frame.tf_eip = (int)whereto; \
- return; \
- } \
- } while (0)
-
- if (intr_nesting_level == 0) {
- /*
- * Invalid %fs's and %gs's can be created using
- * procfs or PT_SETREGS or by invalidating the
- * underlying LDT entry. This causes a fault
- * in kernel mode when the kernel attempts to
- * switch contexts. Lose the bad context
- * (XXX) so that we can continue, and generate
- * a signal.
- */
- if (frame.tf_eip == (int)cpu_switch_load_gs) {
- curpcb->pcb_gs = 0;
- psignal(p, SIGBUS);
- return;
- }
- MAYBE_DORETI_FAULT(doreti_iret,
- doreti_iret_fault);
- MAYBE_DORETI_FAULT(doreti_popl_ds,
- doreti_popl_ds_fault);
- MAYBE_DORETI_FAULT(doreti_popl_es,
- doreti_popl_es_fault);
- MAYBE_DORETI_FAULT(doreti_popl_fs,
- doreti_popl_fs_fault);
- if (curpcb && curpcb->pcb_onfault) {
- frame.tf_eip = (int)curpcb->pcb_onfault;
- return;
- }
- }
- break;
-
- case T_TSSFLT:
- /*
- * PSL_NT can be set in user mode and isn't cleared
- * automatically when the kernel is entered. This
- * causes a TSS fault when the kernel attempts to
- * `iret' because the TSS link is uninitialized. We
- * want to get this fault so that we can fix the
- * problem here and not every time the kernel is
- * entered.
- */
- if (frame.tf_eflags & PSL_NT) {
- frame.tf_eflags &= ~PSL_NT;
- return;
- }
- break;
-
- case T_TRCTRAP: /* trace trap */
- if (frame.tf_eip == (int)IDTVEC(syscall)) {
- /*
- * We've just entered system mode via the
- * syscall lcall. Continue single stepping
- * silently until the syscall handler has
- * saved the flags.
- */
- return;
- }
- if (frame.tf_eip == (int)IDTVEC(syscall) + 1) {
- /*
- * The syscall handler has now saved the
- * flags. Stop single stepping it.
- */
- frame.tf_eflags &= ~PSL_T;
- return;
- }
- /*
- * Ignore debug register trace traps due to
- * accesses in the user's address space, which
- * can happen under several conditions such as
- * if a user sets a watchpoint on a buffer and
- * then passes that buffer to a system call.
- * We still want to get TRCTRAPS for addresses
- * in kernel space because that is useful when
- * debugging the kernel.
- */
- if (user_dbreg_trap()) {
- /*
- * Reset breakpoint bits because the
- * processor doesn't
- */
- load_dr6(rdr6() & 0xfffffff0);
- return;
- }
- /*
- * Fall through (TRCTRAP kernel mode, kernel address)
- */
- case T_BPTFLT:
- /*
- * If DDB is enabled, let it handle the debugger trap.
- * Otherwise, debugger traps "can't happen".
- */
-#ifdef DDB
- if (kdb_trap (type, 0, &frame))
- return;
-#endif
- break;
-
-#if NISA > 0
- case T_NMI:
-#ifdef POWERFAIL_NMI
-#ifndef TIMER_FREQ
-# define TIMER_FREQ 1193182
-#endif
- handle_powerfail:
- {
- static unsigned lastalert = 0;
-
- if(time_second - lastalert > 10)
- {
- log(LOG_WARNING, "NMI: power fail\n");
- sysbeep(TIMER_FREQ/880, hz);
- lastalert = time_second;
- }
- return;
- }
-#else /* !POWERFAIL_NMI */
-#ifdef DDB
- /* NMI can be hooked up to a pushbutton for debugging */
- printf ("NMI ... going to debugger\n");
- if (kdb_trap (type, 0, &frame))
- return;
-#endif /* DDB */
- /* machine/parity/power fail/"kitchen sink" faults */
- if (isa_nmi(code) == 0) return;
- /* FALL THROUGH */
-#endif /* POWERFAIL_NMI */
-#endif /* NISA > 0 */
- }
-
- trap_fatal(&frame, eva);
- return;
- }
-
- /* Translate fault for emulators (e.g. Linux) */
- if (*p->p_sysent->sv_transtrap)
- i = (*p->p_sysent->sv_transtrap)(i, type);
-
- trapsignal(p, i, ucode);
-
-#ifdef DEBUG
- if (type <= MAX_TRAP_MSG) {
- uprintf("fatal process exception: %s",
- trap_msg[type]);
- if ((type == T_PAGEFLT) || (type == T_PROTFLT))
- uprintf(", fault VA = 0x%lx", (u_long)eva);
- uprintf("\n");
- }
-#endif
-
-out:
- userret(p, &frame, sticks);
-}
-
-#ifdef notyet
-/*
- * This version doesn't allow a page fault to user space while
- * in the kernel. The rest of the kernel needs to be made "safe"
- * before this can be used. I think the only things remaining
- * to be made safe are the iBCS2 code and the process tracing/
- * debugging code.
- */
-static int
-trap_pfault(frame, usermode, eva)
- struct trapframe *frame;
- int usermode;
- vm_offset_t eva;
-{
- vm_offset_t va;
- struct vmspace *vm = NULL;
- vm_map_t map = 0;
- int rv = 0;
- vm_prot_t ftype;
- struct proc *p = curproc;
-
- if (frame->tf_err & PGEX_W)
- ftype = VM_PROT_READ | VM_PROT_WRITE;
- else
- ftype = VM_PROT_READ;
-
- va = trunc_page(eva);
- if (va < VM_MIN_KERNEL_ADDRESS) {
- vm_offset_t v;
- vm_page_t mpte;
-
- if (p == NULL ||
- (!usermode && va < VM_MAXUSER_ADDRESS &&
- (intr_nesting_level != 0 || curpcb == NULL ||
- curpcb->pcb_onfault == NULL))) {
- trap_fatal(frame, eva);
- return (-1);
- }
-
- /*
- * This is a fault on non-kernel virtual memory.
- * vm is initialized above to NULL. If curproc is NULL
- * or curproc->p_vmspace is NULL the fault is fatal.
- */
- vm = p->p_vmspace;
- if (vm == NULL)
- goto nogo;
-
- map = &vm->vm_map;
-
- /*
- * Keep swapout from messing with us during this
- * critical time.
- */
- ++p->p_lock;
-
- /*
- * Grow the stack if necessary
- */
- /* grow_stack returns false only if va falls into
- * a growable stack region and the stack growth
- * fails. It returns true if va was not within
- * a growable stack region, or if the stack
- * growth succeeded.
- */
- if (!grow_stack (p, va)) {
- rv = KERN_FAILURE;
- --p->p_lock;
- goto nogo;
- }
-
- /* Fault in the user page: */
- rv = vm_fault(map, va, ftype,
- (ftype & VM_PROT_WRITE) ? VM_FAULT_DIRTY
- : VM_FAULT_NORMAL);
-
- --p->p_lock;
- } else {
- /*
- * Don't allow user-mode faults in kernel address space.
- */
- if (usermode)
- goto nogo;
-
- /*
- * Since we know that kernel virtual address addresses
- * always have pte pages mapped, we just have to fault
- * the page.
- */
- rv = vm_fault(kernel_map, va, ftype, VM_FAULT_NORMAL);
- }
-
- if (rv == KERN_SUCCESS)
- return (0);
-nogo:
- if (!usermode) {
- if (intr_nesting_level == 0 && curpcb && curpcb->pcb_onfault) {
- frame->tf_eip = (int)curpcb->pcb_onfault;
- return (0);
- }
- trap_fatal(frame, eva);
- return (-1);
- }
-
- /* kludge to pass faulting virtual address to sendsig */
- frame->tf_err = eva;
-
- return((rv == KERN_PROTECTION_FAILURE) ? SIGBUS : SIGSEGV);
-}
-#endif
-
-int
-trap_pfault(frame, usermode, eva)
- struct trapframe *frame;
- int usermode;
- vm_offset_t eva;
-{
- vm_offset_t va;
- struct vmspace *vm = NULL;
- vm_map_t map = 0;
- int rv = 0;
- vm_prot_t ftype;
- struct proc *p = curproc;
-
- va = trunc_page(eva);
- if (va >= KERNBASE) {
- /*
- * Don't allow user-mode faults in kernel address space.
- * An exception: if the faulting address is the invalid
- * instruction entry in the IDT, then the Intel Pentium
- * F00F bug workaround was triggered, and we need to
- * treat it is as an illegal instruction, and not a page
- * fault.
- */
-#if defined(I586_CPU) && !defined(NO_F00F_HACK)
- if ((eva == (unsigned int)&idt[6]) && has_f00f_bug) {
- frame->tf_trapno = T_PRIVINFLT;
- return -2;
- }
-#endif
- if (usermode)
- goto nogo;
-
- map = kernel_map;
- } else {
- /*
- * This is a fault on non-kernel virtual memory.
- * vm is initialized above to NULL. If curproc is NULL
- * or curproc->p_vmspace is NULL the fault is fatal.
- */
- if (p != NULL)
- vm = p->p_vmspace;
-
- if (vm == NULL)
- goto nogo;
-
- map = &vm->vm_map;
- }
-
- if (frame->tf_err & PGEX_W)
- ftype = VM_PROT_READ | VM_PROT_WRITE;
- else
- ftype = VM_PROT_READ;
-
- if (map != kernel_map) {
- /*
- * Keep swapout from messing with us during this
- * critical time.
- */
- ++p->p_lock;
-
- /*
- * Grow the stack if necessary
- */
- /* grow_stack returns false only if va falls into
- * a growable stack region and the stack growth
- * fails. It returns true if va was not within
- * a growable stack region, or if the stack
- * growth succeeded.
- */
- if (!grow_stack (p, va)) {
- rv = KERN_FAILURE;
- --p->p_lock;
- goto nogo;
- }
-
- /* Fault in the user page: */
- rv = vm_fault(map, va, ftype,
- (ftype & VM_PROT_WRITE) ? VM_FAULT_DIRTY
- : VM_FAULT_NORMAL);
-
- --p->p_lock;
- } else {
- /*
- * Don't have to worry about process locking or stacks in the kernel.
- */
- rv = vm_fault(map, va, ftype, VM_FAULT_NORMAL);
- }
-
- if (rv == KERN_SUCCESS)
- return (0);
-nogo:
- if (!usermode) {
- if (intr_nesting_level == 0 && curpcb && curpcb->pcb_onfault) {
- frame->tf_eip = (int)curpcb->pcb_onfault;
- return (0);
- }
- trap_fatal(frame, eva);
- return (-1);
- }
-
- /* kludge to pass faulting virtual address to sendsig */
- frame->tf_err = eva;
-
- return((rv == KERN_PROTECTION_FAILURE) ? SIGBUS : SIGSEGV);
-}
-
-static void
-trap_fatal(frame, eva)
- struct trapframe *frame;
- vm_offset_t eva;
-{
- int code, type, ss, esp;
- struct soft_segment_descriptor softseg;
-
- code = frame->tf_err;
- type = frame->tf_trapno;
- sdtossd(&gdt[IDXSEL(frame->tf_cs & 0xffff)].sd, &softseg);
-
- if (type <= MAX_TRAP_MSG)
- printf("\n\nFatal trap %d: %s while in %s mode\n",
- type, trap_msg[type],
- frame->tf_eflags & PSL_VM ? "vm86" :
- ISPL(frame->tf_cs) == SEL_UPL ? "user" : "kernel");
-#ifdef SMP
- /* three seperate prints in case of a trap on an unmapped page */
- printf("mp_lock = %08x; ", mp_lock);
- printf("cpuid = %d; ", cpuid);
- printf("lapic.id = %08x\n", lapic.id);
-#endif
- if (type == T_PAGEFLT) {
- printf("fault virtual address = 0x%x\n", eva);
- printf("fault code = %s %s, %s\n",
- code & PGEX_U ? "user" : "supervisor",
- code & PGEX_W ? "write" : "read",
- code & PGEX_P ? "protection violation" : "page not present");
- }
- printf("instruction pointer = 0x%x:0x%x\n",
- frame->tf_cs & 0xffff, frame->tf_eip);
- if ((ISPL(frame->tf_cs) == SEL_UPL) || (frame->tf_eflags & PSL_VM)) {
- ss = frame->tf_ss & 0xffff;
- esp = frame->tf_esp;
- } else {
- ss = GSEL(GDATA_SEL, SEL_KPL);
- esp = (int)&frame->tf_esp;
- }
- printf("stack pointer = 0x%x:0x%x\n", ss, esp);
- printf("frame pointer = 0x%x:0x%x\n", ss, frame->tf_ebp);
- printf("code segment = base 0x%x, limit 0x%x, type 0x%x\n",
- softseg.ssd_base, softseg.ssd_limit, softseg.ssd_type);
- printf(" = DPL %d, pres %d, def32 %d, gran %d\n",
- softseg.ssd_dpl, softseg.ssd_p, softseg.ssd_def32,
- softseg.ssd_gran);
- printf("processor eflags = ");
- if (frame->tf_eflags & PSL_T)
- printf("trace trap, ");
- if (frame->tf_eflags & PSL_I)
- printf("interrupt enabled, ");
- if (frame->tf_eflags & PSL_NT)
- printf("nested task, ");
- if (frame->tf_eflags & PSL_RF)
- printf("resume, ");
- if (frame->tf_eflags & PSL_VM)
- printf("vm86, ");
- printf("IOPL = %d\n", (frame->tf_eflags & PSL_IOPL) >> 12);
- printf("current process = ");
- if (curproc) {
- printf("%lu (%s)\n",
- (u_long)curproc->p_pid, curproc->p_comm ?
- curproc->p_comm : "");
- } else {
- printf("Idle\n");
- }
- printf("interrupt mask = ");
- if ((cpl & net_imask) == net_imask)
- printf("net ");
- if ((cpl & tty_imask) == tty_imask)
- printf("tty ");
- if ((cpl & bio_imask) == bio_imask)
- printf("bio ");
- if ((cpl & cam_imask) == cam_imask)
- printf("cam ");
- if (cpl == 0)
- printf("none");
-#ifdef SMP
-/**
- * XXX FIXME:
- * we probably SHOULD have stopped the other CPUs before now!
- * another CPU COULD have been touching cpl at this moment...
- */
- printf(" <- SMP: XXX");
-#endif
- printf("\n");
-
-#ifdef KDB
- if (kdb_trap(&psl))
- return;
-#endif
-#ifdef DDB
- if ((debugger_on_panic || db_active) && kdb_trap(type, 0, frame))
- return;
-#endif
- printf("trap number = %d\n", type);
- if (type <= MAX_TRAP_MSG)
- panic(trap_msg[type]);
- else
- panic("unknown/reserved trap");
-}
-
-/*
- * Double fault handler. Called when a fault occurs while writing
- * a frame for a trap/exception onto the stack. This usually occurs
- * when the stack overflows (such is the case with infinite recursion,
- * for example).
- *
- * XXX Note that the current PTD gets replaced by IdlePTD when the
- * task switch occurs. This means that the stack that was active at
- * the time of the double fault is not available at <kstack> unless
- * the machine was idle when the double fault occurred. The downside
- * of this is that "trace <ebp>" in ddb won't work.
- */
-void
-dblfault_handler()
-{
- printf("\nFatal double fault:\n");
- printf("eip = 0x%x\n", common_tss.tss_eip);
- printf("esp = 0x%x\n", common_tss.tss_esp);
- printf("ebp = 0x%x\n", common_tss.tss_ebp);
-#ifdef SMP
- /* three seperate prints in case of a trap on an unmapped page */
- printf("mp_lock = %08x; ", mp_lock);
- printf("cpuid = %d; ", cpuid);
- printf("lapic.id = %08x\n", lapic.id);
-#endif
- panic("double fault");
-}
-
-/*
- * Compensate for 386 brain damage (missing URKR).
- * This is a little simpler than the pagefault handler in trap() because
- * it the page tables have already been faulted in and high addresses
- * are thrown out early for other reasons.
- */
-int trapwrite(addr)
- unsigned addr;
-{
- struct proc *p;
- vm_offset_t va;
- struct vmspace *vm;
- int rv;
-
- va = trunc_page((vm_offset_t)addr);
- /*
- * XXX - MAX is END. Changed > to >= for temp. fix.
- */
- if (va >= VM_MAXUSER_ADDRESS)
- return (1);
-
- p = curproc;
- vm = p->p_vmspace;
-
- ++p->p_lock;
-
- if (!grow_stack (p, va)) {
- --p->p_lock;
- return (1);
- }
-
- /*
- * fault the data page
- */
- rv = vm_fault(&vm->vm_map, va, VM_PROT_READ|VM_PROT_WRITE, VM_FAULT_DIRTY);
-
- --p->p_lock;
-
- if (rv != KERN_SUCCESS)
- return 1;
-
- return (0);
-}
-
-/*
- * System call request from POSIX system call gate interface to kernel.
- * Like trap(), argument is call by reference.
- */
-void
-syscall(frame)
- struct trapframe frame;
-{
- caddr_t params;
- int i;
- struct sysent *callp;
- struct proc *p = curproc;
- u_quad_t sticks;
- int error;
- int args[8];
- u_int code;
-
-#ifdef DIAGNOSTIC
- if (ISPL(frame.tf_cs) != SEL_UPL)
- panic("syscall");
-#endif
- sticks = p->p_sticks;
- p->p_md.md_regs = &frame;
- params = (caddr_t)frame.tf_esp + sizeof(int);
- code = frame.tf_eax;
- if (p->p_sysent->sv_prepsyscall) {
- (*p->p_sysent->sv_prepsyscall)(&frame, args, &code, &params);
- } else {
- /*
- * Need to check if this is a 32 bit or 64 bit syscall.
- */
- if (code == SYS_syscall) {
- /*
- * Code is first argument, followed by actual args.
- */
- code = fuword(params);
- params += sizeof(int);
- } else if (code == SYS___syscall) {
- /*
- * Like syscall, but code is a quad, so as to maintain
- * quad alignment for the rest of the arguments.
- */
- code = fuword(params);
- params += sizeof(quad_t);
- }
- }
-
- if (p->p_sysent->sv_mask)
- code &= p->p_sysent->sv_mask;
-
- if (code >= p->p_sysent->sv_size)
- callp = &p->p_sysent->sv_table[0];
- else
- callp = &p->p_sysent->sv_table[code];
-
- if (params && (i = callp->sy_narg * sizeof(int)) &&
- (error = copyin(params, (caddr_t)args, (u_int)i))) {
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSCALL))
- ktrsyscall(p->p_tracep, code, callp->sy_narg, args);
-#endif
- goto bad;
- }
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSCALL))
- ktrsyscall(p->p_tracep, code, callp->sy_narg, args);
-#endif
- p->p_retval[0] = 0;
- p->p_retval[1] = frame.tf_edx;
-
- STOPEVENT(p, S_SCE, callp->sy_narg);
-
- error = (*callp->sy_call)(p, args);
-
- switch (error) {
-
- case 0:
- /*
- * Reinitialize proc pointer `p' as it may be different
- * if this is a child returning from fork syscall.
- */
- p = curproc;
- frame.tf_eax = p->p_retval[0];
- frame.tf_edx = p->p_retval[1];
- frame.tf_eflags &= ~PSL_C;
- break;
-
- case ERESTART:
- /*
- * Reconstruct pc, assuming lcall $X,y is 7 bytes,
- * int 0x80 is 2 bytes. We saved this in tf_err.
- */
- frame.tf_eip -= frame.tf_err;
- break;
-
- case EJUSTRETURN:
- break;
-
- default:
-bad:
- if (p->p_sysent->sv_errsize) {
- if (error >= p->p_sysent->sv_errsize)
- error = -1; /* XXX */
- else
- error = p->p_sysent->sv_errtbl[error];
- }
- frame.tf_eax = error;
- frame.tf_eflags |= PSL_C;
- break;
- }
-
- if ((frame.tf_eflags & PSL_T) && !(frame.tf_eflags & PSL_VM)) {
- /* Traced syscall. */
- frame.tf_eflags &= ~PSL_T;
- trapsignal(p, SIGTRAP, 0);
- }
-
- userret(p, &frame, sticks);
-
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSRET))
- ktrsysret(p->p_tracep, code, error, p->p_retval[0]);
-#endif
-
- /*
- * This works because errno is findable through the
- * register set. If we ever support an emulation where this
- * is not the case, this code will need to be revisited.
- */
- STOPEVENT(p, S_SCX, code);
-
-}
-
-/*
- * Simplified back end of syscall(), used when returning from fork()
- * directly into user mode.
- */
-void
-fork_return(p, frame)
- struct proc *p;
- struct trapframe frame;
-{
- frame.tf_eax = 0; /* Child returns zero */
- frame.tf_eflags &= ~PSL_C; /* success */
- frame.tf_edx = 1;
-
- userret(p, &frame, 0);
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSRET))
- ktrsysret(p->p_tracep, SYS_fork, 0, 0);
-#endif
-}
diff --git a/sys/amd64/amd64/tsc.c b/sys/amd64/amd64/tsc.c
deleted file mode 100644
index ea39018548b9..000000000000
--- a/sys/amd64/amd64/tsc.c
+++ /dev/null
@@ -1,1230 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz and Don Ahn.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)clock.c 7.2 (Berkeley) 5/12/91
- * $FreeBSD$
- */
-
-/*
- * Routines to handle clock hardware.
- */
-
-/*
- * inittodr, settodr and support routines written
- * by Christoph Robitschko <chmr@edvz.tu-graz.ac.at>
- *
- * reintroduced and updated by Chris Stenton <chris@gnome.co.uk> 8/10/94
- */
-
-#include "opt_clock.h"
-#include "apm.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/time.h>
-#include <sys/kernel.h>
-#ifndef SMP
-#include <sys/lock.h>
-#endif
-#include <sys/sysctl.h>
-#include <sys/cons.h>
-
-#include <machine/clock.h>
-#ifdef CLK_CALIBRATION_LOOP
-#endif
-#include <machine/cputypes.h>
-#include <machine/frame.h>
-#include <machine/ipl.h>
-#include <machine/limits.h>
-#include <machine/md_var.h>
-#include <machine/psl.h>
-#ifdef APIC_IO
-#include <machine/segments.h>
-#endif
-#if defined(SMP) || defined(APIC_IO)
-#include <machine/smp.h>
-#endif /* SMP || APIC_IO */
-#include <machine/specialreg.h>
-
-#include <i386/isa/icu.h>
-#include <i386/isa/isa.h>
-#include <isa/rtc.h>
-#include <i386/isa/timerreg.h>
-
-#include <i386/isa/intr_machdep.h>
-
-#include "mca.h"
-#if NMCA > 0
-#include <i386/isa/mca_machdep.h>
-#endif
-
-#ifdef SMP
-#define disable_intr() CLOCK_DISABLE_INTR()
-#define enable_intr() CLOCK_ENABLE_INTR()
-
-#ifdef APIC_IO
-#include <i386/isa/intr_machdep.h>
-/* The interrupt triggered by the 8254 (timer) chip */
-int apic_8254_intr;
-static u_long read_intr_count __P((int vec));
-static void setup_8254_mixed_mode __P((void));
-#endif
-#endif /* SMP */
-
-/*
- * 32-bit time_t's can't reach leap years before 1904 or after 2036, so we
- * can use a simple formula for leap years.
- */
-#define LEAPYEAR(y) ((u_int)(y) % 4 == 0)
-#define DAYSPERYEAR (31+28+31+30+31+30+31+31+30+31+30+31)
-
-#define TIMER_DIV(x) ((timer_freq + (x) / 2) / (x))
-
-/*
- * Time in timer cycles that it takes for microtime() to disable interrupts
- * and latch the count. microtime() currently uses "cli; outb ..." so it
- * normally takes less than 2 timer cycles. Add a few for cache misses.
- * Add a few more to allow for latency in bogus calls to microtime() with
- * interrupts already disabled.
- */
-#define TIMER0_LATCH_COUNT 20
-
-/*
- * Maximum frequency that we are willing to allow for timer0. Must be
- * low enough to guarantee that the timer interrupt handler returns
- * before the next timer interrupt.
- */
-#define TIMER0_MAX_FREQ 20000
-
-int adjkerntz; /* local offset from GMT in seconds */
-int clkintr_pending;
-int disable_rtc_set; /* disable resettodr() if != 0 */
-volatile u_int idelayed;
-int statclock_disable;
-u_int stat_imask = SWI_CLOCK_MASK;
-#ifndef TIMER_FREQ
-#define TIMER_FREQ 1193182
-#endif
-u_int timer_freq = TIMER_FREQ;
-int timer0_max_count;
-u_int tsc_freq;
-int tsc_is_broken;
-int wall_cmos_clock; /* wall CMOS clock assumed if != 0 */
-
-static int beeping = 0;
-static u_int clk_imask = HWI_MASK | SWI_MASK;
-static const u_char daysinmonth[] = {31,28,31,30,31,30,31,31,30,31,30,31};
-static u_int hardclock_max_count;
-static u_int32_t i8254_lastcount;
-static u_int32_t i8254_offset;
-static int i8254_ticked;
-/*
- * XXX new_function and timer_func should not handle clockframes, but
- * timer_func currently needs to hold hardclock to handle the
- * timer0_state == 0 case. We should use inthand_add()/inthand_remove()
- * to switch between clkintr() and a slightly different timerintr().
- */
-static void (*new_function) __P((struct clockframe *frame));
-static u_int new_rate;
-static u_char rtc_statusa = RTCSA_DIVIDER | RTCSA_NOPROF;
-static u_char rtc_statusb = RTCSB_24HR | RTCSB_PINTR;
-static u_int timer0_prescaler_count;
-
-/* Values for timerX_state: */
-#define RELEASED 0
-#define RELEASE_PENDING 1
-#define ACQUIRED 2
-#define ACQUIRE_PENDING 3
-
-static u_char timer0_state;
-static u_char timer2_state;
-static void (*timer_func) __P((struct clockframe *frame)) = hardclock;
-static u_int tsc_present;
-
-static unsigned i8254_get_timecount __P((struct timecounter *tc));
-static unsigned tsc_get_timecount __P((struct timecounter *tc));
-static void set_timer_freq(u_int freq, int intr_freq);
-
-static struct timecounter tsc_timecounter = {
- tsc_get_timecount, /* get_timecount */
- 0, /* no poll_pps */
- ~0u, /* counter_mask */
- 0, /* frequency */
- "TSC" /* name */
-};
-
-SYSCTL_OPAQUE(_debug, OID_AUTO, tsc_timecounter, CTLFLAG_RD,
- &tsc_timecounter, sizeof(tsc_timecounter), "S,timecounter", "");
-
-static struct timecounter i8254_timecounter = {
- i8254_get_timecount, /* get_timecount */
- 0, /* no poll_pps */
- ~0u, /* counter_mask */
- 0, /* frequency */
- "i8254" /* name */
-};
-
-SYSCTL_OPAQUE(_debug, OID_AUTO, i8254_timecounter, CTLFLAG_RD,
- &i8254_timecounter, sizeof(i8254_timecounter), "S,timecounter", "");
-
-static void
-clkintr(struct clockframe frame)
-{
- if (timecounter->tc_get_timecount == i8254_get_timecount) {
- disable_intr();
- if (i8254_ticked)
- i8254_ticked = 0;
- else {
- i8254_offset += timer0_max_count;
- i8254_lastcount = 0;
- }
- clkintr_pending = 0;
- enable_intr();
- }
- timer_func(&frame);
- switch (timer0_state) {
-
- case RELEASED:
- setdelayed();
- break;
-
- case ACQUIRED:
- if ((timer0_prescaler_count += timer0_max_count)
- >= hardclock_max_count) {
- timer0_prescaler_count -= hardclock_max_count;
- hardclock(&frame);
- setdelayed();
- }
- break;
-
- case ACQUIRE_PENDING:
- disable_intr();
- i8254_offset = i8254_get_timecount(NULL);
- i8254_lastcount = 0;
- timer0_max_count = TIMER_DIV(new_rate);
- outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
- outb(TIMER_CNTR0, timer0_max_count & 0xff);
- outb(TIMER_CNTR0, timer0_max_count >> 8);
- enable_intr();
- timer_func = new_function;
- timer0_state = ACQUIRED;
- setdelayed();
- break;
-
- case RELEASE_PENDING:
- if ((timer0_prescaler_count += timer0_max_count)
- >= hardclock_max_count) {
- disable_intr();
- i8254_offset = i8254_get_timecount(NULL);
- i8254_lastcount = 0;
- timer0_max_count = hardclock_max_count;
- outb(TIMER_MODE,
- TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
- outb(TIMER_CNTR0, timer0_max_count & 0xff);
- outb(TIMER_CNTR0, timer0_max_count >> 8);
- enable_intr();
- timer0_prescaler_count = 0;
- timer_func = hardclock;
- timer0_state = RELEASED;
- hardclock(&frame);
- setdelayed();
- }
- break;
- }
-#if NMCA > 0
- /* Reset clock interrupt by asserting bit 7 of port 0x61 */
- if (MCA_system)
- outb(0x61, inb(0x61) | 0x80);
-#endif
-}
-
-/*
- * The acquire and release functions must be called at ipl >= splclock().
- */
-int
-acquire_timer0(int rate, void (*function) __P((struct clockframe *frame)))
-{
- static int old_rate;
-
- if (rate <= 0 || rate > TIMER0_MAX_FREQ)
- return (-1);
- switch (timer0_state) {
-
- case RELEASED:
- timer0_state = ACQUIRE_PENDING;
- break;
-
- case RELEASE_PENDING:
- if (rate != old_rate)
- return (-1);
- /*
- * The timer has been released recently, but is being
- * re-acquired before the release completed. In this
- * case, we simply reclaim it as if it had not been
- * released at all.
- */
- timer0_state = ACQUIRED;
- break;
-
- default:
- return (-1); /* busy */
- }
- new_function = function;
- old_rate = new_rate = rate;
- return (0);
-}
-
-int
-acquire_timer2(int mode)
-{
-
- if (timer2_state != RELEASED)
- return (-1);
- timer2_state = ACQUIRED;
-
- /*
- * This access to the timer registers is as atomic as possible
- * because it is a single instruction. We could do better if we
- * knew the rate. Use of splclock() limits glitches to 10-100us,
- * and this is probably good enough for timer2, so we aren't as
- * careful with it as with timer0.
- */
- outb(TIMER_MODE, TIMER_SEL2 | (mode & 0x3f));
-
- return (0);
-}
-
-int
-release_timer0()
-{
- switch (timer0_state) {
-
- case ACQUIRED:
- timer0_state = RELEASE_PENDING;
- break;
-
- case ACQUIRE_PENDING:
- /* Nothing happened yet, release quickly. */
- timer0_state = RELEASED;
- break;
-
- default:
- return (-1);
- }
- return (0);
-}
-
-int
-release_timer2()
-{
-
- if (timer2_state != ACQUIRED)
- return (-1);
- timer2_state = RELEASED;
- outb(TIMER_MODE, TIMER_SEL2 | TIMER_SQWAVE | TIMER_16BIT);
- return (0);
-}
-
-/*
- * This routine receives statistical clock interrupts from the RTC.
- * As explained above, these occur at 128 interrupts per second.
- * When profiling, we receive interrupts at a rate of 1024 Hz.
- *
- * This does not actually add as much overhead as it sounds, because
- * when the statistical clock is active, the hardclock driver no longer
- * needs to keep (inaccurate) statistics on its own. This decouples
- * statistics gathering from scheduling interrupts.
- *
- * The RTC chip requires that we read status register C (RTC_INTR)
- * to acknowledge an interrupt, before it will generate the next one.
- * Under high interrupt load, rtcintr() can be indefinitely delayed and
- * the clock can tick immediately after the read from RTC_INTR. In this
- * case, the mc146818A interrupt signal will not drop for long enough
- * to register with the 8259 PIC. If an interrupt is missed, the stat
- * clock will halt, considerably degrading system performance. This is
- * why we use 'while' rather than a more straightforward 'if' below.
- * Stat clock ticks can still be lost, causing minor loss of accuracy
- * in the statistics, but the stat clock will no longer stop.
- */
-static void
-rtcintr(struct clockframe frame)
-{
- while (rtcin(RTC_INTR) & RTCIR_PERIOD)
- statclock(&frame);
-}
-
-#include "opt_ddb.h"
-#ifdef DDB
-#include <ddb/ddb.h>
-
-DB_SHOW_COMMAND(rtc, rtc)
-{
- printf("%02x/%02x/%02x %02x:%02x:%02x, A = %02x, B = %02x, C = %02x\n",
- rtcin(RTC_YEAR), rtcin(RTC_MONTH), rtcin(RTC_DAY),
- rtcin(RTC_HRS), rtcin(RTC_MIN), rtcin(RTC_SEC),
- rtcin(RTC_STATUSA), rtcin(RTC_STATUSB), rtcin(RTC_INTR));
-}
-#endif /* DDB */
-
-static int
-getit(void)
-{
- u_long ef;
- int high, low;
-
- ef = read_eflags();
- disable_intr();
-
- /* Select timer0 and latch counter value. */
- outb(TIMER_MODE, TIMER_SEL0 | TIMER_LATCH);
-
- low = inb(TIMER_CNTR0);
- high = inb(TIMER_CNTR0);
-
- CLOCK_UNLOCK();
- write_eflags(ef);
- return ((high << 8) | low);
-}
-
-/*
- * Wait "n" microseconds.
- * Relies on timer 1 counting down from (timer_freq / hz)
- * Note: timer had better have been programmed before this is first used!
- */
-void
-DELAY(int n)
-{
- int delta, prev_tick, tick, ticks_left;
-
-#ifdef DELAYDEBUG
- int getit_calls = 1;
- int n1;
- static int state = 0;
-
- if (state == 0) {
- state = 1;
- for (n1 = 1; n1 <= 10000000; n1 *= 10)
- DELAY(n1);
- state = 2;
- }
- if (state == 1)
- printf("DELAY(%d)...", n);
-#endif
- /*
- * Guard against the timer being uninitialized if we are called
- * early for console i/o.
- */
- if (timer0_max_count == 0)
- set_timer_freq(timer_freq, hz);
-
- /*
- * Read the counter first, so that the rest of the setup overhead is
- * counted. Guess the initial overhead is 20 usec (on most systems it
- * takes about 1.5 usec for each of the i/o's in getit(). The loop
- * takes about 6 usec on a 486/33 and 13 usec on a 386/20. The
- * multiplications and divisions to scale the count take a while).
- */
- prev_tick = getit();
- n -= 0; /* XXX actually guess no initial overhead */
- /*
- * Calculate (n * (timer_freq / 1e6)) without using floating point
- * and without any avoidable overflows.
- */
- if (n <= 0)
- ticks_left = 0;
- else if (n < 256)
- /*
- * Use fixed point to avoid a slow division by 1000000.
- * 39099 = 1193182 * 2^15 / 10^6 rounded to nearest.
- * 2^15 is the first power of 2 that gives exact results
- * for n between 0 and 256.
- */
- ticks_left = ((u_int)n * 39099 + (1 << 15) - 1) >> 15;
- else
- /*
- * Don't bother using fixed point, although gcc-2.7.2
- * generates particularly poor code for the long long
- * division, since even the slow way will complete long
- * before the delay is up (unless we're interrupted).
- */
- ticks_left = ((u_int)n * (long long)timer_freq + 999999)
- / 1000000;
-
- while (ticks_left > 0) {
- tick = getit();
-#ifdef DELAYDEBUG
- ++getit_calls;
-#endif
- delta = prev_tick - tick;
- prev_tick = tick;
- if (delta < 0) {
- delta += timer0_max_count;
- /*
- * Guard against timer0_max_count being wrong.
- * This shouldn't happen in normal operation,
- * but it may happen if set_timer_freq() is
- * traced.
- */
- if (delta < 0)
- delta = 0;
- }
- ticks_left -= delta;
- }
-#ifdef DELAYDEBUG
- if (state == 1)
- printf(" %d calls to getit() at %d usec each\n",
- getit_calls, (n + 5) / getit_calls);
-#endif
-}
-
-static void
-sysbeepstop(void *chan)
-{
- outb(IO_PPI, inb(IO_PPI)&0xFC); /* disable counter2 output to speaker */
- release_timer2();
- beeping = 0;
-}
-
-int
-sysbeep(int pitch, int period)
-{
- int x = splclock();
-
- if (acquire_timer2(TIMER_SQWAVE|TIMER_16BIT))
- if (!beeping) {
- /* Something else owns it. */
- splx(x);
- return (-1); /* XXX Should be EBUSY, but nobody cares anyway. */
- }
- disable_intr();
- outb(TIMER_CNTR2, pitch);
- outb(TIMER_CNTR2, (pitch>>8));
- enable_intr();
- if (!beeping) {
- /* enable counter2 output to speaker */
- outb(IO_PPI, inb(IO_PPI) | 3);
- beeping = period;
- timeout(sysbeepstop, (void *)NULL, period);
- }
- splx(x);
- return (0);
-}
-
-/*
- * RTC support routines
- */
-
-int
-rtcin(reg)
- int reg;
-{
- int s;
- u_char val;
-
- s = splhigh();
- outb(IO_RTC, reg);
- inb(0x84);
- val = inb(IO_RTC + 1);
- inb(0x84);
- splx(s);
- return (val);
-}
-
-static __inline void
-writertc(u_char reg, u_char val)
-{
- int s;
-
- s = splhigh();
- inb(0x84);
- outb(IO_RTC, reg);
- inb(0x84);
- outb(IO_RTC + 1, val);
- inb(0x84); /* XXX work around wrong order in rtcin() */
- splx(s);
-}
-
-static __inline int
-readrtc(int port)
-{
- return(bcd2bin(rtcin(port)));
-}
-
-static u_int
-calibrate_clocks(void)
-{
- u_int64_t old_tsc;
- u_int count, prev_count, tot_count;
- int sec, start_sec, timeout;
-
- if (bootverbose)
- printf("Calibrating clock(s) ... ");
- if (!(rtcin(RTC_STATUSD) & RTCSD_PWR))
- goto fail;
- timeout = 100000000;
-
- /* Read the mc146818A seconds counter. */
- for (;;) {
- if (!(rtcin(RTC_STATUSA) & RTCSA_TUP)) {
- sec = rtcin(RTC_SEC);
- break;
- }
- if (--timeout == 0)
- goto fail;
- }
-
- /* Wait for the mC146818A seconds counter to change. */
- start_sec = sec;
- for (;;) {
- if (!(rtcin(RTC_STATUSA) & RTCSA_TUP)) {
- sec = rtcin(RTC_SEC);
- if (sec != start_sec)
- break;
- }
- if (--timeout == 0)
- goto fail;
- }
-
- /* Start keeping track of the i8254 counter. */
- prev_count = getit();
- if (prev_count == 0 || prev_count > timer0_max_count)
- goto fail;
- tot_count = 0;
-
- if (tsc_present)
- old_tsc = rdtsc();
- else
- old_tsc = 0; /* shut up gcc */
-
- /*
- * Wait for the mc146818A seconds counter to change. Read the i8254
- * counter for each iteration since this is convenient and only
- * costs a few usec of inaccuracy. The timing of the final reads
- * of the counters almost matches the timing of the initial reads,
- * so the main cause of inaccuracy is the varying latency from
- * inside getit() or rtcin(RTC_STATUSA) to the beginning of the
- * rtcin(RTC_SEC) that returns a changed seconds count. The
- * maximum inaccuracy from this cause is < 10 usec on 486's.
- */
- start_sec = sec;
- for (;;) {
- if (!(rtcin(RTC_STATUSA) & RTCSA_TUP))
- sec = rtcin(RTC_SEC);
- count = getit();
- if (count == 0 || count > timer0_max_count)
- goto fail;
- if (count > prev_count)
- tot_count += prev_count - (count - timer0_max_count);
- else
- tot_count += prev_count - count;
- prev_count = count;
- if (sec != start_sec)
- break;
- if (--timeout == 0)
- goto fail;
- }
-
- /*
- * Read the cpu cycle counter. The timing considerations are
- * similar to those for the i8254 clock.
- */
- if (tsc_present)
- tsc_freq = rdtsc() - old_tsc;
-
- if (bootverbose) {
- if (tsc_present)
- printf("TSC clock: %u Hz, ", tsc_freq);
- printf("i8254 clock: %u Hz\n", tot_count);
- }
- return (tot_count);
-
-fail:
- if (bootverbose)
- printf("failed, using default i8254 clock of %u Hz\n",
- timer_freq);
- return (timer_freq);
-}
-
-static void
-set_timer_freq(u_int freq, int intr_freq)
-{
- u_long ef;
- int new_timer0_max_count;
-
- ef = read_eflags();
- disable_intr();
- timer_freq = freq;
- new_timer0_max_count = hardclock_max_count = TIMER_DIV(intr_freq);
- if (new_timer0_max_count != timer0_max_count) {
- timer0_max_count = new_timer0_max_count;
- outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
- outb(TIMER_CNTR0, timer0_max_count & 0xff);
- outb(TIMER_CNTR0, timer0_max_count >> 8);
- }
- CLOCK_UNLOCK();
- write_eflags(ef);
-}
-
-/*
- * i8254_restore is called from apm_default_resume() to reload
- * the countdown register.
- * this should not be necessary but there are broken laptops that
- * do not restore the countdown register on resume.
- * when it happnes, it messes up the hardclock interval and system clock,
- * which leads to the infamous "calcru: negative time" problem.
- */
-void
-i8254_restore(void)
-{
- u_long ef;
-
- ef = read_eflags();
- disable_intr();
- outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
- outb(TIMER_CNTR0, timer0_max_count & 0xff);
- outb(TIMER_CNTR0, timer0_max_count >> 8);
- CLOCK_UNLOCK();
- write_eflags(ef);
-}
-
-/*
- * Initialize 8254 timer 0 early so that it can be used in DELAY().
- * XXX initialization of other timers is unintentionally left blank.
- */
-void
-startrtclock()
-{
- u_int delta, freq;
-
- if (cpu_feature & CPUID_TSC)
- tsc_present = 1;
- else
- tsc_present = 0;
-
- writertc(RTC_STATUSA, rtc_statusa);
- writertc(RTC_STATUSB, RTCSB_24HR);
-
- set_timer_freq(timer_freq, hz);
- freq = calibrate_clocks();
-#ifdef CLK_CALIBRATION_LOOP
- if (bootverbose) {
- printf(
- "Press a key on the console to abort clock calibration\n");
- while (cncheckc() == -1)
- calibrate_clocks();
- }
-#endif
-
- /*
- * Use the calibrated i8254 frequency if it seems reasonable.
- * Otherwise use the default, and don't use the calibrated i586
- * frequency.
- */
- delta = freq > timer_freq ? freq - timer_freq : timer_freq - freq;
- if (delta < timer_freq / 100) {
-#ifndef CLK_USE_I8254_CALIBRATION
- if (bootverbose)
- printf(
-"CLK_USE_I8254_CALIBRATION not specified - using default frequency\n");
- freq = timer_freq;
-#endif
- timer_freq = freq;
- } else {
- if (bootverbose)
- printf(
- "%d Hz differs from default of %d Hz by more than 1%%\n",
- freq, timer_freq);
- tsc_freq = 0;
- }
-
- set_timer_freq(timer_freq, hz);
- i8254_timecounter.tc_frequency = timer_freq;
- init_timecounter(&i8254_timecounter);
-
-#ifndef CLK_USE_TSC_CALIBRATION
- if (tsc_freq != 0) {
- if (bootverbose)
- printf(
-"CLK_USE_TSC_CALIBRATION not specified - using old calibration method\n");
- tsc_freq = 0;
- }
-#endif
- if (tsc_present && tsc_freq == 0) {
- /*
- * Calibration of the i586 clock relative to the mc146818A
- * clock failed. Do a less accurate calibration relative
- * to the i8254 clock.
- */
- u_int64_t old_tsc = rdtsc();
-
- DELAY(1000000);
- tsc_freq = rdtsc() - old_tsc;
-#ifdef CLK_USE_TSC_CALIBRATION
- if (bootverbose)
- printf("TSC clock: %u Hz (Method B)\n", tsc_freq);
-#endif
- }
-
-#if !defined(SMP)
- /*
- * We can not use the TSC in SMP mode, until we figure out a
- * cheap (impossible), reliable and precise (yeah right!) way
- * to synchronize the TSCs of all the CPUs.
- * Curse Intel for leaving the counter out of the I/O APIC.
- */
-
-#if NAPM > 0
- /*
- * We can not use the TSC if we support APM. Precise timekeeping
- * on an APM'ed machine is at best a fools pursuit, since
- * any and all of the time spent in various SMM code can't
- * be reliably accounted for. Reading the RTC is your only
- * source of reliable time info. The i8254 looses too of course
- * but we need to have some kind of time...
- * We don't know at this point whether APM is going to be used
- * or not, nor when it might be activated. Play it safe.
- */
- return;
-#endif /* NAPM > 0 */
-
- if (tsc_present && tsc_freq != 0 && !tsc_is_broken) {
- tsc_timecounter.tc_frequency = tsc_freq;
- init_timecounter(&tsc_timecounter);
- }
-
-#endif /* !defined(SMP) */
-}
-
-/*
- * Initialize the time of day register, based on the time base which is, e.g.
- * from a filesystem.
- */
-void
-inittodr(time_t base)
-{
- unsigned long sec, days;
- int yd;
- int year, month;
- int y, m, s;
- struct timespec ts;
-
- if (base) {
- s = splclock();
- ts.tv_sec = base;
- ts.tv_nsec = 0;
- set_timecounter(&ts);
- splx(s);
- }
-
- /* Look if we have a RTC present and the time is valid */
- if (!(rtcin(RTC_STATUSD) & RTCSD_PWR))
- goto wrong_time;
-
- /* wait for time update to complete */
- /* If RTCSA_TUP is zero, we have at least 244us before next update */
- s = splhigh();
- while (rtcin(RTC_STATUSA) & RTCSA_TUP) {
- splx(s);
- s = splhigh();
- }
-
- days = 0;
-#ifdef USE_RTC_CENTURY
- year = readrtc(RTC_YEAR) + readrtc(RTC_CENTURY) * 100;
-#else
- year = readrtc(RTC_YEAR) + 1900;
- if (year < 1970)
- year += 100;
-#endif
- if (year < 1970) {
- splx(s);
- goto wrong_time;
- }
- month = readrtc(RTC_MONTH);
- for (m = 1; m < month; m++)
- days += daysinmonth[m-1];
- if ((month > 2) && LEAPYEAR(year))
- days ++;
- days += readrtc(RTC_DAY) - 1;
- yd = days;
- for (y = 1970; y < year; y++)
- days += DAYSPERYEAR + LEAPYEAR(y);
- sec = ((( days * 24 +
- readrtc(RTC_HRS)) * 60 +
- readrtc(RTC_MIN)) * 60 +
- readrtc(RTC_SEC));
- /* sec now contains the number of seconds, since Jan 1 1970,
- in the local time zone */
-
- sec += tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
-
- y = time_second - sec;
- if (y <= -2 || y >= 2) {
- /* badly off, adjust it */
- ts.tv_sec = sec;
- ts.tv_nsec = 0;
- set_timecounter(&ts);
- }
- splx(s);
- return;
-
-wrong_time:
- printf("Invalid time in real time clock.\n");
- printf("Check and reset the date immediately!\n");
-}
-
-/*
- * Write system time back to RTC
- */
-void
-resettodr()
-{
- unsigned long tm;
- int y, m, s;
-
- if (disable_rtc_set)
- return;
-
- s = splclock();
- tm = time_second;
- splx(s);
-
- /* Disable RTC updates and interrupts. */
- writertc(RTC_STATUSB, RTCSB_HALT | RTCSB_24HR);
-
- /* Calculate local time to put in RTC */
-
- tm -= tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
-
- writertc(RTC_SEC, bin2bcd(tm%60)); tm /= 60; /* Write back Seconds */
- writertc(RTC_MIN, bin2bcd(tm%60)); tm /= 60; /* Write back Minutes */
- writertc(RTC_HRS, bin2bcd(tm%24)); tm /= 24; /* Write back Hours */
-
- /* We have now the days since 01-01-1970 in tm */
- writertc(RTC_WDAY, (tm+4)%7); /* Write back Weekday */
- for (y = 1970, m = DAYSPERYEAR + LEAPYEAR(y);
- tm >= m;
- y++, m = DAYSPERYEAR + LEAPYEAR(y))
- tm -= m;
-
- /* Now we have the years in y and the day-of-the-year in tm */
- writertc(RTC_YEAR, bin2bcd(y%100)); /* Write back Year */
-#ifdef USE_RTC_CENTURY
- writertc(RTC_CENTURY, bin2bcd(y/100)); /* ... and Century */
-#endif
- for (m = 0; ; m++) {
- int ml;
-
- ml = daysinmonth[m];
- if (m == 1 && LEAPYEAR(y))
- ml++;
- if (tm < ml)
- break;
- tm -= ml;
- }
-
- writertc(RTC_MONTH, bin2bcd(m + 1)); /* Write back Month */
- writertc(RTC_DAY, bin2bcd(tm + 1)); /* Write back Month Day */
-
- /* Reenable RTC updates and interrupts. */
- writertc(RTC_STATUSB, rtc_statusb);
-}
-
-
-/*
- * Start both clocks running.
- */
-void
-cpu_initclocks()
-{
- int diag;
-#ifdef APIC_IO
- int apic_8254_trial;
- struct intrec *clkdesc;
-#endif /* APIC_IO */
-
- if (statclock_disable) {
- /*
- * The stat interrupt mask is different without the
- * statistics clock. Also, don't set the interrupt
- * flag which would normally cause the RTC to generate
- * interrupts.
- */
- stat_imask = HWI_MASK | SWI_MASK;
- rtc_statusb = RTCSB_24HR;
- } else {
- /* Setting stathz to nonzero early helps avoid races. */
- stathz = RTC_NOPROFRATE;
- profhz = RTC_PROFRATE;
- }
-
- /* Finish initializing 8253 timer 0. */
-#ifdef APIC_IO
-
- apic_8254_intr = isa_apic_irq(0);
- apic_8254_trial = 0;
- if (apic_8254_intr >= 0 ) {
- if (apic_int_type(0, 0) == 3)
- apic_8254_trial = 1;
- } else {
- /* look for ExtInt on pin 0 */
- if (apic_int_type(0, 0) == 3) {
- apic_8254_intr = apic_irq(0, 0);
- setup_8254_mixed_mode();
- } else
- panic("APIC_IO: Cannot route 8254 interrupt to CPU");
- }
-
- clkdesc = inthand_add("clk", apic_8254_intr, (inthand2_t *)clkintr,
- NULL, &clk_imask, INTR_EXCL);
- INTREN(1 << apic_8254_intr);
-
-#else /* APIC_IO */
-
- inthand_add("clk", 0, (inthand2_t *)clkintr, NULL, &clk_imask,
- INTR_EXCL);
- INTREN(IRQ0);
-
-#endif /* APIC_IO */
-
- /* Initialize RTC. */
- writertc(RTC_STATUSA, rtc_statusa);
- writertc(RTC_STATUSB, RTCSB_24HR);
-
- /* Don't bother enabling the statistics clock. */
- if (statclock_disable)
- return;
- diag = rtcin(RTC_DIAG);
- if (diag != 0)
- printf("RTC BIOS diagnostic error %b\n", diag, RTCDG_BITS);
-
-#ifdef APIC_IO
- if (isa_apic_irq(8) != 8)
- panic("APIC RTC != 8");
-#endif /* APIC_IO */
-
- inthand_add("rtc", 8, (inthand2_t *)rtcintr, NULL, &stat_imask,
- INTR_EXCL);
-
-#ifdef APIC_IO
- INTREN(APIC_IRQ8);
-#else
- INTREN(IRQ8);
-#endif /* APIC_IO */
-
- writertc(RTC_STATUSB, rtc_statusb);
-
-#ifdef APIC_IO
- if (apic_8254_trial) {
-
- printf("APIC_IO: Testing 8254 interrupt delivery\n");
- while (read_intr_count(8) < 6)
- ; /* nothing */
- if (read_intr_count(apic_8254_intr) < 3) {
- /*
- * The MP table is broken.
- * The 8254 was not connected to the specified pin
- * on the IO APIC.
- * Workaround: Limited variant of mixed mode.
- */
- INTRDIS(1 << apic_8254_intr);
- inthand_remove(clkdesc);
- printf("APIC_IO: Broken MP table detected: "
- "8254 is not connected to "
- "IOAPIC #%d intpin %d\n",
- int_to_apicintpin[apic_8254_intr].ioapic,
- int_to_apicintpin[apic_8254_intr].int_pin);
- /*
- * Revoke current ISA IRQ 0 assignment and
- * configure a fallback interrupt routing from
- * the 8254 Timer via the 8259 PIC to the
- * an ExtInt interrupt line on IOAPIC #0 intpin 0.
- * We reuse the low level interrupt handler number.
- */
- if (apic_irq(0, 0) < 0) {
- revoke_apic_irq(apic_8254_intr);
- assign_apic_irq(0, 0, apic_8254_intr);
- }
- apic_8254_intr = apic_irq(0, 0);
- setup_8254_mixed_mode();
- inthand_add("clk", apic_8254_intr,
- (inthand2_t *)clkintr,
- NULL, &clk_imask, INTR_EXCL);
- INTREN(1 << apic_8254_intr);
- }
-
- }
- if (apic_int_type(0, 0) != 3 ||
- int_to_apicintpin[apic_8254_intr].ioapic != 0 ||
- int_to_apicintpin[apic_8254_intr].int_pin != 0)
- printf("APIC_IO: routing 8254 via IOAPIC #%d intpin %d\n",
- int_to_apicintpin[apic_8254_intr].ioapic,
- int_to_apicintpin[apic_8254_intr].int_pin);
- else
- printf("APIC_IO: "
- "routing 8254 via 8259 and IOAPIC #0 intpin 0\n");
-#endif
-
-}
-
-#ifdef APIC_IO
-static u_long
-read_intr_count(int vec)
-{
- u_long *up;
- up = intr_countp[vec];
- if (up)
- return *up;
- return 0UL;
-}
-
-static void
-setup_8254_mixed_mode()
-{
- /*
- * Allow 8254 timer to INTerrupt 8259:
- * re-initialize master 8259:
- * reset; prog 4 bytes, single ICU, edge triggered
- */
- outb(IO_ICU1, 0x13);
- outb(IO_ICU1 + 1, NRSVIDT); /* start vector (unused) */
- outb(IO_ICU1 + 1, 0x00); /* ignore slave */
- outb(IO_ICU1 + 1, 0x03); /* auto EOI, 8086 */
- outb(IO_ICU1 + 1, 0xfe); /* unmask INT0 */
-
- /* program IO APIC for type 3 INT on INT0 */
- if (ext_int_setup(0, 0) < 0)
- panic("8254 redirect via APIC pin0 impossible!");
-}
-#endif
-
-void
-setstatclockrate(int newhz)
-{
- if (newhz == RTC_PROFRATE)
- rtc_statusa = RTCSA_DIVIDER | RTCSA_PROF;
- else
- rtc_statusa = RTCSA_DIVIDER | RTCSA_NOPROF;
- writertc(RTC_STATUSA, rtc_statusa);
-}
-
-static int
-sysctl_machdep_i8254_freq SYSCTL_HANDLER_ARGS
-{
- int error;
- u_int freq;
-
- /*
- * Use `i8254' instead of `timer' in external names because `timer'
- * is is too generic. Should use it everywhere.
- */
- freq = timer_freq;
- error = sysctl_handle_int(oidp, &freq, sizeof(freq), req);
- if (error == 0 && req->newptr != NULL) {
- if (timer0_state != RELEASED)
- return (EBUSY); /* too much trouble to handle */
- set_timer_freq(freq, hz);
- i8254_timecounter.tc_frequency = freq;
- update_timecounter(&i8254_timecounter);
- }
- return (error);
-}
-
-SYSCTL_PROC(_machdep, OID_AUTO, i8254_freq, CTLTYPE_INT | CTLFLAG_RW,
- 0, sizeof(u_int), sysctl_machdep_i8254_freq, "I", "");
-
-static int
-sysctl_machdep_tsc_freq SYSCTL_HANDLER_ARGS
-{
- int error;
- u_int freq;
-
- if (tsc_timecounter.tc_frequency == 0)
- return (EOPNOTSUPP);
- freq = tsc_freq;
- error = sysctl_handle_int(oidp, &freq, sizeof(freq), req);
- if (error == 0 && req->newptr != NULL) {
- tsc_freq = freq;
- tsc_timecounter.tc_frequency = tsc_freq;
- update_timecounter(&tsc_timecounter);
- }
- return (error);
-}
-
-SYSCTL_PROC(_machdep, OID_AUTO, tsc_freq, CTLTYPE_INT | CTLFLAG_RW,
- 0, sizeof(u_int), sysctl_machdep_tsc_freq, "I", "");
-
-static unsigned
-i8254_get_timecount(struct timecounter *tc)
-{
- u_int count;
- u_long ef;
- u_int high, low;
-
- ef = read_eflags();
- disable_intr();
-
- /* Select timer0 and latch counter value. */
- outb(TIMER_MODE, TIMER_SEL0 | TIMER_LATCH);
-
- low = inb(TIMER_CNTR0);
- high = inb(TIMER_CNTR0);
- count = timer0_max_count - ((high << 8) | low);
- if (count < i8254_lastcount ||
- (!i8254_ticked && (clkintr_pending ||
- ((count < 20 || (!(ef & PSL_I) && count < timer0_max_count / 2u)) &&
-#ifdef APIC_IO
-#define lapic_irr1 ((volatile u_int *)&lapic)[0x210 / 4] /* XXX XXX */
- /* XXX this assumes that apic_8254_intr is < 24. */
- (lapic_irr1 & (1 << apic_8254_intr))))
-#else
- (inb(IO_ICU1) & 1)))
-#endif
- )) {
- i8254_ticked = 1;
- i8254_offset += timer0_max_count;
- }
- i8254_lastcount = count;
- count += i8254_offset;
- CLOCK_UNLOCK();
- write_eflags(ef);
- return (count);
-}
-
-static unsigned
-tsc_get_timecount(struct timecounter *tc)
-{
- return (rdtsc());
-}
diff --git a/sys/amd64/amd64/vm_machdep.c b/sys/amd64/amd64/vm_machdep.c
deleted file mode 100644
index cdcc27806aef..000000000000
--- a/sys/amd64/amd64/vm_machdep.c
+++ /dev/null
@@ -1,648 +0,0 @@
-/*-
- * Copyright (c) 1982, 1986 The Regents of the University of California.
- * Copyright (c) 1989, 1990 William Jolitz
- * Copyright (c) 1994 John Dyson
- * 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, and William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91
- * Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$
- * $FreeBSD$
- */
-
-#include "npx.h"
-#include "opt_user_ldt.h"
-#ifdef PC98
-#include "opt_pc98.h"
-#endif
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/malloc.h>
-#include <sys/proc.h>
-#include <sys/buf.h>
-#include <sys/vnode.h>
-#include <sys/vmmeter.h>
-#include <sys/kernel.h>
-#include <sys/sysctl.h>
-#include <sys/unistd.h>
-
-#include <machine/clock.h>
-#include <machine/cpu.h>
-#include <machine/md_var.h>
-#ifdef SMP
-#include <machine/smp.h>
-#endif
-#include <machine/pcb.h>
-#include <machine/pcb_ext.h>
-#include <machine/vm86.h>
-
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <sys/lock.h>
-#include <vm/vm_kern.h>
-#include <vm/vm_page.h>
-#include <vm/vm_map.h>
-#include <vm/vm_extern.h>
-
-#include <sys/user.h>
-
-#ifdef PC98
-#include <pc98/pc98/pc98.h>
-#else
-#include <i386/isa/isa.h>
-#endif
-
-static void cpu_reset_real __P((void));
-#ifdef SMP
-static void cpu_reset_proxy __P((void));
-static u_int cpu_reset_proxyid;
-static volatile u_int cpu_reset_proxy_active;
-#endif
-
-/*
- * quick version of vm_fault
- */
-int
-vm_fault_quick(v, prot)
- caddr_t v;
- int prot;
-{
- int r;
-
- if (prot & VM_PROT_WRITE)
- r = subyte(v, fubyte(v));
- else
- r = fubyte(v);
- return(r);
-}
-
-/*
- * Finish a fork operation, with process p2 nearly set up.
- * Copy and update the pcb, set up the stack so that the child
- * ready to run and return to user mode.
- */
-void
-cpu_fork(p1, p2, flags)
- register struct proc *p1, *p2;
- int flags;
-{
- struct pcb *pcb2;
-
- if ((flags & RFPROC) == 0) {
-#ifdef USER_LDT
- if ((flags & RFMEM) == 0) {
- /* unshare user LDT */
- struct pcb *pcb1 = &p1->p_addr->u_pcb;
- struct pcb_ldt *pcb_ldt = pcb1->pcb_ldt;
- if (pcb_ldt && pcb_ldt->ldt_refcnt > 1) {
- pcb_ldt = user_ldt_alloc(pcb1,pcb_ldt->ldt_len);
- user_ldt_free(pcb1);
- pcb1->pcb_ldt = pcb_ldt;
- set_user_ldt(pcb1);
- }
- }
-#endif
- return;
- }
-
-#if NNPX > 0
- /* Ensure that p1's pcb is up to date. */
- if (npxproc == p1)
- npxsave(&p1->p_addr->u_pcb.pcb_savefpu);
-#endif
-
- /* Copy p1's pcb. */
- p2->p_addr->u_pcb = p1->p_addr->u_pcb;
- pcb2 = &p2->p_addr->u_pcb;
-
- /*
- * Create a new fresh stack for the new process.
- * Copy the trap frame for the return to user mode as if from a
- * syscall. This copies the user mode register values.
- */
- p2->p_md.md_regs = (struct trapframe *)
- ((int)p2->p_addr + UPAGES * PAGE_SIZE - 16) - 1;
- *p2->p_md.md_regs = *p1->p_md.md_regs;
-
- /*
- * Set registers for trampoline to user mode. Leave space for the
- * return address on stack. These are the kernel mode register values.
- */
- pcb2->pcb_cr3 = vtophys(vmspace_pmap(p2->p_vmspace)->pm_pdir);
- pcb2->pcb_edi = p2->p_md.md_regs->tf_edi;
- pcb2->pcb_esi = (int)fork_return;
- pcb2->pcb_ebp = p2->p_md.md_regs->tf_ebp;
- pcb2->pcb_esp = (int)p2->p_md.md_regs - sizeof(void *);
- pcb2->pcb_ebx = (int)p2;
- pcb2->pcb_eip = (int)fork_trampoline;
- /*
- * pcb2->pcb_ldt: duplicated below, if necessary.
- * pcb2->pcb_savefpu: cloned above.
- * pcb2->pcb_flags: cloned above (always 0 here?).
- * pcb2->pcb_onfault: cloned above (always NULL here?).
- */
-
-#ifdef SMP
- pcb2->pcb_mpnest = 1;
-#endif
- /*
- * XXX don't copy the i/o pages. this should probably be fixed.
- */
- pcb2->pcb_ext = 0;
-
-#ifdef USER_LDT
- /* Copy the LDT, if necessary. */
- if (pcb2->pcb_ldt != 0) {
- if (flags & RFMEM) {
- pcb2->pcb_ldt->ldt_refcnt++;
- } else {
- pcb2->pcb_ldt = user_ldt_alloc(pcb2,
- pcb2->pcb_ldt->ldt_len);
- }
- }
-#endif
-
- /*
- * Now, cpu_switch() can schedule the new process.
- * pcb_esp is loaded pointing to the cpu_switch() stack frame
- * containing the return address when exiting cpu_switch.
- * This will normally be to proc_trampoline(), which will have
- * %ebx loaded with the new proc's pointer. proc_trampoline()
- * will set up a stack to call fork_return(p, frame); to complete
- * the return to user-mode.
- */
-}
-
-/*
- * Intercept the return address from a freshly forked process that has NOT
- * been scheduled yet.
- *
- * This is needed to make kernel threads stay in kernel mode.
- */
-void
-cpu_set_fork_handler(p, func, arg)
- struct proc *p;
- void (*func) __P((void *));
- void *arg;
-{
- /*
- * Note that the trap frame follows the args, so the function
- * is really called like this: func(arg, frame);
- */
- p->p_addr->u_pcb.pcb_esi = (int) func; /* function */
- p->p_addr->u_pcb.pcb_ebx = (int) arg; /* first arg */
-}
-
-void
-cpu_exit(p)
- register struct proc *p;
-{
- struct pcb *pcb = &p->p_addr->u_pcb;
-
-#if NNPX > 0
- npxexit(p);
-#endif /* NNPX */
- if (pcb->pcb_ext != 0) {
- /*
- * XXX do we need to move the TSS off the allocated pages
- * before freeing them? (not done here)
- */
- kmem_free(kernel_map, (vm_offset_t)pcb->pcb_ext,
- ctob(IOPAGES + 1));
- pcb->pcb_ext = 0;
- }
-#ifdef USER_LDT
- user_ldt_free(pcb);
-#endif
- if (pcb->pcb_flags & PCB_DBREGS) {
- /*
- * disable all hardware breakpoints
- */
- reset_dbregs();
- pcb->pcb_flags &= ~PCB_DBREGS;
- }
- cnt.v_swtch++;
- cpu_switch(p);
- panic("cpu_exit");
-}
-
-void
-cpu_wait(p)
- struct proc *p;
-{
- /* drop per-process resources */
- pmap_dispose_proc(p);
-
- /* and clean-out the vmspace */
- vmspace_free(p->p_vmspace);
-}
-
-/*
- * Dump the machine specific header information at the start of a core dump.
- */
-int
-cpu_coredump(p, vp, cred)
- struct proc *p;
- struct vnode *vp;
- struct ucred *cred;
-{
- int error;
- caddr_t tempuser;
-
- tempuser = malloc(ctob(UPAGES), M_TEMP, M_WAITOK);
- if (!tempuser)
- return EINVAL;
-
- bzero(tempuser, ctob(UPAGES));
- bcopy(p->p_addr, tempuser, sizeof(struct user));
- bcopy(p->p_md.md_regs,
- tempuser + ((caddr_t) p->p_md.md_regs - (caddr_t) p->p_addr),
- sizeof(struct trapframe));
-
- error = vn_rdwr(UIO_WRITE, vp, (caddr_t) tempuser,
- ctob(UPAGES),
- (off_t)0, UIO_SYSSPACE, IO_NODELOCKED|IO_UNIT,
- cred, (int *)NULL, p);
-
- free(tempuser, M_TEMP);
-
- return error;
-}
-
-#ifdef notyet
-static void
-setredzone(pte, vaddr)
- u_short *pte;
- caddr_t vaddr;
-{
-/* eventually do this by setting up an expand-down stack segment
- for ss0: selector, allowing stack access down to top of u.
- this means though that protection violations need to be handled
- thru a double fault exception that must do an integral task
- switch to a known good context, within which a dump can be
- taken. a sensible scheme might be to save the initial context
- used by sched (that has physical memory mapped 1:1 at bottom)
- and take the dump while still in mapped mode */
-}
-#endif
-
-/*
- * Convert kernel VA to physical address
- */
-u_long
-kvtop(void *addr)
-{
- vm_offset_t va;
-
- va = pmap_kextract((vm_offset_t)addr);
- if (va == 0)
- panic("kvtop: zero page frame");
- return((int)va);
-}
-
-/*
- * Map an IO request into kernel virtual address space.
- *
- * All requests are (re)mapped into kernel VA space.
- * Notice that we use b_bufsize for the size of the buffer
- * to be mapped. b_bcount might be modified by the driver.
- */
-void
-vmapbuf(bp)
- register struct buf *bp;
-{
- register caddr_t addr, v, kva;
- vm_offset_t pa;
-
- if ((bp->b_flags & B_PHYS) == 0)
- panic("vmapbuf");
-
- for (v = bp->b_saveaddr, addr = (caddr_t)trunc_page((vm_offset_t)bp->b_data);
- addr < bp->b_data + bp->b_bufsize;
- addr += PAGE_SIZE, v += PAGE_SIZE) {
- /*
- * Do the vm_fault if needed; do the copy-on-write thing
- * when reading stuff off device into memory.
- */
- vm_fault_quick(addr,
- (bp->b_flags&B_READ)?(VM_PROT_READ|VM_PROT_WRITE):VM_PROT_READ);
- pa = trunc_page(pmap_kextract((vm_offset_t) addr));
- if (pa == 0)
- panic("vmapbuf: page not present");
- vm_page_hold(PHYS_TO_VM_PAGE(pa));
- pmap_kenter((vm_offset_t) v, pa);
- }
-
- kva = bp->b_saveaddr;
- bp->b_saveaddr = bp->b_data;
- bp->b_data = kva + (((vm_offset_t) bp->b_data) & PAGE_MASK);
-}
-
-/*
- * Free the io map PTEs associated with this IO operation.
- * We also invalidate the TLB entries and restore the original b_addr.
- */
-void
-vunmapbuf(bp)
- register struct buf *bp;
-{
- register caddr_t addr;
- vm_offset_t pa;
-
- if ((bp->b_flags & B_PHYS) == 0)
- panic("vunmapbuf");
-
- for (addr = (caddr_t)trunc_page((vm_offset_t)bp->b_data);
- addr < bp->b_data + bp->b_bufsize;
- addr += PAGE_SIZE) {
- pa = trunc_page(pmap_kextract((vm_offset_t) addr));
- pmap_kremove((vm_offset_t) addr);
- vm_page_unhold(PHYS_TO_VM_PAGE(pa));
- }
-
- bp->b_data = bp->b_saveaddr;
-}
-
-/*
- * Force reset the processor by invalidating the entire address space!
- */
-
-#ifdef SMP
-static void
-cpu_reset_proxy()
-{
- u_int saved_mp_lock;
-
- cpu_reset_proxy_active = 1;
- while (cpu_reset_proxy_active == 1)
- ; /* Wait for other cpu to disable interupts */
- saved_mp_lock = mp_lock;
- mp_lock = 1;
- printf("cpu_reset_proxy: Grabbed mp lock for BSP\n");
- cpu_reset_proxy_active = 3;
- while (cpu_reset_proxy_active == 3)
- ; /* Wait for other cpu to enable interrupts */
- stop_cpus((1<<cpu_reset_proxyid));
- printf("cpu_reset_proxy: Stopped CPU %d\n", cpu_reset_proxyid);
- DELAY(1000000);
- cpu_reset_real();
-}
-#endif
-
-void
-cpu_reset()
-{
-#ifdef SMP
- if (smp_active == 0) {
- cpu_reset_real();
- /* NOTREACHED */
- } else {
-
- u_int map;
- int cnt;
- printf("cpu_reset called on cpu#%d\n",cpuid);
-
- map = other_cpus & ~ stopped_cpus;
-
- if (map != 0) {
- printf("cpu_reset: Stopping other CPUs\n");
- stop_cpus(map); /* Stop all other CPUs */
- }
-
- if (cpuid == 0) {
- DELAY(1000000);
- cpu_reset_real();
- /* NOTREACHED */
- } else {
- /* We are not BSP (CPU #0) */
-
- cpu_reset_proxyid = cpuid;
- cpustop_restartfunc = cpu_reset_proxy;
- printf("cpu_reset: Restarting BSP\n");
- started_cpus = (1<<0); /* Restart CPU #0 */
-
- cnt = 0;
- while (cpu_reset_proxy_active == 0 && cnt < 10000000)
- cnt++; /* Wait for BSP to announce restart */
- if (cpu_reset_proxy_active == 0)
- printf("cpu_reset: Failed to restart BSP\n");
- __asm __volatile("cli" : : : "memory");
- cpu_reset_proxy_active = 2;
- cnt = 0;
- while (cpu_reset_proxy_active == 2 && cnt < 10000000)
- cnt++; /* Do nothing */
- if (cpu_reset_proxy_active == 2) {
- printf("cpu_reset: BSP did not grab mp lock\n");
- cpu_reset_real(); /* XXX: Bogus ? */
- }
- cpu_reset_proxy_active = 4;
- __asm __volatile("sti" : : : "memory");
- while (1);
- /* NOTREACHED */
- }
- }
-#else
- cpu_reset_real();
-#endif
-}
-
-static void
-cpu_reset_real()
-{
-
-#ifdef PC98
- /*
- * Attempt to do a CPU reset via CPU reset port.
- */
- disable_intr();
- if ((inb(0x35) & 0xa0) != 0xa0) {
- outb(0x37, 0x0f); /* SHUT0 = 0. */
- outb(0x37, 0x0b); /* SHUT1 = 0. */
- }
- outb(0xf0, 0x00); /* Reset. */
-#else
- /*
- * Attempt to do a CPU reset via the keyboard controller,
- * do not turn of the GateA20, as any machine that fails
- * to do the reset here would then end up in no man's land.
- */
-
-#if !defined(BROKEN_KEYBOARD_RESET)
- outb(IO_KBD + 4, 0xFE);
- DELAY(500000); /* wait 0.5 sec to see if that did it */
- printf("Keyboard reset did not work, attempting CPU shutdown\n");
- DELAY(1000000); /* wait 1 sec for printf to complete */
-#endif
-#endif /* PC98 */
- /* force a shutdown by unmapping entire address space ! */
- bzero((caddr_t) PTD, PAGE_SIZE);
-
- /* "good night, sweet prince .... <THUNK!>" */
- invltlb();
- /* NOTREACHED */
- while(1);
-}
-
-int
-grow_stack(p, sp)
- struct proc *p;
- u_int sp;
-{
- int rv;
-
- rv = vm_map_growstack (p, sp);
- if (rv != KERN_SUCCESS)
- return (0);
-
- return (1);
-}
-
-SYSCTL_DECL(_vm_stats_misc);
-
-static int cnt_prezero;
-
-SYSCTL_INT(_vm_stats_misc, OID_AUTO,
- cnt_prezero, CTLFLAG_RD, &cnt_prezero, 0, "");
-
-/*
- * Implement the pre-zeroed page mechanism.
- * This routine is called from the idle loop.
- */
-
-#define ZIDLE_LO(v) ((v) * 2 / 3)
-#define ZIDLE_HI(v) ((v) * 4 / 5)
-
-int
-vm_page_zero_idle()
-{
- static int free_rover;
- static int zero_state;
- vm_page_t m;
- int s;
-
- /*
- * Attempt to maintain approximately 1/2 of our free pages in a
- * PG_ZERO'd state. Add some hysteresis to (attempt to) avoid
- * generally zeroing a page when the system is near steady-state.
- * Otherwise we might get 'flutter' during disk I/O / IPC or
- * fast sleeps. We also do not want to be continuously zeroing
- * pages because doing so may flush our L1 and L2 caches too much.
- */
-
- if (zero_state && vm_page_zero_count >= ZIDLE_LO(cnt.v_free_count))
- return(0);
- if (vm_page_zero_count >= ZIDLE_HI(cnt.v_free_count))
- return(0);
-
-#ifdef SMP
- if (try_mplock()) {
-#endif
- s = splvm();
- __asm __volatile("sti" : : : "memory");
- zero_state = 0;
- m = vm_page_list_find(PQ_FREE, free_rover, FALSE);
- if (m != NULL && (m->flags & PG_ZERO) == 0) {
- vm_page_queues[m->queue].lcnt--;
- TAILQ_REMOVE(&vm_page_queues[m->queue].pl, m, pageq);
- m->queue = PQ_NONE;
- splx(s);
-#if 0
- rel_mplock();
-#endif
- pmap_zero_page(VM_PAGE_TO_PHYS(m));
-#if 0
- get_mplock();
-#endif
- (void)splvm();
- vm_page_flag_set(m, PG_ZERO);
- m->queue = PQ_FREE + m->pc;
- vm_page_queues[m->queue].lcnt++;
- TAILQ_INSERT_TAIL(&vm_page_queues[m->queue].pl, m,
- pageq);
- ++vm_page_zero_count;
- ++cnt_prezero;
- if (vm_page_zero_count >= ZIDLE_HI(cnt.v_free_count))
- zero_state = 1;
- }
- free_rover = (free_rover + PQ_PRIME2) & PQ_L2_MASK;
- splx(s);
- __asm __volatile("cli" : : : "memory");
-#ifdef SMP
- rel_mplock();
-#endif
- return (1);
-#ifdef SMP
- }
-#endif
- return (0);
-}
-
-/*
- * Software interrupt handler for queued VM system processing.
- */
-void
-swi_vm()
-{
- if (busdma_swi_pending != 0)
- busdma_swi();
-}
-
-/*
- * Tell whether this address is in some physical memory region.
- * Currently used by the kernel coredump code in order to avoid
- * dumping the ``ISA memory hole'' which could cause indefinite hangs,
- * or other unpredictable behaviour.
- */
-
-#include "isa.h"
-
-int
-is_physical_memory(addr)
- vm_offset_t addr;
-{
-
-#if NISA > 0
- /* The ISA ``memory hole''. */
- if (addr >= 0xa0000 && addr < 0x100000)
- return 0;
-#endif
-
- /*
- * stuff other tests for known memory-mapped devices (PCI?)
- * here
- */
-
- return 1;
-}
diff --git a/sys/amd64/conf/GENERIC b/sys/amd64/conf/GENERIC
deleted file mode 100644
index 38bf15a14f41..000000000000
--- a/sys/amd64/conf/GENERIC
+++ /dev/null
@@ -1,229 +0,0 @@
-#
-# GENERIC -- Generic kernel configuration file for FreeBSD/i386
-#
-# For more information on this file, please read the handbook section on
-# Kernel Configuration Files:
-#
-# http://www.freebsd.org/handbook/kernelconfig-config.html
-#
-# The handbook is also available locally in /usr/share/doc/handbook
-# if you've installed the doc distribution, otherwise always see the
-# FreeBSD World Wide Web server (http://www.FreeBSD.ORG/) for the
-# latest information.
-#
-# An exhaustive list of options and more detailed explanations of the
-# device lines is also present in the ./LINT configuration file. If you are
-# in doubt as to the purpose or necessity of a line, check first in LINT.
-#
-# $FreeBSD$
-
-machine i386
-cpu I386_CPU
-cpu I486_CPU
-cpu I586_CPU
-cpu I686_CPU
-ident GENERIC
-maxusers 32
-
-#makeoptions DEBUG=-g #Build kernel with gdb(1) debug symbols
-
-options MATH_EMULATE #Support for x87 emulation
-options INET #InterNETworking
-options INET6 #IPv6 communications protocols
-options FFS #Berkeley Fast Filesystem
-options FFS_ROOT #FFS usable as root device [keep this!]
-options MFS #Memory Filesystem
-options MD_ROOT #MD is a potential root device
-options NFS #Network Filesystem
-options NFS_ROOT #NFS usable as root device, NFS required
-options MSDOSFS #MSDOS Filesystem
-options CD9660 #ISO 9660 Filesystem
-options CD9660_ROOT #CD-ROM usable as root, CD9660 required
-options PROCFS #Process filesystem
-options COMPAT_43 #Compatible with BSD 4.3 [KEEP THIS!]
-options SCSI_DELAY=15000 #Delay (in ms) before probing SCSI
-options UCONSOLE #Allow users to grab the console
-options USERCONFIG #boot -c editor
-options VISUAL_USERCONFIG #visual boot -c editor
-options KTRACE #ktrace(1) support
-options SYSVSHM #SYSV-style shared memory
-options SYSVMSG #SYSV-style message queues
-options SYSVSEM #SYSV-style semaphores
-options P1003_1B #Posix P1003_1B real-time extentions
-options _KPOSIX_PRIORITY_SCHEDULING
-options ICMP_BANDLIM #Rate limit bad replies
-
-# To make an SMP kernel, the next two are needed
-#options SMP # Symmetric MultiProcessor Kernel
-#options APIC_IO # Symmetric (APIC) I/O
-# Optionally these may need tweaked, (defaults shown):
-#options NCPU=2 # number of CPUs
-#options NBUS=4 # number of busses
-#options NAPIC=1 # number of IO APICs
-#options NINTR=24 # number of INTs
-
-device isa
-device eisa
-device pci
-
-# Floppy drives
-device fdc0 at isa? port IO_FD1 irq 6 drq 2
-device fd0 at fdc0 drive 0
-device fd1 at fdc0 drive 1
-
-# ATA and ATAPI devices
-device ata0 at isa? port IO_WD1 irq 14
-device ata1 at isa? port IO_WD2 irq 15
-device ata
-device atadisk # ATA disk drives
-device atapicd # ATAPI CDROM drives
-device atapifd # ATAPI floppy drives
-device atapist # ATAPI tape drives
-options ATA_STATIC_ID #Static device numbering
-#options ATA_ENABLE_ATAPI_DMA #Enable DMA on ATAPI devices
-
-# SCSI Controllers
-device ahb # EISA AHA1742 family
-device ahc # AHA2940 and onboard AIC7xxx devices
-device amd # AMD 53C974 (Teckram DC-390(T))
-device dpt # DPT Smartcache - See LINT for options!
-device isp # Qlogic family
-device ncr # NCR/Symbios Logic
-device sym # NCR/Symbios Logic (newer chipsets)
-
-device adv0 at isa?
-device adw
-device bt0 at isa?
-device aha0 at isa?
-device aic0 at isa?
-
-# SCSI peripherals
-device scbus # SCSI bus (required)
-device da # Direct Access (disks)
-device sa # Sequential Access (tape etc)
-device cd # CD
-device pass # Passthrough device (direct SCSI access)
-
-# RAID controllers
-device ida # Compaq Smart RAID
-device amr # AMI MegaRAID
-device mlx # Mylex DAC960 family
-
-# atkbdc0 controls both the keyboard and the PS/2 mouse
-device atkbdc0 at isa? port IO_KBD
-device atkbd0 at atkbdc? irq 1
-device psm0 at atkbdc? irq 12
-
-device vga0 at isa?
-
-# splash screen/screen saver
-pseudo-device splash
-
-# syscons is the default console driver, resembling an SCO console
-device sc0 at isa?
-
-# Enable this and PCVT_FREEBSD for pcvt vt220 compatible console driver
-#device vt0 at isa?
-#options XSERVER # support for X server on a vt console
-#options FAT_CURSOR # start with block cursor
-# If you have a ThinkPAD, uncomment this along with the rest of the PCVT lines
-#options PCVT_SCANSET=2 # IBM keyboards are non-std
-
-# Floating point support - do not disable.
-device npx0 at nexus? port IO_NPX irq 13
-
-# Power management support (see LINT for more options)
-device apm0 at nexus? disable flags 0x20 # Advanced Power Management
-
-# PCCARD (PCMCIA) support
-device card
-device pcic0 at isa? irq 10 port 0x3e0 iomem 0xd0000
-device pcic1 at isa? irq 11 port 0x3e2 iomem 0xd4000 disable
-
-# Serial (COM) ports
-device sio0 at isa? port IO_COM1 flags 0x10 irq 4
-device sio1 at isa? port IO_COM2 irq 3
-device sio2 at isa? disable port IO_COM3 irq 5
-device sio3 at isa? disable port IO_COM4 irq 9
-
-# Parallel port
-device ppc0 at isa? irq 7
-device ppbus # Parallel port bus (required)
-device lpt # Printer
-device plip # TCP/IP over parallel
-device ppi # Parallel port interface device
-#device vpo # Requires scbus and da
-
-
-# PCI Ethernet NICs.
-device de # DEC/Intel DC21x4x (``Tulip'')
-device fxp # Intel EtherExpress PRO/100B (82557, 82558)
-device tx # SMC 9432TX (83c170 ``EPIC'')
-device vx # 3Com 3c590, 3c595 (``Vortex'')
-device wx # Intel Gigabit Ethernet Card (``Wiseman'')
-
-# PCI Ethernet NICs that use the common MII bus controller code.
-device miibus # MII bus support
-device dc # DEC/Intel 21143 and various workalikes
-device rl # RealTek 8129/8139
-device sf # Adaptec AIC-6915 (``Starfire'')
-device sis # Silicon Integrated Systems SiS 900/SiS 7016
-device ste # Sundance ST201 (D-Link DFE-550TX)
-device tl # Texas Instruments ThunderLAN
-device vr # VIA Rhine, Rhine II
-device wb # Winbond W89C840F
-device xl # 3Com 3c90x (``Boomerang'', ``Cyclone'')
-
-# ISA Ethernet NICs.
-device ed0 at isa? port 0x280 irq 10 iomem 0xd8000
-device ex
-device ep
-# WaveLAN/IEEE 802.11 wireless NICs. Note: the WaveLAN/IEEE really
-# exists only as a PCMCIA device, so there is no ISA attatement needed
-# and resources will always be dynamically assigned by the pccard code.
-device wi
-# Aironet 4500/4800 802.11 wireless NICs. Note: the declaration below will
-# work for PCMCIA and PCI cards, as well as ISA cards set to ISA PnP
-# mode (the factory default). If you set the switches on your ISA
-# card for a manually chosen I/O address and IRQ, you must specify
-# those paremeters here.
-device an
-# The probe order of these is presently determined by i386/isa/isa_compat.c.
-device ie0 at isa? port 0x300 irq 10 iomem 0xd0000
-device fe0 at isa? port 0x300
-device le0 at isa? port 0x300 irq 5 iomem 0xd0000
-device lnc0 at isa? port 0x280 irq 10 drq 0
-device cs0 at isa? port 0x300
-device sn0 at isa? port 0x300 irq 10
-# requires PCCARD (PCMCIA) support to be activated
-#device xe0 at isa?
-
-# Pseudo devices - the number indicates how many units to allocated.
-pseudo-device loop # Network loopback
-pseudo-device ether # Ethernet support
-pseudo-device sl 1 # Kernel SLIP
-pseudo-device ppp 1 # Kernel PPP
-pseudo-device tun # Packet tunnel.
-pseudo-device pty # Pseudo-ttys (telnet etc)
-pseudo-device md # Memory "disks"
-pseudo-device gif 4 # IPv6 and IPv4 tunneling
-pseudo-device faith 1 # IPv6-to-IPv4 relaying (translation)
-
-# The `bpf' pseudo-device enables the Berkeley Packet Filter.
-# Be aware of the administrative consequences of enabling this!
-pseudo-device bpf #Berkeley packet filter
-
-# USB support
-#device uhci # UHCI PCI->USB interface
-#device ohci # OHCI PCI->USB interface
-#device usb # USB Bus (required)
-#device ugen # Generic
-#device uhid # "Human Interface Devices"
-#device ukbd # Keyboard
-#device ulpt # Printer
-#device umass # Disks/Mass storage - Requires scbus and da
-#device ums # Mouse
-# USB Ethernet, requires mii
-#device aue # ADMtek USB ethernet
-#device cue # CATC USB ethernet
-#device kue # Kawasaki LSI USB ethernet
diff --git a/sys/amd64/include/apicreg.h b/sys/amd64/include/apicreg.h
deleted file mode 100644
index be9de4f8fe1f..000000000000
--- a/sys/amd64/include/apicreg.h
+++ /dev/null
@@ -1,466 +0,0 @@
-/*
- * Copyright (c) 1996, by Peter Wemm and Steve Passe
- * 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 developer 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _MACHINE_APIC_H_
-#define _MACHINE_APIC_H_
-
-/*
- * Local && I/O APIC definitions.
- */
-
-/*
- * Pentium P54C+ Build-in APIC
- * (Advanced programmable Interrupt Controller)
- *
- * Base Address of Build-in APIC in memory location
- * is 0xfee00000.
- *
- * Map of APIC REgisters:
- *
- * Offset (hex) Description Read/Write state
- * 000 Reserved
- * 010 Reserved
- * 020 ID Local APIC ID R/W
- * 030 VER Local APIC Version R
- * 040 Reserved
- * 050 Reserved
- * 060 Reserved
- * 070 Reserved
- * 080 Task Priority Register R/W
- * 090 Arbitration Priority Register R
- * 0A0 Processor Priority Register R
- * 0B0 EOI Register W
- * 0C0 RRR Remote read R
- * 0D0 Logical Destination R/W
- * 0E0 Destination Format Register 0..27 R; 28..31 R/W
- * 0F0 SVR Spurious Interrupt Vector Reg. 0..3 R; 4..9 R/W
- * 100 ISR 000-031 R
- * 110 ISR 032-063 R
- * 120 ISR 064-095 R
- * 130 ISR 095-128 R
- * 140 ISR 128-159 R
- * 150 ISR 160-191 R
- * 160 ISR 192-223 R
- * 170 ISR 224-255 R
- * 180 TMR 000-031 R
- * 190 TMR 032-063 R
- * 1A0 TMR 064-095 R
- * 1B0 TMR 095-128 R
- * 1C0 TMR 128-159 R
- * 1D0 TMR 160-191 R
- * 1E0 TMR 192-223 R
- * 1F0 TMR 224-255 R
- * 200 IRR 000-031 R
- * 210 IRR 032-063 R
- * 220 IRR 064-095 R
- * 230 IRR 095-128 R
- * 240 IRR 128-159 R
- * 250 IRR 160-191 R
- * 260 IRR 192-223 R
- * 270 IRR 224-255 R
- * 280 Error Status Register R
- * 290 Reserved
- * 2A0 Reserved
- * 2B0 Reserved
- * 2C0 Reserved
- * 2D0 Reserved
- * 2E0 Reserved
- * 2F0 Reserved
- * 300 ICR_LOW Interrupt Command Reg. (0-31) R/W
- * 310 ICR_HI Interrupt Command Reg. (32-63) R/W
- * 320 Local Vector Table (Timer) R/W
- * 330 Reserved
- * 340 Reserved
- * 350 LVT1 Local Vector Table (LINT0) R/W
- * 360 LVT2 Local Vector Table (LINT1) R/W
- * 370 LVT3 Local Vector Table (ERROR) R/W
- * 380 Initial Count Reg. for Timer R/W
- * 390 Current Count of Timer R
- * 3A0 Reserved
- * 3B0 Reserved
- * 3C0 Reserved
- * 3D0 Reserved
- * 3E0 Timer Divide Configuration Reg. R/W
- * 3F0 Reserved
- */
-
-
-/******************************************************************************
- * global defines, etc.
- */
-
-
-/******************************************************************************
- * LOCAL APIC structure
- */
-
-#ifndef LOCORE
-#include <sys/types.h>
-
-#define PAD3 int : 32; int : 32; int : 32
-#define PAD4 int : 32; int : 32; int : 32; int : 32
-
-struct LAPIC {
- /* reserved */ PAD4;
- /* reserved */ PAD4;
- u_int32_t id; PAD3;
- u_int32_t version; PAD3;
- /* reserved */ PAD4;
- /* reserved */ PAD4;
- /* reserved */ PAD4;
- /* reserved */ PAD4;
- u_int32_t tpr; PAD3;
- u_int32_t apr; PAD3;
- u_int32_t ppr; PAD3;
- u_int32_t eoi; PAD3;
- /* reserved */ PAD4;
- u_int32_t ldr; PAD3;
- u_int32_t dfr; PAD3;
- u_int32_t svr; PAD3;
- u_int32_t isr0; PAD3;
- u_int32_t isr1; PAD3;
- u_int32_t isr2; PAD3;
- u_int32_t isr3; PAD3;
- u_int32_t isr4; PAD3;
- u_int32_t isr5; PAD3;
- u_int32_t isr6; PAD3;
- u_int32_t isr7; PAD3;
- u_int32_t tmr0; PAD3;
- u_int32_t tmr1; PAD3;
- u_int32_t tmr2; PAD3;
- u_int32_t tmr3; PAD3;
- u_int32_t tmr4; PAD3;
- u_int32_t tmr5; PAD3;
- u_int32_t tmr6; PAD3;
- u_int32_t tmr7; PAD3;
- u_int32_t irr0; PAD3;
- u_int32_t irr1; PAD3;
- u_int32_t irr2; PAD3;
- u_int32_t irr3; PAD3;
- u_int32_t irr4; PAD3;
- u_int32_t irr5; PAD3;
- u_int32_t irr6; PAD3;
- u_int32_t irr7; PAD3;
- u_int32_t esr; PAD3;
- /* reserved */ PAD4;
- /* reserved */ PAD4;
- /* reserved */ PAD4;
- /* reserved */ PAD4;
- /* reserved */ PAD4;
- /* reserved */ PAD4;
- /* reserved */ PAD4;
- u_int32_t icr_lo; PAD3;
- u_int32_t icr_hi; PAD3;
- u_int32_t lvt_timer; PAD3;
- /* reserved */ PAD4;
- u_int32_t lvt_pcint; PAD3;
- u_int32_t lvt_lint0; PAD3;
- u_int32_t lvt_lint1; PAD3;
- u_int32_t lvt_error; PAD3;
- u_int32_t icr_timer; PAD3;
- u_int32_t ccr_timer; PAD3;
- /* reserved */ PAD4;
- /* reserved */ PAD4;
- /* reserved */ PAD4;
- /* reserved */ PAD4;
- u_int32_t dcr_timer; PAD3;
- /* reserved */ PAD4;
-};
-
-typedef struct LAPIC lapic_t;
-
-/******************************************************************************
- * I/O APIC structure
- */
-
-struct IOAPIC {
- u_int32_t ioregsel; PAD3;
- u_int32_t iowin; PAD3;
-};
-
-typedef struct IOAPIC ioapic_t;
-
-#undef PAD4
-#undef PAD3
-
-#endif /* !LOCORE */
-
-
-/******************************************************************************
- * various code 'logical' values
- */
-
-/* default level for TPR */
-#define LOPRIO_LEVEL 0x00000010 /* TPR of CPU accepting INTs */
-
-#ifdef GRAB_LOPRIO
-#define ALLHWI_LEVEL 0x00000000 /* TPR of CPU grabbing INTs */
-#endif /** GRAB_LOPRIO */
-
-/* XXX these 2 don't really belong here... */
-#define COUNT_FIELD 0x00ffffff /* count portion of the lock */
-#define CPU_FIELD 0xff000000 /* cpu portion of the lock */
-#define FREE_LOCK 0xffffffff /* value of lock when free */
-
-/*
- * XXX This code assummes that the reserved field of the
- * local APIC TPR can be written with all 0s.
- * This saves quite a few memory accesses.
- * If the silicon ever changes then things will break!
- * It affects mplock.s, swtch.s, and possibly other files.
- */
-#define CHEAP_TPR
-
-
-/******************************************************************************
- * LOCAL APIC defines
- */
-
-/* default physical locations of LOCAL (CPU) APICs */
-#define DEFAULT_APIC_BASE 0xfee00000
-
-/* fields in VER */
-#define APIC_VER_VERSION 0x000000ff
-#define APIC_VER_MAXLVT 0x00ff0000
-#define MAXLVTSHIFT 16
-
-/* fields in SVR */
-#define APIC_SVR_VECTOR 0x000000ff
-#define APIC_SVR_VEC_PROG 0x000000f0
-#define APIC_SVR_VEC_FIX 0x0000000f
-#define APIC_SVR_ENABLE 0x00000100
-# define APIC_SVR_SWDIS 0x00000000
-# define APIC_SVR_SWEN 0x00000100
-#define APIC_SVR_FOCUS 0x00000200
-# define APIC_SVR_FEN 0x00000000
-# define APIC_SVR_FDIS 0x00000200
-
-/* fields in TPR */
-#define APIC_TPR_PRIO 0x000000ff
-# define APIC_TPR_INT 0x000000f0
-# define APIC_TPR_SUB 0x0000000f
-
-
-/* fields in ICR_LOW */
-#define APIC_VECTOR_MASK 0x000000ff
-
-#define APIC_DELMODE_MASK 0x00000700
-# define APIC_DELMODE_FIXED 0x00000000
-# define APIC_DELMODE_LOWPRIO 0x00000100
-# define APIC_DELMODE_SMI 0x00000200
-# define APIC_DELMODE_RR 0x00000300
-# define APIC_DELMODE_NMI 0x00000400
-# define APIC_DELMODE_INIT 0x00000500
-# define APIC_DELMODE_STARTUP 0x00000600
-# define APIC_DELMODE_RESV 0x00000700
-
-#define APIC_DESTMODE_MASK 0x00000800
-# define APIC_DESTMODE_PHY 0x00000000
-# define APIC_DESTMODE_LOG 0x00000800
-
-#define APIC_DELSTAT_MASK 0x00001000
-# define APIC_DELSTAT_IDLE 0x00000000
-# define APIC_DELSTAT_PEND 0x00001000
-
-#define APIC_RESV1_MASK 0x00002000
-
-#define APIC_LEVEL_MASK 0x00004000
-# define APIC_LEVEL_DEASSERT 0x00000000
-# define APIC_LEVEL_ASSERT 0x00004000
-
-#define APIC_TRIGMOD_MASK 0x00008000
-# define APIC_TRIGMOD_EDGE 0x00000000
-# define APIC_TRIGMOD_LEVEL 0x00008000
-
-#define APIC_RRSTAT_MASK 0x00030000
-# define APIC_RRSTAT_INVALID 0x00000000
-# define APIC_RRSTAT_INPROG 0x00010000
-# define APIC_RRSTAT_VALID 0x00020000
-# define APIC_RRSTAT_RESV 0x00030000
-
-#define APIC_DEST_MASK 0x000c0000
-# define APIC_DEST_DESTFLD 0x00000000
-# define APIC_DEST_SELF 0x00040000
-# define APIC_DEST_ALLISELF 0x00080000
-# define APIC_DEST_ALLESELF 0x000c0000
-
-#define APIC_RESV2_MASK 0xfff00000
-
-
-/* fields in ICR_HIGH */
-#define APIC_ID_MASK 0x0f000000
-
-
-/* fields in LVT1/2 */
-#define APIC_LVT_VECTOR 0x000000ff
-#define APIC_LVT_DM 0x00000700
-# define APIC_LVT_DM_FIXED 0x00000000
-# define APIC_LVT_DM_NMI 0x00000400
-# define APIC_LVT_DM_EXTINT 0x00000700
-#define APIC_LVT_DS 0x00001000
-#define APIC_LVT_IIPP 0x00002000
-#define APIC_LVT_IIPP_INTALO 0x00002000
-#define APIC_LVT_IIPP_INTAHI 0x00000000
-#define APIC_LVT_RIRR 0x00004000
-#define APIC_LVT_TM 0x00008000
-#define APIC_LVT_M 0x00010000
-
-
-/* fields in LVT Timer */
-#define APIC_LVTT_VECTOR 0x000000ff
-#define APIC_LVTT_DS 0x00001000
-#define APIC_LVTT_M 0x00010000
-#define APIC_LVTT_TM 0x00020000
-
-
-/* fields in TDCR */
-#define APIC_TDCR_2 0x00
-#define APIC_TDCR_4 0x01
-#define APIC_TDCR_8 0x02
-#define APIC_TDCR_16 0x03
-#define APIC_TDCR_32 0x08
-#define APIC_TDCR_64 0x09
-#define APIC_TDCR_128 0x0a
-#define APIC_TDCR_1 0x0b
-
-
-/*
- * fields in IRR
- * ISA INTerrupts are in bits 16-31 of the 1st IRR register.
- * these masks DON'T EQUAL the isa IRQs of the same name.
- */
-#define APIC_IRQ0 0x00000001
-#define APIC_IRQ1 0x00000002
-#define APIC_IRQ2 0x00000004
-#define APIC_IRQ3 0x00000008
-#define APIC_IRQ4 0x00000010
-#define APIC_IRQ5 0x00000020
-#define APIC_IRQ6 0x00000040
-#define APIC_IRQ7 0x00000080
-#define APIC_IRQ8 0x00000100
-#define APIC_IRQ9 0x00000200
-#define APIC_IRQ10 0x00000400
-#define APIC_IRQ11 0x00000800
-#define APIC_IRQ12 0x00001000
-#define APIC_IRQ13 0x00002000
-#define APIC_IRQ14 0x00004000
-#define APIC_IRQ15 0x00008000
-#define APIC_IRQ16 0x00010000
-#define APIC_IRQ17 0x00020000
-#define APIC_IRQ18 0x00040000
-#define APIC_IRQ19 0x00080000
-#define APIC_IRQ20 0x00100000
-#define APIC_IRQ21 0x00200000
-#define APIC_IRQ22 0x00400000
-#define APIC_IRQ23 0x00800000
-
-
-/******************************************************************************
- * I/O APIC defines
- */
-
-/* default physical locations of an IO APIC */
-#define DEFAULT_IO_APIC_BASE 0xfec00000
-
-/* window register offset */
-#define IOAPIC_WINDOW 0x10
-
-/* indexes into IO APIC */
-#define IOAPIC_ID 0x00
-#define IOAPIC_VER 0x01
-#define IOAPIC_ARB 0x02
-#define IOAPIC_REDTBL 0x10
-#define IOAPIC_REDTBL0 IOAPIC_REDTBL
-#define IOAPIC_REDTBL1 (IOAPIC_REDTBL+0x02)
-#define IOAPIC_REDTBL2 (IOAPIC_REDTBL+0x04)
-#define IOAPIC_REDTBL3 (IOAPIC_REDTBL+0x06)
-#define IOAPIC_REDTBL4 (IOAPIC_REDTBL+0x08)
-#define IOAPIC_REDTBL5 (IOAPIC_REDTBL+0x0a)
-#define IOAPIC_REDTBL6 (IOAPIC_REDTBL+0x0c)
-#define IOAPIC_REDTBL7 (IOAPIC_REDTBL+0x0e)
-#define IOAPIC_REDTBL8 (IOAPIC_REDTBL+0x10)
-#define IOAPIC_REDTBL9 (IOAPIC_REDTBL+0x12)
-#define IOAPIC_REDTBL10 (IOAPIC_REDTBL+0x14)
-#define IOAPIC_REDTBL11 (IOAPIC_REDTBL+0x16)
-#define IOAPIC_REDTBL12 (IOAPIC_REDTBL+0x18)
-#define IOAPIC_REDTBL13 (IOAPIC_REDTBL+0x1a)
-#define IOAPIC_REDTBL14 (IOAPIC_REDTBL+0x1c)
-#define IOAPIC_REDTBL15 (IOAPIC_REDTBL+0x1e)
-#define IOAPIC_REDTBL16 (IOAPIC_REDTBL+0x20)
-#define IOAPIC_REDTBL17 (IOAPIC_REDTBL+0x22)
-#define IOAPIC_REDTBL18 (IOAPIC_REDTBL+0x24)
-#define IOAPIC_REDTBL19 (IOAPIC_REDTBL+0x26)
-#define IOAPIC_REDTBL20 (IOAPIC_REDTBL+0x28)
-#define IOAPIC_REDTBL21 (IOAPIC_REDTBL+0x2a)
-#define IOAPIC_REDTBL22 (IOAPIC_REDTBL+0x2c)
-#define IOAPIC_REDTBL23 (IOAPIC_REDTBL+0x2e)
-
-/* fields in VER */
-#define IOART_VER_VERSION 0x000000ff
-#define IOART_VER_MAXREDIR 0x00ff0000
-#define MAXREDIRSHIFT 16
-
-/*
- * fields in the IO APIC's redirection table entries
- */
-#define IOART_DEST APIC_ID_MASK /* broadcast addr: all APICs */
-
-#define IOART_RESV 0x00fe0000 /* reserved */
-
-#define IOART_INTMASK 0x00010000 /* R/W: INTerrupt mask */
-# define IOART_INTMCLR 0x00000000 /* clear, allow INTs */
-# define IOART_INTMSET 0x00010000 /* set, inhibit INTs */
-
-#define IOART_TRGRMOD 0x00008000 /* R/W: trigger mode */
-# define IOART_TRGREDG 0x00000000 /* edge */
-# define IOART_TRGRLVL 0x00008000 /* level */
-
-#define IOART_REM_IRR 0x00004000 /* RO: remote IRR */
-
-#define IOART_INTPOL 0x00002000 /* R/W: INT input pin polarity */
-# define IOART_INTAHI 0x00000000 /* active high */
-# define IOART_INTALO 0x00002000 /* active low */
-
-#define IOART_DELIVS 0x00001000 /* RO: delivery status */
-
-#define IOART_DESTMOD 0x00000800 /* R/W: destination mode */
-# define IOART_DESTPHY 0x00000000 /* physical */
-# define IOART_DESTLOG 0x00000800 /* logical */
-
-#define IOART_DELMOD 0x00000700 /* R/W: delivery mode */
-# define IOART_DELFIXED 0x00000000 /* fixed */
-# define IOART_DELLOPRI 0x00000100 /* lowest priority */
-# define IOART_DELSMI 0x00000200 /* System Management INT */
-# define IOART_DELRSV1 0x00000300 /* reserved */
-# define IOART_DELNMI 0x00000400 /* NMI signal */
-# define IOART_DELINIT 0x00000500 /* INIT signal */
-# define IOART_DELRSV2 0x00000600 /* reserved */
-# define IOART_DELEXINT 0x00000700 /* External INTerrupt */
-
-#define IOART_INTVEC 0x000000ff /* R/W: INTerrupt vector field */
-
-#endif /* _MACHINE_APIC_H_ */
diff --git a/sys/amd64/include/asm.h b/sys/amd64/include/asm.h
deleted file mode 100644
index 340b1701f7c1..000000000000
--- a/sys/amd64/include/asm.h
+++ /dev/null
@@ -1,171 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)DEFS.h 5.1 (Berkeley) 4/23/90
- * $FreeBSD$
- */
-
-#ifndef _MACHINE_ASM_H_
-#define _MACHINE_ASM_H_
-
-#include <sys/cdefs.h>
-
-#ifdef PIC
-#define PIC_PROLOGUE \
- pushl %ebx; \
- call 1f; \
-1: \
- popl %ebx; \
- addl $_GLOBAL_OFFSET_TABLE_+[.-1b],%ebx
-#define PIC_EPILOGUE \
- popl %ebx
-#define PIC_PLT(x) x@PLT
-#define PIC_GOT(x) x@GOT(%ebx)
-#define PIC_GOTOFF(x) x@GOTOFF(%ebx)
-#else
-#define PIC_PROLOGUE
-#define PIC_EPILOGUE
-#define PIC_PLT(x) x
-#define PIC_GOT(x) x
-#define PIC_GOTOFF(x) x
-#endif
-
-/*
- * CNAME and HIDENAME manage the relationship between symbol names in C
- * and the equivalent assembly language names. CNAME is given a name as
- * it would be used in a C program. It expands to the equivalent assembly
- * language name. HIDENAME is given an assembly-language name, and expands
- * to a possibly-modified form that will be invisible to C programs.
- */
-#ifdef __ELF__
-#define CNAME(csym) csym
-#define HIDENAME(asmsym) __CONCAT(.,asmsym)
-#else
-#define CNAME(csym) __CONCAT(_,csym)
-#define HIDENAME(asmsym) asmsym
-#endif
-
-/* XXX should use .p2align 4,0x90 for -m486. */
-#define _START_ENTRY .text; .p2align 2,0x90
-
-#define _ENTRY(x) _START_ENTRY; \
- .globl CNAME(x); .type CNAME(x),@function; CNAME(x):
-
-#ifdef PROF
-#define ALTENTRY(x) _ENTRY(x); \
- pushl %ebp; movl %esp,%ebp; \
- call PIC_PLT(HIDENAME(mcount)); \
- popl %ebp; \
- jmp 9f
-#define ENTRY(x) _ENTRY(x); \
- pushl %ebp; movl %esp,%ebp; \
- call PIC_PLT(HIDENAME(mcount)); \
- popl %ebp; \
- 9:
-#else
-#define ALTENTRY(x) _ENTRY(x)
-#define ENTRY(x) _ENTRY(x)
-#endif
-
-#define RCSID(x) .text; .asciz x
-
-#ifdef _ARCH_INDIRECT
-/*
- * Generate code to select between the generic functions and _ARCH_INDIRECT
- * specific ones.
- * XXX nested __CONCATs don't work with non-ANSI cpp's.
- */
-#define ANAME(x) CNAME(__CONCAT(__CONCAT(__,_ARCH_INDIRECT),x))
-#define ASELNAME(x) CNAME(__CONCAT(__arch_select_,x))
-#define AVECNAME(x) CNAME(__CONCAT(__arch_,x))
-#define GNAME(x) CNAME(__CONCAT(__generic_,x))
-
-/* Don't bother profiling this. */
-#ifdef PIC
-#define ARCH_DISPATCH(x) \
- _START_ENTRY; \
- .globl CNAME(x); .type CNAME(x),@function; CNAME(x): ; \
- PIC_PROLOGUE; \
- movl PIC_GOT(AVECNAME(x)),%eax; \
- PIC_EPILOGUE; \
- jmpl *(%eax)
-
-#define ARCH_SELECT(x) _START_ENTRY; \
- .type ASELNAME(x),@function; \
- ASELNAME(x): \
- PIC_PROLOGUE; \
- call PIC_PLT(CNAME(__get_hw_float)); \
- testl %eax,%eax; \
- movl PIC_GOT(ANAME(x)),%eax; \
- jne 8f; \
- movl PIC_GOT(GNAME(x)),%eax; \
- 8: \
- movl PIC_GOT(AVECNAME(x)),%edx; \
- movl %eax,(%edx); \
- PIC_EPILOGUE; \
- jmpl *%eax
-#else /* !PIC */
-#define ARCH_DISPATCH(x) \
- _START_ENTRY; \
- .globl CNAME(x); .type CNAME(x),@function; CNAME(x): ; \
- jmpl *AVECNAME(x)
-
-#define ARCH_SELECT(x) _START_ENTRY; \
- .type ASELNAME(x),@function; \
- ASELNAME(x): \
- call CNAME(__get_hw_float); \
- testl %eax,%eax; \
- movl $ANAME(x),%eax; \
- jne 8f; \
- movl $GNAME(x),%eax; \
- 8: \
- movl %eax,AVECNAME(x); \
- jmpl *%eax
-#endif /* PIC */
-
-#define ARCH_VECTOR(x) .data; .p2align 2; \
- .globl AVECNAME(x); \
- .type AVECNAME(x),@object; \
- .size AVECNAME(x),4; \
- AVECNAME(x): .long ASELNAME(x)
-
-#undef _ENTRY
-#define _ENTRY(x) ARCH_VECTOR(x); ARCH_SELECT(x); ARCH_DISPATCH(x); \
- _START_ENTRY; \
- .globl ANAME(x); .type ANAME(x),@function; ANAME(x):
-
-#endif /* _ARCH_INDIRECT */
-
-#endif /* !_MACHINE_ASM_H_ */
diff --git a/sys/amd64/include/asmacros.h b/sys/amd64/include/asmacros.h
deleted file mode 100644
index 92b9e1a5d700..000000000000
--- a/sys/amd64/include/asmacros.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/*-
- * Copyright (c) 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _MACHINE_ASMACROS_H_
-#define _MACHINE_ASMACROS_H_
-
-#include <sys/cdefs.h>
-#include <machine/asnames.h>
-
-/* XXX too much duplication in various asm*.h's. */
-
-/*
- * CNAME and HIDENAME manage the relationship between symbol names in C
- * and the equivalent assembly language names. CNAME is given a name as
- * it would be used in a C program. It expands to the equivalent assembly
- * language name. HIDENAME is given an assembly-language name, and expands
- * to a possibly-modified form that will be invisible to C programs.
- */
-#if defined(__ELF__)
-#define CNAME(csym) csym
-#define HIDENAME(asmsym) __CONCAT(.,asmsym)
-#else
-#define CNAME(csym) __CONCAT(_,csym)
-#define HIDENAME(asmsym) asmsym
-#endif
-
-#define ALIGN_DATA .p2align 2 /* 4 byte alignment, zero filled */
-#ifdef GPROF
-#define ALIGN_TEXT .p2align 4,0x90 /* 16-byte alignment, nop filled */
-#else
-#define ALIGN_TEXT .p2align 2,0x90 /* 4-byte alignment, nop filled */
-#endif
-#define SUPERALIGN_TEXT .p2align 4,0x90 /* 16-byte alignment, nop filled */
-
-#define GEN_ENTRY(name) ALIGN_TEXT; .globl CNAME(name); \
- .type CNAME(name),@function; CNAME(name):
-#define NON_GPROF_ENTRY(name) GEN_ENTRY(name)
-#define NON_GPROF_RET .byte 0xc3 /* opcode for `ret' */
-
-#ifdef GPROF
-/*
- * __mcount is like [.]mcount except that doesn't require its caller to set
- * up a frame pointer. It must be called before pushing anything onto the
- * stack. gcc should eventually generate code to call __mcount in most
- * cases. This would make -pg in combination with -fomit-frame-pointer
- * useful. gcc has a configuration variable PROFILE_BEFORE_PROLOGUE to
- * allow profiling before setting up the frame pointer, but this is
- * inadequate for good handling of special cases, e.g., -fpic works best
- * with profiling after the prologue.
- *
- * [.]mexitcount is a new function to support non-statistical profiling if an
- * accurate clock is available. For C sources, calls to it are generated
- * by the FreeBSD extension `-mprofiler-epilogue' to gcc. It is best to
- * call [.]mexitcount at the end of a function like the MEXITCOUNT macro does,
- * but gcc currently generates calls to it at the start of the epilogue to
- * avoid problems with -fpic.
- *
- * [.]mcount and __mcount may clobber the call-used registers and %ef.
- * [.]mexitcount may clobber %ecx and %ef.
- *
- * Cross-jumping makes non-statistical profiling timing more complicated.
- * It is handled in many cases by calling [.]mexitcount before jumping. It
- * is handled for conditional jumps using CROSSJUMP() and CROSSJUMP_LABEL().
- * It is handled for some fault-handling jumps by not sharing the exit
- * routine.
- *
- * ALTENTRY() must be before a corresponding ENTRY() so that it can jump to
- * the main entry point. Note that alt entries are counted twice. They
- * have to be counted as ordinary entries for gprof to get the call times
- * right for the ordinary entries.
- *
- * High local labels are used in macros to avoid clashes with local labels
- * in functions.
- *
- * Ordinary `ret' is used instead of a macro `RET' because there are a lot
- * of `ret's. 0xc3 is the opcode for `ret' (`#define ret ... ret' can't
- * be used because this file is sometimes preprocessed in traditional mode).
- * `ret' clobbers eflags but this doesn't matter.
- */
-#define ALTENTRY(name) GEN_ENTRY(name) ; MCOUNT ; MEXITCOUNT ; jmp 9f
-#define CROSSJUMP(jtrue, label, jfalse) \
- jfalse 8f; MEXITCOUNT; jmp __CONCAT(to,label); 8:
-#define CROSSJUMPTARGET(label) \
- ALIGN_TEXT; __CONCAT(to,label): ; MCOUNT; jmp label
-#define ENTRY(name) GEN_ENTRY(name) ; 9: ; MCOUNT
-#define FAKE_MCOUNT(caller) pushl caller ; call __mcount ; popl %ecx
-#define MCOUNT call __mcount
-#define MCOUNT_LABEL(name) GEN_ENTRY(name) ; nop ; ALIGN_TEXT
-#define MEXITCOUNT call HIDENAME(mexitcount)
-#define ret MEXITCOUNT ; NON_GPROF_RET
-
-#else /* !GPROF */
-/*
- * ALTENTRY() has to align because it is before a corresponding ENTRY().
- * ENTRY() has to align to because there may be no ALTENTRY() before it.
- * If there is a previous ALTENTRY() then the alignment code for ENTRY()
- * is empty.
- */
-#define ALTENTRY(name) GEN_ENTRY(name)
-#define CROSSJUMP(jtrue, label, jfalse) jtrue label
-#define CROSSJUMPTARGET(label)
-#define ENTRY(name) GEN_ENTRY(name)
-#define FAKE_MCOUNT(caller)
-#define MCOUNT
-#define MCOUNT_LABEL(name)
-#define MEXITCOUNT
-#endif /* GPROF */
-
-#endif /* !_MACHINE_ASMACROS_H_ */
diff --git a/sys/amd64/include/atomic.h b/sys/amd64/include/atomic.h
deleted file mode 100644
index 05167aa39625..000000000000
--- a/sys/amd64/include/atomic.h
+++ /dev/null
@@ -1,151 +0,0 @@
-/*-
- * Copyright (c) 1998 Doug Rabson
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#ifndef _MACHINE_ATOMIC_H_
-#define _MACHINE_ATOMIC_H_
-
-/*
- * Various simple arithmetic on memory which is atomic in the presence
- * of interrupts and multiple processors.
- *
- * atomic_set_char(P, V) (*(u_char*)(P) |= (V))
- * atomic_clear_char(P, V) (*(u_char*)(P) &= ~(V))
- * atomic_add_char(P, V) (*(u_char*)(P) += (V))
- * atomic_subtract_char(P, V) (*(u_char*)(P) -= (V))
- *
- * atomic_set_short(P, V) (*(u_short*)(P) |= (V))
- * atomic_clear_short(P, V) (*(u_short*)(P) &= ~(V))
- * atomic_add_short(P, V) (*(u_short*)(P) += (V))
- * atomic_subtract_short(P, V) (*(u_short*)(P) -= (V))
- *
- * atomic_set_int(P, V) (*(u_int*)(P) |= (V))
- * atomic_clear_int(P, V) (*(u_int*)(P) &= ~(V))
- * atomic_add_int(P, V) (*(u_int*)(P) += (V))
- * atomic_subtract_int(P, V) (*(u_int*)(P) -= (V))
- *
- * atomic_set_long(P, V) (*(u_long*)(P) |= (V))
- * atomic_clear_long(P, V) (*(u_long*)(P) &= ~(V))
- * atomic_add_long(P, V) (*(u_long*)(P) += (V))
- * atomic_subtract_long(P, V) (*(u_long*)(P) -= (V))
- */
-
-/*
- * The above functions are expanded inline in the statically-linked
- * kernel. Lock prefixes are generated if an SMP kernel is being
- * built.
- *
- * Kernel modules call real functions which are built into the kernel.
- * This allows kernel modules to be portable between UP and SMP systems.
- */
-#if defined(KLD_MODULE)
-#define ATOMIC_ASM(NAME, TYPE, OP, V) \
- extern void atomic_##NAME##_##TYPE(volatile u_##TYPE *p, u_##TYPE v);
-
-#else /* !KLD_MODULE */
-#if defined(SMP)
-#define MPLOCKED "lock ; "
-#else
-#define MPLOCKED
-#endif
-
-/*
- * The assembly is volatilized to demark potential before-and-after side
- * effects if an interrupt or SMP collision were to occur.
- */
-#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 9)
-/* egcs 1.1.2+ version */
-#define ATOMIC_ASM(NAME, TYPE, OP, V) \
-static __inline void \
-atomic_##NAME##_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\
-{ \
- __asm __volatile(MPLOCKED OP \
- : "=m" (*p) \
- : "0" (*p), "ir" (V)); \
-}
-
-#else
-/* gcc <= 2.8 version */
-#define ATOMIC_ASM(NAME, TYPE, OP, V) \
-static __inline void \
-atomic_##NAME##_##TYPE(volatile u_##TYPE *p, u_##TYPE v)\
-{ \
- __asm __volatile(MPLOCKED OP \
- : "=m" (*p) \
- : "ir" (V)); \
-}
-#endif
-#endif /* KLD_MODULE */
-
-#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 9)
-
-/* egcs 1.1.2+ version */
-ATOMIC_ASM(set, char, "orb %2,%0", v)
-ATOMIC_ASM(clear, char, "andb %2,%0", ~v)
-ATOMIC_ASM(add, char, "addb %2,%0", v)
-ATOMIC_ASM(subtract, char, "subb %2,%0", v)
-
-ATOMIC_ASM(set, short, "orw %2,%0", v)
-ATOMIC_ASM(clear, short, "andw %2,%0", ~v)
-ATOMIC_ASM(add, short, "addw %2,%0", v)
-ATOMIC_ASM(subtract, short, "subw %2,%0", v)
-
-ATOMIC_ASM(set, int, "orl %2,%0", v)
-ATOMIC_ASM(clear, int, "andl %2,%0", ~v)
-ATOMIC_ASM(add, int, "addl %2,%0", v)
-ATOMIC_ASM(subtract, int, "subl %2,%0", v)
-
-ATOMIC_ASM(set, long, "orl %2,%0", v)
-ATOMIC_ASM(clear, long, "andl %2,%0", ~v)
-ATOMIC_ASM(add, long, "addl %2,%0", v)
-ATOMIC_ASM(subtract, long, "subl %2,%0", v)
-
-#else
-
-/* gcc <= 2.8 version */
-ATOMIC_ASM(set, char, "orb %1,%0", v)
-ATOMIC_ASM(clear, char, "andb %1,%0", ~v)
-ATOMIC_ASM(add, char, "addb %1,%0", v)
-ATOMIC_ASM(subtract, char, "subb %1,%0", v)
-
-ATOMIC_ASM(set, short, "orw %1,%0", v)
-ATOMIC_ASM(clear, short, "andw %1,%0", ~v)
-ATOMIC_ASM(add, short, "addw %1,%0", v)
-ATOMIC_ASM(subtract, short, "subw %1,%0", v)
-
-ATOMIC_ASM(set, int, "orl %1,%0", v)
-ATOMIC_ASM(clear, int, "andl %1,%0", ~v)
-ATOMIC_ASM(add, int, "addl %1,%0", v)
-ATOMIC_ASM(subtract, int, "subl %1,%0", v)
-
-ATOMIC_ASM(set, long, "orl %1,%0", v)
-ATOMIC_ASM(clear, long, "andl %1,%0", ~v)
-ATOMIC_ASM(add, long, "addl %1,%0", v)
-ATOMIC_ASM(subtract, long, "subl %1,%0", v)
-
-#endif
-
-#endif /* ! _MACHINE_ATOMIC_H_ */
diff --git a/sys/amd64/include/bus.h b/sys/amd64/include/bus.h
deleted file mode 100644
index 661761271085..000000000000
--- a/sys/amd64/include/bus.h
+++ /dev/null
@@ -1,1291 +0,0 @@
-/* $NetBSD: bus.h,v 1.12 1997/10/01 08:25:15 fvdl Exp $ */
-
-/*-
- * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
- * NASA Ames Research Center.
- *
- * 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 the NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Copyright (c) 1996 Charles M. Hannum. All rights reserved.
- * Copyright (c) 1996 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
- * for the NetBSD Project.
- * 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.
- */
-/* $FreeBSD$ */
-
-#ifndef _I386_BUS_H_
-#define _I386_BUS_H_
-
-#include <machine/cpufunc.h>
-
-/*
- * To remain compatible with NetBSD's interface, default to both memio and
- * pio when neither of them is defined.
- */
-#if !defined(_I386_BUS_PIO_H_) && !defined(_I386_BUS_MEMIO_H_)
-#define _I386_BUS_PIO_H_
-#define _I386_BUS_MEMIO_H_
-#endif
-
-/*
- * Values for the i386 bus space tag, not to be used directly by MI code.
- */
-#define I386_BUS_SPACE_IO 0 /* space is i/o space */
-#define I386_BUS_SPACE_MEM 1 /* space is mem space */
-
-/*
- * Bus address and size types
- */
-typedef u_int bus_addr_t;
-typedef u_int bus_size_t;
-
-#define BUS_SPACE_MAXSIZE_24BIT 0xFFFFFF
-#define BUS_SPACE_MAXSIZE_32BIT 0xFFFFFFFF
-#define BUS_SPACE_MAXSIZE (64 * 1024) /* Maximum supported size */
-#define BUS_SPACE_MAXADDR_24BIT 0xFFFFFF
-#define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFF
-#define BUS_SPACE_MAXADDR 0xFFFFFFFF
-
-#define BUS_SPACE_UNRESTRICTED (~0)
-
-/*
- * Access methods for bus resources and address space.
- */
-typedef int bus_space_tag_t;
-typedef u_int bus_space_handle_t;
-
-/*
- * Map a region of device bus space into CPU virtual address space.
- */
-
-#define BUS_SPACE_MAP_CACHEABLE 0x01
-#define BUS_SPACE_MAP_LINEAR 0x02
-
-int bus_space_map(bus_space_tag_t t, bus_addr_t addr, bus_size_t size,
- int flags, bus_space_handle_t *bshp);
-
-/*
- * Unmap a region of device bus space.
- */
-
-void bus_space_unmap(bus_space_tag_t t, bus_space_handle_t bsh,
- bus_size_t size);
-
-/*
- * Get a new handle for a subregion of an already-mapped area of bus space.
- */
-
-int bus_space_subregion(bus_space_tag_t t, bus_space_handle_t bsh,
- bus_size_t offset, bus_size_t size,
- bus_space_handle_t *nbshp);
-
-/*
- * Allocate a region of memory that is accessible to devices in bus space.
- */
-
-int bus_space_alloc(bus_space_tag_t t, 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);
-
-/*
- * Free a region of bus space accessible memory.
- */
-
-void bus_space_free(bus_space_tag_t t, bus_space_handle_t bsh,
- bus_size_t size);
-
-#if defined(_I386_BUS_PIO_H_) || defined(_I386_BUS_MEMIO_H_)
-
-/*
- * Read a 1, 2, 4, or 8 byte quantity from bus space
- * described by tag/handle/offset.
- */
-static __inline u_int8_t bus_space_read_1(bus_space_tag_t tag,
- bus_space_handle_t handle,
- bus_size_t offset);
-
-static __inline u_int16_t bus_space_read_2(bus_space_tag_t tag,
- bus_space_handle_t handle,
- bus_size_t offset);
-
-static __inline u_int32_t bus_space_read_4(bus_space_tag_t tag,
- bus_space_handle_t handle,
- bus_size_t offset);
-
-static __inline u_int8_t
-bus_space_read_1(bus_space_tag_t tag, bus_space_handle_t handle,
- bus_size_t offset)
-{
-#if defined (_I386_BUS_PIO_H_)
-#if defined (_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- return (inb(handle + offset));
-#endif
-#if defined (_I386_BUS_MEMIO_H_)
- return (*(volatile u_int8_t *)(handle + offset));
-#endif
-}
-
-static __inline u_int16_t
-bus_space_read_2(bus_space_tag_t tag, bus_space_handle_t handle,
- bus_size_t offset)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- return (inw(handle + offset));
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
- return (*(volatile u_int16_t *)(handle + offset));
-#endif
-}
-
-static __inline u_int32_t
-bus_space_read_4(bus_space_tag_t tag, bus_space_handle_t handle,
- bus_size_t offset)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- return (inl(handle + offset));
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
- return (*(volatile u_int32_t *)(handle + offset));
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_read_8 */
-#define bus_space_read_8(t, h, o) !!! bus_space_read_8 unimplemented !!!
-#endif
-
-/*
- * Read `count' 1, 2, 4, or 8 byte quantities from bus space
- * described by tag/handle/offset and copy into buffer provided.
- */
-static __inline void bus_space_read_multi_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t *addr,
- size_t count);
-
-static __inline void bus_space_read_multi_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t *addr,
- size_t count);
-
-static __inline void bus_space_read_multi_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t *addr,
- size_t count);
-
-static __inline void
-bus_space_read_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- insb(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: movb (%2),%%al \n\
- stosb \n\
- loop 1b" :
- "=D" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory");
- }
-#endif
-}
-
-static __inline void
-bus_space_read_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- insw(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: movw (%2),%%ax \n\
- stosw \n\
- loop 1b" :
- "=D" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory");
- }
-#endif
-}
-
-static __inline void
-bus_space_read_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- insl(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: movl (%2),%%eax \n\
- stosl \n\
- loop 1b" :
- "=D" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory");
- }
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_read_multi_8 */
-#define bus_space_read_multi_8 !!! bus_space_read_multi_8 unimplemented !!!
-#endif
-
-/*
- * Read `count' 1, 2, 4, or 8 byte quantities from bus space
- * described by tag/handle and starting at `offset' and copy into
- * buffer provided.
- */
-static __inline void bus_space_read_region_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t *addr,
- size_t count);
-
-static __inline void bus_space_read_region_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t *addr,
- size_t count);
-
-static __inline void bus_space_read_region_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t *addr,
- size_t count);
-
-
-static __inline void
-bus_space_read_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: inb %w2,%%al \n\
- stosb \n\
- incl %2 \n\
- loop 1b" :
- "=D" (addr), "=c" (count), "=d" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsb" :
- "=D" (addr), "=c" (count), "=S" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_read_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: inw %w2,%%ax \n\
- stosw \n\
- addl $2,%2 \n\
- loop 1b" :
- "=D" (addr), "=c" (count), "=d" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsw" :
- "=D" (addr), "=c" (count), "=S" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_read_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: inl %w2,%%eax \n\
- stosl \n\
- addl $4,%2 \n\
- loop 1b" :
- "=D" (addr), "=c" (count), "=d" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsl" :
- "=D" (addr), "=c" (count), "=S" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "memory", "cc");
- }
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_read_region_8 */
-#define bus_space_read_region_8 !!! bus_space_read_region_8 unimplemented !!!
-#endif
-
-/*
- * Write the 1, 2, 4, or 8 byte value `value' to bus space
- * described by tag/handle/offset.
- */
-
-static __inline void bus_space_write_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t value);
-
-static __inline void bus_space_write_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t value);
-
-static __inline void bus_space_write_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t value);
-
-static __inline void
-bus_space_write_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t value)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outb(bsh + offset, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- *(volatile u_int8_t *)(bsh + offset) = value;
-#endif
-}
-
-static __inline void
-bus_space_write_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t value)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outw(bsh + offset, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- *(volatile u_int16_t *)(bsh + offset) = value;
-#endif
-}
-
-static __inline void
-bus_space_write_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t value)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outl(bsh + offset, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- *(volatile u_int32_t *)(bsh + offset) = value;
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_write_8 */
-#define bus_space_write_8 !!! bus_space_write_8 not implemented !!!
-#endif
-
-/*
- * Write `count' 1, 2, 4, or 8 byte quantities from the buffer
- * provided to bus space described by tag/handle/offset.
- */
-
-static __inline void bus_space_write_multi_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int8_t *addr,
- size_t count);
-static __inline void bus_space_write_multi_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int16_t *addr,
- size_t count);
-
-static __inline void bus_space_write_multi_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int32_t *addr,
- size_t count);
-
-static __inline void
-bus_space_write_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int8_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outsb(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: lodsb \n\
- movb %%al,(%2) \n\
- loop 1b" :
- "=S" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_write_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int16_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outsw(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: lodsw \n\
- movw %%ax,(%1) \n\
- movw %%ax,(%2) \n\
- loop 1b" :
- "=S" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_write_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int32_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outsl(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: lodsl \n\
- movl %%eax,(%2) \n\
- loop 1b" :
- "=S" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_write_multi_8 */
-#define bus_space_write_multi_8(t, h, o, a, c) \
- !!! bus_space_write_multi_8 unimplemented !!!
-#endif
-
-/*
- * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided
- * to bus space described by tag/handle starting at `offset'.
- */
-
-static __inline void bus_space_write_region_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int8_t *addr,
- size_t count);
-static __inline void bus_space_write_region_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int16_t *addr,
- size_t count);
-static __inline void bus_space_write_region_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int32_t *addr,
- size_t count);
-
-static __inline void
-bus_space_write_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int8_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: lodsb \n\
- outb %%al,%w0 \n\
- incl %0 \n\
- loop 1b" :
- "=d" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsb" :
- "=D" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_write_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int16_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: lodsw \n\
- outw %%ax,%w0 \n\
- addl $2,%0 \n\
- loop 1b" :
- "=d" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsw" :
- "=D" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_write_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int32_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: lodsl \n\
- outl %%eax,%w0 \n\
- addl $4,%0 \n\
- loop 1b" :
- "=d" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsl" :
- "=D" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "memory", "cc");
- }
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_write_region_8 */
-#define bus_space_write_region_8 \
- !!! bus_space_write_region_8 unimplemented !!!
-#endif
-
-/*
- * Write the 1, 2, 4, or 8 byte value `val' to bus space described
- * by tag/handle/offset `count' times.
- */
-
-static __inline void bus_space_set_multi_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- u_int8_t value, size_t count);
-static __inline void bus_space_set_multi_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- u_int16_t value, size_t count);
-static __inline void bus_space_set_multi_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- u_int32_t value, size_t count);
-
-static __inline void
-bus_space_set_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- while (count--)
- outb(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- while (count--)
- *(volatile u_int8_t *)(addr) = value;
-#endif
-}
-
-static __inline void
-bus_space_set_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- while (count--)
- outw(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- while (count--)
- *(volatile u_int16_t *)(addr) = value;
-#endif
-}
-
-static __inline void
-bus_space_set_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- while (count--)
- outl(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- while (count--)
- *(volatile u_int32_t *)(addr) = value;
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_set_multi_8 */
-#define bus_space_set_multi_8 !!! bus_space_set_multi_8 unimplemented !!!
-#endif
-
-/*
- * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described
- * by tag/handle starting at `offset'.
- */
-
-static __inline void bus_space_set_region_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t value,
- size_t count);
-static __inline void bus_space_set_region_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t value,
- size_t count);
-static __inline void bus_space_set_region_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t value,
- size_t count);
-
-static __inline void
-bus_space_set_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- for (; count != 0; count--, addr++)
- outb(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- for (; count != 0; count--, addr++)
- *(volatile u_int8_t *)(addr) = value;
-#endif
-}
-
-static __inline void
-bus_space_set_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- for (; count != 0; count--, addr += 2)
- outw(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- for (; count != 0; count--, addr += 2)
- *(volatile u_int16_t *)(addr) = value;
-#endif
-}
-
-static __inline void
-bus_space_set_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- for (; count != 0; count--, addr += 4)
- outl(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- for (; count != 0; count--, addr += 4)
- *(volatile u_int32_t *)(addr) = value;
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_set_region_8 */
-#define bus_space_set_region_8 !!! bus_space_set_region_8 unimplemented !!!
-#endif
-
-/*
- * Copy `count' 1, 2, 4, or 8 byte values from bus space starting
- * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2.
- */
-
-static __inline void bus_space_copy_region_1(bus_space_tag_t tag,
- bus_space_handle_t bsh1,
- bus_size_t off1,
- bus_space_handle_t bsh2,
- bus_size_t off2, size_t count);
-
-static __inline void bus_space_copy_region_2(bus_space_tag_t tag,
- bus_space_handle_t bsh1,
- bus_size_t off1,
- bus_space_handle_t bsh2,
- bus_size_t off2, size_t count);
-
-static __inline void bus_space_copy_region_4(bus_space_tag_t tag,
- bus_space_handle_t bsh1,
- bus_size_t off1,
- bus_space_handle_t bsh2,
- bus_size_t off2, size_t count);
-
-static __inline void
-bus_space_copy_region_1(bus_space_tag_t tag, bus_space_handle_t bsh1,
- bus_size_t off1, bus_space_handle_t bsh2,
- bus_size_t off2, size_t count)
-{
- bus_addr_t addr1 = bsh1 + off1;
- bus_addr_t addr2 = bsh2 + off2;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1++, addr2++)
- outb(addr2, inb(addr1));
- } else {
- /* dest after src: copy backwards */
- for (addr1 += (count - 1), addr2 += (count - 1);
- count != 0; count--, addr1--, addr2--)
- outb(addr2, inb(addr1));
- }
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1++, addr2++)
- *(volatile u_int8_t *)(addr2) =
- *(volatile u_int8_t *)(addr1);
- } else {
- /* dest after src: copy backwards */
- for (addr1 += (count - 1), addr2 += (count - 1);
- count != 0; count--, addr1--, addr2--)
- *(volatile u_int8_t *)(addr2) =
- *(volatile u_int8_t *)(addr1);
- }
- }
-#endif
-}
-
-static __inline void
-bus_space_copy_region_2(bus_space_tag_t tag, bus_space_handle_t bsh1,
- bus_size_t off1, bus_space_handle_t bsh2,
- bus_size_t off2, size_t count)
-{
- bus_addr_t addr1 = bsh1 + off1;
- bus_addr_t addr2 = bsh2 + off2;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1 += 2, addr2 += 2)
- outw(addr2, inw(addr1));
- } else {
- /* dest after src: copy backwards */
- for (addr1 += 2 * (count - 1), addr2 += 2 * (count - 1);
- count != 0; count--, addr1 -= 2, addr2 -= 2)
- outw(addr2, inw(addr1));
- }
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1 += 2, addr2 += 2)
- *(volatile u_int16_t *)(addr2) =
- *(volatile u_int16_t *)(addr1);
- } else {
- /* dest after src: copy backwards */
- for (addr1 += 2 * (count - 1), addr2 += 2 * (count - 1);
- count != 0; count--, addr1 -= 2, addr2 -= 2)
- *(volatile u_int16_t *)(addr2) =
- *(volatile u_int16_t *)(addr1);
- }
- }
-#endif
-}
-
-static __inline void
-bus_space_copy_region_4(bus_space_tag_t tag, bus_space_handle_t bsh1,
- bus_size_t off1, bus_space_handle_t bsh2,
- bus_size_t off2, size_t count)
-{
- bus_addr_t addr1 = bsh1 + off1;
- bus_addr_t addr2 = bsh2 + off2;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1 += 4, addr2 += 4)
- outl(addr2, inl(addr1));
- } else {
- /* dest after src: copy backwards */
- for (addr1 += 4 * (count - 1), addr2 += 4 * (count - 1);
- count != 0; count--, addr1 -= 4, addr2 -= 4)
- outl(addr2, inl(addr1));
- }
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1 += 4, addr2 += 4)
- *(volatile u_int32_t *)(addr2) =
- *(volatile u_int32_t *)(addr1);
- } else {
- /* dest after src: copy backwards */
- for (addr1 += 4 * (count - 1), addr2 += 4 * (count - 1);
- count != 0; count--, addr1 -= 4, addr2 -= 4)
- *(volatile u_int32_t *)(addr2) =
- *(volatile u_int32_t *)(addr1);
- }
- }
-#endif
-}
-
-#endif /* defined(_I386_BUS_PIO_H_) || defined(_I386_MEM_IO_H_) */
-
-#if 0 /* Cause a link error for bus_space_copy_8 */
-#define bus_space_copy_region_8 !!! bus_space_copy_region_8 unimplemented !!!
-#endif
-
-/*
- * Bus read/write barrier methods.
- *
- * void bus_space_barrier(bus_space_tag_t tag, bus_space_handle_t bsh,
- * bus_size_t offset, bus_size_t len, int flags);
- *
- * Note: the i386 does not currently require barriers, but we must
- * provide the flags to MI code.
- */
-#define bus_space_barrier(t, h, o, l, f) \
- ((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f)))
-#define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */
-#define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */
-
-/*
- * Flags used in various bus DMA methods.
- */
-#define BUS_DMA_WAITOK 0x00 /* safe to sleep (pseudo-flag) */
-#define BUS_DMA_NOWAIT 0x01 /* not safe to sleep */
-#define BUS_DMA_ALLOCNOW 0x02 /* perform resource allocation now */
-#define BUS_DMAMEM_NOSYNC 0x04 /* map memory to not require sync */
-#define BUS_DMA_BUS1 0x10 /* placeholders for bus functions... */
-#define BUS_DMA_BUS2 0x20
-#define BUS_DMA_BUS3 0x40
-#define BUS_DMA_BUS4 0x80
-
-/* Forwards needed by prototypes below. */
-struct mbuf;
-struct uio;
-
-/*
- * bus_dmasync_op_t
- *
- * Operations performed by bus_dmamap_sync().
- */
-typedef enum {
- BUS_DMASYNC_PREREAD,
- BUS_DMASYNC_POSTREAD,
- BUS_DMASYNC_PREWRITE,
- BUS_DMASYNC_POSTWRITE
-} bus_dmasync_op_t;
-
-/*
- * bus_dma_tag_t
- *
- * A machine-dependent opaque type describing the characteristics
- * of how to perform DMA mappings. This structure encapsultes
- * information concerning address and alignment restrictions, number
- * of S/G segments, amount of data per S/G segment, etc.
- */
-typedef struct bus_dma_tag *bus_dma_tag_t;
-
-/*
- * bus_dmamap_t
- *
- * DMA mapping instance information.
- */
-typedef struct bus_dmamap *bus_dmamap_t;
-
-/*
- * bus_dma_segment_t
- *
- * Describes a single contiguous DMA transaction. Values
- * are suitable for programming into DMA registers.
- */
-typedef struct bus_dma_segment {
- bus_addr_t ds_addr; /* DMA address */
- bus_size_t ds_len; /* length of transfer */
-} bus_dma_segment_t;
-
-/*
- * A function that returns 1 if the address cannot be accessed by
- * a device and 0 if it can be.
- */
-typedef int bus_dma_filter_t(void *, bus_addr_t);
-
-/*
- * Allocate a device specific dma_tag encapsulating the constraints of
- * the parent tag in addition to other restrictions specified:
- *
- * alignment: alignment for segments.
- * boundary: Boundary that segments cannot cross.
- * lowaddr: Low restricted address that cannot appear in a mapping.
- * highaddr: High restricted address that cannot appear in a mapping.
- * filtfunc: An optional function to further test if an address
- * within the range of lowaddr and highaddr cannot appear
- * in a mapping.
- * filtfuncarg: An argument that will be passed to filtfunc in addition
- * to the address to test.
- * maxsize: Maximum mapping size supported by this tag.
- * nsegments: Number of discontinuities allowed in maps.
- * maxsegsz: Maximum size of a segment in the map.
- * flags: Bus DMA flags.
- * dmat: A pointer to set to a valid dma tag should the return
- * value of this function indicate success.
- */
-/* XXX Should probably allow specification of alignment */
-int bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignemnt,
- bus_size_t boundary, bus_addr_t lowaddr,
- bus_addr_t highaddr, bus_dma_filter_t *filtfunc,
- void *filtfuncarg, bus_size_t maxsize, int nsegments,
- bus_size_t maxsegsz, int flags, bus_dma_tag_t *dmat);
-
-int bus_dma_tag_destroy(bus_dma_tag_t dmat);
-
-/*
- * Allocate a handle for mapping from kva/uva/physical
- * address space into bus device space.
- */
-int bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp);
-
-/*
- * Destroy a handle for mapping from kva/uva/physical
- * address space into bus device space.
- */
-int bus_dmamap_destroy(bus_dma_tag_t dmat, bus_dmamap_t map);
-
-/*
- * Allocate a piece of memory that can be efficiently mapped into
- * bus device space based on the constraints lited in the dma tag.
- * A dmamap to for use with dmamap_load is also allocated.
- */
-int bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
- bus_dmamap_t *mapp);
-
-/*
- * Free a piece of memory and it's allociated dmamap, that was allocated
- * via bus_dmamem_alloc.
- */
-void bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map);
-
-/*
- * A function that processes a successfully loaded dma map or an error
- * from a delayed load map.
- */
-typedef void bus_dmamap_callback_t(void *, bus_dma_segment_t *, int, int);
-
-/*
- * Map the buffer buf into bus space using the dmamap map.
- */
-int bus_dmamap_load(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf,
- bus_size_t buflen, bus_dmamap_callback_t *callback,
- void *callback_arg, int flags);
-
-/*
- * Perform a syncronization operation on the given map.
- */
-void _bus_dmamap_sync(bus_dma_tag_t, bus_dmamap_t, bus_dmasync_op_t);
-#define bus_dmamap_sync(dmat, dmamap, op) \
- if ((dmamap) != NULL) \
- _bus_dmamap_sync(dmat, dmamap, op)
-
-/*
- * Release the mapping held by map.
- */
-void _bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map);
-#define bus_dmamap_unload(dmat, dmamap) \
- if ((dmamap) != NULL) \
- _bus_dmamap_unload(dmat, dmamap)
-
-#endif /* _I386_BUS_H_ */
diff --git a/sys/amd64/include/bus_amd64.h b/sys/amd64/include/bus_amd64.h
deleted file mode 100644
index 661761271085..000000000000
--- a/sys/amd64/include/bus_amd64.h
+++ /dev/null
@@ -1,1291 +0,0 @@
-/* $NetBSD: bus.h,v 1.12 1997/10/01 08:25:15 fvdl Exp $ */
-
-/*-
- * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
- * NASA Ames Research Center.
- *
- * 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 the NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Copyright (c) 1996 Charles M. Hannum. All rights reserved.
- * Copyright (c) 1996 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
- * for the NetBSD Project.
- * 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.
- */
-/* $FreeBSD$ */
-
-#ifndef _I386_BUS_H_
-#define _I386_BUS_H_
-
-#include <machine/cpufunc.h>
-
-/*
- * To remain compatible with NetBSD's interface, default to both memio and
- * pio when neither of them is defined.
- */
-#if !defined(_I386_BUS_PIO_H_) && !defined(_I386_BUS_MEMIO_H_)
-#define _I386_BUS_PIO_H_
-#define _I386_BUS_MEMIO_H_
-#endif
-
-/*
- * Values for the i386 bus space tag, not to be used directly by MI code.
- */
-#define I386_BUS_SPACE_IO 0 /* space is i/o space */
-#define I386_BUS_SPACE_MEM 1 /* space is mem space */
-
-/*
- * Bus address and size types
- */
-typedef u_int bus_addr_t;
-typedef u_int bus_size_t;
-
-#define BUS_SPACE_MAXSIZE_24BIT 0xFFFFFF
-#define BUS_SPACE_MAXSIZE_32BIT 0xFFFFFFFF
-#define BUS_SPACE_MAXSIZE (64 * 1024) /* Maximum supported size */
-#define BUS_SPACE_MAXADDR_24BIT 0xFFFFFF
-#define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFF
-#define BUS_SPACE_MAXADDR 0xFFFFFFFF
-
-#define BUS_SPACE_UNRESTRICTED (~0)
-
-/*
- * Access methods for bus resources and address space.
- */
-typedef int bus_space_tag_t;
-typedef u_int bus_space_handle_t;
-
-/*
- * Map a region of device bus space into CPU virtual address space.
- */
-
-#define BUS_SPACE_MAP_CACHEABLE 0x01
-#define BUS_SPACE_MAP_LINEAR 0x02
-
-int bus_space_map(bus_space_tag_t t, bus_addr_t addr, bus_size_t size,
- int flags, bus_space_handle_t *bshp);
-
-/*
- * Unmap a region of device bus space.
- */
-
-void bus_space_unmap(bus_space_tag_t t, bus_space_handle_t bsh,
- bus_size_t size);
-
-/*
- * Get a new handle for a subregion of an already-mapped area of bus space.
- */
-
-int bus_space_subregion(bus_space_tag_t t, bus_space_handle_t bsh,
- bus_size_t offset, bus_size_t size,
- bus_space_handle_t *nbshp);
-
-/*
- * Allocate a region of memory that is accessible to devices in bus space.
- */
-
-int bus_space_alloc(bus_space_tag_t t, 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);
-
-/*
- * Free a region of bus space accessible memory.
- */
-
-void bus_space_free(bus_space_tag_t t, bus_space_handle_t bsh,
- bus_size_t size);
-
-#if defined(_I386_BUS_PIO_H_) || defined(_I386_BUS_MEMIO_H_)
-
-/*
- * Read a 1, 2, 4, or 8 byte quantity from bus space
- * described by tag/handle/offset.
- */
-static __inline u_int8_t bus_space_read_1(bus_space_tag_t tag,
- bus_space_handle_t handle,
- bus_size_t offset);
-
-static __inline u_int16_t bus_space_read_2(bus_space_tag_t tag,
- bus_space_handle_t handle,
- bus_size_t offset);
-
-static __inline u_int32_t bus_space_read_4(bus_space_tag_t tag,
- bus_space_handle_t handle,
- bus_size_t offset);
-
-static __inline u_int8_t
-bus_space_read_1(bus_space_tag_t tag, bus_space_handle_t handle,
- bus_size_t offset)
-{
-#if defined (_I386_BUS_PIO_H_)
-#if defined (_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- return (inb(handle + offset));
-#endif
-#if defined (_I386_BUS_MEMIO_H_)
- return (*(volatile u_int8_t *)(handle + offset));
-#endif
-}
-
-static __inline u_int16_t
-bus_space_read_2(bus_space_tag_t tag, bus_space_handle_t handle,
- bus_size_t offset)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- return (inw(handle + offset));
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
- return (*(volatile u_int16_t *)(handle + offset));
-#endif
-}
-
-static __inline u_int32_t
-bus_space_read_4(bus_space_tag_t tag, bus_space_handle_t handle,
- bus_size_t offset)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- return (inl(handle + offset));
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
- return (*(volatile u_int32_t *)(handle + offset));
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_read_8 */
-#define bus_space_read_8(t, h, o) !!! bus_space_read_8 unimplemented !!!
-#endif
-
-/*
- * Read `count' 1, 2, 4, or 8 byte quantities from bus space
- * described by tag/handle/offset and copy into buffer provided.
- */
-static __inline void bus_space_read_multi_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t *addr,
- size_t count);
-
-static __inline void bus_space_read_multi_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t *addr,
- size_t count);
-
-static __inline void bus_space_read_multi_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t *addr,
- size_t count);
-
-static __inline void
-bus_space_read_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- insb(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: movb (%2),%%al \n\
- stosb \n\
- loop 1b" :
- "=D" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory");
- }
-#endif
-}
-
-static __inline void
-bus_space_read_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- insw(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: movw (%2),%%ax \n\
- stosw \n\
- loop 1b" :
- "=D" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory");
- }
-#endif
-}
-
-static __inline void
-bus_space_read_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- insl(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: movl (%2),%%eax \n\
- stosl \n\
- loop 1b" :
- "=D" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory");
- }
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_read_multi_8 */
-#define bus_space_read_multi_8 !!! bus_space_read_multi_8 unimplemented !!!
-#endif
-
-/*
- * Read `count' 1, 2, 4, or 8 byte quantities from bus space
- * described by tag/handle and starting at `offset' and copy into
- * buffer provided.
- */
-static __inline void bus_space_read_region_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t *addr,
- size_t count);
-
-static __inline void bus_space_read_region_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t *addr,
- size_t count);
-
-static __inline void bus_space_read_region_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t *addr,
- size_t count);
-
-
-static __inline void
-bus_space_read_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: inb %w2,%%al \n\
- stosb \n\
- incl %2 \n\
- loop 1b" :
- "=D" (addr), "=c" (count), "=d" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsb" :
- "=D" (addr), "=c" (count), "=S" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_read_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: inw %w2,%%ax \n\
- stosw \n\
- addl $2,%2 \n\
- loop 1b" :
- "=D" (addr), "=c" (count), "=d" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsw" :
- "=D" (addr), "=c" (count), "=S" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_read_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: inl %w2,%%eax \n\
- stosl \n\
- addl $4,%2 \n\
- loop 1b" :
- "=D" (addr), "=c" (count), "=d" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsl" :
- "=D" (addr), "=c" (count), "=S" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "memory", "cc");
- }
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_read_region_8 */
-#define bus_space_read_region_8 !!! bus_space_read_region_8 unimplemented !!!
-#endif
-
-/*
- * Write the 1, 2, 4, or 8 byte value `value' to bus space
- * described by tag/handle/offset.
- */
-
-static __inline void bus_space_write_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t value);
-
-static __inline void bus_space_write_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t value);
-
-static __inline void bus_space_write_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t value);
-
-static __inline void
-bus_space_write_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t value)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outb(bsh + offset, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- *(volatile u_int8_t *)(bsh + offset) = value;
-#endif
-}
-
-static __inline void
-bus_space_write_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t value)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outw(bsh + offset, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- *(volatile u_int16_t *)(bsh + offset) = value;
-#endif
-}
-
-static __inline void
-bus_space_write_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t value)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outl(bsh + offset, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- *(volatile u_int32_t *)(bsh + offset) = value;
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_write_8 */
-#define bus_space_write_8 !!! bus_space_write_8 not implemented !!!
-#endif
-
-/*
- * Write `count' 1, 2, 4, or 8 byte quantities from the buffer
- * provided to bus space described by tag/handle/offset.
- */
-
-static __inline void bus_space_write_multi_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int8_t *addr,
- size_t count);
-static __inline void bus_space_write_multi_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int16_t *addr,
- size_t count);
-
-static __inline void bus_space_write_multi_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int32_t *addr,
- size_t count);
-
-static __inline void
-bus_space_write_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int8_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outsb(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: lodsb \n\
- movb %%al,(%2) \n\
- loop 1b" :
- "=S" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_write_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int16_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outsw(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: lodsw \n\
- movw %%ax,(%1) \n\
- movw %%ax,(%2) \n\
- loop 1b" :
- "=S" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_write_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int32_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outsl(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: lodsl \n\
- movl %%eax,(%2) \n\
- loop 1b" :
- "=S" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_write_multi_8 */
-#define bus_space_write_multi_8(t, h, o, a, c) \
- !!! bus_space_write_multi_8 unimplemented !!!
-#endif
-
-/*
- * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided
- * to bus space described by tag/handle starting at `offset'.
- */
-
-static __inline void bus_space_write_region_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int8_t *addr,
- size_t count);
-static __inline void bus_space_write_region_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int16_t *addr,
- size_t count);
-static __inline void bus_space_write_region_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int32_t *addr,
- size_t count);
-
-static __inline void
-bus_space_write_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int8_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: lodsb \n\
- outb %%al,%w0 \n\
- incl %0 \n\
- loop 1b" :
- "=d" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsb" :
- "=D" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_write_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int16_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: lodsw \n\
- outw %%ax,%w0 \n\
- addl $2,%0 \n\
- loop 1b" :
- "=d" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsw" :
- "=D" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_write_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int32_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: lodsl \n\
- outl %%eax,%w0 \n\
- addl $4,%0 \n\
- loop 1b" :
- "=d" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsl" :
- "=D" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "memory", "cc");
- }
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_write_region_8 */
-#define bus_space_write_region_8 \
- !!! bus_space_write_region_8 unimplemented !!!
-#endif
-
-/*
- * Write the 1, 2, 4, or 8 byte value `val' to bus space described
- * by tag/handle/offset `count' times.
- */
-
-static __inline void bus_space_set_multi_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- u_int8_t value, size_t count);
-static __inline void bus_space_set_multi_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- u_int16_t value, size_t count);
-static __inline void bus_space_set_multi_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- u_int32_t value, size_t count);
-
-static __inline void
-bus_space_set_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- while (count--)
- outb(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- while (count--)
- *(volatile u_int8_t *)(addr) = value;
-#endif
-}
-
-static __inline void
-bus_space_set_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- while (count--)
- outw(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- while (count--)
- *(volatile u_int16_t *)(addr) = value;
-#endif
-}
-
-static __inline void
-bus_space_set_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- while (count--)
- outl(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- while (count--)
- *(volatile u_int32_t *)(addr) = value;
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_set_multi_8 */
-#define bus_space_set_multi_8 !!! bus_space_set_multi_8 unimplemented !!!
-#endif
-
-/*
- * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described
- * by tag/handle starting at `offset'.
- */
-
-static __inline void bus_space_set_region_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t value,
- size_t count);
-static __inline void bus_space_set_region_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t value,
- size_t count);
-static __inline void bus_space_set_region_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t value,
- size_t count);
-
-static __inline void
-bus_space_set_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- for (; count != 0; count--, addr++)
- outb(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- for (; count != 0; count--, addr++)
- *(volatile u_int8_t *)(addr) = value;
-#endif
-}
-
-static __inline void
-bus_space_set_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- for (; count != 0; count--, addr += 2)
- outw(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- for (; count != 0; count--, addr += 2)
- *(volatile u_int16_t *)(addr) = value;
-#endif
-}
-
-static __inline void
-bus_space_set_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- for (; count != 0; count--, addr += 4)
- outl(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- for (; count != 0; count--, addr += 4)
- *(volatile u_int32_t *)(addr) = value;
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_set_region_8 */
-#define bus_space_set_region_8 !!! bus_space_set_region_8 unimplemented !!!
-#endif
-
-/*
- * Copy `count' 1, 2, 4, or 8 byte values from bus space starting
- * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2.
- */
-
-static __inline void bus_space_copy_region_1(bus_space_tag_t tag,
- bus_space_handle_t bsh1,
- bus_size_t off1,
- bus_space_handle_t bsh2,
- bus_size_t off2, size_t count);
-
-static __inline void bus_space_copy_region_2(bus_space_tag_t tag,
- bus_space_handle_t bsh1,
- bus_size_t off1,
- bus_space_handle_t bsh2,
- bus_size_t off2, size_t count);
-
-static __inline void bus_space_copy_region_4(bus_space_tag_t tag,
- bus_space_handle_t bsh1,
- bus_size_t off1,
- bus_space_handle_t bsh2,
- bus_size_t off2, size_t count);
-
-static __inline void
-bus_space_copy_region_1(bus_space_tag_t tag, bus_space_handle_t bsh1,
- bus_size_t off1, bus_space_handle_t bsh2,
- bus_size_t off2, size_t count)
-{
- bus_addr_t addr1 = bsh1 + off1;
- bus_addr_t addr2 = bsh2 + off2;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1++, addr2++)
- outb(addr2, inb(addr1));
- } else {
- /* dest after src: copy backwards */
- for (addr1 += (count - 1), addr2 += (count - 1);
- count != 0; count--, addr1--, addr2--)
- outb(addr2, inb(addr1));
- }
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1++, addr2++)
- *(volatile u_int8_t *)(addr2) =
- *(volatile u_int8_t *)(addr1);
- } else {
- /* dest after src: copy backwards */
- for (addr1 += (count - 1), addr2 += (count - 1);
- count != 0; count--, addr1--, addr2--)
- *(volatile u_int8_t *)(addr2) =
- *(volatile u_int8_t *)(addr1);
- }
- }
-#endif
-}
-
-static __inline void
-bus_space_copy_region_2(bus_space_tag_t tag, bus_space_handle_t bsh1,
- bus_size_t off1, bus_space_handle_t bsh2,
- bus_size_t off2, size_t count)
-{
- bus_addr_t addr1 = bsh1 + off1;
- bus_addr_t addr2 = bsh2 + off2;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1 += 2, addr2 += 2)
- outw(addr2, inw(addr1));
- } else {
- /* dest after src: copy backwards */
- for (addr1 += 2 * (count - 1), addr2 += 2 * (count - 1);
- count != 0; count--, addr1 -= 2, addr2 -= 2)
- outw(addr2, inw(addr1));
- }
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1 += 2, addr2 += 2)
- *(volatile u_int16_t *)(addr2) =
- *(volatile u_int16_t *)(addr1);
- } else {
- /* dest after src: copy backwards */
- for (addr1 += 2 * (count - 1), addr2 += 2 * (count - 1);
- count != 0; count--, addr1 -= 2, addr2 -= 2)
- *(volatile u_int16_t *)(addr2) =
- *(volatile u_int16_t *)(addr1);
- }
- }
-#endif
-}
-
-static __inline void
-bus_space_copy_region_4(bus_space_tag_t tag, bus_space_handle_t bsh1,
- bus_size_t off1, bus_space_handle_t bsh2,
- bus_size_t off2, size_t count)
-{
- bus_addr_t addr1 = bsh1 + off1;
- bus_addr_t addr2 = bsh2 + off2;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1 += 4, addr2 += 4)
- outl(addr2, inl(addr1));
- } else {
- /* dest after src: copy backwards */
- for (addr1 += 4 * (count - 1), addr2 += 4 * (count - 1);
- count != 0; count--, addr1 -= 4, addr2 -= 4)
- outl(addr2, inl(addr1));
- }
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1 += 4, addr2 += 4)
- *(volatile u_int32_t *)(addr2) =
- *(volatile u_int32_t *)(addr1);
- } else {
- /* dest after src: copy backwards */
- for (addr1 += 4 * (count - 1), addr2 += 4 * (count - 1);
- count != 0; count--, addr1 -= 4, addr2 -= 4)
- *(volatile u_int32_t *)(addr2) =
- *(volatile u_int32_t *)(addr1);
- }
- }
-#endif
-}
-
-#endif /* defined(_I386_BUS_PIO_H_) || defined(_I386_MEM_IO_H_) */
-
-#if 0 /* Cause a link error for bus_space_copy_8 */
-#define bus_space_copy_region_8 !!! bus_space_copy_region_8 unimplemented !!!
-#endif
-
-/*
- * Bus read/write barrier methods.
- *
- * void bus_space_barrier(bus_space_tag_t tag, bus_space_handle_t bsh,
- * bus_size_t offset, bus_size_t len, int flags);
- *
- * Note: the i386 does not currently require barriers, but we must
- * provide the flags to MI code.
- */
-#define bus_space_barrier(t, h, o, l, f) \
- ((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f)))
-#define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */
-#define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */
-
-/*
- * Flags used in various bus DMA methods.
- */
-#define BUS_DMA_WAITOK 0x00 /* safe to sleep (pseudo-flag) */
-#define BUS_DMA_NOWAIT 0x01 /* not safe to sleep */
-#define BUS_DMA_ALLOCNOW 0x02 /* perform resource allocation now */
-#define BUS_DMAMEM_NOSYNC 0x04 /* map memory to not require sync */
-#define BUS_DMA_BUS1 0x10 /* placeholders for bus functions... */
-#define BUS_DMA_BUS2 0x20
-#define BUS_DMA_BUS3 0x40
-#define BUS_DMA_BUS4 0x80
-
-/* Forwards needed by prototypes below. */
-struct mbuf;
-struct uio;
-
-/*
- * bus_dmasync_op_t
- *
- * Operations performed by bus_dmamap_sync().
- */
-typedef enum {
- BUS_DMASYNC_PREREAD,
- BUS_DMASYNC_POSTREAD,
- BUS_DMASYNC_PREWRITE,
- BUS_DMASYNC_POSTWRITE
-} bus_dmasync_op_t;
-
-/*
- * bus_dma_tag_t
- *
- * A machine-dependent opaque type describing the characteristics
- * of how to perform DMA mappings. This structure encapsultes
- * information concerning address and alignment restrictions, number
- * of S/G segments, amount of data per S/G segment, etc.
- */
-typedef struct bus_dma_tag *bus_dma_tag_t;
-
-/*
- * bus_dmamap_t
- *
- * DMA mapping instance information.
- */
-typedef struct bus_dmamap *bus_dmamap_t;
-
-/*
- * bus_dma_segment_t
- *
- * Describes a single contiguous DMA transaction. Values
- * are suitable for programming into DMA registers.
- */
-typedef struct bus_dma_segment {
- bus_addr_t ds_addr; /* DMA address */
- bus_size_t ds_len; /* length of transfer */
-} bus_dma_segment_t;
-
-/*
- * A function that returns 1 if the address cannot be accessed by
- * a device and 0 if it can be.
- */
-typedef int bus_dma_filter_t(void *, bus_addr_t);
-
-/*
- * Allocate a device specific dma_tag encapsulating the constraints of
- * the parent tag in addition to other restrictions specified:
- *
- * alignment: alignment for segments.
- * boundary: Boundary that segments cannot cross.
- * lowaddr: Low restricted address that cannot appear in a mapping.
- * highaddr: High restricted address that cannot appear in a mapping.
- * filtfunc: An optional function to further test if an address
- * within the range of lowaddr and highaddr cannot appear
- * in a mapping.
- * filtfuncarg: An argument that will be passed to filtfunc in addition
- * to the address to test.
- * maxsize: Maximum mapping size supported by this tag.
- * nsegments: Number of discontinuities allowed in maps.
- * maxsegsz: Maximum size of a segment in the map.
- * flags: Bus DMA flags.
- * dmat: A pointer to set to a valid dma tag should the return
- * value of this function indicate success.
- */
-/* XXX Should probably allow specification of alignment */
-int bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignemnt,
- bus_size_t boundary, bus_addr_t lowaddr,
- bus_addr_t highaddr, bus_dma_filter_t *filtfunc,
- void *filtfuncarg, bus_size_t maxsize, int nsegments,
- bus_size_t maxsegsz, int flags, bus_dma_tag_t *dmat);
-
-int bus_dma_tag_destroy(bus_dma_tag_t dmat);
-
-/*
- * Allocate a handle for mapping from kva/uva/physical
- * address space into bus device space.
- */
-int bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp);
-
-/*
- * Destroy a handle for mapping from kva/uva/physical
- * address space into bus device space.
- */
-int bus_dmamap_destroy(bus_dma_tag_t dmat, bus_dmamap_t map);
-
-/*
- * Allocate a piece of memory that can be efficiently mapped into
- * bus device space based on the constraints lited in the dma tag.
- * A dmamap to for use with dmamap_load is also allocated.
- */
-int bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
- bus_dmamap_t *mapp);
-
-/*
- * Free a piece of memory and it's allociated dmamap, that was allocated
- * via bus_dmamem_alloc.
- */
-void bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map);
-
-/*
- * A function that processes a successfully loaded dma map or an error
- * from a delayed load map.
- */
-typedef void bus_dmamap_callback_t(void *, bus_dma_segment_t *, int, int);
-
-/*
- * Map the buffer buf into bus space using the dmamap map.
- */
-int bus_dmamap_load(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf,
- bus_size_t buflen, bus_dmamap_callback_t *callback,
- void *callback_arg, int flags);
-
-/*
- * Perform a syncronization operation on the given map.
- */
-void _bus_dmamap_sync(bus_dma_tag_t, bus_dmamap_t, bus_dmasync_op_t);
-#define bus_dmamap_sync(dmat, dmamap, op) \
- if ((dmamap) != NULL) \
- _bus_dmamap_sync(dmat, dmamap, op)
-
-/*
- * Release the mapping held by map.
- */
-void _bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map);
-#define bus_dmamap_unload(dmat, dmamap) \
- if ((dmamap) != NULL) \
- _bus_dmamap_unload(dmat, dmamap)
-
-#endif /* _I386_BUS_H_ */
diff --git a/sys/amd64/include/bus_at386.h b/sys/amd64/include/bus_at386.h
deleted file mode 100644
index 661761271085..000000000000
--- a/sys/amd64/include/bus_at386.h
+++ /dev/null
@@ -1,1291 +0,0 @@
-/* $NetBSD: bus.h,v 1.12 1997/10/01 08:25:15 fvdl Exp $ */
-
-/*-
- * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
- * NASA Ames Research Center.
- *
- * 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 the NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Copyright (c) 1996 Charles M. Hannum. All rights reserved.
- * Copyright (c) 1996 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
- * for the NetBSD Project.
- * 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.
- */
-/* $FreeBSD$ */
-
-#ifndef _I386_BUS_H_
-#define _I386_BUS_H_
-
-#include <machine/cpufunc.h>
-
-/*
- * To remain compatible with NetBSD's interface, default to both memio and
- * pio when neither of them is defined.
- */
-#if !defined(_I386_BUS_PIO_H_) && !defined(_I386_BUS_MEMIO_H_)
-#define _I386_BUS_PIO_H_
-#define _I386_BUS_MEMIO_H_
-#endif
-
-/*
- * Values for the i386 bus space tag, not to be used directly by MI code.
- */
-#define I386_BUS_SPACE_IO 0 /* space is i/o space */
-#define I386_BUS_SPACE_MEM 1 /* space is mem space */
-
-/*
- * Bus address and size types
- */
-typedef u_int bus_addr_t;
-typedef u_int bus_size_t;
-
-#define BUS_SPACE_MAXSIZE_24BIT 0xFFFFFF
-#define BUS_SPACE_MAXSIZE_32BIT 0xFFFFFFFF
-#define BUS_SPACE_MAXSIZE (64 * 1024) /* Maximum supported size */
-#define BUS_SPACE_MAXADDR_24BIT 0xFFFFFF
-#define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFF
-#define BUS_SPACE_MAXADDR 0xFFFFFFFF
-
-#define BUS_SPACE_UNRESTRICTED (~0)
-
-/*
- * Access methods for bus resources and address space.
- */
-typedef int bus_space_tag_t;
-typedef u_int bus_space_handle_t;
-
-/*
- * Map a region of device bus space into CPU virtual address space.
- */
-
-#define BUS_SPACE_MAP_CACHEABLE 0x01
-#define BUS_SPACE_MAP_LINEAR 0x02
-
-int bus_space_map(bus_space_tag_t t, bus_addr_t addr, bus_size_t size,
- int flags, bus_space_handle_t *bshp);
-
-/*
- * Unmap a region of device bus space.
- */
-
-void bus_space_unmap(bus_space_tag_t t, bus_space_handle_t bsh,
- bus_size_t size);
-
-/*
- * Get a new handle for a subregion of an already-mapped area of bus space.
- */
-
-int bus_space_subregion(bus_space_tag_t t, bus_space_handle_t bsh,
- bus_size_t offset, bus_size_t size,
- bus_space_handle_t *nbshp);
-
-/*
- * Allocate a region of memory that is accessible to devices in bus space.
- */
-
-int bus_space_alloc(bus_space_tag_t t, 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);
-
-/*
- * Free a region of bus space accessible memory.
- */
-
-void bus_space_free(bus_space_tag_t t, bus_space_handle_t bsh,
- bus_size_t size);
-
-#if defined(_I386_BUS_PIO_H_) || defined(_I386_BUS_MEMIO_H_)
-
-/*
- * Read a 1, 2, 4, or 8 byte quantity from bus space
- * described by tag/handle/offset.
- */
-static __inline u_int8_t bus_space_read_1(bus_space_tag_t tag,
- bus_space_handle_t handle,
- bus_size_t offset);
-
-static __inline u_int16_t bus_space_read_2(bus_space_tag_t tag,
- bus_space_handle_t handle,
- bus_size_t offset);
-
-static __inline u_int32_t bus_space_read_4(bus_space_tag_t tag,
- bus_space_handle_t handle,
- bus_size_t offset);
-
-static __inline u_int8_t
-bus_space_read_1(bus_space_tag_t tag, bus_space_handle_t handle,
- bus_size_t offset)
-{
-#if defined (_I386_BUS_PIO_H_)
-#if defined (_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- return (inb(handle + offset));
-#endif
-#if defined (_I386_BUS_MEMIO_H_)
- return (*(volatile u_int8_t *)(handle + offset));
-#endif
-}
-
-static __inline u_int16_t
-bus_space_read_2(bus_space_tag_t tag, bus_space_handle_t handle,
- bus_size_t offset)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- return (inw(handle + offset));
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
- return (*(volatile u_int16_t *)(handle + offset));
-#endif
-}
-
-static __inline u_int32_t
-bus_space_read_4(bus_space_tag_t tag, bus_space_handle_t handle,
- bus_size_t offset)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- return (inl(handle + offset));
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
- return (*(volatile u_int32_t *)(handle + offset));
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_read_8 */
-#define bus_space_read_8(t, h, o) !!! bus_space_read_8 unimplemented !!!
-#endif
-
-/*
- * Read `count' 1, 2, 4, or 8 byte quantities from bus space
- * described by tag/handle/offset and copy into buffer provided.
- */
-static __inline void bus_space_read_multi_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t *addr,
- size_t count);
-
-static __inline void bus_space_read_multi_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t *addr,
- size_t count);
-
-static __inline void bus_space_read_multi_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t *addr,
- size_t count);
-
-static __inline void
-bus_space_read_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- insb(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: movb (%2),%%al \n\
- stosb \n\
- loop 1b" :
- "=D" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory");
- }
-#endif
-}
-
-static __inline void
-bus_space_read_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- insw(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: movw (%2),%%ax \n\
- stosw \n\
- loop 1b" :
- "=D" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory");
- }
-#endif
-}
-
-static __inline void
-bus_space_read_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- insl(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: movl (%2),%%eax \n\
- stosl \n\
- loop 1b" :
- "=D" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory");
- }
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_read_multi_8 */
-#define bus_space_read_multi_8 !!! bus_space_read_multi_8 unimplemented !!!
-#endif
-
-/*
- * Read `count' 1, 2, 4, or 8 byte quantities from bus space
- * described by tag/handle and starting at `offset' and copy into
- * buffer provided.
- */
-static __inline void bus_space_read_region_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t *addr,
- size_t count);
-
-static __inline void bus_space_read_region_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t *addr,
- size_t count);
-
-static __inline void bus_space_read_region_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t *addr,
- size_t count);
-
-
-static __inline void
-bus_space_read_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: inb %w2,%%al \n\
- stosb \n\
- incl %2 \n\
- loop 1b" :
- "=D" (addr), "=c" (count), "=d" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsb" :
- "=D" (addr), "=c" (count), "=S" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_read_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: inw %w2,%%ax \n\
- stosw \n\
- addl $2,%2 \n\
- loop 1b" :
- "=D" (addr), "=c" (count), "=d" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsw" :
- "=D" (addr), "=c" (count), "=S" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_read_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: inl %w2,%%eax \n\
- stosl \n\
- addl $4,%2 \n\
- loop 1b" :
- "=D" (addr), "=c" (count), "=d" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsl" :
- "=D" (addr), "=c" (count), "=S" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "memory", "cc");
- }
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_read_region_8 */
-#define bus_space_read_region_8 !!! bus_space_read_region_8 unimplemented !!!
-#endif
-
-/*
- * Write the 1, 2, 4, or 8 byte value `value' to bus space
- * described by tag/handle/offset.
- */
-
-static __inline void bus_space_write_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t value);
-
-static __inline void bus_space_write_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t value);
-
-static __inline void bus_space_write_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t value);
-
-static __inline void
-bus_space_write_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t value)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outb(bsh + offset, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- *(volatile u_int8_t *)(bsh + offset) = value;
-#endif
-}
-
-static __inline void
-bus_space_write_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t value)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outw(bsh + offset, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- *(volatile u_int16_t *)(bsh + offset) = value;
-#endif
-}
-
-static __inline void
-bus_space_write_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t value)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outl(bsh + offset, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- *(volatile u_int32_t *)(bsh + offset) = value;
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_write_8 */
-#define bus_space_write_8 !!! bus_space_write_8 not implemented !!!
-#endif
-
-/*
- * Write `count' 1, 2, 4, or 8 byte quantities from the buffer
- * provided to bus space described by tag/handle/offset.
- */
-
-static __inline void bus_space_write_multi_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int8_t *addr,
- size_t count);
-static __inline void bus_space_write_multi_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int16_t *addr,
- size_t count);
-
-static __inline void bus_space_write_multi_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int32_t *addr,
- size_t count);
-
-static __inline void
-bus_space_write_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int8_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outsb(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: lodsb \n\
- movb %%al,(%2) \n\
- loop 1b" :
- "=S" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_write_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int16_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outsw(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: lodsw \n\
- movw %%ax,(%1) \n\
- movw %%ax,(%2) \n\
- loop 1b" :
- "=S" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_write_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int32_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outsl(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: lodsl \n\
- movl %%eax,(%2) \n\
- loop 1b" :
- "=S" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_write_multi_8 */
-#define bus_space_write_multi_8(t, h, o, a, c) \
- !!! bus_space_write_multi_8 unimplemented !!!
-#endif
-
-/*
- * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided
- * to bus space described by tag/handle starting at `offset'.
- */
-
-static __inline void bus_space_write_region_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int8_t *addr,
- size_t count);
-static __inline void bus_space_write_region_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int16_t *addr,
- size_t count);
-static __inline void bus_space_write_region_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int32_t *addr,
- size_t count);
-
-static __inline void
-bus_space_write_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int8_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: lodsb \n\
- outb %%al,%w0 \n\
- incl %0 \n\
- loop 1b" :
- "=d" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsb" :
- "=D" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_write_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int16_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: lodsw \n\
- outw %%ax,%w0 \n\
- addl $2,%0 \n\
- loop 1b" :
- "=d" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsw" :
- "=D" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_write_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int32_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: lodsl \n\
- outl %%eax,%w0 \n\
- addl $4,%0 \n\
- loop 1b" :
- "=d" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsl" :
- "=D" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "memory", "cc");
- }
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_write_region_8 */
-#define bus_space_write_region_8 \
- !!! bus_space_write_region_8 unimplemented !!!
-#endif
-
-/*
- * Write the 1, 2, 4, or 8 byte value `val' to bus space described
- * by tag/handle/offset `count' times.
- */
-
-static __inline void bus_space_set_multi_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- u_int8_t value, size_t count);
-static __inline void bus_space_set_multi_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- u_int16_t value, size_t count);
-static __inline void bus_space_set_multi_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- u_int32_t value, size_t count);
-
-static __inline void
-bus_space_set_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- while (count--)
- outb(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- while (count--)
- *(volatile u_int8_t *)(addr) = value;
-#endif
-}
-
-static __inline void
-bus_space_set_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- while (count--)
- outw(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- while (count--)
- *(volatile u_int16_t *)(addr) = value;
-#endif
-}
-
-static __inline void
-bus_space_set_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- while (count--)
- outl(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- while (count--)
- *(volatile u_int32_t *)(addr) = value;
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_set_multi_8 */
-#define bus_space_set_multi_8 !!! bus_space_set_multi_8 unimplemented !!!
-#endif
-
-/*
- * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described
- * by tag/handle starting at `offset'.
- */
-
-static __inline void bus_space_set_region_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t value,
- size_t count);
-static __inline void bus_space_set_region_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t value,
- size_t count);
-static __inline void bus_space_set_region_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t value,
- size_t count);
-
-static __inline void
-bus_space_set_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- for (; count != 0; count--, addr++)
- outb(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- for (; count != 0; count--, addr++)
- *(volatile u_int8_t *)(addr) = value;
-#endif
-}
-
-static __inline void
-bus_space_set_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- for (; count != 0; count--, addr += 2)
- outw(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- for (; count != 0; count--, addr += 2)
- *(volatile u_int16_t *)(addr) = value;
-#endif
-}
-
-static __inline void
-bus_space_set_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- for (; count != 0; count--, addr += 4)
- outl(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- for (; count != 0; count--, addr += 4)
- *(volatile u_int32_t *)(addr) = value;
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_set_region_8 */
-#define bus_space_set_region_8 !!! bus_space_set_region_8 unimplemented !!!
-#endif
-
-/*
- * Copy `count' 1, 2, 4, or 8 byte values from bus space starting
- * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2.
- */
-
-static __inline void bus_space_copy_region_1(bus_space_tag_t tag,
- bus_space_handle_t bsh1,
- bus_size_t off1,
- bus_space_handle_t bsh2,
- bus_size_t off2, size_t count);
-
-static __inline void bus_space_copy_region_2(bus_space_tag_t tag,
- bus_space_handle_t bsh1,
- bus_size_t off1,
- bus_space_handle_t bsh2,
- bus_size_t off2, size_t count);
-
-static __inline void bus_space_copy_region_4(bus_space_tag_t tag,
- bus_space_handle_t bsh1,
- bus_size_t off1,
- bus_space_handle_t bsh2,
- bus_size_t off2, size_t count);
-
-static __inline void
-bus_space_copy_region_1(bus_space_tag_t tag, bus_space_handle_t bsh1,
- bus_size_t off1, bus_space_handle_t bsh2,
- bus_size_t off2, size_t count)
-{
- bus_addr_t addr1 = bsh1 + off1;
- bus_addr_t addr2 = bsh2 + off2;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1++, addr2++)
- outb(addr2, inb(addr1));
- } else {
- /* dest after src: copy backwards */
- for (addr1 += (count - 1), addr2 += (count - 1);
- count != 0; count--, addr1--, addr2--)
- outb(addr2, inb(addr1));
- }
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1++, addr2++)
- *(volatile u_int8_t *)(addr2) =
- *(volatile u_int8_t *)(addr1);
- } else {
- /* dest after src: copy backwards */
- for (addr1 += (count - 1), addr2 += (count - 1);
- count != 0; count--, addr1--, addr2--)
- *(volatile u_int8_t *)(addr2) =
- *(volatile u_int8_t *)(addr1);
- }
- }
-#endif
-}
-
-static __inline void
-bus_space_copy_region_2(bus_space_tag_t tag, bus_space_handle_t bsh1,
- bus_size_t off1, bus_space_handle_t bsh2,
- bus_size_t off2, size_t count)
-{
- bus_addr_t addr1 = bsh1 + off1;
- bus_addr_t addr2 = bsh2 + off2;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1 += 2, addr2 += 2)
- outw(addr2, inw(addr1));
- } else {
- /* dest after src: copy backwards */
- for (addr1 += 2 * (count - 1), addr2 += 2 * (count - 1);
- count != 0; count--, addr1 -= 2, addr2 -= 2)
- outw(addr2, inw(addr1));
- }
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1 += 2, addr2 += 2)
- *(volatile u_int16_t *)(addr2) =
- *(volatile u_int16_t *)(addr1);
- } else {
- /* dest after src: copy backwards */
- for (addr1 += 2 * (count - 1), addr2 += 2 * (count - 1);
- count != 0; count--, addr1 -= 2, addr2 -= 2)
- *(volatile u_int16_t *)(addr2) =
- *(volatile u_int16_t *)(addr1);
- }
- }
-#endif
-}
-
-static __inline void
-bus_space_copy_region_4(bus_space_tag_t tag, bus_space_handle_t bsh1,
- bus_size_t off1, bus_space_handle_t bsh2,
- bus_size_t off2, size_t count)
-{
- bus_addr_t addr1 = bsh1 + off1;
- bus_addr_t addr2 = bsh2 + off2;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1 += 4, addr2 += 4)
- outl(addr2, inl(addr1));
- } else {
- /* dest after src: copy backwards */
- for (addr1 += 4 * (count - 1), addr2 += 4 * (count - 1);
- count != 0; count--, addr1 -= 4, addr2 -= 4)
- outl(addr2, inl(addr1));
- }
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1 += 4, addr2 += 4)
- *(volatile u_int32_t *)(addr2) =
- *(volatile u_int32_t *)(addr1);
- } else {
- /* dest after src: copy backwards */
- for (addr1 += 4 * (count - 1), addr2 += 4 * (count - 1);
- count != 0; count--, addr1 -= 4, addr2 -= 4)
- *(volatile u_int32_t *)(addr2) =
- *(volatile u_int32_t *)(addr1);
- }
- }
-#endif
-}
-
-#endif /* defined(_I386_BUS_PIO_H_) || defined(_I386_MEM_IO_H_) */
-
-#if 0 /* Cause a link error for bus_space_copy_8 */
-#define bus_space_copy_region_8 !!! bus_space_copy_region_8 unimplemented !!!
-#endif
-
-/*
- * Bus read/write barrier methods.
- *
- * void bus_space_barrier(bus_space_tag_t tag, bus_space_handle_t bsh,
- * bus_size_t offset, bus_size_t len, int flags);
- *
- * Note: the i386 does not currently require barriers, but we must
- * provide the flags to MI code.
- */
-#define bus_space_barrier(t, h, o, l, f) \
- ((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f)))
-#define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */
-#define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */
-
-/*
- * Flags used in various bus DMA methods.
- */
-#define BUS_DMA_WAITOK 0x00 /* safe to sleep (pseudo-flag) */
-#define BUS_DMA_NOWAIT 0x01 /* not safe to sleep */
-#define BUS_DMA_ALLOCNOW 0x02 /* perform resource allocation now */
-#define BUS_DMAMEM_NOSYNC 0x04 /* map memory to not require sync */
-#define BUS_DMA_BUS1 0x10 /* placeholders for bus functions... */
-#define BUS_DMA_BUS2 0x20
-#define BUS_DMA_BUS3 0x40
-#define BUS_DMA_BUS4 0x80
-
-/* Forwards needed by prototypes below. */
-struct mbuf;
-struct uio;
-
-/*
- * bus_dmasync_op_t
- *
- * Operations performed by bus_dmamap_sync().
- */
-typedef enum {
- BUS_DMASYNC_PREREAD,
- BUS_DMASYNC_POSTREAD,
- BUS_DMASYNC_PREWRITE,
- BUS_DMASYNC_POSTWRITE
-} bus_dmasync_op_t;
-
-/*
- * bus_dma_tag_t
- *
- * A machine-dependent opaque type describing the characteristics
- * of how to perform DMA mappings. This structure encapsultes
- * information concerning address and alignment restrictions, number
- * of S/G segments, amount of data per S/G segment, etc.
- */
-typedef struct bus_dma_tag *bus_dma_tag_t;
-
-/*
- * bus_dmamap_t
- *
- * DMA mapping instance information.
- */
-typedef struct bus_dmamap *bus_dmamap_t;
-
-/*
- * bus_dma_segment_t
- *
- * Describes a single contiguous DMA transaction. Values
- * are suitable for programming into DMA registers.
- */
-typedef struct bus_dma_segment {
- bus_addr_t ds_addr; /* DMA address */
- bus_size_t ds_len; /* length of transfer */
-} bus_dma_segment_t;
-
-/*
- * A function that returns 1 if the address cannot be accessed by
- * a device and 0 if it can be.
- */
-typedef int bus_dma_filter_t(void *, bus_addr_t);
-
-/*
- * Allocate a device specific dma_tag encapsulating the constraints of
- * the parent tag in addition to other restrictions specified:
- *
- * alignment: alignment for segments.
- * boundary: Boundary that segments cannot cross.
- * lowaddr: Low restricted address that cannot appear in a mapping.
- * highaddr: High restricted address that cannot appear in a mapping.
- * filtfunc: An optional function to further test if an address
- * within the range of lowaddr and highaddr cannot appear
- * in a mapping.
- * filtfuncarg: An argument that will be passed to filtfunc in addition
- * to the address to test.
- * maxsize: Maximum mapping size supported by this tag.
- * nsegments: Number of discontinuities allowed in maps.
- * maxsegsz: Maximum size of a segment in the map.
- * flags: Bus DMA flags.
- * dmat: A pointer to set to a valid dma tag should the return
- * value of this function indicate success.
- */
-/* XXX Should probably allow specification of alignment */
-int bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignemnt,
- bus_size_t boundary, bus_addr_t lowaddr,
- bus_addr_t highaddr, bus_dma_filter_t *filtfunc,
- void *filtfuncarg, bus_size_t maxsize, int nsegments,
- bus_size_t maxsegsz, int flags, bus_dma_tag_t *dmat);
-
-int bus_dma_tag_destroy(bus_dma_tag_t dmat);
-
-/*
- * Allocate a handle for mapping from kva/uva/physical
- * address space into bus device space.
- */
-int bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp);
-
-/*
- * Destroy a handle for mapping from kva/uva/physical
- * address space into bus device space.
- */
-int bus_dmamap_destroy(bus_dma_tag_t dmat, bus_dmamap_t map);
-
-/*
- * Allocate a piece of memory that can be efficiently mapped into
- * bus device space based on the constraints lited in the dma tag.
- * A dmamap to for use with dmamap_load is also allocated.
- */
-int bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
- bus_dmamap_t *mapp);
-
-/*
- * Free a piece of memory and it's allociated dmamap, that was allocated
- * via bus_dmamem_alloc.
- */
-void bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map);
-
-/*
- * A function that processes a successfully loaded dma map or an error
- * from a delayed load map.
- */
-typedef void bus_dmamap_callback_t(void *, bus_dma_segment_t *, int, int);
-
-/*
- * Map the buffer buf into bus space using the dmamap map.
- */
-int bus_dmamap_load(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf,
- bus_size_t buflen, bus_dmamap_callback_t *callback,
- void *callback_arg, int flags);
-
-/*
- * Perform a syncronization operation on the given map.
- */
-void _bus_dmamap_sync(bus_dma_tag_t, bus_dmamap_t, bus_dmasync_op_t);
-#define bus_dmamap_sync(dmat, dmamap, op) \
- if ((dmamap) != NULL) \
- _bus_dmamap_sync(dmat, dmamap, op)
-
-/*
- * Release the mapping held by map.
- */
-void _bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map);
-#define bus_dmamap_unload(dmat, dmamap) \
- if ((dmamap) != NULL) \
- _bus_dmamap_unload(dmat, dmamap)
-
-#endif /* _I386_BUS_H_ */
diff --git a/sys/amd64/include/bus_dma.h b/sys/amd64/include/bus_dma.h
deleted file mode 100644
index 661761271085..000000000000
--- a/sys/amd64/include/bus_dma.h
+++ /dev/null
@@ -1,1291 +0,0 @@
-/* $NetBSD: bus.h,v 1.12 1997/10/01 08:25:15 fvdl Exp $ */
-
-/*-
- * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
- * NASA Ames Research Center.
- *
- * 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 the NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Copyright (c) 1996 Charles M. Hannum. All rights reserved.
- * Copyright (c) 1996 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
- * for the NetBSD Project.
- * 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.
- */
-/* $FreeBSD$ */
-
-#ifndef _I386_BUS_H_
-#define _I386_BUS_H_
-
-#include <machine/cpufunc.h>
-
-/*
- * To remain compatible with NetBSD's interface, default to both memio and
- * pio when neither of them is defined.
- */
-#if !defined(_I386_BUS_PIO_H_) && !defined(_I386_BUS_MEMIO_H_)
-#define _I386_BUS_PIO_H_
-#define _I386_BUS_MEMIO_H_
-#endif
-
-/*
- * Values for the i386 bus space tag, not to be used directly by MI code.
- */
-#define I386_BUS_SPACE_IO 0 /* space is i/o space */
-#define I386_BUS_SPACE_MEM 1 /* space is mem space */
-
-/*
- * Bus address and size types
- */
-typedef u_int bus_addr_t;
-typedef u_int bus_size_t;
-
-#define BUS_SPACE_MAXSIZE_24BIT 0xFFFFFF
-#define BUS_SPACE_MAXSIZE_32BIT 0xFFFFFFFF
-#define BUS_SPACE_MAXSIZE (64 * 1024) /* Maximum supported size */
-#define BUS_SPACE_MAXADDR_24BIT 0xFFFFFF
-#define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFF
-#define BUS_SPACE_MAXADDR 0xFFFFFFFF
-
-#define BUS_SPACE_UNRESTRICTED (~0)
-
-/*
- * Access methods for bus resources and address space.
- */
-typedef int bus_space_tag_t;
-typedef u_int bus_space_handle_t;
-
-/*
- * Map a region of device bus space into CPU virtual address space.
- */
-
-#define BUS_SPACE_MAP_CACHEABLE 0x01
-#define BUS_SPACE_MAP_LINEAR 0x02
-
-int bus_space_map(bus_space_tag_t t, bus_addr_t addr, bus_size_t size,
- int flags, bus_space_handle_t *bshp);
-
-/*
- * Unmap a region of device bus space.
- */
-
-void bus_space_unmap(bus_space_tag_t t, bus_space_handle_t bsh,
- bus_size_t size);
-
-/*
- * Get a new handle for a subregion of an already-mapped area of bus space.
- */
-
-int bus_space_subregion(bus_space_tag_t t, bus_space_handle_t bsh,
- bus_size_t offset, bus_size_t size,
- bus_space_handle_t *nbshp);
-
-/*
- * Allocate a region of memory that is accessible to devices in bus space.
- */
-
-int bus_space_alloc(bus_space_tag_t t, 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);
-
-/*
- * Free a region of bus space accessible memory.
- */
-
-void bus_space_free(bus_space_tag_t t, bus_space_handle_t bsh,
- bus_size_t size);
-
-#if defined(_I386_BUS_PIO_H_) || defined(_I386_BUS_MEMIO_H_)
-
-/*
- * Read a 1, 2, 4, or 8 byte quantity from bus space
- * described by tag/handle/offset.
- */
-static __inline u_int8_t bus_space_read_1(bus_space_tag_t tag,
- bus_space_handle_t handle,
- bus_size_t offset);
-
-static __inline u_int16_t bus_space_read_2(bus_space_tag_t tag,
- bus_space_handle_t handle,
- bus_size_t offset);
-
-static __inline u_int32_t bus_space_read_4(bus_space_tag_t tag,
- bus_space_handle_t handle,
- bus_size_t offset);
-
-static __inline u_int8_t
-bus_space_read_1(bus_space_tag_t tag, bus_space_handle_t handle,
- bus_size_t offset)
-{
-#if defined (_I386_BUS_PIO_H_)
-#if defined (_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- return (inb(handle + offset));
-#endif
-#if defined (_I386_BUS_MEMIO_H_)
- return (*(volatile u_int8_t *)(handle + offset));
-#endif
-}
-
-static __inline u_int16_t
-bus_space_read_2(bus_space_tag_t tag, bus_space_handle_t handle,
- bus_size_t offset)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- return (inw(handle + offset));
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
- return (*(volatile u_int16_t *)(handle + offset));
-#endif
-}
-
-static __inline u_int32_t
-bus_space_read_4(bus_space_tag_t tag, bus_space_handle_t handle,
- bus_size_t offset)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- return (inl(handle + offset));
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
- return (*(volatile u_int32_t *)(handle + offset));
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_read_8 */
-#define bus_space_read_8(t, h, o) !!! bus_space_read_8 unimplemented !!!
-#endif
-
-/*
- * Read `count' 1, 2, 4, or 8 byte quantities from bus space
- * described by tag/handle/offset and copy into buffer provided.
- */
-static __inline void bus_space_read_multi_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t *addr,
- size_t count);
-
-static __inline void bus_space_read_multi_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t *addr,
- size_t count);
-
-static __inline void bus_space_read_multi_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t *addr,
- size_t count);
-
-static __inline void
-bus_space_read_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- insb(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: movb (%2),%%al \n\
- stosb \n\
- loop 1b" :
- "=D" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory");
- }
-#endif
-}
-
-static __inline void
-bus_space_read_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- insw(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: movw (%2),%%ax \n\
- stosw \n\
- loop 1b" :
- "=D" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory");
- }
-#endif
-}
-
-static __inline void
-bus_space_read_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- insl(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: movl (%2),%%eax \n\
- stosl \n\
- loop 1b" :
- "=D" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory");
- }
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_read_multi_8 */
-#define bus_space_read_multi_8 !!! bus_space_read_multi_8 unimplemented !!!
-#endif
-
-/*
- * Read `count' 1, 2, 4, or 8 byte quantities from bus space
- * described by tag/handle and starting at `offset' and copy into
- * buffer provided.
- */
-static __inline void bus_space_read_region_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t *addr,
- size_t count);
-
-static __inline void bus_space_read_region_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t *addr,
- size_t count);
-
-static __inline void bus_space_read_region_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t *addr,
- size_t count);
-
-
-static __inline void
-bus_space_read_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: inb %w2,%%al \n\
- stosb \n\
- incl %2 \n\
- loop 1b" :
- "=D" (addr), "=c" (count), "=d" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsb" :
- "=D" (addr), "=c" (count), "=S" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_read_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: inw %w2,%%ax \n\
- stosw \n\
- addl $2,%2 \n\
- loop 1b" :
- "=D" (addr), "=c" (count), "=d" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsw" :
- "=D" (addr), "=c" (count), "=S" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_read_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: inl %w2,%%eax \n\
- stosl \n\
- addl $4,%2 \n\
- loop 1b" :
- "=D" (addr), "=c" (count), "=d" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsl" :
- "=D" (addr), "=c" (count), "=S" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "memory", "cc");
- }
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_read_region_8 */
-#define bus_space_read_region_8 !!! bus_space_read_region_8 unimplemented !!!
-#endif
-
-/*
- * Write the 1, 2, 4, or 8 byte value `value' to bus space
- * described by tag/handle/offset.
- */
-
-static __inline void bus_space_write_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t value);
-
-static __inline void bus_space_write_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t value);
-
-static __inline void bus_space_write_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t value);
-
-static __inline void
-bus_space_write_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t value)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outb(bsh + offset, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- *(volatile u_int8_t *)(bsh + offset) = value;
-#endif
-}
-
-static __inline void
-bus_space_write_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t value)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outw(bsh + offset, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- *(volatile u_int16_t *)(bsh + offset) = value;
-#endif
-}
-
-static __inline void
-bus_space_write_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t value)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outl(bsh + offset, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- *(volatile u_int32_t *)(bsh + offset) = value;
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_write_8 */
-#define bus_space_write_8 !!! bus_space_write_8 not implemented !!!
-#endif
-
-/*
- * Write `count' 1, 2, 4, or 8 byte quantities from the buffer
- * provided to bus space described by tag/handle/offset.
- */
-
-static __inline void bus_space_write_multi_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int8_t *addr,
- size_t count);
-static __inline void bus_space_write_multi_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int16_t *addr,
- size_t count);
-
-static __inline void bus_space_write_multi_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int32_t *addr,
- size_t count);
-
-static __inline void
-bus_space_write_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int8_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outsb(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: lodsb \n\
- movb %%al,(%2) \n\
- loop 1b" :
- "=S" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_write_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int16_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outsw(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: lodsw \n\
- movw %%ax,(%1) \n\
- movw %%ax,(%2) \n\
- loop 1b" :
- "=S" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_write_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int32_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outsl(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: lodsl \n\
- movl %%eax,(%2) \n\
- loop 1b" :
- "=S" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_write_multi_8 */
-#define bus_space_write_multi_8(t, h, o, a, c) \
- !!! bus_space_write_multi_8 unimplemented !!!
-#endif
-
-/*
- * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided
- * to bus space described by tag/handle starting at `offset'.
- */
-
-static __inline void bus_space_write_region_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int8_t *addr,
- size_t count);
-static __inline void bus_space_write_region_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int16_t *addr,
- size_t count);
-static __inline void bus_space_write_region_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int32_t *addr,
- size_t count);
-
-static __inline void
-bus_space_write_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int8_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: lodsb \n\
- outb %%al,%w0 \n\
- incl %0 \n\
- loop 1b" :
- "=d" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsb" :
- "=D" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_write_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int16_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: lodsw \n\
- outw %%ax,%w0 \n\
- addl $2,%0 \n\
- loop 1b" :
- "=d" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsw" :
- "=D" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_write_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int32_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: lodsl \n\
- outl %%eax,%w0 \n\
- addl $4,%0 \n\
- loop 1b" :
- "=d" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsl" :
- "=D" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "memory", "cc");
- }
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_write_region_8 */
-#define bus_space_write_region_8 \
- !!! bus_space_write_region_8 unimplemented !!!
-#endif
-
-/*
- * Write the 1, 2, 4, or 8 byte value `val' to bus space described
- * by tag/handle/offset `count' times.
- */
-
-static __inline void bus_space_set_multi_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- u_int8_t value, size_t count);
-static __inline void bus_space_set_multi_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- u_int16_t value, size_t count);
-static __inline void bus_space_set_multi_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- u_int32_t value, size_t count);
-
-static __inline void
-bus_space_set_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- while (count--)
- outb(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- while (count--)
- *(volatile u_int8_t *)(addr) = value;
-#endif
-}
-
-static __inline void
-bus_space_set_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- while (count--)
- outw(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- while (count--)
- *(volatile u_int16_t *)(addr) = value;
-#endif
-}
-
-static __inline void
-bus_space_set_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- while (count--)
- outl(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- while (count--)
- *(volatile u_int32_t *)(addr) = value;
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_set_multi_8 */
-#define bus_space_set_multi_8 !!! bus_space_set_multi_8 unimplemented !!!
-#endif
-
-/*
- * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described
- * by tag/handle starting at `offset'.
- */
-
-static __inline void bus_space_set_region_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t value,
- size_t count);
-static __inline void bus_space_set_region_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t value,
- size_t count);
-static __inline void bus_space_set_region_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t value,
- size_t count);
-
-static __inline void
-bus_space_set_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- for (; count != 0; count--, addr++)
- outb(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- for (; count != 0; count--, addr++)
- *(volatile u_int8_t *)(addr) = value;
-#endif
-}
-
-static __inline void
-bus_space_set_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- for (; count != 0; count--, addr += 2)
- outw(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- for (; count != 0; count--, addr += 2)
- *(volatile u_int16_t *)(addr) = value;
-#endif
-}
-
-static __inline void
-bus_space_set_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- for (; count != 0; count--, addr += 4)
- outl(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- for (; count != 0; count--, addr += 4)
- *(volatile u_int32_t *)(addr) = value;
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_set_region_8 */
-#define bus_space_set_region_8 !!! bus_space_set_region_8 unimplemented !!!
-#endif
-
-/*
- * Copy `count' 1, 2, 4, or 8 byte values from bus space starting
- * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2.
- */
-
-static __inline void bus_space_copy_region_1(bus_space_tag_t tag,
- bus_space_handle_t bsh1,
- bus_size_t off1,
- bus_space_handle_t bsh2,
- bus_size_t off2, size_t count);
-
-static __inline void bus_space_copy_region_2(bus_space_tag_t tag,
- bus_space_handle_t bsh1,
- bus_size_t off1,
- bus_space_handle_t bsh2,
- bus_size_t off2, size_t count);
-
-static __inline void bus_space_copy_region_4(bus_space_tag_t tag,
- bus_space_handle_t bsh1,
- bus_size_t off1,
- bus_space_handle_t bsh2,
- bus_size_t off2, size_t count);
-
-static __inline void
-bus_space_copy_region_1(bus_space_tag_t tag, bus_space_handle_t bsh1,
- bus_size_t off1, bus_space_handle_t bsh2,
- bus_size_t off2, size_t count)
-{
- bus_addr_t addr1 = bsh1 + off1;
- bus_addr_t addr2 = bsh2 + off2;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1++, addr2++)
- outb(addr2, inb(addr1));
- } else {
- /* dest after src: copy backwards */
- for (addr1 += (count - 1), addr2 += (count - 1);
- count != 0; count--, addr1--, addr2--)
- outb(addr2, inb(addr1));
- }
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1++, addr2++)
- *(volatile u_int8_t *)(addr2) =
- *(volatile u_int8_t *)(addr1);
- } else {
- /* dest after src: copy backwards */
- for (addr1 += (count - 1), addr2 += (count - 1);
- count != 0; count--, addr1--, addr2--)
- *(volatile u_int8_t *)(addr2) =
- *(volatile u_int8_t *)(addr1);
- }
- }
-#endif
-}
-
-static __inline void
-bus_space_copy_region_2(bus_space_tag_t tag, bus_space_handle_t bsh1,
- bus_size_t off1, bus_space_handle_t bsh2,
- bus_size_t off2, size_t count)
-{
- bus_addr_t addr1 = bsh1 + off1;
- bus_addr_t addr2 = bsh2 + off2;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1 += 2, addr2 += 2)
- outw(addr2, inw(addr1));
- } else {
- /* dest after src: copy backwards */
- for (addr1 += 2 * (count - 1), addr2 += 2 * (count - 1);
- count != 0; count--, addr1 -= 2, addr2 -= 2)
- outw(addr2, inw(addr1));
- }
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1 += 2, addr2 += 2)
- *(volatile u_int16_t *)(addr2) =
- *(volatile u_int16_t *)(addr1);
- } else {
- /* dest after src: copy backwards */
- for (addr1 += 2 * (count - 1), addr2 += 2 * (count - 1);
- count != 0; count--, addr1 -= 2, addr2 -= 2)
- *(volatile u_int16_t *)(addr2) =
- *(volatile u_int16_t *)(addr1);
- }
- }
-#endif
-}
-
-static __inline void
-bus_space_copy_region_4(bus_space_tag_t tag, bus_space_handle_t bsh1,
- bus_size_t off1, bus_space_handle_t bsh2,
- bus_size_t off2, size_t count)
-{
- bus_addr_t addr1 = bsh1 + off1;
- bus_addr_t addr2 = bsh2 + off2;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1 += 4, addr2 += 4)
- outl(addr2, inl(addr1));
- } else {
- /* dest after src: copy backwards */
- for (addr1 += 4 * (count - 1), addr2 += 4 * (count - 1);
- count != 0; count--, addr1 -= 4, addr2 -= 4)
- outl(addr2, inl(addr1));
- }
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1 += 4, addr2 += 4)
- *(volatile u_int32_t *)(addr2) =
- *(volatile u_int32_t *)(addr1);
- } else {
- /* dest after src: copy backwards */
- for (addr1 += 4 * (count - 1), addr2 += 4 * (count - 1);
- count != 0; count--, addr1 -= 4, addr2 -= 4)
- *(volatile u_int32_t *)(addr2) =
- *(volatile u_int32_t *)(addr1);
- }
- }
-#endif
-}
-
-#endif /* defined(_I386_BUS_PIO_H_) || defined(_I386_MEM_IO_H_) */
-
-#if 0 /* Cause a link error for bus_space_copy_8 */
-#define bus_space_copy_region_8 !!! bus_space_copy_region_8 unimplemented !!!
-#endif
-
-/*
- * Bus read/write barrier methods.
- *
- * void bus_space_barrier(bus_space_tag_t tag, bus_space_handle_t bsh,
- * bus_size_t offset, bus_size_t len, int flags);
- *
- * Note: the i386 does not currently require barriers, but we must
- * provide the flags to MI code.
- */
-#define bus_space_barrier(t, h, o, l, f) \
- ((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f)))
-#define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */
-#define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */
-
-/*
- * Flags used in various bus DMA methods.
- */
-#define BUS_DMA_WAITOK 0x00 /* safe to sleep (pseudo-flag) */
-#define BUS_DMA_NOWAIT 0x01 /* not safe to sleep */
-#define BUS_DMA_ALLOCNOW 0x02 /* perform resource allocation now */
-#define BUS_DMAMEM_NOSYNC 0x04 /* map memory to not require sync */
-#define BUS_DMA_BUS1 0x10 /* placeholders for bus functions... */
-#define BUS_DMA_BUS2 0x20
-#define BUS_DMA_BUS3 0x40
-#define BUS_DMA_BUS4 0x80
-
-/* Forwards needed by prototypes below. */
-struct mbuf;
-struct uio;
-
-/*
- * bus_dmasync_op_t
- *
- * Operations performed by bus_dmamap_sync().
- */
-typedef enum {
- BUS_DMASYNC_PREREAD,
- BUS_DMASYNC_POSTREAD,
- BUS_DMASYNC_PREWRITE,
- BUS_DMASYNC_POSTWRITE
-} bus_dmasync_op_t;
-
-/*
- * bus_dma_tag_t
- *
- * A machine-dependent opaque type describing the characteristics
- * of how to perform DMA mappings. This structure encapsultes
- * information concerning address and alignment restrictions, number
- * of S/G segments, amount of data per S/G segment, etc.
- */
-typedef struct bus_dma_tag *bus_dma_tag_t;
-
-/*
- * bus_dmamap_t
- *
- * DMA mapping instance information.
- */
-typedef struct bus_dmamap *bus_dmamap_t;
-
-/*
- * bus_dma_segment_t
- *
- * Describes a single contiguous DMA transaction. Values
- * are suitable for programming into DMA registers.
- */
-typedef struct bus_dma_segment {
- bus_addr_t ds_addr; /* DMA address */
- bus_size_t ds_len; /* length of transfer */
-} bus_dma_segment_t;
-
-/*
- * A function that returns 1 if the address cannot be accessed by
- * a device and 0 if it can be.
- */
-typedef int bus_dma_filter_t(void *, bus_addr_t);
-
-/*
- * Allocate a device specific dma_tag encapsulating the constraints of
- * the parent tag in addition to other restrictions specified:
- *
- * alignment: alignment for segments.
- * boundary: Boundary that segments cannot cross.
- * lowaddr: Low restricted address that cannot appear in a mapping.
- * highaddr: High restricted address that cannot appear in a mapping.
- * filtfunc: An optional function to further test if an address
- * within the range of lowaddr and highaddr cannot appear
- * in a mapping.
- * filtfuncarg: An argument that will be passed to filtfunc in addition
- * to the address to test.
- * maxsize: Maximum mapping size supported by this tag.
- * nsegments: Number of discontinuities allowed in maps.
- * maxsegsz: Maximum size of a segment in the map.
- * flags: Bus DMA flags.
- * dmat: A pointer to set to a valid dma tag should the return
- * value of this function indicate success.
- */
-/* XXX Should probably allow specification of alignment */
-int bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignemnt,
- bus_size_t boundary, bus_addr_t lowaddr,
- bus_addr_t highaddr, bus_dma_filter_t *filtfunc,
- void *filtfuncarg, bus_size_t maxsize, int nsegments,
- bus_size_t maxsegsz, int flags, bus_dma_tag_t *dmat);
-
-int bus_dma_tag_destroy(bus_dma_tag_t dmat);
-
-/*
- * Allocate a handle for mapping from kva/uva/physical
- * address space into bus device space.
- */
-int bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp);
-
-/*
- * Destroy a handle for mapping from kva/uva/physical
- * address space into bus device space.
- */
-int bus_dmamap_destroy(bus_dma_tag_t dmat, bus_dmamap_t map);
-
-/*
- * Allocate a piece of memory that can be efficiently mapped into
- * bus device space based on the constraints lited in the dma tag.
- * A dmamap to for use with dmamap_load is also allocated.
- */
-int bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
- bus_dmamap_t *mapp);
-
-/*
- * Free a piece of memory and it's allociated dmamap, that was allocated
- * via bus_dmamem_alloc.
- */
-void bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map);
-
-/*
- * A function that processes a successfully loaded dma map or an error
- * from a delayed load map.
- */
-typedef void bus_dmamap_callback_t(void *, bus_dma_segment_t *, int, int);
-
-/*
- * Map the buffer buf into bus space using the dmamap map.
- */
-int bus_dmamap_load(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf,
- bus_size_t buflen, bus_dmamap_callback_t *callback,
- void *callback_arg, int flags);
-
-/*
- * Perform a syncronization operation on the given map.
- */
-void _bus_dmamap_sync(bus_dma_tag_t, bus_dmamap_t, bus_dmasync_op_t);
-#define bus_dmamap_sync(dmat, dmamap, op) \
- if ((dmamap) != NULL) \
- _bus_dmamap_sync(dmat, dmamap, op)
-
-/*
- * Release the mapping held by map.
- */
-void _bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map);
-#define bus_dmamap_unload(dmat, dmamap) \
- if ((dmamap) != NULL) \
- _bus_dmamap_unload(dmat, dmamap)
-
-#endif /* _I386_BUS_H_ */
diff --git a/sys/amd64/include/bus_memio.h b/sys/amd64/include/bus_memio.h
deleted file mode 100644
index 3533a671fe8d..000000000000
--- a/sys/amd64/include/bus_memio.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 1997 Justin Gibbs.
- * 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,
- * without modification, immediately at the beginning of the file.
- * 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 BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _I386_BUS_MEMIO_H_
-#define _I386_BUS_MEMIO_H_
-#endif /* _I386_BUS_MEMIO_H_ */
diff --git a/sys/amd64/include/bus_pio.h b/sys/amd64/include/bus_pio.h
deleted file mode 100644
index 8742dd195e0b..000000000000
--- a/sys/amd64/include/bus_pio.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 1997 Justin Gibbs.
- * 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,
- * without modification, immediately at the beginning of the file.
- * 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 BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _I386_BUS_PIO_H_
-#define _I386_BUS_PIO_H_
-#endif /* _I386_BUS_PIO_H_ */
diff --git a/sys/amd64/include/clock.h b/sys/amd64/include/clock.h
deleted file mode 100644
index 3ce7adb2bd27..000000000000
--- a/sys/amd64/include/clock.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Kernel interface to machine-dependent clock driver.
- * Garrett Wollman, September 1994.
- * This file is in the public domain.
- *
- * $FreeBSD$
- */
-
-#ifndef _MACHINE_CLOCK_H_
-#define _MACHINE_CLOCK_H_
-
-#ifdef _KERNEL
-/*
- * i386 to clock driver interface.
- * XXX large parts of the driver and its interface are misplaced.
- */
-extern int adjkerntz;
-extern int disable_rtc_set;
-extern int statclock_disable;
-extern u_int timer_freq;
-extern int timer0_max_count;
-extern u_int tsc_freq;
-extern int tsc_is_broken;
-extern int wall_cmos_clock;
-#ifdef APIC_IO
-extern int apic_8254_intr;
-#endif
-
-/*
- * Driver to clock driver interface.
- */
-struct clockframe;
-
-void DELAY __P((int usec));
-int acquire_timer0 __P((int rate,
- void (*function)(struct clockframe *frame)));
-int acquire_timer2 __P((int mode));
-int release_timer0 __P((void));
-int release_timer2 __P((void));
-#ifndef PC98
-int rtcin __P((int val));
-#else
-int acquire_timer1 __P((int mode));
-int release_timer1 __P((void));
-#endif
-int sysbeep __P((int pitch, int period));
-void i8254_restore __P((void));
-
-#endif /* _KERNEL */
-
-#endif /* !_MACHINE_CLOCK_H_ */
diff --git a/sys/amd64/include/cpu.h b/sys/amd64/include/cpu.h
deleted file mode 100644
index 18049d0d681b..000000000000
--- a/sys/amd64/include/cpu.h
+++ /dev/null
@@ -1,139 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)cpu.h 5.4 (Berkeley) 5/9/91
- * $FreeBSD$
- */
-
-#ifndef _MACHINE_CPU_H_
-#define _MACHINE_CPU_H_
-
-/*
- * Definitions unique to i386 cpu support.
- */
-#include <machine/psl.h>
-#include <machine/frame.h>
-#include <machine/segments.h>
-
-/*
- * definitions of cpu-dependent requirements
- * referenced in generic code
- */
-#undef COPY_SIGCODE /* don't copy sigcode above user stack in exec */
-
-#define cpu_exec(p) /* nothing */
-#define cpu_swapin(p) /* nothing */
-#define cpu_setstack(p, ap) ((p)->p_md.md_regs[SP] = (ap))
-#define cpu_set_init_frame(p, fp) ((p)->p_md.md_regs = (fp))
-
-#define CLKF_USERMODE(framep) \
- ((ISPL((framep)->cf_cs) == SEL_UPL) || (framep->cf_eflags & PSL_VM))
-
-#define CLKF_INTR(framep) (intr_nesting_level >= 2)
-#if 0
-/*
- * XXX splsoftclock() is very broken and barely worth fixing. It doesn't
- * turn off the clock bit in imen or in the icu. (This is not a serious
- * problem at 100 Hz but it is serious at 16000 Hz for pcaudio. softclock()
- * can take more than 62.5 usec so clock interrupts are lost.) It doesn't
- * check for pending interrupts being unmasked. clkintr() and Xintr0()
- * assume that the ipl is high when hardclock() returns. Our SWI_CLOCK
- * handling is efficient enough that little is gained by calling
- * softclock() directly.
- */
-#define CLKF_BASEPRI(framep) ((framep)->cf_ppl == 0)
-#else
-#define CLKF_BASEPRI(framep) (0)
-#endif
-#define CLKF_PC(framep) ((framep)->cf_eip)
-
-/*
- * Preempt the current process if in interrupt from user mode,
- * or after the current trap/syscall if in system mode.
- */
-#define need_resched() do { want_resched = 1; aston(); } while (0)
-
-#define resched_wanted() want_resched
-
-/*
- * Arrange to handle pending profiling ticks before returning to user mode.
- *
- * XXX this is now poorly named and implemented. It used to handle only a
- * single tick and the P_OWEUPC flag served as a counter. Now there is a
- * counter in the proc table and flag isn't really necessary.
- */
-#define need_proftick(p) \
- do { (p)->p_flag |= P_OWEUPC; aston(); } while (0)
-
-/*
- * Notify the current process (p) that it has a signal pending,
- * process as soon as possible.
- */
-#define signotify(p) aston()
-
-#define aston() do { astpending = 1; } while (0)
-#define astoff()
-
-/*
- * CTL_MACHDEP definitions.
- */
-#define CPU_CONSDEV 1 /* dev_t: console terminal device */
-#define CPU_ADJKERNTZ 2 /* int: timezone offset (seconds) */
-#define CPU_DISRTCSET 3 /* int: disable resettodr() call */
-#define CPU_BOOTINFO 4 /* struct: bootinfo */
-#define CPU_WALLCLOCK 5 /* int: indicates wall CMOS clock */
-#define CPU_MAXID 6 /* number of valid machdep ids */
-
-#define CTL_MACHDEP_NAMES { \
- { 0, 0 }, \
- { "console_device", CTLTYPE_STRUCT }, \
- { "adjkerntz", CTLTYPE_INT }, \
- { "disable_rtc_set", CTLTYPE_INT }, \
- { "bootinfo", CTLTYPE_STRUCT }, \
- { "wall_cmos_clock", CTLTYPE_INT }, \
-}
-
-#ifdef _KERNEL
-extern int astpending;
-extern char btext[];
-extern char etext[];
-extern u_char intr_nesting_level;
-extern int want_resched; /* resched was called */
-
-void fork_trampoline __P((void));
-void fork_return __P((struct proc *, struct trapframe));
-#endif
-
-#endif /* !_MACHINE_CPU_H_ */
diff --git a/sys/amd64/include/cpufunc.h b/sys/amd64/include/cpufunc.h
deleted file mode 100644
index 9a4052fd41d1..000000000000
--- a/sys/amd64/include/cpufunc.h
+++ /dev/null
@@ -1,551 +0,0 @@
-/*-
- * Copyright (c) 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Functions to provide access to special i386 instructions.
- */
-
-#ifndef _MACHINE_CPUFUNC_H_
-#define _MACHINE_CPUFUNC_H_
-
-#define readb(va) (*(volatile u_int8_t *) (va))
-#define readw(va) (*(volatile u_int16_t *) (va))
-#define readl(va) (*(volatile u_int32_t *) (va))
-
-#define writeb(va, d) (*(volatile u_int8_t *) (va) = (d))
-#define writew(va, d) (*(volatile u_int16_t *) (va) = (d))
-#define writel(va, d) (*(volatile u_int32_t *) (va) = (d))
-
-#ifdef __GNUC__
-
-#ifdef SMP
-#include <machine/lock.h> /* XXX */
-#endif
-
-#ifdef SWTCH_OPTIM_STATS
-extern int tlb_flush_count; /* XXX */
-#endif
-
-static __inline void
-breakpoint(void)
-{
- __asm __volatile("int $3");
-}
-
-static __inline u_int
-bsfl(u_int mask)
-{
- u_int result;
-
- __asm __volatile("bsfl %0,%0" : "=r" (result) : "0" (mask));
- return (result);
-}
-
-static __inline u_int
-bsrl(u_int mask)
-{
- u_int result;
-
- __asm __volatile("bsrl %0,%0" : "=r" (result) : "0" (mask));
- return (result);
-}
-
-static __inline void
-disable_intr(void)
-{
- __asm __volatile("cli" : : : "memory");
-#ifdef SMP
- MPINTR_LOCK();
-#endif
-}
-
-static __inline void
-enable_intr(void)
-{
-#ifdef SMP
- MPINTR_UNLOCK();
-#endif
- __asm __volatile("sti");
-}
-
-#define HAVE_INLINE_FFS
-
-static __inline int
-ffs(int mask)
-{
- /*
- * Note that gcc-2's builtin ffs would be used if we didn't declare
- * this inline or turn off the builtin. The builtin is faster but
- * broken in gcc-2.4.5 and slower but working in gcc-2.5 and later
- * versions.
- */
- return (mask == 0 ? mask : bsfl((u_int)mask) + 1);
-}
-
-#define HAVE_INLINE_FLS
-
-static __inline int
-fls(int mask)
-{
- return (mask == 0 ? mask : bsrl((u_int)mask) + 1);
-}
-
-#if __GNUC__ < 2
-
-#define inb(port) inbv(port)
-#define outb(port, data) outbv(port, data)
-
-#else /* __GNUC >= 2 */
-
-/*
- * The following complications are to get around gcc not having a
- * constraint letter for the range 0..255. We still put "d" in the
- * constraint because "i" isn't a valid constraint when the port
- * isn't constant. This only matters for -O0 because otherwise
- * the non-working version gets optimized away.
- *
- * Use an expression-statement instead of a conditional expression
- * because gcc-2.6.0 would promote the operands of the conditional
- * and produce poor code for "if ((inb(var) & const1) == const2)".
- *
- * The unnecessary test `(port) < 0x10000' is to generate a warning if
- * the `port' has type u_short or smaller. Such types are pessimal.
- * This actually only works for signed types. The range check is
- * careful to avoid generating warnings.
- */
-#define inb(port) __extension__ ({ \
- u_char _data; \
- if (__builtin_constant_p(port) && ((port) & 0xffff) < 0x100 \
- && (port) < 0x10000) \
- _data = inbc(port); \
- else \
- _data = inbv(port); \
- _data; })
-
-#define outb(port, data) ( \
- __builtin_constant_p(port) && ((port) & 0xffff) < 0x100 \
- && (port) < 0x10000 \
- ? outbc(port, data) : outbv(port, data))
-
-static __inline u_char
-inbc(u_int port)
-{
- u_char data;
-
- __asm __volatile("inb %1,%0" : "=a" (data) : "id" ((u_short)(port)));
- return (data);
-}
-
-static __inline void
-outbc(u_int port, u_char data)
-{
- __asm __volatile("outb %0,%1" : : "a" (data), "id" ((u_short)(port)));
-}
-
-#endif /* __GNUC <= 2 */
-
-static __inline u_char
-inbv(u_int port)
-{
- u_char data;
- /*
- * We use %%dx and not %1 here because i/o is done at %dx and not at
- * %edx, while gcc generates inferior code (movw instead of movl)
- * if we tell it to load (u_short) port.
- */
- __asm __volatile("inb %%dx,%0" : "=a" (data) : "d" (port));
- return (data);
-}
-
-static __inline u_int
-inl(u_int port)
-{
- u_int data;
-
- __asm __volatile("inl %%dx,%0" : "=a" (data) : "d" (port));
- return (data);
-}
-
-static __inline void
-insb(u_int port, void *addr, size_t cnt)
-{
- __asm __volatile("cld; rep; insb"
- : "=D" (addr), "=c" (cnt)
- : "0" (addr), "1" (cnt), "d" (port)
- : "memory");
-}
-
-static __inline void
-insw(u_int port, void *addr, size_t cnt)
-{
- __asm __volatile("cld; rep; insw"
- : "=D" (addr), "=c" (cnt)
- : "0" (addr), "1" (cnt), "d" (port)
- : "memory");
-}
-
-static __inline void
-insl(u_int port, void *addr, size_t cnt)
-{
- __asm __volatile("cld; rep; insl"
- : "=D" (addr), "=c" (cnt)
- : "0" (addr), "1" (cnt), "d" (port)
- : "memory");
-}
-
-static __inline void
-invd(void)
-{
- __asm __volatile("invd");
-}
-
-#if defined(SMP) && defined(_KERNEL)
-
-/*
- * When using APIC IPI's, invlpg() is not simply the invlpg instruction
- * (this is a bug) and the inlining cost is prohibitive since the call
- * executes into the IPI transmission system.
- */
-void invlpg __P((u_int addr));
-void invltlb __P((void));
-
-static __inline void
-cpu_invlpg(void *addr)
-{
- __asm __volatile("invlpg %0" : : "m" (*(char *)addr) : "memory");
-}
-
-static __inline void
-cpu_invltlb(void)
-{
- u_int temp;
- /*
- * This should be implemented as load_cr3(rcr3()) when load_cr3()
- * is inlined.
- */
- __asm __volatile("movl %%cr3, %0; movl %0, %%cr3" : "=r" (temp)
- : : "memory");
-#if defined(SWTCH_OPTIM_STATS)
- ++tlb_flush_count;
-#endif
-}
-
-#else /* !(SMP && _KERNEL) */
-
-static __inline void
-invlpg(u_int addr)
-{
- __asm __volatile("invlpg %0" : : "m" (*(char *)addr) : "memory");
-}
-
-static __inline void
-invltlb(void)
-{
- u_int temp;
- /*
- * This should be implemented as load_cr3(rcr3()) when load_cr3()
- * is inlined.
- */
- __asm __volatile("movl %%cr3, %0; movl %0, %%cr3" : "=r" (temp)
- : : "memory");
-#ifdef SWTCH_OPTIM_STATS
- ++tlb_flush_count;
-#endif
-}
-
-#endif /* SMP && _KERNEL */
-
-static __inline u_short
-inw(u_int port)
-{
- u_short data;
-
- __asm __volatile("inw %%dx,%0" : "=a" (data) : "d" (port));
- return (data);
-}
-
-static __inline u_int
-loadandclear(volatile u_int *addr)
-{
- u_int result;
-
- __asm __volatile("xorl %0,%0; xchgl %1,%0"
- : "=&r" (result) : "m" (*addr));
- return (result);
-}
-
-static __inline void
-outbv(u_int port, u_char data)
-{
- u_char al;
- /*
- * Use an unnecessary assignment to help gcc's register allocator.
- * This make a large difference for gcc-1.40 and a tiny difference
- * for gcc-2.6.0. For gcc-1.40, al had to be ``asm("ax")'' for
- * best results. gcc-2.6.0 can't handle this.
- */
- al = data;
- __asm __volatile("outb %0,%%dx" : : "a" (al), "d" (port));
-}
-
-static __inline void
-outl(u_int port, u_int data)
-{
- /*
- * outl() and outw() aren't used much so we haven't looked at
- * possible micro-optimizations such as the unnecessary
- * assignment for them.
- */
- __asm __volatile("outl %0,%%dx" : : "a" (data), "d" (port));
-}
-
-static __inline void
-outsb(u_int port, const void *addr, size_t cnt)
-{
- __asm __volatile("cld; rep; outsb"
- : "=S" (addr), "=c" (cnt)
- : "0" (addr), "1" (cnt), "d" (port));
-}
-
-static __inline void
-outsw(u_int port, const void *addr, size_t cnt)
-{
- __asm __volatile("cld; rep; outsw"
- : "=S" (addr), "=c" (cnt)
- : "0" (addr), "1" (cnt), "d" (port));
-}
-
-static __inline void
-outsl(u_int port, const void *addr, size_t cnt)
-{
- __asm __volatile("cld; rep; outsl"
- : "=S" (addr), "=c" (cnt)
- : "0" (addr), "1" (cnt), "d" (port));
-}
-
-static __inline void
-outw(u_int port, u_short data)
-{
- __asm __volatile("outw %0,%%dx" : : "a" (data), "d" (port));
-}
-
-static __inline u_int
-rcr2(void)
-{
- u_int data;
-
- __asm __volatile("movl %%cr2,%0" : "=r" (data));
- return (data);
-}
-
-static __inline u_int
-read_eflags(void)
-{
- u_int ef;
-
- __asm __volatile("pushfl; popl %0" : "=r" (ef));
- return (ef);
-}
-
-static __inline u_int64_t
-rdmsr(u_int msr)
-{
- u_int64_t rv;
-
- __asm __volatile(".byte 0x0f, 0x32" : "=A" (rv) : "c" (msr));
- return (rv);
-}
-
-static __inline u_int64_t
-rdpmc(u_int pmc)
-{
- u_int64_t rv;
-
- __asm __volatile(".byte 0x0f, 0x33" : "=A" (rv) : "c" (pmc));
- return (rv);
-}
-
-static __inline u_int64_t
-rdtsc(void)
-{
- u_int64_t rv;
-
- __asm __volatile(".byte 0x0f, 0x31" : "=A" (rv));
- return (rv);
-}
-
-static __inline void
-wbinvd(void)
-{
- __asm __volatile("wbinvd");
-}
-
-static __inline void
-write_eflags(u_int ef)
-{
- __asm __volatile("pushl %0; popfl" : : "r" (ef));
-}
-
-static __inline void
-wrmsr(u_int msr, u_int64_t newval)
-{
- __asm __volatile(".byte 0x0f, 0x30" : : "A" (newval), "c" (msr));
-}
-
-static __inline u_int
-rfs(void)
-{
- u_int sel;
- __asm __volatile("movl %%fs,%0" : "=rm" (sel));
- return (sel);
-}
-
-static __inline u_int
-rgs(void)
-{
- u_int sel;
- __asm __volatile("movl %%gs,%0" : "=rm" (sel));
- return (sel);
-}
-
-static __inline void
-load_fs(u_int sel)
-{
- __asm __volatile("movl %0,%%fs" : : "rm" (sel));
-}
-
-static __inline void
-load_gs(u_int sel)
-{
- __asm __volatile("movl %0,%%gs" : : "rm" (sel));
-}
-
-static __inline u_int
-rdr0(void)
-{
- u_int data;
- __asm __volatile("movl %%dr0,%0" : "=r" (data));
- return (data);
-}
-
-static __inline u_int
-rdr1(void)
-{
- u_int data;
- __asm __volatile("movl %%dr1,%0" : "=r" (data));
- return (data);
-}
-
-static __inline u_int
-rdr2(void)
-{
- u_int data;
- __asm __volatile("movl %%dr2,%0" : "=r" (data));
- return (data);
-}
-
-static __inline u_int
-rdr3(void)
-{
- u_int data;
- __asm __volatile("movl %%dr3,%0" : "=r" (data));
- return (data);
-}
-
-static __inline u_int
-rdr6(void)
-{
- u_int data;
- __asm __volatile("movl %%dr6,%0" : "=r" (data));
- return (data);
-}
-
-static __inline u_int
-rdr7(void)
-{
- u_int data;
- __asm __volatile("movl %%dr7,%0" : "=r" (data));
- return (data);
-}
-
-#else /* !__GNUC__ */
-
-int breakpoint __P((void));
-u_int bsfl __P((u_int mask));
-u_int bsrl __P((u_int mask));
-void disable_intr __P((void));
-void enable_intr __P((void));
-u_char inb __P((u_int port));
-u_int inl __P((u_int port));
-void insb __P((u_int port, void *addr, size_t cnt));
-void insl __P((u_int port, void *addr, size_t cnt));
-void insw __P((u_int port, void *addr, size_t cnt));
-void invd __P((void));
-void invlpg __P((u_int addr));
-void invltlb __P((void));
-u_short inw __P((u_int port));
-u_int loadandclear __P((u_int *addr));
-void outb __P((u_int port, u_char data));
-void outl __P((u_int port, u_int data));
-void outsb __P((u_int port, void *addr, size_t cnt));
-void outsl __P((u_int port, void *addr, size_t cnt));
-void outsw __P((u_int port, void *addr, size_t cnt));
-void outw __P((u_int port, u_short data));
-u_int rcr2 __P((void));
-u_int64_t rdmsr __P((u_int msr));
-u_int64_t rdpmc __P((u_int pmc));
-u_int64_t rdtsc __P((void));
-u_int read_eflags __P((void));
-void wbinvd __P((void));
-void write_eflags __P((u_int ef));
-void wrmsr __P((u_int msr, u_int64_t newval));
-u_int rfs __P((void));
-u_int rgs __P((void));
-void load_fs __P((u_int sel));
-void load_gs __P((u_int sel));
-
-#endif /* __GNUC__ */
-
-void load_cr0 __P((u_int cr0));
-void load_cr3 __P((u_int cr3));
-void load_cr4 __P((u_int cr4));
-void ltr __P((u_short sel));
-u_int rcr0 __P((void));
-u_int rcr3 __P((void));
-u_int rcr4 __P((void));
-void load_dr6 __P((u_int dr6));
-void reset_dbregs __P((void));
-
-#endif /* !_MACHINE_CPUFUNC_H_ */
diff --git a/sys/amd64/include/cputypes.h b/sys/amd64/include/cputypes.h
deleted file mode 100644
index 93e01e26287d..000000000000
--- a/sys/amd64/include/cputypes.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 1993 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. 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _MACHINE_CPUTYPES_H_
-#define _MACHINE_CPUTYPES_H_
-
-/*
- * Classes of processor.
- */
-#define CPUCLASS_286 0
-#define CPUCLASS_386 1
-#define CPUCLASS_486 2
-#define CPUCLASS_586 3
-#define CPUCLASS_686 4
-
-/*
- * Kinds of processor.
- */
-#define CPU_286 0 /* Intel 80286 */
-#define CPU_386SX 1 /* Intel 80386SX */
-#define CPU_386 2 /* Intel 80386DX */
-#define CPU_486SX 3 /* Intel 80486SX */
-#define CPU_486 4 /* Intel 80486DX */
-#define CPU_586 5 /* Intel P.....m (I hate lawyers; it's TM) */
-#define CPU_486DLC 6 /* Cyrix 486DLC */
-#define CPU_686 7 /* Pentium Pro */
-#define CPU_M1SC 8 /* Cyrix M1sc (aka 5x86) */
-#define CPU_M1 9 /* Cyrix M1 (aka 6x86) */
-#define CPU_BLUE 10 /* IBM BlueLighting CPU */
-#define CPU_M2 11 /* Cyrix M2 (aka enhanced 6x86 with MMX */
-#define CPU_NX586 12 /* NexGen (now AMD) 586 */
-#define CPU_CY486DX 13 /* Cyrix 486S/DX/DX2/DX4 */
-#define CPU_PII 14 /* Intel Pentium II */
-#define CPU_PIII 15 /* Intel Pentium III */
-
-#ifndef LOCORE
-struct cpu_nameclass {
- char *cpu_name;
- int cpu_class;
-};
-
-extern int cpu;
-extern int cpu_class;
-#endif
-
-#endif /* !_MACHINE_CPUTYPES_H_ */
diff --git a/sys/amd64/include/db_machdep.h b/sys/amd64/include/db_machdep.h
deleted file mode 100644
index f37d2e82765f..000000000000
--- a/sys/amd64/include/db_machdep.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Mach Operating System
- * Copyright (c) 1991,1990 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _MACHINE_DB_MACHDEP_H_
-#define _MACHINE_DB_MACHDEP_H_
-
-#include <machine/frame.h>
-#include <machine/psl.h>
-#include <machine/trap.h>
-
-#define i386_saved_state trapframe
-
-typedef vm_offset_t db_addr_t; /* address - unsigned */
-typedef int db_expr_t; /* expression - signed */
-
-typedef struct i386_saved_state db_regs_t;
-extern db_regs_t ddb_regs; /* register state */
-#define DDB_REGS (&ddb_regs)
-
-#define PC_REGS(regs) ((db_addr_t)(regs)->tf_eip)
-
-#define BKPT_INST 0xcc /* breakpoint instruction */
-#define BKPT_SIZE (1) /* size of breakpoint inst */
-#define BKPT_SET(inst) (BKPT_INST)
-
-#define FIXUP_PC_AFTER_BREAK ddb_regs.tf_eip -= 1;
-
-#define db_clear_single_step(regs) ((regs)->tf_eflags &= ~PSL_T)
-#define db_set_single_step(regs) ((regs)->tf_eflags |= PSL_T)
-
-#define IS_BREAKPOINT_TRAP(type, code) ((type) == T_BPTFLT)
-/*
- * Watchpoints are not supported. The debug exception type is in %dr6
- * and not yet in the args to this macro.
- */
-#define IS_WATCHPOINT_TRAP(type, code) 0
-
-#define I_CALL 0xe8
-#define I_CALLI 0xff
-#define I_RET 0xc3
-#define I_IRET 0xcf
-
-#define inst_trap_return(ins) (((ins)&0xff) == I_IRET)
-#define inst_return(ins) (((ins)&0xff) == I_RET)
-#define inst_call(ins) (((ins)&0xff) == I_CALL || \
- (((ins)&0xff) == I_CALLI && \
- ((ins)&0x3800) == 0x1000))
-#define inst_load(ins) 0
-#define inst_store(ins) 0
-
-/*
- * There no interesting addresses below _kstack = 0xefbfe000. There
- * are small absolute values for GUPROF, but we don't want to see them.
- * Treat "negative" addresses below _kstack as non-small to allow for
- * future reductions of _kstack and to avoid sign extension problems.
- *
- * There is one interesting symbol above -db_maxoff = 0xffff0000,
- * namely _APTD = 0xfffff000. Accepting this would mess up the
- * printing of small negative offsets. The next largest symbol is
- * _APTmap = 0xffc00000. Accepting this is OK (unless db_maxoff is
- * set to >= 0x400000 - (max stack offset)).
- */
-#define DB_SMALL_VALUE_MAX 0x7fffffff
-#define DB_SMALL_VALUE_MIN (-0x400001)
-
-#endif /* !_MACHINE_DB_MACHDEP_H_ */
diff --git a/sys/amd64/include/elf.h b/sys/amd64/include/elf.h
deleted file mode 100644
index 7fd8fda56d82..000000000000
--- a/sys/amd64/include/elf.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/*-
- * Copyright (c) 1996-1997 John D. Polstra.
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _MACHINE_ELF_H_
-#define _MACHINE_ELF_H_ 1
-
-/*
- * ELF definitions for the i386 architecture.
- */
-
-#include <sys/elf32.h> /* Definitions common to all 32 bit architectures. */
-
-#define __ELF_WORD_SIZE 32 /* Used by <sys/elf_generic.h> */
-#include <sys/elf_generic.h>
-
-#define ELF_ARCH EM_386
-
-#define ELF_MACHINE_OK(x) ((x) == EM_386 || (x) == EM_486)
-
-/*
- * Auxiliary vector entries for passing information to the interpreter.
- *
- * The i386 supplement to the SVR4 ABI specification names this "auxv_t",
- * but POSIX lays claim to all symbols ending with "_t".
- */
-
-typedef struct { /* Auxiliary vector entry on initial stack */
- int a_type; /* Entry type. */
- union {
- long a_val; /* Integer value. */
- void *a_ptr; /* Address. */
- void (*a_fcn)(void); /* Function pointer (not used). */
- } a_un;
-} Elf32_Auxinfo;
-
-__ElfType(Auxinfo);
-
-/* Values for a_type. */
-#define AT_NULL 0 /* Terminates the vector. */
-#define AT_IGNORE 1 /* Ignored entry. */
-#define AT_EXECFD 2 /* File descriptor of program to load. */
-#define AT_PHDR 3 /* Program header of program already loaded. */
-#define AT_PHENT 4 /* Size of each program header entry. */
-#define AT_PHNUM 5 /* Number of program header entries. */
-#define AT_PAGESZ 6 /* Page size in bytes. */
-#define AT_BASE 7 /* Interpreter's base address. */
-#define AT_FLAGS 8 /* Flags (unused for i386). */
-#define AT_ENTRY 9 /* Where interpreter should transfer control. */
-
-/*
- * The following non-standard values are used for passing information
- * from John Polstra's testbed program to the dynamic linker. These
- * are expected to go away soon.
- *
- * Unfortunately, these overlap the Linux non-standard values, so they
- * must not be used in the same context.
- */
-#define AT_BRK 10 /* Starting point for sbrk and brk. */
-#define AT_DEBUG 11 /* Debugging level. */
-
-/*
- * The following non-standard values are used in Linux ELF binaries.
- */
-#define AT_NOTELF 10 /* Program is not ELF ?? */
-#define AT_UID 11 /* Real uid. */
-#define AT_EUID 12 /* Effective uid. */
-#define AT_GID 13 /* Real gid. */
-#define AT_EGID 14 /* Effective gid. */
-
-#define AT_COUNT 15 /* Count of defined aux entry types. */
-
-/*
- * Relocation types.
- */
-
-#define R_386_NONE 0 /* No relocation. */
-#define R_386_32 1 /* Add symbol value. */
-#define R_386_PC32 2 /* Add PC-relative symbol value. */
-#define R_386_GOT32 3 /* Add PC-relative GOT offset. */
-#define R_386_PLT32 4 /* Add PC-relative PLT offset. */
-#define R_386_COPY 5 /* Copy data from shared object. */
-#define R_386_GLOB_DAT 6 /* Set GOT entry to data address. */
-#define R_386_JMP_SLOT 7 /* Set GOT entry to code address. */
-#define R_386_RELATIVE 8 /* Add load address of shared object. */
-#define R_386_GOTOFF 9 /* Add GOT-relative symbol address. */
-#define R_386_GOTPC 10 /* Add PC-relative GOT table address. */
-
-#define R_386_COUNT 11 /* Count of defined relocation types. */
-
-/* Define "machine" characteristics */
-#define ELF_TARG_CLASS ELFCLASS32
-#define ELF_TARG_DATA ELFDATA2LSB
-#define ELF_TARG_MACH EM_386
-#define ELF_TARG_VER 1
-
-#ifdef _KERNEL
-
-/*
- * On the i386 we load the dynamic linker where a userland call
- * to mmap(0, ...) would put it. The rationale behind this
- * calculation is that it leaves room for the heap to grow to
- * its maximum allowed size.
- */
-#define ELF_RTLD_ADDR(vmspace) \
- (round_page((vm_offset_t)(vmspace)->vm_daddr + MAXDSIZ))
-
-#endif /* _KERNEL */
-#endif /* !_MACHINE_ELF_H_ */
diff --git a/sys/amd64/include/exec.h b/sys/amd64/include/exec.h
deleted file mode 100644
index c233b09655b2..000000000000
--- a/sys/amd64/include/exec.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*-
- * 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)exec.h 8.1 (Berkeley) 6/11/93
- * $FreeBSD$
- */
-
-#ifndef _EXEC_H_
-#define _EXEC_H_
-
-#define __LDPGSZ 4096
-
-#endif /* !_EXEC_H_ */
diff --git a/sys/amd64/include/float.h b/sys/amd64/include/float.h
deleted file mode 100644
index 5cdbc97f7d4b..000000000000
--- a/sys/amd64/include/float.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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. 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, Berkeley and its contributors.
- * 4. 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: @(#)float.h 7.1 (Berkeley) 5/8/90
- * $FreeBSD$
- */
-
-#ifndef _MACHINE_FLOAT_H_
-#define _MACHINE_FLOAT_H_ 1
-
-#define FLT_RADIX 2 /* b */
-#define FLT_ROUNDS 1 /* FP addition rounds to nearest */
-
-#define FLT_MANT_DIG 24 /* p */
-#define FLT_EPSILON 1.19209290E-07F /* b**(1-p) */
-#define FLT_DIG 6 /* floor((p-1)*log10(b))+(b == 10) */
-#define FLT_MIN_EXP (-125) /* emin */
-#define FLT_MIN 1.17549435E-38F /* b**(emin-1) */
-#define FLT_MIN_10_EXP (-37) /* ceil(log10(b**(emin-1))) */
-#define FLT_MAX_EXP 128 /* emax */
-#define FLT_MAX 3.40282347E+38F /* (1-b**(-p))*b**emax */
-#define FLT_MAX_10_EXP 38 /* floor(log10((1-b**(-p))*b**emax)) */
-
-#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
-#endif /* _MACHINE_FLOAT_H_ */
diff --git a/sys/amd64/include/floatingpoint.h b/sys/amd64/include/floatingpoint.h
deleted file mode 100644
index c3e674f7f30c..000000000000
--- a/sys/amd64/include/floatingpoint.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/*-
- * Copyright (c) 1993 Andrew Moore, Talke Studio
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#) floatingpoint.h 1.0 (Berkeley) 9/23/93
- * $FreeBSD$
- */
-
-#ifndef _FLOATINGPOINT_H_
-#define _FLOATINGPOINT_H_
-
-/*
- * IEEE floating point structure and function definitions
- */
-
-/*-
- * XXX the following undocumented pollution is exported:
- * fpsetsticky().
- * FP*FLD, FP*OFF and FP*REG from <machine/ieeefp.h>
- */
-
-#include <sys/cdefs.h>
-#include <machine/ieeefp.h>
-
-#ifdef __GNUC__
-
-#define __fldenv(addr) __asm __volatile("fldenv %0" : : "m" (*(addr)))
-#define __fnstenv(addr) __asm __volatile("fnstenv %0" : "=m" (*(addr)))
-#define __fnstcw(addr) __asm __volatile("fnstcw %0" : "=m" (*(addr)))
-#define __fnstsw(addr) __asm __volatile("fnstsw %0" : "=m" (*(addr)))
-
-/*
- * return the contents of a FP register
- */
-static __inline__ int
-__fpgetreg(int _reg)
-{
- unsigned short _mem;
-
- /*-
- * This is more efficient than it looks. The switch gets optimized
- * away if _reg is constant.
- *
- * The default case only supports _reg == 0. We could handle more
- * registers (e.g., tags) using fnstenv, but the interface doesn't
- * support more.
- */
- switch(_reg) {
- default:
- __fnstcw(&_mem);
- break;
- case FP_STKY_REG:
- __fnstsw(&_mem);
- break;
- }
- return _mem;
-}
-
-/*
- * set a FP mode; return previous mode
- */
-static __inline__ int
-__fpsetreg(int _m, int _reg, int _fld, int _off)
-{
- unsigned _env[7];
- unsigned _p;
-
- /*
- * _reg == 0 could be handled better using fnstcw/fldcw.
- */
- __fnstenv(_env);
- _p = (_env[_reg] & _fld) >> _off;
- _env[_reg] = (_env[_reg] & ~_fld) | (_m << _off & _fld);
- __fldenv(_env);
- return _p;
-}
-
-#endif /* __GNUC__ */
-
-/*
- * SysV/386 FP control interface
- */
-#define fpgetround() ((fp_rnd_t) ((__fpgetreg(FP_RND_REG) & FP_RND_FLD) >> FP_RND_OFF))
-#define fpsetround(m) ((fp_rnd_t) __fpsetreg((m), FP_RND_REG, FP_RND_FLD, FP_RND_OFF))
-#define fpgetprec() ((fp_prec_t) ((__fpgetreg(FP_PRC_REG) & FP_PRC_FLD) >> FP_PRC_OFF))
-#define fpsetprec(m) ((fp_prec_t) __fpsetreg((m), FP_PRC_REG, FP_PRC_FLD, FP_PRC_OFF))
-#define fpgetmask() ((fp_except_t) ((~__fpgetreg(FP_MSKS_REG) & FP_MSKS_FLD) >> FP_MSKS_OFF))
-#define fpsetmask(m) ((fp_except_t) (__fpsetreg(~(m), FP_MSKS_REG, FP_MSKS_FLD, FP_MSKS_OFF)))
-#define fpgetsticky() ((fp_except_t) ((__fpgetreg(FP_STKY_REG) & FP_STKY_FLD) >> FP_STKY_OFF))
-#define fpresetsticky(m) ((fp_except_t) __fpsetreg(0, FP_STKY_REG, (m), FP_STKY_OFF))
-#define fpsetsticky(m) fpresetsticky(m)
-
-#endif /* !_FLOATINGPOINT_H_ */
diff --git a/sys/amd64/include/fpu.h b/sys/amd64/include/fpu.h
deleted file mode 100644
index 695ab2a5b61c..000000000000
--- a/sys/amd64/include/fpu.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)npx.h 5.3 (Berkeley) 1/18/91
- * $FreeBSD$
- */
-
-/*
- * 287/387 NPX Coprocessor Data Structures and Constants
- * W. Jolitz 1/90
- */
-
-#ifndef _MACHINE_NPX_H_
-#define _MACHINE_NPX_H_
-
-#include <machine/globals.h>
-
-/* Environment information of floating point unit */
-struct env87 {
- long en_cw; /* control word (16bits) */
- long en_sw; /* status word (16bits) */
- long en_tw; /* tag word (16bits) */
- long en_fip; /* floating point instruction pointer */
- u_short en_fcs; /* floating code segment selector */
- u_short en_opcode; /* opcode last executed (11 bits ) */
- long en_foo; /* floating operand offset */
- long en_fos; /* floating operand segment selector */
-};
-
-/* Contents of each floating point accumulator */
-struct fpacc87 {
-#ifdef dontdef /* too unportable */
- u_long fp_mantlo; /* mantissa low (31:0) */
- u_long fp_manthi; /* mantissa high (63:32) */
- int fp_exp:15; /* exponent */
- int fp_sgn:1; /* mantissa sign */
-#else
- u_char fp_bytes[10];
-#endif
-};
-
-/* Floating point context */
-struct save87 {
- struct env87 sv_env; /* floating point control/status */
- struct fpacc87 sv_ac[8]; /* accumulator contents, 0-7 */
- u_long sv_ex_sw; /* status word for last exception */
- /*
- * Bogus padding for emulators. Emulators should use their own
- * struct and arrange to store into this struct (ending here)
- * before it is inspected for ptracing or for core dumps. Some
- * emulators overwrite the whole struct. We have no good way of
- * knowing how much padding to leave. Leave just enough for the
- * GPL emulator's i387_union (176 bytes total).
- */
- u_char sv_pad[64]; /* padding; used by emulators */
-};
-
-/*
- * The hardware default control word for i387's and later coprocessors is
- * 0x37F, giving:
- *
- * round to nearest
- * 64-bit precision
- * all exceptions masked.
- *
- * We modify the affine mode bit and precision bits in this to give:
- *
- * affine mode for 287's (if they work at all) (1 in bitfield 1<<12)
- * 53-bit precision (2 in bitfield 3<<8)
- *
- * 64-bit precision often gives bad results with high level languages
- * because it makes the results of calculations depend on whether
- * intermediate values are stored in memory or in FPU registers.
- */
-#define __INITIAL_NPXCW__ 0x127F
-
-#ifdef _KERNEL
-#ifndef npxproc
-extern struct proc *npxproc;
-#endif
-
-int npxdna __P((void));
-void npxexit __P((struct proc *p));
-void npxinit __P((int control));
-void npxsave __P((struct save87 *addr));
-#endif
-
-#endif /* !_MACHINE_NPX_H_ */
diff --git a/sys/amd64/include/frame.h b/sys/amd64/include/frame.h
deleted file mode 100644
index 634e6909e908..000000000000
--- a/sys/amd64/include/frame.h
+++ /dev/null
@@ -1,163 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)frame.h 5.2 (Berkeley) 1/18/91
- * $FreeBSD$
- */
-
-#ifndef _MACHINE_FRAME_H_
-#define _MACHINE_FRAME_H_ 1
-
-/*
- * System stack frames.
- */
-
-/*
- * Exception/Trap Stack Frame
- */
-
-struct trapframe {
- int tf_fs;
- int tf_es;
- int tf_ds;
- int tf_edi;
- int tf_esi;
- int tf_ebp;
- int tf_isp;
- int tf_ebx;
- int tf_edx;
- int tf_ecx;
- int tf_eax;
- int tf_trapno;
- /* below portion defined in 386 hardware */
- int tf_err;
- int tf_eip;
- int tf_cs;
- int tf_eflags;
- /* below only when crossing rings (e.g. user to kernel) */
- int tf_esp;
- int tf_ss;
-};
-
-/* Superset of trap frame, for traps from virtual-8086 mode */
-
-struct trapframe_vm86 {
- int tf_fs;
- int tf_es;
- int tf_ds;
- int tf_edi;
- int tf_esi;
- int tf_ebp;
- int tf_isp;
- int tf_ebx;
- int tf_edx;
- int tf_ecx;
- int tf_eax;
- int tf_trapno;
- /* below portion defined in 386 hardware */
- int tf_err;
- int tf_eip;
- int tf_cs;
- int tf_eflags;
- /* below only when crossing rings (e.g. user to kernel) */
- int tf_esp;
- int tf_ss;
- /* below only when switching out of VM86 mode */
- int tf_vm86_es;
- int tf_vm86_ds;
- int tf_vm86_fs;
- int tf_vm86_gs;
-};
-
-/* Interrupt stack frame */
-
-struct intrframe {
- int if_vec;
- int if_ppl;
- int if_fs;
- int if_es;
- int if_ds;
- int if_edi;
- int if_esi;
- int if_ebp;
- int :32;
- int if_ebx;
- int if_edx;
- int if_ecx;
- int if_eax;
- int :32; /* for compat with trap frame - trapno */
- int :32; /* for compat with trap frame - err */
- /* below portion defined in 386 hardware */
- int if_eip;
- int if_cs;
- int if_eflags;
- /* below only when crossing rings (e.g. user to kernel) */
- int if_esp;
- int if_ss;
-};
-
-/* frame of clock (same as interrupt frame) */
-
-struct clockframe {
- int cf_vec;
- int cf_ppl;
- int cf_fs;
- int cf_es;
- int cf_ds;
- int cf_edi;
- int cf_esi;
- int cf_ebp;
- int :32;
- int cf_ebx;
- int cf_edx;
- int cf_ecx;
- int cf_eax;
- int :32; /* for compat with trap frame - trapno */
- int :32; /* for compat with trap frame - err */
- /* below portion defined in 386 hardware */
- int cf_eip;
- int cf_cs;
- int cf_eflags;
- /* below only when crossing rings (e.g. user to kernel) */
- int cf_esp;
- int cf_ss;
-};
-
-int kdb_trap __P((int, int, struct trapframe *));
-extern int (*pmath_emulate) __P((struct trapframe *));
-
-#define INTR_TO_TRAPFRAME(frame) ((struct trapframe *)&(frame)->if_fs)
-
-#endif /* _MACHINE_FRAME_H_ */
diff --git a/sys/amd64/include/ieeefp.h b/sys/amd64/include/ieeefp.h
deleted file mode 100644
index 3c9c49ddda34..000000000000
--- a/sys/amd64/include/ieeefp.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*-
- * Copyright (c) 1990 Andrew Moore, Talke Studio
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#) ieeefp.h 1.0 (Berkeley) 9/23/93
- * $FreeBSD$
- */
-
-/*
- * IEEE floating point type and constant definitions.
- */
-
-#ifndef _MACHINE_IEEEFP_H_
-#define _MACHINE_IEEEFP_H_
-
-/*
- * FP rounding modes
- */
-typedef enum {
- FP_RN=0, /* round to nearest */
- FP_RM, /* round down to minus infinity */
- FP_RP, /* round up to plus infinity */
- FP_RZ /* truncate */
-} fp_rnd_t;
-
-/*
- * FP precision modes
- */
-typedef enum {
- FP_PS=0, /* 24 bit (single-precision) */
- FP_PRS, /* reserved */
- FP_PD, /* 53 bit (double-precision) */
- FP_PE /* 64 bit (extended-precision) */
-} fp_prec_t;
-
-#define fp_except_t int
-
-/*
- * FP exception masks
- */
-#define FP_X_INV 0x01 /* invalid operation */
-#define FP_X_DNML 0x02 /* denormal */
-#define FP_X_DZ 0x04 /* zero divide */
-#define FP_X_OFL 0x08 /* overflow */
-#define FP_X_UFL 0x10 /* underflow */
-#define FP_X_IMP 0x20 /* (im)precision */
-#define FP_X_STK 0x40 /* stack fault */
-
-/*
- * FP registers
- */
-#define FP_MSKS_REG 0 /* exception masks */
-#define FP_PRC_REG 0 /* precision */
-#define FP_RND_REG 0 /* direction */
-#define FP_STKY_REG 1 /* sticky flags */
-
-/*
- * FP register bit field masks
- */
-#define FP_MSKS_FLD 0x3f /* exception masks field */
-#define FP_PRC_FLD 0x300 /* precision control field */
-#define FP_RND_FLD 0xc00 /* round control field */
-#define FP_STKY_FLD 0x3f /* sticky flags field */
-
-/*
- * FP register bit field offsets
- */
-#define FP_MSKS_OFF 0 /* exception masks offset */
-#define FP_PRC_OFF 8 /* precision control offset */
-#define FP_RND_OFF 10 /* round control offset */
-#define FP_STKY_OFF 0 /* sticky flags offset */
-
-#endif /* !_MACHINE_IEEEFP_H_ */
diff --git a/sys/amd64/include/md_var.h b/sys/amd64/include/md_var.h
deleted file mode 100644
index 1c3fe64e413b..000000000000
--- a/sys/amd64/include/md_var.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*-
- * Copyright (c) 1995 Bruce D. Evans.
- * 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 author nor the names of contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _MACHINE_MD_VAR_H_
-#define _MACHINE_MD_VAR_H_
-
-/*
- * Miscellaneous machine-dependent declarations.
- */
-
-extern int Maxmem;
-extern u_int atdevbase; /* offset in virtual memory of ISA io mem */
-extern void (*bcopy_vector) __P((const void *from, void *to, size_t len));
-extern int busdma_swi_pending;
-extern int (*copyin_vector) __P((const void *udaddr, void *kaddr,
- size_t len));
-extern int (*copyout_vector) __P((const void *kaddr, void *udaddr,
- size_t len));
-extern u_int cpu_feature;
-extern u_int cpu_high;
-extern u_int cpu_id;
-extern char cpu_vendor[];
-extern u_int cyrix_did;
-extern char kstack[];
-#ifdef PC98
-extern int need_pre_dma_flush;
-extern int need_post_dma_flush;
-#endif
-extern void (*netisrs[32]) __P((void));
-extern int nfs_diskless_valid;
-extern void (*ovbcopy_vector) __P((const void *from, void *to, size_t len));
-extern char sigcode[];
-extern int szsigcode, szosigcode;
-
-typedef void alias_for_inthand_t __P((u_int cs, u_int ef, u_int esp, u_int ss));
-struct proc;
-struct reg;
-struct fpreg;
-struct dbreg;
-
-void bcopyb __P((const void *from, void *to, size_t len));
-void busdma_swi __P((void));
-void cpu_halt __P((void));
-void cpu_reset __P((void));
-void cpu_switch_load_gs __P((void)) __asm(__STRING(cpu_switch_load_gs));
-void doreti_iret __P((void)) __asm(__STRING(doreti_iret));
-void doreti_iret_fault __P((void)) __asm(__STRING(doreti_iret_fault));
-void doreti_popl_ds __P((void)) __asm(__STRING(doreti_popl_ds));
-void doreti_popl_ds_fault __P((void)) __asm(__STRING(doreti_popl_ds_fault));
-void doreti_popl_es __P((void)) __asm(__STRING(doreti_popl_es));
-void doreti_popl_es_fault __P((void)) __asm(__STRING(doreti_popl_es_fault));
-void doreti_popl_fs __P((void)) __asm(__STRING(doreti_popl_fs));
-void doreti_popl_fs_fault __P((void)) __asm(__STRING(doreti_popl_fs_fault));
-int fill_fpregs __P((struct proc *, struct fpreg *));
-int fill_regs __P((struct proc *p, struct reg *regs));
-int fill_dbregs __P((struct proc *p, struct dbreg *dbregs));
-void fillw __P((int /*u_short*/ pat, void *base, size_t cnt));
-void i486_bzero __P((void *buf, size_t len));
-void i586_bcopy __P((const void *from, void *to, size_t len));
-void i586_bzero __P((void *buf, size_t len));
-int i586_copyin __P((const void *udaddr, void *kaddr, size_t len));
-int i586_copyout __P((const void *kaddr, void *udaddr, size_t len));
-void i686_pagezero __P((void *addr));
-int is_physical_memory __P((vm_offset_t addr));
-u_long kvtop __P((void *addr));
-void setidt __P((int idx, alias_for_inthand_t *func, int typ, int dpl,
- int selec));
-void swi_vm __P((void));
-void userconfig __P((void));
-int user_dbreg_trap __P((void));
-int vm_page_zero_idle __P((void));
-
-#endif /* !_MACHINE_MD_VAR_H_ */
diff --git a/sys/amd64/include/mptable.h b/sys/amd64/include/mptable.h
deleted file mode 100644
index 8e349a9800e4..000000000000
--- a/sys/amd64/include/mptable.h
+++ /dev/null
@@ -1,2739 +0,0 @@
-/*
- * Copyright (c) 1996, by Steve Passe
- * 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 developer 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include "opt_smp.h"
-#include "opt_cpu.h"
-#include "opt_user_ldt.h"
-
-#ifdef SMP
-#include <machine/smptests.h>
-#else
-#error
-#endif
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/proc.h>
-#include <sys/sysctl.h>
-#include <sys/malloc.h>
-#include <sys/memrange.h>
-#ifdef BETTER_CLOCK
-#include <sys/dkstat.h>
-#endif
-#include <sys/cons.h> /* cngetc() */
-
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <vm/pmap.h>
-#include <vm/vm_kern.h>
-#include <vm/vm_extern.h>
-#ifdef BETTER_CLOCK
-#include <sys/lock.h>
-#include <vm/vm_map.h>
-#include <sys/user.h>
-#ifdef GPROF
-#include <sys/gmon.h>
-#endif
-#endif
-
-#include <machine/smp.h>
-#include <machine/apic.h>
-#include <machine/atomic.h>
-#include <machine/cpufunc.h>
-#include <machine/mpapic.h>
-#include <machine/psl.h>
-#include <machine/segments.h>
-#include <machine/smptests.h> /** TEST_DEFAULT_CONFIG, TEST_TEST1 */
-#include <machine/tss.h>
-#include <machine/specialreg.h>
-#include <machine/globaldata.h>
-
-#if defined(APIC_IO)
-#include <machine/md_var.h> /* setidt() */
-#include <i386/isa/icu.h> /* IPIs */
-#include <i386/isa/intr_machdep.h> /* IPIs */
-#endif /* APIC_IO */
-
-#if defined(TEST_DEFAULT_CONFIG)
-#define MPFPS_MPFB1 TEST_DEFAULT_CONFIG
-#else
-#define MPFPS_MPFB1 mpfps->mpfb1
-#endif /* TEST_DEFAULT_CONFIG */
-
-#define WARMBOOT_TARGET 0
-#define WARMBOOT_OFF (KERNBASE + 0x0467)
-#define WARMBOOT_SEG (KERNBASE + 0x0469)
-
-#ifdef PC98
-#define BIOS_BASE (0xe8000)
-#define BIOS_SIZE (0x18000)
-#else
-#define BIOS_BASE (0xf0000)
-#define BIOS_SIZE (0x10000)
-#endif
-#define BIOS_COUNT (BIOS_SIZE/4)
-
-#define CMOS_REG (0x70)
-#define CMOS_DATA (0x71)
-#define BIOS_RESET (0x0f)
-#define BIOS_WARM (0x0a)
-
-#define PROCENTRY_FLAG_EN 0x01
-#define PROCENTRY_FLAG_BP 0x02
-#define IOAPICENTRY_FLAG_EN 0x01
-
-
-/* MP Floating Pointer Structure */
-typedef struct MPFPS {
- char signature[4];
- void *pap;
- u_char length;
- u_char spec_rev;
- u_char checksum;
- u_char mpfb1;
- u_char mpfb2;
- u_char mpfb3;
- u_char mpfb4;
- u_char mpfb5;
-} *mpfps_t;
-
-/* MP Configuration Table Header */
-typedef struct MPCTH {
- char signature[4];
- u_short base_table_length;
- u_char spec_rev;
- u_char checksum;
- u_char oem_id[8];
- u_char product_id[12];
- void *oem_table_pointer;
- u_short oem_table_size;
- u_short entry_count;
- void *apic_address;
- u_short extended_table_length;
- u_char extended_table_checksum;
- u_char reserved;
-} *mpcth_t;
-
-
-typedef struct PROCENTRY {
- u_char type;
- u_char apic_id;
- u_char apic_version;
- u_char cpu_flags;
- u_long cpu_signature;
- u_long feature_flags;
- u_long reserved1;
- u_long reserved2;
-} *proc_entry_ptr;
-
-typedef struct BUSENTRY {
- u_char type;
- u_char bus_id;
- char bus_type[6];
-} *bus_entry_ptr;
-
-typedef struct IOAPICENTRY {
- u_char type;
- u_char apic_id;
- u_char apic_version;
- u_char apic_flags;
- void *apic_address;
-} *io_apic_entry_ptr;
-
-typedef struct INTENTRY {
- u_char type;
- u_char int_type;
- u_short int_flags;
- u_char src_bus_id;
- u_char src_bus_irq;
- u_char dst_apic_id;
- u_char dst_apic_int;
-} *int_entry_ptr;
-
-/* descriptions of MP basetable entries */
-typedef struct BASETABLE_ENTRY {
- u_char type;
- u_char length;
- char name[16];
-} basetable_entry;
-
-/*
- * this code MUST be enabled here and in mpboot.s.
- * it follows the very early stages of AP boot by placing values in CMOS ram.
- * it NORMALLY will never be needed and thus the primitive method for enabling.
- *
-#define CHECK_POINTS
- */
-
-#if defined(CHECK_POINTS) && !defined(PC98)
-#define CHECK_READ(A) (outb(CMOS_REG, (A)), inb(CMOS_DATA))
-#define CHECK_WRITE(A,D) (outb(CMOS_REG, (A)), outb(CMOS_DATA, (D)))
-
-#define CHECK_INIT(D); \
- CHECK_WRITE(0x34, (D)); \
- CHECK_WRITE(0x35, (D)); \
- CHECK_WRITE(0x36, (D)); \
- CHECK_WRITE(0x37, (D)); \
- CHECK_WRITE(0x38, (D)); \
- CHECK_WRITE(0x39, (D));
-
-#define CHECK_PRINT(S); \
- printf("%s: %d, %d, %d, %d, %d, %d\n", \
- (S), \
- CHECK_READ(0x34), \
- CHECK_READ(0x35), \
- CHECK_READ(0x36), \
- CHECK_READ(0x37), \
- CHECK_READ(0x38), \
- CHECK_READ(0x39));
-
-#else /* CHECK_POINTS */
-
-#define CHECK_INIT(D)
-#define CHECK_PRINT(S)
-
-#endif /* CHECK_POINTS */
-
-/*
- * Values to send to the POST hardware.
- */
-#define MP_BOOTADDRESS_POST 0x10
-#define MP_PROBE_POST 0x11
-#define MPTABLE_PASS1_POST 0x12
-
-#define MP_START_POST 0x13
-#define MP_ENABLE_POST 0x14
-#define MPTABLE_PASS2_POST 0x15
-
-#define START_ALL_APS_POST 0x16
-#define INSTALL_AP_TRAMP_POST 0x17
-#define START_AP_POST 0x18
-
-#define MP_ANNOUNCE_POST 0x19
-
-
-/** XXX FIXME: where does this really belong, isa.h/isa.c perhaps? */
-int current_postcode;
-
-/** XXX FIXME: what system files declare these??? */
-extern struct region_descriptor r_gdt, r_idt;
-
-int bsp_apic_ready = 0; /* flags useability of BSP apic */
-int mp_ncpus; /* # of CPUs, including BSP */
-int mp_naps; /* # of Applications processors */
-int mp_nbusses; /* # of busses */
-int mp_napics; /* # of IO APICs */
-int boot_cpu_id; /* designated BSP */
-vm_offset_t cpu_apic_address;
-vm_offset_t io_apic_address[NAPICID]; /* NAPICID is more than enough */
-extern int nkpt;
-
-u_int32_t cpu_apic_versions[NCPU];
-u_int32_t io_apic_versions[NAPIC];
-
-#ifdef APIC_INTR_DIAGNOSTIC
-int apic_itrace_enter[32];
-int apic_itrace_tryisrlock[32];
-int apic_itrace_gotisrlock[32];
-int apic_itrace_active[32];
-int apic_itrace_masked[32];
-int apic_itrace_noisrlock[32];
-int apic_itrace_masked2[32];
-int apic_itrace_unmask[32];
-int apic_itrace_noforward[32];
-int apic_itrace_leave[32];
-int apic_itrace_enter2[32];
-int apic_itrace_doreti[32];
-int apic_itrace_splz[32];
-int apic_itrace_eoi[32];
-#ifdef APIC_INTR_DIAGNOSTIC_IRQ
-unsigned short apic_itrace_debugbuffer[32768];
-int apic_itrace_debugbuffer_idx;
-struct simplelock apic_itrace_debuglock;
-#endif
-#endif
-
-#ifdef APIC_INTR_REORDER
-struct {
- volatile int *location;
- int bit;
-} apic_isrbit_location[32];
-#endif
-
-struct apic_intmapinfo int_to_apicintpin[APIC_INTMAPSIZE];
-
-/*
- * APIC ID logical/physical mapping structures.
- * We oversize these to simplify boot-time config.
- */
-int cpu_num_to_apic_id[NAPICID];
-int io_num_to_apic_id[NAPICID];
-int apic_id_to_logical[NAPICID];
-
-
-/* Bitmap of all available CPUs */
-u_int all_cpus;
-
-/* AP uses this during bootstrap. Do not staticize. */
-char *bootSTK;
-static int bootAP;
-
-/* Hotwire a 0->4MB V==P mapping */
-extern pt_entry_t *KPTphys;
-
-/* SMP page table page */
-extern pt_entry_t *SMPpt;
-
-struct pcb stoppcbs[NCPU];
-
-int smp_started; /* has the system started? */
-
-/*
- * Local data and functions.
- */
-
-static int mp_capable;
-static u_int boot_address;
-static u_int base_memory;
-
-static int picmode; /* 0: virtual wire mode, 1: PIC mode */
-static mpfps_t mpfps;
-static int search_for_sig(u_int32_t target, int count);
-static void mp_enable(u_int boot_addr);
-
-static int mptable_pass1(void);
-static int mptable_pass2(void);
-static void default_mp_table(int type);
-static void fix_mp_table(void);
-static void setup_apic_irq_mapping(void);
-static void init_locks(void);
-static int start_all_aps(u_int boot_addr);
-static void install_ap_tramp(u_int boot_addr);
-static int start_ap(int logicalCpu, u_int boot_addr);
-static int apic_int_is_bus_type(int intr, int bus_type);
-
-/*
- * Calculate usable address in base memory for AP trampoline code.
- */
-u_int
-mp_bootaddress(u_int basemem)
-{
- POSTCODE(MP_BOOTADDRESS_POST);
-
- base_memory = basemem * 1024; /* convert to bytes */
-
- boot_address = base_memory & ~0xfff; /* round down to 4k boundary */
- if ((base_memory - boot_address) < bootMP_size)
- boot_address -= 4096; /* not enough, lower by 4k */
-
- return boot_address;
-}
-
-
-/*
- * Look for an Intel MP spec table (ie, SMP capable hardware).
- */
-int
-mp_probe(void)
-{
- int x;
- u_long segment;
- u_int32_t target;
-
- POSTCODE(MP_PROBE_POST);
-
- /* see if EBDA exists */
- if ((segment = (u_long) * (u_short *) (KERNBASE + 0x40e)) != 0) {
- /* search first 1K of EBDA */
- target = (u_int32_t) (segment << 4);
- if ((x = search_for_sig(target, 1024 / 4)) >= 0)
- goto found;
- } else {
- /* last 1K of base memory, effective 'top of base' passed in */
- target = (u_int32_t) (base_memory - 0x400);
- if ((x = search_for_sig(target, 1024 / 4)) >= 0)
- goto found;
- }
-
- /* search the BIOS */
- target = (u_int32_t) BIOS_BASE;
- if ((x = search_for_sig(target, BIOS_COUNT)) >= 0)
- goto found;
-
- /* nothing found */
- mpfps = (mpfps_t)0;
- mp_capable = 0;
- return 0;
-
-found:
- /* calculate needed resources */
- mpfps = (mpfps_t)x;
- if (mptable_pass1())
- panic("you must reconfigure your kernel");
-
- /* flag fact that we are running multiple processors */
- mp_capable = 1;
- return 1;
-}
-
-
-/*
- * Startup the SMP processors.
- */
-void
-mp_start(void)
-{
- POSTCODE(MP_START_POST);
-
- /* look for MP capable motherboard */
- if (mp_capable)
- mp_enable(boot_address);
- else
- panic("MP hardware not found!");
-}
-
-
-/*
- * Print various information about the SMP system hardware and setup.
- */
-void
-mp_announce(void)
-{
- int x;
-
- POSTCODE(MP_ANNOUNCE_POST);
-
- printf("FreeBSD/SMP: Multiprocessor motherboard\n");
- printf(" cpu0 (BSP): apic id: %2d", CPU_TO_ID(0));
- printf(", version: 0x%08x", cpu_apic_versions[0]);
- printf(", at 0x%08x\n", cpu_apic_address);
- for (x = 1; x <= mp_naps; ++x) {
- printf(" cpu%d (AP): apic id: %2d", x, CPU_TO_ID(x));
- printf(", version: 0x%08x", cpu_apic_versions[x]);
- printf(", at 0x%08x\n", cpu_apic_address);
- }
-
-#if defined(APIC_IO)
- for (x = 0; x < mp_napics; ++x) {
- printf(" io%d (APIC): apic id: %2d", x, IO_TO_ID(x));
- printf(", version: 0x%08x", io_apic_versions[x]);
- printf(", at 0x%08x\n", io_apic_address[x]);
- }
-#else
- printf(" Warning: APIC I/O disabled\n");
-#endif /* APIC_IO */
-}
-
-/*
- * AP cpu's call this to sync up protected mode.
- */
-void
-init_secondary(void)
-{
- int gsel_tss;
- int x, myid = bootAP;
-
- gdt_segs[GPRIV_SEL].ssd_base = (int) &SMP_prvspace[myid];
- gdt_segs[GPROC0_SEL].ssd_base =
- (int) &SMP_prvspace[myid].globaldata.gd_common_tss;
- SMP_prvspace[myid].globaldata.gd_prvspace = &SMP_prvspace[myid];
-
- for (x = 0; x < NGDT; x++) {
- ssdtosd(&gdt_segs[x], &gdt[myid * NGDT + x].sd);
- }
-
- r_gdt.rd_limit = NGDT * sizeof(gdt[0]) - 1;
- r_gdt.rd_base = (int) &gdt[myid * NGDT];
- lgdt(&r_gdt); /* does magic intra-segment return */
-
- lidt(&r_idt);
-
- lldt(_default_ldt);
-#ifdef USER_LDT
- currentldt = _default_ldt;
-#endif
-
- gsel_tss = GSEL(GPROC0_SEL, SEL_KPL);
- gdt[myid * NGDT + GPROC0_SEL].sd.sd_type = SDT_SYS386TSS;
- common_tss.tss_esp0 = 0; /* not used until after switch */
- common_tss.tss_ss0 = GSEL(GDATA_SEL, SEL_KPL);
- common_tss.tss_ioopt = (sizeof common_tss) << 16;
- tss_gdt = &gdt[myid * NGDT + GPROC0_SEL].sd;
- common_tssd = *tss_gdt;
- ltr(gsel_tss);
-
- load_cr0(0x8005003b); /* XXX! */
-
- pmap_set_opt();
-}
-
-
-#if defined(APIC_IO)
-/*
- * Final configuration of the BSP's local APIC:
- * - disable 'pic mode'.
- * - disable 'virtual wire mode'.
- * - enable NMI.
- */
-void
-bsp_apic_configure(void)
-{
- u_char byte;
- u_int32_t temp;
-
- /* leave 'pic mode' if necessary */
- if (picmode) {
- outb(0x22, 0x70); /* select IMCR */
- byte = inb(0x23); /* current contents */
- byte |= 0x01; /* mask external INTR */
- outb(0x23, byte); /* disconnect 8259s/NMI */
- }
-
- /* mask lint0 (the 8259 'virtual wire' connection) */
- temp = lapic.lvt_lint0;
- temp |= APIC_LVT_M; /* set the mask */
- lapic.lvt_lint0 = temp;
-
- /* setup lint1 to handle NMI */
- temp = lapic.lvt_lint1;
- temp &= ~APIC_LVT_M; /* clear the mask */
- lapic.lvt_lint1 = temp;
-
- if (bootverbose)
- apic_dump("bsp_apic_configure()");
-}
-#endif /* APIC_IO */
-
-
-/*******************************************************************
- * local functions and data
- */
-
-/*
- * start the SMP system
- */
-static void
-mp_enable(u_int boot_addr)
-{
- int x;
-#if defined(APIC_IO)
- int apic;
- u_int ux;
-#endif /* APIC_IO */
-
- POSTCODE(MP_ENABLE_POST);
-
- /* turn on 4MB of V == P addressing so we can get to MP table */
- *(int *)PTD = PG_V | PG_RW | ((uintptr_t)(void *)KPTphys & PG_FRAME);
- invltlb();
-
- /* examine the MP table for needed info, uses physical addresses */
- x = mptable_pass2();
-
- *(int *)PTD = 0;
- invltlb();
-
- /* can't process default configs till the CPU APIC is pmapped */
- if (x)
- default_mp_table(x);
-
- /* post scan cleanup */
- fix_mp_table();
- setup_apic_irq_mapping();
-
-#if defined(APIC_IO)
-
- /* fill the LOGICAL io_apic_versions table */
- for (apic = 0; apic < mp_napics; ++apic) {
- ux = io_apic_read(apic, IOAPIC_VER);
- io_apic_versions[apic] = ux;
- }
-
- /* program each IO APIC in the system */
- for (apic = 0; apic < mp_napics; ++apic)
- if (io_apic_setup(apic) < 0)
- panic("IO APIC setup failure");
-
- /* install a 'Spurious INTerrupt' vector */
- setidt(XSPURIOUSINT_OFFSET, Xspuriousint,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-
- /* install an inter-CPU IPI for TLB invalidation */
- setidt(XINVLTLB_OFFSET, Xinvltlb,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-
-#ifdef BETTER_CLOCK
- /* install an inter-CPU IPI for reading processor state */
- setidt(XCPUCHECKSTATE_OFFSET, Xcpucheckstate,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-#endif
-
- /* install an inter-CPU IPI for all-CPU rendezvous */
- setidt(XRENDEZVOUS_OFFSET, Xrendezvous,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-
- /* install an inter-CPU IPI for forcing an additional software trap */
- setidt(XCPUAST_OFFSET, Xcpuast,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-
- /* install an inter-CPU IPI for interrupt forwarding */
- setidt(XFORWARD_IRQ_OFFSET, Xforward_irq,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-
- /* install an inter-CPU IPI for CPU stop/restart */
- setidt(XCPUSTOP_OFFSET, Xcpustop,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-
-#if defined(TEST_TEST1)
- /* install a "fake hardware INTerrupt" vector */
- setidt(XTEST1_OFFSET, Xtest1,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-#endif /** TEST_TEST1 */
-
-#endif /* APIC_IO */
-
- /* initialize all SMP locks */
- init_locks();
-
- /* start each Application Processor */
- start_all_aps(boot_addr);
-
- /*
- * The init process might be started on a different CPU now,
- * and the boot CPU might not call prepare_usermode to get
- * cr0 correctly configured. Thus we initialize cr0 here.
- */
- load_cr0(rcr0() | CR0_WP | CR0_AM);
-}
-
-
-/*
- * look for the MP spec signature
- */
-
-/* string defined by the Intel MP Spec as identifying the MP table */
-#define MP_SIG 0x5f504d5f /* _MP_ */
-#define NEXT(X) ((X) += 4)
-static int
-search_for_sig(u_int32_t target, int count)
-{
- int x;
- u_int32_t *addr = (u_int32_t *) (KERNBASE + target);
-
- for (x = 0; x < count; NEXT(x))
- if (addr[x] == MP_SIG)
- /* make array index a byte index */
- return (target + (x * sizeof(u_int32_t)));
-
- return -1;
-}
-
-
-static basetable_entry basetable_entry_types[] =
-{
- {0, 20, "Processor"},
- {1, 8, "Bus"},
- {2, 8, "I/O APIC"},
- {3, 8, "I/O INT"},
- {4, 8, "Local INT"}
-};
-
-typedef struct BUSDATA {
- u_char bus_id;
- enum busTypes bus_type;
-} bus_datum;
-
-typedef struct INTDATA {
- u_char int_type;
- u_short int_flags;
- u_char src_bus_id;
- u_char src_bus_irq;
- u_char dst_apic_id;
- u_char dst_apic_int;
- u_char int_vector;
-} io_int, local_int;
-
-typedef struct BUSTYPENAME {
- u_char type;
- char name[7];
-} bus_type_name;
-
-static bus_type_name bus_type_table[] =
-{
- {CBUS, "CBUS"},
- {CBUSII, "CBUSII"},
- {EISA, "EISA"},
- {MCA, "MCA"},
- {UNKNOWN_BUSTYPE, "---"},
- {ISA, "ISA"},
- {MCA, "MCA"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {PCI, "PCI"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {XPRESS, "XPRESS"},
- {UNKNOWN_BUSTYPE, "---"}
-};
-/* from MP spec v1.4, table 5-1 */
-static int default_data[7][5] =
-{
-/* nbus, id0, type0, id1, type1 */
- {1, 0, ISA, 255, 255},
- {1, 0, EISA, 255, 255},
- {1, 0, EISA, 255, 255},
- {1, 0, MCA, 255, 255},
- {2, 0, ISA, 1, PCI},
- {2, 0, EISA, 1, PCI},
- {2, 0, MCA, 1, PCI}
-};
-
-
-/* the bus data */
-static bus_datum bus_data[NBUS];
-
-/* the IO INT data, one entry per possible APIC INTerrupt */
-static io_int io_apic_ints[NINTR];
-
-static int nintrs;
-
-static int processor_entry __P((proc_entry_ptr entry, int cpu));
-static int bus_entry __P((bus_entry_ptr entry, int bus));
-static int io_apic_entry __P((io_apic_entry_ptr entry, int apic));
-static int int_entry __P((int_entry_ptr entry, int intr));
-static int lookup_bus_type __P((char *name));
-
-
-/*
- * 1st pass on motherboard's Intel MP specification table.
- *
- * initializes:
- * mp_ncpus = 1
- *
- * determines:
- * cpu_apic_address (common to all CPUs)
- * io_apic_address[N]
- * mp_naps
- * mp_nbusses
- * mp_napics
- * nintrs
- */
-static int
-mptable_pass1(void)
-{
- int x;
- mpcth_t cth;
- int totalSize;
- void* position;
- int count;
- int type;
- int mustpanic;
-
- POSTCODE(MPTABLE_PASS1_POST);
-
- mustpanic = 0;
-
- /* clear various tables */
- for (x = 0; x < NAPICID; ++x) {
- io_apic_address[x] = ~0; /* IO APIC address table */
- }
-
- /* init everything to empty */
- mp_naps = 0;
- mp_nbusses = 0;
- mp_napics = 0;
- nintrs = 0;
-
- /* check for use of 'default' configuration */
- if (MPFPS_MPFB1 != 0) {
- /* use default addresses */
- cpu_apic_address = DEFAULT_APIC_BASE;
- io_apic_address[0] = DEFAULT_IO_APIC_BASE;
-
- /* fill in with defaults */
- mp_naps = 2; /* includes BSP */
- mp_nbusses = default_data[MPFPS_MPFB1 - 1][0];
-#if defined(APIC_IO)
- mp_napics = 1;
- nintrs = 16;
-#endif /* APIC_IO */
- }
- else {
- if ((cth = mpfps->pap) == 0)
- panic("MP Configuration Table Header MISSING!");
-
- cpu_apic_address = (vm_offset_t) cth->apic_address;
-
- /* walk the table, recording info of interest */
- totalSize = cth->base_table_length - sizeof(struct MPCTH);
- position = (u_char *) cth + sizeof(struct MPCTH);
- count = cth->entry_count;
-
- while (count--) {
- switch (type = *(u_char *) position) {
- case 0: /* processor_entry */
- if (((proc_entry_ptr)position)->cpu_flags
- & PROCENTRY_FLAG_EN)
- ++mp_naps;
- break;
- case 1: /* bus_entry */
- ++mp_nbusses;
- break;
- case 2: /* io_apic_entry */
- if (((io_apic_entry_ptr)position)->apic_flags
- & IOAPICENTRY_FLAG_EN)
- io_apic_address[mp_napics++] =
- (vm_offset_t)((io_apic_entry_ptr)
- position)->apic_address;
- break;
- case 3: /* int_entry */
- ++nintrs;
- break;
- case 4: /* int_entry */
- break;
- default:
- panic("mpfps Base Table HOSED!");
- /* NOTREACHED */
- }
-
- totalSize -= basetable_entry_types[type].length;
- (u_char*)position += basetable_entry_types[type].length;
- }
- }
-
- /* qualify the numbers */
- if (mp_naps > NCPU) {
- printf("Warning: only using %d of %d available CPUs!\n",
- NCPU, mp_naps);
- mp_naps = NCPU;
- }
- if (mp_nbusses > NBUS) {
- printf("found %d busses, increase NBUS\n", mp_nbusses);
- mustpanic = 1;
- }
- if (mp_napics > NAPIC) {
- printf("found %d apics, increase NAPIC\n", mp_napics);
- mustpanic = 1;
- }
- if (nintrs > NINTR) {
- printf("found %d intrs, increase NINTR\n", nintrs);
- mustpanic = 1;
- }
-
- /*
- * Count the BSP.
- * This is also used as a counter while starting the APs.
- */
- mp_ncpus = 1;
-
- --mp_naps; /* subtract the BSP */
-
- return mustpanic;
-}
-
-
-/*
- * 2nd pass on motherboard's Intel MP specification table.
- *
- * sets:
- * boot_cpu_id
- * ID_TO_IO(N), phy APIC ID to log CPU/IO table
- * CPU_TO_ID(N), logical CPU to APIC ID table
- * IO_TO_ID(N), logical IO to APIC ID table
- * bus_data[N]
- * io_apic_ints[N]
- */
-static int
-mptable_pass2(void)
-{
- int x;
- mpcth_t cth;
- int totalSize;
- void* position;
- int count;
- int type;
- int apic, bus, cpu, intr;
-
- POSTCODE(MPTABLE_PASS2_POST);
-
- /* clear various tables */
- for (x = 0; x < NAPICID; ++x) {
- ID_TO_IO(x) = -1; /* phy APIC ID to log CPU/IO table */
- CPU_TO_ID(x) = -1; /* logical CPU to APIC ID table */
- IO_TO_ID(x) = -1; /* logical IO to APIC ID table */
- }
-
- /* clear bus data table */
- for (x = 0; x < NBUS; ++x)
- bus_data[x].bus_id = 0xff;
-
- /* clear IO APIC INT table */
- for (x = 0; x < NINTR; ++x) {
- io_apic_ints[x].int_type = 0xff;
- io_apic_ints[x].int_vector = 0xff;
- }
-
- /* setup the cpu/apic mapping arrays */
- boot_cpu_id = -1;
-
- /* record whether PIC or virtual-wire mode */
- picmode = (mpfps->mpfb2 & 0x80) ? 1 : 0;
-
- /* check for use of 'default' configuration */
- if (MPFPS_MPFB1 != 0)
- return MPFPS_MPFB1; /* return default configuration type */
-
- if ((cth = mpfps->pap) == 0)
- panic("MP Configuration Table Header MISSING!");
-
- /* walk the table, recording info of interest */
- totalSize = cth->base_table_length - sizeof(struct MPCTH);
- position = (u_char *) cth + sizeof(struct MPCTH);
- count = cth->entry_count;
- apic = bus = intr = 0;
- cpu = 1; /* pre-count the BSP */
-
- while (count--) {
- switch (type = *(u_char *) position) {
- case 0:
- if (processor_entry(position, cpu))
- ++cpu;
- break;
- case 1:
- if (bus_entry(position, bus))
- ++bus;
- break;
- case 2:
- if (io_apic_entry(position, apic))
- ++apic;
- break;
- case 3:
- if (int_entry(position, intr))
- ++intr;
- break;
- case 4:
- /* int_entry(position); */
- break;
- default:
- panic("mpfps Base Table HOSED!");
- /* NOTREACHED */
- }
-
- totalSize -= basetable_entry_types[type].length;
- (u_char *) position += basetable_entry_types[type].length;
- }
-
- if (boot_cpu_id == -1)
- panic("NO BSP found!");
-
- /* report fact that its NOT a default configuration */
- return 0;
-}
-
-
-void
-assign_apic_irq(int apic, int intpin, int irq)
-{
- int x;
-
- if (int_to_apicintpin[irq].ioapic != -1)
- panic("assign_apic_irq: inconsistent table");
-
- int_to_apicintpin[irq].ioapic = apic;
- int_to_apicintpin[irq].int_pin = intpin;
- int_to_apicintpin[irq].apic_address = ioapic[apic];
- int_to_apicintpin[irq].redirindex = IOAPIC_REDTBL + 2 * intpin;
-
- for (x = 0; x < nintrs; x++) {
- if ((io_apic_ints[x].int_type == 0 ||
- io_apic_ints[x].int_type == 3) &&
- io_apic_ints[x].int_vector == 0xff &&
- io_apic_ints[x].dst_apic_id == IO_TO_ID(apic) &&
- io_apic_ints[x].dst_apic_int == intpin)
- io_apic_ints[x].int_vector = irq;
- }
-}
-
-void
-revoke_apic_irq(int irq)
-{
- int x;
- int oldapic;
- int oldintpin;
-
- if (int_to_apicintpin[irq].ioapic == -1)
- panic("assign_apic_irq: inconsistent table");
-
- oldapic = int_to_apicintpin[irq].ioapic;
- oldintpin = int_to_apicintpin[irq].int_pin;
-
- int_to_apicintpin[irq].ioapic = -1;
- int_to_apicintpin[irq].int_pin = 0;
- int_to_apicintpin[irq].apic_address = NULL;
- int_to_apicintpin[irq].redirindex = 0;
-
- for (x = 0; x < nintrs; x++) {
- if ((io_apic_ints[x].int_type == 0 ||
- io_apic_ints[x].int_type == 3) &&
- io_apic_ints[x].int_vector == 0xff &&
- io_apic_ints[x].dst_apic_id == IO_TO_ID(oldapic) &&
- io_apic_ints[x].dst_apic_int == oldintpin)
- io_apic_ints[x].int_vector = 0xff;
- }
-}
-
-/*
- * parse an Intel MP specification table
- */
-static void
-fix_mp_table(void)
-{
- int x;
- int id;
- int bus_0 = 0; /* Stop GCC warning */
- int bus_pci = 0; /* Stop GCC warning */
- int num_pci_bus;
-
- /*
- * Fix mis-numbering of the PCI bus and its INT entries if the BIOS
- * did it wrong. The MP spec says that when more than 1 PCI bus
- * exists the BIOS must begin with bus entries for the PCI bus and use
- * actual PCI bus numbering. This implies that when only 1 PCI bus
- * exists the BIOS can choose to ignore this ordering, and indeed many
- * MP motherboards do ignore it. This causes a problem when the PCI
- * sub-system makes requests of the MP sub-system based on PCI bus
- * numbers. So here we look for the situation and renumber the
- * busses and associated INTs in an effort to "make it right".
- */
-
- /* find bus 0, PCI bus, count the number of PCI busses */
- for (num_pci_bus = 0, x = 0; x < mp_nbusses; ++x) {
- if (bus_data[x].bus_id == 0) {
- bus_0 = x;
- }
- if (bus_data[x].bus_type == PCI) {
- ++num_pci_bus;
- bus_pci = x;
- }
- }
- /*
- * bus_0 == slot of bus with ID of 0
- * bus_pci == slot of last PCI bus encountered
- */
-
- /* check the 1 PCI bus case for sanity */
- if (num_pci_bus == 1) {
-
- /* if it is number 0 all is well */
- if (bus_data[bus_pci].bus_id == 0)
- return;
-
- /* mis-numbered, swap with whichever bus uses slot 0 */
-
- /* swap the bus entry types */
- bus_data[bus_pci].bus_type = bus_data[bus_0].bus_type;
- bus_data[bus_0].bus_type = PCI;
-
- /* swap each relavant INTerrupt entry */
- id = bus_data[bus_pci].bus_id;
- for (x = 0; x < nintrs; ++x) {
- if (io_apic_ints[x].src_bus_id == id) {
- io_apic_ints[x].src_bus_id = 0;
- }
- else if (io_apic_ints[x].src_bus_id == 0) {
- io_apic_ints[x].src_bus_id = id;
- }
- }
- }
-}
-
-
-/* Assign low level interrupt handlers */
-static void
-setup_apic_irq_mapping(void)
-{
- int x;
- int int_vector;
-
- /* Clear array */
- for (x = 0; x < APIC_INTMAPSIZE; x++) {
- int_to_apicintpin[x].ioapic = -1;
- int_to_apicintpin[x].int_pin = 0;
- int_to_apicintpin[x].apic_address = NULL;
- int_to_apicintpin[x].redirindex = 0;
- }
-
- /* First assign ISA/EISA interrupts */
- for (x = 0; x < nintrs; x++) {
- int_vector = io_apic_ints[x].src_bus_irq;
- if (int_vector < APIC_INTMAPSIZE &&
- io_apic_ints[x].int_vector == 0xff &&
- int_to_apicintpin[int_vector].ioapic == -1 &&
- (apic_int_is_bus_type(x, ISA) ||
- apic_int_is_bus_type(x, EISA)) &&
- io_apic_ints[x].int_type == 0) {
- assign_apic_irq(ID_TO_IO(io_apic_ints[x].dst_apic_id),
- io_apic_ints[x].dst_apic_int,
- int_vector);
- }
- }
-
- /* Assign interrupts on first 24 intpins on IOAPIC #0 */
- for (x = 0; x < nintrs; x++) {
- int_vector = io_apic_ints[x].dst_apic_int;
- if (int_vector < APIC_INTMAPSIZE &&
- io_apic_ints[x].dst_apic_id == IO_TO_ID(0) &&
- io_apic_ints[x].int_vector == 0xff &&
- int_to_apicintpin[int_vector].ioapic == -1 &&
- (io_apic_ints[x].int_type == 0 ||
- io_apic_ints[x].int_type == 3)) {
- assign_apic_irq(0,
- io_apic_ints[x].dst_apic_int,
- int_vector);
- }
- }
- /*
- * Assign interrupts for remaining intpins.
- * Skip IOAPIC #0 intpin 0 if the type is ExtInt, since this indicates
- * that an entry for ISA/EISA irq 0 exist, and a fallback to mixed mode
- * due to 8254 interrupts not being delivered can reuse that low level
- * interrupt handler.
- */
- int_vector = 0;
- while (int_vector < APIC_INTMAPSIZE &&
- int_to_apicintpin[int_vector].ioapic != -1)
- int_vector++;
- for (x = 0; x < nintrs && int_vector < APIC_INTMAPSIZE; x++) {
- if ((io_apic_ints[x].int_type == 0 ||
- (io_apic_ints[x].int_type == 3 &&
- (io_apic_ints[x].dst_apic_id != IO_TO_ID(0) ||
- io_apic_ints[x].dst_apic_int != 0))) &&
- io_apic_ints[x].int_vector == 0xff) {
- assign_apic_irq(ID_TO_IO(io_apic_ints[x].dst_apic_id),
- io_apic_ints[x].dst_apic_int,
- int_vector);
- int_vector++;
- while (int_vector < APIC_INTMAPSIZE &&
- int_to_apicintpin[int_vector].ioapic != -1)
- int_vector++;
- }
- }
-}
-
-
-static int
-processor_entry(proc_entry_ptr entry, int cpu)
-{
- /* check for usability */
- if (!(entry->cpu_flags & PROCENTRY_FLAG_EN))
- return 0;
-
- /* check for BSP flag */
- if (entry->cpu_flags & PROCENTRY_FLAG_BP) {
- boot_cpu_id = entry->apic_id;
- CPU_TO_ID(0) = entry->apic_id;
- ID_TO_CPU(entry->apic_id) = 0;
- return 0; /* its already been counted */
- }
-
- /* add another AP to list, if less than max number of CPUs */
- else if (cpu < NCPU) {
- CPU_TO_ID(cpu) = entry->apic_id;
- ID_TO_CPU(entry->apic_id) = cpu;
- return 1;
- }
-
- return 0;
-}
-
-
-static int
-bus_entry(bus_entry_ptr entry, int bus)
-{
- int x;
- char c, name[8];
-
- /* encode the name into an index */
- for (x = 0; x < 6; ++x) {
- if ((c = entry->bus_type[x]) == ' ')
- break;
- name[x] = c;
- }
- name[x] = '\0';
-
- if ((x = lookup_bus_type(name)) == UNKNOWN_BUSTYPE)
- panic("unknown bus type: '%s'", name);
-
- bus_data[bus].bus_id = entry->bus_id;
- bus_data[bus].bus_type = x;
-
- return 1;
-}
-
-
-static int
-io_apic_entry(io_apic_entry_ptr entry, int apic)
-{
- if (!(entry->apic_flags & IOAPICENTRY_FLAG_EN))
- return 0;
-
- IO_TO_ID(apic) = entry->apic_id;
- ID_TO_IO(entry->apic_id) = apic;
-
- return 1;
-}
-
-
-static int
-lookup_bus_type(char *name)
-{
- int x;
-
- for (x = 0; x < MAX_BUSTYPE; ++x)
- if (strcmp(bus_type_table[x].name, name) == 0)
- return bus_type_table[x].type;
-
- return UNKNOWN_BUSTYPE;
-}
-
-
-static int
-int_entry(int_entry_ptr entry, int intr)
-{
- int apic;
-
- io_apic_ints[intr].int_type = entry->int_type;
- io_apic_ints[intr].int_flags = entry->int_flags;
- io_apic_ints[intr].src_bus_id = entry->src_bus_id;
- io_apic_ints[intr].src_bus_irq = entry->src_bus_irq;
- if (entry->dst_apic_id == 255) {
- /* This signal goes to all IO APICS. Select an IO APIC
- with sufficient number of interrupt pins */
- for (apic = 0; apic < mp_napics; apic++)
- if (((io_apic_read(apic, IOAPIC_VER) &
- IOART_VER_MAXREDIR) >> MAXREDIRSHIFT) >=
- entry->dst_apic_int)
- break;
- if (apic < mp_napics)
- io_apic_ints[intr].dst_apic_id = IO_TO_ID(apic);
- else
- io_apic_ints[intr].dst_apic_id = entry->dst_apic_id;
- } else
- io_apic_ints[intr].dst_apic_id = entry->dst_apic_id;
- io_apic_ints[intr].dst_apic_int = entry->dst_apic_int;
-
- return 1;
-}
-
-
-static int
-apic_int_is_bus_type(int intr, int bus_type)
-{
- int bus;
-
- for (bus = 0; bus < mp_nbusses; ++bus)
- if ((bus_data[bus].bus_id == io_apic_ints[intr].src_bus_id)
- && ((int) bus_data[bus].bus_type == bus_type))
- return 1;
-
- return 0;
-}
-
-
-/*
- * Given a traditional ISA INT mask, return an APIC mask.
- */
-u_int
-isa_apic_mask(u_int isa_mask)
-{
- int isa_irq;
- int apic_pin;
-
-#if defined(SKIP_IRQ15_REDIRECT)
- if (isa_mask == (1 << 15)) {
- printf("skipping ISA IRQ15 redirect\n");
- return isa_mask;
- }
-#endif /* SKIP_IRQ15_REDIRECT */
-
- isa_irq = ffs(isa_mask); /* find its bit position */
- if (isa_irq == 0) /* doesn't exist */
- return 0;
- --isa_irq; /* make it zero based */
-
- apic_pin = isa_apic_irq(isa_irq); /* look for APIC connection */
- if (apic_pin == -1)
- return 0;
-
- return (1 << apic_pin); /* convert pin# to a mask */
-}
-
-
-/*
- * Determine which APIC pin an ISA/EISA INT is attached to.
- */
-#define INTTYPE(I) (io_apic_ints[(I)].int_type)
-#define INTPIN(I) (io_apic_ints[(I)].dst_apic_int)
-#define INTIRQ(I) (io_apic_ints[(I)].int_vector)
-#define INTAPIC(I) (ID_TO_IO(io_apic_ints[(I)].dst_apic_id))
-
-#define SRCBUSIRQ(I) (io_apic_ints[(I)].src_bus_irq)
-int
-isa_apic_irq(int isa_irq)
-{
- int intr;
-
- for (intr = 0; intr < nintrs; ++intr) { /* check each record */
- if (INTTYPE(intr) == 0) { /* standard INT */
- if (SRCBUSIRQ(intr) == isa_irq) {
- if (apic_int_is_bus_type(intr, ISA) ||
- apic_int_is_bus_type(intr, EISA))
- return INTIRQ(intr); /* found */
- }
- }
- }
- return -1; /* NOT found */
-}
-
-
-/*
- * Determine which APIC pin a PCI INT is attached to.
- */
-#define SRCBUSID(I) (io_apic_ints[(I)].src_bus_id)
-#define SRCBUSDEVICE(I) ((io_apic_ints[(I)].src_bus_irq >> 2) & 0x1f)
-#define SRCBUSLINE(I) (io_apic_ints[(I)].src_bus_irq & 0x03)
-int
-pci_apic_irq(int pciBus, int pciDevice, int pciInt)
-{
- int intr;
-
- --pciInt; /* zero based */
-
- for (intr = 0; intr < nintrs; ++intr) /* check each record */
- if ((INTTYPE(intr) == 0) /* standard INT */
- && (SRCBUSID(intr) == pciBus)
- && (SRCBUSDEVICE(intr) == pciDevice)
- && (SRCBUSLINE(intr) == pciInt)) /* a candidate IRQ */
- if (apic_int_is_bus_type(intr, PCI))
- return INTIRQ(intr); /* exact match */
-
- return -1; /* NOT found */
-}
-
-int
-next_apic_irq(int irq)
-{
- int intr, ointr;
- int bus, bustype;
-
- bus = 0;
- bustype = 0;
- for (intr = 0; intr < nintrs; intr++) {
- if (INTIRQ(intr) != irq || INTTYPE(intr) != 0)
- continue;
- bus = SRCBUSID(intr);
- bustype = apic_bus_type(bus);
- if (bustype != ISA &&
- bustype != EISA &&
- bustype != PCI)
- continue;
- break;
- }
- if (intr >= nintrs) {
- return -1;
- }
- for (ointr = intr + 1; ointr < nintrs; ointr++) {
- if (INTTYPE(ointr) != 0)
- continue;
- if (bus != SRCBUSID(ointr))
- continue;
- if (bustype == PCI) {
- if (SRCBUSDEVICE(intr) != SRCBUSDEVICE(ointr))
- continue;
- if (SRCBUSLINE(intr) != SRCBUSLINE(ointr))
- continue;
- }
- if (bustype == ISA || bustype == EISA) {
- if (SRCBUSIRQ(intr) != SRCBUSIRQ(ointr))
- continue;
- }
- if (INTPIN(intr) == INTPIN(ointr))
- continue;
- break;
- }
- if (ointr >= nintrs) {
- return -1;
- }
- return INTIRQ(ointr);
-}
-#undef SRCBUSLINE
-#undef SRCBUSDEVICE
-#undef SRCBUSID
-#undef SRCBUSIRQ
-
-#undef INTPIN
-#undef INTIRQ
-#undef INTAPIC
-#undef INTTYPE
-
-
-/*
- * Reprogram the MB chipset to NOT redirect an ISA INTerrupt.
- *
- * XXX FIXME:
- * Exactly what this means is unclear at this point. It is a solution
- * for motherboards that redirect the MBIRQ0 pin. Generically a motherboard
- * could route any of the ISA INTs to upper (>15) IRQ values. But most would
- * NOT be redirected via MBIRQ0, thus "undirect()ing" them would NOT be an
- * option.
- */
-int
-undirect_isa_irq(int rirq)
-{
-#if defined(READY)
- if (bootverbose)
- printf("Freeing redirected ISA irq %d.\n", rirq);
- /** FIXME: tickle the MB redirector chip */
- return ???;
-#else
- if (bootverbose)
- printf("Freeing (NOT implemented) redirected ISA irq %d.\n", rirq);
- return 0;
-#endif /* READY */
-}
-
-
-/*
- * Reprogram the MB chipset to NOT redirect a PCI INTerrupt
- */
-int
-undirect_pci_irq(int rirq)
-{
-#if defined(READY)
- if (bootverbose)
- printf("Freeing redirected PCI irq %d.\n", rirq);
-
- /** FIXME: tickle the MB redirector chip */
- return ???;
-#else
- if (bootverbose)
- printf("Freeing (NOT implemented) redirected PCI irq %d.\n",
- rirq);
- return 0;
-#endif /* READY */
-}
-
-
-/*
- * given a bus ID, return:
- * the bus type if found
- * -1 if NOT found
- */
-int
-apic_bus_type(int id)
-{
- int x;
-
- for (x = 0; x < mp_nbusses; ++x)
- if (bus_data[x].bus_id == id)
- return bus_data[x].bus_type;
-
- return -1;
-}
-
-
-/*
- * given a LOGICAL APIC# and pin#, return:
- * the associated src bus ID if found
- * -1 if NOT found
- */
-int
-apic_src_bus_id(int apic, int pin)
-{
- int x;
-
- /* search each of the possible INTerrupt sources */
- for (x = 0; x < nintrs; ++x)
- if ((apic == ID_TO_IO(io_apic_ints[x].dst_apic_id)) &&
- (pin == io_apic_ints[x].dst_apic_int))
- return (io_apic_ints[x].src_bus_id);
-
- return -1; /* NOT found */
-}
-
-
-/*
- * given a LOGICAL APIC# and pin#, return:
- * the associated src bus IRQ if found
- * -1 if NOT found
- */
-int
-apic_src_bus_irq(int apic, int pin)
-{
- int x;
-
- for (x = 0; x < nintrs; x++)
- if ((apic == ID_TO_IO(io_apic_ints[x].dst_apic_id)) &&
- (pin == io_apic_ints[x].dst_apic_int))
- return (io_apic_ints[x].src_bus_irq);
-
- return -1; /* NOT found */
-}
-
-
-/*
- * given a LOGICAL APIC# and pin#, return:
- * the associated INTerrupt type if found
- * -1 if NOT found
- */
-int
-apic_int_type(int apic, int pin)
-{
- int x;
-
- /* search each of the possible INTerrupt sources */
- for (x = 0; x < nintrs; ++x)
- if ((apic == ID_TO_IO(io_apic_ints[x].dst_apic_id)) &&
- (pin == io_apic_ints[x].dst_apic_int))
- return (io_apic_ints[x].int_type);
-
- return -1; /* NOT found */
-}
-
-int
-apic_irq(int apic, int pin)
-{
- int x;
- int res;
-
- for (x = 0; x < nintrs; ++x)
- if ((apic == ID_TO_IO(io_apic_ints[x].dst_apic_id)) &&
- (pin == io_apic_ints[x].dst_apic_int)) {
- res = io_apic_ints[x].int_vector;
- if (res == 0xff)
- return -1;
- if (apic != int_to_apicintpin[res].ioapic)
- panic("apic_irq: inconsistent table");
- if (pin != int_to_apicintpin[res].int_pin)
- panic("apic_irq inconsistent table (2)");
- return res;
- }
- return -1;
-}
-
-
-/*
- * given a LOGICAL APIC# and pin#, return:
- * the associated trigger mode if found
- * -1 if NOT found
- */
-int
-apic_trigger(int apic, int pin)
-{
- int x;
-
- /* search each of the possible INTerrupt sources */
- for (x = 0; x < nintrs; ++x)
- if ((apic == ID_TO_IO(io_apic_ints[x].dst_apic_id)) &&
- (pin == io_apic_ints[x].dst_apic_int))
- return ((io_apic_ints[x].int_flags >> 2) & 0x03);
-
- return -1; /* NOT found */
-}
-
-
-/*
- * given a LOGICAL APIC# and pin#, return:
- * the associated 'active' level if found
- * -1 if NOT found
- */
-int
-apic_polarity(int apic, int pin)
-{
- int x;
-
- /* search each of the possible INTerrupt sources */
- for (x = 0; x < nintrs; ++x)
- if ((apic == ID_TO_IO(io_apic_ints[x].dst_apic_id)) &&
- (pin == io_apic_ints[x].dst_apic_int))
- return (io_apic_ints[x].int_flags & 0x03);
-
- return -1; /* NOT found */
-}
-
-
-/*
- * set data according to MP defaults
- * FIXME: probably not complete yet...
- */
-static void
-default_mp_table(int type)
-{
- int ap_cpu_id;
-#if defined(APIC_IO)
- u_int32_t ux;
- int io_apic_id;
- int pin;
-#endif /* APIC_IO */
-
-#if 0
- printf(" MP default config type: %d\n", type);
- switch (type) {
- case 1:
- printf(" bus: ISA, APIC: 82489DX\n");
- break;
- case 2:
- printf(" bus: EISA, APIC: 82489DX\n");
- break;
- case 3:
- printf(" bus: EISA, APIC: 82489DX\n");
- break;
- case 4:
- printf(" bus: MCA, APIC: 82489DX\n");
- break;
- case 5:
- printf(" bus: ISA+PCI, APIC: Integrated\n");
- break;
- case 6:
- printf(" bus: EISA+PCI, APIC: Integrated\n");
- break;
- case 7:
- printf(" bus: MCA+PCI, APIC: Integrated\n");
- break;
- default:
- printf(" future type\n");
- break;
- /* NOTREACHED */
- }
-#endif /* 0 */
-
- boot_cpu_id = (lapic.id & APIC_ID_MASK) >> 24;
- ap_cpu_id = (boot_cpu_id == 0) ? 1 : 0;
-
- /* BSP */
- CPU_TO_ID(0) = boot_cpu_id;
- ID_TO_CPU(boot_cpu_id) = 0;
-
- /* one and only AP */
- CPU_TO_ID(1) = ap_cpu_id;
- ID_TO_CPU(ap_cpu_id) = 1;
-
-#if defined(APIC_IO)
- /* one and only IO APIC */
- io_apic_id = (io_apic_read(0, IOAPIC_ID) & APIC_ID_MASK) >> 24;
-
- /*
- * sanity check, refer to MP spec section 3.6.6, last paragraph
- * necessary as some hardware isn't properly setting up the IO APIC
- */
-#if defined(REALLY_ANAL_IOAPICID_VALUE)
- if (io_apic_id != 2) {
-#else
- if ((io_apic_id == 0) || (io_apic_id == 1) || (io_apic_id == 15)) {
-#endif /* REALLY_ANAL_IOAPICID_VALUE */
- ux = io_apic_read(0, IOAPIC_ID); /* get current contents */
- ux &= ~APIC_ID_MASK; /* clear the ID field */
- ux |= 0x02000000; /* set it to '2' */
- io_apic_write(0, IOAPIC_ID, ux); /* write new value */
- ux = io_apic_read(0, IOAPIC_ID); /* re-read && test */
- if ((ux & APIC_ID_MASK) != 0x02000000)
- panic("can't control IO APIC ID, reg: 0x%08x", ux);
- io_apic_id = 2;
- }
- IO_TO_ID(0) = io_apic_id;
- ID_TO_IO(io_apic_id) = 0;
-#endif /* APIC_IO */
-
- /* fill out bus entries */
- switch (type) {
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- bus_data[0].bus_id = default_data[type - 1][1];
- bus_data[0].bus_type = default_data[type - 1][2];
- bus_data[1].bus_id = default_data[type - 1][3];
- bus_data[1].bus_type = default_data[type - 1][4];
- break;
-
- /* case 4: case 7: MCA NOT supported */
- default: /* illegal/reserved */
- panic("BAD default MP config: %d", type);
- /* NOTREACHED */
- }
-
-#if defined(APIC_IO)
- /* general cases from MP v1.4, table 5-2 */
- for (pin = 0; pin < 16; ++pin) {
- io_apic_ints[pin].int_type = 0;
- io_apic_ints[pin].int_flags = 0x05; /* edge/active-hi */
- io_apic_ints[pin].src_bus_id = 0;
- io_apic_ints[pin].src_bus_irq = pin; /* IRQ2 caught below */
- io_apic_ints[pin].dst_apic_id = io_apic_id;
- io_apic_ints[pin].dst_apic_int = pin; /* 1-to-1 */
- }
-
- /* special cases from MP v1.4, table 5-2 */
- if (type == 2) {
- io_apic_ints[2].int_type = 0xff; /* N/C */
- io_apic_ints[13].int_type = 0xff; /* N/C */
-#if !defined(APIC_MIXED_MODE)
- /** FIXME: ??? */
- panic("sorry, can't support type 2 default yet");
-#endif /* APIC_MIXED_MODE */
- }
- else
- io_apic_ints[2].src_bus_irq = 0; /* ISA IRQ0 is on APIC INT 2 */
-
- if (type == 7)
- io_apic_ints[0].int_type = 0xff; /* N/C */
- else
- io_apic_ints[0].int_type = 3; /* vectored 8259 */
-#endif /* APIC_IO */
-}
-
-
-/*
- * initialize all the SMP locks
- */
-
-/* critical region around IO APIC, apic_imen */
-struct simplelock imen_lock;
-
-/* critical region around splxx(), cpl, cml, cil, ipending */
-struct simplelock cpl_lock;
-
-/* Make FAST_INTR() routines sequential */
-struct simplelock fast_intr_lock;
-
-/* critical region around INTR() routines */
-struct simplelock intr_lock;
-
-/* lock regions protected in UP kernel via cli/sti */
-struct simplelock mpintr_lock;
-
-/* lock region used by kernel profiling */
-struct simplelock mcount_lock;
-
-#ifdef USE_COMLOCK
-/* locks com (tty) data/hardware accesses: a FASTINTR() */
-struct simplelock com_lock;
-#endif /* USE_COMLOCK */
-
-#ifdef USE_CLOCKLOCK
-/* lock regions around the clock hardware */
-struct simplelock clock_lock;
-#endif /* USE_CLOCKLOCK */
-
-/* lock around the MP rendezvous */
-static struct simplelock smp_rv_lock;
-
-static void
-init_locks(void)
-{
- /*
- * Get the initial mp_lock with a count of 1 for the BSP.
- * This uses a LOGICAL cpu ID, ie BSP == 0.
- */
- mp_lock = 0x00000001;
-
- /* ISR uses its own "giant lock" */
- isr_lock = FREE_LOCK;
-
-#if defined(APIC_INTR_DIAGNOSTIC) && defined(APIC_INTR_DIAGNOSTIC_IRQ)
- s_lock_init((struct simplelock*)&apic_itrace_debuglock);
-#endif
-
- s_lock_init((struct simplelock*)&mpintr_lock);
-
- s_lock_init((struct simplelock*)&mcount_lock);
-
- s_lock_init((struct simplelock*)&fast_intr_lock);
- s_lock_init((struct simplelock*)&intr_lock);
- s_lock_init((struct simplelock*)&imen_lock);
- s_lock_init((struct simplelock*)&cpl_lock);
- s_lock_init(&smp_rv_lock);
-
-#ifdef USE_COMLOCK
- s_lock_init((struct simplelock*)&com_lock);
-#endif /* USE_COMLOCK */
-#ifdef USE_CLOCKLOCK
- s_lock_init((struct simplelock*)&clock_lock);
-#endif /* USE_CLOCKLOCK */
-}
-
-
-/* Wait for all APs to be fully initialized */
-extern int wait_ap(unsigned int);
-
-/*
- * start each AP in our list
- */
-static int
-start_all_aps(u_int boot_addr)
-{
- int x, i, pg;
- u_char mpbiosreason;
- u_long mpbioswarmvec;
- struct globaldata *gd;
- char *stack;
-
- POSTCODE(START_ALL_APS_POST);
-
- /* initialize BSP's local APIC */
- apic_initialize();
- bsp_apic_ready = 1;
-
- /* install the AP 1st level boot code */
- install_ap_tramp(boot_addr);
-
-
- /* save the current value of the warm-start vector */
- mpbioswarmvec = *((u_long *) WARMBOOT_OFF);
-#ifndef PC98
- outb(CMOS_REG, BIOS_RESET);
- mpbiosreason = inb(CMOS_DATA);
-#endif
-
- /* record BSP in CPU map */
- all_cpus = 1;
-
- /* set up 0 -> 4MB P==V mapping for AP boot */
- *(int *)PTD = PG_V | PG_RW | ((uintptr_t)(void *)KPTphys & PG_FRAME);
- invltlb();
-
- /* start each AP */
- for (x = 1; x <= mp_naps; ++x) {
-
- /* This is a bit verbose, it will go away soon. */
-
- /* first page of AP's private space */
- pg = x * i386_btop(sizeof(struct privatespace));
-
- /* allocate a new private data page */
- gd = (struct globaldata *)kmem_alloc(kernel_map, PAGE_SIZE);
-
- /* wire it into the private page table page */
- SMPpt[pg] = (pt_entry_t)(PG_V | PG_RW | vtophys(gd));
-
- /* allocate and set up an idle stack data page */
- stack = (char *)kmem_alloc(kernel_map, UPAGES*PAGE_SIZE);
- for (i = 0; i < UPAGES; i++)
- SMPpt[pg + 5 + i] = (pt_entry_t)
- (PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack));
-
- SMPpt[pg + 1] = 0; /* *prv_CMAP1 */
- SMPpt[pg + 2] = 0; /* *prv_CMAP2 */
- SMPpt[pg + 3] = 0; /* *prv_CMAP3 */
- SMPpt[pg + 4] = 0; /* *prv_PMAP1 */
-
- /* prime data page for it to use */
- gd->gd_cpuid = x;
- gd->gd_cpu_lockid = x << 24;
- gd->gd_prv_CMAP1 = &SMPpt[pg + 1];
- gd->gd_prv_CMAP2 = &SMPpt[pg + 2];
- gd->gd_prv_CMAP3 = &SMPpt[pg + 3];
- gd->gd_prv_PMAP1 = &SMPpt[pg + 4];
- gd->gd_prv_CADDR1 = SMP_prvspace[x].CPAGE1;
- gd->gd_prv_CADDR2 = SMP_prvspace[x].CPAGE2;
- gd->gd_prv_CADDR3 = SMP_prvspace[x].CPAGE3;
- gd->gd_prv_PADDR1 = (unsigned *)SMP_prvspace[x].PPAGE1;
-
- /* setup a vector to our boot code */
- *((volatile u_short *) WARMBOOT_OFF) = WARMBOOT_TARGET;
- *((volatile u_short *) WARMBOOT_SEG) = (boot_addr >> 4);
-#ifndef PC98
- outb(CMOS_REG, BIOS_RESET);
- outb(CMOS_DATA, BIOS_WARM); /* 'warm-start' */
-#endif
-
- bootSTK = &SMP_prvspace[x].idlestack[UPAGES*PAGE_SIZE];
- bootAP = x;
-
- /* attempt to start the Application Processor */
- CHECK_INIT(99); /* setup checkpoints */
- if (!start_ap(x, boot_addr)) {
- printf("AP #%d (PHY# %d) failed!\n", x, CPU_TO_ID(x));
- CHECK_PRINT("trace"); /* show checkpoints */
- /* better panic as the AP may be running loose */
- printf("panic y/n? [y] ");
- if (cngetc() != 'n')
- panic("bye-bye");
- }
- CHECK_PRINT("trace"); /* show checkpoints */
-
- /* record its version info */
- cpu_apic_versions[x] = cpu_apic_versions[0];
-
- all_cpus |= (1 << x); /* record AP in CPU map */
- }
-
- /* build our map of 'other' CPUs */
- other_cpus = all_cpus & ~(1 << cpuid);
-
- /* fill in our (BSP) APIC version */
- cpu_apic_versions[0] = lapic.version;
-
- /* restore the warmstart vector */
- *(u_long *) WARMBOOT_OFF = mpbioswarmvec;
-#ifndef PC98
- outb(CMOS_REG, BIOS_RESET);
- outb(CMOS_DATA, mpbiosreason);
-#endif
-
- /*
- * Set up the idle context for the BSP. Similar to above except
- * that some was done by locore, some by pmap.c and some is implicit
- * because the BSP is cpu#0 and the page is initially zero, and also
- * because we can refer to variables by name on the BSP..
- */
-
- /* Allocate and setup BSP idle stack */
- stack = (char *)kmem_alloc(kernel_map, UPAGES * PAGE_SIZE);
- for (i = 0; i < UPAGES; i++)
- SMPpt[5 + i] = (pt_entry_t)
- (PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack));
-
- *(int *)PTD = 0;
- pmap_set_opt();
-
- /* number of APs actually started */
- return mp_ncpus - 1;
-}
-
-
-/*
- * load the 1st level AP boot code into base memory.
- */
-
-/* targets for relocation */
-extern void bigJump(void);
-extern void bootCodeSeg(void);
-extern void bootDataSeg(void);
-extern void MPentry(void);
-extern u_int MP_GDT;
-extern u_int mp_gdtbase;
-
-static void
-install_ap_tramp(u_int boot_addr)
-{
- int x;
- int size = *(int *) ((u_long) & bootMP_size);
- u_char *src = (u_char *) ((u_long) bootMP);
- u_char *dst = (u_char *) boot_addr + KERNBASE;
- u_int boot_base = (u_int) bootMP;
- u_int8_t *dst8;
- u_int16_t *dst16;
- u_int32_t *dst32;
-
- POSTCODE(INSTALL_AP_TRAMP_POST);
-
- for (x = 0; x < size; ++x)
- *dst++ = *src++;
-
- /*
- * modify addresses in code we just moved to basemem. unfortunately we
- * need fairly detailed info about mpboot.s for this to work. changes
- * to mpboot.s might require changes here.
- */
-
- /* boot code is located in KERNEL space */
- dst = (u_char *) boot_addr + KERNBASE;
-
- /* modify the lgdt arg */
- dst32 = (u_int32_t *) (dst + ((u_int) & mp_gdtbase - boot_base));
- *dst32 = boot_addr + ((u_int) & MP_GDT - boot_base);
-
- /* modify the ljmp target for MPentry() */
- dst32 = (u_int32_t *) (dst + ((u_int) bigJump - boot_base) + 1);
- *dst32 = ((u_int) MPentry - KERNBASE);
-
- /* modify the target for boot code segment */
- dst16 = (u_int16_t *) (dst + ((u_int) bootCodeSeg - boot_base));
- dst8 = (u_int8_t *) (dst16 + 1);
- *dst16 = (u_int) boot_addr & 0xffff;
- *dst8 = ((u_int) boot_addr >> 16) & 0xff;
-
- /* modify the target for boot data segment */
- dst16 = (u_int16_t *) (dst + ((u_int) bootDataSeg - boot_base));
- dst8 = (u_int8_t *) (dst16 + 1);
- *dst16 = (u_int) boot_addr & 0xffff;
- *dst8 = ((u_int) boot_addr >> 16) & 0xff;
-}
-
-
-/*
- * this function starts the AP (application processor) identified
- * by the APIC ID 'physicalCpu'. It does quite a "song and dance"
- * to accomplish this. This is necessary because of the nuances
- * of the different hardware we might encounter. It ain't pretty,
- * but it seems to work.
- */
-static int
-start_ap(int logical_cpu, u_int boot_addr)
-{
- int physical_cpu;
- int vector;
- int cpus;
- u_long icr_lo, icr_hi;
-
- POSTCODE(START_AP_POST);
-
- /* get the PHYSICAL APIC ID# */
- physical_cpu = CPU_TO_ID(logical_cpu);
-
- /* calculate the vector */
- vector = (boot_addr >> 12) & 0xff;
-
- /* used as a watchpoint to signal AP startup */
- cpus = mp_ncpus;
-
- /*
- * first we do an INIT/RESET IPI this INIT IPI might be run, reseting
- * and running the target CPU. OR this INIT IPI might be latched (P5
- * bug), CPU waiting for STARTUP IPI. OR this INIT IPI might be
- * ignored.
- */
-
- /* setup the address for the target AP */
- icr_hi = lapic.icr_hi & ~APIC_ID_MASK;
- icr_hi |= (physical_cpu << 24);
- lapic.icr_hi = icr_hi;
-
- /* do an INIT IPI: assert RESET */
- icr_lo = lapic.icr_lo & 0xfff00000;
- lapic.icr_lo = icr_lo | 0x0000c500;
-
- /* wait for pending status end */
- while (lapic.icr_lo & APIC_DELSTAT_MASK)
- /* spin */ ;
-
- /* do an INIT IPI: deassert RESET */
- lapic.icr_lo = icr_lo | 0x00008500;
-
- /* wait for pending status end */
- u_sleep(10000); /* wait ~10mS */
- while (lapic.icr_lo & APIC_DELSTAT_MASK)
- /* spin */ ;
-
- /*
- * next we do a STARTUP IPI: the previous INIT IPI might still be
- * latched, (P5 bug) this 1st STARTUP would then terminate
- * immediately, and the previously started INIT IPI would continue. OR
- * the previous INIT IPI has already run. and this STARTUP IPI will
- * run. OR the previous INIT IPI was ignored. and this STARTUP IPI
- * will run.
- */
-
- /* do a STARTUP IPI */
- lapic.icr_lo = icr_lo | 0x00000600 | vector;
- while (lapic.icr_lo & APIC_DELSTAT_MASK)
- /* spin */ ;
- u_sleep(200); /* wait ~200uS */
-
- /*
- * finally we do a 2nd STARTUP IPI: this 2nd STARTUP IPI should run IF
- * the previous STARTUP IPI was cancelled by a latched INIT IPI. OR
- * this STARTUP IPI will be ignored, as only ONE STARTUP IPI is
- * recognized after hardware RESET or INIT IPI.
- */
-
- lapic.icr_lo = icr_lo | 0x00000600 | vector;
- while (lapic.icr_lo & APIC_DELSTAT_MASK)
- /* spin */ ;
- u_sleep(200); /* wait ~200uS */
-
- /* wait for it to start */
- set_apic_timer(5000000);/* == 5 seconds */
- while (read_apic_timer())
- if (mp_ncpus > cpus)
- return 1; /* return SUCCESS */
-
- return 0; /* return FAILURE */
-}
-
-
-/*
- * Flush the TLB on all other CPU's
- *
- * XXX: Needs to handshake and wait for completion before proceding.
- */
-void
-smp_invltlb(void)
-{
-#if defined(APIC_IO)
- if (smp_started && invltlb_ok)
- all_but_self_ipi(XINVLTLB_OFFSET);
-#endif /* APIC_IO */
-}
-
-void
-invlpg(u_int addr)
-{
- __asm __volatile("invlpg (%0)"::"r"(addr):"memory");
-
- /* send a message to the other CPUs */
- smp_invltlb();
-}
-
-void
-invltlb(void)
-{
- u_long temp;
-
- /*
- * This should be implemented as load_cr3(rcr3()) when load_cr3() is
- * inlined.
- */
- __asm __volatile("movl %%cr3, %0; movl %0, %%cr3":"=r"(temp) :: "memory");
-
- /* send a message to the other CPUs */
- smp_invltlb();
-}
-
-
-/*
- * When called the executing CPU will send an IPI to all other CPUs
- * requesting that they halt execution.
- *
- * Usually (but not necessarily) called with 'other_cpus' as its arg.
- *
- * - Signals all CPUs in map to stop.
- * - Waits for each to stop.
- *
- * Returns:
- * -1: error
- * 0: NA
- * 1: ok
- *
- * XXX FIXME: this is not MP-safe, needs a lock to prevent multiple CPUs
- * from executing at same time.
- */
-int
-stop_cpus(u_int map)
-{
- if (!smp_started)
- return 0;
-
- /* send the Xcpustop IPI to all CPUs in map */
- selected_apic_ipi(map, XCPUSTOP_OFFSET, APIC_DELMODE_FIXED);
-
- while ((stopped_cpus & map) != map)
- /* spin */ ;
-
- return 1;
-}
-
-
-/*
- * Called by a CPU to restart stopped CPUs.
- *
- * Usually (but not necessarily) called with 'stopped_cpus' as its arg.
- *
- * - Signals all CPUs in map to restart.
- * - Waits for each to restart.
- *
- * Returns:
- * -1: error
- * 0: NA
- * 1: ok
- */
-int
-restart_cpus(u_int map)
-{
- if (!smp_started)
- return 0;
-
- started_cpus = map; /* signal other cpus to restart */
-
- while ((stopped_cpus & map) != 0) /* wait for each to clear its bit */
- /* spin */ ;
-
- return 1;
-}
-
-int smp_active = 0; /* are the APs allowed to run? */
-SYSCTL_INT(_machdep, OID_AUTO, smp_active, CTLFLAG_RW, &smp_active, 0, "");
-
-/* XXX maybe should be hw.ncpu */
-static int smp_cpus = 1; /* how many cpu's running */
-SYSCTL_INT(_machdep, OID_AUTO, smp_cpus, CTLFLAG_RD, &smp_cpus, 0, "");
-
-int invltlb_ok = 0; /* throttle smp_invltlb() till safe */
-SYSCTL_INT(_machdep, OID_AUTO, invltlb_ok, CTLFLAG_RW, &invltlb_ok, 0, "");
-
-/* Warning: Do not staticize. Used from swtch.s */
-int do_page_zero_idle = 1; /* bzero pages for fun and profit in idleloop */
-SYSCTL_INT(_machdep, OID_AUTO, do_page_zero_idle, CTLFLAG_RW,
- &do_page_zero_idle, 0, "");
-
-/* Is forwarding of a interrupt to the CPU holding the ISR lock enabled ? */
-int forward_irq_enabled = 1;
-SYSCTL_INT(_machdep, OID_AUTO, forward_irq_enabled, CTLFLAG_RW,
- &forward_irq_enabled, 0, "");
-
-/* Enable forwarding of a signal to a process running on a different CPU */
-static int forward_signal_enabled = 1;
-SYSCTL_INT(_machdep, OID_AUTO, forward_signal_enabled, CTLFLAG_RW,
- &forward_signal_enabled, 0, "");
-
-/* Enable forwarding of roundrobin to all other cpus */
-static int forward_roundrobin_enabled = 1;
-SYSCTL_INT(_machdep, OID_AUTO, forward_roundrobin_enabled, CTLFLAG_RW,
- &forward_roundrobin_enabled, 0, "");
-
-/*
- * This is called once the rest of the system is up and running and we're
- * ready to let the AP's out of the pen.
- */
-void ap_init(void);
-
-void
-ap_init()
-{
- u_int apic_id;
-
- /* BSP may have changed PTD while we're waiting for the lock */
- cpu_invltlb();
-
- smp_cpus++;
-
-#if defined(I586_CPU) && !defined(NO_F00F_HACK)
- lidt(&r_idt);
-#endif
-
- /* Build our map of 'other' CPUs. */
- other_cpus = all_cpus & ~(1 << cpuid);
-
- printf("SMP: AP CPU #%d Launched!\n", cpuid);
-
- /* XXX FIXME: i386 specific, and redundant: Setup the FPU. */
- load_cr0((rcr0() & ~CR0_EM) | CR0_MP | CR0_NE | CR0_TS);
-
- /* set up FPU state on the AP */
- npxinit(__INITIAL_NPXCW__);
-
- /* A quick check from sanity claus */
- apic_id = (apic_id_to_logical[(lapic.id & 0x0f000000) >> 24]);
- if (cpuid != apic_id) {
- printf("SMP: cpuid = %d\n", cpuid);
- printf("SMP: apic_id = %d\n", apic_id);
- printf("PTD[MPPTDI] = %p\n", (void *)PTD[MPPTDI]);
- panic("cpuid mismatch! boom!!");
- }
-
- /* Init local apic for irq's */
- apic_initialize();
-
- /* Set memory range attributes for this CPU to match the BSP */
- mem_range_AP_init();
-
- /*
- * Activate smp_invltlb, although strictly speaking, this isn't
- * quite correct yet. We should have a bitfield for cpus willing
- * to accept TLB flush IPI's or something and sync them.
- */
- if (smp_cpus == mp_ncpus) {
- invltlb_ok = 1;
- smp_started = 1; /* enable IPI's, tlb shootdown, freezes etc */
- smp_active = 1; /* historic */
- }
-}
-
-#ifdef BETTER_CLOCK
-
-#define CHECKSTATE_USER 0
-#define CHECKSTATE_SYS 1
-#define CHECKSTATE_INTR 2
-
-/* Do not staticize. Used from apic_vector.s */
-struct proc* checkstate_curproc[NCPU];
-int checkstate_cpustate[NCPU];
-u_long checkstate_pc[NCPU];
-
-extern long cp_time[CPUSTATES];
-
-#define PC_TO_INDEX(pc, prof) \
- ((int)(((u_quad_t)((pc) - (prof)->pr_off) * \
- (u_quad_t)((prof)->pr_scale)) >> 16) & ~1)
-
-static void
-addupc_intr_forwarded(struct proc *p, int id, int *astmap)
-{
- int i;
- struct uprof *prof;
- u_long pc;
-
- pc = checkstate_pc[id];
- prof = &p->p_stats->p_prof;
- if (pc >= prof->pr_off &&
- (i = PC_TO_INDEX(pc, prof)) < prof->pr_size) {
- if ((p->p_flag & P_OWEUPC) == 0) {
- prof->pr_addr = pc;
- prof->pr_ticks = 1;
- p->p_flag |= P_OWEUPC;
- }
- *astmap |= (1 << id);
- }
-}
-
-static void
-forwarded_statclock(int id, int pscnt, int *astmap)
-{
- struct pstats *pstats;
- long rss;
- struct rusage *ru;
- struct vmspace *vm;
- int cpustate;
- struct proc *p;
-#ifdef GPROF
- register struct gmonparam *g;
- int i;
-#endif
-
- p = checkstate_curproc[id];
- cpustate = checkstate_cpustate[id];
-
- switch (cpustate) {
- case CHECKSTATE_USER:
- if (p->p_flag & P_PROFIL)
- addupc_intr_forwarded(p, id, astmap);
- if (pscnt > 1)
- return;
- p->p_uticks++;
- if (p->p_nice > NZERO)
- cp_time[CP_NICE]++;
- else
- cp_time[CP_USER]++;
- break;
- case CHECKSTATE_SYS:
-#ifdef GPROF
- /*
- * Kernel statistics are just like addupc_intr, only easier.
- */
- g = &_gmonparam;
- if (g->state == GMON_PROF_ON) {
- i = checkstate_pc[id] - g->lowpc;
- if (i < g->textsize) {
- i /= HISTFRACTION * sizeof(*g->kcount);
- g->kcount[i]++;
- }
- }
-#endif
- if (pscnt > 1)
- return;
-
- if (!p)
- cp_time[CP_IDLE]++;
- else {
- p->p_sticks++;
- cp_time[CP_SYS]++;
- }
- break;
- case CHECKSTATE_INTR:
- default:
-#ifdef GPROF
- /*
- * Kernel statistics are just like addupc_intr, only easier.
- */
- g = &_gmonparam;
- if (g->state == GMON_PROF_ON) {
- i = checkstate_pc[id] - g->lowpc;
- if (i < g->textsize) {
- i /= HISTFRACTION * sizeof(*g->kcount);
- g->kcount[i]++;
- }
- }
-#endif
- if (pscnt > 1)
- return;
- if (p)
- p->p_iticks++;
- cp_time[CP_INTR]++;
- }
- if (p != NULL) {
- schedclock(p);
-
- /* Update resource usage integrals and maximums. */
- if ((pstats = p->p_stats) != NULL &&
- (ru = &pstats->p_ru) != NULL &&
- (vm = p->p_vmspace) != NULL) {
- ru->ru_ixrss += pgtok(vm->vm_tsize);
- ru->ru_idrss += pgtok(vm->vm_dsize);
- ru->ru_isrss += pgtok(vm->vm_ssize);
- rss = pgtok(vmspace_resident_count(vm));
- if (ru->ru_maxrss < rss)
- ru->ru_maxrss = rss;
- }
- }
-}
-
-void
-forward_statclock(int pscnt)
-{
- int map;
- int id;
- int i;
-
- /* Kludge. We don't yet have separate locks for the interrupts
- * and the kernel. This means that we cannot let the other processors
- * handle complex interrupts while inhibiting them from entering
- * the kernel in a non-interrupt context.
- *
- * What we can do, without changing the locking mechanisms yet,
- * is letting the other processors handle a very simple interrupt
- * (wich determines the processor states), and do the main
- * work ourself.
- */
-
- if (!smp_started || !invltlb_ok || cold || panicstr)
- return;
-
- /* Step 1: Probe state (user, cpu, interrupt, spinlock, idle ) */
-
- map = other_cpus & ~stopped_cpus ;
- checkstate_probed_cpus = 0;
- if (map != 0)
- selected_apic_ipi(map,
- XCPUCHECKSTATE_OFFSET, APIC_DELMODE_FIXED);
-
- i = 0;
- while (checkstate_probed_cpus != map) {
- /* spin */
- i++;
- if (i == 100000) {
-#ifdef BETTER_CLOCK_DIAGNOSTIC
- printf("forward_statclock: checkstate %x\n",
- checkstate_probed_cpus);
-#endif
- break;
- }
- }
-
- /*
- * Step 2: walk through other processors processes, update ticks and
- * profiling info.
- */
-
- map = 0;
- for (id = 0; id < mp_ncpus; id++) {
- if (id == cpuid)
- continue;
- if (((1 << id) & checkstate_probed_cpus) == 0)
- continue;
- forwarded_statclock(id, pscnt, &map);
- }
- if (map != 0) {
- checkstate_need_ast |= map;
- selected_apic_ipi(map, XCPUAST_OFFSET, APIC_DELMODE_FIXED);
- i = 0;
- while ((checkstate_need_ast & map) != 0) {
- /* spin */
- i++;
- if (i > 100000) {
-#ifdef BETTER_CLOCK_DIAGNOSTIC
- printf("forward_statclock: dropped ast 0x%x\n",
- checkstate_need_ast & map);
-#endif
- break;
- }
- }
- }
-}
-
-void
-forward_hardclock(int pscnt)
-{
- int map;
- int id;
- struct proc *p;
- struct pstats *pstats;
- int i;
-
- /* Kludge. We don't yet have separate locks for the interrupts
- * and the kernel. This means that we cannot let the other processors
- * handle complex interrupts while inhibiting them from entering
- * the kernel in a non-interrupt context.
- *
- * What we can do, without changing the locking mechanisms yet,
- * is letting the other processors handle a very simple interrupt
- * (wich determines the processor states), and do the main
- * work ourself.
- */
-
- if (!smp_started || !invltlb_ok || cold || panicstr)
- return;
-
- /* Step 1: Probe state (user, cpu, interrupt, spinlock, idle) */
-
- map = other_cpus & ~stopped_cpus ;
- checkstate_probed_cpus = 0;
- if (map != 0)
- selected_apic_ipi(map,
- XCPUCHECKSTATE_OFFSET, APIC_DELMODE_FIXED);
-
- i = 0;
- while (checkstate_probed_cpus != map) {
- /* spin */
- i++;
- if (i == 100000) {
-#ifdef BETTER_CLOCK_DIAGNOSTIC
- printf("forward_hardclock: checkstate %x\n",
- checkstate_probed_cpus);
-#endif
- break;
- }
- }
-
- /*
- * Step 2: walk through other processors processes, update virtual
- * timer and profiling timer. If stathz == 0, also update ticks and
- * profiling info.
- */
-
- map = 0;
- for (id = 0; id < mp_ncpus; id++) {
- if (id == cpuid)
- continue;
- if (((1 << id) & checkstate_probed_cpus) == 0)
- continue;
- p = checkstate_curproc[id];
- if (p) {
- pstats = p->p_stats;
- if (checkstate_cpustate[id] == CHECKSTATE_USER &&
- timevalisset(&pstats->p_timer[ITIMER_VIRTUAL].it_value) &&
- itimerdecr(&pstats->p_timer[ITIMER_VIRTUAL], tick) == 0) {
- psignal(p, SIGVTALRM);
- map |= (1 << id);
- }
- if (timevalisset(&pstats->p_timer[ITIMER_PROF].it_value) &&
- itimerdecr(&pstats->p_timer[ITIMER_PROF], tick) == 0) {
- psignal(p, SIGPROF);
- map |= (1 << id);
- }
- }
- if (stathz == 0) {
- forwarded_statclock( id, pscnt, &map);
- }
- }
- if (map != 0) {
- checkstate_need_ast |= map;
- selected_apic_ipi(map, XCPUAST_OFFSET, APIC_DELMODE_FIXED);
- i = 0;
- while ((checkstate_need_ast & map) != 0) {
- /* spin */
- i++;
- if (i > 100000) {
-#ifdef BETTER_CLOCK_DIAGNOSTIC
- printf("forward_hardclock: dropped ast 0x%x\n",
- checkstate_need_ast & map);
-#endif
- break;
- }
- }
- }
-}
-
-#endif /* BETTER_CLOCK */
-
-void
-forward_signal(struct proc *p)
-{
- int map;
- int id;
- int i;
-
- /* Kludge. We don't yet have separate locks for the interrupts
- * and the kernel. This means that we cannot let the other processors
- * handle complex interrupts while inhibiting them from entering
- * the kernel in a non-interrupt context.
- *
- * What we can do, without changing the locking mechanisms yet,
- * is letting the other processors handle a very simple interrupt
- * (wich determines the processor states), and do the main
- * work ourself.
- */
-
- if (!smp_started || !invltlb_ok || cold || panicstr)
- return;
- if (!forward_signal_enabled)
- return;
- while (1) {
- if (p->p_stat != SRUN)
- return;
- id = p->p_oncpu;
- if (id == 0xff)
- return;
- map = (1<<id);
- checkstate_need_ast |= map;
- selected_apic_ipi(map, XCPUAST_OFFSET, APIC_DELMODE_FIXED);
- i = 0;
- while ((checkstate_need_ast & map) != 0) {
- /* spin */
- i++;
- if (i > 100000) {
-#if 0
- printf("forward_signal: dropped ast 0x%x\n",
- checkstate_need_ast & map);
-#endif
- break;
- }
- }
- if (id == p->p_oncpu)
- return;
- }
-}
-
-void
-forward_roundrobin(void)
-{
- u_int map;
- int i;
-
- if (!smp_started || !invltlb_ok || cold || panicstr)
- return;
- if (!forward_roundrobin_enabled)
- return;
- resched_cpus |= other_cpus;
- map = other_cpus & ~stopped_cpus ;
-#if 1
- selected_apic_ipi(map, XCPUAST_OFFSET, APIC_DELMODE_FIXED);
-#else
- (void) all_but_self_ipi(XCPUAST_OFFSET);
-#endif
- i = 0;
- while ((checkstate_need_ast & map) != 0) {
- /* spin */
- i++;
- if (i > 100000) {
-#if 0
- printf("forward_roundrobin: dropped ast 0x%x\n",
- checkstate_need_ast & map);
-#endif
- break;
- }
- }
-}
-
-
-#ifdef APIC_INTR_REORDER
-/*
- * Maintain mapping from softintr vector to isr bit in local apic.
- */
-void
-set_lapic_isrloc(int intr, int vector)
-{
- if (intr < 0 || intr > 32)
- panic("set_apic_isrloc: bad intr argument: %d",intr);
- if (vector < ICU_OFFSET || vector > 255)
- panic("set_apic_isrloc: bad vector argument: %d",vector);
- apic_isrbit_location[intr].location = &lapic.isr0 + ((vector>>5)<<2);
- apic_isrbit_location[intr].bit = (1<<(vector & 31));
-}
-#endif
-
-/*
- * All-CPU rendezvous. CPUs are signalled, all execute the setup function
- * (if specified), rendezvous, execute the action function (if specified),
- * rendezvous again, execute the teardown function (if specified), and then
- * resume.
- *
- * Note that the supplied external functions _must_ be reentrant and aware
- * that they are running in parallel and in an unknown lock context.
- */
-static void (*smp_rv_setup_func)(void *arg);
-static void (*smp_rv_action_func)(void *arg);
-static void (*smp_rv_teardown_func)(void *arg);
-static void *smp_rv_func_arg;
-static volatile int smp_rv_waiters[2];
-
-void
-smp_rendezvous_action(void)
-{
- /* setup function */
- if (smp_rv_setup_func != NULL)
- smp_rv_setup_func(smp_rv_func_arg);
- /* spin on entry rendezvous */
- atomic_add_int(&smp_rv_waiters[0], 1);
- while (smp_rv_waiters[0] < mp_ncpus)
- ;
- /* action function */
- if (smp_rv_action_func != NULL)
- smp_rv_action_func(smp_rv_func_arg);
- /* spin on exit rendezvous */
- atomic_add_int(&smp_rv_waiters[1], 1);
- while (smp_rv_waiters[1] < mp_ncpus)
- ;
- /* teardown function */
- if (smp_rv_teardown_func != NULL)
- smp_rv_teardown_func(smp_rv_func_arg);
-}
-
-void
-smp_rendezvous(void (* setup_func)(void *),
- void (* action_func)(void *),
- void (* teardown_func)(void *),
- void *arg)
-{
- u_int efl;
-
- /* obtain rendezvous lock */
- s_lock(&smp_rv_lock); /* XXX sleep here? NOWAIT flag? */
-
- /* set static function pointers */
- smp_rv_setup_func = setup_func;
- smp_rv_action_func = action_func;
- smp_rv_teardown_func = teardown_func;
- smp_rv_func_arg = arg;
- smp_rv_waiters[0] = 0;
- smp_rv_waiters[1] = 0;
-
- /* disable interrupts on this CPU, save interrupt status */
- efl = read_eflags();
- write_eflags(efl & ~PSL_I);
-
- /* signal other processors, which will enter the IPI with interrupts off */
- all_but_self_ipi(XRENDEZVOUS_OFFSET);
-
- /* call executor function */
- smp_rendezvous_action();
-
- /* restore interrupt flag */
- write_eflags(efl);
-
- /* release lock */
- s_unlock(&smp_rv_lock);
-}
diff --git a/sys/amd64/include/npx.h b/sys/amd64/include/npx.h
deleted file mode 100644
index 695ab2a5b61c..000000000000
--- a/sys/amd64/include/npx.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)npx.h 5.3 (Berkeley) 1/18/91
- * $FreeBSD$
- */
-
-/*
- * 287/387 NPX Coprocessor Data Structures and Constants
- * W. Jolitz 1/90
- */
-
-#ifndef _MACHINE_NPX_H_
-#define _MACHINE_NPX_H_
-
-#include <machine/globals.h>
-
-/* Environment information of floating point unit */
-struct env87 {
- long en_cw; /* control word (16bits) */
- long en_sw; /* status word (16bits) */
- long en_tw; /* tag word (16bits) */
- long en_fip; /* floating point instruction pointer */
- u_short en_fcs; /* floating code segment selector */
- u_short en_opcode; /* opcode last executed (11 bits ) */
- long en_foo; /* floating operand offset */
- long en_fos; /* floating operand segment selector */
-};
-
-/* Contents of each floating point accumulator */
-struct fpacc87 {
-#ifdef dontdef /* too unportable */
- u_long fp_mantlo; /* mantissa low (31:0) */
- u_long fp_manthi; /* mantissa high (63:32) */
- int fp_exp:15; /* exponent */
- int fp_sgn:1; /* mantissa sign */
-#else
- u_char fp_bytes[10];
-#endif
-};
-
-/* Floating point context */
-struct save87 {
- struct env87 sv_env; /* floating point control/status */
- struct fpacc87 sv_ac[8]; /* accumulator contents, 0-7 */
- u_long sv_ex_sw; /* status word for last exception */
- /*
- * Bogus padding for emulators. Emulators should use their own
- * struct and arrange to store into this struct (ending here)
- * before it is inspected for ptracing or for core dumps. Some
- * emulators overwrite the whole struct. We have no good way of
- * knowing how much padding to leave. Leave just enough for the
- * GPL emulator's i387_union (176 bytes total).
- */
- u_char sv_pad[64]; /* padding; used by emulators */
-};
-
-/*
- * The hardware default control word for i387's and later coprocessors is
- * 0x37F, giving:
- *
- * round to nearest
- * 64-bit precision
- * all exceptions masked.
- *
- * We modify the affine mode bit and precision bits in this to give:
- *
- * affine mode for 287's (if they work at all) (1 in bitfield 1<<12)
- * 53-bit precision (2 in bitfield 3<<8)
- *
- * 64-bit precision often gives bad results with high level languages
- * because it makes the results of calculations depend on whether
- * intermediate values are stored in memory or in FPU registers.
- */
-#define __INITIAL_NPXCW__ 0x127F
-
-#ifdef _KERNEL
-#ifndef npxproc
-extern struct proc *npxproc;
-#endif
-
-int npxdna __P((void));
-void npxexit __P((struct proc *p));
-void npxinit __P((int control));
-void npxsave __P((struct save87 *addr));
-#endif
-
-#endif /* !_MACHINE_NPX_H_ */
diff --git a/sys/amd64/include/pc/bios.h b/sys/amd64/include/pc/bios.h
deleted file mode 100644
index 3a317863812f..000000000000
--- a/sys/amd64/include/pc/bios.h
+++ /dev/null
@@ -1,209 +0,0 @@
-/*-
- * Copyright (c) 1997 Michael Smith
- * Copyright (c) 1998 Jonathan Lemon
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Signature structure for the BIOS32 Service Directory header
- */
-struct bios32_SDheader
-{
- u_int8_t sig[4];
- u_int32_t entry;
- u_int8_t revision;
- u_int8_t len;
- u_int8_t cksum;
- u_int8_t pad[5];
-};
-
-/*
- * BIOS32 Service Directory entry. Caller supplies name, bios32_SDlookup
- * fills in the rest of the details.
- */
-struct bios32_SDentry
-{
- union
- {
- u_int8_t name[4]; /* service identifier */
- u_int32_t id; /* as a 32-bit value */
- } ident;
- u_int32_t base; /* base of service */
- u_int32_t len; /* service length */
- u_int32_t entry; /* entrypoint offset from base */
-};
-
-extern int bios32_SDlookup(struct bios32_SDentry *ent);
-extern u_int32_t bios_sigsearch(u_int32_t start, u_char *sig, int siglen,
- int paralen, int sigofs);
-
-#define BIOS_PADDRTOVADDR(x) (((x) - ISA_HOLE_START) + atdevbase)
-#define BIOS_VADDRTOPADDR(x) (((x) - atdevbase) + ISA_HOLE_START)
-
-
-/*
- * PnP BIOS presence structure
- */
-struct PnPBIOS_table
-{
- u_int8_t sig[4]; /* "$PnP */
- u_int8_t version; /* should be 0x10 */
- u_int8_t len; /* total structure length */
- u_int16_t control; /* BIOS feature flags */
- u_int8_t cksum; /* checksum */
- u_int32_t evflagaddr; /* address of event notificaton flag */
- u_int16_t rmentryoffset; /* real-mode entry offset */
- u_int16_t rmentryseg; /* segment */
- u_int16_t pmentryoffset; /* protected-mode entry offset */
- u_int32_t pmentrybase; /* segment base */
- u_int32_t oemdevid; /* motherboard EISA ID */
- u_int16_t rmbiosseg; /* real-mode BIOS segment */
- u_int32_t pmdataseg; /* protected-mode data segment */
-} __attribute__ ((packed));
-
-
-/*
- * Exported lookup results
- */
-extern struct bios32_SDentry PCIbios;
-extern struct PnPBIOS_table *PnPBIOStable;
-
-struct segment_info {
- u_int base;
- u_int limit;
-};
-
-#define BIOSCODE_FLAG 0x01
-#define BIOSDATA_FLAG 0x02
-#define BIOSUTIL_FLAG 0x04
-#define BIOSARGS_FLAG 0x08
-
-struct bios_segments {
- struct segment_info code32; /* 32-bit code (mandatory) */
- struct segment_info code16; /* 16-bit code */
- struct segment_info data; /* 16-bit data */
- struct segment_info util; /* 16-bit utility */
- struct segment_info args; /* 16-bit args */
-};
-
-struct bios_regs {
- u_int eax;
- u_int ebx;
- u_int ecx;
- u_int edx;
- u_int esi;
- u_int edi;
-};
-
-struct bios_args {
- u_int entry; /* entry point of routine */
- struct bios_regs r;
- struct bios_segments seg;
-};
-
-/*
- * PnP BIOS return codes
- */
-#define PNP_SUCCESS 0x00
-#define PNP_NOT_SET_STATICALLY 0x7f
-#define PNP_UNKNOWN_FUNCTION 0x81
-#define PNP_FUNTION_NOT_SUPPORTED 0x82
-#define PNP_INVALID_HANDLE 0x83
-#define PNP_BAD_PARAMETER 0x84
-#define PNP_SET_FAILED 0x85
-#define PNP_EVENTS_NOT_PENDING 0x86
-#define PNP_SYSTEM_NOT_DOCKED 0x87
-#define PNP_NO_ISA_PNP_CARDS 0x88
-#define PNP_UNABLE_TO_DETERMINE_DOCK_CAPABILITIES 0x89
-#define PNP_CONFIG_CHANGE_FAILED_NO_BATTERY 0x8a
-#define PNP_CONFIG_CHANGE_FAILED_RESOURCE_CONFLICT 0x8b
-#define PNP_BUFFER_TOO_SMALL 0x8c
-#define PNP_USE_ESCD_SUPPORT 0x8d
-#define PNP_MESSAGE_NOT_SUPPORTED 0x8e
-#define PNP_HARDWARE_ERROR 0x8f
-
-/*
- * DMI return codes
- */
-#define DMI_SUCCESS 0x00
-#define DMI_UNKNOWN_FUNCTION 0x81
-#define DMI_FUNCTION_NOT_SUPPORTED 0x82
-#define DMI_INVALID_HANDLE 0x83
-#define DMI_BAD_PARAMETER 0x84
-#define DMI_INVALID_SUBFUNCTION 0x85
-#define DMI_NO_CHANGE 0x86
-#define DMI_ADD_STRUCTURE_FAILED 0x87
-#define DMI_READ_ONLY 0x8d
-#define DMI_LOCK_NOT_SUPPORTED 0x90
-#define DMI_CURRENTLY_LOCKED 0x91
-#define DMI_INVALID_LOCK 0x92
-
-/*
- * format specifiers and defines for bios16()
- * s = short (16 bits)
- * i = int (32 bits)
- * p = pointer (converted to seg:offset)
- * C,D,U = selector (corresponding to code/data/utility segment)
- */
-#define PNP_COUNT_DEVNODES "sppD", 0x00
-#define PNP_GET_DEVNODE "sppsD", 0x01
-#define PNP_SET_DEVNODE "sppsD", 0x02
-#define PNP_GET_EVENT "spD", 0x03
-#define PNP_SEND_MSG "ssD", 0x04
-#define PNP_GET_DOCK_INFO "spD", 0x05
-
-#define PNP_SEL_PRIBOOT "ssiiisspD", 0x07
-#define PNP_GET_PRIBOOT "sspppppD", 0x08
-#define PNP_SET_RESINFO "spD", 0x09
-#define PNP_GET_RESINFO "spD", 0x0A
-#define PNP_GET_APM_ID "sppD", 0x0B
-
-#define PNP_GET_ISA_INFO "spD", 0x40
-#define PNP_GET_ECSD_INFO "spppD", 0x41
-#define PNP_READ_ESCD "spUD", 0x42
-#define PNP_WRITE_ESCD "spUD", 0x43
-
-#define PNP_GET_DMI_INFO "spppppD", 0x50
-#define PNP_GET_DMI_STRUCTURE "sppUD", 0x51
-#define PNP_SET_DMI_STRUCTURE "sppsUD" 0x52
-#define PNP_GET_DMI_CHANGE "spUD" 0x53
-#define PNP_DMI_CONTROL "sspsUD" 0x54
-#define PNP_GET_GPNV_INFO "sppppD" 0x55
-#define PNP_READ_GPNV_DATA "ssppUD" 0x56
-#define PNP_WRITE_GPNV_DATA "sspsUD" 0x57
-
-#define PNP_BOOT_CHECK "sp", 0x60
-#define PNP_COUNT_IPL "sppp", 0x61
-#define PNP_GET_BOOTPRI "spp", 0x62
-#define PNP_SET_BOOTPRI "sp", 0x63
-#define PNP_GET_LASTBOOT "sp", 0x64
-#define PNP_GET_BOOTFIRST "sp", 0x65
-#define PNP_SET_BOOTFIRST "sp", 0x66
-
-extern int bios16(struct bios_args *, char *, ...);
-extern int bios16_call(struct bios_regs *, char *);
-extern int bios32(struct bios_regs *, u_int, u_short);
-extern void set_bios_selectors(struct bios_segments *, int);
diff --git a/sys/amd64/include/pc/display.h b/sys/amd64/include/pc/display.h
deleted file mode 100644
index cd2d5ff35b73..000000000000
--- a/sys/amd64/include/pc/display.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * IBM PC display definitions
- *
- * $FreeBSD$
- */
-
-/* Color attributes for foreground text */
-
-#define FG_BLACK 0
-#define FG_BLUE 1
-#define FG_GREEN 2
-#define FG_CYAN 3
-#define FG_RED 4
-#define FG_MAGENTA 5
-#define FG_BROWN 6
-#define FG_LIGHTGREY 7
-#define FG_DARKGREY 8
-#define FG_LIGHTBLUE 9
-#define FG_LIGHTGREEN 10
-#define FG_LIGHTCYAN 11
-#define FG_LIGHTRED 12
-#define FG_LIGHTMAGENTA 13
-#define FG_YELLOW 14
-#define FG_WHITE 15
-#define FG_BLINK 0x80
-
-/* Color attributes for text background */
-
-#define BG_BLACK 0x00
-#define BG_BLUE 0x10
-#define BG_GREEN 0x20
-#define BG_CYAN 0x30
-#define BG_RED 0x40
-#define BG_MAGENTA 0x50
-#define BG_BROWN 0x60
-#define BG_LIGHTGREY 0x70
-
-/* Monochrome attributes for foreground text */
-
-#define FG_UNDERLINE 0x01
-#define FG_INTENSE 0x08
-
-/* Monochrome attributes for text background */
-
-#define BG_INTENSE 0x10
diff --git a/sys/amd64/include/pcb.h b/sys/amd64/include/pcb.h
deleted file mode 100644
index 08beb5a83059..000000000000
--- a/sys/amd64/include/pcb.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)pcb.h 5.10 (Berkeley) 5/12/91
- * $FreeBSD$
- */
-
-#ifndef _I386_PCB_H_
-#define _I386_PCB_H_
-
-/*
- * Intel 386 process control block
- */
-#include <machine/globals.h>
-#include <machine/npx.h>
-
-struct pcb {
- int pcb_cr3;
- int pcb_edi;
- int pcb_esi;
- int pcb_ebp;
- int pcb_esp;
- int pcb_ebx;
- int pcb_eip;
-
- int pcb_dr0;
- int pcb_dr1;
- int pcb_dr2;
- int pcb_dr3;
- int pcb_dr6;
- int pcb_dr7;
-
-#ifdef USER_LDT
- struct pcb_ldt *pcb_ldt; /* per process (user) LDT */
-#else
- struct pcb_ldt *pcb_ldt_dontuse;
-#endif
- struct save87 pcb_savefpu; /* floating point state for 287/387 */
- u_char pcb_flags;
-#define FP_SOFTFP 0x01 /* process using software fltng pnt emulator */
-#define PCB_DBREGS 0x02 /* process using debug registers */
- caddr_t pcb_onfault; /* copyin/out fault recovery */
-#ifdef SMP
- u_long pcb_mpnest;
-#else
- u_long pcb_mpnest_dontuse;
-#endif
- int pcb_gs;
- struct pcb_ext *pcb_ext; /* optional pcb extension */
- u_long __pcb_spare[3]; /* adjust to avoid core dump size changes */
-};
-
-/*
- * The pcb is augmented with machine-dependent additional data for
- * core dumps. For the i386: ???
- */
-struct md_coredump {
-};
-
-#ifdef _KERNEL
-
-#ifndef curpcb
-extern struct pcb *curpcb; /* our current running pcb */
-#endif
-
-void savectx __P((struct pcb *));
-#endif
-
-#endif /* _I386_PCB_H_ */
diff --git a/sys/amd64/include/pcb_ext.h b/sys/amd64/include/pcb_ext.h
deleted file mode 100644
index 482ec96a9cab..000000000000
--- a/sys/amd64/include/pcb_ext.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*-
- * Copyright (c) 1997 Jonathan Lemon
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _I386_PCB_EXT_H_
-#define _I386_PCB_EXT_H_
-
-/*
- * Extension to the 386 process control block
- */
-#include <machine/tss.h>
-#include <machine/vm86.h>
-#include <machine/segments.h>
-
-struct pcb_ext {
- struct segment_descriptor ext_tssd; /* tss descriptor */
- struct i386tss ext_tss; /* per-process i386tss */
- caddr_t ext_iomap; /* i/o permission bitmap */
- struct vm86_kernel ext_vm86; /* vm86 area */
-};
-
-struct pcb_ldt {
- caddr_t ldt_base;
- int ldt_len;
- int ldt_refcnt;
- u_long ldt_active;
- struct segment_descriptor ldt_sd;
-};
-
-#ifdef _KERNEL
-
-#ifdef USER_LDT
-void set_user_ldt __P((struct pcb *));
-struct pcb_ldt *user_ldt_alloc __P((struct pcb *, int));
-void user_ldt_free __P((struct pcb *));
-#endif
-
-#endif
-
-#endif /* _I386_PCB_EXT_H_ */
diff --git a/sys/amd64/include/pci_cfgreg.h b/sys/amd64/include/pci_cfgreg.h
deleted file mode 100644
index 34b3fc54aaa3..000000000000
--- a/sys/amd64/include/pci_cfgreg.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 1997, Stefan Esser <se@freebsd.org>
- * 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 unmodified, 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.
- *
- * $FreeBSD$
- *
- */
-
-#define CONF1_ADDR_PORT 0x0cf8
-#define CONF1_DATA_PORT 0x0cfc
-
-#define CONF1_ENABLE 0x80000000ul
-#define CONF1_ENABLE_CHK 0x80000000ul
-#define CONF1_ENABLE_MSK 0x7ff00000ul
-#define CONF1_ENABLE_CHK1 0xff000001ul
-#define CONF1_ENABLE_MSK1 0x80000001ul
-#define CONF1_ENABLE_RES1 0x80000000ul
-
-#define CONF2_ENABLE_PORT 0x0cf8
-#ifdef PC98
-#define CONF2_FORWARD_PORT 0x0cf9
-#else
-#define CONF2_FORWARD_PORT 0x0cfa
-#endif
-
-#define CONF2_ENABLE_CHK 0x0e
-#define CONF2_ENABLE_RES 0x0e
diff --git a/sys/amd64/include/pcpu.h b/sys/amd64/include/pcpu.h
deleted file mode 100644
index 28336d708534..000000000000
--- a/sys/amd64/include/pcpu.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*-
- * Copyright (c) Peter Wemm <peter@netplex.com.au>
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-/*
- * This structure maps out the global data that needs to be kept on a
- * per-cpu basis. genassym uses this to generate offsets for the assembler
- * code, which also provides external symbols so that C can get at them as
- * though they were really globals.
- *
- * The SMP parts are setup in pmap.c and locore.s for the BSP, and
- * mp_machdep.c sets up the data for the AP's to "see" when they awake.
- * The reason for doing it via a struct is so that an array of pointers
- * to each CPU's data can be set up for things like "check curproc on all
- * other processors"
- */
-struct globaldata {
- struct privatespace *gd_prvspace; /* self-reference */
- struct proc *gd_curproc;
- struct proc *gd_npxproc;
- struct pcb *gd_curpcb;
- struct timeval gd_switchtime;
- struct i386tss gd_common_tss;
- int gd_switchticks;
- struct segment_descriptor gd_common_tssd;
- struct segment_descriptor *gd_tss_gdt;
-#ifdef USER_LDT
- int gd_currentldt;
-#endif
-#ifdef SMP
- u_int gd_cpuid;
- u_int gd_cpu_lockid;
- u_int gd_other_cpus;
- int gd_inside_intr;
- u_int gd_ss_eflags;
- pt_entry_t *gd_prv_CMAP1;
- pt_entry_t *gd_prv_CMAP2;
- pt_entry_t *gd_prv_CMAP3;
- pt_entry_t *gd_prv_PMAP1;
- caddr_t gd_prv_CADDR1;
- caddr_t gd_prv_CADDR2;
- caddr_t gd_prv_CADDR3;
- unsigned *gd_prv_PADDR1;
-#endif
-};
-
-#ifdef SMP
-/*
- * This is the upper (0xff800000) address space layout that is per-cpu.
- * It is setup in locore.s and pmap.c for the BSP and in mp_machdep.c for
- * each AP. genassym helps export this to the assembler code.
- */
-struct privatespace {
- /* page 0 - data page */
- struct globaldata globaldata;
- char __filler0[PAGE_SIZE - sizeof(struct globaldata)];
-
- /* page 1..4 - CPAGE1,CPAGE2,CPAGE3,PPAGE1 */
- char CPAGE1[PAGE_SIZE];
- char CPAGE2[PAGE_SIZE];
- char CPAGE3[PAGE_SIZE];
- char PPAGE1[PAGE_SIZE];
-
- /* page 5..4+UPAGES - idle stack (UPAGES pages) */
- char idlestack[UPAGES * PAGE_SIZE];
-};
-
-extern struct privatespace SMP_prvspace[];
-
-#endif
diff --git a/sys/amd64/include/pmap.h b/sys/amd64/include/pmap.h
deleted file mode 100644
index 66b6b613d569..000000000000
--- a/sys/amd64/include/pmap.h
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Copyright (c) 1991 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 and William Jolitz of UUNET Technologies Inc.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * Derived from hp300 version by Mike Hibler, this version by William
- * Jolitz uses a recursive map [a pde points to the page directory] to
- * map the page tables using the pagetables themselves. This is done to
- * reduce the impact on kernel virtual memory for lots of sparse address
- * space, and to reduce the cost of memory to each process.
- *
- * from: hp300: @(#)pmap.h 7.2 (Berkeley) 12/16/90
- * from: @(#)pmap.h 7.4 (Berkeley) 5/12/91
- * $FreeBSD$
- */
-
-#ifndef _MACHINE_PMAP_H_
-#define _MACHINE_PMAP_H_
-
-/*
- * Page-directory and page-table entires follow this format, with a few
- * of the fields not present here and there, depending on a lot of things.
- */
- /* ---- Intel Nomenclature ---- */
-#define PG_V 0x001 /* P Valid */
-#define PG_RW 0x002 /* R/W Read/Write */
-#define PG_U 0x004 /* U/S User/Supervisor */
-#define PG_NC_PWT 0x008 /* PWT Write through */
-#define PG_NC_PCD 0x010 /* PCD Cache disable */
-#define PG_A 0x020 /* A Accessed */
-#define PG_M 0x040 /* D Dirty */
-#define PG_PS 0x080 /* PS Page size (0=4k,1=4M) */
-#define PG_G 0x100 /* G Global */
-#define PG_AVAIL1 0x200 /* / Available for system */
-#define PG_AVAIL2 0x400 /* < programmers use */
-#define PG_AVAIL3 0x800 /* \ */
-
-
-/* Our various interpretations of the above */
-#define PG_W PG_AVAIL1 /* "Wired" pseudoflag */
-#define PG_MANAGED PG_AVAIL2
-#define PG_FRAME (~PAGE_MASK)
-#define PG_PROT (PG_RW|PG_U) /* all protection bits . */
-#define PG_N (PG_NC_PWT|PG_NC_PCD) /* Non-cacheable */
-
-/*
- * Page Protection Exception bits
- */
-
-#define PGEX_P 0x01 /* Protection violation vs. not present */
-#define PGEX_W 0x02 /* during a Write cycle */
-#define PGEX_U 0x04 /* access from User mode (UPL) */
-
-/*
- * Pte related macros
- */
-#define VADDR(pdi, pti) ((vm_offset_t)(((pdi)<<PDRSHIFT)|((pti)<<PAGE_SHIFT)))
-
-#ifndef NKPT
-#define NKPT 17 /* actual number of kernel page tables */
-#endif
-#ifndef NKPDE
-#ifdef SMP
-#define NKPDE 254 /* addressable number of page tables/pde's */
-#else
-#define NKPDE 255 /* addressable number of page tables/pde's */
-#endif /* SMP */
-#endif
-
-/*
- * The *PTDI values control the layout of virtual memory
- *
- * XXX This works for now, but I am not real happy with it, I'll fix it
- * right after I fix locore.s and the magic 28K hole
- *
- * SMP_PRIVPAGES: The per-cpu address space is 0xff80000 -> 0xffbfffff
- */
-#define APTDPTDI (NPDEPG-1) /* alt ptd entry that points to APTD */
-#ifdef SMP
-#define MPPTDI (APTDPTDI-1) /* per cpu ptd entry */
-#define KPTDI (MPPTDI-NKPDE) /* start of kernel virtual pde's */
-#else
-#define KPTDI (APTDPTDI-NKPDE)/* start of kernel virtual pde's */
-#endif /* SMP */
-#define PTDPTDI (KPTDI-1) /* ptd entry that points to ptd! */
-#define UMAXPTDI (PTDPTDI-1) /* ptd entry for user space end */
-#define UMAXPTEOFF (NPTEPG) /* pte entry for user space end */
-
-/*
- * XXX doesn't really belong here I guess...
- */
-#define ISA_HOLE_START 0xa0000
-#define ISA_HOLE_LENGTH (0x100000-ISA_HOLE_START)
-
-#ifndef LOCORE
-
-#include <sys/queue.h>
-
-typedef unsigned int *pd_entry_t;
-typedef unsigned int *pt_entry_t;
-
-#define PDESIZE sizeof(pd_entry_t) /* for assembly files */
-#define PTESIZE sizeof(pt_entry_t) /* for assembly files */
-
-/*
- * Address of current and alternate address space page table maps
- * and directories.
- */
-#ifdef _KERNEL
-extern pt_entry_t PTmap[], APTmap[], Upte;
-extern pd_entry_t PTD[], APTD[], PTDpde, APTDpde, Upde;
-
-extern pd_entry_t IdlePTD; /* physical address of "Idle" state directory */
-#endif
-
-#ifdef _KERNEL
-/*
- * virtual address to page table entry and
- * to physical address. Likewise for alternate address space.
- * Note: these work recursively, thus vtopte of a pte will give
- * the corresponding pde that in turn maps it.
- */
-#define vtopte(va) (PTmap + i386_btop(va))
-
-#define avtopte(va) (APTmap + i386_btop(va))
-
-/*
- * Routine: pmap_kextract
- * Function:
- * Extract the physical page address associated
- * kernel virtual address.
- */
-static __inline vm_offset_t
-pmap_kextract(vm_offset_t va)
-{
- vm_offset_t pa;
- if ((pa = (vm_offset_t) PTD[va >> PDRSHIFT]) & PG_PS) {
- pa = (pa & ~(NBPDR - 1)) | (va & (NBPDR - 1));
- } else {
- pa = *(vm_offset_t *)vtopte(va);
- pa = (pa & PG_FRAME) | (va & PAGE_MASK);
- }
- return pa;
-}
-
-#if 0
-#define vtophys(va) (((vm_offset_t) (*vtopte(va))&PG_FRAME) | ((vm_offset_t)(va) & PAGE_MASK))
-#else
-#define vtophys(va) pmap_kextract(((vm_offset_t) (va)))
-#endif
-
-#define avtophys(va) (((vm_offset_t) (*avtopte(va))&PG_FRAME) | ((vm_offset_t)(va) & PAGE_MASK))
-
-#endif
-
-/*
- * Pmap stuff
- */
-struct pv_entry;
-typedef struct {
- int pv_list_count;
- struct vm_page *pv_vm_page;
- TAILQ_HEAD(,pv_entry) pv_list;
-} pv_table_t;
-
-struct pmap {
- pd_entry_t *pm_pdir; /* KVA of page directory */
- vm_object_t pm_pteobj; /* Container for pte's */
- TAILQ_HEAD(,pv_entry) pm_pvlist; /* list of mappings in pmap */
- int pm_count; /* reference count */
- int pm_active; /* active on cpus */
- struct pmap_statistics pm_stats; /* pmap statistics */
- struct vm_page *pm_ptphint; /* pmap ptp hint */
-};
-
-#define pmap_resident_count(pmap) (pmap)->pm_stats.resident_count
-
-typedef struct pmap *pmap_t;
-
-#ifdef _KERNEL
-extern pmap_t kernel_pmap;
-#endif
-
-/*
- * For each vm_page_t, there is a list of all currently valid virtual
- * mappings of that page. An entry is a pv_entry_t, the list is pv_table.
- */
-typedef struct pv_entry {
- pmap_t pv_pmap; /* pmap where mapping lies */
- vm_offset_t pv_va; /* virtual address for mapping */
- TAILQ_ENTRY(pv_entry) pv_list;
- TAILQ_ENTRY(pv_entry) pv_plist;
- vm_page_t pv_ptem; /* VM page for pte */
-} *pv_entry_t;
-
-#define PV_ENTRY_NULL ((pv_entry_t) 0)
-
-#define PV_CI 0x01 /* all entries must be cache inhibited */
-#define PV_PTPAGE 0x02 /* entry maps a page table page */
-
-#ifdef _KERNEL
-
-#define NPPROVMTRR 8
-#define PPRO_VMTRRphysBase0 0x200
-#define PPRO_VMTRRphysMask0 0x201
-struct ppro_vmtrr {
- u_int64_t base, mask;
-};
-extern struct ppro_vmtrr PPro_vmtrr[NPPROVMTRR];
-
-extern caddr_t CADDR1;
-extern pt_entry_t *CMAP1;
-extern vm_offset_t avail_end;
-extern vm_offset_t avail_start;
-extern vm_offset_t clean_eva;
-extern vm_offset_t clean_sva;
-extern vm_offset_t phys_avail[];
-extern char *ptvmmap; /* poor name! */
-extern vm_offset_t virtual_avail;
-extern vm_offset_t virtual_end;
-
-void pmap_bootstrap __P(( vm_offset_t, vm_offset_t));
-pmap_t pmap_kernel __P((void));
-void *pmap_mapdev __P((vm_offset_t, vm_size_t));
-void pmap_unmapdev __P((vm_offset_t, vm_size_t));
-unsigned *pmap_pte __P((pmap_t, vm_offset_t)) __pure2;
-vm_page_t pmap_use_pt __P((pmap_t, vm_offset_t));
-#ifdef SMP
-void pmap_set_opt __P((void));
-#endif
-
-#endif /* _KERNEL */
-
-#endif /* !LOCORE */
-
-#endif /* !_MACHINE_PMAP_H_ */
diff --git a/sys/amd64/include/proc.h b/sys/amd64/include/proc.h
deleted file mode 100644
index bc2679e385c3..000000000000
--- a/sys/amd64/include/proc.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 1991 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. 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, Berkeley and its contributors.
- * 4. 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: @(#)proc.h 7.1 (Berkeley) 5/15/91
- * $FreeBSD$
- */
-
-#ifndef _MACHINE_PROC_H_
-#define _MACHINE_PROC_H_
-
-#include <machine/globals.h>
-
-/*
- * Machine-dependent part of the proc structure for i386.
- */
-struct mdproc {
- struct trapframe *md_regs; /* registers on current frame */
-};
-
-#endif /* !_MACHINE_PROC_H_ */
diff --git a/sys/amd64/include/profile.h b/sys/amd64/include/profile.h
deleted file mode 100644
index 22738c3b1fb2..000000000000
--- a/sys/amd64/include/profile.h
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * 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. 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, Berkeley and its contributors.
- * 4. 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
- * $FreeBSD$
- */
-
-#ifndef _MACHINE_PROFILE_H_
-#define _MACHINE_PROFILE_H_
-
-#ifdef _KERNEL
-
-/*
- * Config generates something to tell the compiler to align functions on 16
- * byte boundaries. A strict alignment is good for keeping the tables small.
- */
-#define FUNCTION_ALIGNMENT 16
-
-/*
- * The kernel uses assembler stubs instead of unportable inlines.
- * This is mainly to save a little time when profiling is not enabled,
- * which is the usual case for the kernel.
- */
-#define _MCOUNT_DECL void mcount
-#define MCOUNT
-
-#ifdef GUPROF
-#define CALIB_SCALE 1000
-#define KCOUNT(p,index) ((p)->kcount[(index) \
- / (HISTFRACTION * sizeof(HISTCOUNTER))])
-#define MCOUNT_DECL(s)
-#define MCOUNT_ENTER(s)
-#define MCOUNT_EXIT(s)
-#define PC_TO_I(p, pc) ((uintfptr_t)(pc) - (uintfptr_t)(p)->lowpc)
-#else
-#define MCOUNT_DECL(s) u_long s;
-#ifdef SMP
-#define MCOUNT_ENTER(s) { s = read_eflags(); \
- __asm __volatile("cli" : : : "memory"); \
- s_lock_np(&mcount_lock); }
-#define MCOUNT_EXIT(s) { s_unlock_np(&mcount_lock); write_eflags(s); }
-#else
-#define MCOUNT_ENTER(s) { s = read_eflags(); disable_intr(); }
-#define MCOUNT_EXIT(s) (write_eflags(s))
-#endif
-#endif /* GUPROF */
-
-#else /* !_KERNEL */
-
-#define FUNCTION_ALIGNMENT 4
-
-#define _MCOUNT_DECL static __inline void _mcount
-
-#define MCOUNT \
-void \
-mcount() \
-{ \
- uintfptr_t selfpc, frompc; \
- /* \
- * Find the return address for mcount, \
- * and the return address for mcount's caller. \
- * \
- * selfpc = pc pushed by call to mcount \
- */ \
- asm("movl 4(%%ebp),%0" : "=r" (selfpc)); \
- /* \
- * frompc = pc pushed by call to mcount's caller. \
- * The caller's stack frame has already been built, so %ebp is \
- * the caller's frame pointer. The caller's raddr is in the \
- * caller's frame following the caller's caller's frame pointer. \
- */ \
- asm("movl (%%ebp),%0" : "=r" (frompc)); \
- frompc = ((uintfptr_t *)frompc)[1]; \
- _mcount(frompc, selfpc); \
-}
-
-typedef unsigned int uintfptr_t;
-
-#endif /* _KERNEL */
-
-/*
- * An unsigned integral type that can hold non-negative difference between
- * function pointers.
- */
-typedef u_int fptrdiff_t;
-
-#ifdef _KERNEL
-
-void mcount __P((uintfptr_t frompc, uintfptr_t selfpc));
-
-#ifdef GUPROF
-struct gmonparam;
-
-void nullfunc_loop_profiled __P((void));
-void nullfunc_profiled __P((void));
-void startguprof __P((struct gmonparam *p));
-void stopguprof __P((struct gmonparam *p));
-#else
-#define startguprof(p)
-#define stopguprof(p)
-#endif /* GUPROF */
-
-#else /* !_KERNEL */
-
-#include <sys/cdefs.h>
-
-__BEGIN_DECLS
-#ifdef __GNUC__
-#ifdef __ELF__
-void mcount __P((void)) __asm(".mcount");
-#else
-void mcount __P((void)) __asm("mcount");
-#endif
-#endif
-static void _mcount __P((uintfptr_t frompc, uintfptr_t selfpc));
-__END_DECLS
-
-#endif /* _KERNEL */
-
-#ifdef GUPROF
-/* XXX doesn't quite work outside kernel yet. */
-extern int cputime_bias;
-
-__BEGIN_DECLS
-int cputime __P((void));
-void empty_loop __P((void));
-void mexitcount __P((uintfptr_t selfpc));
-void nullfunc __P((void));
-void nullfunc_loop __P((void));
-__END_DECLS
-#endif
-
-#endif /* !_MACHINE_PROFILE_H_ */
diff --git a/sys/amd64/include/psl.h b/sys/amd64/include/psl.h
deleted file mode 100644
index 6a7e233a8408..000000000000
--- a/sys/amd64/include/psl.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)psl.h 5.2 (Berkeley) 1/18/91
- * $FreeBSD$
- */
-
-#ifndef _MACHINE_PSL_H_
-#define _MACHINE_PSL_H_
-
-/*
- * 386 processor status longword.
- */
-#define PSL_C 0x00000001 /* carry bit */
-#define PSL_PF 0x00000004 /* parity bit */
-#define PSL_AF 0x00000010 /* bcd carry bit */
-#define PSL_Z 0x00000040 /* zero bit */
-#define PSL_N 0x00000080 /* negative bit */
-#define PSL_T 0x00000100 /* trace enable bit */
-#define PSL_I 0x00000200 /* interrupt enable bit */
-#define PSL_D 0x00000400 /* string instruction direction bit */
-#define PSL_V 0x00000800 /* overflow bit */
-#define PSL_IOPL 0x00003000 /* i/o privilege level */
-#define PSL_NT 0x00004000 /* nested task bit */
-#define PSL_RF 0x00010000 /* resume flag bit */
-#define PSL_VM 0x00020000 /* virtual 8086 mode bit */
-#define PSL_AC 0x00040000 /* alignment checking */
-#define PSL_VIF 0x00080000 /* virtual interrupt enable */
-#define PSL_VIP 0x00100000 /* virtual interrupt pending */
-#define PSL_ID 0x00200000 /* identification bit */
-
-/*
- * The i486 manual says that we are not supposed to change reserved flags,
- * but this is too much trouble since the reserved flags depend on the cpu
- * and setting them to their historical values works in practice.
- */
-#define PSL_RESERVED_DEFAULT 0x00000002
-
-/*
- * Initial flags for kernel and user mode. The kernel later inherits
- * PSL_I and some other flags from user mode.
- */
-#define PSL_KERNEL PSL_RESERVED_DEFAULT
-#define PSL_USER (PSL_RESERVED_DEFAULT | PSL_I)
-
-/*
- * Bits that can be changed in user mode on 486's. We allow these bits
- * to be changed using ptrace(), sigreturn() and procfs. Setting PS_NT
- * is undesirable but it may as well be allowed since users can inflict
- * it on the kernel directly. Changes to PSL_AC are silently ignored on
- * 386's.
- */
-#define PSL_USERCHANGE (PSL_C | PSL_PF | PSL_AF | PSL_Z | PSL_N | PSL_T \
- | PSL_D | PSL_V | PSL_NT | PSL_AC)
-
-#endif /* !_MACHINE_PSL_H_ */
diff --git a/sys/amd64/include/ptrace.h b/sys/amd64/include/ptrace.h
deleted file mode 100644
index d59a38f3409b..000000000000
--- a/sys/amd64/include/ptrace.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)ptrace.h 8.1 (Berkeley) 6/11/93
- * $FreeBSD$
- */
-
-#ifndef _MACHINE_PTRACE_H_
-#define _MACHINE_PTRACE_H_
-
-/*
- * Machine dependent trace commands.
- */
-#define PT_GETREGS (PT_FIRSTMACH + 1)
-#define PT_SETREGS (PT_FIRSTMACH + 2)
-#define PT_GETFPREGS (PT_FIRSTMACH + 3)
-#define PT_SETFPREGS (PT_FIRSTMACH + 4)
-#define PT_GETDBREGS (PT_FIRSTMACH + 5)
-#define PT_SETDBREGS (PT_FIRSTMACH + 6)
-
-#ifdef _KERNEL
-int ptrace_read_u_check __P((struct proc *p, vm_offset_t off, size_t len));
-#endif
-
-#endif
-
diff --git a/sys/amd64/include/reg.h b/sys/amd64/include/reg.h
deleted file mode 100644
index 6effd1a60d6f..000000000000
--- a/sys/amd64/include/reg.h
+++ /dev/null
@@ -1,146 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)reg.h 5.5 (Berkeley) 1/18/91
- * $FreeBSD$
- */
-
-#ifndef _MACHINE_REG_H_
-#define _MACHINE_REG_H_
-
-/*
- * Indices for registers in `struct trapframe' and `struct regs'.
- *
- * This interface is deprecated. In the kernel, it is only used in FPU
- * emulators to convert from register numbers encoded in instructions to
- * register values. Everything else just accesses the relevant struct
- * members. In userland, debuggers tend to abuse this interface since
- * they don't understand that `struct regs' is a struct. I hope they have
- * stopped accessing the registers in the trap frame via PT_{READ,WRITE}_U
- * and we can stop supporting the user area soon.
- */
-#define tFS (0)
-#define tES (1)
-#define tDS (2)
-#define tEDI (3)
-#define tESI (4)
-#define tEBP (5)
-#define tISP (6)
-#define tEBX (7)
-#define tEDX (8)
-#define tECX (9)
-#define tEAX (10)
-#define tERR (12)
-#define tEIP (13)
-#define tCS (14)
-#define tEFLAGS (15)
-#define tESP (16)
-#define tSS (17)
-
-/*
- * Indices for registers in `struct regs' only.
- *
- * Some registers live in the pcb and are only in an "array" with the
- * other registers in application interfaces that copy all the registers
- * to or from a `struct regs'.
- */
-#define tGS (18)
-
-/*
- * Register set accessible via /proc/$pid/regs and PT_{SET,GET}REGS.
- */
-struct reg {
- unsigned int r_fs;
- unsigned int r_es;
- unsigned int r_ds;
- unsigned int r_edi;
- unsigned int r_esi;
- unsigned int r_ebp;
- unsigned int r_isp;
- unsigned int r_ebx;
- unsigned int r_edx;
- unsigned int r_ecx;
- unsigned int r_eax;
- unsigned int r_trapno;
- unsigned int r_err;
- unsigned int r_eip;
- unsigned int r_cs;
- unsigned int r_eflags;
- unsigned int r_esp;
- unsigned int r_ss;
- unsigned int r_gs;
-};
-
-/*
- * Register set accessible via /proc/$pid/fpregs.
- */
-struct fpreg {
- /*
- * XXX should get struct from npx.h. Here we give a slightly
- * simplified struct. This may be too much detail. Perhaps
- * an array of unsigned longs is best.
- */
- unsigned long fpr_env[7];
- unsigned char fpr_acc[8][10];
- unsigned long fpr_ex_sw;
- unsigned char fpr_pad[64];
-};
-
-/*
- * Register set accessible via /proc/$pid/dbregs.
- */
-struct dbreg {
- unsigned int dr0; /* debug address register 0 */
- unsigned int dr1; /* debug address register 1 */
- unsigned int dr2; /* debug address register 2 */
- unsigned int dr3; /* debug address register 3 */
- unsigned int dr4; /* reserved */
- unsigned int dr5; /* reserved */
- unsigned int dr6; /* debug status register */
- unsigned int dr7; /* debug control register */
-};
-
-
-#ifdef _KERNEL
-/*
- * XXX these interfaces are MI, so they should be declared in a MI place.
- */
-int set_fpregs __P((struct proc *, struct fpreg *));
-int set_regs __P((struct proc *p, struct reg *regs));
-void setregs __P((struct proc *, u_long, u_long, u_long));
-int set_dbregs __P((struct proc *p, struct dbreg *dbregs));
-#endif
-
-#endif /* !_MACHINE_REG_H_ */
diff --git a/sys/amd64/include/reloc.h b/sys/amd64/include/reloc.h
deleted file mode 100644
index ef4b8dbc3e8c..000000000000
--- a/sys/amd64/include/reloc.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-
- * 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)reloc.h 8.1 (Berkeley) 6/10/93
- * $FreeBSD$
- */
-
-#ifndef _I386_MACHINE_RELOC_H_
-#define _I386_MACHINE_RELOC_H_
-
-/* Relocation format. */
-struct relocation_info {
- int r_address; /* offset in text or data segment */
- unsigned int r_symbolnum : 24, /* ordinal number of add symbol */
- r_pcrel : 1, /* 1 if value should be pc-relative */
- r_length : 2, /* log base 2 of value's width */
- r_extern : 1, /* 1 if need to add symbol to value */
- r_baserel : 1, /* linkage table relative */
- r_jmptable : 1, /* relocate to jump table */
- r_relative : 1, /* load address relative */
- r_copy : 1; /* run time copy */
-};
-
-#endif
diff --git a/sys/amd64/include/resource.h b/sys/amd64/include/resource.h
deleted file mode 100644
index 28fcc98ea1be..000000000000
--- a/sys/amd64/include/resource.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* $FreeBSD$ */
-/*
- * Copyright 1998 Massachusetts Institute of Technology
- *
- * Permission to use, copy, modify, and distribute this software and
- * its documentation for any purpose and without fee is hereby
- * granted, provided that both the above copyright notice and this
- * permission notice appear in all copies, that both the above
- * copyright notice and this permission notice appear in all
- * supporting documentation, and that the name of M.I.T. not be used
- * in advertising or publicity pertaining to distribution of the
- * software without specific, written prior permission. M.I.T. makes
- * no representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied
- * warranty.
- *
- * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS
- * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
- * SHALL M.I.T. 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_RESOURCE_H_
-#define _MACHINE_RESOURCE_H_ 1
-
-/*
- * Definitions of resource types for Intel Architecture machines
- * with support for legacy ISA devices and drivers.
- */
-
-#define SYS_RES_IRQ 1 /* interrupt lines */
-#define SYS_RES_DRQ 2 /* isa dma lines */
-#define SYS_RES_MEMORY 3 /* i/o memory */
-#define SYS_RES_IOPORT 4 /* i/o ports */
-
-#endif /* !_MACHINE_RESOURCE_H_ */
diff --git a/sys/amd64/include/segments.h b/sys/amd64/include/segments.h
deleted file mode 100644
index 8cbe8704bd8e..000000000000
--- a/sys/amd64/include/segments.h
+++ /dev/null
@@ -1,264 +0,0 @@
-/*-
- * Copyright (c) 1989, 1990 William F. Jolitz
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)segments.h 7.1 (Berkeley) 5/9/91
- * $FreeBSD$
- */
-
-#ifndef _MACHINE_SEGMENTS_H_
-#define _MACHINE_SEGMENTS_H_
-
-#include <machine/globals.h>
-
-/*
- * 386 Segmentation Data Structures and definitions
- * William F. Jolitz (william@ernie.berkeley.edu) 6/20/1989
- */
-
-/*
- * Selectors
- */
-
-#define ISPL(s) ((s)&3) /* what is the priority level of a selector */
-#define SEL_KPL 0 /* kernel priority level */
-#define SEL_UPL 3 /* user priority level */
-#define ISLDT(s) ((s)&SEL_LDT) /* is it local or global */
-#define SEL_LDT 4 /* local descriptor table */
-#define IDXSEL(s) (((s)>>3) & 0x1fff) /* index of selector */
-#define LSEL(s,r) (((s)<<3) | SEL_LDT | r) /* a local selector */
-#define GSEL(s,r) (((s)<<3) | r) /* a global selector */
-
-/*
- * Memory and System segment descriptors
- */
-struct segment_descriptor {
- unsigned sd_lolimit:16 ; /* segment extent (lsb) */
- unsigned sd_lobase:24 __attribute__ ((packed));
- /* segment base address (lsb) */
- unsigned sd_type:5 ; /* segment type */
- unsigned sd_dpl:2 ; /* segment descriptor priority level */
- unsigned sd_p:1 ; /* segment descriptor present */
- unsigned sd_hilimit:4 ; /* segment extent (msb) */
- unsigned sd_xx:2 ; /* unused */
- unsigned sd_def32:1 ; /* default 32 vs 16 bit size */
- unsigned sd_gran:1 ; /* limit granularity (byte/page units)*/
- unsigned sd_hibase:8 ; /* segment base address (msb) */
-} ;
-
-/*
- * Gate descriptors (e.g. indirect descriptors)
- */
-struct gate_descriptor {
- unsigned gd_looffset:16 ; /* gate offset (lsb) */
- unsigned gd_selector:16 ; /* gate segment selector */
- unsigned gd_stkcpy:5 ; /* number of stack wds to cpy */
- unsigned gd_xx:3 ; /* unused */
- unsigned gd_type:5 ; /* segment type */
- unsigned gd_dpl:2 ; /* segment descriptor priority level */
- unsigned gd_p:1 ; /* segment descriptor present */
- unsigned gd_hioffset:16 ; /* gate offset (msb) */
-} ;
-
-/*
- * Generic descriptor
- */
-union descriptor {
- struct segment_descriptor sd;
- struct gate_descriptor gd;
-};
-
- /* system segments and gate types */
-#define SDT_SYSNULL 0 /* system null */
-#define SDT_SYS286TSS 1 /* system 286 TSS available */
-#define SDT_SYSLDT 2 /* system local descriptor table */
-#define SDT_SYS286BSY 3 /* system 286 TSS busy */
-#define SDT_SYS286CGT 4 /* system 286 call gate */
-#define SDT_SYSTASKGT 5 /* system task gate */
-#define SDT_SYS286IGT 6 /* system 286 interrupt gate */
-#define SDT_SYS286TGT 7 /* system 286 trap gate */
-#define SDT_SYSNULL2 8 /* system null again */
-#define SDT_SYS386TSS 9 /* system 386 TSS available */
-#define SDT_SYSNULL3 10 /* system null again */
-#define SDT_SYS386BSY 11 /* system 386 TSS busy */
-#define SDT_SYS386CGT 12 /* system 386 call gate */
-#define SDT_SYSNULL4 13 /* system null again */
-#define SDT_SYS386IGT 14 /* system 386 interrupt gate */
-#define SDT_SYS386TGT 15 /* system 386 trap gate */
-
- /* memory segment types */
-#define SDT_MEMRO 16 /* memory read only */
-#define SDT_MEMROA 17 /* memory read only accessed */
-#define SDT_MEMRW 18 /* memory read write */
-#define SDT_MEMRWA 19 /* memory read write accessed */
-#define SDT_MEMROD 20 /* memory read only expand dwn limit */
-#define SDT_MEMRODA 21 /* memory read only expand dwn limit accessed */
-#define SDT_MEMRWD 22 /* memory read write expand dwn limit */
-#define SDT_MEMRWDA 23 /* memory read write expand dwn limit accessed */
-#define SDT_MEME 24 /* memory execute only */
-#define SDT_MEMEA 25 /* memory execute only accessed */
-#define SDT_MEMER 26 /* memory execute read */
-#define SDT_MEMERA 27 /* memory execute read accessed */
-#define SDT_MEMEC 28 /* memory execute only conforming */
-#define SDT_MEMEAC 29 /* memory execute only accessed conforming */
-#define SDT_MEMERC 30 /* memory execute read conforming */
-#define SDT_MEMERAC 31 /* memory execute read accessed conforming */
-
-/* is memory segment descriptor pointer ? */
-#define ISMEMSDP(s) ((s->d_type) >= SDT_MEMRO && (s->d_type) <= SDT_MEMERAC)
-
-/* is 286 gate descriptor pointer ? */
-#define IS286GDP(s) (((s->d_type) >= SDT_SYS286CGT \
- && (s->d_type) < SDT_SYS286TGT))
-
-/* is 386 gate descriptor pointer ? */
-#define IS386GDP(s) (((s->d_type) >= SDT_SYS386CGT \
- && (s->d_type) < SDT_SYS386TGT))
-
-/* is gate descriptor pointer ? */
-#define ISGDP(s) (IS286GDP(s) || IS386GDP(s))
-
-/* is segment descriptor pointer ? */
-#define ISSDP(s) (ISMEMSDP(s) || !ISGDP(s))
-
-/* is system segment descriptor pointer ? */
-#define ISSYSSDP(s) (!ISMEMSDP(s) && !ISGDP(s))
-
-/*
- * Software definitions are in this convenient format,
- * which are translated into inconvenient segment descriptors
- * when needed to be used by the 386 hardware
- */
-
-struct soft_segment_descriptor {
- unsigned ssd_base ; /* segment base address */
- unsigned ssd_limit ; /* segment extent */
- unsigned ssd_type:5 ; /* segment type */
- unsigned ssd_dpl:2 ; /* segment descriptor priority level */
- unsigned ssd_p:1 ; /* segment descriptor present */
- unsigned ssd_xx:4 ; /* unused */
- unsigned ssd_xx1:2 ; /* unused */
- unsigned ssd_def32:1 ; /* default 32 vs 16 bit size */
- unsigned ssd_gran:1 ; /* limit granularity (byte/page units)*/
-};
-
-/*
- * region descriptors, used to load gdt/idt tables before segments yet exist.
- */
-struct region_descriptor {
- unsigned rd_limit:16; /* segment extent */
- unsigned rd_base:32 __attribute__ ((packed)); /* base address */
-};
-
-/*
- * Segment Protection Exception code bits
- */
-
-#define SEGEX_EXT 0x01 /* recursive or externally induced */
-#define SEGEX_IDT 0x02 /* interrupt descriptor table */
-#define SEGEX_TI 0x04 /* local descriptor table */
- /* other bits are affected descriptor index */
-#define SEGEX_IDX(s) ((s)>>3)&0x1fff)
-
-/*
- * Size of IDT table
- */
-
-#if defined(SMP) || defined(APIC_IO)
-#define NIDT 256 /* we use them all */
-#else
-#define NIDT 129 /* 32 reserved, 16 h/w, 0 s/w, linux's 0x80 */
-#endif /* SMP || APIC_IO */
-#define NRSVIDT 32 /* reserved entries for cpu exceptions */
-
-/*
- * Entries in the Global Descriptor Table (GDT)
- */
-#define GNULL_SEL 0 /* Null Descriptor */
-#define GCODE_SEL 1 /* Kernel Code Descriptor */
-#define GDATA_SEL 2 /* Kernel Data Descriptor */
-#define GPRIV_SEL 3 /* SMP Per-Processor Private Data */
-#define GPROC0_SEL 4 /* Task state process slot zero and up */
-#define GLDT_SEL 5 /* LDT - eventually one per process */
-#define GUSERLDT_SEL 6 /* User LDT */
-#define GTGATE_SEL 7 /* Process task switch gate */
-#define GBIOSLOWMEM_SEL 8 /* BIOS low memory access (must be entry 8) */
-#define GPANIC_SEL 9 /* Task state to consider panic from */
-#define GBIOSCODE32_SEL 10 /* BIOS interface (32bit Code) */
-#define GBIOSCODE16_SEL 11 /* BIOS interface (16bit Code) */
-#define GBIOSDATA_SEL 12 /* BIOS interface (Data) */
-#define GBIOSUTIL_SEL 13 /* BIOS interface (Utility) */
-#define GBIOSARGS_SEL 14 /* BIOS interface (Arguments) */
-
-#ifdef BDE_DEBUGGER
-#define NGDT 18 /* some of 11-17 are reserved for debugger */
-#else
-#define NGDT 15
-#endif
-
-/*
- * Entries in the Local Descriptor Table (LDT)
- */
-#define LSYS5CALLS_SEL 0 /* forced by intel BCS */
-#define LSYS5SIGR_SEL 1
-#define L43BSDCALLS_SEL 2 /* notyet */
-#define LUCODE_SEL 3
-#define LSOL26CALLS_SEL 4 /* Solaris >= 2.6 system call gate */
-#define LUDATA_SEL 5
-/* separate stack, es,fs,gs sels ? */
-/* #define LPOSIXCALLS_SEL 5*/ /* notyet */
-#define LBSDICALLS_SEL 16 /* BSDI system call gate */
-#define NLDT (LBSDICALLS_SEL + 1)
-
-#ifdef _KERNEL
-#ifndef currentldt
-extern int currentldt;
-#endif
-extern int _default_ldt;
-extern union descriptor gdt[];
-extern struct soft_segment_descriptor gdt_segs[];
-extern struct gate_descriptor *idt;
-extern union descriptor ldt[NLDT];
-
-void lgdt __P((struct region_descriptor *rdp));
-void lidt __P((struct region_descriptor *rdp));
-void lldt __P((u_short sel));
-void sdtossd __P((struct segment_descriptor *sdp,
- struct soft_segment_descriptor *ssdp));
-void ssdtosd __P((struct soft_segment_descriptor *ssdp,
- struct segment_descriptor *sdp));
-#endif /* _KERNEL */
-
-#endif /* !_MACHINE_SEGMENTS_H_ */
diff --git a/sys/amd64/include/setjmp.h b/sys/amd64/include/setjmp.h
deleted file mode 100644
index 3097df77f0a3..000000000000
--- a/sys/amd64/include/setjmp.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* $FreeBSD$ */
-/*
- * Copyright (c) 1998 John Birrell <jb@cimlogic.com.au>.
- * 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 John Birrell.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
- *
- */
-
-#define _JBLEN 11 /* Size of the jmp_buf on x86. */
-
-/*
- * jmp_buf and sigjmp_buf are encapsulated in different structs to force
- * compile-time diagnostics for mismatches. The structs are the same
- * internally to avoid some run-time errors for mismatches.
- */
-#ifndef _ANSI_SOURCE
-typedef struct { int _sjb[_JBLEN + 1]; } sigjmp_buf[1];
-#endif /* not ANSI */
-
-typedef struct { int _jb[_JBLEN + 1]; } jmp_buf[1];
diff --git a/sys/amd64/include/sigframe.h b/sys/amd64/include/sigframe.h
deleted file mode 100644
index cf764530c0cd..000000000000
--- a/sys/amd64/include/sigframe.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*-
- * Copyright (c) 1999 Marcel Moolenaar
- * 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
- * in this position and unchanged.
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _MACHINE_SIGFRAME_H_
-#define _MACHINE_SIGFRAME_H_
-
-/*
- * Signal frames, arguments passed to application signal handlers.
- */
-
-struct osigframe {
- /*
- * The first four members may be used by applications.
- */
-
- register_t sf_signum;
-
- /*
- * Either 'int' for old-style FreeBSD handler or 'siginfo_t *'
- * pointing to sf_siginfo for SA_SIGINFO handlers.
- */
- register_t sf_arg2;
-
- /* Points to sf_siginfo.si_sc. */
- register_t sf_scp;
-
- register_t sf_addr;
-
- /*
- * The following arguments are not constrained by the
- * function call protocol.
- * Applications are not supposed to access these members,
- * except using the pointers we provide in the first three
- * arguments.
- */
-
- union {
- __osiginfohandler_t *sf_action;
- __sighandler_t *sf_handler;
- } sf_ahu;
-
- /* In the SA_SIGINFO case, sf_arg2 points here. */
- osiginfo_t sf_siginfo;
-};
-
-struct sigframe {
- /*
- * The first four members may be used by applications.
- *
- * NOTE: The 4th argument is undocumented, ill commented
- * on and seems to be somewhat BSD "standard". Handlers
- * installed with sigvec may be using it.
- */
- register_t sf_signum;
- register_t sf_siginfo; /* code or pointer to sf_si */
- register_t sf_ucontext; /* points to sf_uc */
- register_t sf_addr; /* undocumented 4th arg */
-
- union {
- __siginfohandler_t *sf_action;
- __sighandler_t *sf_handler;
- } sf_ahu;
- ucontext_t sf_uc; /* = *sf_ucontext */
- siginfo_t sf_si; /* = *sf_siginfo (SA_SIGINFO case) */
-};
-
-#endif /* !_MACHINE_SIGFRAME_H_ */
diff --git a/sys/amd64/include/signal.h b/sys/amd64/include/signal.h
deleted file mode 100644
index e3f1b19c4cea..000000000000
--- a/sys/amd64/include/signal.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (c) 1986, 1989, 1991, 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)signal.h 8.1 (Berkeley) 6/11/93
- * $FreeBSD$
- */
-
-#ifndef _MACHINE_SIGNAL_H_
-#define _MACHINE_SIGNAL_H_
-
-/*
- * Machine-dependent signal definitions
- */
-
-typedef int sig_atomic_t;
-
-#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
-
-#include <machine/trap.h> /* codes for SIGILL, SIGFPE */
-
-/*
- * 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.
- */
-typedef unsigned int osigset_t;
-
-struct osigcontext {
- int sc_onstack; /* sigstack state to restore */
- osigset_t sc_mask; /* signal mask to restore */
- int sc_esp; /* machine state follows: */
- int sc_ebp;
- int sc_isp;
- int sc_eip;
- int sc_efl;
- int sc_es;
- int sc_ds;
- int sc_cs;
- int sc_ss;
- int sc_edi;
- int sc_esi;
- int sc_ebx;
- int sc_edx;
- int sc_ecx;
- int sc_eax;
- int sc_gs;
- int sc_fs;
- int sc_trapno;
- int sc_err;
-};
-
-/*
- * The sequence of the fields/registers in struct sigcontext should match
- * those in mcontext_t.
- */
-struct sigcontext {
- sigset_t sc_mask; /* signal mask to restore */
- int sc_onstack; /* sigstack state to restore */
- int sc_gs; /* machine state (struct trapframe): */
- int sc_fs;
- int sc_es;
- int sc_ds;
- int sc_edi;
- int sc_esi;
- int sc_ebp;
- int sc_isp;
- int sc_ebx;
- int sc_edx;
- int sc_ecx;
- int sc_eax;
- int sc_trapno;
- int sc_err;
- int sc_eip;
- int sc_cs;
- int sc_efl;
- int sc_esp;
- int sc_ss;
- /*
- * XXX FPU state is 27 * 4 bytes h/w, 1 * 4 bytes s/w (probably not
- * needed here), or that + 16 * 4 bytes for emulators (probably all
- * needed here). The "spare" bytes are mostly not spare.
- */
- int sc_fpregs[28]; /* machine state (FPU): */
- int sc_spare[17];
-};
-
-#define sc_sp sc_esp
-#define sc_fp sc_ebp
-#define sc_pc sc_eip
-#define sc_ps sc_efl
-#define sc_eflags sc_efl
-
-#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
-
-#endif /* !_MACHINE_SIGNAL_H_ */
diff --git a/sys/amd64/include/smp.h b/sys/amd64/include/smp.h
deleted file mode 100644
index c2340aef71d0..000000000000
--- a/sys/amd64/include/smp.h
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * ----------------------------------------------------------------------------
- * "THE BEER-WARE LICENSE" (Revision 42):
- * <phk@FreeBSD.org> wrote this file. As long as you retain this notice you
- * can do whatever you want with this stuff. If we meet some day, and you think
- * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
- * ----------------------------------------------------------------------------
- *
- * $FreeBSD$
- *
- */
-
-#ifndef _MACHINE_SMP_H_
-#define _MACHINE_SMP_H_
-
-#ifdef _KERNEL
-
-#if defined(SMP) && !defined(APIC_IO)
-# error APIC_IO required for SMP, add "options APIC_IO" to your config file.
-#endif /* SMP && !APIC_IO */
-
-/* Number of CPUs. */
-#if defined(SMP) && !defined(NCPU)
-# define NCPU 2
-#endif /* SMP && NCPU */
-
-/* Number of IO APICs. */
-#if defined(APIC_IO) && !defined(NAPIC)
-# define NAPIC 1
-#endif /* SMP && NAPIC */
-
-
-#if defined(SMP) || defined(APIC_IO)
-
-#ifndef LOCORE
-
-/*
- * For sending values to POST displays.
- * XXX FIXME: where does this really belong, isa.h/isa.c perhaps?
- */
-extern int current_postcode; /** XXX currently in mp_machdep.c */
-#define POSTCODE(X) current_postcode = (X), \
- outb(0x80, current_postcode)
-#define POSTCODE_LO(X) current_postcode &= 0xf0, \
- current_postcode |= ((X) & 0x0f), \
- outb(0x80, current_postcode)
-#define POSTCODE_HI(X) current_postcode &= 0x0f, \
- current_postcode |= (((X) << 4) & 0xf0), \
- outb(0x80, current_postcode)
-
-
-#include <machine/apic.h>
-
-/* global data in mpboot.s */
-extern int bootMP_size;
-
-/* functions in mpboot.s */
-void bootMP __P((void));
-
-/* global data in mplock.s */
-extern u_int mp_lock;
-extern u_int isr_lock;
-#ifdef RECURSIVE_MPINTRLOCK
-extern u_int mpintr_lock;
-#endif /* RECURSIVE_MPINTRLOCK */
-
-/* functions in mplock.s */
-void get_mplock __P((void));
-void rel_mplock __P((void));
-int try_mplock __P((void));
-#ifdef RECURSIVE_MPINTRLOCK
-void get_mpintrlock __P((void));
-void rel_mpintrlock __P((void));
-int try_mpintrlock __P((void));
-#endif /* RECURSIVE_MPINTRLOCK */
-
-/* global data in apic_vector.s */
-extern volatile u_int stopped_cpus;
-extern volatile u_int started_cpus;
-
-extern volatile u_int checkstate_probed_cpus;
-extern volatile u_int checkstate_need_ast;
-extern volatile u_int resched_cpus;
-extern void (*cpustop_restartfunc) __P((void));
-
-/* functions in apic_ipl.s */
-void apic_eoi __P((void));
-u_int io_apic_read __P((int, int));
-void io_apic_write __P((int, int, u_int));
-
-/* global data in mp_machdep.c */
-extern int bsp_apic_ready;
-extern int mp_ncpus;
-extern int mp_naps;
-extern int mp_nbusses;
-extern int mp_napics;
-extern int mp_picmode;
-extern int boot_cpu_id;
-extern vm_offset_t cpu_apic_address;
-extern vm_offset_t io_apic_address[];
-extern u_int32_t cpu_apic_versions[];
-extern u_int32_t io_apic_versions[];
-extern int cpu_num_to_apic_id[];
-extern int io_num_to_apic_id[];
-extern int apic_id_to_logical[];
-#define APIC_INTMAPSIZE 24
-struct apic_intmapinfo {
- int ioapic;
- int int_pin;
- volatile void *apic_address;
- int redirindex;
-};
-extern struct apic_intmapinfo int_to_apicintpin[];
-extern u_int all_cpus;
-extern struct pcb stoppcbs[];
-
-/* functions in mp_machdep.c */
-u_int mp_bootaddress __P((u_int));
-int mp_probe __P((void));
-void mp_start __P((void));
-void mp_announce __P((void));
-u_int isa_apic_mask __P((u_int));
-int isa_apic_irq __P((int));
-int pci_apic_irq __P((int, int, int));
-int apic_irq __P((int, int));
-int next_apic_irq __P((int));
-int undirect_isa_irq __P((int));
-int undirect_pci_irq __P((int));
-int apic_bus_type __P((int));
-int apic_src_bus_id __P((int, int));
-int apic_src_bus_irq __P((int, int));
-int apic_int_type __P((int, int));
-int apic_trigger __P((int, int));
-int apic_polarity __P((int, int));
-void assign_apic_irq __P((int apic, int intpin, int irq));
-void revoke_apic_irq __P((int irq));
-void bsp_apic_configure __P((void));
-void init_secondary __P((void));
-void smp_invltlb __P((void));
-int stop_cpus __P((u_int));
-int restart_cpus __P((u_int));
-#ifdef BETTER_CLOCK
-void forward_statclock __P((int pscnt));
-void forward_hardclock __P((int pscnt));
-#endif /* BETTER_CLOCK */
-void forward_signal __P((struct proc *));
-void forward_roundrobin __P((void));
-#ifdef APIC_INTR_REORDER
-void set_lapic_isrloc __P((int, int));
-#endif /* APIC_INTR_REORDER */
-void smp_rendezvous_action __P((void));
-void smp_rendezvous __P((void (*)(void *),
- void (*)(void *),
- void (*)(void *),
- void *arg));
-
-/* global data in mpapic.c */
-extern volatile lapic_t lapic;
-extern volatile ioapic_t *ioapic[];
-
-/* functions in mpapic.c */
-void apic_dump __P((char*));
-void apic_initialize __P((void));
-void imen_dump __P((void));
-int apic_ipi __P((int, int, int));
-int selected_apic_ipi __P((u_int, int, int));
-int io_apic_setup __P((int));
-int ext_int_setup __P((int, int));
-
-#if defined(READY)
-void clr_io_apic_mask24 __P((int, u_int32_t));
-void set_io_apic_mask24 __P((int, u_int32_t));
-#endif /* READY */
-
-void set_apic_timer __P((int));
-int read_apic_timer __P((void));
-void u_sleep __P((int));
-
-/* global data in init_smp.c */
-extern int invltlb_ok;
-extern int smp_active;
-extern int smp_started;
-extern volatile int smp_idle_loops;
-
-#endif /* !LOCORE */
-#endif /* SMP || APIC_IO */
-#endif /* _KERNEL */
-#endif /* _MACHINE_SMP_H_ */
diff --git a/sys/amd64/include/specialreg.h b/sys/amd64/include/specialreg.h
deleted file mode 100644
index 937cab003e7a..000000000000
--- a/sys/amd64/include/specialreg.h
+++ /dev/null
@@ -1,342 +0,0 @@
-/*-
- * 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. 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, Berkeley and its contributors.
- * 4. 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: @(#)specialreg.h 7.1 (Berkeley) 5/9/91
- * $FreeBSD$
- */
-
-#ifndef _MACHINE_SPECIALREG_H_
-#define _MACHINE_SPECIALREG_H_
-
-/*
- * Bits in 386 special registers:
- */
-#define CR0_PE 0x00000001 /* Protected mode Enable */
-#define CR0_MP 0x00000002 /* "Math" Present (NPX or NPX emulator) */
-#define CR0_EM 0x00000004 /* EMulate non-NPX coproc. (trap ESC only) */
-#define CR0_TS 0x00000008 /* Task Switched (if MP, trap ESC and WAIT) */
-#ifdef notused
-#define CR0_ET 0x00000010 /* Extension Type (387 (if set) vs 287) */
-#endif
-#define CR0_PG 0x80000000 /* PaGing enable */
-
-/*
- * Bits in 486 special registers:
- */
-#define CR0_NE 0x00000020 /* Numeric Error enable (EX16 vs IRQ13) */
-#define CR0_WP 0x00010000 /* Write Protect (honor page protect in
- all modes) */
-#define CR0_AM 0x00040000 /* Alignment Mask (set to enable AC flag) */
-#define CR0_NW 0x20000000 /* Not Write-through */
-#define CR0_CD 0x40000000 /* Cache Disable */
-
-/*
- * Bits in PPro special registers
- */
-#define CR4_VME 0x00000001 /* Virtual 8086 mode extensions */
-#define CR4_PVI 0x00000002 /* Protected-mode virtual interrupts */
-#define CR4_TSD 0x00000004 /* Time stamp disable */
-#define CR4_DE 0x00000008 /* Debugging extensions */
-#define CR4_PSE 0x00000010 /* Page size extensions */
-#define CR4_PAE 0x00000020 /* Physical address extension */
-#define CR4_MCE 0x00000040 /* Machine check enable */
-#define CR4_PGE 0x00000080 /* Page global enable */
-#define CR4_PCE 0x00000100 /* Performance monitoring counter enable */
-#define CR4_FXSR 0x00000200 /* Fast FPU save/restore used by OS */
-#define CR4_XMM 0x00000400 /* enable SIMD/MMX2 to use except 16 */
-
-/*
- * CPUID instruction features register
- */
-#define CPUID_FPU 0x0001
-#define CPUID_VME 0x0002
-#define CPUID_DE 0x0004
-#define CPUID_PSE 0x0008
-#define CPUID_TSC 0x0010
-#define CPUID_MSR 0x0020
-#define CPUID_PAE 0x0040
-#define CPUID_MCE 0x0080
-#define CPUID_CX8 0x0100
-#define CPUID_APIC 0x0200
-#define CPUID_B10 0x0400
-#define CPUID_B11 0x0800
-#define CPUID_MTRR 0x1000
-#define CPUID_PGE 0x2000
-#define CPUID_MCA 0x4000
-#define CPUID_CMOV 0x8000
-
-/*
- * Model-specific registers for the i386 family
- */
-#define MSR_P5_MC_ADDR 0x000
-#define MSR_P5_MC_TYPE 0x001
-#define MSR_TSC 0x010
-#define MSR_APICBASE 0x01b
-#define MSR_EBL_CR_POWERON 0x02a
-#define MSR_BIOS_UPDT_TRIG 0x079
-#define MSR_BIOS_SIGN 0x08b
-#define MSR_PERFCTR0 0x0c1
-#define MSR_PERFCTR1 0x0c2
-#define MSR_MTRRcap 0x0fe
-#define MSR_MCG_CAP 0x179
-#define MSR_MCG_STATUS 0x17a
-#define MSR_MCG_CTL 0x17b
-#define MSR_EVNTSEL0 0x186
-#define MSR_EVNTSEL1 0x187
-#define MSR_DEBUGCTLMSR 0x1d9
-#define MSR_LASTBRANCHFROMIP 0x1db
-#define MSR_LASTBRANCHTOIP 0x1dc
-#define MSR_LASTINTFROMIP 0x1dd
-#define MSR_LASTINTTOIP 0x1de
-#define MSR_ROB_CR_BKUPTMPDR6 0x1e0
-#define MSR_MTRRVarBase 0x200
-#define MSR_MTRR64kBase 0x250
-#define MSR_MTRR16kBase 0x258
-#define MSR_MTRR4kBase 0x268
-#define MSR_MTRRdefType 0x2ff
-#define MSR_MC0_CTL 0x400
-#define MSR_MC0_STATUS 0x401
-#define MSR_MC0_ADDR 0x402
-#define MSR_MC0_MISC 0x403
-#define MSR_MC1_CTL 0x404
-#define MSR_MC1_STATUS 0x405
-#define MSR_MC1_ADDR 0x406
-#define MSR_MC1_MISC 0x407
-#define MSR_MC2_CTL 0x408
-#define MSR_MC2_STATUS 0x409
-#define MSR_MC2_ADDR 0x40a
-#define MSR_MC2_MISC 0x40b
-#define MSR_MC4_CTL 0x40c
-#define MSR_MC4_STATUS 0x40d
-#define MSR_MC4_ADDR 0x40e
-#define MSR_MC4_MISC 0x40f
-#define MSR_MC3_CTL 0x410
-#define MSR_MC3_STATUS 0x411
-#define MSR_MC3_ADDR 0x412
-#define MSR_MC3_MISC 0x413
-
-/*
- * Constants related to MTRRs
- */
-#define MTRR_N64K 8 /* numbers of fixed-size entries */
-#define MTRR_N16K 16
-#define MTRR_N4K 64
-
-/*
- * Cyrix configuration registers, accessible as IO ports.
- */
-#define CCR0 0xc0 /* Configuration control register 0 */
-#define CCR0_NC0 0x01 /* First 64K of each 1M memory region is
- non-cacheable */
-#define CCR0_NC1 0x02 /* 640K-1M region is non-cacheable */
-#define CCR0_A20M 0x04 /* Enables A20M# input pin */
-#define CCR0_KEN 0x08 /* Enables KEN# input pin */
-#define CCR0_FLUSH 0x10 /* Enables FLUSH# input pin */
-#define CCR0_BARB 0x20 /* Flushes internal cache when entering hold
- state */
-#define CCR0_CO 0x40 /* Cache org: 1=direct mapped, 0=2x set
- assoc */
-#define CCR0_SUSPEND 0x80 /* Enables SUSP# and SUSPA# pins */
-
-#define CCR1 0xc1 /* Configuration control register 1 */
-#define CCR1_RPL 0x01 /* Enables RPLSET and RPLVAL# pins */
-#define CCR1_SMI 0x02 /* Enables SMM pins */
-#define CCR1_SMAC 0x04 /* System management memory access */
-#define CCR1_MMAC 0x08 /* Main memory access */
-#define CCR1_NO_LOCK 0x10 /* Negate LOCK# */
-#define CCR1_SM3 0x80 /* SMM address space address region 3 */
-
-#define CCR2 0xc2
-#define CCR2_WB 0x02 /* Enables WB cache interface pins */
-#define CCR2_SADS 0x02 /* Slow ADS */
-#define CCR2_LOCK_NW 0x04 /* LOCK NW Bit */
-#define CCR2_SUSP_HLT 0x08 /* Suspend on HALT */
-#define CCR2_WT1 0x10 /* WT region 1 */
-#define CCR2_WPR1 0x10 /* Write-protect region 1 */
-#define CCR2_BARB 0x20 /* Flushes write-back cache when entering
- hold state. */
-#define CCR2_BWRT 0x40 /* Enables burst write cycles */
-#define CCR2_USE_SUSP 0x80 /* Enables suspend pins */
-
-#define CCR3 0xc3
-#define CCR3_SMILOCK 0x01 /* SMM register lock */
-#define CCR3_NMI 0x02 /* Enables NMI during SMM */
-#define CCR3_LINBRST 0x04 /* Linear address burst cycles */
-#define CCR3_SMMMODE 0x08 /* SMM Mode */
-#define CCR3_MAPEN0 0x10 /* Enables Map0 */
-#define CCR3_MAPEN1 0x20 /* Enables Map1 */
-#define CCR3_MAPEN2 0x40 /* Enables Map2 */
-#define CCR3_MAPEN3 0x80 /* Enables Map3 */
-
-#define CCR4 0xe8
-#define CCR4_IOMASK 0x07
-#define CCR4_MEM 0x08 /* Enables momory bypassing */
-#define CCR4_DTE 0x10 /* Enables directory table entry cache */
-#define CCR4_FASTFPE 0x20 /* Fast FPU exception */
-#define CCR4_CPUID 0x80 /* Enables CPUID instruction */
-
-#define CCR5 0xe9
-#define CCR5_WT_ALLOC 0x01 /* Write-through allocate */
-#define CCR5_SLOP 0x02 /* LOOP instruction slowed down */
-#define CCR5_LBR1 0x10 /* Local bus region 1 */
-#define CCR5_ARREN 0x20 /* Enables ARR region */
-
-#define CCR6 0xea
-
-#define CCR7 0xeb
-
-/* Performance Control Register (5x86 only). */
-#define PCR0 0x20
-#define PCR0_RSTK 0x01 /* Enables return stack */
-#define PCR0_BTB 0x02 /* Enables branch target buffer */
-#define PCR0_LOOP 0x04 /* Enables loop */
-#define PCR0_AIS 0x08 /* Enables all instrcutions stalled to
- serialize pipe. */
-#define PCR0_MLR 0x10 /* Enables reordering of misaligned loads */
-#define PCR0_BTBRT 0x40 /* Enables BTB test register. */
-#define PCR0_LSSER 0x80 /* Disable reorder */
-
-/* Device Identification Registers */
-#define DIR0 0xfe
-#define DIR1 0xff
-
-/*
- * The following four 3-byte registers control the non-cacheable regions.
- * These registers must be written as three separate bytes.
- *
- * NCRx+0: A31-A24 of starting address
- * NCRx+1: A23-A16 of starting address
- * NCRx+2: A15-A12 of starting address | NCR_SIZE_xx.
- *
- * The non-cacheable region's starting address must be aligned to the
- * size indicated by the NCR_SIZE_xx field.
- */
-#define NCR1 0xc4
-#define NCR2 0xc7
-#define NCR3 0xca
-#define NCR4 0xcd
-
-#define NCR_SIZE_0K 0
-#define NCR_SIZE_4K 1
-#define NCR_SIZE_8K 2
-#define NCR_SIZE_16K 3
-#define NCR_SIZE_32K 4
-#define NCR_SIZE_64K 5
-#define NCR_SIZE_128K 6
-#define NCR_SIZE_256K 7
-#define NCR_SIZE_512K 8
-#define NCR_SIZE_1M 9
-#define NCR_SIZE_2M 10
-#define NCR_SIZE_4M 11
-#define NCR_SIZE_8M 12
-#define NCR_SIZE_16M 13
-#define NCR_SIZE_32M 14
-#define NCR_SIZE_4G 15
-
-/*
- * The address region registers are used to specify the location and
- * size for the eight address regions.
- *
- * ARRx + 0: A31-A24 of start address
- * ARRx + 1: A23-A16 of start address
- * ARRx + 2: A15-A12 of start address | ARR_SIZE_xx
- */
-#define ARR0 0xc4
-#define ARR1 0xc7
-#define ARR2 0xca
-#define ARR3 0xcd
-#define ARR4 0xd0
-#define ARR5 0xd3
-#define ARR6 0xd6
-#define ARR7 0xd9
-
-#define ARR_SIZE_0K 0
-#define ARR_SIZE_4K 1
-#define ARR_SIZE_8K 2
-#define ARR_SIZE_16K 3
-#define ARR_SIZE_32K 4
-#define ARR_SIZE_64K 5
-#define ARR_SIZE_128K 6
-#define ARR_SIZE_256K 7
-#define ARR_SIZE_512K 8
-#define ARR_SIZE_1M 9
-#define ARR_SIZE_2M 10
-#define ARR_SIZE_4M 11
-#define ARR_SIZE_8M 12
-#define ARR_SIZE_16M 13
-#define ARR_SIZE_32M 14
-#define ARR_SIZE_4G 15
-
-/*
- * The region control registers specify the attributes associated with
- * the ARRx addres regions.
- */
-#define RCR0 0xdc
-#define RCR1 0xdd
-#define RCR2 0xde
-#define RCR3 0xdf
-#define RCR4 0xe0
-#define RCR5 0xe1
-#define RCR6 0xe2
-#define RCR7 0xe3
-
-#define RCR_RCD 0x01 /* Disables caching for ARRx (x = 0-6). */
-#define RCR_RCE 0x01 /* Enables caching for ARR7. */
-#define RCR_WWO 0x02 /* Weak write ordering. */
-#define RCR_WL 0x04 /* Weak locking. */
-#define RCR_WG 0x08 /* Write gathering. */
-#define RCR_WT 0x10 /* Write-through. */
-#define RCR_NLB 0x20 /* LBA# pin is not asserted. */
-
-/* AMD Write Allocate Top-Of-Memory and Control Register */
-#define AMD_WT_ALLOC_TME 0x40000 /* top-of-memory enable */
-#define AMD_WT_ALLOC_PRE 0x20000 /* programmable range enable */
-#define AMD_WT_ALLOC_FRE 0x10000 /* fixed (A0000-FFFFF) range enable */
-
-
-#ifndef LOCORE
-static __inline u_char
-read_cyrix_reg(u_char reg)
-{
- outb(0x22, reg);
- return inb(0x23);
-}
-
-static __inline void
-write_cyrix_reg(u_char reg, u_char data)
-{
- outb(0x22, reg);
- outb(0x23, data);
-}
-#endif
-
-#endif /* !_MACHINE_SPECIALREG_H_ */
diff --git a/sys/amd64/include/sysarch.h b/sys/amd64/include/sysarch.h
deleted file mode 100644
index 01e63c569a78..000000000000
--- a/sys/amd64/include/sysarch.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*-
- * Copyright (c) 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Architecture specific syscalls (i386)
- */
-#ifndef _MACHINE_SYSARCH_H_
-#define _MACHINE_SYSARCH_H_
-
-#define I386_GET_LDT 0
-#define I386_SET_LDT 1
- /* I386_IOPL */
-#define I386_GET_IOPERM 3
-#define I386_SET_IOPERM 4
- /* xxxxx */
-#define I386_VM86 6
-
-struct i386_ldt_args {
- int start;
- union descriptor *descs;
- int num;
-};
-
-struct i386_ioperm_args {
- unsigned int start;
- unsigned int length;
- int enable;
-};
-
-struct i386_vm86_args {
- int sub_op; /* sub-operation to perform */
- char *sub_args; /* args */
-};
-
-#ifndef _KERNEL
-#include <sys/cdefs.h>
-
-union descriptor;
-
-__BEGIN_DECLS
-int i386_get_ldt __P((int, union descriptor *, int));
-int i386_set_ldt __P((int, union descriptor *, int));
-int i386_get_ioperm __P((unsigned int, unsigned int *, int *));
-int i386_set_ioperm __P((unsigned int, unsigned int, int));
-int i386_vm86 __P((int, void *));
-__END_DECLS
-#endif
-
-#endif /* !_MACHINE_SYSARCH_H_ */
diff --git a/sys/amd64/include/trap.h b/sys/amd64/include/trap.h
deleted file mode 100644
index 6cc059a1e584..000000000000
--- a/sys/amd64/include/trap.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)trap.h 5.4 (Berkeley) 5/9/91
- * $FreeBSD$
- */
-
-#ifndef _MACHINE_TRAP_H_
-#define _MACHINE_TRAP_H_
-
-/*
- * Trap type values
- * also known in trap.c for name strings
- */
-
-#define T_PRIVINFLT 1 /* privileged instruction */
-#define T_BPTFLT 3 /* breakpoint instruction */
-#define T_ARITHTRAP 6 /* arithmetic trap */
-#define T_ASTFLT 7 /* system forced exception */
-#define T_PROTFLT 9 /* protection fault */
-#define T_TRCTRAP 10 /* debug exception (sic) */
-#define T_PAGEFLT 12 /* page fault */
-#define T_ALIGNFLT 14 /* alignment fault */
-
-#define T_DIVIDE 18 /* integer divide fault */
-#define T_NMI 19 /* non-maskable trap */
-#define T_OFLOW 20 /* overflow trap */
-#define T_BOUND 21 /* bound instruction fault */
-#define T_DNA 22 /* device not available fault */
-#define T_DOUBLEFLT 23 /* double fault */
-#define T_FPOPFLT 24 /* fp coprocessor operand fetch fault */
-#define T_TSSFLT 25 /* invalid tss fault */
-#define T_SEGNPFLT 26 /* segment not present fault */
-#define T_STKFLT 27 /* stack fault */
-#define T_MCHK 28 /* machine check trap */
-#define T_RESERVED 29 /* reserved (unknown) */
-
-/* XXX most of the following codes aren't used, but could be. */
-
-/* definitions for <sys/signal.h> */
-#define ILL_RESAD_FAULT T_RESADFLT
-#define ILL_PRIVIN_FAULT T_PRIVINFLT
-#define ILL_RESOP_FAULT T_RESOPFLT
-#define ILL_ALIGN_FAULT T_ALIGNFLT
-#define ILL_FPOP_FAULT T_FPOPFLT /* coprocessor operand fault */
-
-/* portable macros for SIGFPE/ARITHTRAP */
-#define FPE_INTDIV 1 /* integer divide by zero */
-#define FPE_INTOVF 2 /* integer overflow */
-#define FPE_FLTDIV 3 /* floating point divide by zero */
-#define FPE_FLTOVF 4 /* floating point overflow */
-#define FPE_FLTUND 5 /* floating point underflow */
-#define FPE_FLTRES 6 /* floating point inexact result */
-#define FPE_FLTINV 7 /* invalid floating point operation */
-#define FPE_FLTSUB 8 /* subscript out of range */
-
-/* old FreeBSD macros, deprecated */
-#define FPE_INTOVF_TRAP 0x1 /* integer overflow */
-#define FPE_INTDIV_TRAP 0x2 /* integer divide by zero */
-#define FPE_FLTDIV_TRAP 0x3 /* floating/decimal divide by zero */
-#define FPE_FLTOVF_TRAP 0x4 /* floating overflow */
-#define FPE_FLTUND_TRAP 0x5 /* floating underflow */
-#define FPE_FPU_NP_TRAP 0x6 /* floating point unit not present */
-#define FPE_SUBRNG_TRAP 0x7 /* subrange out of bounds */
-
-/* codes for SIGBUS */
-#define BUS_PAGE_FAULT T_PAGEFLT /* page fault protection base */
-#define BUS_SEGNP_FAULT T_SEGNPFLT /* segment not present */
-#define BUS_STK_FAULT T_STKFLT /* stack segment */
-#define BUS_SEGM_FAULT T_RESERVED /* segment protection base */
-
-/* Trap's coming from user mode */
-#define T_USER 0x100
-
-#endif /* !_MACHINE_TRAP_H_ */
diff --git a/sys/amd64/include/tss.h b/sys/amd64/include/tss.h
deleted file mode 100644
index 77b94437c034..000000000000
--- a/sys/amd64/include/tss.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)tss.h 5.4 (Berkeley) 1/18/91
- * $FreeBSD$
- */
-
-#ifndef _MACHINE_TSS_H_
-#define _MACHINE_TSS_H_ 1
-
-#include <machine/globals.h>
-
-/*
- * Intel 386 Context Data Type
- */
-
-struct i386tss {
- int tss_link; /* actually 16 bits: top 16 bits must be zero */
- int tss_esp0; /* kernel stack pointer privilege level 0 */
-#define tss_ksp tss_esp0
- int tss_ss0; /* actually 16 bits: top 16 bits must be zero */
- int tss_esp1; /* kernel stack pointer privilege level 1 */
- int tss_ss1; /* actually 16 bits: top 16 bits must be zero */
- int tss_esp2; /* kernel stack pointer privilege level 2 */
- int tss_ss2; /* actually 16 bits: top 16 bits must be zero */
- int tss_cr3; /* page table directory */
-#define tss_ptd tss_cr3
- int tss_eip; /* program counter */
-#define tss_pc tss_eip
- int tss_eflags; /* program status longword */
-#define tss_psl tss_eflags
- int tss_eax;
- int tss_ecx;
- int tss_edx;
- int tss_ebx;
- int tss_esp; /* user stack pointer */
-#define tss_usp tss_esp
- int tss_ebp; /* user frame pointer */
-#define tss_fp tss_ebp
- int tss_esi;
- int tss_edi;
- int tss_es; /* actually 16 bits: top 16 bits must be zero */
- int tss_cs; /* actually 16 bits: top 16 bits must be zero */
- int tss_ss; /* actually 16 bits: top 16 bits must be zero */
- int tss_ds; /* actually 16 bits: top 16 bits must be zero */
- int tss_fs; /* actually 16 bits: top 16 bits must be zero */
- int tss_gs; /* actually 16 bits: top 16 bits must be zero */
- int tss_ldt; /* actually 16 bits: top 16 bits must be zero */
- int tss_ioopt; /* options & io offset bitmap: currently zero */
- /* XXX unimplemented .. i/o permission bitmap */
-};
-
-#ifdef _KERNEL
-#ifndef common_tss
-extern struct i386tss common_tss;
-#endif
-#endif
-
-#endif /* _MACHINE_TSS_H_ */
diff --git a/sys/amd64/include/ucontext.h b/sys/amd64/include/ucontext.h
deleted file mode 100644
index c0a3aa8e1c6e..000000000000
--- a/sys/amd64/include/ucontext.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*-
- * Copyright (c) 1999 Marcel Moolenaar
- * 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
- * in this position and unchanged.
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _MACHINE_UCONTEXT_H_
-#define _MACHINE_UCONTEXT_H_
-
-typedef struct __mcontext {
- /*
- * The first 20 fields must match the definition of
- * sigcontext. So that we can support sigcontext
- * and ucontext_t at the same time.
- */
- int mc_onstack; /* XXX - sigcontext compat. */
- int mc_gs;
- int mc_fs;
- int mc_es;
- int mc_ds;
- int mc_edi;
- int mc_esi;
- int mc_ebp;
- int mc_isp;
- int mc_ebx;
- int mc_edx;
- int mc_ecx;
- int mc_eax;
- int mc_trapno;
- int mc_err;
- int mc_eip;
- int mc_cs;
- int mc_eflags;
- int mc_esp; /* machine state */
- int mc_ss;
-
- int mc_fpregs[28]; /* env87 + fpacc87 + u_long */
- int __spare__[17];
-} mcontext_t;
-
-#endif /* !_MACHINE_UCONTEXT_H_ */
diff --git a/sys/amd64/include/varargs.h b/sys/amd64/include/varargs.h
deleted file mode 100644
index d1d4ed0c0906..000000000000
--- a/sys/amd64/include/varargs.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)varargs.h 8.2 (Berkeley) 3/22/94
- * $FreeBSD$
- */
-
-#ifndef _VARARGS_H_
-#define _VARARGS_H_
-
-typedef char *va_list;
-
-#define __va_size(type) \
- (((sizeof(type) + sizeof(int) - 1) / sizeof(int)) * sizeof(int))
-
-#ifdef __GNUC__
-#define va_alist __builtin_va_alist
-#endif
-#if __GNUC__ > 1
-#define va_dcl int va_alist; ...
-#else
-#define va_dcl int va_alist;
-#endif
-
-#define va_start(ap) \
- ((ap) = (va_list)&va_alist)
-
-#define va_arg(ap, type) \
- (*(type *)((ap) += __va_size(type), (ap) - __va_size(type)))
-
-#define va_end(ap)
-
-#endif /* !_VARARGS_H_ */
diff --git a/sys/amd64/include/vmparam.h b/sys/amd64/include/vmparam.h
deleted file mode 100644
index 0a5847dd5ff6..000000000000
--- a/sys/amd64/include/vmparam.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- * Copyright (c) 1994 John S. Dyson
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)vmparam.h 5.9 (Berkeley) 5/12/91
- * $FreeBSD$
- */
-
-
-#ifndef _MACHINE_VMPARAM_H_
-#define _MACHINE_VMPARAM_H_ 1
-
-/*
- * Machine dependent constants for 386.
- */
-
-#define VM_PROT_READ_IS_EXEC /* if you can read -- then you can exec */
-
-/*
- * Virtual memory related constants, all in bytes
- */
-#define MAXTSIZ (128UL*1024*1024) /* max text size */
-#ifndef DFLDSIZ
-#define DFLDSIZ (128UL*1024*1024) /* initial data size limit */
-#endif
-#ifndef MAXDSIZ
-#define MAXDSIZ (512UL*1024*1024) /* max data size */
-#endif
-#ifndef DFLSSIZ
-#define DFLSSIZ (8UL*1024*1024) /* initial stack size limit */
-#endif
-#ifndef MAXSSIZ
-#define MAXSSIZ (64UL*1024*1024) /* max stack size */
-#endif
-#ifndef SGROWSIZ
-#define SGROWSIZ (128UL*1024) /* amount to grow stack */
-#endif
-
-#define USRTEXT (1*PAGE_SIZE) /* base of user text XXX bogus */
-
-/*
- * Size of the Shared Memory Pages page table.
- */
-#ifndef SHMMAXPGS
-#define SHMMAXPGS 1024 /* XXX until we have more kmap space */
-#endif
-
-/*
- * The time for a process to be blocked before being very swappable.
- * This is a number of seconds which the system takes as being a non-trivial
- * amount of real time. You probably shouldn't change this;
- * it is used in subtle ways (fractions and multiples of it are, that is, like
- * half of a ``long time'', almost a long time, etc.)
- * It is related to human patience and other factors which don't really
- * change over time.
- */
-#define MAXSLP 20
-
-
-/*
- * Virtual addresses of things. Derived from the page directory and
- * page table indexes from pmap.h for precision.
- * Because of the page that is both a PD and PT, it looks a little
- * messy at times, but hey, we'll do anything to save a page :-)
- */
-
-#define VM_MAX_KERNEL_ADDRESS VADDR(KPTDI+NKPDE, 0)
-#define VM_MIN_KERNEL_ADDRESS VADDR(PTDPTDI, PTDPTDI)
-
-#define KERNBASE VADDR(KPTDI, 0)
-
-#define KPT_MAX_ADDRESS VADDR(PTDPTDI, KPTDI+NKPT)
-#define KPT_MIN_ADDRESS VADDR(PTDPTDI, KPTDI)
-
-#define UPT_MAX_ADDRESS VADDR(PTDPTDI, PTDPTDI)
-#define UPT_MIN_ADDRESS VADDR(PTDPTDI, 0)
-
-#define VM_MAXUSER_ADDRESS VADDR(UMAXPTDI, UMAXPTEOFF)
-
-#define USRSTACK VM_MAXUSER_ADDRESS
-
-#define VM_MAX_ADDRESS VADDR(PTDPTDI, PTDPTDI)
-#define VM_MIN_ADDRESS ((vm_offset_t)0)
-
-/* virtual sizes (bytes) for various kernel submaps */
-#ifndef VM_KMEM_SIZE
-#define VM_KMEM_SIZE (12 * 1024 * 1024)
-#endif
-
-/*
- * How many physical pages per KVA page allocated.
- * min(max(VM_KMEM_SIZE, Physical memory/VM_KMEM_SIZE_SCALE), VM_KMEM_SIZE_MAX)
- * is the total KVA space allocated for kmem_map.
- */
-#ifndef VM_KMEM_SIZE_SCALE
-#define VM_KMEM_SIZE_SCALE (3)
-#endif
-
-/*
- * Ceiling on amount of kmem_map kva space.
- */
-#ifndef VM_KMEM_SIZE_MAX
-#define VM_KMEM_SIZE_MAX (200 * 1024 * 1024)
-#endif
-
-/* initial pagein size of beginning of executable file */
-#ifndef VM_INITIAL_PAGEIN
-#define VM_INITIAL_PAGEIN 16
-#endif
-
-#endif /* _MACHINE_VMPARAM_H_ */
diff --git a/sys/amd64/isa/atpic_vector.S b/sys/amd64/isa/atpic_vector.S
deleted file mode 100644
index 24ce97b666b9..000000000000
--- a/sys/amd64/isa/atpic_vector.S
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * from: vector.s, 386BSD 0.1 unknown origin
- * $FreeBSD$
- */
-
-/*
- * modified for PC98 by Kakefuda
- */
-
-#ifdef PC98
-#define ICU_IMR_OFFSET 2 /* IO_ICU{1,2} + 2 */
-#else
-#define ICU_IMR_OFFSET 1 /* IO_ICU{1,2} + 1 */
-#endif
-
-#define ICU_EOI 0x20 /* XXX - define elsewhere */
-
-#define IRQ_BIT(irq_num) (1 << ((irq_num) % 8))
-#define IRQ_BYTE(irq_num) ((irq_num) >> 3)
-
-#ifdef AUTO_EOI_1
-#define ENABLE_ICU1 /* use auto-EOI to reduce i/o */
-#define OUTB_ICU1
-#else
-#define ENABLE_ICU1 \
- movb $ICU_EOI,%al ; /* as soon as possible send EOI ... */ \
- OUTB_ICU1 /* ... to clear in service bit */
-#define OUTB_ICU1 \
- outb %al,$IO_ICU1
-#endif
-
-#ifdef AUTO_EOI_2
-/*
- * The data sheet says no auto-EOI on slave, but it sometimes works.
- */
-#define ENABLE_ICU1_AND_2 ENABLE_ICU1
-#else
-#define ENABLE_ICU1_AND_2 \
- movb $ICU_EOI,%al ; /* as above */ \
- outb %al,$IO_ICU2 ; /* but do second icu first ... */ \
- OUTB_ICU1 /* ... then first icu (if !AUTO_EOI_1) */
-#endif
-
-/*
- * Macros for interrupt interrupt entry, call to handler, and exit.
- */
-
-#define FAST_INTR(irq_num, vec_name, enable_icus) \
- .text ; \
- SUPERALIGN_TEXT ; \
-IDTVEC(vec_name) ; \
- pushl %eax ; /* save only call-used registers */ \
- pushl %ecx ; \
- pushl %edx ; \
- pushl %ds ; \
- MAYBE_PUSHL_ES ; \
- movl $KDSEL,%eax ; \
- movl %ax,%ds ; \
- MAYBE_MOVW_AX_ES ; \
- FAKE_MCOUNT((4+ACTUALLY_PUSHED)*4(%esp)) ; \
- pushl _intr_unit + (irq_num) * 4 ; \
- call *_intr_handler + (irq_num) * 4 ; /* do the work ASAP */ \
- enable_icus ; /* (re)enable ASAP (helps edge trigger?) */ \
- addl $4,%esp ; \
- incl _cnt+V_INTR ; /* book-keeping can wait */ \
- movl _intr_countp + (irq_num) * 4,%eax ; \
- incl (%eax) ; \
- movl _cpl,%eax ; /* are we unmasking pending HWIs or SWIs? */ \
- notl %eax ; \
- andl _ipending,%eax ; \
- jne 2f ; /* yes, maybe handle them */ \
-1: ; \
- MEXITCOUNT ; \
- MAYBE_POPL_ES ; \
- popl %ds ; \
- popl %edx ; \
- popl %ecx ; \
- popl %eax ; \
- iret ; \
-; \
- ALIGN_TEXT ; \
-2: ; \
- cmpb $3,_intr_nesting_level ; /* is there enough stack? */ \
- jae 1b ; /* no, return */ \
- movl _cpl,%eax ; \
- /* XXX next line is probably unnecessary now. */ \
- movl $HWI_MASK|SWI_MASK,_cpl ; /* limit nesting ... */ \
- incb _intr_nesting_level ; /* ... really limit it ... */ \
- sti ; /* ... to do this as early as possible */ \
- MAYBE_POPL_ES ; /* discard most of thin frame ... */ \
- popl %ecx ; /* ... original %ds ... */ \
- popl %edx ; \
- xchgl %eax,4(%esp) ; /* orig %eax; save cpl */ \
- pushal ; /* build fat frame (grrr) ... */ \
- pushl %ecx ; /* ... actually %ds ... */ \
- pushl %es ; \
- pushl %fs ; \
- movl $KDSEL,%eax ; \
- movl %ax,%es ; \
- movl %ax,%fs ; \
- movl (3+8+0)*4(%esp),%ecx ; /* ... %ecx from thin frame ... */ \
- movl %ecx,(3+6)*4(%esp) ; /* ... to fat frame ... */ \
- movl (3+8+1)*4(%esp),%eax ; /* ... cpl from thin frame */ \
- pushl %eax ; \
- subl $4,%esp ; /* junk for unit number */ \
- MEXITCOUNT ; \
- jmp _doreti
-
-#define INTR(irq_num, vec_name, icu, enable_icus, reg, maybe_extra_ipending) \
- .text ; \
- SUPERALIGN_TEXT ; \
-IDTVEC(vec_name) ; \
- pushl $0 ; /* dummy error code */ \
- pushl $0 ; /* dummy trap type */ \
- pushal ; \
- pushl %ds ; /* save our data and extra segments ... */ \
- pushl %es ; \
- pushl %fs ; \
- movl $KDSEL,%eax ; /* ... and reload with kernel's own ... */ \
- movl %ax,%ds ; /* ... early for obsolete reasons */ \
- movl %ax,%es ; \
- movl %ax,%fs ; \
- maybe_extra_ipending ; \
- movb _imen + IRQ_BYTE(irq_num),%al ; \
- orb $IRQ_BIT(irq_num),%al ; \
- movb %al,_imen + IRQ_BYTE(irq_num) ; \
- outb %al,$icu+ICU_IMR_OFFSET ; \
- enable_icus ; \
- movl _cpl,%eax ; \
- testb $IRQ_BIT(irq_num),%reg ; \
- jne 2f ; \
- incb _intr_nesting_level ; \
-__CONCAT(Xresume,irq_num): ; \
- FAKE_MCOUNT(13*4(%esp)) ; /* XXX late to avoid double count */ \
- incl _cnt+V_INTR ; /* tally interrupts */ \
- movl _intr_countp + (irq_num) * 4,%eax ; \
- incl (%eax) ; \
- movl _cpl,%eax ; \
- pushl %eax ; \
- pushl _intr_unit + (irq_num) * 4 ; \
- orl _intr_mask + (irq_num) * 4,%eax ; \
- movl %eax,_cpl ; \
- sti ; \
- call *_intr_handler + (irq_num) * 4 ; \
- cli ; /* must unmask _imen and icu atomically */ \
- movb _imen + IRQ_BYTE(irq_num),%al ; \
- andb $~IRQ_BIT(irq_num),%al ; \
- movb %al,_imen + IRQ_BYTE(irq_num) ; \
- outb %al,$icu+ICU_IMR_OFFSET ; \
- sti ; /* XXX _doreti repeats the cli/sti */ \
- MEXITCOUNT ; \
- /* We could usually avoid the following jmp by inlining some of */ \
- /* _doreti, but it's probably better to use less cache. */ \
- jmp _doreti ; \
-; \
- ALIGN_TEXT ; \
-2: ; \
- /* XXX skip mcounting here to avoid double count */ \
- orb $IRQ_BIT(irq_num),_ipending + IRQ_BYTE(irq_num) ; \
- popl %fs ; \
- popl %es ; \
- popl %ds ; \
- popal ; \
- addl $4+4,%esp ; \
- iret
-
-MCOUNT_LABEL(bintr)
- FAST_INTR(0,fastintr0, ENABLE_ICU1)
- FAST_INTR(1,fastintr1, ENABLE_ICU1)
- FAST_INTR(2,fastintr2, ENABLE_ICU1)
- FAST_INTR(3,fastintr3, ENABLE_ICU1)
- FAST_INTR(4,fastintr4, ENABLE_ICU1)
- FAST_INTR(5,fastintr5, ENABLE_ICU1)
- FAST_INTR(6,fastintr6, ENABLE_ICU1)
- FAST_INTR(7,fastintr7, ENABLE_ICU1)
- FAST_INTR(8,fastintr8, ENABLE_ICU1_AND_2)
- FAST_INTR(9,fastintr9, ENABLE_ICU1_AND_2)
- FAST_INTR(10,fastintr10, ENABLE_ICU1_AND_2)
- FAST_INTR(11,fastintr11, ENABLE_ICU1_AND_2)
- FAST_INTR(12,fastintr12, ENABLE_ICU1_AND_2)
- FAST_INTR(13,fastintr13, ENABLE_ICU1_AND_2)
- FAST_INTR(14,fastintr14, ENABLE_ICU1_AND_2)
- FAST_INTR(15,fastintr15, ENABLE_ICU1_AND_2)
-#define CLKINTR_PENDING movl $1,CNAME(clkintr_pending)
- INTR(0,intr0, IO_ICU1, ENABLE_ICU1, al, CLKINTR_PENDING)
- INTR(1,intr1, IO_ICU1, ENABLE_ICU1, al,)
- INTR(2,intr2, IO_ICU1, ENABLE_ICU1, al,)
- INTR(3,intr3, IO_ICU1, ENABLE_ICU1, al,)
- INTR(4,intr4, IO_ICU1, ENABLE_ICU1, al,)
- INTR(5,intr5, IO_ICU1, ENABLE_ICU1, al,)
- INTR(6,intr6, IO_ICU1, ENABLE_ICU1, al,)
- INTR(7,intr7, IO_ICU1, ENABLE_ICU1, al,)
- INTR(8,intr8, IO_ICU2, ENABLE_ICU1_AND_2, ah,)
- INTR(9,intr9, IO_ICU2, ENABLE_ICU1_AND_2, ah,)
- INTR(10,intr10, IO_ICU2, ENABLE_ICU1_AND_2, ah,)
- INTR(11,intr11, IO_ICU2, ENABLE_ICU1_AND_2, ah,)
- INTR(12,intr12, IO_ICU2, ENABLE_ICU1_AND_2, ah,)
- INTR(13,intr13, IO_ICU2, ENABLE_ICU1_AND_2, ah,)
- INTR(14,intr14, IO_ICU2, ENABLE_ICU1_AND_2, ah,)
- INTR(15,intr15, IO_ICU2, ENABLE_ICU1_AND_2, ah,)
-MCOUNT_LABEL(eintr)
-
- .data
- .globl _ihandlers
-_ihandlers: /* addresses of interrupt handlers */
- /* actually resumption addresses for HWI's */
- .long Xresume0, Xresume1, Xresume2, Xresume3
- .long Xresume4, Xresume5, Xresume6, Xresume7
- .long Xresume8, Xresume9, Xresume10, Xresume11
- .long Xresume12, Xresume13, Xresume14, Xresume15
- .long _swi_null, swi_net, _swi_null, _swi_null
- .long _swi_vm, _swi_null, _swi_null, _swi_null
- .long _swi_null, _swi_null, _swi_null, _swi_null
- .long _swi_null, _swi_null, _softclock, _swi_null
-
-imasks: /* masks for interrupt handlers */
- .space NHWI*4 /* padding; HWI masks are elsewhere */
-
- .long SWI_TTY_MASK, SWI_NET_MASK, SWI_CAMNET_MASK, SWI_CAMBIO_MASK
- .long SWI_VM_MASK, 0, 0, 0
- .long 0, 0, 0, 0
- .long 0, 0, SWI_CLOCK_MASK, 0
-
- .text
diff --git a/sys/amd64/isa/clock.c b/sys/amd64/isa/clock.c
deleted file mode 100644
index ea39018548b9..000000000000
--- a/sys/amd64/isa/clock.c
+++ /dev/null
@@ -1,1230 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz and Don Ahn.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)clock.c 7.2 (Berkeley) 5/12/91
- * $FreeBSD$
- */
-
-/*
- * Routines to handle clock hardware.
- */
-
-/*
- * inittodr, settodr and support routines written
- * by Christoph Robitschko <chmr@edvz.tu-graz.ac.at>
- *
- * reintroduced and updated by Chris Stenton <chris@gnome.co.uk> 8/10/94
- */
-
-#include "opt_clock.h"
-#include "apm.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/time.h>
-#include <sys/kernel.h>
-#ifndef SMP
-#include <sys/lock.h>
-#endif
-#include <sys/sysctl.h>
-#include <sys/cons.h>
-
-#include <machine/clock.h>
-#ifdef CLK_CALIBRATION_LOOP
-#endif
-#include <machine/cputypes.h>
-#include <machine/frame.h>
-#include <machine/ipl.h>
-#include <machine/limits.h>
-#include <machine/md_var.h>
-#include <machine/psl.h>
-#ifdef APIC_IO
-#include <machine/segments.h>
-#endif
-#if defined(SMP) || defined(APIC_IO)
-#include <machine/smp.h>
-#endif /* SMP || APIC_IO */
-#include <machine/specialreg.h>
-
-#include <i386/isa/icu.h>
-#include <i386/isa/isa.h>
-#include <isa/rtc.h>
-#include <i386/isa/timerreg.h>
-
-#include <i386/isa/intr_machdep.h>
-
-#include "mca.h"
-#if NMCA > 0
-#include <i386/isa/mca_machdep.h>
-#endif
-
-#ifdef SMP
-#define disable_intr() CLOCK_DISABLE_INTR()
-#define enable_intr() CLOCK_ENABLE_INTR()
-
-#ifdef APIC_IO
-#include <i386/isa/intr_machdep.h>
-/* The interrupt triggered by the 8254 (timer) chip */
-int apic_8254_intr;
-static u_long read_intr_count __P((int vec));
-static void setup_8254_mixed_mode __P((void));
-#endif
-#endif /* SMP */
-
-/*
- * 32-bit time_t's can't reach leap years before 1904 or after 2036, so we
- * can use a simple formula for leap years.
- */
-#define LEAPYEAR(y) ((u_int)(y) % 4 == 0)
-#define DAYSPERYEAR (31+28+31+30+31+30+31+31+30+31+30+31)
-
-#define TIMER_DIV(x) ((timer_freq + (x) / 2) / (x))
-
-/*
- * Time in timer cycles that it takes for microtime() to disable interrupts
- * and latch the count. microtime() currently uses "cli; outb ..." so it
- * normally takes less than 2 timer cycles. Add a few for cache misses.
- * Add a few more to allow for latency in bogus calls to microtime() with
- * interrupts already disabled.
- */
-#define TIMER0_LATCH_COUNT 20
-
-/*
- * Maximum frequency that we are willing to allow for timer0. Must be
- * low enough to guarantee that the timer interrupt handler returns
- * before the next timer interrupt.
- */
-#define TIMER0_MAX_FREQ 20000
-
-int adjkerntz; /* local offset from GMT in seconds */
-int clkintr_pending;
-int disable_rtc_set; /* disable resettodr() if != 0 */
-volatile u_int idelayed;
-int statclock_disable;
-u_int stat_imask = SWI_CLOCK_MASK;
-#ifndef TIMER_FREQ
-#define TIMER_FREQ 1193182
-#endif
-u_int timer_freq = TIMER_FREQ;
-int timer0_max_count;
-u_int tsc_freq;
-int tsc_is_broken;
-int wall_cmos_clock; /* wall CMOS clock assumed if != 0 */
-
-static int beeping = 0;
-static u_int clk_imask = HWI_MASK | SWI_MASK;
-static const u_char daysinmonth[] = {31,28,31,30,31,30,31,31,30,31,30,31};
-static u_int hardclock_max_count;
-static u_int32_t i8254_lastcount;
-static u_int32_t i8254_offset;
-static int i8254_ticked;
-/*
- * XXX new_function and timer_func should not handle clockframes, but
- * timer_func currently needs to hold hardclock to handle the
- * timer0_state == 0 case. We should use inthand_add()/inthand_remove()
- * to switch between clkintr() and a slightly different timerintr().
- */
-static void (*new_function) __P((struct clockframe *frame));
-static u_int new_rate;
-static u_char rtc_statusa = RTCSA_DIVIDER | RTCSA_NOPROF;
-static u_char rtc_statusb = RTCSB_24HR | RTCSB_PINTR;
-static u_int timer0_prescaler_count;
-
-/* Values for timerX_state: */
-#define RELEASED 0
-#define RELEASE_PENDING 1
-#define ACQUIRED 2
-#define ACQUIRE_PENDING 3
-
-static u_char timer0_state;
-static u_char timer2_state;
-static void (*timer_func) __P((struct clockframe *frame)) = hardclock;
-static u_int tsc_present;
-
-static unsigned i8254_get_timecount __P((struct timecounter *tc));
-static unsigned tsc_get_timecount __P((struct timecounter *tc));
-static void set_timer_freq(u_int freq, int intr_freq);
-
-static struct timecounter tsc_timecounter = {
- tsc_get_timecount, /* get_timecount */
- 0, /* no poll_pps */
- ~0u, /* counter_mask */
- 0, /* frequency */
- "TSC" /* name */
-};
-
-SYSCTL_OPAQUE(_debug, OID_AUTO, tsc_timecounter, CTLFLAG_RD,
- &tsc_timecounter, sizeof(tsc_timecounter), "S,timecounter", "");
-
-static struct timecounter i8254_timecounter = {
- i8254_get_timecount, /* get_timecount */
- 0, /* no poll_pps */
- ~0u, /* counter_mask */
- 0, /* frequency */
- "i8254" /* name */
-};
-
-SYSCTL_OPAQUE(_debug, OID_AUTO, i8254_timecounter, CTLFLAG_RD,
- &i8254_timecounter, sizeof(i8254_timecounter), "S,timecounter", "");
-
-static void
-clkintr(struct clockframe frame)
-{
- if (timecounter->tc_get_timecount == i8254_get_timecount) {
- disable_intr();
- if (i8254_ticked)
- i8254_ticked = 0;
- else {
- i8254_offset += timer0_max_count;
- i8254_lastcount = 0;
- }
- clkintr_pending = 0;
- enable_intr();
- }
- timer_func(&frame);
- switch (timer0_state) {
-
- case RELEASED:
- setdelayed();
- break;
-
- case ACQUIRED:
- if ((timer0_prescaler_count += timer0_max_count)
- >= hardclock_max_count) {
- timer0_prescaler_count -= hardclock_max_count;
- hardclock(&frame);
- setdelayed();
- }
- break;
-
- case ACQUIRE_PENDING:
- disable_intr();
- i8254_offset = i8254_get_timecount(NULL);
- i8254_lastcount = 0;
- timer0_max_count = TIMER_DIV(new_rate);
- outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
- outb(TIMER_CNTR0, timer0_max_count & 0xff);
- outb(TIMER_CNTR0, timer0_max_count >> 8);
- enable_intr();
- timer_func = new_function;
- timer0_state = ACQUIRED;
- setdelayed();
- break;
-
- case RELEASE_PENDING:
- if ((timer0_prescaler_count += timer0_max_count)
- >= hardclock_max_count) {
- disable_intr();
- i8254_offset = i8254_get_timecount(NULL);
- i8254_lastcount = 0;
- timer0_max_count = hardclock_max_count;
- outb(TIMER_MODE,
- TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
- outb(TIMER_CNTR0, timer0_max_count & 0xff);
- outb(TIMER_CNTR0, timer0_max_count >> 8);
- enable_intr();
- timer0_prescaler_count = 0;
- timer_func = hardclock;
- timer0_state = RELEASED;
- hardclock(&frame);
- setdelayed();
- }
- break;
- }
-#if NMCA > 0
- /* Reset clock interrupt by asserting bit 7 of port 0x61 */
- if (MCA_system)
- outb(0x61, inb(0x61) | 0x80);
-#endif
-}
-
-/*
- * The acquire and release functions must be called at ipl >= splclock().
- */
-int
-acquire_timer0(int rate, void (*function) __P((struct clockframe *frame)))
-{
- static int old_rate;
-
- if (rate <= 0 || rate > TIMER0_MAX_FREQ)
- return (-1);
- switch (timer0_state) {
-
- case RELEASED:
- timer0_state = ACQUIRE_PENDING;
- break;
-
- case RELEASE_PENDING:
- if (rate != old_rate)
- return (-1);
- /*
- * The timer has been released recently, but is being
- * re-acquired before the release completed. In this
- * case, we simply reclaim it as if it had not been
- * released at all.
- */
- timer0_state = ACQUIRED;
- break;
-
- default:
- return (-1); /* busy */
- }
- new_function = function;
- old_rate = new_rate = rate;
- return (0);
-}
-
-int
-acquire_timer2(int mode)
-{
-
- if (timer2_state != RELEASED)
- return (-1);
- timer2_state = ACQUIRED;
-
- /*
- * This access to the timer registers is as atomic as possible
- * because it is a single instruction. We could do better if we
- * knew the rate. Use of splclock() limits glitches to 10-100us,
- * and this is probably good enough for timer2, so we aren't as
- * careful with it as with timer0.
- */
- outb(TIMER_MODE, TIMER_SEL2 | (mode & 0x3f));
-
- return (0);
-}
-
-int
-release_timer0()
-{
- switch (timer0_state) {
-
- case ACQUIRED:
- timer0_state = RELEASE_PENDING;
- break;
-
- case ACQUIRE_PENDING:
- /* Nothing happened yet, release quickly. */
- timer0_state = RELEASED;
- break;
-
- default:
- return (-1);
- }
- return (0);
-}
-
-int
-release_timer2()
-{
-
- if (timer2_state != ACQUIRED)
- return (-1);
- timer2_state = RELEASED;
- outb(TIMER_MODE, TIMER_SEL2 | TIMER_SQWAVE | TIMER_16BIT);
- return (0);
-}
-
-/*
- * This routine receives statistical clock interrupts from the RTC.
- * As explained above, these occur at 128 interrupts per second.
- * When profiling, we receive interrupts at a rate of 1024 Hz.
- *
- * This does not actually add as much overhead as it sounds, because
- * when the statistical clock is active, the hardclock driver no longer
- * needs to keep (inaccurate) statistics on its own. This decouples
- * statistics gathering from scheduling interrupts.
- *
- * The RTC chip requires that we read status register C (RTC_INTR)
- * to acknowledge an interrupt, before it will generate the next one.
- * Under high interrupt load, rtcintr() can be indefinitely delayed and
- * the clock can tick immediately after the read from RTC_INTR. In this
- * case, the mc146818A interrupt signal will not drop for long enough
- * to register with the 8259 PIC. If an interrupt is missed, the stat
- * clock will halt, considerably degrading system performance. This is
- * why we use 'while' rather than a more straightforward 'if' below.
- * Stat clock ticks can still be lost, causing minor loss of accuracy
- * in the statistics, but the stat clock will no longer stop.
- */
-static void
-rtcintr(struct clockframe frame)
-{
- while (rtcin(RTC_INTR) & RTCIR_PERIOD)
- statclock(&frame);
-}
-
-#include "opt_ddb.h"
-#ifdef DDB
-#include <ddb/ddb.h>
-
-DB_SHOW_COMMAND(rtc, rtc)
-{
- printf("%02x/%02x/%02x %02x:%02x:%02x, A = %02x, B = %02x, C = %02x\n",
- rtcin(RTC_YEAR), rtcin(RTC_MONTH), rtcin(RTC_DAY),
- rtcin(RTC_HRS), rtcin(RTC_MIN), rtcin(RTC_SEC),
- rtcin(RTC_STATUSA), rtcin(RTC_STATUSB), rtcin(RTC_INTR));
-}
-#endif /* DDB */
-
-static int
-getit(void)
-{
- u_long ef;
- int high, low;
-
- ef = read_eflags();
- disable_intr();
-
- /* Select timer0 and latch counter value. */
- outb(TIMER_MODE, TIMER_SEL0 | TIMER_LATCH);
-
- low = inb(TIMER_CNTR0);
- high = inb(TIMER_CNTR0);
-
- CLOCK_UNLOCK();
- write_eflags(ef);
- return ((high << 8) | low);
-}
-
-/*
- * Wait "n" microseconds.
- * Relies on timer 1 counting down from (timer_freq / hz)
- * Note: timer had better have been programmed before this is first used!
- */
-void
-DELAY(int n)
-{
- int delta, prev_tick, tick, ticks_left;
-
-#ifdef DELAYDEBUG
- int getit_calls = 1;
- int n1;
- static int state = 0;
-
- if (state == 0) {
- state = 1;
- for (n1 = 1; n1 <= 10000000; n1 *= 10)
- DELAY(n1);
- state = 2;
- }
- if (state == 1)
- printf("DELAY(%d)...", n);
-#endif
- /*
- * Guard against the timer being uninitialized if we are called
- * early for console i/o.
- */
- if (timer0_max_count == 0)
- set_timer_freq(timer_freq, hz);
-
- /*
- * Read the counter first, so that the rest of the setup overhead is
- * counted. Guess the initial overhead is 20 usec (on most systems it
- * takes about 1.5 usec for each of the i/o's in getit(). The loop
- * takes about 6 usec on a 486/33 and 13 usec on a 386/20. The
- * multiplications and divisions to scale the count take a while).
- */
- prev_tick = getit();
- n -= 0; /* XXX actually guess no initial overhead */
- /*
- * Calculate (n * (timer_freq / 1e6)) without using floating point
- * and without any avoidable overflows.
- */
- if (n <= 0)
- ticks_left = 0;
- else if (n < 256)
- /*
- * Use fixed point to avoid a slow division by 1000000.
- * 39099 = 1193182 * 2^15 / 10^6 rounded to nearest.
- * 2^15 is the first power of 2 that gives exact results
- * for n between 0 and 256.
- */
- ticks_left = ((u_int)n * 39099 + (1 << 15) - 1) >> 15;
- else
- /*
- * Don't bother using fixed point, although gcc-2.7.2
- * generates particularly poor code for the long long
- * division, since even the slow way will complete long
- * before the delay is up (unless we're interrupted).
- */
- ticks_left = ((u_int)n * (long long)timer_freq + 999999)
- / 1000000;
-
- while (ticks_left > 0) {
- tick = getit();
-#ifdef DELAYDEBUG
- ++getit_calls;
-#endif
- delta = prev_tick - tick;
- prev_tick = tick;
- if (delta < 0) {
- delta += timer0_max_count;
- /*
- * Guard against timer0_max_count being wrong.
- * This shouldn't happen in normal operation,
- * but it may happen if set_timer_freq() is
- * traced.
- */
- if (delta < 0)
- delta = 0;
- }
- ticks_left -= delta;
- }
-#ifdef DELAYDEBUG
- if (state == 1)
- printf(" %d calls to getit() at %d usec each\n",
- getit_calls, (n + 5) / getit_calls);
-#endif
-}
-
-static void
-sysbeepstop(void *chan)
-{
- outb(IO_PPI, inb(IO_PPI)&0xFC); /* disable counter2 output to speaker */
- release_timer2();
- beeping = 0;
-}
-
-int
-sysbeep(int pitch, int period)
-{
- int x = splclock();
-
- if (acquire_timer2(TIMER_SQWAVE|TIMER_16BIT))
- if (!beeping) {
- /* Something else owns it. */
- splx(x);
- return (-1); /* XXX Should be EBUSY, but nobody cares anyway. */
- }
- disable_intr();
- outb(TIMER_CNTR2, pitch);
- outb(TIMER_CNTR2, (pitch>>8));
- enable_intr();
- if (!beeping) {
- /* enable counter2 output to speaker */
- outb(IO_PPI, inb(IO_PPI) | 3);
- beeping = period;
- timeout(sysbeepstop, (void *)NULL, period);
- }
- splx(x);
- return (0);
-}
-
-/*
- * RTC support routines
- */
-
-int
-rtcin(reg)
- int reg;
-{
- int s;
- u_char val;
-
- s = splhigh();
- outb(IO_RTC, reg);
- inb(0x84);
- val = inb(IO_RTC + 1);
- inb(0x84);
- splx(s);
- return (val);
-}
-
-static __inline void
-writertc(u_char reg, u_char val)
-{
- int s;
-
- s = splhigh();
- inb(0x84);
- outb(IO_RTC, reg);
- inb(0x84);
- outb(IO_RTC + 1, val);
- inb(0x84); /* XXX work around wrong order in rtcin() */
- splx(s);
-}
-
-static __inline int
-readrtc(int port)
-{
- return(bcd2bin(rtcin(port)));
-}
-
-static u_int
-calibrate_clocks(void)
-{
- u_int64_t old_tsc;
- u_int count, prev_count, tot_count;
- int sec, start_sec, timeout;
-
- if (bootverbose)
- printf("Calibrating clock(s) ... ");
- if (!(rtcin(RTC_STATUSD) & RTCSD_PWR))
- goto fail;
- timeout = 100000000;
-
- /* Read the mc146818A seconds counter. */
- for (;;) {
- if (!(rtcin(RTC_STATUSA) & RTCSA_TUP)) {
- sec = rtcin(RTC_SEC);
- break;
- }
- if (--timeout == 0)
- goto fail;
- }
-
- /* Wait for the mC146818A seconds counter to change. */
- start_sec = sec;
- for (;;) {
- if (!(rtcin(RTC_STATUSA) & RTCSA_TUP)) {
- sec = rtcin(RTC_SEC);
- if (sec != start_sec)
- break;
- }
- if (--timeout == 0)
- goto fail;
- }
-
- /* Start keeping track of the i8254 counter. */
- prev_count = getit();
- if (prev_count == 0 || prev_count > timer0_max_count)
- goto fail;
- tot_count = 0;
-
- if (tsc_present)
- old_tsc = rdtsc();
- else
- old_tsc = 0; /* shut up gcc */
-
- /*
- * Wait for the mc146818A seconds counter to change. Read the i8254
- * counter for each iteration since this is convenient and only
- * costs a few usec of inaccuracy. The timing of the final reads
- * of the counters almost matches the timing of the initial reads,
- * so the main cause of inaccuracy is the varying latency from
- * inside getit() or rtcin(RTC_STATUSA) to the beginning of the
- * rtcin(RTC_SEC) that returns a changed seconds count. The
- * maximum inaccuracy from this cause is < 10 usec on 486's.
- */
- start_sec = sec;
- for (;;) {
- if (!(rtcin(RTC_STATUSA) & RTCSA_TUP))
- sec = rtcin(RTC_SEC);
- count = getit();
- if (count == 0 || count > timer0_max_count)
- goto fail;
- if (count > prev_count)
- tot_count += prev_count - (count - timer0_max_count);
- else
- tot_count += prev_count - count;
- prev_count = count;
- if (sec != start_sec)
- break;
- if (--timeout == 0)
- goto fail;
- }
-
- /*
- * Read the cpu cycle counter. The timing considerations are
- * similar to those for the i8254 clock.
- */
- if (tsc_present)
- tsc_freq = rdtsc() - old_tsc;
-
- if (bootverbose) {
- if (tsc_present)
- printf("TSC clock: %u Hz, ", tsc_freq);
- printf("i8254 clock: %u Hz\n", tot_count);
- }
- return (tot_count);
-
-fail:
- if (bootverbose)
- printf("failed, using default i8254 clock of %u Hz\n",
- timer_freq);
- return (timer_freq);
-}
-
-static void
-set_timer_freq(u_int freq, int intr_freq)
-{
- u_long ef;
- int new_timer0_max_count;
-
- ef = read_eflags();
- disable_intr();
- timer_freq = freq;
- new_timer0_max_count = hardclock_max_count = TIMER_DIV(intr_freq);
- if (new_timer0_max_count != timer0_max_count) {
- timer0_max_count = new_timer0_max_count;
- outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
- outb(TIMER_CNTR0, timer0_max_count & 0xff);
- outb(TIMER_CNTR0, timer0_max_count >> 8);
- }
- CLOCK_UNLOCK();
- write_eflags(ef);
-}
-
-/*
- * i8254_restore is called from apm_default_resume() to reload
- * the countdown register.
- * this should not be necessary but there are broken laptops that
- * do not restore the countdown register on resume.
- * when it happnes, it messes up the hardclock interval and system clock,
- * which leads to the infamous "calcru: negative time" problem.
- */
-void
-i8254_restore(void)
-{
- u_long ef;
-
- ef = read_eflags();
- disable_intr();
- outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
- outb(TIMER_CNTR0, timer0_max_count & 0xff);
- outb(TIMER_CNTR0, timer0_max_count >> 8);
- CLOCK_UNLOCK();
- write_eflags(ef);
-}
-
-/*
- * Initialize 8254 timer 0 early so that it can be used in DELAY().
- * XXX initialization of other timers is unintentionally left blank.
- */
-void
-startrtclock()
-{
- u_int delta, freq;
-
- if (cpu_feature & CPUID_TSC)
- tsc_present = 1;
- else
- tsc_present = 0;
-
- writertc(RTC_STATUSA, rtc_statusa);
- writertc(RTC_STATUSB, RTCSB_24HR);
-
- set_timer_freq(timer_freq, hz);
- freq = calibrate_clocks();
-#ifdef CLK_CALIBRATION_LOOP
- if (bootverbose) {
- printf(
- "Press a key on the console to abort clock calibration\n");
- while (cncheckc() == -1)
- calibrate_clocks();
- }
-#endif
-
- /*
- * Use the calibrated i8254 frequency if it seems reasonable.
- * Otherwise use the default, and don't use the calibrated i586
- * frequency.
- */
- delta = freq > timer_freq ? freq - timer_freq : timer_freq - freq;
- if (delta < timer_freq / 100) {
-#ifndef CLK_USE_I8254_CALIBRATION
- if (bootverbose)
- printf(
-"CLK_USE_I8254_CALIBRATION not specified - using default frequency\n");
- freq = timer_freq;
-#endif
- timer_freq = freq;
- } else {
- if (bootverbose)
- printf(
- "%d Hz differs from default of %d Hz by more than 1%%\n",
- freq, timer_freq);
- tsc_freq = 0;
- }
-
- set_timer_freq(timer_freq, hz);
- i8254_timecounter.tc_frequency = timer_freq;
- init_timecounter(&i8254_timecounter);
-
-#ifndef CLK_USE_TSC_CALIBRATION
- if (tsc_freq != 0) {
- if (bootverbose)
- printf(
-"CLK_USE_TSC_CALIBRATION not specified - using old calibration method\n");
- tsc_freq = 0;
- }
-#endif
- if (tsc_present && tsc_freq == 0) {
- /*
- * Calibration of the i586 clock relative to the mc146818A
- * clock failed. Do a less accurate calibration relative
- * to the i8254 clock.
- */
- u_int64_t old_tsc = rdtsc();
-
- DELAY(1000000);
- tsc_freq = rdtsc() - old_tsc;
-#ifdef CLK_USE_TSC_CALIBRATION
- if (bootverbose)
- printf("TSC clock: %u Hz (Method B)\n", tsc_freq);
-#endif
- }
-
-#if !defined(SMP)
- /*
- * We can not use the TSC in SMP mode, until we figure out a
- * cheap (impossible), reliable and precise (yeah right!) way
- * to synchronize the TSCs of all the CPUs.
- * Curse Intel for leaving the counter out of the I/O APIC.
- */
-
-#if NAPM > 0
- /*
- * We can not use the TSC if we support APM. Precise timekeeping
- * on an APM'ed machine is at best a fools pursuit, since
- * any and all of the time spent in various SMM code can't
- * be reliably accounted for. Reading the RTC is your only
- * source of reliable time info. The i8254 looses too of course
- * but we need to have some kind of time...
- * We don't know at this point whether APM is going to be used
- * or not, nor when it might be activated. Play it safe.
- */
- return;
-#endif /* NAPM > 0 */
-
- if (tsc_present && tsc_freq != 0 && !tsc_is_broken) {
- tsc_timecounter.tc_frequency = tsc_freq;
- init_timecounter(&tsc_timecounter);
- }
-
-#endif /* !defined(SMP) */
-}
-
-/*
- * Initialize the time of day register, based on the time base which is, e.g.
- * from a filesystem.
- */
-void
-inittodr(time_t base)
-{
- unsigned long sec, days;
- int yd;
- int year, month;
- int y, m, s;
- struct timespec ts;
-
- if (base) {
- s = splclock();
- ts.tv_sec = base;
- ts.tv_nsec = 0;
- set_timecounter(&ts);
- splx(s);
- }
-
- /* Look if we have a RTC present and the time is valid */
- if (!(rtcin(RTC_STATUSD) & RTCSD_PWR))
- goto wrong_time;
-
- /* wait for time update to complete */
- /* If RTCSA_TUP is zero, we have at least 244us before next update */
- s = splhigh();
- while (rtcin(RTC_STATUSA) & RTCSA_TUP) {
- splx(s);
- s = splhigh();
- }
-
- days = 0;
-#ifdef USE_RTC_CENTURY
- year = readrtc(RTC_YEAR) + readrtc(RTC_CENTURY) * 100;
-#else
- year = readrtc(RTC_YEAR) + 1900;
- if (year < 1970)
- year += 100;
-#endif
- if (year < 1970) {
- splx(s);
- goto wrong_time;
- }
- month = readrtc(RTC_MONTH);
- for (m = 1; m < month; m++)
- days += daysinmonth[m-1];
- if ((month > 2) && LEAPYEAR(year))
- days ++;
- days += readrtc(RTC_DAY) - 1;
- yd = days;
- for (y = 1970; y < year; y++)
- days += DAYSPERYEAR + LEAPYEAR(y);
- sec = ((( days * 24 +
- readrtc(RTC_HRS)) * 60 +
- readrtc(RTC_MIN)) * 60 +
- readrtc(RTC_SEC));
- /* sec now contains the number of seconds, since Jan 1 1970,
- in the local time zone */
-
- sec += tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
-
- y = time_second - sec;
- if (y <= -2 || y >= 2) {
- /* badly off, adjust it */
- ts.tv_sec = sec;
- ts.tv_nsec = 0;
- set_timecounter(&ts);
- }
- splx(s);
- return;
-
-wrong_time:
- printf("Invalid time in real time clock.\n");
- printf("Check and reset the date immediately!\n");
-}
-
-/*
- * Write system time back to RTC
- */
-void
-resettodr()
-{
- unsigned long tm;
- int y, m, s;
-
- if (disable_rtc_set)
- return;
-
- s = splclock();
- tm = time_second;
- splx(s);
-
- /* Disable RTC updates and interrupts. */
- writertc(RTC_STATUSB, RTCSB_HALT | RTCSB_24HR);
-
- /* Calculate local time to put in RTC */
-
- tm -= tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
-
- writertc(RTC_SEC, bin2bcd(tm%60)); tm /= 60; /* Write back Seconds */
- writertc(RTC_MIN, bin2bcd(tm%60)); tm /= 60; /* Write back Minutes */
- writertc(RTC_HRS, bin2bcd(tm%24)); tm /= 24; /* Write back Hours */
-
- /* We have now the days since 01-01-1970 in tm */
- writertc(RTC_WDAY, (tm+4)%7); /* Write back Weekday */
- for (y = 1970, m = DAYSPERYEAR + LEAPYEAR(y);
- tm >= m;
- y++, m = DAYSPERYEAR + LEAPYEAR(y))
- tm -= m;
-
- /* Now we have the years in y and the day-of-the-year in tm */
- writertc(RTC_YEAR, bin2bcd(y%100)); /* Write back Year */
-#ifdef USE_RTC_CENTURY
- writertc(RTC_CENTURY, bin2bcd(y/100)); /* ... and Century */
-#endif
- for (m = 0; ; m++) {
- int ml;
-
- ml = daysinmonth[m];
- if (m == 1 && LEAPYEAR(y))
- ml++;
- if (tm < ml)
- break;
- tm -= ml;
- }
-
- writertc(RTC_MONTH, bin2bcd(m + 1)); /* Write back Month */
- writertc(RTC_DAY, bin2bcd(tm + 1)); /* Write back Month Day */
-
- /* Reenable RTC updates and interrupts. */
- writertc(RTC_STATUSB, rtc_statusb);
-}
-
-
-/*
- * Start both clocks running.
- */
-void
-cpu_initclocks()
-{
- int diag;
-#ifdef APIC_IO
- int apic_8254_trial;
- struct intrec *clkdesc;
-#endif /* APIC_IO */
-
- if (statclock_disable) {
- /*
- * The stat interrupt mask is different without the
- * statistics clock. Also, don't set the interrupt
- * flag which would normally cause the RTC to generate
- * interrupts.
- */
- stat_imask = HWI_MASK | SWI_MASK;
- rtc_statusb = RTCSB_24HR;
- } else {
- /* Setting stathz to nonzero early helps avoid races. */
- stathz = RTC_NOPROFRATE;
- profhz = RTC_PROFRATE;
- }
-
- /* Finish initializing 8253 timer 0. */
-#ifdef APIC_IO
-
- apic_8254_intr = isa_apic_irq(0);
- apic_8254_trial = 0;
- if (apic_8254_intr >= 0 ) {
- if (apic_int_type(0, 0) == 3)
- apic_8254_trial = 1;
- } else {
- /* look for ExtInt on pin 0 */
- if (apic_int_type(0, 0) == 3) {
- apic_8254_intr = apic_irq(0, 0);
- setup_8254_mixed_mode();
- } else
- panic("APIC_IO: Cannot route 8254 interrupt to CPU");
- }
-
- clkdesc = inthand_add("clk", apic_8254_intr, (inthand2_t *)clkintr,
- NULL, &clk_imask, INTR_EXCL);
- INTREN(1 << apic_8254_intr);
-
-#else /* APIC_IO */
-
- inthand_add("clk", 0, (inthand2_t *)clkintr, NULL, &clk_imask,
- INTR_EXCL);
- INTREN(IRQ0);
-
-#endif /* APIC_IO */
-
- /* Initialize RTC. */
- writertc(RTC_STATUSA, rtc_statusa);
- writertc(RTC_STATUSB, RTCSB_24HR);
-
- /* Don't bother enabling the statistics clock. */
- if (statclock_disable)
- return;
- diag = rtcin(RTC_DIAG);
- if (diag != 0)
- printf("RTC BIOS diagnostic error %b\n", diag, RTCDG_BITS);
-
-#ifdef APIC_IO
- if (isa_apic_irq(8) != 8)
- panic("APIC RTC != 8");
-#endif /* APIC_IO */
-
- inthand_add("rtc", 8, (inthand2_t *)rtcintr, NULL, &stat_imask,
- INTR_EXCL);
-
-#ifdef APIC_IO
- INTREN(APIC_IRQ8);
-#else
- INTREN(IRQ8);
-#endif /* APIC_IO */
-
- writertc(RTC_STATUSB, rtc_statusb);
-
-#ifdef APIC_IO
- if (apic_8254_trial) {
-
- printf("APIC_IO: Testing 8254 interrupt delivery\n");
- while (read_intr_count(8) < 6)
- ; /* nothing */
- if (read_intr_count(apic_8254_intr) < 3) {
- /*
- * The MP table is broken.
- * The 8254 was not connected to the specified pin
- * on the IO APIC.
- * Workaround: Limited variant of mixed mode.
- */
- INTRDIS(1 << apic_8254_intr);
- inthand_remove(clkdesc);
- printf("APIC_IO: Broken MP table detected: "
- "8254 is not connected to "
- "IOAPIC #%d intpin %d\n",
- int_to_apicintpin[apic_8254_intr].ioapic,
- int_to_apicintpin[apic_8254_intr].int_pin);
- /*
- * Revoke current ISA IRQ 0 assignment and
- * configure a fallback interrupt routing from
- * the 8254 Timer via the 8259 PIC to the
- * an ExtInt interrupt line on IOAPIC #0 intpin 0.
- * We reuse the low level interrupt handler number.
- */
- if (apic_irq(0, 0) < 0) {
- revoke_apic_irq(apic_8254_intr);
- assign_apic_irq(0, 0, apic_8254_intr);
- }
- apic_8254_intr = apic_irq(0, 0);
- setup_8254_mixed_mode();
- inthand_add("clk", apic_8254_intr,
- (inthand2_t *)clkintr,
- NULL, &clk_imask, INTR_EXCL);
- INTREN(1 << apic_8254_intr);
- }
-
- }
- if (apic_int_type(0, 0) != 3 ||
- int_to_apicintpin[apic_8254_intr].ioapic != 0 ||
- int_to_apicintpin[apic_8254_intr].int_pin != 0)
- printf("APIC_IO: routing 8254 via IOAPIC #%d intpin %d\n",
- int_to_apicintpin[apic_8254_intr].ioapic,
- int_to_apicintpin[apic_8254_intr].int_pin);
- else
- printf("APIC_IO: "
- "routing 8254 via 8259 and IOAPIC #0 intpin 0\n");
-#endif
-
-}
-
-#ifdef APIC_IO
-static u_long
-read_intr_count(int vec)
-{
- u_long *up;
- up = intr_countp[vec];
- if (up)
- return *up;
- return 0UL;
-}
-
-static void
-setup_8254_mixed_mode()
-{
- /*
- * Allow 8254 timer to INTerrupt 8259:
- * re-initialize master 8259:
- * reset; prog 4 bytes, single ICU, edge triggered
- */
- outb(IO_ICU1, 0x13);
- outb(IO_ICU1 + 1, NRSVIDT); /* start vector (unused) */
- outb(IO_ICU1 + 1, 0x00); /* ignore slave */
- outb(IO_ICU1 + 1, 0x03); /* auto EOI, 8086 */
- outb(IO_ICU1 + 1, 0xfe); /* unmask INT0 */
-
- /* program IO APIC for type 3 INT on INT0 */
- if (ext_int_setup(0, 0) < 0)
- panic("8254 redirect via APIC pin0 impossible!");
-}
-#endif
-
-void
-setstatclockrate(int newhz)
-{
- if (newhz == RTC_PROFRATE)
- rtc_statusa = RTCSA_DIVIDER | RTCSA_PROF;
- else
- rtc_statusa = RTCSA_DIVIDER | RTCSA_NOPROF;
- writertc(RTC_STATUSA, rtc_statusa);
-}
-
-static int
-sysctl_machdep_i8254_freq SYSCTL_HANDLER_ARGS
-{
- int error;
- u_int freq;
-
- /*
- * Use `i8254' instead of `timer' in external names because `timer'
- * is is too generic. Should use it everywhere.
- */
- freq = timer_freq;
- error = sysctl_handle_int(oidp, &freq, sizeof(freq), req);
- if (error == 0 && req->newptr != NULL) {
- if (timer0_state != RELEASED)
- return (EBUSY); /* too much trouble to handle */
- set_timer_freq(freq, hz);
- i8254_timecounter.tc_frequency = freq;
- update_timecounter(&i8254_timecounter);
- }
- return (error);
-}
-
-SYSCTL_PROC(_machdep, OID_AUTO, i8254_freq, CTLTYPE_INT | CTLFLAG_RW,
- 0, sizeof(u_int), sysctl_machdep_i8254_freq, "I", "");
-
-static int
-sysctl_machdep_tsc_freq SYSCTL_HANDLER_ARGS
-{
- int error;
- u_int freq;
-
- if (tsc_timecounter.tc_frequency == 0)
- return (EOPNOTSUPP);
- freq = tsc_freq;
- error = sysctl_handle_int(oidp, &freq, sizeof(freq), req);
- if (error == 0 && req->newptr != NULL) {
- tsc_freq = freq;
- tsc_timecounter.tc_frequency = tsc_freq;
- update_timecounter(&tsc_timecounter);
- }
- return (error);
-}
-
-SYSCTL_PROC(_machdep, OID_AUTO, tsc_freq, CTLTYPE_INT | CTLFLAG_RW,
- 0, sizeof(u_int), sysctl_machdep_tsc_freq, "I", "");
-
-static unsigned
-i8254_get_timecount(struct timecounter *tc)
-{
- u_int count;
- u_long ef;
- u_int high, low;
-
- ef = read_eflags();
- disable_intr();
-
- /* Select timer0 and latch counter value. */
- outb(TIMER_MODE, TIMER_SEL0 | TIMER_LATCH);
-
- low = inb(TIMER_CNTR0);
- high = inb(TIMER_CNTR0);
- count = timer0_max_count - ((high << 8) | low);
- if (count < i8254_lastcount ||
- (!i8254_ticked && (clkintr_pending ||
- ((count < 20 || (!(ef & PSL_I) && count < timer0_max_count / 2u)) &&
-#ifdef APIC_IO
-#define lapic_irr1 ((volatile u_int *)&lapic)[0x210 / 4] /* XXX XXX */
- /* XXX this assumes that apic_8254_intr is < 24. */
- (lapic_irr1 & (1 << apic_8254_intr))))
-#else
- (inb(IO_ICU1) & 1)))
-#endif
- )) {
- i8254_ticked = 1;
- i8254_offset += timer0_max_count;
- }
- i8254_lastcount = count;
- count += i8254_offset;
- CLOCK_UNLOCK();
- write_eflags(ef);
- return (count);
-}
-
-static unsigned
-tsc_get_timecount(struct timecounter *tc)
-{
- return (rdtsc());
-}
diff --git a/sys/amd64/isa/icu.h b/sys/amd64/isa/icu.h
deleted file mode 100644
index ed3a87902495..000000000000
--- a/sys/amd64/isa/icu.h
+++ /dev/null
@@ -1,157 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)icu.h 5.6 (Berkeley) 5/9/91
- * $FreeBSD$
- */
-
-/*
- * AT/386 Interrupt Control constants
- * W. Jolitz 8/89
- */
-
-#ifndef _I386_ISA_ICU_H_
-#define _I386_ISA_ICU_H_
-
-#ifndef LOCORE
-
-#ifdef APIC_IO
-
-/*
-#define MP_SAFE
- * Note:
- * Most of the SMP equivilants of the icu macros are coded
- * elsewhere in an MP-safe fashion.
- * In particular note that the 'imen' variable is opaque.
- * DO NOT access imen directly, use INTREN()/INTRDIS().
- */
-
-void INTREN __P((u_int));
-void INTRDIS __P((u_int));
-
-#else /* APIC_IO */
-
-/*
- * Interrupt "level" mechanism variables, masks, and macros
- */
-extern unsigned imen; /* interrupt mask enable */
-
-#define INTREN(s) (imen &= ~(s), SET_ICUS())
-#define INTRDIS(s) (imen |= (s), SET_ICUS())
-
-#if 0
-#ifdef PC98
-#define SET_ICUS() (outb(IO_ICU1 + 2, imen), outb(IU_ICU2 + 2, imen >> 8))
-#define INTRGET() ((inb(IO_ICU2) << 8 | inb(IO_ICU1)) & 0xffff)
-#else /* IBM-PC */
-#define SET_ICUS() (outb(IO_ICU1 + 1, imen), outb(IU_ICU2 + 1, imen >> 8))
-#define INTRGET() ((inb(IO_ICU2) << 8 | inb(IO_ICU1)) & 0xffff)
-#endif /* PC98 */
-#else
-/*
- * XXX - IO_ICU* are defined in isa.h, not icu.h, and nothing much bothers to
- * include isa.h, while too many things include icu.h.
- */
-#ifdef PC98
-#define SET_ICUS() (outb(0x02, imen), outb(0x0a, imen >> 8))
-/* XXX is this correct? */
-#define INTRGET() ((inb(0x0a) << 8 | inb(0x02)) & 0xffff)
-#else
-#define SET_ICUS() (outb(0x21, imen), outb(0xa1, imen >> 8))
-#define INTRGET() ((inb(0xa1) << 8 | inb(0x21)) & 0xffff)
-#endif
-#endif
-
-#endif /* APIC_IO */
-
-#endif /* LOCORE */
-
-
-#ifdef APIC_IO
-/*
- * Note: The APIC uses different values for IRQxxx.
- * Unfortunately many drivers use the 8259 values as indexes
- * into tables, etc. The APIC equivilants are kept as APIC_IRQxxx.
- * The 8259 versions have to be used in SMP for legacy operation
- * of the drivers.
- */
-#endif /* APIC_IO */
-
-/*
- * Interrupt enable bits - in normal order of priority (which we change)
- */
-#define IRQ0 0x0001 /* highest priority - timer */
-#define IRQ1 0x0002
-#define IRQ_SLAVE 0x0004
-#define IRQ8 0x0100
-#define IRQ9 0x0200
-#define IRQ2 IRQ9
-#define IRQ10 0x0400
-#define IRQ11 0x0800
-#define IRQ12 0x1000
-#define IRQ13 0x2000
-#define IRQ14 0x4000
-#define IRQ15 0x8000
-#define IRQ3 0x0008 /* this is highest after rotation */
-#define IRQ4 0x0010
-#define IRQ5 0x0020
-#define IRQ6 0x0040
-#define IRQ7 0x0080 /* lowest - parallel printer */
-
-#ifdef PC98
-#undef IRQ2
-#define IRQ2 0x0004
-#undef IRQ_SLAVE
-#define IRQ_SLAVE 0x0080
-#endif
-
-
-/*
- * Interrupt Control offset into Interrupt descriptor table (IDT)
- */
-#define ICU_OFFSET 32 /* 0-31 are processor exceptions */
-
-#ifdef APIC_IO
-
-/* 32-47: ISA IRQ0-IRQ15, 48-55: IO APIC IRQ16-IRQ23 */
-#define ICU_LEN 24
-
-#else
-
-#define ICU_LEN 16 /* 32-47 are ISA interrupts */
-
-#endif /* APIC_IO */
-
-#endif /* !_I386_ISA_ICU_H_ */
diff --git a/sys/amd64/isa/icu_ipl.S b/sys/amd64/isa/icu_ipl.S
deleted file mode 100644
index 34753583a41e..000000000000
--- a/sys/amd64/isa/icu_ipl.S
+++ /dev/null
@@ -1,168 +0,0 @@
-/*-
- * Copyright (c) 1989, 1990 William F. Jolitz.
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- */
-
- .data
- ALIGN_DATA
-vec:
- .long vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7
- .long vec8, vec9, vec10, vec11, vec12, vec13, vec14, vec15
-
-/* interrupt mask enable (all h/w off) */
- .globl _imen
-_imen: .long HWI_MASK
-
-
-/*
- *
- */
- .text
- SUPERALIGN_TEXT
-
-/*
- * Interrupt priority mechanism
- * -- soft splXX masks with group mechanism (cpl)
- * -- h/w masks for currently active or unused interrupts (imen)
- * -- ipending = active interrupts currently masked by cpl
- */
-
-ENTRY(splz)
- /*
- * The caller has restored cpl and checked that (ipending & ~cpl)
- * is nonzero. We have to repeat the check since if there is an
- * interrupt while we're looking, _doreti processing for the
- * interrupt will handle all the unmasked pending interrupts
- * because we restored early. We're repeating the calculation
- * of (ipending & ~cpl) anyway so that the caller doesn't have
- * to pass it, so this only costs one "jne". "bsfl %ecx,%ecx"
- * is undefined when %ecx is 0 so we can't rely on the secondary
- * btrl tests.
- */
- movl _cpl,%eax
-splz_next:
- /*
- * We don't need any locking here. (ipending & ~cpl) cannot grow
- * while we're looking at it - any interrupt will shrink it to 0.
- */
- movl %eax,%ecx
- notl %ecx
- andl _ipending,%ecx
- jne splz_unpend
- ret
-
- ALIGN_TEXT
-splz_unpend:
- bsfl %ecx,%ecx
- btrl %ecx,_ipending
- jnc splz_next
- cmpl $NHWI,%ecx
- jae splz_swi
- /*
- * We would prefer to call the intr handler directly here but that
- * doesn't work for badly behaved handlers that want the interrupt
- * frame. Also, there's a problem determining the unit number.
- * We should change the interface so that the unit number is not
- * determined at config time.
- */
- jmp *vec(,%ecx,4)
-
- ALIGN_TEXT
-splz_swi:
- pushl %eax
- orl imasks(,%ecx,4),%eax
- movl %eax,_cpl
- call *_ihandlers(,%ecx,4)
- popl %eax
- movl %eax,_cpl
- jmp splz_next
-
-/*
- * Fake clock interrupt(s) so that they appear to come from our caller instead
- * of from here, so that system profiling works.
- * XXX do this more generally (for all vectors; look up the C entry point).
- * XXX frame bogusness stops us from just jumping to the C entry point.
- */
- ALIGN_TEXT
-vec0:
- popl %eax /* return address */
- pushfl
- pushl $KCSEL
- pushl %eax
- cli
- MEXITCOUNT
- jmp _Xintr0 /* XXX might need _Xfastintr0 */
-
-#ifndef PC98
- ALIGN_TEXT
-vec8:
- popl %eax
- pushfl
- pushl $KCSEL
- pushl %eax
- cli
- MEXITCOUNT
- jmp _Xintr8 /* XXX might need _Xfastintr8 */
-#endif /* PC98 */
-
-/*
- * The 'generic' vector stubs.
- */
-
-#define BUILD_VEC(irq_num) \
- ALIGN_TEXT ; \
-__CONCAT(vec,irq_num): ; \
- int $ICU_OFFSET + (irq_num) ; \
- ret
-
- BUILD_VEC(1)
- BUILD_VEC(2)
- BUILD_VEC(3)
- BUILD_VEC(4)
- BUILD_VEC(5)
- BUILD_VEC(6)
- BUILD_VEC(7)
-#ifdef PC98
- BUILD_VEC(8)
-#endif
- BUILD_VEC(9)
- BUILD_VEC(10)
- BUILD_VEC(11)
- BUILD_VEC(12)
- BUILD_VEC(13)
- BUILD_VEC(14)
- BUILD_VEC(15)
diff --git a/sys/amd64/isa/icu_ipl.s b/sys/amd64/isa/icu_ipl.s
deleted file mode 100644
index 34753583a41e..000000000000
--- a/sys/amd64/isa/icu_ipl.s
+++ /dev/null
@@ -1,168 +0,0 @@
-/*-
- * Copyright (c) 1989, 1990 William F. Jolitz.
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- */
-
- .data
- ALIGN_DATA
-vec:
- .long vec0, vec1, vec2, vec3, vec4, vec5, vec6, vec7
- .long vec8, vec9, vec10, vec11, vec12, vec13, vec14, vec15
-
-/* interrupt mask enable (all h/w off) */
- .globl _imen
-_imen: .long HWI_MASK
-
-
-/*
- *
- */
- .text
- SUPERALIGN_TEXT
-
-/*
- * Interrupt priority mechanism
- * -- soft splXX masks with group mechanism (cpl)
- * -- h/w masks for currently active or unused interrupts (imen)
- * -- ipending = active interrupts currently masked by cpl
- */
-
-ENTRY(splz)
- /*
- * The caller has restored cpl and checked that (ipending & ~cpl)
- * is nonzero. We have to repeat the check since if there is an
- * interrupt while we're looking, _doreti processing for the
- * interrupt will handle all the unmasked pending interrupts
- * because we restored early. We're repeating the calculation
- * of (ipending & ~cpl) anyway so that the caller doesn't have
- * to pass it, so this only costs one "jne". "bsfl %ecx,%ecx"
- * is undefined when %ecx is 0 so we can't rely on the secondary
- * btrl tests.
- */
- movl _cpl,%eax
-splz_next:
- /*
- * We don't need any locking here. (ipending & ~cpl) cannot grow
- * while we're looking at it - any interrupt will shrink it to 0.
- */
- movl %eax,%ecx
- notl %ecx
- andl _ipending,%ecx
- jne splz_unpend
- ret
-
- ALIGN_TEXT
-splz_unpend:
- bsfl %ecx,%ecx
- btrl %ecx,_ipending
- jnc splz_next
- cmpl $NHWI,%ecx
- jae splz_swi
- /*
- * We would prefer to call the intr handler directly here but that
- * doesn't work for badly behaved handlers that want the interrupt
- * frame. Also, there's a problem determining the unit number.
- * We should change the interface so that the unit number is not
- * determined at config time.
- */
- jmp *vec(,%ecx,4)
-
- ALIGN_TEXT
-splz_swi:
- pushl %eax
- orl imasks(,%ecx,4),%eax
- movl %eax,_cpl
- call *_ihandlers(,%ecx,4)
- popl %eax
- movl %eax,_cpl
- jmp splz_next
-
-/*
- * Fake clock interrupt(s) so that they appear to come from our caller instead
- * of from here, so that system profiling works.
- * XXX do this more generally (for all vectors; look up the C entry point).
- * XXX frame bogusness stops us from just jumping to the C entry point.
- */
- ALIGN_TEXT
-vec0:
- popl %eax /* return address */
- pushfl
- pushl $KCSEL
- pushl %eax
- cli
- MEXITCOUNT
- jmp _Xintr0 /* XXX might need _Xfastintr0 */
-
-#ifndef PC98
- ALIGN_TEXT
-vec8:
- popl %eax
- pushfl
- pushl $KCSEL
- pushl %eax
- cli
- MEXITCOUNT
- jmp _Xintr8 /* XXX might need _Xfastintr8 */
-#endif /* PC98 */
-
-/*
- * The 'generic' vector stubs.
- */
-
-#define BUILD_VEC(irq_num) \
- ALIGN_TEXT ; \
-__CONCAT(vec,irq_num): ; \
- int $ICU_OFFSET + (irq_num) ; \
- ret
-
- BUILD_VEC(1)
- BUILD_VEC(2)
- BUILD_VEC(3)
- BUILD_VEC(4)
- BUILD_VEC(5)
- BUILD_VEC(6)
- BUILD_VEC(7)
-#ifdef PC98
- BUILD_VEC(8)
-#endif
- BUILD_VEC(9)
- BUILD_VEC(10)
- BUILD_VEC(11)
- BUILD_VEC(12)
- BUILD_VEC(13)
- BUILD_VEC(14)
- BUILD_VEC(15)
diff --git a/sys/amd64/isa/icu_vector.S b/sys/amd64/isa/icu_vector.S
deleted file mode 100644
index 24ce97b666b9..000000000000
--- a/sys/amd64/isa/icu_vector.S
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * from: vector.s, 386BSD 0.1 unknown origin
- * $FreeBSD$
- */
-
-/*
- * modified for PC98 by Kakefuda
- */
-
-#ifdef PC98
-#define ICU_IMR_OFFSET 2 /* IO_ICU{1,2} + 2 */
-#else
-#define ICU_IMR_OFFSET 1 /* IO_ICU{1,2} + 1 */
-#endif
-
-#define ICU_EOI 0x20 /* XXX - define elsewhere */
-
-#define IRQ_BIT(irq_num) (1 << ((irq_num) % 8))
-#define IRQ_BYTE(irq_num) ((irq_num) >> 3)
-
-#ifdef AUTO_EOI_1
-#define ENABLE_ICU1 /* use auto-EOI to reduce i/o */
-#define OUTB_ICU1
-#else
-#define ENABLE_ICU1 \
- movb $ICU_EOI,%al ; /* as soon as possible send EOI ... */ \
- OUTB_ICU1 /* ... to clear in service bit */
-#define OUTB_ICU1 \
- outb %al,$IO_ICU1
-#endif
-
-#ifdef AUTO_EOI_2
-/*
- * The data sheet says no auto-EOI on slave, but it sometimes works.
- */
-#define ENABLE_ICU1_AND_2 ENABLE_ICU1
-#else
-#define ENABLE_ICU1_AND_2 \
- movb $ICU_EOI,%al ; /* as above */ \
- outb %al,$IO_ICU2 ; /* but do second icu first ... */ \
- OUTB_ICU1 /* ... then first icu (if !AUTO_EOI_1) */
-#endif
-
-/*
- * Macros for interrupt interrupt entry, call to handler, and exit.
- */
-
-#define FAST_INTR(irq_num, vec_name, enable_icus) \
- .text ; \
- SUPERALIGN_TEXT ; \
-IDTVEC(vec_name) ; \
- pushl %eax ; /* save only call-used registers */ \
- pushl %ecx ; \
- pushl %edx ; \
- pushl %ds ; \
- MAYBE_PUSHL_ES ; \
- movl $KDSEL,%eax ; \
- movl %ax,%ds ; \
- MAYBE_MOVW_AX_ES ; \
- FAKE_MCOUNT((4+ACTUALLY_PUSHED)*4(%esp)) ; \
- pushl _intr_unit + (irq_num) * 4 ; \
- call *_intr_handler + (irq_num) * 4 ; /* do the work ASAP */ \
- enable_icus ; /* (re)enable ASAP (helps edge trigger?) */ \
- addl $4,%esp ; \
- incl _cnt+V_INTR ; /* book-keeping can wait */ \
- movl _intr_countp + (irq_num) * 4,%eax ; \
- incl (%eax) ; \
- movl _cpl,%eax ; /* are we unmasking pending HWIs or SWIs? */ \
- notl %eax ; \
- andl _ipending,%eax ; \
- jne 2f ; /* yes, maybe handle them */ \
-1: ; \
- MEXITCOUNT ; \
- MAYBE_POPL_ES ; \
- popl %ds ; \
- popl %edx ; \
- popl %ecx ; \
- popl %eax ; \
- iret ; \
-; \
- ALIGN_TEXT ; \
-2: ; \
- cmpb $3,_intr_nesting_level ; /* is there enough stack? */ \
- jae 1b ; /* no, return */ \
- movl _cpl,%eax ; \
- /* XXX next line is probably unnecessary now. */ \
- movl $HWI_MASK|SWI_MASK,_cpl ; /* limit nesting ... */ \
- incb _intr_nesting_level ; /* ... really limit it ... */ \
- sti ; /* ... to do this as early as possible */ \
- MAYBE_POPL_ES ; /* discard most of thin frame ... */ \
- popl %ecx ; /* ... original %ds ... */ \
- popl %edx ; \
- xchgl %eax,4(%esp) ; /* orig %eax; save cpl */ \
- pushal ; /* build fat frame (grrr) ... */ \
- pushl %ecx ; /* ... actually %ds ... */ \
- pushl %es ; \
- pushl %fs ; \
- movl $KDSEL,%eax ; \
- movl %ax,%es ; \
- movl %ax,%fs ; \
- movl (3+8+0)*4(%esp),%ecx ; /* ... %ecx from thin frame ... */ \
- movl %ecx,(3+6)*4(%esp) ; /* ... to fat frame ... */ \
- movl (3+8+1)*4(%esp),%eax ; /* ... cpl from thin frame */ \
- pushl %eax ; \
- subl $4,%esp ; /* junk for unit number */ \
- MEXITCOUNT ; \
- jmp _doreti
-
-#define INTR(irq_num, vec_name, icu, enable_icus, reg, maybe_extra_ipending) \
- .text ; \
- SUPERALIGN_TEXT ; \
-IDTVEC(vec_name) ; \
- pushl $0 ; /* dummy error code */ \
- pushl $0 ; /* dummy trap type */ \
- pushal ; \
- pushl %ds ; /* save our data and extra segments ... */ \
- pushl %es ; \
- pushl %fs ; \
- movl $KDSEL,%eax ; /* ... and reload with kernel's own ... */ \
- movl %ax,%ds ; /* ... early for obsolete reasons */ \
- movl %ax,%es ; \
- movl %ax,%fs ; \
- maybe_extra_ipending ; \
- movb _imen + IRQ_BYTE(irq_num),%al ; \
- orb $IRQ_BIT(irq_num),%al ; \
- movb %al,_imen + IRQ_BYTE(irq_num) ; \
- outb %al,$icu+ICU_IMR_OFFSET ; \
- enable_icus ; \
- movl _cpl,%eax ; \
- testb $IRQ_BIT(irq_num),%reg ; \
- jne 2f ; \
- incb _intr_nesting_level ; \
-__CONCAT(Xresume,irq_num): ; \
- FAKE_MCOUNT(13*4(%esp)) ; /* XXX late to avoid double count */ \
- incl _cnt+V_INTR ; /* tally interrupts */ \
- movl _intr_countp + (irq_num) * 4,%eax ; \
- incl (%eax) ; \
- movl _cpl,%eax ; \
- pushl %eax ; \
- pushl _intr_unit + (irq_num) * 4 ; \
- orl _intr_mask + (irq_num) * 4,%eax ; \
- movl %eax,_cpl ; \
- sti ; \
- call *_intr_handler + (irq_num) * 4 ; \
- cli ; /* must unmask _imen and icu atomically */ \
- movb _imen + IRQ_BYTE(irq_num),%al ; \
- andb $~IRQ_BIT(irq_num),%al ; \
- movb %al,_imen + IRQ_BYTE(irq_num) ; \
- outb %al,$icu+ICU_IMR_OFFSET ; \
- sti ; /* XXX _doreti repeats the cli/sti */ \
- MEXITCOUNT ; \
- /* We could usually avoid the following jmp by inlining some of */ \
- /* _doreti, but it's probably better to use less cache. */ \
- jmp _doreti ; \
-; \
- ALIGN_TEXT ; \
-2: ; \
- /* XXX skip mcounting here to avoid double count */ \
- orb $IRQ_BIT(irq_num),_ipending + IRQ_BYTE(irq_num) ; \
- popl %fs ; \
- popl %es ; \
- popl %ds ; \
- popal ; \
- addl $4+4,%esp ; \
- iret
-
-MCOUNT_LABEL(bintr)
- FAST_INTR(0,fastintr0, ENABLE_ICU1)
- FAST_INTR(1,fastintr1, ENABLE_ICU1)
- FAST_INTR(2,fastintr2, ENABLE_ICU1)
- FAST_INTR(3,fastintr3, ENABLE_ICU1)
- FAST_INTR(4,fastintr4, ENABLE_ICU1)
- FAST_INTR(5,fastintr5, ENABLE_ICU1)
- FAST_INTR(6,fastintr6, ENABLE_ICU1)
- FAST_INTR(7,fastintr7, ENABLE_ICU1)
- FAST_INTR(8,fastintr8, ENABLE_ICU1_AND_2)
- FAST_INTR(9,fastintr9, ENABLE_ICU1_AND_2)
- FAST_INTR(10,fastintr10, ENABLE_ICU1_AND_2)
- FAST_INTR(11,fastintr11, ENABLE_ICU1_AND_2)
- FAST_INTR(12,fastintr12, ENABLE_ICU1_AND_2)
- FAST_INTR(13,fastintr13, ENABLE_ICU1_AND_2)
- FAST_INTR(14,fastintr14, ENABLE_ICU1_AND_2)
- FAST_INTR(15,fastintr15, ENABLE_ICU1_AND_2)
-#define CLKINTR_PENDING movl $1,CNAME(clkintr_pending)
- INTR(0,intr0, IO_ICU1, ENABLE_ICU1, al, CLKINTR_PENDING)
- INTR(1,intr1, IO_ICU1, ENABLE_ICU1, al,)
- INTR(2,intr2, IO_ICU1, ENABLE_ICU1, al,)
- INTR(3,intr3, IO_ICU1, ENABLE_ICU1, al,)
- INTR(4,intr4, IO_ICU1, ENABLE_ICU1, al,)
- INTR(5,intr5, IO_ICU1, ENABLE_ICU1, al,)
- INTR(6,intr6, IO_ICU1, ENABLE_ICU1, al,)
- INTR(7,intr7, IO_ICU1, ENABLE_ICU1, al,)
- INTR(8,intr8, IO_ICU2, ENABLE_ICU1_AND_2, ah,)
- INTR(9,intr9, IO_ICU2, ENABLE_ICU1_AND_2, ah,)
- INTR(10,intr10, IO_ICU2, ENABLE_ICU1_AND_2, ah,)
- INTR(11,intr11, IO_ICU2, ENABLE_ICU1_AND_2, ah,)
- INTR(12,intr12, IO_ICU2, ENABLE_ICU1_AND_2, ah,)
- INTR(13,intr13, IO_ICU2, ENABLE_ICU1_AND_2, ah,)
- INTR(14,intr14, IO_ICU2, ENABLE_ICU1_AND_2, ah,)
- INTR(15,intr15, IO_ICU2, ENABLE_ICU1_AND_2, ah,)
-MCOUNT_LABEL(eintr)
-
- .data
- .globl _ihandlers
-_ihandlers: /* addresses of interrupt handlers */
- /* actually resumption addresses for HWI's */
- .long Xresume0, Xresume1, Xresume2, Xresume3
- .long Xresume4, Xresume5, Xresume6, Xresume7
- .long Xresume8, Xresume9, Xresume10, Xresume11
- .long Xresume12, Xresume13, Xresume14, Xresume15
- .long _swi_null, swi_net, _swi_null, _swi_null
- .long _swi_vm, _swi_null, _swi_null, _swi_null
- .long _swi_null, _swi_null, _swi_null, _swi_null
- .long _swi_null, _swi_null, _softclock, _swi_null
-
-imasks: /* masks for interrupt handlers */
- .space NHWI*4 /* padding; HWI masks are elsewhere */
-
- .long SWI_TTY_MASK, SWI_NET_MASK, SWI_CAMNET_MASK, SWI_CAMBIO_MASK
- .long SWI_VM_MASK, 0, 0, 0
- .long 0, 0, 0, 0
- .long 0, 0, SWI_CLOCK_MASK, 0
-
- .text
diff --git a/sys/amd64/isa/icu_vector.s b/sys/amd64/isa/icu_vector.s
deleted file mode 100644
index 24ce97b666b9..000000000000
--- a/sys/amd64/isa/icu_vector.s
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * from: vector.s, 386BSD 0.1 unknown origin
- * $FreeBSD$
- */
-
-/*
- * modified for PC98 by Kakefuda
- */
-
-#ifdef PC98
-#define ICU_IMR_OFFSET 2 /* IO_ICU{1,2} + 2 */
-#else
-#define ICU_IMR_OFFSET 1 /* IO_ICU{1,2} + 1 */
-#endif
-
-#define ICU_EOI 0x20 /* XXX - define elsewhere */
-
-#define IRQ_BIT(irq_num) (1 << ((irq_num) % 8))
-#define IRQ_BYTE(irq_num) ((irq_num) >> 3)
-
-#ifdef AUTO_EOI_1
-#define ENABLE_ICU1 /* use auto-EOI to reduce i/o */
-#define OUTB_ICU1
-#else
-#define ENABLE_ICU1 \
- movb $ICU_EOI,%al ; /* as soon as possible send EOI ... */ \
- OUTB_ICU1 /* ... to clear in service bit */
-#define OUTB_ICU1 \
- outb %al,$IO_ICU1
-#endif
-
-#ifdef AUTO_EOI_2
-/*
- * The data sheet says no auto-EOI on slave, but it sometimes works.
- */
-#define ENABLE_ICU1_AND_2 ENABLE_ICU1
-#else
-#define ENABLE_ICU1_AND_2 \
- movb $ICU_EOI,%al ; /* as above */ \
- outb %al,$IO_ICU2 ; /* but do second icu first ... */ \
- OUTB_ICU1 /* ... then first icu (if !AUTO_EOI_1) */
-#endif
-
-/*
- * Macros for interrupt interrupt entry, call to handler, and exit.
- */
-
-#define FAST_INTR(irq_num, vec_name, enable_icus) \
- .text ; \
- SUPERALIGN_TEXT ; \
-IDTVEC(vec_name) ; \
- pushl %eax ; /* save only call-used registers */ \
- pushl %ecx ; \
- pushl %edx ; \
- pushl %ds ; \
- MAYBE_PUSHL_ES ; \
- movl $KDSEL,%eax ; \
- movl %ax,%ds ; \
- MAYBE_MOVW_AX_ES ; \
- FAKE_MCOUNT((4+ACTUALLY_PUSHED)*4(%esp)) ; \
- pushl _intr_unit + (irq_num) * 4 ; \
- call *_intr_handler + (irq_num) * 4 ; /* do the work ASAP */ \
- enable_icus ; /* (re)enable ASAP (helps edge trigger?) */ \
- addl $4,%esp ; \
- incl _cnt+V_INTR ; /* book-keeping can wait */ \
- movl _intr_countp + (irq_num) * 4,%eax ; \
- incl (%eax) ; \
- movl _cpl,%eax ; /* are we unmasking pending HWIs or SWIs? */ \
- notl %eax ; \
- andl _ipending,%eax ; \
- jne 2f ; /* yes, maybe handle them */ \
-1: ; \
- MEXITCOUNT ; \
- MAYBE_POPL_ES ; \
- popl %ds ; \
- popl %edx ; \
- popl %ecx ; \
- popl %eax ; \
- iret ; \
-; \
- ALIGN_TEXT ; \
-2: ; \
- cmpb $3,_intr_nesting_level ; /* is there enough stack? */ \
- jae 1b ; /* no, return */ \
- movl _cpl,%eax ; \
- /* XXX next line is probably unnecessary now. */ \
- movl $HWI_MASK|SWI_MASK,_cpl ; /* limit nesting ... */ \
- incb _intr_nesting_level ; /* ... really limit it ... */ \
- sti ; /* ... to do this as early as possible */ \
- MAYBE_POPL_ES ; /* discard most of thin frame ... */ \
- popl %ecx ; /* ... original %ds ... */ \
- popl %edx ; \
- xchgl %eax,4(%esp) ; /* orig %eax; save cpl */ \
- pushal ; /* build fat frame (grrr) ... */ \
- pushl %ecx ; /* ... actually %ds ... */ \
- pushl %es ; \
- pushl %fs ; \
- movl $KDSEL,%eax ; \
- movl %ax,%es ; \
- movl %ax,%fs ; \
- movl (3+8+0)*4(%esp),%ecx ; /* ... %ecx from thin frame ... */ \
- movl %ecx,(3+6)*4(%esp) ; /* ... to fat frame ... */ \
- movl (3+8+1)*4(%esp),%eax ; /* ... cpl from thin frame */ \
- pushl %eax ; \
- subl $4,%esp ; /* junk for unit number */ \
- MEXITCOUNT ; \
- jmp _doreti
-
-#define INTR(irq_num, vec_name, icu, enable_icus, reg, maybe_extra_ipending) \
- .text ; \
- SUPERALIGN_TEXT ; \
-IDTVEC(vec_name) ; \
- pushl $0 ; /* dummy error code */ \
- pushl $0 ; /* dummy trap type */ \
- pushal ; \
- pushl %ds ; /* save our data and extra segments ... */ \
- pushl %es ; \
- pushl %fs ; \
- movl $KDSEL,%eax ; /* ... and reload with kernel's own ... */ \
- movl %ax,%ds ; /* ... early for obsolete reasons */ \
- movl %ax,%es ; \
- movl %ax,%fs ; \
- maybe_extra_ipending ; \
- movb _imen + IRQ_BYTE(irq_num),%al ; \
- orb $IRQ_BIT(irq_num),%al ; \
- movb %al,_imen + IRQ_BYTE(irq_num) ; \
- outb %al,$icu+ICU_IMR_OFFSET ; \
- enable_icus ; \
- movl _cpl,%eax ; \
- testb $IRQ_BIT(irq_num),%reg ; \
- jne 2f ; \
- incb _intr_nesting_level ; \
-__CONCAT(Xresume,irq_num): ; \
- FAKE_MCOUNT(13*4(%esp)) ; /* XXX late to avoid double count */ \
- incl _cnt+V_INTR ; /* tally interrupts */ \
- movl _intr_countp + (irq_num) * 4,%eax ; \
- incl (%eax) ; \
- movl _cpl,%eax ; \
- pushl %eax ; \
- pushl _intr_unit + (irq_num) * 4 ; \
- orl _intr_mask + (irq_num) * 4,%eax ; \
- movl %eax,_cpl ; \
- sti ; \
- call *_intr_handler + (irq_num) * 4 ; \
- cli ; /* must unmask _imen and icu atomically */ \
- movb _imen + IRQ_BYTE(irq_num),%al ; \
- andb $~IRQ_BIT(irq_num),%al ; \
- movb %al,_imen + IRQ_BYTE(irq_num) ; \
- outb %al,$icu+ICU_IMR_OFFSET ; \
- sti ; /* XXX _doreti repeats the cli/sti */ \
- MEXITCOUNT ; \
- /* We could usually avoid the following jmp by inlining some of */ \
- /* _doreti, but it's probably better to use less cache. */ \
- jmp _doreti ; \
-; \
- ALIGN_TEXT ; \
-2: ; \
- /* XXX skip mcounting here to avoid double count */ \
- orb $IRQ_BIT(irq_num),_ipending + IRQ_BYTE(irq_num) ; \
- popl %fs ; \
- popl %es ; \
- popl %ds ; \
- popal ; \
- addl $4+4,%esp ; \
- iret
-
-MCOUNT_LABEL(bintr)
- FAST_INTR(0,fastintr0, ENABLE_ICU1)
- FAST_INTR(1,fastintr1, ENABLE_ICU1)
- FAST_INTR(2,fastintr2, ENABLE_ICU1)
- FAST_INTR(3,fastintr3, ENABLE_ICU1)
- FAST_INTR(4,fastintr4, ENABLE_ICU1)
- FAST_INTR(5,fastintr5, ENABLE_ICU1)
- FAST_INTR(6,fastintr6, ENABLE_ICU1)
- FAST_INTR(7,fastintr7, ENABLE_ICU1)
- FAST_INTR(8,fastintr8, ENABLE_ICU1_AND_2)
- FAST_INTR(9,fastintr9, ENABLE_ICU1_AND_2)
- FAST_INTR(10,fastintr10, ENABLE_ICU1_AND_2)
- FAST_INTR(11,fastintr11, ENABLE_ICU1_AND_2)
- FAST_INTR(12,fastintr12, ENABLE_ICU1_AND_2)
- FAST_INTR(13,fastintr13, ENABLE_ICU1_AND_2)
- FAST_INTR(14,fastintr14, ENABLE_ICU1_AND_2)
- FAST_INTR(15,fastintr15, ENABLE_ICU1_AND_2)
-#define CLKINTR_PENDING movl $1,CNAME(clkintr_pending)
- INTR(0,intr0, IO_ICU1, ENABLE_ICU1, al, CLKINTR_PENDING)
- INTR(1,intr1, IO_ICU1, ENABLE_ICU1, al,)
- INTR(2,intr2, IO_ICU1, ENABLE_ICU1, al,)
- INTR(3,intr3, IO_ICU1, ENABLE_ICU1, al,)
- INTR(4,intr4, IO_ICU1, ENABLE_ICU1, al,)
- INTR(5,intr5, IO_ICU1, ENABLE_ICU1, al,)
- INTR(6,intr6, IO_ICU1, ENABLE_ICU1, al,)
- INTR(7,intr7, IO_ICU1, ENABLE_ICU1, al,)
- INTR(8,intr8, IO_ICU2, ENABLE_ICU1_AND_2, ah,)
- INTR(9,intr9, IO_ICU2, ENABLE_ICU1_AND_2, ah,)
- INTR(10,intr10, IO_ICU2, ENABLE_ICU1_AND_2, ah,)
- INTR(11,intr11, IO_ICU2, ENABLE_ICU1_AND_2, ah,)
- INTR(12,intr12, IO_ICU2, ENABLE_ICU1_AND_2, ah,)
- INTR(13,intr13, IO_ICU2, ENABLE_ICU1_AND_2, ah,)
- INTR(14,intr14, IO_ICU2, ENABLE_ICU1_AND_2, ah,)
- INTR(15,intr15, IO_ICU2, ENABLE_ICU1_AND_2, ah,)
-MCOUNT_LABEL(eintr)
-
- .data
- .globl _ihandlers
-_ihandlers: /* addresses of interrupt handlers */
- /* actually resumption addresses for HWI's */
- .long Xresume0, Xresume1, Xresume2, Xresume3
- .long Xresume4, Xresume5, Xresume6, Xresume7
- .long Xresume8, Xresume9, Xresume10, Xresume11
- .long Xresume12, Xresume13, Xresume14, Xresume15
- .long _swi_null, swi_net, _swi_null, _swi_null
- .long _swi_vm, _swi_null, _swi_null, _swi_null
- .long _swi_null, _swi_null, _swi_null, _swi_null
- .long _swi_null, _swi_null, _softclock, _swi_null
-
-imasks: /* masks for interrupt handlers */
- .space NHWI*4 /* padding; HWI masks are elsewhere */
-
- .long SWI_TTY_MASK, SWI_NET_MASK, SWI_CAMNET_MASK, SWI_CAMBIO_MASK
- .long SWI_VM_MASK, 0, 0, 0
- .long 0, 0, 0, 0
- .long 0, 0, SWI_CLOCK_MASK, 0
-
- .text
diff --git a/sys/amd64/isa/intr_machdep.c b/sys/amd64/isa/intr_machdep.c
deleted file mode 100644
index d1f46ca4d8cf..000000000000
--- a/sys/amd64/isa/intr_machdep.c
+++ /dev/null
@@ -1,850 +0,0 @@
-/*-
- * Copyright (c) 1991 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)isa.c 7.2 (Berkeley) 5/13/91
- * $FreeBSD$
- */
-/*
- * This file contains an aggregated module marked:
- * Copyright (c) 1997, Stefan Esser <se@freebsd.org>
- * All rights reserved.
- * See the notice for details.
- */
-
-#include "opt_auto_eoi.h"
-
-#include "isa.h"
-
-#include <sys/param.h>
-#ifndef SMP
-#include <machine/lock.h>
-#endif
-#include <sys/systm.h>
-#include <sys/syslog.h>
-#include <sys/malloc.h>
-#include <sys/errno.h>
-#include <sys/interrupt.h>
-#include <machine/ipl.h>
-#include <machine/md_var.h>
-#include <machine/segments.h>
-#include <sys/bus.h>
-
-#if defined(APIC_IO)
-#include <machine/smp.h>
-#include <machine/smptests.h> /** FAST_HI */
-#endif /* APIC_IO */
-#ifdef PC98
-#include <pc98/pc98/pc98.h>
-#include <pc98/pc98/pc98_machdep.h>
-#include <pc98/pc98/epsonio.h>
-#else
-#include <i386/isa/isa.h>
-#endif
-#include <i386/isa/icu.h>
-
-#if NISA > 0
-#include <isa/isavar.h>
-#endif
-#include <i386/isa/intr_machdep.h>
-#include <sys/interrupt.h>
-#ifdef APIC_IO
-#include <machine/clock.h>
-#endif
-
-#include "mca.h"
-#if NMCA > 0
-#include <i386/isa/mca_machdep.h>
-#endif
-
-/* XXX should be in suitable include files */
-#ifdef PC98
-#define ICU_IMR_OFFSET 2 /* IO_ICU{1,2} + 2 */
-#define ICU_SLAVEID 7
-#else
-#define ICU_IMR_OFFSET 1 /* IO_ICU{1,2} + 1 */
-#define ICU_SLAVEID 2
-#endif
-
-#ifdef APIC_IO
-/*
- * This is to accommodate "mixed-mode" programming for
- * motherboards that don't connect the 8254 to the IO APIC.
- */
-#define AUTO_EOI_1 1
-#endif
-
-#define NR_INTRNAMES (1 + ICU_LEN + 2 * ICU_LEN)
-
-u_long *intr_countp[ICU_LEN];
-inthand2_t *intr_handler[ICU_LEN];
-u_int intr_mask[ICU_LEN];
-static u_int* intr_mptr[ICU_LEN];
-void *intr_unit[ICU_LEN];
-
-static inthand_t *fastintr[ICU_LEN] = {
- &IDTVEC(fastintr0), &IDTVEC(fastintr1),
- &IDTVEC(fastintr2), &IDTVEC(fastintr3),
- &IDTVEC(fastintr4), &IDTVEC(fastintr5),
- &IDTVEC(fastintr6), &IDTVEC(fastintr7),
- &IDTVEC(fastintr8), &IDTVEC(fastintr9),
- &IDTVEC(fastintr10), &IDTVEC(fastintr11),
- &IDTVEC(fastintr12), &IDTVEC(fastintr13),
- &IDTVEC(fastintr14), &IDTVEC(fastintr15),
-#if defined(APIC_IO)
- &IDTVEC(fastintr16), &IDTVEC(fastintr17),
- &IDTVEC(fastintr18), &IDTVEC(fastintr19),
- &IDTVEC(fastintr20), &IDTVEC(fastintr21),
- &IDTVEC(fastintr22), &IDTVEC(fastintr23),
-#endif /* APIC_IO */
-};
-
-static inthand_t *slowintr[ICU_LEN] = {
- &IDTVEC(intr0), &IDTVEC(intr1), &IDTVEC(intr2), &IDTVEC(intr3),
- &IDTVEC(intr4), &IDTVEC(intr5), &IDTVEC(intr6), &IDTVEC(intr7),
- &IDTVEC(intr8), &IDTVEC(intr9), &IDTVEC(intr10), &IDTVEC(intr11),
- &IDTVEC(intr12), &IDTVEC(intr13), &IDTVEC(intr14), &IDTVEC(intr15),
-#if defined(APIC_IO)
- &IDTVEC(intr16), &IDTVEC(intr17), &IDTVEC(intr18), &IDTVEC(intr19),
- &IDTVEC(intr20), &IDTVEC(intr21), &IDTVEC(intr22), &IDTVEC(intr23),
-#endif /* APIC_IO */
-};
-
-static inthand2_t isa_strayintr;
-
-#ifdef PC98
-#define NMI_PARITY 0x04
-#define NMI_EPARITY 0x02
-#else
-#define NMI_PARITY (1 << 7)
-#define NMI_IOCHAN (1 << 6)
-#define ENMI_WATCHDOG (1 << 7)
-#define ENMI_BUSTIMER (1 << 6)
-#define ENMI_IOSTATUS (1 << 5)
-#endif
-
-/*
- * Handle a NMI, possibly a machine check.
- * return true to panic system, false to ignore.
- */
-int
-isa_nmi(cd)
- int cd;
-{
-#ifdef PC98
- int port = inb(0x33);
- if (epson_machine_id == 0x20)
- epson_outb(0xc16, epson_inb(0xc16) | 0x1);
- if (port & NMI_PARITY) {
- panic("BASE RAM parity error, likely hardware failure.");
- } else if (port & NMI_EPARITY) {
- panic("EXTENDED RAM parity error, likely hardware failure.");
- } else {
- printf("\nNMI Resume ??\n");
- return(0);
- }
-#else /* IBM-PC */
- int isa_port = inb(0x61);
- int eisa_port = inb(0x461);
-
-#if NMCA > 0
- if (MCA_system && mca_bus_nmi())
- return(0);
-#endif
-
- if (isa_port & NMI_PARITY)
- panic("RAM parity error, likely hardware failure.");
-
- if (isa_port & NMI_IOCHAN)
- panic("I/O channel check, likely hardware failure.");
-
- /*
- * On a real EISA machine, this will never happen. However it can
- * happen on ISA machines which implement XT style floating point
- * error handling (very rare). Save them from a meaningless panic.
- */
- if (eisa_port == 0xff)
- return(0);
-
- if (eisa_port & ENMI_WATCHDOG)
- panic("EISA watchdog timer expired, likely hardware failure.");
-
- if (eisa_port & ENMI_BUSTIMER)
- panic("EISA bus timeout, likely hardware failure.");
-
- if (eisa_port & ENMI_IOSTATUS)
- panic("EISA I/O port status error.");
-
- printf("\nNMI ISA %x, EISA %x\n", isa_port, eisa_port);
- return(0);
-#endif
-}
-
-/*
- * Fill in default interrupt table (in case of spuruious interrupt
- * during configuration of kernel, setup interrupt control unit
- */
-void
-isa_defaultirq()
-{
- int i;
-
- /* icu vectors */
- for (i = 0; i < ICU_LEN; i++)
- icu_unset(i, (inthand2_t *)NULL);
-
- /* initialize 8259's */
-#if NMCA > 0
- if (MCA_system)
- outb(IO_ICU1, 0x19); /* reset; program device, four bytes */
- else
-#endif
- outb(IO_ICU1, 0x11); /* reset; program device, four bytes */
-
- outb(IO_ICU1+ICU_IMR_OFFSET, NRSVIDT); /* starting at this vector index */
- outb(IO_ICU1+ICU_IMR_OFFSET, IRQ_SLAVE); /* slave on line 7 */
-#ifdef PC98
-#ifdef AUTO_EOI_1
- outb(IO_ICU1+ICU_IMR_OFFSET, 0x1f); /* (master) auto EOI, 8086 mode */
-#else
- outb(IO_ICU1+ICU_IMR_OFFSET, 0x1d); /* (master) 8086 mode */
-#endif
-#else /* IBM-PC */
-#ifdef AUTO_EOI_1
- outb(IO_ICU1+ICU_IMR_OFFSET, 2 | 1); /* auto EOI, 8086 mode */
-#else
- outb(IO_ICU1+ICU_IMR_OFFSET, 1); /* 8086 mode */
-#endif
-#endif /* PC98 */
- outb(IO_ICU1+ICU_IMR_OFFSET, 0xff); /* leave interrupts masked */
- outb(IO_ICU1, 0x0a); /* default to IRR on read */
-#ifndef PC98
- outb(IO_ICU1, 0xc0 | (3 - 1)); /* pri order 3-7, 0-2 (com2 first) */
-#endif /* !PC98 */
-
-#if NMCA > 0
- if (MCA_system)
- outb(IO_ICU2, 0x19); /* reset; program device, four bytes */
- else
-#endif
- outb(IO_ICU2, 0x11); /* reset; program device, four bytes */
-
- outb(IO_ICU2+ICU_IMR_OFFSET, NRSVIDT+8); /* staring at this vector index */
- outb(IO_ICU2+ICU_IMR_OFFSET, ICU_SLAVEID); /* my slave id is 7 */
-#ifdef PC98
- outb(IO_ICU2+ICU_IMR_OFFSET,9); /* 8086 mode */
-#else /* IBM-PC */
-#ifdef AUTO_EOI_2
- outb(IO_ICU2+ICU_IMR_OFFSET, 2 | 1); /* auto EOI, 8086 mode */
-#else
- outb(IO_ICU2+ICU_IMR_OFFSET,1); /* 8086 mode */
-#endif
-#endif /* PC98 */
- outb(IO_ICU2+ICU_IMR_OFFSET, 0xff); /* leave interrupts masked */
- outb(IO_ICU2, 0x0a); /* default to IRR on read */
-}
-
-/*
- * Caught a stray interrupt, notify
- */
-static void
-isa_strayintr(vcookiep)
- void *vcookiep;
-{
- int intr = (void **)vcookiep - &intr_unit[0];
-
- /* DON'T BOTHER FOR NOW! */
- /* for some reason, we get bursts of intr #7, even if not enabled! */
- /*
- * Well the reason you got bursts of intr #7 is because someone
- * raised an interrupt line and dropped it before the 8259 could
- * prioritize it. This is documented in the intel data book. This
- * means you have BAD hardware! I have changed this so that only
- * the first 5 get logged, then it quits logging them, and puts
- * out a special message. rgrimes 3/25/1993
- */
- /*
- * XXX TODO print a different message for #7 if it is for a
- * glitch. Glitches can be distinguished from real #7's by
- * testing that the in-service bit is _not_ set. The test
- * must be done before sending an EOI so it can't be done if
- * we are using AUTO_EOI_1.
- */
- if (intrcnt[1 + intr] <= 5)
- log(LOG_ERR, "stray irq %d\n", intr);
- if (intrcnt[1 + intr] == 5)
- log(LOG_CRIT,
- "too many stray irq %d's; not logging any more\n", intr);
-}
-
-#if NISA > 0
-/*
- * Return a bitmap of the current interrupt requests. This is 8259-specific
- * and is only suitable for use at probe time.
- */
-intrmask_t
-isa_irq_pending()
-{
- u_char irr1;
- u_char irr2;
-
- irr1 = inb(IO_ICU1);
- irr2 = inb(IO_ICU2);
- return ((irr2 << 8) | irr1);
-}
-#endif
-
-int
-update_intr_masks(void)
-{
- int intr, n=0;
- u_int mask,*maskptr;
-
- for (intr=0; intr < ICU_LEN; intr ++) {
-#if defined(APIC_IO)
- /* no 8259 SLAVE to ignore */
-#else
- if (intr==ICU_SLAVEID) continue; /* ignore 8259 SLAVE output */
-#endif /* APIC_IO */
- maskptr = intr_mptr[intr];
- if (!maskptr)
- continue;
- *maskptr |= SWI_CLOCK_MASK | (1 << intr);
- mask = *maskptr;
- if (mask != intr_mask[intr]) {
-#if 0
- printf ("intr_mask[%2d] old=%08x new=%08x ptr=%p.\n",
- intr, intr_mask[intr], mask, maskptr);
-#endif
- intr_mask[intr]=mask;
- n++;
- }
-
- }
- return (n);
-}
-
-static void
-update_intrname(int intr, char *name)
-{
- char buf[32];
- char *cp;
- int name_index, off, strayintr;
-
- /*
- * Initialise strings for bitbucket and stray interrupt counters.
- * These have statically allocated indices 0 and 1 through ICU_LEN.
- */
- if (intrnames[0] == '\0') {
- off = sprintf(intrnames, "???") + 1;
- for (strayintr = 0; strayintr < ICU_LEN; strayintr++)
- off += sprintf(intrnames + off, "stray irq%d",
- strayintr) + 1;
- }
-
- if (name == NULL)
- name = "???";
- if (snprintf(buf, sizeof(buf), "%s irq%d", name, intr) >= sizeof(buf))
- goto use_bitbucket;
-
- /*
- * Search for `buf' in `intrnames'. In the usual case when it is
- * not found, append it to the end if there is enough space (the \0
- * terminator for the previous string, if any, becomes a separator).
- */
- for (cp = intrnames, name_index = 0;
- cp != eintrnames && name_index < NR_INTRNAMES;
- cp += strlen(cp) + 1, name_index++) {
- if (*cp == '\0') {
- if (strlen(buf) >= eintrnames - cp)
- break;
- strcpy(cp, buf);
- goto found;
- }
- if (strcmp(cp, buf) == 0)
- goto found;
- }
-
-use_bitbucket:
- printf("update_intrname: counting %s irq%d as %s\n", name, intr,
- intrnames);
- name_index = 0;
-found:
- intr_countp[intr] = &intrcnt[name_index];
-}
-
-int
-icu_setup(int intr, inthand2_t *handler, void *arg, u_int *maskptr, int flags)
-{
-#ifdef FAST_HI
- int select; /* the select register is 8 bits */
- int vector;
- u_int32_t value; /* the window register is 32 bits */
-#endif /* FAST_HI */
- u_long ef;
- u_int mask = (maskptr ? *maskptr : 0);
-
-#if defined(APIC_IO)
- if ((u_int)intr >= ICU_LEN) /* no 8259 SLAVE to ignore */
-#else
- if ((u_int)intr >= ICU_LEN || intr == ICU_SLAVEID)
-#endif /* APIC_IO */
- if (intr_handler[intr] != isa_strayintr)
- return (EBUSY);
-
- ef = read_eflags();
- disable_intr();
- intr_handler[intr] = handler;
- intr_mptr[intr] = maskptr;
- intr_mask[intr] = mask | SWI_CLOCK_MASK | (1 << intr);
- intr_unit[intr] = arg;
-#ifdef FAST_HI
- if (flags & INTR_FAST) {
- vector = TPR_FAST_INTS + intr;
- setidt(vector, fastintr[intr],
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- }
- else {
- vector = TPR_SLOW_INTS + intr;
-#ifdef APIC_INTR_REORDER
-#ifdef APIC_INTR_HIGHPRI_CLOCK
- /* XXX: Hack (kludge?) for more accurate clock. */
- if (intr == apic_8254_intr || intr == 8) {
- vector = TPR_FAST_INTS + intr;
- }
-#endif
-#endif
- setidt(vector, slowintr[intr],
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- }
-#ifdef APIC_INTR_REORDER
- set_lapic_isrloc(intr, vector);
-#endif
- /*
- * Reprogram the vector in the IO APIC.
- */
- if (int_to_apicintpin[intr].ioapic >= 0) {
- select = int_to_apicintpin[intr].redirindex;
- value = io_apic_read(int_to_apicintpin[intr].ioapic,
- select) & ~IOART_INTVEC;
- io_apic_write(int_to_apicintpin[intr].ioapic,
- select, value | vector);
- }
-#else
- setidt(ICU_OFFSET + intr,
- flags & INTR_FAST ? fastintr[intr] : slowintr[intr],
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-#endif /* FAST_HI */
- INTREN(1 << intr);
- MPINTR_UNLOCK();
- write_eflags(ef);
- return (0);
-}
-
-int
-icu_unset(intr, handler)
- int intr;
- inthand2_t *handler;
-{
- u_long ef;
-
- if ((u_int)intr >= ICU_LEN || handler != intr_handler[intr])
- return (EINVAL);
-
- INTRDIS(1 << intr);
- ef = read_eflags();
- disable_intr();
- intr_countp[intr] = &intrcnt[1 + intr];
- intr_handler[intr] = isa_strayintr;
- intr_mptr[intr] = NULL;
- intr_mask[intr] = HWI_MASK | SWI_MASK;
- intr_unit[intr] = &intr_unit[intr];
-#ifdef FAST_HI_XXX
- /* XXX how do I re-create dvp here? */
- setidt(flags & INTR_FAST ? TPR_FAST_INTS + intr : TPR_SLOW_INTS + intr,
- slowintr[intr], SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-#else /* FAST_HI */
-#ifdef APIC_INTR_REORDER
- set_lapic_isrloc(intr, ICU_OFFSET + intr);
-#endif
- setidt(ICU_OFFSET + intr, slowintr[intr], SDT_SYS386IGT, SEL_KPL,
- GSEL(GCODE_SEL, SEL_KPL));
-#endif /* FAST_HI */
- MPINTR_UNLOCK();
- write_eflags(ef);
- return (0);
-}
-
-/* The following notice applies beyond this point in the file */
-
-/*
- * Copyright (c) 1997, Stefan Esser <se@freebsd.org>
- * 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 unmodified, 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.
- *
- * $FreeBSD$
- *
- */
-
-typedef struct intrec {
- intrmask_t mask;
- inthand2_t *handler;
- void *argument;
- struct intrec *next;
- char *name;
- int intr;
- intrmask_t *maskptr;
- int flags;
-} intrec;
-
-static intrec *intreclist_head[ICU_LEN];
-
-/*
- * The interrupt multiplexer calls each of the handlers in turn. The
- * ipl is initially quite low. It is raised as necessary for each call
- * and lowered after the call. Thus out of order handling is possible
- * even for interrupts of the same type. This is probably no more
- * harmful than out of order handling in general (not harmful except
- * for real time response which we don't support anyway).
- */
-static void
-intr_mux(void *arg)
-{
- intrec *p;
- intrmask_t oldspl;
-
- for (p = arg; p != NULL; p = p->next) {
- oldspl = splq(p->mask);
- p->handler(p->argument);
- splx(oldspl);
- }
-}
-
-static intrec*
-find_idesc(unsigned *maskptr, int irq)
-{
- intrec *p = intreclist_head[irq];
-
- while (p && p->maskptr != maskptr)
- p = p->next;
-
- return (p);
-}
-
-static intrec**
-find_pred(intrec *idesc, int irq)
-{
- intrec **pp = &intreclist_head[irq];
- intrec *p = *pp;
-
- while (p != idesc) {
- if (p == NULL)
- return (NULL);
- pp = &p->next;
- p = *pp;
- }
- return (pp);
-}
-
-/*
- * Both the low level handler and the shared interrupt multiplexer
- * block out further interrupts as set in the handlers "mask", while
- * the handler is running. In fact *maskptr should be used for this
- * purpose, but since this requires one more pointer dereference on
- * each interrupt, we rather bother update "mask" whenever *maskptr
- * changes. The function "update_masks" should be called **after**
- * all manipulation of the linked list of interrupt handlers hung
- * off of intrdec_head[irq] is complete, since the chain of handlers
- * will both determine the *maskptr values and the instances of mask
- * that are fixed. This function should be called with the irq for
- * which a new handler has been add blocked, since the masks may not
- * yet know about the use of this irq for a device of a certain class.
- */
-
-static void
-update_mux_masks(void)
-{
- int irq;
- for (irq = 0; irq < ICU_LEN; irq++) {
- intrec *idesc = intreclist_head[irq];
- while (idesc != NULL) {
- if (idesc->maskptr != NULL) {
- /* our copy of *maskptr may be stale, refresh */
- idesc->mask = *idesc->maskptr;
- }
- idesc = idesc->next;
- }
- }
-}
-
-static void
-update_masks(intrmask_t *maskptr, int irq)
-{
- intrmask_t mask = 1 << irq;
-
- if (maskptr == NULL)
- return;
-
- if (find_idesc(maskptr, irq) == NULL) {
- /* no reference to this maskptr was found in this irq's chain */
- if ((*maskptr & mask) == 0)
- return;
- /* the irq was included in the classes mask, remove it */
- *maskptr &= ~mask;
- } else {
- /* a reference to this maskptr was found in this irq's chain */
- if ((*maskptr & mask) != 0)
- return;
- /* put the irq into the classes mask */
- *maskptr |= mask;
- }
- /* we need to update all values in the intr_mask[irq] array */
- update_intr_masks();
- /* update mask in chains of the interrupt multiplex handler as well */
- update_mux_masks();
-}
-
-/*
- * Add interrupt handler to linked list hung off of intreclist_head[irq]
- * and install shared interrupt multiplex handler, if necessary
- */
-
-static int
-add_intrdesc(intrec *idesc)
-{
- int irq = idesc->intr;
-
- intrec *head = intreclist_head[irq];
-
- if (head == NULL) {
- /* first handler for this irq, just install it */
- if (icu_setup(irq, idesc->handler, idesc->argument,
- idesc->maskptr, idesc->flags) != 0)
- return (-1);
-
- update_intrname(irq, idesc->name);
- /* keep reference */
- intreclist_head[irq] = idesc;
- } else {
- if ((idesc->flags & INTR_EXCL) != 0
- || (head->flags & INTR_EXCL) != 0) {
- /*
- * can't append new handler, if either list head or
- * new handler do not allow interrupts to be shared
- */
- if (bootverbose)
- printf("\tdevice combination doesn't support "
- "shared irq%d\n", irq);
- return (-1);
- }
- if (head->next == NULL) {
- /*
- * second handler for this irq, replace device driver's
- * handler by shared interrupt multiplexer function
- */
- icu_unset(irq, head->handler);
- if (icu_setup(irq, intr_mux, head, 0, 0) != 0)
- return (-1);
- if (bootverbose)
- printf("\tusing shared irq%d.\n", irq);
- update_intrname(irq, "mux");
- }
- /* just append to the end of the chain */
- while (head->next != NULL)
- head = head->next;
- head->next = idesc;
- }
- update_masks(idesc->maskptr, irq);
- return (0);
-}
-
-/*
- * Create and activate an interrupt handler descriptor data structure.
- *
- * The dev_instance pointer is required for resource management, and will
- * only be passed through to resource_claim().
- *
- * There will be functions that derive a driver and unit name from a
- * dev_instance variable, and those functions will be used to maintain the
- * interrupt counter label array referenced by systat and vmstat to report
- * device interrupt rates (->update_intrlabels).
- *
- * Add the interrupt handler descriptor data structure created by an
- * earlier call of create_intr() to the linked list for its irq and
- * adjust the interrupt masks if necessary.
- */
-
-intrec *
-inthand_add(const char *name, int irq, inthand2_t handler, void *arg,
- intrmask_t *maskptr, int flags)
-{
- intrec *idesc;
- int errcode = -1;
- intrmask_t oldspl;
-
- if (ICU_LEN > 8 * sizeof *maskptr) {
- printf("create_intr: ICU_LEN of %d too high for %d bit intrmask\n",
- ICU_LEN, 8 * sizeof *maskptr);
- return (NULL);
- }
- if ((unsigned)irq >= ICU_LEN) {
- printf("create_intr: requested irq%d too high, limit is %d\n",
- irq, ICU_LEN -1);
- return (NULL);
- }
-
- idesc = malloc(sizeof *idesc, M_DEVBUF, M_WAITOK);
- if (idesc == NULL)
- return NULL;
- bzero(idesc, sizeof *idesc);
-
- if (name == NULL)
- name = "???";
- idesc->name = malloc(strlen(name) + 1, M_DEVBUF, M_WAITOK);
- if (idesc->name == NULL) {
- free(idesc, M_DEVBUF);
- return NULL;
- }
- strcpy(idesc->name, name);
-
- idesc->handler = handler;
- idesc->argument = arg;
- idesc->maskptr = maskptr;
- idesc->intr = irq;
- idesc->flags = flags;
-
- /* block this irq */
- oldspl = splq(1 << irq);
-
- /* add irq to class selected by maskptr */
- errcode = add_intrdesc(idesc);
- splx(oldspl);
-
- if (errcode != 0) {
- if (bootverbose)
- printf("\tintr_connect(irq%d) failed, result=%d\n",
- irq, errcode);
- free(idesc->name, M_DEVBUF);
- free(idesc, M_DEVBUF);
- idesc = NULL;
- }
-
- return (idesc);
-}
-
-/*
- * Deactivate and remove the interrupt handler descriptor data connected
- * created by an earlier call of intr_connect() from the linked list and
- * adjust theinterrupt masks if necessary.
- *
- * Return the memory held by the interrupt handler descriptor data structure
- * to the system. Make sure, the handler is not actively used anymore, before.
- */
-
-int
-inthand_remove(intrec *idesc)
-{
- intrec **hook, *head;
- int irq;
- int errcode = 0;
- intrmask_t oldspl;
-
- if (idesc == NULL)
- return (-1);
-
- irq = idesc->intr;
-
- /* find pointer that keeps the reference to this interrupt descriptor */
- hook = find_pred(idesc, irq);
- if (hook == NULL)
- return (-1);
-
- /* make copy of original list head, the line after may overwrite it */
- head = intreclist_head[irq];
-
- /* unlink: make predecessor point to idesc->next instead of to idesc */
- *hook = idesc->next;
-
- /* now check whether the element we removed was the list head */
- if (idesc == head) {
-
- oldspl = splq(1 << irq);
-
- /* check whether the new list head is the only element on list */
- head = intreclist_head[irq];
- if (head != NULL) {
- icu_unset(irq, intr_mux);
- if (head->next != NULL) {
- /* install the multiplex handler with new list head as argument */
- errcode = icu_setup(irq, intr_mux, head, 0, 0);
- if (errcode == 0)
- update_intrname(irq, NULL);
- } else {
- /* install the one remaining handler for this irq */
- errcode = icu_setup(irq, head->handler,
- head->argument,
- head->maskptr, head->flags);
- if (errcode == 0)
- update_intrname(irq, head->name);
- }
- } else {
- /* revert to old handler, eg: strayintr */
- icu_unset(irq, idesc->handler);
- }
- splx(oldspl);
- }
- update_masks(idesc->maskptr, irq);
- free(idesc, M_DEVBUF);
- return (0);
-}
diff --git a/sys/amd64/isa/intr_machdep.h b/sys/amd64/isa/intr_machdep.h
deleted file mode 100644
index cc6ca67a3238..000000000000
--- a/sys/amd64/isa/intr_machdep.h
+++ /dev/null
@@ -1,213 +0,0 @@
-/*-
- * 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _I386_ISA_INTR_MACHDEP_H_
-#define _I386_ISA_INTR_MACHDEP_H_
-
-/*
- * Low level interrupt code.
- */
-
-#ifdef _KERNEL
-
-#if defined(SMP) || defined(APIC_IO)
-/*
- * XXX FIXME: rethink location for all IPI vectors.
- */
-
-/*
- APIC TPR priority vector levels:
-
- 0xff (255) +-------------+
- | | 15 (IPIs: Xspuriousint)
- 0xf0 (240) +-------------+
- | | 14
- 0xe0 (224) +-------------+
- | | 13
- 0xd0 (208) +-------------+
- | | 12
- 0xc0 (192) +-------------+
- | | 11
- 0xb0 (176) +-------------+
- | | 10 (IPIs: Xcpustop)
- 0xa0 (160) +-------------+
- | | 9 (IPIs: Xinvltlb)
- 0x90 (144) +-------------+
- | | 8 (linux/BSD syscall, IGNORE FAST HW INTS)
- 0x80 (128) +-------------+
- | | 7 (FAST_INTR 16-23)
- 0x70 (112) +-------------+
- | | 6 (FAST_INTR 0-15)
- 0x60 (96) +-------------+
- | | 5 (IGNORE HW INTS)
- 0x50 (80) +-------------+
- | | 4 (2nd IO APIC)
- 0x40 (64) +------+------+
- | | | 3 (upper APIC hardware INTs: PCI)
- 0x30 (48) +------+------+
- | | 2 (start of hardware INTs: ISA)
- 0x20 (32) +-------------+
- | | 1 (exceptions, traps, etc.)
- 0x10 (16) +-------------+
- | | 0 (exceptions, traps, etc.)
- 0x00 (0) +-------------+
- */
-
-/* IDT vector base for regular (aka. slow) and fast interrupts */
-#define TPR_SLOW_INTS 0x20
-#define TPR_FAST_INTS 0x60
-
-/* blocking values for local APIC Task Priority Register */
-#define TPR_BLOCK_HWI 0x4f /* hardware INTs */
-#define TPR_IGNORE_HWI 0x5f /* ignore INTs */
-#define TPR_BLOCK_FHWI 0x7f /* hardware FAST INTs */
-#define TPR_IGNORE_FHWI 0x8f /* ignore FAST INTs */
-#define TPR_BLOCK_XINVLTLB 0x9f /* */
-#define TPR_BLOCK_XCPUSTOP 0xaf /* */
-#define TPR_BLOCK_ALL 0xff /* all INTs */
-
-
-#ifdef TEST_TEST1
-/* put a 'fake' HWI in top of APIC prio 0x3x, 32 + 31 = 63 = 0x3f */
-#define XTEST1_OFFSET (ICU_OFFSET + 31)
-#endif /** TEST_TEST1 */
-
-/* TLB shootdowns */
-#define XINVLTLB_OFFSET (ICU_OFFSET + 112)
-
-#ifdef BETTER_CLOCK
-/* inter-cpu clock handling */
-#define XCPUCHECKSTATE_OFFSET (ICU_OFFSET + 113)
-#endif
-
-/* inter-CPU rendezvous */
-#define XRENDEZVOUS_OFFSET (ICU_OFFSET + 114)
-
-/* IPI to generate an additional software trap at the target CPU */
-#define XCPUAST_OFFSET (ICU_OFFSET + 48)
-
-/* IPI to signal the CPU holding the ISR lock that another IRQ has appeared */
-#define XFORWARD_IRQ_OFFSET (ICU_OFFSET + 49)
-
-/* IPI to signal CPUs to stop and wait for another CPU to restart them */
-#define XCPUSTOP_OFFSET (ICU_OFFSET + 128)
-
-/*
- * Note: this vector MUST be xxxx1111, 32 + 223 = 255 = 0xff:
- */
-#define XSPURIOUSINT_OFFSET (ICU_OFFSET + 223)
-
-#endif /* SMP || APIC_IO */
-
-#ifndef LOCORE
-
-/*
- * Type of the first (asm) part of an interrupt handler.
- */
-typedef void inthand_t __P((u_int cs, u_int ef, u_int esp, u_int ss));
-
-#define IDTVEC(name) __CONCAT(X,name)
-
-extern char eintrnames[]; /* end of intrnames[] */
-extern u_long intrcnt[]; /* counts for for each device and stray */
-extern char intrnames[]; /* string table containing device names */
-extern u_long *intr_countp[]; /* pointers into intrcnt[] */
-extern inthand2_t *intr_handler[]; /* C entry points of intr handlers */
-extern u_int intr_mask[]; /* sets of intrs masked during handling of 1 */
-extern void *intr_unit[]; /* cookies to pass to intr handlers */
-
-inthand_t
- IDTVEC(fastintr0), IDTVEC(fastintr1),
- IDTVEC(fastintr2), IDTVEC(fastintr3),
- IDTVEC(fastintr4), IDTVEC(fastintr5),
- IDTVEC(fastintr6), IDTVEC(fastintr7),
- IDTVEC(fastintr8), IDTVEC(fastintr9),
- IDTVEC(fastintr10), IDTVEC(fastintr11),
- IDTVEC(fastintr12), IDTVEC(fastintr13),
- IDTVEC(fastintr14), IDTVEC(fastintr15);
-inthand_t
- IDTVEC(intr0), IDTVEC(intr1), IDTVEC(intr2), IDTVEC(intr3),
- IDTVEC(intr4), IDTVEC(intr5), IDTVEC(intr6), IDTVEC(intr7),
- IDTVEC(intr8), IDTVEC(intr9), IDTVEC(intr10), IDTVEC(intr11),
- IDTVEC(intr12), IDTVEC(intr13), IDTVEC(intr14), IDTVEC(intr15);
-
-#if defined(SMP) || defined(APIC_IO)
-inthand_t
- IDTVEC(fastintr16), IDTVEC(fastintr17),
- IDTVEC(fastintr18), IDTVEC(fastintr19),
- IDTVEC(fastintr20), IDTVEC(fastintr21),
- IDTVEC(fastintr22), IDTVEC(fastintr23);
-inthand_t
- IDTVEC(intr16), IDTVEC(intr17), IDTVEC(intr18), IDTVEC(intr19),
- IDTVEC(intr20), IDTVEC(intr21), IDTVEC(intr22), IDTVEC(intr23);
-
-inthand_t
- Xinvltlb, /* TLB shootdowns */
-#ifdef BETTER_CLOCK
- Xcpucheckstate, /* Check cpu state */
-#endif
- Xcpuast, /* Additional software trap on other cpu */
- Xforward_irq, /* Forward irq to cpu holding ISR lock */
- Xcpustop, /* CPU stops & waits for another CPU to restart it */
- Xspuriousint, /* handle APIC "spurious INTs" */
- Xrendezvous; /* handle CPU rendezvous */
-
-#ifdef TEST_TEST1
-inthand_t
- Xtest1; /* 'fake' HWI at top of APIC prio 0x3x, 32+31 = 0x3f */
-#endif /** TEST_TEST1 */
-#endif /* SMP || APIC_IO */
-
-void isa_defaultirq __P((void));
-int isa_nmi __P((int cd));
-int icu_setup __P((int intr, inthand2_t *func, void *arg,
- u_int *maskptr, int flags));
-int icu_unset __P((int intr, inthand2_t *handler));
-int update_intr_masks __P((void));
-
-intrmask_t splq __P((intrmask_t mask));
-
-#define INTR_FAST 0x00000001 /* fast interrupt handler */
-#define INTR_EXCL 0x00010000 /* excl. intr, default is shared */
-struct intrec *inthand_add(const char *name, int irq, inthand2_t handler,
- void *arg, intrmask_t *maskptr, int flags);
-
-int inthand_remove(struct intrec *idesc);
-
-#endif /* LOCORE */
-
-#endif /* _KERNEL */
-
-#endif /* !_I386_ISA_INTR_MACHDEP_H_ */
diff --git a/sys/amd64/isa/isa.c b/sys/amd64/isa/isa.c
deleted file mode 100644
index 6c4b71a296a5..000000000000
--- a/sys/amd64/isa/isa.c
+++ /dev/null
@@ -1,159 +0,0 @@
-/*-
- * Copyright (c) 1998 Doug Rabson
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Modifications for Intel architecture by Garrett A. Wollman.
- * Copyright 1998 Massachusetts Institute of Technology
- *
- * Permission to use, copy, modify, and distribute this software and
- * its documentation for any purpose and without fee is hereby
- * granted, provided that both the above copyright notice and this
- * permission notice appear in all copies, that both the above
- * copyright notice and this permission notice appear in all
- * supporting documentation, and that the name of M.I.T. not be used
- * in advertising or publicity pertaining to distribution of the
- * software without specific, written prior permission. M.I.T. makes
- * no representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied
- * warranty.
- *
- * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS
- * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
- * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/param.h>
-#include <sys/bus.h>
-#include <sys/malloc.h>
-#include <machine/bus.h>
-
-#include <machine/resource.h>
-
-#include <isa/isavar.h>
-#include <isa/isa_common.h>
-
-void
-isa_init(void)
-{
- isa_wrap_old_drivers();
-}
-
-/*
- * This implementation simply passes the request up to the parent
- * bus, which in our case is the special i386 nexus, substituting any
- * configured values if the caller defaulted. We can get away with
- * this because there is no special mapping for ISA resources on an Intel
- * platform. When porting this code to another architecture, it may be
- * necessary to interpose a mapping layer here.
- */
-struct resource *
-isa_alloc_resource(device_t bus, device_t child, int type, int *rid,
- u_long start, u_long end, u_long count, u_int flags)
-{
- /*
- * Consider adding a resource definition. We allow rid 0-1 for
- * irq and drq, 0-3 for memory and 0-7 for ports which is
- * sufficient for isapnp.
- */
- int passthrough = (device_get_parent(child) != bus);
- int isdefault = (start == 0UL && end == ~0UL);
- struct isa_device* idev = DEVTOISA(child);
- struct resource_list *rl = &idev->id_resources;
- struct resource_list_entry *rle;
-
- if (!passthrough && !isdefault) {
- rle = resource_list_find(rl, type, *rid);
- if (!rle) {
- if (*rid < 0)
- return 0;
- switch (type) {
- case SYS_RES_IRQ:
- if (*rid >= ISA_NIRQ)
- return 0;
- break;
- case SYS_RES_DRQ:
- if (*rid >= ISA_NDRQ)
- return 0;
- break;
- case SYS_RES_MEMORY:
- if (*rid >= ISA_NMEM)
- return 0;
- break;
- case SYS_RES_IOPORT:
- if (*rid >= ISA_NPORT)
- return 0;
- break;
- default:
- return 0;
- }
- resource_list_add(rl, type, *rid, start, end, count);
- }
- }
-
- return resource_list_alloc(rl, bus, child, type, rid,
- start, end, count, flags);
-}
-
-int
-isa_release_resource(device_t bus, device_t child, int type, int rid,
- struct resource *r)
-{
- struct isa_device* idev = DEVTOISA(child);
- struct resource_list *rl = &idev->id_resources;
- return resource_list_release(rl, bus, child, type, rid, r);
-}
-
-/*
- * We can't use the bus_generic_* versions of these methods because those
- * methods always pass the bus param as the requesting device, and we need
- * to pass the child (the i386 nexus knows about this and is prepared to
- * deal).
- */
-int
-isa_setup_intr(device_t bus, device_t child, struct resource *r, int flags,
- void (*ihand)(void *), void *arg, void **cookiep)
-{
- return (BUS_SETUP_INTR(device_get_parent(bus), child, r, flags,
- ihand, arg, cookiep));
-}
-
-int
-isa_teardown_intr(device_t bus, device_t child, struct resource *r,
- void *cookie)
-{
- return (BUS_TEARDOWN_INTR(device_get_parent(bus), child, r, cookie));
-}
diff --git a/sys/amd64/isa/isa.h b/sys/amd64/isa/isa.h
deleted file mode 100644
index cc66da9be045..000000000000
--- a/sys/amd64/isa/isa.h
+++ /dev/null
@@ -1,200 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)isa.h 5.7 (Berkeley) 5/9/91
- * $FreeBSD$
- */
-
-#ifdef PC98
-#error isa.h is included from PC-9801 source
-#endif
-
-#ifndef _I386_ISA_ISA_H_
-#define _I386_ISA_ISA_H_
-
-/* BEWARE: Included in both assembler and C code */
-
-/*
- * ISA Bus conventions
- */
-
-/*
- * Input / Output Port Assignments
- */
-#ifndef IO_ISABEGIN
-#define IO_ISABEGIN 0x000 /* 0x000 - Beginning of I/O Registers */
-
- /* CPU Board */
-#define IO_DMA1 0x000 /* 8237A DMA Controller #1 */
-#define IO_ICU1 0x020 /* 8259A Interrupt Controller #1 */
-#define IO_PMP1 0x026 /* 82347 Power Management Peripheral */
-#define IO_TIMER1 0x040 /* 8253 Timer #1 */
-#define IO_TIMER2 0x048 /* 8253 Timer #2 */
-#define IO_KBD 0x060 /* 8042 Keyboard */
-#define IO_PPI 0x061 /* Programmable Peripheral Interface */
-#define IO_RTC 0x070 /* RTC */
-#define IO_NMI IO_RTC /* NMI Control */
-#define IO_DMAPG 0x080 /* DMA Page Registers */
-#define IO_ICU2 0x0A0 /* 8259A Interrupt Controller #2 */
-#define IO_DMA2 0x0C0 /* 8237A DMA Controller #2 */
-#define IO_NPX 0x0F0 /* Numeric Coprocessor */
-
- /* Cards */
- /* 0x100 - 0x16F Open */
-
-#define IO_WD2 0x170 /* Secondary Fixed Disk Controller */
-
-#define IO_PMP2 0x178 /* 82347 Power Management Peripheral */
-
- /* 0x17A - 0x1EF Open */
-
-#define IO_WD1 0x1F0 /* Primary Fixed Disk Controller */
-#define IO_GAME 0x201 /* Game Controller */
-
- /* 0x202 - 0x22A Open */
-
-#define IO_ASC2 0x22B /* AmiScan addr.grp. 2 */
-
- /* 0x230 - 0x26A Open */
-
-#define IO_ASC3 0x26B /* AmiScan addr.grp. 3 */
-#define IO_GSC1 0x270 /* -- 0x27B! GeniScan GS-4500 addr.grp. 1 */
-#define IO_LPT2 0x278 /* Parallel Port #2 */
-
- /* 0x280 - 0x2AA Open */
-
-#define IO_ASC4 0x2AB /* AmiScan addr.grp. 4 */
-
- /* 0x2B0 - 0x2DF Open */
-
-#define IO_GSC2 0x2E0 /* GeniScan GS-4500 addr.grp. 2 */
-#define IO_COM4 0x2E8 /* COM4 i/o address */
-#define IO_ASC5 0x2EB /* AmiScan addr.grp. 5 */
-
- /* 0x2F0 - 0x2F7 Open */
-
-#define IO_COM2 0x2F8 /* COM2 i/o address */
-
- /* 0x300 - 0x32A Open */
-
-#define IO_ASC6 0x32B /* AmiScan addr.grp. 6 */
-#define IO_AHA0 0x330 /* adaptec 1542 default addr. */
-#define IO_BT0 0x330 /* bustek 742a default addr. */
-#define IO_UHA0 0x330 /* ultrastore 14f default addr. */
-#define IO_AHA1 0x334 /* adaptec 1542 default addr. */
-#define IO_BT1 0x334 /* bustek 742a default addr. */
-
- /* 0x340 - 0x36A Open */
-
-#define IO_ASC7 0x36B /* AmiScan addr.grp. 7 */
-#define IO_GSC3 0x370 /* GeniScan GS-4500 addr.grp. 3 */
-#define IO_FD2 0x370 /* secondary base i/o address */
-#define IO_LPT1 0x378 /* Parallel Port #1 */
-
- /* 0x380 - 0x3AA Open */
-
-#define IO_ASC8 0x3AB /* AmiScan addr.grp. 8 */
-#define IO_MDA 0x3B0 /* Monochome Adapter */
-#define IO_LPT3 0x3BC /* Monochome Adapter Printer Port */
-#define IO_VGA 0x3C0 /* E/VGA Ports */
-#define IO_CGA 0x3D0 /* CGA Ports */
-#define IO_GSC4 0x3E0 /* GeniScan GS-4500 addr.grp. 4 */
-#define IO_COM3 0x3E8 /* COM3 i/o address */
-#define IO_ASC1 0x3EB /* AmiScan addr.grp. 1 */
-#define IO_FD1 0x3F0 /* primary base i/o address */
-#define IO_COM1 0x3F8 /* COM1 i/o address */
-
-#define IO_ISAEND 0x3FF /* End (actually Max) of I/O Regs */
-#endif /* !IO_ISABEGIN */
-
-/*
- * Input / Output Port Sizes - these are from several sources, and tend
- * to be the larger of what was found.
- */
-#ifndef IO_ISASIZES
-#define IO_ISASIZES
-
-#define IO_ASCSIZE 5 /* AmiScan GI1904-based hand scanner */
-#define IO_CGASIZE 12 /* CGA controllers */
-#define IO_COMSIZE 8 /* 8250, 16x50 com controllers */
-#define IO_DMASIZE 16 /* 8237 DMA controllers */
-#define IO_DPGSIZE 32 /* 74LS612 DMA page registers */
-#define IO_EISASIZE 256 /* EISA controllers */
-#define IO_FDCSIZE 8 /* Nec765 floppy controllers */
-#define IO_GAMSIZE 16 /* AT compatible game controllers */
-#define IO_GSCSIZE 8 /* GeniScan GS-4500G hand scanner */
-#define IO_ICUSIZE 16 /* 8259A interrupt controllers */
-#define IO_KBDSIZE 16 /* 8042 Keyboard controllers */
-#define IO_LPTSIZE 8 /* LPT controllers, some use only 4 */
-#define IO_MDASIZE 12 /* Monochrome display controllers */
-#define IO_NPXSIZE 16 /* 80387/80487 NPX registers */
-#define IO_PMPSIZE 2 /* 82347 power management peripheral */
-#define IO_PSMSIZE 5 /* 8042 Keyboard controllers */
-#define IO_RTCSIZE 16 /* CMOS real time clock, NMI control */
-#define IO_TMRSIZE 16 /* 8253 programmable timers */
-#define IO_VGASIZE 16 /* VGA controllers */
-#define IO_WDCSIZE 8 /* WD compatible disk controllers */
-
-#endif /* !IO_ISASIZES */
-
-/*
- * Input / Output Memory Physical Addresses
- */
-#ifndef IOM_BEGIN
-#define IOM_BEGIN 0x0A0000 /* Start of I/O Memory "hole" */
-#define IOM_END 0x100000 /* End of I/O Memory "hole" */
-#define IOM_SIZE (IOM_END - IOM_BEGIN)
-#endif /* !IOM_BEGIN */
-
-/*
- * RAM Physical Address Space (ignoring the above mentioned "hole")
- */
-#ifndef RAM_BEGIN
-#define RAM_BEGIN 0x0000000 /* Start of RAM Memory */
-#define RAM_END 0x1000000 /* End of RAM Memory */
-#define RAM_SIZE (RAM_END - RAM_BEGIN)
-#endif /* !RAM_BEGIN */
-
-/*
- * Oddball Physical Memory Addresses
- */
-#ifndef COMPAQ_RAMRELOC
-#define COMPAQ_RAMRELOC 0x80C00000 /* Compaq RAM relocation/diag */
-#define COMPAQ_RAMSETUP 0x80C00002 /* Compaq RAM setup */
-#define WEITEK_FPU 0xC0000000 /* WTL 2167 */
-#define CYRIX_EMC 0xC0000000 /* Cyrix EMC */
-#endif /* !COMPAQ_RAMRELOC */
-
-#endif /* !_I386_ISA_ISA_H_ */
diff --git a/sys/amd64/isa/isa_dma.c b/sys/amd64/isa/isa_dma.c
deleted file mode 100644
index 698c67004a7e..000000000000
--- a/sys/amd64/isa/isa_dma.c
+++ /dev/null
@@ -1,497 +0,0 @@
-/*-
- * Copyright (c) 1991 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)isa.c 7.2 (Berkeley) 5/13/91
- * $FreeBSD$
- */
-
-/*
- * code to manage AT bus
- *
- * 92/08/18 Frank P. MacLachlan (fpm@crash.cts.com):
- * Fixed uninitialized variable problem and added code to deal
- * with DMA page boundaries in isa_dmarangecheck(). Fixed word
- * mode DMA count compution and reorganized DMA setup code in
- * isa_dmastart()
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/buf.h> /* B_READ and B_RAW */
-#include <sys/malloc.h>
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <vm/pmap.h>
-#include <i386/isa/isa.h>
-#include <i386/isa/isa_dma.h>
-#include <i386/isa/ic/i8237.h>
-
-/*
-** Register definitions for DMA controller 1 (channels 0..3):
-*/
-#define DMA1_CHN(c) (IO_DMA1 + 1*(2*(c))) /* addr reg for channel c */
-#define DMA1_SMSK (IO_DMA1 + 1*10) /* single mask register */
-#define DMA1_MODE (IO_DMA1 + 1*11) /* mode register */
-#define DMA1_FFC (IO_DMA1 + 1*12) /* clear first/last FF */
-
-/*
-** Register definitions for DMA controller 2 (channels 4..7):
-*/
-#define DMA2_CHN(c) (IO_DMA2 + 2*(2*(c))) /* addr reg for channel c */
-#define DMA2_SMSK (IO_DMA2 + 2*10) /* single mask register */
-#define DMA2_MODE (IO_DMA2 + 2*11) /* mode register */
-#define DMA2_FFC (IO_DMA2 + 2*12) /* clear first/last FF */
-
-static int isa_dmarangecheck __P((caddr_t va, u_int length, int chan));
-
-static caddr_t dma_bouncebuf[8];
-static u_int dma_bouncebufsize[8];
-static u_int8_t dma_bounced = 0;
-static u_int8_t dma_busy = 0; /* Used in isa_dmastart() */
-static u_int8_t dma_inuse = 0; /* User for acquire/release */
-static u_int8_t dma_auto_mode = 0;
-
-#define VALID_DMA_MASK (7)
-
-/* high byte of address is stored in this port for i-th dma channel */
-static int dmapageport[8] = { 0x87, 0x83, 0x81, 0x82, 0x8f, 0x8b, 0x89, 0x8a };
-
-/*
- * Setup a DMA channel's bounce buffer.
- */
-void
-isa_dmainit(chan, bouncebufsize)
- int chan;
- u_int bouncebufsize;
-{
- void *buf;
-
-#ifdef DIAGNOSTIC
- if (chan & ~VALID_DMA_MASK)
- panic("isa_dmainit: channel out of range");
-
- if (dma_bouncebuf[chan] != NULL)
- panic("isa_dmainit: impossible request");
-#endif
-
- dma_bouncebufsize[chan] = bouncebufsize;
-
- /* Try malloc() first. It works better if it works. */
- buf = malloc(bouncebufsize, M_DEVBUF, M_NOWAIT);
- if (buf != NULL) {
- if (isa_dmarangecheck(buf, bouncebufsize, chan) == 0) {
- dma_bouncebuf[chan] = buf;
- return;
- }
- free(buf, M_DEVBUF);
- }
- buf = contigmalloc(bouncebufsize, M_DEVBUF, M_NOWAIT, 0ul, 0xfffffful,
- 1ul, chan & 4 ? 0x20000ul : 0x10000ul);
- if (buf == NULL)
- printf("isa_dmainit(%d, %d) failed\n", chan, bouncebufsize);
- else
- dma_bouncebuf[chan] = buf;
-}
-
-/*
- * Register a DMA channel's usage. Usually called from a device driver
- * in open() or during its initialization.
- */
-int
-isa_dma_acquire(chan)
- int chan;
-{
-#ifdef DIAGNOSTIC
- if (chan & ~VALID_DMA_MASK)
- panic("isa_dma_acquire: channel out of range");
-#endif
-
- if (dma_inuse & (1 << chan)) {
- printf("isa_dma_acquire: channel %d already in use\n", chan);
- return (EBUSY);
- }
- dma_inuse |= (1 << chan);
- dma_auto_mode &= ~(1 << chan);
-
- return (0);
-}
-
-/*
- * Unregister a DMA channel's usage. Usually called from a device driver
- * during close() or during its shutdown.
- */
-void
-isa_dma_release(chan)
- int chan;
-{
-#ifdef DIAGNOSTIC
- if (chan & ~VALID_DMA_MASK)
- panic("isa_dma_release: channel out of range");
-
- if ((dma_inuse & (1 << chan)) == 0)
- printf("isa_dma_release: channel %d not in use\n", chan);
-#endif
-
- if (dma_busy & (1 << chan)) {
- dma_busy &= ~(1 << chan);
- /*
- * XXX We should also do "dma_bounced &= (1 << chan);"
- * because we are acting on behalf of isa_dmadone() which
- * was not called to end the last DMA operation. This does
- * not matter now, but it may in the future.
- */
- }
-
- dma_inuse &= ~(1 << chan);
- dma_auto_mode &= ~(1 << chan);
-}
-
-/*
- * isa_dmacascade(): program 8237 DMA controller channel to accept
- * external dma control by a board.
- */
-void
-isa_dmacascade(chan)
- int chan;
-{
-#ifdef DIAGNOSTIC
- if (chan & ~VALID_DMA_MASK)
- panic("isa_dmacascade: channel out of range");
-#endif
-
- /* set dma channel mode, and set dma channel mode */
- if ((chan & 4) == 0) {
- outb(DMA1_MODE, DMA37MD_CASCADE | chan);
- outb(DMA1_SMSK, chan);
- } else {
- outb(DMA2_MODE, DMA37MD_CASCADE | (chan & 3));
- outb(DMA2_SMSK, chan & 3);
- }
-}
-
-/*
- * isa_dmastart(): program 8237 DMA controller channel, avoid page alignment
- * problems by using a bounce buffer.
- */
-void
-isa_dmastart(int flags, caddr_t addr, u_int nbytes, int chan)
-{
- vm_offset_t phys;
- int waport;
- caddr_t newaddr;
-
-#ifdef DIAGNOSTIC
- if (chan & ~VALID_DMA_MASK)
- panic("isa_dmastart: channel out of range");
-
- if ((chan < 4 && nbytes > (1<<16))
- || (chan >= 4 && (nbytes > (1<<17) || (u_int)addr & 1)))
- panic("isa_dmastart: impossible request");
-
- if ((dma_inuse & (1 << chan)) == 0)
- printf("isa_dmastart: channel %d not acquired\n", chan);
-#endif
-
-#if 0
- /*
- * XXX This should be checked, but drivers like ad1848 only call
- * isa_dmastart() once because they use Auto DMA mode. If we
- * leave this in, drivers that do this will print this continuously.
- */
- if (dma_busy & (1 << chan))
- printf("isa_dmastart: channel %d busy\n", chan);
-#endif
-
- dma_busy |= (1 << chan);
-
- if (isa_dmarangecheck(addr, nbytes, chan)) {
- if (dma_bouncebuf[chan] == NULL
- || dma_bouncebufsize[chan] < nbytes)
- panic("isa_dmastart: bad bounce buffer");
- dma_bounced |= (1 << chan);
- newaddr = dma_bouncebuf[chan];
-
- /* copy bounce buffer on write */
- if (!(flags & B_READ))
- bcopy(addr, newaddr, nbytes);
- addr = newaddr;
- }
-
- /* translate to physical */
- phys = pmap_extract(pmap_kernel(), (vm_offset_t)addr);
-
- if (flags & B_RAW) {
- dma_auto_mode |= (1 << chan);
- } else {
- dma_auto_mode &= ~(1 << chan);
- }
-
- if ((chan & 4) == 0) {
- /*
- * Program one of DMA channels 0..3. These are
- * byte mode channels.
- */
- /* set dma channel mode, and reset address ff */
-
- /* If B_RAW flag is set, then use autoinitialise mode */
- if (flags & B_RAW) {
- if (flags & B_READ)
- outb(DMA1_MODE, DMA37MD_AUTO|DMA37MD_WRITE|chan);
- else
- outb(DMA1_MODE, DMA37MD_AUTO|DMA37MD_READ|chan);
- }
- else
- if (flags & B_READ)
- outb(DMA1_MODE, DMA37MD_SINGLE|DMA37MD_WRITE|chan);
- else
- outb(DMA1_MODE, DMA37MD_SINGLE|DMA37MD_READ|chan);
- outb(DMA1_FFC, 0);
-
- /* send start address */
- waport = DMA1_CHN(chan);
- outb(waport, phys);
- outb(waport, phys>>8);
- outb(dmapageport[chan], phys>>16);
-
- /* send count */
- outb(waport + 1, --nbytes);
- outb(waport + 1, nbytes>>8);
-
- /* unmask channel */
- outb(DMA1_SMSK, chan);
- } else {
- /*
- * Program one of DMA channels 4..7. These are
- * word mode channels.
- */
- /* set dma channel mode, and reset address ff */
-
- /* If B_RAW flag is set, then use autoinitialise mode */
- if (flags & B_RAW) {
- if (flags & B_READ)
- outb(DMA2_MODE, DMA37MD_AUTO|DMA37MD_WRITE|(chan&3));
- else
- outb(DMA2_MODE, DMA37MD_AUTO|DMA37MD_READ|(chan&3));
- }
- else
- if (flags & B_READ)
- outb(DMA2_MODE, DMA37MD_SINGLE|DMA37MD_WRITE|(chan&3));
- else
- outb(DMA2_MODE, DMA37MD_SINGLE|DMA37MD_READ|(chan&3));
- outb(DMA2_FFC, 0);
-
- /* send start address */
- waport = DMA2_CHN(chan - 4);
- outb(waport, phys>>1);
- outb(waport, phys>>9);
- outb(dmapageport[chan], phys>>16);
-
- /* send count */
- nbytes >>= 1;
- outb(waport + 2, --nbytes);
- outb(waport + 2, nbytes>>8);
-
- /* unmask channel */
- outb(DMA2_SMSK, chan & 3);
- }
-}
-
-void
-isa_dmadone(int flags, caddr_t addr, int nbytes, int chan)
-{
-#ifdef DIAGNOSTIC
- if (chan & ~VALID_DMA_MASK)
- panic("isa_dmadone: channel out of range");
-
- if ((dma_inuse & (1 << chan)) == 0)
- printf("isa_dmadone: channel %d not acquired\n", chan);
-#endif
-
- if (((dma_busy & (1 << chan)) == 0) &&
- (dma_auto_mode & (1 << chan)) == 0 )
- printf("isa_dmadone: channel %d not busy\n", chan);
-
- if ((dma_auto_mode & (1 << chan)) == 0)
- outb(chan & 4 ? DMA2_SMSK : DMA1_SMSK, (chan & 3) | 4);
-
- if (dma_bounced & (1 << chan)) {
- /* copy bounce buffer on read */
- if (flags & B_READ)
- bcopy(dma_bouncebuf[chan], addr, nbytes);
-
- dma_bounced &= ~(1 << chan);
- }
- dma_busy &= ~(1 << chan);
-}
-
-/*
- * Check for problems with the address range of a DMA transfer
- * (non-contiguous physical pages, outside of bus address space,
- * crossing DMA page boundaries).
- * Return true if special handling needed.
- */
-
-static int
-isa_dmarangecheck(caddr_t va, u_int length, int chan)
-{
- vm_offset_t phys, priorpage = 0, endva;
- u_int dma_pgmsk = (chan & 4) ? ~(128*1024-1) : ~(64*1024-1);
-
- endva = (vm_offset_t)round_page((vm_offset_t)va + length);
- for (; va < (caddr_t) endva ; va += PAGE_SIZE) {
- phys = trunc_page(pmap_extract(pmap_kernel(), (vm_offset_t)va));
-#define ISARAM_END RAM_END
- if (phys == 0)
- panic("isa_dmacheck: no physical page present");
- if (phys >= ISARAM_END)
- return (1);
- if (priorpage) {
- if (priorpage + PAGE_SIZE != phys)
- return (1);
- /* check if crossing a DMA page boundary */
- if (((u_int)priorpage ^ (u_int)phys) & dma_pgmsk)
- return (1);
- }
- priorpage = phys;
- }
- return (0);
-}
-
-/*
- * Query the progress of a transfer on a DMA channel.
- *
- * To avoid having to interrupt a transfer in progress, we sample
- * each of the high and low databytes twice, and apply the following
- * logic to determine the correct count.
- *
- * Reads are performed with interrupts disabled, thus it is to be
- * expected that the time between reads is very small. At most
- * one rollover in the low count byte can be expected within the
- * four reads that are performed.
- *
- * There are three gaps in which a rollover can occur :
- *
- * - read low1
- * gap1
- * - read high1
- * gap2
- * - read low2
- * gap3
- * - read high2
- *
- * If a rollover occurs in gap1 or gap2, the low2 value will be
- * greater than the low1 value. In this case, low2 and high2 are a
- * corresponding pair.
- *
- * In any other case, low1 and high1 can be considered to be correct.
- *
- * The function returns the number of bytes remaining in the transfer,
- * or -1 if the channel requested is not active.
- *
- */
-int
-isa_dmastatus(int chan)
-{
- u_long cnt = 0;
- int ffport, waport;
- u_long low1, high1, low2, high2;
-
- /* channel active? */
- if ((dma_inuse & (1 << chan)) == 0) {
- printf("isa_dmastatus: channel %d not active\n", chan);
- return(-1);
- }
- /* channel busy? */
-
- if (((dma_busy & (1 << chan)) == 0) &&
- (dma_auto_mode & (1 << chan)) == 0 ) {
- printf("chan %d not busy\n", chan);
- return -2 ;
- }
- if (chan < 4) { /* low DMA controller */
- ffport = DMA1_FFC;
- waport = DMA1_CHN(chan) + 1;
- } else { /* high DMA controller */
- ffport = DMA2_FFC;
- waport = DMA2_CHN(chan - 4) + 2;
- }
-
- disable_intr(); /* no interrupts Mr Jones! */
- outb(ffport, 0); /* clear register LSB flipflop */
- low1 = inb(waport);
- high1 = inb(waport);
- outb(ffport, 0); /* clear again */
- low2 = inb(waport);
- high2 = inb(waport);
- enable_intr(); /* enable interrupts again */
-
- /*
- * Now decide if a wrap has tried to skew our results.
- * Note that after TC, the count will read 0xffff, while we want
- * to return zero, so we add and then mask to compensate.
- */
- if (low1 >= low2) {
- cnt = (low1 + (high1 << 8) + 1) & 0xffff;
- } else {
- cnt = (low2 + (high2 << 8) + 1) & 0xffff;
- }
-
- if (chan >= 4) /* high channels move words */
- cnt *= 2;
- return(cnt);
-}
-
-/*
- * Stop a DMA transfer currently in progress.
- */
-int
-isa_dmastop(int chan)
-{
- if ((dma_inuse & (1 << chan)) == 0)
- printf("isa_dmastop: channel %d not acquired\n", chan);
-
- if (((dma_busy & (1 << chan)) == 0) &&
- ((dma_auto_mode & (1 << chan)) == 0)) {
- printf("chan %d not busy\n", chan);
- return -2 ;
- }
-
- if ((chan & 4) == 0) {
- outb(DMA1_SMSK, (chan & 3) | 4 /* disable mask */);
- } else {
- outb(DMA2_SMSK, (chan & 3) | 4 /* disable mask */);
- }
- return(isa_dmastatus(chan));
-}
diff --git a/sys/amd64/isa/isa_dma.h b/sys/amd64/isa/isa_dma.h
deleted file mode 100644
index 7f9396a2fb06..000000000000
--- a/sys/amd64/isa/isa_dma.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*-
- * 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. 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, Berkeley and its contributors.
- * 4. 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: @(#)isa_device.h 7.1 (Berkeley) 5/9/91
- * $FreeBSD$
- */
-
-#ifndef _I386_ISA_ISA_DMA_H_
-#define _I386_ISA_ISA_DMA_H_
-
-#ifdef _KERNEL
-void isa_dmacascade __P((int chan));
-void isa_dmadone __P((int flags, caddr_t addr, int nbytes, int chan));
-void isa_dmainit __P((int chan, u_int bouncebufsize));
-void isa_dmastart __P((int flags, caddr_t addr, u_int nbytes, int chan));
-int isa_dma_acquire __P((int chan));
-void isa_dma_release __P((int chan));
-int isa_dmastatus __P((int chan));
-int isa_dmastop __P((int chan));
-#endif
-
-#endif /* !_I386_ISA_ISA_DMA_H_ */
diff --git a/sys/amd64/isa/nmi.c b/sys/amd64/isa/nmi.c
deleted file mode 100644
index d1f46ca4d8cf..000000000000
--- a/sys/amd64/isa/nmi.c
+++ /dev/null
@@ -1,850 +0,0 @@
-/*-
- * Copyright (c) 1991 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)isa.c 7.2 (Berkeley) 5/13/91
- * $FreeBSD$
- */
-/*
- * This file contains an aggregated module marked:
- * Copyright (c) 1997, Stefan Esser <se@freebsd.org>
- * All rights reserved.
- * See the notice for details.
- */
-
-#include "opt_auto_eoi.h"
-
-#include "isa.h"
-
-#include <sys/param.h>
-#ifndef SMP
-#include <machine/lock.h>
-#endif
-#include <sys/systm.h>
-#include <sys/syslog.h>
-#include <sys/malloc.h>
-#include <sys/errno.h>
-#include <sys/interrupt.h>
-#include <machine/ipl.h>
-#include <machine/md_var.h>
-#include <machine/segments.h>
-#include <sys/bus.h>
-
-#if defined(APIC_IO)
-#include <machine/smp.h>
-#include <machine/smptests.h> /** FAST_HI */
-#endif /* APIC_IO */
-#ifdef PC98
-#include <pc98/pc98/pc98.h>
-#include <pc98/pc98/pc98_machdep.h>
-#include <pc98/pc98/epsonio.h>
-#else
-#include <i386/isa/isa.h>
-#endif
-#include <i386/isa/icu.h>
-
-#if NISA > 0
-#include <isa/isavar.h>
-#endif
-#include <i386/isa/intr_machdep.h>
-#include <sys/interrupt.h>
-#ifdef APIC_IO
-#include <machine/clock.h>
-#endif
-
-#include "mca.h"
-#if NMCA > 0
-#include <i386/isa/mca_machdep.h>
-#endif
-
-/* XXX should be in suitable include files */
-#ifdef PC98
-#define ICU_IMR_OFFSET 2 /* IO_ICU{1,2} + 2 */
-#define ICU_SLAVEID 7
-#else
-#define ICU_IMR_OFFSET 1 /* IO_ICU{1,2} + 1 */
-#define ICU_SLAVEID 2
-#endif
-
-#ifdef APIC_IO
-/*
- * This is to accommodate "mixed-mode" programming for
- * motherboards that don't connect the 8254 to the IO APIC.
- */
-#define AUTO_EOI_1 1
-#endif
-
-#define NR_INTRNAMES (1 + ICU_LEN + 2 * ICU_LEN)
-
-u_long *intr_countp[ICU_LEN];
-inthand2_t *intr_handler[ICU_LEN];
-u_int intr_mask[ICU_LEN];
-static u_int* intr_mptr[ICU_LEN];
-void *intr_unit[ICU_LEN];
-
-static inthand_t *fastintr[ICU_LEN] = {
- &IDTVEC(fastintr0), &IDTVEC(fastintr1),
- &IDTVEC(fastintr2), &IDTVEC(fastintr3),
- &IDTVEC(fastintr4), &IDTVEC(fastintr5),
- &IDTVEC(fastintr6), &IDTVEC(fastintr7),
- &IDTVEC(fastintr8), &IDTVEC(fastintr9),
- &IDTVEC(fastintr10), &IDTVEC(fastintr11),
- &IDTVEC(fastintr12), &IDTVEC(fastintr13),
- &IDTVEC(fastintr14), &IDTVEC(fastintr15),
-#if defined(APIC_IO)
- &IDTVEC(fastintr16), &IDTVEC(fastintr17),
- &IDTVEC(fastintr18), &IDTVEC(fastintr19),
- &IDTVEC(fastintr20), &IDTVEC(fastintr21),
- &IDTVEC(fastintr22), &IDTVEC(fastintr23),
-#endif /* APIC_IO */
-};
-
-static inthand_t *slowintr[ICU_LEN] = {
- &IDTVEC(intr0), &IDTVEC(intr1), &IDTVEC(intr2), &IDTVEC(intr3),
- &IDTVEC(intr4), &IDTVEC(intr5), &IDTVEC(intr6), &IDTVEC(intr7),
- &IDTVEC(intr8), &IDTVEC(intr9), &IDTVEC(intr10), &IDTVEC(intr11),
- &IDTVEC(intr12), &IDTVEC(intr13), &IDTVEC(intr14), &IDTVEC(intr15),
-#if defined(APIC_IO)
- &IDTVEC(intr16), &IDTVEC(intr17), &IDTVEC(intr18), &IDTVEC(intr19),
- &IDTVEC(intr20), &IDTVEC(intr21), &IDTVEC(intr22), &IDTVEC(intr23),
-#endif /* APIC_IO */
-};
-
-static inthand2_t isa_strayintr;
-
-#ifdef PC98
-#define NMI_PARITY 0x04
-#define NMI_EPARITY 0x02
-#else
-#define NMI_PARITY (1 << 7)
-#define NMI_IOCHAN (1 << 6)
-#define ENMI_WATCHDOG (1 << 7)
-#define ENMI_BUSTIMER (1 << 6)
-#define ENMI_IOSTATUS (1 << 5)
-#endif
-
-/*
- * Handle a NMI, possibly a machine check.
- * return true to panic system, false to ignore.
- */
-int
-isa_nmi(cd)
- int cd;
-{
-#ifdef PC98
- int port = inb(0x33);
- if (epson_machine_id == 0x20)
- epson_outb(0xc16, epson_inb(0xc16) | 0x1);
- if (port & NMI_PARITY) {
- panic("BASE RAM parity error, likely hardware failure.");
- } else if (port & NMI_EPARITY) {
- panic("EXTENDED RAM parity error, likely hardware failure.");
- } else {
- printf("\nNMI Resume ??\n");
- return(0);
- }
-#else /* IBM-PC */
- int isa_port = inb(0x61);
- int eisa_port = inb(0x461);
-
-#if NMCA > 0
- if (MCA_system && mca_bus_nmi())
- return(0);
-#endif
-
- if (isa_port & NMI_PARITY)
- panic("RAM parity error, likely hardware failure.");
-
- if (isa_port & NMI_IOCHAN)
- panic("I/O channel check, likely hardware failure.");
-
- /*
- * On a real EISA machine, this will never happen. However it can
- * happen on ISA machines which implement XT style floating point
- * error handling (very rare). Save them from a meaningless panic.
- */
- if (eisa_port == 0xff)
- return(0);
-
- if (eisa_port & ENMI_WATCHDOG)
- panic("EISA watchdog timer expired, likely hardware failure.");
-
- if (eisa_port & ENMI_BUSTIMER)
- panic("EISA bus timeout, likely hardware failure.");
-
- if (eisa_port & ENMI_IOSTATUS)
- panic("EISA I/O port status error.");
-
- printf("\nNMI ISA %x, EISA %x\n", isa_port, eisa_port);
- return(0);
-#endif
-}
-
-/*
- * Fill in default interrupt table (in case of spuruious interrupt
- * during configuration of kernel, setup interrupt control unit
- */
-void
-isa_defaultirq()
-{
- int i;
-
- /* icu vectors */
- for (i = 0; i < ICU_LEN; i++)
- icu_unset(i, (inthand2_t *)NULL);
-
- /* initialize 8259's */
-#if NMCA > 0
- if (MCA_system)
- outb(IO_ICU1, 0x19); /* reset; program device, four bytes */
- else
-#endif
- outb(IO_ICU1, 0x11); /* reset; program device, four bytes */
-
- outb(IO_ICU1+ICU_IMR_OFFSET, NRSVIDT); /* starting at this vector index */
- outb(IO_ICU1+ICU_IMR_OFFSET, IRQ_SLAVE); /* slave on line 7 */
-#ifdef PC98
-#ifdef AUTO_EOI_1
- outb(IO_ICU1+ICU_IMR_OFFSET, 0x1f); /* (master) auto EOI, 8086 mode */
-#else
- outb(IO_ICU1+ICU_IMR_OFFSET, 0x1d); /* (master) 8086 mode */
-#endif
-#else /* IBM-PC */
-#ifdef AUTO_EOI_1
- outb(IO_ICU1+ICU_IMR_OFFSET, 2 | 1); /* auto EOI, 8086 mode */
-#else
- outb(IO_ICU1+ICU_IMR_OFFSET, 1); /* 8086 mode */
-#endif
-#endif /* PC98 */
- outb(IO_ICU1+ICU_IMR_OFFSET, 0xff); /* leave interrupts masked */
- outb(IO_ICU1, 0x0a); /* default to IRR on read */
-#ifndef PC98
- outb(IO_ICU1, 0xc0 | (3 - 1)); /* pri order 3-7, 0-2 (com2 first) */
-#endif /* !PC98 */
-
-#if NMCA > 0
- if (MCA_system)
- outb(IO_ICU2, 0x19); /* reset; program device, four bytes */
- else
-#endif
- outb(IO_ICU2, 0x11); /* reset; program device, four bytes */
-
- outb(IO_ICU2+ICU_IMR_OFFSET, NRSVIDT+8); /* staring at this vector index */
- outb(IO_ICU2+ICU_IMR_OFFSET, ICU_SLAVEID); /* my slave id is 7 */
-#ifdef PC98
- outb(IO_ICU2+ICU_IMR_OFFSET,9); /* 8086 mode */
-#else /* IBM-PC */
-#ifdef AUTO_EOI_2
- outb(IO_ICU2+ICU_IMR_OFFSET, 2 | 1); /* auto EOI, 8086 mode */
-#else
- outb(IO_ICU2+ICU_IMR_OFFSET,1); /* 8086 mode */
-#endif
-#endif /* PC98 */
- outb(IO_ICU2+ICU_IMR_OFFSET, 0xff); /* leave interrupts masked */
- outb(IO_ICU2, 0x0a); /* default to IRR on read */
-}
-
-/*
- * Caught a stray interrupt, notify
- */
-static void
-isa_strayintr(vcookiep)
- void *vcookiep;
-{
- int intr = (void **)vcookiep - &intr_unit[0];
-
- /* DON'T BOTHER FOR NOW! */
- /* for some reason, we get bursts of intr #7, even if not enabled! */
- /*
- * Well the reason you got bursts of intr #7 is because someone
- * raised an interrupt line and dropped it before the 8259 could
- * prioritize it. This is documented in the intel data book. This
- * means you have BAD hardware! I have changed this so that only
- * the first 5 get logged, then it quits logging them, and puts
- * out a special message. rgrimes 3/25/1993
- */
- /*
- * XXX TODO print a different message for #7 if it is for a
- * glitch. Glitches can be distinguished from real #7's by
- * testing that the in-service bit is _not_ set. The test
- * must be done before sending an EOI so it can't be done if
- * we are using AUTO_EOI_1.
- */
- if (intrcnt[1 + intr] <= 5)
- log(LOG_ERR, "stray irq %d\n", intr);
- if (intrcnt[1 + intr] == 5)
- log(LOG_CRIT,
- "too many stray irq %d's; not logging any more\n", intr);
-}
-
-#if NISA > 0
-/*
- * Return a bitmap of the current interrupt requests. This is 8259-specific
- * and is only suitable for use at probe time.
- */
-intrmask_t
-isa_irq_pending()
-{
- u_char irr1;
- u_char irr2;
-
- irr1 = inb(IO_ICU1);
- irr2 = inb(IO_ICU2);
- return ((irr2 << 8) | irr1);
-}
-#endif
-
-int
-update_intr_masks(void)
-{
- int intr, n=0;
- u_int mask,*maskptr;
-
- for (intr=0; intr < ICU_LEN; intr ++) {
-#if defined(APIC_IO)
- /* no 8259 SLAVE to ignore */
-#else
- if (intr==ICU_SLAVEID) continue; /* ignore 8259 SLAVE output */
-#endif /* APIC_IO */
- maskptr = intr_mptr[intr];
- if (!maskptr)
- continue;
- *maskptr |= SWI_CLOCK_MASK | (1 << intr);
- mask = *maskptr;
- if (mask != intr_mask[intr]) {
-#if 0
- printf ("intr_mask[%2d] old=%08x new=%08x ptr=%p.\n",
- intr, intr_mask[intr], mask, maskptr);
-#endif
- intr_mask[intr]=mask;
- n++;
- }
-
- }
- return (n);
-}
-
-static void
-update_intrname(int intr, char *name)
-{
- char buf[32];
- char *cp;
- int name_index, off, strayintr;
-
- /*
- * Initialise strings for bitbucket and stray interrupt counters.
- * These have statically allocated indices 0 and 1 through ICU_LEN.
- */
- if (intrnames[0] == '\0') {
- off = sprintf(intrnames, "???") + 1;
- for (strayintr = 0; strayintr < ICU_LEN; strayintr++)
- off += sprintf(intrnames + off, "stray irq%d",
- strayintr) + 1;
- }
-
- if (name == NULL)
- name = "???";
- if (snprintf(buf, sizeof(buf), "%s irq%d", name, intr) >= sizeof(buf))
- goto use_bitbucket;
-
- /*
- * Search for `buf' in `intrnames'. In the usual case when it is
- * not found, append it to the end if there is enough space (the \0
- * terminator for the previous string, if any, becomes a separator).
- */
- for (cp = intrnames, name_index = 0;
- cp != eintrnames && name_index < NR_INTRNAMES;
- cp += strlen(cp) + 1, name_index++) {
- if (*cp == '\0') {
- if (strlen(buf) >= eintrnames - cp)
- break;
- strcpy(cp, buf);
- goto found;
- }
- if (strcmp(cp, buf) == 0)
- goto found;
- }
-
-use_bitbucket:
- printf("update_intrname: counting %s irq%d as %s\n", name, intr,
- intrnames);
- name_index = 0;
-found:
- intr_countp[intr] = &intrcnt[name_index];
-}
-
-int
-icu_setup(int intr, inthand2_t *handler, void *arg, u_int *maskptr, int flags)
-{
-#ifdef FAST_HI
- int select; /* the select register is 8 bits */
- int vector;
- u_int32_t value; /* the window register is 32 bits */
-#endif /* FAST_HI */
- u_long ef;
- u_int mask = (maskptr ? *maskptr : 0);
-
-#if defined(APIC_IO)
- if ((u_int)intr >= ICU_LEN) /* no 8259 SLAVE to ignore */
-#else
- if ((u_int)intr >= ICU_LEN || intr == ICU_SLAVEID)
-#endif /* APIC_IO */
- if (intr_handler[intr] != isa_strayintr)
- return (EBUSY);
-
- ef = read_eflags();
- disable_intr();
- intr_handler[intr] = handler;
- intr_mptr[intr] = maskptr;
- intr_mask[intr] = mask | SWI_CLOCK_MASK | (1 << intr);
- intr_unit[intr] = arg;
-#ifdef FAST_HI
- if (flags & INTR_FAST) {
- vector = TPR_FAST_INTS + intr;
- setidt(vector, fastintr[intr],
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- }
- else {
- vector = TPR_SLOW_INTS + intr;
-#ifdef APIC_INTR_REORDER
-#ifdef APIC_INTR_HIGHPRI_CLOCK
- /* XXX: Hack (kludge?) for more accurate clock. */
- if (intr == apic_8254_intr || intr == 8) {
- vector = TPR_FAST_INTS + intr;
- }
-#endif
-#endif
- setidt(vector, slowintr[intr],
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- }
-#ifdef APIC_INTR_REORDER
- set_lapic_isrloc(intr, vector);
-#endif
- /*
- * Reprogram the vector in the IO APIC.
- */
- if (int_to_apicintpin[intr].ioapic >= 0) {
- select = int_to_apicintpin[intr].redirindex;
- value = io_apic_read(int_to_apicintpin[intr].ioapic,
- select) & ~IOART_INTVEC;
- io_apic_write(int_to_apicintpin[intr].ioapic,
- select, value | vector);
- }
-#else
- setidt(ICU_OFFSET + intr,
- flags & INTR_FAST ? fastintr[intr] : slowintr[intr],
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-#endif /* FAST_HI */
- INTREN(1 << intr);
- MPINTR_UNLOCK();
- write_eflags(ef);
- return (0);
-}
-
-int
-icu_unset(intr, handler)
- int intr;
- inthand2_t *handler;
-{
- u_long ef;
-
- if ((u_int)intr >= ICU_LEN || handler != intr_handler[intr])
- return (EINVAL);
-
- INTRDIS(1 << intr);
- ef = read_eflags();
- disable_intr();
- intr_countp[intr] = &intrcnt[1 + intr];
- intr_handler[intr] = isa_strayintr;
- intr_mptr[intr] = NULL;
- intr_mask[intr] = HWI_MASK | SWI_MASK;
- intr_unit[intr] = &intr_unit[intr];
-#ifdef FAST_HI_XXX
- /* XXX how do I re-create dvp here? */
- setidt(flags & INTR_FAST ? TPR_FAST_INTS + intr : TPR_SLOW_INTS + intr,
- slowintr[intr], SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-#else /* FAST_HI */
-#ifdef APIC_INTR_REORDER
- set_lapic_isrloc(intr, ICU_OFFSET + intr);
-#endif
- setidt(ICU_OFFSET + intr, slowintr[intr], SDT_SYS386IGT, SEL_KPL,
- GSEL(GCODE_SEL, SEL_KPL));
-#endif /* FAST_HI */
- MPINTR_UNLOCK();
- write_eflags(ef);
- return (0);
-}
-
-/* The following notice applies beyond this point in the file */
-
-/*
- * Copyright (c) 1997, Stefan Esser <se@freebsd.org>
- * 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 unmodified, 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.
- *
- * $FreeBSD$
- *
- */
-
-typedef struct intrec {
- intrmask_t mask;
- inthand2_t *handler;
- void *argument;
- struct intrec *next;
- char *name;
- int intr;
- intrmask_t *maskptr;
- int flags;
-} intrec;
-
-static intrec *intreclist_head[ICU_LEN];
-
-/*
- * The interrupt multiplexer calls each of the handlers in turn. The
- * ipl is initially quite low. It is raised as necessary for each call
- * and lowered after the call. Thus out of order handling is possible
- * even for interrupts of the same type. This is probably no more
- * harmful than out of order handling in general (not harmful except
- * for real time response which we don't support anyway).
- */
-static void
-intr_mux(void *arg)
-{
- intrec *p;
- intrmask_t oldspl;
-
- for (p = arg; p != NULL; p = p->next) {
- oldspl = splq(p->mask);
- p->handler(p->argument);
- splx(oldspl);
- }
-}
-
-static intrec*
-find_idesc(unsigned *maskptr, int irq)
-{
- intrec *p = intreclist_head[irq];
-
- while (p && p->maskptr != maskptr)
- p = p->next;
-
- return (p);
-}
-
-static intrec**
-find_pred(intrec *idesc, int irq)
-{
- intrec **pp = &intreclist_head[irq];
- intrec *p = *pp;
-
- while (p != idesc) {
- if (p == NULL)
- return (NULL);
- pp = &p->next;
- p = *pp;
- }
- return (pp);
-}
-
-/*
- * Both the low level handler and the shared interrupt multiplexer
- * block out further interrupts as set in the handlers "mask", while
- * the handler is running. In fact *maskptr should be used for this
- * purpose, but since this requires one more pointer dereference on
- * each interrupt, we rather bother update "mask" whenever *maskptr
- * changes. The function "update_masks" should be called **after**
- * all manipulation of the linked list of interrupt handlers hung
- * off of intrdec_head[irq] is complete, since the chain of handlers
- * will both determine the *maskptr values and the instances of mask
- * that are fixed. This function should be called with the irq for
- * which a new handler has been add blocked, since the masks may not
- * yet know about the use of this irq for a device of a certain class.
- */
-
-static void
-update_mux_masks(void)
-{
- int irq;
- for (irq = 0; irq < ICU_LEN; irq++) {
- intrec *idesc = intreclist_head[irq];
- while (idesc != NULL) {
- if (idesc->maskptr != NULL) {
- /* our copy of *maskptr may be stale, refresh */
- idesc->mask = *idesc->maskptr;
- }
- idesc = idesc->next;
- }
- }
-}
-
-static void
-update_masks(intrmask_t *maskptr, int irq)
-{
- intrmask_t mask = 1 << irq;
-
- if (maskptr == NULL)
- return;
-
- if (find_idesc(maskptr, irq) == NULL) {
- /* no reference to this maskptr was found in this irq's chain */
- if ((*maskptr & mask) == 0)
- return;
- /* the irq was included in the classes mask, remove it */
- *maskptr &= ~mask;
- } else {
- /* a reference to this maskptr was found in this irq's chain */
- if ((*maskptr & mask) != 0)
- return;
- /* put the irq into the classes mask */
- *maskptr |= mask;
- }
- /* we need to update all values in the intr_mask[irq] array */
- update_intr_masks();
- /* update mask in chains of the interrupt multiplex handler as well */
- update_mux_masks();
-}
-
-/*
- * Add interrupt handler to linked list hung off of intreclist_head[irq]
- * and install shared interrupt multiplex handler, if necessary
- */
-
-static int
-add_intrdesc(intrec *idesc)
-{
- int irq = idesc->intr;
-
- intrec *head = intreclist_head[irq];
-
- if (head == NULL) {
- /* first handler for this irq, just install it */
- if (icu_setup(irq, idesc->handler, idesc->argument,
- idesc->maskptr, idesc->flags) != 0)
- return (-1);
-
- update_intrname(irq, idesc->name);
- /* keep reference */
- intreclist_head[irq] = idesc;
- } else {
- if ((idesc->flags & INTR_EXCL) != 0
- || (head->flags & INTR_EXCL) != 0) {
- /*
- * can't append new handler, if either list head or
- * new handler do not allow interrupts to be shared
- */
- if (bootverbose)
- printf("\tdevice combination doesn't support "
- "shared irq%d\n", irq);
- return (-1);
- }
- if (head->next == NULL) {
- /*
- * second handler for this irq, replace device driver's
- * handler by shared interrupt multiplexer function
- */
- icu_unset(irq, head->handler);
- if (icu_setup(irq, intr_mux, head, 0, 0) != 0)
- return (-1);
- if (bootverbose)
- printf("\tusing shared irq%d.\n", irq);
- update_intrname(irq, "mux");
- }
- /* just append to the end of the chain */
- while (head->next != NULL)
- head = head->next;
- head->next = idesc;
- }
- update_masks(idesc->maskptr, irq);
- return (0);
-}
-
-/*
- * Create and activate an interrupt handler descriptor data structure.
- *
- * The dev_instance pointer is required for resource management, and will
- * only be passed through to resource_claim().
- *
- * There will be functions that derive a driver and unit name from a
- * dev_instance variable, and those functions will be used to maintain the
- * interrupt counter label array referenced by systat and vmstat to report
- * device interrupt rates (->update_intrlabels).
- *
- * Add the interrupt handler descriptor data structure created by an
- * earlier call of create_intr() to the linked list for its irq and
- * adjust the interrupt masks if necessary.
- */
-
-intrec *
-inthand_add(const char *name, int irq, inthand2_t handler, void *arg,
- intrmask_t *maskptr, int flags)
-{
- intrec *idesc;
- int errcode = -1;
- intrmask_t oldspl;
-
- if (ICU_LEN > 8 * sizeof *maskptr) {
- printf("create_intr: ICU_LEN of %d too high for %d bit intrmask\n",
- ICU_LEN, 8 * sizeof *maskptr);
- return (NULL);
- }
- if ((unsigned)irq >= ICU_LEN) {
- printf("create_intr: requested irq%d too high, limit is %d\n",
- irq, ICU_LEN -1);
- return (NULL);
- }
-
- idesc = malloc(sizeof *idesc, M_DEVBUF, M_WAITOK);
- if (idesc == NULL)
- return NULL;
- bzero(idesc, sizeof *idesc);
-
- if (name == NULL)
- name = "???";
- idesc->name = malloc(strlen(name) + 1, M_DEVBUF, M_WAITOK);
- if (idesc->name == NULL) {
- free(idesc, M_DEVBUF);
- return NULL;
- }
- strcpy(idesc->name, name);
-
- idesc->handler = handler;
- idesc->argument = arg;
- idesc->maskptr = maskptr;
- idesc->intr = irq;
- idesc->flags = flags;
-
- /* block this irq */
- oldspl = splq(1 << irq);
-
- /* add irq to class selected by maskptr */
- errcode = add_intrdesc(idesc);
- splx(oldspl);
-
- if (errcode != 0) {
- if (bootverbose)
- printf("\tintr_connect(irq%d) failed, result=%d\n",
- irq, errcode);
- free(idesc->name, M_DEVBUF);
- free(idesc, M_DEVBUF);
- idesc = NULL;
- }
-
- return (idesc);
-}
-
-/*
- * Deactivate and remove the interrupt handler descriptor data connected
- * created by an earlier call of intr_connect() from the linked list and
- * adjust theinterrupt masks if necessary.
- *
- * Return the memory held by the interrupt handler descriptor data structure
- * to the system. Make sure, the handler is not actively used anymore, before.
- */
-
-int
-inthand_remove(intrec *idesc)
-{
- intrec **hook, *head;
- int irq;
- int errcode = 0;
- intrmask_t oldspl;
-
- if (idesc == NULL)
- return (-1);
-
- irq = idesc->intr;
-
- /* find pointer that keeps the reference to this interrupt descriptor */
- hook = find_pred(idesc, irq);
- if (hook == NULL)
- return (-1);
-
- /* make copy of original list head, the line after may overwrite it */
- head = intreclist_head[irq];
-
- /* unlink: make predecessor point to idesc->next instead of to idesc */
- *hook = idesc->next;
-
- /* now check whether the element we removed was the list head */
- if (idesc == head) {
-
- oldspl = splq(1 << irq);
-
- /* check whether the new list head is the only element on list */
- head = intreclist_head[irq];
- if (head != NULL) {
- icu_unset(irq, intr_mux);
- if (head->next != NULL) {
- /* install the multiplex handler with new list head as argument */
- errcode = icu_setup(irq, intr_mux, head, 0, 0);
- if (errcode == 0)
- update_intrname(irq, NULL);
- } else {
- /* install the one remaining handler for this irq */
- errcode = icu_setup(irq, head->handler,
- head->argument,
- head->maskptr, head->flags);
- if (errcode == 0)
- update_intrname(irq, head->name);
- }
- } else {
- /* revert to old handler, eg: strayintr */
- icu_unset(irq, idesc->handler);
- }
- splx(oldspl);
- }
- update_masks(idesc->maskptr, irq);
- free(idesc, M_DEVBUF);
- return (0);
-}
diff --git a/sys/amd64/isa/npx.c b/sys/amd64/isa/npx.c
deleted file mode 100644
index 30914d017355..000000000000
--- a/sys/amd64/isa/npx.c
+++ /dev/null
@@ -1,928 +0,0 @@
-/*-
- * Copyright (c) 1990 William Jolitz.
- * 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. 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, Berkeley and its contributors.
- * 4. 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: @(#)npx.c 7.2 (Berkeley) 5/12/91
- * $FreeBSD$
- */
-
-#include "opt_debug_npx.h"
-#include "opt_math_emulate.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/kernel.h>
-#include <sys/malloc.h>
-#include <sys/module.h>
-#include <sys/sysctl.h>
-#include <sys/proc.h>
-#include <machine/bus.h>
-#include <sys/rman.h>
-#ifdef NPX_DEBUG
-#include <sys/syslog.h>
-#endif
-#include <sys/signalvar.h>
-
-#ifndef SMP
-#include <machine/asmacros.h>
-#endif
-#include <machine/cputypes.h>
-#include <machine/frame.h>
-#include <machine/ipl.h>
-#include <machine/md_var.h>
-#include <machine/pcb.h>
-#include <machine/psl.h>
-#ifndef SMP
-#include <machine/clock.h>
-#endif
-#include <machine/resource.h>
-#include <machine/specialreg.h>
-#include <machine/segments.h>
-
-#ifndef SMP
-#include <i386/isa/icu.h>
-#include <i386/isa/intr_machdep.h>
-#include <i386/isa/isa.h>
-#endif
-
-/*
- * 387 and 287 Numeric Coprocessor Extension (NPX) Driver.
- */
-
-/* Configuration flags. */
-#define NPX_DISABLE_I586_OPTIMIZED_BCOPY (1 << 0)
-#define NPX_DISABLE_I586_OPTIMIZED_BZERO (1 << 1)
-#define NPX_DISABLE_I586_OPTIMIZED_COPYIO (1 << 2)
-#define NPX_PREFER_EMULATOR (1 << 3)
-
-#ifdef __GNUC__
-
-#define fldcw(addr) __asm("fldcw %0" : : "m" (*(addr)))
-#define fnclex() __asm("fnclex")
-#define fninit() __asm("fninit")
-#define fnop() __asm("fnop")
-#define fnsave(addr) __asm __volatile("fnsave %0" : "=m" (*(addr)))
-#define fnstcw(addr) __asm __volatile("fnstcw %0" : "=m" (*(addr)))
-#define fnstsw(addr) __asm __volatile("fnstsw %0" : "=m" (*(addr)))
-#define fp_divide_by_0() __asm("fldz; fld1; fdiv %st,%st(1); fnop")
-#define frstor(addr) __asm("frstor %0" : : "m" (*(addr)))
-#define start_emulating() __asm("smsw %%ax; orb %0,%%al; lmsw %%ax" \
- : : "n" (CR0_TS) : "ax")
-#define stop_emulating() __asm("clts")
-
-#else /* not __GNUC__ */
-
-void fldcw __P((caddr_t addr));
-void fnclex __P((void));
-void fninit __P((void));
-void fnop __P((void));
-void fnsave __P((caddr_t addr));
-void fnstcw __P((caddr_t addr));
-void fnstsw __P((caddr_t addr));
-void fp_divide_by_0 __P((void));
-void frstor __P((caddr_t addr));
-void start_emulating __P((void));
-void stop_emulating __P((void));
-
-#endif /* __GNUC__ */
-
-typedef u_char bool_t;
-
-static int npx_attach __P((device_t dev));
- void npx_intr __P((void *));
-static void npx_identify __P((driver_t *driver, device_t parent));
-static int npx_probe __P((device_t dev));
-static int npx_probe1 __P((device_t dev));
-#ifdef I586_CPU
-static long timezero __P((const char *funcname,
- void (*func)(void *buf, size_t len)));
-#endif /* I586_CPU */
-
-int hw_float; /* XXX currently just alias for npx_exists */
-
-SYSCTL_INT(_hw,HW_FLOATINGPT, floatingpoint,
- CTLFLAG_RD, &hw_float, 0,
- "Floatingpoint instructions executed in hardware");
-
-#ifndef SMP
-static u_int npx0_imask = SWI_CLOCK_MASK;
-static struct gate_descriptor npx_idt_probeintr;
-static int npx_intrno;
-static volatile u_int npx_intrs_while_probing;
-static volatile u_int npx_traps_while_probing;
-#endif
-
-static bool_t npx_ex16;
-static bool_t npx_exists;
-static bool_t npx_irq13;
-static int npx_irq; /* irq number */
-
-#ifndef SMP
-/*
- * Special interrupt handlers. Someday intr0-intr15 will be used to count
- * interrupts. We'll still need a special exception 16 handler. The busy
- * latch stuff in probeintr() can be moved to npxprobe().
- */
-inthand_t probeintr;
-__asm(" \n\
- .text \n\
- .p2align 2,0x90 \n\
- .type " __XSTRING(CNAME(probeintr)) ",@function \n\
-" __XSTRING(CNAME(probeintr)) ": \n\
- ss \n\
- incl " __XSTRING(CNAME(npx_intrs_while_probing)) " \n\
- pushl %eax \n\
- movb $0x20,%al # EOI (asm in strings loses cpp features) \n\
- outb %al,$0xa0 # IO_ICU2 \n\
- outb %al,$0x20 # IO_ICU1 \n\
- movb $0,%al \n\
- outb %al,$0xf0 # clear BUSY# latch \n\
- popl %eax \n\
- iret \n\
-");
-
-inthand_t probetrap;
-__asm(" \n\
- .text \n\
- .p2align 2,0x90 \n\
- .type " __XSTRING(CNAME(probetrap)) ",@function \n\
-" __XSTRING(CNAME(probetrap)) ": \n\
- ss \n\
- incl " __XSTRING(CNAME(npx_traps_while_probing)) " \n\
- fnclex \n\
- iret \n\
-");
-#endif /* SMP */
-
-/*
- * Identify routine. Create a connection point on our parent for probing.
- */
-static void
-npx_identify(driver, parent)
- driver_t *driver;
- device_t parent;
-{
- device_t child;
-
- child = BUS_ADD_CHILD(parent, 0, "npx", 0);
- if (child == NULL)
- panic("npx_identify");
-}
-
-/*
- * Probe routine. Initialize cr0 to give correct behaviour for [f]wait
- * whether the device exists or not (XXX should be elsewhere). Set flags
- * to tell npxattach() what to do. Modify device struct if npx doesn't
- * need to use interrupts. Return 1 if device exists.
- */
-static int
-npx_probe(dev)
- device_t dev;
-{
-#ifdef SMP
-
- if (resource_int_value("npx", 0, "irq", &npx_irq) != 0)
- npx_irq = 13;
- return npx_probe1(dev);
-
-#else /* SMP */
-
- int result;
- u_long save_eflags;
- u_char save_icu1_mask;
- u_char save_icu2_mask;
- struct gate_descriptor save_idt_npxintr;
- struct gate_descriptor save_idt_npxtrap;
- /*
- * This routine is now just a wrapper for npxprobe1(), to install
- * special npx interrupt and trap handlers, to enable npx interrupts
- * and to disable other interrupts. Someday isa_configure() will
- * install suitable handlers and run with interrupts enabled so we
- * won't need to do so much here.
- */
- if (resource_int_value("npx", 0, "irq", &npx_irq) != 0)
- npx_irq = 13;
- npx_intrno = NRSVIDT + npx_irq;
- save_eflags = read_eflags();
- disable_intr();
- save_icu1_mask = inb(IO_ICU1 + 1);
- save_icu2_mask = inb(IO_ICU2 + 1);
- save_idt_npxintr = idt[npx_intrno];
- save_idt_npxtrap = idt[16];
- outb(IO_ICU1 + 1, ~IRQ_SLAVE);
- outb(IO_ICU2 + 1, ~(1 << (npx_irq - 8)));
- setidt(16, probetrap, SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(npx_intrno, probeintr, SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- npx_idt_probeintr = idt[npx_intrno];
- enable_intr();
- result = npx_probe1(dev);
- disable_intr();
- outb(IO_ICU1 + 1, save_icu1_mask);
- outb(IO_ICU2 + 1, save_icu2_mask);
- idt[npx_intrno] = save_idt_npxintr;
- idt[16] = save_idt_npxtrap;
- write_eflags(save_eflags);
- return (result);
-
-#endif /* SMP */
-}
-
-static int
-npx_probe1(dev)
- device_t dev;
-{
-#ifndef SMP
- u_short control;
- u_short status;
-#endif
-
- /*
- * Partially reset the coprocessor, if any. Some BIOS's don't reset
- * it after a warm boot.
- */
- outb(0xf1, 0); /* full reset on some systems, NOP on others */
- outb(0xf0, 0); /* clear BUSY# latch */
- /*
- * Prepare to trap all ESC (i.e., NPX) instructions and all WAIT
- * instructions. We must set the CR0_MP bit and use the CR0_TS
- * bit to control the trap, because setting the CR0_EM bit does
- * not cause WAIT instructions to trap. It's important to trap
- * WAIT instructions - otherwise the "wait" variants of no-wait
- * control instructions would degenerate to the "no-wait" variants
- * after FP context switches but work correctly otherwise. It's
- * particularly important to trap WAITs when there is no NPX -
- * otherwise the "wait" variants would always degenerate.
- *
- * Try setting CR0_NE to get correct error reporting on 486DX's.
- * Setting it should fail or do nothing on lesser processors.
- */
- load_cr0(rcr0() | CR0_MP | CR0_NE);
- /*
- * But don't trap while we're probing.
- */
- stop_emulating();
- /*
- * Finish resetting the coprocessor, if any. If there is an error
- * pending, then we may get a bogus IRQ13, but probeintr() will handle
- * it OK. Bogus halts have never been observed, but we enabled
- * IRQ13 and cleared the BUSY# latch early to handle them anyway.
- */
- fninit();
-
-#ifdef SMP
- /*
- * Exception 16 MUST work for SMP.
- */
- npx_irq13 = 0;
- npx_ex16 = hw_float = npx_exists = 1;
- device_set_desc(dev, "math processor");
- return (0);
-
-#else /* !SMP */
- device_set_desc(dev, "math processor");
-
- /*
- * Don't use fwait here because it might hang.
- * Don't use fnop here because it usually hangs if there is no FPU.
- */
- DELAY(1000); /* wait for any IRQ13 */
-#ifdef DIAGNOSTIC
- if (npx_intrs_while_probing != 0)
- printf("fninit caused %u bogus npx interrupt(s)\n",
- npx_intrs_while_probing);
- if (npx_traps_while_probing != 0)
- printf("fninit caused %u bogus npx trap(s)\n",
- npx_traps_while_probing);
-#endif
- /*
- * Check for a status of mostly zero.
- */
- status = 0x5a5a;
- fnstsw(&status);
- if ((status & 0xb8ff) == 0) {
- /*
- * Good, now check for a proper control word.
- */
- control = 0x5a5a;
- fnstcw(&control);
- if ((control & 0x1f3f) == 0x033f) {
- hw_float = npx_exists = 1;
- /*
- * We have an npx, now divide by 0 to see if exception
- * 16 works.
- */
- control &= ~(1 << 2); /* enable divide by 0 trap */
- fldcw(&control);
- npx_traps_while_probing = npx_intrs_while_probing = 0;
- fp_divide_by_0();
- if (npx_traps_while_probing != 0) {
- /*
- * Good, exception 16 works.
- */
- npx_ex16 = 1;
- return (0);
- }
- if (npx_intrs_while_probing != 0) {
- int rid;
- struct resource *r;
- void *intr;
- /*
- * Bad, we are stuck with IRQ13.
- */
- npx_irq13 = 1;
- /*
- * npxattach would be too late to set npx0_imask
- */
- npx0_imask |= (1 << npx_irq);
-
- /*
- * We allocate these resources permanently,
- * so there is no need to keep track of them.
- */
- rid = 0;
- r = bus_alloc_resource(dev, SYS_RES_IOPORT,
- &rid, IO_NPX, IO_NPX,
- IO_NPXSIZE, RF_ACTIVE);
- if (r == 0)
- panic("npx: can't get ports");
- rid = 0;
- r = bus_alloc_resource(dev, SYS_RES_IRQ,
- &rid, npx_irq, npx_irq,
- 1, RF_ACTIVE);
- if (r == 0)
- panic("npx: can't get IRQ");
- BUS_SETUP_INTR(device_get_parent(dev),
- dev, r, INTR_TYPE_MISC,
- npx_intr, 0, &intr);
- if (intr == 0)
- panic("npx: can't create intr");
-
- return (0);
- }
- /*
- * Worse, even IRQ13 is broken. Use emulator.
- */
- }
- }
- /*
- * Probe failed, but we want to get to npxattach to initialize the
- * emulator and say that it has been installed. XXX handle devices
- * that aren't really devices better.
- */
- return (0);
-#endif /* SMP */
-}
-
-/*
- * Attach routine - announce which it is, and wire into system
- */
-int
-npx_attach(dev)
- device_t dev;
-{
- int flags;
-
- if (resource_int_value("npx", 0, "flags", &flags) != 0)
- flags = 0;
-
- if (flags)
- device_printf(dev, "flags 0x%x ", flags);
- if (npx_irq13) {
- device_printf(dev, "using IRQ 13 interface\n");
- } else {
-#if defined(MATH_EMULATE) || defined(GPL_MATH_EMULATE)
- if (npx_ex16) {
- if (!(flags & NPX_PREFER_EMULATOR))
- device_printf(dev, "INT 16 interface\n");
- else {
- device_printf(dev, "FPU exists, but flags request "
- "emulator\n");
- hw_float = npx_exists = 0;
- }
- } else if (npx_exists) {
- device_printf(dev, "error reporting broken; using 387 emulator\n");
- hw_float = npx_exists = 0;
- } else
- device_printf(dev, "387 emulator\n");
-#else
- if (npx_ex16) {
- device_printf(dev, "INT 16 interface\n");
- if (flags & NPX_PREFER_EMULATOR) {
- device_printf(dev, "emulator requested, but none compiled "
- "into kernel, using FPU\n");
- }
- } else
- device_printf(dev, "no 387 emulator in kernel and no FPU!\n");
-#endif
- }
- npxinit(__INITIAL_NPXCW__);
-
-#ifdef I586_CPU
- if (cpu_class == CPUCLASS_586 && npx_ex16 && npx_exists &&
- timezero("i586_bzero()", i586_bzero) <
- timezero("bzero()", bzero) * 4 / 5) {
- if (!(flags & NPX_DISABLE_I586_OPTIMIZED_BCOPY)) {
- bcopy_vector = i586_bcopy;
- ovbcopy_vector = i586_bcopy;
- }
- if (!(flags & NPX_DISABLE_I586_OPTIMIZED_BZERO))
- bzero = i586_bzero;
- if (!(flags & NPX_DISABLE_I586_OPTIMIZED_COPYIO)) {
- copyin_vector = i586_copyin;
- copyout_vector = i586_copyout;
- }
- }
-#endif
-
- return (0); /* XXX unused */
-}
-
-/*
- * Initialize floating point unit.
- */
-void
-npxinit(control)
- u_short control;
-{
- struct save87 dummy;
-
- if (!npx_exists)
- return;
- /*
- * fninit has the same h/w bugs as fnsave. Use the detoxified
- * fnsave to throw away any junk in the fpu. npxsave() initializes
- * the fpu and sets npxproc = NULL as important side effects.
- */
- npxsave(&dummy);
- stop_emulating();
- fldcw(&control);
- if (curpcb != NULL)
- fnsave(&curpcb->pcb_savefpu);
- start_emulating();
-}
-
-/*
- * Free coprocessor (if we have it).
- */
-void
-npxexit(p)
- struct proc *p;
-{
-
- if (p == npxproc)
- npxsave(&curpcb->pcb_savefpu);
-#ifdef NPX_DEBUG
- if (npx_exists) {
- u_int masked_exceptions;
-
- masked_exceptions = curpcb->pcb_savefpu.sv_env.en_cw
- & curpcb->pcb_savefpu.sv_env.en_sw & 0x7f;
- /*
- * Log exceptions that would have trapped with the old
- * control word (overflow, divide by 0, and invalid operand).
- */
- if (masked_exceptions & 0x0d)
- log(LOG_ERR,
- "pid %d (%s) exited with masked floating point exceptions 0x%02x\n",
- p->p_pid, p->p_comm, masked_exceptions);
- }
-#endif
-}
-
-/*
- * The following mechanism is used to ensure that the FPE_... value
- * that is passed as a trapcode to the signal handler of the user
- * process does not have more than one bit set.
- *
- * Multiple bits may be set if the user process modifies the control
- * word while a status word bit is already set. While this is a sign
- * of bad coding, we have no choise than to narrow them down to one
- * bit, since we must not send a trapcode that is not exactly one of
- * the FPE_ macros.
- *
- * The mechanism has a static table with 127 entries. Each combination
- * of the 7 FPU status word exception bits directly translates to a
- * position in this table, where a single FPE_... value is stored.
- * This FPE_... value stored there is considered the "most important"
- * of the exception bits and will be sent as the signal code. The
- * precedence of the bits is based upon Intel Document "Numerical
- * Applications", Chapter "Special Computational Situations".
- *
- * The macro to choose one of these values does these steps: 1) Throw
- * away status word bits that cannot be masked. 2) Throw away the bits
- * currently masked in the control word, assuming the user isn't
- * interested in them anymore. 3) Reinsert status word bit 7 (stack
- * fault) if it is set, which cannot be masked but must be presered.
- * 4) Use the remaining bits to point into the trapcode table.
- *
- * The 6 maskable bits in order of their preference, as stated in the
- * above referenced Intel manual:
- * 1 Invalid operation (FP_X_INV)
- * 1a Stack underflow
- * 1b Stack overflow
- * 1c Operand of unsupported format
- * 1d SNaN operand.
- * 2 QNaN operand (not an exception, irrelavant here)
- * 3 Any other invalid-operation not mentioned above or zero divide
- * (FP_X_INV, FP_X_DZ)
- * 4 Denormal operand (FP_X_DNML)
- * 5 Numeric over/underflow (FP_X_OFL, FP_X_UFL)
- * 6 Inexact result (FP_X_IMP)
- */
-static char fpetable[128] = {
- 0,
- FPE_FLTINV, /* 1 - INV */
- FPE_FLTUND, /* 2 - DNML */
- FPE_FLTINV, /* 3 - INV | DNML */
- FPE_FLTDIV, /* 4 - DZ */
- FPE_FLTINV, /* 5 - INV | DZ */
- FPE_FLTDIV, /* 6 - DNML | DZ */
- FPE_FLTINV, /* 7 - INV | DNML | DZ */
- FPE_FLTOVF, /* 8 - OFL */
- FPE_FLTINV, /* 9 - INV | OFL */
- FPE_FLTUND, /* A - DNML | OFL */
- FPE_FLTINV, /* B - INV | DNML | OFL */
- FPE_FLTDIV, /* C - DZ | OFL */
- FPE_FLTINV, /* D - INV | DZ | OFL */
- FPE_FLTDIV, /* E - DNML | DZ | OFL */
- FPE_FLTINV, /* F - INV | DNML | DZ | OFL */
- FPE_FLTUND, /* 10 - UFL */
- FPE_FLTINV, /* 11 - INV | UFL */
- FPE_FLTUND, /* 12 - DNML | UFL */
- FPE_FLTINV, /* 13 - INV | DNML | UFL */
- FPE_FLTDIV, /* 14 - DZ | UFL */
- FPE_FLTINV, /* 15 - INV | DZ | UFL */
- FPE_FLTDIV, /* 16 - DNML | DZ | UFL */
- FPE_FLTINV, /* 17 - INV | DNML | DZ | UFL */
- FPE_FLTOVF, /* 18 - OFL | UFL */
- FPE_FLTINV, /* 19 - INV | OFL | UFL */
- FPE_FLTUND, /* 1A - DNML | OFL | UFL */
- FPE_FLTINV, /* 1B - INV | DNML | OFL | UFL */
- FPE_FLTDIV, /* 1C - DZ | OFL | UFL */
- FPE_FLTINV, /* 1D - INV | DZ | OFL | UFL */
- FPE_FLTDIV, /* 1E - DNML | DZ | OFL | UFL */
- FPE_FLTINV, /* 1F - INV | DNML | DZ | OFL | UFL */
- FPE_FLTRES, /* 20 - IMP */
- FPE_FLTINV, /* 21 - INV | IMP */
- FPE_FLTUND, /* 22 - DNML | IMP */
- FPE_FLTINV, /* 23 - INV | DNML | IMP */
- FPE_FLTDIV, /* 24 - DZ | IMP */
- FPE_FLTINV, /* 25 - INV | DZ | IMP */
- FPE_FLTDIV, /* 26 - DNML | DZ | IMP */
- FPE_FLTINV, /* 27 - INV | DNML | DZ | IMP */
- FPE_FLTOVF, /* 28 - OFL | IMP */
- FPE_FLTINV, /* 29 - INV | OFL | IMP */
- FPE_FLTUND, /* 2A - DNML | OFL | IMP */
- FPE_FLTINV, /* 2B - INV | DNML | OFL | IMP */
- FPE_FLTDIV, /* 2C - DZ | OFL | IMP */
- FPE_FLTINV, /* 2D - INV | DZ | OFL | IMP */
- FPE_FLTDIV, /* 2E - DNML | DZ | OFL | IMP */
- FPE_FLTINV, /* 2F - INV | DNML | DZ | OFL | IMP */
- FPE_FLTUND, /* 30 - UFL | IMP */
- FPE_FLTINV, /* 31 - INV | UFL | IMP */
- FPE_FLTUND, /* 32 - DNML | UFL | IMP */
- FPE_FLTINV, /* 33 - INV | DNML | UFL | IMP */
- FPE_FLTDIV, /* 34 - DZ | UFL | IMP */
- FPE_FLTINV, /* 35 - INV | DZ | UFL | IMP */
- FPE_FLTDIV, /* 36 - DNML | DZ | UFL | IMP */
- FPE_FLTINV, /* 37 - INV | DNML | DZ | UFL | IMP */
- FPE_FLTOVF, /* 38 - OFL | UFL | IMP */
- FPE_FLTINV, /* 39 - INV | OFL | UFL | IMP */
- FPE_FLTUND, /* 3A - DNML | OFL | UFL | IMP */
- FPE_FLTINV, /* 3B - INV | DNML | OFL | UFL | IMP */
- FPE_FLTDIV, /* 3C - DZ | OFL | UFL | IMP */
- FPE_FLTINV, /* 3D - INV | DZ | OFL | UFL | IMP */
- FPE_FLTDIV, /* 3E - DNML | DZ | OFL | UFL | IMP */
- FPE_FLTINV, /* 3F - INV | DNML | DZ | OFL | UFL | IMP */
- FPE_FLTSUB, /* 40 - STK */
- FPE_FLTSUB, /* 41 - INV | STK */
- FPE_FLTUND, /* 42 - DNML | STK */
- FPE_FLTSUB, /* 43 - INV | DNML | STK */
- FPE_FLTDIV, /* 44 - DZ | STK */
- FPE_FLTSUB, /* 45 - INV | DZ | STK */
- FPE_FLTDIV, /* 46 - DNML | DZ | STK */
- FPE_FLTSUB, /* 47 - INV | DNML | DZ | STK */
- FPE_FLTOVF, /* 48 - OFL | STK */
- FPE_FLTSUB, /* 49 - INV | OFL | STK */
- FPE_FLTUND, /* 4A - DNML | OFL | STK */
- FPE_FLTSUB, /* 4B - INV | DNML | OFL | STK */
- FPE_FLTDIV, /* 4C - DZ | OFL | STK */
- FPE_FLTSUB, /* 4D - INV | DZ | OFL | STK */
- FPE_FLTDIV, /* 4E - DNML | DZ | OFL | STK */
- FPE_FLTSUB, /* 4F - INV | DNML | DZ | OFL | STK */
- FPE_FLTUND, /* 50 - UFL | STK */
- FPE_FLTSUB, /* 51 - INV | UFL | STK */
- FPE_FLTUND, /* 52 - DNML | UFL | STK */
- FPE_FLTSUB, /* 53 - INV | DNML | UFL | STK */
- FPE_FLTDIV, /* 54 - DZ | UFL | STK */
- FPE_FLTSUB, /* 55 - INV | DZ | UFL | STK */
- FPE_FLTDIV, /* 56 - DNML | DZ | UFL | STK */
- FPE_FLTSUB, /* 57 - INV | DNML | DZ | UFL | STK */
- FPE_FLTOVF, /* 58 - OFL | UFL | STK */
- FPE_FLTSUB, /* 59 - INV | OFL | UFL | STK */
- FPE_FLTUND, /* 5A - DNML | OFL | UFL | STK */
- FPE_FLTSUB, /* 5B - INV | DNML | OFL | UFL | STK */
- FPE_FLTDIV, /* 5C - DZ | OFL | UFL | STK */
- FPE_FLTSUB, /* 5D - INV | DZ | OFL | UFL | STK */
- FPE_FLTDIV, /* 5E - DNML | DZ | OFL | UFL | STK */
- FPE_FLTSUB, /* 5F - INV | DNML | DZ | OFL | UFL | STK */
- FPE_FLTRES, /* 60 - IMP | STK */
- FPE_FLTSUB, /* 61 - INV | IMP | STK */
- FPE_FLTUND, /* 62 - DNML | IMP | STK */
- FPE_FLTSUB, /* 63 - INV | DNML | IMP | STK */
- FPE_FLTDIV, /* 64 - DZ | IMP | STK */
- FPE_FLTSUB, /* 65 - INV | DZ | IMP | STK */
- FPE_FLTDIV, /* 66 - DNML | DZ | IMP | STK */
- FPE_FLTSUB, /* 67 - INV | DNML | DZ | IMP | STK */
- FPE_FLTOVF, /* 68 - OFL | IMP | STK */
- FPE_FLTSUB, /* 69 - INV | OFL | IMP | STK */
- FPE_FLTUND, /* 6A - DNML | OFL | IMP | STK */
- FPE_FLTSUB, /* 6B - INV | DNML | OFL | IMP | STK */
- FPE_FLTDIV, /* 6C - DZ | OFL | IMP | STK */
- FPE_FLTSUB, /* 6D - INV | DZ | OFL | IMP | STK */
- FPE_FLTDIV, /* 6E - DNML | DZ | OFL | IMP | STK */
- FPE_FLTSUB, /* 6F - INV | DNML | DZ | OFL | IMP | STK */
- FPE_FLTUND, /* 70 - UFL | IMP | STK */
- FPE_FLTSUB, /* 71 - INV | UFL | IMP | STK */
- FPE_FLTUND, /* 72 - DNML | UFL | IMP | STK */
- FPE_FLTSUB, /* 73 - INV | DNML | UFL | IMP | STK */
- FPE_FLTDIV, /* 74 - DZ | UFL | IMP | STK */
- FPE_FLTSUB, /* 75 - INV | DZ | UFL | IMP | STK */
- FPE_FLTDIV, /* 76 - DNML | DZ | UFL | IMP | STK */
- FPE_FLTSUB, /* 77 - INV | DNML | DZ | UFL | IMP | STK */
- FPE_FLTOVF, /* 78 - OFL | UFL | IMP | STK */
- FPE_FLTSUB, /* 79 - INV | OFL | UFL | IMP | STK */
- FPE_FLTUND, /* 7A - DNML | OFL | UFL | IMP | STK */
- FPE_FLTSUB, /* 7B - INV | DNML | OFL | UFL | IMP | STK */
- FPE_FLTDIV, /* 7C - DZ | OFL | UFL | IMP | STK */
- FPE_FLTSUB, /* 7D - INV | DZ | OFL | UFL | IMP | STK */
- FPE_FLTDIV, /* 7E - DNML | DZ | OFL | UFL | IMP | STK */
- FPE_FLTSUB, /* 7F - INV | DNML | DZ | OFL | UFL | IMP | STK */
-};
-
-/*
- * Preserve the FP status word, clear FP exceptions, then generate a SIGFPE.
- *
- * Clearing exceptions is necessary mainly to avoid IRQ13 bugs. We now
- * depend on longjmp() restoring a usable state. Restoring the state
- * or examining it might fail if we didn't clear exceptions.
- *
- * The error code chosen will be one of the FPE_... macros. It will be
- * sent as the second argument to old BSD-style signal handlers and as
- * "siginfo_t->si_code" (second argument) to SA_SIGINFO signal handlers.
- *
- * XXX the FP state is not preserved across signal handlers. So signal
- * handlers cannot afford to do FP unless they preserve the state or
- * longjmp() out. Both preserving the state and longjmp()ing may be
- * destroyed by IRQ13 bugs. Clearing FP exceptions is not an acceptable
- * solution for signals other than SIGFPE.
- */
-void
-npx_intr(dummy)
- void *dummy;
-{
- int code;
- u_short control;
- struct intrframe *frame;
-
- if (npxproc == NULL || !npx_exists) {
- printf("npxintr: npxproc = %p, curproc = %p, npx_exists = %d\n",
- npxproc, curproc, npx_exists);
- panic("npxintr from nowhere");
- }
- if (npxproc != curproc) {
- printf("npxintr: npxproc = %p, curproc = %p, npx_exists = %d\n",
- npxproc, curproc, npx_exists);
- panic("npxintr from non-current process");
- }
-
- outb(0xf0, 0);
- fnstsw(&curpcb->pcb_savefpu.sv_ex_sw);
- fnstcw(&control);
- fnclex();
-
- /*
- * Pass exception to process.
- */
- frame = (struct intrframe *)&dummy; /* XXX */
- if ((ISPL(frame->if_cs) == SEL_UPL) || (frame->if_eflags & PSL_VM)) {
- /*
- * Interrupt is essentially a trap, so we can afford to call
- * the SIGFPE handler (if any) as soon as the interrupt
- * returns.
- *
- * XXX little or nothing is gained from this, and plenty is
- * lost - the interrupt frame has to contain the trap frame
- * (this is otherwise only necessary for the rescheduling trap
- * in doreti, and the frame for that could easily be set up
- * just before it is used).
- */
- curproc->p_md.md_regs = INTR_TO_TRAPFRAME(frame);
- /*
- * Encode the appropriate code for detailed information on
- * this exception.
- */
- code =
- fpetable[(curpcb->pcb_savefpu.sv_ex_sw & ~control & 0x3f) |
- (curpcb->pcb_savefpu.sv_ex_sw & 0x40)];
- trapsignal(curproc, SIGFPE, code);
- } else {
- /*
- * Nested interrupt. These losers occur when:
- * o an IRQ13 is bogusly generated at a bogus time, e.g.:
- * o immediately after an fnsave or frstor of an
- * error state.
- * o a couple of 386 instructions after
- * "fstpl _memvar" causes a stack overflow.
- * These are especially nasty when combined with a
- * trace trap.
- * o an IRQ13 occurs at the same time as another higher-
- * priority interrupt.
- *
- * Treat them like a true async interrupt.
- */
- psignal(curproc, SIGFPE);
- }
-}
-
-/*
- * Implement device not available (DNA) exception
- *
- * It would be better to switch FP context here (if curproc != npxproc)
- * and not necessarily for every context switch, but it is too hard to
- * access foreign pcb's.
- */
-int
-npxdna()
-{
- if (!npx_exists)
- return (0);
- if (npxproc != NULL) {
- printf("npxdna: npxproc = %p, curproc = %p\n",
- npxproc, curproc);
- panic("npxdna");
- }
- stop_emulating();
- /*
- * Record new context early in case frstor causes an IRQ13.
- */
- npxproc = curproc;
- curpcb->pcb_savefpu.sv_ex_sw = 0;
- /*
- * The following frstor may cause an IRQ13 when the state being
- * restored has a pending error. The error will appear to have been
- * triggered by the current (npx) user instruction even when that
- * instruction is a no-wait instruction that should not trigger an
- * error (e.g., fnclex). On at least one 486 system all of the
- * no-wait instructions are broken the same as frstor, so our
- * treatment does not amplify the breakage. On at least one
- * 386/Cyrix 387 system, fnclex works correctly while frstor and
- * fnsave are broken, so our treatment breaks fnclex if it is the
- * first FPU instruction after a context switch.
- */
- frstor(&curpcb->pcb_savefpu);
-
- return (1);
-}
-
-/*
- * Wrapper for fnsave instruction to handle h/w bugs. If there is an error
- * pending, then fnsave generates a bogus IRQ13 on some systems. Force
- * any IRQ13 to be handled immediately, and then ignore it. This routine is
- * often called at splhigh so it must not use many system services. In
- * particular, it's much easier to install a special handler than to
- * guarantee that it's safe to use npxintr() and its supporting code.
- */
-void
-npxsave(addr)
- struct save87 *addr;
-{
-#ifdef SMP
-
- stop_emulating();
- fnsave(addr);
- /* fnop(); */
- start_emulating();
- npxproc = NULL;
-
-#else /* SMP */
-
- u_char icu1_mask;
- u_char icu2_mask;
- u_char old_icu1_mask;
- u_char old_icu2_mask;
- struct gate_descriptor save_idt_npxintr;
-
- disable_intr();
- old_icu1_mask = inb(IO_ICU1 + 1);
- old_icu2_mask = inb(IO_ICU2 + 1);
- save_idt_npxintr = idt[npx_intrno];
- outb(IO_ICU1 + 1, old_icu1_mask & ~(IRQ_SLAVE | npx0_imask));
- outb(IO_ICU2 + 1, old_icu2_mask & ~(npx0_imask >> 8));
- idt[npx_intrno] = npx_idt_probeintr;
- enable_intr();
- stop_emulating();
- fnsave(addr);
- fnop();
- start_emulating();
- npxproc = NULL;
- disable_intr();
- icu1_mask = inb(IO_ICU1 + 1); /* masks may have changed */
- icu2_mask = inb(IO_ICU2 + 1);
- outb(IO_ICU1 + 1,
- (icu1_mask & ~npx0_imask) | (old_icu1_mask & npx0_imask));
- outb(IO_ICU2 + 1,
- (icu2_mask & ~(npx0_imask >> 8))
- | (old_icu2_mask & (npx0_imask >> 8)));
- idt[npx_intrno] = save_idt_npxintr;
- enable_intr(); /* back to usual state */
-
-#endif /* SMP */
-}
-
-#ifdef I586_CPU
-static long
-timezero(funcname, func)
- const char *funcname;
- void (*func) __P((void *buf, size_t len));
-
-{
- void *buf;
-#define BUFSIZE 1000000
- long usec;
- struct timeval finish, start;
-
- buf = malloc(BUFSIZE, M_TEMP, M_NOWAIT);
- if (buf == NULL)
- return (BUFSIZE);
- microtime(&start);
- (*func)(buf, BUFSIZE);
- microtime(&finish);
- usec = 1000000 * (finish.tv_sec - start.tv_sec) +
- finish.tv_usec - start.tv_usec;
- if (usec <= 0)
- usec = 1;
- if (bootverbose)
- printf("%s bandwidth = %ld bytes/sec\n",
- funcname, (long)(BUFSIZE * (int64_t)1000000 / usec));
- free(buf, M_TEMP);
- return (usec);
-}
-#endif /* I586_CPU */
-
-static device_method_t npx_methods[] = {
- /* Device interface */
- DEVMETHOD(device_identify, npx_identify),
- DEVMETHOD(device_probe, npx_probe),
- DEVMETHOD(device_attach, npx_attach),
- DEVMETHOD(device_detach, bus_generic_detach),
- DEVMETHOD(device_shutdown, bus_generic_shutdown),
- DEVMETHOD(device_suspend, bus_generic_suspend),
- DEVMETHOD(device_resume, bus_generic_resume),
-
- { 0, 0 }
-};
-
-static driver_t npx_driver = {
- "npx",
- npx_methods,
- 1, /* no softc */
-};
-
-static devclass_t npx_devclass;
-
-/*
- * We prefer to attach to the root nexus so that the usual case (exception 16)
- * doesn't describe the processor as being `on isa'.
- */
-DRIVER_MODULE(npx, nexus, npx_driver, npx_devclass, 0, 0);
diff --git a/sys/amd64/isa/timerreg.h b/sys/amd64/isa/timerreg.h
deleted file mode 100644
index 0bfd7fc8cd63..000000000000
--- a/sys/amd64/isa/timerreg.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/*-
- * Copyright (c) 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. 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, Berkeley and its contributors.
- * 4. 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: Header: timerreg.h,v 1.2 93/02/28 15:08:58 mccanne Exp
- * $FreeBSD$
- */
-
-/*
- *
- * Register definitions for the Intel 8253 Programmable Interval Timer.
- *
- * This chip has three independent 16-bit down counters that can be
- * read on the fly. There are three mode registers and three countdown
- * registers. The countdown registers are addressed directly, via the
- * first three I/O ports. The three mode registers are accessed via
- * the fourth I/O port, with two bits in the mode byte indicating the
- * register. (Why are hardware interfaces always so braindead?).
- *
- * To write a value into the countdown register, the mode register
- * is first programmed with a command indicating the which byte of
- * the two byte register is to be modified. The three possibilities
- * are load msb (TMR_MR_MSB), load lsb (TMR_MR_LSB), or load lsb then
- * msb (TMR_MR_BOTH).
- *
- * To read the current value ("on the fly") from the countdown register,
- * you write a "latch" command into the mode register, then read the stable
- * value from the corresponding I/O port. For example, you write
- * TMR_MR_LATCH into the corresponding mode register. Presumably,
- * after doing this, a write operation to the I/O port would result
- * in undefined behavior (but hopefully not fry the chip).
- * Reading in this manner has no side effects.
- *
- * [IBM-PC]
- * The outputs of the three timers are connected as follows:
- *
- * timer 0 -> irq 0
- * timer 1 -> dma chan 0 (for dram refresh)
- * timer 2 -> speaker (via keyboard controller)
- *
- * Timer 0 is used to call hardclock.
- * Timer 2 is used to generate console beeps.
- *
- * [PC-9801]
- * The outputs of the three timers are connected as follows:
- *
- * timer 0 -> irq 0
- * timer 1 -> speaker (via keyboard controller)
- * timer 2 -> RS232C
- *
- * Timer 0 is used to call hardclock.
- * Timer 1 is used to generate console beeps.
- */
-
-/*
- * Macros for specifying values to be written into a mode register.
- */
-#define TIMER_CNTR0 (IO_TIMER1 + 0) /* timer 0 counter port */
-#ifdef PC98
-#define TIMER_CNTR1 0x3fdb /* timer 1 counter port */
-#define TIMER_CNTR2 (IO_TIMER1 + 4) /* timer 2 counter port */
-#define TIMER_MODE (IO_TIMER1 + 6) /* timer mode port */
-#else
-#define TIMER_CNTR1 (IO_TIMER1 + 1) /* timer 1 counter port */
-#define TIMER_CNTR2 (IO_TIMER1 + 2) /* timer 2 counter port */
-#define TIMER_MODE (IO_TIMER1 + 3) /* timer mode port */
-#endif
-#define TIMER_SEL0 0x00 /* select counter 0 */
-#define TIMER_SEL1 0x40 /* select counter 1 */
-#define TIMER_SEL2 0x80 /* select counter 2 */
-#define TIMER_INTTC 0x00 /* mode 0, intr on terminal cnt */
-#define TIMER_ONESHOT 0x02 /* mode 1, one shot */
-#define TIMER_RATEGEN 0x04 /* mode 2, rate generator */
-#define TIMER_SQWAVE 0x06 /* mode 3, square wave */
-#define TIMER_SWSTROBE 0x08 /* mode 4, s/w triggered strobe */
-#define TIMER_HWSTROBE 0x0a /* mode 5, h/w triggered strobe */
-#define TIMER_LATCH 0x00 /* latch counter for reading */
-#define TIMER_LSB 0x10 /* r/w counter LSB */
-#define TIMER_MSB 0x20 /* r/w counter MSB */
-#define TIMER_16BIT 0x30 /* r/w counter 16 bits, LSB first */
-#define TIMER_BCD 0x01 /* count in BCD */
-
diff --git a/sys/amd64/isa/vector.S b/sys/amd64/isa/vector.S
deleted file mode 100644
index 5447a90126a0..000000000000
--- a/sys/amd64/isa/vector.S
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * from: vector.s, 386BSD 0.1 unknown origin
- * $FreeBSD$
- */
-
-/*
- * modified for PC98 by Kakefuda
- */
-
-#include "opt_auto_eoi.h"
-
-#include <i386/isa/icu.h>
-#ifdef PC98
-#include <pc98/pc98/pc98.h>
-#else
-#include <i386/isa/isa.h>
-#endif
-
-#ifdef FAST_INTR_HANDLER_USES_ES
-#define ACTUALLY_PUSHED 1
-#define MAYBE_MOVW_AX_ES movl %ax,%es
-#define MAYBE_POPL_ES popl %es
-#define MAYBE_PUSHL_ES pushl %es
-#else
-/*
- * We can usually skip loading %es for fastintr handlers. %es should
- * only be used for string instructions, and fastintr handlers shouldn't
- * do anything slow enough to justify using a string instruction.
- */
-#define ACTUALLY_PUSHED 0
-#define MAYBE_MOVW_AX_ES
-#define MAYBE_POPL_ES
-#define MAYBE_PUSHL_ES
-#endif
-
- .data
- ALIGN_DATA
-
- .globl _intr_nesting_level
-_intr_nesting_level:
- .byte 0
- .space 3
-
-/*
- * Interrupt counters and names for export to vmstat(8) and friends.
- *
- * XXX this doesn't really belong here; everything except the labels
- * for the endpointers is almost machine-independent.
- */
-#define NR_INTRNAMES (1 + ICU_LEN + 2 * ICU_LEN)
-
- .globl _intrcnt, _eintrcnt
-_intrcnt:
- .space NR_INTRNAMES * 4
-_eintrcnt:
-
- .globl _intrnames, _eintrnames
-_intrnames:
- .space NR_INTRNAMES * 16
-_eintrnames:
-
- .text
-
-/*
- * Macros for interrupt interrupt entry, call to handler, and exit.
- *
- * XXX - the interrupt frame is set up to look like a trap frame. This is
- * usually a waste of time. The only interrupt handlers that want a frame
- * are the clock handler (it wants a clock frame), the npx handler (it's
- * easier to do right all in assembler). The interrupt return routine
- * needs a trap frame for rare AST's (it could easily convert the frame).
- * The direct costs of setting up a trap frame are two pushl's (error
- * code and trap number), an addl to get rid of these, and pushing and
- * popping the call-saved regs %esi, %edi and %ebp twice, The indirect
- * costs are making the driver interface nonuniform so unpending of
- * interrupts is more complicated and slower (call_driver(unit) would
- * be easier than ensuring an interrupt frame for all handlers. Finally,
- * there are some struct copies in the npx handler and maybe in the clock
- * handler that could be avoided by working more with pointers to frames
- * instead of frames.
- *
- * XXX - should we do a cld on every system entry to avoid the requirement
- * for scattered cld's?
- *
- * Coding notes for *.s:
- *
- * If possible, avoid operations that involve an operand size override.
- * Word-sized operations might be smaller, but the operand size override
- * makes them slower on on 486's and no faster on 386's unless perhaps
- * the instruction pipeline is depleted. E.g.,
- *
- * Use movl to seg regs instead of the equivalent but more descriptive
- * movw - gas generates an irelevant (slower) operand size override.
- *
- * Use movl to ordinary regs in preference to movw and especially
- * in preference to movz[bw]l. Use unsigned (long) variables with the
- * top bits clear instead of unsigned short variables to provide more
- * opportunities for movl.
- *
- * If possible, use byte-sized operations. They are smaller and no slower.
- *
- * Use (%reg) instead of 0(%reg) - gas generates larger code for the latter.
- *
- * If the interrupt frame is made more flexible, INTR can push %eax first
- * and decide the ipending case with less overhead, e.g., by avoiding
- * loading segregs.
- */
-
-#ifdef APIC_IO
-#include "i386/isa/apic_vector.s"
-#else
-#include "i386/isa/icu_vector.s"
-#endif /* APIC_IO */
diff --git a/sys/amd64/isa/vector.s b/sys/amd64/isa/vector.s
deleted file mode 100644
index 5447a90126a0..000000000000
--- a/sys/amd64/isa/vector.s
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * from: vector.s, 386BSD 0.1 unknown origin
- * $FreeBSD$
- */
-
-/*
- * modified for PC98 by Kakefuda
- */
-
-#include "opt_auto_eoi.h"
-
-#include <i386/isa/icu.h>
-#ifdef PC98
-#include <pc98/pc98/pc98.h>
-#else
-#include <i386/isa/isa.h>
-#endif
-
-#ifdef FAST_INTR_HANDLER_USES_ES
-#define ACTUALLY_PUSHED 1
-#define MAYBE_MOVW_AX_ES movl %ax,%es
-#define MAYBE_POPL_ES popl %es
-#define MAYBE_PUSHL_ES pushl %es
-#else
-/*
- * We can usually skip loading %es for fastintr handlers. %es should
- * only be used for string instructions, and fastintr handlers shouldn't
- * do anything slow enough to justify using a string instruction.
- */
-#define ACTUALLY_PUSHED 0
-#define MAYBE_MOVW_AX_ES
-#define MAYBE_POPL_ES
-#define MAYBE_PUSHL_ES
-#endif
-
- .data
- ALIGN_DATA
-
- .globl _intr_nesting_level
-_intr_nesting_level:
- .byte 0
- .space 3
-
-/*
- * Interrupt counters and names for export to vmstat(8) and friends.
- *
- * XXX this doesn't really belong here; everything except the labels
- * for the endpointers is almost machine-independent.
- */
-#define NR_INTRNAMES (1 + ICU_LEN + 2 * ICU_LEN)
-
- .globl _intrcnt, _eintrcnt
-_intrcnt:
- .space NR_INTRNAMES * 4
-_eintrcnt:
-
- .globl _intrnames, _eintrnames
-_intrnames:
- .space NR_INTRNAMES * 16
-_eintrnames:
-
- .text
-
-/*
- * Macros for interrupt interrupt entry, call to handler, and exit.
- *
- * XXX - the interrupt frame is set up to look like a trap frame. This is
- * usually a waste of time. The only interrupt handlers that want a frame
- * are the clock handler (it wants a clock frame), the npx handler (it's
- * easier to do right all in assembler). The interrupt return routine
- * needs a trap frame for rare AST's (it could easily convert the frame).
- * The direct costs of setting up a trap frame are two pushl's (error
- * code and trap number), an addl to get rid of these, and pushing and
- * popping the call-saved regs %esi, %edi and %ebp twice, The indirect
- * costs are making the driver interface nonuniform so unpending of
- * interrupts is more complicated and slower (call_driver(unit) would
- * be easier than ensuring an interrupt frame for all handlers. Finally,
- * there are some struct copies in the npx handler and maybe in the clock
- * handler that could be avoided by working more with pointers to frames
- * instead of frames.
- *
- * XXX - should we do a cld on every system entry to avoid the requirement
- * for scattered cld's?
- *
- * Coding notes for *.s:
- *
- * If possible, avoid operations that involve an operand size override.
- * Word-sized operations might be smaller, but the operand size override
- * makes them slower on on 486's and no faster on 386's unless perhaps
- * the instruction pipeline is depleted. E.g.,
- *
- * Use movl to seg regs instead of the equivalent but more descriptive
- * movw - gas generates an irelevant (slower) operand size override.
- *
- * Use movl to ordinary regs in preference to movw and especially
- * in preference to movz[bw]l. Use unsigned (long) variables with the
- * top bits clear instead of unsigned short variables to provide more
- * opportunities for movl.
- *
- * If possible, use byte-sized operations. They are smaller and no slower.
- *
- * Use (%reg) instead of 0(%reg) - gas generates larger code for the latter.
- *
- * If the interrupt frame is made more flexible, INTR can push %eax first
- * and decide the ipending case with less overhead, e.g., by avoiding
- * loading segregs.
- */
-
-#ifdef APIC_IO
-#include "i386/isa/apic_vector.s"
-#else
-#include "i386/isa/icu_vector.s"
-#endif /* APIC_IO */
diff --git a/sys/amd64/pci/pci_bus.c b/sys/amd64/pci/pci_bus.c
deleted file mode 100644
index f09c907a4346..000000000000
--- a/sys/amd64/pci/pci_bus.c
+++ /dev/null
@@ -1,544 +0,0 @@
-/*
- * Copyright (c) 1997, Stefan Esser <se@freebsd.org>
- * 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 unmodified, 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.
- *
- * $FreeBSD$
- *
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/kernel.h>
-
-#include <pci/pcivar.h>
-#include <pci/pcireg.h>
-#include <i386/isa/pcibus.h>
-
-static int cfgmech;
-static int devmax;
-
-/* enable configuration space accesses and return data port address */
-
-static int
-pci_cfgenable(unsigned bus, unsigned slot, unsigned func, int reg, int bytes)
-{
- int dataport = 0;
-
- if (bus <= PCI_BUSMAX
- && slot < devmax
- && func <= PCI_FUNCMAX
- && reg <= PCI_REGMAX
- && bytes != 3
- && (unsigned) bytes <= 4
- && (reg & (bytes -1)) == 0) {
- switch (cfgmech) {
- case 1:
- outl(CONF1_ADDR_PORT, (1 << 31)
- | (bus << 16) | (slot << 11)
- | (func << 8) | (reg & ~0x03));
- dataport = CONF1_DATA_PORT + (reg & 0x03);
- break;
- case 2:
- outb(CONF2_ENABLE_PORT, 0xf0 | (func << 1));
- outb(CONF2_FORWARD_PORT, bus);
- dataport = 0xc000 | (slot << 8) | reg;
- break;
- }
- }
- return (dataport);
-}
-
-/* disable configuration space accesses */
-
-static void
-pci_cfgdisable(void)
-{
- switch (cfgmech) {
- case 1:
- outl(CONF1_ADDR_PORT, 0);
- break;
- case 2:
- outb(CONF2_ENABLE_PORT, 0);
- outb(CONF2_FORWARD_PORT, 0);
- break;
- }
-}
-
-/* read configuration space register */
-
-int
-pci_cfgread(pcicfgregs *cfg, int reg, int bytes)
-{
- int data = -1;
- int port;
-
- port = pci_cfgenable(cfg->bus, cfg->slot, cfg->func, reg, bytes);
-
- if (port != 0) {
- switch (bytes) {
- case 1:
- data = inb(port);
- break;
- case 2:
- data = inw(port);
- break;
- case 4:
- data = inl(port);
- break;
- }
- pci_cfgdisable();
- }
- return (data);
-}
-
-/* write configuration space register */
-
-void
-pci_cfgwrite(pcicfgregs *cfg, int reg, int data, int bytes)
-{
- int port;
-
- port = pci_cfgenable(cfg->bus, cfg->slot, cfg->func, reg, bytes);
- if (port != 0) {
- switch (bytes) {
- case 1:
- outb(port, data);
- break;
- case 2:
- outw(port, data);
- break;
- case 4:
- outl(port, data);
- break;
- }
- pci_cfgdisable();
- }
-}
-
-/* check whether the configuration mechanism has been correct identified */
-
-static int
-pci_cfgcheck(int maxdev)
-{
- u_char device;
-
- if (bootverbose)
- printf("pci_cfgcheck:\tdevice ");
-
- for (device = 0; device < maxdev; device++) {
- unsigned id, class, header;
- if (bootverbose)
- printf("%d ", device);
-
- id = inl(pci_cfgenable(0, device, 0, 0, 4));
- if (id == 0 || id == -1)
- continue;
-
- class = inl(pci_cfgenable(0, device, 0, 8, 4)) >> 8;
- if (bootverbose)
- printf("[class=%06x] ", class);
- if (class == 0 || (class & 0xf870ff) != 0)
- continue;
-
- header = inb(pci_cfgenable(0, device, 0, 14, 1));
- if (bootverbose)
- printf("[hdr=%02x] ", header);
- if ((header & 0x7e) != 0)
- continue;
-
- if (bootverbose)
- printf("is there (id=%08x)\n", id);
-
- pci_cfgdisable();
- return (1);
- }
- if (bootverbose)
- printf("-- nothing found\n");
-
- pci_cfgdisable();
- return (0);
-}
-
-static int
-pci_cfgopen(void)
-{
- unsigned long mode1res,oldval1;
- unsigned char mode2res,oldval2;
-
- oldval1 = inl(CONF1_ADDR_PORT);
-
- if (bootverbose) {
- printf("pci_open(1):\tmode 1 addr port (0x0cf8) is 0x%08lx\n",
- oldval1);
- }
-
- if ((oldval1 & CONF1_ENABLE_MSK) == 0) {
-
- cfgmech = 1;
- devmax = 32;
-
- outl(CONF1_ADDR_PORT, CONF1_ENABLE_CHK);
- outb(CONF1_ADDR_PORT +3, 0);
- mode1res = inl(CONF1_ADDR_PORT);
- outl(CONF1_ADDR_PORT, oldval1);
-
- if (bootverbose)
- printf("pci_open(1a):\tmode1res=0x%08lx (0x%08lx)\n",
- mode1res, CONF1_ENABLE_CHK);
-
- if (mode1res) {
- if (pci_cfgcheck(32))
- return (cfgmech);
- }
-
- outl(CONF1_ADDR_PORT, CONF1_ENABLE_CHK1);
- mode1res = inl(CONF1_ADDR_PORT);
- outl(CONF1_ADDR_PORT, oldval1);
-
- if (bootverbose)
- printf("pci_open(1b):\tmode1res=0x%08lx (0x%08lx)\n",
- mode1res, CONF1_ENABLE_CHK1);
-
- if ((mode1res & CONF1_ENABLE_MSK1) == CONF1_ENABLE_RES1) {
- if (pci_cfgcheck(32))
- return (cfgmech);
- }
- }
-
- oldval2 = inb(CONF2_ENABLE_PORT);
-
- if (bootverbose) {
- printf("pci_open(2):\tmode 2 enable port (0x0cf8) is 0x%02x\n",
- oldval2);
- }
-
- if ((oldval2 & 0xf0) == 0) {
-
- cfgmech = 2;
- devmax = 16;
-
- outb(CONF2_ENABLE_PORT, CONF2_ENABLE_CHK);
- mode2res = inb(CONF2_ENABLE_PORT);
- outb(CONF2_ENABLE_PORT, oldval2);
-
- if (bootverbose)
- printf("pci_open(2a):\tmode2res=0x%02x (0x%02x)\n",
- mode2res, CONF2_ENABLE_CHK);
-
- if (mode2res == CONF2_ENABLE_RES) {
- if (bootverbose)
- printf("pci_open(2a):\tnow trying mechanism 2\n");
-
- if (pci_cfgcheck(16))
- return (cfgmech);
- }
- }
-
- cfgmech = 0;
- devmax = 0;
- return (cfgmech);
-}
-
-static devclass_t pcib_devclass;
-
-static const char *
-nexus_pcib_is_host_bridge(pcicfgregs *cfg,
- u_int32_t id, u_int8_t class, u_int8_t subclass,
- u_int8_t *busnum)
-{
- const char *s = NULL;
- static u_int8_t pxb[4]; /* hack for 450nx */
-
- *busnum = 0;
-
- switch (id) {
- case 0x12258086:
- s = "Intel 824?? host to PCI bridge";
- /* XXX This is a guess */
- /* *busnum = pci_cfgread(cfg, 0x41, 1); */
- *busnum = cfg->bus;
- break;
- case 0x71208086:
- s = "Intel 82810 (i810 GMCH) Host To Hub bridge";
- break;
- case 0x71228086:
- s = "Intel 82810-DC100 (i810-DC100 GMCH) Host To Hub bridge";
- break;
- case 0x71248086:
- s = "Intel 82810E (i810E GMCH) Host To Hub bridge";
- break;
- case 0x71808086:
- s = "Intel 82443LX (440 LX) host to PCI bridge";
- break;
- case 0x71908086:
- s = "Intel 82443BX (440 BX) host to PCI bridge";
- break;
- case 0x71928086:
- s = "Intel 82443BX host to PCI bridge (AGP disabled)";
- break;
- case 0x71a08086:
- s = "Intel 82443GX host to PCI bridge";
- break;
- case 0x71a18086:
- s = "Intel 82443GX host to AGP bridge";
- break;
- case 0x71a28086:
- s = "Intel 82443GX host to PCI bridge (AGP disabled)";
- break;
- case 0x84c48086:
- s = "Intel 82454KX/GX (Orion) host to PCI bridge";
- *busnum = pci_cfgread(cfg, 0x4a, 1);
- break;
- case 0x84ca8086:
- /*
- * For the 450nx chipset, there is a whole bundle of
- * things pretending to be host bridges. The MIOC will
- * be seen first and isn't really a pci bridge (the
- * actual busses are attached to the PXB's). We need to
- * read the registers of the MIOC to figure out the
- * bus numbers for the PXB channels.
- *
- * Since the MIOC doesn't have a pci bus attached, we
- * pretend it wasn't there.
- */
- pxb[0] = pci_cfgread(cfg, 0xd0, 1); /* BUSNO[0] */
- pxb[1] = pci_cfgread(cfg, 0xd1, 1) + 1; /* SUBA[0]+1 */
- pxb[2] = pci_cfgread(cfg, 0xd3, 1); /* BUSNO[1] */
- pxb[3] = pci_cfgread(cfg, 0xd4, 1) + 1; /* SUBA[1]+1 */
- return NULL;
- case 0x84cb8086:
- switch (cfg->slot) {
- case 0x12:
- s = "Intel 82454NX PXB#0, Bus#A";
- *busnum = pxb[0];
- break;
- case 0x13:
- s = "Intel 82454NX PXB#0, Bus#B";
- *busnum = pxb[1];
- break;
- case 0x14:
- s = "Intel 82454NX PXB#1, Bus#A";
- *busnum = pxb[2];
- break;
- case 0x15:
- s = "Intel 82454NX PXB#1, Bus#B";
- *busnum = pxb[3];
- break;
- }
- break;
-
- /* AMD -- vendor 0x1022 */
- case 0x70061022:
- s = "AMD-751 host to PCI bridge";
- break;
-
- /* SiS -- vendor 0x1039 */
- case 0x04961039:
- s = "SiS 85c496";
- break;
- case 0x04061039:
- s = "SiS 85c501";
- break;
- case 0x06011039:
- s = "SiS 85c601";
- break;
- case 0x55911039:
- s = "SiS 5591 host to PCI bridge";
- break;
- case 0x00011039:
- s = "SiS 5591 host to AGP bridge";
- break;
-
- /* VLSI -- vendor 0x1004 */
- case 0x00051004:
- s = "VLSI 82C592 Host to PCI bridge";
- break;
-
- /* XXX Here is MVP3, I got the datasheet but NO M/B to test it */
- /* totally. Please let me know if anything wrong. -F */
- /* XXX need info on the MVP3 -- any takers? */
- case 0x05981106:
- s = "VIA 82C598MVP (Apollo MVP3) host bridge";
- break;
-
- /* AcerLabs -- vendor 0x10b9 */
- /* Funny : The datasheet told me vendor id is "10b8",sub-vendor */
- /* id is '10b9" but the register always shows "10b9". -Foxfair */
- case 0x154110b9:
- s = "AcerLabs M1541 (Aladdin-V) PCI host bridge";
- break;
-
- /* OPTi -- vendor 0x1045 */
- case 0xc8221045:
- s = "OPTi 82C822 host to PCI Bridge";
- break;
-
- /* RCC -- vendor 0x1166 */
- case 0x00051166:
- s = "RCC HE host to PCI bridge";
- *busnum = pci_cfgread(cfg, 0x44, 1);
- break;
-
- case 0x00061166:
- /* FALLTHROUGH */
- case 0x00081166:
- s = "RCC host to PCI bridge";
- *busnum = pci_cfgread(cfg, 0x44, 1);
- break;
-
- case 0x00091166:
- s = "RCC LE host to PCI bridge";
- *busnum = pci_cfgread(cfg, 0x44, 1);
- break;
-
- /* Integrated Micro Solutions -- vendor 0x10e0 */
- case 0x884910e0:
- s = "Integrated Micro Solutions VL Bridge";
- break;
-
- default:
- if (class == PCIC_BRIDGE && subclass == PCIS_BRIDGE_HOST)
- s = "Host to PCI bridge";
- break;
- }
-
- return s;
-}
-
-/*
- * Scan the first pci bus for host-pci bridges and add pcib instances
- * to the nexus for each bridge.
- */
-static void
-nexus_pcib_identify(driver_t *driver, device_t parent)
-{
- pcicfgregs probe;
- u_int8_t hdrtype;
- int found = 0;
- int pcifunchigh;
- int found824xx = 0;
-
- if (pci_cfgopen() == 0)
- return;
- probe.hose = 0;
- probe.bus = 0;
- retry:
- for (probe.slot = 0; probe.slot <= PCI_SLOTMAX; probe.slot++) {
- probe.func = 0;
- hdrtype = pci_cfgread(&probe, PCIR_HEADERTYPE, 1);
- if (hdrtype & PCIM_MFDEV)
- pcifunchigh = 7;
- else
- pcifunchigh = 0;
- for (probe.func = 0;
- probe.func <= pcifunchigh;
- probe.func++) {
- /*
- * Read the IDs and class from the device.
- */
- u_int32_t id;
- u_int8_t class, subclass, busnum;
- device_t child;
- const char *s;
-
- id = pci_cfgread(&probe, PCIR_DEVVENDOR, 4);
- if (id == -1)
- continue;
- class = pci_cfgread(&probe, PCIR_CLASS, 1);
- subclass = pci_cfgread(&probe, PCIR_SUBCLASS, 1);
-
- s = nexus_pcib_is_host_bridge(&probe, id,
- class, subclass,
- &busnum);
- if (s) {
- /*
- * Add at priority 100 to make sure we
- * go after any motherboard resources
- */
- child = BUS_ADD_CHILD(parent, 100,
- "pcib", busnum);
- device_set_desc(child, s);
- found = 1;
- if (id == 0x12258086)
- found824xx = 1;
- }
- }
- }
- if (found824xx && probe.bus == 0) {
- probe.bus++;
- goto retry;
- }
-
- /*
- * Make sure we add at least one bridge since some old
- * hardware doesn't actually have a host-pci bridge device.
- * Note that pci_cfgopen() thinks we have PCI devices..
- */
- if (!found) {
- if (bootverbose)
- printf(
- "nexus_pcib_identify: no bridge found, adding pcib0 anyway\n");
- BUS_ADD_CHILD(parent, 100, "pcib", 0);
- }
-}
-
-static int
-nexus_pcib_probe(device_t dev)
-{
- if (pci_cfgopen() != 0) {
- device_add_child(dev, "pci", device_get_unit(dev));
- return 0;
- }
- return ENXIO;
-}
-
-static device_method_t nexus_pcib_methods[] = {
- /* Device interface */
- DEVMETHOD(device_identify, nexus_pcib_identify),
- DEVMETHOD(device_probe, nexus_pcib_probe),
- DEVMETHOD(device_attach, bus_generic_attach),
- DEVMETHOD(device_shutdown, bus_generic_shutdown),
- DEVMETHOD(device_suspend, bus_generic_suspend),
- DEVMETHOD(device_resume, bus_generic_resume),
-
- /* Bus interface */
- DEVMETHOD(bus_print_child, bus_generic_print_child),
- DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
- DEVMETHOD(bus_release_resource, bus_generic_release_resource),
- DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
- DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
- DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
- DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
-
- { 0, 0 }
-};
-
-static driver_t nexus_pcib_driver = {
- "pcib",
- nexus_pcib_methods,
- 1,
-};
-
-DRIVER_MODULE(pcib, nexus, nexus_pcib_driver, pcib_devclass, 0, 0);
diff --git a/sys/amd64/pci/pci_cfgreg.c b/sys/amd64/pci/pci_cfgreg.c
deleted file mode 100644
index f09c907a4346..000000000000
--- a/sys/amd64/pci/pci_cfgreg.c
+++ /dev/null
@@ -1,544 +0,0 @@
-/*
- * Copyright (c) 1997, Stefan Esser <se@freebsd.org>
- * 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 unmodified, 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.
- *
- * $FreeBSD$
- *
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/kernel.h>
-
-#include <pci/pcivar.h>
-#include <pci/pcireg.h>
-#include <i386/isa/pcibus.h>
-
-static int cfgmech;
-static int devmax;
-
-/* enable configuration space accesses and return data port address */
-
-static int
-pci_cfgenable(unsigned bus, unsigned slot, unsigned func, int reg, int bytes)
-{
- int dataport = 0;
-
- if (bus <= PCI_BUSMAX
- && slot < devmax
- && func <= PCI_FUNCMAX
- && reg <= PCI_REGMAX
- && bytes != 3
- && (unsigned) bytes <= 4
- && (reg & (bytes -1)) == 0) {
- switch (cfgmech) {
- case 1:
- outl(CONF1_ADDR_PORT, (1 << 31)
- | (bus << 16) | (slot << 11)
- | (func << 8) | (reg & ~0x03));
- dataport = CONF1_DATA_PORT + (reg & 0x03);
- break;
- case 2:
- outb(CONF2_ENABLE_PORT, 0xf0 | (func << 1));
- outb(CONF2_FORWARD_PORT, bus);
- dataport = 0xc000 | (slot << 8) | reg;
- break;
- }
- }
- return (dataport);
-}
-
-/* disable configuration space accesses */
-
-static void
-pci_cfgdisable(void)
-{
- switch (cfgmech) {
- case 1:
- outl(CONF1_ADDR_PORT, 0);
- break;
- case 2:
- outb(CONF2_ENABLE_PORT, 0);
- outb(CONF2_FORWARD_PORT, 0);
- break;
- }
-}
-
-/* read configuration space register */
-
-int
-pci_cfgread(pcicfgregs *cfg, int reg, int bytes)
-{
- int data = -1;
- int port;
-
- port = pci_cfgenable(cfg->bus, cfg->slot, cfg->func, reg, bytes);
-
- if (port != 0) {
- switch (bytes) {
- case 1:
- data = inb(port);
- break;
- case 2:
- data = inw(port);
- break;
- case 4:
- data = inl(port);
- break;
- }
- pci_cfgdisable();
- }
- return (data);
-}
-
-/* write configuration space register */
-
-void
-pci_cfgwrite(pcicfgregs *cfg, int reg, int data, int bytes)
-{
- int port;
-
- port = pci_cfgenable(cfg->bus, cfg->slot, cfg->func, reg, bytes);
- if (port != 0) {
- switch (bytes) {
- case 1:
- outb(port, data);
- break;
- case 2:
- outw(port, data);
- break;
- case 4:
- outl(port, data);
- break;
- }
- pci_cfgdisable();
- }
-}
-
-/* check whether the configuration mechanism has been correct identified */
-
-static int
-pci_cfgcheck(int maxdev)
-{
- u_char device;
-
- if (bootverbose)
- printf("pci_cfgcheck:\tdevice ");
-
- for (device = 0; device < maxdev; device++) {
- unsigned id, class, header;
- if (bootverbose)
- printf("%d ", device);
-
- id = inl(pci_cfgenable(0, device, 0, 0, 4));
- if (id == 0 || id == -1)
- continue;
-
- class = inl(pci_cfgenable(0, device, 0, 8, 4)) >> 8;
- if (bootverbose)
- printf("[class=%06x] ", class);
- if (class == 0 || (class & 0xf870ff) != 0)
- continue;
-
- header = inb(pci_cfgenable(0, device, 0, 14, 1));
- if (bootverbose)
- printf("[hdr=%02x] ", header);
- if ((header & 0x7e) != 0)
- continue;
-
- if (bootverbose)
- printf("is there (id=%08x)\n", id);
-
- pci_cfgdisable();
- return (1);
- }
- if (bootverbose)
- printf("-- nothing found\n");
-
- pci_cfgdisable();
- return (0);
-}
-
-static int
-pci_cfgopen(void)
-{
- unsigned long mode1res,oldval1;
- unsigned char mode2res,oldval2;
-
- oldval1 = inl(CONF1_ADDR_PORT);
-
- if (bootverbose) {
- printf("pci_open(1):\tmode 1 addr port (0x0cf8) is 0x%08lx\n",
- oldval1);
- }
-
- if ((oldval1 & CONF1_ENABLE_MSK) == 0) {
-
- cfgmech = 1;
- devmax = 32;
-
- outl(CONF1_ADDR_PORT, CONF1_ENABLE_CHK);
- outb(CONF1_ADDR_PORT +3, 0);
- mode1res = inl(CONF1_ADDR_PORT);
- outl(CONF1_ADDR_PORT, oldval1);
-
- if (bootverbose)
- printf("pci_open(1a):\tmode1res=0x%08lx (0x%08lx)\n",
- mode1res, CONF1_ENABLE_CHK);
-
- if (mode1res) {
- if (pci_cfgcheck(32))
- return (cfgmech);
- }
-
- outl(CONF1_ADDR_PORT, CONF1_ENABLE_CHK1);
- mode1res = inl(CONF1_ADDR_PORT);
- outl(CONF1_ADDR_PORT, oldval1);
-
- if (bootverbose)
- printf("pci_open(1b):\tmode1res=0x%08lx (0x%08lx)\n",
- mode1res, CONF1_ENABLE_CHK1);
-
- if ((mode1res & CONF1_ENABLE_MSK1) == CONF1_ENABLE_RES1) {
- if (pci_cfgcheck(32))
- return (cfgmech);
- }
- }
-
- oldval2 = inb(CONF2_ENABLE_PORT);
-
- if (bootverbose) {
- printf("pci_open(2):\tmode 2 enable port (0x0cf8) is 0x%02x\n",
- oldval2);
- }
-
- if ((oldval2 & 0xf0) == 0) {
-
- cfgmech = 2;
- devmax = 16;
-
- outb(CONF2_ENABLE_PORT, CONF2_ENABLE_CHK);
- mode2res = inb(CONF2_ENABLE_PORT);
- outb(CONF2_ENABLE_PORT, oldval2);
-
- if (bootverbose)
- printf("pci_open(2a):\tmode2res=0x%02x (0x%02x)\n",
- mode2res, CONF2_ENABLE_CHK);
-
- if (mode2res == CONF2_ENABLE_RES) {
- if (bootverbose)
- printf("pci_open(2a):\tnow trying mechanism 2\n");
-
- if (pci_cfgcheck(16))
- return (cfgmech);
- }
- }
-
- cfgmech = 0;
- devmax = 0;
- return (cfgmech);
-}
-
-static devclass_t pcib_devclass;
-
-static const char *
-nexus_pcib_is_host_bridge(pcicfgregs *cfg,
- u_int32_t id, u_int8_t class, u_int8_t subclass,
- u_int8_t *busnum)
-{
- const char *s = NULL;
- static u_int8_t pxb[4]; /* hack for 450nx */
-
- *busnum = 0;
-
- switch (id) {
- case 0x12258086:
- s = "Intel 824?? host to PCI bridge";
- /* XXX This is a guess */
- /* *busnum = pci_cfgread(cfg, 0x41, 1); */
- *busnum = cfg->bus;
- break;
- case 0x71208086:
- s = "Intel 82810 (i810 GMCH) Host To Hub bridge";
- break;
- case 0x71228086:
- s = "Intel 82810-DC100 (i810-DC100 GMCH) Host To Hub bridge";
- break;
- case 0x71248086:
- s = "Intel 82810E (i810E GMCH) Host To Hub bridge";
- break;
- case 0x71808086:
- s = "Intel 82443LX (440 LX) host to PCI bridge";
- break;
- case 0x71908086:
- s = "Intel 82443BX (440 BX) host to PCI bridge";
- break;
- case 0x71928086:
- s = "Intel 82443BX host to PCI bridge (AGP disabled)";
- break;
- case 0x71a08086:
- s = "Intel 82443GX host to PCI bridge";
- break;
- case 0x71a18086:
- s = "Intel 82443GX host to AGP bridge";
- break;
- case 0x71a28086:
- s = "Intel 82443GX host to PCI bridge (AGP disabled)";
- break;
- case 0x84c48086:
- s = "Intel 82454KX/GX (Orion) host to PCI bridge";
- *busnum = pci_cfgread(cfg, 0x4a, 1);
- break;
- case 0x84ca8086:
- /*
- * For the 450nx chipset, there is a whole bundle of
- * things pretending to be host bridges. The MIOC will
- * be seen first and isn't really a pci bridge (the
- * actual busses are attached to the PXB's). We need to
- * read the registers of the MIOC to figure out the
- * bus numbers for the PXB channels.
- *
- * Since the MIOC doesn't have a pci bus attached, we
- * pretend it wasn't there.
- */
- pxb[0] = pci_cfgread(cfg, 0xd0, 1); /* BUSNO[0] */
- pxb[1] = pci_cfgread(cfg, 0xd1, 1) + 1; /* SUBA[0]+1 */
- pxb[2] = pci_cfgread(cfg, 0xd3, 1); /* BUSNO[1] */
- pxb[3] = pci_cfgread(cfg, 0xd4, 1) + 1; /* SUBA[1]+1 */
- return NULL;
- case 0x84cb8086:
- switch (cfg->slot) {
- case 0x12:
- s = "Intel 82454NX PXB#0, Bus#A";
- *busnum = pxb[0];
- break;
- case 0x13:
- s = "Intel 82454NX PXB#0, Bus#B";
- *busnum = pxb[1];
- break;
- case 0x14:
- s = "Intel 82454NX PXB#1, Bus#A";
- *busnum = pxb[2];
- break;
- case 0x15:
- s = "Intel 82454NX PXB#1, Bus#B";
- *busnum = pxb[3];
- break;
- }
- break;
-
- /* AMD -- vendor 0x1022 */
- case 0x70061022:
- s = "AMD-751 host to PCI bridge";
- break;
-
- /* SiS -- vendor 0x1039 */
- case 0x04961039:
- s = "SiS 85c496";
- break;
- case 0x04061039:
- s = "SiS 85c501";
- break;
- case 0x06011039:
- s = "SiS 85c601";
- break;
- case 0x55911039:
- s = "SiS 5591 host to PCI bridge";
- break;
- case 0x00011039:
- s = "SiS 5591 host to AGP bridge";
- break;
-
- /* VLSI -- vendor 0x1004 */
- case 0x00051004:
- s = "VLSI 82C592 Host to PCI bridge";
- break;
-
- /* XXX Here is MVP3, I got the datasheet but NO M/B to test it */
- /* totally. Please let me know if anything wrong. -F */
- /* XXX need info on the MVP3 -- any takers? */
- case 0x05981106:
- s = "VIA 82C598MVP (Apollo MVP3) host bridge";
- break;
-
- /* AcerLabs -- vendor 0x10b9 */
- /* Funny : The datasheet told me vendor id is "10b8",sub-vendor */
- /* id is '10b9" but the register always shows "10b9". -Foxfair */
- case 0x154110b9:
- s = "AcerLabs M1541 (Aladdin-V) PCI host bridge";
- break;
-
- /* OPTi -- vendor 0x1045 */
- case 0xc8221045:
- s = "OPTi 82C822 host to PCI Bridge";
- break;
-
- /* RCC -- vendor 0x1166 */
- case 0x00051166:
- s = "RCC HE host to PCI bridge";
- *busnum = pci_cfgread(cfg, 0x44, 1);
- break;
-
- case 0x00061166:
- /* FALLTHROUGH */
- case 0x00081166:
- s = "RCC host to PCI bridge";
- *busnum = pci_cfgread(cfg, 0x44, 1);
- break;
-
- case 0x00091166:
- s = "RCC LE host to PCI bridge";
- *busnum = pci_cfgread(cfg, 0x44, 1);
- break;
-
- /* Integrated Micro Solutions -- vendor 0x10e0 */
- case 0x884910e0:
- s = "Integrated Micro Solutions VL Bridge";
- break;
-
- default:
- if (class == PCIC_BRIDGE && subclass == PCIS_BRIDGE_HOST)
- s = "Host to PCI bridge";
- break;
- }
-
- return s;
-}
-
-/*
- * Scan the first pci bus for host-pci bridges and add pcib instances
- * to the nexus for each bridge.
- */
-static void
-nexus_pcib_identify(driver_t *driver, device_t parent)
-{
- pcicfgregs probe;
- u_int8_t hdrtype;
- int found = 0;
- int pcifunchigh;
- int found824xx = 0;
-
- if (pci_cfgopen() == 0)
- return;
- probe.hose = 0;
- probe.bus = 0;
- retry:
- for (probe.slot = 0; probe.slot <= PCI_SLOTMAX; probe.slot++) {
- probe.func = 0;
- hdrtype = pci_cfgread(&probe, PCIR_HEADERTYPE, 1);
- if (hdrtype & PCIM_MFDEV)
- pcifunchigh = 7;
- else
- pcifunchigh = 0;
- for (probe.func = 0;
- probe.func <= pcifunchigh;
- probe.func++) {
- /*
- * Read the IDs and class from the device.
- */
- u_int32_t id;
- u_int8_t class, subclass, busnum;
- device_t child;
- const char *s;
-
- id = pci_cfgread(&probe, PCIR_DEVVENDOR, 4);
- if (id == -1)
- continue;
- class = pci_cfgread(&probe, PCIR_CLASS, 1);
- subclass = pci_cfgread(&probe, PCIR_SUBCLASS, 1);
-
- s = nexus_pcib_is_host_bridge(&probe, id,
- class, subclass,
- &busnum);
- if (s) {
- /*
- * Add at priority 100 to make sure we
- * go after any motherboard resources
- */
- child = BUS_ADD_CHILD(parent, 100,
- "pcib", busnum);
- device_set_desc(child, s);
- found = 1;
- if (id == 0x12258086)
- found824xx = 1;
- }
- }
- }
- if (found824xx && probe.bus == 0) {
- probe.bus++;
- goto retry;
- }
-
- /*
- * Make sure we add at least one bridge since some old
- * hardware doesn't actually have a host-pci bridge device.
- * Note that pci_cfgopen() thinks we have PCI devices..
- */
- if (!found) {
- if (bootverbose)
- printf(
- "nexus_pcib_identify: no bridge found, adding pcib0 anyway\n");
- BUS_ADD_CHILD(parent, 100, "pcib", 0);
- }
-}
-
-static int
-nexus_pcib_probe(device_t dev)
-{
- if (pci_cfgopen() != 0) {
- device_add_child(dev, "pci", device_get_unit(dev));
- return 0;
- }
- return ENXIO;
-}
-
-static device_method_t nexus_pcib_methods[] = {
- /* Device interface */
- DEVMETHOD(device_identify, nexus_pcib_identify),
- DEVMETHOD(device_probe, nexus_pcib_probe),
- DEVMETHOD(device_attach, bus_generic_attach),
- DEVMETHOD(device_shutdown, bus_generic_shutdown),
- DEVMETHOD(device_suspend, bus_generic_suspend),
- DEVMETHOD(device_resume, bus_generic_resume),
-
- /* Bus interface */
- DEVMETHOD(bus_print_child, bus_generic_print_child),
- DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
- DEVMETHOD(bus_release_resource, bus_generic_release_resource),
- DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
- DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
- DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
- DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
-
- { 0, 0 }
-};
-
-static driver_t nexus_pcib_driver = {
- "pcib",
- nexus_pcib_methods,
- 1,
-};
-
-DRIVER_MODULE(pcib, nexus, nexus_pcib_driver, pcib_devclass, 0, 0);
diff --git a/sys/boot/common/loader.8 b/sys/boot/common/loader.8
deleted file mode 100644
index ef847c10e68f..000000000000
--- a/sys/boot/common/loader.8
+++ /dev/null
@@ -1,753 +0,0 @@
-.\" Copyright (c) 1999 Daniel C. Sobral
-.\" 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 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.\"
-.\" Note: The date here should be updated whenever a non-trivial
-.\" change is made to the manual page.
-.Dd March 14, 1999
-.Dt LOADER 8
-.Os
-.Sh NAME
-.Nm loader
-.Nd system bootstrap stage three
-.Sh DESCRIPTION
-The program called
-.Nm
-is the third stage of FreeBSD's three stage bootstrap.
-It is a
-.Pa BTX
-client linked statically to
-.Xr libstand 3
-and usually located in the directory
-.Pa /boot .
-.Pp
-It provides a scripting language that can be used to
-automate tasks, do pre-configuration or assist in recovery
-procedures. This scripting language is roughly divided in
-two main components. The smaller one is a set of commands
-designed for direct use by the casual user, called "builtin
-commands" for historical reasons. The main drive behind
-these commands is user-friendlyness. The bigger component
-is an
-.Tn ANS
-Forth compatible Forth interpreter based on
-ficl, by
-.An John Sadler .
-.Pp
-During initialization,
-.Nm
-will probe for a console and set the
-.Va console
-variable, or set it to serial console
-.Pq Dq comconsole
-if the previous boot stage used that. Then, devices are probed,
-.Va currdev
-and
-.Va loaddev
-are set, and
-.Va LINES
-is set to 24 . Next,
-.Tn FICL
-is initialized, the builtin words are added to its vocabulary, and
-.Pa /boot/boot.4th
-will be processed if it exists. No disk switching is possible while
-that file is being read. The inner interpreter
-.Nm
-will use with
-.Tn FICL
-is then set to
-.Ic interpret ,
-which is
-.Tn FICL Ns 's
-default. After that,
-.Pa /boot/loader.rc
-is processed if available, and, failing that,
-.Pa /boot/boot.conf
-will be read for historical reasons. These files are processed
-through the
-.Ic include
-command, which read all of them into memory before processing them,
-making disk changes possible.
-.Pp
-At this point, if an
-.Ic autoboot
-has not been tried, and if
-.Va autoboot_delay
-is not set to
-.Dq NO
-(not case sensitive), then an
-.Ic autoboot
-will be tried. If the system gets past this point,
-.Va prompt
-will be set and
-.Nm
-will engage interactive mode.
-.Sh BUILTIN COMMANDS
-.Nm Loader Ns No 's
-builtin commands take its parameters from the command line. Presently,
-the only way to call them from a script is by using
-.Pa evaluate
-on a string. If an error condition occurs, an exception will be
-generated, which can be intercepted using
-.Tn ANS
-Forth exception handling
-words. If not intercepted, an error message will be displayed and
-the interpreter's state will be reset, emptying the stack and restoring
-interpreting mode.
-.Pp
-The builtin commands available are:
-.Pp
-.Bl -tag -width Ds -compact -offset indent
-.It Ic autoboot Op Ar seconds
-Proceeds to bootstrap the system after a number of seconds, if not
-interrupted by the user. Displays a countdown prompt warning the
-user the system is about to be booted, unless interrupted by a key
-press. The kernel will be loaded first if necessary. Defaults to
-10 seconds.
-.Pp
-.It Ic bcachestat
-Displays statistics about disk cache usage. For depuration only.
-.Pp
-.It Ic boot
-.It Ic boot Ar kernelname Op Cm ...
-.It Ic boot Fl flag Cm ...
-Immediately proceeds to bootstrap the system, loading the kernel
-if necessary. Any flags or arguments are passed to the kernel, but they
-must precede the kernel name, if a kernel name is provided.
-.Pp
-.It Ic echo Xo
-.Op Fl n
-.Op Aq message
-.Xc
-Displays a text on the screen. A new line will be printed unless
-.Fl n
-is specified.
-.Pp
-.It Ic heap
-Displays memory usage statistics. For debugging purposes only.
-.Pp
-.It Ic help Op topic Op subtopic
-Shows help messages read from
-.Pa /boot/loader.help .
-The special topic
-.Em index
-will list the topics available.
-.Pp
-.It Ic include Ar file Op Ar
-Process script files. Each file is, at a turn, completely read into
-memory, and then have each of its lines passed to the command line
-interpreter. If any error is returned by the interpreter, the include
-commands aborts immediately, without reading any other files, and
-returns an error itself (see
-.Sx ERRORS ) .
-.Pp
-.It Ic load Xo
-.Op Fl t Ar type
-.Ar file Cm ...
-.Xc
-Loads a kernel, kernel loadable module (kld), or a file of opaque
-contents tagged as being of the type
-.Ar type .
-Kernel and modules can be either in a.out or elf format. Any arguments
-passed after the name of the file to be loaded will be passed as
-arguments to that file. Notice, though, that, at the present, this does
-not work for the kernel.
-.Pp
-.It Ic ls Xo
-.Op Fl l
-.Op Ar path
-.Xc
-Displays a listing of files in the directory
-.Ar path ,
-or the root directory if
-.Ar path
-is not specified. If
-.Fl l
-is specified, file sizes will be shown too.
-.Pp
-.It Ic lsdev Op Fl v
-Lists all of the devices from which it may be possible to load modules. If
-.Fl v
-is specified, more details are printed.
-.Pp
-.It Ic lsmod Op Fl v
-Displays loaded modules. If
-.Fl v
-is specified, more details are shown.
-.Pp
-.It Ic more Ar file Op Ar
-Display the files specified, with a pause at each
-.Va LINES
-displayed.
-.Pp
-.It Ic pnpscan Op Fl v
-Scans for Plug-and-Play devices. This is not functional at the present.
-.Pp
-.It Ic read Xo
-.Op Fl t Ar seconds
-.Op Fl p Ar prompt
-.Op Va variable
-.Xc
-Reads a line of input from the terminal, storing it in
-.Va variable
-if specified. A timeout can be specified with
-.Fl t ,
-though it will be canceled at the first key pressed. A prompt may
-also be displayed through the
-.Fl p
-flag.
-.Pp
-.It Ic reboot
-Immediately reboots the system.
-.Pp
-.It Ic set Ar variable
-.It Ic set Ar variable Ns = Ns Ar value
-Set loader's environment variables.
-.Pp
-.It Ic show Op Va variable
-Displays the specified variable's value, or all variables and their
-values if
-.Va variable
-is not specified.
-.Pp
-.It Ic unload
-Remove all modules from memory.
-.Pp
-.It Ic unset Va variable
-Removes
-.Va variable
-from the environment.
-.Pp
-.It Ic \&?
-Same as
-.Dq help index .
-.Pp
-.El
-.Ss BUILTIN ENVIRONMENT VARIABLES
-The
-.Nm
-has actually two different kinds of
-.Sq environment
-variables. There are ANS Forth's
-.Em environmental queries ,
-and a separate space of environment variables used by builtins, which
-are not directly available to Forth words. It is the later ones that
-this session covers.
-.Pp
-Environment variables can be set and unset through the use of the
-.Ic set
-and
-.Ic unset
-builtins, and have their value interactively examined through the
-use of the
-.Ic show
-builtin. Their values can also be accessed as described in
-.Sx BUILTIN PARSER .
-.Pp
-Notice that this environment variables are not inherited by any shell
-after the system has been booted.
-.Pp
-A few variables are set automatically by
-.Nm loader .
-Others can affect either
-.Nm
-or kernel's behavior at boot. While some of these may require a value,
-others define behavior just by being set. These are described below.
-.Bl -tag -width bootfile -offset indent
-.It Va autoboot_delay
-Number of seconds
-.Ic autoboot
-will wait before booting. If this variable is not defined,
-.Ic autoboot
-will default to 10 seconds.
-.Pp
-If set to
-.Dq NO ,
-no
-.Ic autoboot
-will be automatically attempted after processing
-.Pa /boot/loader.rc ,
-though explict
-.Ic autoboot Ns 's
-will be processed normally, defaulting to 10 seconds delay.
-.It Va boot_askname
-Instructs the kernel to prompt the user for the name of the root device
-when the kernel is booted.
-.It Va boot_ddb
-Instructs the kernel to start in the DDB debugger, rather than
-proceeding to initialise when booted.
-.It Va boot_gdb
-Selects gdb-remote mode for the kernel debugger by default.
-.It Va boot_single
-Prevents the kernel from initiating a multi-user startup, single-user
-mode will be entered when the kernel has finished device probes.
-.It Va boot_userconfig
-Requests that the kernel's interactive device configuration program
-be run when the kernel is booted.
-.It Va boot_verbose
-Setting this variable causes extra debugging information to be printed
-by the kernel during the boot phase.
-.It Va bootfile
-List of semicolon-separated search path for bootable kernels. The default
-is
-.Li Dq kernel;kernel.old .
-.It Va console
-Defines the current console.
-.It Va currdev
-Selects the default device. Syntax for devices is odd.
-.It Va init_path
-Sets the list of binaries which the kernel will try to run as initial
-process. The default is
-.Li Dq /sbin/init:/sbin/oinit:/sbin/init.bak:/stand/sysinstall .
-.It Va interpret
-Has the value
-.Li Dq ok
-if the Forth's current state is interpreting.
-.It Va LINES
-Define the number of lines on the screen, to be used by the pager.
-.It Va module_path
-Sets the list of directories which will be searched in for modules
-named in a load command or implicitly required by a dependancy. The
-default value for this variable is
-.Li Dq /;/boot;/modules .
-.It Va num_ide_disks
-Sets the number of IDE disks as a work around for some problems in
-finding the root disk at boot. This has been deprecated in favour of
-.Va root_disk_unit .
-.It Va prompt
-Value of
-.Nm Ns No 's
-prompt. Defaults to
-.Li Dq "${currdev}>" .
-.It Va root_disk_unit
-If the code which detects the disk unit number for the root disk is
-confused, eg. by a mix of SCSI and IDE disks, or IDE disks with
-gaps in the sequence (eg. no primary slave), the unit number can
-be forced by setting this variable.
-.It Va rootdev
-By default the value of
-.Va currdev
-is used to set the root filesystem
-when the kernel is booted. This can be overridden by setting
-.Va rootdev
-explicitly.
-.El
-.Pp
-Other variables are used to override kernel tunnable parameters.
-The following tunables are available:
-.Bl -tag -width Va -offset indent
-.It Va kern.ipc.nmbclusters
-Set the number of mbuf clusters to be allocated. The value
-cannot be set below the default determined when the kernel
-was compiled. Modifies
-.Va NMBCLUSTERS .
-.It Va kern.vm.kmem.size
-Sets the size of kernel memory (bytes). This overrides
-completely the value determined when the kernel was
-compiled. Modifies
-.Va VM_KMEM_SIZE .
-.It Va machdep.pccard.pcic_irq
-Overrides the IRQ normally assigned to a PCCARD controller.
-Typically the first available interrupt will be allocated,
-which may conflict with other hardware. If this value is
-set to 0, an interrupt will not be assigned and the
-controller will operate in polled mode only.
-.It Va net.inet.tcp.tcbhashsize
-Overrides the compile-time set value of
-.Va TCBHASHSIZE
-or the preset default of 512. Must be a power of 2.
-.El
-.Ss BUILTIN PARSER
-When a builtin command is executed, the rest of the line is taken
-by it as arguments, and it is processed by a special parser which
-is not used for regular Forth commands.
-.Pp
-This special parser applies the following rules to the parsed text:
-.Pp
-.Bl -enum
-.It
-All backslash characters are preprocessed.
-.Bl -bullet
-.It
-\eb , \ef , \er , \en and \et are processed as by C's
-.Fn printf .
-.It
-\es is converted to a space.
-.It
-\ev is converted to
-.Tn ASCII
-11.
-.It
-\ez is just skipped. Useful for things like
-.Dq \e0xf\ez\e0xf .
-.It
-\e0xN and \e0xNN are replaced by the hex N or NN.
-.It
-\eNNN is replaced by the octal NNN
-.Tn ASCII
-character.
-.It
-\e" , \e' and \e$ will escape these characters, preventing them from
-receiving special semantics on the step 2 described below.
-.It
-\e\e will be replaced with a single \e .
-.It
-In any other occurance, backslash will just be removed.
-.El
-.It
-Every string between non-escaped quotes or double-quotes will be treated
-as a single word for the purposes of the remaining steps.
-.It
-Replace any
-.Li $VARIABLE
-or
-.Li ${VARIABLE}
-with the value of the environemnt variable
-.Va VARIABLE .
-.It
-Passes multiple space-delimited arguments to the builtin command called.
-Spaces can also be escaped through the use of \e\e .
-.El
-.Pp
-An exception to this parsing rule exists, and is described in
-.Sx BUILTINS AND FORTH .
-.Ss BUILTINS AND FORTH
-All builtin words are state-smart, immediate words. If interpreted, they
-behave exactly as described previously. If they are compiled, though,
-they extract their arguments from the stack instead of the command line.
-.Pp
-If compiled, the builtin words expect to find, at execution time, the
-following parameters on the stack:
-.D1 Ar addrN lenN ... addr2 len2 addr1 len1 N
-where
-.Ar addrX lenX
-are strings which will compose the command line that will be parsed
-into the builtin's arguments. Internally, these strings are
-concatenated in from 1 to N, with a space put between each one.
-.Pp
-If no arguments are passed, a 0
-.Em must
-be passed, even if the builtin accepts no arguments.
-.Pp
-While this behavior has benefits, it has its trade-offs. If the
-execution token of a builtin is acquired (through
-.Ic No '
-or
-.Ic No ['] ) ,
-and then passed to
-.Ic catch
-or
-.Ic execute ,
-the builtin behavior will depend on the system state
-.Bf Em
-at the time
-.Ic catch
-or
-.Ic execute
-is processed
-.Ef
-\&! This is particular annoying for programs that want or need to
-treat exceptions. In this case, it is recommended the use of a proxy.
-For example:
-.Dl : (boot) boot ;
-.Sh FICL
-.Tn FICL
-is a Forth interpreter written in C, in the form of a forth
-virtual machine library that can be called by C functions and vice
-versa.
-.Pp
-In
-.Nm No ,
-each line read interactively is then fed to
-.Tn FICL ,
-which may call
-.Nm
-back to execute the builtin words. The builtin
-.Ic include
-will also feed
-.Tn FICL ,
-one line at a time.
-.Pp
-The words available to
-.Tn FICL
-can be classified in four groups. The
-.Tn ANS
-Forth standard words, extra
-.Tn FICL
-words, extra
-.Os
-words, and the builtin commands. The later were already described. The
-.Tn ANS
-Forth standard words are listed in the
-.Sx STANDARDS
-section. The words falling in the two other groups are described in the
-following subsections.
-.Ss FICL EXTRA WORDS
-.Bl -tag -width wid-set-super -offset indent
-.It Ic .env
-.It Ic .ver
-.It Ic -roll
-.It Ic 2constant
-.It Ic >name
-.It Ic body>
-.It Ic compare
-This the STRING word set's
-.Ic compare .
-.It Ic compile-only
-.It Ic endif
-.It Ic forget-wid
-.It Ic parse-word
-.It Ic sliteral
-This is the STRING word set's
-.Ic sliteral .
-.It Ic wid-set-super
-.It Ic w@
-.It Ic w!
-.It Ic x.
-.It Ic empty
-.It Ic cell-
-.It Ic -rot
-.El
-.Ss FREEBSD EXTRA WORDS
-.Bl -tag -width XXXXXXX -offset indent
-.It Ic tib> Pq -- Ar addr len
-Returns the remainder of the input buffer as a string on the stack.
-.It Ic \&% Pq --
-Evaluates the remainder of the input buffer under a
-.Ic catch
-exception guard.
-.It Ic \&$ Pq --
-Evaluates the remainder of the input buffer, after having printed it first.
-.It Ic fopen Pq Ar addr len -- fd
-Open a file. Returns a file descriptor, or -1 in case of failure.
-.It Ic fclose Pq Ar fd --
-Closes a file.
-.It Xo
-.Ic fread
-.Pq Ar fd addr len -- len'
-.Xc
-Tries to read
-.Em len
-bytes from file
-.Em fd
-into buffer
-.Em addr .
-Returns the actual number of bytes read, or -1 in case of error or end of
-file.
-.It Ic fload Pq Ar fd --
-Process file
-.Em fd .
-.It Ic fkey Pq Ar fd -- char
-Reads a single character from a file.
-.It Ic key Pq -- Ar char
-Reads a single character from the console.
-.It Ic key? Pq -- Ar flag
-Returns
-.Ic true
-if there is a character available to be read from the console.
-.It Ic ms Pq Ar u --
-Waits
-.Em u
-microseconds.
-.It Ic seconds Pq -- Ar u
-Returns the number of seconds since midnight.
-.It Ic trace! Pq Ar flag --
-Activates or deactivates tracing. Does not work with
-.Ic catch .
-.It Ic outb Pq Ar port char --
-Writes a byte to a port.
-.It Ic inb Pq Ar port -- char
-Reads a byte from a port.
-.El
-.Ss FREEBSD DEFINED ENVIRONMENTAL QUERIES
-.Bl -tag -width Ds -offset indent
-.It arch-i386
-.Ic TRUE
-if the architecture is IA32.
-.It arch-alpha
-.Ic TRUE
-if the architecture is AXP.
-.It FreeBSD_version
-.Fx
-version at compile time.
-.It loader_version
-.Nm
-version.
-.El
-.Ss SYSTEM DOCUMENTATION
-.Sh FILES
-.Bl -tag -width /dev/loader.helpX -compact
-.It Pa /boot/loader
-.Nm
-itself.
-.It Pa /boot/boot.4th
-Additional
-.Tn FICL
-initialization.
-.It Pa /boot/boot.conf
-.Nm
-bootstrapping script. Deprecated.
-.It Pa /boot/loader.rc
-.Nm
-bootstrapping script.
-.It Pa /boot/loader.help
-Loaded by
-.Ic help .
-Contains the help messages.
-.El
-.Sh EXAMPLES
-Boot in single user mode:
-.Pp
-.Dl boot -s
-.Pp
-Loads kernel's user configuration file. Notice that a kernel must be
-loaded before any other
-.Ic load
-command is attempted.
-.Pp
-.Bd -literal -offset indent -compact
-load kernel
-load -t userconfig_script /boot/kernel.conf
-.Ed
-.Pp
-Loads the kernel, a splash screen, and then autoboots in five seconds.
-.Pp
-.Bd -literal -offset indent -compact
-load kernel
-load splash_bmp
-load -t splash_image_data /boot/chuckrulez.bmp
-autoboot 5
-.Ed
-.Pp
-Sets the disk unit of the root device to 2, and then boots. This would
-be needed in the case of a two IDE disks system, with the second IDE
-hardwired to wd2 instead of wd1.
-.Pp
-.Bd -literal -offset indent -compact
-set root_disk_unit=2
-boot /kernel
-.Ed
-.Pp
-See also:
-.Bl -tag -width /usr/share/examples/bootforth/X
-.It Pa /boot/loader.4th
-Extra builtin-like words.
-.It Pa /boot/support.4th
-.Pa loader.conf
-processing words.
-.It Pa /usr/share/examples/bootforth/
-Assorted examples.
-.El
-.Sh ERRORS
-The following values are thrown by
-.Nm :
-.Bl -tag -width XXXXX -offset indent
-.It 100
-Any type of error in the processing of a builtin.
-.It -1
-.Ic Abort
-executed.
-.It -2
-.Ic Abort"
-executed.
-.It -56
-.Ic Quit
-executed.
-.It -256
-Out of interpreting text.
-.It -257
-Need more text to succeed -- will finish on next run.
-.It -258
-.Ic Bye
-executed.
-.It -259
-Unspecified error.
-.El
-.Sh SEE ALSO
-.Xr libstand 3 ,
-.Xr loader.conf 5 ,
-.Xr boot 8 ,
-.Xr btxld 8
-.Sh STANDARDS
-For the purposes of ANS Forth compliance, loader is an
-.Bf Em
-ANS Forth System with Environmental Restrictions, Providing
-.Ef
-.Bf Li
-.No .( ,
-.No :noname ,
-.No ?do ,
-parse, pick, roll, refill, to, value, \e, false, true,
-.No <> ,
-.No 0<> ,
-compile\&, , erase, nip, tuck
-.Ef
-.Em and
-.Li marker
-.Bf Em
-from the Core Extensions word set, Providing the Exception Extensions
-word set, Providing the Locals Extensions word set, Providing the
-Memory-Allocation Extensions word set, Providing
-.Ef
-.Bf Li
-\&.s ,
-bye, forget, see, words,
-\&[if] ,
-\&[else]
-.Ef
-.Em and
-.Li No [then]
-.Bf Em
-from the Programming-Tools extension word set, Providing the
-Search-Order extensions word set.
-.Ef
-.Sh HISTORY
-.Nm
-first appeared in
-.Fx 3.1 .
-.Sh AUTHORS
-.Bl -item
-.It
-.Nm
-was written by
-.An Michael Smith Aq msmith@freebsd.org .
-.It
-.Tn FICL
-was written by
-.An John Sadler Aq john_sadler@alum.mit.edu .
-.El
-.Sh BUGS
-.Tn FICL
-is case sensitive. Though this is not a standard violation, all Forth
-words are lower cased, which would result in a standard violation. Do
-not rely on this bug.
-.Pp
-The
-.Ic expect
-and
-.Ic accept
-words will read from the input buffer instead of the console. The latter
-will be fixed, but the former will not.
-
diff --git a/sys/boot/i386/boot2/boot1.S b/sys/boot/i386/boot2/boot1.S
deleted file mode 100644
index d78aaf29b4a6..000000000000
--- a/sys/boot/i386/boot2/boot1.S
+++ /dev/null
@@ -1,259 +0,0 @@
-#
-# Copyright (c) 1998 Robert Nordier
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms are freely
-# permitted provided that the above copyright notice and this
-# paragraph and the following disclaimer are duplicated in all
-# such forms.
-#
-# This software is provided "AS IS" and without any express or
-# implied warranties, including, without limitation, the implied
-# warranties of merchantability and fitness for a particular
-# purpose.
-#
-
-# $FreeBSD$
-
- .set MEM_REL,0x700 # Relocation address
- .set MEM_ARG,0x900 # Arguments
- .set MEM_ORG,0x7c00 # Origin
- .set MEM_BUF,0x8c00 # Load area
- .set MEM_BTX,0x9000 # BTX start
- .set MEM_JMP,0x9010 # BTX entry point
- .set MEM_USR,0xa000 # Client start
-
- .set PRT_OFF,0x1be # Partition offset
- .set PRT_NUM,0x4 # Partitions
- .set PRT_BSD,0xa5 # Partition type
-
- .set SIZ_PAG,0x1000 # Page size
- .set SIZ_SEC,0x200 # Sector size
-
- .globl start
- .globl xread
-
-start: jmp main # Start recognizably
-
- .org 0x4,0x90
-
-# External read from disk
-
-xread: pushl %ss # Address
- popl %ds # data
-xread.1: o16 # Starting
- pushb $0x0 # absolute
- pushl %ecx # block
- pushl %eax # number
- pushl %es # Address of
- pushl %ebx # transfer buffer
- xorl %eax,%eax # Number of
- movb %dh,%al # blocks to
- pushl %eax # transfer
- pushb $0x10 # Size of packet
- movl %esp,%ebp # Packet pointer
- callwi(read) # Read from disk
- leaw1r(0x10,_bp_,_sp) # Clear stack
- lret # To far caller
-
-# Bootstrap
-
-main: cld # String ops inc
- xorl %ecx,%ecx # Zero
- movl %cx,%es # Address
- movl %cx,%ds # data
- movl %cx,%ss # Set up
- movwir(start,_sp) # stack
- movl %esp,%esi # Source
- movwir(MEM_REL,_di) # Destination
- incb %ch # Word count
- rep # Copy
- movsl # code
- movwir(part4,_si) # Partition
- cmpb $0x80,%dl # Hard drive?
- jb main.4 # No
- movb $0x1,%dh # Block count
- callwi(nread) # Read MBR
- movwir(0x1,_cx) # Two passes
-main.1: movwir(MEM_BUF+PRT_OFF,_si) # Partition table
- movb $0x1,%dh # Partition
-main.2: cmpbi1(PRT_BSD,0x4,_si_) # Our partition type?
- jne main.3 # No
- jecxz main.5 # If second pass
- tstbi0(0x80,_si_) # Active?
- jnz main.5 # Yes
-main.3: addl $0x10,%esi # Next entry
- incb %dh # Partition
- cmpb $0x1+PRT_NUM,%dh # In table?
- jb main.2 # Yes
- decl %ecx # Do two
- jecxz main.1 # passes
- movwir(msg_part,_si) # Message
- jmp error # Error
-main.4: xorl %edx,%edx # Partition:drive
-main.5: movwrm(_dx,MEM_ARG) # Save args
- movb $0x10,%dh # Sector count
- callwi(nread) # Read disk
- movwir(MEM_BTX,_bx) # BTX
- movw1r(0xa,_bx_,_si) # Point past
- addl %ebx,%esi # it
- movwir(MEM_USR+SIZ_PAG,_di) # Client page 1
- movwir(MEM_BTX+0xe*SIZ_SEC,_cx) # Byte
- subl %esi,%ecx # count
- rep # Relocate
- movsb # client
- subl %edi,%ecx # Byte count
- xorb %al,%al # Zero
- rep # assumed
- stosb # bss
- callwi(seta20) # Enable A20
- jmpnwi(start+MEM_JMP-MEM_ORG) # Start BTX
-
-# Enable A20
-
-seta20: cli # Disable interrupts
-seta20.1: inb $0x64,%al # Get status
- testb $0x2,%al # Busy?
- jnz seta20.1 # Yes
- movb $0xd1,%al # Command: Write
- outb %al,$0x64 # output port
-seta20.2: inb $0x64,%al # Get status
- testb $0x2,%al # Busy?
- jnz seta20.2 # Yes
- movb $0xdf,%al # Enable
- outb %al,$0x60 # A20
- sti # Enable interrupts
- ret # To caller
-
-# Local read from disk
-
-nread: movwir(MEM_BUF,_bx) # Transfer buffer
- movw1r(0x8,_si_,_ax) # Get
- movw1r(0xa,_si_,_cx) # LBA
- pushl %cs # Read from
- callwi(xread.1) # disk
- jnc return # If success
- movwir(msg_read,_si) # Message
-
-# Error exit
-
-error: callwi(putstr) # Display message
- movwir(prompt,_si) # Display
- callwi(putstr) # prompt
- xorb %ah,%ah # BIOS: Get
- int $0x16 # keypress
- int $0x19 # BIOS: Reboot
-
-# Display string
-
-putstr.0: movwir(0x7,_bx) # Page:attribute
- movb $0xe,%ah # BIOS: Display
- int $0x10 # character
-putstr: lodsb # Get char
- testb %al,%al # End of string?
- jne putstr.0 # No
-
-ereturn: movb $0x1,%ah # Invalid
- stc # argument
-return: ret # To caller
-
-# Read from disk
-
-read: cs_ # LBA support
- tstbim(0x80,MEM_REL+flags-start)# enabled?
- jz read.1 # No
- movwir(0x55aa,_bx) # Magic
- pushl %edx # Save
- movb $0x41,%ah # BIOS: Check
- int $0x13 # extensions present
- popl %edx # Restore
- jc read.1 # If error
- cmpwir(0xaa55,_bx) # Magic?
- jne read.1 # No
- testb $0x1,%cl # Packet interface?
- jz read.1 # No
- movl %ebp,%esi # Disk packet
- movb $0x42,%ah # BIOS: Extended
- int $0x13 # read
- ret # To caller
-
-read.1: pushl %edx # Save
- movb $0x8,%ah # BIOS: Get drive
- int $0x13 # parameters
- movb %dh,%ch # Max head number
- popl %edx # Restore
- jc return # If error
- andb $0x3f,%cl # Sectors per track
- jz ereturn # If zero
- cli # Disable interrupts
- o16 # Get
- movw1r(0x8,_bp_,_ax) # LBA
- pushl %edx # Save
- movzbw %cl,%bx # Divide by
- xorw %dx,%dx # sectors
- divw %bx,%ax # per track
- movb %ch,%bl # Max head number
- movb %dl,%ch # Sector number
- incl %ebx # Divide by
- xorb %dl,%dl # number
- divw %bx,%ax # of heads
- movb %dl,%bh # Head number
- popl %edx # Restore
- o16 # Cylinder number
- cmpl $0x3ff,%eax # supportable?
- sti # Enable interrupts
- ja ereturn # No
- xchgb %al,%ah # Set up cylinder
- rorb $0x2,%al # number
- orb %ch,%al # Merge
- incl %eax # sector
- xchgl %eax,%ecx # number
- movb %bh,%dh # Head number
- subb %ah,%al # Sectors this track
- movb1r(0x2,_bp_,_ah) # Blocks to read
- cmpb %ah,%al # To read
- jb read.2 # this
- movb %ah,%al # track
-read.2: movwir(0x5,_di) # Try count
-read.3: lesw1r(0x4,_bp_,_bx) # Transfer buffer
- pushl %eax # Save
- movb $0x2,%ah # BIOS: Read
- int $0x13 # from disk
- popl %ebx # Restore
- jnc read.4 # If success
- decl %edi # Retry?
- jz read.6 # No
- xorb %ah,%ah # BIOS: Reset
- int $0x13 # disk system
- xchgl %ebx,%eax # Block count
- jmp read.3 # Continue
-read.4: movzbl %bl,%eax # Sectors read
- addwr1(_ax,0x8,_bp_) # Adjust
- jnc read.5 # LBA,
- incw1(0xa,_bp_) # transfer
-read.5: shlb %bl # buffer
- addbr1(_bl,0x5,_bp_) # pointer,
- subbr1(_al,0x2,_bp_) # block count
- ja read.1 # If not done
-read.6: ret # To caller
-
-# Messages
-
-msg_read: .asciz "Read"
-msg_part: .asciz "Boot"
-
-prompt: .asciz " error\r\n"
-
-flags: .byte FLAGS # Flags
-
- .org PRT_OFF,0x90
-
-# Partition table
-
- .fill 0x30,0x1,0x0
-part4: .byte 0x80, 0x00, 0x01, 0x00
- .byte 0xa5, 0xff, 0xff, 0xff
- .byte 0x00, 0x00, 0x00, 0x00
- .byte 0x50, 0xc3, 0x00, 0x00
-
- .word 0xaa55 # Magic number
diff --git a/sys/boot/i386/boot2/sio.S b/sys/boot/i386/boot2/sio.S
deleted file mode 100644
index e29820586a3b..000000000000
--- a/sys/boot/i386/boot2/sio.S
+++ /dev/null
@@ -1,80 +0,0 @@
-#
-# Copyright (c) 1998 Robert Nordier
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms are freely
-# permitted provided that the above copyright notice and this
-# paragraph and the following disclaimer are duplicated in all
-# such forms.
-#
-# This software is provided "AS IS" and without any express or
-# implied warranties, including, without limitation, the implied
-# warranties of merchantability and fitness for a particular
-# purpose.
-#
-
-# $FreeBSD$
-
- .set SIO_PRT,SIOPRT # Base port
- .set SIO_FMT,SIOFMT # 8N1
- .set SIO_DIV,(115200/SIOSPD) # 115200 / SPD
-
- .globl sio_init
- .globl sio_flush
- .globl sio_putc
- .globl sio_getc
- .globl sio_ischar
-
-# void sio_init(void)
-
-sio_init: movw $SIO_PRT+0x3,%dx # Data format reg
- movb $SIO_FMT|0x80,%al # Set format
- outb %al,(%dx) # and DLAB
- pushl %edx # Save
- subb $0x3,%dl # Divisor latch reg
- movw $SIO_DIV,%ax # Set
- outw %ax,(%dx) # BPS
- popl %edx # Restore
- movb $SIO_FMT,%al # Clear
- outb %al,(%dx) # DLAB
- incl %edx # Modem control reg
- movb $0x3,%al # Set RTS,
- outb %al,(%dx) # DTR
- incl %edx # Line status reg
-
-# void sio_flush(void)
-
-sio_flush.0: call sio_getc.1 # Get character
-sio_flush: call sio_ischar # Check for character
- jnz sio_flush.0 # Till none
- ret # To caller
-
-# void sio_putc(int c)
-
-sio_putc: movw $SIO_PRT+0x5,%dx # Line status reg
- xor %ecx,%ecx # Timeout
- movb $0x40,%ch # counter
-sio_putc.1: inb (%dx),%al # Transmitter
- testb $0x20,%al # buffer empty?
- loopz sio_putc.1 # No
- jz sio_putc.2 # If timeout
- movb 0x4(%esp,1),%al # Get character
- subb $0x5,%dl # Transmitter hold reg
- outb %al,(%dx) # Write character
-sio_putc.2: ret $0x4 # To caller
-
-# int sio_getc(void)
-
-sio_getc: call sio_ischar # Character available?
- jz sio_getc # No
-sio_getc.1: subb $0x5,%dl # Receiver buffer reg
- inb (%dx),%al # Read character
- ret # To caller
-
-# int sio_ischar(void)
-
-sio_ischar: movw $SIO_PRT+0x5,%dx # Line status register
- xorl %eax,%eax # Zero
- inb (%dx),%al # Received data
- andb $0x1,%al # ready?
- ret # To caller
diff --git a/sys/boot/i386/btx/btx/btx.S b/sys/boot/i386/btx/btx/btx.S
deleted file mode 100644
index da89da069c6d..000000000000
--- a/sys/boot/i386/btx/btx/btx.S
+++ /dev/null
@@ -1,1050 +0,0 @@
-#
-# Copyright (c) 1998 Robert Nordier
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms are freely
-# permitted provided that the above copyright notice and this
-# paragraph and the following disclaimer are duplicated in all
-# such forms.
-#
-# This software is provided "AS IS" and without any express or
-# implied warranties, including, without limitation, the implied
-# warranties of merchantability and fitness for a particular
-# purpose.
-#
-
-# $FreeBSD$
-
-#
-# Memory layout.
-#
- .set MEM_BTX,0x1000 # Start of BTX memory
- .set MEM_ESP0,0x1800 # Supervisor stack
- .set MEM_BUF,0x1800 # Scratch buffer
- .set MEM_ESP1,0x1e00 # Link stack
- .set MEM_IDT,0x1e00 # IDT
- .set MEM_TSS,0x1f98 # TSS
- .set MEM_MAP,0x2000 # I/O bit map
- .set MEM_DIR,0x4000 # Page directory
- .set MEM_TBL,0x5000 # Page tables
- .set MEM_ORG,0x9000 # BTX code
- .set MEM_USR,0xa000 # Start of user memory
-#
-# Paging control.
-#
- .set PAG_SIZ,0x1000 # Page size
- .set PAG_CNT,0x1000 # Pages to map
-#
-# Segment selectors.
-#
- .set SEL_SCODE,0x8 # Supervisor code
- .set SEL_SDATA,0x10 # Supervisor data
- .set SEL_RCODE,0x18 # Real mode code
- .set SEL_RDATA,0x20 # Real mode data
- .set SEL_UCODE,0x28|3 # User code
- .set SEL_UDATA,0x30|3 # User data
- .set SEL_TSS,0x38 # TSS
-#
-# Task state segment fields.
-#
- .set TSS_ESP0,0x4 # PL 0 ESP
- .set TSS_SS0,0x8 # PL 0 SS
- .set TSS_ESP1,0xc # PL 1 ESP
- .set TSS_MAP,0x66 # I/O bit map base
-#
-# System calls.
-#
- .set SYS_EXIT,0x0 # Exit
- .set SYS_EXEC,0x1 # Exec
-#
-# V86 constants.
-#
- .set V86_FLG,0x208eff # V86 flag mask
- .set V86_STK,0x400 # V86 stack allowance
-#
-# Dump format control bytes.
-#
- .set DMP_X16,0x1 # Word
- .set DMP_X32,0x2 # Long
- .set DMP_MEM,0x4 # Memory
- .set DMP_EOL,0x8 # End of line
-#
-# Screen defaults and assumptions.
-#
- .set SCR_MAT,0x7 # Mode/attribute
- .set SCR_COL,0x50 # Columns per row
- .set SCR_ROW,0x19 # Rows per screen
-#
-# BIOS Data Area locations.
-#
- .set BDA_MEM,0x413 # Free memory
- .set BDA_KEYFLAGS,0x417 # Keyboard shift-state flags
- .set BDA_SCR,0x449 # Video mode
- .set BDA_POS,0x450 # Cursor position
- .set BDA_BOOT,0x472 # Boot howto flag
-#
-# Derivations, for brevity.
-#
- .set _ESP0H,MEM_ESP0>>0x8 # Byte 1 of ESP0
- .set _ESP1H,MEM_ESP1>>0x8 # Byte 1 of ESP1
- .set _TSSIO,MEM_MAP-MEM_TSS # TSS I/O base
- .set _TSSLM,MEM_DIR-MEM_TSS-1 # TSS limit
- .set _IDTLM,MEM_TSS-MEM_IDT-1 # IDT limit
-#
-# Code segment.
-#
- .globl start
-start: # Start of code
-#
-# BTX header.
-#
-btx_hdr: .byte 0xeb # Machine ID
- .byte 0xe # Header size
- .ascii "BTX" # Magic
- .byte 0x1 # Major version
- .byte 0x1 # Minor version
- .byte 0x0 # Flags
- .word PAG_CNT-MEM_ORG>>0xc # Paging control
- .word break-start # Text size
- .long 0x0 # Entry address
-#
-# Initialization routine.
-#
-init: cli # Disable interrupts
- xorl %eax,%eax # Zero/segment
- movl %ax,%ss # Set up
- movwir(MEM_ESP0,_sp) # stack
- movl %ax,%es # Address
- movl %ax,%ds # data
- pushw $0x2 # Clear
- popfw # flags
-#
-# Initialize memory.
-#
- movwir(MEM_IDT,_di) # Memory to initialize
- movwir((MEM_ORG-MEM_IDT)/2,_cx) # Words to zero
- pushl %edi # Save
- rep # Zero-fill
- stosl # memory
- popl %edi # Restore
-#
-# Create IDT.
-#
- movwir(idtctl,_si) # Control string
-init.1: lodsb # Get entry
- cwde # count
- xchgl %eax,%ecx # as word
- jecxz init.4 # If done
- lodsb # Get segment
- xchgl %eax,%edx # P:DPL:type
- lodsl # Get control
- xchgl %eax,%ebx # set
- lodsl # Get handler offset
- movb $SEL_SCODE,%dh # Segment selector
-init.2: shrl %ebx # Handle this int?
- jnc init.3 # No
- movwr0(_ax,_di_) # Set handler offset
- movbr1(_dh,0x2,_di_) # and selector
- movbr1(_dl,0x5,_di_) # Set P:DPL:type
- addwia(0x4) # Next handler
-init.3: leaw1r(0x8,_di_,_di) # Next entry
- loop init.2 # Till set done
- jmp init.1 # Continue
-#
-# Initialize TSS.
-#
-init.4: movbi1(_ESP0H,TSS_ESP0+1,_di_) # Set ESP0
- movbi1(SEL_SDATA,TSS_SS0,_di_) # Set SS0
- movbi1(_ESP1H,TSS_ESP1+1,_di_) # Set ESP1
- movbi1(_TSSIO,TSS_MAP,_di_) # Set I/O bit map base
-ifdef(`PAGING',`
-#
-# Create page directory.
-#
- xorw %dx,%dx # Page
- movb $PAG_SIZ>>0x8,%dh # size
- xorw %ax,%ax # Zero
- movwir(MEM_DIR,_di) # Page directory
- movb $PAG_CNT>>0xa,%cl # Entries
- movwir(MEM_TBL|0x7,_ax) # First entry
-init.5: stosw # Write entry
- addl %edx,%eax # To next
- loop init.5 # Till done
-#
-# Create page tables.
-#
- movwir(MEM_TBL,_di) # Page table
- movb $PAG_CNT>>0x8,%ch # Entries
- xorl %eax,%eax # Start address
-init.6: movb $0x7,%al # Set U:W:P flags
- cmpwmr(btx_hdr+0x8,_cx) # Standard user page?
- jb init.7 # Yes
- cmpwir(PAG_CNT-MEM_BTX>>0xc,_cx)# BTX memory?
- jae init.7 # No or first page
- andb $~0x2,%al # Clear W flag
- cmpwir(PAG_CNT-MEM_USR>>0xc,_cx)# User page zero?
- jne init.7 # No
- tstbim(0x80,btx_hdr+0x7) # Unmap it?
- jz init.7 # No
- andb $~0x1,%al # Clear P flag
-init.7: stosw # Set entry
- addw %dx,%ax # Next address
- loop init.6 # Till done
-')
-#
-# Bring up the system.
-#
- movwir(0x2820,_bx) # Set protected mode
- callwi(setpic) # IRQ offsets
- lidtwm(idtdesc) # Set IDT
-ifdef(`PAGING',`
- xorw %ax,%ax # Set base
- movb $MEM_DIR>>0x8,%ah # of page
- movl %eax,%cr3 # directory
-')
- lgdtwm(gdtdesc) # Set GDT
- movl %cr0,%eax # Switch to
-ifdef(`PAGING',`
- o16 # protected mode
- orl $0x80000001,%eax # and enable paging
-',`
- o16 # protected mode
- orl $0x01,%eax #
-')
- movl %eax,%cr0 #
- jmpfwi(SEL_SCODE,init.8) # To 32-bit code
-init.8: xorl %ecx,%ecx # Zero
- movb $SEL_SDATA,%cl # To 32-bit
- movl %cx,%ss # stack
-#
-# Launch user task.
-#
- movb $SEL_TSS,%cl # Set task
- ltrl %ecx # register
- movl $MEM_USR,%edx # User base address
- movzwl %ss:BDA_MEM,%eax # Get free memory
- shll $0xa,%eax # To bytes
- subl $0x1000,%eax # Less arg space
- subl %edx,%eax # Less base
- movb $SEL_UDATA,%cl # User data selector
- pushl %ecx # Set SS
- pushl %eax # Set ESP
- pushl $0x202 # Set flags (IF set)
- pushl $SEL_UCODE # Set CS
- pushl btx_hdr+0xc # Set EIP
- pushl %ecx # Set GS
- pushl %ecx # Set FS
- pushl %ecx # Set DS
- pushl %ecx # Set ES
- pushl %edx # Set EAX
- movb $0x7,%cl # Set remaining
-init.9: pushb $0x0 # general
- loop init.9 # registers
- popa # and initialize
- popl %es # Initialize
- popl %ds # user
- popl %fs # segment
- popl %gs # registers
- iret # To user mode
-#
-# Exit routine.
-#
-exit: cli # Disable interrupts
- movl $MEM_ESP0,%esp # Clear stack
-#
-# Turn off paging.
-#
- movl %cr0,%eax # Get CR0
-ifdef(`PAGING',`
- andl $~0x80000000,%eax # Disable
- movl %eax,%cr0 # paging
-')
- xorl %ecx,%ecx # Zero
-ifdef(`PAGING',`
- movl %ecx,%cr3 # Flush TLB
-')
-#
-# To 16 bits.
-#
- o16 # Reload
- jmpfwi(SEL_RCODE,exit.1) # CS
-exit.1: movb $SEL_RDATA,%cl # 16-bit selector
- movl %cx,%ss # Reload SS
- movl %cx,%ds # Load
- movl %cx,%es # remaining
- movl %cx,%fs # segment
- movl %cx,%gs # registers
-#
-# To real-address mode.
-#
- decl %eax # Switch to
- movl %eax,%cr0 # real mode
- jmpfwi(0x0,exit.2) # Reload CS
-exit.2: xorl %eax,%eax # Real mode segment
- movl %ax,%ss # Reload SS
- movl %ax,%ds # Address data
- movwir(0x7008,_bx) # Set real mode
- callwi(setpic) # IRQ offsets
- lidtwm(ivtdesc) # Set IVT
-#
-# Reboot or await reset.
-#
- sti # Enable interrupts
- tstbim(0x1,btx_hdr+0x7) # Reboot?
-exit.3: jz exit.3 # No
- .code16
- movw $0x1234, BDA_BOOT # Do a warm boot
- jmpfwi(0xffff,0x0) # reboot the machine
- .code32
-#
-# Set IRQ offsets by reprogramming 8259A PICs.
-#
-setpic: inb $0x21,%al # Save master
- pushl %eax # IMR
- inb $0xa1,%al # Save slave
- pushl %eax # IMR
- movb $0x11,%al # ICW1 to
- outb %al,$0x20 # master,
- outb %al,$0xa0 # slave
- movb %bl,%al # ICW2 to
- outb %al,$0x21 # master
- movb %bh,%al # ICW2 to
- outb %al,$0xa1 # slave
- movb $0x4,%al # ICW3 to
- outb %al,$0x21 # master
- movb $0x2,%al # ICW3 to
- outb %al,$0xa1 # slave
- movb $0x1,%al # ICW4 to
- outb %al,$0x21 # master,
- outb %al,$0xa1 # slave
- popl %eax # Restore slave
- outb %al,$0xa1 # IMR
- popl %eax # Restore master
- outb %al,$0x21 # IMR
- ret # To caller
-#
-# Initiate return from V86 mode to user mode.
-#
-inthlt: hlt # To supervisor mode
-#
-# Exception jump table.
-#
-intx00: pushb $0x0 # Int 0x0: #DE
- jmp ex_noc # Divide error
- pushb $0x1 # Int 0x1: #DB
- jmp ex_noc # Debug
- pushb $0x3 # Int 0x3: #BP
- jmp ex_noc # Breakpoint
- pushb $0x4 # Int 0x4: #OF
- jmp ex_noc # Overflow
- pushb $0x5 # Int 0x5: #BR
- jmp ex_noc # BOUND range exceeded
- pushb $0x6 # Int 0x6: #UD
- jmp ex_noc # Invalid opcode
- pushb $0x7 # Int 0x7: #NM
- jmp ex_noc # Device not available
- pushb $0x8 # Int 0x8: #DF
- jmp except # Double fault
- pushb $0xa # Int 0xa: #TS
- jmp except # Invalid TSS
- pushb $0xb # Int 0xb: #NP
- jmp except # Segment not present
- pushb $0xc # Int 0xc: #SS
- jmp except # Stack segment fault
- pushb $0xd # Int 0xd: #GP
- jmp ex_v86 # General protection
- pushb $0xe # Int 0xe: #PF
- jmp except # Page fault
-intx10: pushb $0x10 # Int 0x10: #MF
- jmp ex_noc # Floating-point error
-#
-# Handle #GP exception.
-#
-ex_v86: testb $0x2,0x12(%esp,1) # V86 mode?
- jz except # No
- jmp v86mon # To monitor
-#
-# Save a zero error code.
-#
-ex_noc: pushl (%esp,1) # Duplicate int no
- movb $0x0,0x4(%esp,1) # Fake error code
-#
-# Handle exception.
-#
-except: cld # String ops inc
- pushl %ds # Save
- pushl %es # most
- pusha # registers
- movb $0x6,%al # Push loop count
- testb $0x2,0x3a(%esp,1) # V86 mode?
- jnz except.1 # Yes
- pushl %gs # Set GS
- pushl %fs # Set FS
- pushl %ds # Set DS
- pushl %es # Set ES
- movb $0x2,%al # Push loop count
- cmpw $SEL_SCODE,0x44(%esp,1) # Supervisor mode?
- jne except.1 # No
- pushl %ss # Set SS
- leal 0x50(%esp,1),%eax # Set
- pushl %eax # ESP
- jmp except.2 # Join common code
-except.1: pushl 0x50(%esp,1) # Set GS, FS, DS, ES
- decb %al # (if V86 mode), and
- jne except.1 # SS, ESP
-except.2: pushl $SEL_SDATA # Set up
- popl %ds # to
- pushl %ds # address
- popl %es # data
- movl %esp,%ebx # Stack frame
- movl $dmpfmt,%esi # Dump format string
- movl $MEM_BUF,%edi # Buffer
- pushl %edi # Dump to
- call dump # buffer
- popl %esi # and
- call putstr # display
- leal 0x18(%esp,1),%esp # Discard frame
- popa # Restore
- popl %es # registers
- popl %ds # saved
- cmpb $0x3,(%esp,1) # Breakpoint?
- je except.3 # Yes
- jmp exit # Exit
-except.3: leal 0x8(%esp,1),%esp # Discard err, int no
- iret # From interrupt
-#
-# Return to user mode from V86 mode.
-#
-intrtn: cld # String ops inc
- pushl %ds # Address
- popl %es # data
- leal 0x3c(%ebp),%edx # V86 Segment registers
- movl MEM_TSS+TSS_ESP1,%esi # Link stack pointer
- lodsl # INT_V86 args pointer
- movl %esi,%ebx # Saved exception frame
- testl %eax,%eax # INT_V86 args?
- jz intrtn.2 # No
- movl $MEM_USR,%edi # User base
- movl 0x1c(%esi),%ebx # User ESP
- movl %eax,(%edi,%ebx,1) # Restore to user stack
- leal 0x8(%edi,%eax,1),%edi # Arg segment registers
- testb $0x4,-0x6(%edi) # Return flags?
- jz intrtn.1 # No
- movl 0x30(%ebp),%eax # Get V86 flags
- movw %ax,0x18(%esi) # Set user flags
-intrtn.1: leal 0x10(%esi),%ebx # Saved exception frame
- xchgl %edx,%esi # Segment registers
- movb $0x4,%cl # Update seg regs
- rep # in INT_V86
- movsl # args
-intrtn.2: movl %edx,%esi # Segment registers
- leal 0x28(%ebp),%edi # Set up seg
- movb $0x4,%cl # regs for
- rep # later
- movsl # pop
- movl %ebx,%esi # Restore exception
- movb $0x5,%cl # frame to
- rep # supervisor
- movsl # stack
- movl %esi,MEM_TSS+TSS_ESP1 # Link stack pointer
- popa # Restore
- leal 0x8(%esp,1),%esp # Discard err, int no
- popl %es # Restore
- popl %ds # user
- popl %fs # segment
- popl %gs # registers
- iret # To user mode
-#
-# V86 monitor.
-#
-v86mon: cld # String ops inc
- pushl $SEL_SDATA # Set up for
- popl %ds # flat addressing
- pusha # Save registers
- movl %esp,%ebp # Address stack frame
- movzwl 0x2c(%ebp),%edi # Load V86 CS
- shll $0x4,%edi # To linear
- movl 0x28(%ebp),%esi # Load V86 IP
- addl %edi,%esi # Code pointer
- xorl %ecx,%ecx # Zero
- movb $0x2,%cl # 16-bit operands
- xorl %eax,%eax # Zero
-v86mon.1: lodsb # Get opcode
- cmpb $0x66,%al # Operand size prefix?
- jne v86mon.2 # No
- movb $0x4,%cl # 32-bit operands
- jmp v86mon.1 # Continue
-v86mon.2: cmpb $0xf4,%al # HLT?
- jne v86mon.3 # No
- cmpl $inthlt+0x1,%esi # Is inthlt?
- jne v86mon.7 # No (ignore)
- jmp intrtn # Return to user mode
-v86mon.3: cmpb $0xf,%al # Is
- jne v86mon.4 # this
- cmpb $0x20,(%esi) # a
- jne v86mon.4 # MOV EAX,CR0
- cmpb $0xc0,0x1(%esi) # instruction?
- je v86mov # Yes
-v86mon.4: cmpb $0xfa,%al # CLI?
- je v86cli # Yes
- cmpb $0xfb,%al # STI?
- je v86sti # Yes
- movzwl 0x38(%ebp),%ebx # Load V86 SS
- shll $0x4,%ebx # To offset
- pushl %ebx # Save
- addl 0x34(%ebp),%ebx # Add V86 SP
- movl 0x30(%ebp),%edx # Load V86 flags
- cmpb $0x9c,%al # PUSHF/PUSHFD?
- je v86pushf # Yes
- cmpb $0x9d,%al # POPF/POPFD?
- je v86popf # Yes
- cmpb $0xcd,%al # INT imm8?
- je v86intn # Yes
- cmpb $0xcf,%al # IRET/IRETD?
- je v86iret # Yes
- popl %ebx # Restore
- popa # Restore
- jmp except # Handle exception
-v86mon.5: movl %edx,0x30(%ebp) # Save V86 flags
-v86mon.6: popl %edx # V86 SS adjustment
- subl %edx,%ebx # Save V86
- movl %ebx,0x34(%ebp) # SP
-v86mon.7: subl %edi,%esi # From linear
- movl %esi,0x28(%ebp) # Save V86 IP
- popa # Restore
- leal 0x8(%esp,1),%esp # Discard int no, error
- iret # To V86 mode
-#
-# Emulate MOV EAX,CR0.
-#
-v86mov: movl %cr0,%eax # CR0 to
- movl %eax,0x1c(%ebp) # saved EAX
- incl %esi # Adjust
- incl %esi # IP
- jmp v86mon.7 # Finish up
-#
-# Emulate CLI.
-#
-v86cli: andb $~0x2,0x31(%ebp) # Clear IF
- jmp v86mon.7 # Finish up
-#
-# Emulate STI.
-#
-v86sti: orb $0x2,0x31(%ebp) # Set IF
- jmp v86mon.7 # Finish up
-#
-# Emulate PUSHF/PUSHFD.
-#
-v86pushf: subl %ecx,%ebx # Adjust SP
- cmpb $0x4,%cl # 32-bit
- je v86pushf.1 # Yes
- o16 # 16-bit
-v86pushf.1: movl %edx,(%ebx) # Save flags
- jmp v86mon.6 # Finish up
-#
-# Emulate IRET/IRETD.
-#
-v86iret: movzwl (%ebx),%esi # Load V86 IP
- movzwl 0x2(%ebx),%edi # Load V86 CS
- leal 0x4(%ebx),%ebx # Adjust SP
- movl %edi,0x2c(%ebp) # Save V86 CS
- xorl %edi,%edi # No ESI adjustment
-#
-# Emulate POPF/POPFD (and remainder of IRET/IRETD).
-#
-v86popf: cmpb $0x4,%cl # 32-bit?
- je v86popf.1 # Yes
- movl %edx,%eax # Initialize
- o16 # 16-bit
-v86popf.1: movl (%ebx),%eax # Load flags
- addl %ecx,%ebx # Adjust SP
- andl $V86_FLG,%eax # Merge
- andl $~V86_FLG,%edx # the
- orl %eax,%edx # flags
- jmp v86mon.5 # Finish up
-#
-# trap int 15, function 87
-# reads %es:%si from saved registers on stack to find a GDT containing
-# source and destination locations
-# reads count of words from saved %cx
-# returns success by setting %ah to 0
-#
-int15_87: pushl %eax # Save
- pushl %ebx # some information
- pushl %esi # onto the stack.
- pushl %edi
- xorl %eax,%eax # clean EAX
- xorl %ebx,%ebx # clean EBX
- movl 0x4(%ebp),%esi # Get user's ESI
- movl 0x3C(%ebp),%ebx # store ES
- movw %si,%ax # store SI
- shll $0x4,%ebx # Make it a seg.
- addl %eax,%ebx # ebx=(es<<4)+si
- movb 0x14(%ebx),%al # Grab the
- movb 0x17(%ebx),%ah # necessary
- shll $0x10,%eax # information
- movw 0x12(%ebx),%ax # from
- movl %eax,%esi # the
- movb 0x1c(%ebx),%al # GDT in order to
- movb 0x1f(%ebx),%ah # have %esi offset
- shll $0x10,%eax # of source and %edi
- movw 0x1a(%ebx),%ax # of destination.
- movl %eax,%edi
- pushl %ds # Make:
- popl %es # es = ds
- pushl %ecx # stash ECX
- xorl %ecx,%ecx # highw of ECX is clear
- movw 0x18(%ebp),%cx # Get user's ECX
- shll $0x1,%ecx # Convert from num words to num
- # bytes
- rep # repeat...
- movsb # perform copy.
- popl %ecx # Restore
- popl %edi
- popl %esi # previous
- popl %ebx # register
- popl %eax # values.
- movb $0x0,0x1d(%ebp) # set ah = 0 to indicate
- # success
- andb $0xfe,%dl # clear CF
- jmp v86mon.5 # Finish up
-
-#
-# Reboot the machine by setting the reboot flag and exiting
-#
-reboot: orb $0x1,btx_hdr+0x7 # Set the reboot flag
- jmp exit # Terminate BTX and reboot
-
-#
-# Emulate INT imm8... also make sure to check if it's int 15/87
-#
-v86intn: lodsb # Get int no
- cmpb $0x19,%al # is it int 19?
- je reboot # yes, reboot the machine
- cmpb $0x15,%al # is it int 15?
- jne v86intn.3 # no, skip parse
- pushl %eax # stash EAX
- movl 0x1c(%ebp),%eax # user's saved EAX
- cmpb $0x87,%ah # is it the memcpy subfunction?
- jne v86intn.1 # no, keep checking
- popl %eax # get the stack straight
- jmp int15_87 # it's our cue
-v86intn.1: cmpw $0x4f53,%ax # is it the delete key callout?
- jne v86intn.2 # no, handle the int normally
- movb BDA_KEYFLAGS,%al # get the shift key state
- andb $0xc,%al # mask off just Ctrl and Alt
- cmpb $0xc,%al # are both Ctrl and Alt down?
- jne v86intn.2 # no, handle the int normally
- popl %eax # restore EAX
- jmp reboot # reboot the machine
-v86intn.2: popl %eax # restore EAX
-v86intn.3: subl %edi,%esi # From
- shrl $0x4,%edi # linear
- movw %dx,-0x2(%ebx) # Save flags
- movw %di,-0x4(%ebx) # Save CS
- leal -0x6(%ebx),%ebx # Adjust SP
- movw %si,(%ebx) # Save IP
- shll $0x2,%eax # Scale
- movzwl (%eax),%esi # Load IP
- movzwl 0x2(%eax),%edi # Load CS
- movl %edi,0x2c(%ebp) # Save CS
- xorl %edi,%edi # No ESI adjustment
- andb $~0x3,%dh # Clear IF and TF
- jmp v86mon.5 # Finish up
-#
-# Hardware interrupt jump table.
-#
-intx20: pushb $0x8 # Int 0x20: IRQ0
- jmp int_hw # V86 int 0x8
- pushb $0x9 # Int 0x21: IRQ1
- jmp int_hw # V86 int 0x9
- pushb $0xa # Int 0x22: IRQ2
- jmp int_hw # V86 int 0xa
- pushb $0xb # Int 0x23: IRQ3
- jmp int_hw # V86 int 0xb
- pushb $0xc # Int 0x24: IRQ4
- jmp int_hw # V86 int 0xc
- pushb $0xd # Int 0x25: IRQ5
- jmp int_hw # V86 int 0xd
- pushb $0xe # Int 0x26: IRQ6
- jmp int_hw # V86 int 0xe
- pushb $0xf # Int 0x27: IRQ7
- jmp int_hw # V86 int 0xf
- pushb $0x70 # Int 0x28: IRQ8
- jmp int_hw # V86 int 0x70
- pushb $0x71 # Int 0x29: IRQ9
- jmp int_hw # V86 int 0x71
- pushb $0x72 # Int 0x2a: IRQ10
- jmp int_hw # V86 int 0x72
- pushb $0x73 # Int 0x2b: IRQ11
- jmp int_hw # V86 int 0x73
- pushb $0x74 # Int 0x2c: IRQ12
- jmp int_hw # V86 int 0x74
- pushb $0x75 # Int 0x2d: IRQ13
- jmp int_hw # V86 int 0x75
- pushb $0x76 # Int 0x2e: IRQ14
- jmp int_hw # V86 int 0x76
- pushb $0x77 # Int 0x2f: IRQ15
- jmp int_hw # V86 int 0x77
-#
-# Reflect hardware interrupts.
-#
-int_hw: testb $0x2,0xe(%esp,1) # V86 mode?
- jz intusr # No
- pushl $SEL_SDATA # Address
- popl %ds # data
- xchgl %eax,(%esp,1) # Swap EAX, int no
- pushl %ebp # Address
- movl %esp,%ebp # stack frame
- pushl %ebx # Save
- shll $0x2,%eax # Get int
- movl (%eax),%eax # vector
- subl $0x6,0x14(%ebp) # Adjust V86 ESP
- movzwl 0x18(%ebp),%ebx # V86 SS
- shll $0x4,%ebx # * 0x10
- addl 0x14(%ebp),%ebx # + V86 ESP
- xchgw %ax,0x8(%ebp) # Swap V86 IP
- rorl $0x10,%eax # Swap words
- xchgw %ax,0xc(%ebp) # Swap V86 CS
- roll $0x10,%eax # Swap words
- movl %eax,(%ebx) # CS:IP for IRET
- movl 0x10(%ebp),%eax # V86 flags
- movw %ax,0x4(%ebx) # Flags for IRET
- andb $~0x3,0x11(%ebp) # Clear IF, TF
- popl %ebx # Restore
- popl %ebp # saved
- popl %eax # registers
- iret # To V86 mode
-#
-# Invoke V86 interrupt from user mode, with arguments.
-#
-intx31: stc # Have btx_v86
- pushl %eax # Missing int no
-#
-# Invoke V86 interrupt from user mode.
-#
-intusr: std # String ops dec
- pushl %eax # Expand
- pushl %eax # stack
- pushl %eax # frame
- pusha # Save
- pushl %gs # Save
- movl %esp,%eax # seg regs
- pushl %fs # and
- pushl %ds # point
- pushl %es # to them
- pushb $SEL_SDATA # Set up
- popl %ds # to
- pushl %ds # address
- popl %es # data
- movl $MEM_USR,%ebx # User base
- movl %ebx,%edx # address
- jc intusr.1 # If btx_v86
- xorl %edx,%edx # Control flags
- xorl %ebp,%ebp # btx_v86 pointer
-intusr.1: leal 0x50(%esp,1),%esi # Base of frame
- pushl %esi # Save
- addl -0x4(%esi),%ebx # User ESP
- movl MEM_TSS+TSS_ESP1,%edi # Link stack pointer
- leal -0x4(%edi),%edi # Adjust for push
- xorl %ecx,%ecx # Zero
- movb $0x5,%cl # Push exception
- rep # frame on
- movsl # link stack
- xchgl %eax,%esi # Saved seg regs
- movl 0x40(%esp,1),%eax # Get int no
- testl %edx,%edx # Have btx_v86?
- jz intusr.2 # No
- movl (%ebx),%ebp # btx_v86 pointer
- movb $0x4,%cl # Count
- addl %ecx,%ebx # Adjust for pop
- rep # Push saved seg regs
- movsl # on link stack
- addl %ebp,%edx # Flatten btx_v86 ptr
- leal 0x14(%edx),%esi # Seg regs pointer
- movl 0x4(%edx),%eax # Get int no/address
- movzwl 0x2(%edx),%edx # Get control flags
-intusr.2: movl %ebp,(%edi) # Push btx_v86 and
- movl %edi,MEM_TSS+TSS_ESP1 # save link stack ptr
- popl %edi # Base of frame
- xchgl %eax,%ebp # Save intno/address
- movl 0x48(%esp,1),%eax # Get flags
- testb $0x2,%dl # Simulate CALLF?
- jnz intusr.3 # Yes
- decl %ebx # Push flags
- decl %ebx # on V86
- movw %ax,(%ebx) # stack
-intusr.3: movb $0x4,%cl # Count
- subl %ecx,%ebx # Push return address
- movl $inthlt,(%ebx) # on V86 stack
- rep # Copy seg regs to
- movsl # exception frame
- xchgl %eax,%ecx # Save flags
- movl %ebx,%eax # User ESP
- subl $V86_STK,%eax # Less bytes
- ja intusr.4 # to
- xorl %eax,%eax # keep
-intusr.4: shrl $0x4,%eax # Gives segment
- stosl # Set SS
- shll $0x4,%eax # To bytes
- xchgl %eax,%ebx # Swap
- subl %ebx,%eax # Gives offset
- stosl # Set ESP
- xchgl %eax,%ecx # Get flags
- btsl $0x11,%eax # Set VM
- andb $~0x3,%ah # Clear IF and TF
- stosl # Set EFL
- xchgl %eax,%ebp # Get int no/address
- testb $0x1,%dl # Address?
- jnz intusr.5 # Yes
- shll $0x2,%eax # Scale
- movl (%eax),%eax # Load int vector
-intusr.5: movl %eax,%ecx # Save
- shrl $0x10,%eax # Gives segment
- stosl # Set CS
- movw %cx,%ax # Restore
- stosl # Set EIP
- leal 0x10(%esp,1),%esp # Discard seg regs
- popa # Restore
- iret # To V86 mode
-#
-# System Call.
-#
-intx30: cmpl $SYS_EXEC,%eax # Exec system call?
- jne intx30.1 # No
- pushl %ss # Set up
- popl %es # all
- pushl %es # segment
- popl %ds # registers
- pushl %ds # for the
- popl %fs # program
- pushl %fs # we're
- popl %gs # invoking
- movl $MEM_USR,%eax # User base address
- addl 0xc(%esp,1),%eax # Change to user
- leal 0x4(%eax),%esp # stack
-ifdef(`PAGING',`
- movl %cr0,%eax # Turn
- andl $~0x80000000,%eax # off
- movl %eax,%cr0 # paging
- xorl %eax,%eax # Flush
- movl %eax,%cr3 # TLB
-')
- popl %eax # Call
- call *%eax # program
-intx30.1: incb %ss:btx_hdr+0x7 # Flag reboot
- jmp exit # Exit
-#
-# Dump structure [EBX] to [EDI], using format string [ESI].
-#
-dump.0: stosb # Save char
-dump: lodsb # Load char
- testb %al,%al # End of string?
- jz dump.10 # Yes
- testb $0x80,%al # Control?
- jz dump.0 # No
- movb %al,%ch # Save control
- movb $'=',%al # Append
- stosb # '='
- lodsb # Get offset
- pushl %esi # Save
- movsbl %al,%esi # To
- addl %ebx,%esi # pointer
- testb $DMP_X16,%ch # Dump word?
- jz dump.1 # No
- lodsw # Get and
- call hex16 # dump it
-dump.1: testb $DMP_X32,%ch # Dump long?
- jz dump.2 # No
- lodsl # Get and
- call hex32 # dump it
-dump.2: testb $DMP_MEM,%ch # Dump memory?
- jz dump.8 # No
- pushl %ds # Save
- testb $0x2,0x52(%ebx) # V86 mode?
- jnz dump.3 # Yes
- verrl 0x4(%esi) # Readable selector?
- jnz dump.3 # No
- ldsl (%esi),%esi # Load pointer
- jmp dump.4 # Join common code
-dump.3: lodsl # Set offset
- xchgl %eax,%edx # Save
- lodsl # Get segment
- shll $0x4,%eax # * 0x10
- addl %edx,%eax # + offset
- xchgl %eax,%esi # Set pointer
-dump.4: movb $0x10,%cl # Bytes to dump
-dump.5: lodsb # Get byte and
- call hex8 # dump it
- decb %cl # Keep count
- jz dump.7 # If done
- movb $'-',%al # Separator
- cmpb $0x8,%cl # Half way?
- je dump.6 # Yes
- movb $' ',%al # Use space
-dump.6: stosb # Save separator
- jmp dump.5 # Continue
-dump.7: popl %ds # Restore
-dump.8: popl %esi # Restore
- movb $0xa,%al # Line feed
- testb $DMP_EOL,%ch # End of line?
- jnz dump.9 # Yes
- movb $' ',%al # Use spaces
- stosb # Save one
-dump.9: jmp dump.0 # Continue
-dump.10: stosb # Terminate string
- ret # To caller
-#
-# Convert EAX, AX, or AL to hex, saving the result to [EDI].
-#
-hex32: pushl %eax # Save
- shrl $0x10,%eax # Do upper
- call hex16 # 16
- popl %eax # Restore
-hex16: call hex16.1 # Do upper 8
-hex16.1: xchgb %ah,%al # Save/restore
-hex8: pushl %eax # Save
- shrb $0x4,%al # Do upper
- call hex8.1 # 4
- popl %eax # Restore
-hex8.1: andb $0xf,%al # Get lower 4
- cmpb $0xa,%al # Convert
- sbbb $0x69,%al # to hex
- das # digit
- orb $0x20,%al # To lower case
- stosb # Save char
- ret # (Recursive)
-#
-# Output zero-terminated string [ESI] to the console.
-#
-putstr.0: call putchr # Output char
-putstr: lodsb # Load char
- testb %al,%al # End of string?
- jnz putstr.0 # No
- ret # To caller
-#
-# Output character AL to the console.
-#
-putchr: pusha # Save
- xorl %ecx,%ecx # Zero for loops
- movb $SCR_MAT,%ah # Mode/attribute
- movl $BDA_POS,%ebx # BDA pointer
- movw (%ebx),%dx # Cursor position
- movl $0xb8000,%edi # Regen buffer (color)
- cmpb %ah,BDA_SCR-BDA_POS(%ebx) # Mono mode?
- jne putchr.1 # No
- xorw %di,%di # Regen buffer (mono)
-putchr.1: cmpb $0xa,%al # New line?
- je putchr.2 # Yes
- xchgl %eax,%ecx # Save char
- movb $SCR_COL,%al # Columns per row
- mulb %dh # * row position
- addb %dl,%al # + column
- adcb $0x0,%ah # position
- shll %eax # * 2
- xchgl %eax,%ecx # Swap char, offset
- movw %ax,(%edi,%ecx,1) # Write attr:char
- incl %edx # Bump cursor
- cmpb $SCR_COL,%dl # Beyond row?
- jb putchr.3 # No
-putchr.2: xorb %dl,%dl # Zero column
- incb %dh # Bump row
-putchr.3: cmpb $SCR_ROW,%dh # Beyond screen?
- jb putchr.4 # No
- leal 2*SCR_COL(%edi),%esi # New top line
- movw $(SCR_ROW-1)*SCR_COL/2,%cx # Words to move
- rep # Scroll
- movsl # screen
- movb $' ',%al # Space
- movb $SCR_COL,%cl # Columns to clear
- rep # Clear
- stosw # line
- movb $SCR_ROW-1,%dh # Bottom line
-putchr.4: movw %dx,(%ebx) # Update position
- popa # Restore
- ret # To caller
-
- .p2align 4
-#
-# Global descriptor table.
-#
-gdt: .word 0x0,0x0,0x0,0x0 # Null entry
- .word 0xffff,0x0,0x9a00,0xcf # SEL_SCODE
- .word 0xffff,0x0,0x9200,0xcf # SEL_SDATA
- .word 0xffff,0x0,0x9a00,0x0 # SEL_RCODE
- .word 0xffff,0x0,0x9200,0x0 # SEL_RDATA
- .word 0xffff,MEM_USR,0xfa00,0xcf# SEL_UCODE
- .word 0xffff,MEM_USR,0xf200,0xcf# SEL_UDATA
- .word _TSSLM,MEM_TSS,0x8900,0x0 # SEL_TSS
-gdt.1:
-#
-# Pseudo-descriptors.
-#
-gdtdesc: .word gdt.1-gdt-1,gdt,0x0 # GDT
-idtdesc: .word _IDTLM,MEM_IDT,0x0 # IDT
-ivtdesc: .word 0x400-0x0-1,0x0,0x0 # IVT
-#
-# IDT construction control string.
-#
-idtctl: .byte 0x10, 0x8e # Int 0x0-0xf
- .word 0x7dfb,intx00 # (exceptions)
- .byte 0x10, 0x8e # Int 0x10
- .word 0x1, intx10 # (exception)
- .byte 0x10, 0x8e # Int 0x20-0x2f
- .word 0xffff,intx20 # (hardware)
- .byte 0x1, 0xee # int 0x30
- .word 0x1, intx30 # (system call)
- .byte 0x2, 0xee # Int 0x31-0x32
- .word 0x1, intx31 # (V86, null)
- .byte 0x0 # End of string
-#
-# Dump format string.
-#
-dmpfmt: .byte '\n' # "\n"
- .ascii "int" # "int="
- .byte 0x80|DMP_X32, 0x40 # "00000000 "
- .ascii "err" # "err="
- .byte 0x80|DMP_X32, 0x44 # "00000000 "
- .ascii "efl" # "efl="
- .byte 0x80|DMP_X32, 0x50 # "00000000 "
- .ascii "eip" # "eip="
- .byte 0x80|DMP_X32|DMP_EOL,0x48 # "00000000\n"
- .ascii "eax" # "eax="
- .byte 0x80|DMP_X32, 0x34 # "00000000 "
- .ascii "ebx" # "ebx="
- .byte 0x80|DMP_X32, 0x28 # "00000000 "
- .ascii "ecx" # "ecx="
- .byte 0x80|DMP_X32, 0x30 # "00000000 "
- .ascii "edx" # "edx="
- .byte 0x80|DMP_X32|DMP_EOL,0x2c # "00000000\n"
- .ascii "esi" # "esi="
- .byte 0x80|DMP_X32, 0x1c # "00000000 "
- .ascii "edi" # "edi="
- .byte 0x80|DMP_X32, 0x18 # "00000000 "
- .ascii "ebp" # "ebp="
- .byte 0x80|DMP_X32, 0x20 # "00000000 "
- .ascii "esp" # "esp="
- .byte 0x80|DMP_X32|DMP_EOL,0x0 # "00000000\n"
- .ascii "cs" # "cs="
- .byte 0x80|DMP_X16, 0x4c # "0000 "
- .ascii "ds" # "ds="
- .byte 0x80|DMP_X16, 0xc # "0000 "
- .ascii "es" # "es="
- .byte 0x80|DMP_X16, 0x8 # "0000 "
- .ascii " " # " "
- .ascii "fs" # "fs="
- .byte 0x80|DMP_X16, 0x10 # "0000 "
- .ascii "gs" # "gs="
- .byte 0x80|DMP_X16, 0x14 # "0000 "
- .ascii "ss" # "ss="
- .byte 0x80|DMP_X16|DMP_EOL,0x4 # "0000\n"
- .ascii "cs:eip" # "cs:eip="
- .byte 0x80|DMP_MEM|DMP_EOL,0x48 # "00 00 ... 00 00\n"
- .ascii "ss:esp" # "ss:esp="
- .byte 0x80|DMP_MEM|DMP_EOL,0x0 # "00 00 ... 00 00\n"
- .asciz "System halted" # End
-#
-# End of BTX memory.
-#
- .p2align 4
-break:
diff --git a/sys/boot/i386/btx/btxldr/btxldr.S b/sys/boot/i386/btx/btxldr/btxldr.S
deleted file mode 100644
index d506a625ed86..000000000000
--- a/sys/boot/i386/btx/btxldr/btxldr.S
+++ /dev/null
@@ -1,386 +0,0 @@
-#
-# Copyright (c) 1998 Robert Nordier
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms are freely
-# permitted provided that the above copyright notice and this
-# paragraph and the following disclaimer are duplicated in all
-# such forms.
-#
-# This software is provided "AS IS" and without any express or
-# implied warranties, including, without limitation, the implied
-# warranties of merchantability and fitness for a particular
-# purpose.
-#
-
-# $FreeBSD$
-
-#
-# Prototype BTX loader program, written in a couple of hours. The
-# real thing should probably be more flexible, and in C.
-#
-
-#
-# Memory locations.
-#
- .set MEM_STUB,0x600 # Real mode stub
- .set MEM_ESP,0x1000 # New stack pointer
- .set MEM_TBL,0x5000 # BTX page tables
- .set MEM_ENTRY,0x9010 # BTX entry point
- .set MEM_DATA,0x101000 # Data segment
-#
-# Segment selectors.
-#
- .set SEL_SCODE,0x8 # 4GB code
- .set SEL_SDATA,0x10 # 4GB data
- .set SEL_RCODE,0x18 # 64K code
- .set SEL_RDATA,0x20 # 64K data
-#
-# Paging constants.
-#
- .set PAG_SIZ,0x1000 # Page size
- .set PAG_ENT,0x4 # Page entry size
-#
-# Screen constants.
-#
- .set SCR_MAT,0x7 # Mode/attribute
- .set SCR_COL,0x50 # Columns per row
- .set SCR_ROW,0x19 # Rows per screen
-#
-# BIOS Data Area locations.
-#
- .set BDA_MEM,0x413 # Free memory
- .set BDA_SCR,0x449 # Video mode
- .set BDA_POS,0x450 # Cursor position
-#
-# Required by aout gas inadequacy.
-#
- .set SIZ_STUB,0x1a # Size of stub
-#
-# We expect to be loaded by boot2 at 0x100000.
-#
- .globl start
-#
-# BTX program loader for ELF clients.
-#
-start: cld # String ops inc
- movl $m_logo,%esi # Identify
- call putstr # ourselves
- movzwl BDA_MEM,%eax # Get base memory
- shll $0xa,%eax # in bytes
- movl %eax,%ebp # Base of user stack
- movl $m_mem,%esi # Display
- call dhexout # amount of
- call dputstr # base memory
- lgdt gdtdesc # Load new GDT
-#
-# Relocate caller's arguments.
-#
- movl $m_esp,%esi # Display
- movl %esp,%eax # caller's
- call dhexout # stack
- call dputstr # pointer
- movl $m_args,%esi # Format string
- leal 0x4(%esp,1),%ebx # First argument
- movl $0x6,%ecx # Count
-start.1: movl (%ebx),%eax # Get argument and
- addl $0x4,%ebx # bump pointer
- call dhexout # Display it
- loop start.1 # Till done
- call dputstr # End message
- movl $0x48,%ecx # Allocate space
- subl %ecx,%ebp # for bootinfo
- movl 0x18(%esp,1),%esi # Source: bootinfo
- cmpl $0x0, %esi # If the bootinfo pointer
- je start_null_bi # is null, don't copy it
- movl %ebp,%edi # Destination
- rep # Copy
- movsb # it
- movl %ebp,0x18(%esp,1) # Update pointer
- movl $m_rel_bi,%esi # Display
- movl %ebp,%eax # bootinfo
- call dhexout # relocation
- call dputstr # message
-start_null_bi: movl $0x18,%ecx # Allocate space
- subl %ecx,%ebp # for arguments
- leal 0x4(%esp,1),%esi # Source
- movl %ebp,%edi # Destination
- rep # Copy
- movsb # them
- movl $m_rel_args,%esi # Display
- movl %ebp,%eax # argument
- call dhexout # relocation
- call dputstr # message
-#
-# Set up BTX kernel.
-#
- movl $MEM_ESP,%esp # Set up new stack
- movl $MEM_DATA,%ebx # Data segment
- movl $m_vers,%esi # Display BTX
- call putstr # version message
- movb 0x5(%ebx),%al # Get major version
- addb $'0',%al # Display
- call putchr # it
- movb $'.',%al # And a
- call putchr # dot
- movb 0x6(%ebx),%al # Get minor
- xorb %ah,%ah # version
- movb $0xa,%dl # Divide
- divb %dl,%al # by 10
- addb $'0',%al # Display
- call putchr # tens
- movb %ah,%al # Get units
- addb $'0',%al # Display
- call putchr # units
- call putstr # End message
- movl %ebx,%esi # BTX image
- movzwl 0x8(%ebx),%edi # Compute
- orl $PAG_SIZ/PAG_ENT-1,%edi # the
- incl %edi # BTX
- shll $0x2,%edi # load
- addl $MEM_TBL,%edi # address
- pushl %edi # Save
- movzwl 0xa(%ebx),%ecx # Image size
- pushl %ecx # Save
- rep # Relocate
- movsb # BTX
- movl %esi,%ebx # Keep place
- movl $m_rel_btx,%esi # Restore
- popl %eax # parameters
- call dhexout # and
- popl %ebp # display
- movl %ebp,%eax # the
- call dhexout # relocation
- call dputstr # message
- addl $PAG_SIZ,%ebp # Display
- movl $m_base,%esi # the
- movl %ebp,%eax # user
- call dhexout # base
- call dputstr # address
-#
-# Set up ELF-format client program.
-#
- cmpl $0x464c457f,(%ebx) # ELF magic number?
- je start.3 # Yes
- movl $e_fmt,%esi # Display error
- call putstr # message
-start.2: jmp start.2 # Hang
-start.3: movl $m_elf,%esi # Display ELF
- call dputstr # message
- movl $m_segs,%esi # Format string
- movl $0x2,%edi # Segment count
- movl 0x1c(%ebx),%edx # Get e_phoff
- addl %ebx,%edx # To pointer
- movzwl 0x2c(%ebx),%ecx # Get e_phnum
-start.4: cmpl $0x1,(%edx) # Is p_type PT_LOAD?
- jne start.6 # No
- movl 0x4(%edx),%eax # Display
- call dhexout # p_offset
- movl 0x8(%edx),%eax # Display
- call dhexout # p_vaddr
- movl 0x10(%edx),%eax # Display
- call dhexout # p_filesz
- movl 0x14(%edx),%eax # Display
- call dhexout # p_memsz
- call dputstr # End message
- pushl %esi # Save
- pushl %edi # working
- pushl %ecx # registers
- movl 0x4(%edx),%esi # Get p_offset
- addl %ebx,%esi # as pointer
- movl 0x8(%edx),%edi # Get p_vaddr
- addl %ebp,%edi # as pointer
- movl 0x10(%edx),%ecx # Get p_filesz
- rep # Set up
- movsb # segment
- movl 0x14(%edx),%ecx # Any bytes
- subl 0x10(%edx),%ecx # to zero?
- jz start.5 # No
- xorb %al,%al # Then
- rep # zero
- stosb # them
-start.5: popl %ecx # Restore
- popl %edi # working
- popl %esi # registers
- decl %edi # Segments to do
- je start.7 # If none
-start.6: addl $0x20,%edx # To next entry
- loop start.4 # Till done
-start.7: movl $m_done,%esi # Display done
- call dputstr # message
- movl $start.8,%esi # Real mode stub
- movl $MEM_STUB,%edi # Destination
- movl $SIZ_STUB,%ecx # Size
- rep # Relocate
- movsb # it
- ljmp $SEL_RCODE,$MEM_STUB # To 16-bit code
-start.8: xorl %eax,%eax # Data
- movb $SEL_RDATA,%al # selector
- movl %eax,%ss # Reload SS
- movl %eax,%ds # Reset
- movl %eax,%es # other
- movl %eax,%fs # segment
- movl %eax,%gs # limits
- movl %cr0,%eax # Switch to
- decl %eax # real
- movl %eax,%cr0 # mode
- .byte 0xea # Jump to
- .word MEM_ENTRY # BTX entry
- .word 0x0 # point
-start.9:
-#
-# Output message [ESI] followed by EAX in hex.
-#
-dhexout:
-#ifndef BTXLDR_VERBOSE
- ret
-#endif
-hexout: pushl %eax # Save
- call putstr # Display message
- popl %eax # Restore
- pushl %esi # Save
- pushl %edi # caller's
- movl $buf,%edi # Buffer
- pushl %edi # Save
- call hex32 # To hex
- xorb %al,%al # Terminate
- stosb # string
- popl %esi # Restore
-hexout.1: lodsb # Get a char
- cmpb $'0',%al # Leading zero?
- je hexout.1 # Yes
- testb %al,%al # End of string?
- jne hexout.2 # No
- decl %esi # Undo
-hexout.2: decl %esi # Adjust for inc
- call putstr # Display hex
- popl %edi # Restore
- popl %esi # caller's
- ret # To caller
-#
-# Output zero-terminated string [ESI] to the console.
-#
-dputstr:
-#ifndef BTXLDR_VERBOSE
- ret
-#else
- jmp putstr
-#endif
-putstr.0: call putchr # Output char
-putstr: lodsb # Load char
- testb %al,%al # End of string?
- jne putstr.0 # No
- ret # To caller
-#
-# Output character AL to the console.
-#
-dputchr:
-#ifndef BTXLDR_VERBOSE
- ret
-#endif
-putchr: pusha # Save
- xorl %ecx,%ecx # Zero for loops
- movb $SCR_MAT,%ah # Mode/attribute
- movl $BDA_POS,%ebx # BDA pointer
- movw (%ebx),%dx # Cursor position
- movl $0xb8000,%edi # Regen buffer (color)
- cmpb %ah,BDA_SCR-BDA_POS(%ebx) # Mono mode?
- jne putchr.1 # No
- xorw %di,%di # Regen buffer (mono)
-putchr.1: cmpb $0xa,%al # New line?
- je putchr.2 # Yes
- xchgl %eax,%ecx # Save char
- movb $SCR_COL,%al # Columns per row
- mulb %dh # * row position
- addb %dl,%al # + column
- adcb $0x0,%ah # position
- shll %eax # * 2
- xchgl %eax,%ecx # Swap char, offset
- movw %ax,(%edi,%ecx,1) # Write attr:char
- incl %edx # Bump cursor
- cmpb $SCR_COL,%dl # Beyond row?
- jb putchr.3 # No
-putchr.2: xorb %dl,%dl # Zero column
- incb %dh # Bump row
-putchr.3: cmpb $SCR_ROW,%dh # Beyond screen?
- jb putchr.4 # No
- leal 2*SCR_COL(%edi),%esi # New top line
- movw $(SCR_ROW-1)*SCR_COL/2,%cx # Words to move
- rep # Scroll
- movsl # screen
- movb $' ',%al # Space
- movb $SCR_COL,%cl # Columns to clear
- rep # Clear
- stosw # line
- movb $SCR_ROW-1,%dh # Bottom line
-putchr.4: movw %dx,(%ebx) # Update position
- popa # Restore
- ret # To caller
-#
-# Convert EAX, AX, or AL to hex, saving the result to [EDI].
-#
-hex32: pushl %eax # Save
- shrl $0x10,%eax # Do upper
- call hex16 # 16
- popl %eax # Restore
-hex16: call hex16.1 # Do upper 8
-hex16.1: xchgb %ah,%al # Save/restore
-hex8: pushl %eax # Save
- shrb $0x4,%al # Do upper
- call hex8.1 # 4
- popl %eax # Restore
-hex8.1: andb $0xf,%al # Get lower 4
- cmpb $0xa,%al # Convert
- sbbb $0x69,%al # to hex
- das # digit
- orb $0x20,%al # To lower case
- stosb # Save char
- ret # (Recursive)
-
- .data
- .p2align 4
-#
-# Global descriptor table.
-#
-gdt: .word 0x0,0x0,0x0,0x0 # Null entry
- .word 0xffff,0x0,0x9a00,0xcf # SEL_SCODE
- .word 0xffff,0x0,0x9200,0xcf # SEL_SDATA
- .word 0xffff,0x0,0x9a00,0x0 # SEL_RCODE
- .word 0xffff,0x0,0x9200,0x0 # SEL_RDATA
-gdt.1:
-gdtdesc: .word gdt.1-gdt-1 # Limit
- .long gdt # Base
-#
-# Messages.
-#
-m_logo: .asciz " \nBTX loader 1.00 "
-m_vers: .asciz "BTX version is \0\n"
-e_fmt: .asciz "Error: Client format not supported\n"
-#ifdef BTXLDR_VERBOSE
-m_mem: .asciz "Starting in protected mode (base mem=\0)\n"
-m_esp: .asciz "Arguments passed (esp=\0):\n"
-m_args: .asciz"<howto="
- .asciz" bootdev="
- .asciz" junk="
- .asciz" "
- .asciz" "
- .asciz" bootinfo=\0>\n"
-m_rel_bi: .asciz "Relocated bootinfo (size=48) to \0\n"
-m_rel_args: .asciz "Relocated arguments (size=18) to \0\n"
-m_rel_btx: .asciz "Relocated kernel (size=\0) to \0\n"
-m_base: .asciz "Client base address is \0\n"
-m_elf: .asciz "Client format is ELF\n"
-m_segs: .asciz "text segment: offset="
- .asciz " vaddr="
- .asciz " filesz="
- .asciz " memsz=\0\n"
- .asciz "data segment: offset="
- .asciz " vaddr="
- .asciz " filesz="
- .asciz " memsz=\0\n"
-m_done: .asciz "Loading complete\n"
-#endif
-#
-# Uninitialized data area.
-#
-buf: # Scratch buffer
diff --git a/sys/boot/i386/cdboot/Makefile b/sys/boot/i386/cdboot/Makefile
deleted file mode 100644
index d57d509d29b6..000000000000
--- a/sys/boot/i386/cdboot/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
-# $FreeBSD$
-
-MAINTAINER=jhb@FreeBSD.org
-
-ORG=0x00
-
-all: cdldr
-
-cdldr: cdldr.o
-.if ${OBJFORMAT} == aout
- ${LD} -nostdlib -N -s -T ${ORG} -o cdldr.out cdldr.o
- dd if=cdldr.out of=${.TARGET} ibs=32 skip=1
-.else
- ${LD} -N -e start -Ttext ${ORG} -o cdldr.out cdldr.o
- objcopy -S -O binary cdldr.out ${.TARGET}
-.endif
-
-cdldr.o: cdldr.s
- ${AS} ${AFLAGS} -o ${.TARGET} ${.CURDIR}/cdldr.s
-
-CLEANFILES+= cdldr cdldr.out cdldr.o
-
-.include <bsd.prog.mk>
diff --git a/sys/boot/i386/cdboot/cdboot.s b/sys/boot/i386/cdboot/cdboot.s
deleted file mode 100644
index 2ad2e300373e..000000000000
--- a/sys/boot/i386/cdboot/cdboot.s
+++ /dev/null
@@ -1,259 +0,0 @@
-#
-# Copyright (c) 2000 John Baldwin
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms are freely
-# permitted provided that the above copyright notice and this
-# paragraph and the following disclaimer are duplicated in all
-# such forms.
-#
-# This software is provided "AS IS" and without any express or
-# implied warranties, including, without limitation, the implied
-# warranties of merchantability and fitness for a particular
-# purpose.
-#
-
-# $FreeBSD$
-
-#
-# This simple program is a preloader for the normal boot3 loader. It is simply
-# prepended to the beginning of a fully built and btxld'd loader. It then
-# copies the loader to the address boot2 normally loads it, emulates the
-# boot[12] environment (protected mode, a bootinfo struct, etc.), and then jumps
-# to the start of btxldr to start the boot process. This method allows a stock
-# /boot/loader to be used w/o having to fully rewrite boot[12] to handle the
-# cd9660 file system.
-#
-
-#
-# Memory locations.
-#
- .set MEM_LOADER_ADDRESS,0x100000 # where the loader lives
- .set MEM_LDR_ENTRY,0x7c00 # our entry point
- .set MEM_ARG,0x900 # Arguments at start
- .set MEM_ARG_BTX,0xa100 # Where we move them to so the
- # BTX client can see them
- .set MEM_ARG_SIZE,0x18 # Size of the arguments
- .set MEM_BTX_ADDRESS,0x9000 # where BTX lives
- .set MEM_BTX_ENTRY,0x9010 # where BTX starts to execute
- .set MEM_AOUT_HEADER,0x1000 # size of the a.out header
- .set MEM_BTX_OFFSET,0x1000 # offset of BTX in the loader
- .set MEM_BTX_IMAGE,MEM_LOADER_ADDRESS+MEM_BTX_OFFSET # where
- # BTX is in the loader
- .set MEM_BTX_CLIENT,0xa000 # where BTX clients live
-#
-# Flags for kargs->bootflags
-#
- .set KARGS_FLAGS_CD,0x1 # flag to indicate booting from
- # CD loader
-#
-# Segment selectors.
-#
- .set SEL_SDATA,0x8 # Supervisor data
- .set SEL_RDATA,0x10 # Real mode data
- .set SEL_SCODE,0x18 # PM-32 code
- .set SEL_SCODE16,0x20 # PM-16 code
-#
-# BTX constants
-#
- .set INT_SYS,0x30 # BTX syscall interrupt
-#
-# We expect to be loaded by the BIOS at 0x7c00 (standard boot loader entry point)
-#
- .code16
- .globl start
- .org 0x0, 0x0
-#
-# BTX program loader for CD booting
-#
-start: jmp begin # skip the boot info table
- .org 0x8, 0x90 # fill with nops up to the table
-#
-# Boot information table that is filled in by mkisofs(8), see the man page for
-# details
-#
-boot_info_table:
-bi_pvd_LBA: .long 0x0
-bi_file_LBA: .long 0x0
-bi_file_length: .long 0x0
-bi_checksum: .long 0x0
-bi_reserved: .byte 0x0
- .org 0x40, 0x0
-#
-# Actual start of execution
-#
-begin: cld # string ops inc
- xorw %ax, %ax # zero %ax
- movw %ax, %ss # setup the
- movw $MEM_LDR_ENTRY, %sp # stack
- pushw %dx # save the BIOS boot device in
- # %dl for later
- movw $(MEM_LDR_ENTRY/0x10), %ax # setup the
- movw %ax, %ds # data segment
- movl $welcome_msg, %si # %ds:(%si) -> welcome message
- call putstr # display the welcome message
-#
-# Setup the arguments that the loader is expecting from boot[12]
-#
- movl $bootinfo_msg, %si # %ds:(%si) -> boot args message
- call putstr # display the message
- pushw %ss # Copy %ss
- popw %es # to %es
- movl $MEM_ARG, %ebx # %es:(%ebx) -> boot args
- movw %bx, %di # %es:(%di) -> boot args
- xorl %eax, %eax # zero %eax
- movw $(MEM_ARG_SIZE/4), %cx # Size of arguments in 32-bit
- # dwords
- rep # Clear the arguments
- stosl # to zero
- popw %dx # restore BIOS boot device
- movb %dl, %es:0x4(%ebx) # set kargs->bootdev
- orb $KARGS_FLAGS_CD, %es:0x8(%ebx) # kargs->bootflags |= KARGS_FLAGS_CD
-#
-# Turn on the A20 address line
-#
- call seta20 # Turn A20 on
-#
-# Relocate the loader and BTX using a very lazy protected mode
-#
- movw $relocate_msg, %si # Display the
- call putstr # relocation message
- movl $MEM_LOADER_ADDRESS, %edi # %edi is the destination
- movl $(MEM_LDR_ENTRY+end-start+MEM_AOUT_HEADER), %esi # %esi is
- # the start of the raw loader
- movl bi_file_length, %ecx # Set %ecx to the length
- subl $(end-start+MEM_AOUT_HEADER), %ecx # of the raw loader
- lgdt gdtdesc # setup our own gdt
- cli # turn off interrupts
- movl %cr0, %eax # Turn on
- orl $0x1, %eax # protected
- movl %eax, %cr0 # mode
- .byte 0xea # long jump to
- .word MEM_LDR_ENTRY+pm_start # clear the instruction
- .word SEL_SCODE # pre-fetch
- .code32
-pm_start: movw $SEL_SDATA, %ax # Initialize
- movw %ax, %ds # %ds and
- movw %ax, %es # %es to a flat selector
- rep # Relocate
- movsb # the loader
- movl $MEM_BTX_IMAGE, %esi # %esi -> BTX in the loader
- movl $MEM_BTX_ADDRESS, %edi # %edi -> where BTX needs to go
- movzwl 0xa(%esi), %ecx # %ecx -> length of BTX
- rep # Relocate
- movsb # BTX
- ljmp $SEL_SCODE16,$(MEM_LDR_ENTRY+pm_16) # Jump to 16-bit PM
- .code16
-pm_16: movw $SEL_RDATA, %ax # Initialize
- movw %ax, %ds # %ds and
- movw %ax, %es # %es to a real mode selector
- movl %cr0, %eax # Turn off
- andl $~0x1, %eax # protected
- movl %eax, %cr0 # mode
- .byte 0xea # Long jump to
- .word pm_end # clear the instruction
- .word MEM_LDR_ENTRY/0x10 # pre-fetch
-pm_end: sti # Turn interrupts back on now
-#
-# Copy the BTX client to MEM_BTX_CLIENT
-#
- movw $(MEM_LDR_ENTRY/0x10), %ax # Initialize
- movw %ax, %ds # %ds to local data segment
- xorw %ax, %ax # zero %ax and initialize
- movw %ax, %es # %es to segment 0
- movw $MEM_BTX_CLIENT, %di # Prepare to relocate
- movw $btx_client, %si # the simple btx client
- movw $(btx_client_end-btx_client), %cx # length of btx client
- rep # Relocate the
- movsb # simple BTX client
-#
-# Copy the boot[12] args to where the BTX client can see them
-#
- movw $MEM_ARG, %si # where the args are at now
- movw %ax, %ds # need segment 0 in %ds
- movw $MEM_ARG_BTX, %di # where the args are moving to
- movw $(MEM_ARG_SIZE/4), %cx # size of the arguments in longs
- rep # Relocate
- movsl # the words
-#
-# Now we just start up BTX and let it do the rest
-#
- movw $(MEM_LDR_ENTRY/0x10), %ax # Initialize
- movw %ax, %ds # %ds to the local data segment
- movl $jump_message, %si # Display the
- call putstr # jump message
- .byte 0xea # Jump to
- .word MEM_BTX_ENTRY # BTX entry
- .word 0x0 # point
-
-#
-# Display a null-terminated string
-#
-putstr: lodsb # load %al from %ds:(%si)
- testb %al,%al # stop at null
- jnz putc # if the char != null, output it
- ret # return when null is hit
-putc: movw $0x7,%bx # attribute for output
- movb $0xe,%ah # BIOS: put_char
- int $0x10 # call BIOS, print char in %al
- jmp putstr # keep looping
-
-#
-# Enable A20
-#
-seta20: cli # Disable interrupts
-seta20.1: inb $0x64,%al # Get status
- testb $0x2,%al # Busy?
- jnz seta20.1 # Yes
- movb $0xd1,%al # Command: Write
- outb %al,$0x64 # output port
-seta20.2: inb $0x64,%al # Get status
- testb $0x2,%al # Busy?
- jnz seta20.2 # Yes
- movb $0xdf,%al # Enable
- outb %al,$0x60 # A20
- sti # Enable interrupts
- ret # To caller
-
-#
-# BTX client to start btxld
-#
- .code32
-btx_client: movl $(MEM_ARG_BTX-MEM_BTX_CLIENT+MEM_ARG_SIZE-4), %esi
- # %ds:(%esi) -> end
- # of boot[12] args
- movl $(MEM_ARG_SIZE/4), %ecx # Number of words to push
- std # Go backwards
-push_arg: lodsl # Read argument
- pushl %eax # Push it onto the stack
- loop push_arg # Push all of the arguments
- cld # In case anyone depends on this
- pushl $(MEM_LOADER_ADDRESS) # Address to jump to
- pushl %eax # Emulate a near call
- movl $0x1, %eax # 'exec' system call
- int $INT_SYS # BTX system call
-btx_client_end:
- .code16
-
- .p2align 4
-#
-# Global descriptor table.
-#
-gdt: .word 0x0,0x0,0x0,0x0 # Null entry
- .word 0xffff,0x0,0x9200,0xcf # SEL_SDATA
- .word 0xffff,0x0,0x9200,0x0 # SEL_RDATA
- .word 0xffff,0x0,0x9a00,0xcf # SEL_SCODE (32-bit)
- .word 0xffff,0x0,0x9a00,0x8f # SEL_SCODE16 (16-bit)
-gdt.1:
-#
-# Pseudo-descriptors.
-#
-gdtdesc: .word gdt.1-gdt-1 # Limit
- .long gdt+MEM_LDR_ENTRY # Base
-
-welcome_msg: .asciz "CD Loader 1.00\r\n\n"
-bootinfo_msg: .asciz "Building the boot loader arguments\r\n"
-relocate_msg: .asciz "Relocating the loader and the BTX\r\n"
-jump_message: .asciz "Starting the BTX loader\r\n"
-
-end:
diff --git a/sys/boot/i386/gptboot/Makefile b/sys/boot/i386/gptboot/Makefile
deleted file mode 100644
index b27780bfaf12..000000000000
--- a/sys/boot/i386/gptboot/Makefile
+++ /dev/null
@@ -1,81 +0,0 @@
-# $FreeBSD$
-
-PROG= boot2
-NOMAN=
-STRIP=
-BINDIR?= /boot
-BINMODE= 444
-CLEANFILES+= boot1 boot1.out boot1.o \
- boot2.ldr boot2.bin boot2.ld boot2.out boot2.o \
- sio.o
-
-M4?= m4
-
-# A value of 0x80 enables LBA support.
-B1FLAGS= 0
-
-BOOT_COMCONSOLE_PORT?= 0x3f8
-BOOT_COMCONSOLE_SPEED?= 9600
-B2SIOFMT?= 0x3
-
-.if exists(${.OBJDIR}/../btx)
-BTX= ${.OBJDIR}/../btx
-.else
-BTX= ${.CURDIR}/../btx
-.endif
-
-ORG1= 0x7c00
-ORG2= 0x1000
-
-CFLAGS= -elf -I${.CURDIR}/../btx/lib -I. \
- -Os -fno-builtin -fforce-addr -fdata-sections \
- -malign-functions=0 -malign-jumps=0 -malign-loops=0 -mrtd \
- -mpreferred-stack-boundary=2 \
- -Wall -Waggregate-return -Wbad-function-cast -Wcast-align \
- -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
- -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings
-
-LDFLAGS=-nostdlib -static -N
-
-all: boot1 boot2
-
-boot1: boot1.out
- objcopy -S -O binary boot1.out ${.TARGET}
-
-boot1.out: boot1.o
- ${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o
-
-boot1.o: boot1.m4 boot1.s
- (cd ${.CURDIR}; ${M4} -DFLAGS=${B1FLAGS} boot1.m4 boot1.s) | \
- ${AS} ${AFLAGS} -o ${.TARGET}
-
-boot2: boot2.ldr boot2.bin
- btxld -v -E ${ORG2} -f bin -b ${BTX}/btx/btx -l boot2.ldr \
- -o boot2.ld -P 1 boot2.bin
- @ls -l boot2.ld | awk '{ x = 7680 - $$5; \
- print x " bytes available"; if (x < 0) exit 1 }'
- dd if=boot2.ld of=${.TARGET} obs=7680 conv=osync 2>/dev/null
-
-boot2.ldr:
- dd if=/dev/zero of=${.TARGET} bs=512 count=1 2>/dev/null
-
-boot2.bin: boot2.out
- objcopy -S -O binary boot2.out ${.TARGET}
-
-boot2.out: boot2.o sio.o
- ${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} \
- ${BTX}/lib/crt0.o boot2.o sio.o
-
-sio.o: sio.s
- (cd ${.CURDIR}; ${M4} -DSIOPRT=${BOOT_COMCONSOLE_PORT} \
- -DSIOFMT=${B2SIOFMT} \
- -DSIOSPD=${BOOT_COMCONSOLE_SPEED} sio.s) | \
- ${AS} ${AFLAGS} -o ${.TARGET}
-
-install:
- ${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
- boot1 ${DESTDIR}${BINDIR}/boot1
- ${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
- boot2 ${DESTDIR}${BINDIR}/boot2
-
-.include <bsd.prog.mk>
diff --git a/sys/boot/i386/gptboot/gptboot.c b/sys/boot/i386/gptboot/gptboot.c
deleted file mode 100644
index ad7e8e9c1623..000000000000
--- a/sys/boot/i386/gptboot/gptboot.c
+++ /dev/null
@@ -1,812 +0,0 @@
-/*
- * Copyright (c) 1998 Robert Nordier
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are freely
- * permitted provided that the above copyright notice and this
- * paragraph and the following disclaimer are duplicated in all
- * such forms.
- *
- * This software is provided "AS IS" and without any express or
- * implied warranties, including, without limitation, the implied
- * warranties of merchantability and fitness for a particular
- * purpose.
- */
-
-/*
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/reboot.h>
-#include <sys/diskslice.h>
-#include <sys/disklabel.h>
-#include <sys/dirent.h>
-#include <machine/bootinfo.h>
-
-#include <ufs/ffs/fs.h>
-#include <ufs/ufs/dinode.h>
-
-#include <stdarg.h>
-
-#include <a.out.h>
-#include <elf.h>
-
-#include <btxv86.h>
-
-#include "lib.h"
-
-#define RBX_ASKNAME 0x0 /* -a */
-#define RBX_SINGLE 0x1 /* -s */
-#define RBX_DFLTROOT 0x5 /* -r */
-#define RBX_KDB 0x6 /* -d */
-#define RBX_CONFIG 0xa /* -c */
-#define RBX_VERBOSE 0xb /* -v */
-#define RBX_SERIAL 0xc /* -h */
-#define RBX_CDROM 0xd /* -C */
-#define RBX_GDB 0xf /* -g */
-#define RBX_DUAL 0x1d /* -D */
-#define RBX_PROBEKBD 0x1e /* -P */
-
-#define RBX_MASK 0xffff
-
-#define PATH_CONFIG "/boot.config"
-#define PATH_BOOT3 "/boot/loader"
-#define PATH_KERNEL "/kernel"
-
-#define ARGS 0x900
-#define NOPT 11
-#define BSIZEMAX 8192
-#define NDEV 5
-#define MEM_BASE 0x12
-#define MEM_EXT 0x15
-#define V86_CY(x) ((x) & 1)
-#define V86_ZR(x) ((x) & 0x40)
-
-#define DRV_HARD 0x80
-#define DRV_MASK 0x7f
-
-#define TYPE_AD 0
-#define TYPE_WD 1
-#define TYPE_WFD 2
-#define TYPE_FD 3
-#define TYPE_DA 4
-
-extern uint32_t _end;
-
-static const char optstr[NOPT] = "DhaCcdgPrsv";
-static const unsigned char flags[NOPT] = {
- RBX_DUAL,
- RBX_SERIAL,
- RBX_ASKNAME,
- RBX_CDROM,
- RBX_CONFIG,
- RBX_KDB,
- RBX_GDB,
- RBX_PROBEKBD,
- RBX_DFLTROOT,
- RBX_SINGLE,
- RBX_VERBOSE
-};
-
-static const char *const dev_nm[] = {"ad", "wd", " ", "fd", "da"};
-static const unsigned dev_maj[] = {30, 0, 1, 2, 4};
-
-static struct dsk {
- unsigned drive;
- unsigned type;
- unsigned unit;
- unsigned slice;
- unsigned part;
- unsigned start;
- int init;
- int meta;
-} dsk;
-static char cmd[512];
-static char kname[1024];
-static uint32_t opts;
-static struct bootinfo bootinfo;
-static int ls;
-static uint32_t fs_off;
-static uint8_t ioctrl = 0x1;
-
-void exit(int);
-static void load(const char *);
-static int parse(char *);
-static void readfile(const char *, void *, size_t);
-static ino_t lookup(const char *);
-static int fsfind(const char *, ino_t *);
-static int xfsread(ino_t, void *, size_t);
-static ssize_t fsread(ino_t, void *, size_t);
-static int dskread(void *, unsigned, unsigned);
-static int printf(const char *,...);
-static void getstr(char *, int);
-static int putchar(int);
-static int getchar(void);
-static void *memcpy(void *, const void *, size_t);
-static int strcmp(const char *, const char *);
-static void *malloc(size_t);
-static uint32_t memsize(int);
-static uint32_t drvinfo(int);
-static int drvread(void *, unsigned, unsigned);
-static int keyhit(unsigned);
-static int xputc(int);
-static int xgetc(int);
-static void putc(int);
-static int getc(int);
-
-int
-main(void)
-{
- int autoboot, i;
-
- v86.ctl = V86_FLAGS;
- dsk.drive = *(uint8_t *)PTOV(ARGS);
- dsk.type = dsk.drive & DRV_HARD ? TYPE_AD : TYPE_FD;
- dsk.unit = dsk.drive & DRV_MASK;
- dsk.slice = *(uint8_t *)PTOV(ARGS + 1) + 1;
- bootinfo.bi_version = BOOTINFO_VERSION;
- bootinfo.bi_size = sizeof(bootinfo);
- bootinfo.bi_basemem = memsize(MEM_BASE);
- bootinfo.bi_extmem = memsize(MEM_EXT);
- bootinfo.bi_memsizes_valid++;
- for (i = 0; i < N_BIOS_GEOM; i++)
- bootinfo.bi_bios_geom[i] = drvinfo(i);
- autoboot = 2;
- readfile(PATH_CONFIG, cmd, sizeof(cmd));
- if (*cmd) {
- printf("%s: %s", PATH_CONFIG, cmd);
- if (parse(cmd))
- autoboot = 0;
- *cmd = 0;
- }
- if (autoboot && !*kname) {
- if (autoboot == 2) {
- memcpy(kname, PATH_BOOT3, sizeof(PATH_BOOT3));
- if (!keyhit(0x37)) {
- load(kname);
- autoboot = 1;
- }
- }
- if (autoboot == 1)
- memcpy(kname, PATH_KERNEL, sizeof(PATH_KERNEL));
- }
- for (;;) {
- printf(" \n>> FreeBSD/i386 BOOT\n"
- "Default: %u:%s(%u,%c)%s\n"
- "boot: ",
- dsk.drive & DRV_MASK, dev_nm[dsk.type], dsk.unit,
- 'a' + dsk.part, kname);
- if (ioctrl & 0x2)
- sio_flush();
- if (!autoboot || keyhit(0x5a))
- getstr(cmd, sizeof(cmd));
- else
- putchar('\n');
- autoboot = 0;
- if (parse(cmd))
- putchar('\a');
- else
- load(kname);
- }
-}
-
-void
-exit(int x)
-{
-}
-
-static void
-load(const char *fname)
-{
- union {
- struct exec ex;
- Elf32_Ehdr eh;
- } hdr;
- Elf32_Phdr ep[2];
- Elf32_Shdr es[2];
- caddr_t p;
- ino_t ino;
- uint32_t addr, x;
- int fmt, i, j;
-
- if (!(ino = lookup(fname))) {
- if (!ls)
- printf("No %s\n", fname);
- return;
- }
- if (xfsread(ino, &hdr, sizeof(hdr)))
- return;
- if (N_GETMAGIC(hdr.ex) == ZMAGIC)
- fmt = 0;
- else if (IS_ELF(hdr.eh))
- fmt = 1;
- else {
- printf("Invalid %s\n", "format");
- return;
- }
- if (fmt == 0) {
- addr = hdr.ex.a_entry & 0xffffff;
- p = PTOV(addr);
- fs_off = PAGE_SIZE;
- if (xfsread(ino, p, hdr.ex.a_text))
- return;
- p += roundup2(hdr.ex.a_text, PAGE_SIZE);
- if (xfsread(ino, p, hdr.ex.a_data))
- return;
- p += hdr.ex.a_data + roundup2(hdr.ex.a_bss, PAGE_SIZE);
- bootinfo.bi_symtab = VTOP(p);
- memcpy(p, &hdr.ex.a_syms, sizeof(hdr.ex.a_syms));
- p += sizeof(hdr.ex.a_syms);
- if (hdr.ex.a_syms) {
- if (xfsread(ino, p, hdr.ex.a_syms))
- return;
- p += hdr.ex.a_syms;
- if (xfsread(ino, p, sizeof(int)))
- return;
- x = *(uint32_t *)p;
- p += sizeof(int);
- x -= sizeof(int);
- if (xfsread(ino, p, x))
- return;
- p += x;
- }
- } else {
- fs_off = hdr.eh.e_phoff;
- for (j = i = 0; i < hdr.eh.e_phnum && j < 2; i++) {
- if (xfsread(ino, ep + j, sizeof(ep[0])))
- return;
- if (ep[j].p_type == PT_LOAD)
- j++;
- }
- for (i = 0; i < 2; i++) {
- p = PTOV(ep[i].p_paddr & 0xffffff);
- fs_off = ep[i].p_offset;
- if (xfsread(ino, p, ep[i].p_filesz))
- return;
- }
- p += roundup2(ep[1].p_memsz, PAGE_SIZE);
- bootinfo.bi_symtab = VTOP(p);
- if (hdr.eh.e_shnum == hdr.eh.e_shstrndx + 3) {
- fs_off = hdr.eh.e_shoff + sizeof(es[0]) *
- (hdr.eh.e_shstrndx + 1);
- if (xfsread(ino, &es, sizeof(es)))
- return;
- for (i = 0; i < 2; i++) {
- memcpy(p, &es[i].sh_size, sizeof(es[i].sh_size));
- p += sizeof(es[i].sh_size);
- fs_off = es[i].sh_offset;
- if (xfsread(ino, p, es[i].sh_size))
- return;
- p += es[i].sh_size;
- }
- }
- addr = hdr.eh.e_entry & 0xffffff;
- }
- bootinfo.bi_esymtab = VTOP(p);
- bootinfo.bi_kernelname = VTOP(fname);
- bootinfo.bi_bios_dev = dsk.drive;
- __exec((caddr_t)addr, RB_BOOTINFO | (opts & RBX_MASK),
- MAKEBOOTDEV(dev_maj[dsk.type], 0, dsk.slice, dsk.unit, dsk.part),
- 0, 0, 0, VTOP(&bootinfo));
-}
-
-static int
-parse(char *arg)
-{
- char *p, *q;
- int drv, c, i;
-
- while ((c = *arg++)) {
- if (c == ' ')
- continue;
- for (p = arg; *p && *p != '\n' && *p != ' '; p++);
- if (*p)
- *p++ = 0;
- if (c == '-') {
- while ((c = *arg++)) {
- for (i = 0; c != optstr[i]; i++)
- if (i == NOPT - 1)
- return -1;
- opts ^= 1 << flags[i];
- }
- if (opts & 1 << RBX_PROBEKBD) {
- i = *(uint8_t *)PTOV(0x496) & 0x10;
- printf("Keyboard: %s\n", i ? "yes" : "no");
- if (!i)
- opts |= 1 << RBX_DUAL | 1 << RBX_SERIAL;
- opts &= ~(1 << RBX_PROBEKBD);
- }
- ioctrl = opts & 1 << RBX_DUAL ? 0x3 :
- opts & 1 << RBX_SERIAL ? 0x2 : 0x1;
- if (ioctrl & 0x2)
- sio_init();
- } else {
- for (q = arg--; *q && *q != '('; q++);
- if (*q) {
- drv = -1;
- if (arg[1] == ':') {
- if (*arg < '0' || *arg > '9')
- return -1;
- drv = *arg - '0';
- arg += 2;
- }
- if (q - arg != 2)
- return -1;
- for (i = 0; arg[0] != dev_nm[i][0] ||
- arg[1] != dev_nm[i][1]; i++)
- if (i == NDEV - 1)
- return -1;
- dsk.type = i;
- arg += 3;
- if (arg[1] != ',' || *arg < '0' || *arg > '9')
- return -1;
- dsk.unit = *arg - '0';
- arg += 2;
- dsk.slice = WHOLE_DISK_SLICE;
- if (arg[1] == ',') {
- if (*arg < '0' || *arg > '0' + NDOSPART)
- return -1;
- if ((dsk.slice = *arg - '0'))
- dsk.slice++;
- arg += 2;
- }
- if (arg[1] != ')' || *arg < 'a' || *arg > 'p')
- return -1;
- dsk.part = *arg - 'a';
- arg += 2;
- if (drv == -1)
- drv = dsk.unit;
- dsk.drive = (dsk.type == TYPE_WD ||
- dsk.type == TYPE_AD ||
- dsk.type == TYPE_DA ? DRV_HARD : 0) + drv;
- dsk.meta = 0;
- fsread(0, NULL, 0);
- }
- if ((i = p - arg - !*(p - 1))) {
- if (i >= sizeof(kname))
- return -1;
- memcpy(kname, arg, i + 1);
- }
- }
- arg = p;
- }
- return 0;
-}
-
-static void
-readfile(const char *fname, void *buf, size_t size)
-{
- ino_t ino;
-
- if ((ino = lookup(fname)))
- fsread(ino, buf, size);
-}
-
-static ino_t
-lookup(const char *path)
-{
- char name[MAXNAMLEN + 1];
- const char *s;
- ino_t ino;
- ssize_t n;
- int dt;
-
- ino = ROOTINO;
- dt = DT_DIR;
- for (;;) {
- if (*path == '/')
- path++;
- if (!*path)
- break;
- for (s = path; *s && *s != '/'; s++);
- if ((n = s - path) > MAXNAMLEN)
- return 0;
- ls = *path == '?' && n == 1 && !*s;
- memcpy(name, path, n);
- name[n] = 0;
- if ((dt = fsfind(name, &ino)) <= 0)
- break;
- path = s;
- }
- return dt == DT_REG ? ino : 0;
-}
-
-static int
-fsfind(const char *name, ino_t * ino)
-{
- char buf[DEV_BSIZE];
- struct dirent *d;
- char *s;
- ssize_t n;
-
- fs_off = 0;
- while ((n = fsread(*ino, buf, DEV_BSIZE)) > 0)
- for (s = buf; s < buf + DEV_BSIZE;) {
- d = (void *)s;
- if (ls)
- printf("%s ", d->d_name);
- else if (!strcmp(name, d->d_name)) {
- *ino = d->d_fileno;
- return d->d_type;
- }
- s += d->d_reclen;
- }
- if (n != -1 && ls)
- putchar('\n');
- return 0;
-}
-
-static int
-xfsread(ino_t inode, void *buf, size_t nbyte)
-{
- if (fsread(inode, buf, nbyte) != nbyte) {
- printf("Invalid %s\n", "format");
- return -1;
- }
- return 0;
-}
-
-static ssize_t
-fsread(ino_t inode, void *buf, size_t nbyte)
-{
- static struct fs fs;
- static struct dinode din;
- static char *blkbuf;
- static ufs_daddr_t *indbuf;
- static ino_t inomap;
- static ufs_daddr_t blkmap, indmap;
- static unsigned fsblks;
- char *s;
- ufs_daddr_t lbn, addr;
- size_t n, nb, off;
-
- if (!dsk.meta) {
- if (!blkbuf)
- blkbuf = malloc(BSIZEMAX);
- inomap = 0;
- if (dskread(blkbuf, SBOFF / DEV_BSIZE, SBSIZE / DEV_BSIZE))
- return -1;
- memcpy(&fs, blkbuf, sizeof(fs));
- if (fs.fs_magic != FS_MAGIC) {
- printf("Not ufs\n");
- return -1;
- }
- fsblks = fs.fs_bsize >> DEV_BSHIFT;
- dsk.meta++;
- }
- if (!inode)
- return 0;
- if (inomap != inode) {
- if (dskread(blkbuf, fsbtodb(&fs, ino_to_fsba(&fs, inode)),
- fsblks))
- return -1;
- din = ((struct dinode *)blkbuf)[inode % INOPB(&fs)];
- inomap = inode;
- fs_off = 0;
- blkmap = indmap = 0;
- }
- s = buf;
- if (nbyte > (n = din.di_size - fs_off))
- nbyte = n;
- nb = nbyte;
- while (nb) {
- lbn = lblkno(&fs, fs_off);
- if (lbn < NDADDR)
- addr = din.di_db[lbn];
- else {
- if (indmap != din.di_ib[0]) {
- if (!indbuf)
- indbuf = malloc(BSIZEMAX);
- if (dskread(indbuf, fsbtodb(&fs, din.di_ib[0]),
- fsblks))
- return -1;
- indmap = din.di_ib[0];
- }
- addr = indbuf[(lbn - NDADDR) % NINDIR(&fs)];
- }
- n = dblksize(&fs, &din, lbn);
- if (blkmap != addr) {
- if (dskread(blkbuf, fsbtodb(&fs, addr), n >> DEV_BSHIFT))
- return -1;
- blkmap = addr;
- }
- off = blkoff(&fs, fs_off);
- n -= off;
- if (n > nb)
- n = nb;
- memcpy(s, blkbuf + off, n);
- s += n;
- fs_off += n;
- nb -= n;
- }
- return nbyte;
-}
-
-static int
-dskread(void *buf, unsigned lba, unsigned nblk)
-{
- static char *sec;
- struct dos_partition *dp;
- struct disklabel *d;
- unsigned sl, i;
-
- if (!dsk.meta) {
- if (!sec)
- sec = malloc(DEV_BSIZE);
- dsk.start = 0;
- if (drvread(sec, DOSBBSECTOR, 1))
- return -1;
- dp = (void *)(sec + DOSPARTOFF);
- sl = dsk.slice;
- if (sl < BASE_SLICE) {
- for (i = 0; i < NDOSPART; i++)
- if (dp[i].dp_typ == DOSPTYP_386BSD &&
- (dp[i].dp_flag & 0x80 || sl < BASE_SLICE)) {
- sl = BASE_SLICE + i;
- if (dp[i].dp_flag & 0x80 ||
- dsk.slice == COMPATIBILITY_SLICE)
- break;
- }
- if (dsk.slice == WHOLE_DISK_SLICE)
- dsk.slice = sl;
- }
- if (sl != WHOLE_DISK_SLICE) {
- if (sl != COMPATIBILITY_SLICE)
- dp += sl - BASE_SLICE;
- if (dp->dp_typ != DOSPTYP_386BSD) {
- printf("Invalid %s\n", "slice");
- return -1;
- }
- dsk.start = dp->dp_start;
- }
- if (drvread(sec, dsk.start + LABELSECTOR, 1))
- return -1;
- d = (void *)(sec + LABELOFFSET);
- if (d->d_magic != DISKMAGIC || d->d_magic2 != DISKMAGIC) {
- if (dsk.part != RAW_PART) {
- printf("Invalid %s\n", "label");
- return -1;
- }
- } else {
- if (!dsk.init) {
- if (d->d_type == DTYPE_SCSI)
- dsk.type = TYPE_DA;
- dsk.init++;
- }
- if (dsk.part >= d->d_npartitions ||
- !d->d_partitions[dsk.part].p_size) {
- printf("Invalid %s\n", "partition");
- return -1;
- }
- dsk.start = d->d_partitions[dsk.part].p_offset;
- }
- }
- return drvread(buf, dsk.start + lba, nblk);
-}
-
-static int
-printf(const char *fmt,...)
-{
- static const char digits[16] = "0123456789abcdef";
- va_list ap;
- char buf[10];
- char *s;
- unsigned r, u;
- int c;
-
- va_start(ap, fmt);
- while ((c = *fmt++)) {
- if (c == '%') {
- c = *fmt++;
- switch (c) {
- case 'c':
- putchar(va_arg(ap, int));
- continue;
- case 's':
- for (s = va_arg(ap, char *); *s; s++)
- putchar(*s);
- continue;
- case 'u':
- case 'x':
- r = c == 'u' ? 10U : 16U;
- u = va_arg(ap, unsigned);
- s = buf;
- do
- *s++ = digits[u % r];
- while (u /= r);
- while (--s >= buf)
- putchar(*s);
- continue;
- }
- }
- putchar(c);
- }
- va_end(ap);
- return 0;
-}
-
-static void
-getstr(char *str, int size)
-{
- char *s;
- int c;
-
- s = str;
- do {
- switch (c = getchar()) {
- case 0:
- break;
- case '\b':
- case '\177':
- if (s > str) {
- s--;
- putchar('\b');
- putchar(' ');
- } else
- c = 0;
- break;
- case '\n':
- *s = 0;
- break;
- default:
- if (s - str < size - 1)
- *s++ = c;
- }
- if (c)
- putchar(c);
- } while (c != '\n');
-}
-
-static int
-putchar(int c)
-{
- if (c == '\n')
- xputc('\r');
- return xputc(c);
-}
-
-static int
-getchar(void)
-{
- int c;
-
- c = xgetc(0);
- if (c == '\r')
- c = '\n';
- return c;
-}
-
-static void *
-memcpy(void *dst, const void *src, size_t size)
-{
- const char *s;
- char *d;
-
- for (d = dst, s = src; size; size--)
- *d++ = *s++;
- return dst;
-}
-
-static int
-strcmp(const char *s1, const char *s2)
-{
- for (; *s1 == *s2 && *s1; s1++, s2++);
- return (u_char)*s1 - (u_char)*s2;
-}
-
-static void *
-malloc(size_t size)
-{
- static uint32_t next;
- void *p;
-
- if (!next)
- next = roundup2(__base + _end, 0x10000) - __base;
- p = (void *)next;
- next += size;
- return p;
-}
-
-static uint32_t
-memsize(int type)
-{
- v86.addr = type;
- v86.eax = 0x8800;
- v86int();
- return v86.eax;
-}
-
-static uint32_t
-drvinfo(int drive)
-{
- v86.addr = 0x13;
- v86.eax = 0x800;
- v86.edx = DRV_HARD + drive;
- v86int();
- if (V86_CY(v86.efl))
- return 0x4f010f;
- return ((v86.ecx & 0xc0) << 18) | ((v86.ecx & 0xff00) << 8) |
- (v86.edx & 0xff00) | (v86.ecx & 0x3f);
-}
-
-static int
-drvread(void *buf, unsigned lba, unsigned nblk)
-{
- static unsigned c = 0x2d5c7c2f;
-
- printf("%c\b", c = c << 8 | c >> 24);
- v86.ctl = V86_ADDR | V86_CALLF | V86_FLAGS;
- v86.addr = 0x704; /* call to xread in boot1 */
- v86.es = VTOPSEG(buf);
- v86.eax = lba;
- v86.ebx = VTOPOFF(buf);
- v86.ecx = lba >> 16;
- v86.edx = nblk << 8 | dsk.drive;
- v86int();
- v86.ctl = V86_FLAGS;
- if (V86_CY(v86.efl)) {
- printf("Disk error 0x%x (lba=0x%x)\n", v86.eax >> 8 & 0xff,
- lba);
- return -1;
- }
- return 0;
-}
-
-static int
-keyhit(unsigned ticks)
-{
- uint32_t t0, t1;
-
- t0 = 0;
- for (;;) {
- if (xgetc(1))
- return 1;
- t1 = *(uint32_t *)PTOV(0x46c);
- if (!t0)
- t0 = t1;
- if (t1 < t0 || t1 >= t0 + ticks)
- return 0;
- }
-}
-
-static int
-xputc(int c)
-{
- if (ioctrl & 0x1)
- putc(c);
- if (ioctrl & 0x2)
- sio_putc(c);
- return c;
-}
-
-static int
-xgetc(int fn)
-{
- for (;;) {
- if (ioctrl & 0x1 && getc(1))
- return fn ? 1 : getc(0);
- if (ioctrl & 0x2 && sio_ischar())
- return fn ? 1 : sio_getc();
- if (fn)
- return 0;
- }
-}
-
-static void
-putc(int c)
-{
- v86.addr = 0x10;
- v86.eax = 0xe00 | (c & 0xff);
- v86.ebx = 0x7;
- v86int();
-}
-
-static int
-getc(int fn)
-{
- v86.addr = 0x16;
- v86.eax = fn << 8;
- v86int();
- return fn == 0 ? v86.eax & 0xff : !V86_ZR(v86.efl);
-}
diff --git a/sys/boot/i386/libi386/bootinfo32.c b/sys/boot/i386/libi386/bootinfo32.c
deleted file mode 100644
index a8738e12dcc3..000000000000
--- a/sys/boot/i386/libi386/bootinfo32.c
+++ /dev/null
@@ -1,334 +0,0 @@
-/*-
- * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include <stand.h>
-#include <sys/param.h>
-#include <sys/reboot.h>
-#include <sys/linker.h>
-#include <machine/bootinfo.h>
-#include "bootstrap.h"
-#include "libi386.h"
-#include "btxv86.h"
-
-static struct bootinfo bi;
-
-/*
- * Return a 'boothowto' value corresponding to the kernel arguments in
- * (kargs) and any relevant environment variables.
- */
-static struct
-{
- char *ev;
- int mask;
-} howto_names[] = {
- {"boot_askname", RB_ASKNAME},
- {"boot_cdrom", RB_CDROM},
- {"boot_userconfig", RB_CONFIG},
- {"boot_ddb", RB_KDB},
- {"boot_gdb", RB_GDB},
- {"boot_single", RB_SINGLE},
- {"boot_verbose", RB_VERBOSE},
- {NULL, 0}
-};
-
-int
-bi_getboothowto(char *kargs)
-{
- char *cp;
- int howto;
- int active;
- int i;
-
- /* Parse kargs */
- howto = 0;
- if (kargs != NULL) {
- cp = kargs;
- active = 0;
- while (*cp != 0) {
- if (!active && (*cp == '-')) {
- active = 1;
- } else if (active)
- switch (*cp) {
- case 'a':
- howto |= RB_ASKNAME;
- break;
- case 'c':
- howto |= RB_CONFIG;
- break;
- case 'C':
- howto |= RB_CDROM;
- break;
- case 'd':
- howto |= RB_KDB;
- break;
- case 'g':
- howto |= RB_GDB;
- break;
- case 'h':
- howto |= RB_SERIAL;
- break;
- case 'r':
- howto |= RB_DFLTROOT;
- break;
- case 's':
- howto |= RB_SINGLE;
- break;
- case 'v':
- howto |= RB_VERBOSE;
- break;
- default:
- active = 0;
- break;
- }
- cp++;
- }
- }
- /* get equivalents from the environment */
- for (i = 0; howto_names[i].ev != NULL; i++)
- if (getenv(howto_names[i].ev) != NULL)
- howto |= howto_names[i].mask;
- if (!strcmp(getenv("console"), "comconsole"))
- howto |= RB_SERIAL;
- return(howto);
-}
-
-/*
- * Copy the environment into the load area starting at (addr).
- * Each variable is formatted as <name>=<value>, with a single nul
- * separating each variable, and a double nul terminating the environment.
- */
-vm_offset_t
-bi_copyenv(vm_offset_t addr)
-{
- struct env_var *ep;
-
- /* traverse the environment */
- for (ep = environ; ep != NULL; ep = ep->ev_next) {
- i386_copyin(ep->ev_name, addr, strlen(ep->ev_name));
- addr += strlen(ep->ev_name);
- i386_copyin("=", addr, 1);
- addr++;
- if (ep->ev_value != NULL) {
- i386_copyin(ep->ev_value, addr, strlen(ep->ev_value));
- addr += strlen(ep->ev_value);
- }
- i386_copyin("", addr, 1);
- addr++;
- }
- i386_copyin("", addr, 1);
- addr++;
- return(addr);
-}
-
-/*
- * Copy module-related data into the load area, where it can be
- * used as a directory for loaded modules.
- *
- * Module data is presented in a self-describing format. Each datum
- * is preceeded by a 32-bit identifier and a 32-bit size field.
- *
- * Currently, the following data are saved:
- *
- * MOD_NAME (variable) module name (string)
- * MOD_TYPE (variable) module type (string)
- * MOD_ARGS (variable) module parameters (string)
- * MOD_ADDR sizeof(vm_offset_t) module load address
- * MOD_SIZE sizeof(size_t) module size
- * MOD_METADATA (variable) type-specific metadata
- */
-#define COPY32(v, a) { \
- u_int32_t x = (v); \
- i386_copyin(&x, a, sizeof(x)); \
- a += sizeof(x); \
-}
-
-#define MOD_STR(t, a, s) { \
- COPY32(t, a); \
- COPY32(strlen(s) + 1, a); \
- i386_copyin(s, a, strlen(s) + 1); \
- a += roundup(strlen(s) + 1, sizeof(u_long));\
-}
-
-#define MOD_NAME(a, s) MOD_STR(MODINFO_NAME, a, s)
-#define MOD_TYPE(a, s) MOD_STR(MODINFO_TYPE, a, s)
-#define MOD_ARGS(a, s) MOD_STR(MODINFO_ARGS, a, s)
-
-#define MOD_VAR(t, a, s) { \
- COPY32(t, a); \
- COPY32(sizeof(s), a); \
- i386_copyin(&s, a, sizeof(s)); \
- a += roundup(sizeof(s), sizeof(u_long)); \
-}
-
-#define MOD_ADDR(a, s) MOD_VAR(MODINFO_ADDR, a, s)
-#define MOD_SIZE(a, s) MOD_VAR(MODINFO_SIZE, a, s)
-
-#define MOD_METADATA(a, mm) { \
- COPY32(MODINFO_METADATA | mm->md_type, a); \
- COPY32(mm->md_size, a); \
- i386_copyin(mm->md_data, a, mm->md_size); \
- a += roundup(mm->md_size, sizeof(u_long));\
-}
-
-#define MOD_END(a) { \
- COPY32(MODINFO_END, a); \
- COPY32(0, a); \
-}
-
-vm_offset_t
-bi_copymodules(vm_offset_t addr)
-{
- struct loaded_module *mp;
- struct module_metadata *md;
-
- /* start with the first module on the list, should be the kernel */
- for (mp = mod_findmodule(NULL, NULL); mp != NULL; mp = mp->m_next) {
-
- MOD_NAME(addr, mp->m_name); /* this field must come first */
- MOD_TYPE(addr, mp->m_type);
- if (mp->m_args)
- MOD_ARGS(addr, mp->m_args);
- MOD_ADDR(addr, mp->m_addr);
- MOD_SIZE(addr, mp->m_size);
- for (md = mp->m_metadata; md != NULL; md = md->md_next)
- if (!(md->md_type & MODINFOMD_NOCOPY))
- MOD_METADATA(addr, md);
- }
- MOD_END(addr);
- return(addr);
-}
-
-/*
- * Load the information expected by an i386 kernel.
- *
- * - The 'boothowto' argument is constructed
- * - The 'botdev' argument is constructed
- * - The 'bootinfo' struct is constructed, and copied into the kernel space.
- * - The kernel environment is copied into kernel space.
- * - Module metadata are formatted and placed in kernel space.
- */
-int
-bi_load(char *args, int *howtop, int *bootdevp, vm_offset_t *bip)
-{
- struct loaded_module *xp;
- struct i386_devdesc *rootdev;
- vm_offset_t addr, bootinfo_addr;
- char *rootdevname;
- int bootdevnr, i;
- u_int pad;
- char *kernelname;
- const char *kernelpath;
-
- *howtop = bi_getboothowto(args);
-
- /*
- * Allow the environment variable 'rootdev' to override the supplied device
- * This should perhaps go to MI code and/or have $rootdev tested/set by
- * MI code before launching the kernel.
- */
- rootdevname = getenv("rootdev");
- i386_getdev((void **)(&rootdev), rootdevname, NULL);
- if (rootdev == NULL) { /* bad $rootdev/$currdev */
- printf("can't determine root device\n");
- return(EINVAL);
- }
-
- /* Try reading the /etc/fstab file to select the root device */
- getrootmount(i386_fmtdev((void *)rootdev));
-
- /* Do legacy rootdev guessing */
- switch(rootdev->d_type) {
- case DEVT_DISK:
- /* pass in the BIOS device number of the current disk */
- bi.bi_bios_dev = bd_unit2bios(rootdev->d_kind.biosdisk.unit);
- bootdevnr = bd_getdev(rootdev);
- if (bootdevnr != -1)
- break;
- printf("root device %s invalid\n", i386_fmtdev(rootdev));
- return(EINVAL);
-
- default:
- printf("WARNING - don't know how to boot from device type %d\n", rootdev->d_type);
- }
- free(rootdev);
- *bootdevp = bootdevnr;
-
- /* legacy bootinfo structure */
- bi.bi_version = BOOTINFO_VERSION;
- bi.bi_kernelname = 0; /* XXX char * -> kernel name */
- bi.bi_nfs_diskless = 0; /* struct nfs_diskless * */
- bi.bi_n_bios_used = 0; /* XXX would have to hook biosdisk driver for these */
- for (i = 0; i < N_BIOS_GEOM; i++)
- bi.bi_bios_geom[i] = bd_getbigeom(i);
- bi.bi_size = sizeof(bi);
- bi.bi_memsizes_valid = 1;
- bi.bi_basemem = bios_basemem / 1024;
- bi.bi_extmem = bios_extmem / 1024;
-
- /* find the last module in the chain */
- addr = 0;
- for (xp = mod_findmodule(NULL, NULL); xp != NULL; xp = xp->m_next) {
- if (addr < (xp->m_addr + xp->m_size))
- addr = xp->m_addr + xp->m_size;
- }
- /* pad to a page boundary */
- pad = (u_int)addr & PAGE_MASK;
- if (pad != 0) {
- pad = PAGE_SIZE - pad;
- addr += pad;
- }
-
- /* copy our environment */
- bi.bi_envp = addr;
- addr = bi_copyenv(addr);
-
- /* pad to a page boundary */
- pad = (u_int)addr & PAGE_MASK;
- if (pad != 0) {
- pad = PAGE_SIZE - pad;
- addr += pad;
- }
- /* copy module list and metadata */
- bi.bi_modulep = addr;
- addr = bi_copymodules(addr);
-
- /* all done copying stuff in, save end of loaded object space */
- bi.bi_kernend = addr;
-
- *howtop |= RB_BOOTINFO; /* it's there now */
-
- /*
- * Get the kernel name, strip off any device prefix.
- */
- kernelname = getenv("kernelname");
- i386_getdev(NULL, kernelname, &kernelpath);
- bi.bi_kernelname = VTOP(kernelpath);
- *bip = VTOP(&bi);
-
- return(0);
-}
diff --git a/sys/boot/i386/libi386/bootinfo64.c b/sys/boot/i386/libi386/bootinfo64.c
deleted file mode 100644
index a8738e12dcc3..000000000000
--- a/sys/boot/i386/libi386/bootinfo64.c
+++ /dev/null
@@ -1,334 +0,0 @@
-/*-
- * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include <stand.h>
-#include <sys/param.h>
-#include <sys/reboot.h>
-#include <sys/linker.h>
-#include <machine/bootinfo.h>
-#include "bootstrap.h"
-#include "libi386.h"
-#include "btxv86.h"
-
-static struct bootinfo bi;
-
-/*
- * Return a 'boothowto' value corresponding to the kernel arguments in
- * (kargs) and any relevant environment variables.
- */
-static struct
-{
- char *ev;
- int mask;
-} howto_names[] = {
- {"boot_askname", RB_ASKNAME},
- {"boot_cdrom", RB_CDROM},
- {"boot_userconfig", RB_CONFIG},
- {"boot_ddb", RB_KDB},
- {"boot_gdb", RB_GDB},
- {"boot_single", RB_SINGLE},
- {"boot_verbose", RB_VERBOSE},
- {NULL, 0}
-};
-
-int
-bi_getboothowto(char *kargs)
-{
- char *cp;
- int howto;
- int active;
- int i;
-
- /* Parse kargs */
- howto = 0;
- if (kargs != NULL) {
- cp = kargs;
- active = 0;
- while (*cp != 0) {
- if (!active && (*cp == '-')) {
- active = 1;
- } else if (active)
- switch (*cp) {
- case 'a':
- howto |= RB_ASKNAME;
- break;
- case 'c':
- howto |= RB_CONFIG;
- break;
- case 'C':
- howto |= RB_CDROM;
- break;
- case 'd':
- howto |= RB_KDB;
- break;
- case 'g':
- howto |= RB_GDB;
- break;
- case 'h':
- howto |= RB_SERIAL;
- break;
- case 'r':
- howto |= RB_DFLTROOT;
- break;
- case 's':
- howto |= RB_SINGLE;
- break;
- case 'v':
- howto |= RB_VERBOSE;
- break;
- default:
- active = 0;
- break;
- }
- cp++;
- }
- }
- /* get equivalents from the environment */
- for (i = 0; howto_names[i].ev != NULL; i++)
- if (getenv(howto_names[i].ev) != NULL)
- howto |= howto_names[i].mask;
- if (!strcmp(getenv("console"), "comconsole"))
- howto |= RB_SERIAL;
- return(howto);
-}
-
-/*
- * Copy the environment into the load area starting at (addr).
- * Each variable is formatted as <name>=<value>, with a single nul
- * separating each variable, and a double nul terminating the environment.
- */
-vm_offset_t
-bi_copyenv(vm_offset_t addr)
-{
- struct env_var *ep;
-
- /* traverse the environment */
- for (ep = environ; ep != NULL; ep = ep->ev_next) {
- i386_copyin(ep->ev_name, addr, strlen(ep->ev_name));
- addr += strlen(ep->ev_name);
- i386_copyin("=", addr, 1);
- addr++;
- if (ep->ev_value != NULL) {
- i386_copyin(ep->ev_value, addr, strlen(ep->ev_value));
- addr += strlen(ep->ev_value);
- }
- i386_copyin("", addr, 1);
- addr++;
- }
- i386_copyin("", addr, 1);
- addr++;
- return(addr);
-}
-
-/*
- * Copy module-related data into the load area, where it can be
- * used as a directory for loaded modules.
- *
- * Module data is presented in a self-describing format. Each datum
- * is preceeded by a 32-bit identifier and a 32-bit size field.
- *
- * Currently, the following data are saved:
- *
- * MOD_NAME (variable) module name (string)
- * MOD_TYPE (variable) module type (string)
- * MOD_ARGS (variable) module parameters (string)
- * MOD_ADDR sizeof(vm_offset_t) module load address
- * MOD_SIZE sizeof(size_t) module size
- * MOD_METADATA (variable) type-specific metadata
- */
-#define COPY32(v, a) { \
- u_int32_t x = (v); \
- i386_copyin(&x, a, sizeof(x)); \
- a += sizeof(x); \
-}
-
-#define MOD_STR(t, a, s) { \
- COPY32(t, a); \
- COPY32(strlen(s) + 1, a); \
- i386_copyin(s, a, strlen(s) + 1); \
- a += roundup(strlen(s) + 1, sizeof(u_long));\
-}
-
-#define MOD_NAME(a, s) MOD_STR(MODINFO_NAME, a, s)
-#define MOD_TYPE(a, s) MOD_STR(MODINFO_TYPE, a, s)
-#define MOD_ARGS(a, s) MOD_STR(MODINFO_ARGS, a, s)
-
-#define MOD_VAR(t, a, s) { \
- COPY32(t, a); \
- COPY32(sizeof(s), a); \
- i386_copyin(&s, a, sizeof(s)); \
- a += roundup(sizeof(s), sizeof(u_long)); \
-}
-
-#define MOD_ADDR(a, s) MOD_VAR(MODINFO_ADDR, a, s)
-#define MOD_SIZE(a, s) MOD_VAR(MODINFO_SIZE, a, s)
-
-#define MOD_METADATA(a, mm) { \
- COPY32(MODINFO_METADATA | mm->md_type, a); \
- COPY32(mm->md_size, a); \
- i386_copyin(mm->md_data, a, mm->md_size); \
- a += roundup(mm->md_size, sizeof(u_long));\
-}
-
-#define MOD_END(a) { \
- COPY32(MODINFO_END, a); \
- COPY32(0, a); \
-}
-
-vm_offset_t
-bi_copymodules(vm_offset_t addr)
-{
- struct loaded_module *mp;
- struct module_metadata *md;
-
- /* start with the first module on the list, should be the kernel */
- for (mp = mod_findmodule(NULL, NULL); mp != NULL; mp = mp->m_next) {
-
- MOD_NAME(addr, mp->m_name); /* this field must come first */
- MOD_TYPE(addr, mp->m_type);
- if (mp->m_args)
- MOD_ARGS(addr, mp->m_args);
- MOD_ADDR(addr, mp->m_addr);
- MOD_SIZE(addr, mp->m_size);
- for (md = mp->m_metadata; md != NULL; md = md->md_next)
- if (!(md->md_type & MODINFOMD_NOCOPY))
- MOD_METADATA(addr, md);
- }
- MOD_END(addr);
- return(addr);
-}
-
-/*
- * Load the information expected by an i386 kernel.
- *
- * - The 'boothowto' argument is constructed
- * - The 'botdev' argument is constructed
- * - The 'bootinfo' struct is constructed, and copied into the kernel space.
- * - The kernel environment is copied into kernel space.
- * - Module metadata are formatted and placed in kernel space.
- */
-int
-bi_load(char *args, int *howtop, int *bootdevp, vm_offset_t *bip)
-{
- struct loaded_module *xp;
- struct i386_devdesc *rootdev;
- vm_offset_t addr, bootinfo_addr;
- char *rootdevname;
- int bootdevnr, i;
- u_int pad;
- char *kernelname;
- const char *kernelpath;
-
- *howtop = bi_getboothowto(args);
-
- /*
- * Allow the environment variable 'rootdev' to override the supplied device
- * This should perhaps go to MI code and/or have $rootdev tested/set by
- * MI code before launching the kernel.
- */
- rootdevname = getenv("rootdev");
- i386_getdev((void **)(&rootdev), rootdevname, NULL);
- if (rootdev == NULL) { /* bad $rootdev/$currdev */
- printf("can't determine root device\n");
- return(EINVAL);
- }
-
- /* Try reading the /etc/fstab file to select the root device */
- getrootmount(i386_fmtdev((void *)rootdev));
-
- /* Do legacy rootdev guessing */
- switch(rootdev->d_type) {
- case DEVT_DISK:
- /* pass in the BIOS device number of the current disk */
- bi.bi_bios_dev = bd_unit2bios(rootdev->d_kind.biosdisk.unit);
- bootdevnr = bd_getdev(rootdev);
- if (bootdevnr != -1)
- break;
- printf("root device %s invalid\n", i386_fmtdev(rootdev));
- return(EINVAL);
-
- default:
- printf("WARNING - don't know how to boot from device type %d\n", rootdev->d_type);
- }
- free(rootdev);
- *bootdevp = bootdevnr;
-
- /* legacy bootinfo structure */
- bi.bi_version = BOOTINFO_VERSION;
- bi.bi_kernelname = 0; /* XXX char * -> kernel name */
- bi.bi_nfs_diskless = 0; /* struct nfs_diskless * */
- bi.bi_n_bios_used = 0; /* XXX would have to hook biosdisk driver for these */
- for (i = 0; i < N_BIOS_GEOM; i++)
- bi.bi_bios_geom[i] = bd_getbigeom(i);
- bi.bi_size = sizeof(bi);
- bi.bi_memsizes_valid = 1;
- bi.bi_basemem = bios_basemem / 1024;
- bi.bi_extmem = bios_extmem / 1024;
-
- /* find the last module in the chain */
- addr = 0;
- for (xp = mod_findmodule(NULL, NULL); xp != NULL; xp = xp->m_next) {
- if (addr < (xp->m_addr + xp->m_size))
- addr = xp->m_addr + xp->m_size;
- }
- /* pad to a page boundary */
- pad = (u_int)addr & PAGE_MASK;
- if (pad != 0) {
- pad = PAGE_SIZE - pad;
- addr += pad;
- }
-
- /* copy our environment */
- bi.bi_envp = addr;
- addr = bi_copyenv(addr);
-
- /* pad to a page boundary */
- pad = (u_int)addr & PAGE_MASK;
- if (pad != 0) {
- pad = PAGE_SIZE - pad;
- addr += pad;
- }
- /* copy module list and metadata */
- bi.bi_modulep = addr;
- addr = bi_copymodules(addr);
-
- /* all done copying stuff in, save end of loaded object space */
- bi.bi_kernend = addr;
-
- *howtop |= RB_BOOTINFO; /* it's there now */
-
- /*
- * Get the kernel name, strip off any device prefix.
- */
- kernelname = getenv("kernelname");
- i386_getdev(NULL, kernelname, &kernelpath);
- bi.bi_kernelname = VTOP(kernelpath);
- *bip = VTOP(&bi);
-
- return(0);
-}
diff --git a/sys/boot/i386/libi386/elf32_freebsd.c b/sys/boot/i386/libi386/elf32_freebsd.c
deleted file mode 100644
index a3d3ef9412d6..000000000000
--- a/sys/boot/i386/libi386/elf32_freebsd.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/*-
- * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/exec.h>
-#include <sys/reboot.h>
-#include <sys/linker.h>
-#include <string.h>
-#include <machine/bootinfo.h>
-#include <machine/elf.h>
-#include <stand.h>
-
-#include "bootstrap.h"
-#include "libi386.h"
-#include "btxv86.h"
-
-static int elf_exec(struct loaded_module *amp);
-
-struct module_format i386_elf = { elf_loadmodule, elf_exec };
-
-static struct bootinfo bi;
-
-/*
- * There is an a.out kernel and one or more a.out modules loaded.
- * We wish to start executing the kernel image, so make such
- * preparations as are required, and do so.
- */
-static int
-elf_exec(struct loaded_module *mp)
-{
- struct module_metadata *md;
- Elf_Ehdr *ehdr;
- vm_offset_t entry, bootinfop;
- int boothowto, err, bootdev;
- struct bootinfo *bi;
- vm_offset_t ssym, esym;
-
- if ((md = mod_findmetadata(mp, MODINFOMD_ELFHDR)) == NULL)
- return(EFTYPE); /* XXX actually EFUCKUP */
- ehdr = (Elf_Ehdr *)&(md->md_data);
-
- if ((err = bi_load(mp->m_args, &boothowto, &bootdev, &bootinfop)) != 0)
- return(err);
- entry = ehdr->e_entry & 0xffffff;
-
- ssym = esym = 0;
- if ((md = mod_findmetadata(mp, MODINFOMD_SSYM)) != NULL)
- ssym = *((vm_offset_t *)&(md->md_data));
- if ((md = mod_findmetadata(mp, MODINFOMD_ESYM)) != NULL)
- esym = *((vm_offset_t *)&(md->md_data));
- if (ssym == 0 || esym == 0)
- ssym = esym = 0; /* sanity */
- bi = (struct bootinfo *)PTOV(bootinfop);
- bi->bi_symtab = ssym; /* XXX this is only the primary kernel symtab */
- bi->bi_esymtab = esym;
-
-
-#ifdef DEBUG
- printf("Start @ 0x%lx ...\n", entry);
-#endif
-
- __exec((void *)entry, boothowto, bootdev, 0, 0, 0, bootinfop);
-
- panic("exec returned");
-}
diff --git a/sys/boot/i386/libi386/elf64_freebsd.c b/sys/boot/i386/libi386/elf64_freebsd.c
deleted file mode 100644
index a3d3ef9412d6..000000000000
--- a/sys/boot/i386/libi386/elf64_freebsd.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/*-
- * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/exec.h>
-#include <sys/reboot.h>
-#include <sys/linker.h>
-#include <string.h>
-#include <machine/bootinfo.h>
-#include <machine/elf.h>
-#include <stand.h>
-
-#include "bootstrap.h"
-#include "libi386.h"
-#include "btxv86.h"
-
-static int elf_exec(struct loaded_module *amp);
-
-struct module_format i386_elf = { elf_loadmodule, elf_exec };
-
-static struct bootinfo bi;
-
-/*
- * There is an a.out kernel and one or more a.out modules loaded.
- * We wish to start executing the kernel image, so make such
- * preparations as are required, and do so.
- */
-static int
-elf_exec(struct loaded_module *mp)
-{
- struct module_metadata *md;
- Elf_Ehdr *ehdr;
- vm_offset_t entry, bootinfop;
- int boothowto, err, bootdev;
- struct bootinfo *bi;
- vm_offset_t ssym, esym;
-
- if ((md = mod_findmetadata(mp, MODINFOMD_ELFHDR)) == NULL)
- return(EFTYPE); /* XXX actually EFUCKUP */
- ehdr = (Elf_Ehdr *)&(md->md_data);
-
- if ((err = bi_load(mp->m_args, &boothowto, &bootdev, &bootinfop)) != 0)
- return(err);
- entry = ehdr->e_entry & 0xffffff;
-
- ssym = esym = 0;
- if ((md = mod_findmetadata(mp, MODINFOMD_SSYM)) != NULL)
- ssym = *((vm_offset_t *)&(md->md_data));
- if ((md = mod_findmetadata(mp, MODINFOMD_ESYM)) != NULL)
- esym = *((vm_offset_t *)&(md->md_data));
- if (ssym == 0 || esym == 0)
- ssym = esym = 0; /* sanity */
- bi = (struct bootinfo *)PTOV(bootinfop);
- bi->bi_symtab = ssym; /* XXX this is only the primary kernel symtab */
- bi->bi_esymtab = esym;
-
-
-#ifdef DEBUG
- printf("Start @ 0x%lx ...\n", entry);
-#endif
-
- __exec((void *)entry, boothowto, bootdev, 0, 0, 0, bootinfop);
-
- panic("exec returned");
-}
diff --git a/sys/boot/ofw/libofw/devicename.c b/sys/boot/ofw/libofw/devicename.c
deleted file mode 100644
index d8ee1133299e..000000000000
--- a/sys/boot/ofw/libofw/devicename.c
+++ /dev/null
@@ -1,236 +0,0 @@
-/*-
- * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include <stand.h>
-#include <string.h>
-#include <sys/disklabel.h>
-#include "bootstrap.h"
-#include "libalpha.h"
-
-static int alpha_parsedev(struct alpha_devdesc **dev, const char *devspec, const char **path);
-
-/*
- * Point (dev) at an allocated device specifier for the device matching the
- * path in (devspec). If it contains an explicit device specification,
- * use that. If not, use the default device.
- */
-int
-alpha_getdev(void **vdev, const char *devspec, const char **path)
-{
- struct alpha_devdesc **dev = (struct alpha_devdesc **)vdev;
- int rv;
-
- /*
- * If it looks like this is just a path and no
- * device, go with the current device.
- */
- if ((devspec == NULL) ||
- (devspec[0] == '/') ||
- (strchr(devspec, ':') == NULL)) {
-
- if (((rv = alpha_parsedev(dev, getenv("currdev"), NULL)) == 0) &&
- (path != NULL))
- *path = devspec;
- return(rv);
- }
-
- /*
- * Try to parse the device name off the beginning of the devspec
- */
- return(alpha_parsedev(dev, devspec, path));
-}
-
-/*
- * Point (dev) at an allocated device specifier matching the string version
- * at the beginning of (devspec). Return a pointer to the remaining
- * text in (path).
- *
- * In all cases, the beginning of (devspec) is compared to the names
- * of known devices in the device switch, and then any following text
- * is parsed according to the rules applied to the device type.
- *
- * For disk-type devices, the syntax is:
- *
- * disk<unit>[s<slice>][<partition>]:
- *
- */
-static int
-alpha_parsedev(struct alpha_devdesc **dev, const char *devspec, const char **path)
-{
- struct alpha_devdesc *idev;
- struct devsw *dv;
- int i, unit, slice, partition, err;
- char *cp;
- const char *np;
-
- /* minimum length check */
- if (strlen(devspec) < 2)
- return(EINVAL);
-
- /* look for a device that matches */
- for (i = 0, dv = NULL; devsw[i] != NULL; i++) {
- if (!strncmp(devspec, devsw[i]->dv_name, strlen(devsw[i]->dv_name))) {
- dv = devsw[i];
- break;
- }
- }
-
- if (dv == NULL)
- return(ENOENT);
- idev = malloc(sizeof(struct alpha_devdesc));
- err = 0;
- np = (devspec + strlen(dv->dv_name));
-
- switch(dv->dv_type) {
- case DEVT_NONE: /* XXX what to do here? Do we care? */
- break;
-
- case DEVT_DISK:
- unit = -1;
- slice = -1;
- partition = -1;
- if (*np && (*np != ':')) {
- unit = strtol(np, &cp, 10); /* next comes the unit number */
- if (cp == np) {
- err = EUNIT;
- goto fail;
- }
- if (*cp == 's') { /* got a slice number */
- np = cp + 1;
- slice = strtol(np, &cp, 10);
- if (cp == np) {
- err = ESLICE;
- goto fail;
- }
- }
- if (*cp && (*cp != ':')) {
- partition = *cp - 'a'; /* get a partition number */
- if ((partition < 0) || (partition >= MAXPARTITIONS)) {
- err = EPART;
- goto fail;
- }
- cp++;
- }
- }
- if (*cp && (*cp != ':')) {
- err = EINVAL;
- goto fail;
- }
-
- idev->d_kind.srmdisk.unit = unit;
- idev->d_kind.srmdisk.slice = slice;
- idev->d_kind.srmdisk.partition = partition;
- if (path != NULL)
- *path = (*cp == 0) ? cp : cp + 1;
- break;
-
- case DEVT_NET:
- unit = 0;
-
- if (*np && (*np != ':')) {
- unit = strtol(np, &cp, 0); /* get unit number if present */
- if (cp == np) {
- err = EUNIT;
- goto fail;
- }
- }
- if (*cp && (*cp != ':')) {
- err = EINVAL;
- goto fail;
- }
-
- idev->d_kind.netif.unit = unit;
- if (path != NULL)
- *path = (*cp == 0) ? cp : cp + 1;
- break;
-
- default:
- err = EINVAL;
- goto fail;
- }
- idev->d_dev = dv;
- idev->d_type = dv->dv_type;
- if (dev == NULL) {
- free(idev);
- } else {
- *dev = idev;
- }
- return(0);
-
- fail:
- free(idev);
- return(err);
-}
-
-
-char *
-alpha_fmtdev(void *vdev)
-{
- struct alpha_devdesc *dev = (struct alpha_devdesc *)vdev;
- static char buf[128]; /* XXX device length constant? */
- char *cp;
-
- switch(dev->d_type) {
- case DEVT_NONE:
- strcpy(buf, "(no device)");
- break;
-
- case DEVT_DISK:
- cp = buf;
- cp += sprintf(cp, "%s%d", dev->d_dev->dv_name, dev->d_kind.srmdisk.unit);
- if (dev->d_kind.srmdisk.slice > 0)
- cp += sprintf(cp, "s%d", dev->d_kind.srmdisk.slice);
- if (dev->d_kind.srmdisk.partition >= 0)
- cp += sprintf(cp, "%c", dev->d_kind.srmdisk.partition + 'a');
- strcat(cp, ":");
- break;
-
- case DEVT_NET:
- sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_kind.netif.unit);
- break;
- }
- return(buf);
-}
-
-
-/*
- * Set currdev to suit the value being supplied in (value)
- */
-int
-alpha_setcurrdev(struct env_var *ev, int flags, void *value)
-{
- struct alpha_devdesc *ncurr;
- int rv;
-
- if ((rv = alpha_parsedev(&ncurr, value, NULL)) != 0)
- return(rv);
- free(ncurr);
- env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL);
- return(0);
-}
-
diff --git a/sys/boot/ofw/libofw/ofw_console.c b/sys/boot/ofw/libofw/ofw_console.c
deleted file mode 100644
index e32d43d3b66f..000000000000
--- a/sys/boot/ofw/libofw/ofw_console.c
+++ /dev/null
@@ -1,165 +0,0 @@
-/* $FreeBSD$ */
-/* $NetBSD: prom.c,v 1.3 1997/09/06 14:03:58 drochner Exp $ */
-
-/*
- * 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 <sys/types.h>
-
-#include <machine/prom.h>
-#include <machine/rpb.h>
-
-#include "common.h"
-#include "bootstrap.h"
-
-int console;
-
-static void prom_probe(struct console *cp);
-static int prom_init(int);
-void prom_putchar(int);
-int prom_getchar(void);
-int prom_poll(void);
-
-struct console promconsole = {
- "prom",
- "SRM firmware console",
- 0,
- prom_probe,
- prom_init,
- prom_putchar,
- prom_getchar,
- prom_poll,
-};
-
-void
-init_prom_calls()
-{
- extern struct prom_vec prom_dispatch_v;
- struct rpb *r;
- struct crb *c;
- char buf[4];
-
- r = (struct rpb *)HWRPB_ADDR;
- c = (struct crb *)((u_int8_t *)r + r->rpb_crb_off);
-
- prom_dispatch_v.routine_arg = c->crb_v_dispatch;
- prom_dispatch_v.routine = c->crb_v_dispatch->entry_va;
-
- /* Look for console tty. */
- prom_getenv(PROM_E_TTY_DEV, buf, 4);
- console = buf[0] - '0';
-}
-
-static void
-prom_probe(struct console *cp)
-{
- init_prom_calls();
- cp->c_flags |= C_PRESENTIN|C_PRESENTOUT;
-}
-
-static int
-prom_init(int arg)
-{
- return 0;
-}
-
-void
-prom_putchar(int c)
-{
- prom_return_t ret;
- char cbuf;
-
- cbuf = c;
- do {
- ret.bits = prom_dispatch(PROM_R_PUTS, console, &cbuf, 1);
- } while ((ret.u.retval & 1) == 0);
-}
-
-static int saved_char = -1;
-
-int
-prom_getchar()
-{
- prom_return_t ret;
-
- if (saved_char != -1) {
- int c = saved_char;
- saved_char = -1;
- return c;
- }
-
- for (;;) {
- ret.bits = prom_dispatch(PROM_R_GETC, console);
- if (ret.u.status == 0 || ret.u.status == 1)
- return (ret.u.retval);
- }
-}
-
-int
-prom_poll()
-{
- prom_return_t ret;
-
- if (saved_char != -1)
- return 1;
-
- ret.bits = prom_dispatch(PROM_R_GETC, console);
- if (ret.u.status == 0 || ret.u.status == 1) {
- saved_char = ret.u.retval;
- return 1;
- }
-
- return 0;
-}
-
-int
-prom_getenv(id, buf, len)
- int id, len;
- char *buf;
-{
- prom_return_t ret;
-
- ret.bits = prom_dispatch(PROM_R_GETENV, id, buf, len-1);
- if (ret.u.status & 0x4)
- ret.u.retval = 0;
- buf[ret.u.retval] = '\0';
-
- return (ret.u.retval);
-}
-
-int
-prom_open(dev, len)
- char *dev;
- int len;
-{
- prom_return_t ret;
-
- ret.bits = prom_dispatch(PROM_R_OPEN, dev, len);
- if (ret.u.status & 0x4)
- return (-1);
- else
- return (ret.u.retval);
-}
diff --git a/sys/boot/ofw/libofw/ofw_copy.c b/sys/boot/ofw/libofw/ofw_copy.c
deleted file mode 100644
index 95b6cba677e4..000000000000
--- a/sys/boot/ofw/libofw/ofw_copy.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*-
- * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-/*
- * MD primitives supporting placement of module data
- *
- * XXX should check load address/size against memory top.
- */
-#include <stand.h>
-
-#include "libalpha.h"
-
-int
-alpha_copyin(void *src, vm_offset_t dest, size_t len)
-{
- bcopy(src, dest, len);
- return(len);
-}
-
-int
-alpha_copyout(vm_offset_t src, void *dest, size_t len)
-{
- bcopy(src, dest, len);
- return(len);
-}
-
-int
-alpha_readin(int fd, vm_offset_t dest, size_t len)
-{
- return(read(fd, (void *) dest, len));
-}
-
-
diff --git a/sys/boot/ofw/libofw/ofw_module.c b/sys/boot/ofw/libofw/ofw_module.c
deleted file mode 100644
index 4ac21d42242d..000000000000
--- a/sys/boot/ofw/libofw/ofw_module.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*-
- * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-/*
- * alpha-specific module functionality.
- *
- */
-
-#include <stand.h>
-#include <string.h>
-
-#include "bootstrap.h"
-#include "libalpha.h"
-
-/*
- * Use voodoo to load modules required by current hardware.
- */
-int
-alpha_autoload(void)
-{
- /* XXX use PnP to locate stuff here */
- return(0);
-}
diff --git a/sys/boot/pc98/btx/btx/btx.S b/sys/boot/pc98/btx/btx/btx.S
deleted file mode 100644
index 5858ddad51ff..000000000000
--- a/sys/boot/pc98/btx/btx/btx.S
+++ /dev/null
@@ -1,1154 +0,0 @@
-#
-# Copyright (c) 1998 Robert Nordier
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms are freely
-# permitted provided that the above copyright notice and this
-# paragraph and the following disclaimer are duplicated in all
-# such forms.
-#
-# This software is provided "AS IS" and without any express or
-# implied warranties, including, without limitation, the implied
-# warranties of merchantability and fitness for a particular
-# purpose.
-#
-
-# $FreeBSD$
-
-#
-# Memory layout.
-#
- .set MEM_BTX,0x1000 # Start of BTX memory
- .set MEM_ESP0,0x1800 # Supervisor stack
- .set MEM_BUF,0x1800 # Scratch buffer
- .set MEM_ESP1,0x1e00 # Link stack
- .set MEM_IDT,0x1e00 # IDT
- .set MEM_TSS,0x1f98 # TSS
- .set MEM_MAP,0x2000 # I/O bit map
- .set MEM_DIR,0x4000 # Page directory
- .set MEM_TBL,0x5000 # Page tables
- .set MEM_ORG,0x9000 # BTX code
- .set MEM_USR,0xa000 # Start of user memory
-#
-# Paging control.
-#
- .set PAG_SIZ,0x1000 # Page size
- .set PAG_CNT,0x1000 # Pages to map
-#
-# Segment selectors.
-#
- .set SEL_SCODE,0x8 # Supervisor code
- .set SEL_SDATA,0x10 # Supervisor data
- .set SEL_RCODE,0x18 # Real mode code
- .set SEL_RDATA,0x20 # Real mode data
- .set SEL_UCODE,0x28|3 # User code
- .set SEL_UDATA,0x30|3 # User data
- .set SEL_TSS,0x38 # TSS
-#
-# Task state segment fields.
-#
- .set TSS_ESP0,0x4 # PL 0 ESP
- .set TSS_SS0,0x8 # PL 0 SS
- .set TSS_ESP1,0xc # PL 1 ESP
- .set TSS_MAP,0x66 # I/O bit map base
-#
-# System calls.
-#
- .set SYS_EXIT,0x0 # Exit
- .set SYS_EXEC,0x1 # Exec
-#
-# V86 constants.
-#
- .set V86_FLG,0x208eff # V86 flag mask
- .set V86_STK,0x400 # V86 stack allowance
-#
-# Dump format control bytes.
-#
- .set DMP_X16,0x1 # Word
- .set DMP_X32,0x2 # Long
- .set DMP_MEM,0x4 # Memory
- .set DMP_EOL,0x8 # End of line
-#
-# Screen defaults and assumptions.
-#
-.`ifdef' PC98
- .set SCR_MAT,0xe1 # Mode/attribute
-.else
- .set SCR_MAT,0x7 # Mode/attribute
-.endif
- .set SCR_COL,0x50 # Columns per row
- .set SCR_ROW,0x19 # Rows per screen
-#
-# BIOS Data Area locations.
-#
-.`ifdef' PC98
- .set BDA_MEM,0xa1501 # Free memory
- .set BDA_POS,0xa153e # Cursor position
-.else
- .set BDA_MEM,0x413 # Free memory
- .set BDA_SCR,0x449 # Video mode
- .set BDA_POS,0x450 # Cursor position
-.endif
-#
-# Derivations, for brevity.
-#
- .set _ESP0H,MEM_ESP0>>0x8 # Byte 1 of ESP0
- .set _ESP1H,MEM_ESP1>>0x8 # Byte 1 of ESP1
- .set _TSSIO,MEM_MAP-MEM_TSS # TSS I/O base
- .set _TSSLM,MEM_DIR-MEM_TSS-1 # TSS limit
- .set _IDTLM,MEM_TSS-MEM_IDT-1 # IDT limit
-#
-# Code segment.
-#
- .globl start
-start: # Start of code
-#
-# BTX header.
-#
-btx_hdr: .byte 0xeb # Machine ID
- .byte 0xe # Header size
- .ascii "BTX" # Magic
- .byte 0x1 # Major version
- .byte 0x1 # Minor version
- .byte 0x0 # Flags
- .word PAG_CNT-MEM_ORG>>0xc # Paging control
- .word break-start # Text size
- .long 0x0 # Entry address
-#
-# Initialization routine.
-#
-init: cli # Disable interrupts
- xorl %eax,%eax # Zero/segment
- movl %ax,%ss # Set up
- movwir(MEM_ESP0,_sp) # stack
- movl %ax,%es # Address
- movl %ax,%ds # data
- pushw $0x2 # Clear
- popfw # flags
-#
-# Initialize memory.
-#
- movwir(MEM_IDT,_di) # Memory to initialize
- movwir((MEM_ORG-MEM_IDT)/2,_cx) # Words to zero
- pushl %edi # Save
- rep # Zero-fill
- stosl # memory
- popl %edi # Restore
-#
-# Create IDT.
-#
- movwir(idtctl,_si) # Control string
-init.1: lodsb # Get entry
- cwde # count
- xchgl %eax,%ecx # as word
- jecxz init.4 # If done
- lodsb # Get segment
- xchgl %eax,%edx # P:DPL:type
- lodsl # Get control
- xchgl %eax,%ebx # set
- lodsl # Get handler offset
- movb $SEL_SCODE,%dh # Segment selector
-init.2: shrl %ebx # Handle this int?
- jnc init.3 # No
- movwr0(_ax,_di_) # Set handler offset
- movbr1(_dh,0x2,_di_) # and selector
- movbr1(_dl,0x5,_di_) # Set P:DPL:type
- addwia(0x4) # Next handler
-init.3: leaw1r(0x8,_di_,_di) # Next entry
- loop init.2 # Till set done
- jmp init.1 # Continue
-#
-# Initialize TSS.
-#
-init.4: movbi1(_ESP0H,TSS_ESP0+1,_di_) # Set ESP0
- movbi1(SEL_SDATA,TSS_SS0,_di_) # Set SS0
- movbi1(_ESP1H,TSS_ESP1+1,_di_) # Set ESP1
- movbi1(_TSSIO,TSS_MAP,_di_) # Set I/O bit map base
-ifdef(`PAGING',`
-#
-# Create page directory.
-#
- xorw %dx,%dx # Page
- movb $PAG_SIZ>>0x8,%dh # size
- xorw %ax,%ax # Zero
- movwir(MEM_DIR,_di) # Page directory
- movb $PAG_CNT>>0xa,%cl # Entries
- movwir(MEM_TBL|0x7,_ax) # First entry
-init.5: stosw # Write entry
- addl %edx,%eax # To next
- loop init.5 # Till done
-#
-# Create page tables.
-#
- movwir(MEM_TBL,_di) # Page table
- movb $PAG_CNT>>0x8,%ch # Entries
- xorl %eax,%eax # Start address
-init.6: movb $0x7,%al # Set U:W:P flags
- cmpwmr(btx_hdr+0x8,_cx) # Standard user page?
- jb init.7 # Yes
- cmpwir(PAG_CNT-MEM_BTX>>0xc,_cx)# BTX memory?
- jae init.7 # No or first page
- andb $~0x2,%al # Clear W flag
- cmpwir(PAG_CNT-MEM_USR>>0xc,_cx)# User page zero?
- jne init.7 # No
- tstbim(0x80,btx_hdr+0x7) # Unmap it?
- jz init.7 # No
- andb $~0x1,%al # Clear P flag
-init.7: stosw # Set entry
- addw %dx,%ax # Next address
- loop init.6 # Till done
-')
-#
-# Bring up the system.
-#
- movwir(0x2820,_bx) # Set protected mode
- callwi(setpic) # IRQ offsets
- lidtwm(idtdesc) # Set IDT
-ifdef(`PAGING',`
- xorw %ax,%ax # Set base
- movb $MEM_DIR>>0x8,%ah # of page
- movl %eax,%cr3 # directory
-')
- lgdtwm(gdtdesc) # Set GDT
- movl %cr0,%eax # Switch to
-ifdef(`PAGING',`
- o16 # protected mode
- orl $0x80000001,%eax # and enable paging
-',`
- o16 # protected mode
- orl $0x01,%eax #
-')
- movl %eax,%cr0 #
- jmpfwi(SEL_SCODE,init.8) # To 32-bit code
-init.8: xorl %ecx,%ecx # Zero
- movb $SEL_SDATA,%cl # To 32-bit
- movl %cx,%ss # stack
-#
-# Launch user task.
-#
- movb $SEL_TSS,%cl # Set task
- ltrl %ecx # register
- movl $MEM_USR,%edx # User base address
- movzwl %ss:BDA_MEM,%eax # Get free memory
-.`ifdef' PC98
- andl $0x7,%eax
- incl %eax
- shll $0x11,%eax # To bytes
-.else
- shll $0xa,%eax # To bytes
-.endif
- subl $0x1000,%eax # Less arg space
- subl %edx,%eax # Less base
- movb $SEL_UDATA,%cl # User data selector
- pushl %ecx # Set SS
- pushl %eax # Set ESP
- pushl $0x202 # Set flags (IF set)
- pushl $SEL_UCODE # Set CS
- pushl btx_hdr+0xc # Set EIP
- pushl %ecx # Set GS
- pushl %ecx # Set FS
- pushl %ecx # Set DS
- pushl %ecx # Set ES
- pushl %edx # Set EAX
- movb $0x7,%cl # Set remaining
-init.9: pushb $0x0 # general
- loop init.9 # registers
- popa # and initialize
- popl %es # Initialize
- popl %ds # user
- popl %fs # segment
- popl %gs # registers
- iret # To user mode
-#
-# Exit routine.
-#
-exit: cli # Disable interrupts
- movl $MEM_ESP0,%esp # Clear stack
-#
-# Turn off paging.
-#
- movl %cr0,%eax # Get CR0
-ifdef(`PAGING',`
- andl $~0x80000000,%eax # Disable
- movl %eax,%cr0 # paging
-')
- xorl %ecx,%ecx # Zero
-ifdef(`PAGING',`
- movl %ecx,%cr3 # Flush TLB
-')
-#
-# To 16 bits.
-#
- o16 # Reload
- jmpfwi(SEL_RCODE,exit.1) # CS
-exit.1: movb $SEL_RDATA,%cl # 16-bit selector
- movl %cx,%ss # Reload SS
- movl %cx,%ds # Load
- movl %cx,%es # remaining
- movl %cx,%fs # segment
- movl %cx,%gs # registers
-#
-# To real-address mode.
-#
- decl %eax # Switch to
- movl %eax,%cr0 # real mode
- jmpfwi(0x0,exit.2) # Reload CS
-exit.2: xorl %eax,%eax # Real mode segment
- movl %ax,%ss # Reload SS
- movl %ax,%ds # Address data
-.`ifdef' PC98
- movwir(0x1008,_bx) # Set real mode
-.else
- movwir(0x7008,_bx) # Set real mode
-.endif
- callwi(setpic) # IRQ offsets
- lidtwm(ivtdesc) # Set IVT
-#
-# Reboot or await reset.
-#
- sti # Enable interrupts
- tstbim(0x1,btx_hdr+0x7) # Reboot?
-exit.3: jz exit.3 # No
-.`ifdef' PC98
- movb $0xa0,%al
- outb %al,$0x35
- movb 0,%al
- outb %al,$0xf0
-exit.4: jmp exit.4
-.else
- int $0x19 # BIOS: Reboot
-.endif
-#
-# Set IRQ offsets by reprogramming 8259A PICs.
-#
-.`ifdef' PC98
-setpic: inb $0x02,%al # Save master
- pushl %eax # IMR
- inb $0x0a,%al # Save slave
- pushl %eax # IMR
- movb $0x11,%al # ICW1 to
- outb %al,$0x00 # master,
- outb %al,$0x08 # slave
- movb %bl,%al # ICW2 to
- outb %al,$0x02 # master
- movb %bh,%al # ICW2 to
- outb %al,$0x0a # slave
- movb $0x80,%al # ICW3 to
- outb %al,$0x02 # master
- movb $0x7,%al # ICW3 to
- outb %al,$0x0a # slave
- movb $0x1d,%al # ICW4 to
- outb %al,$0x02 # master,
- movb $0x9,%al # ICW4 to
- outb %al,$0x0a # slave
- popl %eax # Restore slave
- outb %al,$0x0a # IMR
- popl %eax # Restore master
- outb %al,$0x02 # IMR
-.else
-setpic: inb $0x21,%al # Save master
- pushl %eax # IMR
- inb $0xa1,%al # Save slave
- pushl %eax # IMR
- movb $0x11,%al # ICW1 to
- outb %al,$0x20 # master,
- outb %al,$0xa0 # slave
- movb %bl,%al # ICW2 to
- outb %al,$0x21 # master
- movb %bh,%al # ICW2 to
- outb %al,$0xa1 # slave
- movb $0x4,%al # ICW3 to
- outb %al,$0x21 # master
- movb $0x2,%al # ICW3 to
- outb %al,$0xa1 # slave
- movb $0x1,%al # ICW4 to
- outb %al,$0x21 # master,
- outb %al,$0xa1 # slave
- popl %eax # Restore slave
- outb %al,$0xa1 # IMR
- popl %eax # Restore master
- outb %al,$0x21 # IMR
-.endif
- ret # To caller
-#
-# Initiate return from V86 mode to user mode.
-#
-inthlt: hlt # To supervisor mode
-#
-# Exception jump table.
-#
-intx00: pushb $0x0 # Int 0x0: #DE
- jmp ex_noc # Divide error
- pushb $0x1 # Int 0x1: #DB
- jmp ex_noc # Debug
- pushb $0x3 # Int 0x3: #BP
- jmp ex_noc # Breakpoint
- pushb $0x4 # Int 0x4: #OF
- jmp ex_noc # Overflow
- pushb $0x5 # Int 0x5: #BR
- jmp ex_noc # BOUND range exceeded
- pushb $0x6 # Int 0x6: #UD
- jmp ex_noc # Invalid opcode
- pushb $0x7 # Int 0x7: #NM
- jmp ex_noc # Device not available
- pushb $0x8 # Int 0x8: #DF
- jmp except # Double fault
- pushb $0xa # Int 0xa: #TS
- jmp except # Invalid TSS
- pushb $0xb # Int 0xb: #NP
- jmp except # Segment not present
- pushb $0xc # Int 0xc: #SS
- jmp except # Stack segment fault
- pushb $0xd # Int 0xd: #GP
- jmp ex_v86 # General protection
- pushb $0xe # Int 0xe: #PF
- jmp except # Page fault
-intx10: pushb $0x10 # Int 0x10: #MF
- jmp ex_noc # Floating-point error
-#
-# Handle #GP exception.
-#
-ex_v86: testb $0x2,0x12(%esp,1) # V86 mode?
- jz except # No
- jmp v86mon # To monitor
-#
-# Save a zero error code.
-#
-ex_noc: pushl (%esp,1) # Duplicate int no
- movb $0x0,0x4(%esp,1) # Fake error code
-#
-# Handle exception.
-#
-except: cld # String ops inc
- pushl %ds # Save
- pushl %es # most
- pusha # registers
- movb $0x6,%al # Push loop count
- testb $0x2,0x3a(%esp,1) # V86 mode?
- jnz except.1 # Yes
- pushl %gs # Set GS
- pushl %fs # Set FS
- pushl %ds # Set DS
- pushl %es # Set ES
- movb $0x2,%al # Push loop count
- cmpw $SEL_SCODE,0x44(%esp,1) # Supervisor mode?
- jne except.1 # No
- pushl %ss # Set SS
- leal 0x50(%esp,1),%eax # Set
- pushl %eax # ESP
- jmp except.2 # Join common code
-except.1: pushl 0x50(%esp,1) # Set GS, FS, DS, ES
- decb %al # (if V86 mode), and
- jne except.1 # SS, ESP
-except.2: pushl $SEL_SDATA # Set up
- popl %ds # to
- pushl %ds # address
- popl %es # data
- movl %esp,%ebx # Stack frame
- movl $dmpfmt,%esi # Dump format string
- movl $MEM_BUF,%edi # Buffer
-.`ifdef' PC98
- pushl %eax
- pushl %edx
-wait.1:
- inb $0x60,%al
- testb $0x04,%al
- jz wait.1
- movb $0xe0,%al
- outb %al,$0x62
-wait.2:
- inb $0x60,%al
- testb $0x01,%al
- jz wait.2
- xorl %edx,%edx
- inb $0x62,%al
- movb %al,%dl
- inb $0x62,%al
- movb %al,%dh
- inb $0x62,%al
- inb $0x62,%al
- inb $0x62,%al
- movl %edx,%eax
- shlw $1,%ax
- movl $BDA_POS,%edx
- movw %ax,(%edx)
- popl %edx
- popl %eax
-.endif
- pushl %edi # Dump to
- call dump # buffer
- popl %esi # and
- call putstr # display
- leal 0x18(%esp,1),%esp # Discard frame
- popa # Restore
- popl %es # registers
- popl %ds # saved
- cmpb $0x3,(%esp,1) # Breakpoint?
- je except.3 # Yes
- jmp exit # Exit
-except.3: leal 0x8(%esp,1),%esp # Discard err, int no
- iret # From interrupt
-#
-# Return to user mode from V86 mode.
-#
-intrtn: cld # String ops inc
- pushl %ds # Address
- popl %es # data
- leal 0x3c(%ebp),%edx # V86 Segment registers
- movl MEM_TSS+TSS_ESP1,%esi # Link stack pointer
- lodsl # INT_V86 args pointer
- movl %esi,%ebx # Saved exception frame
- testl %eax,%eax # INT_V86 args?
- jz intrtn.2 # No
- movl $MEM_USR,%edi # User base
- movl 0x1c(%esi),%ebx # User ESP
- movl %eax,(%edi,%ebx,1) # Restore to user stack
- leal 0x8(%edi,%eax,1),%edi # Arg segment registers
- testb $0x4,-0x6(%edi) # Return flags?
- jz intrtn.1 # No
- movl 0x30(%ebp),%eax # Get V86 flags
- movw %ax,0x18(%esi) # Set user flags
-intrtn.1: leal 0x10(%esi),%ebx # Saved exception frame
- xchgl %edx,%esi # Segment registers
- movb $0x4,%cl # Update seg regs
- rep # in INT_V86
- movsl # args
-intrtn.2: movl %edx,%esi # Segment registers
- leal 0x28(%ebp),%edi # Set up seg
- movb $0x4,%cl # regs for
- rep # later
- movsl # pop
- movl %ebx,%esi # Restore exception
- movb $0x5,%cl # frame to
- rep # supervisor
- movsl # stack
- movl %esi,MEM_TSS+TSS_ESP1 # Link stack pointer
- popa # Restore
- leal 0x8(%esp,1),%esp # Discard err, int no
- popl %es # Restore
- popl %ds # user
- popl %fs # segment
- popl %gs # registers
- iret # To user mode
-#
-# V86 monitor.
-#
-v86mon: cld # String ops inc
- pushl $SEL_SDATA # Set up for
- popl %ds # flat addressing
- pusha # Save registers
- movl %esp,%ebp # Address stack frame
- movzwl 0x2c(%ebp),%edi # Load V86 CS
- shll $0x4,%edi # To linear
- movl 0x28(%ebp),%esi # Load V86 IP
- addl %edi,%esi # Code pointer
- xorl %ecx,%ecx # Zero
- movb $0x2,%cl # 16-bit operands
- xorl %eax,%eax # Zero
-v86mon.1: lodsb # Get opcode
- cmpb $0x66,%al # Operand size prefix?
- jne v86mon.2 # No
- movb $0x4,%cl # 32-bit operands
- jmp v86mon.1 # Continue
-v86mon.2: cmpb $0xf4,%al # HLT?
- jne v86mon.3 # No
- cmpl $inthlt+0x1,%esi # Is inthlt?
- jne v86mon.7 # No (ignore)
- jmp intrtn # Return to user mode
-v86mon.3: cmpb $0xf,%al # Is
- jne v86mon.4 # this
- cmpb $0x20,(%esi) # a
- jne v86mon.4 # MOV EAX,CR0
- cmpb $0xc0,0x1(%esi) # instruction?
- je v86mov # Yes
-v86mon.4: cmpb $0xfa,%al # CLI?
- je v86cli # Yes
- cmpb $0xfb,%al # STI?
- je v86sti # Yes
- movzwl 0x38(%ebp),%ebx # Load V86 SS
- shll $0x4,%ebx # To offset
- pushl %ebx # Save
- addl 0x34(%ebp),%ebx # Add V86 SP
- movl 0x30(%ebp),%edx # Load V86 flags
- cmpb $0x9c,%al # PUSHF/PUSHFD?
- je v86pushf # Yes
- cmpb $0x9d,%al # POPF/POPFD?
- je v86popf # Yes
- cmpb $0xcd,%al # INT imm8?
- je v86intn # Yes
- cmpb $0xcf,%al # IRET/IRETD?
- je v86iret # Yes
- popl %ebx # Restore
- popa # Restore
- jmp except # Handle exception
-v86mon.5: movl %edx,0x30(%ebp) # Save V86 flags
-v86mon.6: popl %edx # V86 SS adjustment
- subl %edx,%ebx # Save V86
- movl %ebx,0x34(%ebp) # SP
-v86mon.7: subl %edi,%esi # From linear
- movl %esi,0x28(%ebp) # Save V86 IP
- popa # Restore
- leal 0x8(%esp,1),%esp # Discard int no, error
- iret # To V86 mode
-#
-# Emulate MOV EAX,CR0.
-#
-v86mov: movl %cr0,%eax # CR0 to
- movl %eax,0x1c(%ebp) # saved EAX
- incl %esi # Adjust
- incl %esi # IP
- jmp v86mon.7 # Finish up
-#
-# Emulate CLI.
-#
-v86cli: andb $~0x2,0x31(%ebp) # Clear IF
- jmp v86mon.7 # Finish up
-#
-# Emulate STI.
-#
-v86sti: orb $0x2,0x31(%ebp) # Set IF
- jmp v86mon.7 # Finish up
-#
-# Emulate PUSHF/PUSHFD.
-#
-v86pushf: subl %ecx,%ebx # Adjust SP
- cmpb $0x4,%cl # 32-bit
- je v86pushf.1 # Yes
- o16 # 16-bit
-v86pushf.1: movl %edx,(%ebx) # Save flags
- jmp v86mon.6 # Finish up
-#
-# Emulate IRET/IRETD.
-#
-v86iret: movzwl (%ebx),%esi # Load V86 IP
- movzwl 0x2(%ebx),%edi # Load V86 CS
- leal 0x4(%ebx),%ebx # Adjust SP
- movl %edi,0x2c(%ebp) # Save V86 CS
- xorl %edi,%edi # No ESI adjustment
-#
-# Emulate POPF/POPFD (and remainder of IRET/IRETD).
-#
-v86popf: cmpb $0x4,%cl # 32-bit?
- je v86popf.1 # Yes
- movl %edx,%eax # Initialize
- o16 # 16-bit
-v86popf.1: movl (%ebx),%eax # Load flags
- addl %ecx,%ebx # Adjust SP
- andl $V86_FLG,%eax # Merge
- andl $~V86_FLG,%edx # the
- orl %eax,%edx # flags
- jmp v86mon.5 # Finish up
-#
-# trap int 15, function 87
-# reads %es:%si from saved registers on stack to find a GDT containing
-# source and destination locations
-# reads count of words from saved %cx
-# returns success by setting %ah to 0
-#
-int15_87: pushl %eax # Save
- pushl %ebx # some information
- pushl %esi # onto the stack.
- pushl %edi
- xorl %eax,%eax # clean EAX
- xorl %ebx,%ebx # clean EBX
- movl 0x4(%ebp),%esi # Get user's ESI
- movl 0x3C(%ebp),%ebx # store ES
- movw %si,%ax # store SI
- shll $0x4,%ebx # Make it a seg.
- addl %eax,%ebx # ebx=(es<<4)+si
- movb 0x14(%ebx),%al # Grab the
- movb 0x17(%ebx),%ah # necessary
- shll $0x10,%eax # information
- movw 0x12(%ebx),%ax # from
- movl %eax,%esi # the
- movb 0x1c(%ebx),%al # GDT in order to
- movb 0x1f(%ebx),%ah # have %esi offset
- shll $0x10,%eax # of source and %edi
- movw 0x1a(%ebx),%ax # of destination.
- movl %eax,%edi
- pushl %ds # Make:
- popl %es # es = ds
- pushl %ecx # stash ECX
- xorl %ecx,%ecx # highw of ECX is clear
- movw 0x18(%ebp),%cx # Get user's ECX
- rep # repeat...
- movsb # perform copy.
- popl %ecx # Restore
- popl %edi
- popl %esi # previous
- popl %ebx # register
- popl %eax # values.
- movb $0x0,0x1d(%ebp) # set ah = 0 to indicate
- # success
- andb $0xfe,%dl # clear CF
- jmp v86mon.5 # Finish up
-
-#
-# Emulate INT imm8... also make sure to check if it's int 15/87
-#
-v86intn: lodsb # Get int no
- cmpb $0x15,%al # is it int 15?
- jne v86intn.2 # no, skip parse
- pushl %eax # stash EAX
- movl 0x1c(%ebp),%eax # user's saved EAX
- cmpb $0x87,%ah # is it our sub function?
- jne v86intn.1 # no, don't handle it
- popl %eax # get the stack straight
- jmp int15_87 # it's our cue
-v86intn.1: popl %eax # restore EAX
-v86intn.2: subl %edi,%esi # From
- shrl $0x4,%edi # linear
- movw %dx,-0x2(%ebx) # Save flags
- movw %di,-0x4(%ebx) # Save CS
- leal -0x6(%ebx),%ebx # Adjust SP
- movw %si,(%ebx) # Save IP
- shll $0x2,%eax # Scale
- movzwl (%eax),%esi # Load IP
- movzwl 0x2(%eax),%edi # Load CS
- movl %edi,0x2c(%ebp) # Save CS
- xorl %edi,%edi # No ESI adjustment
- andb $~0x3,%dh # Clear IF and TF
- jmp v86mon.5 # Finish up
-#
-# Hardware interrupt jump table.
-#
-intx20: pushb $0x8 # Int 0x20: IRQ0
- jmp int_hw # V86 int 0x8
- pushb $0x9 # Int 0x21: IRQ1
- jmp int_hw # V86 int 0x9
- pushb $0xa # Int 0x22: IRQ2
- jmp int_hw # V86 int 0xa
- pushb $0xb # Int 0x23: IRQ3
- jmp int_hw # V86 int 0xb
- pushb $0xc # Int 0x24: IRQ4
- jmp int_hw # V86 int 0xc
- pushb $0xd # Int 0x25: IRQ5
- jmp int_hw # V86 int 0xd
- pushb $0xe # Int 0x26: IRQ6
- jmp int_hw # V86 int 0xe
- pushb $0xf # Int 0x27: IRQ7
- jmp int_hw # V86 int 0xf
-.`ifdef' PC98
- pushb $0x10 # Int 0x28: IRQ8
- jmp int_hw # V86 int 0x10
- pushb $0x11 # Int 0x29: IRQ9
- jmp int_hw # V86 int 0x11
- pushb $0x12 # Int 0x2a: IRQ10
- jmp int_hw # V86 int 0x12
- pushb $0x13 # Int 0x2b: IRQ11
- jmp int_hw # V86 int 0x13
- pushb $0x14 # Int 0x2c: IRQ12
- jmp int_hw # V86 int 0x14
- pushb $0x15 # Int 0x2d: IRQ13
- jmp int_hw # V86 int 0x15
- pushb $0x16 # Int 0x2e: IRQ14
- jmp int_hw # V86 int 0x16
- pushb $0x17 # Int 0x2f: IRQ15
- jmp int_hw # V86 int 0x17
-.else
- pushb $0x70 # Int 0x28: IRQ8
- jmp int_hw # V86 int 0x70
- pushb $0x71 # Int 0x29: IRQ9
- jmp int_hw # V86 int 0x71
- pushb $0x72 # Int 0x2a: IRQ10
- jmp int_hw # V86 int 0x72
- pushb $0x73 # Int 0x2b: IRQ11
- jmp int_hw # V86 int 0x73
- pushb $0x74 # Int 0x2c: IRQ12
- jmp int_hw # V86 int 0x74
- pushb $0x75 # Int 0x2d: IRQ13
- jmp int_hw # V86 int 0x75
- pushb $0x76 # Int 0x2e: IRQ14
- jmp int_hw # V86 int 0x76
- pushb $0x77 # Int 0x2f: IRQ15
- jmp int_hw # V86 int 0x77
-.endif
-#
-# Reflect hardware interrupts.
-#
-int_hw: testb $0x2,0xe(%esp,1) # V86 mode?
- jz intusr # No
- pushl $SEL_SDATA # Address
- popl %ds # data
- xchgl %eax,(%esp,1) # Swap EAX, int no
- pushl %ebp # Address
- movl %esp,%ebp # stack frame
- pushl %ebx # Save
- shll $0x2,%eax # Get int
- movl (%eax),%eax # vector
- subl $0x6,0x14(%ebp) # Adjust V86 ESP
- movzwl 0x18(%ebp),%ebx # V86 SS
- shll $0x4,%ebx # * 0x10
- addl 0x14(%ebp),%ebx # + V86 ESP
- xchgw %ax,0x8(%ebp) # Swap V86 IP
- rorl $0x10,%eax # Swap words
- xchgw %ax,0xc(%ebp) # Swap V86 CS
- roll $0x10,%eax # Swap words
- movl %eax,(%ebx) # CS:IP for IRET
- movl 0x10(%ebp),%eax # V86 flags
- movw %ax,0x4(%ebx) # Flags for IRET
- andb $~0x3,0x11(%ebp) # Clear IF, TF
- popl %ebx # Restore
- popl %ebp # saved
- popl %eax # registers
- iret # To V86 mode
-#
-# Invoke V86 interrupt from user mode, with arguments.
-#
-intx31: stc # Have btx_v86
- pushl %eax # Missing int no
-#
-# Invoke V86 interrupt from user mode.
-#
-intusr: std # String ops dec
- pushl %eax # Expand
- pushl %eax # stack
- pushl %eax # frame
- pusha # Save
- pushl %gs # Save
- movl %esp,%eax # seg regs
- pushl %fs # and
- pushl %ds # point
- pushl %es # to them
- pushb $SEL_SDATA # Set up
- popl %ds # to
- pushl %ds # address
- popl %es # data
- movl $MEM_USR,%ebx # User base
- movl %ebx,%edx # address
- jc intusr.1 # If btx_v86
- xorl %edx,%edx # Control flags
- xorl %ebp,%ebp # btx_v86 pointer
-intusr.1: leal 0x50(%esp,1),%esi # Base of frame
- pushl %esi # Save
- addl -0x4(%esi),%ebx # User ESP
- movl MEM_TSS+TSS_ESP1,%edi # Link stack pointer
- leal -0x4(%edi),%edi # Adjust for push
- xorl %ecx,%ecx # Zero
- movb $0x5,%cl # Push exception
- rep # frame on
- movsl # link stack
- xchgl %eax,%esi # Saved seg regs
- movl 0x40(%esp,1),%eax # Get int no
- testl %edx,%edx # Have btx_v86?
- jz intusr.2 # No
- movl (%ebx),%ebp # btx_v86 pointer
- movb $0x4,%cl # Count
- addl %ecx,%ebx # Adjust for pop
- rep # Push saved seg regs
- movsl # on link stack
- addl %ebp,%edx # Flatten btx_v86 ptr
- leal 0x14(%edx),%esi # Seg regs pointer
- movl 0x4(%edx),%eax # Get int no/address
- movzwl 0x2(%edx),%edx # Get control flags
-intusr.2: movl %ebp,(%edi) # Push btx_v86 and
- movl %edi,MEM_TSS+TSS_ESP1 # save link stack ptr
- popl %edi # Base of frame
- xchgl %eax,%ebp # Save intno/address
- movl 0x48(%esp,1),%eax # Get flags
- testb $0x2,%dl # Simulate CALLF?
- jnz intusr.3 # Yes
- decl %ebx # Push flags
- decl %ebx # on V86
- movw %ax,(%ebx) # stack
-intusr.3: movb $0x4,%cl # Count
- subl %ecx,%ebx # Push return address
- movl $inthlt,(%ebx) # on V86 stack
- rep # Copy seg regs to
- movsl # exception frame
- xchgl %eax,%ecx # Save flags
- movl %ebx,%eax # User ESP
- subl $V86_STK,%eax # Less bytes
- ja intusr.4 # to
- xorl %eax,%eax # keep
-intusr.4: shrl $0x4,%eax # Gives segment
- stosl # Set SS
- shll $0x4,%eax # To bytes
- xchgl %eax,%ebx # Swap
- subl %ebx,%eax # Gives offset
- stosl # Set ESP
- xchgl %eax,%ecx # Get flags
- btsl $0x11,%eax # Set VM
- andb $~0x3,%ah # Clear IF and TF
- stosl # Set EFL
- xchgl %eax,%ebp # Get int no/address
- testb $0x1,%dl # Address?
- jnz intusr.5 # Yes
- shll $0x2,%eax # Scale
- movl (%eax),%eax # Load int vector
-intusr.5: movl %eax,%ecx # Save
- shrl $0x10,%eax # Gives segment
- stosl # Set CS
- movw %cx,%ax # Restore
- stosl # Set EIP
- leal 0x10(%esp,1),%esp # Discard seg regs
- popa # Restore
- iret # To V86 mode
-#
-# System Call.
-#
-intx30: cmpl $SYS_EXEC,%eax # Exec system call?
- jne intx30.1 # No
- pushl %ss # Set up
- popl %es # all
- pushl %es # segment
- popl %ds # registers
- pushl %ds # for the
- popl %fs # program
- pushl %fs # we're
- popl %gs # invoking
- movl $MEM_USR,%eax # User base address
- addl 0xc(%esp,1),%eax # Change to user
- leal 0x4(%eax),%esp # stack
-ifdef(`PAGING',`
- movl %cr0,%eax # Turn
- andl $~0x80000000,%eax # off
- movl %eax,%cr0 # paging
- xorl %eax,%eax # Flush
- movl %eax,%cr3 # TLB
-')
- popl %eax # Call
- call *%eax # program
-intx30.1: incb %ss:btx_hdr+0x7 # Flag reboot
- jmp exit # Exit
-#
-# Dump structure [EBX] to [EDI], using format string [ESI].
-#
-dump.0: stosb # Save char
-dump: lodsb # Load char
- testb %al,%al # End of string?
- jz dump.10 # Yes
- testb $0x80,%al # Control?
- jz dump.0 # No
- movb %al,%ch # Save control
- movb $'=',%al # Append
- stosb # '='
- lodsb # Get offset
- pushl %esi # Save
- movsbl %al,%esi # To
- addl %ebx,%esi # pointer
- testb $DMP_X16,%ch # Dump word?
- jz dump.1 # No
- lodsw # Get and
- call hex16 # dump it
-dump.1: testb $DMP_X32,%ch # Dump long?
- jz dump.2 # No
- lodsl # Get and
- call hex32 # dump it
-dump.2: testb $DMP_MEM,%ch # Dump memory?
- jz dump.8 # No
- pushl %ds # Save
- testb $0x2,0x52(%ebx) # V86 mode?
- jnz dump.3 # Yes
- verrl 0x4(%esi) # Readable selector?
- jnz dump.3 # No
- ldsl (%esi),%esi # Load pointer
- jmp dump.4 # Join common code
-dump.3: lodsl # Set offset
- xchgl %eax,%edx # Save
- lodsl # Get segment
- shll $0x4,%eax # * 0x10
- addl %edx,%eax # + offset
- xchgl %eax,%esi # Set pointer
-dump.4: movb $0x10,%cl # Bytes to dump
-dump.5: lodsb # Get byte and
- call hex8 # dump it
- decb %cl # Keep count
- jz dump.7 # If done
- movb $'-',%al # Separator
- cmpb $0x8,%cl # Half way?
- je dump.6 # Yes
- movb $' ',%al # Use space
-dump.6: stosb # Save separator
- jmp dump.5 # Continue
-dump.7: popl %ds # Restore
-dump.8: popl %esi # Restore
- movb $0xa,%al # Line feed
- testb $DMP_EOL,%ch # End of line?
- jnz dump.9 # Yes
- movb $' ',%al # Use spaces
- stosb # Save one
-dump.9: jmp dump.0 # Continue
-dump.10: stosb # Terminate string
- ret # To caller
-#
-# Convert EAX, AX, or AL to hex, saving the result to [EDI].
-#
-hex32: pushl %eax # Save
- shrl $0x10,%eax # Do upper
- call hex16 # 16
- popl %eax # Restore
-hex16: call hex16.1 # Do upper 8
-hex16.1: xchgb %ah,%al # Save/restore
-hex8: pushl %eax # Save
- shrb $0x4,%al # Do upper
- call hex8.1 # 4
- popl %eax # Restore
-hex8.1: andb $0xf,%al # Get lower 4
- cmpb $0xa,%al # Convert
- sbbb $0x69,%al # to hex
- das # digit
- orb $0x20,%al # To lower case
- stosb # Save char
- ret # (Recursive)
-#
-# Output zero-terminated string [ESI] to the console.
-#
-putstr.0: call putchr # Output char
-putstr: lodsb # Load char
- testb %al,%al # End of string?
- jnz putstr.0 # No
- ret # To caller
-#
-# Output character AL to the console.
-#
-putchr: pusha # Save
- xorl %ecx,%ecx # Zero for loops
- movb $SCR_MAT,%ah # Mode/attribute
- movl $BDA_POS,%ebx # BDA pointer
- movw (%ebx),%dx # Cursor position
-.`ifdef' PC98
- movl $0xa0000,%edi
-.else
- movl $0xb8000,%edi # Regen buffer (color)
- cmpb %ah,BDA_SCR-BDA_POS(%ebx) # Mono mode?
- jne putchr.1 # No
- xorw %di,%di # Regen buffer (mono)
-.endif
-putchr.1: cmpb $0xa,%al # New line?
- je putchr.2 # Yes
-.`ifdef' PC98
- movw %dx,%cx
- movb %al,(%edi,%ecx,1) # Write char
- addl $0x2000,%ecx
- movb %ah,(%edi,%ecx,1) # Write attr
- addw $0x02,%dx
- jmp putchr.3
-putchr.2: movw %dx,%ax
- movb $SCR_COL*2,%dl
- div %dl
- incb %al
- mul %dl
- movw %ax,%dx
-putchr.3: cmpw $SCR_ROW*SCR_COL*2,%dx
-.else
- xchgl %eax,%ecx # Save char
- movb $SCR_COL,%al # Columns per row
- mulb %dh # * row position
- addb %dl,%al # + column
- adcb $0x0,%ah # position
- shll %eax # * 2
- xchgl %eax,%ecx # Swap char, offset
- movw %ax,(%edi,%ecx,1) # Write attr:char
- incl %edx # Bump cursor
- cmpb $SCR_COL,%dl # Beyond row?
- jb putchr.3 # No
-putchr.2: xorb %dl,%dl # Zero column
- incb %dh # Bump row
-putchr.3: cmpb $SCR_ROW,%dh # Beyond screen?
-.endif
- jb putchr.4 # No
- leal 2*SCR_COL(%edi),%esi # New top line
- movw $(SCR_ROW-1)*SCR_COL/2,%cx # Words to move
- rep # Scroll
- movsl # screen
- movb $' ',%al # Space
-.`ifdef' PC98
- xorb %ah,%ah
-.endif
- movb $SCR_COL,%cl # Columns to clear
- rep # Clear
- stosw # line
-.`ifdef' PC98
- movw $(SCR_ROW-1)*SCR_COL*2,%dx
-.else
- movb $SCR_ROW-1,%dh # Bottom line
-.endif
-putchr.4: movw %dx,(%ebx) # Update position
- popa # Restore
- ret # To caller
-
- .p2align 4
-#
-# Global descriptor table.
-#
-gdt: .word 0x0,0x0,0x0,0x0 # Null entry
- .word 0xffff,0x0,0x9a00,0xcf # SEL_SCODE
- .word 0xffff,0x0,0x9200,0xcf # SEL_SDATA
- .word 0xffff,0x0,0x9a00,0x0 # SEL_RCODE
- .word 0xffff,0x0,0x9200,0x0 # SEL_RDATA
- .word 0xffff,MEM_USR,0xfa00,0xcf# SEL_UCODE
- .word 0xffff,MEM_USR,0xf200,0xcf# SEL_UDATA
- .word _TSSLM,MEM_TSS,0x8900,0x0 # SEL_TSS
-gdt.1:
-#
-# Pseudo-descriptors.
-#
-gdtdesc: .word gdt.1-gdt-1,gdt,0x0 # GDT
-idtdesc: .word _IDTLM,MEM_IDT,0x0 # IDT
-ivtdesc: .word 0x400-0x0-1,0x0,0x0 # IVT
-#
-# IDT construction control string.
-#
-idtctl: .byte 0x10, 0x8e # Int 0x0-0xf
- .word 0x7dfb,intx00 # (exceptions)
- .byte 0x10, 0x8e # Int 0x10
- .word 0x1, intx10 # (exception)
- .byte 0x10, 0x8e # Int 0x20-0x2f
- .word 0xffff,intx20 # (hardware)
- .byte 0x1, 0xee # int 0x30
- .word 0x1, intx30 # (system call)
- .byte 0x2, 0xee # Int 0x31-0x32
- .word 0x1, intx31 # (V86, null)
- .byte 0x0 # End of string
-#
-# Dump format string.
-#
-dmpfmt: .byte '\n' # "\n"
- .ascii "int" # "int="
- .byte 0x80|DMP_X32, 0x40 # "00000000 "
- .ascii "err" # "err="
- .byte 0x80|DMP_X32, 0x44 # "00000000 "
- .ascii "efl" # "efl="
- .byte 0x80|DMP_X32, 0x50 # "00000000 "
- .ascii "eip" # "eip="
- .byte 0x80|DMP_X32|DMP_EOL,0x48 # "00000000\n"
- .ascii "eax" # "eax="
- .byte 0x80|DMP_X32, 0x34 # "00000000 "
- .ascii "ebx" # "ebx="
- .byte 0x80|DMP_X32, 0x28 # "00000000 "
- .ascii "ecx" # "ecx="
- .byte 0x80|DMP_X32, 0x30 # "00000000 "
- .ascii "edx" # "edx="
- .byte 0x80|DMP_X32|DMP_EOL,0x2c # "00000000\n"
- .ascii "esi" # "esi="
- .byte 0x80|DMP_X32, 0x1c # "00000000 "
- .ascii "edi" # "edi="
- .byte 0x80|DMP_X32, 0x18 # "00000000 "
- .ascii "ebp" # "ebp="
- .byte 0x80|DMP_X32, 0x20 # "00000000 "
- .ascii "esp" # "esp="
- .byte 0x80|DMP_X32|DMP_EOL,0x0 # "00000000\n"
- .ascii "cs" # "cs="
- .byte 0x80|DMP_X16, 0x4c # "0000 "
- .ascii "ds" # "ds="
- .byte 0x80|DMP_X16, 0xc # "0000 "
- .ascii "es" # "es="
- .byte 0x80|DMP_X16, 0x8 # "0000 "
- .ascii " " # " "
- .ascii "fs" # "fs="
- .byte 0x80|DMP_X16, 0x10 # "0000 "
- .ascii "gs" # "gs="
- .byte 0x80|DMP_X16, 0x14 # "0000 "
- .ascii "ss" # "ss="
- .byte 0x80|DMP_X16|DMP_EOL,0x4 # "0000\n"
- .ascii "cs:eip" # "cs:eip="
- .byte 0x80|DMP_MEM|DMP_EOL,0x48 # "00 00 ... 00 00\n"
- .ascii "ss:esp" # "ss:esp="
- .byte 0x80|DMP_MEM|DMP_EOL,0x0 # "00 00 ... 00 00\n"
- .asciz "System halted" # End
-#
-# End of BTX memory.
-#
- .p2align 4
-break:
diff --git a/sys/boot/pc98/btx/btxldr/btxldr.S b/sys/boot/pc98/btx/btxldr/btxldr.S
deleted file mode 100644
index acb4a14b11e6..000000000000
--- a/sys/boot/pc98/btx/btxldr/btxldr.S
+++ /dev/null
@@ -1,459 +0,0 @@
-#
-# Copyright (c) 1998 Robert Nordier
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms are freely
-# permitted provided that the above copyright notice and this
-# paragraph and the following disclaimer are duplicated in all
-# such forms.
-#
-# This software is provided "AS IS" and without any express or
-# implied warranties, including, without limitation, the implied
-# warranties of merchantability and fitness for a particular
-# purpose.
-#
-
-# $FreeBSD$
-
-#
-# Prototype BTX loader program, written in a couple of hours. The
-# real thing should probably be more flexible, and in C.
-#
-
-#
-# Memory locations.
-#
- .set MEM_STUB,0x600 # Real mode stub
- .set MEM_ESP,0x1000 # New stack pointer
- .set MEM_TBL,0x5000 # BTX page tables
- .set MEM_ENTRY,0x9010 # BTX entry point
- .set MEM_DATA,0x101000 # Data segment
-#
-# Segment selectors.
-#
- .set SEL_SCODE,0x8 # 4GB code
- .set SEL_SDATA,0x10 # 4GB data
- .set SEL_RCODE,0x18 # 64K code
- .set SEL_RDATA,0x20 # 64K data
-#
-# Paging constants.
-#
- .set PAG_SIZ,0x1000 # Page size
- .set PAG_ENT,0x4 # Page entry size
-#
-# Screen constants.
-#
-.ifdef PC98
- .set SCR_MAT,0xe1 # Mode/attribute
-.else
- .set SCR_MAT,0x7 # Mode/attribute
-.endif
- .set SCR_COL,0x50 # Columns per row
- .set SCR_ROW,0x19 # Rows per screen
-#
-# BIOS Data Area locations.
-#
-.ifdef PC98
- .set BDA_MEM,0xa1501 # Free memory
- .set BDA_POS,0xa153e # Cursor position
-.else
- .set BDA_MEM,0x413 # Free memory
- .set BDA_SCR,0x449 # Video mode
- .set BDA_POS,0x450 # Cursor position
-.endif
-#
-# Required by aout gas inadequacy.
-#
- .set SIZ_STUB,0x1a # Size of stub
-#
-# We expect to be loaded by boot2 at 0x100000.
-#
- .globl start
-#
-# BTX program loader for ELF clients.
-#
-start: cld # String ops inc
-.ifdef PC98
- cli
-gdcwait.1: inb $0x60,%al
- testb $0x04,%al
- jz gdcwait.1
- movb $0xe0,%al
- outb %al,$0x62
- nop
-gdcwait.2: inb $0x60,%al
- testb $0x01,%al
- jz gdcwait.2
- inb $0x62,%al
- movb %al,%dl
- inb $0x62,%al
- movb %al,%dh
- inb $0x62,%al
- inb $0x62,%al
- inb $0x62,%al
- shlw $1,%dx
- movl $BDA_POS,%ebx
- movw %dx,(%ebx)
-.endif
- movl $m_logo,%esi # Identify
- call putstr # ourselves
- movzwl BDA_MEM,%eax # Get base memory
-.ifdef PC98
- andl $0x7,%eax
- incl %eax
- shll $0x11,%eax # in bytes
-.else
- shll $0xa,%eax # in bytes
-.endif
- movl %eax,%ebp # Base of user stack
- movl $m_mem,%esi # Display
- call dhexout # amount of
- call dputstr # base memory
- lgdt gdtdesc # Load new GDT
-#
-# Relocate caller's arguments.
-#
- movl $m_esp,%esi # Display
- movl %esp,%eax # caller's
- call dhexout # stack
- call dputstr # pointer
- movl $m_args,%esi # Format string
- leal 0x4(%esp,1),%ebx # First argument
- movl $0x6,%ecx # Count
-start.1: movl (%ebx),%eax # Get argument and
- addl $0x4,%ebx # bump pointer
- call dhexout # Display it
- loop start.1 # Till done
- call dputstr # End message
- movl $0x48,%ecx # Allocate space
- subl %ecx,%ebp # for bootinfo
- movl 0x18(%esp,1),%esi # Source
- movl %ebp,%edi # Destination
- rep # Copy
- movsb # it
- movl %ebp,0x18(%esp,1) # Update pointer
- movl $m_rel_bi,%esi # Display
- movl %ebp,%eax # bootinfo
- call dhexout # relocation
- call dputstr # message
- movl $0x18,%ecx # Allocate space
- subl %ecx,%ebp # for arguments
- leal 0x4(%esp,1),%esi # Source
- movl %ebp,%edi # Destination
- rep # Copy
- movsb # them
- movl $m_rel_args,%esi # Display
- movl %ebp,%eax # argument
- call dhexout # relocation
- call dputstr # message
-#
-# Set up BTX kernel.
-#
- movl $MEM_ESP,%esp # Set up new stack
- movl $MEM_DATA,%ebx # Data segment
- movl $m_vers,%esi # Display BTX
- call putstr # version message
- movb 0x5(%ebx),%al # Get major version
- addb $'0',%al # Display
- call putchr # it
- movb $'.',%al # And a
- call putchr # dot
- movb 0x6(%ebx),%al # Get minor
- xorb %ah,%ah # version
- movb $0xa,%dl # Divide
- divb %dl,%al # by 10
- addb $'0',%al # Display
- call putchr # tens
- movb %ah,%al # Get units
- addb $'0',%al # Display
- call putchr # units
- call putstr # End message
- movl %ebx,%esi # BTX image
- movzwl 0x8(%ebx),%edi # Compute
- orl $PAG_SIZ/PAG_ENT-1,%edi # the
- incl %edi # BTX
- shll $0x2,%edi # load
- addl $MEM_TBL,%edi # address
- pushl %edi # Save
- movzwl 0xa(%ebx),%ecx # Image size
- pushl %ecx # Save
- rep # Relocate
- movsb # BTX
- movl %esi,%ebx # Keep place
- movl $m_rel_btx,%esi # Restore
- popl %eax # parameters
- call dhexout # and
- popl %ebp # display
- movl %ebp,%eax # the
- call dhexout # relocation
- call dputstr # message
- addl $PAG_SIZ,%ebp # Display
- movl $m_base,%esi # the
- movl %ebp,%eax # user
- call dhexout # base
- call dputstr # address
-#
-# Set up ELF-format client program.
-#
- cmpl $0x464c457f,(%ebx) # ELF magic number?
- je start.3 # Yes
- movl $e_fmt,%esi # Display error
- call putstr # message
-start.2: jmp start.2 # Hang
-start.3: movl $m_elf,%esi # Display ELF
- call dputstr # message
- movl $m_segs,%esi # Format string
- movl $0x2,%edi # Segment count
- movl 0x1c(%ebx),%edx # Get e_phoff
- addl %ebx,%edx # To pointer
- movzwl 0x2c(%ebx),%ecx # Get e_phnum
-start.4: cmpl $0x1,(%edx) # Is p_type PT_LOAD?
- jne start.6 # No
- movl 0x4(%edx),%eax # Display
- call dhexout # p_offset
- movl 0x8(%edx),%eax # Display
- call dhexout # p_vaddr
- movl 0x10(%edx),%eax # Display
- call dhexout # p_filesz
- movl 0x14(%edx),%eax # Display
- call dhexout # p_memsz
- call dputstr # End message
- pushl %esi # Save
- pushl %edi # working
- pushl %ecx # registers
- movl 0x4(%edx),%esi # Get p_offset
- addl %ebx,%esi # as pointer
- movl 0x8(%edx),%edi # Get p_vaddr
- addl %ebp,%edi # as pointer
- movl 0x10(%edx),%ecx # Get p_filesz
- rep # Set up
- movsb # segment
- movl 0x14(%edx),%ecx # Any bytes
- subl 0x10(%edx),%ecx # to zero?
- jz start.5 # No
- xorb %al,%al # Then
- rep # zero
- stosb # them
-start.5: popl %ecx # Restore
- popl %edi # working
- popl %esi # registers
- decl %edi # Segments to do
- je start.7 # If none
-start.6: addl $0x20,%edx # To next entry
- loop start.4 # Till done
-start.7: movl $m_done,%esi # Display done
- call dputstr # message
- movl $start.8,%esi # Real mode stub
- movl $MEM_STUB,%edi # Destination
- movl $SIZ_STUB,%ecx # Size
- rep # Relocate
- movsb # it
- ljmp $SEL_RCODE,$MEM_STUB # To 16-bit code
-start.8: xorl %eax,%eax # Data
- movb $SEL_RDATA,%al # selector
- movl %eax,%ss # Reload SS
- movl %eax,%ds # Reset
- movl %eax,%es # other
- movl %eax,%fs # segment
- movl %eax,%gs # limits
- movl %cr0,%eax # Switch to
- decl %eax # real
- movl %eax,%cr0 # mode
- .byte 0xea # Jump to
- .word MEM_ENTRY # BTX entry
- .word 0x0 # point
-start.9:
-#
-# Output message [ESI] followed by EAX in hex.
-#
-dhexout:
-.ifndef BTXLDR_VERBOSE
- ret
-.endif
-hexout: pushl %eax # Save
- call putstr # Display message
- popl %eax # Restore
- pushl %esi # Save
- pushl %edi # caller's
- movl $buf,%edi # Buffer
- pushl %edi # Save
- call hex32 # To hex
- xorb %al,%al # Terminate
- stosb # string
- popl %esi # Restore
-hexout.1: lodsb # Get a char
- cmpb $'0',%al # Leading zero?
- je hexout.1 # Yes
- testb %al,%al # End of string?
- jne hexout.2 # No
- decl %esi # Undo
-hexout.2: decl %esi # Adjust for inc
- call putstr # Display hex
- popl %edi # Restore
- popl %esi # caller's
- ret # To caller
-#
-# Output zero-terminated string [ESI] to the console.
-#
-dputstr:
-.ifndef BTXLDR_VERBOSE
- ret
-.else
- jmp putstr
-.endif
-putstr.0: call putchr # Output char
-putstr: lodsb # Load char
- testb %al,%al # End of string?
- jne putstr.0 # No
- ret # To caller
-#
-# Output character AL to the console.
-#
-dputchr:
-.ifndef BTXLDR_VERBOSE
- ret
-.endif
-putchr: pusha # Save
- xorl %ecx,%ecx # Zero for loops
- movb $SCR_MAT,%ah # Mode/attribute
- movl $BDA_POS,%ebx # BDA pointer
- movw (%ebx),%dx # Cursor position
-.ifdef PC98
- movl $0xa0000,%edi # Regen buffer (color)
-.else
- movl $0xb8000,%edi # Regen buffer (color)
- cmpb %ah,BDA_SCR-BDA_POS(%ebx) # Mono mode?
- jne putchr.1 # No
- xorw %di,%di # Regen buffer (mono)
-.endif
-putchr.1: cmpb $0xa,%al # New line?
- je putchr.2 # Yes
-.ifdef PC98
- movw %dx,%cx
- movb %al,(%edi,%ecx,1) # Write char
- addl $0x2000,%ecx
- movb %ah,(%edi,%ecx,1) # Write attr
- addw $0x2,%dx
- jmp putchr.3
-putchr.2: movw %dx,%ax
- movb $SCR_COL*2,%dl
- div %dl
- incb %al
- mul %dl
- movw %ax,%dx
-putchr.3: cmpw $SCR_COL*SCR_ROW*2,%dx
-.else
- xchgl %eax,%ecx # Save char
- movb $SCR_COL,%al # Columns per row
- mulb %dh # * row position
- addb %dl,%al # + column
- adcb $0x0,%ah # position
- shll %eax # * 2
- xchgl %eax,%ecx # Swap char, offset
- movw %ax,(%edi,%ecx,1) # Write attr:char
- incl %edx # Bump cursor
- cmpb $SCR_COL,%dl # Beyond row?
- jb putchr.3 # No
-putchr.2: xorb %dl,%dl # Zero column
- incb %dh # Bump row
-putchr.3: cmpb $SCR_ROW,%dh # Beyond screen?
-.endif
- jb putchr.4 # No
- leal 2*SCR_COL(%edi),%esi # New top line
- movw $(SCR_ROW-1)*SCR_COL/2,%cx # Words to move
- rep # Scroll
- movsl # screen
- movb $' ',%al # Space
-.ifdef PC98
- xorb %ah,%ah
-.endif
- movb $SCR_COL,%cl # Columns to clear
- rep # Clear
- stosw # line
-.ifdef PC98
- movw $(SCR_ROW-1)*SCR_COL*2,%dx
-putchr.4: movw %dx,(%ebx) # Update position
- shrw $1,%dx
-gdcwait.3: inb $0x60,%al
- testb $0x04,%al
- jz gdcwait.3
- movb $0x49,%al
- outb %al,$0x62
- movb %dl,%al
- outb %al,$0x60
- movb %dh,%al
- outb %al,$0x60
-.else
- movb $SCR_ROW-1,%dh # Bottom line
-putchr.4: movw %dx,(%ebx) # Update position
-.endif
- popa # Restore
- ret # To caller
-#
-# Convert EAX, AX, or AL to hex, saving the result to [EDI].
-#
-hex32: pushl %eax # Save
- shrl $0x10,%eax # Do upper
- call hex16 # 16
- popl %eax # Restore
-hex16: call hex16.1 # Do upper 8
-hex16.1: xchgb %ah,%al # Save/restore
-hex8: pushl %eax # Save
- shrb $0x4,%al # Do upper
- call hex8.1 # 4
- popl %eax # Restore
-hex8.1: andb $0xf,%al # Get lower 4
- cmpb $0xa,%al # Convert
- sbbb $0x69,%al # to hex
- das # digit
- orb $0x20,%al # To lower case
- stosb # Save char
- ret # (Recursive)
-
- .data
- .p2align 4
-#
-# Global descriptor table.
-#
-gdt: .word 0x0,0x0,0x0,0x0 # Null entry
- .word 0xffff,0x0,0x9a00,0xcf # SEL_SCODE
- .word 0xffff,0x0,0x9200,0xcf # SEL_SDATA
- .word 0xffff,0x0,0x9a00,0x0 # SEL_RCODE
- .word 0xffff,0x0,0x9200,0x0 # SEL_RDATA
-gdt.1:
-gdtdesc: .word gdt.1-gdt-1 # Limit
- .long gdt # Base
-#
-# Messages.
-#
-m_logo: .asciz " \nBTX loader 1.00 "
-m_vers: .asciz "BTX version is \0\n"
-e_fmt: .asciz "Error: Client format not supported\n"
-#.ifdef BTXLDR_VERBOSE
-m_mem: .asciz "Starting in protected mode (base mem=\0)\n"
-m_esp: .asciz "Arguments passed (esp=\0):\n"
-m_args: .asciz"<howto="
- .asciz" bootdev="
- .asciz" junk="
- .asciz" "
- .asciz" "
- .asciz" bootinfo=\0>\n"
-m_rel_bi: .asciz "Relocated bootinfo (size=48) to \0\n"
-m_rel_args: .asciz "Relocated arguments (size=18) to \0\n"
-m_rel_btx: .asciz "Relocated kernel (size=\0) to \0\n"
-m_base: .asciz "Client base address is \0\n"
-m_elf: .asciz "Client format is ELF\n"
-m_segs: .asciz "text segment: offset="
- .asciz " vaddr="
- .asciz " filesz="
- .asciz " memsz=\0\n"
- .asciz "data segment: offset="
- .asciz " vaddr="
- .asciz " filesz="
- .asciz " memsz=\0\n"
-m_done: .asciz "Loading complete\n"
-#.endif
-#
-# Uninitialized data area.
-#
-buf: # Scratch buffer
diff --git a/sys/boot/powerpc/loader/conf.c b/sys/boot/powerpc/loader/conf.c
deleted file mode 100644
index d243399fe8c3..000000000000
--- a/sys/boot/powerpc/loader/conf.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/*-
- * Copyright (c) 1999 Michael Smith <msmith@freebsd.org>
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include <stand.h>
-#include "libalpha/libalpha.h"
-#ifdef LOADER_NET_SUPPORT
-#include "dev_net.h"
-#endif
-
-/*
- * We could use linker sets for some or all of these, but
- * then we would have to control what ended up linked into
- * the bootstrap. So it's easier to conditionalise things
- * here.
- *
- * XXX rename these arrays to be consistent and less namespace-hostile
- */
-
-/* Exported for libstand */
-struct devsw *devsw[] = {
-#if defined(LOADER_DISK_SUPPORT) || defined(LOADER_CDROM_SUPPORT)
- &srmdisk,
-#endif
-#ifdef LOADER_NET_SUPPORT
- &netdev,
-#endif
- NULL
-};
-
-struct fs_ops *file_system[] = {
-#ifdef LOADER_DISK_SUPPORT
- &ufs_fsops,
-#endif
-#ifdef LOADER_CDROM_SUPPORT
- &cd9660_fsops,
-#endif
-#ifdef LOADER_NET_SUPPORT
- &nfs_fsops,
-#endif
- &zipfs_fsops,
- NULL
-};
-
-#ifdef LOADER_NET_SUPPORT
-struct netif_driver *netif_drivers[] = {
- &srmnet,
- NULL,
-};
-#endif
-
-/* Exported for alpha only */
-/*
- * Sort formats so that those that can detect based on arguments
- * rather than reading the file go first.
- */
-extern struct module_format alpha_elf;
-
-struct module_format *module_formats[] = {
- &alpha_elf,
- NULL
-};
-
-/*
- * Consoles
- *
- * We don't prototype these in libalpha.h because they require
- * data structures from bootstrap.h as well.
- */
-extern struct console promconsole;
-
-struct console *consoles[] = {
- &promconsole,
- NULL
-};
diff --git a/sys/boot/powerpc/ofw/conf.c b/sys/boot/powerpc/ofw/conf.c
deleted file mode 100644
index d243399fe8c3..000000000000
--- a/sys/boot/powerpc/ofw/conf.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/*-
- * Copyright (c) 1999 Michael Smith <msmith@freebsd.org>
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include <stand.h>
-#include "libalpha/libalpha.h"
-#ifdef LOADER_NET_SUPPORT
-#include "dev_net.h"
-#endif
-
-/*
- * We could use linker sets for some or all of these, but
- * then we would have to control what ended up linked into
- * the bootstrap. So it's easier to conditionalise things
- * here.
- *
- * XXX rename these arrays to be consistent and less namespace-hostile
- */
-
-/* Exported for libstand */
-struct devsw *devsw[] = {
-#if defined(LOADER_DISK_SUPPORT) || defined(LOADER_CDROM_SUPPORT)
- &srmdisk,
-#endif
-#ifdef LOADER_NET_SUPPORT
- &netdev,
-#endif
- NULL
-};
-
-struct fs_ops *file_system[] = {
-#ifdef LOADER_DISK_SUPPORT
- &ufs_fsops,
-#endif
-#ifdef LOADER_CDROM_SUPPORT
- &cd9660_fsops,
-#endif
-#ifdef LOADER_NET_SUPPORT
- &nfs_fsops,
-#endif
- &zipfs_fsops,
- NULL
-};
-
-#ifdef LOADER_NET_SUPPORT
-struct netif_driver *netif_drivers[] = {
- &srmnet,
- NULL,
-};
-#endif
-
-/* Exported for alpha only */
-/*
- * Sort formats so that those that can detect based on arguments
- * rather than reading the file go first.
- */
-extern struct module_format alpha_elf;
-
-struct module_format *module_formats[] = {
- &alpha_elf,
- NULL
-};
-
-/*
- * Consoles
- *
- * We don't prototype these in libalpha.h because they require
- * data structures from bootstrap.h as well.
- */
-extern struct console promconsole;
-
-struct console *consoles[] = {
- &promconsole,
- NULL
-};
diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c
deleted file mode 100644
index cee65db8a0af..000000000000
--- a/sys/compat/linux/linux_file.c
+++ /dev/null
@@ -1,893 +0,0 @@
-/*-
- * Copyright (c) 1994-1995 Søren Schmidt
- * 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
- * in this position and unchanged.
- * 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 withough 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.
- *
- * $FreeBSD$
- */
-
-#include "opt_compat.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/sysproto.h>
-#include <sys/fcntl.h>
-#include <sys/file.h>
-#include <sys/filedesc.h>
-#include <sys/lock.h>
-#include <sys/proc.h>
-#include <sys/vnode.h>
-#include <sys/malloc.h>
-#include <sys/dirent.h>
-#include <sys/conf.h>
-#include <sys/tty.h>
-
-#include <i386/linux/linux.h>
-#include <i386/linux/linux_proto.h>
-#include <i386/linux/linux_util.h>
-
-int
-linux_creat(struct proc *p, struct linux_creat_args *args)
-{
- struct open_args /* {
- char *path;
- int flags;
- int mode;
- } */ bsd_open_args;
- caddr_t sg;
-
- sg = stackgap_init();
- CHECKALTCREAT(p, &sg, args->path);
-
-#ifdef DEBUG
- printf("Linux-emul(%d): creat(%s, %d)\n",
- p->p_pid, args->path, args->mode);
-#endif
- bsd_open_args.path = args->path;
- bsd_open_args.mode = args->mode;
- bsd_open_args.flags = O_WRONLY | O_CREAT | O_TRUNC;
- return open(p, &bsd_open_args);
-}
-
-int
-linux_open(struct proc *p, struct linux_open_args *args)
-{
- struct open_args /* {
- char *path;
- int flags;
- int mode;
- } */ bsd_open_args;
- int error;
- caddr_t sg;
-
- sg = stackgap_init();
-
- if (args->flags & LINUX_O_CREAT)
- CHECKALTCREAT(p, &sg, args->path);
- else
- CHECKALTEXIST(p, &sg, args->path);
-
-#ifdef DEBUG
- printf("Linux-emul(%d): open(%s, 0x%x, 0x%x)\n",
- p->p_pid, args->path, args->flags, args->mode);
-#endif
- bsd_open_args.flags = 0;
- if (args->flags & LINUX_O_RDONLY)
- bsd_open_args.flags |= O_RDONLY;
- if (args->flags & LINUX_O_WRONLY)
- bsd_open_args.flags |= O_WRONLY;
- if (args->flags & LINUX_O_RDWR)
- bsd_open_args.flags |= O_RDWR;
- if (args->flags & LINUX_O_NDELAY)
- bsd_open_args.flags |= O_NONBLOCK;
- if (args->flags & LINUX_O_APPEND)
- bsd_open_args.flags |= O_APPEND;
- if (args->flags & LINUX_O_SYNC)
- bsd_open_args.flags |= O_FSYNC;
- if (args->flags & LINUX_O_NONBLOCK)
- bsd_open_args.flags |= O_NONBLOCK;
- if (args->flags & LINUX_FASYNC)
- bsd_open_args.flags |= O_ASYNC;
- if (args->flags & LINUX_O_CREAT)
- bsd_open_args.flags |= O_CREAT;
- if (args->flags & LINUX_O_TRUNC)
- bsd_open_args.flags |= O_TRUNC;
- if (args->flags & LINUX_O_EXCL)
- bsd_open_args.flags |= O_EXCL;
- if (args->flags & LINUX_O_NOCTTY)
- bsd_open_args.flags |= O_NOCTTY;
- bsd_open_args.path = args->path;
- bsd_open_args.mode = args->mode;
-
- error = open(p, &bsd_open_args);
- if (!error && !(bsd_open_args.flags & O_NOCTTY) &&
- SESS_LEADER(p) && !(p->p_flag & P_CONTROLT)) {
- struct filedesc *fdp = p->p_fd;
- struct file *fp = fdp->fd_ofiles[p->p_retval[0]];
-
- if (fp->f_type == DTYPE_VNODE)
- fo_ioctl(fp, TIOCSCTTY, (caddr_t) 0, p);
- }
-#ifdef DEBUG
- printf("Linux-emul(%d): open returns error %d\n",
- p->p_pid, error);
-#endif
- return error;
-}
-
-struct linux_flock {
- short l_type;
- short l_whence;
- linux_off_t l_start;
- linux_off_t l_len;
- linux_pid_t l_pid;
-};
-
-static void
-linux_to_bsd_flock(struct linux_flock *linux_flock, struct flock *bsd_flock)
-{
- switch (linux_flock->l_type) {
- case LINUX_F_RDLCK:
- bsd_flock->l_type = F_RDLCK;
- break;
- case LINUX_F_WRLCK:
- bsd_flock->l_type = F_WRLCK;
- break;
- case LINUX_F_UNLCK:
- bsd_flock->l_type = F_UNLCK;
- break;
- default:
- bsd_flock->l_type = -1;
- break;
- }
- bsd_flock->l_whence = linux_flock->l_whence;
- bsd_flock->l_start = (off_t)linux_flock->l_start;
- bsd_flock->l_len = (off_t)linux_flock->l_len;
- bsd_flock->l_pid = (pid_t)linux_flock->l_pid;
-}
-
-static void
-bsd_to_linux_flock(struct flock *bsd_flock, struct linux_flock *linux_flock)
-{
- switch (bsd_flock->l_type) {
- case F_RDLCK:
- linux_flock->l_type = LINUX_F_RDLCK;
- break;
- case F_WRLCK:
- linux_flock->l_type = LINUX_F_WRLCK;
- break;
- case F_UNLCK:
- linux_flock->l_type = LINUX_F_UNLCK;
- break;
- }
- linux_flock->l_whence = bsd_flock->l_whence;
- linux_flock->l_start = (linux_off_t)bsd_flock->l_start;
- linux_flock->l_len = (linux_off_t)bsd_flock->l_len;
- linux_flock->l_pid = (linux_pid_t)bsd_flock->l_pid;
-}
-
-int
-linux_fcntl(struct proc *p, struct linux_fcntl_args *args)
-{
- int error, result;
- struct fcntl_args /* {
- int fd;
- int cmd;
- int arg;
- } */ fcntl_args;
- struct linux_flock linux_flock;
- struct flock *bsd_flock;
- struct filedesc *fdp;
- struct file *fp;
- struct vnode *vp;
- long pgid;
- struct pgrp *pgrp;
- struct tty *tp;
- caddr_t sg;
- dev_t dev;
-
- sg = stackgap_init();
- bsd_flock = (struct flock *)stackgap_alloc(&sg, sizeof(struct flock));
-
-#ifdef DEBUG
- printf("Linux-emul(%d): fcntl(%d, %08x, *)\n",
- p->p_pid, args->fd, args->cmd);
-#endif
- fcntl_args.fd = args->fd;
-
- switch (args->cmd) {
- case LINUX_F_DUPFD:
- fcntl_args.cmd = F_DUPFD;
- fcntl_args.arg = args->arg;
- return fcntl(p, &fcntl_args);
-
- case LINUX_F_GETFD:
- fcntl_args.cmd = F_GETFD;
- return fcntl(p, &fcntl_args);
-
- case LINUX_F_SETFD:
- fcntl_args.cmd = F_SETFD;
- fcntl_args.arg = args->arg;
- return fcntl(p, &fcntl_args);
-
- case LINUX_F_GETFL:
- fcntl_args.cmd = F_GETFL;
- error = fcntl(p, &fcntl_args);
- result = p->p_retval[0];
- p->p_retval[0] = 0;
- if (result & O_RDONLY) p->p_retval[0] |= LINUX_O_RDONLY;
- if (result & O_WRONLY) p->p_retval[0] |= LINUX_O_WRONLY;
- if (result & O_RDWR) p->p_retval[0] |= LINUX_O_RDWR;
- if (result & O_NDELAY) p->p_retval[0] |= LINUX_O_NONBLOCK;
- if (result & O_APPEND) p->p_retval[0] |= LINUX_O_APPEND;
- if (result & O_FSYNC) p->p_retval[0] |= LINUX_O_SYNC;
- if (result & O_ASYNC) p->p_retval[0] |= LINUX_FASYNC;
- return error;
-
- case LINUX_F_SETFL:
- fcntl_args.arg = 0;
- if (args->arg & LINUX_O_NDELAY) fcntl_args.arg |= O_NONBLOCK;
- if (args->arg & LINUX_O_APPEND) fcntl_args.arg |= O_APPEND;
- if (args->arg & LINUX_O_SYNC) fcntl_args.arg |= O_FSYNC;
- if (args->arg & LINUX_FASYNC) fcntl_args.arg |= O_ASYNC;
- fcntl_args.cmd = F_SETFL;
- return fcntl(p, &fcntl_args);
-
- case LINUX_F_GETLK:
- if ((error = copyin((caddr_t)args->arg, (caddr_t)&linux_flock,
- sizeof(struct linux_flock))))
- return error;
- linux_to_bsd_flock(&linux_flock, bsd_flock);
- fcntl_args.cmd = F_GETLK;
- fcntl_args.arg = (int)bsd_flock;
- error = fcntl(p, &fcntl_args);
- if (error)
- return error;
- bsd_to_linux_flock(bsd_flock, &linux_flock);
- return copyout((caddr_t)&linux_flock, (caddr_t)args->arg,
- sizeof(struct linux_flock));
-
- case LINUX_F_SETLK:
- if ((error = copyin((caddr_t)args->arg, (caddr_t)&linux_flock,
- sizeof(struct linux_flock))))
- return error;
- linux_to_bsd_flock(&linux_flock, bsd_flock);
- fcntl_args.cmd = F_SETLK;
- fcntl_args.arg = (int)bsd_flock;
- return fcntl(p, &fcntl_args);
-
- case LINUX_F_SETLKW:
- if ((error = copyin((caddr_t)args->arg, (caddr_t)&linux_flock,
- sizeof(struct linux_flock))))
- return error;
- linux_to_bsd_flock(&linux_flock, bsd_flock);
- fcntl_args.cmd = F_SETLKW;
- fcntl_args.arg = (int)bsd_flock;
- return fcntl(p, &fcntl_args);
-
- case LINUX_F_SETOWN:
- case LINUX_F_GETOWN:
- /*
- * We need to route around the normal fcntl() for these calls,
- * since it uses TIOC{G,S}PGRP, which is too restrictive for
- * Linux F_{G,S}ETOWN semantics. For sockets, this problem
- * does not exist.
- */
- fdp = p->p_fd;
- if ((u_int)args->fd >= fdp->fd_nfiles ||
- (fp = fdp->fd_ofiles[args->fd]) == NULL)
- return EBADF;
- if (fp->f_type == DTYPE_SOCKET) {
- fcntl_args.cmd = args->cmd == LINUX_F_SETOWN ? F_SETOWN : F_GETOWN;
- fcntl_args.arg = args->arg;
- return fcntl(p, &fcntl_args);
- }
- vp = (struct vnode *)fp->f_data;
- dev = vn_todev(vp);
- if (dev == NODEV)
- return EINVAL;
- if (!(devsw(dev)->d_flags & D_TTY))
- return EINVAL;
- tp = dev->si_tty;
- if (!tp)
- return EINVAL;
- if (args->cmd == LINUX_F_GETOWN) {
- p->p_retval[0] = tp->t_pgrp ? tp->t_pgrp->pg_id : NO_PID;
- return 0;
- }
- if ((long)args->arg <= 0) {
- pgid = -(long)args->arg;
- } else {
- struct proc *p1 = pfind((long)args->arg);
- if (p1 == 0)
- return (ESRCH);
- pgid = (long)p1->p_pgrp->pg_id;
- }
- pgrp = pgfind(pgid);
- if (pgrp == NULL || pgrp->pg_session != p->p_session)
- return EPERM;
- tp->t_pgrp = pgrp;
- return 0;
- }
- return EINVAL;
-}
-
-int
-linux_lseek(struct proc *p, struct linux_lseek_args *args)
-{
-
- struct lseek_args /* {
- int fd;
- int pad;
- off_t offset;
- int whence;
- } */ tmp_args;
- int error;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): lseek(%d, %ld, %d)\n",
- (long)p->p_pid, args->fdes, args->off, args->whence);
-#endif
- tmp_args.fd = args->fdes;
- tmp_args.offset = (off_t)args->off;
- tmp_args.whence = args->whence;
- error = lseek(p, &tmp_args);
- return error;
-}
-
-int
-linux_llseek(struct proc *p, struct linux_llseek_args *args)
-{
- struct lseek_args bsd_args;
- int error;
- off_t off;
-
-#ifdef DEBUG
- printf("Linux-emul(%d): llseek(%d, %d:%d, %d)\n",
- p->p_pid, args->fd, args->ohigh, args->olow, args->whence);
-#endif
- off = (args->olow) | (((off_t) args->ohigh) << 32);
-
- bsd_args.fd = args->fd;
- bsd_args.offset = off;
- bsd_args.whence = args->whence;
-
- if ((error = lseek(p, &bsd_args)))
- return error;
-
- if ((error = copyout(p->p_retval, (caddr_t)args->res, sizeof (off_t))))
- return error;
-
- p->p_retval[0] = 0;
- return 0;
-}
-
-
-struct linux_dirent {
- long dino;
- linux_off_t doff;
- unsigned short dreclen;
- char dname[LINUX_NAME_MAX + 1];
-};
-
-#define LINUX_RECLEN(de,namlen) \
- ALIGN((((char *)&(de)->dname - (char *)de) + (namlen) + 1))
-
-int
-linux_readdir(struct proc *p, struct linux_readdir_args *args)
-{
- struct linux_getdents_args lda;
-
- lda.fd = args->fd;
- lda.dent = args->dent;
- lda.count = 1;
- return linux_getdents(p, &lda);
-}
-
-int
-linux_getdents(struct proc *p, struct linux_getdents_args *args)
-{
- register struct dirent *bdp;
- struct vnode *vp;
- caddr_t inp, buf; /* BSD-format */
- int len, reclen; /* BSD-format */
- caddr_t outp; /* Linux-format */
- int resid, linuxreclen=0; /* Linux-format */
- struct file *fp;
- struct uio auio;
- struct iovec aiov;
- struct vattr va;
- off_t off;
- struct linux_dirent linux_dirent;
- int buflen, error, eofflag, nbytes, justone;
- u_long *cookies = NULL, *cookiep;
- int ncookies;
-
-#ifdef DEBUG
- printf("Linux-emul(%d): getdents(%d, *, %d)\n",
- p->p_pid, args->fd, args->count);
-#endif
- if ((error = getvnode(p->p_fd, args->fd, &fp)) != 0) {
- return (error);
- }
-
- if ((fp->f_flag & FREAD) == 0)
- return (EBADF);
-
- vp = (struct vnode *) fp->f_data;
-
- if (vp->v_type != VDIR)
- return (EINVAL);
-
- if ((error = VOP_GETATTR(vp, &va, p->p_ucred, p))) {
- return error;
- }
-
- nbytes = args->count;
- if (nbytes == 1) {
- nbytes = sizeof (struct linux_dirent);
- justone = 1;
- }
- else
- justone = 0;
-
- off = fp->f_offset;
-#define DIRBLKSIZ 512 /* XXX we used to use ufs's DIRBLKSIZ */
- buflen = max(DIRBLKSIZ, nbytes);
- buflen = min(buflen, MAXBSIZE);
- buf = malloc(buflen, M_TEMP, M_WAITOK);
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
-again:
- aiov.iov_base = buf;
- aiov.iov_len = buflen;
- auio.uio_iov = &aiov;
- auio.uio_iovcnt = 1;
- auio.uio_rw = UIO_READ;
- auio.uio_segflg = UIO_SYSSPACE;
- auio.uio_procp = p;
- auio.uio_resid = buflen;
- auio.uio_offset = off;
-
- if (cookies) {
- free(cookies, M_TEMP);
- cookies = NULL;
- }
-
- error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, &ncookies, &cookies);
- if (error) {
- goto out;
- }
-
- inp = buf;
- outp = (caddr_t) args->dent;
- resid = nbytes;
- if ((len = buflen - auio.uio_resid) <= 0) {
- goto eof;
- }
-
- cookiep = cookies;
-
- if (cookies) {
- /*
- * When using cookies, the vfs has the option of reading from
- * a different offset than that supplied (UFS truncates the
- * offset to a block boundary to make sure that it never reads
- * partway through a directory entry, even if the directory
- * has been compacted).
- */
- while (len > 0 && ncookies > 0 && *cookiep <= off) {
- bdp = (struct dirent *) inp;
- len -= bdp->d_reclen;
- inp += bdp->d_reclen;
- cookiep++;
- ncookies--;
- }
- }
-
- while (len > 0) {
- if (cookiep && ncookies == 0)
- break;
- bdp = (struct dirent *) inp;
- reclen = bdp->d_reclen;
- if (reclen & 3) {
- printf("linux_readdir: reclen=%d\n", reclen);
- error = EFAULT;
- goto out;
- }
-
- if (bdp->d_fileno == 0) {
- inp += reclen;
- if (cookiep) {
- off = *cookiep++;
- ncookies--;
- } else
- off += reclen;
- len -= reclen;
- continue;
- }
- linuxreclen = LINUX_RECLEN(&linux_dirent, bdp->d_namlen);
- if (reclen > len || resid < linuxreclen) {
- outp++;
- break;
- }
- linux_dirent.dino = (long) bdp->d_fileno;
- if (justone) {
- /*
- * old linux-style readdir usage.
- */
- linux_dirent.doff = (linux_off_t) linuxreclen;
- linux_dirent.dreclen = (u_short) bdp->d_namlen;
- } else {
- linux_dirent.doff = (linux_off_t)(off + reclen);
- linux_dirent.dreclen = (u_short) linuxreclen;
- }
- strcpy(linux_dirent.dname, bdp->d_name);
- if ((error = copyout((caddr_t)&linux_dirent, outp, linuxreclen))) {
- goto out;
- }
- inp += reclen;
- if (cookiep) {
- off = *cookiep++;
- ncookies--;
- } else
- off += reclen;
- outp += linuxreclen;
- resid -= linuxreclen;
- len -= reclen;
- if (justone)
- break;
- }
-
- if (outp == (caddr_t) args->dent)
- goto again;
- fp->f_offset = off;
-
- if (justone)
- nbytes = resid + linuxreclen;
-
-eof:
- p->p_retval[0] = nbytes - resid;
-out:
- if (cookies)
- free(cookies, M_TEMP);
- VOP_UNLOCK(vp, 0, p);
- free(buf, M_TEMP);
- return error;
-}
-
-/*
- * These exist mainly for hooks for doing /compat/linux translation.
- */
-
-int
-linux_access(struct proc *p, struct linux_access_args *args)
-{
- struct access_args bsd;
- caddr_t sg;
-
- sg = stackgap_init();
- CHECKALTEXIST(p, &sg, args->path);
-
-#ifdef DEBUG
- printf("Linux-emul(%d): access(%s, %d)\n",
- p->p_pid, args->path, args->flags);
-#endif
- bsd.path = args->path;
- bsd.flags = args->flags;
-
- return access(p, &bsd);
-}
-
-int
-linux_unlink(struct proc *p, struct linux_unlink_args *args)
-{
- struct unlink_args bsd;
- caddr_t sg;
-
- sg = stackgap_init();
- CHECKALTEXIST(p, &sg, args->path);
-
-#ifdef DEBUG
- printf("Linux-emul(%d): unlink(%s)\n",
- p->p_pid, args->path);
-#endif
- bsd.path = args->path;
-
- return unlink(p, &bsd);
-}
-
-int
-linux_chdir(struct proc *p, struct linux_chdir_args *args)
-{
- struct chdir_args bsd;
- caddr_t sg;
-
- sg = stackgap_init();
- CHECKALTEXIST(p, &sg, args->path);
-
-#ifdef DEBUG
- printf("Linux-emul(%d): chdir(%s)\n",
- p->p_pid, args->path);
-#endif
- bsd.path = args->path;
-
- return chdir(p, &bsd);
-}
-
-int
-linux_chmod(struct proc *p, struct linux_chmod_args *args)
-{
- struct chmod_args bsd;
- caddr_t sg;
-
- sg = stackgap_init();
- CHECKALTEXIST(p, &sg, args->path);
-
-#ifdef DEBUG
- printf("Linux-emul(%d): chmod(%s, %d)\n",
- p->p_pid, args->path, args->mode);
-#endif
- bsd.path = args->path;
- bsd.mode = args->mode;
-
- return chmod(p, &bsd);
-}
-
-int
-linux_chown(struct proc *p, struct linux_chown_args *args)
-{
- struct chown_args bsd;
- caddr_t sg;
-
- sg = stackgap_init();
- CHECKALTEXIST(p, &sg, args->path);
-
-#ifdef DEBUG
- printf("Linux-emul(%d): chown(%s, %d, %d)\n",
- p->p_pid, args->path, args->uid, args->gid);
-#endif
- bsd.path = args->path;
- /* XXX size casts here */
- bsd.uid = args->uid;
- bsd.gid = args->gid;
-
- return chown(p, &bsd);
-}
-
-int
-linux_lchown(struct proc *p, struct linux_lchown_args *args)
-{
- struct lchown_args bsd;
- caddr_t sg;
-
- sg = stackgap_init();
- CHECKALTEXIST(p, &sg, args->path);
-
-#ifdef DEBUG
- printf("Linux-emul(%d): lchown(%s, %d, %d)\n",
- p->p_pid, args->path, args->uid, args->gid);
-#endif
- bsd.path = args->path;
- /* XXX size casts here */
- bsd.uid = args->uid;
- bsd.gid = args->gid;
-
- return lchown(p, &bsd);
-}
-
-int
-linux_mkdir(struct proc *p, struct linux_mkdir_args *args)
-{
- struct mkdir_args bsd;
- caddr_t sg;
-
- sg = stackgap_init();
- CHECKALTCREAT(p, &sg, args->path);
-
-#ifdef DEBUG
- printf("Linux-emul(%d): mkdir(%s, %d)\n",
- p->p_pid, args->path, args->mode);
-#endif
- bsd.path = args->path;
- bsd.mode = args->mode;
-
- return mkdir(p, &bsd);
-}
-
-int
-linux_rmdir(struct proc *p, struct linux_rmdir_args *args)
-{
- struct rmdir_args bsd;
- caddr_t sg;
-
- sg = stackgap_init();
- CHECKALTEXIST(p, &sg, args->path);
-
-#ifdef DEBUG
- printf("Linux-emul(%d): rmdir(%s)\n",
- p->p_pid, args->path);
-#endif
- bsd.path = args->path;
-
- return rmdir(p, &bsd);
-}
-
-int
-linux_rename(struct proc *p, struct linux_rename_args *args)
-{
- struct rename_args bsd;
- caddr_t sg;
-
- sg = stackgap_init();
- CHECKALTEXIST(p, &sg, args->from);
- CHECKALTCREAT(p, &sg, args->to);
-
-#ifdef DEBUG
- printf("Linux-emul(%d): rename(%s, %s)\n",
- p->p_pid, args->from, args->to);
-#endif
- bsd.from = args->from;
- bsd.to = args->to;
-
- return rename(p, &bsd);
-}
-
-int
-linux_symlink(struct proc *p, struct linux_symlink_args *args)
-{
- struct symlink_args bsd;
- caddr_t sg;
-
- sg = stackgap_init();
- CHECKALTEXIST(p, &sg, args->path);
- CHECKALTCREAT(p, &sg, args->to);
-
-#ifdef DEBUG
- printf("Linux-emul(%d): symlink(%s, %s)\n",
- p->p_pid, args->path, args->to);
-#endif
- bsd.path = args->path;
- bsd.link = args->to;
-
- return symlink(p, &bsd);
-}
-
-int
-linux_execve(struct proc *p, struct linux_execve_args *args)
-{
- struct execve_args bsd;
- caddr_t sg;
-
- sg = stackgap_init();
- CHECKALTEXIST(p, &sg, args->path);
-
-#ifdef DEBUG
- printf("Linux-emul(%d): execve(%s)\n",
- p->p_pid, args->path);
-#endif
- bsd.fname = args->path;
- bsd.argv = args->argp;
- bsd.envv = args->envp;
-
- return execve(p, &bsd);
-}
-
-int
-linux_readlink(struct proc *p, struct linux_readlink_args *args)
-{
- struct readlink_args bsd;
- caddr_t sg;
-
- sg = stackgap_init();
- CHECKALTEXIST(p, &sg, args->name);
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): readlink(%s, %p, %d)\n",
- (long)p->p_pid, args->name, (void *)args->buf, args->count);
-#endif
- bsd.path = args->name;
- bsd.buf = args->buf;
- bsd.count = args->count;
-
- return readlink(p, &bsd);
-}
-
-int
-linux_truncate(struct proc *p, struct linux_truncate_args *args)
-{
- struct truncate_args bsd;
- caddr_t sg;
-
- sg = stackgap_init();
- CHECKALTEXIST(p, &sg, args->path);
-
-#ifdef DEBUG
- printf("Linux-emul(%d): truncate(%s, %ld)\n",
- p->p_pid, args->path, args->length);
-#endif
- bsd.path = args->path;
- bsd.length = args->length;
-
- return truncate(p, &bsd);
-}
-
-int
-linux_link(struct proc *p, struct linux_link_args *args)
-{
- struct link_args bsd;
- caddr_t sg;
-
- sg = stackgap_init();
- CHECKALTEXIST(p, &sg, args->path);
- CHECKALTCREAT(p, &sg, args->to);
-
-#ifdef DEBUG
- printf("Linux-emul(%d): link(%s, %s)\n", p->p_pid, args->path, args->to);
-#endif
-
- bsd.path = args->path;
- bsd.link = args->to;
-
- return link(p, &bsd);
-}
-
-int
-linux_getcwd(struct proc *p, struct linux_getcwd_args *args)
-{
- struct __getcwd_args bsd;
- caddr_t sg;
- int error, len;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): getcwd(%p, %ld)\n", (long)p->p_pid,
- args->buf, args->bufsize);
-#endif
-
- sg = stackgap_init();
- bsd.buf = stackgap_alloc(&sg, SPARE_USRSPACE);
- bsd.buflen = SPARE_USRSPACE;
- error = __getcwd(p, &bsd);
- if (!error) {
- len = strlen(bsd.buf) + 1;
- if (len <= args->bufsize) {
- p->p_retval[0] = len;
- error = copyout(bsd.buf, args->buf, len);
- }
- else
- error = ERANGE;
- }
- return (error);
-}
-
-int
-linux_fdatasync(p, uap)
- struct proc *p;
- struct linux_fdatasync_args *uap;
-{
- struct fsync_args bsd;
-
- bsd.fd = uap->fd;
- return fsync(p, &bsd);
-}
diff --git a/sys/compat/linux/linux_ioctl.c b/sys/compat/linux/linux_ioctl.c
deleted file mode 100644
index cd532e601099..000000000000
--- a/sys/compat/linux/linux_ioctl.c
+++ /dev/null
@@ -1,1529 +0,0 @@
-/*
- * Copyright (c) 1994-1995 Søren Schmidt
- * 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
- * in this position and unchanged.
- * 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 withough 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/sysproto.h>
-#include <sys/proc.h>
-#include <sys/cdio.h>
-#include <sys/fcntl.h>
-#include <sys/file.h>
-#include <sys/filedesc.h>
-#include <sys/filio.h>
-#include <sys/linker_set.h>
-#include <sys/malloc.h>
-#include <sys/tty.h>
-#include <sys/socket.h>
-#include <net/if.h>
-#include <net/if_dl.h>
-#include <net/if_types.h>
-#include <sys/sockio.h>
-#include <sys/soundcard.h>
-#include <sys/disklabel.h>
-
-#include <machine/console.h>
-
-#include <i386/linux/linux.h>
-#include <i386/linux/linux_ioctl.h>
-#include <i386/linux/linux_mib.h>
-#include <i386/linux/linux_proto.h>
-#include <i386/linux/linux_util.h>
-
-static linux_ioctl_function_t linux_ioctl_disk;
-static linux_ioctl_function_t linux_ioctl_cdrom;
-static linux_ioctl_function_t linux_ioctl_console;
-static linux_ioctl_function_t linux_ioctl_socket;
-static linux_ioctl_function_t linux_ioctl_sound;
-static linux_ioctl_function_t linux_ioctl_termio;
-
-static struct linux_ioctl_handler disk_handler =
-{ linux_ioctl_disk, LINUX_IOCTL_DISK_MIN, LINUX_IOCTL_DISK_MAX };
-static struct linux_ioctl_handler cdrom_handler =
-{ linux_ioctl_cdrom, LINUX_IOCTL_CDROM_MIN, LINUX_IOCTL_CDROM_MAX };
-static struct linux_ioctl_handler console_handler =
-{ linux_ioctl_console, LINUX_IOCTL_CONSOLE_MIN, LINUX_IOCTL_CONSOLE_MAX };
-static struct linux_ioctl_handler socket_handler =
-{ linux_ioctl_socket, LINUX_IOCTL_SOCKET_MIN, LINUX_IOCTL_SOCKET_MAX };
-static struct linux_ioctl_handler sound_handler =
-{ linux_ioctl_sound, LINUX_IOCTL_SOUND_MIN, LINUX_IOCTL_SOUND_MAX };
-static struct linux_ioctl_handler termio_handler =
-{ linux_ioctl_termio, LINUX_IOCTL_TERMIO_MIN, LINUX_IOCTL_TERMIO_MAX };
-
-DATA_SET(linux_ioctl_handler_set, disk_handler);
-DATA_SET(linux_ioctl_handler_set, cdrom_handler);
-DATA_SET(linux_ioctl_handler_set, console_handler);
-DATA_SET(linux_ioctl_handler_set, socket_handler);
-DATA_SET(linux_ioctl_handler_set, sound_handler);
-DATA_SET(linux_ioctl_handler_set, termio_handler);
-
-struct handler_element
-{
- TAILQ_ENTRY(handler_element) list;
- int (*func)(struct proc *, struct linux_ioctl_args *);
- int low, high, span;
-};
-
-static TAILQ_HEAD(, handler_element) handlers =
- TAILQ_HEAD_INITIALIZER(handlers);
-
-static int
-linux_ioctl_disk(struct proc *p, struct linux_ioctl_args *args)
-{
- struct file *fp = p->p_fd->fd_ofiles[args->fd];
- int error;
- struct disklabel dl;
-
- switch (args->cmd & 0xffff) {
- case LINUX_BLKGETSIZE:
- error = fo_ioctl(fp, DIOCGDINFO, (caddr_t)&dl, p);
- if (error)
- return (error);
- return copyout(&(dl.d_secperunit), (caddr_t)args->arg, sizeof(dl.d_secperunit));
- break;
- }
- return (ENOIOCTL);
-}
-
-/*
- * termio related ioctls
- */
-
-struct linux_termio {
- unsigned short c_iflag;
- unsigned short c_oflag;
- unsigned short c_cflag;
- unsigned short c_lflag;
- unsigned char c_line;
- unsigned char c_cc[LINUX_NCC];
-};
-
-struct linux_termios {
- unsigned int c_iflag;
- unsigned int c_oflag;
- unsigned int c_cflag;
- unsigned int c_lflag;
- unsigned char c_line;
- unsigned char c_cc[LINUX_NCCS];
-};
-
-struct linux_winsize {
- unsigned short ws_row, ws_col;
- unsigned short ws_xpixel, ws_ypixel;
-};
-
-static struct speedtab sptab[] = {
- { B0, LINUX_B0 }, { B50, LINUX_B50 },
- { B75, LINUX_B75 }, { B110, LINUX_B110 },
- { B134, LINUX_B134 }, { B150, LINUX_B150 },
- { B200, LINUX_B200 }, { B300, LINUX_B300 },
- { B600, LINUX_B600 }, { B1200, LINUX_B1200 },
- { B1800, LINUX_B1800 }, { B2400, LINUX_B2400 },
- { B4800, LINUX_B4800 }, { B9600, LINUX_B9600 },
- { B19200, LINUX_B19200 }, { B38400, LINUX_B38400 },
- { B57600, LINUX_B57600 }, { B115200, LINUX_B115200 },
- {-1, -1 }
-};
-
-struct linux_serial_struct {
- int type;
- int line;
- int port;
- int irq;
- int flags;
- int xmit_fifo_size;
- int custom_divisor;
- int baud_base;
- unsigned short close_delay;
- char reserved_char[2];
- int hub6;
- unsigned short closing_wait;
- unsigned short closing_wait2;
- int reserved[4];
-};
-
-static int
-linux_to_bsd_speed(int code, struct speedtab *table)
-{
- for ( ; table->sp_code != -1; table++)
- if (table->sp_code == code)
- return (table->sp_speed);
- return -1;
-}
-
-static int
-bsd_to_linux_speed(int speed, struct speedtab *table)
-{
- for ( ; table->sp_speed != -1; table++)
- if (table->sp_speed == speed)
- return (table->sp_code);
- return -1;
-}
-
-static void
-bsd_to_linux_termios(struct termios *bios, struct linux_termios *lios)
-{
- int i;
-
-#ifdef DEBUG
- printf("LINUX: BSD termios structure (input):\n");
- printf("i=%08x o=%08x c=%08x l=%08x ispeed=%d ospeed=%d\n",
- bios->c_iflag, bios->c_oflag, bios->c_cflag, bios->c_lflag,
- bios->c_ispeed, bios->c_ospeed);
- printf("c_cc ");
- for (i=0; i<NCCS; i++)
- printf("%02x ", bios->c_cc[i]);
- printf("\n");
-#endif
-
- lios->c_iflag = 0;
- if (bios->c_iflag & IGNBRK)
- lios->c_iflag |= LINUX_IGNBRK;
- if (bios->c_iflag & BRKINT)
- lios->c_iflag |= LINUX_BRKINT;
- if (bios->c_iflag & IGNPAR)
- lios->c_iflag |= LINUX_IGNPAR;
- if (bios->c_iflag & PARMRK)
- lios->c_iflag |= LINUX_PARMRK;
- if (bios->c_iflag & INPCK)
- lios->c_iflag |= LINUX_INPCK;
- if (bios->c_iflag & ISTRIP)
- lios->c_iflag |= LINUX_ISTRIP;
- if (bios->c_iflag & INLCR)
- lios->c_iflag |= LINUX_INLCR;
- if (bios->c_iflag & IGNCR)
- lios->c_iflag |= LINUX_IGNCR;
- if (bios->c_iflag & ICRNL)
- lios->c_iflag |= LINUX_ICRNL;
- if (bios->c_iflag & IXON)
- lios->c_iflag |= LINUX_IXON;
- if (bios->c_iflag & IXANY)
- lios->c_iflag |= LINUX_IXANY;
- if (bios->c_iflag & IXOFF)
- lios->c_iflag |= LINUX_IXOFF;
- if (bios->c_iflag & IMAXBEL)
- lios->c_iflag |= LINUX_IMAXBEL;
-
- lios->c_oflag = 0;
- if (bios->c_oflag & OPOST)
- lios->c_oflag |= LINUX_OPOST;
- if (bios->c_oflag & ONLCR)
- lios->c_oflag |= LINUX_ONLCR;
- if (bios->c_oflag & OXTABS)
- lios->c_oflag |= LINUX_XTABS;
-
- lios->c_cflag = bsd_to_linux_speed(bios->c_ispeed, sptab);
- lios->c_cflag |= (bios->c_cflag & CSIZE) >> 4;
- if (bios->c_cflag & CSTOPB)
- lios->c_cflag |= LINUX_CSTOPB;
- if (bios->c_cflag & CREAD)
- lios->c_cflag |= LINUX_CREAD;
- if (bios->c_cflag & PARENB)
- lios->c_cflag |= LINUX_PARENB;
- if (bios->c_cflag & PARODD)
- lios->c_cflag |= LINUX_PARODD;
- if (bios->c_cflag & HUPCL)
- lios->c_cflag |= LINUX_HUPCL;
- if (bios->c_cflag & CLOCAL)
- lios->c_cflag |= LINUX_CLOCAL;
- if (bios->c_cflag & CRTSCTS)
- lios->c_cflag |= LINUX_CRTSCTS;
-
- lios->c_lflag = 0;
- if (bios->c_lflag & ISIG)
- lios->c_lflag |= LINUX_ISIG;
- if (bios->c_lflag & ICANON)
- lios->c_lflag |= LINUX_ICANON;
- if (bios->c_lflag & ECHO)
- lios->c_lflag |= LINUX_ECHO;
- if (bios->c_lflag & ECHOE)
- lios->c_lflag |= LINUX_ECHOE;
- if (bios->c_lflag & ECHOK)
- lios->c_lflag |= LINUX_ECHOK;
- if (bios->c_lflag & ECHONL)
- lios->c_lflag |= LINUX_ECHONL;
- if (bios->c_lflag & NOFLSH)
- lios->c_lflag |= LINUX_NOFLSH;
- if (bios->c_lflag & TOSTOP)
- lios->c_lflag |= LINUX_TOSTOP;
- if (bios->c_lflag & ECHOCTL)
- lios->c_lflag |= LINUX_ECHOCTL;
- if (bios->c_lflag & ECHOPRT)
- lios->c_lflag |= LINUX_ECHOPRT;
- if (bios->c_lflag & ECHOKE)
- lios->c_lflag |= LINUX_ECHOKE;
- if (bios->c_lflag & FLUSHO)
- lios->c_lflag |= LINUX_FLUSHO;
- if (bios->c_lflag & PENDIN)
- lios->c_lflag |= LINUX_PENDIN;
- if (bios->c_lflag & IEXTEN)
- lios->c_lflag |= LINUX_IEXTEN;
-
- for (i=0; i<LINUX_NCCS; i++)
- lios->c_cc[i] = LINUX_POSIX_VDISABLE;
- lios->c_cc[LINUX_VINTR] = bios->c_cc[VINTR];
- lios->c_cc[LINUX_VQUIT] = bios->c_cc[VQUIT];
- lios->c_cc[LINUX_VERASE] = bios->c_cc[VERASE];
- lios->c_cc[LINUX_VKILL] = bios->c_cc[VKILL];
- lios->c_cc[LINUX_VEOF] = bios->c_cc[VEOF];
- lios->c_cc[LINUX_VEOL] = bios->c_cc[VEOL];
- lios->c_cc[LINUX_VMIN] = bios->c_cc[VMIN];
- lios->c_cc[LINUX_VTIME] = bios->c_cc[VTIME];
- lios->c_cc[LINUX_VEOL2] = bios->c_cc[VEOL2];
- lios->c_cc[LINUX_VSUSP] = bios->c_cc[VSUSP];
- lios->c_cc[LINUX_VSTART] = bios->c_cc[VSTART];
- lios->c_cc[LINUX_VSTOP] = bios->c_cc[VSTOP];
- lios->c_cc[LINUX_VREPRINT] = bios->c_cc[VREPRINT];
- lios->c_cc[LINUX_VDISCARD] = bios->c_cc[VDISCARD];
- lios->c_cc[LINUX_VWERASE] = bios->c_cc[VWERASE];
- lios->c_cc[LINUX_VLNEXT] = bios->c_cc[VLNEXT];
-
- for (i=0; i<LINUX_NCCS; i++) {
- if (lios->c_cc[i] == _POSIX_VDISABLE)
- lios->c_cc[i] = LINUX_POSIX_VDISABLE;
- }
- lios->c_line = 0;
-
-#ifdef DEBUG
- printf("LINUX: LINUX termios structure (output):\n");
- printf("i=%08x o=%08x c=%08x l=%08x line=%d\n", lios->c_iflag,
- lios->c_oflag, lios->c_cflag, lios->c_lflag, (int)lios->c_line);
- printf("c_cc ");
- for (i=0; i<LINUX_NCCS; i++)
- printf("%02x ", lios->c_cc[i]);
- printf("\n");
-#endif
-}
-
-static void
-linux_to_bsd_termios(struct linux_termios *lios, struct termios *bios)
-{
- int i;
-
-#ifdef DEBUG
- printf("LINUX: LINUX termios structure (input):\n");
- printf("i=%08x o=%08x c=%08x l=%08x line=%d\n", lios->c_iflag,
- lios->c_oflag, lios->c_cflag, lios->c_lflag, (int)lios->c_line);
- printf("c_cc ");
- for (i=0; i<LINUX_NCCS; i++)
- printf("%02x ", lios->c_cc[i]);
- printf("\n");
-#endif
-
- bios->c_iflag = 0;
- if (lios->c_iflag & LINUX_IGNBRK)
- bios->c_iflag |= IGNBRK;
- if (lios->c_iflag & LINUX_BRKINT)
- bios->c_iflag |= BRKINT;
- if (lios->c_iflag & LINUX_IGNPAR)
- bios->c_iflag |= IGNPAR;
- if (lios->c_iflag & LINUX_PARMRK)
- bios->c_iflag |= PARMRK;
- if (lios->c_iflag & LINUX_INPCK)
- bios->c_iflag |= INPCK;
- if (lios->c_iflag & LINUX_ISTRIP)
- bios->c_iflag |= ISTRIP;
- if (lios->c_iflag & LINUX_INLCR)
- bios->c_iflag |= INLCR;
- if (lios->c_iflag & LINUX_IGNCR)
- bios->c_iflag |= IGNCR;
- if (lios->c_iflag & LINUX_ICRNL)
- bios->c_iflag |= ICRNL;
- if (lios->c_iflag & LINUX_IXON)
- bios->c_iflag |= IXON;
- if (lios->c_iflag & LINUX_IXANY)
- bios->c_iflag |= IXANY;
- if (lios->c_iflag & LINUX_IXOFF)
- bios->c_iflag |= IXOFF;
- if (lios->c_iflag & LINUX_IMAXBEL)
- bios->c_iflag |= IMAXBEL;
-
- bios->c_oflag = 0;
- if (lios->c_oflag & LINUX_OPOST)
- bios->c_oflag |= OPOST;
- if (lios->c_oflag & LINUX_ONLCR)
- bios->c_oflag |= ONLCR;
- if (lios->c_oflag & LINUX_XTABS)
- bios->c_oflag |= OXTABS;
-
- bios->c_cflag = (lios->c_cflag & LINUX_CSIZE) << 4;
- if (lios->c_cflag & LINUX_CSTOPB)
- bios->c_cflag |= CSTOPB;
- if (lios->c_cflag & LINUX_CREAD)
- bios->c_cflag |= CREAD;
- if (lios->c_cflag & LINUX_PARENB)
- bios->c_cflag |= PARENB;
- if (lios->c_cflag & LINUX_PARODD)
- bios->c_cflag |= PARODD;
- if (lios->c_cflag & LINUX_HUPCL)
- bios->c_cflag |= HUPCL;
- if (lios->c_cflag & LINUX_CLOCAL)
- bios->c_cflag |= CLOCAL;
- if (lios->c_cflag & LINUX_CRTSCTS)
- bios->c_cflag |= CRTSCTS;
-
- bios->c_lflag = 0;
- if (lios->c_lflag & LINUX_ISIG)
- bios->c_lflag |= ISIG;
- if (lios->c_lflag & LINUX_ICANON)
- bios->c_lflag |= ICANON;
- if (lios->c_lflag & LINUX_ECHO)
- bios->c_lflag |= ECHO;
- if (lios->c_lflag & LINUX_ECHOE)
- bios->c_lflag |= ECHOE;
- if (lios->c_lflag & LINUX_ECHOK)
- bios->c_lflag |= ECHOK;
- if (lios->c_lflag & LINUX_ECHONL)
- bios->c_lflag |= ECHONL;
- if (lios->c_lflag & LINUX_NOFLSH)
- bios->c_lflag |= NOFLSH;
- if (lios->c_lflag & LINUX_TOSTOP)
- bios->c_lflag |= TOSTOP;
- if (lios->c_lflag & LINUX_ECHOCTL)
- bios->c_lflag |= ECHOCTL;
- if (lios->c_lflag & LINUX_ECHOPRT)
- bios->c_lflag |= ECHOPRT;
- if (lios->c_lflag & LINUX_ECHOKE)
- bios->c_lflag |= ECHOKE;
- if (lios->c_lflag & LINUX_FLUSHO)
- bios->c_lflag |= FLUSHO;
- if (lios->c_lflag & LINUX_PENDIN)
- bios->c_lflag |= PENDIN;
- if (lios->c_lflag & LINUX_IEXTEN)
- bios->c_lflag |= IEXTEN;
-
- for (i=0; i<NCCS; i++)
- bios->c_cc[i] = _POSIX_VDISABLE;
- bios->c_cc[VINTR] = lios->c_cc[LINUX_VINTR];
- bios->c_cc[VQUIT] = lios->c_cc[LINUX_VQUIT];
- bios->c_cc[VERASE] = lios->c_cc[LINUX_VERASE];
- bios->c_cc[VKILL] = lios->c_cc[LINUX_VKILL];
- bios->c_cc[VEOF] = lios->c_cc[LINUX_VEOF];
- bios->c_cc[VEOL] = lios->c_cc[LINUX_VEOL];
- bios->c_cc[VMIN] = lios->c_cc[LINUX_VMIN];
- bios->c_cc[VTIME] = lios->c_cc[LINUX_VTIME];
- bios->c_cc[VEOL2] = lios->c_cc[LINUX_VEOL2];
- bios->c_cc[VSUSP] = lios->c_cc[LINUX_VSUSP];
- bios->c_cc[VSTART] = lios->c_cc[LINUX_VSTART];
- bios->c_cc[VSTOP] = lios->c_cc[LINUX_VSTOP];
- bios->c_cc[VREPRINT] = lios->c_cc[LINUX_VREPRINT];
- bios->c_cc[VDISCARD] = lios->c_cc[LINUX_VDISCARD];
- bios->c_cc[VWERASE] = lios->c_cc[LINUX_VWERASE];
- bios->c_cc[VLNEXT] = lios->c_cc[LINUX_VLNEXT];
-
- for (i=0; i<NCCS; i++) {
- if (bios->c_cc[i] == LINUX_POSIX_VDISABLE)
- bios->c_cc[i] = _POSIX_VDISABLE;
- }
-
- bios->c_ispeed = bios->c_ospeed =
- linux_to_bsd_speed(lios->c_cflag & LINUX_CBAUD, sptab);
-
-#ifdef DEBUG
- printf("LINUX: BSD termios structure (output):\n");
- printf("i=%08x o=%08x c=%08x l=%08x ispeed=%d ospeed=%d\n",
- bios->c_iflag, bios->c_oflag, bios->c_cflag, bios->c_lflag,
- bios->c_ispeed, bios->c_ospeed);
- printf("c_cc ");
- for (i=0; i<NCCS; i++)
- printf("%02x ", bios->c_cc[i]);
- printf("\n");
-#endif
-}
-
-static void
-bsd_to_linux_termio(struct termios *bios, struct linux_termio *lio)
-{
- struct linux_termios lios;
-
- bsd_to_linux_termios(bios, &lios);
- lio->c_iflag = lios.c_iflag;
- lio->c_oflag = lios.c_oflag;
- lio->c_cflag = lios.c_cflag;
- lio->c_lflag = lios.c_lflag;
- lio->c_line = lios.c_line;
- memcpy(lio->c_cc, lios.c_cc, LINUX_NCC);
-}
-
-static void
-linux_to_bsd_termio(struct linux_termio *lio, struct termios *bios)
-{
- struct linux_termios lios;
- int i;
-
- lios.c_iflag = lio->c_iflag;
- lios.c_oflag = lio->c_oflag;
- lios.c_cflag = lio->c_cflag;
- lios.c_lflag = lio->c_lflag;
- for (i=LINUX_NCC; i<LINUX_NCCS; i++)
- lios.c_cc[i] = LINUX_POSIX_VDISABLE;
- memcpy(lios.c_cc, lio->c_cc, LINUX_NCC);
- linux_to_bsd_termios(&lios, bios);
-}
-
-static int
-linux_ioctl_termio(struct proc *p, struct linux_ioctl_args *args)
-{
- struct termios bios;
- struct linux_termios lios;
- struct linux_termio lio;
- struct file *fp = p->p_fd->fd_ofiles[args->fd];
- int error;
-
- switch (args->cmd & 0xffff) {
-
- case LINUX_TCGETS:
- error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bios, p);
- if (error)
- return (error);
- bsd_to_linux_termios(&bios, &lios);
- return copyout(&lios, (caddr_t)args->arg, sizeof(lios));
-
- case LINUX_TCSETS:
- error = copyin((caddr_t)args->arg, &lios, sizeof(lios));
- if (error)
- return (error);
- linux_to_bsd_termios(&lios, &bios);
- return (fo_ioctl(fp, TIOCSETA, (caddr_t)&bios, p));
-
- case LINUX_TCSETSW:
- error = copyin((caddr_t)args->arg, &lios, sizeof(lios));
- if (error)
- return (error);
- linux_to_bsd_termios(&lios, &bios);
- return (fo_ioctl(fp, TIOCSETAW, (caddr_t)&bios, p));
-
- case LINUX_TCSETSF:
- error = copyin((caddr_t)args->arg, &lios, sizeof(lios));
- if (error)
- return (error);
- linux_to_bsd_termios(&lios, &bios);
- return (fo_ioctl(fp, TIOCSETAF, (caddr_t)&bios, p));
-
- case LINUX_TCGETA:
- error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bios, p);
- if (error)
- return (error);
- bsd_to_linux_termio(&bios, &lio);
- return (copyout(&lio, (caddr_t)args->arg, sizeof(lio)));
-
- case LINUX_TCSETA:
- error = copyin((caddr_t)args->arg, &lio, sizeof(lio));
- if (error)
- return (error);
- linux_to_bsd_termio(&lio, &bios);
- return (fo_ioctl(fp, TIOCSETA, (caddr_t)&bios, p));
-
- case LINUX_TCSETAW:
- error = copyin((caddr_t)args->arg, &lio, sizeof(lio));
- if (error)
- return (error);
- linux_to_bsd_termio(&lio, &bios);
- return (fo_ioctl(fp, TIOCSETAW, (caddr_t)&bios, p));
-
- case LINUX_TCSETAF:
- error = copyin((caddr_t)args->arg, &lio, sizeof(lio));
- if (error)
- return (error);
- linux_to_bsd_termio(&lio, &bios);
- return (fo_ioctl(fp, TIOCSETAF, (caddr_t)&bios, p));
-
- /* LINUX_TCSBRK */
-
- case LINUX_TCXONC: {
- switch (args->arg) {
- case LINUX_TCOOFF:
- args->cmd = TIOCSTOP;
- break;
- case LINUX_TCOON:
- args->cmd = TIOCSTART;
- break;
- case LINUX_TCIOFF:
- case LINUX_TCION: {
- int c;
- struct write_args wr;
- error = fo_ioctl(fp, TIOCGETA, (caddr_t)&bios, p);
- if (error)
- return (error);
- c = (args->arg == LINUX_TCIOFF) ? VSTOP : VSTART;
- c = bios.c_cc[c];
- if (c != _POSIX_VDISABLE) {
- wr.fd = args->fd;
- wr.buf = &c;
- wr.nbyte = sizeof(c);
- return (write(p, &wr));
- } else
- return (0);
- }
- default:
- return (EINVAL);
- }
- args->arg = 0;
- return (ioctl(p, (struct ioctl_args *)args));
- }
-
- case LINUX_TCFLSH: {
- args->cmd = TIOCFLUSH;
- switch (args->arg) {
- case LINUX_TCIFLUSH:
- args->arg = FREAD;
- break;
- case LINUX_TCOFLUSH:
- args->arg = FWRITE;
- break;
- case LINUX_TCIOFLUSH:
- args->arg = FREAD | FWRITE;
- break;
- default:
- return (EINVAL);
- }
- return (ioctl(p, (struct ioctl_args *)args));
- }
-
- case LINUX_TIOCEXCL:
- args->cmd = TIOCEXCL;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_TIOCNXCL:
- args->cmd = TIOCNXCL;
- return (ioctl(p, (struct ioctl_args *)args));
-
- /* LINUX_TIOCSCTTY */
-
- case LINUX_TIOCGPGRP:
- args->cmd = TIOCGPGRP;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_TIOCSPGRP:
- args->cmd = TIOCSPGRP;
- return (ioctl(p, (struct ioctl_args *)args));
-
- /* LINUX_TIOCOUTQ */
- /* LINUX_TIOCSTI */
-
- case LINUX_TIOCGWINSZ:
- args->cmd = TIOCGWINSZ;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_TIOCSWINSZ:
- args->cmd = TIOCSWINSZ;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_TIOCMGET:
- args->cmd = TIOCMGET;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_TIOCMBIS:
- args->cmd = TIOCMBIS;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_TIOCMBIC:
- args->cmd = TIOCMBIC;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_TIOCMSET:
- args->cmd = TIOCMSET;
- return (ioctl(p, (struct ioctl_args *)args));
-
- /* TIOCGSOFTCAR */
- /* TIOCSSOFTCAR */
-
- case LINUX_FIONREAD: /* LINUX_TIOCINQ */
- args->cmd = FIONREAD;
- return (ioctl(p, (struct ioctl_args *)args));
-
- /* LINUX_TIOCLINUX */
-
- case LINUX_TIOCCONS:
- args->cmd = TIOCCONS;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_TIOCGSERIAL: {
- struct linux_serial_struct lss;
- lss.type = LINUX_PORT_16550A;
- lss.flags = 0;
- lss.close_delay = 0;
- return copyout(&lss, (caddr_t)args->arg, sizeof(lss));
- }
-
- case LINUX_TIOCSSERIAL: {
- struct linux_serial_struct lss;
- error = copyin((caddr_t)args->arg, &lss, sizeof(lss));
- if (error)
- return (error);
- /* XXX - It really helps to have an implementation that
- * does nothing. NOT!
- */
- return (0);
- }
-
- /* LINUX_TIOCPKT */
-
- case LINUX_FIONBIO:
- args->cmd = FIONBIO;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_TIOCNOTTY:
- args->cmd = TIOCNOTTY;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_TIOCSETD: {
- int line;
- switch (args->arg) {
- case LINUX_N_TTY:
- line = TTYDISC;
- break;
- case LINUX_N_SLIP:
- line = SLIPDISC;
- break;
- case LINUX_N_PPP:
- line = PPPDISC;
- break;
- default:
- return (EINVAL);
- }
- return (fo_ioctl(fp, TIOCSETD, (caddr_t)&line, p));
- }
-
- case LINUX_TIOCGETD: {
- int linux_line;
- int bsd_line = TTYDISC;
- error = fo_ioctl(fp, TIOCGETD, (caddr_t)&bsd_line, p);
- if (error)
- return (error);
- switch (bsd_line) {
- case TTYDISC:
- linux_line = LINUX_N_TTY;
- break;
- case SLIPDISC:
- linux_line = LINUX_N_SLIP;
- break;
- case PPPDISC:
- linux_line = LINUX_N_PPP;
- break;
- default:
- return (EINVAL);
- }
- return (copyout(&linux_line, (caddr_t)args->arg, sizeof(int)));
- }
-
- /* LINUX_TCSBRKP */
- /* LINUX_TIOCTTYGSTRUCT */
-
- case LINUX_FIONCLEX:
- args->cmd = FIONCLEX;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_FIOCLEX:
- args->cmd = FIOCLEX;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_FIOASYNC:
- args->cmd = FIOASYNC;
- return (ioctl(p, (struct ioctl_args *)args));
-
- /* LINUX_TIOCSERCONFIG */
- /* LINUX_TIOCSERGWILD */
- /* LINUX_TIOCSERSWILD */
- /* LINUX_TIOCGLCKTRMIOS */
- /* LINUX_TIOCSLCKTRMIOS */
-
- }
-
- return (ENOIOCTL);
-}
-
-/*
- * CDROM related ioctls
- */
-
-struct linux_cdrom_msf
-{
- u_char cdmsf_min0;
- u_char cdmsf_sec0;
- u_char cdmsf_frame0;
- u_char cdmsf_min1;
- u_char cdmsf_sec1;
- u_char cdmsf_frame1;
-};
-
-struct linux_cdrom_tochdr
-{
- u_char cdth_trk0;
- u_char cdth_trk1;
-};
-
-union linux_cdrom_addr
-{
- struct {
- u_char minute;
- u_char second;
- u_char frame;
- } msf;
- int lba;
-};
-
-struct linux_cdrom_tocentry
-{
- u_char cdte_track;
- u_char cdte_adr:4;
- u_char cdte_ctrl:4;
- u_char cdte_format;
- union linux_cdrom_addr cdte_addr;
- u_char cdte_datamode;
-};
-
-struct linux_cdrom_subchnl
-{
- u_char cdsc_format;
- u_char cdsc_audiostatus;
- u_char cdsc_adr:4;
- u_char cdsc_ctrl:4;
- u_char cdsc_trk;
- u_char cdsc_ind;
- union linux_cdrom_addr cdsc_absaddr;
- union linux_cdrom_addr cdsc_reladdr;
-};
-
-static void
-bsd_to_linux_msf_lba(u_char af, union msf_lba *bp, union linux_cdrom_addr *lp)
-{
- if (af == CD_LBA_FORMAT)
- lp->lba = bp->lba;
- else {
- lp->msf.minute = bp->msf.minute;
- lp->msf.second = bp->msf.second;
- lp->msf.frame = bp->msf.frame;
- }
-}
-
-static void
-set_linux_cdrom_addr(union linux_cdrom_addr *addr, int format, int lba)
-{
- if (format == LINUX_CDROM_MSF) {
- addr->msf.frame = lba % 75;
- lba /= 75;
- lba += 2;
- addr->msf.second = lba % 60;
- addr->msf.minute = lba / 60;
- } else
- addr->lba = lba;
-}
-
-static int
-linux_ioctl_cdrom(struct proc *p, struct linux_ioctl_args *args)
-{
- struct file *fp = p->p_fd->fd_ofiles[args->fd];
- int error;
-
- switch (args->cmd & 0xffff) {
-
- case LINUX_CDROMPAUSE:
- args->cmd = CDIOCPAUSE;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_CDROMRESUME:
- args->cmd = CDIOCRESUME;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_CDROMPLAYMSF:
- args->cmd = CDIOCPLAYMSF;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_CDROMPLAYTRKIND:
- args->cmd = CDIOCPLAYTRACKS;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_CDROMREADTOCHDR: {
- struct ioc_toc_header th;
- struct linux_cdrom_tochdr lth;
- error = fo_ioctl(fp, CDIOREADTOCHEADER, (caddr_t)&th, p);
- if (!error) {
- lth.cdth_trk0 = th.starting_track;
- lth.cdth_trk1 = th.ending_track;
- copyout(&lth, (caddr_t)args->arg, sizeof(lth));
- }
- return (error);
- }
-
- case LINUX_CDROMREADTOCENTRY: {
- struct linux_cdrom_tocentry lte, *ltep =
- (struct linux_cdrom_tocentry *)args->arg;
- struct ioc_read_toc_single_entry irtse;
- irtse.address_format = ltep->cdte_format;
- irtse.track = ltep->cdte_track;
- error = fo_ioctl(fp, CDIOREADTOCENTRY, (caddr_t)&irtse, p);
- if (!error) {
- lte = *ltep;
- lte.cdte_ctrl = irtse.entry.control;
- lte.cdte_adr = irtse.entry.addr_type;
- bsd_to_linux_msf_lba(irtse.address_format,
- &irtse.entry.addr, &lte.cdte_addr);
- copyout(&lte, (caddr_t)args->arg, sizeof(lte));
- }
- return (error);
- }
-
- case LINUX_CDROMSTOP:
- args->cmd = CDIOCSTOP;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_CDROMSTART:
- args->cmd = CDIOCSTART;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_CDROMEJECT:
- args->cmd = CDIOCEJECT;
- return (ioctl(p, (struct ioctl_args *)args));
-
- /* LINUX_CDROMVOLCTRL */
-
- case LINUX_CDROMSUBCHNL: {
- struct linux_cdrom_subchnl sc;
- struct ioc_read_subchannel bsdsc;
- struct cd_sub_channel_info *bsdinfo;
- caddr_t sg = stackgap_init();
- bsdinfo = (struct cd_sub_channel_info*)stackgap_alloc(&sg,
- sizeof(struct cd_sub_channel_info));
- bsdsc.address_format = CD_LBA_FORMAT;
- bsdsc.data_format = CD_CURRENT_POSITION;
- bsdsc.track = 0;
- bsdsc.data_len = sizeof(struct cd_sub_channel_info);
- bsdsc.data = bsdinfo;
- error = fo_ioctl(fp, CDIOCREADSUBCHANNEL, (caddr_t)&bsdsc, p);
- if (error)
- return (error);
- error = copyin((caddr_t)args->arg, &sc,
- sizeof(struct linux_cdrom_subchnl));
- if (error)
- return (error);
- sc.cdsc_audiostatus = bsdinfo->header.audio_status;
- sc.cdsc_adr = bsdinfo->what.position.addr_type;
- sc.cdsc_ctrl = bsdinfo->what.position.control;
- sc.cdsc_trk = bsdinfo->what.position.track_number;
- sc.cdsc_ind = bsdinfo->what.position.index_number;
- set_linux_cdrom_addr(&sc.cdsc_absaddr, sc.cdsc_format,
- bsdinfo->what.position.absaddr.lba);
- set_linux_cdrom_addr(&sc.cdsc_reladdr, sc.cdsc_format,
- bsdinfo->what.position.reladdr.lba);
- error = copyout(&sc, (caddr_t)args->arg,
- sizeof(struct linux_cdrom_subchnl));
- return (error);
- }
-
- /* LINUX_CDROMREADMODE2 */
- /* LINUX_CDROMREADMODE1 */
- /* LINUX_CDROMREADAUDIO */
- /* LINUX_CDROMEJECT_SW */
- /* LINUX_CDROMMULTISESSION */
- /* LINUX_CDROM_GET_UPC */
-
- case LINUX_CDROMRESET:
- args->cmd = CDIOCRESET;
- return (ioctl(p, (struct ioctl_args *)args));
-
- /* LINUX_CDROMVOLREAD */
- /* LINUX_CDROMREADRAW */
- /* LINUX_CDROMREADCOOKED */
- /* LINUX_CDROMSEEK */
- /* LINUX_CDROMPLAYBLK */
- /* LINUX_CDROMREADALL */
- /* LINUX_CDROMCLOSETRAY */
- /* LINUX_CDROMLOADFROMSLOT */
-
- }
-
- return (ENOIOCTL);
-}
-
-/*
- * Sound related ioctls
- */
-
-static unsigned dirbits[4] = { IOC_VOID, IOC_IN, IOC_OUT, IOC_INOUT };
-
-#define SETDIR(c) (((c) & ~IOC_DIRMASK) | dirbits[args->cmd >> 30])
-
-static int
-linux_ioctl_sound(struct proc *p, struct linux_ioctl_args *args)
-{
-
- switch (args->cmd & 0xffff) {
-
- case LINUX_SOUND_MIXER_WRITE_VOLUME:
- args->cmd = SETDIR(SOUND_MIXER_WRITE_VOLUME);
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SOUND_MIXER_WRITE_BASS:
- args->cmd = SETDIR(SOUND_MIXER_WRITE_BASS);
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SOUND_MIXER_WRITE_TREBLE:
- args->cmd = SETDIR(SOUND_MIXER_WRITE_TREBLE);
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SOUND_MIXER_WRITE_SYNTH:
- args->cmd = SETDIR(SOUND_MIXER_WRITE_SYNTH);
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SOUND_MIXER_WRITE_PCM:
- args->cmd = SETDIR(SOUND_MIXER_WRITE_PCM);
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SOUND_MIXER_WRITE_SPEAKER:
- args->cmd = SETDIR(SOUND_MIXER_WRITE_SPEAKER);
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SOUND_MIXER_WRITE_LINE:
- args->cmd = SETDIR(SOUND_MIXER_WRITE_LINE);
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SOUND_MIXER_WRITE_MIC:
- args->cmd = SETDIR(SOUND_MIXER_WRITE_MIC);
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SOUND_MIXER_WRITE_CD:
- args->cmd = SETDIR(SOUND_MIXER_WRITE_CD);
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SOUND_MIXER_WRITE_IMIX:
- args->cmd = SETDIR(SOUND_MIXER_WRITE_IMIX);
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SOUND_MIXER_WRITE_ALTPCM:
- args->cmd = SETDIR(SOUND_MIXER_WRITE_ALTPCM);
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SOUND_MIXER_WRITE_RECLEV:
- args->cmd = SETDIR(SOUND_MIXER_WRITE_RECLEV);
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SOUND_MIXER_WRITE_IGAIN:
- args->cmd = SETDIR(SOUND_MIXER_WRITE_IGAIN);
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SOUND_MIXER_WRITE_OGAIN:
- args->cmd = SETDIR(SOUND_MIXER_WRITE_OGAIN);
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SOUND_MIXER_WRITE_LINE1:
- args->cmd = SETDIR(SOUND_MIXER_WRITE_LINE1);
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SOUND_MIXER_WRITE_LINE2:
- args->cmd = SETDIR(SOUND_MIXER_WRITE_LINE2);
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SOUND_MIXER_WRITE_LINE3:
- args->cmd = SETDIR(SOUND_MIXER_WRITE_LINE3);
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_OSS_GETVERSION: {
- int version = linux_get_oss_version(p);
- return (copyout(&version, (caddr_t)args->arg, sizeof(int)));
- }
-
- case LINUX_SOUND_MIXER_READ_DEVMASK:
- args->cmd = SOUND_MIXER_READ_DEVMASK;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SNDCTL_DSP_RESET:
- args->cmd = SNDCTL_DSP_RESET;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SNDCTL_DSP_SYNC:
- args->cmd = SNDCTL_DSP_SYNC;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SNDCTL_DSP_SPEED:
- args->cmd = SNDCTL_DSP_SPEED;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SNDCTL_DSP_STEREO:
- args->cmd = SNDCTL_DSP_STEREO;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SNDCTL_DSP_GETBLKSIZE: /* LINUX_SNDCTL_DSP_SETBLKSIZE */
- args->cmd = SNDCTL_DSP_GETBLKSIZE;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SNDCTL_DSP_SETFMT:
- args->cmd = SNDCTL_DSP_SETFMT;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SOUND_PCM_WRITE_CHANNELS:
- args->cmd = SOUND_PCM_WRITE_CHANNELS;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SOUND_PCM_WRITE_FILTER:
- args->cmd = SOUND_PCM_WRITE_FILTER;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SNDCTL_DSP_POST:
- args->cmd = SNDCTL_DSP_POST;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SNDCTL_DSP_SUBDIVIDE:
- args->cmd = SNDCTL_DSP_SUBDIVIDE;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SNDCTL_DSP_SETFRAGMENT:
- args->cmd = SNDCTL_DSP_SETFRAGMENT;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SNDCTL_DSP_GETFMTS:
- args->cmd = SNDCTL_DSP_GETFMTS;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SNDCTL_DSP_GETOSPACE:
- args->cmd = SNDCTL_DSP_GETOSPACE;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SNDCTL_DSP_GETISPACE:
- args->cmd = SNDCTL_DSP_GETISPACE;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SNDCTL_DSP_NONBLOCK:
- args->cmd = SNDCTL_DSP_NONBLOCK;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SNDCTL_DSP_GETCAPS:
- args->cmd = SNDCTL_DSP_GETCAPS;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SNDCTL_DSP_SETTRIGGER: /* LINUX_SNDCTL_GETTRIGGER */
- args->cmd = SNDCTL_DSP_SETTRIGGER;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SNDCTL_DSP_GETIPTR:
- args->cmd = SNDCTL_DSP_GETIPTR;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SNDCTL_DSP_GETOPTR:
- args->cmd = SNDCTL_DSP_GETOPTR;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SNDCTL_DSP_GETODELAY:
- args->cmd = SNDCTL_DSP_GETODELAY;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SNDCTL_SEQ_RESET:
- args->cmd = SNDCTL_SEQ_RESET;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SNDCTL_SEQ_SYNC:
- args->cmd = SNDCTL_SEQ_SYNC;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SNDCTL_SYNTH_INFO:
- args->cmd = SNDCTL_SYNTH_INFO;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SNDCTL_SEQ_CTRLRATE:
- args->cmd = SNDCTL_SEQ_CTRLRATE;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SNDCTL_SEQ_GETOUTCOUNT:
- args->cmd = SNDCTL_SEQ_GETOUTCOUNT;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SNDCTL_SEQ_GETINCOUNT:
- args->cmd = SNDCTL_SEQ_GETINCOUNT;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SNDCTL_SEQ_PERCMODE:
- args->cmd = SNDCTL_SEQ_PERCMODE;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SNDCTL_FM_LOAD_INSTR:
- args->cmd = SNDCTL_FM_LOAD_INSTR;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SNDCTL_SEQ_TESTMIDI:
- args->cmd = SNDCTL_SEQ_TESTMIDI;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SNDCTL_SEQ_RESETSAMPLES:
- args->cmd = SNDCTL_SEQ_RESETSAMPLES;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SNDCTL_SEQ_NRSYNTHS:
- args->cmd = SNDCTL_SEQ_NRSYNTHS;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SNDCTL_SEQ_NRMIDIS:
- args->cmd = SNDCTL_SEQ_NRMIDIS;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SNDCTL_MIDI_INFO:
- args->cmd = SNDCTL_MIDI_INFO;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SNDCTL_SEQ_TRESHOLD:
- args->cmd = SNDCTL_SEQ_TRESHOLD;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SNDCTL_SYNTH_MEMAVL:
- args->cmd = SNDCTL_SYNTH_MEMAVL;
- return (ioctl(p, (struct ioctl_args *)args));
-
- }
-
- return (ENOIOCTL);
-}
-
-/*
- * Console related ioctls
- */
-
-#define ISSIGVALID(sig) ((sig) > 0 && (sig) < NSIG)
-
-static int
-linux_ioctl_console(struct proc *p, struct linux_ioctl_args *args)
-{
- struct file *fp = p->p_fd->fd_ofiles[args->fd];
-
- switch (args->cmd & 0xffff) {
-
- case LINUX_KIOCSOUND:
- args->cmd = KIOCSOUND;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_KDMKTONE:
- args->cmd = KDMKTONE;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_KDGETLED:
- args->cmd = KDGETLED;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_KDSETLED:
- args->cmd = KDSETLED;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_KDSETMODE:
- args->cmd = KDSETMODE;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_KDGETMODE:
- args->cmd = KDGETMODE;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_KDGKBMODE:
- args->cmd = KDGKBMODE;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_KDSKBMODE: {
- int kbdmode;
- switch (args->arg) {
- case LINUX_KBD_RAW:
- kbdmode = K_RAW;
- break;
- case LINUX_KBD_XLATE:
- kbdmode = K_XLATE;
- break;
- case LINUX_KBD_MEDIUMRAW:
- kbdmode = K_RAW;
- break;
- default:
- return (EINVAL);
- }
- return (fo_ioctl(fp, KDSKBMODE, (caddr_t)&kbdmode, p));
- }
-
- case LINUX_VT_OPENQRY:
- args->cmd = VT_OPENQRY;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_VT_GETMODE:
- args->cmd = VT_GETMODE;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_VT_SETMODE: {
- struct vt_mode *mode;
- args->cmd = VT_SETMODE;
- mode = (struct vt_mode *)args->arg;
- if (!ISSIGVALID(mode->frsig) && ISSIGVALID(mode->acqsig))
- mode->frsig = mode->acqsig;
- return (ioctl(p, (struct ioctl_args *)args));
- }
-
- case LINUX_VT_GETSTATE:
- args->cmd = VT_GETACTIVE;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_VT_RELDISP:
- args->cmd = VT_RELDISP;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_VT_ACTIVATE:
- args->cmd = VT_ACTIVATE;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_VT_WAITACTIVE:
- args->cmd = VT_WAITACTIVE;
- return (ioctl(p, (struct ioctl_args *)args));
-
- }
-
- return (ENOIOCTL);
-}
-
-/*
- * Socket related ioctls
- */
-
-static int
-linux_ioctl_socket(struct proc *p, struct linux_ioctl_args *args)
-{
-
- switch (args->cmd & 0xffff) {
-
- case LINUX_FIOSETOWN:
- args->cmd = FIOSETOWN;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SIOCSPGRP:
- args->cmd = SIOCSPGRP;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_FIOGETOWN:
- args->cmd = FIOGETOWN;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SIOCGPGRP:
- args->cmd = SIOCGPGRP;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SIOCATMARK:
- args->cmd = SIOCATMARK;
- return (ioctl(p, (struct ioctl_args *)args));
-
- /* LINUX_SIOCGSTAMP */
-
- case LINUX_SIOCGIFCONF:
- args->cmd = OSIOCGIFCONF;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SIOCGIFFLAGS:
- args->cmd = SIOCGIFFLAGS;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SIOCGIFADDR:
- args->cmd = OSIOCGIFADDR;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SIOCGIFDSTADDR:
- args->cmd = OSIOCGIFDSTADDR;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SIOCGIFBRDADDR:
- args->cmd = OSIOCGIFBRDADDR;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SIOCGIFNETMASK:
- args->cmd = OSIOCGIFNETMASK;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SIOCGIFHWADDR: {
- int ifn;
- struct ifnet *ifp;
- struct ifaddr *ifa;
- struct sockaddr_dl *sdl;
- struct linux_ifreq *ifr = (struct linux_ifreq *)args->arg;
-
- /* Note that we don't actually respect the name in the ifreq
- * structure, as Linux interface names are all different.
- */
- for (ifn = 0; ifn < if_index; ifn++) {
- ifp = ifnet_addrs[ifn]->ifa_ifp;
- if (ifp->if_type == IFT_ETHER) {
- ifa = TAILQ_FIRST(&ifp->if_addrhead);
- while (ifa) {
- sdl=(struct sockaddr_dl*)ifa->ifa_addr;
- if (sdl != NULL &&
- (sdl->sdl_family == AF_LINK) &&
- (sdl->sdl_type == IFT_ETHER)) {
- return (copyout(LLADDR(sdl),
- &ifr->ifr_hwaddr.sa_data,
- LINUX_IFHWADDRLEN));
- }
- ifa = TAILQ_NEXT(ifa, ifa_link);
- }
- }
- }
- return (ENOENT);
- }
-
- case LINUX_SIOCADDMULTI:
- args->cmd = SIOCADDMULTI;
- return (ioctl(p, (struct ioctl_args *)args));
-
- case LINUX_SIOCDELMULTI:
- args->cmd = SIOCDELMULTI;
- return (ioctl(p, (struct ioctl_args *)args));
-
- }
-
- return (ENOIOCTL);
-}
-
-/*
- * main ioctl syscall function
- */
-
-int
-linux_ioctl(struct proc *p, struct linux_ioctl_args *args)
-{
- struct filedesc *fdp = p->p_fd;
- struct file *fp;
- struct handler_element *he;
- int error, cmd;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): ioctl(%d, %04lx, *)\n", (long)p->p_pid,
- args->fd, args->cmd);
-#endif
-
- if ((unsigned)args->fd >= fdp->fd_nfiles)
- return (EBADF);
-
- fp = fdp->fd_ofiles[args->fd];
- if (fp == NULL || (fp->f_flag & (FREAD|FWRITE)) == 0)
- return (EBADF);
-
- /* Iterate over the ioctl handlers */
- cmd = args->cmd & 0xffff;
- TAILQ_FOREACH(he, &handlers, list) {
- if (cmd >= he->low && cmd <= he->high) {
- error = (*he->func)(p, args);
- if (error != ENOIOCTL)
- return (error);
- }
- }
-
- printf("linux: 'ioctl' fd=%d, cmd=%x ('%c',%d) not implemented\n",
- args->fd, (int)(args->cmd & 0xffff),
- (int)(args->cmd & 0xff00) >> 8, (int)(args->cmd & 0xff));
-
- return (EINVAL);
-}
-
-int
-linux_ioctl_register_handler(struct linux_ioctl_handler *h)
-{
- struct handler_element *he, *cur;
-
- if (h == NULL || h->func == NULL)
- return (EINVAL);
-
- /*
- * Reuse the element if the handler is already on the list, otherwise
- * create a new element.
- */
- TAILQ_FOREACH(he, &handlers, list) {
- if (he->func == h->func)
- break;
- }
- if (he == NULL) {
- MALLOC(he, struct handler_element *, sizeof(*he),
- M_LINUX, M_WAITOK);
- he->func = h->func;
- } else
- TAILQ_REMOVE(&handlers, he, list);
-
- /* Initialize range information. */
- he->low = h->low;
- he->high = h->high;
- he->span = h->high - h->low + 1;
-
- /* Add the element to the list, sorted on span. */
- TAILQ_FOREACH(cur, &handlers, list) {
- if (cur->span > he->span) {
- TAILQ_INSERT_BEFORE(cur, he, list);
- return (0);
- }
- }
- TAILQ_INSERT_TAIL(&handlers, he, list);
-
- return (0);
-}
-
-int
-linux_ioctl_unregister_handler(struct linux_ioctl_handler *h)
-{
- struct handler_element *he;
-
- if (h == NULL || h->func == NULL)
- return (EINVAL);
-
- TAILQ_FOREACH(he, &handlers, list) {
- if (he->func == h->func) {
- TAILQ_REMOVE(&handlers, he, list);
- FREE(he, M_LINUX);
- return (0);
- }
- }
-
- return (EINVAL);
-}
-
-int
-linux_ioctl_register_handlers(struct linker_set *s)
-{
- int error, i;
-
- if (s == NULL)
- return (EINVAL);
-
- for (i = 0; i < s->ls_length; i++) {
- error = linux_ioctl_register_handler(s->ls_items[i]);
- if (error)
- return (error);
- }
-
- return (0);
-}
-
-int
-linux_ioctl_unregister_handlers(struct linker_set *s)
-{
- int error, i;
-
- if (s == NULL)
- return (EINVAL);
-
- for (i = 0; i < s->ls_length; i++) {
- error = linux_ioctl_unregister_handler(s->ls_items[i]);
- if (error)
- return (error);
- }
-
- return (0);
-}
diff --git a/sys/compat/linux/linux_ioctl.h b/sys/compat/linux/linux_ioctl.h
deleted file mode 100644
index 1ed49012547f..000000000000
--- a/sys/compat/linux/linux_ioctl.h
+++ /dev/null
@@ -1,437 +0,0 @@
-/*-
- * Copyright (c) 1999 Marcel Moolenaar
- * 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
- * in this position and unchanged.
- * 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 withough 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _LINUX_IOCTL_H_
-#define _LINUX_IOCTL_H_
-
-/*
- * disk
- */
-#define LINUX_BLKROSET 0x125d
-#define LINUX_BLKROGET 0x125e
-#define LINUX_BLKRRPART 0x125f
-#define LINUX_BLKGETSIZE 0x1260
-#define LINUX_BLKFLSBUF 0x1261
-#define LINUX_BLKRASET 0x1262
-#define LINUX_BLKRAGET 0x1263
-#define LINUX_BLKFRASET 0x1264
-#define LINUX_BLKFRAGET 0x1265
-#define LINUX_BLKSECTSET 0x1266
-#define LINUX_BLKSECTGET 0x1267
-#define LINUX_BLKSSZGET 0x1268
-
-#define LINUX_IOCTL_DISK_MIN LINUX_BLKROSET
-#define LINUX_IOCTL_DISK_MAX LINUX_BLKSSZGET
-
-/*
- * cdrom
- */
-#define LINUX_CDROMPAUSE 0x5301
-#define LINUX_CDROMRESUME 0x5302
-#define LINUX_CDROMPLAYMSF 0x5303
-#define LINUX_CDROMPLAYTRKIND 0x5304
-#define LINUX_CDROMREADTOCHDR 0x5305
-#define LINUX_CDROMREADTOCENTRY 0x5306
-#define LINUX_CDROMSTOP 0x5307
-#define LINUX_CDROMSTART 0x5308
-#define LINUX_CDROMEJECT 0x5309
-#define LINUX_CDROMVOLCTRL 0x530a
-#define LINUX_CDROMSUBCHNL 0x530b
-#define LINUX_CDROMREADMODE2 0x530c
-#define LINUX_CDROMREADMODE1 0x530d
-#define LINUX_CDROMREADAUDIO 0x530e
-#define LINUX_CDROMEJECT_SW 0x530f
-#define LINUX_CDROMMULTISESSION 0x5310
-#define LINUX_CDROM_GET_UPC 0x5311
-#define LINUX_CDROMRESET 0x5312
-#define LINUX_CDROMVOLREAD 0x5313
-#define LINUX_CDROMREADRAW 0x5314
-#define LINUX_CDROMREADCOOKED 0x5315
-#define LINUX_CDROMSEEK 0x5316
-#define LINUX_CDROMPLAYBLK 0x5317
-#define LINUX_CDROMREADALL 0x5318
-#define LINUX_CDROMCLOSETRAY 0x5319
-#define LINUX_CDROMLOADFROMSLOT 0x531a
-
-#define LINUX_IOCTL_CDROM_MIN LINUX_CDROMPAUSE
-#define LINUX_IOCTL_CDROM_MAX LINUX_CDROMLOADFROMSLOT
-
-#define LINUX_CDROM_LBA 0x01
-#define LINUX_CDROM_MSF 0x02
-
-/*
- * console
- */
-#define LINUX_KIOCSOUND 0x4B2F
-#define LINUX_KDMKTONE 0x4B30
-#define LINUX_KDGETLED 0x4B31
-#define LINUX_KDSETLED 0x4B32
-#define LINUX_KDSETMODE 0x4B3A
-#define LINUX_KDGETMODE 0x4B3B
-#define LINUX_KDGKBMODE 0x4B44
-#define LINUX_KDSKBMODE 0x4B45
-#define LINUX_VT_OPENQRY 0x5600
-#define LINUX_VT_GETMODE 0x5601
-#define LINUX_VT_SETMODE 0x5602
-#define LINUX_VT_GETSTATE 0x5603
-#define LINUX_VT_RELDISP 0x5605
-#define LINUX_VT_ACTIVATE 0x5606
-#define LINUX_VT_WAITACTIVE 0x5607
-
-#define LINUX_IOCTL_CONSOLE_MIN LINUX_KIOCSOUND
-#define LINUX_IOCTL_CONSOLE_MAX LINUX_VT_WAITACTIVE
-
-#define LINUX_LED_SCR 0x01
-#define LINUX_LED_NUM 0x02
-#define LINUX_LED_CAP 0x04
-
-#define LINUX_KD_TEXT 0x0
-#define LINUX_KD_GRAPHICS 0x1
-#define LINUX_KD_TEXT0 0x2
-#define LINUX_KD_TEXT1 0x3
-
-#define LINUX_KBD_RAW 0
-#define LINUX_KBD_XLATE 1
-#define LINUX_KBD_MEDIUMRAW 2
-
-/*
- * socket
- */
-#define LINUX_FIOSETOWN 0x8901
-#define LINUX_SIOCSPGRP 0x8902
-#define LINUX_FIOGETOWN 0x8903
-#define LINUX_SIOCGPGRP 0x8904
-#define LINUX_SIOCATMARK 0x8905
-#define LINUX_SIOCGSTAMP 0x8906
-#define LINUX_SIOCGIFCONF 0x8912
-#define LINUX_SIOCGIFFLAGS 0x8913
-#define LINUX_SIOCGIFADDR 0x8915
-#define LINUX_SIOCGIFDSTADDR 0x8917
-#define LINUX_SIOCGIFBRDADDR 0x8919
-#define LINUX_SIOCGIFNETMASK 0x891b
-#define LINUX_SIOCGIFHWADDR 0x8927
-#define LINUX_SIOCADDMULTI 0x8931
-#define LINUX_SIOCDELMULTI 0x8932
-
-#define LINUX_IOCTL_SOCKET_MIN LINUX_FIOSETOWN
-#define LINUX_IOCTL_SOCKET_MAX LINUX_SIOCDELMULTI
-
-/*
- * sound
- */
-#define LINUX_SOUND_MIXER_WRITE_VOLUME 0x4d00
-#define LINUX_SOUND_MIXER_WRITE_BASS 0x4d01
-#define LINUX_SOUND_MIXER_WRITE_TREBLE 0x4d02
-#define LINUX_SOUND_MIXER_WRITE_SYNTH 0x4d03
-#define LINUX_SOUND_MIXER_WRITE_PCM 0x4d04
-#define LINUX_SOUND_MIXER_WRITE_SPEAKER 0x4d05
-#define LINUX_SOUND_MIXER_WRITE_LINE 0x4d06
-#define LINUX_SOUND_MIXER_WRITE_MIC 0x4d07
-#define LINUX_SOUND_MIXER_WRITE_CD 0x4d08
-#define LINUX_SOUND_MIXER_WRITE_IMIX 0x4d09
-#define LINUX_SOUND_MIXER_WRITE_ALTPCM 0x4d0A
-#define LINUX_SOUND_MIXER_WRITE_RECLEV 0x4d0B
-#define LINUX_SOUND_MIXER_WRITE_IGAIN 0x4d0C
-#define LINUX_SOUND_MIXER_WRITE_OGAIN 0x4d0D
-#define LINUX_SOUND_MIXER_WRITE_LINE1 0x4d0E
-#define LINUX_SOUND_MIXER_WRITE_LINE2 0x4d0F
-#define LINUX_SOUND_MIXER_WRITE_LINE3 0x4d10
-#define LINUX_OSS_GETVERSION 0x4d76
-#define LINUX_SOUND_MIXER_READ_DEVMASK 0x4dfe
-#define LINUX_SNDCTL_DSP_RESET 0x5000
-#define LINUX_SNDCTL_DSP_SYNC 0x5001
-#define LINUX_SNDCTL_DSP_SPEED 0x5002
-#define LINUX_SNDCTL_DSP_STEREO 0x5003
-#define LINUX_SNDCTL_DSP_GETBLKSIZE 0x5004
-#define LINUX_SNDCTL_DSP_SETBLKSIZE LINUX_SNDCTL_DSP_GETBLKSIZE
-#define LINUX_SNDCTL_DSP_SETFMT 0x5005
-#define LINUX_SOUND_PCM_WRITE_CHANNELS 0x5006
-#define LINUX_SOUND_PCM_WRITE_FILTER 0x5007
-#define LINUX_SNDCTL_DSP_POST 0x5008
-#define LINUX_SNDCTL_DSP_SUBDIVIDE 0x5009
-#define LINUX_SNDCTL_DSP_SETFRAGMENT 0x500A
-#define LINUX_SNDCTL_DSP_GETFMTS 0x500B
-#define LINUX_SNDCTL_DSP_GETOSPACE 0x500C
-#define LINUX_SNDCTL_DSP_GETISPACE 0x500D
-#define LINUX_SNDCTL_DSP_NONBLOCK 0x500E
-#define LINUX_SNDCTL_DSP_GETCAPS 0x500F
-#define LINUX_SNDCTL_DSP_GETTRIGGER 0x5010
-#define LINUX_SNDCTL_DSP_SETTRIGGER LINUX_SNDCTL_DSP_GETTRIGGER
-#define LINUX_SNDCTL_DSP_GETIPTR 0x5011
-#define LINUX_SNDCTL_DSP_GETOPTR 0x5012
-#define LINUX_SNDCTL_DSP_GETODELAY 0x5017
-#define LINUX_SNDCTL_SEQ_RESET 0x5100
-#define LINUX_SNDCTL_SEQ_SYNC 0x5101
-#define LINUX_SNDCTL_SYNTH_INFO 0x5102
-#define LINUX_SNDCTL_SEQ_CTRLRATE 0x5103
-#define LINUX_SNDCTL_SEQ_GETOUTCOUNT 0x5104
-#define LINUX_SNDCTL_SEQ_GETINCOUNT 0x5105
-#define LINUX_SNDCTL_SEQ_PERCMODE 0x5106
-#define LINUX_SNDCTL_FM_LOAD_INSTR 0x5107
-#define LINUX_SNDCTL_SEQ_TESTMIDI 0x5108
-#define LINUX_SNDCTL_SEQ_RESETSAMPLES 0x5109
-#define LINUX_SNDCTL_SEQ_NRSYNTHS 0x510A
-#define LINUX_SNDCTL_SEQ_NRMIDIS 0x510B
-#define LINUX_SNDCTL_MIDI_INFO 0x510C
-#define LINUX_SNDCTL_SEQ_TRESHOLD 0x510D
-#define LINUX_SNDCTL_SYNTH_MEMAVL 0x510E
-
-#define LINUX_IOCTL_SOUND_MIN LINUX_SOUND_MIXER_WRITE_VOLUME
-#define LINUX_IOCTL_SOUND_MAX LINUX_SNDCTL_SYNTH_MEMAVL
-
-/*
- * termio
- */
-#define LINUX_TCGETS 0x5401
-#define LINUX_TCSETS 0x5402
-#define LINUX_TCSETSW 0x5403
-#define LINUX_TCSETSF 0x5404
-#define LINUX_TCGETA 0x5405
-#define LINUX_TCSETA 0x5406
-#define LINUX_TCSETAW 0x5407
-#define LINUX_TCSETAF 0x5408
-#define LINUX_TCSBRK 0x5409
-#define LINUX_TCXONC 0x540A
-#define LINUX_TCFLSH 0x540B
-#define LINUX_TIOCEXCL 0x540C
-#define LINUX_TIOCNXCL 0x540D
-#define LINUX_TIOCSCTTY 0x540E
-#define LINUX_TIOCGPGRP 0x540F
-#define LINUX_TIOCSPGRP 0x5410
-#define LINUX_TIOCOUTQ 0x5411
-#define LINUX_TIOCSTI 0x5412
-#define LINUX_TIOCGWINSZ 0x5413
-#define LINUX_TIOCSWINSZ 0x5414
-#define LINUX_TIOCMGET 0x5415
-#define LINUX_TIOCMBIS 0x5416
-#define LINUX_TIOCMBIC 0x5417
-#define LINUX_TIOCMSET 0x5418
-#define LINUX_TIOCGSOFTCAR 0x5419
-#define LINUX_TIOCSSOFTCAR 0x541A
-#define LINUX_FIONREAD 0x541B
-#define LINUX_TIOCINQ FIONREAD
-#define LINUX_TIOCLINUX 0x541C
-#define LINUX_TIOCCONS 0x541D
-#define LINUX_TIOCGSERIAL 0x541E
-#define LINUX_TIOCSSERIAL 0x541F
-#define LINUX_TIOCPKT 0x5420
-#define LINUX_FIONBIO 0x5421
-#define LINUX_TIOCNOTTY 0x5422
-#define LINUX_TIOCSETD 0x5423
-#define LINUX_TIOCGETD 0x5424
-#define LINUX_TCSBRKP 0x5425
-#define LINUX_TIOCTTYGSTRUCT 0x5426
-#define LINUX_FIONCLEX 0x5450
-#define LINUX_FIOCLEX 0x5451
-#define LINUX_FIOASYNC 0x5452
-#define LINUX_TIOCSERCONFIG 0x5453
-#define LINUX_TIOCSERGWILD 0x5454
-#define LINUX_TIOCSERSWILD 0x5455
-#define LINUX_TIOCGLCKTRMIOS 0x5456
-#define LINUX_TIOCSLCKTRMIOS 0x5457
-
-#define LINUX_IOCTL_TERMIO_MIN LINUX_TCGETS
-#define LINUX_IOCTL_TERMIO_MAX LINUX_TIOCSLCKTRMIOS
-
-/* arguments for tcflow() and LINUX_TCXONC */
-#define LINUX_TCOOFF 0
-#define LINUX_TCOON 1
-#define LINUX_TCIOFF 2
-#define LINUX_TCION 3
-
-/* arguments for tcflush() and LINUX_TCFLSH */
-#define LINUX_TCIFLUSH 0
-#define LINUX_TCOFLUSH 1
-#define LINUX_TCIOFLUSH 2
-
-/* line disciplines */
-#define LINUX_N_TTY 0
-#define LINUX_N_SLIP 1
-#define LINUX_N_MOUSE 2
-#define LINUX_N_PPP 3
-
-/* Linux termio c_cc values */
-#define LINUX_VINTR 0
-#define LINUX_VQUIT 1
-#define LINUX_VERASE 2
-#define LINUX_VKILL 3
-#define LINUX_VEOF 4
-#define LINUX_VTIME 5
-#define LINUX_VMIN 6
-#define LINUX_VSWTC 7
-#define LINUX_NCC 8
-
-/* Linux termios c_cc values */
-#define LINUX_VSTART 8
-#define LINUX_VSTOP 9
-#define LINUX_VSUSP 10
-#define LINUX_VEOL 11
-#define LINUX_VREPRINT 12
-#define LINUX_VDISCARD 13
-#define LINUX_VWERASE 14
-#define LINUX_VLNEXT 15
-#define LINUX_VEOL2 16
-#define LINUX_NCCS 19
-
-#define LINUX_POSIX_VDISABLE '\0'
-
-/* Linux c_iflag masks */
-#define LINUX_IGNBRK 0x0000001
-#define LINUX_BRKINT 0x0000002
-#define LINUX_IGNPAR 0x0000004
-#define LINUX_PARMRK 0x0000008
-#define LINUX_INPCK 0x0000010
-#define LINUX_ISTRIP 0x0000020
-#define LINUX_INLCR 0x0000040
-#define LINUX_IGNCR 0x0000080
-#define LINUX_ICRNL 0x0000100
-#define LINUX_IUCLC 0x0000200
-#define LINUX_IXON 0x0000400
-#define LINUX_IXANY 0x0000800
-#define LINUX_IXOFF 0x0001000
-#define LINUX_IMAXBEL 0x0002000
-
-/* Linux c_oflag masks */
-#define LINUX_OPOST 0x0000001
-#define LINUX_OLCUC 0x0000002
-#define LINUX_ONLCR 0x0000004
-#define LINUX_OCRNL 0x0000008
-#define LINUX_ONOCR 0x0000010
-#define LINUX_ONLRET 0x0000020
-#define LINUX_OFILL 0x0000040
-#define LINUX_OFDEL 0x0000080
-#define LINUX_NLDLY 0x0000100
-
-#define LINUX_NL0 0x0000000
-#define LINUX_NL1 0x0000100
-#define LINUX_CRDLY 0x0000600
-#define LINUX_CR0 0x0000000
-#define LINUX_CR1 0x0000200
-#define LINUX_CR2 0x0000400
-#define LINUX_CR3 0x0000600
-#define LINUX_TABDLY 0x0001800
-#define LINUX_TAB0 0x0000000
-#define LINUX_TAB1 0x0000800
-#define LINUX_TAB2 0x0001000
-#define LINUX_TAB3 0x0001800
-#define LINUX_XTABS 0x0001800
-#define LINUX_BSDLY 0x0002000
-#define LINUX_BS0 0x0000000
-#define LINUX_BS1 0x0002000
-#define LINUX_VTDLY 0x0004000
-#define LINUX_VT0 0x0000000
-#define LINUX_VT1 0x0004000
-#define LINUX_FFDLY 0x0008000
-#define LINUX_FF0 0x0000000
-#define LINUX_FF1 0x0008000
-
-#define LINUX_CBAUD 0x0000100f
-#define LINUX_B0 0x00000000
-#define LINUX_B50 0x00000001
-#define LINUX_B75 0x00000002
-#define LINUX_B110 0x00000003
-#define LINUX_B134 0x00000004
-#define LINUX_B150 0x00000005
-#define LINUX_B200 0x00000006
-#define LINUX_B300 0x00000007
-#define LINUX_B600 0x00000008
-#define LINUX_B1200 0x00000009
-#define LINUX_B1800 0x0000000a
-#define LINUX_B2400 0x0000000b
-#define LINUX_B4800 0x0000000c
-#define LINUX_B9600 0x0000000d
-#define LINUX_B19200 0x0000000e
-#define LINUX_B38400 0x0000000f
-#define LINUX_EXTA LINUX_B19200
-#define LINUX_EXTB LINUX_B38400
-#define LINUX_CBAUDEX 0x00001000
-#define LINUX_B57600 0x00001001
-#define LINUX_B115200 0x00001002
-
-#define LINUX_CSIZE 0x00000030
-#define LINUX_CS5 0x00000000
-#define LINUX_CS6 0x00000010
-#define LINUX_CS7 0x00000020
-#define LINUX_CS8 0x00000030
-#define LINUX_CSTOPB 0x00000040
-#define LINUX_CREAD 0x00000080
-#define LINUX_PARENB 0x00000100
-#define LINUX_PARODD 0x00000200
-#define LINUX_HUPCL 0x00000400
-#define LINUX_CLOCAL 0x00000800
-#define LINUX_CRTSCTS 0x80000000
-
-/* Linux c_lflag masks */
-#define LINUX_ISIG 0x00000001
-#define LINUX_ICANON 0x00000002
-#define LINUX_XCASE 0x00000004
-#define LINUX_ECHO 0x00000008
-#define LINUX_ECHOE 0x00000010
-#define LINUX_ECHOK 0x00000020
-#define LINUX_ECHONL 0x00000040
-#define LINUX_NOFLSH 0x00000080
-#define LINUX_TOSTOP 0x00000100
-#define LINUX_ECHOCTL 0x00000200
-#define LINUX_ECHOPRT 0x00000400
-#define LINUX_ECHOKE 0x00000800
-#define LINUX_FLUSHO 0x00001000
-#define LINUX_PENDIN 0x00002000
-#define LINUX_IEXTEN 0x00008000
-
-/* serial_struct values for TIOC[GS]SERIAL ioctls */
-#define LINUX_ASYNC_CLOSING_WAIT_INF 0
-#define LINUX_ASYNC_CLOSING_WAIT_NONE 65535
-
-#define LINUX_PORT_UNKNOWN 0
-#define LINUX_PORT_8250 1
-#define LINUX_PORT_16450 2
-#define LINUX_PORT_16550 3
-#define LINUX_PORT_16550A 4
-#define LINUX_PORT_CIRRUS 5
-#define LINUX_PORT_16650 6
-
-#define LINUX_PORT_MAX 6
-
-#define LINUX_ASYNC_HUP_NOTIFY 0x0001
-#define LINUX_ASYNC_FOURPORT 0x0002
-#define LINUX_ASYNC_SAK 0x0004
-#define LINUX_ASYNC_SPLIT_TERMIOS 0x0008
-#define LINUX_ASYNC_SPD_MASK 0x0030
-#define LINUX_ASYNC_SPD_HI 0x0010
-#define LINUX_ASYNC_SPD_VHI 0x0020
-#define LINUX_ASYNC_SPD_CUST 0x0030
-#define LINUX_ASYNC_SKIP_TEST 0x0040
-#define LINUX_ASYNC_AUTO_IRQ 0x0080
-#define LINUX_ASYNC_SESSION_LOCKOUT 0x0100
-#define LINUX_ASYNC_PGRP_LOCKOUT 0x0200
-#define LINUX_ASYNC_CALLOUT_NOHUP 0x0400
-#define LINUX_ASYNC_FLAGS 0x0FFF
-
-#endif /* !_LINUX_IOCTL_H_ */
diff --git a/sys/compat/linux/linux_ipc.c b/sys/compat/linux/linux_ipc.c
deleted file mode 100644
index 0428702d045e..000000000000
--- a/sys/compat/linux/linux_ipc.c
+++ /dev/null
@@ -1,490 +0,0 @@
-/*-
- * Copyright (c) 1994-1995 Søren Schmidt
- * 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
- * in this position and unchanged.
- * 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 withough 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.
- *
- * $FreeBSD$
- */
-
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/sysproto.h>
-#include <sys/proc.h>
-#include <sys/sem.h>
-#include <sys/shm.h>
-
-#include <i386/linux/linux.h>
-#include <i386/linux/linux_proto.h>
-#include <i386/linux/linux_util.h>
-
-static int linux_semop __P((struct proc *, struct linux_ipc_args *));
-static int linux_semget __P((struct proc *, struct linux_ipc_args *));
-static int linux_semctl __P((struct proc *, struct linux_ipc_args *));
-static int linux_msgsnd __P((struct proc *, struct linux_ipc_args *));
-static int linux_msgrcv __P((struct proc *, struct linux_ipc_args *));
-static int linux_msgctl __P((struct proc *, struct linux_ipc_args *));
-static int linux_shmat __P((struct proc *, struct linux_ipc_args *));
-static int linux_shmdt __P((struct proc *, struct linux_ipc_args *));
-static int linux_shmget __P((struct proc *, struct linux_ipc_args *));
-static int linux_shmctl __P((struct proc *, struct linux_ipc_args *));
-
-struct linux_ipc_perm {
- linux_key_t key;
- unsigned short uid;
- unsigned short gid;
- unsigned short cuid;
- unsigned short cgid;
- unsigned short mode;
- unsigned short seq;
-};
-
-static void
-linux_to_bsd_ipc_perm(struct linux_ipc_perm *lpp, struct ipc_perm *bpp)
-{
- bpp->key = lpp->key;
- bpp->uid = lpp->uid;
- bpp->gid = lpp->gid;
- bpp->cuid = lpp->cuid;
- bpp->cgid = lpp->cgid;
- bpp->mode = lpp->mode;
- bpp->seq = lpp->seq;
-}
-
-
-static void
-bsd_to_linux_ipc_perm(struct ipc_perm *bpp, struct linux_ipc_perm *lpp)
-{
- lpp->key = bpp->key;
- lpp->uid = bpp->uid;
- lpp->gid = bpp->gid;
- lpp->cuid = bpp->cuid;
- lpp->cgid = bpp->cgid;
- lpp->mode = bpp->mode;
- lpp->seq = bpp->seq;
-}
-
-struct linux_semid_ds {
- struct linux_ipc_perm sem_perm;
- linux_time_t sem_otime;
- linux_time_t sem_ctime;
- void *sem_base;
- void *sem_pending;
- void *sem_pending_last;
- void *undo;
- ushort sem_nsems;
-};
-
-struct linux_shmid_ds {
- struct linux_ipc_perm shm_perm;
- int shm_segsz;
- linux_time_t shm_atime;
- linux_time_t shm_dtime;
- linux_time_t shm_ctime;
- ushort shm_cpid;
- ushort shm_lpid;
- short shm_nattch;
- ushort private1;
- void *private2;
- void *private3;
-};
-
-static void
-linux_to_bsd_semid_ds(struct linux_semid_ds *lsp, struct semid_ds *bsp)
-{
- linux_to_bsd_ipc_perm(&lsp->sem_perm, &bsp->sem_perm);
- bsp->sem_otime = lsp->sem_otime;
- bsp->sem_ctime = lsp->sem_ctime;
- bsp->sem_nsems = lsp->sem_nsems;
- bsp->sem_base = lsp->sem_base;
-}
-
-static void
-bsd_to_linux_semid_ds(struct semid_ds *bsp, struct linux_semid_ds *lsp)
-{
- bsd_to_linux_ipc_perm(&bsp->sem_perm, &lsp->sem_perm);
- lsp->sem_otime = bsp->sem_otime;
- lsp->sem_ctime = bsp->sem_ctime;
- lsp->sem_nsems = bsp->sem_nsems;
- lsp->sem_base = bsp->sem_base;
-}
-
-static void
-linux_to_bsd_shmid_ds(struct linux_shmid_ds *lsp, struct shmid_ds *bsp)
-{
- linux_to_bsd_ipc_perm(&lsp->shm_perm, &bsp->shm_perm);
- bsp->shm_segsz = lsp->shm_segsz;
- bsp->shm_lpid = lsp->shm_lpid;
- bsp->shm_cpid = lsp->shm_cpid;
- bsp->shm_nattch = lsp->shm_nattch;
- bsp->shm_atime = lsp->shm_atime;
- bsp->shm_dtime = lsp->shm_dtime;
- bsp->shm_ctime = lsp->shm_ctime;
- bsp->shm_internal = lsp->private3; /* this goes (yet) SOS */
-}
-
-static void
-bsd_to_linux_shmid_ds(struct shmid_ds *bsp, struct linux_shmid_ds *lsp)
-{
- bsd_to_linux_ipc_perm(&bsp->shm_perm, &lsp->shm_perm);
- lsp->shm_segsz = bsp->shm_segsz;
- lsp->shm_lpid = bsp->shm_lpid;
- lsp->shm_cpid = bsp->shm_cpid;
- lsp->shm_nattch = bsp->shm_nattch;
- lsp->shm_atime = bsp->shm_atime;
- lsp->shm_dtime = bsp->shm_dtime;
- lsp->shm_ctime = bsp->shm_ctime;
- lsp->private3 = bsp->shm_internal; /* this goes (yet) SOS */
-}
-
-static int
-linux_semop(struct proc *p, struct linux_ipc_args *args)
-{
- struct semop_args /* {
- int semid;
- struct sembuf *sops;
- int nsops;
- } */ bsd_args;
-
- bsd_args.semid = args->arg1;
- bsd_args.sops = (struct sembuf *)args->ptr;
- bsd_args.nsops = args->arg2;
- return semop(p, &bsd_args);
-}
-
-static int
-linux_semget(struct proc *p, struct linux_ipc_args *args)
-{
- struct semget_args /* {
- key_t key;
- int nsems;
- int semflg;
- } */ bsd_args;
-
- bsd_args.key = args->arg1;
- bsd_args.nsems = args->arg2;
- bsd_args.semflg = args->arg3;
- return semget(p, &bsd_args);
-}
-
-static int
-linux_semctl(struct proc *p, struct linux_ipc_args *args)
-{
- struct linux_semid_ds linux_semid;
- struct semid_ds bsd_semid;
- struct __semctl_args /* {
- int semid;
- int semnum;
- int cmd;
- union semun *arg;
- } */ bsd_args;
- int error;
- caddr_t sg, unptr, dsp, ldsp;
-
- sg = stackgap_init();
- bsd_args.semid = args->arg1;
- bsd_args.semnum = args->arg2;
- bsd_args.cmd = args->arg3;
- bsd_args.arg = (union semun *)args->ptr;
-
- switch (args->arg3) {
- case LINUX_IPC_RMID:
- bsd_args.cmd = IPC_RMID;
- break;
- case LINUX_GETNCNT:
- bsd_args.cmd = GETNCNT;
- break;
- case LINUX_GETPID:
- bsd_args.cmd = GETPID;
- break;
- case LINUX_GETVAL:
- bsd_args.cmd = GETVAL;
- break;
- case LINUX_GETZCNT:
- bsd_args.cmd = GETZCNT;
- break;
- case LINUX_SETVAL:
- bsd_args.cmd = SETVAL;
- break;
- case LINUX_IPC_SET:
- bsd_args.cmd = IPC_SET;
- error = copyin(args->ptr, &ldsp, sizeof(ldsp));
- if (error)
- return error;
- error = copyin(ldsp, (caddr_t)&linux_semid, sizeof(linux_semid));
- if (error)
- return error;
- linux_to_bsd_semid_ds(&linux_semid, &bsd_semid);
- unptr = stackgap_alloc(&sg, sizeof(union semun));
- dsp = stackgap_alloc(&sg, sizeof(struct semid_ds));
- error = copyout((caddr_t)&bsd_semid, dsp, sizeof(bsd_semid));
- if (error)
- return error;
- error = copyout((caddr_t)&dsp, unptr, sizeof(dsp));
- if (error)
- return error;
- bsd_args.arg = (union semun *)unptr;
- return __semctl(p, &bsd_args);
- case LINUX_IPC_STAT:
- bsd_args.cmd = IPC_STAT;
- unptr = stackgap_alloc(&sg, sizeof(union semun *));
- dsp = stackgap_alloc(&sg, sizeof(struct semid_ds));
- error = copyout((caddr_t)&dsp, unptr, sizeof(dsp));
- if (error)
- return error;
- bsd_args.arg = (union semun *)unptr;
- error = __semctl(p, &bsd_args);
- if (error)
- return error;
- error = copyin(dsp, (caddr_t)&bsd_semid, sizeof(bsd_semid));
- if (error)
- return error;
- bsd_to_linux_semid_ds(&bsd_semid, &linux_semid);
- error = copyin(args->ptr, &ldsp, sizeof(ldsp));
- if (error)
- return error;
- return copyout((caddr_t)&linux_semid, ldsp, sizeof(linux_semid));
- case LINUX_GETALL:
- /* FALLTHROUGH */
- case LINUX_SETALL:
- /* FALLTHROUGH */
- default:
- uprintf("LINUX: 'ipc' typ=%d not implemented\n", args->what);
- return EINVAL;
- }
- return __semctl(p, &bsd_args);
-}
-
-static int
-linux_msgsnd(struct proc *p, struct linux_ipc_args *args)
-{
- struct msgsnd_args /* {
- int msqid;
- void *msgp;
- size_t msgsz;
- int msgflg;
- } */ bsd_args;
-
- bsd_args.msqid = args->arg1;
- bsd_args.msgp = args->ptr;
- bsd_args.msgsz = args->arg2;
- bsd_args.msgflg = args->arg3;
- return msgsnd(p, &bsd_args);
-}
-
-static int
-linux_msgrcv(struct proc *p, struct linux_ipc_args *args)
-{
- struct msgrcv_args /* {
- int msqid;
- void *msgp;
- size_t msgsz;
- long msgtyp;
- int msgflg;
- } */ bsd_args;
-
- bsd_args.msqid = args->arg1;
- bsd_args.msgp = args->ptr;
- bsd_args.msgsz = args->arg2;
- bsd_args.msgtyp = 0;
- bsd_args.msgflg = args->arg3;
- return msgrcv(p, &bsd_args);
-}
-
-static int
-linux_msgget(struct proc *p, struct linux_ipc_args *args)
-{
- struct msgget_args /* {
- key_t key;
- int msgflg;
- } */ bsd_args;
-
- bsd_args.key = args->arg1;
- bsd_args.msgflg = args->arg2;
- return msgget(p, &bsd_args);
-}
-
-static int
-linux_msgctl(struct proc *p, struct linux_ipc_args *args)
-{
- struct msgctl_args /* {
- int msqid;
- int cmd;
- struct msqid_ds *buf;
- } */ bsd_args;
- int error;
-
- bsd_args.msqid = args->arg1;
- bsd_args.cmd = args->arg2;
- bsd_args.buf = (struct msqid_ds *)args->ptr;
- error = msgctl(p, &bsd_args);
- return ((args->arg2 == LINUX_IPC_RMID && error == EINVAL) ? 0 : error);
-}
-
-static int
-linux_shmat(struct proc *p, struct linux_ipc_args *args)
-{
- struct shmat_args /* {
- int shmid;
- void *shmaddr;
- int shmflg;
- } */ bsd_args;
- int error;
-
- bsd_args.shmid = args->arg1;
- bsd_args.shmaddr = args->ptr;
- bsd_args.shmflg = args->arg2;
- if ((error = shmat(p, &bsd_args)))
- return error;
- if ((error = copyout(p->p_retval, (caddr_t)args->arg3, sizeof(int))))
- return error;
- p->p_retval[0] = 0;
- return 0;
-}
-
-static int
-linux_shmdt(struct proc *p, struct linux_ipc_args *args)
-{
- struct shmdt_args /* {
- void *shmaddr;
- } */ bsd_args;
-
- bsd_args.shmaddr = args->ptr;
- return shmdt(p, &bsd_args);
-}
-
-static int
-linux_shmget(struct proc *p, struct linux_ipc_args *args)
-{
- struct shmget_args /* {
- key_t key;
- int size;
- int shmflg;
- } */ bsd_args;
-
- bsd_args.key = args->arg1;
- bsd_args.size = args->arg2;
- bsd_args.shmflg = args->arg3;
- return shmget(p, &bsd_args);
-}
-
-static int
-linux_shmctl(struct proc *p, struct linux_ipc_args *args)
-{
- struct shmid_ds bsd_shmid;
- struct linux_shmid_ds linux_shmid;
- struct shmctl_args /* {
- int shmid;
- int cmd;
- struct shmid_ds *buf;
- } */ bsd_args;
- int error;
- caddr_t sg = stackgap_init();
-
- switch (args->arg2) {
- case LINUX_IPC_STAT:
- bsd_args.shmid = args->arg1;
- bsd_args.cmd = IPC_STAT;
- bsd_args.buf = (struct shmid_ds*)stackgap_alloc(&sg, sizeof(struct shmid_ds));
- if ((error = shmctl(p, &bsd_args)))
- return error;
- if ((error = copyin((caddr_t)bsd_args.buf, (caddr_t)&bsd_shmid,
- sizeof(struct shmid_ds))))
- return error;
- bsd_to_linux_shmid_ds(&bsd_shmid, &linux_shmid);
- return copyout((caddr_t)&linux_shmid, args->ptr, sizeof(linux_shmid));
-
- case LINUX_IPC_SET:
- if ((error = copyin(args->ptr, (caddr_t)&linux_shmid,
- sizeof(linux_shmid))))
- return error;
- linux_to_bsd_shmid_ds(&linux_shmid, &bsd_shmid);
- bsd_args.buf = (struct shmid_ds*)stackgap_alloc(&sg, sizeof(struct shmid_ds));
- if ((error = copyout((caddr_t)&bsd_shmid, (caddr_t)bsd_args.buf,
- sizeof(struct shmid_ds))))
- return error;
- bsd_args.shmid = args->arg1;
- bsd_args.cmd = IPC_SET;
- return shmctl(p, &bsd_args);
-
- case LINUX_IPC_RMID:
- bsd_args.shmid = args->arg1;
- bsd_args.cmd = IPC_RMID;
- if (NULL == args->ptr)
- bsd_args.buf = NULL;
- else {
- if ((error = copyin(args->ptr, (caddr_t)&linux_shmid,
- sizeof(linux_shmid))))
- return error;
- linux_to_bsd_shmid_ds(&linux_shmid, &bsd_shmid);
- bsd_args.buf = (struct shmid_ds*)stackgap_alloc(&sg, sizeof(struct shmid_ds));
- if ((error = copyout((caddr_t)&bsd_shmid, (caddr_t)bsd_args.buf,
- sizeof(struct shmid_ds))))
- return error;
- }
- return shmctl(p, &bsd_args);
-
- case LINUX_IPC_INFO:
- case LINUX_SHM_STAT:
- case LINUX_SHM_INFO:
- case LINUX_SHM_LOCK:
- case LINUX_SHM_UNLOCK:
- default:
- uprintf("LINUX: 'ipc' typ=%d not implemented\n", args->what);
- return EINVAL;
- }
-}
-
-int
-linux_ipc(struct proc *p, struct linux_ipc_args *args)
-{
- switch (args->what) {
- case LINUX_SEMOP:
- return linux_semop(p, args);
- case LINUX_SEMGET:
- return linux_semget(p, args);
- case LINUX_SEMCTL:
- return linux_semctl(p, args);
- case LINUX_MSGSND:
- return linux_msgsnd(p, args);
- case LINUX_MSGRCV:
- return linux_msgrcv(p, args);
- case LINUX_MSGGET:
- return linux_msgget(p, args);
- case LINUX_MSGCTL:
- return linux_msgctl(p, args);
- case LINUX_SHMAT:
- return linux_shmat(p, args);
- case LINUX_SHMDT:
- return linux_shmdt(p, args);
- case LINUX_SHMGET:
- return linux_shmget(p, args);
- case LINUX_SHMCTL:
- return linux_shmctl(p, args);
- default:
- uprintf("LINUX: 'ipc' typ=%d not implemented\n", args->what);
- return ENOSYS;
- }
-}
diff --git a/sys/compat/linux/linux_mib.c b/sys/compat/linux/linux_mib.c
deleted file mode 100644
index a7ef8f01ca40..000000000000
--- a/sys/compat/linux/linux_mib.c
+++ /dev/null
@@ -1,231 +0,0 @@
-/*-
- * Copyright (c) 1999 Marcel Moolenaar
- * 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
- * in this position and unchanged.
- * 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 withough 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/sysctl.h>
-#include <sys/proc.h>
-#include <sys/malloc.h>
-#include <sys/jail.h>
-
-#include <i386/linux/linux.h>
-#include <i386/linux/linux_mib.h>
-
-struct linux_prison {
- char pr_osname[LINUX_MAX_UTSNAME];
- char pr_osrelease[LINUX_MAX_UTSNAME];
- int pr_oss_version;
-};
-
-SYSCTL_NODE(_compat, OID_AUTO, linux, CTLFLAG_RW, 0,
- "Linux mode");
-
-static char linux_osname[LINUX_MAX_UTSNAME] = "Linux";
-
-static int
-linux_sysctl_osname SYSCTL_HANDLER_ARGS
-{
- char osname[LINUX_MAX_UTSNAME];
- int error;
-
- strcpy(osname, linux_get_osname(req->p));
- error = sysctl_handle_string(oidp, osname, LINUX_MAX_UTSNAME, req);
- if (error || req->newptr == NULL)
- return (error);
- error = linux_set_osname(req->p, osname);
- return (error);
-}
-
-SYSCTL_PROC(_compat_linux, OID_AUTO, osname,
- CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_PRISON,
- 0, 0, linux_sysctl_osname, "A",
- "Linux kernel OS name");
-
-static char linux_osrelease[LINUX_MAX_UTSNAME] = "2.2.12";
-
-static int
-linux_sysctl_osrelease SYSCTL_HANDLER_ARGS
-{
- char osrelease[LINUX_MAX_UTSNAME];
- int error;
-
- strcpy(osrelease, linux_get_osrelease(req->p));
- error = sysctl_handle_string(oidp, osrelease, LINUX_MAX_UTSNAME, req);
- if (error || req->newptr == NULL)
- return (error);
- error = linux_set_osrelease(req->p, osrelease);
- return (error);
-}
-
-SYSCTL_PROC(_compat_linux, OID_AUTO, osrelease,
- CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_PRISON,
- 0, 0, linux_sysctl_osrelease, "A",
- "Linux kernel OS release");
-
-static int linux_oss_version = 0x030600;
-
-static int
-linux_sysctl_oss_version SYSCTL_HANDLER_ARGS
-{
- int oss_version;
- int error;
-
- oss_version = linux_get_oss_version(req->p);
- error = sysctl_handle_int(oidp, &oss_version, 0, req);
- if (error || req->newptr == NULL)
- return (error);
- error = linux_set_oss_version(req->p, oss_version);
- return (error);
-}
-
-SYSCTL_PROC(_compat_linux, OID_AUTO, oss_version,
- CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_PRISON,
- 0, 0, linux_sysctl_oss_version, "I",
- "Linux OSS version");
-
-static struct linux_prison *
-get_prison(struct proc *p)
-{
- register struct prison *pr;
- register struct linux_prison *lpr;
-
- pr = p->p_prison;
- if (pr == NULL)
- return (NULL);
-
- if (pr->pr_linux == NULL) {
- MALLOC(lpr, struct linux_prison *, sizeof *lpr,
- M_PRISON, M_WAITOK);
- bzero((caddr_t)lpr, sizeof *lpr);
- pr->pr_linux = lpr;
- }
-
- return (pr->pr_linux);
-}
-
-char *
-linux_get_osname(p)
- struct proc *p;
-{
- register struct prison *pr;
- register struct linux_prison *lpr;
-
- pr = p->p_prison;
- if (pr != NULL && pr->pr_linux != NULL) {
- lpr = pr->pr_linux;
- if (lpr->pr_osname[0])
- return (lpr->pr_osname);
- }
-
- return (linux_osname);
-}
-
-int
-linux_set_osname(p, osname)
- struct proc *p;
- char *osname;
-{
- register struct linux_prison *lpr;
-
- lpr = get_prison(p);
- if (lpr != NULL)
- strcpy(lpr->pr_osname, osname);
- else
- strcpy(linux_osname, osname);
-
- return (0);
-}
-
-char *
-linux_get_osrelease(p)
- struct proc *p;
-{
- register struct prison *pr;
- register struct linux_prison *lpr;
-
- pr = p->p_prison;
- if (pr != NULL && pr->pr_linux != NULL) {
- lpr = pr->pr_linux;
- if (lpr->pr_osrelease[0])
- return (lpr->pr_osrelease);
- }
-
- return (linux_osrelease);
-}
-
-int
-linux_set_osrelease(p, osrelease)
- struct proc *p;
- char *osrelease;
-{
- register struct linux_prison *lpr;
-
- lpr = get_prison(p);
- if (lpr != NULL)
- strcpy(lpr->pr_osrelease, osrelease);
- else
- strcpy(linux_osrelease, osrelease);
-
- return (0);
-}
-
-int
-linux_get_oss_version(p)
- struct proc *p;
-{
- register struct prison *pr;
- register struct linux_prison *lpr;
-
- pr = p->p_prison;
- if (pr != NULL && pr->pr_linux != NULL) {
- lpr = pr->pr_linux;
- if (lpr->pr_oss_version)
- return (lpr->pr_oss_version);
- }
-
- return (linux_oss_version);
-}
-
-int
-linux_set_oss_version(p, oss_version)
- struct proc *p;
- int oss_version;
-{
- register struct linux_prison *lpr;
-
- lpr = get_prison(p);
- if (lpr != NULL)
- lpr->pr_oss_version = oss_version;
- else
- linux_oss_version = oss_version;
-
- return (0);
-}
diff --git a/sys/compat/linux/linux_mib.h b/sys/compat/linux/linux_mib.h
deleted file mode 100644
index 5a6884c072cc..000000000000
--- a/sys/compat/linux/linux_mib.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*-
- * Copyright (c) 1999 Marcel Moolenaar
- * 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
- * in this position and unchanged.
- * 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 withough 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _LINUX_MIB_H_
-#define _LINUX_MIB_H_
-
-char* linux_get_osname __P((struct proc *p));
-int linux_set_osname __P((struct proc *p, char *osname));
-
-char* linux_get_osrelease __P((struct proc *p));
-int linux_set_osrelease __P((struct proc *p, char *osrelease));
-
-int linux_get_oss_version __P((struct proc *p));
-int linux_set_oss_version __P((struct proc *p, int oss_version));
-
-#endif /* _LINUX_MIB_H_ */
diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c
deleted file mode 100644
index 1b2dd31988ad..000000000000
--- a/sys/compat/linux/linux_misc.c
+++ /dev/null
@@ -1,1461 +0,0 @@
-/*-
- * Copyright (c) 1994-1995 Søren Schmidt
- * 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
- * in this position and unchanged.
- * 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 withough 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.
- *
- * $FreeBSD$
- */
-
-#include "opt_compat.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/sysproto.h>
-#include <sys/kernel.h>
-#include <sys/mman.h>
-#include <sys/proc.h>
-#include <sys/fcntl.h>
-#include <sys/imgact_aout.h>
-#include <sys/mount.h>
-#include <sys/namei.h>
-#include <sys/resourcevar.h>
-#include <sys/stat.h>
-#include <sys/sysctl.h>
-#include <sys/unistd.h>
-#include <sys/vnode.h>
-#include <sys/wait.h>
-#include <sys/time.h>
-#include <sys/signalvar.h>
-
-#include <vm/vm.h>
-#include <vm/pmap.h>
-#include <vm/vm_kern.h>
-#include <vm/vm_map.h>
-#include <vm/vm_extern.h>
-#include <vm/vm_zone.h>
-
-#include <machine/frame.h>
-#include <machine/psl.h>
-#include <machine/sysarch.h>
-#include <machine/segments.h>
-
-#include <i386/linux/linux.h>
-#include <i386/linux/linux_proto.h>
-#include <i386/linux/linux_util.h>
-#include <i386/linux/linux_mib.h>
-
-#include <posix4/sched.h>
-
-#define BSD_TO_LINUX_SIGNAL(sig) \
- (((sig) <= LINUX_SIGTBLSZ) ? bsd_to_linux_signal[_SIG_IDX(sig)] : sig)
-
-static unsigned int linux_to_bsd_resource[LINUX_RLIM_NLIMITS] =
-{ RLIMIT_CPU, RLIMIT_FSIZE, RLIMIT_DATA, RLIMIT_STACK,
- RLIMIT_CORE, RLIMIT_RSS, RLIMIT_NPROC, RLIMIT_NOFILE,
- RLIMIT_MEMLOCK, -1
-};
-
-int
-linux_alarm(struct proc *p, struct linux_alarm_args *args)
-{
- struct itimerval it, old_it;
- struct timeval tv;
- int s;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): alarm(%u)\n", (long)p->p_pid, args->secs);
-#endif
- if (args->secs > 100000000)
- return EINVAL;
- it.it_value.tv_sec = (long)args->secs;
- it.it_value.tv_usec = 0;
- it.it_interval.tv_sec = 0;
- it.it_interval.tv_usec = 0;
- s = splsoftclock();
- old_it = p->p_realtimer;
- getmicrouptime(&tv);
- if (timevalisset(&old_it.it_value))
- untimeout(realitexpire, (caddr_t)p, p->p_ithandle);
- if (it.it_value.tv_sec != 0) {
- p->p_ithandle = timeout(realitexpire, (caddr_t)p, tvtohz(&it.it_value));
- timevaladd(&it.it_value, &tv);
- }
- p->p_realtimer = it;
- splx(s);
- if (timevalcmp(&old_it.it_value, &tv, >)) {
- timevalsub(&old_it.it_value, &tv);
- if (old_it.it_value.tv_usec != 0)
- old_it.it_value.tv_sec++;
- p->p_retval[0] = old_it.it_value.tv_sec;
- }
- return 0;
-}
-
-int
-linux_brk(struct proc *p, struct linux_brk_args *args)
-{
-#if 0
- struct vmspace *vm = p->p_vmspace;
- vm_offset_t new, old;
- int error;
-
- if ((vm_offset_t)args->dsend < (vm_offset_t)vm->vm_daddr)
- return EINVAL;
- if (((caddr_t)args->dsend - (caddr_t)vm->vm_daddr)
- > p->p_rlimit[RLIMIT_DATA].rlim_cur)
- return ENOMEM;
-
- old = round_page((vm_offset_t)vm->vm_daddr) + ctob(vm->vm_dsize);
- new = round_page((vm_offset_t)args->dsend);
- p->p_retval[0] = old;
- if ((new-old) > 0) {
- if (swap_pager_full)
- return ENOMEM;
- error = vm_map_find(&vm->vm_map, NULL, 0, &old, (new-old), FALSE,
- VM_PROT_ALL, VM_PROT_ALL, 0);
- if (error)
- return error;
- vm->vm_dsize += btoc((new-old));
- p->p_retval[0] = (int)(vm->vm_daddr + ctob(vm->vm_dsize));
- }
- return 0;
-#else
- struct vmspace *vm = p->p_vmspace;
- vm_offset_t new, old;
- struct obreak_args /* {
- char * nsize;
- } */ tmp;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): brk(%p)\n", (long)p->p_pid, (void *)args->dsend);
-#endif
- old = (vm_offset_t)vm->vm_daddr + ctob(vm->vm_dsize);
- new = (vm_offset_t)args->dsend;
- tmp.nsize = (char *) new;
- if (((caddr_t)new > vm->vm_daddr) && !obreak(p, &tmp))
- p->p_retval[0] = (int)new;
- else
- p->p_retval[0] = (int)old;
-
- return 0;
-#endif
-}
-
-int
-linux_uselib(struct proc *p, struct linux_uselib_args *args)
-{
- struct nameidata ni;
- struct vnode *vp;
- struct exec *a_out;
- struct vattr attr;
- vm_offset_t vmaddr;
- unsigned long file_offset;
- vm_offset_t buffer;
- unsigned long bss_size;
- int error;
- caddr_t sg;
- int locked;
-
- sg = stackgap_init();
- CHECKALTEXIST(p, &sg, args->library);
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): uselib(%s)\n", (long)p->p_pid, args->library);
-#endif
-
- a_out = NULL;
- locked = 0;
- vp = NULL;
-
- NDINIT(&ni, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, args->library, p);
- error = namei(&ni);
- if (error)
- goto cleanup;
-
- vp = ni.ni_vp;
- /*
- * XXX This looks like a bogus check - a LOCKLEAF namei should not succeed
- * without returning a vnode.
- */
- if (vp == NULL) {
- error = ENOEXEC; /* ?? */
- goto cleanup;
- }
- NDFREE(&ni, NDF_ONLY_PNBUF);
-
- /*
- * From here on down, we have a locked vnode that must be unlocked.
- */
- locked++;
-
- /*
- * Writable?
- */
- if (vp->v_writecount) {
- error = ETXTBSY;
- goto cleanup;
- }
-
- /*
- * Executable?
- */
- error = VOP_GETATTR(vp, &attr, p->p_ucred, p);
- if (error)
- goto cleanup;
-
- if ((vp->v_mount->mnt_flag & MNT_NOEXEC) ||
- ((attr.va_mode & 0111) == 0) ||
- (attr.va_type != VREG)) {
- error = ENOEXEC;
- goto cleanup;
- }
-
- /*
- * Sensible size?
- */
- if (attr.va_size == 0) {
- error = ENOEXEC;
- goto cleanup;
- }
-
- /*
- * Can we access it?
- */
- error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p);
- if (error)
- goto cleanup;
-
- error = VOP_OPEN(vp, FREAD, p->p_ucred, p);
- if (error)
- goto cleanup;
-
- /*
- * Lock no longer needed
- */
- VOP_UNLOCK(vp, 0, p);
- locked = 0;
-
- /*
- * Pull in executable header into kernel_map
- */
- error = vm_mmap(kernel_map, (vm_offset_t *)&a_out, PAGE_SIZE,
- VM_PROT_READ, VM_PROT_READ, 0, (caddr_t)vp, 0);
- if (error)
- goto cleanup;
-
- /*
- * Is it a Linux binary ?
- */
- if (((a_out->a_magic >> 16) & 0xff) != 0x64) {
- error = ENOEXEC;
- goto cleanup;
- }
-
- /* While we are here, we should REALLY do some more checks */
-
- /*
- * Set file/virtual offset based on a.out variant.
- */
- switch ((int)(a_out->a_magic & 0xffff)) {
- case 0413: /* ZMAGIC */
- file_offset = 1024;
- break;
- case 0314: /* QMAGIC */
- file_offset = 0;
- break;
- default:
- error = ENOEXEC;
- goto cleanup;
- }
-
- bss_size = round_page(a_out->a_bss);
-
- /*
- * Check various fields in header for validity/bounds.
- */
- if (a_out->a_text & PAGE_MASK || a_out->a_data & PAGE_MASK) {
- error = ENOEXEC;
- goto cleanup;
- }
-
- /* text + data can't exceed file size */
- if (a_out->a_data + a_out->a_text > attr.va_size) {
- error = EFAULT;
- goto cleanup;
- }
-
- /*
- * text/data/bss must not exceed limits
- * XXX: this is not complete. it should check current usage PLUS
- * the resources needed by this library.
- */
- if (a_out->a_text > MAXTSIZ ||
- a_out->a_data + bss_size > p->p_rlimit[RLIMIT_DATA].rlim_cur) {
- error = ENOMEM;
- goto cleanup;
- }
-
- /*
- * prevent more writers
- */
- vp->v_flag |= VTEXT;
-
- /*
- * Check if file_offset page aligned,.
- * Currently we cannot handle misalinged file offsets,
- * and so we read in the entire image (what a waste).
- */
- if (file_offset & PAGE_MASK) {
-#ifdef DEBUG
-printf("uselib: Non page aligned binary %lu\n", file_offset);
-#endif
- /*
- * Map text+data read/write/execute
- */
-
- /* a_entry is the load address and is page aligned */
- vmaddr = trunc_page(a_out->a_entry);
-
- /* get anon user mapping, read+write+execute */
- error = vm_map_find(&p->p_vmspace->vm_map, NULL, 0, &vmaddr,
- a_out->a_text + a_out->a_data, FALSE,
- VM_PROT_ALL, VM_PROT_ALL, 0);
- if (error)
- goto cleanup;
-
- /* map file into kernel_map */
- error = vm_mmap(kernel_map, &buffer,
- round_page(a_out->a_text + a_out->a_data + file_offset),
- VM_PROT_READ, VM_PROT_READ, 0,
- (caddr_t)vp, trunc_page(file_offset));
- if (error)
- goto cleanup;
-
- /* copy from kernel VM space to user space */
- error = copyout((caddr_t)(void *)(uintptr_t)(buffer + file_offset),
- (caddr_t)vmaddr, a_out->a_text + a_out->a_data);
-
- /* release temporary kernel space */
- vm_map_remove(kernel_map, buffer,
- buffer + round_page(a_out->a_text + a_out->a_data + file_offset));
-
- if (error)
- goto cleanup;
- }
- else {
-#ifdef DEBUG
-printf("uselib: Page aligned binary %lu\n", file_offset);
-#endif
- /*
- * for QMAGIC, a_entry is 20 bytes beyond the load address
- * to skip the executable header
- */
- vmaddr = trunc_page(a_out->a_entry);
-
- /*
- * Map it all into the process's space as a single copy-on-write
- * "data" segment.
- */
- error = vm_mmap(&p->p_vmspace->vm_map, &vmaddr,
- a_out->a_text + a_out->a_data,
- VM_PROT_ALL, VM_PROT_ALL, MAP_PRIVATE | MAP_FIXED,
- (caddr_t)vp, file_offset);
- if (error)
- goto cleanup;
- }
-#ifdef DEBUG
-printf("mem=%08x = %08x %08x\n", vmaddr, ((int*)vmaddr)[0], ((int*)vmaddr)[1]);
-#endif
- if (bss_size != 0) {
- /*
- * Calculate BSS start address
- */
- vmaddr = trunc_page(a_out->a_entry) + a_out->a_text + a_out->a_data;
-
- /*
- * allocate some 'anon' space
- */
- error = vm_map_find(&p->p_vmspace->vm_map, NULL, 0, &vmaddr,
- bss_size, FALSE,
- VM_PROT_ALL, VM_PROT_ALL, 0);
- if (error)
- goto cleanup;
- }
-
-cleanup:
- /*
- * Unlock vnode if needed
- */
- if (locked)
- VOP_UNLOCK(vp, 0, p);
-
- /*
- * Release the kernel mapping.
- */
- if (a_out)
- vm_map_remove(kernel_map, (vm_offset_t)a_out, (vm_offset_t)a_out + PAGE_SIZE);
-
- return error;
-}
-
-/* XXX move */
-struct linux_select_argv {
- int nfds;
- fd_set *readfds;
- fd_set *writefds;
- fd_set *exceptfds;
- struct timeval *timeout;
-};
-
-int
-linux_select(struct proc *p, struct linux_select_args *args)
-{
- struct linux_select_argv linux_args;
- struct linux_newselect_args newsel;
- int error;
-
-#ifdef SELECT_DEBUG
- printf("Linux-emul(%ld): select(%x)\n", (long)p->p_pid, args->ptr);
-#endif
- if ((error = copyin((caddr_t)args->ptr, (caddr_t)&linux_args,
- sizeof(linux_args))))
- return error;
-
- newsel.nfds = linux_args.nfds;
- newsel.readfds = linux_args.readfds;
- newsel.writefds = linux_args.writefds;
- newsel.exceptfds = linux_args.exceptfds;
- newsel.timeout = linux_args.timeout;
-
- return linux_newselect(p, &newsel);
-}
-
-int
-linux_newselect(struct proc *p, struct linux_newselect_args *args)
-{
- struct select_args bsa;
- struct timeval tv0, tv1, utv, *tvp;
- caddr_t sg;
- int error;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): newselect(%d, %p, %p, %p, %p)\n",
- (long)p->p_pid, args->nfds, (void *)args->readfds,
- (void *)args->writefds, (void *)args->exceptfds,
- (void *)args->timeout);
-#endif
- error = 0;
- bsa.nd = args->nfds;
- bsa.in = args->readfds;
- bsa.ou = args->writefds;
- bsa.ex = args->exceptfds;
- bsa.tv = args->timeout;
-
- /*
- * Store current time for computation of the amount of
- * time left.
- */
- if (args->timeout) {
- if ((error = copyin(args->timeout, &utv, sizeof(utv))))
- goto select_out;
-#ifdef DEBUG
- printf("Linux-emul(%ld): incoming timeout (%ld/%ld)\n",
- (long)p->p_pid, utv.tv_sec, utv.tv_usec);
-#endif
- if (itimerfix(&utv)) {
- /*
- * The timeval was invalid. Convert it to something
- * valid that will act as it does under Linux.
- */
- sg = stackgap_init();
- tvp = stackgap_alloc(&sg, sizeof(utv));
- utv.tv_sec += utv.tv_usec / 1000000;
- utv.tv_usec %= 1000000;
- if (utv.tv_usec < 0) {
- utv.tv_sec -= 1;
- utv.tv_usec += 1000000;
- }
- if (utv.tv_sec < 0)
- timevalclear(&utv);
- if ((error = copyout(&utv, tvp, sizeof(utv))))
- goto select_out;
- bsa.tv = tvp;
- }
- microtime(&tv0);
- }
-
- error = select(p, &bsa);
-#ifdef DEBUG
- printf("Linux-emul(%ld): real select returns %d\n", (long)p->p_pid, error);
-#endif
-
- if (error) {
- /*
- * See fs/select.c in the Linux kernel. Without this,
- * Maelstrom doesn't work.
- */
- if (error == ERESTART)
- error = EINTR;
- goto select_out;
- }
-
- if (args->timeout) {
- if (p->p_retval[0]) {
- /*
- * Compute how much time was left of the timeout,
- * by subtracting the current time and the time
- * before we started the call, and subtracting
- * that result from the user-supplied value.
- */
- microtime(&tv1);
- timevalsub(&tv1, &tv0);
- timevalsub(&utv, &tv1);
- if (utv.tv_sec < 0)
- timevalclear(&utv);
- } else
- timevalclear(&utv);
-#ifdef DEBUG
- printf("Linux-emul(%ld): outgoing timeout (%ld/%ld)\n",
- (long)p->p_pid, utv.tv_sec, utv.tv_usec);
-#endif
- if ((error = copyout(&utv, args->timeout, sizeof(utv))))
- goto select_out;
- }
-
-select_out:
-#ifdef DEBUG
- printf("Linux-emul(%ld): newselect_out -> %d\n", (long)p->p_pid, error);
-#endif
- return error;
-}
-
-int
-linux_getpgid(struct proc *p, struct linux_getpgid_args *args)
-{
- struct proc *curp;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): getpgid(%d)\n", (long)p->p_pid, args->pid);
-#endif
- if (args->pid != p->p_pid) {
- if (!(curp = pfind(args->pid)))
- return ESRCH;
- }
- else
- curp = p;
- p->p_retval[0] = curp->p_pgid;
- return 0;
-}
-
-int
-linux_fork(struct proc *p, struct linux_fork_args *args)
-{
- int error;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): fork()\n", (long)p->p_pid);
-#endif
- if ((error = fork(p, (struct fork_args *)args)) != 0)
- return error;
- if (p->p_retval[1] == 1)
- p->p_retval[0] = 0;
- return 0;
-}
-
-int
-linux_vfork(struct proc *p, struct linux_vfork_args *args)
-{
- int error;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): vfork()\n", (long)p->p_pid);
-#endif
-
- if ((error = vfork(p, (struct vfork_args *)args)) != 0)
- return error;
- /* Are we the child? */
- if (p->p_retval[1] == 1)
- p->p_retval[0] = 0;
- return 0;
-}
-
-#define CLONE_VM 0x100
-#define CLONE_FS 0x200
-#define CLONE_FILES 0x400
-#define CLONE_SIGHAND 0x800
-#define CLONE_PID 0x1000
-
-int
-linux_clone(struct proc *p, struct linux_clone_args *args)
-{
- int error, ff = RFPROC;
- struct proc *p2;
- int exit_signal;
- vm_offset_t start;
- struct rfork_args rf_args;
-
-#ifdef DEBUG
- if (args->flags & CLONE_PID)
- printf("linux_clone(%ld): CLONE_PID not yet supported\n",
- (long)p->p_pid);
- printf("linux_clone(%ld): invoked with flags %x and stack %x\n",
- (long)p->p_pid, (unsigned int)args->flags,
- (unsigned int)args->stack);
-#endif
-
- if (!args->stack)
- return (EINVAL);
-
- exit_signal = args->flags & 0x000000ff;
- if (exit_signal >= LINUX_NSIG)
- return EINVAL;
-
- if (exit_signal <= LINUX_SIGTBLSZ)
- exit_signal = linux_to_bsd_signal[_SIG_IDX(exit_signal)];
-
- /* RFTHREAD probably not necessary here, but it shouldn't hurt either */
- ff |= RFTHREAD;
-
- if (args->flags & CLONE_VM)
- ff |= RFMEM;
- if (args->flags & CLONE_SIGHAND)
- ff |= RFSIGSHARE;
- if (!(args->flags & CLONE_FILES))
- ff |= RFFDG;
-
- error = 0;
- start = 0;
-
- rf_args.flags = ff;
- if ((error = rfork(p, &rf_args)) != 0)
- return error;
-
- p2 = pfind(p->p_retval[0]);
- if (p2 == 0)
- return ESRCH;
-
- p2->p_sigparent = exit_signal;
- p2->p_md.md_regs->tf_esp = (unsigned int)args->stack;
-
-#ifdef DEBUG
- printf ("linux_clone(%ld): successful rfork to %ld\n",
- (long)p->p_pid, (long)p2->p_pid);
-#endif
- return 0;
-}
-
-/* XXX move */
-struct linux_mmap_argv {
- linux_caddr_t addr;
- int len;
- int prot;
- int flags;
- int fd;
- int pos;
-};
-
-#define STACK_SIZE (2 * 1024 * 1024)
-#define GUARD_SIZE (4 * PAGE_SIZE)
-int
-linux_mmap(struct proc *p, struct linux_mmap_args *args)
-{
- struct mmap_args /* {
- caddr_t addr;
- size_t len;
- int prot;
- int flags;
- int fd;
- long pad;
- off_t pos;
- } */ bsd_args;
- int error;
- struct linux_mmap_argv linux_args;
-
- if ((error = copyin((caddr_t)args->ptr, (caddr_t)&linux_args,
- sizeof(linux_args))))
- return error;
-#ifdef DEBUG
- printf("Linux-emul(%ld): mmap(%p, %d, %d, %08x, %d, %d)\n",
- (long)p->p_pid, (void *)linux_args.addr, linux_args.len,
- linux_args.prot, linux_args.flags, linux_args.fd, linux_args.pos);
-#endif
- bsd_args.flags = 0;
- if (linux_args.flags & LINUX_MAP_SHARED)
- bsd_args.flags |= MAP_SHARED;
- if (linux_args.flags & LINUX_MAP_PRIVATE)
- bsd_args.flags |= MAP_PRIVATE;
- if (linux_args.flags & LINUX_MAP_FIXED)
- bsd_args.flags |= MAP_FIXED;
- if (linux_args.flags & LINUX_MAP_ANON)
- bsd_args.flags |= MAP_ANON;
- if (linux_args.flags & LINUX_MAP_GROWSDOWN) {
- bsd_args.flags |= MAP_STACK;
-
- /* The linux MAP_GROWSDOWN option does not limit auto
- * growth of the region. Linux mmap with this option
- * takes as addr the inital BOS, and as len, the initial
- * region size. It can then grow down from addr without
- * limit. However, linux threads has an implicit internal
- * limit to stack size of STACK_SIZE. Its just not
- * enforced explicitly in linux. But, here we impose
- * a limit of (STACK_SIZE - GUARD_SIZE) on the stack
- * region, since we can do this with our mmap.
- *
- * Our mmap with MAP_STACK takes addr as the maximum
- * downsize limit on BOS, and as len the max size of
- * the region. It them maps the top SGROWSIZ bytes,
- * and autgrows the region down, up to the limit
- * in addr.
- *
- * If we don't use the MAP_STACK option, the effect
- * of this code is to allocate a stack region of a
- * fixed size of (STACK_SIZE - GUARD_SIZE).
- */
-
- /* This gives us TOS */
- bsd_args.addr = linux_args.addr + linux_args.len;
-
- /* This gives us our maximum stack size */
- if (linux_args.len > STACK_SIZE - GUARD_SIZE)
- bsd_args.len = linux_args.len;
- else
- bsd_args.len = STACK_SIZE - GUARD_SIZE;
-
- /* This gives us a new BOS. If we're using VM_STACK, then
- * mmap will just map the top SGROWSIZ bytes, and let
- * the stack grow down to the limit at BOS. If we're
- * not using VM_STACK we map the full stack, since we
- * don't have a way to autogrow it.
- */
- bsd_args.addr -= bsd_args.len;
-
- } else {
- bsd_args.addr = linux_args.addr;
- bsd_args.len = linux_args.len;
- }
-
- bsd_args.prot = linux_args.prot | PROT_READ; /* always required */
- bsd_args.fd = linux_args.fd;
- bsd_args.pos = linux_args.pos;
- bsd_args.pad = 0;
- return mmap(p, &bsd_args);
-}
-
-int
-linux_mremap(struct proc *p, struct linux_mremap_args *args)
-{
- struct munmap_args /* {
- void *addr;
- size_t len;
- } */ bsd_args;
- int error = 0;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): mremap(%p, %08x, %08x, %08x)\n",
- (long)p->p_pid, (void *)args->addr, args->old_len, args->new_len,
- args->flags);
-#endif
- args->new_len = round_page(args->new_len);
- args->old_len = round_page(args->old_len);
-
- if (args->new_len > args->old_len) {
- p->p_retval[0] = 0;
- return ENOMEM;
- }
-
- if (args->new_len < args->old_len) {
- bsd_args.addr = args->addr + args->new_len;
- bsd_args.len = args->old_len - args->new_len;
- error = munmap(p, &bsd_args);
- }
-
- p->p_retval[0] = error ? 0 : (int)args->addr;
- return error;
-}
-
-int
-linux_msync(struct proc *p, struct linux_msync_args *args)
-{
- struct msync_args bsd_args;
-
- bsd_args.addr = args->addr;
- bsd_args.len = args->len;
- bsd_args.flags = 0; /* XXX ignore */
-
- return msync(p, &bsd_args);
-}
-
-int
-linux_pipe(struct proc *p, struct linux_pipe_args *args)
-{
- int error;
- int reg_edx;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): pipe(*)\n", (long)p->p_pid);
-#endif
- reg_edx = p->p_retval[1];
- error = pipe(p, 0);
- if (error) {
- p->p_retval[1] = reg_edx;
- return error;
- }
-
- error = copyout(p->p_retval, args->pipefds, 2*sizeof(int));
- if (error) {
- p->p_retval[1] = reg_edx;
- return error;
- }
-
- p->p_retval[1] = reg_edx;
- p->p_retval[0] = 0;
- return 0;
-}
-
-int
-linux_time(struct proc *p, struct linux_time_args *args)
-{
- struct timeval tv;
- linux_time_t tm;
- int error;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): time(*)\n", (long)p->p_pid);
-#endif
- microtime(&tv);
- tm = tv.tv_sec;
- if (args->tm && (error = copyout(&tm, args->tm, sizeof(linux_time_t))))
- return error;
- p->p_retval[0] = tm;
- return 0;
-}
-
-struct linux_times_argv {
- long tms_utime;
- long tms_stime;
- long tms_cutime;
- long tms_cstime;
-};
-
-#define CLK_TCK 100 /* Linux uses 100 */
-#define CONVTCK(r) (r.tv_sec * CLK_TCK + r.tv_usec / (1000000 / CLK_TCK))
-
-int
-linux_times(struct proc *p, struct linux_times_args *args)
-{
- struct timeval tv;
- struct linux_times_argv tms;
- struct rusage ru;
- int error;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): times(*)\n", (long)p->p_pid);
-#endif
- calcru(p, &ru.ru_utime, &ru.ru_stime, NULL);
-
- tms.tms_utime = CONVTCK(ru.ru_utime);
- tms.tms_stime = CONVTCK(ru.ru_stime);
-
- tms.tms_cutime = CONVTCK(p->p_stats->p_cru.ru_utime);
- tms.tms_cstime = CONVTCK(p->p_stats->p_cru.ru_stime);
-
- if ((error = copyout((caddr_t)&tms, (caddr_t)args->buf,
- sizeof(struct linux_times_argv))))
- return error;
-
- microuptime(&tv);
- p->p_retval[0] = (int)CONVTCK(tv);
- return 0;
-}
-
-int
-linux_newuname(struct proc *p, struct linux_newuname_args *args)
-{
- struct linux_new_utsname utsname;
- char *osrelease, *osname;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): newuname(*)\n", (long)p->p_pid);
-#endif
-
- osname = linux_get_osname(p);
- osrelease = linux_get_osrelease(p);
-
- bzero(&utsname, sizeof(struct linux_new_utsname));
- strncpy(utsname.sysname, osname, LINUX_MAX_UTSNAME-1);
- strncpy(utsname.nodename, hostname, LINUX_MAX_UTSNAME-1);
- strncpy(utsname.release, osrelease, LINUX_MAX_UTSNAME-1);
- strncpy(utsname.version, version, LINUX_MAX_UTSNAME-1);
- strncpy(utsname.machine, machine, LINUX_MAX_UTSNAME-1);
- strncpy(utsname.domainname, domainname, LINUX_MAX_UTSNAME-1);
-
- return (copyout((caddr_t)&utsname, (caddr_t)args->buf,
- sizeof(struct linux_new_utsname)));
-}
-
-struct linux_utimbuf {
- linux_time_t l_actime;
- linux_time_t l_modtime;
-};
-
-int
-linux_utime(struct proc *p, struct linux_utime_args *args)
-{
- struct utimes_args /* {
- char *path;
- struct timeval *tptr;
- } */ bsdutimes;
- struct timeval tv[2], *tvp;
- struct linux_utimbuf lut;
- int error;
- caddr_t sg;
-
- sg = stackgap_init();
- CHECKALTEXIST(p, &sg, args->fname);
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): utime(%s, *)\n", (long)p->p_pid, args->fname);
-#endif
- if (args->times) {
- if ((error = copyin(args->times, &lut, sizeof lut)))
- return error;
- tv[0].tv_sec = lut.l_actime;
- tv[0].tv_usec = 0;
- tv[1].tv_sec = lut.l_modtime;
- tv[1].tv_usec = 0;
- /* so that utimes can copyin */
- tvp = (struct timeval *)stackgap_alloc(&sg, sizeof(tv));
- if ((error = copyout(tv, tvp, sizeof(tv))))
- return error;
- bsdutimes.tptr = tvp;
- } else
- bsdutimes.tptr = NULL;
-
- bsdutimes.path = args->fname;
- return utimes(p, &bsdutimes);
-}
-
-#define __WCLONE 0x80000000
-
-int
-linux_waitpid(struct proc *p, struct linux_waitpid_args *args)
-{
- struct wait_args /* {
- int pid;
- int *status;
- int options;
- struct rusage *rusage;
- } */ tmp;
- int error, tmpstat;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): waitpid(%d, %p, %d)\n",
- (long)p->p_pid, args->pid, (void *)args->status, args->options);
-#endif
- tmp.pid = args->pid;
- tmp.status = args->status;
- tmp.options = (args->options & (WNOHANG | WUNTRACED));
- /* WLINUXCLONE should be equal to __WCLONE, but we make sure */
- if (args->options & __WCLONE)
- tmp.options |= WLINUXCLONE;
- tmp.rusage = NULL;
-
- if ((error = wait4(p, &tmp)) != 0)
- return error;
-
- if (args->status) {
- if ((error = copyin(args->status, &tmpstat, sizeof(int))) != 0)
- return error;
- tmpstat &= 0xffff;
- if (WIFSIGNALED(tmpstat))
- tmpstat = (tmpstat & 0xffffff80) |
- BSD_TO_LINUX_SIGNAL(WTERMSIG(tmpstat));
- else if (WIFSTOPPED(tmpstat))
- tmpstat = (tmpstat & 0xffff00ff) |
- (BSD_TO_LINUX_SIGNAL(WSTOPSIG(tmpstat)) << 8);
- return copyout(&tmpstat, args->status, sizeof(int));
- } else
- return 0;
-}
-
-int
-linux_wait4(struct proc *p, struct linux_wait4_args *args)
-{
- struct wait_args /* {
- int pid;
- int *status;
- int options;
- struct rusage *rusage;
- } */ tmp;
- int error, tmpstat;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): wait4(%d, %p, %d, %p)\n",
- (long)p->p_pid, args->pid, (void *)args->status, args->options,
- (void *)args->rusage);
-#endif
- tmp.pid = args->pid;
- tmp.status = args->status;
- tmp.options = (args->options & (WNOHANG | WUNTRACED));
- /* WLINUXCLONE should be equal to __WCLONE, but we make sure */
- if (args->options & __WCLONE)
- tmp.options |= WLINUXCLONE;
- tmp.rusage = args->rusage;
-
- if ((error = wait4(p, &tmp)) != 0)
- return error;
-
- SIGDELSET(p->p_siglist, SIGCHLD);
-
- if (args->status) {
- if ((error = copyin(args->status, &tmpstat, sizeof(int))) != 0)
- return error;
- tmpstat &= 0xffff;
- if (WIFSIGNALED(tmpstat))
- tmpstat = (tmpstat & 0xffffff80) |
- BSD_TO_LINUX_SIGNAL(WTERMSIG(tmpstat));
- else if (WIFSTOPPED(tmpstat))
- tmpstat = (tmpstat & 0xffff00ff) |
- (BSD_TO_LINUX_SIGNAL(WSTOPSIG(tmpstat)) << 8);
- return copyout(&tmpstat, args->status, sizeof(int));
- } else
- return 0;
-}
-
-int
-linux_mknod(struct proc *p, struct linux_mknod_args *args)
-{
- caddr_t sg;
- struct mknod_args bsd_mknod;
- struct mkfifo_args bsd_mkfifo;
-
- sg = stackgap_init();
-
- CHECKALTCREAT(p, &sg, args->path);
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): mknod(%s, %d, %d)\n",
- (long)p->p_pid, args->path, args->mode, args->dev);
-#endif
-
- if (args->mode & S_IFIFO) {
- bsd_mkfifo.path = args->path;
- bsd_mkfifo.mode = args->mode;
- return mkfifo(p, &bsd_mkfifo);
- } else {
- bsd_mknod.path = args->path;
- bsd_mknod.mode = args->mode;
- bsd_mknod.dev = args->dev;
- return mknod(p, &bsd_mknod);
- }
-}
-
-/*
- * UGH! This is just about the dumbest idea I've ever heard!!
- */
-int
-linux_personality(struct proc *p, struct linux_personality_args *args)
-{
-#ifdef DEBUG
- printf("Linux-emul(%ld): personality(%d)\n",
- (long)p->p_pid, args->per);
-#endif
- if (args->per != 0)
- return EINVAL;
-
- /* Yes Jim, it's still a Linux... */
- p->p_retval[0] = 0;
- return 0;
-}
-
-/*
- * Wrappers for get/setitimer for debugging..
- */
-int
-linux_setitimer(struct proc *p, struct linux_setitimer_args *args)
-{
- struct setitimer_args bsa;
- struct itimerval foo;
- int error;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): setitimer(%p, %p)\n",
- (long)p->p_pid, (void *)args->itv, (void *)args->oitv);
-#endif
- bsa.which = args->which;
- bsa.itv = args->itv;
- bsa.oitv = args->oitv;
- if (args->itv) {
- if ((error = copyin((caddr_t)args->itv, (caddr_t)&foo,
- sizeof(foo))))
- return error;
-#ifdef DEBUG
- printf("setitimer: value: sec: %ld, usec: %ld\n",
- foo.it_value.tv_sec, foo.it_value.tv_usec);
- printf("setitimer: interval: sec: %ld, usec: %ld\n",
- foo.it_interval.tv_sec, foo.it_interval.tv_usec);
-#endif
- }
- return setitimer(p, &bsa);
-}
-
-int
-linux_getitimer(struct proc *p, struct linux_getitimer_args *args)
-{
- struct getitimer_args bsa;
-#ifdef DEBUG
- printf("Linux-emul(%ld): getitimer(%p)\n",
- (long)p->p_pid, (void *)args->itv);
-#endif
- bsa.which = args->which;
- bsa.itv = args->itv;
- return getitimer(p, &bsa);
-}
-
-int
-linux_ioperm(struct proc *p, struct linux_ioperm_args *args)
-{
- struct sysarch_args sa;
- struct i386_ioperm_args *iia;
- caddr_t sg;
-
- sg = stackgap_init();
- iia = stackgap_alloc(&sg, sizeof(struct i386_ioperm_args));
- iia->start = args->start;
- iia->length = args->length;
- iia->enable = args->enable;
- sa.op = I386_SET_IOPERM;
- sa.parms = (char *)iia;
- return sysarch(p, &sa);
-}
-
-int
-linux_iopl(struct proc *p, struct linux_iopl_args *args)
-{
- int error;
-
- if (args->level < 0 || args->level > 3)
- return (EINVAL);
- if ((error = suser(p)) != 0)
- return (error);
- if (securelevel > 0)
- return (EPERM);
- p->p_md.md_regs->tf_eflags = (p->p_md.md_regs->tf_eflags & ~PSL_IOPL) |
- (args->level * (PSL_IOPL / 3));
- return (0);
-}
-
-int
-linux_nice(struct proc *p, struct linux_nice_args *args)
-{
- struct setpriority_args bsd_args;
-
- bsd_args.which = PRIO_PROCESS;
- bsd_args.who = 0; /* current process */
- bsd_args.prio = args->inc;
- return setpriority(p, &bsd_args);
-}
-
-int
-linux_setgroups(p, uap)
- struct proc *p;
- struct linux_setgroups_args *uap;
-{
- struct pcred *pc;
- linux_gid_t linux_gidset[NGROUPS];
- gid_t *bsd_gidset;
- int ngrp, error;
-
- pc = p->p_cred;
- ngrp = uap->gidsetsize;
-
- /*
- * cr_groups[0] holds egid. Setting the whole set from
- * the supplied set will cause egid to be changed too.
- * Keep cr_groups[0] unchanged to prevent that.
- */
-
- if ((error = suser(p)) != 0)
- return (error);
-
- if (ngrp >= NGROUPS)
- return (EINVAL);
-
- pc->pc_ucred = crcopy(pc->pc_ucred);
- if (ngrp > 0) {
- error = copyin((caddr_t)uap->gidset, (caddr_t)linux_gidset,
- ngrp * sizeof(linux_gid_t));
- if (error)
- return (error);
-
- pc->pc_ucred->cr_ngroups = ngrp + 1;
-
- bsd_gidset = pc->pc_ucred->cr_groups;
- ngrp--;
- while (ngrp >= 0) {
- bsd_gidset[ngrp + 1] = linux_gidset[ngrp];
- ngrp--;
- }
- }
- else
- pc->pc_ucred->cr_ngroups = 1;
-
- setsugid(p);
- return (0);
-}
-
-int
-linux_getgroups(p, uap)
- struct proc *p;
- struct linux_getgroups_args *uap;
-{
- struct pcred *pc;
- linux_gid_t linux_gidset[NGROUPS];
- gid_t *bsd_gidset;
- int bsd_gidsetsz, ngrp, error;
-
- pc = p->p_cred;
- bsd_gidset = pc->pc_ucred->cr_groups;
- bsd_gidsetsz = pc->pc_ucred->cr_ngroups - 1;
-
- /*
- * cr_groups[0] holds egid. Returning the whole set
- * here will cause a duplicate. Exclude cr_groups[0]
- * to prevent that.
- */
-
- if ((ngrp = uap->gidsetsize) == 0) {
- p->p_retval[0] = bsd_gidsetsz;
- return (0);
- }
-
- if (ngrp < bsd_gidsetsz)
- return (EINVAL);
-
- ngrp = 0;
- while (ngrp < bsd_gidsetsz) {
- linux_gidset[ngrp] = bsd_gidset[ngrp + 1];
- ngrp++;
- }
-
- if ((error = copyout((caddr_t)linux_gidset, (caddr_t)uap->gidset,
- ngrp * sizeof(linux_gid_t))))
- return (error);
-
- p->p_retval[0] = ngrp;
- return (0);
-}
-
-int
-linux_setrlimit(p, uap)
- struct proc *p;
- struct linux_setrlimit_args *uap;
-{
- struct osetrlimit_args bsd;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): setrlimit(%d, %p)\n",
- (long)p->p_pid, uap->resource, (void *)uap->rlim);
-#endif
-
- if (uap->resource >= LINUX_RLIM_NLIMITS)
- return EINVAL;
-
- bsd.which = linux_to_bsd_resource[uap->resource];
-
- if (bsd.which == -1)
- return EINVAL;
-
- bsd.rlp = uap->rlim;
- return osetrlimit(p, &bsd);
-}
-
-int
-linux_getrlimit(p, uap)
- struct proc *p;
- struct linux_getrlimit_args *uap;
-{
- struct ogetrlimit_args bsd;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): getrlimit(%d, %p)\n",
- (long)p->p_pid, uap->resource, (void *)uap->rlim);
-#endif
-
- if (uap->resource >= LINUX_RLIM_NLIMITS)
- return EINVAL;
-
- bsd.which = linux_to_bsd_resource[uap->resource];
-
- if (bsd.which == -1)
- return EINVAL;
-
- bsd.rlp = uap->rlim;
- return ogetrlimit(p, &bsd);
-}
-
-int
-linux_sched_setscheduler(p, uap)
- struct proc *p;
- struct linux_sched_setscheduler_args *uap;
-{
- struct sched_setscheduler_args bsd;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): sched_setscheduler(%d, %d, %p)\n",
- (long)p->p_pid, uap->pid, uap->policy, (const void *)uap->param);
-#endif
-
- switch (uap->policy) {
- case LINUX_SCHED_OTHER:
- bsd.policy = SCHED_OTHER;
- break;
- case LINUX_SCHED_FIFO:
- bsd.policy = SCHED_FIFO;
- break;
- case LINUX_SCHED_RR:
- bsd.policy = SCHED_RR;
- break;
- default:
- return EINVAL;
- }
-
- bsd.pid = uap->pid;
- bsd.param = uap->param;
- return sched_setscheduler(p, &bsd);
-}
-
-int
-linux_sched_getscheduler(p, uap)
- struct proc *p;
- struct linux_sched_getscheduler_args *uap;
-{
- struct sched_getscheduler_args bsd;
- int error;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): sched_getscheduler(%d)\n",
- (long)p->p_pid, uap->pid);
-#endif
-
- bsd.pid = uap->pid;
- error = sched_getscheduler(p, &bsd);
-
- switch (p->p_retval[0]) {
- case SCHED_OTHER:
- p->p_retval[0] = LINUX_SCHED_OTHER;
- break;
- case SCHED_FIFO:
- p->p_retval[0] = LINUX_SCHED_FIFO;
- break;
- case SCHED_RR:
- p->p_retval[0] = LINUX_SCHED_RR;
- break;
- }
-
- return error;
-}
-
-struct linux_descriptor {
- unsigned int entry_number;
- unsigned long base_addr;
- unsigned int limit;
- unsigned int seg_32bit:1;
- unsigned int contents:2;
- unsigned int read_exec_only:1;
- unsigned int limit_in_pages:1;
- unsigned int seg_not_present:1;
- unsigned int useable:1;
-};
-
-int
-linux_modify_ldt(p, uap)
- struct proc *p;
- struct linux_modify_ldt_args *uap;
-{
- int error;
- caddr_t sg;
- struct sysarch_args args;
- struct i386_ldt_args *ldt;
- struct linux_descriptor ld;
- union descriptor *desc;
-
- sg = stackgap_init();
-
- if (uap->ptr == NULL)
- return (EINVAL);
-
- switch (uap->func) {
- case 0x00: /* read_ldt */
- ldt = stackgap_alloc(&sg, sizeof(*ldt));
- ldt->start = 0;
- ldt->descs = uap->ptr;
- ldt->num = uap->bytecount / sizeof(union descriptor);
- args.op = I386_GET_LDT;
- args.parms = (char*)ldt;
- error = sysarch(p, &args);
- p->p_retval[0] *= sizeof(union descriptor);
- break;
- case 0x01: /* write_ldt */
- case 0x11: /* write_ldt */
- if (uap->bytecount != sizeof(ld))
- return (EINVAL);
-
- error = copyin(uap->ptr, &ld, sizeof(ld));
- if (error)
- return (error);
-
- ldt = stackgap_alloc(&sg, sizeof(*ldt));
- desc = stackgap_alloc(&sg, sizeof(*desc));
- ldt->start = ld.entry_number;
- ldt->descs = desc;
- ldt->num = 1;
- desc->sd.sd_lolimit = (ld.limit & 0x0000ffff);
- desc->sd.sd_hilimit = (ld.limit & 0x000f0000) >> 16;
- desc->sd.sd_lobase = (ld.base_addr & 0x00ffffff);
- desc->sd.sd_hibase = (ld.base_addr & 0xff000000) >> 24;
- desc->sd.sd_type = SDT_MEMRO | ((ld.read_exec_only ^ 1) << 1) |
- (ld.contents << 2);
- desc->sd.sd_dpl = 3;
- desc->sd.sd_p = (ld.seg_not_present ^ 1);
- desc->sd.sd_xx = 0;
- desc->sd.sd_def32 = ld.seg_32bit;
- desc->sd.sd_gran = ld.limit_in_pages;
- args.op = I386_SET_LDT;
- args.parms = (char*)ldt;
- error = sysarch(p, &args);
- break;
- default:
- error = EINVAL;
- break;
- }
-
- if (error == EOPNOTSUPP) {
- printf("linux: modify_ldt needs kernel option USER_LDT\n");
- error = ENOSYS;
- }
-
- return (error);
-}
diff --git a/sys/compat/linux/linux_signal.c b/sys/compat/linux/linux_signal.c
deleted file mode 100644
index ba4c481e32e9..000000000000
--- a/sys/compat/linux/linux_signal.c
+++ /dev/null
@@ -1,555 +0,0 @@
-/*-
- * Copyright (c) 1994-1995 Søren Schmidt
- * 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
- * in this position and unchanged.
- * 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 withough 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/sysproto.h>
-#include <sys/proc.h>
-#include <sys/signalvar.h>
-
-#include <i386/linux/linux.h>
-#include <i386/linux/linux_proto.h>
-#include <i386/linux/linux_util.h>
-
-static void
-linux_to_bsd_sigset(linux_sigset_t *lss, sigset_t *bss)
-{
- int b, l;
-
- SIGEMPTYSET(*bss);
- bss->__bits[0] = lss->__bits[0] & ~((1U << LINUX_SIGTBLSZ) - 1);
- bss->__bits[1] = lss->__bits[1];
- for (l = 1; l <= LINUX_SIGTBLSZ; l++) {
- if (LINUX_SIGISMEMBER(*lss, l)) {
- b = linux_to_bsd_signal[_SIG_IDX(l)];
- if (b)
- SIGADDSET(*bss, b);
- }
- }
-}
-
-static void
-bsd_to_linux_sigset(sigset_t *bss, linux_sigset_t *lss)
-{
- int b, l;
-
- LINUX_SIGEMPTYSET(*lss);
- lss->__bits[0] = bss->__bits[0] & ~((1U << LINUX_SIGTBLSZ) - 1);
- lss->__bits[1] = bss->__bits[1];
- for (b = 1; b <= LINUX_SIGTBLSZ; b++) {
- if (SIGISMEMBER(*bss, b)) {
- l = bsd_to_linux_signal[_SIG_IDX(b)];
- if (l)
- LINUX_SIGADDSET(*lss, l);
- }
- }
-}
-
-static void
-linux_to_bsd_sigaction(linux_sigaction_t *lsa, struct sigaction *bsa)
-{
-
- linux_to_bsd_sigset(&lsa->lsa_mask, &bsa->sa_mask);
- bsa->sa_handler = lsa->lsa_handler;
- bsa->sa_flags = 0;
- if (lsa->lsa_flags & LINUX_SA_NOCLDSTOP)
- bsa->sa_flags |= SA_NOCLDSTOP;
- if (lsa->lsa_flags & LINUX_SA_NOCLDWAIT)
- bsa->sa_flags |= SA_NOCLDWAIT;
- if (lsa->lsa_flags & LINUX_SA_SIGINFO)
- bsa->sa_flags |= SA_SIGINFO;
- if (lsa->lsa_flags & LINUX_SA_ONSTACK)
- bsa->sa_flags |= SA_ONSTACK;
- if (lsa->lsa_flags & LINUX_SA_RESTART)
- bsa->sa_flags |= SA_RESTART;
- if (lsa->lsa_flags & LINUX_SA_ONESHOT)
- bsa->sa_flags |= SA_RESETHAND;
- if (lsa->lsa_flags & LINUX_SA_NOMASK)
- bsa->sa_flags |= SA_NODEFER;
-}
-
-static void
-bsd_to_linux_sigaction(struct sigaction *bsa, linux_sigaction_t *lsa)
-{
-
- bsd_to_linux_sigset(&bsa->sa_mask, &lsa->lsa_mask);
- lsa->lsa_handler = bsa->sa_handler;
- lsa->lsa_restorer = NULL; /* unsupported */
- lsa->lsa_flags = 0;
- if (bsa->sa_flags & SA_NOCLDSTOP)
- lsa->lsa_flags |= LINUX_SA_NOCLDSTOP;
- if (bsa->sa_flags & SA_NOCLDWAIT)
- lsa->lsa_flags |= LINUX_SA_NOCLDWAIT;
- if (bsa->sa_flags & SA_SIGINFO)
- lsa->lsa_flags |= LINUX_SA_SIGINFO;
- if (bsa->sa_flags & SA_ONSTACK)
- lsa->lsa_flags |= LINUX_SA_ONSTACK;
- if (bsa->sa_flags & SA_RESTART)
- lsa->lsa_flags |= LINUX_SA_RESTART;
- if (bsa->sa_flags & SA_RESETHAND)
- lsa->lsa_flags |= LINUX_SA_ONESHOT;
- if (bsa->sa_flags & SA_NODEFER)
- lsa->lsa_flags |= LINUX_SA_NOMASK;
-}
-
-static int
-linux_do_sigaction(struct proc *p, int linux_sig, linux_sigaction_t *linux_nsa,
- linux_sigaction_t *linux_osa)
-{
- struct sigaction *nsa, *osa;
- struct sigaction_args sa_args;
- int error;
- caddr_t sg = stackgap_init();
-
- if (linux_sig <= 0 || linux_sig > LINUX_NSIG)
- return (EINVAL);
-
- if (linux_osa != NULL)
- osa = stackgap_alloc(&sg, sizeof(struct sigaction));
- else
- osa = NULL;
-
- if (linux_nsa != NULL) {
- nsa = stackgap_alloc(&sg, sizeof(struct sigaction));
- linux_to_bsd_sigaction(linux_nsa, nsa);
- }
- else
- nsa = NULL;
-
- if (linux_sig <= LINUX_SIGTBLSZ)
- sa_args.sig = linux_to_bsd_signal[_SIG_IDX(linux_sig)];
- else
- sa_args.sig = linux_sig;
-
- sa_args.act = nsa;
- sa_args.oact = osa;
- error = sigaction(p, &sa_args);
- if (error)
- return (error);
-
- if (linux_osa != NULL)
- bsd_to_linux_sigaction(osa, linux_osa);
-
- return (0);
-}
-
-int
-linux_sigaction(struct proc *p, struct linux_sigaction_args *args)
-{
- linux_osigaction_t osa;
- linux_sigaction_t act, oact;
- int error;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): sigaction(%d, %p, %p)\n", (long)p->p_pid,
- args->sig, (void *)args->nsa, (void *)args->osa);
-#endif
-
- if (args->nsa != NULL) {
- error = copyin(args->nsa, &osa, sizeof(linux_osigaction_t));
- if (error)
- return (error);
- act.lsa_handler = osa.lsa_handler;
- act.lsa_flags = osa.lsa_flags;
- act.lsa_restorer = osa.lsa_restorer;
- LINUX_SIGEMPTYSET(act.lsa_mask);
- act.lsa_mask.__bits[0] = osa.lsa_mask;
- }
-
- error = linux_do_sigaction(p, args->sig,
- args->nsa ? &act : NULL,
- args->osa ? &oact : NULL);
-
- if (args->osa != NULL && !error) {
- osa.lsa_handler = oact.lsa_handler;
- osa.lsa_flags = oact.lsa_flags;
- osa.lsa_restorer = oact.lsa_restorer;
- osa.lsa_mask = oact.lsa_mask.__bits[0];
- error = copyout(&osa, args->osa, sizeof(linux_osigaction_t));
- }
-
- return (error);
-}
-
-int
-linux_signal(struct proc *p, struct linux_signal_args *args)
-{
- linux_sigaction_t nsa, osa;
- int error;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): signal(%d, %p)\n",
- (long)p->p_pid, args->sig, (void *)args->handler);
-#endif
-
- nsa.lsa_handler = args->handler;
- nsa.lsa_flags = LINUX_SA_ONESHOT | LINUX_SA_NOMASK;
- LINUX_SIGEMPTYSET(nsa.lsa_mask);
-
- error = linux_do_sigaction(p, args->sig, &nsa, &osa);
- p->p_retval[0] = (int)osa.lsa_handler;
-
- return (error);
-}
-
-int
-linux_rt_sigaction(struct proc *p, struct linux_rt_sigaction_args *args)
-{
- linux_sigaction_t nsa, osa;
- int error;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): rt_sigaction(%d, %p, %p, %d)\n",
- (long)p->p_pid, args->sig, (void *)args->act,
- (void *)args->oact, args->sigsetsize);
-#endif
-
- if (args->sigsetsize != sizeof(linux_sigset_t))
- return (EINVAL);
-
- if (args->act != NULL) {
- error = copyin(args->act, &nsa, sizeof(linux_sigaction_t));
- if (error)
- return (error);
- }
-
- error = linux_do_sigaction(p, args->sig,
- args->act ? &nsa : NULL,
- args->oact ? &osa : NULL);
-
- if (args->oact != NULL && !error) {
- error = copyout(&osa, args->oact, sizeof(linux_sigaction_t));
- }
-
- return (error);
-}
-
-static int
-linux_do_sigprocmask(struct proc *p, int how, linux_sigset_t *new,
- linux_sigset_t *old)
-{
- int error, s;
- sigset_t mask;
-
- error = 0;
- p->p_retval[0] = 0;
-
- if (old != NULL)
- bsd_to_linux_sigset(&p->p_sigmask, old);
-
- if (new != NULL) {
- linux_to_bsd_sigset(new, &mask);
-
- s = splhigh();
-
- switch (how) {
- case LINUX_SIG_BLOCK:
- SIGSETOR(p->p_sigmask, mask);
- SIG_CANTMASK(p->p_sigmask);
- break;
- case LINUX_SIG_UNBLOCK:
- SIGSETNAND(p->p_sigmask, mask);
- break;
- case LINUX_SIG_SETMASK:
- p->p_sigmask = mask;
- SIG_CANTMASK(p->p_sigmask);
- break;
- default:
- error = EINVAL;
- break;
- }
-
- splx(s);
- }
-
- return (error);
-}
-
-int
-linux_sigprocmask(struct proc *p, struct linux_sigprocmask_args *args)
-{
- linux_osigset_t mask;
- linux_sigset_t set, oset;
- int error;
-
-#ifdef DEBUG
- printf("Linux-emul(%d): sigprocmask(%d, *, *)\n", p->p_pid, args->how);
-#endif
-
- if (args->mask != NULL) {
- error = copyin(args->mask, &mask, sizeof(linux_osigset_t));
- if (error)
- return (error);
- LINUX_SIGEMPTYSET(set);
- set.__bits[0] = mask;
- }
-
- error = linux_do_sigprocmask(p, args->how,
- args->mask ? &set : NULL,
- args->omask ? &oset : NULL);
-
- if (args->omask != NULL && !error) {
- mask = oset.__bits[0];
- error = copyout(&mask, args->omask, sizeof(linux_osigset_t));
- }
-
- return (error);
-}
-
-int
-linux_rt_sigprocmask(struct proc *p, struct linux_rt_sigprocmask_args *args)
-{
- linux_sigset_t set, oset;
- int error;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): rt_sigprocmask(%d, %p, %p, %d)\n",
- (long)p->p_pid, args->how, (void *)args->mask,
- (void *)args->omask, args->sigsetsize);
-#endif
-
- if (args->sigsetsize != sizeof(linux_sigset_t))
- return EINVAL;
-
- if (args->mask != NULL) {
- error = copyin(args->mask, &set, sizeof(linux_sigset_t));
- if (error)
- return (error);
- }
-
- error = linux_do_sigprocmask(p, args->how,
- args->mask ? &set : NULL,
- args->omask ? &oset : NULL);
-
- if (args->omask != NULL && !error) {
- error = copyout(&oset, args->omask, sizeof(linux_sigset_t));
- }
-
- return (error);
-}
-
-int
-linux_siggetmask(struct proc *p, struct linux_siggetmask_args *args)
-{
- linux_sigset_t mask;
-
-#ifdef DEBUG
- printf("Linux-emul(%d): siggetmask()\n", p->p_pid);
-#endif
-
- bsd_to_linux_sigset(&p->p_sigmask, &mask);
- p->p_retval[0] = mask.__bits[0];
- return (0);
-}
-
-int
-linux_sigsetmask(struct proc *p, struct linux_sigsetmask_args *args)
-{
- linux_sigset_t lset;
- sigset_t bset;
- int s;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): sigsetmask(%08lx)\n",
- (long)p->p_pid, (unsigned long)args->mask);
-#endif
-
- bsd_to_linux_sigset(&p->p_sigmask, &lset);
- p->p_retval[0] = lset.__bits[0];
- LINUX_SIGEMPTYSET(lset);
- lset.__bits[0] = args->mask;
- linux_to_bsd_sigset(&lset, &bset);
- s = splhigh();
- p->p_sigmask = bset;
- SIG_CANTMASK(p->p_sigmask);
- splx(s);
- return (0);
-}
-
-int
-linux_sigpending(struct proc *p, struct linux_sigpending_args *args)
-{
- sigset_t bset;
- linux_sigset_t lset;
- linux_osigset_t mask;
-
-#ifdef DEBUG
- printf("Linux-emul(%d): sigpending(*)\n", p->p_pid);
-#endif
-
- bset = p->p_siglist;
- SIGSETAND(bset, p->p_sigmask);
- bsd_to_linux_sigset(&bset, &lset);
- mask = lset.__bits[0];
- return (copyout(&mask, args->mask, sizeof(mask)));
-}
-
-/*
- * Linux has two extra args, restart and oldmask. We dont use these,
- * but it seems that "restart" is actually a context pointer that
- * enables the signal to happen with a different register set.
- */
-int
-linux_sigsuspend(struct proc *p, struct linux_sigsuspend_args *args)
-{
- struct sigsuspend_args bsd;
- sigset_t *sigmask;
- linux_sigset_t mask;
- caddr_t sg = stackgap_init();
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): sigsuspend(%08lx)\n",
- (long)p->p_pid, (unsigned long)args->mask);
-#endif
-
- sigmask = stackgap_alloc(&sg, sizeof(sigset_t));
- LINUX_SIGEMPTYSET(mask);
- mask.__bits[0] = args->mask;
- linux_to_bsd_sigset(&mask, sigmask);
- bsd.sigmask = sigmask;
- return (sigsuspend(p, &bsd));
-}
-
-int
-linux_rt_sigsuspend(p, uap)
- struct proc *p;
- struct linux_rt_sigsuspend_args *uap;
-{
- linux_sigset_t lmask;
- sigset_t *bmask;
- struct sigsuspend_args bsd;
- caddr_t sg = stackgap_init();
- int error;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): rt_sigsuspend(%p, %d)\n", (long)p->p_pid,
- (void *)uap->newset, uap->sigsetsize);
-#endif
-
- if (uap->sigsetsize != sizeof(linux_sigset_t))
- return (EINVAL);
-
- error = copyin(uap->newset, &lmask, sizeof(linux_sigset_t));
- if (error)
- return (error);
-
- bmask = stackgap_alloc(&sg, sizeof(sigset_t));
- linux_to_bsd_sigset(&lmask, bmask);
- bsd.sigmask = bmask;
- return (sigsuspend(p, &bsd));
-}
-
-int
-linux_pause(struct proc *p, struct linux_pause_args *args)
-{
- struct sigsuspend_args bsd;
- sigset_t *sigmask;
- caddr_t sg = stackgap_init();
-
-#ifdef DEBUG
- printf("Linux-emul(%d): pause()\n", p->p_pid);
-#endif
-
- sigmask = stackgap_alloc(&sg, sizeof(sigset_t));
- *sigmask = p->p_sigmask;
- bsd.sigmask = sigmask;
- return sigsuspend(p, &bsd);
-}
-
-int
-linux_kill(struct proc *p, struct linux_kill_args *args)
-{
- struct kill_args /* {
- int pid;
- int signum;
- } */ tmp;
-
-#ifdef DEBUG
- printf("Linux-emul(%d): kill(%d, %d)\n",
- p->p_pid, args->pid, args->signum);
-#endif
-
- /*
- * Allow signal 0 as a means to check for privileges
- */
- if (args->signum < 0 || args->signum > LINUX_NSIG)
- return EINVAL;
-
- if (args->signum > 0 && args->signum <= LINUX_SIGTBLSZ)
- tmp.signum = linux_to_bsd_signal[_SIG_IDX(args->signum)];
- else
- tmp.signum = args->signum;
-
- tmp.pid = args->pid;
- return (kill(p, &tmp));
-}
-
-int
-linux_sigaltstack(p, uap)
- struct proc *p;
- struct linux_sigaltstack_args *uap;
-{
- struct sigaltstack_args bsd;
- stack_t *ss, *oss;
- linux_stack_t lss;
- int error;
- caddr_t sg = stackgap_init();
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): sigaltstack(%p, %p)\n",
- (long)p->p_pid, uap->uss, uap->uoss);
-#endif
-
- error = copyin(uap->uss, &lss, sizeof(linux_stack_t));
- if (error)
- return (error);
-
- ss = stackgap_alloc(&sg, sizeof(stack_t));
- ss->ss_sp = lss.ss_sp;
- ss->ss_size = lss.ss_size;
- ss->ss_flags = lss.ss_flags;
-
- oss = (uap->uoss != NULL)
- ? stackgap_alloc(&sg, sizeof(stack_t))
- : NULL;
-
- bsd.ss = ss;
- bsd.oss = oss;
- error = sigaltstack(p, &bsd);
-
- if (!error && oss != NULL) {
- lss.ss_sp = oss->ss_sp;
- lss.ss_size = oss->ss_size;
- lss.ss_flags = oss->ss_flags;
- error = copyout(&lss, uap->uoss, sizeof(linux_stack_t));
- }
-
- return (error);
-}
diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c
deleted file mode 100644
index d2be9b94f520..000000000000
--- a/sys/compat/linux/linux_socket.c
+++ /dev/null
@@ -1,874 +0,0 @@
-/*-
- * Copyright (c) 1995 Søren Schmidt
- * 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
- * in this position and unchanged.
- * 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 withough 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.
- *
- * $FreeBSD$
- */
-
-/* XXX we use functions that might not exist. */
-#include "opt_compat.h"
-
-#ifndef COMPAT_43
-#error "Unable to compile Linux-emulator due to missing COMPAT_43 option!"
-#endif
-
-#include <sys/param.h>
-#include <sys/proc.h>
-#include <sys/systm.h>
-#include <sys/sysproto.h>
-#include <sys/fcntl.h>
-#include <sys/socket.h>
-#include <sys/uio.h>
-
-#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-
-#include <i386/linux/linux.h>
-#include <i386/linux/linux_proto.h>
-#include <i386/linux/linux_util.h>
-
-static int
-linux_to_bsd_domain(int domain)
-{
- switch (domain) {
- case LINUX_AF_UNSPEC:
- return AF_UNSPEC;
- case LINUX_AF_UNIX:
- return AF_LOCAL;
- case LINUX_AF_INET:
- return AF_INET;
- case LINUX_AF_AX25:
- return AF_CCITT;
- case LINUX_AF_IPX:
- return AF_IPX;
- case LINUX_AF_APPLETALK:
- return AF_APPLETALK;
- default:
- return -1;
- }
-}
-
-static int
-linux_to_bsd_sockopt_level(int level)
-{
- switch (level) {
- case LINUX_SOL_SOCKET:
- return SOL_SOCKET;
- default:
- return level;
- }
-}
-
-static int linux_to_bsd_ip_sockopt(int opt)
-{
- switch (opt) {
- case LINUX_IP_TOS:
- return IP_TOS;
- case LINUX_IP_TTL:
- return IP_TTL;
- case LINUX_IP_OPTIONS:
- return IP_OPTIONS;
- case LINUX_IP_MULTICAST_IF:
- return IP_MULTICAST_IF;
- case LINUX_IP_MULTICAST_TTL:
- return IP_MULTICAST_TTL;
- case LINUX_IP_MULTICAST_LOOP:
- return IP_MULTICAST_LOOP;
- case LINUX_IP_ADD_MEMBERSHIP:
- return IP_ADD_MEMBERSHIP;
- case LINUX_IP_DROP_MEMBERSHIP:
- return IP_DROP_MEMBERSHIP;
- case LINUX_IP_HDRINCL:
- return IP_HDRINCL;
- default:
- return -1;
- }
-}
-
-static int
-linux_to_bsd_so_sockopt(int opt)
-{
- switch (opt) {
- case LINUX_SO_DEBUG:
- return SO_DEBUG;
- case LINUX_SO_REUSEADDR:
- return SO_REUSEADDR;
- case LINUX_SO_TYPE:
- return SO_TYPE;
- case LINUX_SO_ERROR:
- return SO_ERROR;
- case LINUX_SO_DONTROUTE:
- return SO_DONTROUTE;
- case LINUX_SO_BROADCAST:
- return SO_BROADCAST;
- case LINUX_SO_SNDBUF:
- return SO_SNDBUF;
- case LINUX_SO_RCVBUF:
- return SO_RCVBUF;
- case LINUX_SO_KEEPALIVE:
- return SO_KEEPALIVE;
- case LINUX_SO_OOBINLINE:
- return SO_OOBINLINE;
- case LINUX_SO_LINGER:
- return SO_LINGER;
- case LINUX_SO_PRIORITY:
- case LINUX_SO_NO_CHECK:
- default:
- return -1;
- }
-}
-
-/* Return 0 if IP_HDRINCL is set of the given socket, not 0 otherwise */
-static int
-linux_check_hdrincl(struct proc *p, int s)
-{
- struct getsockopt_args /* {
- int s;
- int level;
- int name;
- caddr_t val;
- int *avalsize;
- } */ bsd_args;
- int error;
- caddr_t sg, val, valsize;
- int size_val = sizeof val;
- int optval;
-
- sg = stackgap_init();
- val = stackgap_alloc(&sg, sizeof(int));
- valsize = stackgap_alloc(&sg, sizeof(int));
-
- if ((error=copyout(&size_val, valsize, sizeof(size_val))))
- return error;
- bsd_args.s = s;
- bsd_args.level = IPPROTO_IP;
- bsd_args.name = IP_HDRINCL;
- bsd_args.val = val;
- bsd_args.avalsize = (int *)valsize;
- if ((error=getsockopt(p, &bsd_args)))
- return error;
- if ((error=copyin(val, &optval, sizeof(optval))))
- return error;
- return optval == 0;
-}
-
-/*
- * Updated sendto() when IP_HDRINCL is set:
- * tweak endian-dependent fields in the IP packet.
- */
-static int
-linux_sendto_hdrincl(struct proc *p, struct sendto_args *bsd_args)
-{
-/*
- * linux_ip_copysize defines how many bytes we should copy
- * from the beginning of the IP packet before we customize it for BSD.
- * It should include all the fields we modify (ip_len and ip_off)
- * and be as small as possible to minimize copying overhead.
- */
-#define linux_ip_copysize 8
-
- caddr_t sg;
- struct ip *packet;
- struct msghdr *msg;
- struct iovec *iov;
-
- int error;
- struct sendmsg_args /* {
- int s;
- caddr_t msg;
- int flags;
- } */ sendmsg_args;
-
- /* Check the packet isn't too small before we mess with it */
- if (bsd_args->len < linux_ip_copysize)
- return EINVAL;
-
- /*
- * Tweaking the user buffer in place would be bad manners.
- * We create a corrected IP header with just the needed length,
- * then use an iovec to glue it to the rest of the user packet
- * when calling sendmsg().
- */
- sg = stackgap_init();
- packet = (struct ip *)stackgap_alloc(&sg, linux_ip_copysize);
- msg = (struct msghdr *)stackgap_alloc(&sg, sizeof(*msg));
- iov = (struct iovec *)stackgap_alloc(&sg, sizeof(*iov)*2);
-
- /* Make a copy of the beginning of the packet to be sent */
- if ((error = copyin(bsd_args->buf, (caddr_t)packet, linux_ip_copysize)))
- return error;
-
- /* Convert fields from Linux to BSD raw IP socket format */
- packet->ip_len = bsd_args->len;
- packet->ip_off = ntohs(packet->ip_off);
-
- /* Prepare the msghdr and iovec structures describing the new packet */
- msg->msg_name = bsd_args->to;
- msg->msg_namelen = bsd_args->tolen;
- msg->msg_iov = iov;
- msg->msg_iovlen = 2;
- msg->msg_control = NULL;
- msg->msg_controllen = 0;
- msg->msg_flags = 0;
- iov[0].iov_base = (char *)packet;
- iov[0].iov_len = linux_ip_copysize;
- iov[1].iov_base = (char *)(bsd_args->buf) + linux_ip_copysize;
- iov[1].iov_len = bsd_args->len - linux_ip_copysize;
-
- sendmsg_args.s = bsd_args->s;
- sendmsg_args.msg = (caddr_t)msg;
- sendmsg_args.flags = bsd_args->flags;
- return sendmsg(p, &sendmsg_args);
-}
-
-struct linux_socket_args {
- int domain;
- int type;
- int protocol;
-};
-
-static int
-linux_socket(struct proc *p, struct linux_socket_args *args)
-{
- struct linux_socket_args linux_args;
- struct socket_args /* {
- int domain;
- int type;
- int protocol;
- } */ bsd_args;
- int error;
- int retval_socket;
-
- if ((error=copyin((caddr_t)args, (caddr_t)&linux_args, sizeof(linux_args))))
- return error;
- bsd_args.protocol = linux_args.protocol;
- bsd_args.type = linux_args.type;
- bsd_args.domain = linux_to_bsd_domain(linux_args.domain);
- if (bsd_args.domain == -1)
- return EINVAL;
-
- retval_socket = socket(p, &bsd_args);
- if (bsd_args.type == SOCK_RAW
- && (bsd_args.protocol == IPPROTO_RAW || bsd_args.protocol == 0)
- && bsd_args.domain == AF_INET
- && retval_socket >= 0) {
- /* It's a raw IP socket: set the IP_HDRINCL option. */
- struct setsockopt_args /* {
- int s;
- int level;
- int name;
- caddr_t val;
- int valsize;
- } */ bsd_setsockopt_args;
- caddr_t sg;
- int *hdrincl;
-
- sg = stackgap_init();
- hdrincl = (int *)stackgap_alloc(&sg, sizeof(*hdrincl));
- *hdrincl = 1;
- bsd_setsockopt_args.s = p->p_retval[0];
- bsd_setsockopt_args.level = IPPROTO_IP;
- bsd_setsockopt_args.name = IP_HDRINCL;
- bsd_setsockopt_args.val = (caddr_t)hdrincl;
- bsd_setsockopt_args.valsize = sizeof(*hdrincl);
- /* We ignore any error returned by setsockopt() */
- setsockopt(p, &bsd_setsockopt_args);
- /* Copy back the return value from socket() */
- p->p_retval[0] = bsd_setsockopt_args.s;
- }
- return retval_socket;
-}
-
-struct linux_bind_args {
- int s;
- struct sockaddr *name;
- int namelen;
-};
-
-static int
-linux_bind(struct proc *p, struct linux_bind_args *args)
-{
- struct linux_bind_args linux_args;
- struct bind_args /* {
- int s;
- caddr_t name;
- int namelen;
- } */ bsd_args;
- int error;
-
- if ((error=copyin((caddr_t)args, (caddr_t)&linux_args, sizeof(linux_args))))
- return error;
- bsd_args.s = linux_args.s;
- bsd_args.name = (caddr_t)linux_args.name;
- bsd_args.namelen = linux_args.namelen;
- return bind(p, &bsd_args);
-}
-
-struct linux_connect_args {
- int s;
- struct sockaddr * name;
- int namelen;
-};
-
-static int
-linux_connect(struct proc *p, struct linux_connect_args *args)
-{
- struct linux_connect_args linux_args;
- struct connect_args /* {
- int s;
- caddr_t name;
- int namelen;
- } */ bsd_args;
- int error;
-
- if ((error=copyin((caddr_t)args, (caddr_t)&linux_args, sizeof(linux_args))))
- return error;
- bsd_args.s = linux_args.s;
- bsd_args.name = (caddr_t)linux_args.name;
- bsd_args.namelen = linux_args.namelen;
- error = connect(p, &bsd_args);
- if (error == EISCONN) {
- /*
- * Linux doesn't return EISCONN the first time it occurs,
- * when on a non-blocking socket. Instead it returns the
- * error getsockopt(SOL_SOCKET, SO_ERROR) would return on BSD.
- */
- struct fcntl_args /* {
- int fd;
- int cmd;
- int arg;
- } */ bsd_fcntl_args;
- struct getsockopt_args /* {
- int s;
- int level;
- int name;
- caddr_t val;
- int *avalsize;
- } */ bsd_getsockopt_args;
- void *status, *statusl;
- int stat, statl = sizeof stat;
- caddr_t sg;
-
- /* Check for non-blocking */
- bsd_fcntl_args.fd = linux_args.s;
- bsd_fcntl_args.cmd = F_GETFL;
- bsd_fcntl_args.arg = 0;
- error = fcntl(p, &bsd_fcntl_args);
- if (error == 0 && (p->p_retval[0] & O_NONBLOCK)) {
- sg = stackgap_init();
- status = stackgap_alloc(&sg, sizeof stat);
- statusl = stackgap_alloc(&sg, sizeof statusl);
-
- if ((error = copyout(&statl, statusl, sizeof statl)))
- return error;
-
- bsd_getsockopt_args.s = linux_args.s;
- bsd_getsockopt_args.level = SOL_SOCKET;
- bsd_getsockopt_args.name = SO_ERROR;
- bsd_getsockopt_args.val = status;
- bsd_getsockopt_args.avalsize = statusl;
-
- error = getsockopt(p, &bsd_getsockopt_args);
- if (error)
- return error;
- if ((error = copyin(status, &stat, sizeof stat)))
- return error;
- p->p_retval[0] = stat;
- return 0;
- }
- }
- return error;
-}
-
-struct linux_listen_args {
- int s;
- int backlog;
-};
-
-static int
-linux_listen(struct proc *p, struct linux_listen_args *args)
-{
- struct linux_listen_args linux_args;
- struct listen_args /* {
- int s;
- int backlog;
- } */ bsd_args;
- int error;
-
- if ((error=copyin((caddr_t)args, (caddr_t)&linux_args, sizeof(linux_args))))
- return error;
- bsd_args.s = linux_args.s;
- bsd_args.backlog = linux_args.backlog;
- return listen(p, &bsd_args);
-}
-
-struct linux_accept_args {
- int s;
- struct sockaddr *addr;
- int *namelen;
-};
-
-static int
-linux_accept(struct proc *p, struct linux_accept_args *args)
-{
- struct linux_accept_args linux_args;
- struct accept_args /* {
- int s;
- caddr_t name;
- int *anamelen;
- } */ bsd_args;
- struct fcntl_args /* {
- int fd;
- int cmd;
- long arg;
- } */ f_args;
- int error;
-
- if ((error=copyin((caddr_t)args, (caddr_t)&linux_args, sizeof(linux_args))))
- return error;
- bsd_args.s = linux_args.s;
- bsd_args.name = (caddr_t)linux_args.addr;
- bsd_args.anamelen = linux_args.namelen;
- error = oaccept(p, &bsd_args);
- if (error)
- return (error);
-
- /*
- * linux appears not to copy flags from the parent socket to the
- * accepted one, so we must clear the flags in the new descriptor.
- * Ignore any errors, because we already have an open fd.
- */
- f_args.fd = p->p_retval[0];
- f_args.cmd = F_SETFL;
- f_args.arg = 0;
- (void)fcntl(p, &f_args);
- p->p_retval[0] = f_args.fd;
- return (0);
-}
-
-struct linux_getsockname_args {
- int s;
- struct sockaddr *addr;
- int *namelen;
-};
-
-static int
-linux_getsockname(struct proc *p, struct linux_getsockname_args *args)
-{
- struct linux_getsockname_args linux_args;
- struct getsockname_args /* {
- int fdes;
- caddr_t asa;
- int *alen;
- } */ bsd_args;
- int error;
-
- if ((error=copyin((caddr_t)args, (caddr_t)&linux_args, sizeof(linux_args))))
- return error;
- bsd_args.fdes = linux_args.s;
- bsd_args.asa = (caddr_t) linux_args.addr;
- bsd_args.alen = linux_args.namelen;
- return ogetsockname(p, &bsd_args);
-}
-
-struct linux_getpeername_args {
- int s;
- struct sockaddr *addr;
- int *namelen;
-};
-
-static int
-linux_getpeername(struct proc *p, struct linux_getpeername_args *args)
-{
- struct linux_getpeername_args linux_args;
- struct ogetpeername_args /* {
- int fdes;
- caddr_t asa;
- int *alen;
- } */ bsd_args;
- int error;
-
- if ((error=copyin((caddr_t)args, (caddr_t)&linux_args, sizeof(linux_args))))
- return error;
- bsd_args.fdes = linux_args.s;
- bsd_args.asa = (caddr_t) linux_args.addr;
- bsd_args.alen = linux_args.namelen;
- return ogetpeername(p, &bsd_args);
-}
-
-struct linux_socketpair_args {
- int domain;
- int type;
- int protocol;
- int *rsv;
-};
-
-static int
-linux_socketpair(struct proc *p, struct linux_socketpair_args *args)
-{
- struct linux_socketpair_args linux_args;
- struct socketpair_args /* {
- int domain;
- int type;
- int protocol;
- int *rsv;
- } */ bsd_args;
- int error;
-
- if ((error=copyin((caddr_t)args, (caddr_t)&linux_args, sizeof(linux_args))))
- return error;
- bsd_args.domain = linux_to_bsd_domain(linux_args.domain);
- if (bsd_args.domain == -1)
- return EINVAL;
- bsd_args.type = linux_args.type;
- bsd_args.protocol = linux_args.protocol;
- bsd_args.rsv = linux_args.rsv;
- return socketpair(p, &bsd_args);
-}
-
-struct linux_send_args {
- int s;
- void *msg;
- int len;
- int flags;
-};
-
-static int
-linux_send(struct proc *p, struct linux_send_args *args)
-{
- struct linux_send_args linux_args;
- struct osend_args /* {
- int s;
- caddr_t buf;
- int len;
- int flags;
- } */ bsd_args;
- int error;
-
- if ((error=copyin((caddr_t)args, (caddr_t)&linux_args, sizeof(linux_args))))
- return error;
- bsd_args.s = linux_args.s;
- bsd_args.buf = linux_args.msg;
- bsd_args.len = linux_args.len;
- bsd_args.flags = linux_args.flags;
- return osend(p, &bsd_args);
-}
-
-struct linux_recv_args {
- int s;
- void *msg;
- int len;
- int flags;
-};
-
-static int
-linux_recv(struct proc *p, struct linux_recv_args *args)
-{
- struct linux_recv_args linux_args;
- struct orecv_args /* {
- int s;
- caddr_t buf;
- int len;
- int flags;
- } */ bsd_args;
- int error;
-
- if ((error=copyin((caddr_t)args, (caddr_t)&linux_args, sizeof(linux_args))))
- return error;
- bsd_args.s = linux_args.s;
- bsd_args.buf = linux_args.msg;
- bsd_args.len = linux_args.len;
- bsd_args.flags = linux_args.flags;
- return orecv(p, &bsd_args);
-}
-
-struct linux_sendto_args {
- int s;
- void *msg;
- int len;
- int flags;
- caddr_t to;
- int tolen;
-};
-
-static int
-linux_sendto(struct proc *p, struct linux_sendto_args *args)
-{
- struct linux_sendto_args linux_args;
- struct sendto_args /* {
- int s;
- caddr_t buf;
- size_t len;
- int flags;
- caddr_t to;
- int tolen;
- } */ bsd_args;
- int error;
-
- if ((error=copyin((caddr_t)args, (caddr_t)&linux_args, sizeof(linux_args))))
- return error;
- bsd_args.s = linux_args.s;
- bsd_args.buf = linux_args.msg;
- bsd_args.len = linux_args.len;
- bsd_args.flags = linux_args.flags;
- bsd_args.to = linux_args.to;
- bsd_args.tolen = linux_args.tolen;
-
- if (linux_check_hdrincl(p, linux_args.s) == 0)
- /* IP_HDRINCL set, tweak the packet before sending */
- return linux_sendto_hdrincl(p, &bsd_args);
-
- return sendto(p, &bsd_args);
-}
-
-struct linux_recvfrom_args {
- int s;
- void *buf;
- int len;
- int flags;
- caddr_t from;
- int *fromlen;
-};
-
-static int
-linux_recvfrom(struct proc *p, struct linux_recvfrom_args *args)
-{
- struct linux_recvfrom_args linux_args;
- struct recvfrom_args /* {
- int s;
- caddr_t buf;
- size_t len;
- int flags;
- caddr_t from;
- int *fromlenaddr;
- } */ bsd_args;
- int error;
-
- if ((error=copyin((caddr_t)args, (caddr_t)&linux_args, sizeof(linux_args))))
- return error;
- bsd_args.s = linux_args.s;
- bsd_args.buf = linux_args.buf;
- bsd_args.len = linux_args.len;
- bsd_args.flags = linux_args.flags;
- bsd_args.from = linux_args.from;
- bsd_args.fromlenaddr = linux_args.fromlen;
- return orecvfrom(p, &bsd_args);
-}
-
-struct linux_shutdown_args {
- int s;
- int how;
-};
-
-static int
-linux_shutdown(struct proc *p, struct linux_shutdown_args *args)
-{
- struct linux_shutdown_args linux_args;
- struct shutdown_args /* {
- int s;
- int how;
- } */ bsd_args;
- int error;
-
- if ((error=copyin((caddr_t)args, (caddr_t)&linux_args, sizeof(linux_args))))
- return error;
- bsd_args.s = linux_args.s;
- bsd_args.how = linux_args.how;
- return shutdown(p, &bsd_args);
-}
-
-struct linux_setsockopt_args {
- int s;
- int level;
- int optname;
- void *optval;
- int optlen;
-};
-
-static int
-linux_setsockopt(struct proc *p, struct linux_setsockopt_args *args)
-{
- struct linux_setsockopt_args linux_args;
- struct setsockopt_args /* {
- int s;
- int level;
- int name;
- caddr_t val;
- int valsize;
- } */ bsd_args;
- int error, name;
-
- if ((error=copyin((caddr_t)args, (caddr_t)&linux_args, sizeof(linux_args))))
- return error;
- bsd_args.s = linux_args.s;
- bsd_args.level = linux_to_bsd_sockopt_level(linux_args.level);
- switch (bsd_args.level) {
- case SOL_SOCKET:
- name = linux_to_bsd_so_sockopt(linux_args.optname);
- break;
- case IPPROTO_IP:
- name = linux_to_bsd_ip_sockopt(linux_args.optname);
- break;
- case IPPROTO_TCP:
- /* Linux TCP option values match BSD's */
- name = linux_args.optname;
- break;
- default:
- return EINVAL;
- }
- if (name == -1)
- return EINVAL;
- bsd_args.name = name;
- bsd_args.val = linux_args.optval;
- bsd_args.valsize = linux_args.optlen;
- return setsockopt(p, &bsd_args);
-}
-
-struct linux_getsockopt_args {
- int s;
- int level;
- int optname;
- void *optval;
- int *optlen;
-};
-
-static int
-linux_getsockopt(struct proc *p, struct linux_getsockopt_args *args)
-{
- struct linux_getsockopt_args linux_args;
- struct getsockopt_args /* {
- int s;
- int level;
- int name;
- caddr_t val;
- int *avalsize;
- } */ bsd_args;
- int error, name;
-
- if ((error=copyin((caddr_t)args, (caddr_t)&linux_args, sizeof(linux_args))))
- return error;
- bsd_args.s = linux_args.s;
- bsd_args.level = linux_to_bsd_sockopt_level(linux_args.level);
- switch (bsd_args.level) {
- case SOL_SOCKET:
- name = linux_to_bsd_so_sockopt(linux_args.optname);
- break;
- case IPPROTO_IP:
- name = linux_to_bsd_ip_sockopt(linux_args.optname);
- break;
- case IPPROTO_TCP:
- /* Linux TCP option values match BSD's */
- name = linux_args.optname;
- break;
- default:
- return EINVAL;
- }
- if (name == -1)
- return EINVAL;
- bsd_args.name = name;
- bsd_args.val = linux_args.optval;
- bsd_args.avalsize = linux_args.optlen;
- return getsockopt(p, &bsd_args);
-}
-
-int
-linux_socketcall(struct proc *p, struct linux_socketcall_args *args)
-{
- switch (args->what) {
- case LINUX_SOCKET:
- return linux_socket(p, args->args);
- case LINUX_BIND:
- return linux_bind(p, args->args);
- case LINUX_CONNECT:
- return linux_connect(p, args->args);
- case LINUX_LISTEN:
- return linux_listen(p, args->args);
- case LINUX_ACCEPT:
- return linux_accept(p, args->args);
- case LINUX_GETSOCKNAME:
- return linux_getsockname(p, args->args);
- case LINUX_GETPEERNAME:
- return linux_getpeername(p, args->args);
- case LINUX_SOCKETPAIR:
- return linux_socketpair(p, args->args);
- case LINUX_SEND:
- return linux_send(p, args->args);
- case LINUX_RECV:
- return linux_recv(p, args->args);
- case LINUX_SENDTO:
- return linux_sendto(p, args->args);
- case LINUX_RECVFROM:
- return linux_recvfrom(p, args->args);
- case LINUX_SHUTDOWN:
- return linux_shutdown(p, args->args);
- case LINUX_SETSOCKOPT:
- return linux_setsockopt(p, args->args);
- case LINUX_GETSOCKOPT:
- return linux_getsockopt(p, args->args);
- case LINUX_SENDMSG:
- do {
- int error;
- int level;
- caddr_t control;
- struct {
- int s;
- const struct msghdr *msg;
- int flags;
- } *uap = args->args;
-
- error = copyin(&uap->msg->msg_control,
- &control, sizeof(caddr_t));
- if (error)
- return error;
- if (control == NULL)
- goto done;
- error = copyin(&((struct cmsghdr *)control)->cmsg_level,
- &level, sizeof(int));
- if (error)
- return error;
- if (level == 1) {
- /*
- * Linux thinks that SOL_SOCKET is 1; we know that it's really
- * 0xffff, of course.
- */
- level = SOL_SOCKET;
- error = copyout(&level, &((struct cmsghdr *)control)->
- cmsg_level, sizeof(int));
- if (error)
- return error;
- }
- done:
- return sendmsg(p, args->args);
- } while (0);
- case LINUX_RECVMSG:
- return recvmsg(p, args->args);
-
- default:
- uprintf("LINUX: 'socket' typ=%d not implemented\n", args->what);
- return ENOSYS;
- }
-}
diff --git a/sys/compat/linux/linux_stats.c b/sys/compat/linux/linux_stats.c
deleted file mode 100644
index 501ef15e5401..000000000000
--- a/sys/compat/linux/linux_stats.c
+++ /dev/null
@@ -1,379 +0,0 @@
-/*-
- * Copyright (c) 1994-1995 Søren Schmidt
- * 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
- * in this position and unchanged.
- * 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 withough 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/conf.h>
-#include <sys/dirent.h>
-#include <sys/file.h>
-#include <sys/filedesc.h>
-#include <sys/proc.h>
-#include <sys/mount.h>
-#include <sys/namei.h>
-#include <sys/stat.h>
-#include <sys/systm.h>
-#include <sys/vnode.h>
-
-#include <i386/linux/linux.h>
-#include <i386/linux/linux_proto.h>
-#include <i386/linux/linux_util.h>
-
-#include <vm/vm_zone.h>
-
-struct linux_newstat {
- u_short stat_dev;
- u_short __pad1;
- u_long stat_ino;
- u_short stat_mode;
- u_short stat_nlink;
- u_short stat_uid;
- u_short stat_gid;
- u_short stat_rdev;
- u_short __pad2;
- u_long stat_size;
- u_long stat_blksize;
- u_long stat_blocks;
- u_long stat_atime;
- u_long __unused1;
- u_long stat_mtime;
- u_long __unused2;
- u_long stat_ctime;
- u_long __unused3;
- u_long __unused4;
- u_long __unused5;
-};
-
-struct linux_ustat
-{
- int f_tfree;
- u_long f_tinode;
- char f_fname[6];
- char f_fpack[6];
-};
-
-static int
-newstat_copyout(struct stat *buf, void *ubuf)
-{
- struct linux_newstat tbuf;
-
- tbuf.stat_dev = uminor(buf->st_dev) | (umajor(buf->st_dev) << 8);
- tbuf.stat_ino = buf->st_ino;
- tbuf.stat_mode = buf->st_mode;
- tbuf.stat_nlink = buf->st_nlink;
- tbuf.stat_uid = buf->st_uid;
- tbuf.stat_gid = buf->st_gid;
- tbuf.stat_rdev = buf->st_rdev;
- tbuf.stat_size = buf->st_size;
- tbuf.stat_atime = buf->st_atime;
- tbuf.stat_mtime = buf->st_mtime;
- tbuf.stat_ctime = buf->st_ctime;
- tbuf.stat_blksize = buf->st_blksize;
- tbuf.stat_blocks = buf->st_blocks;
-
- return (copyout(&tbuf, ubuf, sizeof(tbuf)));
-}
-
-int
-linux_newstat(struct proc *p, struct linux_newstat_args *args)
-{
- struct stat buf;
- struct nameidata nd;
- int error;
- caddr_t sg;
-
- sg = stackgap_init();
- CHECKALTEXIST(p, &sg, args->path);
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): newstat(%s, *)\n", (long)p->p_pid,
- args->path);
-#endif
-
- NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE,
- args->path, p);
- error = namei(&nd);
- if (error)
- return (error);
- NDFREE(&nd, NDF_ONLY_PNBUF);
-
- error = vn_stat(nd.ni_vp, &buf, p);
- vput(nd.ni_vp);
- if (error)
- return (error);
-
- return (newstat_copyout(&buf, args->buf));
-}
-
-/*
- * Get file status; this version does not follow links.
- */
-int
-linux_newlstat(p, uap)
- struct proc *p;
- struct linux_newlstat_args *uap;
-{
- int error;
- struct vnode *vp;
- struct stat sb;
- struct nameidata nd;
- caddr_t sg;
-
- sg = stackgap_init();
- CHECKALTEXIST(p, &sg, uap->path);
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): newlstat(%s, *)\n", (long)p->p_pid,
- uap->path);
-#endif
-
- NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE,
- uap->path, p);
- error = namei(&nd);
- if (error)
- return (error);
- NDFREE(&nd, NDF_ONLY_PNBUF);
-
- vp = nd.ni_vp;
- error = vn_stat(vp, &sb, p);
- vput(vp);
- if (error)
- return (error);
-
- return (newstat_copyout(&sb, uap->buf));
-}
-
-int
-linux_newfstat(struct proc *p, struct linux_newfstat_args *args)
-{
- struct filedesc *fdp;
- struct file *fp;
- struct stat buf;
- int error;
-
- fdp = p->p_fd;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): newfstat(%d, *)\n", (long)p->p_pid, args->fd);
-#endif
-
- if ((unsigned)args->fd >= fdp->fd_nfiles ||
- (fp = fdp->fd_ofiles[args->fd]) == NULL)
- return (EBADF);
-
- error = fo_stat(fp, &buf, p);
- if (!error)
- error = newstat_copyout(&buf, args->buf);
-
- return (error);
-}
-
-struct linux_statfs_buf {
- long ftype;
- long fbsize;
- long fblocks;
- long fbfree;
- long fbavail;
- long ffiles;
- long fffree;
- linux_fsid_t ffsid;
- long fnamelen;
- long fspare[6];
-};
-
-#ifndef VT_NWFS
-#define VT_NWFS VT_TFS /* XXX - bug compatibility with sys/nwfs/nwfs_node.h */
-#endif
-
-#define LINUX_CODA_SUPER_MAGIC 0x73757245L
-#define LINUX_EXT2_SUPER_MAGIC 0xEF53L
-#define LINUX_HPFS_SUPER_MAGIC 0xf995e849L
-#define LINUX_ISOFS_SUPER_MAGIC 0x9660L
-#define LINUX_MSDOS_SUPER_MAGIC 0x4d44L
-#define LINUX_NCP_SUPER_MAGIC 0x564cL
-#define LINUX_NFS_SUPER_MAGIC 0x6969L
-#define LINUX_NTFS_SUPER_MAGIC 0x5346544EL
-#define LINUX_PROC_SUPER_MAGIC 0x9fa0L
-#define LINUX_UFS_SUPER_MAGIC 0x00011954L /* XXX - UFS_MAGIC in Linux */
-
-/*
- * ext2fs uses the VT_UFS tag. A mounted ext2 filesystem will therefore
- * be seen as an ufs/mfs filesystem.
- */
-static long
-bsd_to_linux_ftype(int tag)
-{
-
- switch (tag) {
- case VT_CODA:
- return (LINUX_CODA_SUPER_MAGIC);
- case VT_HPFS:
- return (LINUX_HPFS_SUPER_MAGIC);
- case VT_ISOFS:
- return (LINUX_ISOFS_SUPER_MAGIC);
- case VT_MFS:
- return (LINUX_UFS_SUPER_MAGIC);
- case VT_MSDOSFS:
- return (LINUX_MSDOS_SUPER_MAGIC);
- case VT_NFS:
- return (LINUX_NFS_SUPER_MAGIC);
- case VT_NTFS:
- return (LINUX_NTFS_SUPER_MAGIC);
- case VT_NWFS:
- return (LINUX_NCP_SUPER_MAGIC);
- case VT_PROCFS:
- return (LINUX_PROC_SUPER_MAGIC);
- case VT_UFS:
- return (LINUX_UFS_SUPER_MAGIC);
- }
-
- return (0L);
-}
-
-int
-linux_statfs(struct proc *p, struct linux_statfs_args *args)
-{
- struct mount *mp;
- struct nameidata *ndp;
- struct statfs *bsd_statfs;
- struct nameidata nd;
- struct linux_statfs_buf linux_statfs_buf;
- int error;
- caddr_t sg;
-
- sg = stackgap_init();
- CHECKALTEXIST(p, &sg, args->path);
-
-#ifdef DEBUG
- printf("Linux-emul(%d): statfs(%s, *)\n", p->p_pid, args->path);
-#endif
- ndp = &nd;
- NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args->path, curproc);
- error = namei(ndp);
- if (error)
- return error;
- NDFREE(ndp, NDF_ONLY_PNBUF);
- mp = ndp->ni_vp->v_mount;
- bsd_statfs = &mp->mnt_stat;
- vrele(ndp->ni_vp);
- error = VFS_STATFS(mp, bsd_statfs, p);
- if (error)
- return error;
- bsd_statfs->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
- linux_statfs_buf.ftype = bsd_to_linux_ftype(bsd_statfs->f_type);
- linux_statfs_buf.fbsize = bsd_statfs->f_bsize;
- linux_statfs_buf.fblocks = bsd_statfs->f_blocks;
- linux_statfs_buf.fbfree = bsd_statfs->f_bfree;
- linux_statfs_buf.fbavail = bsd_statfs->f_bavail;
- linux_statfs_buf.fffree = bsd_statfs->f_ffree;
- linux_statfs_buf.ffiles = bsd_statfs->f_files;
- linux_statfs_buf.ffsid.val[0] = bsd_statfs->f_fsid.val[0];
- linux_statfs_buf.ffsid.val[1] = bsd_statfs->f_fsid.val[1];
- linux_statfs_buf.fnamelen = MAXNAMLEN;
- return copyout((caddr_t)&linux_statfs_buf, (caddr_t)args->buf,
- sizeof(struct linux_statfs_buf));
-}
-
-int
-linux_fstatfs(struct proc *p, struct linux_fstatfs_args *args)
-{
- struct file *fp;
- struct mount *mp;
- struct statfs *bsd_statfs;
- struct linux_statfs_buf linux_statfs_buf;
- int error;
-
-#ifdef DEBUG
- printf("Linux-emul(%d): fstatfs(%d, *)\n", p->p_pid, args->fd);
-#endif
- error = getvnode(p->p_fd, args->fd, &fp);
- if (error)
- return error;
- mp = ((struct vnode *)fp->f_data)->v_mount;
- bsd_statfs = &mp->mnt_stat;
- error = VFS_STATFS(mp, bsd_statfs, p);
- if (error)
- return error;
- bsd_statfs->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
- linux_statfs_buf.ftype = bsd_to_linux_ftype(bsd_statfs->f_type);
- linux_statfs_buf.fbsize = bsd_statfs->f_bsize;
- linux_statfs_buf.fblocks = bsd_statfs->f_blocks;
- linux_statfs_buf.fbfree = bsd_statfs->f_bfree;
- linux_statfs_buf.fbavail = bsd_statfs->f_bavail;
- linux_statfs_buf.fffree = bsd_statfs->f_ffree;
- linux_statfs_buf.ffiles = bsd_statfs->f_files;
- linux_statfs_buf.ffsid.val[0] = bsd_statfs->f_fsid.val[0];
- linux_statfs_buf.ffsid.val[1] = bsd_statfs->f_fsid.val[1];
- linux_statfs_buf.fnamelen = MAXNAMLEN;
- return copyout((caddr_t)&linux_statfs_buf, (caddr_t)args->buf,
- sizeof(struct linux_statfs_buf));
-}
-
-int
-linux_ustat(p, uap)
- struct proc *p;
- struct linux_ustat_args *uap;
-{
- struct linux_ustat lu;
- dev_t dev;
- struct vnode *vp;
- struct statfs *stat;
- int error;
-
-#ifdef DEBUG
- printf("Linux-emul(%ld): ustat(%d, *)\n", (long)p->p_pid, uap->dev);
-#endif
-
- /*
- * lu.f_fname and lu.f_fpack are not used. They are always zeroed.
- * lu.f_tinode and lu.f_tfree are set from the device's super block.
- */
- bzero(&lu, sizeof(lu));
-
- /*
- * XXX - Don't return an error if we can't find a vnode for the
- * device. Our dev_t is 32-bits whereas Linux only has a 16-bits
- * dev_t. The dev_t that is used now may as well be a truncated
- * dev_t returned from previous syscalls. Just return a bzeroed
- * ustat in that case.
- */
- dev = makebdev(uap->dev >> 8, uap->dev & 0xFF);
- if (vfinddev(dev, VBLK, &vp)) {
- if (vp->v_mount == NULL)
- return (EINVAL);
- stat = &(vp->v_mount->mnt_stat);
- error = VFS_STATFS(vp->v_mount, stat, p);
- if (error)
- return (error);
-
- lu.f_tfree = stat->f_bfree;
- lu.f_tinode = stat->f_ffree;
- }
-
- return (copyout(&lu, uap->ubuf, sizeof(lu)));
-}
diff --git a/sys/compat/linux/linux_util.c b/sys/compat/linux/linux_util.c
deleted file mode 100644
index 0864ae7caac8..000000000000
--- a/sys/compat/linux/linux_util.c
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Copyright (c) 1994 Christos Zoulas
- * Copyright (c) 1995 Frank van der Linden
- * Copyright (c) 1995 Scott Bartram
- * 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.
- *
- * from: svr4_util.c,v 1.5 1995/01/22 23:44:50 christos Exp
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/namei.h>
-#include <sys/proc.h>
-#include <sys/malloc.h>
-#include <sys/vnode.h>
-
-#include <i386/linux/linux_util.h>
-
-#include <vm/vm_zone.h>
-
-const char linux_emul_path[] = "/compat/linux";
-
-/*
- * Search an alternate path before passing pathname arguments on
- * to system calls. Useful for keeping a seperate 'emulation tree'.
- *
- * If cflag is set, we check if an attempt can be made to create
- * the named file, i.e. we check if the directory it should
- * be in exists.
- */
-int
-linux_emul_find(p, sgp, prefix, path, pbuf, cflag)
- struct proc *p;
- caddr_t *sgp; /* Pointer to stackgap memory */
- const char *prefix;
- char *path;
- char **pbuf;
- int cflag;
-{
- struct nameidata nd;
- struct nameidata ndroot;
- struct vattr vat;
- struct vattr vatroot;
- int error;
- char *ptr, *buf, *cp;
- size_t sz, len;
-
- buf = (char *) malloc(MAXPATHLEN, M_TEMP, M_WAITOK);
- *pbuf = path;
-
- for (ptr = buf; (*ptr = *prefix) != '\0'; ptr++, prefix++)
- continue;
-
- sz = MAXPATHLEN - (ptr - buf);
-
- /*
- * If sgp is not given then the path is already in kernel space
- */
- if (sgp == NULL)
- error = copystr(path, ptr, sz, &len);
- else
- error = copyinstr(path, ptr, sz, &len);
-
- if (error) {
- free(buf, M_TEMP);
- return error;
- }
-
- if (*ptr != '/') {
- free(buf, M_TEMP);
- return EINVAL;
- }
-
- /*
- * We know that there is a / somewhere in this pathname.
- * Search backwards for it, to find the file's parent dir
- * to see if it exists in the alternate tree. If it does,
- * and we want to create a file (cflag is set). We don't
- * need to worry about the root comparison in this case.
- */
-
- if (cflag) {
- for (cp = &ptr[len] - 1; *cp != '/'; cp--);
- *cp = '\0';
-
- NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, buf, p);
-
- if ((error = namei(&nd)) != 0) {
- free(buf, M_TEMP);
- return error;
- }
-
- *cp = '/';
- }
- else {
- NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, buf, p);
-
- if ((error = namei(&nd)) != 0) {
- free(buf, M_TEMP);
- return error;
- }
-
- /*
- * We now compare the vnode of the linux_root to the one
- * vnode asked. If they resolve to be the same, then we
- * ignore the match so that the real root gets used.
- * This avoids the problem of traversing "../.." to find the
- * root directory and never finding it, because "/" resolves
- * to the emulation root directory. This is expensive :-(
- */
- NDINIT(&ndroot, LOOKUP, FOLLOW, UIO_SYSSPACE, linux_emul_path,
- p);
-
- if ((error = namei(&ndroot)) != 0) {
- /* Cannot happen! */
- free(buf, M_TEMP);
- NDFREE(&nd, NDF_ONLY_PNBUF);
- vrele(nd.ni_vp);
- return error;
- }
-
- if ((error = VOP_GETATTR(nd.ni_vp, &vat, p->p_ucred, p)) != 0) {
- goto bad;
- }
-
- if ((error = VOP_GETATTR(ndroot.ni_vp, &vatroot, p->p_ucred, p))
- != 0) {
- goto bad;
- }
-
- if (vat.va_fsid == vatroot.va_fsid &&
- vat.va_fileid == vatroot.va_fileid) {
- error = ENOENT;
- goto bad;
- }
-
- }
- if (sgp == NULL)
- *pbuf = buf;
- else {
- sz = &ptr[len] - buf;
- *pbuf = stackgap_alloc(sgp, sz + 1);
- error = copyout(buf, *pbuf, sz);
- free(buf, M_TEMP);
- }
-
- NDFREE(&nd, NDF_ONLY_PNBUF);
- vrele(nd.ni_vp);
- if (!cflag) {
- NDFREE(&ndroot, NDF_ONLY_PNBUF);
- vrele(ndroot.ni_vp);
- }
- return error;
-
-bad:
- NDFREE(&ndroot, NDF_ONLY_PNBUF);
- vrele(ndroot.ni_vp);
- NDFREE(&nd, NDF_ONLY_PNBUF);
- vrele(nd.ni_vp);
- free(buf, M_TEMP);
- return error;
-}
diff --git a/sys/compat/linux/linux_util.h b/sys/compat/linux/linux_util.h
deleted file mode 100644
index f8775fbf44c8..000000000000
--- a/sys/compat/linux/linux_util.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (c) 1994 Christos Zoulas
- * Copyright (c) 1995 Frank van der Linden
- * Copyright (c) 1995 Scott Bartram
- * 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.
- *
- * from: svr4_util.h,v 1.5 1994/11/18 02:54:31 christos Exp
- * from: linux_util.h,v 1.2 1995/03/05 23:23:50 fvdl Exp
- * $FreeBSD$
- */
-
-/*
- * This file is pretty much the same as Christos' svr4_util.h
- * (for now).
- */
-
-#ifndef _LINUX_UTIL_H_
-#define _LINUX_UTIL_H_
-
-#include "opt_linux.h"
-
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <vm/pmap.h>
-#include <machine/vmparam.h>
-#include <sys/exec.h>
-#include <sys/sysent.h>
-#include <sys/cdefs.h>
-
-#ifndef SCARG
-#define SCARG(p, x) (p)->x
-#endif
-
-static __inline caddr_t stackgap_init(void);
-static __inline void *stackgap_alloc(caddr_t *, size_t);
-
-static __inline caddr_t
-stackgap_init()
-{
-#define szsigcode (*(curproc->p_sysent->sv_szsigcode))
- return (caddr_t)(PS_STRINGS - szsigcode - SPARE_USRSPACE);
-}
-
-
-static __inline void *
-stackgap_alloc(sgp, sz)
- caddr_t *sgp;
- size_t sz;
-{
- void *p = (void *) *sgp;
- *sgp += ALIGN(sz);
- return p;
-}
-
-#ifdef DEBUG_LINUX
-#define DPRINTF(a) printf a;
-#else
-#define DPRINTF(a)
-#endif
-
-extern const char linux_emul_path[];
-
-int linux_emul_find __P((struct proc *, caddr_t *, const char *, char *,
- char **, int));
-
-#define CHECKALT(p, sgp, path, i) \
- do { \
- int _error; \
- \
- _error = linux_emul_find(p, sgp, linux_emul_path, path, \
- &path, i); \
- if (_error == EFAULT) \
- return (_error); \
- } while (0)
-
-#define CHECKALTEXIST(p, sgp, path) CHECKALT(p, sgp, path, 0)
-#define CHECKALTCREAT(p, sgp, path) CHECKALT(p, sgp, path, 1)
-
-#endif /* !_LINUX_UTIL_H_ */
diff --git a/sys/compat/netbsd/dvcfg.h b/sys/compat/netbsd/dvcfg.h
deleted file mode 100644
index 0ac75d9ccdb9..000000000000
--- a/sys/compat/netbsd/dvcfg.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/* $NetBSD$ */
-/*
- * [NetBSD for NEC PC98 series]
- * Copyright (c) 1996 NetBSD/pc98 porting staff.
- * 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.
- */
-/*
- * Copyright (c) 1996 Naofumi HONDA. All rights reserved.
- */
-
-#ifndef _I386_DVCFG_H_
-#define _I386_DVCFG_H_
-
-typedef void *dvcfg_hw_t;
-
-struct dvcfg_hwsel {
- int cfg_max;
-
- dvcfg_hw_t *cfg_sel;
-};
-
-#define DVCFG_MAJOR(dvcfg) (((u_int)(dvcfg)) >> 16)
-#define DVCFG_MINOR(dvcfg) (((u_int)(dvcfg)) & 0xffff)
-
-#define DVCFG_MKCFG(major, minor) ((((u_int)(major)) << 16) | ((minor) & 0xffff))
-
-#define DVCFG_HWSEL_SZ(array) (sizeof(array) / sizeof(dvcfg_hw_t))
-
-static __inline dvcfg_hw_t dvcfg_hw __P((struct dvcfg_hwsel *, u_int));
-
-static __inline dvcfg_hw_t
-dvcfg_hw(selp, num)
- struct dvcfg_hwsel *selp;
- u_int num;
-{
-
- return ((num >= selp->cfg_max) ? 0 : selp->cfg_sel[num]);
-}
-
-#define DVCFG_HW(SELP, NUM) dvcfg_hw((SELP), (NUM))
-#endif /* _I386_DVCFG_H_ */
diff --git a/sys/compat/svr4/Makefile b/sys/compat/svr4/Makefile
deleted file mode 100644
index c8fcdb5206da..000000000000
--- a/sys/compat/svr4/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-# Makefile for syscall tables
-#
-# $FreeBSD$
-
-MAINTAINER= newton@freebsd.org
-
-all:
- @echo "make svr4_sysent.c only"
-
-svr4_sysent.c svr4_syscall.h svr4_proto.h: ../kern/makesyscalls.sh \
- syscalls.master syscalls.conf
- -mv -f svr4_sysent.c svr4_sysent.c.bak
- -mv -f svr4_syscall.h svr4_syscall.h.bak
- -mv -f svr4_proto.h svr4_proto.h.bak
- sh ../kern/makesyscalls.sh syscalls.master syscalls.conf
diff --git a/sys/compat/svr4/imgact_svr4.c b/sys/compat/svr4/imgact_svr4.c
deleted file mode 100644
index 7dc0d635c4d9..000000000000
--- a/sys/compat/svr4/imgact_svr4.c
+++ /dev/null
@@ -1,235 +0,0 @@
-/*-
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1994-1996 Søren Schmidt
- * All rights reserved.
- *
- * Based heavily on /sys/kern/imgact_aout.c which is:
- * Copyright (c) 1993, David Greenman
- *
- * 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
- * in this position and unchanged.
- * 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 withough 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/resourcevar.h>
-#include <sys/exec.h>
-#include <sys/mman.h>
-#include <sys/imgact.h>
-#include <sys/imgact_aout.h>
-#include <sys/kernel.h>
-#include <sys/lock.h>
-#include <sys/proc.h>
-#include <sys/vnode.h>
-
-#include <vm/vm.h>
-#include <vm/vm_kern.h>
-#include <vm/vm_param.h>
-#include <vm/pmap.h>
-#include <vm/vm_map.h>
-#include <vm/vm_extern.h>
-
-#include <svr4/svr4.h>
-
-static int exec_svr4_imgact __P((struct image_params *iparams));
-
-static int
-exec_svr4_imgact(imgp)
- struct image_params *imgp;
-{
- const struct exec *a_out = (const struct exec *) imgp->image_header;
- struct vmspace *vmspace;
- vm_offset_t vmaddr;
- unsigned long virtual_offset, file_offset;
- vm_offset_t buffer;
- unsigned long bss_size;
- int error;
-
- if (((a_out->a_magic >> 16) & 0xff) != 0x64)
- return -1;
-
- /*
- * Set file/virtual offset based on a.out variant.
- */
- switch ((int)(a_out->a_magic & 0xffff)) {
- case 0413:
- virtual_offset = 0;
- file_offset = 1024;
- break;
- case 0314:
- virtual_offset = 4096;
- file_offset = 0;
- break;
- default:
- return (-1);
- }
- bss_size = round_page(a_out->a_bss);
-#ifdef DEBUG
- printf("imgact: text: %08x, data: %08x, bss: %08x\n", a_out->a_text, a_out->a_data, bss_size);
-#endif
-
- /*
- * Check various fields in header for validity/bounds.
- */
- if (a_out->a_entry < virtual_offset ||
- a_out->a_entry >= virtual_offset + a_out->a_text ||
- a_out->a_text & PAGE_MASK || a_out->a_data & PAGE_MASK)
- return (-1);
-
- /* text + data can't exceed file size */
- if (a_out->a_data + a_out->a_text > imgp->attr->va_size)
- return (EFAULT);
- /*
- * text/data/bss must not exceed limits
- */
- if (a_out->a_text > MAXTSIZ ||
- a_out->a_data + bss_size > imgp->proc->p_rlimit[RLIMIT_DATA].rlim_cur)
- return (ENOMEM);
-
- /* copy in arguments and/or environment from old process */
- error = exec_extract_strings(imgp);
- if (error)
- return (error);
-
- /*
- * Destroy old process VM and create a new one (with a new stack)
- */
- exec_new_vmspace(imgp);
- vmspace = imgp->proc->p_vmspace;
-
- /*
- * Check if file_offset page aligned,.
- * Currently we cannot handle misalinged file offsets,
- * and so we read in the entire image (what a waste).
- */
- if (file_offset & PAGE_MASK) {
-#ifdef DEBUG
- printf("imgact: Non page aligned binary %d\n", file_offset);
-#endif
- /*
- * Map text+data+bss read/write/execute
- */
- vmaddr = virtual_offset;
- error = vm_map_find(&vmspace->vm_map, NULL, 0, &vmaddr,
- a_out->a_text + a_out->a_data + bss_size, FALSE,
- VM_PROT_ALL, VM_PROT_ALL, 0);
- if (error)
- return error;
-
- error = vm_mmap(kernel_map, &buffer,
- round_page(a_out->a_text + a_out->a_data + file_offset),
- VM_PROT_READ, VM_PROT_READ, 0,
- (caddr_t) imgp->vp, trunc_page(file_offset));
- if (error)
- return error;
-
- error = copyout((caddr_t)(buffer + file_offset), (caddr_t)vmaddr,
- a_out->a_text + a_out->a_data);
-
- vm_map_remove(kernel_map, buffer,
- buffer + round_page(a_out->a_text + a_out->a_data + file_offset));
-
- if (error)
- return error;
-
- /*
- * remove write enable on the 'text' part
- */
- error = vm_map_protect(&vmspace->vm_map,
- vmaddr,
- vmaddr + a_out->a_text,
- VM_PROT_EXECUTE|VM_PROT_READ,
- TRUE);
- if (error)
- return error;
- }
- else {
-#ifdef DEBUG
- printf("imgact: Page aligned binary %d\n", file_offset);
-#endif
- /*
- * Map text+data read/execute
- */
- vmaddr = virtual_offset;
- error = vm_mmap(&vmspace->vm_map, &vmaddr,
- a_out->a_text + a_out->a_data,
- VM_PROT_READ | VM_PROT_EXECUTE,
- VM_PROT_ALL,
- MAP_PRIVATE | MAP_FIXED,
- (caddr_t)imgp->vp, file_offset);
- if (error)
- return (error);
-
-#ifdef DEBUG
- printf("imgact: startaddr=%08x, length=%08x\n", vmaddr, a_out->a_text + a_out->a_data);
-#endif
- /*
- * allow read/write of data
- */
- error = vm_map_protect(&vmspace->vm_map,
- vmaddr + a_out->a_text,
- vmaddr + a_out->a_text + a_out->a_data,
- VM_PROT_ALL,
- FALSE);
- if (error)
- return (error);
-
- /*
- * Allocate anon demand-zeroed area for uninitialized data
- */
- if (bss_size != 0) {
- vmaddr = virtual_offset + a_out->a_text + a_out->a_data;
- error = vm_map_find(&vmspace->vm_map, NULL, 0, &vmaddr,
- bss_size, FALSE, VM_PROT_ALL, VM_PROT_ALL, 0);
- if (error)
- return (error);
-#ifdef DEBUG
- printf("imgact: bssaddr=%08x, length=%08x\n", vmaddr, bss_size);
-#endif
-
- }
- /* Indicate that this file should not be modified */
- imgp->vp->v_flag |= VTEXT;
- }
- /* Fill in process VM information */
- vmspace->vm_tsize = round_page(a_out->a_text) >> PAGE_SHIFT;
- vmspace->vm_dsize = round_page(a_out->a_data + bss_size) >> PAGE_SHIFT;
- vmspace->vm_taddr = (caddr_t)virtual_offset;
- vmspace->vm_daddr = (caddr_t)virtual_offset + a_out->a_text;
-
- /* Fill in image_params */
- imgp->interpreted = 0;
- imgp->entry_addr = a_out->a_entry;
-
- imgp->proc->p_sysent = &svr4_sysvec;
- return (0);
-}
-
-/*
- * Tell kern_execve.c about it, with a little help from the linker.
- */
-struct execsw svr4_execsw = { exec_svr4_imgact, "svr4 ELF" };
-EXEC_SET(execsw_set, svr4_execsw);
-
diff --git a/sys/compat/svr4/svr4.h b/sys/compat/svr4/svr4.h
deleted file mode 100644
index 4fbace6e2c26..000000000000
--- a/sys/compat/svr4/svr4.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * 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.
- *
- * $FreeBSD$
- */
-
-#include "opt_svr4.h"
-
-#if !defined(_SVR4_H)
-#define _SVR4_H
-
-extern struct sysentvec svr4_sysvec;
-
-#define memset(x,y,z) bzero(x,z)
-
-#define COMPAT_SVR4_SOLARIS2
-#define KTRACE
-
-/* These are currently unimplemented (see svr4_ipc.c) */
-#if defined(SYSVMSG)
-# undef SYSVMSG
-#endif
-#if defined(SYSVSHM)
-# undef SYSVSHM
-#endif
-#if defined(SYSVSEM)
-# undef SYSVSEM
-#endif
-
-#endif
diff --git a/sys/compat/svr4/svr4_acl.h b/sys/compat/svr4/svr4_acl.h
deleted file mode 100644
index 6d9454f65ecd..000000000000
--- a/sys/compat/svr4/svr4_acl.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1996 Christos Zoulas.
- * 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 Christos Zoulas.
- * 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.
- *
- * $FreeBSD$
- */
-#ifndef _SVR4_ACL_H_
-#define _SVR4_ACL_H_
-
-typedef struct svr4_aclent {
- int a_type;
- svr4_uid_t a_id;
- svr4_o_mode_t a_perm;
-} svr4_aclent_t;
-
-#define SVR4_SYS_GETACL 1
-#define SVR4_SYS_SETACL 2
-#define SVR4_SYS_GETACLCNT 3
-
-#endif /* !_SVR4_ACL_H_ */
diff --git a/sys/compat/svr4/svr4_dirent.h b/sys/compat/svr4/svr4_dirent.h
deleted file mode 100644
index 244078227888..000000000000
--- a/sys/compat/svr4/svr4_dirent.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1994 Christos Zoulas
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _SVR4_DIRENT_H_
-#define _SVR4_DIRENT_H_
-
-#define SVR4_MAXNAMLEN 512
-
-struct svr4_dirent {
- svr4_ino_t d_ino;
- svr4_off_t d_off;
- u_short d_reclen;
- char d_name[SVR4_MAXNAMLEN + 1];
-};
-
-struct svr4_dirent64 {
- svr4_ino64_t d_ino;
- svr4_off64_t d_off;
- u_short d_reclen;
- char d_name[SVR4_MAXNAMLEN + 1];
-};
-
-#define SVR4_NAMEOFF(dp) ((char *)&(dp)->d_name - (char *)dp)
-#define SVR4_RECLEN(de,namlen) ALIGN((SVR4_NAMEOFF(de) + (namlen) + 1))
-
-#endif /* !_SVR4_DIRENT_H_ */
diff --git a/sys/compat/svr4/svr4_errno.h b/sys/compat/svr4/svr4_errno.h
deleted file mode 100644
index cc39929acfd5..000000000000
--- a/sys/compat/svr4/svr4_errno.h
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1994 Christos Zoulas
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _SVR4_ERRNO_H_
-#define _SVR4_ERRNO_H_
-
-#define SVR4_EPERM 1
-#define SVR4_ENOENT 2
-#define SVR4_ESRCH 3
-#define SVR4_EINTR 4
-#define SVR4_EIO 5
-#define SVR4_ENXIO 6
-#define SVR4_E2BIG 7
-#define SVR4_ENOEXEC 8
-#define SVR4_EBADF 9
-#define SVR4_ECHILD 10
-#define SVR4_EAGAIN 11
-#define SVR4_ENOMEM 12
-#define SVR4_EACCES 13
-#define SVR4_EFAULT 14
-#define SVR4_ENOTBLK 15
-#define SVR4_EBUSY 16
-#define SVR4_EEXIST 17
-#define SVR4_EXDEV 18
-#define SVR4_ENODEV 19
-#define SVR4_ENOTDIR 20
-#define SVR4_EISDIR 21
-#define SVR4_EINVAL 22
-#define SVR4_ENFILE 23
-#define SVR4_EMFILE 24
-#define SVR4_ENOTTY 25
-#define SVR4_ETXTBSY 26
-#define SVR4_EFBIG 27
-#define SVR4_ENOSPC 28
-#define SVR4_ESPIPE 29
-#define SVR4_EROFS 30
-#define SVR4_EMLINK 31
-#define SVR4_EPIPE 32
-#define SVR4_EDOM 33
-#define SVR4_ERANGE 34
-#define SVR4_ENOMSG 35
-#define SVR4_EIDRM 36
-#define SVR4_ECHRNG 37
-#define SVR4_EL2NSYNC 38
-#define SVR4_EL3HLT 39
-#define SVR4_EL3RST 40
-#define SVR4_ELNRNG 41
-#define SVR4_EUNATCH 42
-#define SVR4_ENOCSI 43
-#define SVR4_EL2HLT 44
-#define SVR4_EDEADLK 45
-#define SVR4_ENOLCK 46
-#define SVR4_EBADE 50
-#define SVR4_EBADR 51
-#define SVR4_EXFULL 52
-#define SVR4_ENOANO 53
-#define SVR4_EBADRQC 54
-#define SVR4_EBADSLT 55
-#define SVR4_EDEADLOCK 56
-#define SVR4_EBFONT 57
-#define SVR4_ENOSTR 60
-#define SVR4_ENODATA 61
-#define SVR4_ETIME 62
-#define SVR4_ENOSR 63
-#define SVR4_ENONET 64
-#define SVR4_ENOPKG 65
-#define SVR4_EREMOTE 66
-#define SVR4_ENOLINK 67
-#define SVR4_EADV 68
-#define SVR4_ESRMNT 69
-#define SVR4_ECOMM 70
-#define SVR4_EPROTO 71
-#define SVR4_EMULTIHOP 74
-#define SVR4_EBADMSG 77
-#define SVR4_ENAMETOOLONG 78
-#define SVR4_EOVERFLOW 79
-#define SVR4_ENOTUNIQ 80
-#define SVR4_EBADFD 81
-#define SVR4_EREMCHG 82
-#define SVR4_ELIBACC 83
-#define SVR4_ELIBBAD 84
-#define SVR4_ELIBSCN 85
-#define SVR4_ELIBMAX 86
-#define SVR4_ELIBEXEC 87
-#define SVR4_EILSEQ 88
-#define SVR4_ENOSYS 89
-#define SVR4_ELOOP 90
-#define SVR4_ERESTART 91
-#define SVR4_ESTRPIPE 92
-#define SVR4_ENOTEMPTY 93
-#define SVR4_EUSERS 94
-#define SVR4_ENOTSOCK 95
-#define SVR4_EDESTADDRREQ 96
-#define SVR4_EMSGSIZE 97
-#define SVR4_EPROTOTYPE 98
-#define SVR4_ENOPROTOOPT 99
-#define SVR4_EPROTONOSUPPORT 120
-#define SVR4_ESOCKTNOSUPPORT 121
-#define SVR4_EOPNOTSUPP 122
-#define SVR4_EPFNOSUPPORT 123
-#define SVR4_EAFNOSUPPORT 124
-#define SVR4_EADDRINUSE 125
-#define SVR4_EADDRNOTAVAIL 126
-#define SVR4_ENETDOWN 127
-#define SVR4_ENETUNREACH 128
-#define SVR4_ENETRESET 129
-#define SVR4_ECONNABORTED 130
-#define SVR4_ECONNRESET 131
-#define SVR4_ENOBUFS 132
-#define SVR4_EISCONN 133
-#define SVR4_ENOTCONN 134
-#define SVR4_EUCLEAN 135
-#define SVR4_ENOTNAM 137
-#define SVR4_ENAVAIL 138
-#define SVR4_EISNAM 139
-#define SVR4_EREMOTEIO 140
-#define SVR4_EINIT 141
-#define SVR4_EREMDEV 142
-#define SVR4_ESHUTDOWN 143
-#define SVR4_ETOOMANYREFS 144
-#define SVR4_ETIMEDOUT 145
-#define SVR4_ECONNREFUSED 146
-#define SVR4_EHOSTDOWN 147
-#define SVR4_EHOSTUNREACH 148
-#define SVR4_EWOULDBLOCK SVR4_EAGAIN
-#define SVR4_EALREADY 149
-#define SVR4_EINPROGRESS 150
-#define SVR4_ESTALE 151
-#define SVR4_EIORESID 500
-
-/*
- * These ones are not translated...
- */
-#define SVR4_EPROCLIM SVR4_ENOSYS
-#define SVR4_EDQUOT SVR4_ENOSYS
-#define SVR4_EBADRPC SVR4_ENOSYS
-#define SVR4_ERPCMISMATCH SVR4_ENOSYS
-#define SVR4_EPROGUNAVAIL SVR4_ENOSYS
-#define SVR4_EPROGMISMATCH SVR4_ENOSYS
-#define SVR4_EPROCUNAVAIL SVR4_ENOSYS
-#define SVR4_EFTYPE SVR4_ENOSYS
-#define SVR4_EAUTH SVR4_ENOSYS
-#define SVR4_ENEEDAUTH SVR4_ENOSYS
-
-#endif /* !_SVR4_ERRNO_H_ */
diff --git a/sys/compat/svr4/svr4_exec.h b/sys/compat/svr4/svr4_exec.h
deleted file mode 100644
index 716dad18924a..000000000000
--- a/sys/compat/svr4/svr4_exec.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1994 Christos Zoulas
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _SVR4_EXEC_H_
-#define _SVR4_EXEC_H_
-
-#ifdef SVR4_COMPAT_SOLARIS2
-# define SVR4_AUX_ARGSIZ (sizeof(AuxInfo) * 12 / sizeof(char *))
-#else
-# define SVR4_AUX_ARGSIZ (sizeof(AuxInfo) * 8 / sizeof(char *))
-#endif
-
-#if 0
-/* Don't think we need all this NetBSD stuff */
-/*
- * The following is horrible; there must be a better way. I need to
- * play with brk(2) a bit more.
- */
-#ifdef i386
-/*
- * I cannot load the interpreter after the data segment because brk(2)
- * breaks. I have to load it somewhere before. Programs start at
- * 0x08000000 so I load the interpreter far before.
- */
-#define SVR4_INTERP_ADDR 0x01000000
-#endif
-
-#ifdef sparc
-/*
- * Here programs load at 0x00010000, so I load the interpreter far after
- * the end of the data segment.
- */
-#define SVR4_INTERP_ADDR 0x10000000
-#endif
-
-#ifndef SVR4_INTERP_ADDR
-# define SVR4_INTERP_ADDR 0
-#endif
-#endif
-
-/*void svr4_setregs __P((struct proc *, struct exec_package *, u_long));*/
-
-#endif /* !_SVR4_EXEC_H_ */
diff --git a/sys/compat/svr4/svr4_fcntl.c b/sys/compat/svr4/svr4_fcntl.c
deleted file mode 100644
index abff2da2c5b8..000000000000
--- a/sys/compat/svr4/svr4_fcntl.c
+++ /dev/null
@@ -1,716 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1994, 1997 Christos Zoulas.
- * 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 Christos Zoulas.
- * 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.
- *
- * $FreeBSD$
- */
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/namei.h>
-#include <sys/proc.h>
-#include <sys/file.h>
-#include <sys/stat.h>
-#include <sys/filedesc.h>
-/*#include <sys/ioctl.h>*/
-#include <sys/kernel.h>
-#include <sys/mount.h>
-#include <sys/malloc.h>
-#include <sys/vnode.h>
-#include <sys/unistd.h>
-
-#include <sys/sysproto.h>
-
-#include <svr4/svr4.h>
-#include <svr4/svr4_types.h>
-#include <svr4/svr4_signal.h>
-#include <svr4/svr4_proto.h>
-#include <svr4/svr4_util.h>
-#include <svr4/svr4_fcntl.h>
-
-static int svr4_to_bsd_flags __P((int));
-static u_long svr4_to_bsd_cmd __P((u_long));
-static int fd_revoke __P((struct proc *, int));
-static int fd_truncate __P((struct proc *, int, struct flock *));
-static int bsd_to_svr4_flags __P((int));
-static void bsd_to_svr4_flock __P((struct flock *, struct svr4_flock *));
-static void svr4_to_bsd_flock __P((struct svr4_flock *, struct flock *));
-static void bsd_to_svr4_flock64 __P((struct flock *, struct svr4_flock64 *));
-static void svr4_to_bsd_flock64 __P((struct svr4_flock64 *, struct flock *));
-
-static u_long
-svr4_to_bsd_cmd(cmd)
- u_long cmd;
-{
- switch (cmd) {
- case SVR4_F_DUPFD:
- return F_DUPFD;
- case SVR4_F_GETFD:
- return F_GETFD;
- case SVR4_F_SETFD:
- return F_SETFD;
- case SVR4_F_GETFL:
- return F_GETFL;
- case SVR4_F_SETFL:
- return F_SETFL;
- case SVR4_F_GETLK:
- return F_GETLK;
- case SVR4_F_SETLK:
- return F_SETLK;
- case SVR4_F_SETLKW:
- return F_SETLKW;
- default:
- return -1;
- }
-}
-
-static int
-svr4_to_bsd_flags(l)
- int l;
-{
- int r = 0;
- r |= (l & SVR4_O_RDONLY) ? O_RDONLY : 0;
- r |= (l & SVR4_O_WRONLY) ? O_WRONLY : 0;
- r |= (l & SVR4_O_RDWR) ? O_RDWR : 0;
- r |= (l & SVR4_O_NDELAY) ? O_NONBLOCK : 0;
- r |= (l & SVR4_O_APPEND) ? O_APPEND : 0;
- r |= (l & SVR4_O_SYNC) ? O_FSYNC : 0;
- r |= (l & SVR4_O_NONBLOCK) ? O_NONBLOCK : 0;
- r |= (l & SVR4_O_PRIV) ? O_EXLOCK : 0;
- r |= (l & SVR4_O_CREAT) ? O_CREAT : 0;
- r |= (l & SVR4_O_TRUNC) ? O_TRUNC : 0;
- r |= (l & SVR4_O_EXCL) ? O_EXCL : 0;
- r |= (l & SVR4_O_NOCTTY) ? O_NOCTTY : 0;
- return r;
-}
-
-static int
-bsd_to_svr4_flags(l)
- int l;
-{
- int r = 0;
- r |= (l & O_RDONLY) ? SVR4_O_RDONLY : 0;
- r |= (l & O_WRONLY) ? SVR4_O_WRONLY : 0;
- r |= (l & O_RDWR) ? SVR4_O_RDWR : 0;
- r |= (l & O_NDELAY) ? SVR4_O_NONBLOCK : 0;
- r |= (l & O_APPEND) ? SVR4_O_APPEND : 0;
- r |= (l & O_FSYNC) ? SVR4_O_SYNC : 0;
- r |= (l & O_NONBLOCK) ? SVR4_O_NONBLOCK : 0;
- r |= (l & O_EXLOCK) ? SVR4_O_PRIV : 0;
- r |= (l & O_CREAT) ? SVR4_O_CREAT : 0;
- r |= (l & O_TRUNC) ? SVR4_O_TRUNC : 0;
- r |= (l & O_EXCL) ? SVR4_O_EXCL : 0;
- r |= (l & O_NOCTTY) ? SVR4_O_NOCTTY : 0;
- return r;
-}
-
-
-static void
-bsd_to_svr4_flock(iflp, oflp)
- struct flock *iflp;
- struct svr4_flock *oflp;
-{
- switch (iflp->l_type) {
- case F_RDLCK:
- oflp->l_type = SVR4_F_RDLCK;
- break;
- case F_WRLCK:
- oflp->l_type = SVR4_F_WRLCK;
- break;
- case F_UNLCK:
- oflp->l_type = SVR4_F_UNLCK;
- break;
- default:
- oflp->l_type = -1;
- break;
- }
-
- oflp->l_whence = (short) iflp->l_whence;
- oflp->l_start = (svr4_off_t) iflp->l_start;
- oflp->l_len = (svr4_off_t) iflp->l_len;
- oflp->l_sysid = 0;
- oflp->l_pid = (svr4_pid_t) iflp->l_pid;
-}
-
-
-static void
-svr4_to_bsd_flock(iflp, oflp)
- struct svr4_flock *iflp;
- struct flock *oflp;
-{
- switch (iflp->l_type) {
- case SVR4_F_RDLCK:
- oflp->l_type = F_RDLCK;
- break;
- case SVR4_F_WRLCK:
- oflp->l_type = F_WRLCK;
- break;
- case SVR4_F_UNLCK:
- oflp->l_type = F_UNLCK;
- break;
- default:
- oflp->l_type = -1;
- break;
- }
-
- oflp->l_whence = iflp->l_whence;
- oflp->l_start = (off_t) iflp->l_start;
- oflp->l_len = (off_t) iflp->l_len;
- oflp->l_pid = (pid_t) iflp->l_pid;
-
-}
-
-static void
-bsd_to_svr4_flock64(iflp, oflp)
- struct flock *iflp;
- struct svr4_flock64 *oflp;
-{
- switch (iflp->l_type) {
- case F_RDLCK:
- oflp->l_type = SVR4_F_RDLCK;
- break;
- case F_WRLCK:
- oflp->l_type = SVR4_F_WRLCK;
- break;
- case F_UNLCK:
- oflp->l_type = SVR4_F_UNLCK;
- break;
- default:
- oflp->l_type = -1;
- break;
- }
-
- oflp->l_whence = (short) iflp->l_whence;
- oflp->l_start = (svr4_off64_t) iflp->l_start;
- oflp->l_len = (svr4_off64_t) iflp->l_len;
- oflp->l_sysid = 0;
- oflp->l_pid = (svr4_pid_t) iflp->l_pid;
-}
-
-
-static void
-svr4_to_bsd_flock64(iflp, oflp)
- struct svr4_flock64 *iflp;
- struct flock *oflp;
-{
- switch (iflp->l_type) {
- case SVR4_F_RDLCK:
- oflp->l_type = F_RDLCK;
- break;
- case SVR4_F_WRLCK:
- oflp->l_type = F_WRLCK;
- break;
- case SVR4_F_UNLCK:
- oflp->l_type = F_UNLCK;
- break;
- default:
- oflp->l_type = -1;
- break;
- }
-
- oflp->l_whence = iflp->l_whence;
- oflp->l_start = (off_t) iflp->l_start;
- oflp->l_len = (off_t) iflp->l_len;
- oflp->l_pid = (pid_t) iflp->l_pid;
-
-}
-
-
-static int
-fd_revoke(p, fd)
- struct proc *p;
- int fd;
-{
- struct filedesc *fdp = p->p_fd;
- struct file *fp;
- struct vnode *vp;
- struct vattr vattr;
- int error, *retval;
-
- retval = p->p_retval;
- if ((u_int)fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[fd]) == NULL)
- return EBADF;
-
- if (fp->f_type != DTYPE_VNODE)
- return EINVAL;
-
- vp = (struct vnode *) fp->f_data;
-
- if (vp->v_type != VCHR && vp->v_type != VBLK) {
- error = EINVAL;
- goto out;
- }
-
- if ((error = VOP_GETATTR(vp, &vattr, p->p_ucred, p)) != 0)
- goto out;
-
- if (p->p_ucred->cr_uid != vattr.va_uid &&
- (error = suser(p)) != 0)
- goto out;
-
- if (vcount(vp) > 1)
- VOP_REVOKE(vp, REVOKEALL);
-out:
- vrele(vp);
- return error;
-}
-
-
-static int
-fd_truncate(p, fd, flp)
- struct proc *p;
- int fd;
- struct flock *flp;
-{
- struct filedesc *fdp = p->p_fd;
- struct file *fp;
- off_t start, length;
- struct vnode *vp;
- struct vattr vattr;
- int error, *retval;
- struct ftruncate_args ft;
-
- retval = p->p_retval;
-
- /*
- * We only support truncating the file.
- */
- if ((u_int)fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[fd]) == NULL)
- return EBADF;
-
- vp = (struct vnode *)fp->f_data;
- if (fp->f_type != DTYPE_VNODE || vp->v_type == VFIFO)
- return ESPIPE;
-
- if ((error = VOP_GETATTR(vp, &vattr, p->p_ucred, p)) != 0)
- return error;
-
- length = vattr.va_size;
-
- switch (flp->l_whence) {
- case SEEK_CUR:
- start = fp->f_offset + flp->l_start;
- break;
-
- case SEEK_END:
- start = flp->l_start + length;
- break;
-
- case SEEK_SET:
- start = flp->l_start;
- break;
-
- default:
- return EINVAL;
- }
-
- if (start + flp->l_len < length) {
- /* We don't support free'ing in the middle of the file */
- return EINVAL;
- }
-
- SCARG(&ft, fd) = fd;
- SCARG(&ft, length) = start;
-
- return ftruncate(p, &ft);
-}
-
-int
-svr4_sys_open(p, uap)
- register struct proc *p;
- struct svr4_sys_open_args *uap;
-{
- int error, retval;
- struct open_args cup;
-
- caddr_t sg = stackgap_init();
- CHECKALTEXIST(p, &sg, SCARG(uap, path));
-
- (&cup)->path = uap->path;
- (&cup)->flags = svr4_to_bsd_flags(uap->flags);
- (&cup)->mode = uap->mode;
- error = open(p, &cup);
-
- if (error) {
- /* uprintf("svr4_open(%s, 0x%0x, 0%o): %d\n", uap->path,
- uap->flags, uap->mode, error);*/
- return error;
- }
-
- retval = p->p_retval[0];
-
- if (!(SCARG(&cup, flags) & O_NOCTTY) && SESS_LEADER(p) &&
- !(p->p_flag & P_CONTROLT)) {
-#if defined(NOTYET)
- struct filedesc *fdp = p->p_fd;
- struct file *fp = fdp->fd_ofiles[retval];
-
- /* ignore any error, just give it a try */
- if (fp->f_type == DTYPE_VNODE)
- fo_ioctl(fp, TIOCSCTTY, (caddr_t) 0, p);
-#endif
- }
- return error;
-}
-
-int
-svr4_sys_open64(p, uap)
- register struct proc *p;
- struct svr4_sys_open64_args *uap;
-{
- return svr4_sys_open(p, (struct svr4_sys_open_args *)uap);
-}
-
-int
-svr4_sys_creat(p, uap)
- register struct proc *p;
- struct svr4_sys_creat_args *uap;
-{
- struct open_args cup;
-
- caddr_t sg = stackgap_init();
- CHECKALTEXIST(p, &sg, SCARG(uap, path));
-
- SCARG(&cup, path) = SCARG(uap, path);
- SCARG(&cup, mode) = SCARG(uap, mode);
- SCARG(&cup, flags) = O_WRONLY | O_CREAT | O_TRUNC;
-
- return open(p, &cup);
-}
-
-int
-svr4_sys_creat64(p, uap)
- register struct proc *p;
- struct svr4_sys_creat64_args *uap;
-{
- return svr4_sys_creat(p, (struct svr4_sys_creat_args *)uap);
-}
-
-int
-svr4_sys_llseek(p, v)
- register struct proc *p;
- struct svr4_sys_llseek_args *v;
-{
- struct svr4_sys_llseek_args *uap = v;
- struct lseek_args ap;
-
- SCARG(&ap, fd) = SCARG(uap, fd);
-
-#if BYTE_ORDER == BIG_ENDIAN
- SCARG(&ap, offset) = (((long long) SCARG(uap, offset1)) << 32) |
- SCARG(uap, offset2);
-#else
- SCARG(&ap, offset) = (((long long) SCARG(uap, offset2)) << 32) |
- SCARG(uap, offset1);
-#endif
- SCARG(&ap, whence) = SCARG(uap, whence);
-
- return lseek(p, &ap);
-}
-
-int
-svr4_sys_access(p, uap)
- register struct proc *p;
- struct svr4_sys_access_args *uap;
-{
- struct access_args cup;
- int *retval;
-
- caddr_t sg = stackgap_init();
- CHECKALTEXIST(p, &sg, SCARG(uap, path));
-
- retval = p->p_retval;
-
- SCARG(&cup, path) = SCARG(uap, path);
- SCARG(&cup, flags) = SCARG(uap, flags);
-
- return access(p, &cup);
-}
-
-#if defined(NOTYET)
-int
-svr4_sys_pread(p, uap)
- register struct proc *p;
- struct svr4_sys_pread_args *uap;
-{
- struct pread_args pra;
-
- /*
- * Just translate the args structure and call the NetBSD
- * pread(2) system call (offset type is 64-bit in NetBSD).
- */
- SCARG(&pra, fd) = SCARG(uap, fd);
- SCARG(&pra, buf) = SCARG(uap, buf);
- SCARG(&pra, nbyte) = SCARG(uap, nbyte);
- SCARG(&pra, offset) = SCARG(uap, off);
-
- return pread(p, &pra);
-}
-#endif
-
-#if defined(NOTYET)
-int
-svr4_sys_pread64(p, v, retval)
- register struct proc *p;
- void *v;
- register_t *retval;
-{
-
- struct svr4_sys_pread64_args *uap = v;
- struct sys_pread_args pra;
-
- /*
- * Just translate the args structure and call the NetBSD
- * pread(2) system call (offset type is 64-bit in NetBSD).
- */
- SCARG(&pra, fd) = SCARG(uap, fd);
- SCARG(&pra, buf) = SCARG(uap, buf);
- SCARG(&pra, nbyte) = SCARG(uap, nbyte);
- SCARG(&pra, offset) = SCARG(uap, off);
-
- return (sys_pread(p, &pra, retval));
-}
-#endif /* NOTYET */
-
-#if defined(NOTYET)
-int
-svr4_sys_pwrite(p, uap)
- register struct proc *p;
- struct svr4_sys_pwrite_args *uap;
-{
- struct pwrite_args pwa;
-
- /*
- * Just translate the args structure and call the NetBSD
- * pwrite(2) system call (offset type is 64-bit in NetBSD).
- */
- SCARG(&pwa, fd) = SCARG(uap, fd);
- SCARG(&pwa, buf) = SCARG(uap, buf);
- SCARG(&pwa, nbyte) = SCARG(uap, nbyte);
- SCARG(&pwa, offset) = SCARG(uap, off);
-
- return pwrite(p, &pwa);
-}
-#endif
-
-#if defined(NOTYET)
-int
-svr4_sys_pwrite64(p, v, retval)
- register struct proc *p;
- void *v;
- register_t *retval;
-{
- struct svr4_sys_pwrite64_args *uap = v;
- struct sys_pwrite_args pwa;
-
- /*
- * Just translate the args structure and call the NetBSD
- * pwrite(2) system call (offset type is 64-bit in NetBSD).
- */
- SCARG(&pwa, fd) = SCARG(uap, fd);
- SCARG(&pwa, buf) = SCARG(uap, buf);
- SCARG(&pwa, nbyte) = SCARG(uap, nbyte);
- SCARG(&pwa, offset) = SCARG(uap, off);
-
- return (sys_pwrite(p, &pwa, retval));
-}
-#endif /* NOTYET */
-
-int
-svr4_sys_fcntl(p, uap)
- register struct proc *p;
- struct svr4_sys_fcntl_args *uap;
-{
- int error;
- struct fcntl_args fa;
- int *retval;
-
- retval = p->p_retval;
-
- SCARG(&fa, fd) = SCARG(uap, fd);
- SCARG(&fa, cmd) = svr4_to_bsd_cmd(SCARG(uap, cmd));
-
- switch (SCARG(&fa, cmd)) {
- case F_DUPFD:
- case F_GETFD:
- case F_SETFD:
- SCARG(&fa, arg) = (long) SCARG(uap, arg);
- return fcntl(p, &fa);
-
- case F_GETFL:
- SCARG(&fa, arg) = (long) SCARG(uap, arg);
- error = fcntl(p, &fa);
- if (error)
- return error;
- *retval = bsd_to_svr4_flags(*retval);
- return error;
-
- case F_SETFL:
- {
- /*
- * we must save the O_ASYNC flag, as that is
- * handled by ioctl(_, I_SETSIG, _) emulation.
- */
- long cmd;
- int flags;
-
- DPRINTF(("Setting flags 0x%x\n", SCARG(uap, arg)));
- cmd = SCARG(&fa, cmd); /* save it for a while */
-
- SCARG(&fa, cmd) = F_GETFL;
- if ((error = fcntl(p, &fa)) != 0)
- return error;
- flags = *retval;
- flags &= O_ASYNC;
- flags |= svr4_to_bsd_flags((u_long) SCARG(uap, arg));
- SCARG(&fa, cmd) = cmd;
- SCARG(&fa, arg) = (long) flags;
- return fcntl(p, &fa);
- }
-
- case F_GETLK:
- case F_SETLK:
- case F_SETLKW:
- {
- struct svr4_flock ifl;
- struct flock *flp, fl;
- caddr_t sg = stackgap_init();
-
- flp = stackgap_alloc(&sg, sizeof(struct flock));
- SCARG(&fa, arg) = (long) flp;
-
- error = copyin(SCARG(uap, arg), &ifl, sizeof ifl);
- if (error)
- return error;
-
- svr4_to_bsd_flock(&ifl, &fl);
-
- error = copyout(&fl, flp, sizeof fl);
- if (error)
- return error;
-
- error = fcntl(p, &fa);
- if (error || SCARG(&fa, cmd) != F_GETLK)
- return error;
-
- error = copyin(flp, &fl, sizeof fl);
- if (error)
- return error;
-
- bsd_to_svr4_flock(&fl, &ifl);
-
- return copyout(&ifl, SCARG(uap, arg), sizeof ifl);
- }
- case -1:
- switch (SCARG(uap, cmd)) {
- case SVR4_F_DUP2FD:
- {
- struct dup2_args du;
-
- SCARG(&du, from) = SCARG(uap, fd);
- SCARG(&du, to) = (int)SCARG(uap, arg);
- error = dup2(p, &du);
- if (error)
- return error;
- *retval = SCARG(&du, to);
- return 0;
- }
-
- case SVR4_F_FREESP:
- {
- struct svr4_flock ifl;
- struct flock fl;
-
- error = copyin(SCARG(uap, arg), &ifl,
- sizeof ifl);
- if (error)
- return error;
- svr4_to_bsd_flock(&ifl, &fl);
- return fd_truncate(p, SCARG(uap, fd), &fl);
- }
-
- case SVR4_F_GETLK64:
- case SVR4_F_SETLK64:
- case SVR4_F_SETLKW64:
- {
- struct svr4_flock64 ifl;
- struct flock *flp, fl;
- caddr_t sg = stackgap_init();
-
- flp = stackgap_alloc(&sg, sizeof(struct flock));
- SCARG(&fa, arg) = (long) flp;
-
- error = copyin(SCARG(uap, arg), &ifl,
- sizeof ifl);
- if (error)
- return error;
-
- svr4_to_bsd_flock64(&ifl, &fl);
-
- error = copyout(&fl, flp, sizeof fl);
- if (error)
- return error;
-
- error = fcntl(p, &fa);
- if (error || SCARG(&fa, cmd) != F_GETLK)
- return error;
-
- error = copyin(flp, &fl, sizeof fl);
- if (error)
- return error;
-
- bsd_to_svr4_flock64(&fl, &ifl);
-
- return copyout(&ifl, SCARG(uap, arg),
- sizeof ifl);
- }
-
- case SVR4_F_FREESP64:
- {
- struct svr4_flock64 ifl;
- struct flock fl;
-
- error = copyin(SCARG(uap, arg), &ifl,
- sizeof ifl);
- if (error)
- return error;
- svr4_to_bsd_flock64(&ifl, &fl);
- return fd_truncate(p, SCARG(uap, fd), &fl);
- }
-
- case SVR4_F_REVOKE:
- return fd_revoke(p, SCARG(uap, fd));
-
- default:
- return ENOSYS;
- }
-
- default:
- return ENOSYS;
- }
-}
diff --git a/sys/compat/svr4/svr4_fcntl.h b/sys/compat/svr4/svr4_fcntl.h
deleted file mode 100644
index 615e09c219fb..000000000000
--- a/sys/compat/svr4/svr4_fcntl.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1994 Christos Zoulas
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _SVR4_FCNTL_H_
-#define _SVR4_FCNTL_H_
-
-#include <svr4/svr4_types.h>
-#include <sys/fcntl.h>
-
-#define SVR4_O_RDONLY 0x0000
-#define SVR4_O_WRONLY 0x0001
-#define SVR4_O_RDWR 0x0002
-#define SVR4_O_ACCMODE 0x0003
-#define SVR4_O_NDELAY 0x0004
-#define SVR4_O_APPEND 0x0008
-#define SVR4_O_SYNC 0x0010
-#define SVR4_O_NONBLOCK 0x0080
-#define SVR4_O_CREAT 0x0100
-#define SVR4_O_TRUNC 0x0200
-#define SVR4_O_EXCL 0x0400
-#define SVR4_O_NOCTTY 0x0800
-#define SVR4_O_PRIV 0x1000
-
-
-#define SVR4_FD_CLOEXEC 1
-
-#define SVR4_F_DUPFD 0
-#define SVR4_F_GETFD 1
-#define SVR4_F_SETFD 2
-#define SVR4_F_GETFL 3
-#define SVR4_F_SETFL 4
-#define SVR4_F_GETLK_SVR3 5
-#define SVR4_F_SETLK 6
-#define SVR4_F_SETLKW 7
-#define SVR4_F_CHKFL 8
-#define SVR4_F_DUP2FD 9
-#define SVR4_F_ALLOCSP 10
-#define SVR4_F_FREESP 11
-
-#define SVR4_F_ISSTREAM 13
-#define SVR4_F_GETLK 14
-#define SVR4_F_PRIV 15
-#define SVR4_F_NPRIV 16
-#define SVR4_F_QUOTACTL 17
-#define SVR4_F_BLOCKS 18
-#define SVR4_F_BLKSIZE 19
-#define SVR4_F_RSETLK 20
-#define SVR4_F_RGETLK 21
-#define SVR4_F_RSETLKW 22
-#define SVR4_F_GETOWN 23
-#define SVR4_F_SETOWN 24
-#define SVR4_F_REVOKE 25
-#define SVR4_F_HASREMOTELOCKS 26
-#define SVR4_F_FREESP64 27
-
-#define SVR4_F_GETLK64 33
-#define SVR4_F_SETLK64 34
-#define SVR4_F_SETLKW64 35
-
-#define SVR4_F_SHARE 40
-#define SVR4_F_UNSHARE 41
-
-#define SVR4_F_CHSIZE_XENIX 0x6000
-#define SVR4_F_RDCHK_XENIX 0x6001
-#define SVR4_F_LK_UNLCK_XENIX 0x6300
-#define SVR4_F_LK_LOCK_XENIX 0x7200
-#define SVR4_F_LK_NBLCK_XENIX 0x6200
-#define SVR4_F_LK_RLCK_XENIX 0x7100
-#define SVR4_F_LK_NBRLCK_XENIX 0x6100
-
-#define SVR4_LK_CMDTYPE(x) (((x) >> 12) & 0x7)
-#define SVR4_LK_LCKTYPE(x) (((x) >> 8) & 0x7)
-
-#define SVR4_F_RDLCK 1
-#define SVR4_F_WRLCK 2
-#define SVR4_F_UNLCK 3
-
-struct svr4_flock_svr3 {
- short l_type;
- short l_whence;
- svr4_off_t l_start;
- svr4_off_t l_len;
- short l_sysid;
- svr4_o_pid_t l_pid;
-};
-
-
-struct svr4_flock {
- short l_type;
- short l_whence;
- svr4_off_t l_start;
- svr4_off_t l_len;
- long l_sysid;
- svr4_pid_t l_pid;
- long pad[4];
-};
-
-struct svr4_flock64 {
- short l_type;
- short l_whence;
- svr4_off64_t l_start;
- svr4_off64_t l_len;
- long l_sysid;
- svr4_pid_t l_pid;
- long pad[4];
-};
-#endif /* !_SVR4_FCNTL_H_ */
diff --git a/sys/compat/svr4/svr4_filio.c b/sys/compat/svr4/svr4_filio.c
deleted file mode 100644
index 92b409270e28..000000000000
--- a/sys/compat/svr4/svr4_filio.c
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1994 Christos Zoulas
- * 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/proc.h>
-#include <sys/systm.h>
-#include <sys/file.h>
-#include <sys/filio.h>
-#include <sys/signal.h>
-#include <sys/filedesc.h>
-#include <sys/poll.h>
-#include <sys/malloc.h>
-
-#include <sys/sysproto.h>
-
-#include <svr4/svr4.h>
-#include <svr4/svr4_types.h>
-#include <svr4/svr4_util.h>
-#include <svr4/svr4_signal.h>
-#include <svr4/svr4_proto.h>
-#include <svr4/svr4_ioctl.h>
-#include <svr4/svr4_filio.h>
-
-/*#define GROTTY_READ_HACK*/
-
-int
-svr4_sys_poll(p, uap)
- struct proc *p;
- struct svr4_sys_poll_args *uap;
-{
- int error;
- struct poll_args pa;
- struct pollfd *pfd;
- int idx = 0, cerr;
- u_long siz;
-
- SCARG(&pa, fds) = SCARG(uap, fds);
- SCARG(&pa, nfds) = SCARG(uap, nfds);
- SCARG(&pa, timeout) = SCARG(uap, timeout);
-
- siz = SCARG(uap, nfds) * sizeof(struct pollfd);
- pfd = (struct pollfd *)malloc(siz, M_TEMP, M_WAITOK);
-
- error = poll(p, (struct poll_args *)uap);
-
- if ((cerr = copyin(SCARG(uap, fds), pfd, siz)) != 0) {
- error = cerr;
- goto done;
- }
-
- for (idx = 0; idx < SCARG(uap, nfds); idx++) {
- /* POLLWRNORM already equals POLLOUT, so we don't worry about that */
- if (pfd[idx].revents & (POLLOUT | POLLWRNORM | POLLWRBAND))
- pfd[idx].revents |= (POLLOUT | POLLWRNORM | POLLWRBAND);
- }
- if ((cerr = copyout(pfd, SCARG(uap, fds), siz)) != 0) {
- error = cerr;
- goto done; /* yeah, I know it's the next line, but this way I won't
- forget to update it if I add more code */
- }
-done:
- free(pfd, M_TEMP);
- return error;
-}
-
-#if defined(READ_TEST)
-int
-svr4_sys_read(p, uap)
- struct proc *p;
- struct svr4_sys_read_args *uap;
-{
- struct read_args ra;
- struct filedesc *fdp = p->p_fd;
- struct file *fp;
- struct socket *so = NULL;
- int so_state;
- sigset_t sigmask;
- int rv;
-
- SCARG(&ra, fd) = SCARG(uap, fd);
- SCARG(&ra, buf) = SCARG(uap, buf);
- SCARG(&ra, nbyte) = SCARG(uap, nbyte);
-
- if ((fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL) {
- DPRINTF(("Something fishy with the user-supplied file descriptor...\n"));
- return EBADF;
- }
-
- if (fp->f_type == DTYPE_SOCKET) {
- so = (struct socket *)fp->f_data;
- DPRINTF(("fd %d is a socket\n", SCARG(uap, fd)));
- if (so->so_state & SS_ASYNC) {
- DPRINTF(("fd %d is an ASYNC socket!\n", SCARG(uap, fd)));
- }
- DPRINTF(("Here are its flags: 0x%x\n", so->so_state));
-#if defined(GROTTY_READ_HACK)
- so_state = so->so_state;
- so->so_state &= ~SS_NBIO;
-#endif
- }
-
- rv = read(p, &ra);
-
- DPRINTF(("svr4_read(%d, 0x%0x, %d) = %d\n",
- SCARG(uap, fd), SCARG(uap, buf), SCARG(uap, nbyte), rv));
- if (rv == EAGAIN) {
- DPRINTF(("sigmask = 0x%x\n", p->p_sigmask));
- DPRINTF(("sigignore = 0x%x\n", p->p_sigignore));
- DPRINTF(("sigcaught = 0x%x\n", p->p_sigcatch));
- DPRINTF(("siglist = 0x%x\n", p->p_siglist));
- }
-
-#if defined(GROTTY_READ_HACK)
- if (so) { /* We've already checked to see if this is a socket */
- so->so_state = so_state;
- }
-#endif
-
- return(rv);
-}
-#endif /* READ_TEST */
-
-#if defined(BOGUS)
-int
-svr4_sys_write(p, uap)
- struct proc *p;
- struct svr4_sys_write_args *uap;
-{
- struct write_args wa;
- struct filedesc *fdp;
- struct file *fp;
- int rv;
-
- SCARG(&wa, fd) = SCARG(uap, fd);
- SCARG(&wa, buf) = SCARG(uap, buf);
- SCARG(&wa, nbyte) = SCARG(uap, nbyte);
-
- rv = write(p, &wa);
-
- DPRINTF(("svr4_write(%d, 0x%0x, %d) = %d\n",
- SCARG(uap, fd), SCARG(uap, buf), SCARG(uap, nbyte), rv));
-
- return(rv);
-}
-#endif /* BOGUS */
-
-int
-svr4_fil_ioctl(fp, p, retval, fd, cmd, data)
- struct file *fp;
- struct proc *p;
- register_t *retval;
- int fd;
- u_long cmd;
- caddr_t data;
-{
- int error;
- int num;
- struct filedesc *fdp = p->p_fd;
-
- *retval = 0;
-
- switch (cmd) {
- case SVR4_FIOCLEX:
- fdp->fd_ofileflags[fd] |= UF_EXCLOSE;
- return 0;
-
- case SVR4_FIONCLEX:
- fdp->fd_ofileflags[fd] &= ~UF_EXCLOSE;
- return 0;
-
- case SVR4_FIOGETOWN:
- case SVR4_FIOSETOWN:
- case SVR4_FIOASYNC:
- case SVR4_FIONBIO:
- case SVR4_FIONREAD:
- if ((error = copyin(data, &num, sizeof(num))) != 0)
- return error;
-
- switch (cmd) {
- case SVR4_FIOGETOWN: cmd = FIOGETOWN; break;
- case SVR4_FIOSETOWN: cmd = FIOSETOWN; break;
- case SVR4_FIOASYNC: cmd = FIOASYNC; break;
- case SVR4_FIONBIO: cmd = FIONBIO; break;
- case SVR4_FIONREAD: cmd = FIONREAD; break;
- }
-
-#ifdef SVR4_DEBUG
- if (cmd == FIOASYNC) DPRINTF(("FIOASYNC\n"));
-#endif
- error = fo_ioctl(fp, cmd, (caddr_t) &num, p);
-
- if (error)
- return error;
-
- return copyout(&num, data, sizeof(num));
-
- default:
- DPRINTF(("Unknown svr4 filio %lx\n", cmd));
- return 0; /* ENOSYS really */
- }
-}
diff --git a/sys/compat/svr4/svr4_filio.h b/sys/compat/svr4/svr4_filio.h
deleted file mode 100644
index 37184cb72610..000000000000
--- a/sys/compat/svr4/svr4_filio.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1994 Christos Zoulas
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _SVR4_FILIO_H_
-#define _SVR4_FILIO_H_
-
-#define SVR4_FIOC ('f' << 8)
-
-#define SVR4_FIOCLEX SVR4_IO('f', 1)
-#define SVR4_FIONCLEX SVR4_IO('f', 2)
-
-#define SVR4_FIOGETOWN SVR4_IOR('f', 123, int)
-#define SVR4_FIOSETOWN SVR4_IOW('f', 124, int)
-#define SVR4_FIOASYNC SVR4_IOW('f', 125, int)
-#define SVR4_FIONBIO SVR4_IOW('f', 126, int)
-#define SVR4_FIONREAD SVR4_IOR('f', 127, int)
-
-#endif /* !_SVR4_FILIO_H_ */
diff --git a/sys/compat/svr4/svr4_fuser.h b/sys/compat/svr4/svr4_fuser.h
deleted file mode 100644
index 25cdcf13e0be..000000000000
--- a/sys/compat/svr4/svr4_fuser.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * $FreeBSD$
- * Derived from:
- * $NetBSD: svr4_fuser.h,v 1.4 1998/09/04 19:54:38 christos Exp $ */
-
-/*-
- * Original Copyright:
- *
- * Copyright (c) 1994 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Christos Zoulas.
- *
- * 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 the NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation 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 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.
- */
-
-/*
- * Portions of this code have been derived from code contributed to the
- * FreeBSD Project by Mark Newton.
- *
- * Copyright (c) 1999 Mark Newton
- * 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.
- */
-
-#ifndef _SVR4_FUSER_H_
-#define _SVR4_FUSER_H_
-
-#include <svr4/svr4_types.h>
-
-struct svr4_f_user {
- svr4_pid_t fu_pid;
- int fu_flags;
- uid_t fu_uid;
-};
-
-
-#define SVR4_F_FILE_ONLY 1
-#define SVR4_F_CONTAINED 2
-
-#define SVR4_F_CDIR 0x01
-#define SVR4_F_RDIR 0x02
-#define SVR4_F_TEXT 0x04
-#define SVR4_F_MAP 0x08
-#define SVR4_F_OPEN 0x10
-#define SVR4_F_TRACE 0x20
-#define SVR4_F_TTY 0x40
-
-#endif /* !_SVR4_FUSER_H_ */
diff --git a/sys/compat/svr4/svr4_hrt.h b/sys/compat/svr4/svr4_hrt.h
deleted file mode 100644
index c160b8eeb6e9..000000000000
--- a/sys/compat/svr4/svr4_hrt.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1994 Christos Zoulas
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _SVR4_HRT_H_
-#define _SVR4_HRT_H_
-
-#define SVR4_HRT_CNTL 0
-#define SVR4_HRT_CNTL_RES 0
-#define SVR4_HRT_CNTL_TOFD 1
-#define SVR4_HRT_CNTL_START 2
-#define SVR4_HRT_CNTL_GET 3
-
-#define SVR4_HRT_ALRM 1
-#define SVR4_HRT_ALRM_DO 4
-#define SVR4_HRT_ALRM_REP 5
-#define SVR4_HRT_ALRM_TOD 6
-#define SVR4_HRT_ALRM_FUTREP 7
-#define SVR4_HRT_ALRM_TODREP 8
-#define SVR4_HRT_ALRM_PEND 9
-
-#define SVR4_HRT_SLP 2
-#define SVR4_HRT_SLP_INT 10
-#define SVR4_HRT_SLP_TOD 11
-
-#define SVR4_HRT_BSD 12
-#define SVR4_HRT_BSD_PEND 13
-#define SVR4_HRT_BSD_REP1 14
-#define SVR4_HRT_BSD_REP2 15
-#define SVR4_HRT_BSD_CANCEL 16
-
-#define SVR4_HRT_CAN 3
-
-#define SVR4_HRT_SEC 1
-#define SVR4_HRT_MSEC 1000
-#define SVR4_HRT_USEC 1000000
-#define SVR4_HRT_NSEC 1000000000
-
-#define SVR4_HRT_TRUNC 0
-#define SVR4_HRT_RND 1
-
-typedef struct {
- u_long i_word1;
- u_long i_word2;
- int i_clock;
-} svr4_hrt_interval_t;
-
-typedef struct {
- u_long h_sec;
- long h_rem;
- u_long h_res;
-} svr4_hrt_time_t;
-
-#define SVR4_HRT_DONE 1
-#define SVR4_HRT_ERROR 2
-
-#define SVR4_HRT_CLK_STD 1
-#define SVR4_HRT_CLK_USERVIRT 2
-#define SVR4_HRT_CLK_PROCVIRT 4
-
-#endif /* !_SVR4_HRT_H_ */
diff --git a/sys/compat/svr4/svr4_ioctl.c b/sys/compat/svr4/svr4_ioctl.c
deleted file mode 100644
index 2891694166a6..000000000000
--- a/sys/compat/svr4/svr4_ioctl.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1994 Christos Zoulas
- * 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/proc.h>
-#include <sys/file.h>
-#include <sys/filedesc.h>
-#include <sys/fcntl.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-#include <sys/systm.h>
-
-#include <svr4/svr4.h>
-#include <svr4/svr4_types.h>
-#include <svr4/svr4_util.h>
-#include <svr4/svr4_signal.h>
-#include <svr4/svr4_proto.h>
-#include <svr4/svr4_stropts.h>
-#include <svr4/svr4_ioctl.h>
-#include <svr4/svr4_termios.h>
-#include <svr4/svr4_ttold.h>
-#include <svr4/svr4_filio.h>
-#include <svr4/svr4_sockio.h>
-
-#ifdef DEBUG_SVR4
-static void svr4_decode_cmd __P((u_long, char *, char *, int *, int *));
-/*
- * Decode an ioctl command symbolically
- */
-static void
-svr4_decode_cmd(cmd, dir, c, num, argsiz)
- u_long cmd;
- char *dir, *c;
- int *num, *argsiz;
-{
- if (cmd & SVR4_IOC_VOID)
- *dir++ = 'V';
- if (cmd & SVR4_IOC_IN)
- *dir++ = 'R';
- if (cmd & SVR4_IOC_OUT)
- *dir++ = 'W';
- *dir = '\0';
- if (cmd & SVR4_IOC_INOUT)
- *argsiz = (cmd >> 16) & 0xff;
- else
- *argsiz = -1;
-
- *c = (cmd >> 8) & 0xff;
- *num = cmd & 0xff;
-}
-#endif
-
-int
-svr4_sys_ioctl(p, uap)
- register struct proc *p;
- struct svr4_sys_ioctl_args *uap;
-{
- int *retval;
- struct file *fp;
- struct filedesc *fdp;
- u_long cmd;
- int (*fun) __P((struct file *, struct proc *, register_t *,
- int, u_long, caddr_t));
-#ifdef DEBUG_SVR4
- char dir[4];
- char c;
- int num;
- int argsiz;
-
- svr4_decode_cmd(SCARG(uap, com), dir, &c, &num, &argsiz);
-
- DPRINTF(("svr4_ioctl[%x](%d, _IO%s(%c, %d, %d), %p);\n", SCARG(uap, com), SCARG(uap, fd),
- dir, c, num, argsiz, SCARG(uap, data)));
-#endif
- retval = p->p_retval;
- fdp = p->p_fd;
- cmd = SCARG(uap, com);
-
- if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles ||
- (fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL)
- return EBADF;
-
- if ((fp->f_flag & (FREAD | FWRITE)) == 0)
- return EBADF;
-
-#if defined(DEBUG_SVR4)
- if (fp->f_type == DTYPE_SOCKET) {
- struct socket *so = fp->f_data;
- DPRINTF(("<<< IN: so_state = 0x%x\n", so->so_state));
- }
-#endif
-
- switch (cmd & 0xff00) {
- case SVR4_tIOC:
- DPRINTF(("ttold\n"));
- fun = svr4_ttold_ioctl;
- break;
-
- case SVR4_TIOC:
- DPRINTF(("term\n"));
- fun = svr4_term_ioctl;
- break;
-
- case SVR4_STR:
- DPRINTF(("stream\n"));
- fun = svr4_stream_ioctl;
- break;
-
- case SVR4_FIOC:
- DPRINTF(("file\n"));
- fun = svr4_fil_ioctl;
- break;
-
- case SVR4_SIOC:
- DPRINTF(("socket\n"));
- fun = svr4_sock_ioctl;
- break;
-
- case SVR4_XIOC:
- /* We do not support those */
- return EINVAL;
-
- default:
- DPRINTF(("Unimplemented ioctl %lx\n", cmd));
- return 0; /* XXX: really ENOSYS */
- }
-#if defined(DEBUG_SVR4)
- if (fp->f_type == DTYPE_SOCKET) {
- struct socket *so = fp->f_data;
- DPRINTF((">>> OUT: so_state = 0x%x\n", so->so_state));
- }
-#endif
- return (*fun)(fp, p, retval, SCARG(uap, fd), cmd, SCARG(uap, data));
-}
diff --git a/sys/compat/svr4/svr4_ioctl.h b/sys/compat/svr4/svr4_ioctl.h
deleted file mode 100644
index a5c6a5324181..000000000000
--- a/sys/compat/svr4/svr4_ioctl.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1994 Christos Zoulas
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _SVR4_IOCTL_H_
-#define _SVR4_IOCTL_H_
-
-#define SVR4_IOC_VOID 0x20000000
-#define SVR4_IOC_OUT 0x40000000
-#define SVR4_IOC_IN 0x80000000
-#define SVR4_IOC_INOUT (SVR4_IOC_IN|SVR4_IOC_OUT)
-
-#define SVR4_IOC(inout,group,num,len) \
- (inout | ((len & 0xff) << 16) | ((group) << 8) | (num))
-
-#define SVR4_XIOC ('X' << 8)
-
-#define SVR4_IO(g,n) SVR4_IOC(SVR4_IOC_VOID, (g), (n), 0)
-#define SVR4_IOR(g,n,t) SVR4_IOC(SVR4_IOC_OUT, (g), (n), sizeof(t))
-#define SVR4_IOW(g,n,t) SVR4_IOC(SVR4_IOC_IN, (g), (n), sizeof(t))
-#define SVR4_IOWR(g,n,t) SVR4_IOC(SVR4_IOC_INOUT,(g), (n), sizeof(t))
-
-int svr4_stream_ti_ioctl __P((struct file *, struct proc *, register_t *,
- int, u_long, caddr_t));
-int svr4_stream_ioctl __P((struct file *, struct proc *, register_t *,
- int, u_long, caddr_t));
-int svr4_term_ioctl __P((struct file *, struct proc *, register_t *,
- int, u_long, caddr_t));
-int svr4_ttold_ioctl __P((struct file *, struct proc *, register_t *,
- int, u_long, caddr_t));
-int svr4_fil_ioctl __P((struct file *, struct proc *, register_t *,
- int, u_long, caddr_t));
-int svr4_sock_ioctl __P((struct file *, struct proc *, register_t *,
- int, u_long, caddr_t));
-
-#endif /* !_SVR4_IOCTL_H_ */
diff --git a/sys/compat/svr4/svr4_ipc.c b/sys/compat/svr4/svr4_ipc.c
deleted file mode 100644
index 6d250fdee471..000000000000
--- a/sys/compat/svr4/svr4_ipc.c
+++ /dev/null
@@ -1,822 +0,0 @@
-/*
- * $FreeBSD$
- * Derived from:
- * $NetBSD: svr4_ipc.c,v 1.7 1998/10/19 22:43:00 tron Exp $ */
-
-/*-
- * Original copyright:
- *
- * Copyright (c) 1995 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Christos Zoulas.
- *
- * 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 the NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation 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 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.
- */
-
-/*
- * Portions of this code have been derived from software contributed
- * to the FreeBSD Project by Mark Newton.
- *
- * Copyright (c) 1999 Mark Newton
- * 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.
- *
- * XXX- This code is presently a no-op on FreeBSD (and isn't compiled due
- * to preprocessor conditionals). A nice project for a kernel hacking
- * novice might be to MakeItGo, but I have more important fish to fry
- * at present.
- *
- */
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/proc.h>
-#include <sys/time.h>
-
-#include <svr4/svr4.h>
-#include <svr4/svr4_types.h>
-#include <svr4/svr4_signal.h>
-#include <svr4/svr4_proto.h>
-#include <svr4/svr4_util.h>
-#include <svr4/svr4_ipc.h>
-
-#if defined(SYSVMSG) || defined(SYSVSHM) || defined(SYSVSEM)
-static void svr4_to_bsd_ipc_perm __P((const struct svr4_ipc_perm *,
- struct ipc_perm *));
-static void bsd_to_svr4_ipc_perm __P((const struct ipc_perm *,
- struct svr4_ipc_perm *));
-#endif
-
-#ifdef SYSVSEM
-static void bsd_to_svr4_semid_ds __P((const struct semid_ds *,
- struct svr4_semid_ds *));
-static void svr4_to_bsd_semid_ds __P((const struct svr4_semid_ds *,
- struct semid_ds *));
-static int svr4_setsemun __P((caddr_t *sgp, union semun **argp,
- union semun *usp));
-static int svr4_semop __P((struct proc *, void *, register_t *));
-static int svr4_semget __P((struct proc *, void *, register_t *));
-static int svr4_semctl __P((struct proc *, void *, register_t *));
-#endif
-
-#ifdef SYSVMSG
-static void bsd_to_svr4_msqid_ds __P((const struct msqid_ds *,
- struct svr4_msqid_ds *));
-static void svr4_to_bsd_msqid_ds __P((const struct svr4_msqid_ds *,
- struct msqid_ds *));
-static int svr4_msgsnd __P((struct proc *, void *, register_t *));
-static int svr4_msgrcv __P((struct proc *, void *, register_t *));
-static int svr4_msgget __P((struct proc *, void *, register_t *));
-static int svr4_msgctl __P((struct proc *, void *, register_t *));
-#endif
-
-#ifdef SYSVSHM
-static void bsd_to_svr4_shmid_ds __P((const struct shmid_ds *,
- struct svr4_shmid_ds *));
-static void svr4_to_bsd_shmid_ds __P((const struct svr4_shmid_ds *,
- struct shmid_ds *));
-static int svr4_shmat __P((struct proc *, void *, register_t *));
-static int svr4_shmdt __P((struct proc *, void *, register_t *));
-static int svr4_shmget __P((struct proc *, void *, register_t *));
-static int svr4_shmctl __P((struct proc *, void *, register_t *));
-#endif
-
-#if defined(SYSVMSG) || defined(SYSVSHM) || defined(SYSVSEM)
-
-static void
-svr4_to_bsd_ipc_perm(spp, bpp)
- const struct svr4_ipc_perm *spp;
- struct ipc_perm *bpp;
-{
- bpp->key = spp->key;
- bpp->uid = spp->uid;
- bpp->gid = spp->gid;
- bpp->cuid = spp->cuid;
- bpp->cgid = spp->cgid;
- bpp->mode = spp->mode;
- bpp->seq = spp->seq;
-}
-
-static void
-bsd_to_svr4_ipc_perm(bpp, spp)
- const struct ipc_perm *bpp;
- struct svr4_ipc_perm *spp;
-{
- spp->key = bpp->key;
- spp->uid = bpp->uid;
- spp->gid = bpp->gid;
- spp->cuid = bpp->cuid;
- spp->cgid = bpp->cgid;
- spp->mode = bpp->mode;
- spp->seq = bpp->seq;
-}
-#endif
-
-#ifdef SYSVSEM
-static void
-bsd_to_svr4_semid_ds(bds, sds)
- const struct semid_ds *bds;
- struct svr4_semid_ds *sds;
-{
- bsd_to_svr4_ipc_perm(&bds->sem_perm, &sds->sem_perm);
- sds->sem_base = (struct svr4_sem *) bds->sem_base;
- sds->sem_nsems = bds->sem_nsems;
- sds->sem_otime = bds->sem_otime;
- sds->sem_pad1 = bds->sem_pad1;
- sds->sem_ctime = bds->sem_ctime;
- sds->sem_pad2 = bds->sem_pad2;
-}
-
-static void
-svr4_to_bsd_semid_ds(sds, bds)
- const struct svr4_semid_ds *sds;
- struct semid_ds *bds;
-{
- svr4_to_bsd_ipc_perm(&sds->sem_perm, &bds->sem_perm);
- bds->sem_base = (struct sem *) bds->sem_base;
- bds->sem_nsems = sds->sem_nsems;
- bds->sem_otime = sds->sem_otime;
- bds->sem_pad1 = sds->sem_pad1;
- bds->sem_ctime = sds->sem_ctime;
- bds->sem_pad2 = sds->sem_pad2;
-}
-
-static int
-svr4_setsemun(sgp, argp, usp)
- caddr_t *sgp;
- union semun **argp;
- union semun *usp;
-{
- *argp = stackgap_alloc(sgp, sizeof(union semun));
- return copyout((caddr_t)usp, *argp, sizeof(union semun));
-}
-
-struct svr4_sys_semctl_args {
- syscallarg(int) what;
- syscallarg(int) semid;
- syscallarg(int) semnum;
- syscallarg(int) cmd;
- syscallarg(union semun) arg;
-};
-
-static int
-svr4_semctl(p, v, retval)
- struct proc *p;
- void *v;
- register_t *retval;
-{
- int error;
- struct svr4_sys_semctl_args *uap = v;
- struct sys___semctl_args ap;
- struct svr4_semid_ds ss;
- struct semid_ds bs, *bsp;
- caddr_t sg = stackgap_init(p->p_emul);
-
- SCARG(&ap, semid) = SCARG(uap, semid);
- SCARG(&ap, semnum) = SCARG(uap, semnum);
-
- switch (SCARG(uap, cmd)) {
- case SVR4_SEM_GETZCNT:
- case SVR4_SEM_GETNCNT:
- case SVR4_SEM_GETPID:
- case SVR4_SEM_GETVAL:
- switch (SCARG(uap, cmd)) {
- case SVR4_SEM_GETZCNT:
- SCARG(&ap, cmd) = GETZCNT;
- break;
- case SVR4_SEM_GETNCNT:
- SCARG(&ap, cmd) = GETNCNT;
- break;
- case SVR4_SEM_GETPID:
- SCARG(&ap, cmd) = GETPID;
- break;
- case SVR4_SEM_GETVAL:
- SCARG(&ap, cmd) = GETVAL;
- break;
- }
- return sys___semctl(p, &ap, retval);
-
- case SVR4_SEM_SETVAL:
- error = svr4_setsemun(&sg, &SCARG(&ap, arg), &SCARG(uap, arg));
- if (error)
- return error;
- SCARG(&ap, cmd) = SETVAL;
- return sys___semctl(p, &ap, retval);
-
- case SVR4_SEM_GETALL:
- error = svr4_setsemun(&sg, &SCARG(&ap, arg), &SCARG(uap, arg));
- if (error)
- return error;
- SCARG(&ap, cmd) = GETVAL;
- return sys___semctl(p, &ap, retval);
-
- case SVR4_SEM_SETALL:
- error = svr4_setsemun(&sg, &SCARG(&ap, arg), &SCARG(uap, arg));
- if (error)
- return error;
- SCARG(&ap, cmd) = SETVAL;
- return sys___semctl(p, &ap, retval);
-
- case SVR4_IPC_STAT:
- SCARG(&ap, cmd) = IPC_STAT;
- bsp = stackgap_alloc(&sg, sizeof(bs));
- error = svr4_setsemun(&sg, &SCARG(&ap, arg),
- (union semun *)&bsp);
- if (error)
- return error;
- if ((error = sys___semctl(p, &ap, retval)) != 0)
- return error;
- error = copyin((caddr_t)bsp, (caddr_t)&bs, sizeof(bs));
- if (error)
- return error;
- bsd_to_svr4_semid_ds(&bs, &ss);
- return copyout(&ss, SCARG(uap, arg).buf, sizeof(ss));
-
- case SVR4_IPC_SET:
- SCARG(&ap, cmd) = IPC_SET;
- bsp = stackgap_alloc(&sg, sizeof(bs));
- error = svr4_setsemun(&sg, &SCARG(&ap, arg),
- (union semun *)&bsp);
- if (error)
- return error;
- error = copyin(SCARG(uap, arg).buf, (caddr_t) &ss, sizeof ss);
- if (error)
- return error;
- svr4_to_bsd_semid_ds(&ss, &bs);
- error = copyout(&bs, bsp, sizeof(bs));
- if (error)
- return error;
- return sys___semctl(p, &ap, retval);
-
- case SVR4_IPC_RMID:
- SCARG(&ap, cmd) = IPC_RMID;
- bsp = stackgap_alloc(&sg, sizeof(bs));
- error = svr4_setsemun(&sg, &SCARG(&ap, arg),
- (union semun *)&bsp);
- if (error)
- return error;
- error = copyin(SCARG(uap, arg).buf, &ss, sizeof ss);
- if (error)
- return error;
- svr4_to_bsd_semid_ds(&ss, &bs);
- error = copyout(&bs, bsp, sizeof(bs));
- if (error)
- return error;
- return sys___semctl(p, &ap, retval);
-
- default:
- return EINVAL;
- }
-}
-
-struct svr4_sys_semget_args {
- syscallarg(int) what;
- syscallarg(svr4_key_t) key;
- syscallarg(int) nsems;
- syscallarg(int) semflg;
-};
-
-static int
-svr4_semget(p, v, retval)
- struct proc *p;
- void *v;
- register_t *retval;
-{
- struct svr4_sys_semget_args *uap = v;
- struct sys_semget_args ap;
-
- SCARG(&ap, key) = SCARG(uap, key);
- SCARG(&ap, nsems) = SCARG(uap, nsems);
- SCARG(&ap, semflg) = SCARG(uap, semflg);
-
- return sys_semget(p, &ap, retval);
-}
-
-struct svr4_sys_semop_args {
- syscallarg(int) what;
- syscallarg(int) semid;
- syscallarg(struct svr4_sembuf *) sops;
- syscallarg(u_int) nsops;
-};
-
-static int
-svr4_semop(p, v, retval)
- struct proc *p;
- void *v;
- register_t *retval;
-{
- struct svr4_sys_semop_args *uap = v;
- struct sys_semop_args ap;
-
- SCARG(&ap, semid) = SCARG(uap, semid);
- /* These are the same */
- SCARG(&ap, sops) = (struct sembuf *) SCARG(uap, sops);
- SCARG(&ap, nsops) = SCARG(uap, nsops);
-
- return sys_semop(p, &ap, retval);
-}
-
-int
-svr4_sys_semsys(p, v, retval)
- struct proc *p;
- void *v;
- register_t *retval;
-{
- struct svr4_sys_semsys_args *uap = v;
-
- DPRINTF(("svr4_semsys(%d)\n", SCARG(uap, what)));
-
- switch (SCARG(uap, what)) {
- case SVR4_semctl:
- return svr4_semctl(p, v, retval);
- case SVR4_semget:
- return svr4_semget(p, v, retval);
- case SVR4_semop:
- return svr4_semop(p, v, retval);
- default:
- return EINVAL;
- }
-}
-#endif
-
-#ifdef SYSVMSG
-static void
-bsd_to_svr4_msqid_ds(bds, sds)
- const struct msqid_ds *bds;
- struct svr4_msqid_ds *sds;
-{
- bsd_to_svr4_ipc_perm(&bds->msg_perm, &sds->msg_perm);
- sds->msg_first = (struct svr4_msg *) bds->msg_first;
- sds->msg_last = (struct svr4_msg *) bds->msg_last;
- sds->msg_cbytes = bds->msg_cbytes;
- sds->msg_qnum = bds->msg_qnum;
- sds->msg_qbytes = bds->msg_qbytes;
- sds->msg_lspid = bds->msg_lspid;
- sds->msg_lrpid = bds->msg_lrpid;
- sds->msg_stime = bds->msg_stime;
- sds->msg_pad1 = bds->msg_pad1;
- sds->msg_rtime = bds->msg_rtime;
- sds->msg_pad2 = bds->msg_pad2;
- sds->msg_ctime = bds->msg_ctime;
- sds->msg_pad3 = bds->msg_pad3;
-
- /* use the padding for the rest of the fields */
- {
- const short *pad = (const short *) bds->msg_pad4;
- sds->msg_cv = pad[0];
- sds->msg_qnum_cv = pad[1];
- }
-}
-
-static void
-svr4_to_bsd_msqid_ds(sds, bds)
- const struct svr4_msqid_ds *sds;
- struct msqid_ds *bds;
-{
- svr4_to_bsd_ipc_perm(&sds->msg_perm, &bds->msg_perm);
- bds->msg_first = (struct msg *) sds->msg_first;
- bds->msg_last = (struct msg *) sds->msg_last;
- bds->msg_cbytes = sds->msg_cbytes;
- bds->msg_qnum = sds->msg_qnum;
- bds->msg_qbytes = sds->msg_qbytes;
- bds->msg_lspid = sds->msg_lspid;
- bds->msg_lrpid = sds->msg_lrpid;
- bds->msg_stime = sds->msg_stime;
- bds->msg_pad1 = sds->msg_pad1;
- bds->msg_rtime = sds->msg_rtime;
- bds->msg_pad2 = sds->msg_pad2;
- bds->msg_ctime = sds->msg_ctime;
- bds->msg_pad3 = sds->msg_pad3;
-
- /* use the padding for the rest of the fields */
- {
- short *pad = (short *) bds->msg_pad4;
- pad[0] = sds->msg_cv;
- pad[1] = sds->msg_qnum_cv;
- }
-}
-
-struct svr4_sys_msgsnd_args {
- syscallarg(int) what;
- syscallarg(int) msqid;
- syscallarg(void *) msgp;
- syscallarg(size_t) msgsz;
- syscallarg(int) msgflg;
-};
-
-static int
-svr4_msgsnd(p, v, retval)
- struct proc *p;
- void *v;
- register_t *retval;
-{
- struct svr4_sys_msgsnd_args *uap = v;
- struct sys_msgsnd_args ap;
-
- SCARG(&ap, msqid) = SCARG(uap, msqid);
- SCARG(&ap, msgp) = SCARG(uap, msgp);
- SCARG(&ap, msgsz) = SCARG(uap, msgsz);
- SCARG(&ap, msgflg) = SCARG(uap, msgflg);
-
- return sys_msgsnd(p, &ap, retval);
-}
-
-struct svr4_sys_msgrcv_args {
- syscallarg(int) what;
- syscallarg(int) msqid;
- syscallarg(void *) msgp;
- syscallarg(size_t) msgsz;
- syscallarg(long) msgtyp;
- syscallarg(int) msgflg;
-};
-
-static int
-svr4_msgrcv(p, v, retval)
- struct proc *p;
- void *v;
- register_t *retval;
-{
- struct svr4_sys_msgrcv_args *uap = v;
- struct sys_msgrcv_args ap;
-
- SCARG(&ap, msqid) = SCARG(uap, msqid);
- SCARG(&ap, msgp) = SCARG(uap, msgp);
- SCARG(&ap, msgsz) = SCARG(uap, msgsz);
- SCARG(&ap, msgtyp) = SCARG(uap, msgtyp);
- SCARG(&ap, msgflg) = SCARG(uap, msgflg);
-
- return sys_msgrcv(p, &ap, retval);
-}
-
-struct svr4_sys_msgget_args {
- syscallarg(int) what;
- syscallarg(svr4_key_t) key;
- syscallarg(int) msgflg;
-};
-
-static int
-svr4_msgget(p, v, retval)
- struct proc *p;
- void *v;
- register_t *retval;
-{
- struct svr4_sys_msgget_args *uap = v;
- struct sys_msgget_args ap;
-
- SCARG(&ap, key) = SCARG(uap, key);
- SCARG(&ap, msgflg) = SCARG(uap, msgflg);
-
- return sys_msgget(p, &ap, retval);
-}
-
-struct svr4_sys_msgctl_args {
- syscallarg(int) what;
- syscallarg(int) msqid;
- syscallarg(int) cmd;
- syscallarg(struct svr4_msqid_ds *) buf;
-};
-
-static int
-svr4_msgctl(p, v, retval)
- struct proc *p;
- void *v;
- register_t *retval;
-{
- int error;
- struct svr4_sys_msgctl_args *uap = v;
- struct sys_msgctl_args ap;
- struct svr4_msqid_ds ss;
- struct msqid_ds bs;
- caddr_t sg = stackgap_init(p->p_emul);
-
- SCARG(&ap, msqid) = SCARG(uap, msqid);
- SCARG(&ap, cmd) = SCARG(uap, cmd);
- SCARG(&ap, buf) = stackgap_alloc(&sg, sizeof(bs));
-
- switch (SCARG(uap, cmd)) {
- case SVR4_IPC_STAT:
- SCARG(&ap, cmd) = IPC_STAT;
- if ((error = sys_msgctl(p, &ap, retval)) != 0)
- return error;
- error = copyin(&bs, SCARG(&ap, buf), sizeof bs);
- if (error)
- return error;
- bsd_to_svr4_msqid_ds(&bs, &ss);
- return copyout(&ss, SCARG(uap, buf), sizeof ss);
-
- case SVR4_IPC_SET:
- SCARG(&ap, cmd) = IPC_SET;
- error = copyin(SCARG(uap, buf), &ss, sizeof ss);
- if (error)
- return error;
- svr4_to_bsd_msqid_ds(&ss, &bs);
- error = copyout(&bs, SCARG(&ap, buf), sizeof bs);
- if (error)
- return error;
- return sys_msgctl(p, &ap, retval);
-
- case SVR4_IPC_RMID:
- SCARG(&ap, cmd) = IPC_RMID;
- error = copyin(SCARG(uap, buf), &ss, sizeof ss);
- if (error)
- return error;
- svr4_to_bsd_msqid_ds(&ss, &bs);
- error = copyout(&bs, SCARG(&ap, buf), sizeof bs);
- if (error)
- return error;
- return sys_msgctl(p, &ap, retval);
-
- default:
- return EINVAL;
- }
-}
-
-int
-svr4_sys_msgsys(p, v, retval)
- struct proc *p;
- void *v;
- register_t *retval;
-{
- struct svr4_sys_msgsys_args *uap = v;
-
- DPRINTF(("svr4_msgsys(%d)\n", SCARG(uap, what)));
-
- switch (SCARG(uap, what)) {
- case SVR4_msgsnd:
- return svr4_msgsnd(p, v, retval);
- case SVR4_msgrcv:
- return svr4_msgrcv(p, v, retval);
- case SVR4_msgget:
- return svr4_msgget(p, v, retval);
- case SVR4_msgctl:
- return svr4_msgctl(p, v, retval);
- default:
- return EINVAL;
- }
-}
-#endif
-
-#ifdef SYSVSHM
-
-static void
-bsd_to_svr4_shmid_ds(bds, sds)
- const struct shmid_ds *bds;
- struct svr4_shmid_ds *sds;
-{
- bsd_to_svr4_ipc_perm(&bds->shm_perm, &sds->shm_perm);
- sds->shm_segsz = bds->shm_segsz;
- sds->shm_lkcnt = 0;
- sds->shm_lpid = bds->shm_lpid;
- sds->shm_cpid = bds->shm_cpid;
- sds->shm_amp = bds->shm_internal;
- sds->shm_nattch = bds->shm_nattch;
- sds->shm_cnattch = 0;
- sds->shm_atime = bds->shm_atime;
- sds->shm_pad1 = 0;
- sds->shm_dtime = bds->shm_dtime;
- sds->shm_pad2 = 0;
- sds->shm_ctime = bds->shm_ctime;
- sds->shm_pad3 = 0;
-}
-
-static void
-svr4_to_bsd_shmid_ds(sds, bds)
- const struct svr4_shmid_ds *sds;
- struct shmid_ds *bds;
-{
- svr4_to_bsd_ipc_perm(&sds->shm_perm, &bds->shm_perm);
- bds->shm_segsz = sds->shm_segsz;
- bds->shm_lpid = sds->shm_lpid;
- bds->shm_cpid = sds->shm_cpid;
- bds->shm_internal = sds->shm_amp;
- bds->shm_nattch = sds->shm_nattch;
- bds->shm_atime = sds->shm_atime;
- bds->shm_dtime = sds->shm_dtime;
- bds->shm_ctime = sds->shm_ctime;
-}
-
-struct svr4_sys_shmat_args {
- syscallarg(int) what;
- syscallarg(int) shmid;
- syscallarg(void *) shmaddr;
- syscallarg(int) shmflg;
-};
-
-static int
-svr4_shmat(p, v, retval)
- struct proc *p;
- void *v;
- register_t *retval;
-{
- struct svr4_sys_shmat_args *uap = v;
- struct sys_shmat_args ap;
-
- SCARG(&ap, shmid) = SCARG(uap, shmid);
- SCARG(&ap, shmaddr) = SCARG(uap, shmaddr);
- SCARG(&ap, shmflg) = SCARG(uap, shmflg);
-
- return sys_shmat(p, &ap, retval);
-}
-
-struct svr4_sys_shmdt_args {
- syscallarg(int) what;
- syscallarg(void *) shmaddr;
-};
-
-static int
-svr4_shmdt(p, v, retval)
- struct proc *p;
- void *v;
- register_t *retval;
-{
- struct svr4_sys_shmdt_args *uap = v;
- struct sys_shmdt_args ap;
-
- SCARG(&ap, shmaddr) = SCARG(uap, shmaddr);
-
- return sys_shmdt(p, &ap, retval);
-}
-
-struct svr4_sys_shmget_args {
- syscallarg(int) what;
- syscallarg(key_t) key;
- syscallarg(int) size;
- syscallarg(int) shmflg;
-};
-
-static int
-svr4_shmget(p, v, retval)
- struct proc *p;
- void *v;
- register_t *retval;
-{
- struct svr4_sys_shmget_args *uap = v;
- struct sys_shmget_args ap;
-
- SCARG(&ap, key) = SCARG(uap, key);
- SCARG(&ap, size) = SCARG(uap, size);
- SCARG(&ap, shmflg) = SCARG(uap, shmflg);
-
- return sys_shmget(p, &ap, retval);
-}
-
-struct svr4_sys_shmctl_args {
- syscallarg(int) what;
- syscallarg(int) shmid;
- syscallarg(int) cmd;
- syscallarg(struct svr4_shmid_ds *) buf;
-};
-
-int
-svr4_shmctl(p, v, retval)
- struct proc *p;
- void *v;
- register_t *retval;
-{
- struct svr4_sys_shmctl_args *uap = v;
- int error;
- caddr_t sg = stackgap_init(p->p_emul);
- struct sys_shmctl_args ap;
- struct shmid_ds bs;
- struct svr4_shmid_ds ss;
-
- SCARG(&ap, shmid) = SCARG(uap, shmid);
-
- if (SCARG(uap, buf) != NULL) {
- SCARG(&ap, buf) = stackgap_alloc(&sg, sizeof (struct shmid_ds));
- switch (SCARG(uap, cmd)) {
- case SVR4_IPC_SET:
- case SVR4_IPC_RMID:
- case SVR4_SHM_LOCK:
- case SVR4_SHM_UNLOCK:
- error = copyin(SCARG(uap, buf), (caddr_t) &ss,
- sizeof ss);
- if (error)
- return error;
- svr4_to_bsd_shmid_ds(&ss, &bs);
- error = copyout(&bs, SCARG(&ap, buf), sizeof bs);
- if (error)
- return error;
- break;
- default:
- break;
- }
- }
- else
- SCARG(&ap, buf) = NULL;
-
-
- switch (SCARG(uap, cmd)) {
- case SVR4_IPC_STAT:
- SCARG(&ap, cmd) = IPC_STAT;
- if ((error = sys_shmctl(p, &ap, retval)) != 0)
- return error;
- if (SCARG(uap, buf) == NULL)
- return 0;
- error = copyin(&bs, SCARG(&ap, buf), sizeof bs);
- if (error)
- return error;
- bsd_to_svr4_shmid_ds(&bs, &ss);
- return copyout(&ss, SCARG(uap, buf), sizeof ss);
-
- case SVR4_IPC_SET:
- SCARG(&ap, cmd) = IPC_SET;
- return sys_shmctl(p, &ap, retval);
-
- case SVR4_IPC_RMID:
- case SVR4_SHM_LOCK:
- case SVR4_SHM_UNLOCK:
- switch (SCARG(uap, cmd)) {
- case SVR4_IPC_RMID:
- SCARG(&ap, cmd) = IPC_RMID;
- break;
- case SVR4_SHM_LOCK:
- SCARG(&ap, cmd) = SHM_LOCK;
- break;
- case SVR4_SHM_UNLOCK:
- SCARG(&ap, cmd) = SHM_UNLOCK;
- break;
- default:
- return EINVAL;
- }
- return sys_shmctl(p, &ap, retval);
-
- default:
- return EINVAL;
- }
-}
-
-int
-svr4_sys_shmsys(p, v, retval)
- struct proc *p;
- void *v;
- register_t *retval;
-{
- struct svr4_sys_shmsys_args *uap = v;
-
- DPRINTF(("svr4_shmsys(%d)\n", SCARG(uap, what)));
-
- switch (SCARG(uap, what)) {
- case SVR4_shmat:
- return svr4_shmat(p, v, retval);
- case SVR4_shmdt:
- return svr4_shmdt(p, v, retval);
- case SVR4_shmget:
- return svr4_shmget(p, v, retval);
- case SVR4_shmctl:
- return svr4_shmctl(p, v, retval);
- default:
- return ENOSYS;
- }
-}
-#endif /* SYSVSHM */
diff --git a/sys/compat/svr4/svr4_ipc.h b/sys/compat/svr4/svr4_ipc.h
deleted file mode 100644
index 6aadb7e050ec..000000000000
--- a/sys/compat/svr4/svr4_ipc.h
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1995 Christos Zoulas. 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 Christos Zoulas.
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _SVR4_IPC_H_
-#define _SVR4_IPC_H_
-
-/*
- * General IPC
- */
-#define SVR4_IPC_RMID 10
-#define SVR4_IPC_SET 11
-#define SVR4_IPC_STAT 12
-
-struct svr4_ipc_perm {
- svr4_uid_t uid;
- svr4_gid_t gid;
- svr4_uid_t cuid;
- svr4_gid_t cgid;
- svr4_mode_t mode;
- u_long seq;
- svr4_key_t key;
- long pad[4];
-};
-
-/*
- * Message queues
- */
-#define SVR4_msgget 0
-#define SVR4_msgctl 1
-#define SVR4_msgrcv 2
-#define SVR4_msgsnd 3
-
-struct svr4_msg {
- struct svr4_msg *msg_next;
- long msg_type;
- u_short msg_ts;
- short msg_spot;
-};
-
-struct svr4_msqid_ds {
- struct svr4_ipc_perm msg_perm;
- struct svr4_msg *msg_first;
- struct svr4_msg *msg_last;
- u_long msg_cbytes;
- u_long msg_qnum;
- u_long msg_qbytes;
- svr4_pid_t msg_lspid;
- svr4_pid_t msg_lrpid;
- svr4_time_t msg_stime;
- long msg_pad1;
- svr4_time_t msg_rtime;
- long msg_pad2;
- svr4_time_t msg_ctime;
- long msg_pad3;
- short msg_cv;
- short msg_qnum_cv;
- long msg_pad4[3];
-};
-
-struct svr4_msgbuf {
- long mtype; /* message type */
- char mtext[1]; /* message text */
-};
-
-struct svr4_msginfo {
- int msgmap;
- int msgmax;
- int msgmnb;
- int msgmni;
- int msgssz;
- int msgtql;
- u_short msgseg;
-};
-
-/*
- * Shared memory
- */
-#define SVR4_shmat 0
-#define SVR4_shmctl 1
-#define SVR4_shmdt 2
-#define SVR4_shmget 3
-
-/* shmctl() operations */
-#define SVR4_SHM_LOCK 3
-#define SVR4_SHM_UNLOCK 4
-
-struct svr4_shmid_ds {
- struct svr4_ipc_perm shm_perm;
- int shm_segsz;
- void *shm_amp;
- u_short shm_lkcnt;
- svr4_pid_t shm_lpid;
- svr4_pid_t shm_cpid;
- u_long shm_nattch;
- u_long shm_cnattch;
- svr4_time_t shm_atime;
- long shm_pad1;
- svr4_time_t shm_dtime;
- long shm_pad2;
- svr4_time_t shm_ctime;
- long shm_pad3;
- long shm_pad4[4];
-};
-
-/*
- * Semaphores
- */
-#define SVR4_semctl 0
-#define SVR4_semget 1
-#define SVR4_semop 2
-
-/* semctl() operations */
-#define SVR4_SEM_GETNCNT 3
-#define SVR4_SEM_GETPID 4
-#define SVR4_SEM_GETVAL 5
-#define SVR4_SEM_GETALL 6
-#define SVR4_SEM_GETZCNT 7
-#define SVR4_SEM_SETVAL 8
-#define SVR4_SEM_SETALL 9
-
-struct svr4_sem {
- u_short semval;
- svr4_pid_t sempid;
- u_short semncnt;
- u_short semzcnt;
- u_short semncnt_cv;
- u_short semzcnt_cv;
-};
-
-struct svr4_semid_ds {
- struct svr4_ipc_perm sem_perm;
- struct svr4_sem *sem_base;
- u_short sem_nsems;
- svr4_time_t sem_otime;
- long sem_pad1;
- svr4_time_t sem_ctime;
- long sem_pad2;
- long sem_pad3[4];
-};
-
-struct svr4_sembuf {
- u_short sem_num;
- short sem_op;
- short sem_flg;
-};
-
-#endif /* _SVR4_IPC_H */
diff --git a/sys/compat/svr4/svr4_misc.c b/sys/compat/svr4/svr4_misc.c
deleted file mode 100644
index 63990498c702..000000000000
--- a/sys/compat/svr4/svr4_misc.c
+++ /dev/null
@@ -1,1656 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1994 Christos Zoulas
- * 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.
- *
- * $FreeBSD$
- */
-
-/*
- * SVR4 compatibility module.
- *
- * SVR4 system calls that are implemented differently in BSD are
- * handled here.
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/namei.h>
-#include <sys/dirent.h>
-#include <sys/malloc.h>
-#include <sys/proc.h>
-#include <sys/file.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/file.h>
-#include <sys/filedesc.h>
-#include <sys/kernel.h>
-#include <sys/mman.h>
-#include <sys/mount.h>
-#include <sys/resource.h>
-#include <sys/resourcevar.h>
-#include <sys/vnode.h>
-#include <sys/uio.h>
-#include <sys/wait.h>
-#include <sys/times.h>
-#include <sys/fcntl.h>
-#include <sys/sem.h>
-#include <sys/msg.h>
-#include <sys/ptrace.h>
-#include <vm/vm_zone.h>
-
-#include <sys/sysproto.h>
-
-#include <svr4/svr4.h>
-#include <svr4/svr4_types.h>
-#include <svr4/svr4_signal.h>
-#include <svr4/svr4_proto.h>
-#include <svr4/svr4_util.h>
-#include <svr4/svr4_sysconfig.h>
-#include <svr4/svr4_dirent.h>
-#include <svr4/svr4_acl.h>
-#include <svr4/svr4_ulimit.h>
-#include <svr4/svr4_statvfs.h>
-#include <svr4/svr4_hrt.h>
-#include <svr4/svr4_mman.h>
-#include <svr4/svr4_wait.h>
-
-#include <machine/vmparam.h>
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <vm/vm_map.h>
-
-#if defined(NetBSD)
-# if defined(UVM)
-# include <uvm/uvm_extern.h>
-# endif
-#endif
-
-#define BSD_DIRENT(cp) ((struct dirent *)(cp))
-
-static int svr4_mknod __P((struct proc *, register_t *, char *,
- svr4_mode_t, svr4_dev_t));
-
-static __inline clock_t timeval_to_clock_t __P((struct timeval *));
-static int svr4_setinfo __P((struct proc *, int, svr4_siginfo_t *));
-
-struct svr4_hrtcntl_args;
-static int svr4_hrtcntl __P((struct proc *, struct svr4_hrtcntl_args *,
- register_t *));
-static void bsd_statfs_to_svr4_statvfs __P((const struct statfs *,
- struct svr4_statvfs *));
-static void bsd_statfs_to_svr4_statvfs64 __P((const struct statfs *,
- struct svr4_statvfs64 *));
-static struct proc *svr4_pfind __P((pid_t pid));
-
-/* BOGUS noop */
-#if defined(BOGUS)
-int
-svr4_sys_setitimer(p, uap)
- register struct proc *p;
- struct svr4_sys_setitimer_args *uap;
-{
- p->p_retval[0] = 0;
- return 0;
-}
-#endif
-
-int
-svr4_sys_wait(p, uap)
- struct proc *p;
- struct svr4_sys_wait_args *uap;
-{
- struct wait_args w4;
- int error, *retval = p->p_retval, st, sig;
- size_t sz = sizeof(*SCARG(&w4, status));
-
- SCARG(&w4, rusage) = NULL;
- SCARG(&w4, options) = 0;
-
- if (SCARG(uap, status) == NULL) {
- caddr_t sg = stackgap_init();
-
- SCARG(&w4, status) = stackgap_alloc(&sg, sz);
- }
- else
- SCARG(&w4, status) = SCARG(uap, status);
-
- SCARG(&w4, pid) = WAIT_ANY;
-
- if ((error = wait4(p, &w4)) != 0)
- return error;
-
- if ((error = copyin(SCARG(&w4, status), &st, sizeof(st))) != 0)
- return error;
-
- if (WIFSIGNALED(st)) {
- sig = WTERMSIG(st);
- if (sig >= 0 && sig < NSIG)
- st = (st & ~0177) | SVR4_BSD2SVR4_SIG(sig);
- } else if (WIFSTOPPED(st)) {
- sig = WSTOPSIG(st);
- if (sig >= 0 && sig < NSIG)
- st = (st & ~0xff00) | (SVR4_BSD2SVR4_SIG(sig) << 8);
- }
-
- /*
- * It looks like wait(2) on svr4/solaris/2.4 returns
- * the status in retval[1], and the pid on retval[0].
- */
- retval[1] = st;
-
- if (SCARG(uap, status))
- if ((error = copyout(&st, SCARG(uap, status), sizeof(st))) != 0)
- return error;
-
- return 0;
-}
-
-int
-svr4_sys_execv(p, uap)
- struct proc *p;
- struct svr4_sys_execv_args *uap;
-{
- struct execve_args ap;
- caddr_t sg;
-
- sg = stackgap_init();
- CHECKALTEXIST(p, &sg, SCARG(uap, path));
-
- SCARG(&ap, fname) = SCARG(uap, path);
- SCARG(&ap, argv) = SCARG(uap, argp);
- SCARG(&ap, envv) = NULL;
-
- return execve(p, &ap);
-}
-
-int
-svr4_sys_execve(p, uap)
- struct proc *p;
- struct svr4_sys_execve_args *uap;
-{
- struct execve_args ap;
- caddr_t sg;
-
- sg = stackgap_init();
- CHECKALTEXIST(p, &sg, uap->path);
-
- SCARG(&ap, fname) = SCARG(uap, path);
- SCARG(&ap, argv) = SCARG(uap, argp);
- SCARG(&ap, envv) = SCARG(uap, envp);
-
- return execve(p, &ap);
-}
-
-int
-svr4_sys_time(p, v)
- struct proc *p;
- struct svr4_sys_time_args *v;
-{
- struct svr4_sys_time_args *uap = v;
- int error = 0;
- struct timeval tv;
-
- microtime(&tv);
- if (SCARG(uap, t))
- error = copyout(&tv.tv_sec, SCARG(uap, t),
- sizeof(*(SCARG(uap, t))));
- p->p_retval[0] = (int) tv.tv_sec;
-
- return error;
-}
-
-
-/*
- * Read SVR4-style directory entries. We suck them into kernel space so
- * that they can be massaged before being copied out to user code.
- *
- * This code is ported from the Linux emulator: Changes to the VFS interface
- * between FreeBSD and NetBSD have made it simpler to port it from there than
- * to adapt the NetBSD version.
- */
-int
-svr4_sys_getdents64(p, uap)
- struct proc *p;
- struct svr4_sys_getdents64_args *uap;
-{
- register struct dirent *bdp;
- struct vnode *vp;
- caddr_t inp, buf; /* BSD-format */
- int len, reclen; /* BSD-format */
- caddr_t outp; /* SVR4-format */
- int resid, svr4reclen=0; /* SVR4-format */
- struct file *fp;
- struct uio auio;
- struct iovec aiov;
- struct vattr va;
- off_t off;
- struct svr4_dirent64 svr4_dirent;
- int buflen, error, eofflag, nbytes, justone;
- u_long *cookies = NULL, *cookiep;
- int ncookies;
-
- DPRINTF(("svr4_sys_getdents64(%d, *, %d)\n",
- p->p_pid, SCARG(uap, fd), SCARG(uap, nbytes)));
- if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) {
- return (error);
- }
-
- if ((fp->f_flag & FREAD) == 0)
- return (EBADF);
-
- vp = (struct vnode *) fp->f_data;
-
- if (vp->v_type != VDIR)
- return (EINVAL);
-
- if ((error = VOP_GETATTR(vp, &va, p->p_ucred, p))) {
- return error;
- }
-
- nbytes = SCARG(uap, nbytes);
- if (nbytes == 1) {
- nbytes = sizeof (struct svr4_dirent64);
- justone = 1;
- }
- else
- justone = 0;
-
- off = fp->f_offset;
-#define DIRBLKSIZ 512 /* XXX we used to use ufs's DIRBLKSIZ */
- buflen = max(DIRBLKSIZ, nbytes);
- buflen = min(buflen, MAXBSIZE);
- buf = malloc(buflen, M_TEMP, M_WAITOK);
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
-again:
- aiov.iov_base = buf;
- aiov.iov_len = buflen;
- auio.uio_iov = &aiov;
- auio.uio_iovcnt = 1;
- auio.uio_rw = UIO_READ;
- auio.uio_segflg = UIO_SYSSPACE;
- auio.uio_procp = p;
- auio.uio_resid = buflen;
- auio.uio_offset = off;
-
- if (cookies) {
- free(cookies, M_TEMP);
- cookies = NULL;
- }
-
- error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag,
- &ncookies, &cookies);
- if (error) {
- goto out;
- }
-
- inp = buf;
- outp = (caddr_t) SCARG(uap, dp);
- resid = nbytes;
- if ((len = buflen - auio.uio_resid) <= 0) {
- goto eof;
- }
-
- cookiep = cookies;
-
- if (cookies) {
- /*
- * When using cookies, the vfs has the option of reading from
- * a different offset than that supplied (UFS truncates the
- * offset to a block boundary to make sure that it never reads
- * partway through a directory entry, even if the directory
- * has been compacted).
- */
- while (len > 0 && ncookies > 0 && *cookiep <= off) {
- bdp = (struct dirent *) inp;
- len -= bdp->d_reclen;
- inp += bdp->d_reclen;
- cookiep++;
- ncookies--;
- }
- }
-
- while (len > 0) {
- if (cookiep && ncookies == 0)
- break;
- bdp = (struct dirent *) inp;
- reclen = bdp->d_reclen;
- if (reclen & 3) {
- DPRINTF(("svr4_readdir: reclen=%d\n", reclen));
- error = EFAULT;
- goto out;
- }
-
- if (bdp->d_fileno == 0) {
- inp += reclen;
- if (cookiep) {
- off = *cookiep++;
- ncookies--;
- } else
- off += reclen;
- len -= reclen;
- continue;
- }
- svr4reclen = SVR4_RECLEN(&svr4_dirent, bdp->d_namlen);
- if (reclen > len || resid < svr4reclen) {
- outp++;
- break;
- }
- svr4_dirent.d_ino = (long) bdp->d_fileno;
- if (justone) {
- /*
- * old svr4-style readdir usage.
- */
- svr4_dirent.d_off = (svr4_off_t) svr4reclen;
- svr4_dirent.d_reclen = (u_short) bdp->d_namlen;
- } else {
- svr4_dirent.d_off = (svr4_off_t)(off + reclen);
- svr4_dirent.d_reclen = (u_short) svr4reclen;
- }
- strcpy(svr4_dirent.d_name, bdp->d_name);
- if ((error = copyout((caddr_t)&svr4_dirent, outp, svr4reclen)))
- goto out;
- inp += reclen;
- if (cookiep) {
- off = *cookiep++;
- ncookies--;
- } else
- off += reclen;
- outp += svr4reclen;
- resid -= svr4reclen;
- len -= reclen;
- if (justone)
- break;
- }
-
- if (outp == (caddr_t) SCARG(uap, dp))
- goto again;
- fp->f_offset = off;
-
- if (justone)
- nbytes = resid + svr4reclen;
-
-eof:
- p->p_retval[0] = nbytes - resid;
-out:
- if (cookies)
- free(cookies, M_TEMP);
- VOP_UNLOCK(vp, 0, p);
- free(buf, M_TEMP);
- return error;
-}
-
-
-int
-svr4_sys_getdents(p, uap)
- struct proc *p;
- struct svr4_sys_getdents_args *uap;
-{
- struct dirent *bdp;
- struct vnode *vp;
- caddr_t inp, buf; /* BSD-format */
- int len, reclen; /* BSD-format */
- caddr_t outp; /* SVR4-format */
- int resid, svr4_reclen; /* SVR4-format */
- struct file *fp;
- struct uio auio;
- struct iovec aiov;
- struct svr4_dirent idb;
- off_t off; /* true file offset */
- int buflen, error, eofflag;
- u_long *cookiebuf = NULL, *cookie;
- int ncookies = 0, *retval = p->p_retval;
-
- if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
- return (error);
-
- if ((fp->f_flag & FREAD) == 0)
- return (EBADF);
-
- vp = (struct vnode *)fp->f_data;
- if (vp->v_type != VDIR)
- return (EINVAL);
-
- buflen = min(MAXBSIZE, SCARG(uap, nbytes));
- buf = malloc(buflen, M_TEMP, M_WAITOK);
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
- off = fp->f_offset;
-again:
- aiov.iov_base = buf;
- aiov.iov_len = buflen;
- auio.uio_iov = &aiov;
- auio.uio_iovcnt = 1;
- auio.uio_rw = UIO_READ;
- auio.uio_segflg = UIO_SYSSPACE;
- auio.uio_procp = p;
- auio.uio_resid = buflen;
- auio.uio_offset = off;
- /*
- * First we read into the malloc'ed buffer, then
- * we massage it into user space, one record at a time.
- */
- error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, &ncookies,
- &cookiebuf);
- if (error)
- goto out;
-
- inp = buf;
- outp = SCARG(uap, buf);
- resid = SCARG(uap, nbytes);
- if ((len = buflen - auio.uio_resid) == 0)
- goto eof;
-
- for (cookie = cookiebuf; len > 0; len -= reclen) {
- bdp = (struct dirent *)inp;
- reclen = bdp->d_reclen;
- if (reclen & 3)
- panic("svr4_sys_getdents64: bad reclen");
- off = *cookie++; /* each entry points to the next */
- if ((off >> 32) != 0) {
- uprintf("svr4_sys_getdents64: dir offset too large for emulated program");
- error = EINVAL;
- goto out;
- }
- if (bdp->d_fileno == 0) {
- inp += reclen; /* it is a hole; squish it out */
- continue;
- }
- svr4_reclen = SVR4_RECLEN(&idb, bdp->d_namlen);
- if (reclen > len || resid < svr4_reclen) {
- /* entry too big for buffer, so just stop */
- outp++;
- break;
- }
- /*
- * Massage in place to make a SVR4-shaped dirent (otherwise
- * we have to worry about touching user memory outside of
- * the copyout() call).
- */
- idb.d_ino = (svr4_ino_t)bdp->d_fileno;
- idb.d_off = (svr4_off_t)off;
- idb.d_reclen = (u_short)svr4_reclen;
- strcpy(idb.d_name, bdp->d_name);
- if ((error = copyout((caddr_t)&idb, outp, svr4_reclen)))
- goto out;
- /* advance past this real entry */
- inp += reclen;
- /* advance output past SVR4-shaped entry */
- outp += svr4_reclen;
- resid -= svr4_reclen;
- }
-
- /* if we squished out the whole block, try again */
- if (outp == SCARG(uap, buf))
- goto again;
- fp->f_offset = off; /* update the vnode offset */
-
-eof:
- *retval = SCARG(uap, nbytes) - resid;
-out:
- VOP_UNLOCK(vp, 0, p);
- if (cookiebuf)
- free(cookiebuf, M_TEMP);
- free(buf, M_TEMP);
- return error;
-}
-
-
-int
-svr4_sys_mmap(p, uap)
- struct proc *p;
- struct svr4_sys_mmap_args *uap;
-{
- struct mmap_args mm;
- int *retval;
-
- retval = p->p_retval;
-#define _MAP_NEW 0x80000000
- /*
- * Verify the arguments.
- */
- if (SCARG(uap, prot) & ~(PROT_READ | PROT_WRITE | PROT_EXEC))
- return EINVAL; /* XXX still needed? */
-
- if (SCARG(uap, len) == 0)
- return EINVAL;
-
- SCARG(&mm, prot) = SCARG(uap, prot);
- SCARG(&mm, len) = SCARG(uap, len);
- SCARG(&mm, flags) = SCARG(uap, flags) & ~_MAP_NEW;
- SCARG(&mm, fd) = SCARG(uap, fd);
- SCARG(&mm, addr) = SCARG(uap, addr);
- SCARG(&mm, pos) = SCARG(uap, pos);
-
- return mmap(p, &mm);
-}
-
-int
-svr4_sys_mmap64(p, uap)
- struct proc *p;
- struct svr4_sys_mmap64_args *uap;
-{
- struct mmap_args mm;
- void *rp;
-
-#define _MAP_NEW 0x80000000
- /*
- * Verify the arguments.
- */
- if (SCARG(uap, prot) & ~(PROT_READ | PROT_WRITE | PROT_EXEC))
- return EINVAL; /* XXX still needed? */
-
- if (SCARG(uap, len) == 0)
- return EINVAL;
-
- SCARG(&mm, prot) = SCARG(uap, prot);
- SCARG(&mm, len) = SCARG(uap, len);
- SCARG(&mm, flags) = SCARG(uap, flags) & ~_MAP_NEW;
- SCARG(&mm, fd) = SCARG(uap, fd);
- SCARG(&mm, addr) = SCARG(uap, addr);
- SCARG(&mm, pos) = SCARG(uap, pos);
-
- rp = (void *) round_page((vm_offset_t)(p->p_vmspace->vm_daddr + MAXDSIZ));
- if ((SCARG(&mm, flags) & MAP_FIXED) == 0 &&
- SCARG(&mm, addr) != 0 && (void *)SCARG(&mm, addr) < rp)
- SCARG(&mm, addr) = rp;
-
- return mmap(p, &mm);
-}
-
-
-int
-svr4_sys_fchroot(p, uap)
- struct proc *p;
- struct svr4_sys_fchroot_args *uap;
-{
- struct filedesc *fdp = p->p_fd;
- struct vnode *vp;
- struct file *fp;
- int error;
-
- if ((error = suser(p)) != 0)
- return error;
- if ((error = getvnode(fdp, SCARG(uap, fd), &fp)) != 0)
- return error;
- vp = (struct vnode *) fp->f_data;
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
- if (vp->v_type != VDIR)
- error = ENOTDIR;
- else
- error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p);
- VOP_UNLOCK(vp, 0, p);
- if (error)
- return error;
- VREF(vp);
- if (fdp->fd_rdir != NULL)
- vrele(fdp->fd_rdir);
- fdp->fd_rdir = vp;
- return 0;
-}
-
-
-static int
-svr4_mknod(p, retval, path, mode, dev)
- struct proc *p;
- register_t *retval;
- char *path;
- svr4_mode_t mode;
- svr4_dev_t dev;
-{
- caddr_t sg = stackgap_init();
-
- CHECKALTEXIST(p, &sg, path);
-
- if (S_ISFIFO(mode)) {
- struct mkfifo_args ap;
- SCARG(&ap, path) = path;
- SCARG(&ap, mode) = mode;
- return mkfifo(p, &ap);
- } else {
- struct mknod_args ap;
- SCARG(&ap, path) = path;
- SCARG(&ap, mode) = mode;
- SCARG(&ap, dev) = dev;
- return mknod(p, &ap);
- }
-}
-
-
-int
-svr4_sys_mknod(p, uap)
- register struct proc *p;
- struct svr4_sys_mknod_args *uap;
-{
- int *retval = p->p_retval;
- return svr4_mknod(p, retval,
- SCARG(uap, path), SCARG(uap, mode),
- (svr4_dev_t)svr4_to_bsd_odev_t(SCARG(uap, dev)));
-}
-
-
-int
-svr4_sys_xmknod(p, uap)
- struct proc *p;
- struct svr4_sys_xmknod_args *uap;
-{
- int *retval = p->p_retval;
- return svr4_mknod(p, retval,
- SCARG(uap, path), SCARG(uap, mode),
- (svr4_dev_t)svr4_to_bsd_dev_t(SCARG(uap, dev)));
-}
-
-
-int
-svr4_sys_vhangup(p, uap)
- struct proc *p;
- struct svr4_sys_vhangup_args *uap;
-{
- return 0;
-}
-
-
-int
-svr4_sys_sysconfig(p, uap)
- struct proc *p;
- struct svr4_sys_sysconfig_args *uap;
-{
- int *retval;
-
- retval = &(p->p_retval[0]);
-
- switch (SCARG(uap, name)) {
- case SVR4_CONFIG_UNUSED:
- *retval = 0;
- break;
- case SVR4_CONFIG_NGROUPS:
- *retval = NGROUPS_MAX;
- break;
- case SVR4_CONFIG_CHILD_MAX:
- *retval = maxproc;
- break;
- case SVR4_CONFIG_OPEN_FILES:
- *retval = maxfiles;
- break;
- case SVR4_CONFIG_POSIX_VER:
- *retval = 198808;
- break;
- case SVR4_CONFIG_PAGESIZE:
- *retval = PAGE_SIZE;
- break;
- case SVR4_CONFIG_CLK_TCK:
- *retval = 60; /* should this be `hz', ie. 100? */
- break;
- case SVR4_CONFIG_XOPEN_VER:
- *retval = 2; /* XXX: What should that be? */
- break;
- case SVR4_CONFIG_PROF_TCK:
- *retval = 60; /* XXX: What should that be? */
- break;
- case SVR4_CONFIG_NPROC_CONF:
- *retval = 1; /* Only one processor for now */
- break;
- case SVR4_CONFIG_NPROC_ONLN:
- *retval = 1; /* And it better be online */
- break;
- case SVR4_CONFIG_AIO_LISTIO_MAX:
- case SVR4_CONFIG_AIO_MAX:
- case SVR4_CONFIG_AIO_PRIO_DELTA_MAX:
- *retval = 0; /* No aio support */
- break;
- case SVR4_CONFIG_DELAYTIMER_MAX:
- *retval = 0; /* No delaytimer support */
- break;
- case SVR4_CONFIG_MQ_OPEN_MAX:
- *retval = msginfo.msgmni;
- break;
- case SVR4_CONFIG_MQ_PRIO_MAX:
- *retval = 0; /* XXX: Don't know */
- break;
- case SVR4_CONFIG_RTSIG_MAX:
- *retval = 0;
- break;
- case SVR4_CONFIG_SEM_NSEMS_MAX:
- *retval = seminfo.semmni;
- break;
- case SVR4_CONFIG_SEM_VALUE_MAX:
- *retval = seminfo.semvmx;
- break;
- case SVR4_CONFIG_SIGQUEUE_MAX:
- *retval = 0; /* XXX: Don't know */
- break;
- case SVR4_CONFIG_SIGRT_MIN:
- case SVR4_CONFIG_SIGRT_MAX:
- *retval = 0; /* No real time signals */
- break;
- case SVR4_CONFIG_TIMER_MAX:
- *retval = 3; /* XXX: real, virtual, profiling */
- break;
-#if defined(NOTYET)
- case SVR4_CONFIG_PHYS_PAGES:
-#if defined(UVM)
- *retval = uvmexp.free; /* XXX: free instead of total */
-#else
- *retval = cnt.v_free_count; /* XXX: free instead of total */
-#endif
- break;
- case SVR4_CONFIG_AVPHYS_PAGES:
-#if defined(UVM)
- *retval = uvmexp.active; /* XXX: active instead of avg */
-#else
- *retval = cnt.v_active_count; /* XXX: active instead of avg */
-#endif
- break;
-#endif /* NOTYET */
-
- default:
- return EINVAL;
- }
- return 0;
-}
-
-extern int swap_pager_full;
-
-/* ARGSUSED */
-int
-svr4_sys_break(p, uap)
- struct proc *p;
- struct svr4_sys_break_args *uap;
-{
- struct vmspace *vm = p->p_vmspace;
- vm_offset_t new, old, base, ns;
- int rv;
-
- base = round_page((vm_offset_t) vm->vm_daddr);
- ns = (vm_offset_t)SCARG(uap, nsize);
- new = round_page(ns);
- if (new > base) {
- if ((new - base) > (unsigned) p->p_rlimit[RLIMIT_DATA].rlim_cur) {
- return ENOMEM;
- }
- if (new >= VM_MAXUSER_ADDRESS) {
- return (ENOMEM);
- }
- } else if (new < base) {
- /*
- * This is simply an invalid value. If someone wants to
- * do fancy address space manipulations, mmap and munmap
- * can do most of what the user would want.
- */
- return EINVAL;
- }
-
- old = base + ctob(vm->vm_dsize);
-
- if (new > old) {
- vm_size_t diff;
- if (swap_pager_full) {
- return (ENOMEM);
- }
- diff = new - old;
- rv = vm_map_find(&vm->vm_map, NULL, 0, &old, diff, FALSE,
- VM_PROT_ALL, VM_PROT_ALL, 0);
- if (rv != KERN_SUCCESS) {
- return (ENOMEM);
- }
- vm->vm_dsize += btoc(diff);
- } else if (new < old) {
- rv = vm_map_remove(&vm->vm_map, new, old);
- if (rv != KERN_SUCCESS) {
- return (ENOMEM);
- }
- vm->vm_dsize -= btoc(old - new);
- }
-
- return (0);
-}
-
-static __inline clock_t
-timeval_to_clock_t(tv)
- struct timeval *tv;
-{
- return tv->tv_sec * hz + tv->tv_usec / (1000000 / hz);
-}
-
-
-int
-svr4_sys_times(p, uap)
- struct proc *p;
- struct svr4_sys_times_args *uap;
-{
- int error, *retval = p->p_retval;
- struct tms tms;
- struct timeval t;
- struct rusage *ru;
- struct rusage r;
- struct getrusage_args ga;
-
- caddr_t sg = stackgap_init();
- ru = stackgap_alloc(&sg, sizeof(struct rusage));
-
- SCARG(&ga, who) = RUSAGE_SELF;
- SCARG(&ga, rusage) = ru;
-
- error = getrusage(p, &ga);
- if (error)
- return error;
-
- if ((error = copyin(ru, &r, sizeof r)) != 0)
- return error;
-
- tms.tms_utime = timeval_to_clock_t(&r.ru_utime);
- tms.tms_stime = timeval_to_clock_t(&r.ru_stime);
-
- SCARG(&ga, who) = RUSAGE_CHILDREN;
- error = getrusage(p, &ga);
- if (error)
- return error;
-
- if ((error = copyin(ru, &r, sizeof r)) != 0)
- return error;
-
- tms.tms_cutime = timeval_to_clock_t(&r.ru_utime);
- tms.tms_cstime = timeval_to_clock_t(&r.ru_stime);
-
- microtime(&t);
- *retval = timeval_to_clock_t(&t);
-
- return copyout(&tms, SCARG(uap, tp), sizeof(tms));
-}
-
-
-int
-svr4_sys_ulimit(p, uap)
- struct proc *p;
- struct svr4_sys_ulimit_args *uap;
-{
- int *retval = p->p_retval;
-
- switch (SCARG(uap, cmd)) {
- case SVR4_GFILLIM:
- *retval = p->p_rlimit[RLIMIT_FSIZE].rlim_cur / 512;
- if (*retval == -1)
- *retval = 0x7fffffff;
- return 0;
-
- case SVR4_SFILLIM:
- {
- int error;
- struct __setrlimit_args srl;
- struct rlimit krl;
- caddr_t sg = stackgap_init();
- struct rlimit *url = (struct rlimit *)
- stackgap_alloc(&sg, sizeof *url);
-
- krl.rlim_cur = SCARG(uap, newlimit) * 512;
- krl.rlim_max = p->p_rlimit[RLIMIT_FSIZE].rlim_max;
-
- error = copyout(&krl, url, sizeof(*url));
- if (error)
- return error;
-
- SCARG(&srl, which) = RLIMIT_FSIZE;
- SCARG(&srl, rlp) = (struct orlimit *)url;
-
- error = setrlimit(p, &srl);
- if (error)
- return error;
-
- *retval = p->p_rlimit[RLIMIT_FSIZE].rlim_cur;
- if (*retval == -1)
- *retval = 0x7fffffff;
- return 0;
- }
-
- case SVR4_GMEMLIM:
- {
- struct vmspace *vm = p->p_vmspace;
- register_t r = p->p_rlimit[RLIMIT_DATA].rlim_cur;
-
- if (r == -1)
- r = 0x7fffffff;
- r += (long) vm->vm_daddr;
- if (r < 0)
- r = 0x7fffffff;
- *retval = r;
- return 0;
- }
-
- case SVR4_GDESLIM:
- *retval = p->p_rlimit[RLIMIT_NOFILE].rlim_cur;
- if (*retval == -1)
- *retval = 0x7fffffff;
- return 0;
-
- default:
- return EINVAL;
- }
-}
-
-static struct proc *
-svr4_pfind(pid)
- pid_t pid;
-{
- struct proc *p;
-
- /* look in the live processes */
- if ((p = pfind(pid)) != NULL)
- return p;
-
- /* look in the zombies */
- for (p = zombproc.lh_first; p != 0; p = p->p_list.le_next)
- if (p->p_pid == pid)
- return p;
-
- return NULL;
-}
-
-
-int
-svr4_sys_pgrpsys(p, uap)
- struct proc *p;
- struct svr4_sys_pgrpsys_args *uap;
-{
- int *retval = p->p_retval;
-
- switch (SCARG(uap, cmd)) {
- case 1: /* setpgrp() */
- /*
- * SVR4 setpgrp() (which takes no arguments) has the
- * semantics that the session ID is also created anew, so
- * in almost every sense, setpgrp() is identical to
- * setsid() for SVR4. (Under BSD, the difference is that
- * a setpgid(0,0) will not create a new session.)
- */
- setsid(p, NULL);
- /*FALLTHROUGH*/
-
- case 0: /* getpgrp() */
- *retval = p->p_pgrp->pg_id;
- return 0;
-
- case 2: /* getsid(pid) */
- if (SCARG(uap, pid) != 0 &&
- (p = svr4_pfind(SCARG(uap, pid))) == NULL)
- return ESRCH;
- /*
- * This has already been initialized to the pid of
- * the session leader.
- */
- *retval = (register_t) p->p_session->s_leader->p_pid;
- return 0;
-
- case 3: /* setsid() */
- return setsid(p, NULL);
-
- case 4: /* getpgid(pid) */
-
- if (SCARG(uap, pid) != 0 &&
- (p = svr4_pfind(SCARG(uap, pid))) == NULL)
- return ESRCH;
-
- *retval = (int) p->p_pgrp->pg_id;
- return 0;
-
- case 5: /* setpgid(pid, pgid); */
- {
- struct setpgid_args sa;
-
- SCARG(&sa, pid) = SCARG(uap, pid);
- SCARG(&sa, pgid) = SCARG(uap, pgid);
- return setpgid(p, &sa);
- }
-
- default:
- return EINVAL;
- }
-}
-
-#define syscallarg(x) union { x datum; register_t pad; }
-
-struct svr4_hrtcntl_args {
- int cmd;
- int fun;
- int clk;
- svr4_hrt_interval_t * iv;
- svr4_hrt_time_t * ti;
-};
-
-
-static int
-svr4_hrtcntl(p, uap, retval)
- struct proc *p;
- struct svr4_hrtcntl_args *uap;
- register_t *retval;
-{
- switch (SCARG(uap, fun)) {
- case SVR4_HRT_CNTL_RES:
- DPRINTF(("htrcntl(RES)\n"));
- *retval = SVR4_HRT_USEC;
- return 0;
-
- case SVR4_HRT_CNTL_TOFD:
- DPRINTF(("htrcntl(TOFD)\n"));
- {
- struct timeval tv;
- svr4_hrt_time_t t;
- if (SCARG(uap, clk) != SVR4_HRT_CLK_STD) {
- DPRINTF(("clk == %d\n", SCARG(uap, clk)));
- return EINVAL;
- }
- if (SCARG(uap, ti) == NULL) {
- DPRINTF(("ti NULL\n"));
- return EINVAL;
- }
- microtime(&tv);
- t.h_sec = tv.tv_sec;
- t.h_rem = tv.tv_usec;
- t.h_res = SVR4_HRT_USEC;
- return copyout(&t, SCARG(uap, ti), sizeof(t));
- }
-
- case SVR4_HRT_CNTL_START:
- DPRINTF(("htrcntl(START)\n"));
- return ENOSYS;
-
- case SVR4_HRT_CNTL_GET:
- DPRINTF(("htrcntl(GET)\n"));
- return ENOSYS;
- default:
- DPRINTF(("Bad htrcntl command %d\n", SCARG(uap, fun)));
- return ENOSYS;
- }
-}
-
-
-int
-svr4_sys_hrtsys(p, uap)
- struct proc *p;
- struct svr4_sys_hrtsys_args *uap;
-{
- int *retval = p->p_retval;
-
- switch (SCARG(uap, cmd)) {
- case SVR4_HRT_CNTL:
- return svr4_hrtcntl(p, (struct svr4_hrtcntl_args *) uap,
- retval);
-
- case SVR4_HRT_ALRM:
- DPRINTF(("hrtalarm\n"));
- return ENOSYS;
-
- case SVR4_HRT_SLP:
- DPRINTF(("hrtsleep\n"));
- return ENOSYS;
-
- case SVR4_HRT_CAN:
- DPRINTF(("hrtcancel\n"));
- return ENOSYS;
-
- default:
- DPRINTF(("Bad hrtsys command %d\n", SCARG(uap, cmd)));
- return EINVAL;
- }
-}
-
-
-static int
-svr4_setinfo(p, st, s)
- struct proc *p;
- int st;
- svr4_siginfo_t *s;
-{
- svr4_siginfo_t i;
- int sig;
-
- memset(&i, 0, sizeof(i));
-
- i.si_signo = SVR4_SIGCHLD;
- i.si_errno = 0; /* XXX? */
-
- if (p) {
- i.si_pid = p->p_pid;
- if (p->p_stat == SZOMB) {
- i.si_stime = p->p_ru->ru_stime.tv_sec;
- i.si_utime = p->p_ru->ru_utime.tv_sec;
- }
- else {
- i.si_stime = p->p_stats->p_ru.ru_stime.tv_sec;
- i.si_utime = p->p_stats->p_ru.ru_utime.tv_sec;
- }
- }
-
- if (WIFEXITED(st)) {
- i.si_status = WEXITSTATUS(st);
- i.si_code = SVR4_CLD_EXITED;
- } else if (WIFSTOPPED(st)) {
- sig = WSTOPSIG(st);
- if (sig >= 0 && sig < NSIG)
- i.si_status = SVR4_BSD2SVR4_SIG(sig);
-
- if (i.si_status == SVR4_SIGCONT)
- i.si_code = SVR4_CLD_CONTINUED;
- else
- i.si_code = SVR4_CLD_STOPPED;
- } else {
- sig = WTERMSIG(st);
- if (sig >= 0 && sig < NSIG)
- i.si_status = SVR4_BSD2SVR4_SIG(sig);
-
- if (WCOREDUMP(st))
- i.si_code = SVR4_CLD_DUMPED;
- else
- i.si_code = SVR4_CLD_KILLED;
- }
-
- DPRINTF(("siginfo [pid %ld signo %d code %d errno %d status %d]\n",
- i.si_pid, i.si_signo, i.si_code, i.si_errno, i.si_status));
-
- return copyout(&i, s, sizeof(i));
-}
-
-
-int
-svr4_sys_waitsys(p, uap)
- struct proc *p;
- struct svr4_sys_waitsys_args *uap;
-{
- int nfound;
- int error, *retval = p->p_retval;
- struct proc *q, *t;
-
-
- switch (SCARG(uap, grp)) {
- case SVR4_P_PID:
- break;
-
- case SVR4_P_PGID:
- SCARG(uap, id) = -p->p_pgid;
- break;
-
- case SVR4_P_ALL:
- SCARG(uap, id) = WAIT_ANY;
- break;
-
- default:
- return EINVAL;
- }
-
- DPRINTF(("waitsys(%d, %d, %p, %x)\n",
- SCARG(uap, grp), SCARG(uap, id),
- SCARG(uap, info), SCARG(uap, options)));
-
-loop:
- nfound = 0;
- for (q = p->p_children.lh_first; q != 0; q = q->p_sibling.le_next) {
- if (SCARG(uap, id) != WAIT_ANY &&
- q->p_pid != SCARG(uap, id) &&
- q->p_pgid != -SCARG(uap, id)) {
- DPRINTF(("pid %d pgid %d != %d\n", q->p_pid,
- q->p_pgid, SCARG(uap, id)));
- continue;
- }
- nfound++;
- if (q->p_stat == SZOMB &&
- ((SCARG(uap, options) & (SVR4_WEXITED|SVR4_WTRAPPED)))) {
- *retval = 0;
- DPRINTF(("found %d\n", q->p_pid));
- if ((error = svr4_setinfo(q, q->p_xstat,
- SCARG(uap, info))) != 0)
- return error;
-
-
- if ((SCARG(uap, options) & SVR4_WNOWAIT)) {
- DPRINTF(("Don't wait\n"));
- return 0;
- }
-
- /*
- * If we got the child via ptrace(2) or procfs, and
- * the parent is different (meaning the process was
- * attached, rather than run as a child), then we need
- * to give it back to the ol dparent, and send the
- * parent a SIGCHLD. The rest of the cleanup will be
- * done when the old parent waits on the child.
- */
- if ((q->p_flag & P_TRACED) &&
- q->p_oppid != q->p_pptr->p_pid) {
- t = pfind(q->p_oppid);
- proc_reparent(q, t ? t : initproc);
- q->p_oppid = 0;
- q->p_flag &= ~(P_TRACED | P_WAITED);
- wakeup((caddr_t)q->p_pptr);
- return 0;
- }
- q->p_xstat = 0;
- ruadd(&p->p_stats->p_cru, q->p_ru);
-
- FREE(q->p_ru, M_ZOMBIE);
-
- /*
- * Finally finished with old proc entry.
- * Unlink it from its process group and free it.
- */
- leavepgrp(q);
-
- LIST_REMOVE(q, p_list); /* off zombproc */
-
- LIST_REMOVE(q, p_sibling);
-
- /*
- * Decrement the count of procs running with this uid.
- */
- (void)chgproccnt(q->p_cred->p_ruid, -1);
-
- /*
- * Free up credentials.
- */
- if (--q->p_cred->p_refcnt == 0) {
- crfree(q->p_ucred);
- FREE(q->p_cred, M_SUBPROC);
- }
-
- /*
- * Release reference to text vnode
- */
- if (q->p_textvp)
- vrele(q->p_textvp);
-
- /*
- * Give machine-dependent layer a chance
- * to free anything that cpu_exit couldn't
- * release while still running in process context.
- */
- cpu_wait(q);
-#if defined(__NetBSD__)
- pool_put(&proc_pool, q);
-#endif
- nprocs--;
- return 0;
- }
- if (q->p_stat == SSTOP && (q->p_flag & P_WAITED) == 0 &&
- (q->p_flag & P_TRACED ||
- (SCARG(uap, options) & (SVR4_WSTOPPED|SVR4_WCONTINUED)))) {
- DPRINTF(("jobcontrol %d\n", q->p_pid));
- if (((SCARG(uap, options) & SVR4_WNOWAIT)) == 0)
- q->p_flag |= P_WAITED;
- *retval = 0;
- return svr4_setinfo(q, W_STOPCODE(q->p_xstat),
- SCARG(uap, info));
- }
- }
-
- if (nfound == 0)
- return ECHILD;
-
- if (SCARG(uap, options) & SVR4_WNOHANG) {
- *retval = 0;
- if ((error = svr4_setinfo(NULL, 0, SCARG(uap, info))) != 0)
- return error;
- return 0;
- }
-
- if ((error = tsleep((caddr_t)p, PWAIT | PCATCH, "svr4_wait", 0)) != 0)
- return error;
- goto loop;
-}
-
-
-static void
-bsd_statfs_to_svr4_statvfs(bfs, sfs)
- const struct statfs *bfs;
- struct svr4_statvfs *sfs;
-{
- sfs->f_bsize = bfs->f_iosize; /* XXX */
- sfs->f_frsize = bfs->f_bsize;
- sfs->f_blocks = bfs->f_blocks;
- sfs->f_bfree = bfs->f_bfree;
- sfs->f_bavail = bfs->f_bavail;
- sfs->f_files = bfs->f_files;
- sfs->f_ffree = bfs->f_ffree;
- sfs->f_favail = bfs->f_ffree;
- sfs->f_fsid = bfs->f_fsid.val[0];
- memcpy(sfs->f_basetype, bfs->f_fstypename, sizeof(sfs->f_basetype));
- sfs->f_flag = 0;
- if (bfs->f_flags & MNT_RDONLY)
- sfs->f_flag |= SVR4_ST_RDONLY;
- if (bfs->f_flags & MNT_NOSUID)
- sfs->f_flag |= SVR4_ST_NOSUID;
- sfs->f_namemax = MAXNAMLEN;
- memcpy(sfs->f_fstr, bfs->f_fstypename, sizeof(sfs->f_fstr)); /* XXX */
- memset(sfs->f_filler, 0, sizeof(sfs->f_filler));
-}
-
-
-static void
-bsd_statfs_to_svr4_statvfs64(bfs, sfs)
- const struct statfs *bfs;
- struct svr4_statvfs64 *sfs;
-{
- sfs->f_bsize = bfs->f_iosize; /* XXX */
- sfs->f_frsize = bfs->f_bsize;
- sfs->f_blocks = bfs->f_blocks;
- sfs->f_bfree = bfs->f_bfree;
- sfs->f_bavail = bfs->f_bavail;
- sfs->f_files = bfs->f_files;
- sfs->f_ffree = bfs->f_ffree;
- sfs->f_favail = bfs->f_ffree;
- sfs->f_fsid = bfs->f_fsid.val[0];
- memcpy(sfs->f_basetype, bfs->f_fstypename, sizeof(sfs->f_basetype));
- sfs->f_flag = 0;
- if (bfs->f_flags & MNT_RDONLY)
- sfs->f_flag |= SVR4_ST_RDONLY;
- if (bfs->f_flags & MNT_NOSUID)
- sfs->f_flag |= SVR4_ST_NOSUID;
- sfs->f_namemax = MAXNAMLEN;
- memcpy(sfs->f_fstr, bfs->f_fstypename, sizeof(sfs->f_fstr)); /* XXX */
- memset(sfs->f_filler, 0, sizeof(sfs->f_filler));
-}
-
-
-int
-svr4_sys_statvfs(p, uap)
- struct proc *p;
- struct svr4_sys_statvfs_args *uap;
-{
- struct statfs_args fs_args;
- caddr_t sg = stackgap_init();
- struct statfs *fs = stackgap_alloc(&sg, sizeof(struct statfs));
- struct statfs bfs;
- struct svr4_statvfs sfs;
- int error;
-
- CHECKALTEXIST(p, &sg, SCARG(uap, path));
- SCARG(&fs_args, path) = SCARG(uap, path);
- SCARG(&fs_args, buf) = fs;
-
- if ((error = statfs(p, &fs_args)) != 0)
- return error;
-
- if ((error = copyin(fs, &bfs, sizeof(bfs))) != 0)
- return error;
-
- bsd_statfs_to_svr4_statvfs(&bfs, &sfs);
-
- return copyout(&sfs, SCARG(uap, fs), sizeof(sfs));
-}
-
-
-int
-svr4_sys_fstatvfs(p, uap)
- struct proc *p;
- struct svr4_sys_fstatvfs_args *uap;
-{
- struct fstatfs_args fs_args;
- caddr_t sg = stackgap_init();
- struct statfs *fs = stackgap_alloc(&sg, sizeof(struct statfs));
- struct statfs bfs;
- struct svr4_statvfs sfs;
- int error;
-
- SCARG(&fs_args, fd) = SCARG(uap, fd);
- SCARG(&fs_args, buf) = fs;
-
- if ((error = fstatfs(p, &fs_args)) != 0)
- return error;
-
- if ((error = copyin(fs, &bfs, sizeof(bfs))) != 0)
- return error;
-
- bsd_statfs_to_svr4_statvfs(&bfs, &sfs);
-
- return copyout(&sfs, SCARG(uap, fs), sizeof(sfs));
-}
-
-
-int
-svr4_sys_statvfs64(p, uap)
- struct proc *p;
- struct svr4_sys_statvfs64_args *uap;
-{
- struct statfs_args fs_args;
- caddr_t sg = stackgap_init();
- struct statfs *fs = stackgap_alloc(&sg, sizeof(struct statfs));
- struct statfs bfs;
- struct svr4_statvfs64 sfs;
- int error;
-
- CHECKALTEXIST(p, &sg, SCARG(uap, path));
- SCARG(&fs_args, path) = SCARG(uap, path);
- SCARG(&fs_args, buf) = fs;
-
- if ((error = statfs(p, &fs_args)) != 0)
- return error;
-
- if ((error = copyin(fs, &bfs, sizeof(bfs))) != 0)
- return error;
-
- bsd_statfs_to_svr4_statvfs64(&bfs, &sfs);
-
- return copyout(&sfs, SCARG(uap, fs), sizeof(sfs));
-}
-
-
-int
-svr4_sys_fstatvfs64(p, uap)
- struct proc *p;
- struct svr4_sys_fstatvfs64_args *uap;
-{
- struct fstatfs_args fs_args;
- caddr_t sg = stackgap_init();
- struct statfs *fs = stackgap_alloc(&sg, sizeof(struct statfs));
- struct statfs bfs;
- struct svr4_statvfs64 sfs;
- int error;
-
- SCARG(&fs_args, fd) = SCARG(uap, fd);
- SCARG(&fs_args, buf) = fs;
-
- if ((error = fstatfs(p, &fs_args)) != 0)
- return error;
-
- if ((error = copyin(fs, &bfs, sizeof(bfs))) != 0)
- return error;
-
- bsd_statfs_to_svr4_statvfs64(&bfs, &sfs);
-
- return copyout(&sfs, SCARG(uap, fs), sizeof(sfs));
-}
-
-int
-svr4_sys_alarm(p, uap)
- struct proc *p;
- struct svr4_sys_alarm_args *uap;
-{
- int error;
- struct itimerval *itp, *oitp;
- struct setitimer_args sa;
- caddr_t sg = stackgap_init();
-
- itp = stackgap_alloc(&sg, sizeof(*itp));
- oitp = stackgap_alloc(&sg, sizeof(*oitp));
- timevalclear(&itp->it_interval);
- itp->it_value.tv_sec = SCARG(uap, sec);
- itp->it_value.tv_usec = 0;
-
- SCARG(&sa, which) = ITIMER_REAL;
- SCARG(&sa, itv) = itp;
- SCARG(&sa, oitv) = oitp;
- error = setitimer(p, &sa);
- if (error)
- return error;
- if (oitp->it_value.tv_usec)
- oitp->it_value.tv_sec++;
- p->p_retval[0] = oitp->it_value.tv_sec;
- return 0;
-
-}
-
-int
-svr4_sys_gettimeofday(p, uap)
- struct proc *p;
- struct svr4_sys_gettimeofday_args *uap;
-{
- if (SCARG(uap, tp)) {
- struct timeval atv;
-
- microtime(&atv);
- return copyout(&atv, SCARG(uap, tp), sizeof (atv));
- }
-
- return 0;
-}
-
-int
-svr4_sys_facl(p, uap)
- struct proc *p;
- struct svr4_sys_facl_args *uap;
-{
- int *retval;
-
- retval = p->p_retval;
- *retval = 0;
-
- switch (SCARG(uap, cmd)) {
- case SVR4_SYS_SETACL:
- /* We don't support acls on any filesystem */
- return ENOSYS;
-
- case SVR4_SYS_GETACL:
- return copyout(retval, &SCARG(uap, num),
- sizeof(SCARG(uap, num)));
-
- case SVR4_SYS_GETACLCNT:
- return 0;
-
- default:
- return EINVAL;
- }
-}
-
-
-int
-svr4_sys_acl(p, uap)
- struct proc *p;
- struct svr4_sys_acl_args *uap;
-{
- /* XXX: for now the same */
- return svr4_sys_facl(p, (struct svr4_sys_facl_args *)uap);
-}
-
-int
-svr4_sys_auditsys(p, uap)
- struct proc *p;
- struct svr4_sys_auditsys_args *uap;
-{
- /*
- * XXX: Big brother is *not* watching.
- */
- return 0;
-}
-
-int
-svr4_sys_memcntl(p, uap)
- struct proc *p;
- struct svr4_sys_memcntl_args *uap;
-{
- switch (SCARG(uap, cmd)) {
- case SVR4_MC_SYNC:
- {
- struct msync_args msa;
-
- SCARG(&msa, addr) = SCARG(uap, addr);
- SCARG(&msa, len) = SCARG(uap, len);
- SCARG(&msa, flags) = (int)SCARG(uap, arg);
-
- return msync(p, &msa);
- }
- case SVR4_MC_ADVISE:
- {
- struct madvise_args maa;
-
- SCARG(&maa, addr) = SCARG(uap, addr);
- SCARG(&maa, len) = SCARG(uap, len);
- SCARG(&maa, behav) = (int)SCARG(uap, arg);
-
- return madvise(p, &maa);
- }
- case SVR4_MC_LOCK:
- case SVR4_MC_UNLOCK:
- case SVR4_MC_LOCKAS:
- case SVR4_MC_UNLOCKAS:
- return EOPNOTSUPP;
- default:
- return ENOSYS;
- }
-}
-
-
-int
-svr4_sys_nice(p, uap)
- struct proc *p;
- struct svr4_sys_nice_args *uap;
-{
- struct setpriority_args ap;
- int error;
-
- SCARG(&ap, which) = PRIO_PROCESS;
- SCARG(&ap, who) = 0;
- SCARG(&ap, prio) = SCARG(uap, prio);
-
- if ((error = setpriority(p, &ap)) != 0)
- return error;
-
- /* the cast is stupid, but the structures are the same */
- if ((error = getpriority(p, (struct getpriority_args *)&ap)) != 0)
- return error;
-
- return 0;
-}
-
-int
-svr4_sys_resolvepath(p, uap)
- struct proc *p;
- struct svr4_sys_resolvepath_args *uap;
-{
- struct nameidata nd;
- int error, *retval = p->p_retval;
-
- NDINIT(&nd, LOOKUP, NOFOLLOW | SAVENAME, UIO_USERSPACE,
- SCARG(uap, path), p);
-
- if ((error = namei(&nd)) != 0)
- return error;
-
- if ((error = copyout(nd.ni_cnd.cn_pnbuf, SCARG(uap, buf),
- SCARG(uap, bufsiz))) != 0)
- goto bad;
-
- *retval = strlen(nd.ni_cnd.cn_pnbuf) < SCARG(uap, bufsiz) ?
- strlen(nd.ni_cnd.cn_pnbuf) + 1 : SCARG(uap, bufsiz);
-bad:
- NDFREE(&nd, NDF_ONLY_PNBUF);
- vput(nd.ni_vp);
- return error;
-}
diff --git a/sys/compat/svr4/svr4_mman.h b/sys/compat/svr4/svr4_mman.h
deleted file mode 100644
index db7c3dacef5f..000000000000
--- a/sys/compat/svr4/svr4_mman.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1997 Todd Vierling
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _SVR4_MMAN_H_
-#define _SVR4_MMAN_H_
-
-/*
- * Commands and flags passed to memcntl().
- * Most of them are the same as <sys/mman.h>, but we need the MC_
- * memcntl command definitions.
- */
-
-#define SVR4_MC_SYNC 1
-#define SVR4_MC_LOCK 2
-#define SVR4_MC_UNLOCK 3
-#define SVR4_MC_ADVISE 4
-#define SVR4_MC_LOCKAS 5
-#define SVR4_MC_UNLOCKAS 6
-
-#endif /* !_SVR4_MMAN_H */
diff --git a/sys/compat/svr4/svr4_proto.h b/sys/compat/svr4/svr4_proto.h
deleted file mode 100644
index 407513af4f89..000000000000
--- a/sys/compat/svr4/svr4_proto.h
+++ /dev/null
@@ -1,473 +0,0 @@
-/*
- * System call prototypes.
- *
- * DO NOT EDIT-- this file is automatically generated.
- * $FreeBSD$
- * created from; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
- */
-
-#ifndef _SVR4_SYSPROTO_H_
-#define _SVR4_SYSPROTO_H_
-
-#include <sys/signal.h>
-
-struct proc;
-
-#define PAD_(t) (sizeof(register_t) <= sizeof(t) ? \
- 0 : sizeof(register_t) - sizeof(t))
-
-struct svr4_sys_open_args {
- char * path; char path_[PAD_(char *)];
- int flags; char flags_[PAD_(int)];
- int mode; char mode_[PAD_(int)];
-};
-struct svr4_sys_wait_args {
- int * status; char status_[PAD_(int *)];
-};
-struct svr4_sys_creat_args {
- char * path; char path_[PAD_(char *)];
- int mode; char mode_[PAD_(int)];
-};
-struct svr4_sys_execv_args {
- char * path; char path_[PAD_(char *)];
- char ** argp; char argp_[PAD_(char **)];
-};
-struct svr4_sys_time_args {
- time_t * t; char t_[PAD_(time_t *)];
-};
-struct svr4_sys_mknod_args {
- char * path; char path_[PAD_(char *)];
- int mode; char mode_[PAD_(int)];
- int dev; char dev_[PAD_(int)];
-};
-struct svr4_sys_break_args {
- caddr_t nsize; char nsize_[PAD_(caddr_t)];
-};
-struct svr4_sys_stat_args {
- char * path; char path_[PAD_(char *)];
- struct svr4_stat * ub; char ub_[PAD_(struct svr4_stat *)];
-};
-struct svr4_sys_alarm_args {
- unsigned sec; char sec_[PAD_(unsigned)];
-};
-struct svr4_sys_fstat_args {
- int fd; char fd_[PAD_(int)];
- struct svr4_stat * sb; char sb_[PAD_(struct svr4_stat *)];
-};
-struct svr4_sys_pause_args {
- register_t dummy;
-};
-struct svr4_sys_utime_args {
- char * path; char path_[PAD_(char *)];
- struct svr4_utimbuf * ubuf; char ubuf_[PAD_(struct svr4_utimbuf *)];
-};
-struct svr4_sys_access_args {
- char * path; char path_[PAD_(char *)];
- int flags; char flags_[PAD_(int)];
-};
-struct svr4_sys_nice_args {
- int prio; char prio_[PAD_(int)];
-};
-struct svr4_sys_kill_args {
- int pid; char pid_[PAD_(int)];
- int signum; char signum_[PAD_(int)];
-};
-struct svr4_sys_pgrpsys_args {
- int cmd; char cmd_[PAD_(int)];
- int pid; char pid_[PAD_(int)];
- int pgid; char pgid_[PAD_(int)];
-};
-struct svr4_sys_times_args {
- struct tms * tp; char tp_[PAD_(struct tms *)];
-};
-struct svr4_sys_signal_args {
- int signum; char signum_[PAD_(int)];
- svr4_sig_t handler; char handler_[PAD_(svr4_sig_t)];
-};
-#if defined(NOTYET)
-struct svr4_sys_msgsys_args {
- int what; char what_[PAD_(int)];
- int a2; char a2_[PAD_(int)];
- int a3; char a3_[PAD_(int)];
- int a4; char a4_[PAD_(int)];
- int a5; char a5_[PAD_(int)];
-};
-#else
-#endif
-struct svr4_sys_sysarch_args {
- int op; char op_[PAD_(int)];
- void * a1; char a1_[PAD_(void *)];
-};
-struct svr4_sys_ioctl_args {
- int fd; char fd_[PAD_(int)];
- u_long com; char com_[PAD_(u_long)];
- caddr_t data; char data_[PAD_(caddr_t)];
-};
-struct svr4_sys_utssys_args {
- void * a1; char a1_[PAD_(void *)];
- void * a2; char a2_[PAD_(void *)];
- int sel; char sel_[PAD_(int)];
- void * a3; char a3_[PAD_(void *)];
-};
-struct svr4_sys_execve_args {
- char * path; char path_[PAD_(char *)];
- char ** argp; char argp_[PAD_(char **)];
- char ** envp; char envp_[PAD_(char **)];
-};
-struct svr4_sys_fcntl_args {
- int fd; char fd_[PAD_(int)];
- int cmd; char cmd_[PAD_(int)];
- char * arg; char arg_[PAD_(char *)];
-};
-struct svr4_sys_ulimit_args {
- int cmd; char cmd_[PAD_(int)];
- long newlimit; char newlimit_[PAD_(long)];
-};
-struct svr4_sys_getdents_args {
- int fd; char fd_[PAD_(int)];
- char * buf; char buf_[PAD_(char *)];
- int nbytes; char nbytes_[PAD_(int)];
-};
-struct svr4_sys_getmsg_args {
- int fd; char fd_[PAD_(int)];
- struct svr4_strbuf * ctl; char ctl_[PAD_(struct svr4_strbuf *)];
- struct svr4_strbuf * dat; char dat_[PAD_(struct svr4_strbuf *)];
- int * flags; char flags_[PAD_(int *)];
-};
-struct svr4_sys_putmsg_args {
- int fd; char fd_[PAD_(int)];
- struct svr4_strbuf * ctl; char ctl_[PAD_(struct svr4_strbuf *)];
- struct svr4_strbuf * dat; char dat_[PAD_(struct svr4_strbuf *)];
- int flags; char flags_[PAD_(int)];
-};
-struct svr4_sys_poll_args {
- struct pollfd * fds; char fds_[PAD_(struct pollfd *)];
- unsigned int nfds; char nfds_[PAD_(unsigned int)];
- int timeout; char timeout_[PAD_(int)];
-};
-struct svr4_sys_lstat_args {
- char * path; char path_[PAD_(char *)];
- struct svr4_stat * ub; char ub_[PAD_(struct svr4_stat *)];
-};
-struct svr4_sys_sigprocmask_args {
- int how; char how_[PAD_(int)];
- svr4_sigset_t * set; char set_[PAD_(svr4_sigset_t *)];
- svr4_sigset_t * oset; char oset_[PAD_(svr4_sigset_t *)];
-};
-struct svr4_sys_sigsuspend_args {
- svr4_sigset_t * ss; char ss_[PAD_(svr4_sigset_t *)];
-};
-struct svr4_sys_sigaltstack_args {
- struct svr4_sigaltstack * nss; char nss_[PAD_(struct svr4_sigaltstack *)];
- struct svr4_sigaltstack * oss; char oss_[PAD_(struct svr4_sigaltstack *)];
-};
-struct svr4_sys_sigaction_args {
- int signum; char signum_[PAD_(int)];
- struct svr4_sigaction * nsa; char nsa_[PAD_(struct svr4_sigaction *)];
- struct svr4_sigaction * osa; char osa_[PAD_(struct svr4_sigaction *)];
-};
-struct svr4_sys_sigpending_args {
- int what; char what_[PAD_(int)];
- svr4_sigset_t * mask; char mask_[PAD_(svr4_sigset_t *)];
-};
-struct svr4_sys_context_args {
- int func; char func_[PAD_(int)];
- struct svr4_ucontext * uc; char uc_[PAD_(struct svr4_ucontext *)];
-};
-struct svr4_sys_statvfs_args {
- char * path; char path_[PAD_(char *)];
- struct svr4_statvfs * fs; char fs_[PAD_(struct svr4_statvfs *)];
-};
-struct svr4_sys_fstatvfs_args {
- int fd; char fd_[PAD_(int)];
- struct svr4_statvfs * fs; char fs_[PAD_(struct svr4_statvfs *)];
-};
-struct svr4_sys_waitsys_args {
- int grp; char grp_[PAD_(int)];
- int id; char id_[PAD_(int)];
- union svr4_siginfo * info; char info_[PAD_(union svr4_siginfo *)];
- int options; char options_[PAD_(int)];
-};
-struct svr4_sys_hrtsys_args {
- int cmd; char cmd_[PAD_(int)];
- int fun; char fun_[PAD_(int)];
- int sub; char sub_[PAD_(int)];
- void * rv1; char rv1_[PAD_(void *)];
- void * rv2; char rv2_[PAD_(void *)];
-};
-struct svr4_sys_pathconf_args {
- char * path; char path_[PAD_(char *)];
- int name; char name_[PAD_(int)];
-};
-struct svr4_sys_mmap_args {
- caddr_t addr; char addr_[PAD_(caddr_t)];
- svr4_size_t len; char len_[PAD_(svr4_size_t)];
- int prot; char prot_[PAD_(int)];
- int flags; char flags_[PAD_(int)];
- int fd; char fd_[PAD_(int)];
- svr4_off_t pos; char pos_[PAD_(svr4_off_t)];
-};
-struct svr4_sys_fpathconf_args {
- int fd; char fd_[PAD_(int)];
- int name; char name_[PAD_(int)];
-};
-struct svr4_sys_xstat_args {
- int two; char two_[PAD_(int)];
- char * path; char path_[PAD_(char *)];
- struct svr4_xstat * ub; char ub_[PAD_(struct svr4_xstat *)];
-};
-struct svr4_sys_lxstat_args {
- int two; char two_[PAD_(int)];
- char * path; char path_[PAD_(char *)];
- struct svr4_xstat * ub; char ub_[PAD_(struct svr4_xstat *)];
-};
-struct svr4_sys_fxstat_args {
- int two; char two_[PAD_(int)];
- int fd; char fd_[PAD_(int)];
- struct svr4_xstat * sb; char sb_[PAD_(struct svr4_xstat *)];
-};
-struct svr4_sys_xmknod_args {
- int two; char two_[PAD_(int)];
- char * path; char path_[PAD_(char *)];
- svr4_mode_t mode; char mode_[PAD_(svr4_mode_t)];
- svr4_dev_t dev; char dev_[PAD_(svr4_dev_t)];
-};
-struct svr4_sys_setrlimit_args {
- int which; char which_[PAD_(int)];
- const struct svr4_rlimit * rlp; char rlp_[PAD_(const struct svr4_rlimit *)];
-};
-struct svr4_sys_getrlimit_args {
- int which; char which_[PAD_(int)];
- struct svr4_rlimit * rlp; char rlp_[PAD_(struct svr4_rlimit *)];
-};
-struct svr4_sys_memcntl_args {
- void * addr; char addr_[PAD_(void *)];
- svr4_size_t len; char len_[PAD_(svr4_size_t)];
- int cmd; char cmd_[PAD_(int)];
- void * arg; char arg_[PAD_(void *)];
- int attr; char attr_[PAD_(int)];
- int mask; char mask_[PAD_(int)];
-};
-struct svr4_sys_uname_args {
- struct svr4_utsname * name; char name_[PAD_(struct svr4_utsname *)];
- int dummy; char dummy_[PAD_(int)];
-};
-struct svr4_sys_sysconfig_args {
- int name; char name_[PAD_(int)];
-};
-struct svr4_sys_systeminfo_args {
- int what; char what_[PAD_(int)];
- char * buf; char buf_[PAD_(char *)];
- long len; char len_[PAD_(long)];
-};
-struct svr4_sys_fchroot_args {
- int fd; char fd_[PAD_(int)];
-};
-struct svr4_sys_utimes_args {
- char * path; char path_[PAD_(char *)];
- struct timeval * tptr; char tptr_[PAD_(struct timeval *)];
-};
-struct svr4_sys_vhangup_args {
- register_t dummy;
-};
-struct svr4_sys_gettimeofday_args {
- struct timeval * tp; char tp_[PAD_(struct timeval *)];
-};
-struct svr4_sys_llseek_args {
- int fd; char fd_[PAD_(int)];
- long offset1; char offset1_[PAD_(long)];
- long offset2; char offset2_[PAD_(long)];
- int whence; char whence_[PAD_(int)];
-};
-struct svr4_sys_acl_args {
- char * path; char path_[PAD_(char *)];
- int cmd; char cmd_[PAD_(int)];
- int num; char num_[PAD_(int)];
- struct svr4_aclent * buf; char buf_[PAD_(struct svr4_aclent *)];
-};
-struct svr4_sys_auditsys_args {
- int code; char code_[PAD_(int)];
- int a1; char a1_[PAD_(int)];
- int a2; char a2_[PAD_(int)];
- int a3; char a3_[PAD_(int)];
- int a4; char a4_[PAD_(int)];
- int a5; char a5_[PAD_(int)];
-};
-struct svr4_sys_facl_args {
- int fd; char fd_[PAD_(int)];
- int cmd; char cmd_[PAD_(int)];
- int num; char num_[PAD_(int)];
- struct svr4_aclent * buf; char buf_[PAD_(struct svr4_aclent *)];
-};
-struct svr4_sys_resolvepath_args {
- const char * path; char path_[PAD_(const char *)];
- char * buf; char buf_[PAD_(char *)];
- size_t bufsiz; char bufsiz_[PAD_(size_t)];
-};
-struct svr4_sys_getdents64_args {
- int fd; char fd_[PAD_(int)];
- struct svr4_dirent64 * dp; char dp_[PAD_(struct svr4_dirent64 *)];
- int nbytes; char nbytes_[PAD_(int)];
-};
-struct svr4_sys_mmap64_args {
- void * addr; char addr_[PAD_(void *)];
- svr4_size_t len; char len_[PAD_(svr4_size_t)];
- int prot; char prot_[PAD_(int)];
- int flags; char flags_[PAD_(int)];
- int fd; char fd_[PAD_(int)];
- svr4_off64_t pos; char pos_[PAD_(svr4_off64_t)];
-};
-struct svr4_sys_stat64_args {
- char * path; char path_[PAD_(char *)];
- struct svr4_stat64 * sb; char sb_[PAD_(struct svr4_stat64 *)];
-};
-struct svr4_sys_lstat64_args {
- char * path; char path_[PAD_(char *)];
- struct svr4_stat64 * sb; char sb_[PAD_(struct svr4_stat64 *)];
-};
-struct svr4_sys_fstat64_args {
- int fd; char fd_[PAD_(int)];
- struct svr4_stat64 * sb; char sb_[PAD_(struct svr4_stat64 *)];
-};
-struct svr4_sys_statvfs64_args {
- char * path; char path_[PAD_(char *)];
- struct svr4_statvfs64 * fs; char fs_[PAD_(struct svr4_statvfs64 *)];
-};
-struct svr4_sys_fstatvfs64_args {
- int fd; char fd_[PAD_(int)];
- struct svr4_statvfs64 * fs; char fs_[PAD_(struct svr4_statvfs64 *)];
-};
-struct svr4_sys_setrlimit64_args {
- int which; char which_[PAD_(int)];
- const struct svr4_rlimit64 * rlp; char rlp_[PAD_(const struct svr4_rlimit64 *)];
-};
-struct svr4_sys_getrlimit64_args {
- int which; char which_[PAD_(int)];
- struct svr4_rlimit64 * rlp; char rlp_[PAD_(struct svr4_rlimit64 *)];
-};
-struct svr4_sys_creat64_args {
- char * path; char path_[PAD_(char *)];
- int mode; char mode_[PAD_(int)];
-};
-struct svr4_sys_open64_args {
- char * path; char path_[PAD_(char *)];
- int flags; char flags_[PAD_(int)];
- int mode; char mode_[PAD_(int)];
-};
-struct svr4_sys_socket_args {
- int domain; char domain_[PAD_(int)];
- int type; char type_[PAD_(int)];
- int protocol; char protocol_[PAD_(int)];
-};
-struct svr4_sys_recv_args {
- int s; char s_[PAD_(int)];
- caddr_t buf; char buf_[PAD_(caddr_t)];
- int len; char len_[PAD_(int)];
- int flags; char flags_[PAD_(int)];
-};
-struct svr4_sys_send_args {
- int s; char s_[PAD_(int)];
- caddr_t buf; char buf_[PAD_(caddr_t)];
- int len; char len_[PAD_(int)];
- int flags; char flags_[PAD_(int)];
-};
-struct svr4_sys_sendto_args {
- int s; char s_[PAD_(int)];
- void * buf; char buf_[PAD_(void *)];
- size_t len; char len_[PAD_(size_t)];
- int flags; char flags_[PAD_(int)];
- struct sockaddr * to; char to_[PAD_(struct sockaddr *)];
- int tolen; char tolen_[PAD_(int)];
-};
-int svr4_sys_open __P((struct proc *, struct svr4_sys_open_args *));
-int svr4_sys_wait __P((struct proc *, struct svr4_sys_wait_args *));
-int svr4_sys_creat __P((struct proc *, struct svr4_sys_creat_args *));
-int svr4_sys_execv __P((struct proc *, struct svr4_sys_execv_args *));
-int svr4_sys_time __P((struct proc *, struct svr4_sys_time_args *));
-int svr4_sys_mknod __P((struct proc *, struct svr4_sys_mknod_args *));
-int svr4_sys_break __P((struct proc *, struct svr4_sys_break_args *));
-int svr4_sys_stat __P((struct proc *, struct svr4_sys_stat_args *));
-int svr4_sys_alarm __P((struct proc *, struct svr4_sys_alarm_args *));
-int svr4_sys_fstat __P((struct proc *, struct svr4_sys_fstat_args *));
-int svr4_sys_pause __P((struct proc *, struct svr4_sys_pause_args *));
-int svr4_sys_utime __P((struct proc *, struct svr4_sys_utime_args *));
-int svr4_sys_access __P((struct proc *, struct svr4_sys_access_args *));
-int svr4_sys_nice __P((struct proc *, struct svr4_sys_nice_args *));
-int svr4_sys_kill __P((struct proc *, struct svr4_sys_kill_args *));
-int svr4_sys_pgrpsys __P((struct proc *, struct svr4_sys_pgrpsys_args *));
-int svr4_sys_times __P((struct proc *, struct svr4_sys_times_args *));
-int svr4_sys_signal __P((struct proc *, struct svr4_sys_signal_args *));
-#if defined(NOTYET)
-int svr4_sys_msgsys __P((struct proc *, struct svr4_sys_msgsys_args *));
-#else
-#endif
-int svr4_sys_sysarch __P((struct proc *, struct svr4_sys_sysarch_args *));
-int svr4_sys_ioctl __P((struct proc *, struct svr4_sys_ioctl_args *));
-int svr4_sys_utssys __P((struct proc *, struct svr4_sys_utssys_args *));
-int svr4_sys_execve __P((struct proc *, struct svr4_sys_execve_args *));
-int svr4_sys_fcntl __P((struct proc *, struct svr4_sys_fcntl_args *));
-int svr4_sys_ulimit __P((struct proc *, struct svr4_sys_ulimit_args *));
-int svr4_sys_getdents __P((struct proc *, struct svr4_sys_getdents_args *));
-int svr4_sys_getmsg __P((struct proc *, struct svr4_sys_getmsg_args *));
-int svr4_sys_putmsg __P((struct proc *, struct svr4_sys_putmsg_args *));
-int svr4_sys_poll __P((struct proc *, struct svr4_sys_poll_args *));
-int svr4_sys_lstat __P((struct proc *, struct svr4_sys_lstat_args *));
-int svr4_sys_sigprocmask __P((struct proc *, struct svr4_sys_sigprocmask_args *));
-int svr4_sys_sigsuspend __P((struct proc *, struct svr4_sys_sigsuspend_args *));
-int svr4_sys_sigaltstack __P((struct proc *, struct svr4_sys_sigaltstack_args *));
-int svr4_sys_sigaction __P((struct proc *, struct svr4_sys_sigaction_args *));
-int svr4_sys_sigpending __P((struct proc *, struct svr4_sys_sigpending_args *));
-int svr4_sys_context __P((struct proc *, struct svr4_sys_context_args *));
-int svr4_sys_statvfs __P((struct proc *, struct svr4_sys_statvfs_args *));
-int svr4_sys_fstatvfs __P((struct proc *, struct svr4_sys_fstatvfs_args *));
-int svr4_sys_waitsys __P((struct proc *, struct svr4_sys_waitsys_args *));
-int svr4_sys_hrtsys __P((struct proc *, struct svr4_sys_hrtsys_args *));
-int svr4_sys_pathconf __P((struct proc *, struct svr4_sys_pathconf_args *));
-int svr4_sys_mmap __P((struct proc *, struct svr4_sys_mmap_args *));
-int svr4_sys_fpathconf __P((struct proc *, struct svr4_sys_fpathconf_args *));
-int svr4_sys_xstat __P((struct proc *, struct svr4_sys_xstat_args *));
-int svr4_sys_lxstat __P((struct proc *, struct svr4_sys_lxstat_args *));
-int svr4_sys_fxstat __P((struct proc *, struct svr4_sys_fxstat_args *));
-int svr4_sys_xmknod __P((struct proc *, struct svr4_sys_xmknod_args *));
-int svr4_sys_setrlimit __P((struct proc *, struct svr4_sys_setrlimit_args *));
-int svr4_sys_getrlimit __P((struct proc *, struct svr4_sys_getrlimit_args *));
-int svr4_sys_memcntl __P((struct proc *, struct svr4_sys_memcntl_args *));
-int svr4_sys_uname __P((struct proc *, struct svr4_sys_uname_args *));
-int svr4_sys_sysconfig __P((struct proc *, struct svr4_sys_sysconfig_args *));
-int svr4_sys_systeminfo __P((struct proc *, struct svr4_sys_systeminfo_args *));
-int svr4_sys_fchroot __P((struct proc *, struct svr4_sys_fchroot_args *));
-int svr4_sys_utimes __P((struct proc *, struct svr4_sys_utimes_args *));
-int svr4_sys_vhangup __P((struct proc *, struct svr4_sys_vhangup_args *));
-int svr4_sys_gettimeofday __P((struct proc *, struct svr4_sys_gettimeofday_args *));
-int svr4_sys_llseek __P((struct proc *, struct svr4_sys_llseek_args *));
-int svr4_sys_acl __P((struct proc *, struct svr4_sys_acl_args *));
-int svr4_sys_auditsys __P((struct proc *, struct svr4_sys_auditsys_args *));
-int svr4_sys_facl __P((struct proc *, struct svr4_sys_facl_args *));
-int svr4_sys_resolvepath __P((struct proc *, struct svr4_sys_resolvepath_args *));
-int svr4_sys_getdents64 __P((struct proc *, struct svr4_sys_getdents64_args *));
-int svr4_sys_mmap64 __P((struct proc *, struct svr4_sys_mmap64_args *));
-int svr4_sys_stat64 __P((struct proc *, struct svr4_sys_stat64_args *));
-int svr4_sys_lstat64 __P((struct proc *, struct svr4_sys_lstat64_args *));
-int svr4_sys_fstat64 __P((struct proc *, struct svr4_sys_fstat64_args *));
-int svr4_sys_statvfs64 __P((struct proc *, struct svr4_sys_statvfs64_args *));
-int svr4_sys_fstatvfs64 __P((struct proc *, struct svr4_sys_fstatvfs64_args *));
-int svr4_sys_setrlimit64 __P((struct proc *, struct svr4_sys_setrlimit64_args *));
-int svr4_sys_getrlimit64 __P((struct proc *, struct svr4_sys_getrlimit64_args *));
-int svr4_sys_creat64 __P((struct proc *, struct svr4_sys_creat64_args *));
-int svr4_sys_open64 __P((struct proc *, struct svr4_sys_open64_args *));
-int svr4_sys_socket __P((struct proc *, struct svr4_sys_socket_args *));
-int svr4_sys_recv __P((struct proc *, struct svr4_sys_recv_args *));
-int svr4_sys_send __P((struct proc *, struct svr4_sys_send_args *));
-int svr4_sys_sendto __P((struct proc *, struct svr4_sys_sendto_args *));
-
-#ifdef COMPAT_43
-
-#if defined(NOTYET)
-#else
-#endif
-
-#endif /* COMPAT_43 */
-
-#undef PAD_
-
-#endif /* !_SVR4_SYSPROTO_H_ */
diff --git a/sys/compat/svr4/svr4_resource.c b/sys/compat/svr4/svr4_resource.c
deleted file mode 100644
index 1e5e8fd2691a..000000000000
--- a/sys/compat/svr4/svr4_resource.c
+++ /dev/null
@@ -1,314 +0,0 @@
-/* Derived from:
- * $NetBSD: svr4_resource.c,v 1.3 1998/12/13 18:00:52 christos Exp $
- */
-
-/*-
- * Original copyright:
- *
- * Copyright (c) 1998 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Christos Zoulas.
- *
- * 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 the NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation 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 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Portions of this software have been derived from software contributed
- * to the FreeBSD Project by Mark Newton.
- *
- * Copyright (c) 1999 Mark Newton
- * 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 <sys/param.h>
-#include <sys/systm.h>
-#include <sys/proc.h>
-#include <sys/file.h>
-#include <sys/resource.h>
-#include <sys/resourcevar.h>
-
-#include <svr4/svr4.h>
-#include <svr4/svr4_types.h>
-#include <svr4/svr4_resource.h>
-#include <svr4/svr4_signal.h>
-#include <svr4/svr4_proto.h>
-#include <svr4/svr4_util.h>
-
-static __inline int svr4_to_native_rl __P((int));
-
-static __inline int
-svr4_to_native_rl(rl)
- int rl;
-{
- switch (rl) {
- case SVR4_RLIMIT_CPU:
- return RLIMIT_CPU;
- case SVR4_RLIMIT_FSIZE:
- return RLIMIT_FSIZE;
- case SVR4_RLIMIT_DATA:
- return RLIMIT_DATA;
- case SVR4_RLIMIT_STACK:
- return RLIMIT_STACK;
- case SVR4_RLIMIT_CORE:
- return RLIMIT_CORE;
- case SVR4_RLIMIT_NOFILE:
- return RLIMIT_NOFILE;
- case SVR4_RLIMIT_VMEM:
- return RLIMIT_RSS;
- default:
- return -1;
- }
-}
-
-/*
- * Check if the resource limit fits within the BSD range and it is not
- * one of the magic SVR4 limit values
- */
-#define OKLIMIT(l) (((int32_t)(l)) >= 0 && ((int32_t)(l)) < 0x7fffffff && \
- ((svr4_rlim_t)(l)) != SVR4_RLIM_INFINITY && \
- ((svr4_rlim_t)(l)) != SVR4_RLIM_SAVED_CUR && \
- ((svr4_rlim_t)(l)) != SVR4_RLIM_SAVED_MAX)
-
-#define OKLIMIT64(l) (((rlim_t)(l)) >= 0 && ((rlim_t)(l)) < RLIM_INFINITY && \
- ((svr4_rlim64_t)(l)) != SVR4_RLIM64_INFINITY && \
- ((svr4_rlim64_t)(l)) != SVR4_RLIM64_SAVED_CUR && \
- ((svr4_rlim64_t)(l)) != SVR4_RLIM64_SAVED_MAX)
-
-int
-svr4_sys_getrlimit(p, uap)
- register struct proc *p;
- struct svr4_sys_getrlimit_args *uap;
-{
- int rl = svr4_to_native_rl(SCARG(uap, which));
- struct rlimit blim;
- struct svr4_rlimit slim;
-
- if (rl == -1)
- return EINVAL;
-
- blim = p->p_rlimit[rl];
-
- /*
- * Our infinity, is their maxfiles.
- */
- if (rl == RLIMIT_NOFILE && blim.rlim_max == RLIM_INFINITY)
- blim.rlim_max = maxfiles;
-
- /*
- * If the limit can be be represented, it is returned.
- * Otherwise, if rlim_cur == rlim_max, return RLIM_SAVED_MAX
- * else return RLIM_SAVED_CUR
- */
- if (blim.rlim_max == RLIM_INFINITY)
- slim.rlim_max = SVR4_RLIM_INFINITY;
- else if (OKLIMIT(blim.rlim_max))
- slim.rlim_max = (svr4_rlim_t) blim.rlim_max;
- else
- slim.rlim_max = SVR4_RLIM_SAVED_MAX;
-
- if (blim.rlim_cur == RLIM_INFINITY)
- slim.rlim_cur = SVR4_RLIM_INFINITY;
- else if (OKLIMIT(blim.rlim_cur))
- slim.rlim_cur = (svr4_rlim_t) blim.rlim_cur;
- else if (blim.rlim_max == blim.rlim_cur)
- slim.rlim_cur = SVR4_RLIM_SAVED_MAX;
- else
- slim.rlim_cur = SVR4_RLIM_SAVED_CUR;
-
- return copyout(&slim, SCARG(uap, rlp), sizeof(*SCARG(uap, rlp)));
-}
-
-
-int
-svr4_sys_setrlimit(p, uap)
- register struct proc *p;
- struct svr4_sys_setrlimit_args *uap;
-{
- int rl = svr4_to_native_rl(SCARG(uap, which));
- struct rlimit blim, *limp;
- struct svr4_rlimit slim;
- int error;
-
- if (rl == -1)
- return EINVAL;
-
- limp = &p->p_rlimit[rl];
-
- if ((error = copyin(SCARG(uap, rlp), &slim, sizeof(slim))) != 0)
- return error;
-
- /*
- * if the limit is SVR4_RLIM_INFINITY, then we set it to our
- * unlimited.
- * We should also: If it is SVR4_RLIM_SAVED_MAX, we should set the
- * new limit to the corresponding saved hard limit, and if
- * it is equal to SVR4_RLIM_SAVED_CUR, we should set it to the
- * corresponding saved soft limit.
- *
- */
- if (slim.rlim_max == SVR4_RLIM_INFINITY)
- blim.rlim_max = RLIM_INFINITY;
- else if (OKLIMIT(slim.rlim_max))
- blim.rlim_max = (rlim_t) slim.rlim_max;
- else if (slim.rlim_max == SVR4_RLIM_SAVED_MAX)
- blim.rlim_max = limp->rlim_max;
- else if (slim.rlim_max == SVR4_RLIM_SAVED_CUR)
- blim.rlim_max = limp->rlim_cur;
-
- if (slim.rlim_cur == SVR4_RLIM_INFINITY)
- blim.rlim_cur = RLIM_INFINITY;
- else if (OKLIMIT(slim.rlim_cur))
- blim.rlim_cur = (rlim_t) slim.rlim_cur;
- else if (slim.rlim_cur == SVR4_RLIM_SAVED_MAX)
- blim.rlim_cur = limp->rlim_max;
- else if (slim.rlim_cur == SVR4_RLIM_SAVED_CUR)
- blim.rlim_cur = limp->rlim_cur;
-
- return dosetrlimit(p, rl, &blim);
-}
-
-
-int
-svr4_sys_getrlimit64(p, uap)
- register struct proc *p;
- struct svr4_sys_getrlimit64_args *uap;
-{
- int rl = svr4_to_native_rl(SCARG(uap, which));
- struct rlimit blim;
- struct svr4_rlimit64 slim;
-
- if (rl == -1)
- return EINVAL;
-
- blim = p->p_rlimit[rl];
-
- /*
- * Our infinity, is their maxfiles.
- */
- if (rl == RLIMIT_NOFILE && blim.rlim_max == RLIM_INFINITY)
- blim.rlim_max = maxfiles;
-
- /*
- * If the limit can be be represented, it is returned.
- * Otherwise, if rlim_cur == rlim_max, return SVR4_RLIM_SAVED_MAX
- * else return SVR4_RLIM_SAVED_CUR
- */
- if (blim.rlim_max == RLIM_INFINITY)
- slim.rlim_max = SVR4_RLIM64_INFINITY;
- else if (OKLIMIT64(blim.rlim_max))
- slim.rlim_max = (svr4_rlim64_t) blim.rlim_max;
- else
- slim.rlim_max = SVR4_RLIM64_SAVED_MAX;
-
- if (blim.rlim_cur == RLIM_INFINITY)
- slim.rlim_cur = SVR4_RLIM64_INFINITY;
- else if (OKLIMIT64(blim.rlim_cur))
- slim.rlim_cur = (svr4_rlim64_t) blim.rlim_cur;
- else if (blim.rlim_max == blim.rlim_cur)
- slim.rlim_cur = SVR4_RLIM64_SAVED_MAX;
- else
- slim.rlim_cur = SVR4_RLIM64_SAVED_CUR;
-
- return copyout(&slim, SCARG(uap, rlp), sizeof(*SCARG(uap, rlp)));
-}
-
-
-int
-svr4_sys_setrlimit64(p, uap)
- register struct proc *p;
- struct svr4_sys_setrlimit64_args *uap;
-{
- int rl = svr4_to_native_rl(SCARG(uap, which));
- struct rlimit blim, *limp;
- struct svr4_rlimit64 slim;
- int error;
-
- if (rl == -1)
- return EINVAL;
-
- limp = &p->p_rlimit[rl];
-
- if ((error = copyin(SCARG(uap, rlp), &slim, sizeof(slim))) != 0)
- return error;
-
- /*
- * if the limit is SVR4_RLIM64_INFINITY, then we set it to our
- * unlimited.
- * We should also: If it is SVR4_RLIM64_SAVED_MAX, we should set the
- * new limit to the corresponding saved hard limit, and if
- * it is equal to SVR4_RLIM64_SAVED_CUR, we should set it to the
- * corresponding saved soft limit.
- *
- */
- if (slim.rlim_max == SVR4_RLIM64_INFINITY)
- blim.rlim_max = RLIM_INFINITY;
- else if (OKLIMIT64(slim.rlim_max))
- blim.rlim_max = (rlim_t) slim.rlim_max;
- else if (slim.rlim_max == SVR4_RLIM64_SAVED_MAX)
- blim.rlim_max = limp->rlim_max;
- else if (slim.rlim_max == SVR4_RLIM64_SAVED_CUR)
- blim.rlim_max = limp->rlim_cur;
-
- if (slim.rlim_cur == SVR4_RLIM64_INFINITY)
- blim.rlim_cur = RLIM_INFINITY;
- else if (OKLIMIT64(slim.rlim_cur))
- blim.rlim_cur = (rlim_t) slim.rlim_cur;
- else if (slim.rlim_cur == SVR4_RLIM64_SAVED_MAX)
- blim.rlim_cur = limp->rlim_max;
- else if (slim.rlim_cur == SVR4_RLIM64_SAVED_CUR)
- blim.rlim_cur = limp->rlim_cur;
-
- return dosetrlimit(p, rl, &blim);
-}
diff --git a/sys/compat/svr4/svr4_resource.h b/sys/compat/svr4/svr4_resource.h
deleted file mode 100644
index 3512df387674..000000000000
--- a/sys/compat/svr4/svr4_resource.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/* Derived from:
- * $NetBSD: svr4_resource.h,v 1.1 1998/11/28 21:53:02 christos Exp $ */
-
-/*-
- * Original copyright:
- *
- * Copyright (c) 1998 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Christos Zoulas.
- *
- * 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 the NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation 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 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Portions of this code derived from software contributed to the
- * FreeBSD Project by Mark Newton.
- *
- * Copyright (c) 1999 Mark Newton
- * 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.
- */
-
-#ifndef _SVR4_RESOURCE_H_
-#define _SVR4_RESOURCE_H_
-
-#define SVR4_RLIMIT_CPU 0
-#define SVR4_RLIMIT_FSIZE 1
-#define SVR4_RLIMIT_DATA 2
-#define SVR4_RLIMIT_STACK 3
-#define SVR4_RLIMIT_CORE 4
-#define SVR4_RLIMIT_NOFILE 5
-#define SVR4_RLIMIT_VMEM 6
-#define SVR4_RLIMIT_AS SVR4_RLIMIT_VMEM
-#define SVR4_RLIM_NLIMITS 7
-
-typedef u_int32_t svr4_rlim_t;
-
-#define SVR4_RLIM_SAVED_CUR 0x7ffffffd
-#define SVR4_RLIM_SAVED_MAX 0x7ffffffe
-#define SVR4_RLIM_INFINITY 0x7fffffff
-
-struct svr4_rlimit {
- svr4_rlim_t rlim_cur;
- svr4_rlim_t rlim_max;
-};
-
-typedef u_int64_t svr4_rlim64_t;
-
-#define SVR4_RLIM64_SAVED_CUR ((svr4_rlim64_t) -1)
-#define SVR4_RLIM64_SAVED_MAX ((svr4_rlim64_t) -2)
-#define SVR4_RLIM64_INFINITY ((svr4_rlim64_t) -3)
-
-struct svr4_rlimit64 {
- svr4_rlim64_t rlim_cur;
- svr4_rlim64_t rlim_max;
-};
-
-#endif /* !_SVR4_RESOURCE_H_ */
diff --git a/sys/compat/svr4/svr4_siginfo.h b/sys/compat/svr4/svr4_siginfo.h
deleted file mode 100644
index be898374dc2b..000000000000
--- a/sys/compat/svr4/svr4_siginfo.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1994 Christos Zoulas
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _SVR4_SIGINFO_H_
-#define _SVR4_SIGINFO_H_
-
-#define SVR4_ILL_ILLOPC 1
-#define SVR4_ILL_ILLOPN 2
-#define SVR4_ILL_ILLADR 3
-#define SVR4_ILL_ILLTRP 4
-#define SVR4_ILL_PRVOPC 5
-#define SVR4_ILL_PRVREG 6
-#define SVR4_ILL_COPROC 7
-#define SVR4_ILL_BADSTK 8
-
-#define SVR4_FPE_INTDIV 1
-#define SVR4_FPE_INTOVF 2
-#define SVR4_FPE_FLTDIV 3
-#define SVR4_FPE_FLTOVF 4
-#define SVR4_FPE_FLTUND 5
-#define SVR4_FPE_FLTRES 6
-#define SVR4_FPE_FLTINV 7
-#define SVR4_FPE_FLTSUB 8
-
-#define SVR4_SEGV_MAPERR 1
-#define SVR4_SEGV_ACCERR 2
-
-#define SVR4_BUS_ADRALN 1
-#define SVR4_BUS_ADRERR 2
-#define SVR4_BUS_OBJERR 3
-
-#define SVR4_TRAP_BRKPT 1
-#define SVR4_TRAP_TRACE 2
-
-#define SVR4_POLL_IN 1
-#define SVR4_POLL_OUT 2
-#define SVR4_POLL_MSG 3
-#define SVR4_POLL_ERR 4
-#define SVR4_POLL_PRI 5
-
-#define SVR4_CLD_EXITED 1
-#define SVR4_CLD_KILLED 2
-#define SVR4_CLD_DUMPED 3
-#define SVR4_CLD_TRAPPED 4
-#define SVR4_CLD_STOPPED 5
-#define SVR4_CLD_CONTINUED 6
-
-#define SVR4_EMT_TAGOVF 1
-
-typedef union svr4_siginfo {
- char si_pad[128]; /* Total size; for future expansion */
- struct {
- int _signo;
- int _code;
- int _errno;
- union {
- struct {
- svr4_pid_t _pid;
- svr4_clock_t _utime;
- int _status;
- svr4_clock_t _stime;
- } _child;
-
- struct {
- caddr_t _addr;
- int _trap;
- } _fault;
- } _reason;
- } _info;
-} svr4_siginfo_t;
-
-#define si_signo _info._signo
-#define si_code _info._code
-#define si_errno _info._errno
-
-#define si_pid _info._reason._child._pid
-#define si_stime _info._reason._child._stime
-#define si_status _info._reason._child._status
-#define si_utime _info._reason._child._utime
-
-#define si_addr _info._reason._fault._addr
-#define si_trap _info._reason._fault._trap
-
-#endif /* !_SVR4_SIGINFO_H_ */
diff --git a/sys/compat/svr4/svr4_signal.c b/sys/compat/svr4/svr4_signal.c
deleted file mode 100644
index 821f62c68b40..000000000000
--- a/sys/compat/svr4/svr4_signal.c
+++ /dev/null
@@ -1,666 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1994 Christos Zoulas
- * 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/proc.h>
-#include <sys/filedesc.h>
-#include <sys/signal.h>
-#include <sys/signalvar.h>
-#include <sys/sysproto.h>
-
-#include <svr4/svr4.h>
-#include <svr4/svr4_types.h>
-#include <svr4/svr4_signal.h>
-#include <svr4/svr4_proto.h>
-#include <svr4/svr4_util.h>
-#include <svr4/svr4_ucontext.h>
-
-#define svr4_sigmask(n) (1 << (((n) - 1) & 31))
-#define svr4_sigword(n) (((n) - 1) >> 5)
-#define svr4_sigemptyset(s) memset((s), 0, sizeof(*(s)))
-#define svr4_sigismember(s, n) ((s)->bits[svr4_sigword(n)] & svr4_sigmask(n))
-#define svr4_sigaddset(s, n) ((s)->bits[svr4_sigword(n)] |= svr4_sigmask(n))
-
-void svr4_to_bsd_sigaction __P((const struct svr4_sigaction *,
- struct sigaction *));
-void bsd_to_svr4_sigaction __P((const struct sigaction *,
- struct svr4_sigaction *));
-void svr4_sigfillset __P((svr4_sigset_t *));
-
-int bsd_to_svr4_sig[SVR4_SIGTBLSZ] = {
- SVR4_SIGHUP,
- SVR4_SIGINT,
- SVR4_SIGQUIT,
- SVR4_SIGILL,
- SVR4_SIGTRAP,
- SVR4_SIGABRT,
- SVR4_SIGEMT,
- SVR4_SIGFPE,
- SVR4_SIGKILL,
- SVR4_SIGBUS,
- SVR4_SIGSEGV,
- SVR4_SIGSYS,
- SVR4_SIGPIPE,
- SVR4_SIGALRM,
- SVR4_SIGTERM,
- SVR4_SIGURG,
- SVR4_SIGSTOP,
- SVR4_SIGTSTP,
- SVR4_SIGCONT,
- SVR4_SIGCHLD,
- SVR4_SIGTTIN,
- SVR4_SIGTTOU,
- SVR4_SIGIO,
- SVR4_SIGXCPU,
- SVR4_SIGXFSZ,
- SVR4_SIGVTALRM,
- SVR4_SIGPROF,
- SVR4_SIGWINCH,
- 0, /* SIGINFO */
- SVR4_SIGUSR1,
- SVR4_SIGUSR2,
-};
-
-int svr4_to_bsd_sig[SVR4_SIGTBLSZ] = {
- SIGHUP,
- SIGINT,
- SIGQUIT,
- SIGILL,
- SIGTRAP,
- SIGABRT,
- SIGEMT,
- SIGFPE,
- SIGKILL,
- SIGBUS,
- SIGSEGV,
- SIGSYS,
- SIGPIPE,
- SIGALRM,
- SIGTERM,
- SIGUSR1,
- SIGUSR2,
- SIGCHLD,
- 0, /* XXX NetBSD uses SIGPWR here, but we don't seem to have one */
- SIGWINCH,
- SIGURG,
- SIGIO,
- SIGSTOP,
- SIGTSTP,
- SIGCONT,
- SIGTTIN,
- SIGTTOU,
- SIGVTALRM,
- SIGPROF,
- SIGXCPU,
- SIGXFSZ,
-};
-
-void
-svr4_sigfillset(s)
- svr4_sigset_t *s;
-{
- int i;
-
- svr4_sigemptyset(s);
- for (i = 0; i < SVR4_NSIG; i++)
- if (svr4_to_bsd_sig[i] != 0)
- svr4_sigaddset(s, i);
-}
-
-void
-svr4_to_bsd_sigset(sss, bss)
- const svr4_sigset_t *sss;
- sigset_t *bss;
-{
- int i, newsig;
-
- SIGEMPTYSET(*bss);
- for (i = 0; i < SVR4_NSIG; i++)
- if (svr4_sigismember(sss, i + 1)) {
- newsig = svr4_to_bsd_sig[i];
- if (newsig)
- SIGADDSET(*bss, newsig);
- }
-}
-
-void
-bsd_to_svr4_sigset(bss, sss)
- const sigset_t *bss;
- svr4_sigset_t *sss;
-{
- int i, newsig;
-
- svr4_sigemptyset(sss);
- sss->bits[0] = bss->__bits[0] & ~((1U << SVR4_SIGTBLSZ) - 1);
- sss->bits[1] = bss->__bits[1];
- sss->bits[2] = bss->__bits[2];
- sss->bits[3] = bss->__bits[3];
- for (i = 1; i <= SVR4_SIGTBLSZ; i++) {
- if (SIGISMEMBER(*bss, i)) {
- newsig = bsd_to_svr4_sig[_SIG_IDX(i)];
- if (newsig)
- svr4_sigaddset(sss, newsig);
- }
- }
-}
-
-/*
- * XXX: Only a subset of the flags is currently implemented.
- */
-void
-svr4_to_bsd_sigaction(ssa, bsa)
- const struct svr4_sigaction *ssa;
- struct sigaction *bsa;
-{
-
- bsa->sa_handler = (sig_t) ssa->ssa_handler;
- svr4_to_bsd_sigset(&ssa->ssa_mask, &bsa->sa_mask);
- bsa->sa_flags = 0;
- if ((ssa->ssa_flags & SVR4_SA_ONSTACK) != 0)
- bsa->sa_flags |= SA_ONSTACK;
- if ((ssa->ssa_flags & SVR4_SA_RESETHAND) != 0)
- bsa->sa_flags |= SA_RESETHAND;
- if ((ssa->ssa_flags & SVR4_SA_RESTART) != 0)
- bsa->sa_flags |= SA_RESTART;
- if ((ssa->ssa_flags & SVR4_SA_SIGINFO) != 0)
- DPRINTF(("svr4_to_bsd_sigaction: SA_SIGINFO ignored\n"));
- if ((ssa->ssa_flags & SVR4_SA_NOCLDSTOP) != 0)
- bsa->sa_flags |= SA_NOCLDSTOP;
- if ((ssa->ssa_flags & SVR4_SA_NODEFER) != 0)
- bsa->sa_flags |= SA_NODEFER;
- if ((ssa->ssa_flags & SVR4_SA_NOCLDWAIT) != 0)
- bsa->sa_flags |= SA_NOCLDWAIT;
- if ((ssa->ssa_flags & ~SVR4_SA_ALLBITS) != 0)
- DPRINTF(("svr4_to_bsd_sigaction: extra bits ignored\n"));
-}
-
-void
-bsd_to_svr4_sigaction(bsa, ssa)
- const struct sigaction *bsa;
- struct svr4_sigaction *ssa;
-{
-
- ssa->ssa_handler = (svr4_sig_t) bsa->sa_handler;
- bsd_to_svr4_sigset(&bsa->sa_mask, &ssa->ssa_mask);
- ssa->ssa_flags = 0;
- if ((bsa->sa_flags & SA_ONSTACK) != 0)
- ssa->ssa_flags |= SVR4_SA_ONSTACK;
- if ((bsa->sa_flags & SA_RESETHAND) != 0)
- ssa->ssa_flags |= SVR4_SA_RESETHAND;
- if ((bsa->sa_flags & SA_RESTART) != 0)
- ssa->ssa_flags |= SVR4_SA_RESTART;
- if ((bsa->sa_flags & SA_NODEFER) != 0)
- ssa->ssa_flags |= SVR4_SA_NODEFER;
- if ((bsa->sa_flags & SA_NOCLDSTOP) != 0)
- ssa->ssa_flags |= SVR4_SA_NOCLDSTOP;
-}
-
-void
-svr4_to_bsd_sigaltstack(sss, bss)
- const struct svr4_sigaltstack *sss;
- struct sigaltstack *bss;
-{
-
- bss->ss_sp = sss->ss_sp;
- bss->ss_size = sss->ss_size;
- bss->ss_flags = 0;
- if ((sss->ss_flags & SVR4_SS_DISABLE) != 0)
- bss->ss_flags |= SS_DISABLE;
- if ((sss->ss_flags & SVR4_SS_ONSTACK) != 0)
- bss->ss_flags |= SS_ONSTACK;
- if ((sss->ss_flags & ~SVR4_SS_ALLBITS) != 0)
- /*XXX*/ uprintf("svr4_to_bsd_sigaltstack: extra bits ignored\n");
-}
-
-void
-bsd_to_svr4_sigaltstack(bss, sss)
- const struct sigaltstack *bss;
- struct svr4_sigaltstack *sss;
-{
-
- sss->ss_sp = bss->ss_sp;
- sss->ss_size = bss->ss_size;
- sss->ss_flags = 0;
- if ((bss->ss_flags & SS_DISABLE) != 0)
- sss->ss_flags |= SVR4_SS_DISABLE;
- if ((bss->ss_flags & SS_ONSTACK) != 0)
- sss->ss_flags |= SVR4_SS_ONSTACK;
-}
-
-int
-svr4_sys_sigaction(p, uap)
- register struct proc *p;
- struct svr4_sys_sigaction_args *uap;
-{
- struct svr4_sigaction *nisa, *oisa, tmpisa;
- struct sigaction *nbsa, *obsa, tmpbsa;
- struct sigaction_args sa;
- caddr_t sg;
- int error;
-
- DPRINTF(("@@@ svr4_sys_sigaction(%d, %d, %d)\n", p->p_pid,
- SCARG(uap, signum),
- SVR4_SVR42BSD_SIG(SCARG(uap, signum))));
-
- sg = stackgap_init();
- nisa = SCARG(uap, nsa);
- oisa = SCARG(uap, osa);
-
- if (oisa != NULL)
- obsa = stackgap_alloc(&sg, sizeof(struct sigaction));
- else
- obsa = NULL;
-
- if (nisa != NULL) {
- nbsa = stackgap_alloc(&sg, sizeof(struct sigaction));
- if ((error = copyin(nisa, &tmpisa, sizeof(tmpisa))) != 0)
- return error;
- svr4_to_bsd_sigaction(&tmpisa, &tmpbsa);
- if ((error = copyout(&tmpbsa, nbsa, sizeof(tmpbsa))) != 0)
- return error;
- } else
- nbsa = NULL;
-
-#if defined(DEBUG_SVR4)
- {
- int i;
- for (i = 0; i < 4; i++)
- DPRINTF(("\tssa_mask[%d] = %lx\n", i,
- nisa->ssa_mask.bits[i]));
- DPRINTF(("\tssa_handler = %lx\n", nisa->ssa_handler));
- }
-#endif
-
- SCARG(&sa, sig) = SVR4_SVR42BSD_SIG(SCARG(uap, signum));
- SCARG(&sa, act) = nbsa;
- SCARG(&sa, oact) = obsa;
-
- if ((error = sigaction(p, &sa)) != 0)
- return error;
-
- if (oisa != NULL) {
- if ((error = copyin(obsa, &tmpbsa, sizeof(tmpbsa))) != 0)
- return error;
- bsd_to_svr4_sigaction(&tmpbsa, &tmpisa);
- if ((error = copyout(&tmpisa, oisa, sizeof(tmpisa))) != 0)
- return error;
- }
-
- return 0;
-}
-
-int
-svr4_sys_sigaltstack(p, uap)
- register struct proc *p;
- struct svr4_sys_sigaltstack_args *uap;
-{
- struct svr4_sigaltstack *nsss, *osss, tmpsss;
- struct sigaltstack *nbss, *obss, tmpbss;
- struct sigaltstack_args sa;
- caddr_t sg;
- int error, *retval;
-
- retval = p->p_retval;
- sg = stackgap_init();
- nsss = SCARG(uap, nss);
- osss = SCARG(uap, oss);
-
- if (osss != NULL)
- obss = stackgap_alloc(&sg, sizeof(struct sigaltstack));
- else
- obss = NULL;
-
- if (nsss != NULL) {
- nbss = stackgap_alloc(&sg, sizeof(struct sigaltstack));
- if ((error = copyin(nsss, &tmpsss, sizeof(tmpsss))) != 0)
- return error;
- svr4_to_bsd_sigaltstack(&tmpsss, &tmpbss);
- if ((error = copyout(&tmpbss, nbss, sizeof(tmpbss))) != 0)
- return error;
- } else
- nbss = NULL;
-
- SCARG(&sa, ss) = nbss;
- SCARG(&sa, oss) = obss;
-
- if ((error = sigaltstack(p, &sa)) != 0)
- return error;
-
- if (obss != NULL) {
- if ((error = copyin(obss, &tmpbss, sizeof(tmpbss))) != 0)
- return error;
- bsd_to_svr4_sigaltstack(&tmpbss, &tmpsss);
- if ((error = copyout(&tmpsss, osss, sizeof(tmpsss))) != 0)
- return error;
- }
-
- return 0;
-}
-
-/*
- * Stolen from the ibcs2 one
- */
-int
-svr4_sys_signal(p, uap)
- register struct proc *p;
- struct svr4_sys_signal_args *uap;
-{
- int signum;
- int error, *retval = p->p_retval;
- caddr_t sg = stackgap_init();
-
- DPRINTF(("@@@ svr4_sys_signal(%d)\n", p->p_pid));
-
- signum = SVR4_SVR42BSD_SIG(SVR4_SIGNO(SCARG(uap, signum)));
- if (signum <= 0 || signum > SVR4_NSIG)
- return (EINVAL);
-
- switch (SVR4_SIGCALL(SCARG(uap, signum))) {
- case SVR4_SIGDEFER_MASK:
- if (SCARG(uap, handler) == SVR4_SIG_HOLD)
- goto sighold;
- /* FALLTHROUGH */
-
- case SVR4_SIGNAL_MASK:
- {
- struct sigaction_args sa_args;
- struct sigaction *nbsa, *obsa, sa;
-
- nbsa = stackgap_alloc(&sg, sizeof(struct sigaction));
- obsa = stackgap_alloc(&sg, sizeof(struct sigaction));
- SCARG(&sa_args, sig) = signum;
- SCARG(&sa_args, act) = nbsa;
- SCARG(&sa_args, oact) = obsa;
-
- sa.sa_handler = (sig_t) SCARG(uap, handler);
- SIGEMPTYSET(sa.sa_mask);
- sa.sa_flags = 0;
-
- if (signum != SIGALRM)
- sa.sa_flags = SA_RESTART;
-
- if ((error = copyout(&sa, nbsa, sizeof(sa))) != 0)
- return error;
- if ((error = sigaction(p, &sa_args)) != 0) {
- DPRINTF(("signal: sigaction failed: %d\n",
- error));
- *retval = (int)SVR4_SIG_ERR;
- return error;
- }
- if ((error = copyin(obsa, &sa, sizeof(sa))) != 0)
- return error;
- *retval = (int)sa.sa_handler;
- return 0;
- }
-
- case SVR4_SIGHOLD_MASK:
-sighold:
- {
- struct sigprocmask_args sa;
- sigset_t *set;
-
- set = stackgap_alloc(&sg, sizeof(sigset_t));
- SIGEMPTYSET(*set);
- SIGADDSET(*set, signum);
- SCARG(&sa, how) = SIG_BLOCK;
- SCARG(&sa, set) = set;
- SCARG(&sa, oset) = NULL;
- return sigprocmask(p, &sa);
- }
-
- case SVR4_SIGRELSE_MASK:
- {
- struct sigprocmask_args sa;
- sigset_t *set;
-
- set = stackgap_alloc(&sg, sizeof(sigset_t));
- SIGEMPTYSET(*set);
- SIGADDSET(*set, signum);
- SCARG(&sa, how) = SIG_UNBLOCK;
- SCARG(&sa, set) = set;
- SCARG(&sa, oset) = NULL;
- return sigprocmask(p, &sa);
- }
-
- case SVR4_SIGIGNORE_MASK:
- {
- struct sigaction_args sa_args;
- struct sigaction *bsa, sa;
-
- bsa = stackgap_alloc(&sg, sizeof(struct sigaction));
- SCARG(&sa_args, sig) = signum;
- SCARG(&sa_args, act) = bsa;
- SCARG(&sa_args, oact) = NULL;
-
- sa.sa_handler = SIG_IGN;
- SIGEMPTYSET(sa.sa_mask);
- sa.sa_flags = 0;
- if ((error = copyout(&sa, bsa, sizeof(sa))) != 0)
- return error;
- if ((error = sigaction(p, &sa_args)) != 0) {
- DPRINTF(("sigignore: sigaction failed\n"));
- return error;
- }
- return 0;
- }
-
- case SVR4_SIGPAUSE_MASK:
- {
- struct sigsuspend_args sa;
- sigset_t *set;
-
- set = stackgap_alloc(&sg, sizeof(sigset_t));
- *set = p->p_sigmask;
- SIGDELSET(*set, signum);
- SCARG(&sa, sigmask) = set;
- return sigsuspend(p, &sa);
- }
-
- default:
- return (ENOSYS);
- }
-}
-
-
-int
-svr4_sys_sigprocmask(p, uap)
- struct proc *p;
- struct svr4_sys_sigprocmask_args *uap;
-{
- svr4_sigset_t sss;
- sigset_t bss;
- int error = 0, *retval;
-
- retval = p->p_retval;
- if (SCARG(uap, oset) != NULL) {
- /* Fix the return value first if needed */
- bsd_to_svr4_sigset(&p->p_sigmask, &sss);
- if ((error = copyout(&sss, SCARG(uap, oset), sizeof(sss))) != 0)
- return error;
- }
-
- if (SCARG(uap, set) == NULL)
- /* Just examine */
- return 0;
-
- if ((error = copyin(SCARG(uap, set), &sss, sizeof(sss))) != 0)
- return error;
-
- svr4_to_bsd_sigset(&sss, &bss);
-
- (void) splhigh();
-
- switch (SCARG(uap, how)) {
- case SVR4_SIG_BLOCK:
- SIGSETOR(p->p_sigmask, bss);
- SIG_CANTMASK(p->p_sigmask);
- break;
-
- case SVR4_SIG_UNBLOCK:
- SIGSETNAND(p->p_sigmask, bss);
- break;
-
- case SVR4_SIG_SETMASK:
- p->p_sigmask = bss;
- SIG_CANTMASK(p->p_sigmask);
- break;
-
- default:
- error = EINVAL;
- break;
- }
-
- (void) spl0();
-
- return error;
-}
-
-int
-svr4_sys_sigpending(p, uap)
- struct proc *p;
- struct svr4_sys_sigpending_args *uap;
-{
- sigset_t bss;
- int *retval;
- svr4_sigset_t sss;
-
- DPRINTF(("@@@ svr4_sys_sigpending(%d)\n", p->p_pid));
- retval = p->p_retval;
- switch (SCARG(uap, what)) {
- case 1: /* sigpending */
- if (SCARG(uap, mask) == NULL)
- return 0;
- bss = p->p_siglist;
- SIGSETAND(bss, p->p_sigmask);
- bsd_to_svr4_sigset(&bss, &sss);
- break;
-
- case 2: /* sigfillset */
- svr4_sigfillset(&sss);
-#if defined(DEBUG_SVR4)
- {
- int i;
- for (i = 0; i < 4; i++)
- DPRINTF(("new sigset[%d] = %lx\n", i, (long)sss.bits[i]));
- }
-#endif
- break;
-
- default:
- return EINVAL;
- }
-
- return copyout(&sss, SCARG(uap, mask), sizeof(sss));
-}
-
-int
-svr4_sys_sigsuspend(p, uap)
- register struct proc *p;
- struct svr4_sys_sigsuspend_args *uap;
-{
- svr4_sigset_t sss;
- sigset_t *bss;
- struct sigsuspend_args sa;
- int error;
- caddr_t sg = stackgap_init();
-
- if ((error = copyin(SCARG(uap, ss), &sss, sizeof(sss))) != 0)
- return error;
-
- bss = stackgap_alloc(&sg, sizeof(sigset_t));
- svr4_to_bsd_sigset(&sss, bss);
-
- SCARG(&sa, sigmask) = bss;
- return sigsuspend(p, &sa);
-}
-
-
-int
-svr4_sys_kill(p, uap)
- register struct proc *p;
- struct svr4_sys_kill_args *uap;
-{
- struct kill_args ka;
-
- SCARG(&ka, pid) = SCARG(uap, pid);
- SCARG(&ka, signum) = SVR4_SVR42BSD_SIG(SCARG(uap, signum));
- return kill(p, &ka);
-}
-
-
-int
-svr4_sys_context(p, uap)
- register struct proc *p;
- struct svr4_sys_context_args *uap;
-{
- struct svr4_ucontext uc;
- int error;
-
- switch (uap->func) {
- case 0:
- DPRINTF(("getcontext(%p)\n", uap->uc));
- svr4_getcontext(p, &uc, &p->p_sigmask,
- p->p_sigstk.ss_flags & SS_ONSTACK);
- return copyout(&uc, uap->uc, sizeof(uc));
-
- case 1:
- DPRINTF(("setcontext(%p)\n", uap->uc));
- if ((error = copyin(uap->uc, &uc, sizeof(uc))) != 0)
- return error;
- DPRINTF(("uc_flags = %lx\n", uc.uc_flags));
-#if defined(DEBUG_SVR4)
- {
- int i;
- for (i = 0; i < 4; i++)
- DPRINTF(("uc_sigmask[%d] = %lx\n", i,
- uc.uc_sigmask.bits[i]));
- }
-#endif
- return svr4_setcontext(p, &uc);
-
- default:
- DPRINTF(("context(%d, %p)\n", uap->func,
- uap->uc));
- return ENOSYS;
- }
- return 0;
-}
-
-int
-svr4_sys_pause(p, uap)
- register struct proc *p;
- struct svr4_sys_pause_args *uap;
-{
- struct sigsuspend_args bsa;
-
- SCARG(&bsa, sigmask) = &p->p_sigmask;
- return sigsuspend(p, &bsa);
-}
diff --git a/sys/compat/svr4/svr4_signal.h b/sys/compat/svr4/svr4_signal.h
deleted file mode 100644
index 1fdc3ab4cbc6..000000000000
--- a/sys/compat/svr4/svr4_signal.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1994 Christos Zoulas
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _SVR4_SIGNAL_H_
-#define _SVR4_SIGNAL_H_
-
-#include <i386/svr4/svr4_machdep.h>
-#include <svr4/svr4_siginfo.h>
-
-#define SVR4_SIGHUP 1
-#define SVR4_SIGINT 2
-#define SVR4_SIGQUIT 3
-#define SVR4_SIGILL 4
-#define SVR4_SIGTRAP 5
-#define SVR4_SIGIOT 6
-#define SVR4_SIGABRT 6
-#define SVR4_SIGEMT 7
-#define SVR4_SIGFPE 8
-#define SVR4_SIGKILL 9
-#define SVR4_SIGBUS 10
-#define SVR4_SIGSEGV 11
-#define SVR4_SIGSYS 12
-#define SVR4_SIGPIPE 13
-#define SVR4_SIGALRM 14
-#define SVR4_SIGTERM 15
-#define SVR4_SIGUSR1 16
-#define SVR4_SIGUSR2 17
-#define SVR4_SIGCLD 18
-#define SVR4_SIGCHLD 18
-#define SVR4_SIGPWR 19
-#define SVR4_SIGWINCH 20
-#define SVR4_SIGURG 21
-#define SVR4_SIGPOLL 22
-#define SVR4_SIGIO 22
-#define SVR4_SIGSTOP 23
-#define SVR4_SIGTSTP 24
-#define SVR4_SIGCONT 25
-#define SVR4_SIGTTIN 26
-#define SVR4_SIGTTOU 27
-#define SVR4_SIGVTALRM 28
-#define SVR4_SIGPROF 29
-#define SVR4_SIGXCPU 30
-#define SVR4_SIGXFSZ 31
-#define SVR4_NSIG 32
-#define SVR4_SIGTBLSZ 31
-
-#define SVR4_SIGNO_MASK 0x00FF
-#define SVR4_SIGNAL_MASK 0x0000
-#define SVR4_SIGDEFER_MASK 0x0100
-#define SVR4_SIGHOLD_MASK 0x0200
-#define SVR4_SIGRELSE_MASK 0x0400
-#define SVR4_SIGIGNORE_MASK 0x0800
-#define SVR4_SIGPAUSE_MASK 0x1000
-
-typedef void (*svr4_sig_t) __P((int, svr4_siginfo_t *, void *));
-#define SVR4_SIG_DFL (svr4_sig_t) 0
-#define SVR4_SIG_ERR (svr4_sig_t) -1
-#define SVR4_SIG_IGN (svr4_sig_t) 1
-#define SVR4_SIG_HOLD (svr4_sig_t) 2
-
-#define SVR4_SIGNO(a) ((a) & SVR4_SIGNO_MASK)
-#define SVR4_SIGCALL(a) ((a) & ~SVR4_SIGNO_MASK)
-
-#define SVR4_SIG_BLOCK 1
-#define SVR4_SIG_UNBLOCK 2
-#define SVR4_SIG_SETMASK 3
-
-extern int bsd_to_svr4_sig[];
-extern int svr4_to_bsd_sig[];
-
-#define SVR4_BSD2SVR4_SIG(sig) \
- (((sig) <= SVR4_SIGTBLSZ) ? bsd_to_svr4_sig[_SIG_IDX(sig)] : sig)
-#define SVR4_SVR42BSD_SIG(sig) \
- (((sig) <= SVR4_SIGTBLSZ) ? svr4_to_bsd_sig[_SIG_IDX(sig)] : sig)
-
-typedef struct {
- u_long bits[4];
-} svr4_sigset_t;
-
-struct svr4_sigaction {
- int ssa_flags;
- svr4_sig_t ssa_handler;
- svr4_sigset_t ssa_mask;
- int ssa_reserved[2];
-};
-
-struct svr4_sigaltstack {
- char *ss_sp;
- int ss_size;
- int ss_flags;
-};
-
-/* sa_flags */
-#define SVR4_SA_ONSTACK 0x00000001
-#define SVR4_SA_RESETHAND 0x00000002
-#define SVR4_SA_RESTART 0x00000004
-#define SVR4_SA_SIGINFO 0x00000008
-#define SVR4_SA_NODEFER 0x00000010
-#define SVR4_SA_NOCLDWAIT 0x00010000 /* No zombies */
-#define SVR4_SA_NOCLDSTOP 0x00020000 /* No jcl */
-#define SVR4_SA_ALLBITS 0x0003001f
-
-/* ss_flags */
-#define SVR4_SS_ONSTACK 0x00000001
-#define SVR4_SS_DISABLE 0x00000002
-#define SVR4_SS_ALLBITS 0x00000003
-
-void bsd_to_svr4_sigaltstack __P((const struct sigaltstack *, struct svr4_sigaltstack *));
-void bsd_to_svr4_sigset __P((const sigset_t *, svr4_sigset_t *));
-void svr4_to_bsd_sigaltstack __P((const struct svr4_sigaltstack *, struct sigaltstack *));
-void svr4_to_bsd_sigset __P((const svr4_sigset_t *, sigset_t *));
-void svr4_sendsig(sig_t, int, sigset_t *, u_long);
-
-#endif /* !_SVR4_SIGNAL_H_ */
diff --git a/sys/compat/svr4/svr4_socket.c b/sys/compat/svr4/svr4_socket.c
deleted file mode 100644
index 1884b07ef316..000000000000
--- a/sys/compat/svr4/svr4_socket.c
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1996 Christos Zoulas.
- * 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 Christos Zoulas.
- * 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.
- *
- * $FreeBSD$
- */
-
-/*
- * In SVR4 unix domain sockets are referenced sometimes
- * (in putmsg(2) for example) as a [device, inode] pair instead of a pathname.
- * Since there is no iname() routine in the kernel, and we need access to
- * a mapping from inode to pathname, we keep our own table. This is a simple
- * linked list that contains the pathname, the [device, inode] pair, the
- * file corresponding to that socket and the process. When the
- * socket gets closed we remove the item from the list. The list gets loaded
- * every time a stat(2) call finds a socket.
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/queue.h>
-#include <sys/file.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-#include <sys/sysproto.h>
-#include <sys/un.h>
-#include <sys/stat.h>
-#include <sys/proc.h>
-#include <sys/malloc.h>
-
-#include <svr4/svr4.h>
-#include <svr4/svr4_types.h>
-#include <svr4/svr4_util.h>
-#include <svr4/svr4_socket.h>
-#include <svr4/svr4_signal.h>
-#include <svr4/svr4_sockmod.h>
-#include <svr4/svr4_proto.h>
-
-struct svr4_sockcache_entry {
- struct proc *p; /* Process for the socket */
- void *cookie; /* Internal cookie used for matching */
- struct sockaddr_un sock;/* Pathname for the socket */
- udev_t dev; /* Device where the socket lives on */
- ino_t ino; /* Inode where the socket lives on */
- TAILQ_ENTRY(svr4_sockcache_entry) entries;
-};
-
-extern TAILQ_HEAD(svr4_sockcache_head, svr4_sockcache_entry) svr4_head;
-extern int svr4_str_initialized;
-
-struct sockaddr_un *
-svr4_find_socket(p, fp, dev, ino)
- struct proc *p;
- struct file *fp;
- udev_t dev;
- ino_t ino;
-{
- struct svr4_sockcache_entry *e;
- void *cookie = ((struct socket *) fp->f_data)->so_emuldata;
-
- if (!svr4_str_initialized) {
- DPRINTF(("svr4_find_socket: uninitialized [%p,%d,%d]\n",
- p, dev, ino));
- TAILQ_INIT(&svr4_head);
- svr4_str_initialized = 1;
- return NULL;
- }
-
-
- DPRINTF(("svr4_find_socket: [%p,%d,%d]: ", p, dev, ino));
- for (e = svr4_head.tqh_first; e != NULL; e = e->entries.tqe_next)
- if (e->p == p && e->dev == dev && e->ino == ino) {
-#ifdef DIAGNOSTIC
- if (e->cookie != NULL && e->cookie != cookie)
- panic("svr4 socket cookie mismatch");
-#endif
- e->cookie = cookie;
- DPRINTF(("%s\n", e->sock.sun_path));
- return &e->sock;
- }
-
- DPRINTF(("not found\n"));
- return NULL;
-}
-
-
-/*
- * svr4_delete_socket() is in sys/dev/streams.c (because it's called by
- * the streams "soo_close()" routine).
- */
-int
-svr4_add_socket(p, path, st)
- struct proc *p;
- const char *path;
- struct stat *st;
-{
- struct svr4_sockcache_entry *e;
- int len, error;
-
- if (!svr4_str_initialized) {
- TAILQ_INIT(&svr4_head);
- svr4_str_initialized = 1;
- }
-
- e = malloc(sizeof(*e), M_TEMP, M_WAITOK);
- e->cookie = NULL;
- e->dev = st->st_dev;
- e->ino = st->st_ino;
- e->p = p;
-
- if ((error = copyinstr(path, e->sock.sun_path,
- sizeof(e->sock.sun_path), &len)) != 0) {
- DPRINTF(("svr4_add_socket: copyinstr failed %d\n", error));
- free(e, M_TEMP);
- return error;
- }
-
- e->sock.sun_family = AF_LOCAL;
- e->sock.sun_len = len;
-
- TAILQ_INSERT_HEAD(&svr4_head, e, entries);
- DPRINTF(("svr4_add_socket: %s [%p,%d,%d]\n", e->sock.sun_path,
- p, e->dev, e->ino));
- return 0;
-}
-
-
-int
-svr4_sys_socket(p, uap)
- struct proc *p;
- struct svr4_sys_socket_args *uap;
-{
- switch (SCARG(uap, type)) {
- case SVR4_SOCK_DGRAM:
- SCARG(uap, type) = SOCK_DGRAM;
- break;
-
- case SVR4_SOCK_STREAM:
- SCARG(uap, type) = SOCK_STREAM;
- break;
-
- case SVR4_SOCK_RAW:
- SCARG(uap, type) = SOCK_RAW;
- break;
-
- case SVR4_SOCK_RDM:
- SCARG(uap, type) = SOCK_RDM;
- break;
-
- case SVR4_SOCK_SEQPACKET:
- SCARG(uap, type) = SOCK_SEQPACKET;
- break;
- default:
- return EINVAL;
- }
- return socket(p, (struct socket_args *)uap);
-}
diff --git a/sys/compat/svr4/svr4_socket.h b/sys/compat/svr4/svr4_socket.h
deleted file mode 100644
index 96e3582738fb..000000000000
--- a/sys/compat/svr4/svr4_socket.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1996 Christos Zoulas.
- * 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 Christos Zoulas.
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _SVR4_SOCKET_H_
-#define _SVR4_SOCKET_H_
-
-#include <netinet/in.h>
-
-struct sockaddr_un;
-struct proc;
-struct file;
-
-struct svr4_sockaddr_in {
- u_char sin_family;
- u_short sin_port;
- struct in_addr sin_addr;
- u_char sin_zero[8];
-};
-
-struct sockaddr_un *svr4_find_socket __P((struct proc *, struct file *,
- udev_t, ino_t));
-void svr4_delete_socket __P((struct proc *, struct file *));
-int svr4_add_socket __P((struct proc *, const char *, struct stat *));
-
-#endif /* _SVR4_SOCKET_H_ */
diff --git a/sys/compat/svr4/svr4_sockio.c b/sys/compat/svr4/svr4_sockio.c
deleted file mode 100644
index 5b99ae924dab..000000000000
--- a/sys/compat/svr4/svr4_sockio.c
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1995 Christos Zoulas
- * 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/proc.h>
-#include <sys/systm.h>
-#include <sys/file.h>
-#include <sys/filedesc.h>
-#include <sys/sockio.h>
-#include <sys/socket.h>
-#include <net/if.h>
-
-
-#include <svr4/svr4.h>
-#include <svr4/svr4_util.h>
-#include <svr4/svr4_ioctl.h>
-#include <svr4/svr4_sockio.h>
-
-static int bsd_to_svr4_flags __P((int));
-
-#define bsd_to_svr4_flag(a) \
- if (bf & __CONCAT(I,a)) sf |= __CONCAT(SVR4_I,a)
-
-static int
-bsd_to_svr4_flags(bf)
- int bf;
-{
- int sf = 0;
- bsd_to_svr4_flag(FF_UP);
- bsd_to_svr4_flag(FF_BROADCAST);
- bsd_to_svr4_flag(FF_DEBUG);
- bsd_to_svr4_flag(FF_LOOPBACK);
- bsd_to_svr4_flag(FF_POINTOPOINT);
-#if defined(IFF_NOTRAILERS)
- bsd_to_svr4_flag(FF_NOTRAILERS);
-#endif
- bsd_to_svr4_flag(FF_RUNNING);
- bsd_to_svr4_flag(FF_NOARP);
- bsd_to_svr4_flag(FF_PROMISC);
- bsd_to_svr4_flag(FF_ALLMULTI);
- bsd_to_svr4_flag(FF_MULTICAST);
- return sf;
-}
-
-int
-svr4_sock_ioctl(fp, p, retval, fd, cmd, data)
- struct file *fp;
- struct proc *p;
- register_t *retval;
- int fd;
- u_long cmd;
- caddr_t data;
-{
- int error;
-
- *retval = 0;
-
- switch (cmd) {
- case SVR4_SIOCGIFNUM:
- {
- struct ifnet *ifp;
- struct ifaddr *ifa;
- int ifnum = 0;
-
- /*
- * This does not return the number of physical
- * interfaces (if_index), but the number of interfaces
- * + addresses like ifconf() does, because this number
- * is used by code that will call SVR4_SIOCGIFCONF to
- * find the space needed for SVR4_SIOCGIFCONF. So we
- * count the number of ifreq entries that the next
- * SVR4_SIOCGIFCONF will return. Maybe a more correct
- * fix is to make SVR4_SIOCGIFCONF return only one
- * entry per physical interface?
- */
-
- for (ifp = ifnet.tqh_first;
- ifp != 0; ifp = ifp->if_link.tqe_next)
- if ((ifa = ifp->if_addrhead.tqh_first) == NULL)
- ifnum++;
- else
- for (;ifa != NULL;
- ifa = ifa->ifa_link.tqe_next)
- ifnum++;
-
-
- DPRINTF(("SIOCGIFNUM %d\n", ifnum));
- return copyout(&ifnum, data, sizeof(ifnum));
- }
-
- case SVR4_SIOCGIFFLAGS:
- {
- struct ifreq br;
- struct svr4_ifreq sr;
-
- if ((error = copyin(data, &sr, sizeof(sr))) != 0)
- return error;
-
- (void) strncpy(br.ifr_name, sr.svr4_ifr_name,
- sizeof(br.ifr_name));
- if ((error = fo_ioctl(fp, SIOCGIFFLAGS,
- (caddr_t) &br, p)) != 0) {
- DPRINTF(("SIOCGIFFLAGS (%s) %s: error %d\n",
- br.ifr_name, sr.svr4_ifr_name, error));
- return error;
- }
-
- sr.svr4_ifr_flags = bsd_to_svr4_flags(br.ifr_flags);
- DPRINTF(("SIOCGIFFLAGS %s = %x\n",
- sr.svr4_ifr_name, sr.svr4_ifr_flags));
- return copyout(&sr, data, sizeof(sr));
- }
-
- case SVR4_SIOCGIFCONF:
- {
- struct svr4_ifconf sc;
-
- if ((error = copyin(data, &sc, sizeof(sc))) != 0)
- return error;
-
- DPRINTF(("ifreq %d svr4_ifreq %d ifc_len %d\n",
- sizeof(struct ifreq), sizeof(struct svr4_ifreq),
- sc.svr4_ifc_len));
-
- if ((error = fo_ioctl(fp, OSIOCGIFCONF,
- (caddr_t) &sc, p)) != 0)
- return error;
-
- DPRINTF(("SIOCGIFCONF\n"));
- return 0;
- }
-
-
- default:
- DPRINTF(("Unknown svr4 sockio %lx\n", cmd));
- return 0; /* ENOSYS really */
- }
-}
diff --git a/sys/compat/svr4/svr4_sockio.h b/sys/compat/svr4/svr4_sockio.h
deleted file mode 100644
index dd4e220c9f48..000000000000
--- a/sys/compat/svr4/svr4_sockio.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1995 Christos Zoulas
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _SVR4_SOCKIO_H_
-#define _SVR4_SOCKIO_H_
-
-#define SVR4_IFF_UP 0x0001
-#define SVR4_IFF_BROADCAST 0x0002
-#define SVR4_IFF_DEBUG 0x0004
-#define SVR4_IFF_LOOPBACK 0x0008
-#define SVR4_IFF_POINTOPOINT 0x0010
-#define SVR4_IFF_NOTRAILERS 0x0020
-#define SVR4_IFF_RUNNING 0x0040
-#define SVR4_IFF_NOARP 0x0080
-#define SVR4_IFF_PROMISC 0x0100
-#define SVR4_IFF_ALLMULTI 0x0200
-#define SVR4_IFF_INTELLIGENT 0x0400
-#define SVR4_IFF_MULTICAST 0x0800
-#define SVR4_IFF_MULTI_BCAST 0x1000
-#define SVR4_IFF_UNNUMBERED 0x2000
-#define SVR4_IFF_PRIVATE 0x8000
-
-struct svr4_ifreq {
-#define SVR4_IFNAMSIZ 16
- char svr4_ifr_name[SVR4_IFNAMSIZ];
- union {
- struct osockaddr ifru_addr;
- struct osockaddr ifru_dstaddr;
- struct osockaddr ifru_broadaddr;
- short ifru_flags;
- int ifru_metric;
- char ifru_data;
- char ifru_enaddr[6];
- int if_muxid[2];
-
- } ifr_ifru;
-
-#define svr4_ifr_addr ifr_ifru.ifru_addr
-#define svr4_ifr_dstaddr ifr_ifru.ifru_dstaddr
-#define svr4_ifr_broadaddr ifr_ifru.ifru_broadaddr
-#define svr4_ifr_flags ifr_ifru.ifru_flags
-#define svr4_ifr_metric ifr_ifru.ifru_metric
-#define svr4_ifr_data ifr_ifru.ifru_data
-#define svr4_ifr_enaddr ifr_ifru.ifru_enaddr
-#define svr4_ifr_muxid ifr_ifru.ifru_muxid
-
-};
-
-struct svr4_ifconf {
- int svr4_ifc_len;
- union {
- caddr_t ifcu_buf;
- struct svr4_ifreq *ifcu_req;
- } ifc_ifcu;
-
-#define svr4_ifc_buf ifc_ifcu.ifcu_buf
-#define svr4_ifc_req ifc_ifcu.ifcu_req
-};
-
-#define SVR4_SIOC ('i' << 8)
-
-#define SVR4_SIOCGIFFLAGS SVR4_IOWR('i', 17, struct svr4_ifreq)
-#define SVR4_SIOCGIFCONF SVR4_IOWR('i', 20, struct svr4_ifconf)
-#define SVR4_SIOCGIFNUM SVR4_IOR('i', 87, int)
-
-#endif /* !_SVR4_SOCKIO_H_ */
diff --git a/sys/compat/svr4/svr4_sockmod.h b/sys/compat/svr4/svr4_sockmod.h
deleted file mode 100644
index 927ba0d28367..000000000000
--- a/sys/compat/svr4/svr4_sockmod.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1994 Christos Zoulas
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _SVR4_SOCKMOD_H_
-#define _SVR4_SOCKMOD_H_
-
-#define SVR4_SIMOD ('I' << 8)
-
-#define SVR4_SI_OGETUDATA (SVR4_SIMOD|101)
-#define SVR4_SI_SHUTDOWN (SVR4_SIMOD|102)
-#define SVR4_SI_LISTEN (SVR4_SIMOD|103)
-#define SVR4_SI_SETMYNAME (SVR4_SIMOD|104)
-#define SVR4_SI_SETPEERNAME (SVR4_SIMOD|105)
-#define SVR4_SI_GETINTRANSIT (SVR4_SIMOD|106)
-#define SVR4_SI_TCL_LINK (SVR4_SIMOD|107)
-#define SVR4_SI_TCL_UNLINK (SVR4_SIMOD|108)
-#define SVR4_SI_SOCKPARAMS (SVR4_SIMOD|109)
-#define SVR4_SI_GETUDATA (SVR4_SIMOD|110)
-
-
-#define SVR4_SOCK_DGRAM 1
-#define SVR4_SOCK_STREAM 2
-#define SVR4_SOCK_STREAM_ORD 3
-#define SVR4_SOCK_RAW 4
-#define SVR4_SOCK_RDM 5
-#define SVR4_SOCK_SEQPACKET 6
-
-struct svr4_si_sockparms {
- int family;
- int type;
- int protocol;
-};
-
-struct svr4_si_oudata {
- int tidusize;
- int addrsize;
- int optsize;
- int etsdusize;
- int servtype;
- int so_state;
- int so_options;
- int tsdusize;
-};
-
-struct svr4_si_udata {
- int tidusize;
- int addrsize;
- int optsize;
- int etsdusize;
- int servtype;
- int so_state;
- int so_options;
- int tsdusize;
- struct svr4_si_sockparms sockparms;
-};
-#endif /* !_SVR4_SOCKMOD_H_ */
diff --git a/sys/compat/svr4/svr4_stat.c b/sys/compat/svr4/svr4_stat.c
deleted file mode 100644
index 8884116f9b2b..000000000000
--- a/sys/compat/svr4/svr4_stat.c
+++ /dev/null
@@ -1,776 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1994 Christos Zoulas
- * 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/proc.h>
-#include <sys/stat.h>
-#include <sys/filedesc.h>
-#include <sys/kernel.h>
-#include <sys/unistd.h>
-#include <sys/time.h>
-#include <sys/sysctl.h>
-#include <sys/sysproto.h>
-
-#include <vm/vm.h>
-
-#include <netinet/in.h>
-
-#include <svr4/svr4.h>
-#include <svr4/svr4_types.h>
-#include <svr4/svr4_signal.h>
-#include <svr4/svr4_proto.h>
-#include <svr4/svr4_util.h>
-#include <svr4/svr4_stat.h>
-#include <svr4/svr4_ustat.h>
-#include <svr4/svr4_utsname.h>
-#include <svr4/svr4_systeminfo.h>
-#include <svr4/svr4_socket.h>
-#include <svr4/svr4_time.h>
-#if defined(NOTYET)
-#include "svr4_fuser.h"
-#endif
-
-#ifdef sparc
-/*
- * Solaris-2.4 on the sparc has the old stat call using the new
- * stat data structure...
- */
-# define SVR4_NO_OSTAT
-#endif
-
-struct svr4_ustat_args {
- svr4_dev_t dev;
- struct svr4_ustat * name;
-};
-
-static void bsd_to_svr4_xstat __P((struct stat *, struct svr4_xstat *));
-static void bsd_to_svr4_stat64 __P((struct stat *, struct svr4_stat64 *));
-int svr4_ustat __P((struct proc *, struct svr4_ustat_args *));
-static int svr4_to_bsd_pathconf __P((int));
-
-/*
- * SVR4 uses named pipes as named sockets, so we tell programs
- * that sockets are named pipes with mode 0
- */
-#define BSD_TO_SVR4_MODE(mode) (S_ISSOCK(mode) ? S_IFIFO : (mode))
-
-
-#ifndef SVR4_NO_OSTAT
-static void bsd_to_svr4_stat __P((struct stat *, struct svr4_stat *));
-
-static void
-bsd_to_svr4_stat(st, st4)
- struct stat *st;
- struct svr4_stat *st4;
-{
- memset(st4, 0, sizeof(*st4));
- st4->st_dev = bsd_to_svr4_odev_t(st->st_dev);
- st4->st_ino = st->st_ino;
- st4->st_mode = BSD_TO_SVR4_MODE(st->st_mode);
- st4->st_nlink = st->st_nlink;
- st4->st_uid = st->st_uid;
- st4->st_gid = st->st_gid;
- st4->st_rdev = bsd_to_svr4_odev_t(st->st_rdev);
- st4->st_size = st->st_size;
- st4->st_atim = st->st_atimespec.tv_sec;
- st4->st_mtim = st->st_mtimespec.tv_sec;
- st4->st_ctim = st->st_ctimespec.tv_sec;
-}
-#endif
-
-
-static void
-bsd_to_svr4_xstat(st, st4)
- struct stat *st;
- struct svr4_xstat *st4;
-{
- memset(st4, 0, sizeof(*st4));
- st4->st_dev = bsd_to_svr4_dev_t(st->st_dev);
- st4->st_ino = st->st_ino;
- st4->st_mode = BSD_TO_SVR4_MODE(st->st_mode);
- st4->st_nlink = st->st_nlink;
- st4->st_uid = st->st_uid;
- st4->st_gid = st->st_gid;
- st4->st_rdev = bsd_to_svr4_dev_t(st->st_rdev);
- st4->st_size = st->st_size;
- st4->st_atim = st->st_atimespec;
- st4->st_mtim = st->st_mtimespec;
- st4->st_ctim = st->st_ctimespec;
- st4->st_blksize = st->st_blksize;
- st4->st_blocks = st->st_blocks;
- strcpy(st4->st_fstype, "unknown");
-}
-
-
-static void
-bsd_to_svr4_stat64(st, st4)
- struct stat *st;
- struct svr4_stat64 *st4;
-{
- memset(st4, 0, sizeof(*st4));
- st4->st_dev = bsd_to_svr4_dev_t(st->st_dev);
- st4->st_ino = st->st_ino;
- st4->st_mode = BSD_TO_SVR4_MODE(st->st_mode);
- st4->st_nlink = st->st_nlink;
- st4->st_uid = st->st_uid;
- st4->st_gid = st->st_gid;
- st4->st_rdev = bsd_to_svr4_dev_t(st->st_rdev);
- st4->st_size = st->st_size;
- st4->st_atim = st->st_atimespec;
- st4->st_mtim = st->st_mtimespec;
- st4->st_ctim = st->st_ctimespec;
- st4->st_blksize = st->st_blksize;
- st4->st_blocks = st->st_blocks;
- strcpy(st4->st_fstype, "unknown");
-}
-
-int
-svr4_sys_stat(p, uap)
- struct proc *p;
- struct svr4_sys_stat_args *uap;
-{
- struct stat st;
- struct svr4_stat svr4_st;
- struct stat_args cup;
- int error;
- caddr_t sg = stackgap_init();
-
- CHECKALTEXIST(p, &sg, SCARG(uap, path));
-
- SCARG(&cup, path) = SCARG(uap, path);
- SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat));
-
-
- if ((error = stat(p, &cup)) != 0)
- return error;
-
- if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0)
- return error;
-
- bsd_to_svr4_stat(&st, &svr4_st);
-
- if (S_ISSOCK(st.st_mode))
- (void) svr4_add_socket(p, SCARG(uap, path), &st);
-
- if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0)
- return error;
-
- return 0;
-}
-
-
-int
-svr4_sys_lstat(p, uap)
- register struct proc *p;
- struct svr4_sys_lstat_args *uap;
-{
- struct stat st;
- struct svr4_stat svr4_st;
- struct lstat_args cup;
- int error;
- caddr_t sg = stackgap_init();
-
- CHECKALTEXIST(p, &sg, SCARG(uap, path));
-
- SCARG(&cup, path) = SCARG(uap, path);
- SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat));
-
- if ((error = lstat(p, &cup)) != 0)
- return error;
-
- if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0)
- return error;
-
- bsd_to_svr4_stat(&st, &svr4_st);
-
- if (S_ISSOCK(st.st_mode))
- (void) svr4_add_socket(p, SCARG(uap, path), &st);
-
- if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0)
- return error;
-
- return 0;
-}
-
-
-int
-svr4_sys_fstat(p, uap)
- register struct proc *p;
- struct svr4_sys_fstat_args *uap;
-{
- struct stat st;
- struct svr4_stat svr4_st;
- struct fstat_args cup;
- int error;
- caddr_t sg = stackgap_init();
-
- SCARG(&cup, fd) = SCARG(uap, fd);
- SCARG(&cup, sb) = stackgap_alloc(&sg, sizeof(struct stat));
-
- if ((error = fstat(p, &cup)) != 0)
- return error;
-
- if ((error = copyin(SCARG(&cup, sb), &st, sizeof st)) != 0)
- return error;
-
- bsd_to_svr4_stat(&st, &svr4_st);
-
- if ((error = copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st)) != 0)
- return error;
-
- return 0;
-}
-
-
-int
-svr4_sys_xstat(p, uap)
- register struct proc *p;
- struct svr4_sys_xstat_args *uap;
-{
- struct stat st;
- struct svr4_xstat svr4_st;
- struct stat_args cup;
- int error;
-
- caddr_t sg = stackgap_init();
- CHECKALTEXIST(p, &sg, SCARG(uap, path));
-
- SCARG(&cup, path) = SCARG(uap, path);
- SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat));
-
- if ((error = stat(p, &cup)) != 0)
- return error;
-
- if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0)
- return error;
-
- bsd_to_svr4_xstat(&st, &svr4_st);
-
-#if defined(SOCKET_NOTYET)
- if (S_ISSOCK(st.st_mode))
- (void) svr4_add_socket(p, SCARG(uap, path), &st);
-#endif
-
- if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0)
- return error;
-
- return 0;
-}
-
-int
-svr4_sys_lxstat(p, uap)
- register struct proc *p;
- struct svr4_sys_lxstat_args *uap;
-{
- struct stat st;
- struct svr4_xstat svr4_st;
- struct lstat_args cup;
- int error;
- caddr_t sg = stackgap_init();
- CHECKALTEXIST(p, &sg, SCARG(uap, path));
-
- SCARG(&cup, path) = SCARG(uap, path);
- SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat));
-
- if ((error = lstat(p, &cup)) != 0)
- return error;
-
- if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0)
- return error;
-
- bsd_to_svr4_xstat(&st, &svr4_st);
-
-#if defined(SOCKET_NOTYET)
- if (S_ISSOCK(st.st_mode))
- (void) svr4_add_socket(p, SCARG(uap, path), &st);
-#endif
- if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0)
- return error;
-
- return 0;
-}
-
-
-int
-svr4_sys_fxstat(p, uap)
- register struct proc *p;
- struct svr4_sys_fxstat_args *uap;
-{
- struct stat st;
- struct svr4_xstat svr4_st;
- struct fstat_args cup;
- int error;
-
- caddr_t sg = stackgap_init();
-
- SCARG(&cup, fd) = SCARG(uap, fd);
- SCARG(&cup, sb) = stackgap_alloc(&sg, sizeof(struct stat));
-
- if ((error = fstat(p, &cup)) != 0)
- return error;
-
- if ((error = copyin(SCARG(&cup, sb), &st, sizeof st)) != 0)
- return error;
-
- bsd_to_svr4_xstat(&st, &svr4_st);
-
- if ((error = copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st)) != 0)
- return error;
-
- return 0;
-}
-
-int
-svr4_sys_stat64(p, uap)
- register struct proc *p;
- struct svr4_sys_stat64_args *uap;
-{
- struct stat st;
- struct svr4_stat64 svr4_st;
- struct stat_args cup;
- int error;
- caddr_t sg = stackgap_init();
-
- CHECKALTEXIST(p, &sg, SCARG(uap, path));
-
- SCARG(&cup, path) = SCARG(uap, path);
- SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat));
-
- if ((error = stat(p, &cup)) != 0)
- return error;
-
- if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0)
- return error;
-
- bsd_to_svr4_stat64(&st, &svr4_st);
-
- if (S_ISSOCK(st.st_mode))
- (void) svr4_add_socket(p, SCARG(uap, path), &st);
-
- if ((error = copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st)) != 0)
- return error;
-
- return 0;
-}
-
-
-int
-svr4_sys_lstat64(p, uap)
- register struct proc *p;
- struct svr4_sys_lstat64_args *uap;
-{
- struct stat st;
- struct svr4_stat64 svr4_st;
- struct stat_args cup;
- int error;
- caddr_t sg = stackgap_init();
-
- CHECKALTEXIST(p, &sg, (char *) SCARG(uap, path));
-
- SCARG(&cup, path) = SCARG(uap, path);
- SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat));
-
- if ((error = lstat(p, (struct lstat_args *)&cup)) != 0)
- return error;
-
- if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0)
- return error;
-
- bsd_to_svr4_stat64(&st, &svr4_st);
-
- if (S_ISSOCK(st.st_mode))
- (void) svr4_add_socket(p, SCARG(uap, path), &st);
-
- if ((error = copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st)) != 0)
- return error;
-
- return 0;
-}
-
-
-int
-svr4_sys_fstat64(p, uap)
- register struct proc *p;
- struct svr4_sys_fstat64_args *uap;
-{
- struct stat st;
- struct svr4_stat64 svr4_st;
- struct fstat_args cup;
- int error;
- caddr_t sg = stackgap_init();
-
- SCARG(&cup, fd) = SCARG(uap, fd);
- SCARG(&cup, sb) = stackgap_alloc(&sg, sizeof(struct stat));
-
- if ((error = fstat(p, &cup)) != 0)
- return error;
-
- if ((error = copyin(SCARG(&cup, sb), &st, sizeof st)) != 0)
- return error;
-
- bsd_to_svr4_stat64(&st, &svr4_st);
-
- if ((error = copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st)) != 0)
- return error;
-
- return 0;
-}
-
-
-int
-svr4_ustat(p, uap)
- register struct proc *p;
- struct svr4_ustat_args *uap;
-{
- struct svr4_ustat us;
- int error;
-
- memset(&us, 0, sizeof us);
-
- /*
- * XXX: should set f_tfree and f_tinode at least
- * How do we translate dev -> fstat? (and then to svr4_ustat)
- */
- if ((error = copyout(&us, SCARG(uap, name), sizeof us)) != 0)
- return (error);
-
- return 0;
-}
-
-/*extern char ostype[], hostname[], osrelease[], version[], machine[];*/
-
-int
-svr4_sys_uname(p, uap)
- register struct proc *p;
- struct svr4_sys_uname_args *uap;
-{
- struct svr4_utsname sut;
-
-
- memset(&sut, 0, sizeof(sut));
-
- strncpy(sut.sysname, ostype, sizeof(sut.sysname));
- sut.sysname[sizeof(sut.sysname) - 1] = '\0';
-
- strncpy(sut.nodename, hostname, sizeof(sut.nodename));
- sut.nodename[sizeof(sut.nodename) - 1] = '\0';
-
- strncpy(sut.release, osrelease, sizeof(sut.release));
- sut.release[sizeof(sut.release) - 1] = '\0';
-
- strncpy(sut.version, version, sizeof(sut.version));
- sut.version[sizeof(sut.version) - 1] = '\0';
-
- strncpy(sut.machine, machine, sizeof(sut.machine));
- sut.machine[sizeof(sut.machine) - 1] = '\0';
-
- return copyout((caddr_t) &sut, (caddr_t) SCARG(uap, name),
- sizeof(struct svr4_utsname));
-}
-
-int
-svr4_sys_systeminfo(p, uap)
- struct proc *p;
- struct svr4_sys_systeminfo_args *uap;
-{
- char *str = NULL;
- int error = 0;
- register_t *retval = p->p_retval;
- size_t len = 0;
- char buf[1]; /* XXX NetBSD uses 256, but that seems
- like awfully excessive kstack usage
- for an empty string... */
- u_int rlen = SCARG(uap, len);
-
- switch (SCARG(uap, what)) {
- case SVR4_SI_SYSNAME:
- str = ostype;
- break;
-
- case SVR4_SI_HOSTNAME:
- str = hostname;
- break;
-
- case SVR4_SI_RELEASE:
- str = osrelease;
- break;
-
- case SVR4_SI_VERSION:
- str = version;
- break;
-
- case SVR4_SI_MACHINE:
- str = machine;
- break;
-
- case SVR4_SI_ARCHITECTURE:
- str = machine;
- break;
-
- case SVR4_SI_HW_SERIAL:
- str = "0";
- break;
-
- case SVR4_SI_HW_PROVIDER:
- str = ostype;
- break;
-
- case SVR4_SI_SRPC_DOMAIN:
- str = domainname;
- break;
-
- case SVR4_SI_PLATFORM:
-#ifdef __i386__
- str = "i86pc";
-#else
- str = "unknown";
-#endif
- break;
-
- case SVR4_SI_KERB_REALM:
- str = "unsupported";
- break;
-#if defined(WHY_DOES_AN_EMULATOR_WANT_TO_SET_HOSTNAMES)
- case SVR4_SI_SET_HOSTNAME:
- if ((error = suser(p)) != 0)
- return error;
- name = KERN_HOSTNAME;
- return kern_sysctl(&name, 1, 0, 0, SCARG(uap, buf), rlen, p);
-
- case SVR4_SI_SET_SRPC_DOMAIN:
- if ((error = suser(p)) != 0)
- return error;
- name = KERN_NISDOMAINNAME;
- return kern_sysctl(&name, 1, 0, 0, SCARG(uap, buf), rlen, p);
-#else
- case SVR4_SI_SET_HOSTNAME:
- case SVR4_SI_SET_SRPC_DOMAIN:
- /* FALLTHROUGH */
-#endif
- case SVR4_SI_SET_KERB_REALM:
- return 0;
-
- default:
- DPRINTF(("Bad systeminfo command %d\n", SCARG(uap, what)));
- return ENOSYS;
- }
-
- if (str) {
- len = strlen(str) + 1;
- if (len > rlen)
- len = rlen;
-
- if (SCARG(uap, buf)) {
- error = copyout(str, SCARG(uap, buf), len);
- if (error)
- return error;
- /* make sure we are NULL terminated */
- buf[0] = '\0';
- error = copyout(buf, &(SCARG(uap, buf)[len - 1]), 1);
- }
- else
- error = 0;
- }
- /* XXX NetBSD has hostname setting stuff here. Why would an emulator
- want to do that? */
-
- *retval = len;
- return error;
-}
-
-int
-svr4_sys_utssys(p, uap)
- register struct proc *p;
- struct svr4_sys_utssys_args *uap;
-{
- switch (SCARG(uap, sel)) {
- case 0: /* uname(2) */
- {
- struct svr4_sys_uname_args ua;
- SCARG(&ua, name) = SCARG(uap, a1);
- return svr4_sys_uname(p, &ua);
- }
-
- case 2: /* ustat(2) */
- {
- struct svr4_ustat_args ua;
- SCARG(&ua, dev) = (svr4_dev_t) SCARG(uap, a2);
- SCARG(&ua, name) = SCARG(uap, a1);
- return svr4_ustat(p, &ua);
- }
-
- case 3: /* fusers(2) */
- return ENOSYS;
-
- default:
- return ENOSYS;
- }
- return ENOSYS;
-}
-
-
-int
-svr4_sys_utime(p, uap)
- register struct proc *p;
- struct svr4_sys_utime_args *uap;
-{
- struct svr4_utimbuf ub;
- struct timeval tbuf[2];
- struct utimes_args ap;
- int error;
- caddr_t sg = stackgap_init();
- void *ttp;
-
- CHECKALTEXIST(p, &sg, SCARG(uap, path));
- SCARG(&ap, path) = SCARG(uap, path);
- if (SCARG(uap, ubuf) != NULL) {
- if ((error = copyin(SCARG(uap, ubuf), &ub, sizeof(ub))) != 0)
- return error;
- tbuf[0].tv_sec = ub.actime;
- tbuf[0].tv_usec = 0;
- tbuf[1].tv_sec = ub.modtime;
- tbuf[1].tv_usec = 0;
- ttp = stackgap_alloc(&sg, sizeof(tbuf));
- error = copyout(tbuf, ttp, sizeof(tbuf));
- if (error)
- return error;
- SCARG(&ap, tptr) = ttp;
- }
- else
- SCARG(&ap, tptr) = NULL;
- return utimes(p, &ap);
-}
-
-
-int
-svr4_sys_utimes(p, uap)
- register struct proc *p;
- struct svr4_sys_utimes_args *uap;
-{
- caddr_t sg = stackgap_init();
- CHECKALTEXIST(p, &sg, SCARG(uap, path));
- return utimes(p, (struct utimes_args *)uap);
-}
-
-static int
-svr4_to_bsd_pathconf(name)
- int name;
-{
- switch (name) {
- case SVR4_PC_LINK_MAX:
- return _PC_LINK_MAX;
-
- case SVR4_PC_MAX_CANON:
- return _PC_MAX_CANON;
-
- case SVR4_PC_MAX_INPUT:
- return _PC_MAX_INPUT;
-
- case SVR4_PC_NAME_MAX:
- return _PC_NAME_MAX;
-
- case SVR4_PC_PATH_MAX:
- return _PC_PATH_MAX;
-
- case SVR4_PC_PIPE_BUF:
- return _PC_PIPE_BUF;
-
- case SVR4_PC_NO_TRUNC:
- return _PC_NO_TRUNC;
-
- case SVR4_PC_VDISABLE:
- return _PC_VDISABLE;
-
- case SVR4_PC_CHOWN_RESTRICTED:
- return _PC_CHOWN_RESTRICTED;
- case SVR4_PC_SYNC_IO:
-#if defined(_PC_SYNC_IO)
- return _PC_SYNC_IO;
-#else
- return 0;
-#endif
- case SVR4_PC_ASYNC_IO:
- case SVR4_PC_PRIO_IO:
- /* Not supported */
- return 0;
-
- default:
- /* Invalid */
- return -1;
- }
-}
-
-
-int
-svr4_sys_pathconf(p, uap)
- register struct proc *p;
- struct svr4_sys_pathconf_args *uap;
-{
- caddr_t sg = stackgap_init();
- register_t *retval = p->p_retval;
-
- CHECKALTEXIST(p, &sg, SCARG(uap, path));
-
- SCARG(uap, name) = svr4_to_bsd_pathconf(SCARG(uap, name));
-
- switch (SCARG(uap, name)) {
- case -1:
- *retval = -1;
- return EINVAL;
- case 0:
- *retval = 0;
- return 0;
- default:
- return pathconf(p, (struct pathconf_args *)uap);
- }
-}
-
-
-int
-svr4_sys_fpathconf(p, uap)
- register struct proc *p;
- struct svr4_sys_fpathconf_args *uap;
-{
- register_t *retval = p->p_retval;
-
- SCARG(uap, name) = svr4_to_bsd_pathconf(SCARG(uap, name));
-
- switch (SCARG(uap, name)) {
- case -1:
- *retval = -1;
- return EINVAL;
- case 0:
- *retval = 0;
- return 0;
- default:
- return fpathconf(p, (struct fpathconf_args *)uap);
- }
-}
diff --git a/sys/compat/svr4/svr4_stat.h b/sys/compat/svr4/svr4_stat.h
deleted file mode 100644
index 7eeff44f30ac..000000000000
--- a/sys/compat/svr4/svr4_stat.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1994 Christos Zoulas
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _SVR4_STAT_H_
-#define _SVR4_STAT_H_
-
-#include <svr4/svr4_types.h>
-#include <sys/stat.h>
-
-struct svr4_stat {
- svr4_o_dev_t st_dev;
- svr4_o_ino_t st_ino;
- svr4_o_mode_t st_mode;
- svr4_o_nlink_t st_nlink;
- svr4_o_uid_t st_uid;
- svr4_o_gid_t st_gid;
- svr4_o_dev_t st_rdev;
- svr4_off_t st_size;
- svr4_time_t st_atim;
- svr4_time_t st_mtim;
- svr4_time_t st_ctim;
-};
-
-struct svr4_xstat {
- svr4_dev_t st_dev;
- long st_pad1[3];
- svr4_ino_t st_ino;
- svr4_mode_t st_mode;
- svr4_nlink_t st_nlink;
- svr4_uid_t st_uid;
- svr4_gid_t st_gid;
- svr4_dev_t st_rdev;
- long st_pad2[2];
- svr4_off_t st_size;
- long st_pad3;
- svr4_timestruc_t st_atim;
- svr4_timestruc_t st_mtim;
- svr4_timestruc_t st_ctim;
- long st_blksize;
- svr4_blkcnt_t st_blocks;
- char st_fstype[16];
- long st_pad4[8];
-};
-
-struct svr4_stat64 {
- svr4_dev_t st_dev;
- long st_pad1[3];
- svr4_ino64_t st_ino;
- svr4_mode_t st_mode;
- svr4_nlink_t st_nlink;
- svr4_uid_t st_uid;
- svr4_gid_t st_gid;
- svr4_dev_t st_rdev;
- long st_pad2[2];
- svr4_off64_t st_size;
- svr4_timestruc_t st_atim;
- svr4_timestruc_t st_mtim;
- svr4_timestruc_t st_ctim;
- long st_blksize;
- svr4_blkcnt64_t st_blocks;
- char st_fstype[16];
- long st_pad4[8];
-};
-
-#define SVR4_PC_LINK_MAX 1
-#define SVR4_PC_MAX_CANON 2
-#define SVR4_PC_MAX_INPUT 3
-#define SVR4_PC_NAME_MAX 4
-#define SVR4_PC_PATH_MAX 5
-#define SVR4_PC_PIPE_BUF 6
-#define SVR4_PC_NO_TRUNC 7
-#define SVR4_PC_VDISABLE 8
-#define SVR4_PC_CHOWN_RESTRICTED 9
-#define SVR4_PC_ASYNC_IO 10
-#define SVR4_PC_PRIO_IO 11
-#define SVR4_PC_SYNC_IO 12
-
-#endif /* !_SVR4_STAT_H_ */
diff --git a/sys/compat/svr4/svr4_statvfs.h b/sys/compat/svr4/svr4_statvfs.h
deleted file mode 100644
index b3bf473a1b52..000000000000
--- a/sys/compat/svr4/svr4_statvfs.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1994 Christos Zoulas
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _SVR4_STATVFS_H_
-#define _SVR4_STATVFS_H_
-
-typedef struct svr4_statvfs {
- u_long f_bsize;
- u_long f_frsize;
- svr4_fsblkcnt_t f_blocks;
- svr4_fsblkcnt_t f_bfree;
- svr4_fsblkcnt_t f_bavail;
- svr4_fsblkcnt_t f_files;
- svr4_fsblkcnt_t f_ffree;
- svr4_fsblkcnt_t f_favail;
- u_long f_fsid;
- char f_basetype[16];
- u_long f_flag;
- u_long f_namemax;
- char f_fstr[32];
- u_long f_filler[16];
-} svr4_statvfs_t;
-
-typedef struct svr4_statvfs64 {
- u_long f_bsize;
- u_long f_frsize;
- svr4_fsblkcnt64_t f_blocks;
- svr4_fsblkcnt64_t f_bfree;
- svr4_fsblkcnt64_t f_bavail;
- svr4_fsblkcnt64_t f_files;
- svr4_fsblkcnt64_t f_ffree;
- svr4_fsblkcnt64_t f_favail;
- u_long f_fsid;
- char f_basetype[16];
- u_long f_flag;
- u_long f_namemax;
- char f_fstr[32];
- u_long f_filler[16];
-} svr4_statvfs64_t;
-
-#define SVR4_ST_RDONLY 0x01
-#define SVR4_ST_NOSUID 0x02
-#define SVR4_ST_NOTRUNC 0x04
-
-#endif /* !_SVR4_STATVFS_H_ */
diff --git a/sys/compat/svr4/svr4_stream.c b/sys/compat/svr4/svr4_stream.c
deleted file mode 100644
index aa27ac04eef2..000000000000
--- a/sys/compat/svr4/svr4_stream.c
+++ /dev/null
@@ -1,2258 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton. All rights reserved.
- * Copyright (c) 1994, 1996 Christos Zoulas. 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 Christos Zoulas.
- * 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Pretend that we have streams...
- * Yes, this is gross.
- *
- * ToDo: The state machine for getmsg needs re-thinking
- */
-
-#define COMPAT_43 1
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/buf.h>
-#include <sys/malloc.h>
-#include <sys/file.h>
-#include <sys/filedesc.h>
-#include <sys/fcntl.h>
-#include <sys/filio.h>
-#include <sys/select.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-#include <sys/un.h>
-#include <netinet/in.h>
-#include <sys/mbuf.h>
-#include <sys/protosw.h>
-#include <sys/signal.h>
-#include <sys/signalvar.h>
-#include <sys/uio.h>
-#include <sys/ktrace.h>
-#include <sys/proc.h>
-#include <sys/stat.h>
-
-#include <sys/sysproto.h>
-
-#include <svr4/svr4.h>
-#include <svr4/svr4_types.h>
-#include <svr4/svr4_util.h>
-#include <svr4/svr4_signal.h>
-#include <svr4/svr4_proto.h>
-#include <svr4/svr4_stropts.h>
-#include <svr4/svr4_timod.h>
-#include <svr4/svr4_sockmod.h>
-#include <svr4/svr4_ioctl.h>
-#include <svr4/svr4_socket.h>
-
-/* Utils */
-static int clean_pipe __P((struct proc *, const char *));
-static void getparm __P((struct file *, struct svr4_si_sockparms *));
-
-/* Address Conversions */
-static void sockaddr_to_netaddr_in __P((struct svr4_strmcmd *,
- const struct sockaddr_in *));
-static void sockaddr_to_netaddr_un __P((struct svr4_strmcmd *,
- const struct sockaddr_un *));
-static void netaddr_to_sockaddr_in __P((struct sockaddr_in *,
- const struct svr4_strmcmd *));
-static void netaddr_to_sockaddr_un __P((struct sockaddr_un *,
- const struct svr4_strmcmd *));
-
-/* stream ioctls */
-static int i_nread __P((struct file *, struct proc *, register_t *, int,
- u_long, caddr_t));
-static int i_fdinsert __P((struct file *, struct proc *, register_t *, int,
- u_long, caddr_t));
-static int i_str __P((struct file *, struct proc *, register_t *, int,
- u_long, caddr_t));
-static int i_setsig __P((struct file *, struct proc *, register_t *, int,
- u_long, caddr_t));
-static int i_getsig __P((struct file *, struct proc *, register_t *, int,
- u_long, caddr_t));
-static int _i_bind_rsvd __P((struct file *, struct proc *, register_t *, int,
- u_long, caddr_t));
-static int _i_rele_rsvd __P((struct file *, struct proc *, register_t *, int,
- u_long, caddr_t));
-
-/* i_str sockmod calls */
-static int sockmod __P((struct file *, int, struct svr4_strioctl *,
- struct proc *));
-static int si_listen __P((struct file *, int, struct svr4_strioctl *,
- struct proc *));
-static int si_ogetudata __P((struct file *, int, struct svr4_strioctl *,
- struct proc *));
-static int si_sockparams __P((struct file *, int, struct svr4_strioctl *,
- struct proc *));
-static int si_shutdown __P((struct file *, int, struct svr4_strioctl *,
- struct proc *));
-static int si_getudata __P((struct file *, int, struct svr4_strioctl *,
- struct proc *));
-
-/* i_str timod calls */
-static int timod __P((struct file *, int, struct svr4_strioctl *,
- struct proc *));
-static int ti_getinfo __P((struct file *, int, struct svr4_strioctl *,
- struct proc *));
-static int ti_bind __P((struct file *, int, struct svr4_strioctl *,
- struct proc *));
-
-/* infrastructure */
-static int svr4_sendit __P((struct proc *p, int s, struct msghdr *mp,
- int flags));
-
-static int svr4_recvit __P((struct proc *p, int s, struct msghdr *mp,
- caddr_t namelenp));
-
-/* <sigh> Ok, so we shouldn't use sendit() in uipc_syscalls.c because
- * it isn't part of a "public" interface; We're supposed to use
- * pru_sosend instead. Same goes for recvit()/pru_soreceive() for
- * that matter. Solution: Suck sendit()/recvit() into here where we
- * can do what we like.
- *
- * I hate code duplication.
- *
- * I will take out all the #ifdef COMPAT_OLDSOCK gumph, though.
- */
-static int
-svr4_sendit(p, s, mp, flags)
- register struct proc *p;
- int s;
- register struct msghdr *mp;
- int flags;
-{
- struct file *fp;
- struct uio auio;
- register struct iovec *iov;
- register int i;
- struct mbuf *control;
- struct sockaddr *to;
- int len, error;
- struct socket *so;
-#ifdef KTRACE
- struct iovec *ktriov = NULL;
-#endif
-
- error = getsock(p->p_fd, s, &fp);
- if (error)
- return (error);
- auio.uio_iov = mp->msg_iov;
- auio.uio_iovcnt = mp->msg_iovlen;
- auio.uio_segflg = UIO_USERSPACE;
- auio.uio_rw = UIO_WRITE;
- auio.uio_procp = p;
- auio.uio_offset = 0; /* XXX */
- auio.uio_resid = 0;
- iov = mp->msg_iov;
- for (i = 0; i < mp->msg_iovlen; i++, iov++) {
- if ((auio.uio_resid += iov->iov_len) < 0)
- return (EINVAL);
- }
- if (mp->msg_name) {
- error = getsockaddr(&to, mp->msg_name, mp->msg_namelen);
- if (error)
- return (error);
- } else
- to = 0;
- if (mp->msg_control) {
- if (mp->msg_controllen < sizeof(struct cmsghdr)) {
- error = EINVAL;
- goto bad;
- }
- error = sockargs(&control, mp->msg_control,
- mp->msg_controllen, MT_CONTROL);
- if (error)
- goto bad;
- } else
- control = 0;
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_GENIO)) {
- int iovlen = auio.uio_iovcnt * sizeof (struct iovec);
-
- MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, M_WAITOK);
- bcopy((caddr_t)auio.uio_iov, (caddr_t)ktriov, iovlen);
- }
-#endif
- len = auio.uio_resid;
- so = (struct socket *)fp->f_data;
- error = so->so_proto->pr_usrreqs->pru_sosend(so, to, &auio, 0, control,
- flags, p);
- if (error) {
- if (auio.uio_resid != len && (error == ERESTART ||
- error == EINTR || error == EWOULDBLOCK))
- error = 0;
- if (error == EPIPE)
- psignal(p, SIGPIPE);
- }
- if (error == 0)
- p->p_retval[0] = len - auio.uio_resid;
-#ifdef KTRACE
- if (ktriov != NULL) {
- if (error == 0)
- ktrgenio(p->p_tracep, s, UIO_WRITE,
- ktriov, p->p_retval[0], error);
- FREE(ktriov, M_TEMP);
- }
-#endif
-bad:
- if (to)
- FREE(to, M_SONAME);
- return (error);
-}
-
-static int
-svr4_recvit(p, s, mp, namelenp)
- register struct proc *p;
- int s;
- register struct msghdr *mp;
- caddr_t namelenp;
-{
- struct file *fp;
- struct uio auio;
- register struct iovec *iov;
- register int i;
- int len, error;
- struct mbuf *m, *control = 0;
- caddr_t ctlbuf;
- struct socket *so;
- struct sockaddr *fromsa = 0;
-#ifdef KTRACE
- struct iovec *ktriov = NULL;
-#endif
-
- error = getsock(p->p_fd, s, &fp);
- if (error)
- return (error);
- auio.uio_iov = mp->msg_iov;
- auio.uio_iovcnt = mp->msg_iovlen;
- auio.uio_segflg = UIO_USERSPACE;
- auio.uio_rw = UIO_READ;
- auio.uio_procp = p;
- auio.uio_offset = 0; /* XXX */
- auio.uio_resid = 0;
- iov = mp->msg_iov;
- for (i = 0; i < mp->msg_iovlen; i++, iov++) {
- if ((auio.uio_resid += iov->iov_len) < 0)
- return (EINVAL);
- }
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_GENIO)) {
- int iovlen = auio.uio_iovcnt * sizeof (struct iovec);
-
- MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, M_WAITOK);
- bcopy((caddr_t)auio.uio_iov, (caddr_t)ktriov, iovlen);
- }
-#endif
- len = auio.uio_resid;
- so = (struct socket *)fp->f_data;
- error = so->so_proto->pr_usrreqs->pru_soreceive(so, &fromsa, &auio,
- (struct mbuf **)0, mp->msg_control ? &control : (struct mbuf **)0,
- &mp->msg_flags);
- if (error) {
- if (auio.uio_resid != len && (error == ERESTART ||
- error == EINTR || error == EWOULDBLOCK))
- error = 0;
- }
-#ifdef KTRACE
- if (ktriov != NULL) {
- if (error == 0)
- ktrgenio(p->p_tracep, s, UIO_READ,
- ktriov, len - auio.uio_resid, error);
- FREE(ktriov, M_TEMP);
- }
-#endif
- if (error)
- goto out;
- p->p_retval[0] = len - auio.uio_resid;
- if (mp->msg_name) {
- len = mp->msg_namelen;
- if (len <= 0 || fromsa == 0)
- len = 0;
- else {
-#ifndef MIN
-#define MIN(a,b) ((a)>(b)?(b):(a))
-#endif
- /* save sa_len before it is destroyed by MSG_COMPAT */
- len = MIN(len, fromsa->sa_len);
- error = copyout(fromsa,
- (caddr_t)mp->msg_name, (unsigned)len);
- if (error)
- goto out;
- }
- mp->msg_namelen = len;
- if (namelenp &&
- (error = copyout((caddr_t)&len, namelenp, sizeof (int)))) {
- goto out;
- }
- }
- if (mp->msg_control) {
- len = mp->msg_controllen;
- m = control;
- mp->msg_controllen = 0;
- ctlbuf = (caddr_t) mp->msg_control;
-
- while (m && len > 0) {
- unsigned int tocopy;
-
- if (len >= m->m_len)
- tocopy = m->m_len;
- else {
- mp->msg_flags |= MSG_CTRUNC;
- tocopy = len;
- }
-
- if ((error = copyout((caddr_t)mtod(m, caddr_t),
- ctlbuf, tocopy)) != 0)
- goto out;
-
- ctlbuf += tocopy;
- len -= tocopy;
- m = m->m_next;
- }
- mp->msg_controllen = ctlbuf - (caddr_t)mp->msg_control;
- }
-out:
- if (fromsa)
- FREE(fromsa, M_SONAME);
- if (control)
- m_freem(control);
- return (error);
-}
-
-#ifdef DEBUG_SVR4
-static void bufprint __P((u_char *, size_t));
-static int show_ioc __P((const char *, struct svr4_strioctl *));
-static int show_strbuf __P((struct svr4_strbuf *));
-static void show_msg __P((const char *, int, struct svr4_strbuf *,
- struct svr4_strbuf *, int));
-
-static void
-bufprint(buf, len)
- u_char *buf;
- size_t len;
-{
- size_t i;
-
- uprintf("\n\t");
- for (i = 0; i < len; i++) {
- uprintf("%x ", buf[i]);
- if (i && (i % 16) == 0)
- uprintf("\n\t");
- }
-}
-
-static int
-show_ioc(str, ioc)
- const char *str;
- struct svr4_strioctl *ioc;
-{
- u_char *ptr = (u_char *) malloc(ioc->len, M_TEMP, M_WAITOK);
- int error;
-
- uprintf("%s cmd = %ld, timeout = %d, len = %d, buf = %p { ",
- str, ioc->cmd, ioc->timeout, ioc->len, ioc->buf);
-
- if ((error = copyin(ioc->buf, ptr, ioc->len)) != 0) {
- free((char *) ptr, M_TEMP);
- return error;
- }
-
- bufprint(ptr, ioc->len);
-
- uprintf("}\n");
-
- free((char *) ptr, M_TEMP);
- return 0;
-}
-
-
-static int
-show_strbuf(str)
- struct svr4_strbuf *str;
-{
- int error;
- u_char *ptr = NULL;
- int maxlen = str->maxlen;
- int len = str->len;
-
- if (maxlen < 0)
- maxlen = 0;
-
- if (len >= maxlen)
- len = maxlen;
-
- if (len > 0) {
- ptr = (u_char *) malloc(len, M_TEMP, M_WAITOK);
-
- if ((error = copyin(str->buf, ptr, len)) != 0) {
- free((char *) ptr, M_TEMP);
- return error;
- }
- }
-
- uprintf(", { %d, %d, %p=[ ", str->maxlen, str->len, str->buf);
-
- if (ptr)
- bufprint(ptr, len);
-
- uprintf("]}");
-
- if (ptr)
- free((char *) ptr, M_TEMP);
-
- return 0;
-}
-
-
-static void
-show_msg(str, fd, ctl, dat, flags)
- const char *str;
- int fd;
- struct svr4_strbuf *ctl;
- struct svr4_strbuf *dat;
- int flags;
-{
- struct svr4_strbuf buf;
- int error;
-
- uprintf("%s(%d", str, fd);
- if (ctl != NULL) {
- if ((error = copyin(ctl, &buf, sizeof(buf))) != 0)
- return;
- show_strbuf(&buf);
- }
- else
- uprintf(", NULL");
-
- if (dat != NULL) {
- if ((error = copyin(dat, &buf, sizeof(buf))) != 0)
- return;
- show_strbuf(&buf);
- }
- else
- uprintf(", NULL");
-
- uprintf(", %x);\n", flags);
-}
-
-#endif /* DEBUG_SVR4 */
-
-/*
- * We are faced with an interesting situation. On svr4 unix sockets
- * are really pipes. But we really have sockets, and we might as
- * well use them. At the point where svr4 calls TI_BIND, it has
- * already created a named pipe for the socket using mknod(2).
- * We need to create a socket with the same name when we bind,
- * so we need to remove the pipe before, otherwise we'll get address
- * already in use. So we *carefully* remove the pipe, to avoid
- * using this as a random file removal tool. We use system calls
- * to avoid code duplication.
- */
-static int
-clean_pipe(p, path)
- struct proc *p;
- const char *path;
-{
- struct lstat_args la;
- struct unlink_args ua;
- struct stat st;
- int error;
- caddr_t sg = stackgap_init();
- size_t l = strlen(path) + 1;
- void *tpath;
-
- tpath = stackgap_alloc(&sg, l);
- SCARG(&la, ub) = stackgap_alloc(&sg, sizeof(struct stat));
-
- if ((error = copyout(path, tpath, l)) != 0)
- return error;
-
- SCARG(&la, path) = tpath;
-
- if ((error = lstat(p, &la)) != 0)
- return 0;
-
- if ((error = copyin(SCARG(&la, ub), &st, sizeof(st))) != 0)
- return 0;
-
- /*
- * Make sure we are dealing with a mode 0 named pipe.
- */
- if ((st.st_mode & S_IFMT) != S_IFIFO)
- return 0;
-
- if ((st.st_mode & ALLPERMS) != 0)
- return 0;
-
- SCARG(&ua, path) = SCARG(&la, path);
-
- if ((error = unlink(p, &ua)) != 0) {
- DPRINTF(("clean_pipe: unlink failed %d\n", error));
- return error;
- }
-
- return 0;
-}
-
-
-static void
-sockaddr_to_netaddr_in(sc, sain)
- struct svr4_strmcmd *sc;
- const struct sockaddr_in *sain;
-{
- struct svr4_netaddr_in *na;
- na = SVR4_ADDROF(sc);
-
- na->family = sain->sin_family;
- na->port = sain->sin_port;
- na->addr = sain->sin_addr.s_addr;
- DPRINTF(("sockaddr_in -> netaddr %d %d %lx\n", na->family, na->port,
- na->addr));
-}
-
-
-static void
-sockaddr_to_netaddr_un(sc, saun)
- struct svr4_strmcmd *sc;
- const struct sockaddr_un *saun;
-{
- struct svr4_netaddr_un *na;
- char *dst, *edst = ((char *) sc) + sc->offs + sizeof(na->family) + 1 -
- sizeof(*sc);
- const char *src;
-
- na = SVR4_ADDROF(sc);
- na->family = saun->sun_family;
- for (src = saun->sun_path, dst = na->path; (*dst++ = *src++) != '\0'; )
- if (dst == edst)
- break;
- DPRINTF(("sockaddr_un -> netaddr %d %s\n", na->family, na->path));
-}
-
-
-static void
-netaddr_to_sockaddr_in(sain, sc)
- struct sockaddr_in *sain;
- const struct svr4_strmcmd *sc;
-{
- const struct svr4_netaddr_in *na;
-
-
- na = SVR4_C_ADDROF(sc);
- memset(sain, 0, sizeof(*sain));
- sain->sin_len = sizeof(*sain);
- sain->sin_family = na->family;
- sain->sin_port = na->port;
- sain->sin_addr.s_addr = na->addr;
- DPRINTF(("netaddr -> sockaddr_in %d %d %x\n", sain->sin_family,
- sain->sin_port, sain->sin_addr.s_addr));
-}
-
-
-static void
-netaddr_to_sockaddr_un(saun, sc)
- struct sockaddr_un *saun;
- const struct svr4_strmcmd *sc;
-{
- const struct svr4_netaddr_un *na;
- char *dst, *edst = &saun->sun_path[sizeof(saun->sun_path) - 1];
- const char *src;
-
- na = SVR4_C_ADDROF(sc);
- memset(saun, 0, sizeof(*saun));
- saun->sun_family = na->family;
- for (src = na->path, dst = saun->sun_path; (*dst++ = *src++) != '\0'; )
- if (dst == edst)
- break;
- saun->sun_len = dst - saun->sun_path;
- DPRINTF(("netaddr -> sockaddr_un %d %s\n", saun->sun_family,
- saun->sun_path));
-}
-
-
-static void
-getparm(fp, pa)
- struct file *fp;
- struct svr4_si_sockparms *pa;
-{
- struct svr4_strm *st = svr4_stream_get(fp);
- struct socket *so = (struct socket *) fp->f_data;
-
- if (st == NULL)
- return;
-
- pa->family = st->s_family;
-
- switch (so->so_type) {
- case SOCK_DGRAM:
- pa->type = SVR4_T_CLTS;
- pa->protocol = IPPROTO_UDP;
- DPRINTF(("getparm(dgram)\n"));
- return;
-
- case SOCK_STREAM:
- pa->type = SVR4_T_COTS; /* What about T_COTS_ORD? XXX */
- pa->protocol = IPPROTO_IP;
- DPRINTF(("getparm(stream)\n"));
- return;
-
- case SOCK_RAW:
- pa->type = SVR4_T_CLTS;
- pa->protocol = IPPROTO_RAW;
- DPRINTF(("getparm(raw)\n"));
- return;
-
- default:
- pa->type = 0;
- pa->protocol = 0;
- DPRINTF(("getparm(type %d?)\n", so->so_type));
- return;
- }
-}
-
-
-static int
-si_ogetudata(fp, fd, ioc, p)
- struct file *fp;
- int fd;
- struct svr4_strioctl *ioc;
- struct proc *p;
-{
- int error;
- struct svr4_si_oudata ud;
- struct svr4_si_sockparms pa;
-
- if (ioc->len != sizeof(ud) && ioc->len != sizeof(ud) - sizeof(int)) {
- DPRINTF(("SI_OGETUDATA: Wrong size %d != %d\n",
- sizeof(ud), ioc->len));
- return EINVAL;
- }
-
- if ((error = copyin(ioc->buf, &ud, sizeof(ud))) != 0)
- return error;
-
- getparm(fp, &pa);
-
- switch (pa.family) {
- case AF_INET:
- ud.tidusize = 16384;
- ud.addrsize = sizeof(struct svr4_sockaddr_in);
- if (pa.type == SVR4_SOCK_STREAM)
- ud.etsdusize = 1;
- else
- ud.etsdusize = 0;
- break;
-
- case AF_LOCAL:
- ud.tidusize = 65536;
- ud.addrsize = 128;
- ud.etsdusize = 128;
- break;
-
- default:
- DPRINTF(("SI_OGETUDATA: Unsupported address family %d\n",
- pa.family));
- return ENOSYS;
- }
-
- /* I have no idea what these should be! */
- ud.optsize = 128;
- ud.tsdusize = 128;
-
- ud.servtype = pa.type;
-
- /* XXX: Fixme */
- ud.so_state = 0;
- ud.so_options = 0;
- return copyout(&ud, ioc->buf, ioc->len);
-}
-
-
-static int
-si_sockparams(fp, fd, ioc, p)
- struct file *fp;
- int fd;
- struct svr4_strioctl *ioc;
- struct proc *p;
-{
- struct svr4_si_sockparms pa;
-
- getparm(fp, &pa);
- return copyout(&pa, ioc->buf, sizeof(pa));
-}
-
-
-static int
-si_listen(fp, fd, ioc, p)
- struct file *fp;
- int fd;
- struct svr4_strioctl *ioc;
- struct proc *p;
-{
- int error;
- struct svr4_strm *st = svr4_stream_get(fp);
- struct svr4_strmcmd lst;
- struct listen_args la;
-
- if (st == NULL)
- return EINVAL;
-
- if ((error = copyin(ioc->buf, &lst, ioc->len)) != 0)
- return error;
-
- if (lst.cmd != SVR4_TI_OLD_BIND_REQUEST) {
- DPRINTF(("si_listen: bad request %ld\n", lst.cmd));
- return EINVAL;
- }
-
- /*
- * We are making assumptions again...
- */
- SCARG(&la, s) = fd;
- DPRINTF(("SI_LISTEN: fileno %d backlog = %d\n", fd, 5));
- SCARG(&la, backlog) = 5;
-
- if ((error = listen(p, &la)) != 0) {
- DPRINTF(("SI_LISTEN: listen failed %d\n", error));
- return error;
- }
-
- st->s_cmd = SVR4_TI__ACCEPT_WAIT;
- lst.cmd = SVR4_TI_BIND_REPLY;
-
- switch (st->s_family) {
- case AF_INET:
- /* XXX: Fill the length here */
- break;
-
- case AF_LOCAL:
- lst.len = 140;
- lst.pad[28] = 0x00000000; /* magic again */
- lst.pad[29] = 0x00000800; /* magic again */
- lst.pad[30] = 0x80001400; /* magic again */
- break;
-
- default:
- DPRINTF(("SI_LISTEN: Unsupported address family %d\n",
- st->s_family));
- return ENOSYS;
- }
-
-
- if ((error = copyout(&lst, ioc->buf, ioc->len)) != 0)
- return error;
-
- return 0;
-}
-
-
-static int
-si_getudata(fp, fd, ioc, p)
- struct file *fp;
- int fd;
- struct svr4_strioctl *ioc;
- struct proc *p;
-{
- int error;
- struct svr4_si_udata ud;
-
- if (sizeof(ud) != ioc->len) {
- DPRINTF(("SI_GETUDATA: Wrong size %d != %d\n",
- sizeof(ud), ioc->len));
- return EINVAL;
- }
-
- if ((error = copyin(ioc->buf, &ud, sizeof(ud))) != 0)
- return error;
-
- getparm(fp, &ud.sockparms);
-
- switch (ud.sockparms.family) {
- case AF_INET:
- DPRINTF(("getudata_inet\n"));
- ud.tidusize = 16384;
- ud.tsdusize = 16384;
- ud.addrsize = sizeof(struct svr4_sockaddr_in);
- if (ud.sockparms.type == SVR4_SOCK_STREAM)
- ud.etsdusize = 1;
- else
- ud.etsdusize = 0;
- ud.optsize = 0;
- break;
-
- case AF_LOCAL:
- DPRINTF(("getudata_local\n"));
- ud.tidusize = 65536;
- ud.tsdusize = 128;
- ud.addrsize = 128;
- ud.etsdusize = 128;
- ud.optsize = 128;
- break;
-
- default:
- DPRINTF(("SI_GETUDATA: Unsupported address family %d\n",
- ud.sockparms.family));
- return ENOSYS;
- }
-
-
- ud.servtype = ud.sockparms.type;
- DPRINTF(("ud.servtype = %d\n", ud.servtype));
- /* XXX: Fixme */
- ud.so_state = 0;
- ud.so_options = 0;
- return copyout(&ud, ioc->buf, sizeof(ud));
-}
-
-
-static int
-si_shutdown(fp, fd, ioc, p)
- struct file *fp;
- int fd;
- struct svr4_strioctl *ioc;
- struct proc *p;
-{
- int error;
- struct shutdown_args ap;
-
- if (ioc->len != sizeof(SCARG(&ap, how))) {
- DPRINTF(("SI_SHUTDOWN: Wrong size %d != %d\n",
- sizeof(SCARG(&ap, how)), ioc->len));
- return EINVAL;
- }
-
- if ((error = copyin(ioc->buf, &SCARG(&ap, how), ioc->len)) != 0)
- return error;
-
- SCARG(&ap, s) = fd;
-
- return shutdown(p, &ap);
-}
-
-
-static int
-sockmod(fp, fd, ioc, p)
- struct file *fp;
- int fd;
- struct svr4_strioctl *ioc;
- struct proc *p;
-{
- switch (ioc->cmd) {
- case SVR4_SI_OGETUDATA:
- DPRINTF(("SI_OGETUDATA\n"));
- return si_ogetudata(fp, fd, ioc, p);
-
- case SVR4_SI_SHUTDOWN:
- DPRINTF(("SI_SHUTDOWN\n"));
- return si_shutdown(fp, fd, ioc, p);
-
- case SVR4_SI_LISTEN:
- DPRINTF(("SI_LISTEN\n"));
- return si_listen(fp, fd, ioc, p);
-
- case SVR4_SI_SETMYNAME:
- DPRINTF(("SI_SETMYNAME\n"));
- return 0;
-
- case SVR4_SI_SETPEERNAME:
- DPRINTF(("SI_SETPEERNAME\n"));
- return 0;
-
- case SVR4_SI_GETINTRANSIT:
- DPRINTF(("SI_GETINTRANSIT\n"));
- return 0;
-
- case SVR4_SI_TCL_LINK:
- DPRINTF(("SI_TCL_LINK\n"));
- return 0;
-
- case SVR4_SI_TCL_UNLINK:
- DPRINTF(("SI_TCL_UNLINK\n"));
- return 0;
-
- case SVR4_SI_SOCKPARAMS:
- DPRINTF(("SI_SOCKPARAMS\n"));
- return si_sockparams(fp, fd, ioc, p);
-
- case SVR4_SI_GETUDATA:
- DPRINTF(("SI_GETUDATA\n"));
- return si_getudata(fp, fd, ioc, p);
-
- default:
- DPRINTF(("Unknown sockmod ioctl %lx\n", ioc->cmd));
- return 0;
-
- }
-}
-
-
-static int
-ti_getinfo(fp, fd, ioc, p)
- struct file *fp;
- int fd;
- struct svr4_strioctl *ioc;
- struct proc *p;
-{
- int error;
- struct svr4_infocmd info;
-
- memset(&info, 0, sizeof(info));
-
- if ((error = copyin(ioc->buf, &info, ioc->len)) != 0)
- return error;
-
- if (info.cmd != SVR4_TI_INFO_REQUEST)
- return EINVAL;
-
- info.cmd = SVR4_TI_INFO_REPLY;
- info.tsdu = 0;
- info.etsdu = 1;
- info.cdata = -2;
- info.ddata = -2;
- info.addr = 16;
- info.opt = -1;
- info.tidu = 16384;
- info.serv = 2;
- info.current = 0;
- info.provider = 2;
-
- ioc->len = sizeof(info);
- if ((error = copyout(&info, ioc->buf, ioc->len)) != 0)
- return error;
-
- return 0;
-}
-
-
-static int
-ti_bind(fp, fd, ioc, p)
- struct file *fp;
- int fd;
- struct svr4_strioctl *ioc;
- struct proc *p;
-{
- int error;
- struct svr4_strm *st = svr4_stream_get(fp);
- struct sockaddr_in sain;
- struct sockaddr_un saun;
- caddr_t sg;
- void *skp, *sup = NULL;
- int sasize;
- struct svr4_strmcmd bnd;
- struct bind_args ba;
-
- if (st == NULL) {
- DPRINTF(("ti_bind: bad file descriptor\n"));
- return EINVAL;
- }
-
- if ((error = copyin(ioc->buf, &bnd, ioc->len)) != 0)
- return error;
-
- if (bnd.cmd != SVR4_TI_OLD_BIND_REQUEST) {
- DPRINTF(("ti_bind: bad request %ld\n", bnd.cmd));
- return EINVAL;
- }
-
- switch (st->s_family) {
- case AF_INET:
- skp = &sain;
- sasize = sizeof(sain);
-
- if (bnd.offs == 0)
- goto reply;
-
- netaddr_to_sockaddr_in(&sain, &bnd);
-
- DPRINTF(("TI_BIND: fam %d, port %d, addr %x\n",
- sain.sin_family, sain.sin_port,
- sain.sin_addr.s_addr));
- break;
-
- case AF_LOCAL:
- skp = &saun;
- sasize = sizeof(saun);
- if (bnd.offs == 0)
- goto reply;
-
- netaddr_to_sockaddr_un(&saun, &bnd);
-
- if (saun.sun_path[0] == '\0')
- goto reply;
-
- DPRINTF(("TI_BIND: fam %d, path %s\n",
- saun.sun_family, saun.sun_path));
-
- if ((error = clean_pipe(p, saun.sun_path)) != 0)
- return error;
-
- bnd.pad[28] = 0x00001000; /* magic again */
- break;
-
- default:
- DPRINTF(("TI_BIND: Unsupported address family %d\n",
- st->s_family));
- return ENOSYS;
- }
-
- sg = stackgap_init();
- sup = stackgap_alloc(&sg, sasize);
-
- if ((error = copyout(skp, sup, sasize)) != 0)
- return error;
-
- SCARG(&ba, s) = fd;
- DPRINTF(("TI_BIND: fileno %d\n", fd));
- SCARG(&ba, name) = (void *) sup;
- SCARG(&ba, namelen) = sasize;
-
- if ((error = bind(p, &ba)) != 0) {
- DPRINTF(("TI_BIND: bind failed %d\n", error));
- return error;
- }
-
-reply:
- if (sup == NULL) {
- memset(&bnd, 0, sizeof(bnd));
- bnd.len = sasize + 4;
- bnd.offs = 0x10; /* XXX */
- }
-
- bnd.cmd = SVR4_TI_BIND_REPLY;
-
- if ((error = copyout(&bnd, ioc->buf, ioc->len)) != 0)
- return error;
-
- return 0;
-}
-
-
-static int
-timod(fp, fd, ioc, p)
- struct file *fp;
- int fd;
- struct svr4_strioctl *ioc;
- struct proc *p;
-{
- switch (ioc->cmd) {
- case SVR4_TI_GETINFO:
- DPRINTF(("TI_GETINFO\n"));
- return ti_getinfo(fp, fd, ioc, p);
-
- case SVR4_TI_OPTMGMT:
- DPRINTF(("TI_OPTMGMT\n"));
- return 0;
-
- case SVR4_TI_BIND:
- DPRINTF(("TI_BIND\n"));
- return ti_bind(fp, fd, ioc, p);
-
- case SVR4_TI_UNBIND:
- DPRINTF(("TI_UNBIND\n"));
- return 0;
-
- default:
- DPRINTF(("Unknown timod ioctl %lx\n", ioc->cmd));
- return 0;
- }
-}
-
-
-int
-svr4_stream_ti_ioctl(fp, p, retval, fd, cmd, dat)
- struct file *fp;
- struct proc *p;
- register_t *retval;
- int fd;
- u_long cmd;
- caddr_t dat;
-{
- struct svr4_strbuf skb, *sub = (struct svr4_strbuf *) dat;
- struct svr4_strm *st = svr4_stream_get(fp);
- int error;
- void *skp, *sup;
- struct sockaddr_in sain;
- struct sockaddr_un saun;
- struct svr4_strmcmd sc;
- int sasize;
- caddr_t sg;
- int *lenp;
-
- DPRINTF(("svr4_stream_ti_ioctl\n"));
-
- if (st == NULL)
- return EINVAL;
-
- sc.offs = 0x10;
-
- if ((error = copyin(sub, &skb, sizeof(skb))) != 0) {
- DPRINTF(("ti_ioctl: error copying in strbuf\n"));
- return error;
- }
-
- switch (st->s_family) {
- case AF_INET:
- skp = &sain;
- sasize = sizeof(sain);
- break;
-
- case AF_LOCAL:
- skp = &saun;
- sasize = sizeof(saun);
- break;
-
- default:
- DPRINTF(("ti_ioctl: Unsupported address family %d\n",
- st->s_family));
- return ENOSYS;
- }
-
- sg = stackgap_init();
- sup = stackgap_alloc(&sg, sasize);
- lenp = stackgap_alloc(&sg, sizeof(*lenp));
-
- if ((error = copyout(&sasize, lenp, sizeof(*lenp))) != 0) {
- DPRINTF(("ti_ioctl: error copying out lenp\n"));
- return error;
- }
-
- switch (cmd) {
- case SVR4_TI_GETMYNAME:
- DPRINTF(("TI_GETMYNAME\n"));
- {
- struct getsockname_args ap;
- SCARG(&ap, fdes) = fd;
- SCARG(&ap, asa) = sup;
- SCARG(&ap, alen) = lenp;
- if ((error = getsockname(p, &ap)) != 0) {
- DPRINTF(("ti_ioctl: getsockname error\n"));
- return error;
- }
- }
- break;
-
- case SVR4_TI_GETPEERNAME:
- DPRINTF(("TI_GETPEERNAME\n"));
- {
- struct getpeername_args ap;
- SCARG(&ap, fdes) = fd;
- SCARG(&ap, asa) = sup;
- SCARG(&ap, alen) = lenp;
- if ((error = getpeername(p, &ap)) != 0) {
- DPRINTF(("ti_ioctl: getpeername error\n"));
- return error;
- }
- }
- break;
-
- case SVR4_TI_SETMYNAME:
- DPRINTF(("TI_SETMYNAME\n"));
- return 0;
-
- case SVR4_TI_SETPEERNAME:
- DPRINTF(("TI_SETPEERNAME\n"));
- return 0;
- default:
- DPRINTF(("ti_ioctl: Unknown ioctl %lx\n", cmd));
- return ENOSYS;
- }
-
- if ((error = copyin(sup, skp, sasize)) != 0) {
- DPRINTF(("ti_ioctl: error copying in socket data\n"));
- return error;
- }
-
- if ((error = copyin(lenp, &sasize, sizeof(*lenp))) != 0) {
- DPRINTF(("ti_ioctl: error copying in socket size\n"));
- return error;
- }
-
- switch (st->s_family) {
- case AF_INET:
- sockaddr_to_netaddr_in(&sc, &sain);
- skb.len = sasize;
- break;
-
- case AF_LOCAL:
- sockaddr_to_netaddr_un(&sc, &saun);
- skb.len = sasize + 4;
- break;
-
- default:
- return ENOSYS;
- }
-
-
- if ((error = copyout(SVR4_ADDROF(&sc), skb.buf, sasize)) != 0) {
- DPRINTF(("ti_ioctl: error copying out socket data\n"));
- return error;
- }
-
-
- if ((error = copyout(&skb, sub, sizeof(skb))) != 0) {
- DPRINTF(("ti_ioctl: error copying out strbuf\n"));
- return error;
- }
-
- return error;
-}
-
-
-
-
-static int
-i_nread(fp, p, retval, fd, cmd, dat)
- struct file *fp;
- struct proc *p;
- register_t *retval;
- int fd;
- u_long cmd;
- caddr_t dat;
-{
- int error;
- int nread = 0;
-
- /*
- * We are supposed to return the message length in nread, and the
- * number of messages in retval. We don't have the notion of number
- * of stream messages, so we just find out if we have any bytes waiting
- * for us, and if we do, then we assume that we have at least one
- * message waiting for us.
- */
- if ((error = fo_ioctl(fp, FIONREAD, (caddr_t) &nread, p)) != 0)
- return error;
-
- if (nread != 0)
- *retval = 1;
- else
- *retval = 0;
-
- return copyout(&nread, dat, sizeof(nread));
-}
-
-static int
-i_fdinsert(fp, p, retval, fd, cmd, dat)
- struct file *fp;
- struct proc *p;
- register_t *retval;
- int fd;
- u_long cmd;
- caddr_t dat;
-{
- /*
- * Major hack again here. We assume that we are using this to
- * implement accept(2). If that is the case, we have already
- * called accept, and we have stored the file descriptor in
- * afd. We find the file descriptor that the code wants to use
- * in fd insert, and then we dup2() our accepted file descriptor
- * to it.
- */
- int error;
- struct svr4_strm *st = svr4_stream_get(fp);
- struct svr4_strfdinsert fdi;
- struct dup2_args d2p;
- struct close_args clp;
-
- if (st == NULL) {
- DPRINTF(("fdinsert: bad file type\n"));
- return EINVAL;
- }
-
- if (st->s_afd == -1) {
- DPRINTF(("fdinsert: accept fd not found\n"));
- return ENOENT;
- }
-
- if ((error = copyin(dat, &fdi, sizeof(fdi))) != 0) {
- DPRINTF(("fdinsert: copyin failed %d\n", error));
- return error;
- }
-
- SCARG(&d2p, from) = st->s_afd;
- SCARG(&d2p, to) = fdi.fd;
-
- if ((error = dup2(p, &d2p)) != 0) {
- DPRINTF(("fdinsert: dup2(%d, %d) failed %d\n",
- st->s_afd, fdi.fd, error));
- return error;
- }
-
- SCARG(&clp, fd) = st->s_afd;
-
- if ((error = close(p, &clp)) != 0) {
- DPRINTF(("fdinsert: close(%d) failed %d\n",
- st->s_afd, error));
- return error;
- }
-
- st->s_afd = -1;
-
- *retval = 0;
- return 0;
-}
-
-
-static int
-_i_bind_rsvd(fp, p, retval, fd, cmd, dat)
- struct file *fp;
- struct proc *p;
- register_t *retval;
- int fd;
- u_long cmd;
- caddr_t dat;
-{
- struct mkfifo_args ap;
-
- /*
- * This is a supposed to be a kernel and library only ioctl.
- * It gets called before ti_bind, when we have a unix
- * socket, to physically create the socket transport and
- * ``reserve'' it. I don't know how this get reserved inside
- * the kernel, but we are going to create it nevertheless.
- */
- SCARG(&ap, path) = dat;
- SCARG(&ap, mode) = S_IFIFO;
-
- return mkfifo(p, &ap);
-}
-
-static int
-_i_rele_rsvd(fp, p, retval, fd, cmd, dat)
- struct file *fp;
- struct proc *p;
- register_t *retval;
- int fd;
- u_long cmd;
- caddr_t dat;
-{
- struct unlink_args ap;
-
- /*
- * This is a supposed to be a kernel and library only ioctl.
- * I guess it is supposed to release the socket.
- */
- SCARG(&ap, path) = dat;
-
- return unlink(p, &ap);
-}
-
-static int
-i_str(fp, p, retval, fd, cmd, dat)
- struct file *fp;
- struct proc *p;
- register_t *retval;
- int fd;
- u_long cmd;
- caddr_t dat;
-{
- int error;
- struct svr4_strioctl ioc;
-
- if ((error = copyin(dat, &ioc, sizeof(ioc))) != 0)
- return error;
-
-#ifdef DEBUG_SVR4
- if ((error = show_ioc(">", &ioc)) != 0)
- return error;
-#endif /* DEBUG_SVR4 */
-
- switch (ioc.cmd & 0xff00) {
- case SVR4_SIMOD:
- if ((error = sockmod(fp, fd, &ioc, p)) != 0)
- return error;
- break;
-
- case SVR4_TIMOD:
- if ((error = timod(fp, fd, &ioc, p)) != 0)
- return error;
- break;
-
- default:
- DPRINTF(("Unimplemented module %c %ld\n",
- (char) (cmd >> 8), cmd & 0xff));
- return 0;
- }
-
-#ifdef DEBUG_SVR4
- if ((error = show_ioc("<", &ioc)) != 0)
- return error;
-#endif /* DEBUG_SVR4 */
- return copyout(&ioc, dat, sizeof(ioc));
-}
-
-static int
-i_setsig(fp, p, retval, fd, cmd, dat)
- struct file *fp;
- struct proc *p;
- register_t *retval;
- int fd;
- u_long cmd;
- caddr_t dat;
-{
- /*
- * This is the best we can do for now; we cannot generate
- * signals only for specific events so the signal mask gets
- * ignored; we save it just to pass it to a possible I_GETSIG...
- *
- * We alse have to fix the O_ASYNC fcntl bit, so the
- * process will get SIGPOLLs.
- */
- struct fcntl_args fa;
- int error;
- register_t oflags, flags;
- struct svr4_strm *st = svr4_stream_get(fp);
-
- if (st == NULL) {
- DPRINTF(("i_setsig: bad file descriptor\n"));
- return EINVAL;
- }
- /* get old status flags */
- SCARG(&fa, fd) = fd;
- SCARG(&fa, cmd) = F_GETFL;
- if ((error = fcntl(p, &fa)) != 0)
- return error;
-
- oflags = p->p_retval[0];
-
- /* update the flags */
- if (dat != NULL) {
- int mask;
-
- flags = oflags | O_ASYNC;
- if ((error = copyin(dat, &mask, sizeof(mask))) != 0) {
- DPRINTF(("i_setsig: bad eventmask pointer\n"));
- return error;
- }
- if (mask & SVR4_S_ALLMASK) {
- DPRINTF(("i_setsig: bad eventmask data %x\n", mask));
- return EINVAL;
- }
- st->s_eventmask = mask;
- }
- else {
- flags = oflags & ~O_ASYNC;
- st->s_eventmask = 0;
- }
-
- /* set the new flags, if changed */
- if (flags != oflags) {
- SCARG(&fa, cmd) = F_SETFL;
- SCARG(&fa, arg) = (long) flags;
- if ((error = fcntl(p, &fa)) != 0)
- return error;
- flags = p->p_retval[0];
- }
-
- /* set up SIGIO receiver if needed */
- if (dat != NULL) {
- SCARG(&fa, cmd) = F_SETOWN;
- SCARG(&fa, arg) = (long) p->p_pid;
- return fcntl(p, &fa);
- }
- return 0;
-}
-
-static int
-i_getsig(fp, p, retval, fd, cmd, dat)
- struct file *fp;
- struct proc *p;
- register_t *retval;
- int fd;
- u_long cmd;
- caddr_t dat;
-{
- int error;
-
- if (dat != NULL) {
- struct svr4_strm *st = svr4_stream_get(fp);
-
- if (st == NULL) {
- DPRINTF(("i_getsig: bad file descriptor\n"));
- return EINVAL;
- }
- if ((error = copyout(&st->s_eventmask, dat,
- sizeof(st->s_eventmask))) != 0) {
- DPRINTF(("i_getsig: bad eventmask pointer\n"));
- return error;
- }
- }
- return 0;
-}
-
-int
-svr4_stream_ioctl(fp, p, retval, fd, cmd, dat)
- struct file *fp;
- struct proc *p;
- register_t *retval;
- int fd;
- u_long cmd;
- caddr_t dat;
-{
- *retval = 0;
-
- /*
- * All the following stuff assumes "sockmod" is pushed...
- */
- switch (cmd) {
- case SVR4_I_NREAD:
- DPRINTF(("I_NREAD\n"));
- return i_nread(fp, p, retval, fd, cmd, dat);
-
- case SVR4_I_PUSH:
- DPRINTF(("I_PUSH %x\n", dat));
-#if defined(DEBUG_SVR4)
- show_strbuf(dat);
-#endif
- return 0;
-
- case SVR4_I_POP:
- DPRINTF(("I_POP\n"));
- return 0;
-
- case SVR4_I_LOOK:
- DPRINTF(("I_LOOK\n"));
- return 0;
-
- case SVR4_I_FLUSH:
- DPRINTF(("I_FLUSH\n"));
- return 0;
-
- case SVR4_I_SRDOPT:
- DPRINTF(("I_SRDOPT\n"));
- return 0;
-
- case SVR4_I_GRDOPT:
- DPRINTF(("I_GRDOPT\n"));
- return 0;
-
- case SVR4_I_STR:
- DPRINTF(("I_STR\n"));
- return i_str(fp, p, retval, fd, cmd, dat);
-
- case SVR4_I_SETSIG:
- DPRINTF(("I_SETSIG\n"));
- return i_setsig(fp, p, retval, fd, cmd, dat);
-
- case SVR4_I_GETSIG:
- DPRINTF(("I_GETSIG\n"));
- return i_getsig(fp, p, retval, fd, cmd, dat);
-
- case SVR4_I_FIND:
- DPRINTF(("I_FIND\n"));
- /*
- * Here we are not pushing modules really, we just
- * pretend all are present
- */
- *retval = 0;
- return 0;
-
- case SVR4_I_LINK:
- DPRINTF(("I_LINK\n"));
- return 0;
-
- case SVR4_I_UNLINK:
- DPRINTF(("I_UNLINK\n"));
- return 0;
-
- case SVR4_I_ERECVFD:
- DPRINTF(("I_ERECVFD\n"));
- return 0;
-
- case SVR4_I_PEEK:
- DPRINTF(("I_PEEK\n"));
- return 0;
-
- case SVR4_I_FDINSERT:
- DPRINTF(("I_FDINSERT\n"));
- return i_fdinsert(fp, p, retval, fd, cmd, dat);
-
- case SVR4_I_SENDFD:
- DPRINTF(("I_SENDFD\n"));
- return 0;
-
- case SVR4_I_RECVFD:
- DPRINTF(("I_RECVFD\n"));
- return 0;
-
- case SVR4_I_SWROPT:
- DPRINTF(("I_SWROPT\n"));
- return 0;
-
- case SVR4_I_GWROPT:
- DPRINTF(("I_GWROPT\n"));
- return 0;
-
- case SVR4_I_LIST:
- DPRINTF(("I_LIST\n"));
- return 0;
-
- case SVR4_I_PLINK:
- DPRINTF(("I_PLINK\n"));
- return 0;
-
- case SVR4_I_PUNLINK:
- DPRINTF(("I_PUNLINK\n"));
- return 0;
-
- case SVR4_I_SETEV:
- DPRINTF(("I_SETEV\n"));
- return 0;
-
- case SVR4_I_GETEV:
- DPRINTF(("I_GETEV\n"));
- return 0;
-
- case SVR4_I_STREV:
- DPRINTF(("I_STREV\n"));
- return 0;
-
- case SVR4_I_UNSTREV:
- DPRINTF(("I_UNSTREV\n"));
- return 0;
-
- case SVR4_I_FLUSHBAND:
- DPRINTF(("I_FLUSHBAND\n"));
- return 0;
-
- case SVR4_I_CKBAND:
- DPRINTF(("I_CKBAND\n"));
- return 0;
-
- case SVR4_I_GETBAND:
- DPRINTF(("I_GETBANK\n"));
- return 0;
-
- case SVR4_I_ATMARK:
- DPRINTF(("I_ATMARK\n"));
- return 0;
-
- case SVR4_I_SETCLTIME:
- DPRINTF(("I_SETCLTIME\n"));
- return 0;
-
- case SVR4_I_GETCLTIME:
- DPRINTF(("I_GETCLTIME\n"));
- return 0;
-
- case SVR4_I_CANPUT:
- DPRINTF(("I_CANPUT\n"));
- return 0;
-
- case SVR4__I_BIND_RSVD:
- DPRINTF(("_I_BIND_RSVD\n"));
- return _i_bind_rsvd(fp, p, retval, fd, cmd, dat);
-
- case SVR4__I_RELE_RSVD:
- DPRINTF(("_I_RELE_RSVD\n"));
- return _i_rele_rsvd(fp, p, retval, fd, cmd, dat);
-
- default:
- DPRINTF(("unimpl cmd = %lx\n", cmd));
- break;
- }
-
- return 0;
-}
-
-
-
-int
-svr4_sys_putmsg(p, uap)
- register struct proc *p;
- struct svr4_sys_putmsg_args *uap;
-{
- struct filedesc *fdp = p->p_fd;
- struct file *fp;
- struct svr4_strbuf dat, ctl;
- struct svr4_strmcmd sc;
- struct sockaddr_in sain;
- struct sockaddr_un saun;
- void *skp, *sup;
- int sasize, *retval;
- struct svr4_strm *st;
- int error;
- caddr_t sg;
-
- retval = p->p_retval;
- fp = fdp->fd_ofiles[SCARG(uap, fd)];
-
- if (((u_int)SCARG(uap, fd) >= fdp->fd_nfiles) || (fp == NULL)) {
-#ifdef DEBUG_SVR4
- uprintf("putmsg: bad fp\n");
-#endif
- return EBADF;
- }
-
-#ifdef DEBUG_SVR4
- show_msg(">putmsg", SCARG(uap, fd), SCARG(uap, ctl),
- SCARG(uap, dat), SCARG(uap, flags));
-#endif /* DEBUG_SVR4 */
-
- if (((u_int)SCARG(uap, fd) >= fdp->fd_nfiles) || (fp == NULL)) {
-#ifdef DEBUG_SVR4
- uprintf("putmsg: bad fp(2)\n");
-#endif
- return EBADF;
- }
-
- if (SCARG(uap, ctl) != NULL) {
- if ((error = copyin(SCARG(uap, ctl), &ctl, sizeof(ctl))) != 0) {
-#ifdef DEBUG_SVR4
- uprintf("putmsg: copyin(): %d\n", error);
-#endif
- return error;
- }
- }
- else
- ctl.len = -1;
-
- if (SCARG(uap, dat) != NULL) {
- if ((error = copyin(SCARG(uap, dat), &dat, sizeof(dat))) != 0) {
-#ifdef DEBUG_SVR4
- uprintf("putmsg: copyin(): %d (2)\n", error);
-#endif
- return error;
- }
- }
- else
- dat.len = -1;
-
- /*
- * Only for sockets for now.
- */
- if ((st = svr4_stream_get(fp)) == NULL) {
- DPRINTF(("putmsg: bad file type\n"));
- return EINVAL;
- }
-
- if (ctl.len > sizeof(sc)) {
- DPRINTF(("putmsg: Bad control size %d != %d\n", ctl.len,
- sizeof(struct svr4_strmcmd)));
- return EINVAL;
- }
-
- if ((error = copyin(ctl.buf, &sc, ctl.len)) != 0)
- return error;
-
- switch (st->s_family) {
- case AF_INET:
- if (sc.len != sizeof(sain)) {
- if (sc.cmd == SVR4_TI_DATA_REQUEST) {
- struct write_args wa;
-
- /* Solaris seems to use sc.cmd = 3 to
- * send "expedited" data. telnet uses
- * this for options processing, sending EOF,
- * etc. I'm sure other things use it too.
- * I don't have any documentation
- * on it, so I'm making a guess that this
- * is how it works. newton@atdot.dotat.org XXX
- */
- DPRINTF(("sending expedited data ??\n"));
- SCARG(&wa, fd) = SCARG(uap, fd);
- SCARG(&wa, buf) = dat.buf;
- SCARG(&wa, nbyte) = dat.len;
- return write(p, &wa);
- }
- DPRINTF(("putmsg: Invalid inet length %ld\n", sc.len));
- return EINVAL;
- }
- netaddr_to_sockaddr_in(&sain, &sc);
- skp = &sain;
- sasize = sizeof(sain);
- error = sain.sin_family != st->s_family;
- break;
-
- case AF_LOCAL:
- if (ctl.len == 8) {
- /* We are doing an accept; succeed */
- DPRINTF(("putmsg: Do nothing\n"));
- *retval = 0;
- return 0;
- }
- else {
- /* Maybe we've been given a device/inode pair */
- udev_t *dev = SVR4_ADDROF(&sc);
- ino_t *ino = (ino_t *) &dev[1];
- skp = svr4_find_socket(p, fp, *dev, *ino);
- if (skp == NULL) {
- skp = &saun;
- /* I guess we have it by name */
- netaddr_to_sockaddr_un(skp, &sc);
- }
- sasize = sizeof(saun);
- }
- break;
-
- default:
- DPRINTF(("putmsg: Unsupported address family %d\n",
- st->s_family));
- return ENOSYS;
- }
-
- sg = stackgap_init();
- sup = stackgap_alloc(&sg, sasize);
-
- if ((error = copyout(skp, sup, sasize)) != 0)
- return error;
-
- switch (st->s_cmd = sc.cmd) {
- case SVR4_TI_CONNECT_REQUEST: /* connect */
- {
- struct connect_args co;
-
- SCARG(&co, s) = SCARG(uap, fd);
- SCARG(&co, name) = (void *) sup;
- SCARG(&co, namelen) = (int) sasize;
-
- return connect(p, &co);
- }
-
- case SVR4_TI_SENDTO_REQUEST: /* sendto */
- {
- struct msghdr msg;
- struct iovec aiov;
-
- msg.msg_name = (caddr_t) sup;
- msg.msg_namelen = sasize;
- msg.msg_iov = &aiov;
- msg.msg_iovlen = 1;
- msg.msg_control = 0;
- msg.msg_flags = 0;
- aiov.iov_base = dat.buf;
- aiov.iov_len = dat.len;
-#if 0
- error = so->so_proto->pr_usrreqs->pru_sosend(so, 0,
- uio, 0, 0, 0, uio->uio_procp);
-#endif
- error = svr4_sendit(p, SCARG(uap, fd), &msg,
- SCARG(uap, flags));
- DPRINTF(("sendto_request error: %d\n", error));
- *retval = 0;
- return error;
- }
-
- default:
- DPRINTF(("putmsg: Unimplemented command %lx\n", sc.cmd));
- return ENOSYS;
- }
-}
-
-int
-svr4_sys_getmsg(p, uap)
- register struct proc *p;
- struct svr4_sys_getmsg_args *uap;
-{
- struct filedesc *fdp = p->p_fd;
- struct file *fp;
- struct getpeername_args ga;
- struct accept_args aa;
- struct svr4_strbuf dat, ctl;
- struct svr4_strmcmd sc;
- int error, *retval;
- struct msghdr msg;
- struct iovec aiov;
- struct sockaddr_in sain;
- struct sockaddr_un saun;
- void *skp, *sup;
- int sasize;
- struct svr4_strm *st;
- int *flen;
- int fl;
- caddr_t sg;
-
- retval = p->p_retval;
- fp = fdp->fd_ofiles[SCARG(uap, fd)];
-
- if (((u_int)SCARG(uap, fd) >= fdp->fd_nfiles) || (fp == NULL))
- return EBADF;
-
- memset(&sc, 0, sizeof(sc));
-
-#ifdef DEBUG_SVR4
- show_msg(">getmsg", SCARG(uap, fd), SCARG(uap, ctl),
- SCARG(uap, dat), 0);
-#endif /* DEBUG_SVR4 */
-
- if (((u_int)SCARG(uap, fd) >= fdp->fd_nfiles) || (fp == NULL))
- return EBADF;
-
- if (SCARG(uap, ctl) != NULL) {
- if ((error = copyin(SCARG(uap, ctl), &ctl, sizeof(ctl))) != 0)
- return error;
- }
- else {
- ctl.len = -1;
- ctl.maxlen = 0;
- }
-
- if (SCARG(uap, dat) != NULL) {
- if ((error = copyin(SCARG(uap, dat), &dat, sizeof(dat))) != 0)
- return error;
- }
- else {
- dat.len = -1;
- dat.maxlen = 0;
- }
-
- /*
- * Only for sockets for now.
- */
- if ((st = svr4_stream_get(fp)) == NULL) {
- DPRINTF(("getmsg: bad file type\n"));
- return EINVAL;
- }
-
- if (ctl.maxlen == -1 || dat.maxlen == -1) {
- DPRINTF(("getmsg: Cannot handle -1 maxlen (yet)\n"));
- return ENOSYS;
- }
-
- switch (st->s_family) {
- case AF_INET:
- skp = &sain;
- sasize = sizeof(sain);
- break;
-
- case AF_LOCAL:
- skp = &saun;
- sasize = sizeof(saun);
- break;
-
- default:
- DPRINTF(("getmsg: Unsupported address family %d\n",
- st->s_family));
- return ENOSYS;
- }
-
- sg = stackgap_init();
- sup = stackgap_alloc(&sg, sasize);
- flen = (int *) stackgap_alloc(&sg, sizeof(*flen));
-
- fl = sasize;
- if ((error = copyout(&fl, flen, sizeof(fl))) != 0)
- return error;
-
- switch (st->s_cmd) {
- case SVR4_TI_CONNECT_REQUEST:
- DPRINTF(("getmsg: TI_CONNECT_REQUEST\n"));
- /*
- * We do the connect in one step, so the putmsg should
- * have gotten the error.
- */
- sc.cmd = SVR4_TI_OK_REPLY;
- sc.len = 0;
-
- ctl.len = 8;
- dat.len = -1;
- fl = 1;
- st->s_cmd = sc.cmd;
- break;
-
- case SVR4_TI_OK_REPLY:
- DPRINTF(("getmsg: TI_OK_REPLY\n"));
- /*
- * We are immediately after a connect reply, so we send
- * a connect verification.
- */
-
- SCARG(&ga, fdes) = SCARG(uap, fd);
- SCARG(&ga, asa) = (void *) sup;
- SCARG(&ga, alen) = flen;
-
- if ((error = getpeername(p, &ga)) != 0) {
- DPRINTF(("getmsg: getpeername failed %d\n", error));
- return error;
- }
-
- if ((error = copyin(sup, skp, sasize)) != 0)
- return error;
-
- sc.cmd = SVR4_TI_CONNECT_REPLY;
- sc.pad[0] = 0x4;
- sc.offs = 0x18;
- sc.pad[1] = 0x14;
- sc.pad[2] = 0x04000402;
-
- switch (st->s_family) {
- case AF_INET:
- sc.len = sasize;
- sockaddr_to_netaddr_in(&sc, &sain);
- break;
-
- case AF_LOCAL:
- sc.len = sasize + 4;
- sockaddr_to_netaddr_un(&sc, &saun);
- break;
-
- default:
- return ENOSYS;
- }
-
- ctl.len = 40;
- dat.len = -1;
- fl = 0;
- st->s_cmd = sc.cmd;
- break;
-
- case SVR4_TI__ACCEPT_OK:
- DPRINTF(("getmsg: TI__ACCEPT_OK\n"));
- /*
- * We do the connect in one step, so the putmsg should
- * have gotten the error.
- */
- sc.cmd = SVR4_TI_OK_REPLY;
- sc.len = 1;
-
- ctl.len = 8;
- dat.len = -1;
- fl = 1;
- st->s_cmd = SVR4_TI__ACCEPT_WAIT;
- break;
-
- case SVR4_TI__ACCEPT_WAIT:
- DPRINTF(("getmsg: TI__ACCEPT_WAIT\n"));
- /*
- * We are after a listen, so we try to accept...
- */
- SCARG(&aa, s) = SCARG(uap, fd);
- SCARG(&aa, name) = (void *) sup;
- SCARG(&aa, anamelen) = flen;
-
- if ((error = accept(p, &aa)) != 0) {
- DPRINTF(("getmsg: accept failed %d\n", error));
- return error;
- }
-
- st->s_afd = *retval;
-
- DPRINTF(("getmsg: Accept fd = %d\n", st->s_afd));
-
- if ((error = copyin(sup, skp, sasize)) != 0)
- return error;
-
- sc.cmd = SVR4_TI_ACCEPT_REPLY;
- sc.offs = 0x18;
- sc.pad[0] = 0x0;
-
- switch (st->s_family) {
- case AF_INET:
- sc.pad[1] = 0x28;
- sockaddr_to_netaddr_in(&sc, &sain);
- ctl.len = 40;
- sc.len = sasize;
- break;
-
- case AF_LOCAL:
- sc.pad[1] = 0x00010000;
- sc.pad[2] = 0xf6bcdaa0; /* I don't know what that is */
- sc.pad[3] = 0x00010000;
- ctl.len = 134;
- sc.len = sasize + 4;
- break;
-
- default:
- return ENOSYS;
- }
-
- dat.len = -1;
- fl = 0;
- st->s_cmd = SVR4_TI__ACCEPT_OK;
- break;
-
- case SVR4_TI_SENDTO_REQUEST:
- DPRINTF(("getmsg: TI_SENDTO_REQUEST\n"));
- if (ctl.maxlen > 36 && ctl.len < 36)
- ctl.len = 36;
-
- if ((error = copyin(ctl.buf, &sc, ctl.len)) != 0)
- return error;
-
- switch (st->s_family) {
- case AF_INET:
- sockaddr_to_netaddr_in(&sc, &sain);
- break;
-
- case AF_LOCAL:
- sockaddr_to_netaddr_un(&sc, &saun);
- break;
-
- default:
- return ENOSYS;
- }
-
- msg.msg_name = (caddr_t) sup;
- msg.msg_namelen = sasize;
- msg.msg_iov = &aiov;
- msg.msg_iovlen = 1;
- msg.msg_control = 0;
- aiov.iov_base = dat.buf;
- aiov.iov_len = dat.maxlen;
- msg.msg_flags = 0;
-
- error = svr4_recvit(p, SCARG(uap, fd), &msg, (caddr_t) flen);
-
- if (error) {
- DPRINTF(("getmsg: recvit failed %d\n", error));
- return error;
- }
-
- if ((error = copyin(msg.msg_name, skp, sasize)) != 0)
- return error;
-
- sc.cmd = SVR4_TI_RECVFROM_IND;
-
- switch (st->s_family) {
- case AF_INET:
- sc.len = sasize;
- sockaddr_to_netaddr_in(&sc, &sain);
- break;
-
- case AF_LOCAL:
- sc.len = sasize + 4;
- sockaddr_to_netaddr_un(&sc, &saun);
- break;
-
- default:
- return ENOSYS;
- }
-
- dat.len = *retval;
- fl = 0;
- st->s_cmd = sc.cmd;
- break;
-
- default:
- st->s_cmd = sc.cmd;
- if (st->s_cmd == SVR4_TI_CONNECT_REQUEST) {
- struct read_args ra;
-
- /* More wierdness: Again, I can't find documentation
- * to back this up, but when a process does a generic
- * "getmsg()" call it seems that the command field is
- * zero and the length of the data area is zero. I
- * think processes expect getmsg() to fill in dat.len
- * after reading at most dat.maxlen octets from the
- * stream. Since we're using sockets I can let
- * read() look after it and frob return values
- * appropriately (or inappropriately :-)
- * -- newton@atdot.dotat.org XXX
- */
- SCARG(&ra, fd) = SCARG(uap, fd);
- SCARG(&ra, buf) = dat.buf;
- SCARG(&ra, nbyte) = dat.maxlen;
- if ((error = read(p, &ra)) != 0) {
- return error;
- }
- dat.len = *retval;
- *retval = 0;
- st->s_cmd = SVR4_TI_SENDTO_REQUEST;
- break;
- }
- DPRINTF(("getmsg: Unknown state %x\n", st->s_cmd));
- return EINVAL;
- }
-
- if (SCARG(uap, ctl)) {
- if (ctl.len != -1)
- if ((error = copyout(&sc, ctl.buf, ctl.len)) != 0)
- return error;
-
- if ((error = copyout(&ctl, SCARG(uap, ctl), sizeof(ctl))) != 0)
- return error;
- }
-
- if (SCARG(uap, dat)) {
- if ((error = copyout(&dat, SCARG(uap, dat), sizeof(dat))) != 0)
- return error;
- }
-
- if (SCARG(uap, flags)) { /* XXX: Need translation */
- if ((error = copyout(&fl, SCARG(uap, flags), sizeof(fl))) != 0)
- return error;
- }
-
- *retval = 0;
-
-#ifdef DEBUG_SVR4
- show_msg("<getmsg", SCARG(uap, fd), SCARG(uap, ctl),
- SCARG(uap, dat), fl);
-#endif /* DEBUG_SVR4 */
- return error;
-}
-
-int svr4_sys_send(p, uap)
- struct proc *p;
- struct svr4_sys_send_args *uap;
-{
- struct osend_args osa;
- SCARG(&osa, s) = SCARG(uap, s);
- SCARG(&osa, buf) = SCARG(uap, buf);
- SCARG(&osa, len) = SCARG(uap, len);
- SCARG(&osa, flags) = SCARG(uap, flags);
- return osend(p, &osa);
-}
-
-int svr4_sys_recv(p, uap)
- struct proc *p;
- struct svr4_sys_recv_args *uap;
-{
- struct orecv_args ora;
- SCARG(&ora, s) = SCARG(uap, s);
- SCARG(&ora, buf) = SCARG(uap, buf);
- SCARG(&ora, len) = SCARG(uap, len);
- SCARG(&ora, flags) = SCARG(uap, flags);
- return orecv(p, &ora);
-}
-
-/*
- * XXX This isn't necessary, but it's handy for inserting debug code into
- * sendto(). Let's leave it here for now...
- */
-int
-svr4_sys_sendto(p, uap)
- struct proc *p;
- struct svr4_sys_sendto_args *uap;
-{
- struct sendto_args sa;
-
- SCARG(&sa, s) = SCARG(uap, s);
- SCARG(&sa, buf) = SCARG(uap, buf);
- SCARG(&sa, len) = SCARG(uap, len);
- SCARG(&sa, flags) = SCARG(uap, flags);
- SCARG(&sa, to) = SCARG(uap, to);
- SCARG(&sa, tolen) = SCARG(uap, tolen);
-
- DPRINTF(("calling sendto()\n"));
- return sendto(p, &sa);
-}
-
diff --git a/sys/compat/svr4/svr4_stropts.h b/sys/compat/svr4/svr4_stropts.h
deleted file mode 100644
index 2fa14a1e988a..000000000000
--- a/sys/compat/svr4/svr4_stropts.h
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1994 Christos Zoulas
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _SVR4_STROPTS_H_
-#define _SVR4_STROPTS_H_
-
-
-struct svr4_strbuf {
- int maxlen;
- int len;
- char *buf;
-};
-
-#define SVR4_STR ('S' << 8)
-#define SVR4_I_NREAD (SVR4_STR| 1)
-#define SVR4_I_PUSH (SVR4_STR| 2)
-#define SVR4_I_POP (SVR4_STR| 3)
-#define SVR4_I_LOOK (SVR4_STR| 4)
-#define SVR4_I_FLUSH (SVR4_STR| 5)
-#define SVR4_I_SRDOPT (SVR4_STR| 6)
-#define SVR4_I_GRDOPT (SVR4_STR| 7)
-#define SVR4_I_STR (SVR4_STR| 8)
-#define SVR4_I_SETSIG (SVR4_STR| 9)
-#define SVR4_I_GETSIG (SVR4_STR|10)
-#define SVR4_I_FIND (SVR4_STR|11)
-#define SVR4_I_LINK (SVR4_STR|12)
-#define SVR4_I_UNLINK (SVR4_STR|13)
-#define SVR4_I_ERECVFD (SVR4_STR|14)
-#define SVR4_I_PEEK (SVR4_STR|15)
-#define SVR4_I_FDINSERT (SVR4_STR|16)
-#define SVR4_I_SENDFD (SVR4_STR|17)
-#define SVR4_I_RECVFD (SVR4_STR|18)
-#define SVR4_I_SWROPT (SVR4_STR|19)
-#define SVR4_I_GWROPT (SVR4_STR|20)
-#define SVR4_I_LIST (SVR4_STR|21)
-#define SVR4_I_PLINK (SVR4_STR|22)
-#define SVR4_I_PUNLINK (SVR4_STR|23)
-#define SVR4_I_SETEV (SVR4_STR|24)
-#define SVR4_I_GETEV (SVR4_STR|25)
-#define SVR4_I_STREV (SVR4_STR|26)
-#define SVR4_I_UNSTREV (SVR4_STR|27)
-#define SVR4_I_FLUSHBAND (SVR4_STR|28)
-#define SVR4_I_CKBAND (SVR4_STR|29)
-#define SVR4_I_GETBAND (SVR4_STR|30)
-#define SVR4_I_ATMARK (SVR4_STR|31)
-#define SVR4_I_SETCLTIME (SVR4_STR|32)
-#define SVR4_I_GETCLTIME (SVR4_STR|33)
-#define SVR4_I_CANPUT (SVR4_STR|34)
-
-/*
- * The following two ioctls are OS specific and
- * undocumented.
- */
-#define SVR4__I_BIND_RSVD (SVR4_STR|242)
-#define SVR4__I_RELE_RSVD (SVR4_STR|243)
-
-/*
- * Service type definitions
- */
-#define SVR4_T_COTS 1 /* Connection-orieted */
-#define SVR4_T_COTS_ORD 2 /* Local connection-oriented */
-#define SVR4_T_CLTS 3 /* Connectionless */
-
-/* Struct passed for SVR4_I_STR */
-struct svr4_strioctl {
- u_long cmd;
- int timeout;
- int len;
- char *buf;
-};
-
-/*
- * Bits for I_{G,S}ETSIG
- */
-#define SVR4_S_INPUT 0x0001 /* any message on read queue no HIPRI */
-#define SVR4_S_HIPRI 0x0002 /* high prio message on read queue */
-#define SVR4_S_OUTPUT 0x0004 /* write queue has free space */
-#define SVR4_S_MSG 0x0008 /* signal message in read queue head */
-#define SVR4_S_ERROR 0x0010 /* error message in read queue head */
-#define SVR4_S_HANGUP 0x0020 /* hangup message in read queue head */
-#define SVR4_S_RDNORM 0x0040 /* normal message on read queue */
-#define SVR4_S_WRNORM S_OUTPUT /* write queue has free space */
-#define SVR4_S_RDBAND 0x0080 /* out of band message on read queue */
-#define SVR4_S_WRBAND 0x0100 /* write queue has free space for oob */
-#define SVR4_S_BANDURG 0x0200 /* generate SIGURG instead of SIGPOLL */
-#define SVR4_S_ALLMASK 0x03ff /* all events mask */
-
-/*
- * Our internal state for the stream
- * For now we keep almost nothing... In the future we can keep more
- * streams state.
- */
-struct svr4_strm {
- int s_family; /* socket family */
- int s_cmd; /* last getmsg reply or putmsg request */
- int s_afd; /* last accepted fd; [for fd_insert] */
- int s_eventmask; /* state info from I_SETSIG et al */
-};
-
-/*
- * The following structures are determined empirically.
- */
-struct svr4_strmcmd {
- long cmd; /* command ? */
- long len; /* Address len */
- long offs; /* Address offset */
- long pad[61];
-};
-
-struct svr4_infocmd {
- long cmd;
- long tsdu;
- long etsdu;
- long cdata;
- long ddata;
- long addr;
- long opt;
- long tidu;
- long serv;
- long current;
- long provider;
-};
-
-struct svr4_strfdinsert {
- struct svr4_strbuf ctl;
- struct svr4_strbuf data;
- long flags;
- int fd;
- int offset;
-};
-
-struct svr4_netaddr_in {
- u_short family;
- u_short port;
- u_long addr;
-};
-
-struct svr4_netaddr_un {
- u_short family;
- char path[1];
-};
-
-#define SVR4_ADDROF(sc) (void *) (((char *) (sc)) + (sc)->offs)
-#define SVR4_C_ADDROF(sc) (const void *) (((const char *) (sc)) + (sc)->offs)
-
-struct svr4_strm *svr4_stream_get __P((struct file *fp));
-
-#endif /* !_SVR4_STROPTS */
diff --git a/sys/compat/svr4/svr4_syscall.h b/sys/compat/svr4/svr4_syscall.h
deleted file mode 100644
index 749acaebbc9d..000000000000
--- a/sys/compat/svr4/svr4_syscall.h
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * System call numbers.
- *
- * DO NOT EDIT-- this file is automatically generated.
- * $FreeBSD$
- * created from; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
- */
-
-#define SVR4_SYS_exit 1
-#define SVR4_SYS_fork 2
-#define SVR4_SYS_read 3
-#define SVR4_SYS_write 4
-#define SVR4_SYS_svr4_sys_open 5
-#define SVR4_SYS_close 6
-#define SVR4_SYS_svr4_sys_wait 7
-#define SVR4_SYS_svr4_sys_creat 8
-#define SVR4_SYS_link 9
-#define SVR4_SYS_unlink 10
-#define SVR4_SYS_svr4_sys_execv 11
-#define SVR4_SYS_chdir 12
-#define SVR4_SYS_svr4_sys_time 13
-#define SVR4_SYS_svr4_sys_mknod 14
-#define SVR4_SYS_chmod 15
-#define SVR4_SYS_chown 16
-#define SVR4_SYS_svr4_sys_break 17
-#define SVR4_SYS_svr4_sys_stat 18
-#define SVR4_SYS_lseek 19
-#define SVR4_SYS_getpid 20
-#define SVR4_SYS_setuid 23
-#define SVR4_SYS_getuid 24
-#define SVR4_SYS_svr4_sys_alarm 27
-#define SVR4_SYS_svr4_sys_fstat 28
-#define SVR4_SYS_svr4_sys_pause 29
-#define SVR4_SYS_svr4_sys_utime 30
-#define SVR4_SYS_svr4_sys_access 33
-#define SVR4_SYS_svr4_sys_nice 34
-#define SVR4_SYS_sync 36
-#define SVR4_SYS_svr4_sys_kill 37
-#define SVR4_SYS_svr4_sys_pgrpsys 39
-#define SVR4_SYS_dup 41
-#define SVR4_SYS_pipe 42
-#define SVR4_SYS_svr4_sys_times 43
-#define SVR4_SYS_setgid 46
-#define SVR4_SYS_getgid 47
-#define SVR4_SYS_svr4_sys_signal 48
-#define SVR4_SYS_svr4_sys_msgsys 49
-#define SVR4_SYS_svr4_sys_sysarch 50
-#define SVR4_SYS_svr4_sys_ioctl 54
-#define SVR4_SYS_svr4_sys_utssys 57
-#define SVR4_SYS_fsync 58
-#define SVR4_SYS_svr4_sys_execve 59
-#define SVR4_SYS_umask 60
-#define SVR4_SYS_chroot 61
-#define SVR4_SYS_svr4_sys_fcntl 62
-#define SVR4_SYS_svr4_sys_ulimit 63
-#define SVR4_SYS_rmdir 79
-#define SVR4_SYS_mkdir 80
-#define SVR4_SYS_svr4_sys_getdents 81
-#define SVR4_SYS_svr4_sys_getmsg 85
-#define SVR4_SYS_svr4_sys_putmsg 86
-#define SVR4_SYS_svr4_sys_poll 87
-#define SVR4_SYS_svr4_sys_lstat 88
-#define SVR4_SYS_symlink 89
-#define SVR4_SYS_readlink 90
-#define SVR4_SYS_getgroups 91
-#define SVR4_SYS_setgroups 92
-#define SVR4_SYS_fchmod 93
-#define SVR4_SYS_fchown 94
-#define SVR4_SYS_svr4_sys_sigprocmask 95
-#define SVR4_SYS_svr4_sys_sigsuspend 96
-#define SVR4_SYS_svr4_sys_sigaltstack 97
-#define SVR4_SYS_svr4_sys_sigaction 98
-#define SVR4_SYS_svr4_sys_sigpending 99
-#define SVR4_SYS_svr4_sys_context 100
-#define SVR4_SYS_svr4_sys_statvfs 103
-#define SVR4_SYS_svr4_sys_fstatvfs 104
-#define SVR4_SYS_svr4_sys_waitsys 107
-#define SVR4_SYS_svr4_sys_hrtsys 109
-#define SVR4_SYS_svr4_sys_pathconf 113
-#define SVR4_SYS_svr4_sys_mmap 115
-#define SVR4_SYS_mprotect 116
-#define SVR4_SYS_munmap 117
-#define SVR4_SYS_svr4_sys_fpathconf 118
-#define SVR4_SYS_vfork 119
-#define SVR4_SYS_fchdir 120
-#define SVR4_SYS_readv 121
-#define SVR4_SYS_writev 122
-#define SVR4_SYS_svr4_sys_xstat 123
-#define SVR4_SYS_svr4_sys_lxstat 124
-#define SVR4_SYS_svr4_sys_fxstat 125
-#define SVR4_SYS_svr4_sys_xmknod 126
-#define SVR4_SYS_svr4_sys_setrlimit 128
-#define SVR4_SYS_svr4_sys_getrlimit 129
-#define SVR4_SYS_lchown 130
-#define SVR4_SYS_svr4_sys_memcntl 131
-#define SVR4_SYS_rename 134
-#define SVR4_SYS_svr4_sys_uname 135
-#define SVR4_SYS_setegid 136
-#define SVR4_SYS_svr4_sys_sysconfig 137
-#define SVR4_SYS_adjtime 138
-#define SVR4_SYS_svr4_sys_systeminfo 139
-#define SVR4_SYS_seteuid 141
-#define SVR4_SYS_svr4_sys_fchroot 153
-#define SVR4_SYS_svr4_sys_utimes 154
-#define SVR4_SYS_svr4_sys_vhangup 155
-#define SVR4_SYS_svr4_sys_gettimeofday 156
-#define SVR4_SYS_getitimer 157
-#define SVR4_SYS_setitimer 158
-#define SVR4_SYS_svr4_sys_llseek 175
-#define SVR4_SYS_svr4_sys_acl 185
-#define SVR4_SYS_svr4_sys_auditsys 186
-#define SVR4_SYS_nanosleep 199
-#define SVR4_SYS_svr4_sys_facl 200
-#define SVR4_SYS_setreuid 202
-#define SVR4_SYS_setregid 203
-#define SVR4_SYS_svr4_sys_resolvepath 209
-#define SVR4_SYS_svr4_sys_getdents64 213
-#define SVR4_SYS_svr4_sys_mmap64 214
-#define SVR4_SYS_svr4_sys_stat64 215
-#define SVR4_SYS_svr4_sys_lstat64 216
-#define SVR4_SYS_svr4_sys_fstat64 217
-#define SVR4_SYS_svr4_sys_statvfs64 218
-#define SVR4_SYS_svr4_sys_fstatvfs64 219
-#define SVR4_SYS_svr4_sys_setrlimit64 220
-#define SVR4_SYS_svr4_sys_getrlimit64 221
-#define SVR4_SYS_svr4_sys_creat64 224
-#define SVR4_SYS_svr4_sys_open64 225
-#define SVR4_SYS_svr4_sys_socket 230
-#define SVR4_SYS_socketpair 231
-#define SVR4_SYS_bind 232
-#define SVR4_SYS_listen 233
-#define SVR4_SYS_accept 234
-#define SVR4_SYS_connect 235
-#define SVR4_SYS_shutdown 236
-#define SVR4_SYS_svr4_sys_recv 237
-#define SVR4_SYS_recvfrom 238
-#define SVR4_SYS_recvmsg 239
-#define SVR4_SYS_svr4_sys_send 240
-#define SVR4_SYS_sendmsg 241
-#define SVR4_SYS_svr4_sys_sendto 242
-#define SVR4_SYS_getpeername 243
-#define SVR4_SYS_getsockname 244
-#define SVR4_SYS_getsockopt 245
-#define SVR4_SYS_setsockopt 246
-#define SVR4_SYS_MAXSYSCALL 250
diff --git a/sys/compat/svr4/svr4_syscallnames.c b/sys/compat/svr4/svr4_syscallnames.c
deleted file mode 100644
index 6de96e6917fb..000000000000
--- a/sys/compat/svr4/svr4_syscallnames.c
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * System call names.
- *
- * DO NOT EDIT-- this file is automatically generated.
- * $FreeBSD$
- * created from; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
- */
-
-char *svr4_syscallnames[] = {
- "#0", /* 0 = unused */
- "exit", /* 1 = exit */
- "fork", /* 2 = fork */
- "read", /* 3 = read */
- "write", /* 4 = write */
- "svr4_sys_open", /* 5 = svr4_sys_open */
- "close", /* 6 = close */
- "svr4_sys_wait", /* 7 = svr4_sys_wait */
- "svr4_sys_creat", /* 8 = svr4_sys_creat */
- "link", /* 9 = link */
- "unlink", /* 10 = unlink */
- "svr4_sys_execv", /* 11 = svr4_sys_execv */
- "chdir", /* 12 = chdir */
- "svr4_sys_time", /* 13 = svr4_sys_time */
- "svr4_sys_mknod", /* 14 = svr4_sys_mknod */
- "chmod", /* 15 = chmod */
- "chown", /* 16 = chown */
- "svr4_sys_break", /* 17 = svr4_sys_break */
- "svr4_sys_stat", /* 18 = svr4_sys_stat */
- "lseek", /* 19 = lseek */
- "getpid", /* 20 = getpid */
- "#21", /* 21 = old_mount */
- "#22", /* 22 = sysv_umount */
- "setuid", /* 23 = setuid */
- "getuid", /* 24 = getuid */
- "#25", /* 25 = stime */
- "#26", /* 26 = ptrace */
- "svr4_sys_alarm", /* 27 = svr4_sys_alarm */
- "svr4_sys_fstat", /* 28 = svr4_sys_fstat */
- "svr4_sys_pause", /* 29 = svr4_sys_pause */
- "svr4_sys_utime", /* 30 = svr4_sys_utime */
- "#31", /* 31 = stty */
- "#32", /* 32 = gtty */
- "svr4_sys_access", /* 33 = svr4_sys_access */
- "svr4_sys_nice", /* 34 = svr4_sys_nice */
- "#35", /* 35 = statfs */
- "sync", /* 36 = sync */
- "svr4_sys_kill", /* 37 = svr4_sys_kill */
- "#38", /* 38 = fstatfs */
- "svr4_sys_pgrpsys", /* 39 = svr4_sys_pgrpsys */
- "#40", /* 40 = xenix */
- "dup", /* 41 = dup */
- "pipe", /* 42 = pipe */
- "svr4_sys_times", /* 43 = svr4_sys_times */
- "#44", /* 44 = profil */
- "#45", /* 45 = plock */
- "setgid", /* 46 = setgid */
- "getgid", /* 47 = getgid */
- "svr4_sys_signal", /* 48 = svr4_sys_signal */
-#if defined(NOTYET)
- "svr4_sys_msgsys", /* 49 = svr4_sys_msgsys */
-#else
- "#49", /* 49 = msgsys */
-#endif
- "svr4_sys_sysarch", /* 50 = svr4_sys_sysarch */
- "#51", /* 51 = acct */
- "#52", /* 52 = shmsys */
- "#53", /* 53 = semsys */
- "svr4_sys_ioctl", /* 54 = svr4_sys_ioctl */
- "#55", /* 55 = uadmin */
- "#56", /* 56 = exch */
- "svr4_sys_utssys", /* 57 = svr4_sys_utssys */
- "fsync", /* 58 = fsync */
- "svr4_sys_execve", /* 59 = svr4_sys_execve */
- "umask", /* 60 = umask */
- "chroot", /* 61 = chroot */
- "svr4_sys_fcntl", /* 62 = svr4_sys_fcntl */
- "svr4_sys_ulimit", /* 63 = svr4_sys_ulimit */
- "#64", /* 64 = reserved */
- "#65", /* 65 = reserved */
- "#66", /* 66 = reserved */
- "#67", /* 67 = reserved */
- "#68", /* 68 = reserved */
- "#69", /* 69 = reserved */
- "#70", /* 70 = advfs */
- "#71", /* 71 = unadvfs */
- "#72", /* 72 = rmount */
- "#73", /* 73 = rumount */
- "#74", /* 74 = rfstart */
- "#75", /* 75 = sigret */
- "#76", /* 76 = rdebug */
- "#77", /* 77 = rfstop */
- "#78", /* 78 = rfsys */
- "rmdir", /* 79 = rmdir */
- "mkdir", /* 80 = mkdir */
- "svr4_sys_getdents", /* 81 = svr4_sys_getdents */
- "#82", /* 82 = libattach */
- "#83", /* 83 = libdetach */
- "#84", /* 84 = sysfs */
- "svr4_sys_getmsg", /* 85 = svr4_sys_getmsg */
- "svr4_sys_putmsg", /* 86 = svr4_sys_putmsg */
- "svr4_sys_poll", /* 87 = svr4_sys_poll */
- "svr4_sys_lstat", /* 88 = svr4_sys_lstat */
- "symlink", /* 89 = symlink */
- "readlink", /* 90 = readlink */
- "getgroups", /* 91 = getgroups */
- "setgroups", /* 92 = setgroups */
- "fchmod", /* 93 = fchmod */
- "fchown", /* 94 = fchown */
- "svr4_sys_sigprocmask", /* 95 = svr4_sys_sigprocmask */
- "svr4_sys_sigsuspend", /* 96 = svr4_sys_sigsuspend */
- "svr4_sys_sigaltstack", /* 97 = svr4_sys_sigaltstack */
- "svr4_sys_sigaction", /* 98 = svr4_sys_sigaction */
- "svr4_sys_sigpending", /* 99 = svr4_sys_sigpending */
- "svr4_sys_context", /* 100 = svr4_sys_context */
- "#101", /* 101 = evsys */
- "#102", /* 102 = evtrapret */
- "svr4_sys_statvfs", /* 103 = svr4_sys_statvfs */
- "svr4_sys_fstatvfs", /* 104 = svr4_sys_fstatvfs */
- "#105", /* 105 = whoknows */
- "#106", /* 106 = nfssvc */
- "svr4_sys_waitsys", /* 107 = svr4_sys_waitsys */
- "#108", /* 108 = sigsendsys */
- "svr4_sys_hrtsys", /* 109 = svr4_sys_hrtsys */
- "#110", /* 110 = acancel */
- "#111", /* 111 = async */
- "#112", /* 112 = priocntlsys */
- "svr4_sys_pathconf", /* 113 = svr4_sys_pathconf */
- "#114", /* 114 = mincore */
- "svr4_sys_mmap", /* 115 = svr4_sys_mmap */
- "mprotect", /* 116 = mprotect */
- "munmap", /* 117 = munmap */
- "svr4_sys_fpathconf", /* 118 = svr4_sys_fpathconf */
- "vfork", /* 119 = vfork */
- "fchdir", /* 120 = fchdir */
- "readv", /* 121 = readv */
- "writev", /* 122 = writev */
- "svr4_sys_xstat", /* 123 = svr4_sys_xstat */
- "svr4_sys_lxstat", /* 124 = svr4_sys_lxstat */
- "svr4_sys_fxstat", /* 125 = svr4_sys_fxstat */
- "svr4_sys_xmknod", /* 126 = svr4_sys_xmknod */
- "#127", /* 127 = clocal */
- "svr4_sys_setrlimit", /* 128 = svr4_sys_setrlimit */
- "svr4_sys_getrlimit", /* 129 = svr4_sys_getrlimit */
- "lchown", /* 130 = lchown */
- "svr4_sys_memcntl", /* 131 = svr4_sys_memcntl */
- "#132", /* 132 = getpmsg */
- "#133", /* 133 = putpmsg */
- "rename", /* 134 = rename */
- "svr4_sys_uname", /* 135 = svr4_sys_uname */
- "setegid", /* 136 = setegid */
- "svr4_sys_sysconfig", /* 137 = svr4_sys_sysconfig */
- "adjtime", /* 138 = adjtime */
- "svr4_sys_systeminfo", /* 139 = svr4_sys_systeminfo */
- "#140", /* 140 = notused */
- "seteuid", /* 141 = seteuid */
- "#142", /* 142 = vtrace */
- "#143", /* 143 = { */
- "#144", /* 144 = sigtimedwait */
- "#145", /* 145 = lwp_info */
- "#146", /* 146 = yield */
- "#147", /* 147 = lwp_sema_wait */
- "#148", /* 148 = lwp_sema_post */
- "#149", /* 149 = lwp_sema_trywait */
- "#150", /* 150 = notused */
- "#151", /* 151 = notused */
- "#152", /* 152 = modctl */
- "svr4_sys_fchroot", /* 153 = svr4_sys_fchroot */
- "svr4_sys_utimes", /* 154 = svr4_sys_utimes */
- "svr4_sys_vhangup", /* 155 = svr4_sys_vhangup */
- "svr4_sys_gettimeofday", /* 156 = svr4_sys_gettimeofday */
- "getitimer", /* 157 = getitimer */
- "setitimer", /* 158 = setitimer */
- "#159", /* 159 = lwp_create */
- "#160", /* 160 = lwp_exit */
- "#161", /* 161 = lwp_suspend */
- "#162", /* 162 = lwp_continue */
- "#163", /* 163 = lwp_kill */
- "#164", /* 164 = lwp_self */
- "#165", /* 165 = lwp_getprivate */
- "#166", /* 166 = lwp_setprivate */
- "#167", /* 167 = lwp_wait */
- "#168", /* 168 = lwp_mutex_unlock */
- "#169", /* 169 = lwp_mutex_lock */
- "#170", /* 170 = lwp_cond_wait */
- "#171", /* 171 = lwp_cond_signal */
- "#172", /* 172 = lwp_cond_broadcast */
- "#173", /* 173 = { */
- "#174", /* 174 = { */
- "svr4_sys_llseek", /* 175 = svr4_sys_llseek */
- "#176", /* 176 = inst_sync */
- "#177", /* 177 = whoknows */
- "#178", /* 178 = kaio */
- "#179", /* 179 = whoknows */
- "#180", /* 180 = whoknows */
- "#181", /* 181 = whoknows */
- "#182", /* 182 = whoknows */
- "#183", /* 183 = whoknows */
- "#184", /* 184 = tsolsys */
- "svr4_sys_acl", /* 185 = svr4_sys_acl */
- "svr4_sys_auditsys", /* 186 = svr4_sys_auditsys */
- "#187", /* 187 = processor_bind */
- "#188", /* 188 = processor_info */
- "#189", /* 189 = p_online */
- "#190", /* 190 = sigqueue */
- "#191", /* 191 = clock_gettime */
- "#192", /* 192 = clock_settime */
- "#193", /* 193 = clock_getres */
- "#194", /* 194 = timer_create */
- "#195", /* 195 = timer_delete */
- "#196", /* 196 = timer_settime */
- "#197", /* 197 = timer_gettime */
- "#198", /* 198 = timer_overrun */
- "nanosleep", /* 199 = nanosleep */
- "svr4_sys_facl", /* 200 = svr4_sys_facl */
- "#201", /* 201 = door */
- "setreuid", /* 202 = setreuid */
- "setregid", /* 203 = setregid */
- "#204", /* 204 = install_utrap */
- "#205", /* 205 = signotify */
- "#206", /* 206 = schedctl */
- "#207", /* 207 = pset */
- "#208", /* 208 = whoknows */
- "svr4_sys_resolvepath", /* 209 = svr4_sys_resolvepath */
- "#210", /* 210 = signotifywait */
- "#211", /* 211 = lwp_sigredirect */
- "#212", /* 212 = lwp_alarm */
- "svr4_sys_getdents64", /* 213 = svr4_sys_getdents64 */
- "svr4_sys_mmap64", /* 214 = svr4_sys_mmap64 */
- "svr4_sys_stat64", /* 215 = svr4_sys_stat64 */
- "svr4_sys_lstat64", /* 216 = svr4_sys_lstat64 */
- "svr4_sys_fstat64", /* 217 = svr4_sys_fstat64 */
- "svr4_sys_statvfs64", /* 218 = svr4_sys_statvfs64 */
- "svr4_sys_fstatvfs64", /* 219 = svr4_sys_fstatvfs64 */
- "svr4_sys_setrlimit64", /* 220 = svr4_sys_setrlimit64 */
- "svr4_sys_getrlimit64", /* 221 = svr4_sys_getrlimit64 */
- "#222", /* 222 = pread64 */
- "#223", /* 223 = pwrite64 */
- "svr4_sys_creat64", /* 224 = svr4_sys_creat64 */
- "svr4_sys_open64", /* 225 = svr4_sys_open64 */
- "#226", /* 226 = rpcsys */
- "#227", /* 227 = whoknows */
- "#228", /* 228 = whoknows */
- "#229", /* 229 = whoknows */
- "svr4_sys_socket", /* 230 = svr4_sys_socket */
- "socketpair", /* 231 = socketpair */
- "bind", /* 232 = bind */
- "listen", /* 233 = listen */
- "accept", /* 234 = accept */
- "connect", /* 235 = connect */
- "shutdown", /* 236 = shutdown */
- "svr4_sys_recv", /* 237 = svr4_sys_recv */
- "recvfrom", /* 238 = recvfrom */
- "recvmsg", /* 239 = recvmsg */
- "svr4_sys_send", /* 240 = svr4_sys_send */
- "sendmsg", /* 241 = sendmsg */
- "svr4_sys_sendto", /* 242 = svr4_sys_sendto */
- "getpeername", /* 243 = getpeername */
- "getsockname", /* 244 = getsockname */
- "getsockopt", /* 245 = getsockopt */
- "setsockopt", /* 246 = setsockopt */
- "#247", /* 247 = sockconfig */
- "#248", /* 248 = { */
- "#249", /* 249 = { */
-};
diff --git a/sys/compat/svr4/svr4_sysconfig.h b/sys/compat/svr4/svr4_sysconfig.h
deleted file mode 100644
index 874c5653e634..000000000000
--- a/sys/compat/svr4/svr4_sysconfig.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1995 Christos Zoulas
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _SVR4_SYSCONFIG_H_
-#define _SVR4_SYSCONFIG_H_
-
-#define SVR4_CONFIG_UNUSED 0x01
-#define SVR4_CONFIG_NGROUPS 0x02
-#define SVR4_CONFIG_CHILD_MAX 0x03
-#define SVR4_CONFIG_OPEN_FILES 0x04
-#define SVR4_CONFIG_POSIX_VER 0x05
-#define SVR4_CONFIG_PAGESIZE 0x06
-#define SVR4_CONFIG_CLK_TCK 0x07
-#define SVR4_CONFIG_XOPEN_VER 0x08
-#define SVR4_CONFIG_UNUSED_9 0x09
-#define SVR4_CONFIG_PROF_TCK 0x0a
-#define SVR4_CONFIG_NPROC_CONF 0x0b
-#define SVR4_CONFIG_NPROC_ONLN 0x0c
-#define SVR4_CONFIG_AIO_LISTIO_MAX 0x0e
-#define SVR4_CONFIG_AIO_MAX 0x0f
-#define SVR4_CONFIG_AIO_PRIO_DELTA_MAX 0x10
-#define SVR4_CONFIG_DELAYTIMER_MAX 0x11
-#define SVR4_CONFIG_MQ_OPEN_MAX 0x12
-#define SVR4_CONFIG_MQ_PRIO_MAX 0x13
-#define SVR4_CONFIG_RTSIG_MAX 0x14
-#define SVR4_CONFIG_SEM_NSEMS_MAX 0x15
-#define SVR4_CONFIG_SEM_VALUE_MAX 0x16
-#define SVR4_CONFIG_SIGQUEUE_MAX 0x17
-#define SVR4_CONFIG_SIGRT_MIN 0x18
-#define SVR4_CONFIG_SIGRT_MAX 0x19
-#define SVR4_CONFIG_TIMER_MAX 0x20
-#define SVR4_CONFIG_PHYS_PAGES 0x21
-#define SVR4_CONFIG_AVPHYS_PAGES 0x22
-
-#endif /* !_SVR4_SYSCONFIG_H_ */
diff --git a/sys/compat/svr4/svr4_sysent.c b/sys/compat/svr4/svr4_sysent.c
deleted file mode 100644
index 84db78b82c10..000000000000
--- a/sys/compat/svr4/svr4_sysent.c
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- * System call switch table.
- *
- * DO NOT EDIT-- this file is automatically generated.
- * $FreeBSD$
- * created from; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
- */
-
-#include <sys/types.h>
-#include <sys/sysent.h>
-#include <sys/sysproto.h>
-#include <netinet/in.h>
-#include <svr4/svr4.h>
-#include <svr4/svr4_types.h>
-#include <svr4/svr4_signal.h>
-#include <svr4/svr4_proto.h>
-
-/* The casts are bogus but will do for now. */
-struct sysent svr4_sysent[] = {
- { 0, (sy_call_t *)nosys }, /* 0 = unused */
- { 1, (sy_call_t *)exit }, /* 1 = exit */
- { 0, (sy_call_t *)fork }, /* 2 = fork */
- { 3, (sy_call_t *)read }, /* 3 = read */
- { 3, (sy_call_t *)write }, /* 4 = write */
- { 3, (sy_call_t *)svr4_sys_open }, /* 5 = svr4_sys_open */
- { 1, (sy_call_t *)close }, /* 6 = close */
- { 1, (sy_call_t *)svr4_sys_wait }, /* 7 = svr4_sys_wait */
- { 2, (sy_call_t *)svr4_sys_creat }, /* 8 = svr4_sys_creat */
- { 2, (sy_call_t *)link }, /* 9 = link */
- { 1, (sy_call_t *)unlink }, /* 10 = unlink */
- { 2, (sy_call_t *)svr4_sys_execv }, /* 11 = svr4_sys_execv */
- { 1, (sy_call_t *)chdir }, /* 12 = chdir */
- { 1, (sy_call_t *)svr4_sys_time }, /* 13 = svr4_sys_time */
- { 3, (sy_call_t *)svr4_sys_mknod }, /* 14 = svr4_sys_mknod */
- { 2, (sy_call_t *)chmod }, /* 15 = chmod */
- { 3, (sy_call_t *)chown }, /* 16 = chown */
- { 1, (sy_call_t *)svr4_sys_break }, /* 17 = svr4_sys_break */
- { 2, (sy_call_t *)svr4_sys_stat }, /* 18 = svr4_sys_stat */
- { 3, (sy_call_t *)lseek }, /* 19 = lseek */
- { 0, (sy_call_t *)getpid }, /* 20 = getpid */
- { 0, (sy_call_t *)nosys }, /* 21 = old_mount */
- { 0, (sy_call_t *)nosys }, /* 22 = sysv_umount */
- { 1, (sy_call_t *)setuid }, /* 23 = setuid */
- { 0, (sy_call_t *)getuid }, /* 24 = getuid */
- { 0, (sy_call_t *)nosys }, /* 25 = stime */
- { 0, (sy_call_t *)nosys }, /* 26 = ptrace */
- { 1, (sy_call_t *)svr4_sys_alarm }, /* 27 = svr4_sys_alarm */
- { 2, (sy_call_t *)svr4_sys_fstat }, /* 28 = svr4_sys_fstat */
- { 0, (sy_call_t *)svr4_sys_pause }, /* 29 = svr4_sys_pause */
- { 2, (sy_call_t *)svr4_sys_utime }, /* 30 = svr4_sys_utime */
- { 0, (sy_call_t *)nosys }, /* 31 = stty */
- { 0, (sy_call_t *)nosys }, /* 32 = gtty */
- { 2, (sy_call_t *)svr4_sys_access }, /* 33 = svr4_sys_access */
- { 1, (sy_call_t *)svr4_sys_nice }, /* 34 = svr4_sys_nice */
- { 0, (sy_call_t *)nosys }, /* 35 = statfs */
- { 0, (sy_call_t *)sync }, /* 36 = sync */
- { 2, (sy_call_t *)svr4_sys_kill }, /* 37 = svr4_sys_kill */
- { 0, (sy_call_t *)nosys }, /* 38 = fstatfs */
- { 3, (sy_call_t *)svr4_sys_pgrpsys }, /* 39 = svr4_sys_pgrpsys */
- { 0, (sy_call_t *)nosys }, /* 40 = xenix */
- { 1, (sy_call_t *)dup }, /* 41 = dup */
- { 0, (sy_call_t *)pipe }, /* 42 = pipe */
- { 1, (sy_call_t *)svr4_sys_times }, /* 43 = svr4_sys_times */
- { 0, (sy_call_t *)nosys }, /* 44 = profil */
- { 0, (sy_call_t *)nosys }, /* 45 = plock */
- { 1, (sy_call_t *)setgid }, /* 46 = setgid */
- { 0, (sy_call_t *)getgid }, /* 47 = getgid */
- { 2, (sy_call_t *)svr4_sys_signal }, /* 48 = svr4_sys_signal */
-#if defined(NOTYET)
- { 5, (sy_call_t *)svr4_sys_msgsys }, /* 49 = svr4_sys_msgsys */
-#else
- { 0, (sy_call_t *)nosys }, /* 49 = msgsys */
-#endif
- { 2, (sy_call_t *)svr4_sys_sysarch }, /* 50 = svr4_sys_sysarch */
- { 0, (sy_call_t *)nosys }, /* 51 = acct */
- { 0, (sy_call_t *)nosys }, /* 52 = shmsys */
- { 0, (sy_call_t *)nosys }, /* 53 = semsys */
- { 3, (sy_call_t *)svr4_sys_ioctl }, /* 54 = svr4_sys_ioctl */
- { 0, (sy_call_t *)nosys }, /* 55 = uadmin */
- { 0, (sy_call_t *)nosys }, /* 56 = exch */
- { 4, (sy_call_t *)svr4_sys_utssys }, /* 57 = svr4_sys_utssys */
- { 1, (sy_call_t *)fsync }, /* 58 = fsync */
- { 3, (sy_call_t *)svr4_sys_execve }, /* 59 = svr4_sys_execve */
- { 1, (sy_call_t *)umask }, /* 60 = umask */
- { 1, (sy_call_t *)chroot }, /* 61 = chroot */
- { 3, (sy_call_t *)svr4_sys_fcntl }, /* 62 = svr4_sys_fcntl */
- { 2, (sy_call_t *)svr4_sys_ulimit }, /* 63 = svr4_sys_ulimit */
- { 0, (sy_call_t *)nosys }, /* 64 = reserved */
- { 0, (sy_call_t *)nosys }, /* 65 = reserved */
- { 0, (sy_call_t *)nosys }, /* 66 = reserved */
- { 0, (sy_call_t *)nosys }, /* 67 = reserved */
- { 0, (sy_call_t *)nosys }, /* 68 = reserved */
- { 0, (sy_call_t *)nosys }, /* 69 = reserved */
- { 0, (sy_call_t *)nosys }, /* 70 = advfs */
- { 0, (sy_call_t *)nosys }, /* 71 = unadvfs */
- { 0, (sy_call_t *)nosys }, /* 72 = rmount */
- { 0, (sy_call_t *)nosys }, /* 73 = rumount */
- { 0, (sy_call_t *)nosys }, /* 74 = rfstart */
- { 0, (sy_call_t *)nosys }, /* 75 = sigret */
- { 0, (sy_call_t *)nosys }, /* 76 = rdebug */
- { 0, (sy_call_t *)nosys }, /* 77 = rfstop */
- { 0, (sy_call_t *)nosys }, /* 78 = rfsys */
- { 1, (sy_call_t *)rmdir }, /* 79 = rmdir */
- { 2, (sy_call_t *)mkdir }, /* 80 = mkdir */
- { 3, (sy_call_t *)svr4_sys_getdents }, /* 81 = svr4_sys_getdents */
- { 0, (sy_call_t *)nosys }, /* 82 = libattach */
- { 0, (sy_call_t *)nosys }, /* 83 = libdetach */
- { 0, (sy_call_t *)nosys }, /* 84 = sysfs */
- { 4, (sy_call_t *)svr4_sys_getmsg }, /* 85 = svr4_sys_getmsg */
- { 4, (sy_call_t *)svr4_sys_putmsg }, /* 86 = svr4_sys_putmsg */
- { 3, (sy_call_t *)svr4_sys_poll }, /* 87 = svr4_sys_poll */
- { 2, (sy_call_t *)svr4_sys_lstat }, /* 88 = svr4_sys_lstat */
- { 2, (sy_call_t *)symlink }, /* 89 = symlink */
- { 3, (sy_call_t *)readlink }, /* 90 = readlink */
- { 2, (sy_call_t *)getgroups }, /* 91 = getgroups */
- { 2, (sy_call_t *)setgroups }, /* 92 = setgroups */
- { 2, (sy_call_t *)fchmod }, /* 93 = fchmod */
- { 3, (sy_call_t *)fchown }, /* 94 = fchown */
- { 3, (sy_call_t *)svr4_sys_sigprocmask }, /* 95 = svr4_sys_sigprocmask */
- { 1, (sy_call_t *)svr4_sys_sigsuspend }, /* 96 = svr4_sys_sigsuspend */
- { 2, (sy_call_t *)svr4_sys_sigaltstack }, /* 97 = svr4_sys_sigaltstack */
- { 3, (sy_call_t *)svr4_sys_sigaction }, /* 98 = svr4_sys_sigaction */
- { 2, (sy_call_t *)svr4_sys_sigpending }, /* 99 = svr4_sys_sigpending */
- { 2, (sy_call_t *)svr4_sys_context }, /* 100 = svr4_sys_context */
- { 0, (sy_call_t *)nosys }, /* 101 = evsys */
- { 0, (sy_call_t *)nosys }, /* 102 = evtrapret */
- { 2, (sy_call_t *)svr4_sys_statvfs }, /* 103 = svr4_sys_statvfs */
- { 2, (sy_call_t *)svr4_sys_fstatvfs }, /* 104 = svr4_sys_fstatvfs */
- { 0, (sy_call_t *)nosys }, /* 105 = whoknows */
- { 0, (sy_call_t *)nosys }, /* 106 = nfssvc */
- { 4, (sy_call_t *)svr4_sys_waitsys }, /* 107 = svr4_sys_waitsys */
- { 0, (sy_call_t *)nosys }, /* 108 = sigsendsys */
- { 5, (sy_call_t *)svr4_sys_hrtsys }, /* 109 = svr4_sys_hrtsys */
- { 0, (sy_call_t *)nosys }, /* 110 = acancel */
- { 0, (sy_call_t *)nosys }, /* 111 = async */
- { 0, (sy_call_t *)nosys }, /* 112 = priocntlsys */
- { 2, (sy_call_t *)svr4_sys_pathconf }, /* 113 = svr4_sys_pathconf */
- { 0, (sy_call_t *)nosys }, /* 114 = mincore */
- { 6, (sy_call_t *)svr4_sys_mmap }, /* 115 = svr4_sys_mmap */
- { 3, (sy_call_t *)mprotect }, /* 116 = mprotect */
- { 2, (sy_call_t *)munmap }, /* 117 = munmap */
- { 2, (sy_call_t *)svr4_sys_fpathconf }, /* 118 = svr4_sys_fpathconf */
- { 0, (sy_call_t *)vfork }, /* 119 = vfork */
- { 1, (sy_call_t *)fchdir }, /* 120 = fchdir */
- { 3, (sy_call_t *)readv }, /* 121 = readv */
- { 3, (sy_call_t *)writev }, /* 122 = writev */
- { 3, (sy_call_t *)svr4_sys_xstat }, /* 123 = svr4_sys_xstat */
- { 3, (sy_call_t *)svr4_sys_lxstat }, /* 124 = svr4_sys_lxstat */
- { 3, (sy_call_t *)svr4_sys_fxstat }, /* 125 = svr4_sys_fxstat */
- { 4, (sy_call_t *)svr4_sys_xmknod }, /* 126 = svr4_sys_xmknod */
- { 0, (sy_call_t *)nosys }, /* 127 = clocal */
- { 2, (sy_call_t *)svr4_sys_setrlimit }, /* 128 = svr4_sys_setrlimit */
- { 2, (sy_call_t *)svr4_sys_getrlimit }, /* 129 = svr4_sys_getrlimit */
- { 3, (sy_call_t *)lchown }, /* 130 = lchown */
- { 6, (sy_call_t *)svr4_sys_memcntl }, /* 131 = svr4_sys_memcntl */
- { 0, (sy_call_t *)nosys }, /* 132 = getpmsg */
- { 0, (sy_call_t *)nosys }, /* 133 = putpmsg */
- { 2, (sy_call_t *)rename }, /* 134 = rename */
- { 2, (sy_call_t *)svr4_sys_uname }, /* 135 = svr4_sys_uname */
- { 1, (sy_call_t *)setegid }, /* 136 = setegid */
- { 1, (sy_call_t *)svr4_sys_sysconfig }, /* 137 = svr4_sys_sysconfig */
- { 2, (sy_call_t *)adjtime }, /* 138 = adjtime */
- { 3, (sy_call_t *)svr4_sys_systeminfo }, /* 139 = svr4_sys_systeminfo */
- { 0, (sy_call_t *)nosys }, /* 140 = notused */
- { 1, (sy_call_t *)seteuid }, /* 141 = seteuid */
- { 0, (sy_call_t *)nosys }, /* 142 = vtrace */
- { 0, (sy_call_t *)nosys }, /* 143 = { */
- { 0, (sy_call_t *)nosys }, /* 144 = sigtimedwait */
- { 0, (sy_call_t *)nosys }, /* 145 = lwp_info */
- { 0, (sy_call_t *)nosys }, /* 146 = yield */
- { 0, (sy_call_t *)nosys }, /* 147 = lwp_sema_wait */
- { 0, (sy_call_t *)nosys }, /* 148 = lwp_sema_post */
- { 0, (sy_call_t *)nosys }, /* 149 = lwp_sema_trywait */
- { 0, (sy_call_t *)nosys }, /* 150 = notused */
- { 0, (sy_call_t *)nosys }, /* 151 = notused */
- { 0, (sy_call_t *)nosys }, /* 152 = modctl */
- { 1, (sy_call_t *)svr4_sys_fchroot }, /* 153 = svr4_sys_fchroot */
- { 2, (sy_call_t *)svr4_sys_utimes }, /* 154 = svr4_sys_utimes */
- { 0, (sy_call_t *)svr4_sys_vhangup }, /* 155 = svr4_sys_vhangup */
- { 1, (sy_call_t *)svr4_sys_gettimeofday }, /* 156 = svr4_sys_gettimeofday */
- { 2, (sy_call_t *)getitimer }, /* 157 = getitimer */
- { 3, (sy_call_t *)setitimer }, /* 158 = setitimer */
- { 0, (sy_call_t *)nosys }, /* 159 = lwp_create */
- { 0, (sy_call_t *)nosys }, /* 160 = lwp_exit */
- { 0, (sy_call_t *)nosys }, /* 161 = lwp_suspend */
- { 0, (sy_call_t *)nosys }, /* 162 = lwp_continue */
- { 0, (sy_call_t *)nosys }, /* 163 = lwp_kill */
- { 0, (sy_call_t *)nosys }, /* 164 = lwp_self */
- { 0, (sy_call_t *)nosys }, /* 165 = lwp_getprivate */
- { 0, (sy_call_t *)nosys }, /* 166 = lwp_setprivate */
- { 0, (sy_call_t *)nosys }, /* 167 = lwp_wait */
- { 0, (sy_call_t *)nosys }, /* 168 = lwp_mutex_unlock */
- { 0, (sy_call_t *)nosys }, /* 169 = lwp_mutex_lock */
- { 0, (sy_call_t *)nosys }, /* 170 = lwp_cond_wait */
- { 0, (sy_call_t *)nosys }, /* 171 = lwp_cond_signal */
- { 0, (sy_call_t *)nosys }, /* 172 = lwp_cond_broadcast */
- { 0, (sy_call_t *)nosys }, /* 173 = { */
- { 0, (sy_call_t *)nosys }, /* 174 = { */
- { 4, (sy_call_t *)svr4_sys_llseek }, /* 175 = svr4_sys_llseek */
- { 0, (sy_call_t *)nosys }, /* 176 = inst_sync */
- { 0, (sy_call_t *)nosys }, /* 177 = whoknows */
- { 0, (sy_call_t *)nosys }, /* 178 = kaio */
- { 0, (sy_call_t *)nosys }, /* 179 = whoknows */
- { 0, (sy_call_t *)nosys }, /* 180 = whoknows */
- { 0, (sy_call_t *)nosys }, /* 181 = whoknows */
- { 0, (sy_call_t *)nosys }, /* 182 = whoknows */
- { 0, (sy_call_t *)nosys }, /* 183 = whoknows */
- { 0, (sy_call_t *)nosys }, /* 184 = tsolsys */
- { 4, (sy_call_t *)svr4_sys_acl }, /* 185 = svr4_sys_acl */
- { 6, (sy_call_t *)svr4_sys_auditsys }, /* 186 = svr4_sys_auditsys */
- { 0, (sy_call_t *)nosys }, /* 187 = processor_bind */
- { 0, (sy_call_t *)nosys }, /* 188 = processor_info */
- { 0, (sy_call_t *)nosys }, /* 189 = p_online */
- { 0, (sy_call_t *)nosys }, /* 190 = sigqueue */
- { 0, (sy_call_t *)nosys }, /* 191 = clock_gettime */
- { 0, (sy_call_t *)nosys }, /* 192 = clock_settime */
- { 0, (sy_call_t *)nosys }, /* 193 = clock_getres */
- { 0, (sy_call_t *)nosys }, /* 194 = timer_create */
- { 0, (sy_call_t *)nosys }, /* 195 = timer_delete */
- { 0, (sy_call_t *)nosys }, /* 196 = timer_settime */
- { 0, (sy_call_t *)nosys }, /* 197 = timer_gettime */
- { 0, (sy_call_t *)nosys }, /* 198 = timer_overrun */
- { 2, (sy_call_t *)nanosleep }, /* 199 = nanosleep */
- { 4, (sy_call_t *)svr4_sys_facl }, /* 200 = svr4_sys_facl */
- { 0, (sy_call_t *)nosys }, /* 201 = door */
- { 2, (sy_call_t *)setreuid }, /* 202 = setreuid */
- { 2, (sy_call_t *)setregid }, /* 203 = setregid */
- { 0, (sy_call_t *)nosys }, /* 204 = install_utrap */
- { 0, (sy_call_t *)nosys }, /* 205 = signotify */
- { 0, (sy_call_t *)nosys }, /* 206 = schedctl */
- { 0, (sy_call_t *)nosys }, /* 207 = pset */
- { 0, (sy_call_t *)nosys }, /* 208 = whoknows */
- { 3, (sy_call_t *)svr4_sys_resolvepath }, /* 209 = svr4_sys_resolvepath */
- { 0, (sy_call_t *)nosys }, /* 210 = signotifywait */
- { 0, (sy_call_t *)nosys }, /* 211 = lwp_sigredirect */
- { 0, (sy_call_t *)nosys }, /* 212 = lwp_alarm */
- { 3, (sy_call_t *)svr4_sys_getdents64 }, /* 213 = svr4_sys_getdents64 */
- { 6, (sy_call_t *)svr4_sys_mmap64 }, /* 214 = svr4_sys_mmap64 */
- { 2, (sy_call_t *)svr4_sys_stat64 }, /* 215 = svr4_sys_stat64 */
- { 2, (sy_call_t *)svr4_sys_lstat64 }, /* 216 = svr4_sys_lstat64 */
- { 2, (sy_call_t *)svr4_sys_fstat64 }, /* 217 = svr4_sys_fstat64 */
- { 2, (sy_call_t *)svr4_sys_statvfs64 }, /* 218 = svr4_sys_statvfs64 */
- { 2, (sy_call_t *)svr4_sys_fstatvfs64 }, /* 219 = svr4_sys_fstatvfs64 */
- { 2, (sy_call_t *)svr4_sys_setrlimit64 }, /* 220 = svr4_sys_setrlimit64 */
- { 2, (sy_call_t *)svr4_sys_getrlimit64 }, /* 221 = svr4_sys_getrlimit64 */
- { 0, (sy_call_t *)nosys }, /* 222 = pread64 */
- { 0, (sy_call_t *)nosys }, /* 223 = pwrite64 */
- { 2, (sy_call_t *)svr4_sys_creat64 }, /* 224 = svr4_sys_creat64 */
- { 3, (sy_call_t *)svr4_sys_open64 }, /* 225 = svr4_sys_open64 */
- { 0, (sy_call_t *)nosys }, /* 226 = rpcsys */
- { 0, (sy_call_t *)nosys }, /* 227 = whoknows */
- { 0, (sy_call_t *)nosys }, /* 228 = whoknows */
- { 0, (sy_call_t *)nosys }, /* 229 = whoknows */
- { 3, (sy_call_t *)svr4_sys_socket }, /* 230 = svr4_sys_socket */
- { 4, (sy_call_t *)socketpair }, /* 231 = socketpair */
- { 3, (sy_call_t *)bind }, /* 232 = bind */
- { 2, (sy_call_t *)listen }, /* 233 = listen */
- { 3, (sy_call_t *)accept }, /* 234 = accept */
- { 3, (sy_call_t *)connect }, /* 235 = connect */
- { 2, (sy_call_t *)shutdown }, /* 236 = shutdown */
- { 4, (sy_call_t *)svr4_sys_recv }, /* 237 = svr4_sys_recv */
- { 6, (sy_call_t *)recvfrom }, /* 238 = recvfrom */
- { 3, (sy_call_t *)recvmsg }, /* 239 = recvmsg */
- { 4, (sy_call_t *)svr4_sys_send }, /* 240 = svr4_sys_send */
- { 3, (sy_call_t *)sendmsg }, /* 241 = sendmsg */
- { 6, (sy_call_t *)svr4_sys_sendto }, /* 242 = svr4_sys_sendto */
- { 3, (sy_call_t *)getpeername }, /* 243 = getpeername */
- { 3, (sy_call_t *)getsockname }, /* 244 = getsockname */
- { 5, (sy_call_t *)getsockopt }, /* 245 = getsockopt */
- { 5, (sy_call_t *)setsockopt }, /* 246 = setsockopt */
- { 0, (sy_call_t *)nosys }, /* 247 = sockconfig */
- { 0, (sy_call_t *)nosys }, /* 248 = { */
- { 0, (sy_call_t *)nosys }, /* 249 = { */
-};
diff --git a/sys/compat/svr4/svr4_systeminfo.h b/sys/compat/svr4/svr4_systeminfo.h
deleted file mode 100644
index 40bc2b85d757..000000000000
--- a/sys/compat/svr4/svr4_systeminfo.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1994 Christos Zoulas
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _SVR4_SYSTEMINFO_H_
-#define _SVR4_SYSTEMINFO_H_
-
-#define SVR4_SI_SYSNAME 1
-#define SVR4_SI_HOSTNAME 2
-#define SVR4_SI_RELEASE 3
-#define SVR4_SI_VERSION 4
-#define SVR4_SI_MACHINE 5
-#define SVR4_SI_ARCHITECTURE 6
-#define SVR4_SI_HW_SERIAL 7
-#define SVR4_SI_HW_PROVIDER 8
-#define SVR4_SI_SRPC_DOMAIN 9
-#define SVR4_SI_SET_HOSTNAME 258
-#define SVR4_SI_SET_SRPC_DOMAIN 265
-#define SVR4_SI_SET_KERB_REALM 266
-#define SVR4_SI_KERB_REALM 267
-#define SVR4_SI_PLATFORM 513
-#define SVR4_SI_ISALIST 514
-
-#endif /* !_SVR4_SYSTEMINFO_H_ */
diff --git a/sys/compat/svr4/svr4_sysvec.c b/sys/compat/svr4/svr4_sysvec.c
deleted file mode 100644
index b470157123b5..000000000000
--- a/sys/compat/svr4/svr4_sysvec.c
+++ /dev/null
@@ -1,406 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * 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 Christos Zoulas.
- * 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.
- *
- * $FreeBSD$
- */
-
-/* XXX we use functions that might not exist. */
-#include "opt_compat.h"
-
-#ifndef COMPAT_43
-#error "Unable to compile SVR4-emulator due to missing COMPAT_43 option!"
-#endif
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/buf.h>
-#include <sys/proc.h>
-#include <sys/sysent.h>
-#include <sys/imgact.h>
-#include <sys/imgact_elf.h>
-#include <sys/socket.h>
-#include <sys/malloc.h>
-#include <sys/namei.h>
-#include <sys/vnode.h>
-#include <sys/module.h>
-#include <vm/vm.h>
-#include <vm/vm_zone.h>
-#include <sys/exec.h>
-#include <sys/kernel.h>
-#include <machine/cpu.h>
-#include <netinet/in.h>
-
-#include <svr4/svr4.h>
-#include <svr4/svr4_types.h>
-#include <svr4/svr4_syscall.h>
-#include <svr4/svr4_signal.h>
-#include <svr4/svr4_sockio.h>
-#include <svr4/svr4_socket.h>
-#include <svr4/svr4_errno.h>
-#include <svr4/svr4_proto.h>
-#include <svr4/svr4_siginfo.h>
-#include <svr4/svr4_util.h>
-
-int bsd_to_svr4_errno[ELAST+1] = {
- 0,
- SVR4_EPERM,
- SVR4_ENOENT,
- SVR4_ESRCH,
- SVR4_EINTR,
- SVR4_EIO,
- SVR4_ENXIO,
- SVR4_E2BIG,
- SVR4_ENOEXEC,
- SVR4_EBADF,
- SVR4_ECHILD,
- SVR4_EDEADLK,
- SVR4_ENOMEM,
- SVR4_EACCES,
- SVR4_EFAULT,
- SVR4_ENOTBLK,
- SVR4_EBUSY,
- SVR4_EEXIST,
- SVR4_EXDEV,
- SVR4_ENODEV,
- SVR4_ENOTDIR,
- SVR4_EISDIR,
- SVR4_EINVAL,
- SVR4_ENFILE,
- SVR4_EMFILE,
- SVR4_ENOTTY,
- SVR4_ETXTBSY,
- SVR4_EFBIG,
- SVR4_ENOSPC,
- SVR4_ESPIPE,
- SVR4_EROFS,
- SVR4_EMLINK,
- SVR4_EPIPE,
- SVR4_EDOM,
- SVR4_ERANGE,
- SVR4_EAGAIN,
- SVR4_EINPROGRESS,
- SVR4_EALREADY,
- SVR4_ENOTSOCK,
- SVR4_EDESTADDRREQ,
- SVR4_EMSGSIZE,
- SVR4_EPROTOTYPE,
- SVR4_ENOPROTOOPT,
- SVR4_EPROTONOSUPPORT,
- SVR4_ESOCKTNOSUPPORT,
- SVR4_EOPNOTSUPP,
- SVR4_EPFNOSUPPORT,
- SVR4_EAFNOSUPPORT,
- SVR4_EADDRINUSE,
- SVR4_EADDRNOTAVAIL,
- SVR4_ENETDOWN,
- SVR4_ENETUNREACH,
- SVR4_ENETRESET,
- SVR4_ECONNABORTED,
- SVR4_ECONNRESET,
- SVR4_ENOBUFS,
- SVR4_EISCONN,
- SVR4_ENOTCONN,
- SVR4_ESHUTDOWN,
- SVR4_ETOOMANYREFS,
- SVR4_ETIMEDOUT,
- SVR4_ECONNREFUSED,
- SVR4_ELOOP,
- SVR4_ENAMETOOLONG,
- SVR4_EHOSTDOWN,
- SVR4_EHOSTUNREACH,
- SVR4_ENOTEMPTY,
- SVR4_EPROCLIM,
- SVR4_EUSERS,
- SVR4_EDQUOT,
- SVR4_ESTALE,
- SVR4_EREMOTE,
- SVR4_EBADRPC,
- SVR4_ERPCMISMATCH,
- SVR4_EPROGUNAVAIL,
- SVR4_EPROGMISMATCH,
- SVR4_EPROCUNAVAIL,
- SVR4_ENOLCK,
- SVR4_ENOSYS,
- SVR4_EFTYPE,
- SVR4_EAUTH,
- SVR4_ENEEDAUTH,
- SVR4_EIDRM,
- SVR4_ENOMSG,
-};
-
-
-static int svr4_fixup(long **stack_base, struct image_params *imgp);
-
-extern struct sysent svr4_sysent[];
-#undef szsigcode
-#undef sigcode
-
-extern int svr4_szsigcode;
-extern char svr4_sigcode[];
-
-struct sysentvec svr4_sysvec = {
- SVR4_SYS_MAXSYSCALL,
- svr4_sysent,
- 0xff,
- SVR4_SIGTBLSZ,
- bsd_to_svr4_sig,
- ELAST, /* ELAST */
- bsd_to_svr4_errno,
- 0,
- svr4_fixup,
- svr4_sendsig,
- svr4_sigcode,
- &svr4_szsigcode,
- NULL,
- "SVR4",
- elf_coredump
-};
-
-Elf32_Brandinfo svr4_brand = {
- "SVR4",
- "/compat/svr4",
- "/lib/libc.so.1",
- &svr4_sysvec
-};
-
-const char svr4_emul_path[] = "/compat/svr4";
-
-static int
-svr4_fixup(long **stack_base, struct image_params *imgp)
-{
- Elf32_Auxargs *args = (Elf32_Auxargs *)imgp->auxargs;
- long *pos;
-
- pos = *stack_base + (imgp->argc + imgp->envc + 2);
-
- if (args->trace) {
- AUXARGS_ENTRY(pos, AT_DEBUG, 1);
- }
- if (args->execfd != -1) {
- AUXARGS_ENTRY(pos, AT_EXECFD, args->execfd);
- }
- AUXARGS_ENTRY(pos, AT_PHDR, args->phdr);
- AUXARGS_ENTRY(pos, AT_PHENT, args->phent);
- AUXARGS_ENTRY(pos, AT_PHNUM, args->phnum);
- AUXARGS_ENTRY(pos, AT_PAGESZ, args->pagesz);
- AUXARGS_ENTRY(pos, AT_FLAGS, args->flags);
- AUXARGS_ENTRY(pos, AT_ENTRY, args->entry);
- AUXARGS_ENTRY(pos, AT_BASE, args->base);
- AUXARGS_ENTRY(pos, AT_UID, imgp->proc->p_cred->p_ruid);
- AUXARGS_ENTRY(pos, AT_EUID, imgp->proc->p_cred->p_svuid);
- AUXARGS_ENTRY(pos, AT_GID, imgp->proc->p_cred->p_rgid);
- AUXARGS_ENTRY(pos, AT_EGID, imgp->proc->p_cred->p_svgid);
- AUXARGS_ENTRY(pos, AT_NULL, 0);
-
- free(imgp->auxargs, M_TEMP);
- imgp->auxargs = NULL;
-
- (*stack_base)--;
- **stack_base = (int)imgp->argc;
- return 0;
-}
-
-/*
- * Search an alternate path before passing pathname arguments on
- * to system calls. Useful for keeping a seperate 'emulation tree'.
- *
- * If cflag is set, we check if an attempt can be made to create
- * the named file, i.e. we check if the directory it should
- * be in exists.
- *
- * Code shamelessly stolen by Mark Newton from IBCS2 emulation code.
- */
-int
-svr4_emul_find(p, sgp, prefix, path, pbuf, cflag)
- struct proc *p;
- caddr_t *sgp; /* Pointer to stackgap memory */
- const char *prefix;
- char *path;
- char **pbuf;
- int cflag;
-{
- struct nameidata nd;
- struct nameidata ndroot;
- struct vattr vat;
- struct vattr vatroot;
- int error;
- char *ptr, *buf, *cp;
- size_t sz, len;
-
- buf = (char *) malloc(MAXPATHLEN, M_TEMP, M_WAITOK);
- *pbuf = path;
-
- for (ptr = buf; (*ptr = *prefix) != '\0'; ptr++, prefix++)
- continue;
-
- sz = MAXPATHLEN - (ptr - buf);
-
- /*
- * If sgp is not given then the path is already in kernel space
- */
- if (sgp == NULL)
- error = copystr(path, ptr, sz, &len);
- else
- error = copyinstr(path, ptr, sz, &len);
-
- if (error) {
- free(buf, M_TEMP);
- return error;
- }
-
- if (*ptr != '/') {
- free(buf, M_TEMP);
- return EINVAL;
- }
-
- /*
- * We know that there is a / somewhere in this pathname.
- * Search backwards for it, to find the file's parent dir
- * to see if it exists in the alternate tree. If it does,
- * and we want to create a file (cflag is set). We don't
- * need to worry about the root comparison in this case.
- */
-
- if (cflag) {
- for (cp = &ptr[len] - 1; *cp != '/'; cp--);
- *cp = '\0';
-
- NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, buf, p);
-
- if ((error = namei(&nd)) != 0) {
- free(buf, M_TEMP);
- return error;
- }
- NDFREE(&nd, NDF_ONLY_PNBUF);
-
- *cp = '/';
- }
- else {
- NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, buf, p);
-
- if ((error = namei(&nd)) != 0) {
- free(buf, M_TEMP);
- return error;
- }
- NDFREE(&nd, NDF_ONLY_PNBUF);
-
- /*
- * We now compare the vnode of the svr4_root to the one
- * vnode asked. If they resolve to be the same, then we
- * ignore the match so that the real root gets used.
- * This avoids the problem of traversing "../.." to find the
- * root directory and never finding it, because "/" resolves
- * to the emulation root directory. This is expensive :-(
- */
- NDINIT(&ndroot, LOOKUP, FOLLOW, UIO_SYSSPACE, svr4_emul_path,
- p);
-
- if ((error = namei(&ndroot)) != 0) {
- /* Cannot happen! */
- free(buf, M_TEMP);
- vrele(nd.ni_vp);
- return error;
- }
- NDFREE(&ndroot, NDF_ONLY_PNBUF);
-
- if ((error = VOP_GETATTR(nd.ni_vp, &vat, p->p_ucred, p)) != 0) {
- goto done;
- }
-
- if ((error = VOP_GETATTR(ndroot.ni_vp, &vatroot, p->p_ucred, p))
- != 0) {
- goto done;
- }
-
- if (vat.va_fsid == vatroot.va_fsid &&
- vat.va_fileid == vatroot.va_fileid) {
- error = ENOENT;
- goto done;
- }
-
- }
- if (sgp == NULL)
- *pbuf = buf;
- else {
- sz = &ptr[len] - buf;
- *pbuf = stackgap_alloc(sgp, sz + 1);
- error = copyout(buf, *pbuf, sz);
- free(buf, M_TEMP);
- }
-
-
-done:
- vrele(nd.ni_vp);
- if (!cflag)
- vrele(ndroot.ni_vp);
- return error;
-}
-
-static int
-svr4_elf_modevent(module_t mod, int type, void *data)
-{
- int error;
-
- error = 0;
-
- switch(type) {
- case MOD_LOAD:
- if (elf_insert_brand_entry(&svr4_brand) < 0)
- error = EINVAL;
- if (error)
- printf("cannot insert svr4 elf brand handler\n");
- else if (bootverbose)
- printf("svr4 ELF exec handler installed\n");
- break;
- case MOD_UNLOAD:
- /* Only allow the emulator to be removed if it isn't in use. */
- if (elf_brand_inuse(&svr4_brand) != 0) {
- error = EBUSY;
- } else if (elf_remove_brand_entry(&svr4_brand) < 0) {
- error = EINVAL;
- }
-
- if (error)
- printf("Could not deinstall ELF interpreter entry (error %d)\n",
- error);
- else if (bootverbose)
- printf("svr4 ELF exec handler removed\n");
- break;
- default:
- break;
- }
- return error;
-}
-
-static moduledata_t svr4_elf_mod = {
- "svr4elf",
- svr4_elf_modevent,
- 0
-};
-DECLARE_MODULE(svr4elf, svr4_elf_mod, SI_SUB_EXEC, SI_ORDER_ANY);
diff --git a/sys/compat/svr4/svr4_termios.c b/sys/compat/svr4/svr4_termios.c
deleted file mode 100644
index 9b9f0e458f73..000000000000
--- a/sys/compat/svr4/svr4_termios.c
+++ /dev/null
@@ -1,607 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1994 Christos Zoulas
- * 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/proc.h>
-#include <sys/systm.h>
-#include <sys/file.h>
-#include <sys/filedesc.h>
-#include <sys/termios.h>
-
-#include <sys/sysproto.h>
-
-#include <svr4/svr4.h>
-#include <svr4/svr4_util.h>
-#include <svr4/svr4_ioctl.h>
-#include <svr4/svr4_termios.h>
-
-#ifndef __CONCAT3
-# if __STDC__
-# define __CONCAT3(a,b,c) a ## b ## c
-# else
-# define __CONCAT3(a,b,c) a/**/b/**/c
-# endif
-#endif
-
-static u_long bsd_to_svr4_speed __P((u_long, u_long));
-static u_long svr4_to_bsd_speed __P((u_long, u_long));
-static void svr4_to_bsd_termios __P((const struct svr4_termios *,
- struct termios *, int));
-static void bsd_to_svr4_termios __P((const struct termios *,
- struct svr4_termios *));
-static void svr4_termio_to_termios __P((const struct svr4_termio *,
- struct svr4_termios *));
-static void svr4_termios_to_termio __P((const struct svr4_termios *,
- struct svr4_termio *));
-#ifdef DEBUG_SVR4
-static void print_svr4_termios __P((const struct svr4_termios *));
-static void print_bsd_termios __P((const struct termios *));
-#endif /* DEBUG_SVR4 */
-
-#define undefined_char(a,b) /**/
-#define undefined_flag1(f,a,b) /**/
-#define undefined_flag2(f,a,b,c1,t1,c2,t2) /**/
-#define undefined_flag4(f,a,b,c1,t1,c2,t2,c3,t3,c4,t4) /**/
-
-#define svr4_to_bsd_char(a,b) \
- if (new || __CONCAT3(SVR4_,a,b) < SVR4_NCC) { \
- if (st->c_cc[__CONCAT3(SVR4_,a,b)] == SVR4_POSIX_VDISABLE) \
- bt->c_cc[__CONCAT(a,b)] = _POSIX_VDISABLE; \
- else \
- bt->c_cc[__CONCAT(a,b)] = st->c_cc[__CONCAT3(SVR4_,a,b)]; \
- }
-
-#define svr4_to_bsd_flag1(f,a,b) \
- if (new || __CONCAT3(SVR4_,a,b) < 0200000) { \
- if (st->f & __CONCAT3(SVR4_,a,b)) \
- bt->f |= __CONCAT(a,b); \
- else \
- bt->f &= ~__CONCAT(a,b); \
- }
-
-#define svr4_to_bsd_flag2(f,a,b,c1,t1,c2,t2) \
- if (new || __CONCAT3(SVR4_,a,b) < 0200000) { \
- bt->f &= ~__CONCAT(a,b); \
- switch (st->f & __CONCAT3(SVR4_,a,b)) { \
- case __CONCAT3(SVR4_,c1,t1): bt->f |= __CONCAT(c1,t1); break; \
- case __CONCAT3(SVR4_,c2,t2): bt->f |= __CONCAT(c2,t2); break; \
- } \
- }
-
-#define svr4_to_bsd_flag4(f,a,b,c1,t1,c2,t2,c3,t3,c4,t4) \
- if (new || __CONCAT3(SVR4_,a,b) < 0200000) { \
- bt->f &= ~__CONCAT(a,b); \
- switch (st->f & __CONCAT3(SVR4_,a,b)) { \
- case __CONCAT3(SVR4_,c1,t1): bt->f |= __CONCAT(c1,t1); break; \
- case __CONCAT3(SVR4_,c2,t2): bt->f |= __CONCAT(c2,t2); break; \
- case __CONCAT3(SVR4_,c3,t3): bt->f |= __CONCAT(c3,t3); break; \
- case __CONCAT3(SVR4_,c4,t4): bt->f |= __CONCAT(c4,t4); break; \
- } \
- }
-
-
-#define bsd_to_svr4_char(a,b) \
- if (bt->c_cc[__CONCAT(a,b)] == _POSIX_VDISABLE) \
- st->c_cc[__CONCAT3(SVR4_,a,b)] = SVR4_POSIX_VDISABLE; \
- else \
- st->c_cc[__CONCAT3(SVR4_,a,b)] = bt->c_cc[__CONCAT(a,b)]
-
-#define bsd_to_svr4_flag1(f,a,b) \
- if (bt->f & __CONCAT(a,b)) \
- st->f |= __CONCAT3(SVR4_,a,b); \
- else \
- st->f &= ~__CONCAT3(SVR4_,a,b)
-
-#define bsd_to_svr4_flag2(f,a,b,c1,t1,c2,t2) \
- st->f &= ~__CONCAT(a,b); \
- switch (bt->f & __CONCAT(a,b)) { \
- case __CONCAT(c1,t1): st->f |= __CONCAT3(SVR4_,c1,t1); break; \
- case __CONCAT(c2,t2): st->f |= __CONCAT3(SVR4_,c2,t2); break; \
- }
-
-#define bsd_to_svr4_flag4(f,a,b,c1,t1,c2,t2,c3,t3,c4,t4) \
- st->f &= ~__CONCAT(a,b); \
- switch (bt->f & __CONCAT(a,b)) { \
- case __CONCAT(c1,t1): st->f |= __CONCAT3(SVR4_,c1,t1); break; \
- case __CONCAT(c2,t2): st->f |= __CONCAT3(SVR4_,c2,t2); break; \
- case __CONCAT(c3,t3): st->f |= __CONCAT3(SVR4_,c3,t3); break; \
- case __CONCAT(c4,t4): st->f |= __CONCAT3(SVR4_,c4,t4); break; \
- }
-
-#ifdef DEBUG_SVR4
-static void
-print_svr4_termios(st)
- const struct svr4_termios *st;
-{
- int i;
- DPRINTF(("SVR4\niflag=%lo oflag=%lo cflag=%lo lflag=%lo\n",
- st->c_iflag, st->c_oflag, st->c_cflag, st->c_lflag));
- DPRINTF(("cc: "));
- for (i = 0; i < SVR4_NCCS; i++)
- DPRINTF(("%o ", st->c_cc[i]));
- DPRINTF(("\n"));
-}
-
-
-static void
-print_bsd_termios(bt)
- const struct termios *bt;
-{
- int i;
- uprintf("BSD\niflag=%o oflag=%o cflag=%o lflag=%o\n",
- bt->c_iflag, bt->c_oflag, bt->c_cflag, bt->c_lflag);
- uprintf("cc: ");
- for (i = 0; i < NCCS; i++)
- uprintf("%o ", bt->c_cc[i]);
- uprintf("\n");
-}
-#endif /* DEBUG_SVR4 */
-
-static u_long
-bsd_to_svr4_speed(sp, mask)
- u_long sp;
- u_long mask;
-{
- switch (sp) {
-#undef getval
-#define getval(a,b) case __CONCAT(a,b): sp = __CONCAT3(SVR4_,a,b)
- getval(B,0);
- getval(B,50);
- getval(B,75);
- getval(B,110);
- getval(B,134);
- getval(B,150);
- getval(B,200);
- getval(B,300);
- getval(B,600);
- getval(B,1200);
- getval(B,1800);
- getval(B,2400);
- getval(B,4800);
- getval(B,9600);
- getval(B,19200);
- getval(B,38400);
- getval(B,57600);
- getval(B,115200);
- default: sp = SVR4_B9600; /* XXX */
- }
-
- while ((mask & 1) == 0) {
- mask >>= 1;
- sp <<= 1;
- }
-
- return sp;
-}
-
-
-static u_long
-svr4_to_bsd_speed(sp, mask)
- u_long sp;
- u_long mask;
-{
- while ((mask & 1) == 0) {
- mask >>= 1;
- sp >>= 1;
- }
-
- switch (sp & mask) {
-#undef getval
-#define getval(a,b) case __CONCAT3(SVR4_,a,b): return __CONCAT(a,b)
- getval(B,0);
- getval(B,50);
- getval(B,75);
- getval(B,110);
- getval(B,134);
- getval(B,150);
- getval(B,200);
- getval(B,300);
- getval(B,600);
- getval(B,1200);
- getval(B,1800);
- getval(B,2400);
- getval(B,4800);
- getval(B,9600);
- getval(B,19200);
- getval(B,38400);
- getval(B,57600);
- getval(B,115200);
- default: return B9600; /* XXX */
- }
-}
-
-
-static void
-svr4_to_bsd_termios(st, bt, new)
- const struct svr4_termios *st;
- struct termios *bt;
- int new;
-{
- /* control characters */
- /*
- * We process VMIN and VTIME first,
- * because they are shared with VEOF and VEOL
- */
- svr4_to_bsd_char(V,MIN);
- svr4_to_bsd_char(V,TIME);
-
- svr4_to_bsd_char(V,INTR);
- svr4_to_bsd_char(V,QUIT);
- svr4_to_bsd_char(V,ERASE);
- svr4_to_bsd_char(V,KILL);
- svr4_to_bsd_char(V,EOF);
- svr4_to_bsd_char(V,EOL);
- svr4_to_bsd_char(V,EOL2);
- undefined_char(V,SWTCH);
- svr4_to_bsd_char(V,START);
- svr4_to_bsd_char(V,STOP);
- svr4_to_bsd_char(V,SUSP);
- svr4_to_bsd_char(V,DSUSP);
- svr4_to_bsd_char(V,REPRINT);
- svr4_to_bsd_char(V,DISCARD);
- svr4_to_bsd_char(V,WERASE);
- svr4_to_bsd_char(V,LNEXT);
-
- /* Input modes */
- svr4_to_bsd_flag1(c_iflag,I,GNBRK);
- svr4_to_bsd_flag1(c_iflag,B,RKINT);
- svr4_to_bsd_flag1(c_iflag,I,GNPAR);
- svr4_to_bsd_flag1(c_iflag,P,ARMRK);
- svr4_to_bsd_flag1(c_iflag,I,NPCK);
- svr4_to_bsd_flag1(c_iflag,I,STRIP);
- svr4_to_bsd_flag1(c_iflag,I,NLCR);
- svr4_to_bsd_flag1(c_iflag,I,GNCR);
- svr4_to_bsd_flag1(c_iflag,I,CRNL);
- undefined_flag1(c_iflag,I,UCLC);
- svr4_to_bsd_flag1(c_iflag,I,XON);
- svr4_to_bsd_flag1(c_iflag,I,XANY);
- svr4_to_bsd_flag1(c_iflag,I,XOFF);
- svr4_to_bsd_flag1(c_iflag,I,MAXBEL);
- undefined_flag1(c_iflag,D,OSMODE);
-
- /* Output modes */
- svr4_to_bsd_flag1(c_oflag,O,POST);
- undefined_flag1(c_oflag,O,LCUC);
- svr4_to_bsd_flag1(c_oflag,O,NLCR);
- undefined_flag1(c_oflag,O,CRNL);
- undefined_flag1(c_oflag,O,NOCR);
- undefined_flag1(c_oflag,O,NLRET);
- undefined_flag1(c_oflag,O,FILL);
- undefined_flag1(c_oflag,O,FDEL);
- undefined_flag2(c_oflag,N,LDLY,N,L0,N,L1);
- undefined_flag4(c_oflag,C,RDLY,C,R0,C,R1,C,R2,C,R3);
- undefined_flag4(c_oflag,T,ABDLY,T,AB0,T,AB1,T,AB2,T,AB3);
- undefined_flag2(c_oflag,B,SDLY,B,S0,B,S1);
- undefined_flag2(c_oflag,V,TDLY,V,T0,V,T1);
- undefined_flag2(c_oflag,F,FDLY,F,F0,F,F1);
- undefined_flag1(c_oflag,P,AGEOUT);
- undefined_flag1(c_oflag,W,RAP);
-
- /* Control modes */
- bt->c_ospeed = svr4_to_bsd_speed(st->c_cflag, SVR4_CBAUD);
- svr4_to_bsd_flag4(c_cflag,C,SIZE,C,S5,C,S6,C,S7,C,S8)
- svr4_to_bsd_flag1(c_cflag,C,STOPB);
- svr4_to_bsd_flag1(c_cflag,C,READ);
- svr4_to_bsd_flag1(c_cflag,P,ARENB);
- svr4_to_bsd_flag1(c_cflag,P,ARODD);
- svr4_to_bsd_flag1(c_cflag,H,UPCL);
- svr4_to_bsd_flag1(c_cflag,C,LOCAL);
- undefined_flag1(c_cflag,R,CV1EN);
- undefined_flag1(c_cflag,X,MT1EN);
- undefined_flag1(c_cflag,L,OBLK);
- undefined_flag1(c_cflag,X,CLUDE);
- bt->c_ispeed = svr4_to_bsd_speed(st->c_cflag, SVR4_CIBAUD);
- undefined_flag1(c_cflag,P,AREXT);
-
- /* line discipline modes */
- svr4_to_bsd_flag1(c_lflag,I,SIG);
- svr4_to_bsd_flag1(c_lflag,I,CANON);
- undefined_flag1(c_lflag,X,CASE);
- svr4_to_bsd_flag1(c_lflag,E,CHO);
- svr4_to_bsd_flag1(c_lflag,E,CHOE);
- svr4_to_bsd_flag1(c_lflag,E,CHOK);
- svr4_to_bsd_flag1(c_lflag,E,CHONL);
- svr4_to_bsd_flag1(c_lflag,N,OFLSH);
- svr4_to_bsd_flag1(c_lflag,T,OSTOP);
- svr4_to_bsd_flag1(c_lflag,E,CHOCTL);
- svr4_to_bsd_flag1(c_lflag,E,CHOPRT);
- svr4_to_bsd_flag1(c_lflag,E,CHOKE);
- undefined_flag1(c_lflag,D,EFECHO);
- svr4_to_bsd_flag1(c_lflag,F,LUSHO);
- svr4_to_bsd_flag1(c_lflag,P,ENDIN);
- svr4_to_bsd_flag1(c_lflag,I,EXTEN);
-}
-
-
-static void
-bsd_to_svr4_termios(bt, st)
- const struct termios *bt;
- struct svr4_termios *st;
-{
- /* control characters */
- /*
- * We process VMIN and VTIME first,
- * because they are shared with VEOF and VEOL
- */
- bsd_to_svr4_char(V,MIN);
- bsd_to_svr4_char(V,TIME);
- bsd_to_svr4_char(V,INTR);
- bsd_to_svr4_char(V,QUIT);
- bsd_to_svr4_char(V,ERASE);
- bsd_to_svr4_char(V,KILL);
- bsd_to_svr4_char(V,EOF);
- bsd_to_svr4_char(V,EOL);
- bsd_to_svr4_char(V,EOL2);
- undefined_char(V,SWTCH);
- bsd_to_svr4_char(V,START);
- bsd_to_svr4_char(V,STOP);
- bsd_to_svr4_char(V,SUSP);
- bsd_to_svr4_char(V,DSUSP);
- bsd_to_svr4_char(V,REPRINT);
- bsd_to_svr4_char(V,DISCARD);
- bsd_to_svr4_char(V,WERASE);
- bsd_to_svr4_char(V,LNEXT);
-
- /* Input modes */
- bsd_to_svr4_flag1(c_iflag,I,GNBRK);
- bsd_to_svr4_flag1(c_iflag,B,RKINT);
- bsd_to_svr4_flag1(c_iflag,I,GNPAR);
- bsd_to_svr4_flag1(c_iflag,P,ARMRK);
- bsd_to_svr4_flag1(c_iflag,I,NPCK);
- bsd_to_svr4_flag1(c_iflag,I,STRIP);
- bsd_to_svr4_flag1(c_iflag,I,NLCR);
- bsd_to_svr4_flag1(c_iflag,I,GNCR);
- bsd_to_svr4_flag1(c_iflag,I,CRNL);
- undefined_flag1(c_iflag,I,UCLC);
- bsd_to_svr4_flag1(c_iflag,I,XON);
- bsd_to_svr4_flag1(c_iflag,I,XANY);
- bsd_to_svr4_flag1(c_iflag,I,XOFF);
- bsd_to_svr4_flag1(c_iflag,I,MAXBEL);
- undefined_flag1(c_iflag,D,OSMODE);
-
- /* Output modes */
- bsd_to_svr4_flag1(c_oflag,O,POST);
- undefined_flag1(c_oflag,O,LCUC);
- bsd_to_svr4_flag1(c_oflag,O,NLCR);
- undefined_flag1(c_oflag,O,CRNL);
- undefined_flag1(c_oflag,O,NOCR);
- undefined_flag1(c_oflag,O,NLRET);
- undefined_flag1(c_oflag,O,FILL);
- undefined_flag1(c_oflag,O,FDEL);
- undefined_flag2(c_oflag,N,LDLY,N,L0,N,L1);
- undefined_flag4(c_oflag,C,RDLY,C,R0,C,R1,C,R2,C,R3);
- undefined_flag4(c_oflag,T,ABDLY,T,AB0,T,AB1,T,AB2,T,AB3);
- undefined_flag2(c_oflag,B,SDLY,B,S0,B,S1);
- undefined_flag2(c_oflag,V,TDLY,V,T0,V,T1);
- undefined_flag2(c_oflag,F,FDLY,F,F0,F,F1);
- undefined_flag1(c_oflag,P,AGEOUT);
- undefined_flag1(c_oflag,W,RAP);
-
- /* Control modes */
- st->c_cflag &= ~SVR4_CBAUD;
- st->c_cflag |= bsd_to_svr4_speed(bt->c_ospeed, SVR4_CBAUD);
- bsd_to_svr4_flag4(c_cflag,C,SIZE,C,S5,C,S6,C,S7,C,S8)
- bsd_to_svr4_flag1(c_cflag,C,STOPB);
- bsd_to_svr4_flag1(c_cflag,C,READ);
- bsd_to_svr4_flag1(c_cflag,P,ARENB);
- bsd_to_svr4_flag1(c_cflag,P,ARODD);
- bsd_to_svr4_flag1(c_cflag,H,UPCL);
- bsd_to_svr4_flag1(c_cflag,C,LOCAL);
- undefined_flag1(c_cflag,R,CV1EN);
- undefined_flag1(c_cflag,X,MT1EN);
- undefined_flag1(c_cflag,L,OBLK);
- undefined_flag1(c_cflag,X,CLUDE);
- st->c_cflag &= ~SVR4_CIBAUD;
- st->c_cflag |= bsd_to_svr4_speed(bt->c_ispeed, SVR4_CIBAUD);
-
- undefined_flag1(c_oflag,P,AREXT);
-
- /* line discipline modes */
- bsd_to_svr4_flag1(c_lflag,I,SIG);
- bsd_to_svr4_flag1(c_lflag,I,CANON);
- undefined_flag1(c_lflag,X,CASE);
- bsd_to_svr4_flag1(c_lflag,E,CHO);
- bsd_to_svr4_flag1(c_lflag,E,CHOE);
- bsd_to_svr4_flag1(c_lflag,E,CHOK);
- bsd_to_svr4_flag1(c_lflag,E,CHONL);
- bsd_to_svr4_flag1(c_lflag,N,OFLSH);
- bsd_to_svr4_flag1(c_lflag,T,OSTOP);
- bsd_to_svr4_flag1(c_lflag,E,CHOCTL);
- bsd_to_svr4_flag1(c_lflag,E,CHOPRT);
- bsd_to_svr4_flag1(c_lflag,E,CHOKE);
- undefined_flag1(c_lflag,D,EFECHO);
- bsd_to_svr4_flag1(c_lflag,F,LUSHO);
- bsd_to_svr4_flag1(c_lflag,P,ENDIN);
- bsd_to_svr4_flag1(c_lflag,I,EXTEN);
-}
-
-
-static void
-svr4_termio_to_termios(t, ts)
- const struct svr4_termio *t;
- struct svr4_termios *ts;
-{
- int i;
-
- ts->c_iflag = (svr4_tcflag_t) t->c_iflag;
- ts->c_oflag = (svr4_tcflag_t) t->c_oflag;
- ts->c_cflag = (svr4_tcflag_t) t->c_cflag;
- ts->c_lflag = (svr4_tcflag_t) t->c_lflag;
-
- for (i = 0; i < SVR4_NCC; i++)
- ts->c_cc[i] = (svr4_cc_t) t->c_cc[i];
-}
-
-
-static void
-svr4_termios_to_termio(ts, t)
- const struct svr4_termios *ts;
- struct svr4_termio *t;
-{
- int i;
-
- t->c_iflag = (u_short) ts->c_iflag;
- t->c_oflag = (u_short) ts->c_oflag;
- t->c_cflag = (u_short) ts->c_cflag;
- t->c_lflag = (u_short) ts->c_lflag;
- t->c_line = 0; /* XXX */
-
- for (i = 0; i < SVR4_NCC; i++)
- t->c_cc[i] = (u_char) ts->c_cc[i];
-}
-
-int
-svr4_term_ioctl(fp, p, retval, fd, cmd, data)
- struct file *fp;
- struct proc *p;
- register_t *retval;
- int fd;
- u_long cmd;
- caddr_t data;
-{
- struct termios bt;
- struct svr4_termios st;
- struct svr4_termio t;
- int error, new;
-
- *retval = 0;
-
- DPRINTF(("TERM ioctl %x\n", cmd));
-
- switch (cmd) {
- case SVR4_TCGETA:
- case SVR4_TCGETS:
- DPRINTF(("ioctl(TCGET%c);\n", cmd == SVR4_TCGETA ? 'A' : 'S'));
- if ((error = fo_ioctl(fp, TIOCGETA, (caddr_t) &bt, p)) != 0)
- return error;
-
- memset(&st, 0, sizeof(st));
- bsd_to_svr4_termios(&bt, &st);
-
-#ifdef DEBUG_SVR4
- print_bsd_termios(&bt);
- print_svr4_termios(&st);
-#endif /* DEBUG_SVR4 */
-
- if (cmd == SVR4_TCGETA) {
- svr4_termios_to_termio(&st, &t);
- return copyout(&t, data, sizeof(t));
- }
- else {
- return copyout(&st, data, sizeof(st));
- }
-
- case SVR4_TCSETA:
- case SVR4_TCSETS:
- case SVR4_TCSETAW:
- case SVR4_TCSETSW:
- case SVR4_TCSETAF:
- case SVR4_TCSETSF:
- DPRINTF(("TCSET{A,S,AW,SW,AF,SF}\n"));
- /* get full BSD termios so we don't lose information */
- if ((error = fo_ioctl(fp, TIOCGETA, (caddr_t) &bt, p)) != 0)
- return error;
-
- switch (cmd) {
- case SVR4_TCSETS:
- case SVR4_TCSETSW:
- case SVR4_TCSETSF:
- if ((error = copyin(data, &st, sizeof(st))) != 0)
- return error;
- new = 1;
- break;
-
- case SVR4_TCSETA:
- case SVR4_TCSETAW:
- case SVR4_TCSETAF:
- if ((error = copyin(data, &t, sizeof(t))) != 0)
- return error;
-
- svr4_termio_to_termios(&t, &st);
- new = 0;
- break;
-
- default:
- return EINVAL;
- }
-
- svr4_to_bsd_termios(&st, &bt, new);
-
- switch (cmd) {
- case SVR4_TCSETA:
- case SVR4_TCSETS:
- DPRINTF(("ioctl(TCSET[A|S]);\n"));
- cmd = TIOCSETA;
- break;
- case SVR4_TCSETAW:
- case SVR4_TCSETSW:
- DPRINTF(("ioctl(TCSET[A|S]W);\n"));
- cmd = TIOCSETAW;
- break;
- case SVR4_TCSETAF:
- case SVR4_TCSETSF:
- DPRINTF(("ioctl(TCSET[A|S]F);\n"));
- cmd = TIOCSETAF;
- break;
- }
-
-#ifdef DEBUG_SVR4
- print_bsd_termios(&bt);
- print_svr4_termios(&st);
-#endif /* DEBUG_SVR4 */
-
- return fo_ioctl(fp, cmd, (caddr_t) &bt, p);
-
- case SVR4_TIOCGWINSZ:
- DPRINTF(("TIOCGWINSZ\n"));
- {
- struct svr4_winsize ws;
-
- error = fo_ioctl(fp, TIOCGWINSZ, (caddr_t) &ws, p);
- if (error)
- return error;
- return copyout(&ws, data, sizeof(ws));
- }
-
- case SVR4_TIOCSWINSZ:
- DPRINTF(("TIOCSWINSZ\n"));
- {
- struct svr4_winsize ws;
-
- if ((error = copyin(data, &ws, sizeof(ws))) != 0)
- return error;
- return fo_ioctl(fp, TIOCSWINSZ, (caddr_t) &ws, p);
- }
-
- default:
- DPRINTF(("teleport to STREAMS ioctls...\n"));
- return svr4_stream_ti_ioctl(fp, p, retval, fd, cmd, data);
- }
-}
diff --git a/sys/compat/svr4/svr4_termios.h b/sys/compat/svr4/svr4_termios.h
deleted file mode 100644
index 8afa4f321bc3..000000000000
--- a/sys/compat/svr4/svr4_termios.h
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1994 Christos Zoulas
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _SVR4_TERMIOS_H_
-#define _SVR4_TERMIOS_H_
-
-#define SVR4_POSIX_VDISABLE 0
-#define SVR4_NCC 8
-#define SVR4_NCCS 19
-
-typedef u_long svr4_tcflag_t;
-typedef u_char svr4_cc_t;
-typedef u_long svr4_speed_t;
-
-struct svr4_termios {
- svr4_tcflag_t c_iflag;
- svr4_tcflag_t c_oflag;
- svr4_tcflag_t c_cflag;
- svr4_tcflag_t c_lflag;
- svr4_cc_t c_cc[SVR4_NCCS];
-};
-
-struct svr4_termio {
- u_short c_iflag;
- u_short c_oflag;
- u_short c_cflag;
- u_short c_lflag;
- char c_line;
- u_char c_cc[SVR4_NCC];
-};
-
-/* control characters */
-#define SVR4_VINTR 0
-#define SVR4_VQUIT 1
-#define SVR4_VERASE 2
-#define SVR4_VKILL 3
-#define SVR4_VEOF 4
-#define SVR4_VEOL 5
-#define SVR4_VEOL2 6
-#define SVR4_VMIN 4
-#define SVR4_VTIME 5
-#define SVR4_VSWTCH 7
-#define SVR4_VSTART 8
-#define SVR4_VSTOP 9
-#define SVR4_VSUSP 10
-#define SVR4_VDSUSP 11
-#define SVR4_VREPRINT 12
-#define SVR4_VDISCARD 13
-#define SVR4_VWERASE 14
-#define SVR4_VLNEXT 15
-
-/* Input modes */
-#define SVR4_IGNBRK 00000001
-#define SVR4_BRKINT 00000002
-#define SVR4_IGNPAR 00000004
-#define SVR4_PARMRK 00000010
-#define SVR4_INPCK 00000020
-#define SVR4_ISTRIP 00000040
-#define SVR4_INLCR 00000100
-#define SVR4_IGNCR 00000200
-#define SVR4_ICRNL 00000400
-#define SVR4_IUCLC 00001000
-#define SVR4_IXON 00002000
-#define SVR4_IXANY 00004000
-#define SVR4_IXOFF 00010000
-#define SVR4_IMAXBEL 00020000
-#define SVR4_DOSMODE 00100000
-
-/* Output modes */
-#define SVR4_OPOST 00000001
-#define SVR4_OLCUC 00000002
-#define SVR4_ONLCR 00000004
-#define SVR4_OCRNL 00000010
-#define SVR4_ONOCR 00000020
-#define SVR4_ONLRET 00000040
-#define SVR4_OFILL 00000100
-#define SVR4_OFDEL 00000200
-#define SVR4_NLDLY 00000400
-#define SVR4_NL0 00000000
-#define SVR4_NL1 00000400
-#define SVR4_CRDLY 00003000
-#define SVR4_CR0 00000000
-#define SVR4_CR1 00001000
-#define SVR4_CR2 00002000
-#define SVR4_CR3 00003000
-#define SVR4_TABDLY 00014000
-#define SVR4_TAB0 00000000
-#define SVR4_TAB1 00004000
-#define SVR4_TAB2 00010000
-#define SVR4_TAB3 00014000
-#define SVR4_XTABS 00014000
-#define SVR4_BSDLY 00020000
-#define SVR4_BS0 00000000
-#define SVR4_BS1 00020000
-#define SVR4_VTDLY 00040000
-#define SVR4_VT0 00000000
-#define SVR4_VT1 00040000
-#define SVR4_FFDLY 00100000
-#define SVR4_FF0 00000000
-#define SVR4_FF1 00100000
-#define SVR4_PAGEOUT 00200000
-#define SVR4_WRAP 00400000
-
-/* Control modes */
-#define SVR4_CBAUD 00000017
-#define SVR4_CSIZE 00000060
-#define SVR4_CS5 00000000
-#define SVR4_CS6 00000200
-#define SVR4_CS7 00000040
-#define SVR4_CS8 00000006
-#define SVR4_CSTOPB 00000100
-#define SVR4_CREAD 00000200
-#define SVR4_PARENB 00000400
-#define SVR4_PARODD 00001000
-#define SVR4_HUPCL 00002000
-#define SVR4_CLOCAL 00004000
-#define SVR4_RCV1EN 00010000
-#define SVR4_XMT1EN 00020000
-#define SVR4_LOBLK 00040000
-#define SVR4_XCLUDE 00100000
-#define SVR4_CIBAUD 03600000
-#define SVR4_PAREXT 04000000
-
-/* line discipline modes */
-#define SVR4_ISIG 00000001
-#define SVR4_ICANON 00000002
-#define SVR4_XCASE 00000004
-#define SVR4_ECHO 00000010
-#define SVR4_ECHOE 00000020
-#define SVR4_ECHOK 00000040
-#define SVR4_ECHONL 00000100
-#define SVR4_NOFLSH 00000200
-#define SVR4_TOSTOP 00000400
-#define SVR4_ECHOCTL 00001000
-#define SVR4_ECHOPRT 00002000
-#define SVR4_ECHOKE 00004000
-#define SVR4_DEFECHO 00010000
-#define SVR4_FLUSHO 00020000
-#define SVR4_PENDIN 00040000
-#define SVR4_IEXTEN 00100000
-
-#define SVR4_TIOC ('T' << 8)
-
-#define SVR4_TCGETA (SVR4_TIOC| 1)
-#define SVR4_TCSETA (SVR4_TIOC| 2)
-#define SVR4_TCSETAW (SVR4_TIOC| 3)
-#define SVR4_TCSETAF (SVR4_TIOC| 4)
-#define SVR4_TCSBRK (SVR4_TIOC| 5)
-#define SVR4_TCXONC (SVR4_TIOC| 6)
-#define SVR4_TCFLSH (SVR4_TIOC| 7)
-#define SVR4_TIOCKBON (SVR4_TIOC| 8)
-#define SVR4_TIOCKBOF (SVR4_TIOC| 9)
-#define SVR4_KBENABLED (SVR4_TIOC|10)
-#define SVR4_TCGETS (SVR4_TIOC|13)
-#define SVR4_TCSETS (SVR4_TIOC|14)
-#define SVR4_TCSETSW (SVR4_TIOC|15)
-#define SVR4_TCSETSF (SVR4_TIOC|16)
-#define SVR4_TCDSET (SVR4_TIOC|32)
-#define SVR4_RTS_TOG (SVR4_TIOC|33)
-#define SVR4_TCGETSC (SVR4_TIOC|34)
-#define SVR4_TCSETSC (SVR4_TIOC|35)
-#define SVR4_TCMOUSE (SVR4_TIOC|36)
-#define SVR4_TIOCGWINSZ (SVR4_TIOC|104)
-#define SVR4_TIOCSWINSZ (SVR4_TIOC|103)
-
-struct svr4_winsize {
- u_short ws_row;
- u_short ws_col;
- u_short ws_xpixel;
- u_short ws_ypixel;
-};
-
-#define SVR4_B0 0
-#define SVR4_B50 1
-#define SVR4_B75 2
-#define SVR4_B110 3
-#define SVR4_B134 4
-#define SVR4_B150 5
-#define SVR4_B200 6
-#define SVR4_B300 7
-#define SVR4_B600 8
-#define SVR4_B1200 9
-#define SVR4_B1800 10
-#define SVR4_B2400 11
-#define SVR4_B4800 12
-#define SVR4_B9600 13
-#define SVR4_B19200 14
-#define SVR4_B38400 15
-#define SVR4_B57600 16
-#define SVR4_B76800 17
-#define SVR4_B115200 18
-#define SVR4_B153600 19
-#define SVR4_B230400 20
-#define SVR4_B307200 21
-#define SVR4_B460800 22
-
-#endif /* !_SVR4_TERMIOS_H_ */
diff --git a/sys/compat/svr4/svr4_time.h b/sys/compat/svr4/svr4_time.h
deleted file mode 100644
index 3d61771fc904..000000000000
--- a/sys/compat/svr4/svr4_time.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1994 Christos Zoulas
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _SVR4_TIME_H_
-#define _SVR4_TIME_H_
-
-#include <sys/time.h>
-
-struct svr4_utimbuf {
- time_t actime;
- time_t modtime;
-};
-
-#endif /* !_SVR4_TIME_H_ */
diff --git a/sys/compat/svr4/svr4_timod.h b/sys/compat/svr4/svr4_timod.h
deleted file mode 100644
index f0c508f511b8..000000000000
--- a/sys/compat/svr4/svr4_timod.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1994 Christos Zoulas
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _SVR4_TIMOD_H_
-#define _SVR4_TIMOD_H_
-
-#define SVR4_TIMOD ('T' << 8)
-#define SVR4_TI_GETINFO (SVR4_TIMOD|140)
-#define SVR4_TI_OPTMGMT (SVR4_TIMOD|141)
-#define SVR4_TI_BIND (SVR4_TIMOD|142)
-#define SVR4_TI_UNBIND (SVR4_TIMOD|143)
-#define SVR4_TI_GETMYNAME (SVR4_TIMOD|144)
-#define SVR4_TI_GETPEERNAME (SVR4_TIMOD|145)
-#define SVR4_TI_SETMYNAME (SVR4_TIMOD|146)
-#define SVR4_TI_SETPEERNAME (SVR4_TIMOD|147)
-#define SVR4_TI_SYNC (SVR4_TIMOD|148)
-#define SVR4_TI_GETADDRS (SVR4_TIMOD|149)
-
-#define SVR4_TI_CONNECT_REQUEST 0x00
-#define SVR4_TI_CONNECT_RESPONSE 0x01
-#define SVR4_TI_DISCONNECT_REQUEST 0x02
-#define SVR4_TI_DATA_REQUEST 0x03
-#define SVR4_TI_EXPDATA_REQUEST 0x04
-#define SVR4_TI_INFO_REQUEST 0x05
-#define SVR4_TI_OLD_BIND_REQUEST 0x06
-#define SVR4_TI_UNBIND_REQUEST 0x07
-#define SVR4_TI_SENDTO_REQUEST 0x08
-#define SVR4_TI_OLD_OPTMGMT_REQUEST 0x09
-#define SVR4_TI_ORDREL_REQUEST 0x0a
-
-#define SVR4_TI_ACCEPT_REPLY 0x0b
-#define SVR4_TI_CONNECT_REPLY 0x0c
-#define SVR4_TI_DISCONNECT_IND 0x0d
-#define SVR4_TI_DATA_IND 0x0e
-#define SVR4_TI_EXPDATA_IND 0x0f
-#define SVR4_TI_INFO_REPLY 0x10
-#define SVR4_TI_BIND_REPLY 0x11
-#define SVR4_TI_ERROR_REPLY 0x12
-#define SVR4_TI_OK_REPLY 0x13
-#define SVR4_TI_RECVFROM_IND 0x14
-#define SVR4_TI_RECVFROM_ERROR_IND 0x15
-#define SVR4_TI_OPTMGMT_REPLY 0x16
-#define SVR4_TI_ORDREL_IND 0x17
-
-#define SVR4_TI_ADDRESS_REQUEST 0x18
-#define SVR4_TI_ADDRESS_REPLY 0x19
-
-#define SVR4_TI_BIND_REQUEST 0x20
-#define SVR4_TI_OPTMGMT_REQUEST 0x21
-
-#define SVR4_TI__ACCEPT_WAIT 0x10000001
-#define SVR4_TI__ACCEPT_OK 0x10000002
-
-struct svr4_netbuf {
- u_int maxlen;
- u_int len;
- char *buf;
-};
-
-#endif /* !_SVR4_TIMOD_H_ */
diff --git a/sys/compat/svr4/svr4_ttold.c b/sys/compat/svr4/svr4_ttold.c
deleted file mode 100644
index 7684487e31af..000000000000
--- a/sys/compat/svr4/svr4_ttold.c
+++ /dev/null
@@ -1,366 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1994 Christos Zoulas
- * 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/proc.h>
-#include <sys/systm.h>
-#include <sys/file.h>
-#include <sys/filedesc.h>
-#include <sys/ioctl_compat.h>
-#include <sys/termios.h>
-
-#include <svr4/svr4.h>
-#include <svr4/svr4_util.h>
-#include <svr4/svr4_ttold.h>
-#include <svr4/svr4_ioctl.h>
-
-
-static void svr4_tchars_to_bsd_tchars __P((const struct svr4_tchars *st,
- struct tchars *bt));
-static void bsd_tchars_to_svr4_tchars __P((const struct tchars *bt,
- struct svr4_tchars *st));
-static void svr4_sgttyb_to_bsd_sgttyb __P((const struct svr4_sgttyb *ss,
- struct sgttyb *bs));
-static void bsd_sgttyb_to_svr4_sgttyb __P((const struct sgttyb *bs,
- struct svr4_sgttyb *ss));
-static void svr4_ltchars_to_bsd_ltchars __P((const struct svr4_ltchars *sl,
- struct ltchars *bl));
-static void bsd_ltchars_to_svr4_ltchars __P((const struct ltchars *bl,
- struct svr4_ltchars *sl));
-
-#ifdef DEBUG_SVR4
-static void print_svr4_sgttyb __P((const char *, struct svr4_sgttyb *));
-static void print_svr4_tchars __P((const char *, struct svr4_tchars *));
-static void print_svr4_ltchars __P((const char *, struct svr4_ltchars *));
-
-static void
-print_svr4_sgttyb(str, ss)
- const char *str;
- struct svr4_sgttyb *ss;
-{
-
- uprintf("%s\nispeed=%o ospeed=%o ", str, ss->sg_ispeed, ss->sg_ospeed);
- uprintf("erase=%o kill=%o flags=%o\n", ss->sg_erase, ss->sg_kill,
- ss->sg_flags);
-}
-
-static void
-print_svr4_tchars(str, st)
- const char *str;
- struct svr4_tchars *st;
-{
- uprintf("%s\nintrc=%o quitc=%o ", str, st->t_intrc, st->t_quitc);
- uprintf("startc=%o stopc=%o eofc=%o brkc=%o\n", st->t_startc,
- st->t_stopc, st->t_eofc, st->t_brkc);
-}
-
-static void
-print_svr4_ltchars(str, sl)
- const char *str;
- struct svr4_ltchars *sl;
-{
- uprintf("%s\nsuspc=%o dsuspc=%o ", str, sl->t_suspc, sl->t_dsuspc);
- uprintf("rprntc=%o flushc=%o werasc=%o lnextc=%o\n", sl->t_rprntc,
- sl->t_flushc, sl->t_werasc, sl->t_lnextc);
-}
-#endif /* DEBUG_SVR4 */
-
-static void
-svr4_tchars_to_bsd_tchars(st, bt)
- const struct svr4_tchars *st;
- struct tchars *bt;
-{
- bt->t_intrc = st->t_intrc;
- bt->t_quitc = st->t_quitc;
- bt->t_startc = st->t_startc;
- bt->t_stopc = st->t_stopc;
- bt->t_eofc = st->t_eofc;
- bt->t_brkc = st->t_brkc;
-}
-
-
-static void
-bsd_tchars_to_svr4_tchars(bt, st)
- const struct tchars *bt;
- struct svr4_tchars *st;
-{
- st->t_intrc = bt->t_intrc;
- st->t_quitc = bt->t_quitc;
- st->t_startc = bt->t_startc;
- st->t_stopc = bt->t_stopc;
- st->t_eofc = bt->t_eofc;
- st->t_brkc = bt->t_brkc;
-}
-
-
-static void
-svr4_sgttyb_to_bsd_sgttyb(ss, bs)
- const struct svr4_sgttyb *ss;
- struct sgttyb *bs;
-{
- bs->sg_ispeed = ss->sg_ispeed;
- bs->sg_ospeed = ss->sg_ospeed;
- bs->sg_erase = ss->sg_erase;
- bs->sg_kill = ss->sg_kill;
- bs->sg_flags = ss->sg_flags;
-};
-
-
-static void
-bsd_sgttyb_to_svr4_sgttyb(bs, ss)
- const struct sgttyb *bs;
- struct svr4_sgttyb *ss;
-{
- ss->sg_ispeed = bs->sg_ispeed;
- ss->sg_ospeed = bs->sg_ospeed;
- ss->sg_erase = bs->sg_erase;
- ss->sg_kill = bs->sg_kill;
- ss->sg_flags = bs->sg_flags;
-}
-
-
-static void
-svr4_ltchars_to_bsd_ltchars(sl, bl)
- const struct svr4_ltchars *sl;
- struct ltchars *bl;
-{
- bl->t_suspc = sl->t_suspc;
- bl->t_dsuspc = sl->t_dsuspc;
- bl->t_rprntc = sl->t_rprntc;
- bl->t_flushc = sl->t_flushc;
- bl->t_werasc = sl->t_werasc;
- bl->t_lnextc = sl->t_lnextc;
-}
-
-
-static void
-bsd_ltchars_to_svr4_ltchars(bl, sl)
- const struct ltchars *bl;
- struct svr4_ltchars *sl;
-{
- sl->t_suspc = bl->t_suspc;
- sl->t_dsuspc = bl->t_dsuspc;
- sl->t_rprntc = bl->t_rprntc;
- sl->t_flushc = bl->t_flushc;
- sl->t_werasc = bl->t_werasc;
- sl->t_lnextc = bl->t_lnextc;
-}
-
-
-int
-svr4_ttold_ioctl(fp, p, retval, fd, cmd, data)
- struct file *fp;
- struct proc *p;
- register_t *retval;
- int fd;
- u_long cmd;
- caddr_t data;
-{
- int error;
-
- *retval = 0;
-
- switch (cmd) {
- case SVR4_TIOCGPGRP:
- {
- pid_t pid;
-
- if ((error = fo_ioctl(fp, TIOCGPGRP, (caddr_t) &pid, p)) != 0)
- return error;
-
- DPRINTF(("TIOCGPGRP %d\n", pid));
-
- if ((error = copyout(&pid, data, sizeof(pid))) != 0)
- return error;
-
- }
-
- case SVR4_TIOCSPGRP:
- {
- pid_t pid;
-
- if ((error = copyin(data, &pid, sizeof(pid))) != 0)
- return error;
-
- DPRINTF(("TIOCSPGRP %d\n", pid));
-
- return fo_ioctl(fp, TIOCSPGRP, (caddr_t) &pid, p);
- }
-
- case SVR4_TIOCGSID:
- {
-#if defined(TIOCGSID)
- pid_t pid;
- if ((error = fo_ioctl(fp, TIOCGSID, (caddr_t) &pid, p)) != 0)
- return error;
-
- DPRINTF(("TIOCGSID %d\n", pid));
-
- return copyout(&pid, data, sizeof(pid));
-#else
- uprintf("ioctl(TIOCGSID) for pid %d unsupported\n", p->p_pid);
- return EINVAL;
-#endif
- }
-
- case SVR4_TIOCGETP:
- {
- struct sgttyb bs;
- struct svr4_sgttyb ss;
-
- error = fo_ioctl(fp, TIOCGETP, (caddr_t) &bs, p);
- if (error)
- return error;
-
- bsd_sgttyb_to_svr4_sgttyb(&bs, &ss);
-#ifdef DEBUG_SVR4
- print_svr4_sgttyb("SVR4_TIOCGETP", &ss);
-#endif /* DEBUG_SVR4 */
- return copyout(&ss, data, sizeof(ss));
- }
-
- case SVR4_TIOCSETP:
- case SVR4_TIOCSETN:
- {
- struct sgttyb bs;
- struct svr4_sgttyb ss;
-
- if ((error = copyin(data, &ss, sizeof(ss))) != 0)
- return error;
-
- svr4_sgttyb_to_bsd_sgttyb(&ss, &bs);
-#ifdef DEBUG_SVR4
- print_svr4_sgttyb("SVR4_TIOCSET{P,N}", &ss);
-#endif /* DEBUG_SVR4 */
- cmd = (cmd == SVR4_TIOCSETP) ? TIOCSETP : TIOCSETN;
- return fo_ioctl(fp, cmd, (caddr_t) &bs, p);
- }
-
- case SVR4_TIOCGETC:
- {
- struct tchars bt;
- struct svr4_tchars st;
-
- error = fo_ioctl(fp, TIOCGETC, (caddr_t) &bt, p);
- if (error)
- return error;
-
- bsd_tchars_to_svr4_tchars(&bt, &st);
-#ifdef DEBUG_SVR4
- print_svr4_tchars("SVR4_TIOCGETC", &st);
-#endif /* DEBUG_SVR4 */
- return copyout(&st, data, sizeof(st));
- }
-
- case SVR4_TIOCSETC:
- {
- struct tchars bt;
- struct svr4_tchars st;
-
- if ((error = copyin(data, &st, sizeof(st))) != 0)
- return error;
-
- svr4_tchars_to_bsd_tchars(&st, &bt);
-#ifdef DEBUG_SVR4
- print_svr4_tchars("SVR4_TIOCSETC", &st);
-#endif /* DEBUG_SVR4 */
- return fo_ioctl(fp, TIOCSETC, (caddr_t) &bt, p);
- }
-
- case SVR4_TIOCGLTC:
- {
- struct ltchars bl;
- struct svr4_ltchars sl;
-
- error = fo_ioctl(fp, TIOCGLTC, (caddr_t) &bl, p);
- if (error)
- return error;
-
- bsd_ltchars_to_svr4_ltchars(&bl, &sl);
-#ifdef DEBUG_SVR4
- print_svr4_ltchars("SVR4_TIOCGLTC", &sl);
-#endif /* DEBUG_SVR4 */
- return copyout(&sl, data, sizeof(sl));
- }
-
- case SVR4_TIOCSLTC:
- {
- struct ltchars bl;
- struct svr4_ltchars sl;
-
- if ((error = copyin(data, &sl, sizeof(sl))) != 0)
- return error;
-
- svr4_ltchars_to_bsd_ltchars(&sl, &bl);
-#ifdef DEBUG_SVR4
- print_svr4_ltchars("SVR4_TIOCSLTC", &sl);
-#endif /* DEBUG_SVR4 */
- return fo_ioctl(fp, TIOCSLTC, (caddr_t) &bl, p);
- }
-
- case SVR4_TIOCLGET:
- {
- int flags;
- if ((error = fo_ioctl(fp, TIOCLGET, (caddr_t) &flags, p)) != 0)
- return error;
- DPRINTF(("SVR4_TIOCLGET %o\n", flags));
- return copyout(&flags, data, sizeof(flags));
- }
-
- case SVR4_TIOCLSET:
- case SVR4_TIOCLBIS:
- case SVR4_TIOCLBIC:
- {
- int flags;
-
- if ((error = copyin(data, &flags, sizeof(flags))) != 0)
- return error;
-
- switch (cmd) {
- case SVR4_TIOCLSET:
- cmd = TIOCLSET;
- break;
- case SVR4_TIOCLBIS:
- cmd = TIOCLBIS;
- break;
- case SVR4_TIOCLBIC:
- cmd = TIOCLBIC;
- break;
- }
-
- DPRINTF(("SVR4_TIOCL{SET,BIS,BIC} %o\n", flags));
- return fo_ioctl(fp, cmd, (caddr_t) &flags, p);
- }
-
- default:
- DPRINTF(("Unknown svr4 ttold %lx\n", cmd));
- return 0; /* ENOSYS really */
- }
-}
diff --git a/sys/compat/svr4/svr4_ttold.h b/sys/compat/svr4/svr4_ttold.h
deleted file mode 100644
index c578170a1ef9..000000000000
--- a/sys/compat/svr4/svr4_ttold.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1994 Christos Zoulas
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _SVR4_TTOLD_H_
-#define _SVR4_TTOLD_H_
-
-struct svr4_tchars {
- char t_intrc;
- char t_quitc;
- char t_startc;
- char t_stopc;
- char t_eofc;
- char t_brkc;
-};
-
-struct svr4_sgttyb {
- u_char sg_ispeed;
- u_char sg_ospeed;
- u_char sg_erase;
- u_char sg_kill;
- int sg_flags;
-};
-
-struct svr4_ltchars {
- char t_suspc;
- char t_dsuspc;
- char t_rprntc;
- char t_flushc;
- char t_werasc;
- char t_lnextc;
-};
-
-#ifndef SVR4_tIOC
-#define SVR4_tIOC ('t' << 8)
-#endif
-
-#define SVR4_TIOCGETD (SVR4_tIOC | 0)
-#define SVR4_TIOCSETD (SVR4_tIOC | 1)
-#define SVR4_TIOCHPCL (SVR4_tIOC | 2)
-#define SVR4_TIOCGETP (SVR4_tIOC | 8)
-#define SVR4_TIOCSETP (SVR4_tIOC | 9)
-#define SVR4_TIOCSETN (SVR4_tIOC | 10)
-#define SVR4_TIOCEXCL (SVR4_tIOC | 13)
-#define SVR4_TIOCNXCL (SVR4_tIOC | 14)
-#define SVR4_TIOCFLUSH (SVR4_tIOC | 16)
-#define SVR4_TIOCSETC (SVR4_tIOC | 17)
-#define SVR4_TIOCGETC (SVR4_tIOC | 18)
-#define SVR4_TIOCGPGRP (SVR4_tIOC | 20)
-#define SVR4_TIOCSPGRP (SVR4_tIOC | 21)
-#define SVR4_TIOCGSID (SVR4_tIOC | 22)
-#define SVR4_TIOCSTI (SVR4_tIOC | 23)
-#define SVR4_TIOCSSID (SVR4_tIOC | 24)
-#define SVR4_TIOCMSET (SVR4_tIOC | 26)
-#define SVR4_TIOCMBIS (SVR4_tIOC | 27)
-#define SVR4_TIOCMBIC (SVR4_tIOC | 28)
-#define SVR4_TIOCMGET (SVR4_tIOC | 29)
-#define SVR4_TIOCREMOTE (SVR4_tIOC | 30)
-#define SVR4_TIOCSIGNAL (SVR4_tIOC | 31)
-
-#define SVR4_TIOCSTART (SVR4_tIOC | 110)
-#define SVR4_TIOCSTOP (SVR4_tIOC | 111)
-#define SVR4_TIOCNOTTY (SVR4_tIOC | 113)
-#define SVR4_TIOCOUTQ (SVR4_tIOC | 115)
-#define SVR4_TIOCGLTC (SVR4_tIOC | 116)
-#define SVR4_TIOCSLTC (SVR4_tIOC | 117)
-#define SVR4_TIOCCDTR (SVR4_tIOC | 120)
-#define SVR4_TIOCSDTR (SVR4_tIOC | 121)
-#define SVR4_TIOCCBRK (SVR4_tIOC | 122)
-#define SVR4_TIOCSBRK (SVR4_tIOC | 123)
-#define SVR4_TIOCLGET (SVR4_tIOC | 124)
-#define SVR4_TIOCLSET (SVR4_tIOC | 125)
-#define SVR4_TIOCLBIC (SVR4_tIOC | 126)
-#define SVR4_TIOCLBIS (SVR4_tIOC | 127)
-
-#define SVR4_TIOCM_LE 0001
-#define SVR4_TIOCM_DTR 0002
-#define SVR4_TIOCM_RTS 0004
-#define SVR4_TIOCM_ST 0010
-#define SVR4_TIOCM_SR 0020
-#define SVR4_TIOCM_CTS 0040
-#define SVR4_TIOCM_CAR 0100
-#define SVR4_TIOCM_CD SVR4_TIOCM_CAR
-#define SVR4_TIOCM_RNG 0200
-#define SVR4_TIOCM_RI SVR4_TIOCM_RNG
-#define SVR4_TIOCM_DSR 0400
-
-#define SVR4_OTTYDISC 0
-#define SVR4_NETLDISC 1
-#define SVR4_NTTYDISC 2
-#define SVR4_TABLDISC 3
-#define SVR4_NTABLDISC 4
-#define SVR4_MOUSELDISC 5
-#define SVR4_KBDLDISC 6
-
-#endif /* !_SVR4_TTOLD_H_ */
diff --git a/sys/compat/svr4/svr4_types.h b/sys/compat/svr4/svr4_types.h
deleted file mode 100644
index 410746b6adc9..000000000000
--- a/sys/compat/svr4/svr4_types.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1994 Christos Zoulas
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _SVR4_TYPES_H_
-#define _SVR4_TYPES_H_
-
-typedef u_quad_t svr4_ino64_t;
-typedef quad_t svr4_off64_t;
-typedef quad_t svr4_blkcnt64_t;
-typedef u_quad_t svr4_fsblkcnt64_t;
-
-typedef long svr4_off_t;
-typedef u_long svr4_dev_t;
-typedef u_long svr4_ino_t;
-typedef u_long svr4_mode_t;
-typedef u_long svr4_nlink_t;
-typedef long svr4_uid_t;
-typedef long svr4_gid_t;
-typedef long svr4_daddr_t;
-typedef long svr4_pid_t;
-typedef long svr4_time_t;
-typedef long svr4_blkcnt_t;
-typedef u_long svr4_fsblkcnt_t;
-typedef char *svr4_caddr_t;
-typedef u_int svr4_size_t;
-
-typedef short svr4_o_dev_t;
-typedef short svr4_o_pid_t;
-typedef u_short svr4_o_ino_t;
-typedef u_short svr4_o_mode_t;
-typedef short svr4_o_nlink_t;
-typedef u_short svr4_o_uid_t;
-typedef u_short svr4_o_gid_t;
-typedef long svr4_clock_t;
-typedef int svr4_key_t;
-
-typedef struct timespec svr4_timestruc_t;
-
-#define svr4_omajor(x) ((int32_t)((((x) & 0x7f00) >> 8)))
-#define svr4_ominor(x) ((int32_t)((((x) & 0x00ff) >> 0)))
-#define svr4_omakedev(x,y) ((svr4_o_dev_t)((((x) << 8) & 0x7f00) | \
- (((y) << 0) & 0x00ff)))
-
-#define svr4_to_bsd_odev_t(d) makedev(svr4_omajor(d), svr4_ominor(d))
-#define bsd_to_svr4_odev_t(d) svr4_omakedev(umajor(d), uminor(d))
-
-#define svr4_major(x) ((int32_t)((((x) & 0xfffc0000) >> 18)))
-#define svr4_minor(x) ((int32_t)((((x) & 0x0003ffff) >> 0)))
-#define svr4_makedev(x,y) ((svr4_dev_t)((((x) << 18) & 0xfffc0000) | \
- (((y) << 0) & 0x0003ffff)))
-#define svr4_to_bsd_dev_t(d) makedev(svr4_major(d), svr4_minor(d))
-#define bsd_to_svr4_dev_t(d) svr4_makedev(umajor(d), uminor(d))
-
-#endif /* !_SVR4_TYPES_H_ */
diff --git a/sys/compat/svr4/svr4_ucontext.h b/sys/compat/svr4/svr4_ucontext.h
deleted file mode 100644
index 04bebe6eb81e..000000000000
--- a/sys/compat/svr4/svr4_ucontext.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1994 Christos Zoulas
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _SVR4_UCONTEXT_H_
-#define _SVR4_UCONTEXT_H_
-
-/*
- * Machine context
- */
-
-#define SVR4_UC_SIGMASK 0x01
-#define SVR4_UC_STACK 0x02
-
-#define SVR4_UC_CPU 0x04
-#define SVR4_UC_FPU 0x08
-#define SVR4_UC_WEITEK 0x10
-
-#define SVR4_UC_MCONTEXT (SVR4_UC_CPU|SVR4_UC_FPU|SVR4_UC_WEITEK)
-
-#define SVR4_UC_ALL (SVR4_UC_SIGMASK|SVR4_UC_STACK|SVR4_UC_MCONTEXT)
-
-typedef struct svr4_ucontext {
- u_long uc_flags;
- /* struct svr4_ucontext *uc_link;*/
- void *uc_link;
- svr4_sigset_t uc_sigmask;
- struct svr4_sigaltstack uc_stack;
- svr4_mcontext_t uc_mcontext;
- long uc_pad[5];
-} svr4_ucontext_t;
-
-#define SVR4_UC_GETREGSET 0
-#define SVR4_UC_SETREGSET 1
-
-/*
- * Signal frame
- */
-struct svr4_sigframe {
- int sf_signum;
- union svr4_siginfo *sf_sip;
- struct svr4_ucontext *sf_ucp;
- sig_t sf_handler;
- struct svr4_ucontext sf_uc;
- union svr4_siginfo sf_si;
-};
-
-#endif /* !_SVR4_UCONTEXT_H_ */
diff --git a/sys/compat/svr4/svr4_ulimit.h b/sys/compat/svr4/svr4_ulimit.h
deleted file mode 100644
index 0735d42f722f..000000000000
--- a/sys/compat/svr4/svr4_ulimit.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1994 Christos Zoulas
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _SVR4_ULIMIT_H_
-#define _SVR4_ULIMIT_H_
-
-#define SVR4_GFILLIM 1
-#define SVR4_SFILLIM 2
-#define SVR4_GMEMLIM 3
-#define SVR4_GDESLIM 4
-#define SVR4_GTXTOFF 64
-
-
-#endif /* !_SVR4_ULIMIT_H_ */
diff --git a/sys/compat/svr4/svr4_ustat.h b/sys/compat/svr4/svr4_ustat.h
deleted file mode 100644
index 0033c96bae0d..000000000000
--- a/sys/compat/svr4/svr4_ustat.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1994 Christos Zoulas
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _SVR4_USTAT_H_
-#define _SVR4_USTAT_H_
-
-#include <svr4/svr4_types.h>
-
-struct svr4_ustat {
- svr4_daddr_t f_tfree;
- svr4_ino_t f_tinode;
- char f_fname[6];
- char f_fpack[6];
-};
-
-#endif /* !_SVR4_USTAT_H_ */
diff --git a/sys/compat/svr4/svr4_util.h b/sys/compat/svr4/svr4_util.h
deleted file mode 100644
index 629edd69cd4a..000000000000
--- a/sys/compat/svr4/svr4_util.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1994 Christos Zoulas
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _SVR4_UTIL_H_
-#define _SVR4_UTIL_H_
-
-/*#include <compat/common/compat_util.h>*/
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <vm/pmap.h>
-#include <machine/vmparam.h>
-#include <sys/exec.h>
-#include <sys/sysent.h>
-#include <sys/cdefs.h>
-
-#ifdef DEBUG_SVR4
-#define DPRINTF(a) uprintf a;
-#else
-#define DPRINTF(a)
-#endif
-
-
-static __inline caddr_t stackgap_init(void);
-static __inline void *stackgap_alloc(caddr_t *, size_t);
-
-static __inline caddr_t
-stackgap_init()
-{
-#define szsigcode (*(curproc->p_sysent->sv_szsigcode))
- return (caddr_t)(((caddr_t)PS_STRINGS) - szsigcode - SPARE_USRSPACE);
-}
-
-static __inline void *
-stackgap_alloc(sgp, sz)
- caddr_t *sgp;
- size_t sz;
-{
- void *p = (void *) *sgp;
- *sgp += ALIGN(sz);
- return p;
-}
-
-extern const char svr4_emul_path[];
-int svr4_emul_find __P((struct proc *, caddr_t *, const char *, char *,
- char **, int));
-
-#define CHECKALT(p, sgp, path, i) \
- do { \
- int _error; \
- \
- _error = svr4_emul_find(p, sgp, svr4_emul_path, path, \
- &path, i); \
- if (_error == EFAULT) \
- return (_error); \
- } while (0)
-
-#define CHECKALTEXIST(p, sgp, path) CHECKALT(p, sgp, path, 0)
-#define CHECKALTCREAT(p, sgp, path) CHECKALT(p, sgp, path, 1)
-
-#endif /* !_SVR4_UTIL_H_ */
diff --git a/sys/compat/svr4/svr4_utsname.h b/sys/compat/svr4/svr4_utsname.h
deleted file mode 100644
index a3714c9b1c10..000000000000
--- a/sys/compat/svr4/svr4_utsname.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1994 Christos Zoulas
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _SVR4_UTSNAME_H_
-#define _SVR4_UTSNAME_H_
-
-#include <svr4/svr4_types.h>
-
-struct svr4_utsname {
- char sysname[257];
- char nodename[257];
- char release[257];
- char version[257];
- char machine[257];
-};
-
-#endif /* !_SVR4_UTSNAME_H_ */
diff --git a/sys/compat/svr4/svr4_wait.h b/sys/compat/svr4/svr4_wait.h
deleted file mode 100644
index 9a92c0114c1c..000000000000
--- a/sys/compat/svr4/svr4_wait.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 1998 Mark Newton
- * Copyright (c) 1994 Christos Zoulas
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _SVR4_WAIT_H_
-#define _SVR4_WAIT_H_
-
-
-#define SVR4_P_PID 0
-#define SVR4_P_PPID 1
-#define SVR4_P_PGID 2
-#define SVR4_P_SID 3
-#define SVR4_P_CID 4
-#define SVR4_P_UID 5
-#define SVR4_P_GID 6
-#define SVR4_P_ALL 7
-
-#define SVR4_WEXITED 0x01
-#define SVR4_WTRAPPED 0x02
-#define SVR4_WSTOPPED 0x04
-#define SVR4_WCONTINUED 0x08
-#define SVR4_WUNDEF1 0x10
-#define SVR4_WUNDEF2 0x20
-#define SVR4_WNOHANG 0x40
-#define SVR4_WNOWAIT 0x80
-
-#define SVR4_WOPTMASK (SVR4_WEXITED|SVR4_WTRAPPED|SVR4_WSTOPPED|\
- SVR4_WCONTINUED|SVR4_WNOHANG|SVR4_WNOWAIT)
-
-#endif /* !_SVR4_WAIT_H_ */
diff --git a/sys/compat/svr4/syscalls.conf b/sys/compat/svr4/syscalls.conf
deleted file mode 100644
index 46f7bd3df7be..000000000000
--- a/sys/compat/svr4/syscalls.conf
+++ /dev/null
@@ -1,12 +0,0 @@
-# $FreeBSD$
-sysnames="svr4_syscallnames.c"
-sysproto="svr4_proto.h"
-sysproto_h=_SVR4_SYSPROTO_H_
-syshdr="svr4_syscall.h"
-syssw="svr4_sysent.c"
-sysmk="/dev/null"
-syshide="/dev/null"
-syscallprefix="SVR4_SYS_"
-switchname="svr4_sysent"
-namesname="svr4_syscallnames"
-sysvec="\n"
diff --git a/sys/compat/svr4/syscalls.master b/sys/compat/svr4/syscalls.master
deleted file mode 100644
index af542181be82..000000000000
--- a/sys/compat/svr4/syscalls.master
+++ /dev/null
@@ -1,366 +0,0 @@
-; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
-; System call name/number master file (or rather, slave, from SVR4).
-; Processed to create svr4_sysent.c, svr4_syscalls.c and svr4_syscall.h.
-
-; Columns: number type nargs namespc name alt{name,tag,rtyp}/comments
-; number system call number, must be in order
-; type one of STD, OBSOL, UNIMPL, COMPAT
-; namespc one of POSIX, BSD, STD, NOHIDE (I dont care :-) -Peter
-; name psuedo-prototype of syscall routine
-; If one of the following alts is different, then all appear:
-; altname name of system call if different
-; alttag name of args struct tag if different from [o]`name'"_args"
-; altrtyp return type if not int (bogus - syscalls always return int)
-; for UNIMPL/OBSOL, name continues with comments
-
-; types:
-; STD always included
-; COMPAT included on COMPAT #ifdef
-; LIBCOMPAT included on COMPAT #ifdef, and placed in syscall.h
-; OBSOL obsolete, not included in system, only specifies name
-; UNIMPL not implemented, placeholder only
-;
-; $FreeBSD$
-;
-#include <sys/types.h>
-#include <sys/sysent.h>
-#include <sys/sysproto.h>
-#include <netinet/in.h>
-
-#include <svr4/svr4.h>
-#include <svr4/svr4_types.h>
-#include <svr4/svr4_signal.h>
-#include <svr4/svr4_proto.h>
-
-; #ifdef's, etc. may be included, and are copied to the output files.
-
-0 UNIMPL SVR4 unused
-1 NOPROTO POSIX { int exit(int rval); }
-2 NOPROTO POSIX { int fork(void); }
-3 NOPROTO POSIX { int read(int fd, char *buf, u_int nbyte); }
-4 NOPROTO SVR4 { int write(int fd, char *buf, u_int nbyte); }
-5 STD SVR4 { int svr4_sys_open(char *path, int flags, int mode); }
-6 NOPROTO SVR4 { int close(int fd); }
-7 STD SVR4 { int svr4_sys_wait(int *status); }
-8 STD SVR4 { int svr4_sys_creat(char *path, int mode); }
-9 NOPROTO SVR4 { int link(char *path, char *link); }
-10 NOPROTO SVR4 { int unlink(char *path); }
-11 STD SVR4 { int svr4_sys_execv(char *path, char **argp); }
-12 NOPROTO SVR4 { int chdir(char *path); }
-13 STD SVR4 { int svr4_sys_time(time_t *t); }
-14 STD SVR4 { int svr4_sys_mknod(char* path, int mode, int dev); }
-15 NOPROTO SVR4 { int chmod(char *path, int mode); }
-16 NOPROTO SVR4 { int chown(char *path, uid_t uid, gid_t gid); }
-17 STD SVR4 { int svr4_sys_break(caddr_t nsize); }
-18 STD SVR4 { int svr4_sys_stat(char* path, \
- struct svr4_stat* ub); }
-19 NOPROTO SVR4 { int lseek(int filedes, off_t *offset, int whence); }
-20 NOPROTO SVR4 { pid_t getpid(void); }
-21 UNIMPL SVR4 old_mount
-22 UNIMPL SVR4 sysv_umount
-23 NOPROTO SVR4 { int setuid(uid_t uid); }
-24 NOPROTO SVR4 { uid_t getuid(void); }
-25 UNIMPL SVR4 stime
-26 UNIMPL SVR4 ptrace
-27 STD SVR4 { int svr4_sys_alarm(unsigned sec); }
-28 STD SVR4 { int svr4_sys_fstat(int fd, struct svr4_stat *sb); }
-29 STD SVR4 { int svr4_sys_pause(void); }
-30 STD SVR4 { int svr4_sys_utime(char *path, \
- struct svr4_utimbuf *ubuf); }
-31 UNIMPL SVR4 stty
-32 UNIMPL SVR4 gtty
-33 STD SVR4 { int svr4_sys_access(char *path, int flags); }
-34 STD SVR4 { int svr4_sys_nice(int prio); }
-35 UNIMPL SVR4 statfs
-36 NOPROTO SVR4 { int sync(void); }
-37 STD SVR4 { int svr4_sys_kill(int pid, int signum); }
-38 UNIMPL SVR4 fstatfs
-39 STD SVR4 { int svr4_sys_pgrpsys(int cmd, int pid, int pgid); }
-40 UNIMPL SVR4 xenix
-41 NOPROTO SVR4 { int dup(u_int fd); }
-42 NOPROTO SVR4 { int pipe(void); }
-43 STD SVR4 { int svr4_sys_times(struct tms *tp); }
-44 UNIMPL SVR4 profil
-45 UNIMPL SVR4 plock
-46 NOPROTO SVR4 { int setgid(gid_t gid); }
-47 NOPROTO SVR4 { gid_t getgid(void); }
-48 STD SVR4 { int svr4_sys_signal(int signum, \
- svr4_sig_t handler); }
-#if defined(NOTYET)
-49 STD SVR4 { int svr4_sys_msgsys(int what, int a2, int a3, \
- int a4, int a5); }
-#else
-49 UNIMPL SVR4 msgsys
-#endif
-50 STD SVR4 { int svr4_sys_sysarch(int op, void *a1); }
-51 UNIMPL SVR4 acct
-52 UNIMPL SVR4 shmsys
-53 UNIMPL SVR4 semsys
-54 STD SVR4 { int svr4_sys_ioctl(int fd, u_long com, \
- caddr_t data); }
-55 UNIMPL SVR4 uadmin
-56 UNIMPL SVR4 exch
-57 STD SVR4 { int svr4_sys_utssys(void *a1, void *a2, int sel, \
- void *a3); }
-58 NOPROTO SVR4 { int fsync(int fd); }
-59 STD SVR4 { int svr4_sys_execve(char *path, char **argp, \
- char **envp); }
-60 NOPROTO SVR4 { int umask(int newmask); }
-61 NOPROTO SVR4 { int chroot(char *path); }
-62 STD SVR4 { int svr4_sys_fcntl(int fd, int cmd, char *arg); }
-63 STD SVR4 { int svr4_sys_ulimit(int cmd, long newlimit); }
-64 UNIMPL SVR4 reserved
-65 UNIMPL SVR4 reserved
-66 UNIMPL SVR4 reserved
-67 UNIMPL SVR4 reserved
-68 UNIMPL SVR4 reserved
-69 UNIMPL SVR4 reserved
-70 UNIMPL SVR4 advfs
-71 UNIMPL SVR4 unadvfs
-72 UNIMPL SVR4 rmount
-73 UNIMPL SVR4 rumount
-74 UNIMPL SVR4 rfstart
-75 UNIMPL SVR4 sigret
-76 UNIMPL SVR4 rdebug
-77 UNIMPL SVR4 rfstop
-78 UNIMPL SVR4 rfsys
-79 NOPROTO SVR4 { int rmdir(char *path); }
-80 NOPROTO SVR4 { int mkdir(char *path, int mode); }
-81 STD SVR4 { int svr4_sys_getdents(int fd, char *buf, \
- int nbytes); }
-82 UNIMPL SVR4 libattach
-83 UNIMPL SVR4 libdetach
-84 UNIMPL SVR4 sysfs
-85 STD SVR4 { int svr4_sys_getmsg(int fd, struct svr4_strbuf *ctl, \
- struct svr4_strbuf *dat, int *flags); }
-86 STD SVR4 { int svr4_sys_putmsg(int fd, struct svr4_strbuf *ctl, \
- struct svr4_strbuf *dat, int flags); }
-87 STD SVR4 { int svr4_sys_poll(struct pollfd *fds, unsigned int nfds, \
- int timeout); }
-88 STD SVR4 { int svr4_sys_lstat(char *path, \
- struct svr4_stat *ub); }
-89 NOPROTO SVR4 { int symlink(char *path, char *link); }
-90 NOPROTO SVR4 { int readlink(char *path, char *buf, int count); }
-91 NOPROTO SVR4 { int getgroups(u_int gidsetsize, gid_t *gidset); }
-92 NOPROTO SVR4 { int setgroups(u_int gidsetsize, gid_t *gidset); }
-93 NOPROTO SVR4 { int fchmod(int fd, int mode); }
-94 NOPROTO SVR4 { int fchown(int fd, int uid, int gid); }
-95 STD SVR4 { int svr4_sys_sigprocmask(int how, \
- svr4_sigset_t *set, svr4_sigset_t *oset); }
-96 STD SVR4 { int svr4_sys_sigsuspend(svr4_sigset_t *ss); }
-97 STD SVR4 { int svr4_sys_sigaltstack( \
- struct svr4_sigaltstack *nss, \
- struct svr4_sigaltstack *oss); }
-98 STD SVR4 { int svr4_sys_sigaction(int signum, \
- struct svr4_sigaction *nsa, \
- struct svr4_sigaction *osa); }
-99 STD SVR4 { int svr4_sys_sigpending(int what, \
- svr4_sigset_t *mask); }
-100 STD SVR4 { int svr4_sys_context(int func, \
- struct svr4_ucontext *uc); }
-101 UNIMPL SVR4 evsys
-102 UNIMPL SVR4 evtrapret
-103 STD SVR4 { int svr4_sys_statvfs(char *path, \
- struct svr4_statvfs *fs); }
-104 STD SVR4 { int svr4_sys_fstatvfs(int fd, \
- struct svr4_statvfs *fs); }
-105 UNIMPL SVR4 whoknows
-106 UNIMPL SVR4 nfssvc
-107 STD SVR4 { int svr4_sys_waitsys(int grp, int id, \
- union svr4_siginfo *info, int options); }
-108 UNIMPL SVR4 sigsendsys
-109 STD SVR4 { int svr4_sys_hrtsys(int cmd, int fun, int sub, \
- void *rv1, void *rv2); }
-110 UNIMPL SVR4 acancel
-111 UNIMPL SVR4 async
-112 UNIMPL SVR4 priocntlsys
-113 STD SVR4 { int svr4_sys_pathconf(char *path, int name); }
-114 UNIMPL SVR4 mincore
-115 STD SVR4 { caddr_t svr4_sys_mmap( caddr_t addr, svr4_size_t len, \
- int prot, int flags, int fd, svr4_off_t pos); }
-116 NOPROTO SVR4 { int mprotect(void *addr, int len, int prot); }
-117 NOPROTO SVR4 { int munmap(void *addr, int len); }
-118 STD SVR4 { int svr4_sys_fpathconf(int fd, int name); }
-119 NOPROTO SVR4 { int vfork(void); }
-120 NOPROTO SVR4 { int fchdir(int fd); }
-121 NOPROTO SVR4 { int readv(int fd, struct iovec *iovp, \
- u_int iovcnt); }
-122 NOPROTO SVR4 { int writev(int fd, struct iovec *iovp, \
- u_int iovcnt); }
-123 STD SVR4 { int svr4_sys_xstat(int two, char *path, \
- struct svr4_xstat *ub); }
-124 STD SVR4 { int svr4_sys_lxstat(int two, char *path, \
- struct svr4_xstat *ub); }
-125 STD SVR4 { int svr4_sys_fxstat(int two, int fd, \
- struct svr4_xstat *sb); }
-126 STD SVR4 { int svr4_sys_xmknod(int two, char *path, \
- svr4_mode_t mode, svr4_dev_t dev); }
-127 UNIMPL SVR4 clocal
-128 STD SVR4 { int svr4_sys_setrlimit(int which, \
- const struct svr4_rlimit *rlp); }
-129 STD SVR4 { int svr4_sys_getrlimit(int which, \
- struct svr4_rlimit *rlp); }
-130 NOPROTO SVR4 { int lchown(char *path, uid_t uid, gid_t gid); }
-131 STD SVR4 { int svr4_sys_memcntl(void * addr, \
- svr4_size_t len, int cmd, void * arg, \
- int attr, int mask); }
-132 UNIMPL SVR4 getpmsg
-133 UNIMPL SVR4 putpmsg
-134 NOPROTO SVR4 { int rename(char *from, char *to); }
-135 STD SVR4 { int svr4_sys_uname(struct svr4_utsname* name, \
- int dummy); }
-136 NOPROTO SVR4 { int setegid(gid_t egid); }
-137 STD SVR4 { int svr4_sys_sysconfig(int name); }
-138 NOPROTO SVR4 { int adjtime(struct timeval *delta, \
- struct timeval *olddelta); }
-139 STD SVR4 { long svr4_sys_systeminfo(int what, char *buf, \
- long len); }
-140 UNIMPL SVR4 notused
-141 NOPROTO SVR4 { int seteuid(uid_t euid); }
-142 UNIMPL SVR4 vtrace
-; fork1
-143 UNIMPL SVR4 { int fork(void); }
-144 UNIMPL SVR4 sigtimedwait
-145 UNIMPL SVR4 lwp_info
-146 UNIMPL SVR4 yield
-147 UNIMPL SVR4 lwp_sema_wait
-148 UNIMPL SVR4 lwp_sema_post
-149 UNIMPL SVR4 lwp_sema_trywait
-150 UNIMPL SVR4 notused
-151 UNIMPL SVR4 notused
-152 UNIMPL SVR4 modctl
-153 STD SVR4 { int svr4_sys_fchroot(int fd); }
-154 STD SVR4 { int svr4_sys_utimes(char *path, \
- struct timeval *tptr); }
-155 STD SVR4 { int svr4_sys_vhangup(void); }
-156 STD SVR4 { int svr4_sys_gettimeofday(struct timeval *tp); }
-157 NOPROTO SVR4 { int getitimer(u_int which, struct itimerval *itv); }
-158 NOPROTO SVR4 { int setitimer(u_int which, struct itimerval *itv, \
- struct itimerval *oitv); }
-159 UNIMPL SVR4 lwp_create
-160 UNIMPL SVR4 lwp_exit
-161 UNIMPL SVR4 lwp_suspend
-162 UNIMPL SVR4 lwp_continue
-163 UNIMPL SVR4 lwp_kill
-164 UNIMPL SVR4 lwp_self
-165 UNIMPL SVR4 lwp_getprivate
-166 UNIMPL SVR4 lwp_setprivate
-167 UNIMPL SVR4 lwp_wait
-168 UNIMPL SVR4 lwp_mutex_unlock
-169 UNIMPL SVR4 lwp_mutex_lock
-170 UNIMPL SVR4 lwp_cond_wait
-171 UNIMPL SVR4 lwp_cond_signal
-172 UNIMPL SVR4 lwp_cond_broadcast
-173 UNIMPL SVR4 { ssize_t svr4_sys_pread(int fd, void *buf, \
- size_t nbyte, svr4_off_t off); }
-174 UNIMPL SVR4 { ssize_t svr4_sys_pwrite(int fd, const void *buf, \
- size_t nbyte, svr4_off_t off); }
-175 STD SVR4 { svr4_off64_t svr4_sys_llseek(int fd, long offset1, \
- long offset2, int whence); }
-176 UNIMPL SVR4 inst_sync
-177 UNIMPL SVR4 whoknows
-178 UNIMPL SVR4 kaio
-179 UNIMPL SVR4 whoknows
-180 UNIMPL SVR4 whoknows
-181 UNIMPL SVR4 whoknows
-182 UNIMPL SVR4 whoknows
-183 UNIMPL SVR4 whoknows
-184 UNIMPL SVR4 tsolsys
-185 STD SVR4 { int svr4_sys_acl(char *path, int cmd, int num, \
- struct svr4_aclent *buf); }
-186 STD SVR4 { int svr4_sys_auditsys(int code, int a1, int a2, \
- int a3, int a4, int a5); }
-187 UNIMPL SVR4 processor_bind
-188 UNIMPL SVR4 processor_info
-189 UNIMPL SVR4 p_online
-190 UNIMPL SVR4 sigqueue
-191 UNIMPL SVR4 clock_gettime
-192 UNIMPL SVR4 clock_settime
-193 UNIMPL SVR4 clock_getres
-194 UNIMPL SVR4 timer_create
-195 UNIMPL SVR4 timer_delete
-196 UNIMPL SVR4 timer_settime
-197 UNIMPL SVR4 timer_gettime
-198 UNIMPL SVR4 timer_overrun
-199 NOPROTO SVR4 { int nanosleep(const struct timespec *rqtp, \
- struct timespec *rmtp); }
-200 STD SVR4 { int svr4_sys_facl(int fd, int cmd, int num, \
- struct svr4_aclent *buf); }
-201 UNIMPL SVR4 door
-202 NOPROTO SVR4 { int setreuid(int ruid, int euid); }
-203 NOPROTO SVR4 { int setregid(int rgid, int egid); }
-204 UNIMPL SVR4 install_utrap
-205 UNIMPL SVR4 signotify
-206 UNIMPL SVR4 schedctl
-207 UNIMPL SVR4 pset
-208 UNIMPL SVR4 whoknows
-209 STD SVR4 { int svr4_sys_resolvepath(const char *path, \
- char *buf, size_t bufsiz); }
-210 UNIMPL SVR4 signotifywait
-211 UNIMPL SVR4 lwp_sigredirect
-212 UNIMPL SVR4 lwp_alarm
-213 STD SVR4 { int svr4_sys_getdents64(int fd, \
- struct svr4_dirent64 *dp, \
- int nbytes); }
-;213 UNIMPL SVR4 getdents64
-214 STD SVR4 { caddr_t svr4_sys_mmap64(void *addr, \
- svr4_size_t len, int prot, int flags, int fd, \
- svr4_off64_t pos); }
-215 STD SVR4 { int svr4_sys_stat64(char *path, \
- struct svr4_stat64 *sb); }
-216 STD SVR4 { int svr4_sys_lstat64(char *path, \
- struct svr4_stat64 *sb); }
-217 STD SVR4 { int svr4_sys_fstat64(int fd, \
- struct svr4_stat64 *sb); }
-218 STD SVR4 { int svr4_sys_statvfs64(char *path, \
- struct svr4_statvfs64 *fs); }
-219 STD SVR4 { int svr4_sys_fstatvfs64(int fd, \
- struct svr4_statvfs64 *fs); }
-220 STD SVR4 { int svr4_sys_setrlimit64(int which, \
- const struct svr4_rlimit64 *rlp); }
-221 STD SVR4 { int svr4_sys_getrlimit64(int which, \
- struct svr4_rlimit64 *rlp); }
-222 UNIMPL SVR4 pread64
-223 UNIMPL SVR4 pwrite64
-224 STD SVR4 { int svr4_sys_creat64(char *path, int mode); }
-225 STD SVR4 { int svr4_sys_open64(char *path, int flags, \
- int mode); }
-226 UNIMPL SVR4 rpcsys
-227 UNIMPL SVR4 whoknows
-228 UNIMPL SVR4 whoknows
-229 UNIMPL SVR4 whoknows
-230 STD SVR4 { int svr4_sys_socket(int domain, int type, \
- int protocol); }
-231 NOPROTO SVR4 { int socketpair(int domain, int type, \
- int protocol, int *rsv); }
-232 NOPROTO SVR4 { int bind(int s, const struct sockaddr *name, \
- int namelen); }
-233 NOPROTO SVR4 { int listen(int s, int backlog); }
-234 NOPROTO SVR4 { int accept(int s, struct sockaddr *name, \
- int *anamelen); }
-235 NOPROTO SVR4 { int connect(int s, const struct sockaddr *name, \
- int namelen); }
-236 NOPROTO SVR4 { int shutdown(int s, int how); }
-237 STD SVR4 { int svr4_sys_recv(int s, caddr_t buf, int len, int flags); }
-238 NOPROTO SVR4 { ssize_t recvfrom(int s, void *buf, size_t len, \
- int flags, struct sockaddr *from, \
- int *fromlenaddr); }
-239 NOPROTO SVR4 { ssize_t recvmsg(int s, struct msghdr *msg, \
- int flags); }
-240 STD SVR4 { int svr4_sys_send(int s, caddr_t buf, int len, int flags); }
-241 NOPROTO SVR4 { ssize_t sendmsg(int s, const struct msghdr *msg, \
- int flags); }
-242 STD SVR4 { ssize_t svr4_sys_sendto(int s, void *buf, \
- size_t len, int flags, \
- struct sockaddr *to, int tolen); }
-243 NOPROTO SVR4 { int getpeername(int fdes, struct sockaddr *asa, \
- int *alen); }
-244 NOPROTO SVR4 { int getsockname(int fdes, struct sockaddr *asa, \
- int *alen); }
-245 NOPROTO SVR4 { int getsockopt(int s, int level, int name, \
- void *val, int *avalsize); }
-246 NOPROTO SVR4 { int setsockopt(int s, int level, int name, \
- const void *val, int valsize); }
-247 UNIMPL SVR4 sockconfig
-248 UNIMPL SVR4 { int ntp_gettime(struct ntptimeval *ntvp); }
-249 UNIMPL SVR4 { int ntp_adjtime(struct timex *tp); }
diff --git a/sys/conf/Makefile.powerpc b/sys/conf/Makefile.powerpc
deleted file mode 100644
index d77453823f02..000000000000
--- a/sys/conf/Makefile.powerpc
+++ /dev/null
@@ -1,251 +0,0 @@
-# Makefile.i386 -- with config changes.
-# Copyright 1990 W. Jolitz
-# from: @(#)Makefile.i386 7.1 5/10/91
-# $FreeBSD$
-#
-# Makefile for FreeBSD
-#
-# This makefile is constructed from a machine description:
-# config machineid
-# Most changes should be made in the machine description
-# /sys/i386/conf/``machineid''
-# after which you should do
-# config machineid
-# Generic makefile changes should be made in
-# /sys/i386/conf/Makefile.i386
-# after which config should be rerun for all machines.
-#
-
-# Which version of config(8) is required.
-%VERSREQ= 400018
-
-# Can be overridden by makeoptions or /etc/make.conf
-KERNEL?= kernel
-STD8X16FONT?= iso
-
-.if !defined(S)
-.if exists(./@/.)
-S= ./@
-.else
-S= ../..
-.endif
-.endif
-M= ${MACHINE_ARCH}
-
-SIZE?= size
-
-COPTFLAGS?=-O
-INCLUDES= -nostdinc -I- -I. -I$S
-# This hack is to allow kernel compiles to succeed on machines w/out srcdist
-.if exists($S/../include)
-INCLUDES+= -I$S/../include
-.else
-INCLUDES+= -I/usr/include
-.endif
-COPTS= ${INCLUDES} ${IDENT} -D_KERNEL -include opt_global.h
-CFLAGS= ${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS}
-
-# XXX LOCORE means "don't declare C stuff" not "for locore.s".
-ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS}
-
-# Select the correct set of tools. Can't set OBJFORMAT here because it
-# doesn't get exported into the environment, and if it were exported
-# then it might break building of utilities.
-FMT= -elf
-CFLAGS+= ${FMT}
-
-LOAD_ADDRESS?= C0100000
-DEFINED_PROF= ${PROF}
-.if defined(PROF)
-CFLAGS+= -malign-functions=4
-.if ${PROFLEVEL} >= 2
-IDENT+= -DGPROF4 -DGUPROF
-PROF+= -mprofiler-epilogue
-.endif
-.endif
-
-# Put configuration-specific C flags last (except for ${PROF}) so that they
-# can override the others.
-CFLAGS+= ${CONF_CFLAGS}
-
-NORMAL_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
-NORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
-NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${.IMPSRC}
-PROFILE_C= ${CC} -c ${CFLAGS} ${.IMPSRC}
-
-GEN_CFILES= $S/$M/$M/genassym.c
-# setdef0.c and setdef1.c are intentionally
-# omitted from SYSTEM_CFILES. They include setdefs.h, a header which
-# is generated from all of ${OBJS}. We don't want to have to compile
-# everything just to do a make depend.
-SYSTEM_CFILES= ioconf.c param.c vnode_if.c config.c
-SYSTEM_SFILES= $S/$M/$M/locore.s
-SYSTEM_DEP= Makefile ${SYSTEM_OBJS}
-SYSTEM_OBJS= locore.o setdef0.o vnode_if.o ${OBJS} ioconf.o param.o config.o \
- setdef1.o hack.So
-SYSTEM_LD= @${LD} ${FMT} -Bdynamic -T $S/conf/ldscript.$M \
- -export-dynamic -dynamic-linker /red/herring \
- -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
-SYSTEM_LD_TAIL= @${SIZE} ${FMT} ${.TARGET} ; chmod 755 ${.TARGET}
-SYSTEM_DEP+= $S/conf/ldscript.$M
-
-%BEFORE_DEPEND
-
-%OBJS
-
-%CFILES
-
-%SFILES
-
-%MFILES
-
-%CLEAN
-
-all: ${KERNEL}
-
-.if !defined(DEBUG)
-FULLKERNEL= ${KERNEL}
-.else
-FULLKERNEL= ${KERNEL}.debug
-${KERNEL}: ${FULLKERNEL}
- objcopy --strip-debug ${FULLKERNEL} ${KERNEL}
-.endif
-
-${FULLKERNEL}: ${SYSTEM_DEP} vers.o
- @rm -f ${.TARGET}
- @echo linking ${.TARGET}
- ${SYSTEM_LD}
- ${SYSTEM_LD_TAIL}
-
-.if !exists(.depend)
-${SYSTEM_OBJS}: vnode_if.h ${BEFORE_DEPEND:M*.h}
-.endif
-
-clean:
- rm -f *.o *.so *.So *.ko *.s eddep errs genassym \
- ${FULLKERNEL} ${KERNEL} linterrs makelinks param.c \
- setdef[01].c setdefs.h tags \
- vers.c vnode_if.c vnode_if.h ${CLEAN}
-
-#lint: /tmp param.c
-# @lint -hbxn -DGENERIC -Dvolatile= ${COPTS} \
-# $S/$M/$M/Locore.c ${CFILES} ioconf.c param.c | \
-# grep -v 'struct/union .* never defined' | \
-# grep -v 'possible pointer alignment problem'
-
-locore.o: $S/$M/$M/locore.s assym.s
- ${NORMAL_S}
-
-# This is a hack. BFD "optimizes" away dynamic mode if there are no
-# dynamic references. We could probably do a '-Bforcedynamic' mode like
-# in the a.out ld. For now, this works.
-hack.So: Makefile
- touch hack.c
- ${CC} ${FMT} -shared -nostdlib hack.c -o hack.So
- rm -f hack.c
-
-.ORDER: setdefs.h setdef0.c setdef1.c
-
-setdef0.o: setdef0.c setdefs.h
- ${NORMAL_C}
-
-setdef1.o: setdef1.c setdefs.h
- ${NORMAL_C}
-
-setdef0.c setdef1.c setdefs.h: ${OBJS}
- @gensetdefs ${OBJS}
-
-# this rule stops ./assym.s in .depend from causing problems
-./assym.s: assym.s
-
-assym.s: genassym.o
- genassym genassym.o >assym.s
-
-genassym.o: $S/$M/$M/genassym.c
- ${CC} -c ${CFLAGS} $S/$M/$M/genassym.c
-
-${SYSTEM_OBJS} genassym.o vers.o: opt_global.h
-
-depend: assym.s param.c vnode_if.h ${BEFORE_DEPEND} \
- ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES} ${SFILES} ${SYSTEM_SFILES}
- rm -f .newdep
- mkdep -a -f .newdep ${CFLAGS} ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES}
- env MKDEP_CPP="${CC} -E" \
- mkdep -a -f .newdep ${ASM_CFLAGS} ${SFILES} ${SYSTEM_SFILES}
- rm -f .depend
- mv -f .newdep .depend
-
-cleandepend:
- rm -f .depend
-
-links:
- egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
- sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
- echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
- sort -u | comm -23 - dontlink | \
- sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks
- sh makelinks && rm -f dontlink
-
-tags:
- @[ -f .depend ] || { echo "you must make depend first"; exit 1; }
- sh $S/conf/systags.sh
- rm -f tags1
- sed -e 's, ../, ,' tags > tags1
-
-install install.debug:
- @if [ ! -f ${KERNEL}${.TARGET:S/install//} ] ; then \
- echo "You must build a kernel first." ; \
- exit 1 ; \
- fi
-.if exists(${DESTDIR}/${KERNEL})
- -chflags noschg ${DESTDIR}/${KERNEL}
- mv ${DESTDIR}/${KERNEL} ${DESTDIR}/${KERNEL}.old
-.endif
- install -c -m 555 -o root -g wheel -fschg \
- ${KERNEL}${.TARGET:S/install//} ${DESTDIR}/${KERNEL}
-
-reinstall reinstall.debug:
- install -c -m 555 -o root -g wheel -fschg \
- ${KERNEL}${.TARGET:S/reinstall//} ${DESTDIR}/${KERNEL}
-
-config.o:
- ${NORMAL_C}
-
-ioconf.o:
- ${NORMAL_C}
-
-param.c: $S/conf/param.c
- -rm -f param.c
- cp $S/conf/param.c .
-
-param.o:
- ${NORMAL_C}
-
-vers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP}
- sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT}
-
-# XXX strictly, everything depends on Makefile because changes to ${PROF}
-# only appear there, but we don't handle that.
-vers.o:
- ${NORMAL_C}
-
-vnode_if.c: $S/kern/vnode_if.pl $S/kern/vnode_if.src
- perl5 $S/kern/vnode_if.pl -c $S/kern/vnode_if.src
-
-vnode_if.h: $S/kern/vnode_if.pl $S/kern/vnode_if.src
- perl5 $S/kern/vnode_if.pl -h $S/kern/vnode_if.src
-
-vnode_if.o:
- ${NORMAL_C}
-
-# Commented out for now pending a better solution.
-# How do we pick up compiler version specific flags??
-#.if exists($S/../share/mk)
-#.include "$S/../share/mk/bsd.kern.mk"
-#.else
-.include <bsd.kern.mk>
-#.endif
-
-%RULES
-
-# DO NOT DELETE THIS LINE -- make depend uses it
diff --git a/sys/conf/NOTES b/sys/conf/NOTES
deleted file mode 100644
index 9f129430e341..000000000000
--- a/sys/conf/NOTES
+++ /dev/null
@@ -1,2414 +0,0 @@
-#
-# LINT -- config file for checking all the sources, tries to pull in
-# as much of the source tree as it can.
-#
-# $FreeBSD$
-#
-# NB: You probably don't want to try running a kernel built from this
-# file. Instead, you should start from GENERIC, and add options from
-# this file as required.
-#
-
-#
-# This directive is mandatory; it defines the architecture to be
-# configured for; in this case, the 386 family based IBM-PC and
-# compatibles.
-#
-machine i386
-
-#
-# This is the ``identification'' of the kernel. Usually this should
-# be the same as the name of your kernel.
-#
-ident LINT
-
-#
-# The `maxusers' parameter controls the static sizing of a number of
-# internal system tables by a complicated formula defined in param.c.
-#
-maxusers 10
-
-#
-# The `makeoptions' parameter allows variables to be passed to the
-# generated Makefile in the build area.
-#
-# CONF_CFLAGS gives some extra compiler flags that are added to ${CFLAGS}
-# after most other flags. Here we use it to inhibit use of non-optimal
-# gcc builtin functions (e.g., memcmp).
-#
-# DEBUG happens to be magic.
-# The following is equivalent to 'config -g KERNELNAME' and creates
-# 'kernel.debug' compiled with -g debugging as well as a normal
-# 'kernel'. Use 'make install.debug' to install the debug kernel
-# but that isn't normally necessary as the debug symbols are not loaded
-# by the kernel and are not useful there anyway.
-#
-# KERNEL can be overridden so that you can change the default name of your
-# kernel.
-#
-makeoptions CONF_CFLAGS=-fno-builtin #Don't allow use of memcmp, etc.
-#makeoptions DEBUG=-g #Build kernel with gdb(1) debug symbols
-#makeoptions KERNEL=foo #Build kernel "foo" and install "/foo"
-
-#
-# Certain applications can grow to be larger than the 128M limit
-# that FreeBSD initially imposes. Below are some options to
-# allow that limit to grow to 256MB, and can be increased further
-# with changing the parameters. MAXDSIZ is the maximum that the
-# limit can be set to, and the DFLDSIZ is the default value for
-# the limit. You might want to set the default lower than the
-# max, and explicitly set the maximum with a shell command for processes
-# that regularly exceed the limit like INND.
-#
-options MAXDSIZ="(256*1024*1024)"
-options DFLDSIZ="(256*1024*1024)"
-
-#
-# BLKDEV_IOSIZE sets the default block size used in user block
-# device I/O. Note that this value will be overriden by the label
-# when specifying a block device from a label with a non-0
-# partition blocksize. The default is PAGE_SIZE.
-#
-options BLKDEV_IOSIZE=8192
-
-# Options for the VM subsystem
-#options PQ_NOOPT # No coloring
-options PQ_LARGECACHE # color for 512k/16k cache
-#options PQ_HUGECACHE # color for 1024k/16k cache
-#options PQ_MEDIUMCACHE # color for 64k/16k cache
-#options PQ_NORMALCACHE # color for 256k/16k cache
-
-# This allows you to actually store this configuration file into
-# the kernel binary itself, where it may be later read by saying:
-# strings -aout -n 3 /kernel | grep ^___ | sed -e 's/^___//' > MYKERNEL
-#
-options INCLUDE_CONFIG_FILE # Include this file in kernel
-
-
-#####################################################################
-# SMP OPTIONS:
-#
-# SMP enables building of a Symmetric MultiProcessor Kernel.
-# APIC_IO enables the use of the IO APIC for Symmetric I/O.
-# NCPU sets the number of CPUs, defaults to 2.
-# NBUS sets the number of busses, defaults to 4.
-# NAPIC sets the number of IO APICs on the motherboard, defaults to 1.
-# NINTR sets the total number of INTs provided by the motherboard.
-#
-# Notes:
-#
-# An SMP kernel will ONLY run on an Intel MP spec. qualified motherboard.
-#
-# Be sure to disable 'cpu I386_CPU' && 'cpu I486_CPU' for SMP kernels.
-#
-# Check the 'Rogue SMP hardware' section to see if additional options
-# are required by your hardware.
-#
-
-# Mandatory:
-options SMP # Symmetric MultiProcessor Kernel
-options APIC_IO # Symmetric (APIC) I/O
-
-# Optional, these are the defaults plus 1:
-options NCPU=5 # number of CPUs
-options NBUS=5 # number of busses
-options NAPIC=2 # number of IO APICs
-options NINTR=25 # number of INTs
-
-#
-# Rogue SMP hardware:
-#
-
-# Bridged PCI cards:
-#
-# The MP tables of most of the current generation MP motherboards
-# do NOT properly support bridged PCI cards. To use one of these
-# cards you should refer to ???
-
-
-#####################################################################
-# CPU OPTIONS
-
-#
-# You must specify at least one CPU (the one you intend to run on);
-# deleting the specification for CPUs you don't need to use may make
-# parts of the system run faster. This is especially true removing
-# I386_CPU.
-#
-cpu I386_CPU
-cpu I486_CPU
-cpu I586_CPU # aka Pentium(tm)
-cpu I686_CPU # aka Pentium Pro(tm)
-
-#
-# Options for CPU features.
-#
-# CPU_BLUELIGHTNING_FPU_OP_CACHE enables FPU operand cache on IBM
-# BlueLightning CPU. It works only with Cyrix FPU, and this option
-# should not be used with Intel FPU.
-#
-# CPU_BLUELIGHTNING_3X enables triple-clock mode on IBM Blue Lightning
-# CPU if CPU supports it. The default is double-clock mode on
-# BlueLightning CPU box.
-#
-# CPU_BTB_EN enables branch target buffer on Cyrix 5x86 (NOTE 1).
-#
-# CPU_DIRECT_MAPPED_CACHE sets L1 cache of Cyrix 486DLC CPU in direct
-# mapped mode. Default is 2-way set associative mode.
-#
-# CPU_CYRIX_NO_LOCK enables weak locking for the entire address space
-# of Cyrix 6x86 and 6x86MX CPUs by setting the NO_LOCK bit of CCR1.
-# Otherwise, the NO_LOCK bit of CCR1 is cleared. (NOTE 3)
-#
-# CPU_DISABLE_5X86_LSSER disables load store serialize (i.e. enables
-# reorder). This option should not be used if you use memory mapped
-# I/O device(s).
-#
-# CPU_FASTER_5X86_FPU enables faster FPU exception handler.
-#
-# CPU_I486_ON_386 enables CPU cache on i486 based CPU upgrade products
-# for i386 machines.
-#
-# CPU_IORT defines I/O clock delay time (NOTE 1). Default values of
-# I/O clock delay time on Cyrix 5x86 and 6x86 are 0 and 7,respectively
-# (no clock delay).
-#
-# CPU_LOOP_EN prevents flushing the prefetch buffer if the destination
-# of a jump is already present in the prefetch buffer on Cyrix 5x86(NOTE
-# 1).
-#
-# CPU_RSTK_EN enables return stack on Cyrix 5x86 (NOTE 1).
-#
-# CPU_SUSP_HLT enables suspend on HALT. If this option is set, CPU
-# enters suspend mode following execution of HALT instruction.
-#
-# CPU_WT_ALLOC enables write allocation on Cyrix 6x86/6x86MX and AMD
-# K5/K6/K6-2 cpus.
-#
-# CYRIX_CACHE_WORKS enables CPU cache on Cyrix 486 CPUs with cache
-# flush at hold state.
-#
-# CYRIX_CACHE_REALLY_WORKS enables (1) CPU cache on Cyrix 486 CPUs
-# without cache flush at hold state, and (2) write-back CPU cache on
-# Cyrix 6x86 whose revision < 2.7 (NOTE 2).
-#
-# NO_F00F_HACK disables the hack that prevents Pentiums (and ONLY
-# Pentiums) from locking up when a LOCK CMPXCHG8B instruction is
-# executed. This should be included for ALL kernels that won't run
-# on a Pentium.
-#
-# NO_MEMORY_HOLE is an optimisation for systems with AMD K6 processors
-# which indicates that the 15-16MB range is *definitely* not being
-# occupied by an ISA memory hole.
-#
-# NOTE 1: The options, CPU_BTB_EN, CPU_LOOP_EN, CPU_IORT,
-# CPU_LOOP_EN and CPU_RSTK_EN should not be used because of CPU bugs.
-# These options may crash your system.
-#
-# NOTE 2: If CYRIX_CACHE_REALLY_WORKS is not set, CPU cache is enabled
-# in write-through mode when revision < 2.7. If revision of Cyrix
-# 6x86 >= 2.7, CPU cache is always enabled in write-back mode.
-#
-# NOTE 3: This option may cause failures for software that requires
-# locked cycles in order to operate correctly.
-#
-options CPU_BLUELIGHTNING_FPU_OP_CACHE
-options CPU_BLUELIGHTNING_3X
-options CPU_BTB_EN
-options CPU_DIRECT_MAPPED_CACHE
-options CPU_DISABLE_5X86_LSSER
-options CPU_FASTER_5X86_FPU
-options CPU_I486_ON_386
-options CPU_IORT
-options CPU_LOOP_EN
-options CPU_RSTK_EN
-options CPU_SUSP_HLT
-options CPU_WT_ALLOC
-options CYRIX_CACHE_WORKS
-options CYRIX_CACHE_REALLY_WORKS
-#options NO_F00F_HACK
-
-#
-# A math emulator is mandatory if you wish to run on hardware which
-# does not have a floating-point processor. Pick either the original,
-# bogus (but freely-distributable) math emulator, or a much more
-# fully-featured but GPL-licensed emulator taken from Linux.
-#
-options MATH_EMULATE #Support for x87 emulation
-# Don't enable both of these in a real config.
-options GPL_MATH_EMULATE #Support for x87 emulation via
- #new math emulator
-
-
-#####################################################################
-# COMPATIBILITY OPTIONS
-
-#
-# Implement system calls compatible with 4.3BSD and older versions of
-# FreeBSD. You probably do NOT want to remove this as much current code
-# still relies on the 4.3 emulation.
-#
-options COMPAT_43
-
-#
-# Allow user-mode programs to manipulate their local descriptor tables.
-# This option is required for the WINE Windows(tm) emulator, and is
-# not used by anything else (that we know of).
-#
-options USER_LDT #allow user-level control of i386 ldt
-
-#
-# These three options provide support for System V Interface
-# Definition-style interprocess communication, in the form of shared
-# memory, semaphores, and message queues, respectively.
-#
-options SYSVSHM
-options SYSVSEM
-options SYSVMSG
-
-#
-# This option includes a MD5 routine in the kernel, this is used for
-# various authentication and privacy uses.
-#
-options MD5
-
-
-#####################################################################
-# DEBUGGING OPTIONS
-
-#
-# Enable the kernel debugger.
-#
-options DDB
-
-#
-# Don't drop into DDB for a panic. Intended for unattended operation
-# where you may want to drop to DDB from the console, but still want
-# the machine to recover from a panic
-#
-options DDB_UNATTENDED
-
-#
-# If using GDB remote mode to debug the kernel, there's a non-standard
-# extension to the remote protocol that can be used to use the serial
-# port as both the debugging port and the system console. It's non-
-# standard and you're on your own if you enable it. See also the
-# "remotechat" variables in the FreeBSD specific version of gdb.
-#
-options GDB_REMOTE_CHAT
-
-#
-# KTRACE enables the system-call tracing facility ktrace(2).
-#
-options KTRACE #kernel tracing
-
-#
-# The INVARIANTS option is used in a number of source files to enable
-# extra sanity checking of internal structures. This support is not
-# enabled by default because of the extra time it would take to check
-# for these conditions, which can only occur as a result of
-# programming errors.
-#
-options INVARIANTS
-
-#
-# The INVARIANT_SUPPORT option makes us compile in support for
-# verifying some of the internal structures. It is a prerequisite for
-# 'INVARIANTS', as enabling 'INVARIANTS' will make these functions be
-# called. The intent is that you can set 'INVARIANTS' for single
-# source files (by changing the source file or specifying it on the
-# command line) if you have 'INVARIANT_SUPPORT' enabled.
-#
-options INVARIANT_SUPPORT
-
-#
-# The DIAGNOSTIC option is used to enable extra debugging information
-# from some parts of the kernel. As this makes everything more noisy,
-# it is disabled by default.
-#
-options DIAGNOSTIC
-
-#
-# PERFMON causes the driver for Pentium/Pentium Pro performance counters
-# to be compiled. See perfmon(4) for more information.
-#
-options PERFMON
-
-
-#
-# This option let some drivers co-exist that can't co-exist in a running
-# system. This is used to be able to compile all kernel code in one go for
-# quality assurance purposes (like this file, which the option takes it name
-# from.)
-#
-options COMPILING_LINT
-
-
-# XXX - this doesn't belong here.
-# Allow ordinary users to take the console - this is useful for X.
-options UCONSOLE
-
-# XXX - this doesn't belong here either
-options USERCONFIG #boot -c editor
-options INTRO_USERCONFIG #imply -c and show intro screen
-options VISUAL_USERCONFIG #visual boot -c editor
-
-# XXX - neither does this
-options ROOTDEVNAME=\"da0s2e\"
-
-#####################################################################
-# NETWORKING OPTIONS
-
-#
-# Protocol families:
-# Only the INET (Internet) family is officially supported in FreeBSD.
-# Source code for the NS (Xerox Network Service) is provided for amusement
-# value.
-#
-options INET #Internet communications protocols
-options INET6 #IPv6 communications protocols
-options IPSEC #IP security
-options IPSEC_ESP #IP security (crypto; define w/ IPSEC)
-options IPSEC_IPV6FWD #IP security tunnel for IPv6
-options IPSEC_DEBUG #debug for IP security
-
-options IPX #IPX/SPX communications protocols
-options IPXIP #IPX in IP encapsulation (not available)
-options IPTUNNEL #IP in IPX encapsulation (not available)
-
-options NCP #NetWare Core protocol
-
-options NETATALK #Appletalk communications protocols
-
-# These are currently broken but are shipped due to interest.
-#options NS #Xerox NS protocols
-#options NSIP #XNS over IP
-
-# netgraph(4). Enable the base netgraph code with the NETGRAPH option.
-# Individual node types can be enabled with the corresponding option
-# listed below; however, this is not strictly necessary as netgraph
-# will automatically load the corresponding KLD module if the node type
-# is not already compiled into the kernel. Each type below has a
-# corresponding man page, e.g., ng_async(8).
-options NETGRAPH #netgraph(4) system
-options NETGRAPH_ASYNC
-options NETGRAPH_BPF
-options NETGRAPH_CISCO
-options NETGRAPH_ECHO
-options NETGRAPH_FRAME_RELAY
-options NETGRAPH_HOLE
-options NETGRAPH_IFACE
-options NETGRAPH_KSOCKET
-options NETGRAPH_LMI
-options NETGRAPH_PPP
-options NETGRAPH_PPPOE
-options NETGRAPH_PPTPGRE
-options NETGRAPH_RFC1490
-options NETGRAPH_SOCKET
-options NETGRAPH_TEE
-options NETGRAPH_TTY
-options NETGRAPH_UI
-options NETGRAPH_VJC
-
-device mn # Munich32x/Falc54 Nx64kbit/sec cards.
-
-#
-# Network interfaces:
-# The `loop' pseudo-device is MANDATORY when networking is enabled.
-# The `ether' pseudo-device provides generic code to handle
-# Ethernets; it is MANDATORY when a Ethernet device driver is
-# configured or token-ring is enabled.
-# The 'fddi' pseudo-device provides generic code to support FDDI.
-# The `sppp' pseudo-device serves a similar role for certain types
-# of synchronous PPP links (like `cx', `ar').
-# The `sl' pseudo-device implements the Serial Line IP (SLIP) service.
-# The `ppp' pseudo-device implements the Point-to-Point Protocol.
-# The `bpf' pseudo-device enables the Berkeley Packet Filter. Be
-# aware of the legal and administrative consequences of enabling this
-# option. The number of devices determines the maximum number of
-# simultaneous BPF clients programs runnable.
-# The `disc' pseudo-device implements a minimal network interface,
-# which throws away all packets sent and never receives any. It is
-# included for testing purposes. This shows up as the 'ds' interface.
-# The `tun' pseudo-device implements (user-)ppp and nos-tun
-# The `gif' pseudo-device implements IPv6 over IP4 tunneling,
-# IPv4 over IPv6 tunneling, IPv4 over IPv4 tunneling and
-# IPv6 over IPv6 tunneling.
-# The `faith' pseudo-device captures packets sent to it and diverts them
-# to the IPv4/IPv6 translation daemon.
-# The `ef' pseudo-device provides support for multiple ethernet frame types
-# specified via ETHER_* options. See ef(4) for details.
-#
-# The PPP_BSDCOMP option enables support for compress(1) style entire
-# packet compression, the PPP_DEFLATE is for zlib/gzip style compression.
-# PPP_FILTER enables code for filtering the ppp data stream and selecting
-# events for resetting the demand dial activity timer - requires bpf.
-# See pppd(8) for more details.
-#
-pseudo-device ether #Generic Ethernet
-pseudo-device token #Generic TokenRing
-pseudo-device fddi #Generic FDDI
-pseudo-device sppp #Generic Synchronous PPP
-pseudo-device loop #Network loopback device
-pseudo-device bpf #Berkeley packet filter
-pseudo-device disc #Discard device (ds0, ds1, etc)
-pseudo-device tun #Tunnel driver (ppp(8), nos-tun(8))
-pseudo-device sl 2 #Serial Line IP
-pseudo-device ppp 2 #Point-to-point protocol
-options PPP_BSDCOMP #PPP BSD-compress support
-options PPP_DEFLATE #PPP zlib/deflate/gzip support
-options PPP_FILTER #enable bpf filtering (needs bpf)
-
-pseudo-device ef # Multiple ethernet frames support
-options ETHER_II # enable Ethernet_II frame
-options ETHER_8023 # enable Ethernet_802.3 (Novell) frame
-options ETHER_8022 # enable Ethernet_802.2 frame
-options ETHER_SNAP # enable Ethernet_802.2/SNAP frame
-
-# for IPv6
-pseudo-device gif 4 #IPv6 and IPv4 tunneling
-pseudo-device faith 1 #for IPv6 and IPv4 translation
-
-#
-# Internet family options:
-#
-# TCP_COMPAT_42 causes the TCP code to emulate certain bugs present in
-# 4.2BSD. This option should not be used unless you have a 4.2BSD
-# machine and TCP connections fail.
-#
-# MROUTING enables the kernel multicast packet forwarder, which works
-# with mrouted(8).
-#
-# IPFIREWALL enables support for IP firewall construction, in
-# conjunction with the `ipfw' program. IPFIREWALL_VERBOSE sends
-# logged packets to the system logger. IPFIREWALL_VERBOSE_LIMIT
-# limits the number of times a matching entry can be logged.
-#
-# WARNING: IPFIREWALL defaults to a policy of "deny ip from any to any"
-# and if you do not add other rules during startup to allow access,
-# YOU WILL LOCK YOURSELF OUT. It is suggested that you set firewall_type=open
-# in /etc/rc.conf when first enabling this feature, then refining the
-# firewall rules in /etc/rc.firewall after you've tested that the new kernel
-# feature works properly.
-#
-# IPFIREWALL_DEFAULT_TO_ACCEPT causes the default rule (at boot) to
-# allow everything. Use with care, if a cracker can crash your
-# firewall machine, they can get to your protected machines. However,
-# if you are using it as an as-needed filter for specific problems as
-# they arise, then this may be for you. Changing the default to 'allow'
-# means that you won't get stuck if the kernel and /sbin/ipfw binary get
-# out of sync.
-#
-# IPDIVERT enables the divert IP sockets, used by ``ipfw divert''
-#
-# IPSTEALTH enables code to support stealth forwarding (i.e., forwarding
-# packets without touching the ttl). This can be useful to hide firewalls
-# from traceroute and similar tools.
-#
-# TCPDEBUG is undocumented.
-#
-options TCP_COMPAT_42 #emulate 4.2BSD TCP bugs
-options MROUTING # Multicast routing
-options IPFIREWALL #firewall
-options IPFIREWALL_VERBOSE #print information about
- # dropped packets
-options IPFIREWALL_FORWARD #enable transparent proxy support
-options IPFIREWALL_VERBOSE_LIMIT=100 #limit verbosity
-options IPFIREWALL_DEFAULT_TO_ACCEPT #allow everything by default
-options IPV6FIREWALL #firewall for IPv6
-options IPV6FIREWALL_VERBOSE
-options IPV6FIREWALL_VERBOSE_LIMIT=100
-options IPV6FIREWALL_DEFAULT_TO_ACCEPT
-options IPDIVERT #divert sockets
-options IPFILTER #ipfilter support
-options IPFILTER_LOG #ipfilter logging
-options IPSTEALTH #support for stealth forwarding
-options TCPDEBUG
-
-# The following options add sysctl variables for controlling how certain
-# TCP packets are handled.
-#
-# TCP_DROP_SYNFIN adds support for ignoring TCP packets with SYN+FIN. This
-# prevents nmap et al. from identifying the TCP/IP stack, but breaks support
-# for RFC1644 extensions and is not recommended for web servers.
-#
-# TCP_RESTRICT_RST adds support for blocking the emission of TCP RST packets.
-# This is useful on systems which are exposed to SYN floods (e.g. IRC servers)
-# or any system which one does not want to be easily portscannable.
-#
-options TCP_DROP_SYNFIN #drop TCP packets with SYN+FIN
-options TCP_RESTRICT_RST #restrict emission of TCP RST
-
-# ICMP_BANDLIM enables icmp error response bandwidth limiting. You
-# typically want this option as it will help protect the machine from
-# D.O.S. packet attacks.
-#
-options ICMP_BANDLIM
-
-# DUMMYNET enables the "dummynet" bandwidth limiter. You need
-# IPFIREWALL as well. See the dummynet(4) manpage for more info.
-# BRIDGE enables bridging between ethernet cards -- see bridge(4).
-# You can use IPFIREWALL and dummynet together with bridging.
-options DUMMYNET
-options BRIDGE
-
-#
-# ATM (HARP version) options
-#
-# ATM_CORE includes the base ATM functionality code. This must be included
-# for ATM support.
-#
-# ATM_IP includes support for running IP over ATM.
-#
-# At least one (and usually only one) of the following signalling managers
-# must be included (note that all signalling managers include PVC support):
-# ATM_SIGPVC includes support for the PVC-only signalling manager `sigpvc'.
-# ATM_SPANS includes support for the `spans' signalling manager, which runs
-# the FORE Systems's proprietary SPANS signalling protocol.
-# ATM_UNI includes support for the `uni30' and `uni31' signalling managers,
-# which run the ATM Forum UNI 3.x signalling protocols.
-#
-# The `hea' driver provides support for the Efficient Networks, Inc.
-# ENI-155p ATM PCI Adapter.
-#
-# The `hfa' driver provides support for the FORE Systems, Inc.
-# PCA-200E ATM PCI Adapter.
-#
-options ATM_CORE #core ATM protocol family
-options ATM_IP #IP over ATM support
-options ATM_SIGPVC #SIGPVC signalling manager
-options ATM_SPANS #SPANS signalling manager
-options ATM_UNI #UNI signalling manager
-device hea #Efficient ENI-155p ATM PCI
-device hfa #FORE PCA-200E ATM PCI
-
-
-#####################################################################
-# FILESYSTEM OPTIONS
-
-#
-# Only the root, /usr, and /tmp filesystems need be statically
-# compiled; everything else will be automatically loaded at mount
-# time. (Exception: the UFS family---FFS, and MFS --- cannot
-# currently be demand-loaded.) Some people still prefer to statically
-# compile other filesystems as well.
-#
-# NB: The NULL, PORTAL, UMAP and UNION filesystems are known to be
-# buggy, and WILL panic your system if you attempt to do anything with
-# them. They are included here as an incentive for some enterprising
-# soul to sit down and fix them.
-#
-
-# One of these is mandatory:
-options FFS #Fast filesystem
-options MFS #Memory File System
-options NFS #Network File System
-
-# The rest are optional:
-#options NFS_NOSERVER #Disable the NFS-server code.
-options CD9660 #ISO 9660 filesystem
-options FDESC #File descriptor filesystem
-options KERNFS #Kernel filesystem
-options MSDOSFS #MS DOS File System
-options NTFS #NT File System
-options NULLFS #NULL filesystem
-options NWFS #NetWare filesystem
-options PORTAL #Portal filesystem
-options PROCFS #Process filesystem
-options UMAPFS #UID map filesystem
-options UNION #Union filesystem
-# The xFS_ROOT options REQUIRE the associated ``options xFS''
-options CD9660_ROOT #CD-ROM usable as root device
-options FFS_ROOT #FFS usable as root device
-options NFS_ROOT #NFS usable as root device
-# This code is still experimental (e.g. doesn't handle disk slices well).
-# Also, 'options MFS' is currently incompatible with DEVFS.
-options DEVFS #devices filesystem
-
-# Soft updates is technique for improving file system speed and
-# making abrupt shutdown less risky. It is not enabled by default due
-# to copyright restraints on the code that implement it.
-#
-# Read ../../ufs/ffs/README.softupdates to learn what you need to
-# do to enable this. ../../contrib/softupdates/README gives
-# more details on how they actually work.
-#
-#options SOFTUPDATES
-
-# Make space in the kernel for a root filesystem on a md device.
-# Define to the number of kilobytes to reserve for the filesystem.
-options MD_ROOT_SIZE=10
-
-# Make the md device a potential root device, either with preloaded
-# images of type mfs_root or md_root.
-options MD_ROOT
-
-# Allow this many swap-devices.
-options NSWAPDEV=20
-
-# Disk quotas are supported when this option is enabled.
-options QUOTA #enable disk quotas
-
-# If you are running a machine just as a fileserver for PC and MAC
-# users, using SAMBA or Netatalk, you may consider setting this option
-# and keeping all those users' directories on a filesystem that is
-# mounted with the suiddir option. This gives new files the same
-# ownership as the directory (similar to group). It's a security hole
-# if you let these users run programs, so confine it to file-servers
-# (but it'll save you lots of headaches in those cases). Root owned
-# directories are exempt and X bits are cleared. The suid bit must be
-# set on the directory as well; see chmod(1) PC owners can't see/set
-# ownerships so they keep getting their toes trodden on. This saves
-# you all the support calls as the filesystem it's used on will act as
-# they expect: "It's my dir so it must be my file".
-#
-options SUIDDIR
-
-# NFS options:
-options NFS_MINATTRTIMO=3 # VREG attrib cache timeout in sec
-options NFS_MAXATTRTIMO=60
-options NFS_MINDIRATTRTIMO=30 # VDIR attrib cache timeout in sec
-options NFS_MAXDIRATTRTIMO=60
-options NFS_GATHERDELAY=10 # Default write gather delay (msec)
-options NFS_UIDHASHSIZ=29 # Tune the size of nfssvc_sock with this
-options NFS_WDELAYHASHSIZ=16 # and with this
-options NFS_MUIDHASHSIZ=63 # Tune the size of nfsmount with this
-options NFS_DEBUG # Enable NFS Debugging
-
-# Coda stuff:
-options CODA #CODA filesystem.
-pseudo-device vcoda 4 #coda minicache <-> venus comm.
-
-#
-# Add support for the EXT2FS filesystem of Linux fame. Be a bit
-# careful with this - the ext2fs code has a tendency to lag behind
-# changes and not be exercised very much, so mounting read/write could
-# be dangerous (and even mounting read only could result in panics.)
-#
-options EXT2FS
-
-# Use real implementations of the aio_* system calls. There are numerous
-# stability issues in the current aio code that make it unsuitable for
-# inclusion on shell boxes.
-options VFS_AIO
-
-
-#####################################################################
-# POSIX P1003.1B
-
-# Real time extensions added in the 1993 Posix
-# P1003_1B: Infrastructure
-# _KPOSIX_PRIORITY_SCHEDULING: Build in _POSIX_PRIORITY_SCHEDULING
-# _KPOSIX_VERSION: Version kernel is built for
-
-options P1003_1B
-options _KPOSIX_PRIORITY_SCHEDULING
-options _KPOSIX_VERSION=199309L
-
-
-#####################################################################
-# SCSI DEVICES
-
-# SCSI DEVICE CONFIGURATION
-
-# The SCSI subsystem consists of the `base' SCSI code, a number of
-# high-level SCSI device `type' drivers, and the low-level host-adapter
-# device drivers. The host adapters are listed in the ISA and PCI
-# device configuration sections below.
-#
-# Beginning with FreeBSD 2.0.5 you can wire down your SCSI devices so
-# that a given bus, target, and LUN always come on line as the same
-# device unit. In earlier versions the unit numbers were assigned
-# in the order that the devices were probed on the SCSI bus. This
-# means that if you removed a disk drive, you may have had to rewrite
-# your /etc/fstab file, and also that you had to be careful when adding
-# a new disk as it may have been probed earlier and moved your device
-# configuration around.
-
-# This old behavior is maintained as the default behavior. The unit
-# assignment begins with the first non-wired down unit for a device
-# type. For example, if you wire a disk as "da3" then the first
-# non-wired disk will be assigned da4.
-
-# The syntax for wiring down devices is:
-
-# device scbus0 at ahc0 # Single bus device
-# device scbus1 at ahc1 bus 0 # Single bus device
-# device scbus3 at ahc2 bus 0 # Twin bus device
-# device scbus2 at ahc2 bus 1 # Twin bus device
-# device da0 at scbus0 target 0 unit 0
-# device da1 at scbus3 target 1
-# device da2 at scbus2 target 3
-# device sa1 at scbus1 target 6
-# device cd
-
-# "units" (SCSI logical unit number) that are not specified are
-# treated as if specified as LUN 0.
-
-# All SCSI devices allocate as many units as are required.
-
-# The "unknown" device (uk? in pre-2.0.5) is now part of the base SCSI
-# configuration and doesn't have to be explicitly configured.
-
-device scbus #base SCSI code
-device ch #SCSI media changers
-device da #SCSI direct access devices (aka disks)
-device sa #SCSI tapes
-device cd #SCSI CD-ROMs
-device pass #CAM passthrough driver
-device pt #SCSI processor type
-device ses #SCSI SES/SAF-TE driver
-
-# CAM OPTIONS:
-# debugging options:
-# -- NOTE -- If you specify one of the bus/target/lun options, you must
-# specify them all!
-# CAMDEBUG: When defined enables debugging macros
-# CAM_DEBUG_BUS: Debug the given bus. Use -1 to debug all busses.
-# CAM_DEBUG_TARGET: Debug the given target. Use -1 to debug all targets.
-# CAM_DEBUG_LUN: Debug the given lun. Use -1 to debug all luns.
-# CAM_DEBUG_FLAGS: OR together CAM_DEBUG_INFO, CAM_DEBUG_TRACE,
-# CAM_DEBUG_SUBTRACE, and CAM_DEBUG_CDB
-#
-# CAM_MAX_HIGHPOWER: Maximum number of concurrent high power (start unit) cmds
-# SCSI_NO_SENSE_STRINGS: When defined disables sense descriptions
-# SCSI_NO_OP_STRINGS: When defined disables opcode descriptions
-# SCSI_DELAY: The number of MILLISECONDS to freeze the SIM (scsi adapter)
-# queue after a bus reset, and the number of milliseconds to
-# freeze the device queue after a bus device reset.
-options CAMDEBUG
-options CAM_DEBUG_BUS=-1
-options CAM_DEBUG_TARGET=-1
-options CAM_DEBUG_LUN=-1
-options CAM_DEBUG_FLAGS="CAM_DEBUG_INFO|CAM_DEBUG_TRACE|CAM_DEBUG_CDB"
-options CAM_MAX_HIGHPOWER=4
-options SCSI_NO_SENSE_STRINGS
-options SCSI_NO_OP_STRINGS
-options SCSI_DELAY=8000 # Be pessimistic about Joe SCSI device
-
-# Options for the CAM CDROM driver:
-# CHANGER_MIN_BUSY_SECONDS: Guaranteed minimum time quantum for a changer LUN
-# CHANGER_MAX_BUSY_SECONDS: Maximum time quantum per changer LUN, only
-# enforced if there is I/O waiting for another LUN
-# The compiled in defaults for these variables are 2 and 10 seconds,
-# respectively.
-#
-# These can also be changed on the fly with the following sysctl variables:
-# kern.cam.cd.changer.min_busy_seconds
-# kern.cam.cd.changer.max_busy_seconds
-#
-options CHANGER_MIN_BUSY_SECONDS=2
-options CHANGER_MAX_BUSY_SECONDS=10
-
-# Options for the CAM sequential access driver:
-# SA_SPACE_TIMEOUT: Timeout for space operations, in minutes
-# SA_REWIND_TIMEOUT: Timeout for rewind operations, in minutes
-# SA_ERASE_TIMEOUT: Timeout for erase operations, in minutes
-# SA_1FM_AT_EOD: Default to model which only has a default one filemark at EOT.
-options SA_SPACE_TIMEOUT="(60)"
-options SA_REWIND_TIMEOUT="(2*60)"
-options SA_ERASE_TIMEOUT="(4*60)"
-options SA_1FM_AT_EOD
-
-# Optional timeout for the CAM processor target (pt) device
-# This is specified in seconds. The default is 60 seconds.
-options SCSI_PT_DEFAULT_TIMEOUT="60"
-
-# Optional enable of doing SES passthrough on other devices (e.g., disks)
-#
-# Normally disabled because a lot of newer SCSI disks report themselves
-# as having SES capabilities, but this can then clot up attempts to build
-# build a topology with the SES device that's on the box these drives
-# are in....
-options SES_ENABLE_PASSTHROUGH
-
-
-#####################################################################
-# MISCELLANEOUS DEVICES AND OPTIONS
-
-# The `pty' device usually turns out to be ``effectively mandatory'',
-# as it is required for `telnetd', `rlogind', `screen', `emacs', and
-# `xterm', among others.
-
-pseudo-device pty #Pseudo ttys
-pseudo-device speaker #Play IBM BASIC-style noises out your speaker
-pseudo-device gzip #Exec gzipped a.out's
-pseudo-device vn #Vnode driver (turns a file into a device)
-pseudo-device md #Memory/malloc disk
-pseudo-device snp 3 #Snoop device - to look at pty/vty/etc..
-pseudo-device ccd 4 #Concatenated disk driver
-
-# Configuring Vinum into the kernel is not necessary, since the kld
-# module gets started automatically when vinum(8) starts. This
-# device is also untested. Use at your own risk.
-#
-# The option VINUMDEBUG must match the value set in CFLAGS
-# in src/sbin/vinum/Makefile. Failure to do so will result in
-# the following message from vinum(8):
-#
-# Can't get vinum config: Invalid argument
-#
-# see vinum(4) for more reasons not to use these options.
-pseudo-device vinum #Vinum concat/mirror/raid driver
-options VINUMDEBUG #enable Vinum debugging hooks
-
-# Size of the kernel message buffer. Should be N * pagesize.
-options MSGBUF_SIZE=40960
-
-
-#####################################################################
-# HARDWARE DEVICE CONFIGURATION
-
-# ISA and EISA devices:
-# EISA support is available for some device, so they can be auto-probed.
-# MicroChannel (MCA) support is available for some devices.
-
-#
-# Mandatory ISA devices: isa, npx
-#
-device isa
-
-#
-# Options for `isa':
-#
-# AUTO_EOI_1 enables the `automatic EOI' feature for the master 8259A
-# interrupt controller. This saves about 0.7-1.25 usec for each interrupt.
-# This option breaks suspend/resume on some portables.
-#
-# AUTO_EOI_2 enables the `automatic EOI' feature for the slave 8259A
-# interrupt controller. This saves about 0.7-1.25 usec for each interrupt.
-# Automatic EOI is documented not to work for for the slave with the
-# original i8259A, but it works for some clones and some integrated
-# versions.
-#
-# MAXMEM specifies the amount of RAM on the machine; if this is not
-# specified, FreeBSD will first read the amount of memory from the CMOS
-# RAM, so the amount of memory will initially be limited to 64MB or 16MB
-# depending on the BIOS. If the BIOS reports 64MB, a memory probe will
-# then attempt to detect the installed amount of RAM. If this probe
-# fails to detect >64MB RAM you will have to use the MAXMEM option.
-# The amount is in kilobytes, so for a machine with 128MB of RAM, it would
-# be 131072 (128 * 1024).
-#
-# BROKEN_KEYBOARD_RESET disables the use of the keyboard controller to
-# reset the CPU for reboot. This is needed on some systems with broken
-# keyboard controllers.
-#
-# PAS_JOYSTICK_ENABLE enables the gameport on the ProAudio Spectrum
-
-options AUTO_EOI_1
-#options AUTO_EOI_2
-options MAXMEM="(128*1024)"
-#options BROKEN_KEYBOARD_RESET
-#options PAS_JOYSTICK_ENABLE
-
-# Enable support for the kernel PLL to use an external PPS signal,
-# under supervision of [x]ntpd(8)
-# More info in ntpd documentation: http://www.eecis.udel.edu/~ntp
-
-options PPS_SYNC
-
-# If you see the "calcru: negative time of %ld usec for pid %d (%s)\n"
-# message you probably have some broken sw/hw which disables interrupts
-# for too long. You can make the system more resistant to this by
-# choosing a high value for NTIMECOUNTER. The default is 5, there
-# is no upper limit but more than a couple of hundred are not productive.
-# A better strategy may be to sysctl -w kern.timecounter.method=1
-
-options NTIMECOUNTER=20
-
-# The keyboard controller; it controls the keyboard and the PS/2 mouse.
-device atkbdc0 at isa? port IO_KBD
-
-# The AT keyboard
-device atkbd0 at atkbdc? irq 1
-
-# Options for atkbd:
-options ATKBD_DFLT_KEYMAP # specify the built-in keymap
-makeoptions ATKBD_DFLT_KEYMAP="jp.106"
-
-# These options are valid for other keyboard drivers as well.
-options KBD_DISABLE_KEYMAP_LOAD # refuse to load a keymap
-options KBD_INSTALL_CDEV # install a CDEV entry in /dev
-
-# `flags' for atkbd:
-# 0x01 Force detection of keyboard, else we always assume a keyboard
-# 0x02 Don't reset keyboard, useful for some newer ThinkPads
-# 0x04 Old-style (XT) keyboard support, useful for older ThinkPads
-
-# PS/2 mouse
-device psm0 at atkbdc? irq 12
-
-# Options for psm:
-options PSM_HOOKRESUME #hook the system resume event, useful
- #for some laptops
-options PSM_RESETAFTERSUSPEND #reset the device at the resume event
-
-# The video card driver.
-device vga0 at isa?
-
-# Options for vga:
-# Try the following option if the mouse pointer is not drawn correctly
-# or font does not seem to be loaded properly. May cause flicker on
-# some systems.
-options VGA_ALT_SEQACCESS
-
-# If you can dispense with some vga driver features, you may want to
-# use the following options to save some memory.
-options VGA_NO_FONT_LOADING # don't save/load font
-options VGA_NO_MODE_CHANGE # don't change video modes
-
-# Older video cards may require this option for proper operation.
-options VGA_SLOW_IOACCESS # do byte-wide i/o's to TS and GDC regs
-
-# The following option probably won't work with the LCD displays.
-options VGA_WIDTH90 # support 90 column modes
-
-# To include support for VESA video modes
-options VESA
-
-# Splash screen at start up! Screen savers require this too.
-pseudo-device splash
-
-# The pcvt console driver (vt220 compatible).
-device vt0 at isa?
-options XSERVER # support for running an X server on vt
-options FAT_CURSOR # start with block cursor
-# This PCVT option is for keyboards such as those used on IBM ThinkPad laptops
-options PCVT_SCANSET=2 # IBM keyboards are non-std
-# Other PCVT options are documented in pcvt(4).
-options PCVT_24LINESDEF
-options PCVT_CTRL_ALT_DEL
-options PCVT_EMU_MOUSE
-options PCVT_FREEBSD=211
-options PCVT_META_ESC
-options PCVT_NSCREENS=9
-options PCVT_PRETTYSCRNS
-options PCVT_SCREENSAVER
-options PCVT_USEKBDSEC
-options PCVT_VT220KEYB
-
-# The syscons console driver (sco color console compatible).
-device sc0 at isa?
-options MAXCONS=16 # number of virtual consoles
-options SC_ALT_MOUSE_IMAGE # simplified mouse cursor in text mode
-options SC_DFLT_FONT # compile font in
-makeoptions SC_DFLT_FONT=cp850
-options SC_DISABLE_DDBKEY # disable `debug' key
-options SC_DISABLE_REBOOT # disable reboot key sequence
-options SC_HISTORY_SIZE=200 # number of history buffer lines
-options SC_MOUSE_CHAR=0x3 # char code for text mode mouse cursor
-options SC_PIXEL_MODE # add support for the raster text mode
-
-# The following options will let you change the default colors of syscons.
-options SC_NORM_ATTR="(FG_GREEN|BG_BLACK)"
-options SC_NORM_REV_ATTR="(FG_YELLOW|BG_GREEN)"
-options SC_KERNEL_CONS_ATTR="(FG_RED|BG_BLACK)"
-options SC_KERNEL_CONS_REV_ATTR="(FG_BLACK|BG_RED)"
-
-# If you have a two button mouse, you may want to add the following option
-# to use the right button of the mouse to paste text.
-options SC_TWOBUTTON_MOUSE
-
-# You can selectively disable features in syscons.
-options SC_NO_CUTPASTE
-options SC_NO_FONT_LOADING
-options SC_NO_HISTORY
-options SC_NO_SYSMOUSE
-
-#
-# The Numeric Processing eXtension driver. In addition to this, you
-# may configure a math emulator (see above). If your machine has a
-# hardware FPU and the kernel configuration includes the npx device
-# *and* a math emulator compiled into the kernel, the hardware FPU
-# will be used, unless it is found to be broken or unless "flags" to
-# npx0 includes "0x08", which requests preference for the emulator.
-device npx0 at nexus? port IO_NPX flags 0x0 irq 13
-
-#
-# `flags' for npx0:
-# 0x01 don't use the npx registers to optimize bcopy.
-# 0x02 don't use the npx registers to optimize bzero.
-# 0x04 don't use the npx registers to optimize copyin or copyout.
-# 0x08 use emulator even if hardware FPU is available.
-# The npx registers are normally used to optimize copying and zeroing when
-# all of the following conditions are satisfied:
-# I586_CPU is an option
-# the cpu is an i586 (perhaps not a Pentium)
-# the probe for npx0 succeeds
-# INT 16 exception handling works.
-# Then copying and zeroing using the npx registers is normally 30-100% faster.
-# The flags can be used to control cases where it doesn't work or is slower.
-# Setting them at boot time using userconfig works right (the optimizations
-# are not used until later in the bootstrap when npx0 is attached).
-# Flag 0x08 automatically disables the i586 optimized routines.
-#
-
-#
-# Optional ISA and EISA devices:
-#
-
-#
-# SCSI host adapters: `aha', `aic', `bt'
-#
-# adv: All Narrow SCSI bus AdvanSys controllers.
-# adw: Second Generation AdvanSys controllers including the ADV940UW.
-# aha: Adaptec 154x
-# ahc: Adaptec 274x/284x/294x
-# aic: Adaptec 152x
-# bt: Most Buslogic controllers
-#
-# Note that the order is important in order for Buslogic cards to be
-# probed correctly.
-#
-
-device bt0 at isa? port IO_BT0
-device adv0 at isa?
-device adw
-device aha0 at isa?
-device aic0 at isa?
-
-#
-# Compaq Smart RAID, Mylex DAC960 and AMI MegaRAID controllers. Only
-# one entry is needed; the code will find and configure all supported
-# controllers.
-#
-device ida # Compaq Smart RAID
-device mlx # Mylex DAC960
-device amr # AMI MegaRAID
-
-#
-# The 'ATA' driver supports all ATA and ATAPI devices.
-# It can reuse the majors of wd.c for booting purposes.
-# You only need one "device ata" for it to find all
-# PCI ATA/ATAPI devices on modern machines.
-device ata
-device atadisk # ATA disk drives
-device atapicd # ATAPI CDROM drives
-device atapifd # ATAPI floppy drives
-device atapist # ATAPI tape drives
-
-#The folliwing options are valid on the ATA driver:
-#
-# ATA_STATIC_ID: controller numbering is static (like the old driver)
-# else the device numbers are dynamically allocated.
-# ATA_ENABLE_ATAPI_DMA: enable DMA on ATAPI device, since many ATAPI devices
-# claim to support DMA but doesn't actually work, this
-# is not enabled as default.
-
-options ATA_STATIC_ID
-options ATA_ENABLE_ATAPI_DMA
-
-#
-# For older non-PCI systems, these are the lines to use:
-#device ata0 at isa? port IO_WD1 irq 14
-#device ata1 at isa? port IO_WD2 irq 15
-
-#
-# ST-506, ESDI, and IDE hard disks: `wdc' and `wd'
-#
-# The flags fields are used to enable the multi-sector I/O and
-# the 32BIT I/O modes. The flags may be used in either the controller
-# definition or in the individual disk definitions. The controller
-# definition is supported for the boot configuration stuff.
-#
-# Each drive has a 16 bit flags value defined:
-# The low 8 bits are the maximum value for the multi-sector I/O,
-# where 0xff defaults to the maximum that the drive can handle.
-# The high bit of the 16 bit flags (0x8000) allows probing for
-# 32 bit transfers. Bit 14 (0x4000) enables a hack to wake
-# up powered-down laptop drives. Bit 13 (0x2000) allows
-# probing for PCI IDE DMA controllers, such as Intel's PIIX
-# south bridges. Bit 12 (0x1000) sets LBA mode instead of the
-# default CHS mode for accessing the drive. See the wd.4 man page.
-#
-# The flags field for the drives can be specified in the controller
-# specification with the low 16 bits for drive 0, and the high 16 bits
-# for drive 1.
-# e.g.:
-#device wdc0 at isa? port IO_WD1 irq 14 flags 0x00ff8004
-#
-# specifies that drive 0 will be allowed to probe for 32 bit transfers and
-# a maximum multi-sector transfer of 4 sectors, and drive 1 will not be
-# allowed to probe for 32 bit transfers, but will allow multi-sector
-# transfers up to the maximum that the drive supports.
-#
-# If you are using a PCI controller that is not running in compatibility
-# mode (for example, it is a 2nd IDE PCI interface), then use config line(s)
-# such as:
-#
-#device wdc2 at isa? port 0 flags 0xa0ffa0ff
-#device wd4 at wdc2 drive 0
-#device wd5 at wdc2 drive 1
-#
-#device wdc3 at isa? port 0 flags 0xa0ffa0ff
-#device wd6 at wdc3 drive 0
-#device wd7 at wdc3 drive 1
-#
-# Note that the above config would be useful for a Promise card, when used
-# on a MB that already has a PIIX controller. Note the bogus irq and port
-# entries. These are automatically filled in by the IDE/PCI support.
-#
-# This driver must be commented out because it is mutually exclusive with
-# the ata(4) driver.
-#
-device wdc0 at isa? port IO_WD1 irq 14
-device wd0 at wdc0 drive 0
-device wd1 at wdc0 drive 1
-device wdc1 at isa? port IO_WD2 irq 15
-device wd2 at wdc1 drive 0
-device wd3 at wdc1 drive 1
-
-#
-# This option allow you to override the default probe time for IDE
-# devices, to get a faster probe. Setting this below 10000 violate
-# the IDE specs, but may still work for you (it will work for most
-# people).
-#
-options IDE_DELAY=8000 # Be optimistic about Joe IDE device
-
-# IDE CD-ROM & CD-R/RW driver - requires wdc controller
-device wcd
-
-# IDE floppy driver - requires wdc controller
-device wfd
-
-# IDE tape driver - requires wdc controller
-device wst
-
-
-#
-# Standard floppy disk controllers and floppy tapes: `fdc', `fd', and `ft'
-#
-device fdc0 at isa? port IO_FD1 irq 6 drq 2
-#
-# FDC_DEBUG enables floppy debugging. Since the debug output is huge, you
-# gotta turn it actually on by setting the variable fd_debug with DDB,
-# however.
-options FDC_DEBUG
-#
-# Activate this line instead of the fdc0 line above if you happen to
-# have an Insight floppy tape. Probing them proved to be dangerous
-# for people with floppy disks only, so it's "hidden" behind a flag:
-#device fdc0 at isa? port IO_FD1 flags 1 irq 6 drq 2
-
-device fd0 at fdc0 drive 0
-device fd1 at fdc0 drive 1
-
-# M-systems DiskOnchip products see src/sys/contrib/dev/fla/README
-device fla0 at isa?
-
-#
-# Other standard PC hardware: `mse', `sio', etc.
-#
-# mse: Logitech and ATI InPort bus mouse ports
-# sio: serial ports (see sio(4))
-
-device mse0 at isa? port 0x23c irq 5
-
-device sio0 at isa? port IO_COM1 flags 0x10 irq 4
-
-#
-# `flags' for serial drivers that support consoles (only for sio now):
-# 0x10 enable console support for this unit. The other console flags
-# are ignored unless this is set. Enabling console support does
-# not make the unit the preferred console - boot with -h or set
-# the 0x20 flag for that. Currently, at most one unit can have
-# console support; the first one (in config file order) with
-# this flag set is preferred. Setting this flag for sio0 gives
-# the old behaviour.
-# 0x20 force this unit to be the console (unless there is another
-# higher priority console). This replaces the COMCONSOLE option.
-# 0x40 reserve this unit for low level console operations. Do not
-# access the device in any normal way.
-# 0x80 use this port for serial line gdb support in ddb.
-#
-# PnP `flags' (set via userconfig using pnp x flags y)
-# 0x1 disable probing of this device. Used to prevent your modem
-# from being attached as a PnP modem.
-#
-
-# Options for serial drivers that support consoles (only for sio now):
-options BREAK_TO_DEBUGGER #a BREAK on a comconsole goes to
- #DDB, if available.
-options CONSPEED=9600 #default speed for serial console (default 9600)
-
-# Options for sio:
-options COM_ESP #code for Hayes ESP
-options COM_MULTIPORT #code for some cards with shared IRQs
-
-# Other flags for sio that aren't documented in the man page.
-# 0x20000 enable hardware RTS/CTS and larger FIFOs. Only works for
-# ST16650A-compatible UARTs.
-
-#
-# Network interfaces: `cx', `ed', `el', `ep', `ie', `is', `le', `lnc'
-#
-# ar: Arnet SYNC/570i hdlc sync 2/4 port V.35/X.21 serial driver (requires sppp)
-# cs: IBM Etherjet and other Crystal Semi CS89x0-based adapters
-# cx: Cronyx/Sigma multiport sync/async (with Cisco or PPP framing)
-# ed: Western Digital and SMC 80xx; Novell NE1000 and NE2000; 3Com 3C503
-# el: 3Com 3C501 (slow!)
-# ep: 3Com 3C509
-# ex: Intel EtherExpress Pro/10 and other i82595-based adapters
-# fe: Fujitsu MB86960A/MB86965A Ethernet
-# ie: AT&T StarLAN 10 and EN100; 3Com 3C507; unknown NI5210; Intel EtherExpress
-# le: Digital Equipment EtherWorks 2 and EtherWorks 3 (DEPCA, DE100,
-# DE101, DE200, DE201, DE202, DE203, DE204, DE205, DE422)
-# lnc: Lance/PCnet cards (Isolan, Novell NE2100, NE32-VL, AMD Am7990 & Am79C960)
-# rdp: RealTek RTL 8002-based pocket ethernet adapters
-# sr: RISCom/N2 hdlc sync 1/2 port V.35/X.21 serial driver (requires sppp)
-# wl: Lucent Wavelan (ISA card only).
-# wi: Lucent WaveLAN/IEEE 802.11 PCMCIA adapters. Note: this supports both
-# the PCMCIA and ISA cards: the ISA card is really a PCMCIA to ISA
-# bridge with a PCMCIA adapter plugged into it.
-# an: Aironet 4500/4800 802.11 wireless adapters. Supports the PCMCIA,
-# PCI and ISA varieties.
-# xe: Xircom/Intel EtherExpress Pro100/16 PC Card ethernet controller.
-# oltr: Olicom ISA token-ring adapters OC-3115, OC-3117, OC-3118 and OC-3133
-# (no options needed)
-#
-device ar0 at isa? port 0x300 irq 10 iomem 0xd0000
-device cs0 at isa? port 0x300
-device cx0 at isa? port 0x240 irq 15 drq 7
-device ed0 at isa? port 0x280 irq 5 iomem 0xd8000
-device el0 at isa? port 0x300 irq 9
-device ep
-device ex
-device fe0 at isa? port 0x300
-device ie0 at isa? port 0x300 irq 5 iomem 0xd0000
-device ie1 at isa? port 0x360 irq 7 iomem 0xd0000
-device le0 at isa? port 0x300 irq 5 iomem 0xd0000
-device lnc0 at isa? port 0x280 irq 10 drq 0
-device rdp0 at isa? port 0x378 irq 7 flags 2
-device sr0 at isa? port 0x300 irq 5 iomem 0xd0000
-device sn0 at isa? port 0x300 irq 10
-device wi
-device an
-options WLCACHE # enables the signal-strength cache
-options WLDEBUG # enables verbose debugging output
-device wl0 at isa? port 0x300
-device xe0 at isa?
-
-device oltr0 at isa?
-
-#
-# ATM related options
-#
-# The `en' device provides support for Efficient Networks (ENI)
-# ENI-155 PCI midway cards, and the Adaptec 155Mbps PCI ATM cards (ANA-59x0).
-#
-# atm pseudo-device provides generic atm functions and is required for
-# atm devices.
-# NATM enables the netnatm protocol family that can be used to
-# bypass TCP/IP.
-#
-# the current driver supports only PVC operations (no atm-arp, no multicast).
-# for more details, please read the original documents at
-# http://www.ccrc.wustl.edu/pub/chuck/tech/bsdatm/bsdatm.html
-#
-pseudo-device atm
-device en
-options NATM #native ATM
-
-#
-# Audio drivers: `snd', `sb', `pas', `gus', `pca'
-#
-# snd: Voxware sound support code
-# sb: SoundBlaster PCM - SoundBlaster, SB Pro, SB16, ProAudioSpectrum
-# sbxvi: SoundBlaster 16
-# sbmidi: SoundBlaster 16 MIDI interface
-# pas: ProAudioSpectrum PCM and MIDI
-# gus: Gravis Ultrasound - Ultrasound, Ultrasound 16, Ultrasound MAX
-# gusxvi: Gravis Ultrasound 16-bit PCM (do not use)
-# mss: Microsoft Sound System
-# css: Crystal Sound System (CSS 423x PnP)
-# sscape: Ensoniq Soundscape MIDI interface
-# sscape_mss: Ensoniq Soundscape PCM (requires sscape)
-# opl: Yamaha OPL-2 and OPL-3 FM - SB, SB Pro, SB 16, ProAudioSpectrum
-# uart: stand-alone 6850 UART for MIDI
-# mpu: Roland MPU-401 stand-alone card
-#
-# Note: It has been reported that ISA DMA with the SoundBlaster will
-# lock up the machine (PR docs/5358). If this happens to you,
-# turning off USWC write posting in your machine's BIOS may fix
-# the problem.
-#
-# Beware! The addresses specified below are also hard-coded in
-# src/sys/i386/isa/sound/sound_config.h. If you change the values here, you
-# must also change the values in the include file.
-#
-# pcm: PCM audio through various sound cards.
-#
-# This has support for a large number of new audio cards, based on
-# CS423x, OPTi931, Yamaha OPL-SAx, and also for SB16, GusPnP.
-# For more information about this driver and supported cards,
-# see the pcm.4 man page.
-#
-# The flags of the device tells the device a bit more info about the
-# device that normally is obtained through the PnP interface.
-# bit 2..0 secondary DMA channel;
-# bit 4 set if the board uses two dma channels;
-# bit 15..8 board type, overrides autodetection; leave it
-# zero if don't know what to put in (and you don't,
-# since this is unsupported at the moment...).
-#
-# This driver will use the new PnP code if it's available.
-#
-# pca: PCM audio through your PC speaker
-#
-# If you have a GUS-MAX card and want to use the CS4231 codec on the
-# card the drqs for the gus max must be 8 bit (1, 2, or 3).
-#
-# If you would like to use the full duplex option on the gus, then define
-# flags to be the ``read dma channel''.
-#
-# options BROKEN_BUS_CLOCK #PAS-16 isn't working and OPTI chipset
-# options SYMPHONY_PAS #PAS-16 isn't working and SYMPHONY chipset
-# options EXCLUDE_SBPRO #PAS-16
-# options SBC_IRQ=5 #PAS-16. Must match irq on sb0 line.
-# PAS16: The order of the pas0/sb0/opl0 is important since the
-# sb emulation is enabled in the pas-16 attach.
-#
-# To override the GUS defaults use:
-# options GUS_DMA2
-# options GUS_DMA
-# options GUS_IRQ
-#
-# The src/sys/i386/isa/sound/sound.doc has more information.
-
-# Controls all "VOXWARE" driver sound devices. See Luigi's driver
-# below for an alternate which may work better for some cards.
-#
-#device snd
-#device pas0 at isa? port 0x388 irq 10 drq 6
-#device sb0 at isa? port 0x220 irq 5 drq 1
-#device sbxvi0 at isa? drq 5
-#device sbmidi0 at isa? port 0x330
-#device awe0 at isa? port 0x620
-#device gus0 at isa? port 0x220 irq 12 drq 1
-##device gus0 at isa? port 0x220 irq 12 drq 1 flags 0x3
-#device mss0 at isa? port 0x530 irq 10 drq 1
-#device css0 at isa? port 0x534 irq 5 drq 1 flags 0x08
-#device sscape0 at isa? port 0x330 irq 9 drq 0
-#device trix0 at isa? port 0x330 irq 6 drq 0
-#device sscape_mss0 at isa? port 0x534 irq 5 drq 1
-#device opl0 at isa? port 0x388
-#device mpu0 at isa? port 0x330 irq 6 drq 0
-#device uart0 at isa? port 0x330 irq 5
-
-# The newpcm driver (use INSTEAD of snd0 and all VOXWARE drivers!).
-# Note that motherboard sound devices may require options PNPBIOS.
-#
-# Supported cards include:
-# Creative SoundBlaster ISA PnP/non-PnP
-# Supports ESS and Avance ISA chips as well.
-# Gravis UltraSound ISA PnP/non-PnP
-# Crystal Semiconductor CS461x/428x PCI
-# Neomagic 256AV (ac97)
-# Most of the more common ISA/PnP sb/mss/ess compatable cards.
-
-# For non-pnp sound cards with no bridge drivers only:
-device pcm0 at isa? irq 10 drq 1 flags 0x0
-#
-# For PnP/PCI sound cards
-device pcm
-
-# The bridge drivers for sound cards. These can be seperately configured
-# for providing services to the likes of new-midi (not in the tree yet).
-# When used with 'device pcm' they also provide pcm sound services.
-#
-# sbc: Creative SoundBlaster ISA PnP/non-PnP
-# Supports ESS and Avance ISA chips as well.
-# gusc: Gravis UltraSound ISA PnP/non-PnP
-# csa: Crystal Semiconductor CS461x/428x PCI
-
-# For non-PnP cards:
-device sbc0 at isa? port 0x220 irq 5 drq 1 flags 0x15
-device gusc0 at isa? port 0x220 irq 5 drq 1 flags 0x13
-
-# Not controlled by `snd'
-device pca0 at isa? port IO_TIMER1
-
-#
-# Miscellaneous hardware:
-#
-# mcd: Mitsumi CD-ROM
-# scd: Sony CD-ROM
-# matcd: Matsushita/Panasonic CD-ROM
-# wt: Wangtek and Archive QIC-02/QIC-36 tape drives
-# ctx: Cortex-I frame grabber
-# apm: Laptop Advanced Power Management (experimental)
-# spigot: The Creative Labs Video Spigot video-acquisition board
-# meteor: Matrox Meteor video capture board
-# bktr: Brooktree bt848/848a/849a/878/879 video capture and TV Tuner board
-# cy: Cyclades serial driver
-# dgb: Digiboard PC/Xi and PC/Xe series driver (ALPHA QUALITY!)
-# dgm: Digiboard PC/Xem driver
-# gp: National Instruments AT-GPIB and AT-GPIB/TNT board
-# asc: GI1904-based hand scanners, e.g. the Trust Amiscan Grey
-# gsc: Genius GS-4500 hand scanner.
-# joy: joystick
-# labpc: National Instrument's Lab-PC and Lab-PC+
-# rc: RISCom/8 multiport card
-# rp: Comtrol Rocketport(ISA) - single card
-# tw: TW-523 power line interface for use with X-10 home control products
-# si: Specialix SI/XIO 4-32 port terminal multiplexor
-# stl: Stallion EasyIO and EasyConnection 8/32 (cd1400 based)
-# stli: Stallion EasyConnection 8/64, ONboard, Brumby (intelligent)
-
-# Notes on APM
-# The flags takes the following meaning for apm0:
-# 0x0020 Statclock is broken.
-# If apm is omitted, some systems require sysctl -w kern.timecounter.method=1
-# for correct timekeeping.
-
-# Notes on the spigot:
-# The video spigot is at 0xad6. This port address can not be changed.
-# The irq values may only be 10, 11, or 15
-# I/O memory is an 8kb region. Possible values are:
-# 0a0000, 0a2000, ..., 0fffff, f00000, f02000, ..., ffffff
-# The start address must be on an even boundary.
-# Add the following option if you want to allow non-root users to be able
-# to access the spigot. This option is not secure because it allows users
-# direct access to the I/O page.
-# options SPIGOT_UNSECURE
-
-# Notes on the Comtrol Rocketport driver:
-#
-# The exact values used for rp0 depend on how many boards you have
-# in the system. The manufacturer's sample configs are listed as:
-#
-# Comtrol Rocketport ISA single card
-# device rp0 at isa? port 0x280
-#
-# If instead you have two ISA cards, one installed at 0x100 and the
-# second installed at 0x180, then you should add the following to
-# your kernel configuration file:
-#
-# device rp0 at isa? port 0x100
-# device rp1 at isa? port 0x180
-#
-# For 4 ISA cards, it might be something like this:
-#
-# device rp0 at isa? port 0x180
-# device rp1 at isa? port 0x100
-# device rp2 at isa? port 0x340
-# device rp3 at isa? port 0x240
-#
-# And for PCI cards, you only need say:
-#
-# device rp
-
-# Notes on the Digiboard driver:
-#
-# The following flag values have special meanings:
-# 0x01 - alternate layout of pins (dgb & dgm)
-# 0x02 - use the windowed PC/Xe in 64K mode (dgb only)
-
-# Notes on the Specialix SI/XIO driver:
-# **This is NOT a Specialix supported Driver!**
-# The host card is memory, not IO mapped.
-# The Rev 1 host cards use a 64K chunk, on a 32K boundary.
-# The Rev 2 host cards use a 32K chunk, on a 32K boundary.
-# The cards can use an IRQ of 11, 12 or 15.
-
-# Notes on the Stallion stl and stli drivers:
-# See src/i386/isa/README.stl for complete instructions.
-# This is version 0.0.5alpha, unsupported by Stallion.
-# The stl driver has a secondary IO port hard coded at 0x280. You need
-# to change src/i386/isa/stallion.c if you reconfigure this on the boards.
-# The "flags" and "iosiz" settings on the stli driver depend on the board:
-# EasyConnection 8/64 ISA: flags 23 iosiz 0x1000
-# EasyConnection 8/64 EISA: flags 24 iosiz 0x10000
-# EasyConnection 8/64 MCA: flags 25 iosiz 0x1000
-# ONboard ISA: flags 4 iosiz 0x10000
-# ONboard EISA: flags 7 iosiz 0x10000
-# ONboard MCA: flags 3 iosiz 0x10000
-# Brumby: flags 2 iosiz 0x4000
-# Stallion: flags 1 iosiz 0x10000
-
-device mcd0 at isa? port 0x300 irq 10
-# for the Sony CDU31/33A CDROM
-device scd0 at isa? port 0x230
-# for the SoundBlaster 16 multicd - up to 4 devices
-device matcd0 at isa? port 0x230
-device wt0 at isa? port 0x300 irq 5 drq 1
-device ctx0 at isa? port 0x230 iomem 0xd0000
-device spigot0 at isa? port 0xad6 irq 15 iomem 0xee000
-device apm0
-device gp0 at isa? port 0x2c0
-device gsc0 at isa? port IO_GSC1 drq 3
-device joy0 at isa? port IO_GAME
-device cy0 at isa? irq 10 iomem 0xd4000 iosiz 0x2000
-options CY_PCI_FASTINTR # Use with cy_pci unless irq is shared
-device dgb0 at isa? port 0x220 iomem 0xfc000
-options NDGBPORTS=16 # Defaults to 16*NDGB
-device dgm0 at isa? port 0x104 iomem 0xd0000
-device labpc0 at isa? port 0x260 irq 5
-device rc0 at isa? port 0x220 irq 12
-device rp0 at isa? port 0x280
-# the port and irq for tw0 are fictitious
-device tw0 at isa? port 0x380 irq 11
-device si0 at isa? iomem 0xd0000 irq 12
-device asc0 at isa? port IO_ASC1 drq 3 irq 10
-device stl0 at isa? port 0x2a0 irq 10
-device stli0 at isa? port 0x2a0 iomem 0xcc000 flags 23 iosiz 0x1000
-# You are unlikely to have the hardware for loran0 <phk@FreeBSD.org>
-device loran0 at isa? irq 5
-# HOT1 Xilinx 6200 card (http://www.vcc.com/)
-device xrpu
-
-#
-# MCA devices:
-#
-# The MCA bus device is `mca'. It provides auto-detection and
-# configuration support for all devices on the MCA bus.
-#
-# The 'aha' device provides support for the Adaptec 1640
-#
-# The 'bt' device provides support for various Buslogic/Bustek
-# and Storage Dimensions SCSI adapters.
-#
-# The 'ep' device provides support for the 3Com 3C529 ethernet card.
-#
-device mca
-
-#
-# EISA devices:
-#
-# The EISA bus device is `eisa'. It provides auto-detection and
-# configuration support for all devices on the EISA bus.
-#
-# The `ahb' device provides support for the Adaptec 174X adapter.
-#
-# The `ahc' device provides support for the Adaptec 274X and 284X
-# adapters. The 284X, although a VLB card, responds to EISA probes.
-#
-# fea: DEC DEFEA EISA FDDI adapter
-#
-device eisa
-device ahb
-device ahc
-device fea
-
-# The aic7xxx driver will attempt to use memory mapped I/O for all PCI
-# controllers that have it configured only if this option is set. Unfortunately,
-# this doesn't work on some motherboards, which prevents it from being the
-# default.
-options AHC_ALLOW_MEMIO
-
-# The adw driver will attempt to use memory mapped I/O for all PCI
-# controllers that have it configured only if this option is set.
-options ADW_ALLOW_MEMIO
-
-# By default, only 10 EISA slots are probed, since the slot numbers
-# above clash with the configuration address space of the PCI subsystem,
-# and the EISA probe is not very smart about this. This is sufficient
-# for most machines, but in particular the HP NetServer LC series comes
-# with an onboard AIC7770 dual-channel SCSI controller on EISA slot #11,
-# thus you need to bump this figure to 12 for them.
-options EISA_SLOTS=12
-
-#
-# PCI devices & PCI options:
-#
-# The main PCI bus device is `pci'. It provides auto-detection and
-# configuration support for all devices on the PCI bus, using either
-# configuration mode defined in the PCI specification.
-
-device pci
-
-# PCI options
-#
-#options PCI_QUIET #quiets PCI code on chipset settings
-
-
-# The `ahc' device provides support for the Adaptec 29/3940(U)(W)
-# and motherboard based AIC7870/AIC7880 adapters.
-#
-# The `amd' device provides support for the AMD 53C974 SCSI host
-# adapter chip as found on devices such as the Tekram DC-390(T).
-#
-# The `ncr' device provides support for the NCR 53C810 and 53C825
-# self-contained SCSI host adapters.
-#
-# The `isp' device provides support for the Qlogic ISP 1020, 1040
-# nd 1040B PCI SCSI host adapters, ISP 1240 Dual Ultra SCSI,
-# ISP 1080 and 1280 (Dual) Ultra2, ISP 12160 Ultra3 SCSI, as well as
-# the Qlogic ISP 2100 and ISP 2200 Fibre Channel Host Adapters.
-#
-# The `dc' device provides support for PCI fast ethernet adapters
-# based on the DEC/Intel 21143 and various workalikes including:
-# the ADMtek AL981 Comet and AN985 Centaur, the ASIX Electronics
-# AX88140A and AX88141, the Davicom DM9100 and DM9102, the Lite-On
-# 82c168 and 82c169 PNIC, the Lite-On/Macronix LC82C115 PNIC II
-# and the Macronix 98713/98713A/98715/98715A/98725 PMAC. This driver
-# replaces the old al, ax, dm, pn and mx drivers. List of brands:
-# Digital DE500-BA, Kingston KNE100TX, D-Link DFE-570TX, SOHOware SFA110,
-# SVEC PN102-TX, CNet Pro110B, 120A, and 120B, Compex RL100-TX,
-# LinkSys LNE100TX, LNE100TX V2.0, Jaton XpressNet, Alfa Inc GFC2204,
-# KNE110TX.
-#
-# The `de' device provides support for the Digital Equipment DC21040
-# self-contained Ethernet adapter.
-#
-# The `fxp' device provides support for the Intel EtherExpress Pro/100B
-# PCI Fast Ethernet adapters.
-#
-# The 'rl' device provides support for PCI fast ethernet adapters based
-# on the RealTek 8129/8139 chipset. Note that the RealTek driver defaults
-# to using programmed I/O to do register accesses because memory mapped
-# mode seems to cause severe lockups on SMP hardware. This driver also
-# supports the Accton EN1207D `Cheetah' adapter, which uses a chip called
-# the MPX 5030/5038, which is either a RealTek in disguise or a RealTek
-# workalike. Note that the D-Link DFE-530TX+ uses the RealTek chipset
-# and is supported by this driver, not the 'vr' driver.
-#
-# The 'sf' device provides support for Adaptec Duralink PCI fast
-# ethernet adapters based on the Adaptec AIC-6915 "starfire" controller.
-# This includes dual and quad port cards, as well as one 100baseFX card.
-# Most of these are 64-bit PCI devices, except for one single port
-# card which is 32-bit.
-#
-# The 'ste' device provides support for adapters based on the Sundance
-# Technologies ST201 PCI fast ethernet controller. This includes the
-# D-Link DFE-550TX.
-#
-# The 'sis' device provides support for adapters based on the Silicon
-# Integrated Systems SiS 900 and SiS 7016 PCI fast ethernet controller
-# chips.
-#
-# The 'sk' device provides support for the SysKonnect SK-984x series
-# PCI gigabit ethernet NICs. This includes the SK-9841 and SK-9842
-# single port cards (single mode and multimode fiber) and the
-# SK-9843 and SK-9844 dual port cards (also single mode and multimode).
-# The driver will autodetect the number of ports on the card and
-# attach each one as a separate network interface.
-#
-# The 'ti' device provides support for PCI gigabit ethernet NICs based
-# on the Alteon Networks Tigon 1 and Tigon 2 chipsets. This includes the
-# Alteon AceNIC, the 3Com 3c985, the Netgear GA620 and various others.
-# Note that you will probably want to bump up NMBCLUSTERS a lot to use
-# this driver.
-#
-# The 'tl' device provides support for the Texas Instruments TNETE100
-# series 'ThunderLAN' cards and integrated ethernet controllers. This
-# includes several Compaq Netelligent 10/100 cards and the built-in
-# ethernet controllers in several Compaq Prosignia, Proliant and
-# Deskpro systems. It also supports several Olicom 10Mbps and 10/100
-# boards.
-#
-# The `tx' device provides support for the SMC 9432TX cards.
-#
-# The `vr' device provides support for various fast ethernet adapters
-# based on the VIA Technologies VT3043 `Rhine I' and VT86C100A `Rhine II'
-# chips, including the D-Link DFE530TX (see 'rl' for DFE530TX+), the Hawking
-# Technologies PN102TX, and the AOpen/Acer ALN-320.
-#
-# The `vx' device provides support for the 3Com 3C590 and 3C595
-# early support
-#
-# The `wb' device provides support for various fast ethernet adapters
-# based on the Winbond W89C840F chip. Note: this is not the same as
-# the Winbond W89C940F, which is an NE2000 clone.
-#
-# The `wx' device provides support for the Intel Gigabit Ethernet
-# PCI card (`Wiseman').
-#
-# The `xl' device provides support for the 3Com 3c900, 3c905 and
-# 3c905B (Fast) Etherlink XL cards and integrated controllers. This
-# includes the integrated 3c905B-TX chips in certain Dell Optiplex and
-# Dell Precision desktop machines and the integrated 3c905-TX chips
-# in Dell Latitude laptop docking stations.
-#
-# The `fpa' device provides support for the Digital DEFPA PCI FDDI
-# adapter. pseudo-device fddi is also needed.
-#
-# The `meteor' device is a PCI video capture board. It can also have the
-# following options:
-# options METEOR_ALLOC_PAGES=xxx preallocate kernel pages for data entry
-# figure (ROWS*COLUMN*BYTES_PER_PIXEL*FRAME+PAGE_SIZE-1)/PAGE_SIZE
-# options METEOR_DEALLOC_PAGES remove all allocated pages on close(2)
-# options METEOR_DEALLOC_ABOVE=xxx remove all allocated pages above the
-# specified amount. If this value is below the allocated amount no action
-# taken
-# options METEOR_SYSTEM_DEFAULT={METEOR_PAL|METEOR_NTSC|METEOR_SECAM}, used
-# for initialization of fps routine when a signal is not present.
-#
-# The 'bktr' device is a PCI video capture device using the Brooktree
-# bt848/bt848a/bt849a/bt878/bt879 chipset. When used with a TV Tuner it forms a
-# TV card, eg Miro PC/TV, Hauppauge WinCast/TV WinTV, VideoLogic Captivator,
-# Intel Smart Video III, AverMedia, IMS Turbo, FlyVideo.
-#
-# options OVERRIDE_CARD=xxx
-# options OVERRIDE_TUNER=xxx
-# options OVERRIDE_MSP=1
-# options OVERRIDE_DBX=1
-# These options can be used to override the auto detection
-# The current values for xxx are found in src/sys/dev/bktr/bktr_card.h
-# Using sysctl(8) run-time overrides on a per-card basis can be made
-#
-# options BROOKTREE_SYSTEM_DEFAULT=BROOKTREE_PAL
-# or
-# options BROOKTREE_SYSTEM_DEFAULT=BROOKTREE_NTSC
-# Specifes the default video capture mode.
-# This is required for Dual Crystal (28&35Mhz) boards where PAL is used
-# to prevent hangs during initialisation. eg VideoLogic Captivator PCI.
-#
-# options BKTR_USE_PLL
-# PAL or SECAM users who have a 28Mhz crystal (and no 35Mhz crystal)
-# must enable PLL mode with this option. eg some new Bt878 cards.
-#
-# options BKTR_GPIO_ACCESS
-# This enable IOCTLs which give user level access to the GPIO port.
-#
-# options BKTR_NO_MSP_RESET
-# Prevents the MSP34xx reset. Good if you initialise the MSP in another OS first
-#
-# options BKTR_430_FX_MODE
-# Switch Bt878/879 cards into Intel 430FX chipset compatibility mode.
-#
-# options BKTR_SIS_VIA_MODE
-# Switch Bt878/879 cards into SIS/VIA chipset compatibility mode which is
-# needed for some old SiS and VIA chipset motherboards.
-# This also allows Bt878/879 chips to work on old OPTi (<1997) chipset
-# motherboards and motherboards with bad or incomplete PCI 2.1 support.
-# As a rough guess, old = before 1998
-#
-#
-# The oltr driver supports the following Olicom PCI token-ring adapters
-# OC-3136, OC-3137, OC-3139, OC-3140, OC-3141, OC-3540, OC-3250
-#
-device ahc # AHA2940 and onboard AIC7xxx devices
-device amd # AMD 53C974 (Teckram DC-390(T))
-device isp # Qlogic family
-device ncr # NCR/Symbios Logic
-device sym # NCR/Symbios Logic (newer chipsets)
-#
-# Options for ISP
-#
-# SCSI_ISP_NO_FWLOAD_MASK - mask of isp unit numbers (obviously
-# a max of 32) that you wish to disable
-# to disable the loading of firmware on.
-# SCSI_ISP_NO_NVRAM_MASK - mask of isp unit numbers (obviously
-# a max of 32) that you wish to disable
-# them picking up information from NVRAM
-# (for broken cards you can't fix the NVRAM
-# on- very rare, or for systems you can't
-# change NVRAM on (e.g. alpha) and you don't
-# like what's in there)
-# SCSI_ISP_PREFER_MEM_MAP - control preference for using memory mappings
-# instead of I/O space mappings. It defaults
-# to 1 for i386, 0 for alpha. Set to 1 to
-# unconditionally prefer mapping memory,
-# else it will use I/O space mappings. Of
-# course, this can fail if the PCI implement-
-# ation doesn't support what you want.
-#
-# SCSI_ISP_FCDUPLEX - mask of isp unit numbers (obviously
-# a max of 32) that you wish to set fibre
-# channel full duplex mode on.
-# to disable the loading of firmware on.
-# SCSI_ISP_FABRIC enable loading of Fabric f/w flavor (2100).
-# SCSI_ISP_SCCLUN enable loading of expanded lun f/w (2100).
-# SCSI_ISP_WWN - define a WWN to use as a default
-#
-# ISP_DISABLE_1020_SUPPORT Disable support for 1020/1040 cards
-# ISP_DISABLE_1080_SUPPORT Disable support for 1080/1240 cards
-# ISP_DISABLE_12160_SUPPORT Disable support for 12160 cards
-# ISP_DISABLE_2100_SUPPORT Disable support for 2100 cards
-# (these really just to save some code space)
-# (use of all four will cause the kernel to not compile)
-#
-# ISP_COMPILE_FW - compile all firmware in
-# ISP_COMPILE_1020_FW - compile in 1020/1040 firmware
-# ISP_COMPILE_1080_FW - compile in 1080/1240/1280 firmware
-# ISP_COMPILE_12160_FW - compile in 12160 firmware
-# ISP_COMPILE_2100_FW - compile in 2100 firmware
-# ISP_COMPILE_2200_FW - compile in 2200 firmware
-#
-# ISP_TARGET_MODE - enable target mode operation
-#
-options SCSI_ISP_NO_FWLOAD_MASK=0x12 # disable FW load for isp1, isp4
-options SCSI_ISP_NO_NVRAM_MASK=0x1 # disable NVRAM for isp0
-options SCSI_ISP_PREFER_MEM_MAP=0 # prefer I/O mapping
-options SCSI_ISP_FCDUPLEX=0x4 # isp2 is a Fibre Channel card
- # we want in full duplex mode.
-options SCSI_ISP_WWN="0x5000000099990000"
-#options ISP_DISABLE_1020_SUPPORT
-#options ISP_DISABLE_1080_SUPPORT
-#options ISP_DISABLE_12160_SUPPORT
-#options ISP_DISABLE_2100_SUPPORT
-#options ISP_COMPILE_1020_FW=1
-#options ISP_COMPILE_1080_FW=1
-#options ISP_COMPILE_2100_FW=1
-#options ISP_COMPILE_2200_FW=1
-#options ISP_TARGET_MODE=1
-
-# Options used in dev/sym/ (Symbios SCSI driver).
-#options SYM_SETUP_LP_PROBE_MAP #-Low Priority Probe Map (bits)
- # Allows the ncr to take precedence
- # 1 (1<<0) -> 810a, 860
- # 2 (1<<1) -> 825a, 875, 885, 895
- # 4 (1<<2) -> 895a, 896, 1510d
-#options SYM_SETUP_SCSI_DIFF #-HVD support for 825a, 875, 885
- # disabled:0 (default), enabled:1
-#options SYM_SETUP_PCI_PARITY #-PCI parity checking
- # disabled:0, enabled:1 (default)
-#options SYM_SETUP_MAX_LUN #-Number of LUNs supported
- # default:8, range:[1..64]
-
-
-# MII bus support is required for some PCI 10/100 ethernet NICs,
-# namely those which use MII-compliant transceivers or implement
-# tranceiver control interfaces that operate like an MII. Adding
-# "device miibus0" to the kernel config pulls in support for
-# the generic miibus API and all of the PHY drivers, including a
-# generic one for PHYs that aren't specifically handled by an
-# individual driver.
-device miibus
-
-# PCI Ethernet NICs that use the common MII bus controller code.
-device dc # DEC/Intel 21143 and various workalikes
-device rl # RealTek 8129/8139
-device sf # Adaptec AIC-6915 (``Starfire'')
-device sis # Silicon Integrated Systems SiS 900/SiS 7016
-device ste # Sundance ST201 (D-Link DFE-550TX)
-device tl # Texas Instruments ThunderLAN
-device vr # VIA Rhine, Rhine II
-device wb # Winbond W89C840F
-device xl # 3Com 3c90x (``Boomerang'', ``Cyclone'')
-
-# PCI Ethernet NICs.
-device de # DEC/Intel DC21x4x (``Tulip'')
-device fxp # Intel EtherExpress PRO/100B (82557, 82558)
-device tx # SMC 9432TX (83c170 ``EPIC'')
-device vx # 3Com 3c590, 3c595 (``Vortex'')
-
-device sk
-device ti
-device wx
-device fpa
-device meteor
-#The oltr driver in the ISA section will also find PCI cards.
-#device oltr0
-
-
-# Brooktree driver has been ported to the new I2C framework. Thus,
-# you'll need to have the following 3 lines in the kernel config.
-# device smbus
-# device iicbus
-# device iicbb
-# The iic and smb devices are only needed if you want to control other
-# I2C slaves connected to the external connector of some cards.
-#
-device bktr
-
-#
-# PCCARD/PCMCIA
-#
-# card: pccard slots
-# pcic: isa/pccard bridge
-device pcic0 at isa?
-device pcic1 at isa?
-device card
-
-# You may need to reset all pccards after resuming
-options PCIC_RESUME_RESET # reset after resume
-
-#
-# Laptop/Notebook options:
-#
-# See also:
-# apm under `Miscellaneous hardware'
-# above.
-
-# For older notebooks that signal a powerfail condition (external
-# power supply dropped, or battery state low) by issuing an NMI:
-
-options POWERFAIL_NMI # make it beep instead of panicing
-
-#
-# SMB bus
-#
-# System Management Bus support provided by the 'smbus' device.
-#
-# Supported devices:
-# smb standard io
-#
-# Supported interfaces:
-# iicsmb I2C to SMB bridge with any iicbus interface
-# bktr brooktree848 I2C hardware interface
-# intpm Intel PIIX4 Power Management Unit
-# alpm Acer Aladdin-IV/V/Pro2 Power Management Unit
-#
-device smbus # Bus support, required for smb below.
-device intpm
-device alpm
-
-device smb
-
-#
-# I2C Bus
-#
-# Philips i2c bus support is provided by the `iicbus' device.
-#
-# Supported devices:
-# ic i2c network interface
-# iic i2c standard io
-# iicsmb i2c to smb bridge. Allow i2c i/o with smb commands.
-#
-# Supported interfaces:
-# pcf Philips PCF8584 ISA-bus controller
-# bktr brooktree848 I2C software interface
-#
-# Other:
-# iicbb generic I2C bit-banging code (needed by lpbb, bktr)
-#
-device iicbus # Bus support, required for ic/iic/iicsmb below.
-device iicbb
-
-device ic
-device iic
-device iicsmb # smb over i2c bridge
-
-device pcf0 at isa? port 0x320 irq 5
-
-# ISDN4BSD section
-#
-# See /usr/share/examples/isdn/ROADMAP for an introduction to isdn4bsd.
-#
-# i4b passive ISDN cards support (isic - I4b Siemens Isdn Chipset driver)
-# note that the ``options'' and ``device'' lines must BOTH be defined !
-#
-# Driver entries marked "(not supported yet!)" are not working currently
-# due to not being converted to newbus. We hope to get them back to support
-# in the near future.
-#
-# ISA bus non-PnP Cards:
-# ----------------------
-#
-# Teles S0/8 or Niccy 1008
-options TEL_S0_8
-device isic0 at isa? iomem 0xd0000 irq 5 flags 1
-#
-# Teles S0/16 or Creatix ISDN-S0 or Niccy 1016
-options TEL_S0_16
-#device isic0 at isa? port 0xd80 iomem 0xd0000 irq 5 flags 2
-#
-# Teles S0/16.3
-options TEL_S0_16_3
-#device isic0 at isa? port 0xd80 irq 5 flags 3
-#
-# AVM A1 or AVM Fritz!Card
-options AVM_A1
-#device isic0 at isa? port 0x340 irq 5 flags 4
-#
-# USRobotics Sportster ISDN TA intern (not supported yet!)
-#options USR_STI
-#device isic0 at isa? port 0x268 irq 5 flags 7
-#
-# ITK ix1 Micro ( < V.3, non-PnP version ) (not supported yet!)
-#options ITKIX1
-#device isic0 at isa? port 0x398 irq 10 flags 18
-#
-# ELSA PCC-16
-options "ELSA_PCC16"
-#device isic0 at isa? port 0x360 irq 10 flags 20
-#
-# ISA bus PnP Cards:
-# ------------------
-#
-# Teles S0/16.3 PnP
-options TEL_S0_16_3_P
-#device isic
-#
-# Creatix ISDN-S0 P&P
-options CRTX_S0_P
-#device isic
-#
-# Dr. Neuhaus Niccy Go@
-options DRN_NGO
-#device isic
-#
-# Sedlbauer Win Speed
-options SEDLBAUER
-#device isic
-#
-# Dynalink IS64PH (not supported yet!)
-#options DYNALINK
-#device isic
-#
-# ELSA QuickStep 1000pro ISA
-options ELSA_QS1ISA
-#device isic
-#
-# ITK ix1 Micro ( V.3, PnP version ) (not supported yet!)
-#options "ITKIX1"
-#device isic
-#
-# AVM Fritz!Card PnP (not supported yet!)
-#options "AVM_PNP"
-#device isic
-#
-# Siemens I-Surf 2.0
-options "SIEMENS_ISURF2"
-#device isic
-#
-# PCI bus Cards:
-# --------------
-#
-# ELSA MicroLink ISDN/PCI (same as ELSA QuickStep 1000pro PCI)
-options ELSA_QS1PCI
-#device isic
-#
-# AVM Fritz!Card PCI
-options "AVM_A1_PCI"
-#device isic
-#
-# PCMCIA Cards:
-# -------------
-#
-# AVM PCMCIA Fritz!Card (not supported yet!)
-#options AVM_A1_PCMCIA
-#device isic0 at isa? port 0x340 irq 5 flags 10
-#
-# Active Cards:
-# -------------
-#
-# Stollmann Tina-dd control device
-# (driver under development, not fully functional!)
-device tina0 at isa? port 0x260 irq 10
-#
-# ISDN Protocol Stack
-# -------------------
-#
-# Q.921 / layer 2 - i4b passive cards D channel handling
-pseudo-device "i4bq921"
-#
-# Q.931 / layer 3 - i4b passive cards D channel handling
-pseudo-device "i4bq931"
-#
-# layer 4 - i4b common passive and active card handling
-pseudo-device "i4b"
-#
-# ISDN devices
-# ------------
-#
-# userland driver to do ISDN tracing (for passive cards only)
-pseudo-device "i4btrc" 4
-#
-# userland driver to control the whole thing
-pseudo-device "i4bctl"
-#
-# userland driver for access to raw B channel
-pseudo-device "i4brbch" 4
-#
-# userland driver for telephony
-pseudo-device "i4btel" 2
-#
-# network driver for IP over raw HDLC ISDN
-pseudo-device "i4bipr" 4
-# enable VJ header compression detection for ipr i/f
-options IPR_VJ
-# enable logging of the first n IP packets to isdnd (n=32 here)
-#options IPR_LOG=32
-#
-# network driver for sync PPP over ISDN
-pseudo-device "i4bisppp" 4
-
-
-# Parallel-Port Bus
-#
-# Parallel port bus support is provided by the `ppbus' device.
-# Multiple devices may be attached to the parallel port, devices
-# are automatically probed and attached when found.
-#
-# Supported devices:
-# vpo Iomega Zip Drive
-# Requires SCSI disk support ('scbus' and 'da'), best
-# performance is achieved with ports in EPP 1.9 mode.
-# lpt Parallel Printer
-# plip Parallel network interface
-# ppi General-purpose I/O ("Geek Port") + IEEE1284 I/O
-# pps Pulse per second Timing Interface
-# lpbb Philips official parallel port I2C bit-banging interface
-#
-# Supported interfaces:
-# ppc ISA-bus parallel port interfaces.
-#
-
-options PPC_PROBE_CHIPSET # Enable chipset specific detection
- # (see flags in ppc(4))
-options DEBUG_1284 # IEEE1284 signaling protocol debug
-options PERIPH_1284 # Makes your computer act as a IEEE1284
- # compliant peripheral
-options DONTPROBE_1284 # Avoid boot detection of PnP parallel devices
-options VP0_DEBUG # ZIP/ZIP+ debug
-options LPT_DEBUG # Printer driver debug
-options PPC_DEBUG # Parallel chipset level debug
-options PLIP_DEBUG # Parallel network IP interface debug
-options PCFCLOCK_VERBOSE # Verbose pcfclock driver
-options PCFCLOCK_MAX_RETRIES=5 # Maximum read tries (default 10)
-
-device ppc0 at isa? irq 7
-device ppbus
-device vpo
-device lpt
-device plip
-device ppi
-device pps
-device lpbb
-device pcfclock
-
-# Kernel BOOTP support
-
-options BOOTP # Use BOOTP to obtain IP address/hostname
-options BOOTP_NFSROOT # NFS mount root filesystem using BOOTP info
-options BOOTP_NFSV3 # Use NFS v3 to NFS mount root
-options BOOTP_COMPAT # Workaround for broken bootp daemons.
-options BOOTP_WIRED_TO=fxp0 # Use interface fxp0 for BOOTP
-
-#
-# Add tie-ins for a hardware watchdog. This only enable the hooks;
-# the user must still supply the actual driver.
-#
-options HW_WDOG
-
-#
-# Set the number of PV entries per process. Increasing this can
-# stop panics related to heavy use of shared memory. However, that can
-# (combined with large amounts of physical memory) cause panics at
-# boot time due the kernel running out of VM space.
-#
-# If you're tweaking this, you might also want to increase the sysctls
-# "vm.v_free_min", "vm.v_free_reserved", and "vm.v_free_target".
-#
-# The value below is the one more than the default.
-#
-options PMAP_SHPGPERPROC=201
-
-#
-# Disable swapping. This option removes all code which actually performs
-# swapping, so it's not possible to turn it back on at run-time.
-#
-# This is sometimes usable for systems which don't have any swap space
-# (see also sysctls "vm.defer_swapspace_pageouts" and
-# "vm.disable_swapspace_pageouts")
-#
-#options NO_SWAPPING
-
-# Set the number of sf_bufs to allocate. sf_bufs are virtual buffers
-# for sendfile(2) that are used to map file VM pages, and normally
-# default to a quantity that is roughly 16*MAXUSERS+512. You would
-# typically want about 4 of these for each simultaneous file send.
-#
-options NSFBUFS=1024
-
-#
-# Enable extra debugging code for locks. This stores the filename and
-# line of whatever acquired the lock in the lock itself, and change a
-# number of function calls to pass around the relevant data. This is
-# not at all useful unless you are debugging lock code. Also note
-# that it is likely to break e.g. fstat(1) unless you recompile your
-# userland with -DDEBUG_LOCKS as well.
-#
-options DEBUG_LOCKS
-
-#
-# SysVR4 ABI emulation
-#
-# The svr4 ABI emulator can be statically compiled into the kernel or loaded as
-# a KLD module.
-# The STREAMS network emulation code can also be compiled statically or as a
-# module. If loaded as a module, it must be loaded before the svr4 module
-# (the /usr/sbin/svr4 script does this for you). If compiling statically,
-# the `streams' pseudo-device must be configured into any kernel which also
-# specifies COMPAT_SVR4. It is possible to have a statically-configured
-# STREAMS device and a dynamically loadable svr4 emulator; the /usr/sbin/svr4
-# script understands that it doesn't need to load the `streams' module under
-# those circumstances.
-# Caveat: At this time, `options KTRACE' is required for the svr4 emulator
-# (whether static or dynamic).
-#
-options COMPAT_SVR4 # build emulator statically
-options DEBUG_SVR4 # enable verbose debugging
-pseudo-device streams # STREAMS network driver (required for svr4).
-
-# More undocumented options for linting.
-# Note that documenting these are not considered an affront.
-
-options AHC_DUMP_EEPROM
-options AHC_TMODE_ENABLE
-options BUS_DEBUG
-options CAM_DEBUG_DELAY
-options CLK_CALIBRATION_LOOP
-options CLK_USE_I8254_CALIBRATION
-options CLK_USE_TSC_CALIBRATION
-options CLUSTERDEBUG
-options COMPAT_LINUX
-options CPU_UPGRADE_HW_CACHE
-options DEBUG
-options DEBUG_LINUX
-options DEBUG_VFS_LOCKS
-#options DISABLE_PSE
-options ENABLE_ALART
-options ENABLE_VFS_IOOPT
-options FB_DEBUG
-options FB_INSTALL_CDEV
-options FE_8BIT_SUPPORT
-options I4B_SMP_WORKAROUND
-options I586_PMC_GUPROF=0x70000
-options IBCS2
-options KBDIO_DEBUG=2
-options KBD_MAXRETRY=4
-options KBD_MAXWAIT=6
-options KBD_RESETDELAY=201
-options KEY
-options LOCKF_DEBUG
-options LOUTB
-options MSGMNB=2049
-options MSGMNI=41
-options MSGSEG=2049
-options MSGSSZ=16
-options MSGTQL=41
-options NBUF=512
-options NETATALKDEBUG
-options NMBCLUSTERS=1024
-options NPX_DEBUG
-#options OLTR_NO_BULLSEYE_MAC
-#options OLTR_NO_HAWKEYE_MAC
-#options OLTR_NO_TMS_MAC
-options PANIC_REBOOT_WAIT_TIME=16
-options PNPBIOS
-options PSM_DEBUG=1
-options SCSI_NCR_DEBUG
-options SCSI_NCR_MAX_SYNC=10000
-options SCSI_NCR_MAX_WIDE=1
-options SCSI_NCR_MYADDR=7
-options SC_DEBUG_LEVEL
-options SC_RENDER_DEBUG
-options SEMMAP=31
-options SEMMNI=11
-options SEMMNS=61
-options SEMMNU=31
-options SEMMSL=61
-options SEMOPM=101
-options SEMUME=11
-options SHMALL=1025
-options SHMMAX="(SHMMAXPGS*PAGE_SIZE+1)"
-options SHMMAXPGS=1025
-options SHMMIN=2
-options SHMMNI=33
-options SHMSEG=9
-options SHOW_BUSYBUFS # List buffers that prevent root unmount
-options SIMPLELOCK_DEBUG
-options SI_DEBUG
-options SLIP_IFF_OPTS
-options SPX_HACK
-options TIMER_FREQ="((14318182+6)/12)"
-options VFS_BIO_DEBUG
-options VM_KMEM_SIZE
-options VM_KMEM_SIZE_MAX
-options VM_KMEM_SIZE_SCALE
-
-# Undocumented options covering presently broken code
-#options ASUSCOM_IPAC
-
-# The 'dpt' driver provides support for DPT controllers (http://www.dpt.com/).
-# These have hardware RAID-{0,1,5} support, and do multi-initiator I/O.
-# The DPT controllers are commonly re-licensed under other brand-names -
-# some controllers by Olivetti, Dec, HP, AT&T, SNI, AST, Alphatronic, NEC and
-# Compaq are actually DPT controllers.
-#
-# See src/sys/dev/dpt for debugging and other subtle options.
-# DPT_MEASURE_PERFORMANCE Enables a set of (semi)invasive metrics. Various
-# instruments are enabled. The tools in
-# /usr/sbin/dpt_* assume these to be enabled.
-# DPT_HANDLE_TIMEOUTS Normally device timeouts are handled by the DPT.
-# If you ant the driver to handle timeouts, enable
-# this option. If your system is very busy, this
-# option will create more trouble than solve.
-# DPT_TIMEOUT_FACTOR Used to compute the excessive amount of time to
-# wait when timing out with the above option.
-# DPT_DEBUG_xxxx These are controllable from sys/dev/dpt/dpt.h
-# DPT_LOST_IRQ When enabled, will try, once per second, to catch
-# any interrupt that got lost. Seems to help in some
-# DPT-firmware/Motherboard combinations. Minimal
-# cost, great benefit.
-# DPT_RESET_HBA Make "reset" actually reset the controller
-# instead of fudging it. Only enable this if you
-# are 100% certain you need it.
-
-device dpt
-
-# DPT options
-#!CAM# options DPT_MEASURE_PERFORMANCE
-#!CAM# options DPT_HANDLE_TIMEOUTS
-options DPT_TIMEOUT_FACTOR=4
-options DPT_LOST_IRQ
-options DPT_RESET_HBA
-options DPT_ALLOW_MEMIO
-
-# USB support
-# UHCI controller
-device uhci
-# OHCI controller
-device ohci
-# General USB code (mandatory for USB)
-device usb
-#
-# Generic USB device driver
-device ugen
-# Human Interface Device (anything with buttons and dials)
-device uhid
-# USB keyboard
-device ukbd
-# USB printer
-device ulpt
-# USB Iomega Zip 100 Drive
-device umass
-# USB mouse
-device ums
-#
-# ADMtek USB ethernet. Supports the LinkSys USB100TX,
-# the Billionton USB100, the Melco LU-ATX, the D-Link DSB-650TX
-# and the SMC 2202USB. Also works with the ADMtek AN986 Pegasus
-# eval board.
-device aue
-#
-# CATC USB-EL1201A USB ethernet. Supports the CATC Netmate
-# and Netmate II, and the Belkin F5U111.
-device cue
-#
-# Kawasaki LSI ethernet. Supports the LinkSys USB10T,
-# Entrega USB-NET-E45, Peracom Ethernet Adapter, the
-# 3Com 3c19250, the ADS Technologies USB-10BT, the ATen UC10T,
-# the Netgear EA101, the D-Link DSB-650, the SMC 2102USB
-# and 2104USB, and the Corega USB-T.
-device kue
-
-# debugging options for the USB subsystem
-#
-options UHCI_DEBUG
-options OHCI_DEBUG
-options USB_DEBUG
-
-options UGEN_DEBUG
-options UHID_DEBUG
-options UHUB_DEBUG
-options UKBD_DEBUG
-options ULPT_DEBUG
-options UMASS_DEBUG
-options UMS_DEBUG
-
-# options for ukbd:
-options UKBD_DFLT_KEYMAP # specify the built-in keymap
-makeoptions UKBD_DFLT_KEYMAP=it.iso
-
-#
-# Embedded system options:
-#
-# An embedded system might want to run something other than init.
-options INIT_PATH="/sbin/init:/stand/sysinstall"
diff --git a/sys/conf/kern.mk b/sys/conf/kern.mk
deleted file mode 100644
index 595bc2e202cb..000000000000
--- a/sys/conf/kern.mk
+++ /dev/null
@@ -1,40 +0,0 @@
-# $FreeBSD$
-
-#
-# Warning flags for compiling the kernel and components of the kernel.
-#
-# Note that the newly added -Wcast-qual is responsible for generating
-# most of the remaining warnings. Warnings introduced with -Wall will
-# also pop up, but are easier to fix.
-#
-CWARNFLAGS?= -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes \
- -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual \
- -fformat-extensions -ansi
-#
-# The following flags are next up for working on:
-# -W
-#
-# When working on removing warnings from code, the `-Werror' flag should be
-# of material assistance.
-#
-
-#
-# On the i386, do not align the stack to 16-byte boundaries. Otherwise GCC
-# 2.95 adds code to the entry and exit point of every function to align the
-# stack to 16-byte boundaries -- thus wasting approximately 12 bytes of stack
-# per function call. While the 16-byte alignment may benefit micro benchmarks,
-# it is probably an overall loose as it makes the code bigger (less efficient
-# use of code cache tag lines) and uses more stack (less efficient use of data
-# cache tag lines)
-#
-.if ${MACHINE_ARCH} == "i386"
-CFLAGS+= -mpreferred-stack-boundary=2
-.endif
-
-#
-# On the alpha, make sure that we don't use floating-point registers and
-# allow the use of EV56 instructions (only needed for low-level i/o).
-#
-.if ${MACHINE_ARCH} == "alpha"
-CFLAGS+= -mno-fp-regs -Wa,-mev56
-.endif
diff --git a/sys/conf/kmod.mk b/sys/conf/kmod.mk
deleted file mode 100644
index aa6e97b638f4..000000000000
--- a/sys/conf/kmod.mk
+++ /dev/null
@@ -1,317 +0,0 @@
-# From: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91
-# $FreeBSD$
-#
-# The include file <bsd.kmod.mk> handles installing Kernel Loadable Device
-# drivers (KLD's).
-#
-#
-# +++ variables +++
-#
-# CLEANFILES Additional files to remove for the clean and cleandir targets.
-#
-# DISTRIBUTION Name of distribution. [bin]
-#
-# KERN Main Kernel source directory. [${.CURDIR}/../../sys/kern]
-#
-# KMOD The name of the kernel module to build.
-#
-# KMODDIR Base path for kernel modules (see kld(4)). [/modules]
-#
-# KMODOWN KLD owner. [${BINOWN}]
-#
-# KMODGRP KLD group. [${BINGRP}]
-#
-# KMODMODE KLD mode. [${BINMODE}]
-#
-# LINKS The list of KLD links; should be full pathnames, the
-# linked-to file coming first, followed by the linked
-# file. The files are hard-linked. For example, to link
-# /modules/master and /modules/meister, use:
-#
-# LINKS= /modules/master /modules/meister
-#
-# KMODLOAD Command to load a kernel module [/sbin/kldload]
-#
-# KMODUNLOAD Command to unload a kernel module [/sbin/kldunload]
-#
-# NOMAN KLD does not have a manual page if set.
-#
-# PROG The name of the kernel module to build.
-# If not supplied, ${KMOD}.o is used.
-#
-# SRCS List of source files
-#
-# KMODDEPS List of modules which this one is dependant on
-#
-# SUBDIR A list of subdirectories that should be built as well.
-# Each of the targets will execute the same target in the
-# subdirectories.
-#
-# SYMLINKS Same as LINKS, except it creates symlinks and the
-# linked-to pathname may be relative.
-#
-# DESTDIR, DISTDIR are set by other Makefiles (e.g. bsd.own.mk)
-#
-#
-# +++ targets +++
-#
-# distribute:
-# This is a variant of install, which will
-# put the stuff into the right "distribution".
-#
-# install:
-# install the program and its manual pages; if the Makefile
-# does not itself define the target install, the targets
-# beforeinstall and afterinstall may also be used to cause
-# actions immediately before and after the install target
-# is executed.
-#
-# load:
-# Load KLD.
-#
-# unload:
-# Unload KLD.
-#
-# bsd.obj.mk: clean, cleandir and obj
-# bsd.dep.mk: cleandepend, depend and tags
-# bsd.man.mk: maninstall
-#
-
-KMODLOAD?= /sbin/kldload
-KMODUNLOAD?= /sbin/kldunload
-
-.if !target(__initialized__)
-__initialized__:
-.if exists(${.CURDIR}/../Makefile.inc)
-.include "${.CURDIR}/../Makefile.inc"
-.endif
-.endif
-
-.SUFFIXES: .out .o .c .cc .cxx .C .y .l .s .S
-
-CFLAGS+= ${COPTS} -D_KERNEL ${CWARNFLAGS}
-CFLAGS+= -DKLD_MODULE
-
-# Don't use any standard or source-relative include directories.
-# Since -nostdinc will annull any previous -I paths, we repeat all
-# such paths after -nostdinc. It doesn't seem to be possible to
-# add to the front of `make' variable.
-_ICFLAGS:= ${CFLAGS:M-I*}
-CFLAGS+= -nostdinc -I- ${_ICFLAGS}
-
-# Add -I paths for system headers. Individual KLD makefiles don't
-# need any -I paths for this. Similar defaults for .PATH can't be
-# set because there are no standard paths for non-headers.
-CFLAGS+= -I. -I@
-
-# Add a -I path to standard headers like <stddef.h>. Use a relative
-# path to src/include if possible. If the @ symlink hasn't been built
-# yet, then we can't tell if the relative path exists. Add both the
-# potential relative path and an absolute path in that case.
-.if exists(@)
-.if exists(@/../include)
-CFLAGS+= -I@/../include
-.else
-CFLAGS+= -I${DESTDIR}/usr/include
-.endif
-.else # !@
-CFLAGS+= -I@/../include -I${DESTDIR}/usr/include
-.endif # @
-
-CFLAGS+= ${DEBUG_FLAGS}
-
-.if ${OBJFORMAT} == elf
-CLEANFILES+= setdef0.c setdef1.c setdefs.h
-CLEANFILES+= setdef0.o setdef1.o
-.endif
-
-OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
-
-.if !defined(PROG)
-PROG= ${KMOD}.ko
-.endif
-
-${PROG}: ${OBJS} ${DPADD} ${KMODDEPS}
-.if ${OBJFORMAT} == elf
- gensetdefs ${OBJS}
- ${CC} ${CFLAGS} -c setdef0.c
- ${CC} ${CFLAGS} -c setdef1.c
- ${LD} -Bshareable ${LDFLAGS} -o ${.TARGET} setdef0.o ${OBJS} setdef1.o ${KMODDEPS}
-.else
- ${LD} -Bshareable ${LDFLAGS} -o ${.TARGET} ${OBJS} ${KMODDEPS}
-.endif
-
-.if defined(KMODDEPS)
-.for dep in ${KMODDEPS}
-CLEANFILES+= ${dep} __${dep}_hack_dep.c
-
-${dep}:
- touch __${dep}_hack_dep.c
- ${CC} -shared ${CFLAGS} -o ${dep} __${dep}_hack_dep.c
-.endfor
-.endif
-
-.if !defined(NOMAN)
-.include <bsd.man.mk>
-.if !defined(_MANPAGES) || empty(_MANPAGES)
-MAN1= ${KMOD}.4
-.endif
-
-.elif !target(maninstall)
-maninstall: _SUBDIR
-all-man:
-.endif
-
-_ILINKS=@ machine
-
-.MAIN: all
-all: objwarn ${PROG} all-man _SUBDIR
-
-beforedepend ${OBJS}: ${_ILINKS}
-
-# The search for the link targets works best if we are in a normal src
-# tree, and not too deeply below src/sys/modules. If we are near "/", then
-# we may find /sys - this is harmless. Other abnormal "sys" directories
-# found in the search are likely to cause problems. If nothing is found,
-# then the links default to /usr/include and /usr/include/machine.
-${_ILINKS}:
- @set +x; for up in ../.. ../../.. ; do \
- case ${.TARGET} in \
- machine) \
- testpath=${.CURDIR}/$$up/${MACHINE_ARCH}/include ; \
- path=${.CURDIR}/$$up/${MACHINE_ARCH}/include ; \
- defaultpath=/usr/include/machine ;; \
- @) \
- testpath=${.CURDIR}/$$up/sys ; \
- path=${.CURDIR}/$$up ; \
- defaultpath=/usr/include ;; \
- esac ; \
- if [ -d $$testpath ] ; then break ; fi ; \
- path=$$defaultpath ; \
- done ; \
- path=`(cd $$path && /bin/pwd)` ; \
- ${ECHO} ${.TARGET} "->" $$path ; \
- ln -s $$path ${.TARGET}
-
-CLEANFILES+= ${PROG} ${OBJS} ${_ILINKS} symb.tmp tmp.o
-
-.if !target(install)
-.if !target(beforeinstall)
-beforeinstall:
-.endif
-.if !target(afterinstall)
-afterinstall:
-.endif
-
-_INSTALLFLAGS:= ${INSTALLFLAGS}
-.for ie in ${INSTALLFLAGS_EDIT}
-_INSTALLFLAGS:= ${_INSTALLFLAGS${ie}}
-.endfor
-
-realinstall: _SUBDIR
- ${INSTALL} ${COPY} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \
- ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${KMODDIR}
-.if defined(LINKS) && !empty(LINKS)
- @set ${LINKS}; \
- while test $$# -ge 2; do \
- l=${DESTDIR}$$1; \
- shift; \
- t=${DESTDIR}$$1; \
- shift; \
- ${ECHO} $$t -\> $$l; \
- ln -f $$l $$t; \
- done; true
-.endif
-.if defined(SYMLINKS) && !empty(SYMLINKS)
- @set ${SYMLINKS}; \
- while test $$# -ge 2; do \
- l=$$1; \
- shift; \
- t=${DESTDIR}$$1; \
- shift; \
- ${ECHO} $$t -\> $$l; \
- ln -fs $$l $$t; \
- done; true
-.endif
-
-install: afterinstall _SUBDIR
-.if !defined(NOMAN)
-afterinstall: realinstall maninstall
-.else
-afterinstall: realinstall
-.endif
-realinstall: beforeinstall
-.endif
-
-DISTRIBUTION?= bin
-.if !target(distribute)
-distribute: _SUBDIR
-.for dist in ${DISTRIBUTION}
- cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${dist} SHARED=copies
-.endfor
-.endif
-
-.if !target(load)
-load: ${PROG} install
- ${KMODLOAD} ${KMOD}
-.endif
-
-.if !target(unload)
-unload:
- ${KMODUNLOAD} ${KMOD}
-.endif
-
-.if exists(${.CURDIR}/../../kern)
-KERN= ${.CURDIR}/../../kern
-.else
-KERN= ${.CURDIR}/../../sys/kern
-.endif
-
-.for _src in ${SRCS:Mopt_*.h}
-CLEANFILES+= ${_src}
-.if !target(${_src})
-${_src}:
- touch ${.TARGET}
-.endif
-.endfor
-
-.for _srcsrc in kern/bus_if.m kern/device_if.m dev/iicbus/iicbb_if.m \
- dev/iicbus/iicbus_if.m isa/isa_if.m dev/mii/miibus_if.m \
- dev/pccard/card_if.m dev/pccard/power_if.m pci/pci_if.m \
- dev/ppbus/ppbus_if.m dev/smbus/smbus_if.m dev/usb/usb_if.m
-.for _ext in c h
-.for _src in ${SRCS:M${_srcsrc:T:R}.${_ext}}
-CLEANFILES+= ${_src}
-.if !target(${_src})
-${_src}: @
-.if exists(@)
-${_src}: @/kern/makedevops.pl @/${_srcsrc}
-.endif
- perl @/kern/makedevops.pl -${_ext} @/${_srcsrc}
-.endif
-.endfor # _src
-.endfor # _ext
-.endfor # _srcsrc
-
-.for _ext in c h
-.if ${SRCS:Mvnode_if.${_ext}} != ""
-CLEANFILES+= vnode_if.${_ext}
-vnode_if.${_ext}: @
-.if exists(@)
-vnode_if.${_ext}: @/kern/vnode_if.pl @/kern/vnode_if.src
-.endif
- perl @/kern/vnode_if.pl -${_ext} @/kern/vnode_if.src
-.endif
-.endfor
-
-regress:
-
-.include <bsd.dep.mk>
-
-.if !exists(${DEPENDFILE})
-${OBJS}: ${SRCS:M*.h}
-.endif
-
-.include <bsd.obj.mk>
-
-.include <bsd.kern.mk>
diff --git a/sys/conf/ldscript.amd64 b/sys/conf/ldscript.amd64
deleted file mode 100644
index a42b8fa70c12..000000000000
--- a/sys/conf/ldscript.amd64
+++ /dev/null
@@ -1,129 +0,0 @@
-/* $FreeBSD$ */
-OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
-OUTPUT_ARCH(i386)
-ENTRY(btext)
-SEARCH_DIR(/usr/lib);
-SECTIONS
-{
- /* Read-only sections, merged into text segment: */
- . = 0xc0100000 + SIZEOF_HEADERS;
- .interp : { *(.interp) }
- .hash : { *(.hash) }
- .dynsym : { *(.dynsym) }
- .dynstr : { *(.dynstr) }
- .gnu.version : { *(.gnu.version) }
- .gnu.version_d : { *(.gnu.version_d) }
- .gnu.version_r : { *(.gnu.version_r) }
- .rel.text :
- { *(.rel.text) *(.rel.gnu.linkonce.t*) }
- .rela.text :
- { *(.rela.text) *(.rela.gnu.linkonce.t*) }
- .rel.data :
- { *(.rel.data) *(.rel.gnu.linkonce.d*) }
- .rela.data :
- { *(.rela.data) *(.rela.gnu.linkonce.d*) }
- .rel.rodata :
- { *(.rel.rodata) *(.rel.gnu.linkonce.r*) }
- .rela.rodata :
- { *(.rela.rodata) *(.rela.gnu.linkonce.r*) }
- .rel.got : { *(.rel.got) }
- .rela.got : { *(.rela.got) }
- .rel.ctors : { *(.rel.ctors) }
- .rela.ctors : { *(.rela.ctors) }
- .rel.dtors : { *(.rel.dtors) }
- .rela.dtors : { *(.rela.dtors) }
- .rel.init : { *(.rel.init) }
- .rela.init : { *(.rela.init) }
- .rel.fini : { *(.rel.fini) }
- .rela.fini : { *(.rela.fini) }
- .rel.bss : { *(.rel.bss) }
- .rela.bss : { *(.rela.bss) }
- .rel.plt : { *(.rel.plt) }
- .rela.plt : { *(.rela.plt) }
- .init : { *(.init) } =0x9090
- .plt : { *(.plt) }
- .text :
- {
- *(.text)
- *(.stub)
- /* .gnu.warning sections are handled specially by elf32.em. */
- *(.gnu.warning)
- *(.gnu.linkonce.t*)
- } =0x9090
- _etext = .;
- PROVIDE (etext = .);
- .fini : { *(.fini) } =0x9090
- .rodata : { *(.rodata) *(.gnu.linkonce.r*) }
- .rodata1 : { *(.rodata1) }
- /* Adjust the address for the data segment. We want to adjust up to
- the same address within the page on the next page up. */
- . = ALIGN(0x1000) + (. & (0x1000 - 1)) ;
- .data :
- {
- *(.data)
- *(.gnu.linkonce.d*)
- CONSTRUCTORS
- }
- .data1 : { *(.data1) }
- .ctors :
- {
- *(.ctors)
- }
- .dtors :
- {
- *(.dtors)
- }
- .got : { *(.got.plt) *(.got) }
- .dynamic : { *(.dynamic) }
- /* We want the small data sections together, so single-instruction offsets
- can access them all, and initialized data all before uninitialized, so
- we can shorten the on-disk segment size. */
- .sdata : { *(.sdata) }
- _edata = .;
- PROVIDE (edata = .);
- __bss_start = .;
- .sbss : { *(.sbss) *(.scommon) }
- .bss :
- {
- *(.dynbss)
- *(.bss)
- *(COMMON)
- }
- . = ALIGN(32 / 8);
- _end = . ;
- PROVIDE (end = .);
- /* Stabs debugging sections. */
- .stab 0 : { *(.stab) }
- .stabstr 0 : { *(.stabstr) }
- .stab.excl 0 : { *(.stab.excl) }
- .stab.exclstr 0 : { *(.stab.exclstr) }
- .stab.index 0 : { *(.stab.index) }
- .stab.indexstr 0 : { *(.stab.indexstr) }
- .comment 0 : { *(.comment) }
- /* DWARF debug sections.
- Symbols in the DWARF debugging sections are relative to the beginning
- of the section so we begin them at 0. */
- /* DWARF 1 */
- .debug 0 : { *(.debug) }
- .line 0 : { *(.line) }
- /* GNU DWARF 1 extensions */
- .debug_srcinfo 0 : { *(.debug_srcinfo) }
- .debug_sfnames 0 : { *(.debug_sfnames) }
- /* DWARF 1.1 and DWARF 2 */
- .debug_aranges 0 : { *(.debug_aranges) }
- .debug_pubnames 0 : { *(.debug_pubnames) }
- /* DWARF 2 */
- .debug_info 0 : { *(.debug_info) }
- .debug_abbrev 0 : { *(.debug_abbrev) }
- .debug_line 0 : { *(.debug_line) }
- .debug_frame 0 : { *(.debug_frame) }
- .debug_str 0 : { *(.debug_str) }
- .debug_loc 0 : { *(.debug_loc) }
- .debug_macinfo 0 : { *(.debug_macinfo) }
- /* SGI/MIPS DWARF 2 extensions */
- .debug_weaknames 0 : { *(.debug_weaknames) }
- .debug_funcnames 0 : { *(.debug_funcnames) }
- .debug_typenames 0 : { *(.debug_typenames) }
- .debug_varnames 0 : { *(.debug_varnames) }
- /* These must appear regardless of . */
-}
diff --git a/sys/conf/ldscript.powerpc b/sys/conf/ldscript.powerpc
deleted file mode 100644
index a0e054787876..000000000000
--- a/sys/conf/ldscript.powerpc
+++ /dev/null
@@ -1,132 +0,0 @@
-/* $FreeBSD$ */
-OUTPUT_FORMAT("elf64-alpha", "elf64-alpha", "elf64-alpha")
-OUTPUT_ARCH(alpha)
-ENTRY(__start)
-SEARCH_DIR(/usr/lib);
-kernel_text = 0xfffffc0000300000;
-SECTIONS
-{
- /* Read-only sections, merged into text segment: */
- . = 0xfffffc0000300000 + SIZEOF_HEADERS;
- .interp : { *(.interp) }
- .hash : { *(.hash) }
- .dynsym : { *(.dynsym) }
- .dynstr : { *(.dynstr) }
- .gnu.version : { *(.gnu.version) }
- .gnu.version_d : { *(.gnu.version_d) }
- .gnu.version_r : { *(.gnu.version_r) }
- .rel.text :
- { *(.rel.text) *(.rel.gnu.linkonce.t*) }
- .rela.text :
- { *(.rela.text) *(.rela.gnu.linkonce.t*) }
- .rel.data :
- { *(.rel.data) *(.rel.gnu.linkonce.d*) }
- .rela.data :
- { *(.rela.data) *(.rela.gnu.linkonce.d*) }
- .rel.rodata :
- { *(.rel.rodata) *(.rel.gnu.linkonce.r*) }
- .rela.rodata :
- { *(.rela.rodata) *(.rela.gnu.linkonce.r*) }
- .rel.got : { *(.rel.got) }
- .rela.got : { *(.rela.got) }
- .rel.ctors : { *(.rel.ctors) }
- .rela.ctors : { *(.rela.ctors) }
- .rel.dtors : { *(.rel.dtors) }
- .rela.dtors : { *(.rela.dtors) }
- .rel.init : { *(.rel.init) }
- .rela.init : { *(.rela.init) }
- .rel.fini : { *(.rel.fini) }
- .rela.fini : { *(.rela.fini) }
- .rel.bss : { *(.rel.bss) }
- .rela.bss : { *(.rela.bss) }
- .rel.plt : { *(.rel.plt) }
- .rela.plt : { *(.rela.plt) }
- .init : { *(.init) } =0x47ff041f
- .text :
- {
- *(.text)
- *(.stub)
- /* .gnu.warning sections are handled specially by elf32.em. */
- *(.gnu.warning)
- *(.gnu.linkonce.t*)
- } =0x47ff041f
- _etext = .;
- PROVIDE (etext = .);
- .fini : { *(.fini) } =0x47ff041f
- .rodata : { *(.rodata) *(.gnu.linkonce.r*) }
- .rodata1 : { *(.rodata1) }
- .reginfo : { *(.reginfo) }
- /* Adjust the address for the data segment. We want to adjust up to
- the same address within the page on the next page up. */
- . = .;
- .data :
- {
- *(.data)
- *(.gnu.linkonce.d*)
- CONSTRUCTORS
- }
- .data1 : { *(.data1) }
- .ctors :
- {
- *(.ctors)
- }
- .dtors :
- {
- *(.dtors)
- }
- .plt : { *(.plt) }
- .got : { *(.got.plt) *(.got) }
- .dynamic : { *(.dynamic) }
- /* We want the small data sections together, so single-instruction offsets
- can access them all, and initialized data all before uninitialized, so
- we can shorten the on-disk segment size. */
- .sdata : { *(.sdata) }
- _edata = .;
- PROVIDE (edata = .);
- __bss_start = .;
- .sbss : { *(.sbss) *(.scommon) }
- .bss :
- {
- *(.dynbss)
- *(.bss)
- *(COMMON)
- }
- . = ALIGN(64 / 8);
- _end = . ;
- PROVIDE (end = .);
- /* Stabs debugging sections. */
- .stab 0 : { *(.stab) }
- .stabstr 0 : { *(.stabstr) }
- .stab.excl 0 : { *(.stab.excl) }
- .stab.exclstr 0 : { *(.stab.exclstr) }
- .stab.index 0 : { *(.stab.index) }
- .stab.indexstr 0 : { *(.stab.indexstr) }
- .comment 0 : { *(.comment) }
- /* DWARF debug sections.
- Symbols in the DWARF debugging sections are relative to the beginning
- of the section so we begin them at 0. */
- /* DWARF 1 */
- .debug 0 : { *(.debug) }
- .line 0 : { *(.line) }
- /* GNU DWARF 1 extensions */
- .debug_srcinfo 0 : { *(.debug_srcinfo) }
- .debug_sfnames 0 : { *(.debug_sfnames) }
- /* DWARF 1.1 and DWARF 2 */
- .debug_aranges 0 : { *(.debug_aranges) }
- .debug_pubnames 0 : { *(.debug_pubnames) }
- /* DWARF 2 */
- .debug_info 0 : { *(.debug_info) }
- .debug_abbrev 0 : { *(.debug_abbrev) }
- .debug_line 0 : { *(.debug_line) }
- .debug_frame 0 : { *(.debug_frame) }
- .debug_str 0 : { *(.debug_str) }
- .debug_loc 0 : { *(.debug_loc) }
- .debug_macinfo 0 : { *(.debug_macinfo) }
- /* SGI/MIPS DWARF 2 extensions */
- .debug_weaknames 0 : { *(.debug_weaknames) }
- .debug_funcnames 0 : { *(.debug_funcnames) }
- .debug_typenames 0 : { *(.debug_typenames) }
- .debug_varnames 0 : { *(.debug_varnames) }
- /* These must appear regardless of . */
-}
-
diff --git a/sys/dev/aic7xxx/aic7xxx_93cx6.c b/sys/dev/aic7xxx/aic7xxx_93cx6.c
deleted file mode 100644
index 06e547b57b13..000000000000
--- a/sys/dev/aic7xxx/aic7xxx_93cx6.c
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Interface for the 93C66/56/46/26/06 serial eeprom parts.
- *
- * Copyright (c) 1995, 1996 Daniel M. Eischen
- * 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 immediately at the beginning of the file, without modification,
- * 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. Absolutely no warranty of function or purpose is made by the author
- * Daniel M. Eischen.
- * 4. Modifications may be freely made to this file if the above conditions
- * are met.
- *
- * $FreeBSD$
- */
-
-/*
- * The instruction set of the 93C66/56/46/26/06 chips are as follows:
- *
- * Start OP *
- * Function Bit Code Address** Data Description
- * -------------------------------------------------------------------
- * READ 1 10 A5 - A0 Reads data stored in memory,
- * starting at specified address
- * EWEN 1 00 11XXXX Write enable must preceed
- * all programming modes
- * ERASE 1 11 A5 - A0 Erase register A5A4A3A2A1A0
- * WRITE 1 01 A5 - A0 D15 - D0 Writes register
- * ERAL 1 00 10XXXX Erase all registers
- * WRAL 1 00 01XXXX D15 - D0 Writes to all registers
- * EWDS 1 00 00XXXX Disables all programming
- * instructions
- * *Note: A value of X for address is a don't care condition.
- * **Note: There are 8 address bits for the 93C56/66 chips unlike
- * the 93C46/26/06 chips which have 6 address bits.
- *
- * The 93C46 has a four wire interface: clock, chip select, data in, and
- * data out. In order to perform one of the above functions, you need
- * to enable the chip select for a clock period (typically a minimum of
- * 1 usec, with the clock high and low a minimum of 750 and 250 nsec
- * respectively). While the chip select remains high, you can clock in
- * the instructions (above) starting with the start bit, followed by the
- * OP code, Address, and Data (if needed). For the READ instruction, the
- * requested 16-bit register contents is read from the data out line but
- * is preceded by an initial zero (leading 0, followed by 16-bits, MSB
- * first). The clock cycling from low to high initiates the next data
- * bit to be sent from the chip.
- *
- */
-
-#include "opt_aic7xxx.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <machine/bus_memio.h>
-#include <machine/bus_pio.h>
-#include <machine/bus.h>
-#include <dev/aic7xxx/93cx6.h>
-
-/*
- * Right now, we only have to read the SEEPROM. But we make it easier to
- * add other 93Cx6 functions.
- */
-static struct seeprom_cmd {
- unsigned char len;
- unsigned char bits[3];
-} seeprom_read = {3, {1, 1, 0}};
-
-/*
- * Wait for the SEERDY to go high; about 800 ns.
- */
-#define CLOCK_PULSE(sd, rdy) \
- while ((SEEPROM_STATUS_INB(sd) & rdy) == 0) { \
- ; /* Do nothing */ \
- } \
- (void)SEEPROM_INB(sd); /* Clear clock */
-
-/*
- * Read the serial EEPROM and returns 1 if successful and 0 if
- * not successful.
- */
-int
-read_seeprom(sd, buf, start_addr, count)
- struct seeprom_descriptor *sd;
- u_int16_t *buf;
- bus_size_t start_addr;
- bus_size_t count;
-{
- int i = 0;
- u_int k = 0;
- u_int16_t v;
- u_int8_t temp;
-
- /*
- * Read the requested registers of the seeprom. The loop
- * will range from 0 to count-1.
- */
- for (k = start_addr; k < count + start_addr; k++) {
- /* Send chip select for one clock cycle. */
- temp = sd->sd_MS ^ sd->sd_CS;
- SEEPROM_OUTB(sd, temp ^ sd->sd_CK);
- CLOCK_PULSE(sd, sd->sd_RDY);
-
- /*
- * Now we're ready to send the read command followed by the
- * address of the 16-bit register we want to read.
- */
- for (i = 0; i < seeprom_read.len; i++) {
- if (seeprom_read.bits[i] != 0)
- temp ^= sd->sd_DO;
- SEEPROM_OUTB(sd, temp);
- CLOCK_PULSE(sd, sd->sd_RDY);
- SEEPROM_OUTB(sd, temp ^ sd->sd_CK);
- CLOCK_PULSE(sd, sd->sd_RDY);
- if (seeprom_read.bits[i] != 0)
- temp ^= sd->sd_DO;
- }
- /* Send the 6 or 8 bit address (MSB first, LSB last). */
- for (i = (sd->sd_chip - 1); i >= 0; i--) {
- if ((k & (1 << i)) != 0)
- temp ^= sd->sd_DO;
- SEEPROM_OUTB(sd, temp);
- CLOCK_PULSE(sd, sd->sd_RDY);
- SEEPROM_OUTB(sd, temp ^ sd->sd_CK);
- CLOCK_PULSE(sd, sd->sd_RDY);
- if ((k & (1 << i)) != 0)
- temp ^= sd->sd_DO;
- }
-
- /*
- * Now read the 16 bit register. An initial 0 precedes the
- * register contents which begins with bit 15 (MSB) and ends
- * with bit 0 (LSB). The initial 0 will be shifted off the
- * top of our word as we let the loop run from 0 to 16.
- */
- v = 0;
- for (i = 16; i >= 0; i--) {
- SEEPROM_OUTB(sd, temp);
- CLOCK_PULSE(sd, sd->sd_RDY);
- v <<= 1;
- if (SEEPROM_DATA_INB(sd) & sd->sd_DI)
- v |= 1;
- SEEPROM_OUTB(sd, temp ^ sd->sd_CK);
- CLOCK_PULSE(sd, sd->sd_RDY);
- }
-
- buf[k - start_addr] = v;
-
- /* Reset the chip select for the next command cycle. */
- temp = sd->sd_MS;
- SEEPROM_OUTB(sd, temp);
- CLOCK_PULSE(sd, sd->sd_RDY);
- SEEPROM_OUTB(sd, temp ^ sd->sd_CK);
- CLOCK_PULSE(sd, sd->sd_RDY);
- SEEPROM_OUTB(sd, temp);
- CLOCK_PULSE(sd, sd->sd_RDY);
- }
-#ifdef AHC_DUMP_EEPROM
- printf("\nSerial EEPROM:\n\t");
- for (k = 0; k < count; k = k + 1) {
- if (((k % 8) == 0) && (k != 0)) {
- printf ("\n\t");
- }
- printf (" 0x%x", buf[k]);
- }
- printf ("\n");
-#endif
- return (1);
-}
diff --git a/sys/dev/aic7xxx/aic7xxx_93cx6.h b/sys/dev/aic7xxx/aic7xxx_93cx6.h
deleted file mode 100644
index 7875032e28de..000000000000
--- a/sys/dev/aic7xxx/aic7xxx_93cx6.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Interface to the 93C46 serial EEPROM that is used to store BIOS
- * settings for the aic7xxx based adaptec SCSI controllers. It can
- * also be used for 93C26 and 93C06 serial EEPROMS.
- *
- * Copyright (c) 1994, 1995 Justin T. Gibbs.
- * 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,
- * without modification.
- * 2. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * Alternatively, this software may be distributed under the terms of the
- * the GNU Public License ("GPL").
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#if !defined(__NetBSD__)
-#include <sys/systm.h>
-#endif
-
-#ifdef _KERNEL
-
-typedef enum {
- C46 = 6,
- C56_66 = 8
-} seeprom_chip_t;
-
-struct seeprom_descriptor {
- bus_space_tag_t sd_tag;
- bus_space_handle_t sd_bsh;
- bus_size_t sd_control_offset;
- bus_size_t sd_status_offset;
- bus_size_t sd_dataout_offset;
- seeprom_chip_t sd_chip;
- u_int16_t sd_MS;
- u_int16_t sd_RDY;
- u_int16_t sd_CS;
- u_int16_t sd_CK;
- u_int16_t sd_DO;
- u_int16_t sd_DI;
-};
-
-/*
- * This function will read count 16-bit words from the serial EEPROM and
- * return their value in buf. The port address of the aic7xxx serial EEPROM
- * control register is passed in as offset. The following parameters are
- * also passed in:
- *
- * CS - Chip select
- * CK - Clock
- * DO - Data out
- * DI - Data in
- * RDY - SEEPROM ready
- * MS - Memory port mode select
- *
- * A failed read attempt returns 0, and a successful read returns 1.
- */
-
-#define SEEPROM_INB(sd) \
- bus_space_read_1(sd->sd_tag, sd->sd_bsh, sd->sd_control_offset)
-#define SEEPROM_OUTB(sd, value) \
- bus_space_write_1(sd->sd_tag, sd->sd_bsh, sd->sd_control_offset, value)
-#define SEEPROM_STATUS_INB(sd) \
- bus_space_read_1(sd->sd_tag, sd->sd_bsh, sd->sd_status_offset)
-#define SEEPROM_DATA_INB(sd) \
- bus_space_read_1(sd->sd_tag, sd->sd_bsh, sd->sd_dataout_offset)
-
-int read_seeprom(struct seeprom_descriptor *sd, u_int16_t *buf,
- bus_size_t start_addr, bus_size_t count);
-
-#endif /* _KERNEL */
diff --git a/sys/dev/aic7xxx/aicasm/Makefile b/sys/dev/aic7xxx/aicasm/Makefile
deleted file mode 100644
index aa478151de4e..000000000000
--- a/sys/dev/aic7xxx/aicasm/Makefile
+++ /dev/null
@@ -1,31 +0,0 @@
-# $FreeBSD$
-
-PROG= aicasm
-
-CSRCS= aicasm.c aicasm_symbol.c
-GENSRCS= aicasm_gram.c aicasm_scan.c
-
-GENHDRS= y.tab.h
-
-SRCS= ${GENSRCS} ${CSRCS}
-CLEANFILES+= ${GENSRCS} ${GENHDRS} y.output
-DPADD+= ${LIBL}
-LDADD+= -ll
-
-# Correct path for kernel builds
-# Don't rely on the kernel's .depend file
-.ifdef MAKESRCPATH
-.PATH: ${MAKESRCPATH}
-DEPENDFILE=
-.endif
-
-CFLAGS+= -I/usr/include -I.
-NOMAN= noman
-
-.ifdef DEBUG
-CFLAGS+= -DDEBUG -g
-YFLAGS+= -t
-LFLAGS+= -d
-.endif
-
-.include <bsd.prog.mk>
diff --git a/sys/dev/aic7xxx/aicasm/aicasm.c b/sys/dev/aic7xxx/aicasm/aicasm.c
deleted file mode 100644
index 9af5c8343274..000000000000
--- a/sys/dev/aic7xxx/aicasm/aicasm.c
+++ /dev/null
@@ -1,720 +0,0 @@
-/*
- * Aic7xxx SCSI host adapter firmware asssembler
- *
- * Copyright (c) 1997, 1998 Justin T. Gibbs.
- * 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,
- * without modification, immediately at the beginning of the file.
- * 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 BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <sys/types.h>
-#include <sys/mman.h>
-
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sysexits.h>
-#include <unistd.h>
-
-#include "aicasm.h"
-#include "aicasm_symbol.h"
-#include "sequencer.h"
-
-typedef struct patch {
- STAILQ_ENTRY(patch) links;
- int patch_func;
- u_int begin;
- u_int skip_instr;
- u_int skip_patch;
-} patch_t;
-
-STAILQ_HEAD(patch_list, patch) patches;
-
-static void usage(void);
-static void back_patch(void);
-static void output_code(FILE *ofile);
-static void output_listing(FILE *listfile, char *ifilename);
-static void dump_scope(scope_t *scope);
-static void emit_patch(scope_t *scope, int patch);
-static int check_patch(patch_t **start_patch, int start_instr,
- int *skip_addr, int *func_vals);
-
-struct path_list search_path;
-int includes_search_curdir;
-char *appname;
-FILE *ofile;
-char *ofilename;
-char *regfilename;
-FILE *regfile;
-char *listfilename;
-FILE *listfile;
-
-static STAILQ_HEAD(,instruction) seq_program;
-struct scope_list scope_stack;
-symlist_t patch_functions;
-
-#if DEBUG
-extern int yy_flex_debug;
-extern int yydebug;
-#endif
-extern FILE *yyin;
-extern int yyparse __P((void));
-
-int
-main(argc, argv)
- int argc;
- char *argv[];
-{
- extern char *optarg;
- extern int optind;
- int ch;
- int retval;
- char *inputfilename;
- scope_t *sentinal;
-
- STAILQ_INIT(&patches);
- SLIST_INIT(&search_path);
- STAILQ_INIT(&seq_program);
- SLIST_INIT(&scope_stack);
-
- /* Set Sentinal scope node */
- sentinal = scope_alloc();
- sentinal->type = SCOPE_ROOT;
-
- includes_search_curdir = 1;
- appname = *argv;
- regfile = NULL;
- listfile = NULL;
-#if DEBUG
- yy_flex_debug = 0;
- yydebug = 0;
-#endif
- while ((ch = getopt(argc, argv, "d:l:n:o:r:I:O:")) != -1) {
- switch(ch) {
- case 'd':
-#if DEBUG
- if (strcmp(optarg, "s") == 0) {
- yy_flex_debug = 1;
- } else if (strcmp(optarg, "p") == 0) {
- yydebug = 1;
- } else {
- fprintf(stderr, "%s: -d Requires either an "
- "'s' or 'p' argument\n", appname);
- usage();
- }
-#else
- stop("-d: Assembler not built with debugging "
- "information", EX_SOFTWARE);
-#endif
- break;
- case 'l':
- /* Create a program listing */
- if ((listfile = fopen(optarg, "w")) == NULL) {
- perror(optarg);
- stop(NULL, EX_CANTCREAT);
- }
- listfilename = optarg;
- break;
- case 'n':
- /* Don't complain about the -nostdinc directrive */
- if (strcmp(optarg, "ostdinc")) {
- fprintf(stderr, "%s: Unknown option -%c%s\n",
- appname, ch, optarg);
- usage();
- /* NOTREACHED */
- }
- break;
- case 'o':
- if ((ofile = fopen(optarg, "w")) == NULL) {
- perror(optarg);
- stop(NULL, EX_CANTCREAT);
- }
- ofilename = optarg;
- break;
- case 'r':
- if ((regfile = fopen(optarg, "w")) == NULL) {
- perror(optarg);
- stop(NULL, EX_CANTCREAT);
- }
- regfilename = optarg;
- break;
- case 'I':
- {
- path_entry_t include_dir;
-
- if (strcmp(optarg, "-") == 0) {
- if (includes_search_curdir == 0) {
- fprintf(stderr, "%s: Warning - '-I-' "
- "specified multiple "
- "times\n", appname);
- }
- includes_search_curdir = 0;
- for (include_dir = search_path.slh_first;
- include_dir != NULL;
- include_dir = include_dir->links.sle_next)
- /*
- * All entries before a '-I-' only
- * apply to includes specified with
- * quotes instead of "<>".
- */
- include_dir->quoted_includes_only = 1;
- } else {
- include_dir =
- (path_entry_t)malloc(sizeof(*include_dir));
- if (include_dir == NULL) {
- perror(optarg);
- stop(NULL, EX_OSERR);
- }
- include_dir->directory = strdup(optarg);
- if (include_dir->directory == NULL) {
- perror(optarg);
- stop(NULL, EX_OSERR);
- }
- include_dir->quoted_includes_only = 0;
- SLIST_INSERT_HEAD(&search_path, include_dir,
- links);
- }
- break;
- }
- case '?':
- default:
- usage();
- /* NOTREACHED */
- }
- }
- argc -= optind;
- argv += optind;
-
- if (argc != 1) {
- fprintf(stderr, "%s: No input file specifiled\n", appname);
- usage();
- /* NOTREACHED */
- }
-
- symtable_open();
- inputfilename = *argv;
- include_file(*argv, SOURCE_FILE);
- retval = yyparse();
- if (retval == 0) {
- if (SLIST_FIRST(&scope_stack) == NULL
- || SLIST_FIRST(&scope_stack)->type != SCOPE_ROOT) {
- stop("Unterminated conditional expression",
- EX_DATAERR);
- /* NOTREACHED */
- }
-
- /* Process outmost scope */
- process_scope(SLIST_FIRST(&scope_stack));
- /*
- * Decend the tree of scopes and insert/emit
- * patches as appropriate. We perform a depth first
- * tranversal, recursively handling each scope.
- */
- /* start at the root scope */
- dump_scope(SLIST_FIRST(&scope_stack));
-
- /* Patch up forward jump addresses */
- back_patch();
-
- if (ofile != NULL)
- output_code(ofile);
- if (regfile != NULL) {
- symtable_dump(regfile);
- }
- if (listfile != NULL)
- output_listing(listfile, inputfilename);
- }
-
- stop(NULL, 0);
- /* NOTREACHED */
- return (0);
-}
-
-static void
-usage()
-{
-
- (void)fprintf(stderr,
-"usage: %-16s [-nostdinc] [-I-] [-I directory] [-o output_file]
- [-r register_output_file] [-l program_list_file]
- input_file\n",
- appname);
- exit(EX_USAGE);
-}
-
-static void
-back_patch()
-{
- struct instruction *cur_instr;
-
- for(cur_instr = seq_program.stqh_first;
- cur_instr != NULL;
- cur_instr = cur_instr->links.stqe_next) {
- if (cur_instr->patch_label != NULL) {
- struct ins_format3 *f3_instr;
- u_int address;
-
- if (cur_instr->patch_label->type != LABEL) {
- char buf[255];
-
- snprintf(buf, sizeof(buf),
- "Undefined label %s",
- cur_instr->patch_label->name);
- stop(buf, EX_DATAERR);
- /* NOTREACHED */
- }
- f3_instr = &cur_instr->format.format3;
- address = f3_instr->address;
- address += cur_instr->patch_label->info.linfo->address;
- f3_instr->address = address;
- }
- }
-}
-
-static void
-output_code(ofile)
- FILE *ofile;
-{
- struct instruction *cur_instr;
- patch_t *cur_patch;
- symbol_node_t *cur_node;
- int instrcount;
-
- instrcount = 0;
- fprintf(ofile,
-"/*
- * DO NOT EDIT - This file is automatically generated.
- */\n");
-
- fprintf(ofile, "static u_int8_t seqprog[] = {\n");
- for(cur_instr = seq_program.stqh_first;
- cur_instr != NULL;
- cur_instr = cur_instr->links.stqe_next) {
-
- fprintf(ofile, "\t0x%02x, 0x%02x, 0x%02x, 0x%02x,\n",
- cur_instr->format.bytes[0],
- cur_instr->format.bytes[1],
- cur_instr->format.bytes[2],
- cur_instr->format.bytes[3]);
- instrcount++;
- }
- fprintf(ofile, "};\n\n");
-
- /*
- * Output patch information. Patch functions first.
- */
- for(cur_node = SLIST_FIRST(&patch_functions);
- cur_node != NULL;
- cur_node = SLIST_NEXT(cur_node,links)) {
- fprintf(ofile,
-"static int ahc_patch%d_func(struct ahc_softc *ahc);
-
-static int
-ahc_patch%d_func(struct ahc_softc *ahc)
-{
- return (%s);
-}\n\n",
- cur_node->symbol->info.condinfo->func_num,
- cur_node->symbol->info.condinfo->func_num,
- cur_node->symbol->name);
- }
-
- fprintf(ofile,
-"typedef int patch_func_t __P((struct ahc_softc *));
-struct patch {
- patch_func_t *patch_func;
- u_int32_t begin :10,
- skip_instr :10,
- skip_patch :12;
-} patches[] = {\n");
-
- for(cur_patch = STAILQ_FIRST(&patches);
- cur_patch != NULL;
- cur_patch = STAILQ_NEXT(cur_patch,links)) {
- fprintf(ofile, "\t{ ahc_patch%d_func, %d, %d, %d },\n",
- cur_patch->patch_func, cur_patch->begin,
- cur_patch->skip_instr, cur_patch->skip_patch);
- }
-
- fprintf(ofile, "\n};\n");
-
- fprintf(stderr, "%s: %d instructions used\n", appname, instrcount);
-}
-
-static void
-dump_scope(scope_t *scope)
-{
- scope_t *cur_scope;
-
- /*
- * Emit the first patch for this scope
- */
- emit_patch(scope, 0);
-
- /*
- * Dump each scope within this one.
- */
- cur_scope = TAILQ_FIRST(&scope->inner_scope);
-
- while (cur_scope != NULL) {
-
- dump_scope(cur_scope);
-
- cur_scope = TAILQ_NEXT(cur_scope, scope_links);
- }
-
- /*
- * Emit the second, closing, patch for this scope
- */
- emit_patch(scope, 1);
-}
-
-void
-emit_patch(scope_t *scope, int patch)
-{
- patch_info_t *pinfo;
- patch_t *new_patch;
-
- pinfo = &scope->patches[patch];
-
- if (pinfo->skip_instr == 0)
- /* No-Op patch */
- return;
-
- new_patch = (patch_t *)malloc(sizeof(*new_patch));
-
- if (new_patch == NULL)
- stop("Could not malloc patch structure", EX_OSERR);
-
- memset(new_patch, 0, sizeof(*new_patch));
-
- if (patch == 0) {
- new_patch->patch_func = scope->func_num;
- new_patch->begin = scope->begin_addr;
- } else {
- new_patch->patch_func = 0;
- new_patch->begin = scope->end_addr;
- }
- new_patch->skip_instr = pinfo->skip_instr;
- new_patch->skip_patch = pinfo->skip_patch;
- STAILQ_INSERT_TAIL(&patches, new_patch, links);
-}
-
-void
-output_listing(FILE *listfile, char *ifilename)
-{
- char buf[1024];
- FILE *ifile;
- struct instruction *cur_instr;
- patch_t *cur_patch;
- symbol_node_t *cur_func;
- int *func_values;
- int instrcount;
- int instrptr;
- int line;
- int func_count;
- int skip_addr;
-
- instrcount = 0;
- instrptr = 0;
- line = 1;
- skip_addr = 0;
- if ((ifile = fopen(ifilename, "r")) == NULL) {
- perror(ifilename);
- stop(NULL, EX_DATAERR);
- }
-
- /*
- * Determine which options to apply to this listing.
- */
- for (func_count = 0, cur_func = SLIST_FIRST(&patch_functions);
- cur_func != NULL;
- cur_func = SLIST_NEXT(cur_func, links))
- func_count++;
-
- if (func_count != 0) {
- func_values = (int *)malloc(func_count * sizeof(int));
-
- if (func_values == NULL)
- stop("Could not malloc", EX_OSERR);
-
- func_values[0] = 0; /* FALSE func */
- func_count--;
-
- /*
- * Ask the user to fill in the return values for
- * the rest of the functions.
- */
-
-
- for (cur_func = SLIST_FIRST(&patch_functions);
- cur_func != NULL && SLIST_NEXT(cur_func, links) != NULL;
- cur_func = SLIST_NEXT(cur_func, links), func_count--) {
- int input;
-
- fprintf(stdout, "\n(%s)\n", cur_func->symbol->name);
- fprintf(stdout,
- "Enter the return value for "
- "this expression[T/F]:");
-
- while (1) {
-
- input = getchar();
- input = toupper(input);
-
- if (input == 'T') {
- func_values[func_count] = 1;
- break;
- } else if (input == 'F') {
- func_values[func_count] = 0;
- break;
- }
- }
- if (isatty(fileno(stdin)) == 0)
- putchar(input);
- }
- fprintf(stdout, "\nThanks!\n");
- }
-
- /* Now output the listing */
- cur_patch = STAILQ_FIRST(&patches);
- for(cur_instr = STAILQ_FIRST(&seq_program);
- cur_instr != NULL;
- cur_instr = STAILQ_NEXT(cur_instr, links), instrcount++) {
-
- if (check_patch(&cur_patch, instrcount,
- &skip_addr, func_values) == 0) {
- /* Don't count this instruction as it is in a patch
- * that was removed.
- */
- continue;
- }
-
- while (line < cur_instr->srcline) {
- fgets(buf, sizeof(buf), ifile);
- fprintf(listfile, "\t\t%s", buf);
- line++;
- }
- fprintf(listfile, "%03x %02x%02x%02x%02x", instrptr,
- cur_instr->format.bytes[0],
- cur_instr->format.bytes[1],
- cur_instr->format.bytes[2],
- cur_instr->format.bytes[3]);
- fgets(buf, sizeof(buf), ifile);
- fprintf(listfile, "\t%s", buf);
- line++;
- instrptr++;
- }
- /* Dump the remainder of the file */
- while(fgets(buf, sizeof(buf), ifile) != NULL)
- fprintf(listfile, "\t\t%s", buf);
-
- fclose(ifile);
-}
-
-static int
-check_patch(patch_t **start_patch, int start_instr,
- int *skip_addr, int *func_vals)
-{
- patch_t *cur_patch;
-
- cur_patch = *start_patch;
-
- while (cur_patch != NULL && start_instr == cur_patch->begin) {
- if (func_vals[cur_patch->patch_func] == 0) {
- int skip;
-
- /* Start rejecting code */
- *skip_addr = start_instr + cur_patch->skip_instr;
- for (skip = cur_patch->skip_patch;
- skip > 0 && cur_patch != NULL;
- skip--)
- cur_patch = STAILQ_NEXT(cur_patch, links);
- } else {
- /* Accepted this patch. Advance to the next
- * one and wait for our intruction pointer to
- * hit this point.
- */
- cur_patch = STAILQ_NEXT(cur_patch, links);
- }
- }
-
- *start_patch = cur_patch;
- if (start_instr < *skip_addr)
- /* Still skipping */
- return (0);
-
- return (1);
-}
-
-/*
- * Print out error information if appropriate, and clean up before
- * terminating the program.
- */
-void
-stop(string, err_code)
- const char *string;
- int err_code;
-{
- if (string != NULL) {
- fprintf(stderr, "%s: ", appname);
- if (yyfilename != NULL) {
- fprintf(stderr, "Stopped at file %s, line %d - ",
- yyfilename, yylineno);
- }
- fprintf(stderr, "%s\n", string);
- }
-
- if (ofile != NULL) {
- fclose(ofile);
- if (err_code != 0) {
- fprintf(stderr, "%s: Removing %s due to error\n",
- appname, ofilename);
- unlink(ofilename);
- }
- }
-
- if (regfile != NULL) {
- fclose(regfile);
- if (err_code != 0) {
- fprintf(stderr, "%s: Removing %s due to error\n",
- appname, regfilename);
- unlink(regfilename);
- }
- }
-
- if (listfile != NULL) {
- fclose(listfile);
- if (err_code != 0) {
- fprintf(stderr, "%s: Removing %s due to error\n",
- appname, listfilename);
- unlink(listfilename);
- }
- }
-
- symlist_free(&patch_functions);
- symtable_close();
-
- exit(err_code);
-}
-
-struct instruction *
-seq_alloc()
-{
- struct instruction *new_instr;
-
- new_instr = (struct instruction *)malloc(sizeof(struct instruction));
- if (new_instr == NULL)
- stop("Unable to malloc instruction object", EX_SOFTWARE);
- memset(new_instr, 0, sizeof(*new_instr));
- STAILQ_INSERT_TAIL(&seq_program, new_instr, links);
- new_instr->srcline = yylineno;
- return new_instr;
-}
-
-scope_t *
-scope_alloc()
-{
- scope_t *new_scope;
-
- new_scope = (scope_t *)malloc(sizeof(scope_t));
- if (new_scope == NULL)
- stop("Unable to malloc scope object", EX_SOFTWARE);
- memset(new_scope, 0, sizeof(*new_scope));
- TAILQ_INIT(&new_scope->inner_scope);
-
- if (SLIST_FIRST(&scope_stack) != NULL) {
- TAILQ_INSERT_TAIL(&SLIST_FIRST(&scope_stack)->inner_scope,
- new_scope, scope_links);
- }
- /* This patch is now the current scope */
- SLIST_INSERT_HEAD(&scope_stack, new_scope, scope_stack_links);
- return new_scope;
-}
-
-void
-process_scope(scope_t *scope)
-{
- /*
- * We are "leaving" this scope. We should now have
- * enough information to process the lists of scopes
- * we encapsulate.
- */
- scope_t *cur_scope;
- u_int skip_patch_count;
- u_int skip_instr_count;
-
- cur_scope = TAILQ_LAST(&scope->inner_scope, scope_tailq);
- skip_patch_count = 0;
- skip_instr_count = 0;
- while (cur_scope != NULL) {
- u_int patch0_patch_skip;
-
- patch0_patch_skip = 0;
- switch (cur_scope->type) {
- case SCOPE_IF:
- case SCOPE_ELSE_IF:
- if (skip_instr_count != 0) {
- /* Create a tail patch */
- patch0_patch_skip++;
- cur_scope->patches[1].skip_patch =
- skip_patch_count + 1;
- cur_scope->patches[1].skip_instr =
- skip_instr_count;
- }
-
- /* Count Head patch */
- patch0_patch_skip++;
-
- /* Count any patches contained in our inner scope */
- patch0_patch_skip += cur_scope->inner_scope_patches;
-
- cur_scope->patches[0].skip_patch = patch0_patch_skip;
- cur_scope->patches[0].skip_instr =
- cur_scope->end_addr - cur_scope->begin_addr;
-
- skip_instr_count += cur_scope->patches[0].skip_instr;
-
- skip_patch_count += patch0_patch_skip;
- if (cur_scope->type == SCOPE_IF) {
- scope->inner_scope_patches += skip_patch_count;
- skip_patch_count = 0;
- skip_instr_count = 0;
- }
- break;
- case SCOPE_ELSE:
- /* Count any patches contained in our innter scope */
- skip_patch_count += cur_scope->inner_scope_patches;
-
- skip_instr_count += cur_scope->end_addr
- - cur_scope->begin_addr;
- break;
- case SCOPE_ROOT:
- stop("Unexpected scope type encountered", EX_SOFTWARE);
- /* NOTREACHED */
- }
-
- cur_scope = TAILQ_PREV(cur_scope, scope_tailq, scope_links);
- }
-}
diff --git a/sys/dev/aic7xxx/aicasm/aicasm.h b/sys/dev/aic7xxx/aicasm/aicasm.h
deleted file mode 100644
index 7e6b4683dfdb..000000000000
--- a/sys/dev/aic7xxx/aicasm/aicasm.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Assembler for the sequencer program downloaded to Aic7xxx SCSI host adapters
- *
- * Copyright (c) 1997 Justin T. Gibbs.
- * 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,
- * without modification.
- * 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 BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/queue.h>
-
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-
-typedef struct path_entry {
- char *directory;
- int quoted_includes_only;
- SLIST_ENTRY(path_entry) links;
-} *path_entry_t;
-
-typedef enum {
- QUOTED_INCLUDE,
- BRACKETED_INCLUDE,
- SOURCE_FILE
-} include_type;
-
-SLIST_HEAD(path_list, path_entry);
-
-extern struct path_list search_path;
-extern struct scope_list scope_stack;
-extern struct symlist patch_functions;
-extern int includes_search_curdir; /* False if we've seen -I- */
-extern char *appname;
-extern int yylineno;
-extern char *yyfilename;
-
-void stop(const char *errstring, int err_code);
-void include_file(char *file_name, include_type type);
-struct instruction *seq_alloc(void);
-struct scope *scope_alloc(void);
-void process_scope(struct scope *);
diff --git a/sys/dev/aic7xxx/aicasm/aicasm_gram.y b/sys/dev/aic7xxx/aicasm/aicasm_gram.y
deleted file mode 100644
index 4d090598e4fa..000000000000
--- a/sys/dev/aic7xxx/aicasm/aicasm_gram.y
+++ /dev/null
@@ -1,1410 +0,0 @@
-%{
-/*
- * Parser for the Aic7xxx SCSI Host adapter sequencer assembler.
- *
- * Copyright (c) 1997-1998 Justin T. Gibbs.
- * 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,
- * without modification.
- * 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 BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sysexits.h>
-
-#include <sys/types.h>
-#include <sys/queue.h>
-
-#include "aicasm.h"
-#include "aicasm_symbol.h"
-#include "sequencer.h"
-
-int yylineno;
-char *yyfilename;
-static symbol_t *cur_symbol;
-static symtype cur_symtype;
-static symbol_t *accumulator;
-static symbol_ref_t allones;
-static symbol_ref_t allzeros;
-static symbol_ref_t none;
-static symbol_ref_t sindex;
-static int instruction_ptr;
-static int sram_or_scb_offset;
-static int download_constant_count;
-
-static void process_bitmask __P((int mask_type, symbol_t *sym, int mask));
-static void initialize_symbol __P((symbol_t *symbol));
-static void process_register __P((symbol_t **p_symbol));
-static void format_1_instr __P((int opcode, symbol_ref_t *dest,
- expression_t *immed, symbol_ref_t *src,
- int ret));
-static void format_2_instr __P((int opcode, symbol_ref_t *dest,
- expression_t *places, symbol_ref_t *src,
- int ret));
-static void format_3_instr __P((int opcode, symbol_ref_t *src,
- expression_t *immed, symbol_ref_t *address));
-static void test_readable_symbol __P((symbol_t *symbol));
-static void test_writable_symbol __P((symbol_t *symbol));
-static void type_check __P((symbol_t *symbol, expression_t *expression,
- int and_op));
-static void make_expression __P((expression_t *immed, int value));
-static void add_conditional __P((symbol_t *symbol));
-static int is_download_const __P((expression_t *immed));
-
-#define YYDEBUG 1
-#define SRAM_SYMNAME "SRAM_BASE"
-#define SCB_SYMNAME "SCB_BASE"
-%}
-
-%union {
- int value;
- char *str;
- symbol_t *sym;
- symbol_ref_t sym_ref;
- expression_t expression;
-}
-
-%token T_REGISTER
-
-%token <value> T_CONST
-
-%token T_DOWNLOAD
-
-%token T_SCB
-
-%token T_SRAM
-
-%token T_ALIAS
-
-%token T_SIZE
-
-%token <value> T_ADDRESS
-
-%token T_ACCESS_MODE
-
-%token <value> T_MODE
-
-%token T_BIT
-
-%token T_MASK
-
-%token <value> T_NUMBER
-
-%token <str> T_PATH
-
-%token <sym> T_CEXPR
-
-%token T_EOF T_INCLUDE
-
-%token <value> T_SHR T_SHL T_ROR T_ROL
-
-%token <value> T_MVI T_MOV T_CLR T_BMOV
-
-%token <value> T_JMP T_JC T_JNC T_JE T_JNE T_JNZ T_JZ T_CALL
-
-%token <value> T_ADD T_ADC
-
-%token <value> T_INC T_DEC
-
-%token <value> T_STC T_CLC
-
-%token <value> T_CMP T_XOR
-
-%token <value> T_TEST T_AND
-
-%token <value> T_OR
-
-%token T_RET
-
-%token T_NOP
-
-%token T_ACCUM T_ALLONES T_ALLZEROS T_NONE T_SINDEX
-
-%token T_A
-
-%token <sym> T_SYMBOL
-
-%token T_NL
-
-%token T_IF T_ELSE T_ELSE_IF T_ENDIF
-
-%type <sym_ref> reg_symbol address destination source opt_source
-
-%type <expression> expression immediate immediate_or_a
-
-%type <value> ret f1_opcode f2_opcode jmp_jc_jnc_call jz_jnz je_jne
-
-%type <value> numerical_value
-
-%left '|'
-%left '&'
-%left '+' '-'
-%right '~'
-%nonassoc UMINUS
-%%
-
-program:
- include
-| program include
-| register
-| program register
-| constant
-| program constant
-| scratch_ram
-| program scratch_ram
-| scb
-| program scb
-| label
-| program label
-| conditional
-| program conditional
-| code
-| program code
-;
-
-include:
- T_INCLUDE '<' T_PATH '>'
- { include_file($3, BRACKETED_INCLUDE); }
-| T_INCLUDE '"' T_PATH '"'
- { include_file($3, QUOTED_INCLUDE); }
-;
-
-register:
- T_REGISTER { cur_symtype = REGISTER; } reg_definition
-;
-
-reg_definition:
- T_SYMBOL '{'
- {
- if ($1->type != UNINITIALIZED) {
- stop("Register multiply defined", EX_DATAERR);
- /* NOTREACHED */
- }
- cur_symbol = $1;
- cur_symbol->type = cur_symtype;
- initialize_symbol(cur_symbol);
- }
- reg_attribute_list
- '}'
- {
- /*
- * Default to allowing everything in for registers
- * with no bit or mask definitions.
- */
- if (cur_symbol->info.rinfo->valid_bitmask == 0)
- cur_symbol->info.rinfo->valid_bitmask = 0xFF;
-
- if (cur_symbol->info.rinfo->size == 0)
- cur_symbol->info.rinfo->size = 1;
-
- /*
- * This might be useful for registers too.
- */
- if (cur_symbol->type != REGISTER) {
- if (cur_symbol->info.rinfo->address == 0)
- cur_symbol->info.rinfo->address =
- sram_or_scb_offset;
- sram_or_scb_offset +=
- cur_symbol->info.rinfo->size;
- }
- cur_symbol = NULL;
- }
-;
-
-reg_attribute_list:
- reg_attribute
-| reg_attribute_list reg_attribute
-;
-
-reg_attribute:
- reg_address
-| size
-| access_mode
-| bit_defn
-| mask_defn
-| alias
-| accumulator
-| allones
-| allzeros
-| none
-| sindex
-;
-
-reg_address:
- T_ADDRESS T_NUMBER
- {
- cur_symbol->info.rinfo->address = $2;
- }
-;
-
-size:
- T_SIZE T_NUMBER
- {
- cur_symbol->info.rinfo->size = $2;
- }
-;
-
-access_mode:
- T_ACCESS_MODE T_MODE
- {
- cur_symbol->info.rinfo->mode = $2;
- }
-;
-
-bit_defn:
- T_BIT T_SYMBOL T_NUMBER
- {
- process_bitmask(BIT, $2, $3);
- }
-;
-
-mask_defn:
- T_MASK T_SYMBOL expression
- {
- process_bitmask(MASK, $2, $3.value);
- }
-;
-
-alias:
- T_ALIAS T_SYMBOL
- {
- if ($2->type != UNINITIALIZED) {
- stop("Re-definition of register alias",
- EX_DATAERR);
- /* NOTREACHED */
- }
- $2->type = ALIAS;
- initialize_symbol($2);
- $2->info.ainfo->parent = cur_symbol;
- }
-;
-
-accumulator:
- T_ACCUM
- {
- if (accumulator != NULL) {
- stop("Only one accumulator definition allowed",
- EX_DATAERR);
- /* NOTREACHED */
- }
- accumulator = cur_symbol;
- }
-;
-
-allones:
- T_ALLONES
- {
- if (allones.symbol != NULL) {
- stop("Only one definition of allones allowed",
- EX_DATAERR);
- /* NOTREACHED */
- }
- allones.symbol = cur_symbol;
- }
-;
-
-allzeros:
- T_ALLZEROS
- {
- if (allzeros.symbol != NULL) {
- stop("Only one definition of allzeros allowed",
- EX_DATAERR);
- /* NOTREACHED */
- }
- allzeros.symbol = cur_symbol;
- }
-;
-
-none:
- T_NONE
- {
- if (none.symbol != NULL) {
- stop("Only one definition of none allowed",
- EX_DATAERR);
- /* NOTREACHED */
- }
- none.symbol = cur_symbol;
- }
-;
-
-sindex:
- T_SINDEX
- {
- if (sindex.symbol != NULL) {
- stop("Only one definition of sindex allowed",
- EX_DATAERR);
- /* NOTREACHED */
- }
- sindex.symbol = cur_symbol;
- }
-;
-
-expression:
- expression '|' expression
- {
- $$.value = $1.value | $3.value;
- symlist_merge(&$$.referenced_syms,
- &$1.referenced_syms,
- &$3.referenced_syms);
- }
-| expression '&' expression
- {
- $$.value = $1.value & $3.value;
- symlist_merge(&$$.referenced_syms,
- &$1.referenced_syms,
- &$3.referenced_syms);
- }
-| expression '+' expression
- {
- $$.value = $1.value + $3.value;
- symlist_merge(&$$.referenced_syms,
- &$1.referenced_syms,
- &$3.referenced_syms);
- }
-| expression '-' expression
- {
- $$.value = $1.value - $3.value;
- symlist_merge(&($$.referenced_syms),
- &($1.referenced_syms),
- &($3.referenced_syms));
- }
-| '(' expression ')'
- {
- $$ = $2;
- }
-| '~' expression
- {
- $$ = $2;
- $$.value = (~$$.value) & 0xFF;
- }
-| '-' expression %prec UMINUS
- {
- $$ = $2;
- $$.value = -$$.value;
- }
-| T_NUMBER
- {
- $$.value = $1;
- SLIST_INIT(&$$.referenced_syms);
- }
-| T_SYMBOL
- {
- symbol_t *symbol;
-
- symbol = $1;
- switch (symbol->type) {
- case ALIAS:
- symbol = $1->info.ainfo->parent;
- case REGISTER:
- case SCBLOC:
- case SRAMLOC:
- $$.value = symbol->info.rinfo->address;
- break;
- case MASK:
- case BIT:
- $$.value = symbol->info.minfo->mask;
- break;
- case DOWNLOAD_CONST:
- case CONST:
- $$.value = symbol->info.cinfo->value;
- break;
- case UNINITIALIZED:
- default:
- {
- char buf[255];
-
- snprintf(buf, sizeof(buf),
- "Undefined symbol %s referenced",
- symbol->name);
- stop(buf, EX_DATAERR);
- /* NOTREACHED */
- break;
- }
- }
- SLIST_INIT(&$$.referenced_syms);
- symlist_add(&$$.referenced_syms, symbol, SYMLIST_INSERT_HEAD);
- }
-;
-
-constant:
- T_CONST T_SYMBOL numerical_value
- {
- if ($2->type != UNINITIALIZED) {
- stop("Re-definition of symbol as a constant",
- EX_DATAERR);
- /* NOTREACHED */
- }
- $2->type = CONST;
- initialize_symbol($2);
- $2->info.cinfo->value = $3;
- $2->info.cinfo->define = $1;
- }
-| T_CONST T_SYMBOL T_DOWNLOAD
- {
- if ($1) {
- stop("Invalid downloaded constant declaration",
- EX_DATAERR);
- /* NOTREACHED */
- }
- if ($2->type != UNINITIALIZED) {
- stop("Re-definition of symbol as a downloaded constant",
- EX_DATAERR);
- /* NOTREACHED */
- }
- $2->type = DOWNLOAD_CONST;
- initialize_symbol($2);
- $2->info.cinfo->value = download_constant_count++;
- $2->info.cinfo->define = FALSE;
- }
-;
-
-numerical_value:
- T_NUMBER
- {
- $$ = $1;
- }
-| '-' T_NUMBER
- {
- $$ = -$2;
- }
-;
-
-scratch_ram:
- T_SRAM '{'
- {
- cur_symbol = symtable_get(SRAM_SYMNAME);
- cur_symtype = SRAMLOC;
- if (cur_symbol->type != UNINITIALIZED) {
- stop("Only one SRAM definition allowed",
- EX_DATAERR);
- /* NOTREACHED */
- }
- cur_symbol->type = SRAMLOC;
- initialize_symbol(cur_symbol);
- }
- reg_address
- {
- sram_or_scb_offset = cur_symbol->info.rinfo->address;
- }
- scb_or_sram_reg_list
- '}'
- {
- cur_symbol = NULL;
- }
-;
-
-scb:
- T_SCB '{'
- {
- cur_symbol = symtable_get(SCB_SYMNAME);
- cur_symtype = SCBLOC;
- if (cur_symbol->type != UNINITIALIZED) {
- stop("Only one SRAM definition allowed",
- EX_SOFTWARE);
- /* NOTREACHED */
- }
- cur_symbol->type = SCBLOC;
- initialize_symbol(cur_symbol);
- }
- reg_address
- {
- sram_or_scb_offset = cur_symbol->info.rinfo->address;
- }
- scb_or_sram_reg_list
- '}'
- {
- cur_symbol = NULL;
- }
-;
-
-scb_or_sram_reg_list:
- reg_definition
-| scb_or_sram_reg_list reg_definition
-;
-
-reg_symbol:
- T_SYMBOL
- {
- process_register(&$1);
- $$.symbol = $1;
- $$.offset = 0;
- }
-| T_SYMBOL '[' T_NUMBER ']'
- {
- process_register(&$1);
- if (($3 + 1) > $1->info.rinfo->size) {
- stop("Accessing offset beyond range of register",
- EX_DATAERR);
- /* NOTREACHED */
- }
- $$.symbol = $1;
- $$.offset = $3;
- }
-| T_A
- {
- if (accumulator == NULL) {
- stop("No accumulator has been defined", EX_DATAERR);
- /* NOTREACHED */
- }
- $$.symbol = accumulator;
- $$.offset = 0;
- }
-;
-
-destination:
- reg_symbol
- {
- test_writable_symbol($1.symbol);
- $$ = $1;
- }
-;
-
-immediate:
- expression
- { $$ = $1; }
-;
-
-immediate_or_a:
- expression
- {
- $$ = $1;
- }
-| T_A
- {
- SLIST_INIT(&$$.referenced_syms);
- $$.value = 0;
- }
-;
-
-source:
- reg_symbol
- {
- test_readable_symbol($1.symbol);
- $$ = $1;
- }
-;
-
-opt_source:
- {
- $$.symbol = NULL;
- $$.offset = 0;
- }
-| ',' source
- { $$ = $2; }
-;
-
-ret:
- { $$ = 0; }
-| T_RET
- { $$ = 1; }
-;
-
-label:
- T_SYMBOL ':'
- {
- if ($1->type != UNINITIALIZED) {
- stop("Program label multiply defined", EX_DATAERR);
- /* NOTREACHED */
- }
- $1->type = LABEL;
- initialize_symbol($1);
- $1->info.linfo->address = instruction_ptr;
- }
-;
-
-address:
- T_SYMBOL
- {
- $$.symbol = $1;
- $$.offset = 0;
- }
-| T_SYMBOL '+' T_NUMBER
- {
- $$.symbol = $1;
- $$.offset = $3;
- }
-| T_SYMBOL '-' T_NUMBER
- {
- $$.symbol = $1;
- $$.offset = -$3;
- }
-| '.'
- {
- $$.symbol = NULL;
- $$.offset = 0;
- }
-| '.' '+' T_NUMBER
- {
- $$.symbol = NULL;
- $$.offset = $3;
- }
-| '.' '-' T_NUMBER
- {
- $$.symbol = NULL;
- $$.offset = -$3;
- }
-;
-
-conditional:
- T_IF T_CEXPR '{'
- {
- scope_t *new_scope;
-
- add_conditional($2);
- new_scope = scope_alloc();
- new_scope->type = SCOPE_IF;
- new_scope->begin_addr = instruction_ptr;
- new_scope->func_num = $2->info.condinfo->func_num;
- }
-| T_ELSE T_IF T_CEXPR '{'
- {
- scope_t *new_scope;
- scope_t *scope_context;
- scope_t *last_scope;
-
- /*
- * Ensure that the previous scope is either an
- * if or and else if.
- */
- scope_context = SLIST_FIRST(&scope_stack);
- last_scope = TAILQ_LAST(&scope_context->inner_scope,
- scope_tailq);
- if (last_scope == NULL
- || last_scope->type == T_ELSE) {
-
- stop("'else if' without leading 'if'", EX_DATAERR);
- /* NOTREACHED */
- }
- add_conditional($3);
- new_scope = scope_alloc();
- new_scope->type = SCOPE_ELSE_IF;
- new_scope->begin_addr = instruction_ptr;
- new_scope->func_num = $3->info.condinfo->func_num;
- }
-| T_ELSE '{'
- {
- scope_t *new_scope;
- scope_t *scope_context;
- scope_t *last_scope;
-
- /*
- * Ensure that the previous scope is either an
- * if or and else if.
- */
- scope_context = SLIST_FIRST(&scope_stack);
- last_scope = TAILQ_LAST(&scope_context->inner_scope,
- scope_tailq);
- if (last_scope == NULL
- || last_scope->type == SCOPE_ELSE) {
-
- stop("'else' without leading 'if'", EX_DATAERR);
- /* NOTREACHED */
- }
- new_scope = scope_alloc();
- new_scope->type = SCOPE_ELSE;
- new_scope->begin_addr = instruction_ptr;
- }
-;
-
-conditional:
- '}'
- {
- scope_t *scope_context;
- scope_t *last_scope;
-
- scope_context = SLIST_FIRST(&scope_stack);
- if (scope_context->type == SCOPE_ROOT) {
- stop("Unexpected '}' encountered", EX_DATAERR);
- /* NOTREACHED */
- }
-
- scope_context->end_addr = instruction_ptr;
-
- /* Pop the scope */
- SLIST_REMOVE_HEAD(&scope_stack, scope_stack_links);
-
- process_scope(scope_context);
-
- if (SLIST_FIRST(&scope_stack) == NULL) {
- stop("Unexpected '}' encountered", EX_DATAERR);
- /* NOTREACHED */
- }
- }
-;
-
-f1_opcode:
- T_AND { $$ = AIC_OP_AND; }
-| T_XOR { $$ = AIC_OP_XOR; }
-| T_ADD { $$ = AIC_OP_ADD; }
-| T_ADC { $$ = AIC_OP_ADC; }
-;
-
-code:
- f1_opcode destination ',' immediate_or_a opt_source ret ';'
- {
- format_1_instr($1, &$2, &$4, &$5, $6);
- }
-;
-
-code:
- T_OR reg_symbol ',' immediate_or_a opt_source ret ';'
- {
- format_1_instr(AIC_OP_OR, &$2, &$4, &$5, $6);
- }
-;
-
-code:
- T_INC destination opt_source ret ';'
- {
- expression_t immed;
-
- make_expression(&immed, 1);
- format_1_instr(AIC_OP_ADD, &$2, &immed, &$3, $4);
- }
-;
-
-code:
- T_DEC destination opt_source ret ';'
- {
- expression_t immed;
-
- make_expression(&immed, -1);
- format_1_instr(AIC_OP_ADD, &$2, &immed, &$3, $4);
- }
-;
-
-code:
- T_CLC ret ';'
- {
- expression_t immed;
-
- make_expression(&immed, -1);
- format_1_instr(AIC_OP_ADD, &none, &immed, &allzeros, $2);
- }
-| T_CLC T_MVI destination ',' immediate_or_a ret ';'
- {
- format_1_instr(AIC_OP_ADD, &$3, &$5, &allzeros, $6);
- }
-;
-
-code:
- T_STC ret ';'
- {
- expression_t immed;
-
- make_expression(&immed, 1);
- format_1_instr(AIC_OP_ADD, &none, &immed, &allones, $2);
- }
-| T_STC destination ret ';'
- {
- expression_t immed;
-
- make_expression(&immed, 1);
- format_1_instr(AIC_OP_ADD, &$2, &immed, &allones, $3);
- }
-;
-
-code:
- T_BMOV destination ',' source ',' immediate ret ';'
- {
- format_1_instr(AIC_OP_BMOV, &$2, &$6, &$4, $7);
- }
-;
-
-code:
- T_MOV destination ',' source ret ';'
- {
- expression_t immed;
-
- make_expression(&immed, 0xff);
- format_1_instr(AIC_OP_AND, &$2, &immed, &$4, $5);
- }
-;
-
-code:
- T_MVI destination ',' immediate_or_a ret ';'
- {
- format_1_instr(AIC_OP_OR, &$2, &$4, &allzeros, $5);
- }
-;
-
-code:
- T_CLR destination ret ';'
- {
- expression_t immed;
-
- make_expression(&immed, 0xff);
- format_1_instr(AIC_OP_AND, &$2, &immed, &allzeros, $3);
- }
-;
-
-code:
- T_NOP ret ';'
- {
- expression_t immed;
-
- make_expression(&immed, 0xff);
- format_1_instr(AIC_OP_AND, &none, &immed, &allzeros, $2);
- }
-;
-
-code:
- T_RET ';'
- {
- expression_t immed;
-
- make_expression(&immed, 0xff);
- format_1_instr(AIC_OP_AND, &none, &immed, &allzeros, TRUE);
- }
-;
-
- /*
- * This grammer differs from the one in the aic7xxx
- * reference manual since the grammer listed there is
- * ambiguous and causes a shift/reduce conflict.
- * It also seems more logical as the "immediate"
- * argument is listed as the second arg like the
- * other formats.
- */
-
-f2_opcode:
- T_SHL { $$ = AIC_OP_SHL; }
-| T_SHR { $$ = AIC_OP_SHR; }
-| T_ROL { $$ = AIC_OP_ROL; }
-| T_ROR { $$ = AIC_OP_ROR; }
-;
-
-code:
- f2_opcode destination ',' expression opt_source ret ';'
- {
- format_2_instr($1, &$2, &$4, &$5, $6);
- }
-;
-
-jmp_jc_jnc_call:
- T_JMP { $$ = AIC_OP_JMP; }
-| T_JC { $$ = AIC_OP_JC; }
-| T_JNC { $$ = AIC_OP_JNC; }
-| T_CALL { $$ = AIC_OP_CALL; }
-;
-
-jz_jnz:
- T_JZ { $$ = AIC_OP_JZ; }
-| T_JNZ { $$ = AIC_OP_JNZ; }
-;
-
-je_jne:
- T_JE { $$ = AIC_OP_JE; }
-| T_JNE { $$ = AIC_OP_JNE; }
-;
-
-code:
- jmp_jc_jnc_call address ';'
- {
- expression_t immed;
-
- make_expression(&immed, 0);
- format_3_instr($1, &sindex, &immed, &$2);
- }
-;
-
-code:
- T_OR reg_symbol ',' immediate jmp_jc_jnc_call address ';'
- {
- format_3_instr($5, &$2, &$4, &$6);
- }
-;
-
-code:
- T_TEST source ',' immediate_or_a jz_jnz address ';'
- {
- format_3_instr($5, &$2, &$4, &$6);
- }
-;
-
-code:
- T_CMP source ',' immediate_or_a je_jne address ';'
- {
- format_3_instr($5, &$2, &$4, &$6);
- }
-;
-
-code:
- T_MOV source jmp_jc_jnc_call address ';'
- {
- expression_t immed;
-
- make_expression(&immed, 0);
- format_3_instr($3, &$2, &immed, &$4);
- }
-;
-
-code:
- T_MVI immediate jmp_jc_jnc_call address ';'
- {
- format_3_instr($3, &allzeros, &$2, &$4);
- }
-;
-
-%%
-
-static void
-process_bitmask(mask_type, sym, mask)
- int mask_type;
- symbol_t *sym;
- int mask;
-{
- /*
- * Add the current register to its
- * symbol list, if it already exists,
- * warn if we are setting it to a
- * different value, or in the bit to
- * the "allowed bits" of this register.
- */
- if (sym->type == UNINITIALIZED) {
- sym->type = mask_type;
- initialize_symbol(sym);
- if (mask_type == BIT) {
- if (mask == 0) {
- stop("Bitmask with no bits set", EX_DATAERR);
- /* NOTREACHED */
- }
- if ((mask & ~(0x01 << (ffs(mask) - 1))) != 0) {
- stop("Bitmask with more than one bit set",
- EX_DATAERR);
- /* NOTREACHED */
- }
- }
- sym->info.minfo->mask = mask;
- } else if (sym->type != mask_type) {
- stop("Bit definition mirrors a definition of the same "
- " name, but a different type", EX_DATAERR);
- /* NOTREACHED */
- } else if (mask != sym->info.minfo->mask) {
- stop("Bitmask redefined with a conflicting value", EX_DATAERR);
- /* NOTREACHED */
- }
- /* Fail if this symbol is already listed */
- if (symlist_search(&(sym->info.minfo->symrefs),
- cur_symbol->name) != NULL) {
- stop("Bitmask defined multiple times for register", EX_DATAERR);
- /* NOTREACHED */
- }
- symlist_add(&(sym->info.minfo->symrefs), cur_symbol,
- SYMLIST_INSERT_HEAD);
- cur_symbol->info.rinfo->valid_bitmask |= mask;
- cur_symbol->info.rinfo->typecheck_masks = TRUE;
-}
-
-static void
-initialize_symbol(symbol)
- symbol_t *symbol;
-{
- switch (symbol->type) {
- case UNINITIALIZED:
- stop("Call to initialize_symbol with type field unset",
- EX_SOFTWARE);
- /* NOTREACHED */
- break;
- case REGISTER:
- case SRAMLOC:
- case SCBLOC:
- symbol->info.rinfo =
- (struct reg_info *)malloc(sizeof(struct reg_info));
- if (symbol->info.rinfo == NULL) {
- stop("Can't create register info", EX_SOFTWARE);
- /* NOTREACHED */
- }
- memset(symbol->info.rinfo, 0,
- sizeof(struct reg_info));
- break;
- case ALIAS:
- symbol->info.ainfo =
- (struct alias_info *)malloc(sizeof(struct alias_info));
- if (symbol->info.ainfo == NULL) {
- stop("Can't create alias info", EX_SOFTWARE);
- /* NOTREACHED */
- }
- memset(symbol->info.ainfo, 0,
- sizeof(struct alias_info));
- break;
- case MASK:
- case BIT:
- symbol->info.minfo =
- (struct mask_info *)malloc(sizeof(struct mask_info));
- if (symbol->info.minfo == NULL) {
- stop("Can't create bitmask info", EX_SOFTWARE);
- /* NOTREACHED */
- }
- memset(symbol->info.minfo, 0, sizeof(struct mask_info));
- SLIST_INIT(&(symbol->info.minfo->symrefs));
- break;
- case CONST:
- case DOWNLOAD_CONST:
- symbol->info.cinfo =
- (struct const_info *)malloc(sizeof(struct const_info));
- if (symbol->info.cinfo == NULL) {
- stop("Can't create alias info", EX_SOFTWARE);
- /* NOTREACHED */
- }
- memset(symbol->info.cinfo, 0,
- sizeof(struct const_info));
- break;
- case LABEL:
- symbol->info.linfo =
- (struct label_info *)malloc(sizeof(struct label_info));
- if (symbol->info.linfo == NULL) {
- stop("Can't create label info", EX_SOFTWARE);
- /* NOTREACHED */
- }
- memset(symbol->info.linfo, 0,
- sizeof(struct label_info));
- break;
- case CONDITIONAL:
- symbol->info.condinfo =
- (struct cond_info *)malloc(sizeof(struct cond_info));
- if (symbol->info.condinfo == NULL) {
- stop("Can't create conditional info", EX_SOFTWARE);
- /* NOTREACHED */
- }
- memset(symbol->info.condinfo, 0,
- sizeof(struct cond_info));
- break;
- default:
- stop("Call to initialize_symbol with invalid symbol type",
- EX_SOFTWARE);
- /* NOTREACHED */
- break;
- }
-}
-
-static void
-process_register(p_symbol)
- symbol_t **p_symbol;
-{
- char buf[255];
- symbol_t *symbol = *p_symbol;
-
- if (symbol->type == UNINITIALIZED) {
- snprintf(buf, sizeof(buf), "Undefined register %s",
- symbol->name);
- stop(buf, EX_DATAERR);
- /* NOTREACHED */
- } else if (symbol->type == ALIAS) {
- *p_symbol = symbol->info.ainfo->parent;
- } else if ((symbol->type != REGISTER)
- && (symbol->type != SCBLOC)
- && (symbol->type != SRAMLOC)) {
- snprintf(buf, sizeof(buf),
- "Specified symbol %s is not a register",
- symbol->name);
- stop(buf, EX_DATAERR);
- }
-}
-
-static void
-format_1_instr(opcode, dest, immed, src, ret)
- int opcode;
- symbol_ref_t *dest;
- expression_t *immed;
- symbol_ref_t *src;
- int ret;
-{
- struct instruction *instr;
- struct ins_format1 *f1_instr;
-
- if (src->symbol == NULL)
- src = dest;
-
- /* Test register permissions */
- test_writable_symbol(dest->symbol);
- test_readable_symbol(src->symbol);
-
- /* Ensure that immediate makes sense for this destination */
- type_check(dest->symbol, immed, opcode);
-
- /* Allocate sequencer space for the instruction and fill it out */
- instr = seq_alloc();
- f1_instr = &instr->format.format1;
- f1_instr->ret = ret ? 1 : 0;
- f1_instr->opcode = opcode;
- f1_instr->destination = dest->symbol->info.rinfo->address
- + dest->offset;
- f1_instr->source = src->symbol->info.rinfo->address
- + src->offset;
- f1_instr->immediate = immed->value;
-
- if (is_download_const(immed))
- f1_instr->parity = 1;
-
- symlist_free(&immed->referenced_syms);
- instruction_ptr++;
-}
-
-static void
-format_2_instr(opcode, dest, places, src, ret)
- int opcode;
- symbol_ref_t *dest;
- expression_t *places;
- symbol_ref_t *src;
- int ret;
-{
- struct instruction *instr;
- struct ins_format2 *f2_instr;
- u_int8_t shift_control;
-
- if (src->symbol == NULL)
- src = dest;
-
- /* Test register permissions */
- test_writable_symbol(dest->symbol);
- test_readable_symbol(src->symbol);
-
- /* Allocate sequencer space for the instruction and fill it out */
- instr = seq_alloc();
- f2_instr = &instr->format.format2;
- f2_instr->ret = ret ? 1 : 0;
- f2_instr->opcode = AIC_OP_ROL;
- f2_instr->destination = dest->symbol->info.rinfo->address
- + dest->offset;
- f2_instr->source = src->symbol->info.rinfo->address
- + src->offset;
- if (places->value > 8 || places->value <= 0) {
- stop("illegal shift value", EX_DATAERR);
- /* NOTREACHED */
- }
- switch (opcode) {
- case AIC_OP_SHL:
- if (places->value == 8)
- shift_control = 0xf0;
- else
- shift_control = (places->value << 4) | places->value;
- break;
- case AIC_OP_SHR:
- if (places->value == 8) {
- shift_control = 0xf8;
- } else {
- shift_control = (places->value << 4)
- | (8 - places->value)
- | 0x08;
- }
- break;
- case AIC_OP_ROL:
- shift_control = places->value & 0x7;
- break;
- case AIC_OP_ROR:
- shift_control = (8 - places->value) | 0x08;
- break;
- default:
- shift_control = 0; /* Quiet Compiler */
- stop("Invalid shift operation specified", EX_SOFTWARE);
- /* NOTREACHED */
- break;
- };
- f2_instr->shift_control = shift_control;
- symlist_free(&places->referenced_syms);
- instruction_ptr++;
-}
-
-static void
-format_3_instr(opcode, src, immed, address)
- int opcode;
- symbol_ref_t *src;
- expression_t *immed;
- symbol_ref_t *address;
-{
- struct instruction *instr;
- struct ins_format3 *f3_instr;
- int addr;
-
- /* Test register permissions */
- test_readable_symbol(src->symbol);
-
- /* Ensure that immediate makes sense for this source */
- type_check(src->symbol, immed, opcode);
-
- /* Allocate sequencer space for the instruction and fill it out */
- instr = seq_alloc();
- f3_instr = &instr->format.format3;
- if (address->symbol == NULL) {
- /* 'dot' referrence. Use the current instruction pointer */
- addr = instruction_ptr + address->offset;
- } else if (address->symbol->type == UNINITIALIZED) {
- /* forward reference */
- addr = address->offset;
- instr->patch_label = address->symbol;
- } else
- addr = address->symbol->info.linfo->address + address->offset;
- f3_instr->opcode = opcode;
- f3_instr->address = addr;
- f3_instr->source = src->symbol->info.rinfo->address
- + src->offset;
- f3_instr->immediate = immed->value;
-
- if (is_download_const(immed))
- f3_instr->parity = 1;
-
- symlist_free(&immed->referenced_syms);
- instruction_ptr++;
-}
-
-static void
-test_readable_symbol(symbol)
- symbol_t *symbol;
-{
- if (symbol->info.rinfo->mode == WO) {
- stop("Write Only register specified as source",
- EX_DATAERR);
- /* NOTREACHED */
- }
-}
-
-static void
-test_writable_symbol(symbol)
- symbol_t *symbol;
-{
- if (symbol->info.rinfo->mode == RO) {
- stop("Read Only register specified as destination",
- EX_DATAERR);
- /* NOTREACHED */
- }
-}
-
-static void
-type_check(symbol, expression, opcode)
- symbol_t *symbol;
- expression_t *expression;
- int opcode;
-{
- symbol_node_t *node;
- int and_op;
- char buf[255];
-
- and_op = FALSE;
- if (opcode == AIC_OP_AND || opcode == AIC_OP_JNZ || AIC_OP_JZ)
- and_op = TRUE;
-
- /*
- * Make sure that we aren't attempting to write something
- * that hasn't been defined. If this is an and operation,
- * this is a mask, so "undefined" bits are okay.
- */
- if (and_op == FALSE
- && (expression->value & ~symbol->info.rinfo->valid_bitmask) != 0) {
- snprintf(buf, sizeof(buf),
- "Invalid bit(s) 0x%x in immediate written to %s",
- expression->value & ~symbol->info.rinfo->valid_bitmask,
- symbol->name);
- stop(buf, EX_DATAERR);
- /* NOTREACHED */
- }
-
- /*
- * Now make sure that all of the symbols referenced by the
- * expression are defined for this register.
- */
- if(symbol->info.rinfo->typecheck_masks != FALSE) {
- for(node = expression->referenced_syms.slh_first;
- node != NULL;
- node = node->links.sle_next) {
- if ((node->symbol->type == MASK
- || node->symbol->type == BIT)
- && symlist_search(&node->symbol->info.minfo->symrefs,
- symbol->name) == NULL) {
- snprintf(buf, sizeof(buf),
- "Invalid bit or mask %s "
- "for register %s",
- node->symbol->name, symbol->name);
- stop(buf, EX_DATAERR);
- /* NOTREACHED */
- }
- }
- }
-}
-
-static void
-make_expression(immed, value)
- expression_t *immed;
- int value;
-{
- SLIST_INIT(&immed->referenced_syms);
- immed->value = value & 0xff;
-}
-
-static void
-add_conditional(symbol)
- symbol_t *symbol;
-{
- static int numfuncs;
-
- if (numfuncs == 0) {
- /* add a special conditional, "0" */
- symbol_t *false_func;
-
- false_func = symtable_get("0");
- if (false_func->type != UNINITIALIZED) {
- stop("Conditional expression '0' "
- "conflicts with a symbol", EX_DATAERR);
- /* NOTREACHED */
- }
- false_func->type = CONDITIONAL;
- initialize_symbol(false_func);
- false_func->info.condinfo->func_num = numfuncs++;
- symlist_add(&patch_functions, false_func, SYMLIST_INSERT_HEAD);
- }
-
- /* This condition has occurred before */
- if (symbol->type == CONDITIONAL)
- return;
-
- if (symbol->type != UNINITIALIZED) {
- stop("Conditional expression conflicts with a symbol",
- EX_DATAERR);
- /* NOTREACHED */
- }
-
- symbol->type = CONDITIONAL;
- initialize_symbol(symbol);
- symbol->info.condinfo->func_num = numfuncs++;
- symlist_add(&patch_functions, symbol, SYMLIST_INSERT_HEAD);
-}
-
-void
-yyerror(string)
- const char *string;
-{
- stop(string, EX_DATAERR);
-}
-
-static int
-is_download_const(immed)
- expression_t *immed;
-{
- if ((immed->referenced_syms.slh_first != NULL)
- && (immed->referenced_syms.slh_first->symbol->type == DOWNLOAD_CONST))
- return (TRUE);
-
- return (FALSE);
-}
diff --git a/sys/dev/aic7xxx/aicasm/aicasm_scan.l b/sys/dev/aic7xxx/aicasm/aicasm_scan.l
deleted file mode 100644
index 28689cbd4996..000000000000
--- a/sys/dev/aic7xxx/aicasm/aicasm_scan.l
+++ /dev/null
@@ -1,283 +0,0 @@
-%{
-/*
- * Lexical Analyzer for the Aic7xxx SCSI Host adapter sequencer assembler.
- *
- * Copyright (c) 1997-1998 Justin T. Gibbs.
- * 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,
- * without modification.
- * 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 BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/types.h>
-
-#include <limits.h>
-#include <stdio.h>
-#include <string.h>
-#include <sysexits.h>
-#include <sys/queue.h>
-
-#include "aicasm.h"
-#include "aicasm_symbol.h"
-#include "y.tab.h"
-
-#define MAX_STR_CONST 256
-char string_buf[MAX_STR_CONST];
-char *string_buf_ptr;
-int parren_count;
-%}
-
-PATH [-/A-Za-z0-9_.]*[./][-/A-Za-z0-9_.]*
-WORD [A-Za-z_][-A-Za-z_0-9]*
-SPACE [ \t]+
-
-%x COMMENT
-%x CEXPR
-%x INCLUDE
-
-%%
-\n { ++yylineno; }
-"/*" { BEGIN COMMENT; /* Enter comment eating state */ }
-<COMMENT>"/*" { fprintf(stderr, "Warning! Comment within comment."); }
-<COMMENT>\n { ++yylineno; }
-<COMMENT>[^*/\n]* ;
-<COMMENT>"*"+[^*/\n]* ;
-<COMMENT>"/"+[^*/\n]* ;
-<COMMENT>"*"+"/" { BEGIN INITIAL; }
-if[ \t]*\( {
- string_buf_ptr = string_buf;
- parren_count = 1;
- BEGIN CEXPR;
- return T_IF;
- }
-<CEXPR>\( { *string_buf_ptr++ = '('; parren_count++; }
-<CEXPR>\) {
- parren_count--;
- if (parren_count == 0) {
- /* All done */
- BEGIN INITIAL;
- *string_buf_ptr = '\0';
- yylval.sym = symtable_get(string_buf);
- return T_CEXPR;
- } else {
- *string_buf_ptr++ = ')';
- }
- }
-<CEXPR>\n { ++yylineno; }
-<CEXPR>[^()\n]+ {
- char *yptr = yytext;
-
- while (*yptr != '\0')
- *string_buf_ptr++ = *yptr++;
- }
-
-{SPACE} ;
-
- /* Register/SCB/SRAM definition keywords */
-register { return T_REGISTER; }
-const { yylval.value = FALSE; return T_CONST; }
-download { return T_DOWNLOAD; }
-address { return T_ADDRESS; }
-access_mode { return T_ACCESS_MODE; }
-RW|RO|WO {
- if (strcmp(yytext, "RW") == 0)
- yylval.value = RW;
- else if (strcmp(yytext, "RO") == 0)
- yylval.value = RO;
- else
- yylval.value = WO;
- return T_MODE;
- }
-bit { return T_BIT; }
-mask { return T_MASK; }
-alias { return T_ALIAS; }
-size { return T_SIZE; }
-scb { return T_SCB; }
-scratch_ram { return T_SRAM; }
-accumulator { return T_ACCUM; }
-allones { return T_ALLONES; }
-allzeros { return T_ALLZEROS; }
-none { return T_NONE; }
-sindex { return T_SINDEX; }
-A { return T_A; }
-
- /* Opcodes */
-shl { return T_SHL; }
-shr { return T_SHR; }
-ror { return T_ROR; }
-rol { return T_ROL; }
-mvi { return T_MVI; }
-mov { return T_MOV; }
-clr { return T_CLR; }
-jmp { return T_JMP; }
-jc { return T_JC; }
-jnc { return T_JNC; }
-je { return T_JE; }
-jne { return T_JNE; }
-jz { return T_JZ; }
-jnz { return T_JNZ; }
-call { return T_CALL; }
-add { return T_ADD; }
-adc { return T_ADC; }
-bmov { return T_BMOV; }
-inc { return T_INC; }
-dec { return T_DEC; }
-stc { return T_STC; }
-clc { return T_CLC; }
-cmp { return T_CMP; }
-xor { return T_XOR; }
-test { return T_TEST;}
-and { return T_AND; }
-or { return T_OR; }
-ret { return T_RET; }
-nop { return T_NOP; }
-else { return T_ELSE; }
-
- /* Allowed Symbols */
-[-+,:()~|&."{};<>[\]!] { return yytext[0]; }
-
- /* Number processing */
-0[0-7]* {
- yylval.value = strtol(yytext, NULL, 8);
- return T_NUMBER;
- }
-
-0[xX][0-9a-fA-F]+ {
- yylval.value = strtoul(yytext + 2, NULL, 16);
- return T_NUMBER;
- }
-
-[1-9][0-9]* {
- yylval.value = strtol(yytext, NULL, 10);
- return T_NUMBER;
- }
-
- /* Include Files */
-#include { return T_INCLUDE; BEGIN INCLUDE;}
-<INCLUDE>[<>\"] { return yytext[0]; }
-<INCLUDE>{PATH} { yylval.str = strdup(yytext); return T_PATH; }
-<INCLUDE>; { BEGIN INITIAL; return yytext[0]; }
-<INCLUDE>. { stop("Invalid include line", EX_DATAERR); }
-
- /* For parsing C include files with #define foo */
-#define { yylval.value = TRUE; return T_CONST; }
- /* Throw away macros */
-#define[^\n]*[()]+[^\n]* ;
-{PATH} { yylval.str = strdup(yytext); return T_PATH; }
-
-{WORD} { yylval.sym = symtable_get(yytext); return T_SYMBOL; }
-
-. {
- char buf[255];
-
- snprintf(buf, sizeof(buf), "Invalid character "
- "'%c'", yytext[0]);
- stop(buf, EX_DATAERR);
- }
-%%
-
-typedef struct include {
- YY_BUFFER_STATE buffer;
- int lineno;
- char *filename;
- SLIST_ENTRY(include) links;
-}include_t;
-
-SLIST_HEAD(, include) include_stack;
-
-void
-include_file(file_name, type)
- char *file_name;
- include_type type;
-{
- FILE *newfile;
- include_t *include;
-
- newfile = NULL;
- /* Try the current directory first */
- if (includes_search_curdir != 0 || type == SOURCE_FILE)
- newfile = fopen(file_name, "r");
-
- if (newfile == NULL && type != SOURCE_FILE) {
- path_entry_t include_dir;
- for (include_dir = search_path.slh_first;
- include_dir != NULL;
- include_dir = include_dir->links.sle_next) {
- char fullname[PATH_MAX];
-
- if ((include_dir->quoted_includes_only == TRUE)
- && (type != QUOTED_INCLUDE))
- continue;
-
- snprintf(fullname, sizeof(fullname),
- "%s/%s", include_dir->directory, file_name);
-
- if ((newfile = fopen(fullname, "r")) != NULL)
- break;
- }
- }
-
- if (newfile == NULL) {
- perror(file_name);
- stop("Unable to open input file", EX_SOFTWARE);
- /* NOTREACHED */
- }
-
- if (type != SOURCE_FILE) {
- include = (include_t *)malloc(sizeof(include_t));
- if (include == NULL) {
- stop("Unable to allocate include stack entry",
- EX_SOFTWARE);
- /* NOTREACHED */
- }
- include->buffer = YY_CURRENT_BUFFER;
- include->lineno = yylineno;
- include->filename = yyfilename;
- SLIST_INSERT_HEAD(&include_stack, include, links);
- }
- yy_switch_to_buffer(yy_create_buffer(newfile, YY_BUF_SIZE));
- yylineno = 1;
- yyfilename = strdup(file_name);
-}
-
-int
-yywrap()
-{
- include_t *include;
-
- yy_delete_buffer(YY_CURRENT_BUFFER);
- (void)fclose(yyin);
- if (yyfilename != NULL)
- free(yyfilename);
- yyfilename = NULL;
- include = include_stack.slh_first;
- if (include != NULL) {
- yy_switch_to_buffer(include->buffer);
- yylineno = include->lineno;
- yyfilename = include->filename;
- SLIST_REMOVE_HEAD(&include_stack, links);
- free(include);
- return (0);
- }
- return (1);
-}
diff --git a/sys/dev/aic7xxx/aicasm/aicasm_symbol.c b/sys/dev/aic7xxx/aicasm/aicasm_symbol.c
deleted file mode 100644
index 8c250d2317ec..000000000000
--- a/sys/dev/aic7xxx/aicasm/aicasm_symbol.c
+++ /dev/null
@@ -1,472 +0,0 @@
-/*
- * Aic7xxx SCSI host adapter firmware asssembler symbol table implementation
- *
- * Copyright (c) 1997 Justin T. Gibbs.
- * 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,
- * without modification.
- * 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 BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-
-#include <sys/types.h>
-
-#include <db.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sysexits.h>
-
-#include "aicasm_symbol.h"
-#include "aicasm.h"
-
-static DB *symtable;
-
-symbol_t *
-symbol_create(name)
- char *name;
-{
- symbol_t *new_symbol;
-
- new_symbol = (symbol_t *)malloc(sizeof(symbol_t));
- if (new_symbol == NULL) {
- perror("Unable to create new symbol");
- exit(EX_SOFTWARE);
- }
- memset(new_symbol, 0, sizeof(*new_symbol));
- new_symbol->name = strdup(name);
- new_symbol->type = UNINITIALIZED;
- return (new_symbol);
-}
-
-void
-symbol_delete(symbol)
- symbol_t *symbol;
-{
- if (symtable != NULL) {
- DBT key;
-
- key.data = symbol->name;
- key.size = strlen(symbol->name);
- symtable->del(symtable, &key, /*flags*/0);
- }
- switch(symbol->type) {
- case SCBLOC:
- case SRAMLOC:
- case REGISTER:
- if (symbol->info.rinfo != NULL)
- free(symbol->info.rinfo);
- break;
- case ALIAS:
- if (symbol->info.ainfo != NULL)
- free(symbol->info.ainfo);
- break;
- case MASK:
- case BIT:
- if (symbol->info.minfo != NULL) {
- symlist_free(&symbol->info.minfo->symrefs);
- free(symbol->info.minfo);
- }
- break;
- case DOWNLOAD_CONST:
- case CONST:
- if (symbol->info.cinfo != NULL)
- free(symbol->info.cinfo);
- break;
- case LABEL:
- if (symbol->info.linfo != NULL)
- free(symbol->info.linfo);
- break;
- case UNINITIALIZED:
- default:
- break;
- }
- free(symbol->name);
- free(symbol);
-}
-
-void
-symtable_open()
-{
- symtable = dbopen(/*filename*/NULL,
- O_CREAT | O_NONBLOCK | O_RDWR, /*mode*/0, DB_HASH,
- /*openinfo*/NULL);
-
- if (symtable == NULL) {
- perror("Symbol table creation failed");
- exit(EX_SOFTWARE);
- /* NOTREACHED */
- }
-}
-
-void
-symtable_close()
-{
- if (symtable != NULL) {
- DBT key;
- DBT data;
-
- while (symtable->seq(symtable, &key, &data, R_FIRST) == 0) {
- symbol_t *stored_ptr;
-
- memcpy(&stored_ptr, data.data, sizeof(stored_ptr));
- symbol_delete(stored_ptr);
- }
- symtable->close(symtable);
- }
-}
-
-/*
- * The semantics of get is to return an uninitialized symbol entry
- * if a lookup fails.
- */
-symbol_t *
-symtable_get(name)
- char *name;
-{
- symbol_t *stored_ptr;
- DBT key;
- DBT data;
- int retval;
-
- key.data = (void *)name;
- key.size = strlen(name);
-
- if ((retval = symtable->get(symtable, &key, &data, /*flags*/0)) != 0) {
- if (retval == -1) {
- perror("Symbol table get operation failed");
- exit(EX_SOFTWARE);
- /* NOTREACHED */
- } else if (retval == 1) {
- /* Symbol wasn't found, so create a new one */
- symbol_t *new_symbol;
-
- new_symbol = symbol_create(name);
- data.data = &new_symbol;
- data.size = sizeof(new_symbol);
- if (symtable->put(symtable, &key, &data,
- /*flags*/0) !=0) {
- perror("Symtable put failed");
- exit(EX_SOFTWARE);
- }
- return (new_symbol);
- } else {
- perror("Unexpected return value from db get routine");
- exit(EX_SOFTWARE);
- /* NOTREACHED */
- }
- }
- memcpy(&stored_ptr, data.data, sizeof(stored_ptr));
- return (stored_ptr);
-}
-
-symbol_node_t *
-symlist_search(symlist, symname)
- symlist_t *symlist;
- char *symname;
-{
- symbol_node_t *curnode;
-
- curnode = symlist->slh_first;
- while(curnode != NULL) {
- if (strcmp(symname, curnode->symbol->name) == 0)
- break;
- curnode = curnode->links.sle_next;
- }
- return (curnode);
-}
-
-void
-symlist_add(symlist, symbol, how)
- symlist_t *symlist;
- symbol_t *symbol;
- int how;
-{
- symbol_node_t *newnode;
-
- newnode = (symbol_node_t *)malloc(sizeof(symbol_node_t));
- if (newnode == NULL) {
- stop("symlist_add: Unable to malloc symbol_node", EX_SOFTWARE);
- /* NOTREACHED */
- }
- newnode->symbol = symbol;
- if (how == SYMLIST_SORT) {
- symbol_node_t *curnode;
- int mask;
-
- mask = FALSE;
- switch(symbol->type) {
- case REGISTER:
- case SCBLOC:
- case SRAMLOC:
- break;
- case BIT:
- case MASK:
- mask = TRUE;
- break;
- default:
- stop("symlist_add: Invalid symbol type for sorting",
- EX_SOFTWARE);
- /* NOTREACHED */
- }
-
- curnode = symlist->slh_first;
- if (curnode == NULL
- || (mask && (curnode->symbol->info.minfo->mask >
- newnode->symbol->info.minfo->mask))
- || (!mask && (curnode->symbol->info.rinfo->address >
- newnode->symbol->info.rinfo->address))) {
- SLIST_INSERT_HEAD(symlist, newnode, links);
- return;
- }
-
- while (1) {
- if (curnode->links.sle_next == NULL) {
- SLIST_INSERT_AFTER(curnode, newnode,
- links);
- break;
- } else {
- symbol_t *cursymbol;
-
- cursymbol = curnode->links.sle_next->symbol;
- if ((mask && (cursymbol->info.minfo->mask >
- symbol->info.minfo->mask))
- || (!mask &&(cursymbol->info.rinfo->address >
- symbol->info.rinfo->address))){
- SLIST_INSERT_AFTER(curnode, newnode,
- links);
- break;
- }
- }
- curnode = curnode->links.sle_next;
- }
- } else {
- SLIST_INSERT_HEAD(symlist, newnode, links);
- }
-}
-
-void
-symlist_free(symlist)
- symlist_t *symlist;
-{
- symbol_node_t *node1, *node2;
-
- node1 = symlist->slh_first;
- while (node1 != NULL) {
- node2 = node1->links.sle_next;
- free(node1);
- node1 = node2;
- }
- SLIST_INIT(symlist);
-}
-
-void
-symlist_merge(symlist_dest, symlist_src1, symlist_src2)
- symlist_t *symlist_dest;
- symlist_t *symlist_src1;
- symlist_t *symlist_src2;
-{
- symbol_node_t *node;
-
- *symlist_dest = *symlist_src1;
- while((node = symlist_src2->slh_first) != NULL) {
- SLIST_REMOVE_HEAD(symlist_src2, links);
- SLIST_INSERT_HEAD(symlist_dest, node, links);
- }
-
- /* These are now empty */
- SLIST_INIT(symlist_src1);
- SLIST_INIT(symlist_src2);
-}
-
-void
-symtable_dump(ofile)
- FILE *ofile;
-{
- /*
- * Sort the registers by address with a simple insertion sort.
- * Put bitmasks next to the first register that defines them.
- * Put constants at the end.
- */
- symlist_t registers;
- symlist_t masks;
- symlist_t constants;
- symlist_t download_constants;
- symlist_t aliases;
-
- SLIST_INIT(&registers);
- SLIST_INIT(&masks);
- SLIST_INIT(&constants);
- SLIST_INIT(&download_constants);
- SLIST_INIT(&aliases);
-
- if (symtable != NULL) {
- DBT key;
- DBT data;
- int flag = R_FIRST;
-
- while (symtable->seq(symtable, &key, &data, flag) == 0) {
- symbol_t *cursym;
-
- memcpy(&cursym, data.data, sizeof(cursym));
- switch(cursym->type) {
- case REGISTER:
- case SCBLOC:
- case SRAMLOC:
- symlist_add(&registers, cursym, SYMLIST_SORT);
- break;
- case MASK:
- case BIT:
- symlist_add(&masks, cursym, SYMLIST_SORT);
- break;
- case CONST:
- if (cursym->info.cinfo->define == FALSE) {
- symlist_add(&constants, cursym,
- SYMLIST_INSERT_HEAD);
- }
- break;
- case DOWNLOAD_CONST:
- symlist_add(&download_constants, cursym,
- SYMLIST_INSERT_HEAD);
- break;
- case ALIAS:
- symlist_add(&aliases, cursym,
- SYMLIST_INSERT_HEAD);
- break;
- default:
- break;
- }
- flag = R_NEXT;
- }
-
- /* Put in the masks and bits */
- while (masks.slh_first != NULL) {
- symbol_node_t *curnode;
- symbol_node_t *regnode;
- char *regname;
-
- curnode = masks.slh_first;
- SLIST_REMOVE_HEAD(&masks, links);
-
- regnode =
- curnode->symbol->info.minfo->symrefs.slh_first;
- regname = regnode->symbol->name;
- regnode = symlist_search(&registers, regname);
- SLIST_INSERT_AFTER(regnode, curnode, links);
- }
-
- /* Add the aliases */
- while (aliases.slh_first != NULL) {
- symbol_node_t *curnode;
- symbol_node_t *regnode;
- char *regname;
-
- curnode = aliases.slh_first;
- SLIST_REMOVE_HEAD(&aliases, links);
-
- regname = curnode->symbol->info.ainfo->parent->name;
- regnode = symlist_search(&registers, regname);
- SLIST_INSERT_AFTER(regnode, curnode, links);
- }
-
- /* Output what we have */
- fprintf(ofile,
-"/*
- * DO NOT EDIT - This file is automatically generated.
- */\n");
- while (registers.slh_first != NULL) {
- symbol_node_t *curnode;
- u_int8_t value;
- char *tab_str;
- char *tab_str2;
-
- curnode = registers.slh_first;
- SLIST_REMOVE_HEAD(&registers, links);
- switch(curnode->symbol->type) {
- case REGISTER:
- case SCBLOC:
- case SRAMLOC:
- fprintf(ofile, "\n");
- value = curnode->symbol->info.rinfo->address;
- tab_str = "\t";
- tab_str2 = "\t\t";
- break;
- case ALIAS:
- {
- symbol_t *parent;
-
- parent = curnode->symbol->info.ainfo->parent;
- value = parent->info.rinfo->address;
- tab_str = "\t";
- tab_str2 = "\t\t";
- break;
- }
- case MASK:
- case BIT:
- value = curnode->symbol->info.minfo->mask;
- tab_str = "\t\t";
- tab_str2 = "\t";
- break;
- default:
- value = 0; /* Quiet compiler */
- tab_str = NULL;
- tab_str2 = NULL;
- stop("symtable_dump: Invalid symbol type "
- "encountered", EX_SOFTWARE);
- break;
- }
- fprintf(ofile, "#define%s%-16s%s0x%02x\n",
- tab_str, curnode->symbol->name, tab_str2,
- value);
- free(curnode);
- }
- fprintf(ofile, "\n\n");
-
- while (constants.slh_first != NULL) {
- symbol_node_t *curnode;
-
- curnode = constants.slh_first;
- SLIST_REMOVE_HEAD(&constants, links);
- fprintf(ofile, "#define\t%-8s\t0x%02x\n",
- curnode->symbol->name,
- curnode->symbol->info.cinfo->value);
- free(curnode);
- }
-
-
- fprintf(ofile, "\n\n/* Downloaded Constant Definitions */\n");
-
- while (download_constants.slh_first != NULL) {
- symbol_node_t *curnode;
-
- curnode = download_constants.slh_first;
- SLIST_REMOVE_HEAD(&download_constants, links);
- fprintf(ofile, "#define\t%-8s\t0x%02x\n",
- curnode->symbol->name,
- curnode->symbol->info.cinfo->value);
- free(curnode);
- }
- }
-}
-
diff --git a/sys/dev/aic7xxx/aicasm/aicasm_symbol.h b/sys/dev/aic7xxx/aicasm/aicasm_symbol.h
deleted file mode 100644
index 79809db8e6a5..000000000000
--- a/sys/dev/aic7xxx/aicasm/aicasm_symbol.h
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Aic7xxx SCSI host adapter firmware asssembler symbol table definitions
- *
- * Copyright (c) 1997 Justin T. Gibbs.
- * 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,
- * without modification.
- * 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 BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/queue.h>
-
-typedef enum {
- UNINITIALIZED,
- REGISTER,
- ALIAS,
- SCBLOC,
- SRAMLOC,
- MASK,
- BIT,
- CONST,
- DOWNLOAD_CONST,
- LABEL,
- CONDITIONAL
-}symtype;
-
-typedef enum {
- RO = 0x01,
- WO = 0x02,
- RW = 0x03
-}amode_t;
-
-struct reg_info {
- u_int8_t address;
- int size;
- amode_t mode;
- u_int8_t valid_bitmask;
- int typecheck_masks;
-};
-
-typedef SLIST_HEAD(symlist, symbol_node) symlist_t;
-
-struct mask_info {
- symlist_t symrefs;
- u_int8_t mask;
-};
-
-struct const_info {
- u_int8_t value;
- int define;
-};
-
-struct alias_info {
- struct symbol *parent;
-};
-
-struct label_info {
- int address;
-};
-
-struct cond_info {
- int func_num;
-};
-
-typedef struct expression_info {
- symlist_t referenced_syms;
- int value;
-} expression_t;
-
-typedef struct symbol {
- char *name;
- symtype type;
- union {
- struct reg_info *rinfo;
- struct mask_info *minfo;
- struct const_info *cinfo;
- struct alias_info *ainfo;
- struct label_info *linfo;
- struct cond_info *condinfo;
- }info;
-} symbol_t;
-
-typedef struct symbol_ref {
- symbol_t *symbol;
- int offset;
-} symbol_ref_t;
-
-typedef struct symbol_node {
- SLIST_ENTRY(symbol_node) links;
- symbol_t *symbol;
-}symbol_node_t;
-
-typedef enum {
- SCOPE_ROOT,
- SCOPE_IF,
- SCOPE_ELSE_IF,
- SCOPE_ELSE
-} scope_type;
-
-typedef struct patch_info {
- int skip_patch;
- int skip_instr;
-} patch_info_t;
-
-typedef struct scope {
- SLIST_ENTRY(scope) scope_stack_links;
- TAILQ_ENTRY(scope) scope_links;
- TAILQ_HEAD(, scope) inner_scope;
- scope_type type;
- int inner_scope_patches;
- int begin_addr;
- int end_addr;
- patch_info_t patches[2];
- int func_num;
-} scope_t;
-
-SLIST_HEAD(scope_list, scope);
-TAILQ_HEAD(scope_tailq, scope);
-
-void symbol_delete __P((symbol_t *symbol));
-
-void symtable_open __P((void));
-
-void symtable_close __P((void));
-
-symbol_t *
- symtable_get __P((char *name));
-
-symbol_node_t *
- symlist_search __P((symlist_t *symlist, char *symname));
-
-void
- symlist_add __P((symlist_t *symlist, symbol_t *symbol, int how));
-#define SYMLIST_INSERT_HEAD 0x00
-#define SYMLIST_SORT 0x01
-
-void symlist_free __P((symlist_t *symlist));
-
-void symlist_merge __P((symlist_t *symlist_dest, symlist_t *symlist_src1,
- symlist_t *symlist_src2));
-void symtable_dump __P((FILE *ofile));
diff --git a/sys/dev/amd/amd.c b/sys/dev/amd/amd.c
deleted file mode 100644
index decdfc3c82e0..000000000000
--- a/sys/dev/amd/amd.c
+++ /dev/null
@@ -1,2439 +0,0 @@
-/*
- *********************************************************************
- * FILE NAME : amd.c
- * BY : C.L. Huang (ching@tekram.com.tw)
- * Erich Chen (erich@tekram.com.tw)
- * Description: Device Driver for the amd53c974 PCI Bus Master
- * SCSI Host adapter found on cards such as
- * the Tekram DC-390(T).
- * (C)Copyright 1995-1999 Tekram Technology Co., Ltd.
- *
- * 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.
- *********************************************************************
- * $FreeBSD$
- */
-
-/*
- *********************************************************************
- * HISTORY:
- *
- * REV# DATE NAME DESCRIPTION
- * 1.00 07/02/96 CLH First release for RELEASE-2.1.0
- * 1.01 08/20/96 CLH Update for RELEASE-2.1.5
- * 1.02 11/06/96 CLH Fixed more than 1 LUN scanning
- * 1.03 12/20/96 CLH Modify to support 2.2-ALPHA
- * 1.04 12/26/97 CLH Modify to support RELEASE-2.2.5
- * 1.05 01/01/99 ERICH CHEN Modify to support RELEASE-3.0.x (CAM)
- *********************************************************************
- */
-
-/* #define AMD_DEBUG0 */
-/* #define AMD_DEBUG_SCSI_PHASE */
-
-#include <sys/param.h>
-
-#include <sys/systm.h>
-#include <sys/malloc.h>
-#include <sys/queue.h>
-#include <sys/buf.h>
-#include <sys/kernel.h>
-
-#include <vm/vm.h>
-#include <vm/pmap.h>
-
-#include <pci/pcivar.h>
-#include <pci/pcireg.h>
-
-#include <machine/bus_pio.h>
-#include <machine/bus.h>
-#include <machine/clock.h>
-
-#include <cam/cam.h>
-#include <cam/cam_ccb.h>
-#include <cam/cam_sim.h>
-#include <cam/cam_xpt_sim.h>
-#include <cam/cam_debug.h>
-
-#include <cam/scsi/scsi_all.h>
-#include <cam/scsi/scsi_message.h>
-
-#include <pci/amd.h>
-
-#define PCI_DEVICE_ID_AMD53C974 0x20201022ul
-#define PCI_BASE_ADDR0 0x10
-
-typedef u_int (phase_handler_t)(struct amd_softc *, struct amd_srb *, u_int);
-typedef phase_handler_t *phase_handler_func_t;
-
-static void amd_intr(void *vamd);
-static int amdstart(struct amd_softc *amd, struct amd_srb * pSRB);
-static phase_handler_t amd_NopPhase;
-
-static phase_handler_t amd_DataOutPhase0;
-static phase_handler_t amd_DataInPhase0;
-#define amd_CommandPhase0 amd_NopPhase
-static phase_handler_t amd_StatusPhase0;
-static phase_handler_t amd_MsgOutPhase0;
-static phase_handler_t amd_MsgInPhase0;
-static phase_handler_t amd_DataOutPhase1;
-static phase_handler_t amd_DataInPhase1;
-static phase_handler_t amd_CommandPhase1;
-static phase_handler_t amd_StatusPhase1;
-static phase_handler_t amd_MsgOutPhase1;
-static phase_handler_t amd_MsgInPhase1;
-
-static void amdsetupcommand(struct amd_softc *amd, struct amd_srb *srb);
-static int amdparsemsg(struct amd_softc *amd);
-static int amdhandlemsgreject(struct amd_softc *amd);
-static void amdconstructsdtr(struct amd_softc *amd,
- u_int period, u_int offset);
-static u_int amdfindclockrate(struct amd_softc *amd, u_int *period);
-static int amdsentmsg(struct amd_softc *amd, u_int msgtype, int full);
-
-static void DataIO_Comm(struct amd_softc *amd, struct amd_srb *pSRB, u_int dir);
-static void amd_Disconnect(struct amd_softc *amd);
-static void amd_Reselect(struct amd_softc *amd);
-static void SRBdone(struct amd_softc *amd, struct amd_srb *pSRB);
-static void amd_ScsiRstDetect(struct amd_softc *amd);
-static void amd_ResetSCSIBus(struct amd_softc *amd);
-static void RequestSense(struct amd_softc *amd, struct amd_srb *pSRB);
-static void amd_InvalidCmd(struct amd_softc *amd);
-
-static void amd_timeout(void *arg1);
-static void amd_reset(struct amd_softc *amd);
-static u_int8_t * phystovirt(struct amd_srb *pSRB, u_int32_t xferCnt);
-
-void amd_linkSRB(struct amd_softc *amd);
-static struct amd_softc *
- amd_init(int unit, pcici_t config_id);
-static void amd_load_defaults(struct amd_softc *amd);
-static void amd_load_eeprom_or_defaults(struct amd_softc *amd);
-static int amd_EEpromInDO(struct amd_softc *amd);
-static u_int16_t EEpromGetData1(struct amd_softc *amd);
-static void amd_EnDisableCE(struct amd_softc *amd, int mode, int *regval);
-static void amd_EEpromOutDI(struct amd_softc *amd, int *regval, int Carry);
-static void amd_Prepare(struct amd_softc *amd, int *regval, u_int8_t EEpromCmd);
-static void amd_ReadEEprom(struct amd_softc *amd);
-
-static const char *amd_probe(pcici_t tag, pcidi_t type);
-static void amd_attach(pcici_t tag, int unit);
-static void amdcompletematch(struct amd_softc *amd, target_id_t target,
- lun_id_t lun, u_int tag, struct srb_queue *queue,
- cam_status status);
-static void amdsetsync(struct amd_softc *amd, u_int target, u_int clockrate,
- u_int period, u_int offset, u_int type);
-static void amdsettags(struct amd_softc *amd, u_int target, int tagenb);
-
-static __inline void amd_clear_msg_state(struct amd_softc *amd);
-
-static __inline void
-amd_clear_msg_state(struct amd_softc *amd)
-{
- amd->msgout_len = 0;
- amd->msgout_index = 0;
- amd->msgin_index = 0;
-}
-
-static u_long amd_count;
-
-/* CAM SIM entry points */
-#define ccb_srb_ptr spriv_ptr0
-#define ccb_amd_ptr spriv_ptr1
-static void amd_action(struct cam_sim *sim, union ccb *ccb);
-static void amd_poll(struct cam_sim *sim);
-
-/*
- * PCI device module setup
- */
-static struct pci_device amd_device =
-{
- "amd",
- amd_probe,
- amd_attach,
- &amd_count,
- NULL
-};
-
-#ifdef COMPAT_PCI_DRIVER
-COMPAT_PCI_DRIVER(amd, amd_device);
-#else
-DATA_SET(pcidevice_set, amd_device);
-#endif
-
-/*
- * State engine function tables indexed by SCSI phase number
- */
-phase_handler_func_t amd_SCSI_phase0[] = {
- amd_DataOutPhase0,
- amd_DataInPhase0,
- amd_CommandPhase0,
- amd_StatusPhase0,
- amd_NopPhase,
- amd_NopPhase,
- amd_MsgOutPhase0,
- amd_MsgInPhase0
-};
-
-phase_handler_func_t amd_SCSI_phase1[] = {
- amd_DataOutPhase1,
- amd_DataInPhase1,
- amd_CommandPhase1,
- amd_StatusPhase1,
- amd_NopPhase,
- amd_NopPhase,
- amd_MsgOutPhase1,
- amd_MsgInPhase1
-};
-
-/*
- * EEProm/BIOS negotiation periods
- */
-u_int8_t eeprom_period[] = {
- 25, /* 10.0MHz */
- 32, /* 8.0MHz */
- 38, /* 6.6MHz */
- 44, /* 5.7MHz */
- 50, /* 5.0MHz */
- 63, /* 4.0MHz */
- 83, /* 3.0MHz */
- 125 /* 2.0MHz */
-};
-
-/*
- * chip clock setting to SCSI specified sync parameter table.
- */
-u_int8_t tinfo_sync_period[] = {
- 25, /* 10.0 */
- 32, /* 8.0 */
- 38, /* 6.6 */
- 44, /* 5.7 */
- 50, /* 5.0 */
- 57, /* 4.4 */
- 63, /* 4.0 */
- 70, /* 3.6 */
- 76, /* 3.3 */
- 83 /* 3.0 */
-};
-
-static __inline struct amd_srb *
-amdgetsrb(struct amd_softc * amd)
-{
- int intflag;
- struct amd_srb * pSRB;
-
- intflag = splcam();
- pSRB = TAILQ_FIRST(&amd->free_srbs);
- if (pSRB)
- TAILQ_REMOVE(&amd->free_srbs, pSRB, links);
- splx(intflag);
- return (pSRB);
-}
-
-static void
-amdsetupcommand(struct amd_softc *amd, struct amd_srb *srb)
-{
- struct scsi_request_sense sense_cmd;
- struct ccb_scsiio *csio;
- u_int8_t *cdb;
- u_int cdb_len;
-
- csio = &srb->pccb->csio;
-
- if (srb->SRBFlag & AUTO_REQSENSE) {
- sense_cmd.opcode = REQUEST_SENSE;
- sense_cmd.byte2 = srb->pccb->ccb_h.target_lun << 5;
- sense_cmd.unused[0] = 0;
- sense_cmd.unused[1] = 0;
- sense_cmd.length = csio->sense_len;
- sense_cmd.control = 0;
- cdb = &sense_cmd.opcode;
- cdb_len = sizeof(sense_cmd);
- } else {
- cdb = &srb->CmdBlock[0];
- cdb_len = srb->ScsiCmdLen;
- }
- amd_write8_multi(amd, SCSIFIFOREG, cdb, cdb_len);
-}
-
-/*
- * Attempt to start a waiting transaction. Interrupts must be disabled
- * upon entry to this function.
- */
-static void
-amdrunwaiting(struct amd_softc *amd) {
- struct amd_srb *srb;
-
- if (amd->last_phase != SCSI_BUS_FREE)
- return;
-
- srb = TAILQ_FIRST(&amd->waiting_srbs);
- if (srb == NULL)
- return;
-
- if (amdstart(amd, srb) == 0) {
- TAILQ_REMOVE(&amd->waiting_srbs, srb, links);
- TAILQ_INSERT_HEAD(&amd->running_srbs, srb, links);
- }
-}
-
-static void
-amdexecutesrb(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error)
-{
- struct amd_srb *srb;
- union ccb *ccb;
- struct amd_softc *amd;
- int s;
-
- srb = (struct amd_srb *)arg;
- ccb = srb->pccb;
- amd = (struct amd_softc *)ccb->ccb_h.ccb_amd_ptr;
-
- if (error != 0) {
- if (error != EFBIG)
- printf("amd%d: Unexepected error 0x%x returned from "
- "bus_dmamap_load\n", amd->unit, error);
- if (ccb->ccb_h.status == CAM_REQ_INPROG) {
- xpt_freeze_devq(ccb->ccb_h.path, /*count*/1);
- ccb->ccb_h.status = CAM_REQ_TOO_BIG|CAM_DEV_QFRZN;
- }
- TAILQ_INSERT_HEAD(&amd->free_srbs, srb, links);
- xpt_done(ccb);
- return;
- }
-
- if (nseg != 0) {
- struct amd_sg *sg;
- bus_dma_segment_t *end_seg;
- bus_dmasync_op_t op;
-
- end_seg = dm_segs + nseg;
-
- /* Copy the segments into our SG list */
- srb->pSGlist = &srb->SGsegment[0];
- sg = srb->pSGlist;
- while (dm_segs < end_seg) {
- sg->SGXLen = dm_segs->ds_len;
- sg->SGXPtr = dm_segs->ds_addr;
- sg++;
- dm_segs++;
- }
-
- if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN)
- op = BUS_DMASYNC_PREREAD;
- else
- op = BUS_DMASYNC_PREWRITE;
-
- bus_dmamap_sync(amd->buffer_dmat, srb->dmamap, op);
-
- }
- srb->SGcount = nseg;
- srb->SGIndex = 0;
- srb->AdaptStatus = 0;
- srb->TargetStatus = 0;
- srb->MsgCnt = 0;
- srb->SRBStatus = 0;
- srb->SRBFlag = 0;
- srb->SRBState = 0;
- srb->TotalXferredLen = 0;
- srb->SGPhysAddr = 0;
- srb->SGToBeXferLen = 0;
- srb->EndMessage = 0;
-
- s = splcam();
-
- /*
- * Last time we need to check if this CCB needs to
- * be aborted.
- */
- if (ccb->ccb_h.status != CAM_REQ_INPROG) {
- if (nseg != 0)
- bus_dmamap_unload(amd->buffer_dmat, srb->dmamap);
- TAILQ_INSERT_HEAD(&amd->free_srbs, srb, links);
- xpt_done(ccb);
- splx(s);
- return;
- }
- ccb->ccb_h.status |= CAM_SIM_QUEUED;
-#if 0
- /* XXX Need a timeout handler */
- ccb->ccb_h.timeout_ch =
- timeout(amdtimeout, (caddr_t)srb,
- (ccb->ccb_h.timeout * hz) / 1000);
-#endif
- TAILQ_INSERT_TAIL(&amd->waiting_srbs, srb, links);
- amdrunwaiting(amd);
- splx(s);
-}
-
-static void
-amd_action(struct cam_sim * psim, union ccb * pccb)
-{
- struct amd_softc * amd;
- u_int target_id, target_lun;
-
- CAM_DEBUG(pccb->ccb_h.path, CAM_DEBUG_TRACE, ("amd_action\n"));
-
- amd = (struct amd_softc *) cam_sim_softc(psim);
- target_id = pccb->ccb_h.target_id;
- target_lun = pccb->ccb_h.target_lun;
-
- switch (pccb->ccb_h.func_code) {
- case XPT_SCSI_IO:
- {
- struct amd_srb * pSRB;
- struct ccb_scsiio *pcsio;
-
- pcsio = &pccb->csio;
-
- /*
- * Assign an SRB and connect it with this ccb.
- */
- pSRB = amdgetsrb(amd);
-
- if (!pSRB) {
- /* Freeze SIMQ */
- pccb->ccb_h.status = CAM_RESRC_UNAVAIL;
- xpt_done(pccb);
- return;
- }
- pSRB->pccb = pccb;
- pccb->ccb_h.ccb_srb_ptr = pSRB;
- pccb->ccb_h.ccb_amd_ptr = amd;
- pSRB->ScsiCmdLen = pcsio->cdb_len;
- bcopy(pcsio->cdb_io.cdb_bytes, pSRB->CmdBlock, pcsio->cdb_len);
- if ((pccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
- if ((pccb->ccb_h.flags & CAM_SCATTER_VALID) == 0) {
- /*
- * We've been given a pointer
- * to a single buffer.
- */
- if ((pccb->ccb_h.flags & CAM_DATA_PHYS) == 0) {
- int s;
- int error;
-
- s = splsoftvm();
- error =
- bus_dmamap_load(amd->buffer_dmat,
- pSRB->dmamap,
- pcsio->data_ptr,
- pcsio->dxfer_len,
- amdexecutesrb,
- pSRB, /*flags*/0);
- if (error == EINPROGRESS) {
- /*
- * So as to maintain
- * ordering, freeze the
- * controller queue
- * until our mapping is
- * returned.
- */
- xpt_freeze_simq(amd->psim, 1);
- pccb->ccb_h.status |=
- CAM_RELEASE_SIMQ;
- }
- splx(s);
- } else {
- struct bus_dma_segment seg;
-
- /* Pointer to physical buffer */
- seg.ds_addr =
- (bus_addr_t)pcsio->data_ptr;
- seg.ds_len = pcsio->dxfer_len;
- amdexecutesrb(pSRB, &seg, 1, 0);
- }
- } else {
- struct bus_dma_segment *segs;
-
- if ((pccb->ccb_h.flags & CAM_SG_LIST_PHYS) == 0
- || (pccb->ccb_h.flags & CAM_DATA_PHYS) != 0) {
- TAILQ_INSERT_HEAD(&amd->free_srbs,
- pSRB, links);
- pccb->ccb_h.status = CAM_PROVIDE_FAIL;
- xpt_done(pccb);
- return;
- }
-
- /* Just use the segments provided */
- segs =
- (struct bus_dma_segment *)pcsio->data_ptr;
- amdexecutesrb(pSRB, segs, pcsio->sglist_cnt, 0);
- }
- } else
- amdexecutesrb(pSRB, NULL, 0, 0);
- break;
- }
- case XPT_PATH_INQ:
- {
- struct ccb_pathinq *cpi = &pccb->cpi;
-
- cpi->version_num = 1;
- cpi->hba_inquiry = PI_SDTR_ABLE | PI_TAG_ABLE;
- cpi->target_sprt = 0;
- cpi->hba_misc = 0;
- cpi->hba_eng_cnt = 0;
- cpi->max_target = 7;
- cpi->max_lun = amd->max_lun; /* 7 or 0 */
- cpi->initiator_id = amd->AdaptSCSIID;
- cpi->bus_id = cam_sim_bus(psim);
- strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN);
- strncpy(cpi->hba_vid, "TRM-AMD", HBA_IDLEN);
- strncpy(cpi->dev_name, cam_sim_name(psim), DEV_IDLEN);
- cpi->unit_number = cam_sim_unit(psim);
- cpi->ccb_h.status = CAM_REQ_CMP;
- xpt_done(pccb);
- break;
- }
- case XPT_ABORT:
- pccb->ccb_h.status = CAM_REQ_INVALID;
- xpt_done(pccb);
- break;
- case XPT_RESET_BUS:
- {
-
- int i;
-
- amd_ResetSCSIBus(amd);
- amd->ACBFlag = 0;
-
- for (i = 0; i < 500; i++) {
- DELAY(1000); /* Wait until our interrupt
- * handler sees it */
- }
-
- pccb->ccb_h.status = CAM_REQ_CMP;
- xpt_done(pccb);
- break;
- }
- case XPT_RESET_DEV:
- pccb->ccb_h.status = CAM_REQ_INVALID;
- xpt_done(pccb);
- break;
- case XPT_TERM_IO:
- pccb->ccb_h.status = CAM_REQ_INVALID;
- xpt_done(pccb);
- case XPT_GET_TRAN_SETTINGS:
- {
- struct ccb_trans_settings *cts;
- struct amd_target_info *targ_info;
- struct amd_transinfo *tinfo;
- int intflag;
-
- cts = &pccb->cts;
- intflag = splcam();
- targ_info = &amd->tinfo[target_id];
- if ((cts->flags & CCB_TRANS_CURRENT_SETTINGS) != 0) {
- /* current transfer settings */
- if (targ_info->disc_tag & AMD_CUR_DISCENB) {
- cts->flags = CCB_TRANS_DISC_ENB;
- } else {
- cts->flags = 0; /* no tag & disconnect */
- }
- if (targ_info->disc_tag & AMD_CUR_TAGENB) {
- cts->flags |= CCB_TRANS_TAG_ENB;
- }
- tinfo = &targ_info->current;
- } else {
- /* default(user) transfer settings */
- if (targ_info->disc_tag & AMD_USR_DISCENB) {
- cts->flags = CCB_TRANS_DISC_ENB;
- } else {
- cts->flags = 0;
- }
- if (targ_info->disc_tag & AMD_USR_TAGENB) {
- cts->flags |= CCB_TRANS_TAG_ENB;
- }
- tinfo = &targ_info->user;
- }
-
- cts->sync_period = tinfo->period;
- cts->sync_offset = tinfo->offset;
- cts->bus_width = MSG_EXT_WDTR_BUS_8_BIT;
- splx(intflag);
- cts->valid = CCB_TRANS_SYNC_RATE_VALID
- | CCB_TRANS_SYNC_OFFSET_VALID
- | CCB_TRANS_BUS_WIDTH_VALID
- | CCB_TRANS_DISC_VALID
- | CCB_TRANS_TQ_VALID;
- pccb->ccb_h.status = CAM_REQ_CMP;
- xpt_done(pccb);
- break;
- }
- case XPT_SET_TRAN_SETTINGS:
- {
- struct ccb_trans_settings *cts;
- struct amd_target_info *targ_info;
- u_int update_type;
- int intflag;
- int last_entry;
-
- cts = &pccb->cts;
- update_type = 0;
- if ((cts->flags & CCB_TRANS_CURRENT_SETTINGS) != 0) {
- update_type |= AMD_TRANS_GOAL;
- } else if ((cts->flags & CCB_TRANS_USER_SETTINGS) != 0) {
- update_type |= AMD_TRANS_USER;
- }
- if (update_type == 0
- || update_type == (AMD_TRANS_USER|AMD_TRANS_GOAL)) {
- cts->ccb_h.status = CAM_REQ_INVALID;
- xpt_done(pccb);
- }
-
- intflag = splcam();
- targ_info = &amd->tinfo[target_id];
-
- if ((cts->valid & CCB_TRANS_DISC_VALID) != 0) {
- if (update_type & AMD_TRANS_GOAL) {
- if ((cts->flags & CCB_TRANS_DISC_ENB) != 0) {
- targ_info->disc_tag |= AMD_CUR_DISCENB;
- } else {
- targ_info->disc_tag &= ~AMD_CUR_DISCENB;
- }
- }
- if (update_type & AMD_TRANS_USER) {
- if ((cts->flags & CCB_TRANS_DISC_ENB) != 0) {
- targ_info->disc_tag |= AMD_USR_DISCENB;
- } else {
- targ_info->disc_tag &= ~AMD_USR_DISCENB;
- }
- }
- }
- if ((cts->valid & CCB_TRANS_TQ_VALID) != 0) {
- if (update_type & AMD_TRANS_GOAL) {
- if ((cts->flags & CCB_TRANS_TAG_ENB) != 0) {
- targ_info->disc_tag |= AMD_CUR_TAGENB;
- } else {
- targ_info->disc_tag &= ~AMD_CUR_TAGENB;
- }
- }
- if (update_type & AMD_TRANS_USER) {
- if ((cts->flags & CCB_TRANS_TAG_ENB) != 0) {
- targ_info->disc_tag |= AMD_USR_TAGENB;
- } else {
- targ_info->disc_tag &= ~AMD_USR_TAGENB;
- }
- }
- }
-
- if ((cts->valid & CCB_TRANS_SYNC_OFFSET_VALID) == 0) {
- if (update_type & AMD_TRANS_GOAL)
- cts->sync_offset = targ_info->goal.offset;
- else
- cts->sync_offset = targ_info->user.offset;
- }
-
- if (cts->sync_offset > AMD_MAX_SYNC_OFFSET)
- cts->sync_offset = AMD_MAX_SYNC_OFFSET;
-
- if ((cts->valid & CCB_TRANS_SYNC_RATE_VALID) == 0) {
- if (update_type & AMD_TRANS_GOAL)
- cts->sync_period = targ_info->goal.period;
- else
- cts->sync_period = targ_info->user.period;
- }
-
- last_entry = sizeof(tinfo_sync_period) - 1;
- if ((cts->sync_period != 0)
- && (cts->sync_period < tinfo_sync_period[0]))
- cts->sync_period = tinfo_sync_period[0];
- if (cts->sync_period > tinfo_sync_period[last_entry])
- cts->sync_period = 0;
- if (cts->sync_offset == 0)
- cts->sync_period = 0;
-
- if ((update_type & AMD_TRANS_USER) != 0) {
- targ_info->user.period = cts->sync_period;
- targ_info->user.offset = cts->sync_offset;
- }
- if ((update_type & AMD_TRANS_GOAL) != 0) {
- targ_info->goal.period = cts->sync_period;
- targ_info->goal.offset = cts->sync_offset;
- }
- splx(intflag);
- pccb->ccb_h.status = CAM_REQ_CMP;
- xpt_done(pccb);
- break;
- }
- case XPT_CALC_GEOMETRY:
- {
- struct ccb_calc_geometry *ccg;
- u_int32_t size_mb;
- u_int32_t secs_per_cylinder;
- int extended;
-
- ccg = &pccb->ccg;
- size_mb = ccg->volume_size/((1024L * 1024L)/ccg->block_size);
- extended = (amd->eepromBuf[EE_MODE2] & GREATER_1G) != 0;
-
- if (size_mb > 1024 && extended) {
- ccg->heads = 255;
- ccg->secs_per_track = 63;
- } else {
- ccg->heads = 64;
- ccg->secs_per_track = 32;
- }
- secs_per_cylinder = ccg->heads * ccg->secs_per_track;
- ccg->cylinders = ccg->volume_size / secs_per_cylinder;
- pccb->ccb_h.status = CAM_REQ_CMP;
- xpt_done(pccb);
- break;
- }
- default:
- pccb->ccb_h.status = CAM_REQ_INVALID;
- xpt_done(pccb);
- break;
- }
-}
-
-static void
-amd_poll(struct cam_sim * psim)
-{
- amd_intr(cam_sim_softc(psim));
-}
-
-static u_int8_t *
-phystovirt(struct amd_srb * pSRB, u_int32_t xferCnt)
-{
- int dataPtr;
- struct ccb_scsiio *pcsio;
- u_int8_t i;
- struct amd_sg * pseg;
-
- dataPtr = 0;
- pcsio = &pSRB->pccb->csio;
-
- dataPtr = (int) pcsio->data_ptr;
- pseg = pSRB->SGsegment;
- for (i = 0; i < pSRB->SGIndex; i++) {
- dataPtr += (int) pseg->SGXLen;
- pseg++;
- }
- dataPtr += (int) xferCnt;
- return ((u_int8_t *) dataPtr);
-}
-
-static void
-ResetDevParam(struct amd_softc * amd)
-{
- u_int target;
-
- for (target = 0; target <= amd->max_id; target++) {
- if (amd->AdaptSCSIID != target) {
- amdsetsync(amd, target, /*clockrate*/0,
- /*period*/0, /*offset*/0, AMD_TRANS_CUR);
- }
- }
-}
-
-static void
-amdcompletematch(struct amd_softc *amd, target_id_t target, lun_id_t lun,
- u_int tag, struct srb_queue *queue, cam_status status)
-{
- struct amd_srb *srb;
- struct amd_srb *next_srb;
-
- for (srb = TAILQ_FIRST(queue); srb != NULL; srb = next_srb) {
- union ccb *ccb;
-
- next_srb = TAILQ_NEXT(srb, links);
- if (srb->pccb->ccb_h.target_id != target
- && target != CAM_TARGET_WILDCARD)
- continue;
-
- if (srb->pccb->ccb_h.target_lun != lun
- && lun != CAM_LUN_WILDCARD)
- continue;
-
- if (srb->TagNumber != tag
- && tag != AMD_TAG_WILDCARD)
- continue;
-
- ccb = srb->pccb;
- TAILQ_REMOVE(queue, srb, links);
- TAILQ_INSERT_HEAD(&amd->free_srbs, srb, links);
- if ((ccb->ccb_h.status & CAM_DEV_QFRZN) == 0
- && (status & CAM_DEV_QFRZN) != 0)
- xpt_freeze_devq(ccb->ccb_h.path, /*count*/1);
- ccb->ccb_h.status = status;
- xpt_done(ccb);
- }
-
-}
-
-static void
-amdsetsync(struct amd_softc *amd, u_int target, u_int clockrate,
- u_int period, u_int offset, u_int type)
-{
- struct amd_target_info *tinfo;
- u_int old_period;
- u_int old_offset;
-
- tinfo = &amd->tinfo[target];
- old_period = tinfo->current.period;
- old_offset = tinfo->current.offset;
- if ((type & AMD_TRANS_CUR) != 0
- && (old_period != period || old_offset != offset)) {
- struct cam_path *path;
-
- tinfo->current.period = period;
- tinfo->current.offset = offset;
- tinfo->sync_period_reg = clockrate;
- tinfo->sync_offset_reg = offset;
- tinfo->CtrlR3 &= ~FAST_SCSI;
- tinfo->CtrlR4 &= ~EATER_25NS;
- if (clockrate > 7)
- tinfo->CtrlR4 |= EATER_25NS;
- else
- tinfo->CtrlR3 |= FAST_SCSI;
-
- if ((type & AMD_TRANS_ACTIVE) == AMD_TRANS_ACTIVE) {
- amd_write8(amd, SYNCPERIOREG, tinfo->sync_period_reg);
- amd_write8(amd, SYNCOFFREG, tinfo->sync_offset_reg);
- amd_write8(amd, CNTLREG3, tinfo->CtrlR3);
- amd_write8(amd, CNTLREG4, tinfo->CtrlR4);
- }
- /* If possible, update the XPT's notion of our transfer rate */
- if (xpt_create_path(&path, /*periph*/NULL,
- cam_sim_path(amd->psim), target,
- CAM_LUN_WILDCARD) == CAM_REQ_CMP) {
- struct ccb_trans_settings neg;
-
- xpt_setup_ccb(&neg.ccb_h, path, /*priority*/1);
- neg.sync_period = period;
- neg.sync_offset = offset;
- neg.valid = CCB_TRANS_SYNC_RATE_VALID
- | CCB_TRANS_SYNC_OFFSET_VALID;
- xpt_async(AC_TRANSFER_NEG, path, &neg);
- xpt_free_path(path);
- }
- }
- if ((type & AMD_TRANS_GOAL) != 0) {
- tinfo->goal.period = period;
- tinfo->goal.offset = offset;
- }
-
- if ((type & AMD_TRANS_USER) != 0) {
- tinfo->user.period = period;
- tinfo->user.offset = offset;
- }
-}
-
-static void
-amdsettags(struct amd_softc *amd, u_int target, int tagenb)
-{
- panic("Implement me!\n");
-}
-
-
-/*
- **********************************************************************
- * Function : amd_reset (struct amd_softc * amd)
- * Purpose : perform a hard reset on the SCSI bus( and AMD chip).
- * Inputs : cmd - command which caused the SCSI RESET
- **********************************************************************
- */
-static void
-amd_reset(struct amd_softc * amd)
-{
- int intflag;
- u_int8_t bval;
- u_int16_t i;
-
-
-#ifdef AMD_DEBUG0
- printf("DC390: RESET");
-#endif
-
- intflag = splcam();
- bval = amd_read8(amd, CNTLREG1);
- bval |= DIS_INT_ON_SCSI_RST;
- amd_write8(amd, CNTLREG1, bval); /* disable interrupt */
- amd_ResetSCSIBus(amd);
-
- for (i = 0; i < 500; i++) {
- DELAY(1000);
- }
-
- bval = amd_read8(amd, CNTLREG1);
- bval &= ~DIS_INT_ON_SCSI_RST;
- amd_write8(amd, CNTLREG1, bval); /* re-enable interrupt */
-
- amd_write8(amd, DMA_Cmd, DMA_IDLE_CMD);
- amd_write8(amd, SCSICMDREG, CLEAR_FIFO_CMD);
-
- ResetDevParam(amd);
- amdcompletematch(amd, CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD,
- AMD_TAG_WILDCARD, &amd->running_srbs,
- CAM_DEV_QFRZN|CAM_SCSI_BUS_RESET);
- amdcompletematch(amd, CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD,
- AMD_TAG_WILDCARD, &amd->waiting_srbs,
- CAM_DEV_QFRZN|CAM_SCSI_BUS_RESET);
- amd->active_srb = NULL;
- amd->ACBFlag = 0;
- splx(intflag);
- return;
-}
-
-void
-amd_timeout(void *arg1)
-{
- struct amd_srb * pSRB;
-
- pSRB = (struct amd_srb *) arg1;
-}
-
-static int
-amdstart(struct amd_softc *amd, struct amd_srb *pSRB)
-{
- union ccb *pccb;
- struct ccb_scsiio *pcsio;
- struct amd_target_info *targ_info;
- u_int identify_msg;
- u_int command;
- u_int target;
- u_int lun;
- int tagged;
-
- pccb = pSRB->pccb;
- pcsio = &pccb->csio;
- target = pccb->ccb_h.target_id;
- lun = pccb->ccb_h.target_lun;
- targ_info = &amd->tinfo[target];
-
- amd_clear_msg_state(amd);
- amd_write8(amd, SCSIDESTIDREG, target);
- amd_write8(amd, SYNCPERIOREG, targ_info->sync_period_reg);
- amd_write8(amd, SYNCOFFREG, targ_info->sync_offset_reg);
- amd_write8(amd, CNTLREG1, targ_info->CtrlR1);
- amd_write8(amd, CNTLREG3, targ_info->CtrlR3);
- amd_write8(amd, CNTLREG4, targ_info->CtrlR4);
- amd_write8(amd, SCSICMDREG, CLEAR_FIFO_CMD);
-
- identify_msg = MSG_IDENTIFYFLAG | lun;
- if ((targ_info->disc_tag & AMD_CUR_DISCENB) != 0
- && (pccb->ccb_h.flags & CAM_DIS_DISCONNECT) == 0
- && (pSRB->CmdBlock[0] != REQUEST_SENSE)
- && (pSRB->SRBFlag & AUTO_REQSENSE) == 0)
- identify_msg |= MSG_IDENTIFY_DISCFLAG;
-
- amd_write8(amd, SCSIFIFOREG, identify_msg);
- tagged = 0;
- if ((targ_info->disc_tag & AMD_CUR_TAGENB) == 0
- || (identify_msg & MSG_IDENTIFY_DISCFLAG) == 0)
- pccb->ccb_h.flags &= ~CAM_TAG_ACTION_VALID;
- if (targ_info->current.period != targ_info->goal.period
- || targ_info->current.offset != targ_info->goal.offset) {
- command = SEL_W_ATN_STOP;
- amdconstructsdtr(amd, targ_info->goal.period,
- targ_info->goal.offset);
- } else if ((pccb->ccb_h.flags & CAM_TAG_ACTION_VALID) != 0) {
- command = SEL_W_ATN2;
- pSRB->SRBState = SRB_START;
- amd_write8(amd, SCSIFIFOREG, pcsio->tag_action);
- amd_write8(amd, SCSIFIFOREG, pSRB->TagNumber);
- tagged++;
- } else {
- command = SEL_W_ATN;
- pSRB->SRBState = SRB_START;
- }
- if (command != SEL_W_ATN_STOP)
- amdsetupcommand(amd, pSRB);
-
- if (amd_read8(amd, SCSISTATREG) & INTERRUPT) {
- pSRB->SRBState = SRB_READY;
- return (1);
- } else {
- amd->last_phase = SCSI_ARBITRATING;
- amd_write8(amd, SCSICMDREG, command);
- amd->active_srb = pSRB;
- amd->cur_target = target;
- amd->cur_lun = lun;
- return (0);
- }
-}
-
-/*
- * Catch an interrupt from the adapter.
- * Process pending device interrupts.
- */
-static void
-amd_intr(void *arg)
-{
- struct amd_softc *amd;
- struct amd_srb *pSRB;
- u_int internstat = 0;
- u_int scsistat;
- u_int intstat;
-
- amd = (struct amd_softc *)arg;
-
- if (amd == NULL) {
-#ifdef AMD_DEBUG0
- printf("amd_intr: amd NULL return......");
-#endif
- return;
- }
-
- scsistat = amd_read8(amd, SCSISTATREG);
- if (!(scsistat & INTERRUPT)) {
-#ifdef AMD_DEBUG0
- printf("amd_intr: scsistat = NULL ,return......");
-#endif
- return;
- }
-#ifdef AMD_DEBUG_SCSI_PHASE
- printf("scsistat=%2x,", scsistat);
-#endif
-
- internstat = amd_read8(amd, INTERNSTATREG);
- intstat = amd_read8(amd, INTSTATREG);
-
-#ifdef AMD_DEBUG_SCSI_PHASE
- printf("intstat=%2x,", intstat);
-#endif
-
- if (intstat & DISCONNECTED) {
- amd_Disconnect(amd);
- return;
- }
- if (intstat & RESELECTED) {
- amd_Reselect(amd);
- return;
- }
- if (intstat & INVALID_CMD) {
- amd_InvalidCmd(amd);
- return;
- }
- if (intstat & SCSI_RESET_) {
- amd_ScsiRstDetect(amd);
- return;
- }
- if (intstat & (SUCCESSFUL_OP + SERVICE_REQUEST)) {
- pSRB = amd->active_srb;
- /*
- * Run our state engine. First perform
- * post processing for the last phase we
- * were in, followed by any processing
- * required to handle the current phase.
- */
- scsistat =
- amd_SCSI_phase0[amd->last_phase](amd, pSRB, scsistat);
- amd->last_phase = scsistat & SCSI_PHASE_MASK;
- (void)amd_SCSI_phase1[amd->last_phase](amd, pSRB, scsistat);
- }
-}
-
-static u_int
-amd_DataOutPhase0(struct amd_softc *amd, struct amd_srb *pSRB, u_int scsistat)
-{
- struct amd_sg *psgl;
- u_int32_t ResidCnt, xferCnt;
-
- if (!(pSRB->SRBState & SRB_XFERPAD)) {
- if (scsistat & PARITY_ERR) {
- pSRB->SRBStatus |= PARITY_ERROR;
- }
- if (scsistat & COUNT_2_ZERO) {
- while ((amd_read8(amd, DMA_Status)&DMA_XFER_DONE) == 0)
- ;
- pSRB->TotalXferredLen += pSRB->SGToBeXferLen;
- pSRB->SGIndex++;
- if (pSRB->SGIndex < pSRB->SGcount) {
- pSRB->pSGlist++;
- psgl = pSRB->pSGlist;
- pSRB->SGPhysAddr = psgl->SGXPtr;
- pSRB->SGToBeXferLen = psgl->SGXLen;
- } else {
- pSRB->SGToBeXferLen = 0;
- }
- } else {
- ResidCnt = amd_read8(amd, CURRENTFIFOREG) & 0x1f;
- ResidCnt += amd_read8(amd, CTCREG_LOW)
- | (amd_read8(amd, CTCREG_MID) << 8)
- | (amd_read8(amd, CURTXTCNTREG) << 16);
-
- xferCnt = pSRB->SGToBeXferLen - ResidCnt;
- pSRB->SGPhysAddr += xferCnt;
- pSRB->TotalXferredLen += xferCnt;
- pSRB->SGToBeXferLen = ResidCnt;
- }
- }
- amd_write8(amd, DMA_Cmd, WRITE_DIRECTION | DMA_IDLE_CMD);
- return (scsistat);
-}
-
-static u_int
-amd_DataInPhase0(struct amd_softc *amd, struct amd_srb *pSRB, u_int scsistat)
-{
- u_int8_t bval;
- u_int16_t i, residual;
- struct amd_sg *psgl;
- u_int32_t ResidCnt, xferCnt;
- u_int8_t * ptr;
-
- if (!(pSRB->SRBState & SRB_XFERPAD)) {
- if (scsistat & PARITY_ERR) {
- pSRB->SRBStatus |= PARITY_ERROR;
- }
- if (scsistat & COUNT_2_ZERO) {
- while (1) {
- bval = amd_read8(amd, DMA_Status);
- if ((bval & DMA_XFER_DONE) != 0)
- break;
- }
- amd_write8(amd, DMA_Cmd, READ_DIRECTION|DMA_IDLE_CMD);
-
- pSRB->TotalXferredLen += pSRB->SGToBeXferLen;
- pSRB->SGIndex++;
- if (pSRB->SGIndex < pSRB->SGcount) {
- pSRB->pSGlist++;
- psgl = pSRB->pSGlist;
- pSRB->SGPhysAddr = psgl->SGXPtr;
- pSRB->SGToBeXferLen = psgl->SGXLen;
- } else {
- pSRB->SGToBeXferLen = 0;
- }
- } else { /* phase changed */
- residual = 0;
- bval = amd_read8(amd, CURRENTFIFOREG);
- while (bval & 0x1f) {
- if ((bval & 0x1f) == 1) {
- for (i = 0; i < 0x100; i++) {
- bval = amd_read8(amd, CURRENTFIFOREG);
- if (!(bval & 0x1f)) {
- goto din_1;
- } else if (i == 0x0ff) {
- residual = 1;
- goto din_1;
- }
- }
- } else {
- bval = amd_read8(amd, CURRENTFIFOREG);
- }
- }
- din_1:
- amd_write8(amd, DMA_Cmd, READ_DIRECTION|DMA_BLAST_CMD);
- for (i = 0; i < 0x8000; i++) {
- if ((amd_read8(amd, DMA_Status)&BLAST_COMPLETE))
- break;
- }
- amd_write8(amd, DMA_Cmd, READ_DIRECTION|DMA_IDLE_CMD);
-
- ResidCnt = amd_read8(amd, CTCREG_LOW)
- | (amd_read8(amd, CTCREG_MID) << 8)
- | (amd_read8(amd, CURTXTCNTREG) << 16);
- xferCnt = pSRB->SGToBeXferLen - ResidCnt;
- pSRB->SGPhysAddr += xferCnt;
- pSRB->TotalXferredLen += xferCnt;
- pSRB->SGToBeXferLen = ResidCnt;
- if (residual) {
- /* get residual byte */
- bval = amd_read8(amd, SCSIFIFOREG);
- ptr = phystovirt(pSRB, xferCnt);
- *ptr = bval;
- pSRB->SGPhysAddr++;
- pSRB->TotalXferredLen++;
- pSRB->SGToBeXferLen--;
- }
- }
- }
- return (scsistat);
-}
-
-static u_int
-amd_StatusPhase0(struct amd_softc *amd, struct amd_srb *pSRB, u_int scsistat)
-{
- pSRB->TargetStatus = amd_read8(amd, SCSIFIFOREG);
- /* get message */
- pSRB->EndMessage = amd_read8(amd, SCSIFIFOREG);
- pSRB->SRBState = SRB_COMPLETED;
- amd_write8(amd, SCSICMDREG, MSG_ACCEPTED_CMD);
- return (SCSI_NOP0);
-}
-
-static u_int
-amd_MsgOutPhase0(struct amd_softc *amd, struct amd_srb *pSRB, u_int scsistat)
-{
- if (pSRB->SRBState & (SRB_UNEXPECT_RESEL + SRB_ABORT_SENT)) {
- scsistat = SCSI_NOP0;
- }
- return (scsistat);
-}
-
-static u_int
-amd_MsgInPhase0(struct amd_softc *amd, struct amd_srb *pSRB, u_int scsistat)
-{
- int done;
-
- amd->msgin_buf[amd->msgin_index] = amd_read8(amd, SCSIFIFOREG);
-
- done = amdparsemsg(amd);
- if (done)
- amd->msgin_index = 0;
- else
- amd->msgin_index++;
- return (SCSI_NOP0);
-}
-
-static int
-amdparsemsg(struct amd_softc *amd)
-{
- struct amd_target_info *targ_info;
- int reject;
- int done;
- int response;
-
- done = FALSE;
- response = FALSE;
- reject = FALSE;
-
- targ_info = &amd->tinfo[amd->cur_target];
-
- /*
- * Parse as much of the message as is availible,
- * rejecting it if we don't support it. When
- * the entire message is availible and has been
- * handled, return TRUE indicating that we have
- * parsed an entire message.
- */
- switch (amd->msgin_buf[0]) {
- case MSG_DISCONNECT:
- amd->active_srb->SRBState = SRB_DISCONNECT;
- amd->disc_count[amd->cur_target][amd->cur_lun]++;
- done = TRUE;
- break;
- case MSG_SIMPLE_Q_TAG:
- {
- struct amd_srb *disc_srb;
-
- if (amd->msgin_index < 1)
- break;
- disc_srb = &amd->SRB_array[amd->msgin_buf[1]];
- if (amd->active_srb != NULL
- || disc_srb->SRBState != SRB_DISCONNECT
- || disc_srb->pccb->ccb_h.target_id != amd->cur_target
- || disc_srb->pccb->ccb_h.target_lun != amd->cur_lun) {
- printf("amd%d: Unexpected tagged reselection "
- "for target %d, Issuing Abort\n", amd->unit,
- amd->cur_target);
- amd->msgout_buf[0] = MSG_ABORT;
- amd->msgout_len = 1;
- response = TRUE;
- break;
- }
- amd->active_srb = disc_srb;
- amd->disc_count[amd->cur_target][amd->cur_lun]--;
- done = TRUE;
- break;
- }
- case MSG_MESSAGE_REJECT:
- response = amdhandlemsgreject(amd);
- if (response == FALSE)
- amd_write8(amd, SCSICMDREG, RESET_ATN_CMD);
- /* FALLTHROUGH */
- case MSG_NOOP:
- done = TRUE;
- break;
- case MSG_EXTENDED:
- {
- u_int clockrate;
- u_int period;
- u_int offset;
- u_int saved_offset;
-
- /* Wait for enough of the message to begin validation */
- if (amd->msgin_index < 1)
- break;
- if (amd->msgin_buf[1] != MSG_EXT_SDTR_LEN) {
- reject = TRUE;
- break;
- }
-
- /* Wait for opcode */
- if (amd->msgin_index < 2)
- break;
-
- if (amd->msgin_buf[2] != MSG_EXT_SDTR) {
- reject = TRUE;
- break;
- }
-
- /*
- * Wait until we have both args before validating
- * and acting on this message.
- *
- * Add one to MSG_EXT_SDTR_LEN to account for
- * the extended message preamble.
- */
- if (amd->msgin_index < (MSG_EXT_SDTR_LEN + 1))
- break;
-
- period = amd->msgin_buf[3];
- saved_offset = offset = amd->msgin_buf[4];
- clockrate = amdfindclockrate(amd, &period);
- if (offset > AMD_MAX_SYNC_OFFSET)
- offset = AMD_MAX_SYNC_OFFSET;
- if (period == 0 || offset == 0) {
- offset = 0;
- period = 0;
- clockrate = 0;
- }
- amdsetsync(amd, amd->cur_target, clockrate, period, offset,
- AMD_TRANS_ACTIVE|AMD_TRANS_GOAL);
-
- /*
- * See if we initiated Sync Negotiation
- * and didn't have to fall down to async
- * transfers.
- */
- if (amdsentmsg(amd, MSG_EXT_SDTR, /*full*/TRUE)) {
- /* We started it */
- if (saved_offset != offset) {
- /* Went too low - force async */
- reject = TRUE;
- }
- } else {
- /*
- * Send our own SDTR in reply
- */
- if (bootverbose)
- printf("Sending SDTR!\n");
- amd->msgout_index = 0;
- amd->msgout_len = 0;
- amdconstructsdtr(amd, period, offset);
- amd->msgout_index = 0;
- response = TRUE;
- }
- done = TRUE;
- break;
- }
- case MSG_SAVEDATAPOINTER:
- case MSG_RESTOREPOINTERS:
- /* XXX Implement!!! */
- done = TRUE;
- break;
- default:
- reject = TRUE;
- break;
- }
-
- if (reject) {
- amd->msgout_index = 0;
- amd->msgout_len = 1;
- amd->msgout_buf[0] = MSG_MESSAGE_REJECT;
- done = TRUE;
- response = TRUE;
- }
-
- if (response)
- amd_write8(amd, SCSICMDREG, SET_ATN_CMD);
-
- if (done && !response)
- /* Clear the outgoing message buffer */
- amd->msgout_len = 0;
-
- /* Drop Ack */
- amd_write8(amd, SCSICMDREG, MSG_ACCEPTED_CMD);
-
- return (done);
-}
-
-static u_int
-amdfindclockrate(struct amd_softc *amd, u_int *period)
-{
- u_int i;
- u_int clockrate;
-
- for (i = 0; i < sizeof(tinfo_sync_period); i++) {
- u_int8_t *table_entry;
-
- table_entry = &tinfo_sync_period[i];
- if (*period <= *table_entry) {
- /*
- * When responding to a target that requests
- * sync, the requested rate may fall between
- * two rates that we can output, but still be
- * a rate that we can receive. Because of this,
- * we want to respond to the target with
- * the same rate that it sent to us even
- * if the period we use to send data to it
- * is lower. Only lower the response period
- * if we must.
- */
- if (i == 0) {
- *period = *table_entry;
- }
- break;
- }
- }
-
- if (i == sizeof(tinfo_sync_period)) {
- /* Too slow for us. Use asnyc transfers. */
- *period = 0;
- clockrate = 0;
- } else
- clockrate = i + 4;
-
- return (clockrate);
-}
-
-/*
- * See if we sent a particular extended message to the target.
- * If "full" is true, the target saw the full message.
- * If "full" is false, the target saw at least the first
- * byte of the message.
- */
-static int
-amdsentmsg(struct amd_softc *amd, u_int msgtype, int full)
-{
- int found;
- int index;
-
- found = FALSE;
- index = 0;
-
- while (index < amd->msgout_len) {
- if ((amd->msgout_buf[index] & MSG_IDENTIFYFLAG) != 0
- || amd->msgout_buf[index] == MSG_MESSAGE_REJECT)
- index++;
- else if (amd->msgout_buf[index] >= MSG_SIMPLE_Q_TAG
- && amd->msgout_buf[index] < MSG_IGN_WIDE_RESIDUE) {
- /* Skip tag type and tag id */
- index += 2;
- } else if (amd->msgout_buf[index] == MSG_EXTENDED) {
- /* Found a candidate */
- if (amd->msgout_buf[index+2] == msgtype) {
- u_int end_index;
-
- end_index = index + 1
- + amd->msgout_buf[index + 1];
- if (full) {
- if (amd->msgout_index > end_index)
- found = TRUE;
- } else if (amd->msgout_index > index)
- found = TRUE;
- }
- break;
- } else {
- panic("amdsentmsg: Inconsistent msg buffer");
- }
- }
- return (found);
-}
-
-static void
-amdconstructsdtr(struct amd_softc *amd, u_int period, u_int offset)
-{
- amd->msgout_buf[amd->msgout_index++] = MSG_EXTENDED;
- amd->msgout_buf[amd->msgout_index++] = MSG_EXT_SDTR_LEN;
- amd->msgout_buf[amd->msgout_index++] = MSG_EXT_SDTR;
- amd->msgout_buf[amd->msgout_index++] = period;
- amd->msgout_buf[amd->msgout_index++] = offset;
- amd->msgout_len += 5;
-}
-
-static int
-amdhandlemsgreject(struct amd_softc *amd)
-{
- /*
- * If we had an outstanding SDTR for this
- * target, this is a signal that the target
- * is refusing negotiation. Also watch out
- * for rejected tag messages.
- */
- struct amd_srb *srb;
- struct amd_target_info *targ_info;
- int response = FALSE;
-
- srb = amd->active_srb;
- targ_info = &amd->tinfo[amd->cur_target];
- if (amdsentmsg(amd, MSG_EXT_SDTR, /*full*/FALSE)) {
- /* note asynch xfers and clear flag */
- amdsetsync(amd, amd->cur_target, /*clockrate*/0,
- /*period*/0, /*offset*/0,
- AMD_TRANS_ACTIVE|AMD_TRANS_GOAL);
- printf("amd%d:%d: refuses synchronous negotiation. "
- "Using asynchronous transfers\n",
- amd->unit, amd->cur_target);
- } else if ((srb != NULL)
- && (srb->pccb->ccb_h.flags & CAM_TAG_ACTION_VALID) != 0) {
- struct ccb_trans_settings neg;
-
- printf("amd%d:%d: refuses tagged commands. Performing "
- "non-tagged I/O\n", amd->unit, amd->cur_target);
-
- amdsettags(amd, amd->cur_target, FALSE);
- neg.flags = 0;
- neg.valid = CCB_TRANS_TQ_VALID;
- xpt_setup_ccb(&neg.ccb_h, srb->pccb->ccb_h.path, /*priority*/1);
- xpt_async(AC_TRANSFER_NEG, srb->pccb->ccb_h.path, &neg);
-
- /*
- * Resend the identify for this CCB as the target
- * may believe that the selection is invalid otherwise.
- */
- if (amd->msgout_len != 0)
- bcopy(&amd->msgout_buf[0], &amd->msgout_buf[1],
- amd->msgout_len);
- amd->msgout_buf[0] = MSG_IDENTIFYFLAG
- | srb->pccb->ccb_h.target_lun;
- amd->msgout_len++;
- if ((targ_info->disc_tag & AMD_CUR_DISCENB) != 0
- && (srb->pccb->ccb_h.flags & CAM_DIS_DISCONNECT) == 0)
- amd->msgout_buf[0] |= MSG_IDENTIFY_DISCFLAG;
-
- srb->pccb->ccb_h.flags &= ~CAM_TAG_ACTION_VALID;
-
- /*
- * Requeue all tagged commands for this target
- * currently in our posession so they can be
- * converted to untagged commands.
- */
- amdcompletematch(amd, amd->cur_target, amd->cur_lun,
- AMD_TAG_WILDCARD, &amd->waiting_srbs,
- CAM_DEV_QFRZN|CAM_REQUEUE_REQ);
- } else {
- /*
- * Otherwise, we ignore it.
- */
- printf("amd%d:%d: Message reject received -- ignored\n",
- amd->unit, amd->cur_target);
- }
- return (response);
-}
-
-#if 0
- if (!(pSRB->SRBState & SRB_MSGIN_MULTI)) {
- if (bval == MSG_DISCONNECT) {
- pSRB->SRBState = SRB_DISCONNECT;
- } else if (bval == MSG_SAVEDATAPOINTER) {
- goto min6;
- } else if ((bval == MSG_EXTENDED)
- || ((bval >= MSG_SIMPLE_Q_TAG)
- && (bval <= MSG_ORDERED_Q_TAG))) {
- pSRB->SRBState |= SRB_MSGIN_MULTI;
- pSRB->MsgInBuf[0] = bval;
- pSRB->MsgCnt = 1;
- pSRB->pMsgPtr = &pSRB->MsgInBuf[1];
- } else if (bval == MSG_MESSAGE_REJECT) {
- amd_write8(amd, SCSICMDREG, RESET_ATN_CMD);
-
- if (pSRB->SRBState & DO_SYNC_NEGO) {
- goto set_async;
- }
- } else if (bval == MSG_RESTOREPOINTERS) {
- goto min6;
- } else {
- goto min6;
- }
- } else { /* minx: */
- *pSRB->pMsgPtr = bval;
- pSRB->MsgCnt++;
- pSRB->pMsgPtr++;
- if ((pSRB->MsgInBuf[0] >= MSG_SIMPLE_Q_TAG)
- && (pSRB->MsgInBuf[0] <= MSG_ORDERED_Q_TAG)) {
- if (pSRB->MsgCnt == 2) {
- pSRB->SRBState = 0;
- pSRB = &amd->SRB_array[pSRB->MsgInBuf[1]];
- if (pSRB->SRBState & SRB_DISCONNECT) == 0) {
- pSRB = amd->pTmpSRB;
- pSRB->SRBState = SRB_UNEXPECT_RESEL;
- pDCB->pActiveSRB = pSRB;
- pSRB->MsgOutBuf[0] = MSG_ABORT_TAG;
- EnableMsgOut2(amd, pSRB);
- } else {
- if (pDCB->DCBFlag & ABORT_DEV_) {
- pSRB->SRBState = SRB_ABORT_SENT;
- EnableMsgOut1(amd, pSRB);
- }
- pDCB->pActiveSRB = pSRB;
- pSRB->SRBState = SRB_DATA_XFER;
- }
- }
- } else if ((pSRB->MsgInBuf[0] == MSG_EXTENDED)
- && (pSRB->MsgCnt == 5)) {
- pSRB->SRBState &= ~(SRB_MSGIN_MULTI + DO_SYNC_NEGO);
- if ((pSRB->MsgInBuf[1] != 3)
- || (pSRB->MsgInBuf[2] != 1)) { /* reject_msg: */
- pSRB->MsgCnt = 1;
- pSRB->MsgInBuf[0] = MSG_MESSAGE_REJECT;
- amd_write8(amd, SCSICMDREG, SET_ATN_CMD);
- } else if (!(pSRB->MsgInBuf[3])
- || !(pSRB->MsgInBuf[4])) {
- set_async: /* set async */
-
- pDCB = pSRB->pSRBDCB;
- /* disable sync & sync nego */
- pDCB->SyncMode &= ~(SYNC_ENABLE|SYNC_NEGO_DONE);
- pDCB->SyncPeriod = 0;
- pDCB->SyncOffset = 0;
-
- pDCB->tinfo.goal.period = 0;
- pDCB->tinfo.goal.offset = 0;
-
- pDCB->tinfo.current.period = 0;
- pDCB->tinfo.current.offset = 0;
- pDCB->tinfo.current.width =
- MSG_EXT_WDTR_BUS_8_BIT;
-
- pDCB->CtrlR3 = FAST_CLK; /* non_fast */
- pDCB->CtrlR4 &= 0x3f;
- pDCB->CtrlR4 |= EATER_25NS;
- goto re_prog;
- } else {/* set sync */
-
- pDCB = pSRB->pSRBDCB;
- /* enable sync & sync nego */
- pDCB->SyncMode |= SYNC_ENABLE|SYNC_NEGO_DONE;
-
- /* set sync offset */
- pDCB->SyncOffset &= 0x0f0;
- pDCB->SyncOffset |= pSRB->MsgInBuf[4];
-
- /* set sync period */
- pDCB->MaxNegoPeriod = pSRB->MsgInBuf[3];
-
- wval = (u_int16_t) pSRB->MsgInBuf[3];
- wval = wval << 2;
- wval--;
- wval1 = wval / 25;
- if ((wval1 * 25) != wval) {
- wval1++;
- }
- bval = FAST_CLK|FAST_SCSI;
- pDCB->CtrlR4 &= 0x3f;
- if (wval1 >= 8) {
- /* Fast SCSI */
- wval1--;
- bval = FAST_CLK;
- pDCB->CtrlR4 |= EATER_25NS;
- }
- pDCB->CtrlR3 = bval;
- pDCB->SyncPeriod = (u_int8_t) wval1;
-
- pDCB->tinfo.goal.period =
- tinfo_sync_period[pDCB->SyncPeriod - 4];
- pDCB->tinfo.goal.offset = pDCB->SyncOffset;
- pDCB->tinfo.current.period =
- tinfo_sync_period[pDCB->SyncPeriod - 4];;
- pDCB->tinfo.current.offset = pDCB->SyncOffset;
-
- /*
- * program SCSI control register
- */
- re_prog:
- amd_write8(amd, SYNCPERIOREG, pDCB->SyncPeriod);
- amd_write8(amd, SYNCOFFREG, pDCB->SyncOffset);
- amd_write8(amd, CNTLREG3, pDCB->CtrlR3);
- amd_write8(amd, CNTLREG4, pDCB->CtrlR4);
- }
- }
- }
-min6:
- amd_write8(amd, SCSICMDREG, MSG_ACCEPTED_CMD);
- return (SCSI_NOP0);
-}
-#endif
-
-static u_int
-amd_DataOutPhase1(struct amd_softc *amd, struct amd_srb *pSRB, u_int scsistat)
-{
- DataIO_Comm(amd, pSRB, WRITE_DIRECTION);
- return (scsistat);
-}
-
-static u_int
-amd_DataInPhase1(struct amd_softc *amd, struct amd_srb *pSRB, u_int scsistat)
-{
- DataIO_Comm(amd, pSRB, READ_DIRECTION);
- return (scsistat);
-}
-
-static void
-DataIO_Comm(struct amd_softc *amd, struct amd_srb *pSRB, u_int ioDir)
-{
- struct amd_sg * psgl;
- u_int32_t lval;
-
- if (pSRB->SGIndex < pSRB->SGcount) {
- amd_write8(amd, DMA_Cmd, DMA_IDLE_CMD|ioDir);/* |EN_DMA_INT */
-
- if (!pSRB->SGToBeXferLen) {
- psgl = pSRB->pSGlist;
- pSRB->SGPhysAddr = psgl->SGXPtr;
- pSRB->SGToBeXferLen = psgl->SGXLen;
- }
- lval = pSRB->SGToBeXferLen;
- amd_write8(amd, CTCREG_LOW, lval);
- amd_write8(amd, CTCREG_MID, lval >> 8);
- amd_write8(amd, CURTXTCNTREG, lval >> 16);
-
- amd_write32(amd, DMA_XferCnt, pSRB->SGToBeXferLen);
-
- amd_write32(amd, DMA_XferAddr, pSRB->SGPhysAddr);
-
- pSRB->SRBState = SRB_DATA_XFER;
-
- amd_write8(amd, SCSICMDREG, DMA_COMMAND|INFO_XFER_CMD);
-
- amd_write8(amd, DMA_Cmd, DMA_IDLE_CMD|ioDir); /* |EN_DMA_INT */
-
- amd_write8(amd, DMA_Cmd, DMA_START_CMD|ioDir);/* |EN_DMA_INT */
- } else { /* xfer pad */
- if (pSRB->SGcount) {
- pSRB->AdaptStatus = H_OVER_UNDER_RUN;
- pSRB->SRBStatus |= OVER_RUN;
- }
- amd_write8(amd, CTCREG_LOW, 0);
- amd_write8(amd, CTCREG_MID, 0);
- amd_write8(amd, CURTXTCNTREG, 0);
-
- pSRB->SRBState |= SRB_XFERPAD;
- amd_write8(amd, SCSICMDREG, DMA_COMMAND|XFER_PAD_BYTE);
- }
-}
-
-static u_int
-amd_CommandPhase1(struct amd_softc *amd, struct amd_srb *srb, u_int scsistat)
-{
- amd_write8(amd, SCSICMDREG, RESET_ATN_CMD);
- amd_write8(amd, SCSICMDREG, CLEAR_FIFO_CMD);
-
- amdsetupcommand(amd, srb);
-
- srb->SRBState = SRB_COMMAND;
- amd_write8(amd, SCSICMDREG, INFO_XFER_CMD);
- return (scsistat);
-}
-
-static u_int
-amd_StatusPhase1(struct amd_softc *amd, struct amd_srb *pSRB, u_int scsistat)
-{
- amd_write8(amd, SCSICMDREG, CLEAR_FIFO_CMD);
- pSRB->SRBState = SRB_STATUS;
- amd_write8(amd, SCSICMDREG, INITIATOR_CMD_CMPLTE);
- return (scsistat);
-}
-
-static u_int
-amd_MsgOutPhase1(struct amd_softc *amd, struct amd_srb *pSRB, u_int scsistat)
-{
- amd_write8(amd, SCSICMDREG, CLEAR_FIFO_CMD);
-
- if (amd->msgout_len == 0) {
- amd->msgout_buf[0] = MSG_NOOP;
- amd->msgout_len = 1;
- }
- amd_write8_multi(amd, SCSIFIFOREG, amd->msgout_buf, amd->msgout_len);
- amd_write8(amd, SCSICMDREG, INFO_XFER_CMD);
- return (scsistat);
-}
-
-static u_int
-amd_MsgInPhase1(struct amd_softc *amd, struct amd_srb *pSRB, u_int scsistat)
-{
- amd_write8(amd, SCSICMDREG, CLEAR_FIFO_CMD);
- amd_write8(amd, SCSICMDREG, INFO_XFER_CMD);
- return (scsistat);
-}
-
-static u_int
-amd_NopPhase(struct amd_softc *amd, struct amd_srb *pSRB, u_int scsistat)
-{
- return (scsistat);
-}
-
-static void
-amd_Disconnect(struct amd_softc * amd)
-{
- struct amd_srb *srb;
- int target;
- int lun;
-
- srb = amd->active_srb;
- amd->active_srb = NULL;
- amd->last_phase = SCSI_BUS_FREE;
- amd_write8(amd, SCSICMDREG, EN_SEL_RESEL);
- target = amd->cur_target;
- lun = amd->cur_lun;
-
- if (srb == NULL) {
- /* Invalid reselection */
- amdrunwaiting(amd);
- } else if (srb->SRBState & SRB_ABORT_SENT) {
- /* Clean up and done this srb */
-#if 0
- while (( = TAILQ_FIRST(&amd->running_srbs)) != NULL) {
- /* XXX What about "done'ing" these srbs??? */
- if (pSRB->pSRBDCB == pDCB) {
- TAILQ_REMOVE(&amd->running_srbs, pSRB, links);
- TAILQ_INSERT_HEAD(&amd->free_srbs, pSRB, links);
- }
- }
- amdrunwaiting(amd);
-#endif
- } else {
- if ((srb->SRBState & (SRB_START | SRB_MSGOUT))
- || !(srb->SRBState & (SRB_DISCONNECT | SRB_COMPLETED))) {
- srb->TargetStatus = AMD_SCSI_STAT_SEL_TIMEOUT;
- goto disc1;
- } else if (srb->SRBState & SRB_DISCONNECT) {
- if (!(srb->pccb->ccb_h.flags & CAM_TAG_ACTION_VALID))
- amd->untagged_srbs[target][lun] = srb;
- amdrunwaiting(amd);
- } else if (srb->SRBState & SRB_COMPLETED) {
- disc1:
- srb->SRBState = SRB_FREE;
- SRBdone(amd, srb);
- }
- }
- return;
-}
-
-static void
-amd_Reselect(struct amd_softc *amd)
-{
- struct amd_target_info *tinfo;
- u_int16_t disc_count;
-
- amd_clear_msg_state(amd);
- if (amd->active_srb != NULL) {
- /* Requeue the SRB for our attempted Selection */
- TAILQ_REMOVE(&amd->running_srbs, amd->active_srb, links);
- TAILQ_INSERT_HEAD(&amd->waiting_srbs, amd->active_srb, links);
- amd->active_srb = NULL;
- }
- /* get ID */
- amd->cur_target = amd_read8(amd, SCSIFIFOREG);
- amd->cur_target ^= amd->HostID_Bit;
- amd->cur_target = ffs(amd->cur_target) - 1;
- amd->cur_lun = amd_read8(amd, SCSIFIFOREG) & 7;
- tinfo = &amd->tinfo[amd->cur_target];
- amd->active_srb = amd->untagged_srbs[amd->cur_target][amd->cur_lun];
- disc_count = amd->disc_count[amd->cur_target][amd->cur_lun];
- if (disc_count == 0) {
- printf("amd%d: Unexpected reselection for target %d, "
- "Issuing Abort\n", amd->unit, amd->cur_target);
- amd->msgout_buf[0] = MSG_ABORT;
- amd->msgout_len = 1;
- amd_write8(amd, SCSICMDREG, SET_ATN_CMD);
- }
- if (amd->active_srb != NULL) {
- amd->disc_count[amd->cur_target][amd->cur_lun]--;
- amd->untagged_srbs[amd->cur_target][amd->cur_lun] = NULL;
- }
-
- amd_write8(amd, SCSIDESTIDREG, amd->cur_target);
- amd_write8(amd, SYNCPERIOREG, tinfo->sync_period_reg);
- amd_write8(amd, SYNCOFFREG, tinfo->sync_offset_reg);
- amd_write8(amd, CNTLREG1, tinfo->CtrlR1);
- amd_write8(amd, CNTLREG3, tinfo->CtrlR3);
- amd_write8(amd, CNTLREG4, tinfo->CtrlR4);
- amd_write8(amd, SCSICMDREG, MSG_ACCEPTED_CMD);/* drop /ACK */
- amd->last_phase = SCSI_NOP0;
-}
-
-static void
-SRBdone(struct amd_softc *amd, struct amd_srb *pSRB)
-{
- u_int8_t bval, i, status;
- union ccb *pccb;
- struct ccb_scsiio *pcsio;
- int intflag;
- struct amd_sg *ptr2;
- u_int32_t swlval;
- u_int target_id, target_lun;
-
- pccb = pSRB->pccb;
- pcsio = &pccb->csio;
- target_id = pSRB->pccb->ccb_h.target_id;
- target_lun = pSRB->pccb->ccb_h.target_lun;
-
- CAM_DEBUG(pccb->ccb_h.path, CAM_DEBUG_TRACE,
- ("SRBdone - TagNumber %d\n", pSRB->TagNumber));
-
- if ((pccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
- bus_dmasync_op_t op;
-
- if ((pccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN)
- op = BUS_DMASYNC_POSTREAD;
- else
- op = BUS_DMASYNC_POSTWRITE;
- bus_dmamap_sync(amd->buffer_dmat, pSRB->dmamap, op);
- bus_dmamap_unload(amd->buffer_dmat, pSRB->dmamap);
- }
-
- status = pSRB->TargetStatus;
- pccb->ccb_h.status = CAM_REQ_CMP;
- pccb->ccb_h.status = CAM_REQ_CMP;
- if (pSRB->SRBFlag & AUTO_REQSENSE) {
- pSRB->SRBFlag &= ~AUTO_REQSENSE;
- pSRB->AdaptStatus = 0;
- pSRB->TargetStatus = SCSI_STATUS_CHECK_COND;
-
- if (status == SCSI_STATUS_CHECK_COND) {
- pccb->ccb_h.status = CAM_SEL_TIMEOUT;
- goto ckc_e;
- }
- *((u_int32_t *)&(pSRB->CmdBlock[0])) = pSRB->Segment0[0];
-
- pcsio->sense_resid = pcsio->sense_len
- - pSRB->TotalXferredLen;
- pSRB->TotalXferredLen = pSRB->Segment1[1];
- if (pSRB->TotalXferredLen) {
- /* ???? */
- pcsio->resid = pcsio->dxfer_len
- - pSRB->TotalXferredLen;
- /* The resid field contains valid data */
- /* Flush resid bytes on complete */
- } else {
- pcsio->scsi_status = SCSI_STATUS_CHECK_COND;
- }
- pccb->ccb_h.status = CAM_AUTOSNS_VALID|CAM_SCSI_STATUS_ERROR;
- goto ckc_e;
- }
- if (status) {
- if (status == SCSI_STATUS_CHECK_COND) {
-
- if ((pSRB->SGIndex < pSRB->SGcount)
- && (pSRB->SGcount) && (pSRB->SGToBeXferLen)) {
- bval = pSRB->SGcount;
- swlval = pSRB->SGToBeXferLen;
- ptr2 = pSRB->pSGlist;
- ptr2++;
- for (i = pSRB->SGIndex + 1; i < bval; i++) {
- swlval += ptr2->SGXLen;
- ptr2++;
- }
- /* ??????? */
- pcsio->resid = (u_int32_t) swlval;
-
-#ifdef AMD_DEBUG0
- printf("XferredLen=%8x,NotYetXferLen=%8x,",
- pSRB->TotalXferredLen, swlval);
-#endif
- }
- if ((pcsio->ccb_h.flags & CAM_DIS_AUTOSENSE) == 0) {
-#ifdef AMD_DEBUG0
- printf("RequestSense..................\n");
-#endif
- RequestSense(amd, pSRB);
- return;
- }
- pcsio->scsi_status = SCSI_STATUS_CHECK_COND;
- pccb->ccb_h.status = CAM_SCSI_STATUS_ERROR;
- goto ckc_e;
- } else if (status == SCSI_STATUS_QUEUE_FULL) {
- pSRB->AdaptStatus = 0;
- pSRB->TargetStatus = 0;
- pcsio->scsi_status = SCSI_STATUS_QUEUE_FULL;
- pccb->ccb_h.status = CAM_SCSI_STATUS_ERROR;
- goto ckc_e;
- } else if (status == AMD_SCSI_STAT_SEL_TIMEOUT) {
- pSRB->AdaptStatus = H_SEL_TIMEOUT;
- pSRB->TargetStatus = 0;
-
- pcsio->scsi_status = AMD_SCSI_STAT_SEL_TIMEOUT;
- pccb->ccb_h.status = CAM_SEL_TIMEOUT;
- } else if (status == SCSI_STATUS_BUSY) {
-#ifdef AMD_DEBUG0
- printf("DC390: target busy at %s %d\n",
- __FILE__, __LINE__);
-#endif
- pcsio->scsi_status = SCSI_STATUS_BUSY;
- pccb->ccb_h.status = CAM_SCSI_BUSY;
- } else if (status == SCSI_STATUS_RESERV_CONFLICT) {
-#ifdef AMD_DEBUG0
- printf("DC390: target reserved at %s %d\n",
- __FILE__, __LINE__);
-#endif
- pcsio->scsi_status = SCSI_STATUS_RESERV_CONFLICT;
- pccb->ccb_h.status = CAM_SCSI_STATUS_ERROR; /* XXX */
- } else {
- pSRB->AdaptStatus = 0;
-#ifdef AMD_DEBUG0
- printf("DC390: driver stuffup at %s %d\n",
- __FILE__, __LINE__);
-#endif
- pccb->ccb_h.status = CAM_SCSI_STATUS_ERROR;
- }
- } else {
- status = pSRB->AdaptStatus;
- if (status & H_OVER_UNDER_RUN) {
- pSRB->TargetStatus = 0;
-
- pccb->ccb_h.status = CAM_DATA_RUN_ERR;
- } else if (pSRB->SRBStatus & PARITY_ERROR) {
-#ifdef AMD_DEBUG0
- printf("DC390: driver stuffup %s %d\n",
- __FILE__, __LINE__);
-#endif
- /* Driver failed to perform operation */
- pccb->ccb_h.status = CAM_UNCOR_PARITY;
- } else { /* No error */
- pSRB->AdaptStatus = 0;
- pSRB->TargetStatus = 0;
- pcsio->resid = 0;
- /* there is no error, (sense is invalid) */
- }
- }
-ckc_e:
- intflag = splcam();
- if ((pccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
- /* CAM request not yet complete =>device_Q frozen */
- xpt_freeze_devq(pccb->ccb_h.path, 1);
- pccb->ccb_h.status |= CAM_DEV_QFRZN;
- }
- TAILQ_REMOVE(&amd->running_srbs, pSRB, links);
- TAILQ_INSERT_HEAD(&amd->free_srbs, pSRB, links);
- amdrunwaiting(amd);
- splx(intflag);
- xpt_done(pccb);
-
-}
-
-static void
-amd_ResetSCSIBus(struct amd_softc * amd)
-{
- int intflag;
-
- intflag = splcam();
- amd->ACBFlag |= RESET_DEV;
- amd_write8(amd, DMA_Cmd, DMA_IDLE_CMD);
- amd_write8(amd, SCSICMDREG, RST_SCSI_BUS_CMD);
- splx(intflag);
- return;
-}
-
-static void
-amd_ScsiRstDetect(struct amd_softc * amd)
-{
- int intflag;
- u_int32_t wlval;
-
-#ifdef AMD_DEBUG0
- printf("amd_ScsiRstDetect \n");
-#endif
-
- wlval = 1000;
- while (--wlval) { /* delay 1 sec */
- DELAY(1000);
- }
- intflag = splcam();
-
- amd_write8(amd, DMA_Cmd, DMA_IDLE_CMD);
- amd_write8(amd, SCSICMDREG, CLEAR_FIFO_CMD);
-
- if (amd->ACBFlag & RESET_DEV) {
- amd->ACBFlag |= RESET_DONE;
- } else {
- amd->ACBFlag |= RESET_DETECT;
- ResetDevParam(amd);
- amdcompletematch(amd, CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD,
- AMD_TAG_WILDCARD, &amd->running_srbs,
- CAM_DEV_QFRZN|CAM_SCSI_BUS_RESET);
- amdcompletematch(amd, CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD,
- AMD_TAG_WILDCARD, &amd->waiting_srbs,
- CAM_DEV_QFRZN|CAM_SCSI_BUS_RESET);
- amd->active_srb = NULL;
- amd->ACBFlag = 0;
- amdrunwaiting(amd);
- }
- splx(intflag);
- return;
-}
-
-static void
-RequestSense(struct amd_softc *amd, struct amd_srb *pSRB)
-{
- union ccb *pccb;
- struct ccb_scsiio *pcsio;
-
- pccb = pSRB->pccb;
- pcsio = &pccb->csio;
-
- pSRB->SRBFlag |= AUTO_REQSENSE;
- pSRB->Segment0[0] = *((u_int32_t *) & (pSRB->CmdBlock[0]));
- pSRB->Segment0[1] = *((u_int32_t *) & (pSRB->CmdBlock[4]));
- pSRB->Segment1[0] = (pSRB->ScsiCmdLen << 8) + pSRB->SGcount;
- pSRB->Segment1[1] = pSRB->TotalXferredLen;
-
- pSRB->AdaptStatus = 0;
- pSRB->TargetStatus = 0;
-
- pSRB->Segmentx.SGXPtr = (u_int32_t) vtophys(&pcsio->sense_data);
- pSRB->Segmentx.SGXLen = (u_int32_t) pcsio->sense_len;
-
- pSRB->pSGlist = &pSRB->Segmentx;
- pSRB->SGcount = 1;
- pSRB->SGIndex = 0;
-
- *((u_int32_t *) & (pSRB->CmdBlock[0])) = 0x00000003;
- pSRB->CmdBlock[1] = pSRB->pccb->ccb_h.target_lun << 5;
- *((u_int16_t *) & (pSRB->CmdBlock[4])) = pcsio->sense_len;
- pSRB->ScsiCmdLen = 6;
-
- pSRB->TotalXferredLen = 0;
- pSRB->SGToBeXferLen = 0;
- if (amdstart(amd, pSRB) != 0) {
- TAILQ_REMOVE(&amd->running_srbs, pSRB, links);
- TAILQ_INSERT_HEAD(&amd->waiting_srbs, pSRB, links);
- }
-}
-
-static void
-amd_InvalidCmd(struct amd_softc * amd)
-{
- struct amd_srb *srb;
-
- srb = amd->active_srb;
- if (srb->SRBState & (SRB_START|SRB_MSGOUT))
- amd_write8(amd, SCSICMDREG, CLEAR_FIFO_CMD);
-}
-
-void
-amd_linkSRB(struct amd_softc *amd)
-{
- u_int16_t count, i;
- struct amd_srb *psrb;
-
- count = amd->SRBCount;
-
- for (i = 0; i < count; i++) {
- psrb = (struct amd_srb *)&amd->SRB_array[i];
- psrb->TagNumber = i;
- TAILQ_INSERT_TAIL(&amd->free_srbs, psrb, links);
- }
-}
-
-void
-amd_EnDisableCE(struct amd_softc *amd, int mode, int *regval)
-{
- if (mode == ENABLE_CE) {
- *regval = 0xc0;
- } else {
- *regval = 0x80;
- }
- pci_cfgwrite(amd->config_id, *regval, 0, /*bytes*/1);
- if (mode == DISABLE_CE) {
- pci_cfgwrite(amd->config_id, *regval, 0, /*bytes*/1);
- }
- DELAY(160);
-}
-
-void
-amd_EEpromOutDI(struct amd_softc *amd, int *regval, int Carry)
-{
- u_int bval;
-
- bval = 0;
- if (Carry) {
- bval = 0x40;
- *regval = 0x80;
- pci_cfgwrite(amd->config_id, *regval, bval, /*bytes*/1);
- }
- DELAY(160);
- bval |= 0x80;
- pci_cfgwrite(amd->config_id, *regval, bval, /*bytes*/1);
- DELAY(160);
- pci_cfgwrite(amd->config_id, *regval, 0, /*bytes*/1);
- DELAY(160);
-}
-
-static int
-amd_EEpromInDO(struct amd_softc *amd)
-{
- pci_cfgwrite(amd->config_id, 0x80, 0x80, /*bytes*/1);
- DELAY(160);
- pci_cfgwrite(amd->config_id, 0x80, 0x40, /*bytes*/1);
- DELAY(160);
- if (pci_cfgread(amd->config_id, 0, /*bytes*/1) == 0x22)
- return (1);
- return (0);
-}
-
-static u_int16_t
-EEpromGetData1(struct amd_softc *amd)
-{
- u_int i;
- u_int carryFlag;
- u_int16_t wval;
-
- wval = 0;
- for (i = 0; i < 16; i++) {
- wval <<= 1;
- carryFlag = amd_EEpromInDO(amd);
- wval |= carryFlag;
- }
- return (wval);
-}
-
-static void
-amd_Prepare(struct amd_softc *amd, int *regval, u_int8_t EEpromCmd)
-{
- u_int i, j;
- int carryFlag;
-
- carryFlag = 1;
- j = 0x80;
- for (i = 0; i < 9; i++) {
- amd_EEpromOutDI(amd, regval, carryFlag);
- carryFlag = (EEpromCmd & j) ? 1 : 0;
- j >>= 1;
- }
-}
-
-static void
-amd_ReadEEprom(struct amd_softc *amd)
-{
- int regval;
- u_int i;
- u_int16_t *ptr;
- u_int8_t cmd;
-
- ptr = (u_int16_t *)&amd->eepromBuf[0];
- cmd = EEPROM_READ;
- for (i = 0; i < 0x40; i++) {
- amd_EnDisableCE(amd, ENABLE_CE, &regval);
- amd_Prepare(amd, &regval, cmd);
- *ptr = EEpromGetData1(amd);
- ptr++;
- cmd++;
- amd_EnDisableCE(amd, DISABLE_CE, &regval);
- }
-}
-
-static void
-amd_load_defaults(struct amd_softc *amd)
-{
- int target;
-
- bzero(&amd->eepromBuf, sizeof amd->eepromBuf);
- for (target = 0; target < MAX_SCSI_ID; target++)
- amd->eepromBuf[target << 2] =
- (TAG_QUEUING|EN_DISCONNECT|SYNC_NEGO|PARITY_CHK);
- amd->eepromBuf[EE_ADAPT_SCSI_ID] = 7;
- amd->eepromBuf[EE_MODE2] = ACTIVE_NEGATION|LUN_CHECK|GREATER_1G;
- amd->eepromBuf[EE_TAG_CMD_NUM] = 4;
-}
-
-static void
-amd_load_eeprom_or_defaults(struct amd_softc *amd)
-{
- u_int16_t wval, *ptr;
- u_int8_t i;
-
- amd_ReadEEprom(amd);
- wval = 0;
- ptr = (u_int16_t *) & amd->eepromBuf[0];
- for (i = 0; i < EE_DATA_SIZE; i += 2, ptr++)
- wval += *ptr;
-
- if (wval != EE_CHECKSUM) {
- if (bootverbose)
- printf("amd%d: SEEPROM data unavailable. "
- "Using default device parameters.\n",
- amd->unit);
- amd_load_defaults(amd);
- }
-}
-
-/*
- **********************************************************************
- * Function : static int amd_init (struct Scsi_Host *host)
- * Purpose : initialize the internal structures for a given SCSI host
- * Inputs : host - pointer to this host adapter's structure/
- **********************************************************************
- */
-static struct amd_softc *
-amd_init(int unit, pcici_t config_id)
-{
- struct amd_softc *amd;
- u_int bval;
- u_int i;
-
- amd = (struct amd_softc *)malloc(sizeof(struct amd_softc),
- M_DEVBUF, M_WAITOK);
- if (amd == NULL) {
- printf("DC390%d: cannot allocate ACB !\n", unit);
- return (amd);
- }
- bzero(amd, sizeof(struct amd_softc));
- amd->tag = I386_BUS_SPACE_IO;
- amd->bsh = pci_conf_read(config_id, PCI_MAP_REG_START) & 0xFFFE;
- /* DMA tag for mapping buffers into device visible space. */
- if (bus_dma_tag_create(/*parent_dmat*/NULL, /*alignment*/1,
- /*boundary*/0,
- /*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
- /*highaddr*/BUS_SPACE_MAXADDR,
- /*filter*/NULL, /*filterarg*/NULL,
- /*maxsize*/MAXBSIZE, /*nsegments*/AMD_NSEG,
- /*maxsegsz*/AMD_MAXTRANSFER_SIZE,
- /*flags*/BUS_DMA_ALLOCNOW,
- &amd->buffer_dmat) != 0) {
- free(amd, M_DEVBUF);
- return (NULL);
- }
- TAILQ_INIT(&amd->free_srbs);
- TAILQ_INIT(&amd->running_srbs);
- TAILQ_INIT(&amd->waiting_srbs);
- amd->last_phase = SCSI_BUS_FREE;
- amd->config_id = config_id;
- amd->unit = unit;
- amd->SRBCount = MAX_SRB_CNT;
- amd->status = 0;
- amd_load_eeprom_or_defaults(amd);
- amd->max_id = 7;
- if (amd->eepromBuf[EE_MODE2] & LUN_CHECK) {
- amd->max_lun = 7;
- } else {
- amd->max_lun = 0;
- }
- amd->AdaptSCSIID = amd->eepromBuf[EE_ADAPT_SCSI_ID];
- amd->HostID_Bit = (1 << amd->AdaptSCSIID);
- amd->AdaptSCSILUN = 0;
- /* (eepromBuf[EE_TAG_CMD_NUM]) << 2; */
- amd->ACBFlag = 0;
- amd->Gmode2 = amd->eepromBuf[EE_MODE2];
- amd_linkSRB(amd);
- for (i = 0; i <= amd->max_id; i++) {
-
- if (amd->AdaptSCSIID != i) {
- struct amd_target_info *tinfo;
- PEEprom prom;
-
- tinfo = &amd->tinfo[i];
- prom = (PEEprom)&amd->eepromBuf[i << 2];
- if ((prom->EE_MODE1 & EN_DISCONNECT) != 0) {
- tinfo->disc_tag |= AMD_USR_DISCENB;
- if ((prom->EE_MODE1 & TAG_QUEUING) != 0)
- tinfo->disc_tag |= AMD_USR_TAGENB;
- }
- if ((prom->EE_MODE1 & SYNC_NEGO) != 0) {
- tinfo->user.period =
- eeprom_period[prom->EE_SPEED];
- tinfo->user.offset = AMD_MAX_SYNC_OFFSET;
- }
- tinfo->CtrlR1 = amd->AdaptSCSIID;
- if ((prom->EE_MODE1 & PARITY_CHK) != 0)
- tinfo->CtrlR1 |= PARITY_ERR_REPO;
- tinfo->CtrlR3 = FAST_CLK;
- tinfo->CtrlR4 = EATER_25NS;
- if ((amd->eepromBuf[EE_MODE2] & ACTIVE_NEGATION) != 0)
- tinfo->CtrlR4 |= NEGATE_REQACKDATA;
- }
- }
- amd_write8(amd, SCSITIMEOUTREG, 153); /* 250ms selection timeout */
- /* Conversion factor = 0 , 40MHz clock */
- amd_write8(amd, CLKFACTREG, CLK_FREQ_40MHZ);
- /* NOP cmd - clear command register */
- amd_write8(amd, SCSICMDREG, NOP_CMD);
- amd_write8(amd, CNTLREG2, EN_FEATURE|EN_SCSI2_CMD);
- amd_write8(amd, CNTLREG3, FAST_CLK);
- bval = EATER_25NS;
- if (amd->eepromBuf[EE_MODE2] & ACTIVE_NEGATION) {
- bval |= NEGATE_REQACKDATA;
- }
- amd_write8(amd, CNTLREG4, bval);
-
- /* Disable SCSI bus reset interrupt */
- amd_write8(amd, CNTLREG1, DIS_INT_ON_SCSI_RST);
- return (amd);
-}
-
-/*
- * attach and init a host adapter
- */
-static void
-amd_attach(pcici_t config_id, int unit)
-{
- struct cam_devq *devq; /* Device Queue to use for this SIM */
- u_int8_t intstat;
- u_int32_t wlval;
- struct amd_softc *amd = NULL;
-
- wlval = pci_conf_read(config_id, PCI_ID_REG);
-
- if (wlval == PCI_DEVICE_ID_AMD53C974) {
- if ((amd = amd_init(unit, config_id)) == NULL)
- return;
-
- /* Reset Pending INT */
- intstat = amd_read8(amd, INTSTATREG);
- }
-
- /* After setting up the adapter, map our interrupt */
- if (!pci_map_int(config_id, amd_intr, amd, &cam_imask)) {
- if (bootverbose)
- printf("amd%d: unable to register interrupt handler!\n",
- unit);
- free(amd, M_DEVBUF);
- return;
- }
-
- /*
- * Now let the CAM generic SCSI layer find the SCSI devices on
- * the bus * start queue to reset to the idle loop. *
- * Create device queue of SIM(s) * (MAX_START_JOB - 1) :
- * max_sim_transactions
- */
- devq = cam_simq_alloc(MAX_START_JOB);
- if (devq == NULL) {
- free(amd, M_DEVBUF);
- return;
- }
-
- amd->psim = cam_sim_alloc(amd_action, amd_poll, "amd",
- amd, amd->unit, 1, MAX_TAGS_CMD_QUEUE,
- devq);
- if (amd->psim == NULL) {
- cam_simq_free(devq);
- free(amd, M_DEVBUF);
- return;
- }
-
- if (xpt_bus_register(amd->psim, 0) != CAM_SUCCESS) {
- cam_sim_free(amd->psim, /*free_devq*/TRUE);
- free(amd, M_DEVBUF);
- return;
- }
-
- if (xpt_create_path(&amd->ppath, /* periph */ NULL,
- cam_sim_path(amd->psim), CAM_TARGET_WILDCARD,
- CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
- xpt_bus_deregister(cam_sim_path(amd->psim));
- cam_sim_free(amd->psim, /* free_simq */ TRUE);
- free(amd, M_DEVBUF);
- return;
- }
-}
-
-static const char *
-amd_probe(pcici_t tag, pcidi_t type)
-{
- if (type == PCI_DEVICE_ID_AMD53C974) {
- return ("Tekram DC390(T)/AMD53c974 SCSI Host Adapter");
- } else {
- return (NULL);
- }
-}
diff --git a/sys/dev/amd/amd.h b/sys/dev/amd/amd.h
deleted file mode 100644
index c140e313cf6d..000000000000
--- a/sys/dev/amd/amd.h
+++ /dev/null
@@ -1,579 +0,0 @@
-/*
- *********************************************************************
- * FILE NAME : amd.h
- * BY : C.L. Huang (ching@tekram.com.tw)
- * Erich Chen (erich@tekram.com.tw)
- * Description: Device Driver for the amd53c974 PCI Bus Master
- * SCSI Host adapter found on cards such as
- * the Tekram DC-390(T).
- * (C)Copyright 1995-1999 Tekram Technology Co., Ltd.
- *
- * 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.
- *********************************************************************
- */
-
-#ifndef AMD_H
-#define AMD_H
-
-#define AMD_TRANS_CUR 0x01 /* Modify current neogtiation status */
-#define AMD_TRANS_ACTIVE 0x03 /* Assume this is the active target */
-#define AMD_TRANS_GOAL 0x04 /* Modify negotiation goal */
-#define AMD_TRANS_USER 0x08 /* Modify user negotiation settings */
-
-/*
- * Per target transfer parameters.
- */
-struct amd_transinfo {
- u_int8_t period;
- u_int8_t offset;
-};
-
-struct amd_target_info {
- /*
- * Records the currently active and user/default settings for
- * tagged queueing and disconnection for each target.
- */
- u_int8_t disc_tag;
-#define AMD_CUR_DISCENB 0x01
-#define AMD_CUR_TAGENB 0x02
-#define AMD_USR_DISCENB 0x04
-#define AMD_USR_TAGENB 0x08
- u_int8_t CtrlR1;
- u_int8_t CtrlR3;
- u_int8_t CtrlR4;
- u_int8_t sync_period_reg;
- u_int8_t sync_offset_reg;
-
- /*
- * Currently active transfer settings.
- */
- struct amd_transinfo current;
- /*
- * Transfer settings we wish to achieve
- * through negotiation.
- */
- struct amd_transinfo goal;
- /*
- * User defined or default transfer settings.
- */
- struct amd_transinfo user;
-};
-
-/*
- * Scatter/Gather Segment entry.
- */
-struct amd_sg {
- u_int32_t SGXLen;
- u_int32_t SGXPtr;
-};
-
-/*
- * Chipset feature limits
- */
-#define MAX_SCSI_ID 8
-#define AMD_MAX_SYNC_OFFSET 15
-#define AMD_TARGET_MAX 7
-#define AMD_LUN_MAX 7
-#define AMD_NSEG (btoc(MAXPHYS) + 1)
-#define AMD_MAXTRANSFER_SIZE 0xFFFFFF /* restricted by 24 bit counter */
-#define MAX_DEVICES 10
-#define MAX_TAGS_CMD_QUEUE 256
-#define MAX_CMD_PER_LUN 6
-#define MAX_SRB_CNT 256
-#define MAX_START_JOB 256
-
-/*
- * BIT position to integer mapping.
- */
-#define BIT(N) (0x01 << N)
-
-/*
- * EEPROM storage offsets and data structures.
- */
-typedef struct _EEprom {
- u_int8_t EE_MODE1;
- u_int8_t EE_SPEED;
- u_int8_t xx1;
- u_int8_t xx2;
-} EEprom, *PEEprom;
-
-#define EE_ADAPT_SCSI_ID 64
-#define EE_MODE2 65
-#define EE_DELAY 66
-#define EE_TAG_CMD_NUM 67
-#define EE_DATA_SIZE 128
-#define EE_CHECKSUM 0x1234
-
-/*
- * EE_MODE1 bits definition
- */
-#define PARITY_CHK BIT(0)
-#define SYNC_NEGO BIT(1)
-#define EN_DISCONNECT BIT(2)
-#define SEND_START BIT(3)
-#define TAG_QUEUING BIT(4)
-
-/*
- * EE_MODE2 bits definition
- */
-#define MORE2_DRV BIT(0)
-#define GREATER_1G BIT(1)
-#define RST_SCSI_BUS BIT(2)
-#define ACTIVE_NEGATION BIT(3)
-#define NO_SEEK BIT(4)
-#define LUN_CHECK BIT(5)
-
-#define ENABLE_CE 1
-#define DISABLE_CE 0
-#define EEPROM_READ 0x80
-
-#define AMD_TAG_WILDCARD ((u_int)(~0))
-
-/*
- * SCSI Request Block
- */
-struct amd_srb {
- TAILQ_ENTRY(amd_srb) links;
- u_int8_t CmdBlock[12];
- union ccb *pccb;
- bus_dmamap_t dmamap;
- struct amd_sg *pSGlist;
-
- u_int32_t TotalXferredLen;
- u_int32_t SGPhysAddr; /* a segment starting address */
- u_int32_t SGToBeXferLen; /* to be xfer length */
- u_int32_t Segment0[2];
- u_int32_t Segment1[2];
-
- struct amd_sg SGsegment[AMD_NSEG];
- struct amd_sg Segmentx;/* a one entry of S/G list table */
- u_int8_t *pMsgPtr;
- u_int16_t SRBState;
-
- u_int8_t AdaptStatus;
- u_int8_t TargetStatus;
- u_int8_t MsgCnt;
- u_int8_t EndMessage;
- u_int8_t TagNumber;
- u_int8_t SGcount;
- u_int8_t SGIndex;
- u_int8_t IORBFlag; /* ;81h-Reset, 2-retry */
-
- u_int8_t SRBStatus;
- u_int8_t SRBFlag;
- /* ; b0-AutoReqSense,b6-Read,b7-write */
- /* ; b4-settimeout,b5-Residual valid */
- u_int8_t ScsiCmdLen;
-};
-
-TAILQ_HEAD(srb_queue, amd_srb);
-
-/*
- * Per-adapter, software configuration.
- */
-struct amd_softc {
- bus_space_tag_t tag;
- bus_space_handle_t bsh;
- bus_dma_tag_t buffer_dmat; /* dmat for buffer I/O */
- int unit;
-
- int last_phase;
- int cur_target;
- int cur_lun;
- struct amd_srb *active_srb;
- struct amd_srb *untagged_srbs[AMD_TARGET_MAX+1][AMD_LUN_MAX+1];
- struct amd_target_info tinfo[AMD_TARGET_MAX+1];
- u_int16_t disc_count[AMD_TARGET_MAX+1][AMD_LUN_MAX+1];
-
- struct srb_queue free_srbs;
- struct srb_queue waiting_srbs;
- struct srb_queue running_srbs;
-
- pcici_t config_id;
- struct amd_srb *pTmpSRB;
-
- u_int16_t SRBCount;
-
- u_int16_t max_id;
- u_int16_t max_lun;
-
- /* Hooks into the CAM XPT */
- struct cam_sim *psim;
- struct cam_path *ppath;
-
- u_int8_t msgin_buf[6];
- u_int8_t msgout_buf[6];
- u_int msgin_index;
- u_int msgout_index;
- u_int msgout_len;
-
- u_int8_t status;
- u_int8_t AdaptSCSIID; /* ; Adapter SCSI Target ID */
- u_int8_t AdaptSCSILUN; /* ; Adapter SCSI LUN */
-
- u_int8_t ACBFlag;
-
- u_int8_t Gmode2;
-
- u_int8_t HostID_Bit;
-
- u_int8_t InitDCB_flag[8][8]; /* flag of initDCB for device */
- struct amd_srb SRB_array[MAX_SRB_CNT]; /* +45Ch, Len= */
- struct amd_srb TmpSRB;
- /* Setup data stored in an 93c46 serial eeprom */
- u_int8_t eepromBuf[EE_DATA_SIZE];
-};
-
-/*
- * ----SRB State machine definition
- */
-#define SRB_FREE 0
-#define SRB_READY BIT(1)
-#define SRB_MSGOUT BIT(2) /* ;arbitration+msg_out 1st byte */
-#define SRB_MSGIN BIT(3)
-#define SRB_MSGIN_MULTI BIT(4)
-#define SRB_COMMAND BIT(5)
-#define SRB_START BIT(6) /* ;arbitration+msg_out+command_out */
-#define SRB_DISCONNECT BIT(7)
-#define SRB_DATA_XFER BIT(8)
-#define SRB_XFERPAD BIT(9)
-#define SRB_STATUS BIT(10)
-#define SRB_COMPLETED BIT(11)
-#define SRB_ABORT_SENT BIT(12)
-#define DO_SYNC_NEGO BIT(13)
-#define SRB_UNEXPECT_RESEL BIT(14)
-
-/*
- * ---ACB Flag
- */
-#define RESET_DEV BIT(0)
-#define RESET_DETECT BIT(1)
-#define RESET_DONE BIT(2)
-
-/*
- * ---DCB Flag
- */
-#define ABORT_DEV_ BIT(0)
-
-/*
- * ---SRB status
- */
-#define SRB_OK BIT(0)
-#define ABORTION BIT(1)
-#define OVER_RUN BIT(2)
-#define UNDER_RUN BIT(3)
-#define PARITY_ERROR BIT(4)
-#define SRB_ERROR BIT(5)
-
-/*
- * ---SRB Flags
- */
-#define DATAOUT BIT(7)
-#define DATAIN BIT(6)
-#define RESIDUAL_VALID BIT(5)
-#define ENABLE_TIMER BIT(4)
-#define RESET_DEV0 BIT(2)
-#define ABORT_DEV BIT(1)
-#define AUTO_REQSENSE BIT(0)
-
-/*
- * ---Adapter status
- */
-#define H_STATUS_GOOD 0
-#define H_SEL_TIMEOUT 0x11
-#define H_OVER_UNDER_RUN 0x12
-#define H_UNEXP_BUS_FREE 0x13
-#define H_TARGET_PHASE_F 0x14
-#define H_INVALID_CCB_OP 0x16
-#define H_LINK_CCB_BAD 0x17
-#define H_BAD_TARGET_DIR 0x18
-#define H_DUPLICATE_CCB 0x19
-#define H_BAD_CCB_OR_SG 0x1A
-#define H_ABORT 0x0FF
-
-/*
- * AMD specific "status" codes returned in the SCSI status byte.
- */
-#define AMD_SCSI_STAT_UNEXP_BUS_F 0xFD /* ; Unexpect Bus Free */
-#define AMD_SCSI_STAT_BUS_RST_DETECT 0xFE /* ; Scsi Bus Reset detected */
-#define AMD_SCSI_STAT_SEL_TIMEOUT 0xFF /* ; Selection Time out */
-
-/*
- * ---Sync_Mode
- */
-#define SYNC_DISABLE 0
-#define SYNC_ENABLE BIT(0)
-#define SYNC_NEGO_DONE BIT(1)
-#define WIDE_ENABLE BIT(2)
-#define WIDE_NEGO_DONE BIT(3)
-#define EN_TAG_QUEUING BIT(4)
-#define EN_ATN_STOP BIT(5)
-
-#define SYNC_NEGO_OFFSET 15
-
-/*
- * ---SCSI bus phase
- */
-#define SCSI_DATA_OUT 0
-#define SCSI_DATA_IN 1
-#define SCSI_COMMAND 2
-#define SCSI_STATUS 3
-#define SCSI_NOP0 4
-#define SCSI_ARBITRATING 5
-#define SCSI_MSG_OUT 6
-#define SCSI_MSG_IN 7
-#define SCSI_BUS_FREE 8
-
-/*
- *==========================================================
- * AMD 53C974 Registers bit Definition
- *==========================================================
- */
-
-/*
- * ------SCSI Register-------
- * Command Reg.(+0CH)
- */
-#define DMA_COMMAND BIT(7)
-#define NOP_CMD 0
-#define CLEAR_FIFO_CMD 1
-#define RST_DEVICE_CMD 2
-#define RST_SCSI_BUS_CMD 3
-#define INFO_XFER_CMD 0x10
-#define INITIATOR_CMD_CMPLTE 0x11
-#define MSG_ACCEPTED_CMD 0x12
-#define XFER_PAD_BYTE 0x18
-#define SET_ATN_CMD 0x1A
-#define RESET_ATN_CMD 0x1B
-#define SEL_W_ATN 0x42
-#define SEL_W_ATN_STOP 0x43
-#define EN_SEL_RESEL 0x44
-#define SEL_W_ATN2 0x46
-#define DATA_XFER_CMD INFO_XFER_CMD
-
-
-/*
- * ------SCSI Register-------
- * SCSI Status Reg.(+10H)
- */
-#define INTERRUPT BIT(7)
-#define ILLEGAL_OP_ERR BIT(6)
-#define PARITY_ERR BIT(5)
-#define COUNT_2_ZERO BIT(4)
-#define GROUP_CODE_VALID BIT(3)
-#define SCSI_PHASE_MASK (BIT(2)+BIT(1)+BIT(0))
-
-/*
- * ------SCSI Register-------
- * Interrupt Status Reg.(+14H)
- */
-#define SCSI_RESET_ BIT(7)
-#define INVALID_CMD BIT(6)
-#define DISCONNECTED BIT(5)
-#define SERVICE_REQUEST BIT(4)
-#define SUCCESSFUL_OP BIT(3)
-#define RESELECTED BIT(2)
-#define SEL_ATTENTION BIT(1)
-#define SELECTED BIT(0)
-
-/*
- * ------SCSI Register-------
- * Internal State Reg.(+18H)
- */
-#define SYNC_OFFSET_FLAG BIT(3)
-#define INTRN_STATE_MASK (BIT(2)+BIT(1)+BIT(0))
-
-/*
- * ------SCSI Register-------
- * Clock Factor Reg.(+24H)
- */
-#define CLK_FREQ_40MHZ 0
-#define CLK_FREQ_35MHZ (BIT(2)+BIT(1)+BIT(0))
-#define CLK_FREQ_30MHZ (BIT(2)+BIT(1))
-#define CLK_FREQ_25MHZ (BIT(2)+BIT(0))
-#define CLK_FREQ_20MHZ BIT(2)
-#define CLK_FREQ_15MHZ (BIT(1)+BIT(0))
-#define CLK_FREQ_10MHZ BIT(1)
-
-/*
- * ------SCSI Register-------
- * Control Reg. 1(+20H)
- */
-#define EXTENDED_TIMING BIT(7)
-#define DIS_INT_ON_SCSI_RST BIT(6)
-#define PARITY_ERR_REPO BIT(4)
-#define SCSI_ID_ON_BUS (BIT(2)+BIT(1)+BIT(0))
-
-/*
- * ------SCSI Register-------
- * Control Reg. 2(+2CH)
- */
-#define EN_FEATURE BIT(6)
-#define EN_SCSI2_CMD BIT(3)
-
-/*
- * ------SCSI Register-------
- * Control Reg. 3(+30H)
- */
-#define ID_MSG_CHECK BIT(7)
-#define EN_QTAG_MSG BIT(6)
-#define EN_GRP2_CMD BIT(5)
-#define FAST_SCSI BIT(4) /* ;10MB/SEC */
-#define FAST_CLK BIT(3) /* ;25 - 40 MHZ */
-
-/*
- * ------SCSI Register-------
- * Control Reg. 4(+34H)
- */
-#define EATER_12NS 0
-#define EATER_25NS BIT(7)
-#define EATER_35NS BIT(6)
-#define EATER_0NS (BIT(7)+BIT(6))
-#define NEGATE_REQACKDATA BIT(2)
-#define NEGATE_REQACK BIT(3)
-
-/*
- *========================================
- * DMA Register
- *========================================
- */
-
-/*
- * -------DMA Register--------
- * DMA Command Reg.(+40H)
- */
-#define READ_DIRECTION BIT(7)
-#define WRITE_DIRECTION 0
-#define EN_DMA_INT BIT(6)
-#define MAP_TO_MDL BIT(5)
-#define DMA_DIAGNOSTIC BIT(4)
-#define DMA_IDLE_CMD 0
-#define DMA_BLAST_CMD BIT(0)
-#define DMA_ABORT_CMD BIT(1)
-#define DMA_START_CMD (BIT(1)|BIT(0))
-
-/*
- * -------DMA Register--------
- * DMA Status Reg.(+54H)
- */
-#define PCI_MS_ABORT BIT(6)
-#define BLAST_COMPLETE BIT(5)
-#define SCSI_INTERRUPT BIT(4)
-#define DMA_XFER_DONE BIT(3)
-#define DMA_XFER_ABORT BIT(2)
-#define DMA_XFER_ERROR BIT(1)
-#define POWER_DOWN BIT(0)
-
-/*
- * -------DMA Register--------
- * DMA SCSI Bus and Ctrl.(+70H)
- * EN_INT_ON_PCI_ABORT
- */
-
-/*
- *==========================================================
- * SCSI Chip register address offset
- *==========================================================
- */
-#define CTCREG_LOW 0x00 /* (R) current transfer count register low */
-#define STCREG_LOW 0x00 /* (W) start transfer count register low */
-
-#define CTCREG_MID 0x04 /* (R) current transfer count register
- * middle */
-#define STCREG_MID 0x04 /* (W) start transfer count register middle */
-
-#define SCSIFIFOREG 0x08 /* (R/W) SCSI FIFO register */
-
-#define SCSICMDREG 0x0C /* (R/W) SCSI command register */
-
-#define SCSISTATREG 0x10 /* (R) SCSI status register */
-#define SCSIDESTIDREG 0x10 /* (W) SCSI destination ID register */
-
-#define INTSTATREG 0x14 /* (R) interrupt status register */
-#define SCSITIMEOUTREG 0x14 /* (W) SCSI timeout register */
-
-
-#define INTERNSTATREG 0x18 /* (R) internal state register */
-#define SYNCPERIOREG 0x18 /* (W) synchronous transfer period register */
-
-#define CURRENTFIFOREG 0x1C /* (R) current FIFO/internal state register */
-#define SYNCOFFREG 0x1C/* (W) synchronous transfer period register */
-
-#define CNTLREG1 0x20 /* (R/W) control register 1 */
-#define CLKFACTREG 0x24 /* (W) clock factor register */
-#define CNTLREG2 0x2C /* (R/W) control register 2 */
-#define CNTLREG3 0x30 /* (R/W) control register 3 */
-#define CNTLREG4 0x34 /* (R/W) control register 4 */
-
-#define CURTXTCNTREG 0x38 /* (R) current transfer count register
- * high/part-unique ID code */
-#define STCREG_HIGH 0x38 /* (W) Start current transfer count register
- * high */
-
-/*
- *********************************************************
- *
- * SCSI DMA register
- *
- *********************************************************
- */
-#define DMA_Cmd 0x40 /* (R/W) command register */
-#define DMA_XferCnt 0x44 /* (R/W) starting transfer count */
-#define DMA_XferAddr 0x48 /* (R/W) starting Physical address */
-#define DMA_Wk_ByteCntr 0x4C /* ( R ) working byte counter */
-#define DMA_Wk_AddrCntr 0x50 /* ( R ) working address counter */
-#define DMA_Status 0x54 /* ( R ) status register */
-#define DMA_MDL_Addr 0x58 /* (R/W) starting memory descriptor list (MDL)
- * address */
-#define DMA_Wk_MDL_Cntr 0x5C /* ( R ) working MDL counter */
-#define DMA_ScsiBusCtrl 0x70 /* (bits R/W) SCSI BUS and control */
-
-/* ******************************************************* */
-#define am_target SCSISTATREG
-#define am_timeout INTSTATREG
-#define am_seq_step SYNCPERIOREG
-#define am_fifo_count SYNCOFFREG
-
-
-#define amd_read8(amd, port) \
- bus_space_read_1((amd)->tag, (amd)->bsh, port)
-
-#define amd_read16(amd, port) \
- bus_space_read_2((amd)->tag, (amd)->bsh, port)
-
-#define amd_read32(amd, port) \
- bus_space_read_4((amd)->tag, (amd)->bsh, port)
-
-#define amd_write8(amd, port, value) \
- bus_space_write_1((amd)->tag, (amd)->bsh, port, value)
-
-#define amd_write8_multi(amd, port, ptr, len) \
- bus_space_write_multi_1((amd)->tag, (amd)->bsh, port, ptr, len)
-
-#define amd_write16(amd, port, value) \
- bus_space_write_2((amd)->tag, (amd)->bsh, port, value)
-
-#define amd_write32(amd, port, value) \
- bus_space_write_4((amd)->tag, (amd)->bsh, port, value)
-
-#endif /* AMD_H */
diff --git a/sys/dev/ar/if_ar.c b/sys/dev/ar/if_ar.c
deleted file mode 100644
index 6f9122c22482..000000000000
--- a/sys/dev/ar/if_ar.c
+++ /dev/null
@@ -1,2390 +0,0 @@
-/*
- * Copyright (c) 1995, 1999 John Hay. 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 author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY John Hay ``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 John Hay 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Programming assumptions and other issues.
- *
- * The descriptors of a DMA channel will fit in a 16K memory window.
- *
- * The buffers of a transmit DMA channel will fit in a 16K memory window.
- *
- * Only the ISA bus cards with X.21 and V.35 is tested.
- *
- * When interface is going up, handshaking is set and it is only cleared
- * when the interface is down'ed.
- *
- * There should be a way to set/reset Raw HDLC/PPP, Loopback, DCE/DTE,
- * internal/external clock, etc.....
- *
- */
-
-#include "opt_netgraph.h"
-#include "ar.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/malloc.h>
-#include <sys/mbuf.h>
-#include <sys/sockio.h>
-#include <sys/socket.h>
-
-#include <net/if.h>
-#ifdef NETGRAPH
-#include <netgraph/ng_message.h>
-#include <netgraph/netgraph.h>
-#include <sys/kernel.h>
-#include <sys/syslog.h>
-#include <i386/isa/if_ar.h>
-#else /* NETGRAPH */
-#include <net/if_sppp.h>
-#include <net/bpf.h>
-#endif /* NETGRAPH */
-
-#include <machine/clock.h>
-#include <machine/md_var.h>
-
-#include <i386/isa/if_arregs.h>
-#include <i386/isa/ic/hd64570.h>
-#include <i386/isa/isa_device.h>
-
-#ifndef NETGRAPH
-#include "sppp.h"
-#if NSPPP <= 0
-#error device 'ar' require sppp.
-#endif /* NSPPP <= 0 */
-#endif /* NETGRAPH */
-
-#ifdef TRACE
-#define TRC(x) x
-#else
-#define TRC(x)
-#endif
-
-#define TRCL(x) x
-
-#define PPP_HEADER_LEN 4
-
-#define ARC_GET_WIN(addr) ((addr >> ARC_WIN_SHFT) & AR_WIN_MSK)
-
-#define ARC_SET_MEM(iobase,win) outb(iobase+AR_MSCA_EN, AR_ENA_MEM | \
- ARC_GET_WIN(win))
-#define ARC_SET_SCA(iobase,ch) outb(iobase+AR_MSCA_EN, AR_ENA_MEM | \
- AR_ENA_SCA | (ch ? AR_SEL_SCA_1:AR_SEL_SCA_0))
-#define ARC_SET_OFF(iobase) outb(iobase+AR_MSCA_EN, 0)
-
-struct ar_hardc {
- int cunit;
- struct ar_softc *sc;
- u_short iobase;
- int isa_irq;
- int numports;
- caddr_t mem_start;
- caddr_t mem_end;
- u_char *orbase;
-
- u_int memsize; /* in bytes */
- u_int winsize; /* in bytes */
- u_int winmsk;
- u_char bustype; /* ISA, MCA, PCI.... */
- u_char interface[NPORT];/* X21, V.35, EIA-530.... */
- u_char revision;
- u_char handshake; /* handshake lines supported by card. */
-
- u_char txc_dtr[NPORT/NCHAN]; /* the register is write only */
- u_int txc_dtr_off[NPORT/NCHAN];
-
- sca_regs *sca[NPORT/NCHAN];
-
-};
-
-static int next_ar_unit = 0;
-static struct ar_hardc ar_hardc[NAR];
-
-struct ar_softc {
-#ifndef NETGRAPH
- struct sppp ifsppp;
-#endif /* NETGRAPH */
- int unit; /* With regards to all ar devices */
- int subunit; /* With regards to this card */
- struct ar_hardc *hc;
-
- struct buf_block {
- u_int txdesc; /* On card address */
- u_int txstart; /* On card address */
- u_int txend; /* On card address */
- u_int txtail; /* Index of first unused buffer */
- u_int txmax; /* number of usable buffers/descriptors */
- u_int txeda; /* Error descriptor addresses */
- }block[AR_TX_BLOCKS];
-
- char xmit_busy; /* Transmitter is busy */
- char txb_inuse; /* Number of tx blocks currently in use */
- u_char txb_new; /* Index to where new buffer will be added */
- u_char txb_next_tx; /* Index to next block ready to tx */
-
- u_int rxdesc; /* On card address */
- u_int rxstart; /* On card address */
- u_int rxend; /* On card address */
- u_int rxhind; /* Index to the head of the rx buffers. */
- u_int rxmax; /* number of usable buffers/descriptors */
-
- int scano;
- int scachan;
- sca_regs *sca;
-#ifdef NETGRAPH
- int running; /* something is attached so we are running */
- int dcd; /* do we have dcd? */
- /* ---netgraph bits --- */
- char nodename[NG_NODELEN + 1]; /* store our node name */
- int datahooks; /* number of data hooks attached */
- node_p node; /* netgraph node */
- hook_p hook; /* data hook */
- hook_p debug_hook;
- struct ifqueue xmitq_hipri; /* hi-priority transmit queue */
- struct ifqueue xmitq; /* transmit queue */
- int flags; /* state */
-#define SCF_RUNNING 0x01 /* board is active */
-#define SCF_OACTIVE 0x02 /* output is active */
- int out_dog; /* watchdog cycles output count-down */
- struct callout_handle handle; /* timeout(9) handle */
- u_long inbytes, outbytes; /* stats */
- u_long lastinbytes, lastoutbytes; /* a second ago */
- u_long inrate, outrate; /* highest rate seen */
- u_long inlast; /* last input N secs ago */
- u_long out_deficit; /* output since last input */
- u_long oerrors, ierrors[6];
- u_long opackets, ipackets;
-#endif /* NETGRAPH */
-};
-
-#ifdef NETGRAPH
-#define DOG_HOLDOFF 6 /* dog holds off for 6 secs */
-#define QUITE_A_WHILE 300 /* 5 MINUTES */
-#define LOTS_OF_PACKETS 100
-#endif /* NETGRAPH */
-
-static int arprobe(struct isa_device *id);
-static int arattach_isa(struct isa_device *id);
-
-/*
- * This translate from irq numbers to
- * the value that the arnet card needs
- * in the lower part of the AR_INT_SEL
- * register.
- */
-static int irqtable[16] = {
- 0, /* 0 */
- 0, /* 1 */
- 0, /* 2 */
- 1, /* 3 */
- 0, /* 4 */
- 2, /* 5 */
- 0, /* 6 */
- 3, /* 7 */
- 0, /* 8 */
- 0, /* 9 */
- 4, /* 10 */
- 5, /* 11 */
- 6, /* 12 */
- 0, /* 13 */
- 0, /* 14 */
- 7 /* 15 */
-};
-
-struct isa_driver ardriver = {arprobe, arattach_isa, "ar"};
-
-struct ar_hardc *arattach_pci(int unit, vm_offset_t mem_addr);
-void arintr_hc(struct ar_hardc *hc);
-
-static ointhand2_t arintr;
-static int arattach(struct ar_hardc *hc);
-static void ar_xmit(struct ar_softc *sc);
-#ifndef NETGRAPH
-static void arstart(struct ifnet *ifp);
-static int arioctl(struct ifnet *ifp, u_long cmd, caddr_t data);
-static void arwatchdog(struct ifnet *ifp);
-#else /* NETGRAPH */
-static void arstart(struct ar_softc *sc);
-static void arwatchdog(struct ar_softc *sc);
-#endif /* NETGRAPH */
-static int ar_packet_avail(struct ar_softc *sc, int *len, u_char *rxstat);
-static void ar_copy_rxbuf(struct mbuf *m, struct ar_softc *sc, int len);
-static void ar_eat_packet(struct ar_softc *sc, int single);
-static void ar_get_packets(struct ar_softc *sc);
-
-static int ar_read_pim_iface(volatile struct ar_hardc *hc, int channel);
-static void ar_up(struct ar_softc *sc);
-static void ar_down(struct ar_softc *sc);
-static void arc_init(struct ar_hardc *hc);
-static void ar_init_sca(struct ar_hardc *hc, int scano);
-static void ar_init_msci(struct ar_softc *sc);
-static void ar_init_rx_dmac(struct ar_softc *sc);
-static void ar_init_tx_dmac(struct ar_softc *sc);
-static void ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr);
-static void ar_msci_intr(struct ar_hardc *hc, int scano, u_char isr);
-static void ar_timer_intr(struct ar_hardc *hc, int scano, u_char isr);
-
-#ifdef NETGRAPH
-static void ngar_watchdog_frame(void * arg);
-static void ngar_init(void* ignored);
-
-static ng_constructor_t ngar_constructor;
-static ng_rcvmsg_t ngar_rcvmsg;
-static ng_shutdown_t ngar_rmnode;
-static ng_newhook_t ngar_newhook;
-/*static ng_findhook_t ngar_findhook; */
-static ng_connect_t ngar_connect;
-static ng_rcvdata_t ngar_rcvdata;
-static ng_disconnect_t ngar_disconnect;
-
-static struct ng_type typestruct = {
- NG_VERSION,
- NG_AR_NODE_TYPE,
- NULL,
- ngar_constructor,
- ngar_rcvmsg,
- ngar_rmnode,
- ngar_newhook,
- NULL,
- ngar_connect,
- ngar_rcvdata,
- ngar_rcvdata,
- ngar_disconnect,
- NULL
-};
-
-static int ngar_done_init = 0;
-#endif /* NETGRAPH */
-
-/*
- * Register the Adapter.
- * Probe to see if it is there.
- * Get its information and fill it in.
- */
-static int
-arprobe(struct isa_device *id)
-{
- struct ar_hardc *hc = &ar_hardc[id->id_unit];
- u_int tmp;
- u_short port;
-
- /*
- * Register the card.
- */
-
- /*
- * Now see if the card is realy there.
- *
- * XXX For now I just check the undocumented ports
- * for "570". We will probably have to do more checking.
- */
- port = id->id_iobase;
-
- if((inb(port+AR_ID_5) != '5') || (inb(port+AR_ID_7) != '7') ||
- (inb(port+AR_ID_0) != '0'))
- return 0;
- /*
- * We have a card here, fill in what we can.
- */
- tmp = inb(port + AR_BMI);
- hc->bustype = tmp & AR_BUS_MSK;
- hc->memsize = (tmp & AR_MEM_MSK) >> AR_MEM_SHFT;
- hc->memsize = 1 << hc->memsize;
- hc->memsize <<= 16;
- hc->interface[0] = (tmp & AR_IFACE_MSK);
- hc->interface[1] = hc->interface[0];
- hc->interface[2] = hc->interface[0];
- hc->interface[3] = hc->interface[0];
- tmp = inb(port + AR_REV);
- hc->revision = tmp & AR_REV_MSK;
- hc->winsize = 1 << ((tmp & AR_WSIZ_MSK) >> AR_WSIZ_SHFT);
- hc->winsize *= ARC_WIN_SIZ;
- hc->winmsk = hc->winsize - 1;
- hc->numports = inb(port + AR_PNUM);
- hc->handshake = inb(port + AR_HNDSH);
-
- id->id_msize = hc->winsize;
-
- hc->iobase = id->id_iobase;
- hc->mem_start = id->id_maddr;
- hc->mem_end = id->id_maddr + id->id_msize;
- hc->cunit = id->id_unit;
- hc->isa_irq = id->id_irq;
-
- switch(hc->interface[0]) {
- case AR_IFACE_EIA_232:
- printf("ar%d: The EIA 232 interface is not supported.\n",
- id->id_unit);
- return 0;
- case AR_IFACE_V_35:
- break;
- case AR_IFACE_EIA_530:
- printf("ar%d: WARNING: The EIA 530 interface is untested.\n",
- id->id_unit);
- break;
- case AR_IFACE_X_21:
- break;
- case AR_IFACE_COMBO:
- printf("ar%d: WARNING: The COMBO interface is untested.\n",
- id->id_unit);
- break;
- }
-
- /*
- * Do a little sanity check.
- */
- if((hc->numports > NPORT) || (hc->memsize > (512*1024)))
- return 0;
-
- return ARC_IO_SIZ; /* return the amount of IO addresses used. */
-}
-
-/*
- * Malloc memory for the softc structures.
- * Reset the card to put it in a known state.
- * Register the ports on the adapter.
- * Fill in the info for each port.
- * Attach each port to sppp and bpf.
- */
-static int
-arattach_isa(struct isa_device *id)
-{
- struct ar_hardc *hc = &ar_hardc[id->id_unit];
- id->id_ointr = arintr;
- return arattach(hc);
-}
-
-struct ar_hardc *
-arattach_pci(int unit, vm_offset_t mem_addr)
-{
- struct ar_hardc *hc;
- u_int i, tmp;
-
- hc = malloc(sizeof(struct ar_hardc), M_DEVBUF, M_WAITOK);
- bzero(hc, sizeof(struct ar_hardc));
-
- hc->cunit = unit;
- hc->mem_start = (caddr_t)mem_addr;
- hc->sca[0] = (sca_regs *)(mem_addr + AR_PCI_SCA_1_OFFSET);
- hc->sca[1] = (sca_regs *)(mem_addr + AR_PCI_SCA_2_OFFSET);
- hc->iobase = 0;
- hc->orbase = (u_char *)(mem_addr + AR_PCI_ORBASE_OFFSET);
-
- tmp = hc->orbase[AR_BMI * 4];
- hc->bustype = tmp & AR_BUS_MSK;
- hc->memsize = (tmp & AR_MEM_MSK) >> AR_MEM_SHFT;
- hc->memsize = 1 << hc->memsize;
- hc->memsize <<= 16;
- hc->interface[0] = (tmp & AR_IFACE_MSK);
- tmp = hc->orbase[AR_REV * 4];
- hc->revision = tmp & AR_REV_MSK;
- hc->winsize = (1 << ((tmp & AR_WSIZ_MSK) >> AR_WSIZ_SHFT)) * 16 * 1024;
- hc->mem_end = (caddr_t)(mem_addr + hc->winsize);
- hc->winmsk = hc->winsize - 1;
- hc->numports = hc->orbase[AR_PNUM * 4];
- hc->handshake = hc->orbase[AR_HNDSH * 4];
-
- for(i = 1; i < hc->numports; i++)
- hc->interface[i] = hc->interface[0];
-
- TRC(printf("arp%d: bus %x, rev %d, memstart %p, winsize %d, "
- "winmsk %x, interface %x\n",
- unit, hc->bustype, hc->revision, hc->mem_start, hc->winsize,
- hc->winmsk, hc->interface[0]));
-
- arattach(hc);
- return hc;
-}
-
-static int
-arattach(struct ar_hardc *hc)
-{
- struct ar_softc *sc;
-#ifndef NETGRAPH
- struct ifnet *ifp;
- char *iface;
-#endif /* NETGRAPH */
- int unit;
-
- printf("arc%d: %uK RAM, %u ports, rev %u.\n",
- hc->cunit,
- hc->memsize/1024,
- hc->numports,
- hc->revision);
-
- arc_init(hc);
-
- sc = hc->sc;
-
- for(unit=0;unit<hc->numports;unit+=NCHAN)
- ar_init_sca(hc, unit / NCHAN);
-
- /*
- * Now configure each port on the card.
- */
- for(unit=0;unit<hc->numports;sc++,unit++) {
- sc->hc = hc;
- sc->subunit = unit;
- sc->unit = next_ar_unit;
- next_ar_unit++;
- sc->scano = unit / NCHAN;
- sc->scachan = unit%NCHAN;
-
- ar_init_rx_dmac(sc);
- ar_init_tx_dmac(sc);
- ar_init_msci(sc);
-
-#ifndef NETGRAPH
- ifp = &sc->ifsppp.pp_if;
-
- ifp->if_softc = sc;
- ifp->if_unit = sc->unit;
- ifp->if_name = "ar";
- ifp->if_mtu = PP_MTU;
- ifp->if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
- ifp->if_ioctl = arioctl;
- ifp->if_start = arstart;
- ifp->if_watchdog = arwatchdog;
-
- sc->ifsppp.pp_flags = PP_KEEPALIVE;
-
- switch(hc->interface[unit]) {
- default: iface = "UNKNOWN"; break;
- case AR_IFACE_EIA_232: iface = "EIA-232"; break;
- case AR_IFACE_V_35: iface = "EIA-232 or V.35"; break;
- case AR_IFACE_EIA_530: iface = "EIA-530"; break;
- case AR_IFACE_X_21: iface = "X.21"; break;
- case AR_IFACE_COMBO: iface = "COMBO X.21 / EIA-530"; break;
- }
-
- printf("ar%d: Adapter %d, port %d, interface %s.\n",
- sc->unit,
- hc->cunit,
- sc->subunit,
- iface);
-
- sppp_attach((struct ifnet *)&sc->ifsppp);
- if_attach(ifp);
-
- bpfattach(ifp, DLT_PPP, PPP_HEADER_LEN);
-#else /* NETGRAPH */
- /*
- * we have found a node, make sure our 'type' is availabe.
- */
- if (ngar_done_init == 0) ngar_init(NULL);
- if (ng_make_node_common(&typestruct, &sc->node) != 0)
- return (0);
- sc->node->private = sc;
- callout_handle_init(&sc->handle);
- sc->xmitq.ifq_maxlen = IFQ_MAXLEN;
- sc->xmitq_hipri.ifq_maxlen = IFQ_MAXLEN;
- sprintf(sc->nodename, "%s%d", NG_AR_NODE_TYPE, sc->unit);
- if (ng_name_node(sc->node, sc->nodename)) {
- ng_rmnode(sc->node);
- ng_unref(sc->node);
- return (0);
- }
- sc->running = 0;
-#endif /* NETGRAPH */
- }
-
- if(hc->bustype == AR_BUS_ISA)
- ARC_SET_OFF(hc->iobase);
-
- return 1;
-}
-
-/*
- * First figure out which SCA gave the interrupt.
- * Process it.
- * See if there is other interrupts pending.
- * Repeat until there is no more interrupts.
- */
-static void
-arintr(int unit)
-{
- struct ar_hardc *hc;
-
- hc = &ar_hardc[unit];
- arintr_hc(hc);
- return;
-}
-
-void
-arintr_hc(struct ar_hardc *hc)
-{
- sca_regs *sca;
- u_char isr0, isr1, isr2, arisr;
- int scano;
-
- /* XXX Use the PCI interrupt score board register later */
- if(hc->bustype == AR_BUS_PCI)
- arisr = hc->orbase[AR_ISTAT * 4];
- else
- arisr = inb(hc->iobase + AR_ISTAT);
-
- while(arisr & AR_BD_INT) {
- TRC(printf("arisr = %x\n", arisr));
- if(arisr & AR_INT_0)
- scano = 0;
- else if(arisr & AR_INT_1)
- scano = 1;
- else {
- /* XXX Oops this shouldn't happen. */
- printf("arc%d: Interrupted with no interrupt.\n",
- hc->cunit);
- return;
- }
- sca = hc->sca[scano];
-
- if(hc->bustype == AR_BUS_ISA)
- ARC_SET_SCA(hc->iobase, scano);
-
- isr0 = sca->isr0;
- isr1 = sca->isr1;
- isr2 = sca->isr2;
-
- TRC(printf("arc%d: ARINTR isr0 %x, isr1 %x, isr2 %x\n",
- hc->cunit,
- isr0,
- isr1,
- isr2));
- if(isr0)
- ar_msci_intr(hc, scano, isr0);
-
- if(isr1)
- ar_dmac_intr(hc, scano, isr1);
-
- if(isr2)
- ar_timer_intr(hc, scano, isr2);
-
- /*
- * Proccess the second sca's interrupt if available.
- * Else see if there are any new interrupts.
- */
- if((arisr & AR_INT_0) && (arisr & AR_INT_1))
- arisr &= ~AR_INT_0;
- else {
- if(hc->bustype == AR_BUS_PCI)
- arisr = hc->orbase[AR_ISTAT * 4];
- else
- arisr = inb(hc->iobase + AR_ISTAT);
- }
- }
-
- if(hc->bustype == AR_BUS_ISA)
- ARC_SET_OFF(hc->iobase);
-}
-
-
-/*
- * This will only start the transmitter. It is assumed that the data
- * is already there. It is normally called from arstart() or ar_dmac_intr().
- *
- */
-static void
-ar_xmit(struct ar_softc *sc)
-{
-#ifndef NETGRAPH
- struct ifnet *ifp;
-#endif /* NETGRAPH */
- dmac_channel *dmac;
-
-#ifndef NETGRAPH
- ifp = &sc->ifsppp.pp_if;
-#endif /* NETGRAPH */
- dmac = &sc->sca->dmac[DMAC_TXCH(sc->scachan)];
-
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_SCA(sc->hc->iobase, sc->scano);
- dmac->cda = (u_short)(sc->block[sc->txb_next_tx].txdesc & 0xffff);
-
- dmac->eda = (u_short)(sc->block[sc->txb_next_tx].txeda & 0xffff);
- dmac->dsr = SCA_DSR_DE;
-
- sc->xmit_busy = 1;
-
- sc->txb_next_tx++;
- if(sc->txb_next_tx == AR_TX_BLOCKS)
- sc->txb_next_tx = 0;
-
-#ifndef NETGRAPH
- ifp->if_timer = 2; /* Value in seconds. */
-#else /* NETGRAPH */
- sc->out_dog = DOG_HOLDOFF; /* give ourself some breathing space*/
-#endif /* NETGRAPH */
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_OFF(sc->hc->iobase);
-}
-
-/*
- * This function will be called from the upper level when a user add a
- * packet to be send, and from the interrupt handler after a finished
- * transmit.
- *
- * NOTE: it should run at spl_imp().
- *
- * This function only place the data in the oncard buffers. It does not
- * start the transmition. ar_xmit() does that.
- *
- * Transmitter idle state is indicated by the IFF_OACTIVE flag. The function
- * that clears that should ensure that the transmitter and its DMA is
- * in a "good" idle state.
- */
-#ifndef NETGRAPH
-static void
-arstart(struct ifnet *ifp)
-{
- struct ar_softc *sc = ifp->if_softc;
-#else /* NETGRAPH */
-static void
-arstart(struct ar_softc *sc)
-{
-#endif /* NETGRAPH */
- int i, len, tlen;
- struct mbuf *mtx;
- u_char *txdata;
- sca_descriptor *txdesc;
- struct buf_block *blkp;
-
-#ifndef NETGRAPH
- if(!(ifp->if_flags & IFF_RUNNING))
- return;
-#else /* NETGRAPH */
-/* XXX */
-#endif /* NETGRAPH */
-
-top_arstart:
-
- /*
- * See if we have space for more packets.
- */
- if(sc->txb_inuse == AR_TX_BLOCKS) {
-#ifndef NETGRAPH
- ifp->if_flags |= IFF_OACTIVE; /* yes, mark active */
-#else /* NETGRAPH */
-/*XXX*/ /*ifp->if_flags |= IFF_OACTIVE;*/ /* yes, mark active */
-#endif /* NETGRAPH */
- return;
- }
-
-#ifndef NETGRAPH
- mtx = sppp_dequeue(ifp);
-#else /* NETGRAPH */
- IF_DEQUEUE(&sc->xmitq_hipri, mtx);
- if (mtx == NULL) {
- IF_DEQUEUE(&sc->xmitq, mtx);
- }
-#endif /* NETGRAPH */
- if(!mtx)
- return;
-
- /*
- * It is OK to set the memory window outside the loop because
- * all tx buffers and descriptors are assumed to be in the same
- * 16K window.
- */
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_MEM(sc->hc->iobase, sc->block[0].txdesc);
-
- /*
- * We stay in this loop until there is nothing in the
- * TX queue left or the tx buffer is full.
- */
- i = 0;
- blkp = &sc->block[sc->txb_new];
- txdesc = (sca_descriptor *)
- (sc->hc->mem_start + (blkp->txdesc & sc->hc->winmsk));
- txdata = (u_char *)(sc->hc->mem_start + (blkp->txstart & sc->hc->winmsk));
- for(;;) {
- len = mtx->m_pkthdr.len;
-
- TRC(printf("ar%d: ARstart len %u\n", sc->unit, len));
-
- /*
- * We can do this because the tx buffers don't wrap.
- */
- m_copydata(mtx, 0, len, txdata);
- tlen = len;
- while(tlen > AR_BUF_SIZ) {
- txdesc->stat = 0;
- txdesc->len = AR_BUF_SIZ;
- tlen -= AR_BUF_SIZ;
- txdesc++;
- txdata += AR_BUF_SIZ;
- i++;
- }
- /* XXX Move into the loop? */
- txdesc->stat = SCA_DESC_EOM;
- txdesc->len = tlen;
- txdesc++;
- txdata += AR_BUF_SIZ;
- i++;
-
-#ifndef NETGRAPH
- if(ifp->if_bpf)
- bpf_mtap(ifp, mtx);
- m_freem(mtx);
- ++sc->ifsppp.pp_if.if_opackets;
-#else /* NETGRAPH */
- m_freem(mtx);
- sc->outbytes += len;
- ++sc->opackets;
-#endif /* NETGRAPH */
-
- /*
- * Check if we have space for another mbuf.
- * XXX This is hardcoded. A packet won't be larger
- * than 3 buffers (3 x 512).
- */
- if((i + 3) >= blkp->txmax)
- break;
-
-#ifndef NETGRAPH
- mtx = sppp_dequeue(ifp);
-#else /* NETGRAPH */
- IF_DEQUEUE(&sc->xmitq_hipri, mtx);
- if (mtx == NULL) {
- IF_DEQUEUE(&sc->xmitq, mtx);
- }
-#endif /* NETGRAPH */
- if(!mtx)
- break;
- }
-
- blkp->txtail = i;
-
- /*
- * Mark the last descriptor, so that the SCA know where
- * to stop.
- */
- txdesc--;
- txdesc->stat |= SCA_DESC_EOT;
-
- txdesc = (sca_descriptor *)blkp->txdesc;
- blkp->txeda = (u_short)((u_int)&txdesc[i]);
-
-#if 0
- printf("ARstart: %p desc->cp %x\n", &txdesc->cp, txdesc->cp);
- printf("ARstart: %p desc->bp %x\n", &txdesc->bp, txdesc->bp);
- printf("ARstart: %p desc->bpb %x\n", &txdesc->bpb, txdesc->bpb);
- printf("ARstart: %p desc->len %x\n", &txdesc->len, txdesc->len);
- printf("ARstart: %p desc->stat %x\n", &txdesc->stat, txdesc->stat);
-#endif
-
- sc->txb_inuse++;
- sc->txb_new++;
- if(sc->txb_new == AR_TX_BLOCKS)
- sc->txb_new = 0;
-
- if(sc->xmit_busy == 0)
- ar_xmit(sc);
-
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_OFF(sc->hc->iobase);
-
- goto top_arstart;
-}
-
-#ifndef NETGRAPH
-static int
-arioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
-{
- int s, error;
- int was_up, should_be_up;
- struct ar_softc *sc = ifp->if_softc;
-
- TRC(printf("ar%d: arioctl.\n", ifp->if_unit);)
-
- was_up = ifp->if_flags & IFF_RUNNING;
-
- error = sppp_ioctl(ifp, cmd, data);
- TRC(printf("ar%d: ioctl: ifsppp.pp_flags = %x, if_flags %x.\n",
- ifp->if_unit, ((struct sppp *)ifp)->pp_flags, ifp->if_flags);)
- if(error)
- return error;
-
- if((cmd != SIOCSIFFLAGS) && cmd != (SIOCSIFADDR))
- return 0;
-
- TRC(printf("ar%d: arioctl %s.\n", ifp->if_unit,
- (cmd == SIOCSIFFLAGS) ? "SIOCSIFFLAGS" : "SIOCSIFADDR");)
-
- s = splimp();
- should_be_up = ifp->if_flags & IFF_RUNNING;
-
- if(!was_up && should_be_up) {
- /* Interface should be up -- start it. */
- ar_up(sc);
- arstart(ifp);
- /* XXX Maybe clear the IFF_UP flag so that the link
- * will only go up after sppp lcp and ipcp negotiation.
- */
- } else if(was_up && !should_be_up) {
- /* Interface should be down -- stop it. */
- ar_down(sc);
- sppp_flush(ifp);
- }
- splx(s);
- return 0;
-}
-#endif /* NETGRAPH */
-
-/*
- * This is to catch lost tx interrupts.
- */
-static void
-#ifndef NETGRAPH
-arwatchdog(struct ifnet *ifp)
-{
- struct ar_softc *sc = ifp->if_softc;
-#else /* NETGRAPH */
-arwatchdog(struct ar_softc *sc)
-{
-#endif /* NETGRAPH */
- msci_channel *msci = &sc->sca->msci[sc->scachan];
-
-#ifndef NETGRAPH
- if(!(ifp->if_flags & IFF_RUNNING))
- return;
-#endif /* NETGRAPH */
-
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_SCA(sc->hc->iobase, sc->scano);
-
- /* XXX if(sc->ifsppp.pp_if.if_flags & IFF_DEBUG) */
- printf("ar%d: transmit failed, "
- "ST0 %x, ST1 %x, ST3 %x, DSR %x.\n",
- sc->unit,
- msci->st0,
- msci->st1,
- msci->st3,
- sc->sca->dmac[DMAC_TXCH(sc->scachan)].dsr);
-
- if(msci->st1 & SCA_ST1_UDRN) {
- msci->cmd = SCA_CMD_TXABORT;
- msci->cmd = SCA_CMD_TXENABLE;
- msci->st1 = SCA_ST1_UDRN;
- }
-
- sc->xmit_busy = 0;
-#ifndef NETGRAPH
- ifp->if_flags &= ~IFF_OACTIVE;
-#else /* NETGRAPH */
- /* XXX ifp->if_flags &= ~IFF_OACTIVE; */
-#endif /* NETGRAPH */
-
- if(sc->txb_inuse && --sc->txb_inuse)
- ar_xmit(sc);
-
-#ifndef NETGRAPH
- arstart(ifp);
-#else /* NETGRAPH */
- arstart(sc);
-#endif /* NETGRAPH */
-}
-
-static void
-ar_up(struct ar_softc *sc)
-{
- sca_regs *sca;
- msci_channel *msci;
-
- sca = sc->sca;
- msci = &sca->msci[sc->scachan];
-
- TRC(printf("ar%d: sca %p, msci %p, ch %d\n",
- sc->unit, sca, msci, sc->scachan));
-
- /*
- * Enable transmitter and receiver.
- * Raise DTR and RTS.
- * Enable interrupts.
- */
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_SCA(sc->hc->iobase, sc->scano);
-
- /* XXX
- * What about using AUTO mode in msci->md0 ???
- * And what about CTS/DCD etc... ?
- */
- if(sc->hc->handshake & AR_SHSK_RTS)
- msci->ctl &= ~SCA_CTL_RTS;
- if(sc->hc->handshake & AR_SHSK_DTR) {
- sc->hc->txc_dtr[sc->scano] &= sc->scachan ?
- ~AR_TXC_DTR_DTR1 : ~AR_TXC_DTR_DTR0;
- if(sc->hc->bustype == AR_BUS_PCI)
- sc->hc->orbase[sc->hc->txc_dtr_off[sc->scano]] =
- sc->hc->txc_dtr[sc->scano];
- else
- outb(sc->hc->iobase + sc->hc->txc_dtr_off[sc->scano],
- sc->hc->txc_dtr[sc->scano]);
- }
-
- if(sc->scachan == 0) {
- sca->ier0 |= 0x0F;
- sca->ier1 |= 0x0F;
- } else {
- sca->ier0 |= 0xF0;
- sca->ier1 |= 0xF0;
- }
-
- msci->cmd = SCA_CMD_RXENABLE;
- if(sc->hc->bustype == AR_BUS_ISA)
- inb(sc->hc->iobase + AR_ID_5); /* XXX slow it down a bit. */
- msci->cmd = SCA_CMD_TXENABLE;
-
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_OFF(sc->hc->iobase);
-#ifdef NETGRAPH
- untimeout(ngar_watchdog_frame, sc, sc->handle);
- sc->handle = timeout(ngar_watchdog_frame, sc, hz);
- sc->running = 1;
-#endif /* NETGRAPH */
-}
-
-static void
-ar_down(struct ar_softc *sc)
-{
- sca_regs *sca;
- msci_channel *msci;
-
- sca = sc->sca;
- msci = &sca->msci[sc->scachan];
-
-#ifdef NETGRAPH
- untimeout(ngar_watchdog_frame, sc, sc->handle);
- sc->running = 0;
-#endif /* NETGRAPH */
- /*
- * Disable transmitter and receiver.
- * Lower DTR and RTS.
- * Disable interrupts.
- */
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_SCA(sc->hc->iobase, sc->scano);
- msci->cmd = SCA_CMD_RXDISABLE;
- if(sc->hc->bustype == AR_BUS_ISA)
- inb(sc->hc->iobase + AR_ID_5); /* XXX slow it down a bit. */
- msci->cmd = SCA_CMD_TXDISABLE;
-
- if(sc->hc->handshake & AR_SHSK_RTS)
- msci->ctl |= SCA_CTL_RTS;
- if(sc->hc->handshake & AR_SHSK_DTR) {
- sc->hc->txc_dtr[sc->scano] |= sc->scachan ?
- AR_TXC_DTR_DTR1 : AR_TXC_DTR_DTR0;
- if(sc->hc->bustype == AR_BUS_PCI)
- sc->hc->orbase[sc->hc->txc_dtr_off[sc->scano]] =
- sc->hc->txc_dtr[sc->scano];
- else
- outb(sc->hc->iobase + sc->hc->txc_dtr_off[sc->scano],
- sc->hc->txc_dtr[sc->scano]);
- }
-
- if(sc->scachan == 0) {
- sca->ier0 &= ~0x0F;
- sca->ier1 &= ~0x0F;
- } else {
- sca->ier0 &= ~0xF0;
- sca->ier1 &= ~0xF0;
- }
-
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_OFF(sc->hc->iobase);
-}
-
-static int
-ar_read_pim_iface(volatile struct ar_hardc *hc, int channel)
-{
- int ctype, i, val, x;
- volatile u_char *pimctrl;
-
- ctype = 0;
- val = 0;
-
- pimctrl = hc->orbase + AR_PIMCTRL;
-
- /* Reset the PIM */
- *pimctrl = 0x00;
- *pimctrl = AR_PIM_STROBE;
-
- /* Check if there is a PIM */
- *pimctrl = 0x00;
- *pimctrl = AR_PIM_READ;
- x = *pimctrl;
- TRC(printf("x = %x", x));
- if(x & AR_PIM_DATA) {
- printf("No PIM installed\n");
- return(AR_IFACE_UNKNOWN);
- }
-
- x = (x >> 1) & 0x01;
- val |= x << 0;
-
- /* Now read the next 15 bits */
- for(i = 1; i < 16; i++) {
- *pimctrl = AR_PIM_READ;
- *pimctrl = AR_PIM_READ | AR_PIM_STROBE;
- x = *pimctrl;
- TRC(printf(" %x ", x));
- x = (x >> 1) & 0x01;
- val |= x << i;
- if(i == 8 && (val & 0x000f) == 0x0004) {
- int ii;
-
- /* Start bit */
- *pimctrl = AR_PIM_A2D_DOUT | AR_PIM_A2D_STROBE;
- *pimctrl = AR_PIM_A2D_DOUT;
-
- /* Mode bit */
- *pimctrl = AR_PIM_A2D_DOUT | AR_PIM_A2D_STROBE;
- *pimctrl = AR_PIM_A2D_DOUT;
-
- /* Sign bit */
- *pimctrl = AR_PIM_A2D_DOUT | AR_PIM_A2D_STROBE;
- *pimctrl = AR_PIM_A2D_DOUT;
-
- /* Select channel */
- *pimctrl = AR_PIM_A2D_STROBE | ((channel & 2) << 2);
- *pimctrl = ((channel & 2) << 2);
- *pimctrl = AR_PIM_A2D_STROBE | ((channel & 1) << 3);
- *pimctrl = ((channel & 1) << 3);
-
- *pimctrl = AR_PIM_A2D_STROBE;
-
- x = *pimctrl;
- if(x & AR_PIM_DATA)
- printf("\nOops A2D start bit not zero (%X)\n", x);
-
- for(ii = 7; ii >= 0; ii--) {
- *pimctrl = 0x00;
- *pimctrl = AR_PIM_A2D_STROBE;
- x = *pimctrl;
- if(x & AR_PIM_DATA)
- ctype |= 1 << ii;
- }
- }
- }
- TRC(printf("\nPIM val %x, ctype %x, %d\n", val, ctype, ctype));
- *pimctrl = AR_PIM_MODEG;
- *pimctrl = AR_PIM_MODEG | AR_PIM_AUTO_LED;
- if(ctype > 255)
- return(AR_IFACE_UNKNOWN);
- if(ctype > 239)
- return(AR_IFACE_V_35);
- if(ctype > 207)
- return(AR_IFACE_EIA_232);
- if(ctype > 178)
- return(AR_IFACE_X_21);
- if(ctype > 150)
- return(AR_IFACE_EIA_530);
- if(ctype > 25)
- return(AR_IFACE_UNKNOWN);
- if(ctype > 7)
- return(AR_IFACE_LOOPBACK);
- return(AR_IFACE_UNKNOWN);
-}
-
-/*
- * Initialize the card, allocate memory for the ar_softc structures
- * and fill in the pointers.
- */
-static void
-arc_init(struct ar_hardc *hc)
-{
- struct ar_softc *sc;
- int x;
- u_int chanmem;
- u_int bufmem;
- u_int next;
- u_int descneeded;
- u_char isr, mar;
-
- MALLOC(sc, struct ar_softc *,
- hc->numports * sizeof(struct ar_softc), M_DEVBUF, M_WAITOK);
- if (sc == NULL)
- return;
- bzero(sc, hc->numports * sizeof(struct ar_softc));
- hc->sc = sc;
-
- hc->txc_dtr[0] = AR_TXC_DTR_NOTRESET |
- AR_TXC_DTR_DTR0 | AR_TXC_DTR_DTR1;
- hc->txc_dtr[1] = AR_TXC_DTR_DTR0 | AR_TXC_DTR_DTR1;
- hc->txc_dtr_off[0] = AR_TXC_DTR0;
- hc->txc_dtr_off[1] = AR_TXC_DTR2;
- if(hc->bustype == AR_BUS_PCI) {
- hc->txc_dtr_off[0] *= 4;
- hc->txc_dtr_off[1] *= 4;
- }
-
- /*
- * reset the card and wait at least 1uS.
- */
- if(hc->bustype == AR_BUS_PCI)
- hc->orbase[AR_TXC_DTR0 * 4] = ~AR_TXC_DTR_NOTRESET &
- hc->txc_dtr[0];
- else
- outb(hc->iobase + AR_TXC_DTR0, ~AR_TXC_DTR_NOTRESET &
- hc->txc_dtr[0]);
- DELAY(2);
- if(hc->bustype == AR_BUS_PCI)
- hc->orbase[AR_TXC_DTR0 * 4] = hc->txc_dtr[0];
- else
- outb(hc->iobase + AR_TXC_DTR0, hc->txc_dtr[0]);
-
- if(hc->bustype == AR_BUS_ISA) {
- /*
- * Configure the card.
- * Mem address, irq,
- */
- mar = kvtop(hc->mem_start) >> 16;
- isr = irqtable[ffs(hc->isa_irq) - 1] << 1;
- if(isr == 0)
- printf("ar%d: Warning illegal interrupt %d\n",
- hc->cunit, ffs(hc->isa_irq) - 1);
- isr = isr | ((kvtop(hc->mem_start) & 0xc000) >> 10);
-
- hc->sca[0] = (sca_regs *)hc->mem_start;
- hc->sca[1] = (sca_regs *)hc->mem_start;
-
- outb(hc->iobase + AR_MEM_SEL, mar);
- outb(hc->iobase + AR_INT_SEL, isr | AR_INTS_CEN);
- }
-
- if(hc->bustype == AR_BUS_PCI && hc->interface[0] == AR_IFACE_PIM)
- for(x = 0; x < hc->numports; x++)
- hc->interface[x] = ar_read_pim_iface(hc, x);
-
- /*
- * Set the TX clock direction and enable TX.
- */
- for(x=0;x<hc->numports;x++) {
- switch(hc->interface[x]) {
- case AR_IFACE_V_35:
- hc->txc_dtr[x / NCHAN] |= (x % NCHAN == 0) ?
- AR_TXC_DTR_TX0 : AR_TXC_DTR_TX1;
- hc->txc_dtr[x / NCHAN] |= (x % NCHAN == 0) ?
- AR_TXC_DTR_TXCS0 : AR_TXC_DTR_TXCS1;
- break;
- case AR_IFACE_EIA_530:
- case AR_IFACE_COMBO:
- case AR_IFACE_X_21:
- hc->txc_dtr[x / NCHAN] |= (x % NCHAN == 0) ?
- AR_TXC_DTR_TX0 : AR_TXC_DTR_TX1;
- break;
- }
- }
-
- if(hc->bustype == AR_BUS_PCI)
- hc->orbase[AR_TXC_DTR0 * 4] = hc->txc_dtr[0];
- else
- outb(hc->iobase + AR_TXC_DTR0, hc->txc_dtr[0]);
- if(hc->numports > NCHAN) {
- if(hc->bustype == AR_BUS_PCI)
- hc->orbase[AR_TXC_DTR2 * 4] = hc->txc_dtr[1];
- else
- outb(hc->iobase + AR_TXC_DTR2, hc->txc_dtr[1]);
- }
-
- chanmem = hc->memsize / hc->numports;
- next = 0;
-
- for(x=0;x<hc->numports;x++, sc++) {
- int blk;
-
- sc->sca = hc->sca[x / NCHAN];
-
- for(blk = 0; blk < AR_TX_BLOCKS; blk++) {
- sc->block[blk].txdesc = next;
- bufmem = (16 * 1024) / AR_TX_BLOCKS;
- descneeded = bufmem / AR_BUF_SIZ;
- sc->block[blk].txstart = sc->block[blk].txdesc +
- ((((descneeded * sizeof(sca_descriptor)) /
- AR_BUF_SIZ) + 1) * AR_BUF_SIZ);
- sc->block[blk].txend = next + bufmem;
- sc->block[blk].txmax =
- (sc->block[blk].txend - sc->block[blk].txstart)
- / AR_BUF_SIZ;
- next += bufmem;
-
- TRC(printf("ar%d: blk %d: txdesc %x, txstart %x, "
- "txend %x, txmax %d\n",
- x,
- blk,
- sc->block[blk].txdesc,
- sc->block[blk].txstart,
- sc->block[blk].txend,
- sc->block[blk].txmax));
- }
-
- sc->rxdesc = next;
- bufmem = chanmem - (bufmem * AR_TX_BLOCKS);
- descneeded = bufmem / AR_BUF_SIZ;
- sc->rxstart = sc->rxdesc +
- ((((descneeded * sizeof(sca_descriptor)) /
- AR_BUF_SIZ) + 1) * AR_BUF_SIZ);
- sc->rxend = next + bufmem;
- sc->rxmax = (sc->rxend - sc->rxstart) / AR_BUF_SIZ;
- next += bufmem;
- TRC(printf("ar%d: rxdesc %x, rxstart %x, "
- "rxend %x, rxmax %d\n",
- x, sc->rxdesc, sc->rxstart, sc->rxend, sc->rxmax));
- }
-
- if(hc->bustype == AR_BUS_PCI)
- hc->orbase[AR_PIMCTRL] = AR_PIM_MODEG | AR_PIM_AUTO_LED;
-}
-
-
-/*
- * The things done here are channel independent.
- *
- * Configure the sca waitstates.
- * Configure the global interrupt registers.
- * Enable master dma enable.
- */
-static void
-ar_init_sca(struct ar_hardc *hc, int scano)
-{
- sca_regs *sca;
-
- sca = hc->sca[scano];
- if(hc->bustype == AR_BUS_ISA)
- ARC_SET_SCA(hc->iobase, scano);
-
- /*
- * Do the wait registers.
- * Set everything to 0 wait states.
- */
- sca->pabr0 = 0;
- sca->pabr1 = 0;
- sca->wcrl = 0;
- sca->wcrm = 0;
- sca->wcrh = 0;
-
- /*
- * Configure the interrupt registers.
- * Most are cleared until the interface is configured.
- */
- sca->ier0 = 0x00; /* MSCI interrupts... Not used with dma. */
- sca->ier1 = 0x00; /* DMAC interrupts */
- sca->ier2 = 0x00; /* TIMER interrupts... Not used yet. */
- sca->itcr = 0x00; /* Use ivr and no intr ack */
- sca->ivr = 0x40; /* Fill in the interrupt vector. */
- sca->imvr = 0x40;
-
- /*
- * Configure the timers.
- * XXX Later
- */
-
-
- /*
- * Set the DMA channel priority to rotate between
- * all four channels.
- *
- * Enable all dma channels.
- */
- if(hc->bustype == AR_BUS_PCI) {
- u_char *t;
-
- /*
- * Stupid problem with the PCI interface chip that break
- * things.
- * XXX
- */
- t = (u_char *)sca;
- t[AR_PCI_SCA_PCR] = SCA_PCR_PR2;
- t[AR_PCI_SCA_DMER] = SCA_DMER_EN;
- } else {
- sca->pcr = SCA_PCR_PR2;
- sca->dmer = SCA_DMER_EN;
- }
-}
-
-
-/*
- * Configure the msci
- *
- * NOTE: The serial port configuration is hardcoded at the moment.
- */
-static void
-ar_init_msci(struct ar_softc *sc)
-{
- msci_channel *msci;
-
- msci = &sc->sca->msci[sc->scachan];
-
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_SCA(sc->hc->iobase, sc->scano);
-
- msci->cmd = SCA_CMD_RESET;
-
- msci->md0 = SCA_MD0_CRC_1 |
- SCA_MD0_CRC_CCITT |
- SCA_MD0_CRC_ENABLE |
- SCA_MD0_MODE_HDLC;
- msci->md1 = SCA_MD1_NOADDRCHK;
- msci->md2 = SCA_MD2_DUPLEX | SCA_MD2_NRZ;
-
- /*
- * Acording to the manual I should give a reset after changing the
- * mode registers.
- */
- msci->cmd = SCA_CMD_RXRESET;
- msci->ctl = SCA_CTL_IDLPAT | SCA_CTL_UDRNC | SCA_CTL_RTS;
-
- /*
- * For now all interfaces are programmed to use the RX clock for
- * the TX clock.
- */
- switch(sc->hc->interface[sc->subunit]) {
- case AR_IFACE_V_35:
- msci->rxs = SCA_RXS_CLK_RXC0 | SCA_RXS_DIV1;
- msci->txs = SCA_TXS_CLK_TXC | SCA_TXS_DIV1;
- break;
- case AR_IFACE_X_21:
- case AR_IFACE_EIA_530:
- case AR_IFACE_COMBO:
- msci->rxs = SCA_RXS_CLK_RXC0 | SCA_RXS_DIV1;
- msci->txs = SCA_TXS_CLK_RX | SCA_TXS_DIV1;
- }
-
- msci->tmc = 153; /* This give 64k for loopback */
-
- /* XXX
- * Disable all interrupts for now. I think if you are using
- * the dmac you don't use these interrupts.
- */
- msci->ie0 = 0;
- msci->ie1 = 0x0C; /* XXX CTS and DCD (DSR on 570I) level change. */
- msci->ie2 = 0;
- msci->fie = 0;
-
- msci->sa0 = 0;
- msci->sa1 = 0;
-
- msci->idl = 0x7E; /* XXX This is what cisco does. */
-
- /*
- * This is what the ARNET diags use.
- */
- msci->rrc = 0x0E;
- msci->trc0 = 0x12;
- msci->trc1 = 0x1F;
-}
-
-/*
- * Configure the rx dma controller.
- */
-static void
-ar_init_rx_dmac(struct ar_softc *sc)
-{
- dmac_channel *dmac;
- sca_descriptor *rxd;
- u_int rxbuf;
- u_int rxda;
- u_int rxda_d;
- int x = 0;
-
- dmac = &sc->sca->dmac[DMAC_RXCH(sc->scachan)];
-
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_MEM(sc->hc->iobase, sc->rxdesc);
-
- rxd = (sca_descriptor *)(sc->hc->mem_start + (sc->rxdesc&sc->hc->winmsk));
- rxda_d = (u_int)sc->hc->mem_start - (sc->rxdesc & ~sc->hc->winmsk);
-
- for(rxbuf=sc->rxstart;rxbuf<sc->rxend;rxbuf += AR_BUF_SIZ, rxd++) {
- rxda = (u_int)&rxd[1] - rxda_d;
- rxd->cp = (u_short)(rxda & 0xfffful);
-
- x++;
- if(x < 6)
- TRC(printf("Descrp %p, data pt %x, data %x, ",
- rxd, rxda, rxbuf));
-
- rxd->bp = (u_short)(rxbuf & 0xfffful);
- rxd->bpb = (u_char)((rxbuf >> 16) & 0xff);
- rxd->len = 0;
- rxd->stat = 0xff; /* The sca write here when it is finished. */
-
- if(x < 6)
- TRC(printf("bpb %x, bp %x.\n", rxd->bpb, rxd->bp));
- }
- rxd--;
- rxd->cp = (u_short)(sc->rxdesc & 0xfffful);
-
- sc->rxhind = 0;
-
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_SCA(sc->hc->iobase, sc->scano);
-
- dmac->dsr = 0; /* Disable DMA transfer */
- dmac->dcr = SCA_DCR_ABRT;
-
- /* XXX maybe also SCA_DMR_CNTE */
- dmac->dmr = SCA_DMR_TMOD | SCA_DMR_NF;
- dmac->bfl = AR_BUF_SIZ;
-
- dmac->cda = (u_short)(sc->rxdesc & 0xffff);
- dmac->sarb = (u_char)((sc->rxdesc >> 16) & 0xff);
-
- rxd = (sca_descriptor *)sc->rxstart;
- dmac->eda = (u_short)((u_int)&rxd[sc->rxmax - 1] & 0xffff);
-
- dmac->dir = 0xF0;
-
- dmac->dsr = SCA_DSR_DE;
-}
-
-/*
- * Configure the TX DMA descriptors.
- * Initialize the needed values and chain the descriptors.
- */
-static void
-ar_init_tx_dmac(struct ar_softc *sc)
-{
- dmac_channel *dmac;
- struct buf_block *blkp;
- int blk;
- sca_descriptor *txd;
- u_int txbuf;
- u_int txda;
- u_int txda_d;
-
- dmac = &sc->sca->dmac[DMAC_TXCH(sc->scachan)];
-
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_MEM(sc->hc->iobase, sc->block[0].txdesc);
-
- for(blk = 0; blk < AR_TX_BLOCKS; blk++) {
- blkp = &sc->block[blk];
- txd = (sca_descriptor *)(sc->hc->mem_start +
- (blkp->txdesc&sc->hc->winmsk));
- txda_d = (u_int)sc->hc->mem_start -
- (blkp->txdesc & ~sc->hc->winmsk);
-
- txbuf=blkp->txstart;
- for(;txbuf<blkp->txend;txbuf += AR_BUF_SIZ, txd++) {
- txda = (u_int)&txd[1] - txda_d;
- txd->cp = (u_short)(txda & 0xfffful);
-
- txd->bp = (u_short)(txbuf & 0xfffful);
- txd->bpb = (u_char)((txbuf >> 16) & 0xff);
- TRC(printf("ar%d: txbuf %x, bpb %x, bp %x\n",
- sc->unit, txbuf, txd->bpb, txd->bp));
- txd->len = 0;
- txd->stat = 0;
- }
- txd--;
- txd->cp = (u_short)(blkp->txdesc & 0xfffful);
-
- blkp->txtail = (u_int)txd - (u_int)sc->hc->mem_start;
- TRC(printf("TX Descriptors start %x, end %x.\n",
- blkp->txdesc,
- blkp->txtail));
- }
-
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_SCA(sc->hc->iobase, sc->scano);
-
- dmac->dsr = 0; /* Disable DMA */
- dmac->dcr = SCA_DCR_ABRT;
- dmac->dmr = SCA_DMR_TMOD | SCA_DMR_NF;
- dmac->dir = SCA_DIR_EOT | SCA_DIR_BOF | SCA_DIR_COF;
-
- dmac->sarb = (u_char)((sc->block[0].txdesc >> 16) & 0xff);
-}
-
-
-/*
- * Look through the descriptors to see if there is a complete packet
- * available. Stop if we get to where the sca is busy.
- *
- * Return the length and status of the packet.
- * Return nonzero if there is a packet available.
- *
- * NOTE:
- * It seems that we get the interrupt a bit early. The updateing of
- * descriptor values is not always completed when this is called.
- */
-static int
-ar_packet_avail(struct ar_softc *sc,
- int *len,
- u_char *rxstat)
-{
- dmac_channel *dmac;
- sca_descriptor *rxdesc;
- sca_descriptor *endp;
- sca_descriptor *cda;
-
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_SCA(sc->hc->iobase, sc->scano);
- dmac = &sc->sca->dmac[DMAC_RXCH(sc->scachan)];
- cda = (sca_descriptor *)(sc->hc->mem_start +
- ((((u_int)dmac->sarb << 16) + dmac->cda) & sc->hc->winmsk));
-
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_MEM(sc->hc->iobase, sc->rxdesc);
- rxdesc = (sca_descriptor *)
- (sc->hc->mem_start + (sc->rxdesc & sc->hc->winmsk));
- endp = rxdesc;
- rxdesc = &rxdesc[sc->rxhind];
- endp = &endp[sc->rxmax];
-
- *len = 0;
-
- while(rxdesc != cda) {
- *len += rxdesc->len;
-
- if(rxdesc->stat & SCA_DESC_EOM) {
- *rxstat = rxdesc->stat;
- TRC(printf("ar%d: PKT AVAIL len %d, %x.\n",
- sc->unit, *len, *rxstat));
- return 1;
- }
-
- rxdesc++;
- if(rxdesc == endp)
- rxdesc = (sca_descriptor *)
- (sc->hc->mem_start + (sc->rxdesc & sc->hc->winmsk));
- }
-
- *len = 0;
- *rxstat = 0;
- return 0;
-}
-
-
-/*
- * Copy a packet from the on card memory into a provided mbuf.
- * Take into account that buffers wrap and that a packet may
- * be larger than a buffer.
- */
-static void
-ar_copy_rxbuf(struct mbuf *m,
- struct ar_softc *sc,
- int len)
-{
- sca_descriptor *rxdesc;
- u_int rxdata;
- u_int rxmax;
- u_int off = 0;
- u_int tlen;
-
- rxdata = sc->rxstart + (sc->rxhind * AR_BUF_SIZ);
- rxmax = sc->rxstart + (sc->rxmax * AR_BUF_SIZ);
-
- rxdesc = (sca_descriptor *)
- (sc->hc->mem_start + (sc->rxdesc & sc->hc->winmsk));
- rxdesc = &rxdesc[sc->rxhind];
-
- while(len) {
- tlen = (len < AR_BUF_SIZ) ? len : AR_BUF_SIZ;
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_MEM(sc->hc->iobase, rxdata);
- bcopy(sc->hc->mem_start + (rxdata & sc->hc->winmsk),
- mtod(m, caddr_t) + off,
- tlen);
-
- off += tlen;
- len -= tlen;
-
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_MEM(sc->hc->iobase, sc->rxdesc);
- rxdesc->len = 0;
- rxdesc->stat = 0xff;
-
- rxdata += AR_BUF_SIZ;
- rxdesc++;
- if(rxdata == rxmax) {
- rxdata = sc->rxstart;
- rxdesc = (sca_descriptor *)
- (sc->hc->mem_start + (sc->rxdesc & sc->hc->winmsk));
- }
- }
-}
-
-/*
- * If single is set, just eat a packet. Otherwise eat everything up to
- * where cda points. Update pointers to point to the next packet.
- */
-static void
-ar_eat_packet(struct ar_softc *sc, int single)
-{
- dmac_channel *dmac;
- sca_descriptor *rxdesc;
- sca_descriptor *endp;
- sca_descriptor *cda;
- int loopcnt = 0;
- u_char stat;
-
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_SCA(sc->hc->iobase, sc->scano);
- dmac = &sc->sca->dmac[DMAC_RXCH(sc->scachan)];
- cda = (sca_descriptor *)(sc->hc->mem_start +
- ((((u_int)dmac->sarb << 16) + dmac->cda) & sc->hc->winmsk));
-
- /*
- * Loop until desc->stat == (0xff || EOM)
- * Clear the status and length in the descriptor.
- * Increment the descriptor.
- */
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_MEM(sc->hc->iobase, sc->rxdesc);
- rxdesc = (sca_descriptor *)
- (sc->hc->mem_start + (sc->rxdesc & sc->hc->winmsk));
- endp = rxdesc;
- rxdesc = &rxdesc[sc->rxhind];
- endp = &endp[sc->rxmax];
-
- while(rxdesc != cda) {
- loopcnt++;
- if(loopcnt > sc->rxmax) {
- printf("ar%d: eat pkt %d loop, cda %p, "
- "rxdesc %p, stat %x.\n",
- sc->unit,
- loopcnt,
- (void *)cda,
- (void *)rxdesc,
- rxdesc->stat);
- break;
- }
-
- stat = rxdesc->stat;
-
- rxdesc->len = 0;
- rxdesc->stat = 0xff;
-
- rxdesc++;
- sc->rxhind++;
- if(rxdesc == endp) {
- rxdesc = (sca_descriptor *)
- (sc->hc->mem_start + (sc->rxdesc & sc->hc->winmsk));
- sc->rxhind = 0;
- }
-
- if(single && (stat == SCA_DESC_EOM))
- break;
- }
-
- /*
- * Update the eda to the previous descriptor.
- */
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_SCA(sc->hc->iobase, sc->scano);
-
- rxdesc = (sca_descriptor *)sc->rxdesc;
- rxdesc = &rxdesc[(sc->rxhind + sc->rxmax - 2 ) % sc->rxmax];
-
- sc->sca->dmac[DMAC_RXCH(sc->scachan)].eda =
- (u_short)((u_int)rxdesc & 0xffff);
-}
-
-
-/*
- * While there is packets available in the rx buffer, read them out
- * into mbufs and ship them off.
- */
-static void
-ar_get_packets(struct ar_softc *sc)
-{
- sca_descriptor *rxdesc;
- struct mbuf *m = NULL;
- int i;
- int len;
- u_char rxstat;
-
- while(ar_packet_avail(sc, &len, &rxstat)) {
- TRC(printf("apa: len %d, rxstat %x\n", len, rxstat));
- if(((rxstat & SCA_DESC_ERRORS) == 0) && (len < MCLBYTES)) {
- MGETHDR(m, M_DONTWAIT, MT_DATA);
- if(m == NULL) {
- /* eat packet if get mbuf fail!! */
- ar_eat_packet(sc, 1);
- continue;
- }
-#ifndef NETGRAPH
- m->m_pkthdr.rcvif = &sc->ifsppp.pp_if;
-#else /* NETGRAPH */
- m->m_pkthdr.rcvif = NULL;
- sc->inbytes += len;
- sc->inlast = 0;
-#endif /* NETGRAPH */
- m->m_pkthdr.len = m->m_len = len;
- if(len > MHLEN) {
- MCLGET(m, M_DONTWAIT);
- if((m->m_flags & M_EXT) == 0) {
- m_freem(m);
- ar_eat_packet(sc, 1);
- continue;
- }
- }
- ar_copy_rxbuf(m, sc, len);
-#ifndef NETGRAPH
- if(sc->ifsppp.pp_if.if_bpf)
- bpf_mtap(&sc->ifsppp.pp_if, m);
- sppp_input(&sc->ifsppp.pp_if, m);
- sc->ifsppp.pp_if.if_ipackets++;
-#else /* NETGRAPH */
- ng_queue_data(sc->hook, m, NULL);
- sc->ipackets++;
-#endif /* NETGRAPH */
-
- /*
- * Update the eda to the previous descriptor.
- */
- i = (len + AR_BUF_SIZ - 1) / AR_BUF_SIZ;
- sc->rxhind = (sc->rxhind + i) % sc->rxmax;
-
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_SCA(sc->hc->iobase, sc->scano);
-
- rxdesc = (sca_descriptor *)sc->rxdesc;
- rxdesc =
- &rxdesc[(sc->rxhind + sc->rxmax - 2 ) % sc->rxmax];
-
- sc->sca->dmac[DMAC_RXCH(sc->scachan)].eda =
- (u_short)((u_int)rxdesc & 0xffff);
- } else {
- int tries = 5;
-
- while((rxstat == 0xff) && --tries)
- ar_packet_avail(sc, &len, &rxstat);
-
- /*
- * It look like we get an interrupt early
- * sometimes and then the status is not
- * filled in yet.
- */
- if(tries && (tries != 5))
- continue;
-
- ar_eat_packet(sc, 1);
-
-#ifndef NETGRAPH
- sc->ifsppp.pp_if.if_ierrors++;
-#else /* NETGRAPH */
- sc->ierrors[0]++;
-#endif /* NETGRAPH */
-
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_SCA(sc->hc->iobase, sc->scano);
-
- TRCL(printf("ar%d: Receive error chan %d, "
- "stat %x, msci st3 %x,"
- "rxhind %d, cda %x, eda %x.\n",
- sc->unit,
- sc->scachan,
- rxstat,
- sc->sca->msci[sc->scachan].st3,
- sc->rxhind,
- sc->sca->dmac[
- DMAC_RXCH(sc->scachan)].cda,
- sc->sca->dmac[
- DMAC_RXCH(sc->scachan)].eda));
- }
- }
-}
-
-
-/*
- * All DMA interrupts come here.
- *
- * Each channel has two interrupts.
- * Interrupt A for errors and Interrupt B for normal stuff like end
- * of transmit or receive dmas.
- */
-static void
-ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
-{
- u_char dsr;
- u_char dotxstart = isr1;
- int mch;
- struct ar_softc *sc;
- sca_regs *sca;
- dmac_channel *dmac;
-
- sca = hc->sca[scano];
- mch = 0;
- /*
- * Shortcut if there is no interrupts for dma channel 0 or 1
- */
- if((isr1 & 0x0F) == 0) {
- mch = 1;
- isr1 >>= 4;
- }
-
- do {
- sc = &hc->sc[mch + (NCHAN * scano)];
-
- /*
- * Transmit channel
- */
- if(isr1 & 0x0C) {
- dmac = &sca->dmac[DMAC_TXCH(mch)];
-
- if(hc->bustype == AR_BUS_ISA)
- ARC_SET_SCA(hc->iobase, scano);
-
- dsr = dmac->dsr;
- dmac->dsr = dsr;
-
- /* Counter overflow */
- if(dsr & SCA_DSR_COF) {
- printf("ar%d: TX DMA Counter overflow, "
- "txpacket no %lu.\n",
- sc->unit,
-#ifndef NETGRAPH
- sc->ifsppp.pp_if.if_opackets);
- sc->ifsppp.pp_if.if_oerrors++;
-#else /* NETGRAPH */
- sc->opackets);
- sc->oerrors++;
-#endif /* NETGRAPH */
- }
-
- /* Buffer overflow */
- if(dsr & SCA_DSR_BOF) {
- printf("ar%d: TX DMA Buffer overflow, "
- "txpacket no %lu, dsr %02x, "
- "cda %04x, eda %04x.\n",
- sc->unit,
-#ifndef NETGRAPH
- sc->ifsppp.pp_if.if_opackets,
-#else /* NETGRAPH */
- sc->opackets,
-#endif /* NETGRAPH */
- dsr,
- dmac->cda,
- dmac->eda);
-#ifndef NETGRAPH
- sc->ifsppp.pp_if.if_oerrors++;
-#else /* NETGRAPH */
- sc->oerrors++;
-#endif /* NETGRAPH */
- }
-
- /* End of Transfer */
- if(dsr & SCA_DSR_EOT) {
- /*
- * This should be the most common case.
- *
- * Clear the IFF_OACTIVE flag.
- *
- * Call arstart to start a new transmit if
- * there is data to transmit.
- */
- sc->xmit_busy = 0;
-#ifndef NETGRAPH
- sc->ifsppp.pp_if.if_flags &= ~IFF_OACTIVE;
- sc->ifsppp.pp_if.if_timer = 0;
-#else /* NETGRAPH */
- /* XXX c->ifsppp.pp_if.if_flags &= ~IFF_OACTIVE; */
- sc->out_dog = 0; /* XXX */
-#endif /* NETGRAPH */
-
- if(sc->txb_inuse && --sc->txb_inuse)
- ar_xmit(sc);
- }
- }
-
- /*
- * Receive channel
- */
- if(isr1 & 0x03) {
- dmac = &sca->dmac[DMAC_RXCH(mch)];
-
- if(hc->bustype == AR_BUS_ISA)
- ARC_SET_SCA(hc->iobase, scano);
-
- dsr = dmac->dsr;
- dmac->dsr = dsr;
-
- TRC(printf("AR: RX DSR %x\n", dsr));
-
- /* End of frame */
- if(dsr & SCA_DSR_EOM) {
- TRC(int tt = sc->ifsppp.pp_if.if_ipackets;)
- TRC(int ind = sc->rxhind;)
-
- ar_get_packets(sc);
- TRC(
-#ifndef NETGRAPH
- if(tt == sc->ifsppp.pp_if.if_ipackets) {
-#else /* NETGRAPH */
- if(tt == sc->ipackets) {
-#endif /* NETGRAPH */
- sca_descriptor *rxdesc;
- int i;
-
- if(hc->bustype == AR_BUS_ISA)
- ARC_SET_SCA(hc->iobase, scano);
- printf("AR: RXINTR isr1 %x, dsr %x, "
- "no data %d pkts, orxhind %d.\n",
- dotxstart,
- dsr,
- tt,
- ind);
- printf("AR: rxdesc %x, rxstart %x, "
- "rxend %x, rxhind %d, "
- "rxmax %d.\n",
- sc->rxdesc,
- sc->rxstart,
- sc->rxend,
- sc->rxhind,
- sc->rxmax);
- printf("AR: cda %x, eda %x.\n",
- dmac->cda,
- dmac->eda);
-
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_MEM(sc->hc->iobase,
- sc->rxdesc);
- rxdesc = (sca_descriptor *)
- (sc->hc->mem_start +
- (sc->rxdesc & sc->hc->winmsk));
- rxdesc = &rxdesc[sc->rxhind];
- for(i=0;i<3;i++,rxdesc++)
- printf("AR: rxdesc->stat %x, "
- "len %d.\n",
- rxdesc->stat,
- rxdesc->len);
- })
- }
-
- /* Counter overflow */
- if(dsr & SCA_DSR_COF) {
- printf("ar%d: RX DMA Counter overflow, "
- "rxpkts %lu.\n",
- sc->unit,
-#ifndef NETGRAPH
- sc->ifsppp.pp_if.if_ipackets);
- sc->ifsppp.pp_if.if_ierrors++;
-#else /* NETGRAPH */
- sc->ipackets);
- sc->ierrors[1]++;
-#endif /* NETGRAPH */
- }
-
- /* Buffer overflow */
- if(dsr & SCA_DSR_BOF) {
- if(hc->bustype == AR_BUS_ISA)
- ARC_SET_SCA(hc->iobase, scano);
- printf("ar%d: RX DMA Buffer overflow, "
- "rxpkts %lu, rxind %d, "
- "cda %x, eda %x, dsr %x.\n",
- sc->unit,
-#ifndef NETGRAPH
- sc->ifsppp.pp_if.if_ipackets,
-#else /* NETGRAPH */
- sc->ipackets,
-#endif /* NETGRAPH */
- sc->rxhind,
- dmac->cda,
- dmac->eda,
- dsr);
- /*
- * Make sure we eat as many as possible.
- * Then get the system running again.
- */
- ar_eat_packet(sc, 0);
-#ifndef NETGRAPH
- sc->ifsppp.pp_if.if_ierrors++;
-#else /* NETGRAPH */
- sc->ierrors[2]++;
-#endif /* NETGRAPH */
- if(hc->bustype == AR_BUS_ISA)
- ARC_SET_SCA(hc->iobase, scano);
- sca->msci[mch].cmd = SCA_CMD_RXMSGREJ;
- dmac->dsr = SCA_DSR_DE;
-
- TRC(printf("ar%d: RX DMA Buffer overflow, "
- "rxpkts %lu, rxind %d, "
- "cda %x, eda %x, dsr %x. After\n",
- sc->unit,
- sc->ifsppp.pp_if.if_ipackets,
- sc->rxhind,
- dmac->cda,
- dmac->eda,
- dmac->dsr);)
- }
-
- /* End of Transfer */
- if(dsr & SCA_DSR_EOT) {
- /*
- * If this happen, it means that we are
- * receiving faster than what the processor
- * can handle.
- *
- * XXX We should enable the dma again.
- */
- printf("ar%d: RX End of transfer, rxpkts %lu.\n",
- sc->unit,
-#ifndef NETGRAPH
- sc->ifsppp.pp_if.if_ipackets);
- sc->ifsppp.pp_if.if_ierrors++;
-#else /* NETGRAPH */
- sc->ipackets);
- sc->ierrors[3]++;
-#endif /* NETGRAPH */
- }
- }
-
- isr1 >>= 4;
-
- mch++;
- }while((mch<NCHAN) && isr1);
-
- /*
- * Now that we have done all the urgent things, see if we
- * can fill the transmit buffers.
- */
- for(mch = 0; mch < NCHAN; mch++) {
- if(dotxstart & 0x0C) {
- sc = &hc->sc[mch + (NCHAN * scano)];
-#ifndef NETGRAPH
- arstart(&sc->ifsppp.pp_if);
-#else /* NETGRAPH */
- arstart(sc);
-#endif /* NETGRAPH */
- }
- dotxstart >>= 4;
- }
-}
-
-static void
-ar_msci_intr(struct ar_hardc *hc, int scano, u_char isr0)
-{
- printf("arc%d: ARINTR: MSCI\n", hc->cunit);
-}
-
-static void
-ar_timer_intr(struct ar_hardc *hc, int scano, u_char isr2)
-{
- printf("arc%d: ARINTR: TIMER\n", hc->cunit);
-}
-
-
-#ifdef NETGRAPH
-/*****************************************
- * Device timeout/watchdog routine.
- * called once per second.
- * checks to see that if activity was expected, that it hapenned.
- * At present we only look to see if expected output was completed.
- */
-static void
-ngar_watchdog_frame(void * arg)
-{
- struct ar_softc * sc = arg;
- int s;
- int speed;
-
- if(sc->running == 0)
- return; /* if we are not running let timeouts die */
- /*
- * calculate the apparent throughputs
- * XXX a real hack
- */
- s = splimp();
- speed = sc->inbytes - sc->lastinbytes;
- sc->lastinbytes = sc->inbytes;
- if ( sc->inrate < speed )
- sc->inrate = speed;
- speed = sc->outbytes - sc->lastoutbytes;
- sc->lastoutbytes = sc->outbytes;
- if ( sc->outrate < speed )
- sc->outrate = speed;
- sc->inlast++;
- splx(s);
-
- if ((sc->inlast > QUITE_A_WHILE)
- && (sc->out_deficit > LOTS_OF_PACKETS)) {
- log(LOG_ERR, "ar%d: No response from remote end\n", sc->unit);
- s = splimp();
- ar_down(sc);
- ar_up(sc);
- sc->inlast = sc->out_deficit = 0;
- splx(s);
- } else if ( sc->xmit_busy ) { /* no TX -> no TX timeouts */
- if (sc->out_dog == 0) {
- log(LOG_ERR, "ar%d: Transmit failure.. no clock?\n",
- sc->unit);
- s = splimp();
- arwatchdog(sc);
-#if 0
- ar_down(sc);
- ar_up(sc);
-#endif
- splx(s);
- sc->inlast = sc->out_deficit = 0;
- } else {
- sc->out_dog--;
- }
- }
- sc->handle = timeout(ngar_watchdog_frame, sc, hz);
-}
-
-/***********************************************************************
- * This section contains the methods for the Netgraph interface
- ***********************************************************************/
-/*
- * It is not possible or allowable to create a node of this type.
- * If the hardware exists, it will already have created it.
- */
-static int
-ngar_constructor(node_p *nodep)
-{
- return (EINVAL);
-}
-
-/*
- * give our ok for a hook to be added...
- * If we are not running this should kick the device into life.
- * The hook's private info points to our stash of info about that
- * channel.
- */
-static int
-ngar_newhook(node_p node, hook_p hook, const char *name)
-{
- struct ar_softc * sc = node->private;
-
- /*
- * check if it's our friend the debug hook
- */
- if (strcmp(name, NG_AR_HOOK_DEBUG) == 0) {
- hook->private = NULL; /* paranoid */
- sc->debug_hook = hook;
- return (0);
- }
-
- /*
- * Check for raw mode hook.
- */
- if (strcmp(name, NG_AR_HOOK_RAW) != 0) {
- return (EINVAL);
- }
- hook->private = sc;
- sc->hook = hook;
- sc->datahooks++;
- ar_up(sc);
- return (0);
-}
-
-/*
- * incoming messages.
- * Just respond to the generic TEXT_STATUS message
- */
-static int
-ngar_rcvmsg(node_p node,
- struct ng_mesg *msg, const char *retaddr, struct ng_mesg **resp)
-{
- struct ar_softc * sc;
- int error = 0;
-
- sc = node->private;
- switch (msg->header.typecookie) {
- case NG_AR_COOKIE:
- error = EINVAL;
- break;
- case NGM_GENERIC_COOKIE:
- switch(msg->header.cmd) {
- case NGM_TEXT_STATUS: {
- char *arg;
- int pos = 0;
- int resplen = sizeof(struct ng_mesg) + 512;
- MALLOC(*resp, struct ng_mesg *, resplen,
- M_NETGRAPH, M_NOWAIT);
- if (*resp == NULL) {
- error = ENOMEM;
- break;
- }
- bzero(*resp, resplen);
- arg = (*resp)->data;
-
- /*
- * Put in the throughput information.
- */
- pos = sprintf(arg, "%ld bytes in, %ld bytes out\n"
- "highest rate seen: %ld B/S in, %ld B/S out\n",
- sc->inbytes, sc->outbytes,
- sc->inrate, sc->outrate);
- pos += sprintf(arg + pos,
- "%ld output errors\n",
- sc->oerrors);
- pos += sprintf(arg + pos,
- "ierrors = %ld, %ld, %ld, %ld\n",
- sc->ierrors[0],
- sc->ierrors[1],
- sc->ierrors[2],
- sc->ierrors[3]);
-
- (*resp)->header.version = NG_VERSION;
- (*resp)->header.arglen = strlen(arg) + 1;
- (*resp)->header.token = msg->header.token;
- (*resp)->header.typecookie = NG_AR_COOKIE;
- (*resp)->header.cmd = msg->header.cmd;
- strncpy((*resp)->header.cmdstr, "status",
- NG_CMDSTRLEN);
- }
- break;
- default:
- error = EINVAL;
- break;
- }
- break;
- default:
- error = EINVAL;
- break;
- }
- free(msg, M_NETGRAPH);
- return (error);
-}
-
-/*
- * get data from another node and transmit it to the correct channel
- */
-static int
-ngar_rcvdata(hook_p hook, struct mbuf *m, meta_p meta)
-{
- int s;
- int error = 0;
- struct ar_softc * sc = hook->node->private;
- struct ifqueue *xmitq_p;
-
- /*
- * data doesn't come in from just anywhere (e.g control hook)
- */
- if ( hook->private == NULL) {
- error = ENETDOWN;
- goto bad;
- }
-
- /*
- * Now queue the data for when it can be sent
- */
- if (meta && meta->priority > 0) {
- xmitq_p = (&sc->xmitq_hipri);
- } else {
- xmitq_p = (&sc->xmitq);
- }
- s = splimp();
- if (IF_QFULL(xmitq_p)) {
- IF_DROP(xmitq_p);
- splx(s);
- error = ENOBUFS;
- goto bad;
- }
- IF_ENQUEUE(xmitq_p, m);
- arstart(sc);
- splx(s);
- return (0);
-
-bad:
- /*
- * It was an error case.
- * check if we need to free the mbuf, and then return the error
- */
- NG_FREE_DATA(m, meta);
- return (error);
-}
-
-/*
- * do local shutdown processing..
- * this node will refuse to go away, unless the hardware says to..
- * don't unref the node, or remove our name. just clear our links up.
- */
-static int
-ngar_rmnode(node_p node)
-{
- struct ar_softc * sc = node->private;
-
- ar_down(sc);
- ng_cutlinks(node);
- node->flags &= ~NG_INVALID; /* bounce back to life */
- return (0);
-}
-
-/* already linked */
-static int
-ngar_connect(hook_p hook)
-{
- /* be really amiable and just say "YUP that's OK by me! " */
- return (0);
-}
-
-/*
- * notify on hook disconnection (destruction)
- *
- * Invalidate the private data associated with this dlci.
- * For this type, removal of the last link resets tries to destroy the node.
- * As the device still exists, the shutdown method will not actually
- * destroy the node, but reset the device and leave it 'fresh' :)
- *
- * The node removal code will remove all references except that owned by the
- * driver.
- */
-static int
-ngar_disconnect(hook_p hook)
-{
- struct ar_softc * sc = hook->node->private;
- int s;
- /*
- * If it's the data hook, then free resources etc.
- */
- if (hook->private) {
- s = splimp();
- sc->datahooks--;
- if (sc->datahooks == 0)
- ar_down(sc);
- splx(s);
- } else {
- sc->debug_hook = NULL;
- }
- return (0);
-}
-
-/*
- * called during bootup
- * or LKM loading to put this type into the list of known modules
- */
-static void
-ngar_init(void *ignored)
-{
- if (ng_newtype(&typestruct))
- printf("ngar install failed\n");
- ngar_done_init = 1;
-}
-#endif /* NETGRAPH */
-
-/*
- ********************************* END ************************************
- */
diff --git a/sys/dev/ar/if_ar.h b/sys/dev/ar/if_ar.h
deleted file mode 100644
index 77bd5bc54261..000000000000
--- a/sys/dev/ar/if_ar.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * if_ar.h
- *
- * Copyright (C) 1997-1999 Whistle Communications Inc.
- * All rights reserved.
- *
- * $FreeBSD$
- */
-
-#ifndef _I386_ISA_IF_AR_H_
-#define _I386_ISA_IF_AR_H_
-
-/* Node type name and type cookie */
-#define NG_AR_NODE_TYPE "sync_ar"
-#define NG_AR_COOKIE 860552149
-
-/* Netgraph hooks */
-#define NG_AR_HOOK_DEBUG "debug"
-#define NG_AR_HOOK_RAW "rawdata"
-
-#endif /* _I386_ISA_IF_AR_H_ */
-
diff --git a/sys/dev/ar/if_ar_isa.c b/sys/dev/ar/if_ar_isa.c
deleted file mode 100644
index 6f9122c22482..000000000000
--- a/sys/dev/ar/if_ar_isa.c
+++ /dev/null
@@ -1,2390 +0,0 @@
-/*
- * Copyright (c) 1995, 1999 John Hay. 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 author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY John Hay ``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 John Hay 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Programming assumptions and other issues.
- *
- * The descriptors of a DMA channel will fit in a 16K memory window.
- *
- * The buffers of a transmit DMA channel will fit in a 16K memory window.
- *
- * Only the ISA bus cards with X.21 and V.35 is tested.
- *
- * When interface is going up, handshaking is set and it is only cleared
- * when the interface is down'ed.
- *
- * There should be a way to set/reset Raw HDLC/PPP, Loopback, DCE/DTE,
- * internal/external clock, etc.....
- *
- */
-
-#include "opt_netgraph.h"
-#include "ar.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/malloc.h>
-#include <sys/mbuf.h>
-#include <sys/sockio.h>
-#include <sys/socket.h>
-
-#include <net/if.h>
-#ifdef NETGRAPH
-#include <netgraph/ng_message.h>
-#include <netgraph/netgraph.h>
-#include <sys/kernel.h>
-#include <sys/syslog.h>
-#include <i386/isa/if_ar.h>
-#else /* NETGRAPH */
-#include <net/if_sppp.h>
-#include <net/bpf.h>
-#endif /* NETGRAPH */
-
-#include <machine/clock.h>
-#include <machine/md_var.h>
-
-#include <i386/isa/if_arregs.h>
-#include <i386/isa/ic/hd64570.h>
-#include <i386/isa/isa_device.h>
-
-#ifndef NETGRAPH
-#include "sppp.h"
-#if NSPPP <= 0
-#error device 'ar' require sppp.
-#endif /* NSPPP <= 0 */
-#endif /* NETGRAPH */
-
-#ifdef TRACE
-#define TRC(x) x
-#else
-#define TRC(x)
-#endif
-
-#define TRCL(x) x
-
-#define PPP_HEADER_LEN 4
-
-#define ARC_GET_WIN(addr) ((addr >> ARC_WIN_SHFT) & AR_WIN_MSK)
-
-#define ARC_SET_MEM(iobase,win) outb(iobase+AR_MSCA_EN, AR_ENA_MEM | \
- ARC_GET_WIN(win))
-#define ARC_SET_SCA(iobase,ch) outb(iobase+AR_MSCA_EN, AR_ENA_MEM | \
- AR_ENA_SCA | (ch ? AR_SEL_SCA_1:AR_SEL_SCA_0))
-#define ARC_SET_OFF(iobase) outb(iobase+AR_MSCA_EN, 0)
-
-struct ar_hardc {
- int cunit;
- struct ar_softc *sc;
- u_short iobase;
- int isa_irq;
- int numports;
- caddr_t mem_start;
- caddr_t mem_end;
- u_char *orbase;
-
- u_int memsize; /* in bytes */
- u_int winsize; /* in bytes */
- u_int winmsk;
- u_char bustype; /* ISA, MCA, PCI.... */
- u_char interface[NPORT];/* X21, V.35, EIA-530.... */
- u_char revision;
- u_char handshake; /* handshake lines supported by card. */
-
- u_char txc_dtr[NPORT/NCHAN]; /* the register is write only */
- u_int txc_dtr_off[NPORT/NCHAN];
-
- sca_regs *sca[NPORT/NCHAN];
-
-};
-
-static int next_ar_unit = 0;
-static struct ar_hardc ar_hardc[NAR];
-
-struct ar_softc {
-#ifndef NETGRAPH
- struct sppp ifsppp;
-#endif /* NETGRAPH */
- int unit; /* With regards to all ar devices */
- int subunit; /* With regards to this card */
- struct ar_hardc *hc;
-
- struct buf_block {
- u_int txdesc; /* On card address */
- u_int txstart; /* On card address */
- u_int txend; /* On card address */
- u_int txtail; /* Index of first unused buffer */
- u_int txmax; /* number of usable buffers/descriptors */
- u_int txeda; /* Error descriptor addresses */
- }block[AR_TX_BLOCKS];
-
- char xmit_busy; /* Transmitter is busy */
- char txb_inuse; /* Number of tx blocks currently in use */
- u_char txb_new; /* Index to where new buffer will be added */
- u_char txb_next_tx; /* Index to next block ready to tx */
-
- u_int rxdesc; /* On card address */
- u_int rxstart; /* On card address */
- u_int rxend; /* On card address */
- u_int rxhind; /* Index to the head of the rx buffers. */
- u_int rxmax; /* number of usable buffers/descriptors */
-
- int scano;
- int scachan;
- sca_regs *sca;
-#ifdef NETGRAPH
- int running; /* something is attached so we are running */
- int dcd; /* do we have dcd? */
- /* ---netgraph bits --- */
- char nodename[NG_NODELEN + 1]; /* store our node name */
- int datahooks; /* number of data hooks attached */
- node_p node; /* netgraph node */
- hook_p hook; /* data hook */
- hook_p debug_hook;
- struct ifqueue xmitq_hipri; /* hi-priority transmit queue */
- struct ifqueue xmitq; /* transmit queue */
- int flags; /* state */
-#define SCF_RUNNING 0x01 /* board is active */
-#define SCF_OACTIVE 0x02 /* output is active */
- int out_dog; /* watchdog cycles output count-down */
- struct callout_handle handle; /* timeout(9) handle */
- u_long inbytes, outbytes; /* stats */
- u_long lastinbytes, lastoutbytes; /* a second ago */
- u_long inrate, outrate; /* highest rate seen */
- u_long inlast; /* last input N secs ago */
- u_long out_deficit; /* output since last input */
- u_long oerrors, ierrors[6];
- u_long opackets, ipackets;
-#endif /* NETGRAPH */
-};
-
-#ifdef NETGRAPH
-#define DOG_HOLDOFF 6 /* dog holds off for 6 secs */
-#define QUITE_A_WHILE 300 /* 5 MINUTES */
-#define LOTS_OF_PACKETS 100
-#endif /* NETGRAPH */
-
-static int arprobe(struct isa_device *id);
-static int arattach_isa(struct isa_device *id);
-
-/*
- * This translate from irq numbers to
- * the value that the arnet card needs
- * in the lower part of the AR_INT_SEL
- * register.
- */
-static int irqtable[16] = {
- 0, /* 0 */
- 0, /* 1 */
- 0, /* 2 */
- 1, /* 3 */
- 0, /* 4 */
- 2, /* 5 */
- 0, /* 6 */
- 3, /* 7 */
- 0, /* 8 */
- 0, /* 9 */
- 4, /* 10 */
- 5, /* 11 */
- 6, /* 12 */
- 0, /* 13 */
- 0, /* 14 */
- 7 /* 15 */
-};
-
-struct isa_driver ardriver = {arprobe, arattach_isa, "ar"};
-
-struct ar_hardc *arattach_pci(int unit, vm_offset_t mem_addr);
-void arintr_hc(struct ar_hardc *hc);
-
-static ointhand2_t arintr;
-static int arattach(struct ar_hardc *hc);
-static void ar_xmit(struct ar_softc *sc);
-#ifndef NETGRAPH
-static void arstart(struct ifnet *ifp);
-static int arioctl(struct ifnet *ifp, u_long cmd, caddr_t data);
-static void arwatchdog(struct ifnet *ifp);
-#else /* NETGRAPH */
-static void arstart(struct ar_softc *sc);
-static void arwatchdog(struct ar_softc *sc);
-#endif /* NETGRAPH */
-static int ar_packet_avail(struct ar_softc *sc, int *len, u_char *rxstat);
-static void ar_copy_rxbuf(struct mbuf *m, struct ar_softc *sc, int len);
-static void ar_eat_packet(struct ar_softc *sc, int single);
-static void ar_get_packets(struct ar_softc *sc);
-
-static int ar_read_pim_iface(volatile struct ar_hardc *hc, int channel);
-static void ar_up(struct ar_softc *sc);
-static void ar_down(struct ar_softc *sc);
-static void arc_init(struct ar_hardc *hc);
-static void ar_init_sca(struct ar_hardc *hc, int scano);
-static void ar_init_msci(struct ar_softc *sc);
-static void ar_init_rx_dmac(struct ar_softc *sc);
-static void ar_init_tx_dmac(struct ar_softc *sc);
-static void ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr);
-static void ar_msci_intr(struct ar_hardc *hc, int scano, u_char isr);
-static void ar_timer_intr(struct ar_hardc *hc, int scano, u_char isr);
-
-#ifdef NETGRAPH
-static void ngar_watchdog_frame(void * arg);
-static void ngar_init(void* ignored);
-
-static ng_constructor_t ngar_constructor;
-static ng_rcvmsg_t ngar_rcvmsg;
-static ng_shutdown_t ngar_rmnode;
-static ng_newhook_t ngar_newhook;
-/*static ng_findhook_t ngar_findhook; */
-static ng_connect_t ngar_connect;
-static ng_rcvdata_t ngar_rcvdata;
-static ng_disconnect_t ngar_disconnect;
-
-static struct ng_type typestruct = {
- NG_VERSION,
- NG_AR_NODE_TYPE,
- NULL,
- ngar_constructor,
- ngar_rcvmsg,
- ngar_rmnode,
- ngar_newhook,
- NULL,
- ngar_connect,
- ngar_rcvdata,
- ngar_rcvdata,
- ngar_disconnect,
- NULL
-};
-
-static int ngar_done_init = 0;
-#endif /* NETGRAPH */
-
-/*
- * Register the Adapter.
- * Probe to see if it is there.
- * Get its information and fill it in.
- */
-static int
-arprobe(struct isa_device *id)
-{
- struct ar_hardc *hc = &ar_hardc[id->id_unit];
- u_int tmp;
- u_short port;
-
- /*
- * Register the card.
- */
-
- /*
- * Now see if the card is realy there.
- *
- * XXX For now I just check the undocumented ports
- * for "570". We will probably have to do more checking.
- */
- port = id->id_iobase;
-
- if((inb(port+AR_ID_5) != '5') || (inb(port+AR_ID_7) != '7') ||
- (inb(port+AR_ID_0) != '0'))
- return 0;
- /*
- * We have a card here, fill in what we can.
- */
- tmp = inb(port + AR_BMI);
- hc->bustype = tmp & AR_BUS_MSK;
- hc->memsize = (tmp & AR_MEM_MSK) >> AR_MEM_SHFT;
- hc->memsize = 1 << hc->memsize;
- hc->memsize <<= 16;
- hc->interface[0] = (tmp & AR_IFACE_MSK);
- hc->interface[1] = hc->interface[0];
- hc->interface[2] = hc->interface[0];
- hc->interface[3] = hc->interface[0];
- tmp = inb(port + AR_REV);
- hc->revision = tmp & AR_REV_MSK;
- hc->winsize = 1 << ((tmp & AR_WSIZ_MSK) >> AR_WSIZ_SHFT);
- hc->winsize *= ARC_WIN_SIZ;
- hc->winmsk = hc->winsize - 1;
- hc->numports = inb(port + AR_PNUM);
- hc->handshake = inb(port + AR_HNDSH);
-
- id->id_msize = hc->winsize;
-
- hc->iobase = id->id_iobase;
- hc->mem_start = id->id_maddr;
- hc->mem_end = id->id_maddr + id->id_msize;
- hc->cunit = id->id_unit;
- hc->isa_irq = id->id_irq;
-
- switch(hc->interface[0]) {
- case AR_IFACE_EIA_232:
- printf("ar%d: The EIA 232 interface is not supported.\n",
- id->id_unit);
- return 0;
- case AR_IFACE_V_35:
- break;
- case AR_IFACE_EIA_530:
- printf("ar%d: WARNING: The EIA 530 interface is untested.\n",
- id->id_unit);
- break;
- case AR_IFACE_X_21:
- break;
- case AR_IFACE_COMBO:
- printf("ar%d: WARNING: The COMBO interface is untested.\n",
- id->id_unit);
- break;
- }
-
- /*
- * Do a little sanity check.
- */
- if((hc->numports > NPORT) || (hc->memsize > (512*1024)))
- return 0;
-
- return ARC_IO_SIZ; /* return the amount of IO addresses used. */
-}
-
-/*
- * Malloc memory for the softc structures.
- * Reset the card to put it in a known state.
- * Register the ports on the adapter.
- * Fill in the info for each port.
- * Attach each port to sppp and bpf.
- */
-static int
-arattach_isa(struct isa_device *id)
-{
- struct ar_hardc *hc = &ar_hardc[id->id_unit];
- id->id_ointr = arintr;
- return arattach(hc);
-}
-
-struct ar_hardc *
-arattach_pci(int unit, vm_offset_t mem_addr)
-{
- struct ar_hardc *hc;
- u_int i, tmp;
-
- hc = malloc(sizeof(struct ar_hardc), M_DEVBUF, M_WAITOK);
- bzero(hc, sizeof(struct ar_hardc));
-
- hc->cunit = unit;
- hc->mem_start = (caddr_t)mem_addr;
- hc->sca[0] = (sca_regs *)(mem_addr + AR_PCI_SCA_1_OFFSET);
- hc->sca[1] = (sca_regs *)(mem_addr + AR_PCI_SCA_2_OFFSET);
- hc->iobase = 0;
- hc->orbase = (u_char *)(mem_addr + AR_PCI_ORBASE_OFFSET);
-
- tmp = hc->orbase[AR_BMI * 4];
- hc->bustype = tmp & AR_BUS_MSK;
- hc->memsize = (tmp & AR_MEM_MSK) >> AR_MEM_SHFT;
- hc->memsize = 1 << hc->memsize;
- hc->memsize <<= 16;
- hc->interface[0] = (tmp & AR_IFACE_MSK);
- tmp = hc->orbase[AR_REV * 4];
- hc->revision = tmp & AR_REV_MSK;
- hc->winsize = (1 << ((tmp & AR_WSIZ_MSK) >> AR_WSIZ_SHFT)) * 16 * 1024;
- hc->mem_end = (caddr_t)(mem_addr + hc->winsize);
- hc->winmsk = hc->winsize - 1;
- hc->numports = hc->orbase[AR_PNUM * 4];
- hc->handshake = hc->orbase[AR_HNDSH * 4];
-
- for(i = 1; i < hc->numports; i++)
- hc->interface[i] = hc->interface[0];
-
- TRC(printf("arp%d: bus %x, rev %d, memstart %p, winsize %d, "
- "winmsk %x, interface %x\n",
- unit, hc->bustype, hc->revision, hc->mem_start, hc->winsize,
- hc->winmsk, hc->interface[0]));
-
- arattach(hc);
- return hc;
-}
-
-static int
-arattach(struct ar_hardc *hc)
-{
- struct ar_softc *sc;
-#ifndef NETGRAPH
- struct ifnet *ifp;
- char *iface;
-#endif /* NETGRAPH */
- int unit;
-
- printf("arc%d: %uK RAM, %u ports, rev %u.\n",
- hc->cunit,
- hc->memsize/1024,
- hc->numports,
- hc->revision);
-
- arc_init(hc);
-
- sc = hc->sc;
-
- for(unit=0;unit<hc->numports;unit+=NCHAN)
- ar_init_sca(hc, unit / NCHAN);
-
- /*
- * Now configure each port on the card.
- */
- for(unit=0;unit<hc->numports;sc++,unit++) {
- sc->hc = hc;
- sc->subunit = unit;
- sc->unit = next_ar_unit;
- next_ar_unit++;
- sc->scano = unit / NCHAN;
- sc->scachan = unit%NCHAN;
-
- ar_init_rx_dmac(sc);
- ar_init_tx_dmac(sc);
- ar_init_msci(sc);
-
-#ifndef NETGRAPH
- ifp = &sc->ifsppp.pp_if;
-
- ifp->if_softc = sc;
- ifp->if_unit = sc->unit;
- ifp->if_name = "ar";
- ifp->if_mtu = PP_MTU;
- ifp->if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
- ifp->if_ioctl = arioctl;
- ifp->if_start = arstart;
- ifp->if_watchdog = arwatchdog;
-
- sc->ifsppp.pp_flags = PP_KEEPALIVE;
-
- switch(hc->interface[unit]) {
- default: iface = "UNKNOWN"; break;
- case AR_IFACE_EIA_232: iface = "EIA-232"; break;
- case AR_IFACE_V_35: iface = "EIA-232 or V.35"; break;
- case AR_IFACE_EIA_530: iface = "EIA-530"; break;
- case AR_IFACE_X_21: iface = "X.21"; break;
- case AR_IFACE_COMBO: iface = "COMBO X.21 / EIA-530"; break;
- }
-
- printf("ar%d: Adapter %d, port %d, interface %s.\n",
- sc->unit,
- hc->cunit,
- sc->subunit,
- iface);
-
- sppp_attach((struct ifnet *)&sc->ifsppp);
- if_attach(ifp);
-
- bpfattach(ifp, DLT_PPP, PPP_HEADER_LEN);
-#else /* NETGRAPH */
- /*
- * we have found a node, make sure our 'type' is availabe.
- */
- if (ngar_done_init == 0) ngar_init(NULL);
- if (ng_make_node_common(&typestruct, &sc->node) != 0)
- return (0);
- sc->node->private = sc;
- callout_handle_init(&sc->handle);
- sc->xmitq.ifq_maxlen = IFQ_MAXLEN;
- sc->xmitq_hipri.ifq_maxlen = IFQ_MAXLEN;
- sprintf(sc->nodename, "%s%d", NG_AR_NODE_TYPE, sc->unit);
- if (ng_name_node(sc->node, sc->nodename)) {
- ng_rmnode(sc->node);
- ng_unref(sc->node);
- return (0);
- }
- sc->running = 0;
-#endif /* NETGRAPH */
- }
-
- if(hc->bustype == AR_BUS_ISA)
- ARC_SET_OFF(hc->iobase);
-
- return 1;
-}
-
-/*
- * First figure out which SCA gave the interrupt.
- * Process it.
- * See if there is other interrupts pending.
- * Repeat until there is no more interrupts.
- */
-static void
-arintr(int unit)
-{
- struct ar_hardc *hc;
-
- hc = &ar_hardc[unit];
- arintr_hc(hc);
- return;
-}
-
-void
-arintr_hc(struct ar_hardc *hc)
-{
- sca_regs *sca;
- u_char isr0, isr1, isr2, arisr;
- int scano;
-
- /* XXX Use the PCI interrupt score board register later */
- if(hc->bustype == AR_BUS_PCI)
- arisr = hc->orbase[AR_ISTAT * 4];
- else
- arisr = inb(hc->iobase + AR_ISTAT);
-
- while(arisr & AR_BD_INT) {
- TRC(printf("arisr = %x\n", arisr));
- if(arisr & AR_INT_0)
- scano = 0;
- else if(arisr & AR_INT_1)
- scano = 1;
- else {
- /* XXX Oops this shouldn't happen. */
- printf("arc%d: Interrupted with no interrupt.\n",
- hc->cunit);
- return;
- }
- sca = hc->sca[scano];
-
- if(hc->bustype == AR_BUS_ISA)
- ARC_SET_SCA(hc->iobase, scano);
-
- isr0 = sca->isr0;
- isr1 = sca->isr1;
- isr2 = sca->isr2;
-
- TRC(printf("arc%d: ARINTR isr0 %x, isr1 %x, isr2 %x\n",
- hc->cunit,
- isr0,
- isr1,
- isr2));
- if(isr0)
- ar_msci_intr(hc, scano, isr0);
-
- if(isr1)
- ar_dmac_intr(hc, scano, isr1);
-
- if(isr2)
- ar_timer_intr(hc, scano, isr2);
-
- /*
- * Proccess the second sca's interrupt if available.
- * Else see if there are any new interrupts.
- */
- if((arisr & AR_INT_0) && (arisr & AR_INT_1))
- arisr &= ~AR_INT_0;
- else {
- if(hc->bustype == AR_BUS_PCI)
- arisr = hc->orbase[AR_ISTAT * 4];
- else
- arisr = inb(hc->iobase + AR_ISTAT);
- }
- }
-
- if(hc->bustype == AR_BUS_ISA)
- ARC_SET_OFF(hc->iobase);
-}
-
-
-/*
- * This will only start the transmitter. It is assumed that the data
- * is already there. It is normally called from arstart() or ar_dmac_intr().
- *
- */
-static void
-ar_xmit(struct ar_softc *sc)
-{
-#ifndef NETGRAPH
- struct ifnet *ifp;
-#endif /* NETGRAPH */
- dmac_channel *dmac;
-
-#ifndef NETGRAPH
- ifp = &sc->ifsppp.pp_if;
-#endif /* NETGRAPH */
- dmac = &sc->sca->dmac[DMAC_TXCH(sc->scachan)];
-
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_SCA(sc->hc->iobase, sc->scano);
- dmac->cda = (u_short)(sc->block[sc->txb_next_tx].txdesc & 0xffff);
-
- dmac->eda = (u_short)(sc->block[sc->txb_next_tx].txeda & 0xffff);
- dmac->dsr = SCA_DSR_DE;
-
- sc->xmit_busy = 1;
-
- sc->txb_next_tx++;
- if(sc->txb_next_tx == AR_TX_BLOCKS)
- sc->txb_next_tx = 0;
-
-#ifndef NETGRAPH
- ifp->if_timer = 2; /* Value in seconds. */
-#else /* NETGRAPH */
- sc->out_dog = DOG_HOLDOFF; /* give ourself some breathing space*/
-#endif /* NETGRAPH */
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_OFF(sc->hc->iobase);
-}
-
-/*
- * This function will be called from the upper level when a user add a
- * packet to be send, and from the interrupt handler after a finished
- * transmit.
- *
- * NOTE: it should run at spl_imp().
- *
- * This function only place the data in the oncard buffers. It does not
- * start the transmition. ar_xmit() does that.
- *
- * Transmitter idle state is indicated by the IFF_OACTIVE flag. The function
- * that clears that should ensure that the transmitter and its DMA is
- * in a "good" idle state.
- */
-#ifndef NETGRAPH
-static void
-arstart(struct ifnet *ifp)
-{
- struct ar_softc *sc = ifp->if_softc;
-#else /* NETGRAPH */
-static void
-arstart(struct ar_softc *sc)
-{
-#endif /* NETGRAPH */
- int i, len, tlen;
- struct mbuf *mtx;
- u_char *txdata;
- sca_descriptor *txdesc;
- struct buf_block *blkp;
-
-#ifndef NETGRAPH
- if(!(ifp->if_flags & IFF_RUNNING))
- return;
-#else /* NETGRAPH */
-/* XXX */
-#endif /* NETGRAPH */
-
-top_arstart:
-
- /*
- * See if we have space for more packets.
- */
- if(sc->txb_inuse == AR_TX_BLOCKS) {
-#ifndef NETGRAPH
- ifp->if_flags |= IFF_OACTIVE; /* yes, mark active */
-#else /* NETGRAPH */
-/*XXX*/ /*ifp->if_flags |= IFF_OACTIVE;*/ /* yes, mark active */
-#endif /* NETGRAPH */
- return;
- }
-
-#ifndef NETGRAPH
- mtx = sppp_dequeue(ifp);
-#else /* NETGRAPH */
- IF_DEQUEUE(&sc->xmitq_hipri, mtx);
- if (mtx == NULL) {
- IF_DEQUEUE(&sc->xmitq, mtx);
- }
-#endif /* NETGRAPH */
- if(!mtx)
- return;
-
- /*
- * It is OK to set the memory window outside the loop because
- * all tx buffers and descriptors are assumed to be in the same
- * 16K window.
- */
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_MEM(sc->hc->iobase, sc->block[0].txdesc);
-
- /*
- * We stay in this loop until there is nothing in the
- * TX queue left or the tx buffer is full.
- */
- i = 0;
- blkp = &sc->block[sc->txb_new];
- txdesc = (sca_descriptor *)
- (sc->hc->mem_start + (blkp->txdesc & sc->hc->winmsk));
- txdata = (u_char *)(sc->hc->mem_start + (blkp->txstart & sc->hc->winmsk));
- for(;;) {
- len = mtx->m_pkthdr.len;
-
- TRC(printf("ar%d: ARstart len %u\n", sc->unit, len));
-
- /*
- * We can do this because the tx buffers don't wrap.
- */
- m_copydata(mtx, 0, len, txdata);
- tlen = len;
- while(tlen > AR_BUF_SIZ) {
- txdesc->stat = 0;
- txdesc->len = AR_BUF_SIZ;
- tlen -= AR_BUF_SIZ;
- txdesc++;
- txdata += AR_BUF_SIZ;
- i++;
- }
- /* XXX Move into the loop? */
- txdesc->stat = SCA_DESC_EOM;
- txdesc->len = tlen;
- txdesc++;
- txdata += AR_BUF_SIZ;
- i++;
-
-#ifndef NETGRAPH
- if(ifp->if_bpf)
- bpf_mtap(ifp, mtx);
- m_freem(mtx);
- ++sc->ifsppp.pp_if.if_opackets;
-#else /* NETGRAPH */
- m_freem(mtx);
- sc->outbytes += len;
- ++sc->opackets;
-#endif /* NETGRAPH */
-
- /*
- * Check if we have space for another mbuf.
- * XXX This is hardcoded. A packet won't be larger
- * than 3 buffers (3 x 512).
- */
- if((i + 3) >= blkp->txmax)
- break;
-
-#ifndef NETGRAPH
- mtx = sppp_dequeue(ifp);
-#else /* NETGRAPH */
- IF_DEQUEUE(&sc->xmitq_hipri, mtx);
- if (mtx == NULL) {
- IF_DEQUEUE(&sc->xmitq, mtx);
- }
-#endif /* NETGRAPH */
- if(!mtx)
- break;
- }
-
- blkp->txtail = i;
-
- /*
- * Mark the last descriptor, so that the SCA know where
- * to stop.
- */
- txdesc--;
- txdesc->stat |= SCA_DESC_EOT;
-
- txdesc = (sca_descriptor *)blkp->txdesc;
- blkp->txeda = (u_short)((u_int)&txdesc[i]);
-
-#if 0
- printf("ARstart: %p desc->cp %x\n", &txdesc->cp, txdesc->cp);
- printf("ARstart: %p desc->bp %x\n", &txdesc->bp, txdesc->bp);
- printf("ARstart: %p desc->bpb %x\n", &txdesc->bpb, txdesc->bpb);
- printf("ARstart: %p desc->len %x\n", &txdesc->len, txdesc->len);
- printf("ARstart: %p desc->stat %x\n", &txdesc->stat, txdesc->stat);
-#endif
-
- sc->txb_inuse++;
- sc->txb_new++;
- if(sc->txb_new == AR_TX_BLOCKS)
- sc->txb_new = 0;
-
- if(sc->xmit_busy == 0)
- ar_xmit(sc);
-
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_OFF(sc->hc->iobase);
-
- goto top_arstart;
-}
-
-#ifndef NETGRAPH
-static int
-arioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
-{
- int s, error;
- int was_up, should_be_up;
- struct ar_softc *sc = ifp->if_softc;
-
- TRC(printf("ar%d: arioctl.\n", ifp->if_unit);)
-
- was_up = ifp->if_flags & IFF_RUNNING;
-
- error = sppp_ioctl(ifp, cmd, data);
- TRC(printf("ar%d: ioctl: ifsppp.pp_flags = %x, if_flags %x.\n",
- ifp->if_unit, ((struct sppp *)ifp)->pp_flags, ifp->if_flags);)
- if(error)
- return error;
-
- if((cmd != SIOCSIFFLAGS) && cmd != (SIOCSIFADDR))
- return 0;
-
- TRC(printf("ar%d: arioctl %s.\n", ifp->if_unit,
- (cmd == SIOCSIFFLAGS) ? "SIOCSIFFLAGS" : "SIOCSIFADDR");)
-
- s = splimp();
- should_be_up = ifp->if_flags & IFF_RUNNING;
-
- if(!was_up && should_be_up) {
- /* Interface should be up -- start it. */
- ar_up(sc);
- arstart(ifp);
- /* XXX Maybe clear the IFF_UP flag so that the link
- * will only go up after sppp lcp and ipcp negotiation.
- */
- } else if(was_up && !should_be_up) {
- /* Interface should be down -- stop it. */
- ar_down(sc);
- sppp_flush(ifp);
- }
- splx(s);
- return 0;
-}
-#endif /* NETGRAPH */
-
-/*
- * This is to catch lost tx interrupts.
- */
-static void
-#ifndef NETGRAPH
-arwatchdog(struct ifnet *ifp)
-{
- struct ar_softc *sc = ifp->if_softc;
-#else /* NETGRAPH */
-arwatchdog(struct ar_softc *sc)
-{
-#endif /* NETGRAPH */
- msci_channel *msci = &sc->sca->msci[sc->scachan];
-
-#ifndef NETGRAPH
- if(!(ifp->if_flags & IFF_RUNNING))
- return;
-#endif /* NETGRAPH */
-
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_SCA(sc->hc->iobase, sc->scano);
-
- /* XXX if(sc->ifsppp.pp_if.if_flags & IFF_DEBUG) */
- printf("ar%d: transmit failed, "
- "ST0 %x, ST1 %x, ST3 %x, DSR %x.\n",
- sc->unit,
- msci->st0,
- msci->st1,
- msci->st3,
- sc->sca->dmac[DMAC_TXCH(sc->scachan)].dsr);
-
- if(msci->st1 & SCA_ST1_UDRN) {
- msci->cmd = SCA_CMD_TXABORT;
- msci->cmd = SCA_CMD_TXENABLE;
- msci->st1 = SCA_ST1_UDRN;
- }
-
- sc->xmit_busy = 0;
-#ifndef NETGRAPH
- ifp->if_flags &= ~IFF_OACTIVE;
-#else /* NETGRAPH */
- /* XXX ifp->if_flags &= ~IFF_OACTIVE; */
-#endif /* NETGRAPH */
-
- if(sc->txb_inuse && --sc->txb_inuse)
- ar_xmit(sc);
-
-#ifndef NETGRAPH
- arstart(ifp);
-#else /* NETGRAPH */
- arstart(sc);
-#endif /* NETGRAPH */
-}
-
-static void
-ar_up(struct ar_softc *sc)
-{
- sca_regs *sca;
- msci_channel *msci;
-
- sca = sc->sca;
- msci = &sca->msci[sc->scachan];
-
- TRC(printf("ar%d: sca %p, msci %p, ch %d\n",
- sc->unit, sca, msci, sc->scachan));
-
- /*
- * Enable transmitter and receiver.
- * Raise DTR and RTS.
- * Enable interrupts.
- */
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_SCA(sc->hc->iobase, sc->scano);
-
- /* XXX
- * What about using AUTO mode in msci->md0 ???
- * And what about CTS/DCD etc... ?
- */
- if(sc->hc->handshake & AR_SHSK_RTS)
- msci->ctl &= ~SCA_CTL_RTS;
- if(sc->hc->handshake & AR_SHSK_DTR) {
- sc->hc->txc_dtr[sc->scano] &= sc->scachan ?
- ~AR_TXC_DTR_DTR1 : ~AR_TXC_DTR_DTR0;
- if(sc->hc->bustype == AR_BUS_PCI)
- sc->hc->orbase[sc->hc->txc_dtr_off[sc->scano]] =
- sc->hc->txc_dtr[sc->scano];
- else
- outb(sc->hc->iobase + sc->hc->txc_dtr_off[sc->scano],
- sc->hc->txc_dtr[sc->scano]);
- }
-
- if(sc->scachan == 0) {
- sca->ier0 |= 0x0F;
- sca->ier1 |= 0x0F;
- } else {
- sca->ier0 |= 0xF0;
- sca->ier1 |= 0xF0;
- }
-
- msci->cmd = SCA_CMD_RXENABLE;
- if(sc->hc->bustype == AR_BUS_ISA)
- inb(sc->hc->iobase + AR_ID_5); /* XXX slow it down a bit. */
- msci->cmd = SCA_CMD_TXENABLE;
-
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_OFF(sc->hc->iobase);
-#ifdef NETGRAPH
- untimeout(ngar_watchdog_frame, sc, sc->handle);
- sc->handle = timeout(ngar_watchdog_frame, sc, hz);
- sc->running = 1;
-#endif /* NETGRAPH */
-}
-
-static void
-ar_down(struct ar_softc *sc)
-{
- sca_regs *sca;
- msci_channel *msci;
-
- sca = sc->sca;
- msci = &sca->msci[sc->scachan];
-
-#ifdef NETGRAPH
- untimeout(ngar_watchdog_frame, sc, sc->handle);
- sc->running = 0;
-#endif /* NETGRAPH */
- /*
- * Disable transmitter and receiver.
- * Lower DTR and RTS.
- * Disable interrupts.
- */
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_SCA(sc->hc->iobase, sc->scano);
- msci->cmd = SCA_CMD_RXDISABLE;
- if(sc->hc->bustype == AR_BUS_ISA)
- inb(sc->hc->iobase + AR_ID_5); /* XXX slow it down a bit. */
- msci->cmd = SCA_CMD_TXDISABLE;
-
- if(sc->hc->handshake & AR_SHSK_RTS)
- msci->ctl |= SCA_CTL_RTS;
- if(sc->hc->handshake & AR_SHSK_DTR) {
- sc->hc->txc_dtr[sc->scano] |= sc->scachan ?
- AR_TXC_DTR_DTR1 : AR_TXC_DTR_DTR0;
- if(sc->hc->bustype == AR_BUS_PCI)
- sc->hc->orbase[sc->hc->txc_dtr_off[sc->scano]] =
- sc->hc->txc_dtr[sc->scano];
- else
- outb(sc->hc->iobase + sc->hc->txc_dtr_off[sc->scano],
- sc->hc->txc_dtr[sc->scano]);
- }
-
- if(sc->scachan == 0) {
- sca->ier0 &= ~0x0F;
- sca->ier1 &= ~0x0F;
- } else {
- sca->ier0 &= ~0xF0;
- sca->ier1 &= ~0xF0;
- }
-
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_OFF(sc->hc->iobase);
-}
-
-static int
-ar_read_pim_iface(volatile struct ar_hardc *hc, int channel)
-{
- int ctype, i, val, x;
- volatile u_char *pimctrl;
-
- ctype = 0;
- val = 0;
-
- pimctrl = hc->orbase + AR_PIMCTRL;
-
- /* Reset the PIM */
- *pimctrl = 0x00;
- *pimctrl = AR_PIM_STROBE;
-
- /* Check if there is a PIM */
- *pimctrl = 0x00;
- *pimctrl = AR_PIM_READ;
- x = *pimctrl;
- TRC(printf("x = %x", x));
- if(x & AR_PIM_DATA) {
- printf("No PIM installed\n");
- return(AR_IFACE_UNKNOWN);
- }
-
- x = (x >> 1) & 0x01;
- val |= x << 0;
-
- /* Now read the next 15 bits */
- for(i = 1; i < 16; i++) {
- *pimctrl = AR_PIM_READ;
- *pimctrl = AR_PIM_READ | AR_PIM_STROBE;
- x = *pimctrl;
- TRC(printf(" %x ", x));
- x = (x >> 1) & 0x01;
- val |= x << i;
- if(i == 8 && (val & 0x000f) == 0x0004) {
- int ii;
-
- /* Start bit */
- *pimctrl = AR_PIM_A2D_DOUT | AR_PIM_A2D_STROBE;
- *pimctrl = AR_PIM_A2D_DOUT;
-
- /* Mode bit */
- *pimctrl = AR_PIM_A2D_DOUT | AR_PIM_A2D_STROBE;
- *pimctrl = AR_PIM_A2D_DOUT;
-
- /* Sign bit */
- *pimctrl = AR_PIM_A2D_DOUT | AR_PIM_A2D_STROBE;
- *pimctrl = AR_PIM_A2D_DOUT;
-
- /* Select channel */
- *pimctrl = AR_PIM_A2D_STROBE | ((channel & 2) << 2);
- *pimctrl = ((channel & 2) << 2);
- *pimctrl = AR_PIM_A2D_STROBE | ((channel & 1) << 3);
- *pimctrl = ((channel & 1) << 3);
-
- *pimctrl = AR_PIM_A2D_STROBE;
-
- x = *pimctrl;
- if(x & AR_PIM_DATA)
- printf("\nOops A2D start bit not zero (%X)\n", x);
-
- for(ii = 7; ii >= 0; ii--) {
- *pimctrl = 0x00;
- *pimctrl = AR_PIM_A2D_STROBE;
- x = *pimctrl;
- if(x & AR_PIM_DATA)
- ctype |= 1 << ii;
- }
- }
- }
- TRC(printf("\nPIM val %x, ctype %x, %d\n", val, ctype, ctype));
- *pimctrl = AR_PIM_MODEG;
- *pimctrl = AR_PIM_MODEG | AR_PIM_AUTO_LED;
- if(ctype > 255)
- return(AR_IFACE_UNKNOWN);
- if(ctype > 239)
- return(AR_IFACE_V_35);
- if(ctype > 207)
- return(AR_IFACE_EIA_232);
- if(ctype > 178)
- return(AR_IFACE_X_21);
- if(ctype > 150)
- return(AR_IFACE_EIA_530);
- if(ctype > 25)
- return(AR_IFACE_UNKNOWN);
- if(ctype > 7)
- return(AR_IFACE_LOOPBACK);
- return(AR_IFACE_UNKNOWN);
-}
-
-/*
- * Initialize the card, allocate memory for the ar_softc structures
- * and fill in the pointers.
- */
-static void
-arc_init(struct ar_hardc *hc)
-{
- struct ar_softc *sc;
- int x;
- u_int chanmem;
- u_int bufmem;
- u_int next;
- u_int descneeded;
- u_char isr, mar;
-
- MALLOC(sc, struct ar_softc *,
- hc->numports * sizeof(struct ar_softc), M_DEVBUF, M_WAITOK);
- if (sc == NULL)
- return;
- bzero(sc, hc->numports * sizeof(struct ar_softc));
- hc->sc = sc;
-
- hc->txc_dtr[0] = AR_TXC_DTR_NOTRESET |
- AR_TXC_DTR_DTR0 | AR_TXC_DTR_DTR1;
- hc->txc_dtr[1] = AR_TXC_DTR_DTR0 | AR_TXC_DTR_DTR1;
- hc->txc_dtr_off[0] = AR_TXC_DTR0;
- hc->txc_dtr_off[1] = AR_TXC_DTR2;
- if(hc->bustype == AR_BUS_PCI) {
- hc->txc_dtr_off[0] *= 4;
- hc->txc_dtr_off[1] *= 4;
- }
-
- /*
- * reset the card and wait at least 1uS.
- */
- if(hc->bustype == AR_BUS_PCI)
- hc->orbase[AR_TXC_DTR0 * 4] = ~AR_TXC_DTR_NOTRESET &
- hc->txc_dtr[0];
- else
- outb(hc->iobase + AR_TXC_DTR0, ~AR_TXC_DTR_NOTRESET &
- hc->txc_dtr[0]);
- DELAY(2);
- if(hc->bustype == AR_BUS_PCI)
- hc->orbase[AR_TXC_DTR0 * 4] = hc->txc_dtr[0];
- else
- outb(hc->iobase + AR_TXC_DTR0, hc->txc_dtr[0]);
-
- if(hc->bustype == AR_BUS_ISA) {
- /*
- * Configure the card.
- * Mem address, irq,
- */
- mar = kvtop(hc->mem_start) >> 16;
- isr = irqtable[ffs(hc->isa_irq) - 1] << 1;
- if(isr == 0)
- printf("ar%d: Warning illegal interrupt %d\n",
- hc->cunit, ffs(hc->isa_irq) - 1);
- isr = isr | ((kvtop(hc->mem_start) & 0xc000) >> 10);
-
- hc->sca[0] = (sca_regs *)hc->mem_start;
- hc->sca[1] = (sca_regs *)hc->mem_start;
-
- outb(hc->iobase + AR_MEM_SEL, mar);
- outb(hc->iobase + AR_INT_SEL, isr | AR_INTS_CEN);
- }
-
- if(hc->bustype == AR_BUS_PCI && hc->interface[0] == AR_IFACE_PIM)
- for(x = 0; x < hc->numports; x++)
- hc->interface[x] = ar_read_pim_iface(hc, x);
-
- /*
- * Set the TX clock direction and enable TX.
- */
- for(x=0;x<hc->numports;x++) {
- switch(hc->interface[x]) {
- case AR_IFACE_V_35:
- hc->txc_dtr[x / NCHAN] |= (x % NCHAN == 0) ?
- AR_TXC_DTR_TX0 : AR_TXC_DTR_TX1;
- hc->txc_dtr[x / NCHAN] |= (x % NCHAN == 0) ?
- AR_TXC_DTR_TXCS0 : AR_TXC_DTR_TXCS1;
- break;
- case AR_IFACE_EIA_530:
- case AR_IFACE_COMBO:
- case AR_IFACE_X_21:
- hc->txc_dtr[x / NCHAN] |= (x % NCHAN == 0) ?
- AR_TXC_DTR_TX0 : AR_TXC_DTR_TX1;
- break;
- }
- }
-
- if(hc->bustype == AR_BUS_PCI)
- hc->orbase[AR_TXC_DTR0 * 4] = hc->txc_dtr[0];
- else
- outb(hc->iobase + AR_TXC_DTR0, hc->txc_dtr[0]);
- if(hc->numports > NCHAN) {
- if(hc->bustype == AR_BUS_PCI)
- hc->orbase[AR_TXC_DTR2 * 4] = hc->txc_dtr[1];
- else
- outb(hc->iobase + AR_TXC_DTR2, hc->txc_dtr[1]);
- }
-
- chanmem = hc->memsize / hc->numports;
- next = 0;
-
- for(x=0;x<hc->numports;x++, sc++) {
- int blk;
-
- sc->sca = hc->sca[x / NCHAN];
-
- for(blk = 0; blk < AR_TX_BLOCKS; blk++) {
- sc->block[blk].txdesc = next;
- bufmem = (16 * 1024) / AR_TX_BLOCKS;
- descneeded = bufmem / AR_BUF_SIZ;
- sc->block[blk].txstart = sc->block[blk].txdesc +
- ((((descneeded * sizeof(sca_descriptor)) /
- AR_BUF_SIZ) + 1) * AR_BUF_SIZ);
- sc->block[blk].txend = next + bufmem;
- sc->block[blk].txmax =
- (sc->block[blk].txend - sc->block[blk].txstart)
- / AR_BUF_SIZ;
- next += bufmem;
-
- TRC(printf("ar%d: blk %d: txdesc %x, txstart %x, "
- "txend %x, txmax %d\n",
- x,
- blk,
- sc->block[blk].txdesc,
- sc->block[blk].txstart,
- sc->block[blk].txend,
- sc->block[blk].txmax));
- }
-
- sc->rxdesc = next;
- bufmem = chanmem - (bufmem * AR_TX_BLOCKS);
- descneeded = bufmem / AR_BUF_SIZ;
- sc->rxstart = sc->rxdesc +
- ((((descneeded * sizeof(sca_descriptor)) /
- AR_BUF_SIZ) + 1) * AR_BUF_SIZ);
- sc->rxend = next + bufmem;
- sc->rxmax = (sc->rxend - sc->rxstart) / AR_BUF_SIZ;
- next += bufmem;
- TRC(printf("ar%d: rxdesc %x, rxstart %x, "
- "rxend %x, rxmax %d\n",
- x, sc->rxdesc, sc->rxstart, sc->rxend, sc->rxmax));
- }
-
- if(hc->bustype == AR_BUS_PCI)
- hc->orbase[AR_PIMCTRL] = AR_PIM_MODEG | AR_PIM_AUTO_LED;
-}
-
-
-/*
- * The things done here are channel independent.
- *
- * Configure the sca waitstates.
- * Configure the global interrupt registers.
- * Enable master dma enable.
- */
-static void
-ar_init_sca(struct ar_hardc *hc, int scano)
-{
- sca_regs *sca;
-
- sca = hc->sca[scano];
- if(hc->bustype == AR_BUS_ISA)
- ARC_SET_SCA(hc->iobase, scano);
-
- /*
- * Do the wait registers.
- * Set everything to 0 wait states.
- */
- sca->pabr0 = 0;
- sca->pabr1 = 0;
- sca->wcrl = 0;
- sca->wcrm = 0;
- sca->wcrh = 0;
-
- /*
- * Configure the interrupt registers.
- * Most are cleared until the interface is configured.
- */
- sca->ier0 = 0x00; /* MSCI interrupts... Not used with dma. */
- sca->ier1 = 0x00; /* DMAC interrupts */
- sca->ier2 = 0x00; /* TIMER interrupts... Not used yet. */
- sca->itcr = 0x00; /* Use ivr and no intr ack */
- sca->ivr = 0x40; /* Fill in the interrupt vector. */
- sca->imvr = 0x40;
-
- /*
- * Configure the timers.
- * XXX Later
- */
-
-
- /*
- * Set the DMA channel priority to rotate between
- * all four channels.
- *
- * Enable all dma channels.
- */
- if(hc->bustype == AR_BUS_PCI) {
- u_char *t;
-
- /*
- * Stupid problem with the PCI interface chip that break
- * things.
- * XXX
- */
- t = (u_char *)sca;
- t[AR_PCI_SCA_PCR] = SCA_PCR_PR2;
- t[AR_PCI_SCA_DMER] = SCA_DMER_EN;
- } else {
- sca->pcr = SCA_PCR_PR2;
- sca->dmer = SCA_DMER_EN;
- }
-}
-
-
-/*
- * Configure the msci
- *
- * NOTE: The serial port configuration is hardcoded at the moment.
- */
-static void
-ar_init_msci(struct ar_softc *sc)
-{
- msci_channel *msci;
-
- msci = &sc->sca->msci[sc->scachan];
-
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_SCA(sc->hc->iobase, sc->scano);
-
- msci->cmd = SCA_CMD_RESET;
-
- msci->md0 = SCA_MD0_CRC_1 |
- SCA_MD0_CRC_CCITT |
- SCA_MD0_CRC_ENABLE |
- SCA_MD0_MODE_HDLC;
- msci->md1 = SCA_MD1_NOADDRCHK;
- msci->md2 = SCA_MD2_DUPLEX | SCA_MD2_NRZ;
-
- /*
- * Acording to the manual I should give a reset after changing the
- * mode registers.
- */
- msci->cmd = SCA_CMD_RXRESET;
- msci->ctl = SCA_CTL_IDLPAT | SCA_CTL_UDRNC | SCA_CTL_RTS;
-
- /*
- * For now all interfaces are programmed to use the RX clock for
- * the TX clock.
- */
- switch(sc->hc->interface[sc->subunit]) {
- case AR_IFACE_V_35:
- msci->rxs = SCA_RXS_CLK_RXC0 | SCA_RXS_DIV1;
- msci->txs = SCA_TXS_CLK_TXC | SCA_TXS_DIV1;
- break;
- case AR_IFACE_X_21:
- case AR_IFACE_EIA_530:
- case AR_IFACE_COMBO:
- msci->rxs = SCA_RXS_CLK_RXC0 | SCA_RXS_DIV1;
- msci->txs = SCA_TXS_CLK_RX | SCA_TXS_DIV1;
- }
-
- msci->tmc = 153; /* This give 64k for loopback */
-
- /* XXX
- * Disable all interrupts for now. I think if you are using
- * the dmac you don't use these interrupts.
- */
- msci->ie0 = 0;
- msci->ie1 = 0x0C; /* XXX CTS and DCD (DSR on 570I) level change. */
- msci->ie2 = 0;
- msci->fie = 0;
-
- msci->sa0 = 0;
- msci->sa1 = 0;
-
- msci->idl = 0x7E; /* XXX This is what cisco does. */
-
- /*
- * This is what the ARNET diags use.
- */
- msci->rrc = 0x0E;
- msci->trc0 = 0x12;
- msci->trc1 = 0x1F;
-}
-
-/*
- * Configure the rx dma controller.
- */
-static void
-ar_init_rx_dmac(struct ar_softc *sc)
-{
- dmac_channel *dmac;
- sca_descriptor *rxd;
- u_int rxbuf;
- u_int rxda;
- u_int rxda_d;
- int x = 0;
-
- dmac = &sc->sca->dmac[DMAC_RXCH(sc->scachan)];
-
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_MEM(sc->hc->iobase, sc->rxdesc);
-
- rxd = (sca_descriptor *)(sc->hc->mem_start + (sc->rxdesc&sc->hc->winmsk));
- rxda_d = (u_int)sc->hc->mem_start - (sc->rxdesc & ~sc->hc->winmsk);
-
- for(rxbuf=sc->rxstart;rxbuf<sc->rxend;rxbuf += AR_BUF_SIZ, rxd++) {
- rxda = (u_int)&rxd[1] - rxda_d;
- rxd->cp = (u_short)(rxda & 0xfffful);
-
- x++;
- if(x < 6)
- TRC(printf("Descrp %p, data pt %x, data %x, ",
- rxd, rxda, rxbuf));
-
- rxd->bp = (u_short)(rxbuf & 0xfffful);
- rxd->bpb = (u_char)((rxbuf >> 16) & 0xff);
- rxd->len = 0;
- rxd->stat = 0xff; /* The sca write here when it is finished. */
-
- if(x < 6)
- TRC(printf("bpb %x, bp %x.\n", rxd->bpb, rxd->bp));
- }
- rxd--;
- rxd->cp = (u_short)(sc->rxdesc & 0xfffful);
-
- sc->rxhind = 0;
-
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_SCA(sc->hc->iobase, sc->scano);
-
- dmac->dsr = 0; /* Disable DMA transfer */
- dmac->dcr = SCA_DCR_ABRT;
-
- /* XXX maybe also SCA_DMR_CNTE */
- dmac->dmr = SCA_DMR_TMOD | SCA_DMR_NF;
- dmac->bfl = AR_BUF_SIZ;
-
- dmac->cda = (u_short)(sc->rxdesc & 0xffff);
- dmac->sarb = (u_char)((sc->rxdesc >> 16) & 0xff);
-
- rxd = (sca_descriptor *)sc->rxstart;
- dmac->eda = (u_short)((u_int)&rxd[sc->rxmax - 1] & 0xffff);
-
- dmac->dir = 0xF0;
-
- dmac->dsr = SCA_DSR_DE;
-}
-
-/*
- * Configure the TX DMA descriptors.
- * Initialize the needed values and chain the descriptors.
- */
-static void
-ar_init_tx_dmac(struct ar_softc *sc)
-{
- dmac_channel *dmac;
- struct buf_block *blkp;
- int blk;
- sca_descriptor *txd;
- u_int txbuf;
- u_int txda;
- u_int txda_d;
-
- dmac = &sc->sca->dmac[DMAC_TXCH(sc->scachan)];
-
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_MEM(sc->hc->iobase, sc->block[0].txdesc);
-
- for(blk = 0; blk < AR_TX_BLOCKS; blk++) {
- blkp = &sc->block[blk];
- txd = (sca_descriptor *)(sc->hc->mem_start +
- (blkp->txdesc&sc->hc->winmsk));
- txda_d = (u_int)sc->hc->mem_start -
- (blkp->txdesc & ~sc->hc->winmsk);
-
- txbuf=blkp->txstart;
- for(;txbuf<blkp->txend;txbuf += AR_BUF_SIZ, txd++) {
- txda = (u_int)&txd[1] - txda_d;
- txd->cp = (u_short)(txda & 0xfffful);
-
- txd->bp = (u_short)(txbuf & 0xfffful);
- txd->bpb = (u_char)((txbuf >> 16) & 0xff);
- TRC(printf("ar%d: txbuf %x, bpb %x, bp %x\n",
- sc->unit, txbuf, txd->bpb, txd->bp));
- txd->len = 0;
- txd->stat = 0;
- }
- txd--;
- txd->cp = (u_short)(blkp->txdesc & 0xfffful);
-
- blkp->txtail = (u_int)txd - (u_int)sc->hc->mem_start;
- TRC(printf("TX Descriptors start %x, end %x.\n",
- blkp->txdesc,
- blkp->txtail));
- }
-
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_SCA(sc->hc->iobase, sc->scano);
-
- dmac->dsr = 0; /* Disable DMA */
- dmac->dcr = SCA_DCR_ABRT;
- dmac->dmr = SCA_DMR_TMOD | SCA_DMR_NF;
- dmac->dir = SCA_DIR_EOT | SCA_DIR_BOF | SCA_DIR_COF;
-
- dmac->sarb = (u_char)((sc->block[0].txdesc >> 16) & 0xff);
-}
-
-
-/*
- * Look through the descriptors to see if there is a complete packet
- * available. Stop if we get to where the sca is busy.
- *
- * Return the length and status of the packet.
- * Return nonzero if there is a packet available.
- *
- * NOTE:
- * It seems that we get the interrupt a bit early. The updateing of
- * descriptor values is not always completed when this is called.
- */
-static int
-ar_packet_avail(struct ar_softc *sc,
- int *len,
- u_char *rxstat)
-{
- dmac_channel *dmac;
- sca_descriptor *rxdesc;
- sca_descriptor *endp;
- sca_descriptor *cda;
-
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_SCA(sc->hc->iobase, sc->scano);
- dmac = &sc->sca->dmac[DMAC_RXCH(sc->scachan)];
- cda = (sca_descriptor *)(sc->hc->mem_start +
- ((((u_int)dmac->sarb << 16) + dmac->cda) & sc->hc->winmsk));
-
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_MEM(sc->hc->iobase, sc->rxdesc);
- rxdesc = (sca_descriptor *)
- (sc->hc->mem_start + (sc->rxdesc & sc->hc->winmsk));
- endp = rxdesc;
- rxdesc = &rxdesc[sc->rxhind];
- endp = &endp[sc->rxmax];
-
- *len = 0;
-
- while(rxdesc != cda) {
- *len += rxdesc->len;
-
- if(rxdesc->stat & SCA_DESC_EOM) {
- *rxstat = rxdesc->stat;
- TRC(printf("ar%d: PKT AVAIL len %d, %x.\n",
- sc->unit, *len, *rxstat));
- return 1;
- }
-
- rxdesc++;
- if(rxdesc == endp)
- rxdesc = (sca_descriptor *)
- (sc->hc->mem_start + (sc->rxdesc & sc->hc->winmsk));
- }
-
- *len = 0;
- *rxstat = 0;
- return 0;
-}
-
-
-/*
- * Copy a packet from the on card memory into a provided mbuf.
- * Take into account that buffers wrap and that a packet may
- * be larger than a buffer.
- */
-static void
-ar_copy_rxbuf(struct mbuf *m,
- struct ar_softc *sc,
- int len)
-{
- sca_descriptor *rxdesc;
- u_int rxdata;
- u_int rxmax;
- u_int off = 0;
- u_int tlen;
-
- rxdata = sc->rxstart + (sc->rxhind * AR_BUF_SIZ);
- rxmax = sc->rxstart + (sc->rxmax * AR_BUF_SIZ);
-
- rxdesc = (sca_descriptor *)
- (sc->hc->mem_start + (sc->rxdesc & sc->hc->winmsk));
- rxdesc = &rxdesc[sc->rxhind];
-
- while(len) {
- tlen = (len < AR_BUF_SIZ) ? len : AR_BUF_SIZ;
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_MEM(sc->hc->iobase, rxdata);
- bcopy(sc->hc->mem_start + (rxdata & sc->hc->winmsk),
- mtod(m, caddr_t) + off,
- tlen);
-
- off += tlen;
- len -= tlen;
-
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_MEM(sc->hc->iobase, sc->rxdesc);
- rxdesc->len = 0;
- rxdesc->stat = 0xff;
-
- rxdata += AR_BUF_SIZ;
- rxdesc++;
- if(rxdata == rxmax) {
- rxdata = sc->rxstart;
- rxdesc = (sca_descriptor *)
- (sc->hc->mem_start + (sc->rxdesc & sc->hc->winmsk));
- }
- }
-}
-
-/*
- * If single is set, just eat a packet. Otherwise eat everything up to
- * where cda points. Update pointers to point to the next packet.
- */
-static void
-ar_eat_packet(struct ar_softc *sc, int single)
-{
- dmac_channel *dmac;
- sca_descriptor *rxdesc;
- sca_descriptor *endp;
- sca_descriptor *cda;
- int loopcnt = 0;
- u_char stat;
-
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_SCA(sc->hc->iobase, sc->scano);
- dmac = &sc->sca->dmac[DMAC_RXCH(sc->scachan)];
- cda = (sca_descriptor *)(sc->hc->mem_start +
- ((((u_int)dmac->sarb << 16) + dmac->cda) & sc->hc->winmsk));
-
- /*
- * Loop until desc->stat == (0xff || EOM)
- * Clear the status and length in the descriptor.
- * Increment the descriptor.
- */
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_MEM(sc->hc->iobase, sc->rxdesc);
- rxdesc = (sca_descriptor *)
- (sc->hc->mem_start + (sc->rxdesc & sc->hc->winmsk));
- endp = rxdesc;
- rxdesc = &rxdesc[sc->rxhind];
- endp = &endp[sc->rxmax];
-
- while(rxdesc != cda) {
- loopcnt++;
- if(loopcnt > sc->rxmax) {
- printf("ar%d: eat pkt %d loop, cda %p, "
- "rxdesc %p, stat %x.\n",
- sc->unit,
- loopcnt,
- (void *)cda,
- (void *)rxdesc,
- rxdesc->stat);
- break;
- }
-
- stat = rxdesc->stat;
-
- rxdesc->len = 0;
- rxdesc->stat = 0xff;
-
- rxdesc++;
- sc->rxhind++;
- if(rxdesc == endp) {
- rxdesc = (sca_descriptor *)
- (sc->hc->mem_start + (sc->rxdesc & sc->hc->winmsk));
- sc->rxhind = 0;
- }
-
- if(single && (stat == SCA_DESC_EOM))
- break;
- }
-
- /*
- * Update the eda to the previous descriptor.
- */
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_SCA(sc->hc->iobase, sc->scano);
-
- rxdesc = (sca_descriptor *)sc->rxdesc;
- rxdesc = &rxdesc[(sc->rxhind + sc->rxmax - 2 ) % sc->rxmax];
-
- sc->sca->dmac[DMAC_RXCH(sc->scachan)].eda =
- (u_short)((u_int)rxdesc & 0xffff);
-}
-
-
-/*
- * While there is packets available in the rx buffer, read them out
- * into mbufs and ship them off.
- */
-static void
-ar_get_packets(struct ar_softc *sc)
-{
- sca_descriptor *rxdesc;
- struct mbuf *m = NULL;
- int i;
- int len;
- u_char rxstat;
-
- while(ar_packet_avail(sc, &len, &rxstat)) {
- TRC(printf("apa: len %d, rxstat %x\n", len, rxstat));
- if(((rxstat & SCA_DESC_ERRORS) == 0) && (len < MCLBYTES)) {
- MGETHDR(m, M_DONTWAIT, MT_DATA);
- if(m == NULL) {
- /* eat packet if get mbuf fail!! */
- ar_eat_packet(sc, 1);
- continue;
- }
-#ifndef NETGRAPH
- m->m_pkthdr.rcvif = &sc->ifsppp.pp_if;
-#else /* NETGRAPH */
- m->m_pkthdr.rcvif = NULL;
- sc->inbytes += len;
- sc->inlast = 0;
-#endif /* NETGRAPH */
- m->m_pkthdr.len = m->m_len = len;
- if(len > MHLEN) {
- MCLGET(m, M_DONTWAIT);
- if((m->m_flags & M_EXT) == 0) {
- m_freem(m);
- ar_eat_packet(sc, 1);
- continue;
- }
- }
- ar_copy_rxbuf(m, sc, len);
-#ifndef NETGRAPH
- if(sc->ifsppp.pp_if.if_bpf)
- bpf_mtap(&sc->ifsppp.pp_if, m);
- sppp_input(&sc->ifsppp.pp_if, m);
- sc->ifsppp.pp_if.if_ipackets++;
-#else /* NETGRAPH */
- ng_queue_data(sc->hook, m, NULL);
- sc->ipackets++;
-#endif /* NETGRAPH */
-
- /*
- * Update the eda to the previous descriptor.
- */
- i = (len + AR_BUF_SIZ - 1) / AR_BUF_SIZ;
- sc->rxhind = (sc->rxhind + i) % sc->rxmax;
-
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_SCA(sc->hc->iobase, sc->scano);
-
- rxdesc = (sca_descriptor *)sc->rxdesc;
- rxdesc =
- &rxdesc[(sc->rxhind + sc->rxmax - 2 ) % sc->rxmax];
-
- sc->sca->dmac[DMAC_RXCH(sc->scachan)].eda =
- (u_short)((u_int)rxdesc & 0xffff);
- } else {
- int tries = 5;
-
- while((rxstat == 0xff) && --tries)
- ar_packet_avail(sc, &len, &rxstat);
-
- /*
- * It look like we get an interrupt early
- * sometimes and then the status is not
- * filled in yet.
- */
- if(tries && (tries != 5))
- continue;
-
- ar_eat_packet(sc, 1);
-
-#ifndef NETGRAPH
- sc->ifsppp.pp_if.if_ierrors++;
-#else /* NETGRAPH */
- sc->ierrors[0]++;
-#endif /* NETGRAPH */
-
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_SCA(sc->hc->iobase, sc->scano);
-
- TRCL(printf("ar%d: Receive error chan %d, "
- "stat %x, msci st3 %x,"
- "rxhind %d, cda %x, eda %x.\n",
- sc->unit,
- sc->scachan,
- rxstat,
- sc->sca->msci[sc->scachan].st3,
- sc->rxhind,
- sc->sca->dmac[
- DMAC_RXCH(sc->scachan)].cda,
- sc->sca->dmac[
- DMAC_RXCH(sc->scachan)].eda));
- }
- }
-}
-
-
-/*
- * All DMA interrupts come here.
- *
- * Each channel has two interrupts.
- * Interrupt A for errors and Interrupt B for normal stuff like end
- * of transmit or receive dmas.
- */
-static void
-ar_dmac_intr(struct ar_hardc *hc, int scano, u_char isr1)
-{
- u_char dsr;
- u_char dotxstart = isr1;
- int mch;
- struct ar_softc *sc;
- sca_regs *sca;
- dmac_channel *dmac;
-
- sca = hc->sca[scano];
- mch = 0;
- /*
- * Shortcut if there is no interrupts for dma channel 0 or 1
- */
- if((isr1 & 0x0F) == 0) {
- mch = 1;
- isr1 >>= 4;
- }
-
- do {
- sc = &hc->sc[mch + (NCHAN * scano)];
-
- /*
- * Transmit channel
- */
- if(isr1 & 0x0C) {
- dmac = &sca->dmac[DMAC_TXCH(mch)];
-
- if(hc->bustype == AR_BUS_ISA)
- ARC_SET_SCA(hc->iobase, scano);
-
- dsr = dmac->dsr;
- dmac->dsr = dsr;
-
- /* Counter overflow */
- if(dsr & SCA_DSR_COF) {
- printf("ar%d: TX DMA Counter overflow, "
- "txpacket no %lu.\n",
- sc->unit,
-#ifndef NETGRAPH
- sc->ifsppp.pp_if.if_opackets);
- sc->ifsppp.pp_if.if_oerrors++;
-#else /* NETGRAPH */
- sc->opackets);
- sc->oerrors++;
-#endif /* NETGRAPH */
- }
-
- /* Buffer overflow */
- if(dsr & SCA_DSR_BOF) {
- printf("ar%d: TX DMA Buffer overflow, "
- "txpacket no %lu, dsr %02x, "
- "cda %04x, eda %04x.\n",
- sc->unit,
-#ifndef NETGRAPH
- sc->ifsppp.pp_if.if_opackets,
-#else /* NETGRAPH */
- sc->opackets,
-#endif /* NETGRAPH */
- dsr,
- dmac->cda,
- dmac->eda);
-#ifndef NETGRAPH
- sc->ifsppp.pp_if.if_oerrors++;
-#else /* NETGRAPH */
- sc->oerrors++;
-#endif /* NETGRAPH */
- }
-
- /* End of Transfer */
- if(dsr & SCA_DSR_EOT) {
- /*
- * This should be the most common case.
- *
- * Clear the IFF_OACTIVE flag.
- *
- * Call arstart to start a new transmit if
- * there is data to transmit.
- */
- sc->xmit_busy = 0;
-#ifndef NETGRAPH
- sc->ifsppp.pp_if.if_flags &= ~IFF_OACTIVE;
- sc->ifsppp.pp_if.if_timer = 0;
-#else /* NETGRAPH */
- /* XXX c->ifsppp.pp_if.if_flags &= ~IFF_OACTIVE; */
- sc->out_dog = 0; /* XXX */
-#endif /* NETGRAPH */
-
- if(sc->txb_inuse && --sc->txb_inuse)
- ar_xmit(sc);
- }
- }
-
- /*
- * Receive channel
- */
- if(isr1 & 0x03) {
- dmac = &sca->dmac[DMAC_RXCH(mch)];
-
- if(hc->bustype == AR_BUS_ISA)
- ARC_SET_SCA(hc->iobase, scano);
-
- dsr = dmac->dsr;
- dmac->dsr = dsr;
-
- TRC(printf("AR: RX DSR %x\n", dsr));
-
- /* End of frame */
- if(dsr & SCA_DSR_EOM) {
- TRC(int tt = sc->ifsppp.pp_if.if_ipackets;)
- TRC(int ind = sc->rxhind;)
-
- ar_get_packets(sc);
- TRC(
-#ifndef NETGRAPH
- if(tt == sc->ifsppp.pp_if.if_ipackets) {
-#else /* NETGRAPH */
- if(tt == sc->ipackets) {
-#endif /* NETGRAPH */
- sca_descriptor *rxdesc;
- int i;
-
- if(hc->bustype == AR_BUS_ISA)
- ARC_SET_SCA(hc->iobase, scano);
- printf("AR: RXINTR isr1 %x, dsr %x, "
- "no data %d pkts, orxhind %d.\n",
- dotxstart,
- dsr,
- tt,
- ind);
- printf("AR: rxdesc %x, rxstart %x, "
- "rxend %x, rxhind %d, "
- "rxmax %d.\n",
- sc->rxdesc,
- sc->rxstart,
- sc->rxend,
- sc->rxhind,
- sc->rxmax);
- printf("AR: cda %x, eda %x.\n",
- dmac->cda,
- dmac->eda);
-
- if(sc->hc->bustype == AR_BUS_ISA)
- ARC_SET_MEM(sc->hc->iobase,
- sc->rxdesc);
- rxdesc = (sca_descriptor *)
- (sc->hc->mem_start +
- (sc->rxdesc & sc->hc->winmsk));
- rxdesc = &rxdesc[sc->rxhind];
- for(i=0;i<3;i++,rxdesc++)
- printf("AR: rxdesc->stat %x, "
- "len %d.\n",
- rxdesc->stat,
- rxdesc->len);
- })
- }
-
- /* Counter overflow */
- if(dsr & SCA_DSR_COF) {
- printf("ar%d: RX DMA Counter overflow, "
- "rxpkts %lu.\n",
- sc->unit,
-#ifndef NETGRAPH
- sc->ifsppp.pp_if.if_ipackets);
- sc->ifsppp.pp_if.if_ierrors++;
-#else /* NETGRAPH */
- sc->ipackets);
- sc->ierrors[1]++;
-#endif /* NETGRAPH */
- }
-
- /* Buffer overflow */
- if(dsr & SCA_DSR_BOF) {
- if(hc->bustype == AR_BUS_ISA)
- ARC_SET_SCA(hc->iobase, scano);
- printf("ar%d: RX DMA Buffer overflow, "
- "rxpkts %lu, rxind %d, "
- "cda %x, eda %x, dsr %x.\n",
- sc->unit,
-#ifndef NETGRAPH
- sc->ifsppp.pp_if.if_ipackets,
-#else /* NETGRAPH */
- sc->ipackets,
-#endif /* NETGRAPH */
- sc->rxhind,
- dmac->cda,
- dmac->eda,
- dsr);
- /*
- * Make sure we eat as many as possible.
- * Then get the system running again.
- */
- ar_eat_packet(sc, 0);
-#ifndef NETGRAPH
- sc->ifsppp.pp_if.if_ierrors++;
-#else /* NETGRAPH */
- sc->ierrors[2]++;
-#endif /* NETGRAPH */
- if(hc->bustype == AR_BUS_ISA)
- ARC_SET_SCA(hc->iobase, scano);
- sca->msci[mch].cmd = SCA_CMD_RXMSGREJ;
- dmac->dsr = SCA_DSR_DE;
-
- TRC(printf("ar%d: RX DMA Buffer overflow, "
- "rxpkts %lu, rxind %d, "
- "cda %x, eda %x, dsr %x. After\n",
- sc->unit,
- sc->ifsppp.pp_if.if_ipackets,
- sc->rxhind,
- dmac->cda,
- dmac->eda,
- dmac->dsr);)
- }
-
- /* End of Transfer */
- if(dsr & SCA_DSR_EOT) {
- /*
- * If this happen, it means that we are
- * receiving faster than what the processor
- * can handle.
- *
- * XXX We should enable the dma again.
- */
- printf("ar%d: RX End of transfer, rxpkts %lu.\n",
- sc->unit,
-#ifndef NETGRAPH
- sc->ifsppp.pp_if.if_ipackets);
- sc->ifsppp.pp_if.if_ierrors++;
-#else /* NETGRAPH */
- sc->ipackets);
- sc->ierrors[3]++;
-#endif /* NETGRAPH */
- }
- }
-
- isr1 >>= 4;
-
- mch++;
- }while((mch<NCHAN) && isr1);
-
- /*
- * Now that we have done all the urgent things, see if we
- * can fill the transmit buffers.
- */
- for(mch = 0; mch < NCHAN; mch++) {
- if(dotxstart & 0x0C) {
- sc = &hc->sc[mch + (NCHAN * scano)];
-#ifndef NETGRAPH
- arstart(&sc->ifsppp.pp_if);
-#else /* NETGRAPH */
- arstart(sc);
-#endif /* NETGRAPH */
- }
- dotxstart >>= 4;
- }
-}
-
-static void
-ar_msci_intr(struct ar_hardc *hc, int scano, u_char isr0)
-{
- printf("arc%d: ARINTR: MSCI\n", hc->cunit);
-}
-
-static void
-ar_timer_intr(struct ar_hardc *hc, int scano, u_char isr2)
-{
- printf("arc%d: ARINTR: TIMER\n", hc->cunit);
-}
-
-
-#ifdef NETGRAPH
-/*****************************************
- * Device timeout/watchdog routine.
- * called once per second.
- * checks to see that if activity was expected, that it hapenned.
- * At present we only look to see if expected output was completed.
- */
-static void
-ngar_watchdog_frame(void * arg)
-{
- struct ar_softc * sc = arg;
- int s;
- int speed;
-
- if(sc->running == 0)
- return; /* if we are not running let timeouts die */
- /*
- * calculate the apparent throughputs
- * XXX a real hack
- */
- s = splimp();
- speed = sc->inbytes - sc->lastinbytes;
- sc->lastinbytes = sc->inbytes;
- if ( sc->inrate < speed )
- sc->inrate = speed;
- speed = sc->outbytes - sc->lastoutbytes;
- sc->lastoutbytes = sc->outbytes;
- if ( sc->outrate < speed )
- sc->outrate = speed;
- sc->inlast++;
- splx(s);
-
- if ((sc->inlast > QUITE_A_WHILE)
- && (sc->out_deficit > LOTS_OF_PACKETS)) {
- log(LOG_ERR, "ar%d: No response from remote end\n", sc->unit);
- s = splimp();
- ar_down(sc);
- ar_up(sc);
- sc->inlast = sc->out_deficit = 0;
- splx(s);
- } else if ( sc->xmit_busy ) { /* no TX -> no TX timeouts */
- if (sc->out_dog == 0) {
- log(LOG_ERR, "ar%d: Transmit failure.. no clock?\n",
- sc->unit);
- s = splimp();
- arwatchdog(sc);
-#if 0
- ar_down(sc);
- ar_up(sc);
-#endif
- splx(s);
- sc->inlast = sc->out_deficit = 0;
- } else {
- sc->out_dog--;
- }
- }
- sc->handle = timeout(ngar_watchdog_frame, sc, hz);
-}
-
-/***********************************************************************
- * This section contains the methods for the Netgraph interface
- ***********************************************************************/
-/*
- * It is not possible or allowable to create a node of this type.
- * If the hardware exists, it will already have created it.
- */
-static int
-ngar_constructor(node_p *nodep)
-{
- return (EINVAL);
-}
-
-/*
- * give our ok for a hook to be added...
- * If we are not running this should kick the device into life.
- * The hook's private info points to our stash of info about that
- * channel.
- */
-static int
-ngar_newhook(node_p node, hook_p hook, const char *name)
-{
- struct ar_softc * sc = node->private;
-
- /*
- * check if it's our friend the debug hook
- */
- if (strcmp(name, NG_AR_HOOK_DEBUG) == 0) {
- hook->private = NULL; /* paranoid */
- sc->debug_hook = hook;
- return (0);
- }
-
- /*
- * Check for raw mode hook.
- */
- if (strcmp(name, NG_AR_HOOK_RAW) != 0) {
- return (EINVAL);
- }
- hook->private = sc;
- sc->hook = hook;
- sc->datahooks++;
- ar_up(sc);
- return (0);
-}
-
-/*
- * incoming messages.
- * Just respond to the generic TEXT_STATUS message
- */
-static int
-ngar_rcvmsg(node_p node,
- struct ng_mesg *msg, const char *retaddr, struct ng_mesg **resp)
-{
- struct ar_softc * sc;
- int error = 0;
-
- sc = node->private;
- switch (msg->header.typecookie) {
- case NG_AR_COOKIE:
- error = EINVAL;
- break;
- case NGM_GENERIC_COOKIE:
- switch(msg->header.cmd) {
- case NGM_TEXT_STATUS: {
- char *arg;
- int pos = 0;
- int resplen = sizeof(struct ng_mesg) + 512;
- MALLOC(*resp, struct ng_mesg *, resplen,
- M_NETGRAPH, M_NOWAIT);
- if (*resp == NULL) {
- error = ENOMEM;
- break;
- }
- bzero(*resp, resplen);
- arg = (*resp)->data;
-
- /*
- * Put in the throughput information.
- */
- pos = sprintf(arg, "%ld bytes in, %ld bytes out\n"
- "highest rate seen: %ld B/S in, %ld B/S out\n",
- sc->inbytes, sc->outbytes,
- sc->inrate, sc->outrate);
- pos += sprintf(arg + pos,
- "%ld output errors\n",
- sc->oerrors);
- pos += sprintf(arg + pos,
- "ierrors = %ld, %ld, %ld, %ld\n",
- sc->ierrors[0],
- sc->ierrors[1],
- sc->ierrors[2],
- sc->ierrors[3]);
-
- (*resp)->header.version = NG_VERSION;
- (*resp)->header.arglen = strlen(arg) + 1;
- (*resp)->header.token = msg->header.token;
- (*resp)->header.typecookie = NG_AR_COOKIE;
- (*resp)->header.cmd = msg->header.cmd;
- strncpy((*resp)->header.cmdstr, "status",
- NG_CMDSTRLEN);
- }
- break;
- default:
- error = EINVAL;
- break;
- }
- break;
- default:
- error = EINVAL;
- break;
- }
- free(msg, M_NETGRAPH);
- return (error);
-}
-
-/*
- * get data from another node and transmit it to the correct channel
- */
-static int
-ngar_rcvdata(hook_p hook, struct mbuf *m, meta_p meta)
-{
- int s;
- int error = 0;
- struct ar_softc * sc = hook->node->private;
- struct ifqueue *xmitq_p;
-
- /*
- * data doesn't come in from just anywhere (e.g control hook)
- */
- if ( hook->private == NULL) {
- error = ENETDOWN;
- goto bad;
- }
-
- /*
- * Now queue the data for when it can be sent
- */
- if (meta && meta->priority > 0) {
- xmitq_p = (&sc->xmitq_hipri);
- } else {
- xmitq_p = (&sc->xmitq);
- }
- s = splimp();
- if (IF_QFULL(xmitq_p)) {
- IF_DROP(xmitq_p);
- splx(s);
- error = ENOBUFS;
- goto bad;
- }
- IF_ENQUEUE(xmitq_p, m);
- arstart(sc);
- splx(s);
- return (0);
-
-bad:
- /*
- * It was an error case.
- * check if we need to free the mbuf, and then return the error
- */
- NG_FREE_DATA(m, meta);
- return (error);
-}
-
-/*
- * do local shutdown processing..
- * this node will refuse to go away, unless the hardware says to..
- * don't unref the node, or remove our name. just clear our links up.
- */
-static int
-ngar_rmnode(node_p node)
-{
- struct ar_softc * sc = node->private;
-
- ar_down(sc);
- ng_cutlinks(node);
- node->flags &= ~NG_INVALID; /* bounce back to life */
- return (0);
-}
-
-/* already linked */
-static int
-ngar_connect(hook_p hook)
-{
- /* be really amiable and just say "YUP that's OK by me! " */
- return (0);
-}
-
-/*
- * notify on hook disconnection (destruction)
- *
- * Invalidate the private data associated with this dlci.
- * For this type, removal of the last link resets tries to destroy the node.
- * As the device still exists, the shutdown method will not actually
- * destroy the node, but reset the device and leave it 'fresh' :)
- *
- * The node removal code will remove all references except that owned by the
- * driver.
- */
-static int
-ngar_disconnect(hook_p hook)
-{
- struct ar_softc * sc = hook->node->private;
- int s;
- /*
- * If it's the data hook, then free resources etc.
- */
- if (hook->private) {
- s = splimp();
- sc->datahooks--;
- if (sc->datahooks == 0)
- ar_down(sc);
- splx(s);
- } else {
- sc->debug_hook = NULL;
- }
- return (0);
-}
-
-/*
- * called during bootup
- * or LKM loading to put this type into the list of known modules
- */
-static void
-ngar_init(void *ignored)
-{
- if (ng_newtype(&typestruct))
- printf("ngar install failed\n");
- ngar_done_init = 1;
-}
-#endif /* NETGRAPH */
-
-/*
- ********************************* END ************************************
- */
diff --git a/sys/dev/ar/if_ar_pci.c b/sys/dev/ar/if_ar_pci.c
deleted file mode 100644
index 800e63db2acb..000000000000
--- a/sys/dev/ar/if_ar_pci.c
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (c) 1999 John Hay.
- * 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 author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include "ar.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/malloc.h>
-
-#include <pci/pcivar.h>
-
-/*
- * The must match with the real functions in if_ar.c
- */
-extern void *arattach_pci(int unit, vm_offset_t mem_vaddr);
-extern void arintr_hc(void *hc);
-
-static const char *ar_pci_probe(pcici_t tag, pcidi_t type);
-static void ar_pci_attach(pcici_t config_id, int unit);
-
-static u_long arc_count = NAR;
-
-static struct pci_device ar_pci_driver =
-{
- "ar",
- ar_pci_probe,
- ar_pci_attach,
- &arc_count,
- NULL
-};
-
-COMPAT_PCI_DRIVER (ar_pci, ar_pci_driver);
-
-static const char *
-ar_pci_probe(pcici_t tag, pcidi_t type)
-{
- switch(type) {
- case 0x5012114f:
- return ("Digi SYNC/570i-PCI 2 port");
- break;
- case 0x5010114f:
- printf("Digi SYNC/570i-PCI 2 port (mapped below 1M)\n");
- printf("Please change the jumper to select linear mode.\n");
- break;
- case 0x5013114f:
- return ("Digi SYNC/570i-PCI 4 port");
- break;
- case 0x5011114f:
- printf("Digi SYNC/570i-PCI 4 port (mapped below 1M)\n");
- printf("Please change the jumper to select linear mode.\n");
- break;
- default:
- break;
- }
- return (0);
-}
-
-static void
-ar_pci_attach(pcici_t config_id, int unit)
-{
- u_char *inten;
- void *hc;
- vm_offset_t mem_vaddr, mem_paddr;
- vm_offset_t plx_vaddr, plx_paddr;
-
- if(!pci_map_mem(config_id, 0x10, &plx_vaddr, &plx_paddr)) {
- printf("arp: map failed.\n");
- return;
- }
-
- if(!pci_map_mem(config_id, 0x18, &mem_vaddr, &mem_paddr)) {
- printf("arp: map failed.\n");
- return;
- }
-
- hc = arattach_pci(unit, mem_vaddr);
- if(!hc)
- return;
-
- /* Magic to enable the card to generate interrupts. */
- inten = (u_char *)plx_vaddr;
- inten[0x69] = 0x09;
-
- if(!pci_map_int(config_id, arintr_hc, (void *)hc, &net_imask)) {
- free(hc, M_DEVBUF);
- return;
- }
-}
diff --git a/sys/dev/ar/if_arregs.h b/sys/dev/ar/if_arregs.h
deleted file mode 100644
index 32e3b0d96e11..000000000000
--- a/sys/dev/ar/if_arregs.h
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Copyright (c) 1995, 1999 John Hay. 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 author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY [your name] 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.
- *
- * $FreeBSD$
- */
-#ifndef _IF_ARREGS_H_
-#define _IF_ARREGS_H_
-
-#define NCHAN 2 /* A HD64570 chip have 2 channels */
-#define NPORT 4 /* A ArNet board can have 4 ports or */
- /* channels */
-
-#define AR_BUF_SIZ 512
-#define AR_TX_BLOCKS 2
-#define ARC_IO_SIZ 0x10
-#define ARC_WIN_SIZ 0x00004000
-#define ARC_WIN_MSK (ARC_WIN_SIZ - 1)
-#define ARC_WIN_SHFT 14
-
-/* Some PCI specific offsets. */
-#define AR_PCI_SCA_1_OFFSET 0x00040000
-#define AR_PCI_SCA_2_OFFSET 0x00040400
-#define AR_PCI_ORBASE_OFFSET 0x00041000
-#define AR_PCI_SCA_PCR 0x0208
-#define AR_PCI_SCA_DMER 0x0309
-/* PCI Legacy (below 1M) offsets. */
-#define AR_PCI_L_SCA_1_OFFSET 0x00004000
-#define AR_PCI_L_SCA_2_OFFSET 0x00004400
-#define AR_PCI_L_ORBASE_OFFSET 0x00005000
-
-#define AR_ID_5 0x00 /* RO, Card probe '5' */
-#define AR_ID_7 0x01 /* RO, Card probe '7' */
-#define AR_ID_0 0x02 /* RO, Card probe '0' */
-#define AR_BMI 0x03 /* RO, Bus, mem and interface type */
-#define AR_REV 0x04 /* RO, Adapter revision */
-#define AR_PNUM 0x05 /* RO, Port number */
-#define AR_HNDSH 0x06 /* RO, Supported handshake */
-#define AR_ISTAT 0x07 /* RO, DCD and Interrupt status */
-#define AR_MSCA_EN 0x08 /* WO, Memory and SCA enable */
-#define AR_TXC_DTR0 0x09 /* WO, Tx Clock and DTR control 0 + 1 */
-#define AR_SEC_PAL 0x0A /* RW, Security PAL */
-#define AR_INT_ACK0 0x0B /* RO, Interrupt Acknowledge 0 + 1 */
-#define AR_INT_SEL 0x0C /* RW, Interrupt Select */
-#define AR_MEM_SEL 0x0D /* RW, Memory Select */
-#define AR_INT_ACK2 0x0E /* RO, Interrupt Acknowledge 2 + 3 */
-#define AR_TXC_DTR2 0x0E /* WO, Tx Clock and DTR control 2 + 3 */
-/* PCI only */
-#define AR_PIMCTRL 0x4C /* RW, PIM and LEDs */
-#define AR_INT_SCB 0x50 /* RO, Interrupt Scoreboard */
-
-#define AR_REV_MSK 0x0F
-#define AR_WSIZ_MSK 0xE0
-#define AR_WSIZ_SHFT 5
-/* Bus memory and interface type */
-#define AR_BUS_MSK 0x03
-#define AR_BUS_ISA 0x00
-#define AR_BUS_MCA 0x01
-#define AR_BUS_EISA 0x02
-#define AR_BUS_PCI 0x03
-
-#define AR_MEM_MSK 0x1C
-#define AR_MEM_SHFT 0x02
-#define AR_MEM_64K 0x00
-#define AR_MEM_128K 0x04
-#define AR_MEM_256K 0x08
-#define AR_MEM_512K 0x0C
-
-/*
- * EIA-232
- * V.35/EIA-232
- * EIA-530
- * X.21
- * EIA-530/X.21 Combo
- */
-#define AR_IFACE_MSK 0xE0
-#define AR_IFACE_SHFT 0x05
-#define AR_IFACE_EIA_232 0x00 /* Only on the 570 card, not 570i */
-#define AR_IFACE_V_35 0x20 /* Selectable between V.35 and EIA-232 */
-#define AR_IFACE_EIA_530 0x40
-#define AR_IFACE_X_21 0x60
-#define AR_IFACE_COMBO 0xC0 /* X.21 / EIA-530 */
-#define AR_IFACE_PIM 0xE0 /* PIM module */
-#define AR_IFACE_LOOPBACK 0xFE
-#define AR_IFACE_UNKNOWN 0xFF
-
-/* Supported Handshake signals */
-#define AR_SHSK_DTR 0x01
-#define AR_SHSK_RTS 0x02
-#define AR_SHSK_CTS 0x10
-#define AR_SHSK_DSR 0x20
-#define AR_SHSK_RI 0x40
-#define AR_SHSK_DCD 0x80
-
-/* DCD and Interrupt status */
-#define AR_BD_INT 0x01
-#define AR_INT_0 0x20
-#define AR_INT_1 0x40
-
-#define AR_DCD_MSK 0x1E
-#define AR_DCD_SHFT 0x01
-#define AR_DCD_0 0x02
-#define AR_DCD_1 0x04
-#define AR_DCD_2 0x08
-#define AR_DCD_3 0x10
-
-/* Memory and SCA enable */
-#define AR_WIN_MSK 0x1F
-
-#define AR_SEL_SCA_0 0x00
-#define AR_SEL_SCA_1 0x20
-#define AR_ENA_SCA 0x40
-#define AR_ENA_MEM 0x80
-
-/* Transmit Clock and DTR and RESET */
-#define AR_TXC_DTR_TX0 0x01
-#define AR_TXC_DTR_TX1 0x02
-#define AR_TXC_DTR_DTR0 0x04
-#define AR_TXC_DTR_DTR1 0x08
-#define AR_TXC_DTR_TXCS0 0x10
-#define AR_TXC_DTR_TXCS1 0x20
-#define AR_TXC_DTR_NOTRESET 0x40
-#define AR_TXC_DTR_RESET 0x00
-
-/* Interrupt select register */
-#define AR_INTS_CEN 0x01
-#define AR_INTS_ISEL0 0x02
-#define AR_INTS_ISEL1 0x04
-#define AR_INTS_ISEL2 0x08
-#define AR_INTS_CMA14 0x10
-#define AR_INTS_CMA15 0x20
-
-/* Advanced PIM Control */
-#define AR_PIM_STROBE 0x01
-#define AR_PIM_DATA 0x02
-#define AR_PIM_MODEG 0x04
-#define AR_PIM_A2D_STROBE 0x04
-#define AR_PIM_MODEY 0x08
-#define AR_PIM_A2D_DOUT 0x08
-#define AR_PIM_AUTO_LED 0x10
-#define AR_PIM_INT 0x20
-
-#define AR_PIM_RESET 0x00 /* MODEG and MODEY 0 */
-#define AR_PIM_READ AR_PIM_MODEG
-#define AR_PIM_WRITE AR_PIM_MODEY
-
-#endif /* _IF_ARREGS_H_ */
diff --git a/sys/dev/atkbdc/atkbd.c b/sys/dev/atkbdc/atkbd.c
deleted file mode 100644
index 549dc43e114d..000000000000
--- a/sys/dev/atkbdc/atkbd.c
+++ /dev/null
@@ -1,1409 +0,0 @@
-/*-
- * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
- * 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 as
- * the first lines of this file unmodified.
- * 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 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.
- *
- * $FreeBSD$
- */
-
-#include "opt_kbd.h"
-#include "opt_atkbd.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/bus.h>
-#include <sys/proc.h>
-#include <sys/malloc.h>
-
-#ifdef __i386__
-#include <machine/md_var.h>
-#include <machine/psl.h>
-#include <machine/vm86.h>
-#include <machine/pc/bios.h>
-
-#include <vm/vm.h>
-#include <vm/pmap.h>
-#endif /* __i386__ */
-
-#include <dev/kbd/kbdreg.h>
-#include <dev/kbd/atkbdreg.h>
-#include <dev/kbd/atkbdcreg.h>
-
-#include <isa/isareg.h>
-
-static timeout_t atkbd_timeout;
-
-int
-atkbd_probe_unit(int unit, int port, int irq, int flags)
-{
- keyboard_switch_t *sw;
- int args[2];
- int error;
-
- sw = kbd_get_switch(ATKBD_DRIVER_NAME);
- if (sw == NULL)
- return ENXIO;
-
- args[0] = port;
- args[1] = irq;
- error = (*sw->probe)(unit, args, flags);
- if (error)
- return error;
- return 0;
-}
-
-int
-atkbd_attach_unit(int unit, keyboard_t **kbd, int port, int irq, int flags)
-{
- keyboard_switch_t *sw;
- int args[2];
- int error;
-
- sw = kbd_get_switch(ATKBD_DRIVER_NAME);
- if (sw == NULL)
- return ENXIO;
-
- /* reset, initialize and enable the device */
- args[0] = port;
- args[1] = irq;
- *kbd = NULL;
- error = (*sw->probe)(unit, args, flags);
- if (error)
- return error;
- error = (*sw->init)(unit, kbd, args, flags);
- if (error)
- return error;
- (*sw->enable)(*kbd);
-
-#ifdef KBD_INSTALL_CDEV
- /* attach a virtual keyboard cdev */
- error = kbd_attach(*kbd);
- if (error)
- return error;
-#endif
-
- /*
- * This is a kludge to compensate for lost keyboard interrupts.
- * A similar code used to be in syscons. See below. XXX
- */
- atkbd_timeout(*kbd);
-
- if (bootverbose)
- (*sw->diag)(*kbd, bootverbose);
- return 0;
-}
-
-static void
-atkbd_timeout(void *arg)
-{
- keyboard_t *kbd;
- int s;
-
- /*
- * The original text of the following comments are extracted
- * from syscons.c (1.287)
- *
- * With release 2.1 of the Xaccel server, the keyboard is left
- * hanging pretty often. Apparently an interrupt from the
- * keyboard is lost, and I don't know why (yet).
- * This ugly hack calls the low-level interrupt routine if input
- * is ready for the keyboard and conveniently hides the problem. XXX
- *
- * Try removing anything stuck in the keyboard controller; whether
- * it's a keyboard scan code or mouse data. The low-level
- * interrupt routine doesn't read the mouse data directly,
- * but the keyboard controller driver will, as a side effect.
- */
- /*
- * And here is bde's original comment about this:
- *
- * This is necessary to handle edge triggered interrupts - if we
- * returned when our IRQ is high due to unserviced input, then there
- * would be no more keyboard IRQs until the keyboard is reset by
- * external powers.
- *
- * The keyboard apparently unwedges the irq in most cases.
- */
- s = spltty();
- kbd = (keyboard_t *)arg;
- if ((*kbdsw[kbd->kb_index]->lock)(kbd, TRUE)) {
- /*
- * We have seen the lock flag is not set. Let's reset
- * the flag early, otherwise the LED update routine fails
- * which may want the lock during the interrupt routine.
- */
- (*kbdsw[kbd->kb_index]->lock)(kbd, FALSE);
- if ((*kbdsw[kbd->kb_index]->check_char)(kbd))
- (*kbdsw[kbd->kb_index]->intr)(kbd, NULL);
- }
- splx(s);
- timeout(atkbd_timeout, arg, hz/10);
-}
-
-/* LOW-LEVEL */
-
-#include <machine/limits.h>
-#include <machine/console.h>
-#include <machine/clock.h>
-
-#define ATKBD_DEFAULT 0
-
-typedef struct atkbd_state {
- KBDC kbdc; /* keyboard controller */
- /* XXX: don't move this field; pcvt
- * expects `kbdc' to be the first
- * field in this structure. */
- int ks_mode; /* input mode (K_XLATE,K_RAW,K_CODE) */
- int ks_flags; /* flags */
-#define COMPOSE (1 << 0)
- int ks_polling;
- int ks_state; /* shift/lock key state */
- int ks_accents; /* accent key index (> 0) */
- u_int ks_composed_char; /* composed char code (> 0) */
- u_char ks_prefix; /* AT scan code prefix */
-} atkbd_state_t;
-
-/* keyboard driver declaration */
-static int atkbd_configure(int flags);
-static kbd_probe_t atkbd_probe;
-static kbd_init_t atkbd_init;
-static kbd_term_t atkbd_term;
-static kbd_intr_t atkbd_intr;
-static kbd_test_if_t atkbd_test_if;
-static kbd_enable_t atkbd_enable;
-static kbd_disable_t atkbd_disable;
-static kbd_read_t atkbd_read;
-static kbd_check_t atkbd_check;
-static kbd_read_char_t atkbd_read_char;
-static kbd_check_char_t atkbd_check_char;
-static kbd_ioctl_t atkbd_ioctl;
-static kbd_lock_t atkbd_lock;
-static kbd_clear_state_t atkbd_clear_state;
-static kbd_get_state_t atkbd_get_state;
-static kbd_set_state_t atkbd_set_state;
-static kbd_poll_mode_t atkbd_poll;
-
-keyboard_switch_t atkbdsw = {
- atkbd_probe,
- atkbd_init,
- atkbd_term,
- atkbd_intr,
- atkbd_test_if,
- atkbd_enable,
- atkbd_disable,
- atkbd_read,
- atkbd_check,
- atkbd_read_char,
- atkbd_check_char,
- atkbd_ioctl,
- atkbd_lock,
- atkbd_clear_state,
- atkbd_get_state,
- atkbd_set_state,
- genkbd_get_fkeystr,
- atkbd_poll,
- genkbd_diag,
-};
-
-KEYBOARD_DRIVER(atkbd, atkbdsw, atkbd_configure);
-
-/* local functions */
-static int get_typematic(keyboard_t *kbd);
-static int setup_kbd_port(KBDC kbdc, int port, int intr);
-static int get_kbd_echo(KBDC kbdc);
-static int probe_keyboard(KBDC kbdc, int flags);
-static int init_keyboard(KBDC kbdc, int *type, int flags);
-static int write_kbd(KBDC kbdc, int command, int data);
-static int get_kbd_id(KBDC kbdc);
-static int typematic(int delay, int rate);
-static int typematic_delay(int delay);
-static int typematic_rate(int rate);
-
-/* local variables */
-
-/* the initial key map, accent map and fkey strings */
-#ifdef ATKBD_DFLT_KEYMAP
-#define KBD_DFLT_KEYMAP
-#include "atkbdmap.h"
-#endif
-#include <dev/kbd/kbdtables.h>
-
-/* structures for the default keyboard */
-static keyboard_t default_kbd;
-static atkbd_state_t default_kbd_state;
-static keymap_t default_keymap;
-static accentmap_t default_accentmap;
-static fkeytab_t default_fkeytab[NUM_FKEYS];
-
-/*
- * The back door to the keyboard driver!
- * This function is called by the console driver, via the kbdio module,
- * to tickle keyboard drivers when the low-level console is being initialized.
- * Almost nothing in the kernel has been initialied yet. Try to probe
- * keyboards if possible.
- * NOTE: because of the way the low-level conole is initialized, this routine
- * may be called more than once!!
- */
-static int
-atkbd_configure(int flags)
-{
- keyboard_t *kbd;
- int arg[2];
- int i;
-
- /* probe the keyboard controller */
- atkbdc_configure();
-
- /* if the driver is disabled, unregister the keyboard if any */
- if ((resource_int_value("atkbd", ATKBD_DEFAULT, "disabled", &i) == 0)
- && i != 0) {
- i = kbd_find_keyboard(ATKBD_DRIVER_NAME, ATKBD_DEFAULT);
- if (i >= 0) {
- kbd = kbd_get_keyboard(i);
- kbd_unregister(kbd);
- kbd->kb_flags &= ~KB_REGISTERED;
- }
- return 0;
- }
-
- /* XXX: a kludge to obtain the device configuration flags */
- if (resource_int_value("atkbd", ATKBD_DEFAULT, "flags", &i) == 0)
- flags |= i;
-
- /* probe the default keyboard */
- arg[0] = -1;
- arg[1] = -1;
- kbd = NULL;
- if (atkbd_probe(ATKBD_DEFAULT, arg, flags))
- return 0;
- if (atkbd_init(ATKBD_DEFAULT, &kbd, arg, flags))
- return 0;
-
- /* return the number of found keyboards */
- return 1;
-}
-
-/* low-level functions */
-
-/* detect a keyboard */
-static int
-atkbd_probe(int unit, void *arg, int flags)
-{
- KBDC kbdc;
- int *data = (int *)arg;
-
- /* XXX */
- if (unit == ATKBD_DEFAULT) {
- if (KBD_IS_PROBED(&default_kbd))
- return 0;
- }
-
- kbdc = kbdc_open(data[0]);
- if (kbdc == NULL)
- return ENXIO;
- if (probe_keyboard(kbdc, flags)) {
- if (flags & KB_CONF_FAIL_IF_NO_KBD)
- return ENXIO;
- }
- return 0;
-}
-
-/* reset and initialize the device */
-static int
-atkbd_init(int unit, keyboard_t **kbdp, void *arg, int flags)
-{
- keyboard_t *kbd;
- atkbd_state_t *state;
- keymap_t *keymap;
- accentmap_t *accmap;
- fkeytab_t *fkeymap;
- int fkeymap_size;
- int delay[2];
- int *data = (int *)arg;
-
- /* XXX */
- if (unit == ATKBD_DEFAULT) {
- *kbdp = kbd = &default_kbd;
- if (KBD_IS_INITIALIZED(kbd) && KBD_IS_CONFIGURED(kbd))
- return 0;
- state = &default_kbd_state;
- keymap = &default_keymap;
- accmap = &default_accentmap;
- fkeymap = default_fkeytab;
- fkeymap_size =
- sizeof(default_fkeytab)/sizeof(default_fkeytab[0]);
- } else if (*kbdp == NULL) {
- *kbdp = kbd = malloc(sizeof(*kbd), M_DEVBUF, M_NOWAIT);
- if (kbd == NULL)
- return ENOMEM;
- bzero(kbd, sizeof(*kbd));
- state = malloc(sizeof(*state), M_DEVBUF, M_NOWAIT);
- keymap = malloc(sizeof(key_map), M_DEVBUF, M_NOWAIT);
- accmap = malloc(sizeof(accent_map), M_DEVBUF, M_NOWAIT);
- fkeymap = malloc(sizeof(fkey_tab), M_DEVBUF, M_NOWAIT);
- fkeymap_size = sizeof(fkey_tab)/sizeof(fkey_tab[0]);
- if ((state == NULL) || (keymap == NULL) || (accmap == NULL)
- || (fkeymap == NULL)) {
- if (state != NULL)
- free(state, M_DEVBUF);
- if (keymap != NULL)
- free(keymap, M_DEVBUF);
- if (accmap != NULL)
- free(accmap, M_DEVBUF);
- if (fkeymap != NULL)
- free(fkeymap, M_DEVBUF);
- free(kbd, M_DEVBUF);
- return ENOMEM;
- }
- bzero(state, sizeof(*state));
- } else if (KBD_IS_INITIALIZED(*kbdp) && KBD_IS_CONFIGURED(*kbdp)) {
- return 0;
- } else {
- kbd = *kbdp;
- state = (atkbd_state_t *)kbd->kb_data;
- bzero(state, sizeof(*state));
- keymap = kbd->kb_keymap;
- accmap = kbd->kb_accentmap;
- fkeymap = kbd->kb_fkeytab;
- fkeymap_size = kbd->kb_fkeytab_size;
- }
-
- if (!KBD_IS_PROBED(kbd)) {
- state->kbdc = kbdc_open(data[0]);
- if (state->kbdc == NULL)
- return ENXIO;
- kbd_init_struct(kbd, ATKBD_DRIVER_NAME, KB_OTHER, unit, flags,
- data[0], IO_KBDSIZE);
- bcopy(&key_map, keymap, sizeof(key_map));
- bcopy(&accent_map, accmap, sizeof(accent_map));
- bcopy(fkey_tab, fkeymap,
- imin(fkeymap_size*sizeof(fkeymap[0]), sizeof(fkey_tab)));
- kbd_set_maps(kbd, keymap, accmap, fkeymap, fkeymap_size);
- kbd->kb_data = (void *)state;
-
- if (probe_keyboard(state->kbdc, flags)) { /* shouldn't happen */
- if (flags & KB_CONF_FAIL_IF_NO_KBD)
- return ENXIO;
- } else {
- KBD_FOUND_DEVICE(kbd);
- }
- atkbd_clear_state(kbd);
- state->ks_mode = K_XLATE;
- /*
- * FIXME: set the initial value for lock keys in ks_state
- * according to the BIOS data?
- */
- KBD_PROBE_DONE(kbd);
- }
- if (!KBD_IS_INITIALIZED(kbd) && !(flags & KB_CONF_PROBE_ONLY)) {
- kbd->kb_config = flags & ~KB_CONF_PROBE_ONLY;
- if (KBD_HAS_DEVICE(kbd)
- && init_keyboard(state->kbdc, &kbd->kb_type, kbd->kb_config)
- && (kbd->kb_config & KB_CONF_FAIL_IF_NO_KBD))
- return ENXIO;
- atkbd_ioctl(kbd, KDSETLED, (caddr_t)&state->ks_state);
- get_typematic(kbd);
- delay[0] = kbd->kb_delay1;
- delay[1] = kbd->kb_delay2;
- atkbd_ioctl(kbd, KDSETREPEAT, (caddr_t)delay);
- KBD_INIT_DONE(kbd);
- }
- if (!KBD_IS_CONFIGURED(kbd)) {
- if (kbd_register(kbd) < 0)
- return ENXIO;
- KBD_CONFIG_DONE(kbd);
- }
-
- return 0;
-}
-
-/* finish using this keyboard */
-static int
-atkbd_term(keyboard_t *kbd)
-{
- kbd_unregister(kbd);
- return 0;
-}
-
-/* keyboard interrupt routine */
-static int
-atkbd_intr(keyboard_t *kbd, void *arg)
-{
- atkbd_state_t *state;
- int delay[2];
- int c;
-
- if (KBD_IS_ACTIVE(kbd) && KBD_IS_BUSY(kbd)) {
- /* let the callback function to process the input */
- (*kbd->kb_callback.kc_func)(kbd, KBDIO_KEYINPUT,
- kbd->kb_callback.kc_arg);
- } else {
- /* read and discard the input; no one is waiting for input */
- do {
- c = atkbd_read_char(kbd, FALSE);
- } while (c != NOKEY);
-
- if (!KBD_HAS_DEVICE(kbd)) {
- /*
- * The keyboard was not detected before;
- * it must have been reconnected!
- */
- state = (atkbd_state_t *)kbd->kb_data;
- init_keyboard(state->kbdc, &kbd->kb_type,
- kbd->kb_config);
- atkbd_ioctl(kbd, KDSETLED, (caddr_t)&state->ks_state);
- get_typematic(kbd);
- delay[0] = kbd->kb_delay1;
- delay[1] = kbd->kb_delay2;
- atkbd_ioctl(kbd, KDSETREPEAT, (caddr_t)delay);
- KBD_FOUND_DEVICE(kbd);
- }
- }
- return 0;
-}
-
-/* test the interface to the device */
-static int
-atkbd_test_if(keyboard_t *kbd)
-{
- int error;
- int s;
-
- error = 0;
- empty_both_buffers(((atkbd_state_t *)kbd->kb_data)->kbdc, 10);
- s = spltty();
- if (!test_controller(((atkbd_state_t *)kbd->kb_data)->kbdc))
- error = EIO;
- else if (test_kbd_port(((atkbd_state_t *)kbd->kb_data)->kbdc) != 0)
- error = EIO;
- splx(s);
-
- return error;
-}
-
-/*
- * Enable the access to the device; until this function is called,
- * the client cannot read from the keyboard.
- */
-static int
-atkbd_enable(keyboard_t *kbd)
-{
- int s;
-
- s = spltty();
- KBD_ACTIVATE(kbd);
- splx(s);
- return 0;
-}
-
-/* disallow the access to the device */
-static int
-atkbd_disable(keyboard_t *kbd)
-{
- int s;
-
- s = spltty();
- KBD_DEACTIVATE(kbd);
- splx(s);
- return 0;
-}
-
-/* read one byte from the keyboard if it's allowed */
-static int
-atkbd_read(keyboard_t *kbd, int wait)
-{
- int c;
-
- if (wait)
- c = read_kbd_data(((atkbd_state_t *)kbd->kb_data)->kbdc);
- else
- c = read_kbd_data_no_wait(((atkbd_state_t *)kbd->kb_data)->kbdc);
- if (c != -1)
- ++kbd->kb_count;
- return (KBD_IS_ACTIVE(kbd) ? c : -1);
-}
-
-/* check if data is waiting */
-static int
-atkbd_check(keyboard_t *kbd)
-{
- if (!KBD_IS_ACTIVE(kbd))
- return FALSE;
- return kbdc_data_ready(((atkbd_state_t *)kbd->kb_data)->kbdc);
-}
-
-/* read char from the keyboard */
-static u_int
-atkbd_read_char(keyboard_t *kbd, int wait)
-{
- atkbd_state_t *state;
- u_int action;
- int scancode;
- int keycode;
-
- state = (atkbd_state_t *)kbd->kb_data;
-next_code:
- /* do we have a composed char to return? */
- if (!(state->ks_flags & COMPOSE) && (state->ks_composed_char > 0)) {
- action = state->ks_composed_char;
- state->ks_composed_char = 0;
- if (action > UCHAR_MAX)
- return ERRKEY;
- return action;
- }
-
- /* see if there is something in the keyboard port */
- if (wait) {
- do {
- scancode = read_kbd_data(state->kbdc);
- } while (scancode == -1);
- } else {
- scancode = read_kbd_data_no_wait(state->kbdc);
- if (scancode == -1)
- return NOKEY;
- }
- ++kbd->kb_count;
-
-#if KBDIO_DEBUG >= 10
- printf("atkbd_read_char(): scancode:0x%x\n", scancode);
-#endif
-
- /* return the byte as is for the K_RAW mode */
- if (state->ks_mode == K_RAW)
- return scancode;
-
- /* translate the scan code into a keycode */
- keycode = scancode & 0x7F;
- switch (state->ks_prefix) {
- case 0x00: /* normal scancode */
- switch(scancode) {
- case 0xB8: /* left alt (compose key) released */
- if (state->ks_flags & COMPOSE) {
- state->ks_flags &= ~COMPOSE;
- if (state->ks_composed_char > UCHAR_MAX)
- state->ks_composed_char = 0;
- }
- break;
- case 0x38: /* left alt (compose key) pressed */
- if (!(state->ks_flags & COMPOSE)) {
- state->ks_flags |= COMPOSE;
- state->ks_composed_char = 0;
- }
- break;
- case 0xE0:
- case 0xE1:
- state->ks_prefix = scancode;
- goto next_code;
- }
- break;
- case 0xE0: /* 0xE0 prefix */
- state->ks_prefix = 0;
- switch (keycode) {
- case 0x1C: /* right enter key */
- keycode = 0x59;
- break;
- case 0x1D: /* right ctrl key */
- keycode = 0x5A;
- break;
- case 0x35: /* keypad divide key */
- keycode = 0x5B;
- break;
- case 0x37: /* print scrn key */
- keycode = 0x5C;
- break;
- case 0x38: /* right alt key (alt gr) */
- keycode = 0x5D;
- break;
- case 0x46: /* ctrl-pause/break on AT 101 (see below) */
- keycode = 0x68;
- break;
- case 0x47: /* grey home key */
- keycode = 0x5E;
- break;
- case 0x48: /* grey up arrow key */
- keycode = 0x5F;
- break;
- case 0x49: /* grey page up key */
- keycode = 0x60;
- break;
- case 0x4B: /* grey left arrow key */
- keycode = 0x61;
- break;
- case 0x4D: /* grey right arrow key */
- keycode = 0x62;
- break;
- case 0x4F: /* grey end key */
- keycode = 0x63;
- break;
- case 0x50: /* grey down arrow key */
- keycode = 0x64;
- break;
- case 0x51: /* grey page down key */
- keycode = 0x65;
- break;
- case 0x52: /* grey insert key */
- keycode = 0x66;
- break;
- case 0x53: /* grey delete key */
- keycode = 0x67;
- break;
- /* the following 3 are only used on the MS "Natural" keyboard */
- case 0x5b: /* left Window key */
- keycode = 0x69;
- break;
- case 0x5c: /* right Window key */
- keycode = 0x6a;
- break;
- case 0x5d: /* menu key */
- keycode = 0x6b;
- break;
- default: /* ignore everything else */
- goto next_code;
- }
- break;
- case 0xE1: /* 0xE1 prefix */
- /*
- * The pause/break key on the 101 keyboard produces:
- * E1-1D-45 E1-9D-C5
- * Ctrl-pause/break produces:
- * E0-46 E0-C6 (See above.)
- */
- state->ks_prefix = 0;
- if (keycode == 0x1D)
- state->ks_prefix = 0x1D;
- goto next_code;
- /* NOT REACHED */
- case 0x1D: /* pause / break */
- state->ks_prefix = 0;
- if (keycode != 0x45)
- goto next_code;
- keycode = 0x68;
- break;
- }
-
- if (kbd->kb_type == KB_84) {
- switch (keycode) {
- case 0x37: /* *(numpad)/print screen */
- if (state->ks_flags & SHIFTS)
- keycode = 0x5c; /* print screen */
- break;
- case 0x45: /* num lock/pause */
- if (state->ks_flags & CTLS)
- keycode = 0x68; /* pause */
- break;
- case 0x46: /* scroll lock/break */
- if (state->ks_flags & CTLS)
- keycode = 0x6c; /* break */
- break;
- }
- } else if (kbd->kb_type == KB_101) {
- switch (keycode) {
- case 0x5c: /* print screen */
- if (state->ks_flags & ALTS)
- keycode = 0x54; /* sysrq */
- break;
- case 0x68: /* pause/break */
- if (state->ks_flags & CTLS)
- keycode = 0x6c; /* break */
- break;
- }
- }
-
- /* return the key code in the K_CODE mode */
- if (state->ks_mode == K_CODE)
- return (keycode | (scancode & 0x80));
-
- /* compose a character code */
- if (state->ks_flags & COMPOSE) {
- switch (keycode | (scancode & 0x80)) {
- /* key pressed, process it */
- case 0x47: case 0x48: case 0x49: /* keypad 7,8,9 */
- state->ks_composed_char *= 10;
- state->ks_composed_char += keycode - 0x40;
- if (state->ks_composed_char > UCHAR_MAX)
- return ERRKEY;
- goto next_code;
- case 0x4B: case 0x4C: case 0x4D: /* keypad 4,5,6 */
- state->ks_composed_char *= 10;
- state->ks_composed_char += keycode - 0x47;
- if (state->ks_composed_char > UCHAR_MAX)
- return ERRKEY;
- goto next_code;
- case 0x4F: case 0x50: case 0x51: /* keypad 1,2,3 */
- state->ks_composed_char *= 10;
- state->ks_composed_char += keycode - 0x4E;
- if (state->ks_composed_char > UCHAR_MAX)
- return ERRKEY;
- goto next_code;
- case 0x52: /* keypad 0 */
- state->ks_composed_char *= 10;
- if (state->ks_composed_char > UCHAR_MAX)
- return ERRKEY;
- goto next_code;
-
- /* key released, no interest here */
- case 0xC7: case 0xC8: case 0xC9: /* keypad 7,8,9 */
- case 0xCB: case 0xCC: case 0xCD: /* keypad 4,5,6 */
- case 0xCF: case 0xD0: case 0xD1: /* keypad 1,2,3 */
- case 0xD2: /* keypad 0 */
- goto next_code;
-
- case 0x38: /* left alt key */
- break;
-
- default:
- if (state->ks_composed_char > 0) {
- state->ks_flags &= ~COMPOSE;
- state->ks_composed_char = 0;
- return ERRKEY;
- }
- break;
- }
- }
-
- /* keycode to key action */
- action = genkbd_keyaction(kbd, keycode, scancode & 0x80,
- &state->ks_state, &state->ks_accents);
- if (action == NOKEY)
- goto next_code;
- else
- return action;
-}
-
-/* check if char is waiting */
-static int
-atkbd_check_char(keyboard_t *kbd)
-{
- atkbd_state_t *state;
-
- if (!KBD_IS_ACTIVE(kbd))
- return FALSE;
- state = (atkbd_state_t *)kbd->kb_data;
- if (!(state->ks_flags & COMPOSE) && (state->ks_composed_char > 0))
- return TRUE;
- return kbdc_data_ready(state->kbdc);
-}
-
-/* some useful control functions */
-static int
-atkbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
-{
- /* trasnlate LED_XXX bits into the device specific bits */
- static u_char ledmap[8] = {
- 0, 4, 2, 6, 1, 5, 3, 7,
- };
- atkbd_state_t *state = kbd->kb_data;
- int error;
- int s;
- int i;
-
- s = spltty();
- switch (cmd) {
-
- case KDGKBMODE: /* get keyboard mode */
- *(int *)arg = state->ks_mode;
- break;
- case KDSKBMODE: /* set keyboard mode */
- switch (*(int *)arg) {
- case K_XLATE:
- if (state->ks_mode != K_XLATE) {
- /* make lock key state and LED state match */
- state->ks_state &= ~LOCK_MASK;
- state->ks_state |= KBD_LED_VAL(kbd);
- }
- /* FALL THROUGH */
- case K_RAW:
- case K_CODE:
- if (state->ks_mode != *(int *)arg) {
- atkbd_clear_state(kbd);
- state->ks_mode = *(int *)arg;
- }
- break;
- default:
- splx(s);
- return EINVAL;
- }
- break;
-
- case KDGETLED: /* get keyboard LED */
- *(int *)arg = KBD_LED_VAL(kbd);
- break;
- case KDSETLED: /* set keyboard LED */
- /* NOTE: lock key state in ks_state won't be changed */
- if (*(int *)arg & ~LOCK_MASK) {
- splx(s);
- return EINVAL;
- }
- i = *(int *)arg;
- /* replace CAPS LED with ALTGR LED for ALTGR keyboards */
- if (kbd->kb_keymap->n_keys > ALTGR_OFFSET) {
- if (i & ALKED)
- i |= CLKED;
- else
- i &= ~CLKED;
- }
- if (KBD_HAS_DEVICE(kbd)) {
- error = write_kbd(state->kbdc, KBDC_SET_LEDS,
- ledmap[i & LED_MASK]);
- if (error) {
- splx(s);
- return error;
- }
- }
- KBD_LED_VAL(kbd) = *(int *)arg;
- break;
-
- case KDGKBSTATE: /* get lock key state */
- *(int *)arg = state->ks_state & LOCK_MASK;
- break;
- case KDSKBSTATE: /* set lock key state */
- if (*(int *)arg & ~LOCK_MASK) {
- splx(s);
- return EINVAL;
- }
- state->ks_state &= ~LOCK_MASK;
- state->ks_state |= *(int *)arg;
- splx(s);
- /* set LEDs and quit */
- return atkbd_ioctl(kbd, KDSETLED, arg);
-
- case KDSETREPEAT: /* set keyboard repeat rate (new interface) */
- splx(s);
- if (!KBD_HAS_DEVICE(kbd))
- return 0;
- i = typematic(((int *)arg)[0], ((int *)arg)[1]);
- error = write_kbd(state->kbdc, KBDC_SET_TYPEMATIC, i);
- if (error == 0) {
- kbd->kb_delay1 = typematic_delay(i);
- kbd->kb_delay2 = typematic_rate(i);
- }
- return error;
-
- case KDSETRAD: /* set keyboard repeat rate (old interface) */
- splx(s);
- if (!KBD_HAS_DEVICE(kbd))
- return 0;
- error = write_kbd(state->kbdc, KBDC_SET_TYPEMATIC, *(int *)arg);
- if (error == 0) {
- kbd->kb_delay1 = typematic_delay(*(int *)arg);
- kbd->kb_delay2 = typematic_rate(*(int *)arg);
- }
- return error;
-
- case PIO_KEYMAP: /* set keyboard translation table */
- case PIO_KEYMAPENT: /* set keyboard translation table entry */
- case PIO_DEADKEYMAP: /* set accent key translation table */
- state->ks_accents = 0;
- /* FALL THROUGH */
- default:
- splx(s);
- return genkbd_commonioctl(kbd, cmd, arg);
- }
-
- splx(s);
- return 0;
-}
-
-/* lock the access to the keyboard */
-static int
-atkbd_lock(keyboard_t *kbd, int lock)
-{
- return kbdc_lock(((atkbd_state_t *)kbd->kb_data)->kbdc, lock);
-}
-
-/* clear the internal state of the keyboard */
-static void
-atkbd_clear_state(keyboard_t *kbd)
-{
- atkbd_state_t *state;
-
- state = (atkbd_state_t *)kbd->kb_data;
- state->ks_flags = 0;
- state->ks_polling = 0;
- state->ks_state &= LOCK_MASK; /* preserve locking key state */
- state->ks_accents = 0;
- state->ks_composed_char = 0;
-#if 0
- state->ks_prefix = 0; /* XXX */
-#endif
-}
-
-/* save the internal state */
-static int
-atkbd_get_state(keyboard_t *kbd, void *buf, size_t len)
-{
- if (len == 0)
- return sizeof(atkbd_state_t);
- if (len < sizeof(atkbd_state_t))
- return -1;
- bcopy(kbd->kb_data, buf, sizeof(atkbd_state_t));
- return 0;
-}
-
-/* set the internal state */
-static int
-atkbd_set_state(keyboard_t *kbd, void *buf, size_t len)
-{
- if (len < sizeof(atkbd_state_t))
- return ENOMEM;
- if (((atkbd_state_t *)kbd->kb_data)->kbdc
- != ((atkbd_state_t *)buf)->kbdc)
- return ENOMEM;
- bcopy(buf, kbd->kb_data, sizeof(atkbd_state_t));
- return 0;
-}
-
-static int
-atkbd_poll(keyboard_t *kbd, int on)
-{
- atkbd_state_t *state;
- int s;
-
- state = (atkbd_state_t *)kbd->kb_data;
- s = spltty();
- if (on)
- ++state->ks_polling;
- else
- --state->ks_polling;
- splx(s);
- return 0;
-}
-
-/* local functions */
-
-static int
-get_typematic(keyboard_t *kbd)
-{
-#ifdef __i386__
- /*
- * Only some systems allow us to retrieve the keyboard repeat
- * rate previously set via the BIOS...
- */
- struct vm86frame vmf;
- u_int32_t p;
-
- bzero(&vmf, sizeof(vmf));
- vmf.vmf_ax = 0xc000;
- vm86_intcall(0x15, &vmf);
- if ((vmf.vmf_eflags & PSL_C) || vmf.vmf_ah)
- return ENODEV;
- p = BIOS_PADDRTOVADDR(((u_int32_t)vmf.vmf_es << 4) + vmf.vmf_bx);
- if ((readb(p + 6) & 0x40) == 0) /* int 16, function 0x09 supported? */
- return ENODEV;
- vmf.vmf_ax = 0x0900;
- vm86_intcall(0x16, &vmf);
- if ((vmf.vmf_al & 0x08) == 0) /* int 16, function 0x0306 supported? */
- return ENODEV;
- vmf.vmf_ax = 0x0306;
- vm86_intcall(0x16, &vmf);
- kbd->kb_delay1 = typematic_delay(vmf.vmf_bh << 5);
- kbd->kb_delay2 = typematic_rate(vmf.vmf_bl);
- return 0;
-#else
- return ENODEV;
-#endif /* __i386__ */
-}
-
-static int
-setup_kbd_port(KBDC kbdc, int port, int intr)
-{
- if (!set_controller_command_byte(kbdc,
- KBD_KBD_CONTROL_BITS,
- ((port) ? KBD_ENABLE_KBD_PORT : KBD_DISABLE_KBD_PORT)
- | ((intr) ? KBD_ENABLE_KBD_INT : KBD_DISABLE_KBD_INT)))
- return 1;
- return 0;
-}
-
-static int
-get_kbd_echo(KBDC kbdc)
-{
- /* enable the keyboard port, but disable the keyboard intr. */
- if (setup_kbd_port(kbdc, TRUE, FALSE))
- /* CONTROLLER ERROR: there is very little we can do... */
- return ENXIO;
-
- /* see if something is present */
- write_kbd_command(kbdc, KBDC_ECHO);
- if (read_kbd_data(kbdc) != KBD_ECHO) {
- empty_both_buffers(kbdc, 10);
- test_controller(kbdc);
- test_kbd_port(kbdc);
- return ENXIO;
- }
-
- /* enable the keyboard port and intr. */
- if (setup_kbd_port(kbdc, TRUE, TRUE)) {
- /*
- * CONTROLLER ERROR
- * This is serious; the keyboard intr is left disabled!
- */
- return ENXIO;
- }
-
- return 0;
-}
-
-static int
-probe_keyboard(KBDC kbdc, int flags)
-{
- /*
- * Don't try to print anything in this function. The low-level
- * console may not have been initialized yet...
- */
- int err;
- int c;
- int m;
-
- if (!kbdc_lock(kbdc, TRUE)) {
- /* driver error? */
- return ENXIO;
- }
-
- /* temporarily block data transmission from the keyboard */
- write_controller_command(kbdc, KBDC_DISABLE_KBD_PORT);
-
- /* flush any noise in the buffer */
- empty_both_buffers(kbdc, 100);
-
- /* save the current keyboard controller command byte */
- m = kbdc_get_device_mask(kbdc) & ~KBD_KBD_CONTROL_BITS;
- c = get_controller_command_byte(kbdc);
- if (c == -1) {
- /* CONTROLLER ERROR */
- kbdc_set_device_mask(kbdc, m);
- kbdc_lock(kbdc, FALSE);
- return ENXIO;
- }
-
- /*
- * The keyboard may have been screwed up by the boot block.
- * We may just be able to recover from error by testing the controller
- * and the keyboard port. The controller command byte needs to be
- * saved before this recovery operation, as some controllers seem
- * to set the command byte to particular values.
- */
- test_controller(kbdc);
- test_kbd_port(kbdc);
-
- err = get_kbd_echo(kbdc);
-
- /*
- * Even if the keyboard doesn't seem to be present (err != 0),
- * we shall enable the keyboard port and interrupt so that
- * the driver will be operable when the keyboard is attached
- * to the system later. It is NOT recommended to hot-plug
- * the AT keyboard, but many people do so...
- */
- kbdc_set_device_mask(kbdc, m | KBD_KBD_CONTROL_BITS);
- setup_kbd_port(kbdc, TRUE, TRUE);
-#if 0
- if (err == 0) {
- kbdc_set_device_mask(kbdc, m | KBD_KBD_CONTROL_BITS);
- } else {
- /* try to restore the command byte as before */
- set_controller_command_byte(kbdc, 0xff, c);
- kbdc_set_device_mask(kbdc, m);
- }
-#endif
-
- kbdc_lock(kbdc, FALSE);
- return err;
-}
-
-static int
-init_keyboard(KBDC kbdc, int *type, int flags)
-{
- int codeset;
- int id;
- int c;
-
- if (!kbdc_lock(kbdc, TRUE)) {
- /* driver error? */
- return EIO;
- }
-
- /* temporarily block data transmission from the keyboard */
- write_controller_command(kbdc, KBDC_DISABLE_KBD_PORT);
-
- /* save the current controller command byte */
- empty_both_buffers(kbdc, 200);
- c = get_controller_command_byte(kbdc);
- if (c == -1) {
- /* CONTROLLER ERROR */
- kbdc_lock(kbdc, FALSE);
- printf("atkbd: unable to get the current command byte value.\n");
- return EIO;
- }
- if (bootverbose)
- printf("atkbd: the current kbd controller command byte %04x\n",
- c);
-#if 0
- /* override the keyboard lock switch */
- c |= KBD_OVERRIDE_KBD_LOCK;
-#endif
-
- /* enable the keyboard port, but disable the keyboard intr. */
- if (setup_kbd_port(kbdc, TRUE, FALSE)) {
- /* CONTROLLER ERROR: there is very little we can do... */
- printf("atkbd: unable to set the command byte.\n");
- kbdc_lock(kbdc, FALSE);
- return EIO;
- }
-
- /*
- * Check if we have an XT keyboard before we attempt to reset it.
- * The procedure assumes that the keyboard and the controller have
- * been set up properly by BIOS and have not been messed up
- * during the boot process.
- */
- codeset = -1;
- if (flags & KB_CONF_ALT_SCANCODESET)
- /* the user says there is a XT keyboard */
- codeset = 1;
-#ifdef KBD_DETECT_XT_KEYBOARD
- else if ((c & KBD_TRANSLATION) == 0) {
- /* SET_SCANCODE_SET is not always supported; ignore error */
- if (send_kbd_command_and_data(kbdc, KBDC_SET_SCANCODE_SET, 0)
- == KBD_ACK)
- codeset = read_kbd_data(kbdc);
- }
- if (bootverbose)
- printf("atkbd: scancode set %d\n", codeset);
-#endif /* KBD_DETECT_XT_KEYBOARD */
-
- *type = KB_OTHER;
- id = get_kbd_id(kbdc);
- switch(id) {
- case 0x41ab: /* 101/102/... Enhanced */
- case 0x83ab: /* ditto */
- case 0x54ab: /* SpaceSaver */
- case 0x84ab: /* ditto */
-#if 0
- case 0x90ab: /* 'G' */
- case 0x91ab: /* 'P' */
- case 0x92ab: /* 'A' */
-#endif
- *type = KB_101;
- break;
- case -1: /* AT 84 keyboard doesn't return ID */
- *type = KB_84;
- break;
- default:
- break;
- }
- if (bootverbose)
- printf("atkbd: keyboard ID 0x%x (%d)\n", id, *type);
-
- /* reset keyboard hardware */
- if (!(flags & KB_CONF_NO_RESET) && !reset_kbd(kbdc)) {
- /*
- * KEYBOARD ERROR
- * Keyboard reset may fail either because the keyboard
- * doen't exist, or because the keyboard doesn't pass
- * the self-test, or the keyboard controller on the
- * motherboard and the keyboard somehow fail to shake hands.
- * It is just possible, particularly in the last case,
- * that the keyoard controller may be left in a hung state.
- * test_controller() and test_kbd_port() appear to bring
- * the keyboard controller back (I don't know why and how,
- * though.)
- */
- empty_both_buffers(kbdc, 10);
- test_controller(kbdc);
- test_kbd_port(kbdc);
- /*
- * We could disable the keyboard port and interrupt... but,
- * the keyboard may still exist (see above).
- */
- set_controller_command_byte(kbdc, 0xff, c);
- kbdc_lock(kbdc, FALSE);
- if (bootverbose)
- printf("atkbd: failed to reset the keyboard.\n");
- return EIO;
- }
-
- /*
- * Allow us to set the XT_KEYBD flag in UserConfig so that keyboards
- * such as those on the IBM ThinkPad laptop computers can be used
- * with the standard console driver.
- */
- if (codeset == 1) {
- if (send_kbd_command_and_data(kbdc,
- KBDC_SET_SCANCODE_SET, codeset) == KBD_ACK) {
- /* XT kbd doesn't need scan code translation */
- c &= ~KBD_TRANSLATION;
- } else {
- /*
- * KEYBOARD ERROR
- * The XT kbd isn't usable unless the proper scan
- * code set is selected.
- */
- set_controller_command_byte(kbdc, 0xff, c);
- kbdc_lock(kbdc, FALSE);
- printf("atkbd: unable to set the XT keyboard mode.\n");
- return EIO;
- }
- }
-
-#ifdef __alpha__
- if (send_kbd_command_and_data(
- kbdc, KBDC_SET_SCANCODE_SET, 2) != KBD_ACK) {
- printf("atkbd: can't set translation.\n");
-
- }
- c |= KBD_TRANSLATION;
-#endif
-
- /* enable the keyboard port and intr. */
- if (!set_controller_command_byte(kbdc,
- KBD_KBD_CONTROL_BITS | KBD_TRANSLATION | KBD_OVERRIDE_KBD_LOCK,
- (c & (KBD_TRANSLATION | KBD_OVERRIDE_KBD_LOCK))
- | KBD_ENABLE_KBD_PORT | KBD_ENABLE_KBD_INT)) {
- /*
- * CONTROLLER ERROR
- * This is serious; we are left with the disabled
- * keyboard intr.
- */
- set_controller_command_byte(kbdc, 0xff, c);
- kbdc_lock(kbdc, FALSE);
- printf("atkbd: unable to enable the keyboard port and intr.\n");
- return EIO;
- }
-
- kbdc_lock(kbdc, FALSE);
- return 0;
-}
-
-static int
-write_kbd(KBDC kbdc, int command, int data)
-{
- int s;
-
- /* prevent the timeout routine from polling the keyboard */
- if (!kbdc_lock(kbdc, TRUE))
- return EBUSY;
-
- /* disable the keyboard and mouse interrupt */
- s = spltty();
-#if 0
- c = get_controller_command_byte(kbdc);
- if ((c == -1)
- || !set_controller_command_byte(kbdc,
- kbdc_get_device_mask(kbdc),
- KBD_DISABLE_KBD_PORT | KBD_DISABLE_KBD_INT
- | KBD_DISABLE_AUX_PORT | KBD_DISABLE_AUX_INT)) {
- /* CONTROLLER ERROR */
- kbdc_lock(kbdc, FALSE);
- splx(s);
- return EIO;
- }
- /*
- * Now that the keyboard controller is told not to generate
- * the keyboard and mouse interrupts, call `splx()' to allow
- * the other tty interrupts. The clock interrupt may also occur,
- * but the timeout routine (`scrn_timer()') will be blocked
- * by the lock flag set via `kbdc_lock()'
- */
- splx(s);
-#endif
-
- if (send_kbd_command_and_data(kbdc, command, data) != KBD_ACK)
- send_kbd_command(kbdc, KBDC_ENABLE_KBD);
-
-#if 0
- /* restore the interrupts */
- if (!set_controller_command_byte(kbdc,
- kbdc_get_device_mask(kbdc),
- c & (KBD_KBD_CONTROL_BITS | KBD_AUX_CONTROL_BITS))) {
- /* CONTROLLER ERROR */
- }
-#else
- splx(s);
-#endif
- kbdc_lock(kbdc, FALSE);
-
- return 0;
-}
-
-static int
-get_kbd_id(KBDC kbdc)
-{
- int id1, id2;
-
- empty_both_buffers(kbdc, 10);
- id1 = id2 = -1;
- if (send_kbd_command(kbdc, KBDC_SEND_DEV_ID) != KBD_ACK)
- return -1;
-
- DELAY(10000); /* 10 msec delay */
- id1 = read_kbd_data(kbdc);
- if (id1 != -1)
- id2 = read_kbd_data(kbdc);
-
- if ((id1 == -1) || (id2 == -1)) {
- empty_both_buffers(kbdc, 10);
- test_controller(kbdc);
- test_kbd_port(kbdc);
- return -1;
- }
- return ((id2 << 8) | id1);
-}
-
-static int delays[] = { 250, 500, 750, 1000 };
-static int rates[] = { 34, 38, 42, 46, 50, 55, 59, 63,
- 68, 76, 84, 92, 100, 110, 118, 126,
- 136, 152, 168, 184, 200, 220, 236, 252,
- 272, 304, 336, 368, 400, 440, 472, 504 };
-
-static int
-typematic_delay(int i)
-{
- return delays[(i >> 5) & 3];
-}
-
-static int
-typematic_rate(int i)
-{
- return rates[i & 0x1f];
-}
-
-static int
-typematic(int delay, int rate)
-{
- int value;
- int i;
-
- for (i = sizeof(delays)/sizeof(delays[0]) - 1; i > 0; --i) {
- if (delay >= delays[i])
- break;
- }
- value = i << 5;
- for (i = sizeof(rates)/sizeof(rates[0]) - 1; i > 0; --i) {
- if (rate >= rates[i])
- break;
- }
- value |= i;
- return value;
-}
diff --git a/sys/dev/atkbdc/atkbd_atkbdc.c b/sys/dev/atkbdc/atkbd_atkbdc.c
deleted file mode 100644
index 944695aace39..000000000000
--- a/sys/dev/atkbdc/atkbd_atkbdc.c
+++ /dev/null
@@ -1,123 +0,0 @@
-/*-
- * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
- * 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 as
- * the first lines of this file unmodified.
- * 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 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.
- *
- * $FreeBSD$
- */
-
-#include "opt_kbd.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/conf.h>
-#include <sys/tty.h>
-#include <sys/bus.h>
-#include <machine/bus.h>
-#include <sys/rman.h>
-
-#include <machine/resource.h>
-
-#include <dev/kbd/kbdreg.h>
-#include <dev/kbd/atkbdreg.h>
-#include <dev/kbd/atkbdcreg.h>
-
-#include <isa/isareg.h>
-#include <isa/isavar.h>
-
-devclass_t atkbd_devclass;
-
-static int atkbdprobe(device_t dev);
-static int atkbdattach(device_t dev);
-static void atkbd_isa_intr(void *arg);
-
-static device_method_t atkbd_methods[] = {
- DEVMETHOD(device_probe, atkbdprobe),
- DEVMETHOD(device_attach, atkbdattach),
- { 0, 0 }
-};
-
-static driver_t atkbd_driver = {
- ATKBD_DRIVER_NAME,
- atkbd_methods,
- 1,
-};
-
-static int
-atkbdprobe(device_t dev)
-{
- uintptr_t port;
- uintptr_t irq;
- uintptr_t flags;
-
- device_set_desc(dev, "AT Keyboard");
-
- /* obtain parameters */
- BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_PORT, &port);
- BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_IRQ, &irq);
- BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_FLAGS, &flags);
-
- /* probe the device */
- return atkbd_probe_unit(device_get_unit(dev), port, irq, flags);
-}
-
-static int
-atkbdattach(device_t dev)
-{
- keyboard_t *kbd;
- uintptr_t port;
- uintptr_t irq;
- uintptr_t flags;
- struct resource *res;
- void *ih;
- int zero = 0;
- int error;
-
- BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_PORT, &port);
- BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_IRQ, &irq);
- BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_FLAGS, &flags);
-
- error = atkbd_attach_unit(device_get_unit(dev), &kbd, port, irq, flags);
- if (error)
- return error;
-
- /* declare our interrupt handler */
- res = bus_alloc_resource(dev, SYS_RES_IRQ, &zero, irq, irq, 1,
- RF_SHAREABLE | RF_ACTIVE);
- BUS_SETUP_INTR(device_get_parent(dev), dev, res, INTR_TYPE_TTY,
- atkbd_isa_intr, kbd, &ih);
-
- return 0;
-}
-
-static void
-atkbd_isa_intr(void *arg)
-{
- keyboard_t *kbd;
-
- kbd = (keyboard_t *)arg;
- (*kbdsw[kbd->kb_index]->intr)(kbd, NULL);
-}
-
-DRIVER_MODULE(atkbd, atkbdc, atkbd_driver, atkbd_devclass, 0, 0);
diff --git a/sys/dev/atkbdc/atkbd_isa.c b/sys/dev/atkbdc/atkbd_isa.c
deleted file mode 100644
index 944695aace39..000000000000
--- a/sys/dev/atkbdc/atkbd_isa.c
+++ /dev/null
@@ -1,123 +0,0 @@
-/*-
- * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
- * 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 as
- * the first lines of this file unmodified.
- * 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 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.
- *
- * $FreeBSD$
- */
-
-#include "opt_kbd.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/conf.h>
-#include <sys/tty.h>
-#include <sys/bus.h>
-#include <machine/bus.h>
-#include <sys/rman.h>
-
-#include <machine/resource.h>
-
-#include <dev/kbd/kbdreg.h>
-#include <dev/kbd/atkbdreg.h>
-#include <dev/kbd/atkbdcreg.h>
-
-#include <isa/isareg.h>
-#include <isa/isavar.h>
-
-devclass_t atkbd_devclass;
-
-static int atkbdprobe(device_t dev);
-static int atkbdattach(device_t dev);
-static void atkbd_isa_intr(void *arg);
-
-static device_method_t atkbd_methods[] = {
- DEVMETHOD(device_probe, atkbdprobe),
- DEVMETHOD(device_attach, atkbdattach),
- { 0, 0 }
-};
-
-static driver_t atkbd_driver = {
- ATKBD_DRIVER_NAME,
- atkbd_methods,
- 1,
-};
-
-static int
-atkbdprobe(device_t dev)
-{
- uintptr_t port;
- uintptr_t irq;
- uintptr_t flags;
-
- device_set_desc(dev, "AT Keyboard");
-
- /* obtain parameters */
- BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_PORT, &port);
- BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_IRQ, &irq);
- BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_FLAGS, &flags);
-
- /* probe the device */
- return atkbd_probe_unit(device_get_unit(dev), port, irq, flags);
-}
-
-static int
-atkbdattach(device_t dev)
-{
- keyboard_t *kbd;
- uintptr_t port;
- uintptr_t irq;
- uintptr_t flags;
- struct resource *res;
- void *ih;
- int zero = 0;
- int error;
-
- BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_PORT, &port);
- BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_IRQ, &irq);
- BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_FLAGS, &flags);
-
- error = atkbd_attach_unit(device_get_unit(dev), &kbd, port, irq, flags);
- if (error)
- return error;
-
- /* declare our interrupt handler */
- res = bus_alloc_resource(dev, SYS_RES_IRQ, &zero, irq, irq, 1,
- RF_SHAREABLE | RF_ACTIVE);
- BUS_SETUP_INTR(device_get_parent(dev), dev, res, INTR_TYPE_TTY,
- atkbd_isa_intr, kbd, &ih);
-
- return 0;
-}
-
-static void
-atkbd_isa_intr(void *arg)
-{
- keyboard_t *kbd;
-
- kbd = (keyboard_t *)arg;
- (*kbdsw[kbd->kb_index]->intr)(kbd, NULL);
-}
-
-DRIVER_MODULE(atkbd, atkbdc, atkbd_driver, atkbd_devclass, 0, 0);
diff --git a/sys/dev/atkbdc/atkbdc.c b/sys/dev/atkbdc/atkbdc.c
deleted file mode 100644
index 63ea12614918..000000000000
--- a/sys/dev/atkbdc/atkbdc.c
+++ /dev/null
@@ -1,1017 +0,0 @@
-/*-
- * Copyright (c) 1996-1999
- * Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- * from kbdio.c,v 1.13 1998/09/25 11:55:46 yokota Exp
- */
-
-#include "atkbdc.h"
-#include "opt_kbd.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/malloc.h>
-#include <sys/syslog.h>
-
-#include <machine/clock.h>
-
-#include <dev/kbd/atkbdcreg.h>
-
-#include <isa/isareg.h>
-
-/* constants */
-
-#define MAXKBDC MAX(NATKBDC, 1) /* XXX */
-
-/* macros */
-
-#ifndef MAX
-#define MAX(x, y) ((x) > (y) ? (x) : (y))
-#endif
-
-#define kbdcp(p) ((atkbdc_softc_t *)(p))
-#define nextq(i) (((i) + 1) % KBDQ_BUFSIZE)
-#define availq(q) ((q)->head != (q)->tail)
-#if KBDIO_DEBUG >= 2
-#define emptyq(q) ((q)->tail = (q)->head = (q)->qcount = 0)
-#else
-#define emptyq(q) ((q)->tail = (q)->head = 0)
-#endif
-
-/* local variables */
-
-/*
- * We always need at least one copy of the kbdc_softc struct for the
- * low-level console. As the low-level console accesses the keyboard
- * controller before kbdc, and all other devices, is probed, we
- * statically allocate one entry. XXX
- */
-static atkbdc_softc_t default_kbdc;
-static atkbdc_softc_t *atkbdc_softc[MAXKBDC] = { &default_kbdc };
-
-static int verbose = KBDIO_DEBUG;
-
-/* function prototypes */
-
-static int atkbdc_setup(atkbdc_softc_t *sc, int port);
-static int addq(kqueue *q, int c);
-static int removeq(kqueue *q);
-static int wait_while_controller_busy(atkbdc_softc_t *kbdc);
-static int wait_for_data(atkbdc_softc_t *kbdc);
-static int wait_for_kbd_data(atkbdc_softc_t *kbdc);
-static int wait_for_kbd_ack(atkbdc_softc_t *kbdc);
-static int wait_for_aux_data(atkbdc_softc_t *kbdc);
-static int wait_for_aux_ack(atkbdc_softc_t *kbdc);
-
-atkbdc_softc_t
-*atkbdc_get_softc(int unit)
-{
- atkbdc_softc_t *sc;
-
- if (unit >= sizeof(atkbdc_softc)/sizeof(atkbdc_softc[0]))
- return NULL;
- sc = atkbdc_softc[unit];
- if (sc == NULL) {
- sc = atkbdc_softc[unit]
- = malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT);
- if (sc == NULL)
- return NULL;
- bzero(sc, sizeof(*sc));
- sc->port = -1; /* XXX */
- }
- return sc;
-}
-
-int
-atkbdc_probe_unit(int unit, int port)
-{
- if (port <= 0)
- return ENXIO;
- return 0;
-}
-
-int
-atkbdc_attach_unit(int unit, atkbdc_softc_t *sc, int port)
-{
- return atkbdc_setup(sc, port);
-}
-
-/* the backdoor to the keyboard controller! XXX */
-int
-atkbdc_configure(void)
-{
- return atkbdc_setup(atkbdc_softc[0], -1);
-}
-
-static int
-atkbdc_setup(atkbdc_softc_t *sc, int port)
-{
- if (port <= 0)
- port = IO_KBD;
-
- if (sc->port <= 0) {
- sc->command_byte = -1;
- sc->command_mask = 0;
- sc->lock = FALSE;
- sc->kbd.head = sc->kbd.tail = 0;
- sc->aux.head = sc->aux.tail = 0;
-#if KBDIO_DEBUG >= 2
- sc->kbd.call_count = 0;
- sc->kbd.qcount = sc->kbd.max_qcount = 0;
- sc->aux.call_count = 0;
- sc->aux.qcount = sc->aux.max_qcount = 0;
-#endif
- }
- sc->port = port; /* may override the previous value */
- return 0;
-}
-
-/* associate a port number with a KBDC */
-
-KBDC
-kbdc_open(int port)
-{
- int s;
- int i;
-
- if (port <= 0)
- port = IO_KBD;
-
- s = spltty();
- for (i = 0; i < sizeof(atkbdc_softc)/sizeof(atkbdc_softc[0]); ++i) {
- if (atkbdc_softc[i] == NULL)
- continue;
- if (atkbdc_softc[i]->port == port) {
- splx(s);
- return (KBDC)atkbdc_softc[i];
- }
- if (atkbdc_softc[i]->port <= 0) {
- if (atkbdc_setup(atkbdc_softc[i], port))
- break;
- splx(s);
- return (KBDC)atkbdc_softc[i];
- }
- }
- splx(s);
- return NULL;
-}
-
-/*
- * I/O access arbitration in `kbdio'
- *
- * The `kbdio' module uses a simplistic convention to arbitrate
- * I/O access to the controller/keyboard/mouse. The convention requires
- * close cooperation of the calling device driver.
- *
- * The device driver which utilizes the `kbdio' module are assumed to
- * have the following set of routines.
- * a. An interrupt handler (the bottom half of the driver).
- * b. Timeout routines which may briefly polls the keyboard controller.
- * c. Routines outside interrupt context (the top half of the driver).
- * They should follow the rules below:
- * 1. The interrupt handler may assume that it always has full access
- * to the controller/keyboard/mouse.
- * 2. The other routines must issue `spltty()' if they wish to
- * prevent the interrupt handler from accessing
- * the controller/keyboard/mouse.
- * 3. The timeout routines and the top half routines of the device driver
- * arbitrate I/O access by observing the lock flag in `kbdio'.
- * The flag is manipulated via `kbdc_lock()'; when one wants to
- * perform I/O, call `kbdc_lock(kbdc, TRUE)' and proceed only if
- * the call returns with TRUE. Otherwise the caller must back off.
- * Call `kbdc_lock(kbdc, FALSE)' when necessary I/O operaion
- * is finished. This mechanism does not prevent the interrupt
- * handler from being invoked at any time and carrying out I/O.
- * Therefore, `spltty()' must be strategically placed in the device
- * driver code. Also note that the timeout routine may interrupt
- * `kbdc_lock()' called by the top half of the driver, but this
- * interruption is OK so long as the timeout routine observes the
- * the rule 4 below.
- * 4. The interrupt and timeout routines should not extend I/O operation
- * across more than one interrupt or timeout; they must complete
- * necessary I/O operation within one invokation of the routine.
- * This measns that if the timeout routine acquires the lock flag,
- * it must reset the flag to FALSE before it returns.
- */
-
-/* set/reset polling lock */
-int
-kbdc_lock(KBDC p, int lock)
-{
- int prevlock;
-
- prevlock = kbdcp(p)->lock;
- kbdcp(p)->lock = lock;
-
- return (prevlock != lock);
-}
-
-/* check if any data is waiting to be processed */
-int
-kbdc_data_ready(KBDC p)
-{
- return (availq(&kbdcp(p)->kbd) || availq(&kbdcp(p)->aux)
- || (inb(kbdcp(p)->port + KBD_STATUS_PORT) & KBDS_ANY_BUFFER_FULL));
-}
-
-/* queuing functions */
-
-static int
-addq(kqueue *q, int c)
-{
- if (nextq(q->tail) != q->head) {
- q->q[q->tail] = c;
- q->tail = nextq(q->tail);
-#if KBDIO_DEBUG >= 2
- ++q->call_count;
- ++q->qcount;
- if (q->qcount > q->max_qcount)
- q->max_qcount = q->qcount;
-#endif
- return TRUE;
- }
- return FALSE;
-}
-
-static int
-removeq(kqueue *q)
-{
- int c;
-
- if (q->tail != q->head) {
- c = q->q[q->head];
- q->head = nextq(q->head);
-#if KBDIO_DEBUG >= 2
- --q->qcount;
-#endif
- return c;
- }
- return -1;
-}
-
-/*
- * device I/O routines
- */
-static int
-wait_while_controller_busy(struct atkbdc_softc *kbdc)
-{
- /* CPU will stay inside the loop for 100msec at most */
- int retry = 5000;
- int port = kbdc->port;
- int f;
-
- while ((f = inb(port + KBD_STATUS_PORT)) & KBDS_INPUT_BUFFER_FULL) {
- if ((f & KBDS_BUFFER_FULL) == KBDS_KBD_BUFFER_FULL) {
- DELAY(KBDD_DELAYTIME);
- addq(&kbdc->kbd, inb(port + KBD_DATA_PORT));
- } else if ((f & KBDS_BUFFER_FULL) == KBDS_AUX_BUFFER_FULL) {
- DELAY(KBDD_DELAYTIME);
- addq(&kbdc->aux, inb(port + KBD_DATA_PORT));
- }
- DELAY(KBDC_DELAYTIME);
- if (--retry < 0)
- return FALSE;
- }
- return TRUE;
-}
-
-/*
- * wait for any data; whether it's from the controller,
- * the keyboard, or the aux device.
- */
-static int
-wait_for_data(struct atkbdc_softc *kbdc)
-{
- /* CPU will stay inside the loop for 200msec at most */
- int retry = 10000;
- int port = kbdc->port;
- int f;
-
- while ((f = inb(port + KBD_STATUS_PORT) & KBDS_ANY_BUFFER_FULL) == 0) {
- DELAY(KBDC_DELAYTIME);
- if (--retry < 0)
- return 0;
- }
- DELAY(KBDD_DELAYTIME);
- return f;
-}
-
-/* wait for data from the keyboard */
-static int
-wait_for_kbd_data(struct atkbdc_softc *kbdc)
-{
- /* CPU will stay inside the loop for 200msec at most */
- int retry = 10000;
- int port = kbdc->port;
- int f;
-
- while ((f = inb(port + KBD_STATUS_PORT) & KBDS_BUFFER_FULL)
- != KBDS_KBD_BUFFER_FULL) {
- if (f == KBDS_AUX_BUFFER_FULL) {
- DELAY(KBDD_DELAYTIME);
- addq(&kbdc->aux, inb(port + KBD_DATA_PORT));
- }
- DELAY(KBDC_DELAYTIME);
- if (--retry < 0)
- return 0;
- }
- DELAY(KBDD_DELAYTIME);
- return f;
-}
-
-/*
- * wait for an ACK(FAh), RESEND(FEh), or RESET_FAIL(FCh) from the keyboard.
- * queue anything else.
- */
-static int
-wait_for_kbd_ack(struct atkbdc_softc *kbdc)
-{
- /* CPU will stay inside the loop for 200msec at most */
- int retry = 10000;
- int port = kbdc->port;
- int f;
- int b;
-
- while (retry-- > 0) {
- if ((f = inb(port + KBD_STATUS_PORT)) & KBDS_ANY_BUFFER_FULL) {
- DELAY(KBDD_DELAYTIME);
- b = inb(port + KBD_DATA_PORT);
- if ((f & KBDS_BUFFER_FULL) == KBDS_KBD_BUFFER_FULL) {
- if ((b == KBD_ACK) || (b == KBD_RESEND)
- || (b == KBD_RESET_FAIL))
- return b;
- addq(&kbdc->kbd, b);
- } else if ((f & KBDS_BUFFER_FULL) == KBDS_AUX_BUFFER_FULL) {
- addq(&kbdc->aux, b);
- }
- }
- DELAY(KBDC_DELAYTIME);
- }
- return -1;
-}
-
-/* wait for data from the aux device */
-static int
-wait_for_aux_data(struct atkbdc_softc *kbdc)
-{
- /* CPU will stay inside the loop for 200msec at most */
- int retry = 10000;
- int port = kbdc->port;
- int f;
-
- while ((f = inb(port + KBD_STATUS_PORT) & KBDS_BUFFER_FULL)
- != KBDS_AUX_BUFFER_FULL) {
- if (f == KBDS_KBD_BUFFER_FULL) {
- DELAY(KBDD_DELAYTIME);
- addq(&kbdc->kbd, inb(port + KBD_DATA_PORT));
- }
- DELAY(KBDC_DELAYTIME);
- if (--retry < 0)
- return 0;
- }
- DELAY(KBDD_DELAYTIME);
- return f;
-}
-
-/*
- * wait for an ACK(FAh), RESEND(FEh), or RESET_FAIL(FCh) from the aux device.
- * queue anything else.
- */
-static int
-wait_for_aux_ack(struct atkbdc_softc *kbdc)
-{
- /* CPU will stay inside the loop for 200msec at most */
- int retry = 10000;
- int port = kbdc->port;
- int f;
- int b;
-
- while (retry-- > 0) {
- if ((f = inb(port + KBD_STATUS_PORT)) & KBDS_ANY_BUFFER_FULL) {
- DELAY(KBDD_DELAYTIME);
- b = inb(port + KBD_DATA_PORT);
- if ((f & KBDS_BUFFER_FULL) == KBDS_AUX_BUFFER_FULL) {
- if ((b == PSM_ACK) || (b == PSM_RESEND)
- || (b == PSM_RESET_FAIL))
- return b;
- addq(&kbdc->aux, b);
- } else if ((f & KBDS_BUFFER_FULL) == KBDS_KBD_BUFFER_FULL) {
- addq(&kbdc->kbd, b);
- }
- }
- DELAY(KBDC_DELAYTIME);
- }
- return -1;
-}
-
-/* write a one byte command to the controller */
-int
-write_controller_command(KBDC p, int c)
-{
- if (!wait_while_controller_busy(kbdcp(p)))
- return FALSE;
- outb(kbdcp(p)->port + KBD_COMMAND_PORT, c);
- return TRUE;
-}
-
-/* write a one byte data to the controller */
-int
-write_controller_data(KBDC p, int c)
-{
- if (!wait_while_controller_busy(kbdcp(p)))
- return FALSE;
- outb(kbdcp(p)->port + KBD_DATA_PORT, c);
- return TRUE;
-}
-
-/* write a one byte keyboard command */
-int
-write_kbd_command(KBDC p, int c)
-{
- if (!wait_while_controller_busy(kbdcp(p)))
- return FALSE;
- outb(kbdcp(p)->port + KBD_DATA_PORT, c);
- return TRUE;
-}
-
-/* write a one byte auxiliary device command */
-int
-write_aux_command(KBDC p, int c)
-{
- if (!write_controller_command(p, KBDC_WRITE_TO_AUX))
- return FALSE;
- return write_controller_data(p, c);
-}
-
-/* send a command to the keyboard and wait for ACK */
-int
-send_kbd_command(KBDC p, int c)
-{
- int retry = KBD_MAXRETRY;
- int res = -1;
-
- while (retry-- > 0) {
- if (!write_kbd_command(p, c))
- continue;
- res = wait_for_kbd_ack(kbdcp(p));
- if (res == KBD_ACK)
- break;
- }
- return res;
-}
-
-/* send a command to the auxiliary device and wait for ACK */
-int
-send_aux_command(KBDC p, int c)
-{
- int retry = KBD_MAXRETRY;
- int res = -1;
-
- while (retry-- > 0) {
- if (!write_aux_command(p, c))
- continue;
- /*
- * FIXME: XXX
- * The aux device may have already sent one or two bytes of
- * status data, when a command is received. It will immediately
- * stop data transmission, thus, leaving an incomplete data
- * packet in our buffer. We have to discard any unprocessed
- * data in order to remove such packets. Well, we may remove
- * unprocessed, but necessary data byte as well...
- */
- emptyq(&kbdcp(p)->aux);
- res = wait_for_aux_ack(kbdcp(p));
- if (res == PSM_ACK)
- break;
- }
- return res;
-}
-
-/* send a command and a data to the keyboard, wait for ACKs */
-int
-send_kbd_command_and_data(KBDC p, int c, int d)
-{
- int retry;
- int res = -1;
-
- for (retry = KBD_MAXRETRY; retry > 0; --retry) {
- if (!write_kbd_command(p, c))
- continue;
- res = wait_for_kbd_ack(kbdcp(p));
- if (res == KBD_ACK)
- break;
- else if (res != KBD_RESEND)
- return res;
- }
- if (retry <= 0)
- return res;
-
- for (retry = KBD_MAXRETRY, res = -1; retry > 0; --retry) {
- if (!write_kbd_command(p, d))
- continue;
- res = wait_for_kbd_ack(kbdcp(p));
- if (res != KBD_RESEND)
- break;
- }
- return res;
-}
-
-/* send a command and a data to the auxiliary device, wait for ACKs */
-int
-send_aux_command_and_data(KBDC p, int c, int d)
-{
- int retry;
- int res = -1;
-
- for (retry = KBD_MAXRETRY; retry > 0; --retry) {
- if (!write_aux_command(p, c))
- continue;
- emptyq(&kbdcp(p)->aux);
- res = wait_for_aux_ack(kbdcp(p));
- if (res == PSM_ACK)
- break;
- else if (res != PSM_RESEND)
- return res;
- }
- if (retry <= 0)
- return res;
-
- for (retry = KBD_MAXRETRY, res = -1; retry > 0; --retry) {
- if (!write_aux_command(p, d))
- continue;
- res = wait_for_aux_ack(kbdcp(p));
- if (res != PSM_RESEND)
- break;
- }
- return res;
-}
-
-/*
- * read one byte from any source; whether from the controller,
- * the keyboard, or the aux device
- */
-int
-read_controller_data(KBDC p)
-{
- if (availq(&kbdcp(p)->kbd))
- return removeq(&kbdcp(p)->kbd);
- if (availq(&kbdcp(p)->aux))
- return removeq(&kbdcp(p)->aux);
- if (!wait_for_data(kbdcp(p)))
- return -1; /* timeout */
- return inb(kbdcp(p)->port + KBD_DATA_PORT);
-}
-
-#if KBDIO_DEBUG >= 2
-static int call = 0;
-#endif
-
-/* read one byte from the keyboard */
-int
-read_kbd_data(KBDC p)
-{
-#if KBDIO_DEBUG >= 2
- if (++call > 2000) {
- call = 0;
- log(LOG_DEBUG, "kbdc: kbd q: %d calls, max %d chars, "
- "aux q: %d calls, max %d chars\n",
- kbdcp(p)->kbd.call_count, kbdcp(p)->kbd.max_qcount,
- kbdcp(p)->aux.call_count, kbdcp(p)->aux.max_qcount);
- }
-#endif
-
- if (availq(&kbdcp(p)->kbd))
- return removeq(&kbdcp(p)->kbd);
- if (!wait_for_kbd_data(kbdcp(p)))
- return -1; /* timeout */
- return inb(kbdcp(p)->port + KBD_DATA_PORT);
-}
-
-/* read one byte from the keyboard, but return immediately if
- * no data is waiting
- */
-int
-read_kbd_data_no_wait(KBDC p)
-{
- int f;
-
-#if KBDIO_DEBUG >= 2
- if (++call > 2000) {
- call = 0;
- log(LOG_DEBUG, "kbdc: kbd q: %d calls, max %d chars, "
- "aux q: %d calls, max %d chars\n",
- kbdcp(p)->kbd.call_count, kbdcp(p)->kbd.max_qcount,
- kbdcp(p)->aux.call_count, kbdcp(p)->aux.max_qcount);
- }
-#endif
-
- if (availq(&kbdcp(p)->kbd))
- return removeq(&kbdcp(p)->kbd);
- f = inb(kbdcp(p)->port + KBD_STATUS_PORT) & KBDS_BUFFER_FULL;
- if (f == KBDS_AUX_BUFFER_FULL) {
- DELAY(KBDD_DELAYTIME);
- addq(&kbdcp(p)->aux, inb(kbdcp(p)->port + KBD_DATA_PORT));
- f = inb(kbdcp(p)->port + KBD_STATUS_PORT) & KBDS_BUFFER_FULL;
- }
- if (f == KBDS_KBD_BUFFER_FULL) {
- DELAY(KBDD_DELAYTIME);
- return inb(kbdcp(p)->port + KBD_DATA_PORT);
- }
- return -1; /* no data */
-}
-
-/* read one byte from the aux device */
-int
-read_aux_data(KBDC p)
-{
- if (availq(&kbdcp(p)->aux))
- return removeq(&kbdcp(p)->aux);
- if (!wait_for_aux_data(kbdcp(p)))
- return -1; /* timeout */
- return inb(kbdcp(p)->port + KBD_DATA_PORT);
-}
-
-/* read one byte from the aux device, but return immediately if
- * no data is waiting
- */
-int
-read_aux_data_no_wait(KBDC p)
-{
- int f;
-
- if (availq(&kbdcp(p)->aux))
- return removeq(&kbdcp(p)->aux);
- f = inb(kbdcp(p)->port + KBD_STATUS_PORT) & KBDS_BUFFER_FULL;
- if (f == KBDS_KBD_BUFFER_FULL) {
- DELAY(KBDD_DELAYTIME);
- addq(&kbdcp(p)->kbd, inb(kbdcp(p)->port + KBD_DATA_PORT));
- f = inb(kbdcp(p)->port + KBD_STATUS_PORT) & KBDS_BUFFER_FULL;
- }
- if (f == KBDS_AUX_BUFFER_FULL) {
- DELAY(KBDD_DELAYTIME);
- return inb(kbdcp(p)->port + KBD_DATA_PORT);
- }
- return -1; /* no data */
-}
-
-/* discard data from the keyboard */
-void
-empty_kbd_buffer(KBDC p, int wait)
-{
- int t;
- int b;
- int f;
-#if KBDIO_DEBUG >= 2
- int c1 = 0;
- int c2 = 0;
-#endif
- int delta = 2;
-
- for (t = wait; t > 0; ) {
- if ((f = inb(kbdcp(p)->port + KBD_STATUS_PORT)) & KBDS_ANY_BUFFER_FULL) {
- DELAY(KBDD_DELAYTIME);
- b = inb(kbdcp(p)->port + KBD_DATA_PORT);
- if ((f & KBDS_BUFFER_FULL) == KBDS_AUX_BUFFER_FULL) {
- addq(&kbdcp(p)->aux, b);
-#if KBDIO_DEBUG >= 2
- ++c2;
- } else {
- ++c1;
-#endif
- }
- t = wait;
- } else {
- t -= delta;
- }
- DELAY(delta*1000);
- }
-#if KBDIO_DEBUG >= 2
- if ((c1 > 0) || (c2 > 0))
- log(LOG_DEBUG, "kbdc: %d:%d char read (empty_kbd_buffer)\n", c1, c2);
-#endif
-
- emptyq(&kbdcp(p)->kbd);
-}
-
-/* discard data from the aux device */
-void
-empty_aux_buffer(KBDC p, int wait)
-{
- int t;
- int b;
- int f;
-#if KBDIO_DEBUG >= 2
- int c1 = 0;
- int c2 = 0;
-#endif
- int delta = 2;
-
- for (t = wait; t > 0; ) {
- if ((f = inb(kbdcp(p)->port + KBD_STATUS_PORT)) & KBDS_ANY_BUFFER_FULL) {
- DELAY(KBDD_DELAYTIME);
- b = inb(kbdcp(p)->port + KBD_DATA_PORT);
- if ((f & KBDS_BUFFER_FULL) == KBDS_KBD_BUFFER_FULL) {
- addq(&kbdcp(p)->kbd, b);
-#if KBDIO_DEBUG >= 2
- ++c1;
- } else {
- ++c2;
-#endif
- }
- t = wait;
- } else {
- t -= delta;
- }
- DELAY(delta*1000);
- }
-#if KBDIO_DEBUG >= 2
- if ((c1 > 0) || (c2 > 0))
- log(LOG_DEBUG, "kbdc: %d:%d char read (empty_aux_buffer)\n", c1, c2);
-#endif
-
- emptyq(&kbdcp(p)->aux);
-}
-
-/* discard any data from the keyboard or the aux device */
-void
-empty_both_buffers(KBDC p, int wait)
-{
- int t;
- int f;
-#if KBDIO_DEBUG >= 2
- int c1 = 0;
- int c2 = 0;
-#endif
- int delta = 2;
-
- for (t = wait; t > 0; ) {
- if ((f = inb(kbdcp(p)->port + KBD_STATUS_PORT)) & KBDS_ANY_BUFFER_FULL) {
- DELAY(KBDD_DELAYTIME);
- (void)inb(kbdcp(p)->port + KBD_DATA_PORT);
-#if KBDIO_DEBUG >= 2
- if ((f & KBDS_BUFFER_FULL) == KBDS_KBD_BUFFER_FULL)
- ++c1;
- else
- ++c2;
-#endif
- t = wait;
- } else {
- t -= delta;
- }
- DELAY(delta*1000);
- }
-#if KBDIO_DEBUG >= 2
- if ((c1 > 0) || (c2 > 0))
- log(LOG_DEBUG, "kbdc: %d:%d char read (empty_both_buffers)\n", c1, c2);
-#endif
-
- emptyq(&kbdcp(p)->kbd);
- emptyq(&kbdcp(p)->aux);
-}
-
-/* keyboard and mouse device control */
-
-/* NOTE: enable the keyboard port but disable the keyboard
- * interrupt before calling "reset_kbd()".
- */
-int
-reset_kbd(KBDC p)
-{
- int retry = KBD_MAXRETRY;
- int again = KBD_MAXWAIT;
- int c = KBD_RESEND; /* keep the compiler happy */
-
- while (retry-- > 0) {
- empty_both_buffers(p, 10);
- if (!write_kbd_command(p, KBDC_RESET_KBD))
- continue;
- emptyq(&kbdcp(p)->kbd);
- c = read_controller_data(p);
- if (verbose || bootverbose)
- log(LOG_DEBUG, "kbdc: RESET_KBD return code:%04x\n", c);
- if (c == KBD_ACK) /* keyboard has agreed to reset itself... */
- break;
- }
- if (retry < 0)
- return FALSE;
-
- while (again-- > 0) {
- /* wait awhile, well, in fact we must wait quite loooooooooooong */
- DELAY(KBD_RESETDELAY*1000);
- c = read_controller_data(p); /* RESET_DONE/RESET_FAIL */
- if (c != -1) /* wait again if the controller is not ready */
- break;
- }
- if (verbose || bootverbose)
- log(LOG_DEBUG, "kbdc: RESET_KBD status:%04x\n", c);
- if (c != KBD_RESET_DONE)
- return FALSE;
- return TRUE;
-}
-
-/* NOTE: enable the aux port but disable the aux interrupt
- * before calling `reset_aux_dev()'.
- */
-int
-reset_aux_dev(KBDC p)
-{
- int retry = KBD_MAXRETRY;
- int again = KBD_MAXWAIT;
- int c = PSM_RESEND; /* keep the compiler happy */
-
- while (retry-- > 0) {
- empty_both_buffers(p, 10);
- if (!write_aux_command(p, PSMC_RESET_DEV))
- continue;
- emptyq(&kbdcp(p)->aux);
- /* NOTE: Compaq Armada laptops require extra delay here. XXX */
- for (again = KBD_MAXWAIT; again > 0; --again) {
- DELAY(KBD_RESETDELAY*1000);
- c = read_aux_data_no_wait(p);
- if (c != -1)
- break;
- }
- if (verbose || bootverbose)
- log(LOG_DEBUG, "kbdc: RESET_AUX return code:%04x\n", c);
- if (c == PSM_ACK) /* aux dev is about to reset... */
- break;
- }
- if (retry < 0)
- return FALSE;
-
- for (again = KBD_MAXWAIT; again > 0; --again) {
- /* wait awhile, well, quite looooooooooooong */
- DELAY(KBD_RESETDELAY*1000);
- c = read_aux_data_no_wait(p); /* RESET_DONE/RESET_FAIL */
- if (c != -1) /* wait again if the controller is not ready */
- break;
- }
- if (verbose || bootverbose)
- log(LOG_DEBUG, "kbdc: RESET_AUX status:%04x\n", c);
- if (c != PSM_RESET_DONE) /* reset status */
- return FALSE;
-
- c = read_aux_data(p); /* device ID */
- if (verbose || bootverbose)
- log(LOG_DEBUG, "kbdc: RESET_AUX ID:%04x\n", c);
- /* NOTE: we could check the device ID now, but leave it later... */
- return TRUE;
-}
-
-/* controller diagnostics and setup */
-
-int
-test_controller(KBDC p)
-{
- int retry = KBD_MAXRETRY;
- int again = KBD_MAXWAIT;
- int c = KBD_DIAG_FAIL;
-
- while (retry-- > 0) {
- empty_both_buffers(p, 10);
- if (write_controller_command(p, KBDC_DIAGNOSE))
- break;
- }
- if (retry < 0)
- return FALSE;
-
- emptyq(&kbdcp(p)->kbd);
- while (again-- > 0) {
- /* wait awhile */
- DELAY(KBD_RESETDELAY*1000);
- c = read_controller_data(p); /* DIAG_DONE/DIAG_FAIL */
- if (c != -1) /* wait again if the controller is not ready */
- break;
- }
- if (verbose || bootverbose)
- log(LOG_DEBUG, "kbdc: DIAGNOSE status:%04x\n", c);
- return (c == KBD_DIAG_DONE);
-}
-
-int
-test_kbd_port(KBDC p)
-{
- int retry = KBD_MAXRETRY;
- int again = KBD_MAXWAIT;
- int c = -1;
-
- while (retry-- > 0) {
- empty_both_buffers(p, 10);
- if (write_controller_command(p, KBDC_TEST_KBD_PORT))
- break;
- }
- if (retry < 0)
- return FALSE;
-
- emptyq(&kbdcp(p)->kbd);
- while (again-- > 0) {
- c = read_controller_data(p);
- if (c != -1) /* try again if the controller is not ready */
- break;
- }
- if (verbose || bootverbose)
- log(LOG_DEBUG, "kbdc: TEST_KBD_PORT status:%04x\n", c);
- return c;
-}
-
-int
-test_aux_port(KBDC p)
-{
- int retry = KBD_MAXRETRY;
- int again = KBD_MAXWAIT;
- int c = -1;
-
- while (retry-- > 0) {
- empty_both_buffers(p, 10);
- if (write_controller_command(p, KBDC_TEST_AUX_PORT))
- break;
- }
- if (retry < 0)
- return FALSE;
-
- emptyq(&kbdcp(p)->kbd);
- while (again-- > 0) {
- c = read_controller_data(p);
- if (c != -1) /* try again if the controller is not ready */
- break;
- }
- if (verbose || bootverbose)
- log(LOG_DEBUG, "kbdc: TEST_AUX_PORT status:%04x\n", c);
- return c;
-}
-
-int
-kbdc_get_device_mask(KBDC p)
-{
- return kbdcp(p)->command_mask;
-}
-
-void
-kbdc_set_device_mask(KBDC p, int mask)
-{
- kbdcp(p)->command_mask =
- mask & (KBD_KBD_CONTROL_BITS | KBD_AUX_CONTROL_BITS);
-}
-
-int
-get_controller_command_byte(KBDC p)
-{
- if (kbdcp(p)->command_byte != -1)
- return kbdcp(p)->command_byte;
- if (!write_controller_command(p, KBDC_GET_COMMAND_BYTE))
- return -1;
- emptyq(&kbdcp(p)->kbd);
- kbdcp(p)->command_byte = read_controller_data(p);
- return kbdcp(p)->command_byte;
-}
-
-int
-set_controller_command_byte(KBDC p, int mask, int command)
-{
- if (get_controller_command_byte(p) == -1)
- return FALSE;
-
- command = (kbdcp(p)->command_byte & ~mask) | (command & mask);
- if (command & KBD_DISABLE_KBD_PORT) {
- if (!write_controller_command(p, KBDC_DISABLE_KBD_PORT))
- return FALSE;
- }
- if (!write_controller_command(p, KBDC_SET_COMMAND_BYTE))
- return FALSE;
- if (!write_controller_data(p, command))
- return FALSE;
- kbdcp(p)->command_byte = command;
-
- if (verbose)
- log(LOG_DEBUG, "kbdc: new command byte:%04x (set_controller...)\n",
- command);
-
- return TRUE;
-}
diff --git a/sys/dev/atkbdc/atkbdc_isa.c b/sys/dev/atkbdc/atkbdc_isa.c
deleted file mode 100644
index 9549c99d5d4d..000000000000
--- a/sys/dev/atkbdc/atkbdc_isa.c
+++ /dev/null
@@ -1,267 +0,0 @@
-/*-
- * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
- * 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 as
- * the first lines of this file unmodified.
- * 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 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.
- *
- * $FreeBSD$
- */
-
-#include "opt_kbd.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/bus.h>
-#include <sys/malloc.h>
-#include <machine/bus.h>
-#include <machine/resource.h>
-#include <sys/rman.h>
-
-#include <dev/kbd/atkbdcreg.h>
-
-#include <isa/isareg.h>
-#include <isa/isavar.h>
-
-MALLOC_DEFINE(M_ATKBDDEV, "atkbddev", "AT Keyboard device");
-
-/* children */
-typedef struct atkbdc_device {
- int flags; /* configuration flags */
- int port; /* port number (same as the controller's) */
- int irq; /* ISA IRQ mask */
-} atkbdc_device_t;
-
-/* kbdc */
-devclass_t atkbdc_devclass;
-
-static int atkbdc_probe(device_t dev);
-static int atkbdc_attach(device_t dev);
-static int atkbdc_print_child(device_t bus, device_t dev);
-static int atkbdc_read_ivar(device_t bus, device_t dev, int index,
- u_long *val);
-static int atkbdc_write_ivar(device_t bus, device_t dev, int index,
- u_long val);
-
-static device_method_t atkbdc_methods[] = {
- DEVMETHOD(device_probe, atkbdc_probe),
- DEVMETHOD(device_attach, atkbdc_attach),
- DEVMETHOD(device_suspend, bus_generic_suspend),
- DEVMETHOD(device_resume, bus_generic_resume),
-
- DEVMETHOD(bus_print_child, atkbdc_print_child),
- DEVMETHOD(bus_read_ivar, atkbdc_read_ivar),
- DEVMETHOD(bus_write_ivar, atkbdc_write_ivar),
- DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
- DEVMETHOD(bus_release_resource, bus_generic_release_resource),
- DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
- DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
- DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
- DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
-
- { 0, 0 }
-};
-
-static driver_t atkbdc_driver = {
- ATKBDC_DRIVER_NAME,
- atkbdc_methods,
- sizeof(atkbdc_softc_t *),
-};
-
-static int
-atkbdc_probe(device_t dev)
-{
- int error;
- int rid;
- struct resource *port;
-
- /* Check isapnp ids */
- if (isa_get_vendorid(dev))
- return (ENXIO);
-
- device_set_desc(dev, "keyboard controller (i8042)");
- rid = 0;
- port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
- 0, ~0, IO_KBDSIZE, RF_ACTIVE);
- if (!port)
- return ENXIO;
- error = atkbdc_probe_unit(device_get_unit(dev), rman_get_start(port));
- bus_release_resource(dev, SYS_RES_IOPORT, rid, port);
- return error;
-}
-
-static void
-atkbdc_add_device(device_t dev, const char *name, int unit)
-{
- atkbdc_softc_t *sc = *(atkbdc_softc_t **)device_get_softc(dev);
- atkbdc_device_t *kdev;
- device_t child;
- int t;
-
- if (resource_int_value(name, unit, "disabled", &t) == 0 && t != 0)
- return;
-
- kdev = malloc(sizeof(struct atkbdc_device), M_ATKBDDEV, M_NOWAIT);
- if (!kdev)
- return;
- bzero(kdev, sizeof *kdev);
-
- kdev->port = sc->port;
-
- if (resource_int_value(name, unit, "irq", &t) == 0)
- kdev->irq = t;
- else
- kdev->irq = -1;
-
- if (resource_int_value(name, unit, "flags", &t) == 0)
- kdev->flags = t;
- else
- kdev->flags = 0;
-
- child = device_add_child(dev, name, unit);
- device_set_ivars(child, kdev);
-}
-
-static int
-atkbdc_attach(device_t dev)
-{
- atkbdc_softc_t *sc;
- struct resource *port;
- int unit;
- int error;
- int rid;
- int i;
-
- unit = device_get_unit(dev);
- sc = *(atkbdc_softc_t **)device_get_softc(dev);
- if (sc == NULL) {
- /*
- * We have to maintain two copies of the kbdc_softc struct,
- * as the low-level console needs to have access to the
- * keyboard controller before kbdc is probed and attached.
- * kbdc_soft[] contains the default entry for that purpose.
- * See atkbdc.c. XXX
- */
- sc = atkbdc_get_softc(unit);
- if (sc == NULL)
- return ENOMEM;
- }
-
- /* XXX should track resource in softc */
- rid = 0;
- port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
- 0, ~0, IO_KBDSIZE, RF_ACTIVE);
- if (!port)
- return ENXIO;
- error = atkbdc_attach_unit(unit, sc, rman_get_start(port));
- if (error)
- return error;
- *(atkbdc_softc_t **)device_get_softc(dev) = sc;
-
- /*
- * Add all devices configured to be attached to atkbdc0.
- */
- for (i = resource_query_string(-1, "at", "atkbdc0");
- i != -1;
- i = resource_query_string(i, "at", "atkbdc0")) {
- atkbdc_add_device(dev, resource_query_name(i),
- resource_query_unit(i));
- }
-
- /*
- * and atkbdc?
- */
- for (i = resource_query_string(-1, "at", "atkbdc");
- i != -1;
- i = resource_query_string(i, "at", "atkbdc")) {
- atkbdc_add_device(dev, resource_query_name(i),
- resource_query_unit(i));
- }
-
- bus_generic_attach(dev);
-
- return 0;
-}
-
-static int
-atkbdc_print_child(device_t bus, device_t dev)
-{
- atkbdc_device_t *kbdcdev;
- int retval = 0;
-
- kbdcdev = (atkbdc_device_t *)device_get_ivars(dev);
-
- retval += bus_print_child_header(bus, dev);
- if (kbdcdev->flags != 0)
- retval += printf(" flags 0x%x", kbdcdev->flags);
- if (kbdcdev->irq != -1)
- retval += printf(" irq %d", kbdcdev->irq);
- retval += bus_print_child_footer(bus, dev);
-
- return (retval);
-}
-
-static int
-atkbdc_read_ivar(device_t bus, device_t dev, int index, u_long *val)
-{
- atkbdc_device_t *ivar;
-
- ivar = (atkbdc_device_t *)device_get_ivars(dev);
- switch (index) {
- case KBDC_IVAR_PORT:
- *val = (u_long)ivar->port;
- break;
- case KBDC_IVAR_IRQ:
- *val = (u_long)ivar->irq;
- break;
- case KBDC_IVAR_FLAGS:
- *val = (u_long)ivar->flags;
- break;
- default:
- return ENOENT;
- }
- return 0;
-}
-
-static int
-atkbdc_write_ivar(device_t bus, device_t dev, int index, u_long val)
-{
- atkbdc_device_t *ivar;
-
- ivar = (atkbdc_device_t *)device_get_ivars(dev);
- switch (index) {
- case KBDC_IVAR_PORT:
- ivar->port = (int)val;
- break;
- case KBDC_IVAR_IRQ:
- ivar->irq = (int)val;
- break;
- case KBDC_IVAR_FLAGS:
- ivar->flags = (int)val;
- break;
- default:
- return ENOENT;
- }
- return 0;
-}
-
-DRIVER_MODULE(atkbdc, isa, atkbdc_driver, atkbdc_devclass, 0, 0);
diff --git a/sys/dev/atkbdc/atkbdc_subr.c b/sys/dev/atkbdc/atkbdc_subr.c
deleted file mode 100644
index 9549c99d5d4d..000000000000
--- a/sys/dev/atkbdc/atkbdc_subr.c
+++ /dev/null
@@ -1,267 +0,0 @@
-/*-
- * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
- * 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 as
- * the first lines of this file unmodified.
- * 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 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.
- *
- * $FreeBSD$
- */
-
-#include "opt_kbd.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/bus.h>
-#include <sys/malloc.h>
-#include <machine/bus.h>
-#include <machine/resource.h>
-#include <sys/rman.h>
-
-#include <dev/kbd/atkbdcreg.h>
-
-#include <isa/isareg.h>
-#include <isa/isavar.h>
-
-MALLOC_DEFINE(M_ATKBDDEV, "atkbddev", "AT Keyboard device");
-
-/* children */
-typedef struct atkbdc_device {
- int flags; /* configuration flags */
- int port; /* port number (same as the controller's) */
- int irq; /* ISA IRQ mask */
-} atkbdc_device_t;
-
-/* kbdc */
-devclass_t atkbdc_devclass;
-
-static int atkbdc_probe(device_t dev);
-static int atkbdc_attach(device_t dev);
-static int atkbdc_print_child(device_t bus, device_t dev);
-static int atkbdc_read_ivar(device_t bus, device_t dev, int index,
- u_long *val);
-static int atkbdc_write_ivar(device_t bus, device_t dev, int index,
- u_long val);
-
-static device_method_t atkbdc_methods[] = {
- DEVMETHOD(device_probe, atkbdc_probe),
- DEVMETHOD(device_attach, atkbdc_attach),
- DEVMETHOD(device_suspend, bus_generic_suspend),
- DEVMETHOD(device_resume, bus_generic_resume),
-
- DEVMETHOD(bus_print_child, atkbdc_print_child),
- DEVMETHOD(bus_read_ivar, atkbdc_read_ivar),
- DEVMETHOD(bus_write_ivar, atkbdc_write_ivar),
- DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
- DEVMETHOD(bus_release_resource, bus_generic_release_resource),
- DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
- DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
- DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
- DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
-
- { 0, 0 }
-};
-
-static driver_t atkbdc_driver = {
- ATKBDC_DRIVER_NAME,
- atkbdc_methods,
- sizeof(atkbdc_softc_t *),
-};
-
-static int
-atkbdc_probe(device_t dev)
-{
- int error;
- int rid;
- struct resource *port;
-
- /* Check isapnp ids */
- if (isa_get_vendorid(dev))
- return (ENXIO);
-
- device_set_desc(dev, "keyboard controller (i8042)");
- rid = 0;
- port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
- 0, ~0, IO_KBDSIZE, RF_ACTIVE);
- if (!port)
- return ENXIO;
- error = atkbdc_probe_unit(device_get_unit(dev), rman_get_start(port));
- bus_release_resource(dev, SYS_RES_IOPORT, rid, port);
- return error;
-}
-
-static void
-atkbdc_add_device(device_t dev, const char *name, int unit)
-{
- atkbdc_softc_t *sc = *(atkbdc_softc_t **)device_get_softc(dev);
- atkbdc_device_t *kdev;
- device_t child;
- int t;
-
- if (resource_int_value(name, unit, "disabled", &t) == 0 && t != 0)
- return;
-
- kdev = malloc(sizeof(struct atkbdc_device), M_ATKBDDEV, M_NOWAIT);
- if (!kdev)
- return;
- bzero(kdev, sizeof *kdev);
-
- kdev->port = sc->port;
-
- if (resource_int_value(name, unit, "irq", &t) == 0)
- kdev->irq = t;
- else
- kdev->irq = -1;
-
- if (resource_int_value(name, unit, "flags", &t) == 0)
- kdev->flags = t;
- else
- kdev->flags = 0;
-
- child = device_add_child(dev, name, unit);
- device_set_ivars(child, kdev);
-}
-
-static int
-atkbdc_attach(device_t dev)
-{
- atkbdc_softc_t *sc;
- struct resource *port;
- int unit;
- int error;
- int rid;
- int i;
-
- unit = device_get_unit(dev);
- sc = *(atkbdc_softc_t **)device_get_softc(dev);
- if (sc == NULL) {
- /*
- * We have to maintain two copies of the kbdc_softc struct,
- * as the low-level console needs to have access to the
- * keyboard controller before kbdc is probed and attached.
- * kbdc_soft[] contains the default entry for that purpose.
- * See atkbdc.c. XXX
- */
- sc = atkbdc_get_softc(unit);
- if (sc == NULL)
- return ENOMEM;
- }
-
- /* XXX should track resource in softc */
- rid = 0;
- port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
- 0, ~0, IO_KBDSIZE, RF_ACTIVE);
- if (!port)
- return ENXIO;
- error = atkbdc_attach_unit(unit, sc, rman_get_start(port));
- if (error)
- return error;
- *(atkbdc_softc_t **)device_get_softc(dev) = sc;
-
- /*
- * Add all devices configured to be attached to atkbdc0.
- */
- for (i = resource_query_string(-1, "at", "atkbdc0");
- i != -1;
- i = resource_query_string(i, "at", "atkbdc0")) {
- atkbdc_add_device(dev, resource_query_name(i),
- resource_query_unit(i));
- }
-
- /*
- * and atkbdc?
- */
- for (i = resource_query_string(-1, "at", "atkbdc");
- i != -1;
- i = resource_query_string(i, "at", "atkbdc")) {
- atkbdc_add_device(dev, resource_query_name(i),
- resource_query_unit(i));
- }
-
- bus_generic_attach(dev);
-
- return 0;
-}
-
-static int
-atkbdc_print_child(device_t bus, device_t dev)
-{
- atkbdc_device_t *kbdcdev;
- int retval = 0;
-
- kbdcdev = (atkbdc_device_t *)device_get_ivars(dev);
-
- retval += bus_print_child_header(bus, dev);
- if (kbdcdev->flags != 0)
- retval += printf(" flags 0x%x", kbdcdev->flags);
- if (kbdcdev->irq != -1)
- retval += printf(" irq %d", kbdcdev->irq);
- retval += bus_print_child_footer(bus, dev);
-
- return (retval);
-}
-
-static int
-atkbdc_read_ivar(device_t bus, device_t dev, int index, u_long *val)
-{
- atkbdc_device_t *ivar;
-
- ivar = (atkbdc_device_t *)device_get_ivars(dev);
- switch (index) {
- case KBDC_IVAR_PORT:
- *val = (u_long)ivar->port;
- break;
- case KBDC_IVAR_IRQ:
- *val = (u_long)ivar->irq;
- break;
- case KBDC_IVAR_FLAGS:
- *val = (u_long)ivar->flags;
- break;
- default:
- return ENOENT;
- }
- return 0;
-}
-
-static int
-atkbdc_write_ivar(device_t bus, device_t dev, int index, u_long val)
-{
- atkbdc_device_t *ivar;
-
- ivar = (atkbdc_device_t *)device_get_ivars(dev);
- switch (index) {
- case KBDC_IVAR_PORT:
- ivar->port = (int)val;
- break;
- case KBDC_IVAR_IRQ:
- ivar->irq = (int)val;
- break;
- case KBDC_IVAR_FLAGS:
- ivar->flags = (int)val;
- break;
- default:
- return ENOENT;
- }
- return 0;
-}
-
-DRIVER_MODULE(atkbdc, isa, atkbdc_driver, atkbdc_devclass, 0, 0);
diff --git a/sys/dev/atkbdc/atkbdcreg.h b/sys/dev/atkbdc/atkbdcreg.h
deleted file mode 100644
index d01489ee84b8..000000000000
--- a/sys/dev/atkbdc/atkbdcreg.h
+++ /dev/null
@@ -1,247 +0,0 @@
-/*-
- * Copyright (c) 1996-1999
- * Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- * from kbdio.h,v 1.8 1998/09/25 11:55:46 yokota Exp
- */
-
-#ifndef _DEV_KBD_ATKBDCREG_H_
-#define _DEV_KBD_ATKBDCREG_H_
-
-/* constants */
-
-/* I/O ports */
-#define KBD_STATUS_PORT 4 /* status port, read */
-#define KBD_COMMAND_PORT 4 /* controller command port, write */
-#define KBD_DATA_PORT 0 /* data port, read/write
- * also used as keyboard command
- * and mouse command port
- */
-
-/* controller commands (sent to KBD_COMMAND_PORT) */
-#define KBDC_SET_COMMAND_BYTE 0x0060
-#define KBDC_GET_COMMAND_BYTE 0x0020
-#define KBDC_WRITE_TO_AUX 0x00d4
-#define KBDC_DISABLE_AUX_PORT 0x00a7
-#define KBDC_ENABLE_AUX_PORT 0x00a8
-#define KBDC_TEST_AUX_PORT 0x00a9
-#define KBDC_DIAGNOSE 0x00aa
-#define KBDC_TEST_KBD_PORT 0x00ab
-#define KBDC_DISABLE_KBD_PORT 0x00ad
-#define KBDC_ENABLE_KBD_PORT 0x00ae
-
-/* controller command byte (set by KBDC_SET_COMMAND_BYTE) */
-#define KBD_TRANSLATION 0x0040
-#define KBD_RESERVED_BITS 0x0004
-#define KBD_OVERRIDE_KBD_LOCK 0x0008
-#define KBD_ENABLE_KBD_PORT 0x0000
-#define KBD_DISABLE_KBD_PORT 0x0010
-#define KBD_ENABLE_AUX_PORT 0x0000
-#define KBD_DISABLE_AUX_PORT 0x0020
-#define KBD_ENABLE_AUX_INT 0x0002
-#define KBD_DISABLE_AUX_INT 0x0000
-#define KBD_ENABLE_KBD_INT 0x0001
-#define KBD_DISABLE_KBD_INT 0x0000
-#define KBD_KBD_CONTROL_BITS (KBD_DISABLE_KBD_PORT | KBD_ENABLE_KBD_INT)
-#define KBD_AUX_CONTROL_BITS (KBD_DISABLE_AUX_PORT | KBD_ENABLE_AUX_INT)
-
-/* keyboard device commands (sent to KBD_DATA_PORT) */
-#define KBDC_RESET_KBD 0x00ff
-#define KBDC_ENABLE_KBD 0x00f4
-#define KBDC_DISABLE_KBD 0x00f5
-#define KBDC_SET_DEFAULTS 0x00f6
-#define KBDC_SEND_DEV_ID 0x00f2
-#define KBDC_SET_LEDS 0x00ed
-#define KBDC_ECHO 0x00ee
-#define KBDC_SET_SCANCODE_SET 0x00f0
-#define KBDC_SET_TYPEMATIC 0x00f3
-
-/* aux device commands (sent to KBD_DATA_PORT) */
-#define PSMC_RESET_DEV 0x00ff
-#define PSMC_ENABLE_DEV 0x00f4
-#define PSMC_DISABLE_DEV 0x00f5
-#define PSMC_SET_DEFAULTS 0x00f6
-#define PSMC_SEND_DEV_ID 0x00f2
-#define PSMC_SEND_DEV_STATUS 0x00e9
-#define PSMC_SEND_DEV_DATA 0x00eb
-#define PSMC_SET_SCALING11 0x00e6
-#define PSMC_SET_SCALING21 0x00e7
-#define PSMC_SET_RESOLUTION 0x00e8
-#define PSMC_SET_STREAM_MODE 0x00ea
-#define PSMC_SET_REMOTE_MODE 0x00f0
-#define PSMC_SET_SAMPLING_RATE 0x00f3
-
-/* PSMC_SET_RESOLUTION argument */
-#define PSMD_RES_LOW 0 /* typically 25ppi */
-#define PSMD_RES_MEDIUM_LOW 1 /* typically 50ppi */
-#define PSMD_RES_MEDIUM_HIGH 2 /* typically 100ppi (default) */
-#define PSMD_RES_HIGH 3 /* typically 200ppi */
-#define PSMD_MAX_RESOLUTION PSMD_RES_HIGH
-
-/* PSMC_SET_SAMPLING_RATE */
-#define PSMD_MAX_RATE 255 /* FIXME: not sure if it's possible */
-
-/* status bits (KBD_STATUS_PORT) */
-#define KBDS_BUFFER_FULL 0x0021
-#define KBDS_ANY_BUFFER_FULL 0x0001
-#define KBDS_KBD_BUFFER_FULL 0x0001
-#define KBDS_AUX_BUFFER_FULL 0x0021
-#define KBDS_INPUT_BUFFER_FULL 0x0002
-
-/* return code */
-#define KBD_ACK 0x00fa
-#define KBD_RESEND 0x00fe
-#define KBD_RESET_DONE 0x00aa
-#define KBD_RESET_FAIL 0x00fc
-#define KBD_DIAG_DONE 0x0055
-#define KBD_DIAG_FAIL 0x00fd
-#define KBD_ECHO 0x00ee
-
-#define PSM_ACK 0x00fa
-#define PSM_RESEND 0x00fe
-#define PSM_RESET_DONE 0x00aa
-#define PSM_RESET_FAIL 0x00fc
-
-/* aux device ID */
-#define PSM_MOUSE_ID 0
-#define PSM_BALLPOINT_ID 2
-#define PSM_INTELLI_ID 3
-
-#ifdef _KERNEL
-
-#define ATKBDC_DRIVER_NAME "atkbdc"
-
-/*
- * driver specific options: the following options may be set by
- * `options' statements in the kernel configuration file.
- */
-
-/* retry count */
-#ifndef KBD_MAXRETRY
-#define KBD_MAXRETRY 3
-#endif
-
-/* timing parameters */
-#ifndef KBD_RESETDELAY
-#define KBD_RESETDELAY 200 /* wait 200msec after kbd/mouse reset */
-#endif
-#ifndef KBD_MAXWAIT
-#define KBD_MAXWAIT 5 /* wait 5 times at most after reset */
-#endif
-
-/* I/O recovery time */
-#define KBDC_DELAYTIME 20
-#define KBDD_DELAYTIME 7
-
-/* debug option */
-#ifndef KBDIO_DEBUG
-#define KBDIO_DEBUG 0
-#endif
-
-/* end of driver specific options */
-
-/* types/structures */
-
-#define KBDQ_BUFSIZE 32
-
-typedef struct _kqueue {
- int head;
- int tail;
- unsigned char q[KBDQ_BUFSIZE];
-#if KBDIO_DEBUG >= 2
- int call_count;
- int qcount;
- int max_qcount;
-#endif
-} kqueue;
-
-typedef struct atkbdc_softc {
- int port; /* base port address */
- int command_byte; /* current command byte value */
- int command_mask; /* command byte mask bits for kbd/aux devices */
- int lock; /* FIXME: XXX not quite a semaphore... */
- kqueue kbd; /* keyboard data queue */
- kqueue aux; /* auxiliary data queue */
-} atkbdc_softc_t;
-
-enum kbdc_device_ivar {
- KBDC_IVAR_PORT,
- KBDC_IVAR_IRQ,
- KBDC_IVAR_FLAGS,
-};
-
-typedef caddr_t KBDC;
-
-/* function prototypes */
-
-atkbdc_softc_t *atkbdc_get_softc(int unit);
-int atkbdc_probe_unit(int unit, int port);
-int atkbdc_attach_unit(int unit, atkbdc_softc_t *sc, int port);
-int atkbdc_configure(void);
-
-KBDC kbdc_open(int port);
-int kbdc_lock(KBDC kbdc, int lock);
-int kbdc_data_ready(KBDC kbdc);
-
-int write_controller_command(KBDC kbdc,int c);
-int write_controller_data(KBDC kbdc,int c);
-
-int write_kbd_command(KBDC kbdc,int c);
-int write_aux_command(KBDC kbdc,int c);
-int send_kbd_command(KBDC kbdc,int c);
-int send_aux_command(KBDC kbdc,int c);
-int send_kbd_command_and_data(KBDC kbdc,int c,int d);
-int send_aux_command_and_data(KBDC kbdc,int c,int d);
-
-int read_controller_data(KBDC kbdc);
-int read_kbd_data(KBDC kbdc);
-int read_kbd_data_no_wait(KBDC kbdc);
-int read_aux_data(KBDC kbdc);
-int read_aux_data_no_wait(KBDC kbdc);
-
-void empty_kbd_buffer(KBDC kbdc, int t);
-void empty_aux_buffer(KBDC kbdc, int t);
-void empty_both_buffers(KBDC kbdc, int t);
-
-int reset_kbd(KBDC kbdc);
-int reset_aux_dev(KBDC kbdc);
-
-int test_controller(KBDC kbdc);
-int test_kbd_port(KBDC kbdc);
-int test_aux_port(KBDC kbdc);
-
-int kbdc_get_device_mask(KBDC kbdc);
-void kbdc_set_device_mask(KBDC kbdc, int mask);
-
-int get_controller_command_byte(KBDC kbdc);
-int set_controller_command_byte(KBDC kbdc, int command, int flag);
-
-#endif /* _KERNEL */
-
-#endif /* !_DEV_KBD_ATKBDCREG_H_ */
diff --git a/sys/dev/atkbdc/atkbdreg.h b/sys/dev/atkbdc/atkbdreg.h
deleted file mode 100644
index 46405c6be2a5..000000000000
--- a/sys/dev/atkbdc/atkbdreg.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*-
- * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
- * 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 as
- * the first lines of this file unmodified.
- * 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 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _DEV_KBD_ATKBDREG_H_
-#define _DEV_KBD_ATKBDREG_H_
-
-#define ATKBD_DRIVER_NAME "atkbd"
-
-/* device configuration flags (atkbdprobe, atkbdattach) */
-#define KB_CONF_FAIL_IF_NO_KBD (1 << 0) /* don't install if no kbd is found */
-#define KB_CONF_NO_RESET (1 << 1) /* don't reset the keyboard */
-#define KB_CONF_ALT_SCANCODESET (1 << 2) /* assume the XT type keyboard */
-
-#ifdef _KERNEL
-
-int atkbd_probe_unit(int unit, int port, int irq, int flags);
-int atkbd_attach_unit(int unit, keyboard_t **kbd,
- int port, int irq, int flags);
-
-#endif
-
-#endif /* !_DEV_KBD_ATKBDREG_H_ */
diff --git a/sys/dev/atkbdc/psm.c b/sys/dev/atkbdc/psm.c
deleted file mode 100644
index e702d0492d69..000000000000
--- a/sys/dev/atkbdc/psm.c
+++ /dev/null
@@ -1,2444 +0,0 @@
-/*-
- * Copyright (c) 1992, 1993 Erik Forsberg.
- * Copyright (c) 1996, 1997 Kazutaka YOKOTA.
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY ``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 I 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Ported to 386bsd Oct 17, 1992
- * Sandi Donno, Computer Science, University of Cape Town, South Africa
- * Please send bug reports to sandi@cs.uct.ac.za
- *
- * Thanks are also due to Rick Macklem, rick@snowhite.cis.uoguelph.ca -
- * although I was only partially successful in getting the alpha release
- * of his "driver for the Logitech and ATI Inport Bus mice for use with
- * 386bsd and the X386 port" to work with my Microsoft mouse, I nevertheless
- * found his code to be an invaluable reference when porting this driver
- * to 386bsd.
- *
- * Further modifications for latest 386BSD+patchkit and port to NetBSD,
- * Andrew Herbert <andrew@werple.apana.org.au> - 8 June 1993
- *
- * Cloned from the Microsoft Bus Mouse driver, also by Erik Forsberg, by
- * Andrew Herbert - 12 June 1993
- *
- * Modified for PS/2 mouse by Charles Hannum <mycroft@ai.mit.edu>
- * - 13 June 1993
- *
- * Modified for PS/2 AUX mouse by Shoji Yuen <yuen@nuie.nagoya-u.ac.jp>
- * - 24 October 1993
- *
- * Hardware access routines and probe logic rewritten by
- * Kazutaka Yokota <yokota@zodiac.mech.utsunomiya-u.ac.jp>
- * - 3, 14, 22 October 1996.
- * - 12 November 1996. IOCTLs and rearranging `psmread', `psmioctl'...
- * - 14, 30 November 1996. Uses `kbdio.c'.
- * - 13 December 1996. Uses queuing version of `kbdio.c'.
- * - January/February 1997. Tweaked probe logic for
- * HiNote UltraII/Latitude/Armada laptops.
- * - 30 July 1997. Added APM support.
- * - 5 March 1997. Defined driver configuration flags (PSM_CONFIG_XXX).
- * Improved sync check logic.
- * Vendor specific support routines.
- */
-
-#include "opt_psm.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/bus.h>
-#include <sys/conf.h>
-#include <sys/poll.h>
-#include <sys/syslog.h>
-#include <sys/malloc.h>
-#include <machine/bus.h>
-#include <sys/rman.h>
-#include <sys/select.h>
-#include <sys/uio.h>
-
-#include <machine/clock.h>
-#include <machine/limits.h>
-#include <machine/mouse.h>
-#include <machine/resource.h>
-
-#include <isa/isavar.h>
-#include <dev/kbd/atkbdcreg.h>
-
-/*
- * Driver specific options: the following options may be set by
- * `options' statements in the kernel configuration file.
- */
-
-/* debugging */
-#ifndef PSM_DEBUG
-#define PSM_DEBUG 0 /* logging: 0: none, 1: brief, 2: verbose */
-#endif
-
-/* features */
-
-/* #define PSM_HOOKRESUME hook the system resume event */
-/* #define PSM_RESETAFTERSUSPEND reset the device at the resume event */
-
-#ifdef PSM_HOOKAPM
-#undef PSM_HOOKRESUME
-#define PSM_HOOKRESUME 1
-#endif /* PSM_HOOKAPM */
-
-#ifndef PSM_HOOKRESUME
-#undef PSM_RESETAFTERSUSPEND
-#endif /* PSM_HOOKRESUME */
-
-/* end of driver specific options */
-
-/* input queue */
-#define PSM_BUFSIZE 960
-#define PSM_SMALLBUFSIZE 240
-
-/* operation levels */
-#define PSM_LEVEL_BASE 0
-#define PSM_LEVEL_STANDARD 1
-#define PSM_LEVEL_NATIVE 2
-#define PSM_LEVEL_MIN PSM_LEVEL_BASE
-#define PSM_LEVEL_MAX PSM_LEVEL_NATIVE
-
-/* Logitech PS2++ protocol */
-#define MOUSE_PS2PLUS_CHECKBITS(b) \
- ((((b[2] & 0x03) << 2) | 0x02) == (b[1] & 0x0f))
-#define MOUSE_PS2PLUS_PACKET_TYPE(b) \
- (((b[0] & 0x30) >> 2) | ((b[1] & 0x30) >> 4))
-
-/* some macros */
-#define PSM_UNIT(dev) (minor(dev) >> 1)
-#define PSM_NBLOCKIO(dev) (minor(dev) & 1)
-#define PSM_MKMINOR(unit,block) (((unit) << 1) | ((block) ? 0:1))
-
-#ifndef max
-#define max(x,y) ((x) > (y) ? (x) : (y))
-#endif
-#ifndef min
-#define min(x,y) ((x) < (y) ? (x) : (y))
-#endif
-
-#define abs(x) (((x) < 0) ? -(x) : (x))
-
-/* ring buffer */
-typedef struct ringbuf {
- int count; /* # of valid elements in the buffer */
- int head; /* head pointer */
- int tail; /* tail poiner */
- unsigned char buf[PSM_BUFSIZE];
-} ringbuf_t;
-
-/* driver control block */
-struct psm_softc { /* Driver status information */
- struct selinfo rsel; /* Process selecting for Input */
- unsigned char state; /* Mouse driver state */
- int config; /* driver configuration flags */
- int flags; /* other flags */
- KBDC kbdc; /* handle to access the keyboard controller */
- int addr; /* I/O port address */
- mousehw_t hw; /* hardware information */
- mousemode_t mode; /* operation mode */
- mousemode_t dflt_mode; /* default operation mode */
- mousestatus_t status; /* accumulated mouse movement */
- ringbuf_t queue; /* mouse status queue */
- unsigned char ipacket[16]; /* interim input buffer */
- int inputbytes; /* # of bytes in the input buffer */
- int button; /* the latest button state */
- int xold; /* previous absolute X position */
- int yold; /* previous absolute Y position */
-};
-devclass_t psm_devclass;
-#define PSM_SOFTC(unit) ((struct psm_softc*)devclass_get_softc(psm_devclass, unit))
-
-/* driver state flags (state) */
-#define PSM_VALID 0x80
-#define PSM_OPEN 1 /* Device is open */
-#define PSM_ASLP 2 /* Waiting for mouse data */
-
-/* driver configuration flags (config) */
-#define PSM_CONFIG_RESOLUTION 0x000f /* resolution */
-#define PSM_CONFIG_ACCEL 0x00f0 /* acceleration factor */
-#define PSM_CONFIG_NOCHECKSYNC 0x0100 /* disable sync. test */
-#define PSM_CONFIG_NOIDPROBE 0x0200 /* disable mouse model probe */
-#define PSM_CONFIG_NORESET 0x0400 /* don't reset the mouse */
-#define PSM_CONFIG_FORCETAP 0x0800 /* assume `tap' action exists */
-#define PSM_CONFIG_IGNPORTERROR 0x1000 /* ignore error in aux port test */
-
-#define PSM_CONFIG_FLAGS (PSM_CONFIG_RESOLUTION \
- | PSM_CONFIG_ACCEL \
- | PSM_CONFIG_NOCHECKSYNC \
- | PSM_CONFIG_NOIDPROBE \
- | PSM_CONFIG_NORESET \
- | PSM_CONFIG_FORCETAP \
- | PSM_CONFIG_IGNPORTERROR)
-
-/* other flags (flags) */
-#define PSM_FLAGS_FINGERDOWN 0x0001 /* VersaPad finger down */
-
-/* for backward compatibility */
-#define OLD_MOUSE_GETHWINFO _IOR('M', 1, old_mousehw_t)
-#define OLD_MOUSE_GETMODE _IOR('M', 2, old_mousemode_t)
-#define OLD_MOUSE_SETMODE _IOW('M', 3, old_mousemode_t)
-
-typedef struct old_mousehw {
- int buttons;
- int iftype;
- int type;
- int hwid;
-} old_mousehw_t;
-
-typedef struct old_mousemode {
- int protocol;
- int rate;
- int resolution;
- int accelfactor;
-} old_mousemode_t;
-
-/* packet formatting function */
-typedef int packetfunc_t __P((struct psm_softc *, unsigned char *,
- int *, int, mousestatus_t *));
-
-/* function prototypes */
-static int psmprobe __P((device_t));
-static int psmattach __P((device_t));
-static int psmresume __P((device_t));
-
-static d_open_t psmopen;
-static d_close_t psmclose;
-static d_read_t psmread;
-static d_ioctl_t psmioctl;
-static d_poll_t psmpoll;
-
-static int enable_aux_dev __P((KBDC));
-static int disable_aux_dev __P((KBDC));
-static int get_mouse_status __P((KBDC, int *, int, int));
-static int get_aux_id __P((KBDC));
-static int set_mouse_sampling_rate __P((KBDC, int));
-static int set_mouse_scaling __P((KBDC, int));
-static int set_mouse_resolution __P((KBDC, int));
-#ifdef PSM_RESETAFTERSUSPEND
-static int set_mouse_mode __P((KBDC));
-#endif /* PSM_RESETAFTERSUSPEND */
-static int get_mouse_buttons __P((KBDC));
-static int is_a_mouse __P((int));
-static void recover_from_error __P((KBDC));
-static int restore_controller __P((KBDC, int));
-#ifdef PSM_RESETAFTERSUSPEND
-static int reinitialize __P((int, mousemode_t *));
-#endif
-static int doopen __P((int, int));
-static char *model_name(int);
-static void psmintr(void*);
-
-/* vendor specific features */
-typedef int probefunc_t __P((struct psm_softc *));
-
-static int mouse_id_proc1 __P((KBDC, int, int, int *));
-static probefunc_t enable_groller;
-static probefunc_t enable_gmouse;
-static probefunc_t enable_aglide;
-static probefunc_t enable_kmouse;
-static probefunc_t enable_msintelli;
-static probefunc_t enable_mmanplus;
-static probefunc_t enable_versapad;
-static int tame_mouse __P((struct psm_softc *, mousestatus_t *, unsigned char *));
-
-static struct {
- int model;
- unsigned char syncmask;
- int packetsize;
- probefunc_t *probefunc;
-} vendortype[] = {
- { MOUSE_MODEL_NET, /* Genius NetMouse */
- 0xc8, MOUSE_INTELLI_PACKETSIZE, enable_gmouse, },
- { MOUSE_MODEL_NETSCROLL, /* Genius NetScroll */
- 0xc8, 6, enable_groller, },
- { MOUSE_MODEL_GLIDEPOINT, /* ALPS GlidePoint */
- 0xc0, MOUSE_PS2_PACKETSIZE, enable_aglide, },
- { MOUSE_MODEL_MOUSEMANPLUS, /* Logitech MouseMan+ */
- 0x08, MOUSE_PS2_PACKETSIZE, enable_mmanplus, },
- { MOUSE_MODEL_THINK, /* Kensignton ThinkingMouse */
- 0x80, MOUSE_PS2_PACKETSIZE, enable_kmouse, },
- { MOUSE_MODEL_INTELLI, /* Microsoft IntelliMouse */
- 0xc8, MOUSE_INTELLI_PACKETSIZE, enable_msintelli, },
- { MOUSE_MODEL_VERSAPAD, /* Interlink electronics VersaPad */
- 0xe8, MOUSE_PS2VERSA_PACKETSIZE, enable_versapad, },
- { MOUSE_MODEL_GENERIC,
- 0xc0, MOUSE_PS2_PACKETSIZE, NULL, },
-};
-#define GENERIC_MOUSE_ENTRY 7
-
-/* device driver declarateion */
-static device_method_t psm_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, psmprobe),
- DEVMETHOD(device_attach, psmattach),
- DEVMETHOD(device_resume, psmresume),
-
- { 0, 0 }
-};
-
-static driver_t psm_driver = {
- "psm",
- psm_methods,
- sizeof(struct psm_softc),
-};
-
-#define CDEV_MAJOR 21
-
-static struct cdevsw psm_cdevsw = {
- /* open */ psmopen,
- /* close */ psmclose,
- /* read */ psmread,
- /* write */ nowrite,
- /* ioctl */ psmioctl,
- /* poll */ psmpoll,
- /* mmap */ nommap,
- /* strategy */ nostrategy,
- /* name */ "psm",
- /* maj */ CDEV_MAJOR,
- /* dump */ nodump,
- /* psize */ nopsize,
- /* flags */ 0,
- /* bmaj */ -1
-};
-
-/* debug message level */
-static int verbose = PSM_DEBUG;
-
-/* device I/O routines */
-static int
-enable_aux_dev(KBDC kbdc)
-{
- int res;
-
- res = send_aux_command(kbdc, PSMC_ENABLE_DEV);
- if (verbose >= 2)
- log(LOG_DEBUG, "psm: ENABLE_DEV return code:%04x\n", res);
-
- return (res == PSM_ACK);
-}
-
-static int
-disable_aux_dev(KBDC kbdc)
-{
- int res;
-
- res = send_aux_command(kbdc, PSMC_DISABLE_DEV);
- if (verbose >= 2)
- log(LOG_DEBUG, "psm: DISABLE_DEV return code:%04x\n", res);
-
- return (res == PSM_ACK);
-}
-
-static int
-get_mouse_status(KBDC kbdc, int *status, int flag, int len)
-{
- int cmd;
- int res;
- int i;
-
- switch (flag) {
- case 0:
- default:
- cmd = PSMC_SEND_DEV_STATUS;
- break;
- case 1:
- cmd = PSMC_SEND_DEV_DATA;
- break;
- }
- empty_aux_buffer(kbdc, 5);
- res = send_aux_command(kbdc, cmd);
- if (verbose >= 2)
- log(LOG_DEBUG, "psm: SEND_AUX_DEV_%s return code:%04x\n",
- (flag == 1) ? "DATA" : "STATUS", res);
- if (res != PSM_ACK)
- return 0;
-
- for (i = 0; i < len; ++i) {
- status[i] = read_aux_data(kbdc);
- if (status[i] < 0)
- break;
- }
-
- if (verbose) {
- log(LOG_DEBUG, "psm: %s %02x %02x %02x\n",
- (flag == 1) ? "data" : "status", status[0], status[1], status[2]);
- }
-
- return i;
-}
-
-static int
-get_aux_id(KBDC kbdc)
-{
- int res;
- int id;
-
- empty_aux_buffer(kbdc, 5);
- res = send_aux_command(kbdc, PSMC_SEND_DEV_ID);
- if (verbose >= 2)
- log(LOG_DEBUG, "psm: SEND_DEV_ID return code:%04x\n", res);
- if (res != PSM_ACK)
- return (-1);
-
- /* 10ms delay */
- DELAY(10000);
-
- id = read_aux_data(kbdc);
- if (verbose >= 2)
- log(LOG_DEBUG, "psm: device ID: %04x\n", id);
-
- return id;
-}
-
-static int
-set_mouse_sampling_rate(KBDC kbdc, int rate)
-{
- int res;
-
- res = send_aux_command_and_data(kbdc, PSMC_SET_SAMPLING_RATE, rate);
- if (verbose >= 2)
- log(LOG_DEBUG, "psm: SET_SAMPLING_RATE (%d) %04x\n", rate, res);
-
- return ((res == PSM_ACK) ? rate : -1);
-}
-
-static int
-set_mouse_scaling(KBDC kbdc, int scale)
-{
- int res;
-
- switch (scale) {
- case 1:
- default:
- scale = PSMC_SET_SCALING11;
- break;
- case 2:
- scale = PSMC_SET_SCALING21;
- break;
- }
- res = send_aux_command(kbdc, scale);
- if (verbose >= 2)
- log(LOG_DEBUG, "psm: SET_SCALING%s return code:%04x\n",
- (scale == PSMC_SET_SCALING21) ? "21" : "11", res);
-
- return (res == PSM_ACK);
-}
-
-/* `val' must be 0 through PSMD_MAX_RESOLUTION */
-static int
-set_mouse_resolution(KBDC kbdc, int val)
-{
- int res;
-
- res = send_aux_command_and_data(kbdc, PSMC_SET_RESOLUTION, val);
- if (verbose >= 2)
- log(LOG_DEBUG, "psm: SET_RESOLUTION (%d) %04x\n", val, res);
-
- return ((res == PSM_ACK) ? val : -1);
-}
-
-#ifdef PSM_RESETAFTERSUSPEND
-/*
- * NOTE: once `set_mouse_mode()' is called, the mouse device must be
- * re-enabled by calling `enable_aux_dev()'
- */
-static int
-set_mouse_mode(KBDC kbdc)
-{
- int res;
-
- res = send_aux_command(kbdc, PSMC_SET_STREAM_MODE);
- if (verbose >= 2)
- log(LOG_DEBUG, "psm: SET_STREAM_MODE return code:%04x\n", res);
-
- return (res == PSM_ACK);
-}
-#endif /* PSM_RESETAFTERSUSPEND */
-
-
-static int
-get_mouse_buttons(KBDC kbdc)
-{
- int c = 2; /* assume two buttons by default */
- int status[3];
-
- /*
- * NOTE: a special sequence to obtain Logitech Mouse specific
- * information: set resolution to 25 ppi, set scaling to 1:1, set
- * scaling to 1:1, set scaling to 1:1. Then the second byte of the
- * mouse status bytes is the number of available buttons.
- * Some manufactures also support this sequence.
- */
- if (set_mouse_resolution(kbdc, PSMD_RES_LOW) != PSMD_RES_LOW)
- return c;
- if (set_mouse_scaling(kbdc, 1) && set_mouse_scaling(kbdc, 1)
- && set_mouse_scaling(kbdc, 1)
- && (get_mouse_status(kbdc, status, 0, 3) >= 3)) {
- if (status[1] != 0)
- return status[1];
- }
- return c;
-}
-
-/* misc subroutines */
-/*
- * Someday, I will get the complete list of valid pointing devices and
- * their IDs... XXX
- */
-static int
-is_a_mouse(int id)
-{
-#if 0
- static int valid_ids[] = {
- PSM_MOUSE_ID, /* mouse */
- PSM_BALLPOINT_ID, /* ballpoint device */
- PSM_INTELLI_ID, /* Intellimouse */
- -1 /* end of table */
- };
- int i;
-
- for (i = 0; valid_ids[i] >= 0; ++i)
- if (valid_ids[i] == id)
- return TRUE;
- return FALSE;
-#else
- return TRUE;
-#endif
-}
-
-static char *
-model_name(int model)
-{
- static struct {
- int model_code;
- char *model_name;
- } models[] = {
- { MOUSE_MODEL_NETSCROLL, "NetScroll Mouse" },
- { MOUSE_MODEL_NET, "NetMouse" },
- { MOUSE_MODEL_GLIDEPOINT, "GlidePoint" },
- { MOUSE_MODEL_THINK, "ThinkingMouse" },
- { MOUSE_MODEL_INTELLI, "IntelliMouse" },
- { MOUSE_MODEL_MOUSEMANPLUS, "MouseMan+" },
- { MOUSE_MODEL_VERSAPAD, "VersaPad" },
- { MOUSE_MODEL_GENERIC, "Generic PS/2 mouse" },
- { MOUSE_MODEL_UNKNOWN, NULL },
- };
- int i;
-
- for (i = 0; models[i].model_code != MOUSE_MODEL_UNKNOWN; ++i) {
- if (models[i].model_code == model)
- return models[i].model_name;
- }
- return "Unknown";
-}
-
-static void
-recover_from_error(KBDC kbdc)
-{
- /* discard anything left in the output buffer */
- empty_both_buffers(kbdc, 10);
-
-#if 0
- /*
- * NOTE: KBDC_RESET_KBD may not restore the communication between the
- * keyboard and the controller.
- */
- reset_kbd(kbdc);
-#else
- /*
- * NOTE: somehow diagnostic and keyboard port test commands bring the
- * keyboard back.
- */
- if (!test_controller(kbdc))
- log(LOG_ERR, "psm: keyboard controller failed.\n");
- /* if there isn't a keyboard in the system, the following error is OK */
- if (test_kbd_port(kbdc) != 0) {
- if (verbose)
- log(LOG_ERR, "psm: keyboard port failed.\n");
- }
-#endif
-}
-
-static int
-restore_controller(KBDC kbdc, int command_byte)
-{
- empty_both_buffers(kbdc, 10);
-
- if (!set_controller_command_byte(kbdc, 0xff, command_byte)) {
- log(LOG_ERR, "psm: failed to restore the keyboard controller "
- "command byte.\n");
- return FALSE;
- } else {
- return TRUE;
- }
-}
-
-#ifdef PSM_RESETAFTERSUSPEND
-/*
- * Re-initialize the aux port and device. The aux port must be enabled
- * and its interrupt must be disabled before calling this routine.
- * The aux device will be disabled before returning.
- * The keyboard controller must be locked via `kbdc_lock()' before
- * calling this routine.
- */
-static int
-reinitialize(int unit, mousemode_t *mode)
-{
- struct psm_softc *sc = PSM_SOFTC(unit);
- KBDC kbdc = sc->kbdc;
- int stat[3];
- int i;
-
- switch((i = test_aux_port(kbdc))) {
- case 1: /* ignore this error */
- case PSM_ACK:
- if (verbose)
- log(LOG_DEBUG, "psm%d: strange result for test aux port (%d).\n",
- unit, i);
- /* fall though */
- case 0: /* no error */
- break;
- case -1: /* time out */
- default: /* error */
- recover_from_error(kbdc);
- if (sc->config & PSM_CONFIG_IGNPORTERROR)
- break;
- log(LOG_ERR, "psm%d: the aux port is not functioning (%d).\n",
- unit, i);
- return FALSE;
- }
-
- if (sc->config & PSM_CONFIG_NORESET) {
- /*
- * Don't try to reset the pointing device. It may possibly be
- * left in the unknown state, though...
- */
- } else {
- /*
- * NOTE: some controllers appears to hang the `keyboard' when
- * the aux port doesn't exist and `PSMC_RESET_DEV' is issued.
- */
- if (!reset_aux_dev(kbdc)) {
- recover_from_error(kbdc);
- log(LOG_ERR, "psm%d: failed to reset the aux device.\n", unit);
- return FALSE;
- }
- }
-
- /*
- * both the aux port and the aux device is functioning, see
- * if the device can be enabled.
- */
- if (!enable_aux_dev(kbdc) || !disable_aux_dev(kbdc)) {
- log(LOG_ERR, "psm%d: failed to enable the aux device.\n", unit);
- return FALSE;
- }
- empty_both_buffers(kbdc, 10); /* remove stray data if any */
-
- if (sc->config & PSM_CONFIG_NOIDPROBE) {
- i = GENERIC_MOUSE_ENTRY;
- } else {
- /* FIXME: hardware ID, mouse buttons? */
-
- /* other parameters */
- for (i = 0; vendortype[i].probefunc != NULL; ++i) {
- if ((*vendortype[i].probefunc)(sc)) {
- if (verbose >= 2)
- log(LOG_ERR, "psm%d: found %s\n",
- unit, model_name(vendortype[i].model));
- break;
- }
- }
- }
-
- sc->hw.model = vendortype[i].model;
- sc->mode.packetsize = vendortype[i].packetsize;
-
- /* set mouse parameters */
- if (mode != (mousemode_t *)NULL) {
- if (mode->rate > 0)
- mode->rate = set_mouse_sampling_rate(kbdc, mode->rate);
- if (mode->resolution >= 0)
- mode->resolution = set_mouse_resolution(kbdc, mode->resolution);
- set_mouse_scaling(kbdc, 1);
- set_mouse_mode(kbdc);
- }
-
- /* request a data packet and extract sync. bits */
- if (get_mouse_status(kbdc, stat, 1, 3) < 3) {
- log(LOG_DEBUG, "psm%d: failed to get data (reinitialize).\n", unit);
- sc->mode.syncmask[0] = 0;
- } else {
- sc->mode.syncmask[1] = stat[0] & sc->mode.syncmask[0]; /* syncbits */
- /* the NetScroll Mouse will send three more bytes... Ignore them */
- empty_aux_buffer(kbdc, 5);
- }
-
- /* just check the status of the mouse */
- if (get_mouse_status(kbdc, stat, 0, 3) < 3)
- log(LOG_DEBUG, "psm%d: failed to get status (reinitialize).\n", unit);
-
- return TRUE;
-}
-#endif /* PSM_RESETAFTERSUSPEND */
-
-static int
-doopen(int unit, int command_byte)
-{
- struct psm_softc *sc = PSM_SOFTC(unit);
- int stat[3];
-
- /* enable the mouse device */
- if (!enable_aux_dev(sc->kbdc)) {
- /* MOUSE ERROR: failed to enable the mouse because:
- * 1) the mouse is faulty,
- * 2) the mouse has been removed(!?)
- * In the latter case, the keyboard may have hung, and need
- * recovery procedure...
- */
- recover_from_error(sc->kbdc);
-#if 0
- /* FIXME: we could reset the mouse here and try to enable
- * it again. But it will take long time and it's not a good
- * idea to disable the keyboard that long...
- */
- if (!reinitialize(unit, &sc->mode) || !enable_aux_dev(sc->kbdc)) {
- recover_from_error(sc->kbdc);
-#else
- {
-#endif
- restore_controller(sc->kbdc, command_byte);
- /* mark this device is no longer available */
- sc->state &= ~PSM_VALID;
- log(LOG_ERR, "psm%d: failed to enable the device (doopen).\n",
- unit);
- return (EIO);
- }
- }
-
- if (get_mouse_status(sc->kbdc, stat, 0, 3) < 3)
- log(LOG_DEBUG, "psm%d: failed to get status (doopen).\n", unit);
-
- /* enable the aux port and interrupt */
- if (!set_controller_command_byte(sc->kbdc,
- kbdc_get_device_mask(sc->kbdc),
- (command_byte & KBD_KBD_CONTROL_BITS)
- | KBD_ENABLE_AUX_PORT | KBD_ENABLE_AUX_INT)) {
- /* CONTROLLER ERROR */
- disable_aux_dev(sc->kbdc);
- restore_controller(sc->kbdc, command_byte);
- log(LOG_ERR, "psm%d: failed to enable the aux interrupt (doopen).\n",
- unit);
- return (EIO);
- }
-
- return (0);
-}
-
-/* psm driver entry points */
-
-#define endprobe(v) { if (bootverbose) \
- --verbose; \
- kbdc_set_device_mask(sc->kbdc, mask); \
- kbdc_lock(sc->kbdc, FALSE); \
- return (v); \
- }
-
-static int
-psmprobe(device_t dev)
-{
- int unit = device_get_unit(dev);
- struct psm_softc *sc = device_get_softc(dev);
- uintptr_t port;
- uintptr_t flags;
- int stat[3];
- int command_byte;
- int mask;
- int i;
-
-#if 0
- kbdc_debug(TRUE);
-#endif
- BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_PORT, &port);
- BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_FLAGS, &flags);
-
- sc->addr = port;
- sc->kbdc = kbdc_open(sc->addr);
- sc->config = flags & PSM_CONFIG_FLAGS;
- sc->flags = 0;
- if (bootverbose)
- ++verbose;
-
- device_set_desc(dev, "PS/2 Mouse");
-
- if (!kbdc_lock(sc->kbdc, TRUE)) {
- printf("psm%d: unable to lock the controller.\n", unit);
- if (bootverbose)
- --verbose;
- return (ENXIO);
- }
-
- /*
- * NOTE: two bits in the command byte controls the operation of the
- * aux port (mouse port): the aux port disable bit (bit 5) and the aux
- * port interrupt (IRQ 12) enable bit (bit 2).
- */
-
- /* discard anything left after the keyboard initialization */
- empty_both_buffers(sc->kbdc, 10);
-
- /* save the current command byte; it will be used later */
- mask = kbdc_get_device_mask(sc->kbdc) & ~KBD_AUX_CONTROL_BITS;
- command_byte = get_controller_command_byte(sc->kbdc);
- if (verbose)
- printf("psm%d: current command byte:%04x\n", unit, command_byte);
- if (command_byte == -1) {
- /* CONTROLLER ERROR */
- printf("psm%d: unable to get the current command byte value.\n",
- unit);
- endprobe(ENXIO);
- }
-
- /*
- * disable the keyboard port while probing the aux port, which must be
- * enabled during this routine
- */
- if (!set_controller_command_byte(sc->kbdc,
- KBD_KBD_CONTROL_BITS | KBD_AUX_CONTROL_BITS,
- KBD_DISABLE_KBD_PORT | KBD_DISABLE_KBD_INT
- | KBD_ENABLE_AUX_PORT | KBD_DISABLE_AUX_INT)) {
- /*
- * this is CONTROLLER ERROR; I don't know how to recover
- * from this error...
- */
- restore_controller(sc->kbdc, command_byte);
- printf("psm%d: unable to set the command byte.\n", unit);
- endprobe(ENXIO);
- }
- write_controller_command(sc->kbdc, KBDC_ENABLE_AUX_PORT);
-
- /*
- * NOTE: `test_aux_port()' is designed to return with zero if the aux
- * port exists and is functioning. However, some controllers appears
- * to respond with zero even when the aux port doesn't exist. (It may
- * be that this is only the case when the controller DOES have the aux
- * port but the port is not wired on the motherboard.) The keyboard
- * controllers without the port, such as the original AT, are
- * supporsed to return with an error code or simply time out. In any
- * case, we have to continue probing the port even when the controller
- * passes this test.
- *
- * XXX: some controllers erroneously return the error code 1 when
- * it has the perfectly functional aux port. We have to ignore this
- * error code. Even if the controller HAS error with the aux port,
- * it will be detected later...
- * XXX: another incompatible controller returns PSM_ACK (0xfa)...
- */
- switch ((i = test_aux_port(sc->kbdc))) {
- case 1: /* ignore this error */
- case PSM_ACK:
- if (verbose)
- printf("psm%d: strange result for test aux port (%d).\n",
- unit, i);
- /* fall though */
- case 0: /* no error */
- break;
- case -1: /* time out */
- default: /* error */
- recover_from_error(sc->kbdc);
- if (sc->config & PSM_CONFIG_IGNPORTERROR)
- break;
- restore_controller(sc->kbdc, command_byte);
- if (verbose)
- printf("psm%d: the aux port is not functioning (%d).\n",
- unit, i);
- endprobe(ENXIO);
- }
-
- if (sc->config & PSM_CONFIG_NORESET) {
- /*
- * Don't try to reset the pointing device. It may possibly be
- * left in the unknown state, though...
- */
- } else {
- /*
- * NOTE: some controllers appears to hang the `keyboard' when the aux
- * port doesn't exist and `PSMC_RESET_DEV' is issued.
- */
- if (!reset_aux_dev(sc->kbdc)) {
- recover_from_error(sc->kbdc);
- restore_controller(sc->kbdc, command_byte);
- if (verbose)
- printf("psm%d: failed to reset the aux device.\n", unit);
- endprobe(ENXIO);
- }
- }
-
- /*
- * both the aux port and the aux device is functioning, see if the
- * device can be enabled. NOTE: when enabled, the device will start
- * sending data; we shall immediately disable the device once we know
- * the device can be enabled.
- */
- if (!enable_aux_dev(sc->kbdc) || !disable_aux_dev(sc->kbdc)) {
- /* MOUSE ERROR */
- recover_from_error(sc->kbdc);
- restore_controller(sc->kbdc, command_byte);
- if (verbose)
- printf("psm%d: failed to enable the aux device.\n", unit);
- endprobe(ENXIO);
- }
-
- /* save the default values after reset */
- if (get_mouse_status(sc->kbdc, stat, 0, 3) >= 3) {
- sc->dflt_mode.rate = sc->mode.rate = stat[2];
- sc->dflt_mode.resolution = sc->mode.resolution = stat[1];
- } else {
- sc->dflt_mode.rate = sc->mode.rate = -1;
- sc->dflt_mode.resolution = sc->mode.resolution = -1;
- }
-
- /* hardware information */
- sc->hw.iftype = MOUSE_IF_PS2;
-
- /* verify the device is a mouse */
- sc->hw.hwid = get_aux_id(sc->kbdc);
- if (!is_a_mouse(sc->hw.hwid)) {
- restore_controller(sc->kbdc, command_byte);
- if (verbose)
- printf("psm%d: unknown device type (%d).\n", unit, sc->hw.hwid);
- endprobe(ENXIO);
- }
- switch (sc->hw.hwid) {
- case PSM_BALLPOINT_ID:
- sc->hw.type = MOUSE_TRACKBALL;
- break;
- case PSM_MOUSE_ID:
- case PSM_INTELLI_ID:
- sc->hw.type = MOUSE_MOUSE;
- break;
- default:
- sc->hw.type = MOUSE_UNKNOWN;
- break;
- }
-
- if (sc->config & PSM_CONFIG_NOIDPROBE) {
- sc->hw.buttons = 2;
- i = GENERIC_MOUSE_ENTRY;
- } else {
- /* # of buttons */
- sc->hw.buttons = get_mouse_buttons(sc->kbdc);
-
- /* other parameters */
- for (i = 0; vendortype[i].probefunc != NULL; ++i) {
- if ((*vendortype[i].probefunc)(sc)) {
- if (verbose >= 2)
- printf("psm%d: found %s\n",
- unit, model_name(vendortype[i].model));
- break;
- }
- }
- }
-
- sc->hw.model = vendortype[i].model;
-
- sc->dflt_mode.level = PSM_LEVEL_BASE;
- sc->dflt_mode.packetsize = MOUSE_PS2_PACKETSIZE;
- sc->dflt_mode.accelfactor = (sc->config & PSM_CONFIG_ACCEL) >> 4;
- if (sc->config & PSM_CONFIG_NOCHECKSYNC)
- sc->dflt_mode.syncmask[0] = 0;
- else
- sc->dflt_mode.syncmask[0] = vendortype[i].syncmask;
- if (sc->config & PSM_CONFIG_FORCETAP)
- sc->mode.syncmask[0] &= ~MOUSE_PS2_TAP;
- sc->dflt_mode.syncmask[1] = 0; /* syncbits */
- sc->mode = sc->dflt_mode;
- sc->mode.packetsize = vendortype[i].packetsize;
-
- /* set mouse parameters */
-#if 0
- /*
- * A version of Logitech FirstMouse+ won't report wheel movement,
- * if SET_DEFAULTS is sent... Don't use this command.
- * This fix was found by Takashi Nishida.
- */
- i = send_aux_command(sc->kbdc, PSMC_SET_DEFAULTS);
- if (verbose >= 2)
- printf("psm%d: SET_DEFAULTS return code:%04x\n", unit, i);
-#endif
- if (sc->config & PSM_CONFIG_RESOLUTION) {
- sc->mode.resolution
- = set_mouse_resolution(sc->kbdc,
- (sc->config & PSM_CONFIG_RESOLUTION) - 1);
- } else if (sc->mode.resolution >= 0) {
- sc->mode.resolution
- = set_mouse_resolution(sc->kbdc, sc->dflt_mode.resolution);
- }
- if (sc->mode.rate > 0) {
- sc->mode.rate = set_mouse_sampling_rate(sc->kbdc, sc->dflt_mode.rate);
- }
- set_mouse_scaling(sc->kbdc, 1);
-
- /* request a data packet and extract sync. bits */
- if (get_mouse_status(sc->kbdc, stat, 1, 3) < 3) {
- printf("psm%d: failed to get data.\n", unit);
- sc->mode.syncmask[0] = 0;
- } else {
- sc->mode.syncmask[1] = stat[0] & sc->mode.syncmask[0]; /* syncbits */
- /* the NetScroll Mouse will send three more bytes... Ignore them */
- empty_aux_buffer(sc->kbdc, 5);
- }
-
- /* just check the status of the mouse */
- /*
- * NOTE: XXX there are some arcane controller/mouse combinations out
- * there, which hung the controller unless there is data transmission
- * after ACK from the mouse.
- */
- if (get_mouse_status(sc->kbdc, stat, 0, 3) < 3) {
- printf("psm%d: failed to get status.\n", unit);
- } else {
- /*
- * When in its native mode, some mice operate with different
- * default parameters than in the PS/2 compatible mode.
- */
- sc->dflt_mode.rate = sc->mode.rate = stat[2];
- sc->dflt_mode.resolution = sc->mode.resolution = stat[1];
- }
-
- /* disable the aux port for now... */
- if (!set_controller_command_byte(sc->kbdc,
- KBD_KBD_CONTROL_BITS | KBD_AUX_CONTROL_BITS,
- (command_byte & KBD_KBD_CONTROL_BITS)
- | KBD_DISABLE_AUX_PORT | KBD_DISABLE_AUX_INT)) {
- /*
- * this is CONTROLLER ERROR; I don't know the proper way to
- * recover from this error...
- */
- restore_controller(sc->kbdc, command_byte);
- printf("psm%d: unable to set the command byte.\n", unit);
- endprobe(ENXIO);
- }
-
- /* done */
- kbdc_set_device_mask(sc->kbdc, mask | KBD_AUX_CONTROL_BITS);
- kbdc_lock(sc->kbdc, FALSE);
- return (0);
-}
-
-static int
-psmattach(device_t dev)
-{
- int unit = device_get_unit(dev);
- struct psm_softc *sc = device_get_softc(dev);
- void *ih;
- struct resource *res;
- uintptr_t irq;
- int zero = 0;
-
- if (sc == NULL) /* shouldn't happen */
- return (ENXIO);
-
- /* Setup initial state */
- sc->state = PSM_VALID;
-
- /* Done */
- make_dev(&psm_cdevsw, PSM_MKMINOR(unit, FALSE), 0, 0, 0666, "psm%d", unit);
- make_dev(&psm_cdevsw, PSM_MKMINOR(unit, TRUE), 0, 0, 0666, "bpsm%d", unit);
-
- if (!verbose) {
- printf("psm%d: model %s, device ID %d\n",
- unit, model_name(sc->hw.model), sc->hw.hwid & 0x00ff);
- } else {
- printf("psm%d: model %s, device ID %d-%02x, %d buttons\n",
- unit, model_name(sc->hw.model),
- sc->hw.hwid & 0x00ff, sc->hw.hwid >> 8, sc->hw.buttons);
- printf("psm%d: config:%08x, flags:%08x, packet size:%d\n",
- unit, sc->config, sc->flags, sc->mode.packetsize);
- printf("psm%d: syncmask:%02x, syncbits:%02x\n",
- unit, sc->mode.syncmask[0], sc->mode.syncmask[1]);
- }
-
- if (bootverbose)
- --verbose;
-
- BUS_READ_IVAR(device_get_parent(dev), dev, KBDC_IVAR_IRQ, &irq);
- res = bus_alloc_resource(dev, SYS_RES_IRQ, &zero, irq, irq, 1,
- RF_SHAREABLE | RF_ACTIVE);
- BUS_SETUP_INTR(device_get_parent(dev), dev, res, INTR_TYPE_TTY,
- psmintr, sc, &ih);
-
- return (0);
-}
-
-static int
-psmopen(dev_t dev, int flag, int fmt, struct proc *p)
-{
- int unit = PSM_UNIT(dev);
- struct psm_softc *sc;
- int command_byte;
- int err;
- int s;
-
- /* Get device data */
- sc = PSM_SOFTC(unit);
- if ((sc == NULL) || (sc->state & PSM_VALID) == 0)
- /* the device is no longer valid/functioning */
- return (ENXIO);
-
- /* Disallow multiple opens */
- if (sc->state & PSM_OPEN)
- return (EBUSY);
-
- device_busy(devclass_get_device(psm_devclass, unit));
-
- /* Initialize state */
- sc->rsel.si_flags = 0;
- sc->rsel.si_pid = 0;
- sc->mode.level = sc->dflt_mode.level;
- sc->mode.protocol = sc->dflt_mode.protocol;
-
- /* flush the event queue */
- sc->queue.count = 0;
- sc->queue.head = 0;
- sc->queue.tail = 0;
- sc->status.flags = 0;
- sc->status.button = 0;
- sc->status.obutton = 0;
- sc->status.dx = 0;
- sc->status.dy = 0;
- sc->status.dz = 0;
- sc->button = 0;
-
- /* empty input buffer */
- bzero(sc->ipacket, sizeof(sc->ipacket));
- sc->inputbytes = 0;
-
- /* don't let timeout routines in the keyboard driver to poll the kbdc */
- if (!kbdc_lock(sc->kbdc, TRUE))
- return (EIO);
-
- /* save the current controller command byte */
- s = spltty();
- command_byte = get_controller_command_byte(sc->kbdc);
-
- /* enable the aux port and temporalily disable the keyboard */
- if ((command_byte == -1)
- || !set_controller_command_byte(sc->kbdc,
- kbdc_get_device_mask(sc->kbdc),
- KBD_DISABLE_KBD_PORT | KBD_DISABLE_KBD_INT
- | KBD_ENABLE_AUX_PORT | KBD_DISABLE_AUX_INT)) {
- /* CONTROLLER ERROR; do you know how to get out of this? */
- kbdc_lock(sc->kbdc, FALSE);
- splx(s);
- log(LOG_ERR, "psm%d: unable to set the command byte (psmopen).\n",
- unit);
- return (EIO);
- }
- /*
- * Now that the keyboard controller is told not to generate
- * the keyboard and mouse interrupts, call `splx()' to allow
- * the other tty interrupts. The clock interrupt may also occur,
- * but timeout routines will be blocked by the poll flag set
- * via `kbdc_lock()'
- */
- splx(s);
-
- /* enable the mouse device */
- err = doopen(unit, command_byte);
-
- /* done */
- if (err == 0)
- sc->state |= PSM_OPEN;
- kbdc_lock(sc->kbdc, FALSE);
- return (err);
-}
-
-static int
-psmclose(dev_t dev, int flag, int fmt, struct proc *p)
-{
- int unit = PSM_UNIT(dev);
- struct psm_softc *sc = PSM_SOFTC(unit);
- int stat[3];
- int command_byte;
- int s;
-
- /* don't let timeout routines in the keyboard driver to poll the kbdc */
- if (!kbdc_lock(sc->kbdc, TRUE))
- return (EIO);
-
- /* save the current controller command byte */
- s = spltty();
- command_byte = get_controller_command_byte(sc->kbdc);
- if (command_byte == -1) {
- kbdc_lock(sc->kbdc, FALSE);
- splx(s);
- return (EIO);
- }
-
- /* disable the aux interrupt and temporalily disable the keyboard */
- if (!set_controller_command_byte(sc->kbdc,
- kbdc_get_device_mask(sc->kbdc),
- KBD_DISABLE_KBD_PORT | KBD_DISABLE_KBD_INT
- | KBD_ENABLE_AUX_PORT | KBD_DISABLE_AUX_INT)) {
- log(LOG_ERR, "psm%d: failed to disable the aux int (psmclose).\n",
- PSM_UNIT(dev));
- /* CONTROLLER ERROR;
- * NOTE: we shall force our way through. Because the only
- * ill effect we shall see is that we may not be able
- * to read ACK from the mouse, and it doesn't matter much
- * so long as the mouse will accept the DISABLE command.
- */
- }
- splx(s);
-
- /* remove anything left in the output buffer */
- empty_aux_buffer(sc->kbdc, 10);
-
- /* disable the aux device, port and interrupt */
- if (sc->state & PSM_VALID) {
- if (!disable_aux_dev(sc->kbdc)) {
- /* MOUSE ERROR;
- * NOTE: we don't return error and continue, pretending
- * we have successfully disabled the device. It's OK because
- * the interrupt routine will discard any data from the mouse
- * hereafter.
- */
- log(LOG_ERR, "psm%d: failed to disable the device (psmclose).\n",
- PSM_UNIT(dev));
- }
-
- if (get_mouse_status(sc->kbdc, stat, 0, 3) < 3)
- log(LOG_DEBUG, "psm%d: failed to get status (psmclose).\n",
- PSM_UNIT(dev));
- }
-
- if (!set_controller_command_byte(sc->kbdc,
- kbdc_get_device_mask(sc->kbdc),
- (command_byte & KBD_KBD_CONTROL_BITS)
- | KBD_DISABLE_AUX_PORT | KBD_DISABLE_AUX_INT)) {
- /* CONTROLLER ERROR;
- * we shall ignore this error; see the above comment.
- */
- log(LOG_ERR, "psm%d: failed to disable the aux port (psmclose).\n",
- PSM_UNIT(dev));
- }
-
- /* remove anything left in the output buffer */
- empty_aux_buffer(sc->kbdc, 10);
-
- /* close is almost always successful */
- sc->state &= ~PSM_OPEN;
- kbdc_lock(sc->kbdc, FALSE);
- device_unbusy(devclass_get_device(psm_devclass, unit));
- return (0);
-}
-
-static int
-tame_mouse(struct psm_softc *sc, mousestatus_t *status, unsigned char *buf)
-{
- static unsigned char butmapps2[8] = {
- 0,
- MOUSE_PS2_BUTTON1DOWN,
- MOUSE_PS2_BUTTON2DOWN,
- MOUSE_PS2_BUTTON1DOWN | MOUSE_PS2_BUTTON2DOWN,
- MOUSE_PS2_BUTTON3DOWN,
- MOUSE_PS2_BUTTON1DOWN | MOUSE_PS2_BUTTON3DOWN,
- MOUSE_PS2_BUTTON2DOWN | MOUSE_PS2_BUTTON3DOWN,
- MOUSE_PS2_BUTTON1DOWN | MOUSE_PS2_BUTTON2DOWN | MOUSE_PS2_BUTTON3DOWN,
- };
- static unsigned char butmapmsc[8] = {
- MOUSE_MSC_BUTTON1UP | MOUSE_MSC_BUTTON2UP | MOUSE_MSC_BUTTON3UP,
- MOUSE_MSC_BUTTON2UP | MOUSE_MSC_BUTTON3UP,
- MOUSE_MSC_BUTTON1UP | MOUSE_MSC_BUTTON3UP,
- MOUSE_MSC_BUTTON3UP,
- MOUSE_MSC_BUTTON1UP | MOUSE_MSC_BUTTON2UP,
- MOUSE_MSC_BUTTON2UP,
- MOUSE_MSC_BUTTON1UP,
- 0,
- };
- int mapped;
- int i;
-
- if (sc->mode.level == PSM_LEVEL_BASE) {
- mapped = status->button & ~MOUSE_BUTTON4DOWN;
- if (status->button & MOUSE_BUTTON4DOWN)
- mapped |= MOUSE_BUTTON1DOWN;
- status->button = mapped;
- buf[0] = MOUSE_PS2_SYNC | butmapps2[mapped & MOUSE_STDBUTTONS];
- i = max(min(status->dx, 255), -256);
- if (i < 0)
- buf[0] |= MOUSE_PS2_XNEG;
- buf[1] = i;
- i = max(min(status->dy, 255), -256);
- if (i < 0)
- buf[0] |= MOUSE_PS2_YNEG;
- buf[2] = i;
- return MOUSE_PS2_PACKETSIZE;
- } else if (sc->mode.level == PSM_LEVEL_STANDARD) {
- buf[0] = MOUSE_MSC_SYNC | butmapmsc[status->button & MOUSE_STDBUTTONS];
- i = max(min(status->dx, 255), -256);
- buf[1] = i >> 1;
- buf[3] = i - buf[1];
- i = max(min(status->dy, 255), -256);
- buf[2] = i >> 1;
- buf[4] = i - buf[2];
- i = max(min(status->dz, 127), -128);
- buf[5] = (i >> 1) & 0x7f;
- buf[6] = (i - (i >> 1)) & 0x7f;
- buf[7] = (~status->button >> 3) & 0x7f;
- return MOUSE_SYS_PACKETSIZE;
- }
- return sc->inputbytes;;
-}
-
-static int
-psmread(dev_t dev, struct uio *uio, int flag)
-{
- register struct psm_softc *sc = PSM_SOFTC(PSM_UNIT(dev));
- unsigned char buf[PSM_SMALLBUFSIZE];
- int error = 0;
- int s;
- int l;
-
- if ((sc->state & PSM_VALID) == 0)
- return EIO;
-
- /* block until mouse activity occured */
- s = spltty();
- while (sc->queue.count <= 0) {
- if (PSM_NBLOCKIO(dev)) {
- splx(s);
- return EWOULDBLOCK;
- }
- sc->state |= PSM_ASLP;
- error = tsleep((caddr_t) sc, PZERO | PCATCH, "psmrea", 0);
- sc->state &= ~PSM_ASLP;
- if (error) {
- splx(s);
- return error;
- } else if ((sc->state & PSM_VALID) == 0) {
- /* the device disappeared! */
- splx(s);
- return EIO;
- }
- }
- splx(s);
-
- /* copy data to the user land */
- while ((sc->queue.count > 0) && (uio->uio_resid > 0)) {
- s = spltty();
- l = min(sc->queue.count, uio->uio_resid);
- if (l > sizeof(buf))
- l = sizeof(buf);
- if (l > sizeof(sc->queue.buf) - sc->queue.head) {
- bcopy(&sc->queue.buf[sc->queue.head], &buf[0],
- sizeof(sc->queue.buf) - sc->queue.head);
- bcopy(&sc->queue.buf[0],
- &buf[sizeof(sc->queue.buf) - sc->queue.head],
- l - (sizeof(sc->queue.buf) - sc->queue.head));
- } else {
- bcopy(&sc->queue.buf[sc->queue.head], &buf[0], l);
- }
- sc->queue.count -= l;
- sc->queue.head = (sc->queue.head + l) % sizeof(sc->queue.buf);
- splx(s);
- error = uiomove(buf, l, uio);
- if (error)
- break;
- }
-
- return error;
-}
-
-static int
-block_mouse_data(struct psm_softc *sc, int *c)
-{
- int s;
-
- if (!kbdc_lock(sc->kbdc, TRUE))
- return EIO;
-
- s = spltty();
- *c = get_controller_command_byte(sc->kbdc);
- if ((*c == -1)
- || !set_controller_command_byte(sc->kbdc,
- kbdc_get_device_mask(sc->kbdc),
- KBD_DISABLE_KBD_PORT | KBD_DISABLE_KBD_INT
- | KBD_ENABLE_AUX_PORT | KBD_DISABLE_AUX_INT)) {
- /* this is CONTROLLER ERROR */
- splx(s);
- kbdc_lock(sc->kbdc, FALSE);
- return EIO;
- }
-
- /*
- * The device may be in the middle of status data transmission.
- * The transmission will be interrupted, thus, incomplete status
- * data must be discarded. Although the aux interrupt is disabled
- * at the keyboard controller level, at most one aux interrupt
- * may have already been pending and a data byte is in the
- * output buffer; throw it away. Note that the second argument
- * to `empty_aux_buffer()' is zero, so that the call will just
- * flush the internal queue.
- * `psmintr()' will be invoked after `splx()' if an interrupt is
- * pending; it will see no data and returns immediately.
- */
- empty_aux_buffer(sc->kbdc, 0); /* flush the queue */
- read_aux_data_no_wait(sc->kbdc); /* throw away data if any */
- sc->inputbytes = 0;
- splx(s);
-
- return 0;
-}
-
-static int
-unblock_mouse_data(struct psm_softc *sc, int c)
-{
- int error = 0;
-
- /*
- * We may have seen a part of status data during `set_mouse_XXX()'.
- * they have been queued; flush it.
- */
- empty_aux_buffer(sc->kbdc, 0);
-
- /* restore ports and interrupt */
- if (!set_controller_command_byte(sc->kbdc,
- kbdc_get_device_mask(sc->kbdc),
- c & (KBD_KBD_CONTROL_BITS | KBD_AUX_CONTROL_BITS))) {
- /* CONTROLLER ERROR; this is serious, we may have
- * been left with the inaccessible keyboard and
- * the disabled mouse interrupt.
- */
- error = EIO;
- }
-
- kbdc_lock(sc->kbdc, FALSE);
- return error;
-}
-
-static int
-psmioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
-{
- struct psm_softc *sc = PSM_SOFTC(PSM_UNIT(dev));
- mousemode_t mode;
- mousestatus_t status;
-#if (defined(MOUSE_GETVARS))
- mousevar_t *var;
-#endif
- mousedata_t *data;
- int stat[3];
- int command_byte;
- int error = 0;
- int s;
-
- /* Perform IOCTL command */
- switch (cmd) {
-
- case OLD_MOUSE_GETHWINFO:
- s = spltty();
- ((old_mousehw_t *)addr)->buttons = sc->hw.buttons;
- ((old_mousehw_t *)addr)->iftype = sc->hw.iftype;
- ((old_mousehw_t *)addr)->type = sc->hw.type;
- ((old_mousehw_t *)addr)->hwid = sc->hw.hwid & 0x00ff;
- splx(s);
- break;
-
- case MOUSE_GETHWINFO:
- s = spltty();
- *(mousehw_t *)addr = sc->hw;
- if (sc->mode.level == PSM_LEVEL_BASE)
- ((mousehw_t *)addr)->model = MOUSE_MODEL_GENERIC;
- splx(s);
- break;
-
- case OLD_MOUSE_GETMODE:
- s = spltty();
- switch (sc->mode.level) {
- case PSM_LEVEL_BASE:
- ((old_mousemode_t *)addr)->protocol = MOUSE_PROTO_PS2;
- break;
- case PSM_LEVEL_STANDARD:
- ((old_mousemode_t *)addr)->protocol = MOUSE_PROTO_SYSMOUSE;
- break;
- case PSM_LEVEL_NATIVE:
- ((old_mousemode_t *)addr)->protocol = MOUSE_PROTO_PS2;
- break;
- }
- ((old_mousemode_t *)addr)->rate = sc->mode.rate;
- ((old_mousemode_t *)addr)->resolution = sc->mode.resolution;
- ((old_mousemode_t *)addr)->accelfactor = sc->mode.accelfactor;
- splx(s);
- break;
-
- case MOUSE_GETMODE:
- s = spltty();
- *(mousemode_t *)addr = sc->mode;
- ((mousemode_t *)addr)->resolution =
- MOUSE_RES_LOW - sc->mode.resolution;
- switch (sc->mode.level) {
- case PSM_LEVEL_BASE:
- ((mousemode_t *)addr)->protocol = MOUSE_PROTO_PS2;
- ((mousemode_t *)addr)->packetsize = MOUSE_PS2_PACKETSIZE;
- break;
- case PSM_LEVEL_STANDARD:
- ((mousemode_t *)addr)->protocol = MOUSE_PROTO_SYSMOUSE;
- ((mousemode_t *)addr)->packetsize = MOUSE_SYS_PACKETSIZE;
- ((mousemode_t *)addr)->syncmask[0] = MOUSE_SYS_SYNCMASK;
- ((mousemode_t *)addr)->syncmask[1] = MOUSE_SYS_SYNC;
- break;
- case PSM_LEVEL_NATIVE:
- /* FIXME: this isn't quite correct... XXX */
- ((mousemode_t *)addr)->protocol = MOUSE_PROTO_PS2;
- break;
- }
- splx(s);
- break;
-
- case OLD_MOUSE_SETMODE:
- case MOUSE_SETMODE:
- if (cmd == OLD_MOUSE_SETMODE) {
- mode.rate = ((old_mousemode_t *)addr)->rate;
- /*
- * resolution old I/F new I/F
- * default 0 0
- * low 1 -2
- * medium low 2 -3
- * medium high 3 -4
- * high 4 -5
- */
- if (((old_mousemode_t *)addr)->resolution > 0)
- mode.resolution = -((old_mousemode_t *)addr)->resolution - 1;
- mode.accelfactor = ((old_mousemode_t *)addr)->accelfactor;
- mode.level = -1;
- } else {
- mode = *(mousemode_t *)addr;
- }
-
- /* adjust and validate parameters. */
- if (mode.rate > UCHAR_MAX)
- return EINVAL;
- if (mode.rate == 0)
- mode.rate = sc->dflt_mode.rate;
- else if (mode.rate == -1)
- /* don't change the current setting */
- ;
- else if (mode.rate < 0)
- return EINVAL;
- if (mode.resolution >= UCHAR_MAX)
- return EINVAL;
- if (mode.resolution >= 200)
- mode.resolution = MOUSE_RES_HIGH;
- else if (mode.resolution >= 100)
- mode.resolution = MOUSE_RES_MEDIUMHIGH;
- else if (mode.resolution >= 50)
- mode.resolution = MOUSE_RES_MEDIUMLOW;
- else if (mode.resolution > 0)
- mode.resolution = MOUSE_RES_LOW;
- if (mode.resolution == MOUSE_RES_DEFAULT)
- mode.resolution = sc->dflt_mode.resolution;
- else if (mode.resolution == -1)
- /* don't change the current setting */
- ;
- else if (mode.resolution < 0) /* MOUSE_RES_LOW/MEDIUM/HIGH */
- mode.resolution = MOUSE_RES_LOW - mode.resolution;
- if (mode.level == -1)
- /* don't change the current setting */
- mode.level = sc->mode.level;
- else if ((mode.level < PSM_LEVEL_MIN) || (mode.level > PSM_LEVEL_MAX))
- return EINVAL;
- if (mode.accelfactor == -1)
- /* don't change the current setting */
- mode.accelfactor = sc->mode.accelfactor;
- else if (mode.accelfactor < 0)
- return EINVAL;
-
- /* don't allow anybody to poll the keyboard controller */
- error = block_mouse_data(sc, &command_byte);
- if (error)
- return error;
-
- /* set mouse parameters */
- if (mode.rate > 0)
- mode.rate = set_mouse_sampling_rate(sc->kbdc, mode.rate);
- if (mode.resolution >= 0)
- mode.resolution = set_mouse_resolution(sc->kbdc, mode.resolution);
- set_mouse_scaling(sc->kbdc, 1);
- get_mouse_status(sc->kbdc, stat, 0, 3);
-
- s = spltty();
- sc->mode.rate = mode.rate;
- sc->mode.resolution = mode.resolution;
- sc->mode.accelfactor = mode.accelfactor;
- sc->mode.level = mode.level;
- splx(s);
-
- unblock_mouse_data(sc, command_byte);
- break;
-
- case MOUSE_GETLEVEL:
- *(int *)addr = sc->mode.level;
- break;
-
- case MOUSE_SETLEVEL:
- if ((*(int *)addr < PSM_LEVEL_MIN) || (*(int *)addr > PSM_LEVEL_MAX))
- return EINVAL;
- sc->mode.level = *(int *)addr;
- break;
-
- case MOUSE_GETSTATUS:
- s = spltty();
- status = sc->status;
- sc->status.flags = 0;
- sc->status.obutton = sc->status.button;
- sc->status.button = 0;
- sc->status.dx = 0;
- sc->status.dy = 0;
- sc->status.dz = 0;
- splx(s);
- *(mousestatus_t *)addr = status;
- break;
-
-#if (defined(MOUSE_GETVARS))
- case MOUSE_GETVARS:
- var = (mousevar_t *)addr;
- bzero(var, sizeof(*var));
- s = spltty();
- var->var[0] = MOUSE_VARS_PS2_SIG;
- var->var[1] = sc->config;
- var->var[2] = sc->flags;
- splx(s);
- break;
-
- case MOUSE_SETVARS:
- return ENODEV;
-#endif /* MOUSE_GETVARS */
-
- case MOUSE_READSTATE:
- case MOUSE_READDATA:
- data = (mousedata_t *)addr;
- if (data->len > sizeof(data->buf)/sizeof(data->buf[0]))
- return EINVAL;
-
- error = block_mouse_data(sc, &command_byte);
- if (error)
- return error;
- if ((data->len = get_mouse_status(sc->kbdc, data->buf,
- (cmd == MOUSE_READDATA) ? 1 : 0, data->len)) <= 0)
- error = EIO;
- unblock_mouse_data(sc, command_byte);
- break;
-
-#if (defined(MOUSE_SETRESOLUTION))
- case MOUSE_SETRESOLUTION:
- mode.resolution = *(int *)addr;
- if (mode.resolution >= UCHAR_MAX)
- return EINVAL;
- else if (mode.resolution >= 200)
- mode.resolution = MOUSE_RES_HIGH;
- else if (mode.resolution >= 100)
- mode.resolution = MOUSE_RES_MEDIUMHIGH;
- else if (mode.resolution >= 50)
- mode.resolution = MOUSE_RES_MEDIUMLOW;
- else if (mode.resolution > 0)
- mode.resolution = MOUSE_RES_LOW;
- if (mode.resolution == MOUSE_RES_DEFAULT)
- mode.resolution = sc->dflt_mode.resolution;
- else if (mode.resolution == -1)
- mode.resolution = sc->mode.resolution;
- else if (mode.resolution < 0) /* MOUSE_RES_LOW/MEDIUM/HIGH */
- mode.resolution = MOUSE_RES_LOW - mode.resolution;
-
- error = block_mouse_data(sc, &command_byte);
- if (error)
- return error;
- sc->mode.resolution = set_mouse_resolution(sc->kbdc, mode.resolution);
- if (sc->mode.resolution != mode.resolution)
- error = EIO;
- unblock_mouse_data(sc, command_byte);
- break;
-#endif /* MOUSE_SETRESOLUTION */
-
-#if (defined(MOUSE_SETRATE))
- case MOUSE_SETRATE:
- mode.rate = *(int *)addr;
- if (mode.rate > UCHAR_MAX)
- return EINVAL;
- if (mode.rate == 0)
- mode.rate = sc->dflt_mode.rate;
- else if (mode.rate < 0)
- mode.rate = sc->mode.rate;
-
- error = block_mouse_data(sc, &command_byte);
- if (error)
- return error;
- sc->mode.rate = set_mouse_sampling_rate(sc->kbdc, mode.rate);
- if (sc->mode.rate != mode.rate)
- error = EIO;
- unblock_mouse_data(sc, command_byte);
- break;
-#endif /* MOUSE_SETRATE */
-
-#if (defined(MOUSE_SETSCALING))
- case MOUSE_SETSCALING:
- if ((*(int *)addr <= 0) || (*(int *)addr > 2))
- return EINVAL;
-
- error = block_mouse_data(sc, &command_byte);
- if (error)
- return error;
- if (!set_mouse_scaling(sc->kbdc, *(int *)addr))
- error = EIO;
- unblock_mouse_data(sc, command_byte);
- break;
-#endif /* MOUSE_SETSCALING */
-
-#if (defined(MOUSE_GETHWID))
- case MOUSE_GETHWID:
- error = block_mouse_data(sc, &command_byte);
- if (error)
- return error;
- sc->hw.hwid &= ~0x00ff;
- sc->hw.hwid |= get_aux_id(sc->kbdc);
- *(int *)addr = sc->hw.hwid & 0x00ff;
- unblock_mouse_data(sc, command_byte);
- break;
-#endif /* MOUSE_GETHWID */
-
- default:
- return ENOTTY;
- }
-
- return error;
-}
-
-static void
-psmintr(void *arg)
-{
- /*
- * the table to turn PS/2 mouse button bits (MOUSE_PS2_BUTTON?DOWN)
- * into `mousestatus' button bits (MOUSE_BUTTON?DOWN).
- */
- static int butmap[8] = {
- 0,
- MOUSE_BUTTON1DOWN,
- MOUSE_BUTTON3DOWN,
- MOUSE_BUTTON1DOWN | MOUSE_BUTTON3DOWN,
- MOUSE_BUTTON2DOWN,
- MOUSE_BUTTON1DOWN | MOUSE_BUTTON2DOWN,
- MOUSE_BUTTON2DOWN | MOUSE_BUTTON3DOWN,
- MOUSE_BUTTON1DOWN | MOUSE_BUTTON2DOWN | MOUSE_BUTTON3DOWN
- };
- static int butmap_versapad[8] = {
- 0,
- MOUSE_BUTTON3DOWN,
- 0,
- MOUSE_BUTTON3DOWN,
- MOUSE_BUTTON1DOWN,
- MOUSE_BUTTON1DOWN | MOUSE_BUTTON3DOWN,
- MOUSE_BUTTON1DOWN,
- MOUSE_BUTTON1DOWN | MOUSE_BUTTON3DOWN
- };
- register struct psm_softc *sc = arg;
- mousestatus_t ms;
- int x, y, z;
- int c;
- int l;
- int x0, y0;
-
- /* read until there is nothing to read */
- while((c = read_aux_data_no_wait(sc->kbdc)) != -1) {
-
- /* discard the byte if the device is not open */
- if ((sc->state & PSM_OPEN) == 0)
- continue;
-
- /*
- * Check sync bits. We check for overflow bits and the bit 3
- * for most mice. True, the code doesn't work if overflow
- * condition occurs. But we expect it rarely happens...
- */
- if ((sc->inputbytes == 0)
- && ((c & sc->mode.syncmask[0]) != sc->mode.syncmask[1])) {
- log(LOG_DEBUG, "psmintr: out of sync (%04x != %04x).\n",
- c & sc->mode.syncmask[0], sc->mode.syncmask[1]);
- continue;
- }
-
- sc->ipacket[sc->inputbytes++] = c;
- if (sc->inputbytes < sc->mode.packetsize)
- continue;
-
-#if 0
- log(LOG_DEBUG, "psmintr: %02x %02x %02x %02x %02x %02x\n",
- sc->ipacket[0], sc->ipacket[1], sc->ipacket[2],
- sc->ipacket[3], sc->ipacket[4], sc->ipacket[5]);
-#endif
-
- c = sc->ipacket[0];
-
- /*
- * A kludge for Kensington device!
- * The MSB of the horizontal count appears to be stored in
- * a strange place. This kludge doesn't affect other mice
- * because the bit is the overflow bit which is, in most cases,
- * expected to be zero when we reach here. XXX
- */
- if (sc->hw.model != MOUSE_MODEL_VERSAPAD)
- sc->ipacket[1] |= (c & MOUSE_PS2_XOVERFLOW) ? 0x80 : 0;
-
- /* ignore the overflow bits... */
- x = (c & MOUSE_PS2_XNEG) ? sc->ipacket[1] - 256 : sc->ipacket[1];
- y = (c & MOUSE_PS2_YNEG) ? sc->ipacket[2] - 256 : sc->ipacket[2];
- z = 0;
- ms.obutton = sc->button; /* previous button state */
- ms.button = butmap[c & MOUSE_PS2_BUTTONS];
- /* `tapping' action */
- if (sc->config & PSM_CONFIG_FORCETAP)
- ms.button |= ((c & MOUSE_PS2_TAP)) ? 0 : MOUSE_BUTTON4DOWN;
-
- switch (sc->hw.model) {
-
- case MOUSE_MODEL_INTELLI:
- case MOUSE_MODEL_NET:
- /* wheel data is in the fourth byte */
- z = (char)sc->ipacket[3];
- break;
-
- case MOUSE_MODEL_MOUSEMANPLUS:
- /*
- * PS2++ protocl packet
- *
- * b7 b6 b5 b4 b3 b2 b1 b0
- * byte 1: * 1 p3 p2 1 * * *
- * byte 2: c1 c2 p1 p0 d1 d0 1 0
- *
- * p3-p0: packet type
- * c1, c2: c1 & c2 == 1, if p2 == 0
- * c1 & c2 == 0, if p2 == 1
- *
- * packet type: 0 (device type)
- * See comments in enable_mmanplus() below.
- *
- * packet type: 1 (wheel data)
- *
- * b7 b6 b5 b4 b3 b2 b1 b0
- * byte 3: h * B5 B4 s d2 d1 d0
- *
- * h: 1, if horizontal roller data
- * 0, if vertical roller data
- * B4, B5: button 4 and 5
- * s: sign bit
- * d2-d0: roller data
- *
- * packet type: 2 (reserved)
- */
- if (((c & MOUSE_PS2PLUS_SYNCMASK) == MOUSE_PS2PLUS_SYNC)
- && (abs(x) > 191)
- && MOUSE_PS2PLUS_CHECKBITS(sc->ipacket)) {
- /* the extended data packet encodes button and wheel events */
- switch (MOUSE_PS2PLUS_PACKET_TYPE(sc->ipacket)) {
- case 1:
- /* wheel data packet */
- x = y = 0;
- if (sc->ipacket[2] & 0x80) {
- /* horizontal roller count - ignore it XXX*/
- } else {
- /* vertical roller count */
- z = (sc->ipacket[2] & MOUSE_PS2PLUS_ZNEG)
- ? (sc->ipacket[2] & 0x0f) - 16
- : (sc->ipacket[2] & 0x0f);
- }
- ms.button |= (sc->ipacket[2] & MOUSE_PS2PLUS_BUTTON4DOWN)
- ? MOUSE_BUTTON4DOWN : 0;
- ms.button |= (sc->ipacket[2] & MOUSE_PS2PLUS_BUTTON5DOWN)
- ? MOUSE_BUTTON5DOWN : 0;
- break;
- case 2:
- /* this packet type is reserved, and currently ignored */
- /* FALL THROUGH */
- case 0:
- /* device type packet - shouldn't happen */
- /* FALL THROUGH */
- default:
- x = y = 0;
- ms.button = ms.obutton;
- log(LOG_DEBUG, "psmintr: unknown PS2++ packet type %d: "
- "0x%02x 0x%02x 0x%02x\n",
- MOUSE_PS2PLUS_PACKET_TYPE(sc->ipacket),
- sc->ipacket[0], sc->ipacket[1], sc->ipacket[2]);
- break;
- }
- } else {
- /* preserve button states */
- ms.button |= ms.obutton & MOUSE_EXTBUTTONS;
- }
- break;
-
- case MOUSE_MODEL_GLIDEPOINT:
- /* `tapping' action */
- ms.button |= ((c & MOUSE_PS2_TAP)) ? 0 : MOUSE_BUTTON4DOWN;
- break;
-
- case MOUSE_MODEL_NETSCROLL:
- /* three addtional bytes encode button and wheel events */
- ms.button |= (sc->ipacket[3] & MOUSE_PS2_BUTTON3DOWN)
- ? MOUSE_BUTTON4DOWN : 0;
- z = (sc->ipacket[3] & MOUSE_PS2_XNEG)
- ? sc->ipacket[4] - 256 : sc->ipacket[4];
- break;
-
- case MOUSE_MODEL_THINK:
- /* the fourth button state in the first byte */
- ms.button |= (c & MOUSE_PS2_TAP) ? MOUSE_BUTTON4DOWN : 0;
- break;
-
- case MOUSE_MODEL_VERSAPAD:
- /* VersaPad PS/2 absolute mode message format
- *
- * [packet1] 7 6 5 4 3 2 1 0(LSB)
- * ipacket[0]: 1 1 0 A 1 L T R
- * ipacket[1]: H7 H6 H5 H4 H3 H2 H1 H0
- * ipacket[2]: V7 V6 V5 V4 V3 V2 V1 V0
- * ipacket[3]: 1 1 1 A 1 L T R
- * ipacket[4]:V11 V10 V9 V8 H11 H10 H9 H8
- * ipacket[5]: 0 P6 P5 P4 P3 P2 P1 P0
- *
- * [note]
- * R: right physical mouse button (1=on)
- * T: touch pad virtual button (1=tapping)
- * L: left physical mouse button (1=on)
- * A: position data is valid (1=valid)
- * H: horizontal data (12bit signed integer. H11 is sign bit.)
- * V: vertical data (12bit signed integer. V11 is sign bit.)
- * P: pressure data
- *
- * Tapping is mapped to MOUSE_BUTTON4.
- */
- ms.button = butmap_versapad[c & MOUSE_PS2VERSA_BUTTONS];
- ms.button |= (c & MOUSE_PS2VERSA_TAP) ? MOUSE_BUTTON4DOWN : 0;
- x = y = 0;
- if (c & MOUSE_PS2VERSA_IN_USE) {
- x0 = sc->ipacket[1] | (((sc->ipacket[4]) & 0x0f) << 8);
- y0 = sc->ipacket[2] | (((sc->ipacket[4]) & 0xf0) << 4);
- if (x0 & 0x800)
- x0 -= 0x1000;
- if (y0 & 0x800)
- y0 -= 0x1000;
- if (sc->flags & PSM_FLAGS_FINGERDOWN) {
- x = sc->xold - x0;
- y = y0 - sc->yold;
- if (x < 0) /* XXX */
- x++;
- else if (x)
- x--;
- if (y < 0)
- y++;
- else if (y)
- y--;
- } else {
- sc->flags |= PSM_FLAGS_FINGERDOWN;
- }
- sc->xold = x0;
- sc->yold = y0;
- } else {
- sc->flags &= ~PSM_FLAGS_FINGERDOWN;
- }
- c = ((x < 0) ? MOUSE_PS2_XNEG : 0)
- | ((y < 0) ? MOUSE_PS2_YNEG : 0);
- break;
-
- case MOUSE_MODEL_GENERIC:
- default:
- break;
- }
-
- /* scale values */
- if (sc->mode.accelfactor >= 1) {
- if (x != 0) {
- x = x * x / sc->mode.accelfactor;
- if (x == 0)
- x = 1;
- if (c & MOUSE_PS2_XNEG)
- x = -x;
- }
- if (y != 0) {
- y = y * y / sc->mode.accelfactor;
- if (y == 0)
- y = 1;
- if (c & MOUSE_PS2_YNEG)
- y = -y;
- }
- }
-
- ms.dx = x;
- ms.dy = y;
- ms.dz = z;
- ms.flags = ((x || y || z) ? MOUSE_POSCHANGED : 0)
- | (ms.obutton ^ ms.button);
-
- if (sc->mode.level < PSM_LEVEL_NATIVE)
- sc->inputbytes = tame_mouse(sc, &ms, sc->ipacket);
-
- sc->status.flags |= ms.flags;
- sc->status.dx += ms.dx;
- sc->status.dy += ms.dy;
- sc->status.dz += ms.dz;
- sc->status.button = ms.button;
- sc->button = ms.button;
-
- /* queue data */
- if (sc->queue.count + sc->inputbytes < sizeof(sc->queue.buf)) {
- l = min(sc->inputbytes, sizeof(sc->queue.buf) - sc->queue.tail);
- bcopy(&sc->ipacket[0], &sc->queue.buf[sc->queue.tail], l);
- if (sc->inputbytes > l)
- bcopy(&sc->ipacket[l], &sc->queue.buf[0], sc->inputbytes - l);
- sc->queue.tail =
- (sc->queue.tail + sc->inputbytes) % sizeof(sc->queue.buf);
- sc->queue.count += sc->inputbytes;
- }
- sc->inputbytes = 0;
-
- if (sc->state & PSM_ASLP) {
- sc->state &= ~PSM_ASLP;
- wakeup((caddr_t) sc);
- }
- selwakeup(&sc->rsel);
- }
-}
-
-static int
-psmpoll(dev_t dev, int events, struct proc *p)
-{
- struct psm_softc *sc = PSM_SOFTC(PSM_UNIT(dev));
- int s;
- int revents = 0;
-
- /* Return true if a mouse event available */
- s = spltty();
- if (events & (POLLIN | POLLRDNORM)) {
- if (sc->queue.count > 0)
- revents |= events & (POLLIN | POLLRDNORM);
- else
- selrecord(p, &sc->rsel);
- }
- splx(s);
-
- return (revents);
-}
-
-/* vendor/model specific routines */
-
-static int mouse_id_proc1(KBDC kbdc, int res, int scale, int *status)
-{
- if (set_mouse_resolution(kbdc, res) != res)
- return FALSE;
- if (set_mouse_scaling(kbdc, scale)
- && set_mouse_scaling(kbdc, scale)
- && set_mouse_scaling(kbdc, scale)
- && (get_mouse_status(kbdc, status, 0, 3) >= 3))
- return TRUE;
- return FALSE;
-}
-
-#if notyet
-/* Logitech MouseMan Cordless II */
-static int
-enable_lcordless(struct psm_softc *sc)
-{
- int status[3];
- int ch;
-
- if (!mouse_id_proc1(sc->kbdc, PSMD_RES_HIGH, 2, status))
- return FALSE;
- if (status[1] == PSMD_RES_HIGH)
- return FALSE;
- ch = (status[0] & 0x07) - 1; /* channel # */
- if ((ch <= 0) || (ch > 4))
- return FALSE;
- /*
- * status[1]: always one?
- * status[2]: battery status? (0-100)
- */
- return TRUE;
-}
-#endif /* notyet */
-
-/* Genius NetScroll Mouse */
-static int
-enable_groller(struct psm_softc *sc)
-{
- int status[3];
-
- /*
- * The special sequence to enable the fourth button and the
- * roller. Immediately after this sequence check status bytes.
- * if the mouse is NetScroll, the second and the third bytes are
- * '3' and 'D'.
- */
-
- /*
- * If the mouse is an ordinary PS/2 mouse, the status bytes should
- * look like the following.
- *
- * byte 1 bit 7 always 0
- * bit 6 stream mode (0)
- * bit 5 disabled (0)
- * bit 4 1:1 scaling (0)
- * bit 3 always 0
- * bit 0-2 button status
- * byte 2 resolution (PSMD_RES_HIGH)
- * byte 3 report rate (?)
- */
-
- if (!mouse_id_proc1(sc->kbdc, PSMD_RES_HIGH, 1, status))
- return FALSE;
- if ((status[1] != '3') || (status[2] != 'D'))
- return FALSE;
- /* FIXME!! */
- sc->hw.buttons = get_mouse_buttons(sc->kbdc);
- sc->hw.buttons = 4;
- return TRUE;
-}
-
-/* Genius NetMouse/NetMouse Pro */
-static int
-enable_gmouse(struct psm_softc *sc)
-{
- int status[3];
-
- /*
- * The special sequence to enable the middle, "rubber" button.
- * Immediately after this sequence check status bytes.
- * if the mouse is NetMouse, NetMouse Pro, or ASCII MIE Mouse,
- * the second and the third bytes are '3' and 'U'.
- * NOTE: NetMouse reports that it has three buttons although it has
- * two buttons and a rubber button. NetMouse Pro and MIE Mouse
- * say they have three buttons too and they do have a button on the
- * side...
- */
- if (!mouse_id_proc1(sc->kbdc, PSMD_RES_HIGH, 1, status))
- return FALSE;
- if ((status[1] != '3') || (status[2] != 'U'))
- return FALSE;
- return TRUE;
-}
-
-/* ALPS GlidePoint */
-static int
-enable_aglide(struct psm_softc *sc)
-{
- int status[3];
-
- /*
- * The special sequence to obtain ALPS GlidePoint specific
- * information. Immediately after this sequence, status bytes will
- * contain something interesting.
- * NOTE: ALPS produces several models of GlidePoint. Some of those
- * do not respond to this sequence, thus, cannot be detected this way.
- */
- if (set_mouse_sampling_rate(sc->kbdc, 100) != 100)
- return FALSE;
- if (!mouse_id_proc1(sc->kbdc, PSMD_RES_LOW, 2, status))
- return FALSE;
- if ((status[1] == PSMD_RES_LOW) || (status[2] == 100))
- return FALSE;
- return TRUE;
-}
-
-/* Kensington ThinkingMouse/Trackball */
-static int
-enable_kmouse(struct psm_softc *sc)
-{
- static unsigned char rate[] = { 20, 60, 40, 20, 20, 60, 40, 20, 20 };
- KBDC kbdc = sc->kbdc;
- int status[3];
- int id1;
- int id2;
- int i;
-
- id1 = get_aux_id(kbdc);
- if (set_mouse_sampling_rate(kbdc, 10) != 10)
- return FALSE;
- /*
- * The device is now in the native mode? It returns a different
- * ID value...
- */
- id2 = get_aux_id(kbdc);
- if ((id1 == id2) || (id2 != 2))
- return FALSE;
-
- if (set_mouse_resolution(kbdc, PSMD_RES_LOW) != PSMD_RES_LOW)
- return FALSE;
-#if PSM_DEBUG >= 2
- /* at this point, resolution is LOW, sampling rate is 10/sec */
- if (get_mouse_status(kbdc, status, 0, 3) < 3)
- return FALSE;
-#endif
-
- /*
- * The special sequence to enable the third and fourth buttons.
- * Otherwise they behave like the first and second buttons.
- */
- for (i = 0; i < sizeof(rate)/sizeof(rate[0]); ++i) {
- if (set_mouse_sampling_rate(kbdc, rate[i]) != rate[i])
- return FALSE;
- }
-
- /*
- * At this point, the device is using default resolution and
- * sampling rate for the native mode.
- */
- if (get_mouse_status(kbdc, status, 0, 3) < 3)
- return FALSE;
- if ((status[1] == PSMD_RES_LOW) || (status[2] == rate[i - 1]))
- return FALSE;
-
- /* the device appears be enabled by this sequence, diable it for now */
- disable_aux_dev(kbdc);
- empty_aux_buffer(kbdc, 5);
-
- return TRUE;
-}
-
-/* Logitech MouseMan+/FirstMouse+ */
-static int
-enable_mmanplus(struct psm_softc *sc)
-{
- static char res[] = {
- -1, PSMD_RES_LOW, PSMD_RES_HIGH, PSMD_RES_MEDIUM_HIGH,
- PSMD_RES_MEDIUM_LOW, -1, PSMD_RES_HIGH, PSMD_RES_MEDIUM_LOW,
- PSMD_RES_MEDIUM_HIGH, PSMD_RES_HIGH,
- };
- KBDC kbdc = sc->kbdc;
- int data[3];
- int i;
-
- /* the special sequence to enable the fourth button and the roller. */
- for (i = 0; i < sizeof(res)/sizeof(res[0]); ++i) {
- if (res[i] < 0) {
- if (!set_mouse_scaling(kbdc, 1))
- return FALSE;
- } else {
- if (set_mouse_resolution(kbdc, res[i]) != res[i])
- return FALSE;
- }
- }
-
- if (get_mouse_status(kbdc, data, 1, 3) < 3)
- return FALSE;
-
- /*
- * PS2++ protocl, packet type 0
- *
- * b7 b6 b5 b4 b3 b2 b1 b0
- * byte 1: * 1 p3 p2 1 * * *
- * byte 2: 1 1 p1 p0 m1 m0 1 0
- * byte 3: m7 m6 m5 m4 m3 m2 m1 m0
- *
- * p3-p0: packet type: 0
- * m7-m0: model ID: MouseMan+:0x50, FirstMouse+:0x51,...
- */
- /* check constant bits */
- if ((data[0] & MOUSE_PS2PLUS_SYNCMASK) != MOUSE_PS2PLUS_SYNC)
- return FALSE;
- if ((data[1] & 0xc3) != 0xc2)
- return FALSE;
- /* check d3-d0 in byte 2 */
- if (!MOUSE_PS2PLUS_CHECKBITS(data))
- return FALSE;
- /* check p3-p0 */
- if (MOUSE_PS2PLUS_PACKET_TYPE(data) != 0)
- return FALSE;
-
- sc->hw.hwid &= 0x00ff;
- sc->hw.hwid |= data[2] << 8; /* save model ID */
-
- /*
- * MouseMan+ (or FirstMouse+) is now in its native mode, in which
- * the wheel and the fourth button events are encoded in the
- * special data packet. The mouse may be put in the IntelliMouse mode
- * if it is initialized by the IntelliMouse's method.
- */
- return TRUE;
-}
-
-/* MS IntelliMouse */
-static int
-enable_msintelli(struct psm_softc *sc)
-{
- /*
- * Logitech MouseMan+ and FirstMouse+ will also respond to this
- * probe routine and act like IntelliMouse.
- */
-
- static unsigned char rate[] = { 200, 100, 80, };
- KBDC kbdc = sc->kbdc;
- int id;
- int i;
-
- /* the special sequence to enable the third button and the roller. */
- for (i = 0; i < sizeof(rate)/sizeof(rate[0]); ++i) {
- if (set_mouse_sampling_rate(kbdc, rate[i]) != rate[i])
- return FALSE;
- }
- /* the device will give the genuine ID only after the above sequence */
- id = get_aux_id(kbdc);
- if (id != PSM_INTELLI_ID)
- return FALSE;
-
- sc->hw.hwid = id;
- sc->hw.buttons = 3;
-
- return TRUE;
-}
-
-/* Interlink electronics VersaPad */
-static int
-enable_versapad(struct psm_softc *sc)
-{
- KBDC kbdc = sc->kbdc;
- int data[3];
-
- set_mouse_resolution(kbdc, PSMD_RES_MEDIUM_HIGH); /* set res. 2 */
- set_mouse_sampling_rate(kbdc, 100); /* set rate 100 */
- set_mouse_scaling(kbdc, 1); /* set scale 1:1 */
- set_mouse_scaling(kbdc, 1); /* set scale 1:1 */
- set_mouse_scaling(kbdc, 1); /* set scale 1:1 */
- set_mouse_scaling(kbdc, 1); /* set scale 1:1 */
- if (get_mouse_status(kbdc, data, 0, 3) < 3) /* get status */
- return FALSE;
- if (data[2] != 0xa || data[1] != 0 ) /* rate == 0xa && res. == 0 */
- return FALSE;
- set_mouse_scaling(kbdc, 1); /* set scale 1:1 */
-
- return TRUE; /* PS/2 absolute mode */
-}
-
-static int
-psmresume(device_t dev)
-{
-#ifdef PSM_HOOKRESUME
- struct psm_softc *sc = device_get_softc(dev);
- int unit = device_get_unit(dev);
- int err = 0;
- int s;
- int c;
-
- if (verbose >= 2)
- log(LOG_NOTICE, "psm%d: system resume hook called.\n", unit);
-
- /* don't let anybody mess with the aux device */
- if (!kbdc_lock(sc->kbdc, TRUE))
- return (EIO);
- s = spltty();
-
- /* save the current controller command byte */
- empty_both_buffers(sc->kbdc, 10);
- c = get_controller_command_byte(sc->kbdc);
- if (verbose >= 2)
- log(LOG_DEBUG, "psm%d: current command byte: %04x (psmresume).\n",
- unit, c);
-
- /* enable the aux port but disable the aux interrupt and the keyboard */
- if ((c == -1) || !set_controller_command_byte(sc->kbdc,
- kbdc_get_device_mask(sc->kbdc),
- KBD_DISABLE_KBD_PORT | KBD_DISABLE_KBD_INT
- | KBD_ENABLE_AUX_PORT | KBD_DISABLE_AUX_INT)) {
- /* CONTROLLER ERROR */
- splx(s);
- kbdc_lock(sc->kbdc, FALSE);
- log(LOG_ERR, "psm%d: unable to set the command byte (psmresume).\n",
- unit);
- return (EIO);
- }
-
- /* flush any data */
- if (sc->state & PSM_VALID) {
- disable_aux_dev(sc->kbdc); /* this may fail; but never mind... */
- empty_aux_buffer(sc->kbdc, 10);
- }
- sc->inputbytes = 0;
-
-#ifdef PSM_RESETAFTERSUSPEND
- /* try to detect the aux device; are you still there? */
- if (reinitialize(unit, &sc->mode)) {
- /* yes */
- sc->state |= PSM_VALID;
- } else {
- /* the device has gone! */
- restore_controller(sc->kbdc, c);
- sc->state &= ~PSM_VALID;
- log(LOG_ERR, "psm%d: the aux device has gone! (psmresume).\n",
- unit);
- err = ENXIO;
- }
-#endif /* PSM_RESETAFTERSUSPEND */
- splx(s);
-
- /* restore the driver state */
- if ((sc->state & PSM_OPEN) && (err == 0)) {
- /* enable the aux device and the port again */
- err = doopen(unit, c);
- if (err != 0)
- log(LOG_ERR, "psm%d: failed to enable the device (psmresume).\n",
- unit);
- } else {
- /* restore the keyboard port and disable the aux port */
- if (!set_controller_command_byte(sc->kbdc,
- kbdc_get_device_mask(sc->kbdc),
- (c & KBD_KBD_CONTROL_BITS)
- | KBD_DISABLE_AUX_PORT | KBD_DISABLE_AUX_INT)) {
- /* CONTROLLER ERROR */
- log(LOG_ERR, "psm%d: failed to disable the aux port (psmresume).\n",
- unit);
- err = EIO;
- }
- }
-
- /* done */
- kbdc_lock(sc->kbdc, FALSE);
- if ((sc->state & PSM_ASLP) && !(sc->state & PSM_VALID)) {
- /*
- * Release the blocked process; it must be notified that the device
- * cannot be accessed anymore.
- */
- sc->state &= ~PSM_ASLP;
- wakeup((caddr_t)sc);
- }
-
- if (verbose >= 2)
- log(LOG_DEBUG, "psm%d: system resume hook exiting.\n", unit);
-
- return (err);
-#else /* !PSM_HOOKRESUME */
- return (0);
-#endif /* PSM_HOOKRESUME */
-}
-
-DRIVER_MODULE(psm, atkbdc, psm_driver, psm_devclass, 0, 0);
diff --git a/sys/dev/bktr/ioctl_bt848.h b/sys/dev/bktr/ioctl_bt848.h
deleted file mode 100644
index 95538f9ac86f..000000000000
--- a/sys/dev/bktr/ioctl_bt848.h
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
- * extensions to ioctl_meteor.h for the bt848 cards
- *
- * $FreeBSD$
- */
-
-/*
- * frequency sets
- */
-#define CHNLSET_NABCST 1
-#define CHNLSET_CABLEIRC 2
-#define CHNLSET_CABLEHRC 3
-#define CHNLSET_WEUROPE 4
-#define CHNLSET_JPNBCST 5
-#define CHNLSET_JPNCABLE 6
-#define CHNLSET_XUSSR 7
-#define CHNLSET_AUSTRALIA 8
-#define CHNLSET_FRANCE 9
-#define CHNLSET_MIN CHNLSET_NABCST
-#define CHNLSET_MAX CHNLSET_FRANCE
-
-
-/*
- * constants for various tuner registers
- */
-#define BT848_HUEMIN (-90)
-#define BT848_HUEMAX 90
-#define BT848_HUECENTER 0
-#define BT848_HUERANGE 179.3
-#define BT848_HUEREGMIN (-128)
-#define BT848_HUEREGMAX 127
-#define BT848_HUESTEPS 256
-
-#define BT848_BRIGHTMIN (-50)
-#define BT848_BRIGHTMAX 50
-#define BT848_BRIGHTCENTER 0
-#define BT848_BRIGHTRANGE 99.6
-#define BT848_BRIGHTREGMIN (-128)
-#define BT848_BRIGHTREGMAX 127
-#define BT848_BRIGHTSTEPS 256
-
-#define BT848_CONTRASTMIN 0
-#define BT848_CONTRASTMAX 237
-#define BT848_CONTRASTCENTER 100
-#define BT848_CONTRASTRANGE 236.57
-#define BT848_CONTRASTREGMIN 0
-#define BT848_CONTRASTREGMAX 511
-#define BT848_CONTRASTSTEPS 512
-
-#define BT848_CHROMAMIN 0
-#define BT848_CHROMAMAX 284
-#define BT848_CHROMACENTER 100
-#define BT848_CHROMARANGE 283.89
-#define BT848_CHROMAREGMIN 0
-#define BT848_CHROMAREGMAX 511
-#define BT848_CHROMASTEPS 512
-
-#define BT848_SATUMIN 0
-#define BT848_SATUMAX 202
-#define BT848_SATUCENTER 100
-#define BT848_SATURANGE 201.18
-#define BT848_SATUREGMIN 0
-#define BT848_SATUREGMAX 511
-#define BT848_SATUSTEPS 512
-
-#define BT848_SATVMIN 0
-#define BT848_SATVMAX 284
-#define BT848_SATVCENTER 100
-#define BT848_SATVRANGE 283.89
-#define BT848_SATVREGMIN 0
-#define BT848_SATVREGMAX 511
-#define BT848_SATVSTEPS 512
-
-
-/*
- * audio stuff
- */
-#define AUDIO_TUNER 0x00 /* command for the audio routine */
-#define AUDIO_EXTERN 0x01 /* don't confuse them with bit */
-#define AUDIO_INTERN 0x02 /* settings */
-#define AUDIO_MUTE 0x80
-#define AUDIO_UNMUTE 0x81
-
-
-/*
- * EEProm stuff
- */
-struct eeProm {
- short offset;
- short count;
- u_char bytes[ 256 ];
-};
-
-
-/*
- * XXX: this is a hack, should be in ioctl_meteor.h
- * here to avoid touching that file for now...
- */
-#define TVTUNER_SETCHNL _IOW('x', 32, unsigned int) /* set channel */
-#define TVTUNER_GETCHNL _IOR('x', 32, unsigned int) /* get channel */
-#define TVTUNER_SETTYPE _IOW('x', 33, unsigned int) /* set tuner type */
-#define TVTUNER_GETTYPE _IOR('x', 33, unsigned int) /* get tuner type */
-#define TVTUNER_GETSTATUS _IOR('x', 34, unsigned int) /* get tuner status */
-#define TVTUNER_SETFREQ _IOW('x', 35, unsigned int) /* set frequency */
-#define TVTUNER_GETFREQ _IOR('x', 36, unsigned int) /* get frequency */
-
-
-#define BT848_SHUE _IOW('x', 37, int) /* set hue */
-#define BT848_GHUE _IOR('x', 37, int) /* get hue */
-#define BT848_SBRIG _IOW('x', 38, int) /* set brightness */
-#define BT848_GBRIG _IOR('x', 38, int) /* get brightness */
-#define BT848_SCSAT _IOW('x', 39, int) /* set chroma sat */
-#define BT848_GCSAT _IOR('x', 39, int) /* get UV saturation */
-#define BT848_SCONT _IOW('x', 40, int) /* set contrast */
-#define BT848_GCONT _IOR('x', 40, int) /* get contrast */
-#define BT848_SVSAT _IOW('x', 41, int) /* set chroma V sat */
-#define BT848_GVSAT _IOR('x', 41, int) /* get V saturation */
-#define BT848_SUSAT _IOW('x', 42, int) /* set chroma U sat */
-#define BT848_GUSAT _IOR('x', 42, int) /* get U saturation */
-
-#define BT848_SCBARS _IOR('x', 43, int) /* set colorbar */
-#define BT848_CCBARS _IOR('x', 44, int) /* clear colorbar */
-
-
-#define BT848_SAUDIO _IOW('x', 46, int) /* set audio channel */
-#define BT848_GAUDIO _IOR('x', 47, int) /* get audio channel */
-#define BT848_SBTSC _IOW('x', 48, int) /* set audio channel */
-
-#define BT848_GSTATUS _IOR('x', 49, unsigned int) /* reap status */
-
-#define BT848_WEEPROM _IOWR('x', 50, struct eeProm) /* write to EEProm */
-#define BT848_REEPROM _IOWR('x', 51, struct eeProm) /* read from EEProm */
-
-#define BT848_SIGNATURE _IOWR('x', 52, struct eeProm) /* read card sig */
-
-#define TVTUNER_SETAFC _IOW('x', 53, int) /* turn AFC on/off */
-#define TVTUNER_GETAFC _IOR('x', 54, int) /* query AFC on/off */
-#define BT848_SLNOTCH _IOW('x', 55, int) /* set luma notch */
-#define BT848_GLNOTCH _IOR('x', 56, int) /* get luma notch */
-
-/* Read/Write the BT848's I2C bus directly
- * b7-b0: data (read/write)
- * b15-b8: internal peripheral register (write)
- * b23-b16: i2c addr (write)
- * b31-b24: 1 = write, 0 = read
- */
-#define BT848_I2CWR _IOWR('x', 57, u_long) /* i2c read-write */
-
-/* Support for radio tuner */
-#define RADIO_SETMODE _IOW('x', 58, unsigned int) /* set radio modes */
-#define RADIO_GETMODE _IOR('x', 58, unsigned char) /* get radio modes */
-#define RADIO_AFC 0x01 /* These modes will probably not */
-#define RADIO_MONO 0x02 /* work on the FRxxxx. It does */
-#define RADIO_MUTE 0x08 /* work on the FMxxxx. */
-#define RADIO_SETFREQ _IOW('x', 59, unsigned int) /* set frequency */
-#define RADIO_GETFREQ _IOR('x', 59, unsigned int) /* set frequency */
- /* Argument is frequency*100MHz */
-
-/*
- * XXX: more bad magic,
- * we need to fix the METEORGINPUT to return something public
- * duplicate them here for now...
- */
-#define METEOR_DEV0 0x00001000
-#define METEOR_DEV1 0x00002000
-#define METEOR_DEV2 0x00004000
-#define METEOR_DEV3 0x00008000
-#define METEOR_DEV_SVIDEO 0x00006000
-/*
- * right now I don't know were to put these, but as they are suppose to be
- * a part of a common video capture interface, these should be relocated to
- * another place. Probably most of the METEOR_xxx defines need to be
- * renamed and moved to a common header
- */
-
-typedef enum { METEOR_PIXTYPE_RGB, METEOR_PIXTYPE_YUV,
- METEOR_PIXTYPE_YUV_PACKED,
- METEOR_PIXTYPE_YUV_12 } METEOR_PIXTYPE;
-
-
-struct meteor_pixfmt {
- u_int index; /* Index in supported pixfmt list */
- METEOR_PIXTYPE type; /* What's the board gonna feed us */
- u_int Bpp; /* Bytes per pixel */
- u_long masks[3]; /* R,G,B or Y,U,V masks, respectively */
- unsigned swap_bytes :1; /* Bytes swapped within shorts */
- unsigned swap_shorts:1; /* Shorts swapped within longs */
-};
-
-
-struct bktr_clip {
- int x_min;
- int x_max;
- int y_min;
- int y_max;
-};
-
-#define BT848_MAX_CLIP_NODE 100
-struct _bktr_clip {
- struct bktr_clip x[BT848_MAX_CLIP_NODE];
-};
-
-/*
- * I'm using METEOR_xxx just because that will be common to other interface
- * and less of a surprise
- */
-#define METEORSACTPIXFMT _IOW('x', 64, int )
-#define METEORGACTPIXFMT _IOR('x', 64, int )
-#define METEORGSUPPIXFMT _IOWR('x', 65, struct meteor_pixfmt)
-
-/* set clip list */
-#define BT848SCLIP _IOW('x', 66, struct _bktr_clip )
-#define BT848GCLIP _IOR('x', 66, struct _bktr_clip )
-
-
-/* set input format */
-#define BT848SFMT _IOW('x', 67, unsigned long )
-#define BT848GFMT _IOR('x', 67, unsigned long )
-
-/* set clear-buffer-on-start */
-#define BT848SCBUF _IOW('x', 68, int)
-#define BT848GCBUF _IOR('x', 68, int)
-
-/* set capture area */
-/* The capture area is the area of the video image which is grabbed */
-/* Usually the capture area is 640x480 (768x576 PAL) pixels */
-/* This area is then scaled to the dimensions the user requires */
-/* using the METEORGEO ioctl */
-/* However, the capture area could be 400x300 pixels from the top right */
-/* corner of the video image */
-struct bktr_capture_area {
- int x_offset;
- int y_offset;
- int x_size;
- int y_size;
-};
-#define BT848_SCAPAREA _IOW('x', 69, struct bktr_capture_area)
-#define BT848_GCAPAREA _IOR('x', 69, struct bktr_capture_area)
-
-
-/* Get channel Set */
-#define BT848_MAX_CHNLSET_NAME_LEN 16
-struct bktr_chnlset {
- short index;
- short max_channel;
- char name[BT848_MAX_CHNLSET_NAME_LEN];
-};
-#define TVTUNER_GETCHNLSET _IOWR('x', 70, struct bktr_chnlset)
-
-
-
-/* Infra Red Remote Control */
-struct bktr_remote {
- unsigned char data[3];
-};
-#define REMOTE_GETKEY _IOR('x', 71, struct bktr_remote)/*read the remote */
- /*control receiver*/
- /*returns raw data*/
-
-
-/*
- * Direct access to GPIO pins. You must add BKTR_GPIO_ACCESS to your kernel
- * configuration file to use these
- */
-#define BT848_GPIO_SET_EN _IOW('x', 72, int) /* set gpio_out_en */
-#define BT848_GPIO_GET_EN _IOR('x', 73, int) /* get gpio_out_en */
-#define BT848_GPIO_SET_DATA _IOW('x', 74, int) /* set gpio_data */
-#define BT848_GPIO_GET_DATA _IOR('x', 75, int) /* get gpio_data */
-
-
-
-/* XXX - Copied from /sys/pci/brktree_reg.h */
-#define BT848_IFORM_FORMAT (0x7<<0)
-# define BT848_IFORM_F_RSVD (0x7)
-# define BT848_IFORM_F_SECAM (0x6)
-# define BT848_IFORM_F_PALN (0x5)
-# define BT848_IFORM_F_PALM (0x4)
-# define BT848_IFORM_F_PALBDGHI (0x3)
-# define BT848_IFORM_F_NTSCJ (0x2)
-# define BT848_IFORM_F_NTSCM (0x1)
-# define BT848_IFORM_F_AUTO (0x0)
-
diff --git a/sys/dev/bktr/ioctl_meteor.h b/sys/dev/bktr/ioctl_meteor.h
deleted file mode 100644
index f62d392ea0ae..000000000000
--- a/sys/dev/bktr/ioctl_meteor.h
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Copyright (c) 1995 Mark Tinguely and Jim Lowe
- * 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 Mark Tinguely and Jim Lowe
- * 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.
- *
- * $FreeBSD$
- */
-/*
- * ioctl constants for Matrox Meteor Capture card.
- */
-
-#ifndef _MACHINE_IOCTL_METEOR_H_
-#define _MACHINE_IOCTL_METEOR_H_
-
-#ifndef _KERNEL
-#include <sys/types.h>
-#endif
-#include <sys/ioccom.h>
-
-struct meteor_capframe {
- short command; /* see below for valid METEORCAPFRM commands */
- short lowat; /* start transfer if < this number */
- short hiwat; /* stop transfer if > this number */
-} ;
-
-/* structure for METEOR[GS]ETGEO - get/set geometry */
-struct meteor_geomet {
- u_short rows;
- u_short columns;
- u_short frames;
- u_long oformat;
-} ;
-
-/* structure for METEORGCOUNT-get count of frames, fifo errors and dma errors */
-struct meteor_counts {
- u_long fifo_errors; /* count of fifo errors since open */
- u_long dma_errors; /* count of dma errors since open */
- u_long frames_captured; /* count of frames captured since open */
- u_long even_fields_captured; /* count of even fields captured */
- u_long odd_fields_captured; /* count of odd fields captured */
-} ;
-
-/* structure for getting and setting direct transfers to vram */
-struct meteor_video {
- u_long addr; /* Address of location to dma to */
- u_long width; /* Width of memory area */
- u_long banksize; /* Size of Vram bank */
- u_long ramsize; /* Size of Vram */
-};
-
-#define METEORCAPTUR _IOW('x', 1, int) /* capture a frame */
-#define METEORCAPFRM _IOW('x', 2, struct meteor_capframe) /* sync capture */
-#define METEORSETGEO _IOW('x', 3, struct meteor_geomet) /* set geometry */
-#define METEORGETGEO _IOR('x', 4, struct meteor_geomet) /* get geometry */
-#define METEORSTATUS _IOR('x', 5, unsigned short) /* get status */
-#define METEORSHUE _IOW('x', 6, signed char) /* set hue */
-#define METEORGHUE _IOR('x', 6, signed char) /* get hue */
-#define METEORSFMT _IOW('x', 7, unsigned long) /* set format */
-#define METEORGFMT _IOR('x', 7, unsigned long) /* get format */
-#define METEORSINPUT _IOW('x', 8, unsigned long) /* set input dev */
-#define METEORGINPUT _IOR('x', 8, unsigned long) /* get input dev */
-#define METEORSCHCV _IOW('x', 9, unsigned char) /* set uv gain */
-#define METEORGCHCV _IOR('x', 9, unsigned char) /* get uv gain */
-#define METEORSCOUNT _IOW('x',10, struct meteor_counts)
-#define METEORGCOUNT _IOR('x',10, struct meteor_counts)
-#define METEORSFPS _IOW('x',11, unsigned short) /* set fps */
-#define METEORGFPS _IOR('x',11, unsigned short) /* get fps */
-#define METEORSSIGNAL _IOW('x', 12, unsigned int) /* set signal */
-#define METEORGSIGNAL _IOR('x', 12, unsigned int) /* get signal */
-#define METEORSVIDEO _IOW('x', 13, struct meteor_video) /* set video */
-#define METEORGVIDEO _IOR('x', 13, struct meteor_video) /* get video */
-#define METEORSBRIG _IOW('x', 14, unsigned char) /* set brightness */
-#define METEORGBRIG _IOR('x', 14, unsigned char) /* get brightness */
-#define METEORSCSAT _IOW('x', 15, unsigned char) /* set chroma sat */
-#define METEORGCSAT _IOR('x', 15, unsigned char) /* get uv saturation */
-#define METEORSCONT _IOW('x', 16, unsigned char) /* set contrast */
-#define METEORGCONT _IOR('x', 16, unsigned char) /* get contrast */
-#define METEORSBT254 _IOW('x', 17, unsigned short) /* set Bt254 reg */
-#define METEORGBT254 _IOR('x', 17, unsigned short) /* get Bt254 reg */
-#define METEORSHWS _IOW('x', 18, unsigned char) /* set hor start reg */
-#define METEORGHWS _IOR('x', 18, unsigned char) /* get hor start reg */
-#define METEORSVWS _IOW('x', 19, unsigned char) /* set vert start reg */
-#define METEORGVWS _IOR('x', 19, unsigned char) /* get vert start reg */
-#define METEORSTS _IOW('x', 20, unsigned char) /* set time stamp */
-#define METEORGTS _IOR('x', 20, unsigned char) /* get time stamp */
-
-#define METEOR_STATUS_ID_MASK 0xf000 /* ID of 7196 */
-#define METEOR_STATUS_DIR 0x0800 /* Direction of Expansion port YUV */
-#define METEOR_STATUS_OEF 0x0200 /* Field detected: Even/Odd */
-#define METEOR_STATUS_SVP 0x0100 /* State of VRAM Port:inactive/active */
-#define METEOR_STATUS_STTC 0x0080 /* Time Constant: TV/VCR */
-#define METEOR_STATUS_HCLK 0x0040 /* Horiz PLL: locked/unlocked */
-#define METEOR_STATUS_FIDT 0x0020 /* Field detect: 50/60hz */
-#define METEOR_STATUS_ALTD 0x0002 /* Line alt: no line alt/line alt */
-#define METEOR_STATUS_CODE 0x0001 /* Colour info: no colour/colour */
-
- /* METEORCAPTUR capture options */
-#define METEOR_CAP_SINGLE 0x0001 /* capture one frame */
-#define METEOR_CAP_CONTINOUS 0x0002 /* continuously capture */
-#define METEOR_CAP_STOP_CONT 0x0004 /* stop the continuous capture */
-
- /* METEORCAPFRM capture commands */
-#define METEOR_CAP_N_FRAMES 0x0001 /* capture N frames */
-#define METEOR_CAP_STOP_FRAMES 0x0002 /* stop capture N frames */
-#define METEOR_HALT_N_FRAMES 0x0003 /* halt of capture N frames */
-#define METEOR_CONT_N_FRAMES 0x0004 /* continue after above halt */
-
- /* valid video input formats: */
-#define METEOR_FMT_NTSC 0x00100 /* NTSC -- initialized default */
-#define METEOR_FMT_PAL 0x00200 /* PAL */
-#define METEOR_FMT_SECAM 0x00400 /* SECAM */
-#define METEOR_FMT_AUTOMODE 0x00800 /* auto-mode */
-#define METEOR_INPUT_DEV0 0x01000 /* camera input 0 -- default */
-#define METEOR_INPUT_DEV_RCA METEOR_INPUT_DEV0
-#define METEOR_INPUT_DEV1 0x02000 /* camera input 1 */
-#define METEOR_INPUT_DEV2 0x04000 /* camera input 2 */
-#define METEOR_INPUT_DEV3 0x08000 /* camera input 3 */
-#define METEOR_INPUT_DEV_RGB 0x0a000 /* for rgb version of meteor */
-#define METEOR_INPUT_DEV_SVIDEO 0x06000 /* S-video input port */
-
- /* valid video output formats: */
-#define METEOR_GEO_RGB16 0x0010000 /* packed -- initialized default */
-#define METEOR_GEO_RGB24 0x0020000 /* RBG 24 bits packed */
- /* internally stored in 32 bits */
-#define METEOR_GEO_YUV_PACKED 0x0040000 /* 4-2-2 YUV 16 bits packed */
-#define METEOR_GEO_YUV_PLANAR 0x0080000 /* 4-2-2 YUV 16 bits planer */
-#define METEOR_GEO_YUV_PLANER METEOR_GEO_YUV_PLANAR
-#define METEOR_GEO_UNSIGNED 0x0400000 /* unsigned uv outputs */
-#define METEOR_GEO_EVEN_ONLY 0x1000000 /* set for even only field capture */
-#define METEOR_GEO_ODD_ONLY 0x2000000 /* set for odd only field capture */
-#define METEOR_GEO_FIELD_MASK 0x3000000
-#define METEOR_GEO_YUV_422 0x4000000 /* 4-2-2 YUV in Y-U-V combined */
-#define METEOR_GEO_OUTPUT_MASK 0x40f0000
-#define METEOR_GEO_YUV_12 0x10000000 /* YUV 12 format */
-#define METEOR_GEO_YUV_9 0x40000000 /* YUV 9 format */
-
-#define METEOR_FIELD_MODE 0x80000000 /* Field cap or Frame cap */
-
-#define METEOR_SIG_MODE_MASK 0xffff0000
-#define METEOR_SIG_FRAME 0x00000000 /* signal every frame */
-#define METEOR_SIG_FIELD 0x00010000 /* signal every field */
-
- /* following structure is used to coordinate the synchronous */
-
-struct meteor_mem {
- /* kernel write only */
- int frame_size; /* row*columns*depth */
- unsigned num_bufs; /* number of frames in buffer (1-32) */
- /* user and kernel change these */
- int lowat; /* kernel starts capture if < this number */
- int hiwat; /* kernel stops capture if > this number.
- hiwat <= numbufs */
- unsigned active; /* bit mask of active frame buffers
- kernel sets, user clears */
- int num_active_bufs; /* count of active frame buffer
- kernel increments, user decrements */
-
- /* reference to mmapped data */
- caddr_t buf; /* The real space (virtual addr) */
-} ;
-
-#endif /* !_MACHINE_IOCTL_METEOR_H_ */
diff --git a/sys/dev/cs/if_cs.c b/sys/dev/cs/if_cs.c
deleted file mode 100644
index 29f91b99cd2f..000000000000
--- a/sys/dev/cs/if_cs.c
+++ /dev/null
@@ -1,1388 +0,0 @@
-/*
- * Copyright (c) 1997,1998 Maxim Bolotin and Oleg Sharoiko.
- * 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 unmodified, 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 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 AUTHOR 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.
- *
- */
-
-/*
- * $FreeBSD$
- *
- * Device driver for Crystal Semiconductor CS8920 based ethernet
- * adapters. By Maxim Bolotin and Oleg Sharoiko, 27-April-1997
- */
-
-/* #define CS_DEBUG */
-#include "cs.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/malloc.h>
-#include <sys/sockio.h>
-#include <sys/kernel.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <sys/sysctl.h>
-#include <sys/syslog.h>
-
-#include <net/if.h>
-#include <net/if_arp.h>
-#include <net/if_media.h>
-#include <net/ethernet.h>
-
-#include <net/bpf.h>
-
-#include <machine/clock.h>
-
-#include <i386/isa/isa_device.h>
-#include <i386/isa/if_csreg.h>
-
-/* #include "pnp.h" */
-#define NPNP 0
-
-#if NPNP > 0
-#include <i386/isa/pnp.h>
-#endif
-
-#ifdef CS_USE_64K_DMA
-#define CS_DMA_BUFFER_SIZE 65536
-#else
-#define CS_DMA_BUFFER_SIZE 16384
-#endif
-
-/*
- * cs_softc: per line info and status
- */
-static struct cs_softc {
-
- /* Ethernet common code */
- struct arpcom arpcom;
-
- /* Configuration words from EEPROM */
- int auto_neg_cnf; /* AutoNegotitation configuration */
- int adapter_cnf; /* Adapter configuration */
- int isa_config; /* ISA configuration */
- int chip_type; /* Type of chip */
-
- struct ifmedia media; /* Media information */
-
- int nic_addr; /* Base IO address of card */
- int send_cmd;
- int line_ctl; /* */
- int send_underrun;
- void *recv_ring;
-
- unsigned char *buffer;
- int buf_len;
-
-} cs_softc[NCS];
-
-#if NPNP > 0
-static u_long cs_unit = NCS;
-#endif
-
-static int cs_recv_delay = 570;
-SYSCTL_INT(_machdep, OID_AUTO, cs_recv_delay, CTLFLAG_RW, &cs_recv_delay, 0, "");
-
-static int cs_attach __P((struct cs_softc *, int, int));
-static int cs_attach_isa __P((struct isa_device *));
-static void cs_init __P((void *));
-static ointhand2_t csintr;
-static int cs_ioctl __P((struct ifnet *, u_long, caddr_t));
-static int cs_probe __P((struct isa_device *));
-static int cs_cs89x0_probe __P((struct cs_softc *,
- u_int *, int *, int, int, int));
-static void cs_start __P((struct ifnet *));
-static void cs_stop __P((struct cs_softc *));
-static void cs_reset __P((struct cs_softc *));
-static void cs_watchdog __P((struct ifnet *));
-
-static int cs_mediachange __P((struct ifnet *));
-static void cs_mediastatus __P((struct ifnet *, struct ifmediareq *));
-static int cs_mediaset __P((struct cs_softc *, int));
-
-static void cs_write_mbufs(struct cs_softc*, struct mbuf*);
-static void cs_xmit_buf(struct cs_softc*);
-static int cs_get_packet(struct cs_softc*);
-static void cs_setmode(struct cs_softc*);
-
-static int get_eeprom_data(struct cs_softc *sc, int, int, int *);
-static int get_eeprom_cksum(int, int, int *);
-static int wait_eeprom_ready( struct cs_softc *);
-static void control_dc_dc( struct cs_softc *, int );
-static int send_test_pkt( struct cs_softc * );
-static int enable_tp(struct cs_softc *);
-static int enable_aui(struct cs_softc *);
-static int enable_bnc(struct cs_softc *);
-static int cs_duplex_auto(struct cs_softc *);
-
-struct isa_driver csdriver = {
- cs_probe,
- cs_attach_isa,
- CS_NAME,
- 0
-};
-
-static int
-get_eeprom_data( struct cs_softc *sc, int off, int len, int *buffer)
-{
- int i;
-
-#ifdef CS_DEBUG
- printf(CS_NAME":EEPROM data from %x for %x:\n", off,len);
-#endif
-
- for (i=0;i<len;i++) {
- if (wait_eeprom_ready(sc) < 0) return -1;
- /* Send command to EEPROM to read */
- cs_writereg(sc->nic_addr, PP_EECMD, (off+i)|EEPROM_READ_CMD );
- if (wait_eeprom_ready(sc)<0)
- return -1;
- buffer[i] = cs_readreg (sc->nic_addr, PP_EEData);
-
-#ifdef CS_DEBUG
- printf("%02x %02x ",(unsigned char)buffer[i],
- (unsigned char)buffer[i+1]);
-#endif
- }
-
-#ifdef CS_DEBUG
- printf("\n");
-#endif
-
- return 0;
-}
-
-static int
-get_eeprom_cksum(int off, int len, int *buffer)
-{
- int i,cksum=0;
-
- for (i=0;i<len;i++)
- cksum+=buffer[i];
- cksum &= 0xffff;
- if (cksum==0)
- return 0;
- return -1;
-}
-
-static int
-wait_eeprom_ready(struct cs_softc *sc)
-{
- DELAY ( 30000 ); /* XXX should we do some checks here ? */
- return 0;
-}
-
-static void
-control_dc_dc(struct cs_softc *sc, int on_not_off)
-{
- unsigned int self_control = HCB1_ENBL;
-
- if (((sc->adapter_cnf & A_CNF_DC_DC_POLARITY)!=0) ^ on_not_off)
- self_control |= HCB1;
- else
- self_control &= ~HCB1;
- cs_writereg( sc->nic_addr, PP_SelfCTL, self_control );
-
- DELAY( 500000 );
-}
-
-
-static int
-cs_duplex_auto(struct cs_softc *sc)
-{
- int i, error=0, unit=sc->arpcom.ac_if.if_unit;
-
- cs_writereg(sc->nic_addr, PP_AutoNegCTL,
- RE_NEG_NOW | ALLOW_FDX | AUTO_NEG_ENABLE );
- for (i=0; cs_readreg(sc->nic_addr,PP_AutoNegST)&AUTO_NEG_BUSY; i++) {
- if (i > 40000) {
- printf(CS_NAME"%1d: full/half duplex "
- "auto negotiation timeout\n", unit);
- error = ETIMEDOUT;
- break;
- }
- DELAY(1000);
- }
- DELAY( 1000000 );
- return error;
-}
-
-static int
-enable_tp(struct cs_softc *sc)
-{
- int unit = sc->arpcom.ac_if.if_unit;
-
- cs_writereg(sc->nic_addr, PP_LineCTL, sc->line_ctl & ~AUI_ONLY);
- control_dc_dc(sc, 0);
- DELAY( 150000 );
-
- if ((cs_readreg(sc->nic_addr, PP_LineST) & LINK_OK)==0) {
- printf(CS_NAME"%1d: failed to enable TP\n", unit);
- return EINVAL;
- }
-
- return 0;
-}
-
-/*
- * XXX This was rewritten from Linux driver without any tests.
- */
-static int
-send_test_pkt(struct cs_softc *sc)
-{
- char test_packet[] = { 0,0,0,0,0,0, 0,0,0,0,0,0,
- 0, 46, /* A 46 in network order */
- 0, 0, /* DSAP=0 & SSAP=0 fields */
- 0xf3, 0 /* Control (Test Req + P bit set) */ };
- int i;
- u_char ether_address_backup[ETHER_ADDR_LEN];
-
- for (i = 0; i < ETHER_ADDR_LEN; i++) {
- ether_address_backup[i] = sc->arpcom.ac_enaddr[i];
- }
-
- cs_writereg(sc->nic_addr, PP_LineCTL,
- cs_readreg(sc->nic_addr, PP_LineCTL) | SERIAL_TX_ON );
- bcopy(test_packet,
- sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
- bcopy(test_packet+ETHER_ADDR_LEN,
- sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
- outw(sc->nic_addr + TX_CMD_PORT, sc->send_cmd);
- outw(sc->nic_addr + TX_LEN_PORT, sizeof(test_packet));
-
- /* Wait for chip to allocate memory */
- DELAY(50000);
- if (!(cs_readreg(sc->nic_addr, PP_BusST) & READY_FOR_TX_NOW)) {
- for (i = 0; i < ETHER_ADDR_LEN; i++) {
- sc->arpcom.ac_enaddr[i] = ether_address_backup[i];
- }
- return 0;
- }
-
- outsw(sc->nic_addr + TX_FRAME_PORT, test_packet, sizeof(test_packet));
-
- DELAY(30000);
-
- if ((cs_readreg(sc->nic_addr,PP_TxEvent) & TX_SEND_OK_BITS) == TX_OK) {
- for (i = 0; i < ETHER_ADDR_LEN; i++) {
- sc->arpcom.ac_enaddr[i] = ether_address_backup[i];
- }
- return 1;
- }
- for (i = 0; i < ETHER_ADDR_LEN; i++) {
- sc->arpcom.ac_enaddr[i] = ether_address_backup[i];
- }
- return 0;
-}
-
-/*
- * XXX This was rewritten from Linux driver without any tests.
- */
-static int
-enable_aui(struct cs_softc *sc)
-{
- int unit = sc->arpcom.ac_if.if_unit;
-
- control_dc_dc(sc, 0);
- cs_writereg(sc->nic_addr, PP_LineCTL,
- (sc->line_ctl & ~AUTO_AUI_10BASET) | AUI_ONLY);
-
- if (!send_test_pkt(sc)) {
- printf(CS_NAME"%1d failed to enable AUI\n", unit);
- return EINVAL;
- }
- return 0;
-}
-
-/*
- * XXX This was rewritten from Linux driver without any tests.
- */
-static int
-enable_bnc(struct cs_softc *sc)
-{
- int unit = sc->arpcom.ac_if.if_unit;
-
- control_dc_dc(sc, 1);
- cs_writereg(sc->nic_addr, PP_LineCTL,
- (sc->line_ctl & ~AUTO_AUI_10BASET) | AUI_ONLY);
-
- if (!send_test_pkt(sc)) {
- printf(CS_NAME"%1d failed to enable BNC\n", unit);
- return EINVAL;
- }
- return 0;
-}
-
-static int
-cs_cs89x0_probe(struct cs_softc *sc, u_int *dev_irq,
- int *dev_drq, int iobase, int unit, int flags)
-{
- unsigned rev_type = 0;
- int i, irq=0;
- int eeprom_buff[CHKSUM_LEN];
- int chip_type, pp_isaint, pp_isadma;
- char chip_revision;
-
- if ((inw(iobase+ADD_PORT) & ADD_MASK) != ADD_SIG) {
- /* Chip not detected. Let's try to reset it */
- if (bootverbose)
- printf(CS_NAME"%1d: trying to reset the chip.\n", unit);
- outw(iobase+ADD_PORT, PP_SelfCTL);
- i = inw(iobase+DATA_PORT);
- outw(iobase+ADD_PORT, PP_SelfCTL);
- outw(iobase+DATA_PORT, i | POWER_ON_RESET);
- if ((inw(iobase+ADD_PORT) & ADD_MASK) != ADD_SIG)
- return 0;
- }
-
- outw(iobase+ADD_PORT, PP_ChipID);
- if (inw(iobase+DATA_PORT) != CHIP_EISA_ID_SIG)
- return 0;
-
- rev_type = cs_readreg(iobase, PRODUCT_ID_ADD);
- chip_type = rev_type & ~REVISON_BITS;
- chip_revision = ((rev_type & REVISON_BITS) >> 8) + 'A';
-
- sc->nic_addr = iobase;
- sc->chip_type = chip_type;
- if(chip_type==CS8900) {
- pp_isaint = PP_CS8900_ISAINT;
- pp_isadma = PP_CS8900_ISADMA;
- sc->send_cmd = TX_CS8900_AFTER_ALL;
- } else {
- pp_isaint = PP_CS8920_ISAINT;
- pp_isadma = PP_CS8920_ISADMA;
- sc->send_cmd = TX_CS8920_AFTER_ALL;
- }
-
- /*
- * Clear some fields so that fail of EEPROM will left them clean
- */
- sc->auto_neg_cnf = 0;
- sc->adapter_cnf = 0;
- sc->isa_config = 0;
-
- /*
- * EEPROM
- */
- if((cs_readreg(iobase, PP_SelfST) & EEPROM_PRESENT) == 0) {
- printf(CS_NAME"%1d: No EEPROM, assuming defaults.\n",
- unit);
- } else {
- if (get_eeprom_data(sc,START_EEPROM_DATA,CHKSUM_LEN, eeprom_buff)<0) {
- printf(CS_NAME"%1d: EEPROM read failed, "
- "assuming defaults..\n", unit);
- } else {
- if (get_eeprom_cksum(START_EEPROM_DATA,CHKSUM_LEN, eeprom_buff)<0) {
- printf( CS_NAME"%1d: EEPROM cheksum bad, "
- "assuming defaults..\n", unit );
- } else {
- sc->auto_neg_cnf =
- eeprom_buff[AUTO_NEG_CNF_OFFSET/2];
- sc->adapter_cnf =
- eeprom_buff[ADAPTER_CNF_OFFSET/2];
- sc->isa_config =
- eeprom_buff[ISA_CNF_OFFSET/2];
-
- for (i=0; i<ETHER_ADDR_LEN/2; i++) {
- sc->arpcom.ac_enaddr[i*2]=
- eeprom_buff[i];
- sc->arpcom.ac_enaddr[i*2+1]=
- eeprom_buff[i] >> 8;
- }
-
- /*
- * If no interrupt specified (or "?"),
- * use what the board tells us.
- */
- if (*dev_irq <= 0) {
- irq = sc->isa_config & INT_NO_MASK;
- if (chip_type==CS8900) {
- switch(irq) {
- case 0: irq=10; break;
- case 1: irq=11; break;
- case 2: irq=12; break;
- case 3: irq=5; break;
- default: printf(CS_NAME"%1d: invalid irq in EEPROM.\n",unit);
- }
- if (irq!=0)
- *dev_irq=(u_short)(1<<irq);
- } else {
- if (irq!=0 && irq<=CS8920_NO_INTS)
- *dev_irq=(u_short)(1<<irq);
- }
- }
- }
- }
- }
-
- if ((irq=ffs(*dev_irq))) {
- irq--;
- if (chip_type == CS8900) {
- switch(irq) {
- case 5: irq = 3; break;
- case 10: irq = 0; break;
- case 11: irq = 1; break;
- case 12: irq = 2; break;
- default: printf(CS_NAME"%1d: invalid irq\n", unit);
- return 0;
- }
- } else {
- if (irq > CS8920_NO_INTS) {
- printf(CS_NAME"%1d: invalid irq\n", unit);
- return 0;
- }
- }
- cs_writereg(iobase, pp_isaint, irq);
- } else {
- printf(CS_NAME"%1d: invalid irq\n", unit);
- return 0;
- }
-
- /*
- * Temporary disabled
- *
- if (drq>0)
- cs_writereg(iobase, pp_isadma, drq);
- else {
- printf( CS_NAME"%1d: incorrect drq\n", unit );
- return 0;
- }
- */
-
- if (bootverbose)
- printf(CS_NAME"%1d: model CS89%c0%s rev %c\n"
- CS_NAME"%1d: media%s%s%s\n"
- CS_NAME"%1d: irq %d drq %d\n",
- unit,
- chip_type==CS8900 ? '0' : '2',
- chip_type==CS8920M ? "M" : "",
- chip_revision,
- unit,
- (sc->adapter_cnf & A_CNF_10B_T) ? " TP" : "",
- (sc->adapter_cnf & A_CNF_AUI) ? " AUI" : "",
- (sc->adapter_cnf & A_CNF_10B_2) ? " BNC" : "",
- unit, (int)*dev_irq, (int)*dev_drq);
-
- if ((sc->adapter_cnf & A_CNF_EXTND_10B_2) &&
- (sc->adapter_cnf & A_CNF_LOW_RX_SQUELCH))
- sc->line_ctl = LOW_RX_SQUELCH;
- else
- sc->line_ctl = 0;
-
-
- return PP_ISAIOB;
-}
-
-/*
- * Determine if the device is present
- *
- * on entry:
- * a pointer to an isa_device struct
- * on exit:
- * NULL if device not found
- * or # of i/o addresses used (if found)
- */
-static int
-cs_probe(struct isa_device *dev)
-{
- int nports;
-
- struct cs_softc *sc=&cs_softc[dev->id_unit];
-
- nports=cs_cs89x0_probe(sc, &(dev->id_irq), &(dev->id_drq),
- (dev->id_iobase), (dev->id_unit), (dev->id_flags));
-
- if (nports)
- return (nports);
-
- return (0);
-}
-
-/*
- * Install the interface into kernel networking data structures
- */
-static int
-cs_attach(struct cs_softc *sc, int unit, int flags)
-{
- int media=0;
-/* struct cs_softc *sc = &cs_softc[dev->id_unit]; */
- struct ifnet *ifp = &(sc->arpcom.ac_if);
-
- if (!ifp->if_name) {
- ifp->if_softc=sc;
- ifp->if_unit=unit;
- ifp->if_name=csdriver.name;
- ifp->if_output=ether_output;
- ifp->if_start=cs_start;
- ifp->if_ioctl=cs_ioctl;
- ifp->if_watchdog=cs_watchdog;
- ifp->if_init=cs_init;
- ifp->if_snd.ifq_maxlen= IFQ_MAXLEN;
- /*
- * MIB DATA
- */
- /*
- ifp->if_linkmib=&sc->mibdata;
- ifp->if_linkmiblen=sizeof sc->mibdata;
- */
-
- ifp->if_flags=(IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST );
-
- /*
- * this code still in progress (DMA support)
- *
-
- sc->recv_ring=malloc(CS_DMA_BUFFER_SIZE<<1, M_DEVBUF, M_NOWAIT);
- if (sc->recv_ring == NULL) {
- log(LOG_ERR,CS_NAME
- "%d: Couldn't allocate memory for NIC\n", unit);
- return(0);
- }
- if ((sc->recv_ring-(sc->recv_ring & 0x1FFFF))
- < (128*1024-CS_DMA_BUFFER_SIZE))
- sc->recv_ring+=16*1024;
-
- */
-
- sc->buffer=malloc(ETHER_MAX_LEN-ETHER_CRC_LEN,M_DEVBUF,M_NOWAIT);
- if (sc->buffer == NULL) {
- printf(CS_NAME"%d: Couldn't allocate memory for NIC\n",
- unit);
- return(0);
- }
-
- /*
- * Initialize the media structures.
- */
- ifmedia_init(&sc->media, 0, cs_mediachange, cs_mediastatus);
-
- if (sc->adapter_cnf & A_CNF_10B_T) {
- ifmedia_add(&sc->media, IFM_ETHER|IFM_10_T, 0, NULL);
- if (sc->chip_type != CS8900) {
- ifmedia_add(&sc->media,
- IFM_ETHER|IFM_10_T|IFM_FDX, 0, NULL);
- ifmedia_add(&sc->media,
- IFM_ETHER|IFM_10_T|IFM_HDX, 0, NULL);
- }
- }
-
- if (sc->adapter_cnf & A_CNF_10B_2)
- ifmedia_add(&sc->media, IFM_ETHER|IFM_10_2, 0, NULL);
-
- if (sc->adapter_cnf & A_CNF_AUI)
- ifmedia_add(&sc->media, IFM_ETHER|IFM_10_5, 0, NULL);
-
- if (sc->adapter_cnf & A_CNF_MEDIA)
- ifmedia_add(&sc->media, IFM_ETHER|IFM_AUTO, 0, NULL);
-
- /* Set default media from EEPROM */
- switch (sc->adapter_cnf & A_CNF_MEDIA_TYPE) {
- case A_CNF_MEDIA_AUTO: media = IFM_ETHER|IFM_AUTO; break;
- case A_CNF_MEDIA_10B_T: media = IFM_ETHER|IFM_10_T; break;
- case A_CNF_MEDIA_10B_2: media = IFM_ETHER|IFM_10_2; break;
- case A_CNF_MEDIA_AUI: media = IFM_ETHER|IFM_10_5; break;
- default: printf(CS_NAME"%d: adapter has no media\n", unit);
- }
- ifmedia_set(&sc->media, media);
- cs_mediaset(sc, media);
-
- if_attach(ifp);
- cs_stop( sc );
- ether_ifattach(ifp);
- }
-
- if (bootverbose)
- printf(CS_NAME"%d: ethernet address %6D\n",
- ifp->if_unit, sc->arpcom.ac_enaddr, ":");
-
- bpfattach(ifp, DLT_EN10MB, sizeof (struct ether_header));
- return 1;
-}
-
-static int
-cs_attach_isa(struct isa_device *dev)
-{
- int unit=dev->id_unit;
- struct cs_softc *sc=&cs_softc[unit];
- int flags=dev->id_flags;
-
- dev->id_ointr = csintr;
- return cs_attach(sc, unit, flags);
-}
-
-/*
- * Initialize the board
- */
-static void
-cs_init(void *xsc)
-{
- struct cs_softc *sc=(struct cs_softc *)xsc;
- struct ifnet *ifp = &sc->arpcom.ac_if;
- int i, s, rx_cfg;
-
- /* address not known */
- if (TAILQ_EMPTY(&ifp->if_addrhead)) /* unlikely? XXX */
- return;
-
- /*
- * reset whatchdog timer
- */
- ifp->if_timer=0;
- sc->buf_len = 0;
-
- s=splimp();
-
- /*
- * Hardware initialization of cs
- */
-
- /* Enable receiver and transmitter */
- cs_writereg(sc->nic_addr, PP_LineCTL,
- cs_readreg( sc->nic_addr, PP_LineCTL ) |
- SERIAL_RX_ON | SERIAL_TX_ON);
-
- /* Configure the receiver mode */
- cs_setmode(sc);
-
- /*
- * This defines what type of frames will cause interrupts
- * Bad frames should generate interrupts so that the driver
- * could track statistics of discarded packets
- */
- rx_cfg = RX_OK_ENBL | RX_CRC_ERROR_ENBL | RX_RUNT_ENBL |
- RX_EXTRA_DATA_ENBL;
- if (sc->isa_config & STREAM_TRANSFER)
- rx_cfg |= RX_STREAM_ENBL;
- cs_writereg(sc->nic_addr, PP_RxCFG, rx_cfg);
-
- cs_writereg(sc->nic_addr, PP_TxCFG, TX_LOST_CRS_ENBL |
- TX_SQE_ERROR_ENBL | TX_OK_ENBL | TX_LATE_COL_ENBL |
- TX_JBR_ENBL | TX_ANY_COL_ENBL | TX_16_COL_ENBL);
-
- cs_writereg(sc->nic_addr, PP_BufCFG, READY_FOR_TX_ENBL |
- RX_MISS_COUNT_OVRFLOW_ENBL | TX_COL_COUNT_OVRFLOW_ENBL |
- TX_UNDERRUN_ENBL /*| RX_DMA_ENBL*/);
-
- /* Write MAC address into IA filter */
- for (i=0; i<ETHER_ADDR_LEN/2; i++)
- cs_writereg(sc->nic_addr, PP_IA+i*2,
- sc->arpcom.ac_enaddr[i*2] |
- (sc->arpcom.ac_enaddr[i*2+1] << 8) );
-
- /*
- * Now enable everything
- */
-/*
-#ifdef CS_USE_64K_DMA
- cs_writereg(sc->nic_addr, PP_BusCTL, ENABLE_IRQ | RX_DMA_SIZE_64K);
- #else
-
- cs_writereg(sc->nic_addr, PP_BusCTL, ENABLE_IRQ);
-#endif
-*/
- cs_writereg(sc->nic_addr, PP_BusCTL, ENABLE_IRQ);
-
- /*
- * Set running and clear output active flags
- */
- sc->arpcom.ac_if.if_flags |= IFF_RUNNING;
- sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE;
-
- /*
- * Start sending process
- */
- cs_start(ifp);
-
- (void) splx(s);
-}
-
-/*
- * Get the packet from the board and send it to the upper layer
- * via ether_input().
- */
-static int
-cs_get_packet(struct cs_softc *sc)
-{
- struct ifnet *ifp = &(sc->arpcom.ac_if);
- int iobase = sc->nic_addr, status, length;
- struct ether_header *eh;
- struct mbuf *m;
-
-#ifdef CS_DEBUG
- int i;
-#endif
-
- status = inw(iobase + RX_FRAME_PORT);
- length = inw(iobase + RX_FRAME_PORT);
-
-#ifdef CS_DEBUG
- printf(CS_NAME"%1d: rcvd: stat %x, len %d\n",
- ifp->if_unit, status, length);
-#endif
-
- if (!(status & RX_OK)) {
-#ifdef CS_DEBUG
- printf(CS_NAME"%1d: bad pkt stat %x\n", ifp->if_unit, status);
-#endif
- ifp->if_ierrors++;
- return -1;
- }
-
- MGETHDR(m, M_DONTWAIT, MT_DATA);
- if (m==NULL)
- return -1;
-
- if (length > MHLEN) {
- MCLGET(m, M_DONTWAIT);
- if (!(m->m_flags & M_EXT)) {
- m_freem(m);
- return -1;
- }
- }
-
- /* Initialize packet's header info */
- m->m_pkthdr.rcvif = ifp;
- m->m_pkthdr.len = length;
- m->m_len = length;
-
- /* Get the data */
- insw(iobase + RX_FRAME_PORT, m->m_data, (length+1)>>1);
-
- eh = mtod(m, struct ether_header *);
-
- if (ifp->if_bpf)
- bpf_mtap(ifp, m);
-
-#ifdef CS_DEBUG
- for (i=0;i<length;i++)
- printf(" %02x",(unsigned char)*((char *)(m->m_data+i)));
- printf( "\n" );
-#endif
-
- if (status & (RX_IA | RX_BROADCAST) ||
- (ifp->if_flags & IFF_MULTICAST && status & RX_HASHED)) {
- m->m_pkthdr.len -= sizeof(struct ether_header);
- m->m_len -= sizeof(struct ether_header);
- m->m_data += sizeof(struct ether_header);
-
- /* Feed the packet to the upper layer */
- ether_input(ifp, eh, m);
-
- ifp->if_ipackets++;
-
- if (length==ETHER_MAX_LEN-ETHER_CRC_LEN)
- DELAY( cs_recv_delay );
- } else {
- m_freem(m);
- }
-
- return 0;
-}
-
-/*
- * Software calls interrupt handler
- */
-static void
-csintr_sc(struct cs_softc *sc, int unit)
-{
- struct ifnet *ifp = &(sc->arpcom.ac_if);
- int status;
-
-#ifdef CS_DEBUG
- printf(CS_NAME"%1d: Interrupt.\n", unit);
-#endif
-
- while ((status=cs_readword(sc->nic_addr, ISQ_PORT))) {
-
-#ifdef CS_DEBUG
- printf( CS_NAME"%1d:from ISQ: %04x\n", unit, status );
-#endif
-
- switch (status & ISQ_EVENT_MASK) {
- case ISQ_RECEIVER_EVENT:
- cs_get_packet(sc);
- break;
-
- case ISQ_TRANSMITTER_EVENT:
- if (status & TX_OK)
- ifp->if_opackets++;
- else
- ifp->if_oerrors++;
- ifp->if_flags &= ~IFF_OACTIVE;
- ifp->if_timer = 0;
- break;
-
- case ISQ_BUFFER_EVENT:
- if (status & READY_FOR_TX) {
- ifp->if_flags &= ~IFF_OACTIVE;
- ifp->if_timer = 0;
- }
-
- if (status & TX_UNDERRUN) {
- ifp->if_flags &= ~IFF_OACTIVE;
- ifp->if_timer = 0;
- ifp->if_oerrors++;
- }
- break;
-
- case ISQ_RX_MISS_EVENT:
- ifp->if_ierrors+=(status>>6);
- break;
-
- case ISQ_TX_COL_EVENT:
- ifp->if_collisions+=(status>>6);
- break;
- }
- }
-
- if (!(ifp->if_flags & IFF_OACTIVE)) {
- cs_start(ifp);
- }
-}
-
-/*
- * Handle interrupts
- */
-static void
-csintr(int unit)
-{
- struct cs_softc *sc = &cs_softc[unit];
-
- csintr_sc(sc, unit);
-}
-
-/*
- * Save the data in buffer
- */
-
-static void
-cs_write_mbufs( struct cs_softc *sc, struct mbuf *m )
-{
- int len;
- struct mbuf *mp;
- unsigned char *data, *buf;
-
- for (mp=m, buf=sc->buffer, sc->buf_len=0; mp != NULL; mp=mp->m_next) {
- len = mp->m_len;
-
- /*
- * Ignore empty parts
- */
- if (!len)
- continue;
-
- /*
- * Find actual data address
- */
- data = mtod(mp, caddr_t);
-
- bcopy((caddr_t) data, (caddr_t) buf, len);
- buf += len;
- sc->buf_len += len;
- }
-}
-
-
-static void
-cs_xmit_buf( struct cs_softc *sc )
-{
- outsw(sc->nic_addr+TX_FRAME_PORT, sc->buffer, (sc->buf_len+1)>>1);
- sc->buf_len = 0;
-}
-
-static void
-cs_start(struct ifnet *ifp)
-{
- int s, length;
- struct mbuf *m, *mp;
- struct cs_softc *sc = ifp->if_softc;
-
- s = splimp();
-
- for (;;) {
- if (sc->buf_len)
- length = sc->buf_len;
- else {
- IF_DEQUEUE( &ifp->if_snd, m );
-
- if (m==NULL) {
- (void) splx(s);
- return;
- }
-
- for (length=0, mp=m; mp != NULL; mp=mp->m_next)
- length += mp->m_len;
-
- /* Skip zero-length packets */
- if (length == 0) {
- m_freem(m);
- continue;
- }
-
- cs_write_mbufs(sc, m);
-
- if (ifp->if_bpf) {
- bpf_mtap(ifp, m);
- }
-
- m_freem(m);
- }
-
- /*
- * Issue a SEND command
- */
- outw(sc->nic_addr+TX_CMD_PORT, sc->send_cmd);
- outw(sc->nic_addr+TX_LEN_PORT, length );
-
- /*
- * If there's no free space in the buffer then leave
- * this packet for the next time: indicate output active
- * and return.
- */
- if (!(cs_readreg(sc->nic_addr, PP_BusST) & READY_FOR_TX_NOW)) {
- ifp->if_timer = sc->buf_len;
- (void) splx(s);
- ifp->if_flags |= IFF_OACTIVE;
- return;
- }
-
- cs_xmit_buf(sc);
-
- /*
- * Set the watchdog timer in case we never hear
- * from board again. (I don't know about correct
- * value for this timeout)
- */
- ifp->if_timer = length;
-
- (void) splx(s);
- ifp->if_flags |= IFF_OACTIVE;
- return;
- }
-}
-
-/*
- * Stop everything on the interface
- */
-static void
-cs_stop(struct cs_softc *sc)
-{
- int s = splimp();
-
- cs_writereg(sc->nic_addr, PP_RxCFG, 0);
- cs_writereg(sc->nic_addr, PP_TxCFG, 0);
- cs_writereg(sc->nic_addr, PP_BufCFG, 0);
- cs_writereg(sc->nic_addr, PP_BusCTL, 0);
-
- sc->arpcom.ac_if.if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
- sc->arpcom.ac_if.if_timer = 0;
-
- (void) splx(s);
-}
-
-/*
- * Reset the interface
- */
-static void
-cs_reset(struct cs_softc *sc)
-{
- cs_stop(sc);
- cs_init(sc);
-}
-
-static void
-cs_setmode(struct cs_softc *sc)
-{
- struct ifnet *ifp = &(sc->arpcom.ac_if);
- int rx_ctl;
-
- /* Stop the receiver while changing filters */
- cs_writereg(sc->nic_addr, PP_LineCTL,
- cs_readreg(sc->nic_addr, PP_LineCTL) & ~SERIAL_RX_ON);
-
- if (ifp->if_flags & IFF_PROMISC) {
- /* Turn on promiscuous mode. */
- rx_ctl = RX_OK_ACCEPT | RX_PROM_ACCEPT;
- } else {
- if (ifp->if_flags & IFF_MULTICAST) {
- /* Allow receiving frames with multicast addresses */
- rx_ctl = RX_IA_ACCEPT | RX_BROADCAST_ACCEPT |
- RX_OK_ACCEPT | RX_MULTCAST_ACCEPT;
- /*
- * Here the reconfiguration of chip's multicast
- * filters should be done but I've no idea about
- * hash transformation in this chip. If you can
- * add this code or describe me the transformation
- * I'd be very glad.
- */
- } else {
- /*
- * Receive only good frames addressed for us and
- * good broadcasts.
- */
- rx_ctl = RX_IA_ACCEPT | RX_BROADCAST_ACCEPT |
- RX_OK_ACCEPT;
- }
- }
-
- /* Set up the filter */
- cs_writereg(sc->nic_addr, PP_RxCTL, RX_DEF_ACCEPT | rx_ctl);
-
- /* Turn on receiver */
- cs_writereg(sc->nic_addr, PP_LineCTL,
- cs_readreg(sc->nic_addr, PP_LineCTL) | SERIAL_RX_ON);
-}
-
-static int
-cs_ioctl(register struct ifnet *ifp, u_long command, caddr_t data)
-{
- struct cs_softc *sc=ifp->if_softc;
- struct ifreq *ifr = (struct ifreq *)data;
- int s,error=0;
-
-#ifdef CS_DEBUG
- printf(CS_NAME"%d: ioctl(%x)\n",sc->arpcom.ac_if.if_unit,command);
-#endif
-
- s=splimp();
-
- switch (command) {
- case SIOCSIFADDR:
- case SIOCGIFADDR:
- case SIOCSIFMTU:
- ether_ioctl(ifp, command, data);
- break;
-
- case SIOCSIFFLAGS:
- /*
- * Switch interface state between "running" and
- * "stopped", reflecting the UP flag.
- */
- if (sc->arpcom.ac_if.if_flags & IFF_UP) {
- if ((sc->arpcom.ac_if.if_flags & IFF_RUNNING)==0) {
- cs_init(sc);
- }
- } else {
- if ((sc->arpcom.ac_if.if_flags & IFF_RUNNING)!=0) {
- cs_stop(sc);
- }
- }
- /*
- * Promiscuous and/or multicast flags may have changed,
- * so reprogram the multicast filter and/or receive mode.
- *
- * See note about multicasts in cs_setmode
- */
- cs_setmode(sc);
- break;
-
- case SIOCADDMULTI:
- case SIOCDELMULTI:
- /*
- * Multicast list has changed; set the hardware filter
- * accordingly.
- *
- * See note about multicasts in cs_setmode
- */
- cs_setmode(sc);
- error = 0;
- break;
-
- case SIOCSIFMEDIA:
- case SIOCGIFMEDIA:
- error = ifmedia_ioctl(ifp, ifr, &sc->media, command);
- break;
-
- default:
- error = EINVAL;
- }
-
- (void) splx(s);
- return error;
-}
-
-/*
- * Device timeout/watchdog routine. Entered if the device neglects to
- * generate an interrupt after a transmit has been started on it.
- */
-static void
-cs_watchdog(struct ifnet *ifp)
-{
- struct cs_softc *sc = &cs_softc[ifp->if_unit];
-
- ifp->if_oerrors++;
- log(LOG_ERR, CS_NAME"%d: device timeout\n", ifp->if_unit);
-
- /* Reset the interface */
- if (ifp->if_flags & IFF_UP)
- cs_reset(sc);
- else
- cs_stop(sc);
-}
-
-static int
-cs_mediachange(struct ifnet *ifp)
-{
- struct cs_softc *sc = ifp->if_softc;
- struct ifmedia *ifm = &sc->media;
-
- if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER)
- return EINVAL;
-
- return cs_mediaset(sc, ifm->ifm_media);
-}
-
-static void
-cs_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr)
-{
- int line_status;
- struct cs_softc *sc = ifp->if_softc;
-
- ifmr->ifm_active = IFM_ETHER;
- line_status = cs_readreg(sc->nic_addr, PP_LineST);
- if (line_status & TENBASET_ON) {
- ifmr->ifm_active |= IFM_10_T;
- if (sc->chip_type != CS8900) {
- if (cs_readreg(sc->nic_addr, PP_AutoNegST) & FDX_ACTIVE)
- ifmr->ifm_active |= IFM_FDX;
- if (cs_readreg(sc->nic_addr, PP_AutoNegST) & HDX_ACTIVE)
- ifmr->ifm_active |= IFM_HDX;
- }
- ifmr->ifm_status = IFM_AVALID;
- if (line_status & LINK_OK)
- ifmr->ifm_status |= IFM_ACTIVE;
- } else {
- if (line_status & AUI_ON) {
- cs_writereg(sc->nic_addr, PP_SelfCTL,
- cs_readreg(sc->nic_addr, PP_SelfCTL) |
- HCB1_ENBL);
- if (((sc->adapter_cnf & A_CNF_DC_DC_POLARITY)!=0)^
- (cs_readreg(sc->nic_addr, PP_SelfCTL)&HCB1))
- ifmr->ifm_active |= IFM_10_2;
- else
- ifmr->ifm_active |= IFM_10_5;
- }
- }
-}
-
-static int
-cs_mediaset(struct cs_softc *sc, int media)
-{
- int error;
-
- /* Stop the receiver & transmitter */
- cs_writereg(sc->nic_addr, PP_LineCTL,
- cs_readreg(sc->nic_addr, PP_LineCTL) &
- ~(SERIAL_RX_ON | SERIAL_TX_ON));
-
-#ifdef CS_DEBUG
- printf(CS_NAME"%d: cs_setmedia(%x)\n",sc->arpcom.ac_if.if_unit,media);
-#endif
-
- switch (IFM_SUBTYPE(media)) {
- default:
- case IFM_AUTO:
- if ((error=enable_tp(sc))==0)
- error = cs_duplex_auto(sc);
- else if ((error=enable_bnc(sc)) != 0)
- error = enable_aui(sc);
- break;
- case IFM_10_T:
- if ((error=enable_tp(sc)) != 0)
- break;
- if (media & IFM_FDX)
- cs_duplex_full(sc);
- else if (media & IFM_HDX)
- cs_duplex_half(sc);
- else
- error = cs_duplex_auto(sc);
- break;
- case IFM_10_2:
- error = enable_bnc(sc);
- break;
- case IFM_10_5:
- error = enable_aui(sc);
- break;
- }
-
- /*
- * Turn the transmitter & receiver back on
- */
- cs_writereg(sc->nic_addr, PP_LineCTL,
- cs_readreg( sc->nic_addr, PP_LineCTL ) |
- SERIAL_RX_ON | SERIAL_TX_ON);
-
- return error;
-}
-
-
-#if NPNP > 0
-
-static struct cspnp_ids {
- u_long vend_id;
- char *id_str;
-} cspnp_ids[]= {
- { 0x4060630e, "CSC6040" },
- { 0x10104d24, "IBM EtherJet" },
- { 0 }
-};
-
-static char *cs_pnp_probe(u_long, u_long);
-static void cs_pnp_attach(u_long, u_long, char *, struct isa_device *);
-
-struct pnp_device cs_pnp = {
- "CS8920 based PnP Ethernet",
- cs_pnp_probe,
- cs_pnp_attach,
- &cs_unit,
- &net_imask /* imask */
-};
-
-DATA_SET (pnpdevice_set, cs_pnp);
-
-struct csintr_list {
- struct cs_softc *sc;
- int unit;
- struct csintr_list *next;
-};
-
-static struct csintr_list *csintr_head;
-
-static void csintr_pnp_add(struct cs_softc *sc, int unit);
-static void csintr_pnp(int unit);
-
-static void
-csintr_pnp_add(struct cs_softc *sc, int unit)
-{
- struct csintr_list *intr;
-
- if (!sc) return;
-
- intr = malloc (sizeof (*intr), M_DEVBUF, M_WAITOK);
- if (!intr) return;
-
- intr->sc = sc;
- intr->unit = unit;
- intr->next = csintr_head;
- csintr_head = intr;
-}
-
-/*
- * Interrupt handler for PNP installed card
- * We have to find the number of the card.
- */
-static void
-csintr_pnp(int unit)
-{
- struct csintr_list *intr;
-
- for (intr=csintr_head; intr; intr=intr->next) {
- if (intr->unit == unit)
- csintr_sc(intr->sc, unit);
- break;
- }
-}
-
-static char *
-cs_pnp_probe(u_long csn, u_long vend_id)
-{
- struct cspnp_ids *ids;
- char *s=NULL;
-
- for(ids = cspnp_ids; ids->vend_id != 0; ids++) {
- if (vend_id == ids->vend_id) {
- s = ids->id_str;
- break;
- }
- }
-
- if (s) {
- struct pnp_cinfo d;
- int ldn = 0;
-
- read_pnp_parms(&d, ldn);
- if (d.enable == 0) {
- printf("This is a %s, but LDN %d is disabled\n", s, ldn);
- return NULL ;
- }
- return s;
- }
-
- return NULL ;
-}
-
-static void
-cs_pnp_attach(u_long csn, u_long vend_id, char *name,
- struct isa_device *dev)
-{
-
- struct pnp_cinfo d;
- int ldn = 0;
- int iobase, unit, flags;
- u_int irq;
- int drq;
- struct cs_softc *sc = malloc(sizeof *sc, M_DEVBUF, M_NOWAIT);
-
- if (read_pnp_parms ( &d , ldn ) == 0 ) {
- printf("failed to read pnp parms\n");
- return;
- }
-
- write_pnp_parms( &d, ldn );
- enable_pnp_card();
-
- iobase = dev->id_iobase = d.port[0];
- irq = dev->id_irq = (1 << d.irq[0] );
- drq = dev->id_drq = d.drq[0];
- dev->id_maddr = 0;
- dev->id_ointr = csintr_pnp;
- flags = dev->id_flags = 0;
- unit = dev->id_unit;
-
- if (dev->id_driver == NULL) {
- dev->id_driver = &csdriver;
- dev->id_id = isa_compat_nextid();
- }
-
- if (!sc) return;
-
- bzero(sc, sizeof *sc);
- if (cs_cs89x0_probe(sc, &irq, &drq, iobase, unit, flags) == 0
- || cs_attach(sc, unit, flags) == 0) {
- free(sc, M_DEVBUF);
- } else {
- if ((irq != dev->id_irq)
- || (drq != dev->id_drq)
- || (iobase != dev->id_iobase)
- || (unit != dev->id_unit)
- || (flags != dev->id_flags)
- ) {
- printf("failed to pnp card parametars\n");
- }
- }
- csintr_pnp_add(sc, dev->id_unit);
-}
-#endif /* NPNP */
diff --git a/sys/dev/cs/if_csreg.h b/sys/dev/cs/if_csreg.h
deleted file mode 100644
index 56d9fcd595af..000000000000
--- a/sys/dev/cs/if_csreg.h
+++ /dev/null
@@ -1,542 +0,0 @@
-/*
- * Copyright (c) 1997,1998 Maxim Bolotin and Oleg Sharoiko.
- * 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 unmodified, 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 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 AUTHOR 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.
- *
- */
-
-/*
- * $FreeBSD$
- */
-
-#define PP_ChipID 0x0000 /* offset 0h -> Corp -ID */
- /* offset 2h -> Model/Product Number */
- /* offset 3h -> Chip Revision Number */
-
-#define PP_ISAIOB 0x0020 /* IO base address */
-#define PP_CS8900_ISAINT 0x0022 /* ISA interrupt select */
-#define PP_CS8900_ISADMA 0x0024 /* ISA Rec DMA channel */
-#define PP_CS8920_ISAINT 0x0370 /* ISA interrupt select */
-#define PP_CS8920_ISADMA 0x0374 /* ISA Rec DMA channel */
-#define PP_ISASOF 0x0026 /* ISA DMA offset */
-#define PP_DmaFrameCnt 0x0028 /* ISA DMA Frame count */
-#define PP_DmaByteCnt 0x002A /* ISA DMA Byte count */
-#define PP_CS8920_ISAMemB 0x0348 /* Memory base */
-
-/* EEPROM data and command registers */
-#define PP_EECMD 0x0040 /* NVR Interface Command register */
-#define PP_EEData 0x0042 /* NVR Interface Data Register */
-#define PP_DebugReg 0x0044 /* Debug Register */
-
-#define PP_RxCFG 0x0102 /* Rx Bus config */
-#define PP_RxCTL 0x0104 /* Receive Control Register */
-#define PP_TxCFG 0x0106 /* Transmit Config Register */
-#define PP_TxCMD 0x0108 /* Transmit Command Register */
-#define PP_BufCFG 0x010A /* Bus configuration Register */
-#define PP_LineCTL 0x0112 /* Line Config Register */
-#define PP_SelfCTL 0x0114 /* Self Command Register */
-#define PP_BusCTL 0x0116 /* ISA bus control Register */
-#define PP_TestCTL 0x0118 /* Test Register */
-#define PP_AutoNegCTL 0x011C /* Auto Negotiation Ctrl */
-
-#define PP_ISQ 0x0120 /* Interrupt Status */
-#define PP_RxEvent 0x0124 /* Rx Event Register */
-#define PP_TxEvent 0x0128 /* Tx Event Register */
-#define PP_BufEvent 0x012C /* Bus Event Register */
-#define PP_RxMiss 0x0130 /* Receive Miss Count */
-#define PP_TxCol 0x0132 /* Transmit Collision Count */
-#define PP_LineST 0x0134 /* Line State Register */
-#define PP_SelfST 0x0136 /* Self State register */
-#define PP_BusST 0x0138 /* Bus Status */
-#define PP_TDR 0x013C /* Time Domain Reflectometry */
-#define PP_AutoNegST 0x013E /* Auto Neg Status */
-#define PP_TxCommand 0x0144 /* Tx Command */
-#define PP_TxLength 0x0146 /* Tx Length */
-#define PP_LAF 0x0150 /* Hash Table */
-#define PP_IA 0x0158 /* Physical Address Register */
-
-#define PP_RxStatus 0x0400 /* Receive start of frame */
-#define PP_RxLength 0x0402 /* Receive Length of frame */
-#define PP_RxFrame 0x0404 /* Receive frame pointer */
-#define PP_TxFrame 0x0A00 /* Transmit frame pointer */
-
-/*
- * Primary I/O Base Address. If no I/O base is supplied by the user, then this
- * can be used as the default I/O base to access the PacketPage Area.
- */
-#define DEFAULTIOBASE 0x0300
-#define FIRST_IO 0x020C /* First I/O port to check */
-#define LAST_IO 0x037C /* Last I/O port to check (+10h) */
-#define ADD_MASK 0x3000 /* Mask it use of the ADD_PORT register */
-#define ADD_SIG 0x3000 /* Expected ID signature */
-
-#define CHIP_EISA_ID_SIG 0x630E /* Product ID Code for Crystal Chip (CS8900 spec 4.3) */
-
-#define PRODUCT_ID_ADD 0x0002 /* Address of product ID */
-
-/* Mask to find out the types of registers */
-#define REG_TYPE_MASK 0x001F
-
-/* Eeprom Commands */
-#define ERSE_WR_ENBL 0x00F0
-#define ERSE_WR_DISABLE 0x0000
-
-/* Defines Control/Config register quintuplet numbers */
-#define RX_BUF_CFG 0x0003
-#define RX_CONTROL 0x0005
-#define TX_CFG 0x0007
-#define TX_COMMAND 0x0009
-#define BUF_CFG 0x000B
-#define LINE_CONTROL 0x0013
-#define SELF_CONTROL 0x0015
-#define BUS_CONTROL 0x0017
-#define TEST_CONTROL 0x0019
-
-/* Defines Status/Count registers quintuplet numbers */
-#define RX_EVENT 0x0004
-#define TX_EVENT 0x0008
-#define BUF_EVENT 0x000C
-#define RX_MISS_COUNT 0x0010
-#define TX_COL_COUNT 0x0012
-#define LINE_STATUS 0x0014
-#define SELF_STATUS 0x0016
-#define BUS_STATUS 0x0018
-#define TDR 0x001C
-
-/*
- * PP_RxCFG - Receive Configuration and Interrupt Mask
- * bit definition - Read/write
- */
-#define SKIP_1 0x0040
-#define RX_STREAM_ENBL 0x0080
-#define RX_OK_ENBL 0x0100
-#define RX_DMA_ONLY 0x0200
-#define AUTO_RX_DMA 0x0400
-#define BUFFER_CRC 0x0800
-#define RX_CRC_ERROR_ENBL 0x1000
-#define RX_RUNT_ENBL 0x2000
-#define RX_EXTRA_DATA_ENBL 0x4000
-
-/* PP_RxCTL - Receive Control bit definition - Read/write */
-#define RX_IA_HASH_ACCEPT 0x0040
-#define RX_PROM_ACCEPT 0x0080
-#define RX_OK_ACCEPT 0x0100
-#define RX_MULTCAST_ACCEPT 0x0200
-#define RX_IA_ACCEPT 0x0400
-#define RX_BROADCAST_ACCEPT 0x0800
-#define RX_BAD_CRC_ACCEPT 0x1000
-#define RX_RUNT_ACCEPT 0x2000
-#define RX_EXTRA_DATA_ACCEPT 0x4000
-#define RX_ALL_ACCEPT (RX_PROM_ACCEPT | RX_BAD_CRC_ACCEPT | \
- RX_RUNT_ACCEPT | RX_EXTRA_DATA_ACCEPT)
-/*
- * Default receive mode - individually addressed, broadcast, and error free
- */
-#define RX_DEF_ACCEPT (RX_IA_ACCEPT | RX_BROADCAST_ACCEPT | RX_OK_ACCEPT)
-
-/*
- * PP_TxCFG - Transmit Configuration Interrupt Mask
- * bit definition - Read/write
- */
-#define TX_LOST_CRS_ENBL 0x0040
-#define TX_SQE_ERROR_ENBL 0x0080
-#define TX_OK_ENBL 0x0100
-#define TX_LATE_COL_ENBL 0x0200
-#define TX_JBR_ENBL 0x0400
-#define TX_ANY_COL_ENBL 0x0800
-#define TX_16_COL_ENBL 0x8000
-
-/*
- * PP_TxCMD - Transmit Command bit definition - Read-only
- */
-#define TX_START_4_BYTES 0x0000
-#define TX_START_64_BYTES 0x0040
-#define TX_START_128_BYTES 0x0080
-#define TX_START_ALL_BYTES 0x00C0
-#define TX_FORCE 0x0100
-#define TX_ONE_COL 0x0200
-#define TX_TWO_PART_DEFF_DISABLE 0x0400
-#define TX_NO_CRC 0x1000
-#define TX_RUNT 0x2000
-
-/*
- * PP_BufCFG - Buffer Configuration Interrupt Mask
- * bit definition - Read/write
- */
-#define GENERATE_SW_INTERRUPT 0x0040
-#define RX_DMA_ENBL 0x0080
-#define READY_FOR_TX_ENBL 0x0100
-#define TX_UNDERRUN_ENBL 0x0200
-#define RX_MISS_ENBL 0x0400
-#define RX_128_BYTE_ENBL 0x0800
-#define TX_COL_COUNT_OVRFLOW_ENBL 0x1000
-#define RX_MISS_COUNT_OVRFLOW_ENBL 0x2000
-#define RX_DEST_MATCH_ENBL 0x8000
-
-/*
- * PP_LineCTL - Line Control bit definition - Read/write
- */
-#define SERIAL_RX_ON 0x0040
-#define SERIAL_TX_ON 0x0080
-#define AUI_ONLY 0x0100
-#define AUTO_AUI_10BASET 0x0200
-#define MODIFIED_BACKOFF 0x0800
-#define NO_AUTO_POLARITY 0x1000
-#define TWO_PART_DEFDIS 0x2000
-#define LOW_RX_SQUELCH 0x4000
-
-/*
- * PP_SelfCTL - Software Self Control bit definition - Read/write
- */
-#define POWER_ON_RESET 0x0040
-#define SW_STOP 0x0100
-#define SLEEP_ON 0x0200
-#define AUTO_WAKEUP 0x0400
-#define HCB0_ENBL 0x1000
-#define HCB1_ENBL 0x2000
-#define HCB0 0x4000
-#define HCB1 0x8000
-
-/*
- * PP_BusCTL - ISA Bus Control bit definition - Read/write
- */
-#define RESET_RX_DMA 0x0040
-#define MEMORY_ON 0x0400
-#define DMA_BURST_MODE 0x0800
-#define IO_CHANNEL_READY_ON 0x1000
-#define RX_DMA_SIZE_64Ks 0x2000
-#define ENABLE_IRQ 0x8000
-
-/*
- * PP_TestCTL - Test Control bit definition - Read/write
- */
-#define LINK_OFF 0x0080
-#define ENDEC_LOOPBACK 0x0200
-#define AUI_LOOPBACK 0x0400
-#define BACKOFF_OFF 0x0800
-#define FAST_TEST 0x8000
-
-/*
- * PP_RxEvent - Receive Event Bit definition - Read-only
- */
-#define RX_IA_HASHED 0x0040
-#define RX_DRIBBLE 0x0080
-#define RX_OK 0x0100
-#define RX_HASHED 0x0200
-#define RX_IA 0x0400
-#define RX_BROADCAST 0x0800
-#define RX_CRC_ERROR 0x1000
-#define RX_RUNT 0x2000
-#define RX_EXTRA_DATA 0x4000
-
-#define HASH_INDEX_MASK 0x0FC00
-
-/*
- * PP_TxEvent - Transmit Event Bit definition - Read-only
- */
-#define TX_LOST_CRS 0x0040
-#define TX_SQE_ERROR 0x0080
-#define TX_OK 0x0100
-#define TX_LATE_COL 0x0200
-#define TX_JBR 0x0400
-#define TX_16_COL 0x8000
-#define TX_SEND_OK_BITS (TX_OK | TX_LOST_CRS)
-#define TX_COL_COUNT_MASK 0x7800
-
-/*
- * PP_BufEvent - Buffer Event Bit definition - Read-only
- */
-#define SW_INTERRUPT 0x0040
-#define RX_DMA 0x0080
-#define READY_FOR_TX 0x0100
-#define TX_UNDERRUN 0x0200
-#define RX_MISS 0x0400
-#define RX_128_BYTE 0x0800
-#define TX_COL_OVRFLW 0x1000
-#define RX_MISS_OVRFLW 0x2000
-#define RX_DEST_MATCH 0x8000
-
-/*
- * PP_LineST - Ethernet Line Status bit definition - Read-only
- */
-#define LINK_OK 0x0080
-#define AUI_ON 0x0100
-#define TENBASET_ON 0x0200
-#define POLARITY_OK 0x1000
-#define CRS_OK 0x4000
-
-/*
- * PP_SelfST - Chip Software Status bit definition
- */
-#define ACTIVE_33V 0x0040
-#define INIT_DONE 0x0080
-#define SI_BUSY 0x0100
-#define EEPROM_PRESENT 0x0200
-#define EEPROM_OK 0x0400
-#define EL_PRESENT 0x0800
-#define EE_SIZE_64 0x1000
-
-/*
- * PP_BusST - ISA Bus Status bit definition
- */
-#define TX_BID_ERROR 0x0080
-#define READY_FOR_TX_NOW 0x0100
-
-/*
- * PP_AutoNegCTL - Auto Negotiation Control bit definition
- */
-#define RE_NEG_NOW 0x0040
-#define ALLOW_FDX 0x0080
-#define AUTO_NEG_ENABLE 0x0100
-#define NLP_ENABLE 0x0200
-#define FORCE_FDX 0x8000
-#define AUTO_NEG_BITS (FORCE_FDX | NLP_ENABLE | AUTO_NEG_ENABLE)
-#define AUTO_NEG_MASK (FORCE_FDX | NLP_ENABLE | AUTO_NEG_ENABLE | \
- ALLOW_FDX | RE_NEG_NOW)
-
-/*
- * PP_AutoNegST - Auto Negotiation Status bit definition
- */
-#define AUTO_NEG_BUSY 0x0080
-#define FLP_LINK 0x0100
-#define FLP_LINK_GOOD 0x0800
-#define LINK_FAULT 0x1000
-#define HDX_ACTIVE 0x4000
-#define FDX_ACTIVE 0x8000
-
-/*
- * The following block defines the ISQ event types
- */
-#define ISQ_RECEIVER_EVENT 0x04
-#define ISQ_TRANSMITTER_EVENT 0x08
-#define ISQ_BUFFER_EVENT 0x0c
-#define ISQ_RX_MISS_EVENT 0x10
-#define ISQ_TX_COL_EVENT 0x12
-
-#define ISQ_EVENT_MASK 0x003F /* ISQ mask to find out type of event */
-#define ISQ_HIST 16 /* small history buffer */
-#define AUTOINCREMENT 0x8000 /* Bit mask to set bit-15 for autoincrement */
-
-#define TXRXBUFSIZE 0x0600
-#define RXDMABUFSIZE 0x8000
-#define RXDMASIZE 0x4000
-#define TXRX_LENGTH_MASK 0x07FF
-
-/* rx options bits */
-#define RCV_WITH_RXON 1 /* Set SerRx ON */
-#define RCV_COUNTS 2 /* Use Framecnt1 */
-#define RCV_PONG 4 /* Pong respondent */
-#define RCV_DONG 8 /* Dong operation */
-#define RCV_POLLING 0x10 /* Poll RxEvent */
-#define RCV_ISQ 0x20 /* Use ISQ, int */
-#define RCV_AUTO_DMA 0x100 /* Set AutoRxDMAE */
-#define RCV_DMA 0x200 /* Set RxDMA only */
-#define RCV_DMA_ALL 0x400 /* Copy all DMA'ed */
-#define RCV_FIXED_DATA 0x800 /* Every frame same */
-#define RCV_IO 0x1000 /* Use ISA IO only */
-#define RCV_MEMORY 0x2000 /* Use ISA Memory */
-
-#define RAM_SIZE 0x1000 /* The card has 4k bytes or RAM */
-#define PKT_START PP_TxFrame /* Start of packet RAM */
-
-#define RX_FRAME_PORT 0x0000
-#define TX_FRAME_PORT RX_FRAME_PORT
-#define TX_CMD_PORT 0x0004
-#define TX_CS8900_NOW 0x0000 /* Tx packet after 5 bytes copied */
-#define TX_CS8900_AFTER_381 0x0020 /* Tx packet after 381 bytes copied */
-#define TX_CS8900_AFTER_ALL 0x0060 /* Tx packet after all bytes copied */
-#define TX_CS8920_NOW 0x0000 /* Tx packet after 5 bytes copied */
-#define TX_CS8920_AFTER_381 0x0040 /* Tx packet after 381 bytes copied */
-#define TX_CS8920_AFTER_1021 0x0080 /* Tx packet after1021 bytes copied */
-#define TX_CS8920_AFTER_ALL 0x00C0 /* Tx packet after all bytes copied */
-#define TX_LEN_PORT 0x0006
-#define ISQ_PORT 0x0008
-#define ADD_PORT 0x000A
-#define DATA_PORT 0x000C
-
-#define EEPROM_WRITE_EN 0x00F0
-#define EEPROM_WRITE_DIS 0x0000
-#define EEPROM_WRITE_CMD 0x0100
-#define EEPROM_READ_CMD 0x0200
-
-/* Receive Header
- * Description of header of each packet in receive area of memory
- */
-#define RBUF_EVENT_LOW 0 /* Low byte of RxEvent - status of received frame */
-#define RBUF_EVENT_HIGH 1 /* High byte of RxEvent - status of received frame */
-#define RBUF_LEN_LOW 2 /* Length of received data - low byte */
-#define RBUF_LEN_HI 3 /* Length of received data - high byte */
-#define RBUF_HEAD_LEN 4 /* Length of this header */
-
-#define CHIP_READ 0x1 /* Used to mark state of the repins code (chip or dma) */
-#define DMA_READ 0x2 /* Used to mark state of the repins code (chip or dma) */
-
-/* for bios scan */
-/* */
-#ifdef CSDEBUG
-/* use these values for debugging bios scan */
-#define BIOS_START_SEG 0x00000
-#define BIOS_OFFSET_INC 0x0010
-#else
-#define BIOS_START_SEG 0x0c000
-#define BIOS_OFFSET_INC 0x0200
-#endif
-
-#define BIOS_LAST_OFFSET 0x0fc00
-
-/*
- * Byte offsets into the EEPROM configuration buffer
- */
-#define ISA_CNF_OFFSET 0x6
-#define TX_CTL_OFFSET (ISA_CNF_OFFSET + 8) /* 8900 eeprom */
-#define AUTO_NEG_CNF_OFFSET (ISA_CNF_OFFSET + 8) /* 8920 eeprom */
-
-/*
- * the assumption here is that the bits in the eeprom are generally
- * in the same position as those in the autonegctl register.
- * Of course the IMM bit is not in that register so it must be
- * masked out
- */
-#define EE_FORCE_FDX 0x8000
-#define EE_NLP_ENABLE 0x0200
-#define EE_AUTO_NEG_ENABLE 0x0100
-#define EE_ALLOW_FDX 0x0080
-#define EE_AUTO_NEG_CNF_MASK (EE_FORCE_FDX | EE_NLP_ENABLE | \
- EE_AUTO_NEG_ENABLE | EE_ALLOW_FDX)
-
-#define IMM_BIT 0x0040 /* ignore missing media */
-
-#define ADAPTER_CNF_OFFSET (AUTO_NEG_CNF_OFFSET + 2)
-#define A_CNF_MEDIA 0x0007
-#define A_CNF_10B_T 0x0001
-#define A_CNF_AUI 0x0002
-#define A_CNF_10B_2 0x0004
-#define A_CNF_MEDIA_TYPE 0x0060
-#define A_CNF_MEDIA_AUTO 0x0000
-#define A_CNF_MEDIA_10B_T 0x0020
-#define A_CNF_MEDIA_AUI 0x0040
-#define A_CNF_MEDIA_10B_2 0x0060
-#define A_CNF_DC_DC_POLARITY 0x0080
-#define A_CNF_NO_AUTO_POLARITY 0x2000
-#define A_CNF_LOW_RX_SQUELCH 0x4000
-#define A_CNF_EXTND_10B_2 0x8000
-
-#define PACKET_PAGE_OFFSET 0x8
-
-/*
- * Bit definitions for the ISA configuration word from the EEPROM
- */
-#define INT_NO_MASK 0x000F
-#define DMA_NO_MASK 0x0070
-#define ISA_DMA_SIZE 0x0200
-#define ISA_AUTO_RxDMA 0x0400
-#define ISA_RxDMA 0x0800
-#define DMA_BURST 0x1000
-#define STREAM_TRANSFER 0x2000
-#define ANY_ISA_DMA (ISA_AUTO_RxDMA | ISA_RxDMA)
-
-/* DMA controller registers */
-#define DMA_BASE 0x00 /* DMA controller base */
-#define DMA_BASE_2 0x0C0 /* DMA controller base */
-
-#define DMA_STAT 0x0D0 /* DMA controller status register */
-#define DMA_MASK 0x0D4 /* DMA controller mask register */
-#define DMA_MODE 0x0D6 /* DMA controller mode register */
-#define DMA_RESETFF 0x0D8 /* DMA controller first/last flip flop */
-
-/* DMA data */
-#define DMA_DISABLE 0x04 /* Disable channel n */
-#define DMA_ENABLE 0x00 /* Enable channel n */
-/* Demand transfers, incr. address, auto init, writes, ch. n */
-#define DMA_RX_MODE 0x14
-/* Demand transfers, incr. address, auto init, reads, ch. n */
-#define DMA_TX_MODE 0x18
-
-#define DMA_SIZE (16*1024) /* Size of dma buffer - 16k */
-
-#define CS8900 0x0000
-#define CS8920 0x4000
-#define CS8920M 0x6000
-#define REVISON_BITS 0x1F00
-#define EEVER_NUMBER 0x12
-#define CHKSUM_LEN 0x14
-#define CHKSUM_VAL 0x0000
-#define START_EEPROM_DATA 0x001c /* Offset into eeprom for start of data */
-#define IRQ_MAP_EEPROM_DATA 0x0046 /* Offset into eeprom for the IRQ map */
-#define IRQ_MAP_LEN 0x0004 /* No of bytes to read for the IRQ map */
-#define PNP_IRQ_FRMT 0x0022 /* PNP small item IRQ format */
-#define CS8900_IRQ_MAP 0x1c20 /* This IRQ map is fixed */
-
-#define CS8920_NO_INTS 0x0F /* Max CS8920 interrupt select # */
-
-#define PNP_ADD_PORT 0x0279
-#define PNP_WRITE_PORT 0x0A79
-
-#define GET_PNP_ISA_STRUCT 0x40
-#define PNP_ISA_STRUCT_LEN 0x06
-#define PNP_CSN_CNT_OFF 0x01
-#define PNP_RD_PORT_OFF 0x02
-#define PNP_FUNCTION_OK 0x00
-#define PNP_WAKE 0x03
-#define PNP_RSRC_DATA 0x04
-#define PNP_RSRC_READY 0x01
-#define PNP_STATUS 0x05
-#define PNP_ACTIVATE 0x30
-#define PNP_CNF_IO_H 0x60
-#define PNP_CNF_IO_L 0x61
-#define PNP_CNF_INT 0x70
-#define PNP_CNF_DMA 0x74
-#define PNP_CNF_MEM 0x48
-
-#define BIT0 1
-#define BIT15 0x8000
-
-#define CS_DUPLEX_AUTO 0
-#define CS_DUPLEX_FULL 1
-#define CS_DUPLEX_HALF 2
-
-/* Device name */
-#define CS_NAME "cs"
-
-#define cs_readreg(iobase, portno) \
- (outw((iobase) + ADD_PORT, (portno)), \
- inw((iobase) + DATA_PORT))
-#define cs_writereg(iobase, portno, value) \
- (outw((iobase) + ADD_PORT, (portno)), \
- outw((iobase) + DATA_PORT, (value)))
-#define cs_readword(iobase, portno) \
- (inw((iobase) + (portno)))
-#define cs_writeword(iobase, portno, value) \
- (outw((iobase) + (portno), (value)))
-
-#define reset_chip(nic_addr) \
- cs_writereg(nic_addr, PP_SelfCTL, cs_readreg(ioaddr, PP_SelfCTL) | POWER_ON_RESET), \
- DELAY(30000)
-
-#define cs_duplex_full(sc) \
- (cs_writereg(sc->nic_addr, PP_AutoNegCTL, FORCE_FDX))
-
-#define cs_duplex_half(sc) \
- (cs_writereg(sc->nic_addr, PP_AutoNegCTL, NLP_ENABLE))
-
diff --git a/sys/dev/cy/cy.c b/sys/dev/cy/cy.c
deleted file mode 100644
index dfeb69ac11e5..000000000000
--- a/sys/dev/cy/cy.c
+++ /dev/null
@@ -1,2885 +0,0 @@
-/*-
- * cyclades cyclom-y serial driver
- * Andrew Herbert <andrew@werple.apana.org.au>, 17 August 1993
- *
- * Copyright (c) 1993 Andrew Herbert.
- * 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 Andrew Herbert may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY ``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 I 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.
- *
- * $FreeBSD$
- */
-
-#include "opt_compat.h"
-#include "cy.h"
-
-/*
- * TODO:
- * Atomic COR change.
- * Consoles.
- */
-
-/*
- * Temporary compile-time configuration options.
- */
-#define RxFifoThreshold (CD1400_RX_FIFO_SIZE / 2)
- /* Number of chars in the receiver FIFO before an
- * an interrupt is generated. Should depend on
- * line speed. Needs to be about 6 on a 486DX33
- * for 4 active ports at 115200 bps. Why doesn't
- * 10 work?
- */
-#define PollMode /* Use polling-based irq service routine, not the
- * hardware svcack lines. Must be defined for
- * Cyclom-16Y boards. Less efficient for Cyclom-8Ys,
- * and stops 4 * 115200 bps from working.
- */
-#undef Smarts /* Enable slightly more CD1400 intelligence. Mainly
- * the output CR/LF processing, plus we can avoid a
- * few checks usually done in ttyinput().
- *
- * XXX not fully implemented, and not particularly
- * worthwhile.
- */
-#undef CyDebug /* Include debugging code (not very expensive). */
-
-/* These will go away. */
-#undef SOFT_CTS_OFLOW
-#define SOFT_HOTCHAR
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/tty.h>
-#include <sys/proc.h>
-#include <sys/conf.h>
-#include <sys/dkstat.h>
-#include <sys/fcntl.h>
-#include <sys/interrupt.h>
-#include <sys/kernel.h>
-#include <sys/malloc.h>
-#include <sys/syslog.h>
-#include <machine/clock.h>
-#include <machine/ipl.h>
-#ifndef SMP
-#include <machine/lock.h>
-#endif
-#include <machine/psl.h>
-
-#include <i386/isa/isa_device.h>
-#include <i386/isa/cyreg.h>
-#include <i386/isa/ic/cd1400.h>
-
-#ifdef SMP
-#define disable_intr() COM_DISABLE_INTR()
-#define enable_intr() COM_ENABLE_INTR()
-#endif /* SMP */
-
-/*
- * Dictionary so that I can name everything *sio* or *com* to compare with
- * sio.c. There is also lots of ugly formatting and unnecessary ifdefs to
- * simplify the comparision. These will go away.
- */
-#define LSR_BI CD1400_RDSR_BREAK
-#define LSR_FE CD1400_RDSR_FE
-#define LSR_OE CD1400_RDSR_OE
-#define LSR_PE CD1400_RDSR_PE
-#define MCR_DTR CD1400_MSVR2_DTR
-#define MCR_RTS CD1400_MSVR1_RTS
-#define MSR_CTS CD1400_MSVR2_CTS
-#define MSR_DCD CD1400_MSVR2_CD
-#define MSR_DSR CD1400_MSVR2_DSR
-#define MSR_RI CD1400_MSVR2_RI
-#define NSIO (NCY * CY_MAX_PORTS)
-#define comconsole cyconsole
-#define comdefaultrate cydefaultrate
-#define com_events cy_events
-#define comhardclose cyhardclose
-#define commctl cymctl
-#define comparam cyparam
-#define comspeed cyspeed
-#define comstart cystart
-#define comwakeup cywakeup
-#define nsio_tty ncy_tty
-#define p_com_addr p_cy_addr
-#define sioattach cyattach
-#define sioclose cyclose
-#define siodriver cydriver
-#define siodtrwakeup cydtrwakeup
-#define sioinput cyinput
-#define siointr cyintr
-#define siointr1 cyintr1
-#define sioioctl cyioctl
-#define sioopen cyopen
-#define siopoll cypoll
-#define sioprobe cyprobe
-#define siosettimeout cysettimeout
-#define siosetwater cysetwater
-#define comstop cystop
-#define siowrite cywrite
-#define sio_registered cy_registered
-#define sio_timeout cy_timeout
-#define sio_timeout_handle cy_timeout_handle
-#define sio_timeouts_until_log cy_timeouts_until_log
-#define sio_tty cy_tty
-
-#define CY_MAX_PORTS (CD1400_NO_OF_CHANNELS * CY_MAX_CD1400s)
-
-/* We encode the cyclom unit number (cyu) in spare bits in the IVR's. */
-#define CD1400_xIVR_CHAN_SHIFT 3
-#define CD1400_xIVR_CHAN 0x1F
-
-/*
- * ETC states. com->etc may also contain a hardware ETC command value,
- * meaning that execution of that command is pending.
- */
-#define ETC_NONE 0 /* we depend on bzero() setting this */
-#define ETC_BREAK_STARTING 1
-#define ETC_BREAK_STARTED 2
-#define ETC_BREAK_ENDING 3
-#define ETC_BREAK_ENDED 4
-
-#define LOTS_OF_EVENTS 64 /* helps separate urgent events from input */
-
-#define CALLOUT_MASK 0x80
-#define CONTROL_MASK 0x60
-#define CONTROL_INIT_STATE 0x20
-#define CONTROL_LOCK_STATE 0x40
-#define DEV_TO_UNIT(dev) (MINOR_TO_UNIT(minor(dev)))
-#define MINOR_MAGIC_MASK (CALLOUT_MASK | CONTROL_MASK)
-#define MINOR_TO_UNIT(mynor) (((mynor) >> 16) * CY_MAX_PORTS \
- | (((mynor) & 0xff) & ~MINOR_MAGIC_MASK))
-
-/*
- * com state bits.
- * (CS_BUSY | CS_TTGO) and (CS_BUSY | CS_TTGO | CS_ODEVREADY) must be higher
- * than the other bits so that they can be tested as a group without masking
- * off the low bits.
- *
- * The following com and tty flags correspond closely:
- * CS_BUSY = TS_BUSY (maintained by comstart(), siopoll() and
- * comstop())
- * CS_TTGO = ~TS_TTSTOP (maintained by comparam() and comstart())
- * CS_CTS_OFLOW = CCTS_OFLOW (maintained by comparam())
- * CS_RTS_IFLOW = CRTS_IFLOW (maintained by comparam())
- * TS_FLUSH is not used.
- * XXX I think TIOCSETA doesn't clear TS_TTSTOP when it clears IXON.
- * XXX CS_*FLOW should be CF_*FLOW in com->flags (control flags not state).
- */
-#define CS_BUSY 0x80 /* output in progress */
-#define CS_TTGO 0x40 /* output not stopped by XOFF */
-#define CS_ODEVREADY 0x20 /* external device h/w ready (CTS) */
-#define CS_CHECKMSR 1 /* check of MSR scheduled */
-#define CS_CTS_OFLOW 2 /* use CTS output flow control */
-#define CS_DTR_OFF 0x10 /* DTR held off */
-#define CS_ODONE 4 /* output completed */
-#define CS_RTS_IFLOW 8 /* use RTS input flow control */
-#define CSE_ODONE 1 /* output transmitted */
-
-static char const * const error_desc[] = {
-#define CE_OVERRUN 0
- "silo overflow",
-#define CE_INTERRUPT_BUF_OVERFLOW 1
- "interrupt-level buffer overflow",
-#define CE_TTY_BUF_OVERFLOW 2
- "tty-level buffer overflow",
-};
-
-#define CE_NTYPES 3
-#define CE_RECORD(com, errnum) (++(com)->delta_error_counts[errnum])
-
-/* types. XXX - should be elsewhere */
-typedef u_char bool_t; /* boolean */
-typedef u_char volatile *cy_addr;
-
-/* queue of linear buffers */
-struct lbq {
- u_char *l_head; /* next char to process */
- u_char *l_tail; /* one past the last char to process */
- struct lbq *l_next; /* next in queue */
- bool_t l_queued; /* nonzero if queued */
-};
-
-/* com device structure */
-struct com_s {
- u_char state; /* miscellaneous flag bits */
- bool_t active_out; /* nonzero if the callout device is open */
-#if 0
- u_char cfcr_image; /* copy of value written to CFCR */
-#endif
- u_char etc; /* pending Embedded Transmit Command */
- u_char extra_state; /* more flag bits, separate for order trick */
-#if 0
- u_char fifo_image; /* copy of value written to FIFO */
-#endif
- u_char gfrcr_image; /* copy of value read from GFRCR */
-#if 0
- bool_t hasfifo; /* nonzero for 16550 UARTs */
- bool_t loses_outints; /* nonzero if device loses output interrupts */
-#endif
- u_char mcr_dtr; /* MCR bit that is wired to DTR */
- u_char mcr_image; /* copy of value written to MCR */
- u_char mcr_rts; /* MCR bit that is wired to RTS */
-#if 0
-#ifdef COM_MULTIPORT
- bool_t multiport; /* is this unit part of a multiport device? */
-#endif /* COM_MULTIPORT */
- bool_t no_irq; /* nonzero if irq is not attached */
- bool_t poll; /* nonzero if polling is required */
- bool_t poll_output; /* nonzero if polling for output is required */
-#endif
- int unit; /* unit number */
- int dtr_wait; /* time to hold DTR down on close (* 1/hz) */
-#if 0
- u_int tx_fifo_size;
-#endif
- u_int wopeners; /* # processes waiting for DCD in open() */
-
- /*
- * The high level of the driver never reads status registers directly
- * because there would be too many side effects to handle conveniently.
- * Instead, it reads copies of the registers stored here by the
- * interrupt handler.
- */
- u_char last_modem_status; /* last MSR read by intr handler */
- u_char prev_modem_status; /* last MSR handled by high level */
-
- u_char hotchar; /* ldisc-specific char to be handled ASAP */
- u_char *ibuf; /* start of input buffer */
- u_char *ibufend; /* end of input buffer */
- u_char *ibufold; /* old input buffer, to be freed */
- u_char *ihighwater; /* threshold in input buffer */
- u_char *iptr; /* next free spot in input buffer */
- int ibufsize; /* size of ibuf (not include error bytes) */
- int ierroff; /* offset of error bytes in ibuf */
-
- struct lbq obufq; /* head of queue of output buffers */
- struct lbq obufs[2]; /* output buffers */
-
- int cy_align; /* index for register alignment */
- cy_addr cy_iobase; /* base address of this port's cyclom */
- cy_addr iobase; /* base address of this port's cd1400 */
- int mcr_rts_reg; /* cd1400 reg number of reg holding mcr_rts */
-
- struct tty *tp; /* cross reference */
-
- /* Initial state. */
- struct termios it_in; /* should be in struct tty */
- struct termios it_out;
-
- /* Lock state. */
- struct termios lt_in; /* should be in struct tty */
- struct termios lt_out;
-
- bool_t do_timestamp;
- bool_t do_dcd_timestamp;
- struct timeval timestamp;
- struct timeval dcd_timestamp;
-
- u_long bytes_in; /* statistics */
- u_long bytes_out;
- u_int delta_error_counts[CE_NTYPES];
- u_long error_counts[CE_NTYPES];
-
- u_int recv_exception; /* exception chars received */
- u_int mdm; /* modem signal changes */
-#ifdef CyDebug
- u_int start_count; /* no. of calls to comstart() */
- u_int start_real; /* no. of calls that did something */
-#endif
- u_char car; /* CD1400 CAR shadow (if first unit in cd) */
- u_char channel_control;/* CD1400 CCR control command shadow */
- u_char cor[3]; /* CD1400 COR1-3 shadows */
- u_char intr_enable; /* CD1400 SRER shadow */
-
- /*
- * Data area for output buffers. Someday we should build the output
- * buffer queue without copying data.
- */
- u_char obuf1[256];
- u_char obuf2[256];
-};
-
-/* PCI driver entry point. */
-int cyattach_common __P((cy_addr cy_iobase, int cy_align));
-ointhand2_t siointr;
-
-static int cy_units __P((cy_addr cy_iobase, int cy_align));
-static int sioattach __P((struct isa_device *dev));
-static void cd1400_channel_cmd __P((struct com_s *com, int cmd));
-static void cd1400_channel_cmd_wait __P((struct com_s *com));
-static void cd_etc __P((struct com_s *com, int etc));
-static int cd_getreg __P((struct com_s *com, int reg));
-static void cd_setreg __P((struct com_s *com, int reg, int val));
-static timeout_t siodtrwakeup;
-static void comhardclose __P((struct com_s *com));
-static void sioinput __P((struct com_s *com));
-#if 0
-static void siointr1 __P((struct com_s *com));
-#endif
-static int commctl __P((struct com_s *com, int bits, int how));
-static int comparam __P((struct tty *tp, struct termios *t));
-static swihand_t siopoll;
-static int sioprobe __P((struct isa_device *dev));
-static void siosettimeout __P((void));
-static int siosetwater __P((struct com_s *com, speed_t speed));
-static int comspeed __P((speed_t speed, u_long cy_clock,
- int *prescaler_io));
-static void comstart __P((struct tty *tp));
-static void comstop __P((struct tty *tp, int rw));
-static timeout_t comwakeup;
-static void disc_optim __P((struct tty *tp, struct termios *t,
- struct com_s *com));
-
-#ifdef CyDebug
-void cystatus __P((int unit));
-#endif
-
-static char driver_name[] = "cy";
-
-/* table and macro for fast conversion from a unit number to its com struct */
-static struct com_s *p_com_addr[NSIO];
-#define com_addr(unit) (p_com_addr[unit])
-
-struct isa_driver siodriver = {
- sioprobe, sioattach, driver_name
-};
-
-static d_open_t sioopen;
-static d_close_t sioclose;
-static d_write_t siowrite;
-static d_ioctl_t sioioctl;
-
-#define CDEV_MAJOR 48
-static struct cdevsw sio_cdevsw = {
- /* open */ sioopen,
- /* close */ sioclose,
- /* read */ ttyread,
- /* write */ siowrite,
- /* ioctl */ sioioctl,
- /* poll */ ttypoll,
- /* mmap */ nommap,
- /* strategy */ nostrategy,
- /* name */ driver_name,
- /* maj */ CDEV_MAJOR,
- /* dump */ nodump,
- /* psize */ nopsize,
- /* flags */ D_TTY,
- /* bmaj */ -1
-};
-
-static int comconsole = -1;
-static speed_t comdefaultrate = TTYDEF_SPEED;
-static u_int com_events; /* input chars + weighted output completions */
-static bool_t sio_registered;
-static int sio_timeout;
-static int sio_timeouts_until_log;
-static struct callout_handle sio_timeout_handle
- = CALLOUT_HANDLE_INITIALIZER(&sio_timeout_handle);
-#if 0 /* XXX */
-static struct tty *sio_tty[NSIO];
-#else
-static struct tty sio_tty[NSIO];
-#endif
-static const int nsio_tty = NSIO;
-
-#ifdef CyDebug
-static u_int cd_inbs;
-static u_int cy_inbs;
-static u_int cd_outbs;
-static u_int cy_outbs;
-static u_int cy_svrr_probes;
-static u_int cy_timeouts;
-#endif
-
-static int cy_chip_offset[] = {
- 0x0000, 0x0400, 0x0800, 0x0c00, 0x0200, 0x0600, 0x0a00, 0x0e00,
-};
-static int cy_nr_cd1400s[NCY];
-static int cy_total_devices;
-#undef RxFifoThreshold
-static int volatile RxFifoThreshold = (CD1400_RX_FIFO_SIZE / 2);
-
-static int
-sioprobe(dev)
- struct isa_device *dev;
-{
- cy_addr iobase;
-
- iobase = (cy_addr)dev->id_maddr;
-
- /* Cyclom-16Y hardware reset (Cyclom-8Ys don't care) */
- cy_inb(iobase, CY16_RESET, 0); /* XXX? */
- DELAY(500); /* wait for the board to get its act together */
-
- /* this is needed to get the board out of reset */
- cy_outb(iobase, CY_CLEAR_INTR, 0, 0);
- DELAY(500);
-
- return (cy_units(iobase, 0) == 0 ? 0 : -1);
-}
-
-static int
-cy_units(cy_iobase, cy_align)
- cy_addr cy_iobase;
- int cy_align;
-{
- int cyu;
- u_char firmware_version;
- int i;
- cy_addr iobase;
-
- for (cyu = 0; cyu < CY_MAX_CD1400s; ++cyu) {
- iobase = cy_iobase + (cy_chip_offset[cyu] << cy_align);
-
- /* wait for chip to become ready for new command */
- for (i = 0; i < 10; i++) {
- DELAY(50);
- if (!cd_inb(iobase, CD1400_CCR, cy_align))
- break;
- }
-
- /* clear the GFRCR register */
- cd_outb(iobase, CD1400_GFRCR, cy_align, 0);
-
- /* issue a reset command */
- cd_outb(iobase, CD1400_CCR, cy_align,
- CD1400_CCR_CMDRESET | CD1400_CCR_FULLRESET);
-
- /* wait for the CD1400 to initialize itself */
- for (i = 0; i < 200; i++) {
- DELAY(50);
-
- /* retrieve firmware version */
- firmware_version = cd_inb(iobase, CD1400_GFRCR,
- cy_align);
- if ((firmware_version & 0xf0) == 0x40)
- break;
- }
-
- /*
- * Anything in the 0x40-0x4F range is fine.
- * If one CD1400 is bad then we don't support higher
- * numbered good ones on this board.
- */
- if ((firmware_version & 0xf0) != 0x40)
- break;
- }
- return (cyu);
-}
-
-static int
-sioattach(isdp)
- struct isa_device *isdp;
-{
- int adapter;
-
- adapter = cyattach_common((cy_addr) isdp->id_maddr, 0);
- if (adapter < 0)
- return (0);
-
- /*
- * XXX
- * This kludge is to allow ISA/PCI device specifications in the
- * kernel config file to be in any order.
- */
- if (isdp->id_unit != adapter) {
- printf("cy%d: attached as cy%d\n", isdp->id_unit, adapter);
- isdp->id_unit = adapter; /* XXX */
- }
- isdp->id_ointr = siointr;
- /* isdp->id_ri_flags |= RI_FAST; XXX unimplemented - use newbus! */
- return (1);
-}
-
-int
-cyattach_common(cy_iobase, cy_align)
- cy_addr cy_iobase;
- int cy_align;
-{
- int adapter;
- int cyu;
- u_char firmware_version;
- cy_addr iobase;
- int ncyu;
- int unit;
-
- adapter = cy_total_devices;
- if ((u_int)adapter >= NCY) {
- printf(
- "cy%d: can't attach adapter: insufficient cy devices configured\n",
- adapter);
- return (-1);
- }
- ncyu = cy_units(cy_iobase, cy_align);
- if (ncyu == 0)
- return (-1);
- cy_nr_cd1400s[adapter] = ncyu;
- cy_total_devices++;
-
- unit = adapter * CY_MAX_PORTS;
- for (cyu = 0; cyu < ncyu; ++cyu) {
- int cdu;
-
- iobase = (cy_addr) (cy_iobase
- + (cy_chip_offset[cyu] << cy_align));
- firmware_version = cd_inb(iobase, CD1400_GFRCR, cy_align);
-
- /* Set up a receive timeout period of than 1+ ms. */
- cd_outb(iobase, CD1400_PPR, cy_align,
- howmany(CY_CLOCK(firmware_version)
- / CD1400_PPR_PRESCALER, 1000));
-
- for (cdu = 0; cdu < CD1400_NO_OF_CHANNELS; ++cdu, ++unit) {
- struct com_s *com;
- int s;
-
- com = malloc(sizeof *com, M_DEVBUF, M_NOWAIT);
- if (com == NULL)
- break;
- bzero(com, sizeof *com);
- com->unit = unit;
- com->gfrcr_image = firmware_version;
- if (CY_RTS_DTR_SWAPPED(firmware_version)) {
- com->mcr_dtr = MCR_RTS;
- com->mcr_rts = MCR_DTR;
- com->mcr_rts_reg = CD1400_MSVR2;
- } else {
- com->mcr_dtr = MCR_DTR;
- com->mcr_rts = MCR_RTS;
- com->mcr_rts_reg = CD1400_MSVR1;
- }
- com->dtr_wait = 3 * hz;
- com->obufs[0].l_head = com->obuf1;
- com->obufs[1].l_head = com->obuf2;
-
- com->cy_align = cy_align;
- com->cy_iobase = cy_iobase;
- com->iobase = iobase;
- com->car = ~CD1400_CAR_CHAN;
-
- /*
- * We don't use all the flags from <sys/ttydefaults.h> since they
- * are only relevant for logins. It's important to have echo off
- * initially so that the line doesn't start blathering before the
- * echo flag can be turned off.
- */
- com->it_in.c_iflag = 0;
- com->it_in.c_oflag = 0;
- com->it_in.c_cflag = TTYDEF_CFLAG;
- com->it_in.c_lflag = 0;
- if (unit == comconsole) {
- com->it_in.c_iflag = TTYDEF_IFLAG;
- com->it_in.c_oflag = TTYDEF_OFLAG;
- com->it_in.c_cflag = TTYDEF_CFLAG | CLOCAL;
- com->it_in.c_lflag = TTYDEF_LFLAG;
- com->lt_out.c_cflag = com->lt_in.c_cflag = CLOCAL;
- }
- if (siosetwater(com, com->it_in.c_ispeed) != 0) {
- enable_intr();
- free(com, M_DEVBUF);
- return (0);
- }
- enable_intr();
- termioschars(&com->it_in);
- com->it_in.c_ispeed = com->it_in.c_ospeed = comdefaultrate;
- com->it_out = com->it_in;
-
- s = spltty();
- com_addr(unit) = com;
- splx(s);
-
- if (!sio_registered) {
- cdevsw_add(&sio_cdevsw);
- register_swi(SWI_TTY, siopoll);
- sio_registered = TRUE;
- }
- make_dev(&sio_cdevsw, unit,
- UID_ROOT, GID_WHEEL, 0600, "ttyc%r%r", adapter,
- unit % CY_MAX_PORTS);
- make_dev(&sio_cdevsw, unit | CONTROL_INIT_STATE,
- UID_ROOT, GID_WHEEL, 0600, "ttyic%r%r", adapter,
- unit % CY_MAX_PORTS);
- make_dev(&sio_cdevsw, unit | CONTROL_LOCK_STATE,
- UID_ROOT, GID_WHEEL, 0600, "ttylc%r%r", adapter,
- unit % CY_MAX_PORTS);
- make_dev(&sio_cdevsw, unit | CALLOUT_MASK,
- UID_UUCP, GID_DIALER, 0660, "cuac%r%r", adapter,
- unit % CY_MAX_PORTS);
- make_dev(&sio_cdevsw, unit | CALLOUT_MASK | CONTROL_INIT_STATE,
- UID_UUCP, GID_DIALER, 0660, "cuaic%r%r", adapter,
- unit % CY_MAX_PORTS);
- make_dev(&sio_cdevsw, unit | CALLOUT_MASK | CONTROL_LOCK_STATE,
- UID_UUCP, GID_DIALER, 0660, "cualc%r%r", adapter,
- unit % CY_MAX_PORTS);
- }
- }
-
- /* ensure an edge for the next interrupt */
- cy_outb(cy_iobase, CY_CLEAR_INTR, cy_align, 0);
-
- return (adapter);
-}
-
-static int
-sioopen(dev, flag, mode, p)
- dev_t dev;
- int flag;
- int mode;
- struct proc *p;
-{
- struct com_s *com;
- int error;
- int mynor;
- int s;
- struct tty *tp;
- int unit;
-
- mynor = minor(dev);
- unit = MINOR_TO_UNIT(mynor);
- if ((u_int) unit >= NSIO || (com = com_addr(unit)) == NULL)
- return (ENXIO);
- if (mynor & CONTROL_MASK)
- return (0);
-#if 0 /* XXX */
- tp = com->tp = sio_tty[unit] = ttymalloc(sio_tty[unit]);
-#else
- tp = com->tp = &sio_tty[unit];
-#endif
- dev->si_tty = tp;
- s = spltty();
- /*
- * We jump to this label after all non-interrupted sleeps to pick
- * up any changes of the device state.
- */
-open_top:
- while (com->state & CS_DTR_OFF) {
- error = tsleep(&com->dtr_wait, TTIPRI | PCATCH, "cydtr", 0);
- if (error != 0)
- goto out;
- }
- if (tp->t_state & TS_ISOPEN) {
- /*
- * The device is open, so everything has been initialized.
- * Handle conflicts.
- */
- if (mynor & CALLOUT_MASK) {
- if (!com->active_out) {
- error = EBUSY;
- goto out;
- }
- } else {
- if (com->active_out) {
- if (flag & O_NONBLOCK) {
- error = EBUSY;
- goto out;
- }
- error = tsleep(&com->active_out,
- TTIPRI | PCATCH, "cybi", 0);
- if (error != 0)
- goto out;
- goto open_top;
- }
- }
- if (tp->t_state & TS_XCLUDE &&
- suser(p)) {
- error = EBUSY;
- goto out;
- }
- } else {
- /*
- * The device isn't open, so there are no conflicts.
- * Initialize it. Initialization is done twice in many
- * cases: to preempt sleeping callin opens if we are
- * callout, and to complete a callin open after DCD rises.
- */
- tp->t_oproc = comstart;
- tp->t_stop = comstop;
- tp->t_param = comparam;
- tp->t_dev = dev;
- tp->t_termios = mynor & CALLOUT_MASK
- ? com->it_out : com->it_in;
-
- /* Encode per-board unit in LIVR for access in intr routines. */
- cd_setreg(com, CD1400_LIVR,
- (unit & CD1400_xIVR_CHAN) << CD1400_xIVR_CHAN_SHIFT);
-
- (void)commctl(com, TIOCM_DTR | TIOCM_RTS, DMSET);
-#if 0
- com->poll = com->no_irq;
- com->poll_output = com->loses_outints;
-#endif
- ++com->wopeners;
- error = comparam(tp, &tp->t_termios);
- --com->wopeners;
- if (error != 0)
- goto out;
-#if 0
- if (com->hasfifo) {
- /*
- * (Re)enable and flush fifos.
- *
- * Certain SMC chips cause problems if the fifos
- * are enabled while input is ready. Turn off the
- * fifo if necessary to clear the input. We test
- * the input ready bit after enabling the fifos
- * since we've already enabled them in comparam()
- * and to handle races between enabling and fresh
- * input.
- */
- while (TRUE) {
- outb(iobase + com_fifo,
- FIFO_RCV_RST | FIFO_XMT_RST
- | com->fifo_image);
- DELAY(100);
- if (!(inb(com->line_status_port) & LSR_RXRDY))
- break;
- outb(iobase + com_fifo, 0);
- DELAY(100);
- (void) inb(com->data_port);
- }
- }
-
- disable_intr();
- (void) inb(com->line_status_port);
- (void) inb(com->data_port);
- com->prev_modem_status = com->last_modem_status
- = inb(com->modem_status_port);
- outb(iobase + com_ier, IER_ERXRDY | IER_ETXRDY | IER_ERLS
- | IER_EMSC);
- enable_intr();
-#else /* !0 */
- /*
- * Flush fifos. This requires a full channel reset which
- * also disables the transmitter and receiver. Recover
- * from this.
- */
- cd1400_channel_cmd(com,
- CD1400_CCR_CMDRESET | CD1400_CCR_CHANRESET);
- cd1400_channel_cmd(com, com->channel_control);
-
- disable_intr();
- com->prev_modem_status = com->last_modem_status
- = cd_getreg(com, CD1400_MSVR2);
- cd_setreg(com, CD1400_SRER,
- com->intr_enable
- = CD1400_SRER_MDMCH | CD1400_SRER_RXDATA);
- enable_intr();
-#endif /* 0 */
- /*
- * Handle initial DCD. Callout devices get a fake initial
- * DCD (trapdoor DCD). If we are callout, then any sleeping
- * callin opens get woken up and resume sleeping on "cybi"
- * instead of "cydcd".
- */
- /*
- * XXX `mynor & CALLOUT_MASK' should be
- * `tp->t_cflag & (SOFT_CARRIER | TRAPDOOR_CARRIER) where
- * TRAPDOOR_CARRIER is the default initial state for callout
- * devices and SOFT_CARRIER is like CLOCAL except it hides
- * the true carrier.
- */
- if (com->prev_modem_status & MSR_DCD || mynor & CALLOUT_MASK)
- (*linesw[tp->t_line].l_modem)(tp, 1);
- }
- /*
- * Wait for DCD if necessary.
- */
- if (!(tp->t_state & TS_CARR_ON) && !(mynor & CALLOUT_MASK)
- && !(tp->t_cflag & CLOCAL) && !(flag & O_NONBLOCK)) {
- ++com->wopeners;
- error = tsleep(TSA_CARR_ON(tp), TTIPRI | PCATCH, "cydcd", 0);
- --com->wopeners;
- if (error != 0)
- goto out;
- goto open_top;
- }
- error = (*linesw[tp->t_line].l_open)(dev, tp);
- disc_optim(tp, &tp->t_termios, com);
- if (tp->t_state & TS_ISOPEN && mynor & CALLOUT_MASK)
- com->active_out = TRUE;
- siosettimeout();
-out:
- splx(s);
- if (!(tp->t_state & TS_ISOPEN) && com->wopeners == 0)
- comhardclose(com);
- return (error);
-}
-
-static int
-sioclose(dev, flag, mode, p)
- dev_t dev;
- int flag;
- int mode;
- struct proc *p;
-{
- struct com_s *com;
- int mynor;
- int s;
- struct tty *tp;
-
- mynor = minor(dev);
- if (mynor & CONTROL_MASK)
- return (0);
- com = com_addr(MINOR_TO_UNIT(mynor));
- tp = com->tp;
- s = spltty();
- cd_etc(com, CD1400_ETC_STOPBREAK);
- (*linesw[tp->t_line].l_close)(tp, flag);
- disc_optim(tp, &tp->t_termios, com);
- comstop(tp, FREAD | FWRITE);
- comhardclose(com);
- ttyclose(tp);
- siosettimeout();
- splx(s);
-#ifdef broken /* session holds a ref to the tty; can't deallocate */
- ttyfree(tp);
- com->tp = sio_tty[unit] = NULL;
-#endif
- return (0);
-}
-
-static void
-comhardclose(com)
- struct com_s *com;
-{
- cy_addr iobase;
- int s;
- struct tty *tp;
- int unit;
-
- unit = com->unit;
- iobase = com->iobase;
- s = spltty();
-#if 0
- com->poll = FALSE;
- com->poll_output = FALSE;
-#endif
- com->do_timestamp = 0;
-#if 0
- outb(iobase + com_cfcr, com->cfcr_image &= ~CFCR_SBREAK);
-#else
- /* XXX */
- disable_intr();
- com->etc = ETC_NONE;
- cd_setreg(com, CD1400_COR2, com->cor[1] &= ~CD1400_COR2_ETC);
- enable_intr();
- cd1400_channel_cmd(com, CD1400_CCR_CMDRESET | CD1400_CCR_FTF);
-#endif
-
- {
-#if 0
- outb(iobase + com_ier, 0);
-#else
- disable_intr();
- cd_setreg(com, CD1400_SRER, com->intr_enable = 0);
- enable_intr();
-#endif
- tp = com->tp;
- if ((tp->t_cflag & HUPCL)
- /*
- * XXX we will miss any carrier drop between here and the
- * next open. Perhaps we should watch DCD even when the
- * port is closed; it is not sufficient to check it at
- * the next open because it might go up and down while
- * we're not watching.
- */
- || (!com->active_out
- && !(com->prev_modem_status & MSR_DCD)
- && !(com->it_in.c_cflag & CLOCAL))
- || !(tp->t_state & TS_ISOPEN)) {
- (void)commctl(com, TIOCM_DTR, DMBIC);
-
- /* Disable receiver (leave transmitter enabled). */
- com->channel_control = CD1400_CCR_CMDCHANCTL
- | CD1400_CCR_XMTEN
- | CD1400_CCR_RCVDIS;
- cd1400_channel_cmd(com, com->channel_control);
-
- if (com->dtr_wait != 0 && !(com->state & CS_DTR_OFF)) {
- timeout(siodtrwakeup, com, com->dtr_wait);
- com->state |= CS_DTR_OFF;
- }
- }
- }
-#if 0
- if (com->hasfifo) {
- /*
- * Disable fifos so that they are off after controlled
- * reboots. Some BIOSes fail to detect 16550s when the
- * fifos are enabled.
- */
- outb(iobase + com_fifo, 0);
- }
-#endif
- com->active_out = FALSE;
- wakeup(&com->active_out);
- wakeup(TSA_CARR_ON(tp)); /* restart any wopeners */
- splx(s);
-}
-
-static int
-siowrite(dev, uio, flag)
- dev_t dev;
- struct uio *uio;
- int flag;
-{
- int mynor;
- struct tty *tp;
- int unit;
-
- mynor = minor(dev);
- if (mynor & CONTROL_MASK)
- return (ENODEV);
-
- unit = MINOR_TO_UNIT(mynor);
- tp = com_addr(unit)->tp;
- /*
- * (XXX) We disallow virtual consoles if the physical console is
- * a serial port. This is in case there is a display attached that
- * is not the console. In that situation we don't need/want the X
- * server taking over the console.
- */
- if (constty != NULL && unit == comconsole)
- constty = NULL;
-#ifdef Smarts
- /* XXX duplicate ttwrite(), but without so much output processing on
- * CR & LF chars. Hardly worth the effort, given that high-throughput
- * sessions are raw anyhow.
- */
-#else
- return ((*linesw[tp->t_line].l_write)(tp, uio, flag));
-#endif
-}
-
-static void
-siodtrwakeup(chan)
- void *chan;
-{
- struct com_s *com;
-
- com = (struct com_s *)chan;
- com->state &= ~CS_DTR_OFF;
- wakeup(&com->dtr_wait);
-}
-
-static void
-sioinput(com)
- struct com_s *com;
-{
- u_char *buf;
- int incc;
- u_char line_status;
- int recv_data;
- struct tty *tp;
-
- buf = com->ibuf;
- tp = com->tp;
- if (!(tp->t_state & TS_ISOPEN)) {
- com_events -= (com->iptr - com->ibuf);
- com->iptr = com->ibuf;
- return;
- }
- if (tp->t_state & TS_CAN_BYPASS_L_RINT) {
- /*
- * Avoid the grotesquely inefficient lineswitch routine
- * (ttyinput) in "raw" mode. It usually takes about 450
- * instructions (that's without canonical processing or echo!).
- * slinput is reasonably fast (usually 40 instructions plus
- * call overhead).
- */
- do {
- enable_intr();
- incc = com->iptr - buf;
- if (tp->t_rawq.c_cc + incc > tp->t_ihiwat
- && (com->state & CS_RTS_IFLOW
- || tp->t_iflag & IXOFF)
- && !(tp->t_state & TS_TBLOCK))
- ttyblock(tp);
- com->delta_error_counts[CE_TTY_BUF_OVERFLOW]
- += b_to_q((char *)buf, incc, &tp->t_rawq);
- buf += incc;
- tk_nin += incc;
- tk_rawcc += incc;
- tp->t_rawcc += incc;
- ttwakeup(tp);
- if (tp->t_state & TS_TTSTOP
- && (tp->t_iflag & IXANY
- || tp->t_cc[VSTART] == tp->t_cc[VSTOP])) {
- tp->t_state &= ~TS_TTSTOP;
- tp->t_lflag &= ~FLUSHO;
- comstart(tp);
- }
- disable_intr();
- } while (buf < com->iptr);
- } else {
- do {
- enable_intr();
- line_status = buf[com->ierroff];
- recv_data = *buf++;
- if (line_status
- & (LSR_BI | LSR_FE | LSR_OE | LSR_PE)) {
- if (line_status & LSR_BI)
- recv_data |= TTY_BI;
- if (line_status & LSR_FE)
- recv_data |= TTY_FE;
- if (line_status & LSR_OE)
- recv_data |= TTY_OE;
- if (line_status & LSR_PE)
- recv_data |= TTY_PE;
- }
- (*linesw[tp->t_line].l_rint)(recv_data, tp);
- disable_intr();
- } while (buf < com->iptr);
- }
- com_events -= (com->iptr - com->ibuf);
- com->iptr = com->ibuf;
-
- /*
- * There is now room for another low-level buffer full of input,
- * so enable RTS if it is now disabled and there is room in the
- * high-level buffer.
- */
- if ((com->state & CS_RTS_IFLOW) && !(com->mcr_image & com->mcr_rts) &&
- !(tp->t_state & TS_TBLOCK))
-#if 0
- outb(com->modem_ctl_port, com->mcr_image |= MCR_RTS);
-#else
- cd_setreg(com, com->mcr_rts_reg,
- com->mcr_image |= com->mcr_rts);
-#endif
-}
-
-void
-siointr(unit)
- int unit;
-{
- int baseu;
- int cy_align;
- cy_addr cy_iobase;
- int cyu;
- cy_addr iobase;
- u_char status;
-
- COM_LOCK(); /* XXX could this be placed down lower in the loop? */
-
- baseu = unit * CY_MAX_PORTS;
- cy_align = com_addr(baseu)->cy_align;
- cy_iobase = com_addr(baseu)->cy_iobase;
-
- /* check each CD1400 in turn */
- for (cyu = 0; cyu < cy_nr_cd1400s[unit]; ++cyu) {
- iobase = (cy_addr) (cy_iobase
- + (cy_chip_offset[cyu] << cy_align));
- /* poll to see if it has any work */
- status = cd_inb(iobase, CD1400_SVRR, cy_align);
- if (status == 0)
- continue;
-#ifdef CyDebug
- ++cy_svrr_probes;
-#endif
- /* service requests as appropriate, giving priority to RX */
- if (status & CD1400_SVRR_RXRDY) {
- struct com_s *com;
- u_int count;
- u_char *ioptr;
- u_char line_status;
- u_char recv_data;
- u_char serv_type;
-#ifdef PollMode
- u_char save_rir;
-#endif
-
-#ifdef PollMode
- save_rir = cd_inb(iobase, CD1400_RIR, cy_align);
-
- /* enter rx service */
- cd_outb(iobase, CD1400_CAR, cy_align, save_rir);
- com_addr(baseu + cyu * CD1400_NO_OF_CHANNELS)->car
- = save_rir & CD1400_CAR_CHAN;
-
- serv_type = cd_inb(iobase, CD1400_RIVR, cy_align);
- com = com_addr(baseu
- + ((serv_type >> CD1400_xIVR_CHAN_SHIFT)
- & CD1400_xIVR_CHAN));
-#else
- /* ack receive service */
- serv_type = cy_inb(iobase, CY8_SVCACKR, cy_align);
-
- com = com_addr(baseu +
- + ((serv_type >> CD1400_xIVR_CHAN_SHIFT)
- & CD1400_xIVR_CHAN));
-#endif
-
- if (serv_type & CD1400_RIVR_EXCEPTION) {
- ++com->recv_exception;
- line_status = cd_inb(iobase, CD1400_RDSR, cy_align);
- /* break/unnattached error bits or real input? */
- recv_data = cd_inb(iobase, CD1400_RDSR, cy_align);
-#ifndef SOFT_HOTCHAR
- if (line_status & CD1400_RDSR_SPECIAL
- && com->hotchar != 0)
- setsofttty();
-#endif
-#if 1 /* XXX "intelligent" PFO error handling would break O error handling */
- if (line_status & (LSR_PE|LSR_FE|LSR_BI)) {
- /*
- Don't store PE if IGNPAR and BI if IGNBRK,
- this hack allows "raw" tty optimization
- works even if IGN* is set.
- */
- if ( com->tp == NULL
- || !(com->tp->t_state & TS_ISOPEN)
- || ((line_status & (LSR_PE|LSR_FE))
- && (com->tp->t_iflag & IGNPAR))
- || ((line_status & LSR_BI)
- && (com->tp->t_iflag & IGNBRK)))
- goto cont;
- if ( (line_status & (LSR_PE|LSR_FE))
- && (com->tp->t_state & TS_CAN_BYPASS_L_RINT)
- && ((line_status & LSR_FE)
- || ((line_status & LSR_PE)
- && (com->tp->t_iflag & INPCK))))
- recv_data = 0;
- }
-#endif /* 1 */
- ++com->bytes_in;
-#ifdef SOFT_HOTCHAR
- if (com->hotchar != 0 && recv_data == com->hotchar)
- setsofttty();
-#endif
- ioptr = com->iptr;
- if (ioptr >= com->ibufend)
- CE_RECORD(com, CE_INTERRUPT_BUF_OVERFLOW);
- else {
- if (com->do_timestamp)
- microtime(&com->timestamp);
- ++com_events;
- ioptr[0] = recv_data;
- ioptr[com->ierroff] = line_status;
- com->iptr = ++ioptr;
- if (ioptr == com->ihighwater
- && com->state & CS_RTS_IFLOW)
-#if 0
- outb(com->modem_ctl_port,
- com->mcr_image &= ~MCR_RTS);
-#else
- cd_outb(iobase, com->mcr_rts_reg,
- cy_align,
- com->mcr_image &=
- ~com->mcr_rts);
-#endif
- if (line_status & LSR_OE)
- CE_RECORD(com, CE_OVERRUN);
- }
- goto cont;
- } else {
- int ifree;
-
- count = cd_inb(iobase, CD1400_RDCR, cy_align);
- if (!count)
- goto cont;
- com->bytes_in += count;
- ioptr = com->iptr;
- ifree = com->ibufend - ioptr;
- if (count > ifree) {
- count -= ifree;
- com_events += ifree;
- if (ifree != 0) {
- if (com->do_timestamp)
- microtime(&com->timestamp);
- do {
- recv_data = cd_inb(iobase,
- CD1400_RDSR,
- cy_align);
-#ifdef SOFT_HOTCHAR
- if (com->hotchar != 0
- && recv_data
- == com->hotchar)
- setsofttty();
-#endif
- ioptr[0] = recv_data;
- ioptr[com->ierroff] = 0;
- ++ioptr;
- } while (--ifree != 0);
- }
- com->delta_error_counts
- [CE_INTERRUPT_BUF_OVERFLOW] += count;
- do {
- recv_data = cd_inb(iobase, CD1400_RDSR,
- cy_align);
-#ifdef SOFT_HOTCHAR
- if (com->hotchar != 0
- && recv_data == com->hotchar)
- setsofttty();
-#endif
- } while (--count != 0);
- } else {
- if (com->do_timestamp)
- microtime(&com->timestamp);
- if (ioptr <= com->ihighwater
- && ioptr + count > com->ihighwater
- && com->state & CS_RTS_IFLOW)
-#if 0
- outb(com->modem_ctl_port,
- com->mcr_image &= ~MCR_RTS);
-#else
- cd_outb(iobase, com->mcr_rts_reg,
- cy_align,
- com->mcr_image
- &= ~com->mcr_rts);
-#endif
- com_events += count;
- do {
- recv_data = cd_inb(iobase, CD1400_RDSR,
- cy_align);
-#ifdef SOFT_HOTCHAR
- if (com->hotchar != 0
- && recv_data == com->hotchar)
- setsofttty();
-#endif
- ioptr[0] = recv_data;
- ioptr[com->ierroff] = 0;
- ++ioptr;
- } while (--count != 0);
- }
- com->iptr = ioptr;
- }
-cont:
-
- /* terminate service context */
-#ifdef PollMode
- cd_outb(iobase, CD1400_RIR, cy_align,
- save_rir
- & ~(CD1400_RIR_RDIREQ | CD1400_RIR_RBUSY));
-#else
- cd_outb(iobase, CD1400_EOSRR, cy_align, 0);
-#endif
- }
- if (status & CD1400_SVRR_MDMCH) {
- struct com_s *com;
- u_char modem_status;
-#ifdef PollMode
- u_char save_mir;
-#else
- u_char vector;
-#endif
-
-#ifdef PollMode
- save_mir = cd_inb(iobase, CD1400_MIR, cy_align);
-
- /* enter modem service */
- cd_outb(iobase, CD1400_CAR, cy_align, save_mir);
- com_addr(baseu + cyu * CD1400_NO_OF_CHANNELS)->car
- = save_mir & CD1400_CAR_CHAN;
-
- com = com_addr(baseu + cyu * CD1400_NO_OF_CHANNELS
- + (save_mir & CD1400_MIR_CHAN));
-#else
- /* ack modem service */
- vector = cy_inb(iobase, CY8_SVCACKM, cy_align);
-
- com = com_addr(baseu
- + ((vector >> CD1400_xIVR_CHAN_SHIFT)
- & CD1400_xIVR_CHAN));
-#endif
- ++com->mdm;
- modem_status = cd_inb(iobase, CD1400_MSVR2, cy_align);
- if (modem_status != com->last_modem_status) {
- if (com->do_dcd_timestamp
- && !(com->last_modem_status & MSR_DCD)
- && modem_status & MSR_DCD)
- microtime(&com->dcd_timestamp);
-
- /*
- * Schedule high level to handle DCD changes. Note
- * that we don't use the delta bits anywhere. Some
- * UARTs mess them up, and it's easy to remember the
- * previous bits and calculate the delta.
- */
- com->last_modem_status = modem_status;
- if (!(com->state & CS_CHECKMSR)) {
- com_events += LOTS_OF_EVENTS;
- com->state |= CS_CHECKMSR;
- setsofttty();
- }
-
-#ifdef SOFT_CTS_OFLOW
- /* handle CTS change immediately for crisp flow ctl */
- if (com->state & CS_CTS_OFLOW) {
- if (modem_status & MSR_CTS) {
- com->state |= CS_ODEVREADY;
- if (com->state >= (CS_BUSY | CS_TTGO
- | CS_ODEVREADY)
- && !(com->intr_enable
- & CD1400_SRER_TXRDY))
- cd_outb(iobase, CD1400_SRER,
- cy_align,
- com->intr_enable
- = com->intr_enable
- & ~CD1400_SRER_TXMPTY
- | CD1400_SRER_TXRDY);
- } else {
- com->state &= ~CS_ODEVREADY;
- if (com->intr_enable
- & CD1400_SRER_TXRDY)
- cd_outb(iobase, CD1400_SRER,
- cy_align,
- com->intr_enable
- = com->intr_enable
- & ~CD1400_SRER_TXRDY
- | CD1400_SRER_TXMPTY);
- }
- }
-#endif
- }
-
- /* terminate service context */
-#ifdef PollMode
- cd_outb(iobase, CD1400_MIR, cy_align,
- save_mir
- & ~(CD1400_MIR_RDIREQ | CD1400_MIR_RBUSY));
-#else
- cd_outb(iobase, CD1400_EOSRR, cy_align, 0);
-#endif
- }
- if (status & CD1400_SVRR_TXRDY) {
- struct com_s *com;
-#ifdef PollMode
- u_char save_tir;
-#else
- u_char vector;
-#endif
-
-#ifdef PollMode
- save_tir = cd_inb(iobase, CD1400_TIR, cy_align);
-
- /* enter tx service */
- cd_outb(iobase, CD1400_CAR, cy_align, save_tir);
- com_addr(baseu + cyu * CD1400_NO_OF_CHANNELS)->car
- = save_tir & CD1400_CAR_CHAN;
-
- com = com_addr(baseu
- + cyu * CD1400_NO_OF_CHANNELS
- + (save_tir & CD1400_TIR_CHAN));
-#else
- /* ack transmit service */
- vector = cy_inb(iobase, CY8_SVCACKT, cy_align);
-
- com = com_addr(baseu
- + ((vector >> CD1400_xIVR_CHAN_SHIFT)
- & CD1400_xIVR_CHAN));
-#endif
-
- if (com->etc != ETC_NONE) {
- if (com->intr_enable & CD1400_SRER_TXRDY) {
- /*
- * Here due to sloppy SRER_TXRDY
- * enabling. Ignore. Come back when
- * tx is empty.
- */
- cd_outb(iobase, CD1400_SRER, cy_align,
- com->intr_enable
- = (com->intr_enable
- & ~CD1400_SRER_TXRDY)
- | CD1400_SRER_TXMPTY);
- goto terminate_tx_service;
- }
- switch (com->etc) {
- case CD1400_ETC_SENDBREAK:
- case CD1400_ETC_STOPBREAK:
- /*
- * Start the command. Come back on
- * next tx empty interrupt, hopefully
- * after command has been executed.
- */
- cd_outb(iobase, CD1400_COR2, cy_align,
- com->cor[1] |= CD1400_COR2_ETC);
- cd_outb(iobase, CD1400_TDR, cy_align,
- CD1400_ETC_CMD);
- cd_outb(iobase, CD1400_TDR, cy_align,
- com->etc);
- if (com->etc == CD1400_ETC_SENDBREAK)
- com->etc = ETC_BREAK_STARTING;
- else
- com->etc = ETC_BREAK_ENDING;
- goto terminate_tx_service;
- case ETC_BREAK_STARTING:
- /*
- * BREAK is now on. Continue with
- * SRER_TXMPTY processing, hopefully
- * don't come back.
- */
- com->etc = ETC_BREAK_STARTED;
- break;
- case ETC_BREAK_STARTED:
- /*
- * Came back due to sloppy SRER_TXMPTY
- * enabling. Hope again.
- */
- break;
- case ETC_BREAK_ENDING:
- /*
- * BREAK is now off. Continue with
- * SRER_TXMPTY processing and don't
- * come back. The SWI handler will
- * restart tx interrupts if necessary.
- */
- cd_outb(iobase, CD1400_COR2, cy_align,
- com->cor[1]
- &= ~CD1400_COR2_ETC);
- com->etc = ETC_BREAK_ENDED;
- if (!(com->state & CS_ODONE)) {
- com_events += LOTS_OF_EVENTS;
- com->state |= CS_ODONE;
- setsofttty();
- }
- break;
- case ETC_BREAK_ENDED:
- /*
- * Shouldn't get here. Hope again.
- */
- break;
- }
- }
- if (com->intr_enable & CD1400_SRER_TXMPTY) {
- if (!(com->extra_state & CSE_ODONE)) {
- com_events += LOTS_OF_EVENTS;
- com->extra_state |= CSE_ODONE;
- setsofttty();
- }
- cd_outb(iobase, CD1400_SRER, cy_align,
- com->intr_enable
- &= ~CD1400_SRER_TXMPTY);
- goto terminate_tx_service;
- }
- if (com->state >= (CS_BUSY | CS_TTGO | CS_ODEVREADY)) {
- u_char *ioptr;
- u_int ocount;
-
- ioptr = com->obufq.l_head;
- ocount = com->obufq.l_tail - ioptr;
- if (ocount > CD1400_TX_FIFO_SIZE)
- ocount = CD1400_TX_FIFO_SIZE;
- com->bytes_out += ocount;
- do
- cd_outb(iobase, CD1400_TDR, cy_align,
- *ioptr++);
- while (--ocount != 0);
- com->obufq.l_head = ioptr;
- if (ioptr >= com->obufq.l_tail) {
- struct lbq *qp;
-
- qp = com->obufq.l_next;
- qp->l_queued = FALSE;
- qp = qp->l_next;
- if (qp != NULL) {
- com->obufq.l_head = qp->l_head;
- com->obufq.l_tail = qp->l_tail;
- com->obufq.l_next = qp;
- } else {
- /* output just completed */
- com->state &= ~CS_BUSY;
-
- /*
- * The setting of CSE_ODONE may be
- * stale here. We currently only
- * use it when CS_BUSY is set, and
- * fixing it when we clear CS_BUSY
- * is easiest.
- */
- if (com->extra_state & CSE_ODONE) {
- com_events -= LOTS_OF_EVENTS;
- com->extra_state &= ~CSE_ODONE;
- }
-
- cd_outb(iobase, CD1400_SRER, cy_align,
- com->intr_enable
- = (com->intr_enable
- & ~CD1400_SRER_TXRDY)
- | CD1400_SRER_TXMPTY);
- }
- if (!(com->state & CS_ODONE)) {
- com_events += LOTS_OF_EVENTS;
- com->state |= CS_ODONE;
-
- /* handle at high level ASAP */
- setsofttty();
- }
- }
- }
-
- /* terminate service context */
-terminate_tx_service:
-#ifdef PollMode
- cd_outb(iobase, CD1400_TIR, cy_align,
- save_tir
- & ~(CD1400_TIR_RDIREQ | CD1400_TIR_RBUSY));
-#else
- cd_outb(iobase, CD1400_EOSRR, cy_align, 0);
-#endif
- }
- }
-
- /* ensure an edge for the next interrupt */
- cy_outb(cy_iobase, CY_CLEAR_INTR, cy_align, 0);
-
- schedsofttty();
-
- COM_UNLOCK();
-}
-
-#if 0
-static void
-siointr1(com)
- struct com_s *com;
-{
-}
-#endif
-
-static int
-sioioctl(dev, cmd, data, flag, p)
- dev_t dev;
- u_long cmd;
- caddr_t data;
- int flag;
- struct proc *p;
-{
- struct com_s *com;
- int error;
- int mynor;
- int s;
- struct tty *tp;
-#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
- int oldcmd;
- struct termios term;
-#endif
-
- mynor = minor(dev);
- com = com_addr(MINOR_TO_UNIT(mynor));
- if (mynor & CONTROL_MASK) {
- struct termios *ct;
-
- switch (mynor & CONTROL_MASK) {
- case CONTROL_INIT_STATE:
- ct = mynor & CALLOUT_MASK ? &com->it_out : &com->it_in;
- break;
- case CONTROL_LOCK_STATE:
- ct = mynor & CALLOUT_MASK ? &com->lt_out : &com->lt_in;
- break;
- default:
- return (ENODEV); /* /dev/nodev */
- }
- switch (cmd) {
- case TIOCSETA:
- error = suser(p);
- if (error != 0)
- return (error);
- *ct = *(struct termios *)data;
- return (0);
- case TIOCGETA:
- *(struct termios *)data = *ct;
- return (0);
- case TIOCGETD:
- *(int *)data = TTYDISC;
- return (0);
- case TIOCGWINSZ:
- bzero(data, sizeof(struct winsize));
- return (0);
- default:
- return (ENOTTY);
- }
- }
- tp = com->tp;
-#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
- term = tp->t_termios;
- oldcmd = cmd;
- error = ttsetcompat(tp, &cmd, data, &term);
- if (error != 0)
- return (error);
- if (cmd != oldcmd)
- data = (caddr_t)&term;
-#endif
- if (cmd == TIOCSETA || cmd == TIOCSETAW || cmd == TIOCSETAF) {
- int cc;
- struct termios *dt = (struct termios *)data;
- struct termios *lt = mynor & CALLOUT_MASK
- ? &com->lt_out : &com->lt_in;
-
- dt->c_iflag = (tp->t_iflag & lt->c_iflag)
- | (dt->c_iflag & ~lt->c_iflag);
- dt->c_oflag = (tp->t_oflag & lt->c_oflag)
- | (dt->c_oflag & ~lt->c_oflag);
- dt->c_cflag = (tp->t_cflag & lt->c_cflag)
- | (dt->c_cflag & ~lt->c_cflag);
- dt->c_lflag = (tp->t_lflag & lt->c_lflag)
- | (dt->c_lflag & ~lt->c_lflag);
- for (cc = 0; cc < NCCS; ++cc)
- if (lt->c_cc[cc] != 0)
- dt->c_cc[cc] = tp->t_cc[cc];
- if (lt->c_ispeed != 0)
- dt->c_ispeed = tp->t_ispeed;
- if (lt->c_ospeed != 0)
- dt->c_ospeed = tp->t_ospeed;
- }
- error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p);
- if (error != ENOIOCTL)
- return (error);
- s = spltty();
- error = ttioctl(tp, cmd, data, flag);
- disc_optim(tp, &tp->t_termios, com);
- if (error != ENOIOCTL) {
- splx(s);
- return (error);
- }
- switch (cmd) {
- case TIOCSBRK:
-#if 0
- outb(iobase + com_cfcr, com->cfcr_image |= CFCR_SBREAK);
-#else
- cd_etc(com, CD1400_ETC_SENDBREAK);
-#endif
- break;
- case TIOCCBRK:
-#if 0
- outb(iobase + com_cfcr, com->cfcr_image &= ~CFCR_SBREAK);
-#else
- cd_etc(com, CD1400_ETC_STOPBREAK);
-#endif
- break;
- case TIOCSDTR:
- (void)commctl(com, TIOCM_DTR, DMBIS);
- break;
- case TIOCCDTR:
- (void)commctl(com, TIOCM_DTR, DMBIC);
- break;
- /*
- * XXX should disallow changing MCR_RTS if CS_RTS_IFLOW is set. The
- * changes get undone on the next call to comparam().
- */
- case TIOCMSET:
- (void)commctl(com, *(int *)data, DMSET);
- break;
- case TIOCMBIS:
- (void)commctl(com, *(int *)data, DMBIS);
- break;
- case TIOCMBIC:
- (void)commctl(com, *(int *)data, DMBIC);
- break;
- case TIOCMGET:
- *(int *)data = commctl(com, 0, DMGET);
- break;
- case TIOCMSDTRWAIT:
- /* must be root since the wait applies to following logins */
- error = suser(p);
- if (error != 0) {
- splx(s);
- return (error);
- }
- com->dtr_wait = *(int *)data * hz / 100;
- break;
- case TIOCMGDTRWAIT:
- *(int *)data = com->dtr_wait * 100 / hz;
- break;
- case TIOCTIMESTAMP:
- com->do_timestamp = TRUE;
- *(struct timeval *)data = com->timestamp;
- break;
- case TIOCDCDTIMESTAMP:
- com->do_dcd_timestamp = TRUE;
- *(struct timeval *)data = com->dcd_timestamp;
- break;
- default:
- splx(s);
- return (ENOTTY);
- }
- splx(s);
- return (0);
-}
-
-static void
-siopoll()
-{
- int unit;
-
-#ifdef CyDebug
- ++cy_timeouts;
-#endif
- if (com_events == 0)
- return;
-repeat:
- for (unit = 0; unit < NSIO; ++unit) {
- struct com_s *com;
- int incc;
- struct tty *tp;
-
- com = com_addr(unit);
- if (com == NULL)
- continue;
- tp = com->tp;
- if (tp == NULL) {
- /*
- * XXX forget any events related to closed devices
- * (actually never opened devices) so that we don't
- * loop.
- */
- disable_intr();
- incc = com->iptr - com->ibuf;
- com->iptr = com->ibuf;
- if (com->state & CS_CHECKMSR) {
- incc += LOTS_OF_EVENTS;
- com->state &= ~CS_CHECKMSR;
- }
- com_events -= incc;
- enable_intr();
- if (incc != 0)
- log(LOG_DEBUG,
- "sio%d: %d events for device with no tp\n",
- unit, incc);
- continue;
- }
- if (com->iptr != com->ibuf) {
- disable_intr();
- sioinput(com);
- enable_intr();
- }
- if (com->state & CS_CHECKMSR) {
- u_char delta_modem_status;
-
- disable_intr();
- delta_modem_status = com->last_modem_status
- ^ com->prev_modem_status;
- com->prev_modem_status = com->last_modem_status;
- com_events -= LOTS_OF_EVENTS;
- com->state &= ~CS_CHECKMSR;
- enable_intr();
- if (delta_modem_status & MSR_DCD)
- (*linesw[tp->t_line].l_modem)
- (tp, com->prev_modem_status & MSR_DCD);
- }
- if (com->extra_state & CSE_ODONE) {
- disable_intr();
- com_events -= LOTS_OF_EVENTS;
- com->extra_state &= ~CSE_ODONE;
- enable_intr();
- if (!(com->state & CS_BUSY)) {
- tp->t_state &= ~TS_BUSY;
- ttwwakeup(com->tp);
- }
- if (com->etc != ETC_NONE) {
- if (com->etc == ETC_BREAK_ENDED)
- com->etc = ETC_NONE;
- wakeup(&com->etc);
- }
- }
- if (com->state & CS_ODONE) {
- disable_intr();
- com_events -= LOTS_OF_EVENTS;
- com->state &= ~CS_ODONE;
- enable_intr();
- (*linesw[tp->t_line].l_start)(tp);
- }
- if (com_events == 0)
- break;
- }
- if (com_events >= LOTS_OF_EVENTS)
- goto repeat;
-}
-
-static int
-comparam(tp, t)
- struct tty *tp;
- struct termios *t;
-{
- int bits;
- int cflag;
- struct com_s *com;
- u_char cor_change;
- u_long cy_clock;
- int idivisor;
- int iflag;
- int iprescaler;
- int itimeout;
- int odivisor;
- int oprescaler;
- u_char opt;
- int s;
- int unit;
-
- /* do historical conversions */
- if (t->c_ispeed == 0)
- t->c_ispeed = t->c_ospeed;
-
- unit = DEV_TO_UNIT(tp->t_dev);
- com = com_addr(unit);
-
- /* check requested parameters */
- cy_clock = CY_CLOCK(com->gfrcr_image);
- idivisor = comspeed(t->c_ispeed, cy_clock, &iprescaler);
- if (idivisor < 0)
- return (EINVAL);
- odivisor = comspeed(t->c_ospeed, cy_clock, &oprescaler);
- if (odivisor < 0)
- return (EINVAL);
-
- /* parameters are OK, convert them to the com struct and the device */
- s = spltty();
- if (odivisor == 0)
- (void)commctl(com, TIOCM_DTR, DMBIC); /* hang up line */
- else
- (void)commctl(com, TIOCM_DTR, DMBIS);
-
- /*
- * This returns with interrupts disabled so that we can complete
- * the speed change atomically.
- */
- (void) siosetwater(com, t->c_ispeed);
-
- /* XXX we don't actually change the speed atomically. */
- enable_intr();
-
- if (idivisor != 0) {
- cd_setreg(com, CD1400_RBPR, idivisor);
- cd_setreg(com, CD1400_RCOR, iprescaler);
- }
- if (odivisor != 0) {
- cd_setreg(com, CD1400_TBPR, odivisor);
- cd_setreg(com, CD1400_TCOR, oprescaler);
- }
-
- /*
- * channel control
- * receiver enable
- * transmitter enable (always set)
- */
- cflag = t->c_cflag;
- opt = CD1400_CCR_CMDCHANCTL | CD1400_CCR_XMTEN
- | (cflag & CREAD ? CD1400_CCR_RCVEN : CD1400_CCR_RCVDIS);
- if (opt != com->channel_control) {
- com->channel_control = opt;
- cd1400_channel_cmd(com, opt);
- }
-
-#ifdef Smarts
- /* set special chars */
- /* XXX if one is _POSIX_VDISABLE, can't use some others */
- if (t->c_cc[VSTOP] != _POSIX_VDISABLE)
- cd_setreg(com, CD1400_SCHR1, t->c_cc[VSTOP]);
- if (t->c_cc[VSTART] != _POSIX_VDISABLE)
- cd_setreg(com, CD1400_SCHR2, t->c_cc[VSTART]);
- if (t->c_cc[VINTR] != _POSIX_VDISABLE)
- cd_setreg(com, CD1400_SCHR3, t->c_cc[VINTR]);
- if (t->c_cc[VSUSP] != _POSIX_VDISABLE)
- cd_setreg(com, CD1400_SCHR4, t->c_cc[VSUSP]);
-#endif
-
- /*
- * set channel option register 1 -
- * parity mode
- * stop bits
- * char length
- */
- opt = 0;
- /* parity */
- if (cflag & PARENB) {
- if (cflag & PARODD)
- opt |= CD1400_COR1_PARODD;
- opt |= CD1400_COR1_PARNORMAL;
- }
- iflag = t->c_iflag;
- if (!(iflag & INPCK))
- opt |= CD1400_COR1_NOINPCK;
- bits = 1 + 1;
- /* stop bits */
- if (cflag & CSTOPB) {
- ++bits;
- opt |= CD1400_COR1_STOP2;
- }
- /* char length */
- switch (cflag & CSIZE) {
- case CS5:
- bits += 5;
- opt |= CD1400_COR1_CS5;
- break;
- case CS6:
- bits += 6;
- opt |= CD1400_COR1_CS6;
- break;
- case CS7:
- bits += 7;
- opt |= CD1400_COR1_CS7;
- break;
- default:
- bits += 8;
- opt |= CD1400_COR1_CS8;
- break;
- }
- cor_change = 0;
- if (opt != com->cor[0]) {
- cor_change |= CD1400_CCR_COR1;
- cd_setreg(com, CD1400_COR1, com->cor[0] = opt);
- }
-
- /*
- * Set receive time-out period, normally to max(one char time, 5 ms).
- */
- if (t->c_ispeed == 0)
- itimeout = cd_getreg(com, CD1400_RTPR);
- else {
- itimeout = (1000 * bits + t->c_ispeed - 1) / t->c_ispeed;
-#ifdef SOFT_HOTCHAR
-#define MIN_RTP 1
-#else
-#define MIN_RTP 5
-#endif
- if (itimeout < MIN_RTP)
- itimeout = MIN_RTP;
- }
- if (!(t->c_lflag & ICANON) && t->c_cc[VMIN] != 0 && t->c_cc[VTIME] != 0
- && t->c_cc[VTIME] * 10 > itimeout)
- itimeout = t->c_cc[VTIME] * 10;
- if (itimeout > 255)
- itimeout = 255;
- cd_setreg(com, CD1400_RTPR, itimeout);
-
- /*
- * set channel option register 2 -
- * flow control
- */
- opt = 0;
-#ifdef Smarts
- if (iflag & IXANY)
- opt |= CD1400_COR2_IXANY;
- if (iflag & IXOFF)
- opt |= CD1400_COR2_IXOFF;
-#endif
-#ifndef SOFT_CTS_OFLOW
- if (cflag & CCTS_OFLOW)
- opt |= CD1400_COR2_CCTS_OFLOW;
-#endif
- disable_intr();
- if (opt != com->cor[1]) {
- cor_change |= CD1400_CCR_COR2;
- cd_setreg(com, CD1400_COR2, com->cor[1] = opt);
- }
- enable_intr();
-
- /*
- * set channel option register 3 -
- * receiver FIFO interrupt threshold
- * flow control
- */
- opt = RxFifoThreshold;
-#ifdef Smarts
- if (t->c_lflag & ICANON)
- opt |= CD1400_COR3_SCD34; /* detect INTR & SUSP chars */
- if (iflag & IXOFF)
- /* detect and transparently handle START and STOP chars */
- opt |= CD1400_COR3_FCT | CD1400_COR3_SCD12;
-#endif
- if (opt != com->cor[2]) {
- cor_change |= CD1400_CCR_COR3;
- cd_setreg(com, CD1400_COR3, com->cor[2] = opt);
- }
-
- /* notify the CD1400 if COR1-3 have changed */
- if (cor_change)
- cd1400_channel_cmd(com, CD1400_CCR_CMDCORCHG | cor_change);
-
- /*
- * set channel option register 4 -
- * CR/NL processing
- * break processing
- * received exception processing
- */
- opt = 0;
- if (iflag & IGNCR)
- opt |= CD1400_COR4_IGNCR;
-#ifdef Smarts
- /*
- * we need a new ttyinput() for this, as we don't want to
- * have ICRNL && INLCR being done in both layers, or to have
- * synchronisation problems
- */
- if (iflag & ICRNL)
- opt |= CD1400_COR4_ICRNL;
- if (iflag & INLCR)
- opt |= CD1400_COR4_INLCR;
-#endif
- if (iflag & IGNBRK)
- opt |= CD1400_COR4_IGNBRK | CD1400_COR4_NOBRKINT;
- /*
- * The `-ignbrk -brkint parmrk' case is not handled by the hardware,
- * so only tell the hardware about -brkint if -parmrk.
- */
- if (!(iflag & (BRKINT | PARMRK)))
- opt |= CD1400_COR4_NOBRKINT;
-#if 0
- /* XXX using this "intelligence" breaks reporting of overruns. */
- if (iflag & IGNPAR)
- opt |= CD1400_COR4_PFO_DISCARD;
- else {
- if (iflag & PARMRK)
- opt |= CD1400_COR4_PFO_ESC;
- else
- opt |= CD1400_COR4_PFO_NUL;
- }
-#else
- opt |= CD1400_COR4_PFO_EXCEPTION;
-#endif
- cd_setreg(com, CD1400_COR4, opt);
-
- /*
- * set channel option register 5 -
- */
- opt = 0;
- if (iflag & ISTRIP)
- opt |= CD1400_COR5_ISTRIP;
- if (t->c_iflag & IEXTEN)
- /* enable LNEXT (e.g. ctrl-v quoting) handling */
- opt |= CD1400_COR5_LNEXT;
-#ifdef Smarts
- if (t->c_oflag & ONLCR)
- opt |= CD1400_COR5_ONLCR;
- if (t->c_oflag & OCRNL)
- opt |= CD1400_COR5_OCRNL;
-#endif
- cd_setreg(com, CD1400_COR5, opt);
-
- /*
- * We always generate modem status change interrupts for CD changes.
- * Among other things, this is necessary to track TS_CARR_ON for
- * pstat to print even when the driver doesn't care. CD changes
- * should be rare so interrupts for them are not worth extra code to
- * avoid. We avoid interrupts for other modem status changes (except
- * for CTS changes when SOFT_CTS_OFLOW is configured) since this is
- * simplest and best.
- */
-
- /*
- * set modem change option register 1
- * generate modem interrupts on which 1 -> 0 input transitions
- * also controls auto-DTR output flow-control, which we don't use
- */
- opt = CD1400_MCOR1_CDzd;
-#ifdef SOFT_CTS_OFLOW
- if (cflag & CCTS_OFLOW)
- opt |= CD1400_MCOR1_CTSzd;
-#endif
- cd_setreg(com, CD1400_MCOR1, opt);
-
- /*
- * set modem change option register 2
- * generate modem interrupts on specific 0 -> 1 input transitions
- */
- opt = CD1400_MCOR2_CDod;
-#ifdef SOFT_CTS_OFLOW
- if (cflag & CCTS_OFLOW)
- opt |= CD1400_MCOR2_CTSod;
-#endif
- cd_setreg(com, CD1400_MCOR2, opt);
-
- /*
- * XXX should have done this long ago, but there is too much state
- * to change all atomically.
- */
- disable_intr();
-
- com->state &= ~CS_TTGO;
- if (!(tp->t_state & TS_TTSTOP))
- com->state |= CS_TTGO;
- if (cflag & CRTS_IFLOW) {
- com->state |= CS_RTS_IFLOW;
- /*
- * If CS_RTS_IFLOW just changed from off to on, the change
- * needs to be propagated to MCR_RTS. This isn't urgent,
- * so do it later by calling comstart() instead of repeating
- * a lot of code from comstart() here.
- */
- } else if (com->state & CS_RTS_IFLOW) {
- com->state &= ~CS_RTS_IFLOW;
- /*
- * CS_RTS_IFLOW just changed from on to off. Force MCR_RTS
- * on here, since comstart() won't do it later.
- */
-#if 0
- outb(com->modem_ctl_port, com->mcr_image |= MCR_RTS);
-#else
- cd_setreg(com, com->mcr_rts_reg,
- com->mcr_image |= com->mcr_rts);
-#endif
- }
-
- /*
- * Set up state to handle output flow control.
- * XXX - worth handling MDMBUF (DCD) flow control at the lowest level?
- * Now has 10+ msec latency, while CTS flow has 50- usec latency.
- */
- com->state |= CS_ODEVREADY;
-#ifdef SOFT_CTS_OFLOW
- com->state &= ~CS_CTS_OFLOW;
- if (cflag & CCTS_OFLOW) {
- com->state |= CS_CTS_OFLOW;
- if (!(com->last_modem_status & MSR_CTS))
- com->state &= ~CS_ODEVREADY;
- }
-#endif
- /* XXX shouldn't call functions while intrs are disabled. */
- disc_optim(tp, t, com);
-#if 0
- /*
- * Recover from fiddling with CS_TTGO. We used to call siointr1()
- * unconditionally, but that defeated the careful discarding of
- * stale input in sioopen().
- */
- if (com->state >= (CS_BUSY | CS_TTGO))
- siointr1(com);
-#endif
- if (com->state >= (CS_BUSY | CS_TTGO | CS_ODEVREADY)) {
- if (!(com->intr_enable & CD1400_SRER_TXRDY))
- cd_setreg(com, CD1400_SRER,
- com->intr_enable
- = (com->intr_enable & ~CD1400_SRER_TXMPTY)
- | CD1400_SRER_TXRDY);
- } else {
- if (com->intr_enable & CD1400_SRER_TXRDY)
- cd_setreg(com, CD1400_SRER,
- com->intr_enable
- = (com->intr_enable & ~CD1400_SRER_TXRDY)
- | CD1400_SRER_TXMPTY);
- }
-
- enable_intr();
- splx(s);
- comstart(tp);
- if (com->ibufold != NULL) {
- free(com->ibufold, M_DEVBUF);
- com->ibufold = NULL;
- }
- return (0);
-}
-
-static int
-siosetwater(com, speed)
- struct com_s *com;
- speed_t speed;
-{
- int cp4ticks;
- u_char *ibuf;
- int ibufsize;
- struct tty *tp;
-
- /*
- * Make the buffer size large enough to handle a softtty interrupt
- * latency of about 2 ticks without loss of throughput or data
- * (about 3 ticks if input flow control is not used or not honoured,
- * but a bit less for CS5-CS7 modes).
- */
- cp4ticks = speed / 10 / hz * 4;
- for (ibufsize = 128; ibufsize < cp4ticks;)
- ibufsize <<= 1;
- if (ibufsize == com->ibufsize) {
- disable_intr();
- return (0);
- }
-
- /*
- * Allocate input buffer. The extra factor of 2 in the size is
- * to allow for an error byte for each input byte.
- */
- ibuf = malloc(2 * ibufsize, M_DEVBUF, M_NOWAIT);
- if (ibuf == NULL) {
- disable_intr();
- return (ENOMEM);
- }
-
- /* Initialize non-critical variables. */
- com->ibufold = com->ibuf;
- com->ibufsize = ibufsize;
- tp = com->tp;
- if (tp != NULL) {
- tp->t_ififosize = 2 * ibufsize;
- tp->t_ispeedwat = (speed_t)-1;
- tp->t_ospeedwat = (speed_t)-1;
- }
-
- /*
- * Read current input buffer, if any. Continue with interrupts
- * disabled.
- */
- disable_intr();
- if (com->iptr != com->ibuf)
- sioinput(com);
-
- /*-
- * Initialize critical variables, including input buffer watermarks.
- * The external device is asked to stop sending when the buffer
- * exactly reaches high water, or when the high level requests it.
- * The high level is notified immediately (rather than at a later
- * clock tick) when this watermark is reached.
- * The buffer size is chosen so the watermark should almost never
- * be reached.
- * The low watermark is invisibly 0 since the buffer is always
- * emptied all at once.
- */
- com->iptr = com->ibuf = ibuf;
- com->ibufend = ibuf + ibufsize;
- com->ierroff = ibufsize;
- com->ihighwater = ibuf + 3 * ibufsize / 4;
- return (0);
-}
-
-static void
-comstart(tp)
- struct tty *tp;
-{
- struct com_s *com;
- int s;
-#ifdef CyDebug
- bool_t started;
-#endif
- int unit;
-
- unit = DEV_TO_UNIT(tp->t_dev);
- com = com_addr(unit);
- s = spltty();
-
-#ifdef CyDebug
- ++com->start_count;
- started = FALSE;
-#endif
-
- disable_intr();
- if (tp->t_state & TS_TTSTOP) {
- com->state &= ~CS_TTGO;
- if (com->intr_enable & CD1400_SRER_TXRDY)
- cd_setreg(com, CD1400_SRER,
- com->intr_enable
- = (com->intr_enable & ~CD1400_SRER_TXRDY)
- | CD1400_SRER_TXMPTY);
- } else {
- com->state |= CS_TTGO;
- if (com->state >= (CS_BUSY | CS_TTGO | CS_ODEVREADY)
- && !(com->intr_enable & CD1400_SRER_TXRDY))
- cd_setreg(com, CD1400_SRER,
- com->intr_enable
- = (com->intr_enable & ~CD1400_SRER_TXMPTY)
- | CD1400_SRER_TXRDY);
- }
- if (tp->t_state & TS_TBLOCK) {
- if (com->mcr_image & com->mcr_rts && com->state & CS_RTS_IFLOW)
-#if 0
- outb(com->modem_ctl_port, com->mcr_image &= ~MCR_RTS);
-#else
- cd_setreg(com, com->mcr_rts_reg,
- com->mcr_image &= ~com->mcr_rts);
-#endif
- } else {
- if (!(com->mcr_image & com->mcr_rts)
- && com->iptr < com->ihighwater
- && com->state & CS_RTS_IFLOW)
-#if 0
- outb(com->modem_ctl_port, com->mcr_image |= MCR_RTS);
-#else
- cd_setreg(com, com->mcr_rts_reg,
- com->mcr_image |= com->mcr_rts);
-#endif
- }
- enable_intr();
- if (tp->t_state & (TS_TIMEOUT | TS_TTSTOP)) {
- ttwwakeup(tp);
- splx(s);
- return;
- }
- if (tp->t_outq.c_cc != 0) {
- struct lbq *qp;
- struct lbq *next;
-
- if (!com->obufs[0].l_queued) {
-#ifdef CyDebug
- started = TRUE;
-#endif
- com->obufs[0].l_tail
- = com->obuf1 + q_to_b(&tp->t_outq, com->obuf1,
- sizeof com->obuf1);
- com->obufs[0].l_next = NULL;
- com->obufs[0].l_queued = TRUE;
- disable_intr();
- if (com->state & CS_BUSY) {
- qp = com->obufq.l_next;
- while ((next = qp->l_next) != NULL)
- qp = next;
- qp->l_next = &com->obufs[0];
- } else {
- com->obufq.l_head = com->obufs[0].l_head;
- com->obufq.l_tail = com->obufs[0].l_tail;
- com->obufq.l_next = &com->obufs[0];
- com->state |= CS_BUSY;
- if (com->state >= (CS_BUSY | CS_TTGO
- | CS_ODEVREADY))
- cd_setreg(com, CD1400_SRER,
- com->intr_enable
- = (com->intr_enable
- & ~CD1400_SRER_TXMPTY)
- | CD1400_SRER_TXRDY);
- }
- enable_intr();
- }
- if (tp->t_outq.c_cc != 0 && !com->obufs[1].l_queued) {
-#ifdef CyDebug
- started = TRUE;
-#endif
- com->obufs[1].l_tail
- = com->obuf2 + q_to_b(&tp->t_outq, com->obuf2,
- sizeof com->obuf2);
- com->obufs[1].l_next = NULL;
- com->obufs[1].l_queued = TRUE;
- disable_intr();
- if (com->state & CS_BUSY) {
- qp = com->obufq.l_next;
- while ((next = qp->l_next) != NULL)
- qp = next;
- qp->l_next = &com->obufs[1];
- } else {
- com->obufq.l_head = com->obufs[1].l_head;
- com->obufq.l_tail = com->obufs[1].l_tail;
- com->obufq.l_next = &com->obufs[1];
- com->state |= CS_BUSY;
- if (com->state >= (CS_BUSY | CS_TTGO
- | CS_ODEVREADY))
- cd_setreg(com, CD1400_SRER,
- com->intr_enable
- = (com->intr_enable
- & ~CD1400_SRER_TXMPTY)
- | CD1400_SRER_TXRDY);
- }
- enable_intr();
- }
- tp->t_state |= TS_BUSY;
- }
-#ifdef CyDebug
- if (started)
- ++com->start_real;
-#endif
-#if 0
- disable_intr();
- if (com->state >= (CS_BUSY | CS_TTGO))
- siointr1(com); /* fake interrupt to start output */
- enable_intr();
-#endif
- ttwwakeup(tp);
- splx(s);
-}
-
-static void
-comstop(tp, rw)
- struct tty *tp;
- int rw;
-{
- struct com_s *com;
- bool_t wakeup_etc;
-
- com = com_addr(DEV_TO_UNIT(tp->t_dev));
- wakeup_etc = FALSE;
- disable_intr();
- if (rw & FWRITE) {
- com->obufs[0].l_queued = FALSE;
- com->obufs[1].l_queued = FALSE;
- if (com->extra_state & CSE_ODONE) {
- com_events -= LOTS_OF_EVENTS;
- com->extra_state &= ~CSE_ODONE;
- if (com->etc != ETC_NONE) {
- if (com->etc == ETC_BREAK_ENDED)
- com->etc = ETC_NONE;
- wakeup_etc = TRUE;
- }
- }
- com->tp->t_state &= ~TS_BUSY;
- if (com->state & CS_ODONE)
- com_events -= LOTS_OF_EVENTS;
- com->state &= ~(CS_ODONE | CS_BUSY);
- }
- if (rw & FREAD) {
- /* XXX no way to reset only input fifo. */
- com_events -= (com->iptr - com->ibuf);
- com->iptr = com->ibuf;
- }
- enable_intr();
- if (wakeup_etc)
- wakeup(&com->etc);
- if (rw & FWRITE && com->etc == ETC_NONE)
- cd1400_channel_cmd(com, CD1400_CCR_CMDRESET | CD1400_CCR_FTF);
- comstart(tp);
-}
-
-static int
-commctl(com, bits, how)
- struct com_s *com;
- int bits;
- int how;
-{
- int mcr;
- int msr;
-
- if (how == DMGET) {
- if (com->channel_control & CD1400_CCR_RCVEN)
- bits |= TIOCM_LE;
- mcr = com->mcr_image;
- if (mcr & com->mcr_dtr)
- bits |= TIOCM_DTR;
- if (mcr & com->mcr_rts)
- /* XXX wired on for Cyclom-8Ys */
- bits |= TIOCM_RTS;
-
- /*
- * We must read the modem status from the hardware because
- * we don't generate modem status change interrupts for all
- * changes, so com->prev_modem_status is not guaranteed to
- * be up to date. This is safe, unlike for sio, because
- * reading the status register doesn't clear pending modem
- * status change interrupts.
- */
- msr = cd_getreg(com, CD1400_MSVR2);
-
- if (msr & MSR_CTS)
- bits |= TIOCM_CTS;
- if (msr & MSR_DCD)
- bits |= TIOCM_CD;
- if (msr & MSR_DSR)
- bits |= TIOCM_DSR;
- if (msr & MSR_RI)
- /* XXX not connected except for Cyclom-16Y? */
- bits |= TIOCM_RI;
- return (bits);
- }
- mcr = 0;
- if (bits & TIOCM_DTR)
- mcr |= com->mcr_dtr;
- if (bits & TIOCM_RTS)
- mcr |= com->mcr_rts;
- disable_intr();
- switch (how) {
- case DMSET:
- com->mcr_image = mcr;
- cd_setreg(com, CD1400_MSVR1, mcr);
- cd_setreg(com, CD1400_MSVR2, mcr);
- break;
- case DMBIS:
- com->mcr_image = mcr = com->mcr_image | mcr;
- cd_setreg(com, CD1400_MSVR1, mcr);
- cd_setreg(com, CD1400_MSVR2, mcr);
- break;
- case DMBIC:
- com->mcr_image = mcr = com->mcr_image & ~mcr;
- cd_setreg(com, CD1400_MSVR1, mcr);
- cd_setreg(com, CD1400_MSVR2, mcr);
- break;
- }
- enable_intr();
- return (0);
-}
-
-static void
-siosettimeout()
-{
- struct com_s *com;
- bool_t someopen;
- int unit;
-
- /*
- * Set our timeout period to 1 second if no polled devices are open.
- * Otherwise set it to max(1/200, 1/hz).
- * Enable timeouts iff some device is open.
- */
- untimeout(comwakeup, (void *)NULL, sio_timeout_handle);
- sio_timeout = hz;
- someopen = FALSE;
- for (unit = 0; unit < NSIO; ++unit) {
- com = com_addr(unit);
- if (com != NULL && com->tp != NULL
- && com->tp->t_state & TS_ISOPEN) {
- someopen = TRUE;
-#if 0
- if (com->poll || com->poll_output) {
- sio_timeout = hz > 200 ? hz / 200 : 1;
- break;
- }
-#endif
- }
- }
- if (someopen) {
- sio_timeouts_until_log = hz / sio_timeout;
- sio_timeout_handle = timeout(comwakeup, (void *)NULL,
- sio_timeout);
- } else {
- /* Flush error messages, if any. */
- sio_timeouts_until_log = 1;
- comwakeup((void *)NULL);
- untimeout(comwakeup, (void *)NULL, sio_timeout_handle);
- }
-}
-
-static void
-comwakeup(chan)
- void *chan;
-{
- struct com_s *com;
- int unit;
-
- sio_timeout_handle = timeout(comwakeup, (void *)NULL, sio_timeout);
-
-#if 0
- /*
- * Recover from lost output interrupts.
- * Poll any lines that don't use interrupts.
- */
- for (unit = 0; unit < NSIO; ++unit) {
- com = com_addr(unit);
- if (com != NULL
- && (com->state >= (CS_BUSY | CS_TTGO) || com->poll)) {
- disable_intr();
- siointr1(com);
- enable_intr();
- }
- }
-#endif
-
- /*
- * Check for and log errors, but not too often.
- */
- if (--sio_timeouts_until_log > 0)
- return;
- sio_timeouts_until_log = hz / sio_timeout;
- for (unit = 0; unit < NSIO; ++unit) {
- int errnum;
-
- com = com_addr(unit);
- if (com == NULL)
- continue;
- for (errnum = 0; errnum < CE_NTYPES; ++errnum) {
- u_int delta;
- u_long total;
-
- disable_intr();
- delta = com->delta_error_counts[errnum];
- com->delta_error_counts[errnum] = 0;
- enable_intr();
- if (delta == 0)
- continue;
- total = com->error_counts[errnum] += delta;
- log(LOG_ERR, "cy%d: %u more %s%s (total %lu)\n",
- unit, delta, error_desc[errnum],
- delta == 1 ? "" : "s", total);
- }
- }
-}
-
-static void
-disc_optim(tp, t, com)
- struct tty *tp;
- struct termios *t;
- struct com_s *com;
-{
-#ifndef SOFT_HOTCHAR
- u_char opt;
-#endif
-
- /*
- * XXX can skip a lot more cases if Smarts. Maybe
- * (IGNCR | ISTRIP | IXON) in c_iflag. But perhaps we
- * shouldn't skip if (TS_CNTTB | TS_LNCH) is set in t_state.
- */
- if (!(t->c_iflag & (ICRNL | IGNCR | IMAXBEL | INLCR | ISTRIP | IXON))
- && (!(t->c_iflag & BRKINT) || (t->c_iflag & IGNBRK))
- && (!(t->c_iflag & PARMRK)
- || (t->c_iflag & (IGNPAR | IGNBRK)) == (IGNPAR | IGNBRK))
- && !(t->c_lflag & (ECHO | ICANON | IEXTEN | ISIG | PENDIN))
- && linesw[tp->t_line].l_rint == ttyinput)
- tp->t_state |= TS_CAN_BYPASS_L_RINT;
- else
- tp->t_state &= ~TS_CAN_BYPASS_L_RINT;
- com->hotchar = linesw[tp->t_line].l_hotchar;
-#ifndef SOFT_HOTCHAR
- opt = com->cor[2] & ~CD1400_COR3_SCD34;
- if (com->hotchar != 0) {
- cd_setreg(com, CD1400_SCHR3, com->hotchar);
- cd_setreg(com, CD1400_SCHR4, com->hotchar);
- opt |= CD1400_COR3_SCD34;
- }
- if (opt != com->cor[2]) {
- cd_setreg(com, CD1400_COR3, com->cor[2] = opt);
- cd1400_channel_cmd(com, CD1400_CCR_CMDCORCHG | CD1400_CCR_COR3);
- }
-#endif
-}
-
-#ifdef Smarts
-/* standard line discipline input routine */
-int
-cyinput(c, tp)
- int c;
- struct tty *tp;
-{
- /* XXX duplicate ttyinput(), but without the IXOFF/IXON/ISTRIP/IPARMRK
- * bits, as they are done by the CD1400. Hardly worth the effort,
- * given that high-throughput sessions are raw anyhow.
- */
-}
-#endif /* Smarts */
-
-static int
-comspeed(speed, cy_clock, prescaler_io)
- speed_t speed;
- u_long cy_clock;
- int *prescaler_io;
-{
- int actual;
- int error;
- int divider;
- int prescaler;
- int prescaler_unit;
-
- if (speed == 0)
- return (0);
- if (speed < 0 || speed > 150000)
- return (-1);
-
- /* determine which prescaler to use */
- for (prescaler_unit = 4, prescaler = 2048; prescaler_unit;
- prescaler_unit--, prescaler >>= 2) {
- if (cy_clock / prescaler / speed > 63)
- break;
- }
-
- divider = (cy_clock / prescaler * 2 / speed + 1) / 2; /* round off */
- if (divider > 255)
- divider = 255;
- actual = cy_clock/prescaler/divider;
-
- /* 10 times error in percent: */
- error = ((actual - (long)speed) * 2000 / (long)speed + 1) / 2;
-
- /* 3.0% max error tolerance */
- if (error < -30 || error > 30)
- return (-1);
-
-#if 0
- printf("prescaler = %d (%d)\n", prescaler, prescaler_unit);
- printf("divider = %d (%x)\n", divider, divider);
- printf("actual = %d\n", actual);
- printf("error = %d\n", error);
-#endif
-
- *prescaler_io = prescaler_unit;
- return (divider);
-}
-
-static void
-cd1400_channel_cmd(com, cmd)
- struct com_s *com;
- int cmd;
-{
- cd1400_channel_cmd_wait(com);
- cd_setreg(com, CD1400_CCR, cmd);
- cd1400_channel_cmd_wait(com);
-}
-
-static void
-cd1400_channel_cmd_wait(com)
- struct com_s *com;
-{
- struct timeval start;
- struct timeval tv;
- long usec;
-
- if (cd_getreg(com, CD1400_CCR) == 0)
- return;
- microtime(&start);
- for (;;) {
- if (cd_getreg(com, CD1400_CCR) == 0)
- return;
- microtime(&tv);
- usec = 1000000 * (tv.tv_sec - start.tv_sec) +
- tv.tv_usec - start.tv_usec;
- if (usec >= 5000) {
- log(LOG_ERR,
- "cy%d: channel command timeout (%ld usec)\n",
- com->unit, usec);
- return;
- }
- }
-}
-
-static void
-cd_etc(com, etc)
- struct com_s *com;
- int etc;
-{
- /*
- * We can't change the hardware's ETC state while there are any
- * characters in the tx fifo, since those characters would be
- * interpreted as commands! Unputting characters from the fifo
- * is difficult, so we wait up to 12 character times for the fifo
- * to drain. The command will be delayed for up to 2 character
- * times for the tx to become empty. Unputting characters from
- * the tx holding and shift registers is impossible, so we wait
- * for the tx to become empty so that the command is sure to be
- * executed soon after we issue it.
- */
- disable_intr();
- if (com->etc == etc) {
- enable_intr();
- goto wait;
- }
- if ((etc == CD1400_ETC_SENDBREAK
- && (com->etc == ETC_BREAK_STARTING
- || com->etc == ETC_BREAK_STARTED))
- || (etc == CD1400_ETC_STOPBREAK
- && (com->etc == ETC_BREAK_ENDING || com->etc == ETC_BREAK_ENDED
- || com->etc == ETC_NONE))) {
- enable_intr();
- return;
- }
- com->etc = etc;
- cd_setreg(com, CD1400_SRER,
- com->intr_enable
- = (com->intr_enable & ~CD1400_SRER_TXRDY) | CD1400_SRER_TXMPTY);
- enable_intr();
-wait:
- while (com->etc == etc
- && tsleep(&com->etc, TTIPRI | PCATCH, "cyetc", 0) == 0)
- continue;
-}
-
-static int
-cd_getreg(com, reg)
- struct com_s *com;
- int reg;
-{
- struct com_s *basecom;
- u_char car;
- int cy_align;
- u_long ef;
- cy_addr iobase;
- int val;
-
- basecom = com_addr(com->unit & ~(CD1400_NO_OF_CHANNELS - 1));
- car = com->unit & CD1400_CAR_CHAN;
- cy_align = com->cy_align;
- iobase = com->iobase;
- ef = read_eflags();
- if (ef & PSL_I)
- disable_intr();
- if (basecom->car != car)
- cd_outb(iobase, CD1400_CAR, cy_align, basecom->car = car);
- val = cd_inb(iobase, reg, cy_align);
- if (ef & PSL_I)
- enable_intr();
- return (val);
-}
-
-static void
-cd_setreg(com, reg, val)
- struct com_s *com;
- int reg;
- int val;
-{
- struct com_s *basecom;
- u_char car;
- int cy_align;
- u_long ef;
- cy_addr iobase;
-
- basecom = com_addr(com->unit & ~(CD1400_NO_OF_CHANNELS - 1));
- car = com->unit & CD1400_CAR_CHAN;
- cy_align = com->cy_align;
- iobase = com->iobase;
- ef = read_eflags();
- if (ef & PSL_I)
- disable_intr();
- if (basecom->car != car)
- cd_outb(iobase, CD1400_CAR, cy_align, basecom->car = car);
- cd_outb(iobase, reg, cy_align, val);
- if (ef & PSL_I)
- enable_intr();
-}
-
-#ifdef CyDebug
-/* useful in ddb */
-void
-cystatus(unit)
- int unit;
-{
- struct com_s *com;
- cy_addr iobase;
- u_int ocount;
- struct tty *tp;
-
- com = com_addr(unit);
- printf("info for channel %d\n", unit);
- printf("------------------\n");
- printf("total cyclom service probes:\t%d\n", cy_svrr_probes);
- printf("calls to upper layer:\t\t%d\n", cy_timeouts);
- if (com == NULL)
- return;
- iobase = com->iobase;
- printf("\n");
- printf("cd1400 base address:\\tt%p\n", iobase);
- printf("saved channel_control:\t\t0x%02x\n", com->channel_control);
- printf("saved cor1-3:\t\t\t0x%02x 0x%02x 0x%02x\n",
- com->cor[0], com->cor[1], com->cor[2]);
- printf("service request enable reg:\t0x%02x (0x%02x cached)\n",
- cd_getreg(com, CD1400_SRER), com->intr_enable);
- printf("service request register:\t0x%02x\n",
- cd_inb(iobase, CD1400_SVRR, com->cy_align));
- printf("modem status:\t\t\t0x%02x (0x%02x cached)\n",
- cd_getreg(com, CD1400_MSVR2), com->prev_modem_status);
- printf("rx/tx/mdm interrupt registers:\t0x%02x 0x%02x 0x%02x\n",
- cd_inb(iobase, CD1400_RIR, com->cy_align),
- cd_inb(iobase, CD1400_TIR, com->cy_align),
- cd_inb(iobase, CD1400_MIR, com->cy_align));
- printf("\n");
- printf("com state:\t\t\t0x%02x\n", com->state);
- printf("calls to comstart():\t\t%d (%d useful)\n",
- com->start_count, com->start_real);
- printf("rx buffer chars free:\t\t%d\n", com->iptr - com->ibuf);
- ocount = 0;
- if (com->obufs[0].l_queued)
- ocount += com->obufs[0].l_tail - com->obufs[0].l_head;
- if (com->obufs[1].l_queued)
- ocount += com->obufs[1].l_tail - com->obufs[1].l_head;
- printf("tx buffer chars:\t\t%u\n", ocount);
- printf("received chars:\t\t\t%d\n", com->bytes_in);
- printf("received exceptions:\t\t%d\n", com->recv_exception);
- printf("modem signal deltas:\t\t%d\n", com->mdm);
- printf("transmitted chars:\t\t%d\n", com->bytes_out);
- printf("\n");
- tp = com->tp;
- if (tp != NULL) {
- printf("tty state:\t\t\t0x%08x\n", tp->t_state);
- printf(
- "upper layer queue lengths:\t%d raw, %d canon, %d output\n",
- tp->t_rawq.c_cc, tp->t_canq.c_cc, tp->t_outq.c_cc);
- } else
- printf("tty state:\t\t\tclosed\n");
-}
-#endif /* CyDebug */
diff --git a/sys/dev/cy/cy_isa.c b/sys/dev/cy/cy_isa.c
deleted file mode 100644
index dfeb69ac11e5..000000000000
--- a/sys/dev/cy/cy_isa.c
+++ /dev/null
@@ -1,2885 +0,0 @@
-/*-
- * cyclades cyclom-y serial driver
- * Andrew Herbert <andrew@werple.apana.org.au>, 17 August 1993
- *
- * Copyright (c) 1993 Andrew Herbert.
- * 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 Andrew Herbert may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY ``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 I 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.
- *
- * $FreeBSD$
- */
-
-#include "opt_compat.h"
-#include "cy.h"
-
-/*
- * TODO:
- * Atomic COR change.
- * Consoles.
- */
-
-/*
- * Temporary compile-time configuration options.
- */
-#define RxFifoThreshold (CD1400_RX_FIFO_SIZE / 2)
- /* Number of chars in the receiver FIFO before an
- * an interrupt is generated. Should depend on
- * line speed. Needs to be about 6 on a 486DX33
- * for 4 active ports at 115200 bps. Why doesn't
- * 10 work?
- */
-#define PollMode /* Use polling-based irq service routine, not the
- * hardware svcack lines. Must be defined for
- * Cyclom-16Y boards. Less efficient for Cyclom-8Ys,
- * and stops 4 * 115200 bps from working.
- */
-#undef Smarts /* Enable slightly more CD1400 intelligence. Mainly
- * the output CR/LF processing, plus we can avoid a
- * few checks usually done in ttyinput().
- *
- * XXX not fully implemented, and not particularly
- * worthwhile.
- */
-#undef CyDebug /* Include debugging code (not very expensive). */
-
-/* These will go away. */
-#undef SOFT_CTS_OFLOW
-#define SOFT_HOTCHAR
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/tty.h>
-#include <sys/proc.h>
-#include <sys/conf.h>
-#include <sys/dkstat.h>
-#include <sys/fcntl.h>
-#include <sys/interrupt.h>
-#include <sys/kernel.h>
-#include <sys/malloc.h>
-#include <sys/syslog.h>
-#include <machine/clock.h>
-#include <machine/ipl.h>
-#ifndef SMP
-#include <machine/lock.h>
-#endif
-#include <machine/psl.h>
-
-#include <i386/isa/isa_device.h>
-#include <i386/isa/cyreg.h>
-#include <i386/isa/ic/cd1400.h>
-
-#ifdef SMP
-#define disable_intr() COM_DISABLE_INTR()
-#define enable_intr() COM_ENABLE_INTR()
-#endif /* SMP */
-
-/*
- * Dictionary so that I can name everything *sio* or *com* to compare with
- * sio.c. There is also lots of ugly formatting and unnecessary ifdefs to
- * simplify the comparision. These will go away.
- */
-#define LSR_BI CD1400_RDSR_BREAK
-#define LSR_FE CD1400_RDSR_FE
-#define LSR_OE CD1400_RDSR_OE
-#define LSR_PE CD1400_RDSR_PE
-#define MCR_DTR CD1400_MSVR2_DTR
-#define MCR_RTS CD1400_MSVR1_RTS
-#define MSR_CTS CD1400_MSVR2_CTS
-#define MSR_DCD CD1400_MSVR2_CD
-#define MSR_DSR CD1400_MSVR2_DSR
-#define MSR_RI CD1400_MSVR2_RI
-#define NSIO (NCY * CY_MAX_PORTS)
-#define comconsole cyconsole
-#define comdefaultrate cydefaultrate
-#define com_events cy_events
-#define comhardclose cyhardclose
-#define commctl cymctl
-#define comparam cyparam
-#define comspeed cyspeed
-#define comstart cystart
-#define comwakeup cywakeup
-#define nsio_tty ncy_tty
-#define p_com_addr p_cy_addr
-#define sioattach cyattach
-#define sioclose cyclose
-#define siodriver cydriver
-#define siodtrwakeup cydtrwakeup
-#define sioinput cyinput
-#define siointr cyintr
-#define siointr1 cyintr1
-#define sioioctl cyioctl
-#define sioopen cyopen
-#define siopoll cypoll
-#define sioprobe cyprobe
-#define siosettimeout cysettimeout
-#define siosetwater cysetwater
-#define comstop cystop
-#define siowrite cywrite
-#define sio_registered cy_registered
-#define sio_timeout cy_timeout
-#define sio_timeout_handle cy_timeout_handle
-#define sio_timeouts_until_log cy_timeouts_until_log
-#define sio_tty cy_tty
-
-#define CY_MAX_PORTS (CD1400_NO_OF_CHANNELS * CY_MAX_CD1400s)
-
-/* We encode the cyclom unit number (cyu) in spare bits in the IVR's. */
-#define CD1400_xIVR_CHAN_SHIFT 3
-#define CD1400_xIVR_CHAN 0x1F
-
-/*
- * ETC states. com->etc may also contain a hardware ETC command value,
- * meaning that execution of that command is pending.
- */
-#define ETC_NONE 0 /* we depend on bzero() setting this */
-#define ETC_BREAK_STARTING 1
-#define ETC_BREAK_STARTED 2
-#define ETC_BREAK_ENDING 3
-#define ETC_BREAK_ENDED 4
-
-#define LOTS_OF_EVENTS 64 /* helps separate urgent events from input */
-
-#define CALLOUT_MASK 0x80
-#define CONTROL_MASK 0x60
-#define CONTROL_INIT_STATE 0x20
-#define CONTROL_LOCK_STATE 0x40
-#define DEV_TO_UNIT(dev) (MINOR_TO_UNIT(minor(dev)))
-#define MINOR_MAGIC_MASK (CALLOUT_MASK | CONTROL_MASK)
-#define MINOR_TO_UNIT(mynor) (((mynor) >> 16) * CY_MAX_PORTS \
- | (((mynor) & 0xff) & ~MINOR_MAGIC_MASK))
-
-/*
- * com state bits.
- * (CS_BUSY | CS_TTGO) and (CS_BUSY | CS_TTGO | CS_ODEVREADY) must be higher
- * than the other bits so that they can be tested as a group without masking
- * off the low bits.
- *
- * The following com and tty flags correspond closely:
- * CS_BUSY = TS_BUSY (maintained by comstart(), siopoll() and
- * comstop())
- * CS_TTGO = ~TS_TTSTOP (maintained by comparam() and comstart())
- * CS_CTS_OFLOW = CCTS_OFLOW (maintained by comparam())
- * CS_RTS_IFLOW = CRTS_IFLOW (maintained by comparam())
- * TS_FLUSH is not used.
- * XXX I think TIOCSETA doesn't clear TS_TTSTOP when it clears IXON.
- * XXX CS_*FLOW should be CF_*FLOW in com->flags (control flags not state).
- */
-#define CS_BUSY 0x80 /* output in progress */
-#define CS_TTGO 0x40 /* output not stopped by XOFF */
-#define CS_ODEVREADY 0x20 /* external device h/w ready (CTS) */
-#define CS_CHECKMSR 1 /* check of MSR scheduled */
-#define CS_CTS_OFLOW 2 /* use CTS output flow control */
-#define CS_DTR_OFF 0x10 /* DTR held off */
-#define CS_ODONE 4 /* output completed */
-#define CS_RTS_IFLOW 8 /* use RTS input flow control */
-#define CSE_ODONE 1 /* output transmitted */
-
-static char const * const error_desc[] = {
-#define CE_OVERRUN 0
- "silo overflow",
-#define CE_INTERRUPT_BUF_OVERFLOW 1
- "interrupt-level buffer overflow",
-#define CE_TTY_BUF_OVERFLOW 2
- "tty-level buffer overflow",
-};
-
-#define CE_NTYPES 3
-#define CE_RECORD(com, errnum) (++(com)->delta_error_counts[errnum])
-
-/* types. XXX - should be elsewhere */
-typedef u_char bool_t; /* boolean */
-typedef u_char volatile *cy_addr;
-
-/* queue of linear buffers */
-struct lbq {
- u_char *l_head; /* next char to process */
- u_char *l_tail; /* one past the last char to process */
- struct lbq *l_next; /* next in queue */
- bool_t l_queued; /* nonzero if queued */
-};
-
-/* com device structure */
-struct com_s {
- u_char state; /* miscellaneous flag bits */
- bool_t active_out; /* nonzero if the callout device is open */
-#if 0
- u_char cfcr_image; /* copy of value written to CFCR */
-#endif
- u_char etc; /* pending Embedded Transmit Command */
- u_char extra_state; /* more flag bits, separate for order trick */
-#if 0
- u_char fifo_image; /* copy of value written to FIFO */
-#endif
- u_char gfrcr_image; /* copy of value read from GFRCR */
-#if 0
- bool_t hasfifo; /* nonzero for 16550 UARTs */
- bool_t loses_outints; /* nonzero if device loses output interrupts */
-#endif
- u_char mcr_dtr; /* MCR bit that is wired to DTR */
- u_char mcr_image; /* copy of value written to MCR */
- u_char mcr_rts; /* MCR bit that is wired to RTS */
-#if 0
-#ifdef COM_MULTIPORT
- bool_t multiport; /* is this unit part of a multiport device? */
-#endif /* COM_MULTIPORT */
- bool_t no_irq; /* nonzero if irq is not attached */
- bool_t poll; /* nonzero if polling is required */
- bool_t poll_output; /* nonzero if polling for output is required */
-#endif
- int unit; /* unit number */
- int dtr_wait; /* time to hold DTR down on close (* 1/hz) */
-#if 0
- u_int tx_fifo_size;
-#endif
- u_int wopeners; /* # processes waiting for DCD in open() */
-
- /*
- * The high level of the driver never reads status registers directly
- * because there would be too many side effects to handle conveniently.
- * Instead, it reads copies of the registers stored here by the
- * interrupt handler.
- */
- u_char last_modem_status; /* last MSR read by intr handler */
- u_char prev_modem_status; /* last MSR handled by high level */
-
- u_char hotchar; /* ldisc-specific char to be handled ASAP */
- u_char *ibuf; /* start of input buffer */
- u_char *ibufend; /* end of input buffer */
- u_char *ibufold; /* old input buffer, to be freed */
- u_char *ihighwater; /* threshold in input buffer */
- u_char *iptr; /* next free spot in input buffer */
- int ibufsize; /* size of ibuf (not include error bytes) */
- int ierroff; /* offset of error bytes in ibuf */
-
- struct lbq obufq; /* head of queue of output buffers */
- struct lbq obufs[2]; /* output buffers */
-
- int cy_align; /* index for register alignment */
- cy_addr cy_iobase; /* base address of this port's cyclom */
- cy_addr iobase; /* base address of this port's cd1400 */
- int mcr_rts_reg; /* cd1400 reg number of reg holding mcr_rts */
-
- struct tty *tp; /* cross reference */
-
- /* Initial state. */
- struct termios it_in; /* should be in struct tty */
- struct termios it_out;
-
- /* Lock state. */
- struct termios lt_in; /* should be in struct tty */
- struct termios lt_out;
-
- bool_t do_timestamp;
- bool_t do_dcd_timestamp;
- struct timeval timestamp;
- struct timeval dcd_timestamp;
-
- u_long bytes_in; /* statistics */
- u_long bytes_out;
- u_int delta_error_counts[CE_NTYPES];
- u_long error_counts[CE_NTYPES];
-
- u_int recv_exception; /* exception chars received */
- u_int mdm; /* modem signal changes */
-#ifdef CyDebug
- u_int start_count; /* no. of calls to comstart() */
- u_int start_real; /* no. of calls that did something */
-#endif
- u_char car; /* CD1400 CAR shadow (if first unit in cd) */
- u_char channel_control;/* CD1400 CCR control command shadow */
- u_char cor[3]; /* CD1400 COR1-3 shadows */
- u_char intr_enable; /* CD1400 SRER shadow */
-
- /*
- * Data area for output buffers. Someday we should build the output
- * buffer queue without copying data.
- */
- u_char obuf1[256];
- u_char obuf2[256];
-};
-
-/* PCI driver entry point. */
-int cyattach_common __P((cy_addr cy_iobase, int cy_align));
-ointhand2_t siointr;
-
-static int cy_units __P((cy_addr cy_iobase, int cy_align));
-static int sioattach __P((struct isa_device *dev));
-static void cd1400_channel_cmd __P((struct com_s *com, int cmd));
-static void cd1400_channel_cmd_wait __P((struct com_s *com));
-static void cd_etc __P((struct com_s *com, int etc));
-static int cd_getreg __P((struct com_s *com, int reg));
-static void cd_setreg __P((struct com_s *com, int reg, int val));
-static timeout_t siodtrwakeup;
-static void comhardclose __P((struct com_s *com));
-static void sioinput __P((struct com_s *com));
-#if 0
-static void siointr1 __P((struct com_s *com));
-#endif
-static int commctl __P((struct com_s *com, int bits, int how));
-static int comparam __P((struct tty *tp, struct termios *t));
-static swihand_t siopoll;
-static int sioprobe __P((struct isa_device *dev));
-static void siosettimeout __P((void));
-static int siosetwater __P((struct com_s *com, speed_t speed));
-static int comspeed __P((speed_t speed, u_long cy_clock,
- int *prescaler_io));
-static void comstart __P((struct tty *tp));
-static void comstop __P((struct tty *tp, int rw));
-static timeout_t comwakeup;
-static void disc_optim __P((struct tty *tp, struct termios *t,
- struct com_s *com));
-
-#ifdef CyDebug
-void cystatus __P((int unit));
-#endif
-
-static char driver_name[] = "cy";
-
-/* table and macro for fast conversion from a unit number to its com struct */
-static struct com_s *p_com_addr[NSIO];
-#define com_addr(unit) (p_com_addr[unit])
-
-struct isa_driver siodriver = {
- sioprobe, sioattach, driver_name
-};
-
-static d_open_t sioopen;
-static d_close_t sioclose;
-static d_write_t siowrite;
-static d_ioctl_t sioioctl;
-
-#define CDEV_MAJOR 48
-static struct cdevsw sio_cdevsw = {
- /* open */ sioopen,
- /* close */ sioclose,
- /* read */ ttyread,
- /* write */ siowrite,
- /* ioctl */ sioioctl,
- /* poll */ ttypoll,
- /* mmap */ nommap,
- /* strategy */ nostrategy,
- /* name */ driver_name,
- /* maj */ CDEV_MAJOR,
- /* dump */ nodump,
- /* psize */ nopsize,
- /* flags */ D_TTY,
- /* bmaj */ -1
-};
-
-static int comconsole = -1;
-static speed_t comdefaultrate = TTYDEF_SPEED;
-static u_int com_events; /* input chars + weighted output completions */
-static bool_t sio_registered;
-static int sio_timeout;
-static int sio_timeouts_until_log;
-static struct callout_handle sio_timeout_handle
- = CALLOUT_HANDLE_INITIALIZER(&sio_timeout_handle);
-#if 0 /* XXX */
-static struct tty *sio_tty[NSIO];
-#else
-static struct tty sio_tty[NSIO];
-#endif
-static const int nsio_tty = NSIO;
-
-#ifdef CyDebug
-static u_int cd_inbs;
-static u_int cy_inbs;
-static u_int cd_outbs;
-static u_int cy_outbs;
-static u_int cy_svrr_probes;
-static u_int cy_timeouts;
-#endif
-
-static int cy_chip_offset[] = {
- 0x0000, 0x0400, 0x0800, 0x0c00, 0x0200, 0x0600, 0x0a00, 0x0e00,
-};
-static int cy_nr_cd1400s[NCY];
-static int cy_total_devices;
-#undef RxFifoThreshold
-static int volatile RxFifoThreshold = (CD1400_RX_FIFO_SIZE / 2);
-
-static int
-sioprobe(dev)
- struct isa_device *dev;
-{
- cy_addr iobase;
-
- iobase = (cy_addr)dev->id_maddr;
-
- /* Cyclom-16Y hardware reset (Cyclom-8Ys don't care) */
- cy_inb(iobase, CY16_RESET, 0); /* XXX? */
- DELAY(500); /* wait for the board to get its act together */
-
- /* this is needed to get the board out of reset */
- cy_outb(iobase, CY_CLEAR_INTR, 0, 0);
- DELAY(500);
-
- return (cy_units(iobase, 0) == 0 ? 0 : -1);
-}
-
-static int
-cy_units(cy_iobase, cy_align)
- cy_addr cy_iobase;
- int cy_align;
-{
- int cyu;
- u_char firmware_version;
- int i;
- cy_addr iobase;
-
- for (cyu = 0; cyu < CY_MAX_CD1400s; ++cyu) {
- iobase = cy_iobase + (cy_chip_offset[cyu] << cy_align);
-
- /* wait for chip to become ready for new command */
- for (i = 0; i < 10; i++) {
- DELAY(50);
- if (!cd_inb(iobase, CD1400_CCR, cy_align))
- break;
- }
-
- /* clear the GFRCR register */
- cd_outb(iobase, CD1400_GFRCR, cy_align, 0);
-
- /* issue a reset command */
- cd_outb(iobase, CD1400_CCR, cy_align,
- CD1400_CCR_CMDRESET | CD1400_CCR_FULLRESET);
-
- /* wait for the CD1400 to initialize itself */
- for (i = 0; i < 200; i++) {
- DELAY(50);
-
- /* retrieve firmware version */
- firmware_version = cd_inb(iobase, CD1400_GFRCR,
- cy_align);
- if ((firmware_version & 0xf0) == 0x40)
- break;
- }
-
- /*
- * Anything in the 0x40-0x4F range is fine.
- * If one CD1400 is bad then we don't support higher
- * numbered good ones on this board.
- */
- if ((firmware_version & 0xf0) != 0x40)
- break;
- }
- return (cyu);
-}
-
-static int
-sioattach(isdp)
- struct isa_device *isdp;
-{
- int adapter;
-
- adapter = cyattach_common((cy_addr) isdp->id_maddr, 0);
- if (adapter < 0)
- return (0);
-
- /*
- * XXX
- * This kludge is to allow ISA/PCI device specifications in the
- * kernel config file to be in any order.
- */
- if (isdp->id_unit != adapter) {
- printf("cy%d: attached as cy%d\n", isdp->id_unit, adapter);
- isdp->id_unit = adapter; /* XXX */
- }
- isdp->id_ointr = siointr;
- /* isdp->id_ri_flags |= RI_FAST; XXX unimplemented - use newbus! */
- return (1);
-}
-
-int
-cyattach_common(cy_iobase, cy_align)
- cy_addr cy_iobase;
- int cy_align;
-{
- int adapter;
- int cyu;
- u_char firmware_version;
- cy_addr iobase;
- int ncyu;
- int unit;
-
- adapter = cy_total_devices;
- if ((u_int)adapter >= NCY) {
- printf(
- "cy%d: can't attach adapter: insufficient cy devices configured\n",
- adapter);
- return (-1);
- }
- ncyu = cy_units(cy_iobase, cy_align);
- if (ncyu == 0)
- return (-1);
- cy_nr_cd1400s[adapter] = ncyu;
- cy_total_devices++;
-
- unit = adapter * CY_MAX_PORTS;
- for (cyu = 0; cyu < ncyu; ++cyu) {
- int cdu;
-
- iobase = (cy_addr) (cy_iobase
- + (cy_chip_offset[cyu] << cy_align));
- firmware_version = cd_inb(iobase, CD1400_GFRCR, cy_align);
-
- /* Set up a receive timeout period of than 1+ ms. */
- cd_outb(iobase, CD1400_PPR, cy_align,
- howmany(CY_CLOCK(firmware_version)
- / CD1400_PPR_PRESCALER, 1000));
-
- for (cdu = 0; cdu < CD1400_NO_OF_CHANNELS; ++cdu, ++unit) {
- struct com_s *com;
- int s;
-
- com = malloc(sizeof *com, M_DEVBUF, M_NOWAIT);
- if (com == NULL)
- break;
- bzero(com, sizeof *com);
- com->unit = unit;
- com->gfrcr_image = firmware_version;
- if (CY_RTS_DTR_SWAPPED(firmware_version)) {
- com->mcr_dtr = MCR_RTS;
- com->mcr_rts = MCR_DTR;
- com->mcr_rts_reg = CD1400_MSVR2;
- } else {
- com->mcr_dtr = MCR_DTR;
- com->mcr_rts = MCR_RTS;
- com->mcr_rts_reg = CD1400_MSVR1;
- }
- com->dtr_wait = 3 * hz;
- com->obufs[0].l_head = com->obuf1;
- com->obufs[1].l_head = com->obuf2;
-
- com->cy_align = cy_align;
- com->cy_iobase = cy_iobase;
- com->iobase = iobase;
- com->car = ~CD1400_CAR_CHAN;
-
- /*
- * We don't use all the flags from <sys/ttydefaults.h> since they
- * are only relevant for logins. It's important to have echo off
- * initially so that the line doesn't start blathering before the
- * echo flag can be turned off.
- */
- com->it_in.c_iflag = 0;
- com->it_in.c_oflag = 0;
- com->it_in.c_cflag = TTYDEF_CFLAG;
- com->it_in.c_lflag = 0;
- if (unit == comconsole) {
- com->it_in.c_iflag = TTYDEF_IFLAG;
- com->it_in.c_oflag = TTYDEF_OFLAG;
- com->it_in.c_cflag = TTYDEF_CFLAG | CLOCAL;
- com->it_in.c_lflag = TTYDEF_LFLAG;
- com->lt_out.c_cflag = com->lt_in.c_cflag = CLOCAL;
- }
- if (siosetwater(com, com->it_in.c_ispeed) != 0) {
- enable_intr();
- free(com, M_DEVBUF);
- return (0);
- }
- enable_intr();
- termioschars(&com->it_in);
- com->it_in.c_ispeed = com->it_in.c_ospeed = comdefaultrate;
- com->it_out = com->it_in;
-
- s = spltty();
- com_addr(unit) = com;
- splx(s);
-
- if (!sio_registered) {
- cdevsw_add(&sio_cdevsw);
- register_swi(SWI_TTY, siopoll);
- sio_registered = TRUE;
- }
- make_dev(&sio_cdevsw, unit,
- UID_ROOT, GID_WHEEL, 0600, "ttyc%r%r", adapter,
- unit % CY_MAX_PORTS);
- make_dev(&sio_cdevsw, unit | CONTROL_INIT_STATE,
- UID_ROOT, GID_WHEEL, 0600, "ttyic%r%r", adapter,
- unit % CY_MAX_PORTS);
- make_dev(&sio_cdevsw, unit | CONTROL_LOCK_STATE,
- UID_ROOT, GID_WHEEL, 0600, "ttylc%r%r", adapter,
- unit % CY_MAX_PORTS);
- make_dev(&sio_cdevsw, unit | CALLOUT_MASK,
- UID_UUCP, GID_DIALER, 0660, "cuac%r%r", adapter,
- unit % CY_MAX_PORTS);
- make_dev(&sio_cdevsw, unit | CALLOUT_MASK | CONTROL_INIT_STATE,
- UID_UUCP, GID_DIALER, 0660, "cuaic%r%r", adapter,
- unit % CY_MAX_PORTS);
- make_dev(&sio_cdevsw, unit | CALLOUT_MASK | CONTROL_LOCK_STATE,
- UID_UUCP, GID_DIALER, 0660, "cualc%r%r", adapter,
- unit % CY_MAX_PORTS);
- }
- }
-
- /* ensure an edge for the next interrupt */
- cy_outb(cy_iobase, CY_CLEAR_INTR, cy_align, 0);
-
- return (adapter);
-}
-
-static int
-sioopen(dev, flag, mode, p)
- dev_t dev;
- int flag;
- int mode;
- struct proc *p;
-{
- struct com_s *com;
- int error;
- int mynor;
- int s;
- struct tty *tp;
- int unit;
-
- mynor = minor(dev);
- unit = MINOR_TO_UNIT(mynor);
- if ((u_int) unit >= NSIO || (com = com_addr(unit)) == NULL)
- return (ENXIO);
- if (mynor & CONTROL_MASK)
- return (0);
-#if 0 /* XXX */
- tp = com->tp = sio_tty[unit] = ttymalloc(sio_tty[unit]);
-#else
- tp = com->tp = &sio_tty[unit];
-#endif
- dev->si_tty = tp;
- s = spltty();
- /*
- * We jump to this label after all non-interrupted sleeps to pick
- * up any changes of the device state.
- */
-open_top:
- while (com->state & CS_DTR_OFF) {
- error = tsleep(&com->dtr_wait, TTIPRI | PCATCH, "cydtr", 0);
- if (error != 0)
- goto out;
- }
- if (tp->t_state & TS_ISOPEN) {
- /*
- * The device is open, so everything has been initialized.
- * Handle conflicts.
- */
- if (mynor & CALLOUT_MASK) {
- if (!com->active_out) {
- error = EBUSY;
- goto out;
- }
- } else {
- if (com->active_out) {
- if (flag & O_NONBLOCK) {
- error = EBUSY;
- goto out;
- }
- error = tsleep(&com->active_out,
- TTIPRI | PCATCH, "cybi", 0);
- if (error != 0)
- goto out;
- goto open_top;
- }
- }
- if (tp->t_state & TS_XCLUDE &&
- suser(p)) {
- error = EBUSY;
- goto out;
- }
- } else {
- /*
- * The device isn't open, so there are no conflicts.
- * Initialize it. Initialization is done twice in many
- * cases: to preempt sleeping callin opens if we are
- * callout, and to complete a callin open after DCD rises.
- */
- tp->t_oproc = comstart;
- tp->t_stop = comstop;
- tp->t_param = comparam;
- tp->t_dev = dev;
- tp->t_termios = mynor & CALLOUT_MASK
- ? com->it_out : com->it_in;
-
- /* Encode per-board unit in LIVR for access in intr routines. */
- cd_setreg(com, CD1400_LIVR,
- (unit & CD1400_xIVR_CHAN) << CD1400_xIVR_CHAN_SHIFT);
-
- (void)commctl(com, TIOCM_DTR | TIOCM_RTS, DMSET);
-#if 0
- com->poll = com->no_irq;
- com->poll_output = com->loses_outints;
-#endif
- ++com->wopeners;
- error = comparam(tp, &tp->t_termios);
- --com->wopeners;
- if (error != 0)
- goto out;
-#if 0
- if (com->hasfifo) {
- /*
- * (Re)enable and flush fifos.
- *
- * Certain SMC chips cause problems if the fifos
- * are enabled while input is ready. Turn off the
- * fifo if necessary to clear the input. We test
- * the input ready bit after enabling the fifos
- * since we've already enabled them in comparam()
- * and to handle races between enabling and fresh
- * input.
- */
- while (TRUE) {
- outb(iobase + com_fifo,
- FIFO_RCV_RST | FIFO_XMT_RST
- | com->fifo_image);
- DELAY(100);
- if (!(inb(com->line_status_port) & LSR_RXRDY))
- break;
- outb(iobase + com_fifo, 0);
- DELAY(100);
- (void) inb(com->data_port);
- }
- }
-
- disable_intr();
- (void) inb(com->line_status_port);
- (void) inb(com->data_port);
- com->prev_modem_status = com->last_modem_status
- = inb(com->modem_status_port);
- outb(iobase + com_ier, IER_ERXRDY | IER_ETXRDY | IER_ERLS
- | IER_EMSC);
- enable_intr();
-#else /* !0 */
- /*
- * Flush fifos. This requires a full channel reset which
- * also disables the transmitter and receiver. Recover
- * from this.
- */
- cd1400_channel_cmd(com,
- CD1400_CCR_CMDRESET | CD1400_CCR_CHANRESET);
- cd1400_channel_cmd(com, com->channel_control);
-
- disable_intr();
- com->prev_modem_status = com->last_modem_status
- = cd_getreg(com, CD1400_MSVR2);
- cd_setreg(com, CD1400_SRER,
- com->intr_enable
- = CD1400_SRER_MDMCH | CD1400_SRER_RXDATA);
- enable_intr();
-#endif /* 0 */
- /*
- * Handle initial DCD. Callout devices get a fake initial
- * DCD (trapdoor DCD). If we are callout, then any sleeping
- * callin opens get woken up and resume sleeping on "cybi"
- * instead of "cydcd".
- */
- /*
- * XXX `mynor & CALLOUT_MASK' should be
- * `tp->t_cflag & (SOFT_CARRIER | TRAPDOOR_CARRIER) where
- * TRAPDOOR_CARRIER is the default initial state for callout
- * devices and SOFT_CARRIER is like CLOCAL except it hides
- * the true carrier.
- */
- if (com->prev_modem_status & MSR_DCD || mynor & CALLOUT_MASK)
- (*linesw[tp->t_line].l_modem)(tp, 1);
- }
- /*
- * Wait for DCD if necessary.
- */
- if (!(tp->t_state & TS_CARR_ON) && !(mynor & CALLOUT_MASK)
- && !(tp->t_cflag & CLOCAL) && !(flag & O_NONBLOCK)) {
- ++com->wopeners;
- error = tsleep(TSA_CARR_ON(tp), TTIPRI | PCATCH, "cydcd", 0);
- --com->wopeners;
- if (error != 0)
- goto out;
- goto open_top;
- }
- error = (*linesw[tp->t_line].l_open)(dev, tp);
- disc_optim(tp, &tp->t_termios, com);
- if (tp->t_state & TS_ISOPEN && mynor & CALLOUT_MASK)
- com->active_out = TRUE;
- siosettimeout();
-out:
- splx(s);
- if (!(tp->t_state & TS_ISOPEN) && com->wopeners == 0)
- comhardclose(com);
- return (error);
-}
-
-static int
-sioclose(dev, flag, mode, p)
- dev_t dev;
- int flag;
- int mode;
- struct proc *p;
-{
- struct com_s *com;
- int mynor;
- int s;
- struct tty *tp;
-
- mynor = minor(dev);
- if (mynor & CONTROL_MASK)
- return (0);
- com = com_addr(MINOR_TO_UNIT(mynor));
- tp = com->tp;
- s = spltty();
- cd_etc(com, CD1400_ETC_STOPBREAK);
- (*linesw[tp->t_line].l_close)(tp, flag);
- disc_optim(tp, &tp->t_termios, com);
- comstop(tp, FREAD | FWRITE);
- comhardclose(com);
- ttyclose(tp);
- siosettimeout();
- splx(s);
-#ifdef broken /* session holds a ref to the tty; can't deallocate */
- ttyfree(tp);
- com->tp = sio_tty[unit] = NULL;
-#endif
- return (0);
-}
-
-static void
-comhardclose(com)
- struct com_s *com;
-{
- cy_addr iobase;
- int s;
- struct tty *tp;
- int unit;
-
- unit = com->unit;
- iobase = com->iobase;
- s = spltty();
-#if 0
- com->poll = FALSE;
- com->poll_output = FALSE;
-#endif
- com->do_timestamp = 0;
-#if 0
- outb(iobase + com_cfcr, com->cfcr_image &= ~CFCR_SBREAK);
-#else
- /* XXX */
- disable_intr();
- com->etc = ETC_NONE;
- cd_setreg(com, CD1400_COR2, com->cor[1] &= ~CD1400_COR2_ETC);
- enable_intr();
- cd1400_channel_cmd(com, CD1400_CCR_CMDRESET | CD1400_CCR_FTF);
-#endif
-
- {
-#if 0
- outb(iobase + com_ier, 0);
-#else
- disable_intr();
- cd_setreg(com, CD1400_SRER, com->intr_enable = 0);
- enable_intr();
-#endif
- tp = com->tp;
- if ((tp->t_cflag & HUPCL)
- /*
- * XXX we will miss any carrier drop between here and the
- * next open. Perhaps we should watch DCD even when the
- * port is closed; it is not sufficient to check it at
- * the next open because it might go up and down while
- * we're not watching.
- */
- || (!com->active_out
- && !(com->prev_modem_status & MSR_DCD)
- && !(com->it_in.c_cflag & CLOCAL))
- || !(tp->t_state & TS_ISOPEN)) {
- (void)commctl(com, TIOCM_DTR, DMBIC);
-
- /* Disable receiver (leave transmitter enabled). */
- com->channel_control = CD1400_CCR_CMDCHANCTL
- | CD1400_CCR_XMTEN
- | CD1400_CCR_RCVDIS;
- cd1400_channel_cmd(com, com->channel_control);
-
- if (com->dtr_wait != 0 && !(com->state & CS_DTR_OFF)) {
- timeout(siodtrwakeup, com, com->dtr_wait);
- com->state |= CS_DTR_OFF;
- }
- }
- }
-#if 0
- if (com->hasfifo) {
- /*
- * Disable fifos so that they are off after controlled
- * reboots. Some BIOSes fail to detect 16550s when the
- * fifos are enabled.
- */
- outb(iobase + com_fifo, 0);
- }
-#endif
- com->active_out = FALSE;
- wakeup(&com->active_out);
- wakeup(TSA_CARR_ON(tp)); /* restart any wopeners */
- splx(s);
-}
-
-static int
-siowrite(dev, uio, flag)
- dev_t dev;
- struct uio *uio;
- int flag;
-{
- int mynor;
- struct tty *tp;
- int unit;
-
- mynor = minor(dev);
- if (mynor & CONTROL_MASK)
- return (ENODEV);
-
- unit = MINOR_TO_UNIT(mynor);
- tp = com_addr(unit)->tp;
- /*
- * (XXX) We disallow virtual consoles if the physical console is
- * a serial port. This is in case there is a display attached that
- * is not the console. In that situation we don't need/want the X
- * server taking over the console.
- */
- if (constty != NULL && unit == comconsole)
- constty = NULL;
-#ifdef Smarts
- /* XXX duplicate ttwrite(), but without so much output processing on
- * CR & LF chars. Hardly worth the effort, given that high-throughput
- * sessions are raw anyhow.
- */
-#else
- return ((*linesw[tp->t_line].l_write)(tp, uio, flag));
-#endif
-}
-
-static void
-siodtrwakeup(chan)
- void *chan;
-{
- struct com_s *com;
-
- com = (struct com_s *)chan;
- com->state &= ~CS_DTR_OFF;
- wakeup(&com->dtr_wait);
-}
-
-static void
-sioinput(com)
- struct com_s *com;
-{
- u_char *buf;
- int incc;
- u_char line_status;
- int recv_data;
- struct tty *tp;
-
- buf = com->ibuf;
- tp = com->tp;
- if (!(tp->t_state & TS_ISOPEN)) {
- com_events -= (com->iptr - com->ibuf);
- com->iptr = com->ibuf;
- return;
- }
- if (tp->t_state & TS_CAN_BYPASS_L_RINT) {
- /*
- * Avoid the grotesquely inefficient lineswitch routine
- * (ttyinput) in "raw" mode. It usually takes about 450
- * instructions (that's without canonical processing or echo!).
- * slinput is reasonably fast (usually 40 instructions plus
- * call overhead).
- */
- do {
- enable_intr();
- incc = com->iptr - buf;
- if (tp->t_rawq.c_cc + incc > tp->t_ihiwat
- && (com->state & CS_RTS_IFLOW
- || tp->t_iflag & IXOFF)
- && !(tp->t_state & TS_TBLOCK))
- ttyblock(tp);
- com->delta_error_counts[CE_TTY_BUF_OVERFLOW]
- += b_to_q((char *)buf, incc, &tp->t_rawq);
- buf += incc;
- tk_nin += incc;
- tk_rawcc += incc;
- tp->t_rawcc += incc;
- ttwakeup(tp);
- if (tp->t_state & TS_TTSTOP
- && (tp->t_iflag & IXANY
- || tp->t_cc[VSTART] == tp->t_cc[VSTOP])) {
- tp->t_state &= ~TS_TTSTOP;
- tp->t_lflag &= ~FLUSHO;
- comstart(tp);
- }
- disable_intr();
- } while (buf < com->iptr);
- } else {
- do {
- enable_intr();
- line_status = buf[com->ierroff];
- recv_data = *buf++;
- if (line_status
- & (LSR_BI | LSR_FE | LSR_OE | LSR_PE)) {
- if (line_status & LSR_BI)
- recv_data |= TTY_BI;
- if (line_status & LSR_FE)
- recv_data |= TTY_FE;
- if (line_status & LSR_OE)
- recv_data |= TTY_OE;
- if (line_status & LSR_PE)
- recv_data |= TTY_PE;
- }
- (*linesw[tp->t_line].l_rint)(recv_data, tp);
- disable_intr();
- } while (buf < com->iptr);
- }
- com_events -= (com->iptr - com->ibuf);
- com->iptr = com->ibuf;
-
- /*
- * There is now room for another low-level buffer full of input,
- * so enable RTS if it is now disabled and there is room in the
- * high-level buffer.
- */
- if ((com->state & CS_RTS_IFLOW) && !(com->mcr_image & com->mcr_rts) &&
- !(tp->t_state & TS_TBLOCK))
-#if 0
- outb(com->modem_ctl_port, com->mcr_image |= MCR_RTS);
-#else
- cd_setreg(com, com->mcr_rts_reg,
- com->mcr_image |= com->mcr_rts);
-#endif
-}
-
-void
-siointr(unit)
- int unit;
-{
- int baseu;
- int cy_align;
- cy_addr cy_iobase;
- int cyu;
- cy_addr iobase;
- u_char status;
-
- COM_LOCK(); /* XXX could this be placed down lower in the loop? */
-
- baseu = unit * CY_MAX_PORTS;
- cy_align = com_addr(baseu)->cy_align;
- cy_iobase = com_addr(baseu)->cy_iobase;
-
- /* check each CD1400 in turn */
- for (cyu = 0; cyu < cy_nr_cd1400s[unit]; ++cyu) {
- iobase = (cy_addr) (cy_iobase
- + (cy_chip_offset[cyu] << cy_align));
- /* poll to see if it has any work */
- status = cd_inb(iobase, CD1400_SVRR, cy_align);
- if (status == 0)
- continue;
-#ifdef CyDebug
- ++cy_svrr_probes;
-#endif
- /* service requests as appropriate, giving priority to RX */
- if (status & CD1400_SVRR_RXRDY) {
- struct com_s *com;
- u_int count;
- u_char *ioptr;
- u_char line_status;
- u_char recv_data;
- u_char serv_type;
-#ifdef PollMode
- u_char save_rir;
-#endif
-
-#ifdef PollMode
- save_rir = cd_inb(iobase, CD1400_RIR, cy_align);
-
- /* enter rx service */
- cd_outb(iobase, CD1400_CAR, cy_align, save_rir);
- com_addr(baseu + cyu * CD1400_NO_OF_CHANNELS)->car
- = save_rir & CD1400_CAR_CHAN;
-
- serv_type = cd_inb(iobase, CD1400_RIVR, cy_align);
- com = com_addr(baseu
- + ((serv_type >> CD1400_xIVR_CHAN_SHIFT)
- & CD1400_xIVR_CHAN));
-#else
- /* ack receive service */
- serv_type = cy_inb(iobase, CY8_SVCACKR, cy_align);
-
- com = com_addr(baseu +
- + ((serv_type >> CD1400_xIVR_CHAN_SHIFT)
- & CD1400_xIVR_CHAN));
-#endif
-
- if (serv_type & CD1400_RIVR_EXCEPTION) {
- ++com->recv_exception;
- line_status = cd_inb(iobase, CD1400_RDSR, cy_align);
- /* break/unnattached error bits or real input? */
- recv_data = cd_inb(iobase, CD1400_RDSR, cy_align);
-#ifndef SOFT_HOTCHAR
- if (line_status & CD1400_RDSR_SPECIAL
- && com->hotchar != 0)
- setsofttty();
-#endif
-#if 1 /* XXX "intelligent" PFO error handling would break O error handling */
- if (line_status & (LSR_PE|LSR_FE|LSR_BI)) {
- /*
- Don't store PE if IGNPAR and BI if IGNBRK,
- this hack allows "raw" tty optimization
- works even if IGN* is set.
- */
- if ( com->tp == NULL
- || !(com->tp->t_state & TS_ISOPEN)
- || ((line_status & (LSR_PE|LSR_FE))
- && (com->tp->t_iflag & IGNPAR))
- || ((line_status & LSR_BI)
- && (com->tp->t_iflag & IGNBRK)))
- goto cont;
- if ( (line_status & (LSR_PE|LSR_FE))
- && (com->tp->t_state & TS_CAN_BYPASS_L_RINT)
- && ((line_status & LSR_FE)
- || ((line_status & LSR_PE)
- && (com->tp->t_iflag & INPCK))))
- recv_data = 0;
- }
-#endif /* 1 */
- ++com->bytes_in;
-#ifdef SOFT_HOTCHAR
- if (com->hotchar != 0 && recv_data == com->hotchar)
- setsofttty();
-#endif
- ioptr = com->iptr;
- if (ioptr >= com->ibufend)
- CE_RECORD(com, CE_INTERRUPT_BUF_OVERFLOW);
- else {
- if (com->do_timestamp)
- microtime(&com->timestamp);
- ++com_events;
- ioptr[0] = recv_data;
- ioptr[com->ierroff] = line_status;
- com->iptr = ++ioptr;
- if (ioptr == com->ihighwater
- && com->state & CS_RTS_IFLOW)
-#if 0
- outb(com->modem_ctl_port,
- com->mcr_image &= ~MCR_RTS);
-#else
- cd_outb(iobase, com->mcr_rts_reg,
- cy_align,
- com->mcr_image &=
- ~com->mcr_rts);
-#endif
- if (line_status & LSR_OE)
- CE_RECORD(com, CE_OVERRUN);
- }
- goto cont;
- } else {
- int ifree;
-
- count = cd_inb(iobase, CD1400_RDCR, cy_align);
- if (!count)
- goto cont;
- com->bytes_in += count;
- ioptr = com->iptr;
- ifree = com->ibufend - ioptr;
- if (count > ifree) {
- count -= ifree;
- com_events += ifree;
- if (ifree != 0) {
- if (com->do_timestamp)
- microtime(&com->timestamp);
- do {
- recv_data = cd_inb(iobase,
- CD1400_RDSR,
- cy_align);
-#ifdef SOFT_HOTCHAR
- if (com->hotchar != 0
- && recv_data
- == com->hotchar)
- setsofttty();
-#endif
- ioptr[0] = recv_data;
- ioptr[com->ierroff] = 0;
- ++ioptr;
- } while (--ifree != 0);
- }
- com->delta_error_counts
- [CE_INTERRUPT_BUF_OVERFLOW] += count;
- do {
- recv_data = cd_inb(iobase, CD1400_RDSR,
- cy_align);
-#ifdef SOFT_HOTCHAR
- if (com->hotchar != 0
- && recv_data == com->hotchar)
- setsofttty();
-#endif
- } while (--count != 0);
- } else {
- if (com->do_timestamp)
- microtime(&com->timestamp);
- if (ioptr <= com->ihighwater
- && ioptr + count > com->ihighwater
- && com->state & CS_RTS_IFLOW)
-#if 0
- outb(com->modem_ctl_port,
- com->mcr_image &= ~MCR_RTS);
-#else
- cd_outb(iobase, com->mcr_rts_reg,
- cy_align,
- com->mcr_image
- &= ~com->mcr_rts);
-#endif
- com_events += count;
- do {
- recv_data = cd_inb(iobase, CD1400_RDSR,
- cy_align);
-#ifdef SOFT_HOTCHAR
- if (com->hotchar != 0
- && recv_data == com->hotchar)
- setsofttty();
-#endif
- ioptr[0] = recv_data;
- ioptr[com->ierroff] = 0;
- ++ioptr;
- } while (--count != 0);
- }
- com->iptr = ioptr;
- }
-cont:
-
- /* terminate service context */
-#ifdef PollMode
- cd_outb(iobase, CD1400_RIR, cy_align,
- save_rir
- & ~(CD1400_RIR_RDIREQ | CD1400_RIR_RBUSY));
-#else
- cd_outb(iobase, CD1400_EOSRR, cy_align, 0);
-#endif
- }
- if (status & CD1400_SVRR_MDMCH) {
- struct com_s *com;
- u_char modem_status;
-#ifdef PollMode
- u_char save_mir;
-#else
- u_char vector;
-#endif
-
-#ifdef PollMode
- save_mir = cd_inb(iobase, CD1400_MIR, cy_align);
-
- /* enter modem service */
- cd_outb(iobase, CD1400_CAR, cy_align, save_mir);
- com_addr(baseu + cyu * CD1400_NO_OF_CHANNELS)->car
- = save_mir & CD1400_CAR_CHAN;
-
- com = com_addr(baseu + cyu * CD1400_NO_OF_CHANNELS
- + (save_mir & CD1400_MIR_CHAN));
-#else
- /* ack modem service */
- vector = cy_inb(iobase, CY8_SVCACKM, cy_align);
-
- com = com_addr(baseu
- + ((vector >> CD1400_xIVR_CHAN_SHIFT)
- & CD1400_xIVR_CHAN));
-#endif
- ++com->mdm;
- modem_status = cd_inb(iobase, CD1400_MSVR2, cy_align);
- if (modem_status != com->last_modem_status) {
- if (com->do_dcd_timestamp
- && !(com->last_modem_status & MSR_DCD)
- && modem_status & MSR_DCD)
- microtime(&com->dcd_timestamp);
-
- /*
- * Schedule high level to handle DCD changes. Note
- * that we don't use the delta bits anywhere. Some
- * UARTs mess them up, and it's easy to remember the
- * previous bits and calculate the delta.
- */
- com->last_modem_status = modem_status;
- if (!(com->state & CS_CHECKMSR)) {
- com_events += LOTS_OF_EVENTS;
- com->state |= CS_CHECKMSR;
- setsofttty();
- }
-
-#ifdef SOFT_CTS_OFLOW
- /* handle CTS change immediately for crisp flow ctl */
- if (com->state & CS_CTS_OFLOW) {
- if (modem_status & MSR_CTS) {
- com->state |= CS_ODEVREADY;
- if (com->state >= (CS_BUSY | CS_TTGO
- | CS_ODEVREADY)
- && !(com->intr_enable
- & CD1400_SRER_TXRDY))
- cd_outb(iobase, CD1400_SRER,
- cy_align,
- com->intr_enable
- = com->intr_enable
- & ~CD1400_SRER_TXMPTY
- | CD1400_SRER_TXRDY);
- } else {
- com->state &= ~CS_ODEVREADY;
- if (com->intr_enable
- & CD1400_SRER_TXRDY)
- cd_outb(iobase, CD1400_SRER,
- cy_align,
- com->intr_enable
- = com->intr_enable
- & ~CD1400_SRER_TXRDY
- | CD1400_SRER_TXMPTY);
- }
- }
-#endif
- }
-
- /* terminate service context */
-#ifdef PollMode
- cd_outb(iobase, CD1400_MIR, cy_align,
- save_mir
- & ~(CD1400_MIR_RDIREQ | CD1400_MIR_RBUSY));
-#else
- cd_outb(iobase, CD1400_EOSRR, cy_align, 0);
-#endif
- }
- if (status & CD1400_SVRR_TXRDY) {
- struct com_s *com;
-#ifdef PollMode
- u_char save_tir;
-#else
- u_char vector;
-#endif
-
-#ifdef PollMode
- save_tir = cd_inb(iobase, CD1400_TIR, cy_align);
-
- /* enter tx service */
- cd_outb(iobase, CD1400_CAR, cy_align, save_tir);
- com_addr(baseu + cyu * CD1400_NO_OF_CHANNELS)->car
- = save_tir & CD1400_CAR_CHAN;
-
- com = com_addr(baseu
- + cyu * CD1400_NO_OF_CHANNELS
- + (save_tir & CD1400_TIR_CHAN));
-#else
- /* ack transmit service */
- vector = cy_inb(iobase, CY8_SVCACKT, cy_align);
-
- com = com_addr(baseu
- + ((vector >> CD1400_xIVR_CHAN_SHIFT)
- & CD1400_xIVR_CHAN));
-#endif
-
- if (com->etc != ETC_NONE) {
- if (com->intr_enable & CD1400_SRER_TXRDY) {
- /*
- * Here due to sloppy SRER_TXRDY
- * enabling. Ignore. Come back when
- * tx is empty.
- */
- cd_outb(iobase, CD1400_SRER, cy_align,
- com->intr_enable
- = (com->intr_enable
- & ~CD1400_SRER_TXRDY)
- | CD1400_SRER_TXMPTY);
- goto terminate_tx_service;
- }
- switch (com->etc) {
- case CD1400_ETC_SENDBREAK:
- case CD1400_ETC_STOPBREAK:
- /*
- * Start the command. Come back on
- * next tx empty interrupt, hopefully
- * after command has been executed.
- */
- cd_outb(iobase, CD1400_COR2, cy_align,
- com->cor[1] |= CD1400_COR2_ETC);
- cd_outb(iobase, CD1400_TDR, cy_align,
- CD1400_ETC_CMD);
- cd_outb(iobase, CD1400_TDR, cy_align,
- com->etc);
- if (com->etc == CD1400_ETC_SENDBREAK)
- com->etc = ETC_BREAK_STARTING;
- else
- com->etc = ETC_BREAK_ENDING;
- goto terminate_tx_service;
- case ETC_BREAK_STARTING:
- /*
- * BREAK is now on. Continue with
- * SRER_TXMPTY processing, hopefully
- * don't come back.
- */
- com->etc = ETC_BREAK_STARTED;
- break;
- case ETC_BREAK_STARTED:
- /*
- * Came back due to sloppy SRER_TXMPTY
- * enabling. Hope again.
- */
- break;
- case ETC_BREAK_ENDING:
- /*
- * BREAK is now off. Continue with
- * SRER_TXMPTY processing and don't
- * come back. The SWI handler will
- * restart tx interrupts if necessary.
- */
- cd_outb(iobase, CD1400_COR2, cy_align,
- com->cor[1]
- &= ~CD1400_COR2_ETC);
- com->etc = ETC_BREAK_ENDED;
- if (!(com->state & CS_ODONE)) {
- com_events += LOTS_OF_EVENTS;
- com->state |= CS_ODONE;
- setsofttty();
- }
- break;
- case ETC_BREAK_ENDED:
- /*
- * Shouldn't get here. Hope again.
- */
- break;
- }
- }
- if (com->intr_enable & CD1400_SRER_TXMPTY) {
- if (!(com->extra_state & CSE_ODONE)) {
- com_events += LOTS_OF_EVENTS;
- com->extra_state |= CSE_ODONE;
- setsofttty();
- }
- cd_outb(iobase, CD1400_SRER, cy_align,
- com->intr_enable
- &= ~CD1400_SRER_TXMPTY);
- goto terminate_tx_service;
- }
- if (com->state >= (CS_BUSY | CS_TTGO | CS_ODEVREADY)) {
- u_char *ioptr;
- u_int ocount;
-
- ioptr = com->obufq.l_head;
- ocount = com->obufq.l_tail - ioptr;
- if (ocount > CD1400_TX_FIFO_SIZE)
- ocount = CD1400_TX_FIFO_SIZE;
- com->bytes_out += ocount;
- do
- cd_outb(iobase, CD1400_TDR, cy_align,
- *ioptr++);
- while (--ocount != 0);
- com->obufq.l_head = ioptr;
- if (ioptr >= com->obufq.l_tail) {
- struct lbq *qp;
-
- qp = com->obufq.l_next;
- qp->l_queued = FALSE;
- qp = qp->l_next;
- if (qp != NULL) {
- com->obufq.l_head = qp->l_head;
- com->obufq.l_tail = qp->l_tail;
- com->obufq.l_next = qp;
- } else {
- /* output just completed */
- com->state &= ~CS_BUSY;
-
- /*
- * The setting of CSE_ODONE may be
- * stale here. We currently only
- * use it when CS_BUSY is set, and
- * fixing it when we clear CS_BUSY
- * is easiest.
- */
- if (com->extra_state & CSE_ODONE) {
- com_events -= LOTS_OF_EVENTS;
- com->extra_state &= ~CSE_ODONE;
- }
-
- cd_outb(iobase, CD1400_SRER, cy_align,
- com->intr_enable
- = (com->intr_enable
- & ~CD1400_SRER_TXRDY)
- | CD1400_SRER_TXMPTY);
- }
- if (!(com->state & CS_ODONE)) {
- com_events += LOTS_OF_EVENTS;
- com->state |= CS_ODONE;
-
- /* handle at high level ASAP */
- setsofttty();
- }
- }
- }
-
- /* terminate service context */
-terminate_tx_service:
-#ifdef PollMode
- cd_outb(iobase, CD1400_TIR, cy_align,
- save_tir
- & ~(CD1400_TIR_RDIREQ | CD1400_TIR_RBUSY));
-#else
- cd_outb(iobase, CD1400_EOSRR, cy_align, 0);
-#endif
- }
- }
-
- /* ensure an edge for the next interrupt */
- cy_outb(cy_iobase, CY_CLEAR_INTR, cy_align, 0);
-
- schedsofttty();
-
- COM_UNLOCK();
-}
-
-#if 0
-static void
-siointr1(com)
- struct com_s *com;
-{
-}
-#endif
-
-static int
-sioioctl(dev, cmd, data, flag, p)
- dev_t dev;
- u_long cmd;
- caddr_t data;
- int flag;
- struct proc *p;
-{
- struct com_s *com;
- int error;
- int mynor;
- int s;
- struct tty *tp;
-#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
- int oldcmd;
- struct termios term;
-#endif
-
- mynor = minor(dev);
- com = com_addr(MINOR_TO_UNIT(mynor));
- if (mynor & CONTROL_MASK) {
- struct termios *ct;
-
- switch (mynor & CONTROL_MASK) {
- case CONTROL_INIT_STATE:
- ct = mynor & CALLOUT_MASK ? &com->it_out : &com->it_in;
- break;
- case CONTROL_LOCK_STATE:
- ct = mynor & CALLOUT_MASK ? &com->lt_out : &com->lt_in;
- break;
- default:
- return (ENODEV); /* /dev/nodev */
- }
- switch (cmd) {
- case TIOCSETA:
- error = suser(p);
- if (error != 0)
- return (error);
- *ct = *(struct termios *)data;
- return (0);
- case TIOCGETA:
- *(struct termios *)data = *ct;
- return (0);
- case TIOCGETD:
- *(int *)data = TTYDISC;
- return (0);
- case TIOCGWINSZ:
- bzero(data, sizeof(struct winsize));
- return (0);
- default:
- return (ENOTTY);
- }
- }
- tp = com->tp;
-#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
- term = tp->t_termios;
- oldcmd = cmd;
- error = ttsetcompat(tp, &cmd, data, &term);
- if (error != 0)
- return (error);
- if (cmd != oldcmd)
- data = (caddr_t)&term;
-#endif
- if (cmd == TIOCSETA || cmd == TIOCSETAW || cmd == TIOCSETAF) {
- int cc;
- struct termios *dt = (struct termios *)data;
- struct termios *lt = mynor & CALLOUT_MASK
- ? &com->lt_out : &com->lt_in;
-
- dt->c_iflag = (tp->t_iflag & lt->c_iflag)
- | (dt->c_iflag & ~lt->c_iflag);
- dt->c_oflag = (tp->t_oflag & lt->c_oflag)
- | (dt->c_oflag & ~lt->c_oflag);
- dt->c_cflag = (tp->t_cflag & lt->c_cflag)
- | (dt->c_cflag & ~lt->c_cflag);
- dt->c_lflag = (tp->t_lflag & lt->c_lflag)
- | (dt->c_lflag & ~lt->c_lflag);
- for (cc = 0; cc < NCCS; ++cc)
- if (lt->c_cc[cc] != 0)
- dt->c_cc[cc] = tp->t_cc[cc];
- if (lt->c_ispeed != 0)
- dt->c_ispeed = tp->t_ispeed;
- if (lt->c_ospeed != 0)
- dt->c_ospeed = tp->t_ospeed;
- }
- error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p);
- if (error != ENOIOCTL)
- return (error);
- s = spltty();
- error = ttioctl(tp, cmd, data, flag);
- disc_optim(tp, &tp->t_termios, com);
- if (error != ENOIOCTL) {
- splx(s);
- return (error);
- }
- switch (cmd) {
- case TIOCSBRK:
-#if 0
- outb(iobase + com_cfcr, com->cfcr_image |= CFCR_SBREAK);
-#else
- cd_etc(com, CD1400_ETC_SENDBREAK);
-#endif
- break;
- case TIOCCBRK:
-#if 0
- outb(iobase + com_cfcr, com->cfcr_image &= ~CFCR_SBREAK);
-#else
- cd_etc(com, CD1400_ETC_STOPBREAK);
-#endif
- break;
- case TIOCSDTR:
- (void)commctl(com, TIOCM_DTR, DMBIS);
- break;
- case TIOCCDTR:
- (void)commctl(com, TIOCM_DTR, DMBIC);
- break;
- /*
- * XXX should disallow changing MCR_RTS if CS_RTS_IFLOW is set. The
- * changes get undone on the next call to comparam().
- */
- case TIOCMSET:
- (void)commctl(com, *(int *)data, DMSET);
- break;
- case TIOCMBIS:
- (void)commctl(com, *(int *)data, DMBIS);
- break;
- case TIOCMBIC:
- (void)commctl(com, *(int *)data, DMBIC);
- break;
- case TIOCMGET:
- *(int *)data = commctl(com, 0, DMGET);
- break;
- case TIOCMSDTRWAIT:
- /* must be root since the wait applies to following logins */
- error = suser(p);
- if (error != 0) {
- splx(s);
- return (error);
- }
- com->dtr_wait = *(int *)data * hz / 100;
- break;
- case TIOCMGDTRWAIT:
- *(int *)data = com->dtr_wait * 100 / hz;
- break;
- case TIOCTIMESTAMP:
- com->do_timestamp = TRUE;
- *(struct timeval *)data = com->timestamp;
- break;
- case TIOCDCDTIMESTAMP:
- com->do_dcd_timestamp = TRUE;
- *(struct timeval *)data = com->dcd_timestamp;
- break;
- default:
- splx(s);
- return (ENOTTY);
- }
- splx(s);
- return (0);
-}
-
-static void
-siopoll()
-{
- int unit;
-
-#ifdef CyDebug
- ++cy_timeouts;
-#endif
- if (com_events == 0)
- return;
-repeat:
- for (unit = 0; unit < NSIO; ++unit) {
- struct com_s *com;
- int incc;
- struct tty *tp;
-
- com = com_addr(unit);
- if (com == NULL)
- continue;
- tp = com->tp;
- if (tp == NULL) {
- /*
- * XXX forget any events related to closed devices
- * (actually never opened devices) so that we don't
- * loop.
- */
- disable_intr();
- incc = com->iptr - com->ibuf;
- com->iptr = com->ibuf;
- if (com->state & CS_CHECKMSR) {
- incc += LOTS_OF_EVENTS;
- com->state &= ~CS_CHECKMSR;
- }
- com_events -= incc;
- enable_intr();
- if (incc != 0)
- log(LOG_DEBUG,
- "sio%d: %d events for device with no tp\n",
- unit, incc);
- continue;
- }
- if (com->iptr != com->ibuf) {
- disable_intr();
- sioinput(com);
- enable_intr();
- }
- if (com->state & CS_CHECKMSR) {
- u_char delta_modem_status;
-
- disable_intr();
- delta_modem_status = com->last_modem_status
- ^ com->prev_modem_status;
- com->prev_modem_status = com->last_modem_status;
- com_events -= LOTS_OF_EVENTS;
- com->state &= ~CS_CHECKMSR;
- enable_intr();
- if (delta_modem_status & MSR_DCD)
- (*linesw[tp->t_line].l_modem)
- (tp, com->prev_modem_status & MSR_DCD);
- }
- if (com->extra_state & CSE_ODONE) {
- disable_intr();
- com_events -= LOTS_OF_EVENTS;
- com->extra_state &= ~CSE_ODONE;
- enable_intr();
- if (!(com->state & CS_BUSY)) {
- tp->t_state &= ~TS_BUSY;
- ttwwakeup(com->tp);
- }
- if (com->etc != ETC_NONE) {
- if (com->etc == ETC_BREAK_ENDED)
- com->etc = ETC_NONE;
- wakeup(&com->etc);
- }
- }
- if (com->state & CS_ODONE) {
- disable_intr();
- com_events -= LOTS_OF_EVENTS;
- com->state &= ~CS_ODONE;
- enable_intr();
- (*linesw[tp->t_line].l_start)(tp);
- }
- if (com_events == 0)
- break;
- }
- if (com_events >= LOTS_OF_EVENTS)
- goto repeat;
-}
-
-static int
-comparam(tp, t)
- struct tty *tp;
- struct termios *t;
-{
- int bits;
- int cflag;
- struct com_s *com;
- u_char cor_change;
- u_long cy_clock;
- int idivisor;
- int iflag;
- int iprescaler;
- int itimeout;
- int odivisor;
- int oprescaler;
- u_char opt;
- int s;
- int unit;
-
- /* do historical conversions */
- if (t->c_ispeed == 0)
- t->c_ispeed = t->c_ospeed;
-
- unit = DEV_TO_UNIT(tp->t_dev);
- com = com_addr(unit);
-
- /* check requested parameters */
- cy_clock = CY_CLOCK(com->gfrcr_image);
- idivisor = comspeed(t->c_ispeed, cy_clock, &iprescaler);
- if (idivisor < 0)
- return (EINVAL);
- odivisor = comspeed(t->c_ospeed, cy_clock, &oprescaler);
- if (odivisor < 0)
- return (EINVAL);
-
- /* parameters are OK, convert them to the com struct and the device */
- s = spltty();
- if (odivisor == 0)
- (void)commctl(com, TIOCM_DTR, DMBIC); /* hang up line */
- else
- (void)commctl(com, TIOCM_DTR, DMBIS);
-
- /*
- * This returns with interrupts disabled so that we can complete
- * the speed change atomically.
- */
- (void) siosetwater(com, t->c_ispeed);
-
- /* XXX we don't actually change the speed atomically. */
- enable_intr();
-
- if (idivisor != 0) {
- cd_setreg(com, CD1400_RBPR, idivisor);
- cd_setreg(com, CD1400_RCOR, iprescaler);
- }
- if (odivisor != 0) {
- cd_setreg(com, CD1400_TBPR, odivisor);
- cd_setreg(com, CD1400_TCOR, oprescaler);
- }
-
- /*
- * channel control
- * receiver enable
- * transmitter enable (always set)
- */
- cflag = t->c_cflag;
- opt = CD1400_CCR_CMDCHANCTL | CD1400_CCR_XMTEN
- | (cflag & CREAD ? CD1400_CCR_RCVEN : CD1400_CCR_RCVDIS);
- if (opt != com->channel_control) {
- com->channel_control = opt;
- cd1400_channel_cmd(com, opt);
- }
-
-#ifdef Smarts
- /* set special chars */
- /* XXX if one is _POSIX_VDISABLE, can't use some others */
- if (t->c_cc[VSTOP] != _POSIX_VDISABLE)
- cd_setreg(com, CD1400_SCHR1, t->c_cc[VSTOP]);
- if (t->c_cc[VSTART] != _POSIX_VDISABLE)
- cd_setreg(com, CD1400_SCHR2, t->c_cc[VSTART]);
- if (t->c_cc[VINTR] != _POSIX_VDISABLE)
- cd_setreg(com, CD1400_SCHR3, t->c_cc[VINTR]);
- if (t->c_cc[VSUSP] != _POSIX_VDISABLE)
- cd_setreg(com, CD1400_SCHR4, t->c_cc[VSUSP]);
-#endif
-
- /*
- * set channel option register 1 -
- * parity mode
- * stop bits
- * char length
- */
- opt = 0;
- /* parity */
- if (cflag & PARENB) {
- if (cflag & PARODD)
- opt |= CD1400_COR1_PARODD;
- opt |= CD1400_COR1_PARNORMAL;
- }
- iflag = t->c_iflag;
- if (!(iflag & INPCK))
- opt |= CD1400_COR1_NOINPCK;
- bits = 1 + 1;
- /* stop bits */
- if (cflag & CSTOPB) {
- ++bits;
- opt |= CD1400_COR1_STOP2;
- }
- /* char length */
- switch (cflag & CSIZE) {
- case CS5:
- bits += 5;
- opt |= CD1400_COR1_CS5;
- break;
- case CS6:
- bits += 6;
- opt |= CD1400_COR1_CS6;
- break;
- case CS7:
- bits += 7;
- opt |= CD1400_COR1_CS7;
- break;
- default:
- bits += 8;
- opt |= CD1400_COR1_CS8;
- break;
- }
- cor_change = 0;
- if (opt != com->cor[0]) {
- cor_change |= CD1400_CCR_COR1;
- cd_setreg(com, CD1400_COR1, com->cor[0] = opt);
- }
-
- /*
- * Set receive time-out period, normally to max(one char time, 5 ms).
- */
- if (t->c_ispeed == 0)
- itimeout = cd_getreg(com, CD1400_RTPR);
- else {
- itimeout = (1000 * bits + t->c_ispeed - 1) / t->c_ispeed;
-#ifdef SOFT_HOTCHAR
-#define MIN_RTP 1
-#else
-#define MIN_RTP 5
-#endif
- if (itimeout < MIN_RTP)
- itimeout = MIN_RTP;
- }
- if (!(t->c_lflag & ICANON) && t->c_cc[VMIN] != 0 && t->c_cc[VTIME] != 0
- && t->c_cc[VTIME] * 10 > itimeout)
- itimeout = t->c_cc[VTIME] * 10;
- if (itimeout > 255)
- itimeout = 255;
- cd_setreg(com, CD1400_RTPR, itimeout);
-
- /*
- * set channel option register 2 -
- * flow control
- */
- opt = 0;
-#ifdef Smarts
- if (iflag & IXANY)
- opt |= CD1400_COR2_IXANY;
- if (iflag & IXOFF)
- opt |= CD1400_COR2_IXOFF;
-#endif
-#ifndef SOFT_CTS_OFLOW
- if (cflag & CCTS_OFLOW)
- opt |= CD1400_COR2_CCTS_OFLOW;
-#endif
- disable_intr();
- if (opt != com->cor[1]) {
- cor_change |= CD1400_CCR_COR2;
- cd_setreg(com, CD1400_COR2, com->cor[1] = opt);
- }
- enable_intr();
-
- /*
- * set channel option register 3 -
- * receiver FIFO interrupt threshold
- * flow control
- */
- opt = RxFifoThreshold;
-#ifdef Smarts
- if (t->c_lflag & ICANON)
- opt |= CD1400_COR3_SCD34; /* detect INTR & SUSP chars */
- if (iflag & IXOFF)
- /* detect and transparently handle START and STOP chars */
- opt |= CD1400_COR3_FCT | CD1400_COR3_SCD12;
-#endif
- if (opt != com->cor[2]) {
- cor_change |= CD1400_CCR_COR3;
- cd_setreg(com, CD1400_COR3, com->cor[2] = opt);
- }
-
- /* notify the CD1400 if COR1-3 have changed */
- if (cor_change)
- cd1400_channel_cmd(com, CD1400_CCR_CMDCORCHG | cor_change);
-
- /*
- * set channel option register 4 -
- * CR/NL processing
- * break processing
- * received exception processing
- */
- opt = 0;
- if (iflag & IGNCR)
- opt |= CD1400_COR4_IGNCR;
-#ifdef Smarts
- /*
- * we need a new ttyinput() for this, as we don't want to
- * have ICRNL && INLCR being done in both layers, or to have
- * synchronisation problems
- */
- if (iflag & ICRNL)
- opt |= CD1400_COR4_ICRNL;
- if (iflag & INLCR)
- opt |= CD1400_COR4_INLCR;
-#endif
- if (iflag & IGNBRK)
- opt |= CD1400_COR4_IGNBRK | CD1400_COR4_NOBRKINT;
- /*
- * The `-ignbrk -brkint parmrk' case is not handled by the hardware,
- * so only tell the hardware about -brkint if -parmrk.
- */
- if (!(iflag & (BRKINT | PARMRK)))
- opt |= CD1400_COR4_NOBRKINT;
-#if 0
- /* XXX using this "intelligence" breaks reporting of overruns. */
- if (iflag & IGNPAR)
- opt |= CD1400_COR4_PFO_DISCARD;
- else {
- if (iflag & PARMRK)
- opt |= CD1400_COR4_PFO_ESC;
- else
- opt |= CD1400_COR4_PFO_NUL;
- }
-#else
- opt |= CD1400_COR4_PFO_EXCEPTION;
-#endif
- cd_setreg(com, CD1400_COR4, opt);
-
- /*
- * set channel option register 5 -
- */
- opt = 0;
- if (iflag & ISTRIP)
- opt |= CD1400_COR5_ISTRIP;
- if (t->c_iflag & IEXTEN)
- /* enable LNEXT (e.g. ctrl-v quoting) handling */
- opt |= CD1400_COR5_LNEXT;
-#ifdef Smarts
- if (t->c_oflag & ONLCR)
- opt |= CD1400_COR5_ONLCR;
- if (t->c_oflag & OCRNL)
- opt |= CD1400_COR5_OCRNL;
-#endif
- cd_setreg(com, CD1400_COR5, opt);
-
- /*
- * We always generate modem status change interrupts for CD changes.
- * Among other things, this is necessary to track TS_CARR_ON for
- * pstat to print even when the driver doesn't care. CD changes
- * should be rare so interrupts for them are not worth extra code to
- * avoid. We avoid interrupts for other modem status changes (except
- * for CTS changes when SOFT_CTS_OFLOW is configured) since this is
- * simplest and best.
- */
-
- /*
- * set modem change option register 1
- * generate modem interrupts on which 1 -> 0 input transitions
- * also controls auto-DTR output flow-control, which we don't use
- */
- opt = CD1400_MCOR1_CDzd;
-#ifdef SOFT_CTS_OFLOW
- if (cflag & CCTS_OFLOW)
- opt |= CD1400_MCOR1_CTSzd;
-#endif
- cd_setreg(com, CD1400_MCOR1, opt);
-
- /*
- * set modem change option register 2
- * generate modem interrupts on specific 0 -> 1 input transitions
- */
- opt = CD1400_MCOR2_CDod;
-#ifdef SOFT_CTS_OFLOW
- if (cflag & CCTS_OFLOW)
- opt |= CD1400_MCOR2_CTSod;
-#endif
- cd_setreg(com, CD1400_MCOR2, opt);
-
- /*
- * XXX should have done this long ago, but there is too much state
- * to change all atomically.
- */
- disable_intr();
-
- com->state &= ~CS_TTGO;
- if (!(tp->t_state & TS_TTSTOP))
- com->state |= CS_TTGO;
- if (cflag & CRTS_IFLOW) {
- com->state |= CS_RTS_IFLOW;
- /*
- * If CS_RTS_IFLOW just changed from off to on, the change
- * needs to be propagated to MCR_RTS. This isn't urgent,
- * so do it later by calling comstart() instead of repeating
- * a lot of code from comstart() here.
- */
- } else if (com->state & CS_RTS_IFLOW) {
- com->state &= ~CS_RTS_IFLOW;
- /*
- * CS_RTS_IFLOW just changed from on to off. Force MCR_RTS
- * on here, since comstart() won't do it later.
- */
-#if 0
- outb(com->modem_ctl_port, com->mcr_image |= MCR_RTS);
-#else
- cd_setreg(com, com->mcr_rts_reg,
- com->mcr_image |= com->mcr_rts);
-#endif
- }
-
- /*
- * Set up state to handle output flow control.
- * XXX - worth handling MDMBUF (DCD) flow control at the lowest level?
- * Now has 10+ msec latency, while CTS flow has 50- usec latency.
- */
- com->state |= CS_ODEVREADY;
-#ifdef SOFT_CTS_OFLOW
- com->state &= ~CS_CTS_OFLOW;
- if (cflag & CCTS_OFLOW) {
- com->state |= CS_CTS_OFLOW;
- if (!(com->last_modem_status & MSR_CTS))
- com->state &= ~CS_ODEVREADY;
- }
-#endif
- /* XXX shouldn't call functions while intrs are disabled. */
- disc_optim(tp, t, com);
-#if 0
- /*
- * Recover from fiddling with CS_TTGO. We used to call siointr1()
- * unconditionally, but that defeated the careful discarding of
- * stale input in sioopen().
- */
- if (com->state >= (CS_BUSY | CS_TTGO))
- siointr1(com);
-#endif
- if (com->state >= (CS_BUSY | CS_TTGO | CS_ODEVREADY)) {
- if (!(com->intr_enable & CD1400_SRER_TXRDY))
- cd_setreg(com, CD1400_SRER,
- com->intr_enable
- = (com->intr_enable & ~CD1400_SRER_TXMPTY)
- | CD1400_SRER_TXRDY);
- } else {
- if (com->intr_enable & CD1400_SRER_TXRDY)
- cd_setreg(com, CD1400_SRER,
- com->intr_enable
- = (com->intr_enable & ~CD1400_SRER_TXRDY)
- | CD1400_SRER_TXMPTY);
- }
-
- enable_intr();
- splx(s);
- comstart(tp);
- if (com->ibufold != NULL) {
- free(com->ibufold, M_DEVBUF);
- com->ibufold = NULL;
- }
- return (0);
-}
-
-static int
-siosetwater(com, speed)
- struct com_s *com;
- speed_t speed;
-{
- int cp4ticks;
- u_char *ibuf;
- int ibufsize;
- struct tty *tp;
-
- /*
- * Make the buffer size large enough to handle a softtty interrupt
- * latency of about 2 ticks without loss of throughput or data
- * (about 3 ticks if input flow control is not used or not honoured,
- * but a bit less for CS5-CS7 modes).
- */
- cp4ticks = speed / 10 / hz * 4;
- for (ibufsize = 128; ibufsize < cp4ticks;)
- ibufsize <<= 1;
- if (ibufsize == com->ibufsize) {
- disable_intr();
- return (0);
- }
-
- /*
- * Allocate input buffer. The extra factor of 2 in the size is
- * to allow for an error byte for each input byte.
- */
- ibuf = malloc(2 * ibufsize, M_DEVBUF, M_NOWAIT);
- if (ibuf == NULL) {
- disable_intr();
- return (ENOMEM);
- }
-
- /* Initialize non-critical variables. */
- com->ibufold = com->ibuf;
- com->ibufsize = ibufsize;
- tp = com->tp;
- if (tp != NULL) {
- tp->t_ififosize = 2 * ibufsize;
- tp->t_ispeedwat = (speed_t)-1;
- tp->t_ospeedwat = (speed_t)-1;
- }
-
- /*
- * Read current input buffer, if any. Continue with interrupts
- * disabled.
- */
- disable_intr();
- if (com->iptr != com->ibuf)
- sioinput(com);
-
- /*-
- * Initialize critical variables, including input buffer watermarks.
- * The external device is asked to stop sending when the buffer
- * exactly reaches high water, or when the high level requests it.
- * The high level is notified immediately (rather than at a later
- * clock tick) when this watermark is reached.
- * The buffer size is chosen so the watermark should almost never
- * be reached.
- * The low watermark is invisibly 0 since the buffer is always
- * emptied all at once.
- */
- com->iptr = com->ibuf = ibuf;
- com->ibufend = ibuf + ibufsize;
- com->ierroff = ibufsize;
- com->ihighwater = ibuf + 3 * ibufsize / 4;
- return (0);
-}
-
-static void
-comstart(tp)
- struct tty *tp;
-{
- struct com_s *com;
- int s;
-#ifdef CyDebug
- bool_t started;
-#endif
- int unit;
-
- unit = DEV_TO_UNIT(tp->t_dev);
- com = com_addr(unit);
- s = spltty();
-
-#ifdef CyDebug
- ++com->start_count;
- started = FALSE;
-#endif
-
- disable_intr();
- if (tp->t_state & TS_TTSTOP) {
- com->state &= ~CS_TTGO;
- if (com->intr_enable & CD1400_SRER_TXRDY)
- cd_setreg(com, CD1400_SRER,
- com->intr_enable
- = (com->intr_enable & ~CD1400_SRER_TXRDY)
- | CD1400_SRER_TXMPTY);
- } else {
- com->state |= CS_TTGO;
- if (com->state >= (CS_BUSY | CS_TTGO | CS_ODEVREADY)
- && !(com->intr_enable & CD1400_SRER_TXRDY))
- cd_setreg(com, CD1400_SRER,
- com->intr_enable
- = (com->intr_enable & ~CD1400_SRER_TXMPTY)
- | CD1400_SRER_TXRDY);
- }
- if (tp->t_state & TS_TBLOCK) {
- if (com->mcr_image & com->mcr_rts && com->state & CS_RTS_IFLOW)
-#if 0
- outb(com->modem_ctl_port, com->mcr_image &= ~MCR_RTS);
-#else
- cd_setreg(com, com->mcr_rts_reg,
- com->mcr_image &= ~com->mcr_rts);
-#endif
- } else {
- if (!(com->mcr_image & com->mcr_rts)
- && com->iptr < com->ihighwater
- && com->state & CS_RTS_IFLOW)
-#if 0
- outb(com->modem_ctl_port, com->mcr_image |= MCR_RTS);
-#else
- cd_setreg(com, com->mcr_rts_reg,
- com->mcr_image |= com->mcr_rts);
-#endif
- }
- enable_intr();
- if (tp->t_state & (TS_TIMEOUT | TS_TTSTOP)) {
- ttwwakeup(tp);
- splx(s);
- return;
- }
- if (tp->t_outq.c_cc != 0) {
- struct lbq *qp;
- struct lbq *next;
-
- if (!com->obufs[0].l_queued) {
-#ifdef CyDebug
- started = TRUE;
-#endif
- com->obufs[0].l_tail
- = com->obuf1 + q_to_b(&tp->t_outq, com->obuf1,
- sizeof com->obuf1);
- com->obufs[0].l_next = NULL;
- com->obufs[0].l_queued = TRUE;
- disable_intr();
- if (com->state & CS_BUSY) {
- qp = com->obufq.l_next;
- while ((next = qp->l_next) != NULL)
- qp = next;
- qp->l_next = &com->obufs[0];
- } else {
- com->obufq.l_head = com->obufs[0].l_head;
- com->obufq.l_tail = com->obufs[0].l_tail;
- com->obufq.l_next = &com->obufs[0];
- com->state |= CS_BUSY;
- if (com->state >= (CS_BUSY | CS_TTGO
- | CS_ODEVREADY))
- cd_setreg(com, CD1400_SRER,
- com->intr_enable
- = (com->intr_enable
- & ~CD1400_SRER_TXMPTY)
- | CD1400_SRER_TXRDY);
- }
- enable_intr();
- }
- if (tp->t_outq.c_cc != 0 && !com->obufs[1].l_queued) {
-#ifdef CyDebug
- started = TRUE;
-#endif
- com->obufs[1].l_tail
- = com->obuf2 + q_to_b(&tp->t_outq, com->obuf2,
- sizeof com->obuf2);
- com->obufs[1].l_next = NULL;
- com->obufs[1].l_queued = TRUE;
- disable_intr();
- if (com->state & CS_BUSY) {
- qp = com->obufq.l_next;
- while ((next = qp->l_next) != NULL)
- qp = next;
- qp->l_next = &com->obufs[1];
- } else {
- com->obufq.l_head = com->obufs[1].l_head;
- com->obufq.l_tail = com->obufs[1].l_tail;
- com->obufq.l_next = &com->obufs[1];
- com->state |= CS_BUSY;
- if (com->state >= (CS_BUSY | CS_TTGO
- | CS_ODEVREADY))
- cd_setreg(com, CD1400_SRER,
- com->intr_enable
- = (com->intr_enable
- & ~CD1400_SRER_TXMPTY)
- | CD1400_SRER_TXRDY);
- }
- enable_intr();
- }
- tp->t_state |= TS_BUSY;
- }
-#ifdef CyDebug
- if (started)
- ++com->start_real;
-#endif
-#if 0
- disable_intr();
- if (com->state >= (CS_BUSY | CS_TTGO))
- siointr1(com); /* fake interrupt to start output */
- enable_intr();
-#endif
- ttwwakeup(tp);
- splx(s);
-}
-
-static void
-comstop(tp, rw)
- struct tty *tp;
- int rw;
-{
- struct com_s *com;
- bool_t wakeup_etc;
-
- com = com_addr(DEV_TO_UNIT(tp->t_dev));
- wakeup_etc = FALSE;
- disable_intr();
- if (rw & FWRITE) {
- com->obufs[0].l_queued = FALSE;
- com->obufs[1].l_queued = FALSE;
- if (com->extra_state & CSE_ODONE) {
- com_events -= LOTS_OF_EVENTS;
- com->extra_state &= ~CSE_ODONE;
- if (com->etc != ETC_NONE) {
- if (com->etc == ETC_BREAK_ENDED)
- com->etc = ETC_NONE;
- wakeup_etc = TRUE;
- }
- }
- com->tp->t_state &= ~TS_BUSY;
- if (com->state & CS_ODONE)
- com_events -= LOTS_OF_EVENTS;
- com->state &= ~(CS_ODONE | CS_BUSY);
- }
- if (rw & FREAD) {
- /* XXX no way to reset only input fifo. */
- com_events -= (com->iptr - com->ibuf);
- com->iptr = com->ibuf;
- }
- enable_intr();
- if (wakeup_etc)
- wakeup(&com->etc);
- if (rw & FWRITE && com->etc == ETC_NONE)
- cd1400_channel_cmd(com, CD1400_CCR_CMDRESET | CD1400_CCR_FTF);
- comstart(tp);
-}
-
-static int
-commctl(com, bits, how)
- struct com_s *com;
- int bits;
- int how;
-{
- int mcr;
- int msr;
-
- if (how == DMGET) {
- if (com->channel_control & CD1400_CCR_RCVEN)
- bits |= TIOCM_LE;
- mcr = com->mcr_image;
- if (mcr & com->mcr_dtr)
- bits |= TIOCM_DTR;
- if (mcr & com->mcr_rts)
- /* XXX wired on for Cyclom-8Ys */
- bits |= TIOCM_RTS;
-
- /*
- * We must read the modem status from the hardware because
- * we don't generate modem status change interrupts for all
- * changes, so com->prev_modem_status is not guaranteed to
- * be up to date. This is safe, unlike for sio, because
- * reading the status register doesn't clear pending modem
- * status change interrupts.
- */
- msr = cd_getreg(com, CD1400_MSVR2);
-
- if (msr & MSR_CTS)
- bits |= TIOCM_CTS;
- if (msr & MSR_DCD)
- bits |= TIOCM_CD;
- if (msr & MSR_DSR)
- bits |= TIOCM_DSR;
- if (msr & MSR_RI)
- /* XXX not connected except for Cyclom-16Y? */
- bits |= TIOCM_RI;
- return (bits);
- }
- mcr = 0;
- if (bits & TIOCM_DTR)
- mcr |= com->mcr_dtr;
- if (bits & TIOCM_RTS)
- mcr |= com->mcr_rts;
- disable_intr();
- switch (how) {
- case DMSET:
- com->mcr_image = mcr;
- cd_setreg(com, CD1400_MSVR1, mcr);
- cd_setreg(com, CD1400_MSVR2, mcr);
- break;
- case DMBIS:
- com->mcr_image = mcr = com->mcr_image | mcr;
- cd_setreg(com, CD1400_MSVR1, mcr);
- cd_setreg(com, CD1400_MSVR2, mcr);
- break;
- case DMBIC:
- com->mcr_image = mcr = com->mcr_image & ~mcr;
- cd_setreg(com, CD1400_MSVR1, mcr);
- cd_setreg(com, CD1400_MSVR2, mcr);
- break;
- }
- enable_intr();
- return (0);
-}
-
-static void
-siosettimeout()
-{
- struct com_s *com;
- bool_t someopen;
- int unit;
-
- /*
- * Set our timeout period to 1 second if no polled devices are open.
- * Otherwise set it to max(1/200, 1/hz).
- * Enable timeouts iff some device is open.
- */
- untimeout(comwakeup, (void *)NULL, sio_timeout_handle);
- sio_timeout = hz;
- someopen = FALSE;
- for (unit = 0; unit < NSIO; ++unit) {
- com = com_addr(unit);
- if (com != NULL && com->tp != NULL
- && com->tp->t_state & TS_ISOPEN) {
- someopen = TRUE;
-#if 0
- if (com->poll || com->poll_output) {
- sio_timeout = hz > 200 ? hz / 200 : 1;
- break;
- }
-#endif
- }
- }
- if (someopen) {
- sio_timeouts_until_log = hz / sio_timeout;
- sio_timeout_handle = timeout(comwakeup, (void *)NULL,
- sio_timeout);
- } else {
- /* Flush error messages, if any. */
- sio_timeouts_until_log = 1;
- comwakeup((void *)NULL);
- untimeout(comwakeup, (void *)NULL, sio_timeout_handle);
- }
-}
-
-static void
-comwakeup(chan)
- void *chan;
-{
- struct com_s *com;
- int unit;
-
- sio_timeout_handle = timeout(comwakeup, (void *)NULL, sio_timeout);
-
-#if 0
- /*
- * Recover from lost output interrupts.
- * Poll any lines that don't use interrupts.
- */
- for (unit = 0; unit < NSIO; ++unit) {
- com = com_addr(unit);
- if (com != NULL
- && (com->state >= (CS_BUSY | CS_TTGO) || com->poll)) {
- disable_intr();
- siointr1(com);
- enable_intr();
- }
- }
-#endif
-
- /*
- * Check for and log errors, but not too often.
- */
- if (--sio_timeouts_until_log > 0)
- return;
- sio_timeouts_until_log = hz / sio_timeout;
- for (unit = 0; unit < NSIO; ++unit) {
- int errnum;
-
- com = com_addr(unit);
- if (com == NULL)
- continue;
- for (errnum = 0; errnum < CE_NTYPES; ++errnum) {
- u_int delta;
- u_long total;
-
- disable_intr();
- delta = com->delta_error_counts[errnum];
- com->delta_error_counts[errnum] = 0;
- enable_intr();
- if (delta == 0)
- continue;
- total = com->error_counts[errnum] += delta;
- log(LOG_ERR, "cy%d: %u more %s%s (total %lu)\n",
- unit, delta, error_desc[errnum],
- delta == 1 ? "" : "s", total);
- }
- }
-}
-
-static void
-disc_optim(tp, t, com)
- struct tty *tp;
- struct termios *t;
- struct com_s *com;
-{
-#ifndef SOFT_HOTCHAR
- u_char opt;
-#endif
-
- /*
- * XXX can skip a lot more cases if Smarts. Maybe
- * (IGNCR | ISTRIP | IXON) in c_iflag. But perhaps we
- * shouldn't skip if (TS_CNTTB | TS_LNCH) is set in t_state.
- */
- if (!(t->c_iflag & (ICRNL | IGNCR | IMAXBEL | INLCR | ISTRIP | IXON))
- && (!(t->c_iflag & BRKINT) || (t->c_iflag & IGNBRK))
- && (!(t->c_iflag & PARMRK)
- || (t->c_iflag & (IGNPAR | IGNBRK)) == (IGNPAR | IGNBRK))
- && !(t->c_lflag & (ECHO | ICANON | IEXTEN | ISIG | PENDIN))
- && linesw[tp->t_line].l_rint == ttyinput)
- tp->t_state |= TS_CAN_BYPASS_L_RINT;
- else
- tp->t_state &= ~TS_CAN_BYPASS_L_RINT;
- com->hotchar = linesw[tp->t_line].l_hotchar;
-#ifndef SOFT_HOTCHAR
- opt = com->cor[2] & ~CD1400_COR3_SCD34;
- if (com->hotchar != 0) {
- cd_setreg(com, CD1400_SCHR3, com->hotchar);
- cd_setreg(com, CD1400_SCHR4, com->hotchar);
- opt |= CD1400_COR3_SCD34;
- }
- if (opt != com->cor[2]) {
- cd_setreg(com, CD1400_COR3, com->cor[2] = opt);
- cd1400_channel_cmd(com, CD1400_CCR_CMDCORCHG | CD1400_CCR_COR3);
- }
-#endif
-}
-
-#ifdef Smarts
-/* standard line discipline input routine */
-int
-cyinput(c, tp)
- int c;
- struct tty *tp;
-{
- /* XXX duplicate ttyinput(), but without the IXOFF/IXON/ISTRIP/IPARMRK
- * bits, as they are done by the CD1400. Hardly worth the effort,
- * given that high-throughput sessions are raw anyhow.
- */
-}
-#endif /* Smarts */
-
-static int
-comspeed(speed, cy_clock, prescaler_io)
- speed_t speed;
- u_long cy_clock;
- int *prescaler_io;
-{
- int actual;
- int error;
- int divider;
- int prescaler;
- int prescaler_unit;
-
- if (speed == 0)
- return (0);
- if (speed < 0 || speed > 150000)
- return (-1);
-
- /* determine which prescaler to use */
- for (prescaler_unit = 4, prescaler = 2048; prescaler_unit;
- prescaler_unit--, prescaler >>= 2) {
- if (cy_clock / prescaler / speed > 63)
- break;
- }
-
- divider = (cy_clock / prescaler * 2 / speed + 1) / 2; /* round off */
- if (divider > 255)
- divider = 255;
- actual = cy_clock/prescaler/divider;
-
- /* 10 times error in percent: */
- error = ((actual - (long)speed) * 2000 / (long)speed + 1) / 2;
-
- /* 3.0% max error tolerance */
- if (error < -30 || error > 30)
- return (-1);
-
-#if 0
- printf("prescaler = %d (%d)\n", prescaler, prescaler_unit);
- printf("divider = %d (%x)\n", divider, divider);
- printf("actual = %d\n", actual);
- printf("error = %d\n", error);
-#endif
-
- *prescaler_io = prescaler_unit;
- return (divider);
-}
-
-static void
-cd1400_channel_cmd(com, cmd)
- struct com_s *com;
- int cmd;
-{
- cd1400_channel_cmd_wait(com);
- cd_setreg(com, CD1400_CCR, cmd);
- cd1400_channel_cmd_wait(com);
-}
-
-static void
-cd1400_channel_cmd_wait(com)
- struct com_s *com;
-{
- struct timeval start;
- struct timeval tv;
- long usec;
-
- if (cd_getreg(com, CD1400_CCR) == 0)
- return;
- microtime(&start);
- for (;;) {
- if (cd_getreg(com, CD1400_CCR) == 0)
- return;
- microtime(&tv);
- usec = 1000000 * (tv.tv_sec - start.tv_sec) +
- tv.tv_usec - start.tv_usec;
- if (usec >= 5000) {
- log(LOG_ERR,
- "cy%d: channel command timeout (%ld usec)\n",
- com->unit, usec);
- return;
- }
- }
-}
-
-static void
-cd_etc(com, etc)
- struct com_s *com;
- int etc;
-{
- /*
- * We can't change the hardware's ETC state while there are any
- * characters in the tx fifo, since those characters would be
- * interpreted as commands! Unputting characters from the fifo
- * is difficult, so we wait up to 12 character times for the fifo
- * to drain. The command will be delayed for up to 2 character
- * times for the tx to become empty. Unputting characters from
- * the tx holding and shift registers is impossible, so we wait
- * for the tx to become empty so that the command is sure to be
- * executed soon after we issue it.
- */
- disable_intr();
- if (com->etc == etc) {
- enable_intr();
- goto wait;
- }
- if ((etc == CD1400_ETC_SENDBREAK
- && (com->etc == ETC_BREAK_STARTING
- || com->etc == ETC_BREAK_STARTED))
- || (etc == CD1400_ETC_STOPBREAK
- && (com->etc == ETC_BREAK_ENDING || com->etc == ETC_BREAK_ENDED
- || com->etc == ETC_NONE))) {
- enable_intr();
- return;
- }
- com->etc = etc;
- cd_setreg(com, CD1400_SRER,
- com->intr_enable
- = (com->intr_enable & ~CD1400_SRER_TXRDY) | CD1400_SRER_TXMPTY);
- enable_intr();
-wait:
- while (com->etc == etc
- && tsleep(&com->etc, TTIPRI | PCATCH, "cyetc", 0) == 0)
- continue;
-}
-
-static int
-cd_getreg(com, reg)
- struct com_s *com;
- int reg;
-{
- struct com_s *basecom;
- u_char car;
- int cy_align;
- u_long ef;
- cy_addr iobase;
- int val;
-
- basecom = com_addr(com->unit & ~(CD1400_NO_OF_CHANNELS - 1));
- car = com->unit & CD1400_CAR_CHAN;
- cy_align = com->cy_align;
- iobase = com->iobase;
- ef = read_eflags();
- if (ef & PSL_I)
- disable_intr();
- if (basecom->car != car)
- cd_outb(iobase, CD1400_CAR, cy_align, basecom->car = car);
- val = cd_inb(iobase, reg, cy_align);
- if (ef & PSL_I)
- enable_intr();
- return (val);
-}
-
-static void
-cd_setreg(com, reg, val)
- struct com_s *com;
- int reg;
- int val;
-{
- struct com_s *basecom;
- u_char car;
- int cy_align;
- u_long ef;
- cy_addr iobase;
-
- basecom = com_addr(com->unit & ~(CD1400_NO_OF_CHANNELS - 1));
- car = com->unit & CD1400_CAR_CHAN;
- cy_align = com->cy_align;
- iobase = com->iobase;
- ef = read_eflags();
- if (ef & PSL_I)
- disable_intr();
- if (basecom->car != car)
- cd_outb(iobase, CD1400_CAR, cy_align, basecom->car = car);
- cd_outb(iobase, reg, cy_align, val);
- if (ef & PSL_I)
- enable_intr();
-}
-
-#ifdef CyDebug
-/* useful in ddb */
-void
-cystatus(unit)
- int unit;
-{
- struct com_s *com;
- cy_addr iobase;
- u_int ocount;
- struct tty *tp;
-
- com = com_addr(unit);
- printf("info for channel %d\n", unit);
- printf("------------------\n");
- printf("total cyclom service probes:\t%d\n", cy_svrr_probes);
- printf("calls to upper layer:\t\t%d\n", cy_timeouts);
- if (com == NULL)
- return;
- iobase = com->iobase;
- printf("\n");
- printf("cd1400 base address:\\tt%p\n", iobase);
- printf("saved channel_control:\t\t0x%02x\n", com->channel_control);
- printf("saved cor1-3:\t\t\t0x%02x 0x%02x 0x%02x\n",
- com->cor[0], com->cor[1], com->cor[2]);
- printf("service request enable reg:\t0x%02x (0x%02x cached)\n",
- cd_getreg(com, CD1400_SRER), com->intr_enable);
- printf("service request register:\t0x%02x\n",
- cd_inb(iobase, CD1400_SVRR, com->cy_align));
- printf("modem status:\t\t\t0x%02x (0x%02x cached)\n",
- cd_getreg(com, CD1400_MSVR2), com->prev_modem_status);
- printf("rx/tx/mdm interrupt registers:\t0x%02x 0x%02x 0x%02x\n",
- cd_inb(iobase, CD1400_RIR, com->cy_align),
- cd_inb(iobase, CD1400_TIR, com->cy_align),
- cd_inb(iobase, CD1400_MIR, com->cy_align));
- printf("\n");
- printf("com state:\t\t\t0x%02x\n", com->state);
- printf("calls to comstart():\t\t%d (%d useful)\n",
- com->start_count, com->start_real);
- printf("rx buffer chars free:\t\t%d\n", com->iptr - com->ibuf);
- ocount = 0;
- if (com->obufs[0].l_queued)
- ocount += com->obufs[0].l_tail - com->obufs[0].l_head;
- if (com->obufs[1].l_queued)
- ocount += com->obufs[1].l_tail - com->obufs[1].l_head;
- printf("tx buffer chars:\t\t%u\n", ocount);
- printf("received chars:\t\t\t%d\n", com->bytes_in);
- printf("received exceptions:\t\t%d\n", com->recv_exception);
- printf("modem signal deltas:\t\t%d\n", com->mdm);
- printf("transmitted chars:\t\t%d\n", com->bytes_out);
- printf("\n");
- tp = com->tp;
- if (tp != NULL) {
- printf("tty state:\t\t\t0x%08x\n", tp->t_state);
- printf(
- "upper layer queue lengths:\t%d raw, %d canon, %d output\n",
- tp->t_rawq.c_cc, tp->t_canq.c_cc, tp->t_outq.c_cc);
- } else
- printf("tty state:\t\t\tclosed\n");
-}
-#endif /* CyDebug */
diff --git a/sys/dev/cy/cy_pci.c b/sys/dev/cy/cy_pci.c
deleted file mode 100644
index 71e16953af7a..000000000000
--- a/sys/dev/cy/cy_pci.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright (c) 1996, David Greenman
- * 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 unmodified, 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Cyclades Y PCI serial interface driver
- */
-
-#include "opt_cy_pci_fastintr.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <vm/vm.h>
-#include <vm/pmap.h>
-
-#include <pci/pcivar.h>
-
-#include <pci/cy_pcireg.h>
-
-#ifdef CY_PCI_FASTINTR
-#include <i386/isa/intr_machdep.h>
-#endif
-
-static const char *cy_probe __P((pcici_t, pcidi_t));
-static void cy_attach __P((pcici_t, int));
-
-extern int cyattach_common(void *, int); /* Not exactly correct */
-extern void cyintr(int);
-
-static u_long cy_count;
-
-static struct pci_device cy_device = {
- "cy",
- cy_probe,
- cy_attach,
- &cy_count,
- NULL
-};
-COMPAT_PCI_DRIVER(cy_pci, cy_device);
-
-static const char *
-cy_probe(config_id, device_id)
- pcici_t config_id;
- pcidi_t device_id;
-{
- device_id &= ~0x00060000;
- if (device_id == 0x0100120e || device_id == 0x0101120e)
- return ("Cyclades Cyclom-Y Serial Adapter");
- return (NULL);
-}
-
-static void
-cy_attach(config_id, unit)
- pcici_t config_id;
- int unit;
-{
- vm_offset_t paddr;
- void *vaddr;
- u_int32_t ioport;
- int adapter;
- u_char plx_ver;
-
- ioport = (u_int32_t) pci_conf_read(config_id, CY_PCI_BASE_ADDR1) & ~0x3;
- paddr = pci_conf_read(config_id, CY_PCI_BASE_ADDR2) & ~0xf;
-#if 0
- if (!pci_map_mem(config_id, CY_PCI_BASE_ADDR2, &vaddr, &paddr)) {
- printf("cy%d: couldn't map shared memory\n", unit);
- return;
- };
-#endif
- vaddr = pmap_mapdev(paddr, 0x4000);
-
- adapter = cyattach_common(vaddr, 1);
- if (adapter < 0) {
- /*
- * No ports found. Release resources and punt.
- */
- printf("cy%d: no ports found!\n", unit);
- goto fail;
- }
-
- /*
- * Allocate our interrupt.
- * XXX Using the ISA interrupt handler directly is a bit of a violation
- * since it doesn't actually take the same argument. For PCI, the
- * argument is a void * token, but for ISA it is a unit. Since
- * there is no overlap in PCI/ISA unit numbers for this driver, and
- * since the ISA driver must handle the interrupt anyway, we use
- * the unit number as the token even for PCI.
- */
- if (
-#ifdef CY_PCI_FASTINTR
- !pci_map_int_right(config_id, (pci_inthand_t *)cyintr,
- (void *)adapter, &tty_imask,
- INTR_EXCL | INTR_FAST) &&
-#endif
- !pci_map_int_right(config_id, (pci_inthand_t *)cyintr,
- (void *)adapter, &tty_imask, 0)) {
- printf("cy%d: couldn't map interrupt\n", unit);
- goto fail;
- }
-
- /*
- * Enable the "local" interrupt input to generate a
- * PCI interrupt.
- */
- plx_ver = *((u_char *)vaddr + PLX_VER) & 0x0f;
- switch (plx_ver) {
- case PLX_9050:
- outw(ioport + CY_PLX_9050_ICS,
- inw(ioport + CY_PLX_9050_ICS) | CY_PLX_9050_ICS_IENABLE |
- CY_PLX_9050_ICS_LOCAL_IENABLE);
- break;
- case PLX_9060:
- case PLX_9080:
- default: /* Old board, use PLX_9060 values. */
- outw(ioport + CY_PLX_9060_ICS,
- inw(ioport + CY_PLX_9060_ICS) | CY_PLX_9060_ICS_IENABLE |
- CY_PLX_9060_ICS_LOCAL_IENABLE);
- break;
- }
-
- return;
-
-fail:
- /* XXX should release any allocated virtual memory */
- return;
-}
diff --git a/sys/dev/cy/cyreg.h b/sys/dev/cy/cyreg.h
deleted file mode 100644
index 88a36eb4a65e..000000000000
--- a/sys/dev/cy/cyreg.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*-
- * Copyright (c) 1995 Bruce Evans.
- * 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 author nor the names of contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Definitions for Cyclades Cyclom-Y serial boards.
- */
-
-/*
- * Cyclades register offsets. These are physical offsets for ISA boards
- * and physical offsets divided by 2 for PCI boards.
- */
-#define CY8_SVCACKR 0x100 /* (r) */
-#define CY8_SVCACKT 0x200 /* (r) */
-#define CY8_SVCACKM 0x300 /* (r) */
-#define CY16_RESET 0x1400 /* (r) */
-#define CY_CLEAR_INTR 0x1800 /* intr ack address (w) */
-
-#define CY_MAX_CD1400s 8 /* for Cyclom-32Y */
-
-#define CY_CLOCK(version) ((version) >= 0x48 ? 60000000 : 25000000)
-#define CY_RTS_DTR_SWAPPED(version) ((version) >= 0x48)
-
-/*
- * The `cd' macros are for access to cd1400 registers. The `cy' macros
- * are for access to Cyclades registers. Both sets of macros scale the
- * register number to get an offset, but the scales are different for
- * mostly historical reasons.
- */
-#ifdef CyDebug
-#define cd_inb(iobase, reg, cy_align) \
- (++cd_inbs, *((iobase) + (2 * (reg) << (cy_align))))
-#define cy_inb(iobase, reg, cy_align) \
- (++cy_inbs, *((iobase) + ((reg) << (cy_align))))
-#define cd_outb(iobase, reg, cy_align, val) \
- (++cd_outbs, (void)(*((iobase) + (2 * (reg) << (cy_align))) = (val)))
-#define cy_outb(iobase, reg, cy_align, val) \
- (++cy_outbs, (void)(*((iobase) + ((reg) << (cy_align))) = (val)))
-#else
-#define cd_inb(iobase, reg, cy_align) \
- (*((iobase) + (2 * (reg) << (cy_align))))
-#define cy_inb(iobase, reg, cy_align) \
- (*((iobase) + ((reg) << (cy_align))))
-#define cd_outb(iobase, reg, cy_align, val) \
- ((void)(*((iobase) + (2 * (reg) << (cy_align))) = (val)))
-#define cy_outb(iobase, reg, cy_align, val) \
- ((void)(*((iobase) + ((reg) << (cy_align))) = (val)))
-#endif
diff --git a/sys/dev/dc/dcphy.c b/sys/dev/dc/dcphy.c
deleted file mode 100644
index 8576d84f8db5..000000000000
--- a/sys/dev/dc/dcphy.c
+++ /dev/null
@@ -1,541 +0,0 @@
-/*
- * Copyright (c) 1997, 1998, 1999
- * Bill Paul <wpaul@ee.columbia.edu>. 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 Bill Paul.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY Bill Paul 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 Bill Paul OR THE VOICES IN HIS HEAD
- * 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Pseudo-driver for internal NWAY support on DEC 21143 and workalike
- * controllers. Technically we're abusing the miibus code to handle
- * media selection and NWAY support here since there is no MII
- * interface. However the logical operations are roughly the same,
- * and the alternative is to create a fake MII interface in the driver,
- * which is harder to do.
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/malloc.h>
-#include <sys/socket.h>
-#include <sys/errno.h>
-#include <sys/module.h>
-#include <sys/bus.h>
-
-#include <net/if.h>
-#include <net/if_arp.h>
-#include <net/if_media.h>
-
-#include <dev/mii/mii.h>
-#include <dev/mii/miivar.h>
-#include <dev/mii/miidevs.h>
-
-#include <machine/clock.h>
-#include <machine/bus_pio.h>
-#include <machine/bus_memio.h>
-#include <machine/bus.h>
-#include <machine/resource.h>
-#include <sys/bus.h>
-
-#include <pci/pcivar.h>
-
-#include <pci/if_dcreg.h>
-
-#include "miibus_if.h"
-
-#if !defined(lint)
-static const char rcsid[] =
- "$FreeBSD$";
-#endif
-
-#define DC_SETBIT(sc, reg, x) \
- CSR_WRITE_4(sc, reg, \
- CSR_READ_4(sc, reg) | x)
-
-#define DC_CLRBIT(sc, reg, x) \
- CSR_WRITE_4(sc, reg, \
- CSR_READ_4(sc, reg) & ~x)
-
-#define MIIF_AUTOTIMEOUT 0x0004
-
-/*
- * This is the subsystem ID for the built-in 21143 ethernet
- * in several Compaq Presario systems. Apparently these are
- * 10Mbps only, so we need to treat them specially.
- */
-#define COMPAQ_PRESARIO_ID 0xb0bb0e11
-
-static int dcphy_probe __P((device_t));
-static int dcphy_attach __P((device_t));
-static int dcphy_detach __P((device_t));
-
-static device_method_t dcphy_methods[] = {
- /* device interface */
- DEVMETHOD(device_probe, dcphy_probe),
- DEVMETHOD(device_attach, dcphy_attach),
- DEVMETHOD(device_detach, dcphy_detach),
- DEVMETHOD(device_shutdown, bus_generic_shutdown),
- { 0, 0 }
-};
-
-static devclass_t dcphy_devclass;
-
-static driver_t dcphy_driver = {
- "dcphy",
- dcphy_methods,
- sizeof(struct mii_softc)
-};
-
-DRIVER_MODULE(dcphy, miibus, dcphy_driver, dcphy_devclass, 0, 0);
-
-int dcphy_service __P((struct mii_softc *, struct mii_data *, int));
-void dcphy_status __P((struct mii_softc *));
-static int dcphy_auto __P((struct mii_softc *, int));
-static void dcphy_reset __P((struct mii_softc *));
-
-static int dcphy_probe(dev)
- device_t dev;
-{
- struct mii_attach_args *ma;
-
- ma = device_get_ivars(dev);
-
- /*
- * The dc driver will report the 21143 vendor and device
- * ID to let us know that it wants us to attach.
- */
- if (ma->mii_id1 != DC_VENDORID_DEC ||
- ma->mii_id2 != DC_DEVICEID_21143)
- return(ENXIO);
-
- device_set_desc(dev, "Intel 21143 NWAY media interface");
-
- return (0);
-}
-
-static int dcphy_attach(dev)
- device_t dev;
-{
- struct mii_softc *sc;
- struct mii_attach_args *ma;
- struct mii_data *mii;
- struct dc_softc *dc_sc;
-
- sc = device_get_softc(dev);
- ma = device_get_ivars(dev);
- sc->mii_dev = device_get_parent(dev);
- mii = device_get_softc(sc->mii_dev);
- LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
-
- sc->mii_inst = mii->mii_instance;
- sc->mii_phy = ma->mii_phyno;
- sc->mii_service = dcphy_service;
- sc->mii_pdata = mii;
-
- sc->mii_flags |= MIIF_NOISOLATE;
- mii->mii_instance++;
-
-#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL)
-
- ADD(IFM_MAKEWORD(IFM_ETHER, IFM_NONE, 0, sc->mii_inst),
- BMCR_ISO);
-
- /*dcphy_reset(sc);*/
- dc_sc = mii->mii_ifp->if_softc;
- CSR_WRITE_4(dc_sc, DC_10BTSTAT, 0);
- CSR_WRITE_4(dc_sc, DC_10BTCTRL, 0);
-
- switch(pci_read_config(device_get_parent(sc->mii_dev),
- DC_PCI_CSID, 4)) {
- case COMPAQ_PRESARIO_ID:
- /* Example of how to only allow 10Mbps modes. */
- sc->mii_capabilities = BMSR_ANEG|BMSR_10TFDX|BMSR_10THDX;
- break;
- default:
- ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP,
- sc->mii_inst), BMCR_LOOP|BMCR_S100);
-
- sc->mii_capabilities =
- BMSR_ANEG|BMSR_100TXFDX|BMSR_100TXHDX|
- BMSR_10TFDX|BMSR_10THDX;
- break;
- }
-
- sc->mii_capabilities &= ma->mii_capmask;
- device_printf(dev, " ");
- if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0)
- printf("no media present");
- else
- mii_add_media(mii, sc->mii_capabilities, sc->mii_inst);
- printf("\n");
-#undef ADD
-
- MIIBUS_MEDIAINIT(sc->mii_dev);
- return(0);
-}
-
-static int dcphy_detach(dev)
- device_t dev;
-{
- struct mii_softc *sc;
- struct mii_data *mii;
-
- sc = device_get_softc(dev);
- mii = device_get_softc(device_get_parent(dev));
- sc->mii_dev = NULL;
- LIST_REMOVE(sc, mii_list);
-
- return(0);
-}
-
-int
-dcphy_service(sc, mii, cmd)
- struct mii_softc *sc;
- struct mii_data *mii;
- int cmd;
-{
- struct dc_softc *dc_sc;
- struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
- int reg;
- u_int32_t mode;
-
- dc_sc = mii->mii_ifp->if_softc;
-
- switch (cmd) {
- case MII_POLLSTAT:
- /*
- * If we're not polling our PHY instance, just return.
- */
- if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
- return (0);
- }
- break;
-
- case MII_MEDIACHG:
- /*
- * If the media indicates a different PHY instance,
- * isolate ourselves.
- */
- if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
- return (0);
- }
-
- /*
- * If the interface is not up, don't do anything.
- */
- if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
- break;
-
- sc->mii_flags = 0;
- mii->mii_media_active = IFM_NONE;
- mode = CSR_READ_4(dc_sc, DC_NETCFG);
- mode &= ~(DC_NETCFG_FULLDUPLEX|DC_NETCFG_PORTSEL|
- DC_NETCFG_PCS|DC_NETCFG_SCRAMBLER|DC_NETCFG_SPEEDSEL);
-
- switch (IFM_SUBTYPE(ife->ifm_media)) {
- case IFM_AUTO:
- /*dcphy_reset(sc);*/
- (void) dcphy_auto(sc, 0);
- break;
- case IFM_100_T4:
- /*
- * XXX Not supported as a manual setting right now.
- */
- return (EINVAL);
- case IFM_100_TX:
- dcphy_reset(sc);
- DC_CLRBIT(dc_sc, DC_10BTCTRL, DC_TCTL_AUTONEGENBL);
- mode |= DC_NETCFG_PORTSEL|DC_NETCFG_PCS|
- DC_NETCFG_SCRAMBLER;
- if ((ife->ifm_media & IFM_GMASK) == IFM_FDX)
- mode |= DC_NETCFG_FULLDUPLEX;
- else
- mode &= ~DC_NETCFG_FULLDUPLEX;
- CSR_WRITE_4(dc_sc, DC_NETCFG, mode);
- break;
- case IFM_10_T:
- DC_CLRBIT(dc_sc, DC_SIARESET, DC_SIA_RESET);
- DC_CLRBIT(dc_sc, DC_10BTCTRL, 0xFFFF);
- if ((ife->ifm_media & IFM_GMASK) == IFM_FDX)
- DC_SETBIT(dc_sc, DC_10BTCTRL, 0x7F3D);
- else
- DC_SETBIT(dc_sc, DC_10BTCTRL, 0x7F3F);
- DC_SETBIT(dc_sc, DC_SIARESET, DC_SIA_RESET);
- DC_CLRBIT(dc_sc, DC_10BTCTRL, DC_TCTL_AUTONEGENBL);
- mode &= ~DC_NETCFG_PORTSEL;
- mode |= DC_NETCFG_SPEEDSEL;
- if ((ife->ifm_media & IFM_GMASK) == IFM_FDX)
- mode |= DC_NETCFG_FULLDUPLEX;
- else
- mode &= ~DC_NETCFG_FULLDUPLEX;
- CSR_WRITE_4(dc_sc, DC_NETCFG, mode);
- break;
- default:
- return(EINVAL);
- break;
- }
- break;
-
- case MII_TICK:
- /*
- * If we're not currently selected, just return.
- */
- if (IFM_INST(ife->ifm_media) != sc->mii_inst)
- return (0);
-
- /*
- * Only used for autonegotiation.
- */
- if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
- return (0);
-
- /*
- * Is the interface even up?
- */
- if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
- return (0);
-
- if (sc->mii_flags & MIIF_DOINGAUTO) {
- if (++sc->mii_ticks != 5)
- return(0);
- else {
- sc->mii_ticks = 0;
- sc->mii_flags &= ~MIIF_DOINGAUTO;
- sc->mii_flags |= MIIF_AUTOTIMEOUT;
- }
- }
-
- sc->mii_flags &= ~MIIF_DOINGAUTO;
-
- /*
- * Check to see if we have link. If we do, we don't
- * need to restart the autonegotiation process. Read
- * the BMSR twice in case it's latched.
- */
- reg = CSR_READ_4(dc_sc, DC_10BTSTAT) &
- (DC_TSTAT_LS10|DC_TSTAT_LS100);
-
- if (IFM_SUBTYPE(mii->mii_media_active) == IFM_100_TX &&
- !(reg & DC_TSTAT_LS100)) {
- if (sc->mii_flags & MIIF_AUTOTIMEOUT) {
- sc->mii_flags &= ~MIIF_AUTOTIMEOUT;
- break;
- } else
- return(0);
- } else if (IFM_SUBTYPE(mii->mii_media_active) == IFM_10_T &&
- !(reg & DC_TSTAT_LS10)) {
- if (sc->mii_flags & MIIF_AUTOTIMEOUT) {
- sc->mii_flags &= ~MIIF_AUTOTIMEOUT;
- break;
- } else
- return(0);
- } else if (IFM_SUBTYPE(mii->mii_media_active) == IFM_NONE &&
- (!(reg & DC_TSTAT_LS10) || !(reg & DC_TSTAT_LS100))) {
- if (sc->mii_flags & MIIF_AUTOTIMEOUT) {
- sc->mii_flags &= ~MIIF_AUTOTIMEOUT;
- break;
- } else
- return(0);
- } else if (CSR_READ_4(dc_sc, DC_ISR) & DC_ISR_LINKGOOD) {
- if (sc->mii_flags & MIIF_AUTOTIMEOUT) {
- sc->mii_flags &= ~MIIF_AUTOTIMEOUT;
- break;
- } else
- return(0);
- }
-
- sc->mii_ticks = 0;
- /*dcphy_reset(sc);*/
- dcphy_auto(sc, 0);
-
- break;
- }
-
- /* Update the media status. */
- dcphy_status(sc);
-
- /* Callback if something changed. */
- if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) {
- MIIBUS_STATCHG(sc->mii_dev);
- sc->mii_active = mii->mii_media_active;
- }
- return (0);
-}
-
-void
-dcphy_status(sc)
- struct mii_softc *sc;
-{
- struct mii_data *mii = sc->mii_pdata;
- int reg, anlpar;
- struct dc_softc *dc_sc;
-
- dc_sc = mii->mii_ifp->if_softc;
-
- mii->mii_media_status = IFM_AVALID;
- mii->mii_media_active = IFM_ETHER;
-
- reg = CSR_READ_4(dc_sc, DC_10BTSTAT) &
- (DC_TSTAT_LS10|DC_TSTAT_LS100);
-
- if (!(reg & DC_TSTAT_LS10) || !(reg & DC_TSTAT_LS100))
- mii->mii_media_status |= IFM_ACTIVE;
-
- if (sc->mii_flags & MIIF_DOINGAUTO) {
- mii->mii_media_active |= IFM_NONE;
- return;
- }
-
- if (CSR_READ_4(dc_sc, DC_10BTCTRL) & DC_TCTL_AUTONEGENBL &&
- CSR_READ_4(dc_sc, DC_10BTSTAT) & DC_TSTAT_ANEGSTAT) {
- /* Erg, still trying, I guess... */
- if ((CSR_READ_4(dc_sc, DC_10BTSTAT) &
- DC_ASTAT_AUTONEGCMP) != DC_ASTAT_AUTONEGCMP) {
- mii->mii_media_active |= IFM_NONE;
- return;
- }
-
- if (CSR_READ_4(dc_sc, DC_10BTSTAT) & DC_TSTAT_LP_CAN_NWAY) {
- anlpar = CSR_READ_4(dc_sc, DC_10BTSTAT) >> 16;
- if (anlpar & ANLPAR_T4 &&
- sc->mii_capabilities & BMSR_100TXHDX)
- mii->mii_media_active |= IFM_100_T4;
- else if (anlpar & ANLPAR_TX_FD &&
- sc->mii_capabilities & BMSR_100TXHDX)
- mii->mii_media_active |= IFM_100_TX|IFM_FDX;
- else if (anlpar & ANLPAR_TX &&
- sc->mii_capabilities & BMSR_100TXHDX)
- mii->mii_media_active |= IFM_100_TX;
- else if (anlpar & ANLPAR_10_FD)
- mii->mii_media_active |= IFM_10_T|IFM_FDX;
- else if (anlpar & ANLPAR_10)
- mii->mii_media_active |= IFM_10_T;
- else
- mii->mii_media_active |= IFM_NONE;
- if (DC_IS_INTEL(dc_sc))
- DC_CLRBIT(dc_sc, DC_10BTCTRL,
- DC_TCTL_AUTONEGENBL);
- return;
- }
- /*
- * If the other side doesn't support NWAY, then the
- * best we can do is determine if we have a 10Mbps or
- * 100Mbps link. There's no way to know if the link
- * is full or half duplex, so we default to half duplex
- * and hope that the user is clever enough to manually
- * change the media settings if we're wrong.
- */
- if (!(reg & DC_TSTAT_LS100))
- mii->mii_media_active |= IFM_100_TX;
- else if (!(reg & DC_TSTAT_LS10))
- mii->mii_media_active |= IFM_10_T;
- else
- mii->mii_media_active |= IFM_NONE;
- if (DC_IS_INTEL(dc_sc))
- DC_CLRBIT(dc_sc, DC_10BTCTRL, DC_TCTL_AUTONEGENBL);
- return;
- }
-
- if (CSR_READ_4(dc_sc, DC_NETCFG) & DC_NETCFG_SCRAMBLER)
- mii->mii_media_active |= IFM_100_TX;
- else
- mii->mii_media_active |= IFM_10_T;
- if (CSR_READ_4(dc_sc, DC_NETCFG) & DC_NETCFG_FULLDUPLEX)
- mii->mii_media_active |= IFM_FDX;
-
- return;
-}
-
-static int
-dcphy_auto(mii, waitfor)
- struct mii_softc *mii;
- int waitfor;
-{
- int i;
- struct dc_softc *sc;
-
- sc = mii->mii_pdata->mii_ifp->if_softc;
-
- if ((mii->mii_flags & MIIF_DOINGAUTO) == 0) {
- DC_CLRBIT(sc, DC_NETCFG, DC_NETCFG_PORTSEL);
- DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_FULLDUPLEX);
- DC_CLRBIT(sc, DC_SIARESET, DC_SIA_RESET);
- if (mii->mii_capabilities & BMSR_100TXHDX)
- CSR_WRITE_4(sc, DC_10BTCTRL, 0x3FFFF);
- else
- CSR_WRITE_4(sc, DC_10BTCTRL, 0xFFFF);
- DC_SETBIT(sc, DC_SIARESET, DC_SIA_RESET);
- DC_SETBIT(sc, DC_10BTCTRL, DC_TCTL_AUTONEGENBL);
- DC_SETBIT(sc, DC_10BTSTAT, DC_ASTAT_TXDISABLE);
- }
-
- if (waitfor) {
- /* Wait 500ms for it to complete. */
- for (i = 0; i < 500; i++) {
- if ((CSR_READ_4(sc, DC_10BTSTAT) & DC_TSTAT_ANEGSTAT)
- == DC_ASTAT_AUTONEGCMP)
- return(0);
- DELAY(1000);
- }
- /*
- * Don't need to worry about clearing MIIF_DOINGAUTO.
- * If that's set, a timeout is pending, and it will
- * clear the flag.
- */
- return(EIO);
- }
-
- /*
- * Just let it finish asynchronously. This is for the benefit of
- * the tick handler driving autonegotiation. Don't want 500ms
- * delays all the time while the system is running!
- */
- if ((mii->mii_flags & MIIF_DOINGAUTO) == 0)
- mii->mii_flags |= MIIF_DOINGAUTO;
-
- return(EJUSTRETURN);
-}
-
-static void
-dcphy_reset(mii)
- struct mii_softc *mii;
-{
- struct dc_softc *sc;
-
- sc = mii->mii_pdata->mii_ifp->if_softc;
-
- DC_CLRBIT(sc, DC_SIARESET, DC_SIA_RESET);
- DELAY(1000);
- DC_SETBIT(sc, DC_SIARESET, DC_SIA_RESET);
-
- return;
-}
-
diff --git a/sys/dev/dc/if_dc.c b/sys/dev/dc/if_dc.c
deleted file mode 100644
index d25727cefa09..000000000000
--- a/sys/dev/dc/if_dc.c
+++ /dev/null
@@ -1,2937 +0,0 @@
-/*
- * Copyright (c) 1997, 1998, 1999
- * Bill Paul <wpaul@ee.columbia.edu>. 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 Bill Paul.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY Bill Paul 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 Bill Paul OR THE VOICES IN HIS HEAD
- * 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.
- *
- * $FreeBSD$
- */
-
-/*
- * DEC "tulip" clone ethernet driver. Supports the DEC/Intel 21143
- * series chips and several workalikes including the following:
- *
- * Macronix 98713/98715/98725 PMAC (www.macronix.com)
- * Macronix/Lite-On 82c115 PNIC II (www.macronix.com)
- * Lite-On 82c168/82c169 PNIC (www.litecom.com)
- * ASIX Electronics AX88140A (www.asix.com.tw)
- * ASIX Electronics AX88141 (www.asix.com.tw)
- * ADMtek AL981 (www.admtek.com.tw)
- * ADMtek AN985 (www.admtek.com.tw)
- * Davicom DM9100, DM9102, DM9102A (www.davicom8.com)
- *
- * Datasheets for the 21143 are available at developer.intel.com.
- * Datasheets for the clone parts can be found at their respective sites.
- * (Except for the PNIC; see www.freebsd.org/~wpaul/PNIC/pnic.ps.gz.)
- * The PNIC II is essentially a Macronix 98715A chip; the only difference
- * worth noting is that its multicast hash table is only 128 bits wide
- * instead of 512.
- *
- * Written by Bill Paul <wpaul@ee.columbia.edu>
- * Electrical Engineering Department
- * Columbia University, New York City
- */
-
-/*
- * The Intel 21143 is the successor to the DEC 21140. It is basically
- * the same as the 21140 but with a few new features. The 21143 supports
- * three kinds of media attachments:
- *
- * o MII port, for 10Mbps and 100Mbps support and NWAY
- * autonegotiation provided by an external PHY.
- * o SYM port, for symbol mode 100Mbps support.
- * o 10baseT port.
- * o AUI/BNC port.
- *
- * The 100Mbps SYM port and 10baseT port can be used together in
- * combination with the internal NWAY support to create a 10/100
- * autosensing configuration.
- *
- * Knowing which media is available on a given card is tough: you're
- * supposed to go slogging through the EEPROM looking for media
- * description structures. Unfortunately, some card vendors that use
- * the 21143 don't obey the DEC SROM spec correctly, which means that
- * what you find in the EEPROM may not agree with reality. Fortunately,
- * the 21143 provides us a way to get around this issue: lurking in
- * PCI configuration space is the Configuration Wake-Up Command Register.
- * This register is loaded with a value from the EEPROM when wake on LAN
- * mode is enabled; this value tells us quite clearly what kind of media
- * is attached to the NIC. The main purpose of this register is to tell
- * the NIC what media to scan when in wake on LAN mode, however by
- * forcibly enabling wake on LAN mode, we can use to learn what kind of
- * media a given NIC has available and adapt ourselves accordingly.
- *
- * Of course, if the media description blocks in the EEPROM are bogus.
- * what are the odds that the CWUC aren't bogus as well, right? Well,
- * the CWUC value is more likely to be correct since wake on LAN mode
- * won't work correctly without it, and wake on LAN is a big selling
- * point these days. It's also harder to screw up a single byte than
- * a whole media descriptor block.
- *
- * Note that not all tulip workalikes are handled in this driver: we only
- * deal with those which are relatively well behaved. The Winbond is
- * handled separately due to its different register offsets and the
- * special handling needed for its various bugs. The PNIC is handled
- * here, but I'm not thrilled about it.
- *
- * All of the workalike chips use some form of MII transceiver support
- * with the exception of the Macronix chips, which also have a SYM port.
- * The ASIX AX88140A is also documented to have a SYM port, but all
- * the cards I've seen use an MII transceiver, probably because the
- * AX88140A doesn't support internal NWAY.
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/sockio.h>
-#include <sys/mbuf.h>
-#include <sys/malloc.h>
-#include <sys/kernel.h>
-#include <sys/socket.h>
-
-#include <net/if.h>
-#include <net/if_arp.h>
-#include <net/ethernet.h>
-#include <net/if_dl.h>
-#include <net/if_media.h>
-
-#include <net/bpf.h>
-
-#include "opt_bdg.h"
-#ifdef BRIDGE
-#include <net/bridge.h>
-#endif
-
-#include <vm/vm.h> /* for vtophys */
-#include <vm/pmap.h> /* for vtophys */
-#include <machine/clock.h> /* for DELAY */
-#include <machine/bus_pio.h>
-#include <machine/bus_memio.h>
-#include <machine/bus.h>
-#include <machine/resource.h>
-#include <sys/bus.h>
-#include <sys/rman.h>
-
-#include <dev/mii/mii.h>
-#include <dev/mii/miivar.h>
-
-#include <pci/pcireg.h>
-#include <pci/pcivar.h>
-
-#define DC_USEIOSPACE
-
-#include <pci/if_dcreg.h>
-
-/* "controller miibus0" required. See GENERIC if you get errors here. */
-#include "miibus_if.h"
-
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif
-
-/*
- * Various supported device vendors/types and their names.
- */
-static struct dc_type dc_devs[] = {
- { DC_VENDORID_DEC, DC_DEVICEID_21143,
- "Intel 21143 10/100BaseTX" },
- { DC_VENDORID_DAVICOM, DC_DEVICEID_DM9100,
- "Davicom DM9100 10/100BaseTX" },
- { DC_VENDORID_DAVICOM, DC_DEVICEID_DM9102,
- "Davicom DM9102 10/100BaseTX" },
- { DC_VENDORID_DAVICOM, DC_DEVICEID_DM9102,
- "Davicom DM9102A 10/100BaseTX" },
- { DC_VENDORID_ADMTEK, DC_DEVICEID_AL981,
- "ADMtek AL981 10/100BaseTX" },
- { DC_VENDORID_ADMTEK, DC_DEVICEID_AN985,
- "ADMtek AN985 10/100BaseTX" },
- { DC_VENDORID_ASIX, DC_DEVICEID_AX88140A,
- "ASIX AX88140A 10/100BaseTX" },
- { DC_VENDORID_ASIX, DC_DEVICEID_AX88140A,
- "ASIX AX88141 10/100BaseTX" },
- { DC_VENDORID_MX, DC_DEVICEID_98713,
- "Macronix 98713 10/100BaseTX" },
- { DC_VENDORID_MX, DC_DEVICEID_98713,
- "Macronix 98713A 10/100BaseTX" },
- { DC_VENDORID_CP, DC_DEVICEID_98713_CP,
- "Compex RL100-TX 10/100BaseTX" },
- { DC_VENDORID_CP, DC_DEVICEID_98713_CP,
- "Compex RL100-TX 10/100BaseTX" },
- { DC_VENDORID_MX, DC_DEVICEID_987x5,
- "Macronix 98715/98715A 10/100BaseTX" },
- { DC_VENDORID_MX, DC_DEVICEID_987x5,
- "Macronix 98725 10/100BaseTX" },
- { DC_VENDORID_LO, DC_DEVICEID_82C115,
- "LC82C115 PNIC II 10/100BaseTX" },
- { DC_VENDORID_LO, DC_DEVICEID_82C168,
- "82c168 PNIC 10/100BaseTX" },
- { DC_VENDORID_LO, DC_DEVICEID_82C168,
- "82c169 PNIC 10/100BaseTX" },
- { 0, 0, NULL }
-};
-
-static int dc_probe __P((device_t));
-static int dc_attach __P((device_t));
-static int dc_detach __P((device_t));
-static void dc_acpi __P((device_t));
-static struct dc_type *dc_devtype __P((device_t));
-static int dc_newbuf __P((struct dc_softc *, int, struct mbuf *));
-static int dc_encap __P((struct dc_softc *, struct mbuf *,
- u_int32_t *));
-static int dc_coal __P((struct dc_softc *, struct mbuf **));
-static void dc_pnic_rx_bug_war __P((struct dc_softc *, int));
-static int dc_rx_resync __P((struct dc_softc *));
-static void dc_rxeof __P((struct dc_softc *));
-static void dc_txeof __P((struct dc_softc *));
-static void dc_tick __P((void *));
-static void dc_intr __P((void *));
-static void dc_start __P((struct ifnet *));
-static int dc_ioctl __P((struct ifnet *, u_long, caddr_t));
-static void dc_init __P((void *));
-static void dc_stop __P((struct dc_softc *));
-static void dc_watchdog __P((struct ifnet *));
-static void dc_shutdown __P((device_t));
-static int dc_ifmedia_upd __P((struct ifnet *));
-static void dc_ifmedia_sts __P((struct ifnet *, struct ifmediareq *));
-
-static void dc_delay __P((struct dc_softc *));
-static void dc_eeprom_idle __P((struct dc_softc *));
-static void dc_eeprom_putbyte __P((struct dc_softc *, int));
-static void dc_eeprom_getword __P((struct dc_softc *, int, u_int16_t *));
-static void dc_eeprom_getword_pnic
- __P((struct dc_softc *, int, u_int16_t *));
-static void dc_read_eeprom __P((struct dc_softc *, caddr_t, int,
- int, int));
-
-static void dc_mii_writebit __P((struct dc_softc *, int));
-static int dc_mii_readbit __P((struct dc_softc *));
-static void dc_mii_sync __P((struct dc_softc *));
-static void dc_mii_send __P((struct dc_softc *, u_int32_t, int));
-static int dc_mii_readreg __P((struct dc_softc *, struct dc_mii_frame *));
-static int dc_mii_writereg __P((struct dc_softc *, struct dc_mii_frame *));
-static int dc_miibus_readreg __P((device_t, int, int));
-static int dc_miibus_writereg __P((device_t, int, int, int));
-static void dc_miibus_statchg __P((device_t));
-static void dc_miibus_mediainit __P((device_t));
-
-static void dc_setcfg __P((struct dc_softc *, int));
-static u_int32_t dc_crc_le __P((struct dc_softc *, caddr_t));
-static u_int32_t dc_crc_be __P((caddr_t));
-static void dc_setfilt_21143 __P((struct dc_softc *));
-static void dc_setfilt_asix __P((struct dc_softc *));
-static void dc_setfilt_admtek __P((struct dc_softc *));
-
-static void dc_setfilt __P((struct dc_softc *));
-
-static void dc_reset __P((struct dc_softc *));
-static int dc_list_rx_init __P((struct dc_softc *));
-static int dc_list_tx_init __P((struct dc_softc *));
-
-#ifdef DC_USEIOSPACE
-#define DC_RES SYS_RES_IOPORT
-#define DC_RID DC_PCI_CFBIO
-#else
-#define DC_RES SYS_RES_MEMORY
-#define DC_RID DC_PCI_CFBMA
-#endif
-
-static device_method_t dc_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, dc_probe),
- DEVMETHOD(device_attach, dc_attach),
- DEVMETHOD(device_detach, dc_detach),
- DEVMETHOD(device_shutdown, dc_shutdown),
-
- /* bus interface */
- DEVMETHOD(bus_print_child, bus_generic_print_child),
- DEVMETHOD(bus_driver_added, bus_generic_driver_added),
-
- /* MII interface */
- DEVMETHOD(miibus_readreg, dc_miibus_readreg),
- DEVMETHOD(miibus_writereg, dc_miibus_writereg),
- DEVMETHOD(miibus_statchg, dc_miibus_statchg),
- DEVMETHOD(miibus_mediainit, dc_miibus_mediainit),
-
- { 0, 0 }
-};
-
-static driver_t dc_driver = {
- "dc",
- dc_methods,
- sizeof(struct dc_softc)
-};
-
-static devclass_t dc_devclass;
-
-DRIVER_MODULE(if_dc, pci, dc_driver, dc_devclass, 0, 0);
-DRIVER_MODULE(miibus, dc, miibus_driver, miibus_devclass, 0, 0);
-
-#define DC_SETBIT(sc, reg, x) \
- CSR_WRITE_4(sc, reg, CSR_READ_4(sc, reg) | (x))
-
-#define DC_CLRBIT(sc, reg, x) \
- CSR_WRITE_4(sc, reg, CSR_READ_4(sc, reg) & ~(x))
-
-#define SIO_SET(x) DC_SETBIT(sc, DC_SIO, (x))
-#define SIO_CLR(x) DC_CLRBIT(sc, DC_SIO, (x))
-
-static void dc_delay(sc)
- struct dc_softc *sc;
-{
- int idx;
-
- for (idx = (300 / 33) + 1; idx > 0; idx--)
- CSR_READ_4(sc, DC_BUSCTL);
-}
-
-static void dc_eeprom_idle(sc)
- struct dc_softc *sc;
-{
- register int i;
-
- CSR_WRITE_4(sc, DC_SIO, DC_SIO_EESEL);
- dc_delay(sc);
- DC_SETBIT(sc, DC_SIO, DC_SIO_ROMCTL_READ);
- dc_delay(sc);
- DC_CLRBIT(sc, DC_SIO, DC_SIO_EE_CLK);
- dc_delay(sc);
- DC_SETBIT(sc, DC_SIO, DC_SIO_EE_CS);
- dc_delay(sc);
-
- for (i = 0; i < 25; i++) {
- DC_CLRBIT(sc, DC_SIO, DC_SIO_EE_CLK);
- dc_delay(sc);
- DC_SETBIT(sc, DC_SIO, DC_SIO_EE_CLK);
- dc_delay(sc);
- }
-
- DC_CLRBIT(sc, DC_SIO, DC_SIO_EE_CLK);
- dc_delay(sc);
- DC_CLRBIT(sc, DC_SIO, DC_SIO_EE_CS);
- dc_delay(sc);
- CSR_WRITE_4(sc, DC_SIO, 0x00000000);
-
- return;
-}
-
-/*
- * Send a read command and address to the EEPROM, check for ACK.
- */
-static void dc_eeprom_putbyte(sc, addr)
- struct dc_softc *sc;
- int addr;
-{
- register int d, i;
-
- /*
- * The AN985 has a 93C66 EEPROM on it instead of
- * a 93C46. It uses a different bit sequence for
- * specifying the "read" opcode.
- */
- if (DC_IS_CENTAUR(sc))
- d = addr | (DC_EECMD_READ << 2);
- else
- d = addr | DC_EECMD_READ;
-
- /*
- * Feed in each bit and strobe the clock.
- */
- for (i = 0x400; i; i >>= 1) {
- if (d & i) {
- SIO_SET(DC_SIO_EE_DATAIN);
- } else {
- SIO_CLR(DC_SIO_EE_DATAIN);
- }
- dc_delay(sc);
- SIO_SET(DC_SIO_EE_CLK);
- dc_delay(sc);
- SIO_CLR(DC_SIO_EE_CLK);
- dc_delay(sc);
- }
-
- return;
-}
-
-/*
- * Read a word of data stored in the EEPROM at address 'addr.'
- * The PNIC 82c168/82c169 has its own non-standard way to read
- * the EEPROM.
- */
-static void dc_eeprom_getword_pnic(sc, addr, dest)
- struct dc_softc *sc;
- int addr;
- u_int16_t *dest;
-{
- register int i;
- u_int32_t r;
-
- CSR_WRITE_4(sc, DC_PN_SIOCTL, DC_PN_EEOPCODE_READ|addr);
-
- for (i = 0; i < DC_TIMEOUT; i++) {
- DELAY(1);
- r = CSR_READ_4(sc, DC_SIO);
- if (!(r & DC_PN_SIOCTL_BUSY)) {
- *dest = (u_int16_t)(r & 0xFFFF);
- return;
- }
- }
-
- return;
-}
-
-/*
- * Read a word of data stored in the EEPROM at address 'addr.'
- */
-static void dc_eeprom_getword(sc, addr, dest)
- struct dc_softc *sc;
- int addr;
- u_int16_t *dest;
-{
- register int i;
- u_int16_t word = 0;
-
- /* Force EEPROM to idle state. */
- dc_eeprom_idle(sc);
-
- /* Enter EEPROM access mode. */
- CSR_WRITE_4(sc, DC_SIO, DC_SIO_EESEL);
- dc_delay(sc);
- DC_SETBIT(sc, DC_SIO, DC_SIO_ROMCTL_READ);
- dc_delay(sc);
- DC_CLRBIT(sc, DC_SIO, DC_SIO_EE_CLK);
- dc_delay(sc);
- DC_SETBIT(sc, DC_SIO, DC_SIO_EE_CS);
- dc_delay(sc);
-
- /*
- * Send address of word we want to read.
- */
- dc_eeprom_putbyte(sc, addr);
-
- /*
- * Start reading bits from EEPROM.
- */
- for (i = 0x8000; i; i >>= 1) {
- SIO_SET(DC_SIO_EE_CLK);
- dc_delay(sc);
- if (CSR_READ_4(sc, DC_SIO) & DC_SIO_EE_DATAOUT)
- word |= i;
- dc_delay(sc);
- SIO_CLR(DC_SIO_EE_CLK);
- dc_delay(sc);
- }
-
- /* Turn off EEPROM access mode. */
- dc_eeprom_idle(sc);
-
- *dest = word;
-
- return;
-}
-
-/*
- * Read a sequence of words from the EEPROM.
- */
-static void dc_read_eeprom(sc, dest, off, cnt, swap)
- struct dc_softc *sc;
- caddr_t dest;
- int off;
- int cnt;
- int swap;
-{
- int i;
- u_int16_t word = 0, *ptr;
-
- for (i = 0; i < cnt; i++) {
- if (DC_IS_PNIC(sc))
- dc_eeprom_getword_pnic(sc, off + i, &word);
- else
- dc_eeprom_getword(sc, off + i, &word);
- ptr = (u_int16_t *)(dest + (i * 2));
- if (swap)
- *ptr = ntohs(word);
- else
- *ptr = word;
- }
-
- return;
-}
-
-/*
- * The following two routines are taken from the Macronix 98713
- * Application Notes pp.19-21.
- */
-/*
- * Write a bit to the MII bus.
- */
-static void dc_mii_writebit(sc, bit)
- struct dc_softc *sc;
- int bit;
-{
- if (bit)
- CSR_WRITE_4(sc, DC_SIO,
- DC_SIO_ROMCTL_WRITE|DC_SIO_MII_DATAOUT);
- else
- CSR_WRITE_4(sc, DC_SIO, DC_SIO_ROMCTL_WRITE);
-
- DC_SETBIT(sc, DC_SIO, DC_SIO_MII_CLK);
- DC_CLRBIT(sc, DC_SIO, DC_SIO_MII_CLK);
-
- return;
-}
-
-/*
- * Read a bit from the MII bus.
- */
-static int dc_mii_readbit(sc)
- struct dc_softc *sc;
-{
- CSR_WRITE_4(sc, DC_SIO, DC_SIO_ROMCTL_READ|DC_SIO_MII_DIR);
- CSR_READ_4(sc, DC_SIO);
- DC_SETBIT(sc, DC_SIO, DC_SIO_MII_CLK);
- DC_CLRBIT(sc, DC_SIO, DC_SIO_MII_CLK);
- if (CSR_READ_4(sc, DC_SIO) & DC_SIO_MII_DATAIN)
- return(1);
-
- return(0);
-}
-
-/*
- * Sync the PHYs by setting data bit and strobing the clock 32 times.
- */
-static void dc_mii_sync(sc)
- struct dc_softc *sc;
-{
- register int i;
-
- CSR_WRITE_4(sc, DC_SIO, DC_SIO_ROMCTL_WRITE);
-
- for (i = 0; i < 32; i++)
- dc_mii_writebit(sc, 1);
-
- return;
-}
-
-/*
- * Clock a series of bits through the MII.
- */
-static void dc_mii_send(sc, bits, cnt)
- struct dc_softc *sc;
- u_int32_t bits;
- int cnt;
-{
- int i;
-
- for (i = (0x1 << (cnt - 1)); i; i >>= 1)
- dc_mii_writebit(sc, bits & i);
-}
-
-/*
- * Read an PHY register through the MII.
- */
-static int dc_mii_readreg(sc, frame)
- struct dc_softc *sc;
- struct dc_mii_frame *frame;
-
-{
- int i, ack, s;
-
- s = splimp();
-
- /*
- * Set up frame for RX.
- */
- frame->mii_stdelim = DC_MII_STARTDELIM;
- frame->mii_opcode = DC_MII_READOP;
- frame->mii_turnaround = 0;
- frame->mii_data = 0;
-
- /*
- * Sync the PHYs.
- */
- dc_mii_sync(sc);
-
- /*
- * Send command/address info.
- */
- dc_mii_send(sc, frame->mii_stdelim, 2);
- dc_mii_send(sc, frame->mii_opcode, 2);
- dc_mii_send(sc, frame->mii_phyaddr, 5);
- dc_mii_send(sc, frame->mii_regaddr, 5);
-
-#ifdef notdef
- /* Idle bit */
- dc_mii_writebit(sc, 1);
- dc_mii_writebit(sc, 0);
-#endif
-
- /* Check for ack */
- ack = dc_mii_readbit(sc);
-
- /*
- * Now try reading data bits. If the ack failed, we still
- * need to clock through 16 cycles to keep the PHY(s) in sync.
- */
- if (ack) {
- for(i = 0; i < 16; i++) {
- dc_mii_readbit(sc);
- }
- goto fail;
- }
-
- for (i = 0x8000; i; i >>= 1) {
- if (!ack) {
- if (dc_mii_readbit(sc))
- frame->mii_data |= i;
- }
- }
-
-fail:
-
- dc_mii_writebit(sc, 0);
- dc_mii_writebit(sc, 0);
-
- splx(s);
-
- if (ack)
- return(1);
- return(0);
-}
-
-/*
- * Write to a PHY register through the MII.
- */
-static int dc_mii_writereg(sc, frame)
- struct dc_softc *sc;
- struct dc_mii_frame *frame;
-
-{
- int s;
-
- s = splimp();
- /*
- * Set up frame for TX.
- */
-
- frame->mii_stdelim = DC_MII_STARTDELIM;
- frame->mii_opcode = DC_MII_WRITEOP;
- frame->mii_turnaround = DC_MII_TURNAROUND;
-
- /*
- * Sync the PHYs.
- */
- dc_mii_sync(sc);
-
- dc_mii_send(sc, frame->mii_stdelim, 2);
- dc_mii_send(sc, frame->mii_opcode, 2);
- dc_mii_send(sc, frame->mii_phyaddr, 5);
- dc_mii_send(sc, frame->mii_regaddr, 5);
- dc_mii_send(sc, frame->mii_turnaround, 2);
- dc_mii_send(sc, frame->mii_data, 16);
-
- /* Idle bit. */
- dc_mii_writebit(sc, 0);
- dc_mii_writebit(sc, 0);
-
- splx(s);
-
- return(0);
-}
-
-static int dc_miibus_readreg(dev, phy, reg)
- device_t dev;
- int phy, reg;
-{
- struct dc_mii_frame frame;
- struct dc_softc *sc;
- int i, rval, phy_reg;
-
- sc = device_get_softc(dev);
- bzero((char *)&frame, sizeof(frame));
-
- /*
- * Note: both the AL981 and AN985 have internal PHYs,
- * however the AL981 provides direct access to the PHY
- * registers while the AN985 uses a serial MII interface.
- * The AN985's MII interface is also buggy in that you
- * can read from any MII address (0 to 31), but only address 1
- * behaves normally. To deal with both cases, we pretend
- * that the PHY is at MII address 1.
- */
- if (DC_IS_ADMTEK(sc) && phy != DC_ADMTEK_PHYADDR)
- return(0);
-
- if (sc->dc_pmode == DC_PMODE_SYM) {
- if (phy == (MII_NPHY - 1)) {
- switch(reg) {
- case MII_BMSR:
- /*
- * Fake something to make the probe
- * code think there's a PHY here.
- */
- return(BMSR_MEDIAMASK);
- break;
- case MII_PHYIDR1:
- if (DC_IS_PNIC(sc))
- return(DC_VENDORID_LO);
- return(DC_VENDORID_DEC);
- break;
- case MII_PHYIDR2:
- if (DC_IS_PNIC(sc))
- return(DC_DEVICEID_82C168);
- return(DC_DEVICEID_21143);
- break;
- default:
- return(0);
- break;
- }
- } else
- return(0);
- }
-
- if (DC_IS_PNIC(sc)) {
- CSR_WRITE_4(sc, DC_PN_MII, DC_PN_MIIOPCODE_READ |
- (phy << 23) | (reg << 18));
- for (i = 0; i < DC_TIMEOUT; i++) {
- DELAY(1);
- rval = CSR_READ_4(sc, DC_PN_MII);
- if (!(rval & DC_PN_MII_BUSY)) {
- rval &= 0xFFFF;
- return(rval == 0xFFFF ? 0 : rval);
- }
- }
- return(0);
- }
-
- if (DC_IS_COMET(sc)) {
- switch(reg) {
- case MII_BMCR:
- phy_reg = DC_AL_BMCR;
- break;
- case MII_BMSR:
- phy_reg = DC_AL_BMSR;
- break;
- case MII_PHYIDR1:
- phy_reg = DC_AL_VENID;
- break;
- case MII_PHYIDR2:
- phy_reg = DC_AL_DEVID;
- break;
- case MII_ANAR:
- phy_reg = DC_AL_ANAR;
- break;
- case MII_ANLPAR:
- phy_reg = DC_AL_LPAR;
- break;
- case MII_ANER:
- phy_reg = DC_AL_ANER;
- break;
- default:
- printf("dc%d: phy_read: bad phy register %x\n",
- sc->dc_unit, reg);
- return(0);
- break;
- }
-
- rval = CSR_READ_4(sc, phy_reg) & 0x0000FFFF;
-
- if (rval == 0xFFFF)
- return(0);
- return(rval);
- }
-
- frame.mii_phyaddr = phy;
- frame.mii_regaddr = reg;
- phy_reg = CSR_READ_4(sc, DC_NETCFG);
- CSR_WRITE_4(sc, DC_NETCFG, phy_reg & ~DC_NETCFG_PORTSEL);
- dc_mii_readreg(sc, &frame);
- CSR_WRITE_4(sc, DC_NETCFG, phy_reg);
-
- return(frame.mii_data);
-}
-
-static int dc_miibus_writereg(dev, phy, reg, data)
- device_t dev;
- int phy, reg, data;
-{
- struct dc_softc *sc;
- struct dc_mii_frame frame;
- int i, phy_reg;
-
- sc = device_get_softc(dev);
- bzero((char *)&frame, sizeof(frame));
-
- if (DC_IS_ADMTEK(sc) && phy != DC_ADMTEK_PHYADDR)
- return(0);
-
- if (DC_IS_PNIC(sc)) {
- CSR_WRITE_4(sc, DC_PN_MII, DC_PN_MIIOPCODE_WRITE |
- (phy << 23) | (reg << 10) | data);
- for (i = 0; i < DC_TIMEOUT; i++) {
- if (!(CSR_READ_4(sc, DC_PN_MII) & DC_PN_MII_BUSY))
- break;
- }
- return(0);
- }
-
- if (DC_IS_COMET(sc)) {
- switch(reg) {
- case MII_BMCR:
- phy_reg = DC_AL_BMCR;
- break;
- case MII_BMSR:
- phy_reg = DC_AL_BMSR;
- break;
- case MII_PHYIDR1:
- phy_reg = DC_AL_VENID;
- break;
- case MII_PHYIDR2:
- phy_reg = DC_AL_DEVID;
- break;
- case MII_ANAR:
- phy_reg = DC_AL_ANAR;
- break;
- case MII_ANLPAR:
- phy_reg = DC_AL_LPAR;
- break;
- case MII_ANER:
- phy_reg = DC_AL_ANER;
- break;
- default:
- printf("dc%d: phy_write: bad phy register %x\n",
- sc->dc_unit, reg);
- return(0);
- break;
- }
-
- CSR_WRITE_4(sc, phy_reg, data);
- return(0);
- }
-
- frame.mii_phyaddr = phy;
- frame.mii_regaddr = reg;
- frame.mii_data = data;
-
- phy_reg = CSR_READ_4(sc, DC_NETCFG);
- CSR_WRITE_4(sc, DC_NETCFG, phy_reg & ~DC_NETCFG_PORTSEL);
- dc_mii_writereg(sc, &frame);
- CSR_WRITE_4(sc, DC_NETCFG, phy_reg);
-
- return(0);
-}
-
-static void dc_miibus_statchg(dev)
- device_t dev;
-{
- struct dc_softc *sc;
- struct mii_data *mii;
- struct ifmedia *ifm;
-
- sc = device_get_softc(dev);
- if (DC_IS_ADMTEK(sc))
- return;
- mii = device_get_softc(sc->dc_miibus);
- ifm = &mii->mii_media;
- if (DC_IS_DAVICOM(sc) &&
- IFM_SUBTYPE(ifm->ifm_media) == IFM_homePNA) {
- dc_setcfg(sc, ifm->ifm_media);
- sc->dc_if_media = ifm->ifm_media;
- } else {
- dc_setcfg(sc, mii->mii_media_active);
- sc->dc_if_media = mii->mii_media_active;
- }
-
- return;
-}
-
-/*
- * Special support for DM9102A cards with HomePNA PHYs. Note:
- * with the Davicom DM9102A/DM9801 eval board that I have, it seems
- * to be impossible to talk to the management interface of the DM9801
- * PHY (its MDIO pin is not connected to anything). Consequently,
- * the driver has to just 'know' about the additional mode and deal
- * with it itself. *sigh*
- */
-static void dc_miibus_mediainit(dev)
- device_t dev;
-{
- struct dc_softc *sc;
- struct mii_data *mii;
- struct ifmedia *ifm;
- int rev;
-
- rev = pci_read_config(dev, DC_PCI_CFRV, 4) & 0xFF;
-
- sc = device_get_softc(dev);
- mii = device_get_softc(sc->dc_miibus);
- ifm = &mii->mii_media;
-
- if (DC_IS_DAVICOM(sc) && rev >= DC_REVISION_DM9102A)
- ifmedia_add(ifm, IFM_ETHER|IFM_homePNA, 0, NULL);
-
- return;
-}
-
-#define DC_POLY 0xEDB88320
-#define DC_BITS 9
-#define DC_BITS_PNIC_II 7
-
-static u_int32_t dc_crc_le(sc, addr)
- struct dc_softc *sc;
- caddr_t addr;
-{
- u_int32_t idx, bit, data, crc;
-
- /* Compute CRC for the address value. */
- crc = 0xFFFFFFFF; /* initial value */
-
- for (idx = 0; idx < 6; idx++) {
- for (data = *addr++, bit = 0; bit < 8; bit++, data >>= 1)
- crc = (crc >> 1) ^ (((crc ^ data) & 1) ? DC_POLY : 0);
- }
-
- /* The hash table on the PNIC II is only 128 bits wide. */
- if (DC_IS_PNICII(sc))
- return (crc & ((1 << DC_BITS_PNIC_II) - 1));
-
- return (crc & ((1 << DC_BITS) - 1));
-}
-
-/*
- * Calculate CRC of a multicast group address, return the lower 6 bits.
- */
-static u_int32_t dc_crc_be(addr)
- caddr_t addr;
-{
- u_int32_t crc, carry;
- int i, j;
- u_int8_t c;
-
- /* Compute CRC for the address value. */
- crc = 0xFFFFFFFF; /* initial value */
-
- for (i = 0; i < 6; i++) {
- c = *(addr + i);
- for (j = 0; j < 8; j++) {
- carry = ((crc & 0x80000000) ? 1 : 0) ^ (c & 0x01);
- crc <<= 1;
- c >>= 1;
- if (carry)
- crc = (crc ^ 0x04c11db6) | carry;
- }
- }
-
- /* return the filter bit position */
- return((crc >> 26) & 0x0000003F);
-}
-
-/*
- * 21143-style RX filter setup routine. Filter programming is done by
- * downloading a special setup frame into the TX engine. 21143, Macronix,
- * PNIC, PNIC II and Davicom chips are programmed this way.
- *
- * We always program the chip using 'hash perfect' mode, i.e. one perfect
- * address (our node address) and a 512-bit hash filter for multicast
- * frames. We also sneak the broadcast address into the hash filter since
- * we need that too.
- */
-void dc_setfilt_21143(sc)
- struct dc_softc *sc;
-{
- struct dc_desc *sframe;
- u_int32_t h, *sp;
- struct ifmultiaddr *ifma;
- struct ifnet *ifp;
- int i;
-
- ifp = &sc->arpcom.ac_if;
-
- i = sc->dc_cdata.dc_tx_prod;
- DC_INC(sc->dc_cdata.dc_tx_prod, DC_TX_LIST_CNT);
- sc->dc_cdata.dc_tx_cnt++;
- sframe = &sc->dc_ldata->dc_tx_list[i];
- sp = (u_int32_t *)&sc->dc_cdata.dc_sbuf;
- bzero((char *)sp, DC_SFRAME_LEN);
-
- sframe->dc_data = vtophys(&sc->dc_cdata.dc_sbuf);
- sframe->dc_ctl = DC_SFRAME_LEN | DC_TXCTL_SETUP | DC_TXCTL_TLINK |
- DC_FILTER_HASHPERF | DC_TXCTL_FINT;
-
- sc->dc_cdata.dc_tx_chain[i] = (struct mbuf *)&sc->dc_cdata.dc_sbuf;
-
- /* If we want promiscuous mode, set the allframes bit. */
- if (ifp->if_flags & IFF_PROMISC)
- DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_RX_PROMISC);
- else
- DC_CLRBIT(sc, DC_NETCFG, DC_NETCFG_RX_PROMISC);
-
- if (ifp->if_flags & IFF_ALLMULTI)
- DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_RX_ALLMULTI);
- else
- DC_CLRBIT(sc, DC_NETCFG, DC_NETCFG_RX_ALLMULTI);
-
- for (ifma = ifp->if_multiaddrs.lh_first; ifma != NULL;
- ifma = ifma->ifma_link.le_next) {
- if (ifma->ifma_addr->sa_family != AF_LINK)
- continue;
- h = dc_crc_le(sc,
- LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
- sp[h >> 4] |= 1 << (h & 0xF);
- }
-
- if (ifp->if_flags & IFF_BROADCAST) {
- h = dc_crc_le(sc, (caddr_t)&etherbroadcastaddr);
- sp[h >> 4] |= 1 << (h & 0xF);
- }
-
- /* Set our MAC address */
- sp[39] = ((u_int16_t *)sc->arpcom.ac_enaddr)[0];
- sp[40] = ((u_int16_t *)sc->arpcom.ac_enaddr)[1];
- sp[41] = ((u_int16_t *)sc->arpcom.ac_enaddr)[2];
-
- sframe->dc_status = DC_TXSTAT_OWN;
- CSR_WRITE_4(sc, DC_TXSTART, 0xFFFFFFFF);
-
- /*
- * The PNIC takes an exceedingly long time to process its
- * setup frame; wait 10ms after posting the setup frame
- * before proceeding, just so it has time to swallow its
- * medicine.
- */
- DELAY(10000);
-
- ifp->if_timer = 5;
-
- return;
-}
-
-void dc_setfilt_admtek(sc)
- struct dc_softc *sc;
-{
- struct ifnet *ifp;
- int h = 0;
- u_int32_t hashes[2] = { 0, 0 };
- struct ifmultiaddr *ifma;
-
- ifp = &sc->arpcom.ac_if;
-
- /* Init our MAC address */
- CSR_WRITE_4(sc, DC_AL_PAR0, *(u_int32_t *)(&sc->arpcom.ac_enaddr[0]));
- CSR_WRITE_4(sc, DC_AL_PAR1, *(u_int32_t *)(&sc->arpcom.ac_enaddr[4]));
-
- /* If we want promiscuous mode, set the allframes bit. */
- if (ifp->if_flags & IFF_PROMISC)
- DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_RX_PROMISC);
- else
- DC_CLRBIT(sc, DC_NETCFG, DC_NETCFG_RX_PROMISC);
-
- if (ifp->if_flags & IFF_ALLMULTI)
- DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_RX_ALLMULTI);
- else
- DC_CLRBIT(sc, DC_NETCFG, DC_NETCFG_RX_ALLMULTI);
-
- /* first, zot all the existing hash bits */
- CSR_WRITE_4(sc, DC_AL_MAR0, 0);
- CSR_WRITE_4(sc, DC_AL_MAR1, 0);
-
- /*
- * If we're already in promisc or allmulti mode, we
- * don't have to bother programming the multicast filter.
- */
- if (ifp->if_flags & (IFF_PROMISC|IFF_ALLMULTI))
- return;
-
- /* now program new ones */
- for (ifma = ifp->if_multiaddrs.lh_first; ifma != NULL;
- ifma = ifma->ifma_link.le_next) {
- if (ifma->ifma_addr->sa_family != AF_LINK)
- continue;
- h = dc_crc_be(LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
- if (h < 32)
- hashes[0] |= (1 << h);
- else
- hashes[1] |= (1 << (h - 32));
- }
-
- CSR_WRITE_4(sc, DC_AL_MAR0, hashes[0]);
- CSR_WRITE_4(sc, DC_AL_MAR1, hashes[1]);
-
- return;
-}
-
-void dc_setfilt_asix(sc)
- struct dc_softc *sc;
-{
- struct ifnet *ifp;
- int h = 0;
- u_int32_t hashes[2] = { 0, 0 };
- struct ifmultiaddr *ifma;
-
- ifp = &sc->arpcom.ac_if;
-
- /* Init our MAC address */
- CSR_WRITE_4(sc, DC_AX_FILTIDX, DC_AX_FILTIDX_PAR0);
- CSR_WRITE_4(sc, DC_AX_FILTDATA,
- *(u_int32_t *)(&sc->arpcom.ac_enaddr[0]));
- CSR_WRITE_4(sc, DC_AX_FILTIDX, DC_AX_FILTIDX_PAR1);
- CSR_WRITE_4(sc, DC_AX_FILTDATA,
- *(u_int32_t *)(&sc->arpcom.ac_enaddr[4]));
-
- /* If we want promiscuous mode, set the allframes bit. */
- if (ifp->if_flags & IFF_PROMISC)
- DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_RX_PROMISC);
- else
- DC_CLRBIT(sc, DC_NETCFG, DC_NETCFG_RX_PROMISC);
-
- if (ifp->if_flags & IFF_ALLMULTI)
- DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_RX_ALLMULTI);
- else
- DC_CLRBIT(sc, DC_NETCFG, DC_NETCFG_RX_ALLMULTI);
-
- /*
- * The ASIX chip has a special bit to enable reception
- * of broadcast frames.
- */
- if (ifp->if_flags & IFF_BROADCAST)
- DC_SETBIT(sc, DC_NETCFG, DC_AX_NETCFG_RX_BROAD);
- else
- DC_CLRBIT(sc, DC_NETCFG, DC_AX_NETCFG_RX_BROAD);
-
- /* first, zot all the existing hash bits */
- CSR_WRITE_4(sc, DC_AX_FILTIDX, DC_AX_FILTIDX_MAR0);
- CSR_WRITE_4(sc, DC_AX_FILTDATA, 0);
- CSR_WRITE_4(sc, DC_AX_FILTIDX, DC_AX_FILTIDX_MAR1);
- CSR_WRITE_4(sc, DC_AX_FILTDATA, 0);
-
- /*
- * If we're already in promisc or allmulti mode, we
- * don't have to bother programming the multicast filter.
- */
- if (ifp->if_flags & (IFF_PROMISC|IFF_ALLMULTI))
- return;
-
- /* now program new ones */
- for (ifma = ifp->if_multiaddrs.lh_first; ifma != NULL;
- ifma = ifma->ifma_link.le_next) {
- if (ifma->ifma_addr->sa_family != AF_LINK)
- continue;
- h = dc_crc_be(LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
- if (h < 32)
- hashes[0] |= (1 << h);
- else
- hashes[1] |= (1 << (h - 32));
- }
-
- CSR_WRITE_4(sc, DC_AX_FILTIDX, DC_AX_FILTIDX_MAR0);
- CSR_WRITE_4(sc, DC_AX_FILTDATA, hashes[0]);
- CSR_WRITE_4(sc, DC_AX_FILTIDX, DC_AX_FILTIDX_MAR1);
- CSR_WRITE_4(sc, DC_AX_FILTDATA, hashes[1]);
-
- return;
-}
-
-static void dc_setfilt(sc)
- struct dc_softc *sc;
-{
- if (DC_IS_INTEL(sc) || DC_IS_MACRONIX(sc) || DC_IS_PNIC(sc) ||
- DC_IS_PNICII(sc) || DC_IS_DAVICOM(sc))
- dc_setfilt_21143(sc);
-
- if (DC_IS_ASIX(sc))
- dc_setfilt_asix(sc);
-
- if (DC_IS_ADMTEK(sc))
- dc_setfilt_admtek(sc);
-
- return;
-}
-
-/*
- * In order to fiddle with the
- * 'full-duplex' and '100Mbps' bits in the netconfig register, we
- * first have to put the transmit and/or receive logic in the idle state.
- */
-static void dc_setcfg(sc, media)
- struct dc_softc *sc;
- int media;
-{
- int i, restart = 0;
- u_int32_t isr;
-
- if (IFM_SUBTYPE(media) == IFM_NONE)
- return;
-
- if (CSR_READ_4(sc, DC_NETCFG) & (DC_NETCFG_TX_ON|DC_NETCFG_RX_ON)) {
- restart = 1;
- DC_CLRBIT(sc, DC_NETCFG, (DC_NETCFG_TX_ON|DC_NETCFG_RX_ON));
-
- for (i = 0; i < DC_TIMEOUT; i++) {
- DELAY(10);
- isr = CSR_READ_4(sc, DC_ISR);
- if (isr & DC_ISR_TX_IDLE ||
- (isr & DC_ISR_RX_STATE) == DC_RXSTATE_STOPPED)
- break;
- }
-
- if (i == DC_TIMEOUT)
- printf("dc%d: failed to force tx and "
- "rx to idle state\n", sc->dc_unit);
-
- }
-
- if (IFM_SUBTYPE(media) == IFM_100_TX) {
- DC_CLRBIT(sc, DC_NETCFG, DC_NETCFG_SPEEDSEL);
- DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_HEARTBEAT);
- if (sc->dc_pmode == DC_PMODE_MII) {
- DC_SETBIT(sc, DC_WATCHDOG, DC_WDOG_JABBERDIS);
- DC_CLRBIT(sc, DC_NETCFG, (DC_NETCFG_PCS|
- DC_NETCFG_PORTSEL|DC_NETCFG_SCRAMBLER));
- if (sc->dc_type == DC_TYPE_98713)
- DC_SETBIT(sc, DC_NETCFG, (DC_NETCFG_PCS|
- DC_NETCFG_SCRAMBLER));
- if (!DC_IS_DAVICOM(sc))
- DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_PORTSEL);
- DC_CLRBIT(sc, DC_10BTCTRL, 0xFFFF);
- } else {
- if (DC_IS_PNIC(sc)) {
- DC_PN_GPIO_SETBIT(sc, DC_PN_GPIO_SPEEDSEL);
- DC_PN_GPIO_SETBIT(sc, DC_PN_GPIO_100TX_LOOP);
- DC_SETBIT(sc, DC_PN_NWAY, DC_PN_NWAY_SPEEDSEL);
- }
- DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_PORTSEL|
- DC_NETCFG_PCS|DC_NETCFG_SCRAMBLER);
- }
- }
-
- if (IFM_SUBTYPE(media) == IFM_10_T) {
- DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_SPEEDSEL);
- DC_CLRBIT(sc, DC_NETCFG, DC_NETCFG_HEARTBEAT);
- if (sc->dc_pmode == DC_PMODE_MII) {
- DC_SETBIT(sc, DC_WATCHDOG, DC_WDOG_JABBERDIS);
- DC_CLRBIT(sc, DC_NETCFG, (DC_NETCFG_PCS|
- DC_NETCFG_PORTSEL|DC_NETCFG_SCRAMBLER));
- if (sc->dc_type == DC_TYPE_98713)
- DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_PCS);
- if (!DC_IS_DAVICOM(sc))
- DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_PORTSEL);
- DC_CLRBIT(sc, DC_10BTCTRL, 0xFFFF);
- } else {
- if (DC_IS_PNIC(sc)) {
- DC_PN_GPIO_CLRBIT(sc, DC_PN_GPIO_SPEEDSEL);
- DC_PN_GPIO_SETBIT(sc, DC_PN_GPIO_100TX_LOOP);
- DC_CLRBIT(sc, DC_PN_NWAY, DC_PN_NWAY_SPEEDSEL);
- }
- DC_CLRBIT(sc, DC_NETCFG, DC_NETCFG_PORTSEL);
- DC_CLRBIT(sc, DC_NETCFG, DC_NETCFG_SCRAMBLER);
- DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_PCS);
- }
- }
-
- /*
- * If this is a Davicom DM9102A card with a DM9801 HomePNA
- * PHY and we want HomePNA mode, set the portsel bit to turn
- * on the external MII port.
- */
- if (DC_IS_DAVICOM(sc)) {
- if (IFM_SUBTYPE(media) == IFM_homePNA) {
- DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_PORTSEL);
- sc->dc_link = 1;
- } else {
- DC_CLRBIT(sc, DC_NETCFG, DC_NETCFG_PORTSEL);
- }
- }
-
- if ((media & IFM_GMASK) == IFM_FDX) {
- DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_FULLDUPLEX);
- if (sc->dc_pmode == DC_PMODE_SYM && DC_IS_PNIC(sc))
- DC_SETBIT(sc, DC_PN_NWAY, DC_PN_NWAY_DUPLEX);
- } else {
- DC_CLRBIT(sc, DC_NETCFG, DC_NETCFG_FULLDUPLEX);
- if (sc->dc_pmode == DC_PMODE_SYM && DC_IS_PNIC(sc))
- DC_CLRBIT(sc, DC_PN_NWAY, DC_PN_NWAY_DUPLEX);
- }
-
- if (restart)
- DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_TX_ON|DC_NETCFG_RX_ON);
-
- return;
-}
-
-static void dc_reset(sc)
- struct dc_softc *sc;
-{
- register int i;
-
- DC_SETBIT(sc, DC_BUSCTL, DC_BUSCTL_RESET);
-
- for (i = 0; i < DC_TIMEOUT; i++) {
- DELAY(10);
- if (!(CSR_READ_4(sc, DC_BUSCTL) & DC_BUSCTL_RESET))
- break;
- }
-
- if (DC_IS_ASIX(sc) || DC_IS_ADMTEK(sc)) {
- DELAY(10000);
- DC_CLRBIT(sc, DC_BUSCTL, DC_BUSCTL_RESET);
- i = 0;
- }
-
- if (i == DC_TIMEOUT)
- printf("dc%d: reset never completed!\n", sc->dc_unit);
-
- /* Wait a little while for the chip to get its brains in order. */
- DELAY(1000);
-
- CSR_WRITE_4(sc, DC_IMR, 0x00000000);
- CSR_WRITE_4(sc, DC_BUSCTL, 0x00000000);
- CSR_WRITE_4(sc, DC_NETCFG, 0x00000000);
-
- /*
- * Bring the SIA out of reset. In some cases, it looks
- * like failing to unreset the SIA soon enough gets it
- * into a state where it will never come out of reset
- * until we reset the whole chip again.
- */
- if (DC_IS_INTEL(sc))
- DC_SETBIT(sc, DC_SIARESET, DC_SIA_RESET);
-
- return;
-}
-
-static struct dc_type *dc_devtype(dev)
- device_t dev;
-{
- struct dc_type *t;
- u_int32_t rev;
-
- t = dc_devs;
-
- while(t->dc_name != NULL) {
- if ((pci_get_vendor(dev) == t->dc_vid) &&
- (pci_get_device(dev) == t->dc_did)) {
- /* Check the PCI revision */
- rev = pci_read_config(dev, DC_PCI_CFRV, 4) & 0xFF;
- if (t->dc_did == DC_DEVICEID_98713 &&
- rev >= DC_REVISION_98713A)
- t++;
- if (t->dc_did == DC_DEVICEID_98713_CP &&
- rev >= DC_REVISION_98713A)
- t++;
- if (t->dc_did == DC_DEVICEID_987x5 &&
- rev >= DC_REVISION_98725)
- t++;
- if (t->dc_did == DC_DEVICEID_AX88140A &&
- rev >= DC_REVISION_88141)
- t++;
- if (t->dc_did == DC_DEVICEID_82C168 &&
- rev >= DC_REVISION_82C169)
- t++;
- if (t->dc_did == DC_DEVICEID_DM9102 &&
- rev >= DC_REVISION_DM9102A)
- t++;
- return(t);
- }
- t++;
- }
-
- return(NULL);
-}
-
-/*
- * Probe for a 21143 or clone chip. Check the PCI vendor and device
- * IDs against our list and return a device name if we find a match.
- * We do a little bit of extra work to identify the exact type of
- * chip. The MX98713 and MX98713A have the same PCI vendor/device ID,
- * but different revision IDs. The same is true for 98715/98715A
- * chips and the 98725, as well as the ASIX and ADMtek chips. In some
- * cases, the exact chip revision affects driver behavior.
- */
-static int dc_probe(dev)
- device_t dev;
-{
- struct dc_type *t;
-
- t = dc_devtype(dev);
-
- if (t != NULL) {
- device_set_desc(dev, t->dc_name);
- return(0);
- }
-
- return(ENXIO);
-}
-
-static void dc_acpi(dev)
- device_t dev;
-{
- u_int32_t r, cptr;
- int unit;
-
- unit = device_get_unit(dev);
-
- /* Find the location of the capabilities block */
- cptr = pci_read_config(dev, DC_PCI_CCAP, 4) & 0xFF;
-
- r = pci_read_config(dev, cptr, 4) & 0xFF;
- if (r == 0x01) {
-
- r = pci_read_config(dev, cptr + 4, 4);
- if (r & DC_PSTATE_D3) {
- u_int32_t iobase, membase, irq;
-
- /* Save important PCI config data. */
- iobase = pci_read_config(dev, DC_PCI_CFBIO, 4);
- membase = pci_read_config(dev, DC_PCI_CFBMA, 4);
- irq = pci_read_config(dev, DC_PCI_CFIT, 4);
-
- /* Reset the power state. */
- printf("dc%d: chip is in D%d power mode "
- "-- setting to D0\n", unit, r & DC_PSTATE_D3);
- r &= 0xFFFFFFFC;
- pci_write_config(dev, cptr + 4, r, 4);
-
- /* Restore PCI config data. */
- pci_write_config(dev, DC_PCI_CFBIO, iobase, 4);
- pci_write_config(dev, DC_PCI_CFBMA, membase, 4);
- pci_write_config(dev, DC_PCI_CFIT, irq, 4);
- }
- }
- return;
-}
-
-/*
- * Attach the interface. Allocate softc structures, do ifmedia
- * setup and ethernet/BPF attach.
- */
-static int dc_attach(dev)
- device_t dev;
-{
- int s;
- u_char eaddr[ETHER_ADDR_LEN];
- u_int32_t command;
- struct dc_softc *sc;
- struct ifnet *ifp;
- u_int32_t revision;
- int unit, error = 0, rid, mac_offset;
-
- s = splimp();
-
- sc = device_get_softc(dev);
- unit = device_get_unit(dev);
- bzero(sc, sizeof(struct dc_softc));
-
- /*
- * Handle power management nonsense.
- */
- dc_acpi(dev);
-
- /*
- * Map control/status registers.
- */
- command = pci_read_config(dev, PCI_COMMAND_STATUS_REG, 4);
- command |= (PCIM_CMD_PORTEN|PCIM_CMD_MEMEN|PCIM_CMD_BUSMASTEREN);
- pci_write_config(dev, PCI_COMMAND_STATUS_REG, command, 4);
- command = pci_read_config(dev, PCI_COMMAND_STATUS_REG, 4);
-
-#ifdef DC_USEIOSPACE
- if (!(command & PCIM_CMD_PORTEN)) {
- printf("dc%d: failed to enable I/O ports!\n", unit);
- error = ENXIO;
- goto fail;
- }
-#else
- if (!(command & PCIM_CMD_MEMEN)) {
- printf("dc%d: failed to enable memory mapping!\n", unit);
- error = ENXIO;
- goto fail;
- }
-#endif
-
- rid = DC_RID;
- sc->dc_res = bus_alloc_resource(dev, DC_RES, &rid,
- 0, ~0, 1, RF_ACTIVE);
-
- if (sc->dc_res == NULL) {
- printf("dc%d: couldn't map ports/memory\n", unit);
- error = ENXIO;
- goto fail;
- }
-
- sc->dc_btag = rman_get_bustag(sc->dc_res);
- sc->dc_bhandle = rman_get_bushandle(sc->dc_res);
-
- /* Allocate interrupt */
- rid = 0;
- sc->dc_irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1,
- RF_SHAREABLE | RF_ACTIVE);
-
- if (sc->dc_irq == NULL) {
- printf("dc%d: couldn't map interrupt\n", unit);
- bus_release_resource(dev, DC_RES, DC_RID, sc->dc_res);
- error = ENXIO;
- goto fail;
- }
-
- error = bus_setup_intr(dev, sc->dc_irq, INTR_TYPE_NET,
- dc_intr, sc, &sc->dc_intrhand);
-
- if (error) {
- bus_release_resource(dev, SYS_RES_IRQ, 0, sc->dc_irq);
- bus_release_resource(dev, DC_RES, DC_RID, sc->dc_res);
- printf("dc%d: couldn't set up irq\n", unit);
- goto fail;
- }
-
- /* Need this info to decide on a chip type. */
- sc->dc_info = dc_devtype(dev);
- revision = pci_read_config(dev, DC_PCI_CFRV, 4) & 0x000000FF;
-
- switch(sc->dc_info->dc_did) {
- case DC_DEVICEID_21143:
- sc->dc_type = DC_TYPE_21143;
- sc->dc_flags |= DC_TX_POLL|DC_TX_USE_TX_INTR;
- sc->dc_flags |= DC_REDUCED_MII_POLL;
- break;
- case DC_DEVICEID_DM9100:
- case DC_DEVICEID_DM9102:
- sc->dc_type = DC_TYPE_DM9102;
- sc->dc_flags |= DC_TX_COALESCE|DC_TX_USE_TX_INTR;
- sc->dc_flags |= DC_REDUCED_MII_POLL;
- sc->dc_pmode = DC_PMODE_MII;
- break;
- case DC_DEVICEID_AL981:
- sc->dc_type = DC_TYPE_AL981;
- sc->dc_flags |= DC_TX_USE_TX_INTR;
- sc->dc_flags |= DC_TX_ADMTEK_WAR;
- sc->dc_pmode = DC_PMODE_MII;
- break;
- case DC_DEVICEID_AN985:
- sc->dc_type = DC_TYPE_AN985;
- sc->dc_flags |= DC_TX_USE_TX_INTR;
- sc->dc_flags |= DC_TX_ADMTEK_WAR;
- sc->dc_pmode = DC_PMODE_MII;
- break;
- case DC_DEVICEID_98713:
- case DC_DEVICEID_98713_CP:
- if (revision < DC_REVISION_98713A) {
- sc->dc_type = DC_TYPE_98713;
- sc->dc_flags |= DC_REDUCED_MII_POLL;
- }
- if (revision >= DC_REVISION_98713A)
- sc->dc_type = DC_TYPE_98713A;
- sc->dc_flags |= DC_TX_POLL|DC_TX_USE_TX_INTR;
- break;
- case DC_DEVICEID_987x5:
- sc->dc_type = DC_TYPE_987x5;
- sc->dc_flags |= DC_TX_POLL|DC_TX_USE_TX_INTR;
- break;
- case DC_DEVICEID_82C115:
- sc->dc_type = DC_TYPE_PNICII;
- sc->dc_flags |= DC_TX_POLL|DC_TX_USE_TX_INTR;
- break;
- case DC_DEVICEID_82C168:
- sc->dc_type = DC_TYPE_PNIC;
- sc->dc_flags |= DC_TX_STORENFWD|DC_TX_INTR_ALWAYS;
- sc->dc_flags |= DC_PNIC_RX_BUG_WAR;
- sc->dc_pnic_rx_buf = malloc(DC_RXLEN * 5, M_DEVBUF, M_NOWAIT);
- if (revision < DC_REVISION_82C169)
- sc->dc_pmode = DC_PMODE_SYM;
- break;
- case DC_DEVICEID_AX88140A:
- sc->dc_type = DC_TYPE_ASIX;
- sc->dc_flags |= DC_TX_USE_TX_INTR|DC_TX_INTR_FIRSTFRAG;
- sc->dc_flags |= DC_REDUCED_MII_POLL;
- sc->dc_pmode = DC_PMODE_MII;
- break;
- default:
- printf("dc%d: unknown device: %x\n", sc->dc_unit,
- sc->dc_info->dc_did);
- break;
- }
-
- /* Save the cache line size. */
- if (DC_IS_DAVICOM(sc))
- sc->dc_cachesize = 0;
- else
- sc->dc_cachesize = pci_read_config(dev,
- DC_PCI_CFLT, 4) & 0xFF;
-
- /* Reset the adapter. */
- dc_reset(sc);
-
- /* Take 21143 out of snooze mode */
- if (DC_IS_INTEL(sc)) {
- command = pci_read_config(dev, DC_PCI_CFDD, 4);
- command &= ~(DC_CFDD_SNOOZE_MODE|DC_CFDD_SLEEP_MODE);
- pci_write_config(dev, DC_PCI_CFDD, command, 4);
- }
-
- /*
- * Try to learn something about the supported media.
- * We know that ASIX and ADMtek and Davicom devices
- * will *always* be using MII media, so that's a no-brainer.
- * The tricky ones are the Macronix/PNIC II and the
- * Intel 21143.
- */
- if (DC_IS_INTEL(sc)) {
- u_int32_t media, cwuc;
- cwuc = pci_read_config(dev, DC_PCI_CWUC, 4);
- cwuc |= DC_CWUC_FORCE_WUL;
- pci_write_config(dev, DC_PCI_CWUC, cwuc, 4);
- DELAY(10000);
- media = pci_read_config(dev, DC_PCI_CWUC, 4);
- cwuc &= ~DC_CWUC_FORCE_WUL;
- pci_write_config(dev, DC_PCI_CWUC, cwuc, 4);
- DELAY(10000);
- if (media & DC_CWUC_MII_ABILITY)
- sc->dc_pmode = DC_PMODE_MII;
- if (media & DC_CWUC_SYM_ABILITY)
- sc->dc_pmode = DC_PMODE_SYM;
- /*
- * If none of the bits are set, then this NIC
- * isn't meant to support 'wake up LAN' mode.
- * This is usually only the case on multiport
- * cards, and these cards almost always have
- * MII transceivers.
- */
- if (media == 0)
- sc->dc_pmode = DC_PMODE_MII;
- } else if (DC_IS_MACRONIX(sc) || DC_IS_PNICII(sc)) {
- if (sc->dc_type == DC_TYPE_98713)
- sc->dc_pmode = DC_PMODE_MII;
- else
- sc->dc_pmode = DC_PMODE_SYM;
- } else if (!sc->dc_pmode)
- sc->dc_pmode = DC_PMODE_MII;
-
- /*
- * Get station address from the EEPROM.
- */
- switch(sc->dc_type) {
- case DC_TYPE_98713:
- case DC_TYPE_98713A:
- case DC_TYPE_987x5:
- case DC_TYPE_PNICII:
- dc_read_eeprom(sc, (caddr_t)&mac_offset,
- (DC_EE_NODEADDR_OFFSET / 2), 1, 0);
- dc_read_eeprom(sc, (caddr_t)&eaddr, (mac_offset / 2), 3, 0);
- break;
- case DC_TYPE_PNIC:
- dc_read_eeprom(sc, (caddr_t)&eaddr, 0, 3, 1);
- break;
- case DC_TYPE_DM9102:
- case DC_TYPE_21143:
- case DC_TYPE_ASIX:
- dc_read_eeprom(sc, (caddr_t)&eaddr, DC_EE_NODEADDR, 3, 0);
- break;
- case DC_TYPE_AL981:
- case DC_TYPE_AN985:
- dc_read_eeprom(sc, (caddr_t)&eaddr, DC_AL_EE_NODEADDR, 3, 0);
- break;
- default:
- dc_read_eeprom(sc, (caddr_t)&eaddr, DC_EE_NODEADDR, 3, 0);
- break;
- }
-
- /*
- * A 21143 or clone chip was detected. Inform the world.
- */
- printf("dc%d: Ethernet address: %6D\n", unit, eaddr, ":");
-
- sc->dc_unit = unit;
- bcopy(eaddr, (char *)&sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
-
- sc->dc_ldata = contigmalloc(sizeof(struct dc_list_data), M_DEVBUF,
- M_NOWAIT, 0, 0xffffffff, PAGE_SIZE, 0);
-
- if (sc->dc_ldata == NULL) {
- printf("dc%d: no memory for list buffers!\n", unit);
- bus_teardown_intr(dev, sc->dc_irq, sc->dc_intrhand);
- bus_release_resource(dev, SYS_RES_IRQ, 0, sc->dc_irq);
- bus_release_resource(dev, DC_RES, DC_RID, sc->dc_res);
- error = ENXIO;
- goto fail;
- }
-
- bzero(sc->dc_ldata, sizeof(struct dc_list_data));
-
- ifp = &sc->arpcom.ac_if;
- ifp->if_softc = sc;
- ifp->if_unit = unit;
- ifp->if_name = "dc";
- ifp->if_mtu = ETHERMTU;
- ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
- ifp->if_ioctl = dc_ioctl;
- ifp->if_output = ether_output;
- ifp->if_start = dc_start;
- ifp->if_watchdog = dc_watchdog;
- ifp->if_init = dc_init;
- ifp->if_baudrate = 10000000;
- ifp->if_snd.ifq_maxlen = DC_TX_LIST_CNT - 1;
-
- /*
- * Do MII setup.
- */
- error = mii_phy_probe(dev, &sc->dc_miibus,
- dc_ifmedia_upd, dc_ifmedia_sts);
-
- if (error && DC_IS_INTEL(sc)) {
- sc->dc_pmode = DC_PMODE_SYM;
- mii_phy_probe(dev, &sc->dc_miibus,
- dc_ifmedia_upd, dc_ifmedia_sts);
- error = 0;
- }
-
- if (error) {
- printf("dc%d: MII without any PHY!\n", sc->dc_unit);
- bus_teardown_intr(dev, sc->dc_irq, sc->dc_intrhand);
- bus_release_resource(dev, SYS_RES_IRQ, 0, sc->dc_irq);
- bus_release_resource(dev, DC_RES, DC_RID, sc->dc_res);
- error = ENXIO;
- goto fail;
- }
-
- /*
- * Call MI attach routines.
- */
- if_attach(ifp);
- ether_ifattach(ifp);
- callout_handle_init(&sc->dc_stat_ch);
-
- bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
-
-#ifdef __alpha__
- sc->dc_srm_media = 0;
-
- /* Remember the SRM console media setting */
- if (DC_IS_INTEL(sc)) {
- command = pci_read_config(dev, DC_PCI_CFDD, 4);
- command &= ~(DC_CFDD_SNOOZE_MODE|DC_CFDD_SLEEP_MODE);
- switch ((command >> 8) & 0xff) {
- case 3:
- sc->dc_srm_media = IFM_10_T;
- break;
- case 4:
- sc->dc_srm_media = IFM_10_T | IFM_FDX;
- break;
- case 5:
- sc->dc_srm_media = IFM_100_TX;
- break;
- case 6:
- sc->dc_srm_media = IFM_100_TX | IFM_FDX;
- break;
- }
- if (sc->dc_srm_media)
- sc->dc_srm_media |= IFM_ACTIVE | IFM_ETHER;
- }
-#endif
-
-
-fail:
- splx(s);
-
- return(error);
-}
-
-static int dc_detach(dev)
- device_t dev;
-{
- struct dc_softc *sc;
- struct ifnet *ifp;
- int s;
-
- s = splimp();
-
- sc = device_get_softc(dev);
- ifp = &sc->arpcom.ac_if;
-
- dc_stop(sc);
- if_detach(ifp);
-
- bus_generic_detach(dev);
- device_delete_child(dev, sc->dc_miibus);
-
- bus_teardown_intr(dev, sc->dc_irq, sc->dc_intrhand);
- bus_release_resource(dev, SYS_RES_IRQ, 0, sc->dc_irq);
- bus_release_resource(dev, DC_RES, DC_RID, sc->dc_res);
-
- contigfree(sc->dc_ldata, sizeof(struct dc_list_data), M_DEVBUF);
- if (sc->dc_pnic_rx_buf != NULL)
- free(sc->dc_pnic_rx_buf, M_DEVBUF);
-
- splx(s);
-
- return(0);
-}
-
-/*
- * Initialize the transmit descriptors.
- */
-static int dc_list_tx_init(sc)
- struct dc_softc *sc;
-{
- struct dc_chain_data *cd;
- struct dc_list_data *ld;
- int i;
-
- cd = &sc->dc_cdata;
- ld = sc->dc_ldata;
- for (i = 0; i < DC_TX_LIST_CNT; i++) {
- if (i == (DC_TX_LIST_CNT - 1)) {
- ld->dc_tx_list[i].dc_next =
- vtophys(&ld->dc_tx_list[0]);
- } else {
- ld->dc_tx_list[i].dc_next =
- vtophys(&ld->dc_tx_list[i + 1]);
- }
- cd->dc_tx_chain[i] = NULL;
- ld->dc_tx_list[i].dc_data = 0;
- ld->dc_tx_list[i].dc_ctl = 0;
- }
-
- cd->dc_tx_prod = cd->dc_tx_cons = cd->dc_tx_cnt = 0;
-
- return(0);
-}
-
-
-/*
- * Initialize the RX descriptors and allocate mbufs for them. Note that
- * we arrange the descriptors in a closed ring, so that the last descriptor
- * points back to the first.
- */
-static int dc_list_rx_init(sc)
- struct dc_softc *sc;
-{
- struct dc_chain_data *cd;
- struct dc_list_data *ld;
- int i;
-
- cd = &sc->dc_cdata;
- ld = sc->dc_ldata;
-
- for (i = 0; i < DC_RX_LIST_CNT; i++) {
- if (dc_newbuf(sc, i, NULL) == ENOBUFS)
- return(ENOBUFS);
- if (i == (DC_RX_LIST_CNT - 1)) {
- ld->dc_rx_list[i].dc_next =
- vtophys(&ld->dc_rx_list[0]);
- } else {
- ld->dc_rx_list[i].dc_next =
- vtophys(&ld->dc_rx_list[i + 1]);
- }
- }
-
- cd->dc_rx_prod = 0;
-
- return(0);
-}
-
-/*
- * Initialize an RX descriptor and attach an MBUF cluster.
- */
-static int dc_newbuf(sc, i, m)
- struct dc_softc *sc;
- int i;
- struct mbuf *m;
-{
- struct mbuf *m_new = NULL;
- struct dc_desc *c;
-
- c = &sc->dc_ldata->dc_rx_list[i];
-
- if (m == NULL) {
- MGETHDR(m_new, M_DONTWAIT, MT_DATA);
- if (m_new == NULL) {
- printf("dc%d: no memory for rx list "
- "-- packet dropped!\n", sc->dc_unit);
- return(ENOBUFS);
- }
-
- MCLGET(m_new, M_DONTWAIT);
- if (!(m_new->m_flags & M_EXT)) {
- printf("dc%d: no memory for rx list "
- "-- packet dropped!\n", sc->dc_unit);
- m_freem(m_new);
- return(ENOBUFS);
- }
- m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
- } else {
- m_new = m;
- m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
- m_new->m_data = m_new->m_ext.ext_buf;
- }
-
- m_adj(m_new, sizeof(u_int64_t));
-
- /*
- * If this is a PNIC chip, zero the buffer. This is part
- * of the workaround for the receive bug in the 82c168 and
- * 82c169 chips.
- */
- if (sc->dc_flags & DC_PNIC_RX_BUG_WAR)
- bzero((char *)mtod(m_new, char *), m_new->m_len);
-
- sc->dc_cdata.dc_rx_chain[i] = m_new;
- c->dc_data = vtophys(mtod(m_new, caddr_t));
- c->dc_ctl = DC_RXCTL_RLINK | DC_RXLEN;
- c->dc_status = DC_RXSTAT_OWN;
-
- return(0);
-}
-
-/*
- * Grrrrr.
- * The PNIC chip has a terrible bug in it that manifests itself during
- * periods of heavy activity. The exact mode of failure if difficult to
- * pinpoint: sometimes it only happens in promiscuous mode, sometimes it
- * will happen on slow machines. The bug is that sometimes instead of
- * uploading one complete frame during reception, it uploads what looks
- * like the entire contents of its FIFO memory. The frame we want is at
- * the end of the whole mess, but we never know exactly how much data has
- * been uploaded, so salvaging the frame is hard.
- *
- * There is only one way to do it reliably, and it's disgusting.
- * Here's what we know:
- *
- * - We know there will always be somewhere between one and three extra
- * descriptors uploaded.
- *
- * - We know the desired received frame will always be at the end of the
- * total data upload.
- *
- * - We know the size of the desired received frame because it will be
- * provided in the length field of the status word in the last descriptor.
- *
- * Here's what we do:
- *
- * - When we allocate buffers for the receive ring, we bzero() them.
- * This means that we know that the buffer contents should be all
- * zeros, except for data uploaded by the chip.
- *
- * - We also force the PNIC chip to upload frames that include the
- * ethernet CRC at the end.
- *
- * - We gather all of the bogus frame data into a single buffer.
- *
- * - We then position a pointer at the end of this buffer and scan
- * backwards until we encounter the first non-zero byte of data.
- * This is the end of the received frame. We know we will encounter
- * some data at the end of the frame because the CRC will always be
- * there, so even if the sender transmits a packet of all zeros,
- * we won't be fooled.
- *
- * - We know the size of the actual received frame, so we subtract
- * that value from the current pointer location. This brings us
- * to the start of the actual received packet.
- *
- * - We copy this into an mbuf and pass it on, along with the actual
- * frame length.
- *
- * The performance hit is tremendous, but it beats dropping frames all
- * the time.
- */
-
-#define DC_WHOLEFRAME (DC_RXSTAT_FIRSTFRAG|DC_RXSTAT_LASTFRAG)
-static void dc_pnic_rx_bug_war(sc, idx)
- struct dc_softc *sc;
- int idx;
-{
- struct dc_desc *cur_rx;
- struct dc_desc *c = NULL;
- struct mbuf *m = NULL;
- unsigned char *ptr;
- int i, total_len;
- u_int32_t rxstat = 0;
-
- i = sc->dc_pnic_rx_bug_save;
- cur_rx = &sc->dc_ldata->dc_rx_list[idx];
- ptr = sc->dc_pnic_rx_buf;
- bzero(ptr, sizeof(DC_RXLEN * 5));
-
- /* Copy all the bytes from the bogus buffers. */
- while (1) {
- c = &sc->dc_ldata->dc_rx_list[i];
- rxstat = c->dc_status;
- m = sc->dc_cdata.dc_rx_chain[i];
- bcopy(mtod(m, char *), ptr, DC_RXLEN);
- ptr += DC_RXLEN;
- /* If this is the last buffer, break out. */
- if (i == idx || rxstat & DC_RXSTAT_LASTFRAG)
- break;
- dc_newbuf(sc, i, m);
- DC_INC(i, DC_RX_LIST_CNT);
- }
-
- /* Find the length of the actual receive frame. */
- total_len = DC_RXBYTES(rxstat);
-
- /* Scan backwards until we hit a non-zero byte. */
- while(*ptr == 0x00)
- ptr--;
-
- /* Round off. */
- if ((uintptr_t)(ptr) & 0x3)
- ptr -= 1;
-
- /* Now find the start of the frame. */
- ptr -= total_len;
- if (ptr < sc->dc_pnic_rx_buf)
- ptr = sc->dc_pnic_rx_buf;
-
- /*
- * Now copy the salvaged frame to the last mbuf and fake up
- * the status word to make it look like a successful
- * frame reception.
- */
- dc_newbuf(sc, i, m);
- bcopy(ptr, mtod(m, char *), total_len);
- cur_rx->dc_status = rxstat | DC_RXSTAT_FIRSTFRAG;
-
- return;
-}
-
-/*
- * This routine searches the RX ring for dirty descriptors in the
- * event that the rxeof routine falls out of sync with the chip's
- * current descriptor pointer. This may happen sometimes as a result
- * of a "no RX buffer available" condition that happens when the chip
- * consumes all of the RX buffers before the driver has a chance to
- * process the RX ring. This routine may need to be called more than
- * once to bring the driver back in sync with the chip, however we
- * should still be getting RX DONE interrupts to drive the search
- * for new packets in the RX ring, so we should catch up eventually.
- */
-static int dc_rx_resync(sc)
- struct dc_softc *sc;
-{
- int i, pos;
- struct dc_desc *cur_rx;
-
- pos = sc->dc_cdata.dc_rx_prod;
-
- for (i = 0; i < DC_RX_LIST_CNT; i++) {
- cur_rx = &sc->dc_ldata->dc_rx_list[pos];
- if (!(cur_rx->dc_status & DC_RXSTAT_OWN))
- break;
- DC_INC(pos, DC_RX_LIST_CNT);
- }
-
- /* If the ring really is empty, then just return. */
- if (i == DC_RX_LIST_CNT)
- return(0);
-
- /* We've fallen behing the chip: catch it. */
- sc->dc_cdata.dc_rx_prod = pos;
-
- return(EAGAIN);
-}
-
-/*
- * A frame has been uploaded: pass the resulting mbuf chain up to
- * the higher level protocols.
- */
-static void dc_rxeof(sc)
- struct dc_softc *sc;
-{
- struct ether_header *eh;
- struct mbuf *m;
- struct ifnet *ifp;
- struct dc_desc *cur_rx;
- int i, total_len = 0;
- u_int32_t rxstat;
-
- ifp = &sc->arpcom.ac_if;
- i = sc->dc_cdata.dc_rx_prod;
-
- while(!(sc->dc_ldata->dc_rx_list[i].dc_status & DC_RXSTAT_OWN)) {
- struct mbuf *m0 = NULL;
-
- cur_rx = &sc->dc_ldata->dc_rx_list[i];
- rxstat = cur_rx->dc_status;
- m = sc->dc_cdata.dc_rx_chain[i];
- total_len = DC_RXBYTES(rxstat);
-
- if (sc->dc_flags & DC_PNIC_RX_BUG_WAR) {
- if ((rxstat & DC_WHOLEFRAME) != DC_WHOLEFRAME) {
- if (rxstat & DC_RXSTAT_FIRSTFRAG)
- sc->dc_pnic_rx_bug_save = i;
- if ((rxstat & DC_RXSTAT_LASTFRAG) == 0) {
- DC_INC(i, DC_RX_LIST_CNT);
- continue;
- }
- dc_pnic_rx_bug_war(sc, i);
- rxstat = cur_rx->dc_status;
- total_len = DC_RXBYTES(rxstat);
- }
- }
-
- sc->dc_cdata.dc_rx_chain[i] = NULL;
-
- /*
- * If an error occurs, update stats, clear the
- * status word and leave the mbuf cluster in place:
- * it should simply get re-used next time this descriptor
- * comes up in the ring.
- */
- if (rxstat & DC_RXSTAT_RXERR) {
- ifp->if_ierrors++;
- if (rxstat & DC_RXSTAT_COLLSEEN)
- ifp->if_collisions++;
- dc_newbuf(sc, i, m);
- if (rxstat & DC_RXSTAT_CRCERR) {
- DC_INC(i, DC_RX_LIST_CNT);
- continue;
- } else {
- dc_init(sc);
- return;
- }
- }
-
- /* No errors; receive the packet. */
- total_len -= ETHER_CRC_LEN;
-
- m0 = m_devget(mtod(m, char *) - ETHER_ALIGN,
- total_len + ETHER_ALIGN, 0, ifp, NULL);
- dc_newbuf(sc, i, m);
- DC_INC(i, DC_RX_LIST_CNT);
- if (m0 == NULL) {
- ifp->if_ierrors++;
- continue;
- }
- m_adj(m0, ETHER_ALIGN);
- m = m0;
-
- ifp->if_ipackets++;
- eh = mtod(m, struct ether_header *);
-
- /* Handle BPF listeners. Let the BPF user see the packet */
- if (ifp->if_bpf)
- bpf_mtap(ifp, m);
-
-#ifdef BRIDGE
- if (do_bridge) {
- struct ifnet *bdg_ifp ;
- bdg_ifp = bridge_in(m);
- if (bdg_ifp != BDG_LOCAL && bdg_ifp != BDG_DROP)
- bdg_forward(&m, bdg_ifp);
- if (((bdg_ifp != BDG_LOCAL) && (bdg_ifp != BDG_BCAST) && (bdg_ifp != BDG_MCAST)) || bdg_ifp == BDG_DROP) {
- m_freem(m);
- continue;
- }
- }
-
- eh = mtod(m, struct ether_header *);
-#endif
-
- /* Don't pass it up to the ether_input() layer unless it's
- * a broadcast packet, multicast packet, matches our ethernet
- * address or the interface is in promiscuous mode.
- */
- if (ifp->if_bpf) {
- if (ifp->if_flags & IFF_PROMISC &&
- (bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr,
- ETHER_ADDR_LEN) &&
- (eh->ether_dhost[0] & 1) == 0)) {
- m_freem(m);
- continue;
- }
- }
-
- /* Remove header from mbuf and pass it on. */
- m_adj(m, sizeof(struct ether_header));
- ether_input(ifp, eh, m);
- }
-
- sc->dc_cdata.dc_rx_prod = i;
-
- return;
-}
-
-/*
- * A frame was downloaded to the chip. It's safe for us to clean up
- * the list buffers.
- */
-
-static void dc_txeof(sc)
- struct dc_softc *sc;
-{
- struct dc_desc *cur_tx = NULL;
- struct ifnet *ifp;
- int idx;
-
- ifp = &sc->arpcom.ac_if;
-
- /* Clear the timeout timer. */
- ifp->if_timer = 0;
-
- /*
- * Go through our tx list and free mbufs for those
- * frames that have been transmitted.
- */
- idx = sc->dc_cdata.dc_tx_cons;
- while(idx != sc->dc_cdata.dc_tx_prod) {
- u_int32_t txstat;
-
- cur_tx = &sc->dc_ldata->dc_tx_list[idx];
- txstat = cur_tx->dc_status;
-
- if (txstat & DC_TXSTAT_OWN)
- break;
-
- if (!(cur_tx->dc_ctl & DC_TXCTL_LASTFRAG) ||
- cur_tx->dc_ctl & DC_TXCTL_SETUP) {
- sc->dc_cdata.dc_tx_cnt--;
- if (cur_tx->dc_ctl & DC_TXCTL_SETUP) {
- /*
- * Yes, the PNIC is so brain damaged
- * that it will sometimes generate a TX
- * underrun error while DMAing the RX
- * filter setup frame. If we detect this,
- * we have to send the setup frame again,
- * or else the filter won't be programmed
- * correctly.
- */
- if (DC_IS_PNIC(sc)) {
- if (txstat & DC_TXSTAT_ERRSUM)
- dc_setfilt(sc);
- }
- sc->dc_cdata.dc_tx_chain[idx] = NULL;
- }
- DC_INC(idx, DC_TX_LIST_CNT);
- continue;
- }
-
- if (/*sc->dc_type == DC_TYPE_21143 &&*/
- sc->dc_pmode == DC_PMODE_MII &&
- ((txstat & 0xFFFF) & ~(DC_TXSTAT_ERRSUM|
- DC_TXSTAT_NOCARRIER|DC_TXSTAT_CARRLOST)))
- txstat &= ~DC_TXSTAT_ERRSUM;
-
- if (txstat & DC_TXSTAT_ERRSUM) {
- ifp->if_oerrors++;
- if (txstat & DC_TXSTAT_EXCESSCOLL)
- ifp->if_collisions++;
- if (txstat & DC_TXSTAT_LATECOLL)
- ifp->if_collisions++;
- if (!(txstat & DC_TXSTAT_UNDERRUN)) {
- dc_init(sc);
- return;
- }
- }
-
- ifp->if_collisions += (txstat & DC_TXSTAT_COLLCNT) >> 3;
-
- ifp->if_opackets++;
- if (sc->dc_cdata.dc_tx_chain[idx] != NULL) {
- m_freem(sc->dc_cdata.dc_tx_chain[idx]);
- sc->dc_cdata.dc_tx_chain[idx] = NULL;
- }
-
- sc->dc_cdata.dc_tx_cnt--;
- DC_INC(idx, DC_TX_LIST_CNT);
- }
-
- sc->dc_cdata.dc_tx_cons = idx;
- if (cur_tx != NULL)
- ifp->if_flags &= ~IFF_OACTIVE;
-
- return;
-}
-
-static void dc_tick(xsc)
- void *xsc;
-{
- struct dc_softc *sc;
- struct mii_data *mii;
- struct ifnet *ifp;
- int s;
- u_int32_t r;
-
- s = splimp();
-
- sc = xsc;
- ifp = &sc->arpcom.ac_if;
- mii = device_get_softc(sc->dc_miibus);
-
- if (sc->dc_flags & DC_REDUCED_MII_POLL) {
- r = CSR_READ_4(sc, DC_ISR);
- if (DC_IS_INTEL(sc)) {
- if (r & DC_ISR_LINKFAIL)
- sc->dc_link = 0;
- if (sc->dc_link == 0)
- mii_tick(mii);
- } else {
- if ((r & DC_ISR_RX_STATE) == DC_RXSTATE_WAIT &&
- sc->dc_cdata.dc_tx_prod == 0)
- mii_tick(mii);
- }
- } else
- mii_tick(mii);
-
- /*
- * When the init routine completes, we expect to be able to send
- * packets right away, and in fact the network code will send a
- * gratuitous ARP the moment the init routine marks the interface
- * as running. However, even though the MAC may have been initialized,
- * there may be a delay of a few seconds before the PHY completes
- * autonegotiation and the link is brought up. Any transmissions
- * made during that delay will be lost. Dealing with this is tricky:
- * we can't just pause in the init routine while waiting for the
- * PHY to come ready since that would bring the whole system to
- * a screeching halt for several seconds.
- *
- * What we do here is prevent the TX start routine from sending
- * any packets until a link has been established. After the
- * interface has been initialized, the tick routine will poll
- * the state of the PHY until the IFM_ACTIVE flag is set. Until
- * that time, packets will stay in the send queue, and once the
- * link comes up, they will be flushed out to the wire.
- */
- if (!sc->dc_link) {
- mii_pollstat(mii);
- if (mii->mii_media_status & IFM_ACTIVE &&
- IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE) {
- sc->dc_link++;
- if (ifp->if_snd.ifq_head != NULL)
- dc_start(ifp);
- }
- }
-
- sc->dc_stat_ch = timeout(dc_tick, sc, hz);
-
- splx(s);
-
- return;
-}
-
-static void dc_intr(arg)
- void *arg;
-{
- struct dc_softc *sc;
- struct ifnet *ifp;
- u_int32_t status;
-
- sc = arg;
- ifp = &sc->arpcom.ac_if;
-
- /* Supress unwanted interrupts */
- if (!(ifp->if_flags & IFF_UP)) {
- if (CSR_READ_4(sc, DC_ISR) & DC_INTRS)
- dc_stop(sc);
- return;
- }
-
- /* Disable interrupts. */
- CSR_WRITE_4(sc, DC_IMR, 0x00000000);
-
- while((status = CSR_READ_4(sc, DC_ISR)) & DC_INTRS) {
-
- CSR_WRITE_4(sc, DC_ISR, status);
-
- if (status & DC_ISR_RX_OK) {
- int curpkts;
- curpkts = ifp->if_ipackets;
- dc_rxeof(sc);
- if (curpkts == ifp->if_ipackets) {
- while(dc_rx_resync(sc))
- dc_rxeof(sc);
- }
- }
-
- if (status & (DC_ISR_TX_OK|DC_ISR_TX_NOBUF))
- dc_txeof(sc);
-
- if (status & DC_ISR_TX_IDLE) {
- dc_txeof(sc);
- if (sc->dc_cdata.dc_tx_cnt) {
- DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_TX_ON);
- CSR_WRITE_4(sc, DC_TXSTART, 0xFFFFFFFF);
- }
- }
-
- if (status & DC_ISR_TX_UNDERRUN) {
- u_int32_t cfg;
-
- printf("dc%d: TX underrun -- ", sc->dc_unit);
- if (DC_IS_DAVICOM(sc) || DC_IS_INTEL(sc))
- dc_init(sc);
- cfg = CSR_READ_4(sc, DC_NETCFG);
- cfg &= ~DC_NETCFG_TX_THRESH;
- if (sc->dc_txthresh == DC_TXTHRESH_160BYTES) {
- printf("using store and forward mode\n");
- DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_STORENFWD);
- } else if (sc->dc_flags & DC_TX_STORENFWD) {
- printf("resetting\n");
- } else {
- sc->dc_txthresh += 0x4000;
- printf("increasing TX threshold\n");
- CSR_WRITE_4(sc, DC_NETCFG, cfg);
- DC_SETBIT(sc, DC_NETCFG, sc->dc_txthresh);
- DC_CLRBIT(sc, DC_NETCFG, DC_NETCFG_STORENFWD);
- }
- }
-
- if ((status & DC_ISR_RX_WATDOGTIMEO)
- || (status & DC_ISR_RX_NOBUF)) {
- int curpkts;
- curpkts = ifp->if_ipackets;
- dc_rxeof(sc);
- if (curpkts == ifp->if_ipackets) {
- while(dc_rx_resync(sc))
- dc_rxeof(sc);
- }
- }
-
- if (status & DC_ISR_BUS_ERR) {
- dc_reset(sc);
- dc_init(sc);
- }
- }
-
- /* Re-enable interrupts. */
- CSR_WRITE_4(sc, DC_IMR, DC_INTRS);
-
- if (ifp->if_snd.ifq_head != NULL)
- dc_start(ifp);
-
- return;
-}
-
-/*
- * Encapsulate an mbuf chain in a descriptor by coupling the mbuf data
- * pointers to the fragment pointers.
- */
-static int dc_encap(sc, m_head, txidx)
- struct dc_softc *sc;
- struct mbuf *m_head;
- u_int32_t *txidx;
-{
- struct dc_desc *f = NULL;
- struct mbuf *m;
- int frag, cur, cnt = 0;
-
- /*
- * Start packing the mbufs in this chain into
- * the fragment pointers. Stop when we run out
- * of fragments or hit the end of the mbuf chain.
- */
- m = m_head;
- cur = frag = *txidx;
-
- for (m = m_head; m != NULL; m = m->m_next) {
- if (m->m_len != 0) {
- if (sc->dc_flags & DC_TX_ADMTEK_WAR) {
- if (*txidx != sc->dc_cdata.dc_tx_prod &&
- frag == (DC_TX_LIST_CNT - 1))
- return(ENOBUFS);
- }
- if ((DC_TX_LIST_CNT -
- (sc->dc_cdata.dc_tx_cnt + cnt)) < 5)
- return(ENOBUFS);
-
- f = &sc->dc_ldata->dc_tx_list[frag];
- f->dc_ctl = DC_TXCTL_TLINK | m->m_len;
- if (cnt == 0) {
- f->dc_status = 0;
- f->dc_ctl |= DC_TXCTL_FIRSTFRAG;
- } else
- f->dc_status = DC_TXSTAT_OWN;
- f->dc_data = vtophys(mtod(m, vm_offset_t));
- cur = frag;
- DC_INC(frag, DC_TX_LIST_CNT);
- cnt++;
- }
- }
-
- if (m != NULL)
- return(ENOBUFS);
-
- sc->dc_cdata.dc_tx_cnt += cnt;
- sc->dc_cdata.dc_tx_chain[cur] = m_head;
- sc->dc_ldata->dc_tx_list[cur].dc_ctl |= DC_TXCTL_LASTFRAG;
- if (sc->dc_flags & DC_TX_INTR_FIRSTFRAG)
- sc->dc_ldata->dc_tx_list[*txidx].dc_ctl |= DC_TXCTL_FINT;
- if (sc->dc_flags & DC_TX_INTR_ALWAYS)
- sc->dc_ldata->dc_tx_list[cur].dc_ctl |= DC_TXCTL_FINT;
- if (sc->dc_flags & DC_TX_USE_TX_INTR && sc->dc_cdata.dc_tx_cnt > 64)
- sc->dc_ldata->dc_tx_list[cur].dc_ctl |= DC_TXCTL_FINT;
- sc->dc_ldata->dc_tx_list[*txidx].dc_status = DC_TXSTAT_OWN;
- *txidx = frag;
-
- return(0);
-}
-
-/*
- * Coalesce an mbuf chain into a single mbuf cluster buffer.
- * Needed for some really badly behaved chips that just can't
- * do scatter/gather correctly.
- */
-static int dc_coal(sc, m_head)
- struct dc_softc *sc;
- struct mbuf **m_head;
-{
- struct mbuf *m_new, *m;
-
- m = *m_head;
- MGETHDR(m_new, M_DONTWAIT, MT_DATA);
- if (m_new == NULL) {
- printf("dc%d: no memory for tx list", sc->dc_unit);
- return(ENOBUFS);
- }
- if (m->m_pkthdr.len > MHLEN) {
- MCLGET(m_new, M_DONTWAIT);
- if (!(m_new->m_flags & M_EXT)) {
- m_freem(m_new);
- printf("dc%d: no memory for tx list", sc->dc_unit);
- return(ENOBUFS);
- }
- }
- m_copydata(m, 0, m->m_pkthdr.len, mtod(m_new, caddr_t));
- m_new->m_pkthdr.len = m_new->m_len = m->m_pkthdr.len;
- m_freem(m);
- *m_head = m_new;
-
- return(0);
-}
-
-/*
- * Main transmit routine. To avoid having to do mbuf copies, we put pointers
- * to the mbuf data regions directly in the transmit lists. We also save a
- * copy of the pointers since the transmit list fragment pointers are
- * physical addresses.
- */
-
-static void dc_start(ifp)
- struct ifnet *ifp;
-{
- struct dc_softc *sc;
- struct mbuf *m_head = NULL;
- int idx;
-
- sc = ifp->if_softc;
-
- if (!sc->dc_link)
- return;
-
- if (ifp->if_flags & IFF_OACTIVE)
- return;
-
- idx = sc->dc_cdata.dc_tx_prod;
-
- while(sc->dc_cdata.dc_tx_chain[idx] == NULL) {
- IF_DEQUEUE(&ifp->if_snd, m_head);
- if (m_head == NULL)
- break;
-
- if (sc->dc_flags & DC_TX_COALESCE) {
- if (dc_coal(sc, &m_head)) {
- IF_PREPEND(&ifp->if_snd, m_head);
- ifp->if_flags |= IFF_OACTIVE;
- break;
- }
- }
-
- if (dc_encap(sc, m_head, &idx)) {
- IF_PREPEND(&ifp->if_snd, m_head);
- ifp->if_flags |= IFF_OACTIVE;
- break;
- }
-
- /*
- * If there's a BPF listener, bounce a copy of this frame
- * to him.
- */
- if (ifp->if_bpf)
- bpf_mtap(ifp, m_head);
- }
-
- /* Transmit */
- sc->dc_cdata.dc_tx_prod = idx;
- if (!(sc->dc_flags & DC_TX_POLL))
- CSR_WRITE_4(sc, DC_TXSTART, 0xFFFFFFFF);
-
- /*
- * Set a timeout in case the chip goes out to lunch.
- */
- ifp->if_timer = 5;
-
- return;
-}
-
-static void dc_init(xsc)
- void *xsc;
-{
- struct dc_softc *sc = xsc;
- struct ifnet *ifp = &sc->arpcom.ac_if;
- struct mii_data *mii;
- int s;
-
- s = splimp();
-
- mii = device_get_softc(sc->dc_miibus);
-
- /*
- * Cancel pending I/O and free all RX/TX buffers.
- */
- dc_stop(sc);
- dc_reset(sc);
-
- /*
- * Set cache alignment and burst length.
- */
- if (DC_IS_ASIX(sc) || DC_IS_DAVICOM(sc))
- CSR_WRITE_4(sc, DC_BUSCTL, 0);
- else
- CSR_WRITE_4(sc, DC_BUSCTL, DC_BUSCTL_MRME|DC_BUSCTL_MRLE);
- if (DC_IS_DAVICOM(sc) || DC_IS_INTEL(sc)) {
- DC_SETBIT(sc, DC_BUSCTL, DC_BURSTLEN_USECA);
- } else {
- DC_SETBIT(sc, DC_BUSCTL, DC_BURSTLEN_16LONG);
- }
- if (sc->dc_flags & DC_TX_POLL)
- DC_SETBIT(sc, DC_BUSCTL, DC_TXPOLL_1);
- switch(sc->dc_cachesize) {
- case 32:
- DC_SETBIT(sc, DC_BUSCTL, DC_CACHEALIGN_32LONG);
- break;
- case 16:
- DC_SETBIT(sc, DC_BUSCTL, DC_CACHEALIGN_16LONG);
- break;
- case 8:
- DC_SETBIT(sc, DC_BUSCTL, DC_CACHEALIGN_8LONG);
- break;
- case 0:
- default:
- DC_SETBIT(sc, DC_BUSCTL, DC_CACHEALIGN_NONE);
- break;
- }
-
- if (sc->dc_flags & DC_TX_STORENFWD)
- DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_STORENFWD);
- else {
- if (sc->dc_txthresh == DC_TXTHRESH_160BYTES) {
- DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_STORENFWD);
- } else {
- DC_CLRBIT(sc, DC_NETCFG, DC_NETCFG_STORENFWD);
- DC_SETBIT(sc, DC_NETCFG, sc->dc_txthresh);
- }
- }
-
- DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_NO_RXCRC);
- DC_CLRBIT(sc, DC_NETCFG, DC_NETCFG_TX_BACKOFF);
-
- if (DC_IS_MACRONIX(sc) || DC_IS_PNICII(sc)) {
- /*
- * The app notes for the 98713 and 98715A say that
- * in order to have the chips operate properly, a magic
- * number must be written to CSR16. Macronix does not
- * document the meaning of these bits so there's no way
- * to know exactly what they do. The 98713 has a magic
- * number all its own; the rest all use a different one.
- */
- DC_CLRBIT(sc, DC_MX_MAGICPACKET, 0xFFFF0000);
- if (sc->dc_type == DC_TYPE_98713)
- DC_SETBIT(sc, DC_MX_MAGICPACKET, DC_MX_MAGIC_98713);
- else
- DC_SETBIT(sc, DC_MX_MAGICPACKET, DC_MX_MAGIC_98715);
- }
-
- DC_CLRBIT(sc, DC_NETCFG, DC_NETCFG_TX_THRESH);
- DC_SETBIT(sc, DC_NETCFG, DC_TXTHRESH_72BYTES);
-
- /* Init circular RX list. */
- if (dc_list_rx_init(sc) == ENOBUFS) {
- printf("dc%d: initialization failed: no "
- "memory for rx buffers\n", sc->dc_unit);
- dc_stop(sc);
- (void)splx(s);
- return;
- }
-
- /*
- * Init tx descriptors.
- */
- dc_list_tx_init(sc);
-
- /*
- * Load the address of the RX list.
- */
- CSR_WRITE_4(sc, DC_RXADDR, vtophys(&sc->dc_ldata->dc_rx_list[0]));
- CSR_WRITE_4(sc, DC_TXADDR, vtophys(&sc->dc_ldata->dc_tx_list[0]));
-
- /*
- * Enable interrupts.
- */
- CSR_WRITE_4(sc, DC_IMR, DC_INTRS);
- CSR_WRITE_4(sc, DC_ISR, 0xFFFFFFFF);
-
- /* Enable transmitter. */
- DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_TX_ON);
-
- /*
- * Load the RX/multicast filter. We do this sort of late
- * because the filter programming scheme on the 21143 and
- * some clones requires DMAing a setup frame via the TX
- * engine, and we need the transmitter enabled for that.
- */
- dc_setfilt(sc);
-
- /* Enable receiver. */
- DC_SETBIT(sc, DC_NETCFG, DC_NETCFG_RX_ON);
- CSR_WRITE_4(sc, DC_RXSTART, 0xFFFFFFFF);
-
- mii_mediachg(mii);
- dc_setcfg(sc, sc->dc_if_media);
-
- ifp->if_flags |= IFF_RUNNING;
- ifp->if_flags &= ~IFF_OACTIVE;
-
- (void)splx(s);
-
- sc->dc_stat_ch = timeout(dc_tick, sc, hz);
-
-#ifdef __alpha__
- if(sc->dc_srm_media) {
- struct ifreq ifr;
-
- ifr.ifr_media = sc->dc_srm_media;
- ifmedia_ioctl(ifp, &ifr, &mii->mii_media, SIOCSIFMEDIA);
- sc->dc_srm_media = 0;
- }
-#endif
- return;
-}
-
-/*
- * Set media options.
- */
-static int dc_ifmedia_upd(ifp)
- struct ifnet *ifp;
-{
- struct dc_softc *sc;
- struct mii_data *mii;
- struct ifmedia *ifm;
-
- sc = ifp->if_softc;
- mii = device_get_softc(sc->dc_miibus);
- mii_mediachg(mii);
- ifm = &mii->mii_media;
-
- if (DC_IS_DAVICOM(sc) &&
- IFM_SUBTYPE(ifm->ifm_media) == IFM_homePNA)
- dc_setcfg(sc, ifm->ifm_media);
- else
- sc->dc_link = 0;
-
- return(0);
-}
-
-/*
- * Report current media status.
- */
-static void dc_ifmedia_sts(ifp, ifmr)
- struct ifnet *ifp;
- struct ifmediareq *ifmr;
-{
- struct dc_softc *sc;
- struct mii_data *mii;
- struct ifmedia *ifm;
-
- sc = ifp->if_softc;
- mii = device_get_softc(sc->dc_miibus);
- mii_pollstat(mii);
- ifm = &mii->mii_media;
- if (DC_IS_DAVICOM(sc)) {
- if (IFM_SUBTYPE(ifm->ifm_media) == IFM_homePNA) {
- ifmr->ifm_active = ifm->ifm_media;
- ifmr->ifm_status = 0;
- return;
- }
- }
- ifmr->ifm_active = mii->mii_media_active;
- ifmr->ifm_status = mii->mii_media_status;
-
- return;
-}
-
-static int dc_ioctl(ifp, command, data)
- struct ifnet *ifp;
- u_long command;
- caddr_t data;
-{
- struct dc_softc *sc = ifp->if_softc;
- struct ifreq *ifr = (struct ifreq *) data;
- struct mii_data *mii;
- int s, error = 0;
-
- s = splimp();
-
- switch(command) {
- case SIOCSIFADDR:
- case SIOCGIFADDR:
- case SIOCSIFMTU:
- error = ether_ioctl(ifp, command, data);
- break;
- case SIOCSIFFLAGS:
- if (ifp->if_flags & IFF_UP) {
- if (ifp->if_flags & IFF_RUNNING &&
- ifp->if_flags & IFF_PROMISC &&
- !(sc->dc_if_flags & IFF_PROMISC)) {
- dc_setfilt(sc);
- } else if (ifp->if_flags & IFF_RUNNING &&
- !(ifp->if_flags & IFF_PROMISC) &&
- sc->dc_if_flags & IFF_PROMISC) {
- dc_setfilt(sc);
- } else if (!(ifp->if_flags & IFF_RUNNING)) {
- sc->dc_txthresh = 0;
- dc_init(sc);
- }
- } else {
- if (ifp->if_flags & IFF_RUNNING)
- dc_stop(sc);
- }
- sc->dc_if_flags = ifp->if_flags;
- error = 0;
- break;
- case SIOCADDMULTI:
- case SIOCDELMULTI:
- dc_setfilt(sc);
- error = 0;
- break;
- case SIOCGIFMEDIA:
- case SIOCSIFMEDIA:
- mii = device_get_softc(sc->dc_miibus);
- error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, command);
-#ifdef __alpha__
- if (sc->dc_srm_media)
- sc->dc_srm_media = 0;
-#endif
- break;
- default:
- error = EINVAL;
- break;
- }
-
- (void)splx(s);
-
- return(error);
-}
-
-static void dc_watchdog(ifp)
- struct ifnet *ifp;
-{
- struct dc_softc *sc;
-
- sc = ifp->if_softc;
-
- ifp->if_oerrors++;
- printf("dc%d: watchdog timeout\n", sc->dc_unit);
-
- dc_stop(sc);
- dc_reset(sc);
- dc_init(sc);
-
- if (ifp->if_snd.ifq_head != NULL)
- dc_start(ifp);
-
- return;
-}
-
-/*
- * Stop the adapter and free any mbufs allocated to the
- * RX and TX lists.
- */
-static void dc_stop(sc)
- struct dc_softc *sc;
-{
- register int i;
- struct ifnet *ifp;
-
- ifp = &sc->arpcom.ac_if;
- ifp->if_timer = 0;
-
- untimeout(dc_tick, sc, sc->dc_stat_ch);
-
- DC_CLRBIT(sc, DC_NETCFG, (DC_NETCFG_RX_ON|DC_NETCFG_TX_ON));
- CSR_WRITE_4(sc, DC_IMR, 0x00000000);
- CSR_WRITE_4(sc, DC_TXADDR, 0x00000000);
- CSR_WRITE_4(sc, DC_RXADDR, 0x00000000);
- sc->dc_link = 0;
-
- /*
- * Free data in the RX lists.
- */
- for (i = 0; i < DC_RX_LIST_CNT; i++) {
- if (sc->dc_cdata.dc_rx_chain[i] != NULL) {
- m_freem(sc->dc_cdata.dc_rx_chain[i]);
- sc->dc_cdata.dc_rx_chain[i] = NULL;
- }
- }
- bzero((char *)&sc->dc_ldata->dc_rx_list,
- sizeof(sc->dc_ldata->dc_rx_list));
-
- /*
- * Free the TX list buffers.
- */
- for (i = 0; i < DC_TX_LIST_CNT; i++) {
- if (sc->dc_cdata.dc_tx_chain[i] != NULL) {
- if (sc->dc_ldata->dc_tx_list[i].dc_ctl &
- DC_TXCTL_SETUP) {
- sc->dc_cdata.dc_tx_chain[i] = NULL;
- continue;
- }
- m_freem(sc->dc_cdata.dc_tx_chain[i]);
- sc->dc_cdata.dc_tx_chain[i] = NULL;
- }
- }
-
- bzero((char *)&sc->dc_ldata->dc_tx_list,
- sizeof(sc->dc_ldata->dc_tx_list));
-
- ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
-
- return;
-}
-
-/*
- * Stop all chip I/O so that the kernel's probe routines don't
- * get confused by errant DMAs when rebooting.
- */
-static void dc_shutdown(dev)
- device_t dev;
-{
- struct dc_softc *sc;
-
- sc = device_get_softc(dev);
-
- dc_stop(sc);
-
- return;
-}
diff --git a/sys/dev/dc/if_dcreg.h b/sys/dev/dc/if_dcreg.h
deleted file mode 100644
index 9620e103c35e..000000000000
--- a/sys/dev/dc/if_dcreg.h
+++ /dev/null
@@ -1,914 +0,0 @@
-/*
- * Copyright (c) 1997, 1998, 1999
- * Bill Paul <wpaul@ee.columbia.edu>. 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 Bill Paul.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY Bill Paul 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 Bill Paul OR THE VOICES IN HIS HEAD
- * 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.
- *
- * $FreeBSD$
- */
-
-/*
- * 21143 and clone common register definitions.
- */
-
-#define DC_BUSCTL 0x00 /* bus control */
-#define DC_TXSTART 0x08 /* tx start demand */
-#define DC_RXSTART 0x10 /* rx start demand */
-#define DC_RXADDR 0x18 /* rx descriptor list start addr */
-#define DC_TXADDR 0x20 /* tx descriptor list start addr */
-#define DC_ISR 0x28 /* interrupt status register */
-#define DC_NETCFG 0x30 /* network config register */
-#define DC_IMR 0x38 /* interrupt mask */
-#define DC_FRAMESDISCARDED 0x40 /* # of discarded frames */
-#define DC_SIO 0x48 /* MII and ROM/EEPROM access */
-#define DC_ROM 0x50 /* ROM programming address */
-#define DC_TIMER 0x58 /* general timer */
-#define DC_10BTSTAT 0x60 /* SIA status */
-#define DC_SIARESET 0x68 /* SIA connectivity */
-#define DC_10BTCTRL 0x70 /* SIA transmit and receive */
-#define DC_WATCHDOG 0x78 /* SIA and general purpose port */
-
-/*
- * There are two general 'types' of MX chips that we need to be
- * concerned with. One is the original 98713, which has its internal
- * NWAY support controlled via the MDIO bits in the serial I/O
- * register. The other is everything else (from the 98713A on up),
- * which has its internal NWAY controlled via CSR13, CSR14 and CSR15,
- * just like the 21143. This type setting also governs which of the
- * 'magic' numbers we write to CSR16. The PNIC II falls into the
- * 98713A/98715/98715A/98725 category.
- */
-#define DC_TYPE_98713 0x1
-#define DC_TYPE_98713A 0x2
-#define DC_TYPE_987x5 0x3
-
-/* Other type of supported chips. */
-#define DC_TYPE_21143 0x4 /* Intel 21143 */
-#define DC_TYPE_ASIX 0x5 /* ASIX AX88140A/AX88141 */
-#define DC_TYPE_AL981 0x6 /* ADMtek AL981 Comet */
-#define DC_TYPE_AN985 0x7 /* ADMtek AN985 Centaur */
-#define DC_TYPE_DM9102 0x8 /* Davicom DM9102 */
-#define DC_TYPE_PNICII 0x9 /* 82c115 PNIC II */
-#define DC_TYPE_PNIC 0xA /* 82c168/82c169 PNIC I */
-
-#define DC_IS_MACRONIX(x) \
- (x->dc_type == DC_TYPE_98713 || \
- x->dc_type == DC_TYPE_98713A || \
- x->dc_type == DC_TYPE_987x5)
-
-#define DC_IS_ADMTEK(x) \
- (x->dc_type == DC_TYPE_AL981 || \
- x->dc_type == DC_TYPE_AN985)
-
-#define DC_IS_INTEL(x) (x->dc_type == DC_TYPE_21143)
-#define DC_IS_ASIX(x) (x->dc_type == DC_TYPE_ASIX)
-#define DC_IS_COMET(x) (x->dc_type == DC_TYPE_AL981)
-#define DC_IS_CENTAUR(x) (x->dc_type == DC_TYPE_AN985)
-#define DC_IS_DAVICOM(x) (x->dc_type == DC_TYPE_DM9102)
-#define DC_IS_PNICII(x) (x->dc_type == DC_TYPE_PNICII)
-#define DC_IS_PNIC(x) (x->dc_type == DC_TYPE_PNIC)
-
-/* MII/symbol mode port types */
-#define DC_PMODE_MII 0x1
-#define DC_PMODE_SYM 0x2
-
-/*
- * Bus control bits.
- */
-#define DC_BUSCTL_RESET 0x00000001
-#define DC_BUSCTL_ARBITRATION 0x00000002
-#define DC_BUSCTL_SKIPLEN 0x0000007C
-#define DC_BUSCTL_BUF_BIGENDIAN 0x00000080
-#define DC_BUSCTL_BURSTLEN 0x00003F00
-#define DC_BUSCTL_CACHEALIGN 0x0000C000
-#define DC_BUSCTL_TXPOLL 0x000E0000
-#define DC_BUSCTL_DBO 0x00100000
-#define DC_BUSCTL_MRME 0x00200000
-#define DC_BUSCTL_MRLE 0x00800000
-#define DC_BUSCTL_MWIE 0x01000000
-#define DC_BUSCTL_ONNOW_ENB 0x04000000
-
-#define DC_SKIPLEN_1LONG 0x00000004
-#define DC_SKIPLEN_2LONG 0x00000008
-#define DC_SKIPLEN_3LONG 0x00000010
-#define DC_SKIPLEN_4LONG 0x00000020
-#define DC_SKIPLEN_5LONG 0x00000040
-
-#define DC_CACHEALIGN_NONE 0x00000000
-#define DC_CACHEALIGN_8LONG 0x00004000
-#define DC_CACHEALIGN_16LONG 0x00008000
-#define DC_CACHEALIGN_32LONG 0x0000C000
-
-#define DC_BURSTLEN_USECA 0x00000000
-#define DC_BURSTLEN_1LONG 0x00000100
-#define DC_BURSTLEN_2LONG 0x00000200
-#define DC_BURSTLEN_4LONG 0x00000400
-#define DC_BURSTLEN_8LONG 0x00000800
-#define DC_BURSTLEN_16LONG 0x00001000
-#define DC_BURSTLEN_32LONG 0x00002000
-
-#define DC_TXPOLL_OFF 0x00000000
-#define DC_TXPOLL_1 0x00020000
-#define DC_TXPOLL_2 0x00040000
-#define DC_TXPOLL_3 0x00060000
-#define DC_TXPOLL_4 0x00080000
-#define DC_TXPOLL_5 0x000A0000
-#define DC_TXPOLL_6 0x000C0000
-#define DC_TXPOLL_7 0x000E0000
-
-/*
- * Interrupt status bits.
- */
-#define DC_ISR_TX_OK 0x00000001
-#define DC_ISR_TX_IDLE 0x00000002
-#define DC_ISR_TX_NOBUF 0x00000004
-#define DC_ISR_TX_JABBERTIMEO 0x00000008
-#define DC_ISR_LINKGOOD 0x00000010
-#define DC_ISR_TX_UNDERRUN 0x00000020
-#define DC_ISR_RX_OK 0x00000040
-#define DC_ISR_RX_NOBUF 0x00000080
-#define DC_ISR_RX_READ 0x00000100
-#define DC_ISR_RX_WATDOGTIMEO 0x00000200
-#define DC_ISR_TX_EARLY 0x00000400
-#define DC_ISR_TIMER_EXPIRED 0x00000800
-#define DC_ISR_LINKFAIL 0x00001000
-#define DC_ISR_BUS_ERR 0x00002000
-#define DC_ISR_RX_EARLY 0x00004000
-#define DC_ISR_ABNORMAL 0x00008000
-#define DC_ISR_NORMAL 0x00010000
-#define DC_ISR_RX_STATE 0x000E0000
-#define DC_ISR_TX_STATE 0x00700000
-#define DC_ISR_BUSERRTYPE 0x03800000
-#define DC_ISR_100MBPSLINK 0x08000000
-#define DC_ISR_MAGICKPACK 0x10000000
-
-#define DC_RXSTATE_STOPPED 0x00000000 /* 000 - Stopped */
-#define DC_RXSTATE_FETCH 0x00020000 /* 001 - Fetching descriptor */
-#define DC_RXSTATE_ENDCHECK 0x00040000 /* 010 - check for rx end */
-#define DC_RXSTATE_WAIT 0x00060000 /* 011 - waiting for packet */
-#define DC_RXSTATE_SUSPEND 0x00080000 /* 100 - suspend rx */
-#define DC_RXSTATE_CLOSE 0x000A0000 /* 101 - close tx desc */
-#define DC_RXSTATE_FLUSH 0x000C0000 /* 110 - flush from FIFO */
-#define DC_RXSTATE_DEQUEUE 0x000E0000 /* 111 - dequeue from FIFO */
-
-#define DC_TXSTATE_RESET 0x00000000 /* 000 - reset */
-#define DC_TXSTATE_FETCH 0x00100000 /* 001 - fetching descriptor */
-#define DC_TXSTATE_WAITEND 0x00200000 /* 010 - wait for tx end */
-#define DC_TXSTATE_READING 0x00300000 /* 011 - read and enqueue */
-#define DC_TXSTATE_RSVD 0x00400000 /* 100 - reserved */
-#define DC_TXSTATE_SETUP 0x00500000 /* 101 - setup packet */
-#define DC_TXSTATE_SUSPEND 0x00600000 /* 110 - suspend tx */
-#define DC_TXSTATE_CLOSE 0x00700000 /* 111 - close tx desc */
-
-/*
- * Network config bits.
- */
-#define DC_NETCFG_RX_HASHPERF 0x00000001
-#define DC_NETCFG_RX_ON 0x00000002
-#define DC_NETCFG_RX_HASHONLY 0x00000004
-#define DC_NETCFG_RX_BADFRAMES 0x00000008
-#define DC_NETCFG_RX_INVFILT 0x00000010
-#define DC_NETCFG_BACKOFFCNT 0x00000020
-#define DC_NETCFG_RX_PROMISC 0x00000040
-#define DC_NETCFG_RX_ALLMULTI 0x00000080
-#define DC_NETCFG_FULLDUPLEX 0x00000200
-#define DC_NETCFG_LOOPBACK 0x00000C00
-#define DC_NETCFG_FORCECOLL 0x00001000
-#define DC_NETCFG_TX_ON 0x00002000
-#define DC_NETCFG_TX_THRESH 0x0000C000
-#define DC_NETCFG_TX_BACKOFF 0x00020000
-#define DC_NETCFG_PORTSEL 0x00040000 /* 0 == 10, 1 == 100 */
-#define DC_NETCFG_HEARTBEAT 0x00080000
-#define DC_NETCFG_STORENFWD 0x00200000
-#define DC_NETCFG_SPEEDSEL 0x00400000 /* 1 == 10, 0 == 100 */
-#define DC_NETCFG_PCS 0x00800000
-#define DC_NETCFG_SCRAMBLER 0x01000000
-#define DC_NETCFG_NO_RXCRC 0x02000000
-#define DC_NETCFG_RX_ALL 0x40000000
-#define DC_NETCFG_CAPEFFECT 0x80000000
-
-#define DC_OPMODE_NORM 0x00000000
-#define DC_OPMODE_INTLOOP 0x00000400
-#define DC_OPMODE_EXTLOOP 0x00000800
-
-#define DC_TXTHRESH_72BYTES 0x00000000
-#define DC_TXTHRESH_96BYTES 0x00004000
-#define DC_TXTHRESH_128BYTES 0x00008000
-#define DC_TXTHRESH_160BYTES 0x0000C000
-
-
-/*
- * Interrupt mask bits.
- */
-#define DC_IMR_TX_OK 0x00000001
-#define DC_IMR_TX_IDLE 0x00000002
-#define DC_IMR_TX_NOBUF 0x00000004
-#define DC_IMR_TX_JABBERTIMEO 0x00000008
-#define DC_IMR_LINKGOOD 0x00000010
-#define DC_IMR_TX_UNDERRUN 0x00000020
-#define DC_IMR_RX_OK 0x00000040
-#define DC_IMR_RX_NOBUF 0x00000080
-#define DC_IMR_RX_READ 0x00000100
-#define DC_IMR_RX_WATDOGTIMEO 0x00000200
-#define DC_IMR_TX_EARLY 0x00000400
-#define DC_IMR_TIMER_EXPIRED 0x00000800
-#define DC_IMR_LINKFAIL 0x00001000
-#define DC_IMR_BUS_ERR 0x00002000
-#define DC_IMR_RX_EARLY 0x00004000
-#define DC_IMR_ABNORMAL 0x00008000
-#define DC_IMR_NORMAL 0x00010000
-#define DC_IMR_100MBPSLINK 0x08000000
-#define DC_IMR_MAGICKPACK 0x10000000
-
-#define DC_INTRS \
- (DC_IMR_RX_OK|DC_IMR_TX_OK|DC_IMR_RX_NOBUF|DC_IMR_RX_WATDOGTIMEO|\
- DC_IMR_TX_NOBUF|DC_IMR_TX_UNDERRUN|DC_IMR_BUS_ERR| \
- DC_IMR_ABNORMAL|DC_IMR_NORMAL/*|DC_IMR_TX_EARLY*/)
-/*
- * Serial I/O (EEPROM/ROM) bits.
- */
-#define DC_SIO_EE_CS 0x00000001 /* EEPROM chip select */
-#define DC_SIO_EE_CLK 0x00000002 /* EEPROM clock */
-#define DC_SIO_EE_DATAIN 0x00000004 /* EEPROM data output */
-#define DC_SIO_EE_DATAOUT 0x00000008 /* EEPROM data input */
-#define DC_SIO_ROMDATA4 0x00000010
-#define DC_SIO_ROMDATA5 0x00000020
-#define DC_SIO_ROMDATA6 0x00000040
-#define DC_SIO_ROMDATA7 0x00000080
-#define DC_SIO_EESEL 0x00000800
-#define DC_SIO_ROMSEL 0x00001000
-#define DC_SIO_ROMCTL_WRITE 0x00002000
-#define DC_SIO_ROMCTL_READ 0x00004000
-#define DC_SIO_MII_CLK 0x00010000 /* MDIO clock */
-#define DC_SIO_MII_DATAOUT 0x00020000 /* MDIO data out */
-#define DC_SIO_MII_DIR 0x00040000 /* MDIO dir */
-#define DC_SIO_MII_DATAIN 0x00080000 /* MDIO data in */
-
-#define DC_EECMD_WRITE 0x140
-#define DC_EECMD_READ 0x180
-#define DC_EECMD_ERASE 0x1c0
-
-#define DC_EE_NODEADDR_OFFSET 0x70
-#define DC_EE_NODEADDR 10
-
-/*
- * General purpose timer register
- */
-#define DC_TIMER_VALUE 0x0000FFFF
-#define DC_TIMER_CONTINUOUS 0x00010000
-
-/*
- * 10baseT status register
- */
-#define DC_TSTAT_MIIACT 0x00000001 /* MII port activity */
-#define DC_TSTAT_LS100 0x00000002 /* link status of 100baseTX */
-#define DC_TSTAT_LS10 0x00000004 /* link status of 10baseT */
-#define DC_TSTAT_AUTOPOLARITY 0x00000008
-#define DC_TSTAT_AUIACT 0x00000100 /* AUI activity */
-#define DC_TSTAT_10BTACT 0x00000200 /* 10baseT activity */
-#define DC_TSTAT_NSN 0x00000400 /* non-stable FLPs detected */
-#define DC_TSTAT_REMFAULT 0x00000800
-#define DC_TSTAT_ANEGSTAT 0x00007000
-#define DC_TSTAT_LP_CAN_NWAY 0x00008000 /* link partner supports NWAY */
-#define DC_TSTAT_LPCODEWORD 0xFFFF0000 /* link partner's code word */
-
-#define DC_ASTAT_DISABLE 0x00000000
-#define DC_ASTAT_TXDISABLE 0x00001000
-#define DC_ASTAT_ABDETECT 0x00002000
-#define DC_ASTAT_ACKDETECT 0x00003000
-#define DC_ASTAT_CMPACKDETECT 0x00004000
-#define DC_ASTAT_AUTONEGCMP 0x00005000
-#define DC_ASTAT_LINKCHECK 0x00006000
-
-/*
- * PHY reset register
- */
-#define DC_SIA_RESET 0x00000001
-#define DC_SIA_AUI 0x00000008 /* AUI or 10baseT */
-
-/*
- * 10baseT control register
- */
-#define DC_TCTL_ENCODER_ENB 0x00000001
-#define DC_TCTL_LOOPBACK 0x00000002
-#define DC_TCTL_DRIVER_ENB 0x00000004
-#define DC_TCTL_LNKPULSE_ENB 0x00000008
-#define DC_TCTL_HALFDUPLEX 0x00000040
-#define DC_TCTL_AUTONEGENBL 0x00000080
-#define DC_TCTL_RX_SQUELCH 0x00000100
-#define DC_TCTL_COLL_SQUELCH 0x00000200
-#define DC_TCTL_COLL_DETECT 0x00000400
-#define DC_TCTL_SQE_ENB 0x00000800
-#define DC_TCTL_LINKTEST 0x00001000
-#define DC_TCTL_AUTOPOLARITY 0x00002000
-#define DC_TCTL_SET_POL_PLUS 0x00004000
-#define DC_TCTL_AUTOSENSE 0x00008000 /* 10bt/AUI autosense */
-#define DC_TCTL_100BTXHALF 0x00010000
-#define DC_TCTL_100BTXFULL 0x00020000
-#define DC_TCTL_100BT4 0x00040000
-
-/*
- * Watchdog timer register
- */
-#define DC_WDOG_JABBERDIS 0x00000001
-#define DC_WDOG_HOSTUNJAB 0x00000002
-#define DC_WDOG_JABBERCLK 0x00000004
-#define DC_WDOG_RXWDOGDIS 0x00000010
-#define DC_WDOG_RXWDOGCLK 0x00000020
-#define DC_WDOG_MUSTBEZERO 0x00000100
-
-/*
- * Size of a setup frame.
- */
-#define DC_SFRAME_LEN 192
-
-/*
- * 21x4x TX/RX list structure.
- */
-
-struct dc_desc {
- u_int32_t dc_status;
- u_int32_t dc_ctl;
- u_int32_t dc_ptr1;
- u_int32_t dc_ptr2;
-};
-
-#define dc_data dc_ptr1
-#define dc_next dc_ptr2
-
-#define DC_RXSTAT_FIFOOFLOW 0x00000001
-#define DC_RXSTAT_CRCERR 0x00000002
-#define DC_RXSTAT_DRIBBLE 0x00000004
-#define DC_RXSTAT_WATCHDOG 0x00000010
-#define DC_RXSTAT_FRAMETYPE 0x00000020 /* 0 == IEEE 802.3 */
-#define DC_RXSTAT_COLLSEEN 0x00000040
-#define DC_RXSTAT_GIANT 0x00000080
-#define DC_RXSTAT_LASTFRAG 0x00000100
-#define DC_RXSTAT_FIRSTFRAG 0x00000200
-#define DC_RXSTAT_MULTICAST 0x00000400
-#define DC_RXSTAT_RUNT 0x00000800
-#define DC_RXSTAT_RXTYPE 0x00003000
-#define DC_RXSTAT_RXERR 0x00008000
-#define DC_RXSTAT_RXLEN 0x3FFF0000
-#define DC_RXSTAT_OWN 0x80000000
-
-#define DC_RXBYTES(x) ((x & DC_RXSTAT_RXLEN) >> 16)
-#define DC_RXSTAT (DC_RXSTAT_FIRSTFRAG|DC_RXSTAT_LASTFRAG|DC_RXSTAT_OWN)
-
-#define DC_RXCTL_BUFLEN1 0x00000FFF
-#define DC_RXCTL_BUFLEN2 0x00FFF000
-#define DC_RXCTL_RLINK 0x01000000
-#define DC_RXCTL_RLAST 0x02000000
-
-#define DC_TXSTAT_DEFER 0x00000001
-#define DC_TXSTAT_UNDERRUN 0x00000002
-#define DC_TXSTAT_LINKFAIL 0x00000003
-#define DC_TXSTAT_COLLCNT 0x00000078
-#define DC_TXSTAT_SQE 0x00000080
-#define DC_TXSTAT_EXCESSCOLL 0x00000100
-#define DC_TXSTAT_LATECOLL 0x00000200
-#define DC_TXSTAT_NOCARRIER 0x00000400
-#define DC_TXSTAT_CARRLOST 0x00000800
-#define DC_TXSTAT_JABTIMEO 0x00004000
-#define DC_TXSTAT_ERRSUM 0x00008000
-#define DC_TXSTAT_OWN 0x80000000
-
-#define DC_TXCTL_BUFLEN1 0x000007FF
-#define DC_TXCTL_BUFLEN2 0x003FF800
-#define DC_TXCTL_FILTTYPE0 0x00400000
-#define DC_TXCTL_PAD 0x00800000
-#define DC_TXCTL_TLINK 0x01000000
-#define DC_TXCTL_TLAST 0x02000000
-#define DC_TXCTL_NOCRC 0x04000000
-#define DC_TXCTL_SETUP 0x08000000
-#define DC_TXCTL_FILTTYPE1 0x10000000
-#define DC_TXCTL_FIRSTFRAG 0x20000000
-#define DC_TXCTL_LASTFRAG 0x40000000
-#define DC_TXCTL_FINT 0x80000000
-
-#define DC_FILTER_PERFECT 0x00000000
-#define DC_FILTER_HASHPERF 0x00400000
-#define DC_FILTER_INVERSE 0x10000000
-#define DC_FILTER_HASHONLY 0x10400000
-
-#define DC_MAXFRAGS 16
-#define DC_RX_LIST_CNT 64
-#define DC_TX_LIST_CNT 256
-#define DC_MIN_FRAMELEN 60
-#define DC_RXLEN 1536
-
-#define DC_INC(x, y) (x) = (x + 1) % y
-
-struct dc_list_data {
- struct dc_desc dc_rx_list[DC_RX_LIST_CNT];
- struct dc_desc dc_tx_list[DC_TX_LIST_CNT];
-};
-
-struct dc_chain_data {
- struct mbuf *dc_rx_chain[DC_RX_LIST_CNT];
- struct mbuf *dc_tx_chain[DC_TX_LIST_CNT];
- u_int32_t dc_sbuf[DC_SFRAME_LEN/sizeof(u_int32_t)];
- u_int8_t dc_pad[DC_MIN_FRAMELEN];
- int dc_tx_prod;
- int dc_tx_cons;
- int dc_tx_cnt;
- int dc_rx_prod;
-};
-
-struct dc_type {
- u_int16_t dc_vid;
- u_int16_t dc_did;
- char *dc_name;
-};
-
-struct dc_mii_frame {
- u_int8_t mii_stdelim;
- u_int8_t mii_opcode;
- u_int8_t mii_phyaddr;
- u_int8_t mii_regaddr;
- u_int8_t mii_turnaround;
- u_int16_t mii_data;
-};
-
-/*
- * MII constants
- */
-#define DC_MII_STARTDELIM 0x01
-#define DC_MII_READOP 0x02
-#define DC_MII_WRITEOP 0x01
-#define DC_MII_TURNAROUND 0x02
-
-
-/*
- * Registers specific to clone devices.
- * This mainly relates to RX filter programming: not all 21x4x clones
- * use the standard DEC filter programming mechanism.
- */
-
-/*
- * ADMtek specific registers and constants for the AL981 and AN985.
- * The AN985 doesn't use the magic PHY registers.
- */
-#define DC_AL_PAR0 0xA4 /* station address */
-#define DC_AL_PAR1 0xA8 /* station address */
-#define DC_AL_MAR0 0xAC /* multicast hash filter */
-#define DC_AL_MAR1 0xB0 /* multicast hash filter */
-#define DC_AL_BMCR 0xB4 /* built in PHY control */
-#define DC_AL_BMSR 0xB8 /* built in PHY status */
-#define DC_AL_VENID 0xBC /* built in PHY ID0 */
-#define DC_AL_DEVID 0xC0 /* built in PHY ID1 */
-#define DC_AL_ANAR 0xC4 /* built in PHY autoneg advert */
-#define DC_AL_LPAR 0xC8 /* bnilt in PHY link part. ability */
-#define DC_AL_ANER 0xCC /* built in PHY autoneg expansion */
-
-#define DC_ADMTEK_PHYADDR 0x1
-#define DC_AL_EE_NODEADDR 4
-/* End of ADMtek specific registers */
-
-/*
- * ASIX specific registers.
- */
-#define DC_AX_FILTIDX 0x68 /* RX filter index */
-#define DC_AX_FILTDATA 0x70 /* RX filter data */
-
-/*
- * Special ASIX-specific bits in the ASIX NETCFG register (CSR6).
- */
-#define DC_AX_NETCFG_RX_BROAD 0x00000100
-
-/*
- * RX Filter Index Register values
- */
-#define DC_AX_FILTIDX_PAR0 0x00000000
-#define DC_AX_FILTIDX_PAR1 0x00000001
-#define DC_AX_FILTIDX_MAR0 0x00000002
-#define DC_AX_FILTIDX_MAR1 0x00000003
-/* End of ASIX specific registers */
-
-/*
- * Macronix specific registers. The Macronix chips have a special
- * register for reading the NWAY status, which we don't use, plus
- * a magic packet register, which we need to tweak a bit per the
- * Macronix application notes.
- */
-#define DC_MX_MAGICPACKET 0x80
-#define DC_MX_NWAYSTAT 0xA0
-
-/*
- * Magic packet register
- */
-#define DC_MX_MPACK_DISABLE 0x00400000
-
-/*
- * NWAY status register.
- */
-#define DC_MX_NWAY_10BTHALF 0x08000000
-#define DC_MX_NWAY_10BTFULL 0x10000000
-#define DC_MX_NWAY_100BTHALF 0x20000000
-#define DC_MX_NWAY_100BTFULL 0x40000000
-#define DC_MX_NWAY_100BT4 0x80000000
-
-/*
- * These are magic values that must be written into CSR16
- * (DC_MX_MAGICPACKET) in order to put the chip into proper
- * operating mode. The magic numbers are documented in the
- * Macronix 98715 application notes.
- */
-#define DC_MX_MAGIC_98713 0x0F370000
-#define DC_MX_MAGIC_98713A 0x0B3C0000
-#define DC_MX_MAGIC_98715 0x0B3C0000
-#define DC_MX_MAGIC_98725 0x0B3C0000
-/* End of Macronix specific registers */
-
-/*
- * PNIC 82c168/82c169 specific registers.
- * The PNIC has its own special NWAY support, which doesn't work,
- * and shortcut ways of reading the EEPROM and MII bus.
- */
-#define DC_PN_GPIO 0x60 /* general purpose pins control */
-#define DC_PN_PWRUP_CFG 0x90 /* config register, set by EEPROM */
-#define DC_PN_SIOCTL 0x98 /* serial EEPROM control register */
-#define DC_PN_MII 0xA0 /* MII access register */
-#define DC_PN_NWAY 0xB8 /* Internal NWAY register */
-
-/* Serial I/O EEPROM register */
-#define DC_PN_SIOCTL_DATA 0x0000003F
-#define DC_PN_SIOCTL_OPCODE 0x00000300
-#define DC_PN_SIOCTL_BUSY 0x80000000
-
-#define DC_PN_EEOPCODE_ERASE 0x00000300
-#define DC_PN_EEOPCODE_READ 0x00000600
-#define DC_PN_EEOPCODE_WRITE 0x00000100
-
-/*
- * The first two general purpose pins control speed selection and
- * 100Mbps loopback on the 82c168 chip. The control bits should always
- * be set (to make the data pins outputs) and the speed selction and
- * loopback bits set accordingly when changing media. Physically, this
- * will set the state of a relay mounted on the card.
- */
-#define DC_PN_GPIO_DATA0 0x000000001
-#define DC_PN_GPIO_DATA1 0x000000002
-#define DC_PN_GPIO_DATA2 0x000000004
-#define DC_PN_GPIO_DATA3 0x000000008
-#define DC_PN_GPIO_CTL0 0x000000010
-#define DC_PN_GPIO_CTL1 0x000000020
-#define DC_PN_GPIO_CTL2 0x000000040
-#define DC_PN_GPIO_CTL3 0x000000080
-#define DC_PN_GPIO_SPEEDSEL DC_PN_GPIO_DATA0/* 1 == 100Mbps, 0 == 10Mbps */
-#define DC_PN_GPIO_100TX_LOOP DC_PN_GPIO_DATA1/* 1 == normal, 0 == loop */
-#define DC_PN_GPIO_BNC_ENB DC_PN_GPIO_DATA2
-#define DC_PN_GPIO_100TX_LNK DC_PN_GPIO_DATA3
-#define DC_PN_GPIO_SETBIT(sc, r) \
- DC_SETBIT(sc, DC_PN_GPIO, ((r) | (r << 4)))
-#define DC_PN_GPIO_CLRBIT(sc, r) \
- { \
- DC_SETBIT(sc, DC_PN_GPIO, ((r) << 4)); \
- DC_CLRBIT(sc, DC_PN_GPIO, (r)); \
- }
-
-/* shortcut MII access register */
-#define DC_PN_MII_DATA 0x0000FFFF
-#define DC_PN_MII_RESERVER 0x00020000
-#define DC_PN_MII_REGADDR 0x007C0000
-#define DC_PN_MII_PHYADDR 0x0F800000
-#define DC_PN_MII_OPCODE 0x30000000
-#define DC_PN_MII_BUSY 0x80000000
-
-#define DC_PN_MIIOPCODE_READ 0x60020000
-#define DC_PN_MIIOPCODE_WRITE 0x50020000
-
-/* Internal NWAY bits */
-#define DC_PN_NWAY_RESET 0x00000001 /* reset */
-#define DC_PN_NWAY_PDOWN 0x00000002 /* power down */
-#define DC_PN_NWAY_BYPASS 0x00000004 /* bypass */
-#define DC_PN_NWAY_AUILOWCUR 0x00000008 /* AUI low current */
-#define DC_PN_NWAY_TPEXTEND 0x00000010 /* low squelch voltage */
-#define DC_PN_NWAY_POLARITY 0x00000020 /* 0 == on, 1 == off */
-#define DC_PN_NWAY_TP 0x00000040 /* 1 == tp, 0 == AUI */
-#define DC_PN_NWAY_AUIVOLT 0x00000080 /* 1 == full, 0 == half */
-#define DC_PN_NWAY_DUPLEX 0x00000100 /* LED, 1 == full, 0 == half */
-#define DC_PN_NWAY_LINKTEST 0x00000200 /* 0 == on, 1 == off */
-#define DC_PN_NWAY_AUTODETECT 0x00000400 /* 1 == off, 0 == on */
-#define DC_PN_NWAY_SPEEDSEL 0x00000800 /* LED, 0 = 10, 1 == 100 */
-#define DC_PN_NWAY_NWAY_ENB 0x00001000 /* 0 == off, 1 == on */
-#define DC_PN_NWAY_CAP10HDX 0x00002000
-#define DC_PN_NWAY_CAP10FDX 0x00004000
-#define DC_PN_NWAY_CAP100FDX 0x00008000
-#define DC_PN_NWAY_CAP100HDX 0x00010000
-#define DC_PN_NWAY_CAP100T4 0x00020000
-#define DC_PN_NWAY_ANEGRESTART 0x02000000 /* resets when aneg done */
-#define DC_PN_NWAY_REMFAULT 0x04000000
-#define DC_PN_NWAY_LPAR10HDX 0x08000000
-#define DC_PN_NWAY_LPAR10FDX 0x10000000
-#define DC_PN_NWAY_LPAR100FDX 0x20000000
-#define DC_PN_NWAY_LPAR100HDX 0x40000000
-#define DC_PN_NWAY_LPAR100T4 0x80000000
-
-/* End of PNIC specific registers */
-
-struct dc_softc {
- struct arpcom arpcom; /* interface info */
- bus_space_handle_t dc_bhandle; /* bus space handle */
- bus_space_tag_t dc_btag; /* bus space tag */
- void *dc_intrhand;
- struct resource *dc_irq;
- struct resource *dc_res;
- struct dc_type *dc_info; /* adapter info */
- device_t dc_miibus;
- u_int8_t dc_unit; /* interface number */
- u_int8_t dc_type;
- u_int8_t dc_pmode;
- u_int8_t dc_link;
- u_int8_t dc_cachesize;
- int dc_pnic_rx_bug_save;
- unsigned char *dc_pnic_rx_buf;
- int dc_if_flags;
- int dc_if_media;
- u_int32_t dc_flags;
- u_int32_t dc_txthresh;
- struct dc_list_data *dc_ldata;
- struct dc_chain_data dc_cdata;
- struct callout_handle dc_stat_ch;
-#ifdef __alpha__
- int dc_srm_media;
-#endif
-};
-
-#define DC_TX_POLL 0x00000001
-#define DC_TX_COALESCE 0x00000002
-#define DC_TX_ADMTEK_WAR 0x00000004
-#define DC_TX_USE_TX_INTR 0x00000008
-#define DC_RX_FILTER_TULIP 0x00000010
-#define DC_TX_INTR_FIRSTFRAG 0x00000020
-#define DC_PNIC_RX_BUG_WAR 0x00000040
-#define DC_TX_FIXED_RING 0x00000080
-#define DC_TX_STORENFWD 0x00000100
-#define DC_REDUCED_MII_POLL 0x00000200
-#define DC_TX_INTR_ALWAYS 0x00000400
-
-/*
- * register space access macros
- */
-#define CSR_WRITE_4(sc, reg, val) \
- bus_space_write_4(sc->dc_btag, sc->dc_bhandle, reg, val)
-
-#define CSR_READ_4(sc, reg) \
- bus_space_read_4(sc->dc_btag, sc->dc_bhandle, reg)
-
-#define DC_TIMEOUT 1000
-#define ETHER_ALIGN 2
-
-/*
- * General constants that are fun to know.
- */
-
-/*
- * DEC PCI vendor ID
- */
-#define DC_VENDORID_DEC 0x1011
-
-/*
- * DEC/Intel 21143 PCI device ID
- */
-#define DC_DEVICEID_21143 0x0019
-
-/*
- * Macronix PCI vendor ID
- */
-#define DC_VENDORID_MX 0x10D9
-
-/*
- * Macronix PMAC device IDs.
- */
-#define DC_DEVICEID_98713 0x0512
-#define DC_DEVICEID_987x5 0x0531
-
-/* Macronix PCI revision codes. */
-#define DC_REVISION_98713 0x00
-#define DC_REVISION_98713A 0x10
-#define DC_REVISION_98715 0x20
-#define DC_REVISION_98725 0x30
-
-/*
- * Compex PCI vendor ID.
- */
-#define DC_VENDORID_CP 0x11F6
-
-/*
- * Compex PMAC PCI device IDs.
- */
-#define DC_DEVICEID_98713_CP 0x9881
-
-/*
- * Lite-On PNIC PCI vendor ID
- */
-#define DC_VENDORID_LO 0x11AD
-
-/*
- * 82c168/82c169 PNIC device IDs. Both chips have the same device
- * ID but different revisions. Revision 0x10 is the 82c168, and
- * 0x20 is the 82c169.
- */
-#define DC_DEVICEID_82C168 0x0002
-
-#define DC_REVISION_82C168 0x10
-#define DC_REVISION_82C169 0x20
-
-/*
- * Lite-On PNIC II device ID. Note: this is actually a Macronix 98715A
- * with wake on lan/magic packet support.
- */
-#define DC_DEVICEID_82C115 0xc115
-
-/*
- * Davicom vendor ID.
- */
-#define DC_VENDORID_DAVICOM 0x1282
-
-/*
- * Davicom device IDs.
- */
-#define DC_DEVICEID_DM9100 0x9100
-#define DC_DEVICEID_DM9102 0x9102
-
-/*
- * The DM9102A has the same PCI device ID as the DM9102,
- * but a higher revision code.
- */
-#define DC_REVISION_DM9102 0x10
-#define DC_REVISION_DM9102A 0x30
-
-/*
- * ADMtek vendor ID.
- */
-#define DC_VENDORID_ADMTEK 0x1317
-
-/*
- * ADMtek device IDs.
- */
-#define DC_DEVICEID_AL981 0x0981
-#define DC_DEVICEID_AN985 0x0985
-
-/*
- * ASIX vendor ID.
- */
-#define DC_VENDORID_ASIX 0x125B
-
-/*
- * ASIX device IDs.
- */
-#define DC_DEVICEID_AX88140A 0x1400
-
-/*
- * The ASIX AX88140 and ASIX AX88141 have the same vendor and
- * device IDs but different revision values.
- */
-#define DC_REVISION_88140 0x00
-#define DC_REVISION_88141 0x10
-
-/*
- * PCI low memory base and low I/O base register, and
- * other PCI registers.
- */
-
-#define DC_PCI_CFID 0x00 /* Id */
-#define DC_PCI_CFCS 0x04 /* Command and status */
-#define DC_PCI_CFRV 0x08 /* Revision */
-#define DC_PCI_CFLT 0x0C /* Latency timer */
-#define DC_PCI_CFBIO 0x10 /* Base I/O address */
-#define DC_PCI_CFBMA 0x14 /* Base memory address */
-#define DC_PCI_CCIS 0x28 /* Card info struct */
-#define DC_PCI_CSID 0x2C /* Subsystem ID */
-#define DC_PCI_CBER 0x30 /* Expansion ROM base address */
-#define DC_PCI_CCAP 0x34 /* Caps pointer - PD/TD chip only */
-#define DC_PCI_CFIT 0x3C /* Interrupt */
-#define DC_PCI_CFDD 0x40 /* Device and driver area */
-#define DC_PCI_CWUA0 0x44 /* Wake-Up LAN addr 0 */
-#define DC_PCI_CWUA1 0x48 /* Wake-Up LAN addr 1 */
-#define DC_PCI_SOP0 0x4C /* SecureON passwd 0 */
-#define DC_PCI_SOP1 0x50 /* SecureON passwd 1 */
-#define DC_PCI_CWUC 0x54 /* Configuration Wake-Up cmd */
-#define DC_PCI_CCID 0xDC /* Capability ID - PD/TD only */
-#define DC_PCI_CPMC 0xE0 /* Pwrmgmt ctl & sts - PD/TD only */
-
-/* PCI ID register */
-#define DC_CFID_VENDOR 0x0000FFFF
-#define DC_CFID_DEVICE 0xFFFF0000
-
-/* PCI command/status register */
-#define DC_CFCS_IOSPACE 0x00000001 /* I/O space enable */
-#define DC_CFCS_MEMSPACE 0x00000002 /* memory space enable */
-#define DC_CFCS_BUSMASTER 0x00000004 /* bus master enable */
-#define DC_CFCS_MWI_ENB 0x00000008 /* mem write and inval enable */
-#define DC_CFCS_PARITYERR_ENB 0x00000020 /* parity error enable */
-#define DC_CFCS_SYSERR_ENB 0x00000080 /* system error enable */
-#define DC_CFCS_NEWCAPS 0x00100000 /* new capabilities */
-#define DC_CFCS_FAST_B2B 0x00800000 /* fast back-to-back capable */
-#define DC_CFCS_DATAPARITY 0x01000000 /* Parity error report */
-#define DC_CFCS_DEVSELTIM 0x06000000 /* devsel timing */
-#define DC_CFCS_TGTABRT 0x10000000 /* received target abort */
-#define DC_CFCS_MASTERABRT 0x20000000 /* received master abort */
-#define DC_CFCS_SYSERR 0x40000000 /* asserted system error */
-#define DC_CFCS_PARITYERR 0x80000000 /* asserted parity error */
-
-/* PCI revision register */
-#define DC_CFRV_STEPPING 0x0000000F
-#define DC_CFRV_REVISION 0x000000F0
-#define DC_CFRV_SUBCLASS 0x00FF0000
-#define DC_CFRV_BASECLASS 0xFF000000
-
-#define DC_21143_PB_REV 0x00000030
-#define DC_21143_TB_REV 0x00000030
-#define DC_21143_PC_REV 0x00000030
-#define DC_21143_TC_REV 0x00000030
-#define DC_21143_PD_REV 0x00000041
-#define DC_21143_TD_REV 0x00000041
-
-/* PCI latency timer register */
-#define DC_CFLT_CACHELINESIZE 0x000000FF
-#define DC_CFLT_LATENCYTIMER 0x0000FF00
-
-/* PCI subsystem ID register */
-#define DC_CSID_VENDOR 0x0000FFFF
-#define DC_CSID_DEVICE 0xFFFF0000
-
-/* PCI cababilities pointer */
-#define DC_CCAP_OFFSET 0x000000FF
-
-/* PCI interrupt config register */
-#define DC_CFIT_INTLINE 0x000000FF
-#define DC_CFIT_INTPIN 0x0000FF00
-#define DC_CFIT_MIN_GNT 0x00FF0000
-#define DC_CFIT_MAX_LAT 0xFF000000
-
-/* PCI capability register */
-#define DC_CCID_CAPID 0x000000FF
-#define DC_CCID_NEXTPTR 0x0000FF00
-#define DC_CCID_PM_VERS 0x00070000
-#define DC_CCID_PME_CLK 0x00080000
-#define DC_CCID_DVSPEC_INT 0x00200000
-#define DC_CCID_STATE_D1 0x02000000
-#define DC_CCID_STATE_D2 0x04000000
-#define DC_CCID_PME_D0 0x08000000
-#define DC_CCID_PME_D1 0x10000000
-#define DC_CCID_PME_D2 0x20000000
-#define DC_CCID_PME_D3HOT 0x40000000
-#define DC_CCID_PME_D3COLD 0x80000000
-
-/* PCI power management control/status register */
-#define DC_CPMC_STATE 0x00000003
-#define DC_CPMC_PME_ENB 0x00000100
-#define DC_CPMC_PME_STS 0x00008000
-
-#define DC_PSTATE_D0 0x0
-#define DC_PSTATE_D1 0x1
-#define DC_PSTATE_D2 0x2
-#define DC_PSTATE_D3 0x3
-
-/* Device specific region */
-/* Configuration and driver area */
-#define DC_CFDD_DRVUSE 0x0000FFFF
-#define DC_CFDD_SNOOZE_MODE 0x40000000
-#define DC_CFDD_SLEEP_MODE 0x80000000
-
-/* Configuration wake-up command register */
-#define DC_CWUC_MUST_BE_ZERO 0x00000001
-#define DC_CWUC_SECUREON_ENB 0x00000002
-#define DC_CWUC_FORCE_WUL 0x00000004
-#define DC_CWUC_BNC_ABILITY 0x00000008
-#define DC_CWUC_AUI_ABILITY 0x00000010
-#define DC_CWUC_TP10_ABILITY 0x00000020
-#define DC_CWUC_MII_ABILITY 0x00000040
-#define DC_CWUC_SYM_ABILITY 0x00000080
-#define DC_CWUC_LOCK 0x00000100
-
-#ifdef __alpha__
-#undef vtophys
-#define vtophys(va) alpha_XXX_dmamap((vm_offset_t)va)
-#endif
diff --git a/sys/dev/dc/pnphy.c b/sys/dev/dc/pnphy.c
deleted file mode 100644
index 0f8498ef6ff6..000000000000
--- a/sys/dev/dc/pnphy.c
+++ /dev/null
@@ -1,311 +0,0 @@
-/*
- * Copyright (c) 1997, 1998, 1999
- * Bill Paul <wpaul@ee.columbia.edu>. 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 Bill Paul.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY Bill Paul 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 Bill Paul OR THE VOICES IN HIS HEAD
- * 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Pseudo-driver for media selection on the Lite-On PNIC 82c168
- * chip. The NWAY support on this chip is horribly broken, so we
- * only support manual mode selection. This is lame, but getting
- * NWAY to work right is amazingly difficult.
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/malloc.h>
-#include <sys/socket.h>
-#include <sys/errno.h>
-#include <sys/module.h>
-#include <sys/bus.h>
-
-#include <net/if.h>
-#include <net/if_arp.h>
-#include <net/if_media.h>
-
-#include <dev/mii/mii.h>
-#include <dev/mii/miivar.h>
-#include <dev/mii/miidevs.h>
-
-#include <machine/clock.h>
-#include <machine/bus_pio.h>
-#include <machine/bus_memio.h>
-#include <machine/bus.h>
-#include <machine/resource.h>
-#include <sys/bus.h>
-
-#include <pci/if_dcreg.h>
-
-#include "miibus_if.h"
-
-#if !defined(lint)
-static const char rcsid[] =
- "$FreeBSD$";
-#endif
-
-#define DC_SETBIT(sc, reg, x) \
- CSR_WRITE_4(sc, reg, \
- CSR_READ_4(sc, reg) | x)
-
-#define DC_CLRBIT(sc, reg, x) \
- CSR_WRITE_4(sc, reg, \
- CSR_READ_4(sc, reg) & ~x)
-
-static int pnphy_probe __P((device_t));
-static int pnphy_attach __P((device_t));
-static int pnphy_detach __P((device_t));
-
-static device_method_t pnphy_methods[] = {
- /* device interface */
- DEVMETHOD(device_probe, pnphy_probe),
- DEVMETHOD(device_attach, pnphy_attach),
- DEVMETHOD(device_detach, pnphy_detach),
- DEVMETHOD(device_shutdown, bus_generic_shutdown),
- { 0, 0 }
-};
-
-static devclass_t pnphy_devclass;
-
-static driver_t pnphy_driver = {
- "pnphy",
- pnphy_methods,
- sizeof(struct mii_softc)
-};
-
-DRIVER_MODULE(pnphy, miibus, pnphy_driver, pnphy_devclass, 0, 0);
-
-int pnphy_service __P((struct mii_softc *, struct mii_data *, int));
-void pnphy_status __P((struct mii_softc *));
-
-static int pnphy_probe(dev)
- device_t dev;
-{
- struct mii_attach_args *ma;
-
- ma = device_get_ivars(dev);
-
- /*
- * The dc driver will report the 82c168 vendor and device
- * ID to let us know that it wants us to attach.
- */
- if (ma->mii_id1 != DC_VENDORID_LO ||
- ma->mii_id2 != DC_DEVICEID_82C168)
- return(ENXIO);
-
- device_set_desc(dev, "PNIC 82c168 media interface");
-
- return (0);
-}
-
-static int pnphy_attach(dev)
- device_t dev;
-{
- struct mii_softc *sc;
- struct mii_attach_args *ma;
- struct mii_data *mii;
-
- sc = device_get_softc(dev);
- ma = device_get_ivars(dev);
- sc->mii_dev = device_get_parent(dev);
- mii = device_get_softc(sc->mii_dev);
- LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list);
-
- sc->mii_inst = mii->mii_instance;
- sc->mii_phy = ma->mii_phyno;
- sc->mii_service = pnphy_service;
- sc->mii_pdata = mii;
-
- sc->mii_flags |= MIIF_NOISOLATE;
- mii->mii_instance++;
-
-#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL)
-
- sc->mii_capabilities =
- BMSR_100TXFDX|BMSR_100TXHDX|BMSR_10TFDX|BMSR_10THDX;
- sc->mii_capabilities &= ma->mii_capmask;
- device_printf(dev, " ");
- if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0)
- printf("no media present");
- else
- mii_add_media(mii, sc->mii_capabilities, sc->mii_inst);
- printf("\n");
- ADD(IFM_MAKEWORD(IFM_ETHER, IFM_NONE, 0, sc->mii_inst),
- BMCR_ISO);
-
- ADD(IFM_MAKEWORD(IFM_ETHER, IFM_100_TX, IFM_LOOP, sc->mii_inst),
- BMCR_LOOP|BMCR_S100);
-
-#undef ADD
-
- MIIBUS_MEDIAINIT(sc->mii_dev);
- return(0);
-}
-
-static int pnphy_detach(dev)
- device_t dev;
-{
- struct mii_softc *sc;
- struct mii_data *mii;
-
- sc = device_get_softc(dev);
- mii = device_get_softc(device_get_parent(dev));
- sc->mii_dev = NULL;
- LIST_REMOVE(sc, mii_list);
-
- return(0);
-}
-
-int
-pnphy_service(sc, mii, cmd)
- struct mii_softc *sc;
- struct mii_data *mii;
- int cmd;
-{
- struct dc_softc *dc_sc;
- struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
-
- dc_sc = mii->mii_ifp->if_softc;
-
- switch (cmd) {
- case MII_POLLSTAT:
- /*
- * If we're not polling our PHY instance, just return.
- */
- if (IFM_INST(ife->ifm_media) != sc->mii_inst) {
- return (0);
- }
- break;
-
- case MII_MEDIACHG:
- /*
- * If the media indicates a different PHY instance,
- * isolate ourselves.
- */
- if (IFM_INST(ife->ifm_media) != sc->mii_inst)
- return (0);
-
- /*
- * If the interface is not up, don't do anything.
- */
- if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
- break;
-
- sc->mii_flags = 0;
-
- switch (IFM_SUBTYPE(ife->ifm_media)) {
- case IFM_AUTO:
- /* NWAY is busted on this chip */
- case IFM_100_T4:
- /*
- * XXX Not supported as a manual setting right now.
- */
- return (EINVAL);
- case IFM_100_TX:
- mii->mii_media_active = IFM_ETHER|IFM_100_TX;
- if ((ife->ifm_media & IFM_GMASK) == IFM_FDX)
- mii->mii_media_active |= IFM_FDX;
- MIIBUS_STATCHG(sc->mii_dev);
- return(0);
- break;
- case IFM_10_T:
- mii->mii_media_active = IFM_ETHER|IFM_10_T;
- if ((ife->ifm_media & IFM_GMASK) == IFM_FDX)
- mii->mii_media_active |= IFM_FDX;
- MIIBUS_STATCHG(sc->mii_dev);
- return(0);
- break;
- default:
- return(EINVAL);
- break;
- }
- break;
-
- case MII_TICK:
- /*
- * If we're not currently selected, just return.
- */
- if (IFM_INST(ife->ifm_media) != sc->mii_inst)
- return (0);
-
- /*
- * Only used for autonegotiation.
- */
- if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO)
- return (0);
-
- /*
- * Is the interface even up?
- */
- if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
- return (0);
-
- return(0);
- }
-
- /* Update the media status. */
- pnphy_status(sc);
-
- /* Callback if something changed. */
- if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) {
- MIIBUS_STATCHG(sc->mii_dev);
- sc->mii_active = mii->mii_media_active;
- }
- return (0);
-}
-
-void
-pnphy_status(sc)
- struct mii_softc *sc;
-{
- struct mii_data *mii = sc->mii_pdata;
- int reg;
- struct dc_softc *dc_sc;
-
- dc_sc = mii->mii_ifp->if_softc;
-
- mii->mii_media_status = IFM_AVALID;
- mii->mii_media_active = IFM_ETHER;
-
- reg = CSR_READ_4(dc_sc, DC_ISR);
-
- if (!(reg & DC_ISR_LINKFAIL))
- mii->mii_media_status |= IFM_ACTIVE;
-
- if (CSR_READ_4(dc_sc, DC_NETCFG) & DC_NETCFG_SPEEDSEL)
- mii->mii_media_active |= IFM_10_T;
- else
- mii->mii_media_active |= IFM_100_TX;
- if (CSR_READ_4(dc_sc, DC_NETCFG) & DC_NETCFG_FULLDUPLEX)
- mii->mii_media_active |= IFM_FDX;
-
- return;
-}
diff --git a/sys/dev/de/dc21040reg.h b/sys/dev/de/dc21040reg.h
deleted file mode 100644
index 8959de04cc03..000000000000
--- a/sys/dev/de/dc21040reg.h
+++ /dev/null
@@ -1,609 +0,0 @@
-/* $NetBSD: dc21040reg.h,v 1.15 1998/05/22 18:50:59 matt Exp $ */
-
-/* $FreeBSD$ */
-
-/*-
- * Copyright (c) 1994, 1995, 1996 Matt Thomas <matt@3am-software.com>
- * 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 withough 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.
- *
- * Id: dc21040reg.h,v 1.24 1997/05/16 19:47:09 thomas Exp
- */
-
-#if !defined(_DC21040_H)
-#define _DC21040_H
-
-#if defined(BYTE_ORDER) && BYTE_ORDER == BIG_ENDIAN
-#define TULIP_BITFIELD2(a, b) b, a
-#define TULIP_BITFIELD3(a, b, c) c, b, a
-#define TULIP_BITFIELD4(a, b, c, d) d, c, b, a
-#else
-#define TULIP_BITFIELD2(a, b) a, b
-#define TULIP_BITFIELD3(a, b, c) a, b, c
-#define TULIP_BITFIELD4(a, b, c, d) a, b, c, d
-#endif
-
-typedef struct {
- u_int32_t d_status;
- u_int32_t TULIP_BITFIELD3(d_length1 : 11,
- d_length2 : 11,
- d_flag : 10);
- u_int32_t d_addr1;
- u_int32_t d_addr2;
-} tulip_desc_t;
-
-#define TULIP_DSTS_OWNER 0x80000000 /* Owner (1 = 21040) */
-#define TULIP_DSTS_ERRSUM 0x00008000 /* Error Summary */
-/*
- * Transmit Status
- */
-#define TULIP_DSTS_TxBABBLE 0x00004000 /* Transmitter Babbled */
-#define TULIP_DSTS_TxCARRLOSS 0x00000800 /* Carrier Loss */
-#define TULIP_DSTS_TxNOCARR 0x00000400 /* No Carrier */
-#define TULIP_DSTS_TxLATECOLL 0x00000200 /* Late Collision */
-#define TULIP_DSTS_TxEXCCOLL 0x00000100 /* Excessive Collisions */
-#define TULIP_DSTS_TxNOHRTBT 0x00000080 /* No Heartbeat */
-#define TULIP_DSTS_TxCOLLMASK 0x00000078 /* Collision Count (mask) */
-#define TULIP_DSTS_V_TxCOLLCNT 0x00000003 /* Collision Count (bit) */
-#define TULIP_DSTS_TxLINKFAIL 0x00000004 /* Link Failure */
-#define TULIP_DSTS_TxUNDERFLOW 0x00000002 /* Underflow Error */
-#define TULIP_DSTS_TxDEFERRED 0x00000001 /* Initially Deferred */
-/*
- * Receive Status
- */
-#define TULIP_DSTS_RxBADLENGTH 0x00004000 /* Length Error */
-#define TULIP_DSTS_RxDATATYPE 0x00003000 /* Data Type */
-#define TULIP_DSTS_RxRUNT 0x00000800 /* Runt Frame */
-#define TULIP_DSTS_RxMULTICAST 0x00000400 /* Multicast Frame */
-#define TULIP_DSTS_RxFIRSTDESC 0x00000200 /* First Descriptor */
-#define TULIP_DSTS_RxLASTDESC 0x00000100 /* Last Descriptor */
-#define TULIP_DSTS_RxTOOLONG 0x00000080 /* Frame Too Long */
-#define TULIP_DSTS_RxCOLLSEEN 0x00000040 /* Collision Seen */
-#define TULIP_DSTS_RxFRAMETYPE 0x00000020 /* Frame Type */
-#define TULIP_DSTS_RxWATCHDOG 0x00000010 /* Receive Watchdog */
-#define TULIP_DSTS_RxDRBBLBIT 0x00000004 /* Dribble Bit */
-#define TULIP_DSTS_RxBADCRC 0x00000002 /* CRC Error */
-#define TULIP_DSTS_RxOVERFLOW 0x00000001 /* Overflow */
-
-
-#define TULIP_DFLAG_ENDRING 0x0008 /* End of Transmit Ring */
-#define TULIP_DFLAG_CHAIN 0x0004 /* Chain using d_addr2 */
-
-#define TULIP_DFLAG_TxWANTINTR 0x0200 /* Signal Interrupt on Completion */
-#define TULIP_DFLAG_TxLASTSEG 0x0100 /* Last Segment */
-#define TULIP_DFLAG_TxFIRSTSEG 0x0080 /* First Segment */
-#define TULIP_DFLAG_TxINVRSFILT 0x0040 /* Inverse Filtering */
-#define TULIP_DFLAG_TxSETUPPKT 0x0020 /* Setup Packet */
-#define TULIP_DFLAG_TxHASCRC 0x0010 /* Don't Append the CRC */
-#define TULIP_DFLAG_TxNOPADDING 0x0002 /* Don't AutoPad */
-#define TULIP_DFLAG_TxHASHFILT 0x0001 /* Hash/Perfect Filtering */
-
-/*
- * The 21040 Registers (IO Space Addresses)
- */
-#define TULIP_REG_BUSMODE 0x00 /* CSR0 -- Bus Mode */
-#define TULIP_REG_TXPOLL 0x08 /* CSR1 -- Transmit Poll Demand */
-#define TULIP_REG_RXPOLL 0x10 /* CSR2 -- Receive Poll Demand */
-#define TULIP_REG_RXLIST 0x18 /* CSR3 -- Receive List Base Addr */
-#define TULIP_REG_TXLIST 0x20 /* CSR4 -- Transmit List Base Addr */
-#define TULIP_REG_STATUS 0x28 /* CSR5 -- Status */
-#define TULIP_REG_CMD 0x30 /* CSR6 -- Command */
-#define TULIP_REG_INTR 0x38 /* CSR7 -- Interrupt Control */
-#define TULIP_REG_MISSES 0x40 /* CSR8 -- Missed Frame Counter */
-#define TULIP_REG_ADDRROM 0x48 /* CSR9 -- ENET ROM Register */
-#define TULIP_REG_RSRVD 0x50 /* CSR10 -- Reserved */
-#define TULIP_REG_FULL_DUPLEX 0x58 /* CSR11 -- Full Duplex */
-#define TULIP_REG_SIA_STATUS 0x60 /* CSR12 -- SIA Status */
-#define TULIP_REG_SIA_CONN 0x68 /* CSR13 -- SIA Connectivity */
-#define TULIP_REG_SIA_TXRX 0x70 /* CSR14 -- SIA Tx Rx */
-#define TULIP_REG_SIA_GEN 0x78 /* CSR15 -- SIA General */
-
-/*
- * CSR5 -- Status Register
- * CSR7 -- Interrupt Control
- */
-#define TULIP_STS_ERRORMASK 0x03800000L /* ( R) Error Bits (Valid when SYSERROR is set) */
-#define TULIP_STS_ERR_PARITY 0x00000000L /* 000 - Parity Error (Perform Reset) */
-#define TULIP_STS_ERR_MASTER 0x00800000L /* 001 - Master Abort */
-#define TULIP_STS_ERR_TARGET 0x01000000L /* 010 - Target Abort */
-#define TULIP_STS_ERR_SHIFT 23
-#define TULIP_STS_TXSTATEMASK 0x00700000L /* ( R) Transmission Process State */
-#define TULIP_STS_TXS_RESET 0x00000000L /* 000 - Rset or transmit jabber expired */
-#define TULIP_STS_TXS_FETCH 0x00100000L /* 001 - Fetching transmit descriptor */
-#define TULIP_STS_TXS_WAITEND 0x00200000L /* 010 - Wait for end of transmission */
-#define TULIP_STS_TXS_READING 0x00300000L /* 011 - Read buffer and enqueue data */
-#define TULIP_STS_TXS_RSRVD 0x00400000L /* 100 - Reserved */
-#define TULIP_STS_TXS_SETUP 0x00500000L /* 101 - Setup Packet */
-#define TULIP_STS_TXS_SUSPEND 0x00600000L /* 110 - Transmit FIFO underflow or an
- unavailable transmit descriptor */
-#define TULIP_STS_TXS_CLOSE 0x00700000L /* 111 - Close transmit descriptor */
-#define TULIP_STS_RXSTATEMASK 0x000E0000L /* ( R) Receive Process State*/
-#define TULIP_STS_RXS_STOPPED 0x00000000L /* 000 - Stopped */
-#define TULIP_STS_RXS_FETCH 0x00020000L /* 001 - Running -- Fetch receive descriptor */
-#define TULIP_STS_RXS_ENDCHECK 0x00040000L /* 010 - Running -- Check for end of receive
- packet before prefetch of next descriptor */
-#define TULIP_STS_RXS_WAIT 0x00060000L /* 011 - Running -- Wait for receive packet */
-#define TULIP_STS_RXS_SUSPEND 0x00080000L /* 100 - Suspended -- As a result of
- unavailable receive buffers */
-#define TULIP_STS_RXS_CLOSE 0x000A0000L /* 101 - Running -- Close receive descriptor */
-#define TULIP_STS_RXS_FLUSH 0x000C0000L /* 110 - Running -- Flush the current frame
- from the receive FIFO as a result of
- an unavailable receive buffer */
-#define TULIP_STS_RXS_DEQUEUE 0x000E0000L /* 111 - Running -- Dequeue the receive frame
- from the receive FIFO into the receive
- buffer. */
-#define TULIP_STS_NORMALINTR 0x00010000L /* (RW) Normal Interrupt */
-#define TULIP_STS_ABNRMLINTR 0x00008000L /* (RW) Abnormal Interrupt */
-#define TULIP_STS_SYSERROR 0x00002000L /* (RW) System Error */
-#define TULIP_STS_LINKFAIL 0x00001000L /* (RW) Link Failure (21040) */
-#define TULIP_STS_FULDPLXSHRT 0x00000800L /* (RW) Full Duplex Short Fram Rcvd (21040) */
-#define TULIP_STS_GPTIMEOUT 0x00000800L /* (RW) General Purpose Timeout (21140) */
-#define TULIP_STS_AUI 0x00000400L /* (RW) AUI/TP Switch (21040) */
-#define TULIP_STS_RXTIMEOUT 0x00000200L /* (RW) Receive Watchbog Timeout */
-#define TULIP_STS_RXSTOPPED 0x00000100L /* (RW) Receive Process Stopped */
-#define TULIP_STS_RXNOBUF 0x00000080L /* (RW) Receive Buffer Unavailable */
-#define TULIP_STS_RXINTR 0x00000040L /* (RW) Receive Interrupt */
-#define TULIP_STS_TXUNDERFLOW 0x00000020L /* (RW) Transmit Underflow */
-#define TULIP_STS_LINKPASS 0x00000010L /* (RW) LinkPass (21041) */
-#define TULIP_STS_TXBABBLE 0x00000008L /* (RW) Transmit Jabber Timeout */
-#define TULIP_STS_TXNOBUF 0x00000004L /* (RW) Transmit Buffer Unavailable */
-#define TULIP_STS_TXSTOPPED 0x00000002L /* (RW) Transmit Process Stopped */
-#define TULIP_STS_TXINTR 0x00000001L /* (RW) Transmit Interrupt */
-
-/*
- * CSR6 -- Command (Operation Mode) Register
- */
-#define TULIP_CMD_MUSTBEONE 0x02000000L /* (RW) Must Be One (21140) */
-#define TULIP_CMD_SCRAMBLER 0x01000000L /* (RW) Scrambler Mode (21140) */
-#define TULIP_CMD_PCSFUNCTION 0x00800000L /* (RW) PCS Function (21140) */
-#define TULIP_CMD_TXTHRSHLDCTL 0x00400000L /* (RW) Transmit Threshold Mode (21140) */
-#define TULIP_CMD_STOREFWD 0x00200000L /* (RW) Store and Foward (21140) */
-#define TULIP_CMD_NOHEARTBEAT 0x00080000L /* (RW) No Heartbeat (21140) */
-#define TULIP_CMD_PORTSELECT 0x00040000L /* (RW) Post Select (100Mb) (21140) */
-#define TULIP_CMD_ENHCAPTEFFCT 0x00040000L /* (RW) Enhanced Capture Effecty (21041) */
-#define TULIP_CMD_CAPTREFFCT 0x00020000L /* (RW) Capture Effect (!802.3) */
-#define TULIP_CMD_BACKPRESSURE 0x00010000L /* (RW) Back Pressure (!802.3) (21040) */
-#define TULIP_CMD_THRESHOLDCTL 0x0000C000L /* (RW) Threshold Control */
-#define TULIP_CMD_THRSHLD72 0x00000000L /* 00 - 72 Bytes */
-#define TULIP_CMD_THRSHLD96 0x00004000L /* 01 - 96 Bytes */
-#define TULIP_CMD_THRSHLD128 0x00008000L /* 10 - 128 bytes */
-#define TULIP_CMD_THRSHLD160 0x0000C000L /* 11 - 160 Bytes */
-#define TULIP_CMD_TXRUN 0x00002000L /* (RW) Start/Stop Transmitter */
-#define TULIP_CMD_FORCECOLL 0x00001000L /* (RW) Force Collisions */
-#define TULIP_CMD_OPERMODE 0x00000C00L /* (RW) Operating Mode */
-#define TULIP_CMD_FULLDUPLEX 0x00000200L /* (RW) Full Duplex Mode */
-#define TULIP_CMD_FLAKYOSCDIS 0x00000100L /* (RW) Flakey Oscillator Disable */
-#define TULIP_CMD_ALLMULTI 0x00000080L /* (RW) Pass All Multicasts */
-#define TULIP_CMD_PROMISCUOUS 0x00000040L /* (RW) Promiscuous Mode */
-#define TULIP_CMD_BACKOFFCTR 0x00000020L /* (RW) Start/Stop Backoff Counter (!802.3) */
-#define TULIP_CMD_INVFILTER 0x00000010L /* (R ) Inverse Filtering */
-#define TULIP_CMD_PASSBADPKT 0x00000008L /* (RW) Pass Bad Frames */
-#define TULIP_CMD_HASHONLYFLTR 0x00000004L /* (R ) Hash Only Filtering */
-#define TULIP_CMD_RXRUN 0x00000002L /* (RW) Start/Stop Receive Filtering */
-#define TULIP_CMD_HASHPRFCTFLTR 0x00000001L /* (R ) Hash/Perfect Receive Filtering */
-
-#define TULIP_SIASTS_OTHERRXACTIVITY 0x00000200L
-#define TULIP_SIASTS_RXACTIVITY 0x00000100L
-#define TULIP_SIASTS_LINKFAIL 0x00000004L
-#define TULIP_SIASTS_LINK100FAIL 0x00000002L
-#define TULIP_SIACONN_RESET 0x00000000L
-
-/*
- * 21040 SIA definitions
- */
-#define TULIP_21040_PROBE_10BASET_TIMEOUT 2500
-#define TULIP_21040_PROBE_AUIBNC_TIMEOUT 300
-#define TULIP_21040_PROBE_EXTSIA_TIMEOUT 300
-
-#define TULIP_21040_SIACONN_10BASET 0x0000EF01L
-#define TULIP_21040_SIATXRX_10BASET 0x0000FFFFL
-#define TULIP_21040_SIAGEN_10BASET 0x00000000L
-
-#define TULIP_21040_SIACONN_10BASET_FD 0x0000EF01L
-#define TULIP_21040_SIATXRX_10BASET_FD 0x0000FFFDL
-#define TULIP_21040_SIAGEN_10BASET_FD 0x00000000L
-
-#define TULIP_21040_SIACONN_AUIBNC 0x0000EF09L
-#define TULIP_21040_SIATXRX_AUIBNC 0x00000705L
-#define TULIP_21040_SIAGEN_AUIBNC 0x00000006L
-
-#define TULIP_21040_SIACONN_EXTSIA 0x00003041L
-#define TULIP_21040_SIATXRX_EXTSIA 0x00000000L
-#define TULIP_21040_SIAGEN_EXTSIA 0x00000006L
-
-/*
- * 21041 SIA definitions
- */
-
-#define TULIP_21041_PROBE_10BASET_TIMEOUT 2500
-#define TULIP_21041_PROBE_AUIBNC_TIMEOUT 300
-
-#define TULIP_21041_SIACONN_10BASET 0x0000EF01L
-#define TULIP_21041_SIATXRX_10BASET 0x0000FF3FL
-#define TULIP_21041_SIAGEN_10BASET 0x00000000L
-
-#define TULIP_21041P2_SIACONN_10BASET 0x0000EF01L
-#define TULIP_21041P2_SIATXRX_10BASET 0x0000FFFFL
-#define TULIP_21041P2_SIAGEN_10BASET 0x00000000L
-
-#define TULIP_21041_SIACONN_10BASET_FD 0x0000EF01L
-#define TULIP_21041_SIATXRX_10BASET_FD 0x0000FF3DL
-#define TULIP_21041_SIAGEN_10BASET_FD 0x00000000L
-
-#define TULIP_21041P2_SIACONN_10BASET_FD 0x0000EF01L
-#define TULIP_21041P2_SIATXRX_10BASET_FD 0x0000FFFFL
-#define TULIP_21041P2_SIAGEN_10BASET_FD 0x00000000L
-
-#define TULIP_21041_SIACONN_AUI 0x0000EF09L
-#define TULIP_21041_SIATXRX_AUI 0x0000F73DL
-#define TULIP_21041_SIAGEN_AUI 0x0000000EL
-
-#define TULIP_21041P2_SIACONN_AUI 0x0000EF09L
-#define TULIP_21041P2_SIATXRX_AUI 0x0000F7FDL
-#define TULIP_21041P2_SIAGEN_AUI 0x0000000EL
-
-#define TULIP_21041_SIACONN_BNC 0x0000EF09L
-#define TULIP_21041_SIATXRX_BNC 0x0000F73DL
-#define TULIP_21041_SIAGEN_BNC 0x00000006L
-
-#define TULIP_21041P2_SIACONN_BNC 0x0000EF09L
-#define TULIP_21041P2_SIATXRX_BNC 0x0000F7FDL
-#define TULIP_21041P2_SIAGEN_BNC 0x00000006L
-
-/*
- * 21142 SIA definitions
- */
-
-#define TULIP_21142_PROBE_10BASET_TIMEOUT 2500
-#define TULIP_21142_PROBE_AUIBNC_TIMEOUT 300
-
-#define TULIP_21142_SIACONN_10BASET 0x00000001L
-#define TULIP_21142_SIATXRX_10BASET 0x00007F3FL
-#define TULIP_21142_SIAGEN_10BASET 0x00000008L
-
-#define TULIP_21142_SIACONN_10BASET_FD 0x00000001L
-#define TULIP_21142_SIATXRX_10BASET_FD 0x00007F3DL
-#define TULIP_21142_SIAGEN_10BASET_FD 0x00000008L
-
-#define TULIP_21142_SIACONN_AUI 0x00000009L
-#define TULIP_21142_SIATXRX_AUI 0x00000705L
-#define TULIP_21142_SIAGEN_AUI 0x0000000EL
-
-#define TULIP_21142_SIACONN_BNC 0x00000009L
-#define TULIP_21142_SIATXRX_BNC 0x00000705L
-#define TULIP_21142_SIAGEN_BNC 0x00000006L
-
-
-
-
-#define TULIP_WATCHDOG_TXDISABLE 0x00000001L
-#define TULIP_WATCHDOG_RXDISABLE 0x00000010L
-
-#define TULIP_BUSMODE_SWRESET 0x00000001L
-#define TULIP_BUSMODE_DESCSKIPLEN_MASK 0x0000007CL
-#define TULIP_BUSMODE_BIGENDIAN 0x00000080L
-#define TULIP_BUSMODE_BURSTLEN_MASK 0x00003F00L
-#define TULIP_BUSMODE_BURSTLEN_DEFAULT 0x00000000L
-#define TULIP_BUSMODE_BURSTLEN_1LW 0x00000100L
-#define TULIP_BUSMODE_BURSTLEN_2LW 0x00000200L
-#define TULIP_BUSMODE_BURSTLEN_4LW 0x00000400L
-#define TULIP_BUSMODE_BURSTLEN_8LW 0x00000800L
-#define TULIP_BUSMODE_BURSTLEN_16LW 0x00001000L
-#define TULIP_BUSMODE_BURSTLEN_32LW 0x00002000L
-#define TULIP_BUSMODE_CACHE_NOALIGN 0x00000000L
-#define TULIP_BUSMODE_CACHE_ALIGN8 0x00004000L
-#define TULIP_BUSMODE_CACHE_ALIGN16 0x00008000L
-#define TULIP_BUSMODE_CACHE_ALIGN32 0x0000C000L
-#define TULIP_BUSMODE_TXPOLL_NEVER 0x00000000L
-#define TULIP_BUSMODE_TXPOLL_200000ns 0x00020000L
-#define TULIP_BUSMODE_TXPOLL_800000ns 0x00040000L
-#define TULIP_BUSMODE_TXPOLL_1600000ns 0x00060000L
-#define TULIP_BUSMODE_TXPOLL_12800ns 0x00080000L /* 21041 only */
-#define TULIP_BUSMODE_TXPOLL_25600ns 0x000A0000L /* 21041 only */
-#define TULIP_BUSMODE_TXPOLL_51200ns 0x000C0000L /* 21041 only */
-#define TULIP_BUSMODE_TXPOLL_102400ns 0x000E0000L /* 21041 only */
-#define TULIP_BUSMODE_DESC_BIGENDIAN 0x00100000L /* 21041 only */
-#define TULIP_BUSMODE_READMULTIPLE 0x00200000L /* */
-
-#define TULIP_REG_CFDA 0x40
-#define TULIP_CFDA_SLEEP 0x80000000L
-#define TULIP_CFDA_SNOOZE 0x40000000L
-
-#define TULIP_GP_PINSET 0x00000100L
-/*
- * These are the defintitions used for the DEC 21140
- * evaluation board.
- */
-#define TULIP_GP_EB_PINS 0x0000001F /* General Purpose Pin directions */
-#define TULIP_GP_EB_OK10 0x00000080 /* 10 Mb/sec Signal Detect gep<7> */
-#define TULIP_GP_EB_OK100 0x00000040 /* 100 Mb/sec Signal Detect gep<6> */
-#define TULIP_GP_EB_INIT 0x0000000B /* No loopback --- point-to-point */
-
-/*
- * These are the defintitions used for the SMC9332 (21140) board.
- */
-#define TULIP_GP_SMC_9332_PINS 0x0000003F /* General Purpose Pin directions */
-#define TULIP_GP_SMC_9332_OK10 0x00000080 /* 10 Mb/sec Signal Detect gep<7> */
-#define TULIP_GP_SMC_9332_OK100 0x00000040 /* 100 Mb/sec Signal Detect gep<6> */
-#define TULIP_GP_SMC_9332_INIT 0x00000009 /* No loopback --- point-to-point */
-
-#define TULIP_OUI_SMC_0 0x00
-#define TULIP_OUI_SMC_1 0x00
-#define TULIP_OUI_SMC_2 0xC0
-
-/*
- * There are the definitions used for the DEC DE500
- * 10/100 family of boards
- */
-#define TULIP_GP_DE500_PINS 0x0000001FL
-#define TULIP_GP_DE500_LINK_PASS 0x00000080L
-#define TULIP_GP_DE500_SYM_LINK 0x00000040L
-#define TULIP_GP_DE500_SIGNAL_DETECT 0x00000020L
-#define TULIP_GP_DE500_PHY_RESET 0x00000010L
-#define TULIP_GP_DE500_HALFDUPLEX 0x00000008L
-#define TULIP_GP_DE500_PHY_LOOPBACK 0x00000004L
-#define TULIP_GP_DE500_FORCE_LED 0x00000002L
-#define TULIP_GP_DE500_FORCE_100 0x00000001L
-
-/*
- * These are the defintitions used for the Cogent EM100
- * 21140 board.
- */
-#define TULIP_GP_EM100_PINS 0x0000003F /* General Purpose Pin directions */
-#define TULIP_GP_EM100_INIT 0x00000009 /* No loopback --- point-to-point */
-#define TULIP_OUI_COGENT_0 0x00
-#define TULIP_OUI_COGENT_1 0x00
-#define TULIP_OUI_COGENT_2 0x92
-#define TULIP_COGENT_EM100TX_ID 0x12
-#define TULIP_COGENT_EM100FX_ID 0x15
-
-
-/*
- * These are the defintitions used for the Znyx ZX342
- * 10/100 board
- */
-#define TULIP_OUI_ZNYX_0 0x00
-#define TULIP_OUI_ZNYX_1 0xC0
-#define TULIP_OUI_ZNYX_2 0x95
-
-#define TULIP_ZNYX_ID_ZX312 0x0602
-#define TULIP_ZNYX_ID_ZX312T 0x0622
-#define TULIP_ZNYX_ID_ZX314_INTA 0x0701
-#define TULIP_ZNYX_ID_ZX314 0x0711
-#define TULIP_ZNYX_ID_ZX315_INTA 0x0801
-#define TULIP_ZNYX_ID_ZX315 0x0811
-#define TULIP_ZNYX_ID_ZX342 0x0901
-#define TULIP_ZNYX_ID_ZX342B 0x0921
-#define TULIP_ZNYX_ID_ZX342_X3 0x0902
-#define TULIP_ZNYX_ID_ZX342_X4 0x0903
-#define TULIP_ZNYX_ID_ZX344 0x0A01
-#define TULIP_ZNYX_ID_ZX351 0x0B01
-#define TULIP_ZNYX_ID_ZX345 0x0C01
-#define TULIP_ZNYX_ID_ZX311 0x0D01
-#define TULIP_ZNYX_ID_ZX346 0x0E01
-
-#define TULIP_GP_ZX34X_PINS 0x0000001F /* General Purpose Pin directions */
-#define TULIP_GP_ZX344_PINS 0x0000000B /* General Purpose Pin directions */
-#define TULIP_GP_ZX345_PINS 0x00000003 /* General Purpose Pin directions */
-#define TULIP_GP_ZX346_PINS 0x00000043 /* General Purpose Pin directions */
-#define TULIP_GP_ZX34X_LNKFAIL 0x00000080 /* 10Mb/s Link Failure */
-#define TULIP_GP_ZX34X_SYMDET 0x00000040 /* 100Mb/s Symbol Detect */
-#define TULIP_GP_ZX345_PHYACT 0x00000040 /* PHY Activity */
-#define TULIP_GP_ZX34X_SIGDET 0x00000020 /* 100Mb/s Signal Detect */
-#define TULIP_GP_ZX346_AUTONEG_ENABLED 0x00000020 /* 802.3u autoneg enabled */
-#define TULIP_GP_ZX342_COLENA 0x00000008 /* 10t Ext LB */
-#define TULIP_GP_ZX344_ROTINT 0x00000008 /* PPB IRQ rotation */
-#define TULIP_GP_ZX345_SPEED10 0x00000008 /* 10Mb speed detect */
-#define TULIP_GP_ZX346_SPEED100 0x00000008 /* 100Mb speed detect */
-#define TULIP_GP_ZX34X_NCOLENA 0x00000004 /* 10t Int LB */
-#define TULIP_GP_ZX34X_RXMATCH 0x00000004 /* RX Match */
-#define TULIP_GP_ZX346_FULLDUPLEX 0x00000004 /* Full Duplex Sensed */
-#define TULIP_GP_ZX34X_LB102 0x00000002 /* 100tx twister LB */
-#define TULIP_GP_ZX34X_NLB101 0x00000001 /* PDT/PDR LB */
-#define TULIP_GP_ZX34X_INIT 0x00000009
-
-/*
- * Compex's OUI. We need to twiddle a bit on their 21041 card.
- */
-#define TULIP_OUI_COMPEX_0 0x00
-#define TULIP_OUI_COMPEX_1 0x80
-#define TULIP_OUI_COMPEX_2 0x48
-#define TULIP_21041_COMPEX_XREGDATA 1
-
-/*
- * Asante's OUI and stuff...
- */
-#define TULIP_OUI_ASANTE_0 0x00
-#define TULIP_OUI_ASANTE_1 0x00
-#define TULIP_OUI_ASANTE_2 0x94
-#define TULIP_GP_ASANTE_PINS 0x000000bf /* GP pin config */
-#define TULIP_GP_ASANTE_PHYRESET 0x00000008 /* Reset PHY */
-
-/*
- * ACCTON EN1207 specialties
- */
-
-#define TULIP_OUI_EN1207_0 0x00
-#define TULIP_OUI_EN1207_1 0x00
-#define TULIP_OUI_EN1207_2 0xE8
-
-#define TULIP_CSR8_EN1207 0x08
-#define TULIP_CSR9_EN1207 0x00
-#define TULIP_CSR10_EN1207 0x03
-#define TULIP_CSR11_EN1207 0x1F
-
-#define TULIP_GP_EN1207_BNC_INIT 0x0000011B
-#define TULIP_GP_EN1207_UTP_INIT 0x9E00000B
-#define TULIP_GP_EN1207_100_INIT 0x6D00031B
-
-/*
- * SROM definitions for the 21140 and 21041.
- */
-#define SROMXREG 0x0400
-#define SROMSEL 0x0800
-#define SROMRD 0x4000
-#define SROMWR 0x2000
-#define SROMDIN 0x0008
-#define SROMDOUT 0x0004
-#define SROMDOUTON 0x0004
-#define SROMDOUTOFF 0x0004
-#define SROMCLKON 0x0002
-#define SROMCLKOFF 0x0002
-#define SROMCSON 0x0001
-#define SROMCSOFF 0x0001
-#define SROMCS 0x0001
-
-#define SROMCMD_MODE 4
-#define SROMCMD_WR 5
-#define SROMCMD_RD 6
-
-#define SROM_BITWIDTH 6
-
-/*
- * MII Definitions for the 21041 and 21140/21140A/21142
- */
-#define MII_PREAMBLE (~0)
-#define MII_TEST 0xAAAAAAAA
-#define MII_RDCMD 0xF6 /* 1111.0110 */
-#define MII_WRCMD 0xF5 /* 1111.0101 */
-#define MII_DIN 0x00080000
-#define MII_RD 0x00040000
-#define MII_WR 0x00000000
-#define MII_DOUT 0x00020000
-#define MII_CLK 0x00010000
-#define MII_CLKON MII_CLK
-#define MII_CLKOFF MII_CLK
-
-#define PHYREG_CONTROL 0
-#define PHYREG_STATUS 1
-#define PHYREG_IDLOW 2
-#define PHYREG_IDHIGH 3
-#define PHYREG_AUTONEG_ADVERTISEMENT 4
-#define PHYREG_AUTONEG_ABILITIES 5
-#define PHYREG_AUTONEG_EXPANSION 6
-#define PHYREG_AUTONEG_NEXTPAGE 7
-
-#define PHYSTS_100BASET4 0x8000
-#define PHYSTS_100BASETX_FD 0x4000
-#define PHYSTS_100BASETX 0x2000
-#define PHYSTS_10BASET_FD 0x1000
-#define PHYSTS_10BASET 0x0800
-#define PHYSTS_AUTONEG_DONE 0x0020
-#define PHYSTS_REMOTE_FAULT 0x0010
-#define PHYSTS_CAN_AUTONEG 0x0008
-#define PHYSTS_LINK_UP 0x0004
-#define PHYSTS_JABBER_DETECT 0x0002
-#define PHYSTS_EXTENDED_REGS 0x0001
-
-#define PHYCTL_RESET 0x8000
-#define PHYCTL_SELECT_100MB 0x2000
-#define PHYCTL_AUTONEG_ENABLE 0x1000
-#define PHYCTL_ISOLATE 0x0400
-#define PHYCTL_AUTONEG_RESTART 0x0200
-#define PHYCTL_FULL_DUPLEX 0x0100
-
-/*
- * Definitions for the DE425.
- */
-#define DE425_CFID 0x08 /* Configuration Id */
-#define DE425_CFCS 0x0C /* Configuration Command-Status */
-#define DE425_CFRV 0x18 /* Configuration Revision */
-#define DE425_CFLT 0x1C /* Configuration Latency Timer */
-#define DE425_CBIO 0x28 /* Configuration Base IO Address */
-#define DE425_CFDA 0x2C /* Configuration Driver Area */
-#define DE425_ENETROM_OFFSET 0xC90 /* Offset in I/O space for ENETROM */
-#define DE425_CFG0 0xC88 /* IRQ register */
-#define DE425_EISAID 0x10a34250 /* EISA device id */
-#define DE425_EISA_IOSIZE 0x100
-
-#define DEC_VENDORID 0x1011
-#define CHIPID_21040 0x0002
-#define CHIPID_21140 0x0009
-#define CHIPID_21041 0x0014
-#define CHIPID_21142 0x0019
-#define PCI_VENDORID(x) ((x) & 0xFFFF)
-#define PCI_CHIPID(x) (((x) >> 16) & 0xFFFF)
-
-/*
- * Generic SROM Format
- *
- *
- */
-
-typedef struct {
- u_int8_t sh_idbuf[18];
- u_int8_t sh_version;
- u_int8_t sh_adapter_count;
- u_int8_t sh_ieee802_address[6];
-} tulip_srom_header_t;
-
-typedef struct {
- u_int8_t sai_device;
- u_int8_t sai_leaf_offset_lowbyte;
- u_int8_t sai_leaf_offset_highbyte;
-} tulip_srom_adapter_info_t;
-
-typedef enum {
- TULIP_SROM_CONNTYPE_10BASET =0x0000,
- TULIP_SROM_CONNTYPE_BNC =0x0001,
- TULIP_SROM_CONNTYPE_AUI =0x0002,
- TULIP_SROM_CONNTYPE_100BASETX =0x0003,
- TULIP_SROM_CONNTYPE_100BASET4 =0x0006,
- TULIP_SROM_CONNTYPE_100BASEFX =0x0007,
- TULIP_SROM_CONNTYPE_MII_10BASET =0x0009,
- TULIP_SROM_CONNTYPE_MII_100BASETX =0x000D,
- TULIP_SROM_CONNTYPE_MII_100BASET4 =0x000F,
- TULIP_SROM_CONNTYPE_MII_100BASEFX =0x0010,
- TULIP_SROM_CONNTYPE_10BASET_NWAY =0x0100,
- TULIP_SROM_CONNTYPE_10BASET_FD =0x0204,
- TULIP_SROM_CONNTYPE_MII_10BASET_FD =0x020A,
- TULIP_SROM_CONNTYPE_100BASETX_FD =0x020E,
- TULIP_SROM_CONNTYPE_MII_100BASETX_FD =0x0211,
- TULIP_SROM_CONNTYPE_10BASET_NOLINKPASS =0x0400,
- TULIP_SROM_CONNTYPE_AUTOSENSE =0x0800,
- TULIP_SROM_CONNTYPE_AUTOSENSE_POWERUP =0x8800,
- TULIP_SROM_CONNTYPE_AUTOSENSE_NWAY =0x9000,
- TULIP_SROM_CONNTYPE_NOT_USED =0xFFFF
-} tulip_srom_connection_t;
-
-typedef enum {
- TULIP_SROM_MEDIA_10BASET =0x0000,
- TULIP_SROM_MEDIA_BNC =0x0001,
- TULIP_SROM_MEDIA_AUI =0x0002,
- TULIP_SROM_MEDIA_100BASETX =0x0003,
- TULIP_SROM_MEDIA_10BASET_FD =0x0004,
- TULIP_SROM_MEDIA_100BASETX_FD =0x0005,
- TULIP_SROM_MEDIA_100BASET4 =0x0006,
- TULIP_SROM_MEDIA_100BASEFX =0x0007,
- TULIP_SROM_MEDIA_100BASEFX_FD =0x0008
-} tulip_srom_media_t;
-
-#define TULIP_SROM_21041_EXTENDED 0x40
-
-#define TULIP_SROM_2114X_NOINDICATOR 0x8000
-#define TULIP_SROM_2114X_DEFAULT 0x4000
-#define TULIP_SROM_2114X_POLARITY 0x0080
-#define TULIP_SROM_2114X_CMDBITS(n) (((n) & 0x0071) << 18)
-#define TULIP_SROM_2114X_BITPOS(b) (1 << (((b) & 0x0E) >> 1))
-
-
-
-#endif /* !defined(_DC21040_H) */
diff --git a/sys/dev/de/if_de.c b/sys/dev/de/if_de.c
deleted file mode 100644
index dbbecf9e5bad..000000000000
--- a/sys/dev/de/if_de.c
+++ /dev/null
@@ -1,5334 +0,0 @@
-/* $NetBSD: if_de.c,v 1.86 1999/06/01 19:17:59 thorpej Exp $ */
-
-/* $FreeBSD$ */
-
-/*-
- * Copyright (c) 1994-1997 Matt Thomas (matt@3am-software.com)
- * 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 withough 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.
- *
- * Id: if_de.c,v 1.94 1997/07/03 16:55:07 thomas Exp
- *
- */
-
-/*
- * DEC 21040 PCI Ethernet Controller
- *
- * Written by Matt Thomas
- * BPF support code stolen directly from if_ec.c
- *
- * This driver supports the DEC DE435 or any other PCI
- * board which support 21040, 21041, or 21140 (mostly).
- */
-#define TULIP_HDR_DATA
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <sys/sockio.h>
-#include <sys/malloc.h>
-#include <sys/kernel.h>
-#include <sys/eventhandler.h>
-#include <machine/clock.h>
-
-#include "opt_inet.h"
-#include "opt_ipx.h"
-
-#include <net/if.h>
-#include <net/if_media.h>
-#include <net/if_dl.h>
-#ifdef TULIP_USE_SOFTINTR
-#include <net/netisr.h>
-#endif
-
-#include <net/bpf.h>
-
-#ifdef INET
-#include <netinet/in.h>
-#include <netinet/if_ether.h>
-#endif
-
-#ifdef IPX
-#include <netipx/ipx.h>
-#include <netipx/ipx_if.h>
-#endif
-
-#ifdef NS
-#include <netns/ns.h>
-#include <netns/ns_if.h>
-#endif
-
-#include <vm/vm.h>
-
-#include <net/if_var.h>
-#include <vm/pmap.h>
-#include <pci/pcivar.h>
-#include <pci/pcireg.h>
-#include <pci/dc21040reg.h>
-
-#include "opt_bdg.h"
-#ifdef BRIDGE
-#include <net/bridge.h>
-#endif
-
-/*
- * Intel CPUs should use I/O mapped access.
- */
-#if defined(__i386__)
-#define TULIP_IOMAPPED
-#endif
-
-#if 0
-/*
- * This turns on all sort of debugging stuff and make the
- * driver much larger.
- */
-#define TULIP_DEBUG
-#endif
-
-#if 0
-#define TULIP_PERFSTATS
-#endif
-
-#if 0
-#define TULIP_USE_SOFTINTR
-#endif
-
-#define TULIP_HZ 10
-
-#include <pci/if_devar.h>
-
-/*
- * This module supports
- * the DEC 21040 PCI Ethernet Controller.
- * the DEC 21041 PCI Ethernet Controller.
- * the DEC 21140 PCI Fast Ethernet Controller.
- */
-static void tulip_mii_autonegotiate(tulip_softc_t * const sc, const unsigned phyaddr);
-static void tulip_intr_shared(void *arg);
-static void tulip_intr_normal(void *arg);
-static void tulip_init(tulip_softc_t * const sc);
-static void tulip_reset(tulip_softc_t * const sc);
-static void tulip_ifstart_one(struct ifnet *ifp);
-static void tulip_ifstart(struct ifnet *ifp);
-static struct mbuf *tulip_txput(tulip_softc_t * const sc, struct mbuf *m);
-static void tulip_txput_setup(tulip_softc_t * const sc);
-static void tulip_rx_intr(tulip_softc_t * const sc);
-static void tulip_addr_filter(tulip_softc_t * const sc);
-static unsigned tulip_mii_readreg(tulip_softc_t * const sc, unsigned devaddr, unsigned regno);
-static void tulip_mii_writereg(tulip_softc_t * const sc, unsigned devaddr, unsigned regno, unsigned data);
-static int tulip_mii_map_abilities(tulip_softc_t * const sc, unsigned abilities);
-static tulip_media_t tulip_mii_phy_readspecific(tulip_softc_t * const sc);
-static int tulip_srom_decode(tulip_softc_t * const sc);
-static int tulip_ifmedia_change(struct ifnet * const ifp);
-static void tulip_ifmedia_status(struct ifnet * const ifp, struct ifmediareq *req);
-/* static void tulip_21140_map_media(tulip_softc_t *sc); */
-
-static void
-tulip_timeout_callback(
- void *arg)
-{
- tulip_softc_t * const sc = arg;
- int s = splimp();
-
- TULIP_PERFSTART(timeout)
-
- sc->tulip_flags &= ~TULIP_TIMEOUTPENDING;
- sc->tulip_probe_timeout -= 1000 / TULIP_HZ;
- (sc->tulip_boardsw->bd_media_poll)(sc, TULIP_MEDIAPOLL_TIMER);
-
- TULIP_PERFEND(timeout);
- splx(s);
-}
-
-static void
-tulip_timeout(
- tulip_softc_t * const sc)
-{
- if (sc->tulip_flags & TULIP_TIMEOUTPENDING)
- return;
- sc->tulip_flags |= TULIP_TIMEOUTPENDING;
- timeout(tulip_timeout_callback, sc, (hz + TULIP_HZ / 2) / TULIP_HZ);
-}
-
-#if defined(TULIP_NEED_FASTTIMEOUT)
-static void
-tulip_fasttimeout_callback(
- void *arg)
-{
- tulip_softc_t * const sc = arg;
- int s = splimp();
-
- sc->tulip_flags &= ~TULIP_FASTTIMEOUTPENDING;
- (sc->tulip_boardsw->bd_media_poll)(sc, TULIP_MEDIAPOLL_FASTTIMER);
- splx(s);
-}
-
-static void
-tulip_fasttimeout(
- tulip_softc_t * const sc)
-{
- if (sc->tulip_flags & TULIP_FASTTIMEOUTPENDING)
- return;
- sc->tulip_flags |= TULIP_FASTTIMEOUTPENDING;
- timeout(tulip_fasttimeout_callback, sc, 1);
-}
-#endif
-
-static int
-tulip_txprobe(
- tulip_softc_t * const sc)
-{
- struct mbuf *m;
- /*
- * Before we are sure this is the right media we need
- * to send a small packet to make sure there's carrier.
- * Strangely, BNC and AUI will "see" receive data if
- * either is connected so the transmit is the only way
- * to verify the connectivity.
- */
- MGETHDR(m, M_DONTWAIT, MT_DATA);
- if (m == NULL)
- return 0;
- /*
- * Construct a LLC TEST message which will point to ourselves.
- */
- bcopy(sc->tulip_enaddr, mtod(m, struct ether_header *)->ether_dhost, 6);
- bcopy(sc->tulip_enaddr, mtod(m, struct ether_header *)->ether_shost, 6);
- mtod(m, struct ether_header *)->ether_type = htons(3);
- mtod(m, unsigned char *)[14] = 0;
- mtod(m, unsigned char *)[15] = 0;
- mtod(m, unsigned char *)[16] = 0xE3; /* LLC Class1 TEST (no poll) */
- m->m_len = m->m_pkthdr.len = sizeof(struct ether_header) + 3;
- /*
- * send it!
- */
- sc->tulip_cmdmode |= TULIP_CMD_TXRUN;
- sc->tulip_intrmask |= TULIP_STS_TXINTR;
- sc->tulip_flags |= TULIP_TXPROBE_ACTIVE;
- TULIP_CSR_WRITE(sc, csr_command, sc->tulip_cmdmode);
- TULIP_CSR_WRITE(sc, csr_intr, sc->tulip_intrmask);
- if ((m = tulip_txput(sc, m)) != NULL)
- m_freem(m);
- sc->tulip_probe.probe_txprobes++;
- return 1;
-}
-
-#ifdef BIG_PACKET
-#define TULIP_SIAGEN_WATCHDOG (sc->tulip_if.if_mtu > ETHERMTU ? TULIP_WATCHDOG_RXDISABLE|TULIP_WATCHDOG_TXDISABLE : 0)
-#else
-#define TULIP_SIAGEN_WATCHDOG 0
-#endif
-
-static void
-tulip_media_set(
- tulip_softc_t * const sc,
- tulip_media_t media)
-{
- const tulip_media_info_t *mi = sc->tulip_mediums[media];
-
- if (mi == NULL)
- return;
-
- /*
- * If we are switching media, make sure we don't think there's
- * any stale RX activity
- */
- sc->tulip_flags &= ~TULIP_RXACT;
- if (mi->mi_type == TULIP_MEDIAINFO_SIA) {
- TULIP_CSR_WRITE(sc, csr_sia_connectivity, TULIP_SIACONN_RESET);
- TULIP_CSR_WRITE(sc, csr_sia_tx_rx, mi->mi_sia_tx_rx);
- if (sc->tulip_features & TULIP_HAVE_SIAGP) {
- TULIP_CSR_WRITE(sc, csr_sia_general, mi->mi_sia_gp_control|mi->mi_sia_general|TULIP_SIAGEN_WATCHDOG);
- DELAY(50);
- TULIP_CSR_WRITE(sc, csr_sia_general, mi->mi_sia_gp_data|mi->mi_sia_general|TULIP_SIAGEN_WATCHDOG);
- } else {
- TULIP_CSR_WRITE(sc, csr_sia_general, mi->mi_sia_general|TULIP_SIAGEN_WATCHDOG);
- }
- TULIP_CSR_WRITE(sc, csr_sia_connectivity, mi->mi_sia_connectivity);
- } else if (mi->mi_type == TULIP_MEDIAINFO_GPR) {
-#define TULIP_GPR_CMDBITS (TULIP_CMD_PORTSELECT|TULIP_CMD_PCSFUNCTION|TULIP_CMD_SCRAMBLER|TULIP_CMD_TXTHRSHLDCTL)
- /*
- * If the cmdmode bits don't match the currently operating mode,
- * set the cmdmode appropriately and reset the chip.
- */
- if (((mi->mi_cmdmode ^ TULIP_CSR_READ(sc, csr_command)) & TULIP_GPR_CMDBITS) != 0) {
- sc->tulip_cmdmode &= ~TULIP_GPR_CMDBITS;
- sc->tulip_cmdmode |= mi->mi_cmdmode;
- tulip_reset(sc);
- }
- TULIP_CSR_WRITE(sc, csr_gp, TULIP_GP_PINSET|sc->tulip_gpinit);
- DELAY(10);
- TULIP_CSR_WRITE(sc, csr_gp, (u_int8_t) mi->mi_gpdata);
- } else if (mi->mi_type == TULIP_MEDIAINFO_SYM) {
- /*
- * If the cmdmode bits don't match the currently operating mode,
- * set the cmdmode appropriately and reset the chip.
- */
- if (((mi->mi_cmdmode ^ TULIP_CSR_READ(sc, csr_command)) & TULIP_GPR_CMDBITS) != 0) {
- sc->tulip_cmdmode &= ~TULIP_GPR_CMDBITS;
- sc->tulip_cmdmode |= mi->mi_cmdmode;
- tulip_reset(sc);
- }
- TULIP_CSR_WRITE(sc, csr_sia_general, mi->mi_gpcontrol);
- TULIP_CSR_WRITE(sc, csr_sia_general, mi->mi_gpdata);
- } else if (mi->mi_type == TULIP_MEDIAINFO_MII
- && sc->tulip_probe_state != TULIP_PROBE_INACTIVE) {
- int idx;
- if (sc->tulip_features & TULIP_HAVE_SIAGP) {
- const u_int8_t *dp;
- dp = &sc->tulip_rombuf[mi->mi_reset_offset];
- for (idx = 0; idx < mi->mi_reset_length; idx++, dp += 2) {
- DELAY(10);
- TULIP_CSR_WRITE(sc, csr_sia_general, (dp[0] + 256 * dp[1]) << 16);
- }
- sc->tulip_phyaddr = mi->mi_phyaddr;
- dp = &sc->tulip_rombuf[mi->mi_gpr_offset];
- for (idx = 0; idx < mi->mi_gpr_length; idx++, dp += 2) {
- DELAY(10);
- TULIP_CSR_WRITE(sc, csr_sia_general, (dp[0] + 256 * dp[1]) << 16);
- }
- } else {
- for (idx = 0; idx < mi->mi_reset_length; idx++) {
- DELAY(10);
- TULIP_CSR_WRITE(sc, csr_gp, sc->tulip_rombuf[mi->mi_reset_offset + idx]);
- }
- sc->tulip_phyaddr = mi->mi_phyaddr;
- for (idx = 0; idx < mi->mi_gpr_length; idx++) {
- DELAY(10);
- TULIP_CSR_WRITE(sc, csr_gp, sc->tulip_rombuf[mi->mi_gpr_offset + idx]);
- }
- }
- if (sc->tulip_flags & TULIP_TRYNWAY) {
- tulip_mii_autonegotiate(sc, sc->tulip_phyaddr);
- } else if ((sc->tulip_flags & TULIP_DIDNWAY) == 0) {
- u_int32_t data = tulip_mii_readreg(sc, sc->tulip_phyaddr, PHYREG_CONTROL);
- data &= ~(PHYCTL_SELECT_100MB|PHYCTL_FULL_DUPLEX|PHYCTL_AUTONEG_ENABLE);
- sc->tulip_flags &= ~TULIP_DIDNWAY;
- if (TULIP_IS_MEDIA_FD(media))
- data |= PHYCTL_FULL_DUPLEX;
- if (TULIP_IS_MEDIA_100MB(media))
- data |= PHYCTL_SELECT_100MB;
- tulip_mii_writereg(sc, sc->tulip_phyaddr, PHYREG_CONTROL, data);
- }
- }
-}
-
-static void
-tulip_linkup(
- tulip_softc_t * const sc,
- tulip_media_t media)
-{
- if ((sc->tulip_flags & TULIP_LINKUP) == 0)
- sc->tulip_flags |= TULIP_PRINTLINKUP;
- sc->tulip_flags |= TULIP_LINKUP;
- sc->tulip_if.if_flags &= ~IFF_OACTIVE;
-#if 0 /* XXX how does with work with ifmedia? */
- if ((sc->tulip_flags & TULIP_DIDNWAY) == 0) {
- if (sc->tulip_if.if_flags & IFF_FULLDUPLEX) {
- if (TULIP_CAN_MEDIA_FD(media)
- && sc->tulip_mediums[TULIP_FD_MEDIA_OF(media)] != NULL)
- media = TULIP_FD_MEDIA_OF(media);
- } else {
- if (TULIP_IS_MEDIA_FD(media)
- && sc->tulip_mediums[TULIP_HD_MEDIA_OF(media)] != NULL)
- media = TULIP_HD_MEDIA_OF(media);
- }
- }
-#endif
- if (sc->tulip_media != media) {
-#ifdef TULIP_DEBUG
- sc->tulip_dbg.dbg_last_media = sc->tulip_media;
-#endif
- sc->tulip_media = media;
- sc->tulip_flags |= TULIP_PRINTMEDIA;
- if (TULIP_IS_MEDIA_FD(sc->tulip_media)) {
- sc->tulip_cmdmode |= TULIP_CMD_FULLDUPLEX;
- } else if (sc->tulip_chipid != TULIP_21041 || (sc->tulip_flags & TULIP_DIDNWAY) == 0) {
- sc->tulip_cmdmode &= ~TULIP_CMD_FULLDUPLEX;
- }
- }
- /*
- * We could set probe_timeout to 0 but setting to 3000 puts this
- * in one central place and the only matters is tulip_link is
- * followed by a tulip_timeout. Therefore setting it should not
- * result in aberrant behavour.
- */
- sc->tulip_probe_timeout = 3000;
- sc->tulip_probe_state = TULIP_PROBE_INACTIVE;
- sc->tulip_flags &= ~(TULIP_TXPROBE_ACTIVE|TULIP_TRYNWAY);
- if (sc->tulip_flags & TULIP_INRESET) {
- tulip_media_set(sc, sc->tulip_media);
- } else if (sc->tulip_probe_media != sc->tulip_media) {
- /*
- * No reason to change media if we have the right media.
- */
- tulip_reset(sc);
- }
- tulip_init(sc);
-}
-
-static void
-tulip_media_print(
- tulip_softc_t * const sc)
-{
- if ((sc->tulip_flags & TULIP_LINKUP) == 0)
- return;
- if (sc->tulip_flags & TULIP_PRINTMEDIA) {
- printf("%s%d: enabling %s port\n",
- sc->tulip_name, sc->tulip_unit,
- tulip_mediums[sc->tulip_media]);
- sc->tulip_flags &= ~(TULIP_PRINTMEDIA|TULIP_PRINTLINKUP);
- } else if (sc->tulip_flags & TULIP_PRINTLINKUP) {
- printf("%s%d: link up\n", sc->tulip_name, sc->tulip_unit);
- sc->tulip_flags &= ~TULIP_PRINTLINKUP;
- }
-}
-
-#if defined(TULIP_DO_GPR_SENSE)
-static tulip_media_t
-tulip_21140_gpr_media_sense(
- tulip_softc_t * const sc)
-{
- tulip_media_t maybe_media = TULIP_MEDIA_UNKNOWN;
- tulip_media_t last_media = TULIP_MEDIA_UNKNOWN;
- tulip_media_t media;
-
- /*
- * If one of the media blocks contained a default media flag,
- * use that.
- */
- for (media = TULIP_MEDIA_UNKNOWN; media < TULIP_MEDIA_MAX; media++) {
- const tulip_media_info_t *mi;
- /*
- * Media is not supported (or is full-duplex).
- */
- if ((mi = sc->tulip_mediums[media]) == NULL || TULIP_IS_MEDIA_FD(media))
- continue;
- if (mi->mi_type != TULIP_MEDIAINFO_GPR)
- continue;
-
- /*
- * Remember the media is this is the "default" media.
- */
- if (mi->mi_default && maybe_media == TULIP_MEDIA_UNKNOWN)
- maybe_media = media;
-
- /*
- * No activity mask? Can't see if it is active if there's no mask.
- */
- if (mi->mi_actmask == 0)
- continue;
-
- /*
- * Does the activity data match?
- */
- if ((TULIP_CSR_READ(sc, csr_gp) & mi->mi_actmask) != mi->mi_actdata)
- continue;
-
-#if defined(TULIP_DEBUG)
- printf("%s%d: gpr_media_sense: %s: 0x%02x & 0x%02x == 0x%02x\n",
- sc->tulip_name, sc->tulip_unit, tulip_mediums[media],
- TULIP_CSR_READ(sc, csr_gp) & 0xFF,
- mi->mi_actmask, mi->mi_actdata);
-#endif
- /*
- * It does! If this is the first media we detected, then
- * remember this media. If isn't the first, then there were
- * multiple matches which we equate to no match (since we don't
- * which to select (if any).
- */
- if (last_media == TULIP_MEDIA_UNKNOWN) {
- last_media = media;
- } else if (last_media != media) {
- last_media = TULIP_MEDIA_UNKNOWN;
- }
- }
- return (last_media != TULIP_MEDIA_UNKNOWN) ? last_media : maybe_media;
-}
-#endif /* TULIP_DO_GPR_SENSE */
-
-static tulip_link_status_t
-tulip_media_link_monitor(
- tulip_softc_t * const sc)
-{
- const tulip_media_info_t * const mi = sc->tulip_mediums[sc->tulip_media];
- tulip_link_status_t linkup = TULIP_LINK_DOWN;
-
- if (mi == NULL) {
-#if defined(DIAGNOSTIC) || defined(TULIP_DEBUG)
- panic("tulip_media_link_monitor: %s: botch at line %d\n",
- tulip_mediums[sc->tulip_media],__LINE__);
-#endif
- return TULIP_LINK_UNKNOWN;
- }
-
-
- /*
- * Have we seen some packets? If so, the link must be good.
- */
- if ((sc->tulip_flags & (TULIP_RXACT|TULIP_LINKUP)) == (TULIP_RXACT|TULIP_LINKUP)) {
- sc->tulip_flags &= ~TULIP_RXACT;
- sc->tulip_probe_timeout = 3000;
- return TULIP_LINK_UP;
- }
-
- sc->tulip_flags &= ~TULIP_RXACT;
- if (mi->mi_type == TULIP_MEDIAINFO_MII) {
- u_int32_t status;
- /*
- * Read the PHY status register.
- */
- status = tulip_mii_readreg(sc, sc->tulip_phyaddr, PHYREG_STATUS);
- if (status & PHYSTS_AUTONEG_DONE) {
- /*
- * If the PHY has completed autonegotiation, see the if the
- * remote systems abilities have changed. If so, upgrade or
- * downgrade as appropriate.
- */
- u_int32_t abilities = tulip_mii_readreg(sc, sc->tulip_phyaddr, PHYREG_AUTONEG_ABILITIES);
- abilities = (abilities << 6) & status;
- if (abilities != sc->tulip_abilities) {
-#if defined(TULIP_DEBUG)
- loudprintf("%s%d(phy%d): autonegotiation changed: 0x%04x -> 0x%04x\n",
- sc->tulip_name, sc->tulip_unit, sc->tulip_phyaddr,
- sc->tulip_abilities, abilities);
-#endif
- if (tulip_mii_map_abilities(sc, abilities)) {
- tulip_linkup(sc, sc->tulip_probe_media);
- return TULIP_LINK_UP;
- }
- /*
- * if we had selected media because of autonegotiation,
- * we need to probe for the new media.
- */
- sc->tulip_probe_state = TULIP_PROBE_INACTIVE;
- if (sc->tulip_flags & TULIP_DIDNWAY)
- return TULIP_LINK_DOWN;
- }
- }
- /*
- * The link is now up. If was down, say its back up.
- */
- if ((status & (PHYSTS_LINK_UP|PHYSTS_REMOTE_FAULT)) == PHYSTS_LINK_UP)
- linkup = TULIP_LINK_UP;
- } else if (mi->mi_type == TULIP_MEDIAINFO_GPR) {
- /*
- * No activity sensor? Assume all's well.
- */
- if (mi->mi_actmask == 0)
- return TULIP_LINK_UNKNOWN;
- /*
- * Does the activity data match?
- */
- if ((TULIP_CSR_READ(sc, csr_gp) & mi->mi_actmask) == mi->mi_actdata)
- linkup = TULIP_LINK_UP;
- } else if (mi->mi_type == TULIP_MEDIAINFO_SIA) {
- /*
- * Assume non TP ok for now.
- */
- if (!TULIP_IS_MEDIA_TP(sc->tulip_media))
- return TULIP_LINK_UNKNOWN;
- if ((TULIP_CSR_READ(sc, csr_sia_status) & TULIP_SIASTS_LINKFAIL) == 0)
- linkup = TULIP_LINK_UP;
-#if defined(TULIP_DEBUG)
- if (sc->tulip_probe_timeout <= 0)
- printf("%s%d: sia status = 0x%08x\n", sc->tulip_name,
- sc->tulip_unit, TULIP_CSR_READ(sc, csr_sia_status));
-#endif
- } else if (mi->mi_type == TULIP_MEDIAINFO_SYM) {
- return TULIP_LINK_UNKNOWN;
- }
- /*
- * We will wait for 3 seconds until the link goes into suspect mode.
- */
- if (sc->tulip_flags & TULIP_LINKUP) {
- if (linkup == TULIP_LINK_UP)
- sc->tulip_probe_timeout = 3000;
- if (sc->tulip_probe_timeout > 0)
- return TULIP_LINK_UP;
-
- sc->tulip_flags &= ~TULIP_LINKUP;
- printf("%s%d: link down: cable problem?\n", sc->tulip_name, sc->tulip_unit);
- }
-#if defined(TULIP_DEBUG)
- sc->tulip_dbg.dbg_link_downed++;
-#endif
- return TULIP_LINK_DOWN;
-}
-
-static void
-tulip_media_poll(
- tulip_softc_t * const sc,
- tulip_mediapoll_event_t event)
-{
-#if defined(TULIP_DEBUG)
- sc->tulip_dbg.dbg_events[event]++;
-#endif
- if (sc->tulip_probe_state == TULIP_PROBE_INACTIVE
- && event == TULIP_MEDIAPOLL_TIMER) {
- switch (tulip_media_link_monitor(sc)) {
- case TULIP_LINK_DOWN: {
- /*
- * Link Monitor failed. Probe for new media.
- */
- event = TULIP_MEDIAPOLL_LINKFAIL;
- break;
- }
- case TULIP_LINK_UP: {
- /*
- * Check again soon.
- */
- tulip_timeout(sc);
- return;
- }
- case TULIP_LINK_UNKNOWN: {
- /*
- * We can't tell so don't bother.
- */
- return;
- }
- }
- }
-
- if (event == TULIP_MEDIAPOLL_LINKFAIL) {
- if (sc->tulip_probe_state == TULIP_PROBE_INACTIVE) {
- if (TULIP_DO_AUTOSENSE(sc)) {
-#if defined(TULIP_DEBUG)
- sc->tulip_dbg.dbg_link_failures++;
-#endif
- sc->tulip_media = TULIP_MEDIA_UNKNOWN;
- if (sc->tulip_if.if_flags & IFF_UP)
- tulip_reset(sc); /* restart probe */
- }
- return;
- }
-#if defined(TULIP_DEBUG)
- sc->tulip_dbg.dbg_link_pollintrs++;
-#endif
- }
-
- if (event == TULIP_MEDIAPOLL_START) {
- sc->tulip_if.if_flags |= IFF_OACTIVE;
- if (sc->tulip_probe_state != TULIP_PROBE_INACTIVE)
- return;
- sc->tulip_probe_mediamask = 0;
- sc->tulip_probe_passes = 0;
-#if defined(TULIP_DEBUG)
- sc->tulip_dbg.dbg_media_probes++;
-#endif
- /*
- * If the SROM contained an explicit media to use, use it.
- */
- sc->tulip_cmdmode &= ~(TULIP_CMD_RXRUN|TULIP_CMD_FULLDUPLEX);
- sc->tulip_flags |= TULIP_TRYNWAY|TULIP_PROBE1STPASS;
- sc->tulip_flags &= ~(TULIP_DIDNWAY|TULIP_PRINTMEDIA|TULIP_PRINTLINKUP);
- /*
- * connidx is defaulted to a media_unknown type.
- */
- sc->tulip_probe_media = tulip_srom_conninfo[sc->tulip_connidx].sc_media;
- if (sc->tulip_probe_media != TULIP_MEDIA_UNKNOWN) {
- tulip_linkup(sc, sc->tulip_probe_media);
- tulip_timeout(sc);
- return;
- }
-
- if (sc->tulip_features & TULIP_HAVE_GPR) {
- sc->tulip_probe_state = TULIP_PROBE_GPRTEST;
- sc->tulip_probe_timeout = 2000;
- } else {
- sc->tulip_probe_media = TULIP_MEDIA_MAX;
- sc->tulip_probe_timeout = 0;
- sc->tulip_probe_state = TULIP_PROBE_MEDIATEST;
- }
- }
-
- /*
- * Ignore txprobe failures or spurious callbacks.
- */
- if (event == TULIP_MEDIAPOLL_TXPROBE_FAILED
- && sc->tulip_probe_state != TULIP_PROBE_MEDIATEST) {
- sc->tulip_flags &= ~TULIP_TXPROBE_ACTIVE;
- return;
- }
-
- /*
- * If we really transmitted a packet, then that's the media we'll use.
- */
- if (event == TULIP_MEDIAPOLL_TXPROBE_OK || event == TULIP_MEDIAPOLL_LINKPASS) {
- if (event == TULIP_MEDIAPOLL_LINKPASS) {
- /* XXX Check media status just to be sure */
- sc->tulip_probe_media = TULIP_MEDIA_10BASET;
-#if defined(TULIP_DEBUG)
- } else {
- sc->tulip_dbg.dbg_txprobes_ok[sc->tulip_probe_media]++;
-#endif
- }
- tulip_linkup(sc, sc->tulip_probe_media);
- tulip_timeout(sc);
- return;
- }
-
- if (sc->tulip_probe_state == TULIP_PROBE_GPRTEST) {
-#if defined(TULIP_DO_GPR_SENSE)
- /*
- * Check for media via the general purpose register.
- *
- * Try to sense the media via the GPR. If the same value
- * occurs 3 times in a row then just use that.
- */
- if (sc->tulip_probe_timeout > 0) {
- tulip_media_t new_probe_media = tulip_21140_gpr_media_sense(sc);
-#if defined(TULIP_DEBUG)
- printf("%s%d: media_poll: gpr sensing = %s\n",
- sc->tulip_name, sc->tulip_unit, tulip_mediums[new_probe_media]);
-#endif
- if (new_probe_media != TULIP_MEDIA_UNKNOWN) {
- if (new_probe_media == sc->tulip_probe_media) {
- if (--sc->tulip_probe_count == 0)
- tulip_linkup(sc, sc->tulip_probe_media);
- } else {
- sc->tulip_probe_count = 10;
- }
- }
- sc->tulip_probe_media = new_probe_media;
- tulip_timeout(sc);
- return;
- }
-#endif /* TULIP_DO_GPR_SENSE */
- /*
- * Brute force. We cycle through each of the media types
- * and try to transmit a packet.
- */
- sc->tulip_probe_state = TULIP_PROBE_MEDIATEST;
- sc->tulip_probe_media = TULIP_MEDIA_MAX;
- sc->tulip_probe_timeout = 0;
- tulip_timeout(sc);
- return;
- }
-
- if (sc->tulip_probe_state != TULIP_PROBE_MEDIATEST
- && (sc->tulip_features & TULIP_HAVE_MII)) {
- tulip_media_t old_media = sc->tulip_probe_media;
- tulip_mii_autonegotiate(sc, sc->tulip_phyaddr);
- switch (sc->tulip_probe_state) {
- case TULIP_PROBE_FAILED:
- case TULIP_PROBE_MEDIATEST: {
- /*
- * Try the next media.
- */
- sc->tulip_probe_mediamask |= sc->tulip_mediums[sc->tulip_probe_media]->mi_mediamask;
- sc->tulip_probe_timeout = 0;
-#ifdef notyet
- if (sc->tulip_probe_state == TULIP_PROBE_FAILED)
- break;
- if (sc->tulip_probe_media != tulip_mii_phy_readspecific(sc))
- break;
- sc->tulip_probe_timeout = TULIP_IS_MEDIA_TP(sc->tulip_probe_media) ? 2500 : 300;
-#endif
- break;
- }
- case TULIP_PROBE_PHYAUTONEG: {
- return;
- }
- case TULIP_PROBE_INACTIVE: {
- /*
- * Only probe if we autonegotiated a media that hasn't failed.
- */
- sc->tulip_probe_timeout = 0;
- if (sc->tulip_probe_mediamask & TULIP_BIT(sc->tulip_probe_media)) {
- sc->tulip_probe_media = old_media;
- break;
- }
- tulip_linkup(sc, sc->tulip_probe_media);
- tulip_timeout(sc);
- return;
- }
- default: {
-#if defined(DIAGNOSTIC) || defined(TULIP_DEBUG)
- panic("tulip_media_poll: botch at line %d\n", __LINE__);
-#endif
- break;
- }
- }
- }
-
- if (event == TULIP_MEDIAPOLL_TXPROBE_FAILED) {
-#if defined(TULIP_DEBUG)
- sc->tulip_dbg.dbg_txprobes_failed[sc->tulip_probe_media]++;
-#endif
- sc->tulip_flags &= ~TULIP_TXPROBE_ACTIVE;
- return;
- }
-
- /*
- * switch to another media if we tried this one enough.
- */
- if (/* event == TULIP_MEDIAPOLL_TXPROBE_FAILED || */ sc->tulip_probe_timeout <= 0) {
-#if defined(TULIP_DEBUG)
- if (sc->tulip_probe_media == TULIP_MEDIA_UNKNOWN) {
- printf("%s%d: poll media unknown!\n",
- sc->tulip_name, sc->tulip_unit);
- sc->tulip_probe_media = TULIP_MEDIA_MAX;
- }
-#endif
- /*
- * Find the next media type to check for. Full Duplex
- * types are not allowed.
- */
- do {
- sc->tulip_probe_media -= 1;
- if (sc->tulip_probe_media == TULIP_MEDIA_UNKNOWN) {
- if (++sc->tulip_probe_passes == 3) {
- printf("%s%d: autosense failed: cable problem?\n",
- sc->tulip_name, sc->tulip_unit);
- if ((sc->tulip_if.if_flags & IFF_UP) == 0) {
- sc->tulip_if.if_flags &= ~IFF_RUNNING;
- sc->tulip_probe_state = TULIP_PROBE_INACTIVE;
- return;
- }
- }
- sc->tulip_flags ^= TULIP_TRYNWAY; /* XXX */
- sc->tulip_probe_mediamask = 0;
- sc->tulip_probe_media = TULIP_MEDIA_MAX - 1;
- }
- } while (sc->tulip_mediums[sc->tulip_probe_media] == NULL
- || (sc->tulip_probe_mediamask & TULIP_BIT(sc->tulip_probe_media))
- || TULIP_IS_MEDIA_FD(sc->tulip_probe_media));
-
-#if defined(TULIP_DEBUG)
- printf("%s%d: %s: probing %s\n", sc->tulip_name, sc->tulip_unit,
- event == TULIP_MEDIAPOLL_TXPROBE_FAILED ? "txprobe failed" : "timeout",
- tulip_mediums[sc->tulip_probe_media]);
-#endif
- sc->tulip_probe_timeout = TULIP_IS_MEDIA_TP(sc->tulip_probe_media) ? 2500 : 1000;
- sc->tulip_probe_state = TULIP_PROBE_MEDIATEST;
- sc->tulip_probe.probe_txprobes = 0;
- tulip_reset(sc);
- tulip_media_set(sc, sc->tulip_probe_media);
- sc->tulip_flags &= ~TULIP_TXPROBE_ACTIVE;
- }
- tulip_timeout(sc);
-
- /*
- * If this is hanging off a phy, we know are doing NWAY and we have
- * forced the phy to a specific speed. Wait for link up before
- * before sending a packet.
- */
- switch (sc->tulip_mediums[sc->tulip_probe_media]->mi_type) {
- case TULIP_MEDIAINFO_MII: {
- if (sc->tulip_probe_media != tulip_mii_phy_readspecific(sc))
- return;
- break;
- }
- case TULIP_MEDIAINFO_SIA: {
- if (TULIP_IS_MEDIA_TP(sc->tulip_probe_media)) {
- if (TULIP_CSR_READ(sc, csr_sia_status) & TULIP_SIASTS_LINKFAIL)
- return;
- tulip_linkup(sc, sc->tulip_probe_media);
-#ifdef notyet
- if (sc->tulip_features & TULIP_HAVE_MII)
- tulip_timeout(sc);
-#endif
- return;
- }
- break;
- }
- case TULIP_MEDIAINFO_RESET:
- case TULIP_MEDIAINFO_SYM:
- case TULIP_MEDIAINFO_NONE:
- case TULIP_MEDIAINFO_GPR: {
- break;
- }
- }
- /*
- * Try to send a packet.
- */
- tulip_txprobe(sc);
-}
-
-static void
-tulip_media_select(
- tulip_softc_t * const sc)
-{
- if (sc->tulip_features & TULIP_HAVE_GPR) {
- TULIP_CSR_WRITE(sc, csr_gp, TULIP_GP_PINSET|sc->tulip_gpinit);
- DELAY(10);
- TULIP_CSR_WRITE(sc, csr_gp, sc->tulip_gpdata);
- }
- /*
- * If this board has no media, just return
- */
- if (sc->tulip_features & TULIP_HAVE_NOMEDIA)
- return;
-
- if (sc->tulip_media == TULIP_MEDIA_UNKNOWN) {
- TULIP_CSR_WRITE(sc, csr_intr, sc->tulip_intrmask);
- (*sc->tulip_boardsw->bd_media_poll)(sc, TULIP_MEDIAPOLL_START);
- } else {
- tulip_media_set(sc, sc->tulip_media);
- }
-}
-
-static void
-tulip_21040_mediainfo_init(
- tulip_softc_t * const sc,
- tulip_media_t media)
-{
- sc->tulip_cmdmode |= TULIP_CMD_CAPTREFFCT|TULIP_CMD_THRSHLD160
- |TULIP_CMD_BACKOFFCTR;
- sc->tulip_if.if_baudrate = 10000000;
-
- if (media == TULIP_MEDIA_10BASET || media == TULIP_MEDIA_UNKNOWN) {
- TULIP_MEDIAINFO_SIA_INIT(sc, &sc->tulip_mediainfo[0], 21040, 10BASET);
- TULIP_MEDIAINFO_SIA_INIT(sc, &sc->tulip_mediainfo[1], 21040, 10BASET_FD);
- sc->tulip_intrmask |= TULIP_STS_LINKPASS|TULIP_STS_LINKFAIL;
- }
-
- if (media == TULIP_MEDIA_AUIBNC || media == TULIP_MEDIA_UNKNOWN) {
- TULIP_MEDIAINFO_SIA_INIT(sc, &sc->tulip_mediainfo[2], 21040, AUIBNC);
- }
-
- if (media == TULIP_MEDIA_UNKNOWN) {
- TULIP_MEDIAINFO_SIA_INIT(sc, &sc->tulip_mediainfo[3], 21040, EXTSIA);
- }
-}
-
-static void
-tulip_21040_media_probe(
- tulip_softc_t * const sc)
-{
- tulip_21040_mediainfo_init(sc, TULIP_MEDIA_UNKNOWN);
- return;
-}
-
-static void
-tulip_21040_10baset_only_media_probe(
- tulip_softc_t * const sc)
-{
- tulip_21040_mediainfo_init(sc, TULIP_MEDIA_10BASET);
- tulip_media_set(sc, TULIP_MEDIA_10BASET);
- sc->tulip_media = TULIP_MEDIA_10BASET;
-}
-
-static void
-tulip_21040_10baset_only_media_select(
- tulip_softc_t * const sc)
-{
- sc->tulip_flags |= TULIP_LINKUP;
- if (sc->tulip_media == TULIP_MEDIA_10BASET_FD) {
- sc->tulip_cmdmode |= TULIP_CMD_FULLDUPLEX;
- sc->tulip_flags &= ~TULIP_SQETEST;
- } else {
- sc->tulip_cmdmode &= ~TULIP_CMD_FULLDUPLEX;
- sc->tulip_flags |= TULIP_SQETEST;
- }
- tulip_media_set(sc, sc->tulip_media);
-}
-
-static void
-tulip_21040_auibnc_only_media_probe(
- tulip_softc_t * const sc)
-{
- tulip_21040_mediainfo_init(sc, TULIP_MEDIA_AUIBNC);
- sc->tulip_flags |= TULIP_SQETEST|TULIP_LINKUP;
- tulip_media_set(sc, TULIP_MEDIA_AUIBNC);
- sc->tulip_media = TULIP_MEDIA_AUIBNC;
-}
-
-static void
-tulip_21040_auibnc_only_media_select(
- tulip_softc_t * const sc)
-{
- tulip_media_set(sc, TULIP_MEDIA_AUIBNC);
- sc->tulip_cmdmode &= ~TULIP_CMD_FULLDUPLEX;
-}
-
-static const tulip_boardsw_t tulip_21040_boardsw = {
- TULIP_21040_GENERIC,
- tulip_21040_media_probe,
- tulip_media_select,
- tulip_media_poll,
-};
-
-static const tulip_boardsw_t tulip_21040_10baset_only_boardsw = {
- TULIP_21040_GENERIC,
- tulip_21040_10baset_only_media_probe,
- tulip_21040_10baset_only_media_select,
- NULL,
-};
-
-static const tulip_boardsw_t tulip_21040_auibnc_only_boardsw = {
- TULIP_21040_GENERIC,
- tulip_21040_auibnc_only_media_probe,
- tulip_21040_auibnc_only_media_select,
- NULL,
-};
-
-static void
-tulip_21041_mediainfo_init(
- tulip_softc_t * const sc)
-{
- tulip_media_info_t * const mi = sc->tulip_mediainfo;
-
-#ifdef notyet
- if (sc->tulip_revinfo >= 0x20) {
- TULIP_MEDIAINFO_SIA_INIT(sc, &mi[0], 21041P2, 10BASET);
- TULIP_MEDIAINFO_SIA_INIT(sc, &mi[1], 21041P2, 10BASET_FD);
- TULIP_MEDIAINFO_SIA_INIT(sc, &mi[0], 21041P2, AUI);
- TULIP_MEDIAINFO_SIA_INIT(sc, &mi[1], 21041P2, BNC);
- return;
- }
-#endif
- TULIP_MEDIAINFO_SIA_INIT(sc, &mi[0], 21041, 10BASET);
- TULIP_MEDIAINFO_SIA_INIT(sc, &mi[1], 21041, 10BASET_FD);
- TULIP_MEDIAINFO_SIA_INIT(sc, &mi[2], 21041, AUI);
- TULIP_MEDIAINFO_SIA_INIT(sc, &mi[3], 21041, BNC);
-}
-
-static void
-tulip_21041_media_probe(
- tulip_softc_t * const sc)
-{
- sc->tulip_if.if_baudrate = 10000000;
- sc->tulip_cmdmode |= TULIP_CMD_CAPTREFFCT|TULIP_CMD_ENHCAPTEFFCT
- |TULIP_CMD_THRSHLD160|TULIP_CMD_BACKOFFCTR;
- sc->tulip_intrmask |= TULIP_STS_LINKPASS|TULIP_STS_LINKFAIL;
- tulip_21041_mediainfo_init(sc);
-}
-
-static void
-tulip_21041_media_poll(
- tulip_softc_t * const sc,
- const tulip_mediapoll_event_t event)
-{
- u_int32_t sia_status;
-
-#if defined(TULIP_DEBUG)
- sc->tulip_dbg.dbg_events[event]++;
-#endif
-
- if (event == TULIP_MEDIAPOLL_LINKFAIL) {
- if (sc->tulip_probe_state != TULIP_PROBE_INACTIVE
- || !TULIP_DO_AUTOSENSE(sc))
- return;
- sc->tulip_media = TULIP_MEDIA_UNKNOWN;
- tulip_reset(sc); /* start probe */
- return;
- }
-
- /*
- * If we've been been asked to start a poll or link change interrupt
- * restart the probe (and reset the tulip to a known state).
- */
- if (event == TULIP_MEDIAPOLL_START) {
- sc->tulip_if.if_flags |= IFF_OACTIVE;
- sc->tulip_cmdmode &= ~(TULIP_CMD_FULLDUPLEX|TULIP_CMD_RXRUN);
-#ifdef notyet
- if (sc->tulip_revinfo >= 0x20) {
- sc->tulip_cmdmode |= TULIP_CMD_FULLDUPLEX;
- sc->tulip_flags |= TULIP_DIDNWAY;
- }
-#endif
- TULIP_CSR_WRITE(sc, csr_command, sc->tulip_cmdmode);
- sc->tulip_probe_state = TULIP_PROBE_MEDIATEST;
- sc->tulip_probe_media = TULIP_MEDIA_10BASET;
- sc->tulip_probe_timeout = TULIP_21041_PROBE_10BASET_TIMEOUT;
- tulip_media_set(sc, TULIP_MEDIA_10BASET);
- tulip_timeout(sc);
- return;
- }
-
- if (sc->tulip_probe_state == TULIP_PROBE_INACTIVE)
- return;
-
- if (event == TULIP_MEDIAPOLL_TXPROBE_OK) {
-#if defined(TULIP_DEBUG)
- sc->tulip_dbg.dbg_txprobes_ok[sc->tulip_probe_media]++;
-#endif
- tulip_linkup(sc, sc->tulip_probe_media);
- return;
- }
-
- sia_status = TULIP_CSR_READ(sc, csr_sia_status);
- TULIP_CSR_WRITE(sc, csr_sia_status, sia_status);
- if ((sia_status & TULIP_SIASTS_LINKFAIL) == 0) {
- if (sc->tulip_revinfo >= 0x20) {
- if (sia_status & (PHYSTS_10BASET_FD << (16 - 6)))
- sc->tulip_probe_media = TULIP_MEDIA_10BASET_FD;
- }
- /*
- * If the link has passed LinkPass, 10baseT is the
- * proper media to use.
- */
- tulip_linkup(sc, sc->tulip_probe_media);
- return;
- }
-
- /*
- * wait for up to 2.4 seconds for the link to reach pass state.
- * Only then start scanning the other media for activity.
- * choose media with receive activity over those without.
- */
- if (sc->tulip_probe_media == TULIP_MEDIA_10BASET) {
- if (event != TULIP_MEDIAPOLL_TIMER)
- return;
- if (sc->tulip_probe_timeout > 0
- && (sia_status & TULIP_SIASTS_OTHERRXACTIVITY) == 0) {
- tulip_timeout(sc);
- return;
- }
- sc->tulip_probe_timeout = TULIP_21041_PROBE_AUIBNC_TIMEOUT;
- sc->tulip_flags |= TULIP_WANTRXACT;
- if (sia_status & TULIP_SIASTS_OTHERRXACTIVITY) {
- sc->tulip_probe_media = TULIP_MEDIA_BNC;
- } else {
- sc->tulip_probe_media = TULIP_MEDIA_AUI;
- }
- tulip_media_set(sc, sc->tulip_probe_media);
- tulip_timeout(sc);
- return;
- }
-
- /*
- * If we failed, clear the txprobe active flag.
- */
- if (event == TULIP_MEDIAPOLL_TXPROBE_FAILED)
- sc->tulip_flags &= ~TULIP_TXPROBE_ACTIVE;
-
-
- if (event == TULIP_MEDIAPOLL_TIMER) {
- /*
- * If we've received something, then that's our link!
- */
- if (sc->tulip_flags & TULIP_RXACT) {
- tulip_linkup(sc, sc->tulip_probe_media);
- return;
- }
- /*
- * if no txprobe active
- */
- if ((sc->tulip_flags & TULIP_TXPROBE_ACTIVE) == 0
- && ((sc->tulip_flags & TULIP_WANTRXACT) == 0
- || (sia_status & TULIP_SIASTS_RXACTIVITY))) {
- sc->tulip_probe_timeout = TULIP_21041_PROBE_AUIBNC_TIMEOUT;
- tulip_txprobe(sc);
- tulip_timeout(sc);
- return;
- }
- /*
- * Take 2 passes through before deciding to not
- * wait for receive activity. Then take another
- * two passes before spitting out a warning.
- */
- if (sc->tulip_probe_timeout <= 0) {
- if (sc->tulip_flags & TULIP_WANTRXACT) {
- sc->tulip_flags &= ~TULIP_WANTRXACT;
- sc->tulip_probe_timeout = TULIP_21041_PROBE_AUIBNC_TIMEOUT;
- } else {
- printf("%s%d: autosense failed: cable problem?\n",
- sc->tulip_name, sc->tulip_unit);
- if ((sc->tulip_if.if_flags & IFF_UP) == 0) {
- sc->tulip_if.if_flags &= ~IFF_RUNNING;
- sc->tulip_probe_state = TULIP_PROBE_INACTIVE;
- return;
- }
- }
- }
- }
-
- /*
- * Since this media failed to probe, try the other one.
- */
- sc->tulip_probe_timeout = TULIP_21041_PROBE_AUIBNC_TIMEOUT;
- if (sc->tulip_probe_media == TULIP_MEDIA_AUI) {
- sc->tulip_probe_media = TULIP_MEDIA_BNC;
- } else {
- sc->tulip_probe_media = TULIP_MEDIA_AUI;
- }
- tulip_media_set(sc, sc->tulip_probe_media);
- sc->tulip_flags &= ~TULIP_TXPROBE_ACTIVE;
- tulip_timeout(sc);
-}
-
-static const tulip_boardsw_t tulip_21041_boardsw = {
- TULIP_21041_GENERIC,
- tulip_21041_media_probe,
- tulip_media_select,
- tulip_21041_media_poll
-};
-
-static const tulip_phy_attr_t tulip_mii_phy_attrlist[] = {
- { 0x20005c00, 0, /* 08-00-17 */
- {
- { 0x19, 0x0040, 0x0040 }, /* 10TX */
- { 0x19, 0x0040, 0x0000 }, /* 100TX */
- },
-#if defined(TULIP_DEBUG)
- "NS DP83840",
-#endif
- },
- { 0x0281F400, 0, /* 00-A0-7D */
- {
- { 0x12, 0x0010, 0x0000 }, /* 10T */
- { }, /* 100TX */
- { 0x12, 0x0010, 0x0010 }, /* 100T4 */
- { 0x12, 0x0008, 0x0008 }, /* FULL_DUPLEX */
- },
-#if defined(TULIP_DEBUG)
- "Seeq 80C240"
-#endif
- },
-#if 0
- { 0x0015F420, 0, /* 00-A0-7D */
- {
- { 0x12, 0x0010, 0x0000 }, /* 10T */
- { }, /* 100TX */
- { 0x12, 0x0010, 0x0010 }, /* 100T4 */
- { 0x12, 0x0008, 0x0008 }, /* FULL_DUPLEX */
- },
-#if defined(TULIP_DEBUG)
- "Broadcom BCM5000"
-#endif
- },
-#endif
- { 0x0281F400, 0, /* 00-A0-BE */
- {
- { 0x11, 0x8000, 0x0000 }, /* 10T */
- { 0x11, 0x8000, 0x8000 }, /* 100TX */
- { }, /* 100T4 */
- { 0x11, 0x4000, 0x4000 }, /* FULL_DUPLEX */
- },
-#if defined(TULIP_DEBUG)
- "ICS 1890"
-#endif
- },
- { 0 }
-};
-
-static tulip_media_t
-tulip_mii_phy_readspecific(
- tulip_softc_t * const sc)
-{
- const tulip_phy_attr_t *attr;
- u_int16_t data;
- u_int32_t id;
- unsigned idx = 0;
- static const tulip_media_t table[] = {
- TULIP_MEDIA_UNKNOWN,
- TULIP_MEDIA_10BASET,
- TULIP_MEDIA_100BASETX,
- TULIP_MEDIA_100BASET4,
- TULIP_MEDIA_UNKNOWN,
- TULIP_MEDIA_10BASET_FD,
- TULIP_MEDIA_100BASETX_FD,
- TULIP_MEDIA_UNKNOWN
- };
-
- /*
- * Don't read phy specific registers if link is not up.
- */
- data = tulip_mii_readreg(sc, sc->tulip_phyaddr, PHYREG_STATUS);
- if ((data & (PHYSTS_LINK_UP|PHYSTS_EXTENDED_REGS)) != (PHYSTS_LINK_UP|PHYSTS_EXTENDED_REGS))
- return TULIP_MEDIA_UNKNOWN;
-
- id = (tulip_mii_readreg(sc, sc->tulip_phyaddr, PHYREG_IDLOW) << 16) |
- tulip_mii_readreg(sc, sc->tulip_phyaddr, PHYREG_IDHIGH);
- for (attr = tulip_mii_phy_attrlist;; attr++) {
- if (attr->attr_id == 0)
- return TULIP_MEDIA_UNKNOWN;
- if ((id & ~0x0F) == attr->attr_id)
- break;
- }
-
- if (attr->attr_modes[PHY_MODE_100TX].pm_regno) {
- const tulip_phy_modedata_t * const pm = &attr->attr_modes[PHY_MODE_100TX];
- data = tulip_mii_readreg(sc, sc->tulip_phyaddr, pm->pm_regno);
- if ((data & pm->pm_mask) == pm->pm_value)
- idx = 2;
- }
- if (idx == 0 && attr->attr_modes[PHY_MODE_100T4].pm_regno) {
- const tulip_phy_modedata_t * const pm = &attr->attr_modes[PHY_MODE_100T4];
- data = tulip_mii_readreg(sc, sc->tulip_phyaddr, pm->pm_regno);
- if ((data & pm->pm_mask) == pm->pm_value)
- idx = 3;
- }
- if (idx == 0 && attr->attr_modes[PHY_MODE_10T].pm_regno) {
- const tulip_phy_modedata_t * const pm = &attr->attr_modes[PHY_MODE_10T];
- data = tulip_mii_readreg(sc, sc->tulip_phyaddr, pm->pm_regno);
- if ((data & pm->pm_mask) == pm->pm_value)
- idx = 1;
- }
- if (idx != 0 && attr->attr_modes[PHY_MODE_FULLDUPLEX].pm_regno) {
- const tulip_phy_modedata_t * const pm = &attr->attr_modes[PHY_MODE_FULLDUPLEX];
- data = tulip_mii_readreg(sc, sc->tulip_phyaddr, pm->pm_regno);
- idx += ((data & pm->pm_mask) == pm->pm_value ? 4 : 0);
- }
- return table[idx];
-}
-
-static unsigned
-tulip_mii_get_phyaddr(
- tulip_softc_t * const sc,
- unsigned offset)
-{
- unsigned phyaddr;
-
- for (phyaddr = 1; phyaddr < 32; phyaddr++) {
- unsigned status = tulip_mii_readreg(sc, phyaddr, PHYREG_STATUS);
- if (status == 0 || status == 0xFFFF || status < PHYSTS_10BASET)
- continue;
- if (offset == 0)
- return phyaddr;
- offset--;
- }
- if (offset == 0) {
- unsigned status = tulip_mii_readreg(sc, 0, PHYREG_STATUS);
- if (status == 0 || status == 0xFFFF || status < PHYSTS_10BASET)
- return TULIP_MII_NOPHY;
- return 0;
- }
- return TULIP_MII_NOPHY;
-}
-
-static int
-tulip_mii_map_abilities(
- tulip_softc_t * const sc,
- unsigned abilities)
-{
- sc->tulip_abilities = abilities;
- if (abilities & PHYSTS_100BASETX_FD) {
- sc->tulip_probe_media = TULIP_MEDIA_100BASETX_FD;
- } else if (abilities & PHYSTS_100BASET4) {
- sc->tulip_probe_media = TULIP_MEDIA_100BASET4;
- } else if (abilities & PHYSTS_100BASETX) {
- sc->tulip_probe_media = TULIP_MEDIA_100BASETX;
- } else if (abilities & PHYSTS_10BASET_FD) {
- sc->tulip_probe_media = TULIP_MEDIA_10BASET_FD;
- } else if (abilities & PHYSTS_10BASET) {
- sc->tulip_probe_media = TULIP_MEDIA_10BASET;
- } else {
- sc->tulip_probe_state = TULIP_PROBE_MEDIATEST;
- return 0;
- }
- sc->tulip_probe_state = TULIP_PROBE_INACTIVE;
- return 1;
-}
-
-static void
-tulip_mii_autonegotiate(
- tulip_softc_t * const sc,
- const unsigned phyaddr)
-{
- switch (sc->tulip_probe_state) {
- case TULIP_PROBE_MEDIATEST:
- case TULIP_PROBE_INACTIVE: {
- sc->tulip_flags |= TULIP_DIDNWAY;
- tulip_mii_writereg(sc, phyaddr, PHYREG_CONTROL, PHYCTL_RESET);
- sc->tulip_probe_timeout = 3000;
- sc->tulip_intrmask |= TULIP_STS_ABNRMLINTR|TULIP_STS_NORMALINTR;
- sc->tulip_probe_state = TULIP_PROBE_PHYRESET;
- /* FALL THROUGH */
- }
- case TULIP_PROBE_PHYRESET: {
- u_int32_t status;
- u_int32_t data = tulip_mii_readreg(sc, phyaddr, PHYREG_CONTROL);
- if (data & PHYCTL_RESET) {
- if (sc->tulip_probe_timeout > 0) {
- tulip_timeout(sc);
- return;
- }
- printf("%s%d(phy%d): error: reset of PHY never completed!\n",
- sc->tulip_name, sc->tulip_unit, phyaddr);
- sc->tulip_flags &= ~TULIP_TXPROBE_ACTIVE;
- sc->tulip_probe_state = TULIP_PROBE_FAILED;
- sc->tulip_if.if_flags &= ~(IFF_UP|IFF_RUNNING);
- return;
- }
- status = tulip_mii_readreg(sc, phyaddr, PHYREG_STATUS);
- if ((status & PHYSTS_CAN_AUTONEG) == 0) {
-#if defined(TULIP_DEBUG)
- loudprintf("%s%d(phy%d): autonegotiation disabled\n",
- sc->tulip_name, sc->tulip_unit, phyaddr);
-#endif
- sc->tulip_flags &= ~TULIP_DIDNWAY;
- sc->tulip_probe_state = TULIP_PROBE_MEDIATEST;
- return;
- }
- if (tulip_mii_readreg(sc, phyaddr, PHYREG_AUTONEG_ADVERTISEMENT) != ((status >> 6) | 0x01))
- tulip_mii_writereg(sc, phyaddr, PHYREG_AUTONEG_ADVERTISEMENT, (status >> 6) | 0x01);
- tulip_mii_writereg(sc, phyaddr, PHYREG_CONTROL, data|PHYCTL_AUTONEG_RESTART|PHYCTL_AUTONEG_ENABLE);
- data = tulip_mii_readreg(sc, phyaddr, PHYREG_CONTROL);
-#if defined(TULIP_DEBUG)
- if ((data & PHYCTL_AUTONEG_ENABLE) == 0)
- loudprintf("%s%d(phy%d): oops: enable autonegotiation failed: 0x%04x\n",
- sc->tulip_name, sc->tulip_unit, phyaddr, data);
- else
- loudprintf("%s%d(phy%d): autonegotiation restarted: 0x%04x\n",
- sc->tulip_name, sc->tulip_unit, phyaddr, data);
- sc->tulip_dbg.dbg_nway_starts++;
-#endif
- sc->tulip_probe_state = TULIP_PROBE_PHYAUTONEG;
- sc->tulip_probe_timeout = 3000;
- /* FALL THROUGH */
- }
- case TULIP_PROBE_PHYAUTONEG: {
- u_int32_t status = tulip_mii_readreg(sc, phyaddr, PHYREG_STATUS);
- u_int32_t data;
- if ((status & PHYSTS_AUTONEG_DONE) == 0) {
- if (sc->tulip_probe_timeout > 0) {
- tulip_timeout(sc);
- return;
- }
-#if defined(TULIP_DEBUG)
- loudprintf("%s%d(phy%d): autonegotiation timeout: sts=0x%04x, ctl=0x%04x\n",
- sc->tulip_name, sc->tulip_unit, phyaddr, status,
- tulip_mii_readreg(sc, phyaddr, PHYREG_CONTROL));
-#endif
- sc->tulip_flags &= ~TULIP_DIDNWAY;
- sc->tulip_probe_state = TULIP_PROBE_MEDIATEST;
- return;
- }
- data = tulip_mii_readreg(sc, phyaddr, PHYREG_AUTONEG_ABILITIES);
-#if defined(TULIP_DEBUG)
- loudprintf("%s%d(phy%d): autonegotiation complete: 0x%04x\n",
- sc->tulip_name, sc->tulip_unit, phyaddr, data);
-#endif
- data = (data << 6) & status;
- if (!tulip_mii_map_abilities(sc, data))
- sc->tulip_flags &= ~TULIP_DIDNWAY;
- return;
- }
- default: {
-#if defined(DIAGNOSTIC)
- panic("tulip_media_poll: botch at line %d\n", __LINE__);
-#endif
- break;
- }
- }
-#if defined(TULIP_DEBUG)
- loudprintf("%s%d(phy%d): autonegotiation failure: state = %d\n",
- sc->tulip_name, sc->tulip_unit, phyaddr, sc->tulip_probe_state);
- sc->tulip_dbg.dbg_nway_failures++;
-#endif
-}
-
-static void
-tulip_2114x_media_preset(
- tulip_softc_t * const sc)
-{
- const tulip_media_info_t *mi = NULL;
- tulip_media_t media = sc->tulip_media;
-
- if (sc->tulip_probe_state == TULIP_PROBE_INACTIVE)
- media = sc->tulip_media;
- else
- media = sc->tulip_probe_media;
-
- sc->tulip_cmdmode &= ~TULIP_CMD_PORTSELECT;
- sc->tulip_flags &= ~TULIP_SQETEST;
- if (media != TULIP_MEDIA_UNKNOWN && media != TULIP_MEDIA_MAX) {
-#if defined(TULIP_DEBUG)
- if (media < TULIP_MEDIA_MAX && sc->tulip_mediums[media] != NULL) {
-#endif
- mi = sc->tulip_mediums[media];
- if (mi->mi_type == TULIP_MEDIAINFO_MII) {
- sc->tulip_cmdmode |= TULIP_CMD_PORTSELECT;
- } else if (mi->mi_type == TULIP_MEDIAINFO_GPR
- || mi->mi_type == TULIP_MEDIAINFO_SYM) {
- sc->tulip_cmdmode &= ~TULIP_GPR_CMDBITS;
- sc->tulip_cmdmode |= mi->mi_cmdmode;
- } else if (mi->mi_type == TULIP_MEDIAINFO_SIA) {
- TULIP_CSR_WRITE(sc, csr_sia_connectivity, TULIP_SIACONN_RESET);
- }
-#if defined(TULIP_DEBUG)
- } else {
- printf("%s%d: preset: bad media %d!\n",
- sc->tulip_name, sc->tulip_unit, media);
- }
-#endif
- }
- switch (media) {
- case TULIP_MEDIA_BNC:
- case TULIP_MEDIA_AUI:
- case TULIP_MEDIA_10BASET: {
- sc->tulip_cmdmode &= ~TULIP_CMD_FULLDUPLEX;
- sc->tulip_cmdmode |= TULIP_CMD_TXTHRSHLDCTL;
- sc->tulip_if.if_baudrate = 10000000;
- sc->tulip_flags |= TULIP_SQETEST;
- break;
- }
- case TULIP_MEDIA_10BASET_FD: {
- sc->tulip_cmdmode |= TULIP_CMD_FULLDUPLEX|TULIP_CMD_TXTHRSHLDCTL;
- sc->tulip_if.if_baudrate = 10000000;
- break;
- }
- case TULIP_MEDIA_100BASEFX:
- case TULIP_MEDIA_100BASET4:
- case TULIP_MEDIA_100BASETX: {
- sc->tulip_cmdmode &= ~(TULIP_CMD_FULLDUPLEX|TULIP_CMD_TXTHRSHLDCTL);
- sc->tulip_cmdmode |= TULIP_CMD_PORTSELECT;
- sc->tulip_if.if_baudrate = 100000000;
- break;
- }
- case TULIP_MEDIA_100BASEFX_FD:
- case TULIP_MEDIA_100BASETX_FD: {
- sc->tulip_cmdmode |= TULIP_CMD_FULLDUPLEX|TULIP_CMD_PORTSELECT;
- sc->tulip_cmdmode &= ~TULIP_CMD_TXTHRSHLDCTL;
- sc->tulip_if.if_baudrate = 100000000;
- break;
- }
- default: {
- break;
- }
- }
- TULIP_CSR_WRITE(sc, csr_command, sc->tulip_cmdmode);
-}
-
-/*
- ********************************************************************
- * Start of 21140/21140A support which does not use the MII interface
- */
-
-static void
-tulip_null_media_poll(
- tulip_softc_t * const sc,
- tulip_mediapoll_event_t event)
-{
-#if defined(TULIP_DEBUG)
- sc->tulip_dbg.dbg_events[event]++;
-#endif
-#if defined(DIAGNOSTIC)
- printf("%s%d: botch(media_poll) at line %d\n",
- sc->tulip_name, sc->tulip_unit, __LINE__);
-#endif
-}
-
-__inline__ static void
-tulip_21140_mediainit(
- tulip_softc_t * const sc,
- tulip_media_info_t * const mip,
- tulip_media_t const media,
- unsigned gpdata,
- unsigned cmdmode)
-{
- sc->tulip_mediums[media] = mip;
- mip->mi_type = TULIP_MEDIAINFO_GPR;
- mip->mi_cmdmode = cmdmode;
- mip->mi_gpdata = gpdata;
-}
-
-static void
-tulip_21140_evalboard_media_probe(
- tulip_softc_t * const sc)
-{
- tulip_media_info_t *mip = sc->tulip_mediainfo;
-
- sc->tulip_gpinit = TULIP_GP_EB_PINS;
- sc->tulip_gpdata = TULIP_GP_EB_INIT;
- TULIP_CSR_WRITE(sc, csr_gp, TULIP_GP_EB_PINS);
- TULIP_CSR_WRITE(sc, csr_gp, TULIP_GP_EB_INIT);
- TULIP_CSR_WRITE(sc, csr_command,
- TULIP_CSR_READ(sc, csr_command) | TULIP_CMD_PORTSELECT |
- TULIP_CMD_PCSFUNCTION | TULIP_CMD_SCRAMBLER | TULIP_CMD_MUSTBEONE);
- TULIP_CSR_WRITE(sc, csr_command,
- TULIP_CSR_READ(sc, csr_command) & ~TULIP_CMD_TXTHRSHLDCTL);
- DELAY(1000000);
- if ((TULIP_CSR_READ(sc, csr_gp) & TULIP_GP_EB_OK100) != 0) {
- sc->tulip_media = TULIP_MEDIA_10BASET;
- } else {
- sc->tulip_media = TULIP_MEDIA_100BASETX;
- }
- tulip_21140_mediainit(sc, mip++, TULIP_MEDIA_10BASET,
- TULIP_GP_EB_INIT,
- TULIP_CMD_TXTHRSHLDCTL);
- tulip_21140_mediainit(sc, mip++, TULIP_MEDIA_10BASET_FD,
- TULIP_GP_EB_INIT,
- TULIP_CMD_TXTHRSHLDCTL|TULIP_CMD_FULLDUPLEX);
- tulip_21140_mediainit(sc, mip++, TULIP_MEDIA_100BASETX,
- TULIP_GP_EB_INIT,
- TULIP_CMD_PORTSELECT|TULIP_CMD_PCSFUNCTION
- |TULIP_CMD_SCRAMBLER);
- tulip_21140_mediainit(sc, mip++, TULIP_MEDIA_100BASETX_FD,
- TULIP_GP_EB_INIT,
- TULIP_CMD_PORTSELECT|TULIP_CMD_PCSFUNCTION
- |TULIP_CMD_SCRAMBLER|TULIP_CMD_FULLDUPLEX);
-}
-
-static const tulip_boardsw_t tulip_21140_eb_boardsw = {
- TULIP_21140_DEC_EB,
- tulip_21140_evalboard_media_probe,
- tulip_media_select,
- tulip_null_media_poll,
- tulip_2114x_media_preset,
-};
-
-static void
-tulip_21140_accton_media_probe(
- tulip_softc_t * const sc)
-{
- tulip_media_info_t *mip = sc->tulip_mediainfo;
- unsigned gpdata;
-
- sc->tulip_gpinit = TULIP_GP_EB_PINS;
- sc->tulip_gpdata = TULIP_GP_EB_INIT;
- TULIP_CSR_WRITE(sc, csr_gp, TULIP_GP_EB_PINS);
- TULIP_CSR_WRITE(sc, csr_gp, TULIP_GP_EB_INIT);
- TULIP_CSR_WRITE(sc, csr_command,
- TULIP_CSR_READ(sc, csr_command) | TULIP_CMD_PORTSELECT |
- TULIP_CMD_PCSFUNCTION | TULIP_CMD_SCRAMBLER | TULIP_CMD_MUSTBEONE);
- TULIP_CSR_WRITE(sc, csr_command,
- TULIP_CSR_READ(sc, csr_command) & ~TULIP_CMD_TXTHRSHLDCTL);
- DELAY(1000000);
- gpdata = TULIP_CSR_READ(sc, csr_gp);
- if ((gpdata & TULIP_GP_EN1207_UTP_INIT) == 0) {
- sc->tulip_media = TULIP_MEDIA_10BASET;
- } else {
- if ((gpdata & TULIP_GP_EN1207_BNC_INIT) == 0) {
- sc->tulip_media = TULIP_MEDIA_BNC;
- } else {
- sc->tulip_media = TULIP_MEDIA_100BASETX;
- }
- }
- tulip_21140_mediainit(sc, mip++, TULIP_MEDIA_BNC,
- TULIP_GP_EN1207_BNC_INIT,
- TULIP_CMD_TXTHRSHLDCTL);
- tulip_21140_mediainit(sc, mip++, TULIP_MEDIA_10BASET,
- TULIP_GP_EN1207_UTP_INIT,
- TULIP_CMD_TXTHRSHLDCTL);
- tulip_21140_mediainit(sc, mip++, TULIP_MEDIA_10BASET_FD,
- TULIP_GP_EN1207_UTP_INIT,
- TULIP_CMD_TXTHRSHLDCTL|TULIP_CMD_FULLDUPLEX);
- tulip_21140_mediainit(sc, mip++, TULIP_MEDIA_100BASETX,
- TULIP_GP_EN1207_100_INIT,
- TULIP_CMD_PORTSELECT|TULIP_CMD_PCSFUNCTION
- |TULIP_CMD_SCRAMBLER);
- tulip_21140_mediainit(sc, mip++, TULIP_MEDIA_100BASETX_FD,
- TULIP_GP_EN1207_100_INIT,
- TULIP_CMD_PORTSELECT|TULIP_CMD_PCSFUNCTION
- |TULIP_CMD_SCRAMBLER|TULIP_CMD_FULLDUPLEX);
-}
-
-static const tulip_boardsw_t tulip_21140_accton_boardsw = {
- TULIP_21140_EN1207,
- tulip_21140_accton_media_probe,
- tulip_media_select,
- tulip_null_media_poll,
- tulip_2114x_media_preset,
-};
-
-static void
-tulip_21140_smc9332_media_probe(
- tulip_softc_t * const sc)
-{
- tulip_media_info_t *mip = sc->tulip_mediainfo;
- int idx, cnt = 0;
-
- TULIP_CSR_WRITE(sc, csr_command, TULIP_CMD_PORTSELECT|TULIP_CMD_MUSTBEONE);
- TULIP_CSR_WRITE(sc, csr_busmode, TULIP_BUSMODE_SWRESET);
- DELAY(10); /* Wait 10 microseconds (actually 50 PCI cycles but at
- 33MHz that comes to two microseconds but wait a
- bit longer anyways) */
- TULIP_CSR_WRITE(sc, csr_command, TULIP_CMD_PORTSELECT |
- TULIP_CMD_PCSFUNCTION | TULIP_CMD_SCRAMBLER | TULIP_CMD_MUSTBEONE);
- sc->tulip_gpinit = TULIP_GP_SMC_9332_PINS;
- sc->tulip_gpdata = TULIP_GP_SMC_9332_INIT;
- TULIP_CSR_WRITE(sc, csr_gp, TULIP_GP_SMC_9332_PINS|TULIP_GP_PINSET);
- TULIP_CSR_WRITE(sc, csr_gp, TULIP_GP_SMC_9332_INIT);
- DELAY(200000);
- for (idx = 1000; idx > 0; idx--) {
- u_int32_t csr = TULIP_CSR_READ(sc, csr_gp);
- if ((csr & (TULIP_GP_SMC_9332_OK10|TULIP_GP_SMC_9332_OK100)) == (TULIP_GP_SMC_9332_OK10|TULIP_GP_SMC_9332_OK100)) {
- if (++cnt > 100)
- break;
- } else if ((csr & TULIP_GP_SMC_9332_OK10) == 0) {
- break;
- } else {
- cnt = 0;
- }
- DELAY(1000);
- }
- sc->tulip_media = cnt > 100 ? TULIP_MEDIA_100BASETX : TULIP_MEDIA_10BASET;
- tulip_21140_mediainit(sc, mip++, TULIP_MEDIA_100BASETX,
- TULIP_GP_SMC_9332_INIT,
- TULIP_CMD_PORTSELECT|TULIP_CMD_PCSFUNCTION
- |TULIP_CMD_SCRAMBLER);
- tulip_21140_mediainit(sc, mip++, TULIP_MEDIA_100BASETX_FD,
- TULIP_GP_SMC_9332_INIT,
- TULIP_CMD_PORTSELECT|TULIP_CMD_PCSFUNCTION
- |TULIP_CMD_SCRAMBLER|TULIP_CMD_FULLDUPLEX);
- tulip_21140_mediainit(sc, mip++, TULIP_MEDIA_10BASET,
- TULIP_GP_SMC_9332_INIT,
- TULIP_CMD_TXTHRSHLDCTL);
- tulip_21140_mediainit(sc, mip++, TULIP_MEDIA_10BASET_FD,
- TULIP_GP_SMC_9332_INIT,
- TULIP_CMD_TXTHRSHLDCTL|TULIP_CMD_FULLDUPLEX);
-}
-
-static const tulip_boardsw_t tulip_21140_smc9332_boardsw = {
- TULIP_21140_SMC_9332,
- tulip_21140_smc9332_media_probe,
- tulip_media_select,
- tulip_null_media_poll,
- tulip_2114x_media_preset,
-};
-
-static void
-tulip_21140_cogent_em100_media_probe(
- tulip_softc_t * const sc)
-{
- tulip_media_info_t *mip = sc->tulip_mediainfo;
- u_int32_t cmdmode = TULIP_CSR_READ(sc, csr_command);
-
- sc->tulip_gpinit = TULIP_GP_EM100_PINS;
- sc->tulip_gpdata = TULIP_GP_EM100_INIT;
- TULIP_CSR_WRITE(sc, csr_gp, TULIP_GP_EM100_PINS);
- TULIP_CSR_WRITE(sc, csr_gp, TULIP_GP_EM100_INIT);
-
- cmdmode = TULIP_CMD_PORTSELECT|TULIP_CMD_PCSFUNCTION|TULIP_CMD_MUSTBEONE;
- cmdmode &= ~(TULIP_CMD_TXTHRSHLDCTL|TULIP_CMD_SCRAMBLER);
- if (sc->tulip_rombuf[32] == TULIP_COGENT_EM100FX_ID) {
- TULIP_CSR_WRITE(sc, csr_command, cmdmode);
- sc->tulip_media = TULIP_MEDIA_100BASEFX;
-
- tulip_21140_mediainit(sc, mip++, TULIP_MEDIA_100BASEFX,
- TULIP_GP_EM100_INIT,
- TULIP_CMD_PORTSELECT|TULIP_CMD_PCSFUNCTION);
- tulip_21140_mediainit(sc, mip++, TULIP_MEDIA_100BASEFX_FD,
- TULIP_GP_EM100_INIT,
- TULIP_CMD_PORTSELECT|TULIP_CMD_PCSFUNCTION
- |TULIP_CMD_FULLDUPLEX);
- } else {
- TULIP_CSR_WRITE(sc, csr_command, cmdmode|TULIP_CMD_SCRAMBLER);
- sc->tulip_media = TULIP_MEDIA_100BASETX;
- tulip_21140_mediainit(sc, mip++, TULIP_MEDIA_100BASETX,
- TULIP_GP_EM100_INIT,
- TULIP_CMD_PORTSELECT|TULIP_CMD_PCSFUNCTION
- |TULIP_CMD_SCRAMBLER);
- tulip_21140_mediainit(sc, mip++, TULIP_MEDIA_100BASETX_FD,
- TULIP_GP_EM100_INIT,
- TULIP_CMD_PORTSELECT|TULIP_CMD_PCSFUNCTION
- |TULIP_CMD_SCRAMBLER|TULIP_CMD_FULLDUPLEX);
- }
-}
-
-static const tulip_boardsw_t tulip_21140_cogent_em100_boardsw = {
- TULIP_21140_COGENT_EM100,
- tulip_21140_cogent_em100_media_probe,
- tulip_media_select,
- tulip_null_media_poll,
- tulip_2114x_media_preset
-};
-
-static void
-tulip_21140_znyx_zx34x_media_probe(
- tulip_softc_t * const sc)
-{
- tulip_media_info_t *mip = sc->tulip_mediainfo;
- int cnt10 = 0, cnt100 = 0, idx;
-
- sc->tulip_gpinit = TULIP_GP_ZX34X_PINS;
- sc->tulip_gpdata = TULIP_GP_ZX34X_INIT;
- TULIP_CSR_WRITE(sc, csr_gp, TULIP_GP_ZX34X_PINS);
- TULIP_CSR_WRITE(sc, csr_gp, TULIP_GP_ZX34X_INIT);
- TULIP_CSR_WRITE(sc, csr_command,
- TULIP_CSR_READ(sc, csr_command) | TULIP_CMD_PORTSELECT |
- TULIP_CMD_PCSFUNCTION | TULIP_CMD_SCRAMBLER | TULIP_CMD_MUSTBEONE);
- TULIP_CSR_WRITE(sc, csr_command,
- TULIP_CSR_READ(sc, csr_command) & ~TULIP_CMD_TXTHRSHLDCTL);
-
- DELAY(200000);
- for (idx = 1000; idx > 0; idx--) {
- u_int32_t csr = TULIP_CSR_READ(sc, csr_gp);
- if ((csr & (TULIP_GP_ZX34X_LNKFAIL|TULIP_GP_ZX34X_SYMDET|TULIP_GP_ZX34X_SIGDET)) == (TULIP_GP_ZX34X_LNKFAIL|TULIP_GP_ZX34X_SYMDET|TULIP_GP_ZX34X_SIGDET)) {
- if (++cnt100 > 100)
- break;
- } else if ((csr & TULIP_GP_ZX34X_LNKFAIL) == 0) {
- if (++cnt10 > 100)
- break;
- } else {
- cnt10 = 0;
- cnt100 = 0;
- }
- DELAY(1000);
- }
- sc->tulip_media = cnt100 > 100 ? TULIP_MEDIA_100BASETX : TULIP_MEDIA_10BASET;
- tulip_21140_mediainit(sc, mip++, TULIP_MEDIA_10BASET,
- TULIP_GP_ZX34X_INIT,
- TULIP_CMD_TXTHRSHLDCTL);
- tulip_21140_mediainit(sc, mip++, TULIP_MEDIA_10BASET_FD,
- TULIP_GP_ZX34X_INIT,
- TULIP_CMD_TXTHRSHLDCTL|TULIP_CMD_FULLDUPLEX);
- tulip_21140_mediainit(sc, mip++, TULIP_MEDIA_100BASETX,
- TULIP_GP_ZX34X_INIT,
- TULIP_CMD_PORTSELECT|TULIP_CMD_PCSFUNCTION
- |TULIP_CMD_SCRAMBLER);
- tulip_21140_mediainit(sc, mip++, TULIP_MEDIA_100BASETX_FD,
- TULIP_GP_ZX34X_INIT,
- TULIP_CMD_PORTSELECT|TULIP_CMD_PCSFUNCTION
- |TULIP_CMD_SCRAMBLER|TULIP_CMD_FULLDUPLEX);
-}
-
-static const tulip_boardsw_t tulip_21140_znyx_zx34x_boardsw = {
- TULIP_21140_ZNYX_ZX34X,
- tulip_21140_znyx_zx34x_media_probe,
- tulip_media_select,
- tulip_null_media_poll,
- tulip_2114x_media_preset,
-};
-
-static void
-tulip_2114x_media_probe(
- tulip_softc_t * const sc)
-{
- sc->tulip_cmdmode |= TULIP_CMD_MUSTBEONE
- |TULIP_CMD_BACKOFFCTR|TULIP_CMD_THRSHLD72;
-}
-
-static const tulip_boardsw_t tulip_2114x_isv_boardsw = {
- TULIP_21140_ISV,
- tulip_2114x_media_probe,
- tulip_media_select,
- tulip_media_poll,
- tulip_2114x_media_preset,
-};
-
-/*
- * ******** END of chip-specific handlers. ***********
- */
-
-/*
- * Code the read the SROM and MII bit streams (I2C)
- */
-#define EMIT do { TULIP_CSR_WRITE(sc, csr_srom_mii, csr); DELAY(1); } while (0)
-
-static void
-tulip_srom_idle(
- tulip_softc_t * const sc)
-{
- unsigned bit, csr;
-
- csr = SROMSEL ; EMIT;
- csr = SROMSEL | SROMRD; EMIT;
- csr ^= SROMCS; EMIT;
- csr ^= SROMCLKON; EMIT;
-
- /*
- * Write 25 cycles of 0 which will force the SROM to be idle.
- */
- for (bit = 3 + SROM_BITWIDTH + 16; bit > 0; bit--) {
- csr ^= SROMCLKOFF; EMIT; /* clock low; data not valid */
- csr ^= SROMCLKON; EMIT; /* clock high; data valid */
- }
- csr ^= SROMCLKOFF; EMIT;
- csr ^= SROMCS; EMIT;
- csr = 0; EMIT;
-}
-
-
-static void
-tulip_srom_read(
- tulip_softc_t * const sc)
-{
- unsigned idx;
- const unsigned bitwidth = SROM_BITWIDTH;
- const unsigned cmdmask = (SROMCMD_RD << bitwidth);
- const unsigned msb = 1 << (bitwidth + 3 - 1);
- unsigned lastidx = (1 << bitwidth) - 1;
-
- tulip_srom_idle(sc);
-
- for (idx = 0; idx <= lastidx; idx++) {
- unsigned lastbit, data, bits, bit, csr;
- csr = SROMSEL ; EMIT;
- csr = SROMSEL | SROMRD; EMIT;
- csr ^= SROMCSON; EMIT;
- csr ^= SROMCLKON; EMIT;
-
- lastbit = 0;
- for (bits = idx|cmdmask, bit = bitwidth + 3; bit > 0; bit--, bits <<= 1) {
- const unsigned thisbit = bits & msb;
- csr ^= SROMCLKOFF; EMIT; /* clock low; data not valid */
- if (thisbit != lastbit) {
- csr ^= SROMDOUT; EMIT; /* clock low; invert data */
- } else {
- EMIT;
- }
- csr ^= SROMCLKON; EMIT; /* clock high; data valid */
- lastbit = thisbit;
- }
- csr ^= SROMCLKOFF; EMIT;
-
- for (data = 0, bits = 0; bits < 16; bits++) {
- data <<= 1;
- csr ^= SROMCLKON; EMIT; /* clock high; data valid */
- data |= TULIP_CSR_READ(sc, csr_srom_mii) & SROMDIN ? 1 : 0;
- csr ^= SROMCLKOFF; EMIT; /* clock low; data not valid */
- }
- sc->tulip_rombuf[idx*2] = data & 0xFF;
- sc->tulip_rombuf[idx*2+1] = data >> 8;
- csr = SROMSEL | SROMRD; EMIT;
- csr = 0; EMIT;
- }
- tulip_srom_idle(sc);
-}
-
-#define MII_EMIT do { TULIP_CSR_WRITE(sc, csr_srom_mii, csr); DELAY(1); } while (0)
-
-static void
-tulip_mii_writebits(
- tulip_softc_t * const sc,
- unsigned data,
- unsigned bits)
-{
- unsigned msb = 1 << (bits - 1);
- unsigned csr = TULIP_CSR_READ(sc, csr_srom_mii) & (MII_RD|MII_DOUT|MII_CLK);
- unsigned lastbit = (csr & MII_DOUT) ? msb : 0;
-
- csr |= MII_WR; MII_EMIT; /* clock low; assert write */
-
- for (; bits > 0; bits--, data <<= 1) {
- const unsigned thisbit = data & msb;
- if (thisbit != lastbit) {
- csr ^= MII_DOUT; MII_EMIT; /* clock low; invert data */
- }
- csr ^= MII_CLKON; MII_EMIT; /* clock high; data valid */
- lastbit = thisbit;
- csr ^= MII_CLKOFF; MII_EMIT; /* clock low; data not valid */
- }
-}
-
-static void
-tulip_mii_turnaround(
- tulip_softc_t * const sc,
- unsigned cmd)
-{
- unsigned csr = TULIP_CSR_READ(sc, csr_srom_mii) & (MII_RD|MII_DOUT|MII_CLK);
-
- if (cmd == MII_WRCMD) {
- csr |= MII_DOUT; MII_EMIT; /* clock low; change data */
- csr ^= MII_CLKON; MII_EMIT; /* clock high; data valid */
- csr ^= MII_CLKOFF; MII_EMIT; /* clock low; data not valid */
- csr ^= MII_DOUT; MII_EMIT; /* clock low; change data */
- } else {
- csr |= MII_RD; MII_EMIT; /* clock low; switch to read */
- }
- csr ^= MII_CLKON; MII_EMIT; /* clock high; data valid */
- csr ^= MII_CLKOFF; MII_EMIT; /* clock low; data not valid */
-}
-
-static unsigned
-tulip_mii_readbits(
- tulip_softc_t * const sc)
-{
- unsigned data;
- unsigned csr = TULIP_CSR_READ(sc, csr_srom_mii) & (MII_RD|MII_DOUT|MII_CLK);
- int idx;
-
- for (idx = 0, data = 0; idx < 16; idx++) {
- data <<= 1; /* this is NOOP on the first pass through */
- csr ^= MII_CLKON; MII_EMIT; /* clock high; data valid */
- if (TULIP_CSR_READ(sc, csr_srom_mii) & MII_DIN)
- data |= 1;
- csr ^= MII_CLKOFF; MII_EMIT; /* clock low; data not valid */
- }
- csr ^= MII_RD; MII_EMIT; /* clock low; turn off read */
-
- return data;
-}
-
-static unsigned
-tulip_mii_readreg(
- tulip_softc_t * const sc,
- unsigned devaddr,
- unsigned regno)
-{
- unsigned csr = TULIP_CSR_READ(sc, csr_srom_mii) & (MII_RD|MII_DOUT|MII_CLK);
- unsigned data;
-
- csr &= ~(MII_RD|MII_CLK); MII_EMIT;
- tulip_mii_writebits(sc, MII_PREAMBLE, 32);
- tulip_mii_writebits(sc, MII_RDCMD, 8);
- tulip_mii_writebits(sc, devaddr, 5);
- tulip_mii_writebits(sc, regno, 5);
- tulip_mii_turnaround(sc, MII_RDCMD);
-
- data = tulip_mii_readbits(sc);
-#if defined(TULIP_DEBUG)
- sc->tulip_dbg.dbg_phyregs[regno][0] = data;
- sc->tulip_dbg.dbg_phyregs[regno][1]++;
-#endif
- return data;
-}
-
-static void
-tulip_mii_writereg(
- tulip_softc_t * const sc,
- unsigned devaddr,
- unsigned regno,
- unsigned data)
-{
- unsigned csr = TULIP_CSR_READ(sc, csr_srom_mii) & (MII_RD|MII_DOUT|MII_CLK);
- csr &= ~(MII_RD|MII_CLK); MII_EMIT;
- tulip_mii_writebits(sc, MII_PREAMBLE, 32);
- tulip_mii_writebits(sc, MII_WRCMD, 8);
- tulip_mii_writebits(sc, devaddr, 5);
- tulip_mii_writebits(sc, regno, 5);
- tulip_mii_turnaround(sc, MII_WRCMD);
- tulip_mii_writebits(sc, data, 16);
-#if defined(TULIP_DEBUG)
- sc->tulip_dbg.dbg_phyregs[regno][2] = data;
- sc->tulip_dbg.dbg_phyregs[regno][3]++;
-#endif
-}
-
-#define tulip_mchash(mca) (tulip_crc32(mca, 6) & 0x1FF)
-#define tulip_srom_crcok(databuf) ( \
- ((tulip_crc32(databuf, 126) & 0xFFFFU) ^ 0xFFFFU) == \
- ((databuf)[126] | ((databuf)[127] << 8)))
-
-static unsigned
-tulip_crc32(
- const unsigned char *databuf,
- size_t datalen)
-{
- u_int idx, crc = 0xFFFFFFFFUL;
- static const u_int crctab[] = {
- 0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac,
- 0x76dc4190, 0x6b6b51f4, 0x4db26158, 0x5005713c,
- 0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c,
- 0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c
- };
-
- for (idx = 0; idx < datalen; idx++) {
- crc ^= *databuf++;
- crc = (crc >> 4) ^ crctab[crc & 0xf];
- crc = (crc >> 4) ^ crctab[crc & 0xf];
- }
- return crc;
-}
-
-static void
-tulip_identify_dec_nic(
- tulip_softc_t * const sc)
-{
- strcpy(sc->tulip_boardid, "DEC ");
-#define D0 4
- if (sc->tulip_chipid <= TULIP_21040)
- return;
- if (bcmp(sc->tulip_rombuf + 29, "DE500", 5) == 0
- || bcmp(sc->tulip_rombuf + 29, "DE450", 5) == 0) {
- bcopy(sc->tulip_rombuf + 29, &sc->tulip_boardid[D0], 8);
- sc->tulip_boardid[D0+8] = ' ';
- }
-#undef D0
-}
-
-static void
-tulip_identify_znyx_nic(
- tulip_softc_t * const sc)
-{
- unsigned id = 0;
- strcpy(sc->tulip_boardid, "ZNYX ZX3XX ");
- if (sc->tulip_chipid == TULIP_21140 || sc->tulip_chipid == TULIP_21140A) {
- unsigned znyx_ptr;
- sc->tulip_boardid[8] = '4';
- znyx_ptr = sc->tulip_rombuf[124] + 256 * sc->tulip_rombuf[125];
- if (znyx_ptr < 26 || znyx_ptr > 116) {
- sc->tulip_boardsw = &tulip_21140_znyx_zx34x_boardsw;
- return;
- }
- /* ZX344 = 0010 .. 0013FF
- */
- if (sc->tulip_rombuf[znyx_ptr] == 0x4A
- && sc->tulip_rombuf[znyx_ptr + 1] == 0x52
- && sc->tulip_rombuf[znyx_ptr + 2] == 0x01) {
- id = sc->tulip_rombuf[znyx_ptr + 5] + 256 * sc->tulip_rombuf[znyx_ptr + 4];
- if ((id >> 8) == (TULIP_ZNYX_ID_ZX342 >> 8)) {
- sc->tulip_boardid[9] = '2';
- if (id == TULIP_ZNYX_ID_ZX342B) {
- sc->tulip_boardid[10] = 'B';
- sc->tulip_boardid[11] = ' ';
- }
- sc->tulip_boardsw = &tulip_21140_znyx_zx34x_boardsw;
- } else if (id == TULIP_ZNYX_ID_ZX344) {
- sc->tulip_boardid[10] = '4';
- sc->tulip_boardsw = &tulip_21140_znyx_zx34x_boardsw;
- } else if (id == TULIP_ZNYX_ID_ZX345) {
- sc->tulip_boardid[9] = (sc->tulip_rombuf[19] > 1) ? '8' : '5';
- } else if (id == TULIP_ZNYX_ID_ZX346) {
- sc->tulip_boardid[9] = '6';
- } else if (id == TULIP_ZNYX_ID_ZX351) {
- sc->tulip_boardid[8] = '5';
- sc->tulip_boardid[9] = '1';
- }
- }
- if (id == 0) {
- /*
- * Assume it's a ZX342...
- */
- sc->tulip_boardsw = &tulip_21140_znyx_zx34x_boardsw;
- }
- return;
- }
- sc->tulip_boardid[8] = '1';
- if (sc->tulip_chipid == TULIP_21041) {
- sc->tulip_boardid[10] = '1';
- return;
- }
- if (sc->tulip_rombuf[32] == 0x4A && sc->tulip_rombuf[33] == 0x52) {
- id = sc->tulip_rombuf[37] + 256 * sc->tulip_rombuf[36];
- if (id == TULIP_ZNYX_ID_ZX312T) {
- sc->tulip_boardid[9] = '2';
- sc->tulip_boardid[10] = 'T';
- sc->tulip_boardid[11] = ' ';
- sc->tulip_boardsw = &tulip_21040_10baset_only_boardsw;
- } else if (id == TULIP_ZNYX_ID_ZX314_INTA) {
- sc->tulip_boardid[9] = '4';
- sc->tulip_boardsw = &tulip_21040_10baset_only_boardsw;
- sc->tulip_features |= TULIP_HAVE_SHAREDINTR|TULIP_HAVE_BASEROM;
- } else if (id == TULIP_ZNYX_ID_ZX314) {
- sc->tulip_boardid[9] = '4';
- sc->tulip_boardsw = &tulip_21040_10baset_only_boardsw;
- sc->tulip_features |= TULIP_HAVE_BASEROM;
- } else if (id == TULIP_ZNYX_ID_ZX315_INTA) {
- sc->tulip_boardid[9] = '5';
- sc->tulip_features |= TULIP_HAVE_SHAREDINTR|TULIP_HAVE_BASEROM;
- } else if (id == TULIP_ZNYX_ID_ZX315) {
- sc->tulip_boardid[9] = '5';
- sc->tulip_features |= TULIP_HAVE_BASEROM;
- } else {
- id = 0;
- }
- }
- if (id == 0) {
- if ((sc->tulip_enaddr[3] & ~3) == 0xF0 && (sc->tulip_enaddr[5] & 2) == 0) {
- sc->tulip_boardid[9] = '4';
- sc->tulip_boardsw = &tulip_21040_10baset_only_boardsw;
- sc->tulip_features |= TULIP_HAVE_SHAREDINTR|TULIP_HAVE_BASEROM;
- } else if ((sc->tulip_enaddr[3] & ~3) == 0xF4 && (sc->tulip_enaddr[5] & 1) == 0) {
- sc->tulip_boardid[9] = '5';
- sc->tulip_boardsw = &tulip_21040_boardsw;
- sc->tulip_features |= TULIP_HAVE_SHAREDINTR|TULIP_HAVE_BASEROM;
- } else if ((sc->tulip_enaddr[3] & ~3) == 0xEC) {
- sc->tulip_boardid[9] = '2';
- sc->tulip_boardsw = &tulip_21040_boardsw;
- }
- }
-}
-
-static void
-tulip_identify_smc_nic(
- tulip_softc_t * const sc)
-{
- u_int32_t id1, id2, ei;
- int auibnc = 0, utp = 0;
- char *cp;
-
- strcpy(sc->tulip_boardid, "SMC ");
- if (sc->tulip_chipid == TULIP_21041)
- return;
- if (sc->tulip_chipid != TULIP_21040) {
- if (sc->tulip_boardsw != &tulip_2114x_isv_boardsw) {
- strcpy(&sc->tulip_boardid[4], "9332DST ");
- sc->tulip_boardsw = &tulip_21140_smc9332_boardsw;
- } else if (sc->tulip_features & (TULIP_HAVE_BASEROM|TULIP_HAVE_SLAVEDROM)) {
- strcpy(&sc->tulip_boardid[4], "9334BDT ");
- } else {
- strcpy(&sc->tulip_boardid[4], "9332BDT ");
- }
- return;
- }
- id1 = sc->tulip_rombuf[0x60] | (sc->tulip_rombuf[0x61] << 8);
- id2 = sc->tulip_rombuf[0x62] | (sc->tulip_rombuf[0x63] << 8);
- ei = sc->tulip_rombuf[0x66] | (sc->tulip_rombuf[0x67] << 8);
-
- strcpy(&sc->tulip_boardid[4], "8432");
- cp = &sc->tulip_boardid[8];
- if ((id1 & 1) == 0)
- *cp++ = 'B', auibnc = 1;
- if ((id1 & 0xFF) > 0x32)
- *cp++ = 'T', utp = 1;
- if ((id1 & 0x4000) == 0)
- *cp++ = 'A', auibnc = 1;
- if (id2 == 0x15) {
- sc->tulip_boardid[7] = '4';
- *cp++ = '-';
- *cp++ = 'C';
- *cp++ = 'H';
- *cp++ = (ei ? '2' : '1');
- }
- *cp++ = ' ';
- *cp = '\0';
- if (utp && !auibnc)
- sc->tulip_boardsw = &tulip_21040_10baset_only_boardsw;
- else if (!utp && auibnc)
- sc->tulip_boardsw = &tulip_21040_auibnc_only_boardsw;
-}
-
-static void
-tulip_identify_cogent_nic(
- tulip_softc_t * const sc)
-{
- strcpy(sc->tulip_boardid, "Cogent ");
- if (sc->tulip_chipid == TULIP_21140 || sc->tulip_chipid == TULIP_21140A) {
- if (sc->tulip_rombuf[32] == TULIP_COGENT_EM100TX_ID) {
- strcat(sc->tulip_boardid, "EM100TX ");
- sc->tulip_boardsw = &tulip_21140_cogent_em100_boardsw;
-#if defined(TULIP_COGENT_EM110TX_ID)
- } else if (sc->tulip_rombuf[32] == TULIP_COGENT_EM110TX_ID) {
- strcat(sc->tulip_boardid, "EM110TX ");
- sc->tulip_boardsw = &tulip_21140_cogent_em100_boardsw;
-#endif
- } else if (sc->tulip_rombuf[32] == TULIP_COGENT_EM100FX_ID) {
- strcat(sc->tulip_boardid, "EM100FX ");
- sc->tulip_boardsw = &tulip_21140_cogent_em100_boardsw;
- }
- /*
- * Magic number (0x24001109U) is the SubVendor (0x2400) and
- * SubDevId (0x1109) for the ANA6944TX (EM440TX).
- */
- if (*(u_int32_t *) sc->tulip_rombuf == 0x24001109U
- && (sc->tulip_features & TULIP_HAVE_BASEROM)) {
- /*
- * Cogent (Adaptec) is still mapping all INTs to INTA of
- * first 21140. Dumb! Dumb!
- */
- strcat(sc->tulip_boardid, "EM440TX ");
- sc->tulip_features |= TULIP_HAVE_SHAREDINTR;
- }
- } else if (sc->tulip_chipid == TULIP_21040) {
- sc->tulip_features |= TULIP_HAVE_SHAREDINTR|TULIP_HAVE_BASEROM;
- }
-}
-
-static void
-tulip_identify_accton_nic(
- tulip_softc_t * const sc)
-{
- strcpy(sc->tulip_boardid, "ACCTON ");
- switch (sc->tulip_chipid) {
- case TULIP_21140A:
- strcat(sc->tulip_boardid, "EN1207 ");
- if (sc->tulip_boardsw != &tulip_2114x_isv_boardsw)
- sc->tulip_boardsw = &tulip_21140_accton_boardsw;
- break;
- case TULIP_21140:
- strcat(sc->tulip_boardid, "EN1207TX ");
- if (sc->tulip_boardsw != &tulip_2114x_isv_boardsw)
- sc->tulip_boardsw = &tulip_21140_eb_boardsw;
- break;
- case TULIP_21040:
- strcat(sc->tulip_boardid, "EN1203 ");
- sc->tulip_boardsw = &tulip_21040_boardsw;
- break;
- case TULIP_21041:
- strcat(sc->tulip_boardid, "EN1203 ");
- sc->tulip_boardsw = &tulip_21041_boardsw;
- break;
- default:
- sc->tulip_boardsw = &tulip_2114x_isv_boardsw;
- break;
- }
-}
-
-static void
-tulip_identify_asante_nic(
- tulip_softc_t * const sc)
-{
- strcpy(sc->tulip_boardid, "Asante ");
- if ((sc->tulip_chipid == TULIP_21140 || sc->tulip_chipid == TULIP_21140A)
- && sc->tulip_boardsw != &tulip_2114x_isv_boardsw) {
- tulip_media_info_t *mi = sc->tulip_mediainfo;
- int idx;
- /*
- * The Asante Fast Ethernet doesn't always ship with a valid
- * new format SROM. So if isn't in the new format, we cheat
- * set it up as if we had.
- */
-
- sc->tulip_gpinit = TULIP_GP_ASANTE_PINS;
- sc->tulip_gpdata = 0;
-
- TULIP_CSR_WRITE(sc, csr_gp, TULIP_GP_ASANTE_PINS|TULIP_GP_PINSET);
- TULIP_CSR_WRITE(sc, csr_gp, TULIP_GP_ASANTE_PHYRESET);
- DELAY(100);
- TULIP_CSR_WRITE(sc, csr_gp, 0);
-
- mi->mi_type = TULIP_MEDIAINFO_MII;
- mi->mi_gpr_length = 0;
- mi->mi_gpr_offset = 0;
- mi->mi_reset_length = 0;
- mi->mi_reset_offset = 0;;
-
- mi->mi_phyaddr = TULIP_MII_NOPHY;
- for (idx = 20; idx > 0 && mi->mi_phyaddr == TULIP_MII_NOPHY; idx--) {
- DELAY(10000);
- mi->mi_phyaddr = tulip_mii_get_phyaddr(sc, 0);
- }
- if (mi->mi_phyaddr == TULIP_MII_NOPHY) {
- printf("%s%d: can't find phy 0\n", sc->tulip_name, sc->tulip_unit);
- return;
- }
-
- sc->tulip_features |= TULIP_HAVE_MII;
- mi->mi_capabilities = PHYSTS_10BASET|PHYSTS_10BASET_FD|PHYSTS_100BASETX|PHYSTS_100BASETX_FD;
- mi->mi_advertisement = PHYSTS_10BASET|PHYSTS_10BASET_FD|PHYSTS_100BASETX|PHYSTS_100BASETX_FD;
- mi->mi_full_duplex = PHYSTS_10BASET_FD|PHYSTS_100BASETX_FD;
- mi->mi_tx_threshold = PHYSTS_10BASET|PHYSTS_10BASET_FD;
- TULIP_MEDIAINFO_ADD_CAPABILITY(sc, mi, 100BASETX_FD);
- TULIP_MEDIAINFO_ADD_CAPABILITY(sc, mi, 100BASETX);
- TULIP_MEDIAINFO_ADD_CAPABILITY(sc, mi, 100BASET4);
- TULIP_MEDIAINFO_ADD_CAPABILITY(sc, mi, 10BASET_FD);
- TULIP_MEDIAINFO_ADD_CAPABILITY(sc, mi, 10BASET);
- mi->mi_phyid = (tulip_mii_readreg(sc, mi->mi_phyaddr, PHYREG_IDLOW) << 16) |
- tulip_mii_readreg(sc, mi->mi_phyaddr, PHYREG_IDHIGH);
-
- sc->tulip_boardsw = &tulip_2114x_isv_boardsw;
- }
-}
-
-static void
-tulip_identify_compex_nic(
- tulip_softc_t * const sc)
-{
- strcpy(sc->tulip_boardid, "COMPEX ");
- if (sc->tulip_chipid == TULIP_21140A) {
- int root_unit;
- tulip_softc_t *root_sc = NULL;
-
- strcat(sc->tulip_boardid, "400TX/PCI ");
- /*
- * All 4 chips on these boards share an interrupt. This code
- * copied from tulip_read_macaddr.
- */
- sc->tulip_features |= TULIP_HAVE_SHAREDINTR;
- for (root_unit = sc->tulip_unit - 1; root_unit >= 0; root_unit--) {
- root_sc = tulips[root_unit];
- if (root_sc == NULL
- || !(root_sc->tulip_features & TULIP_HAVE_SLAVEDINTR))
- break;
- root_sc = NULL;
- }
- if (root_sc != NULL
- && root_sc->tulip_chipid == sc->tulip_chipid
- && root_sc->tulip_pci_busno == sc->tulip_pci_busno) {
- sc->tulip_features |= TULIP_HAVE_SLAVEDINTR;
- sc->tulip_slaves = root_sc->tulip_slaves;
- root_sc->tulip_slaves = sc;
- } else if(sc->tulip_features & TULIP_HAVE_SLAVEDINTR) {
- printf("\nCannot find master device for de%d interrupts",
- sc->tulip_unit);
- }
- } else {
- strcat(sc->tulip_boardid, "unknown ");
- }
- /* sc->tulip_boardsw = &tulip_21140_eb_boardsw; */
- return;
-}
-
-static int
-tulip_srom_decode(
- tulip_softc_t * const sc)
-{
- unsigned idx1, idx2, idx3;
-
- const tulip_srom_header_t *shp = (const tulip_srom_header_t *) &sc->tulip_rombuf[0];
- const tulip_srom_adapter_info_t *saip = (const tulip_srom_adapter_info_t *) (shp + 1);
- tulip_srom_media_t srom_media;
- tulip_media_info_t *mi = sc->tulip_mediainfo;
- const u_int8_t *dp;
- u_int32_t leaf_offset, blocks, data;
-
- for (idx1 = 0; idx1 < shp->sh_adapter_count; idx1++, saip++) {
- if (shp->sh_adapter_count == 1)
- break;
- if (saip->sai_device == sc->tulip_pci_devno)
- break;
- }
- /*
- * Didn't find the right media block for this card.
- */
- if (idx1 == shp->sh_adapter_count)
- return 0;
-
- /*
- * Save the hardware address.
- */
- bcopy(shp->sh_ieee802_address, sc->tulip_enaddr, 6);
- /*
- * If this is a multiple port card, add the adapter index to the last
- * byte of the hardware address. (if it isn't multiport, adding 0
- * won't hurt.
- */
- sc->tulip_enaddr[5] += idx1;
-
- leaf_offset = saip->sai_leaf_offset_lowbyte
- + saip->sai_leaf_offset_highbyte * 256;
- dp = sc->tulip_rombuf + leaf_offset;
-
- sc->tulip_conntype = (tulip_srom_connection_t) (dp[0] + dp[1] * 256); dp += 2;
-
- for (idx2 = 0;; idx2++) {
- if (tulip_srom_conninfo[idx2].sc_type == sc->tulip_conntype
- || tulip_srom_conninfo[idx2].sc_type == TULIP_SROM_CONNTYPE_NOT_USED)
- break;
- }
- sc->tulip_connidx = idx2;
-
- if (sc->tulip_chipid == TULIP_21041) {
- blocks = *dp++;
- for (idx2 = 0; idx2 < blocks; idx2++) {
- tulip_media_t media;
- data = *dp++;
- srom_media = (tulip_srom_media_t) (data & 0x3F);
- for (idx3 = 0; tulip_srom_mediums[idx3].sm_type != TULIP_MEDIA_UNKNOWN; idx3++) {
- if (tulip_srom_mediums[idx3].sm_srom_type == srom_media)
- break;
- }
- media = tulip_srom_mediums[idx3].sm_type;
- if (media != TULIP_MEDIA_UNKNOWN) {
- if (data & TULIP_SROM_21041_EXTENDED) {
- mi->mi_type = TULIP_MEDIAINFO_SIA;
- sc->tulip_mediums[media] = mi;
- mi->mi_sia_connectivity = dp[0] + dp[1] * 256;
- mi->mi_sia_tx_rx = dp[2] + dp[3] * 256;
- mi->mi_sia_general = dp[4] + dp[5] * 256;
- mi++;
- } else {
- switch (media) {
- case TULIP_MEDIA_BNC: {
- TULIP_MEDIAINFO_SIA_INIT(sc, mi, 21041, BNC);
- mi++;
- break;
- }
- case TULIP_MEDIA_AUI: {
- TULIP_MEDIAINFO_SIA_INIT(sc, mi, 21041, AUI);
- mi++;
- break;
- }
- case TULIP_MEDIA_10BASET: {
- TULIP_MEDIAINFO_SIA_INIT(sc, mi, 21041, 10BASET);
- mi++;
- break;
- }
- case TULIP_MEDIA_10BASET_FD: {
- TULIP_MEDIAINFO_SIA_INIT(sc, mi, 21041, 10BASET_FD);
- mi++;
- break;
- }
- default: {
- break;
- }
- }
- }
- }
- if (data & TULIP_SROM_21041_EXTENDED)
- dp += 6;
- }
-#ifdef notdef
- if (blocks == 0) {
- TULIP_MEDIAINFO_SIA_INIT(sc, mi, 21041, BNC); mi++;
- TULIP_MEDIAINFO_SIA_INIT(sc, mi, 21041, AUI); mi++;
- TULIP_MEDIAINFO_SIA_INIT(sc, mi, 21041, 10BASET); mi++;
- TULIP_MEDIAINFO_SIA_INIT(sc, mi, 21041, 10BASET_FD); mi++;
- }
-#endif
- } else {
- unsigned length, type;
- tulip_media_t gp_media = TULIP_MEDIA_UNKNOWN;
- if (sc->tulip_features & TULIP_HAVE_GPR)
- sc->tulip_gpinit = *dp++;
- blocks = *dp++;
- for (idx2 = 0; idx2 < blocks; idx2++) {
- const u_int8_t *ep;
- if ((*dp & 0x80) == 0) {
- length = 4;
- type = 0;
- } else {
- length = (*dp++ & 0x7f) - 1;
- type = *dp++ & 0x3f;
- }
- ep = dp + length;
- switch (type & 0x3f) {
- case 0: { /* 21140[A] GPR block */
- tulip_media_t media;
- srom_media = (tulip_srom_media_t)(dp[0] & 0x3f);
- for (idx3 = 0; tulip_srom_mediums[idx3].sm_type != TULIP_MEDIA_UNKNOWN; idx3++) {
- if (tulip_srom_mediums[idx3].sm_srom_type == srom_media)
- break;
- }
- media = tulip_srom_mediums[idx3].sm_type;
- if (media == TULIP_MEDIA_UNKNOWN)
- break;
- mi->mi_type = TULIP_MEDIAINFO_GPR;
- sc->tulip_mediums[media] = mi;
- mi->mi_gpdata = dp[1];
- if (media > gp_media && !TULIP_IS_MEDIA_FD(media)) {
- sc->tulip_gpdata = mi->mi_gpdata;
- gp_media = media;
- }
- data = dp[2] + dp[3] * 256;
- mi->mi_cmdmode = TULIP_SROM_2114X_CMDBITS(data);
- if (data & TULIP_SROM_2114X_NOINDICATOR) {
- mi->mi_actmask = 0;
- } else {
-#if 0
- mi->mi_default = (data & TULIP_SROM_2114X_DEFAULT) != 0;
-#endif
- mi->mi_actmask = TULIP_SROM_2114X_BITPOS(data);
- mi->mi_actdata = (data & TULIP_SROM_2114X_POLARITY) ? 0 : mi->mi_actmask;
- }
- mi++;
- break;
- }
- case 1: { /* 21140[A] MII block */
- const unsigned phyno = *dp++;
- mi->mi_type = TULIP_MEDIAINFO_MII;
- mi->mi_gpr_length = *dp++;
- mi->mi_gpr_offset = dp - sc->tulip_rombuf;
- dp += mi->mi_gpr_length;
- mi->mi_reset_length = *dp++;
- mi->mi_reset_offset = dp - sc->tulip_rombuf;
- dp += mi->mi_reset_length;
-
- /*
- * Before we probe for a PHY, use the GPR information
- * to select it. If we don't, it may be inaccessible.
- */
- TULIP_CSR_WRITE(sc, csr_gp, sc->tulip_gpinit|TULIP_GP_PINSET);
- for (idx3 = 0; idx3 < mi->mi_reset_length; idx3++) {
- DELAY(10);
- TULIP_CSR_WRITE(sc, csr_gp, sc->tulip_rombuf[mi->mi_reset_offset + idx3]);
- }
- sc->tulip_phyaddr = mi->mi_phyaddr;
- for (idx3 = 0; idx3 < mi->mi_gpr_length; idx3++) {
- DELAY(10);
- TULIP_CSR_WRITE(sc, csr_gp, sc->tulip_rombuf[mi->mi_gpr_offset + idx3]);
- }
-
- /*
- * At least write something!
- */
- if (mi->mi_reset_length == 0 && mi->mi_gpr_length == 0)
- TULIP_CSR_WRITE(sc, csr_gp, 0);
-
- mi->mi_phyaddr = TULIP_MII_NOPHY;
- for (idx3 = 20; idx3 > 0 && mi->mi_phyaddr == TULIP_MII_NOPHY; idx3--) {
- DELAY(10000);
- mi->mi_phyaddr = tulip_mii_get_phyaddr(sc, phyno);
- }
- if (mi->mi_phyaddr == TULIP_MII_NOPHY) {
-#if defined(TULIP_DEBUG)
- printf("%s%d: can't find phy %d\n",
- sc->tulip_name, sc->tulip_unit, phyno);
-#endif
- break;
- }
- sc->tulip_features |= TULIP_HAVE_MII;
- mi->mi_capabilities = dp[0] + dp[1] * 256; dp += 2;
- mi->mi_advertisement = dp[0] + dp[1] * 256; dp += 2;
- mi->mi_full_duplex = dp[0] + dp[1] * 256; dp += 2;
- mi->mi_tx_threshold = dp[0] + dp[1] * 256; dp += 2;
- TULIP_MEDIAINFO_ADD_CAPABILITY(sc, mi, 100BASETX_FD);
- TULIP_MEDIAINFO_ADD_CAPABILITY(sc, mi, 100BASETX);
- TULIP_MEDIAINFO_ADD_CAPABILITY(sc, mi, 100BASET4);
- TULIP_MEDIAINFO_ADD_CAPABILITY(sc, mi, 10BASET_FD);
- TULIP_MEDIAINFO_ADD_CAPABILITY(sc, mi, 10BASET);
- mi->mi_phyid = (tulip_mii_readreg(sc, mi->mi_phyaddr, PHYREG_IDLOW) << 16) |
- tulip_mii_readreg(sc, mi->mi_phyaddr, PHYREG_IDHIGH);
- mi++;
- break;
- }
- case 2: { /* 2114[23] SIA block */
- tulip_media_t media;
- srom_media = (tulip_srom_media_t)(dp[0] & 0x3f);
- for (idx3 = 0; tulip_srom_mediums[idx3].sm_type != TULIP_MEDIA_UNKNOWN; idx3++) {
- if (tulip_srom_mediums[idx3].sm_srom_type == srom_media)
- break;
- }
- media = tulip_srom_mediums[idx3].sm_type;
- if (media == TULIP_MEDIA_UNKNOWN)
- break;
- mi->mi_type = TULIP_MEDIAINFO_SIA;
- sc->tulip_mediums[media] = mi;
- if (dp[0] & 0x40) {
- mi->mi_sia_connectivity = dp[1] + dp[2] * 256;
- mi->mi_sia_tx_rx = dp[3] + dp[4] * 256;
- mi->mi_sia_general = dp[5] + dp[6] * 256;
- dp += 6;
- } else {
- switch (media) {
- case TULIP_MEDIA_BNC: {
- TULIP_MEDIAINFO_SIA_INIT(sc, mi, 21142, BNC);
- break;
- }
- case TULIP_MEDIA_AUI: {
- TULIP_MEDIAINFO_SIA_INIT(sc, mi, 21142, AUI);
- break;
- }
- case TULIP_MEDIA_10BASET: {
- TULIP_MEDIAINFO_SIA_INIT(sc, mi, 21142, 10BASET);
- sc->tulip_intrmask |= TULIP_STS_LINKPASS|TULIP_STS_LINKFAIL;
- break;
- }
- case TULIP_MEDIA_10BASET_FD: {
- TULIP_MEDIAINFO_SIA_INIT(sc, mi, 21142, 10BASET_FD);
- sc->tulip_intrmask |= TULIP_STS_LINKPASS|TULIP_STS_LINKFAIL;
- break;
- }
- default: {
- goto bad_media;
- }
- }
- }
- mi->mi_sia_gp_control = (dp[1] + dp[2] * 256) << 16;
- mi->mi_sia_gp_data = (dp[3] + dp[4] * 256) << 16;
- mi++;
- bad_media:
- break;
- }
- case 3: { /* 2114[23] MII PHY block */
- const unsigned phyno = *dp++;
- const u_int8_t *dp0;
- mi->mi_type = TULIP_MEDIAINFO_MII;
- mi->mi_gpr_length = *dp++;
- mi->mi_gpr_offset = dp - sc->tulip_rombuf;
- dp += 2 * mi->mi_gpr_length;
- mi->mi_reset_length = *dp++;
- mi->mi_reset_offset = dp - sc->tulip_rombuf;
- dp += 2 * mi->mi_reset_length;
-
- dp0 = &sc->tulip_rombuf[mi->mi_reset_offset];
- for (idx3 = 0; idx3 < mi->mi_reset_length; idx3++, dp0 += 2) {
- DELAY(10);
- TULIP_CSR_WRITE(sc, csr_sia_general, (dp0[0] + 256 * dp0[1]) << 16);
- }
- sc->tulip_phyaddr = mi->mi_phyaddr;
- dp0 = &sc->tulip_rombuf[mi->mi_gpr_offset];
- for (idx3 = 0; idx3 < mi->mi_gpr_length; idx3++, dp0 += 2) {
- DELAY(10);
- TULIP_CSR_WRITE(sc, csr_sia_general, (dp0[0] + 256 * dp0[1]) << 16);
- }
-
- if (mi->mi_reset_length == 0 && mi->mi_gpr_length == 0)
- TULIP_CSR_WRITE(sc, csr_sia_general, 0);
-
- mi->mi_phyaddr = TULIP_MII_NOPHY;
- for (idx3 = 20; idx3 > 0 && mi->mi_phyaddr == TULIP_MII_NOPHY; idx3--) {
- DELAY(10000);
- mi->mi_phyaddr = tulip_mii_get_phyaddr(sc, phyno);
- }
- if (mi->mi_phyaddr == TULIP_MII_NOPHY) {
-#if defined(TULIP_DEBUG)
- printf("%s%d: can't find phy %d\n",
- sc->tulip_name, sc->tulip_unit, phyno);
-#endif
- break;
- }
- sc->tulip_features |= TULIP_HAVE_MII;
- mi->mi_capabilities = dp[0] + dp[1] * 256; dp += 2;
- mi->mi_advertisement = dp[0] + dp[1] * 256; dp += 2;
- mi->mi_full_duplex = dp[0] + dp[1] * 256; dp += 2;
- mi->mi_tx_threshold = dp[0] + dp[1] * 256; dp += 2;
- mi->mi_mii_interrupt = dp[0] + dp[1] * 256; dp += 2;
- TULIP_MEDIAINFO_ADD_CAPABILITY(sc, mi, 100BASETX_FD);
- TULIP_MEDIAINFO_ADD_CAPABILITY(sc, mi, 100BASETX);
- TULIP_MEDIAINFO_ADD_CAPABILITY(sc, mi, 100BASET4);
- TULIP_MEDIAINFO_ADD_CAPABILITY(sc, mi, 10BASET_FD);
- TULIP_MEDIAINFO_ADD_CAPABILITY(sc, mi, 10BASET);
- mi->mi_phyid = (tulip_mii_readreg(sc, mi->mi_phyaddr, PHYREG_IDLOW) << 16) |
- tulip_mii_readreg(sc, mi->mi_phyaddr, PHYREG_IDHIGH);
- mi++;
- break;
- }
- case 4: { /* 21143 SYM block */
- tulip_media_t media;
- srom_media = (tulip_srom_media_t) dp[0];
- for (idx3 = 0; tulip_srom_mediums[idx3].sm_type != TULIP_MEDIA_UNKNOWN; idx3++) {
- if (tulip_srom_mediums[idx3].sm_srom_type == srom_media)
- break;
- }
- media = tulip_srom_mediums[idx3].sm_type;
- if (media == TULIP_MEDIA_UNKNOWN)
- break;
- mi->mi_type = TULIP_MEDIAINFO_SYM;
- sc->tulip_mediums[media] = mi;
- mi->mi_gpcontrol = (dp[1] + dp[2] * 256) << 16;
- mi->mi_gpdata = (dp[3] + dp[4] * 256) << 16;
- data = dp[5] + dp[6] * 256;
- mi->mi_cmdmode = TULIP_SROM_2114X_CMDBITS(data);
- if (data & TULIP_SROM_2114X_NOINDICATOR) {
- mi->mi_actmask = 0;
- } else {
- mi->mi_default = (data & TULIP_SROM_2114X_DEFAULT) != 0;
- mi->mi_actmask = TULIP_SROM_2114X_BITPOS(data);
- mi->mi_actdata = (data & TULIP_SROM_2114X_POLARITY) ? 0 : mi->mi_actmask;
- }
- if (TULIP_IS_MEDIA_TP(media))
- sc->tulip_intrmask |= TULIP_STS_LINKPASS|TULIP_STS_LINKFAIL;
- mi++;
- break;
- }
-#if 0
- case 5: { /* 21143 Reset block */
- mi->mi_type = TULIP_MEDIAINFO_RESET;
- mi->mi_reset_length = *dp++;
- mi->mi_reset_offset = dp - sc->tulip_rombuf;
- dp += 2 * mi->mi_reset_length;
- mi++;
- break;
- }
-#endif
- default: {
- }
- }
- dp = ep;
- }
- }
- return mi - sc->tulip_mediainfo;
-}
-
-static const struct {
- void (*vendor_identify_nic)(tulip_softc_t * const sc);
- unsigned char vendor_oui[3];
-} tulip_vendors[] = {
- { tulip_identify_dec_nic, { 0x08, 0x00, 0x2B } },
- { tulip_identify_dec_nic, { 0x00, 0x00, 0xF8 } },
- { tulip_identify_smc_nic, { 0x00, 0x00, 0xC0 } },
- { tulip_identify_smc_nic, { 0x00, 0xE0, 0x29 } },
- { tulip_identify_znyx_nic, { 0x00, 0xC0, 0x95 } },
- { tulip_identify_cogent_nic, { 0x00, 0x00, 0x92 } },
- { tulip_identify_asante_nic, { 0x00, 0x00, 0x94 } },
- { tulip_identify_cogent_nic, { 0x00, 0x00, 0xD1 } },
- { tulip_identify_accton_nic, { 0x00, 0x00, 0xE8 } },
- { tulip_identify_compex_nic, { 0x00, 0x80, 0x48 } },
- { NULL }
-};
-
-/*
- * This deals with the vagaries of the address roms and the
- * brain-deadness that various vendors commit in using them.
- */
-static int
-tulip_read_macaddr(
- tulip_softc_t * const sc)
-{
- unsigned cksum, rom_cksum, idx;
- u_int32_t csr;
- unsigned char tmpbuf[8];
- static const u_char testpat[] = { 0xFF, 0, 0x55, 0xAA, 0xFF, 0, 0x55, 0xAA };
-
- sc->tulip_connidx = TULIP_SROM_LASTCONNIDX;
-
- if (sc->tulip_chipid == TULIP_21040) {
- TULIP_CSR_WRITE(sc, csr_enetrom, 1);
- for (idx = 0; idx < sizeof(sc->tulip_rombuf); idx++) {
- int cnt = 0;
- while (((csr = TULIP_CSR_READ(sc, csr_enetrom)) & 0x80000000L) && cnt < 10000)
- cnt++;
- sc->tulip_rombuf[idx] = csr & 0xFF;
- }
- sc->tulip_boardsw = &tulip_21040_boardsw;
- } else {
- if (sc->tulip_chipid == TULIP_21041) {
- /*
- * Thankfully all 21041's act the same.
- */
- sc->tulip_boardsw = &tulip_21041_boardsw;
- } else {
- /*
- * Assume all 21140 board are compatible with the
- * DEC 10/100 evaluation board. Not really valid but
- * it's the best we can do until every one switches to
- * the new SROM format.
- */
-
- sc->tulip_boardsw = &tulip_21140_eb_boardsw;
- }
- tulip_srom_read(sc);
- if (tulip_srom_crcok(sc->tulip_rombuf)) {
- /*
- * SROM CRC is valid therefore it must be in the
- * new format.
- */
- sc->tulip_features |= TULIP_HAVE_ISVSROM|TULIP_HAVE_OKSROM;
- } else if (sc->tulip_rombuf[126] == 0xff && sc->tulip_rombuf[127] == 0xFF) {
- /*
- * No checksum is present. See if the SROM id checks out;
- * the first 18 bytes should be 0 followed by a 1 followed
- * by the number of adapters (which we don't deal with yet).
- */
- for (idx = 0; idx < 18; idx++) {
- if (sc->tulip_rombuf[idx] != 0)
- break;
- }
- if (idx == 18 && sc->tulip_rombuf[18] == 1 && sc->tulip_rombuf[19] != 0)
- sc->tulip_features |= TULIP_HAVE_ISVSROM;
- } else if (sc->tulip_chipid >= TULIP_21142) {
- sc->tulip_features |= TULIP_HAVE_ISVSROM;
- sc->tulip_boardsw = &tulip_2114x_isv_boardsw;
- }
- if ((sc->tulip_features & TULIP_HAVE_ISVSROM) && tulip_srom_decode(sc)) {
- if (sc->tulip_chipid != TULIP_21041)
- sc->tulip_boardsw = &tulip_2114x_isv_boardsw;
-
- /*
- * If the SROM specifies more than one adapter, tag this as a
- * BASE rom.
- */
- if (sc->tulip_rombuf[19] > 1)
- sc->tulip_features |= TULIP_HAVE_BASEROM;
- if (sc->tulip_boardsw == NULL)
- return -6;
- goto check_oui;
- }
- }
-
-
- if (bcmp(&sc->tulip_rombuf[0], &sc->tulip_rombuf[16], 8) != 0) {
- /*
- * Some folks don't use the standard ethernet rom format
- * but instead just put the address in the first 6 bytes
- * of the rom and let the rest be all 0xffs. (Can we say
- * ZNYX?) (well sometimes they put in a checksum so we'll
- * start at 8).
- */
- for (idx = 8; idx < 32; idx++) {
- if (sc->tulip_rombuf[idx] != 0xFF)
- return -4;
- }
- /*
- * Make sure the address is not multicast or locally assigned
- * that the OUI is not 00-00-00.
- */
- if ((sc->tulip_rombuf[0] & 3) != 0)
- return -4;
- if (sc->tulip_rombuf[0] == 0 && sc->tulip_rombuf[1] == 0
- && sc->tulip_rombuf[2] == 0)
- return -4;
- bcopy(sc->tulip_rombuf, sc->tulip_enaddr, 6);
- sc->tulip_features |= TULIP_HAVE_OKROM;
- goto check_oui;
- } else {
- /*
- * A number of makers of multiport boards (ZNYX and Cogent)
- * only put on one address ROM on their 21040 boards. So
- * if the ROM is all zeros (or all 0xFFs), look at the
- * previous configured boards (as long as they are on the same
- * PCI bus and the bus number is non-zero) until we find the
- * master board with address ROM. We then use its address ROM
- * as the base for this board. (we add our relative board
- * to the last byte of its address).
- */
- for (idx = 0; idx < sizeof(sc->tulip_rombuf); idx++) {
- if (sc->tulip_rombuf[idx] != 0 && sc->tulip_rombuf[idx] != 0xFF)
- break;
- }
- if (idx == sizeof(sc->tulip_rombuf)) {
- int root_unit;
- tulip_softc_t *root_sc = NULL;
- for (root_unit = sc->tulip_unit - 1; root_unit >= 0; root_unit--) {
- root_sc = tulips[root_unit];
- if (root_sc == NULL || (root_sc->tulip_features & (TULIP_HAVE_OKROM|TULIP_HAVE_SLAVEDROM)) == TULIP_HAVE_OKROM)
- break;
- root_sc = NULL;
- }
- if (root_sc != NULL && (root_sc->tulip_features & TULIP_HAVE_BASEROM)
- && root_sc->tulip_chipid == sc->tulip_chipid
- && root_sc->tulip_pci_busno == sc->tulip_pci_busno) {
- sc->tulip_features |= TULIP_HAVE_SLAVEDROM;
- sc->tulip_boardsw = root_sc->tulip_boardsw;
- strcpy(sc->tulip_boardid, root_sc->tulip_boardid);
- if (sc->tulip_boardsw->bd_type == TULIP_21140_ISV) {
- bcopy(root_sc->tulip_rombuf, sc->tulip_rombuf,
- sizeof(sc->tulip_rombuf));
- if (!tulip_srom_decode(sc))
- return -5;
- } else {
- bcopy(root_sc->tulip_enaddr, sc->tulip_enaddr, 6);
- sc->tulip_enaddr[5] += sc->tulip_unit - root_sc->tulip_unit;
- }
- /*
- * Now for a truly disgusting kludge: all 4 21040s on
- * the ZX314 share the same INTA line so the mapping
- * setup by the BIOS on the PCI bridge is worthless.
- * Rather than reprogramming the value in the config
- * register, we will handle this internally.
- */
- if (root_sc->tulip_features & TULIP_HAVE_SHAREDINTR) {
- sc->tulip_slaves = root_sc->tulip_slaves;
- root_sc->tulip_slaves = sc;
- sc->tulip_features |= TULIP_HAVE_SLAVEDINTR;
- }
- return 0;
- }
- }
- }
-
- /*
- * This is the standard DEC address ROM test.
- */
-
- if (bcmp(&sc->tulip_rombuf[24], testpat, 8) != 0)
- return -3;
-
- tmpbuf[0] = sc->tulip_rombuf[15]; tmpbuf[1] = sc->tulip_rombuf[14];
- tmpbuf[2] = sc->tulip_rombuf[13]; tmpbuf[3] = sc->tulip_rombuf[12];
- tmpbuf[4] = sc->tulip_rombuf[11]; tmpbuf[5] = sc->tulip_rombuf[10];
- tmpbuf[6] = sc->tulip_rombuf[9]; tmpbuf[7] = sc->tulip_rombuf[8];
- if (bcmp(&sc->tulip_rombuf[0], tmpbuf, 8) != 0)
- return -2;
-
- bcopy(sc->tulip_rombuf, sc->tulip_enaddr, 6);
-
- cksum = *(u_int16_t *) &sc->tulip_enaddr[0];
- cksum *= 2;
- if (cksum > 65535) cksum -= 65535;
- cksum += *(u_int16_t *) &sc->tulip_enaddr[2];
- if (cksum > 65535) cksum -= 65535;
- cksum *= 2;
- if (cksum > 65535) cksum -= 65535;
- cksum += *(u_int16_t *) &sc->tulip_enaddr[4];
- if (cksum >= 65535) cksum -= 65535;
-
- rom_cksum = *(u_int16_t *) &sc->tulip_rombuf[6];
-
- if (cksum != rom_cksum)
- return -1;
-
- check_oui:
- /*
- * Check for various boards based on OUI. Did I say braindead?
- */
- for (idx = 0; tulip_vendors[idx].vendor_identify_nic != NULL; idx++) {
- if (bcmp(sc->tulip_enaddr, tulip_vendors[idx].vendor_oui, 3) == 0) {
- (*tulip_vendors[idx].vendor_identify_nic)(sc);
- break;
- }
- }
-
- sc->tulip_features |= TULIP_HAVE_OKROM;
- return 0;
-}
-
-static void
-tulip_ifmedia_add(
- tulip_softc_t * const sc)
-{
- tulip_media_t media;
- int medias = 0;
-
- for (media = TULIP_MEDIA_UNKNOWN; media < TULIP_MEDIA_MAX; media++) {
- if (sc->tulip_mediums[media] != NULL) {
- ifmedia_add(&sc->tulip_ifmedia, tulip_media_to_ifmedia[media],
- 0, 0);
- medias++;
- }
- }
- if (medias == 0) {
- sc->tulip_features |= TULIP_HAVE_NOMEDIA;
- ifmedia_add(&sc->tulip_ifmedia, IFM_ETHER | IFM_NONE, 0, 0);
- ifmedia_set(&sc->tulip_ifmedia, IFM_ETHER | IFM_NONE);
- } else if (sc->tulip_media == TULIP_MEDIA_UNKNOWN) {
- ifmedia_add(&sc->tulip_ifmedia, IFM_ETHER | IFM_AUTO, 0, 0);
- ifmedia_set(&sc->tulip_ifmedia, IFM_ETHER | IFM_AUTO);
- } else {
- ifmedia_set(&sc->tulip_ifmedia, tulip_media_to_ifmedia[sc->tulip_media]);
- sc->tulip_flags |= TULIP_PRINTMEDIA;
- tulip_linkup(sc, sc->tulip_media);
- }
-}
-
-static int
-tulip_ifmedia_change(
- struct ifnet * const ifp)
-{
- tulip_softc_t * const sc = (tulip_softc_t *)ifp->if_softc;
-
- sc->tulip_flags |= TULIP_NEEDRESET;
- sc->tulip_probe_state = TULIP_PROBE_INACTIVE;
- sc->tulip_media = TULIP_MEDIA_UNKNOWN;
- if (IFM_SUBTYPE(sc->tulip_ifmedia.ifm_media) != IFM_AUTO) {
- tulip_media_t media;
- for (media = TULIP_MEDIA_UNKNOWN; media < TULIP_MEDIA_MAX; media++) {
- if (sc->tulip_mediums[media] != NULL
- && sc->tulip_ifmedia.ifm_media == tulip_media_to_ifmedia[media]) {
- sc->tulip_flags |= TULIP_PRINTMEDIA;
- sc->tulip_flags &= ~TULIP_DIDNWAY;
- tulip_linkup(sc, media);
- return 0;
- }
- }
- }
- sc->tulip_flags &= ~(TULIP_TXPROBE_ACTIVE|TULIP_WANTRXACT);
- tulip_reset(sc);
- tulip_init(sc);
- return 0;
-}
-
-/*
- * Media status callback
- */
-static void
-tulip_ifmedia_status(
- struct ifnet * const ifp,
- struct ifmediareq *req)
-{
- tulip_softc_t *sc = (tulip_softc_t *)ifp->if_softc;
-
- if (sc->tulip_media == TULIP_MEDIA_UNKNOWN)
- return;
-
- req->ifm_status = IFM_AVALID;
- if (sc->tulip_flags & TULIP_LINKUP)
- req->ifm_status |= IFM_ACTIVE;
-
- req->ifm_active = tulip_media_to_ifmedia[sc->tulip_media];
-}
-
-static void
-tulip_addr_filter(
- tulip_softc_t * const sc)
-{
- struct ifmultiaddr *ifma;
- u_char *addrp;
- int multicnt;
-
- sc->tulip_flags &= ~(TULIP_WANTHASHPERFECT|TULIP_WANTHASHONLY|TULIP_ALLMULTI);
- sc->tulip_flags |= TULIP_WANTSETUP|TULIP_WANTTXSTART;
- sc->tulip_cmdmode &= ~TULIP_CMD_RXRUN;
- sc->tulip_intrmask &= ~TULIP_STS_RXSTOPPED;
-#if defined(IFF_ALLMULTI)
- if (sc->tulip_if.if_flags & IFF_ALLMULTI)
- sc->tulip_flags |= TULIP_ALLMULTI ;
-#endif
-
- multicnt = 0;
- for (ifma = sc->tulip_if.if_multiaddrs.lh_first; ifma != NULL;
- ifma = ifma->ifma_link.le_next) {
-
- if (ifma->ifma_addr->sa_family == AF_LINK)
- multicnt++;
- }
-
- sc->tulip_if.if_start = tulip_ifstart; /* so the setup packet gets queued */
- if (multicnt > 14) {
- u_int32_t *sp = sc->tulip_setupdata;
- unsigned hash;
- /*
- * Some early passes of the 21140 have broken implementations of
- * hash-perfect mode. When we get too many multicasts for perfect
- * filtering with these chips, we need to switch into hash-only
- * mode (this is better than all-multicast on network with lots
- * of multicast traffic).
- */
- if (sc->tulip_features & TULIP_HAVE_BROKEN_HASH)
- sc->tulip_flags |= TULIP_WANTHASHONLY;
- else
- sc->tulip_flags |= TULIP_WANTHASHPERFECT;
- /*
- * If we have more than 14 multicasts, we have
- * go into hash perfect mode (512 bit multicast
- * hash and one perfect hardware).
- */
- bzero(sc->tulip_setupdata, sizeof(sc->tulip_setupdata));
-
- for (ifma = sc->tulip_if.if_multiaddrs.lh_first; ifma != NULL;
- ifma = ifma->ifma_link.le_next) {
-
- if (ifma->ifma_addr->sa_family != AF_LINK)
- continue;
-
- hash = tulip_mchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
-#if BYTE_ORDER == BIG_ENDIAN
- sp[hash >> 4] |= bswap32(1 << (hash & 0xF));
-#else
- sp[hash >> 4] |= 1 << (hash & 0xF);
-#endif
- }
- /*
- * No reason to use a hash if we are going to be
- * receiving every multicast.
- */
- if ((sc->tulip_flags & TULIP_ALLMULTI) == 0) {
- hash = tulip_mchash(etherbroadcastaddr);
-#if BYTE_ORDER == BIG_ENDIAN
- sp[hash >> 4] |= bswap32(1 << (hash & 0xF));
-#else
- sp[hash >> 4] |= 1 << (hash & 0xF);
-#endif
- if (sc->tulip_flags & TULIP_WANTHASHONLY) {
- hash = tulip_mchash(sc->tulip_enaddr);
-#if BYTE_ORDER == BIG_ENDIAN
- sp[hash >> 4] |= bswap32(1 << (hash & 0xF));
-#else
- sp[hash >> 4] |= 1 << (hash & 0xF);
-#endif
- } else {
-#if BYTE_ORDER == BIG_ENDIAN
- sp[39] = ((u_int16_t *) sc->tulip_enaddr)[0] << 16;
- sp[40] = ((u_int16_t *) sc->tulip_enaddr)[1] << 16;
- sp[41] = ((u_int16_t *) sc->tulip_enaddr)[2] << 16;
-#else
- sp[39] = ((u_int16_t *) sc->tulip_enaddr)[0];
- sp[40] = ((u_int16_t *) sc->tulip_enaddr)[1];
- sp[41] = ((u_int16_t *) sc->tulip_enaddr)[2];
-#endif
- }
- }
- }
- if ((sc->tulip_flags & (TULIP_WANTHASHPERFECT|TULIP_WANTHASHONLY)) == 0) {
- u_int32_t *sp = sc->tulip_setupdata;
- int idx = 0;
- if ((sc->tulip_flags & TULIP_ALLMULTI) == 0) {
- /*
- * Else can get perfect filtering for 16 addresses.
- */
- for (ifma = sc->tulip_if.if_multiaddrs.lh_first; ifma != NULL;
- ifma = ifma->ifma_link.le_next) {
- if (ifma->ifma_addr->sa_family != AF_LINK)
- continue;
- addrp = LLADDR((struct sockaddr_dl *)ifma->ifma_addr);
-#if BYTE_ORDER == BIG_ENDIAN
- *sp++ = ((u_int16_t *) addrp)[0] << 16;
- *sp++ = ((u_int16_t *) addrp)[1] << 16;
- *sp++ = ((u_int16_t *) addrp)[2] << 16;
-#else
- *sp++ = ((u_int16_t *) addrp)[0];
- *sp++ = ((u_int16_t *) addrp)[1];
- *sp++ = ((u_int16_t *) addrp)[2];
-#endif
- idx++;
- }
- /*
- * Add the broadcast address.
- */
- idx++;
-#if BYTE_ORDER == BIG_ENDIAN
- *sp++ = 0xFFFF << 16;
- *sp++ = 0xFFFF << 16;
- *sp++ = 0xFFFF << 16;
-#else
- *sp++ = 0xFFFF;
- *sp++ = 0xFFFF;
- *sp++ = 0xFFFF;
-#endif
- }
- /*
- * Pad the rest with our hardware address
- */
- for (; idx < 16; idx++) {
-#if BYTE_ORDER == BIG_ENDIAN
- *sp++ = ((u_int16_t *) sc->tulip_enaddr)[0] << 16;
- *sp++ = ((u_int16_t *) sc->tulip_enaddr)[1] << 16;
- *sp++ = ((u_int16_t *) sc->tulip_enaddr)[2] << 16;
-#else
- *sp++ = ((u_int16_t *) sc->tulip_enaddr)[0];
- *sp++ = ((u_int16_t *) sc->tulip_enaddr)[1];
- *sp++ = ((u_int16_t *) sc->tulip_enaddr)[2];
-#endif
- }
- }
-#if defined(IFF_ALLMULTI)
- if (sc->tulip_flags & TULIP_ALLMULTI)
- sc->tulip_if.if_flags |= IFF_ALLMULTI;
-#endif
-}
-
-static void
-tulip_reset(
- tulip_softc_t * const sc)
-{
- tulip_ringinfo_t *ri;
- tulip_desc_t *di;
- u_int32_t inreset = (sc->tulip_flags & TULIP_INRESET);
-
- /*
- * Brilliant. Simply brilliant. When switching modes/speeds
- * on a 2114*, you need to set the appriopriate MII/PCS/SCL/PS
- * bits in CSR6 and then do a software reset to get the 21140
- * to properly reset its internal pathways to the right places.
- * Grrrr.
- */
- if ((sc->tulip_flags & TULIP_DEVICEPROBE) == 0
- && sc->tulip_boardsw->bd_media_preset != NULL)
- (*sc->tulip_boardsw->bd_media_preset)(sc);
-
- TULIP_CSR_WRITE(sc, csr_busmode, TULIP_BUSMODE_SWRESET);
- DELAY(10); /* Wait 10 microseconds (actually 50 PCI cycles but at
- 33MHz that comes to two microseconds but wait a
- bit longer anyways) */
-
- if (!inreset) {
- sc->tulip_flags |= TULIP_INRESET;
- sc->tulip_flags &= ~(TULIP_NEEDRESET|TULIP_RXBUFSLOW);
- sc->tulip_if.if_flags &= ~IFF_OACTIVE;
- sc->tulip_if.if_start = tulip_ifstart;
- }
-
-#if defined(TULIP_BUS_DMA) && !defined(TULIP_BUS_DMA_NOTX)
- TULIP_CSR_WRITE(sc, csr_txlist, sc->tulip_txdescmap->dm_segs[0].ds_addr);
-#else
- TULIP_CSR_WRITE(sc, csr_txlist, TULIP_KVATOPHYS(sc, &sc->tulip_txinfo.ri_first[0]));
-#endif
-#if defined(TULIP_BUS_DMA) && !defined(TULIP_BUS_DMA_NORX)
- TULIP_CSR_WRITE(sc, csr_rxlist, sc->tulip_rxdescmap->dm_segs[0].ds_addr);
-#else
- TULIP_CSR_WRITE(sc, csr_rxlist, TULIP_KVATOPHYS(sc, &sc->tulip_rxinfo.ri_first[0]));
-#endif
- TULIP_CSR_WRITE(sc, csr_busmode,
- (1 << (pci_max_burst_len + 8))
- |TULIP_BUSMODE_CACHE_ALIGN8
- |TULIP_BUSMODE_READMULTIPLE
- |(BYTE_ORDER != LITTLE_ENDIAN ?
- TULIP_BUSMODE_DESC_BIGENDIAN : 0));
-
- sc->tulip_txtimer = 0;
- sc->tulip_txq.ifq_maxlen = TULIP_TXDESCS;
- /*
- * Free all the mbufs that were on the transmit ring.
- */
- for (;;) {
-#if defined(TULIP_BUS_DMA) && !defined(TULIP_BUS_DMA_NOTX)
- bus_dmamap_t map;
-#endif
- struct mbuf *m;
- IF_DEQUEUE(&sc->tulip_txq, m);
- if (m == NULL)
- break;
-#if defined(TULIP_BUS_DMA) && !defined(TULIP_BUS_DMA_NOTX)
- map = M_GETCTX(m, bus_dmamap_t);
- bus_dmamap_unload(sc->tulip_dmatag, map);
- sc->tulip_txmaps[sc->tulip_txmaps_free++] = map;
-#endif
- m_freem(m);
- }
-
- ri = &sc->tulip_txinfo;
- ri->ri_nextin = ri->ri_nextout = ri->ri_first;
- ri->ri_free = ri->ri_max;
- for (di = ri->ri_first; di < ri->ri_last; di++)
- di->d_status = 0;
-#if defined(TULIP_BUS_DMA) && !defined(TULIP_BUS_DMA_NOTX)
- bus_dmamap_sync(sc->tulip_dmatag, sc->tulip_txdescmap,
- 0, sc->tulip_txdescmap->dm_mapsize,
- BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
-#endif
-
- /*
- * We need to collect all the mbufs were on the
- * receive ring before we reinit it either to put
- * them back on or to know if we have to allocate
- * more.
- */
- ri = &sc->tulip_rxinfo;
- ri->ri_nextin = ri->ri_nextout = ri->ri_first;
- ri->ri_free = ri->ri_max;
- for (di = ri->ri_first; di < ri->ri_last; di++) {
- di->d_status = 0;
- di->d_length1 = 0; di->d_addr1 = 0;
- di->d_length2 = 0; di->d_addr2 = 0;
- }
-#if defined(TULIP_BUS_DMA) && !defined(TULIP_BUS_DMA_NORX)
- bus_dmamap_sync(sc->tulip_dmatag, sc->tulip_rxdescmap,
- 0, sc->tulip_rxdescmap->dm_mapsize,
- BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
-#endif
- for (;;) {
-#if defined(TULIP_BUS_DMA) && !defined(TULIP_BUS_DMA_NORX)
- bus_dmamap_t map;
-#endif
- struct mbuf *m;
- IF_DEQUEUE(&sc->tulip_rxq, m);
- if (m == NULL)
- break;
-#if defined(TULIP_BUS_DMA) && !defined(TULIP_BUS_DMA_NORX)
- map = M_GETCTX(m, bus_dmamap_t);
- bus_dmamap_unload(sc->tulip_dmatag, map);
- sc->tulip_rxmaps[sc->tulip_rxmaps_free++] = map;
-#endif
- m_freem(m);
- }
-
- /*
- * If tulip_reset is being called recurisvely, exit quickly knowing
- * that when the outer tulip_reset returns all the right stuff will
- * have happened.
- */
- if (inreset)
- return;
-
- sc->tulip_intrmask |= TULIP_STS_NORMALINTR|TULIP_STS_RXINTR|TULIP_STS_TXINTR
- |TULIP_STS_ABNRMLINTR|TULIP_STS_SYSERROR|TULIP_STS_TXSTOPPED
- |TULIP_STS_TXUNDERFLOW|TULIP_STS_TXBABBLE
- |TULIP_STS_RXSTOPPED;
-
- if ((sc->tulip_flags & TULIP_DEVICEPROBE) == 0)
- (*sc->tulip_boardsw->bd_media_select)(sc);
-#if defined(TULIP_DEBUG)
- if ((sc->tulip_flags & TULIP_NEEDRESET) == TULIP_NEEDRESET)
- printf("%s%d: tulip_reset: additional reset needed?!?\n",
- sc->tulip_name, sc->tulip_unit);
-#endif
- tulip_media_print(sc);
- if (sc->tulip_features & TULIP_HAVE_DUALSENSE)
- TULIP_CSR_WRITE(sc, csr_sia_status, TULIP_CSR_READ(sc, csr_sia_status));
-
- sc->tulip_flags &= ~(TULIP_DOINGSETUP|TULIP_WANTSETUP|TULIP_INRESET
- |TULIP_RXACT);
- tulip_addr_filter(sc);
-}
-
-static void
-tulip_init(
- tulip_softc_t * const sc)
-{
- if (sc->tulip_if.if_flags & IFF_UP) {
- if ((sc->tulip_if.if_flags & IFF_RUNNING) == 0) {
- /* initialize the media */
- tulip_reset(sc);
- }
- sc->tulip_if.if_flags |= IFF_RUNNING;
- if (sc->tulip_if.if_flags & IFF_PROMISC) {
- sc->tulip_flags |= TULIP_PROMISC;
- sc->tulip_cmdmode |= TULIP_CMD_PROMISCUOUS;
- sc->tulip_intrmask |= TULIP_STS_TXINTR;
- } else {
- sc->tulip_flags &= ~TULIP_PROMISC;
- sc->tulip_cmdmode &= ~TULIP_CMD_PROMISCUOUS;
- if (sc->tulip_flags & TULIP_ALLMULTI) {
- sc->tulip_cmdmode |= TULIP_CMD_ALLMULTI;
- } else {
- sc->tulip_cmdmode &= ~TULIP_CMD_ALLMULTI;
- }
- }
- sc->tulip_cmdmode |= TULIP_CMD_TXRUN;
- if ((sc->tulip_flags & (TULIP_TXPROBE_ACTIVE|TULIP_WANTSETUP)) == 0) {
- tulip_rx_intr(sc);
- sc->tulip_cmdmode |= TULIP_CMD_RXRUN;
- sc->tulip_intrmask |= TULIP_STS_RXSTOPPED;
- } else {
- sc->tulip_if.if_flags |= IFF_OACTIVE;
- sc->tulip_cmdmode &= ~TULIP_CMD_RXRUN;
- sc->tulip_intrmask &= ~TULIP_STS_RXSTOPPED;
- }
- TULIP_CSR_WRITE(sc, csr_intr, sc->tulip_intrmask);
- TULIP_CSR_WRITE(sc, csr_command, sc->tulip_cmdmode);
- if ((sc->tulip_flags & (TULIP_WANTSETUP|TULIP_TXPROBE_ACTIVE)) == TULIP_WANTSETUP)
- tulip_txput_setup(sc);
- } else {
- sc->tulip_if.if_flags &= ~IFF_RUNNING;
- tulip_reset(sc);
- }
-}
-
-static void
-tulip_rx_intr(
- tulip_softc_t * const sc)
-{
- TULIP_PERFSTART(rxintr)
- tulip_ringinfo_t * const ri = &sc->tulip_rxinfo;
- struct ifnet * const ifp = &sc->tulip_if;
- int fillok = 1;
-#if defined(TULIP_DEBUG)
- int cnt = 0;
-#endif
-
- for (;;) {
- TULIP_PERFSTART(rxget)
- struct ether_header eh;
- tulip_desc_t *eop = ri->ri_nextin;
- int total_len = 0, last_offset = 0;
- struct mbuf *ms = NULL, *me = NULL;
- int accept = 0;
-#if defined(TULIP_BUS_DMA) && !defined(TULIP_BUS_DMA_NORX)
- bus_dmamap_t map;
- int error;
-#endif
-
- if (fillok && sc->tulip_rxq.ifq_len < TULIP_RXQ_TARGET)
- goto queue_mbuf;
-
-#if defined(TULIP_DEBUG)
- if (cnt == ri->ri_max)
- break;
-#endif
- /*
- * If the TULIP has no descriptors, there can't be any receive
- * descriptors to process.
- */
- if (eop == ri->ri_nextout)
- break;
-
- /*
- * 90% of the packets will fit in one descriptor. So we optimize
- * for that case.
- */
- TULIP_RXDESC_POSTSYNC(sc, eop, sizeof(*eop));
- if ((((volatile tulip_desc_t *) eop)->d_status & (TULIP_DSTS_OWNER|TULIP_DSTS_RxFIRSTDESC|TULIP_DSTS_RxLASTDESC)) == (TULIP_DSTS_RxFIRSTDESC|TULIP_DSTS_RxLASTDESC)) {
- IF_DEQUEUE(&sc->tulip_rxq, ms);
- me = ms;
- } else {
- /*
- * If still owned by the TULIP, don't touch it.
- */
- if (((volatile tulip_desc_t *) eop)->d_status & TULIP_DSTS_OWNER)
- break;
-
- /*
- * It is possible (though improbable unless the BIG_PACKET support
- * is enabled or MCLBYTES < 1518) for a received packet to cross
- * more than one receive descriptor.
- */
- while ((((volatile tulip_desc_t *) eop)->d_status & TULIP_DSTS_RxLASTDESC) == 0) {
- if (++eop == ri->ri_last)
- eop = ri->ri_first;
- TULIP_RXDESC_POSTSYNC(sc, eop, sizeof(*eop));
- if (eop == ri->ri_nextout || ((((volatile tulip_desc_t *) eop)->d_status & TULIP_DSTS_OWNER))) {
-#if defined(TULIP_DEBUG)
- sc->tulip_dbg.dbg_rxintrs++;
- sc->tulip_dbg.dbg_rxpktsperintr[cnt]++;
-#endif
- TULIP_PERFEND(rxget);
- TULIP_PERFEND(rxintr);
- return;
- }
- total_len++;
- }
-
- /*
- * Dequeue the first buffer for the start of the packet. Hopefully
- * this will be the only one we need to dequeue. However, if the
- * packet consumed multiple descriptors, then we need to dequeue
- * those buffers and chain to the starting mbuf. All buffers but
- * the last buffer have the same length so we can set that now.
- * (we add to last_offset instead of multiplying since we normally
- * won't go into the loop and thereby saving a ourselves from
- * doing a multiplication by 0 in the normal case).
- */
- IF_DEQUEUE(&sc->tulip_rxq, ms);
- for (me = ms; total_len > 0; total_len--) {
-#if defined(TULIP_BUS_DMA) && !defined(TULIP_BUS_DMA_NORX)
- map = M_GETCTX(me, bus_dmamap_t);
- TULIP_RXMAP_POSTSYNC(sc, map);
- bus_dmamap_unload(sc->tulip_dmatag, map);
- sc->tulip_rxmaps[sc->tulip_rxmaps_free++] = map;
-#if defined(DIAGNOSTIC)
- M_SETCTX(me, NULL);
-#endif
-#endif /* TULIP_BUS_DMA */
- me->m_len = TULIP_RX_BUFLEN;
- last_offset += TULIP_RX_BUFLEN;
- IF_DEQUEUE(&sc->tulip_rxq, me->m_next);
- me = me->m_next;
- }
- }
-
- /*
- * Now get the size of received packet (minus the CRC).
- */
- total_len = ((eop->d_status >> 16) & 0x7FFF) - 4;
- if ((sc->tulip_flags & TULIP_RXIGNORE) == 0
- && ((eop->d_status & TULIP_DSTS_ERRSUM) == 0
-#ifdef BIG_PACKET
- || (total_len <= sc->tulip_if.if_mtu + sizeof(struct ether_header) &&
- (eop->d_status & (TULIP_DSTS_RxBADLENGTH|TULIP_DSTS_RxRUNT|
- TULIP_DSTS_RxCOLLSEEN|TULIP_DSTS_RxBADCRC|
- TULIP_DSTS_RxOVERFLOW)) == 0)
-#endif
- )) {
- me->m_len = total_len - last_offset;
-
-#if defined(TULIP_BUS_DMA) && !defined(TULIP_BUS_DMA_NORX)
- map = M_GETCTX(me, bus_dmamap_t);
- bus_dmamap_sync(sc->tulip_dmatag, map, 0, me->m_len,
- BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE);
- bus_dmamap_unload(sc->tulip_dmatag, map);
- sc->tulip_rxmaps[sc->tulip_rxmaps_free++] = map;
-#if defined(DIAGNOSTIC)
- M_SETCTX(me, NULL);
-#endif
-#endif /* TULIP_BUS_DMA */
-
- eh = *mtod(ms, struct ether_header *);
- if (sc->tulip_if.if_bpf != NULL) {
- if (me == ms)
- bpf_tap(&sc->tulip_if, mtod(ms, caddr_t), total_len);
- else
- bpf_mtap(&sc->tulip_if, ms);
- }
- sc->tulip_flags |= TULIP_RXACT;
-
-#ifdef BRIDGE /* see code in if_ed.c */
- ms->m_pkthdr.rcvif = ifp; /* XXX */
- ms->m_pkthdr.len = total_len; /* XXX */
- if (do_bridge) {
- struct ifnet *bdg_ifp ;
- bdg_ifp = bridge_in(ms);
- if (bdg_ifp == BDG_DROP)
- goto next ; /* and drop */
- if (bdg_ifp != BDG_LOCAL)
- bdg_forward(&ms, bdg_ifp);
- if (bdg_ifp != BDG_LOCAL && bdg_ifp != BDG_BCAST &&
- bdg_ifp != BDG_MCAST)
- goto next ; /* and drop */
- /* all others accepted locally */
- } else
-#endif
- if ((sc->tulip_flags & (TULIP_PROMISC|TULIP_HASHONLY))
- && (eh.ether_dhost[0] & 1) == 0
- && !TULIP_ADDREQUAL(eh.ether_dhost, sc->tulip_enaddr))
- goto next;
- accept = 1;
- } else {
- ifp->if_ierrors++;
- if (eop->d_status & (TULIP_DSTS_RxBADLENGTH|TULIP_DSTS_RxOVERFLOW|TULIP_DSTS_RxWATCHDOG)) {
- sc->tulip_dot3stats.dot3StatsInternalMacReceiveErrors++;
- } else {
-#if defined(TULIP_VERBOSE)
- const char *error = NULL;
-#endif
- if (eop->d_status & TULIP_DSTS_RxTOOLONG) {
- sc->tulip_dot3stats.dot3StatsFrameTooLongs++;
-#if defined(TULIP_VERBOSE)
- error = "frame too long";
-#endif
- }
- if (eop->d_status & TULIP_DSTS_RxBADCRC) {
- if (eop->d_status & TULIP_DSTS_RxDRBBLBIT) {
- sc->tulip_dot3stats.dot3StatsAlignmentErrors++;
-#if defined(TULIP_VERBOSE)
- error = "alignment error";
-#endif
- } else {
- sc->tulip_dot3stats.dot3StatsFCSErrors++;
-#if defined(TULIP_VERBOSE)
- error = "bad crc";
-#endif
- }
- }
-#if defined(TULIP_VERBOSE)
- if (error != NULL && (sc->tulip_flags & TULIP_NOMESSAGES) == 0) {
- printf("%s%d: receive: %6D: %s\n",
- sc->tulip_name, sc->tulip_unit,
- mtod(ms, u_char *) + 6, ":",
- error);
- sc->tulip_flags |= TULIP_NOMESSAGES;
- }
-#endif
- }
-
-#if defined(TULIP_BUS_DMA) && !defined(TULIP_BUS_DMA_NORX)
- map = M_GETCTX(me, bus_dmamap_t);
- bus_dmamap_unload(sc->tulip_dmatag, map);
- sc->tulip_rxmaps[sc->tulip_rxmaps_free++] = map;
-#if defined(DIAGNOSTIC)
- M_SETCTX(me, NULL);
-#endif
-#endif /* TULIP_BUS_DMA */
- }
- next:
-#if defined(TULIP_DEBUG)
- cnt++;
-#endif
- ifp->if_ipackets++;
- if (++eop == ri->ri_last)
- eop = ri->ri_first;
- ri->ri_nextin = eop;
- queue_mbuf:
- /*
- * Either we are priming the TULIP with mbufs (m == NULL)
- * or we are about to accept an mbuf for the upper layers
- * so we need to allocate an mbuf to replace it. If we
- * can't replace it, send up it anyways. This may cause
- * us to drop packets in the future but that's better than
- * being caught in livelock.
- *
- * Note that if this packet crossed multiple descriptors
- * we don't even try to reallocate all the mbufs here.
- * Instead we rely on the test of the beginning of
- * the loop to refill for the extra consumed mbufs.
- */
- if (accept || ms == NULL) {
- struct mbuf *m0;
- MGETHDR(m0, M_DONTWAIT, MT_DATA);
- if (m0 != NULL) {
-#if defined(TULIP_COPY_RXDATA)
- if (!accept || total_len >= (MHLEN - 2)) {
-#endif
- MCLGET(m0, M_DONTWAIT);
- if ((m0->m_flags & M_EXT) == 0) {
- m_freem(m0);
- m0 = NULL;
- }
-#if defined(TULIP_COPY_RXDATA)
- }
-#endif
- }
- if (accept
-#if defined(TULIP_COPY_RXDATA)
- && m0 != NULL
-#endif
- ) {
-#if !defined(TULIP_COPY_RXDATA)
- ms->m_pkthdr.len = total_len;
- ms->m_pkthdr.rcvif = ifp;
- m_adj(ms, sizeof(struct ether_header));
- ether_input(ifp, &eh, ms);
-#else
-#ifdef BIG_PACKET
-#error BIG_PACKET is incompatible with TULIP_COPY_RXDATA
-#endif
- m0->m_data += 2; /* align data after header */
- m_copydata(ms, 0, total_len, mtod(m0, caddr_t));
- m0->m_len = m0->m_pkthdr.len = total_len;
- m0->m_pkthdr.rcvif = ifp;
- m_adj(m0, sizeof(struct ether_header));
- ether_input(ifp, &eh, m0);
- m0 = ms;
-#endif /* ! TULIP_COPY_RXDATA */
- }
- ms = m0;
- }
- if (ms == NULL) {
- /*
- * Couldn't allocate a new buffer. Don't bother
- * trying to replenish the receive queue.
- */
- fillok = 0;
- sc->tulip_flags |= TULIP_RXBUFSLOW;
-#if defined(TULIP_DEBUG)
- sc->tulip_dbg.dbg_rxlowbufs++;
-#endif
- TULIP_PERFEND(rxget);
- continue;
- }
- /*
- * Now give the buffer(s) to the TULIP and save in our
- * receive queue.
- */
- do {
- tulip_desc_t * const nextout = ri->ri_nextout;
-#if defined(TULIP_BUS_DMA) && !defined(TULIP_BUS_DMA_NORX)
- if (sc->tulip_rxmaps_free > 0) {
- map = sc->tulip_rxmaps[--sc->tulip_rxmaps_free];
- } else {
- m_freem(ms);
- sc->tulip_flags |= TULIP_RXBUFSLOW;
-#if defined(TULIP_DEBUG)
- sc->tulip_dbg.dbg_rxlowbufs++;
-#endif
- break;
- }
- M_SETCTX(ms, map);
- error = bus_dmamap_load(sc->tulip_dmatag, map, mtod(ms, void *),
- TULIP_RX_BUFLEN, NULL, BUS_DMA_NOWAIT);
- if (error) {
- printf("%s%d: unable to load rx map, "
- "error = %d\n", sc->tulip_name, sc->tulip_unit, error);
- panic("tulip_rx_intr"); /* XXX */
- }
- nextout->d_addr1 = map->dm_segs[0].ds_addr;
- nextout->d_length1 = map->dm_segs[0].ds_len;
- if (map->dm_nsegs == 2) {
- nextout->d_addr2 = map->dm_segs[1].ds_addr;
- nextout->d_length2 = map->dm_segs[1].ds_len;
- } else {
- nextout->d_addr2 = 0;
- nextout->d_length2 = 0;
- }
- TULIP_RXDESC_POSTSYNC(sc, nextout, sizeof(*nextout));
-#else /* TULIP_BUS_DMA */
- nextout->d_addr1 = TULIP_KVATOPHYS(sc, mtod(ms, caddr_t));
- nextout->d_length1 = TULIP_RX_BUFLEN;
-#endif /* TULIP_BUS_DMA */
- nextout->d_status = TULIP_DSTS_OWNER;
- TULIP_RXDESC_POSTSYNC(sc, nextout, sizeof(u_int32_t));
- if (++ri->ri_nextout == ri->ri_last)
- ri->ri_nextout = ri->ri_first;
- me = ms->m_next;
- ms->m_next = NULL;
- IF_ENQUEUE(&sc->tulip_rxq, ms);
- } while ((ms = me) != NULL);
-
- if (sc->tulip_rxq.ifq_len >= TULIP_RXQ_TARGET)
- sc->tulip_flags &= ~TULIP_RXBUFSLOW;
- TULIP_PERFEND(rxget);
- }
-
-#if defined(TULIP_DEBUG)
- sc->tulip_dbg.dbg_rxintrs++;
- sc->tulip_dbg.dbg_rxpktsperintr[cnt]++;
-#endif
- TULIP_PERFEND(rxintr);
-}
-
-static int
-tulip_tx_intr(
- tulip_softc_t * const sc)
-{
- TULIP_PERFSTART(txintr)
- tulip_ringinfo_t * const ri = &sc->tulip_txinfo;
- struct mbuf *m;
- int xmits = 0;
- int descs = 0;
-
- while (ri->ri_free < ri->ri_max) {
- u_int32_t d_flag;
-
- TULIP_TXDESC_POSTSYNC(sc, ri->ri_nextin, sizeof(*ri->ri_nextin));
- if (((volatile tulip_desc_t *) ri->ri_nextin)->d_status & TULIP_DSTS_OWNER)
- break;
-
- ri->ri_free++;
- descs++;
- d_flag = ri->ri_nextin->d_flag;
- if (d_flag & TULIP_DFLAG_TxLASTSEG) {
- if (d_flag & TULIP_DFLAG_TxSETUPPKT) {
- /*
- * We've just finished processing a setup packet.
- * Mark that we finished it. If there's not
- * another pending, startup the TULIP receiver.
- * Make sure we ack the RXSTOPPED so we won't get
- * an abormal interrupt indication.
- */
- TULIP_TXMAP_POSTSYNC(sc, sc->tulip_setupmap);
- sc->tulip_flags &= ~(TULIP_DOINGSETUP|TULIP_HASHONLY);
- if (ri->ri_nextin->d_flag & TULIP_DFLAG_TxINVRSFILT)
- sc->tulip_flags |= TULIP_HASHONLY;
- if ((sc->tulip_flags & (TULIP_WANTSETUP|TULIP_TXPROBE_ACTIVE)) == 0) {
- tulip_rx_intr(sc);
- sc->tulip_cmdmode |= TULIP_CMD_RXRUN;
- sc->tulip_intrmask |= TULIP_STS_RXSTOPPED;
- TULIP_CSR_WRITE(sc, csr_status, TULIP_STS_RXSTOPPED);
- TULIP_CSR_WRITE(sc, csr_intr, sc->tulip_intrmask);
- TULIP_CSR_WRITE(sc, csr_command, sc->tulip_cmdmode);
- }
- } else {
- const u_int32_t d_status = ri->ri_nextin->d_status;
- IF_DEQUEUE(&sc->tulip_txq, m);
- if (m != NULL) {
-#if defined(TULIP_BUS_DMA) && !defined(TULIP_BUS_DMA_NOTX)
- bus_dmamap_t map = M_GETCTX(m, bus_dmamap_t);
- TULIP_TXMAP_POSTSYNC(sc, map);
- sc->tulip_txmaps[sc->tulip_txmaps_free++] = map;
-#endif /* TULIP_BUS_DMA */
- if (sc->tulip_if.if_bpf != NULL)
- bpf_mtap(&sc->tulip_if, m);
- m_freem(m);
-#if defined(TULIP_DEBUG)
- } else {
- printf("%s%d: tx_intr: failed to dequeue mbuf?!?\n",
- sc->tulip_name, sc->tulip_unit);
-#endif
- }
- if (sc->tulip_flags & TULIP_TXPROBE_ACTIVE) {
- tulip_mediapoll_event_t event = TULIP_MEDIAPOLL_TXPROBE_OK;
- if (d_status & (TULIP_DSTS_TxNOCARR|TULIP_DSTS_TxEXCCOLL)) {
-#if defined(TULIP_DEBUG)
- if (d_status & TULIP_DSTS_TxNOCARR)
- sc->tulip_dbg.dbg_txprobe_nocarr++;
- if (d_status & TULIP_DSTS_TxEXCCOLL)
- sc->tulip_dbg.dbg_txprobe_exccoll++;
-#endif
- event = TULIP_MEDIAPOLL_TXPROBE_FAILED;
- }
- (*sc->tulip_boardsw->bd_media_poll)(sc, event);
- /*
- * Escape from the loop before media poll has reset the TULIP!
- */
- break;
- } else {
- xmits++;
- if (d_status & TULIP_DSTS_ERRSUM) {
- sc->tulip_if.if_oerrors++;
- if (d_status & TULIP_DSTS_TxEXCCOLL)
- sc->tulip_dot3stats.dot3StatsExcessiveCollisions++;
- if (d_status & TULIP_DSTS_TxLATECOLL)
- sc->tulip_dot3stats.dot3StatsLateCollisions++;
- if (d_status & (TULIP_DSTS_TxNOCARR|TULIP_DSTS_TxCARRLOSS))
- sc->tulip_dot3stats.dot3StatsCarrierSenseErrors++;
- if (d_status & (TULIP_DSTS_TxUNDERFLOW|TULIP_DSTS_TxBABBLE))
- sc->tulip_dot3stats.dot3StatsInternalMacTransmitErrors++;
- if (d_status & TULIP_DSTS_TxUNDERFLOW)
- sc->tulip_dot3stats.dot3StatsInternalTransmitUnderflows++;
- if (d_status & TULIP_DSTS_TxBABBLE)
- sc->tulip_dot3stats.dot3StatsInternalTransmitBabbles++;
- } else {
- u_int32_t collisions =
- (d_status & TULIP_DSTS_TxCOLLMASK)
- >> TULIP_DSTS_V_TxCOLLCNT;
- sc->tulip_if.if_collisions += collisions;
- if (collisions == 1)
- sc->tulip_dot3stats.dot3StatsSingleCollisionFrames++;
- else if (collisions > 1)
- sc->tulip_dot3stats.dot3StatsMultipleCollisionFrames++;
- else if (d_status & TULIP_DSTS_TxDEFERRED)
- sc->tulip_dot3stats.dot3StatsDeferredTransmissions++;
- /*
- * SQE is only valid for 10baseT/BNC/AUI when not
- * running in full-duplex. In order to speed up the
- * test, the corresponding bit in tulip_flags needs to
- * set as well to get us to count SQE Test Errors.
- */
- if (d_status & TULIP_DSTS_TxNOHRTBT & sc->tulip_flags)
- sc->tulip_dot3stats.dot3StatsSQETestErrors++;
- }
- }
- }
- }
-
- if (++ri->ri_nextin == ri->ri_last)
- ri->ri_nextin = ri->ri_first;
-
- if ((sc->tulip_flags & TULIP_TXPROBE_ACTIVE) == 0)
- sc->tulip_if.if_flags &= ~IFF_OACTIVE;
- }
- /*
- * If nothing left to transmit, disable the timer.
- * Else if progress, reset the timer back to 2 ticks.
- */
- if (ri->ri_free == ri->ri_max || (sc->tulip_flags & TULIP_TXPROBE_ACTIVE))
- sc->tulip_txtimer = 0;
- else if (xmits > 0)
- sc->tulip_txtimer = TULIP_TXTIMER;
- sc->tulip_if.if_opackets += xmits;
- TULIP_PERFEND(txintr);
- return descs;
-}
-
-static void
-tulip_print_abnormal_interrupt(
- tulip_softc_t * const sc,
- u_int32_t csr)
-{
- const char * const *msgp = tulip_status_bits;
- const char *sep;
- u_int32_t mask;
- const char thrsh[] = "72|128\0\0\0" "96|256\0\0\0" "128|512\0\0" "160|1024";
-
- csr &= (1 << (sizeof(tulip_status_bits)/sizeof(tulip_status_bits[0]))) - 1;
- printf("%s%d: abnormal interrupt:", sc->tulip_name, sc->tulip_unit);
- for (sep = " ", mask = 1; mask <= csr; mask <<= 1, msgp++) {
- if ((csr & mask) && *msgp != NULL) {
- printf("%s%s", sep, *msgp);
- if (mask == TULIP_STS_TXUNDERFLOW && (sc->tulip_flags & TULIP_NEWTXTHRESH)) {
- sc->tulip_flags &= ~TULIP_NEWTXTHRESH;
- if (sc->tulip_cmdmode & TULIP_CMD_STOREFWD) {
- printf(" (switching to store-and-forward mode)");
- } else {
- printf(" (raising TX threshold to %s)",
- &thrsh[9 * ((sc->tulip_cmdmode & TULIP_CMD_THRESHOLDCTL) >> 14)]);
- }
- }
- sep = ", ";
- }
- }
- printf("\n");
-}
-
-static void
-tulip_intr_handler(
- tulip_softc_t * const sc,
- int *progress_p)
-{
- TULIP_PERFSTART(intr)
- u_int32_t csr;
-
- while ((csr = TULIP_CSR_READ(sc, csr_status)) & sc->tulip_intrmask) {
- *progress_p = 1;
- TULIP_CSR_WRITE(sc, csr_status, csr);
-
- if (csr & TULIP_STS_SYSERROR) {
- sc->tulip_last_system_error = (csr & TULIP_STS_ERRORMASK) >> TULIP_STS_ERR_SHIFT;
- if (sc->tulip_flags & TULIP_NOMESSAGES) {
- sc->tulip_flags |= TULIP_SYSTEMERROR;
- } else {
- printf("%s%d: system error: %s\n",
- sc->tulip_name, sc->tulip_unit,
- tulip_system_errors[sc->tulip_last_system_error]);
- }
- sc->tulip_flags |= TULIP_NEEDRESET;
- sc->tulip_system_errors++;
- break;
- }
- if (csr & (TULIP_STS_LINKPASS|TULIP_STS_LINKFAIL) & sc->tulip_intrmask) {
-#if defined(TULIP_DEBUG)
- sc->tulip_dbg.dbg_link_intrs++;
-#endif
- if (sc->tulip_boardsw->bd_media_poll != NULL) {
- (*sc->tulip_boardsw->bd_media_poll)(sc, csr & TULIP_STS_LINKFAIL
- ? TULIP_MEDIAPOLL_LINKFAIL
- : TULIP_MEDIAPOLL_LINKPASS);
- csr &= ~TULIP_STS_ABNRMLINTR;
- }
- tulip_media_print(sc);
- }
- if (csr & (TULIP_STS_RXINTR|TULIP_STS_RXNOBUF)) {
- u_int32_t misses = TULIP_CSR_READ(sc, csr_missed_frames);
- if (csr & TULIP_STS_RXNOBUF)
- sc->tulip_dot3stats.dot3StatsMissedFrames += misses & 0xFFFF;
- /*
- * Pass 2.[012] of the 21140A-A[CDE] may hang and/or corrupt data
- * on receive overflows.
- */
- if ((misses & 0x0FFE0000) && (sc->tulip_features & TULIP_HAVE_RXBADOVRFLW)) {
- sc->tulip_dot3stats.dot3StatsInternalMacReceiveErrors++;
- /*
- * Stop the receiver process and spin until it's stopped.
- * Tell rx_intr to drop the packets it dequeues.
- */
- TULIP_CSR_WRITE(sc, csr_command, sc->tulip_cmdmode & ~TULIP_CMD_RXRUN);
- while ((TULIP_CSR_READ(sc, csr_status) & TULIP_STS_RXSTOPPED) == 0)
- ;
- TULIP_CSR_WRITE(sc, csr_status, TULIP_STS_RXSTOPPED);
- sc->tulip_flags |= TULIP_RXIGNORE;
- }
- tulip_rx_intr(sc);
- if (sc->tulip_flags & TULIP_RXIGNORE) {
- /*
- * Restart the receiver.
- */
- sc->tulip_flags &= ~TULIP_RXIGNORE;
- TULIP_CSR_WRITE(sc, csr_command, sc->tulip_cmdmode);
- }
- }
- if (csr & TULIP_STS_ABNRMLINTR) {
- u_int32_t tmp = csr & sc->tulip_intrmask
- & ~(TULIP_STS_NORMALINTR|TULIP_STS_ABNRMLINTR);
- if (csr & TULIP_STS_TXUNDERFLOW) {
- if ((sc->tulip_cmdmode & TULIP_CMD_THRESHOLDCTL) != TULIP_CMD_THRSHLD160) {
- sc->tulip_cmdmode += TULIP_CMD_THRSHLD96;
- sc->tulip_flags |= TULIP_NEWTXTHRESH;
- } else if (sc->tulip_features & TULIP_HAVE_STOREFWD) {
- sc->tulip_cmdmode |= TULIP_CMD_STOREFWD;
- sc->tulip_flags |= TULIP_NEWTXTHRESH;
- }
- }
- if (sc->tulip_flags & TULIP_NOMESSAGES) {
- sc->tulip_statusbits |= tmp;
- } else {
- tulip_print_abnormal_interrupt(sc, tmp);
- sc->tulip_flags |= TULIP_NOMESSAGES;
- }
- TULIP_CSR_WRITE(sc, csr_command, sc->tulip_cmdmode);
- }
- if (sc->tulip_flags & (TULIP_WANTTXSTART|TULIP_TXPROBE_ACTIVE|TULIP_DOINGSETUP|TULIP_PROMISC)) {
- tulip_tx_intr(sc);
- if ((sc->tulip_flags & TULIP_TXPROBE_ACTIVE) == 0)
- tulip_ifstart(&sc->tulip_if);
- }
- }
- if (sc->tulip_flags & TULIP_NEEDRESET) {
- tulip_reset(sc);
- tulip_init(sc);
- }
- TULIP_PERFEND(intr);
-}
-
-#if defined(TULIP_USE_SOFTINTR)
-/*
- * This is a experimental idea to alleviate problems due to interrupt
- * livelock. What is interrupt livelock? It's when you spend all your
- * time servicing device interrupts and never drop below device ipl
- * to do "useful" work.
- *
- * So what we do here is see if the device needs service and if so,
- * disable interrupts (dismiss the interrupt), place it in a list of devices
- * needing service, and issue a network software interrupt.
- *
- * When our network software interrupt routine gets called, we simply
- * walk done the list of devices that we have created and deal with them
- * at splnet/splsoftnet.
- *
- */
-static void
-tulip_hardintr_handler(
- tulip_softc_t * const sc,
- int *progress_p)
-{
- if (TULIP_CSR_READ(sc, csr_status) & (TULIP_STS_NORMALINTR|TULIP_STS_ABNRMLINTR) == 0)
- return;
- *progress_p = 1;
- /*
- * disable interrupts
- */
- TULIP_CSR_WRITE(sc, csr_intr, 0);
- /*
- * mark it as needing a software interrupt
- */
- tulip_softintr_mask |= (1U << sc->tulip_unit);
-}
-
-static void
-tulip_softintr(
- void)
-{
- u_int32_t softintr_mask, mask;
- int progress = 0;
- int unit;
- int s;
-
- /*
- * Copy mask to local copy and reset global one to 0.
- */
- s = splimp();
- softintr_mask = tulip_softintr_mask;
- tulip_softintr_mask = 0;
- splx(s);
-
- /*
- * Optimize for the single unit case.
- */
- if (tulip_softintr_max_unit == 0) {
- if (softintr_mask & 1) {
- tulip_softc_t * const sc = tulips[0];
- /*
- * Handle the "interrupt" and then reenable interrupts
- */
- softintr_mask = 0;
- tulip_intr_handler(sc, &progress);
- TULIP_CSR_WRITE(sc, csr_intr, sc->tulip_intrmask);
- }
- return;
- }
-
- /*
- * Handle all "queued" interrupts in a round robin fashion.
- * This is done so as not to favor a particular interface.
- */
- unit = tulip_softintr_last_unit;
- mask = (1U << unit);
- while (softintr_mask != 0) {
- if (tulip_softintr_max_unit == unit) {
- unit = 0; mask = 1;
- } else {
- unit += 1; mask <<= 1;
- }
- if (softintr_mask & mask) {
- tulip_softc_t * const sc = tulips[unit];
- /*
- * Handle the "interrupt" and then reenable interrupts
- */
- softintr_mask ^= mask;
- tulip_intr_handler(sc, &progress);
- TULIP_CSR_WRITE(sc, csr_intr, sc->tulip_intrmask);
- }
- }
-
- /*
- * Save where we ending up.
- */
- tulip_softintr_last_unit = unit;
-}
-#endif /* TULIP_USE_SOFTINTR */
-
-static void
-tulip_intr_shared(
- void *arg)
-{
- tulip_softc_t * sc = arg;
- int progress = 0;
-
- for (; sc != NULL; sc = sc->tulip_slaves) {
-#if defined(TULIP_DEBUG)
- sc->tulip_dbg.dbg_intrs++;
-#endif
-#if defined(TULIP_USE_SOFTINTR)
- tulip_hardintr_handler(sc, &progress);
-#else
- tulip_intr_handler(sc, &progress);
-#endif
- }
-#if defined(TULIP_USE_SOFTINTR)
- if (progress)
- schednetisr(NETISR_DE);
-#endif
-}
-
-static void
-tulip_intr_normal(
- void *arg)
-{
- tulip_softc_t * sc = (tulip_softc_t *) arg;
- int progress = 0;
-
-#if defined(TULIP_DEBUG)
- sc->tulip_dbg.dbg_intrs++;
-#endif
-#if defined(TULIP_USE_SOFTINTR)
- tulip_hardintr_handler(sc, &progress);
- if (progress)
- schednetisr(NETISR_DE);
-#else
- tulip_intr_handler(sc, &progress);
-#endif
-}
-
-static struct mbuf *
-tulip_mbuf_compress(
- struct mbuf *m)
-{
- struct mbuf *m0;
-#if MCLBYTES >= ETHERMTU + 18 && !defined(BIG_PACKET)
- MGETHDR(m0, M_DONTWAIT, MT_DATA);
- if (m0 != NULL) {
- if (m->m_pkthdr.len > MHLEN) {
- MCLGET(m0, M_DONTWAIT);
- if ((m0->m_flags & M_EXT) == 0) {
- m_freem(m);
- m_freem(m0);
- return NULL;
- }
- }
- m_copydata(m, 0, m->m_pkthdr.len, mtod(m0, caddr_t));
- m0->m_pkthdr.len = m0->m_len = m->m_pkthdr.len;
- }
-#else
- int mlen = MHLEN;
- int len = m->m_pkthdr.len;
- struct mbuf **mp = &m0;
-
- while (len > 0) {
- if (mlen == MHLEN) {
- MGETHDR(*mp, M_DONTWAIT, MT_DATA);
- } else {
- MGET(*mp, M_DONTWAIT, MT_DATA);
- }
- if (*mp == NULL) {
- m_freem(m0);
- m0 = NULL;
- break;
- }
- if (len > MLEN) {
- MCLGET(*mp, M_DONTWAIT);
- if (((*mp)->m_flags & M_EXT) == 0) {
- m_freem(m0);
- m0 = NULL;
- break;
- }
- (*mp)->m_len = len <= MCLBYTES ? len : MCLBYTES;
- } else {
- (*mp)->m_len = len <= mlen ? len : mlen;
- }
- m_copydata(m, m->m_pkthdr.len - len,
- (*mp)->m_len, mtod((*mp), caddr_t));
- len -= (*mp)->m_len;
- mp = &(*mp)->m_next;
- mlen = MLEN;
- }
-#endif
- m_freem(m);
- return m0;
-}
-
-static struct mbuf *
-tulip_txput(
- tulip_softc_t * const sc,
- struct mbuf *m)
-{
- TULIP_PERFSTART(txput)
- tulip_ringinfo_t * const ri = &sc->tulip_txinfo;
- tulip_desc_t *eop, *nextout;
- int segcnt, free;
- u_int32_t d_status;
-#if defined(TULIP_BUS_DMA) && !defined(TULIP_BUS_DMA_NOTX)
- bus_dmamap_t map;
- int error;
-#else
- struct mbuf *m0;
-#endif
-
-#if defined(TULIP_DEBUG)
- if ((sc->tulip_cmdmode & TULIP_CMD_TXRUN) == 0) {
- printf("%s%d: txput%s: tx not running\n",
- sc->tulip_name, sc->tulip_unit,
- (sc->tulip_flags & TULIP_TXPROBE_ACTIVE) ? "(probe)" : "");
- sc->tulip_flags |= TULIP_WANTTXSTART;
- sc->tulip_dbg.dbg_txput_finishes[0]++;
- goto finish;
- }
-#endif
-
- /*
- * Now we try to fill in our transmit descriptors. This is
- * a bit reminiscent of going on the Ark two by two
- * since each descriptor for the TULIP can describe
- * two buffers. So we advance through packet filling
- * each of the two entries at a time to to fill each
- * descriptor. Clear the first and last segment bits
- * in each descriptor (actually just clear everything
- * but the end-of-ring or chain bits) to make sure
- * we don't get messed up by previously sent packets.
- *
- * We may fail to put the entire packet on the ring if
- * there is either not enough ring entries free or if the
- * packet has more than MAX_TXSEG segments. In the former
- * case we will just wait for the ring to empty. In the
- * latter case we have to recopy.
- */
-#if !defined(TULIP_BUS_DMA) || defined(TULIP_BUS_DMA_NOTX)
- again:
- m0 = m;
-#endif
- d_status = 0;
- eop = nextout = ri->ri_nextout;
- segcnt = 0;
- free = ri->ri_free;
-
-#if defined(TULIP_BUS_DMA) && !defined(TULIP_BUS_DMA_NOTX)
- /*
- * Reclaim some dma maps from if we are out.
- */
- if (sc->tulip_txmaps_free == 0) {
-#if defined(TULIP_DEBUG)
- sc->tulip_dbg.dbg_no_txmaps++;
-#endif
- free += tulip_tx_intr(sc);
- }
- if (sc->tulip_txmaps_free > 0) {
- map = sc->tulip_txmaps[sc->tulip_txmaps_free-1];
- } else {
- sc->tulip_flags |= TULIP_WANTTXSTART;
-#if defined(TULIP_DEBUG)
- sc->tulip_dbg.dbg_txput_finishes[1]++;
-#endif
- goto finish;
- }
- error = bus_dmamap_load_mbuf(sc->tulip_dmatag, map, m, BUS_DMA_NOWAIT);
- if (error != 0) {
- if (error == EFBIG) {
- /*
- * The packet exceeds the number of transmit buffer
- * entries that we can use for one packet, so we have
- * to recopy it into one mbuf and then try again.
- */
- m = tulip_mbuf_compress(m);
- if (m == NULL) {
-#if defined(TULIP_DEBUG)
- sc->tulip_dbg.dbg_txput_finishes[2]++;
-#endif
- goto finish;
- }
- error = bus_dmamap_load_mbuf(sc->tulip_dmatag, map, m, BUS_DMA_NOWAIT);
- }
- if (error != 0) {
- printf("%s%d: unable to load tx map, "
- "error = %d\n", sc->tulip_name, sc->tulip_unit, error);
-#if defined(TULIP_DEBUG)
- sc->tulip_dbg.dbg_txput_finishes[3]++;
-#endif
- goto finish;
- }
- }
- if ((free -= (map->dm_nsegs + 1) / 2) <= 0
- /*
- * See if there's any unclaimed space in the transmit ring.
- */
- && (free += tulip_tx_intr(sc)) <= 0) {
- /*
- * There's no more room but since nothing
- * has been committed at this point, just
- * show output is active, put back the
- * mbuf and return.
- */
- sc->tulip_flags |= TULIP_WANTTXSTART;
-#if defined(TULIP_DEBUG)
- sc->tulip_dbg.dbg_txput_finishes[4]++;
-#endif
- bus_dmamap_unload(sc->tulip_dmatag, map);
- goto finish;
- }
- for (; map->dm_nsegs - segcnt > 1; segcnt += 2) {
- eop = nextout;
- eop->d_flag &= TULIP_DFLAG_ENDRING|TULIP_DFLAG_CHAIN;
- eop->d_status = d_status;
- eop->d_addr1 = map->dm_segs[segcnt].ds_addr;
- eop->d_length1 = map->dm_segs[segcnt].ds_len;
- eop->d_addr2 = map->dm_segs[segcnt+1].ds_addr;
- eop->d_length2 = map->dm_segs[segcnt+1].ds_len;
- d_status = TULIP_DSTS_OWNER;
- if (++nextout == ri->ri_last)
- nextout = ri->ri_first;
- }
- if (segcnt < map->dm_nsegs) {
- eop = nextout;
- eop->d_flag &= TULIP_DFLAG_ENDRING|TULIP_DFLAG_CHAIN;
- eop->d_status = d_status;
- eop->d_addr1 = map->dm_segs[segcnt].ds_addr;
- eop->d_length1 = map->dm_segs[segcnt].ds_len;
- eop->d_addr2 = 0;
- eop->d_length2 = 0;
- if (++nextout == ri->ri_last)
- nextout = ri->ri_first;
- }
- TULIP_TXMAP_PRESYNC(sc, map);
- M_SETCTX(m, map);
- map = NULL;
- --sc->tulip_txmaps_free; /* commit to using the dmamap */
-
-#else /* !TULIP_BUS_DMA */
-
- do {
- int len = m0->m_len;
- caddr_t addr = mtod(m0, caddr_t);
- unsigned clsize = PAGE_SIZE - (((uintptr_t) addr) & (PAGE_SIZE-1));
-
- while (len > 0) {
- unsigned slen = min(len, clsize);
-#ifdef BIG_PACKET
- int partial = 0;
- if (slen >= 2048)
- slen = 2040, partial = 1;
-#endif
- segcnt++;
- if (segcnt > TULIP_MAX_TXSEG) {
- /*
- * The packet exceeds the number of transmit buffer
- * entries that we can use for one packet, so we have
- * recopy it into one mbuf and then try again.
- */
- m = tulip_mbuf_compress(m);
- if (m == NULL)
- goto finish;
- goto again;
- }
- if (segcnt & 1) {
- if (--free == 0) {
- /*
- * See if there's any unclaimed space in the
- * transmit ring.
- */
- if ((free += tulip_tx_intr(sc)) == 0) {
- /*
- * There's no more room but since nothing
- * has been committed at this point, just
- * show output is active, put back the
- * mbuf and return.
- */
- sc->tulip_flags |= TULIP_WANTTXSTART;
-#if defined(TULIP_DEBUG)
- sc->tulip_dbg.dbg_txput_finishes[1]++;
-#endif
- goto finish;
- }
- }
- eop = nextout;
- if (++nextout == ri->ri_last)
- nextout = ri->ri_first;
- eop->d_flag &= TULIP_DFLAG_ENDRING|TULIP_DFLAG_CHAIN;
- eop->d_status = d_status;
- eop->d_addr1 = TULIP_KVATOPHYS(sc, addr);
- eop->d_length1 = slen;
- } else {
- /*
- * Fill in second half of descriptor
- */
- eop->d_addr2 = TULIP_KVATOPHYS(sc, addr);
- eop->d_length2 = slen;
- }
- d_status = TULIP_DSTS_OWNER;
- len -= slen;
- addr += slen;
-#ifdef BIG_PACKET
- if (partial)
- continue;
-#endif
- clsize = PAGE_SIZE;
- }
- } while ((m0 = m0->m_next) != NULL);
-#endif /* TULIP_BUS_DMA */
-
- /*
- * The descriptors have been filled in. Now get ready
- * to transmit.
- */
- IF_ENQUEUE(&sc->tulip_txq, m);
- m = NULL;
-
- /*
- * Make sure the next descriptor after this packet is owned
- * by us since it may have been set up above if we ran out
- * of room in the ring.
- */
- nextout->d_status = 0;
- TULIP_TXDESC_PRESYNC(sc, nextout, sizeof(u_int32_t));
-
-#if !defined(TULIP_BUS_DMA) || defined(TULIP_BUS_DMA_NOTX)
- /*
- * If we only used the first segment of the last descriptor,
- * make sure the second segment will not be used.
- */
- if (segcnt & 1) {
- eop->d_addr2 = 0;
- eop->d_length2 = 0;
- }
-#endif /* TULIP_BUS_DMA */
-
- /*
- * Mark the last and first segments, indicate we want a transmit
- * complete interrupt, and tell it to transmit!
- */
- eop->d_flag |= TULIP_DFLAG_TxLASTSEG|TULIP_DFLAG_TxWANTINTR;
-
- /*
- * Note that ri->ri_nextout is still the start of the packet
- * and until we set the OWNER bit, we can still back out of
- * everything we have done.
- */
- ri->ri_nextout->d_flag |= TULIP_DFLAG_TxFIRSTSEG;
-#if defined(TULIP_BUS_MAP) && !defined(TULIP_BUS_DMA_NOTX)
- if (eop < ri->ri_nextout) {
- TULIP_TXDESC_PRESYNC(sc, ri->ri_nextout,
- (caddr_t) ri->ri_last - (caddr_t) ri->ri_nextout);
- TULIP_TXDESC_PRESYNC(sc, ri->ri_first,
- (caddr_t) (eop + 1) - (caddr_t) ri->ri_first);
- } else {
- TULIP_TXDESC_PRESYNC(sc, ri->ri_nextout,
- (caddr_t) (eop + 1) - (caddr_t) ri->ri_nextout);
- }
-#endif
- ri->ri_nextout->d_status = TULIP_DSTS_OWNER;
- TULIP_TXDESC_PRESYNC(sc, ri->ri_nextout, sizeof(u_int32_t));
-
- /*
- * This advances the ring for us.
- */
- ri->ri_nextout = nextout;
- ri->ri_free = free;
-
- TULIP_PERFEND(txput);
-
- if (sc->tulip_flags & TULIP_TXPROBE_ACTIVE) {
- TULIP_CSR_WRITE(sc, csr_txpoll, 1);
- sc->tulip_if.if_flags |= IFF_OACTIVE;
- sc->tulip_if.if_start = tulip_ifstart;
- TULIP_PERFEND(txput);
- return NULL;
- }
-
- /*
- * switch back to the single queueing ifstart.
- */
- sc->tulip_flags &= ~TULIP_WANTTXSTART;
- if (sc->tulip_txtimer == 0)
- sc->tulip_txtimer = TULIP_TXTIMER;
-#if defined(TULIP_DEBUG)
- sc->tulip_dbg.dbg_txput_finishes[5]++;
-#endif
-
- /*
- * If we want a txstart, there must be not enough space in the
- * transmit ring. So we want to enable transmit done interrupts
- * so we can immediately reclaim some space. When the transmit
- * interrupt is posted, the interrupt handler will call tx_intr
- * to reclaim space and then txstart (since WANTTXSTART is set).
- * txstart will move the packet into the transmit ring and clear
- * WANTTXSTART thereby causing TXINTR to be cleared.
- */
- finish:
-#if defined(TULIP_DEBUG)
- sc->tulip_dbg.dbg_txput_finishes[6]++;
-#endif
- if (sc->tulip_flags & (TULIP_WANTTXSTART|TULIP_DOINGSETUP)) {
- sc->tulip_if.if_flags |= IFF_OACTIVE;
- sc->tulip_if.if_start = tulip_ifstart;
- if ((sc->tulip_intrmask & TULIP_STS_TXINTR) == 0) {
- sc->tulip_intrmask |= TULIP_STS_TXINTR;
- TULIP_CSR_WRITE(sc, csr_intr, sc->tulip_intrmask);
- }
- } else if ((sc->tulip_flags & TULIP_PROMISC) == 0) {
- if (sc->tulip_intrmask & TULIP_STS_TXINTR) {
- sc->tulip_intrmask &= ~TULIP_STS_TXINTR;
- TULIP_CSR_WRITE(sc, csr_intr, sc->tulip_intrmask);
- }
- }
- TULIP_CSR_WRITE(sc, csr_txpoll, 1);
- TULIP_PERFEND(txput);
- return m;
-}
-
-static void
-tulip_txput_setup(
- tulip_softc_t * const sc)
-{
- tulip_ringinfo_t * const ri = &sc->tulip_txinfo;
- tulip_desc_t *nextout;
-
- /*
- * We will transmit, at most, one setup packet per call to ifstart.
- */
-
-#if defined(TULIP_DEBUG)
- if ((sc->tulip_cmdmode & TULIP_CMD_TXRUN) == 0) {
- printf("%s%d: txput_setup: tx not running\n",
- sc->tulip_name, sc->tulip_unit);
- sc->tulip_flags |= TULIP_WANTTXSTART;
- sc->tulip_if.if_start = tulip_ifstart;
- return;
- }
-#endif
- /*
- * Try to reclaim some free descriptors..
- */
- if (ri->ri_free < 2)
- tulip_tx_intr(sc);
- if ((sc->tulip_flags & TULIP_DOINGSETUP) || ri->ri_free == 1) {
- sc->tulip_flags |= TULIP_WANTTXSTART;
- sc->tulip_if.if_start = tulip_ifstart;
- return;
- }
- bcopy(sc->tulip_setupdata, sc->tulip_setupbuf,
- sizeof(sc->tulip_setupbuf));
- /*
- * Clear WANTSETUP and set DOINGSETUP. Set know that WANTSETUP is
- * set and DOINGSETUP is clear doing an XOR of the two will DTRT.
- */
- sc->tulip_flags ^= TULIP_WANTSETUP|TULIP_DOINGSETUP;
- ri->ri_free--;
- nextout = ri->ri_nextout;
- nextout->d_flag &= TULIP_DFLAG_ENDRING|TULIP_DFLAG_CHAIN;
- nextout->d_flag |= TULIP_DFLAG_TxFIRSTSEG|TULIP_DFLAG_TxLASTSEG
- |TULIP_DFLAG_TxSETUPPKT|TULIP_DFLAG_TxWANTINTR;
- if (sc->tulip_flags & TULIP_WANTHASHPERFECT)
- nextout->d_flag |= TULIP_DFLAG_TxHASHFILT;
- else if (sc->tulip_flags & TULIP_WANTHASHONLY)
- nextout->d_flag |= TULIP_DFLAG_TxHASHFILT|TULIP_DFLAG_TxINVRSFILT;
-
- nextout->d_length2 = 0;
- nextout->d_addr2 = 0;
-#if defined(TULIP_BUS_DMA) && !defined(TULIP_BUS_DMA_NOTX)
- nextout->d_length1 = sc->tulip_setupmap->dm_segs[0].ds_len;
- nextout->d_addr1 = sc->tulip_setupmap->dm_segs[0].ds_addr;
- if (sc->tulip_setupmap->dm_nsegs == 2) {
- nextout->d_length2 = sc->tulip_setupmap->dm_segs[1].ds_len;
- nextout->d_addr2 = sc->tulip_setupmap->dm_segs[1].ds_addr;
- }
- TULIP_TXMAP_PRESYNC(sc, sc->tulip_setupmap);
- TULIP_TXDESC_PRESYNC(sc, nextout, sizeof(*nextout));
-#else
- nextout->d_length1 = sizeof(sc->tulip_setupbuf);
- nextout->d_addr1 = TULIP_KVATOPHYS(sc, sc->tulip_setupbuf);
-#endif
-
- /*
- * Advance the ring for the next transmit packet.
- */
- if (++ri->ri_nextout == ri->ri_last)
- ri->ri_nextout = ri->ri_first;
-
- /*
- * Make sure the next descriptor is owned by us since it
- * may have been set up above if we ran out of room in the
- * ring.
- */
- ri->ri_nextout->d_status = 0;
- TULIP_TXDESC_PRESYNC(sc, ri->ri_nextout, sizeof(u_int32_t));
- nextout->d_status = TULIP_DSTS_OWNER;
- /*
- * Flush the ownwership of the current descriptor
- */
- TULIP_TXDESC_PRESYNC(sc, nextout, sizeof(u_int32_t));
- TULIP_CSR_WRITE(sc, csr_txpoll, 1);
- if ((sc->tulip_intrmask & TULIP_STS_TXINTR) == 0) {
- sc->tulip_intrmask |= TULIP_STS_TXINTR;
- TULIP_CSR_WRITE(sc, csr_intr, sc->tulip_intrmask);
- }
-}
-
-
-/*
- * This routine is entered at splnet() (splsoftnet() on NetBSD)
- * and thereby imposes no problems when TULIP_USE_SOFTINTR is
- * defined or not.
- */
-static int
-tulip_ifioctl(
- struct ifnet * ifp,
- u_long cmd,
- caddr_t data)
-{
- TULIP_PERFSTART(ifioctl)
- tulip_softc_t * const sc = (tulip_softc_t *)ifp->if_softc;
- struct ifaddr *ifa = (struct ifaddr *)data;
- struct ifreq *ifr = (struct ifreq *) data;
- int s;
- int error = 0;
-
-#if defined(TULIP_USE_SOFTINTR)
- s = splnet();
-#else
- s = splimp();
-#endif
- switch (cmd) {
- case SIOCSIFADDR: {
- ifp->if_flags |= IFF_UP;
- switch(ifa->ifa_addr->sa_family) {
-#ifdef INET
- case AF_INET: {
- tulip_init(sc);
- arp_ifinit(&(sc)->tulip_ac, ifa);
- break;
- }
-#endif /* INET */
-
-#ifdef IPX
- case AF_IPX: {
- struct ipx_addr *ina = &(IA_SIPX(ifa)->sipx_addr);
- if (ipx_nullhost(*ina)) {
- ina->x_host = *(union ipx_host *)(sc->tulip_enaddr);
- } else {
- ifp->if_flags &= ~IFF_RUNNING;
- bcopy((caddr_t)ina->x_host.c_host,
- (caddr_t)sc->tulip_enaddr,
- sizeof(sc->tulip_enaddr));
- }
- tulip_init(sc);
- break;
- }
-#endif /* IPX */
-
-#ifdef NS
- /*
- * This magic copied from if_is.c; I don't use XNS,
- * so I have no way of telling if this actually
- * works or not.
- */
- case AF_NS: {
- struct ns_addr *ina = &(IA_SNS(ifa)->sns_addr);
- if (ns_nullhost(*ina)) {
- ina->x_host = *(union ns_host *)(sc->tulip_enaddr);
- } else {
- ifp->if_flags &= ~IFF_RUNNING;
- bcopy((caddr_t)ina->x_host.c_host,
- (caddr_t)sc->tulip_enaddr,
- sizeof(sc->tulip_enaddr));
- }
- tulip_init(sc);
- break;
- }
-#endif /* NS */
-
- default: {
- tulip_init(sc);
- break;
- }
- }
- break;
- }
- case SIOCGIFADDR: {
- bcopy((caddr_t) sc->tulip_enaddr,
- (caddr_t) ((struct sockaddr *)&ifr->ifr_data)->sa_data,
- 6);
- break;
- }
-
- case SIOCSIFFLAGS: {
- tulip_addr_filter(sc); /* reinit multicast filter */
- tulip_init(sc);
- break;
- }
-
- case SIOCSIFMEDIA:
- case SIOCGIFMEDIA: {
- error = ifmedia_ioctl(ifp, ifr, &sc->tulip_ifmedia, cmd);
- break;
- }
-
- case SIOCADDMULTI:
- case SIOCDELMULTI: {
- /*
- * Update multicast listeners
- */
- tulip_addr_filter(sc); /* reset multicast filtering */
- tulip_init(sc);
- error = 0;
- break;
- }
-
- case SIOCSIFMTU:
- /*
- * Set the interface MTU.
- */
- if (ifr->ifr_mtu > ETHERMTU
-#ifdef BIG_PACKET
- && sc->tulip_chipid != TULIP_21140
- && sc->tulip_chipid != TULIP_21140A
- && sc->tulip_chipid != TULIP_21041
-#endif
- ) {
- error = EINVAL;
- break;
- }
- ifp->if_mtu = ifr->ifr_mtu;
-#ifdef BIG_PACKET
- tulip_reset(sc);
- tulip_init(sc);
-#endif
- break;
-
-#ifdef SIOCGADDRROM
- case SIOCGADDRROM: {
- error = copyout(sc->tulip_rombuf, ifr->ifr_data, sizeof(sc->tulip_rombuf));
- break;
- }
-#endif
-#ifdef SIOCGCHIPID
- case SIOCGCHIPID: {
- ifr->ifr_metric = (int) sc->tulip_chipid;
- break;
- }
-#endif
- default: {
- error = EINVAL;
- break;
- }
- }
-
- splx(s);
- TULIP_PERFEND(ifioctl);
- return error;
-}
-
-/*
- * These routines gets called at device spl (from ether_output). This might
- * pose a problem for TULIP_USE_SOFTINTR if ether_output is called at
- * device spl from another driver.
- */
-
-static void
-tulip_ifstart(
- struct ifnet * const ifp)
-{
- TULIP_PERFSTART(ifstart)
- tulip_softc_t * const sc = (tulip_softc_t *)ifp->if_softc;
-
- if (sc->tulip_if.if_flags & IFF_RUNNING) {
-
- if ((sc->tulip_flags & (TULIP_WANTSETUP|TULIP_TXPROBE_ACTIVE)) == TULIP_WANTSETUP)
- tulip_txput_setup(sc);
-
- while (sc->tulip_if.if_snd.ifq_head != NULL) {
- struct mbuf *m;
- IF_DEQUEUE(&sc->tulip_if.if_snd, m);
- if ((m = tulip_txput(sc, m)) != NULL) {
- IF_PREPEND(&sc->tulip_if.if_snd, m);
- break;
- }
- }
- if (sc->tulip_if.if_snd.ifq_head == NULL)
- sc->tulip_if.if_start = tulip_ifstart_one;
- }
-
- TULIP_PERFEND(ifstart);
-}
-
-static void
-tulip_ifstart_one(
- struct ifnet * const ifp)
-{
- TULIP_PERFSTART(ifstart_one)
- tulip_softc_t * const sc = (tulip_softc_t *)ifp->if_softc;
-
- if ((sc->tulip_if.if_flags & IFF_RUNNING)
- && sc->tulip_if.if_snd.ifq_head != NULL) {
- struct mbuf *m;
- IF_DEQUEUE(&sc->tulip_if.if_snd, m);
- if ((m = tulip_txput(sc, m)) != NULL)
- IF_PREPEND(&sc->tulip_if.if_snd, m);
- }
- TULIP_PERFEND(ifstart_one);
-}
-
-/*
- * Even though this routine runs at device spl, it does not break
- * our use of splnet (splsoftnet under NetBSD) for the majority
- * of this driver (if TULIP_USE_SOFTINTR defined) since
- * if_watcbog is called from if_watchdog which is called from
- * splsoftclock which is below spl[soft]net.
- */
-static void
-tulip_ifwatchdog(
- struct ifnet *ifp)
-{
- TULIP_PERFSTART(ifwatchdog)
- tulip_softc_t * const sc = (tulip_softc_t *)ifp->if_softc;
-
-#if defined(TULIP_DEBUG)
- u_int32_t rxintrs = sc->tulip_dbg.dbg_rxintrs - sc->tulip_dbg.dbg_last_rxintrs;
- if (rxintrs > sc->tulip_dbg.dbg_high_rxintrs_hz)
- sc->tulip_dbg.dbg_high_rxintrs_hz = rxintrs;
- sc->tulip_dbg.dbg_last_rxintrs = sc->tulip_dbg.dbg_rxintrs;
-#endif /* TULIP_DEBUG */
-
- sc->tulip_if.if_timer = 1;
- /*
- * These should be rare so do a bulk test up front so we can just skip
- * them if needed.
- */
- if (sc->tulip_flags & (TULIP_SYSTEMERROR|TULIP_RXBUFSLOW|TULIP_NOMESSAGES)) {
- /*
- * If the number of receive buffer is low, try to refill
- */
- if (sc->tulip_flags & TULIP_RXBUFSLOW)
- tulip_rx_intr(sc);
-
- if (sc->tulip_flags & TULIP_SYSTEMERROR) {
- printf("%s%d: %d system errors: last was %s\n",
- sc->tulip_name, sc->tulip_unit, sc->tulip_system_errors,
- tulip_system_errors[sc->tulip_last_system_error]);
- }
- if (sc->tulip_statusbits) {
- tulip_print_abnormal_interrupt(sc, sc->tulip_statusbits);
- sc->tulip_statusbits = 0;
- }
-
- sc->tulip_flags &= ~(TULIP_NOMESSAGES|TULIP_SYSTEMERROR);
- }
-
- if (sc->tulip_txtimer)
- tulip_tx_intr(sc);
- if (sc->tulip_txtimer && --sc->tulip_txtimer == 0) {
- printf("%s%d: transmission timeout\n", sc->tulip_name, sc->tulip_unit);
- if (TULIP_DO_AUTOSENSE(sc)) {
- sc->tulip_media = TULIP_MEDIA_UNKNOWN;
- sc->tulip_probe_state = TULIP_PROBE_INACTIVE;
- sc->tulip_flags &= ~(TULIP_WANTRXACT|TULIP_LINKUP);
- }
- tulip_reset(sc);
- tulip_init(sc);
- }
-
- TULIP_PERFEND(ifwatchdog);
- TULIP_PERFMERGE(sc, perf_intr_cycles);
- TULIP_PERFMERGE(sc, perf_ifstart_cycles);
- TULIP_PERFMERGE(sc, perf_ifioctl_cycles);
- TULIP_PERFMERGE(sc, perf_ifwatchdog_cycles);
- TULIP_PERFMERGE(sc, perf_timeout_cycles);
- TULIP_PERFMERGE(sc, perf_ifstart_one_cycles);
- TULIP_PERFMERGE(sc, perf_txput_cycles);
- TULIP_PERFMERGE(sc, perf_txintr_cycles);
- TULIP_PERFMERGE(sc, perf_rxintr_cycles);
- TULIP_PERFMERGE(sc, perf_rxget_cycles);
- TULIP_PERFMERGE(sc, perf_intr);
- TULIP_PERFMERGE(sc, perf_ifstart);
- TULIP_PERFMERGE(sc, perf_ifioctl);
- TULIP_PERFMERGE(sc, perf_ifwatchdog);
- TULIP_PERFMERGE(sc, perf_timeout);
- TULIP_PERFMERGE(sc, perf_ifstart_one);
- TULIP_PERFMERGE(sc, perf_txput);
- TULIP_PERFMERGE(sc, perf_txintr);
- TULIP_PERFMERGE(sc, perf_rxintr);
- TULIP_PERFMERGE(sc, perf_rxget);
-}
-
-/*
- * All printf's are real as of now!
- */
-#ifdef printf
-#undef printf
-#endif
-
-static void
-tulip_attach(
- tulip_softc_t * const sc)
-{
- struct ifnet * const ifp = &sc->tulip_if;
-
- ifp->if_flags = IFF_BROADCAST|IFF_SIMPLEX|IFF_MULTICAST;
- ifp->if_ioctl = tulip_ifioctl;
- ifp->if_start = tulip_ifstart;
- ifp->if_watchdog = tulip_ifwatchdog;
- ifp->if_timer = 1;
- ifp->if_output = ether_output;
-
- printf("%s%d: %s%s pass %d.%d%s\n",
- sc->tulip_name, sc->tulip_unit,
- sc->tulip_boardid,
- tulip_chipdescs[sc->tulip_chipid],
- (sc->tulip_revinfo & 0xF0) >> 4,
- sc->tulip_revinfo & 0x0F,
- (sc->tulip_features & (TULIP_HAVE_ISVSROM|TULIP_HAVE_OKSROM))
- == TULIP_HAVE_ISVSROM ? " (invalid EESPROM checksum)" : "");
- printf("%s%d: address %6D\n",
- sc->tulip_name, sc->tulip_unit, sc->tulip_enaddr, ":");
-
-#if defined(__alpha__)
- /*
- * In case the SRM console told us about a bogus media,
- * we need to check to be safe.
- */
- if (sc->tulip_mediums[sc->tulip_media] == NULL)
- sc->tulip_media = TULIP_MEDIA_UNKNOWN;
-#endif
-
- (*sc->tulip_boardsw->bd_media_probe)(sc);
- ifmedia_init(&sc->tulip_ifmedia, 0,
- tulip_ifmedia_change,
- tulip_ifmedia_status);
- sc->tulip_flags &= ~TULIP_DEVICEPROBE;
- tulip_ifmedia_add(sc);
-
- tulip_reset(sc);
-
- if_attach(ifp);
- ifp->if_snd.ifq_maxlen = ifqmaxlen;
- ether_ifattach(&(sc)->tulip_if);
-
- bpfattach(&sc->tulip_if, DLT_EN10MB, sizeof(struct ether_header));
-}
-
-#if defined(TULIP_BUS_DMA)
-#if !defined(TULIP_BUS_DMA_NOTX) || !defined(TULIP_BUS_DMA_NORX)
-static int
-tulip_busdma_allocmem(
- tulip_softc_t * const sc,
- size_t size,
- bus_dmamap_t *map_p,
- tulip_desc_t **desc_p)
-{
- bus_dma_segment_t segs[1];
- int nsegs, error;
- error = bus_dmamem_alloc(sc->tulip_dmatag, size, 1, PAGE_SIZE,
- segs, sizeof(segs)/sizeof(segs[0]),
- &nsegs, BUS_DMA_NOWAIT);
- if (error == 0) {
- void *desc;
- error = bus_dmamem_map(sc->tulip_dmatag, segs, nsegs, size,
- (void *) &desc, BUS_DMA_NOWAIT|BUS_DMA_COHERENT);
- if (error == 0) {
- bus_dmamap_t map;
- error = bus_dmamap_create(sc->tulip_dmatag, size, 1, size, 0,
- BUS_DMA_NOWAIT, &map);
- if (error == 0) {
- error = bus_dmamap_load(sc->tulip_dmatag, map, desc,
- size, NULL, BUS_DMA_NOWAIT);
- if (error)
- bus_dmamap_destroy(sc->tulip_dmatag, map);
- else
- *map_p = map;
- }
- if (error)
- bus_dmamem_unmap(sc->tulip_dmatag, desc, size);
- }
- if (error)
- bus_dmamem_free(sc->tulip_dmatag, segs, nsegs);
- else
- *desc_p = desc;
- }
- return error;
-}
-#endif
-
-static int
-tulip_busdma_init(
- tulip_softc_t * const sc)
-{
- int error = 0;
-
-#if !defined(TULIP_BUS_DMA_NOTX)
- /*
- * Allocate dmamap for setup descriptor
- */
- error = bus_dmamap_create(sc->tulip_dmatag, sizeof(sc->tulip_setupbuf), 2,
- sizeof(sc->tulip_setupbuf), 0, BUS_DMA_NOWAIT,
- &sc->tulip_setupmap);
- if (error == 0) {
- error = bus_dmamap_load(sc->tulip_dmatag, sc->tulip_setupmap,
- sc->tulip_setupbuf, sizeof(sc->tulip_setupbuf),
- NULL, BUS_DMA_NOWAIT);
- if (error)
- bus_dmamap_destroy(sc->tulip_dmatag, sc->tulip_setupmap);
- }
- /*
- * Allocate space and dmamap for transmit ring
- */
- if (error == 0) {
- error = tulip_busdma_allocmem(sc, sizeof(tulip_desc_t) * TULIP_TXDESCS,
- &sc->tulip_txdescmap,
- &sc->tulip_txdescs);
- }
-
- /*
- * Allocate dmamaps for each transmit descriptors
- */
- if (error == 0) {
- while (error == 0 && sc->tulip_txmaps_free < TULIP_TXDESCS) {
- bus_dmamap_t map;
- if ((error = TULIP_TXMAP_CREATE(sc, &map)) == 0)
- sc->tulip_txmaps[sc->tulip_txmaps_free++] = map;
- }
- if (error) {
- while (sc->tulip_txmaps_free > 0)
- bus_dmamap_destroy(sc->tulip_dmatag,
- sc->tulip_txmaps[--sc->tulip_txmaps_free]);
- }
- }
-#else
- if (error == 0) {
- sc->tulip_txdescs = (tulip_desc_t *) malloc(TULIP_TXDESCS * sizeof(tulip_desc_t), M_DEVBUF, M_NOWAIT);
- if (sc->tulip_txdescs == NULL)
- error = ENOMEM;
- }
-#endif
-#if !defined(TULIP_BUS_DMA_NORX)
- /*
- * Allocate space and dmamap for receive ring
- */
- if (error == 0) {
- error = tulip_busdma_allocmem(sc, sizeof(tulip_desc_t) * TULIP_RXDESCS,
- &sc->tulip_rxdescmap,
- &sc->tulip_rxdescs);
- }
-
- /*
- * Allocate dmamaps for each receive descriptors
- */
- if (error == 0) {
- while (error == 0 && sc->tulip_rxmaps_free < TULIP_RXDESCS) {
- bus_dmamap_t map;
- if ((error = TULIP_RXMAP_CREATE(sc, &map)) == 0)
- sc->tulip_rxmaps[sc->tulip_rxmaps_free++] = map;
- }
- if (error) {
- while (sc->tulip_rxmaps_free > 0)
- bus_dmamap_destroy(sc->tulip_dmatag,
- sc->tulip_rxmaps[--sc->tulip_rxmaps_free]);
- }
- }
-#else
- if (error == 0) {
- sc->tulip_rxdescs = (tulip_desc_t *) malloc(TULIP_RXDESCS * sizeof(tulip_desc_t), M_DEVBUF, M_NOWAIT);
- if (sc->tulip_rxdescs == NULL)
- error = ENOMEM;
- }
-#endif
- return error;
-}
-#endif /* TULIP_BUS_DMA */
-
-static void
-tulip_initcsrs(
- tulip_softc_t * const sc,
- tulip_csrptr_t csr_base,
- size_t csr_size)
-{
- sc->tulip_csrs.csr_busmode = csr_base + 0 * csr_size;
- sc->tulip_csrs.csr_txpoll = csr_base + 1 * csr_size;
- sc->tulip_csrs.csr_rxpoll = csr_base + 2 * csr_size;
- sc->tulip_csrs.csr_rxlist = csr_base + 3 * csr_size;
- sc->tulip_csrs.csr_txlist = csr_base + 4 * csr_size;
- sc->tulip_csrs.csr_status = csr_base + 5 * csr_size;
- sc->tulip_csrs.csr_command = csr_base + 6 * csr_size;
- sc->tulip_csrs.csr_intr = csr_base + 7 * csr_size;
- sc->tulip_csrs.csr_missed_frames = csr_base + 8 * csr_size;
- sc->tulip_csrs.csr_9 = csr_base + 9 * csr_size;
- sc->tulip_csrs.csr_10 = csr_base + 10 * csr_size;
- sc->tulip_csrs.csr_11 = csr_base + 11 * csr_size;
- sc->tulip_csrs.csr_12 = csr_base + 12 * csr_size;
- sc->tulip_csrs.csr_13 = csr_base + 13 * csr_size;
- sc->tulip_csrs.csr_14 = csr_base + 14 * csr_size;
- sc->tulip_csrs.csr_15 = csr_base + 15 * csr_size;
-}
-
-static void
-tulip_initring(
- tulip_softc_t * const sc,
- tulip_ringinfo_t * const ri,
- tulip_desc_t *descs,
- int ndescs)
-{
- ri->ri_max = ndescs;
- ri->ri_first = descs;
- ri->ri_last = ri->ri_first + ri->ri_max;
- bzero((caddr_t) ri->ri_first, sizeof(ri->ri_first[0]) * ri->ri_max);
- ri->ri_last[-1].d_flag = TULIP_DFLAG_ENDRING;
-}
-
-/*
- * This is the PCI configuration support.
- */
-
-#define PCI_CFID 0x00 /* Configuration ID */
-#define PCI_CFCS 0x04 /* Configurtion Command/Status */
-#define PCI_CFRV 0x08 /* Configuration Revision */
-#define PCI_CFLT 0x0c /* Configuration Latency Timer */
-#define PCI_CBIO 0x10 /* Configuration Base IO Address */
-#define PCI_CBMA 0x14 /* Configuration Base Memory Address */
-#define PCI_CFIT 0x3c /* Configuration Interrupt */
-#define PCI_CFDA 0x40 /* Configuration Driver Area */
-
-static const char*
-tulip_pci_probe(
- pcici_t config_id,
- pcidi_t device_id)
-{
- if (PCI_VENDORID(device_id) != DEC_VENDORID)
- return NULL;
- if (PCI_CHIPID(device_id) == CHIPID_21040)
- return "Digital 21040 Ethernet";
- if (PCI_CHIPID(device_id) == CHIPID_21041)
- return "Digital 21041 Ethernet";
- if (PCI_CHIPID(device_id) == CHIPID_21140) {
- u_int32_t revinfo = pci_conf_read(config_id, PCI_CFRV) & 0xFF;
- if (revinfo >= 0x20)
- return "Digital 21140A Fast Ethernet";
- else
- return "Digital 21140 Fast Ethernet";
- }
- if (PCI_CHIPID(device_id) == CHIPID_21142) {
- u_int32_t revinfo = pci_conf_read(config_id, PCI_CFRV) & 0xFF;
- if (revinfo >= 0x20)
- return "Digital 21143 Fast Ethernet";
- else
- return "Digital 21142 Fast Ethernet";
- }
- return NULL;
-}
-
-static void tulip_pci_attach(pcici_t config_id, int unit);
-static u_long tulip_pci_count;
-
-static struct pci_device dedevice = {
- "de",
- tulip_pci_probe,
- tulip_pci_attach,
- &tulip_pci_count,
-};
-
-COMPAT_PCI_DRIVER(de, dedevice);
-
-static void
-tulip_shutdown(void *arg, int howto)
-{
- tulip_softc_t * const sc = arg;
- TULIP_CSR_WRITE(sc, csr_busmode, TULIP_BUSMODE_SWRESET);
- DELAY(10); /* Wait 10 microseconds (actually 50 PCI cycles but at
- 33MHz that comes to two microseconds but wait a
- bit longer anyways) */
-}
-
-static void
-tulip_pci_attach(pcici_t config_id, int unit)
-{
- tulip_softc_t *sc;
-#if defined(__alpha__)
- tulip_media_t media = TULIP_MEDIA_UNKNOWN;
-#endif
- int retval, idx;
- u_int32_t revinfo, cfdainfo, id, cfcsinfo;
-#if !defined(TULIP_IOMAPPED)
- vm_offset_t pa_csrs;
-#endif
- unsigned csroffset = TULIP_PCI_CSROFFSET;
- unsigned csrsize = TULIP_PCI_CSRSIZE;
- tulip_csrptr_t csr_base;
- tulip_chipid_t chipid = TULIP_CHIPID_UNKNOWN;
-
- if (unit >= TULIP_MAX_DEVICES) {
- printf("de%d", unit);
- printf(": not configured; limit of %d reached or exceeded\n",
- TULIP_MAX_DEVICES);
- return;
- }
-
- revinfo = pci_conf_read(config_id, PCI_CFRV) & 0xFF;
- id = pci_conf_read(config_id, PCI_CFID);
- cfdainfo = pci_conf_read(config_id, PCI_CFDA);
- cfcsinfo = pci_conf_read(config_id, PCI_CFCS);
-
- /* turn busmaster on in case BIOS doesn't set it */
- if(!(cfcsinfo & PCIM_CMD_BUSMASTEREN)) {
- cfcsinfo |= PCIM_CMD_BUSMASTEREN;
- pci_conf_write(config_id, PCI_CFCS, cfcsinfo);
- }
-
- if (PCI_VENDORID(id) == DEC_VENDORID) {
- if (PCI_CHIPID(id) == CHIPID_21040)
- chipid = TULIP_21040;
- else if (PCI_CHIPID(id) == CHIPID_21041)
- chipid = TULIP_21041;
- else if (PCI_CHIPID(id) == CHIPID_21140)
- chipid = (revinfo >= 0x20) ? TULIP_21140A : TULIP_21140;
- else if (PCI_CHIPID(id) == CHIPID_21142)
- chipid = (revinfo >= 0x20) ? TULIP_21143 : TULIP_21142;
- }
- if (chipid == TULIP_CHIPID_UNKNOWN)
- return;
-
- if (chipid == TULIP_21040 && revinfo < 0x20) {
- printf("de%d", unit);
- printf(": not configured; 21040 pass 2.0 required (%d.%d found)\n",
- revinfo >> 4, revinfo & 0x0f);
- return;
- } else if (chipid == TULIP_21140 && revinfo < 0x11) {
- printf("de%d: not configured; 21140 pass 1.1 required (%d.%d found)\n",
- unit, revinfo >> 4, revinfo & 0x0f);
- return;
- }
-
- sc = (tulip_softc_t *) malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT);
- if (sc == NULL)
- return;
- bzero(sc, sizeof(*sc)); /* Zero out the softc*/
-
- sc->tulip_pci_busno = config_id->bus;
- sc->tulip_pci_devno = config_id->slot;
- sc->tulip_chipid = chipid;
- sc->tulip_flags |= TULIP_DEVICEPROBE;
- if (chipid == TULIP_21140 || chipid == TULIP_21140A)
- sc->tulip_features |= TULIP_HAVE_GPR|TULIP_HAVE_STOREFWD;
- if (chipid == TULIP_21140A && revinfo <= 0x22)
- sc->tulip_features |= TULIP_HAVE_RXBADOVRFLW;
- if (chipid == TULIP_21140)
- sc->tulip_features |= TULIP_HAVE_BROKEN_HASH;
- if (chipid != TULIP_21040 && chipid != TULIP_21140)
- sc->tulip_features |= TULIP_HAVE_POWERMGMT;
- if (chipid == TULIP_21041 || chipid == TULIP_21142 || chipid == TULIP_21143) {
- sc->tulip_features |= TULIP_HAVE_DUALSENSE;
- if (chipid != TULIP_21041 || revinfo >= 0x20)
- sc->tulip_features |= TULIP_HAVE_SIANWAY;
- if (chipid != TULIP_21041)
- sc->tulip_features |= TULIP_HAVE_SIAGP|TULIP_HAVE_RXBADOVRFLW|TULIP_HAVE_STOREFWD;
- if (chipid != TULIP_21041 && revinfo >= 0x20)
- sc->tulip_features |= TULIP_HAVE_SIA100;
- }
-
- if (sc->tulip_features & TULIP_HAVE_POWERMGMT
- && (cfdainfo & (TULIP_CFDA_SLEEP|TULIP_CFDA_SNOOZE))) {
- cfdainfo &= ~(TULIP_CFDA_SLEEP|TULIP_CFDA_SNOOZE);
- pci_conf_write(config_id, PCI_CFDA, cfdainfo);
- DELAY(11*1000);
- }
-#if defined(__alpha__)
- /*
- * The Alpha SRM console encodes a console set media in the driver
- * part of the CFDA register. Note that the Multia presents a
- * problem in that its BNC mode is really EXTSIA. So in that case
- * force a probe.
- */
- switch ((cfdainfo >> 8) & 0xff) {
- case 1: media = chipid > TULIP_21040 ? TULIP_MEDIA_AUI : TULIP_MEDIA_AUIBNC; break;
- case 2: media = chipid > TULIP_21040 ? TULIP_MEDIA_BNC : TULIP_MEDIA_UNKNOWN; break;
- case 3: media = TULIP_MEDIA_10BASET; break;
- case 4: media = TULIP_MEDIA_10BASET_FD; break;
- case 5: media = TULIP_MEDIA_100BASETX; break;
- case 6: media = TULIP_MEDIA_100BASETX_FD; break;
- default: media = TULIP_MEDIA_UNKNOWN; break;
- }
-#endif
-
- sc->tulip_unit = unit;
- sc->tulip_name = "de";
- sc->tulip_revinfo = revinfo;
- sc->tulip_if.if_softc = sc;
-#if defined(TULIP_IOMAPPED)
- retval = pci_map_port(config_id, PCI_CBIO, &csr_base);
-#else
- retval = pci_map_mem(config_id, PCI_CBMA, (vm_offset_t *) &csr_base, &pa_csrs);
-#endif
- if (!retval) {
- free((caddr_t) sc, M_DEVBUF);
- return;
- }
- tulips[unit] = sc;
-
- tulip_initcsrs(sc, csr_base + csroffset, csrsize);
-
-#if defined(TULIP_BUS_DMA)
- if ((retval = tulip_busdma_init(sc)) != 0) {
- printf("error initing bus_dma: %d\n", retval);
- return;
- }
-#else
- sc->tulip_rxdescs = (tulip_desc_t *) malloc(sizeof(tulip_desc_t) * TULIP_RXDESCS, M_DEVBUF, M_NOWAIT);
- sc->tulip_txdescs = (tulip_desc_t *) malloc(sizeof(tulip_desc_t) * TULIP_TXDESCS, M_DEVBUF, M_NOWAIT);
- if (sc->tulip_rxdescs == NULL || sc->tulip_txdescs == NULL) {
- printf("malloc failed\n");
- if (sc->tulip_rxdescs)
- free((caddr_t) sc->tulip_rxdescs, M_DEVBUF);
- if (sc->tulip_txdescs)
- free((caddr_t) sc->tulip_txdescs, M_DEVBUF);
- free((caddr_t) sc, M_DEVBUF);
- return;
- }
-#endif
-
- tulip_initring(sc, &sc->tulip_rxinfo, sc->tulip_rxdescs, TULIP_RXDESCS);
- tulip_initring(sc, &sc->tulip_txinfo, sc->tulip_txdescs, TULIP_TXDESCS);
-
- /*
- * Make sure there won't be any interrupts or such...
- */
- TULIP_CSR_WRITE(sc, csr_busmode, TULIP_BUSMODE_SWRESET);
- DELAY(100); /* Wait 10 microseconds (actually 50 PCI cycles but at
- 33MHz that comes to two microseconds but wait a
- bit longer anyways) */
-
- if ((retval = tulip_read_macaddr(sc)) < 0) {
- printf("%s%d", sc->tulip_name, sc->tulip_unit);
- printf(": can't read ENET ROM (why=%d) (", retval);
- for (idx = 0; idx < 32; idx++)
- printf("%02x", sc->tulip_rombuf[idx]);
- printf("\n");
- printf("%s%d: %s%s pass %d.%d\n",
- sc->tulip_name, sc->tulip_unit,
- sc->tulip_boardid, tulip_chipdescs[sc->tulip_chipid],
- (sc->tulip_revinfo & 0xF0) >> 4, sc->tulip_revinfo & 0x0F);
- printf("%s%d: address unknown\n", sc->tulip_name, sc->tulip_unit);
- } else {
- int s;
- void (*intr_rtn)(void *) = tulip_intr_normal;
-
- if (sc->tulip_features & TULIP_HAVE_SHAREDINTR)
- intr_rtn = tulip_intr_shared;
-
- if ((sc->tulip_features & TULIP_HAVE_SLAVEDINTR) == 0) {
- if (!pci_map_int (config_id, intr_rtn, (void*) sc, &net_imask)) {
- printf("%s%d: couldn't map interrupt\n",
- sc->tulip_name, sc->tulip_unit);
- free((caddr_t) sc->tulip_rxdescs, M_DEVBUF);
- free((caddr_t) sc->tulip_txdescs, M_DEVBUF);
- free((caddr_t) sc, M_DEVBUF);
- return;
- }
- }
- EVENTHANDLER_REGISTER(shutdown_post_sync, tulip_shutdown, sc,
- SHUTDOWN_PRI_DEFAULT);
-#if defined(TULIP_USE_SOFTINTR)
- if (sc->tulip_unit > tulip_softintr_max_unit)
- tulip_softintr_max_unit = sc->tulip_unit;
-#endif
-
- s = splimp();
-#if defined(__alpha__)
- sc->tulip_media = media;
-#endif
- tulip_attach(sc);
-#if defined(__alpha__)
- if (sc->tulip_media != TULIP_MEDIA_UNKNOWN)
- tulip_linkup(sc, media);
-#endif
- splx(s);
- }
-}
diff --git a/sys/dev/de/if_devar.h b/sys/dev/de/if_devar.h
deleted file mode 100644
index cd89c5a0b243..000000000000
--- a/sys/dev/de/if_devar.h
+++ /dev/null
@@ -1,942 +0,0 @@
-/* $NetBSD: if_devar.h,v 1.32 1999/04/01 14:55:25 tsubai Exp $ */
-
-/* $FreeBSD$ */
-
-/*-
- * Copyright (c) 1994-1997 Matt Thomas (matt@3am-software.com)
- * 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 withough 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.
- *
- * Id: if_devar.h,v 1.28 1997/07/03 16:55:07 thomas Exp
- */
-
-#if !defined(_DEVAR_H)
-#define _DEVAR_H
-
-#ifdef TULIP_IOMAPPED
-#define TULIP_PCI_CSRSIZE 8
-#define TULIP_PCI_CSROFFSET 0
-
-typedef pci_port_t tulip_csrptr_t;
-
-#define TULIP_CSR_READ(sc, csr) (inl((sc)->tulip_csrs.csr))
-#define TULIP_CSR_WRITE(sc, csr, val) outl((sc)->tulip_csrs.csr, val)
-
-#define TULIP_CSR_READBYTE(sc, csr) (inb((sc)->tulip_csrs.csr))
-#define TULIP_CSR_WRITEBYTE(sc, csr, val) outb((sc)->tulip_csrs.csr, val)
-
-#else /* TULIP_IOMAPPED */
-
-#define TULIP_PCI_CSRSIZE 8
-#define TULIP_PCI_CSROFFSET 0
-
-#if defined(__alpha__)
-
-typedef u_int32_t tulip_csrptr_t;
-
-#define TULIP_CSR_READ(sc, csr) (readl((sc)->tulip_csrs.csr))
-#define TULIP_CSR_WRITE(sc, csr, val) writel((sc)->tulip_csrs.csr, val)
-
-#define TULIP_CSR_READBYTE(sc, csr) (readb((sc)->tulip_csrs.csr))
-#define TULIP_CSR_WRITEBYTE(sc, csr, val) writeb((sc)->tulip_csrs.csr, val)
-
-#else /* __alpha__ */
-
-typedef volatile u_int32_t *tulip_csrptr_t;
-
-/*
- * macros to read and write CSRs. Note that the "0 +" in
- * READ_CSR is to prevent the macro from being an lvalue
- * and WRITE_CSR shouldn't be assigned from.
- */
-#define TULIP_CSR_READ(sc, csr) (0 + *(sc)->tulip_csrs.csr)
-#define TULIP_CSR_WRITE(sc, csr, val) ((void)(*(sc)->tulip_csrs.csr = (val)))
-
-#endif /* __alpha__ */
-
-#endif /* TULIP_IOMAPPED */
-
-/*
- * This structure contains "pointers" for the registers on
- * the various 21x4x chips. CSR0 through CSR8 are common
- * to all chips. After that, it gets messy...
- */
-typedef struct {
- tulip_csrptr_t csr_busmode; /* CSR0 */
- tulip_csrptr_t csr_txpoll; /* CSR1 */
- tulip_csrptr_t csr_rxpoll; /* CSR2 */
- tulip_csrptr_t csr_rxlist; /* CSR3 */
- tulip_csrptr_t csr_txlist; /* CSR4 */
- tulip_csrptr_t csr_status; /* CSR5 */
- tulip_csrptr_t csr_command; /* CSR6 */
- tulip_csrptr_t csr_intr; /* CSR7 */
- tulip_csrptr_t csr_missed_frames; /* CSR8 */
- tulip_csrptr_t csr_9; /* CSR9 */
- tulip_csrptr_t csr_10; /* CSR10 */
- tulip_csrptr_t csr_11; /* CSR11 */
- tulip_csrptr_t csr_12; /* CSR12 */
- tulip_csrptr_t csr_13; /* CSR13 */
- tulip_csrptr_t csr_14; /* CSR14 */
- tulip_csrptr_t csr_15; /* CSR15 */
-} tulip_regfile_t;
-
-#define csr_enetrom csr_9 /* 21040 */
-#define csr_reserved csr_10 /* 21040 */
-#define csr_full_duplex csr_11 /* 21040 */
-#define csr_bootrom csr_10 /* 21041/21140A/?? */
-#define csr_gp csr_12 /* 21140* */
-#define csr_watchdog csr_15 /* 21140* */
-#define csr_gp_timer csr_11 /* 21041/21140* */
-#define csr_srom_mii csr_9 /* 21041/21140* */
-#define csr_sia_status csr_12 /* 2104x */
-#define csr_sia_connectivity csr_13 /* 2104x */
-#define csr_sia_tx_rx csr_14 /* 2104x */
-#define csr_sia_general csr_15 /* 2104x */
-
-/*
- * While 21x4x allows chaining of its descriptors, this driver
- * doesn't take advantage of it. We keep the descriptors in a
- * traditional FIFO ring.
- */
-typedef struct {
- tulip_desc_t *ri_first; /* first entry in ring */
- tulip_desc_t *ri_last; /* one after last entry */
- tulip_desc_t *ri_nextin; /* next to processed by host */
- tulip_desc_t *ri_nextout; /* next to processed by adapter */
- int ri_max;
- int ri_free;
-} tulip_ringinfo_t;
-
-/*
- * The 21040 has a stupid restriction in that the receive
- * buffers must be longword aligned. But since Ethernet
- * headers are not a multiple of longwords in size this forces
- * the data to non-longword aligned. Since IP requires the
- * data to be longword aligned, we need to copy it after it has
- * been DMA'ed in our memory.
- *
- * Since we have to copy it anyways, we might as well as allocate
- * dedicated receive space for the input. This allows to use a
- * small receive buffer size and more ring entries to be able to
- * better keep with a flood of tiny Ethernet packets.
- *
- * The receive space MUST ALWAYS be a multiple of the page size.
- * And the number of receive descriptors multiplied by the size
- * of the receive buffers must equal the recevive space. This
- * is so that we can manipulate the page tables so that even if a
- * packet wraps around the end of the receive space, we can
- * treat it as virtually contiguous.
- *
- * The above used to be true (the stupid restriction is still true)
- * but we gone to directly DMA'ing into MBUFs (unless it's on an
- * architecture which can't handle unaligned accesses) because with
- * 100Mb/s cards the copying is just too much of a hit.
- */
-#if !defined(__i386__) && !defined(__vax__)
-#define TULIP_COPY_RXDATA 1
-#endif
-
-#define TULIP_DATA_PER_DESC 2032
-#define TULIP_TXTIMER 4
-#define TULIP_RXDESCS 48
-#define TULIP_TXDESCS 128
-#define TULIP_RXQ_TARGET 32
-#if TULIP_RXQ_TARGET >= TULIP_RXDESCS
-#error TULIP_RXQ_TARGET must be less than TULIP_RXDESCS
-#endif
-#define TULIP_RX_BUFLEN ((MCLBYTES < 2048 ? MCLBYTES : 2048) - 16)
-
-/*
- * Forward reference to make C happy.
- */
-typedef struct _tulip_softc_t tulip_softc_t;
-
-/*
- * The various controllers support.
- */
-
-typedef enum {
- TULIP_21040,
- TULIP_21041,
- TULIP_21140, TULIP_21140A, TULIP_21142,
- TULIP_21143,
- TULIP_CHIPID_UNKNOWN
-} tulip_chipid_t;
-
-/*
- * Various physical media types supported.
- * BNCAUI is BNC or AUI since on the 21040 you can't really tell
- * which is in use.
- */
-typedef enum {
- TULIP_MEDIA_UNKNOWN,
- TULIP_MEDIA_10BASET,
- TULIP_MEDIA_10BASET_FD,
- TULIP_MEDIA_BNC,
- TULIP_MEDIA_AUI,
- TULIP_MEDIA_EXTSIA,
- TULIP_MEDIA_AUIBNC,
- TULIP_MEDIA_100BASETX,
- TULIP_MEDIA_100BASETX_FD,
- TULIP_MEDIA_100BASET4,
- TULIP_MEDIA_100BASEFX,
- TULIP_MEDIA_100BASEFX_FD,
- TULIP_MEDIA_MAX
-} tulip_media_t;
-
-#define TULIP_BIT(b) (1L << ((int)(b)))
-#define TULIP_FDBIT(m) (1L << ((int)TULIP_MEDIA_ ## m ## _FD))
-#define TULIP_MBIT(m) (1L << ((int)TULIP_MEDIA_ ## m ))
-#define TULIP_IS_MEDIA_FD(m) (TULIP_BIT(m) & \
- (TULIP_FDBIT(10BASET) \
- |TULIP_FDBIT(100BASETX) \
- |TULIP_FDBIT(100BASEFX)))
-#define TULIP_CAN_MEDIA_FD(m) (TULIP_BIT(m) & \
- (TULIP_MBIT(10BASET) \
- |TULIP_MBIT(100BASETX) \
- |TULIP_MBIT(100BASEFX)))
-#define TULIP_FD_MEDIA_OF(m) ((tulip_media_t)((m) + 1))
-#define TULIP_HD_MEDIA_OF(m) ((tulip_media_t)((m) - 1))
-#define TULIP_IS_MEDIA_100MB(m) ((m) >= TULIP_MEDIA_100BASETX)
-#define TULIP_IS_MEDIA_TP(m) ((TULIP_BIT(m) & \
- (TULIP_MBIT(BNC) \
- |TULIP_MBIT(AUI) \
- |TULIP_MBIT(AUIBNC) \
- |TULIP_MBIT(EXTSIA))) == 0)
-
-#define TULIP_SROM_ATTR_MII 0x0100
-#define TULIP_SROM_ATTR_NWAY 0x0200
-#define TULIP_SROM_ATTR_AUTOSENSE 0x0400
-#define TULIP_SROM_ATTR_POWERUP 0x0800
-#define TULIP_SROM_ATTR_NOLINKPASS 0x1000
-
-typedef struct {
- enum {
- TULIP_MEDIAINFO_NONE,
- TULIP_MEDIAINFO_SIA,
- TULIP_MEDIAINFO_GPR,
- TULIP_MEDIAINFO_MII,
- TULIP_MEDIAINFO_RESET,
- TULIP_MEDIAINFO_SYM
- } mi_type;
- union {
- struct {
- u_int16_t sia_connectivity;
- u_int16_t sia_tx_rx;
- u_int16_t sia_general;
- u_int32_t sia_gp_control; /* 21142/21143 */
- u_int32_t sia_gp_data; /* 21142/21143 */
- } un_sia;
- struct {
- u_int32_t gpr_cmdmode;
- u_int32_t gpr_gpcontrol; /* 21142/21143 */
- u_int32_t gpr_gpdata;
- u_int8_t gpr_actmask;
- u_int8_t gpr_actdata;
- u_int gpr_default : 1;
- } un_gpr;
- struct {
- u_int32_t mii_mediamask;
- u_int16_t mii_capabilities;
- u_int16_t mii_advertisement;
- u_int16_t mii_full_duplex;
- u_int16_t mii_tx_threshold;
- u_int16_t mii_interrupt; /* 21142/21143 */
- u_int8_t mii_phyaddr;
- u_int8_t mii_gpr_length;
- u_int8_t mii_gpr_offset;
- u_int8_t mii_reset_length;
- u_int8_t mii_reset_offset;
- u_int32_t mii_phyid;
- } un_mii;
- } mi_un;
-} tulip_media_info_t;
-
-#define mi_sia_connectivity mi_un.un_sia.sia_connectivity
-#define mi_sia_tx_rx mi_un.un_sia.sia_tx_rx
-#define mi_sia_general mi_un.un_sia.sia_general
-#define mi_sia_gp_control mi_un.un_sia.sia_gp_control
-#define mi_sia_gp_data mi_un.un_sia.sia_gp_data
-
-#define mi_gpcontrol mi_un.un_gpr.gpr_gpcontrol
-#define mi_gpdata mi_un.un_gpr.gpr_gpdata
-#define mi_actmask mi_un.un_gpr.gpr_actmask
-#define mi_actdata mi_un.un_gpr.gpr_actdata
-#define mi_default mi_un.un_gpr.gpr_default
-#define mi_cmdmode mi_un.un_gpr.gpr_cmdmode
-
-#define mi_phyaddr mi_un.un_mii.mii_phyaddr
-#define mi_gpr_length mi_un.un_mii.mii_gpr_length
-#define mi_gpr_offset mi_un.un_mii.mii_gpr_offset
-#define mi_reset_length mi_un.un_mii.mii_reset_length
-#define mi_reset_offset mi_un.un_mii.mii_reset_offset
-#define mi_capabilities mi_un.un_mii.mii_capabilities
-#define mi_advertisement mi_un.un_mii.mii_advertisement
-#define mi_full_duplex mi_un.un_mii.mii_full_duplex
-#define mi_tx_threshold mi_un.un_mii.mii_tx_threshold
-#define mi_mediamask mi_un.un_mii.mii_mediamask
-#define mi_mii_interrupt mi_un.un_mii.mii_interrupt
-#define mi_phyid mi_un.un_mii.mii_phyid
-
-#define TULIP_MEDIAINFO_SIA_INIT(sc, mi, chipid, media) do { \
- (mi)->mi_type = TULIP_MEDIAINFO_SIA; \
- sc->tulip_mediums[TULIP_MEDIA_ ## media] = (mi); \
- (mi)->mi_sia_connectivity = TULIP_ ## chipid ## _SIACONN_ ## media; \
- (mi)->mi_sia_tx_rx = TULIP_ ## chipid ## _SIATXRX_ ## media; \
- (mi)->mi_sia_general = TULIP_ ## chipid ## _SIAGEN_ ## media; \
-} while (0)
-
-#define TULIP_MEDIAINFO_ADD_CAPABILITY(sc, mi, media) do { \
- if ((sc)->tulip_mediums[TULIP_MEDIA_ ## media] == NULL \
- && ((mi)->mi_capabilities & PHYSTS_ ## media)) { \
- (sc)->tulip_mediums[TULIP_MEDIA_ ## media] = (mi); \
- (mi)->mi_mediamask |= TULIP_BIT(TULIP_MEDIA_ ## media); \
- } \
-} while (0)
-
-#define TULIP_MII_NOPHY 32
-/*
- * Some boards need to treated specially. The following enumeration
- * identifies the cards with quirks (or those we just want to single
- * out for special merit or scorn).
- */
-typedef enum {
- TULIP_21040_GENERIC, /* Generic 21040 (works with most any board) */
- TULIP_21140_ISV, /* Digital Semicondutor 21140 ISV SROM Format */
- TULIP_21142_ISV, /* Digital Semicondutor 21142 ISV SROM Format */
- TULIP_21143_ISV, /* Digital Semicondutor 21143 ISV SROM Format */
- TULIP_21140_DEC_EB, /* Digital Semicondutor 21140 Evaluation Board */
- TULIP_21140_MII, /* 21140[A] with MII */
- TULIP_21140_DEC_DE500, /* Digital DE500-?? 10/100 */
- TULIP_21140_SMC_9332, /* SMC 9332 */
- TULIP_21140_COGENT_EM100, /* Cogent EM100 100 only */
- TULIP_21140_ZNYX_ZX34X, /* ZNYX ZX342 10/100 */
- TULIP_21140_ASANTE, /* AsanteFast 10/100 */
- TULIP_21140_EN1207, /* Accton EN2107 10/100 BNC */
- TULIP_21041_GENERIC /* Generic 21041 card */
-} tulip_board_t;
-
-typedef enum {
- TULIP_MEDIAPOLL_TIMER, /* 100ms timer fired */
- TULIP_MEDIAPOLL_FASTTIMER, /* <100ms timer fired */
- TULIP_MEDIAPOLL_LINKFAIL, /* called from interrupt routine */
- TULIP_MEDIAPOLL_LINKPASS, /* called from interrupt routine */
- TULIP_MEDIAPOLL_START, /* start a media probe (called from reset) */
- TULIP_MEDIAPOLL_TXPROBE_OK, /* txprobe succeeded */
- TULIP_MEDIAPOLL_TXPROBE_FAILED, /* txprobe failed */
- TULIP_MEDIAPOLL_MAX
-} tulip_mediapoll_event_t;
-
-typedef enum {
- TULIP_LINK_DOWN, /* Link is down */
- TULIP_LINK_UP, /* link is ok */
- TULIP_LINK_UNKNOWN /* we can't tell either way */
-} tulip_link_status_t;
-
-
-/*
- * This data structure is used to abstract out the quirks.
- * media_probe = tries to determine the media type.
- * media_select = enables the current media (or autosenses)
- * media_poll = autosenses media
- * media_preset = 21140, etal requires bit to set before the
- * the software reset; hence pre-set. Should be
- * pre-reset but that's ugly.
- */
-
-typedef struct {
- tulip_board_t bd_type;
- void (*bd_media_probe)(tulip_softc_t * const sc);
- void (*bd_media_select)(tulip_softc_t * const sc);
- void (*bd_media_poll)(tulip_softc_t * const sc, tulip_mediapoll_event_t event);
- void (*bd_media_preset)(tulip_softc_t * const sc);
-} tulip_boardsw_t;
-
-/*
- * The next few declarations are for MII/PHY based board.
- *
- * The first enumeration identifies a superset of various datums
- * that can be obtained from various PHY chips. Not all PHYs will
- * support all datums.
- * The modedata structure indicates what register contains
- * a datum, what mask is applied the register contents, and what the
- * result should be.
- * The attr structure records information about a supported PHY.
- * The phy structure records information about a PHY instance.
- */
-
-typedef enum {
- PHY_MODE_10T,
- PHY_MODE_100TX,
- PHY_MODE_100T4,
- PHY_MODE_FULLDUPLEX,
- PHY_MODE_MAX
-} tulip_phy_mode_t;
-
-typedef struct {
- u_int16_t pm_regno;
- u_int16_t pm_mask;
- u_int16_t pm_value;
-} tulip_phy_modedata_t;
-
-typedef struct {
- u_int32_t attr_id;
- u_int16_t attr_flags;
-#define PHY_NEED_HARD_RESET 0x0001
-#define PHY_DUAL_CYCLE_TA 0x0002
- tulip_phy_modedata_t attr_modes[PHY_MODE_MAX];
-#ifdef TULIP_DEBUG
- const char *attr_name;
-#endif
-} tulip_phy_attr_t;
-
-/*
- * Various probe states used when trying to autosense the media.
- */
-
-typedef enum {
- TULIP_PROBE_INACTIVE,
- TULIP_PROBE_PHYRESET,
- TULIP_PROBE_PHYAUTONEG,
- TULIP_PROBE_GPRTEST,
- TULIP_PROBE_MEDIATEST,
- TULIP_PROBE_FAILED
-} tulip_probe_state_t;
-
-typedef struct {
- /*
- * Transmit Statistics
- */
- u_int32_t dot3StatsSingleCollisionFrames;
- u_int32_t dot3StatsMultipleCollisionFrames;
- u_int32_t dot3StatsSQETestErrors;
- u_int32_t dot3StatsDeferredTransmissions;
- u_int32_t dot3StatsLateCollisions;
- u_int32_t dot3StatsExcessiveCollisions;
- u_int32_t dot3StatsCarrierSenseErrors;
- u_int32_t dot3StatsInternalMacTransmitErrors;
- u_int32_t dot3StatsInternalTransmitUnderflows; /* not in rfc1650! */
- u_int32_t dot3StatsInternalTransmitBabbles; /* not in rfc1650! */
- /*
- * Receive Statistics
- */
- u_int32_t dot3StatsMissedFrames; /* not in rfc1650! */
- u_int32_t dot3StatsAlignmentErrors;
- u_int32_t dot3StatsFCSErrors;
- u_int32_t dot3StatsFrameTooLongs;
- u_int32_t dot3StatsInternalMacReceiveErrors;
-} tulip_dot3_stats_t;
-
-/*
- * Now to important stuff. This is softc structure (where does softc
- * come from??? No idea) for the tulip device.
- */
-struct _tulip_softc_t {
- struct ifmedia tulip_ifmedia;
-#if defined(TULIP_BUS_DMA)
- bus_dma_tag_t tulip_dmatag; /* bus DMA tag */
-#if !defined(TULIP_BUS_DMA_NOTX)
- bus_dmamap_t tulip_setupmap;
- bus_dmamap_t tulip_txdescmap;
- bus_dmamap_t tulip_txmaps[TULIP_TXDESCS];
- unsigned tulip_txmaps_free;
-#endif
-#if !defined(TULIP_BUS_DMA_NORX)
- bus_dmamap_t tulip_rxdescmap;
- bus_dmamap_t tulip_rxmaps[TULIP_RXDESCS];
- unsigned tulip_rxmaps_free;
-#endif
-#endif
- struct arpcom tulip_ac;
- tulip_regfile_t tulip_csrs;
- u_int32_t tulip_flags;
-#define TULIP_WANTSETUP 0x00000001
-#define TULIP_WANTHASHPERFECT 0x00000002
-#define TULIP_WANTHASHONLY 0x00000004
-#define TULIP_DOINGSETUP 0x00000008
-#define TULIP_PRINTMEDIA 0x00000010
-#define TULIP_TXPROBE_ACTIVE 0x00000020
-#define TULIP_ALLMULTI 0x00000040
-#define TULIP_WANTRXACT 0x00000080
-#define TULIP_RXACT 0x00000100
-#define TULIP_INRESET 0x00000200
-#define TULIP_NEEDRESET 0x00000400
-#define TULIP_SQETEST 0x00000800
-#define TULIP_xxxxxx0 0x00001000
-#define TULIP_xxxxxx1 0x00002000
-#define TULIP_WANTTXSTART 0x00004000
-#define TULIP_NEWTXTHRESH 0x00008000
-#define TULIP_NOAUTOSENSE 0x00010000
-#define TULIP_PRINTLINKUP 0x00020000
-#define TULIP_LINKUP 0x00040000
-#define TULIP_RXBUFSLOW 0x00080000
-#define TULIP_NOMESSAGES 0x00100000
-#define TULIP_SYSTEMERROR 0x00200000
-#define TULIP_TIMEOUTPENDING 0x00400000
-#define TULIP_xxxxxx2 0x00800000
-#define TULIP_TRYNWAY 0x01000000
-#define TULIP_DIDNWAY 0x02000000
-#define TULIP_RXIGNORE 0x04000000
-#define TULIP_PROBE1STPASS 0x08000000
-#define TULIP_DEVICEPROBE 0x10000000
-#define TULIP_PROMISC 0x20000000
-#define TULIP_HASHONLY 0x40000000
-#define TULIP_xxxxxx3 0x80000000
- /* only 4 bits left! */
- u_int32_t tulip_features; /* static bits indicating features of chip */
-#define TULIP_HAVE_GPR 0x00000001 /* have gp register (140[A]) */
-#define TULIP_HAVE_RXBADOVRFLW 0x00000002 /* RX corrupts on overflow */
-#define TULIP_HAVE_POWERMGMT 0x00000004 /* Snooze/sleep modes */
-#define TULIP_HAVE_MII 0x00000008 /* Some medium on MII */
-#define TULIP_HAVE_SIANWAY 0x00000010 /* SIA does NWAY */
-#define TULIP_HAVE_DUALSENSE 0x00000020 /* SIA senses both AUI & TP */
-#define TULIP_HAVE_SIAGP 0x00000040 /* SIA has a GP port */
-#define TULIP_HAVE_BROKEN_HASH 0x00000080 /* Broken Multicast Hash */
-#define TULIP_HAVE_ISVSROM 0x00000100 /* uses ISV SROM Format */
-#define TULIP_HAVE_BASEROM 0x00000200 /* Board ROM can be cloned */
-#define TULIP_HAVE_SLAVEDROM 0x00000400 /* Board ROM cloned */
-#define TULIP_HAVE_SLAVEDINTR 0x00000800 /* Board slaved interrupt */
-#define TULIP_HAVE_SHAREDINTR 0x00001000 /* Board shares interrupts */
-#define TULIP_HAVE_OKROM 0x00002000 /* ROM was recognized */
-#define TULIP_HAVE_NOMEDIA 0x00004000 /* did not detect any media */
-#define TULIP_HAVE_STOREFWD 0x00008000 /* have CMD_STOREFWD */
-#define TULIP_HAVE_SIA100 0x00010000 /* has LS100 in SIA status */
-#define TULIP_HAVE_OKSROM 0x00020000 /* SROM CRC is OK */
- u_int32_t tulip_intrmask; /* our copy of csr_intr */
- u_int32_t tulip_cmdmode; /* our copy of csr_cmdmode */
- u_int32_t tulip_last_system_error : 3; /* last system error (only value is TULIP_SYSTEMERROR is also set) */
- u_int32_t tulip_txtimer : 2; /* transmission timer */
- u_int32_t tulip_system_errors; /* number of system errors encountered */
- u_int32_t tulip_statusbits; /* status bits from CSR5 that may need to be printed */
-
- tulip_media_info_t *tulip_mediums[TULIP_MEDIA_MAX]; /* indexes into mediainfo */
- tulip_media_t tulip_media; /* current media type */
- u_int32_t tulip_abilities; /* remote system's abiltities (as defined in IEEE 802.3u) */
-
- u_int8_t tulip_revinfo; /* revision of chip */
- u_int8_t tulip_phyaddr; /* 0..31 -- address of current phy */
- u_int8_t tulip_gpinit; /* active pins on 21140 */
- u_int8_t tulip_gpdata; /* default gpdata for 21140 */
-
- struct {
- u_int8_t probe_count; /* count of probe operations */
- int32_t probe_timeout; /* time in ms of probe timeout */
- tulip_probe_state_t probe_state; /* current media probe state */
- tulip_media_t probe_media; /* current media being probed */
- u_int32_t probe_mediamask; /* medias checked */
- u_int32_t probe_passes; /* times autosense failed */
- u_int32_t probe_txprobes; /* txprobes attempted */
- } tulip_probe;
-#define tulip_probe_count tulip_probe.probe_count
-#define tulip_probe_timeout tulip_probe.probe_timeout
-#define tulip_probe_state tulip_probe.probe_state
-#define tulip_probe_media tulip_probe.probe_media
-#define tulip_probe_mediamask tulip_probe.probe_mediamask
-#define tulip_probe_passes tulip_probe.probe_passes
-
- tulip_chipid_t tulip_chipid; /* type of chip we are using */
- const tulip_boardsw_t *tulip_boardsw; /* board/chip characteristics */
- tulip_softc_t *tulip_slaves; /* slaved devices (ZX3xx) */
-#if defined(TULIP_DEBUG)
- /*
- * Debugging/Statistical information
- */
- struct {
- tulip_media_t dbg_last_media;
- u_int32_t dbg_intrs;
- u_int32_t dbg_media_probes;
- u_int32_t dbg_txprobe_nocarr;
- u_int32_t dbg_txprobe_exccoll;
- u_int32_t dbg_link_downed;
- u_int32_t dbg_link_suspected;
- u_int32_t dbg_link_intrs;
- u_int32_t dbg_link_pollintrs;
- u_int32_t dbg_link_failures;
- u_int32_t dbg_nway_starts;
- u_int32_t dbg_nway_failures;
- u_int16_t dbg_phyregs[32][4];
- u_int32_t dbg_rxlowbufs;
- u_int32_t dbg_rxintrs;
- u_int32_t dbg_last_rxintrs;
- u_int32_t dbg_high_rxintrs_hz;
- u_int32_t dbg_no_txmaps;
- u_int32_t dbg_txput_finishes[8];
- u_int32_t dbg_txprobes_ok[TULIP_MEDIA_MAX];
- u_int32_t dbg_txprobes_failed[TULIP_MEDIA_MAX];
- u_int32_t dbg_events[TULIP_MEDIAPOLL_MAX];
- u_int32_t dbg_rxpktsperintr[TULIP_RXDESCS];
- } tulip_dbg;
-#endif
-#if defined(TULIP_PERFSTATS)
-#define TULIP_PERF_CURRENT 0
-#define TULIP_PERF_PREVIOUS 1
-#define TULIP_PERF_TOTAL 2
-#define TULIP_PERF_MAX 3
- struct tulip_perfstats {
- u_quad_t perf_intr_cycles;
- u_quad_t perf_ifstart_cycles;
- u_quad_t perf_ifstart_one_cycles;
- u_quad_t perf_ifioctl_cycles;
- u_quad_t perf_ifwatchdog_cycles;
- u_quad_t perf_timeout_cycles;
- u_quad_t perf_txput_cycles;
- u_quad_t perf_txintr_cycles;
- u_quad_t perf_rxintr_cycles;
- u_quad_t perf_rxget_cycles;
- unsigned perf_intr;
- unsigned perf_ifstart;
- unsigned perf_ifstart_one;
- unsigned perf_ifioctl;
- unsigned perf_ifwatchdog;
- unsigned perf_timeout;
- unsigned perf_txput;
- unsigned perf_txintr;
- unsigned perf_rxintr;
- unsigned perf_rxget;
- } tulip_perfstats[TULIP_PERF_MAX];
-#define tulip_curperfstats tulip_perfstats[TULIP_PERF_CURRENT]
-#endif
- struct ifqueue tulip_txq;
- struct ifqueue tulip_rxq;
- tulip_dot3_stats_t tulip_dot3stats;
- tulip_ringinfo_t tulip_rxinfo;
- tulip_ringinfo_t tulip_txinfo;
- tulip_media_info_t tulip_mediainfo[10];
- /*
- * The setup buffers for sending the setup frame to the chip.
- * one is the one being sent while the other is the one being
- * filled.
- */
- u_int32_t tulip_setupbuf[192/sizeof(u_int32_t)];
- u_int32_t tulip_setupdata[192/sizeof(u_int32_t)];
- char tulip_boardid[16]; /* buffer for board ID */
- u_int8_t tulip_rombuf[128];
- u_int8_t tulip_pci_busno; /* needed for multiport boards */
- u_int8_t tulip_pci_devno; /* needed for multiport boards */
- u_int8_t tulip_connidx;
- tulip_srom_connection_t tulip_conntype;
- tulip_desc_t *tulip_rxdescs;
- tulip_desc_t *tulip_txdescs;
-};
-
-#define TULIP_DO_AUTOSENSE(sc) (IFM_SUBTYPE((sc)->tulip_ifmedia.ifm_media) == IFM_AUTO)
-
-
-#if defined(TULIP_HDR_DATA)
-static const char * const tulip_chipdescs[] = {
- "21040 [10Mb/s]",
- "21041 [10Mb/s]",
- "21140 [10-100Mb/s]",
- "21140A [10-100Mb/s]",
- "21142 [10-100Mb/s]",
- "21143 [10-100Mb/s]",
-};
-
-static const char * const tulip_mediums[] = {
- "unknown", /* TULIP_MEDIA_UNKNOWN */
- "10baseT", /* TULIP_MEDIA_10BASET */
- "Full Duplex 10baseT", /* TULIP_MEDIA_10BASET_FD */
- "BNC", /* TULIP_MEDIA_BNC */
- "AUI", /* TULIP_MEDIA_AUI */
- "External SIA", /* TULIP_MEDIA_EXTSIA */
- "AUI/BNC", /* TULIP_MEDIA_AUIBNC */
- "100baseTX", /* TULIP_MEDIA_100BASET */
- "Full Duplex 100baseTX", /* TULIP_MEDIA_100BASET_FD */
- "100baseT4", /* TULIP_MEDIA_100BASET4 */
- "100baseFX", /* TULIP_MEDIA_100BASEFX */
- "Full Duplex 100baseFX", /* TULIP_MEDIA_100BASEFX_FD */
-};
-
-static const int tulip_media_to_ifmedia[] = {
- IFM_ETHER | IFM_NONE, /* TULIP_MEDIA_UNKNOWN */
- IFM_ETHER | IFM_10_T, /* TULIP_MEDIA_10BASET */
- IFM_ETHER | IFM_10_T | IFM_FDX, /* TULIP_MEDIA_10BASET_FD */
- IFM_ETHER | IFM_10_2, /* TULIP_MEDIA_BNC */
- IFM_ETHER | IFM_10_5, /* TULIP_MEDIA_AUI */
- IFM_ETHER | IFM_MANUAL, /* TULIP_MEDIA_EXTSIA */
- IFM_ETHER | IFM_10_5, /* TULIP_MEDIA_AUIBNC */
- IFM_ETHER | IFM_100_TX, /* TULIP_MEDIA_100BASET */
- IFM_ETHER | IFM_100_TX | IFM_FDX, /* TULIP_MEDIA_100BASET_FD */
- IFM_ETHER | IFM_100_T4, /* TULIP_MEDIA_100BASET4 */
- IFM_ETHER | IFM_100_FX, /* TULIP_MEDIA_100BASEFX */
- IFM_ETHER | IFM_100_FX | IFM_FDX, /* TULIP_MEDIA_100BASEFX_FD */
-};
-
-static const char * const tulip_system_errors[] = {
- "parity error",
- "master abort",
- "target abort",
- "reserved #3",
- "reserved #4",
- "reserved #5",
- "reserved #6",
- "reserved #7",
-};
-
-static const char * const tulip_status_bits[] = {
- NULL,
- "transmit process stopped",
- NULL,
- "transmit jabber timeout",
-
- NULL,
- "transmit underflow",
- NULL,
- "receive underflow",
-
- "receive process stopped",
- "receive watchdog timeout",
- NULL,
- NULL,
-
- "link failure",
- NULL,
- NULL,
-};
-
-static const struct {
- tulip_srom_connection_t sc_type;
- tulip_media_t sc_media;
- u_int32_t sc_attrs;
-} tulip_srom_conninfo[] = {
- { TULIP_SROM_CONNTYPE_10BASET, TULIP_MEDIA_10BASET },
- { TULIP_SROM_CONNTYPE_BNC, TULIP_MEDIA_BNC },
- { TULIP_SROM_CONNTYPE_AUI, TULIP_MEDIA_AUI },
- { TULIP_SROM_CONNTYPE_100BASETX, TULIP_MEDIA_100BASETX },
- { TULIP_SROM_CONNTYPE_100BASET4, TULIP_MEDIA_100BASET4 },
- { TULIP_SROM_CONNTYPE_100BASEFX, TULIP_MEDIA_100BASEFX },
- { TULIP_SROM_CONNTYPE_MII_10BASET, TULIP_MEDIA_10BASET,
- TULIP_SROM_ATTR_MII },
- { TULIP_SROM_CONNTYPE_MII_100BASETX, TULIP_MEDIA_100BASETX,
- TULIP_SROM_ATTR_MII },
- { TULIP_SROM_CONNTYPE_MII_100BASET4, TULIP_MEDIA_100BASET4,
- TULIP_SROM_ATTR_MII },
- { TULIP_SROM_CONNTYPE_MII_100BASEFX, TULIP_MEDIA_100BASEFX,
- TULIP_SROM_ATTR_MII },
- { TULIP_SROM_CONNTYPE_10BASET_NWAY, TULIP_MEDIA_10BASET,
- TULIP_SROM_ATTR_NWAY },
- { TULIP_SROM_CONNTYPE_10BASET_FD, TULIP_MEDIA_10BASET_FD },
- { TULIP_SROM_CONNTYPE_MII_10BASET_FD, TULIP_MEDIA_10BASET_FD,
- TULIP_SROM_ATTR_MII },
- { TULIP_SROM_CONNTYPE_100BASETX_FD, TULIP_MEDIA_100BASETX_FD },
- { TULIP_SROM_CONNTYPE_MII_100BASETX_FD, TULIP_MEDIA_100BASETX_FD,
- TULIP_SROM_ATTR_MII },
- { TULIP_SROM_CONNTYPE_10BASET_NOLINKPASS, TULIP_MEDIA_10BASET,
- TULIP_SROM_ATTR_NOLINKPASS },
- { TULIP_SROM_CONNTYPE_AUTOSENSE, TULIP_MEDIA_UNKNOWN,
- TULIP_SROM_ATTR_AUTOSENSE },
- { TULIP_SROM_CONNTYPE_AUTOSENSE_POWERUP, TULIP_MEDIA_UNKNOWN,
- TULIP_SROM_ATTR_AUTOSENSE|TULIP_SROM_ATTR_POWERUP },
- { TULIP_SROM_CONNTYPE_AUTOSENSE_NWAY, TULIP_MEDIA_UNKNOWN,
- TULIP_SROM_ATTR_AUTOSENSE|TULIP_SROM_ATTR_NWAY },
- { TULIP_SROM_CONNTYPE_NOT_USED, TULIP_MEDIA_UNKNOWN }
-};
-#define TULIP_SROM_LASTCONNIDX \
- (sizeof(tulip_srom_conninfo)/sizeof(tulip_srom_conninfo[0]) - 1)
-
-static const struct {
- tulip_media_t sm_type;
- tulip_srom_media_t sm_srom_type;
-} tulip_srom_mediums[] = {
- { TULIP_MEDIA_100BASEFX_FD, TULIP_SROM_MEDIA_100BASEFX_FD },
- { TULIP_MEDIA_100BASEFX, TULIP_SROM_MEDIA_100BASEFX },
- { TULIP_MEDIA_100BASET4, TULIP_SROM_MEDIA_100BASET4 },
- { TULIP_MEDIA_100BASETX_FD, TULIP_SROM_MEDIA_100BASETX_FD },
- { TULIP_MEDIA_100BASETX, TULIP_SROM_MEDIA_100BASETX },
- { TULIP_MEDIA_10BASET_FD, TULIP_SROM_MEDIA_10BASET_FD },
- { TULIP_MEDIA_AUI, TULIP_SROM_MEDIA_AUI },
- { TULIP_MEDIA_BNC, TULIP_SROM_MEDIA_BNC },
- { TULIP_MEDIA_10BASET, TULIP_SROM_MEDIA_10BASET },
- { TULIP_MEDIA_UNKNOWN }
-};
-#endif /* TULIP_HDR_DATA */
-
-/*
- * This driver supports a maximum of 32 tulip boards.
- * This should be enough for the forseeable future.
- */
-#define TULIP_MAX_DEVICES 32
-
-#if defined(TULIP_USE_SOFTINTR) && defined(TULIP_HDR_DATA)
-static u_int32_t tulip_softintr_mask;
-static int tulip_softintr_last_unit;
-static int tulip_softintr_max_unit;
-static void tulip_softintr(void);
-#endif
-
-#if defined(TULIP_BUS_DMA) && !defined(TULIP_BUS_DMA_NORX)
-#define TULIP_RXDESC_PRESYNC(sc, di, s) \
- bus_dmamap_sync((sc)->tulip_dmatag, (sc)->tulip_rxdescmap, \
- (caddr_t) di - (caddr_t) (sc)->tulip_rxdescs, \
- (s), BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE)
-#define TULIP_RXDESC_POSTSYNC(sc, di, s) \
- bus_dmamap_sync((sc)->tulip_dmatag, (sc)->tulip_rxdescmap, \
- (caddr_t) di - (caddr_t) (sc)->tulip_rxdescs, \
- (s), BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE)
-#define TULIP_RXMAP_PRESYNC(sc, map) \
- bus_dmamap_sync((sc)->tulip_dmatag, (map), 0, (map)->dm_mapsize, \
- BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE)
-#define TULIP_RXMAP_POSTSYNC(sc, map) \
- bus_dmamap_sync((sc)->tulip_dmatag, (map), 0, (map)->dm_mapsize, \
- BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE)
-#define TULIP_RXMAP_CREATE(sc, mapp) \
- bus_dmamap_create((sc)->tulip_dmatag, TULIP_RX_BUFLEN, 2, \
- TULIP_DATA_PER_DESC, 0, \
- BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW, (mapp))
-#else
-#ifdef __alpha__
-#define TULIP_RXDESC_PRESYNC(sc, di, s) alpha_mb()
-#define TULIP_RXDESC_POSTSYNC(sc, di, s) alpha_mb()
-#define TULIP_RXMAP_PRESYNC(sc, map) alpha_mb()
-#define TULIP_RXMAP_POSTSYNC(sc, map) alpha_mb()
-#else
-#define TULIP_RXDESC_PRESYNC(sc, di, s) do { } while (0)
-#define TULIP_RXDESC_POSTSYNC(sc, di, s) do { } while (0)
-#define TULIP_RXMAP_PRESYNC(sc, map) do { } while (0)
-#define TULIP_RXMAP_POSTSYNC(sc, map) do { } while (0)
-#endif
-#define TULIP_RXMAP_CREATE(sc, mapp) do { } while (0)
-#endif
-
-#if defined(TULIP_BUS_DMA) && !defined(TULIP_BUS_DMA_NOTX)
-#define TULIP_TXDESC_PRESYNC(sc, di, s) \
- bus_dmamap_sync((sc)->tulip_dmatag, (sc)->tulip_txdescmap, \
- (caddr_t) di - (caddr_t) (sc)->tulip_txdescs, \
- (s), BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE)
-#define TULIP_TXDESC_POSTSYNC(sc, di, s) \
- bus_dmamap_sync((sc)->tulip_dmatag, (sc)->tulip_txdescmap, \
- (caddr_t) di - (caddr_t) (sc)->tulip_txdescs, \
- (s), BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE)
-#define TULIP_TXMAP_PRESYNC(sc, map) \
- bus_dmamap_sync((sc)->tulip_dmatag, (map), 0, (map)->dm_mapsize, \
- BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE)
-#define TULIP_TXMAP_POSTSYNC(sc, map) \
- bus_dmamap_sync((sc)->tulip_dmatag, (map), 0, (map)->dm_mapsize, \
- BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE)
-#define TULIP_TXMAP_CREATE(sc, mapp) \
- bus_dmamap_create((sc)->tulip_dmatag, TULIP_DATA_PER_DESC, \
- TULIP_MAX_TXSEG, TULIP_DATA_PER_DESC, \
- 0, BUS_DMA_NOWAIT, (mapp))
-#else
-#ifdef __alpha__
-#define TULIP_TXDESC_PRESYNC(sc, di, s) alpha_mb()
-#define TULIP_TXDESC_POSTSYNC(sc, di, s) alpha_mb()
-#define TULIP_TXMAP_PRESYNC(sc, map) alpha_mb()
-#define TULIP_TXMAP_POSTSYNC(sc, map) alpha_mb()
-#else
-#define TULIP_TXDESC_PRESYNC(sc, di, s) do { } while (0)
-#define TULIP_TXDESC_POSTSYNC(sc, di, s) do { } while (0)
-#define TULIP_TXMAP_PRESYNC(sc, map) do { } while (0)
-#define TULIP_TXMAP_POSTSYNC(sc, map) do { } while (0)
-#endif
-#define TULIP_TXMAP_CREATE(sc, mapp) do { } while (0)
-#endif
-
-#ifdef notyet
-#define SIOCGADDRROM _IOW('i', 240, struct ifreq) /* get 128 bytes of ROM */
-#define SIOCGCHIPID _IOWR('i', 241, struct ifreq) /* get chipid */
-#endif
-
-#if defined(TULIP_HDR_DATA)
-static tulip_softc_t *tulips[TULIP_MAX_DEVICES];
-#endif
-
-#if defined(TULIP_USE_SOFTINTR)
-NETISR_SET(NETISR_DE, tulip_softintr);
-#endif
-
-#define loudprintf if (bootverbose) printf
-
-#ifndef tulip_if
-#define tulip_if tulip_ac.ac_if
-#endif
-#ifndef tulip_unit
-#define tulip_unit tulip_if.if_unit
-#endif
-#define tulip_name tulip_if.if_name
-#ifndef tulip_enaddr
-#define tulip_enaddr tulip_ac.ac_enaddr
-#endif
-
-#if !defined(TULIP_KVATOPHYS) && (!defined(TULIP_BUS_DMA) || defined(TULIP_BUS_DMA_NORX) || defined(TULIP_BUS_DMA_NOTX))
-#if defined(__alpha__)
-/* XXX XXX NEED REAL DMA MAPPING SUPPORT XXX XXX */
-#define vtobus(va) alpha_XXX_dmamap((vm_offset_t)va)
-#else
-#define vtobus(va) vtophys(va)
-#endif
-#define TULIP_KVATOPHYS(sc, va) vtobus(va)
-#endif
-
-#if defined(TULIP_PERFSTATS)
-#define TULIP_PERFMERGE(sc, member) \
- do { (sc)->tulip_perfstats[TULIP_PERF_TOTAL].member \
- += (sc)->tulip_perfstats[TULIP_PERF_CURRENT].member; \
- (sc)->tulip_perfstats[TULIP_PERF_PREVIOUS].member \
- = (sc)->tulip_perfstats[TULIP_PERF_CURRENT].member; \
- (sc)->tulip_perfstats[TULIP_PERF_CURRENT].member = 0; } while (0)
-#define TULIP_PERFSTART(name) const tulip_cycle_t perfstart_ ## name = TULIP_PERFREAD();
-#define TULIP_PERFEND(name) do { \
- (sc)->tulip_curperfstats.perf_ ## name ## _cycles += TULIP_PERFDIFF(perfstart_ ## name, TULIP_PERFREAD()); \
- (sc)->tulip_curperfstats.perf_ ## name ++; \
- } while (0)
-#if defined(__i386__)
-typedef u_quad_t tulip_cycle_t;
-static __inline__ tulip_cycle_t
-TULIP_PERFREAD(
- void)
-{
- tulip_cycle_t x;
- __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x));
- return x;
-}
-#define TULIP_PERFDIFF(s, f) ((f) - (s))
-#elif defined(__alpha__)
-typedef unsigned long tulip_cycle_t;
-static __inline__ tulip_cycle_t
-TULIP_PERFREAD(
- void)
-{
- tulip_cycle_t x;
- __asm__ volatile ("rpcc %0" : "=r" (x));
- return x;
-}
-#define TULIP_PERFDIFF(s, f) ((unsigned int) ((f) - (s)))
-#endif
-#else
-#define TULIP_PERFSTART(name)
-#define TULIP_PERFEND(name) do { } while (0)
-#define TULIP_PERFMERGE(s,n) do { } while (0)
-#endif /* TULIP_PERFSTATS */
-
-#define TULIP_CRC32_POLY 0xEDB88320UL /* CRC-32 Poly -- Little Endian */
-#define TULIP_MAX_TXSEG 30
-
-#define TULIP_ADDREQUAL(a1, a2) \
- (((u_int16_t *)a1)[0] == ((u_int16_t *)a2)[0] \
- && ((u_int16_t *)a1)[1] == ((u_int16_t *)a2)[1] \
- && ((u_int16_t *)a1)[2] == ((u_int16_t *)a2)[2])
-#define TULIP_ADDRBRDCST(a1) \
- (((u_int16_t *)a1)[0] == 0xFFFFU \
- && ((u_int16_t *)a1)[1] == 0xFFFFU \
- && ((u_int16_t *)a1)[2] == 0xFFFFU)
-
-#endif /* !defined(_DEVAR_H) */
diff --git a/sys/dev/dgb/dgb.c b/sys/dev/dgb/dgb.c
deleted file mode 100644
index f054e7baae3f..000000000000
--- a/sys/dev/dgb/dgb.c
+++ /dev/null
@@ -1,2199 +0,0 @@
-/*-
- * dgb.c $FreeBSD$
- *
- * Digiboard driver.
- *
- * Stage 1. "Better than nothing".
- * Stage 2. "Gee, it works!".
- *
- * Based on sio driver by Bruce Evans and on Linux driver by Troy
- * De Jongh <troyd@digibd.com> or <troyd@skypoint.com>
- * which is under GNU General Public License version 2 so this driver
- * is forced to be under GPL 2 too.
- *
- * Written by Serge Babkin,
- * Joint Stock Commercial Bank "Chelindbank"
- * (Chelyabinsk, Russia)
- * babkin@hq.icb.chel.su
- *
- * Assorted hacks to make it more functional and working under 3.0-current.
- * Fixed broken routines to prevent processes hanging on closed (thanks
- * to Bruce for his patience and assistance). Thanks also to Maxim Bolotin
- * <max@run.net> for his patches which did most of the work to get this
- * running under 2.2/3.0-current.
- * Implemented ioctls: TIOCMSDTRWAIT, TIOCMGDTRWAIT, TIOCTIMESTAMP &
- * TIOCDCDTIMESTAMP.
- * Sysctl debug flag is now a bitflag, to filter noise during debugging.
- * David L. Nugent <davidn@blaze.net.au>
- */
-
-#include "opt_compat.h"
-#include "opt_dgb.h"
-
-#include "dgb.h"
-
-/* Helg: i.e.25 times per sec board will be polled */
-#define POLLSPERSEC 25
-/* How many charactes can we write to input tty rawq */
-#define DGB_IBUFSIZE (TTYHOG-100)
-
-/* the overall number of ports controlled by this driver */
-
-#ifndef NDGBPORTS
-# define NDGBPORTS (NDGB*16)
-#endif
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/tty.h>
-#include <sys/proc.h>
-#include <sys/conf.h>
-#include <sys/dkstat.h>
-#include <sys/fcntl.h>
-#include <sys/kernel.h>
-#include <sys/sysctl.h>
-
-#include <machine/clock.h>
-
-#include <vm/vm.h>
-#include <vm/pmap.h>
-
-#include <i386/isa/isa_device.h>
-
-#include <gnu/i386/isa/dgbios.h>
-#include <gnu/i386/isa/dgfep.h>
-
-#define DGB_DEBUG /* Enable debugging info via sysctl */
-#include <gnu/i386/isa/dgreg.h>
-
-#define CALLOUT_MASK 0x80
-#define CONTROL_MASK 0x60
-#define CONTROL_INIT_STATE 0x20
-#define CONTROL_LOCK_STATE 0x40
-#define UNIT_MASK 0x30000
-#define PORT_MASK 0x1F
-#define DEV_TO_UNIT(dev) (MINOR_TO_UNIT(minor(dev)))
-#define MINOR_MAGIC_MASK (CALLOUT_MASK | CONTROL_MASK)
-#define MINOR_TO_UNIT(mynor) (((mynor) & UNIT_MASK)>>16)
-#define MINOR_TO_PORT(mynor) ((mynor) & PORT_MASK)
-
-/* types. XXX - should be elsewhere */
-typedef u_char bool_t; /* boolean */
-
-/* digiboard port structure */
-struct dgb_p {
- bool_t status;
-
- u_char unit; /* board unit number */
- u_char pnum; /* port number */
- u_char omodem; /* FEP output modem status */
- u_char imodem; /* FEP input modem status */
- u_char modemfake; /* Modem values to be forced */
- u_char modem; /* Force values */
- u_char hflow;
- u_char dsr;
- u_char dcd;
- u_char stopc;
- u_char startc;
- u_char stopca;
- u_char startca;
- u_char fepstopc;
- u_char fepstartc;
- u_char fepstopca;
- u_char fepstartca;
- u_char txwin;
- u_char rxwin;
- ushort fepiflag;
- ushort fepcflag;
- ushort fepoflag;
- ushort txbufhead;
- ushort txbufsize;
- ushort rxbufhead;
- ushort rxbufsize;
- int close_delay;
- int count;
- int blocked_open;
- int event;
- int asyncflags;
- u_long statusflags;
- u_char *txptr;
- u_char *rxptr;
- volatile struct board_chan *brdchan;
- struct tty *tty;
-
- bool_t active_out; /* nonzero if the callout device is open */
- u_int wopeners; /* # processes waiting for DCD in open() */
-
- /* Initial state. */
- struct termios it_in; /* should be in struct tty */
- struct termios it_out;
-
- /* Lock state. */
- struct termios lt_in; /* should be in struct tty */
- struct termios lt_out;
-
- bool_t do_timestamp;
- bool_t do_dcd_timestamp;
- struct timeval timestamp;
- struct timeval dcd_timestamp;
-
- /* flags of state, are used in sleep() too */
- u_char closing; /* port is being closed now */
- u_char draining; /* port is being drained now */
- u_char used; /* port is being used now */
- u_char mustdrain; /* data must be waited to drain in dgbparam() */
-};
-
-/* Digiboard per-board structure */
-struct dgb_softc {
- /* struct board_info */
- u_char status; /* status: DISABLED/ENABLED */
- u_char unit; /* unit number */
- u_char type; /* type of card: PCXE, PCXI, PCXEVE */
- u_char altpin; /* do we need alternate pin setting ? */
- int numports; /* number of ports on card */
- int port; /* I/O port */
- u_char *vmem; /* virtual memory address */
- long pmem; /* physical memory address */
- int mem_seg; /* internal memory segment */
- struct dgb_p *ports; /* pointer to array of port descriptors */
- struct tty *ttys; /* pointer to array of TTY structures */
- volatile struct global_data *mailbox;
- };
-
-
-static struct dgb_softc dgb_softc[NDGB];
-static struct dgb_p dgb_ports[NDGBPORTS];
-static struct tty dgb_tty[NDGBPORTS];
-
-/*
- * The public functions in the com module ought to be declared in a com-driver
- * system header.
- */
-
-/* Interrupt handling entry points. */
-static void dgbpoll __P((void *unit_c));
-
-/* Device switch entry points. */
-#define dgbreset noreset
-#define dgbmmap nommap
-#define dgbstrategy nostrategy
-
-static int dgbattach __P((struct isa_device *dev));
-static int dgbprobe __P((struct isa_device *dev));
-
-static void fepcmd(struct dgb_p *port, unsigned cmd, unsigned op1, unsigned op2,
- unsigned ncmds, unsigned bytecmd);
-
-static void dgbstart __P((struct tty *tp));
-static void dgbstop __P((struct tty *tp, int rw));
-static int dgbparam __P((struct tty *tp, struct termios *t));
-static void dgbhardclose __P((struct dgb_p *port));
-static void dgb_drain_or_flush __P((struct dgb_p *port));
-static int dgbdrain __P((struct dgb_p *port));
-static void dgb_pause __P((void *chan));
-static void wakeflush __P((void *p));
-static void disc_optim __P((struct tty *tp, struct termios *t));
-
-
-struct isa_driver dgbdriver = {
- dgbprobe, dgbattach, "dgb",0
-};
-
-static d_open_t dgbopen;
-static d_close_t dgbclose;
-static d_ioctl_t dgbioctl;
-
-#define CDEV_MAJOR 58
-static struct cdevsw dgb_cdevsw = {
- /* open */ dgbopen,
- /* close */ dgbclose,
- /* read */ ttyread,
- /* write */ ttywrite,
- /* ioctl */ dgbioctl,
- /* poll */ ttypoll,
- /* mmap */ nommap,
- /* strategy */ nostrategy,
- /* name */ "dgb",
- /* maj */ CDEV_MAJOR,
- /* dump */ nodump,
- /* psize */ nopsize,
- /* flags */ D_TTY,
- /* bmaj */ -1
-};
-
-static speed_t dgbdefaultrate = TTYDEF_SPEED;
-
-static struct speedtab dgbspeedtab[] = {
- 0, FEP_B0, /* old (sysV-like) Bx codes */
- 50, FEP_B50,
- 75, FEP_B75,
- 110, FEP_B110,
- 134, FEP_B134,
- 150, FEP_B150,
- 200, FEP_B200,
- 300, FEP_B300,
- 600, FEP_B600,
- 1200, FEP_B1200,
- 1800, FEP_B1800,
- 2400, FEP_B2400,
- 4800, FEP_B4800,
- 9600, FEP_B9600,
- 19200, FEP_B19200,
- 38400, FEP_B38400,
- 57600, (FEP_FASTBAUD|FEP_B50), /* B50 & fast baud table */
- 115200, (FEP_FASTBAUD|FEP_B110), /* B100 & fast baud table */
- -1, -1
-};
-
-static struct dbgflagtbl
-{
- tcflag_t in_mask;
- tcflag_t in_val;
- tcflag_t out_val;
-} dgb_cflags[] =
-{
- { PARODD, PARODD, FEP_PARODD },
- { PARENB, PARENB, FEP_PARENB },
- { CSTOPB, CSTOPB, FEP_CSTOPB },
- { CSIZE, CS5, FEP_CS6 },
- { CSIZE, CS6, FEP_CS6 },
- { CSIZE, CS7, FEP_CS7 },
- { CSIZE, CS8, FEP_CS8 },
- { CLOCAL, CLOCAL, FEP_CLOCAL },
- { (tcflag_t)-1 }
-}, dgb_iflags[] =
-{
- { IGNBRK, IGNBRK, FEP_IGNBRK },
- { BRKINT, BRKINT, FEP_BRKINT },
- { IGNPAR, IGNPAR, FEP_IGNPAR },
- { PARMRK, PARMRK, FEP_PARMRK },
- { INPCK, INPCK, FEP_INPCK },
- { ISTRIP, ISTRIP, FEP_ISTRIP },
- { IXON, IXON, FEP_IXON },
- { IXOFF, IXOFF, FEP_IXOFF },
- { IXANY, IXANY, FEP_IXANY },
- { (tcflag_t)-1 }
-}, dgb_flow[] =
-{
- { CRTSCTS, CRTSCTS, CTS|RTS },
- { CRTSCTS, CCTS_OFLOW, CTS },
- { CRTSCTS, CRTS_IFLOW, RTS },
- { (tcflag_t)-1 }
-};
-
-/* xlat bsd termios flags to dgb sys-v style */
-static tcflag_t
-dgbflags(struct dbgflagtbl *tbl, tcflag_t input)
-{
- tcflag_t output = 0;
- int i;
-
- for (i=0; tbl[i].in_mask != (tcflag_t)-1; i++)
- {
- if ((input & tbl[i].in_mask) == tbl[i].in_val)
- output |= tbl[i].out_val;
- }
- return output;
-}
-
-#ifdef DGB_DEBUG
-static int dgbdebug=0;
-SYSCTL_INT(_debug, OID_AUTO, dgb_debug, CTLFLAG_RW, &dgbdebug, 0, "");
-#endif
-
-static __inline int setwin __P((struct dgb_softc *sc, unsigned addr));
-static __inline int setinitwin __P((struct dgb_softc *sc, unsigned addr));
-static __inline void hidewin __P((struct dgb_softc *sc));
-static __inline void towin __P((struct dgb_softc *sc, int win));
-
-/*Helg: to allow recursive dgb...() calls */
-typedef struct
- { /* If we were called and don't want to disturb we need: */
- int port; /* write to this port */
- u_char data; /* this data on exit */
- /* or DATA_WINOFF to close memory window on entry */
- } BoardMemWinState; /* so several channels and even boards can coexist */
-#define DATA_WINOFF 0
-static BoardMemWinState bmws;
-
-/* return current memory window state and close window */
-static BoardMemWinState
-bmws_get(void)
-{
- BoardMemWinState bmwsRet=bmws;
- if(bmws.data!=DATA_WINOFF)
- outb(bmws.port, bmws.data=DATA_WINOFF);
- return bmwsRet;
-}
-
-/* restore memory window state */
-static void
-bmws_set(BoardMemWinState ws)
-{
- if(ws.data != bmws.data || ws.port!=bmws.port ) {
- if(bmws.data!=DATA_WINOFF)
- outb(bmws.port,DATA_WINOFF);
- if(ws.data!=DATA_WINOFF)
- outb(ws.port, ws.data);
- bmws=ws;
- }
-}
-
-static __inline int
-setwin(sc,addr)
- struct dgb_softc *sc;
- unsigned int addr;
-{
- if(sc->type==PCXEVE) {
- outb(bmws.port=sc->port+1, bmws.data=FEPWIN|(addr>>13));
- DPRINT3(DB_WIN,"dgb%d: switched to window 0x%x\n",sc->unit,addr>>13);
- return (addr & 0x1FFF);
- } else {
- outb(bmws.port=sc->port,bmws.data=FEPMEM);
- return addr;
- }
-}
-
-static __inline int
-setinitwin(sc,addr)
- struct dgb_softc *sc;
- unsigned int addr;
-{
- if(sc->type==PCXEVE) {
- outb(bmws.port=sc->port+1, bmws.data=FEPWIN|(addr>>13));
- DPRINT3(DB_WIN,"dgb%d: switched to window 0x%x\n",sc->unit,addr>>13);
- return (addr & 0x1FFF);
- } else {
- outb(bmws.port=sc->port,bmws.data=inb(sc->port)|FEPMEM);
- return addr;
- }
-}
-
-static __inline void
-hidewin(sc)
- struct dgb_softc *sc;
-{
- bmws.data=0;
- if(sc->type==PCXEVE)
- outb(bmws.port=sc->port+1, bmws.data);
- else
- outb(bmws.port=sc->port, bmws.data);
-}
-
-static __inline void
-towin(sc,win)
- struct dgb_softc *sc;
- int win;
-{
- if(sc->type==PCXEVE) {
- outb(bmws.port=sc->port+1, bmws.data=win);
- } else {
- outb(bmws.port=sc->port,bmws.data=FEPMEM);
- }
-}
-
-static int
-dgbprobe(dev)
- struct isa_device *dev;
-{
- struct dgb_softc *sc= &dgb_softc[dev->id_unit];
- int i, v;
- u_long win_size; /* size of vizible memory window */
- int unit=dev->id_unit;
- static int once;
-
- if (!once++)
- cdevsw_add(&dgb_cdevsw);
- sc->unit=dev->id_unit;
- sc->port=dev->id_iobase;
-
- if(dev->id_flags & DGBFLAG_ALTPIN)
- sc->altpin=1;
- else
- sc->altpin=0;
-
- /* left 24 bits only (ISA address) */
- sc->pmem=((intptr_t)(void *)dev->id_maddr & 0xFFFFFF);
-
- DPRINT4(DB_INFO,"dgb%d: port 0x%x mem 0x%lx\n",unit,sc->port,sc->pmem);
-
- outb(sc->port, FEPRST);
- sc->status=DISABLED;
-
- for(i=0; i< 1000; i++) {
- DELAY(1);
- if( (inb(sc->port) & FEPMASK) == FEPRST ) {
- sc->status=ENABLED;
- DPRINT3(DB_EXCEPT,"dgb%d: got reset after %d us\n",unit,i);
- break;
- }
- }
-
- if(sc->status!=ENABLED) {
- DPRINT2(DB_EXCEPT,"dgb%d: failed to respond\n",dev->id_unit);
- return 0;
- }
-
- /* check type of card and get internal memory characteristics */
-
- v=inb(sc->port);
-
- if( v & 0x1 ) {
- switch( v&0x30 ) {
- case 0:
- sc->mem_seg=0xF000;
- win_size=0x10000;
- printf("dgb%d: PC/Xi 64K\n",dev->id_unit);
- break;
- case 0x10:
- sc->mem_seg=0xE000;
- win_size=0x20000;
- printf("dgb%d: PC/Xi 128K\n",dev->id_unit);
- break;
- case 0x20:
- sc->mem_seg=0xC000;
- win_size=0x40000;
- printf("dgb%d: PC/Xi 256K\n",dev->id_unit);
- break;
- default: /* case 0x30: */
- sc->mem_seg=0x8000;
- win_size=0x80000;
- printf("dgb%d: PC/Xi 512K\n",dev->id_unit);
- break;
- }
- sc->type=PCXI;
- } else {
- outb(sc->port, 1);
- v=inb(sc->port);
-
- if( v & 0x1 ) {
- printf("dgb%d: PC/Xm isn't supported\n",dev->id_unit);
- sc->status=DISABLED;
- return 0;
- }
-
- sc->mem_seg=0xF000;
-
- if(dev->id_flags==DGBFLAG_NOWIN || ( v&0xC0 )==0) {
- win_size=0x10000;
- printf("dgb%d: PC/Xe 64K\n",dev->id_unit);
- sc->type=PCXE;
- } else {
- win_size=0x2000;
- printf("dgb%d: PC/Xe 64/8K (windowed)\n",dev->id_unit);
- sc->type=PCXEVE;
- if((u_long)sc->pmem & ~0xFFE000) {
- printf("dgb%d: warning: address 0x%lx truncated to 0x%lx\n",
- dev->id_unit, sc->pmem,
- sc->pmem & 0xFFE000);
-
- dev->id_maddr= (u_char *)(void *)(intptr_t)( sc->pmem & 0xFFE000 );
- }
- }
- }
-
- /* save size of vizible memory segment */
- dev->id_msize=win_size;
-
- /* map memory */
- dev->id_maddr=sc->vmem=pmap_mapdev(sc->pmem,dev->id_msize);
-
- outb(sc->port, FEPCLR); /* drop RESET */
- hidewin(sc); /* Helg: to set initial bmws state */
-
- return 4; /* we need I/O space of 4 ports */
-}
-
-static int
-dgbattach(dev)
- struct isa_device *dev;
-{
- int unit=dev->id_unit;
- struct dgb_softc *sc= &dgb_softc[dev->id_unit];
- int i, t;
- u_char volatile *mem;
- u_char volatile *ptr;
- int addr;
- struct dgb_p *port;
- volatile struct board_chan *bc;
- int shrinkmem;
- int nfails;
- ushort *pstat;
- int lowwater;
- static int nports=0;
- char suffix;
-
- if(sc->status!=ENABLED) {
- DPRINT2(DB_EXCEPT,"dbg%d: try to attach a disabled card\n",unit);
- return 0;
- }
-
- mem=sc->vmem;
-
- DPRINT3(DB_INFO,"dgb%d: internal memory segment 0x%x\n",unit,sc->mem_seg);
-
- outb(sc->port, FEPRST); DELAY(1);
-
- for(i=0; (inb(sc->port) & FEPMASK) != FEPRST ; i++) {
- if(i>10000) {
- printf("dgb%d: 1st reset failed\n",dev->id_unit);
- sc->status=DISABLED;
- hidewin(sc);
- return 0;
- }
- DELAY(1);
- }
-
- DPRINT3(DB_INFO,"dgb%d: got reset after %d us\n",unit,i);
-
- /* for PCXEVE set up interrupt and base address */
-
- if(sc->type==PCXEVE) {
- t=(((u_long)sc->pmem>>8) & 0xFFE0) | 0x10 /* enable windowing */;
- /* IRQ isn't used */
- outb(sc->port+2,t & 0xFF);
- outb(sc->port+3,t>>8);
- } else if(sc->type==PCXE) {
- t=(((u_long)sc->pmem>>8) & 0xFFE0) /* disable windowing */;
- outb(sc->port+2,t & 0xFF);
- outb(sc->port+3,t>>8);
- }
-
-
- if(sc->type==PCXI || sc->type==PCXE) {
- outb(sc->port, FEPRST|FEPMEM); DELAY(1);
-
- for(i=0; (inb(sc->port) & FEPMASK) != (FEPRST|FEPMEM) ; i++) {
- if(i>10000) {
- printf("dgb%d: 2nd reset failed\n",dev->id_unit);
- sc->status=DISABLED;
- hidewin(sc);
- return 0;
- }
- DELAY(1);
- }
-
- DPRINT3(DB_INFO,"dgb%d: got memory after %d us\n",unit,i);
- }
-
- mem=sc->vmem;
-
- /* very short memory test */
-
- addr=setinitwin(sc,BOTWIN);
- *(u_long volatile *)(mem+addr) = 0xA55A3CC3;
- if(*(u_long volatile *)(mem+addr)!=0xA55A3CC3) {
- printf("dgb%d: 1st memory test failed\n",dev->id_unit);
- sc->status=DISABLED;
- hidewin(sc);
- return 0;
- }
-
- addr=setinitwin(sc,TOPWIN);
- *(u_long volatile *)(mem+addr) = 0x5AA5C33C;
- if(*(u_long volatile *)(mem+addr)!=0x5AA5C33C) {
- printf("dgb%d: 2nd memory test failed\n",dev->id_unit);
- sc->status=DISABLED;
- hidewin(sc);
- return 0;
- }
-
- addr=setinitwin(sc,BIOSCODE+((0xF000-sc->mem_seg)<<4));
- *(u_long volatile *)(mem+addr) = 0x5AA5C33C;
- if(*(u_long volatile *)(mem+addr)!=0x5AA5C33C) {
- printf("dgb%d: 3rd (BIOS) memory test failed\n",dev->id_unit);
- }
-
- addr=setinitwin(sc,MISCGLOBAL);
- for(i=0; i<16; i++) {
- mem[addr+i]=0;
- }
-
- if(sc->type==PCXI || sc->type==PCXE) {
-
- addr=BIOSCODE+((0xF000-sc->mem_seg)<<4);
-
- DPRINT3(DB_INFO,"dgb%d: BIOS local address=0x%x\n",unit,addr);
-
- ptr= mem+addr;
-
- for(i=0; i<pcxx_nbios; i++, ptr++)
- *ptr = pcxx_bios[i];
-
- ptr= mem+addr;
-
- nfails=0;
- for(i=0; i<pcxx_nbios; i++, ptr++)
- if( *ptr != pcxx_bios[i] ) {
- DPRINT5(DB_EXCEPT,"dgb%d: wrong code in BIOS at addr 0x%x : \
-0x%x instead of 0x%x\n", unit, ptr-(mem+addr), *ptr, pcxx_bios[i] );
-
- if(++nfails>=5) {
- printf("dgb%d: 4th memory test (BIOS load) fails\n",unit);
- break;
- }
- }
-
- outb(sc->port,FEPMEM);
-
- for(i=0; (inb(sc->port) & FEPMASK) != FEPMEM ; i++) {
- if(i>10000) {
- printf("dgb%d: BIOS start failed\n",dev->id_unit);
- sc->status=DISABLED;
- hidewin(sc);
- return 0;
- }
- DELAY(1);
- }
-
- DPRINT3(DB_INFO,"dgb%d: reset dropped after %d us\n",unit,i);
-
- for(i=0; i<200000; i++) {
- if( *((ushort volatile *)(mem+MISCGLOBAL)) == *((ushort *)"GD") )
- goto load_fep;
- DELAY(1);
- }
- printf("dgb%d: BIOS download failed\n",dev->id_unit);
- DPRINT4(DB_EXCEPT,"dgb%d: code=0x%x must be 0x%x\n",
- dev->id_unit,
- *((ushort volatile *)(mem+MISCGLOBAL)),
- *((ushort *)"GD"));
-
- sc->status=DISABLED;
- hidewin(sc);
- return 0;
- }
-
- if(sc->type==PCXEVE) {
- /* set window 7 */
- outb(sc->port+1,0xFF);
-
- ptr= mem+(BIOSCODE & 0x1FFF);
-
- for(i=0; i<pcxx_nbios; i++)
- *ptr++ = pcxx_bios[i];
-
- ptr= mem+(BIOSCODE & 0x1FFF);
-
- nfails=0;
- for(i=0; i<pcxx_nbios; i++, ptr++)
- if( *ptr != pcxx_bios[i] ) {
- DPRINT5(DB_EXCEPT,"dgb%d: wrong code in BIOS at addr 0x%x : \
-0x%x instead of 0x%x\n", unit, ptr-(mem+addr), *ptr, pcxx_bios[i] );
-
- if(++nfails>=5) {
- printf("dgb%d: 4th memory test (BIOS load) fails\n",unit);
- break;
- }
- }
-
- outb(sc->port,FEPCLR);
-
- setwin(sc,0);
-
- for(i=0; (inb(sc->port) & FEPMASK) != FEPCLR ; i++) {
- if(i>10000) {
- printf("dgb%d: BIOS start failed\n",dev->id_unit);
- sc->status=DISABLED;
- hidewin(sc);
- return 0;
- }
- DELAY(1);
- }
-
- DPRINT3(DB_INFO,"dgb%d: reset dropped after %d us\n",unit,i);
-
- addr=setwin(sc,MISCGLOBAL);
-
- for(i=0; i<200000; i++) {
- if(*(ushort volatile *)(mem+addr)== *(ushort *)"GD")
- goto load_fep;
- DELAY(1);
- }
- printf("dgb%d: BIOS download failed\n",dev->id_unit);
- DPRINT5(DB_EXCEPT,"dgb%d: Error#(0x%x,0x%x) code=0x%x\n",
- dev->id_unit,
- *(ushort volatile *)(mem+0xC12),
- *(ushort volatile *)(mem+0xC14),
- *(ushort volatile *)(mem+MISCGLOBAL));
-
- sc->status=DISABLED;
- hidewin(sc);
- return 0;
- }
-
-load_fep:
- DPRINT2(DB_INFO,"dgb%d: BIOS loaded\n",dev->id_unit);
-
- addr=setwin(sc,FEPCODE);
-
- ptr= mem+addr;
-
- for(i=0; i<pcxx_ncook; i++)
- *ptr++ = pcxx_cook[i];
-
- addr=setwin(sc,MBOX);
- *(ushort volatile *)(mem+addr+ 0)=2;
- *(ushort volatile *)(mem+addr+ 2)=sc->mem_seg+FEPCODESEG;
- *(ushort volatile *)(mem+addr+ 4)=0;
- *(ushort volatile *)(mem+addr+ 6)=FEPCODESEG;
- *(ushort volatile *)(mem+addr+ 8)=0;
- *(ushort volatile *)(mem+addr+10)=pcxx_ncook;
-
- outb(sc->port,FEPMEM|FEPINT); /* send interrupt to BIOS */
- outb(sc->port,FEPMEM);
-
- for(i=0; *(ushort volatile *)(mem+addr)!=0; i++) {
- if(i>200000) {
- printf("dgb%d: FEP code download failed\n",unit);
- DPRINT3(DB_EXCEPT,"dgb%d: code=0x%x must be 0\n", unit,
- *(ushort volatile *)(mem+addr));
- sc->status=DISABLED;
- hidewin(sc);
- return 0;
- }
- }
-
- DPRINT2(DB_INFO,"dgb%d: FEP code loaded\n",unit);
-
- *(ushort volatile *)(mem+setwin(sc,FEPSTAT))=0;
- addr=setwin(sc,MBOX);
- *(ushort volatile *)(mem+addr+0)=1;
- *(ushort volatile *)(mem+addr+2)=FEPCODESEG;
- *(ushort volatile *)(mem+addr+4)=0x4;
-
- outb(sc->port,FEPINT); /* send interrupt to BIOS */
- outb(sc->port,FEPCLR);
-
- addr=setwin(sc,FEPSTAT);
- for(i=0; *(ushort volatile *)(mem+addr)!= *(ushort *)"OS"; i++) {
- if(i>200000) {
- printf("dgb%d: FEP/OS start failed\n",dev->id_unit);
- sc->status=DISABLED;
- hidewin(sc);
- return 0;
- }
- }
-
- DPRINT2(DB_INFO,"dgb%d: FEP/OS started\n",dev->id_unit);
-
- sc->numports= *(ushort volatile *)(mem+setwin(sc,NPORT));
-
- printf("dgb%d: %d ports\n",unit,sc->numports);
-
- if(sc->numports > MAX_DGB_PORTS) {
- printf("dgb%d: too many ports\n",unit);
- sc->status=DISABLED;
- hidewin(sc);
- return 0;
- }
-
- if(nports+sc->numports>NDGBPORTS) {
- printf("dgb%d: only %d ports are usable\n", unit, NDGBPORTS-nports);
- sc->numports=NDGBPORTS-nports;
- }
-
- /* allocate port and tty structures */
- sc->ports=&dgb_ports[nports];
- sc->ttys=&dgb_tty[nports];
- nports+=sc->numports;
-
- addr=setwin(sc,PORTBASE);
- pstat=(ushort volatile *)(mem+addr);
-
- for(i=0; i<sc->numports && pstat[i]; i++)
- if(pstat[i])
- sc->ports[i].status=ENABLED;
- else {
- sc->ports[i].status=DISABLED;
- printf("dgb%d: port%d is broken\n", unit, i);
- }
-
- /* We should now init per-port structures */
- bc=(volatile struct board_chan *)(mem + CHANSTRUCT);
- sc->mailbox=(volatile struct global_data *)(mem + FEP_GLOBAL);
-
- if(sc->numports<3)
- shrinkmem=1;
- else
- shrinkmem=0;
-
- for(i=0; i<sc->numports; i++, bc++) {
- port= &sc->ports[i];
-
- port->tty=&sc->ttys[i];
- port->unit=unit;
-
- port->brdchan=bc;
-
- if(sc->altpin) {
- port->dsr=CD;
- port->dcd=DSR;
- } else {
- port->dcd=CD;
- port->dsr=DSR;
- }
-
- port->pnum=i;
-
- if(shrinkmem) {
- DPRINT2(DB_INFO,"dgb%d: shrinking memory\n",unit);
- fepcmd(port, SETBUFFER, 32, 0, 0, 0);
- shrinkmem=0;
- }
-
- if(sc->type!=PCXEVE) {
- port->txptr=mem+((bc->tseg-sc->mem_seg)<<4);
- port->rxptr=mem+((bc->rseg-sc->mem_seg)<<4);
- port->txwin=port->rxwin=0;
- } else {
- port->txptr=mem+( ((bc->tseg-sc->mem_seg)<<4) & 0x1FFF );
- port->rxptr=mem+( ((bc->rseg-sc->mem_seg)<<4) & 0x1FFF );
- port->txwin=FEPWIN | ((bc->tseg-sc->mem_seg)>>9);
- port->rxwin=FEPWIN | ((bc->rseg-sc->mem_seg)>>9);
- }
-
- port->txbufhead=0;
- port->rxbufhead=0;
- port->txbufsize=bc->tmax+1;
- port->rxbufsize=bc->rmax+1;
-
- lowwater= (port->txbufsize>=2000) ? 1024 : (port->txbufsize/2);
- setwin(sc,0);
- fepcmd(port, STXLWATER, lowwater, 0, 10, 0);
- fepcmd(port, SRXLWATER, port->rxbufsize/4, 0, 10, 0);
- fepcmd(port, SRXHWATER, 3*port->rxbufsize/4, 0, 10, 0);
-
- bc->edelay=100;
- bc->idata=1;
-
- port->startc=bc->startc;
- port->startca=bc->startca;
- port->stopc=bc->stopc;
- port->stopca=bc->stopca;
-
- /*port->close_delay=50;*/
- port->close_delay=3 * hz;
- port->do_timestamp=0;
- port->do_dcd_timestamp=0;
-
- /*
- * We don't use all the flags from <sys/ttydefaults.h> since they
- * are only relevant for logins. It's important to have echo off
- * initially so that the line doesn't start blathering before the
- * echo flag can be turned off.
- */
- port->it_in.c_iflag = TTYDEF_IFLAG;
- port->it_in.c_oflag = TTYDEF_OFLAG;
- port->it_in.c_cflag = TTYDEF_CFLAG;
- port->it_in.c_lflag = TTYDEF_LFLAG;
- termioschars(&port->it_in);
- port->it_in.c_ispeed = port->it_in.c_ospeed = dgbdefaultrate;
- port->it_out = port->it_in;
- /* MAX_DGB_PORTS is 32 => [0-9a-v] */
- suffix = i < 10 ? '0' + i : 'a' + i - 10;
- make_dev(&dgb_cdevsw, (unit*32)+i,
- UID_ROOT, GID_WHEEL, 0600, "ttyD%d%c", unit, suffix);
-
- make_dev(&dgb_cdevsw, (unit*32)+i+32,
- UID_ROOT, GID_WHEEL, 0600, "ttyiD%d%c", unit, suffix);
-
- make_dev(&dgb_cdevsw, (unit*32)+i+64,
- UID_ROOT, GID_WHEEL, 0600, "ttylD%d%c", unit, suffix);
-
- make_dev(&dgb_cdevsw, (unit*32)+i+128,
- UID_UUCP, GID_DIALER, 0660, "cuaD%d%c", unit, suffix);
-
- make_dev(&dgb_cdevsw, (unit*32)+i+160,
- UID_UUCP, GID_DIALER, 0660, "cuaiD%d%c", unit, suffix);
-
- make_dev(&dgb_cdevsw, (unit*32)+i+192,
- UID_UUCP, GID_DIALER, 0660, "cualD%d%c", unit, suffix);
- }
-
- hidewin(sc);
-
- /* register the polling function */
- timeout(dgbpoll, (void *)unit, hz/POLLSPERSEC);
-
- return 1;
-}
-
-/* ARGSUSED */
-static int
-dgbopen(dev, flag, mode, p)
- dev_t dev;
- int flag;
- int mode;
- struct proc *p;
-{
- struct dgb_softc *sc;
- struct tty *tp;
- int unit;
- int mynor;
- int pnum;
- struct dgb_p *port;
- int s,cs;
- int error;
- volatile struct board_chan *bc;
-
- error=0;
-
- mynor=minor(dev);
- unit=MINOR_TO_UNIT(mynor);
- pnum=MINOR_TO_PORT(mynor);
-
- if(unit >= NDGB) {
- DPRINT2(DB_EXCEPT,"dgb%d: try to open a nonexisting card\n",unit);
- return ENXIO;
- }
-
- sc=&dgb_softc[unit];
-
- if(sc->status!=ENABLED) {
- DPRINT2(DB_EXCEPT,"dgb%d: try to open a disabled card\n",unit);
- return ENXIO;
- }
-
- if(pnum>=sc->numports) {
- DPRINT3(DB_EXCEPT,"dgb%d: try to open non-existing port %d\n",unit,pnum);
- return ENXIO;
- }
-
- if(mynor & CONTROL_MASK)
- return 0;
-
- tp=&sc->ttys[pnum];
- dev->si_tty = tp;
- port=&sc->ports[pnum];
- bc=port->brdchan;
-
-open_top:
-
- s=spltty();
-
- while(port->closing) {
- error=tsleep(&port->closing, TTOPRI|PCATCH, "dgocl", 0);
-
- if(error) {
- DPRINT4(DB_OPEN,"dgb%d: port%d: tsleep(dgocl) error=%d\n",unit,pnum,error);
- goto out;
- }
- }
-
- if (tp->t_state & TS_ISOPEN) {
- /*
- * The device is open, so everything has been initialized.
- * Handle conflicts.
- */
- if (mynor & CALLOUT_MASK) {
- if (!port->active_out) {
- error = EBUSY;
- DPRINT4(DB_OPEN,"dgb%d: port%d: BUSY error=%d\n",unit,pnum,error);
- goto out;
- }
- } else {
- if (port->active_out) {
- if (flag & O_NONBLOCK) {
- error = EBUSY;
- DPRINT4(DB_OPEN,"dgb%d: port%d: BUSY error=%d\n",unit,pnum,error);
- goto out;
- }
- error = tsleep(&port->active_out,
- TTIPRI | PCATCH, "dgbi", 0);
- if (error != 0) {
- DPRINT4(DB_OPEN,"dgb%d: port%d: tsleep(dgbi) error=%d\n",
- unit,pnum,error);
- goto out;
- }
- splx(s);
- goto open_top;
- }
- }
- if (tp->t_state & TS_XCLUDE &&
- suser(p)) {
- error = EBUSY;
- goto out;
- }
- } else {
- /*
- * The device isn't open, so there are no conflicts.
- * Initialize it. Initialization is done twice in many
- * cases: to preempt sleeping callin opens if we are
- * callout, and to complete a callin open after DCD rises.
- */
- tp->t_oproc=dgbstart;
- tp->t_param=dgbparam;
- tp->t_stop=dgbstop;
- tp->t_dev=dev;
- tp->t_termios= (mynor & CALLOUT_MASK) ?
- port->it_out :
- port->it_in;
-
- cs=splclock();
- setwin(sc,0);
- port->imodem=bc->mstat;
- bc->rout=bc->rin; /* clear input queue */
- bc->idata=1;
-#ifdef PRINT_BUFSIZE
- printf("dgb buffers tx=%x:%x rx=%x:%x\n",bc->tseg,bc->tmax,bc->rseg,bc->rmax);
-#endif
-
- hidewin(sc);
- splx(cs);
-
- port->wopeners++;
- error=dgbparam(tp, &tp->t_termios);
- port->wopeners--;
-
- if(error!=0) {
- DPRINT4(DB_OPEN,"dgb%d: port%d: dgbparam error=%d\n",unit,pnum,error);
- goto out;
- }
-
- /* handle fake DCD for callout devices */
- /* and initial DCD */
-
- if( (port->imodem & port->dcd) || mynor & CALLOUT_MASK )
- linesw[tp->t_line].l_modem(tp,1);
-
- }
-
- /*
- * Wait for DCD if necessary.
- */
- if (!(tp->t_state & TS_CARR_ON) && !(mynor & CALLOUT_MASK)
- && !(tp->t_cflag & CLOCAL) && !(flag & O_NONBLOCK)) {
- ++port->wopeners;
- error = tsleep(TSA_CARR_ON(tp), TTIPRI | PCATCH, "dgdcd", 0);
- --port->wopeners;
- if (error != 0) {
- DPRINT4(DB_OPEN,"dgb%d: port%d: tsleep(dgdcd) error=%d\n",unit,pnum,error);
- goto out;
- }
- splx(s);
- goto open_top;
- }
- error = linesw[tp->t_line].l_open(dev, tp);
- disc_optim(tp,&tp->t_termios);
- DPRINT4(DB_OPEN,"dgb%d: port%d: l_open error=%d\n",unit,pnum,error);
-
- if (tp->t_state & TS_ISOPEN && mynor & CALLOUT_MASK)
- port->active_out = TRUE;
-
- port->used=1;
-
- /* If any port is open (i.e. the open() call is completed for it)
- * the device is busy
- */
-
-out:
- disc_optim(tp,&tp->t_termios);
- splx(s);
-
- if( !(tp->t_state & TS_ISOPEN) && port->wopeners==0 )
- dgbhardclose(port);
-
- DPRINT4(DB_OPEN,"dgb%d: port%d: open() returns %d\n",unit,pnum,error);
-
- return error;
-}
-
-/*ARGSUSED*/
-static int
-dgbclose(dev, flag, mode, p)
- dev_t dev;
- int flag;
- int mode;
- struct proc *p;
-{
- int mynor;
- struct tty *tp;
- int unit, pnum;
- struct dgb_softc *sc;
- struct dgb_p *port;
- int s;
- int i;
-
- mynor=minor(dev);
- if(mynor & CONTROL_MASK)
- return 0;
- unit=MINOR_TO_UNIT(mynor);
- pnum=MINOR_TO_PORT(mynor);
-
- sc=&dgb_softc[unit];
- tp=&sc->ttys[pnum];
- port=sc->ports+pnum;
-
- DPRINT3(DB_CLOSE,"dgb%d: port%d: closing\n",unit,pnum);
-
- DPRINT3(DB_CLOSE,"dgb%d: port%d: draining port\n",unit,pnum);
- dgb_drain_or_flush(port);
-
- s=spltty();
-
- port->closing=1;
- DPRINT3(DB_CLOSE,"dgb%d: port%d: closing line disc\n",unit,pnum);
- linesw[tp->t_line].l_close(tp,flag);
- disc_optim(tp,&tp->t_termios);
-
- DPRINT3(DB_CLOSE,"dgb%d: port%d: hard closing\n",unit,pnum);
- dgbhardclose(port);
- DPRINT3(DB_CLOSE,"dgb%d: port%d: closing tty\n",unit,pnum);
- ttyclose(tp);
- port->closing=0;
- wakeup(&port->closing);
- port->used=0;
-
- /* mark the card idle when all ports are closed */
-
- for(i=0; i<sc->numports; i++)
- if(sc->ports[i].used)
- break;
-
- splx(s);
-
- DPRINT3(DB_CLOSE,"dgb%d: port%d: closed\n",unit,pnum);
-
- wakeup(TSA_CARR_ON(tp));
- wakeup(&port->active_out);
- port->active_out=0;
-
- DPRINT3(DB_CLOSE,"dgb%d: port%d: close exit\n",unit,pnum);
-
- return 0;
-}
-
-static void
-dgbhardclose(port)
- struct dgb_p *port;
-{
- struct dgb_softc *sc=&dgb_softc[port->unit];
- volatile struct board_chan *bc=port->brdchan;
- int cs;
-
- cs=splclock();
- port->do_timestamp = 0;
- setwin(sc,0);
-
- bc->idata=0; bc->iempty=0; bc->ilow=0;
- if(port->tty->t_cflag & HUPCL) {
- port->omodem &= ~(RTS|DTR);
- fepcmd(port, SETMODEM, 0, DTR|RTS, 0, 1);
- }
-
- hidewin(sc);
- splx(cs);
-
- timeout(dgb_pause, &port->brdchan, hz/2);
- tsleep(&port->brdchan, TTIPRI | PCATCH, "dgclo", 0);
-}
-
-static void
-dgb_pause(chan)
- void *chan;
-{
- wakeup((caddr_t)chan);
-}
-
-static void
-dgbpoll(unit_c)
- void *unit_c;
-{
- int unit=(int)unit_c;
- int pnum;
- struct dgb_p *port;
- struct dgb_softc *sc=&dgb_softc[unit];
- int head, tail;
- u_char *eventbuf;
- int event, mstat, lstat;
- volatile struct board_chan *bc;
- struct tty *tp;
- int rhead, rtail;
- int whead, wtail;
- int size;
- u_char *ptr;
- int ocount;
- int ibuf_full,obuf_full;
-
- BoardMemWinState ws=bmws_get();
-
- if(sc->status==DISABLED) {
- printf("dgb%d: polling of disabled board stopped\n",unit);
- return;
- }
-
- setwin(sc,0);
-
- head=sc->mailbox->ein;
- tail=sc->mailbox->eout;
-
- while(head!=tail) {
- if(head >= FEP_IMAX-FEP_ISTART
- || tail >= FEP_IMAX-FEP_ISTART
- || (head|tail) & 03 ) {
- printf("dgb%d: event queue's head or tail is wrong! hd=%d,tl=%d\n", unit,head,tail);
- break;
- }
-
- eventbuf=sc->vmem+tail+FEP_ISTART;
- pnum=eventbuf[0];
- event=eventbuf[1];
- mstat=eventbuf[2];
- lstat=eventbuf[3];
-
- port=&sc->ports[pnum];
- bc=port->brdchan;
- tp=&sc->ttys[pnum];
-
- if(pnum>=sc->numports || port->status==DISABLED) {
- printf("dgb%d: port%d: got event on nonexisting port\n",unit,pnum);
- } else if(port->used || port->wopeners>0 ) {
-
- int wrapmask=port->rxbufsize-1;
-
- if( !(event & ALL_IND) )
- printf("dgb%d: port%d: ? event 0x%x mstat 0x%x lstat 0x%x\n",
- unit, pnum, event, mstat, lstat);
-
- if(event & DATA_IND) {
- DPRINT3(DB_DATA,"dgb%d: port%d: DATA_IND\n",unit,pnum);
-
- rhead=bc->rin & wrapmask;
- rtail=bc->rout & wrapmask;
-
- if( !(tp->t_cflag & CREAD) || !port->used ) {
- bc->rout=rhead;
- goto end_of_data;
- }
-
- if(bc->orun) {
- printf("dgb%d: port%d: overrun\n", unit, pnum);
- bc->orun=0;
- }
-
- if(!(tp->t_state & TS_ISOPEN))
- goto end_of_data;
-
- for(ibuf_full=FALSE;rhead!=rtail && !ibuf_full;) {
- DPRINT5(DB_RXDATA,"dgb%d: port%d: p rx head=%d tail=%d\n",
- unit,pnum,rhead,rtail);
-
- if(rhead>rtail)
- size=rhead-rtail;
- else
- size=port->rxbufsize-rtail;
-
- ptr=port->rxptr+rtail;
-
-/* Helg: */
- if( tp->t_rawq.c_cc + size > DGB_IBUFSIZE ) {
- size=DGB_IBUFSIZE-tp->t_rawq.c_cc;
- DPRINT1(DB_RXDATA,"*");
- ibuf_full=TRUE;
- }
-
- if(size) {
- if (tp->t_state & TS_CAN_BYPASS_L_RINT) {
- DPRINT1(DB_RXDATA,"!");
- towin(sc,port->rxwin);
- tk_nin += size;
- tk_rawcc += size;
- tp->t_rawcc += size;
- b_to_q(ptr,size,&tp->t_rawq);
- setwin(sc,0);
- } else {
- int i=size;
- unsigned char chr;
- do {
- towin(sc,port->rxwin);
- chr= *ptr++;
- hidewin(sc);
- (*linesw[tp->t_line].l_rint)(chr, tp);
- } while (--i > 0 );
- setwin(sc,0);
- }
- }
- rtail= (rtail + size) & wrapmask;
- bc->rout=rtail;
- rhead=bc->rin & wrapmask;
- hidewin(sc);
- ttwakeup(tp);
- setwin(sc,0);
- }
- end_of_data: ;
- }
-
- if(event & MODEMCHG_IND) {
- DPRINT3(DB_MODEM,"dgb%d: port%d: MODEMCHG_IND\n",unit,pnum);
- port->imodem=mstat;
- if(mstat & port->dcd) {
- hidewin(sc);
- linesw[tp->t_line].l_modem(tp,1);
- setwin(sc,0);
- wakeup(TSA_CARR_ON(tp));
- } else {
- hidewin(sc);
- linesw[tp->t_line].l_modem(tp,0);
- setwin(sc,0);
- if( port->draining) {
- port->draining=0;
- wakeup(&port->draining);
- }
- }
- }
-
- if(event & BREAK_IND) {
- if((tp->t_state & TS_ISOPEN) && (tp->t_iflag & IGNBRK)) {
- DPRINT3(DB_BREAK,"dgb%d: port%d: BREAK_IND\n",unit,pnum);
- hidewin(sc);
- linesw[tp->t_line].l_rint(TTY_BI, tp);
- setwin(sc,0);
- }
- }
-
-/* Helg: with output flow control */
-
- if(event & (LOWTX_IND | EMPTYTX_IND) ) {
- DPRINT3(DB_TXDATA,"dgb%d: port%d: LOWTX_IND or EMPTYTX_IND\n",unit,pnum);
-
- if( (event & EMPTYTX_IND ) && tp->t_outq.c_cc==0
- && port->draining) {
- port->draining=0;
- wakeup(&port->draining);
- bc->ilow=0; bc->iempty=0;
- } else {
-
- int wrapmask=port->txbufsize-1;
-
- for(obuf_full=FALSE; tp->t_outq.c_cc!=0 && !obuf_full; ) {
- int s;
- /* add "last-minute" data to write buffer */
- if(!(tp->t_state & TS_BUSY)) {
- hidewin(sc);
-#ifndef TS_ASLEEP /* post 2.0.5 FreeBSD */
- ttwwakeup(tp);
-#else
- if(tp->t_outq.c_cc <= tp->t_lowat) {
- if(tp->t_state & TS_ASLEEP) {
- tp->t_state &= ~TS_ASLEEP;
- wakeup(TSA_OLOWAT(tp));
- }
- /* selwakeup(&tp->t_wsel); */
- }
-#endif
- setwin(sc,0);
- }
- s=spltty();
-
- whead=bc->tin & wrapmask;
- wtail=bc->tout & wrapmask;
-
- if(whead<wtail)
- size=wtail-whead-1;
- else {
- size=port->txbufsize-whead;
- if(wtail==0)
- size--;
- }
-
- if(size==0) {
- DPRINT5(DB_WR,"dgb: head=%d tail=%d size=%d full=%d\n",
- whead,wtail,size,obuf_full);
- bc->iempty=1; bc->ilow=1;
- obuf_full=TRUE;
- splx(s);
- break;
- }
-
- towin(sc,port->txwin);
-
- ocount=q_to_b(&tp->t_outq, port->txptr+whead, size);
- whead+=ocount;
-
- setwin(sc,0);
- bc->tin=whead;
- bc->tin=whead & wrapmask;
- splx(s);
- }
-
- if(obuf_full) {
- DPRINT1(DB_WR," +BUSY\n");
- tp->t_state|=TS_BUSY;
- } else {
- DPRINT1(DB_WR," -BUSY\n");
- hidewin(sc);
-#ifndef TS_ASLEEP /* post 2.0.5 FreeBSD */
- /* should clear TS_BUSY before ttwwakeup */
- if(tp->t_state & TS_BUSY) {
- tp->t_state &= ~TS_BUSY;
- linesw[tp->t_line].l_start(tp);
- ttwwakeup(tp);
- }
-#else
- if(tp->t_state & TS_ASLEEP) {
- tp->t_state &= ~TS_ASLEEP;
- wakeup(TSA_OLOWAT(tp));
- }
- tp->t_state &= ~TS_BUSY;
-#endif
- setwin(sc,0);
- }
- }
- }
- bc->idata=1; /* require event on incoming data */
-
- } else {
- bc=port->brdchan;
- DPRINT4(DB_EXCEPT,"dgb%d: port%d: got event 0x%x on closed port\n",
- unit,pnum,event);
- bc->rout=bc->rin;
- bc->idata=bc->iempty=bc->ilow=0;
- }
-
- tail= (tail+4) & (FEP_IMAX-FEP_ISTART-4);
- }
-
- sc->mailbox->eout=tail;
- bmws_set(ws);
-
- timeout(dgbpoll, unit_c, hz/POLLSPERSEC);
-}
-
-static int
-dgbioctl(dev, cmd, data, flag, p)
- dev_t dev;
- u_long cmd;
- caddr_t data;
- int flag;
- struct proc *p;
-{
- struct dgb_softc *sc;
- int unit, pnum;
- struct dgb_p *port;
- int mynor;
- struct tty *tp;
- volatile struct board_chan *bc;
- int error;
- int s,cs;
- int tiocm_xxx;
-
-#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
- u_long oldcmd;
- struct termios term;
-#endif
-
- BoardMemWinState ws=bmws_get();
-
- mynor=minor(dev);
- unit=MINOR_TO_UNIT(mynor);
- pnum=MINOR_TO_PORT(mynor);
-
- sc=&dgb_softc[unit];
- port=&sc->ports[pnum];
- tp=&sc->ttys[pnum];
- bc=port->brdchan;
-
- if (mynor & CONTROL_MASK) {
- struct termios *ct;
-
- switch (mynor & CONTROL_MASK) {
- case CONTROL_INIT_STATE:
- ct = mynor & CALLOUT_MASK ? &port->it_out : &port->it_in;
- break;
- case CONTROL_LOCK_STATE:
- ct = mynor & CALLOUT_MASK ? &port->lt_out : &port->lt_in;
- break;
- default:
- return (ENODEV); /* /dev/nodev */
- }
- switch (cmd) {
- case TIOCSETA:
- error = suser(p);
- if (error != 0)
- return (error);
- *ct = *(struct termios *)data;
- return (0);
- case TIOCGETA:
- *(struct termios *)data = *ct;
- return (0);
- case TIOCGETD:
- *(int *)data = TTYDISC;
- return (0);
- case TIOCGWINSZ:
- bzero(data, sizeof(struct winsize));
- return (0);
- default:
- return (ENOTTY);
- }
- }
-
-#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
- term = tp->t_termios;
- if (cmd == TIOCSETA || cmd == TIOCSETAW || cmd == TIOCSETAF) {
- DPRINT6(DB_PARAM,"dgb%d: port%d: dgbioctl-ISNOW c=0x%x i=0x%x l=0x%x\n",unit,pnum,term.c_cflag,term.c_iflag,term.c_lflag);
- }
- oldcmd = cmd;
- error = ttsetcompat(tp, &cmd, data, &term);
- if (error != 0)
- return (error);
- if (cmd != oldcmd)
- data = (caddr_t)&term;
-#endif
-
- if (cmd == TIOCSETA || cmd == TIOCSETAW || cmd == TIOCSETAF) {
- int cc;
- struct termios *dt = (struct termios *)data;
- struct termios *lt = mynor & CALLOUT_MASK
- ? &port->lt_out : &port->lt_in;
-
- DPRINT6(DB_PARAM,"dgb%d: port%d: dgbioctl-TOSET c=0x%x i=0x%x l=0x%x\n",unit,pnum,dt->c_cflag,dt->c_iflag,dt->c_lflag);
- dt->c_iflag = (tp->t_iflag & lt->c_iflag)
- | (dt->c_iflag & ~lt->c_iflag);
- dt->c_oflag = (tp->t_oflag & lt->c_oflag)
- | (dt->c_oflag & ~lt->c_oflag);
- dt->c_cflag = (tp->t_cflag & lt->c_cflag)
- | (dt->c_cflag & ~lt->c_cflag);
- dt->c_lflag = (tp->t_lflag & lt->c_lflag)
- | (dt->c_lflag & ~lt->c_lflag);
- for (cc = 0; cc < NCCS; ++cc)
- if (lt->c_cc[cc] != 0)
- dt->c_cc[cc] = tp->t_cc[cc];
- if (lt->c_ispeed != 0)
- dt->c_ispeed = tp->t_ispeed;
- if (lt->c_ospeed != 0)
- dt->c_ospeed = tp->t_ospeed;
- }
-
- if(cmd==TIOCSTOP) {
- cs=splclock();
- setwin(sc,0);
- fepcmd(port, PAUSETX, 0, 0, 0, 0);
- bmws_set(ws);
- splx(cs);
- return 0;
- } else if(cmd==TIOCSTART) {
- cs=splclock();
- setwin(sc,0);
- fepcmd(port, RESUMETX, 0, 0, 0, 0);
- bmws_set(ws);
- splx(cs);
- return 0;
- }
-
- if(cmd==TIOCSETAW || cmd==TIOCSETAF)
- port->mustdrain=1;
-
- error = linesw[tp->t_line].l_ioctl(tp, cmd, data, flag, p);
- if (error != ENOIOCTL)
- return error;
- s = spltty();
- error = ttioctl(tp, cmd, data, flag);
- disc_optim(tp,&tp->t_termios);
- port->mustdrain=0;
- if (error != ENOIOCTL) {
- splx(s);
- if (cmd == TIOCSETA || cmd == TIOCSETAW || cmd == TIOCSETAF) {
- DPRINT6(DB_PARAM,"dgb%d: port%d: dgbioctl-RES c=0x%x i=0x%x l=0x%x\n",unit,pnum,tp->t_cflag,tp->t_iflag,tp->t_lflag);
- }
- return error;
- }
-
- switch (cmd) {
- case TIOCSBRK:
-/* Helg: commented */
-/* error=dgbdrain(port);*/
-
- if(error!=0) {
- splx(s);
- return error;
- }
-
- cs=splclock();
- setwin(sc,0);
-
- /* now it sends 250 millisecond break because I don't know */
- /* how to send an infinite break */
-
- fepcmd(port, SENDBREAK, 250, 0, 10, 0);
- hidewin(sc);
- splx(cs);
- break;
- case TIOCCBRK:
- /* now it's empty */
- break;
- case TIOCSDTR:
- DPRINT3(DB_MODEM,"dgb%d: port%d: set DTR\n",unit,pnum);
- port->omodem |= DTR;
- cs=splclock();
- setwin(sc,0);
- fepcmd(port, SETMODEM, port->omodem, RTS, 0, 1);
-
- if( !(bc->mstat & DTR) ) {
- DPRINT3(DB_MODEM,"dgb%d: port%d: DTR is off\n",unit,pnum);
- }
-
- hidewin(sc);
- splx(cs);
- break;
- case TIOCCDTR:
- DPRINT3(DB_MODEM,"dgb%d: port%d: reset DTR\n",unit,pnum);
- port->omodem &= ~DTR;
- cs=splclock();
- setwin(sc,0);
- fepcmd(port, SETMODEM, port->omodem, RTS|DTR, 0, 1);
-
- if( bc->mstat & DTR ) {
- DPRINT3(DB_MODEM,"dgb%d: port%d: DTR is on\n",unit,pnum);
- }
-
- hidewin(sc);
- splx(cs);
- break;
- case TIOCMSET:
- if(*(int *)data & TIOCM_DTR)
- port->omodem |=DTR;
- else
- port->omodem &=~DTR;
-
- if(*(int *)data & TIOCM_RTS)
- port->omodem |=RTS;
- else
- port->omodem &=~RTS;
-
- cs=splclock();
- setwin(sc,0);
- fepcmd(port, SETMODEM, port->omodem, RTS|DTR, 0, 1);
- hidewin(sc);
- splx(cs);
- break;
- case TIOCMBIS:
- if(*(int *)data & TIOCM_DTR)
- port->omodem |=DTR;
-
- if(*(int *)data & TIOCM_RTS)
- port->omodem |=RTS;
-
- cs=splclock();
- setwin(sc,0);
- fepcmd(port, SETMODEM, port->omodem, RTS|DTR, 0, 1);
- hidewin(sc);
- splx(cs);
- break;
- case TIOCMBIC:
- if(*(int *)data & TIOCM_DTR)
- port->omodem &=~DTR;
-
- if(*(int *)data & TIOCM_RTS)
- port->omodem &=~RTS;
-
- cs=splclock();
- setwin(sc,0);
- fepcmd(port, SETMODEM, port->omodem, RTS|DTR, 0, 1);
- hidewin(sc);
- splx(cs);
- break;
- case TIOCMGET:
- setwin(sc,0);
- port->imodem=bc->mstat;
- hidewin(sc);
-
- tiocm_xxx = TIOCM_LE; /* XXX - always enabled while open */
-
- DPRINT3(DB_MODEM,"dgb%d: port%d: modem stat -- ",unit,pnum);
-
- if (port->imodem & DTR) {
- DPRINT1(DB_MODEM,"DTR ");
- tiocm_xxx |= TIOCM_DTR;
- }
- if (port->imodem & RTS) {
- DPRINT1(DB_MODEM,"RTS ");
- tiocm_xxx |= TIOCM_RTS;
- }
- if (port->imodem & CTS) {
- DPRINT1(DB_MODEM,"CTS ");
- tiocm_xxx |= TIOCM_CTS;
- }
- if (port->imodem & port->dcd) {
- DPRINT1(DB_MODEM,"DCD ");
- tiocm_xxx |= TIOCM_CD;
- }
- if (port->imodem & port->dsr) {
- DPRINT1(DB_MODEM,"DSR ");
- tiocm_xxx |= TIOCM_DSR;
- }
- if (port->imodem & RI) {
- DPRINT1(DB_MODEM,"RI ");
- tiocm_xxx |= TIOCM_RI;
- }
- *(int *)data = tiocm_xxx;
- DPRINT1(DB_MODEM,"--\n");
- break;
- case TIOCMSDTRWAIT:
- /* must be root since the wait applies to following logins */
- error = suser(p);
- if (error != 0) {
- splx(s);
- return (error);
- }
- port->close_delay = *(int *)data * hz / 100;
- break;
- case TIOCMGDTRWAIT:
- *(int *)data = port->close_delay * 100 / hz;
- break;
- case TIOCTIMESTAMP:
- port->do_timestamp = TRUE;
- *(struct timeval *)data = port->timestamp;
- break;
- case TIOCDCDTIMESTAMP:
- port->do_dcd_timestamp = TRUE;
- *(struct timeval *)data = port->dcd_timestamp;
- break;
- default:
- bmws_set(ws);
- splx(s);
- return ENOTTY;
- }
- bmws_set(ws);
- splx(s);
-
- return 0;
-}
-
-static void
-wakeflush(p)
- void *p;
-{
- struct dgb_p *port=p;
-
- wakeup(&port->draining);
-}
-
-/* wait for the output to drain */
-
-static int
-dgbdrain(port)
- struct dgb_p *port;
-{
- struct dgb_softc *sc=&dgb_softc[port->unit];
- volatile struct board_chan *bc=port->brdchan;
- int error;
- int head, tail;
-
- BoardMemWinState ws=bmws_get();
-
- setwin(sc,0);
-
- bc->iempty=1;
- tail=bc->tout;
- head=bc->tin;
-
- while(tail!=head) {
- DPRINT5(DB_WR,"dgb%d: port%d: drain: head=%d tail=%d\n",
- port->unit, port->pnum, head, tail);
-
- hidewin(sc);
- port->draining=1;
- timeout(wakeflush,port, hz);
- error=tsleep(&port->draining, TTIPRI | PCATCH, "dgdrn", 0);
- port->draining=0;
- setwin(sc,0);
-
- if (error != 0) {
- DPRINT4(DB_WR,"dgb%d: port%d: tsleep(dgdrn) error=%d\n",
- port->unit,port->pnum,error);
-
- bc->iempty=0;
- bmws_set(ws);
- return error;
- }
-
- tail=bc->tout;
- head=bc->tin;
- }
- DPRINT5(DB_WR,"dgb%d: port%d: drain: head=%d tail=%d\n",
- port->unit, port->pnum, head, tail);
- bmws_set(ws);
- return 0;
-}
-
-/* wait for the output to drain */
-/* or simply clear the buffer it it's stopped */
-
-static void
-dgb_drain_or_flush(port)
- struct dgb_p *port;
-{
- struct tty *tp=port->tty;
- struct dgb_softc *sc=&dgb_softc[port->unit];
- volatile struct board_chan *bc=port->brdchan;
- int error;
- int lasttail;
- int head, tail;
-
- setwin(sc,0);
-
- lasttail=-1;
- bc->iempty=1;
- tail=bc->tout;
- head=bc->tin;
-
- while(tail!=head /* && tail!=lasttail */ ) {
- DPRINT5(DB_WR,"dgb%d: port%d: flush: head=%d tail=%d\n",
- port->unit, port->pnum, head, tail);
-
- /* if there is no carrier simply clean the buffer */
- if( !(tp->t_state & TS_CARR_ON) ) {
- bc->tout=bc->tin=0;
- bc->iempty=0;
- hidewin(sc);
- return;
- }
-
- hidewin(sc);
- port->draining=1;
- timeout(wakeflush,port, hz);
- error=tsleep(&port->draining, TTIPRI | PCATCH, "dgfls", 0);
- port->draining=0;
- setwin(sc,0);
-
- if (error != 0) {
- DPRINT4(DB_WR,"dgb%d: port%d: tsleep(dgfls) error=%d\n",
- port->unit,port->pnum,error);
-
- /* silently clean the buffer */
-
- bc->tout=bc->tin=0;
- bc->iempty=0;
- hidewin(sc);
- return;
- }
-
- lasttail=tail;
- tail=bc->tout;
- head=bc->tin;
- }
- hidewin(sc);
- DPRINT5(DB_WR,"dgb%d: port%d: flush: head=%d tail=%d\n",
- port->unit, port->pnum, head, tail);
-}
-
-static int
-dgbparam(tp, t)
- struct tty *tp;
- struct termios *t;
-{
- int unit=MINOR_TO_UNIT(minor(tp->t_dev));
- int pnum=MINOR_TO_PORT(minor(tp->t_dev));
- struct dgb_softc *sc=&dgb_softc[unit];
- struct dgb_p *port=&sc->ports[pnum];
- volatile struct board_chan *bc=port->brdchan;
- int cflag;
- int head;
- int mval;
- int iflag;
- int hflow;
- int cs;
-
- BoardMemWinState ws=bmws_get();
-
- DPRINT6(DB_PARAM,"dgb%d: port%d: dgbparm c=0x%x i=0x%x l=0x%x\n",unit,pnum,t->c_cflag,t->c_iflag,t->c_lflag);
-
- if(port->mustdrain) {
- DPRINT3(DB_PARAM,"dgb%d: port%d: must call dgbdrain()\n",unit,pnum);
- dgbdrain(port);
- }
-
- cflag=ttspeedtab(t->c_ospeed, dgbspeedtab);
-
- if (t->c_ispeed == 0)
- t->c_ispeed = t->c_ospeed;
-
- if (cflag < 0 /* || cflag > 0 && t->c_ispeed != t->c_ospeed */) {
- DPRINT4(DB_PARAM,"dgb%d: port%d: invalid cflag=0%o\n",unit,pnum,cflag);
- return (EINVAL);
- }
-
- cs=splclock();
- setwin(sc,0);
-
- if(cflag==0) { /* hangup */
- DPRINT3(DB_PARAM,"dgb%d: port%d: hangup\n",unit,pnum);
- head=bc->rin;
- bc->rout=head;
- head=bc->tin;
- fepcmd(port, STOUT, (unsigned)head, 0, 0, 0);
- mval= port->omodem & ~(DTR|RTS);
- } else {
- cflag |= dgbflags(dgb_cflags, t->c_cflag);
-
- if(cflag!=port->fepcflag) {
- port->fepcflag=cflag;
- DPRINT5(DB_PARAM,"dgb%d: port%d: set cflag=0x%x c=0x%x\n",
- unit,pnum,cflag,t->c_cflag&~CRTSCTS);
- fepcmd(port, SETCTRLFLAGS, (unsigned)cflag, 0, 0, 0);
- }
- mval= port->omodem | (DTR|RTS);
- }
-
- iflag=dgbflags(dgb_iflags, t->c_iflag);
- if(iflag!=port->fepiflag) {
- port->fepiflag=iflag;
- DPRINT5(DB_PARAM,"dgb%d: port%d: set iflag=0x%x c=0x%x\n",unit,pnum,iflag,t->c_iflag);
- fepcmd(port, SETIFLAGS, (unsigned)iflag, 0, 0, 0);
- }
-
- bc->mint=port->dcd;
-
- hflow=dgbflags(dgb_flow, t->c_cflag);
- if(hflow!=port->hflow) {
- port->hflow=hflow;
- DPRINT5(DB_PARAM,"dgb%d: port%d: set hflow=0x%x f=0x%x\n",unit,pnum,hflow,t->c_cflag&CRTSCTS);
- fepcmd(port, SETHFLOW, (unsigned)hflow, 0xff, 0, 1);
- }
-
- if(port->omodem != mval) {
- DPRINT5(DB_PARAM,"dgb%d: port%d: setting modem parameters 0x%x was 0x%x\n",
- unit,pnum,mval,port->omodem);
- port->omodem=mval;
- fepcmd(port, SETMODEM, (unsigned)mval, RTS|DTR, 0, 1);
- }
-
- if(port->fepstartc!=t->c_cc[VSTART] || port->fepstopc!=t->c_cc[VSTOP]) {
- DPRINT5(DB_PARAM,"dgb%d: port%d: set startc=%d, stopc=%d\n",unit,pnum,t->c_cc[VSTART],t->c_cc[VSTOP]);
- port->fepstartc=t->c_cc[VSTART];
- port->fepstopc=t->c_cc[VSTOP];
- fepcmd(port, SONOFFC, port->fepstartc, port->fepstopc, 0, 1);
- }
-
- bmws_set(ws);
- splx(cs);
-
- return 0;
-
-}
-
-static void
-dgbstart(tp)
- struct tty *tp;
-{
- int unit;
- int pnum;
- struct dgb_p *port;
- struct dgb_softc *sc;
- volatile struct board_chan *bc;
- int head, tail;
- int size, ocount;
- int s;
- int wmask;
-
- BoardMemWinState ws=bmws_get();
-
- unit=MINOR_TO_UNIT(minor(tp->t_dev));
- pnum=MINOR_TO_PORT(minor(tp->t_dev));
- sc=&dgb_softc[unit];
- port=&sc->ports[pnum];
- bc=port->brdchan;
-
- wmask=port->txbufsize-1;
-
- s=spltty();
-
- while( tp->t_outq.c_cc!=0 ) {
- int cs;
-#ifndef TS_ASLEEP /* post 2.0.5 FreeBSD */
- ttwwakeup(tp);
-#else
- if(tp->t_outq.c_cc <= tp->t_lowat) {
- if(tp->t_state & TS_ASLEEP) {
- tp->t_state &= ~TS_ASLEEP;
- wakeup(TSA_OLOWAT(tp));
- }
- /*selwakeup(&tp->t_wsel);*/
- }
-#endif
- cs=splclock();
- setwin(sc,0);
-
- head=bc->tin & wmask;
-
- do { tail=bc->tout; } while (tail != bc->tout);
- tail=bc->tout & wmask;
-
- DPRINT5(DB_WR,"dgb%d: port%d: s tx head=%d tail=%d\n",unit,pnum,head,tail);
-
-#ifdef LEAVE_FREE_CHARS
- if(tail>head) {
- size=tail-head-LEAVE_FREE_CHARS;
- if (size <0)
- size=0;
- } else {
- size=port->txbufsize-head;
- if(tail+port->txbufsize < head)
- size=0;
- }
- }
-#else
- if(tail>head)
- size=tail-head-1;
- else {
- size=port->txbufsize-head/*-1*/;
- if(tail==0)
- size--;
- }
-#endif
-
- if(size==0) {
- bc->iempty=1; bc->ilow=1;
- splx(cs);
- bmws_set(ws);
- tp->t_state|=TS_BUSY;
- splx(s);
- return;
- }
-
- towin(sc,port->txwin);
-
- ocount=q_to_b(&tp->t_outq, port->txptr+head, size);
- head+=ocount;
- if(head>=port->txbufsize)
- head-=port->txbufsize;
-
- setwin(sc,0);
- bc->tin=head;
-
- DPRINT5(DB_WR,"dgb%d: port%d: tx avail=%d count=%d\n",unit,pnum,size,ocount);
- hidewin(sc);
- splx(cs);
- }
-
- bmws_set(ws);
- splx(s);
-
-#ifndef TS_ASLEEP /* post 2.0.5 FreeBSD */
- if(tp->t_state & TS_BUSY) {
- tp->t_state&=~TS_BUSY;
- linesw[tp->t_line].l_start(tp);
- ttwwakeup(tp);
- }
-#else
- if(tp->t_state & TS_ASLEEP) {
- tp->t_state &= ~TS_ASLEEP;
- wakeup(TSA_OLOWAT(tp));
- }
- tp->t_state&=~TS_BUSY;
-#endif
-}
-
-void
-dgbstop(tp, rw)
- struct tty *tp;
- int rw;
-{
- int unit;
- int pnum;
- struct dgb_p *port;
- struct dgb_softc *sc;
- volatile struct board_chan *bc;
- int s;
-
- BoardMemWinState ws=bmws_get();
-
- unit=MINOR_TO_UNIT(minor(tp->t_dev));
- pnum=MINOR_TO_PORT(minor(tp->t_dev));
-
- sc=&dgb_softc[unit];
- port=&sc->ports[pnum];
- bc=port->brdchan;
-
- DPRINT3(DB_WR,"dgb%d: port%d: stop\n",port->unit, port->pnum);
-
- s = spltty();
- setwin(sc,0);
-
- if (rw & FWRITE) {
- /* clear output queue */
- bc->tout=bc->tin=0;
- bc->ilow=0;bc->iempty=0;
- }
- if (rw & FREAD) {
- /* clear input queue */
- bc->rout=bc->rin;
- bc->idata=1;
- }
- hidewin(sc);
- bmws_set(ws);
- splx(s);
- dgbstart(tp);
-}
-
-static void
-fepcmd(port, cmd, op1, op2, ncmds, bytecmd)
- struct dgb_p *port;
- unsigned cmd, op1, op2, ncmds, bytecmd;
-{
- struct dgb_softc *sc=&dgb_softc[port->unit];
- u_char *mem=sc->vmem;
- unsigned tail, head;
- int count, n;
-
- if(port->status==DISABLED) {
- printf("dgb%d: port%d: FEP command on disabled port\n",
- port->unit, port->pnum);
- return;
- }
-
- /* setwin(sc,0); Require this to be set by caller */
- head=sc->mailbox->cin;
-
- if(head>=(FEP_CMAX-FEP_CSTART) || (head & 3)) {
- printf("dgb%d: port%d: wrong pointer head of command queue : 0x%x\n",
- port->unit, port->pnum, head);
- return;
- }
-
- mem[head+FEP_CSTART+0]=cmd;
- mem[head+FEP_CSTART+1]=port->pnum;
- if(bytecmd) {
- mem[head+FEP_CSTART+2]=op1;
- mem[head+FEP_CSTART+3]=op2;
- } else {
- mem[head+FEP_CSTART+2]=op1&0xff;
- mem[head+FEP_CSTART+3]=(op1>>8)&0xff;
- }
-
- DPRINT7(DB_FEP,"dgb%d: port%d: %s cmd=0x%x op1=0x%x op2=0x%x\n", port->unit, port->pnum,
- (bytecmd)?"byte":"word", cmd, mem[head+FEP_CSTART+2], mem[head+FEP_CSTART+3]);
-
- head=(head+4) & (FEP_CMAX-FEP_CSTART-4);
- sc->mailbox->cin=head;
-
- count=FEPTIMEOUT;
-
- while (count-- != 0) {
- head=sc->mailbox->cin;
- tail=sc->mailbox->cout;
-
- n = (head-tail) & (FEP_CMAX-FEP_CSTART-4);
- if(n <= ncmds * (sizeof(ushort)*4))
- return;
- }
- printf("dgb%d(%d): timeout on FEP cmd=0x%x\n", port->unit, port->pnum, cmd);
-}
-
-static void
-disc_optim(tp, t)
- struct tty *tp;
- struct termios *t;
-{
- if (!(t->c_iflag & (ICRNL | IGNCR | IMAXBEL | INLCR | ISTRIP | IXON))
- && (!(t->c_iflag & BRKINT) || (t->c_iflag & IGNBRK))
- && (!(t->c_iflag & PARMRK)
- || (t->c_iflag & (IGNPAR | IGNBRK)) == (IGNPAR | IGNBRK))
- && !(t->c_lflag & (ECHO | ICANON | IEXTEN | ISIG | PENDIN))
- && linesw[tp->t_line].l_rint == ttyinput)
- tp->t_state |= TS_CAN_BYPASS_L_RINT;
- else
- tp->t_state &= ~TS_CAN_BYPASS_L_RINT;
-}
diff --git a/sys/dev/dgb/dgbios.h b/sys/dev/dgb/dgbios.h
deleted file mode 100644
index 02dd6bb94d07..000000000000
--- a/sys/dev/dgb/dgbios.h
+++ /dev/null
@@ -1,175 +0,0 @@
-static unsigned char pcxx_bios[] = {
- 0x28,0x43,0x29,0x20,0x43,0x6f,0x70,0x79,0x72,0x69,0x67,0x68,
- 0x74,0x20,0x31,0x39,0x39,0x34,0x2c,0x20,0x44,0x69,0x67,0x69,
- 0x42,0x6f,0x61,0x72,0x64,0x20,0x49,0x6e,0x63,0x2e,0x00,0x00,
- 0x8a,0xf8,0x8a,0xf8,0x15,0xf9,0x8a,0xf8,0x8a,0xf8,0x8a,0xf8,
- 0x8a,0xf8,0x8a,0xf8,0xbc,0xf8,0x8a,0xf8,0x96,0xf8,0x96,0xf8,
- 0x96,0xf8,0x96,0xf8,0x96,0xf8,0x96,0xf8,0x8a,0xf8,0x8a,0xf8,
- 0x96,0xf8,0x96,0xf8,0x8a,0xf8,0xad,0xf8,0xb0,0xf8,0x8a,0xf8,
- 0x8a,0xf8,0x8a,0xf8,0x8a,0xf8,0x8a,0xf8,0x8a,0xf8,0x8a,0xf8,
- 0x8a,0xf8,0x8a,0xf8,0x8a,0xf8,0x04,0x02,0x00,0x02,0x14,0x02,
- 0x10,0x02,0x24,0x02,0x20,0x02,0x34,0x02,0x30,0x02,0x44,0x02,
- 0x40,0x02,0x54,0x02,0x50,0x02,0x64,0x02,0x60,0x02,0x74,0x02,
- 0x70,0x02,0x04,0x01,0x00,0x01,0x1e,0x2e,0x8e,0x1e,0x22,0xf8,
- 0xfe,0x06,0x70,0x00,0x1f,0xcf,0x1e,0x50,0x52,0x2e,0x8e,0x1e,
- 0x22,0xf8,0xfe,0x06,0x71,0x00,0xb8,0x00,0x80,0xba,0x22,0xff,
- 0xef,0x5a,0x58,0x1f,0xcf,0xb4,0x80,0xcf,0x1e,0x2e,0x8e,0x1e,
- 0x22,0xf8,0xfe,0x06,0x2b,0x00,0x1f,0xcf,0x1e,0x52,0x50,0x2e,
- 0x8e,0x1e,0x22,0xf8,0xcd,0x16,0xfe,0x06,0x2a,0x00,0x80,0x3e,
- 0x2a,0x00,0x12,0x72,0x39,0xc6,0x06,0x2a,0x00,0x00,0xfe,0x06,
- 0x29,0x00,0x80,0x3e,0x29,0x00,0x3c,0x72,0x29,0xc6,0x06,0x29,
- 0x00,0x00,0xfe,0x06,0x28,0x00,0x80,0x3e,0x28,0x00,0x3c,0x72,
- 0x19,0xc6,0x06,0x28,0x00,0x00,0xfe,0x06,0x27,0x00,0x80,0x3e,
- 0x27,0x00,0x18,0x72,0x09,0xc6,0x06,0x27,0x00,0x00,0xff,0x06,
- 0x25,0x00,0xba,0x22,0xff,0xb8,0x00,0x80,0xef,0x58,0x5a,0x1f,
- 0xcf,0x60,0x1e,0x06,0xfc,0x2e,0x8e,0x06,0x22,0xf8,0x2e,0x8e,
- 0x1e,0x22,0xf8,0x8d,0x36,0x40,0x00,0xad,0x3c,0x3f,0x7f,0x22,
- 0x3c,0x1f,0x7f,0x22,0x32,0xe4,0xd1,0xe0,0x3d,0x16,0x00,0x90,
- 0x73,0x14,0xbb,0x56,0xf9,0x03,0xd8,0x2e,0xff,0x17,0x8d,0x36,
- 0x40,0x00,0xb0,0x00,0x89,0x04,0x07,0x1f,0x61,0xcf,0xb4,0x80,
- 0xeb,0xf0,0xcd,0x15,0xeb,0xec,0x6c,0xf9,0x79,0xf9,0xb9,0xf9,
- 0xd3,0xf9,0xd8,0xf9,0xe1,0xf9,0xe9,0xf9,0xf2,0xf9,0xfa,0xf9,
- 0xfd,0xf9,0x2a,0xfa,0xe4,0x00,0x24,0xf7,0xe6,0x00,0x0c,0x08,
- 0xe6,0x00,0xb4,0x00,0xc3,0x1e,0xad,0x8b,0xd8,0xad,0x8e,0xdb,
- 0x8b,0xf0,0x33,0xdb,0x8b,0x07,0x3d,0x4f,0x53,0x75,0x2a,0x8a,
- 0x47,0x02,0x32,0xe4,0x86,0xc4,0x8b,0xc8,0x32,0xc0,0x02,0x07,
- 0x43,0xe2,0xfb,0x0a,0xc0,0x75,0x16,0x8c,0xd9,0x1f,0x89,0x0e,
- 0x2e,0x00,0x89,0x36,0x2c,0x00,0x8d,0x1e,0x02,0x00,0xc7,0x07,
- 0x45,0x4d,0x32,0xe4,0xc3,0x1f,0xb4,0x80,0xc3,0xad,0x8b,0xd8,
- 0xad,0x8b,0xd0,0xad,0x8e,0xc0,0xad,0x8b,0xf8,0xad,0x8b,0xc8,
- 0x8b,0xf2,0x1e,0x8e,0xdb,0xf3,0xa4,0x1f,0x32,0xe4,0xc3,0xea,
- 0xf0,0xff,0x00,0xf0,0xad,0x8b,0xd0,0xec,0x88,0x04,0x32,0xe4,
- 0xc3,0xad,0x8b,0xd0,0xac,0xee,0x32,0xe4,0xc3,0xad,0x8b,0xd0,
- 0xed,0x89,0x04,0x32,0xe4,0xc3,0xad,0x8b,0xd0,0xad,0xef,0x32,
- 0xe4,0xc3,0xb4,0x80,0xc3,0xac,0x3c,0x12,0x7f,0x25,0xfe,0xc8,
- 0x32,0xe4,0xd1,0xe0,0x8d,0x1e,0x66,0xf8,0x03,0xd8,0x2e,0x8b,
- 0x17,0xec,0xac,0x3c,0x0f,0x7f,0x10,0x3c,0x00,0x74,0x03,0xee,
- 0x90,0x90,0xec,0x8b,0xfe,0x1e,0x07,0xaa,0x32,0xe4,0xc3,0xb4,
- 0x80,0xc3,0xac,0x3c,0x12,0x7f,0x1f,0xfe,0xc8,0x32,0xe4,0xd1,
- 0xe0,0x8d,0x1e,0x66,0xf8,0x03,0xd8,0x2e,0x8b,0x17,0xec,0xac,
- 0x3c,0x0f,0x7f,0x0a,0x3c,0x00,0x74,0x01,0xee,0xac,0xee,0x32,
- 0xe4,0xc3,0xb4,0x80,0xc3,0xfc,0x8e,0xc0,0xb8,0xff,0xff,0x8b,
- 0xcb,0x33,0xff,0xf3,0xab,0x8b,0xcb,0x33,0xff,0xf3,0xaf,0xe3,
- 0x01,0xc3,0x8b,0xcb,0xbf,0x00,0x00,0x26,0x89,0x3d,0x83,0xc7,
- 0x02,0xe2,0xf8,0xbe,0x00,0x00,0x8b,0xcb,0x26,0x8b,0x3c,0x3b,
- 0xfe,0x74,0x01,0xc3,0x83,0xc6,0x02,0x83,0xc7,0x02,0xe2,0xf0,
- 0x33,0xc0,0x8b,0xcb,0x33,0xff,0xf3,0xab,0x8b,0xcb,0x33,0xff,
- 0xf3,0xaf,0xc3,0x32,0xc0,0x26,0x80,0x3e,0x23,0x00,0x00,0x74,
- 0x02,0x0c,0x01,0x26,0xf7,0x06,0x20,0x00,0x0f,0x00,0x74,0x02,
- 0x0c,0x02,0x26,0xf7,0x06,0x20,0x00,0xf0,0x00,0x74,0x02,0x0c,
- 0x04,0x26,0xf7,0x06,0x20,0x00,0x00,0xff,0x74,0x02,0x0c,0x08,
- 0x26,0xa2,0x24,0x00,0xb8,0x00,0x40,0xba,0x5e,0xff,0xef,0xba,
- 0x66,0xff,0xef,0xba,0x52,0xff,0xb8,0x63,0x0e,0xef,0xba,0x56,
- 0xff,0xb8,0x05,0xe0,0xef,0xba,0x28,0xff,0xb8,0xfc,0x00,0xef,
- 0xb8,0x00,0x02,0x26,0xa3,0x2e,0x00,0xb8,0x04,0x00,0x26,0xa3,
- 0x2c,0x00,0xb0,0xc3,0xe6,0x08,0x8a,0xd8,0xe4,0x08,0x3a,0xc3,
- 0x75,0x06,0x26,0xc6,0x06,0xb4,0x00,0x01,0xb0,0x00,0xe6,0x00,
- 0xfc,0x8d,0x3e,0x00,0x00,0xb8,0x47,0x44,0xab,0xb8,0xff,0xff,
- 0xab,0xab,0xab,0xb8,0x42,0x49,0xab,0xb8,0x4f,0x53,0xab,0xb8,
- 0x58,0x69,0x26,0x80,0x3e,0x10,0x00,0x04,0x74,0x0e,0xb8,0x58,
- 0x65,0x26,0x80,0x3e,0x10,0x00,0x03,0x74,0x03,0xb8,0x58,0x74,
- 0xab,0x8d,0x36,0xfe,0xff,0x8a,0x04,0x8d,0x36,0xff,0xff,0x8a,
- 0x24,0xab,0xfb,0x26,0x81,0x0e,0x12,0x00,0x00,0x08,0x06,0x1f,
- 0xa1,0x00,0x00,0x8b,0x1e,0x02,0x00,0x3d,0x44,0x47,0x75,0x0b,
- 0x26,0x81,0x0e,0x12,0x00,0x00,0x10,0xff,0x2e,0x2c,0x00,0x81,
- 0xfb,0x45,0x4d,0x75,0xe3,0x26,0x81,0x0e,0x12,0x00,0x00,0x20,
- 0xff,0x2e,0x2c,0x00,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,
- 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,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,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,
- 0xff,0xff,0xff,0xff,0xfa,0xba,0xa8,0xff,0xb8,0xba,0x81,0xef,
- 0xba,0xa4,0xff,0xb8,0x3a,0x00,0xef,0x90,0xe4,0x00,0xa8,0x60,
- 0x75,0x0c,0x24,0x06,0x74,0x14,0x3c,0x02,0x74,0x1c,0x3c,0x04,
- 0x74,0x24,0xbb,0x38,0xc0,0xbe,0xf8,0x81,0xbf,0xba,0xa0,0xeb,
- 0x22,0x90,0xbb,0x38,0xf0,0xbe,0xf8,0x41,0xbf,0xba,0x81,0xeb,
- 0x16,0x90,0xbb,0x38,0xf0,0xbe,0xf8,0xe1,0xbf,0xba,0x88,0xeb,
- 0x0a,0x90,0xbb,0x38,0xc0,0xbe,0xf8,0x41,0xbf,0xba,0x81,0xba,
- 0xa0,0xff,0x8b,0xc3,0xef,0xba,0xa2,0xff,0xb8,0xf8,0x0f,0xef,
- 0xba,0xa6,0xff,0x8b,0xc6,0xef,0xba,0xa8,0xff,0x8b,0xc7,0xef,
- 0x8c,0xc8,0x8e,0xd8,0xe4,0x00,0x24,0x06,0x74,0x17,0xbb,0x00,
- 0x80,0xbd,0xc0,0xe0,0x3c,0x02,0x74,0x5a,0xbd,0xc0,0xc0,0x3c,
- 0x04,0x74,0x53,0xbd,0xc0,0x80,0xeb,0x4e,0x90,0xb9,0x08,0x00,
- 0xb8,0x00,0x80,0x8e,0xc0,0x26,0xa3,0x00,0x00,0x05,0x00,0x10,
- 0xe2,0xf5,0xbd,0xc0,0xf0,0xbb,0x00,0x7c,0xb8,0x00,0xe0,0x8e,
- 0xc0,0x26,0x8b,0x0e,0x00,0x00,0x3b,0xc8,0x75,0x28,0xbb,0x00,
- 0x80,0xbd,0xc0,0xe0,0xb8,0x00,0xc0,0x8e,0xc0,0x26,0x8b,0x0e,
- 0x00,0x00,0x3b,0xc8,0x75,0x14,0xbd,0xc0,0xc0,0xb8,0x00,0x80,
- 0x8e,0xc0,0x26,0x8b,0x0e,0x00,0x00,0x3b,0xc8,0x75,0x03,0xbd,
- 0xc0,0x80,0x8c,0xc8,0x8e,0xd0,0xbc,0xed,0xfc,0x8b,0xc5,0x25,
- 0x00,0xf0,0xe9,0x6c,0xfd,0xb4,0x00,0x74,0x06,0xb4,0xff,0xeb,
- 0x02,0xe5,0xfc,0x8e,0xc5,0x2e,0x89,0x2e,0x22,0xf8,0xe4,0x00,
- 0x24,0x16,0x26,0xa2,0x11,0x00,0x26,0x83,0x0e,0x12,0x00,0x01,
- 0x80,0xfc,0x00,0x74,0x06,0x26,0x83,0x0e,0x14,0x00,0x01,0x26,
- 0xc7,0x06,0x18,0x00,0x40,0x00,0x26,0xc6,0x06,0x10,0x00,0x03,
- 0xa8,0x10,0x74,0x06,0x26,0xc6,0x06,0x10,0x00,0x04,0xb8,0x00,
- 0x00,0x8e,0xc0,0xb8,0xaa,0x55,0x26,0xa3,0x00,0x00,0x26,0xc7,
- 0x06,0x02,0x00,0x00,0x00,0x26,0xc7,0x06,0x04,0x00,0x00,0x00,
- 0x8b,0xcd,0x81,0xe1,0x00,0xf0,0x8e,0xc1,0x26,0x8b,0x1e,0x00,
- 0x00,0x3b,0xc3,0x75,0x13,0x8e,0xc5,0x26,0xc6,0x06,0x10,0x00,
- 0x05,0xb8,0x40,0x00,0x8e,0xd0,0xbc,0x00,0x04,0xe9,0x99,0x00,
- 0x8c,0xc8,0x8e,0xd0,0xbc,0x7c,0xfd,0xb8,0x00,0x00,0xbb,0x00,
- 0x20,0xe9,0xdd,0xfc,0xb4,0x00,0x74,0x06,0xb4,0xff,0xeb,0x02,
- 0x74,0xfd,0x8e,0xc5,0x80,0xfc,0x00,0x74,0x08,0x26,0x83,0x0e,
- 0x14,0x00,0x02,0xeb,0x0d,0x26,0xc7,0x06,0x16,0x00,0x10,0x00,
- 0x26,0x83,0x0e,0x12,0x00,0x02,0xb8,0x40,0x00,0x8e,0xd0,0xbc,
- 0x00,0x04,0xe4,0x00,0xa8,0x60,0x75,0x07,0xba,0xa2,0xff,0xb8,
- 0xfc,0x0f,0xef,0xb8,0x00,0x04,0x8e,0xc0,0xb8,0xaa,0x55,0x26,
- 0xa3,0x00,0x00,0x26,0xc7,0x06,0x02,0x00,0x00,0x00,0x26,0xc7,
- 0x06,0x04,0x00,0x00,0x00,0xb9,0x00,0x00,0x8e,0xc1,0x26,0x8b,
- 0x1e,0x00,0x00,0x3b,0xc3,0x75,0x02,0xeb,0x24,0x8e,0xc5,0x26,
- 0x83,0x0e,0x12,0x00,0x04,0xb8,0x00,0x04,0xbb,0x00,0x60,0x06,
- 0xe8,0x66,0xfc,0x07,0x75,0x09,0x26,0xc7,0x06,0x16,0x00,0x40,
- 0x00,0xeb,0x06,0x26,0x83,0x0e,0x14,0x00,0x04,0x8e,0xc5,0x8c,
- 0xc0,0x3d,0xc0,0xf0,0x75,0x03,0xe9,0x9f,0x00,0x3d,0xc0,0x80,
- 0x74,0x62,0x3d,0xc0,0xc0,0x74,0x23,0x26,0x83,0x0e,0x12,0x00,
- 0x08,0xb8,0x00,0xf0,0xbb,0x00,0x7c,0x06,0xe8,0x2e,0xfc,0x07,
- 0x75,0x08,0x26,0x83,0x06,0x18,0x00,0x40,0xeb,0x06,0x26,0x83,
- 0x0e,0x14,0x00,0x08,0xeb,0x72,0xb9,0x03,0x00,0xb8,0x00,0xd0,
- 0xba,0x08,0x00,0xbb,0x00,0x80,0x3d,0x00,0xf0,0x75,0x03,0xbb,
- 0x00,0x7c,0x26,0x09,0x16,0x12,0x00,0x06,0x50,0x51,0xe8,0xfc,
- 0xfb,0x59,0x58,0x07,0x75,0x0f,0x26,0x83,0x06,0x18,0x00,0x40,
- 0xd1,0xe2,0x05,0x00,0x10,0xe2,0xd8,0xeb,0x05,0x26,0x09,0x16,
- 0x14,0x00,0xeb,0x38,0xb9,0x07,0x00,0xb8,0x00,0x90,0xba,0x08,
- 0x00,0xbb,0x00,0x80,0x3d,0x00,0xf0,0x75,0x03,0xbb,0x00,0x7c,
- 0x26,0x09,0x16,0x12,0x00,0x06,0x50,0x51,0xe8,0xc2,0xfb,0x59,
- 0x58,0x07,0x75,0x0f,0x26,0x83,0x06,0x18,0x00,0x40,0xd1,0xe2,
- 0x05,0x00,0x10,0xe2,0xd8,0xeb,0x05,0x26,0x09,0x16,0x14,0x00,
- 0x26,0xa1,0x18,0x00,0x2d,0x10,0x00,0x26,0xa3,0x1a,0x00,0x06,
- 0xfc,0x33,0xff,0x8e,0xc7,0xb9,0x00,0x02,0xb8,0x00,0xf0,0xf3,
- 0xab,0x33,0xff,0xbe,0x24,0xf8,0xb9,0x20,0x00,0xa5,0x47,0x47,
- 0xe2,0xfb,0xbe,0x64,0xf8,0xb9,0xe0,0x00,0x8b,0x1c,0x26,0x89,
- 0x1d,0x83,0xc7,0x04,0xe2,0xf8,0x07,0xba,0x28,0xff,0xb8,0xfd,
- 0x00,0xef,0xba,0x32,0xff,0xb8,0x0d,0x00,0xef,0xba,0x34,0xff,
- 0xb8,0x0f,0x00,0xef,0xba,0x36,0xff,0xb8,0x0e,0x00,0xef,0xba,
- 0x38,0xff,0xb8,0x19,0x00,0xef,0xba,0x3a,0xff,0xb8,0x18,0x00,
- 0xef,0xba,0x3c,0xff,0xb8,0x0b,0x00,0xef,0xba,0x3e,0xff,0xb8,
- 0x1a,0x00,0xef,0x8d,0x3e,0x90,0x00,0x8d,0x36,0x66,0xf8,0xb9,
- 0x10,0x00,0xf3,0xa5,0x8d,0x3e,0xb0,0x00,0x8d,0x36,0x86,0xf8,
- 0xb9,0x02,0x00,0xf3,0xa5,0xb9,0x10,0x00,0x8d,0x36,0x90,0x00,
- 0x83,0xc6,0x1e,0x26,0x8b,0x14,0xb3,0x10,0x32,0xc0,0xec,0xb0,
- 0x0c,0xee,0x8a,0xc3,0x8a,0xc3,0xee,0x83,0xee,0x02,0x26,0x8b,
- 0x14,0xfe,0xcb,0xe2,0xeb,0xb9,0x10,0x00,0x8d,0x36,0x90,0x00,
- 0x26,0x8b,0x14,0xb3,0x01,0xbf,0x00,0x80,0xb0,0x0c,0xee,0xf6,
- 0xe8,0xec,0x3a,0xc3,0x75,0x0e,0xd1,0xc7,0x26,0x09,0x3e,0x20,
- 0x00,0x26,0xfe,0x06,0x22,0x00,0xeb,0x07,0x33,0xc0,0x26,0x89,
- 0x04,0xd1,0xc7,0x83,0xc6,0x02,0x26,0x8b,0x14,0xfe,0xc3,0xe2,
- 0xd7,0x26,0xc6,0x06,0x23,0x00,0x01,0x8d,0x36,0xb0,0x00,0x26,
- 0x8b,0x14,0x32,0xc0,0xee,0xb0,0x0c,0xee,0xb0,0x5a,0xee,0xb0,
- 0x0c,0xee,0xf6,0xe8,0xec,0x3c,0x5a,0x74,0x14,0x26,0xc7,0x06,
- 0xb0,0x00,0x00,0x00,0x26,0xc7,0x06,0xb2,0x00,0x00,0x00,0x26,
- 0xc6,0x06,0x23,0x00,0x00,0xe9,0xd3,0xfa,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0xea,0x00,0xfc,0x00,0xf0,0x4d,0x2f,0x50,
- 0x43,0x2f,0x58,0x2a,0x39,0x34,0x34,0x31
-};
-
-static unsigned pcxx_nbios=sizeof(pcxx_bios);
diff --git a/sys/dev/dgb/dgfep.h b/sys/dev/dgb/dgfep.h
deleted file mode 100644
index 9ed4f7d218de..000000000000
--- a/sys/dev/dgb/dgfep.h
+++ /dev/null
@@ -1,516 +0,0 @@
-static unsigned char pcxx_cook[] = {
- 0x4f,0x53,0x18,0x80,0xe9,0xbf,0x15,0x00,0x40,0x28,0x23,0x29,
- 0x46,0x45,0x50,0x4f,0x53,0x20,0x37,0x2e,0x30,0x38,0x20,0x34,
- 0x2f,0x32,0x30,0x2f,0x39,0x35,0x00,0x40,0x28,0x23,0x29,0x28,
- 0x43,0x29,0x43,0x6f,0x70,0x79,0x72,0x69,0x67,0x68,0x74,0x20,
- 0x31,0x39,0x38,0x39,0x2d,0x31,0x39,0x39,0x35,0x20,0x44,0x69,
- 0x67,0x69,0x42,0x6f,0x61,0x72,0x64,0x20,0x49,0x6e,0x63,0x2e,
- 0x00,0xcb,0x0c,0xcb,0x0c,0xe2,0x0c,0xcb,0x0c,0xcb,0x0c,0xcb,
- 0x0c,0xcb,0x0c,0xcb,0x0c,0x57,0x0c,0xcb,0x0c,0xcb,0x0c,0xcb,
- 0x0c,0x53,0x0b,0xcb,0x0c,0xcb,0x0c,0x42,0x0b,0xcb,0x0c,0xcb,
- 0x0c,0x12,0x0d,0xcb,0x0c,0xcb,0x0c,0xcb,0x0c,0xcb,0x0c,0xcb,
- 0x0c,0xcb,0x0c,0xcb,0x0c,0xcb,0x0c,0xcb,0x0c,0xcb,0x0c,0xcb,
- 0x0c,0xcb,0x0c,0xcb,0x0c,0x00,0x10,0x80,0x10,0x00,0x11,0x80,
- 0x11,0x00,0x12,0x80,0x12,0x00,0x13,0x80,0x13,0x00,0x14,0x80,
- 0x14,0x00,0x15,0x80,0x15,0x00,0x16,0x80,0x16,0x00,0x17,0x80,
- 0x17,0x78,0x0b,0xb9,0x0b,0x50,0x0c,0xb9,0x0b,0x8d,0x0b,0x8d,
- 0x0b,0x8d,0x0b,0x8d,0x0b,0xc0,0x0b,0xc0,0x0b,0xc0,0x0b,0xc0,
- 0x0b,0x8d,0x0b,0x8d,0x0b,0x8d,0x0b,0x8d,0x0b,0x50,0x0c,0xb9,
- 0x0b,0x50,0x0c,0xb9,0x0b,0x8d,0x0b,0x8d,0x0b,0x8d,0x0b,0x8d,
- 0x0b,0xc0,0x0b,0xc0,0x0b,0xc0,0x0b,0xc0,0x0b,0x8d,0x0b,0x8d,
- 0x0b,0x8d,0x0b,0x8d,0x0b,0x94,0x0b,0x94,0x0b,0x94,0x0b,0x94,
- 0x0b,0x94,0x0b,0x94,0x0b,0x94,0x0b,0x94,0x0b,0x94,0x0b,0x94,
- 0x0b,0x94,0x0b,0x94,0x0b,0x94,0x0b,0x94,0x0b,0x94,0x0b,0x94,
- 0x0b,0x94,0x0b,0x94,0x0b,0x94,0x0b,0x94,0x0b,0x94,0x0b,0x94,
- 0x0b,0x94,0x0b,0x94,0x0b,0x94,0x0b,0x94,0x0b,0x94,0x0b,0x94,
- 0x0b,0x94,0x0b,0x94,0x0b,0x94,0x0b,0x94,0x0b,0x16,0x00,0xfe,
- 0x11,0xfe,0x0b,0x2c,0x08,0xb5,0x06,0xfe,0x05,0x7e,0x04,0xfe,
- 0x02,0x7e,0x01,0xbe,0x00,0x7e,0x00,0x5e,0x00,0x2e,0x00,0x16,
- 0x00,0x0a,0x00,0x04,0x00,0x16,0x00,0x02,0x00,0x01,0x00,0x00,
- 0x00,0x0e,0x00,0x06,0x00,0x7e,0x04,0xfe,0x02,0x7e,0x01,0xbe,
- 0x00,0x7e,0x00,0x5e,0x00,0x2e,0x00,0x16,0x00,0x0a,0x00,0x04,
- 0x00,0x18,0x00,0x86,0x13,0x03,0x0d,0xdf,0x08,0x41,0x07,0x81,
- 0x06,0xe0,0x04,0x3f,0x03,0x9f,0x01,0xce,0x00,0x89,0x00,0x66,
- 0x00,0x32,0x00,0x18,0x00,0x0b,0x00,0x0b,0x00,0x18,0x00,0x0b,
- 0x00,0x0b,0x00,0x0b,0x00,0x41,0x07,0x81,0x06,0xe0,0x04,0x3f,
- 0x03,0x9f,0x01,0xce,0x00,0x89,0x00,0x66,0x00,0x32,0x00,0x18,
- 0x00,0x0b,0x00,0x0b,0x00,0x00,0x80,0x40,0xc0,0x1f,0x3f,0x7f,
- 0xff,0x00,0x04,0x02,0x06,0x08,0x0c,0x0a,0x0e,0x00,0x04,0x02,
- 0x06,0x08,0x0c,0x0a,0x0e,0xa0,0x08,0xa0,0x08,0xa0,0x08,0xa0,
- 0x08,0xa0,0x08,0xa0,0x08,0xa0,0x08,0xa0,0x08,0x1e,0x06,0x3e,
- 0x06,0xef,0x06,0xf8,0x05,0x0e,0x06,0x55,0x07,0xa0,0x08,0xa0,
- 0x08,0xa0,0x08,0xa0,0x08,0xa0,0x08,0xa0,0x08,0xa0,0x08,0xa0,
- 0x08,0xa0,0x08,0xa0,0x08,0xa0,0x08,0xa0,0x08,0xa0,0x08,0xa0,
- 0x08,0xa0,0x08,0xa0,0x08,0xa0,0x08,0xa0,0x08,0x9d,0x08,0x9d,
- 0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,
- 0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,
- 0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,
- 0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,
- 0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,
- 0x08,0x9d,0x08,0xa1,0x05,0xa1,0x05,0xa1,0x05,0xa1,0x05,0xa1,
- 0x05,0xa1,0x05,0xa1,0x05,0xa1,0x05,0xa1,0x05,0xa1,0x05,0xa1,
- 0x05,0xa1,0x05,0xa1,0x05,0xa1,0x05,0xa1,0x05,0xa1,0x05,0xa1,
- 0x05,0xa1,0x05,0xa1,0x05,0xa1,0x05,0xa1,0x05,0xa1,0x05,0xa1,
- 0x05,0xa1,0x05,0xa1,0x05,0xa1,0x05,0x9d,0x08,0x9d,0x08,0x9d,
- 0x08,0x9d,0x08,0x9d,0x08,0x5b,0x05,0xea,0x05,0xea,0x05,0xea,
- 0x05,0xea,0x05,0xea,0x05,0xea,0x05,0xea,0x05,0xea,0x05,0xea,
- 0x05,0xea,0x05,0xea,0x05,0xea,0x05,0xea,0x05,0xea,0x05,0xea,
- 0x05,0xea,0x05,0xea,0x05,0xea,0x05,0xea,0x05,0xea,0x05,0xea,
- 0x05,0xea,0x05,0xea,0x05,0xea,0x05,0xea,0x05,0xea,0x05,0x69,
- 0x05,0x77,0x05,0x85,0x05,0x93,0x05,0xa0,0x08,0xa0,0x08,0xa0,
- 0x08,0xa0,0x08,0xa0,0x08,0xa0,0x08,0xa0,0x08,0xa0,0x08,0xa0,
- 0x08,0xa0,0x08,0xa0,0x08,0xa0,0x08,0xa0,0x08,0xa0,0x08,0xa0,
- 0x08,0xa0,0x08,0xa0,0x08,0xa0,0x08,0xa0,0x08,0xa0,0x08,0xa0,
- 0x08,0xa0,0x08,0xa0,0x08,0xa0,0x08,0xa0,0x08,0xa0,0x08,0xa0,
- 0x08,0xa0,0x08,0xa0,0x08,0xa0,0x08,0xa0,0x08,0xa0,0x08,0xa0,
- 0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,
- 0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,
- 0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,
- 0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,
- 0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,
- 0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,
- 0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,
- 0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,
- 0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,
- 0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,
- 0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,
- 0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,
- 0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,
- 0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,
- 0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,
- 0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,0x08,0x9d,
- 0x08,0x00,0x00,0xfa,0x8a,0x5c,0x50,0xf6,0xc3,0x0e,0x75,0x3c,
- 0xf6,0xc3,0x40,0x75,0x16,0xf6,0xc3,0x10,0x74,0x26,0xf6,0xc3,
- 0x01,0x75,0x13,0xf6,0xc3,0x20,0x75,0x15,0xc7,0x04,0xb6,0x04,
- 0xe9,0xcf,0x00,0x8b,0x44,0x02,0x89,0x04,0xff,0xe0,0xc7,0x04,
- 0x03,0x05,0xe9,0x0e,0x01,0xc7,0x04,0x66,0x08,0xe9,0x6a,0x04,
- 0xf6,0xc3,0x20,0x74,0x1a,0xc7,0x04,0xb3,0x08,0xe9,0xab,0x04,
- 0x8b,0x54,0x20,0xec,0x8a,0xc8,0xf6,0xc3,0x02,0x75,0x42,0xf6,
- 0xc3,0x08,0x75,0x0e,0xeb,0x69,0x90,0xc7,0x04,0x20,0x04,0xfb,
- 0x81,0xc6,0x80,0x00,0xff,0x24,0xf6,0xc1,0x04,0x74,0x27,0x80,
- 0x64,0x50,0xf7,0xf6,0x44,0x51,0x02,0x74,0x13,0xf6,0x44,0x29,
- 0x10,0x74,0x0d,0x8a,0x44,0x5d,0x83,0xc2,0x02,0xee,0x83,0xea,
- 0x02,0xe9,0x49,0x04,0x8a,0x44,0x5c,0x83,0xc2,0x02,0xee,0x83,
- 0xea,0x02,0xe9,0x3c,0x04,0xf6,0x44,0x50,0x04,0x75,0x28,0x83,
- 0x7c,0x24,0xff,0x74,0x1f,0xa1,0x00,0x0e,0x2b,0x44,0x26,0x3d,
- 0x64,0x00,0x77,0x14,0xb0,0x05,0xee,0x8a,0x44,0x75,0x24,0xef,
- 0x88,0x44,0x75,0xee,0x80,0x64,0x50,0xfd,0x80,0x64,0x4b,0xfd,
- 0xe9,0x0e,0x04,0xb0,0x01,0xee,0x90,0x90,0x90,0xec,0xa8,0x01,
- 0x74,0x25,0xb0,0x05,0xee,0x8a,0x44,0x75,0x0c,0x10,0x88,0x44,
- 0x75,0xee,0xa1,0x00,0x0e,0x03,0x44,0x24,0x89,0x44,0x26,0x80,
- 0x64,0x50,0xfb,0x80,0x64,0x4b,0xfb,0x80,0x4c,0x50,0x02,0x80,
- 0x4c,0x4b,0x02,0xe9,0xdb,0x03,0xfa,0x8b,0x54,0x20,0xec,0x8a,
- 0xc8,0x22,0x44,0x52,0x3a,0x44,0x53,0x75,0x19,0x8b,0x7c,0x0c,
- 0x3b,0x7c,0x0a,0x74,0x18,0x8e,0x44,0x08,0x26,0x8a,0x05,0x47,
- 0x23,0x7c,0x0e,0x89,0x7c,0x0c,0x83,0xc2,0x02,0xee,0xfb,0x81,
- 0xc6,0x80,0x00,0xff,0x24,0xb0,0x01,0xee,0x90,0x90,0x90,0xec,
- 0xa8,0x01,0x74,0x0c,0x80,0x64,0x50,0xef,0x80,0x64,0x4b,0xef,
- 0xc7,0x04,0xc3,0x03,0xfb,0x81,0xc6,0x80,0x00,0xff,0x24,0xfa,
- 0x8b,0x54,0x20,0xec,0x8a,0xc8,0x22,0x44,0x52,0x3a,0x44,0x53,
- 0x75,0x3a,0x8b,0x7c,0x0c,0x3b,0x7c,0x0a,0x74,0x1b,0x8e,0x44,
- 0x08,0x26,0x8a,0x05,0x47,0x23,0x7c,0x0e,0x89,0x7c,0x0c,0x8a,
- 0xd8,0x22,0x5c,0x62,0x32,0xff,0x03,0xdb,0x2e,0xff,0xa7,0xc1,
- 0x01,0xb0,0x01,0xee,0x90,0x90,0x90,0xec,0xa8,0x01,0x74,0x0c,
- 0x80,0x64,0x50,0xef,0x80,0x64,0x4b,0xef,0xc7,0x04,0xc3,0x03,
- 0xf6,0xc1,0x01,0x75,0x07,0xfb,0x81,0xc6,0x80,0x00,0xff,0x24,
- 0xe9,0x61,0x03,0xf6,0x44,0x2a,0x01,0x75,0x03,0xe9,0x39,0x03,
- 0xb0,0x27,0xeb,0x42,0x90,0xf6,0x44,0x2a,0x01,0x75,0x03,0xe9,
- 0x2b,0x03,0xb0,0x28,0xeb,0x34,0x90,0xf6,0x44,0x2a,0x01,0x75,
- 0x03,0xe9,0x1d,0x03,0xb0,0x21,0xeb,0x26,0x90,0xf6,0x44,0x2a,
- 0x01,0x75,0x03,0xe9,0x0f,0x03,0xb0,0x29,0xeb,0x18,0x90,0xf6,
- 0x44,0x2a,0x01,0x75,0x03,0xe9,0x01,0x03,0xb0,0x5e,0xeb,0x0a,
- 0x90,0xf6,0x44,0x2a,0x01,0x75,0x03,0xe9,0xf3,0x02,0x88,0x44,
- 0x61,0xb0,0x5c,0x83,0xc2,0x02,0xee,0x83,0xea,0x02,0x80,0x4c,
- 0x50,0x40,0xc7,0x04,0xc6,0x05,0xc7,0x44,0x02,0xc6,0x05,0xe9,
- 0xcb,0x02,0xfa,0x8b,0x54,0x20,0xec,0x8a,0xc8,0x22,0x44,0x52,
- 0x3a,0x44,0x53,0x75,0x12,0x80,0x64,0x50,0xbf,0xc7,0x04,0x03,
- 0x05,0x83,0x44,0x30,0x02,0x8a,0x44,0x61,0xe9,0xb9,0x02,0xe9,
- 0xa7,0x02,0xf6,0x44,0x2a,0x02,0x75,0x03,0xe9,0xaa,0x02,0x2c,
- 0x20,0xe9,0xa5,0x02,0x83,0xc2,0x02,0xee,0x83,0xea,0x02,0xf6,
- 0x44,0x2b,0x40,0x75,0x03,0xe9,0x89,0x02,0xb8,0x7f,0x00,0xe9,
- 0x9b,0x01,0x83,0xc2,0x02,0xee,0x83,0xea,0x02,0xf6,0x44,0x2b,
- 0x80,0x75,0xed,0xe9,0x73,0x02,0x83,0xc2,0x02,0xee,0x83,0xea,
- 0x02,0xf7,0x44,0x30,0xff,0xff,0x74,0x03,0xff,0x4c,0x30,0xf6,
- 0x44,0x2b,0x20,0x75,0x03,0xe9,0x59,0x02,0xb8,0x02,0x00,0xe9,
- 0x6b,0x01,0xb3,0x18,0x22,0x5c,0x2b,0x75,0x16,0x83,0xc2,0x02,
- 0xee,0x83,0xea,0x02,0x8b,0x44,0x30,0x05,0x08,0x00,0x25,0xf8,
- 0xff,0x89,0x44,0x30,0xe9,0x36,0x02,0x80,0xfb,0x18,0x75,0x57,
- 0xb0,0x20,0x83,0xc2,0x02,0xee,0x83,0xea,0x02,0x8b,0x44,0x30,
- 0x8b,0xd8,0x05,0x08,0x00,0x25,0xf8,0xff,0x89,0x44,0x30,0x2b,
- 0xc3,0x48,0x74,0x38,0x89,0x44,0x32,0x80,0x4c,0x50,0x40,0xc7,
- 0x44,0x02,0x8f,0x06,0xc7,0x04,0x8f,0x06,0xe9,0x02,0x02,0xfa,
- 0x8b,0x54,0x20,0xec,0x8a,0xc8,0x22,0x44,0x52,0x3a,0x44,0x53,
- 0x75,0x16,0xb0,0x20,0x83,0xc2,0x02,0xee,0x83,0xea,0x02,0xff,
- 0x4c,0x32,0x75,0x08,0x80,0x64,0x50,0xbf,0xc7,0x04,0x03,0x05,
- 0xe9,0xda,0x01,0x83,0xc2,0x02,0xee,0x83,0xea,0x02,0x80,0xfb,
- 0x08,0x75,0x18,0x8b,0x44,0x30,0x8b,0xd8,0x05,0x08,0x00,0x25,
- 0xf8,0xff,0x89,0x44,0x30,0x2b,0xc3,0x3d,0x05,0x00,0x7c,0xdc,
- 0xe9,0xce,0x00,0x8b,0x44,0x30,0x8b,0xd8,0x05,0x08,0x00,0x25,
- 0xf8,0xff,0x89,0x44,0x30,0xb8,0x02,0x00,0xe9,0xba,0x00,0xf6,
- 0x44,0x2a,0x20,0x75,0x43,0xf6,0x44,0x2a,0x04,0x74,0x42,0xf6,
- 0x44,0x2a,0x10,0x74,0x07,0xf7,0x44,0x30,0xff,0xff,0x74,0x30,
- 0xb0,0x0d,0x83,0xc2,0x02,0xee,0x83,0xea,0x02,0x80,0x4c,0x50,
- 0x40,0xc7,0x04,0x21,0x07,0xc7,0x44,0x02,0x21,0x07,0xe9,0x70,
- 0x01,0xfa,0x8b,0x54,0x20,0xec,0x8a,0xc8,0x22,0x44,0x52,0x3a,
- 0x44,0x53,0x75,0x1c,0x80,0x64,0x50,0xbf,0xc7,0x04,0x03,0x05,
- 0xb0,0x0a,0xeb,0x2b,0x90,0xb0,0x0a,0x83,0xc2,0x02,0xee,0x83,
- 0xea,0x02,0xf6,0x44,0x2b,0x01,0x75,0x03,0xe9,0x42,0x01,0xb8,
- 0x05,0x00,0xeb,0x55,0x90,0xf6,0x44,0x2a,0x08,0x75,0xe2,0xf6,
- 0x44,0x2a,0x10,0x74,0x06,0x83,0x7c,0x30,0x00,0x74,0x13,0x83,
- 0xc2,0x02,0xee,0x83,0xea,0x02,0xb3,0x06,0x22,0x5c,0x2b,0x75,
- 0x08,0xc7,0x44,0x30,0x00,0x00,0xe9,0x14,0x01,0x80,0xfb,0x02,
- 0x75,0x14,0x8b,0x44,0x30,0xc1,0xe8,0x04,0x05,0x03,0x00,0x3d,
- 0x06,0x00,0x72,0x14,0xb8,0x06,0x00,0xeb,0x0f,0x90,0x80,0xfb,
- 0x04,0x75,0x06,0xb8,0x05,0x00,0xeb,0x04,0x90,0xb8,0x09,0x00,
- 0xc7,0x44,0x30,0x00,0x00,0xf6,0x44,0x2a,0x40,0x74,0x45,0x3d,
- 0x20,0x00,0x77,0x40,0xbb,0x01,0x00,0x3d,0x03,0x00,0x7e,0x03,
- 0xbb,0x02,0x00,0x89,0x5c,0x32,0x80,0x4c,0x50,0x40,0xc7,0x44,
- 0x02,0xd2,0x07,0xc7,0x04,0xd2,0x07,0xe9,0xbf,0x00,0xfa,0x8b,
- 0x54,0x20,0xec,0x8a,0xc8,0x22,0x44,0x52,0x3a,0x44,0x53,0x75,
- 0x10,0x8a,0x44,0x60,0x83,0xc2,0x02,0xee,0x83,0xea,0x02,0x83,
- 0x6c,0x32,0x01,0x7e,0x50,0xe9,0x9d,0x00,0x05,0x06,0x00,0x03,
- 0xc0,0x89,0x44,0x32,0x80,0x4c,0x50,0x40,0xc7,0x44,0x02,0x0c,
- 0x08,0xc7,0x04,0x0c,0x08,0xe9,0x85,0x00,0xfa,0x8b,0x54,0x20,
- 0xec,0x8a,0xc8,0xb0,0x01,0xee,0x90,0x90,0x90,0xec,0xa8,0x01,
- 0x74,0x0f,0xa1,0x00,0x0e,0x01,0x44,0x32,0xc7,0x44,0x02,0x30,
- 0x08,0xc7,0x04,0x30,0x08,0xeb,0x62,0x90,0x8b,0x54,0x20,0xec,
- 0x8a,0xc8,0xa1,0x00,0x0e,0x2b,0x44,0x32,0x3d,0xe8,0x03,0x77,
- 0xec,0x80,0x64,0x50,0xbf,0xc7,0x04,0x03,0x05,0xeb,0x46,0x90,
- 0xb0,0x01,0xee,0x90,0x90,0x90,0xec,0xa8,0x01,0x74,0x3a,0x80,
- 0x64,0x50,0xef,0x80,0x64,0x4b,0xef,0xc7,0x04,0xb3,0x08,0xeb,
- 0x2c,0x90,0xfa,0x8b,0x54,0x20,0xec,0x8a,0xc8,0x22,0x44,0x52,
- 0x3a,0x44,0x53,0x75,0x1c,0x8b,0x7c,0x0c,0x3b,0x7c,0x0a,0x74,
- 0xcf,0x8e,0x44,0x08,0x26,0x8a,0x05,0x47,0x23,0x7c,0x0e,0x89,
- 0x7c,0x0c,0x83,0xc2,0x02,0xee,0x83,0xea,0x02,0xf6,0xc1,0x01,
- 0x75,0x26,0xfb,0x81,0xc6,0x80,0x00,0xff,0x24,0xff,0x44,0x30,
- 0x83,0xc2,0x02,0xee,0x83,0xea,0x02,0xf6,0xc1,0x01,0x75,0x10,
- 0xfb,0x81,0xc6,0x80,0x00,0xff,0x24,0xfa,0x8b,0x54,0x20,0xec,
- 0xa8,0x01,0x74,0xda,0xc6,0x44,0x49,0x02,0x8b,0x7c,0x12,0x8e,
- 0x44,0x10,0xb0,0x01,0xee,0x90,0x90,0x90,0xec,0x8a,0xe0,0x90,
- 0xb0,0x30,0xee,0x83,0xc2,0x02,0x90,0xec,0x83,0xea,0x02,0x23,
- 0x44,0x34,0xff,0x64,0x06,0xb3,0x1c,0x22,0x5c,0x51,0x75,0x1a,
- 0xf6,0x44,0x29,0x04,0x74,0x21,0xf6,0x44,0x29,0x20,0x75,0x2b,
- 0x80,0x7c,0x5e,0x00,0x75,0x1d,0xc7,0x44,0x06,0x58,0x0a,0xe9,
- 0x56,0x01,0xf6,0xc3,0x10,0x75,0x2e,0xf6,0xc3,0x04,0x75,0x74,
- 0xeb,0x6b,0x90,0xc7,0x44,0x06,0x62,0x0a,0xe9,0x4b,0x01,0xc7,
- 0x44,0x06,0x53,0x0a,0xe9,0x34,0x01,0x80,0x7c,0x5e,0x00,0x75,
- 0x08,0xc7,0x44,0x06,0xca,0x09,0xe9,0x9d,0x00,0xc7,0x44,0x06,
- 0xc5,0x09,0xe9,0x90,0x00,0x0a,0xc0,0x74,0x2a,0xfe,0x4c,0x63,
- 0x74,0x1a,0x80,0xe3,0xef,0x75,0xc4,0xf6,0x44,0x29,0x04,0x74,
- 0x21,0xf6,0x44,0x29,0x20,0x75,0x21,0x80,0x7c,0x5e,0x00,0x75,
- 0x18,0xe9,0x00,0x01,0x80,0x64,0x51,0xef,0x80,0xe3,0xef,0x75,
- 0xa6,0xeb,0x85,0x80,0x64,0x51,0xef,0xe9,0x06,0x01,0xe9,0xf5,
- 0x00,0xe9,0xe3,0x00,0x80,0x7c,0x5e,0x00,0x75,0x4f,0xeb,0x52,
- 0x90,0x80,0x64,0x51,0xf7,0xe9,0xe2,0x00,0x80,0x64,0x53,0x3f,
- 0x80,0x64,0x54,0xfe,0x80,0x4c,0x58,0x01,0x80,0x64,0x51,0xfb,
- 0xf6,0x44,0x29,0x40,0x75,0x2c,0x3a,0x44,0x5d,0x74,0x27,0x3a,
- 0x44,0x5c,0x74,0x22,0xf6,0x44,0x29,0x20,0x74,0x0a,0x3a,0x44,
- 0x5a,0x74,0x17,0x3a,0x44,0x5b,0x74,0x12,0xf6,0x44,0x5e,0xff,
- 0x74,0x09,0x3a,0x44,0x5e,0x75,0x04,0x80,0x4c,0x51,0x08,0xe9,
- 0xa0,0x00,0xe9,0xab,0x00,0x3a,0x44,0x5e,0x74,0x7d,0x3a,0x44,
- 0x5c,0x74,0x3d,0x3a,0x44,0x5d,0x74,0x55,0x3a,0x44,0x5a,0x74,
- 0x08,0x3a,0x44,0x5b,0x74,0x18,0xe9,0x81,0x00,0xf6,0x44,0x53,
- 0x40,0x74,0x07,0x80,0x64,0x53,0xbf,0xe9,0x82,0x00,0x3a,0x44,
- 0x5b,0x74,0x03,0xeb,0x7b,0x90,0x80,0x4c,0x53,0x40,0xf6,0x44,
- 0x29,0x08,0x74,0x70,0x80,0x4c,0x51,0x04,0xc7,0x44,0x06,0xe1,
- 0x08,0xeb,0x65,0x90,0xf6,0x44,0x53,0x80,0x74,0x0f,0x80,0x64,
- 0x53,0x7f,0x80,0x64,0x54,0xfe,0x80,0x4c,0x58,0x01,0xeb,0x50,
- 0x90,0x3a,0x44,0x5d,0x74,0x03,0xeb,0x48,0x90,0x80,0x4c,0x53,
- 0x80,0x80,0x4c,0x54,0x01,0x80,0x4c,0x58,0x01,0xf6,0x44,0x29,
- 0x08,0x74,0x35,0x80,0x4c,0x51,0x04,0xc7,0x44,0x06,0xe1,0x08,
- 0xeb,0x2a,0x90,0x80,0x4c,0x51,0x08,0xc7,0x44,0x06,0xe1,0x08,
- 0xeb,0x10,0x90,0x3a,0x44,0x5e,0x74,0xef,0x3a,0x44,0x5c,0x74,
- 0xaf,0x3a,0x44,0x5d,0x74,0xc7,0x3d,0xff,0x00,0x73,0x26,0xaa,
- 0x23,0x7c,0x16,0x3b,0x7c,0x14,0x74,0x4f,0xec,0xa8,0x01,0x74,
- 0x03,0xe9,0x4e,0xfe,0x89,0x7c,0x12,0x2b,0x7c,0x14,0x23,0x7c,
- 0x16,0x3b,0x7c,0x1c,0x73,0x46,0xfb,0x81,0xc6,0x80,0x00,0xff,
- 0x24,0x0a,0xe4,0x75,0x1e,0xb3,0x0c,0x22,0x5c,0x28,0x80,0xfb,
- 0x08,0x75,0xcc,0xaa,0x23,0x7c,0x16,0x3b,0x7c,0x14,0x74,0x1b,
- 0xaa,0x23,0x7c,0x16,0x3b,0x7c,0x14,0x74,0x12,0xeb,0xc1,0xf6,
- 0x44,0x28,0x04,0x75,0xbb,0xf6,0x44,0x28,0x08,0x75,0x50,0x32,
- 0xc0,0xeb,0xa8,0x4f,0x23,0x7c,0x16,0x89,0x7c,0x12,0xc6,0x44,
- 0x59,0x01,0xeb,0xa4,0xf6,0x44,0x51,0x02,0x74,0x07,0xfb,0x81,
- 0xc6,0x80,0x00,0xff,0x24,0x80,0x4c,0x51,0x02,0xb0,0x05,0xee,
- 0xb0,0x82,0x22,0x44,0x5f,0xf6,0xd0,0x22,0x44,0x75,0x88,0x44,
- 0x75,0xee,0xf6,0x44,0x29,0x10,0x74,0x10,0x80,0x4c,0x54,0x04,
- 0x80,0x4c,0x58,0x04,0x80,0x74,0x50,0x08,0xc7,0x04,0xc3,0x03,
- 0xfb,0x81,0xc6,0x80,0x00,0xff,0x24,0x26,0xc6,0x05,0xff,0x47,
- 0x23,0x7c,0x16,0x3b,0x7c,0x14,0x74,0xa7,0x32,0xff,0xf6,0x44,
- 0x29,0x80,0x74,0x0a,0x8a,0xdc,0xc0,0xeb,0x04,0x2e,0x8a,0xbf,
- 0xb1,0x01,0x26,0x88,0x3d,0x47,0x23,0x7c,0x16,0x3b,0x7c,0x14,
- 0x74,0x89,0xaa,0x23,0x7c,0x16,0x3b,0x7c,0x14,0x74,0x80,0xe9,
- 0x2e,0xff,0x1e,0x2e,0x8e,0x1e,0xc1,0x03,0xff,0x06,0x1c,0x0e,
- 0x60,0xbe,0x00,0x14,0xeb,0x0f,0x90,0x1e,0x2e,0x8e,0x1e,0xc1,
- 0x03,0xff,0x06,0x1a,0x0e,0x60,0xbe,0x00,0x10,0xb9,0x08,0x00,
- 0x8b,0x54,0x20,0xb0,0x03,0xee,0x90,0x90,0x32,0xff,0xec,0x8a,
- 0xd8,0x02,0xd8,0x2e,0xff,0xa7,0xa9,0x00,0x81,0xc6,0x00,0x01,
- 0x8b,0x54,0x20,0x0b,0xd2,0xe0,0xe4,0xb8,0x00,0x80,0xba,0x22,
- 0xff,0xef,0x61,0x1f,0xcf,0x81,0xce,0x80,0x00,0x8b,0x54,0x20,
- 0xff,0x06,0x20,0x0e,0xb0,0x01,0xee,0x8a,0x44,0x71,0x24,0xe7,
- 0x88,0x44,0x71,0xee,0xc6,0x44,0x49,0x02,0x80,0x4c,0x50,0x20,
- 0xc7,0x04,0xc3,0x03,0x81,0xe6,0x7f,0xff,0x8b,0x54,0x20,0xeb,
- 0xae,0x81,0xce,0x80,0x00,0x8b,0x54,0x20,0xff,0x06,0x22,0x0e,
- 0xec,0x0a,0xc0,0x79,0x7a,0x80,0x4c,0x51,0x10,0xc7,0x44,0x06,
- 0xe1,0x08,0xc6,0x44,0x63,0x04,0xf6,0x44,0x51,0x04,0x74,0x08,
- 0x80,0x64,0x51,0xfb,0x80,0x64,0x53,0x3f,0xf6,0x44,0x28,0x01,
- 0x75,0x59,0xf6,0x44,0x28,0x02,0x75,0x4f,0x8b,0x7c,0x12,0x8c,
- 0xc3,0x8e,0x44,0x10,0xf6,0x44,0x28,0x08,0x74,0x1e,0xb0,0xff,
- 0xaa,0x23,0x7c,0x16,0x3b,0x7c,0x14,0x74,0x26,0x32,0xc0,0xf6,
- 0x44,0x29,0x80,0x74,0x02,0xb0,0x10,0xaa,0x23,0x7c,0x16,0x3b,
- 0x7c,0x14,0x74,0x13,0x32,0xc0,0xaa,0x23,0x7c,0x16,0x3b,0x7c,
- 0x14,0x74,0x08,0x8e,0xc3,0x89,0x7c,0x12,0xeb,0x15,0x90,0x8e,
- 0xc3,0x4f,0x23,0x7c,0x16,0x89,0x7c,0x12,0xc6,0x44,0x59,0x01,
- 0xeb,0x05,0x90,0x80,0x4c,0x4f,0x01,0xb0,0x10,0xee,0x81,0xe6,
- 0x7f,0xff,0x8b,0x54,0x20,0xe9,0x17,0xff,0xff,0x06,0x1e,0x0e,
- 0xe9,0x10,0xff,0x1e,0x2e,0x8e,0x1e,0xc1,0x03,0x50,0x52,0x55,
- 0x8b,0xec,0x8b,0x46,0x08,0xa3,0x12,0x0e,0x32,0xe4,0xa0,0x22,
- 0x0c,0xa3,0x10,0x0e,0xff,0x06,0x00,0x0e,0x83,0x06,0x0e,0x0e,
- 0x0a,0x83,0x3e,0x04,0x0e,0x00,0x74,0x31,0x8b,0x16,0x00,0x0e,
- 0x2b,0x16,0x02,0x0e,0x3b,0x16,0x04,0x0e,0x72,0x23,0x8b,0x16,
- 0x00,0x0e,0x89,0x16,0x02,0x0e,0x8b,0x16,0x18,0x0d,0x3b,0x16,
- 0x1a,0x0d,0x74,0x11,0x80,0x3e,0x10,0x0c,0x01,0x74,0x16,0xb0,
- 0x00,0x90,0xe6,0x00,0x0c,0x08,0x90,0xe6,0x00,0xb8,0x00,0x80,
- 0xba,0x22,0xff,0xef,0x5d,0x5a,0x58,0x1f,0xcf,0xb0,0x80,0xe6,
- 0x00,0xa0,0x11,0x0c,0x0c,0x10,0xa2,0x11,0x0c,0xeb,0xe6,0x1e,
- 0x2e,0x8e,0x1e,0xc1,0x03,0xff,0x06,0x28,0x0e,0x55,0x8b,0xec,
- 0x8b,0x6e,0x02,0x89,0x2e,0x16,0x0e,0x5d,0x1f,0xcf,0x1e,0x2e,
- 0x8e,0x1e,0xc1,0x03,0xff,0x06,0x24,0x0e,0x55,0x8b,0xec,0x8b,
- 0x6e,0x02,0x89,0x2e,0x14,0x0e,0x5d,0x80,0x3e,0x10,0x0c,0x01,
- 0x75,0x12,0x50,0xa0,0x11,0x0c,0x0c,0x01,0xa2,0x11,0x0c,0xe4,
- 0x00,0x90,0x90,0x24,0x7f,0xe6,0x00,0x58,0x1f,0xcf,0x1e,0x06,
- 0x60,0xb8,0x00,0x80,0xba,0x22,0xff,0xef,0x2e,0x8e,0x1e,0xc1,
- 0x03,0x2e,0x8e,0x06,0xc1,0x03,0x2e,0xff,0x06,0x30,0x0d,0xfc,
- 0xff,0x26,0x2e,0x0e,0x00,0x00,0xfb,0x40,0x43,0x41,0x42,0x46,
- 0x47,0x45,0xeb,0xf6,0xc3,0x00,0x00,0x8f,0x06,0x2e,0x0e,0x2e,
- 0xff,0x06,0x3d,0x0d,0xb8,0x00,0x00,0xba,0x58,0xff,0xef,0xb8,
- 0x00,0xe0,0xba,0x5e,0xff,0xef,0x61,0x07,0x1f,0xcf,0xc2,0xfe,
- 0xff,0x8b,0x7c,0x0a,0x2b,0x7c,0x0c,0x23,0x7c,0x0e,0x3b,0x7c,
- 0x18,0x77,0x2e,0xc6,0x44,0x4d,0x00,0x80,0x4c,0x4f,0x02,0xeb,
- 0x5a,0x90,0x8b,0x7c,0x0a,0x3b,0x7c,0x0c,0x75,0x1b,0x8b,0x3e,
- 0x10,0x0d,0x3b,0x3e,0x12,0x0d,0x75,0x53,0xf6,0x44,0x4b,0xff,
- 0x75,0x4d,0xc6,0x44,0x4c,0x00,0x80,0x4c,0x4f,0x04,0xeb,0x43,
- 0x90,0xf6,0x44,0x50,0x10,0x75,0x3c,0xeb,0x09,0x90,0x8b,0x7c,
- 0x0a,0x2b,0x7c,0x0c,0x74,0x31,0x80,0x4c,0x50,0x10,0x80,0x4c,
- 0x4b,0x10,0xc7,0x04,0xc3,0x03,0xeb,0x23,0x90,0xfa,0x8b,0x36,
- 0x08,0x0e,0x8b,0x54,0x20,0xec,0x8a,0xf8,0x8a,0x5c,0x54,0x32,
- 0xfb,0xf6,0x44,0x4d,0xff,0x75,0x8e,0xf6,0x44,0x4c,0xff,0x75,
- 0xa1,0xf6,0x44,0x50,0x10,0x74,0xc7,0xec,0x32,0xc3,0x22,0xf8,
- 0x83,0x2e,0x10,0x0e,0x01,0x78,0x05,0xd0,0x6c,0x49,0x72,0x45,
- 0x8b,0x7c,0x12,0x2b,0x7c,0x14,0x74,0x22,0x80,0x7c,0x4e,0x00,
- 0x74,0x1c,0x23,0x7c,0x16,0x03,0xff,0x3b,0x7c,0x16,0x73,0x43,
- 0x8b,0x0e,0x0e,0x0e,0x2b,0x4c,0x6e,0x3b,0x4c,0x22,0x73,0x37,
- 0x80,0x7c,0x49,0x00,0x74,0x31,0xf6,0x44,0x51,0x02,0x75,0x3c,
- 0xec,0x32,0xc3,0x22,0xf8,0x80,0xe7,0x38,0xfb,0x89,0x1e,0x30,
- 0x0e,0xbe,0x00,0x10,0xff,0x14,0xeb,0x61,0x90,0xb0,0x01,0xee,
- 0x8a,0x44,0x71,0x0c,0x10,0x88,0x44,0x71,0xee,0x80,0x64,0x50,
- 0xdf,0xc7,0x04,0xc3,0x03,0xeb,0xa5,0xc6,0x44,0x4e,0x00,0x8b,
- 0x0e,0x0e,0x0e,0x89,0x4c,0x6e,0x80,0x4c,0x4f,0x08,0xeb,0xbe,
- 0x8b,0x7c,0x12,0x2b,0x7c,0x14,0x23,0x7c,0x16,0x3b,0x7c,0x1a,
- 0x73,0xb6,0x80,0x64,0x51,0xfd,0xf6,0x44,0x29,0x10,0x74,0x10,
- 0x80,0x64,0x54,0xfb,0x80,0x4c,0x58,0x04,0x80,0x74,0x50,0x08,
- 0xc7,0x04,0xc3,0x03,0xb0,0x05,0xee,0xb0,0x82,0x22,0x44,0x5f,
- 0x0a,0x44,0x75,0x88,0x44,0x75,0xee,0xeb,0x8b,0xfa,0x8b,0x36,
- 0x08,0x0e,0x8b,0x1e,0x30,0x0e,0x8a,0xcb,0xe5,0x80,0x23,0x44,
- 0x2e,0x74,0x02,0xf6,0xd1,0x80,0xe1,0x40,0x0a,0xf9,0x8a,0xdf,
- 0x22,0x5c,0x55,0x30,0x5c,0x54,0x32,0xfb,0x88,0x7c,0x55,0x0a,
- 0x5c,0x58,0x88,0x5c,0x58,0x22,0x5c,0x56,0x75,0x24,0x80,0x7c,
- 0x4f,0x00,0x75,0x22,0xfb,0x03,0x74,0x1e,0x89,0x36,0x08,0x0e,
- 0xff,0x06,0x26,0x0e,0x8b,0x3e,0x12,0x0d,0x3b,0x3e,0x10,0x0d,
- 0x75,0x46,0xbe,0x00,0x10,0xff,0x14,0xe9,0xd3,0xfe,0x80,0x4c,
- 0x4f,0x20,0x8b,0x3e,0x18,0x0d,0x8a,0x44,0x48,0x8a,0x64,0x4f,
- 0x89,0x85,0x00,0x08,0x8a,0x44,0x54,0x8a,0x64,0x57,0x89,0x85,
- 0x02,0x08,0x83,0xc7,0x04,0x81,0xe7,0xfc,0x03,0x3b,0x3e,0x1a,
- 0x0d,0x74,0x13,0x88,0x44,0x57,0xc6,0x44,0x4f,0x00,0x8a,0x44,
- 0x56,0xf6,0xd0,0x20,0x44,0x58,0x89,0x3e,0x18,0x0d,0xeb,0xa4,
- 0xff,0x06,0x2c,0x0e,0xbe,0x00,0x10,0xff,0x14,0xfa,0x8b,0x3e,
- 0x12,0x0d,0x81,0xc7,0x00,0x04,0x8a,0x5d,0x01,0x83,0xe3,0x0f,
- 0x03,0xdb,0x2e,0x8b,0xb7,0x89,0x00,0x8b,0x54,0x20,0x0b,0xd2,
- 0x74,0x0d,0x8a,0x1d,0x83,0xe3,0x1f,0x03,0xdb,0xfa,0x2e,0xff,
- 0xa7,0x9c,0x0f,0xff,0x06,0x2a,0x0e,0x8b,0x3e,0x12,0x0d,0x8b,
- 0x36,0x18,0x0d,0x8b,0x9d,0x00,0x04,0x89,0x9c,0x00,0x08,0x8b,
- 0x9d,0x02,0x04,0x89,0x9c,0x02,0x08,0x83,0xc6,0x04,0x81,0xe6,
- 0xfc,0x03,0x3b,0x36,0x1a,0x0d,0x74,0x04,0x89,0x36,0x18,0x0d,
- 0xfb,0x8b,0x3e,0x12,0x0d,0x83,0xc7,0x04,0x81,0xe7,0xfc,0x03,
- 0x89,0x3e,0x12,0x0d,0xbe,0x00,0x10,0xff,0x14,0xe9,0x1d,0xfe,
- 0xdc,0x0f,0xe4,0x0f,0xec,0x0f,0x0d,0x10,0x1c,0x10,0x57,0x0f,
- 0x2f,0x10,0x57,0x0f,0x3b,0x10,0x54,0x10,0x83,0x10,0xcf,0x10,
- 0xdb,0x10,0xe4,0x10,0xeb,0x10,0x35,0x11,0x7d,0x11,0x83,0x11,
- 0xa1,0x11,0xb9,0x11,0xf2,0x11,0x38,0x12,0x03,0x13,0x0c,0x13,
- 0x57,0x0f,0x57,0x0f,0x57,0x0f,0x57,0x0f,0x57,0x0f,0x57,0x0f,
- 0x57,0x0f,0x57,0x0f,0x8b,0x45,0x02,0x89,0x44,0x1a,0xeb,0xa0,
- 0x8b,0x45,0x02,0x89,0x44,0x1c,0xeb,0x98,0x8b,0x45,0x02,0x8b,
- 0x5c,0x0a,0x2b,0x5c,0x0c,0x23,0x5c,0x0e,0x8b,0x4c,0x0a,0x2b,
- 0xc8,0x23,0x4c,0x0e,0x3b,0xd9,0x76,0x06,0x23,0x44,0x0e,0x89,
- 0x44,0x0c,0xe9,0x77,0xff,0x80,0x4c,0x53,0x80,0x80,0x4c,0x54,
- 0x01,0x80,0x4c,0x58,0x01,0xe9,0x68,0xff,0x80,0x64,0x53,0x3f,
- 0x80,0x64,0x54,0xfe,0x80,0x4c,0x58,0x01,0x80,0x64,0x51,0xfb,
- 0xe9,0x55,0xff,0x8b,0x45,0x02,0x88,0x44,0x5a,0x88,0x64,0x5b,
- 0xe9,0x49,0xff,0x8b,0x45,0x02,0x0b,0xc0,0x74,0x03,0x89,0x44,
- 0x24,0x80,0x4c,0x50,0x04,0x80,0x4c,0x4b,0x04,0xc7,0x04,0xc3,
- 0x03,0xe9,0x30,0xff,0x8b,0x5d,0x02,0xf6,0xd7,0x22,0x7c,0x54,
- 0x0a,0xdf,0x8a,0x44,0x54,0x32,0xc3,0x24,0x82,0x30,0x44,0x54,
- 0xb0,0x05,0xee,0x8a,0x44,0x75,0x32,0xd8,0x8a,0x7c,0x5f,0xf6,
- 0xd7,0x22,0xdf,0x80,0xe3,0x82,0x32,0xc3,0x88,0x44,0x75,0xee,
- 0xe9,0x01,0xff,0x8b,0x5d,0x02,0xf6,0xc7,0x04,0x75,0x08,0x80,
- 0x64,0x53,0x3f,0x80,0x64,0x51,0xfb,0x8a,0x44,0x29,0x32,0xc7,
- 0xa8,0x10,0x74,0x0e,0xf6,0x44,0x51,0x02,0x74,0x08,0x80,0x74,
- 0x50,0x08,0xc7,0x04,0xc3,0x03,0x88,0x5c,0x28,0x88,0x7c,0x29,
- 0xb4,0x60,0xf6,0xc3,0x10,0x74,0x03,0x80,0xcc,0x10,0x8a,0x44,
- 0x62,0xf6,0xc3,0x20,0x74,0x02,0x24,0x7f,0x89,0x44,0x34,0xc7,
- 0x44,0x06,0xe1,0x08,0xe9,0xb5,0xfe,0x8b,0x45,0x02,0x88,0x44,
- 0x5c,0x88,0x64,0x5d,0xe9,0xa9,0xfe,0x8b,0x45,0x02,0x89,0x44,
- 0x18,0xe9,0xa0,0xfe,0xff,0x1e,0x24,0x0d,0xe9,0x99,0xfe,0xf6,
- 0x44,0x51,0x02,0x75,0x41,0x8b,0x44,0x12,0x2b,0x44,0x14,0x23,
- 0x44,0x16,0x3b,0x44,0x1a,0x72,0x33,0x80,0x4c,0x51,0x02,0xf6,
- 0x44,0x29,0x10,0x74,0x10,0x80,0x4c,0x54,0x04,0x80,0x4c,0x58,
- 0x04,0x80,0x74,0x50,0x08,0xc7,0x04,0xc3,0x03,0xf6,0x44,0x5f,
- 0x82,0x74,0x13,0xb0,0x05,0xee,0x8a,0x44,0x75,0xb4,0x82,0x22,
- 0x64,0x5f,0xf6,0xd4,0x22,0xc4,0x88,0x44,0x75,0xee,0xe9,0x4f,
- 0xfe,0xf6,0x44,0x51,0x02,0x74,0x3f,0x8b,0x44,0x12,0x2b,0x44,
- 0x14,0x23,0x44,0x16,0x3b,0x44,0x1c,0x73,0xe9,0x80,0x64,0x51,
- 0xfd,0xf6,0x44,0x29,0x10,0x74,0x10,0x80,0x64,0x54,0xfb,0x80,
- 0x4c,0x58,0x04,0x80,0x74,0x50,0x08,0xc7,0x04,0xc3,0x03,0xf6,
- 0x44,0x5f,0x02,0x74,0x11,0xb0,0x05,0xee,0x8a,0x44,0x75,0xb4,
- 0x82,0x22,0x64,0x5f,0x0a,0xc4,0x88,0x44,0x75,0xee,0xe9,0x07,
- 0xfe,0xe8,0x8a,0x02,0xe9,0x01,0xfe,0x8b,0x45,0x02,0xbb,0x10,
- 0x27,0xf7,0xe3,0xbb,0x0f,0x00,0xf7,0xf3,0xa3,0x06,0x0e,0xba,
- 0x52,0xff,0xef,0xba,0x50,0xff,0xb8,0x00,0x00,0xef,0xe9,0xe3,
- 0xfd,0x8b,0x45,0x02,0x3a,0x06,0x22,0x0c,0x72,0x0c,0x3b,0x06,
- 0x1a,0x0c,0x77,0x06,0xe8,0xab,0x01,0xe9,0xce,0xfd,0xe9,0x9e,
- 0xfd,0x8b,0x45,0x02,0x88,0x44,0x2a,0x88,0x64,0x2b,0x0b,0xc0,
- 0x75,0x07,0x80,0x64,0x50,0xfe,0xeb,0x10,0x90,0xf6,0x44,0x50,
- 0x01,0x75,0x09,0x80,0x4c,0x50,0x01,0xc7,0x44,0x30,0x00,0x00,
- 0xa8,0x80,0x75,0x07,0xc6,0x44,0x60,0x00,0xeb,0x05,0x90,0xc6,
- 0x44,0x60,0x7f,0xc7,0x04,0xc3,0x03,0xe9,0x92,0xfd,0x8b,0x5d,
- 0x02,0xf6,0xd7,0x22,0x7c,0x5f,0x0a,0xdf,0x8a,0xfb,0x88,0x5c,
- 0x5f,0x8a,0x44,0x52,0x8a,0x64,0x53,0x8b,0xcb,0x33,0xc8,0x81,
- 0xe1,0x38,0x38,0x33,0xc1,0x88,0x44,0x52,0x88,0x64,0x53,0xb0,
- 0x05,0xee,0xf6,0xd3,0x22,0x5c,0x54,0xf6,0x44,0x51,0x02,0x75,
- 0x02,0x0a,0xdf,0x8a,0x44,0x75,0x32,0xd8,0x80,0xe3,0x82,0x32,
- 0xc3,0x88,0x44,0x75,0xee,0xe9,0x4c,0xfd,0x8b,0x5d,0x02,0x88,
- 0x5c,0x2c,0x88,0x7c,0x2d,0x8b,0xcb,0x83,0xe3,0x0f,0x03,0xdb,
- 0x80,0x3e,0x10,0x0c,0x01,0x75,0x1f,0xa1,0x0e,0x0c,0x86,0xe0,
- 0x3d,0x32,0x31,0x73,0x15,0xf6,0xc5,0x04,0x75,0x08,0x2e,0x8b,
- 0x9f,0x69,0x01,0xeb,0x1b,0x90,0x2e,0x8b,0x9f,0x89,0x01,0xeb,
- 0x13,0x90,0xf6,0xc5,0x04,0x75,0x08,0x2e,0x8b,0x9f,0x29,0x01,
- 0xeb,0x06,0x90,0x2e,0x8b,0x9f,0x49,0x01,0xb0,0x0c,0xee,0x8a,
- 0xc3,0x88,0x44,0x7c,0xee,0xb0,0x0d,0x90,0x90,0xee,0x8a,0xc7,
- 0x88,0x44,0x7d,0xee,0xb0,0x04,0xee,0xb0,0x44,0xf6,0xc1,0x40,
- 0x74,0x0c,0xf6,0xc1,0x80,0x74,0x05,0x04,0x04,0xeb,0x03,0x90,
- 0x0c,0x08,0xf6,0xc5,0x01,0x74,0x09,0x0c,0x01,0xf6,0xc5,0x02,
- 0x75,0x02,0x0c,0x02,0x88,0x44,0x74,0xee,0xb0,0x03,0x90,0x90,
- 0xee,0x8a,0xd9,0x80,0xe3,0x30,0xc0,0xeb,0x04,0x32,0xff,0x2e,
- 0x8a,0xa7,0xa9,0x01,0x8a,0x44,0x73,0x24,0x3f,0x0a,0xc4,0x88,
- 0x44,0x73,0xee,0x90,0x90,0xb0,0x05,0xee,0xd0,0xec,0x8a,0x44,
- 0x75,0x24,0x9f,0x0a,0xc4,0x88,0x44,0x75,0xee,0x2e,0x8a,0x87,
- 0xad,0x01,0x88,0x44,0x62,0xf6,0x44,0x28,0x20,0x74,0x02,0x24,
- 0x7f,0x88,0x44,0x34,0xe9,0x81,0xfc,0x8a,0x45,0x02,0x88,0x44,
- 0x5e,0xe9,0x78,0xfc,0x8b,0x45,0x02,0xba,0x5a,0xff,0xef,0x9c,
- 0xff,0x36,0x26,0x0d,0xff,0x36,0x24,0x0d,0x1e,0x06,0x60,0x8b,
- 0x36,0x0a,0x0e,0xc7,0x04,0x3f,0x0d,0xe9,0x5a,0xfc,0xb8,0x00,
- 0x00,0x8e,0xc0,0x8b,0xf0,0x8b,0xf8,0x2e,0x8b,0x9c,0x49,0x00,
- 0x83,0xc6,0x02,0x26,0x89,0x1d,0x26,0x8c,0x4d,0x02,0x83,0xc7,
- 0x04,0x81,0xff,0x80,0x00,0x72,0xe8,0x26,0xc7,0x05,0xcb,0x0c,
- 0x26,0x8c,0x4d,0x02,0x83,0xc7,0x04,0x81,0xff,0x00,0x04,0x72,
- 0xee,0xc3,0xc1,0xe0,0x06,0x8b,0xd8,0x8c,0xda,0x81,0xc2,0x00,
- 0x04,0x8b,0xfa,0x8a,0x0e,0x22,0x0c,0xb5,0x00,0xbe,0x00,0x10,
- 0x33,0xc0,0x89,0x44,0x0a,0x89,0x44,0x0c,0x89,0x44,0x12,0x89,
- 0x44,0x14,0x81,0xc6,0x80,0x00,0xe2,0xee,0x89,0x36,0x0a,0x0e,
- 0xb8,0x01,0x00,0x8b,0xd0,0xb3,0x00,0x8a,0x0e,0x22,0x0c,0xb5,
- 0x00,0xbe,0x00,0x10,0x2b,0xda,0x72,0x29,0x89,0x44,0x16,0x81,
- 0xc6,0x80,0x00,0xe2,0xf3,0x8a,0x0e,0x22,0x0c,0xb5,0x00,0xbe,
- 0x00,0x10,0x2b,0xda,0x72,0x13,0x89,0x44,0x0e,0x81,0xc6,0x80,
- 0x00,0xe2,0xf3,0x8b,0xd0,0x03,0xc0,0x81,0xfa,0x00,0x02,0x72,
- 0xca,0x8a,0x0e,0x22,0x0c,0xb5,0x00,0xbe,0x00,0x10,0x89,0x7c,
- 0x10,0x8b,0x44,0x16,0x03,0xf8,0x8b,0xd7,0xc1,0xe0,0x04,0x48,
- 0x89,0x44,0x16,0x81,0xc6,0x80,0x00,0xe2,0xe9,0x8a,0x0e,0x22,
- 0x0c,0xb5,0x00,0xbe,0x00,0x10,0x89,0x7c,0x08,0x8b,0x44,0x0e,
- 0x03,0xf8,0x8b,0xd7,0xc1,0xe0,0x04,0x48,0x89,0x44,0x0e,0x81,
- 0xc6,0x80,0x00,0xe2,0xe9,0xc3,0xc7,0x04,0x20,0x04,0xc7,0x44,
- 0x06,0xe1,0x08,0x8b,0xc6,0x2d,0x00,0x10,0xb1,0x80,0xf6,0xf1,
- 0x88,0x44,0x48,0xc7,0x44,0x0a,0x00,0x00,0xc7,0x44,0x0c,0x00,
- 0x00,0xc7,0x44,0x12,0x00,0x00,0xc7,0x44,0x14,0x00,0x00,0xc7,
- 0x44,0x18,0x00,0x00,0xc7,0x44,0x1a,0x00,0x00,0xc7,0x44,0x1c,
- 0xff,0xff,0x8a,0x5c,0x48,0x83,0xe3,0x0f,0x03,0xdb,0x8b,0x97,
- 0x90,0x0c,0x89,0x54,0x20,0xb8,0x01,0x00,0x8a,0x4c,0x48,0xd3,
- 0xe0,0x89,0x44,0x2e,0xc7,0x44,0x24,0x19,0x00,0xc7,0x44,0x26,
- 0x00,0x00,0xc6,0x44,0x4a,0x00,0xc7,0x44,0x30,0x00,0x00,0xc7,
- 0x44,0x32,0x00,0x00,0xc6,0x44,0x4c,0x00,0xc6,0x44,0x4d,0x00,
- 0xc6,0x44,0x4e,0x00,0xc6,0x44,0x4f,0x00,0xc6,0x44,0x50,0x00,
- 0xc6,0x44,0x4b,0x00,0xc6,0x44,0x51,0x00,0xc6,0x44,0x28,0x00,
- 0xc6,0x44,0x29,0x00,0xc6,0x44,0x2a,0x00,0xc6,0x44,0x2b,0x00,
- 0xc6,0x44,0x54,0x00,0xc6,0x44,0x57,0x00,0xc6,0x44,0x55,0x00,
- 0xc6,0x44,0x56,0x00,0xc6,0x44,0x58,0x00,0xc6,0x44,0x52,0x04,
- 0xc6,0x44,0x53,0x04,0xc6,0x44,0x5f,0x00,0xc6,0x44,0x2c,0x3d,
- 0xc6,0x44,0x2d,0x00,0xc7,0x44,0x34,0xff,0x60,0xc6,0x44,0x62,
- 0xff,0xc6,0x44,0x5d,0x13,0xc6,0x44,0x5c,0x11,0xc6,0x44,0x5e,
- 0x00,0xc6,0x44,0x60,0x23,0xc6,0x44,0x61,0x23,0x0b,0xd2,0x75,
- 0x03,0xe9,0xd9,0x00,0xb0,0x09,0xee,0x8a,0x4c,0x48,0xb0,0x80,
- 0xd2,0xe8,0xee,0xc6,0x44,0x70,0x00,0xb0,0x01,0xee,0xb0,0x11,
- 0x88,0x44,0x71,0xee,0xb0,0x02,0x90,0x90,0xee,0x8a,0x44,0x48,
- 0xc0,0xe0,0x03,0x24,0xf0,0x88,0x44,0x72,0xee,0xb0,0x03,0x90,
- 0x90,0xee,0xb0,0xc0,0x88,0x44,0x73,0xee,0xb0,0x04,0x90,0x90,
- 0xee,0xb0,0x44,0x88,0x44,0x74,0xee,0xb0,0x05,0x90,0xee,0xb0,
- 0x60,0x88,0x44,0x75,0xee,0xc6,0x44,0x76,0x00,0xc6,0x44,0x77,
- 0x00,0xc6,0x44,0x78,0x00,0xb0,0x09,0xee,0xb0,0x09,0x88,0x44,
- 0x79,0xee,0xc6,0x44,0x7a,0x00,0xb0,0x0b,0xee,0xb0,0x52,0x88,
- 0x44,0x7b,0xee,0x80,0x3e,0x10,0x0c,0x01,0x75,0x21,0xa1,0x0e,
- 0x0c,0x86,0xe0,0x3d,0x32,0x31,0x73,0x17,0xb0,0x0c,0xee,0xb0,
- 0x18,0x88,0x44,0x7c,0xee,0xb0,0x0d,0x90,0x90,0xee,0xb0,0x00,
- 0x88,0x44,0x7d,0xee,0xeb,0x15,0x90,0xb0,0x0c,0xee,0xb0,0x16,
- 0x88,0x44,0x7c,0xee,0xb0,0x0d,0x90,0x90,0xee,0xb0,0x00,0x88,
- 0x44,0x7d,0xee,0xb0,0x0e,0x90,0x90,0xee,0xb0,0x03,0x88,0x44,
- 0x7e,0xee,0xb0,0x0f,0x90,0x90,0xee,0xb0,0x80,0x88,0x44,0x7f,
- 0xee,0xb0,0x03,0x90,0x90,0xee,0x8a,0x44,0x73,0x0c,0x01,0x88,
- 0x44,0x73,0xee,0x90,0x90,0xb0,0x05,0xee,0x8a,0x44,0x75,0x0c,
- 0x08,0x88,0x44,0x75,0xee,0xc3,0xfa,0x8c,0xd8,0x25,0x00,0xf0,
- 0x8e,0xd0,0xbc,0xfe,0x1f,0x8c,0xd8,0x25,0x00,0xf0,0x8e,0xd8,
- 0x80,0x3e,0x40,0x0d,0x01,0x75,0x51,0xa1,0x0e,0x0c,0x86,0xe0,
- 0x3d,0x30,0x32,0x73,0x47,0x8b,0x1e,0x20,0x0c,0x8a,0x16,0x23,
- 0x0c,0xc6,0x06,0x23,0x0c,0x00,0x83,0xfb,0x00,0x74,0x07,0xfe,
- 0xca,0xc6,0x06,0x23,0x0c,0x01,0x88,0x16,0x22,0x0c,0xbe,0x10,
- 0x0c,0xbf,0x90,0x0c,0xb9,0x08,0x00,0x1e,0x07,0xfc,0xf3,0xa5,
- 0xbf,0xa0,0x0c,0xb8,0x00,0x00,0xb9,0x08,0x00,0xf3,0xab,0xc7,
- 0x06,0x1a,0x0c,0x70,0x00,0xa0,0x40,0x0d,0xa2,0x10,0x0c,0xc6,
- 0x06,0x11,0x0c,0x00,0x2e,0x8c,0x1e,0xc1,0x03,0xc7,0x06,0x18,
- 0x0e,0x02,0x00,0xe8,0xec,0xfc,0xc7,0x06,0x24,0x0d,0x5a,0x0d,
- 0x8c,0x0e,0x26,0x0d,0xc7,0x06,0x18,0x0e,0x06,0x00,0xa1,0x1a,
- 0x0c,0xe8,0x0a,0xfd,0xc7,0x06,0x18,0x0e,0x0a,0x00,0xbe,0x00,
- 0x10,0xc7,0x44,0x1e,0x80,0x00,0xe8,0xa5,0xfd,0x81,0xc6,0x80,
- 0x00,0x81,0xfe,0x00,0x18,0x72,0xee,0xa0,0x22,0x0c,0xb4,0x80,
- 0xf6,0xe4,0xbe,0x00,0x10,0x03,0xf0,0x89,0x36,0x0a,0x0e,0x29,
- 0x44,0x9e,0xc7,0x06,0x00,0x0e,0x00,0x00,0xc7,0x06,0x02,0x0e,
- 0x00,0x00,0xc7,0x06,0x04,0x0e,0x00,0x00,0xc7,0x06,0x06,0x0e,
- 0x9a,0x02,0xba,0x52,0xff,0xa1,0x06,0x0e,0xef,0xba,0x50,0xff,
- 0xb8,0x00,0x00,0xef,0xba,0x56,0xff,0xb8,0x05,0xe0,0xef,0xba,
- 0x5e,0xff,0xb8,0x00,0x40,0xef,0xba,0x66,0xff,0xb8,0x00,0x40,
- 0xef,0xc7,0x06,0x10,0x0d,0x00,0x00,0xc7,0x06,0x12,0x0d,0x00,
- 0x00,0xc7,0x06,0x14,0x0d,0x00,0x04,0xc7,0x06,0x16,0x0d,0xfc,
- 0x03,0xc7,0x06,0x18,0x0d,0x00,0x00,0xc7,0x06,0x1a,0x0d,0x00,
- 0x00,0xc7,0x06,0x1c,0x0d,0x00,0x08,0xc7,0x06,0x1e,0x0d,0xfc,
- 0x03,0xb0,0x00,0x90,0xe6,0x00,0xc7,0x06,0x18,0x0e,0x32,0x00,
- 0xba,0x38,0xff,0xb8,0x11,0x00,0xef,0xba,0x3a,0xff,0xb8,0x08,
- 0x00,0xef,0xba,0x3c,0xff,0xb8,0x08,0x00,0xef,0xba,0x3e,0xff,
- 0xb8,0x08,0x00,0x80,0x3e,0x22,0x0c,0x08,0x76,0x03,0xb8,0x12,
- 0x00,0xef,0xba,0x32,0xff,0xb8,0x05,0x00,0xef,0xba,0x28,0xff,
- 0xb8,0x6c,0x00,0xef,0xba,0x22,0xff,0xb8,0x00,0x80,0xef,0xc7,
- 0x06,0x18,0x0e,0x33,0x00,0xc7,0x06,0x20,0x0d,0x4f,0x00,0xc7,
- 0x06,0x21,0x0d,0x53,0x00,0x8b,0x36,0x0a,0x0e,0xc7,0x04,0x3c,
- 0x0d,0xc7,0x06,0x08,0x0e,0x00,0x10,0xe9,0x63,0xf6,0x40,0x28,
- 0x23,0x29,0x20,0x24,0x49,0x64,0x3a,0x20,0x78,0x61,0x63,0x6f,
- 0x6f,0x6b,0x2e,0x61,0x73,0x6d,0x2c,0x76,0x20,0x37,0x2e,0x32,
- 0x35,0x20,0x31,0x39,0x39,0x35,0x2f,0x30,0x31,0x2f,0x31,0x32,
- 0x20,0x32,0x30,0x3a,0x35,0x39,0x3a,0x32,0x31,0x20,0x6d,0x69,
- 0x6c,0x74,0x20,0x45,0x78,0x70,0x20,0x24,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
-};
-
-static unsigned pcxx_ncook=sizeof(pcxx_cook);
diff --git a/sys/dev/dgb/dgm.c b/sys/dev/dgb/dgm.c
deleted file mode 100644
index 18122f00db65..000000000000
--- a/sys/dev/dgb/dgm.c
+++ /dev/null
@@ -1,2002 +0,0 @@
-/*-
- * $FreeBSD$
- *
- * This driver and the associated header files support the ISA PC/Xem
- * Digiboards. Its evolutionary roots are described below.
- * Jack O'Neill <jack@diamond.xtalwind.net>
- *
- * Digiboard driver.
- *
- * Stage 1. "Better than nothing".
- * Stage 2. "Gee, it works!".
- *
- * Based on sio driver by Bruce Evans and on Linux driver by Troy
- * De Jongh <troyd@digibd.com> or <troyd@skypoint.com>
- * which is under GNU General Public License version 2 so this driver
- * is forced to be under GPL 2 too.
- *
- * Written by Serge Babkin,
- * Joint Stock Commercial Bank "Chelindbank"
- * (Chelyabinsk, Russia)
- * babkin@hq.icb.chel.su
- *
- * Assorted hacks to make it more functional and working under 3.0-current.
- * Fixed broken routines to prevent processes hanging on closed (thanks
- * to Bruce for his patience and assistance). Thanks also to Maxim Bolotin
- * <max@run.net> for his patches which did most of the work to get this
- * running under 2.2/3.0-current.
- * Implemented ioctls: TIOCMSDTRWAIT, TIOCMGDTRWAIT, TIOCTIMESTAMP &
- * TIOCDCDTIMESTAMP.
- * Sysctl debug flag is now a bitflag, to filter noise during debugging.
- * David L. Nugent <davidn@blaze.net.au>
- */
-
-#include "opt_compat.h"
-
-#include "dgm.h"
-
-/* Helg: i.e.25 times per sec board will be polled */
-#define POLLSPERSEC 25
-/* How many charactes can we write to input tty rawq */
-#define DGB_IBUFSIZE (TTYHOG-100)
-
-/* the overall number of ports controlled by this driver */
-
-#ifndef NDGMPORTS
-# define NDGMPORTS (NDGM*64)
-#endif
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/tty.h>
-#include <sys/proc.h>
-#include <sys/conf.h>
-#include <sys/dkstat.h>
-#include <sys/fcntl.h>
-#include <sys/kernel.h>
-#include <sys/sysctl.h>
-
-#include <machine/clock.h>
-
-#include <vm/vm.h>
-#include <vm/pmap.h>
-
-#include <i386/isa/isa_device.h>
-
-#include <gnu/i386/isa/dgmfep.h>
-#include <gnu/i386/isa/dgmbios.h>
-#include <gnu/i386/isa/dgmreg.h>
-
-#define CALLOUT_MASK 0x40000
-#define CONTROL_MASK 0xC0
-#define CONTROL_INIT_STATE 0x40
-#define CONTROL_LOCK_STATE 0x80
-#define UNIT_MASK 0x30000
-#define PORT_MASK 0x3F
-#define DEV_TO_UNIT(dev) (MINOR_TO_UNIT(minor(dev)))
-#define MINOR_MAGIC_MASK (CALLOUT_MASK | CONTROL_MASK)
-#define MINOR_TO_UNIT(mynor) (((mynor) & UNIT_MASK)>>16)
-#define MINOR_TO_PORT(mynor) ((mynor) & PORT_MASK)
-
-/* types. XXX - should be elsewhere */
-typedef u_char bool_t; /* boolean */
-
-/* digiboard port structure */
-struct dgm_p {
- bool_t status;
-
- u_char unit; /* board unit number */
- u_char pnum; /* port number */
- u_char omodem; /* FEP output modem status */
- u_char imodem; /* FEP input modem status */
- u_char modemfake; /* Modem values to be forced */
- u_char modem; /* Force values */
- u_char hflow;
- u_char dsr;
- u_char dcd;
- u_char stopc;
- u_char startc;
- u_char stopca;
- u_char startca;
- u_char fepstopc;
- u_char fepstartc;
- u_char fepstopca;
- u_char fepstartca;
- u_char txwin;
- u_char rxwin;
- ushort fepiflag;
- ushort fepcflag;
- ushort fepoflag;
- ushort txbufhead;
- ushort txbufsize;
- ushort rxbufhead;
- ushort rxbufsize;
- int close_delay;
- int count;
- int blocked_open;
- int event;
- int asyncflags;
- u_long statusflags;
- u_char *txptr;
- u_char *rxptr;
- volatile struct board_chan *brdchan;
- struct tty *tty;
-
- bool_t active_out; /* nonzero if the callout device is open */
- u_int wopeners; /* # processes waiting for DCD in open() */
-
- /* Initial state. */
- struct termios it_in; /* should be in struct tty */
- struct termios it_out;
-
- /* Lock state. */
- struct termios lt_in; /* should be in struct tty */
- struct termios lt_out;
-
- bool_t do_timestamp;
- bool_t do_dcd_timestamp;
- struct timeval timestamp;
- struct timeval dcd_timestamp;
-
- /* flags of state, are used in sleep() too */
- u_char closing; /* port is being closed now */
- u_char draining; /* port is being drained now */
- u_char used; /* port is being used now */
- u_char mustdrain; /* data must be waited to drain in dgmparam() */
-};
-
-/* Digiboard per-board structure */
-struct dgm_softc {
- /* struct board_info */
- u_char status; /* status: DISABLED/ENABLED */
- u_char unit; /* unit number */
- u_char type; /* type of card: PCXE, PCXI, PCXEVE */
- u_char altpin; /* do we need alternate pin setting ? */
- int numports; /* number of ports on card */
- int port; /* I/O port */
- u_char *vmem; /* virtual memory address */
- long pmem; /* physical memory address */
- int mem_seg; /* internal memory segment */
- struct dgm_p *ports; /* pointer to array of port descriptors */
- struct tty *ttys; /* pointer to array of TTY structures */
- volatile struct global_data *mailbox;
- };
-
-
-static struct dgm_softc dgm_softc[NDGM];
-static struct dgm_p dgm_ports[NDGMPORTS];
-static struct tty dgm_tty[NDGMPORTS];
-
-int fi(void);
-
-/*
- * The public functions in the com module ought to be declared in a com-driver
- * system header.
- */
-
-/* Interrupt handling entry points. */
-static void dgmpoll __P((void *unit_c));
-
-/* Device switch entry points. */
-#define dgmreset noreset
-#define dgmmmap nommap
-#define dgmstrategy nostrategy
-
-static int dgmattach __P((struct isa_device *dev));
-static int dgmprobe __P((struct isa_device *dev));
-
-static void fepcmd(struct dgm_p *port, unsigned cmd, unsigned op1, unsigned op2,
- unsigned ncmds, unsigned bytecmd);
-
-static void dgmstart __P((struct tty *tp));
-static void dgmstop __P((struct tty *tp, int rw));
-static int dgmparam __P((struct tty *tp, struct termios *t));
-static void dgmhardclose __P((struct dgm_p *port));
-static void dgm_drain_or_flush __P((struct dgm_p *port));
-static int dgmdrain __P((struct dgm_p *port));
-static void dgm_pause __P((void *chan));
-static void wakeflush __P((void *p));
-static void disc_optim __P((struct tty *tp, struct termios *t));
-
-
-struct isa_driver dgmdriver = {
- dgmprobe, dgmattach, "dgm",0
-};
-
-static d_open_t dgmopen;
-static d_close_t dgmclose;
-static d_ioctl_t dgmioctl;
-
-#define CDEV_MAJOR 101
-static struct cdevsw dgm_cdevsw = {
- /* open */ dgmopen,
- /* close */ dgmclose,
- /* read */ ttyread,
- /* write */ ttywrite,
- /* ioctl */ dgmioctl,
- /* poll */ ttypoll,
- /* mmap */ nommap,
- /* strategy */ nostrategy,
- /* name */ "dgm",
- /* maj */ CDEV_MAJOR,
- /* dump */ nodump,
- /* psize */ nopsize,
- /* flags */ D_TTY,
- /* bmaj */ -1
-};
-
-static speed_t dgmdefaultrate = TTYDEF_SPEED;
-
-static struct speedtab dgmspeedtab[] = {
- 0, FEP_B0, /* old (sysV-like) Bx codes */
- 50, FEP_B50,
- 75, FEP_B75,
- 110, FEP_B110,
- 134, FEP_B134,
- 150, FEP_B150,
- 200, FEP_B200,
- 300, FEP_B300,
- 600, FEP_B600,
- 1200, FEP_B1200,
- 1800, FEP_B1800,
- 2400, FEP_B2400,
- 4800, FEP_B4800,
- 9600, FEP_B9600,
- 19200, FEP_B19200,
- 38400, FEP_B38400,
- 57600, (FEP_FASTBAUD|FEP_B50), /* B50 & fast baud table */
- 115200, (FEP_FASTBAUD|FEP_B110), /* B100 & fast baud table */
- -1, -1
-};
-
-static struct dbgflagtbl
-{
- tcflag_t in_mask;
- tcflag_t in_val;
- tcflag_t out_val;
-} dgm_cflags[] =
-{
- { PARODD, PARODD, FEP_PARODD },
- { PARENB, PARENB, FEP_PARENB },
- { CSTOPB, CSTOPB, FEP_CSTOPB },
- { CSIZE, CS5, FEP_CS6 },
- { CSIZE, CS6, FEP_CS6 },
- { CSIZE, CS7, FEP_CS7 },
- { CSIZE, CS8, FEP_CS8 },
- { CLOCAL, CLOCAL, FEP_CLOCAL },
- { (tcflag_t)-1 }
-}, dgm_iflags[] =
-{
- { IGNBRK, IGNBRK, FEP_IGNBRK },
- { BRKINT, BRKINT, FEP_BRKINT },
- { IGNPAR, IGNPAR, FEP_IGNPAR },
- { PARMRK, PARMRK, FEP_PARMRK },
- { INPCK, INPCK, FEP_INPCK },
- { ISTRIP, ISTRIP, FEP_ISTRIP },
- { IXON, IXON, FEP_IXON },
- { IXOFF, IXOFF, FEP_IXOFF },
- { IXANY, IXANY, FEP_IXANY },
- { (tcflag_t)-1 }
-}, dgm_flow[] =
-{
- { CRTSCTS, CRTSCTS, CTS|RTS },
- { CRTSCTS, CCTS_OFLOW, CTS },
- { CRTSCTS, CRTS_IFLOW, RTS },
- { (tcflag_t)-1 }
-};
-
-/* xlat bsd termios flags to dgm sys-v style */
-static tcflag_t
-dgmflags(struct dbgflagtbl *tbl, tcflag_t input)
-{
- tcflag_t output = 0;
- int i;
-
- for (i=0; tbl[i].in_mask != (tcflag_t)-1; i++)
- {
- if ((input & tbl[i].in_mask) == tbl[i].in_val)
- output |= tbl[i].out_val;
- }
- return output;
-}
-
-static int dgmdebug=0;
-SYSCTL_INT(_debug, OID_AUTO, dgm_debug, CTLFLAG_RW, &dgmdebug, 0, "");
-
-static __inline int setwin __P((struct dgm_softc *sc, unsigned addr));
-static __inline void hidewin __P((struct dgm_softc *sc));
-static __inline void towin __P((struct dgm_softc *sc, int win));
-
-/*Helg: to allow recursive dgm...() calls */
-typedef struct
- { /* If we were called and don't want to disturb we need: */
- int port; /* write to this port */
- u_char data; /* this data on exit */
- /* or DATA_WINOFF to close memory window on entry */
- } BoardMemWinState; /* so several channels and even boards can coexist */
-#define DATA_WINOFF 0
-static BoardMemWinState bmws;
-
-/* return current memory window state and close window */
-static BoardMemWinState
-bmws_get(void)
-{
- BoardMemWinState bmwsRet=bmws;
- if(bmws.data!=DATA_WINOFF)
- outb(bmws.port, bmws.data=DATA_WINOFF);
- return bmwsRet;
-}
-
-/* restore memory window state */
-static void
-bmws_set(BoardMemWinState ws)
-{
- if(ws.data != bmws.data || ws.port!=bmws.port ) {
- if(bmws.data!=DATA_WINOFF)
- outb(bmws.port,DATA_WINOFF);
- if(ws.data!=DATA_WINOFF)
- outb(ws.port, ws.data);
- bmws=ws;
- }
-}
-
-static __inline int
-setwin(sc,addr)
- struct dgm_softc *sc;
- unsigned int addr;
-{
- outb(bmws.port=sc->port+1,bmws.data=FEPWIN|(addr >> 15));
- return (addr & 0x7FFF);
-}
-
-static __inline void
-hidewin(sc)
- struct dgm_softc *sc;
-{
- bmws.data=0;
- outb(bmws.port=sc->port+1, bmws.data);
-}
-
-static __inline void
-towin(sc,win)
- struct dgm_softc *sc;
- int win;
-{
- outb(bmws.port=sc->port+1, bmws.data=win);
-}
-
-static int
-dgmprobe(dev)
- struct isa_device *dev;
-{
- struct dgm_softc *sc= &dgm_softc[dev->id_unit];
- int i, v;
- int unit=dev->id_unit;
- static int once;
-
- if (!once++)
- cdevsw_add(&dgm_cdevsw);
-
- sc->unit=dev->id_unit;
- sc->port=dev->id_iobase;
-
- if(dev->id_flags & DGBFLAG_ALTPIN)
- sc->altpin=1;
- else
- sc->altpin=0;
-
- /* left 24 bits only (ISA address) */
- sc->pmem=((intptr_t)(void *)dev->id_maddr & 0xFFFFFF);
-
- DPRINT4(DB_INFO,"dgm%d: port 0x%x mem 0x%lx\n",unit,sc->port,sc->pmem);
-
- outb(sc->port, FEPRST);
- sc->status=DISABLED;
-
- for(i=0; i< 1000; i++) {
- DELAY(1);
- if( (inb(sc->port) & FEPMASK) == FEPRST ) {
- sc->status=ENABLED;
- DPRINT3(DB_EXCEPT,"dgm%d: got reset after %d us\n",unit,i);
- break;
- }
- }
-
- if(sc->status!=ENABLED) {
- DPRINT2(DB_EXCEPT,"dgm%d: failed to respond\n",dev->id_unit);
- return 0;
- }
-
- /* check type of card and get internal memory characteristics */
-
- v = inb(sc->port);
-
- if (!(v & 0x1)) {
- int second;
-
- outb(sc->port, 1);
- second = inb(sc->port);
- printf("dgm%d: PC/Xem (type %d, %d)\n", dev->id_unit, v, second);
- } else
- printf("dgm%d: PC/Xem (type %d)\n", dev->id_unit, v);
- sc->type=PCXEM;
- sc->mem_seg=0x8000;
-
- /* save size of vizible memory segment */
- /* all PCXEMs have a 32k window size */
- dev->id_msize=0x8000;
-
- /* map memory */
- dev->id_maddr=sc->vmem=pmap_mapdev(sc->pmem,dev->id_msize);
-
- outb(sc->port, FEPCLR); /* drop RESET */
- hidewin(sc); /* Helg: to set initial bmws state */
-
- return 4; /* we need I/O space of 4 ports */
-}
-
-static int
-dgmattach(dev)
- struct isa_device *dev;
-{
- int unit=dev->id_unit;
- struct dgm_softc *sc= &dgm_softc[dev->id_unit];
- int i, t;
- u_char *mem;
- u_char *ptr;
- int addr;
- struct dgm_p *port;
- volatile struct board_chan *bc;
- int shrinkmem;
- int lowwater;
- static int nports=0;
-
- if(sc->status!=ENABLED) {
- DPRINT2(DB_EXCEPT,"dbg%d: try to attach a disabled card\n",unit);
- return 0;
- }
-
- mem=sc->vmem;
-
- DPRINT3(DB_INFO,"dgm%d: internal memory segment 0x%x\n",unit,sc->mem_seg);
-
- outb(sc->port, FEPRST); DELAY(1);
-
- for(i=0; (inb(sc->port) & FEPMASK) != FEPRST ; i++) {
- if(i>10000) {
- printf("dgm%d: 1st reset failed\n",dev->id_unit);
- sc->status=DISABLED;
- hidewin(sc);
- return 0;
- }
- DELAY(1);
- }
-
- DPRINT3(DB_INFO,"dgm%d: got reset after %d us\n",unit,i);
-
- t=(((u_long)sc->pmem>>8)) /* disable windowing */;
- outb(sc->port+2,t & 0xFF);
- outb(sc->port+3,t>>8);
-
-
- mem=sc->vmem;
-
- /* very short memory test */
-
- addr=setwin(sc,BOTWIN);
- *(u_long *)(mem+addr) = 0xA55A3CC3;
- if(*(u_long *)(mem+addr)!=0xA55A3CC3) {
- printf("dgm%d: 1st memory test failed\n",dev->id_unit);
- sc->status=DISABLED;
- hidewin(sc);
- return 0;
- }
- addr=setwin(sc,TOPWIN);
- *(u_long *)(mem+addr) = 0x5AA5C33C;
- if(*(u_long *)(mem+addr)!=0x5AA5C33C) {
- printf("dgm%d: 2nd memory test failed\n",dev->id_unit);
- sc->status=DISABLED;
- hidewin(sc);
- return 0;
- }
-
- addr=setwin(sc,BIOSCODE+((0xF000-sc->mem_seg)<<4));
- *(u_long *)(mem+addr) = 0x5AA5C33C;
- if(*(u_long *)(mem+addr)!=0x5AA5C33C) {
- printf("dgm%d: 3rd (BIOS) memory test failed\n",dev->id_unit);
- }
-
- addr=setwin(sc,MISCGLOBAL);
- for(i=0; i<16; i++) {
- mem[addr+i]=0;
- }
-
- addr=setwin(sc,BIOSOFFSET);
- ptr=mem+addr;
- for(i=0; ptr<mem+dev->id_msize; i++){
- *ptr++ = pcem_bios[i];
- }
- ptr=mem+BIOSOFFSET;
- for(i=0; ptr<mem+dev->id_msize; i++){
- if(*ptr++ != pcem_bios[i]){
- printf("Low BIOS load failed\n");
- sc->status = DISABLED;
- hidewin(sc);
- return 0;
- }
- }
- addr=setwin(sc,dev->id_msize);
- ptr =mem+addr;
- for(;i < pcem_nbios; i++){
- *ptr++ = pcem_bios[i];
- }
- ptr=mem;
- for(i = dev->id_msize - BIOSOFFSET; i < pcem_nbios; i++){
- if(*ptr++ != pcem_bios[i]){
- printf("High BIOS load failed\n");
- sc->status = DISABLED;
- hidewin(sc);
- return 0;
- }
- }
- printf("dgm%d: DigiBIOS loaded, initializing",dev->id_unit);
-
- addr=setwin(sc,0);
-
- *(u_int *)(mem+addr+0)=0x0bf00401;
- *(u_int *)(mem+addr+4)=0;
- *(ushort *)(mem+addr+0xc00)=0;
- outb(sc->port, 0);
-
- for(i = 0;*(u_char *)(mem+addr+ 0xc00) != 0x47;i++){
- DELAY(10000);
- if(i> 3000){
- printf("\nBIOS initialize failed(1)\n");
- sc->status = DISABLED;
- hidewin(sc);
- return 0;
- }
- }
-
- if(*(u_char *)(mem+addr+ 0xc01) != 0x44){
- printf("\nBIOS initialize failed(2)\n");
- sc->status = DISABLED;
- hidewin(sc);
- return 0;
- }
- printf(", DigiBIOS running\n");
-
- DELAY(10000);
-
- addr=setwin(sc,BIOSOFFSET);
- ptr=mem+addr;
- for(i=0; i<pcem_ncook; i++){
- *ptr++ = pcem_cook[i];
- }
- ptr=mem+BIOSOFFSET;
- for(i=0; i<pcem_ncook; i++){
- if(*ptr++ != pcem_cook[i]){
- printf("FEP/OS load failed\n");
- sc->status = DISABLED;
- hidewin(sc);
- return 0;
- }
- }
- printf("dgm%d: FEP/OS loaded, initializing",dev->id_unit);
-
- addr=setwin(sc,0);
- *(ushort *)(mem+addr+0xd20)=0;
- *(u_int *)(mem+addr+0xc34)=0xbfc01004;
- *(u_int *)(mem+addr+0xc30)=0x3L;
- outb(sc->port,0);
-
- for(i = 0;*(u_char *)(mem+addr+ 0xd20) != 'O';i++){
- DELAY(10000);
- if(i> 3000){
- printf("\nFEP/OS initialize failed(1)\n");
- sc->status = DISABLED;
- hidewin(sc);
- return 0;
- }
- }
-
- if(*(u_char *)(mem+addr+ 0xd21) != 'S'){
- printf("\nFEP/OS initialize failed(2)\n");
- sc->status = DISABLED;
- hidewin(sc);
- return 0;
- }
- printf(", FEP/OS running\n");
-
- sc->numports= *(ushort *)(mem+setwin(sc,NPORT));
- printf("dgm%d: %d ports\n",unit,sc->numports);
-
- if(sc->numports > MAX_DGM_PORTS) {
- printf("dgm%d: too many ports\n",unit);
- sc->status=DISABLED;
- hidewin(sc);
- return 0;
- }
-
- if(nports+sc->numports>NDGMPORTS) {
- printf("dgm%d: only %d ports are usable\n", unit, NDGMPORTS-nports);
- sc->numports=NDGMPORTS-nports;
- }
-
- /* allocate port and tty structures */
- sc->ports=&dgm_ports[nports];
- sc->ttys=&dgm_tty[nports];
- nports+=sc->numports;
-
- for(i=0; i<sc->numports; i++)
- sc->ports[i].status = ENABLED;
-
- /* We should now init per-port structures */
- setwin(sc,0);
- bc=(volatile struct board_chan *)(mem + CHANSTRUCT);
- sc->mailbox=(volatile struct global_data *)(mem + FEP_GLOBAL);
-
- if(sc->numports<3)
- shrinkmem=1;
- else
- shrinkmem=0;
-
- for(i=0; i<sc->numports; i++, bc++) {
- port= &sc->ports[i];
-
- port->tty=&sc->ttys[i];
- port->unit=unit;
-
- port->brdchan=bc;
-
- port->dcd=CD;
- port->dsr=DSR;
- port->pnum=i;
-
- if(shrinkmem) {
- DPRINT2(DB_INFO,"dgm%d: shrinking memory\n",unit);
- fepcmd(port, SETBUFFER, 32, 0, 0, 0);
- shrinkmem=0;
- }
-
- port->txptr=mem+( ((bc->tseg)<<4) & 0x7FFF );
- port->rxptr=mem+( ((bc->rseg)<<4) & 0x7FFF );
- port->txwin=FEPWIN | ((bc->tseg)>>11);
- port->rxwin=FEPWIN | ((bc->rseg)>>11);
-
- port->txbufhead=0;
- port->rxbufhead=0;
- port->txbufsize=bc->tmax+1;
- port->rxbufsize=bc->rmax+1;
-
- lowwater= (port->txbufsize>=2000) ? 1024 : (port->txbufsize/2);
- setwin(sc,0);
- fepcmd(port, STXLWATER, lowwater, 0, 10, 0);
- fepcmd(port, SRXLWATER, port->rxbufsize/4, 0, 10, 0);
- fepcmd(port, SRXHWATER, 3*port->rxbufsize/4, 0, 10, 0);
-
- bc->edelay=100;
- bc->idata=1;
-
- port->startc=bc->startc;
- port->startca=bc->startca;
- port->stopc=bc->stopc;
- port->stopca=bc->stopca;
-
- /*port->close_delay=50;*/
- port->close_delay=3 * hz;
- port->do_timestamp=0;
- port->do_dcd_timestamp=0;
-
- /*
- * We don't use all the flags from <sys/ttydefaults.h> since they
- * are only relevant for logins. It's important to have echo off
- * initially so that the line doesn't start blathering before the
- * echo flag can be turned off.
- */
- port->it_in.c_iflag = TTYDEF_IFLAG;
- port->it_in.c_oflag = TTYDEF_OFLAG;
- port->it_in.c_cflag = TTYDEF_CFLAG;
- port->it_in.c_lflag = TTYDEF_LFLAG;
- termioschars(&port->it_in);
- port->it_in.c_ispeed = port->it_in.c_ospeed = dgmdefaultrate;
- port->it_out = port->it_in;
- make_dev(&dgm_cdevsw, (unit*65536)+i,
- UID_ROOT, GID_WHEEL, 0600, "ttyM%d%x", unit, i + 0xa0);
- make_dev(&dgm_cdevsw, (unit*65536)+i+64,
- UID_ROOT, GID_WHEEL, 0600, "ttyiM%d%x", unit, i + 0xa0);
- make_dev(&dgm_cdevsw, (unit*65536)+i+128,
- UID_ROOT, GID_WHEEL, 0600, "ttylM%d%x", unit, i + 0xa0);
- make_dev(&dgm_cdevsw, (unit*65536)+i+262144,
- UID_UUCP, GID_DIALER, 0660, "cuaM%d%x", unit, i + 0xa0);
- make_dev(&dgm_cdevsw, (unit*65536)+i+262208,
- UID_UUCP, GID_DIALER, 0660, "cuaiM%d%x", unit, i + 0xa0);
- make_dev(&dgm_cdevsw, (unit*65536)+i+262272,
- UID_UUCP, GID_DIALER, 0660, "cualM%d%x", unit, i + 0xa0);
- }
-
- hidewin(sc);
-
- /* register the polling function */
- timeout(dgmpoll, (void *)unit, hz/POLLSPERSEC);
-
- return 1;
-}
-
-/* ARGSUSED */
-static int
-dgmopen(dev, flag, mode, p)
- dev_t dev;
- int flag;
- int mode;
- struct proc *p;
-{
- struct dgm_softc *sc;
- struct tty *tp;
- int unit;
- int mynor;
- int pnum;
- struct dgm_p *port;
- int s,cs;
- int error;
- volatile struct board_chan *bc;
-
- error=0;
- mynor=minor(dev);
- unit=MINOR_TO_UNIT(mynor);
- pnum=MINOR_TO_PORT(mynor);
-
- if(unit >= NDGM) {
- DPRINT2(DB_EXCEPT,"dgm%d: try to open a nonexisting card\n",unit);
- return ENXIO;
- }
-
- sc=&dgm_softc[unit];
-
- if(sc->status!=ENABLED) {
- DPRINT2(DB_EXCEPT,"dgm%d: try to open a disabled card\n",unit);
- return ENXIO;
- }
-
- if(pnum>=sc->numports) {
- DPRINT3(DB_EXCEPT,"dgm%d: try to open non-existing port %d\n",unit,pnum);
- return ENXIO;
- }
-
- if(mynor & CONTROL_MASK)
- return 0;
-
- tp=&sc->ttys[pnum];
- dev->si_tty = tp;
- port=&sc->ports[pnum];
- bc=port->brdchan;
-
-open_top:
-
- s=spltty();
-
- while(port->closing) {
- error=tsleep(&port->closing, TTOPRI|PCATCH, "dgocl", 0);
-
- if(error) {
- DPRINT4(DB_OPEN,"dgm%d: port%d: tsleep(dgocl) error=%d\n",unit,pnum,error);
- goto out;
- }
- }
-
- if (tp->t_state & TS_ISOPEN) {
- /*
- * The device is open, so everything has been initialized.
- * Handle conflicts.
- */
- if (mynor & CALLOUT_MASK) {
- if (!port->active_out) {
- error = EBUSY;
- DPRINT4(DB_OPEN,"dgm%d: port%d: BUSY error=%d\n",unit,pnum,error);
- goto out;
- }
- } else {
- if (port->active_out) {
- if (flag & O_NONBLOCK) {
- error = EBUSY;
- DPRINT4(DB_OPEN,"dgm%d: port%d: BUSY error=%d\n",unit,pnum,error);
- goto out;
- }
- error = tsleep(&port->active_out,
- TTIPRI | PCATCH, "dgmi", 0);
- if (error != 0) {
- DPRINT4(DB_OPEN,"dgm%d: port%d: tsleep(dgmi) error=%d\n",
- unit,pnum,error);
- goto out;
- }
- splx(s);
- goto open_top;
- }
- }
- if (tp->t_state & TS_XCLUDE &&
- suser(p)) {
- error = EBUSY;
- goto out;
- }
- } else {
- /*
- * The device isn't open, so there are no conflicts.
- * Initialize it. Initialization is done twice in many
- * cases: to preempt sleeping callin opens if we are
- * callout, and to complete a callin open after DCD rises.
- */
- tp->t_oproc=dgmstart;
- tp->t_param=dgmparam;
- tp->t_stop=dgmstop;
- tp->t_dev=dev;
- tp->t_termios= (mynor & CALLOUT_MASK) ?
- port->it_out :
- port->it_in;
-
- cs=splclock();
- setwin(sc,0);
- port->imodem=bc->mstat;
- bc->rout=bc->rin; /* clear input queue */
- bc->idata=1;
-#ifdef PRINT_BUFSIZE
- printf("dgm buffers tx=%x:%x rx=%x:%x\n",bc->tseg,bc->tmax,bc->rseg,bc->rmax);
-#endif
-
- hidewin(sc);
- splx(cs);
-
- port->wopeners++;
- error=dgmparam(tp, &tp->t_termios);
- port->wopeners--;
-
- if(error!=0) {
- DPRINT4(DB_OPEN,"dgm%d: port%d: dgmparam error=%d\n",unit,pnum,error);
- goto out;
- }
-
- /* handle fake DCD for callout devices */
- /* and initial DCD */
-
- if( (port->imodem & port->dcd) || mynor & CALLOUT_MASK )
- linesw[tp->t_line].l_modem(tp,1);
-
- }
-
- /*
- * Wait for DCD if necessary.
- */
- if (!(tp->t_state & TS_CARR_ON) && !(mynor & CALLOUT_MASK)
- && !(tp->t_cflag & CLOCAL) && !(flag & O_NONBLOCK)) {
- ++port->wopeners;
- error = tsleep(TSA_CARR_ON(tp), TTIPRI | PCATCH, "dgdcd", 0);
- --port->wopeners;
- if (error != 0) {
- DPRINT4(DB_OPEN,"dgm%d: port%d: tsleep(dgdcd) error=%d\n",unit,pnum,error);
- goto out;
- }
- splx(s);
- goto open_top;
- }
- error = linesw[tp->t_line].l_open(dev, tp);
- disc_optim(tp,&tp->t_termios);
- DPRINT4(DB_OPEN,"dgm%d: port%d: l_open error=%d\n",unit,pnum,error);
-
- if (tp->t_state & TS_ISOPEN && mynor & CALLOUT_MASK)
- port->active_out = TRUE;
-
- port->used=1;
-
- /* If any port is open (i.e. the open() call is completed for it)
- * the device is busy
- */
-
-out:
- disc_optim(tp,&tp->t_termios);
- splx(s);
-
- if( !(tp->t_state & TS_ISOPEN) && port->wopeners==0 )
- dgmhardclose(port);
-
- DPRINT4(DB_OPEN,"dgm%d: port%d: open() returns %d\n",unit,pnum,error);
-
- return error;
-}
-
-/*ARGSUSED*/
-static int
-dgmclose(dev, flag, mode, p)
- dev_t dev;
- int flag;
- int mode;
- struct proc *p;
-{
- int mynor;
- struct tty *tp;
- int unit, pnum;
- struct dgm_softc *sc;
- struct dgm_p *port;
- int s;
- int i;
-
- mynor=minor(dev);
- if(mynor & CONTROL_MASK)
- return 0;
- unit=MINOR_TO_UNIT(mynor);
- pnum=MINOR_TO_PORT(mynor);
-
- sc=&dgm_softc[unit];
- tp=&sc->ttys[pnum];
- port=sc->ports+pnum;
-
- DPRINT3(DB_CLOSE,"dgm%d: port%d: closing\n",unit,pnum);
-
- DPRINT3(DB_CLOSE,"dgm%d: port%d: draining port\n",unit,pnum);
- dgm_drain_or_flush(port);
-
- s=spltty();
-
- port->closing=1;
- DPRINT3(DB_CLOSE,"dgm%d: port%d: closing line disc\n",unit,pnum);
- linesw[tp->t_line].l_close(tp,flag);
- disc_optim(tp,&tp->t_termios);
-
- DPRINT3(DB_CLOSE,"dgm%d: port%d: hard closing\n",unit,pnum);
- dgmhardclose(port);
- DPRINT3(DB_CLOSE,"dgm%d: port%d: closing tty\n",unit,pnum);
- ttyclose(tp);
- port->closing=0;
- wakeup(&port->closing);
- port->used=0;
-
- /* mark the card idle when all ports are closed */
-
- for(i=0; i<sc->numports; i++)
- if(sc->ports[i].used)
- break;
-
- splx(s);
-
- DPRINT3(DB_CLOSE,"dgm%d: port%d: closed\n",unit,pnum);
-
- wakeup(TSA_CARR_ON(tp));
- wakeup(&port->active_out);
- port->active_out=0;
-
- DPRINT3(DB_CLOSE,"dgm%d: port%d: close exit\n",unit,pnum);
-
- return 0;
-}
-
-static void
-dgmhardclose(port)
- struct dgm_p *port;
-{
- struct dgm_softc *sc=&dgm_softc[port->unit];
- volatile struct board_chan *bc=port->brdchan;
- int cs;
-
- cs=splclock();
- port->do_timestamp = 0;
- setwin(sc,0);
-
- bc->idata=0; bc->iempty=0; bc->ilow=0;
- if(port->tty->t_cflag & HUPCL) {
- port->omodem &= ~(RTS|DTR);
- fepcmd(port, SETMODEM, 0, DTR|RTS, 0, 1);
- }
-
- hidewin(sc);
- splx(cs);
-
- timeout(dgm_pause, &port->brdchan, hz/2);
- tsleep(&port->brdchan, TTIPRI | PCATCH, "dgclo", 0);
-}
-
-static void
-dgm_pause(chan)
- void *chan;
-{
-wakeup((caddr_t)chan);
-}
-
-
-static void
-dgmpoll(unit_c)
- void *unit_c;
-{
- int unit=(int)unit_c;
- int pnum;
- struct dgm_p *port;
- struct dgm_softc *sc=&dgm_softc[unit];
- int head, tail;
- u_char *eventbuf;
- int event, mstat, lstat;
- volatile struct board_chan *bc;
- struct tty *tp;
- int rhead, rtail;
- int whead, wtail;
- int size;
- u_char *ptr;
- int ocount;
- int ibuf_full,obuf_full;
-
- BoardMemWinState ws=bmws_get();
-
- if(sc->status==DISABLED) {
- printf("dgm%d: polling of disabled board stopped\n",unit);
- return;
- }
-
- setwin(sc,0);
-
- head=sc->mailbox->ein;
- tail=sc->mailbox->eout;
-
- while(head!=tail) {
- if(head >= FEP_IMAX-FEP_ISTART
- || tail >= FEP_IMAX-FEP_ISTART
- || (head|tail) & 03 ) {
- printf("dgm%d: event queue's head or tail is wrong! hd=%d,tl=%d\n", unit,head,tail);
- break;
- }
-
- eventbuf=sc->vmem+tail+FEP_ISTART;
- pnum=eventbuf[0];
- event=eventbuf[1];
- mstat=eventbuf[2];
- lstat=eventbuf[3];
-
- port=&sc->ports[pnum];
- bc=port->brdchan;
- tp=&sc->ttys[pnum];
-
- if(pnum>=sc->numports || port->status==DISABLED) {
- printf("dgm%d: port%d: got event on nonexisting port\n",unit,pnum);
- } else if(port->used || port->wopeners>0 ) {
-
- int wrapmask=port->rxbufsize-1;
-
- if( !(event & ALL_IND) )
- printf("dgm%d: port%d: ? event 0x%x mstat 0x%x lstat 0x%x\n",
- unit, pnum, event, mstat, lstat);
-
- if(event & DATA_IND) {
- DPRINT3(DB_DATA,"dgm%d: port%d: DATA_IND\n",unit,pnum);
-
- rhead=bc->rin & wrapmask;
- rtail=bc->rout & wrapmask;
-
- if( !(tp->t_cflag & CREAD) || !port->used ) {
- bc->rout=rhead;
- goto end_of_data;
- }
-
- if(bc->orun) {
- printf("dgm%d: port%d: overrun\n", unit, pnum);
- bc->orun=0;
- }
-
- if(!(tp->t_state & TS_ISOPEN))
- goto end_of_data;
-
- for(ibuf_full=FALSE;rhead!=rtail && !ibuf_full;) {
- DPRINT5(DB_RXDATA,"dgm%d: port%d: p rx head=%d tail=%d\n",
- unit,pnum,rhead,rtail);
-
- if(rhead>rtail)
- size=rhead-rtail;
- else
- size=port->rxbufsize-rtail;
-
- ptr=port->rxptr+rtail;
-
-/* Helg: */
- if( tp->t_rawq.c_cc + size > DGB_IBUFSIZE ) {
- size=DGB_IBUFSIZE-tp->t_rawq.c_cc;
- DPRINT1(DB_RXDATA,"*");
- ibuf_full=TRUE;
- }
-
- if(size) {
- if (tp->t_state & TS_CAN_BYPASS_L_RINT) {
- DPRINT1(DB_RXDATA,"!");
- towin(sc,port->rxwin);
- tk_nin += size;
- tk_rawcc += size;
- tp->t_rawcc += size;
- b_to_q(ptr,size,&tp->t_rawq);
- setwin(sc,0);
- } else {
- int i=size;
- unsigned char chr;
- do {
- towin(sc,port->rxwin);
- chr= *ptr++;
- hidewin(sc);
- (*linesw[tp->t_line].l_rint)(chr, tp);
- } while (--i > 0 );
- setwin(sc,0);
- }
- }
- rtail= (rtail + size) & wrapmask;
- bc->rout=rtail;
- rhead=bc->rin & wrapmask;
- hidewin(sc);
- ttwakeup(tp);
- setwin(sc,0);
- }
- end_of_data: ;
- }
-
- if(event & MODEMCHG_IND) {
- DPRINT3(DB_MODEM,"dgm%d: port%d: MODEMCHG_IND\n",unit,pnum);
- port->imodem=mstat;
- if(mstat & port->dcd) {
- hidewin(sc);
- linesw[tp->t_line].l_modem(tp,1);
- setwin(sc,0);
- wakeup(TSA_CARR_ON(tp));
- } else {
- hidewin(sc);
- linesw[tp->t_line].l_modem(tp,0);
- setwin(sc,0);
- if( port->draining) {
- port->draining=0;
- wakeup(&port->draining);
- }
- }
- }
-
- if(event & BREAK_IND) {
- if((tp->t_state & TS_ISOPEN) && (tp->t_iflag & IGNBRK)) {
- DPRINT3(DB_BREAK,"dgm%d: port%d: BREAK_IND\n",unit,pnum);
- hidewin(sc);
- linesw[tp->t_line].l_rint(TTY_BI, tp);
- setwin(sc,0);
- }
- }
-
-/* Helg: with output flow control */
-
- if(event & (LOWTX_IND | EMPTYTX_IND) ) {
- DPRINT3(DB_TXDATA,"dgm%d: port%d: LOWTX_IND or EMPTYTX_IND\n",unit,pnum);
-
- if( (event & EMPTYTX_IND ) && tp->t_outq.c_cc==0
- && port->draining) {
- port->draining=0;
- wakeup(&port->draining);
- bc->ilow=0; bc->iempty=0;
- } else {
-
- int wrapmask=port->txbufsize-1;
-
- for(obuf_full=FALSE; tp->t_outq.c_cc!=0 && !obuf_full; ) {
- int s;
- /* add "last-minute" data to write buffer */
- if(!(tp->t_state & TS_BUSY)) {
- hidewin(sc);
-#ifndef TS_ASLEEP /* post 2.0.5 FreeBSD */
- ttwwakeup(tp);
-#else
- if(tp->t_outq.c_cc <= tp->t_lowat) {
- if(tp->t_state & TS_ASLEEP) {
- tp->t_state &= ~TS_ASLEEP;
- wakeup(TSA_OLOWAT(tp));
- }
- /* selwakeup(&tp->t_wsel); */
- }
-#endif
- setwin(sc,0);
- }
- s=spltty();
-
- whead=bc->tin & wrapmask;
- wtail=bc->tout & wrapmask;
-
- if(whead<wtail)
- size=wtail-whead-1;
- else {
- size=port->txbufsize-whead;
- if(wtail==0)
- size--;
- }
-
- if(size==0) {
- DPRINT5(DB_WR,"dgm: head=%d tail=%d size=%d full=%d\n",
- whead,wtail,size,obuf_full);
- bc->iempty=1; bc->ilow=1;
- obuf_full=TRUE;
- splx(s);
- break;
- }
-
- towin(sc,port->txwin);
-
- ocount=q_to_b(&tp->t_outq, port->txptr+whead, size);
- whead+=ocount;
-
- setwin(sc,0);
- bc->tin=whead;
- bc->tin=whead & wrapmask;
- splx(s);
- }
-
- if(obuf_full) {
- DPRINT1(DB_WR," +BUSY\n");
- tp->t_state|=TS_BUSY;
- } else {
- DPRINT1(DB_WR," -BUSY\n");
- hidewin(sc);
-#ifndef TS_ASLEEP /* post 2.0.5 FreeBSD */
- /* should clear TS_BUSY before ttwwakeup */
- if(tp->t_state & TS_BUSY) {
- tp->t_state &= ~TS_BUSY;
- linesw[tp->t_line].l_start(tp);
- ttwwakeup(tp);
- }
-#else
- if(tp->t_state & TS_ASLEEP) {
- tp->t_state &= ~TS_ASLEEP;
- wakeup(TSA_OLOWAT(tp));
- }
- tp->t_state &= ~TS_BUSY;
-#endif
- setwin(sc,0);
- }
- }
- }
- bc->idata=1; /* require event on incoming data */
-
- } else {
- bc=port->brdchan;
- DPRINT4(DB_EXCEPT,"dgm%d: port%d: got event 0x%x on closed port\n",
- unit,pnum,event);
- bc->rout=bc->rin;
- bc->idata=bc->iempty=bc->ilow=0;
- }
-
- tail= (tail+4) & (FEP_IMAX-FEP_ISTART-4);
- }
-
- sc->mailbox->eout=tail;
- bmws_set(ws);
-
- timeout(dgmpoll, unit_c, hz/POLLSPERSEC);
-}
-
-static int
-dgmioctl(dev, cmd, data, flag, p)
- dev_t dev;
- u_long cmd;
- caddr_t data;
- int flag;
- struct proc *p;
-{
- struct dgm_softc *sc;
- int unit, pnum;
- struct dgm_p *port;
- int mynor;
- struct tty *tp;
- volatile struct board_chan *bc;
- int error;
- int s,cs;
- int tiocm_xxx;
-
-#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
- u_long oldcmd;
- struct termios term;
-#endif
-
- BoardMemWinState ws=bmws_get();
-
- mynor=minor(dev);
- unit=MINOR_TO_UNIT(mynor);
- pnum=MINOR_TO_PORT(mynor);
-
- sc=&dgm_softc[unit];
- port=&sc->ports[pnum];
- tp=&sc->ttys[pnum];
- bc=port->brdchan;
-
- if (mynor & CONTROL_MASK) {
- struct termios *ct;
-
- switch (mynor & CONTROL_MASK) {
- case CONTROL_INIT_STATE:
- ct = mynor & CALLOUT_MASK ? &port->it_out : &port->it_in;
- break;
- case CONTROL_LOCK_STATE:
- ct = mynor & CALLOUT_MASK ? &port->lt_out : &port->lt_in;
- break;
- default:
- return (ENODEV); /* /dev/nodev */
- }
- switch (cmd) {
- case TIOCSETA:
- error = suser(p);
- if (error != 0)
- return (error);
- *ct = *(struct termios *)data;
- return (0);
- case TIOCGETA:
- *(struct termios *)data = *ct;
- return (0);
- case TIOCGETD:
- *(int *)data = TTYDISC;
- return (0);
- case TIOCGWINSZ:
- bzero(data, sizeof(struct winsize));
- return (0);
- default:
- return (ENOTTY);
- }
- }
-
-#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
- term = tp->t_termios;
- if (cmd == TIOCSETA || cmd == TIOCSETAW || cmd == TIOCSETAF) {
- DPRINT6(DB_PARAM,"dgm%d: port%d: dgmioctl-ISNOW c=0x%x i=0x%x l=0x%x\n",unit,pnum,term.c_cflag,term.c_iflag,term.c_lflag);
- }
- oldcmd = cmd;
- error = ttsetcompat(tp, &cmd, data, &term);
- if (error != 0)
- return (error);
- if (cmd != oldcmd)
- data = (caddr_t)&term;
-#endif
-
- if (cmd == TIOCSETA || cmd == TIOCSETAW || cmd == TIOCSETAF) {
- int cc;
- struct termios *dt = (struct termios *)data;
- struct termios *lt = mynor & CALLOUT_MASK
- ? &port->lt_out : &port->lt_in;
-
- DPRINT6(DB_PARAM,"dgm%d: port%d: dgmioctl-TOSET c=0x%x i=0x%x l=0x%x\n",unit,pnum,dt->c_cflag,dt->c_iflag,dt->c_lflag);
- dt->c_iflag = (tp->t_iflag & lt->c_iflag)
- | (dt->c_iflag & ~lt->c_iflag);
- dt->c_oflag = (tp->t_oflag & lt->c_oflag)
- | (dt->c_oflag & ~lt->c_oflag);
- dt->c_cflag = (tp->t_cflag & lt->c_cflag)
- | (dt->c_cflag & ~lt->c_cflag);
- dt->c_lflag = (tp->t_lflag & lt->c_lflag)
- | (dt->c_lflag & ~lt->c_lflag);
- for (cc = 0; cc < NCCS; ++cc)
- if (lt->c_cc[cc] != 0)
- dt->c_cc[cc] = tp->t_cc[cc];
- if (lt->c_ispeed != 0)
- dt->c_ispeed = tp->t_ispeed;
- if (lt->c_ospeed != 0)
- dt->c_ospeed = tp->t_ospeed;
- }
-
- if(cmd==TIOCSTOP) {
- cs=splclock();
- setwin(sc,0);
- fepcmd(port, PAUSETX, 0, 0, 0, 0);
- bmws_set(ws);
- splx(cs);
- return 0;
- } else if(cmd==TIOCSTART) {
- cs=splclock();
- setwin(sc,0);
- fepcmd(port, RESUMETX, 0, 0, 0, 0);
- bmws_set(ws);
- splx(cs);
- return 0;
- }
-
- if(cmd==TIOCSETAW || cmd==TIOCSETAF)
- port->mustdrain=1;
-
- error = linesw[tp->t_line].l_ioctl(tp, cmd, data, flag, p);
- if (error != ENOIOCTL)
- return error;
- s = spltty();
- error = ttioctl(tp, cmd, data, flag);
- disc_optim(tp,&tp->t_termios);
- port->mustdrain=0;
- if (error != ENOIOCTL) {
- splx(s);
- if (cmd == TIOCSETA || cmd == TIOCSETAW || cmd == TIOCSETAF) {
- DPRINT6(DB_PARAM,"dgm%d: port%d: dgmioctl-RES c=0x%x i=0x%x l=0x%x\n",unit,pnum,tp->t_cflag,tp->t_iflag,tp->t_lflag);
- }
- return error;
- }
-
- switch (cmd) {
- case TIOCSBRK:
-/* Helg: commented */
-/* error=dgmdrain(port);*/
-
- if(error!=0) {
- splx(s);
- return error;
- }
-
- cs=splclock();
- setwin(sc,0);
-
- /* now it sends 250 millisecond break because I don't know */
- /* how to send an infinite break */
-
- fepcmd(port, SENDBREAK, 250, 0, 10, 0);
- hidewin(sc);
- splx(cs);
- break;
- case TIOCCBRK:
- /* now it's empty */
- break;
- case TIOCSDTR:
- DPRINT3(DB_MODEM,"dgm%d: port%d: set DTR\n",unit,pnum);
- port->omodem |= DTR;
- cs=splclock();
- setwin(sc,0);
- fepcmd(port, SETMODEM, port->omodem, RTS, 0, 1);
-
- if( !(bc->mstat & DTR) ) {
- DPRINT3(DB_MODEM,"dgm%d: port%d: DTR is off\n",unit,pnum);
- }
-
- hidewin(sc);
- splx(cs);
- break;
- case TIOCCDTR:
- DPRINT3(DB_MODEM,"dgm%d: port%d: reset DTR\n",unit,pnum);
- port->omodem &= ~DTR;
- cs=splclock();
- setwin(sc,0);
- fepcmd(port, SETMODEM, port->omodem, RTS|DTR, 0, 1);
-
- if( bc->mstat & DTR ) {
- DPRINT3(DB_MODEM,"dgm%d: port%d: DTR is on\n",unit,pnum);
- }
-
- hidewin(sc);
- splx(cs);
- break;
- case TIOCMSET:
- if(*(int *)data & TIOCM_DTR)
- port->omodem |=DTR;
- else
- port->omodem &=~DTR;
-
- if(*(int *)data & TIOCM_RTS)
- port->omodem |=RTS;
- else
- port->omodem &=~RTS;
-
- cs=splclock();
- setwin(sc,0);
- fepcmd(port, SETMODEM, port->omodem, RTS|DTR, 0, 1);
- hidewin(sc);
- splx(cs);
- break;
- case TIOCMBIS:
- if(*(int *)data & TIOCM_DTR)
- port->omodem |=DTR;
-
- if(*(int *)data & TIOCM_RTS)
- port->omodem |=RTS;
-
- cs=splclock();
- setwin(sc,0);
- fepcmd(port, SETMODEM, port->omodem, RTS|DTR, 0, 1);
- hidewin(sc);
- splx(cs);
- break;
- case TIOCMBIC:
- if(*(int *)data & TIOCM_DTR)
- port->omodem &=~DTR;
-
- if(*(int *)data & TIOCM_RTS)
- port->omodem &=~RTS;
-
- cs=splclock();
- setwin(sc,0);
- fepcmd(port, SETMODEM, port->omodem, RTS|DTR, 0, 1);
- hidewin(sc);
- splx(cs);
- break;
- case TIOCMGET:
- setwin(sc,0);
- port->imodem=bc->mstat;
- hidewin(sc);
-
- tiocm_xxx = TIOCM_LE; /* XXX - always enabled while open */
-
- DPRINT3(DB_MODEM,"dgm%d: port%d: modem stat -- ",unit,pnum);
-
- if (port->imodem & DTR) {
- DPRINT1(DB_MODEM,"DTR ");
- tiocm_xxx |= TIOCM_DTR;
- }
- if (port->imodem & RTS) {
- DPRINT1(DB_MODEM,"RTS ");
- tiocm_xxx |= TIOCM_RTS;
- }
- if (port->imodem & CTS) {
- DPRINT1(DB_MODEM,"CTS ");
- tiocm_xxx |= TIOCM_CTS;
- }
- if (port->imodem & port->dcd) {
- DPRINT1(DB_MODEM,"DCD ");
- tiocm_xxx |= TIOCM_CD;
- }
- if (port->imodem & port->dsr) {
- DPRINT1(DB_MODEM,"DSR ");
- tiocm_xxx |= TIOCM_DSR;
- }
- if (port->imodem & RI) {
- DPRINT1(DB_MODEM,"RI ");
- tiocm_xxx |= TIOCM_RI;
- }
- *(int *)data = tiocm_xxx;
- DPRINT1(DB_MODEM,"--\n");
- break;
- case TIOCMSDTRWAIT:
- /* must be root since the wait applies to following logins */
- error = suser(p);
- if (error != 0) {
- splx(s);
- return (error);
- }
- port->close_delay = *(int *)data * hz / 100;
- break;
- case TIOCMGDTRWAIT:
- *(int *)data = port->close_delay * 100 / hz;
- break;
- case TIOCTIMESTAMP:
- port->do_timestamp = TRUE;
- *(struct timeval *)data = port->timestamp;
- break;
- case TIOCDCDTIMESTAMP:
- port->do_dcd_timestamp = TRUE;
- *(struct timeval *)data = port->dcd_timestamp;
- break;
- default:
- bmws_set(ws);
- splx(s);
- return ENOTTY;
- }
- bmws_set(ws);
- splx(s);
-
- return 0;
-}
-
-static void
-wakeflush(p)
- void *p;
-{
- struct dgm_p *port=p;
-
- wakeup(&port->draining);
-}
-
-/* wait for the output to drain */
-
-static int
-dgmdrain(port)
- struct dgm_p *port;
-{
- struct dgm_softc *sc=&dgm_softc[port->unit];
- volatile struct board_chan *bc=port->brdchan;
- int error;
- int head, tail;
-
- BoardMemWinState ws=bmws_get();
-
- setwin(sc,0);
-
- bc->iempty=1;
- tail=bc->tout;
- head=bc->tin;
-
- while(tail!=head) {
- DPRINT5(DB_WR,"dgm%d: port%d: drain: head=%d tail=%d\n",
- port->unit, port->pnum, head, tail);
-
- hidewin(sc);
- port->draining=1;
- timeout(wakeflush,port, hz);
- error=tsleep(&port->draining, TTIPRI | PCATCH, "dgdrn", 0);
- port->draining=0;
- setwin(sc,0);
-
- if (error != 0) {
- DPRINT4(DB_WR,"dgm%d: port%d: tsleep(dgdrn) error=%d\n",
- port->unit,port->pnum,error);
-
- bc->iempty=0;
- bmws_set(ws);
- return error;
- }
-
- tail=bc->tout;
- head=bc->tin;
- }
- DPRINT5(DB_WR,"dgm%d: port%d: drain: head=%d tail=%d\n",
- port->unit, port->pnum, head, tail);
- bmws_set(ws);
- return 0;
-}
-
-/* wait for the output to drain */
-/* or simply clear the buffer it it's stopped */
-
-static void
-dgm_drain_or_flush(port)
- struct dgm_p *port;
-{
- struct tty *tp=port->tty;
- struct dgm_softc *sc=&dgm_softc[port->unit];
- volatile struct board_chan *bc=port->brdchan;
- int error;
- int lasttail;
- int head, tail;
-
- setwin(sc,0);
-
- lasttail=-1;
- bc->iempty=1;
- tail=bc->tout;
- head=bc->tin;
-
- while(tail!=head /* && tail!=lasttail */ ) {
- DPRINT5(DB_WR,"dgm%d: port%d: flush: head=%d tail=%d\n",
- port->unit, port->pnum, head, tail);
-
- /* if there is no carrier simply clean the buffer */
- if( !(tp->t_state & TS_CARR_ON) ) {
- bc->tout=bc->tin=0;
- bc->iempty=0;
- hidewin(sc);
- return;
- }
-
- hidewin(sc);
- port->draining=1;
- timeout(wakeflush,port, hz);
- error=tsleep(&port->draining, TTIPRI | PCATCH, "dgfls", 0);
- port->draining=0;
- setwin(sc,0);
-
- if (error != 0) {
- DPRINT4(DB_WR,"dgm%d: port%d: tsleep(dgfls) error=%d\n",
- port->unit,port->pnum,error);
-
- /* silently clean the buffer */
-
- bc->tout=bc->tin=0;
- bc->iempty=0;
- hidewin(sc);
- return;
- }
-
- lasttail=tail;
- tail=bc->tout;
- head=bc->tin;
- }
- hidewin(sc);
- DPRINT5(DB_WR,"dgm%d: port%d: flush: head=%d tail=%d\n",
- port->unit, port->pnum, head, tail);
-}
-
-static int
-dgmparam(tp, t)
- struct tty *tp;
- struct termios *t;
-{
- int unit=MINOR_TO_UNIT(minor(tp->t_dev));
- int pnum=MINOR_TO_PORT(minor(tp->t_dev));
- struct dgm_softc *sc=&dgm_softc[unit];
- struct dgm_p *port=&sc->ports[pnum];
- volatile struct board_chan *bc=port->brdchan;
- int cflag;
- int head;
- int mval;
- int iflag;
- int hflow;
- int cs;
-
- BoardMemWinState ws=bmws_get();
-
- DPRINT6(DB_PARAM,"dgm%d: port%d: dgmparm c=0x%x i=0x%x l=0x%x\n",unit,pnum,t->c_cflag,t->c_iflag,t->c_lflag);
-
- if(port->mustdrain) {
- DPRINT3(DB_PARAM,"dgm%d: port%d: must call dgmdrain()\n",unit,pnum);
- dgmdrain(port);
- }
-
- cflag=ttspeedtab(t->c_ospeed, dgmspeedtab);
-
- if (t->c_ispeed == 0)
- t->c_ispeed = t->c_ospeed;
-
- if (cflag < 0 /* || cflag > 0 && t->c_ispeed != t->c_ospeed */) {
- DPRINT4(DB_PARAM,"dgm%d: port%d: invalid cflag=0%o\n",unit,pnum,cflag);
- return (EINVAL);
- }
-
- cs=splclock();
- setwin(sc,0);
-
- if(cflag==0) { /* hangup */
- DPRINT3(DB_PARAM,"dgm%d: port%d: hangup\n",unit,pnum);
- head=bc->rin;
- bc->rout=head;
- head=bc->tin;
- fepcmd(port, STOUT, (unsigned)head, 0, 0, 0);
- mval= port->omodem & ~(DTR|RTS);
- } else {
- cflag |= dgmflags(dgm_cflags, t->c_cflag);
-
- if(cflag!=port->fepcflag) {
- port->fepcflag=cflag;
- DPRINT5(DB_PARAM,"dgm%d: port%d: set cflag=0x%x c=0x%x\n",
- unit,pnum,cflag,t->c_cflag&~CRTSCTS);
- fepcmd(port, SETCTRLFLAGS, (unsigned)cflag, 0, 0, 0);
- }
- mval= port->omodem | (DTR|RTS);
- }
-
- iflag=dgmflags(dgm_iflags, t->c_iflag);
- if(iflag!=port->fepiflag) {
- port->fepiflag=iflag;
- DPRINT5(DB_PARAM,"dgm%d: port%d: set iflag=0x%x c=0x%x\n",unit,pnum,iflag,t->c_iflag);
- fepcmd(port, SETIFLAGS, (unsigned)iflag, 0, 0, 0);
- }
-
- bc->mint=port->dcd;
-
- hflow=dgmflags(dgm_flow, t->c_cflag);
- if(hflow!=port->hflow) {
- port->hflow=hflow;
- DPRINT5(DB_PARAM,"dgm%d: port%d: set hflow=0x%x f=0x%x\n",unit,pnum,hflow,t->c_cflag&CRTSCTS);
- fepcmd(port, SETHFLOW, (unsigned)hflow, 0xff, 0, 1);
- }
-
- if(port->omodem != mval) {
- DPRINT5(DB_PARAM,"dgm%d: port%d: setting modem parameters 0x%x was 0x%x\n",
- unit,pnum,mval,port->omodem);
- port->omodem=mval;
- fepcmd(port, SETMODEM, (unsigned)mval, RTS|DTR, 0, 1);
- }
-
- if(port->fepstartc!=t->c_cc[VSTART] || port->fepstopc!=t->c_cc[VSTOP]) {
- DPRINT5(DB_PARAM,"dgm%d: port%d: set startc=%d, stopc=%d\n",unit,pnum,t->c_cc[VSTART],t->c_cc[VSTOP]);
- port->fepstartc=t->c_cc[VSTART];
- port->fepstopc=t->c_cc[VSTOP];
- fepcmd(port, SONOFFC, port->fepstartc, port->fepstopc, 0, 1);
- }
-
- bmws_set(ws);
- splx(cs);
-
- return 0;
-
-}
-
-static void
-dgmstart(tp)
- struct tty *tp;
-{
- int unit;
- int pnum;
- struct dgm_p *port;
- struct dgm_softc *sc;
- volatile struct board_chan *bc;
- int head, tail;
- int size, ocount;
- int s;
- int wmask;
-
- BoardMemWinState ws=bmws_get();
-
- unit=MINOR_TO_UNIT(minor(tp->t_dev));
- pnum=MINOR_TO_PORT(minor(tp->t_dev));
- sc=&dgm_softc[unit];
- port=&sc->ports[pnum];
- bc=port->brdchan;
-
- wmask=port->txbufsize-1;
-
- s=spltty();
-
- while( tp->t_outq.c_cc!=0 ) {
- int cs;
-#ifndef TS_ASLEEP /* post 2.0.5 FreeBSD */
- ttwwakeup(tp);
-#else
- if(tp->t_outq.c_cc <= tp->t_lowat) {
- if(tp->t_state & TS_ASLEEP) {
- tp->t_state &= ~TS_ASLEEP;
- wakeup(TSA_OLOWAT(tp));
- }
- /*selwakeup(&tp->t_wsel);*/
- }
-#endif
- cs=splclock();
- setwin(sc,0);
-
- head=bc->tin & wmask;
-
- do { tail=bc->tout; } while (tail != bc->tout);
- tail=bc->tout & wmask;
-
- DPRINT5(DB_WR,"dgm%d: port%d: s tx head=%d tail=%d\n",unit,pnum,head,tail);
-
-#ifdef LEAVE_FREE_CHARS
- if(tail>head) {
- size=tail-head-LEAVE_FREE_CHARS;
- if (size <0)
- size=0;
- } else {
- size=port->txbufsize-head;
- if(tail+port->txbufsize < head)
- size=0;
- }
- }
-#else
- if(tail>head)
- size=tail-head-1;
- else {
- size=port->txbufsize-head/*-1*/;
- if(tail==0)
- size--;
- }
-#endif
-
- if(size==0) {
- bc->iempty=1; bc->ilow=1;
- splx(cs);
- bmws_set(ws);
- tp->t_state|=TS_BUSY;
- splx(s);
- return;
- }
-
- towin(sc,port->txwin);
-
- ocount=q_to_b(&tp->t_outq, port->txptr+head, size);
- head+=ocount;
- if(head>=port->txbufsize)
- head-=port->txbufsize;
-
- setwin(sc,0);
- bc->tin=head;
-
- DPRINT5(DB_WR,"dgm%d: port%d: tx avail=%d count=%d\n",unit,pnum,size,ocount);
- hidewin(sc);
- splx(cs);
- }
-
- bmws_set(ws);
- splx(s);
-
-#ifndef TS_ASLEEP /* post 2.0.5 FreeBSD */
- if(tp->t_state & TS_BUSY) {
- tp->t_state&=~TS_BUSY;
- linesw[tp->t_line].l_start(tp);
- ttwwakeup(tp);
- }
-#else
- if(tp->t_state & TS_ASLEEP) {
- tp->t_state &= ~TS_ASLEEP;
- wakeup(TSA_OLOWAT(tp));
- }
- tp->t_state&=~TS_BUSY;
-#endif
-}
-
-void
-dgmstop(tp, rw)
- struct tty *tp;
- int rw;
-{
- int unit;
- int pnum;
- struct dgm_p *port;
- struct dgm_softc *sc;
- volatile struct board_chan *bc;
- int s;
-
- BoardMemWinState ws=bmws_get();
-
- unit=MINOR_TO_UNIT(minor(tp->t_dev));
- pnum=MINOR_TO_PORT(minor(tp->t_dev));
-
- sc=&dgm_softc[unit];
- port=&sc->ports[pnum];
- bc=port->brdchan;
-
- DPRINT3(DB_WR,"dgm%d: port%d: stop\n",port->unit, port->pnum);
-
- s = spltty();
- setwin(sc,0);
-
- if (rw & FWRITE) {
- /* clear output queue */
- bc->tout=bc->tin=0;
- bc->ilow=0;bc->iempty=0;
- }
- if (rw & FREAD) {
- /* clear input queue */
- bc->rout=bc->rin;
- bc->idata=1;
- }
- hidewin(sc);
- bmws_set(ws);
- splx(s);
- dgmstart(tp);
-}
-
-static void
-fepcmd(port, cmd, op1, op2, ncmds, bytecmd)
- struct dgm_p *port;
- unsigned cmd, op1, op2, ncmds, bytecmd;
-{
- struct dgm_softc *sc=&dgm_softc[port->unit];
- u_char *mem=sc->vmem;
- unsigned tail, head;
- int count, n;
-
- if(port->status==DISABLED) {
- printf("dgm%d: port%d: FEP command on disabled port\n",
- port->unit, port->pnum);
- return;
- }
-
- /* setwin(sc,0); Require this to be set by caller */
- head=sc->mailbox->cin;
-
- if(head>=(FEP_CMAX-FEP_CSTART) || (head & 3)) {
- printf("dgm%d: port%d: wrong pointer head of command queue : 0x%x\n",
- port->unit, port->pnum, head);
- return;
- }
-
- mem[head+FEP_CSTART+0]=cmd;
- mem[head+FEP_CSTART+1]=port->pnum;
- if(bytecmd) {
- mem[head+FEP_CSTART+2]=op1;
- mem[head+FEP_CSTART+3]=op2;
- } else {
- mem[head+FEP_CSTART+2]=op1&0xff;
- mem[head+FEP_CSTART+3]=(op1>>8)&0xff;
- }
-
- DPRINT7(DB_FEP,"dgm%d: port%d: %s cmd=0x%x op1=0x%x op2=0x%x\n", port->unit, port->pnum,
- (bytecmd)?"byte":"word", cmd, mem[head+FEP_CSTART+2], mem[head+FEP_CSTART+3]);
-
- head=(head+4) & (FEP_CMAX-FEP_CSTART-4);
- sc->mailbox->cin=head;
-
- count=FEPTIMEOUT;
-
- while (count-- != 0) {
- head=sc->mailbox->cin;
- tail=sc->mailbox->cout;
-
- n = (head-tail) & (FEP_CMAX-FEP_CSTART-4);
- if(n <= ncmds * (sizeof(ushort)*4))
- return;
- }
- printf("dgm%d(%d): timeout on FEP cmd=0x%x\n", port->unit, port->pnum, cmd);
-}
-
-static void
-disc_optim(tp, t)
- struct tty *tp;
- struct termios *t;
-{
- if (!(t->c_iflag & (ICRNL | IGNCR | IMAXBEL | INLCR | ISTRIP | IXON))
- && (!(t->c_iflag & BRKINT) || (t->c_iflag & IGNBRK))
- && (!(t->c_iflag & PARMRK)
- || (t->c_iflag & (IGNPAR | IGNBRK)) == (IGNPAR | IGNBRK))
- && !(t->c_lflag & (ECHO | ICANON | IEXTEN | ISIG | PENDIN))
- && linesw[tp->t_line].l_rint == ttyinput)
- tp->t_state |= TS_CAN_BYPASS_L_RINT;
- else
- tp->t_state &= ~TS_CAN_BYPASS_L_RINT;
-}
diff --git a/sys/dev/dgb/dgmbios.h b/sys/dev/dgb/dgmbios.h
deleted file mode 100644
index 498bced5358a..000000000000
--- a/sys/dev/dgb/dgmbios.h
+++ /dev/null
@@ -1,2509 +0,0 @@
-/*
- * $FreeBSD$
- *
- * This file is an ascii copy of the file sxbios.bin included in the
- * Digiboard PC/Xem driver for Linux. It is copyright 1992, DIGI
- * International. All Rights Reserved.
- */
-
-static unsigned char pcem_bios[] = {
- 0x4f,0x53,0x75,0xd5,0x4e,0x00,0x00,0x10,0xad,0x00,0x1e,0x24,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x9c,0x72,0xb2,0xa8,0x00,0x00,0x00,0x00,0x40,0x28,0x23,0x29,
- 0x73,0x78,0x62,0x69,0x6f,0x73,0x2e,0x62,0x69,0x6e,0x20,0x20,
- 0x20,0x20,0x32,0x2e,0x31,0x20,0x30,0x38,0x2f,0x31,0x37,0x2f,
- 0x39,0x34,0x00,0x40,0x28,0x23,0x29,0x43,0x6f,0x70,0x79,0x72,
- 0x69,0x67,0x68,0x74,0x20,0x28,0x43,0x29,0x20,0x31,0x39,0x39,
- 0x32,0x2c,0x20,0x44,0x49,0x47,0x49,0x20,0x49,0x6e,0x74,0x65,
- 0x72,0x6e,0x61,0x74,0x69,0x6f,0x6e,0x61,0x6c,0x2e,0x20,0x41,
- 0x6c,0x6c,0x20,0x52,0x69,0x67,0x68,0x74,0x73,0x20,0x52,0x65,
- 0x73,0x65,0x72,0x76,0x65,0x64,0x2e,0x00,0x43,0x50,0x55,0x20,
- 0x64,0x6f,0x65,0x73,0x6e,0x27,0x74,0x20,0x77,0x6f,0x72,0x6b,
- 0x5b,0x00,0x1e,0x24,0x00,0x83,0x01,0x3c,0x00,0xa3,0x04,0x3c,
- 0x10,0x00,0x3e,0xac,0x80,0x01,0x84,0x34,0x0c,0x00,0x88,0x8c,
- 0xff,0x03,0x05,0x24,0x01,0x00,0x08,0x35,0x0c,0x00,0x88,0xac,
- 0x01,0xa0,0x04,0x3c,0x80,0x80,0x84,0x24,0x24,0x20,0x85,0x00,
- 0x00,0xa3,0x05,0x3c,0x00,0x10,0xa5,0x34,0x21,0x20,0x85,0x00,
- 0x00,0x00,0x1e,0x24,0x67,0x00,0x05,0x24,0x00,0xa3,0x09,0x3c,
- 0x10,0x00,0x08,0x24,0x00,0x02,0x29,0x25,0x00,0x00,0x8a,0x80,
- 0x00,0x00,0x00,0x00,0x02,0x00,0x40,0x11,0x00,0x00,0x2a,0xa1,
- 0x01,0x00,0x84,0x24,0xff,0xff,0x08,0x25,0xf9,0xff,0x00,0x1d,
- 0x01,0x00,0x29,0x25,0x00,0xa3,0x01,0x3c,0x10,0x02,0x25,0xac,
- 0x00,0xa3,0x01,0x3c,0x14,0x02,0x3f,0xac,0x00,0xa3,0x01,0x3c,
- 0x18,0x02,0x3d,0xac,0x01,0x00,0x08,0x24,0x00,0xa3,0x01,0x3c,
- 0x00,0xa3,0x1d,0x3c,0x10,0x0c,0x28,0xac,0x00,0x04,0xbd,0x27,
- 0x14,0x28,0x00,0x0c,0x00,0x00,0x00,0x00,0xfd,0xff,0x00,0x10,
- 0x00,0x00,0x00,0x00,0xad,0x00,0x1e,0x24,0x00,0x83,0x01,0x3c,
- 0x10,0x00,0x3e,0xac,0x00,0xa3,0x05,0x3c,0x00,0x00,0x1e,0x24,
- 0x00,0xa3,0x04,0x3c,0x00,0x10,0xa5,0x34,0x04,0x00,0x84,0x24,
- 0xfe,0xff,0x85,0x14,0xfc,0xff,0x80,0xac,0xb8,0x00,0x1e,0x24,
- 0x00,0x83,0x01,0x3c,0x10,0x00,0x3e,0xac,0xff,0xff,0x08,0x24,
- 0xb4,0x00,0x00,0x11,0x00,0x00,0x1e,0x24,0x01,0x00,0x08,0x25,
- 0xb1,0x00,0x00,0x15,0x00,0x00,0x00,0x00,0xff,0xff,0x08,0x24,
- 0x21,0x08,0x00,0x01,0xad,0x00,0x28,0x14,0x01,0x00,0x21,0x24,
- 0xab,0x00,0x20,0x14,0x00,0x00,0x00,0x00,0xff,0xff,0x02,0x24,
- 0xa8,0x00,0x48,0x14,0x00,0x00,0x00,0x00,0x01,0x00,0x42,0x24,
- 0xa5,0x00,0x40,0x14,0x00,0x00,0x00,0x00,0xff,0xff,0x03,0x24,
- 0xa2,0x00,0x68,0x14,0x00,0x00,0x00,0x00,0x01,0x00,0x63,0x24,
- 0x9f,0x00,0x60,0x14,0x00,0x00,0x00,0x00,0xff,0xff,0x04,0x24,
- 0x9c,0x00,0x88,0x14,0x00,0x00,0x00,0x00,0x01,0x00,0x84,0x24,
- 0x99,0x00,0x80,0x14,0x00,0x00,0x00,0x00,0xff,0xff,0x05,0x24,
- 0x96,0x00,0xa8,0x14,0x00,0x00,0x00,0x00,0x01,0x00,0xa5,0x24,
- 0x93,0x00,0xa0,0x14,0x00,0x00,0x00,0x00,0xff,0xff,0x06,0x24,
- 0x90,0x00,0xc8,0x14,0x00,0x00,0x00,0x00,0x01,0x00,0xc6,0x24,
- 0x8d,0x00,0xc0,0x14,0x00,0x00,0x00,0x00,0xff,0xff,0x07,0x24,
- 0x8a,0x00,0xe8,0x14,0x00,0x00,0x00,0x00,0x01,0x00,0xe7,0x24,
- 0x87,0x00,0xe0,0x14,0x00,0x00,0x00,0x00,0xff,0xff,0x09,0x24,
- 0x84,0x00,0x28,0x15,0x00,0x00,0x00,0x00,0x01,0x00,0x29,0x25,
- 0x81,0x00,0x20,0x15,0x00,0x00,0x00,0x00,0xff,0xff,0x0a,0x24,
- 0x7e,0x00,0x48,0x15,0x00,0x00,0x00,0x00,0x01,0x00,0x4a,0x25,
- 0x7b,0x00,0x40,0x15,0x00,0x00,0x00,0x00,0xff,0xff,0x0b,0x24,
- 0x78,0x00,0x68,0x15,0x00,0x00,0x00,0x00,0x01,0x00,0x6b,0x25,
- 0x75,0x00,0x60,0x15,0x00,0x00,0x00,0x00,0xff,0xff,0x0c,0x24,
- 0x72,0x00,0x88,0x15,0x00,0x00,0x00,0x00,0x01,0x00,0x8c,0x25,
- 0x6f,0x00,0x80,0x15,0x00,0x00,0x00,0x00,0xff,0xff,0x0d,0x24,
- 0x6c,0x00,0xa8,0x15,0x00,0x00,0x00,0x00,0x01,0x00,0xad,0x25,
- 0x69,0x00,0xa0,0x15,0x00,0x00,0x00,0x00,0xff,0xff,0x0e,0x24,
- 0x66,0x00,0xc8,0x15,0x00,0x00,0x00,0x00,0x01,0x00,0xce,0x25,
- 0x63,0x00,0xc0,0x15,0x00,0x00,0x00,0x00,0xff,0xff,0x0f,0x24,
- 0x60,0x00,0xe8,0x15,0x00,0x00,0x00,0x00,0x01,0x00,0xef,0x25,
- 0x5d,0x00,0xe0,0x15,0x00,0x00,0x00,0x00,0xff,0xff,0x18,0x24,
- 0x5a,0x00,0x08,0x17,0x00,0x00,0x00,0x00,0x01,0x00,0x18,0x27,
- 0x57,0x00,0x00,0x17,0x00,0x00,0x00,0x00,0xff,0xff,0x10,0x24,
- 0x54,0x00,0x08,0x16,0x00,0x00,0x00,0x00,0x01,0x00,0x10,0x26,
- 0x51,0x00,0x00,0x16,0x00,0x00,0x00,0x00,0xff,0xff,0x11,0x24,
- 0x4e,0x00,0x28,0x16,0x00,0x00,0x00,0x00,0x01,0x00,0x31,0x26,
- 0x4b,0x00,0x20,0x16,0x00,0x00,0x00,0x00,0xff,0xff,0x12,0x24,
- 0x48,0x00,0x48,0x16,0x00,0x00,0x00,0x00,0x01,0x00,0x52,0x26,
- 0x45,0x00,0x40,0x16,0x00,0x00,0x00,0x00,0xff,0xff,0x13,0x24,
- 0x42,0x00,0x68,0x16,0x00,0x00,0x00,0x00,0x01,0x00,0x73,0x26,
- 0x3f,0x00,0x60,0x16,0x00,0x00,0x00,0x00,0xff,0xff,0x14,0x24,
- 0x3c,0x00,0x88,0x16,0x00,0x00,0x00,0x00,0x01,0x00,0x94,0x26,
- 0x39,0x00,0x80,0x16,0x00,0x00,0x00,0x00,0xff,0xff,0x15,0x24,
- 0x36,0x00,0xa8,0x16,0x00,0x00,0x00,0x00,0x01,0x00,0xb5,0x26,
- 0x33,0x00,0xa0,0x16,0x00,0x00,0x00,0x00,0xff,0xff,0x16,0x24,
- 0x30,0x00,0xc8,0x16,0x00,0x00,0x00,0x00,0x01,0x00,0xd6,0x26,
- 0x2d,0x00,0xc0,0x16,0x00,0x00,0x00,0x00,0xff,0xff,0x17,0x24,
- 0x2a,0x00,0xe8,0x16,0x00,0x00,0x00,0x00,0x01,0x00,0xf7,0x26,
- 0x27,0x00,0xe0,0x16,0x00,0x00,0x00,0x00,0xff,0xff,0x1a,0x24,
- 0x24,0x00,0x48,0x17,0x00,0x00,0x00,0x00,0x01,0x00,0x5a,0x27,
- 0x21,0x00,0x40,0x17,0x00,0x00,0x00,0x00,0xff,0xff,0x1b,0x24,
- 0x1e,0x00,0x68,0x17,0x00,0x00,0x00,0x00,0x01,0x00,0x7b,0x27,
- 0x1b,0x00,0x60,0x17,0x00,0x00,0x00,0x00,0xff,0xff,0x1c,0x24,
- 0x18,0x00,0x88,0x17,0x00,0x00,0x00,0x00,0x01,0x00,0x9c,0x27,
- 0x15,0x00,0x80,0x17,0x00,0x00,0x00,0x00,0xff,0xff,0x1d,0x24,
- 0x12,0x00,0xa8,0x17,0x00,0x00,0x00,0x00,0x01,0x00,0xbd,0x27,
- 0x0f,0x00,0xa0,0x17,0x00,0x00,0x00,0x00,0xff,0xff,0x1e,0x24,
- 0x0c,0x00,0xc8,0x17,0x00,0x00,0x00,0x00,0x01,0x00,0xde,0x27,
- 0x09,0x00,0xc0,0x17,0x00,0x00,0x00,0x00,0xff,0xff,0x1f,0x24,
- 0x06,0x00,0xe8,0x17,0x00,0x00,0x00,0x00,0x01,0x00,0xff,0x27,
- 0x03,0x00,0xe0,0x17,0x00,0x00,0x00,0x00,0x0e,0x00,0x00,0x10,
- 0x6b,0x01,0x1e,0x24,0x01,0xa0,0x04,0x3c,0x90,0x80,0x84,0x24,
- 0xff,0x03,0x05,0x24,0x24,0x20,0x85,0x00,0x00,0xa3,0x05,0x3c,
- 0x5b,0x01,0x1e,0x24,0x00,0x83,0x01,0x3c,0x00,0x10,0xa5,0x34,
- 0x10,0x00,0x3e,0xac,0x21,0x20,0x85,0x00,0x08,0x00,0x80,0x00,
- 0x00,0x00,0x1e,0x24,0x6b,0x01,0x1e,0x24,0x00,0x83,0x01,0x3c,
- 0x10,0x00,0x3e,0xac,0x00,0x00,0x1e,0x24,0x00,0x10,0x08,0x3c,
- 0x00,0x60,0x88,0x40,0x74,0x01,0x1e,0x24,0x00,0x83,0x01,0x3c,
- 0x01,0xa0,0x1c,0x3c,0x10,0x00,0x3e,0xac,0x90,0x5d,0x9c,0x27,
- 0x00,0x00,0x1e,0x24,0x01,0x00,0x11,0x04,0x00,0x00,0x00,0x00,
- 0x01,0xa0,0x04,0x3c,0x8f,0x01,0x1e,0x24,0x00,0x83,0x01,0x3c,
- 0x01,0xa0,0x06,0x3c,0xb0,0x84,0x84,0x24,0x10,0x00,0x3e,0xac,
- 0x01,0xa0,0x05,0x3c,0x70,0xf1,0xc6,0x24,0x23,0x20,0xe4,0x03,
- 0x00,0x00,0x1e,0x24,0x00,0x80,0xa5,0x24,0x21,0x20,0x86,0x00,
- 0xfc,0xff,0x88,0x8c,0xfc,0xff,0xc6,0x24,0x2b,0x08,0xa6,0x00,
- 0xfc,0xff,0x84,0x24,0xfb,0xff,0x20,0x14,0x00,0x00,0xc8,0xac,
- 0x9f,0x01,0x1e,0x24,0x00,0x83,0x01,0x3c,0x10,0x00,0x3e,0xac,
- 0x00,0x00,0x1e,0x24,0xaa,0x01,0x1e,0x24,0x00,0x83,0x01,0x3c,
- 0x10,0x00,0x3e,0xac,0x01,0xa0,0x04,0x3c,0x00,0x86,0x84,0x24,
- 0x00,0xa0,0x01,0x3c,0x01,0xa0,0x1f,0x3c,0x25,0x20,0x81,0x00,
- 0x00,0x00,0x1e,0x24,0x08,0x00,0x80,0x00,0x34,0x85,0xff,0x27,
- 0x00,0xa0,0x0b,0x3c,0xb5,0x01,0x1e,0x24,0x00,0x83,0x01,0x3c,
- 0x01,0xa0,0x09,0x3c,0x01,0xa0,0x0a,0x3c,0x00,0x80,0x6b,0x35,
- 0x10,0x00,0x3e,0xac,0x00,0xa0,0x08,0x3c,0x88,0x85,0x29,0x25,
- 0xd8,0x85,0x4a,0x25,0x00,0x00,0x1e,0x24,0x80,0x00,0x08,0x35,
- 0x25,0x48,0x2b,0x01,0x25,0x50,0x4b,0x01,0x00,0x00,0x2b,0x8d,
- 0x04,0x00,0x29,0x25,0x04,0x00,0x08,0x25,0xfc,0xff,0x2a,0x15,
- 0xfc,0xff,0x0b,0xad,0x16,0x00,0x00,0x10,0xfc,0x01,0x1e,0x24,
- 0x00,0xa3,0x1a,0x3c,0x80,0x01,0x5a,0x37,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x40,0xaf,0x00,0x00,0x00,0x00,0x00,0x60,0x1a,0x40,
- 0x00,0x00,0x00,0x00,0xff,0xff,0x1b,0x3c,0xfe,0x00,0x7b,0x37,
- 0x00,0x00,0x00,0x00,0x24,0xd0,0x5b,0x03,0x00,0x00,0x00,0x00,
- 0x00,0x60,0x9a,0x40,0x00,0x00,0x00,0x00,0x00,0x70,0x1a,0x40,
- 0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x42,0x00,0x00,0x00,0x00,
- 0x08,0x00,0x40,0x03,0x00,0x00,0x00,0x00,0xfc,0x01,0x1e,0x24,
- 0x00,0x83,0x01,0x3c,0x10,0x00,0x3e,0xac,0x00,0x00,0x1e,0x24,
- 0x83,0x23,0x00,0x0c,0xc8,0x97,0x9d,0x27,0x4f,0x20,0x00,0x08,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x01,0xa0,0x08,0x3c,0x18,0x86,0x08,0x25,0x00,0xa0,0x01,0x3c,
- 0x25,0x40,0x01,0x01,0x08,0x00,0x00,0x01,0x00,0x00,0x00,0x00,
- 0x00,0x60,0x04,0x40,0x00,0x00,0x00,0x00,0x01,0x00,0x05,0x3c,
- 0x00,0x60,0x85,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0xa0,0x09,0x3c,0x01,0x00,0x01,0x3c,0x23,0x40,0x21,0x01,
- 0x03,0x00,0x00,0xa1,0x04,0x00,0x08,0x25,0xfd,0xff,0x09,0x15,
- 0x00,0x00,0x00,0x00,0x03,0x00,0x05,0x3c,0x00,0x60,0x85,0x40,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa0,0x09,0x3c,
- 0x01,0x00,0x01,0x3c,0x23,0x40,0x21,0x01,0x03,0x00,0x00,0xa1,
- 0x04,0x00,0x08,0x25,0xfd,0xff,0x09,0x15,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x84,0x40,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x04,0x40,
- 0xff,0xff,0x08,0x3c,0xff,0x3f,0x08,0x35,0x24,0x20,0x88,0x00,
- 0x00,0x10,0x84,0x40,0x01,0xa0,0x08,0x3c,0xfc,0xff,0x01,0x24,
- 0x01,0xa0,0x09,0x3c,0x70,0xf1,0x08,0x25,0x60,0xf5,0x29,0x25,
- 0x24,0x40,0x01,0x01,0x24,0x48,0x21,0x01,0x04,0x00,0x08,0x25,
- 0xfe,0xff,0x09,0x15,0xfc,0xff,0x00,0xad,0x08,0x00,0xe0,0x03,
- 0x00,0x00,0x00,0x00,0x00,0x60,0x02,0x40,0xff,0xff,0x01,0x3c,
- 0xfe,0x00,0x21,0x34,0x25,0x20,0x81,0x00,0x24,0x40,0x44,0x00,
- 0x00,0x60,0x88,0x40,0x08,0x00,0xe0,0x03,0x01,0xff,0x42,0x30,
- 0x00,0x60,0x02,0x40,0x00,0x00,0x00,0x00,0x26,0x40,0x44,0x00,
- 0x01,0xff,0x08,0x31,0x26,0x40,0x02,0x01,0x00,0x60,0x88,0x40,
- 0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0x00,0x60,0x08,0x40,
- 0x00,0x00,0x00,0x00,0xfe,0xff,0x01,0x24,0x24,0x48,0x01,0x01,
- 0x00,0x60,0x89,0x40,0x00,0x68,0x02,0x40,0x00,0x03,0x84,0x30,
- 0x25,0x18,0x44,0x00,0x00,0x68,0x83,0x40,0x00,0x60,0x88,0x40,
- 0x08,0x00,0xe0,0x03,0x24,0x10,0x44,0x00,0x00,0x60,0x08,0x40,
- 0x00,0x03,0x84,0x30,0xfe,0xff,0x01,0x24,0x24,0x48,0x01,0x01,
- 0x00,0x60,0x89,0x40,0x00,0x68,0x02,0x40,0x27,0x18,0x80,0x00,
- 0x24,0x18,0x62,0x00,0x00,0x68,0x83,0x40,0x00,0x60,0x88,0x40,
- 0x08,0x00,0xe0,0x03,0x24,0x10,0x44,0x00,0x40,0x10,0x08,0x3c,
- 0x00,0x60,0x88,0x40,0xc0,0xbf,0x08,0x3c,0x08,0x00,0x00,0x01,
- 0x00,0x00,0x00,0x00,0x00,0x60,0x08,0x40,0x00,0x00,0x00,0x00,
- 0xff,0xff,0x09,0x3c,0xfe,0x00,0x29,0x35,0x00,0x00,0x00,0x00,
- 0x24,0x40,0x09,0x01,0x00,0x00,0x00,0x00,0x25,0x40,0x04,0x01,
- 0x00,0x00,0x00,0x00,0x00,0x60,0x88,0x40,0x00,0x00,0x00,0x00,
- 0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0xd0,0xff,0xbd,0x27,0x00,0xa3,0x0d,0x3c,
- 0x30,0x31,0x0e,0x3c,0x04,0x01,0xad,0x35,0x2c,0x00,0xbf,0xaf,
- 0x28,0x00,0xb2,0xaf,0x20,0x00,0xb0,0xaf,0x24,0x00,0xb1,0xaf,
- 0x42,0x54,0xce,0x35,0x23,0x01,0x04,0x3c,0xdc,0xfe,0x06,0x3c,
- 0xff,0xa2,0x07,0x3c,0xff,0xa2,0x08,0x3c,0xf0,0xf0,0x09,0x3c,
- 0xff,0xa2,0x0a,0x3c,0x0f,0x0f,0x0b,0x3c,0x01,0x00,0x0c,0x3c,
- 0x00,0x00,0xae,0xad,0x01,0x00,0x8c,0x35,0x0f,0x0f,0x6b,0x35,
- 0xfc,0xff,0x4a,0x35,0xf0,0xf0,0x29,0x35,0xf8,0xff,0x08,0x35,
- 0x00,0x80,0xe7,0x34,0x98,0xba,0xc6,0x34,0x67,0x45,0x84,0x34,
- 0x10,0x00,0x05,0x3c,0x21,0x18,0xa7,0x00,0xf8,0x7f,0x64,0xac,
- 0x42,0x10,0x05,0x00,0xfc,0x7f,0x66,0xac,0x21,0x78,0x48,0x00,
- 0x00,0x00,0xe9,0xad,0x21,0xc0,0x4a,0x00,0x00,0x00,0x0b,0xaf,
- 0xf8,0x7f,0x79,0x8c,0x00,0x00,0x00,0x00,0x05,0x00,0x99,0x14,
- 0x00,0x00,0x00,0x00,0xfc,0x7f,0x6e,0x8c,0x00,0x00,0x00,0x00,
- 0x06,0x00,0xce,0x10,0x00,0xa3,0x12,0x3c,0x42,0x28,0x05,0x00,
- 0x2b,0x08,0xac,0x00,0xee,0xff,0x20,0x10,0x21,0x18,0xa7,0x00,
- 0x00,0xa3,0x12,0x3c,0x80,0x01,0x52,0x36,0x31,0x30,0x0f,0x3c,
- 0x10,0x00,0x45,0xae,0x42,0x54,0xef,0x35,0x00,0x00,0xaf,0xad,
- 0x29,0x2a,0x00,0x0c,0x20,0x80,0x84,0x27,0x00,0xa3,0x11,0x3c,
- 0x90,0x01,0x31,0x36,0x00,0x00,0x25,0x8e,0x29,0x2a,0x00,0x0c,
- 0x3c,0x80,0x84,0x27,0x29,0x2a,0x00,0x0c,0x50,0x80,0x84,0x27,
- 0x65,0x2a,0x00,0x0c,0x00,0x00,0x00,0x00,0x02,0x00,0x18,0x24,
- 0xc8,0x97,0x98,0xaf,0x02,0x00,0x19,0x24,0x01,0xa1,0x0e,0x3c,
- 0x01,0xa0,0x04,0x3c,0x01,0xa0,0x05,0x3c,0x00,0x80,0xd9,0xa5,
- 0x70,0xf1,0xa5,0x24,0x08,0x28,0x00,0x0c,0x00,0x80,0x84,0x24,
- 0x00,0xa3,0x10,0x3c,0xa0,0x01,0x10,0x36,0x00,0x00,0x02,0xae,
- 0x29,0x2a,0x00,0x0c,0x68,0x80,0x84,0x27,0x00,0x00,0x0f,0x8e,
- 0xff,0xff,0x01,0x24,0x0c,0x00,0xe1,0x11,0x00,0x00,0x00,0x00,
- 0x00,0xa3,0x02,0x3c,0x8c,0x01,0x42,0x34,0x00,0x00,0x58,0x8c,
- 0x80,0x80,0x84,0x27,0x02,0x00,0x19,0x37,0x00,0x00,0x59,0xac,
- 0x00,0x00,0x05,0x8e,0x29,0x2a,0x00,0x0c,0x00,0x00,0x00,0x00,
- 0x03,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x65,0x2a,0x00,0x0c,
- 0x00,0x00,0x00,0x00,0x29,0x2a,0x00,0x0c,0x9c,0x80,0x84,0x27,
- 0x32,0x30,0x0e,0x3c,0x42,0x54,0xce,0x35,0x00,0xa3,0x0f,0x3c,
- 0x04,0x01,0xee,0xad,0x29,0x2a,0x00,0x0c,0xa0,0x80,0x84,0x27,
- 0x00,0xa3,0x10,0x3c,0x00,0x10,0x10,0x36,0x00,0xa3,0x05,0x3c,
- 0x01,0x00,0x18,0x24,0x10,0x00,0xb8,0xaf,0x10,0x40,0xa5,0x34,
- 0x21,0x20,0x00,0x02,0x01,0x00,0x06,0x24,0xfe,0x2b,0x00,0x0c,
- 0x21,0x38,0x00,0x00,0x06,0x00,0x40,0x10,0x00,0x00,0x00,0x00,
- 0x0c,0x00,0x59,0x8e,0x00,0x00,0x00,0x00,0x08,0x00,0x2e,0x37,
- 0x03,0x00,0x00,0x10,0x0c,0x00,0x4e,0xae,0xc1,0x27,0x00,0x0c,
- 0x0a,0x00,0x04,0x24,0x00,0x00,0x2f,0x8e,0x04,0x00,0x01,0x3c,
- 0x01,0x00,0x21,0x34,0x2b,0x08,0xe1,0x01,0x1d,0x00,0x20,0x14,
- 0x00,0x00,0x00,0x00,0x29,0x2a,0x00,0x0c,0xac,0x80,0x84,0x27,
- 0x00,0x00,0x25,0x8e,0x00,0x03,0x01,0x3c,0x25,0x28,0xa1,0x00,
- 0xff,0xff,0x01,0x3c,0x10,0x00,0x21,0x34,0x21,0x28,0xa1,0x00,
- 0xff,0x1f,0x01,0x3c,0xff,0xff,0x21,0x34,0x24,0x28,0xa1,0x00,
- 0x00,0xa0,0x01,0x3c,0x01,0x00,0x18,0x24,0x10,0x00,0xb8,0xaf,
- 0x25,0x28,0xa1,0x00,0x04,0xa3,0x04,0x3c,0x01,0x00,0x06,0x24,
- 0xfe,0x2b,0x00,0x0c,0x21,0x38,0x00,0x00,0x06,0x00,0x40,0x10,
- 0x00,0x00,0x00,0x00,0x0c,0x00,0x59,0x8e,0x00,0x00,0x00,0x00,
- 0x08,0x00,0x2e,0x37,0x03,0x00,0x00,0x10,0x0c,0x00,0x4e,0xae,
- 0xc1,0x27,0x00,0x0c,0x0a,0x00,0x04,0x24,0x29,0x2a,0x00,0x0c,
- 0xb4,0x80,0x84,0x27,0x00,0xa3,0x05,0x3c,0x00,0x20,0xa5,0x34,
- 0x21,0x20,0x00,0x02,0x01,0x00,0x06,0x24,0x21,0x38,0x00,0x00,
- 0xfe,0x2b,0x00,0x0c,0x10,0x00,0xa0,0xaf,0x06,0x00,0x40,0x10,
- 0x00,0x00,0x00,0x00,0x0c,0x00,0x4f,0x8e,0x00,0x00,0x00,0x00,
- 0x08,0x00,0xf8,0x35,0x03,0x00,0x00,0x10,0x0c,0x00,0x58,0xae,
- 0xc1,0x27,0x00,0x0c,0x0a,0x00,0x04,0x24,0x82,0x00,0x19,0x24,
- 0xc8,0x97,0x99,0xaf,0x82,0x00,0x0e,0x24,0x01,0xa1,0x0f,0x3c,
- 0x00,0x80,0xee,0xa5,0x00,0xa3,0x18,0x3c,0xc9,0x01,0x19,0x93,
- 0x00,0x00,0x00,0x00,0x55,0x00,0x20,0x17,0x2c,0x00,0xbf,0x8f,
- 0x33,0x30,0x0e,0x3c,0x42,0x54,0xce,0x35,0x00,0xa3,0x0f,0x3c,
- 0x04,0x01,0xee,0xad,0xc9,0x2a,0x00,0x0c,0x21,0x20,0x00,0x00,
- 0x06,0x00,0x40,0x10,0x00,0x00,0x00,0x00,0x0c,0x00,0x58,0x8e,
- 0x00,0x00,0x00,0x00,0x04,0x00,0x19,0x37,0x03,0x00,0x00,0x10,
- 0x0c,0x00,0x59,0xae,0xc1,0x27,0x00,0x0c,0x0a,0x00,0x04,0x24,
- 0x00,0xa3,0x0e,0x3c,0xc9,0x01,0xcf,0x91,0x00,0x00,0x00,0x00,
- 0x41,0x00,0xe0,0x15,0x2c,0x00,0xbf,0x8f,0x21,0x80,0x00,0x00,
- 0x10,0x80,0x91,0x27,0x00,0x00,0x38,0x8e,0x00,0xa3,0x19,0x3c,
- 0x04,0x01,0x38,0xaf,0x10,0x00,0xa0,0xaf,0x21,0x20,0x00,0x02,
- 0x21,0x28,0x00,0x00,0x21,0x30,0x00,0x00,0x94,0x2e,0x00,0x0c,
- 0x21,0x38,0x00,0x00,0x07,0x00,0x40,0x10,0x00,0x00,0x00,0x00,
- 0x0c,0x00,0x4e,0x8e,0x10,0x00,0x0f,0x24,0x04,0xc0,0x0f,0x02,
- 0x25,0xc8,0xd8,0x01,0x03,0x00,0x00,0x10,0x0c,0x00,0x59,0xae,
- 0xc1,0x27,0x00,0x0c,0x0a,0x00,0x04,0x24,0x00,0xa3,0x0f,0x3c,
- 0xc9,0x01,0xee,0x91,0x00,0x00,0x00,0x00,0x27,0x00,0xc0,0x15,
- 0x2c,0x00,0xbf,0x8f,0x01,0x00,0x10,0x26,0x04,0x00,0x01,0x24,
- 0xe5,0xff,0x01,0x16,0x04,0x00,0x31,0x26,0x2f,0x00,0x58,0x92,
- 0xff,0x00,0x03,0x24,0x08,0x00,0x78,0x14,0x03,0x00,0x10,0x24,
- 0x21,0x10,0x50,0x02,0x2b,0x00,0x59,0x90,0xff,0xff,0x10,0x26,
- 0x03,0x00,0x79,0x14,0xff,0xff,0x42,0x24,0xfb,0xff,0x00,0x16,
- 0x00,0x00,0x00,0x00,0x21,0x10,0x50,0x02,0x2c,0x00,0x4f,0x90,
- 0x00,0x00,0x00,0x00,0x09,0x00,0x6f,0x10,0x00,0x00,0x00,0x00,
- 0x07,0x00,0x00,0x1a,0x00,0x00,0x00,0x00,0x2b,0x00,0x4e,0x90,
- 0xff,0xff,0x10,0x26,0x03,0x00,0x6e,0x10,0xff,0xff,0x42,0x24,
- 0xfb,0xff,0x00,0x1e,0x00,0x00,0x00,0x00,0x09,0x00,0x00,0x12,
- 0x2c,0x00,0xbf,0x8f,0x29,0x2a,0x00,0x0c,0xc0,0x80,0x84,0x27,
- 0x0c,0x00,0x58,0x8e,0x10,0x00,0x19,0x24,0x04,0x78,0x19,0x02,
- 0x25,0x70,0x0f,0x03,0x0c,0x00,0x4e,0xae,0x2c,0x00,0xbf,0x8f,
- 0x20,0x00,0xb0,0x8f,0x24,0x00,0xb1,0x8f,0x28,0x00,0xb2,0x8f,
- 0x08,0x00,0xe0,0x03,0x30,0x00,0xbd,0x27,0xe8,0xff,0xbd,0x27,
- 0x14,0x00,0xbf,0xaf,0xdc,0x80,0x84,0x27,0x35,0x20,0x00,0x0c,
- 0xcf,0x00,0x05,0x24,0x14,0x00,0xbf,0x8f,0x18,0x00,0xbd,0x27,
- 0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0xe8,0xff,0xbd,0x27,
- 0x14,0x00,0xbf,0xaf,0xec,0x80,0x84,0x27,0x35,0x20,0x00,0x0c,
- 0xd9,0x00,0x05,0x24,0x14,0x00,0xbf,0x8f,0x18,0x00,0xbd,0x27,
- 0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0xc0,0xff,0xbd,0x27,
- 0x2c,0x00,0xb5,0xaf,0x1c,0x00,0xb1,0xaf,0x38,0x00,0xbe,0xaf,
- 0x30,0x00,0xb6,0xaf,0x34,0x00,0xb7,0xaf,0x28,0x00,0xb4,0xaf,
- 0x20,0x00,0xb2,0xaf,0x24,0x00,0xb3,0xaf,0x00,0xa3,0x11,0x3c,
- 0x00,0xa3,0x15,0x3c,0x21,0x98,0x80,0x00,0x3c,0x00,0xbf,0xaf,
- 0x18,0x00,0xb0,0xaf,0xc8,0x01,0xb5,0x36,0xc9,0x01,0x31,0x36,
- 0xff,0xff,0x12,0x24,0xff,0xff,0x14,0x24,0x0a,0x00,0x17,0x24,
- 0x08,0x00,0x16,0x24,0x0d,0x00,0x1e,0x24,0x00,0x00,0x2e,0x92,
- 0x00,0x00,0x00,0x00,0x05,0x00,0xc0,0x15,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x2f,0x92,0x00,0x00,0x00,0x00,0xfd,0xff,0xe0,0x11,
- 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x92,0x00,0x00,0x20,0xa2,
- 0x07,0x00,0x16,0x12,0x00,0x00,0x00,0x00,0x03,0x00,0x17,0x12,
- 0x00,0x00,0x00,0x00,0x19,0x00,0x1e,0x16,0x10,0x00,0x01,0x24,
- 0x3d,0x00,0x00,0x10,0x21,0x10,0x40,0x02,0xed,0xff,0x54,0x12,
- 0x00,0x00,0x00,0x00,0x5c,0x28,0x00,0x0c,0x08,0x00,0x04,0x24,
- 0x5c,0x28,0x00,0x0c,0x20,0x00,0x04,0x24,0x5c,0x28,0x00,0x0c,
- 0x08,0x00,0x04,0x24,0x1a,0x00,0x53,0x02,0x02,0x00,0x60,0x16,
- 0x00,0x00,0x00,0x00,0x0d,0x00,0x07,0x00,0xff,0xff,0x01,0x24,
- 0x04,0x00,0x61,0x16,0x00,0x80,0x01,0x3c,0x02,0x00,0x41,0x16,
- 0x00,0x00,0x00,0x00,0x0d,0x00,0x06,0x00,0x12,0x90,0x00,0x00,
- 0xdb,0xff,0x00,0x10,0x00,0x00,0x2e,0x92,0x10,0x00,0x01,0x24,
- 0x15,0x00,0x61,0x16,0x61,0x00,0x01,0x2e,0x05,0x00,0x20,0x14,
- 0x67,0x00,0x01,0x2e,0x04,0x00,0x20,0x10,0x41,0x00,0x01,0x2e,
- 0xe0,0x00,0x10,0x26,0xff,0x00,0x10,0x32,0x41,0x00,0x01,0x2e,
- 0x0c,0x00,0x20,0x14,0x47,0x00,0x01,0x2e,0x0b,0x00,0x20,0x10,
- 0x30,0x00,0x01,0x2e,0x02,0x00,0x54,0x16,0x00,0x00,0x00,0x00,
- 0x21,0x90,0x00,0x00,0x19,0x00,0x53,0x02,0x21,0x20,0x00,0x02,
- 0x12,0xc0,0x00,0x00,0x21,0x90,0x10,0x03,0x5c,0x28,0x00,0x0c,
- 0xc9,0xff,0x52,0x26,0x30,0x00,0x01,0x2e,0xc0,0xff,0x20,0x14,
- 0x3a,0x00,0x01,0x2e,0xbe,0xff,0x20,0x10,0x00,0x00,0x00,0x00,
- 0x02,0x00,0x54,0x16,0x00,0x00,0x00,0x00,0x21,0x90,0x00,0x00,
- 0x19,0x00,0x53,0x02,0x21,0x20,0x00,0x02,0x12,0xc8,0x00,0x00,
- 0x21,0x90,0x30,0x03,0x5c,0x28,0x00,0x0c,0xd0,0xff,0x52,0x26,
- 0xb4,0xff,0x00,0x10,0x00,0x00,0x2e,0x92,0x3c,0x00,0xbf,0x8f,
- 0x18,0x00,0xb0,0x8f,0x1c,0x00,0xb1,0x8f,0x20,0x00,0xb2,0x8f,
- 0x24,0x00,0xb3,0x8f,0x28,0x00,0xb4,0x8f,0x2c,0x00,0xb5,0x8f,
- 0x30,0x00,0xb6,0x8f,0x34,0x00,0xb7,0x8f,0x38,0x00,0xbe,0x8f,
- 0x08,0x00,0xe0,0x03,0x40,0x00,0xbd,0x27,0xc8,0xfe,0xbd,0x27,
- 0x24,0x00,0xbf,0xaf,0x1c,0x37,0x00,0x0c,0x00,0x00,0x00,0x00,
- 0x4f,0x53,0x0e,0x3c,0x4c,0x00,0xb0,0xaf,0x42,0x49,0xce,0x35,
- 0x00,0xa3,0x0f,0x3c,0x4f,0x20,0x18,0x3c,0x00,0x01,0xee,0xad,
- 0x20,0x47,0x18,0x37,0x00,0xa3,0x19,0x3c,0x4b,0x20,0x08,0x3c,
- 0x04,0x01,0x38,0xaf,0x20,0x4f,0x08,0x35,0x00,0xa3,0x09,0x3c,
- 0x08,0x01,0x28,0xad,0x20,0x20,0x0a,0x3c,0x20,0x20,0x4a,0x35,
- 0x00,0xa3,0x0b,0x3c,0x0c,0x01,0x6a,0xad,0x03,0x00,0x0c,0x24,
- 0x00,0xa3,0x0d,0x3c,0x14,0x01,0xac,0xad,0x00,0xa3,0x0e,0x3c,
- 0xca,0x01,0xce,0x35,0x00,0xa3,0x0f,0x3c,0x00,0xa3,0x18,0x3c,
- 0x18,0x01,0xee,0xad,0x30,0x0c,0x18,0x37,0x00,0xa3,0x19,0x3c,
- 0x00,0xa3,0x08,0x3c,0x1c,0x01,0x38,0xaf,0x80,0x01,0x08,0x35,
- 0x00,0xa3,0x09,0x3c,0x20,0x01,0x28,0xad,0x00,0xa3,0x0a,0x3c,
- 0x84,0x01,0x40,0xad,0x00,0xa3,0x0b,0x3c,0x88,0x01,0x60,0xad,
- 0x00,0xa3,0x0c,0x3c,0x94,0x01,0x80,0xad,0x00,0xa3,0x0d,0x3c,
- 0x98,0x01,0xa0,0xad,0x01,0x00,0x0e,0x24,0x00,0xa3,0x0f,0x3c,
- 0x9c,0x01,0xee,0xad,0x01,0x01,0x18,0x24,0x00,0xa3,0x19,0x3c,
- 0xa4,0x01,0x38,0xaf,0x00,0xa3,0x08,0x3c,0xa8,0x01,0x00,0xa5,
- 0x00,0xa3,0x09,0x3c,0xaa,0x01,0x20,0xa5,0x00,0xa3,0x0a,0x3c,
- 0xca,0x01,0x40,0xa5,0x00,0xa3,0x0b,0x3c,0x00,0xa3,0x02,0x3c,
- 0xcc,0x01,0x60,0xa5,0x00,0xa3,0x0d,0x3c,0xff,0x01,0x0c,0x24,
- 0x10,0x01,0x42,0x34,0xce,0x01,0xac,0xa5,0x00,0x00,0x50,0x8c,
- 0x00,0x00,0x00,0x00,0x01,0x00,0x10,0x2e,0x04,0x00,0x00,0x12,
- 0x00,0x00,0x00,0x00,0x00,0x17,0x0e,0x3c,0x05,0x06,0xce,0x35,
- 0x00,0x00,0x4e,0xac,0xf0,0x21,0x00,0x0c,0x00,0x00,0x00,0x00,
- 0x00,0xa3,0x02,0x3c,0x39,0x39,0x0f,0x3c,0x04,0x01,0x42,0x34,
- 0x42,0x54,0xef,0x35,0x00,0x00,0x4f,0xac,0x47,0x00,0x18,0x24,
- 0x00,0xa3,0x19,0x3c,0x00,0x0c,0x38,0xa3,0x44,0x00,0x08,0x24,
- 0x00,0xa3,0x09,0x3c,0x01,0x0c,0x28,0xa1,0x00,0xa3,0x0a,0x3c,
- 0x30,0x0c,0x40,0xa1,0x00,0xa3,0x0b,0x3c,0x32,0x0c,0x60,0xa1,
- 0x00,0xa3,0x0c,0x3c,0x45,0x23,0x0d,0x3c,0x38,0x0c,0x80,0xa5,
- 0x89,0x67,0xad,0x35,0x00,0xa3,0x0e,0x3c,0x05,0x00,0x00,0x12,
- 0x10,0x00,0xcd,0xad,0x4e,0x45,0x0f,0x3c,0x44,0x4f,0xef,0x35,
- 0x04,0x00,0x00,0x10,0x00,0x00,0x4f,0xac,0x49,0x54,0x18,0x3c,
- 0x57,0x41,0x18,0x37,0x00,0x00,0x58,0xac,0x38,0x00,0xb4,0xaf,
- 0x00,0xa3,0x14,0x3c,0x30,0x00,0xb6,0xaf,0x0a,0x00,0x16,0x24,
- 0xc9,0x01,0x94,0x36,0x44,0x00,0xb1,0xaf,0x40,0x00,0xb2,0xaf,
- 0x3c,0x00,0xb3,0xaf,0x34,0x00,0xb5,0xaf,0x2c,0x00,0xb7,0xaf,
- 0x28,0x00,0xbe,0xaf,0x00,0xa3,0x02,0x3c,0x10,0x00,0x42,0x34,
- 0x00,0x00,0x59,0x8c,0x00,0x00,0x00,0x00,0x01,0x00,0x28,0x27,
- 0x14,0x28,0x00,0x0c,0x00,0x00,0x48,0xac,0x00,0xa3,0x09,0x3c,
- 0x10,0x01,0x2a,0x8d,0x00,0x00,0x00,0x00,0x09,0x00,0x40,0x15,
- 0x00,0x00,0x00,0x00,0x00,0x17,0x0b,0x3c,0x05,0x06,0x6b,0x35,
- 0x00,0xa3,0x0c,0x3c,0x4e,0x45,0x0d,0x3c,0x10,0x01,0x8b,0xad,
- 0x44,0x4f,0xad,0x35,0x00,0xa3,0x0e,0x3c,0x04,0x01,0xcd,0xad,
- 0x00,0x00,0x8f,0x92,0x00,0x00,0x00,0x00,0xea,0xff,0xe0,0x11,
- 0x00,0xa3,0x02,0x3c,0x00,0xa3,0x18,0x3c,0xc8,0x01,0x19,0x93,
- 0x21,0x98,0x00,0x00,0x30,0x01,0xb9,0xa3,0x00,0x00,0x80,0xa2,
- 0x74,0x00,0xa0,0xaf,0x60,0x00,0xa0,0xaf,0x01,0x00,0x1e,0x24,
- 0x3c,0x01,0xb0,0x27,0x4c,0x01,0xa2,0x27,0x10,0x00,0x10,0x26,
- 0x18,0xff,0x00,0xae,0x2c,0xff,0x00,0xae,0x1c,0xff,0x00,0xae,
- 0x30,0xff,0x00,0xae,0x20,0xff,0x00,0xae,0x34,0xff,0x00,0xae,
- 0x24,0xff,0x00,0xae,0xf7,0xff,0x02,0x16,0x38,0xff,0x00,0xae,
- 0x09,0x03,0x00,0x10,0x30,0x01,0xac,0x93,0x29,0x2a,0x00,0x0c,
- 0x4c,0x81,0x84,0x27,0x29,0x2a,0x00,0x0c,0x6c,0x81,0x84,0x27,
- 0x29,0x2a,0x00,0x0c,0x7c,0x81,0x84,0x27,0x29,0x2a,0x00,0x0c,
- 0x90,0x81,0x84,0x27,0x29,0x2a,0x00,0x0c,0xa4,0x81,0x84,0x27,
- 0x29,0x2a,0x00,0x0c,0xb4,0x81,0x84,0x27,0x29,0x2a,0x00,0x0c,
- 0xd8,0x81,0x84,0x27,0x29,0x2a,0x00,0x0c,0xfc,0x81,0x84,0x27,
- 0x29,0x2a,0x00,0x0c,0x20,0x82,0x84,0x27,0x29,0x2a,0x00,0x0c,
- 0x38,0x82,0x84,0x27,0x29,0x2a,0x00,0x0c,0x70,0x82,0x84,0x27,
- 0x29,0x2a,0x00,0x0c,0x94,0x82,0x84,0x27,0xba,0xff,0x00,0x10,
- 0x00,0xa3,0x02,0x3c,0x65,0x00,0x08,0x24,0x30,0x01,0xa8,0xa3,
- 0x29,0x2a,0x00,0x0c,0xc4,0x82,0x84,0x27,0x14,0x23,0x00,0x0c,
- 0x21,0x20,0xc0,0x02,0x21,0xb8,0x40,0x00,0x29,0x2a,0x00,0x0c,
- 0xe8,0x82,0x84,0x27,0xaf,0xff,0xe0,0x12,0x00,0xa3,0x02,0x3c,
- 0x01,0x00,0x09,0x24,0x10,0x00,0xa9,0xaf,0x21,0x20,0x00,0x00,
- 0x02,0x00,0x05,0x24,0xb0,0x00,0xa6,0x27,0x94,0x2e,0x00,0x0c,
- 0x21,0x38,0x00,0x00,0x01,0x00,0x0a,0x24,0x10,0x00,0xaa,0xaf,
- 0x01,0x00,0x04,0x24,0x02,0x00,0x05,0x24,0xb0,0x00,0xa6,0x27,
- 0x94,0x2e,0x00,0x0c,0x21,0x38,0x00,0x00,0x01,0x00,0x0b,0x24,
- 0x10,0x00,0xab,0xaf,0x02,0x00,0x04,0x24,0x02,0x00,0x05,0x24,
- 0xb0,0x00,0xa6,0x27,0x94,0x2e,0x00,0x0c,0x21,0x38,0x00,0x00,
- 0x01,0x00,0x0c,0x24,0x10,0x00,0xac,0xaf,0x03,0x00,0x04,0x24,
- 0x02,0x00,0x05,0x24,0xb0,0x00,0xa6,0x27,0x94,0x2e,0x00,0x0c,
- 0x21,0x38,0x00,0x00,0x21,0x18,0xe0,0x02,0x67,0x00,0x60,0x10,
- 0xff,0xff,0xf7,0x26,0x30,0x01,0xad,0x93,0x65,0x00,0x01,0x24,
- 0x30,0x00,0xa1,0x11,0x01,0x00,0x73,0x26,0x21,0xa8,0x00,0x00,
- 0xfc,0x80,0x84,0x8f,0x29,0x2a,0x00,0x0c,0x21,0x28,0x60,0x02,
- 0xc9,0x2a,0x00,0x0c,0x21,0x20,0x00,0x00,0x07,0x00,0x40,0x10,
- 0x60,0x00,0xb8,0x8f,0x74,0x00,0xae,0x8f,0x00,0x00,0x00,0x00,
- 0x01,0x00,0xcf,0x25,0x05,0x00,0x00,0x10,0x74,0x00,0xaf,0xaf,
- 0x60,0x00,0xb8,0x8f,0x00,0x00,0x00,0x00,0x01,0x00,0x19,0x27,
- 0x60,0x00,0xb9,0xaf,0x00,0x00,0x88,0x92,0x00,0x00,0x00,0x00,
- 0x4e,0x00,0x00,0x15,0x00,0x00,0x00,0x00,0x01,0x00,0xb5,0x26,
- 0x14,0x00,0x01,0x24,0xe9,0xff,0xa1,0x16,0x00,0x00,0x00,0x00,
- 0xfc,0x80,0x84,0x8f,0x29,0x2a,0x00,0x0c,0x21,0x28,0x60,0x02,
- 0x00,0xa3,0x04,0x3c,0x00,0xa3,0x05,0x3c,0xf0,0x7f,0xa5,0x34,
- 0x10,0x7f,0x84,0x34,0x01,0x00,0x06,0x24,0x21,0x38,0x00,0x00,
- 0xfe,0x2b,0x00,0x0c,0x10,0x00,0xa0,0xaf,0x07,0x00,0x40,0x10,
- 0x64,0x00,0xab,0x8f,0x78,0x00,0xa9,0x8f,0x00,0x00,0x00,0x00,
- 0x01,0x00,0x2a,0x25,0x05,0x00,0x00,0x10,0x78,0x00,0xaa,0xaf,
- 0x64,0x00,0xab,0x8f,0x00,0x00,0x00,0x00,0x01,0x00,0x6c,0x25,
- 0x64,0x00,0xac,0xaf,0x00,0x00,0x8d,0x92,0x00,0x00,0x00,0x00,
- 0x30,0x00,0xa0,0x15,0x00,0x00,0x00,0x00,0x21,0x80,0x00,0x00,
- 0x21,0x90,0x00,0x00,0x21,0x88,0x00,0x00,0xfc,0x80,0x84,0x8f,
- 0x29,0x2a,0x00,0x0c,0x21,0x28,0x60,0x02,0x21,0x20,0x20,0x02,
- 0x21,0x28,0x00,0x02,0xb0,0x00,0xa6,0x27,0x21,0x38,0x00,0x00,
- 0x94,0x2e,0x00,0x0c,0x10,0x00,0xa0,0xaf,0x0a,0x00,0x40,0x10,
- 0x80,0x40,0x10,0x00,0x80,0x70,0x10,0x00,0x38,0x01,0xaf,0x27,
- 0x21,0x10,0xcf,0x01,0x44,0xff,0x58,0x8c,0x00,0x00,0x00,0x00,
- 0x01,0x00,0x19,0x27,0x08,0x00,0x00,0x10,0x44,0xff,0x59,0xac,
- 0x80,0x40,0x10,0x00,0x38,0x01,0xa9,0x27,0x21,0x10,0x09,0x01,
- 0x30,0xff,0x4a,0x8c,0x00,0x00,0x00,0x00,0x01,0x00,0x4b,0x25,
- 0x30,0xff,0x4b,0xac,0x00,0x00,0x8c,0x92,0x00,0x00,0x00,0x00,
- 0x0f,0x00,0x80,0x15,0x00,0x00,0x00,0x00,0x01,0x00,0x31,0x26,
- 0x04,0x00,0x21,0x2a,0xdf,0xff,0x20,0x14,0x00,0x00,0x00,0x00,
- 0x01,0x00,0x52,0x26,0xdc,0xff,0x56,0x16,0x21,0x88,0x00,0x00,
- 0x01,0x00,0x10,0x26,0x02,0x00,0x01,0x24,0xd7,0xff,0x01,0x16,
- 0x21,0x90,0x00,0x00,0x21,0x18,0xe0,0x02,0x9b,0xff,0x60,0x14,
- 0xff,0xff,0xf7,0x26,0x29,0x2a,0x00,0x0c,0xec,0x82,0x84,0x27,
- 0x00,0x83,0x84,0x27,0x29,0x2a,0x00,0x0c,0x21,0x28,0x60,0x02,
- 0x21,0xf0,0x00,0x00,0x38,0x01,0xb0,0x27,0x01,0x00,0xd1,0x27,
- 0x28,0xff,0x06,0x8e,0x3c,0xff,0x07,0x8e,0x21,0x28,0x20,0x02,
- 0x29,0x2a,0x00,0x0c,0x14,0x83,0x84,0x27,0x21,0xf0,0x20,0x02,
- 0x04,0x00,0x01,0x24,0xf7,0xff,0xc1,0x17,0x04,0x00,0x10,0x26,
- 0x16,0xff,0x00,0x10,0x00,0x00,0x80,0xa2,0x29,0x2a,0x00,0x0c,
- 0x38,0x83,0x84,0x27,0x01,0x00,0x73,0x26,0xfc,0x80,0x84,0x8f,
- 0x29,0x2a,0x00,0x0c,0x21,0x28,0x60,0x02,0xc9,0x2a,0x00,0x0c,
- 0x21,0x20,0x00,0x00,0x07,0x00,0x40,0x10,0x60,0x00,0xaf,0x8f,
- 0x74,0x00,0xad,0x8f,0x00,0x00,0x00,0x00,0x01,0x00,0xae,0x25,
- 0x05,0x00,0x00,0x10,0x74,0x00,0xae,0xaf,0x60,0x00,0xaf,0x8f,
- 0x00,0x00,0x00,0x00,0x01,0x00,0xf8,0x25,0x60,0x00,0xb8,0xaf,
- 0x00,0x00,0x99,0x92,0x00,0x00,0x00,0x00,0xec,0xff,0x20,0x13,
- 0x00,0x00,0x00,0x00,0x29,0x2a,0x00,0x0c,0x54,0x83,0x84,0x27,
- 0x70,0x83,0x84,0x27,0x29,0x2a,0x00,0x0c,0x21,0x28,0x60,0x02,
- 0x60,0x00,0xa5,0x8f,0x74,0x00,0xa6,0x8f,0x29,0x2a,0x00,0x0c,
- 0x84,0x83,0x84,0x27,0xf4,0xfe,0x00,0x10,0x00,0x00,0x80,0xa2,
- 0x29,0x2a,0x00,0x0c,0xa4,0x83,0x84,0x27,0x14,0x23,0x00,0x0c,
- 0x10,0x00,0x04,0x24,0xff,0xff,0x01,0x24,0x03,0x00,0x41,0x14,
- 0x21,0x90,0x40,0x00,0x00,0xa3,0x12,0x3c,0x00,0x10,0x52,0x36,
- 0x29,0x2a,0x00,0x0c,0xb4,0x83,0x84,0x27,0x14,0x23,0x00,0x0c,
- 0x10,0x00,0x04,0x24,0xff,0xff,0x01,0x24,0x03,0x00,0x41,0x14,
- 0x21,0x80,0x40,0x00,0x02,0xa3,0x10,0x3c,0xf0,0xff,0x10,0x36,
- 0x29,0x2a,0x00,0x0c,0xc4,0x83,0x84,0x27,0x29,0x2a,0x00,0x0c,
- 0xc8,0x83,0x84,0x27,0x01,0x00,0x73,0x26,0xfc,0x80,0x84,0x8f,
- 0x29,0x2a,0x00,0x0c,0x21,0x28,0x60,0x02,0x21,0x20,0x40,0x02,
- 0x21,0x28,0x00,0x02,0x01,0x00,0x06,0x24,0x21,0x38,0x00,0x00,
- 0xfe,0x2b,0x00,0x0c,0x10,0x00,0xa0,0xaf,0x07,0x00,0x40,0x10,
- 0x64,0x00,0xaa,0x8f,0x78,0x00,0xa8,0x8f,0x00,0x00,0x00,0x00,
- 0x01,0x00,0x09,0x25,0x05,0x00,0x00,0x10,0x78,0x00,0xa9,0xaf,
- 0x64,0x00,0xaa,0x8f,0x00,0x00,0x00,0x00,0x01,0x00,0x4b,0x25,
- 0x64,0x00,0xab,0xaf,0x00,0x00,0x8c,0x92,0x00,0x00,0x00,0x00,
- 0xe8,0xff,0x80,0x11,0x00,0x00,0x00,0x00,0x29,0x2a,0x00,0x0c,
- 0xe4,0x83,0x84,0x27,0xfc,0x83,0x84,0x27,0x29,0x2a,0x00,0x0c,
- 0x21,0x28,0x60,0x02,0x64,0x00,0xa5,0x8f,0x78,0x00,0xa6,0x8f,
- 0x29,0x2a,0x00,0x0c,0x10,0x84,0x84,0x27,0xba,0xfe,0x00,0x10,
- 0x00,0x00,0x80,0xa2,0x29,0x2a,0x00,0x0c,0x30,0x84,0x84,0x27,
- 0x29,0x2a,0x00,0x0c,0x58,0x84,0x84,0x27,0x00,0x00,0x8d,0x92,
- 0x00,0x00,0x00,0x00,0x06,0x00,0xa0,0x15,0x00,0xa3,0x0f,0x3c,
- 0x00,0x00,0x8e,0x92,0x00,0x00,0x00,0x00,0xfd,0xff,0xc0,0x11,
- 0x00,0x00,0x00,0x00,0x00,0xa3,0x0f,0x3c,0xc8,0x01,0xf2,0x91,
- 0x00,0x00,0x80,0xa2,0x29,0x2a,0x00,0x0c,0x7c,0x84,0x84,0x27,
- 0x30,0x00,0x41,0x2a,0xa6,0xfe,0x20,0x14,0x34,0x00,0x41,0x2a,
- 0xa5,0xfe,0x20,0x10,0x00,0xa3,0x02,0x3c,0xd0,0xff,0x42,0x26,
- 0x21,0xa8,0x40,0x00,0x21,0xf0,0x40,0x00,0x29,0x2a,0x00,0x0c,
- 0x80,0x84,0x84,0x27,0x14,0x23,0x00,0x0c,0x21,0x20,0xc0,0x02,
- 0xff,0xff,0x52,0x24,0x0f,0x00,0x52,0x32,0x29,0x2a,0x00,0x0c,
- 0xa0,0x84,0x84,0x27,0x21,0x88,0xc0,0x03,0x2a,0x08,0xbe,0x02,
- 0xff,0xff,0x20,0x14,0x2a,0x08,0xbe,0x02,0xff,0xff,0x18,0x24,
- 0x23,0x80,0x12,0x03,0x01,0x00,0x73,0x26,0xfc,0x80,0x84,0x8f,
- 0x29,0x2a,0x00,0x0c,0x21,0x28,0x60,0x02,0x21,0x20,0x20,0x02,
- 0x21,0x28,0x00,0x02,0x21,0x30,0x00,0x00,0x21,0x38,0x00,0x00,
- 0x94,0x2e,0x00,0x0c,0x10,0x00,0xa0,0xaf,0x07,0x00,0x40,0x10,
- 0x68,0x00,0xa9,0x8f,0x7c,0x00,0xb9,0x8f,0x00,0x00,0x00,0x00,
- 0x01,0x00,0x28,0x27,0x05,0x00,0x00,0x10,0x7c,0x00,0xa8,0xaf,
- 0x68,0x00,0xa9,0x8f,0x00,0x00,0x00,0x00,0x01,0x00,0x2a,0x25,
- 0x68,0x00,0xaa,0xaf,0x00,0x00,0x8b,0x92,0x00,0x00,0x00,0x00,
- 0x07,0x00,0x60,0x15,0x00,0x00,0x00,0x00,0x01,0x00,0x31,0x26,
- 0x2a,0x08,0xb1,0x02,0xe4,0xff,0x20,0x10,0x00,0x00,0x00,0x00,
- 0xdd,0xff,0x00,0x10,0x21,0x88,0xc0,0x03,0x29,0x2a,0x00,0x0c,
- 0xc0,0x84,0x84,0x27,0xd8,0x84,0x84,0x27,0x29,0x2a,0x00,0x0c,
- 0x21,0x28,0x60,0x02,0x68,0x00,0xa6,0x8f,0x7c,0x00,0xa7,0x8f,
- 0xec,0x84,0x84,0x27,0x29,0x2a,0x00,0x0c,0x33,0x00,0x05,0x24,
- 0x68,0xfe,0x00,0x10,0x00,0x00,0x80,0xa2,0x29,0x2a,0x00,0x0c,
- 0x10,0x85,0x84,0x27,0x30,0x01,0xb7,0x93,0x00,0x00,0x00,0x00,
- 0xcd,0xff,0xf7,0x26,0x05,0x00,0xe0,0x12,0x00,0x00,0x00,0x00,
- 0x29,0x2a,0x00,0x0c,0x18,0x85,0x84,0x27,0x03,0x00,0x00,0x10,
- 0x00,0x00,0x00,0x00,0x29,0x2a,0x00,0x0c,0x1c,0x85,0x84,0x27,
- 0x29,0x2a,0x00,0x0c,0x20,0x85,0x84,0x27,0x29,0x2a,0x00,0x0c,
- 0x38,0x85,0x84,0x27,0x00,0x00,0x8c,0x92,0x00,0x00,0x00,0x00,
- 0x06,0x00,0x80,0x15,0x00,0xa3,0x0e,0x3c,0x00,0x00,0x8d,0x92,
- 0x00,0x00,0x00,0x00,0xfd,0xff,0xa0,0x11,0x00,0x00,0x00,0x00,
- 0x00,0xa3,0x0e,0x3c,0xc8,0x01,0xd2,0x91,0x61,0x00,0x01,0x24,
- 0x04,0x00,0x41,0x12,0x00,0x00,0x80,0xa2,0x41,0x00,0x01,0x24,
- 0x05,0x00,0x41,0x16,0x30,0x00,0x41,0x2a,0x21,0xf0,0x00,0x00,
- 0x09,0x00,0x00,0x10,0x03,0x00,0x15,0x24,0x30,0x00,0x41,0x2a,
- 0x41,0xfe,0x20,0x14,0x34,0x00,0x41,0x2a,0x40,0xfe,0x20,0x10,
- 0x00,0xa3,0x02,0x3c,0xd0,0xff,0x42,0x26,0x21,0xa8,0x40,0x00,
- 0x21,0xf0,0x40,0x00,0x29,0x2a,0x00,0x0c,0x6c,0x85,0x84,0x27,
- 0x01,0x00,0x01,0x24,0x0e,0x00,0xe1,0x16,0x2a,0x08,0xbe,0x02,
- 0x0c,0x00,0x20,0x14,0x21,0x88,0xc0,0x03,0x01,0x00,0x0f,0x24,
- 0x10,0x00,0xaf,0xaf,0x21,0x20,0x20,0x02,0x02,0x00,0x05,0x24,
- 0xb0,0x00,0xa6,0x27,0x94,0x2e,0x00,0x0c,0x21,0x38,0x00,0x00,
- 0x01,0x00,0x31,0x26,0x2a,0x08,0xb1,0x02,0xf7,0xff,0x20,0x10,
- 0x01,0x00,0x0f,0x24,0x21,0x88,0xc0,0x03,0x2a,0x08,0xbe,0x02,
- 0xff,0xff,0x20,0x14,0x2a,0x08,0xbe,0x02,0x01,0x00,0x73,0x26,
- 0xfc,0x80,0x84,0x8f,0x29,0x2a,0x00,0x0c,0x21,0x28,0x60,0x02,
- 0x21,0x20,0x20,0x02,0x21,0x28,0xe0,0x02,0xb0,0x00,0xa6,0x27,
- 0x21,0x38,0x00,0x00,0x94,0x2e,0x00,0x0c,0x10,0x00,0xa0,0xaf,
- 0x0b,0x00,0x40,0x10,0x30,0x01,0xab,0x93,0x30,0x01,0xb8,0x93,
- 0x38,0x01,0xa8,0x27,0x80,0xc8,0x18,0x00,0x21,0x80,0x28,0x03,
- 0x78,0xfe,0x09,0x8e,0x00,0x00,0x00,0x00,0x01,0x00,0x2a,0x25,
- 0x09,0x00,0x00,0x10,0x78,0xfe,0x0a,0xae,0x30,0x01,0xab,0x93,
- 0x38,0x01,0xad,0x27,0x80,0x60,0x0b,0x00,0x21,0x80,0x8d,0x01,
- 0x64,0xfe,0x0e,0x8e,0x00,0x00,0x00,0x00,0x01,0x00,0xcf,0x25,
- 0x64,0xfe,0x0f,0xae,0x00,0x00,0x98,0x92,0x00,0x00,0x00,0x00,
- 0x07,0x00,0x00,0x17,0x00,0x00,0x00,0x00,0x01,0x00,0x31,0x26,
- 0x2a,0x08,0xb1,0x02,0xdc,0xff,0x20,0x10,0x00,0x00,0x00,0x00,
- 0xd7,0xff,0x00,0x10,0x21,0x88,0xc0,0x03,0x29,0x2a,0x00,0x0c,
- 0x88,0x85,0x84,0x27,0xa0,0x85,0x84,0x27,0x29,0x2a,0x00,0x0c,
- 0x21,0x28,0x60,0x02,0x30,0x01,0xa5,0x93,0x64,0xfe,0x06,0x8e,
- 0x78,0xfe,0x07,0x8e,0x29,0x2a,0x00,0x0c,0xb4,0x85,0x84,0x27,
- 0xf3,0xfd,0x00,0x10,0x00,0x00,0x80,0xa2,0x01,0xa0,0x04,0x3c,
- 0x01,0xa0,0x05,0x3c,0xa0,0xdd,0xa5,0x24,0x08,0x28,0x00,0x0c,
- 0x00,0x80,0x84,0x24,0x21,0x80,0x40,0x00,0x29,0x2a,0x00,0x0c,
- 0xd8,0x85,0x84,0x27,0x01,0x00,0x73,0x26,0xfc,0x80,0x84,0x8f,
- 0x29,0x2a,0x00,0x0c,0x21,0x28,0x60,0x02,0x29,0x2a,0x00,0x0c,
- 0xf4,0x85,0x84,0x27,0x0f,0xa3,0x02,0x3c,0x23,0x01,0x03,0x3c,
- 0x67,0x45,0x63,0x34,0xf8,0xff,0x42,0x34,0xdc,0xfe,0x19,0x3c,
- 0x00,0x00,0x43,0xac,0x98,0xba,0x39,0x37,0x10,0xa3,0x08,0x3c,
- 0xf0,0xf0,0x09,0x3c,0xfc,0xff,0x19,0xad,0xf0,0xf0,0x29,0x35,
- 0x08,0xa3,0x0a,0x3c,0x0f,0x0f,0x0b,0x3c,0xf8,0xff,0x49,0xad,
- 0x0f,0x0f,0x6b,0x35,0x08,0xa3,0x0c,0x3c,0xfc,0xff,0x8b,0xad,
- 0x00,0x00,0x4d,0x8c,0x00,0x00,0x00,0x00,0x07,0x00,0x6d,0x14,
- 0x00,0x00,0x00,0x00,0x10,0xa3,0x0e,0x3c,0xfc,0xff,0xcf,0x8d,
- 0xdc,0xfe,0x01,0x3c,0x98,0xba,0x21,0x34,0x14,0x00,0xe1,0x11,
- 0x00,0x00,0x00,0x00,0x01,0xa0,0x04,0x3c,0x01,0xa0,0x05,0x3c,
- 0xa0,0xdd,0xa5,0x24,0x08,0x28,0x00,0x0c,0x00,0x80,0x84,0x24,
- 0x05,0x00,0x02,0x16,0x00,0x00,0x00,0x00,0x65,0x2a,0x00,0x0c,
- 0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x10,0x00,0x00,0x98,0x92,
- 0x29,0x2a,0x00,0x0c,0x04,0x86,0x84,0x27,0x05,0x00,0x00,0x10,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x98,0x92,0x00,0x00,0x00,0x00,
- 0xcd,0xff,0x00,0x13,0x00,0x00,0x00,0x00,0x29,0x2a,0x00,0x0c,
- 0x2c,0x86,0x84,0x27,0x44,0x86,0x84,0x27,0x29,0x2a,0x00,0x0c,
- 0x21,0x28,0x60,0x02,0x70,0x00,0xa5,0x8f,0x84,0x00,0xa6,0x8f,
- 0x29,0x2a,0x00,0x0c,0x58,0x86,0x84,0x27,0xac,0xfd,0x00,0x10,
- 0x00,0x00,0x80,0xa2,0xc8,0x97,0x82,0x8f,0x00,0xa1,0x03,0x3c,
- 0x00,0x80,0x63,0x34,0x01,0x00,0x59,0x38,0x00,0x00,0x79,0xa4,
- 0x00,0xa3,0x08,0x3c,0x00,0x00,0x00,0x8d,0x78,0x86,0x84,0x27,
- 0x29,0x2a,0x00,0x0c,0x00,0x00,0x62,0xa4,0xa1,0xfd,0x00,0x10,
- 0x00,0xa3,0x02,0x3c,0x29,0x2a,0x00,0x0c,0x98,0x86,0x84,0x27,
- 0x14,0x23,0x00,0x0c,0x10,0x00,0x04,0x24,0xff,0xff,0x01,0x24,
- 0x99,0xfd,0x41,0x10,0x21,0x90,0x40,0x00,0x29,0x2a,0x00,0x0c,
- 0xa8,0x86,0x84,0x27,0x30,0x01,0xa9,0x93,0x64,0x00,0x01,0x24,
- 0x05,0x00,0x21,0x11,0x04,0x00,0x01,0x24,0x03,0x00,0x21,0x11,
- 0x44,0x00,0x01,0x24,0x23,0x00,0x21,0x15,0x30,0x01,0xac,0x93,
- 0x30,0x01,0xaa,0x93,0x64,0x00,0x01,0x24,0x03,0x00,0x41,0x15,
- 0x21,0xf0,0x00,0x00,0x02,0x00,0x00,0x10,0x04,0x00,0x03,0x24,
- 0x10,0x00,0x03,0x24,0x87,0xfd,0x60,0x18,0x00,0xa3,0x02,0x3c,
- 0x00,0x89,0x1e,0x00,0x21,0x80,0x51,0x02,0x21,0x28,0x00,0x02,
- 0x29,0x2a,0x00,0x0c,0xac,0x86,0x84,0x27,0x00,0xa0,0x01,0x3c,
- 0x25,0x20,0x01,0x02,0x6d,0x2a,0x00,0x0c,0x10,0x00,0x05,0x24,
- 0x29,0x2a,0x00,0x0c,0xb4,0x86,0x84,0x27,0x30,0x01,0xab,0x93,
- 0x64,0x00,0x01,0x24,0x01,0x00,0xde,0x27,0x03,0x00,0x61,0x15,
- 0x10,0x00,0x31,0x26,0x02,0x00,0x00,0x10,0x04,0x00,0x03,0x24,
- 0x10,0x00,0x03,0x24,0x2a,0x08,0xc3,0x03,0xed,0xff,0x20,0x14,
- 0x21,0x80,0x51,0x02,0x6f,0xfd,0x00,0x10,0x00,0xa3,0x02,0x3c,
- 0x30,0x01,0xac,0x93,0x72,0x00,0x01,0x24,0x07,0x00,0x81,0x15,
- 0x00,0xa0,0x01,0x3c,0x25,0x68,0x41,0x02,0x00,0x00,0xa5,0x91,
- 0x29,0x2a,0x00,0x0c,0xb8,0x86,0x84,0x27,0x65,0xfd,0x00,0x10,
- 0x00,0xa3,0x02,0x3c,0x30,0x01,0xae,0x93,0x12,0x00,0x01,0x24,
- 0x07,0x00,0xc1,0x15,0x00,0xa0,0x01,0x3c,0x25,0x78,0x41,0x02,
- 0x00,0x00,0xe5,0x95,0x29,0x2a,0x00,0x0c,0xc0,0x86,0x84,0x27,
- 0x5b,0xfd,0x00,0x10,0x00,0xa3,0x02,0x3c,0x30,0x01,0xb8,0x93,
- 0x52,0x00,0x01,0x24,0x07,0x00,0x01,0x17,0x00,0xa0,0x01,0x3c,
- 0x25,0xc8,0x41,0x02,0x00,0x00,0x25,0x8f,0x29,0x2a,0x00,0x0c,
- 0xc8,0x86,0x84,0x27,0x51,0xfd,0x00,0x10,0x00,0xa3,0x02,0x3c,
- 0x30,0x01,0xa8,0x93,0x66,0x00,0x01,0x24,0x03,0x00,0x01,0x11,
- 0x77,0x00,0x01,0x24,0x06,0x00,0x01,0x15,0x30,0x01,0xa9,0x93,
- 0x29,0x2a,0x00,0x0c,0xd0,0x86,0x84,0x27,0x0d,0x00,0x00,0x10,
- 0x00,0x00,0x00,0x00,0x30,0x01,0xa9,0x93,0x06,0x00,0x01,0x24,
- 0x03,0x00,0x21,0x11,0x17,0x00,0x01,0x24,0x05,0x00,0x21,0x15,
- 0x00,0x00,0x00,0x00,0x29,0x2a,0x00,0x0c,0xd4,0x86,0x84,0x27,
- 0x03,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x29,0x2a,0x00,0x0c,
- 0xd8,0x86,0x84,0x27,0x29,0x2a,0x00,0x0c,0xdc,0x86,0x84,0x27,
- 0x14,0x23,0x00,0x0c,0x10,0x00,0x04,0x24,0x21,0x80,0x40,0x00,
- 0x29,0x2a,0x00,0x0c,0xf0,0x86,0x84,0x27,0x30,0x01,0xaa,0x93,
- 0x66,0x00,0x01,0x24,0x05,0x00,0x41,0x11,0x06,0x00,0x01,0x24,
- 0x03,0x00,0x41,0x11,0x46,0x00,0x01,0x24,0x0b,0x00,0x41,0x15,
- 0x21,0xa8,0x00,0x00,0x29,0x2a,0x00,0x0c,0xf4,0x86,0x84,0x27,
- 0x14,0x23,0x00,0x0c,0x10,0x00,0x04,0x24,0xff,0xff,0x55,0x24,
- 0x29,0x2a,0x00,0x0c,0x04,0x87,0x84,0x27,0x03,0x00,0x00,0x10,
- 0x00,0xa0,0x01,0x3c,0x21,0xa8,0x00,0x00,0x00,0xa0,0x01,0x3c,
- 0x25,0x90,0x41,0x02,0x30,0x01,0xab,0x93,0x77,0x00,0x01,0x24,
- 0x03,0x00,0x61,0x11,0x66,0x00,0x01,0x24,0x05,0x00,0x61,0x15,
- 0x30,0x01,0xad,0x93,0x21,0x60,0x55,0x02,0x0e,0x00,0x00,0x10,
- 0x00,0x00,0x90,0xa1,0x30,0x01,0xad,0x93,0x17,0x00,0x01,0x24,
- 0x03,0x00,0xa1,0x11,0x06,0x00,0x01,0x24,0x06,0x00,0xa1,0x15,
- 0x80,0xc0,0x15,0x00,0x40,0x70,0x15,0x00,0x21,0x78,0x4e,0x02,
- 0x04,0x00,0x00,0x10,0x00,0x00,0xf0,0xa5,0x80,0xc0,0x15,0x00,
- 0x21,0xc8,0x58,0x02,0x00,0x00,0x30,0xaf,0xff,0xff,0xb5,0x26,
- 0xe9,0xff,0xa1,0x06,0x30,0x01,0xab,0x93,0x05,0xfd,0x00,0x10,
- 0x00,0xa3,0x02,0x3c,0xc9,0x2a,0x00,0x0c,0x21,0x20,0x00,0x00,
- 0x00,0xa3,0x08,0x3c,0x88,0x01,0x02,0xad,0x01,0x00,0x09,0x24,
- 0x00,0xa3,0x0a,0x3c,0xfc,0xfc,0x00,0x10,0xc8,0x01,0x49,0xa1,
- 0x00,0xa3,0x04,0x3c,0x00,0xa3,0x05,0x3c,0x10,0x40,0xa5,0x34,
- 0x00,0x10,0x84,0x34,0x21,0x30,0x00,0x00,0x21,0x38,0x00,0x00,
- 0xfe,0x2b,0x00,0x0c,0x10,0x00,0xa0,0xaf,0x00,0xa3,0x0b,0x3c,
- 0x88,0x01,0x62,0xad,0x01,0x00,0x0c,0x24,0x00,0xa3,0x0d,0x3c,
- 0xee,0xfc,0x00,0x10,0xc8,0x01,0xac,0xa1,0x00,0xa3,0x0e,0x3c,
- 0x88,0x01,0xde,0x8d,0x10,0x00,0xa0,0xaf,0x21,0x28,0x00,0x00,
- 0x21,0x30,0x00,0x00,0x21,0x38,0x00,0x00,0x94,0x2e,0x00,0x0c,
- 0x21,0x20,0xc0,0x03,0x00,0xa3,0x0f,0x3c,0x88,0x01,0xe2,0xad,
- 0x01,0x00,0x18,0x24,0x00,0xa3,0x19,0x3c,0xe0,0xfc,0x00,0x10,
- 0xc8,0x01,0x38,0xa3,0x00,0xa3,0x02,0x3c,0x88,0x01,0x42,0x34,
- 0x00,0x00,0x5e,0x8c,0x00,0x00,0x55,0x8c,0xff,0xff,0x08,0x24,
- 0x02,0xaa,0x15,0x00,0xff,0x00,0xb5,0x32,0xff,0x00,0xde,0x33,
- 0x21,0x20,0xc0,0x03,0x23,0x28,0x15,0x01,0x10,0x00,0xa0,0xaf,
- 0x21,0x30,0x00,0x00,0x94,0x2e,0x00,0x0c,0x01,0x00,0x07,0x24,
- 0x00,0xa3,0x09,0x3c,0x88,0x01,0x22,0xad,0x01,0x00,0x0a,0x24,
- 0x00,0xa3,0x0b,0x3c,0xcc,0xfc,0x00,0x10,0xc8,0x01,0x6a,0xa1,
- 0x30,0x01,0xac,0x93,0x49,0x00,0x01,0x24,0x1d,0xff,0x81,0x11,
- 0x4a,0x00,0x81,0x2d,0x4d,0x00,0x20,0x10,0x33,0x00,0x01,0x24,
- 0x5d,0xfe,0x81,0x11,0x34,0x00,0x81,0x2d,0x25,0x00,0x20,0x10,
- 0x17,0x00,0x01,0x24,0x21,0xff,0x81,0x11,0x18,0x00,0x81,0x2d,
- 0x11,0x00,0x20,0x10,0x06,0x00,0x01,0x24,0x1d,0xff,0x81,0x11,
- 0x07,0x00,0x81,0x2d,0x05,0x00,0x20,0x10,0x04,0x00,0x01,0x24,
- 0x19,0xff,0x81,0x11,0x00,0x00,0x00,0x00,0x05,0x00,0x00,0x10,
- 0x00,0x00,0x00,0x00,0x30,0x01,0xad,0x93,0x12,0x00,0x01,0x24,
- 0x13,0xff,0xa1,0x11,0x00,0x00,0x00,0x00,0x29,0x2a,0x00,0x0c,
- 0x08,0x87,0x84,0x27,0xaf,0xfc,0x00,0x10,0x00,0xa3,0x02,0x3c,
- 0x30,0x01,0xae,0x93,0x31,0x00,0x01,0x24,0x95,0xfd,0xc1,0x11,
- 0x32,0x00,0xc1,0x2d,0x05,0x00,0x20,0x10,0x24,0x00,0x01,0x24,
- 0xed,0xfd,0xc1,0x11,0x00,0x00,0x00,0x00,0xf3,0xff,0x00,0x10,
- 0x00,0x00,0x00,0x00,0x30,0x01,0xaf,0x93,0x32,0x00,0x01,0x24,
- 0xad,0xfd,0xe1,0x11,0x00,0x00,0x00,0x00,0xed,0xff,0x00,0x10,
- 0x00,0x00,0x00,0x00,0x30,0x01,0xb8,0x93,0x41,0x00,0x01,0x24,
- 0xe4,0xfc,0x01,0x13,0x42,0x00,0x01,0x2f,0x0f,0x00,0x20,0x10,
- 0x35,0x00,0x01,0x24,0xa4,0xfe,0x01,0x13,0x36,0x00,0x01,0x2f,
- 0x05,0x00,0x20,0x10,0x34,0x00,0x01,0x24,0x2b,0xfe,0x01,0x13,
- 0x00,0x00,0x00,0x00,0xdf,0xff,0x00,0x10,0x00,0x00,0x00,0x00,
- 0x30,0x01,0xb9,0x93,0x3f,0x00,0x01,0x24,0xba,0xfc,0x21,0x13,
- 0x00,0x00,0x00,0x00,0xd9,0xff,0x00,0x10,0x00,0x00,0x00,0x00,
- 0x30,0x01,0xa8,0x93,0x45,0x00,0x01,0x24,0xce,0xfc,0x01,0x11,
- 0x46,0x00,0x01,0x2d,0x05,0x00,0x20,0x10,0x44,0x00,0x01,0x24,
- 0xe3,0xfe,0x01,0x11,0x00,0x00,0x00,0x00,0xcf,0xff,0x00,0x10,
- 0x00,0x00,0x00,0x00,0x30,0x01,0xa9,0x93,0x46,0x00,0x01,0x24,
- 0xdd,0xfe,0x21,0x11,0x00,0x00,0x00,0x00,0xc9,0xff,0x00,0x10,
- 0x00,0x00,0x00,0x00,0x30,0x01,0xaa,0x93,0x72,0x00,0x01,0x24,
- 0xd7,0xfe,0x41,0x11,0x73,0x00,0x41,0x2d,0x23,0x00,0x20,0x10,
- 0x64,0x00,0x01,0x24,0xd3,0xfe,0x41,0x11,0x65,0x00,0x41,0x2d,
- 0x0f,0x00,0x20,0x10,0x57,0x00,0x01,0x24,0xcf,0xfe,0x41,0x11,
- 0x58,0x00,0x41,0x2d,0x05,0x00,0x20,0x10,0x52,0x00,0x01,0x24,
- 0xcb,0xfe,0x41,0x11,0x00,0x00,0x00,0x00,0xb7,0xff,0x00,0x10,
- 0x00,0x00,0x00,0x00,0x30,0x01,0xab,0x93,0x61,0x00,0x01,0x24,
- 0xae,0xfc,0x61,0x11,0x00,0x00,0x00,0x00,0xb1,0xff,0x00,0x10,
- 0x00,0x00,0x00,0x00,0x30,0x01,0xac,0x93,0x66,0x00,0x01,0x24,
- 0xbf,0xfe,0x81,0x11,0x67,0x00,0x81,0x2d,0x05,0x00,0x20,0x10,
- 0x65,0x00,0x01,0x24,0xa4,0xfc,0x81,0x11,0x00,0x00,0x00,0x00,
- 0xa7,0xff,0x00,0x10,0x00,0x00,0x00,0x00,0x30,0x01,0xad,0x93,
- 0x69,0x00,0x01,0x24,0xa9,0xfe,0xa1,0x11,0x00,0x00,0x00,0x00,
- 0xa1,0xff,0x00,0x10,0x00,0x00,0x00,0x00,0x30,0x01,0xae,0x93,
- 0x83,0x00,0x01,0x24,0x61,0xff,0xc1,0x11,0x84,0x00,0xc1,0x2d,
- 0x0f,0x00,0x20,0x10,0x81,0x00,0x01,0x24,0x47,0xff,0xc1,0x11,
- 0x82,0x00,0xc1,0x2d,0x05,0x00,0x20,0x10,0x77,0x00,0x01,0x24,
- 0xa7,0xfe,0xc1,0x11,0x00,0x00,0x00,0x00,0x93,0xff,0x00,0x10,
- 0x00,0x00,0x00,0x00,0x30,0x01,0xaf,0x93,0x82,0x00,0x01,0x24,
- 0x46,0xff,0xe1,0x11,0x00,0xa3,0x04,0x3c,0x8d,0xff,0x00,0x10,
- 0x00,0x00,0x00,0x00,0x30,0x01,0xb8,0x93,0x84,0x00,0x01,0x24,
- 0x5c,0xff,0x01,0x13,0x00,0xa3,0x02,0x3c,0x87,0xff,0x00,0x10,
- 0x00,0x00,0x00,0x00,0x24,0x00,0xbf,0x8f,0x38,0x01,0xbd,0x27,
- 0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0x00,0xa3,0x03,0x3c,
- 0x80,0x01,0x63,0x34,0x4a,0x00,0x6e,0x94,0xff,0x00,0x84,0x30,
- 0x21,0x78,0x6e,0x00,0x50,0x00,0xe4,0xa1,0x4a,0x00,0x78,0x94,
- 0x4e,0x00,0x68,0x94,0x01,0x00,0x19,0x27,0x4c,0x00,0x69,0x94,
- 0x24,0x10,0x28,0x03,0xff,0xff,0x42,0x30,0x02,0x00,0x49,0x10,
- 0x00,0x00,0x00,0x00,0x4a,0x00,0x62,0xa4,0x08,0x00,0xe0,0x03,
- 0x00,0x00,0x00,0x00,0xe8,0xff,0xbd,0x27,0x14,0x00,0xbf,0xaf,
- 0x00,0xa3,0x0e,0x3c,0x80,0x01,0xcf,0x8d,0x01,0x00,0x01,0x24,
- 0x09,0x00,0xe1,0x15,0x00,0x00,0x00,0x00,0x30,0x87,0x83,0x97,
- 0x00,0x00,0x00,0x00,0x21,0x10,0x60,0x00,0xff,0xff,0x63,0x24,
- 0x03,0x00,0x40,0x10,0xff,0xff,0x63,0x30,0x0f,0x00,0x00,0x10,
- 0x30,0x87,0x83,0xa7,0x2c,0x87,0x98,0x97,0x00,0xa1,0x08,0x3c,
- 0x01,0x00,0x19,0x27,0x2c,0x87,0x99,0xa7,0xe8,0x03,0x03,0x24,
- 0x00,0x40,0x00,0xa5,0x30,0x87,0x83,0xa7,0xe1,0x21,0x00,0x0c,
- 0x21,0x20,0x00,0x00,0x01,0x00,0x09,0x24,0x00,0xa3,0x0a,0x3c,
- 0x80,0x01,0x49,0xad,0xe1,0x21,0x00,0x0c,0x01,0x04,0x04,0x24,
- 0x14,0x00,0xbf,0x8f,0x18,0x00,0xbd,0x27,0x08,0x00,0xe0,0x03,
- 0x00,0x00,0x00,0x00,0x00,0xa3,0x02,0x3c,0xcc,0x01,0x42,0x34,
- 0x00,0x00,0x4e,0x94,0x00,0x00,0x00,0x00,0x0d,0x00,0xc0,0x11,
- 0x00,0x00,0x00,0x00,0x00,0xa3,0x03,0x3c,0xca,0x01,0x63,0x34,
- 0x00,0x00,0x6f,0x94,0x00,0x00,0x58,0x94,0x00,0x00,0x00,0x00,
- 0x06,0x00,0xf8,0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x79,0x94,
- 0x00,0x00,0x48,0x94,0x00,0x00,0x00,0x00,0xfc,0xff,0x28,0x17,
- 0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x2b,0x08,0x85,0x00,0x08,0x00,0x20,0x10,
- 0x21,0x18,0x00,0x00,0x00,0x00,0x8e,0x8c,0x04,0x00,0x84,0x24,
- 0x21,0x10,0x6e,0x00,0x2b,0x78,0x43,0x00,0x2b,0x08,0x85,0x00,
- 0xfa,0xff,0x20,0x14,0x21,0x18,0x4f,0x00,0x08,0x00,0xe0,0x03,
- 0x21,0x10,0x60,0x00,0xe8,0xff,0xbd,0x27,0x00,0xa3,0x07,0x3c,
- 0x30,0x0c,0xe7,0x34,0x14,0x00,0xbf,0xaf,0x00,0x00,0xee,0x90,
- 0x00,0x00,0x00,0x00,0x3c,0x00,0xc0,0x11,0x14,0x00,0xbf,0x8f,
- 0x00,0xa3,0x0f,0x3c,0x32,0x0c,0xf8,0x91,0x00,0x00,0x00,0x00,
- 0x37,0x00,0x00,0x17,0x14,0x00,0xbf,0x8f,0x00,0xa3,0x03,0x3c,
- 0x34,0x0c,0x63,0x34,0x00,0x00,0x65,0x8c,0xff,0x3f,0x01,0x3c,
- 0x00,0xa3,0x06,0x3c,0xff,0xff,0x21,0x34,0x38,0x0c,0xc6,0x34,
- 0x24,0x28,0xa1,0x00,0x00,0x00,0xd9,0x94,0x00,0x80,0x01,0x3c,
- 0x25,0x28,0xa1,0x00,0x81,0x00,0x21,0x2f,0x03,0x00,0x20,0x14,
- 0x00,0x00,0x00,0x00,0x80,0x00,0x08,0x24,0x00,0x00,0xc8,0xa4,
- 0x00,0x00,0xe2,0x90,0x1d,0x00,0x00,0x10,0x01,0x00,0x01,0x24,
- 0x00,0xa3,0x04,0x3c,0x00,0x00,0xc2,0x94,0x21,0x18,0xa0,0x00,
- 0x05,0x00,0x00,0x10,0x3a,0x0c,0x84,0x34,0x00,0xa3,0x03,0x3c,
- 0x00,0x00,0xc2,0x94,0x3a,0x0c,0x63,0x34,0x21,0x20,0xa0,0x00,
- 0xff,0xff,0x42,0x24,0x07,0x00,0x40,0x04,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x69,0x90,0xff,0xff,0x42,0x24,0x01,0x00,0x63,0x24,
- 0x01,0x00,0x84,0x24,0xfb,0xff,0x41,0x04,0xff,0xff,0x89,0xa0,
- 0x0f,0x00,0x00,0x10,0x00,0x00,0xe0,0xa0,0x00,0x00,0xe0,0xa0,
- 0x00,0x00,0x6a,0x8c,0x00,0x00,0x00,0x00,0x09,0xf8,0x40,0x01,
- 0x00,0x00,0x00,0x00,0x09,0x00,0x00,0x10,0x14,0x00,0xbf,0x8f,
- 0x01,0x00,0x01,0x24,0xe3,0xff,0x41,0x10,0x02,0x00,0x01,0x24,
- 0xe6,0xff,0x41,0x10,0x03,0x00,0x01,0x24,0xf3,0xff,0x41,0x10,
- 0x00,0x00,0x00,0x00,0x14,0x00,0xbf,0x8f,0x18,0x00,0xbd,0x27,
- 0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0xe8,0xff,0xbd,0x27,0x14,0x00,0xbf,0xaf,
- 0x13,0x00,0x00,0x10,0xff,0x00,0x84,0x30,0x40,0x87,0x82,0x93,
- 0x00,0x00,0x00,0x00,0x01,0x00,0x4e,0x30,0x1a,0x00,0xc0,0x15,
- 0x14,0x00,0xbf,0x8f,0x01,0x00,0x42,0x34,0xff,0x00,0x42,0x30,
- 0x11,0x00,0x00,0x10,0x40,0x87,0x82,0xa3,0x40,0x87,0x82,0x93,
- 0x00,0x00,0x00,0x00,0x02,0x00,0x4f,0x30,0x11,0x00,0xe0,0x15,
- 0x14,0x00,0xbf,0x8f,0x02,0x00,0x42,0x34,0xff,0x00,0x42,0x30,
- 0x08,0x00,0x00,0x10,0x40,0x87,0x82,0xa3,0x0a,0x00,0x01,0x24,
- 0xec,0xff,0x81,0x10,0x0d,0x00,0x01,0x24,0xf3,0xff,0x81,0x10,
- 0x00,0x00,0x00,0x00,0x21,0x10,0x00,0x00,0x40,0x87,0x82,0xa3,
- 0xc1,0x27,0x00,0x0c,0x00,0x00,0x00,0x00,0xf3,0x27,0x00,0x0c,
- 0x00,0x00,0x00,0x00,0x14,0x00,0xbf,0x8f,0x18,0x00,0xbd,0x27,
- 0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0xe8,0xff,0xbd,0x27,
- 0x14,0x00,0xbf,0xaf,0x5c,0x28,0x00,0x0c,0xff,0x00,0x84,0x30,
- 0x14,0x00,0xbf,0x8f,0x18,0x00,0xbd,0x27,0x08,0x00,0xe0,0x03,
- 0x00,0x00,0x00,0x00,0xa0,0xff,0xbd,0x27,0x18,0x00,0xb0,0xaf,
- 0x1c,0x00,0xb1,0xaf,0x21,0x88,0xe0,0x00,0x24,0x00,0xbf,0xaf,
- 0x20,0x00,0xb2,0xaf,0x68,0x00,0xa6,0xaf,0x04,0x00,0xa0,0x14,
- 0x21,0x80,0x00,0x00,0x70,0x00,0xa2,0x8f,0x0a,0x00,0x00,0x10,
- 0x5b,0x00,0xb2,0x27,0x70,0x00,0xa2,0x8f,0x00,0x00,0x00,0x00,
- 0x06,0x00,0x41,0x04,0x5b,0x00,0xb2,0x27,0x2d,0x00,0x10,0x24,
- 0x02,0x00,0x20,0x12,0x23,0x10,0x02,0x00,0xff,0xff,0x31,0x26,
- 0x5b,0x00,0xb2,0x27,0x5b,0x00,0xa0,0xa3,0x44,0x87,0x83,0x27,
- 0x1b,0x00,0x44,0x00,0xff,0xff,0x52,0x26,0x10,0x70,0x00,0x00,
- 0x21,0x78,0x6e,0x00,0x00,0x00,0xf8,0x91,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x58,0xa2,0x02,0x00,0x80,0x14,0x00,0x00,0x00,0x00,
- 0x0d,0x00,0x07,0x00,0x02,0x00,0x20,0x12,0x00,0x00,0x00,0x00,
- 0xff,0xff,0x31,0x26,0x1b,0x00,0x44,0x00,0x12,0x10,0x00,0x00,
- 0x02,0x00,0x80,0x14,0x00,0x00,0x00,0x00,0x0d,0x00,0x07,0x00,
- 0xed,0xff,0x40,0x14,0x00,0x00,0x00,0x00,0x68,0x00,0xb9,0x93,
- 0x01,0x00,0x01,0x24,0x09,0x00,0x21,0x17,0x00,0x00,0x00,0x00,
- 0x21,0x10,0x20,0x02,0x06,0x00,0x40,0x10,0xff,0xff,0x31,0x26,
- 0x81,0x28,0x00,0x0c,0x20,0x00,0x04,0x24,0x21,0x10,0x20,0x02,
- 0xfc,0xff,0x40,0x14,0xff,0xff,0x31,0x26,0x04,0x00,0x00,0x12,
- 0x68,0x00,0xa8,0x93,0x81,0x28,0x00,0x0c,0x21,0x20,0x00,0x02,
- 0x68,0x00,0xa8,0x93,0x02,0x00,0x01,0x24,0x09,0x00,0x01,0x15,
- 0x00,0x00,0x00,0x00,0x21,0x10,0x20,0x02,0x06,0x00,0x40,0x10,
- 0xff,0xff,0x31,0x26,0x81,0x28,0x00,0x0c,0x30,0x00,0x04,0x24,
- 0x21,0x10,0x20,0x02,0xfc,0xff,0x40,0x14,0xff,0xff,0x31,0x26,
- 0x00,0x00,0x50,0x92,0x00,0x00,0x00,0x00,0x09,0x00,0x00,0x12,
- 0x68,0x00,0xa9,0x93,0x21,0x20,0x00,0x02,0x81,0x28,0x00,0x0c,
- 0x01,0x00,0x52,0x26,0x00,0x00,0x50,0x92,0x00,0x00,0x00,0x00,
- 0xfb,0xff,0x00,0x16,0x21,0x20,0x00,0x02,0x68,0x00,0xa9,0x93,
- 0x03,0x00,0x01,0x24,0x0a,0x00,0x21,0x15,0x24,0x00,0xbf,0x8f,
- 0x21,0x10,0x20,0x02,0x06,0x00,0x40,0x10,0xff,0xff,0x31,0x26,
- 0x81,0x28,0x00,0x0c,0x20,0x00,0x04,0x24,0x21,0x10,0x20,0x02,
- 0xfc,0xff,0x40,0x14,0xff,0xff,0x31,0x26,0x24,0x00,0xbf,0x8f,
- 0x18,0x00,0xb0,0x8f,0x1c,0x00,0xb1,0x8f,0x20,0x00,0xb2,0x8f,
- 0x08,0x00,0xe0,0x03,0x60,0x00,0xbd,0x27,0x00,0x00,0x82,0x90,
- 0x21,0x18,0x00,0x00,0x05,0x00,0x40,0x10,0x01,0x00,0x84,0x24,
- 0x00,0x00,0x82,0x90,0x01,0x00,0x63,0x24,0xfd,0xff,0x40,0x14,
- 0x01,0x00,0x84,0x24,0x08,0x00,0xe0,0x03,0x21,0x10,0x60,0x00,
- 0xd8,0xff,0xbd,0x27,0x20,0x00,0xb2,0xaf,0x21,0x90,0xc0,0x00,
- 0x24,0x00,0xbf,0xaf,0x1c,0x00,0xb1,0xaf,0x28,0x00,0xa4,0xaf,
- 0x21,0x88,0xa0,0x00,0x18,0x00,0xb0,0xaf,0xed,0x28,0x00,0x0c,
- 0x21,0x20,0x40,0x02,0x2a,0x08,0x51,0x00,0x03,0x00,0x20,0x10,
- 0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x10,0x23,0x88,0x22,0x02,
- 0x21,0x88,0x00,0x00,0x28,0x00,0xae,0x93,0x01,0x00,0x01,0x24,
- 0x0a,0x00,0xc1,0x15,0x28,0x00,0xaf,0x93,0x21,0x10,0x20,0x02,
- 0x06,0x00,0x40,0x10,0xff,0xff,0x31,0x26,0x81,0x28,0x00,0x0c,
- 0x20,0x00,0x04,0x24,0x21,0x10,0x20,0x02,0xfc,0xff,0x40,0x14,
- 0xff,0xff,0x31,0x26,0x28,0x00,0xaf,0x93,0x02,0x00,0x01,0x24,
- 0x09,0x00,0xe1,0x15,0x00,0x00,0x00,0x00,0x21,0x10,0x20,0x02,
- 0x06,0x00,0x40,0x10,0xff,0xff,0x31,0x26,0x81,0x28,0x00,0x0c,
- 0x30,0x00,0x04,0x24,0x21,0x10,0x20,0x02,0xfc,0xff,0x40,0x14,
- 0xff,0xff,0x31,0x26,0x00,0x00,0x50,0x92,0x00,0x00,0x00,0x00,
- 0x09,0x00,0x00,0x12,0x28,0x00,0xb8,0x93,0x21,0x20,0x00,0x02,
- 0x81,0x28,0x00,0x0c,0x01,0x00,0x52,0x26,0x00,0x00,0x50,0x92,
- 0x00,0x00,0x00,0x00,0xfb,0xff,0x00,0x16,0x21,0x20,0x00,0x02,
- 0x28,0x00,0xb8,0x93,0x03,0x00,0x01,0x24,0x0a,0x00,0x01,0x17,
- 0x24,0x00,0xbf,0x8f,0x21,0x10,0x20,0x02,0x06,0x00,0x40,0x10,
- 0xff,0xff,0x31,0x26,0x81,0x28,0x00,0x0c,0x20,0x00,0x04,0x24,
- 0x21,0x10,0x20,0x02,0xfc,0xff,0x40,0x14,0xff,0xff,0x31,0x26,
- 0x24,0x00,0xbf,0x8f,0x18,0x00,0xb0,0x8f,0x1c,0x00,0xb1,0x8f,
- 0x20,0x00,0xb2,0x8f,0x08,0x00,0xe0,0x03,0x28,0x00,0xbd,0x27,
- 0xc0,0xff,0xbd,0x27,0x40,0x00,0xa4,0xaf,0x40,0x00,0xae,0x8f,
- 0x24,0x00,0xbf,0xaf,0x44,0x00,0xa5,0xaf,0x01,0x00,0xcf,0x91,
- 0x21,0x40,0x00,0x00,0x21,0x38,0x00,0x00,0xdd,0x00,0xe0,0x11,
- 0x01,0x00,0x02,0x24,0x01,0x00,0xc9,0x25,0x00,0x00,0x23,0x91,
- 0x62,0x00,0x04,0x24,0x35,0x00,0x05,0x24,0x31,0x00,0x06,0x24,
- 0x2d,0x00,0x0a,0x24,0x30,0x00,0x0b,0x24,0x33,0x00,0x0c,0x24,
- 0x32,0x00,0x0d,0x24,0x34,0x00,0x1f,0x24,0x6d,0x00,0x00,0x10,
- 0x21,0x10,0x60,0x00,0x25,0x00,0x04,0x24,0x81,0x28,0x00,0x0c,
- 0x2c,0x00,0xa9,0xaf,0x2c,0x00,0xa9,0x8f,0xce,0x00,0x00,0x10,
- 0x01,0x00,0x22,0x25,0x21,0x20,0x00,0x00,0x21,0x28,0x00,0x00,
- 0x58,0x87,0x86,0x27,0xf7,0x28,0x00,0x0c,0x2c,0x00,0xa9,0xaf,
- 0x2c,0x00,0xa9,0x8f,0xc6,0x00,0x00,0x10,0x01,0x00,0x22,0x25,
- 0x44,0x00,0xa4,0x93,0x81,0x28,0x00,0x0c,0x2c,0x00,0xa9,0xaf,
- 0x2c,0x00,0xa9,0x8f,0xc0,0x00,0x00,0x10,0x01,0x00,0x22,0x25,
- 0x44,0x00,0xb8,0x8f,0x02,0x00,0x04,0x24,0x21,0x28,0x00,0x00,
- 0x21,0x30,0x00,0x01,0x2c,0x00,0xa9,0xaf,0x89,0x28,0x00,0x0c,
- 0x10,0x00,0xb8,0xaf,0x2c,0x00,0xa9,0x8f,0x81,0x28,0x00,0x0c,
- 0x42,0x00,0x04,0x24,0x2c,0x00,0xa9,0x8f,0xb3,0x00,0x00,0x10,
- 0x01,0x00,0x22,0x25,0x44,0x00,0xb9,0x8f,0x08,0x00,0x04,0x24,
- 0x21,0x28,0x00,0x00,0x21,0x30,0x00,0x01,0x2c,0x00,0xa9,0xaf,
- 0x89,0x28,0x00,0x0c,0x10,0x00,0xb9,0xaf,0x2c,0x00,0xa9,0x8f,
- 0x81,0x28,0x00,0x0c,0x51,0x00,0x04,0x24,0x2c,0x00,0xa9,0x8f,
- 0xa6,0x00,0x00,0x10,0x01,0x00,0x22,0x25,0x44,0x00,0xaf,0x8f,
- 0x0a,0x00,0x04,0x24,0x01,0x00,0x05,0x24,0x21,0x30,0x00,0x01,
- 0x2c,0x00,0xa9,0xaf,0x89,0x28,0x00,0x0c,0x10,0x00,0xaf,0xaf,
- 0x2c,0x00,0xa9,0x8f,0x9c,0x00,0x00,0x10,0x01,0x00,0x22,0x25,
- 0x44,0x00,0xae,0x8f,0x0a,0x00,0x04,0x24,0x21,0x28,0x00,0x00,
- 0x21,0x30,0x00,0x01,0x2c,0x00,0xa9,0xaf,0x89,0x28,0x00,0x0c,
- 0x10,0x00,0xae,0xaf,0x2c,0x00,0xa9,0x8f,0x92,0x00,0x00,0x10,
- 0x01,0x00,0x22,0x25,0x21,0x20,0x00,0x00,0x21,0x28,0x00,0x00,
- 0x64,0x87,0x86,0x27,0x34,0x00,0xa7,0xaf,0x38,0x00,0xa8,0xa3,
- 0xf7,0x28,0x00,0x0c,0x2c,0x00,0xa9,0xaf,0x34,0x00,0xa7,0x8f,
- 0x38,0x00,0xa8,0x93,0x2c,0x00,0xa9,0x8f,0x00,0x00,0x00,0x00,
- 0x44,0x00,0xb8,0x8f,0x10,0x00,0x04,0x24,0x21,0x28,0x00,0x00,
- 0x21,0x30,0x00,0x01,0x2c,0x00,0xa9,0xaf,0x89,0x28,0x00,0x0c,
- 0x10,0x00,0xb8,0xaf,0x2c,0x00,0xa9,0x8f,0x7d,0x00,0x00,0x10,
- 0x01,0x00,0x22,0x25,0x44,0x00,0xa6,0x8f,0x21,0x20,0x00,0x01,
- 0x21,0x28,0xe0,0x00,0xf7,0x28,0x00,0x0c,0x2c,0x00,0xa9,0xaf,
- 0x2c,0x00,0xa9,0x8f,0x75,0x00,0x00,0x10,0x01,0x00,0x22,0x25,
- 0x6c,0x00,0x00,0x10,0x03,0x00,0x08,0x24,0x03,0x00,0x00,0x15,
- 0x80,0xc8,0x07,0x00,0x02,0x00,0x08,0x24,0x80,0xc8,0x07,0x00,
- 0x21,0xc8,0x27,0x03,0x40,0xc8,0x19,0x00,0x21,0x38,0x23,0x03,
- 0x63,0x00,0x00,0x15,0xd0,0xff,0xe7,0x24,0x61,0x00,0x00,0x10,
- 0x01,0x00,0x08,0x24,0xa7,0xff,0x44,0x10,0x63,0x00,0x41,0x2c,
- 0x3e,0x00,0x20,0x10,0x6f,0x00,0x01,0x24,0xf3,0xff,0x45,0x10,
- 0x36,0x00,0x41,0x2c,0x1f,0x00,0x20,0x10,0x39,0x00,0x01,0x24,
- 0xef,0xff,0x46,0x10,0x32,0x00,0x41,0x2c,0x0e,0x00,0x20,0x10,
- 0x00,0x00,0x00,0x00,0xe6,0xff,0x4a,0x10,0x2e,0x00,0x41,0x2c,
- 0x05,0x00,0x20,0x10,0x25,0x00,0x01,0x24,0x84,0xff,0x41,0x10,
- 0x25,0x00,0x04,0x24,0x04,0x00,0x00,0x10,0x40,0x00,0xa2,0x8f,
- 0xe0,0xff,0x4b,0x10,0x00,0x00,0x00,0x00,0x40,0x00,0xa2,0x8f,
- 0x4f,0x00,0x00,0x10,0x01,0x00,0x42,0x24,0xde,0xff,0x4c,0x10,
- 0x34,0x00,0x41,0x2c,0x05,0x00,0x20,0x10,0x00,0x00,0x00,0x00,
- 0xdb,0xff,0x4d,0x10,0x80,0xc8,0x07,0x00,0xf7,0xff,0x00,0x10,
- 0x40,0x00,0xa2,0x8f,0xd7,0xff,0x5f,0x10,0x80,0xc8,0x07,0x00,
- 0xf3,0xff,0x00,0x10,0x40,0x00,0xa2,0x8f,0x39,0x00,0x01,0x24,
- 0xd1,0xff,0x41,0x10,0x3a,0x00,0x41,0x2c,0x0e,0x00,0x20,0x10,
- 0x37,0x00,0x01,0x24,0xcd,0xff,0x41,0x10,0x38,0x00,0x41,0x2c,
- 0x05,0x00,0x20,0x10,0x36,0x00,0x01,0x24,0xca,0xff,0x41,0x10,
- 0x80,0xc8,0x07,0x00,0xe6,0xff,0x00,0x10,0x40,0x00,0xa2,0x8f,
- 0x38,0x00,0x01,0x24,0xc5,0xff,0x41,0x10,0x80,0xc8,0x07,0x00,
- 0xe1,0xff,0x00,0x10,0x40,0x00,0xa2,0x8f,0x58,0x00,0x01,0x24,
- 0xa8,0xff,0x41,0x10,0x59,0x00,0x41,0x2c,0xdb,0xff,0x20,0x10,
- 0x45,0x00,0x01,0x24,0x5e,0xff,0x41,0x10,0x21,0x20,0x00,0x00,
- 0xd8,0xff,0x00,0x10,0x40,0x00,0xa2,0x8f,0x6f,0x00,0x01,0x24,
- 0x73,0xff,0x41,0x10,0x70,0x00,0x41,0x2c,0x0e,0x00,0x20,0x10,
- 0x64,0x00,0x01,0x24,0x7c,0xff,0x41,0x10,0x65,0x00,0x41,0x2c,
- 0x05,0x00,0x20,0x10,0x63,0x00,0x01,0x24,0x59,0xff,0x41,0x10,
- 0x44,0x00,0xa4,0x93,0xcb,0xff,0x00,0x10,0x40,0x00,0xa2,0x8f,
- 0x6c,0x00,0x01,0x24,0x11,0x00,0x41,0x10,0x00,0x00,0x00,0x00,
- 0xc6,0xff,0x00,0x10,0x40,0x00,0xa2,0x8f,0x75,0x00,0x01,0x24,
- 0x78,0xff,0x41,0x10,0x76,0x00,0x41,0x2c,0x05,0x00,0x20,0x10,
- 0x73,0x00,0x01,0x24,0x94,0xff,0x41,0x10,0x44,0x00,0xa6,0x8f,
- 0xbd,0xff,0x00,0x10,0x40,0x00,0xa2,0x8f,0x78,0x00,0x01,0x24,
- 0x7a,0xff,0x41,0x10,0x21,0x20,0x00,0x00,0xb8,0xff,0x00,0x10,
- 0x40,0x00,0xa2,0x8f,0x01,0x00,0x23,0x91,0x01,0x00,0x29,0x25,
- 0x2f,0xff,0x60,0x14,0x00,0x00,0x00,0x00,0x40,0x00,0xa2,0x8f,
- 0x00,0x00,0x00,0x00,0x01,0x00,0x42,0x24,0x24,0x00,0xbf,0x8f,
- 0x40,0x00,0xbd,0x27,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,
- 0xb8,0xff,0xbd,0x27,0x20,0x00,0xb4,0xaf,0x48,0x00,0xae,0x27,
- 0xfc,0xff,0x14,0x24,0x03,0x00,0xcf,0x25,0x24,0x00,0xbf,0xaf,
- 0x18,0x00,0xb0,0xaf,0x1c,0x00,0xb1,0xaf,0x48,0x00,0xa4,0xaf,
- 0x4c,0x00,0xa5,0xaf,0x50,0x00,0xa6,0xaf,0x54,0x00,0xa7,0xaf,
- 0x24,0x10,0xf4,0x01,0x00,0x00,0x50,0x8c,0x04,0x00,0x42,0x24,
- 0x00,0x00,0x04,0x92,0x21,0x88,0x40,0x00,0x25,0x00,0x80,0x10,
- 0x24,0x00,0xbf,0x8f,0x30,0x00,0xb2,0xaf,0x2c,0x00,0xb3,0xaf,
- 0x45,0x00,0x13,0x24,0x25,0x00,0x12,0x24,0x21,0x10,0x80,0x00,
- 0x14,0x00,0x52,0x14,0x00,0x00,0x00,0x00,0x01,0x00,0x02,0x92,
- 0x00,0x00,0x00,0x00,0x04,0x00,0x42,0x12,0x21,0x20,0x00,0x02,
- 0x07,0x00,0x62,0x16,0x03,0x00,0x38,0x26,0x21,0x20,0x00,0x02,
- 0x3c,0x29,0x00,0x0c,0x21,0x28,0x00,0x00,0x0b,0x00,0x00,0x10,
- 0x21,0x80,0x40,0x00,0x03,0x00,0x38,0x26,0x24,0x88,0x14,0x03,
- 0x00,0x00,0x25,0x8e,0x04,0x00,0x31,0x26,0x3c,0x29,0x00,0x0c,
- 0x21,0x20,0x00,0x02,0x03,0x00,0x00,0x10,0x21,0x80,0x40,0x00,
- 0x81,0x28,0x00,0x0c,0x01,0x00,0x10,0x26,0x00,0x00,0x04,0x92,
- 0x00,0x00,0x00,0x00,0xe5,0xff,0x80,0x14,0x00,0x00,0x00,0x00,
- 0x30,0x00,0xb2,0x8f,0x2c,0x00,0xb3,0x8f,0x00,0x00,0x00,0x00,
- 0x24,0x00,0xbf,0x8f,0x18,0x00,0xb0,0x8f,0x1c,0x00,0xb1,0x8f,
- 0x20,0x00,0xb4,0x8f,0x08,0x00,0xe0,0x03,0x48,0x00,0xbd,0x27,
- 0xe8,0xff,0xbd,0x27,0x14,0x00,0xbf,0xaf,0x29,0x2a,0x00,0x0c,
- 0x68,0x87,0x84,0x27,0x14,0x00,0xbf,0x8f,0x18,0x00,0xbd,0x27,
- 0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0xc0,0xff,0xbd,0x27,
- 0x14,0x00,0xb1,0xaf,0x21,0x88,0xa0,0x00,0x18,0x00,0xb2,0xaf,
- 0x21,0x90,0x80,0x00,0x24,0x00,0xbf,0xaf,0x20,0x00,0xb4,0xaf,
- 0x03,0x00,0x20,0x1e,0x1c,0x00,0xb3,0xaf,0x05,0x00,0x00,0x10,
- 0x01,0x00,0x11,0x24,0x1a,0x00,0x21,0x2a,0x03,0x00,0x20,0x14,
- 0x21,0x98,0x20,0x02,0x19,0x00,0x11,0x24,0x21,0x98,0x20,0x02,
- 0x21,0x10,0x20,0x02,0x21,0xa0,0x40,0x02,0x0d,0x00,0x40,0x10,
- 0xff,0xff,0x31,0x26,0x2c,0x00,0xb0,0xaf,0x70,0x87,0x90,0x27,
- 0x00,0x00,0x45,0x92,0x21,0x20,0x00,0x02,0x29,0x2a,0x00,0x0c,
- 0xff,0x00,0xa5,0x30,0x21,0x10,0x20,0x02,0x01,0x00,0x52,0x26,
- 0xf9,0xff,0x40,0x14,0xff,0xff,0x31,0x26,0x2c,0x00,0xb0,0x8f,
- 0x00,0x00,0x00,0x00,0x11,0x00,0x61,0x2a,0x18,0x00,0x20,0x10,
- 0x24,0x00,0xbf,0x8f,0x5c,0x28,0x00,0x0c,0x20,0x00,0x04,0x24,
- 0x21,0x10,0x60,0x02,0x12,0x00,0x40,0x10,0xff,0xff,0x73,0x26,
- 0x00,0x00,0x84,0x92,0x00,0x00,0x00,0x00,0x20,0x00,0x81,0x2c,
- 0x07,0x00,0x20,0x14,0x7f,0x00,0x81,0x2c,0x05,0x00,0x20,0x10,
- 0x00,0x00,0x00,0x00,0x5c,0x28,0x00,0x0c,0x00,0x00,0x00,0x00,
- 0x04,0x00,0x00,0x10,0x21,0x10,0x60,0x02,0x5c,0x28,0x00,0x0c,
- 0x2e,0x00,0x04,0x24,0x21,0x10,0x60,0x02,0x01,0x00,0x94,0x26,
- 0xf0,0xff,0x40,0x14,0xff,0xff,0x73,0x26,0x24,0x00,0xbf,0x8f,
- 0x14,0x00,0xb1,0x8f,0x18,0x00,0xb2,0x8f,0x1c,0x00,0xb3,0x8f,
- 0x20,0x00,0xb4,0x8f,0x08,0x00,0xe0,0x03,0x40,0x00,0xbd,0x27,
- 0xe0,0xff,0xbd,0x27,0x1c,0x00,0xbf,0xaf,0x18,0x00,0xb1,0xaf,
- 0x14,0x00,0xb0,0xaf,0x5c,0x28,0x00,0x0c,0x0d,0x00,0x04,0x24,
- 0x21,0x80,0x00,0x00,0x4e,0x00,0x11,0x24,0x5c,0x28,0x00,0x0c,
- 0x20,0x00,0x04,0x24,0x01,0x00,0x10,0x26,0xfc,0xff,0x11,0x16,
- 0x00,0x00,0x00,0x00,0x5c,0x28,0x00,0x0c,0x0d,0x00,0x04,0x24,
- 0x1c,0x00,0xbf,0x8f,0x14,0x00,0xb0,0x8f,0x18,0x00,0xb1,0x8f,
- 0x08,0x00,0xe0,0x03,0x20,0x00,0xbd,0x27,0x21,0x10,0x80,0x00,
- 0x04,0x00,0x40,0x10,0xff,0xff,0x84,0x24,0x21,0x10,0x80,0x00,
- 0xfe,0xff,0x40,0x14,0xff,0xff,0x84,0x24,0x08,0x00,0xe0,0x03,
- 0x00,0x00,0x00,0x00,0xc0,0xff,0xbd,0x27,0x2c,0x00,0xbf,0xaf,
- 0x28,0x00,0xb4,0xaf,0x20,0x00,0xb2,0xaf,0x24,0x00,0xb3,0xaf,
- 0x18,0x00,0xb0,0xaf,0x03,0x00,0x80,0x10,0x1c,0x00,0xb1,0xaf,
- 0xad,0x2a,0x00,0x0c,0x00,0x00,0x00,0x00,0x29,0x2a,0x00,0x0c,
- 0x78,0x87,0x84,0x27,0x34,0x00,0xa0,0xaf,0x00,0xa1,0x0e,0x3c,
- 0x00,0xa1,0x12,0x3c,0x00,0x40,0xc0,0xa5,0x0c,0x00,0x52,0x36,
- 0x63,0x00,0x10,0x24,0x00,0xa1,0x11,0x3c,0xd2,0x27,0x00,0x0c,
- 0x00,0x00,0x00,0x00,0xc1,0x2a,0x00,0x0c,0x0a,0x00,0x04,0x24,
- 0x34,0x00,0x0f,0x24,0x00,0x00,0x4f,0xa2,0xc1,0x2a,0x00,0x0c,
- 0x0a,0x00,0x04,0x24,0x10,0x00,0x18,0x24,0x00,0x00,0x38,0xa2,
- 0xc1,0x2a,0x00,0x0c,0x0a,0x00,0x04,0x24,0x10,0x00,0x19,0x24,
- 0x00,0x00,0x39,0xa2,0xc1,0x2a,0x00,0x0c,0x0a,0x00,0x04,0x24,
- 0xe2,0x00,0x08,0x24,0x00,0x00,0x48,0xa2,0xc1,0x2a,0x00,0x0c,
- 0x0a,0x00,0x04,0x24,0x00,0x00,0x29,0x92,0x00,0x00,0x00,0x00,
- 0x40,0x00,0x2a,0x31,0x05,0x00,0x40,0x11,0x2b,0x10,0x10,0x00,
- 0xff,0xff,0x10,0x26,0xe5,0xff,0x00,0x16,0x00,0x00,0x00,0x00,
- 0x2b,0x10,0x10,0x00,0x05,0x00,0x40,0x14,0x63,0x00,0x10,0x24,
- 0x08,0x00,0x0b,0x24,0x34,0x00,0xab,0xaf,0x29,0x2a,0x00,0x0c,
- 0x90,0x87,0x84,0x27,0x00,0xa1,0x13,0x3c,0x08,0x00,0x73,0x36,
- 0xff,0x00,0x14,0x24,0xd2,0x27,0x00,0x0c,0x00,0x00,0x00,0x00,
- 0xc1,0x2a,0x00,0x0c,0x0a,0x00,0x04,0x24,0xb4,0x00,0x0c,0x24,
- 0x00,0x00,0x4c,0xa2,0xc1,0x2a,0x00,0x0c,0x0a,0x00,0x04,0x24,
- 0x00,0x00,0x74,0xa2,0xc1,0x2a,0x00,0x0c,0x0a,0x00,0x04,0x24,
- 0x00,0x00,0x74,0xa2,0xc1,0x2a,0x00,0x0c,0x0a,0x00,0x04,0x24,
- 0xe8,0x00,0x0d,0x24,0x00,0x00,0x4d,0xa2,0xc1,0x2a,0x00,0x0c,
- 0x0a,0x00,0x04,0x24,0x00,0x00,0x6e,0x92,0x00,0x00,0x00,0x00,
- 0x40,0x00,0xcf,0x31,0x04,0x00,0xe0,0x11,0x00,0x00,0x00,0x00,
- 0xff,0xff,0x10,0x26,0xe7,0xff,0x00,0x16,0x00,0x00,0x00,0x00,
- 0x07,0x00,0x00,0x16,0x02,0x00,0x03,0x24,0x34,0x00,0xb8,0x8f,
- 0xac,0x87,0x84,0x27,0x08,0x00,0x19,0x37,0x29,0x2a,0x00,0x0c,
- 0x34,0x00,0xb9,0xaf,0x02,0x00,0x03,0x24,0xd2,0x27,0x00,0x0c,
- 0x3c,0x00,0xa3,0xaf,0x3c,0x00,0xa3,0x8f,0x00,0x00,0x00,0x00,
- 0x21,0x10,0x60,0x00,0xfa,0xff,0x40,0x14,0xff,0xff,0x63,0x24,
- 0xd8,0x00,0x08,0x24,0x00,0x00,0x48,0xa2,0xc1,0x2a,0x00,0x0c,
- 0x0a,0x00,0x04,0x24,0x00,0x00,0x70,0x92,0xc1,0x2a,0x00,0x0c,
- 0x0a,0x00,0x04,0x24,0x00,0x00,0x69,0x92,0x00,0x00,0x00,0x00,
- 0x05,0x00,0x89,0x16,0xff,0x00,0x01,0x24,0x04,0x00,0x01,0x16,
- 0x00,0xa1,0x0a,0x3c,0x29,0x2a,0x00,0x0c,0xc8,0x87,0x84,0x27,
- 0x00,0xa1,0x0a,0x3c,0x00,0x40,0x40,0xa5,0xe1,0x21,0x00,0x0c,
- 0x21,0x20,0x00,0x00,0x01,0x00,0x0b,0x24,0x00,0xa3,0x0c,0x3c,
- 0x80,0x01,0x8b,0xad,0xe1,0x21,0x00,0x0c,0x01,0x04,0x04,0x24,
- 0x00,0xa3,0x0d,0x3c,0x80,0x01,0xae,0x8d,0x01,0x00,0x01,0x24,
- 0x07,0x00,0xc1,0x11,0x06,0x00,0x03,0x3c,0x34,0x00,0xaf,0x8f,
- 0xe0,0x87,0x84,0x27,0x01,0x00,0xf8,0x35,0x29,0x2a,0x00,0x0c,
- 0x34,0x00,0xb8,0xaf,0x06,0x00,0x03,0x3c,0x7f,0x1a,0x63,0x34,
- 0xd2,0x27,0x00,0x0c,0x3c,0x00,0xa3,0xaf,0x00,0xa3,0x19,0x3c,
- 0x80,0x01,0x28,0x8f,0x3c,0x00,0xa3,0x8f,0x05,0x00,0x00,0x11,
- 0x00,0xa3,0x09,0x3c,0x21,0x10,0x60,0x00,0xf7,0xff,0x40,0x14,
- 0xff,0xff,0x63,0x24,0x00,0xa3,0x09,0x3c,0x80,0x01,0x2a,0x8d,
- 0x00,0x00,0x00,0x00,0x07,0x00,0x40,0x11,0x00,0xa1,0x0d,0x3c,
- 0x34,0x00,0xab,0x8f,0xfc,0x87,0x84,0x27,0x02,0x00,0x6c,0x35,
- 0x29,0x2a,0x00,0x0c,0x34,0x00,0xac,0xaf,0x00,0xa1,0x0d,0x3c,
- 0x00,0x40,0xa0,0xa5,0x63,0x00,0x10,0x24,0xd2,0x27,0x00,0x0c,
- 0x00,0x00,0x00,0x00,0xc1,0x2a,0x00,0x0c,0x0a,0x00,0x04,0x24,
- 0x34,0x00,0x0e,0x24,0x00,0x00,0x4e,0xa2,0xc1,0x2a,0x00,0x0c,
- 0x0a,0x00,0x04,0x24,0x00,0x00,0x34,0xa2,0xc1,0x2a,0x00,0x0c,
- 0x0a,0x00,0x04,0x24,0x00,0x00,0x34,0xa2,0xc1,0x2a,0x00,0x0c,
- 0x0a,0x00,0x04,0x24,0xe2,0x00,0x0f,0x24,0x00,0x00,0x4f,0xa2,
- 0xc1,0x2a,0x00,0x0c,0x0a,0x00,0x04,0x24,0x00,0x00,0x38,0x92,
- 0x00,0x00,0x00,0x00,0x40,0x00,0x19,0x33,0x05,0x00,0x20,0x13,
- 0x2b,0x10,0x10,0x00,0xff,0xff,0x10,0x26,0xe7,0xff,0x00,0x16,
- 0x00,0x00,0x00,0x00,0x2b,0x10,0x10,0x00,0x06,0x00,0x40,0x14,
- 0x63,0x00,0x10,0x24,0x34,0x00,0xa8,0x8f,0x1c,0x88,0x84,0x27,
- 0x08,0x00,0x09,0x35,0x29,0x2a,0x00,0x0c,0x34,0x00,0xa9,0xaf,
- 0xe1,0x21,0x00,0x0c,0x21,0x20,0x00,0x00,0x01,0x00,0x0a,0x24,
- 0x00,0xa3,0x0b,0x3c,0x80,0x01,0x6a,0xad,0xe1,0x21,0x00,0x0c,
- 0x01,0x04,0x04,0x24,0xc1,0x2a,0x00,0x0c,0x0a,0x00,0x04,0x24,
- 0xd2,0x27,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0xa3,0x0c,0x3c,
- 0x80,0x01,0x8d,0x8d,0x01,0x00,0x01,0x24,0x06,0x00,0xa1,0x11,
- 0x00,0x00,0x00,0x00,0x34,0x00,0xae,0x8f,0x38,0x88,0x84,0x27,
- 0x04,0x00,0xcf,0x35,0x29,0x2a,0x00,0x0c,0x34,0x00,0xaf,0xaf,
- 0xe1,0x21,0x00,0x0c,0x21,0x20,0x00,0x00,0x00,0xa1,0x18,0x3c,
- 0x00,0x40,0x00,0xa7,0xd2,0x27,0x00,0x0c,0x00,0x00,0x00,0x00,
- 0xc1,0x2a,0x00,0x0c,0x0a,0x00,0x04,0x24,0x34,0x00,0x19,0x24,
- 0x00,0x00,0x59,0xa2,0xc1,0x2a,0x00,0x0c,0x0a,0x00,0x04,0x24,
- 0xcc,0x00,0x08,0x24,0x00,0x00,0x28,0xa2,0xc1,0x2a,0x00,0x0c,
- 0x0a,0x00,0x04,0x24,0x1c,0x00,0x09,0x24,0x00,0x00,0x29,0xa2,
- 0xc1,0x2a,0x00,0x0c,0x0a,0x00,0x04,0x24,0xe2,0x00,0x0a,0x24,
- 0x00,0x00,0x4a,0xa2,0xc1,0x2a,0x00,0x0c,0x0a,0x00,0x04,0x24,
- 0x00,0x00,0x2b,0x92,0x00,0x00,0x00,0x00,0x40,0x00,0x6c,0x31,
- 0x05,0x00,0x80,0x11,0x2b,0x10,0x10,0x00,0xff,0xff,0x10,0x26,
- 0xe5,0xff,0x00,0x16,0x00,0x00,0x00,0x00,0x2b,0x10,0x10,0x00,
- 0x06,0x00,0x40,0x14,0x63,0x00,0x10,0x24,0x34,0x00,0xad,0x8f,
- 0x58,0x88,0x84,0x27,0x08,0x00,0xae,0x35,0x29,0x2a,0x00,0x0c,
- 0x34,0x00,0xae,0xaf,0xd2,0x27,0x00,0x0c,0x00,0x00,0x00,0x00,
- 0xc1,0x2a,0x00,0x0c,0x0a,0x00,0x04,0x24,0xb4,0x00,0x0f,0x24,
- 0x00,0x00,0x4f,0xa2,0xc1,0x2a,0x00,0x0c,0x0a,0x00,0x04,0x24,
- 0x00,0x00,0x74,0xa2,0xc1,0x2a,0x00,0x0c,0x0a,0x00,0x04,0x24,
- 0x00,0x00,0x74,0xa2,0xc1,0x2a,0x00,0x0c,0x0a,0x00,0x04,0x24,
- 0xe8,0x00,0x18,0x24,0x00,0x00,0x58,0xa2,0xc1,0x2a,0x00,0x0c,
- 0x0a,0x00,0x04,0x24,0x00,0x00,0x79,0x92,0x00,0x00,0x00,0x00,
- 0x40,0x00,0x28,0x33,0x04,0x00,0x00,0x11,0x00,0x00,0x00,0x00,
- 0xff,0xff,0x10,0x26,0xe7,0xff,0x00,0x16,0x00,0x00,0x00,0x00,
- 0x07,0x00,0x00,0x16,0x00,0xa1,0x0b,0x3c,0x34,0x00,0xa9,0x8f,
- 0x74,0x88,0x84,0x27,0x08,0x00,0x2a,0x35,0x29,0x2a,0x00,0x0c,
- 0x34,0x00,0xaa,0xaf,0x00,0xa1,0x0b,0x3c,0x00,0x40,0x60,0xa5,
- 0xe1,0x21,0x00,0x0c,0x21,0x20,0x00,0x00,0x01,0x00,0x0c,0x24,
- 0x00,0xa3,0x0d,0x3c,0x80,0x01,0xac,0xad,0xe1,0x21,0x00,0x0c,
- 0x01,0x04,0x04,0x24,0x34,0x00,0xae,0x8f,0x00,0x00,0x00,0x00,
- 0x04,0x00,0xc0,0x15,0x2c,0x00,0xbf,0x8f,0x65,0x2a,0x00,0x0c,
- 0x00,0x00,0x00,0x00,0x2c,0x00,0xbf,0x8f,0x34,0x00,0xa2,0x8f,
- 0x18,0x00,0xb0,0x8f,0x1c,0x00,0xb1,0x8f,0x20,0x00,0xb2,0x8f,
- 0x24,0x00,0xb3,0x8f,0x28,0x00,0xb4,0x8f,0x08,0x00,0xe0,0x03,
- 0x40,0x00,0xbd,0x27,0xb8,0xff,0xbd,0x27,0x50,0x00,0xa6,0xaf,
- 0x50,0x00,0xae,0x8f,0x40,0x00,0xb6,0xaf,0x3c,0x00,0xb5,0xaf,
- 0x21,0xa8,0xa0,0x00,0x21,0xb0,0x80,0x00,0x44,0x00,0xbf,0xaf,
- 0x38,0x00,0xb4,0xaf,0x30,0x00,0xb2,0xaf,0x34,0x00,0xb3,0xaf,
- 0x28,0x00,0xb0,0xaf,0x09,0x00,0xc0,0x11,0x2c,0x00,0xb1,0xaf,
- 0x03,0x00,0xe0,0x10,0x00,0x00,0x00,0x00,0xad,0x2a,0x00,0x0c,
- 0x00,0x00,0x00,0x00,0xbc,0x88,0x84,0x27,0x21,0x28,0xc0,0x02,
- 0x29,0x2a,0x00,0x0c,0x21,0x30,0xa0,0x02,0x2b,0x08,0xb6,0x02,
- 0x21,0xa0,0x00,0x00,0x05,0x00,0x20,0x14,0x21,0x80,0xc0,0x02,
- 0x04,0x00,0x10,0x26,0x2b,0x08,0xb0,0x02,0xfd,0xff,0x20,0x10,
- 0xfc,0xff,0x00,0xae,0xd2,0x27,0x00,0x0c,0x00,0x00,0x00,0x00,
- 0x58,0x00,0xaf,0x8f,0x00,0x00,0x00,0x00,0xa3,0x00,0xe0,0x11,
- 0x2b,0x08,0xb6,0x02,0x08,0x00,0x20,0x10,0x21,0x80,0xc0,0x02,
- 0x77,0x77,0x13,0x3c,0x33,0x33,0x12,0x3c,0x11,0x11,0x11,0x3c,
- 0x11,0x11,0x31,0x36,0x33,0x33,0x52,0x36,0x4e,0x00,0x00,0x10,
- 0x77,0x77,0x73,0x36,0x11,0x11,0x11,0x3c,0x33,0x33,0x12,0x3c,
- 0x77,0x77,0x13,0x3c,0x77,0x77,0x73,0x36,0x33,0x33,0x52,0x36,
- 0x11,0x11,0x31,0x36,0x00,0x00,0x18,0x8e,0x00,0x00,0x00,0x00,
- 0x08,0x00,0x00,0x13,0x00,0x00,0x00,0x00,0x90,0x88,0x84,0x8f,
- 0x00,0x00,0x07,0x8e,0x10,0x00,0xb0,0xaf,0x01,0x00,0x05,0x24,
- 0x29,0x2a,0x00,0x0c,0x21,0x30,0x00,0x00,0x01,0x00,0x94,0x36,
- 0x00,0x00,0x11,0xae,0x00,0x00,0x19,0x8e,0x00,0x00,0x00,0x00,
- 0x09,0x00,0x39,0x12,0x00,0x00,0x00,0x00,0x90,0x88,0x84,0x8f,
- 0x11,0x11,0x06,0x3c,0x00,0x00,0x07,0x8e,0x10,0x00,0xb0,0xaf,
- 0x11,0x11,0xc6,0x34,0x29,0x2a,0x00,0x0c,0x02,0x00,0x05,0x24,
- 0x02,0x00,0x94,0x36,0x00,0x00,0x12,0xae,0x00,0x00,0x08,0x8e,
- 0x00,0x00,0x00,0x00,0x09,0x00,0x48,0x12,0x00,0x00,0x00,0x00,
- 0x90,0x88,0x84,0x8f,0x33,0x33,0x06,0x3c,0x00,0x00,0x07,0x8e,
- 0x10,0x00,0xb0,0xaf,0x33,0x33,0xc6,0x34,0x29,0x2a,0x00,0x0c,
- 0x03,0x00,0x05,0x24,0x04,0x00,0x94,0x36,0x00,0x00,0x13,0xae,
- 0x00,0x00,0x09,0x8e,0x00,0x00,0x00,0x00,0x0a,0x00,0x69,0x12,
- 0xff,0xff,0x0a,0x24,0x90,0x88,0x84,0x8f,0x77,0x77,0x06,0x3c,
- 0x00,0x00,0x07,0x8e,0x10,0x00,0xb0,0xaf,0x77,0x77,0xc6,0x34,
- 0x29,0x2a,0x00,0x0c,0x04,0x00,0x05,0x24,0x08,0x00,0x94,0x36,
- 0xff,0xff,0x0a,0x24,0x00,0x00,0x0a,0xae,0x00,0x00,0x0b,0x8e,
- 0xff,0xff,0x01,0x24,0x09,0x00,0x61,0x11,0xff,0x00,0x0c,0x32,
- 0x90,0x88,0x84,0x8f,0x00,0x00,0x07,0x8e,0x10,0x00,0xb0,0xaf,
- 0x05,0x00,0x05,0x24,0x29,0x2a,0x00,0x0c,0xff,0xff,0x06,0x24,
- 0x10,0x00,0x94,0x36,0xff,0x00,0x0c,0x32,0x03,0x00,0x80,0x15,
- 0x00,0x00,0x00,0x00,0xd2,0x27,0x00,0x0c,0x00,0x00,0x00,0x00,
- 0x04,0x00,0x10,0x26,0x2b,0x08,0xb0,0x02,0xb9,0xff,0x20,0x10,
- 0x2b,0x08,0xb6,0x02,0xee,0x01,0x20,0x14,0x21,0x80,0xa0,0x02,
- 0x00,0x00,0x0d,0x8e,0xff,0xff,0x01,0x24,0x08,0x00,0xa1,0x11,
- 0x00,0x00,0x00,0x00,0x90,0x88,0x84,0x8f,0x00,0x00,0x07,0x8e,
- 0x10,0x00,0xb0,0xaf,0x06,0x00,0x05,0x24,0x29,0x2a,0x00,0x0c,
- 0xff,0xff,0x06,0x24,0x20,0x00,0x94,0x36,0x00,0x00,0x13,0xae,
- 0x00,0x00,0x0e,0x8e,0x00,0x00,0x00,0x00,0x09,0x00,0x6e,0x12,
- 0x00,0x00,0x00,0x00,0x90,0x88,0x84,0x8f,0x77,0x77,0x06,0x3c,
- 0x00,0x00,0x07,0x8e,0x10,0x00,0xb0,0xaf,0x77,0x77,0xc6,0x34,
- 0x29,0x2a,0x00,0x0c,0x07,0x00,0x05,0x24,0x40,0x00,0x94,0x36,
- 0x00,0x00,0x12,0xae,0x00,0x00,0x0f,0x8e,0x00,0x00,0x00,0x00,
- 0x09,0x00,0x4f,0x12,0x00,0x00,0x00,0x00,0x90,0x88,0x84,0x8f,
- 0x33,0x33,0x06,0x3c,0x00,0x00,0x07,0x8e,0x10,0x00,0xb0,0xaf,
- 0x33,0x33,0xc6,0x34,0x29,0x2a,0x00,0x0c,0x08,0x00,0x05,0x24,
- 0x80,0x00,0x94,0x36,0x00,0x00,0x11,0xae,0x00,0x00,0x18,0x8e,
- 0x00,0x00,0x00,0x00,0x09,0x00,0x38,0x12,0x00,0x00,0x00,0x00,
- 0x90,0x88,0x84,0x8f,0x11,0x11,0x06,0x3c,0x00,0x00,0x07,0x8e,
- 0x10,0x00,0xb0,0xaf,0x11,0x11,0xc6,0x34,0x29,0x2a,0x00,0x0c,
- 0x09,0x00,0x05,0x24,0x00,0x01,0x94,0x36,0x00,0x00,0x00,0xae,
- 0x00,0x00,0x19,0x8e,0x00,0x00,0x00,0x00,0x09,0x00,0x20,0x13,
- 0xff,0x00,0x08,0x32,0x90,0x88,0x84,0x8f,0x00,0x00,0x07,0x8e,
- 0x10,0x00,0xb0,0xaf,0x0a,0x00,0x05,0x24,0x29,0x2a,0x00,0x0c,
- 0x21,0x30,0x00,0x00,0x00,0x02,0x94,0x36,0xff,0x00,0x08,0x32,
- 0x03,0x00,0x00,0x15,0x00,0x00,0x00,0x00,0xd2,0x27,0x00,0x0c,
- 0x00,0x00,0x00,0x00,0xfc,0xff,0x10,0x26,0x2b,0x08,0x16,0x02,
- 0xba,0xff,0x20,0x10,0x00,0x00,0x00,0x00,0xa5,0x01,0x00,0x10,
- 0x00,0x00,0x00,0x00,0x2b,0x08,0xb6,0x02,0x37,0x00,0x20,0x14,
- 0x21,0x98,0xc0,0x02,0x01,0x00,0x12,0x24,0x21,0x88,0x00,0x00,
- 0x00,0x00,0x69,0x92,0x00,0x00,0x00,0x00,0x09,0x00,0x29,0x12,
- 0x25,0x80,0x32,0x02,0x90,0x88,0x84,0x8f,0x00,0x00,0x67,0x92,
- 0x10,0x00,0xb3,0xaf,0x01,0x00,0x05,0x24,0x29,0x2a,0x00,0x0c,
- 0x21,0x30,0x20,0x02,0x01,0x00,0x94,0x36,0x25,0x80,0x32,0x02,
- 0x00,0x00,0x70,0xa2,0x00,0x00,0x6a,0x92,0x00,0x00,0x00,0x00,
- 0x08,0x00,0x0a,0x12,0x00,0x00,0x00,0x00,0x90,0x88,0x84,0x8f,
- 0x00,0x00,0x67,0x92,0x10,0x00,0xb3,0xaf,0x02,0x00,0x05,0x24,
- 0x29,0x2a,0x00,0x0c,0x21,0x30,0x00,0x02,0x02,0x00,0x94,0x36,
- 0x00,0x00,0x71,0xa2,0x00,0x00,0x6b,0x92,0x00,0x00,0x00,0x00,
- 0x08,0x00,0x2b,0x12,0x00,0x00,0x00,0x00,0x90,0x88,0x84,0x8f,
- 0x00,0x00,0x67,0x92,0x10,0x00,0xb3,0xaf,0x03,0x00,0x05,0x24,
- 0x29,0x2a,0x00,0x0c,0x21,0x30,0x20,0x02,0x04,0x00,0x94,0x36,
- 0x40,0x90,0x12,0x00,0xff,0x00,0x52,0x32,0xff,0xff,0x51,0x26,
- 0x00,0x00,0x70,0xa2,0xd7,0xff,0x40,0x16,0xff,0x00,0x31,0x32,
- 0xff,0x00,0x6c,0x32,0x03,0x00,0x80,0x15,0x00,0x00,0x00,0x00,
- 0xd2,0x27,0x00,0x0c,0x00,0x00,0x00,0x00,0x01,0x00,0x73,0x26,
- 0x2b,0x08,0xb3,0x02,0xcd,0xff,0x20,0x10,0x01,0x00,0x12,0x24,
- 0x21,0x98,0xc0,0x02,0x2b,0x08,0xb6,0x02,0x1f,0x00,0x20,0x14,
- 0x2b,0x08,0xb6,0x02,0x01,0x00,0x12,0x24,0xfe,0x00,0x11,0x24,
- 0x00,0x00,0x6d,0x92,0x25,0x80,0x32,0x02,0x08,0x00,0x0d,0x12,
- 0x00,0x00,0x00,0x00,0x90,0x88,0x84,0x8f,0x00,0x00,0x67,0x92,
- 0x10,0x00,0xb3,0xaf,0x04,0x00,0x05,0x24,0x29,0x2a,0x00,0x0c,
- 0x21,0x30,0x00,0x02,0x08,0x00,0x94,0x36,0x00,0x00,0x71,0xa2,
- 0x40,0x88,0x11,0x00,0x40,0x90,0x12,0x00,0xff,0x00,0x52,0x32,
- 0x01,0x00,0x31,0x36,0x00,0x00,0x70,0xa2,0xee,0xff,0x40,0x16,
- 0xff,0x00,0x31,0x32,0xff,0x00,0x6e,0x32,0x03,0x00,0xc0,0x15,
- 0x00,0x00,0x00,0x00,0xd2,0x27,0x00,0x0c,0x00,0x00,0x00,0x00,
- 0x01,0x00,0x73,0x26,0x2b,0x08,0xb3,0x02,0xe3,0xff,0x20,0x10,
- 0x2b,0x08,0xb6,0x02,0x20,0x00,0x20,0x14,0x21,0x98,0xa0,0x02,
- 0x80,0x00,0x12,0x24,0x7f,0x00,0x11,0x24,0x00,0x00,0x6f,0x92,
- 0x25,0x80,0x32,0x02,0x08,0x00,0x0f,0x12,0x00,0x00,0x00,0x00,
- 0x90,0x88,0x84,0x8f,0x00,0x00,0x67,0x92,0x10,0x00,0xb3,0xaf,
- 0x05,0x00,0x05,0x24,0x29,0x2a,0x00,0x0c,0x21,0x30,0x00,0x02,
- 0x10,0x00,0x94,0x36,0x00,0x00,0x71,0xa2,0x00,0x00,0x70,0xa2,
- 0x00,0x00,0x71,0xa2,0x42,0x90,0x12,0x00,0xff,0x00,0x52,0x32,
- 0x42,0x88,0x11,0x00,0xee,0xff,0x40,0x16,0xff,0x00,0x31,0x32,
- 0xff,0x00,0x78,0x32,0x03,0x00,0x00,0x17,0x00,0x00,0x00,0x00,
- 0xd2,0x27,0x00,0x0c,0x00,0x00,0x00,0x00,0xff,0xff,0x73,0x26,
- 0x2b,0x08,0x76,0x02,0xe4,0xff,0x20,0x10,0x80,0x00,0x12,0x24,
- 0x21,0x98,0xa0,0x02,0x2b,0x08,0xb6,0x02,0x1b,0x00,0x20,0x14,
- 0x00,0x00,0x00,0x00,0x80,0x00,0x12,0x24,0x00,0x00,0x79,0x92,
- 0x00,0x00,0x00,0x00,0x08,0x00,0x20,0x13,0x00,0x00,0x00,0x00,
- 0x90,0x88,0x84,0x8f,0x00,0x00,0x67,0x92,0x10,0x00,0xb3,0xaf,
- 0x06,0x00,0x05,0x24,0x29,0x2a,0x00,0x0c,0x21,0x30,0x00,0x00,
- 0x20,0x00,0x94,0x36,0x00,0x00,0x72,0xa2,0x42,0x90,0x12,0x00,
- 0xff,0x00,0x52,0x32,0xf1,0xff,0x40,0x16,0x00,0x00,0x60,0xa2,
- 0xff,0x00,0x68,0x32,0x03,0x00,0x00,0x15,0x00,0x00,0x00,0x00,
- 0xd2,0x27,0x00,0x0c,0x00,0x00,0x00,0x00,0xff,0xff,0x73,0x26,
- 0x2b,0x08,0x76,0x02,0xe8,0xff,0x20,0x10,0x80,0x00,0x12,0x24,
- 0x00,0x44,0x13,0x3c,0x00,0x11,0x73,0x36,0x0f,0x00,0x12,0x24,
- 0x01,0x00,0x49,0x32,0x21,0x88,0x00,0x00,0x02,0x00,0x20,0x11,
- 0x21,0x80,0xc0,0x02,0x21,0x88,0x60,0x02,0x02,0x00,0x4a,0x32,
- 0x03,0x00,0x40,0x11,0x00,0x11,0x01,0x3c,0x00,0x44,0x21,0x34,
- 0x25,0x88,0x21,0x02,0x04,0x00,0x4b,0x32,0x03,0x00,0x60,0x11,
- 0x88,0x00,0x01,0x3c,0x22,0x00,0x21,0x34,0x25,0x88,0x21,0x02,
- 0x08,0x00,0x4c,0x32,0x03,0x00,0x80,0x11,0x22,0x00,0x01,0x3c,
- 0x88,0x00,0x21,0x34,0x25,0x88,0x21,0x02,0x2b,0x08,0xb6,0x02,
- 0x06,0x00,0x20,0x14,0x00,0x00,0x00,0x00,0x04,0x00,0x10,0x26,
- 0x2b,0x08,0xb0,0x02,0xfd,0xff,0x20,0x10,0xfc,0xff,0x11,0xae,
- 0x21,0x80,0xc0,0x02,0xd2,0x27,0x00,0x0c,0x00,0x00,0x00,0x00,
- 0x2b,0x08,0xb6,0x02,0x17,0x00,0x20,0x14,0x55,0xaa,0x01,0x3c,
- 0x00,0x00,0x0d,0x8e,0x00,0x00,0x00,0x00,0x09,0x00,0x2d,0x12,
- 0xff,0x00,0x0e,0x32,0x90,0x88,0x84,0x8f,0x00,0x00,0x07,0x8e,
- 0x10,0x00,0xb0,0xaf,0x07,0x00,0x05,0x24,0x29,0x2a,0x00,0x0c,
- 0x21,0x30,0x20,0x02,0x40,0x00,0x94,0x36,0xff,0x00,0x0e,0x32,
- 0x03,0x00,0xc0,0x15,0x00,0x00,0x00,0x00,0xd2,0x27,0x00,0x0c,
- 0x00,0x00,0x00,0x00,0x04,0x00,0x10,0x26,0x2b,0x08,0xb0,0x02,
- 0xed,0xff,0x20,0x10,0x00,0x00,0x00,0x00,0x21,0x80,0xc0,0x02,
- 0x55,0xaa,0x01,0x3c,0x55,0xaa,0x21,0x34,0x25,0x88,0x21,0x02,
- 0x2b,0x08,0xb6,0x02,0x06,0x00,0x20,0x14,0x00,0x00,0x00,0x00,
- 0x04,0x00,0x10,0x26,0x2b,0x08,0xb0,0x02,0xfd,0xff,0x20,0x10,
- 0xfc,0xff,0x11,0xae,0x21,0x80,0xc0,0x02,0xd2,0x27,0x00,0x0c,
- 0x00,0x00,0x00,0x00,0x2b,0x08,0xb6,0x02,0x17,0x00,0x20,0x14,
- 0xaa,0x55,0x01,0x3c,0x00,0x00,0x0f,0x8e,0x00,0x00,0x00,0x00,
- 0x09,0x00,0x2f,0x12,0xff,0x00,0x18,0x32,0x90,0x88,0x84,0x8f,
- 0x00,0x00,0x07,0x8e,0x10,0x00,0xb0,0xaf,0x08,0x00,0x05,0x24,
- 0x29,0x2a,0x00,0x0c,0x21,0x30,0x20,0x02,0x80,0x00,0x94,0x36,
- 0xff,0x00,0x18,0x32,0x03,0x00,0x00,0x17,0x00,0x00,0x00,0x00,
- 0xd2,0x27,0x00,0x0c,0x00,0x00,0x00,0x00,0x04,0x00,0x10,0x26,
- 0x2b,0x08,0xb0,0x02,0xed,0xff,0x20,0x10,0x00,0x00,0x00,0x00,
- 0x21,0x80,0xc0,0x02,0xaa,0x55,0x01,0x3c,0xaa,0x55,0x21,0x34,
- 0x24,0x88,0x21,0x02,0x2b,0x08,0xb6,0x02,0x06,0x00,0x20,0x14,
- 0x00,0x00,0x00,0x00,0x04,0x00,0x10,0x26,0x2b,0x08,0xb0,0x02,
- 0xfd,0xff,0x20,0x10,0xfc,0xff,0x11,0xae,0x21,0x80,0xc0,0x02,
- 0xd2,0x27,0x00,0x0c,0x00,0x00,0x00,0x00,0x2b,0x08,0xb6,0x02,
- 0x15,0x00,0x20,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x19,0x8e,
- 0x00,0x00,0x00,0x00,0x09,0x00,0x39,0x12,0xff,0x00,0x08,0x32,
- 0x90,0x88,0x84,0x8f,0x00,0x00,0x07,0x8e,0x10,0x00,0xb0,0xaf,
- 0x09,0x00,0x05,0x24,0x29,0x2a,0x00,0x0c,0x21,0x30,0x20,0x02,
- 0x00,0x01,0x94,0x36,0xff,0x00,0x08,0x32,0x03,0x00,0x00,0x15,
- 0x00,0x00,0x00,0x00,0xd2,0x27,0x00,0x0c,0x00,0x00,0x00,0x00,
- 0x04,0x00,0x10,0x26,0x2b,0x08,0xb0,0x02,0xed,0xff,0x20,0x10,
- 0x00,0x00,0x00,0x00,0xff,0xff,0x52,0x26,0xff,0xff,0x01,0x24,
- 0x7f,0xff,0x41,0x16,0x01,0x00,0x49,0x32,0x00,0x88,0x13,0x3c,
- 0x00,0x22,0x73,0x36,0x0f,0x00,0x12,0x24,0x01,0x00,0x49,0x32,
- 0x21,0x88,0x00,0x00,0x02,0x00,0x20,0x11,0x21,0x80,0xc0,0x02,
- 0x21,0x88,0x60,0x02,0x02,0x00,0x4a,0x32,0x03,0x00,0x40,0x11,
- 0x00,0x22,0x01,0x3c,0x00,0x88,0x21,0x34,0x25,0x88,0x21,0x02,
- 0x04,0x00,0x4b,0x32,0x03,0x00,0x60,0x11,0x44,0x00,0x01,0x3c,
- 0x11,0x00,0x21,0x34,0x25,0x88,0x21,0x02,0x08,0x00,0x4c,0x32,
- 0x03,0x00,0x80,0x11,0x11,0x00,0x01,0x3c,0x44,0x00,0x21,0x34,
- 0x25,0x88,0x21,0x02,0x2b,0x08,0xb6,0x02,0x06,0x00,0x20,0x14,
- 0x00,0x00,0x00,0x00,0x04,0x00,0x10,0x26,0x2b,0x08,0xb0,0x02,
- 0xfd,0xff,0x20,0x10,0xfc,0xff,0x11,0xae,0x21,0x80,0xc0,0x02,
- 0xd2,0x27,0x00,0x0c,0x00,0x00,0x00,0x00,0x2b,0x08,0xb6,0x02,
- 0x17,0x00,0x20,0x14,0xaa,0x55,0x01,0x3c,0x00,0x00,0x0d,0x8e,
- 0x00,0x00,0x00,0x00,0x09,0x00,0x2d,0x12,0xff,0x00,0x0e,0x32,
- 0x90,0x88,0x84,0x8f,0x00,0x00,0x07,0x8e,0x10,0x00,0xb0,0xaf,
- 0x0a,0x00,0x05,0x24,0x29,0x2a,0x00,0x0c,0x21,0x30,0x20,0x02,
- 0x00,0x02,0x94,0x36,0xff,0x00,0x0e,0x32,0x03,0x00,0xc0,0x15,
- 0x00,0x00,0x00,0x00,0xd2,0x27,0x00,0x0c,0x00,0x00,0x00,0x00,
- 0x04,0x00,0x10,0x26,0x2b,0x08,0xb0,0x02,0xed,0xff,0x20,0x10,
- 0x00,0x00,0x00,0x00,0x21,0x80,0xc0,0x02,0xaa,0x55,0x01,0x3c,
- 0xaa,0x55,0x21,0x34,0x25,0x88,0x21,0x02,0x2b,0x08,0xb6,0x02,
- 0x06,0x00,0x20,0x14,0x00,0x00,0x00,0x00,0x04,0x00,0x10,0x26,
- 0x2b,0x08,0xb0,0x02,0xfd,0xff,0x20,0x10,0xfc,0xff,0x11,0xae,
- 0x21,0x80,0xc0,0x02,0xd2,0x27,0x00,0x0c,0x00,0x00,0x00,0x00,
- 0x2b,0x08,0xb6,0x02,0x17,0x00,0x20,0x14,0x55,0xaa,0x01,0x3c,
- 0x00,0x00,0x0f,0x8e,0x00,0x00,0x00,0x00,0x09,0x00,0x2f,0x12,
- 0xff,0x00,0x18,0x32,0x90,0x88,0x84,0x8f,0x00,0x00,0x07,0x8e,
- 0x10,0x00,0xb0,0xaf,0x0b,0x00,0x05,0x24,0x29,0x2a,0x00,0x0c,
- 0x21,0x30,0x20,0x02,0x00,0x02,0x94,0x36,0xff,0x00,0x18,0x32,
- 0x03,0x00,0x00,0x17,0x00,0x00,0x00,0x00,0xd2,0x27,0x00,0x0c,
- 0x00,0x00,0x00,0x00,0x04,0x00,0x10,0x26,0x2b,0x08,0xb0,0x02,
- 0xed,0xff,0x20,0x10,0x00,0x00,0x00,0x00,0x21,0x80,0xc0,0x02,
- 0x55,0xaa,0x01,0x3c,0x55,0xaa,0x21,0x34,0x24,0x88,0x21,0x02,
- 0x2b,0x08,0xb6,0x02,0x06,0x00,0x20,0x14,0x00,0x00,0x00,0x00,
- 0x04,0x00,0x10,0x26,0x2b,0x08,0xb0,0x02,0xfd,0xff,0x20,0x10,
- 0xfc,0xff,0x11,0xae,0x21,0x80,0xc0,0x02,0xd2,0x27,0x00,0x0c,
- 0x00,0x00,0x00,0x00,0x2b,0x08,0xb6,0x02,0x15,0x00,0x20,0x14,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x19,0x8e,0x00,0x00,0x00,0x00,
- 0x09,0x00,0x39,0x12,0xff,0x00,0x08,0x32,0x90,0x88,0x84,0x8f,
- 0x00,0x00,0x07,0x8e,0x10,0x00,0xb0,0xaf,0x0c,0x00,0x05,0x24,
- 0x29,0x2a,0x00,0x0c,0x21,0x30,0x20,0x02,0x00,0x02,0x94,0x36,
- 0xff,0x00,0x08,0x32,0x03,0x00,0x00,0x15,0x00,0x00,0x00,0x00,
- 0xd2,0x27,0x00,0x0c,0x00,0x00,0x00,0x00,0x04,0x00,0x10,0x26,
- 0x2b,0x08,0xb0,0x02,0xed,0xff,0x20,0x10,0x00,0x00,0x00,0x00,
- 0xff,0xff,0x52,0x26,0xff,0xff,0x01,0x24,0x7f,0xff,0x41,0x16,
- 0x01,0x00,0x49,0x32,0x08,0x00,0x80,0x16,0x44,0x00,0xbf,0x8f,
- 0x50,0x00,0xa9,0x8f,0x00,0x00,0x00,0x00,0x04,0x00,0x20,0x11,
- 0x44,0x00,0xbf,0x8f,0x65,0x2a,0x00,0x0c,0x00,0x00,0x00,0x00,
- 0x44,0x00,0xbf,0x8f,0x21,0x10,0x80,0x02,0x38,0x00,0xb4,0x8f,
- 0x28,0x00,0xb0,0x8f,0x2c,0x00,0xb1,0x8f,0x30,0x00,0xb2,0x8f,
- 0x34,0x00,0xb3,0x8f,0x3c,0x00,0xb5,0x8f,0x40,0x00,0xb6,0x8f,
- 0x08,0x00,0xe0,0x03,0x48,0x00,0xbd,0x27,0xf8,0xff,0xbd,0x27,
- 0x10,0x27,0x0e,0x24,0x04,0x00,0xae,0xaf,0x04,0x00,0xa2,0x8f,
- 0x04,0x00,0xaf,0x8f,0x00,0x00,0x00,0x00,0xff,0xff,0xf8,0x25,
- 0x0f,0x00,0x40,0x10,0x04,0x00,0xb8,0xaf,0x2c,0x00,0x99,0x90,
- 0x00,0x00,0x00,0x00,0x0b,0x00,0x20,0x13,0x00,0x00,0x00,0x00,
- 0x04,0x00,0xa2,0x8f,0x04,0x00,0xa8,0x8f,0x00,0x00,0x00,0x00,
- 0xff,0xff,0x09,0x25,0x05,0x00,0x40,0x10,0x04,0x00,0xa9,0xaf,
- 0x2c,0x00,0x8a,0x90,0x00,0x00,0x00,0x00,0xf7,0xff,0x40,0x15,
- 0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,0x08,0x00,0xbd,0x27,
- 0x28,0xff,0xbd,0x27,0xd8,0x00,0xa4,0xaf,0xd8,0x00,0xae,0x8f,
- 0x01,0xa1,0x01,0x3c,0x80,0x7b,0x0e,0x00,0x21,0xc0,0xe1,0x01,
- 0x44,0x00,0xb6,0xaf,0x01,0xa1,0x01,0x3c,0x4c,0x00,0xbf,0xaf,
- 0x48,0x00,0xb7,0xaf,0x40,0x00,0xb3,0xaf,0x3c,0x00,0xb0,0xaf,
- 0xdc,0x00,0xa5,0xaf,0xe0,0x00,0xa6,0xaf,0x21,0x08,0x2f,0x00,
- 0x88,0x00,0xb8,0xaf,0x8c,0x00,0xaf,0xaf,0xff,0x00,0x19,0x24,
- 0x00,0x00,0x39,0xa0,0x21,0xb0,0x00,0x00,0xf4,0x01,0x02,0x24,
- 0x04,0x00,0xd6,0x26,0xff,0xff,0xc2,0x16,0x04,0x00,0xd6,0x26,
- 0x88,0x00,0xa9,0x8f,0xd8,0x00,0xaa,0x8f,0x00,0x00,0x33,0x91,
- 0x06,0x00,0x40,0x11,0x1c,0x00,0x01,0x24,0x03,0x00,0x61,0x12,
- 0x20,0x00,0x01,0x24,0x03,0x00,0x61,0x16,0xd8,0x00,0xab,0x8f,
- 0xff,0x00,0x13,0x24,0xd8,0x00,0xab,0x8f,0x00,0xa3,0x01,0x3c,
- 0x21,0x08,0x2b,0x00,0xac,0x01,0x33,0xa0,0x00,0xa3,0x01,0x3c,
- 0xb0,0x01,0x21,0x34,0x21,0x60,0x61,0x01,0x00,0xa3,0x01,0x3c,
- 0x84,0x00,0xac,0xaf,0x21,0x08,0x2b,0x00,0xb0,0x01,0x20,0xa0,
- 0x00,0xa3,0x01,0x3c,0xb4,0x01,0x21,0x34,0x21,0x68,0x61,0x01,
- 0x00,0xa3,0x01,0x3c,0x80,0x00,0xad,0xaf,0x21,0x08,0x2b,0x00,
- 0xb4,0x01,0x20,0xa0,0x00,0xa3,0x01,0x3c,0xb8,0x01,0x21,0x34,
- 0x80,0x70,0x0b,0x00,0x21,0xc0,0xc1,0x01,0x00,0xa3,0x01,0x3c,
- 0x21,0x08,0x2e,0x00,0x7c,0x00,0xb8,0xaf,0xb8,0x01,0x20,0xac,
- 0x83,0xb8,0x13,0x00,0x10,0x00,0x19,0x24,0x3f,0x00,0xf7,0x32,
- 0x04,0x00,0x01,0x24,0xbc,0x00,0xa0,0xaf,0xa0,0x00,0xb9,0xaf,
- 0x08,0x00,0xe1,0x12,0x9c,0x00,0xa0,0xaf,0x06,0x00,0x01,0x24,
- 0x05,0x00,0xe1,0x12,0x0c,0x00,0x01,0x24,0x03,0x00,0xe1,0x12,
- 0x0e,0x00,0x01,0x24,0x04,0x00,0xe1,0x16,0x04,0x00,0x01,0x24,
- 0x08,0x00,0x0f,0x24,0xa0,0x00,0xaf,0xaf,0x04,0x00,0x01,0x24,
- 0x03,0x00,0xe1,0x12,0x0c,0x00,0x01,0x24,0x04,0x00,0xe1,0x16,
- 0x07,0x00,0x04,0x24,0x01,0x00,0x09,0x24,0x9c,0x00,0xa9,0xaf,
- 0x07,0x00,0x04,0x24,0x04,0x00,0xe4,0x16,0x08,0x00,0x03,0x24,
- 0x04,0x00,0x0a,0x24,0xa0,0x00,0xaa,0xaf,0x08,0x00,0x03,0x24,
- 0x03,0x00,0xe3,0x16,0x01,0x00,0x0c,0x24,0xa0,0x00,0xa3,0xaf,
- 0x01,0x00,0x0c,0x24,0x94,0x00,0xac,0xaf,0xde,0x07,0x00,0x10,
- 0x21,0x10,0xe0,0x02,0xdc,0x00,0xad,0x8f,0x60,0x00,0xb4,0xaf,
- 0x5c,0x00,0xb5,0xaf,0x04,0x00,0xa0,0x11,0x58,0x00,0xbe,0xaf,
- 0xf7,0xff,0x01,0x24,0xfa,0x00,0xa1,0x15,0xdc,0x00,0xac,0x8f,
- 0xd8,0x00,0xa5,0x8f,0x08,0x89,0x84,0x27,0x29,0x2a,0x00,0x0c,
- 0x21,0x30,0x60,0x02,0x8c,0x00,0xbe,0x8f,0x01,0xa1,0x01,0x3c,
- 0x00,0x08,0x21,0x34,0x21,0xf0,0xc1,0x03,0x7b,0x2e,0x00,0x0c,
- 0x21,0x20,0xc0,0x03,0x81,0x00,0x14,0x24,0x2c,0x00,0xd4,0xa3,
- 0x3c,0x00,0xcb,0x93,0x00,0x00,0x00,0x00,0x0e,0x00,0x60,0x15,
- 0xf0,0x01,0x10,0x24,0x0f,0x00,0x02,0x3c,0x40,0x42,0x42,0x34,
- 0x0f,0x00,0x16,0x3c,0x08,0x00,0x40,0x10,0x3f,0x42,0xd6,0x36,
- 0x3c,0x00,0xd8,0x93,0x00,0x00,0x00,0x00,0x05,0x00,0x00,0x17,
- 0xf0,0x01,0x10,0x24,0x21,0x10,0xc0,0x02,0xfa,0xff,0x40,0x14,
- 0xff,0xff,0xd6,0x26,0xf0,0x01,0x10,0x24,0xfc,0xff,0x10,0x26,
- 0xff,0xff,0x00,0x16,0xfc,0xff,0x10,0x26,0xed,0x00,0x0e,0x24,
- 0x10,0x00,0xce,0xa3,0x10,0x00,0xd9,0x93,0xed,0x00,0x01,0x24,
- 0xc2,0x00,0x21,0x17,0x21,0xa8,0x00,0x00,0x80,0x00,0xaf,0x8f,
- 0x54,0x00,0xb1,0xaf,0x50,0x00,0xb2,0xaf,0x00,0x00,0xe9,0x91,
- 0xff,0x00,0x0c,0x24,0x01,0x00,0x2a,0x25,0x00,0x00,0xea,0xa1,
- 0x10,0x00,0xc0,0xa3,0x10,0x00,0xd2,0x93,0x10,0x00,0xcc,0xa3,
- 0x10,0x00,0xd0,0x93,0x03,0x00,0x40,0x16,0xff,0x00,0x01,0x24,
- 0x07,0x00,0x01,0x12,0x00,0x00,0x00,0x00,0xd8,0x00,0xa5,0x8f,
- 0x00,0x02,0x15,0x24,0x24,0x89,0x84,0x27,0x21,0x30,0x40,0x02,
- 0x29,0x2a,0x00,0x0c,0x21,0x38,0x00,0x02,0x28,0x00,0xc0,0xa3,
- 0x7b,0x2e,0x00,0x0c,0x21,0x20,0xc0,0x03,0x80,0x00,0x0d,0x24,
- 0x2c,0x00,0xcd,0xa3,0xf0,0x01,0x10,0x24,0xfc,0xff,0x10,0x26,
- 0xff,0xff,0x00,0x16,0xfc,0xff,0x10,0x26,0x7b,0x2e,0x00,0x0c,
- 0x21,0x20,0xc0,0x03,0x42,0x00,0x0b,0x24,0x2c,0x00,0xcb,0xa3,
- 0xf0,0x01,0x10,0x24,0xfc,0xff,0x10,0x26,0xff,0xff,0x00,0x16,
- 0xfc,0xff,0x10,0x26,0x48,0x00,0xc0,0x93,0x21,0xb0,0x00,0x00,
- 0x80,0x00,0x10,0x24,0x48,0x00,0xd6,0xa3,0x01,0x00,0xd8,0x26,
- 0x02,0x00,0xce,0x26,0x48,0x00,0xd8,0xa3,0x03,0x00,0xd9,0x26,
- 0x04,0x00,0xd6,0x26,0x48,0x00,0xce,0xa3,0xf8,0xff,0xd0,0x16,
- 0x48,0x00,0xd9,0xa3,0x21,0xb0,0x00,0x00,0x60,0x89,0x91,0x27,
- 0x48,0x00,0xd2,0x93,0x00,0x00,0x00,0x00,0x07,0x00,0x56,0x12,
- 0x00,0x00,0x00,0x00,0xd8,0x00,0xa5,0x8f,0x10,0x00,0xb5,0x36,
- 0x21,0x20,0x20,0x02,0x21,0x30,0xc0,0x02,0x29,0x2a,0x00,0x0c,
- 0x21,0x38,0x40,0x02,0x01,0x00,0xd6,0x26,0xf4,0xff,0xd0,0x16,
- 0x00,0x00,0x00,0x00,0x7b,0x2e,0x00,0x0c,0x21,0x20,0xc0,0x03,
- 0x42,0x00,0x09,0x24,0x2c,0x00,0xc9,0xa3,0xf0,0x01,0x10,0x24,
- 0xfc,0xff,0x10,0x26,0xff,0xff,0x00,0x16,0xfc,0xff,0x10,0x26,
- 0x7b,0x2e,0x00,0x0c,0x21,0x20,0xc0,0x03,0x43,0x00,0x0a,0x24,
- 0x2c,0x00,0xca,0xa3,0xe1,0x21,0x00,0x0c,0x21,0x20,0x00,0x00,
- 0x01,0x00,0x0f,0x24,0x00,0xa3,0x0c,0x3c,0x80,0x01,0x8f,0xad,
- 0xd8,0x00,0xad,0x8f,0xdc,0x88,0x98,0x27,0x80,0x58,0x0d,0x00,
- 0x21,0x70,0x78,0x01,0x70,0x00,0xae,0xaf,0x00,0x00,0xc4,0x8d,
- 0xe1,0x21,0x00,0x0c,0x01,0x00,0x84,0x24,0x84,0x13,0x10,0x24,
- 0xfc,0xff,0x10,0x26,0xff,0xff,0x00,0x16,0xfc,0xff,0x10,0x26,
- 0x00,0xa3,0x19,0x3c,0x80,0x01,0x29,0x8f,0x01,0x00,0x01,0x24,
- 0x06,0x00,0x21,0x11,0x88,0x00,0xb1,0x8f,0xd8,0x00,0xa5,0x8f,
- 0x40,0x00,0xb5,0x36,0x29,0x2a,0x00,0x0c,0x94,0x89,0x84,0x27,
- 0x88,0x00,0xb1,0x8f,0x00,0x00,0x00,0x00,0x08,0x00,0x2a,0x92,
- 0x08,0x00,0x31,0x26,0x01,0x00,0x4f,0x31,0x06,0x00,0xe0,0x11,
- 0x05,0x00,0x02,0x24,0xd8,0x00,0xa5,0x8f,0x40,0x00,0xb5,0x36,
- 0x29,0x2a,0x00,0x0c,0xc0,0x89,0x84,0x27,0x05,0x00,0x02,0x24,
- 0x00,0x00,0xc0,0xa3,0x10,0x00,0xc2,0xa3,0x14,0x00,0xc2,0xa3,
- 0x7b,0x2e,0x00,0x0c,0x21,0x20,0xc0,0x03,0x18,0x00,0x0c,0x24,
- 0x2c,0x00,0xcc,0xa3,0x04,0x00,0xd4,0xa3,0x0c,0x27,0x10,0x24,
- 0xfc,0xff,0x10,0x26,0xff,0xff,0x00,0x16,0xfc,0xff,0x10,0x26,
- 0x00,0x00,0x2d,0x92,0x00,0x00,0x00,0x00,0x01,0x00,0xab,0x31,
- 0x05,0x00,0x60,0x15,0x00,0x00,0x00,0x00,0xd8,0x00,0xa5,0x8f,
- 0x40,0x00,0xb5,0x36,0x29,0x2a,0x00,0x0c,0xfc,0x89,0x84,0x27,
- 0x40,0x00,0xc0,0xa3,0x30,0x00,0xc0,0xa3,0x10,0x00,0xc0,0xa3,
- 0x14,0x00,0xc0,0xa3,0x7b,0x2e,0x00,0x0c,0x21,0x20,0xc0,0x03,
- 0x10,0x00,0x18,0x24,0x2c,0x00,0xd8,0xa3,0x00,0x00,0xc0,0xa3,
- 0x04,0x00,0xc0,0xa3,0x00,0xa3,0x0e,0x3c,0x80,0x01,0xd9,0x8d,
- 0x00,0x00,0x00,0x00,0x05,0x00,0x20,0x13,0x00,0x00,0x00,0x00,
- 0xd8,0x00,0xa5,0x8f,0x80,0x00,0xb5,0x36,0x29,0x2a,0x00,0x0c,
- 0x38,0x8a,0x84,0x27,0xe1,0x21,0x00,0x0c,0x21,0x20,0x00,0x00,
- 0x01,0x00,0x09,0x24,0x00,0xa3,0x0a,0x3c,0x80,0x01,0x49,0xad,
- 0x70,0x00,0xaf,0x8f,0x00,0x00,0x00,0x00,0x00,0x00,0xe4,0x8d,
- 0xe1,0x21,0x00,0x0c,0x01,0x00,0x84,0x24,0x0c,0x27,0x10,0x24,
- 0xfc,0xff,0x10,0x26,0xff,0xff,0x00,0x16,0xfc,0xff,0x10,0x26,
- 0x00,0xa3,0x0c,0x3c,0x80,0x01,0x8d,0x8d,0x01,0x00,0x01,0x24,
- 0x05,0x00,0xa1,0x11,0x00,0x00,0x00,0x00,0xd8,0x00,0xa5,0x8f,
- 0x00,0x01,0xb5,0x36,0x29,0x2a,0x00,0x0c,0x6c,0x8a,0x84,0x27,
- 0x00,0x00,0x2b,0x92,0x00,0x00,0x00,0x00,0x01,0x00,0x78,0x31,
- 0x05,0x00,0x00,0x13,0x00,0x00,0x00,0x00,0xd8,0x00,0xa5,0x8f,
- 0x40,0x00,0xb5,0x36,0x29,0x2a,0x00,0x0c,0xa0,0x8a,0x84,0x27,
- 0xe1,0x21,0x00,0x0c,0x21,0x20,0x00,0x00,0x54,0x00,0xb1,0x8f,
- 0x50,0x00,0xb2,0x8f,0x05,0x00,0x00,0x10,0x00,0x00,0x00,0x00,
- 0xd8,0x00,0xa5,0x8f,0x00,0x02,0x15,0x24,0x29,0x2a,0x00,0x0c,
- 0xdc,0x8a,0x84,0x27,0x08,0x00,0xa0,0x12,0x00,0x00,0x00,0x00,
- 0x7c,0x00,0xae,0x8f,0x01,0x00,0x0a,0x24,0x00,0x00,0xd9,0x8d,
- 0x00,0x00,0x00,0x00,0x00,0x02,0x29,0x37,0x00,0x00,0xc9,0xad,
- 0xbc,0x00,0xaa,0xaf,0x7b,0x2e,0x00,0x0c,0x21,0x20,0xc0,0x03,
- 0x42,0x00,0x0f,0x24,0x2c,0x00,0xcf,0xa3,0xdc,0x00,0xac,0x8f,
- 0xf7,0xff,0x01,0x24,0x07,0x00,0x81,0x15,0x60,0x00,0xb4,0x8f,
- 0x60,0x00,0xb4,0x8f,0x5c,0x00,0xb5,0x8f,0x58,0x00,0xbe,0x8f,
- 0x13,0x07,0x00,0x10,0x00,0x00,0x00,0x00,0x60,0x00,0xb4,0x8f,
- 0x5c,0x00,0xb5,0x8f,0x58,0x00,0xbe,0x8f,0x02,0x00,0x10,0x24,
- 0xe8,0x00,0xad,0x8f,0x00,0x00,0x00,0x00,0x04,0x00,0xa0,0x11,
- 0xdc,0x00,0xab,0x8f,0xad,0x2a,0x00,0x0c,0x00,0x00,0x00,0x00,
- 0xdc,0x00,0xab,0x8f,0x00,0x00,0x00,0x00,0x0c,0x00,0x70,0x15,
- 0xd8,0x00,0xa5,0x8f,0xd8,0x00,0xa5,0x8f,0x29,0x2a,0x00,0x0c,
- 0x04,0x8b,0x84,0x27,0xd8,0x00,0xb8,0x8f,0x00,0x00,0x00,0x00,
- 0x09,0x00,0x00,0x17,0xdc,0x00,0xa3,0x8f,0xff,0x00,0x19,0x24,
- 0x05,0x00,0x00,0x10,0xec,0x88,0x99,0xaf,0xd8,0x00,0xa5,0x8f,
- 0x1c,0x8b,0x84,0x27,0x29,0x2a,0x00,0x0c,0x21,0x30,0x60,0x02,
- 0xdc,0x00,0xa3,0x8f,0x00,0x00,0x00,0x00,0x12,0x02,0x60,0x14,
- 0x00,0x00,0x00,0x00,0xd8,0x00,0xa9,0x8f,0xa0,0x00,0xaa,0x8f,
- 0x01,0x00,0x2e,0x2d,0x6c,0x00,0xae,0xaf,0xdd,0x01,0x40,0x19,
- 0x21,0xb0,0x00,0x00,0x58,0x00,0xbe,0xaf,0x7c,0x8b,0x9e,0x27,
- 0x54,0x00,0xb1,0xaf,0x50,0x00,0xb2,0xaf,0x60,0x00,0xb4,0xaf,
- 0x5c,0x00,0xb5,0xaf,0x68,0x00,0xa0,0xaf,0xed,0x00,0x02,0x24,
- 0x10,0x00,0x13,0x24,0x88,0x00,0xaf,0x8f,0x68,0x00,0xac,0x8f,
- 0x21,0xa8,0x00,0x00,0x21,0x88,0xec,0x01,0x1c,0x01,0x22,0xa2,
- 0x1c,0x01,0x2d,0x92,0x00,0x00,0x00,0x00,0xad,0x01,0x4d,0x14,
- 0x7c,0x00,0xac,0x8f,0xd8,0x00,0xab,0x8f,0x00,0x00,0x00,0x00,
- 0x07,0x00,0x60,0x15,0x80,0x00,0xa3,0x8f,0x00,0xa3,0x19,0x3c,
- 0xa8,0x01,0x29,0x97,0x01,0x00,0xd8,0x26,0xa4,0x01,0x09,0x13,
- 0x7c,0x00,0xac,0x8f,0x80,0x00,0xa3,0x8f,0x00,0x01,0x34,0x26,
- 0x00,0x00,0x6e,0x90,0xff,0x00,0x02,0x24,0x01,0x00,0xca,0x25,
- 0x00,0x00,0x6a,0xa0,0x1c,0x00,0x80,0xa2,0x0c,0x00,0x82,0xa2,
- 0x1c,0x00,0x92,0x92,0x1c,0x00,0x82,0xa2,0x0c,0x00,0x80,0xa2,
- 0xd8,0x00,0xaf,0x8f,0xdc,0x88,0x8d,0x27,0x80,0x60,0x0f,0x00,
- 0x1c,0x00,0x90,0x92,0x21,0x58,0x8d,0x01,0x04,0x00,0x40,0x16,
- 0x70,0x00,0xab,0xaf,0xff,0x00,0x01,0x24,0x09,0x00,0x01,0x12,
- 0x00,0x00,0x00,0x00,0x94,0x00,0xb9,0x8f,0xd8,0x00,0xa5,0x8f,
- 0x00,0x02,0x15,0x24,0x38,0x8b,0x84,0x27,0x21,0x38,0x40,0x02,
- 0x10,0x00,0xb0,0xaf,0x29,0x2a,0x00,0x0c,0x21,0x30,0xd9,0x02,
- 0x1c,0x00,0x80,0xa2,0x07,0x00,0x18,0x24,0x01,0x00,0x02,0x24,
- 0x08,0x00,0x98,0xa2,0x08,0x00,0x82,0xa2,0x8f,0x00,0x09,0x24,
- 0x0c,0x00,0x89,0xa2,0x04,0x00,0x0e,0x24,0x00,0x00,0x8e,0xa2,
- 0x04,0x00,0x80,0xa2,0x0f,0x00,0x0a,0x24,0x0c,0x00,0x8a,0xa2,
- 0x04,0x00,0x82,0xa2,0x1b,0x00,0x0f,0x24,0x10,0x00,0x8f,0xa2,
- 0x3f,0x00,0x12,0x24,0x00,0x00,0x80,0x92,0x21,0x10,0x40,0x02,
- 0xfd,0xff,0x40,0x14,0xff,0xff,0x52,0x26,0xc1,0x2a,0x00,0x0c,
- 0xc4,0x09,0x04,0x24,0x21,0x90,0x00,0x00,0x05,0x00,0x01,0x24,
- 0x07,0x00,0xe1,0x12,0x7f,0x00,0x01,0x24,0x05,0x00,0xe1,0x12,
- 0x0c,0x00,0x01,0x24,0x03,0x00,0xe1,0x12,0x0e,0x00,0x01,0x24,
- 0x0f,0x00,0xe1,0x16,0x00,0x00,0x00,0x00,0x14,0x00,0x8c,0x92,
- 0x00,0x00,0x00,0x00,0x01,0x00,0x8d,0x31,0x0a,0x00,0xa0,0x11,
- 0x00,0x00,0x00,0x00,0x94,0x00,0xab,0x8f,0xd8,0x00,0xa5,0x8f,
- 0x01,0x00,0xb5,0x36,0x21,0x20,0xc0,0x03,0x21,0x90,0x00,0x00,
- 0x29,0x2a,0x00,0x0c,0x21,0x30,0xcb,0x02,0x98,0x00,0x00,0x10,
- 0x0c,0x00,0x4d,0x32,0x14,0x00,0x99,0x92,0x00,0x00,0x00,0x00,
- 0x20,0x00,0x38,0x33,0x0a,0x00,0x00,0x17,0x00,0x00,0x00,0x00,
- 0x94,0x00,0xa9,0x8f,0xd8,0x00,0xa5,0x8f,0x02,0x00,0xb5,0x36,
- 0xa4,0x8b,0x84,0x27,0x21,0x90,0x00,0x00,0x29,0x2a,0x00,0x0c,
- 0x21,0x30,0xc9,0x02,0x8a,0x00,0x00,0x10,0x0c,0x00,0x4d,0x32,
- 0x00,0x00,0x80,0x92,0x00,0x00,0x92,0xa2,0x14,0x00,0x8e,0x92,
- 0x00,0x00,0x00,0x00,0x40,0x00,0xca,0x31,0x0d,0x00,0x40,0x11,
- 0xc3,0x09,0x10,0x24,0x94,0x00,0xaf,0x8f,0xd8,0x00,0xa5,0x8f,
- 0x04,0x00,0xb5,0x36,0xc8,0x8b,0x84,0x27,0x21,0x90,0x00,0x00,
- 0x29,0x2a,0x00,0x0c,0x21,0x30,0xcf,0x02,0xc1,0x2a,0x00,0x0c,
- 0xc4,0x09,0x04,0x24,0x78,0x00,0x00,0x10,0x0c,0x00,0x4d,0x32,
- 0xc3,0x09,0x10,0x24,0xd2,0x27,0x00,0x0c,0x00,0x00,0x00,0x00,
- 0x08,0x00,0x8c,0x92,0x00,0x00,0x00,0x00,0x01,0x00,0x8d,0x31,
- 0x04,0x00,0xa0,0x11,0x00,0x00,0x00,0x00,0x21,0x10,0x00,0x02,
- 0xf7,0xff,0x40,0x14,0xff,0xff,0x10,0x26,0x0a,0x00,0x01,0x06,
- 0x00,0x00,0x00,0x00,0x94,0x00,0xab,0x8f,0xd8,0x00,0xa5,0x8f,
- 0x00,0x04,0xb5,0x36,0xfc,0x8b,0x84,0x27,0x21,0x90,0x00,0x00,
- 0x29,0x2a,0x00,0x0c,0x21,0x30,0xcb,0x02,0x62,0x00,0x00,0x10,
- 0x0c,0x00,0x4d,0x32,0x14,0x00,0x99,0x92,0x00,0x00,0x00,0x00,
- 0x0e,0x00,0x38,0x33,0x1f,0x00,0x00,0x13,0x05,0x00,0x01,0x24,
- 0x94,0x00,0xa9,0x8f,0xd8,0x00,0xa5,0x8f,0x08,0x00,0xb5,0x36,
- 0x24,0x8c,0x84,0x27,0x29,0x2a,0x00,0x0c,0x21,0x30,0xc9,0x02,
- 0x14,0x00,0x8e,0x92,0x00,0x00,0x00,0x00,0x02,0x00,0xca,0x31,
- 0x03,0x00,0x40,0x11,0x00,0x00,0x00,0x00,0x29,0x2a,0x00,0x0c,
- 0x38,0x8c,0x84,0x27,0x14,0x00,0x8f,0x92,0x00,0x00,0x00,0x00,
- 0x04,0x00,0xec,0x31,0x03,0x00,0x80,0x11,0x00,0x00,0x00,0x00,
- 0x29,0x2a,0x00,0x0c,0x48,0x8c,0x84,0x27,0x14,0x00,0x8d,0x92,
- 0x00,0x00,0x00,0x00,0x08,0x00,0xab,0x31,0x03,0x00,0x60,0x11,
- 0x00,0x00,0x00,0x00,0x29,0x2a,0x00,0x0c,0x58,0x8c,0x84,0x27,
- 0x29,0x2a,0x00,0x0c,0x68,0x8c,0x84,0x27,0x05,0x00,0x01,0x24,
- 0x07,0x00,0xe1,0x12,0x7f,0x00,0x01,0x24,0x05,0x00,0xe1,0x12,
- 0x0c,0x00,0x01,0x24,0x03,0x00,0xe1,0x12,0x0e,0x00,0x01,0x24,
- 0x0f,0x00,0xe1,0x16,0x00,0x00,0x00,0x00,0x14,0x00,0x99,0x92,
- 0x00,0x00,0x00,0x00,0x01,0x00,0x38,0x33,0x0a,0x00,0x00,0x17,
- 0x00,0x00,0x00,0x00,0x94,0x00,0xa9,0x8f,0xd8,0x00,0xa5,0x8f,
- 0x01,0x00,0xb5,0x36,0x6c,0x8c,0x84,0x27,0x21,0x90,0x00,0x00,
- 0x29,0x2a,0x00,0x0c,0x21,0x30,0xc9,0x02,0x29,0x00,0x00,0x10,
- 0x0c,0x00,0x4d,0x32,0x00,0x00,0x90,0x92,0x05,0x00,0x01,0x24,
- 0x07,0x00,0xe1,0x12,0x7f,0x00,0x01,0x24,0x05,0x00,0xe1,0x12,
- 0x0c,0x00,0x01,0x24,0x03,0x00,0xe1,0x12,0x0e,0x00,0x01,0x24,
- 0x0f,0x00,0xe1,0x16,0x00,0x00,0x00,0x00,0x14,0x00,0x8e,0x92,
- 0x00,0x00,0x00,0x00,0x01,0x00,0xca,0x31,0x0a,0x00,0x40,0x11,
- 0x00,0x00,0x00,0x00,0x94,0x00,0xaf,0x8f,0xd8,0x00,0xa5,0x8f,
- 0x01,0x00,0xb5,0x36,0x94,0x8c,0x84,0x27,0x21,0x90,0x00,0x00,
- 0x29,0x2a,0x00,0x0c,0x21,0x30,0xcf,0x02,0x11,0x00,0x00,0x10,
- 0x0c,0x00,0x4d,0x32,0x09,0x00,0x12,0x12,0x00,0x00,0x00,0x00,
- 0x94,0x00,0xac,0x8f,0xd8,0x00,0xa5,0x8f,0x10,0x00,0xb5,0x36,
- 0xc0,0x8c,0x84,0x27,0x21,0x38,0x40,0x02,0x10,0x00,0xb0,0xaf,
- 0x29,0x2a,0x00,0x0c,0x21,0x30,0xcc,0x02,0x01,0x00,0x52,0x26,
- 0x00,0x01,0x41,0x2a,0x56,0xff,0x20,0x14,0x05,0x00,0x01,0x24,
- 0x21,0x90,0x00,0x00,0x0c,0x00,0x4d,0x32,0x01,0x00,0x59,0x32,
- 0x40,0xc0,0x19,0x00,0x10,0x00,0xab,0x35,0x02,0x00,0x4e,0x32,
- 0x43,0x50,0x0e,0x00,0x25,0x48,0x78,0x01,0x25,0x78,0x2a,0x01,
- 0x10,0x00,0x8f,0xa2,0xc1,0x2a,0x00,0x0c,0xfa,0x00,0x04,0x24,
- 0x18,0x00,0x90,0x92,0x00,0x00,0x00,0x00,0x02,0x81,0x10,0x00,
- 0x0f,0x00,0x10,0x32,0x20,0x00,0x12,0x12,0x00,0x00,0x00,0x00,
- 0x94,0x00,0xac,0x8f,0xd8,0x00,0xa5,0x8f,0x20,0x00,0xb5,0x36,
- 0xec,0x8c,0x84,0x27,0x21,0x38,0x40,0x02,0x10,0x00,0xb0,0xaf,
- 0x29,0x2a,0x00,0x0c,0x21,0x30,0xcc,0x02,0x26,0x88,0x12,0x02,
- 0x01,0x00,0x2d,0x32,0x04,0x00,0xa0,0x11,0x02,0x00,0x39,0x32,
- 0x29,0x2a,0x00,0x0c,0x20,0x8d,0x84,0x27,0x02,0x00,0x39,0x32,
- 0x04,0x00,0x20,0x13,0x04,0x00,0x2b,0x32,0x29,0x2a,0x00,0x0c,
- 0x2c,0x8d,0x84,0x27,0x04,0x00,0x2b,0x32,0x04,0x00,0x60,0x11,
- 0x08,0x00,0x38,0x32,0x29,0x2a,0x00,0x0c,0x38,0x8d,0x84,0x27,
- 0x08,0x00,0x38,0x32,0x03,0x00,0x00,0x13,0x00,0x00,0x00,0x00,
- 0x29,0x2a,0x00,0x0c,0x44,0x8d,0x84,0x27,0x29,0x2a,0x00,0x0c,
- 0x50,0x8d,0x84,0x27,0x01,0x00,0x52,0x26,0xcf,0xff,0x53,0x16,
- 0x0c,0x00,0x4d,0x32,0x1b,0x00,0x0e,0x24,0x10,0x00,0x8e,0xa2,
- 0xe1,0x21,0x00,0x0c,0x21,0x20,0x00,0x00,0x01,0x00,0x09,0x24,
- 0x00,0xa3,0x0a,0x3c,0x80,0x01,0x49,0xad,0x70,0x00,0xaf,0x8f,
- 0x00,0x00,0x00,0x00,0x00,0x00,0xe4,0x8d,0xe1,0x21,0x00,0x0c,
- 0x01,0x00,0x84,0x24,0x01,0x00,0x0c,0x24,0x04,0x00,0x8c,0xa2,
- 0x00,0x00,0x80,0x92,0x08,0x00,0x80,0x92,0xc0,0x09,0x10,0x24,
- 0xfc,0xff,0x10,0x26,0xff,0xff,0x00,0x16,0xfc,0xff,0x10,0x26,
- 0x00,0xa3,0x0d,0x3c,0x80,0x01,0xb9,0x8d,0x01,0x00,0x01,0x24,
- 0x08,0x00,0x21,0x13,0x08,0x00,0xce,0x32,0x94,0x00,0xab,0x8f,
- 0xd8,0x00,0xa5,0x8f,0x40,0x00,0xb5,0x36,0x54,0x8d,0x84,0x27,
- 0x29,0x2a,0x00,0x0c,0x21,0x30,0xcb,0x02,0x08,0x00,0xce,0x32,
- 0x88,0x00,0xb8,0x8f,0x08,0x00,0xc9,0x25,0x43,0x50,0x09,0x00,
- 0x21,0x88,0x0a,0x03,0x00,0x00,0x2d,0x92,0x07,0x00,0xcf,0x32,
- 0x01,0x00,0x0c,0x24,0x04,0x90,0xec,0x01,0x24,0xc8,0xb2,0x01,
- 0x08,0x00,0x20,0x13,0x2a,0x00,0x0e,0x24,0x94,0x00,0xab,0x8f,
- 0xd8,0x00,0xa5,0x8f,0x40,0x00,0xb5,0x36,0x74,0x8d,0x84,0x27,
- 0x29,0x2a,0x00,0x0c,0x21,0x30,0xcb,0x02,0x2a,0x00,0x0e,0x24,
- 0x00,0x00,0x8e,0xa2,0xc3,0x09,0x10,0x24,0x00,0xa3,0x09,0x3c,
- 0x80,0x01,0x38,0x8d,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x13,
- 0x00,0x00,0x00,0x00,0xff,0xff,0x10,0x26,0xfa,0xff,0x00,0x16,
- 0x00,0xa3,0x09,0x3c,0xc0,0x09,0x10,0x24,0xfc,0xff,0x10,0x26,
- 0xff,0xff,0x00,0x16,0xfc,0xff,0x10,0x26,0x00,0x00,0x2a,0x92,
- 0x00,0x00,0x00,0x00,0x24,0x60,0x52,0x01,0x07,0x00,0x80,0x15,
- 0x00,0x00,0x00,0x00,0x94,0x00,0xaf,0x8f,0xd8,0x00,0xa5,0x8f,
- 0x40,0x00,0xb5,0x36,0xa4,0x8d,0x84,0x27,0x29,0x2a,0x00,0x0c,
- 0x21,0x30,0xcf,0x02,0x00,0x00,0x80,0x92,0x08,0x00,0x80,0x92,
- 0x00,0xa3,0x0d,0x3c,0x80,0x01,0xb9,0x8d,0x00,0x00,0x00,0x00,
- 0x07,0x00,0x20,0x13,0x00,0x00,0x00,0x00,0x94,0x00,0xab,0x8f,
- 0xd8,0x00,0xa5,0x8f,0x80,0x00,0xb5,0x36,0xd4,0x8d,0x84,0x27,
- 0x29,0x2a,0x00,0x0c,0x21,0x30,0xcb,0x02,0xe1,0x21,0x00,0x0c,
- 0x21,0x20,0x00,0x00,0x01,0x00,0x0e,0x24,0x00,0xa3,0x09,0x3c,
- 0x80,0x01,0x2e,0xad,0x70,0x00,0xb8,0x8f,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x04,0x8f,0xe1,0x21,0x00,0x0c,0x01,0x00,0x84,0x24,
- 0xc0,0x09,0x10,0x24,0xfc,0xff,0x10,0x26,0xff,0xff,0x00,0x16,
- 0xfc,0xff,0x10,0x26,0x00,0xa3,0x0a,0x3c,0x80,0x01,0x4c,0x8d,
- 0x01,0x00,0x01,0x24,0x07,0x00,0x81,0x11,0x00,0x00,0x00,0x00,
- 0x94,0x00,0xaf,0x8f,0xd8,0x00,0xa5,0x8f,0x00,0x01,0xb5,0x36,
- 0xfc,0x8d,0x84,0x27,0x29,0x2a,0x00,0x0c,0x21,0x30,0xcf,0x02,
- 0x00,0x00,0x2d,0x92,0x00,0x00,0x00,0x00,0x24,0xc8,0xb2,0x01,
- 0x07,0x00,0x20,0x13,0x00,0x00,0x00,0x00,0x94,0x00,0xab,0x8f,
- 0xd8,0x00,0xa5,0x8f,0x40,0x00,0xb5,0x36,0x24,0x8e,0x84,0x27,
- 0x29,0x2a,0x00,0x0c,0x21,0x30,0xcb,0x02,0xe1,0x21,0x00,0x0c,
- 0x21,0x20,0x00,0x00,0x07,0x00,0x02,0x24,0x04,0x00,0x80,0xa2,
- 0x08,0x00,0x82,0xa2,0x01,0x00,0x0e,0x24,0x08,0x00,0x8e,0xa2,
- 0x87,0x00,0x09,0x24,0x0c,0x00,0x89,0xa2,0x30,0x00,0x18,0x24,
- 0x00,0x00,0x98,0xa2,0x04,0x00,0x80,0xa2,0x0c,0x00,0x82,0xa2,
- 0x08,0x00,0x0a,0x24,0x10,0x00,0x8a,0xa2,0x00,0x00,0x80,0x92,
- 0x07,0x00,0x00,0x10,0xed,0x00,0x02,0x24,0x7c,0x00,0xac,0x8f,
- 0x01,0x00,0x0d,0x24,0x00,0x00,0x8f,0x8d,0x04,0xc8,0xcd,0x02,
- 0x25,0x58,0xf9,0x01,0x00,0x00,0x8b,0xad,0x0c,0x00,0xa0,0x12,
- 0x68,0x00,0xab,0x8f,0x7c,0x00,0xae,0x8f,0x01,0x00,0x18,0x24,
- 0x00,0x00,0xc9,0x8d,0x04,0x50,0xd8,0x02,0x25,0x68,0x2a,0x01,
- 0x00,0x00,0xcd,0xad,0xbc,0x00,0xaf,0x8f,0x00,0x00,0x00,0x00,
- 0x01,0x00,0xf9,0x35,0xbc,0x00,0xb9,0xaf,0x68,0x00,0xab,0x8f,
- 0xa0,0x00,0xb8,0x8f,0x01,0x00,0xd6,0x26,0x20,0x00,0x6c,0x25,
- 0x2a,0x08,0xd8,0x02,0x34,0xfe,0x20,0x14,0x68,0x00,0xac,0xaf,
- 0x54,0x00,0xb1,0x8f,0x50,0x00,0xb2,0x8f,0x60,0x00,0xb4,0x8f,
- 0x5c,0x00,0xb5,0x8f,0x58,0x00,0xbe,0x8f,0x00,0x00,0x00,0x00,
- 0x6c,0x00,0xa9,0x8f,0x00,0x00,0x00,0x00,0x05,0x00,0x20,0x11,
- 0x21,0x10,0x20,0x01,0x00,0xa3,0x0a,0x3c,0xa8,0x01,0x42,0x95,
- 0x00,0x00,0x00,0x00,0x2b,0x10,0x02,0x00,0x80,0x00,0xae,0x8f,
- 0x9c,0x00,0xa3,0x8f,0xa0,0x00,0xa7,0x8f,0x00,0x00,0xcf,0x91,
- 0x21,0x68,0xe3,0x00,0x21,0xc8,0xe2,0x01,0x0a,0x00,0xb9,0x11,
- 0xbc,0x00,0xb8,0x8f,0xbc,0x00,0xab,0x8f,0xd8,0x00,0xa5,0x8f,
- 0x02,0x00,0x6c,0x35,0xbc,0x00,0xac,0xaf,0x00,0x00,0xc6,0x91,
- 0x10,0x00,0xa3,0xaf,0x29,0x2a,0x00,0x0c,0x54,0x8e,0x84,0x27,
- 0xbc,0x00,0xb8,0x8f,0x00,0x00,0x00,0x00,0x11,0x00,0x00,0x17,
- 0x84,0x00,0xad,0x8f,0x80,0x00,0xa9,0x8f,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x2a,0x91,0x00,0x00,0x00,0x00,0x08,0x00,0x40,0x11,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x25,0x91,0x29,0x2a,0x00,0x0c,
- 0x80,0x8e,0x84,0x27,0x65,0x2a,0x00,0x0c,0x00,0x00,0x00,0x00,
- 0x04,0x00,0x00,0x10,0x84,0x00,0xad,0x8f,0x29,0x2a,0x00,0x0c,
- 0x8c,0x8e,0x84,0x27,0x84,0x00,0xad,0x8f,0x01,0x00,0x0f,0x24,
- 0xe2,0x04,0x00,0x10,0x00,0x00,0xaf,0xa1,0x07,0x00,0x61,0x04,
- 0xa0,0x00,0xab,0x8f,0x23,0x10,0x03,0x00,0xff,0xff,0x59,0x24,
- 0xac,0x00,0xb9,0xaf,0x04,0x00,0x00,0x10,0xa8,0x00,0xa2,0xaf,
- 0xa0,0x00,0xab,0x8f,0xac,0x00,0xa0,0xaf,0xa8,0x00,0xab,0xaf,
- 0xac,0x00,0xac,0x8f,0xa8,0x00,0xae,0x8f,0x21,0xb0,0x80,0x01,
- 0x2a,0x08,0x8e,0x01,0x2b,0x00,0x20,0x10,0x00,0x00,0x00,0x00,
- 0x60,0x00,0xb4,0xaf,0xd8,0x00,0xb8,0x8f,0x00,0x00,0x00,0x00,
- 0x07,0x00,0x00,0x17,0x88,0x00,0xad,0x8f,0x00,0xa3,0x09,0x3c,
- 0xa8,0x01,0x2f,0x95,0x01,0x00,0xca,0x26,0x14,0x00,0x4f,0x11,
- 0x00,0x00,0x00,0x00,0x88,0x00,0xad,0x8f,0x40,0xc9,0x16,0x00,
- 0x21,0xa0,0xb9,0x01,0x07,0x00,0x0b,0x24,0x08,0x01,0x8b,0xa2,
- 0x01,0x00,0x0c,0x24,0x08,0x01,0x8c,0xa2,0x8f,0x00,0x0e,0x24,
- 0x0c,0x01,0x8e,0xa2,0x04,0x00,0x18,0x24,0x00,0x01,0x98,0xa2,
- 0x04,0x01,0x80,0xa2,0x0f,0x00,0x09,0x24,0x0c,0x01,0x89,0xa2,
- 0x01,0x00,0x0a,0x24,0x04,0x01,0x8a,0xa2,0x08,0x00,0x0f,0x24,
- 0x00,0x01,0x94,0x26,0x10,0x00,0x8f,0xa2,0xc1,0x2a,0x00,0x0c,
- 0xc4,0x09,0x04,0x24,0xa8,0x00,0xad,0x8f,0x01,0x00,0xd6,0x26,
- 0x2a,0x08,0xcd,0x02,0x05,0x00,0x20,0x10,0x60,0x00,0xb4,0x8f,
- 0xdc,0x00,0xa3,0x8f,0xdc,0xff,0x00,0x10,0xd8,0x00,0xb8,0x8f,
- 0x60,0x00,0xb4,0x8f,0xdc,0x00,0xa3,0x8f,0x00,0x00,0x00,0x00,
- 0x9c,0x01,0x70,0x14,0x00,0x00,0x00,0x00,0xd8,0x00,0xa3,0x8f,
- 0xe0,0x00,0xab,0x8f,0x40,0x61,0x03,0x00,0x54,0x00,0xb1,0xaf,
- 0x01,0x00,0x79,0x2c,0x21,0xb8,0x6c,0x01,0x50,0x00,0xb2,0xaf,
- 0x21,0x88,0xe0,0x02,0x6c,0x00,0xb9,0xaf,0x21,0xb0,0x00,0x00,
- 0xff,0xff,0x02,0x24,0x10,0x00,0x13,0x24,0x04,0x00,0xd6,0x26,
- 0x00,0x00,0x22,0xa6,0x02,0x00,0x22,0xa6,0x04,0x00,0x22,0xa6,
- 0x06,0x00,0x22,0xa6,0xfa,0xff,0xd3,0x16,0x08,0x00,0x31,0x26,
- 0x9c,0x00,0xae,0x8f,0x01,0x00,0x01,0x24,0x7b,0x00,0xc1,0x15,
- 0x00,0x00,0x00,0x00,0xec,0x88,0x98,0x8f,0xff,0x00,0x01,0x24,
- 0x10,0x00,0x01,0x17,0x00,0x00,0x00,0x00,0x58,0x00,0xbe,0xaf,
- 0x8c,0x00,0xbe,0x8f,0x01,0xa1,0x01,0x3c,0x00,0x08,0x21,0x34,
- 0x80,0x00,0x69,0x24,0x21,0xf0,0xc1,0x03,0xec,0x88,0x89,0xaf,
- 0x7b,0x2e,0x00,0x0c,0x21,0x20,0xc0,0x03,0x42,0x00,0x0a,0x24,
- 0x2c,0x00,0xca,0xa3,0xd8,0x00,0xa3,0x8f,0x58,0x00,0xbe,0x8f,
- 0x68,0x00,0x00,0x10,0xff,0xff,0x02,0x24,0xec,0x88,0x8f,0x8f,
- 0x00,0x00,0x00,0x00,0x80,0x00,0xed,0x31,0x63,0x00,0xa0,0x11,
- 0x00,0x00,0x00,0x00,0x80,0x00,0x72,0x24,0x60,0x00,0xf2,0x11,
- 0x00,0x00,0x00,0x00,0x58,0x00,0xbe,0xaf,0x8c,0x00,0xbe,0x8f,
- 0x01,0xa1,0x01,0x3c,0x00,0x08,0x21,0x34,0x60,0x00,0xb4,0xaf,
- 0x03,0x00,0x19,0x24,0x21,0xf0,0xc1,0x03,0x28,0x00,0xd9,0xa3,
- 0x7b,0x2e,0x00,0x0c,0x21,0x20,0xc0,0x03,0x80,0x00,0x0b,0x24,
- 0x2c,0x00,0xcb,0xa3,0x08,0x00,0x0c,0x24,0x78,0x00,0xcc,0xa3,
- 0x7b,0x2e,0x00,0x0c,0x21,0x20,0xc0,0x03,0x42,0x00,0x0e,0x24,
- 0x2c,0x00,0xce,0xa3,0x04,0x00,0x18,0x24,0x08,0x00,0xd8,0xa3,
- 0x04,0x00,0x09,0x24,0x0c,0x00,0xc9,0xa3,0xec,0x88,0x90,0x8f,
- 0x01,0xa1,0x01,0x3c,0x7f,0x00,0x10,0x32,0x80,0x83,0x10,0x00,
- 0x00,0x08,0x21,0x34,0x21,0x80,0x01,0x02,0x21,0xa0,0x00,0x02,
- 0x28,0x00,0x00,0xa2,0x7b,0x2e,0x00,0x0c,0x21,0x20,0x00,0x02,
- 0x80,0x00,0x0a,0x24,0x2c,0x00,0x0a,0xa2,0x09,0x00,0x0d,0x24,
- 0x78,0x00,0x0d,0xa2,0x7b,0x2e,0x00,0x0c,0x21,0x20,0x00,0x02,
- 0x42,0x00,0x0f,0x24,0x2c,0x00,0x0f,0xa2,0x04,0x00,0x19,0x24,
- 0x08,0x00,0x19,0xa2,0x04,0x00,0x0b,0x24,0x0c,0x00,0x0b,0xa2,
- 0x7b,0x2e,0x00,0x0c,0x21,0x20,0x00,0x02,0x43,0x00,0x0c,0x24,
- 0x2c,0x00,0x0c,0xa2,0x7b,0x2e,0x00,0x0c,0x21,0x20,0xc0,0x03,
- 0x43,0x00,0x0e,0x24,0x2c,0x00,0xce,0xa3,0xd8,0x00,0xb1,0x8f,
- 0x0f,0x27,0x16,0x24,0x50,0x00,0x31,0x26,0x48,0x00,0x11,0xa2,
- 0xd2,0x27,0x00,0x0c,0x00,0x00,0x00,0x00,0x38,0x00,0xd8,0x93,
- 0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x17,0x00,0x00,0x00,0x00,
- 0x21,0x10,0xc0,0x02,0xf8,0xff,0x40,0x14,0xff,0xff,0xd6,0x26,
- 0x48,0x00,0xc9,0x93,0x00,0x00,0x00,0x00,0x0d,0x00,0x29,0x16,
- 0x00,0x00,0x00,0x00,0xa0,0x00,0xad,0x8f,0xec,0x88,0x8a,0x8f,
- 0x40,0x78,0x0d,0x00,0x21,0xc8,0xef,0x02,0x00,0x00,0x2a,0xa7,
- 0xe0,0x00,0xab,0x8f,0x7f,0x00,0x4c,0x31,0x40,0x71,0x0c,0x00,
- 0x40,0x48,0x0d,0x00,0x21,0xc0,0x6e,0x01,0x21,0x78,0x09,0x03,
- 0x00,0x00,0xf2,0xa5,0x7b,0x2e,0x00,0x0c,0x21,0x20,0x80,0x02,
- 0x42,0x00,0x19,0x24,0x2c,0x00,0x99,0xa2,0x7b,0x2e,0x00,0x0c,
- 0x21,0x20,0xc0,0x03,0x42,0x00,0x0a,0x24,0x2c,0x00,0xca,0xa3,
- 0xff,0x00,0x0c,0x24,0xd8,0x00,0xa3,0x8f,0x58,0x00,0xbe,0x8f,
- 0x60,0x00,0xb4,0x8f,0xec,0x88,0x8c,0xaf,0xff,0xff,0x02,0x24,
- 0xa0,0x00,0xa5,0x8f,0x21,0xb0,0x00,0x00,0x06,0x00,0xa0,0x1c,
- 0x00,0xa3,0x07,0x3c,0x00,0xa3,0x07,0x3c,0x88,0x00,0xa6,0x8f,
- 0x12,0x00,0x00,0x10,0xa8,0x01,0xe7,0x34,0x00,0xa3,0x07,0x3c,
- 0x88,0x00,0xa6,0x8f,0xa8,0x01,0xe7,0x34,0x06,0x00,0x60,0x14,
- 0x40,0x69,0x16,0x00,0x00,0x00,0xee,0x94,0x01,0x00,0xcb,0x26,
- 0x04,0x00,0x6e,0x11,0x00,0x00,0x00,0x00,0x40,0x69,0x16,0x00,
- 0x21,0xc0,0xcd,0x00,0x00,0x01,0x16,0xa3,0x01,0x00,0xd6,0x26,
- 0x2a,0x08,0xc5,0x02,0xf4,0xff,0x20,0x14,0x00,0x00,0x00,0x00,
- 0x21,0xb0,0x00,0x00,0xc1,0x2a,0x00,0x0c,0x10,0x27,0x04,0x24,
- 0xa0,0x00,0xa2,0x8f,0x00,0x00,0x00,0x00,0x05,0x00,0x40,0x1c,
- 0x00,0x00,0x00,0x00,0x00,0xa3,0x08,0x3c,0xd8,0x00,0xa7,0x8f,
- 0x5c,0x00,0x00,0x10,0xa8,0x01,0x08,0x35,0x5c,0x00,0xb5,0xaf,
- 0x00,0xa3,0x08,0x3c,0xd8,0x00,0xa7,0x8f,0xa8,0x01,0x08,0x35,
- 0xd4,0x8e,0x95,0x27,0x60,0x00,0xb4,0xaf,0x9c,0x8e,0x93,0x27,
- 0x06,0x00,0xe0,0x14,0x88,0x00,0xb9,0x8f,0x00,0x00,0x0f,0x95,
- 0x01,0x00,0xc9,0x26,0x48,0x00,0x2f,0x11,0x00,0x00,0x00,0x00,
- 0x88,0x00,0xb9,0x8f,0x40,0x51,0x16,0x00,0x21,0xa0,0x2a,0x03,
- 0x14,0x01,0x8c,0x92,0x00,0x01,0x94,0x26,0x01,0x00,0x8b,0x31,
- 0x05,0x00,0x60,0x11,0xff,0x00,0x12,0x24,0x00,0x00,0x92,0x92,
- 0x02,0x00,0x00,0x10,0x7f,0x00,0x52,0x32,0xff,0x00,0x12,0x24,
- 0xff,0x00,0x01,0x24,0x39,0x00,0x41,0x12,0x00,0x00,0x00,0x00,
- 0x40,0x70,0x16,0x00,0x2a,0x00,0x40,0x06,0x21,0x88,0xee,0x02,
- 0x2a,0x08,0x42,0x02,0x28,0x00,0x20,0x10,0x94,0x00,0xa2,0x8f,
- 0x05,0x00,0xe0,0x14,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x95,
- 0x01,0x00,0x4d,0x26,0x22,0x00,0xb8,0x11,0x94,0x00,0xa2,0x8f,
- 0x00,0x00,0x23,0x86,0xff,0xff,0x01,0x24,0x04,0x00,0x61,0x10,
- 0x40,0x48,0x12,0x00,0x0a,0x00,0x43,0x16,0x40,0x78,0x12,0x00,
- 0x40,0x48,0x12,0x00,0x21,0x80,0xe9,0x02,0x00,0x00,0x02,0x86,
- 0xff,0xff,0x01,0x24,0x12,0x00,0x41,0x10,0x00,0x00,0x00,0x00,
- 0x10,0x00,0xc2,0x12,0x00,0x00,0x00,0x00,0x40,0x78,0x12,0x00,
- 0x94,0x00,0xa2,0x8f,0x21,0x80,0xef,0x02,0x00,0x00,0x06,0x86,
- 0x21,0xc8,0x42,0x02,0x10,0x00,0xb9,0xaf,0x21,0x20,0x60,0x02,
- 0x01,0x00,0x65,0x24,0x21,0x38,0xc2,0x02,0x29,0x2a,0x00,0x0c,
- 0x01,0x00,0xc6,0x24,0xff,0xff,0x02,0x24,0x00,0x00,0x22,0xa6,
- 0x0c,0x00,0x00,0x10,0x00,0x00,0x02,0xa6,0x00,0x00,0x32,0xa6,
- 0x09,0x00,0x00,0x10,0x00,0x00,0x16,0xa6,0x94,0x00,0xa2,0x8f,
- 0x00,0x00,0x2a,0x86,0x21,0x20,0xa0,0x02,0x21,0x30,0x42,0x02,
- 0x29,0x2a,0x00,0x0c,0x21,0x28,0x42,0x01,0xff,0xff,0x0c,0x24,
- 0x00,0x00,0x2c,0xa6,0x00,0xa3,0x08,0x3c,0xa0,0x00,0xa2,0x8f,
- 0xd8,0x00,0xa7,0x8f,0xa8,0x01,0x08,0x35,0x01,0x00,0xd6,0x26,
- 0x2a,0x08,0xc2,0x02,0xb0,0xff,0x20,0x14,0x00,0x00,0x00,0x00,
- 0x60,0x00,0xb4,0x8f,0x5c,0x00,0xb5,0x8f,0x21,0xb0,0x00,0x00,
- 0x35,0x00,0x40,0x18,0x21,0x90,0x00,0x00,0x60,0x00,0xb4,0xaf,
- 0x04,0x8f,0x94,0x27,0x21,0x88,0xe0,0x02,0xfc,0x8e,0x90,0x27,
- 0x00,0x8f,0x93,0x27,0x00,0x00,0x23,0x86,0xff,0xff,0x01,0x24,
- 0x13,0x00,0x61,0x10,0x2a,0x08,0x76,0x00,0x0f,0x00,0x20,0x14,
- 0x00,0x00,0x00,0x00,0x21,0x20,0x00,0x02,0x29,0x2a,0x00,0x0c,
- 0x01,0x00,0xc5,0x26,0x00,0x00,0x23,0x86,0x00,0x00,0x00,0x00,
- 0x05,0x00,0xc3,0x12,0x00,0x00,0x00,0x00,0x21,0x20,0x60,0x02,
- 0x29,0x2a,0x00,0x0c,0x01,0x00,0x65,0x24,0x01,0x00,0x52,0x26,
- 0x5c,0x28,0x00,0x0c,0x20,0x00,0x04,0x24,0x01,0x00,0x52,0x26,
- 0x0c,0x00,0x00,0x10,0x01,0x00,0xc2,0x26,0xd8,0x00,0xab,0x8f,
- 0x00,0x00,0x00,0x00,0x05,0x00,0x60,0x15,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x0d,0x95,0x01,0x00,0xce,0x26,0x04,0x00,0xcd,0x11,
- 0x01,0x00,0xc2,0x26,0x29,0x2a,0x00,0x0c,0x21,0x20,0x80,0x02,
- 0x01,0x00,0xc2,0x26,0xa0,0x00,0xb8,0x8f,0x21,0xb0,0x40,0x00,
- 0x2a,0x08,0xd8,0x02,0x05,0x00,0x20,0x10,0x02,0x00,0x31,0x26,
- 0x00,0xa3,0x08,0x3c,0xa8,0x01,0x08,0x35,0xd7,0xff,0x00,0x10,
- 0x21,0x10,0x00,0x03,0x00,0xa3,0x08,0x3c,0x60,0x00,0xb4,0x8f,
- 0xa0,0x00,0xa2,0x8f,0xd8,0x00,0xa7,0x8f,0xa8,0x01,0x08,0x35,
- 0x9c,0x00,0xa9,0x8f,0x01,0x00,0x01,0x24,0x13,0x00,0x21,0x15,
- 0x6c,0x00,0xac,0x8f,0xa0,0x00,0xaf,0x8f,0xff,0xff,0x01,0x24,
- 0x40,0xc8,0x0f,0x00,0x21,0x50,0xf9,0x02,0x00,0x00,0x42,0x85,
- 0x00,0x00,0x00,0x00,0x03,0x00,0x41,0x14,0x00,0x00,0x00,0x00,
- 0x08,0x00,0x00,0x10,0x21,0x10,0xe0,0x01,0x08,0x8f,0x84,0x27,
- 0x7f,0x00,0x45,0x30,0x29,0x2a,0x00,0x0c,0x21,0x30,0xe0,0x00,
- 0x00,0xa3,0x08,0x3c,0xa0,0x00,0xa2,0x8f,0xa8,0x01,0x08,0x35,
- 0x6c,0x00,0xac,0x8f,0x00,0x00,0x00,0x00,0x0c,0x00,0x80,0x11,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x0b,0x95,0x00,0x00,0x00,0x00,
- 0x08,0x00,0x60,0x11,0x00,0x00,0x00,0x00,0x00,0xa3,0x0e,0x3c,
- 0xa8,0x01,0xc5,0x95,0x29,0x2a,0x00,0x0c,0x14,0x8f,0x84,0x27,
- 0x00,0xa3,0x08,0x3c,0xa0,0x00,0xa2,0x8f,0xa8,0x01,0x08,0x35,
- 0x0a,0x00,0x40,0x16,0x6c,0x00,0xa9,0x8f,0x29,0x2a,0x00,0x0c,
- 0x20,0x8f,0x84,0x27,0xbc,0x00,0xad,0x8f,0x00,0xa3,0x08,0x3c,
- 0x00,0x80,0xb8,0x35,0xa0,0x00,0xa2,0x8f,0xbc,0x00,0xb8,0xaf,
- 0xa8,0x01,0x08,0x35,0x6c,0x00,0xa9,0x8f,0x00,0x00,0x00,0x00,
- 0x06,0x00,0x20,0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x19,0x95,
- 0x00,0x00,0x00,0x00,0x02,0x00,0x20,0x13,0x00,0x00,0x00,0x00,
- 0x01,0x00,0x52,0x26,0x29,0x2a,0x00,0x0c,0x44,0x8f,0x84,0x27,
- 0xa0,0x00,0xaa,0x8f,0x00,0x00,0x00,0x00,0x2a,0x08,0x4a,0x02,
- 0x04,0x00,0x20,0x10,0x9c,0x00,0xaf,0x8f,0x29,0x2a,0x00,0x0c,
- 0x48,0x8f,0x84,0x27,0x9c,0x00,0xaf,0x8f,0x01,0x00,0x01,0x24,
- 0x10,0x00,0xe1,0x15,0x54,0x00,0xb1,0x8f,0xa0,0x00,0xac,0x8f,
- 0xff,0xff,0x01,0x24,0x40,0x58,0x0c,0x00,0x21,0x70,0xeb,0x02,
- 0x00,0x00,0xcd,0x85,0x00,0x00,0x00,0x00,0x08,0x00,0xa1,0x15,
- 0x54,0x00,0xb1,0x8f,0xec,0x88,0x98,0x8f,0xff,0x00,0x01,0x24,
- 0x04,0x00,0x01,0x17,0x54,0x00,0xb1,0x8f,0x29,0x2a,0x00,0x0c,
- 0x78,0x8f,0x84,0x27,0x54,0x00,0xb1,0x8f,0x50,0x00,0xb2,0x8f,
- 0x0b,0x03,0x00,0x10,0x00,0x00,0x00,0x00,0x5c,0x00,0xb5,0xaf,
- 0x21,0xa8,0x00,0x00,0x04,0x00,0x61,0x04,0xec,0x88,0x80,0xaf,
- 0xe0,0x00,0xa6,0x8f,0xa3,0x00,0x00,0x10,0xac,0x00,0xad,0x8f,
- 0x9c,0x00,0xa9,0x8f,0x01,0x00,0x01,0x24,0x05,0x00,0x21,0x11,
- 0xe0,0x00,0xa6,0x8f,0xe0,0x00,0xa6,0x8f,0x9c,0x00,0x00,0x10,
- 0xac,0x00,0xad,0x8f,0xe0,0x00,0xa6,0x8f,0x00,0x00,0x00,0x00,
- 0x98,0x00,0xc0,0x10,0xac,0x00,0xad,0x8f,0xd8,0x00,0xb9,0x8f,
- 0xa0,0x00,0xac,0x8f,0x40,0x51,0x19,0x00,0x21,0x78,0xca,0x00,
- 0x40,0x58,0x0c,0x00,0x21,0x10,0xeb,0x01,0x00,0x00,0x4e,0x84,
- 0xff,0xff,0x01,0x24,0x8e,0x00,0xc1,0x11,0xac,0x00,0xad,0x8f,
- 0x58,0x00,0xbe,0xaf,0x8c,0x00,0xbe,0x8f,0x01,0xa1,0x01,0x3c,
- 0x00,0x08,0x21,0x34,0x54,0x00,0xb1,0xaf,0x50,0x00,0xb2,0xaf,
- 0x60,0x00,0xb4,0xaf,0x03,0x00,0x0d,0x24,0x21,0xf0,0xc1,0x03,
- 0x28,0x00,0xcd,0xa3,0x84,0x00,0xa2,0xaf,0x7b,0x2e,0x00,0x0c,
- 0x21,0x20,0xc0,0x03,0x80,0x00,0x18,0x24,0x2c,0x00,0xd8,0xa3,
- 0x08,0x00,0x09,0x24,0x78,0x00,0xc9,0xa3,0x7b,0x2e,0x00,0x0c,
- 0x21,0x20,0xc0,0x03,0x42,0x00,0x19,0x24,0x2c,0x00,0xd9,0xa3,
- 0x04,0x00,0x0a,0x24,0x08,0x00,0xca,0xa3,0x04,0x00,0x0c,0x24,
- 0x0c,0x00,0xcc,0xa3,0x84,0x00,0xaf,0x8f,0x01,0xa1,0x01,0x3c,
- 0x00,0x00,0xf4,0x85,0x00,0x08,0x21,0x34,0x7f,0x00,0x94,0x32,
- 0x80,0xa3,0x14,0x00,0x21,0xa0,0x81,0x02,0x28,0x00,0x80,0xa2,
- 0x7b,0x2e,0x00,0x0c,0x21,0x20,0x80,0x02,0x80,0x00,0x0b,0x24,
- 0x2c,0x00,0x8b,0xa2,0x09,0x00,0x0e,0x24,0x78,0x00,0x8e,0xa2,
- 0x7b,0x2e,0x00,0x0c,0x21,0x20,0x80,0x02,0x42,0x00,0x0d,0x24,
- 0x2c,0x00,0x8d,0xa2,0x04,0x00,0x18,0x24,0x08,0x00,0x98,0xa2,
- 0x04,0x00,0x09,0x24,0x0c,0x00,0x89,0xa2,0x7b,0x2e,0x00,0x0c,
- 0x21,0x20,0xc0,0x03,0x43,0x00,0x19,0x24,0x2c,0x00,0xd9,0xa3,
- 0x7b,0x2e,0x00,0x0c,0x21,0x20,0x80,0x02,0x43,0x00,0x0a,0x24,
- 0x2c,0x00,0x8a,0xa2,0x7b,0x2e,0x00,0x0c,0x21,0x20,0xc0,0x03,
- 0x7b,0x2e,0x00,0x0c,0x21,0x20,0x80,0x02,0xf0,0x88,0x8c,0x93,
- 0x01,0xa0,0x02,0x3c,0x48,0x00,0x8c,0xa2,0xf1,0x88,0x8f,0x93,
- 0x96,0xe6,0x42,0x24,0x02,0x00,0x16,0x24,0xf2,0x88,0x90,0x27,
- 0x48,0x00,0x8f,0xa2,0x00,0x00,0x0b,0x92,0x04,0x00,0x10,0x26,
- 0x48,0x00,0x8b,0xa2,0xfd,0xff,0x0e,0x92,0x00,0x00,0x00,0x00,
- 0x48,0x00,0x8e,0xa2,0xfe,0xff,0x0d,0x92,0x00,0x00,0x00,0x00,
- 0x48,0x00,0x8d,0xa2,0xff,0xff,0x18,0x92,0xf5,0xff,0x02,0x16,
- 0x48,0x00,0x98,0xa2,0x0f,0x27,0x16,0x24,0xd2,0x27,0x00,0x0c,
- 0x00,0x00,0x00,0x00,0x38,0x00,0xc9,0x93,0x00,0x00,0x00,0x00,
- 0x16,0x00,0x21,0x2d,0x04,0x00,0x20,0x10,0x00,0x00,0x00,0x00,
- 0x21,0x10,0xc0,0x02,0xf7,0xff,0x40,0x14,0xff,0xff,0xd6,0x26,
- 0x38,0x00,0xd9,0x93,0x16,0x00,0x01,0x24,0x0b,0x00,0x21,0x13,
- 0x00,0x00,0x00,0x00,0x84,0x00,0xaa,0x8f,0x38,0x00,0xcc,0x93,
- 0x00,0x00,0x45,0x85,0xd8,0x00,0xa7,0x8f,0xa4,0x8f,0x84,0x27,
- 0x16,0x00,0x06,0x24,0x10,0x00,0xac,0xaf,0x29,0x2a,0x00,0x0c,
- 0x7f,0x00,0xa5,0x30,0x00,0x04,0x15,0x24,0x01,0xa0,0x13,0x3c,
- 0x96,0xe6,0x73,0x26,0x21,0xb0,0x00,0x00,0xf0,0x88,0x90,0x27,
- 0xf0,0x8f,0x91,0x27,0x48,0x00,0xd2,0x93,0x00,0x00,0x06,0x92,
- 0x00,0x00,0x00,0x00,0x09,0x00,0x46,0x12,0x00,0x00,0x00,0x00,
- 0x84,0x00,0xaf,0x8f,0xd8,0x00,0xa7,0x8f,0x00,0x00,0xe5,0x85,
- 0x10,0x00,0xb2,0xaf,0x21,0x20,0x20,0x02,0x29,0x2a,0x00,0x0c,
- 0x7f,0x00,0xa5,0x30,0x10,0x00,0xb5,0x36,0x01,0x00,0x10,0x26,
- 0xf1,0xff,0x13,0x16,0x00,0x00,0x00,0x00,0x7b,0x2e,0x00,0x0c,
- 0x21,0x20,0x80,0x02,0x42,0x00,0x0b,0x24,0x2c,0x00,0x8b,0xa2,
- 0x7b,0x2e,0x00,0x0c,0x21,0x20,0xc0,0x03,0x42,0x00,0x0e,0x24,
- 0x2c,0x00,0xce,0xa3,0xe0,0x00,0xa6,0x8f,0xdc,0x00,0xa3,0x8f,
- 0x58,0x00,0xbe,0x8f,0x60,0x00,0xb4,0x8f,0x50,0x00,0xb2,0x8f,
- 0x54,0x00,0xb1,0x8f,0x00,0x00,0x00,0x00,0xac,0x00,0xad,0x8f,
- 0xa8,0x00,0xb8,0x8f,0x21,0xb0,0xa0,0x01,0x2a,0x08,0xb8,0x01,
- 0xc4,0x01,0x20,0x10,0xbc,0x00,0xad,0x8f,0x54,0x00,0xb1,0xaf,
- 0x50,0x00,0xb2,0xaf,0x60,0x00,0xb4,0xaf,0x58,0x00,0xbe,0xaf,
- 0x04,0x00,0x10,0x24,0x0c,0x00,0x61,0x04,0xd8,0x00,0xab,0x8f,
- 0xd8,0x00,0xa9,0x8f,0xdc,0x88,0x8a,0x27,0x80,0xc8,0x09,0x00,
- 0x21,0x60,0x2a,0x03,0x40,0x79,0x16,0x00,0x21,0xf0,0xc0,0x02,
- 0x68,0x00,0xaf,0xaf,0x70,0x00,0xac,0xaf,0x3b,0x00,0x00,0x10,
- 0x21,0x90,0x00,0x00,0xd8,0x00,0xab,0x8f,0x40,0xc0,0x16,0x00,
- 0x40,0x71,0x0b,0x00,0x21,0x68,0xce,0x00,0x21,0x48,0xb8,0x01,
- 0x00,0x00,0x3e,0x85,0xff,0xff,0x01,0x24,0x2b,0x00,0xc1,0x17,
- 0xd8,0x00,0xad,0x8f,0x00,0xa3,0x0a,0x3c,0xa8,0x01,0x4c,0x95,
- 0x01,0x00,0xd9,0x26,0x04,0x00,0x2c,0x17,0x88,0x00,0xaf,0x8f,
- 0x98,0x01,0x00,0x10,0x04,0x00,0x10,0x24,0x88,0x00,0xaf,0x8f,
- 0x40,0x59,0x16,0x00,0x21,0x88,0xeb,0x01,0x14,0x01,0x2e,0x92,
- 0x21,0x90,0x00,0x00,0x20,0x00,0xcd,0x31,0x08,0x00,0xa0,0x15,
- 0x00,0x01,0x34,0x26,0x94,0x00,0xb8,0x8f,0xd8,0x00,0xa5,0x8f,
- 0x02,0x00,0xb5,0x36,0x34,0x90,0x84,0x27,0x29,0x2a,0x00,0x0c,
- 0x21,0x30,0xd8,0x02,0x00,0x01,0x34,0x26,0x55,0x00,0x09,0x24,
- 0x00,0x00,0x89,0xa2,0x04,0x00,0x10,0x24,0x01,0x00,0x4a,0x32,
- 0x40,0xc8,0x0a,0x00,0x02,0x00,0x4f,0x32,0x43,0x58,0x0f,0x00,
- 0x08,0x00,0x2c,0x37,0x25,0x70,0x8b,0x01,0x10,0x00,0x8e,0xa2,
- 0xc1,0x2a,0x00,0x0c,0xfa,0x00,0x04,0x24,0x01,0x00,0x52,0x26,
- 0xf6,0xff,0x50,0x16,0x01,0x00,0x4a,0x32,0xdc,0x00,0xa3,0x8f,
- 0xe0,0x00,0xa6,0x8f,0x77,0x01,0x00,0x10,0xa8,0x00,0xae,0x8f,
- 0xd8,0x00,0xad,0x8f,0xdc,0x88,0x89,0x27,0x80,0xc0,0x0d,0x00,
- 0x21,0x50,0x09,0x03,0x40,0xc9,0x16,0x00,0x68,0x00,0xb9,0xaf,
- 0x70,0x00,0xaa,0xaf,0x21,0x90,0x00,0x00,0x88,0x00,0xa2,0x8f,
- 0x68,0x00,0xaf,0x8f,0x40,0x61,0x1e,0x00,0x21,0x98,0x4c,0x00,
- 0x21,0xa0,0x4f,0x00,0x00,0x01,0x94,0x26,0x00,0x01,0x73,0x26,
- 0x05,0x00,0x01,0x24,0x07,0x00,0xe1,0x12,0x7f,0x00,0x01,0x24,
- 0x05,0x00,0xe1,0x12,0x0c,0x00,0x01,0x24,0x03,0x00,0xe1,0x12,
- 0x0e,0x00,0x01,0x24,0x0f,0x00,0xe1,0x16,0x00,0x00,0x00,0x00,
- 0x14,0x00,0x6b,0x92,0x00,0x00,0x00,0x00,0x01,0x00,0x6e,0x31,
- 0x0a,0x00,0xc0,0x11,0x00,0x00,0x00,0x00,0x94,0x00,0xad,0x8f,
- 0xd8,0x00,0xa5,0x8f,0x01,0x00,0xb5,0x36,0x58,0x90,0x84,0x27,
- 0x21,0x90,0x00,0x00,0x29,0x2a,0x00,0x0c,0x21,0x30,0xcd,0x03,
- 0x98,0x00,0x00,0x10,0x01,0x00,0x4e,0x32,0x14,0x00,0x98,0x92,
- 0x00,0x00,0x00,0x00,0x20,0x00,0x09,0x33,0x0a,0x00,0x20,0x15,
- 0x00,0x00,0x00,0x00,0x94,0x00,0xaa,0x8f,0xd8,0x00,0xa5,0x8f,
- 0x02,0x00,0xb5,0x36,0x80,0x90,0x84,0x27,0x21,0x90,0x00,0x00,
- 0x29,0x2a,0x00,0x0c,0x21,0x30,0xca,0x02,0x8a,0x00,0x00,0x10,
- 0x01,0x00,0x4e,0x32,0x00,0x00,0x60,0x92,0x00,0x00,0x92,0xa2,
- 0x14,0x00,0x99,0x92,0x00,0x00,0x00,0x00,0x40,0x00,0x2f,0x33,
- 0x0d,0x00,0xe0,0x11,0xc3,0x09,0x10,0x24,0x94,0x00,0xac,0x8f,
- 0xd8,0x00,0xa5,0x8f,0x04,0x00,0xb5,0x36,0xa4,0x90,0x84,0x27,
- 0x21,0x90,0x00,0x00,0x29,0x2a,0x00,0x0c,0x21,0x30,0xcc,0x02,
- 0xc1,0x2a,0x00,0x0c,0xc4,0x09,0x04,0x24,0x78,0x00,0x00,0x10,
- 0x01,0x00,0x4e,0x32,0xc3,0x09,0x10,0x24,0xd2,0x27,0x00,0x0c,
- 0x00,0x00,0x00,0x00,0x08,0x00,0x6b,0x92,0x00,0x00,0x00,0x00,
- 0x01,0x00,0x6e,0x31,0x04,0x00,0xc0,0x11,0x00,0x00,0x00,0x00,
- 0x21,0x10,0x00,0x02,0xf7,0xff,0x40,0x14,0xff,0xff,0x10,0x26,
- 0x0a,0x00,0x01,0x06,0x00,0x00,0x00,0x00,0x94,0x00,0xad,0x8f,
- 0xd8,0x00,0xa5,0x8f,0x00,0x04,0xb5,0x36,0xd8,0x90,0x84,0x27,
- 0x21,0x90,0x00,0x00,0x29,0x2a,0x00,0x0c,0x21,0x30,0xcd,0x02,
- 0x62,0x00,0x00,0x10,0x01,0x00,0x4e,0x32,0x14,0x00,0x78,0x92,
- 0x00,0x00,0x00,0x00,0x0e,0x00,0x09,0x33,0x1f,0x00,0x20,0x11,
- 0x05,0x00,0x01,0x24,0x94,0x00,0xaa,0x8f,0xd8,0x00,0xa5,0x8f,
- 0x08,0x00,0xb5,0x36,0x00,0x91,0x84,0x27,0x29,0x2a,0x00,0x0c,
- 0x21,0x30,0xca,0x03,0x14,0x00,0x79,0x92,0x00,0x00,0x00,0x00,
- 0x02,0x00,0x2f,0x33,0x03,0x00,0xe0,0x11,0x00,0x00,0x00,0x00,
- 0x29,0x2a,0x00,0x0c,0x14,0x91,0x84,0x27,0x14,0x00,0x6c,0x92,
- 0x00,0x00,0x00,0x00,0x04,0x00,0x8b,0x31,0x03,0x00,0x60,0x11,
- 0x00,0x00,0x00,0x00,0x29,0x2a,0x00,0x0c,0x24,0x91,0x84,0x27,
- 0x14,0x00,0x6e,0x92,0x00,0x00,0x00,0x00,0x08,0x00,0xcd,0x31,
- 0x03,0x00,0xa0,0x11,0x00,0x00,0x00,0x00,0x29,0x2a,0x00,0x0c,
- 0x34,0x91,0x84,0x27,0x29,0x2a,0x00,0x0c,0x44,0x91,0x84,0x27,
- 0x05,0x00,0x01,0x24,0x07,0x00,0xe1,0x12,0x7f,0x00,0x01,0x24,
- 0x05,0x00,0xe1,0x12,0x0c,0x00,0x01,0x24,0x03,0x00,0xe1,0x12,
- 0x0e,0x00,0x01,0x24,0x0f,0x00,0xe1,0x16,0x00,0x00,0x00,0x00,
- 0x14,0x00,0x78,0x92,0x00,0x00,0x00,0x00,0x01,0x00,0x09,0x33,
- 0x0a,0x00,0x20,0x15,0x00,0x00,0x00,0x00,0x94,0x00,0xaa,0x8f,
- 0xd8,0x00,0xa5,0x8f,0x01,0x00,0xb5,0x36,0x48,0x91,0x84,0x27,
- 0x21,0x90,0x00,0x00,0x29,0x2a,0x00,0x0c,0x21,0x30,0xca,0x02,
- 0x29,0x00,0x00,0x10,0x01,0x00,0x4e,0x32,0x00,0x00,0x70,0x92,
- 0x05,0x00,0x01,0x24,0x07,0x00,0xe1,0x12,0x7f,0x00,0x01,0x24,
- 0x05,0x00,0xe1,0x12,0x0c,0x00,0x01,0x24,0x03,0x00,0xe1,0x12,
- 0x0e,0x00,0x01,0x24,0x0f,0x00,0xe1,0x16,0x00,0x00,0x00,0x00,
- 0x14,0x00,0x79,0x92,0x00,0x00,0x00,0x00,0x01,0x00,0x2f,0x33,
- 0x0a,0x00,0xe0,0x11,0x00,0x00,0x00,0x00,0x94,0x00,0xac,0x8f,
- 0xd8,0x00,0xa5,0x8f,0x01,0x00,0xb5,0x36,0x70,0x91,0x84,0x27,
- 0x21,0x90,0x00,0x00,0x29,0x2a,0x00,0x0c,0x21,0x30,0xcc,0x02,
- 0x11,0x00,0x00,0x10,0x01,0x00,0x4e,0x32,0x09,0x00,0x12,0x12,
- 0x00,0x00,0x00,0x00,0x94,0x00,0xab,0x8f,0xd8,0x00,0xa5,0x8f,
- 0x10,0x00,0xb5,0x36,0x9c,0x91,0x84,0x27,0x21,0x38,0x40,0x02,
- 0x10,0x00,0xb0,0xaf,0x29,0x2a,0x00,0x0c,0x21,0x30,0xcb,0x03,
- 0x01,0x00,0x52,0x26,0x00,0x01,0x41,0x2a,0x56,0xff,0x20,0x14,
- 0x05,0x00,0x01,0x24,0x21,0x90,0x00,0x00,0x01,0x00,0x4e,0x32,
- 0x40,0x68,0x0e,0x00,0x02,0x00,0x49,0x32,0x43,0x50,0x09,0x00,
- 0x08,0x00,0xb8,0x35,0x25,0xc8,0x0a,0x03,0x10,0x00,0x99,0xa2,
- 0xc1,0x2a,0x00,0x0c,0xfa,0x00,0x04,0x24,0x18,0x00,0x60,0x92,
- 0x18,0x00,0x60,0x92,0x18,0x00,0x70,0x92,0x02,0x01,0x00,0x00,
- 0x02,0x81,0x10,0x00,0x03,0x00,0x10,0x32,0x03,0x00,0x00,0x30,
- 0x02,0x01,0x00,0x00,0x15,0x00,0x12,0x12,0x03,0x00,0x00,0x30,
- 0x94,0x00,0xaf,0x8f,0xd8,0x00,0xa5,0x8f,0x20,0x00,0xb5,0x36,
- 0xc8,0x91,0x84,0x27,0x10,0x00,0xb2,0xaf,0x14,0x00,0xb0,0xaf,
- 0x21,0x30,0xcf,0x02,0x29,0x2a,0x00,0x0c,0x21,0x38,0xcf,0x03,
- 0x26,0x88,0x12,0x02,0x01,0x00,0x2c,0x32,0x04,0x00,0x80,0x11,
- 0x02,0x00,0x2b,0x32,0x29,0x2a,0x00,0x0c,0x04,0x92,0x84,0x27,
- 0x02,0x00,0x2b,0x32,0x03,0x00,0x60,0x11,0x00,0x00,0x00,0x00,
- 0x29,0x2a,0x00,0x0c,0x10,0x92,0x84,0x27,0x01,0x00,0x52,0x26,
- 0x04,0x00,0x01,0x24,0xd7,0xff,0x41,0x16,0x01,0x00,0x4e,0x32,
- 0x08,0x00,0x0e,0x24,0x10,0x00,0x8e,0xa2,0xe1,0x21,0x00,0x0c,
- 0x21,0x20,0x00,0x00,0x01,0x00,0x0d,0x24,0x00,0xa3,0x09,0x3c,
- 0x80,0x01,0x2d,0xad,0x70,0x00,0xb8,0x8f,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x04,0x8f,0xe1,0x21,0x00,0x0c,0x01,0x00,0x84,0x24,
- 0xa0,0x00,0xa7,0x8f,0x01,0x00,0x0a,0x24,0x04,0x00,0x6a,0xa2,
- 0x0d,0x00,0xe0,0x18,0x21,0x90,0x00,0x00,0x88,0x00,0xa5,0x8f,
- 0x21,0x18,0x00,0x00,0x40,0x21,0x07,0x00,0x21,0x10,0xa3,0x00,
- 0x00,0x01,0x40,0x90,0x00,0x01,0x40,0x90,0x00,0x01,0x40,0x90,
- 0x20,0x00,0x63,0x24,0x08,0x01,0x40,0x90,0x2a,0x08,0x64,0x00,
- 0xf9,0xff,0x20,0x14,0x21,0x10,0xa3,0x00,0xc0,0x09,0x10,0x24,
- 0xfc,0xff,0x10,0x26,0xff,0xff,0x00,0x16,0xfc,0xff,0x10,0x26,
- 0x00,0xa3,0x19,0x3c,0x80,0x01,0x2f,0x8f,0x01,0x00,0x01,0x24,
- 0x08,0x00,0xe1,0x11,0x08,0x00,0xce,0x33,0x94,0x00,0xac,0x8f,
- 0xd8,0x00,0xa5,0x8f,0x40,0x00,0xb5,0x36,0x1c,0x92,0x84,0x27,
- 0x29,0x2a,0x00,0x0c,0x21,0x30,0xcc,0x03,0x08,0x00,0xce,0x33,
- 0x88,0x00,0xab,0x8f,0x08,0x00,0xcd,0x25,0x43,0x48,0x0d,0x00,
- 0x21,0x88,0x69,0x01,0x00,0x00,0x39,0x92,0x07,0x00,0xd8,0x33,
- 0x01,0x00,0x0a,0x24,0x04,0x90,0x0a,0x03,0x24,0x78,0x32,0x03,
- 0x08,0x00,0xe0,0x11,0x2a,0x00,0x0e,0x24,0x94,0x00,0xac,0x8f,
- 0xd8,0x00,0xa5,0x8f,0x40,0x00,0xb5,0x36,0x3c,0x92,0x84,0x27,
- 0x29,0x2a,0x00,0x0c,0x21,0x30,0xcc,0x03,0x2a,0x00,0x0e,0x24,
- 0x00,0x00,0x8e,0xa2,0xc3,0x09,0x10,0x24,0x00,0xa3,0x0d,0x3c,
- 0x80,0x01,0xab,0x8d,0x00,0x00,0x00,0x00,0x04,0x00,0x60,0x11,
- 0x00,0x00,0x00,0x00,0xff,0xff,0x10,0x26,0xfa,0xff,0x00,0x16,
- 0x00,0xa3,0x0d,0x3c,0xc0,0x09,0x10,0x24,0xfc,0xff,0x10,0x26,
- 0xff,0xff,0x00,0x16,0xfc,0xff,0x10,0x26,0x00,0x00,0x29,0x92,
- 0x00,0x00,0x00,0x00,0x24,0x50,0x32,0x01,0x07,0x00,0x40,0x15,
- 0x00,0x00,0x00,0x00,0x94,0x00,0xb8,0x8f,0xd8,0x00,0xa5,0x8f,
- 0x40,0x00,0xb5,0x36,0x6c,0x92,0x84,0x27,0x29,0x2a,0x00,0x0c,
- 0x21,0x30,0xd8,0x03,0x00,0x00,0x60,0x92,0x08,0x00,0x60,0x92,
- 0x00,0xa3,0x19,0x3c,0x80,0x01,0x2f,0x8f,0x00,0x00,0x00,0x00,
- 0x07,0x00,0xe0,0x11,0x00,0x00,0x00,0x00,0x94,0x00,0xac,0x8f,
- 0xd8,0x00,0xa5,0x8f,0x80,0x00,0xb5,0x36,0x9c,0x92,0x84,0x27,
- 0x29,0x2a,0x00,0x0c,0x21,0x30,0xcc,0x03,0xe1,0x21,0x00,0x0c,
- 0x21,0x20,0x00,0x00,0x01,0x00,0x0e,0x24,0x00,0xa3,0x0d,0x3c,
- 0x80,0x01,0xae,0xad,0x70,0x00,0xab,0x8f,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x64,0x8d,0xe1,0x21,0x00,0x0c,0x01,0x00,0x84,0x24,
- 0xc0,0x09,0x10,0x24,0xfc,0xff,0x10,0x26,0xff,0xff,0x00,0x16,
- 0xfc,0xff,0x10,0x26,0x00,0xa3,0x09,0x3c,0x80,0x01,0x2a,0x8d,
- 0x01,0x00,0x01,0x24,0x07,0x00,0x41,0x11,0x00,0x00,0x00,0x00,
- 0x94,0x00,0xb8,0x8f,0xd8,0x00,0xa5,0x8f,0x00,0x01,0xb5,0x36,
- 0xc4,0x92,0x84,0x27,0x29,0x2a,0x00,0x0c,0x21,0x30,0xd8,0x03,
- 0x00,0x00,0x39,0x92,0x00,0x00,0x00,0x00,0x24,0x78,0x32,0x03,
- 0x07,0x00,0xe0,0x11,0x00,0x00,0x00,0x00,0x94,0x00,0xac,0x8f,
- 0xd8,0x00,0xa5,0x8f,0x40,0x00,0xb5,0x36,0xec,0x92,0x84,0x27,
- 0x29,0x2a,0x00,0x0c,0x21,0x30,0xcc,0x03,0xe1,0x21,0x00,0x0c,
- 0x21,0x20,0x00,0x00,0xdc,0x00,0xa3,0x8f,0xe0,0x00,0xa6,0x8f,
- 0x04,0x00,0x10,0x24,0xa8,0x00,0xae,0x8f,0x01,0x00,0xd6,0x26,
- 0x2a,0x08,0xce,0x02,0x49,0xfe,0x20,0x14,0x00,0x00,0x00,0x00,
- 0x54,0x00,0xb1,0x8f,0x50,0x00,0xb2,0x8f,0x60,0x00,0xb4,0x8f,
- 0x58,0x00,0xbe,0x8f,0x00,0x00,0x00,0x00,0xbc,0x00,0xad,0x8f,
- 0x00,0x00,0x00,0x00,0x25,0x58,0xb5,0x01,0x3a,0x00,0x60,0x15,
- 0xbc,0x00,0xab,0xaf,0x03,0x00,0x61,0x04,0x50,0x00,0xb2,0xaf,
- 0x19,0x00,0x00,0x10,0x01,0x00,0x12,0x24,0xac,0x00,0xa9,0x8f,
- 0xa8,0x00,0xaa,0x8f,0x21,0x90,0x00,0x00,0x2a,0x08,0x2a,0x01,
- 0x13,0x00,0x20,0x10,0x21,0xb0,0x20,0x01,0xd8,0x00,0xb8,0x8f,
- 0x54,0x00,0xb1,0xaf,0x40,0xc9,0x18,0x00,0x21,0x78,0xd9,0x00,
- 0x40,0x60,0x16,0x00,0x21,0x88,0xec,0x01,0x00,0x00,0x2e,0x86,
- 0xff,0xff,0x01,0x24,0x03,0x00,0xc1,0x11,0xa8,0x00,0xad,0x8f,
- 0x01,0x00,0x52,0x26,0xa8,0x00,0xad,0x8f,0x01,0x00,0xd6,0x26,
- 0x2a,0x08,0xcd,0x02,0xf7,0xff,0x20,0x14,0x02,0x00,0x31,0x26,
- 0x54,0x00,0xb1,0x8f,0x00,0x00,0x00,0x00,0x1a,0x00,0x40,0x12,
- 0x00,0x00,0x00,0x00,0x1c,0x93,0x84,0x27,0x29,0x2a,0x00,0x0c,
- 0x21,0x28,0x40,0x02,0x9c,0x00,0xab,0x8f,0x01,0x00,0x01,0x24,
- 0x11,0x00,0x61,0x15,0x00,0x00,0x00,0x00,0xe0,0x00,0xa9,0x8f,
- 0x00,0x00,0x00,0x00,0x0d,0x00,0x20,0x11,0x00,0x00,0x00,0x00,
- 0xd8,0x00,0xaa,0x8f,0xa0,0x00,0xaf,0x8f,0x40,0xc1,0x0a,0x00,
- 0x21,0xc8,0x38,0x01,0x40,0x60,0x0f,0x00,0x21,0x70,0x2c,0x03,
- 0x00,0x00,0xcd,0x85,0xff,0xff,0x01,0x24,0x03,0x00,0xa1,0x11,
- 0x00,0x00,0x00,0x00,0x29,0x2a,0x00,0x0c,0x28,0x93,0x84,0x27,
- 0x65,0x2a,0x00,0x0c,0x00,0x00,0x00,0x00,0x50,0x00,0xb2,0x8f,
- 0x00,0x00,0x00,0x00,0x5c,0x00,0xb5,0x8f,0x5a,0x00,0x00,0x10,
- 0x00,0x00,0x00,0x00,0x58,0x00,0xe0,0x14,0x00,0x00,0x00,0x00,
- 0xe8,0x00,0xab,0x8f,0x00,0x00,0x00,0x00,0x03,0x00,0x60,0x11,
- 0x00,0x00,0x00,0x00,0xad,0x2a,0x00,0x0c,0x00,0x00,0x00,0x00,
- 0xd8,0x00,0xa5,0x8f,0x29,0x2a,0x00,0x0c,0x34,0x93,0x84,0x27,
- 0x4d,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x4b,0x00,0xe0,0x14,
- 0x00,0x00,0x00,0x00,0xe8,0x00,0xaa,0x8f,0x00,0x00,0x00,0x00,
- 0x03,0x00,0x40,0x11,0x00,0x00,0x00,0x00,0xad,0x2a,0x00,0x0c,
- 0x00,0x00,0x00,0x00,0xd8,0x00,0xa5,0x8f,0x50,0x93,0x84,0x27,
- 0x29,0x2a,0x00,0x0c,0x21,0x30,0x60,0x02,0x3f,0x00,0x00,0x10,
- 0x00,0x00,0x00,0x00,0x04,0x00,0x43,0x14,0x09,0x00,0x41,0x28,
- 0x2d,0xf9,0x00,0x10,0x02,0x00,0x10,0x24,0x09,0x00,0x41,0x28,
- 0x23,0x00,0x20,0x10,0x04,0x00,0x01,0x24,0x1b,0xf8,0x41,0x10,
- 0x05,0x00,0x41,0x28,0x10,0x00,0x20,0x10,0x06,0x00,0x01,0x24,
- 0x02,0x00,0x10,0x24,0x23,0xf9,0x50,0x10,0x03,0x00,0x41,0x28,
- 0x05,0x00,0x20,0x10,0x01,0x00,0x01,0x24,0x20,0xf9,0x41,0x10,
- 0xe8,0x00,0xad,0x8f,0xdf,0xff,0x00,0x10,0x00,0x00,0x00,0x00,
- 0x03,0x00,0x01,0x24,0x1b,0xf9,0x41,0x10,0xe8,0x00,0xad,0x8f,
- 0xda,0xff,0x00,0x10,0x00,0x00,0x00,0x00,0x06,0x00,0x01,0x24,
- 0x04,0x00,0x41,0x14,0x07,0x00,0x41,0x28,0x13,0xf9,0x00,0x10,
- 0x02,0x00,0x10,0x24,0x07,0x00,0x41,0x28,0x05,0x00,0x20,0x10,
- 0x05,0x00,0x01,0x24,0xd0,0xff,0x41,0x14,0x00,0x00,0x00,0x00,
- 0x0c,0xf9,0x00,0x10,0x02,0x00,0x10,0x24,0xcc,0xff,0x44,0x14,
- 0x00,0x00,0x00,0x00,0x08,0xf9,0x00,0x10,0x02,0x00,0x10,0x24,
- 0x3f,0x00,0x01,0x24,0xba,0xff,0x41,0x10,0x40,0x00,0x41,0x28,
- 0x0c,0x00,0x20,0x10,0x0e,0x00,0x01,0x24,0x04,0x00,0x41,0x14,
- 0x0f,0x00,0x41,0x28,0xff,0xf8,0x00,0x10,0x02,0x00,0x10,0x24,
- 0x0f,0x00,0x41,0x28,0xbe,0xff,0x20,0x10,0x0c,0x00,0x01,0x24,
- 0xee,0xf7,0x41,0x10,0xdc,0x00,0xad,0x8f,0xba,0xff,0x00,0x10,
- 0x00,0x00,0x00,0x00,0x7f,0x00,0x01,0x24,0xb7,0xff,0x41,0x14,
- 0x00,0x00,0x00,0x00,0xf3,0xf8,0x00,0x10,0x02,0x00,0x10,0x24,
- 0xe1,0x21,0x00,0x0c,0x01,0x04,0x04,0x24,0x4c,0x00,0xbf,0x8f,
- 0xbc,0x00,0xa2,0x8f,0x3c,0x00,0xb0,0x8f,0x40,0x00,0xb3,0x8f,
- 0x44,0x00,0xb6,0x8f,0x48,0x00,0xb7,0x8f,0x08,0x00,0xe0,0x03,
- 0xd8,0x00,0xbd,0x27,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0xc8,0xff,0xbd,0x27,0x30,0x00,0xb6,0xaf,0x28,0x00,0xb4,0xaf,
- 0x2c,0x00,0xb5,0xaf,0x24,0x00,0xb3,0xaf,0x18,0x00,0xb0,0xaf,
- 0x1c,0x00,0xb1,0xaf,0x34,0x00,0xbf,0xaf,0x20,0x00,0xb2,0xaf,
- 0x04,0x00,0x11,0x24,0x00,0xa1,0x10,0x3c,0x90,0x93,0x93,0x27,
- 0x21,0xa8,0x00,0x00,0xcc,0x93,0x94,0x27,0x0f,0x00,0x16,0x24,
- 0x21,0x90,0x00,0x00,0xcc,0x97,0x80,0xaf,0x21,0x18,0x00,0x00,
- 0x21,0x10,0x60,0x02,0x00,0x00,0x4f,0x94,0x02,0x00,0x4e,0x94,
- 0x21,0xc0,0xf0,0x01,0x00,0x00,0x0e,0xa3,0xcc,0x97,0x80,0xaf,
- 0x04,0x00,0x48,0x94,0x06,0x00,0x59,0x94,0x21,0x48,0x10,0x01,
- 0x00,0x00,0x39,0xa1,0xcc,0x97,0x80,0xaf,0x08,0x00,0x4b,0x94,
- 0x0a,0x00,0x4a,0x94,0x21,0x60,0x70,0x01,0x00,0x00,0x8a,0xa1,
- 0xcc,0x97,0x80,0xaf,0x0c,0x00,0x4f,0x94,0x0e,0x00,0x4d,0x94,
- 0x04,0x00,0x42,0x24,0x04,0x00,0x42,0x24,0x21,0x70,0xf0,0x01,
- 0x04,0x00,0x42,0x24,0x04,0x00,0x63,0x24,0x00,0x00,0xcd,0xa1,
- 0xcc,0x97,0x80,0xaf,0xe7,0xff,0x71,0x14,0x04,0x00,0x42,0x24,
- 0x00,0x00,0x58,0x94,0x00,0x00,0x00,0x00,0x21,0x40,0x18,0x02,
- 0x00,0x00,0x19,0x91,0x00,0x00,0x00,0x00,0x40,0x00,0x29,0x33,
- 0x08,0x00,0x20,0x11,0x64,0x00,0x41,0x2a,0x04,0x00,0x20,0x14,
- 0x00,0x00,0x00,0x00,0x21,0x20,0x80,0x02,0x35,0x20,0x00,0x0c,
- 0x47,0x00,0x05,0x24,0xd5,0xff,0x00,0x10,0x01,0x00,0x52,0x26,
- 0x05,0x00,0xb5,0x26,0xd1,0xff,0xb6,0x16,0x14,0x00,0x73,0x26,
- 0x34,0x00,0xbf,0x8f,0x18,0x00,0xb0,0x8f,0x1c,0x00,0xb1,0x8f,
- 0x20,0x00,0xb2,0x8f,0x24,0x00,0xb3,0x8f,0x28,0x00,0xb4,0x8f,
- 0x2c,0x00,0xb5,0x8f,0x30,0x00,0xb6,0x8f,0x08,0x00,0xe0,0x03,
- 0x38,0x00,0xbd,0x27,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x42,0x54,0x34,0x30,0x42,0x54,0x34,0x31,
- 0x42,0x54,0x34,0x32,0x42,0x54,0x34,0x33,0x0a,0x0d,0x44,0x69,
- 0x67,0x69,0x42,0x6f,0x61,0x72,0x64,0x20,0x53,0x6d,0x61,0x72,
- 0x74,0x43,0x6f,0x6d,0x6d,0x20,0x42,0x49,0x4f,0x53,0x00,0x00,
- 0x0a,0x0d,0x52,0x41,0x4d,0x20,0x73,0x69,0x7a,0x65,0x3a,0x20,
- 0x25,0x30,0x38,0x78,0x00,0x00,0x00,0x00,0x0a,0x0d,0x43,0x50,
- 0x55,0x20,0x74,0x65,0x73,0x74,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,
- 0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x00,0x00,0x0a,0x0d,0x63,0x6f,
- 0x64,0x65,0x20,0x63,0x68,0x65,0x63,0x6b,0x73,0x75,0x6d,0x20,
- 0x74,0x65,0x73,0x74,0x2e,0x2e,0x00,0x00,0x25,0x45,0x20,0x62,
- 0x61,0x64,0x20,0x63,0x6f,0x64,0x65,0x20,0x63,0x68,0x65,0x63,
- 0x6b,0x73,0x75,0x6d,0x3a,0x20,0x25,0x30,0x38,0x78,0x00,0x00,
- 0x0d,0x0a,0x00,0x00,0x53,0x69,0x6d,0x70,0x6c,0x65,0x0a,0x0d,
- 0x00,0x00,0x00,0x00,0x48,0x69,0x67,0x68,0x0a,0x0d,0x00,0x00,
- 0x43,0x6f,0x6d,0x70,0x6c,0x65,0x78,0x0a,0x0d,0x00,0x00,0x00,
- 0x25,0x45,0x20,0x47,0x61,0x70,0x20,0x69,0x6e,0x20,0x45,0x42,
- 0x49,0x20,0x73,0x65,0x71,0x75,0x65,0x6e,0x63,0x65,0x0a,0x0d,
- 0x00,0x00,0x00,0x00,0x2e,0x2e,0x2f,0x73,0x6d,0x61,0x72,0x74,
- 0x62,0x69,0x6f,0x73,0x2e,0x63,0x00,0x00,0x2e,0x2e,0x2f,0x73,
- 0x6d,0x61,0x72,0x74,0x62,0x69,0x6f,0x73,0x2e,0x63,0x00,0x00,
- 0x90,0xde,0x00,0xa0,0x0d,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x50,0x61,0x73,0x73,0x20,0x25,0x64,0x20,
- 0x20,0x20,0x20,0x20,0x00,0x00,0x00,0x00,0x2d,0x2d,0x2d,0x20,
- 0x53,0x6d,0x61,0x72,0x74,0x43,0x6f,0x6d,0x6d,0x20,0x44,0x69,
- 0x61,0x67,0x6e,0x6f,0x73,0x74,0x69,0x63,0x73,0x20,0x2d,0x2d,
- 0x2d,0x0a,0x0d,0x00,0x41,0x20,0x3d,0x20,0x41,0x6c,0x6c,0x20,
- 0x74,0x65,0x73,0x74,0x73,0x0a,0x0d,0x00,0x45,0x20,0x3d,0x20,
- 0x41,0x6c,0x6c,0x20,0x45,0x42,0x49,0x20,0x74,0x65,0x73,0x74,
- 0x73,0x0a,0x0d,0x00,0x31,0x20,0x3d,0x20,0x54,0x69,0x6d,0x65,
- 0x72,0x20,0x74,0x65,0x73,0x74,0x0a,0x0d,0x00,0x00,0x00,0x00,
- 0x32,0x20,0x3d,0x20,0x52,0x41,0x4d,0x20,0x74,0x65,0x73,0x74,
- 0x0a,0x0d,0x00,0x00,0x33,0x20,0x3d,0x20,0x45,0x42,0x49,0x20,
- 0x69,0x6e,0x74,0x65,0x72,0x6e,0x61,0x6c,0x20,0x6c,0x6f,0x6f,
- 0x70,0x62,0x61,0x63,0x6b,0x20,0x74,0x65,0x73,0x74,0x0a,0x0d,
- 0x00,0x00,0x00,0x00,0x34,0x20,0x3d,0x20,0x45,0x42,0x49,0x20,
- 0x65,0x78,0x74,0x65,0x72,0x6e,0x61,0x6c,0x20,0x6c,0x6f,0x6f,
- 0x70,0x62,0x61,0x63,0x6b,0x20,0x74,0x65,0x73,0x74,0x0a,0x0d,
- 0x00,0x00,0x00,0x00,0x24,0x20,0x3d,0x20,0x45,0x42,0x49,0x20,
- 0x73,0x69,0x6e,0x67,0x6c,0x65,0x20,0x65,0x78,0x74,0x65,0x72,
- 0x6e,0x61,0x6c,0x20,0x70,0x6f,0x72,0x74,0x20,0x74,0x65,0x73,
- 0x74,0x0a,0x0d,0x00,0x35,0x20,0x3d,0x20,0x53,0x70,0x65,0x63,
- 0x69,0x61,0x6c,0x20,0x50,0x41,0x4c,0x20,0x74,0x65,0x73,0x74,
- 0x0a,0x0d,0x00,0x00,0x74,0x2f,0x5e,0x54,0x2f,0x54,0x20,0x3d,
- 0x20,0x48,0x6f,0x73,0x74,0x20,0x73,0x69,0x64,0x65,0x20,0x20,
- 0x38,0x2f,0x31,0x36,0x2f,0x33,0x32,0x2d,0x62,0x69,0x74,0x20,
- 0x52,0x41,0x4d,0x20,0x74,0x65,0x73,0x74,0x20,0x73,0x74,0x61,
- 0x72,0x74,0x2f,0x73,0x74,0x6f,0x70,0x0a,0x0d,0x00,0x00,0x00,
- 0x69,0x20,0x3d,0x20,0x63,0x61,0x72,0x64,0x2d,0x74,0x6f,0x2d,
- 0x68,0x6f,0x73,0x74,0x20,0x69,0x6e,0x74,0x65,0x72,0x72,0x75,
- 0x70,0x74,0x20,0x74,0x65,0x73,0x74,0x0a,0x0d,0x00,0x00,0x00,
- 0x64,0x5e,0x44,0x44,0x29,0x75,0x6d,0x70,0x2c,0x20,0x72,0x5e,
- 0x52,0x52,0x29,0x65,0x61,0x64,0x2c,0x20,0x77,0x5e,0x57,0x57,
- 0x29,0x72,0x69,0x74,0x65,0x2c,0x20,0x66,0x5e,0x46,0x46,0x29,
- 0x69,0x6c,0x6c,0x20,0x52,0x41,0x4d,0x0a,0x0d,0x00,0x00,0x00,
- 0x0d,0x0a,0x4e,0x75,0x6d,0x62,0x65,0x72,0x20,0x6f,0x66,0x20,
- 0x74,0x69,0x6d,0x65,0x73,0x20,0x74,0x6f,0x20,0x64,0x6f,0x20,
- 0x61,0x6c,0x6c,0x20,0x74,0x65,0x73,0x74,0x73,0x3a,0x20,0x00,
- 0x0a,0x00,0x00,0x00,0x0a,0x0d,0x20,0x20,0x54,0x65,0x73,0x74,
- 0x73,0x20,0x73,0x74,0x6f,0x70,0x70,0x65,0x64,0x0a,0x0d,0x00,
- 0x54,0x6f,0x74,0x61,0x6c,0x20,0x70,0x61,0x73,0x73,0x65,0x73,
- 0x3a,0x20,0x25,0x64,0x0a,0x0d,0x00,0x00,0x20,0x20,0x54,0x65,
- 0x73,0x74,0x20,0x25,0x64,0x3a,0x20,0x25,0x64,0x20,0x70,0x61,
- 0x73,0x73,0x20,0x25,0x64,0x20,0x66,0x61,0x69,0x6c,0x75,0x72,
- 0x65,0x73,0x0a,0x0d,0x00,0x00,0x00,0x00,0x20,0x20,0x28,0x70,
- 0x72,0x65,0x73,0x73,0x20,0x61,0x6e,0x79,0x20,0x6b,0x65,0x79,
- 0x20,0x74,0x6f,0x20,0x73,0x74,0x6f,0x70,0x29,0x0a,0x00,0x00,
- 0x0a,0x0d,0x20,0x20,0x54,0x69,0x6d,0x65,0x72,0x20,0x74,0x65,
- 0x73,0x74,0x20,0x73,0x74,0x6f,0x70,0x70,0x65,0x64,0x0a,0x0d,
- 0x00,0x00,0x00,0x00,0x54,0x6f,0x74,0x61,0x6c,0x20,0x70,0x61,
- 0x73,0x73,0x65,0x73,0x3a,0x20,0x25,0x64,0x0a,0x0d,0x00,0x00,
- 0x20,0x20,0x54,0x65,0x73,0x74,0x20,0x31,0x3a,0x20,0x25,0x64,
- 0x20,0x70,0x61,0x73,0x73,0x20,0x25,0x64,0x20,0x66,0x61,0x69,
- 0x6c,0x75,0x72,0x65,0x73,0x0a,0x0d,0x00,0x53,0x74,0x61,0x72,
- 0x74,0x20,0x41,0x64,0x64,0x72,0x65,0x73,0x73,0x3a,0x20,0x00,
- 0x0a,0x0d,0x45,0x6e,0x64,0x20,0x41,0x64,0x64,0x72,0x65,0x73,
- 0x73,0x3a,0x20,0x00,0x0a,0x0d,0x00,0x00,0x20,0x20,0x28,0x70,
- 0x72,0x65,0x73,0x73,0x20,0x61,0x6e,0x79,0x20,0x6b,0x65,0x79,
- 0x20,0x74,0x6f,0x20,0x73,0x74,0x6f,0x70,0x29,0x0a,0x00,0x00,
- 0x0a,0x0d,0x20,0x20,0x52,0x41,0x4d,0x20,0x74,0x65,0x73,0x74,
- 0x20,0x73,0x74,0x6f,0x70,0x70,0x65,0x64,0x0a,0x0d,0x00,0x00,
- 0x54,0x6f,0x74,0x61,0x6c,0x20,0x70,0x61,0x73,0x73,0x65,0x73,
- 0x3a,0x20,0x25,0x64,0x0a,0x0d,0x00,0x00,0x20,0x20,0x54,0x65,
- 0x73,0x74,0x20,0x32,0x3a,0x20,0x25,0x64,0x20,0x70,0x61,0x73,
- 0x73,0x20,0x25,0x64,0x20,0x66,0x61,0x69,0x6c,0x75,0x72,0x65,
- 0x73,0x0a,0x0d,0x00,0x20,0x20,0x45,0x42,0x49,0x20,0x73,0x69,
- 0x6e,0x67,0x6c,0x65,0x20,0x65,0x78,0x74,0x65,0x72,0x6e,0x61,
- 0x6c,0x20,0x6c,0x6f,0x6f,0x70,0x62,0x61,0x63,0x6b,0x20,0x74,
- 0x65,0x73,0x74,0x0a,0x0d,0x00,0x00,0x00,0x20,0x20,0x45,0x6e,
- 0x74,0x65,0x72,0x20,0x45,0x42,0x49,0x20,0x6e,0x75,0x6d,0x62,
- 0x65,0x72,0x20,0x74,0x6f,0x20,0x74,0x65,0x73,0x74,0x20,0x28,
- 0x30,0x2d,0x33,0x29,0x20,0x00,0x00,0x00,0x0a,0x0d,0x00,0x00,
- 0x20,0x20,0x45,0x6e,0x74,0x65,0x72,0x20,0x70,0x6f,0x72,0x74,
- 0x20,0x74,0x6f,0x20,0x74,0x65,0x73,0x74,0x20,0x28,0x31,0x2d,
- 0x31,0x36,0x29,0x20,0x00,0x00,0x00,0x00,0x0a,0x0d,0x20,0x20,
- 0x28,0x70,0x72,0x65,0x73,0x73,0x20,0x61,0x6e,0x79,0x20,0x6b,
- 0x65,0x79,0x20,0x74,0x6f,0x20,0x73,0x74,0x6f,0x70,0x29,0x0a,
- 0x00,0x00,0x00,0x00,0x0a,0x0d,0x20,0x20,0x45,0x42,0x49,0x20,
- 0x74,0x65,0x73,0x74,0x20,0x73,0x74,0x6f,0x70,0x70,0x65,0x64,
- 0x0a,0x0d,0x00,0x00,0x54,0x6f,0x74,0x61,0x6c,0x20,0x70,0x61,
- 0x73,0x73,0x65,0x73,0x3a,0x20,0x25,0x64,0x0a,0x0d,0x00,0x00,
- 0x20,0x20,0x54,0x65,0x73,0x74,0x20,0x25,0x63,0x3a,0x20,0x25,
- 0x64,0x20,0x70,0x61,0x73,0x73,0x20,0x25,0x64,0x20,0x66,0x61,
- 0x69,0x6c,0x75,0x72,0x65,0x73,0x0a,0x0d,0x00,0x00,0x00,0x00,
- 0x20,0x20,0x45,0x42,0x49,0x20,0x00,0x00,0x65,0x78,0x00,0x00,
- 0x69,0x6e,0x00,0x00,0x74,0x65,0x72,0x6e,0x61,0x6c,0x20,0x6c,
- 0x6f,0x6f,0x70,0x62,0x61,0x63,0x6b,0x20,0x74,0x65,0x73,0x74,
- 0x0a,0x0d,0x00,0x00,0x20,0x20,0x45,0x6e,0x74,0x65,0x72,0x20,
- 0x45,0x42,0x49,0x20,0x6e,0x75,0x6d,0x62,0x65,0x72,0x20,0x74,
- 0x6f,0x20,0x74,0x65,0x73,0x74,0x20,0x28,0x30,0x2d,0x33,0x29,
- 0x20,0x6f,0x72,0x20,0x27,0x41,0x27,0x20,0x66,0x6f,0x72,0x20,
- 0x61,0x6c,0x6c,0x0a,0x0d,0x00,0x00,0x00,0x20,0x20,0x28,0x70,
- 0x72,0x65,0x73,0x73,0x20,0x61,0x6e,0x79,0x20,0x6b,0x65,0x79,
- 0x20,0x74,0x6f,0x20,0x73,0x74,0x6f,0x70,0x29,0x0a,0x00,0x00,
- 0x0a,0x0d,0x20,0x20,0x45,0x42,0x49,0x20,0x74,0x65,0x73,0x74,
- 0x20,0x73,0x74,0x6f,0x70,0x70,0x65,0x64,0x0a,0x0d,0x00,0x00,
- 0x54,0x6f,0x74,0x61,0x6c,0x20,0x70,0x61,0x73,0x73,0x65,0x73,
- 0x3a,0x20,0x25,0x64,0x0a,0x0d,0x00,0x00,0x20,0x20,0x54,0x65,
- 0x73,0x74,0x20,0x25,0x63,0x3a,0x20,0x25,0x64,0x20,0x70,0x61,
- 0x73,0x73,0x20,0x25,0x64,0x20,0x66,0x61,0x69,0x6c,0x75,0x72,
- 0x65,0x73,0x0a,0x0d,0x00,0x00,0x00,0x00,0x20,0x20,0x28,0x70,
- 0x72,0x65,0x73,0x73,0x20,0x61,0x6e,0x79,0x20,0x6b,0x65,0x79,
- 0x20,0x74,0x6f,0x20,0x73,0x74,0x6f,0x70,0x29,0x0a,0x00,0x00,
- 0x0d,0x50,0x41,0x4c,0x20,0x74,0x65,0x73,0x74,0x2e,0x2e,0x2e,
- 0x2e,0x2e,0x00,0x00,0x0a,0x0d,0x46,0x41,0x49,0x4c,0x45,0x44,
- 0x20,0x2d,0x20,0x74,0x65,0x6c,0x6c,0x20,0x54,0x4a,0x20,0x43,
- 0x61,0x72,0x74,0x65,0x72,0x20,0x61,0x74,0x20,0x39,0x34,0x33,
- 0x2d,0x35,0x33,0x36,0x31,0x0a,0x0d,0x00,0x0a,0x0d,0x20,0x20,
- 0x50,0x41,0x4c,0x20,0x74,0x65,0x73,0x74,0x20,0x73,0x74,0x6f,
- 0x70,0x70,0x65,0x64,0x0a,0x0d,0x00,0x00,0x54,0x6f,0x74,0x61,
- 0x6c,0x20,0x70,0x61,0x73,0x73,0x65,0x73,0x3a,0x20,0x25,0x64,
- 0x0a,0x0d,0x00,0x00,0x20,0x20,0x54,0x65,0x73,0x74,0x20,0x35,
- 0x3a,0x20,0x25,0x64,0x20,0x70,0x61,0x73,0x73,0x20,0x25,0x64,
- 0x20,0x66,0x61,0x69,0x6c,0x75,0x72,0x65,0x73,0x0a,0x0d,0x00,
- 0x43,0x61,0x72,0x64,0x2d,0x74,0x6f,0x2d,0x68,0x6f,0x73,0x74,
- 0x20,0x69,0x6e,0x74,0x65,0x72,0x72,0x75,0x70,0x74,0x20,0x74,
- 0x65,0x73,0x74,0x2e,0x2e,0x2e,0x00,0x00,0x48,0x65,0x78,0x20,
- 0x41,0x64,0x64,0x72,0x65,0x73,0x73,0x3a,0x20,0x00,0x00,0x00,
- 0x0a,0x0d,0x00,0x00,0x25,0x30,0x38,0x78,0x3a,0x20,0x00,0x00,
- 0x0a,0x0d,0x00,0x00,0x25,0x30,0x32,0x78,0x0a,0x0d,0x00,0x00,
- 0x25,0x30,0x34,0x78,0x0a,0x0d,0x00,0x00,0x25,0x30,0x38,0x78,
- 0x0a,0x0d,0x00,0x00,0x38,0x00,0x00,0x00,0x31,0x36,0x00,0x00,
- 0x33,0x32,0x00,0x00,0x2d,0x62,0x69,0x74,0x20,0x48,0x65,0x78,
- 0x20,0x56,0x61,0x6c,0x75,0x65,0x3a,0x20,0x00,0x00,0x00,0x00,
- 0x0a,0x0d,0x00,0x00,0x48,0x65,0x78,0x20,0x4c,0x65,0x6e,0x67,
- 0x74,0x68,0x3a,0x20,0x00,0x00,0x00,0x00,0x0a,0x0d,0x00,0x00,
- 0x50,0x72,0x65,0x73,0x73,0x20,0x27,0x3f,0x27,0x20,0x66,0x6f,
- 0x72,0x20,0x64,0x69,0x61,0x67,0x6e,0x6f,0x73,0x74,0x69,0x63,
- 0x73,0x20,0x6d,0x65,0x6e,0x75,0x0a,0x0d,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0xe8,0x03,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x41,0x42,
- 0x43,0x44,0x45,0x46,0x00,0x00,0x00,0x00,0x0a,0x0d,0x45,0x52,
- 0x52,0x4f,0x52,0x20,0x2d,0x00,0x00,0x00,0x30,0x78,0x00,0x00,
- 0x70,0x61,0x73,0x73,0x65,0x64,0x00,0x00,0x25,0x30,0x32,0x58,
- 0x20,0x00,0x00,0x00,0x0d,0x54,0x69,0x6d,0x65,0x72,0x20,0x74,
- 0x65,0x73,0x74,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,
- 0x2e,0x00,0x00,0x00,0x25,0x45,0x20,0x63,0x61,0x6e,0x27,0x74,
- 0x20,0x73,0x65,0x74,0x20,0x75,0x70,0x20,0x74,0x69,0x6d,0x65,
- 0x72,0x20,0x30,0x0a,0x0d,0x00,0x00,0x00,0x25,0x45,0x20,0x63,
- 0x61,0x6e,0x27,0x74,0x20,0x73,0x65,0x74,0x20,0x75,0x70,0x20,
- 0x74,0x69,0x6d,0x65,0x72,0x20,0x32,0x0a,0x0d,0x00,0x00,0x00,
- 0x25,0x45,0x20,0x74,0x69,0x6d,0x65,0x72,0x20,0x32,0x20,0x62,
- 0x61,0x64,0x20,0x63,0x6f,0x75,0x6e,0x74,0x0a,0x0d,0x00,0x00,
- 0x25,0x45,0x20,0x74,0x69,0x6d,0x65,0x72,0x20,0x30,0x20,0x49,
- 0x4e,0x54,0x20,0x73,0x74,0x75,0x63,0x6b,0x20,0x6f,0x6e,0x0a,
- 0x0d,0x00,0x00,0x00,0x25,0x45,0x20,0x74,0x69,0x6d,0x65,0x72,
- 0x20,0x30,0x20,0x64,0x6f,0x65,0x73,0x20,0x6e,0x6f,0x74,0x20,
- 0x69,0x6e,0x74,0x65,0x72,0x72,0x75,0x70,0x74,0x0a,0x0d,0x00,
- 0x25,0x45,0x20,0x63,0x61,0x6e,0x27,0x74,0x20,0x73,0x65,0x74,
- 0x20,0x75,0x70,0x20,0x74,0x69,0x6d,0x65,0x72,0x20,0x30,0x0a,
- 0x0d,0x00,0x00,0x00,0x25,0x45,0x20,0x74,0x69,0x6d,0x65,0x72,
- 0x20,0x30,0x20,0x49,0x4e,0x54,0x20,0x77,0x6f,0x6e,0x27,0x74,
- 0x20,0x67,0x6f,0x20,0x61,0x77,0x61,0x79,0x0a,0x0d,0x00,0x00,
- 0x25,0x45,0x20,0x63,0x61,0x6e,0x27,0x74,0x20,0x73,0x65,0x74,
- 0x20,0x75,0x70,0x20,0x74,0x69,0x6d,0x65,0x72,0x20,0x30,0x0a,
- 0x0d,0x00,0x00,0x00,0x25,0x45,0x20,0x63,0x61,0x6e,0x27,0x74,
- 0x20,0x73,0x65,0x74,0x20,0x75,0x70,0x20,0x74,0x69,0x6d,0x65,
- 0x72,0x20,0x32,0x0a,0x0d,0x00,0x00,0x00,0x24,0xe6,0x00,0xa0,
- 0x25,0x45,0x20,0x54,0x25,0x64,0x20,0x77,0x72,0x6f,0x74,0x65,
- 0x20,0x25,0x30,0x38,0x78,0x20,0x72,0x65,0x61,0x64,0x20,0x25,
- 0x30,0x38,0x78,0x20,0x61,0x74,0x20,0x25,0x30,0x38,0x78,0x0a,
- 0x0d,0x00,0x00,0x00,0x0d,0x52,0x41,0x4d,0x20,0x74,0x65,0x73,
- 0x74,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,
- 0x2e,0x25,0x30,0x38,0x78,0x2d,0x25,0x30,0x38,0x78,0x20,0x00,
- 0x00,0x10,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x40,0x00,0x00,
- 0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x01,0x02,
- 0x04,0x08,0x10,0x20,0x40,0x80,0x7f,0xbf,0xdf,0xef,0xf7,0xfb,
- 0xfd,0xfe,0x55,0xaa,0xf0,0x0f,0x00,0x00,0x0d,0x54,0x65,0x73,
- 0x74,0x20,0x45,0x42,0x49,0x20,0x25,0x64,0x20,0x50,0x41,0x52,
- 0x41,0x2d,0x25,0x30,0x32,0x58,0x2e,0x2e,0x00,0x00,0x00,0x00,
- 0x25,0x45,0x20,0x45,0x42,0x49,0x20,0x25,0x64,0x20,0x70,0x61,
- 0x72,0x61,0x6c,0x6c,0x65,0x6c,0x20,0x70,0x6f,0x72,0x74,0x20,
- 0x54,0x50,0x52,0x20,0x77,0x72,0x6f,0x74,0x65,0x20,0x30,0x78,
- 0x30,0x30,0x20,0x30,0x78,0x46,0x46,0x20,0x72,0x65,0x61,0x64,
- 0x20,0x25,0x30,0x32,0x78,0x20,0x25,0x30,0x32,0x78,0x0a,0x00,
- 0x25,0x45,0x20,0x45,0x42,0x49,0x20,0x25,0x64,0x20,0x70,0x61,
- 0x72,0x61,0x6c,0x6c,0x65,0x6c,0x20,0x70,0x6f,0x72,0x74,0x20,
- 0x73,0x65,0x6e,0x64,0x20,0x25,0x30,0x32,0x78,0x20,0x72,0x65,
- 0x63,0x65,0x69,0x76,0x65,0x64,0x20,0x25,0x30,0x32,0x78,0x0a,
- 0x00,0x00,0x00,0x00,0x25,0x45,0x20,0x45,0x42,0x49,0x20,0x25,
- 0x64,0x20,0x70,0x61,0x72,0x61,0x6c,0x6c,0x65,0x6c,0x20,0x70,
- 0x6f,0x72,0x74,0x20,0x69,0x6e,0x74,0x65,0x72,0x72,0x75,0x70,
- 0x74,0x20,0x73,0x74,0x75,0x63,0x6b,0x20,0x6f,0x6e,0x0a,0x00,
- 0x25,0x45,0x20,0x45,0x42,0x49,0x20,0x25,0x64,0x20,0x70,0x61,
- 0x72,0x61,0x6c,0x6c,0x65,0x6c,0x20,0x70,0x6f,0x72,0x74,0x20,
- 0x69,0x6e,0x74,0x65,0x72,0x72,0x75,0x70,0x74,0x20,0x6d,0x61,
- 0x73,0x6b,0x20,0x6f,0x6e,0x20,0x77,0x2f,0x6f,0x20,0x69,0x6e,
- 0x74,0x65,0x72,0x72,0x75,0x70,0x74,0x0a,0x00,0x00,0x00,0x00,
- 0x25,0x45,0x20,0x45,0x42,0x49,0x20,0x25,0x64,0x20,0x70,0x61,
- 0x72,0x61,0x6c,0x6c,0x65,0x6c,0x20,0x70,0x6f,0x72,0x74,0x20,
- 0x69,0x6e,0x74,0x65,0x72,0x72,0x75,0x70,0x74,0x20,0x6d,0x61,
- 0x73,0x6b,0x20,0x64,0x6f,0x65,0x73,0x20,0x6e,0x6f,0x74,0x20,
- 0x73,0x65,0x74,0x20,0x62,0x69,0x74,0x0a,0x00,0x00,0x00,0x00,
- 0x25,0x45,0x20,0x45,0x42,0x49,0x20,0x25,0x64,0x20,0x70,0x61,
- 0x72,0x61,0x6c,0x6c,0x65,0x6c,0x20,0x70,0x6f,0x72,0x74,0x20,
- 0x69,0x6e,0x74,0x65,0x72,0x72,0x75,0x70,0x74,0x20,0x64,0x6f,
- 0x65,0x73,0x20,0x6e,0x6f,0x74,0x20,0x77,0x6f,0x72,0x6b,0x0a,
- 0x00,0x00,0x00,0x00,0x25,0x45,0x20,0x45,0x42,0x49,0x20,0x25,
- 0x64,0x20,0x70,0x61,0x72,0x61,0x6c,0x6c,0x65,0x6c,0x20,0x70,
- 0x6f,0x72,0x74,0x20,0x69,0x6e,0x74,0x65,0x72,0x72,0x75,0x70,
- 0x74,0x20,0x77,0x6f,0x6e,0x27,0x74,0x20,0x67,0x6f,0x20,0x61,
- 0x77,0x61,0x79,0x0a,0x00,0x00,0x00,0x00,0x25,0x45,0x20,0x45,
- 0x42,0x49,0x20,0x25,0x64,0x20,0x70,0x61,0x72,0x61,0x6c,0x6c,
- 0x65,0x6c,0x20,0x70,0x6f,0x72,0x74,0x20,0x69,0x6e,0x74,0x65,
- 0x72,0x72,0x75,0x70,0x74,0x20,0x6d,0x61,0x73,0x6b,0x20,0x64,
- 0x6f,0x65,0x73,0x20,0x6e,0x6f,0x74,0x20,0x72,0x65,0x73,0x65,
- 0x74,0x20,0x62,0x69,0x74,0x0a,0x00,0x00,0x25,0x45,0x20,0x45,
- 0x42,0x49,0x20,0x25,0x64,0x20,0x70,0x61,0x72,0x61,0x6c,0x6c,
- 0x65,0x6c,0x20,0x70,0x6f,0x72,0x74,0x20,0x54,0x50,0x52,0x20,
- 0x6e,0x6f,0x74,0x20,0x66,0x6f,0x75,0x6e,0x64,0x0a,0x00,0x00,
- 0x0d,0x45,0x42,0x49,0x20,0x25,0x64,0x20,0x65,0x78,0x74,0x2e,
- 0x20,0x6c,0x6f,0x6f,0x70,0x62,0x61,0x63,0x6b,0x3a,0x20,0x00,
- 0x0d,0x54,0x65,0x73,0x74,0x20,0x45,0x42,0x49,0x20,0x25,0x64,
- 0x20,0x55,0x41,0x52,0x54,0x2d,0x25,0x30,0x32,0x58,0x2e,0x2e,
- 0x00,0x00,0x00,0x00,0x25,0x45,0x20,0x45,0x42,0x49,0x20,0x25,
- 0x64,0x20,0x70,0x6f,0x72,0x74,0x20,0x25,0x64,0x20,0x73,0x63,
- 0x72,0x61,0x74,0x63,0x68,0x20,0x72,0x65,0x67,0x69,0x73,0x74,
- 0x65,0x72,0x20,0x77,0x72,0x6f,0x74,0x65,0x20,0x30,0x78,0x30,
- 0x30,0x20,0x30,0x78,0x46,0x46,0x20,0x72,0x65,0x61,0x64,0x20,
- 0x25,0x30,0x32,0x78,0x20,0x25,0x30,0x32,0x78,0x0a,0x00,0x00,
- 0x25,0x45,0x20,0x45,0x42,0x49,0x20,0x25,0x64,0x20,0x70,0x6f,
- 0x72,0x74,0x20,0x25,0x64,0x20,0x27,0x64,0x61,0x74,0x61,0x20,
- 0x72,0x65,0x61,0x64,0x79,0x20,0x73,0x74,0x75,0x63,0x6b,0x20,
- 0x6f,0x6e,0x0a,0x00,0x25,0x45,0x20,0x45,0x42,0x49,0x20,0x25,
- 0x64,0x20,0x70,0x6f,0x72,0x74,0x20,0x25,0x64,0x20,0x54,0x48,
- 0x52,0x45,0x20,0x6e,0x65,0x76,0x65,0x72,0x20,0x72,0x65,0x61,
- 0x64,0x79,0x0a,0x00,0x25,0x45,0x20,0x45,0x42,0x49,0x20,0x25,
- 0x64,0x20,0x70,0x6f,0x72,0x74,0x20,0x25,0x64,0x20,0x6e,0x6f,
- 0x6e,0x65,0x6d,0x70,0x74,0x79,0x20,0x74,0x72,0x61,0x6e,0x73,
- 0x6d,0x69,0x74,0x74,0x65,0x72,0x20,0x6c,0x6f,0x6f,0x6b,0x73,
- 0x20,0x65,0x6d,0x70,0x74,0x79,0x0a,0x00,0x25,0x45,0x20,0x45,
- 0x42,0x49,0x20,0x25,0x64,0x20,0x70,0x6f,0x72,0x74,0x20,0x25,
- 0x64,0x20,0x64,0x61,0x74,0x61,0x20,0x6e,0x65,0x76,0x65,0x72,
- 0x20,0x61,0x72,0x72,0x69,0x76,0x65,0x64,0x0a,0x00,0x00,0x00,
- 0x25,0x45,0x20,0x45,0x42,0x49,0x20,0x25,0x64,0x20,0x70,0x6f,
- 0x72,0x74,0x20,0x25,0x64,0x00,0x00,0x00,0x20,0x6f,0x76,0x65,
- 0x72,0x72,0x75,0x6e,0x20,0x65,0x72,0x72,0x6f,0x72,0x00,0x00,
- 0x20,0x70,0x61,0x72,0x69,0x74,0x79,0x20,0x65,0x72,0x72,0x6f,
- 0x72,0x00,0x00,0x00,0x20,0x66,0x72,0x61,0x6d,0x69,0x6e,0x67,
- 0x20,0x65,0x72,0x72,0x6f,0x72,0x00,0x00,0x0a,0x00,0x00,0x00,
- 0x25,0x45,0x20,0x45,0x42,0x49,0x20,0x25,0x64,0x20,0x70,0x6f,
- 0x72,0x74,0x20,0x25,0x64,0x20,0x27,0x64,0x61,0x74,0x61,0x20,
- 0x72,0x65,0x61,0x64,0x79,0x27,0x20,0x6e,0x6f,0x74,0x20,0x73,
- 0x65,0x74,0x0a,0x00,0x25,0x45,0x20,0x45,0x42,0x49,0x20,0x25,
- 0x64,0x20,0x70,0x6f,0x72,0x74,0x20,0x25,0x64,0x20,0x27,0x64,
- 0x61,0x74,0x61,0x20,0x72,0x65,0x61,0x64,0x79,0x27,0x20,0x73,
- 0x74,0x69,0x6c,0x6c,0x20,0x73,0x65,0x74,0x0a,0x00,0x00,0x00,
- 0x25,0x45,0x20,0x45,0x42,0x49,0x20,0x25,0x64,0x20,0x70,0x6f,
- 0x72,0x74,0x20,0x25,0x64,0x20,0x73,0x65,0x6e,0x64,0x20,0x25,
- 0x30,0x32,0x78,0x20,0x72,0x65,0x63,0x65,0x69,0x76,0x65,0x64,
- 0x20,0x25,0x30,0x32,0x78,0x0a,0x00,0x00,0x25,0x45,0x20,0x45,
- 0x42,0x49,0x20,0x25,0x64,0x20,0x70,0x6f,0x72,0x74,0x20,0x25,
- 0x64,0x20,0x6d,0x6f,0x64,0x65,0x6d,0x20,0x73,0x74,0x61,0x74,
- 0x75,0x73,0x20,0x6f,0x75,0x74,0x20,0x25,0x30,0x32,0x78,0x20,
- 0x69,0x6e,0x20,0x25,0x30,0x32,0x78,0x0a,0x0d,0x00,0x00,0x00,
- 0x20,0x43,0x54,0x53,0x2f,0x52,0x54,0x53,0x00,0x00,0x00,0x00,
- 0x20,0x44,0x53,0x52,0x2f,0x44,0x54,0x52,0x00,0x00,0x00,0x00,
- 0x20,0x52,0x49,0x2f,0x4f,0x55,0x54,0x31,0x00,0x00,0x00,0x00,
- 0x20,0x44,0x43,0x44,0x2f,0x4f,0x55,0x54,0x32,0x00,0x00,0x00,
- 0x0a,0x00,0x00,0x00,0x25,0x45,0x20,0x45,0x42,0x49,0x20,0x25,
- 0x64,0x20,0x70,0x6f,0x72,0x74,0x20,0x25,0x64,0x20,0x49,0x4e,
- 0x54,0x20,0x73,0x74,0x75,0x63,0x6b,0x20,0x6f,0x6e,0x0a,0x00,
- 0x25,0x45,0x20,0x45,0x42,0x49,0x20,0x25,0x64,0x20,0x70,0x6f,
- 0x72,0x74,0x20,0x25,0x64,0x20,0x49,0x4e,0x54,0x20,0x6d,0x61,
- 0x73,0x6b,0x20,0x6f,0x6e,0x20,0x77,0x2f,0x6f,0x20,0x69,0x6e,
- 0x74,0x65,0x72,0x72,0x75,0x70,0x74,0x0a,0x00,0x00,0x00,0x00,
- 0x25,0x45,0x20,0x45,0x42,0x49,0x20,0x25,0x64,0x20,0x70,0x6f,
- 0x72,0x74,0x20,0x25,0x64,0x20,0x49,0x4e,0x54,0x20,0x6d,0x61,
- 0x73,0x6b,0x20,0x64,0x6f,0x65,0x73,0x20,0x6e,0x6f,0x74,0x20,
- 0x73,0x65,0x74,0x20,0x62,0x69,0x74,0x0a,0x00,0x00,0x00,0x00,
- 0x25,0x45,0x20,0x45,0x42,0x49,0x20,0x25,0x64,0x20,0x70,0x6f,
- 0x72,0x74,0x20,0x25,0x64,0x20,0x49,0x4e,0x54,0x20,0x64,0x6f,
- 0x65,0x73,0x20,0x6e,0x6f,0x74,0x20,0x77,0x6f,0x72,0x6b,0x0a,
- 0x00,0x00,0x00,0x00,0x25,0x45,0x20,0x45,0x42,0x49,0x20,0x25,
- 0x64,0x20,0x70,0x6f,0x72,0x74,0x20,0x25,0x64,0x20,0x49,0x4e,
- 0x54,0x20,0x77,0x6f,0x6e,0x27,0x74,0x20,0x67,0x6f,0x20,0x61,
- 0x77,0x61,0x79,0x0a,0x00,0x00,0x00,0x00,0x25,0x45,0x20,0x45,
- 0x42,0x49,0x20,0x25,0x64,0x20,0x70,0x6f,0x72,0x74,0x20,0x25,
- 0x64,0x20,0x49,0x4e,0x54,0x20,0x6d,0x61,0x73,0x6b,0x20,0x64,
- 0x6f,0x65,0x73,0x20,0x6e,0x6f,0x74,0x20,0x72,0x65,0x73,0x65,
- 0x74,0x20,0x62,0x69,0x74,0x0a,0x00,0x00,0x25,0x45,0x20,0x45,
- 0x42,0x49,0x20,0x25,0x64,0x20,0x68,0x61,0x73,0x20,0x25,0x64,
- 0x20,0x70,0x6f,0x72,0x74,0x73,0x2c,0x20,0x73,0x68,0x6f,0x75,
- 0x6c,0x64,0x20,0x62,0x65,0x20,0x25,0x64,0x73,0x20,0x25,0x64,
- 0x70,0x0a,0x00,0x00,0x25,0x64,0x20,0x64,0x65,0x76,0x69,0x63,
- 0x65,0x73,0x20,0x00,0x6e,0x6f,0x74,0x20,0x70,0x6f,0x70,0x75,
- 0x6c,0x61,0x74,0x65,0x64,0x00,0x00,0x00,0x25,0x45,0x20,0x6c,
- 0x6f,0x6f,0x70,0x62,0x61,0x63,0x6b,0x20,0x70,0x6f,0x72,0x74,
- 0x20,0x6d,0x69,0x73,0x6d,0x61,0x74,0x63,0x68,0x3a,0x20,0x70,
- 0x6f,0x72,0x74,0x20,0x25,0x64,0x3d,0x25,0x64,0x2c,0x20,0x61,
- 0x6e,0x64,0x20,0x70,0x6f,0x72,0x74,0x20,0x25,0x64,0x3d,0x25,
- 0x64,0x0a,0x00,0x00,0x25,0x45,0x20,0x6c,0x6f,0x6f,0x70,0x62,
- 0x61,0x63,0x6b,0x20,0x70,0x6f,0x72,0x74,0x20,0x6d,0x69,0x73,
- 0x6d,0x61,0x74,0x63,0x68,0x3a,0x20,0x70,0x6f,0x72,0x74,0x20,
- 0x25,0x64,0x3d,0x25,0x64,0x3f,0x0a,0x00,0x25,0x64,0x00,0x00,
- 0x3d,0x25,0x64,0x00,0x3f,0x20,0x00,0x00,0x50,0x25,0x64,0x3d,
- 0x50,0x25,0x64,0x20,0x00,0x00,0x00,0x00,0x25,0x64,0x3d,0x64,
- 0x65,0x62,0x75,0x67,0x00,0x00,0x00,0x00,0x25,0x45,0x20,0x4e,
- 0x6f,0x20,0x65,0x78,0x74,0x65,0x72,0x6e,0x61,0x6c,0x20,0x63,
- 0x6f,0x6e,0x6e,0x65,0x63,0x74,0x69,0x6f,0x6e,0x73,0x20,0x66,
- 0x6f,0x75,0x6e,0x64,0x00,0x00,0x00,0x00,0x0a,0x0d,0x00,0x00,
- 0x57,0x41,0x52,0x4e,0x49,0x4e,0x47,0x20,0x2d,0x20,0x4e,0x6f,
- 0x74,0x20,0x61,0x6c,0x6c,0x20,0x55,0x41,0x52,0x54,0x53,0x20,
- 0x64,0x65,0x74,0x65,0x63,0x74,0x65,0x64,0x20,0x69,0x6e,0x20,
- 0x6c,0x6f,0x6f,0x70,0x62,0x61,0x63,0x6b,0x0a,0x0d,0x00,0x00,
- 0x57,0x41,0x52,0x4e,0x49,0x4e,0x47,0x20,0x2d,0x20,0x50,0x61,
- 0x72,0x61,0x6c,0x6c,0x65,0x6c,0x20,0x70,0x6f,0x72,0x74,0x73,
- 0x20,0x6e,0x6f,0x74,0x20,0x6c,0x6f,0x6f,0x70,0x65,0x64,0x20,
- 0x62,0x61,0x63,0x6b,0x0a,0x0d,0x00,0x00,0x25,0x45,0x20,0x45,
- 0x42,0x49,0x20,0x25,0x64,0x20,0x70,0x61,0x72,0x61,0x6c,0x6c,
- 0x65,0x6c,0x20,0x70,0x6f,0x72,0x74,0x20,0x73,0x65,0x6e,0x74,
- 0x20,0x25,0x64,0x20,0x62,0x79,0x74,0x65,0x73,0x2c,0x20,0x45,
- 0x42,0x49,0x20,0x25,0x64,0x20,0x70,0x61,0x72,0x61,0x6c,0x6c,
- 0x65,0x6c,0x20,0x70,0x6f,0x72,0x74,0x20,0x67,0x6f,0x74,0x20,
- 0x25,0x64,0x20,0x62,0x79,0x74,0x65,0x73,0x0a,0x00,0x00,0x00,
- 0x25,0x45,0x20,0x45,0x42,0x49,0x20,0x25,0x64,0x20,0x70,0x61,
- 0x72,0x61,0x6c,0x6c,0x65,0x6c,0x20,0x70,0x6f,0x72,0x74,0x20,
- 0x77,0x72,0x6f,0x74,0x65,0x20,0x25,0x30,0x32,0x78,0x2c,0x20,
- 0x45,0x42,0x49,0x20,0x25,0x64,0x20,0x70,0x61,0x72,0x61,0x6c,
- 0x6c,0x65,0x6c,0x20,0x70,0x6f,0x72,0x74,0x20,0x72,0x65,0x61,
- 0x64,0x20,0x25,0x30,0x32,0x78,0x0a,0x00,0x25,0x45,0x20,0x45,
- 0x42,0x49,0x20,0x25,0x64,0x20,0x70,0x6f,0x72,0x74,0x20,0x25,
- 0x64,0x20,0x54,0x48,0x52,0x45,0x20,0x6e,0x65,0x76,0x65,0x72,
- 0x20,0x72,0x65,0x61,0x64,0x79,0x0a,0x00,0x25,0x45,0x20,0x45,
- 0x42,0x49,0x20,0x25,0x64,0x20,0x70,0x6f,0x72,0x74,0x20,0x25,
- 0x64,0x20,0x27,0x64,0x61,0x74,0x61,0x20,0x72,0x65,0x61,0x64,
- 0x79,0x20,0x73,0x74,0x75,0x63,0x6b,0x20,0x6f,0x6e,0x0a,0x00,
- 0x25,0x45,0x20,0x45,0x42,0x49,0x20,0x25,0x64,0x20,0x70,0x6f,
- 0x72,0x74,0x20,0x25,0x64,0x20,0x54,0x48,0x52,0x45,0x20,0x6e,
- 0x65,0x76,0x65,0x72,0x20,0x72,0x65,0x61,0x64,0x79,0x0a,0x00,
- 0x25,0x45,0x20,0x45,0x42,0x49,0x20,0x25,0x64,0x20,0x70,0x6f,
- 0x72,0x74,0x20,0x25,0x64,0x20,0x6e,0x6f,0x6e,0x65,0x6d,0x70,
- 0x74,0x79,0x20,0x74,0x72,0x61,0x6e,0x73,0x6d,0x69,0x74,0x74,
- 0x65,0x72,0x20,0x6c,0x6f,0x6f,0x6b,0x73,0x20,0x65,0x6d,0x70,
- 0x74,0x79,0x0a,0x00,0x25,0x45,0x20,0x45,0x42,0x49,0x20,0x25,
- 0x64,0x20,0x70,0x6f,0x72,0x74,0x20,0x25,0x64,0x20,0x64,0x61,
- 0x74,0x61,0x20,0x6e,0x65,0x76,0x65,0x72,0x20,0x61,0x72,0x72,
- 0x69,0x76,0x65,0x64,0x0a,0x00,0x00,0x00,0x25,0x45,0x20,0x45,
- 0x42,0x49,0x20,0x25,0x64,0x20,0x70,0x6f,0x72,0x74,0x20,0x25,
- 0x64,0x00,0x00,0x00,0x20,0x6f,0x76,0x65,0x72,0x72,0x75,0x6e,
- 0x20,0x65,0x72,0x72,0x6f,0x72,0x00,0x00,0x20,0x70,0x61,0x72,
- 0x69,0x74,0x79,0x20,0x65,0x72,0x72,0x6f,0x72,0x00,0x00,0x00,
- 0x20,0x66,0x72,0x61,0x6d,0x69,0x6e,0x67,0x20,0x65,0x72,0x72,
- 0x6f,0x72,0x00,0x00,0x0a,0x00,0x00,0x00,0x25,0x45,0x20,0x45,
- 0x42,0x49,0x20,0x25,0x64,0x20,0x70,0x6f,0x72,0x74,0x20,0x25,
- 0x64,0x20,0x27,0x64,0x61,0x74,0x61,0x20,0x72,0x65,0x61,0x64,
- 0x79,0x27,0x20,0x6e,0x6f,0x74,0x20,0x73,0x65,0x74,0x0a,0x00,
- 0x25,0x45,0x20,0x45,0x42,0x49,0x20,0x25,0x64,0x20,0x70,0x6f,
- 0x72,0x74,0x20,0x25,0x64,0x20,0x27,0x64,0x61,0x74,0x61,0x20,
- 0x72,0x65,0x61,0x64,0x79,0x27,0x20,0x73,0x74,0x69,0x6c,0x6c,
- 0x20,0x73,0x65,0x74,0x0a,0x00,0x00,0x00,0x25,0x45,0x20,0x45,
- 0x42,0x49,0x20,0x25,0x64,0x20,0x70,0x6f,0x72,0x74,0x20,0x25,
- 0x64,0x20,0x73,0x65,0x6e,0x64,0x20,0x25,0x30,0x32,0x78,0x20,
- 0x72,0x65,0x63,0x65,0x69,0x76,0x65,0x64,0x20,0x25,0x30,0x32,
- 0x78,0x0a,0x00,0x00,0x25,0x45,0x20,0x45,0x42,0x49,0x20,0x25,
- 0x64,0x20,0x70,0x6f,0x72,0x74,0x20,0x25,0x64,0x20,0x26,0x20,
- 0x70,0x6f,0x72,0x74,0x20,0x25,0x64,0x20,0x6d,0x6f,0x64,0x65,
- 0x6d,0x20,0x73,0x74,0x61,0x74,0x75,0x73,0x20,0x6f,0x75,0x74,
- 0x20,0x25,0x30,0x32,0x78,0x20,0x69,0x6e,0x20,0x25,0x30,0x32,
- 0x78,0x0a,0x0d,0x00,0x20,0x43,0x54,0x53,0x2f,0x52,0x54,0x53,
- 0x00,0x00,0x00,0x00,0x20,0x44,0x53,0x52,0x2f,0x44,0x54,0x52,
- 0x00,0x00,0x00,0x00,0x25,0x45,0x20,0x45,0x42,0x49,0x20,0x25,
- 0x64,0x20,0x70,0x6f,0x72,0x74,0x20,0x25,0x64,0x20,0x49,0x4e,
- 0x54,0x20,0x73,0x74,0x75,0x63,0x6b,0x20,0x6f,0x6e,0x0a,0x00,
- 0x25,0x45,0x20,0x45,0x42,0x49,0x20,0x25,0x64,0x20,0x70,0x6f,
- 0x72,0x74,0x20,0x25,0x64,0x20,0x49,0x4e,0x54,0x20,0x6d,0x61,
- 0x73,0x6b,0x20,0x6f,0x6e,0x20,0x77,0x2f,0x6f,0x20,0x69,0x6e,
- 0x74,0x65,0x72,0x72,0x75,0x70,0x74,0x0a,0x00,0x00,0x00,0x00,
- 0x25,0x45,0x20,0x45,0x42,0x49,0x20,0x25,0x64,0x20,0x70,0x6f,
- 0x72,0x74,0x20,0x25,0x64,0x20,0x49,0x4e,0x54,0x20,0x6d,0x61,
- 0x73,0x6b,0x20,0x64,0x6f,0x65,0x73,0x20,0x6e,0x6f,0x74,0x20,
- 0x73,0x65,0x74,0x20,0x62,0x69,0x74,0x0a,0x00,0x00,0x00,0x00,
- 0x25,0x45,0x20,0x45,0x42,0x49,0x20,0x25,0x64,0x20,0x70,0x6f,
- 0x72,0x74,0x20,0x25,0x64,0x20,0x49,0x4e,0x54,0x20,0x64,0x6f,
- 0x65,0x73,0x20,0x6e,0x6f,0x74,0x20,0x77,0x6f,0x72,0x6b,0x0a,
- 0x00,0x00,0x00,0x00,0x25,0x45,0x20,0x45,0x42,0x49,0x20,0x25,
- 0x64,0x20,0x70,0x6f,0x72,0x74,0x20,0x25,0x64,0x20,0x49,0x4e,
- 0x54,0x20,0x77,0x6f,0x6e,0x27,0x74,0x20,0x67,0x6f,0x20,0x61,
- 0x77,0x61,0x79,0x0a,0x00,0x00,0x00,0x00,0x25,0x45,0x20,0x45,
- 0x42,0x49,0x20,0x25,0x64,0x20,0x70,0x6f,0x72,0x74,0x20,0x25,
- 0x64,0x20,0x49,0x4e,0x54,0x20,0x6d,0x61,0x73,0x6b,0x20,0x64,
- 0x6f,0x65,0x73,0x20,0x6e,0x6f,0x74,0x20,0x72,0x65,0x73,0x65,
- 0x74,0x20,0x62,0x69,0x74,0x0a,0x00,0x00,0x25,0x64,0x20,0x55,
- 0x41,0x52,0x54,0x73,0x20,0x00,0x00,0x00,0x31,0x20,0x70,0x61,
- 0x72,0x61,0x6c,0x6c,0x65,0x6c,0x20,0x00,0x0d,0x45,0x42,0x49,
- 0x20,0x25,0x64,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,
- 0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x6e,0x6f,0x6e,0x65,0x00,0x00,
- 0x0d,0x45,0x42,0x49,0x20,0x25,0x64,0x2e,0x2e,0x2e,0x2e,0x2e,
- 0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x2e,0x75,0x6e,
- 0x6b,0x6e,0x6f,0x77,0x6e,0x20,0x45,0x42,0x49,0x20,0x74,0x79,
- 0x70,0x65,0x20,0x25,0x30,0x32,0x78,0x2c,0x20,0x6e,0x6f,0x74,
- 0x20,0x74,0x65,0x73,0x74,0x65,0x64,0x0d,0x0a,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x0c,0x00,0x34,0x00,0x00,0x00,0x41,0x0b,
- 0x00,0x00,0x0b,0x00,0x0c,0x00,0xe2,0x00,0x00,0x00,0x40,0x00,
- 0x0c,0x00,0x74,0x00,0x04,0x00,0x6e,0x00,0x04,0x00,0x00,0x00,
- 0x0c,0x00,0xe4,0x00,0x04,0x00,0x40,0x00,0x0c,0x00,0xb4,0x00,
- 0x08,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x0c,0x00,0xe8,0x00,
- 0x08,0x00,0x40,0x00,0x2e,0x2e,0x2f,0x74,0x69,0x6d,0x65,0x72,
- 0x2e,0x63,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x40,0x28,0x23,0x29,0x62,0x69,0x6f,0x73,0x69,0x6e,0x69,0x74,
- 0x2e,0x73,0x20,0x20,0x20,0x20,0x33,0x2e,0x36,0x2e,0x31,0x20,
- 0x20,0x37,0x2f,0x31,0x2f,0x39,0x34,0x00,0x40,0x28,0x23,0x29,
- 0x62,0x69,0x6f,0x73,0x69,0x6e,0x69,0x74,0x2e,0x73,0x20,0x20,
- 0x20,0x20,0x33,0x2e,0x36,0x20,0x20,0x37,0x2f,0x31,0x2f,0x39,
- 0x34,0x00,0x40,0x28,0x23,0x29,0x63,0x68,0x65,0x63,0x6b,0x72,
- 0x61,0x6e,0x67,0x65,0x2e,0x63,0x20,0x20,0x31,0x2e,0x31,0x20,
- 0x20,0x35,0x2f,0x31,0x38,0x2f,0x39,0x32,0x00,0x40,0x28,0x23,
- 0x29,0x63,0x6f,0x6d,0x6d,0x6f,0x6e,0x2e,0x6d,0x6b,0x20,0x20,
- 0x20,0x20,0x20,0x33,0x2e,0x31,0x30,0x20,0x20,0x31,0x2f,0x36,
- 0x2f,0x39,0x34,0x00,0x40,0x28,0x23,0x29,0x64,0x65,0x66,0x73,
- 0x2e,0x68,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x33,0x2e,
- 0x32,0x20,0x20,0x34,0x2f,0x36,0x2f,0x39,0x34,0x00,0x40,0x28,
- 0x23,0x29,0x64,0x65,0x76,0x69,0x63,0x65,0x2e,0x68,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x33,0x2e,0x38,0x20,0x20,0x34,0x2f,0x31,
- 0x34,0x2f,0x39,0x34,0x00,0x40,0x28,0x23,0x29,0x68,0x6f,0x73,
- 0x74,0x63,0x6f,0x6d,0x6d,0x2e,0x68,0x20,0x20,0x20,0x20,0x33,
- 0x2e,0x33,0x20,0x20,0x33,0x2f,0x32,0x32,0x2f,0x39,0x33,0x00,
- 0x40,0x28,0x23,0x29,0x6d,0x69,0x64,0x2e,0x68,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x33,0x2e,0x33,0x20,0x20,0x34,
- 0x2f,0x36,0x2f,0x39,0x34,0x00,0x40,0x28,0x23,0x29,0x6d,0x6f,
- 0x64,0x75,0x6c,0x65,0x2e,0x68,0x20,0x20,0x20,0x20,0x20,0x20,
- 0x33,0x2e,0x31,0x20,0x20,0x38,0x2f,0x32,0x30,0x2f,0x39,0x33,
- 0x00,0x40,0x28,0x23,0x29,0x70,0x61,0x72,0x61,0x2e,0x68,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x31,0x2e,0x31,0x20,0x20,
- 0x37,0x2f,0x37,0x2f,0x39,0x33,0x00,0x40,0x28,0x23,0x29,0x70,
- 0x62,0x75,0x73,0x2e,0x68,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
- 0x20,0x33,0x2e,0x32,0x20,0x20,0x34,0x2f,0x36,0x2f,0x39,0x34,
- 0x00,0x40,0x28,0x23,0x29,0x72,0x65,0x67,0x2e,0x68,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x33,0x2e,0x32,0x20,0x20,
- 0x38,0x2f,0x32,0x35,0x2f,0x39,0x33,0x00,0x40,0x28,0x23,0x29,
- 0x72,0x65,0x6c,0x65,0x61,0x73,0x65,0x2e,0x68,0x20,0x20,0x20,
- 0x20,0x20,0x33,0x2e,0x39,0x20,0x20,0x38,0x2f,0x31,0x37,0x2f,
- 0x39,0x34,0x00,0x40,0x28,0x23,0x29,0x72,0x77,0x2e,0x63,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x33,0x2e,0x31,
- 0x20,0x20,0x31,0x31,0x2f,0x35,0x2f,0x39,0x32,0x00,0x40,0x28,
- 0x23,0x29,0x72,0x77,0x2e,0x68,0x20,0x20,0x20,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x32,0x2e,0x31,0x20,0x20,0x33,0x2f,0x31,
- 0x2f,0x39,0x32,0x00,0x40,0x28,0x23,0x29,0x73,0x63,0x61,0x2e,
- 0x68,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x33,0x2e,
- 0x34,0x20,0x20,0x34,0x2f,0x31,0x39,0x2f,0x39,0x33,0x00,0x40,
- 0x28,0x23,0x29,0x73,0x6d,0x61,0x72,0x74,0x62,0x69,0x6f,0x73,
- 0x2e,0x63,0x20,0x20,0x20,0x33,0x2e,0x31,0x31,0x20,0x20,0x37,
- 0x2f,0x31,0x2f,0x39,0x34,0x00,0x40,0x28,0x23,0x29,0x73,0x6d,
- 0x61,0x72,0x74,0x62,0x69,0x6f,0x73,0x2e,0x68,0x20,0x20,0x20,
- 0x33,0x2e,0x31,0x20,0x20,0x38,0x2f,0x32,0x30,0x2f,0x39,0x33,
- 0x00,0x40,0x28,0x23,0x29,0x73,0x78,0x62,0x69,0x6f,0x73,0x2e,
- 0x6d,0x6b,0x20,0x20,0x20,0x20,0x20,0x33,0x2e,0x33,0x20,0x20,
- 0x37,0x2f,0x31,0x2f,0x39,0x34,0x00,0x40,0x28,0x23,0x29,0x74,
- 0x65,0x73,0x74,0x73,0x2e,0x63,0x20,0x20,0x20,0x20,0x20,0x20,
- 0x20,0x33,0x2e,0x32,0x33,0x20,0x20,0x37,0x2f,0x32,0x31,0x2f,
- 0x39,0x34,0x00,0x40,0x28,0x23,0x29,0x74,0x69,0x6d,0x65,0x72,
- 0x2e,0x63,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x33,0x2e,0x33,
- 0x20,0x20,0x37,0x2f,0x37,0x2f,0x39,0x33,0x00,0x40,0x28,0x23,
- 0x29,0x74,0x69,0x6d,0x65,0x72,0x2e,0x68,0x20,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x33,0x2e,0x33,0x20,0x20,0x34,0x2f,0x36,0x2f,
- 0x39,0x34,0x00,0x40,0x28,0x23,0x29,0x75,0x61,0x72,0x74,0x2e,
- 0x68,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x33,0x2e,0x31,
- 0x20,0x20,0x34,0x2f,0x36,0x2f,0x39,0x34,0x00,0x40,0x28,0x23,
- 0x29,0x75,0x74,0x69,0x6c,0x2e,0x73,0x20,0x20,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x33,0x2e,0x33,0x20,0x20,0x37,0x2f,0x31,0x2f,
- 0x39,0x34,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
-};
-
-static unsigned pcem_nbios = sizeof(pcem_bios);
-
diff --git a/sys/dev/dgb/dgmfep.h b/sys/dev/dgb/dgmfep.h
deleted file mode 100644
index 7921fa3b058f..000000000000
--- a/sys/dev/dgb/dgmfep.h
+++ /dev/null
@@ -1,1954 +0,0 @@
-/*
- * $FreeBSD$
- *
- * This file is an ascii copy of the file sxbios.bin included in the
- * Digiboard PC/Xem driver for Linux. It is copyright 1992, DIGI
- * International. All Rights Reserved.
- */
-
-static unsigned char pcem_cook[] = {
- 0x4f,0x53,0x5b,0x12,0x65,0x00,0x00,0x10,0xc5,0x00,0x1e,0x24,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x4b,0x3d,0xb2,0x87,0x00,0x00,0x00,0x00,0x40,0x28,0x23,0x29,
- 0x73,0x78,0x66,0x65,0x70,0x2e,0x62,0x69,0x6e,0x20,0x20,0x20,
- 0x20,0x20,0x32,0x2e,0x31,0x20,0x30,0x38,0x2f,0x31,0x37,0x2f,
- 0x39,0x34,0x00,0x40,0x28,0x23,0x29,0x43,0x6f,0x70,0x79,0x72,
- 0x69,0x67,0x68,0x74,0x20,0x28,0x43,0x29,0x20,0x31,0x39,0x39,
- 0x32,0x2c,0x20,0x44,0x49,0x47,0x49,0x20,0x49,0x6e,0x74,0x65,
- 0x72,0x6e,0x61,0x74,0x69,0x6f,0x6e,0x61,0x6c,0x2e,0x20,0x41,
- 0x6c,0x6c,0x20,0x52,0x69,0x67,0x68,0x74,0x73,0x20,0x52,0x65,
- 0x73,0x65,0x72,0x76,0x65,0x64,0x2e,0x00,0x00,0xa3,0x01,0x3c,
- 0x28,0x02,0x22,0xac,0x00,0xa3,0x02,0x3c,0x20,0x02,0x42,0x24,
- 0x0c,0x00,0x43,0xac,0x00,0x60,0x03,0x40,0x00,0x60,0x80,0x40,
- 0x00,0x00,0x43,0xac,0x00,0x68,0x03,0x40,0x00,0x00,0x00,0x00,
- 0x24,0x00,0x49,0xac,0x20,0x00,0x48,0xac,0x00,0xa3,0x09,0x3c,
- 0x04,0x00,0x43,0xac,0x10,0x00,0x44,0xac,0x14,0x00,0x45,0xac,
- 0x18,0x00,0x46,0xac,0x1c,0x00,0x47,0xac,0x28,0x00,0x4a,0xac,
- 0x2c,0x00,0x4b,0xac,0x30,0x00,0x4c,0xac,0x34,0x00,0x4d,0xac,
- 0x38,0x00,0x4e,0xac,0x3c,0x00,0x4f,0xac,0x40,0x00,0x50,0xac,
- 0x44,0x00,0x51,0xac,0x48,0x00,0x52,0xac,0x4c,0x00,0x53,0xac,
- 0x50,0x00,0x54,0xac,0x54,0x00,0x55,0xac,0x58,0x00,0x56,0xac,
- 0x5c,0x00,0x57,0xac,0x60,0x00,0x58,0xac,0x64,0x00,0x59,0xac,
- 0x68,0x00,0x5a,0xac,0x6c,0x00,0x5b,0xac,0x70,0x00,0x5c,0xac,
- 0x74,0x00,0x5d,0xac,0x78,0x00,0x5e,0xac,0x7c,0x00,0x5f,0xac,
- 0x10,0x00,0x08,0x24,0x00,0x02,0x29,0x25,0x00,0x00,0x8a,0x80,
- 0x00,0x00,0x00,0x00,0x02,0x00,0x40,0x11,0x00,0x00,0x2a,0xa1,
- 0x01,0x00,0x84,0x24,0xff,0xff,0x08,0x25,0xf9,0xff,0x00,0x1d,
- 0x01,0x00,0x29,0x25,0x00,0xa3,0x01,0x3c,0x10,0x02,0x25,0xac,
- 0x00,0xa3,0x01,0x3c,0x14,0x02,0x3f,0xac,0x00,0xa3,0x01,0x3c,
- 0x18,0x02,0x3d,0xac,0x02,0x00,0x08,0x24,0x00,0xa3,0x01,0x3c,
- 0x00,0xa3,0x1d,0x3c,0x10,0x0c,0x28,0xac,0x00,0x04,0xbd,0x27,
- 0x64,0x17,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0xa3,0x08,0x3c,
- 0x10,0x0c,0x08,0x8d,0x01,0x00,0x01,0x24,0x23,0x00,0x01,0x11,
- 0x00,0x00,0x00,0x00,0xf8,0xff,0x00,0x10,0x00,0x00,0x00,0x00,
- 0xc5,0x00,0x1e,0x24,0x00,0x83,0x01,0x3c,0x10,0x00,0x3e,0xac,
- 0x00,0x00,0x1e,0x24,0x00,0x10,0x08,0x3c,0x00,0x60,0x88,0x40,
- 0xce,0x00,0x1e,0x24,0x00,0x83,0x01,0x3c,0x01,0x80,0x1c,0x3c,
- 0x10,0x00,0x3e,0xac,0xb0,0xfb,0x9c,0x27,0x00,0x00,0x1e,0x24,
- 0x01,0x00,0x11,0x04,0x00,0x00,0x00,0x00,0x00,0x80,0x04,0x3c,
- 0xe9,0x00,0x1e,0x24,0x00,0x83,0x01,0x3c,0x01,0x80,0x06,0x3c,
- 0xd0,0x31,0x84,0x24,0x10,0x00,0x3e,0xac,0x00,0x80,0x05,0x3c,
- 0x50,0x86,0xc6,0x24,0x23,0x20,0xe4,0x03,0x00,0x00,0x1e,0x24,
- 0x00,0x30,0xa5,0x24,0x21,0x20,0x86,0x00,0xfc,0xff,0x88,0x8c,
- 0xfc,0xff,0xc6,0x24,0x2b,0x08,0xa6,0x00,0xfc,0xff,0x84,0x24,
- 0xfb,0xff,0x20,0x14,0x00,0x00,0xc8,0xac,0x00,0x60,0x08,0x40,
- 0x00,0x00,0x00,0x00,0xff,0xff,0x01,0x3c,0xfe,0x00,0x21,0x34,
- 0x24,0x40,0x01,0x01,0x00,0x60,0x88,0x40,0x09,0x01,0x1e,0x24,
- 0x00,0x83,0x01,0x3c,0x10,0x00,0x3e,0xac,0x00,0x80,0x04,0x3c,
- 0x90,0x44,0x84,0x24,0x00,0xa0,0x01,0x3c,0x00,0x80,0x1f,0x3c,
- 0x25,0x20,0x81,0x00,0x00,0x00,0x1e,0x24,0x08,0x00,0x80,0x00,
- 0x5c,0x32,0xff,0x27,0x13,0x01,0x1e,0x24,0x00,0x83,0x01,0x3c,
- 0x10,0x00,0x3e,0xac,0x00,0xa3,0x01,0x3c,0x00,0x00,0x1e,0x24,
- 0x80,0x92,0x9d,0x27,0x9e,0x15,0x00,0x0c,0x10,0x0c,0x20,0xac,
- 0x66,0x0c,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x94,0xff,0xbd,0x27,
- 0x10,0x00,0xa1,0xaf,0x14,0x00,0xa2,0xaf,0x18,0x00,0xa3,0xaf,
- 0x1c,0x00,0xa4,0xaf,0x20,0x00,0xa5,0xaf,0x24,0x00,0xa6,0xaf,
- 0x28,0x00,0xa7,0xaf,0x2c,0x00,0xa8,0xaf,0x30,0x00,0xa9,0xaf,
- 0x34,0x00,0xaa,0xaf,0x38,0x00,0xab,0xaf,0x3c,0x00,0xac,0xaf,
- 0x40,0x00,0xad,0xaf,0x44,0x00,0xae,0xaf,0x48,0x00,0xaf,0xaf,
- 0x4c,0x00,0xb8,0xaf,0x50,0x00,0xb9,0xaf,0x58,0x00,0xbe,0xaf,
- 0x5c,0x00,0xbf,0xaf,0x00,0x70,0x08,0x40,0x12,0x48,0x00,0x00,
- 0x10,0x50,0x00,0x00,0x54,0x00,0xa8,0xaf,0x60,0x00,0xa9,0xaf,
- 0x64,0x00,0xaa,0xaf,0x00,0x68,0x05,0x40,0x00,0x60,0x06,0x40,
- 0x7c,0x00,0xa4,0x30,0x55,0x00,0x80,0x14,0x00,0x00,0x00,0x00,
- 0x24,0x10,0xa6,0x00,0x68,0x00,0xa6,0xaf,0x00,0xff,0x42,0x30,
- 0x00,0x08,0x44,0x30,0x44,0x00,0x80,0x14,0x00,0x00,0x00,0x00,
- 0x00,0x04,0x48,0x30,0x37,0x00,0x00,0x15,0x00,0x00,0x00,0x00,
- 0x2a,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x68,0x00,0xa6,0x8f,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x86,0x40,
- 0x00,0x68,0x05,0x40,0x00,0x00,0x00,0x00,0x24,0x10,0xa6,0x00,
- 0x00,0xff,0x42,0x30,0xf0,0xff,0x40,0x14,0x00,0x08,0x44,0x30,
- 0x68,0x00,0xa8,0x8f,0x60,0x00,0xa9,0x8f,0x64,0x00,0xaa,0x8f,
- 0x00,0x00,0x00,0x00,0x00,0x60,0x88,0x40,0x13,0x00,0x20,0x01,
- 0x11,0x00,0x40,0x01,0x14,0x00,0xa2,0x8f,0x18,0x00,0xa3,0x8f,
- 0x1c,0x00,0xa4,0x8f,0x20,0x00,0xa5,0x8f,0x24,0x00,0xa6,0x8f,
- 0x28,0x00,0xa7,0x8f,0x2c,0x00,0xa8,0x8f,0x30,0x00,0xa9,0x8f,
- 0x34,0x00,0xaa,0x8f,0x38,0x00,0xab,0x8f,0x3c,0x00,0xac,0x8f,
- 0x40,0x00,0xad,0x8f,0x44,0x00,0xae,0x8f,0x48,0x00,0xaf,0x8f,
- 0x4c,0x00,0xb8,0x8f,0x50,0x00,0xb9,0x8f,0x58,0x00,0xbe,0x8f,
- 0x5c,0x00,0xbf,0x8f,0x00,0x00,0x00,0x00,0x54,0x00,0xba,0x8f,
- 0x10,0x00,0xa1,0x8f,0x6c,0x00,0xbd,0x27,0x08,0x00,0x40,0x03,
- 0x10,0x00,0x00,0x42,0x84,0x92,0x88,0x8f,0x00,0x00,0x09,0x24,
- 0x26,0x40,0x06,0x01,0x01,0xff,0x08,0x31,0x26,0x30,0xc8,0x00,
- 0x00,0x68,0x89,0x40,0x00,0x60,0x86,0x40,0x8c,0x15,0x00,0x0c,
- 0x00,0x00,0x00,0x00,0xce,0xff,0x00,0x10,0x68,0x00,0xa6,0x8f,
- 0x80,0x92,0x88,0x8f,0x00,0x00,0x00,0x00,0x26,0x40,0x06,0x01,
- 0x01,0xff,0x08,0x31,0x26,0x30,0xc8,0x00,0x00,0x60,0x86,0x40,
- 0x44,0x19,0x00,0x0c,0x00,0x00,0x00,0x00,0xc4,0xff,0x00,0x10,
- 0x68,0x00,0xa6,0x8f,0x01,0x80,0x08,0x3c,0x48,0x8e,0x08,0x8d,
- 0x00,0x00,0x00,0x00,0x26,0x40,0x06,0x01,0x01,0xff,0x08,0x31,
- 0x26,0x30,0xc8,0x00,0x00,0x60,0x86,0x40,0x95,0x15,0x00,0x0c,
- 0x00,0x00,0x00,0x00,0xb9,0xff,0x00,0x10,0x68,0x00,0xa6,0x8f,
- 0x00,0x80,0x04,0x3c,0xd0,0x7a,0x84,0x24,0x20,0x0c,0x00,0x0c,
- 0x74,0x01,0x05,0x24,0xbd,0xff,0x00,0x10,0x68,0x00,0xa8,0x8f,
- 0xec,0xff,0xbd,0x27,0x08,0x00,0xa1,0xaf,0x00,0x70,0x1a,0x40,
- 0x00,0x00,0x00,0x00,0x0c,0x00,0xba,0xaf,0x10,0x00,0xbf,0xaf,
- 0x00,0x80,0x04,0x3c,0xd0,0x7a,0x84,0x24,0x20,0x0c,0x00,0x0c,
- 0x96,0x01,0x05,0x24,0x10,0x00,0xbf,0x8f,0x0c,0x00,0xba,0x8f,
- 0x08,0x00,0xa1,0x8f,0x0c,0x00,0xbd,0x27,0x08,0x00,0x40,0x03,
- 0x10,0x00,0x00,0x42,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0xdc,0xff,0xbd,0x27,0xa0,0x92,0x84,0x8f,
- 0x00,0x00,0xb0,0xaf,0x04,0x00,0xb1,0xaf,0x08,0x00,0xb2,0xaf,
- 0x0c,0x00,0xb3,0xaf,0x10,0x00,0xb4,0xaf,0x14,0x00,0xb5,0xaf,
- 0x18,0x00,0xb6,0xaf,0x1c,0x00,0xb7,0xaf,0x20,0x00,0xbf,0xaf,
- 0x04,0x00,0x88,0x8c,0x01,0x80,0x10,0x3c,0xcc,0x85,0x10,0x8e,
- 0x08,0x00,0x00,0x01,0x00,0x20,0x11,0x3c,0x00,0x93,0x88,0x8f,
- 0x21,0x80,0x10,0x02,0x04,0x00,0x08,0x31,0x21,0x08,0x1c,0x01,
- 0xa4,0x92,0x24,0x8c,0x00,0x00,0x00,0x00,0x04,0x00,0x8a,0x8c,
- 0x00,0x00,0x00,0x00,0x08,0x00,0x40,0x01,0x00,0x00,0x00,0x00,
- 0x00,0x93,0x88,0x8f,0x21,0x80,0x10,0x02,0x21,0x08,0x1c,0x01,
- 0xac,0x92,0x24,0x8c,0x04,0x00,0x0a,0x25,0x04,0x00,0x89,0x8c,
- 0x0c,0x00,0x4a,0x31,0x08,0x00,0x20,0x01,0x00,0x93,0x8a,0xaf,
- 0xbc,0x92,0x84,0x8f,0x9c,0x92,0x90,0x8f,0x00,0x00,0x00,0x00,
- 0x34,0x00,0x88,0x8c,0xff,0xff,0x10,0x26,0x09,0xf8,0x00,0x01,
- 0x00,0x00,0x00,0x00,0x30,0x00,0x84,0x8c,0xfa,0xff,0x00,0x16,
- 0x00,0x00,0x00,0x00,0x20,0x00,0xbf,0x8f,0x00,0x00,0xb0,0x8f,
- 0x04,0x00,0xb1,0x8f,0x08,0x00,0xb2,0x8f,0x0c,0x00,0xb3,0x8f,
- 0x10,0x00,0xb4,0x8f,0x14,0x00,0xb5,0x8f,0x18,0x00,0xb6,0x8f,
- 0x1c,0x00,0xb7,0x8f,0xbc,0x92,0x84,0xaf,0x08,0x00,0xe0,0x03,
- 0x24,0x00,0xbd,0x27,0x50,0x00,0x87,0x94,0x24,0x00,0x86,0x8c,
- 0x82,0x48,0x07,0x00,0x0c,0x00,0x29,0x31,0x21,0x08,0x3c,0x01,
- 0x10,0x80,0x29,0x8c,0x25,0x28,0x91,0x00,0x08,0x00,0x20,0x01,
- 0x00,0x00,0x00,0x00,0x08,0x00,0xc2,0x90,0x00,0x00,0x00,0x00,
- 0xc0,0x47,0x02,0x00,0xab,0x00,0x11,0x05,0x00,0x00,0x00,0x00,
- 0x44,0x00,0x92,0x8c,0x02,0x49,0x07,0x00,0x23,0x90,0x50,0x02,
- 0x9e,0x00,0x41,0x06,0x7c,0x00,0x29,0x31,0x21,0x08,0x3c,0x01,
- 0x30,0x80,0x29,0x8c,0x40,0x00,0x93,0x8c,0x08,0x00,0x20,0x01,
- 0x00,0x00,0x00,0x00,0x2c,0x00,0x89,0x94,0x00,0x00,0x00,0x00,
- 0x00,0x08,0x29,0x31,0x0d,0x01,0x20,0x15,0x00,0x00,0x00,0x00,
- 0x02,0x49,0x07,0x00,0x0c,0x00,0x29,0x31,0x21,0x08,0x3c,0x01,
- 0x20,0x80,0x29,0x8c,0x00,0x00,0x00,0x00,0x08,0x00,0x20,0x01,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x84,0x8c,0x00,0x00,0x00,0x00,
- 0x04,0x00,0x89,0x8c,0x00,0x00,0x00,0x00,0x08,0x00,0x20,0x01,
- 0x00,0x00,0x00,0x00,0x02,0x41,0x07,0x00,0x7c,0x00,0x08,0x31,
- 0x21,0x08,0x1c,0x01,0x30,0x80,0x28,0x8c,0x00,0x00,0x00,0x00,
- 0x08,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x54,0x00,0xa9,0x90,
- 0x58,0x00,0xaa,0x90,0x01,0x00,0xe8,0x30,0x09,0x00,0x00,0x11,
- 0x00,0x00,0x00,0x00,0x28,0x00,0x8c,0x94,0x00,0x00,0x00,0x00,
- 0x00,0x10,0x88,0x31,0x04,0x00,0x00,0x11,0x00,0x00,0x00,0x00,
- 0x5d,0x00,0x83,0x90,0x03,0x00,0x00,0x10,0x08,0x00,0x2b,0x35,
- 0x5c,0x00,0x83,0x90,0xf7,0xff,0x2b,0x31,0x26,0x48,0x2b,0x01,
- 0x25,0x50,0x49,0x01,0x54,0x00,0xab,0xa0,0x58,0x00,0xaa,0xa0,
- 0xff,0xfd,0xe7,0x30,0x50,0x00,0x87,0xa4,0x21,0x90,0x53,0x02,
- 0xe2,0xff,0x40,0x06,0x00,0x00,0xc3,0xa0,0x67,0x00,0x00,0x10,
- 0x00,0x00,0x88,0x8c,0x02,0x00,0x08,0x24,0x21,0x48,0x12,0x02,
- 0x5c,0x00,0x20,0x15,0x67,0x00,0x88,0xa0,0x0c,0x00,0xca,0x90,
- 0x00,0x04,0xe7,0x34,0x40,0x00,0x4a,0x35,0x0c,0x00,0xca,0xa0,
- 0x56,0x00,0x00,0x10,0x50,0x00,0x87,0xa4,0x6c,0x00,0x89,0x8c,
- 0x02,0x00,0x08,0x24,0xff,0xff,0x01,0x24,0x0b,0x00,0x21,0x11,
- 0x67,0x00,0x88,0xa0,0x23,0x48,0x30,0x01,0x07,0x00,0x20,0x1d,
- 0x00,0x00,0x00,0x00,0x0c,0x00,0xca,0x90,0xff,0xfa,0xe7,0x30,
- 0xbf,0xff,0x4a,0x31,0x0c,0x00,0xca,0xa0,0x00,0x00,0x09,0x24,
- 0x50,0x00,0x87,0xa4,0x6c,0x00,0x89,0xac,0x46,0x00,0x00,0x10,
- 0x00,0x00,0x88,0x8c,0x24,0x00,0x86,0x8c,0x25,0x28,0x91,0x00,
- 0x08,0x00,0xc2,0x90,0x00,0x00,0x00,0x00,0xc0,0x47,0x02,0x00,
- 0x4a,0x00,0x11,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x84,0x8c,
- 0x00,0x00,0x00,0x00,0x04,0x00,0x89,0x8c,0x00,0x00,0x00,0x00,
- 0x08,0x00,0x20,0x01,0x00,0x00,0x00,0x00,0x00,0x80,0x0a,0x3c,
- 0x88,0x37,0x4a,0x25,0x49,0x00,0x88,0x90,0x4a,0x00,0x89,0x90,
- 0x0e,0x00,0x00,0x10,0x04,0x00,0x8a,0xac,0x24,0x00,0x86,0x8c,
- 0x50,0x00,0x87,0x94,0x08,0x00,0xc2,0x90,0x25,0x28,0x91,0x00,
- 0xc0,0x47,0x02,0x00,0x3a,0x00,0x11,0x05,0x42,0x42,0x07,0x00,
- 0x44,0x00,0x92,0x8c,0x49,0x00,0x88,0x90,0x4a,0x00,0x89,0x90,
- 0x23,0x90,0x50,0x02,0x2b,0x00,0x41,0x06,0x00,0x00,0x00,0x00,
- 0x0a,0x00,0xb5,0x94,0x0c,0x00,0xb6,0x94,0x18,0x00,0xca,0x90,
- 0x17,0x00,0xb6,0x12,0x00,0x00,0x00,0x00,0x24,0x40,0x0a,0x01,
- 0x1d,0x00,0x09,0x15,0x00,0x00,0x00,0x00,0x3c,0x00,0x94,0x8c,
- 0x40,0x00,0x93,0x8c,0x0e,0x00,0x97,0x94,0x21,0x40,0x96,0x02,
- 0x00,0x00,0x03,0x91,0x01,0x00,0xd6,0x26,0x00,0x00,0xc3,0xa0,
- 0x21,0x90,0x53,0x02,0x04,0x00,0x41,0x06,0x24,0xb0,0xd7,0x02,
- 0xf9,0xff,0xb6,0x16,0x21,0x40,0x96,0x02,0x00,0x00,0x12,0x24,
- 0x00,0x00,0x88,0x8c,0x0c,0x00,0xb6,0xa4,0x04,0x00,0x09,0x8d,
- 0x44,0x00,0x92,0xac,0x08,0x00,0x20,0x01,0x21,0x20,0x00,0x01,
- 0x21,0x40,0x12,0x02,0x07,0x00,0x00,0x15,0x00,0x00,0x00,0x00,
- 0x00,0x80,0x08,0x3c,0xbf,0xff,0xe7,0x30,0x3c,0x37,0x08,0x25,
- 0x4b,0x00,0x80,0xa0,0x50,0x00,0x87,0xa4,0x04,0x00,0x88,0xac,
- 0x00,0x00,0x88,0x8c,0x00,0x00,0x00,0x00,0x04,0x00,0x09,0x8d,
- 0x44,0x00,0x80,0xac,0x08,0x00,0x20,0x01,0x21,0x20,0x00,0x01,
- 0x00,0x00,0x88,0x8c,0x44,0x00,0x92,0xac,0x04,0x00,0x09,0x8d,
- 0x21,0x20,0x00,0x01,0x08,0x00,0x20,0x01,0x00,0x00,0x00,0x00,
- 0x50,0x00,0x87,0x8c,0x00,0x00,0x00,0x00,0x42,0x42,0x07,0x00,
- 0x7c,0x00,0x08,0x31,0x21,0x08,0x1c,0x01,0x6a,0x00,0x92,0x94,
- 0xb0,0x88,0x33,0x8c,0x38,0x00,0x94,0x8c,0x12,0x00,0xb5,0x94,
- 0x14,0x00,0xb6,0x94,0x16,0x00,0x97,0x94,0x28,0x00,0x8c,0x94,
- 0x5c,0x00,0x8e,0x90,0x5d,0x00,0x8f,0x90,0x00,0x00,0x00,0x00,
- 0x14,0x00,0xc2,0x90,0x00,0x00,0xc3,0x90,0x00,0x42,0x02,0x00,
- 0x25,0x18,0x68,0x00,0x08,0x00,0x60,0x02,0x24,0x18,0x72,0x00,
- 0xff,0xf9,0x68,0x30,0x65,0x02,0x0e,0x11,0x21,0x48,0x95,0x02,
- 0x74,0x02,0x0f,0x11,0xff,0x00,0x61,0x2c,0x11,0x00,0x20,0x10,
- 0x00,0x00,0x23,0xa1,0x01,0x00,0xb5,0x26,0x24,0xa8,0xb7,0x02,
- 0x1e,0x00,0xb6,0x16,0x00,0x00,0x00,0x00,0xc4,0x02,0x00,0x10,
- 0xff,0xff,0xb5,0x26,0x21,0x48,0x95,0x02,0xff,0x00,0x61,0x2c,
- 0x07,0x00,0x20,0x10,0x00,0x00,0x23,0xa1,0x01,0x00,0xb5,0x26,
- 0x24,0xa8,0xb7,0x02,0x14,0x00,0xb6,0x16,0x00,0x00,0x00,0x00,
- 0xba,0x02,0x00,0x10,0xff,0xff,0xb5,0x26,0x00,0xff,0x68,0x30,
- 0x71,0x02,0x00,0x15,0xc2,0x51,0x03,0x00,0x01,0x00,0xb5,0x26,
- 0x24,0xa8,0xb7,0x02,0xb2,0x02,0xb6,0x12,0x00,0x00,0x00,0x00,
- 0x08,0x00,0x8a,0x31,0x08,0x00,0x40,0x11,0x00,0x00,0x00,0x00,
- 0x21,0x48,0x95,0x02,0x01,0x00,0xb5,0x26,0x24,0xa8,0xb7,0x02,
- 0x03,0x00,0xb6,0x16,0x00,0x00,0x23,0xa1,0xa7,0x02,0x00,0x10,
- 0xff,0xff,0xb5,0x26,0x08,0x00,0xc2,0x90,0x00,0x00,0x00,0x00,
- 0x01,0x00,0x48,0x30,0xce,0xff,0x00,0x11,0x00,0x00,0x00,0x00,
- 0x1c,0x00,0x88,0x94,0x23,0x48,0xb6,0x02,0x24,0x48,0x37,0x01,
- 0x2b,0x08,0x28,0x01,0x1a,0x00,0x20,0x14,0x12,0x00,0xb5,0xa4,
- 0x01,0x00,0xea,0x30,0x17,0x00,0x40,0x15,0x00,0x00,0x00,0x00,
- 0x00,0x10,0x88,0x31,0x06,0x00,0x00,0x11,0x01,0x00,0xe7,0x34,
- 0x00,0x80,0x13,0x3c,0x00,0x80,0x1f,0x3c,0x00,0x02,0xe7,0x38,
- 0xa4,0x35,0x73,0x26,0xdc,0x35,0xff,0x27,0x5f,0x00,0x88,0x90,
- 0x54,0x00,0xa9,0x90,0x03,0x00,0x08,0x31,0x26,0x48,0x28,0x01,
- 0x54,0x00,0xa9,0xa0,0x56,0x00,0xa9,0x90,0x58,0x00,0xaa,0x90,
- 0x24,0x48,0x28,0x01,0x25,0x50,0x49,0x01,0x58,0x00,0xaa,0xa0,
- 0x68,0x00,0x8b,0x90,0x27,0x40,0x00,0x01,0x24,0x58,0x68,0x01,
- 0x10,0x00,0xcb,0xa0,0x12,0x00,0xb5,0xa4,0x08,0x00,0xe0,0x03,
- 0x50,0x00,0x87,0xa4,0x24,0x00,0x86,0x8c,0x25,0x28,0x91,0x00,
- 0x54,0x00,0xa9,0x90,0x18,0x00,0xc8,0x90,0x58,0x00,0xaa,0x90,
- 0x26,0x40,0x09,0x01,0xf0,0x00,0x08,0x31,0x26,0x48,0x28,0x01,
- 0x54,0x00,0xa9,0xa0,0x56,0x00,0xa9,0x90,0x00,0x00,0x00,0x00,
- 0x24,0x48,0x28,0x01,0x25,0x50,0x49,0x01,0x08,0x00,0xe0,0x03,
- 0x58,0x00,0xaa,0xa0,0x00,0x80,0x0a,0x3c,0x58,0x3a,0x4a,0x25,
- 0x04,0x00,0x00,0x10,0x04,0x00,0x8a,0xac,0x24,0x00,0x86,0x8c,
- 0x50,0x00,0x87,0x94,0x25,0x28,0x91,0x00,0x38,0x00,0xc9,0x90,
- 0x00,0x00,0x00,0x00,0x14,0x00,0x20,0x11,0x00,0x00,0x00,0x00,
- 0x12,0x00,0xb5,0x94,0x38,0x00,0x94,0x8c,0x14,0x00,0xb6,0x94,
- 0x16,0x00,0x97,0x94,0x21,0x40,0x95,0x02,0x01,0x00,0xb5,0x26,
- 0x24,0xa8,0xb7,0x02,0x08,0x00,0xb6,0x12,0x00,0x00,0x00,0x00,
- 0x48,0x00,0xc3,0x90,0xff,0xff,0x29,0x25,0x00,0x00,0x03,0xa1,
- 0xf8,0xff,0x20,0x15,0x21,0x40,0x95,0x02,0x04,0x00,0x00,0x10,
- 0x12,0x00,0xb5,0xa4,0xff,0xff,0xb5,0x26,0x24,0xa8,0xb7,0x02,
- 0x12,0x00,0xb5,0xa4,0x00,0x00,0x88,0x8c,0x00,0x00,0x00,0x00,
- 0x04,0x00,0x09,0x8d,0x21,0x20,0x00,0x01,0x08,0x00,0x20,0x01,
- 0x00,0x00,0x00,0x00,0x00,0x80,0x0a,0x3c,0xe8,0x3a,0x4a,0x25,
- 0x04,0x00,0x00,0x10,0x04,0x00,0x8a,0xac,0x24,0x00,0x86,0x8c,
- 0x50,0x00,0x87,0x94,0x25,0x28,0x91,0x00,0x0a,0x00,0xb5,0x94,
- 0x0c,0x00,0xb6,0x94,0x00,0x00,0x00,0x00,0x72,0x00,0xb6,0x12,
- 0x00,0x00,0x00,0x00,0x38,0x00,0xc9,0x90,0x3c,0x00,0x94,0x8c,
- 0x80,0xff,0x29,0x21,0x0e,0x00,0x97,0x94,0x22,0x48,0x09,0x00,
- 0x21,0x40,0x96,0x02,0x08,0x00,0x20,0x19,0x00,0x00,0x00,0x00,
- 0xff,0xff,0x29,0x25,0x00,0x00,0x03,0x91,0x01,0x00,0xd6,0x26,
- 0x48,0x00,0xc3,0xa0,0x24,0xb0,0xd7,0x02,0xf8,0xff,0xb6,0x16,
- 0x21,0x40,0x96,0x02,0x00,0x00,0x88,0x8c,0x0c,0x00,0xb6,0xa4,
- 0x04,0x00,0x09,0x8d,0x21,0x20,0x00,0x01,0x08,0x00,0x20,0x01,
- 0x00,0x00,0x00,0x00,0x00,0x80,0x0a,0x3c,0x6c,0x3b,0x4a,0x25,
- 0x04,0x00,0x00,0x10,0x04,0x00,0x8a,0xac,0x24,0x00,0x86,0x8c,
- 0x50,0x00,0x87,0x94,0x25,0x28,0x91,0x00,0x0a,0x00,0xb5,0x94,
- 0x0c,0x00,0xb6,0x94,0x00,0x00,0x00,0x00,0x51,0x00,0xb6,0x12,
- 0x00,0x00,0x00,0x00,0x38,0x00,0xc9,0x90,0x3c,0x00,0x94,0x8c,
- 0x80,0xff,0x29,0x25,0x0e,0x00,0x97,0x94,0x2a,0x00,0x8c,0x94,
- 0x63,0x00,0x8e,0x90,0x22,0x48,0x09,0x00,0x14,0x00,0x20,0x19,
- 0x21,0x40,0x96,0x02,0x00,0x00,0x08,0x91,0xff,0xff,0x29,0x25,
- 0x21,0x18,0x00,0x01,0x80,0x40,0x08,0x00,0x21,0x08,0x1c,0x01,
- 0xb0,0x84,0x28,0x8c,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x01,
- 0x00,0x00,0x00,0x00,0x02,0x00,0x88,0x31,0x02,0x00,0x00,0x11,
- 0x00,0x00,0x00,0x00,0xe0,0xff,0x63,0x24,0x01,0x00,0xce,0x25,
- 0x48,0x00,0xc3,0xa0,0x01,0x00,0xd6,0x26,0x24,0xb0,0xd7,0x02,
- 0xec,0xff,0xb6,0x16,0x00,0x00,0x00,0x00,0x00,0x00,0x88,0x8c,
- 0x63,0x00,0x8e,0xa0,0x0c,0x00,0xb6,0xa4,0x04,0x00,0x09,0x8d,
- 0x21,0x20,0x00,0x01,0x08,0x00,0x20,0x01,0x00,0x00,0x00,0x00,
- 0xf3,0xff,0xc0,0x11,0x00,0x00,0x00,0x00,0xf1,0xff,0x00,0x10,
- 0xff,0xff,0xce,0x25,0x20,0x00,0x8a,0x31,0x03,0x00,0x40,0x11,
- 0x04,0x00,0x8a,0x31,0x00,0x00,0x0e,0x24,0x04,0x00,0x8a,0x31,
- 0xea,0xff,0x40,0x11,0x00,0x00,0x00,0x00,0xed,0xff,0x20,0x11,
- 0x00,0x00,0x0e,0x24,0x0d,0x00,0x0a,0x24,0xff,0xff,0x29,0x25,
- 0xe4,0xff,0x00,0x10,0x48,0x00,0xca,0xa0,0x21,0x40,0xc0,0x01,
- 0x08,0x00,0x8a,0x31,0x08,0x00,0x40,0x15,0x00,0x00,0x0e,0x24,
- 0x10,0x00,0x8a,0x31,0xdd,0xff,0x40,0x11,0x00,0x00,0x00,0x00,
- 0xdc,0xff,0x00,0x11,0x00,0x00,0x00,0x00,0xda,0xff,0x00,0x10,
- 0x48,0x00,0xc3,0xa0,0xd7,0xff,0x00,0x10,0x0a,0x00,0x03,0x24,
- 0x21,0x40,0xc0,0x01,0x07,0x00,0x08,0x31,0x07,0x00,0x08,0x39,
- 0x2b,0x08,0x28,0x01,0xd6,0xff,0x20,0x14,0x00,0x00,0x00,0x00,
- 0x08,0x00,0xce,0x25,0x23,0x48,0x28,0x01,0xf8,0xff,0xce,0x31,
- 0x20,0x00,0x03,0x24,0xff,0xff,0x08,0x25,0xfe,0xff,0x01,0x05,
- 0x48,0x00,0xc3,0xa0,0xca,0xff,0x00,0x10,0x01,0x00,0xd6,0x26,
- 0x00,0x80,0x08,0x3c,0xbf,0xff,0xe7,0x30,0x34,0x36,0x08,0x25,
- 0x4b,0x00,0x80,0xa0,0x50,0x00,0x87,0xa4,0x13,0x0e,0x00,0x08,
- 0x04,0x00,0x88,0xac,0x00,0x00,0x88,0x8c,0x74,0x00,0x9f,0xac,
- 0x63,0x00,0x8e,0xa0,0x0c,0x00,0xb6,0xa4,0x04,0x00,0x09,0x8d,
- 0x44,0x00,0x92,0xac,0x08,0x00,0x20,0x01,0x21,0x20,0x00,0x01,
- 0x00,0x80,0x0a,0x3c,0x20,0x3d,0x4a,0x25,0x49,0x00,0x88,0x90,
- 0x4a,0x00,0x89,0x90,0x0e,0x00,0x00,0x10,0x04,0x00,0x8a,0xac,
- 0x24,0x00,0x86,0x8c,0x50,0x00,0x87,0x94,0x08,0x00,0xc2,0x90,
- 0x25,0x28,0x91,0x00,0xc0,0x47,0x02,0x00,0xd4,0xfe,0x11,0x05,
- 0x42,0x42,0x07,0x00,0x44,0x00,0x92,0x8c,0x49,0x00,0x88,0x90,
- 0x4a,0x00,0x89,0x90,0x23,0x90,0x50,0x02,0xc5,0xfe,0x41,0x06,
- 0x00,0x00,0x00,0x00,0x18,0x00,0xca,0x90,0x0a,0x00,0xb5,0x94,
- 0x0c,0x00,0xb6,0x94,0x24,0x40,0x0a,0x01,0xb9,0xfe,0x09,0x15,
- 0x00,0x00,0x00,0x00,0x74,0x00,0x88,0x8c,0x40,0x00,0x93,0x8c,
- 0x3c,0x00,0x94,0x8c,0x0e,0x00,0x97,0x94,0x2a,0x00,0x8c,0x94,
- 0x62,0x00,0x8d,0x90,0x63,0x00,0x8e,0x90,0x09,0xf8,0x00,0x01,
- 0x00,0x00,0x00,0x00,0xa5,0xfe,0xb6,0x12,0x21,0x40,0x96,0x02,
- 0x00,0x00,0x03,0x91,0x01,0x00,0xd6,0x26,0x24,0x40,0x6d,0x00,
- 0x80,0x40,0x08,0x00,0x21,0x08,0x1c,0x01,0xb0,0x80,0x28,0x8c,
- 0x24,0xb0,0xd7,0x02,0x08,0x00,0x00,0x01,0x00,0x00,0x00,0x00,
- 0x01,0x00,0xce,0x25,0x21,0x90,0x53,0x02,0xc8,0xff,0x41,0x06,
- 0x00,0x00,0xc3,0xa0,0xc6,0xff,0xb6,0x12,0x21,0x40,0x96,0x02,
- 0x00,0x00,0x03,0x91,0x01,0x00,0xd6,0x26,0x24,0x40,0x6d,0x00,
- 0x80,0x40,0x08,0x00,0x21,0x08,0x1c,0x01,0xb0,0x80,0x28,0x8c,
- 0x24,0xb0,0xd7,0x02,0x08,0x00,0x00,0x01,0x00,0x00,0x00,0x00,
- 0x01,0x00,0x88,0x31,0xef,0xff,0x00,0x11,0x00,0x00,0x00,0x00,
- 0x18,0x00,0x00,0x10,0x27,0x00,0x03,0x24,0x01,0x00,0x88,0x31,
- 0xea,0xff,0x00,0x11,0x00,0x00,0x00,0x00,0x13,0x00,0x00,0x10,
- 0x28,0x00,0x03,0x24,0x01,0x00,0x88,0x31,0xe5,0xff,0x00,0x11,
- 0x00,0x00,0x00,0x00,0x0e,0x00,0x00,0x10,0x21,0x00,0x03,0x24,
- 0x01,0x00,0x88,0x31,0xe0,0xff,0x00,0x11,0x00,0x00,0x00,0x00,
- 0x09,0x00,0x00,0x10,0x29,0x00,0x03,0x24,0x01,0x00,0x88,0x31,
- 0xdb,0xff,0x00,0x11,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x10,
- 0x5e,0x00,0x03,0x24,0x01,0x00,0x88,0x31,0xd6,0xff,0x00,0x11,
- 0x00,0x00,0x00,0x00,0x5c,0x00,0x08,0x24,0x21,0x90,0x53,0x02,
- 0x00,0x00,0xc8,0xa0,0xd2,0xff,0x40,0x06,0x02,0x00,0xce,0x25,
- 0x3a,0x0f,0x00,0x0c,0x61,0x00,0x83,0xa0,0x61,0x00,0x83,0x90,
- 0xce,0xff,0x00,0x10,0x21,0x90,0x53,0x02,0x02,0x00,0x88,0x31,
- 0xc9,0xff,0x00,0x11,0x00,0x00,0x00,0x00,0xc7,0xff,0x00,0x10,
- 0xe0,0xff,0x63,0x24,0x02,0x00,0xc0,0x11,0x00,0x20,0x89,0x31,
- 0xff,0xff,0xce,0x25,0xc3,0xff,0x20,0x11,0x02,0x00,0x08,0x24,
- 0x53,0x00,0x00,0x10,0x21,0x90,0x53,0x02,0x42,0x4a,0x0c,0x00,
- 0x0c,0x00,0x29,0x31,0x21,0x08,0x3c,0x01,0x30,0x89,0x29,0x8c,
- 0x21,0x40,0xc0,0x01,0x08,0x00,0xce,0x25,0x08,0x00,0x20,0x01,
- 0xf8,0xff,0xce,0x31,0x23,0x40,0xc8,0x01,0x05,0x00,0x01,0x29,
- 0xb5,0xff,0x20,0x14,0x00,0x00,0x00,0x00,0x45,0x00,0x00,0x10,
- 0x21,0x90,0x53,0x02,0x42,0x00,0x00,0x10,0x02,0x00,0x08,0x24,
- 0x23,0x40,0xc8,0x01,0xff,0xff,0x08,0x25,0xad,0xff,0x00,0x19,
- 0x20,0x00,0x03,0x24,0x21,0x90,0x53,0x02,0xfb,0xff,0x40,0x06,
- 0x00,0x00,0xc3,0xa0,0x3a,0x0f,0x00,0x0c,0x61,0x00,0x88,0xa0,
- 0x61,0x00,0x88,0x90,0xf7,0xff,0x00,0x10,0xff,0xff,0x08,0x25,
- 0x00,0x40,0x89,0x31,0xa2,0xff,0x20,0x11,0x00,0x00,0x00,0x00,
- 0x31,0x00,0x00,0x10,0x7f,0x00,0x08,0x24,0x00,0x80,0x89,0x31,
- 0x9d,0xff,0x20,0x11,0x00,0x00,0x00,0x00,0x2c,0x00,0x00,0x10,
- 0x7f,0x00,0x08,0x24,0x20,0x00,0x8a,0x31,0x21,0x40,0xc0,0x01,
- 0x18,0x00,0x40,0x15,0x04,0x00,0x89,0x31,0x08,0x00,0x20,0x11,
- 0x0d,0x00,0x0a,0x24,0x21,0x90,0x53,0x02,0x00,0x00,0x0e,0x24,
- 0x04,0x00,0x40,0x06,0x00,0x00,0xca,0xa0,0x3a,0x0f,0x00,0x0c,
- 0x00,0x00,0x00,0x00,0x0a,0x00,0x03,0x24,0x00,0x01,0x88,0x31,
- 0x8b,0xff,0x00,0x11,0x00,0x00,0x00,0x00,0x1a,0x00,0x00,0x10,
- 0x05,0x00,0x08,0x24,0x21,0x40,0xc0,0x01,0x08,0x00,0x89,0x31,
- 0x0d,0x00,0x20,0x15,0x00,0x00,0x0e,0x24,0x10,0x00,0x8a,0x31,
- 0x03,0x00,0x40,0x11,0x00,0x00,0x00,0x00,0x83,0xff,0x00,0x11,
- 0x00,0x00,0x00,0x00,0xc2,0x49,0x0c,0x00,0x0c,0x00,0x29,0x31,
- 0x21,0x08,0x3c,0x01,0x40,0x89,0x29,0x8c,0x00,0x00,0x0e,0x24,
- 0x08,0x00,0x20,0x01,0x00,0x00,0x00,0x00,0xea,0xff,0x00,0x10,
- 0x0a,0x00,0x03,0x24,0x02,0x41,0x08,0x00,0x05,0x00,0x00,0x10,
- 0x03,0x00,0x08,0x25,0x03,0x00,0x00,0x10,0x05,0x00,0x08,0x24,
- 0x01,0x00,0x00,0x10,0x09,0x00,0x08,0x24,0x21,0x90,0x53,0x02,
- 0x05,0x00,0x40,0x06,0x00,0x00,0xc3,0xa0,0x3a,0x0f,0x00,0x0c,
- 0x61,0x00,0x88,0xa0,0x61,0x00,0x88,0x90,0x00,0x00,0x00,0x00,
- 0x40,0x00,0x89,0x31,0x0f,0x00,0x20,0x11,0x20,0x00,0x01,0x29,
- 0x0d,0x00,0x20,0x10,0x00,0x00,0x00,0x00,0x60,0x00,0x83,0x90,
- 0x04,0x00,0x01,0x29,0x60,0xff,0x20,0x14,0x00,0x00,0x00,0x00,
- 0x21,0x90,0x53,0x02,0x5d,0xff,0x40,0x06,0x00,0x00,0xc3,0xa0,
- 0x3a,0x0f,0x00,0x0c,0x00,0x00,0x00,0x00,0x60,0x00,0x83,0x90,
- 0x59,0xff,0x00,0x10,0x21,0x90,0x53,0x02,0x06,0x00,0x08,0x25,
- 0x00,0x1e,0x09,0x24,0x19,0x00,0x09,0x01,0x12,0x40,0x00,0x00,
- 0x21,0x90,0x48,0x02,0x1c,0xff,0x00,0x10,0x00,0x00,0x88,0x8c,
- 0xff,0xe7,0xe7,0x30,0x42,0x42,0x07,0x00,0x7c,0x00,0x08,0x31,
- 0x21,0x08,0x1c,0x01,0xb0,0x88,0x33,0x8c,0x01,0x00,0x00,0x8c,
- 0x08,0x00,0x60,0x02,0x00,0x00,0x00,0x00,0x00,0x80,0x13,0x3c,
- 0x5a,0x00,0xb8,0x90,0x5b,0x00,0xb9,0x90,0x5e,0x00,0x8d,0x90,
- 0xb4,0x40,0x73,0x26,0xff,0xfd,0x68,0x30,0x0a,0x00,0x0d,0x15,
- 0xff,0xf9,0x68,0x30,0x00,0x80,0x13,0x3c,0x30,0x42,0x73,0x26,
- 0x0e,0xfe,0x00,0x10,0x00,0x08,0xe7,0x34,0x00,0x80,0x13,0x3c,
- 0x5a,0x00,0xb8,0x90,0x5b,0x00,0xb9,0x90,0xe0,0x40,0x73,0x26,
- 0xff,0xf9,0x68,0x30,0x05,0x00,0x18,0x11,0x00,0x00,0x00,0x00,
- 0xf9,0xfd,0x19,0x15,0x00,0x00,0x00,0x00,0x13,0x00,0x00,0x10,
- 0x4a,0x00,0x88,0x90,0x4a,0x00,0x88,0x90,0x00,0x00,0x00,0x00,
- 0x08,0x00,0x09,0x31,0x0b,0x00,0x20,0x11,0x00,0x00,0x00,0x00,
- 0xf7,0xff,0x08,0x31,0x4a,0x00,0x88,0xa0,0x54,0x00,0xa9,0x90,
- 0x58,0x00,0xaa,0x90,0xfb,0xff,0x2b,0x31,0x26,0x48,0x2b,0x01,
- 0x25,0x50,0x49,0x01,0x54,0x00,0xab,0xa0,0x0f,0xfe,0x00,0x10,
- 0x58,0x00,0xaa,0xa0,0x0d,0xfe,0x19,0x17,0x00,0x00,0x00,0x00,
- 0x4a,0x00,0x88,0x90,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x35,
- 0x4a,0x00,0x88,0xa0,0x54,0x00,0xa9,0x90,0x58,0x00,0xaa,0x90,
- 0x04,0x00,0x2b,0x35,0x26,0x48,0x2b,0x01,0x25,0x50,0x49,0x01,
- 0x00,0x08,0x89,0x31,0x54,0x00,0xab,0xa0,0x00,0xfe,0x20,0x11,
- 0x58,0x00,0xaa,0xa0,0x00,0x80,0x13,0x3c,0x00,0x10,0xe7,0x34,
- 0xfc,0xfd,0x00,0x10,0x84,0x41,0x73,0x26,0x4a,0x00,0x88,0x90,
- 0xff,0xef,0xe7,0x30,0xf3,0xff,0x08,0x31,0x4a,0x00,0x88,0xa0,
- 0x54,0x00,0xa9,0x90,0x58,0x00,0xaa,0x90,0xfb,0xff,0x2b,0x31,
- 0x26,0x48,0x2b,0x01,0x25,0x50,0x49,0x01,0x42,0x4a,0x07,0x00,
- 0x7c,0x00,0x29,0x31,0x54,0x00,0xab,0xa0,0x58,0x00,0xaa,0xa0,
- 0x21,0x08,0x3c,0x01,0xb0,0x88,0x33,0x8c,0x40,0x00,0x88,0x31,
- 0xea,0xfd,0x00,0x15,0x00,0x00,0x00,0x00,0xff,0xfd,0x68,0x30,
- 0xe7,0xfd,0x0e,0x11,0x00,0x00,0x00,0x00,0xe5,0xfd,0x0f,0x11,
- 0x00,0x00,0x00,0x00,0x00,0x20,0x89,0x31,0x07,0x00,0x20,0x11,
- 0x00,0x00,0x00,0x00,0x5a,0x00,0xaa,0x90,0x5b,0x00,0xab,0x90,
- 0xde,0xfd,0x0a,0x11,0x00,0x00,0x00,0x00,0xdc,0xfd,0x0b,0x11,
- 0x00,0x00,0x00,0x00,0x00,0x20,0x89,0x31,0xbf,0xfd,0x20,0x11,
- 0x21,0x48,0x95,0x02,0x5e,0x00,0x8d,0x90,0x00,0x00,0x00,0x00,
- 0xbb,0xfd,0x0d,0x15,0x21,0x48,0x95,0x02,0x00,0x80,0x13,0x3c,
- 0x00,0x08,0xe7,0x34,0xb6,0xfd,0x00,0x10,0x30,0x42,0x73,0x26,
- 0xff,0xf7,0xe7,0x30,0x42,0x4a,0x07,0x00,0x7c,0x00,0x29,0x31,
- 0x21,0x08,0x3c,0x01,0xb0,0x88,0x33,0x8c,0xb0,0xfd,0x00,0x10,
- 0x21,0x48,0x95,0x02,0x5e,0x00,0x8d,0x90,0xff,0xfd,0x68,0x30,
- 0x9f,0xfd,0x0d,0x15,0x00,0x00,0x00,0x00,0x00,0x80,0x13,0x3c,
- 0x00,0x08,0xe7,0x34,0xa7,0xfd,0x00,0x10,0x30,0x42,0x73,0x26,
- 0x4a,0x00,0x88,0x90,0x00,0x00,0x00,0x00,0x04,0x00,0x09,0x31,
- 0x0b,0x00,0x20,0x11,0x00,0x00,0x00,0x00,0xfb,0xff,0x08,0x31,
- 0x4a,0x00,0x88,0xa0,0x54,0x00,0xa9,0x90,0x58,0x00,0xaa,0x90,
- 0xfb,0xff,0x2b,0x31,0x26,0x48,0x2b,0x01,0x25,0x50,0x49,0x01,
- 0x54,0x00,0xab,0xa0,0xb3,0xfd,0x00,0x10,0x58,0x00,0xaa,0xa0,
- 0xb1,0xfd,0xcf,0x15,0x00,0x00,0x00,0x00,0x4a,0x00,0x88,0x90,
- 0x00,0x00,0x00,0x00,0x04,0x00,0x08,0x35,0x4a,0x00,0x88,0xa0,
- 0x54,0x00,0xa9,0x90,0x58,0x00,0xaa,0x90,0x04,0x00,0x2b,0x35,
- 0x26,0x48,0x2b,0x01,0x25,0x50,0x49,0x01,0x00,0x08,0x89,0x31,
- 0x54,0x00,0xab,0xa0,0xa4,0xfd,0x20,0x11,0x58,0x00,0xaa,0xa0,
- 0x00,0x80,0x13,0x3c,0x00,0x10,0xe7,0x34,0xa0,0xfd,0x00,0x10,
- 0x84,0x41,0x73,0x26,0xc2,0x51,0x03,0x00,0x3c,0x00,0x4a,0x31,
- 0x21,0x08,0x5c,0x01,0xc0,0x92,0x28,0x8c,0x21,0x08,0x5c,0x01,
- 0x00,0x10,0x6a,0x30,0x01,0x00,0x08,0x25,0x0e,0x00,0x40,0x11,
- 0xc0,0x92,0x28,0xac,0x01,0x00,0x8b,0x31,0x94,0xfd,0x60,0x15,
- 0x00,0x00,0x00,0x00,0x02,0x00,0x8a,0x31,0x03,0x00,0x40,0x15,
- 0x00,0x00,0x00,0x00,0x15,0x00,0x00,0x10,0x00,0x10,0x03,0x24,
- 0x4f,0x00,0xa8,0x90,0x00,0x00,0x00,0x00,0x01,0x00,0x08,0x35,
- 0x8a,0xfd,0x00,0x10,0x4f,0x00,0xa8,0xa0,0x04,0x00,0x88,0x31,
- 0x87,0xfd,0x00,0x15,0x00,0x00,0x00,0x00,0x00,0x02,0x6a,0x30,
- 0x0b,0x00,0x40,0x11,0x08,0x00,0x88,0x31,0x4f,0x00,0xa8,0x90,
- 0xff,0xfd,0x63,0x30,0xff,0x00,0x0b,0x24,0x2a,0x08,0x6b,0x00,
- 0x80,0x00,0x08,0x35,0x66,0xfd,0x20,0x14,0x4f,0x00,0xa8,0xa0,
- 0x6d,0xfd,0x6b,0x10,0x00,0x00,0x00,0x00,0x08,0x00,0x88,0x31,
- 0x07,0x00,0x00,0x15,0x00,0x00,0x00,0x00,0x01,0x00,0xb5,0x26,
- 0x24,0xa8,0xb7,0x02,0x74,0xfd,0xb6,0x16,0x00,0x00,0x20,0xa1,
- 0x1a,0x00,0x00,0x10,0xff,0xff,0xb5,0x26,0x01,0x00,0xb5,0x26,
- 0xff,0x00,0x08,0x24,0x24,0xa8,0xb7,0x02,0x14,0x00,0xb6,0x12,
- 0x00,0x00,0x28,0xa1,0x00,0x80,0x89,0x31,0x02,0x00,0x20,0x11,
- 0x00,0x00,0x08,0x24,0x02,0x42,0x03,0x00,0x21,0x48,0x95,0x02,
- 0x01,0x00,0xb5,0x26,0x24,0xa8,0xb7,0x02,0x09,0x00,0xb6,0x12,
- 0x00,0x00,0x28,0xa1,0x21,0x48,0x95,0x02,0x01,0x00,0xb5,0x26,
- 0x24,0xa8,0xb7,0x02,0x5f,0xfd,0xb6,0x16,0x00,0x00,0x23,0xa1,
- 0x02,0x00,0x00,0x10,0xff,0xff,0xb5,0x26,0xff,0xff,0xb5,0x26,
- 0xff,0xff,0xb5,0x26,0x24,0xb0,0xb7,0x02,0xff,0xff,0xb5,0x26,
- 0x4f,0x00,0xa8,0x90,0x24,0xa8,0xb7,0x02,0x40,0x00,0x08,0x35,
- 0x4f,0x00,0xa8,0xa0,0x24,0x00,0x86,0x8c,0x25,0x28,0x91,0x00,
- 0x78,0x00,0xc8,0x90,0x58,0x00,0xaa,0x90,0x21,0x48,0x00,0x01,
- 0x20,0x00,0x29,0x31,0x80,0x48,0x09,0x00,0x50,0x00,0x08,0x31,
- 0x25,0x40,0x09,0x01,0x70,0x00,0xc9,0x90,0x00,0x00,0x00,0x00,
- 0x42,0x48,0x09,0x00,0x20,0x00,0x29,0x31,0x20,0x00,0x29,0x39,
- 0x25,0x40,0x09,0x01,0x54,0x00,0xa9,0x90,0x00,0x00,0x00,0x00,
- 0x26,0x40,0x09,0x01,0xf0,0x00,0x08,0x31,0x26,0x48,0x28,0x01,
- 0x54,0x00,0xa9,0xa0,0x56,0x00,0xa9,0x90,0x00,0x00,0x00,0x00,
- 0x24,0x48,0x28,0x01,0x25,0x50,0x49,0x01,0x08,0x00,0xe0,0x03,
- 0x58,0x00,0xaa,0xa0,0x00,0x00,0x00,0x00,0x00,0x80,0x08,0x3c,
- 0xa8,0x44,0x08,0x25,0x00,0xa0,0x01,0x3c,0x25,0x40,0x01,0x01,
- 0x08,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x60,0x04,0x40,
- 0x00,0x00,0x00,0x00,0x01,0x00,0x05,0x3c,0x00,0x60,0x85,0x40,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa0,0x09,0x3c,
- 0x01,0x00,0x01,0x3c,0x23,0x40,0x21,0x01,0x03,0x00,0x00,0xa1,
- 0x04,0x00,0x08,0x25,0xfd,0xff,0x09,0x15,0x00,0x00,0x00,0x00,
- 0x03,0x00,0x05,0x3c,0x00,0x60,0x85,0x40,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0xa0,0x09,0x3c,0x01,0x00,0x01,0x3c,
- 0x23,0x40,0x21,0x01,0x03,0x00,0x00,0xa1,0x04,0x00,0x08,0x25,
- 0xfd,0xff,0x09,0x15,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x60,0x84,0x40,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x10,0x04,0x40,0xff,0xff,0x08,0x3c,
- 0xff,0x3f,0x08,0x35,0x24,0x20,0x88,0x00,0x00,0x10,0x84,0x40,
- 0x01,0x80,0x08,0x3c,0xfc,0xff,0x01,0x24,0x01,0x80,0x09,0x3c,
- 0x50,0x86,0x08,0x25,0x80,0x95,0x29,0x25,0x24,0x40,0x01,0x01,
- 0x24,0x48,0x21,0x01,0x04,0x00,0x08,0x25,0xfe,0xff,0x09,0x15,
- 0xfc,0xff,0x00,0xad,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,
- 0x00,0x60,0x02,0x40,0xff,0xff,0x01,0x3c,0xfe,0x00,0x21,0x34,
- 0x25,0x20,0x81,0x00,0x24,0x40,0x44,0x00,0x00,0x60,0x88,0x40,
- 0x08,0x00,0xe0,0x03,0x01,0xff,0x42,0x30,0x00,0x60,0x02,0x40,
- 0x00,0x00,0x00,0x00,0x26,0x40,0x44,0x00,0x01,0xff,0x08,0x31,
- 0x26,0x40,0x02,0x01,0x00,0x60,0x88,0x40,0x08,0x00,0xe0,0x03,
- 0x00,0x00,0x00,0x00,0x00,0x60,0x08,0x40,0x00,0x00,0x00,0x00,
- 0xfe,0xff,0x01,0x24,0x24,0x48,0x01,0x01,0x00,0x60,0x89,0x40,
- 0x00,0x68,0x02,0x40,0x00,0x03,0x84,0x30,0x25,0x18,0x44,0x00,
- 0x00,0x68,0x83,0x40,0x00,0x60,0x88,0x40,0x08,0x00,0xe0,0x03,
- 0x24,0x10,0x44,0x00,0x00,0x60,0x08,0x40,0x00,0x03,0x84,0x30,
- 0xfe,0xff,0x01,0x24,0x24,0x48,0x01,0x01,0x00,0x60,0x89,0x40,
- 0x00,0x68,0x02,0x40,0x27,0x18,0x80,0x00,0x24,0x18,0x62,0x00,
- 0x00,0x68,0x83,0x40,0x00,0x60,0x88,0x40,0x08,0x00,0xe0,0x03,
- 0x24,0x10,0x44,0x00,0x40,0x10,0x08,0x3c,0x00,0x60,0x88,0x40,
- 0xc0,0xbf,0x08,0x3c,0x08,0x00,0x00,0x01,0x00,0x00,0x00,0x00,
- 0x00,0x60,0x08,0x40,0x00,0x00,0x00,0x00,0xff,0xff,0x09,0x3c,
- 0xfe,0x00,0x29,0x35,0x00,0x00,0x00,0x00,0x24,0x40,0x09,0x01,
- 0x00,0x00,0x00,0x00,0x25,0x40,0x04,0x01,0x00,0x00,0x00,0x00,
- 0x00,0x60,0x88,0x40,0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x21,0x18,0xa0,0x00,0xe0,0xff,0xbd,0x27,0x17,0x00,0x61,0x2c,
- 0x14,0x00,0xbf,0xaf,0xb1,0x00,0x20,0x10,0x21,0x38,0x80,0x00,
- 0x80,0x70,0x03,0x00,0x00,0x80,0x01,0x3c,0x21,0x08,0x2e,0x00,
- 0xe0,0x7a,0x2e,0x8c,0x00,0x00,0x00,0x00,0x08,0x00,0xc0,0x01,
- 0x00,0x00,0x00,0x00,0x00,0x20,0x01,0x3c,0x1a,0x00,0xe6,0xa4,
- 0x25,0x18,0xe1,0x00,0x12,0x00,0x6f,0x94,0x14,0x00,0x78,0x94,
- 0x16,0x00,0xe8,0x94,0x23,0xc8,0xf8,0x01,0x24,0x48,0x28,0x03,
- 0x2b,0x08,0x26,0x01,0xa2,0x00,0x20,0x10,0x01,0x00,0x02,0x24,
- 0x6c,0x1a,0x00,0x0c,0x21,0x20,0xe0,0x00,0x9e,0x00,0x00,0x10,
- 0x01,0x00,0x02,0x24,0x00,0x20,0x01,0x3c,0x1c,0x00,0xe6,0xa4,
- 0x25,0x18,0xe1,0x00,0x12,0x00,0x6a,0x94,0x14,0x00,0x6b,0x94,
- 0x16,0x00,0xed,0x94,0x23,0x60,0x4b,0x01,0x24,0x70,0x8d,0x01,
- 0x2b,0x08,0xce,0x00,0x93,0x00,0x20,0x10,0x01,0x00,0x02,0x24,
- 0x36,0x1a,0x00,0x0c,0x21,0x20,0xe0,0x00,0x8f,0x00,0x00,0x10,
- 0x01,0x00,0x02,0x24,0x80,0x92,0x84,0x8f,0x58,0x11,0x00,0x0c,
- 0x20,0x00,0xa7,0xaf,0x20,0x00,0xa7,0x8f,0x00,0x20,0x01,0x3c,
- 0x25,0x18,0xe1,0x00,0x0a,0x00,0x6f,0x94,0x21,0x20,0x40,0x00,
- 0x60,0x11,0x00,0x0c,0x0c,0x00,0x6f,0xa4,0x83,0x00,0x00,0x10,
- 0x01,0x00,0x02,0x24,0x80,0x92,0x84,0x8f,0x58,0x11,0x00,0x0c,
- 0x20,0x00,0xa7,0xaf,0x20,0x00,0xa7,0x8f,0x21,0x20,0x40,0x00,
- 0x4a,0x00,0xf8,0x90,0x00,0x00,0x00,0x00,0x04,0x00,0x19,0x37,
- 0x60,0x11,0x00,0x0c,0x4a,0x00,0xf9,0xa0,0x77,0x00,0x00,0x10,
- 0x01,0x00,0x02,0x24,0x80,0x92,0x84,0x8f,0x58,0x11,0x00,0x0c,
- 0x20,0x00,0xa7,0xaf,0x20,0x00,0xa7,0x8f,0x21,0x20,0x40,0x00,
- 0x4a,0x00,0xe8,0x90,0x00,0x00,0x00,0x00,0xf3,0x00,0x09,0x31,
- 0x60,0x11,0x00,0x0c,0x4a,0x00,0xe9,0xa0,0x6b,0x00,0x00,0x10,
- 0x01,0x00,0x02,0x24,0x00,0x20,0x01,0x3c,0x25,0x18,0xe1,0x00,
- 0x5a,0x00,0x66,0xa0,0x02,0x52,0x06,0x00,0x64,0x00,0x00,0x10,
- 0x5b,0x00,0x6a,0xa0,0x04,0x00,0xc0,0x10,0x19,0x00,0x03,0x24,
- 0x02,0x00,0x00,0x10,0x21,0x18,0xc0,0x00,0x19,0x00,0x03,0x24,
- 0x21,0x20,0xe0,0x00,0x66,0x1b,0x00,0x0c,0x21,0x28,0x60,0x00,
- 0x5b,0x00,0x00,0x10,0x01,0x00,0x02,0x24,0x68,0x00,0xeb,0x90,
- 0x02,0x62,0x06,0x00,0x27,0x68,0x80,0x01,0xff,0x00,0xcf,0x30,
- 0x24,0x70,0x6d,0x01,0x25,0x30,0xcf,0x01,0x21,0x28,0xc0,0x00,
- 0x93,0x1b,0x00,0x0c,0x21,0x20,0xe0,0x00,0x50,0x00,0x00,0x10,
- 0x01,0x00,0x02,0x24,0x21,0x20,0xe0,0x00,0xfe,0x1a,0x00,0x0c,
- 0x21,0x28,0xc0,0x00,0x4b,0x00,0x00,0x10,0x01,0x00,0x02,0x24,
- 0x02,0xc2,0x06,0x00,0x5c,0x00,0xe6,0xa0,0x46,0x00,0x00,0x10,
- 0x5d,0x00,0xf8,0xa0,0x44,0x00,0x00,0x10,0x18,0x00,0xe6,0xa4,
- 0x36,0x1a,0x00,0x0c,0x21,0x20,0xe0,0x00,0x41,0x00,0x00,0x10,
- 0x01,0x00,0x02,0x24,0x6c,0x1a,0x00,0x0c,0x21,0x20,0xe0,0x00,
- 0x3d,0x00,0x00,0x10,0x01,0x00,0x02,0x24,0x80,0x92,0x84,0x8f,
- 0x58,0x11,0x00,0x0c,0x20,0x00,0xa7,0xaf,0x20,0x00,0xa7,0x8f,
- 0x21,0x18,0x40,0x00,0x1c,0x00,0xa3,0xaf,0x01,0x1c,0x00,0x0c,
- 0x21,0x20,0xe0,0x00,0x1c,0x00,0xa3,0x8f,0x60,0x11,0x00,0x0c,
- 0x21,0x20,0x60,0x00,0x30,0x00,0x00,0x10,0x01,0x00,0x02,0x24,
- 0x21,0x20,0xe0,0x00,0x3c,0x1b,0x00,0x0c,0x21,0x28,0xc0,0x00,
- 0x2b,0x00,0x00,0x10,0x01,0x00,0x02,0x24,0x5f,0x00,0xf9,0x90,
- 0x02,0x42,0x06,0x00,0x27,0x48,0x00,0x01,0xff,0x00,0xcc,0x30,
- 0x24,0x50,0x29,0x03,0x25,0x30,0x4c,0x01,0x21,0x28,0xc0,0x00,
- 0xca,0x1b,0x00,0x0c,0x21,0x20,0xe0,0x00,0x20,0x00,0x00,0x10,
- 0x01,0x00,0x02,0x24,0x21,0x20,0xe0,0x00,0xa1,0x1a,0x00,0x0c,
- 0x21,0x28,0xc0,0x00,0x1b,0x00,0x00,0x10,0x01,0x00,0x02,0x24,
- 0x80,0x92,0x84,0x8f,0x28,0x00,0xa6,0xaf,0x58,0x11,0x00,0x0c,
- 0x20,0x00,0xa7,0xaf,0x28,0x00,0xa6,0x8f,0x20,0x00,0xa7,0x8f,
- 0xff,0x00,0xcb,0x30,0x21,0x18,0x40,0x00,0x06,0x00,0x60,0x11,
- 0x5e,0x00,0xe6,0xa0,0x50,0x00,0xed,0x94,0x00,0x00,0x00,0x00,
- 0x00,0x20,0xae,0x35,0x05,0x00,0x00,0x10,0x50,0x00,0xee,0xa4,
- 0x50,0x00,0xef,0x94,0x00,0x00,0x00,0x00,0xff,0xd7,0xf8,0x31,
- 0x50,0x00,0xf8,0xa4,0x60,0x11,0x00,0x0c,0x21,0x20,0x60,0x00,
- 0x04,0x00,0x00,0x10,0x01,0x00,0x02,0x24,0x02,0x00,0x00,0x10,
- 0x21,0x10,0x00,0x00,0x01,0x00,0x02,0x24,0x14,0x00,0xbf,0x8f,
- 0x20,0x00,0xbd,0x27,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,
- 0xe0,0xff,0xbd,0x27,0x14,0x00,0xbf,0xaf,0x21,0x38,0x80,0x00,
- 0x48,0x00,0xe2,0x90,0x21,0x18,0xa0,0x00,0x08,0x00,0x41,0x2c,
- 0x07,0x00,0x20,0x10,0x08,0x00,0x01,0x24,0x21,0x20,0xe0,0x00,
- 0x94,0x11,0x00,0x0c,0x21,0x28,0x60,0x00,0xc9,0x00,0x00,0x10,
- 0x14,0x00,0xbf,0x8f,0x08,0x00,0x01,0x24,0x0d,0x00,0x41,0x14,
- 0x00,0x00,0x00,0x00,0x65,0x00,0xee,0x90,0x00,0x00,0x00,0x00,
- 0x80,0x78,0x0e,0x00,0x23,0x78,0xee,0x01,0x80,0x78,0x0f,0x00,
- 0x23,0x78,0xee,0x01,0x80,0x78,0x0f,0x00,0x21,0x08,0xfc,0x01,
- 0x38,0x94,0x38,0x8c,0x04,0x00,0x01,0x24,0x04,0x00,0x01,0x13,
- 0x21,0x28,0x60,0x00,0xb7,0x00,0x00,0x10,0x01,0x00,0x02,0x24,
- 0x21,0x28,0x60,0x00,0x17,0x00,0xa1,0x2c,0xb0,0x00,0x20,0x10,
- 0x00,0x00,0x00,0x00,0x80,0xc8,0x05,0x00,0x00,0x80,0x01,0x3c,
- 0x21,0x08,0x39,0x00,0x3c,0x7b,0x39,0x8c,0x00,0x00,0x00,0x00,
- 0x08,0x00,0x20,0x03,0x00,0x00,0x00,0x00,0x00,0x20,0x01,0x3c,
- 0x1a,0x00,0xe6,0xa4,0x25,0x18,0xe1,0x00,0x12,0x00,0x68,0x94,
- 0x14,0x00,0x69,0x94,0x16,0x00,0xeb,0x94,0x23,0x50,0x09,0x01,
- 0x24,0x60,0x4b,0x01,0x2b,0x08,0x86,0x01,0xa1,0x00,0x20,0x10,
- 0x01,0x00,0x02,0x24,0xb3,0x1c,0x00,0x0c,0x21,0x20,0xe0,0x00,
- 0x9d,0x00,0x00,0x10,0x01,0x00,0x02,0x24,0x00,0x20,0x01,0x3c,
- 0x1c,0x00,0xe6,0xa4,0x25,0x18,0xe1,0x00,0x12,0x00,0x6d,0x94,
- 0x14,0x00,0x6e,0x94,0x16,0x00,0xf8,0x94,0x23,0x78,0xae,0x01,
- 0x24,0xc8,0xf8,0x01,0x2b,0x08,0xd9,0x00,0x92,0x00,0x20,0x10,
- 0x01,0x00,0x02,0x24,0x8a,0x1c,0x00,0x0c,0x21,0x20,0xe0,0x00,
- 0x8e,0x00,0x00,0x10,0x01,0x00,0x02,0x24,0x80,0x92,0x84,0x8f,
- 0x58,0x11,0x00,0x0c,0x20,0x00,0xa7,0xaf,0x20,0x00,0xa7,0x8f,
- 0x00,0x20,0x01,0x3c,0x25,0x18,0xe1,0x00,0x0a,0x00,0x68,0x94,
- 0x21,0x20,0x40,0x00,0x60,0x11,0x00,0x0c,0x0c,0x00,0x68,0xa4,
- 0x82,0x00,0x00,0x10,0x01,0x00,0x02,0x24,0x80,0x92,0x84,0x8f,
- 0x58,0x11,0x00,0x0c,0x20,0x00,0xa7,0xaf,0x20,0x00,0xa7,0x8f,
- 0x21,0x20,0x40,0x00,0x4a,0x00,0xe9,0x90,0x00,0x00,0x00,0x00,
- 0x04,0x00,0x2a,0x35,0x60,0x11,0x00,0x0c,0x4a,0x00,0xea,0xa0,
- 0x76,0x00,0x00,0x10,0x01,0x00,0x02,0x24,0x80,0x92,0x84,0x8f,
- 0x58,0x11,0x00,0x0c,0x20,0x00,0xa7,0xaf,0x20,0x00,0xa7,0x8f,
- 0x21,0x20,0x40,0x00,0x4a,0x00,0xeb,0x90,0x00,0x00,0x00,0x00,
- 0xf3,0x00,0x6c,0x31,0x60,0x11,0x00,0x0c,0x4a,0x00,0xec,0xa0,
- 0x6a,0x00,0x00,0x10,0x01,0x00,0x02,0x24,0x00,0x20,0x01,0x3c,
- 0x25,0x18,0xe1,0x00,0x5a,0x00,0x66,0xa0,0x02,0x6a,0x06,0x00,
- 0x63,0x00,0x00,0x10,0x5b,0x00,0x6d,0xa0,0x04,0x00,0xc0,0x10,
- 0x19,0x00,0x05,0x24,0x02,0x00,0x00,0x10,0x21,0x28,0xc0,0x00,
- 0x19,0x00,0x05,0x24,0x88,0x1c,0x00,0x0c,0x21,0x20,0xe0,0x00,
- 0x5b,0x00,0x00,0x10,0x01,0x00,0x02,0x24,0x68,0x00,0xee,0x90,
- 0x02,0x7a,0x06,0x00,0x27,0xc0,0xe0,0x01,0xff,0x00,0xc8,0x30,
- 0x24,0xc8,0xd8,0x01,0x25,0x30,0x28,0x03,0x21,0x28,0xc0,0x00,
- 0xcc,0x1d,0x00,0x0c,0x21,0x20,0xe0,0x00,0x50,0x00,0x00,0x10,
- 0x01,0x00,0x02,0x24,0x21,0x20,0xe0,0x00,0x63,0x1d,0x00,0x0c,
- 0x21,0x28,0xc0,0x00,0x4b,0x00,0x00,0x10,0x01,0x00,0x02,0x24,
- 0x02,0x4a,0x06,0x00,0x5c,0x00,0xe6,0xa0,0x46,0x00,0x00,0x10,
- 0x5d,0x00,0xe9,0xa0,0x44,0x00,0x00,0x10,0x18,0x00,0xe6,0xa4,
- 0x8a,0x1c,0x00,0x0c,0x21,0x20,0xe0,0x00,0x41,0x00,0x00,0x10,
- 0x01,0x00,0x02,0x24,0xb3,0x1c,0x00,0x0c,0x21,0x20,0xe0,0x00,
- 0x3d,0x00,0x00,0x10,0x01,0x00,0x02,0x24,0x80,0x92,0x84,0x8f,
- 0x58,0x11,0x00,0x0c,0x20,0x00,0xa7,0xaf,0x20,0x00,0xa7,0x8f,
- 0x21,0x18,0x40,0x00,0x1c,0x00,0xa3,0xaf,0xdb,0x1d,0x00,0x0c,
- 0x21,0x20,0xe0,0x00,0x1c,0x00,0xa3,0x8f,0x60,0x11,0x00,0x0c,
- 0x21,0x20,0x60,0x00,0x30,0x00,0x00,0x10,0x01,0x00,0x02,0x24,
- 0x21,0x20,0xe0,0x00,0x98,0x1d,0x00,0x0c,0x21,0x28,0xc0,0x00,
- 0x2b,0x00,0x00,0x10,0x01,0x00,0x02,0x24,0x5f,0x00,0xea,0x90,
- 0x02,0x5a,0x06,0x00,0x27,0x60,0x60,0x01,0xff,0x00,0xcf,0x30,
- 0x24,0x68,0x4c,0x01,0x25,0x30,0xaf,0x01,0x21,0x28,0xc0,0x00,
- 0xdb,0x1c,0x00,0x0c,0x21,0x20,0xe0,0x00,0x20,0x00,0x00,0x10,
- 0x01,0x00,0x02,0x24,0x21,0x20,0xe0,0x00,0x72,0x1d,0x00,0x0c,
- 0x21,0x28,0xc0,0x00,0x1b,0x00,0x00,0x10,0x01,0x00,0x02,0x24,
- 0x80,0x92,0x84,0x8f,0x28,0x00,0xa6,0xaf,0x58,0x11,0x00,0x0c,
- 0x20,0x00,0xa7,0xaf,0x28,0x00,0xa6,0x8f,0x20,0x00,0xa7,0x8f,
- 0xff,0x00,0xce,0x30,0x21,0x18,0x40,0x00,0x06,0x00,0xc0,0x11,
- 0x5e,0x00,0xe6,0xa0,0x50,0x00,0xf8,0x94,0x00,0x00,0x00,0x00,
- 0x00,0x20,0x19,0x37,0x05,0x00,0x00,0x10,0x50,0x00,0xf9,0xa4,
- 0x50,0x00,0xe8,0x94,0x00,0x00,0x00,0x00,0xff,0xd7,0x09,0x31,
- 0x50,0x00,0xe9,0xa4,0x60,0x11,0x00,0x0c,0x21,0x20,0x60,0x00,
- 0x04,0x00,0x00,0x10,0x01,0x00,0x02,0x24,0x02,0x00,0x00,0x10,
- 0x21,0x10,0x00,0x00,0x01,0x00,0x02,0x24,0x14,0x00,0xbf,0x8f,
- 0x20,0x00,0xbd,0x27,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,
- 0xa0,0xff,0xbd,0x27,0x1c,0x00,0xbf,0xaf,0x18,0x00,0xb1,0xaf,
- 0x00,0xa3,0x0e,0x3c,0x10,0x0d,0xc7,0x95,0x00,0xa3,0x0f,0x3c,
- 0x12,0x0d,0xf1,0x95,0xfc,0x03,0xe7,0x30,0xfc,0x03,0x31,0x32,
- 0x51,0x00,0xf1,0x10,0x1c,0x00,0xbf,0x8f,0x3c,0x00,0xb2,0xaf,
- 0x34,0x00,0xb4,0xaf,0x30,0x00,0xb5,0xaf,0x28,0x00,0xb7,0xaf,
- 0x24,0x00,0xbe,0xaf,0x00,0xa3,0x1e,0x3c,0x00,0xa3,0x17,0x3c,
- 0x00,0x83,0x15,0x3c,0x00,0xa3,0x14,0x3c,0x00,0xa3,0x12,0x3c,
- 0x38,0x00,0xb3,0xaf,0x2c,0x00,0xb6,0xaf,0x10,0x94,0x96,0x27,
- 0x54,0x00,0xb3,0x27,0x18,0x0d,0x52,0x36,0x00,0x04,0x94,0x36,
- 0x00,0x10,0xb5,0x36,0x1a,0x0d,0xf7,0x36,0x00,0x08,0xde,0x37,
- 0x40,0x00,0xb0,0xaf,0x83,0xc0,0x11,0x00,0x80,0xc8,0x18,0x00,
- 0x21,0x80,0x99,0x02,0x03,0x00,0x01,0x8a,0x00,0x00,0x01,0x9a,
- 0x00,0x00,0x00,0x00,0x03,0x00,0x61,0xaa,0x00,0x00,0x61,0xba,
- 0x55,0x00,0xa9,0x93,0x08,0x94,0x8b,0x8f,0xc0,0x51,0x09,0x00,
- 0x2b,0x08,0x2b,0x01,0x11,0x00,0x20,0x10,0x21,0x20,0xaa,0x02,
- 0x5c,0x00,0xa7,0xaf,0x65,0x00,0x8c,0x90,0x54,0x00,0xa5,0x93,
- 0x80,0x68,0x0c,0x00,0x23,0x68,0xac,0x01,0x80,0x68,0x0d,0x00,
- 0x23,0x68,0xac,0x01,0x80,0x68,0x0d,0x00,0x21,0x70,0xcd,0x02,
- 0x10,0x00,0xcf,0x8d,0x56,0x00,0xa6,0x97,0x09,0xf8,0xe0,0x01,
- 0x1f,0x00,0xa5,0x30,0x5c,0x00,0xa7,0x8f,0x10,0x00,0x40,0x14,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x42,0x96,0x03,0x00,0x01,0x8a,
- 0xfc,0x03,0x42,0x30,0x83,0xc0,0x02,0x00,0x00,0x00,0xe3,0x96,
- 0x00,0x00,0x01,0x9a,0x80,0xc8,0x18,0x00,0x21,0x40,0xd9,0x03,
- 0x04,0x00,0x42,0x24,0xfc,0x03,0x42,0x30,0xfc,0x03,0x63,0x30,
- 0x03,0x00,0x01,0xa9,0x02,0x00,0x43,0x10,0x00,0x00,0x01,0xb9,
- 0x00,0x00,0x42,0xa6,0x04,0x00,0x31,0x26,0xfc,0x03,0x31,0x32,
- 0x00,0xa3,0x09,0x3c,0xcf,0xff,0xf1,0x14,0x12,0x0d,0x31,0xa5,
- 0x40,0x00,0xb0,0x8f,0x3c,0x00,0xb2,0x8f,0x38,0x00,0xb3,0x8f,
- 0x34,0x00,0xb4,0x8f,0x30,0x00,0xb5,0x8f,0x2c,0x00,0xb6,0x8f,
- 0x28,0x00,0xb7,0x8f,0x24,0x00,0xbe,0x8f,0x00,0x00,0x00,0x00,
- 0x1c,0x00,0xbf,0x8f,0x18,0x00,0xb1,0x8f,0x08,0x00,0xe0,0x03,
- 0x60,0x00,0xbd,0x27,0x78,0xff,0xbd,0x27,0x2c,0x00,0xbf,0xaf,
- 0xc0,0x94,0x84,0x8f,0x28,0x00,0xb7,0xaf,0x24,0x00,0xb5,0xaf,
- 0x60,0x11,0x00,0x0c,0x20,0x00,0xb0,0xaf,0x00,0xa3,0x0e,0x3c,
- 0x30,0x0c,0xcf,0x91,0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x11,
- 0x00,0x00,0x00,0x00,0x00,0xa3,0x18,0x3c,0x32,0x0c,0x19,0x93,
- 0x00,0x00,0x00,0x00,0x03,0x00,0x20,0x17,0x00,0x00,0x00,0x00,
- 0x64,0x17,0x00,0x0c,0x00,0x00,0x00,0x00,0x90,0x92,0x88,0x8f,
- 0x08,0x94,0x8a,0x8f,0x00,0xa3,0x09,0x3c,0x6c,0x00,0xa8,0xaf,
- 0x12,0x0d,0x35,0x95,0x00,0x83,0x17,0x3c,0x00,0x10,0xf7,0x36,
- 0xd7,0x00,0x40,0x19,0x78,0x00,0xa0,0xaf,0x34,0x00,0xbe,0xaf,
- 0x00,0xa3,0x1e,0x3c,0xe8,0x94,0x8b,0x27,0x4c,0x00,0xab,0xaf,
- 0x10,0x0d,0xde,0x37,0x48,0x00,0xb1,0xaf,0x44,0x00,0xb2,0xaf,
- 0x40,0x00,0xb3,0xaf,0x3c,0x00,0xb4,0xaf,0x38,0x00,0xb6,0xaf,
- 0x00,0x20,0x01,0x3c,0x25,0x90,0xe1,0x02,0x0a,0x00,0x53,0x96,
- 0x0c,0x00,0x54,0x96,0x4f,0x00,0x4c,0x92,0x70,0x00,0x4d,0x96,
- 0x78,0x00,0xaf,0x8f,0x54,0x89,0x98,0x8f,0x2f,0x00,0xae,0x35,
- 0x2a,0x08,0xf8,0x01,0x0a,0x00,0x20,0x10,0x24,0xb0,0x8e,0x01,
- 0x50,0x89,0x99,0x8f,0x00,0x00,0x00,0x00,0x2a,0x08,0xf9,0x01,
- 0x05,0x00,0x20,0x14,0x00,0x00,0x00,0x00,0x0e,0x00,0xe9,0x96,
- 0xff,0xff,0x88,0x26,0x24,0x98,0x09,0x01,0x0a,0x00,0x53,0xa6,
- 0x12,0x00,0x74,0x12,0x00,0x00,0x00,0x00,0x50,0x00,0xea,0x96,
- 0x00,0x00,0x00,0x00,0x40,0x00,0x4b,0x31,0x0d,0x00,0x60,0x15,
- 0x00,0x00,0x00,0x00,0x80,0x92,0x84,0x8f,0x00,0x80,0x10,0x3c,
- 0x58,0x11,0x00,0x0c,0xa4,0x35,0x10,0x26,0x50,0x00,0xec,0x96,
- 0x01,0x00,0x0d,0x24,0x40,0x00,0x8e,0x35,0x4b,0x00,0xed,0xa2,
- 0x50,0x00,0xee,0xa6,0x04,0x00,0xf0,0xae,0x60,0x11,0x00,0x0c,
- 0x21,0x20,0x40,0x00,0x4c,0x00,0x58,0x92,0x00,0x00,0x00,0x00,
- 0x05,0x00,0x00,0x13,0x00,0x00,0x00,0x00,0x03,0x00,0x74,0x16,
- 0x00,0x00,0x00,0x00,0x04,0x00,0xd6,0x36,0x4c,0x00,0x40,0xa2,
- 0x4d,0x00,0x4f,0x92,0x00,0x00,0x00,0x00,0x0a,0x00,0xe0,0x11,
- 0x00,0x00,0x00,0x00,0x0e,0x00,0xe8,0x96,0x18,0x00,0xea,0x96,
- 0x23,0xc8,0x74,0x02,0x24,0x48,0x28,0x03,0x2b,0x08,0x49,0x01,
- 0x03,0x00,0x20,0x14,0x00,0x00,0x00,0x00,0x02,0x00,0xd6,0x36,
- 0x4d,0x00,0x40,0xa2,0x50,0x00,0xeb,0x96,0x12,0x00,0x53,0x96,
- 0x14,0x00,0x54,0x96,0x01,0x00,0x6d,0x31,0x0a,0x00,0xa0,0x11,
- 0x00,0x00,0x00,0x00,0x16,0x00,0xee,0x96,0x1a,0x00,0xef,0x96,
- 0x23,0x60,0x74,0x02,0x24,0xc0,0x8e,0x01,0x2b,0x08,0x0f,0x03,
- 0x03,0x00,0x20,0x10,0x00,0x00,0x00,0x00,0x6c,0x1a,0x00,0x0c,
- 0x21,0x20,0xe0,0x02,0x4e,0x00,0x59,0x92,0x00,0x00,0x00,0x00,
- 0x1d,0x00,0x20,0x13,0x4c,0x00,0xa9,0x8f,0x1b,0x00,0x74,0x12,
- 0x4c,0x00,0xa9,0x8f,0x16,0x00,0xe2,0x96,0x23,0x40,0x74,0x02,
- 0x24,0x48,0x02,0x01,0x42,0x50,0x02,0x00,0x2b,0x08,0x49,0x01,
- 0x0f,0x00,0x20,0x14,0x00,0x00,0x00,0x00,0x6c,0x00,0xab,0x8f,
- 0x20,0x00,0x4d,0x96,0x22,0x00,0x58,0x96,0x23,0x60,0x6d,0x01,
- 0xff,0xff,0x8e,0x31,0x2b,0x08,0xd8,0x01,0x07,0x00,0x20,0x10,
- 0x00,0x00,0x00,0x00,0x4c,0x00,0xaf,0x8f,0x00,0x00,0x00,0x00,
- 0x00,0x00,0xf9,0x95,0x00,0x00,0x00,0x00,0x06,0x00,0x79,0x16,
- 0x4c,0x00,0xa9,0x8f,0x4e,0x00,0x40,0xa2,0x6c,0x00,0xa8,0x8f,
- 0x08,0x00,0xd6,0x36,0x20,0x00,0x48,0xa6,0x4c,0x00,0xa9,0x8f,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x33,0xa5,0x54,0x00,0x4a,0x92,
- 0x57,0x00,0x4b,0x92,0x56,0x00,0x4c,0x92,0x58,0x00,0x58,0x92,
- 0x26,0x68,0x4b,0x01,0x24,0x70,0xac,0x01,0x25,0x78,0xd8,0x01,
- 0x02,0x00,0xe0,0x11,0x00,0x00,0x00,0x00,0x20,0x00,0xd6,0x36,
- 0x33,0x00,0xc0,0x12,0x00,0x00,0x00,0x00,0x00,0xa3,0x19,0x3c,
- 0x18,0x0d,0x33,0x97,0x00,0xa3,0x08,0x3c,0xfc,0x03,0x73,0x32,
- 0x1a,0x0d,0x14,0x95,0x83,0x88,0x13,0x00,0x00,0xa3,0x01,0x3c,
- 0x04,0x00,0x73,0x26,0x00,0x08,0x21,0x34,0x80,0x88,0x11,0x00,
- 0xfc,0x03,0x73,0x32,0xfc,0x03,0x94,0x32,0x0c,0x00,0x74,0x16,
- 0x21,0x88,0x21,0x02,0x80,0x92,0x84,0x8f,0x58,0x11,0x00,0x0c,
- 0x00,0x00,0x00,0x00,0x4f,0x00,0x49,0x92,0xff,0x00,0xca,0x32,
- 0x25,0x58,0x2a,0x01,0x4f,0x00,0x4b,0xa2,0x60,0x11,0x00,0x0c,
- 0x21,0x20,0x40,0x00,0x1e,0x00,0x00,0x10,0x00,0x00,0xc9,0x97,
- 0x78,0x00,0xad,0x8f,0x00,0x00,0x00,0x00,0x00,0x00,0x2d,0xa2,
- 0x01,0x00,0x36,0xa2,0x57,0x00,0x50,0x92,0x00,0x00,0x00,0x00,
- 0x03,0x00,0x30,0xa2,0x80,0x92,0x84,0x8f,0x58,0x11,0x00,0x0c,
- 0x00,0x00,0x00,0x00,0x54,0x00,0x4c,0x92,0x58,0x00,0x58,0x92,
- 0x26,0x70,0x90,0x01,0x58,0x00,0x40,0xa2,0x25,0x78,0xd8,0x01,
- 0x26,0x80,0x0f,0x02,0x4f,0x00,0x40,0xa2,0x60,0x11,0x00,0x0c,
- 0x21,0x20,0x40,0x00,0xff,0x00,0x02,0x32,0x02,0x00,0x22,0xa2,
- 0x57,0x00,0x42,0xa2,0x00,0xa3,0x19,0x3c,0x04,0x00,0x00,0x10,
- 0x18,0x0d,0x33,0xa7,0x54,0x00,0x48,0x92,0x00,0x00,0x00,0x00,
- 0x57,0x00,0x48,0xa2,0x00,0x00,0xc9,0x97,0x00,0x00,0x00,0x00,
- 0x0a,0x00,0xa9,0x12,0x78,0x00,0xad,0x8f,0x29,0x13,0x00,0x0c,
- 0x00,0x00,0x00,0x00,0x00,0xa3,0x0a,0x3c,0x12,0x0d,0x55,0x95,
- 0x00,0x00,0xcb,0x97,0x00,0x00,0x00,0x00,0xf9,0xff,0xab,0x16,
- 0x00,0x00,0x00,0x00,0x78,0x00,0xad,0x8f,0x4c,0x00,0xae,0x8f,
- 0x08,0x94,0x8f,0x8f,0x01,0x00,0xac,0x25,0x02,0x00,0xd8,0x25,
- 0x2a,0x08,0x8f,0x01,0x4c,0x00,0xb8,0xaf,0x78,0x00,0xac,0xaf,
- 0x3c,0xff,0x20,0x14,0x80,0x00,0xf7,0x26,0x48,0x00,0xb1,0x8f,
- 0x44,0x00,0xb2,0x8f,0x40,0x00,0xb3,0x8f,0x3c,0x00,0xb4,0x8f,
- 0x38,0x00,0xb6,0x8f,0x34,0x00,0xbe,0x8f,0x00,0x00,0x00,0x00,
- 0x00,0xa3,0x10,0x3c,0x04,0x0e,0x10,0x36,0x00,0x00,0x19,0x96,
- 0x00,0x00,0x00,0x00,0x22,0x00,0x20,0x13,0x00,0x00,0x00,0x00,
- 0xc8,0x94,0x82,0x8f,0x00,0x00,0x00,0x00,0xff,0xff,0x42,0x24,
- 0x1d,0x00,0x40,0x1c,0xc8,0x94,0x82,0xaf,0x00,0xa3,0x08,0x3c,
- 0x1a,0x0d,0x09,0x95,0x00,0xa3,0x0a,0x3c,0x18,0x0d,0x4b,0x95,
- 0x00,0x00,0x00,0x00,0x13,0x00,0x2b,0x11,0x00,0x00,0x00,0x00,
- 0x80,0x92,0x84,0x8f,0x58,0x11,0x00,0x0c,0x00,0x00,0x00,0x00,
- 0xc4,0x94,0x82,0x8f,0x00,0xa1,0x03,0x3c,0x00,0x80,0x63,0x34,
- 0x00,0xa3,0x05,0x3c,0x01,0x00,0x4d,0x34,0x06,0x0e,0xa5,0x34,
- 0x00,0x00,0x6d,0xa4,0x00,0x00,0xae,0x94,0x00,0x00,0x00,0x00,
- 0x01,0x00,0xd8,0x25,0x00,0x00,0xb8,0xa4,0x00,0x00,0x62,0xa4,
- 0xc0,0x94,0x84,0x8f,0x60,0x11,0x00,0x0c,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x02,0x96,0x00,0x00,0x00,0x00,0xc8,0x94,0x82,0xaf,
- 0x33,0x18,0x00,0x0c,0x0a,0x00,0x04,0x24,0x2c,0x00,0xbf,0x8f,
- 0x20,0x00,0xb0,0x8f,0x24,0x00,0xb5,0x8f,0x28,0x00,0xb7,0x8f,
- 0x08,0x00,0xe0,0x03,0x88,0x00,0xbd,0x27,0xc0,0xff,0xbd,0x27,
- 0x18,0x00,0xb0,0xaf,0x00,0x83,0x10,0x3c,0x00,0x10,0x10,0x36,
- 0x3c,0x00,0xbf,0xaf,0x00,0x83,0x05,0x3c,0x38,0x00,0xbe,0xaf,
- 0x30,0x00,0xb6,0xaf,0x34,0x00,0xb7,0xaf,0x28,0x00,0xb4,0xaf,
- 0x2c,0x00,0xb5,0xaf,0x20,0x00,0xb2,0xaf,0x24,0x00,0xb3,0xaf,
- 0x1c,0x00,0xb1,0xaf,0x00,0x30,0xa5,0x34,0xe8,0x15,0x00,0x0c,
- 0x21,0x20,0x00,0x02,0x21,0xa0,0x00,0x02,0x10,0x94,0x92,0x27,
- 0x21,0xa8,0x00,0x00,0x01,0xa1,0x16,0x3c,0x07,0x00,0x17,0x24,
- 0x04,0x00,0x1e,0x24,0x21,0x98,0xc0,0x02,0xff,0x00,0x0e,0x24,
- 0x00,0x00,0x6e,0xa2,0xf3,0x01,0x02,0x24,0x21,0x18,0x40,0x00,
- 0xfe,0xff,0x60,0x14,0xff,0xff,0x42,0x24,0x00,0x00,0x70,0x92,
- 0x00,0x00,0x00,0x00,0x82,0x80,0x10,0x00,0x21,0x18,0x00,0x02,
- 0xff,0xff,0x6f,0x24,0x08,0x00,0xe1,0x2d,0x6c,0x00,0x20,0x10,
- 0x00,0x00,0x00,0x00,0x80,0x78,0x0f,0x00,0x00,0x80,0x01,0x3c,
- 0x21,0x08,0x2f,0x00,0x98,0x7b,0x2f,0x8c,0x00,0x00,0x00,0x00,
- 0x08,0x00,0xe0,0x01,0x00,0x00,0x00,0x00,0x00,0x80,0x02,0x3c,
- 0x50,0x5c,0x42,0x24,0x00,0x80,0x19,0x3c,0x00,0x80,0x08,0x3c,
- 0x00,0x80,0x09,0x3c,0x10,0x00,0x18,0x24,0x50,0x46,0x39,0x27,
- 0x04,0x70,0x08,0x25,0x90,0x71,0x29,0x25,0x00,0x00,0x54,0xae,
- 0x24,0x00,0x58,0xae,0x04,0x00,0x53,0xae,0x08,0x00,0x42,0xae,
- 0x0c,0x00,0x42,0xae,0x10,0x00,0x59,0xae,0x14,0x00,0x42,0xae,
- 0x18,0x00,0x48,0xae,0x1c,0x00,0x49,0xae,0x28,0x00,0x50,0xae,
- 0x02,0x00,0x0a,0x24,0x0c,0x00,0x6a,0xa2,0x31,0x00,0x00,0x10,
- 0x21,0x88,0x00,0x00,0x80,0x58,0x15,0x00,0x23,0x58,0x75,0x01,
- 0xc0,0x58,0x0b,0x00,0xa8,0x93,0x8c,0x27,0x00,0x80,0x06,0x3c,
- 0x00,0x77,0xc6,0x24,0x21,0x20,0x6c,0x01,0x01,0x00,0x05,0x24,
- 0xd3,0x17,0x00,0x0c,0x00,0x04,0x87,0x26,0x08,0x00,0x01,0x24,
- 0x03,0x00,0x01,0x12,0x00,0x00,0x00,0x00,0x03,0x00,0x17,0x16,
- 0x00,0x00,0x00,0x00,0x3d,0x00,0xa0,0x1e,0x00,0x00,0x00,0x00,
- 0x00,0x80,0x02,0x3c,0x00,0x80,0x04,0x3c,0x00,0x80,0x05,0x3c,
- 0x00,0x80,0x06,0x3c,0x00,0x00,0x54,0xae,0xd8,0x79,0xc6,0x24,
- 0x6c,0x77,0xa5,0x24,0x44,0x49,0x84,0x24,0x50,0x5c,0x42,0x24,
- 0x04,0x00,0x1e,0x16,0x21,0x88,0x00,0x00,0x09,0x00,0x0d,0x24,
- 0x07,0x00,0x00,0x10,0x24,0x00,0x4d,0xae,0x04,0x00,0x17,0x16,
- 0x08,0x00,0x03,0x24,0x02,0x00,0x00,0x10,0x21,0x18,0xc0,0x03,
- 0x08,0x00,0x03,0x24,0x24,0x00,0x43,0xae,0x04,0x00,0x53,0xae,
- 0x08,0x00,0x42,0xae,0x0c,0x00,0x42,0xae,0x10,0x00,0x44,0xae,
- 0x14,0x00,0x42,0xae,0x18,0x00,0x45,0xae,0x1c,0x00,0x46,0xae,
- 0x28,0x00,0x50,0xae,0x02,0x00,0x0e,0x24,0x01,0x00,0x00,0x10,
- 0x0c,0x00,0x6e,0xa2,0x24,0x00,0x42,0x8e,0x08,0x94,0x98,0x8f,
- 0xc0,0x79,0x02,0x00,0x21,0xc8,0x02,0x03,0x41,0x00,0x21,0x2b,
- 0x21,0xa0,0x8f,0x02,0x04,0x00,0x20,0x14,0x08,0x94,0x99,0xaf,
- 0x58,0x89,0x84,0x27,0x20,0x0c,0x00,0x0c,0x3b,0x03,0x05,0x24,
- 0x24,0x00,0x48,0x8e,0x00,0x00,0x50,0x8e,0x0b,0x00,0x00,0x11,
- 0x00,0x00,0x00,0x00,0x1c,0x00,0x49,0x8e,0x21,0x20,0x00,0x02,
- 0x21,0x28,0x40,0x02,0x09,0xf8,0x20,0x01,0x21,0x30,0x20,0x02,
- 0x24,0x00,0x4a,0x8e,0x01,0x00,0x31,0x26,0x2b,0x08,0x2a,0x02,
- 0xf7,0xff,0x20,0x14,0x80,0x00,0x10,0x26,0x0c,0x94,0x8b,0x8f,
- 0x2c,0x00,0x52,0x26,0x01,0x00,0x6c,0x25,0x0c,0x94,0x8c,0xaf,
- 0x01,0x00,0xb5,0x26,0x84,0xff,0xbe,0x16,0x00,0x40,0xd6,0x26,
- 0x08,0x94,0x8d,0x8f,0x00,0xa3,0x12,0x3c,0x1f,0x00,0xae,0x25,
- 0x42,0x79,0x0e,0x00,0x90,0x01,0x52,0x36,0x9c,0x92,0x8f,0xaf,
- 0x00,0x00,0x45,0x8e,0x01,0x80,0x04,0x3c,0x00,0xa0,0x01,0x3c,
- 0x80,0x95,0x84,0x24,0xf1,0x15,0x00,0x0c,0x21,0x28,0xa1,0x00,
- 0xd0,0x94,0x90,0x27,0x00,0x80,0x06,0x3c,0x21,0x88,0x40,0x00,
- 0x1c,0x4e,0xc6,0x24,0x21,0x20,0x00,0x02,0x01,0x00,0x05,0x24,
- 0xd3,0x17,0x00,0x0c,0x21,0x38,0x00,0x00,0xed,0x17,0x00,0x0c,
- 0x21,0x20,0x00,0x02,0x08,0x94,0x98,0x8f,0x00,0xa3,0x19,0x3c,
- 0x00,0xa3,0x08,0x3c,0x02,0x0c,0x38,0xa7,0x04,0x0c,0x00,0xa5,
- 0x00,0xa3,0x09,0x3c,0x06,0x0c,0x31,0xa5,0x00,0x00,0x4a,0x8e,
- 0x00,0xa3,0x0c,0x3c,0x82,0x5a,0x0a,0x00,0x08,0x0c,0x8b,0xa5,
- 0x00,0xa3,0x0d,0x3c,0x10,0x0d,0xa0,0xa5,0x00,0xa3,0x0e,0x3c,
- 0x12,0x0d,0xc0,0xa5,0x00,0xa3,0x18,0x3c,0x00,0x04,0x0f,0x24,
- 0xfc,0x03,0x02,0x24,0x14,0x0d,0x0f,0xa7,0x00,0xa3,0x19,0x3c,
- 0x16,0x0d,0x22,0xa7,0x00,0xa3,0x08,0x3c,0x18,0x0d,0x00,0xa5,
- 0x00,0xa3,0x09,0x3c,0x1a,0x0d,0x20,0xa5,0x00,0xa3,0x0b,0x3c,
- 0x00,0x08,0x0a,0x24,0x1c,0x0d,0x6a,0xa5,0x00,0xa3,0x0c,0x3c,
- 0x1e,0x0d,0x82,0xa5,0x3c,0x00,0xbf,0x8f,0x38,0x00,0xbe,0x8f,
- 0x34,0x00,0xb7,0x8f,0x30,0x00,0xb6,0x8f,0x2c,0x00,0xb5,0x8f,
- 0x28,0x00,0xb4,0x8f,0x24,0x00,0xb3,0x8f,0x20,0x00,0xb2,0x8f,
- 0x1c,0x00,0xb1,0x8f,0x18,0x00,0xb0,0x8f,0x08,0x00,0xe0,0x03,
- 0x40,0x00,0xbd,0x27,0x70,0x95,0x82,0x8f,0x6c,0x95,0x98,0x8f,
- 0x01,0x08,0x42,0x34,0x00,0x04,0x43,0x34,0x25,0x20,0x78,0x00,
- 0x01,0x00,0x0e,0x24,0x01,0x08,0x0f,0x24,0x00,0x03,0x99,0x34,
- 0x98,0x92,0x8e,0xaf,0x8c,0x92,0x8f,0xaf,0xc0,0x94,0x99,0xaf,
- 0x68,0x95,0x84,0xaf,0x84,0x92,0x84,0xaf,0x88,0x92,0x83,0xaf,
- 0x08,0x00,0xe0,0x03,0x80,0x92,0x82,0xaf,0xe8,0xff,0xbd,0x27,
- 0x14,0x00,0xbf,0xaf,0x70,0x89,0x84,0x27,0x20,0x0c,0x00,0x0c,
- 0x4d,0x00,0x05,0x24,0x14,0x00,0xbf,0x8f,0x18,0x00,0xbd,0x27,
- 0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0xe8,0xff,0xbd,0x27,
- 0x14,0x00,0xbf,0xaf,0x80,0x89,0x84,0x27,0x20,0x0c,0x00,0x0c,
- 0x58,0x00,0x05,0x24,0x14,0x00,0xbf,0x8f,0x18,0x00,0xbd,0x27,
- 0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0x00,0x80,0x0e,0x3c,
- 0xff,0x03,0x02,0x3c,0x74,0x34,0xce,0x25,0xff,0xff,0x42,0x34,
- 0x82,0x78,0x0e,0x00,0x00,0x80,0x0a,0x3c,0xe8,0xff,0xbd,0x27,
- 0x00,0x08,0x03,0x3c,0x24,0xc0,0xe2,0x01,0x90,0x32,0x4a,0x25,
- 0x14,0x00,0xbf,0xaf,0x25,0xc8,0x03,0x03,0x00,0x80,0x08,0x3c,
- 0x82,0x58,0x0a,0x00,0x00,0x00,0x19,0xad,0x00,0x80,0x09,0x3c,
- 0x24,0x60,0x62,0x01,0x04,0x00,0x20,0xad,0x25,0x68,0x83,0x01,
- 0x00,0x80,0x0e,0x3c,0x80,0x00,0xcd,0xad,0x00,0x80,0x0f,0x3c,
- 0xf8,0x18,0x00,0x0c,0x84,0x00,0xe0,0xad,0x00,0xa1,0x05,0x3c,
- 0x00,0x80,0xa5,0x34,0x80,0x00,0x18,0x24,0x00,0x00,0xb8,0xa4,
- 0x21,0x10,0x00,0x00,0x64,0x00,0x03,0x24,0x04,0x00,0x42,0x24,
- 0xff,0xff,0x43,0x14,0x04,0x00,0x42,0x24,0x82,0x00,0x19,0x24,
- 0xc4,0x94,0x99,0xaf,0x82,0x00,0x08,0x24,0x00,0x00,0xa8,0xa4,
- 0x00,0xa3,0x09,0x3c,0x30,0x0c,0x20,0xa1,0x74,0x11,0x00,0x0c,
- 0x00,0x03,0x04,0x24,0x7c,0x15,0x00,0x0c,0x00,0x00,0x00,0x00,
- 0xac,0x17,0x00,0x0c,0x00,0x00,0x00,0x00,0x4b,0x17,0x00,0x0c,
- 0x00,0x00,0x00,0x00,0xa8,0x14,0x00,0x0c,0x00,0x00,0x00,0x00,
- 0x7c,0x15,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x80,0x06,0x3c,
- 0xc8,0x5b,0xc6,0x24,0x78,0x95,0x84,0x27,0x21,0x28,0x00,0x00,
- 0xd3,0x17,0x00,0x0c,0x21,0x38,0x00,0x00,0xed,0x17,0x00,0x0c,
- 0x78,0x95,0x84,0x27,0x4f,0x00,0x02,0x24,0x00,0xa3,0x0a,0x3c,
- 0x20,0x0d,0x42,0xa1,0x00,0xa3,0x0b,0x3c,0x53,0x00,0x03,0x24,
- 0x00,0x0c,0x62,0xa1,0x00,0xa3,0x0c,0x3c,0x21,0x0d,0x83,0xa1,
- 0x00,0xa3,0x0d,0x3c,0x61,0x18,0x00,0x0c,0x01,0x0c,0xa3,0xa1,
- 0x14,0x00,0xbf,0x8f,0x18,0x00,0xbd,0x27,0x08,0x00,0xe0,0x03,
- 0x21,0x10,0x00,0x00,0x2b,0x08,0x85,0x00,0x05,0x00,0x20,0x10,
- 0x00,0x00,0x00,0x00,0x04,0x00,0x84,0x24,0x2b,0x08,0x85,0x00,
- 0xfd,0xff,0x20,0x14,0xfc,0xff,0x80,0xac,0x08,0x00,0xe0,0x03,
- 0x00,0x00,0x00,0x00,0xa8,0xff,0xbd,0x27,0x40,0x00,0xbe,0xaf,
- 0xff,0x1f,0x02,0x3c,0x00,0xff,0x42,0x34,0x21,0xf0,0x80,0x00,
- 0x3c,0x00,0xb7,0xaf,0x21,0xb8,0xa0,0x00,0x00,0xa0,0x03,0x3c,
- 0xff,0x00,0xce,0x27,0x24,0x78,0xc2,0x01,0x24,0xc0,0xe2,0x02,
- 0x44,0x00,0xbf,0xaf,0x25,0xf0,0xe3,0x01,0x25,0xb8,0x03,0x03,
- 0x38,0x00,0xb6,0xaf,0x30,0x00,0xb4,0xaf,0x34,0x00,0xb5,0xaf,
- 0x28,0x00,0xb2,0xaf,0x2c,0x00,0xb3,0xaf,0x20,0x00,0xb0,0xaf,
- 0x24,0x00,0xb1,0xaf,0x21,0x28,0xe0,0x02,0xe8,0x15,0x00,0x0c,
- 0x21,0x20,0xc0,0x03,0x01,0x80,0x16,0x3c,0x01,0x80,0x07,0x3c,
- 0x48,0x00,0xa0,0xaf,0x4c,0x00,0xa0,0xaf,0x70,0x90,0xe7,0x24,
- 0xc0,0x8f,0xd6,0x26,0x04,0x00,0x06,0x24,0x28,0x00,0xc2,0x8e,
- 0x08,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x48,0x00,0xb9,0x8f,
- 0x4c,0x00,0xa9,0x8f,0x01,0x00,0x28,0x27,0x08,0x00,0x2a,0x25,
- 0x48,0x00,0xa8,0xaf,0x08,0x00,0x00,0x10,0x4c,0x00,0xaa,0xaf,
- 0xf9,0xff,0x46,0x10,0x48,0x00,0xb9,0x8f,0x4c,0x00,0xab,0x8f,
- 0x24,0x00,0xcc,0x8e,0x00,0x00,0x00,0x00,0x21,0x68,0x6c,0x01,
- 0x4c,0x00,0xad,0xaf,0x2c,0x00,0xd6,0x26,0xed,0xff,0xc7,0x16,
- 0x00,0x00,0x00,0x00,0x10,0x00,0x15,0x24,0x48,0x00,0xae,0x8f,
- 0x00,0x00,0x00,0x00,0x05,0x00,0xc0,0x19,0x00,0x10,0xa1,0x2a,
- 0x03,0x00,0x20,0x10,0x00,0xe0,0x01,0x24,0x05,0x00,0x00,0x10,
- 0x24,0x88,0xe1,0x02,0x21,0x78,0xb5,0x02,0xff,0xff,0xf8,0x25,
- 0x27,0xc8,0x00,0x03,0x24,0x88,0xf9,0x02,0x00,0x10,0xa1,0x2a,
- 0x04,0x00,0x20,0x10,0x21,0x90,0xa0,0x02,0x02,0x00,0x00,0x10,
- 0x00,0x10,0x12,0x24,0x21,0x90,0xa0,0x02,0x4c,0x00,0xa9,0x8f,
- 0x40,0x18,0x15,0x00,0x19,0x00,0x69,0x00,0x48,0x00,0xac,0x8f,
- 0x23,0x40,0x3e,0x02,0x12,0x50,0x00,0x00,0x23,0x58,0x0a,0x01,
- 0x00,0x00,0x00,0x00,0x19,0x00,0x4c,0x02,0x12,0x68,0x00,0x00,
- 0x23,0x10,0x6d,0x01,0x2a,0x08,0x55,0x00,0x09,0x00,0x20,0x10,
- 0x21,0x98,0x40,0x00,0x22,0x00,0x61,0x28,0x9e,0x00,0x20,0x10,
- 0x23,0x10,0xfe,0x02,0x90,0x89,0x84,0x27,0x20,0x0c,0x00,0x0c,
- 0xb2,0x00,0x05,0x24,0x99,0x00,0x00,0x10,0x23,0x10,0xfe,0x02,
- 0x01,0x80,0x16,0x3c,0xc0,0x8f,0xd6,0x26,0x28,0x00,0xce,0x8e,
- 0x00,0x00,0x00,0x00,0x27,0x00,0xce,0x14,0x00,0x00,0x00,0x00,
- 0x00,0x00,0xd0,0x8e,0xff,0xff,0x4f,0x26,0x2a,0x08,0x72,0x02,
- 0x00,0x04,0x10,0x26,0x06,0x00,0x20,0x14,0x0e,0x00,0x0f,0xa6,
- 0x0e,0x00,0x18,0x96,0xff,0xff,0x59,0x32,0x21,0x48,0x19,0x03,
- 0x0e,0x00,0x09,0xa6,0x23,0x98,0x72,0x02,0x0e,0x00,0x02,0x96,
- 0x00,0x00,0x00,0x00,0x23,0x88,0x22,0x02,0xff,0xff,0x31,0x26,
- 0x02,0x41,0x11,0x00,0x2b,0x08,0x3e,0x02,0x08,0x00,0x08,0xa6,
- 0x07,0x00,0x20,0x14,0x3c,0x00,0x11,0xae,0x3c,0x00,0x03,0x8e,
- 0x00,0x00,0x00,0x00,0x21,0x50,0x62,0x00,0x2b,0x08,0x57,0x01,
- 0x09,0x00,0x20,0x14,0x00,0x00,0x00,0x00,0x9c,0x89,0x84,0x27,
- 0x20,0x0c,0x00,0x0c,0xce,0x00,0x05,0x24,0x01,0x80,0x07,0x3c,
- 0x0e,0x00,0x02,0x96,0x3c,0x00,0x03,0x8e,0x70,0x90,0xe7,0x24,
- 0x04,0x00,0x06,0x24,0x08,0x00,0x0c,0x96,0x16,0x00,0x02,0xa6,
- 0x38,0x00,0x03,0xae,0x10,0x00,0x0c,0xa6,0x2c,0x00,0xd6,0x26,
- 0xd4,0xff,0xc7,0x16,0x00,0x00,0x00,0x00,0x01,0x80,0x16,0x3c,
- 0xc0,0x8f,0xd6,0x26,0x28,0x00,0xc2,0x8e,0x03,0x00,0x00,0x10,
- 0x00,0x00,0x00,0x00,0x05,0x00,0x00,0x10,0x08,0x00,0x12,0x24,
- 0xfd,0xff,0x46,0x10,0x00,0x00,0x00,0x00,0x24,0x00,0xd2,0x8e,
- 0x00,0x00,0x00,0x00,0x00,0x00,0xd0,0x8e,0x22,0x00,0x40,0x12,
- 0x00,0x00,0x00,0x00,0xff,0xff,0xb4,0x26,0x2a,0x08,0x75,0x02,
- 0x06,0x00,0x20,0x14,0x16,0x00,0x14,0xa6,0x16,0x00,0x0b,0x96,
- 0xff,0xff,0xad,0x32,0x21,0x70,0x6d,0x01,0x16,0x00,0x0e,0xa6,
- 0x23,0x98,0x75,0x02,0x16,0x00,0x02,0x96,0x00,0x00,0x00,0x00,
- 0x23,0x88,0x22,0x02,0xff,0xff,0x31,0x26,0x02,0x79,0x11,0x00,
- 0x2b,0x08,0x3e,0x02,0x38,0x00,0x11,0xae,0x07,0x00,0x20,0x14,
- 0x10,0x00,0x0f,0xa6,0x38,0x00,0x18,0x8e,0x00,0x00,0x00,0x00,
- 0x21,0xc8,0x02,0x03,0x2b,0x08,0x37,0x03,0x04,0x00,0x20,0x14,
- 0x00,0x00,0x00,0x00,0xa8,0x89,0x84,0x27,0x20,0x0c,0x00,0x0c,
- 0x00,0x01,0x05,0x24,0xff,0xff,0x52,0x26,0xe4,0xff,0x40,0x16,
- 0x80,0x00,0x10,0x26,0x01,0x80,0x07,0x3c,0x70,0x90,0xe7,0x24,
- 0x04,0x00,0x06,0x24,0x2c,0x00,0xd6,0x26,0xd1,0xff,0xc7,0x16,
- 0x00,0x00,0x00,0x00,0x01,0x80,0x16,0x3c,0xc0,0x8f,0xd6,0x26,
- 0x28,0x00,0xc2,0x8e,0x03,0x00,0x00,0x10,0x00,0x00,0x00,0x00,
- 0x05,0x00,0x00,0x10,0x08,0x00,0x12,0x24,0xfd,0xff,0x46,0x10,
- 0x00,0x00,0x00,0x00,0x24,0x00,0xd2,0x8e,0x00,0x00,0x00,0x00,
- 0x00,0x00,0xd0,0x8e,0x22,0x00,0x40,0x12,0x00,0x00,0x00,0x00,
- 0xff,0xff,0xb4,0x26,0x2a,0x08,0x75,0x02,0x06,0x00,0x20,0x14,
- 0x0e,0x00,0x14,0xa6,0x0e,0x00,0x09,0x96,0xff,0xff,0xa8,0x32,
- 0x21,0x50,0x28,0x01,0x0e,0x00,0x0a,0xa6,0x23,0x98,0x75,0x02,
- 0x0e,0x00,0x02,0x96,0x00,0x00,0x00,0x00,0x23,0x88,0x22,0x02,
- 0xff,0xff,0x31,0x26,0x02,0x61,0x11,0x00,0x2b,0x08,0x3e,0x02,
- 0x08,0x00,0x0c,0xa6,0x07,0x00,0x20,0x14,0x3c,0x00,0x11,0xae,
- 0x3c,0x00,0x0b,0x8e,0x00,0x00,0x00,0x00,0x21,0x68,0x62,0x01,
- 0x2b,0x08,0xb7,0x01,0x04,0x00,0x20,0x14,0x00,0x00,0x00,0x00,
- 0xb4,0x89,0x84,0x27,0x20,0x0c,0x00,0x0c,0x27,0x01,0x05,0x24,
- 0xff,0xff,0x52,0x26,0xe4,0xff,0x40,0x16,0x80,0x00,0x10,0x26,
- 0x01,0x80,0x07,0x3c,0x70,0x90,0xe7,0x24,0x04,0x00,0x06,0x24,
- 0x2c,0x00,0xd6,0x26,0xd1,0xff,0xc7,0x16,0x00,0x00,0x00,0x00,
- 0x40,0xa8,0x15,0x00,0x01,0x40,0xa1,0x2a,0x43,0xff,0x20,0x14,
- 0x48,0x00,0xae,0x8f,0x23,0x10,0xfe,0x02,0x44,0x00,0xbf,0x8f,
- 0x40,0x00,0xbe,0x8f,0x3c,0x00,0xb7,0x8f,0x20,0x00,0xb0,0x8f,
- 0x24,0x00,0xb1,0x8f,0x28,0x00,0xb2,0x8f,0x2c,0x00,0xb3,0x8f,
- 0x30,0x00,0xb4,0x8f,0x34,0x00,0xb5,0x8f,0x38,0x00,0xb6,0x8f,
- 0x58,0x00,0xbd,0x27,0x08,0x00,0xe0,0x03,0x82,0x12,0x02,0x00,
- 0xe8,0xff,0xbd,0x27,0x14,0x00,0xbf,0xaf,0xc0,0x94,0x84,0x8f,
- 0x60,0x11,0x00,0x0c,0x00,0x00,0x00,0x00,0x33,0x18,0x00,0x0c,
- 0x32,0x00,0x04,0x24,0x90,0x95,0x82,0x8f,0x94,0x95,0x83,0x8f,
- 0x98,0x95,0x82,0xaf,0x2b,0x08,0x62,0x00,0x03,0x00,0x20,0x10,
- 0x82,0x70,0x02,0x00,0x21,0x18,0x40,0x00,0x82,0x70,0x02,0x00,
- 0x23,0x10,0x4e,0x00,0x03,0x00,0x60,0x14,0x90,0x95,0x82,0xaf,
- 0x0b,0x00,0x00,0x10,0x94,0x95,0x83,0xaf,0x98,0x95,0x8f,0x8f,
- 0x00,0xa3,0x08,0x3c,0x00,0xc3,0x0f,0x00,0x1b,0x00,0x03,0x03,
- 0x12,0xc8,0x00,0x00,0x08,0x00,0x19,0xa5,0x94,0x95,0x83,0xaf,
- 0x02,0x00,0x60,0x14,0x00,0x00,0x00,0x00,0x0d,0x00,0x07,0x00,
- 0x14,0x00,0xbf,0x8f,0x18,0x00,0xbd,0x27,0x08,0x00,0xe0,0x03,
- 0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,0x21,0x10,0x00,0x00,
- 0x00,0x83,0x08,0x3c,0x21,0x38,0x80,0x00,0x00,0x10,0x08,0x35,
- 0x21,0x10,0x00,0x00,0xa0,0x92,0x86,0x27,0x00,0x00,0xc4,0x8c,
- 0x21,0x18,0xc0,0x00,0x2b,0x08,0x88,0x00,0x0b,0x00,0x20,0x14,
- 0x2b,0x08,0x87,0x00,0x09,0x00,0x20,0x10,0x00,0x00,0x00,0x00,
- 0x21,0x18,0x80,0x00,0x00,0x00,0x84,0x8c,0x00,0x00,0x00,0x00,
- 0x2b,0x08,0x88,0x00,0x03,0x00,0x20,0x14,0x2b,0x08,0x87,0x00,
- 0xf9,0xff,0x20,0x14,0x00,0x00,0x00,0x00,0x06,0x00,0x87,0x14,
- 0x00,0x00,0x00,0x00,0x1c,0x00,0xa2,0x10,0x00,0x00,0x00,0x00,
- 0x00,0x00,0xee,0x8c,0x05,0x00,0x00,0x10,0x00,0x00,0x6e,0xac,
- 0x01,0x00,0x42,0x24,0x07,0x00,0x41,0x28,0xe7,0xff,0x20,0x14,
- 0x04,0x00,0xc6,0x24,0x80,0x78,0x05,0x00,0xa0,0x92,0x98,0x27,
- 0x21,0x10,0xf8,0x01,0x00,0x00,0x44,0x8c,0x21,0x18,0x40,0x00,
- 0x2b,0x08,0x88,0x00,0x0b,0x00,0x20,0x14,0x2b,0x08,0x87,0x00,
- 0x09,0x00,0x20,0x10,0x00,0x00,0x00,0x00,0x21,0x18,0x80,0x00,
- 0x00,0x00,0x84,0x8c,0x00,0x00,0x00,0x00,0x2b,0x08,0x88,0x00,
- 0x03,0x00,0x20,0x14,0x2b,0x08,0x87,0x00,0xf9,0xff,0x20,0x14,
- 0x00,0x00,0x00,0x00,0x00,0x00,0xe4,0xac,0x00,0x00,0x67,0xac,
- 0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0xb0,0x95,0x83,0x27,
- 0x00,0x80,0x0e,0x3c,0x00,0x80,0x0f,0x3c,0x00,0x80,0x18,0x3c,
- 0xa8,0x95,0x82,0x27,0x00,0x35,0xce,0x25,0x28,0x35,0xef,0x25,
- 0x4c,0x35,0x18,0x27,0xa0,0x95,0x99,0x27,0xa0,0x95,0x80,0xaf,
- 0xa4,0x95,0x8e,0xaf,0xa8,0x95,0x80,0xaf,0xac,0x95,0x8f,0xaf,
- 0xb0,0x95,0x80,0xaf,0xb4,0x95,0x98,0xaf,0xa0,0x92,0x99,0xaf,
- 0xa8,0x92,0x82,0xaf,0xa4,0x92,0x82,0xaf,0xb8,0x92,0x83,0xaf,
- 0xb4,0x92,0x83,0xaf,0xb0,0x92,0x83,0xaf,0x08,0x00,0xe0,0x03,
- 0xac,0x92,0x83,0xaf,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0xe8,0xff,0xbd,0x27,0x00,0xa3,0x07,0x3c,0x30,0x0c,0xe7,0x34,
- 0x14,0x00,0xbf,0xaf,0x00,0x00,0xee,0x90,0x00,0x00,0x00,0x00,
- 0x3c,0x00,0xc0,0x11,0x14,0x00,0xbf,0x8f,0x00,0xa3,0x0f,0x3c,
- 0x32,0x0c,0xf8,0x91,0x00,0x00,0x00,0x00,0x37,0x00,0x00,0x17,
- 0x14,0x00,0xbf,0x8f,0x00,0xa3,0x03,0x3c,0x34,0x0c,0x63,0x34,
- 0x00,0x00,0x65,0x8c,0xff,0x3f,0x01,0x3c,0x00,0xa3,0x06,0x3c,
- 0xff,0xff,0x21,0x34,0x38,0x0c,0xc6,0x34,0x24,0x28,0xa1,0x00,
- 0x00,0x00,0xd9,0x94,0x00,0x80,0x01,0x3c,0x25,0x28,0xa1,0x00,
- 0x81,0x00,0x21,0x2f,0x03,0x00,0x20,0x14,0x00,0x00,0x00,0x00,
- 0x80,0x00,0x08,0x24,0x00,0x00,0xc8,0xa4,0x00,0x00,0xe2,0x90,
- 0x1d,0x00,0x00,0x10,0x01,0x00,0x01,0x24,0x00,0xa3,0x04,0x3c,
- 0x00,0x00,0xc2,0x94,0x21,0x18,0xa0,0x00,0x05,0x00,0x00,0x10,
- 0x3a,0x0c,0x84,0x34,0x00,0xa3,0x03,0x3c,0x00,0x00,0xc2,0x94,
- 0x3a,0x0c,0x63,0x34,0x21,0x20,0xa0,0x00,0xff,0xff,0x42,0x24,
- 0x07,0x00,0x40,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x69,0x90,
- 0xff,0xff,0x42,0x24,0x01,0x00,0x63,0x24,0x01,0x00,0x84,0x24,
- 0xfb,0xff,0x41,0x04,0xff,0xff,0x89,0xa0,0x0f,0x00,0x00,0x10,
- 0x00,0x00,0xe0,0xa0,0x00,0x00,0xe0,0xa0,0x00,0x00,0x6a,0x8c,
- 0x00,0x00,0x00,0x00,0x09,0xf8,0x40,0x01,0x00,0x00,0x00,0x00,
- 0x09,0x00,0x00,0x10,0x14,0x00,0xbf,0x8f,0x01,0x00,0x01,0x24,
- 0xe3,0xff,0x41,0x10,0x02,0x00,0x01,0x24,0xe6,0xff,0x41,0x10,
- 0x03,0x00,0x01,0x24,0xf3,0xff,0x41,0x10,0x00,0x00,0x00,0x00,
- 0x14,0x00,0xbf,0x8f,0x18,0x00,0xbd,0x27,0x08,0x00,0xe0,0x03,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x90,0x92,0x8e,0x8f,0x21,0x10,0x00,0x00,0xff,0xff,0xcf,0x25,
- 0xbc,0x95,0x8f,0xaf,0x88,0x93,0x83,0x27,0x04,0x00,0x04,0x24,
- 0x00,0x00,0x63,0xac,0x04,0x00,0x63,0xac,0x08,0x00,0x63,0x24,
- 0x00,0x00,0x63,0xac,0x04,0x00,0x63,0xac,0x08,0x00,0x63,0x24,
- 0x00,0x00,0x63,0xac,0x04,0x00,0x63,0xac,0x08,0x00,0x63,0x24,
- 0x00,0x00,0x63,0xac,0x04,0x00,0x63,0xac,0x04,0x00,0x42,0x24,
- 0xf3,0xff,0x44,0x14,0x08,0x00,0x63,0x24,0x21,0x10,0x00,0x00,
- 0x08,0x93,0x83,0x27,0x10,0x00,0x04,0x24,0x00,0x00,0x63,0xac,
- 0x04,0x00,0x63,0xac,0x08,0x00,0x63,0x24,0x00,0x00,0x63,0xac,
- 0x04,0x00,0x63,0xac,0x08,0x00,0x63,0x24,0x00,0x00,0x63,0xac,
- 0x04,0x00,0x63,0xac,0x08,0x00,0x63,0x24,0x00,0x00,0x63,0xac,
- 0x04,0x00,0x63,0xac,0x04,0x00,0x42,0x24,0xf3,0xff,0x44,0x14,
- 0x08,0x00,0x63,0x24,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,
- 0xd8,0xff,0xbd,0x27,0x21,0x18,0x80,0x00,0x24,0x00,0xbf,0xaf,
- 0x68,0x95,0x84,0x8f,0x2c,0x00,0xa5,0xaf,0x30,0x00,0xa6,0xaf,
- 0x34,0x00,0xa7,0xaf,0x58,0x11,0x00,0x0c,0x28,0x00,0xa3,0xaf,
- 0x28,0x00,0xa3,0x8f,0x21,0x20,0x40,0x00,0x00,0x00,0x63,0xac,
- 0x04,0x00,0x63,0xac,0x2c,0x00,0xae,0x8f,0x00,0x00,0x00,0x00,
- 0x10,0x00,0x6e,0xac,0x30,0x00,0xaf,0x8f,0x00,0x00,0x00,0x00,
- 0x08,0x00,0x6f,0xac,0x34,0x00,0xb8,0x8f,0x60,0x11,0x00,0x0c,
- 0x0c,0x00,0x78,0xac,0x24,0x00,0xbf,0x8f,0x28,0x00,0xbd,0x27,
- 0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0xe8,0xff,0xbd,0x27,
- 0x21,0x18,0x80,0x00,0x14,0x00,0xbf,0xaf,0x68,0x95,0x84,0x8f,
- 0x58,0x11,0x00,0x0c,0x18,0x00,0xa3,0xaf,0x18,0x00,0xa3,0x8f,
- 0x90,0x92,0x8e,0x8f,0x04,0x00,0x66,0x8c,0x00,0x00,0x67,0x8c,
- 0x14,0x00,0x6e,0xac,0x00,0x00,0xc7,0xac,0x04,0x00,0xe6,0xac,
- 0x10,0x00,0x6f,0x8c,0x88,0x93,0x99,0x27,0xc0,0xc0,0x0f,0x00,
- 0x21,0x28,0x19,0x03,0x04,0x00,0xa8,0x8c,0x21,0x20,0x40,0x00,
- 0x00,0x00,0x03,0xad,0x00,0x00,0x65,0xac,0x04,0x00,0x68,0xac,
- 0x60,0x11,0x00,0x0c,0x04,0x00,0xa3,0xac,0x14,0x00,0xbf,0x8f,
- 0x18,0x00,0xbd,0x27,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,
- 0xe8,0xff,0xbd,0x27,0x21,0x30,0x80,0x00,0x14,0x00,0xbf,0xaf,
- 0x68,0x95,0x84,0x8f,0x18,0x00,0xa6,0xaf,0x58,0x11,0x00,0x0c,
- 0x1c,0x00,0xa5,0xaf,0x18,0x00,0xa6,0x8f,0x1c,0x00,0xa5,0x8f,
- 0x04,0x00,0xc3,0x8c,0x00,0x00,0xc4,0x8c,0x00,0x40,0x01,0x3c,
- 0x00,0x00,0x64,0xac,0x04,0x00,0x83,0xac,0x90,0x92,0x8e,0x8f,
- 0x21,0x38,0x40,0x00,0x23,0x78,0xc5,0x01,0x2b,0x08,0xe1,0x01,
- 0x08,0x00,0x20,0x10,0x0f,0x00,0xa9,0x30,0x10,0x00,0xd8,0x8c,
- 0x88,0x93,0x88,0x27,0xc0,0xc8,0x18,0x00,0x14,0x00,0xce,0xac,
- 0x06,0x00,0x00,0x10,0x21,0x18,0x28,0x03,0x0f,0x00,0xa9,0x30,
- 0xc0,0x50,0x09,0x00,0x08,0x93,0x8b,0x27,0x14,0x00,0xc5,0xac,
- 0x21,0x18,0x4b,0x01,0x04,0x00,0x62,0x8c,0x21,0x20,0xe0,0x00,
- 0x00,0x00,0x46,0xac,0x00,0x00,0xc3,0xac,0x04,0x00,0xc2,0xac,
- 0x60,0x11,0x00,0x0c,0x04,0x00,0x66,0xac,0x14,0x00,0xbf,0x8f,
- 0x18,0x00,0xbd,0x27,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,
- 0xb8,0x95,0x8e,0x8f,0xe0,0xff,0xbd,0x27,0x14,0x00,0xbf,0xaf,
- 0x14,0x00,0xcf,0x8d,0x21,0x18,0x80,0x00,0x21,0xc0,0xe3,0x01,
- 0x14,0x00,0xd8,0xad,0x68,0x95,0x84,0x8f,0x21,0x28,0xc0,0x01,
- 0x58,0x11,0x00,0x0c,0x1c,0x00,0xa5,0xaf,0x1c,0x00,0xa5,0x8f,
- 0x00,0x40,0x01,0x3c,0x04,0x00,0xa3,0x8c,0x00,0x00,0xa4,0x8c,
- 0x21,0x38,0x40,0x00,0x00,0x00,0x64,0xac,0x04,0x00,0x83,0xac,
- 0x90,0x92,0x99,0x8f,0x14,0x00,0xa6,0x8c,0x00,0x00,0x00,0x00,
- 0x23,0x40,0x26,0x03,0x2b,0x08,0x01,0x01,0x08,0x00,0x20,0x10,
- 0x0f,0x00,0xcc,0x30,0x10,0x00,0xa9,0x8c,0x88,0x93,0x8b,0x27,
- 0xc0,0x50,0x09,0x00,0x14,0x00,0xb9,0xac,0x05,0x00,0x00,0x10,
- 0x21,0x18,0x4b,0x01,0x0f,0x00,0xcc,0x30,0xc0,0x68,0x0c,0x00,
- 0x08,0x93,0x8f,0x27,0x21,0x18,0xaf,0x01,0x04,0x00,0x62,0x8c,
- 0x21,0x20,0xe0,0x00,0x00,0x00,0x45,0xac,0x00,0x00,0xa3,0xac,
- 0x04,0x00,0xa2,0xac,0x60,0x11,0x00,0x0c,0x04,0x00,0x65,0xac,
- 0x14,0x00,0xbf,0x8f,0x20,0x00,0xbd,0x27,0x08,0x00,0xe0,0x03,
- 0x00,0x00,0x00,0x00,0xa8,0xff,0xbd,0x27,0x14,0x00,0xbf,0xaf,
- 0xc0,0x94,0x84,0x8f,0x60,0x11,0x00,0x0c,0x00,0x00,0x00,0x00,
- 0x28,0x00,0xb3,0xaf,0x24,0x00,0xb4,0xaf,0x00,0xa3,0x14,0x3c,
- 0x00,0xa3,0x13,0x3c,0x34,0x00,0xb0,0xaf,0x30,0x00,0xb1,0xaf,
- 0x20,0x00,0xb5,0xaf,0x1c,0x00,0xb6,0xaf,0x18,0x00,0xb7,0xaf,
- 0xc0,0x95,0x97,0x27,0x90,0x93,0x96,0x27,0x08,0x93,0x95,0x27,
- 0x00,0x80,0x11,0x3c,0x88,0x93,0x90,0x27,0x12,0x0d,0x73,0x36,
- 0x10,0x0d,0x94,0x36,0x2c,0x00,0xb2,0xaf,0x00,0x00,0x6e,0x96,
- 0x00,0x00,0x8f,0x96,0x00,0x00,0x00,0x00,0x08,0x00,0xcf,0x11,
- 0x00,0x00,0x00,0x00,0x29,0x13,0x00,0x0c,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x78,0x96,0x00,0x00,0x99,0x96,0x00,0x00,0x00,0x00,
- 0xfa,0xff,0x19,0x17,0x00,0x00,0x00,0x00,0x68,0x95,0x84,0x8f,
- 0x58,0x11,0x00,0x0c,0x00,0x00,0x00,0x00,0xbc,0x95,0x88,0x8f,
- 0x90,0x92,0x89,0x8f,0x00,0x00,0x00,0x00,0x2d,0x00,0x09,0x11,
- 0x00,0x00,0x00,0x00,0xbc,0x95,0x8a,0x8f,0x00,0x00,0x00,0x00,
- 0x01,0x00,0x4b,0x25,0x0f,0x00,0x6c,0x31,0xc0,0x68,0x0c,0x00,
- 0xbc,0x95,0x8b,0xaf,0x21,0x10,0xad,0x02,0x00,0x00,0x45,0x8c,
- 0x21,0x38,0x40,0x00,0x1d,0x00,0xa2,0x10,0x21,0x20,0x40,0x00,
- 0x21,0x18,0xa0,0x00,0x14,0x00,0x6f,0x8c,0xbc,0x95,0x8e,0x8f,
- 0x00,0x00,0x00,0x00,0x23,0xc0,0xcf,0x01,0x2b,0x08,0x11,0x03,
- 0x10,0x00,0x20,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0xa2,0x8c,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x82,0xac,0x04,0x00,0x44,0xac,
- 0x10,0x00,0x79,0x8c,0x00,0x00,0x00,0x00,0xc0,0x40,0x19,0x00,
- 0x21,0x30,0x08,0x02,0x04,0x00,0xc2,0x8c,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x45,0xac,0x00,0x00,0xa6,0xac,0x04,0x00,0xa2,0xac,
- 0x02,0x00,0x00,0x10,0x04,0x00,0xc5,0xac,0x21,0x20,0xa0,0x00,
- 0x00,0x00,0x85,0x8c,0x00,0x00,0x00,0x00,0xe6,0xff,0xa7,0x14,
- 0x21,0x18,0xa0,0x00,0xbc,0x95,0x89,0x8f,0x90,0x92,0x8a,0x8f,
- 0x00,0x00,0x00,0x00,0xd5,0xff,0x2a,0x15,0x00,0x00,0x00,0x00,
- 0x88,0x93,0x8b,0x8f,0x21,0x30,0x00,0x02,0x16,0x00,0x0b,0x16,
- 0x00,0x00,0x00,0x00,0x21,0x30,0xc0,0x02,0x00,0x00,0xcc,0x8c,
- 0x00,0x00,0x00,0x00,0x11,0x00,0xcc,0x14,0x00,0x00,0x00,0x00,
- 0x08,0x00,0xcd,0x8c,0x08,0x00,0xc6,0x24,0x0d,0x00,0xcd,0x14,
- 0x00,0x00,0x00,0x00,0x08,0x00,0xce,0x8c,0x08,0x00,0xc6,0x24,
- 0x09,0x00,0xce,0x14,0x00,0x00,0x00,0x00,0xc0,0x94,0x84,0x8f,
- 0x60,0x11,0x00,0x0c,0x00,0x00,0x00,0x00,0x90,0x95,0x8f,0x8f,
- 0x00,0x00,0x00,0x00,0x01,0x00,0xf8,0x25,0xa8,0xff,0x00,0x10,
- 0x90,0x95,0x98,0xaf,0x00,0x00,0xc5,0x8c,0x00,0x00,0x00,0x00,
- 0x00,0x00,0xa2,0x8c,0x00,0x00,0x00,0x00,0x00,0x00,0xc2,0xac,
- 0x04,0x00,0x46,0xac,0x00,0x00,0xa5,0xac,0x04,0x00,0xa5,0xac,
- 0xb8,0x95,0x85,0xaf,0xb8,0x95,0x99,0x8f,0x90,0x92,0x92,0x8f,
- 0x08,0x00,0x28,0x8f,0x0c,0x00,0x24,0x8f,0x09,0xf8,0x00,0x01,
- 0x00,0x00,0x00,0x00,0xc0,0x94,0x84,0x8f,0x60,0x11,0x00,0x0c,
- 0x00,0x00,0x00,0x00,0x90,0x92,0x89,0x8f,0xb8,0x95,0x80,0xaf,
- 0x23,0x90,0x32,0x01,0x32,0x00,0x41,0x2e,0x04,0x00,0x20,0x10,
- 0x31,0x00,0x03,0x24,0x02,0x00,0x00,0x10,0x21,0x18,0x40,0x02,
- 0x31,0x00,0x03,0x24,0x80,0x50,0x03,0x00,0x21,0x10,0xea,0x02,
- 0x00,0x00,0x4b,0x8c,0x00,0x00,0x00,0x00,0x01,0x00,0x6c,0x25,
- 0x86,0xff,0x00,0x10,0x00,0x00,0x4c,0xac,0x14,0x00,0xbf,0x8f,
- 0x58,0x00,0xbd,0x27,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc8,0xff,0xbd,0x27,
- 0x30,0x00,0xb6,0xaf,0x28,0x00,0xb4,0xaf,0x2c,0x00,0xb5,0xaf,
- 0x24,0x00,0xb3,0xaf,0x18,0x00,0xb0,0xaf,0x1c,0x00,0xb1,0xaf,
- 0x34,0x00,0xbf,0xaf,0x20,0x00,0xb2,0xaf,0x04,0x00,0x11,0x24,
- 0x00,0xa1,0x10,0x3c,0xc0,0x89,0x93,0x27,0x21,0xa8,0x00,0x00,
- 0xfc,0x89,0x94,0x27,0x0f,0x00,0x16,0x24,0x21,0x90,0x00,0x00,
- 0x88,0x96,0x80,0xaf,0x21,0x18,0x00,0x00,0x21,0x10,0x60,0x02,
- 0x00,0x00,0x4f,0x94,0x02,0x00,0x4e,0x94,0x21,0xc0,0xf0,0x01,
- 0x00,0x00,0x0e,0xa3,0x88,0x96,0x80,0xaf,0x04,0x00,0x48,0x94,
- 0x06,0x00,0x59,0x94,0x21,0x48,0x10,0x01,0x00,0x00,0x39,0xa1,
- 0x88,0x96,0x80,0xaf,0x08,0x00,0x4b,0x94,0x0a,0x00,0x4a,0x94,
- 0x21,0x60,0x70,0x01,0x00,0x00,0x8a,0xa1,0x88,0x96,0x80,0xaf,
- 0x0c,0x00,0x4f,0x94,0x0e,0x00,0x4d,0x94,0x04,0x00,0x42,0x24,
- 0x04,0x00,0x42,0x24,0x21,0x70,0xf0,0x01,0x04,0x00,0x42,0x24,
- 0x04,0x00,0x63,0x24,0x00,0x00,0xcd,0xa1,0x88,0x96,0x80,0xaf,
- 0xe7,0xff,0x71,0x14,0x04,0x00,0x42,0x24,0x00,0x00,0x58,0x94,
- 0x00,0x00,0x00,0x00,0x21,0x40,0x18,0x02,0x00,0x00,0x19,0x91,
- 0x00,0x00,0x00,0x00,0x40,0x00,0x29,0x33,0x08,0x00,0x20,0x11,
- 0x64,0x00,0x41,0x2a,0x04,0x00,0x20,0x14,0x00,0x00,0x00,0x00,
- 0x21,0x20,0x80,0x02,0x20,0x0c,0x00,0x0c,0x47,0x00,0x05,0x24,
- 0xd5,0xff,0x00,0x10,0x01,0x00,0x52,0x26,0x05,0x00,0xb5,0x26,
- 0xd1,0xff,0xb6,0x16,0x14,0x00,0x73,0x26,0x34,0x00,0xbf,0x8f,
- 0x18,0x00,0xb0,0x8f,0x1c,0x00,0xb1,0x8f,0x20,0x00,0xb2,0x8f,
- 0x24,0x00,0xb3,0x8f,0x28,0x00,0xb4,0x8f,0x2c,0x00,0xb5,0x8f,
- 0x30,0x00,0xb6,0x8f,0x08,0x00,0xe0,0x03,0x38,0x00,0xbd,0x27,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0xd0,0xff,0xbd,0x27,0x14,0x00,0xbf,0xaf,0x00,0xa1,0x0e,0x3c,
- 0x00,0x40,0xc0,0xa5,0x9c,0x96,0x98,0x8f,0xa0,0x96,0x8f,0x8f,
- 0x40,0xc9,0x18,0x00,0x23,0xc8,0x38,0x03,0x80,0xc8,0x19,0x00,
- 0x21,0xc8,0x38,0x03,0x70,0x00,0x04,0x3c,0xc0,0xc8,0x19,0x00,
- 0x00,0x80,0x84,0x34,0x21,0x30,0xf9,0x01,0x2b,0x08,0xc4,0x00,
- 0x0a,0x00,0x20,0x14,0x00,0xa0,0x02,0x3c,0x8f,0xff,0x03,0x3c,
- 0x90,0x92,0x82,0x8f,0x00,0x80,0x63,0x34,0x21,0x30,0xc3,0x00,
- 0x2b,0x08,0xc4,0x00,0xfd,0xff,0x20,0x10,0x01,0x00,0x42,0x24,
- 0x90,0x92,0x82,0xaf,0x00,0xa0,0x02,0x3c,0x14,0x00,0x42,0x34,
- 0xa0,0x96,0x86,0xaf,0x00,0xa1,0x03,0x3c,0x80,0x00,0x05,0x24,
- 0x0c,0x00,0x65,0xa0,0x88,0x96,0x80,0xaf,0x08,0x00,0x67,0x90,
- 0x08,0x00,0x6b,0x90,0x88,0x96,0x80,0xaf,0x0c,0x00,0x65,0xa0,
- 0x88,0x96,0x80,0xaf,0x08,0x00,0x66,0x90,0x08,0x00,0x6d,0x90,
- 0x00,0x62,0x0b,0x00,0x00,0x72,0x0d,0x00,0x25,0x38,0xec,0x00,
- 0x25,0x30,0xce,0x00,0x23,0x30,0xe6,0x00,0xff,0xff,0xc6,0x30,
- 0x80,0x00,0xc1,0x2c,0x07,0x00,0x20,0x14,0x42,0xc8,0x06,0x00,
- 0x00,0x00,0x58,0x8c,0x00,0x00,0x00,0x00,0x01,0x00,0x0f,0x27,
- 0xea,0xff,0x00,0x10,0x00,0x00,0x4f,0xac,0x42,0xc8,0x06,0x00,
- 0x21,0x38,0xf9,0x00,0x30,0x0d,0x00,0x0c,0x24,0x00,0xa7,0xaf,
- 0x00,0xa0,0x04,0x3c,0x24,0x00,0xa7,0x8f,0x18,0x00,0x84,0x34,
- 0x00,0xa1,0x03,0x3c,0x80,0x00,0x05,0x24,0x0c,0x00,0x65,0xa0,
- 0x88,0x96,0x80,0xaf,0x08,0x00,0x62,0x90,0x08,0x00,0x6b,0x90,
- 0x88,0x96,0x80,0xaf,0x0c,0x00,0x65,0xa0,0x88,0x96,0x80,0xaf,
- 0x08,0x00,0x66,0x90,0x08,0x00,0x6d,0x90,0x00,0x62,0x0b,0x00,
- 0x00,0x72,0x0d,0x00,0x25,0x10,0x4c,0x00,0x25,0x30,0xce,0x00,
- 0x23,0x30,0x46,0x00,0xff,0xff,0xc6,0x30,0x80,0x00,0xc1,0x2c,
- 0x07,0x00,0x20,0x14,0x42,0xc8,0x06,0x00,0x00,0x00,0x98,0x8c,
- 0x00,0x00,0x00,0x00,0x01,0x00,0x0f,0x27,0xea,0xff,0x00,0x10,
- 0x00,0x00,0x8f,0xac,0x42,0xc8,0x06,0x00,0x21,0x10,0x59,0x00,
- 0x8c,0x96,0x88,0x8f,0x23,0x50,0xe2,0x00,0x90,0x96,0x89,0x8f,
- 0xff,0xff,0x4a,0x31,0x10,0x8a,0x8c,0x8f,0x21,0x58,0x0a,0x01,
- 0x23,0x40,0x69,0x01,0x19,0x00,0x88,0x01,0x14,0x8a,0x8d,0x8f,
- 0x1c,0x8a,0x85,0x8f,0x18,0x8a,0x8f,0x8f,0x00,0x29,0x05,0x00,
- 0x01,0x00,0xa5,0x24,0x8c,0x96,0x88,0xaf,0x12,0x48,0x00,0x00,
- 0x82,0x49,0x09,0x00,0x90,0x96,0x89,0xaf,0x19,0x00,0xa9,0x01,
- 0x12,0x70,0x00,0x00,0x02,0xc1,0x0e,0x00,0x21,0x20,0x0f,0x03,
- 0x2b,0x08,0x85,0x00,0x21,0x30,0x80,0x00,0x02,0x00,0x20,0x10,
- 0x94,0x96,0x84,0xaf,0x21,0x30,0xa0,0x00,0x9c,0x96,0x99,0x8f,
- 0x00,0x00,0x00,0x00,0x05,0x00,0x26,0x13,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x66,0xa0,0x9c,0x96,0x86,0xaf,0x02,0x5a,0x06,0x00,
- 0x00,0x00,0x6b,0xa0,0x20,0x8a,0x8c,0x8f,0x00,0x00,0x00,0x00,
- 0x4b,0x00,0x80,0x11,0x00,0xa3,0x18,0x3c,0x98,0x96,0x84,0x8f,
- 0x00,0x00,0x00,0x00,0x30,0x00,0x80,0x10,0x80,0x10,0x0a,0x00,
- 0x38,0x98,0x83,0x8f,0x23,0x10,0x87,0x00,0x01,0x00,0x63,0x24,
- 0xff,0xff,0x42,0x30,0xe8,0x03,0x61,0x28,0x21,0x30,0x40,0x00,
- 0x11,0x00,0x20,0x14,0x38,0x98,0x83,0xaf,0x24,0x8a,0x8d,0x8f,
- 0x00,0x00,0x00,0x00,0x2b,0x08,0xa2,0x01,0x0d,0x00,0x20,0x10,
- 0x21,0x08,0xc0,0x00,0x28,0x8a,0x84,0x27,0x40,0x01,0x05,0x24,
- 0x28,0x00,0xa6,0xaf,0x24,0x00,0xa7,0xaf,0x20,0x0c,0x00,0x0c,
- 0x18,0x00,0xaa,0xaf,0x21,0x18,0x00,0x00,0x28,0x00,0xa6,0x8f,
- 0x24,0x00,0xa7,0x8f,0x18,0x00,0xaa,0x8f,0x38,0x98,0x83,0xaf,
- 0x21,0x08,0xc0,0x00,0x80,0x30,0x01,0x00,0x23,0x30,0xc1,0x00,
- 0x80,0x30,0x06,0x00,0x23,0x30,0xc1,0x00,0xc0,0x30,0x06,0x00,
- 0x21,0x30,0xc1,0x00,0xc0,0x30,0x06,0x00,0x23,0x30,0xc1,0x00,
- 0xc0,0x30,0x06,0x00,0x02,0x35,0x06,0x00,0x64,0x00,0xc1,0x2c,
- 0x03,0x00,0x20,0x14,0x80,0x70,0x06,0x00,0x63,0x00,0x06,0x24,
- 0x80,0x70,0x06,0x00,0xa8,0x96,0x98,0x27,0x21,0x10,0xd8,0x01,
- 0x00,0x00,0x4f,0x8c,0x00,0x00,0x00,0x00,0x01,0x00,0xf9,0x25,
- 0x00,0x00,0x59,0xac,0x80,0x10,0x0a,0x00,0x23,0x10,0x4a,0x00,
- 0x80,0x10,0x02,0x00,0x23,0x10,0x4a,0x00,0xc0,0x10,0x02,0x00,
- 0x21,0x10,0x4a,0x00,0xc0,0x10,0x02,0x00,0x23,0x10,0x4a,0x00,
- 0xc0,0x10,0x02,0x00,0x02,0x15,0x02,0x00,0x21,0x20,0xe0,0x00,
- 0x64,0x00,0x41,0x2c,0x21,0x30,0x40,0x00,0x02,0x00,0x20,0x14,
- 0x98,0x96,0x84,0xaf,0x63,0x00,0x06,0x24,0x80,0x58,0x06,0x00,
- 0x40,0x98,0x8c,0x27,0x21,0x10,0x6c,0x01,0x00,0x00,0x4d,0x8c,
- 0x00,0x00,0x00,0x00,0x01,0x00,0xae,0x25,0x00,0x00,0x4e,0xac,
- 0x00,0xa3,0x18,0x3c,0x10,0x0c,0x02,0x97,0x00,0x00,0x00,0x00,
- 0x0c,0x00,0x40,0x10,0x01,0x00,0x01,0x24,0x05,0x00,0x41,0x14,
- 0x00,0x00,0x00,0x00,0x86,0x0c,0x00,0x0c,0x00,0x00,0x00,0x00,
- 0x07,0x00,0x00,0x10,0x14,0x00,0xbf,0x8f,0x38,0x8a,0x84,0x27,
- 0x20,0x0c,0x00,0x0c,0xbf,0x01,0x05,0x24,0x00,0xa3,0x0f,0x3c,
- 0x10,0x0c,0xe0,0xa5,0x14,0x00,0xbf,0x8f,0x30,0x00,0xbd,0x27,
- 0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x40,0x00,0x82,0x8c,0x00,0x00,0x00,0x00,
- 0x1e,0x00,0x41,0x28,0x04,0x00,0x20,0x10,0x3c,0x00,0x41,0x28,
- 0x0e,0x00,0x00,0x10,0x21,0x18,0x00,0x00,0x3c,0x00,0x41,0x28,
- 0x06,0x00,0x20,0x10,0x00,0x00,0x00,0x00,0x48,0x00,0x82,0x90,
- 0x00,0x00,0x00,0x00,0x01,0x00,0x42,0x30,0x05,0x00,0x00,0x10,
- 0x01,0x00,0x42,0x24,0x48,0x00,0x82,0x90,0x00,0x00,0x00,0x00,
- 0x03,0x00,0x42,0x30,0x03,0x00,0x42,0x24,0x21,0x18,0x40,0x00,
- 0x08,0x00,0xe0,0x03,0x21,0x10,0x60,0x00,0xd8,0xff,0xbd,0x27,
- 0x1c,0x00,0xbf,0xaf,0x21,0x28,0x80,0x00,0x24,0x00,0xae,0x8c,
- 0x80,0x92,0x84,0x8f,0x28,0x00,0xa5,0xaf,0x58,0x11,0x00,0x0c,
- 0x24,0x00,0xae,0xaf,0x28,0x00,0xa5,0x8f,0x21,0x30,0x40,0x00,
- 0x50,0x00,0xa3,0x94,0x00,0x00,0x00,0x00,0x01,0x00,0x6f,0x30,
- 0x22,0x00,0xe0,0x15,0x00,0x00,0x00,0x00,0x28,0x00,0xb9,0x94,
- 0x01,0x00,0x78,0x34,0x00,0x10,0x28,0x33,0x07,0x00,0x00,0x11,
- 0x50,0x00,0xb8,0xa4,0x50,0x00,0xa9,0x94,0x00,0x80,0x0b,0x3c,
- 0xa4,0x35,0x6b,0x25,0x00,0x02,0x2a,0x39,0x50,0x00,0xaa,0xa4,
- 0x04,0x00,0xab,0xac,0x5f,0x00,0xad,0x90,0x68,0x00,0xac,0x90,
- 0x03,0x00,0xae,0x31,0x24,0x00,0xb8,0x8f,0x27,0x78,0xc0,0x01,
- 0x00,0x20,0x01,0x3c,0x24,0x18,0x8f,0x01,0x25,0x10,0xa1,0x00,
- 0x10,0x00,0x03,0xa3,0x54,0x00,0x59,0x90,0x54,0x00,0x48,0x90,
- 0x26,0x20,0x23,0x03,0x03,0x00,0x84,0x30,0xff,0x00,0x89,0x30,
- 0x26,0x50,0x09,0x01,0x54,0x00,0x4a,0xa0,0x58,0x00,0x4b,0x90,
- 0x56,0x00,0x4d,0x90,0x00,0x00,0x00,0x00,0x24,0x70,0x8d,0x00,
- 0x25,0x60,0x6e,0x01,0x58,0x00,0x4c,0xa0,0x60,0x11,0x00,0x0c,
- 0x21,0x20,0xc0,0x00,0x1c,0x00,0xbf,0x8f,0x28,0x00,0xbd,0x27,
- 0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0xd8,0xff,0xbd,0x27,
- 0x1c,0x00,0xbf,0xaf,0x21,0x28,0x80,0x00,0x24,0x00,0xae,0x8c,
- 0x80,0x92,0x84,0x8f,0x28,0x00,0xa5,0xaf,0x58,0x11,0x00,0x0c,
- 0x24,0x00,0xae,0xaf,0x28,0x00,0xa5,0x8f,0x21,0x30,0x40,0x00,
- 0x50,0x00,0xa3,0x94,0x00,0x00,0x00,0x00,0x01,0x00,0x6f,0x30,
- 0x21,0x00,0xe0,0x11,0x00,0x00,0x00,0x00,0x28,0x00,0xb9,0x94,
- 0xfe,0xff,0x78,0x30,0x00,0x10,0x28,0x33,0x07,0x00,0x00,0x11,
- 0x50,0x00,0xb8,0xa4,0x50,0x00,0xa9,0x94,0x00,0x80,0x0b,0x3c,
- 0xa4,0x35,0x6b,0x25,0x00,0x02,0x2a,0x39,0x50,0x00,0xaa,0xa4,
- 0x04,0x00,0xab,0xac,0x5f,0x00,0xad,0x90,0x68,0x00,0xac,0x90,
- 0x24,0x00,0xaf,0x8f,0x03,0x00,0xae,0x31,0x00,0x20,0x01,0x3c,
- 0x25,0x18,0x8e,0x01,0x25,0x10,0xa1,0x00,0x10,0x00,0xe3,0xa1,
- 0x54,0x00,0x58,0x90,0x54,0x00,0x59,0x90,0x26,0x20,0x03,0x03,
- 0x03,0x00,0x84,0x30,0xff,0x00,0x88,0x30,0x26,0x48,0x28,0x03,
- 0x54,0x00,0x49,0xa0,0x58,0x00,0x4a,0x90,0x56,0x00,0x4b,0x90,
- 0x00,0x00,0x00,0x00,0x24,0x68,0x8b,0x00,0x25,0x60,0x4d,0x01,
- 0x58,0x00,0x4c,0xa0,0x60,0x11,0x00,0x0c,0x21,0x20,0xc0,0x00,
- 0x1c,0x00,0xbf,0x8f,0x28,0x00,0xbd,0x27,0x08,0x00,0xe0,0x03,
- 0x00,0x00,0x00,0x00,0xd8,0xff,0xbd,0x27,0x18,0x00,0xb0,0xaf,
- 0x21,0x80,0x80,0x00,0x1c,0x00,0xbf,0xaf,0x24,0x00,0x06,0x8e,
- 0x21,0x38,0xa0,0x00,0x80,0x92,0x84,0x8f,0x2c,0x00,0xa7,0xaf,
- 0x58,0x11,0x00,0x0c,0x24,0x00,0xa6,0xaf,0x2c,0x00,0xa7,0x8f,
- 0x28,0x00,0x0f,0x96,0x30,0x00,0xe9,0x30,0x02,0x49,0x09,0x00,
- 0x05,0x00,0x29,0x25,0x01,0x00,0x0e,0x24,0x04,0x18,0x2e,0x01,
- 0x24,0x00,0xa6,0x8f,0xff,0xff,0x63,0x24,0x20,0x00,0xf8,0x31,
- 0x21,0x50,0x40,0x00,0x02,0x00,0x08,0x24,0x21,0x20,0x60,0x00,
- 0x02,0x00,0x00,0x13,0x62,0x00,0x03,0xa2,0x7f,0x00,0x64,0x30,
- 0x6a,0x00,0x19,0x96,0x00,0x01,0xed,0x30,0x00,0xff,0x2b,0x33,
- 0x25,0x60,0x64,0x01,0x6a,0x00,0x0c,0xa6,0x06,0x00,0xa0,0x11,
- 0xfb,0xff,0x25,0x25,0x00,0x02,0xee,0x30,0x02,0x00,0xc0,0x15,
- 0x08,0x00,0xa5,0x34,0x10,0x00,0xa5,0x34,0x03,0x00,0x08,0x24,
- 0x40,0x00,0xef,0x30,0x04,0x00,0xe0,0x11,0x00,0x04,0xf8,0x30,
- 0x04,0x00,0xa5,0x34,0x01,0x00,0x08,0x25,0x00,0x04,0xf8,0x30,
- 0x0f,0x00,0x00,0x13,0x00,0x00,0x00,0x00,0x65,0x00,0x19,0x92,
- 0x00,0x00,0x00,0x00,0x80,0x58,0x19,0x00,0x23,0x58,0x79,0x01,
- 0x80,0x58,0x0b,0x00,0x23,0x58,0x79,0x01,0x80,0x58,0x0b,0x00,
- 0x21,0x08,0x7c,0x01,0x38,0x94,0x2c,0x8c,0x03,0x00,0x01,0x24,
- 0x03,0x00,0x81,0x11,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x10,
- 0x70,0x8a,0x83,0x27,0x50,0x8a,0x83,0x27,0x0f,0x00,0xed,0x30,
- 0x0c,0x00,0xd8,0x90,0x40,0x70,0x0d,0x00,0x21,0x78,0x6e,0x00,
- 0x00,0x00,0xe2,0x95,0x80,0x00,0x19,0x37,0x21,0xc0,0x28,0x01,
- 0x19,0x00,0x58,0x00,0x0c,0x00,0xd9,0xa0,0x7f,0x00,0x0b,0x24,
- 0x04,0x00,0xcb,0xa0,0x00,0x00,0xc2,0xa0,0x03,0x62,0x02,0x00,
- 0x04,0x00,0xcc,0xa0,0x0c,0x00,0xcd,0x90,0x21,0x20,0x40,0x01,
- 0x40,0x00,0xae,0x31,0x21,0x78,0xc5,0x01,0x0c,0x00,0xcf,0xa0,
- 0x12,0xc8,0x00,0x00,0x40,0x00,0x19,0xae,0x60,0x11,0x00,0x0c,
- 0x2c,0x00,0x07,0xa6,0x20,0x1a,0x00,0x0c,0x21,0x20,0x00,0x02,
- 0x21,0x20,0x00,0x02,0x16,0x17,0x00,0x0c,0x21,0x28,0x40,0x00,
- 0x1c,0x00,0xbf,0x8f,0x18,0x00,0xb0,0x8f,0x08,0x00,0xe0,0x03,
- 0x28,0x00,0xbd,0x27,0xe8,0xff,0xbd,0x27,0x21,0x30,0x80,0x00,
- 0x14,0x00,0xbf,0xaf,0x80,0x92,0x84,0x8f,0x18,0x00,0xa6,0xaf,
- 0x58,0x11,0x00,0x0c,0x1c,0x00,0xa5,0xaf,0x18,0x00,0xa6,0x8f,
- 0x1c,0x00,0xa5,0x8f,0x28,0x00,0xce,0x94,0x21,0x20,0x40,0x00,
- 0x26,0x78,0xae,0x00,0x00,0x10,0xf8,0x31,0x0b,0x00,0x00,0x13,
- 0x00,0x00,0x00,0x00,0x50,0x00,0xc3,0x94,0x00,0x00,0x00,0x00,
- 0x01,0x00,0x79,0x30,0x06,0x00,0x20,0x13,0x00,0x00,0x00,0x00,
- 0x00,0x80,0x09,0x3c,0x00,0x02,0x68,0x34,0xa4,0x35,0x29,0x25,
- 0x50,0x00,0xc8,0xa4,0x04,0x00,0xc9,0xac,0x62,0x00,0xc2,0x90,
- 0x50,0x00,0xc3,0x94,0x20,0x00,0xaa,0x30,0x03,0x00,0x40,0x11,
- 0x10,0x00,0xab,0x30,0x7f,0x00,0x42,0x30,0x10,0x00,0xab,0x30,
- 0x02,0x00,0x60,0x11,0x00,0x1a,0x42,0x34,0x00,0x04,0x42,0x34,
- 0xff,0xff,0x01,0x3c,0x6a,0x00,0xc2,0xa4,0xfb,0x3f,0x21,0x34,
- 0x00,0x04,0xac,0x30,0x0d,0x00,0x80,0x11,0x24,0x10,0x61,0x00,
- 0x00,0x20,0xad,0x30,0x02,0x00,0xa0,0x11,0x00,0x80,0x42,0x34,
- 0x00,0x40,0x42,0x34,0x00,0x08,0xae,0x30,0x04,0x00,0xc0,0x11,
- 0xff,0xef,0x01,0x24,0x06,0x00,0x00,0x10,0x04,0x00,0x42,0x34,
- 0xff,0xef,0x01,0x24,0x03,0x00,0x00,0x10,0x24,0x10,0x41,0x00,
- 0xff,0xe7,0x01,0x24,0x24,0x10,0x41,0x00,0x50,0x00,0xc2,0xa4,
- 0x60,0x11,0x00,0x0c,0x28,0x00,0xc5,0xa4,0x14,0x00,0xbf,0x8f,
- 0x18,0x00,0xbd,0x27,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,
- 0xe8,0xff,0xbd,0x27,0x21,0x18,0x80,0x00,0x14,0x00,0xbf,0xaf,
- 0x80,0x92,0x84,0x8f,0x18,0x00,0xa3,0xaf,0x58,0x11,0x00,0x0c,
- 0x1c,0x00,0xa5,0xaf,0x1c,0x00,0xa5,0x8f,0x7f,0xff,0x01,0x24,
- 0x18,0x00,0xa3,0x8f,0x24,0x70,0xa1,0x00,0x0b,0x00,0xc0,0x11,
- 0x21,0x20,0x40,0x00,0x50,0x00,0x62,0x94,0x00,0x00,0x00,0x00,
- 0x80,0x00,0x4f,0x30,0x04,0x00,0xe0,0x15,0x80,0x00,0x58,0x34,
- 0x50,0x00,0x62,0x94,0x63,0x00,0x60,0xa0,0x80,0x00,0x58,0x34,
- 0x05,0x00,0x00,0x10,0x50,0x00,0x78,0xa4,0x50,0x00,0x79,0x94,
- 0x00,0x00,0x00,0x00,0x7f,0xff,0x28,0x33,0x50,0x00,0x68,0xa4,
- 0x00,0x80,0x09,0x3c,0xa4,0x35,0x29,0x25,0x80,0x00,0xaa,0x30,
- 0x04,0x00,0x40,0x11,0x04,0x00,0x69,0xac,0x7f,0x00,0x0b,0x24,
- 0x02,0x00,0x00,0x10,0x60,0x00,0x6b,0xa0,0x60,0x00,0x60,0xa0,
- 0x60,0x11,0x00,0x0c,0x2a,0x00,0x65,0xa4,0x14,0x00,0xbf,0x8f,
- 0x18,0x00,0xbd,0x27,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,
- 0xe8,0xff,0xbd,0x27,0x21,0x18,0x80,0x00,0x14,0x00,0xbf,0xaf,
- 0x80,0x92,0x84,0x8f,0x18,0x00,0xa3,0xaf,0x58,0x11,0x00,0x0c,
- 0x1c,0x00,0xa5,0xaf,0x18,0x00,0xa3,0x8f,0x1c,0x00,0xa5,0x8f,
- 0x6c,0x00,0x6e,0x8c,0xff,0xff,0x06,0x24,0x09,0x00,0xce,0x14,
- 0x21,0x20,0x40,0x00,0xff,0xff,0x01,0x34,0x06,0x00,0xa1,0x10,
- 0x00,0x00,0x00,0x00,0x50,0x00,0x6f,0x94,0x6c,0x00,0x60,0xac,
- 0xff,0xfe,0xf8,0x31,0x13,0x00,0x00,0x10,0x50,0x00,0x78,0xa4,
- 0x50,0x00,0x68,0x94,0x00,0x80,0x0a,0x3c,0x01,0x00,0x19,0x24,
- 0xa4,0x35,0x4a,0x25,0xff,0xff,0x01,0x34,0x00,0x01,0x09,0x35,
- 0x4b,0x00,0x79,0xa0,0x50,0x00,0x69,0xa4,0x03,0x00,0xa1,0x14,
- 0x04,0x00,0x6a,0xac,0x07,0x00,0x00,0x10,0x6c,0x00,0x66,0xac,
- 0xc0,0x60,0x05,0x00,0x6c,0x00,0x6b,0x8c,0x21,0x60,0x85,0x01,
- 0x40,0x62,0x0c,0x00,0x21,0x10,0x6c,0x01,0x6c,0x00,0x62,0xac,
- 0x60,0x11,0x00,0x0c,0x00,0x00,0x00,0x00,0x14,0x00,0xbf,0x8f,
- 0x18,0x00,0xbd,0x27,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,
- 0xe0,0xff,0xbd,0x27,0x14,0x00,0xbf,0xaf,0x21,0x30,0x80,0x00,
- 0x24,0x00,0xc7,0x8c,0x10,0x00,0xae,0x30,0x03,0x00,0xc0,0x11,
- 0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x10,0x1f,0x00,0xa5,0x30,
- 0x03,0x00,0xa5,0x30,0x08,0x00,0xa5,0x34,0x80,0x92,0x84,0x8f,
- 0x24,0x00,0xa5,0xaf,0x20,0x00,0xa6,0xaf,0x58,0x11,0x00,0x0c,
- 0x1c,0x00,0xa7,0xaf,0x20,0x00,0xa6,0x8f,0x24,0x00,0xa5,0x8f,
- 0x50,0x00,0xcf,0x94,0x1c,0x00,0xa7,0x8f,0x01,0x00,0xf8,0x31,
- 0x21,0x20,0x40,0x00,0x07,0x00,0x00,0x13,0x68,0x00,0xc5,0xa0,
- 0x5f,0x00,0xd9,0x90,0x00,0x00,0x00,0x00,0x03,0x00,0x28,0x33,
- 0x27,0x48,0x00,0x01,0x05,0x00,0x00,0x10,0x24,0x28,0xa9,0x00,
- 0x5f,0x00,0xca,0x90,0x00,0x00,0x00,0x00,0x03,0x00,0x4b,0x31,
- 0x25,0x28,0xab,0x00,0x00,0x20,0x01,0x3c,0x10,0x00,0xe5,0xa0,
- 0x25,0x10,0xc1,0x00,0x54,0x00,0x4c,0x90,0x54,0x00,0x4d,0x90,
- 0x26,0x18,0x85,0x01,0x03,0x00,0x63,0x30,0xff,0x00,0x6e,0x30,
- 0x26,0x78,0xae,0x01,0x54,0x00,0x4f,0xa0,0x58,0x00,0x58,0x90,
- 0x56,0x00,0x59,0x90,0x00,0x00,0x00,0x00,0x24,0x40,0x79,0x00,
- 0x25,0x48,0x08,0x03,0x60,0x11,0x00,0x0c,0x58,0x00,0x49,0xa0,
- 0x14,0x00,0xbf,0x8f,0x20,0x00,0xbd,0x27,0x08,0x00,0xe0,0x03,
- 0x00,0x00,0x00,0x00,0xd8,0xff,0xbd,0x27,0x1c,0x00,0xbf,0xaf,
- 0x21,0x30,0x80,0x00,0x24,0x00,0xce,0x8c,0xf3,0x00,0xa5,0x30,
- 0x80,0x92,0x84,0x8f,0x2c,0x00,0xa5,0xaf,0x28,0x00,0xa6,0xaf,
- 0x58,0x11,0x00,0x0c,0x24,0x00,0xae,0xaf,0x28,0x00,0xa6,0x8f,
- 0x2c,0x00,0xa5,0x8f,0x4a,0x00,0xd8,0x90,0xf0,0x00,0xaf,0x30,
- 0x49,0x00,0xcf,0xa0,0x49,0x00,0xc8,0x90,0x50,0x00,0xca,0x94,
- 0x0f,0xff,0x01,0x24,0x24,0xc8,0x01,0x03,0x5f,0x00,0xc5,0xa0,
- 0x25,0x48,0x28,0x03,0x01,0x00,0x4b,0x31,0x21,0x20,0x40,0x00,
- 0x4a,0x00,0xc9,0xa0,0x05,0x00,0x60,0x11,0x03,0x00,0xa5,0x30,
- 0x68,0x00,0xcd,0x90,0x27,0x60,0xa0,0x00,0x04,0x00,0x00,0x10,
- 0x24,0x28,0x8d,0x01,0x68,0x00,0xce,0x90,0x00,0x00,0x00,0x00,
- 0x25,0x28,0xae,0x00,0x24,0x00,0xaf,0x8f,0x00,0x20,0x01,0x3c,
- 0x25,0x10,0xc1,0x00,0x10,0x00,0xe5,0xa1,0x54,0x00,0x58,0x90,
- 0x54,0x00,0x59,0x90,0x26,0x18,0x05,0x03,0x03,0x00,0x63,0x30,
- 0xff,0x00,0x68,0x30,0x26,0x48,0x28,0x03,0x54,0x00,0x49,0xa0,
- 0x58,0x00,0x4a,0x90,0x56,0x00,0x4b,0x90,0x00,0x00,0x00,0x00,
- 0x24,0x60,0x6b,0x00,0x25,0x68,0x4c,0x01,0x60,0x11,0x00,0x0c,
- 0x58,0x00,0x4d,0xa0,0x1c,0x00,0xbf,0x8f,0x28,0x00,0xbd,0x27,
- 0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0xd8,0xff,0xbd,0x27,
- 0x18,0x00,0xb0,0xaf,0x21,0x80,0x80,0x00,0x1c,0x00,0xbf,0xaf,
- 0x24,0x00,0x05,0x8e,0x80,0x92,0x84,0x8f,0x58,0x11,0x00,0x0c,
- 0x20,0x00,0xa5,0xaf,0x20,0x00,0xa5,0x8f,0x00,0x20,0x01,0x3c,
- 0x25,0x18,0x01,0x02,0x0a,0x00,0x60,0xa4,0x0c,0x00,0x60,0xa4,
- 0x12,0x00,0x60,0xa4,0x14,0x00,0x60,0xa4,0xff,0xff,0x0e,0x34,
- 0x3f,0x00,0x0f,0x24,0x78,0x00,0x18,0x24,0x01,0x00,0x06,0x24,
- 0x18,0x00,0x00,0xa6,0x1a,0x00,0x00,0xa6,0x1c,0x00,0x0e,0xa6,
- 0x28,0x00,0x00,0xa6,0x2a,0x00,0x00,0xa6,0x2c,0x00,0x0f,0xa6,
- 0x40,0x00,0x18,0xae,0x44,0x00,0x00,0xae,0x4b,0x00,0x00,0xa2,
- 0x4c,0x00,0x66,0xa0,0x4d,0x00,0x66,0xa0,0x4e,0x00,0x66,0xa0,
- 0xff,0x00,0x07,0x24,0x4f,0x00,0x60,0xa0,0x56,0x00,0x67,0xa0,
- 0x10,0x00,0x19,0x24,0x50,0x00,0x19,0xa6,0x49,0x00,0x00,0xa2,
- 0x4a,0x00,0x00,0xa2,0x54,0x00,0x60,0xa0,0x57,0x00,0x60,0xa0,
- 0x58,0x00,0x60,0xa0,0x59,0x00,0x60,0xa0,0x5a,0x00,0x60,0xa0,
- 0x5b,0x00,0x60,0xa0,0x00,0x80,0x0b,0x3c,0x00,0x80,0x0c,0x3c,
- 0x00,0x80,0x0d,0x3c,0x11,0x00,0x08,0x24,0x13,0x00,0x09,0x24,
- 0xff,0x0a,0x0a,0x24,0xa4,0x35,0x6b,0x25,0x90,0x3d,0x8c,0x25,
- 0x0c,0x3a,0xad,0x25,0x5c,0x00,0x08,0xa2,0x5d,0x00,0x09,0xa2,
- 0x5e,0x00,0x00,0xa2,0x5f,0x00,0x00,0xa2,0x60,0x00,0x00,0xa2,
- 0x61,0x00,0x00,0xa2,0x62,0x00,0x07,0xa2,0x63,0x00,0x00,0xa2,
- 0x64,0x00,0x00,0xa2,0x66,0x00,0x00,0xa2,0x67,0x00,0x00,0xa2,
- 0x68,0x00,0x00,0xa2,0x69,0x00,0x00,0xa2,0x6a,0x00,0x0a,0xa6,
- 0x6c,0x00,0x00,0xae,0x04,0x00,0x0b,0xae,0x74,0x00,0x0c,0xae,
- 0x34,0x00,0x0d,0xae,0x80,0x00,0x0e,0x24,0x0c,0x00,0x0f,0x24,
- 0x0c,0x00,0xae,0xa0,0x00,0x00,0xaf,0xa0,0x03,0x00,0x18,0x24,
- 0x04,0x00,0xa0,0xa0,0x0c,0x00,0xb8,0xa0,0x0f,0x00,0x19,0x24,
- 0x08,0x00,0xa6,0xa0,0x08,0x00,0xb9,0xa0,0x08,0x00,0x08,0x24,
- 0x04,0x00,0xa6,0xa0,0x10,0x00,0xa8,0xa0,0x08,0x00,0xa0,0x90,
- 0x00,0x00,0xa0,0x90,0x14,0x00,0xa0,0x90,0x18,0x00,0xa0,0x90,
- 0x60,0x11,0x00,0x0c,0x21,0x20,0x40,0x00,0x20,0x1a,0x00,0x0c,
- 0x21,0x20,0x00,0x02,0x21,0x20,0x00,0x02,0x16,0x17,0x00,0x0c,
- 0x21,0x28,0x40,0x00,0x1c,0x00,0xbf,0x8f,0x18,0x00,0xb0,0x8f,
- 0x08,0x00,0xe0,0x03,0x28,0x00,0xbd,0x27,0x10,0x94,0x8e,0x27,
- 0x23,0x78,0xae,0x00,0x2c,0x00,0x01,0x24,0x1a,0x00,0xe1,0x01,
- 0xe8,0xff,0xbd,0x27,0x14,0x00,0xbf,0xaf,0x48,0x00,0x86,0xa0,
- 0x40,0x41,0x06,0x00,0x12,0xc0,0x00,0x00,0x65,0x00,0x98,0xa0,
- 0x04,0x00,0xb9,0x8c,0x00,0x00,0x00,0x00,0x21,0x48,0x28,0x03,
- 0x00,0x01,0x2a,0x25,0x24,0x00,0x8a,0xac,0x01,0x1c,0x00,0x0c,
- 0x18,0x00,0xa4,0xaf,0xbc,0x92,0x8b,0x8f,0x18,0x00,0xa4,0x8f,
- 0x03,0x00,0x60,0x15,0x00,0x00,0x00,0x00,0x09,0x00,0x00,0x10,
- 0x30,0x00,0x84,0xac,0xbc,0x92,0x8c,0x8f,0x00,0x00,0x00,0x00,
- 0x30,0x00,0x8d,0x8d,0x00,0x00,0x00,0x00,0x30,0x00,0x8d,0xac,
- 0xbc,0x92,0x8e,0x8f,0x00,0x00,0x00,0x00,0x30,0x00,0xc4,0xad,
- 0x14,0x00,0xbf,0x8f,0xbc,0x92,0x84,0xaf,0x08,0x00,0xe0,0x03,
- 0x18,0x00,0xbd,0x27,0x00,0x00,0x00,0x00,0x08,0x00,0xe0,0x03,
- 0x00,0x00,0x00,0x00,0xe8,0xff,0xbd,0x27,0x21,0x28,0x80,0x00,
- 0x14,0x00,0xbf,0xaf,0x80,0x92,0x84,0x8f,0x58,0x11,0x00,0x0c,
- 0x18,0x00,0xa5,0xaf,0x18,0x00,0xa5,0x8f,0x21,0x38,0x40,0x00,
- 0x50,0x00,0xa6,0x94,0x00,0x00,0x00,0x00,0x01,0x00,0xce,0x30,
- 0x17,0x00,0xc0,0x15,0x00,0x00,0x00,0x00,0x5f,0x00,0xb9,0x90,
- 0x01,0x00,0xcf,0x34,0x00,0x20,0x01,0x3c,0x68,0x00,0xb8,0x90,
- 0x50,0x00,0xaf,0xa4,0x25,0x10,0xa1,0x00,0x03,0x00,0x28,0x33,
- 0x54,0x00,0x4a,0x90,0x27,0x48,0x00,0x01,0x24,0x20,0x09,0x03,
- 0x26,0x18,0x44,0x01,0x54,0x00,0x4b,0x90,0x03,0x00,0x63,0x30,
- 0xff,0x00,0x6c,0x30,0x26,0x68,0x6c,0x01,0x54,0x00,0x4d,0xa0,
- 0x58,0x00,0x4e,0x90,0x56,0x00,0x4f,0x90,0x00,0x00,0x00,0x00,
- 0x24,0xc8,0x6f,0x00,0x25,0x40,0xd9,0x01,0x58,0x00,0x48,0xa0,
- 0x60,0x11,0x00,0x0c,0x21,0x20,0xe0,0x00,0x14,0x00,0xbf,0x8f,
- 0x18,0x00,0xbd,0x27,0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,
- 0xe8,0xff,0xbd,0x27,0x21,0x28,0x80,0x00,0x14,0x00,0xbf,0xaf,
- 0x80,0x92,0x84,0x8f,0x58,0x11,0x00,0x0c,0x18,0x00,0xa5,0xaf,
- 0x18,0x00,0xa5,0x8f,0x21,0x38,0x40,0x00,0x50,0x00,0xa6,0x94,
- 0x00,0x00,0x00,0x00,0x01,0x00,0xce,0x30,0x16,0x00,0xc0,0x11,
- 0x00,0x00,0x00,0x00,0x5f,0x00,0xb9,0x90,0xfe,0xff,0xcf,0x30,
- 0x00,0x20,0x01,0x3c,0x68,0x00,0xb8,0x90,0x50,0x00,0xaf,0xa4,
- 0x25,0x10,0xa1,0x00,0x54,0x00,0x49,0x90,0x03,0x00,0x28,0x33,
- 0x25,0x20,0x08,0x03,0x26,0x18,0x24,0x01,0x54,0x00,0x4a,0x90,
- 0x03,0x00,0x63,0x30,0xff,0x00,0x6b,0x30,0x26,0x60,0x4b,0x01,
- 0x54,0x00,0x4c,0xa0,0x58,0x00,0x4d,0x90,0x56,0x00,0x4e,0x90,
- 0x00,0x00,0x00,0x00,0x24,0x78,0x6e,0x00,0x25,0xc8,0xaf,0x01,
- 0x58,0x00,0x59,0xa0,0x60,0x11,0x00,0x0c,0x21,0x20,0xe0,0x00,
- 0x14,0x00,0xbf,0x8f,0x18,0x00,0xbd,0x27,0x08,0x00,0xe0,0x03,
- 0x00,0x00,0x00,0x00,0xd0,0xff,0xbd,0x27,0x14,0x00,0xbf,0xaf,
- 0x21,0x38,0x80,0x00,0x24,0x00,0xe6,0x8c,0xf3,0x00,0xa5,0x30,
- 0x80,0x92,0x84,0x8f,0x34,0x00,0xa5,0xaf,0x30,0x00,0xa7,0xaf,
- 0x58,0x11,0x00,0x0c,0x2c,0x00,0xa6,0xaf,0x30,0x00,0xa7,0x8f,
- 0x34,0x00,0xa5,0x8f,0x2c,0x00,0xa6,0x8f,0xf0,0x00,0xae,0x30,
- 0x4a,0x00,0xef,0x90,0x49,0x00,0xee,0xa0,0x49,0x00,0xf9,0x90,
- 0x50,0x00,0xe9,0x94,0x0f,0xff,0x01,0x24,0x24,0xc0,0xe1,0x01,
- 0x5f,0x00,0xe5,0xa0,0x25,0x40,0x19,0x03,0x01,0x00,0x2a,0x31,
- 0x21,0x20,0x40,0x00,0x4a,0x00,0xe8,0xa0,0x05,0x00,0x40,0x11,
- 0x03,0x00,0xa5,0x30,0x68,0x00,0xec,0x90,0x27,0x58,0xa0,0x00,
- 0x04,0x00,0x00,0x10,0x24,0x28,0x6c,0x01,0x68,0x00,0xed,0x90,
- 0x00,0x00,0x00,0x00,0x25,0x28,0xad,0x00,0x4a,0x00,0xe3,0x90,
- 0x00,0x00,0x00,0x00,0x20,0x00,0x63,0x30,0x04,0x00,0x60,0x10,
- 0x21,0x10,0x00,0x00,0x02,0x00,0x00,0x10,0x04,0x00,0x02,0x24,
- 0x21,0x10,0x00,0x00,0x28,0x00,0xce,0x90,0x00,0x00,0x00,0x00,
- 0x04,0x00,0xcf,0x31,0x47,0x00,0x4f,0x10,0x00,0x20,0x01,0x3c,
- 0x04,0x00,0x60,0x10,0x00,0x00,0x00,0x00,0x04,0x00,0x18,0x24,
- 0x02,0x00,0x00,0x10,0x28,0x00,0xd8,0xa0,0x28,0x00,0xc0,0xa0,
- 0x10,0x27,0x19,0x24,0x1c,0x00,0xb9,0xaf,0x1c,0x00,0xa2,0x8f,
- 0x1c,0x00,0xa8,0x8f,0x00,0x00,0x00,0x00,0xff,0xff,0x09,0x25,
- 0x0f,0x00,0x40,0x10,0x1c,0x00,0xa9,0xaf,0x2c,0x00,0xca,0x90,
- 0x00,0x00,0x00,0x00,0x0c,0x00,0x40,0x11,0x80,0x00,0x0e,0x24,
- 0x1c,0x00,0xa2,0x8f,0x1c,0x00,0xab,0x8f,0x00,0x00,0x00,0x00,
- 0xff,0xff,0x6c,0x25,0x05,0x00,0x40,0x10,0x1c,0x00,0xac,0xaf,
- 0x2c,0x00,0xcd,0x90,0x00,0x00,0x00,0x00,0xf8,0xff,0xa0,0x15,
- 0x1c,0x00,0xa2,0x8f,0x80,0x00,0x0e,0x24,0x2c,0x00,0xce,0xa0,
- 0x10,0x27,0x0f,0x24,0x18,0x00,0xaf,0xaf,0x18,0x00,0xa2,0x8f,
- 0x18,0x00,0xb8,0x8f,0x00,0x00,0x00,0x00,0xff,0xff,0x19,0x27,
- 0x0f,0x00,0x40,0x10,0x18,0x00,0xb9,0xaf,0x2c,0x00,0xc8,0x90,
- 0x00,0x00,0x00,0x00,0x0c,0x00,0x00,0x11,0x41,0x00,0x0c,0x24,
- 0x18,0x00,0xa2,0x8f,0x18,0x00,0xa9,0x8f,0x00,0x00,0x00,0x00,
- 0xff,0xff,0x2a,0x25,0x05,0x00,0x40,0x10,0x18,0x00,0xaa,0xaf,
- 0x2c,0x00,0xcb,0x90,0x00,0x00,0x00,0x00,0xf8,0xff,0x60,0x15,
- 0x18,0x00,0xa2,0x8f,0x41,0x00,0x0c,0x24,0x2c,0x00,0xcc,0xa0,
- 0x2c,0x00,0xe2,0x94,0x00,0x00,0x00,0x00,0x0f,0x00,0x43,0x30,
- 0x04,0x00,0x61,0x28,0x06,0x00,0x20,0x10,0x21,0x08,0x7c,0x00,
- 0x00,0x04,0x4d,0x30,0x03,0x00,0xa0,0x11,0x21,0x08,0x7c,0x00,
- 0x21,0x18,0x00,0x00,0x21,0x08,0x7c,0x00,0x90,0x8a,0x22,0x90,
- 0x00,0x00,0x00,0x00,0x08,0x00,0xc2,0xa0,0x0c,0x00,0xc2,0xa0,
- 0x00,0x20,0x01,0x3c,0x25,0x10,0xe1,0x00,0x54,0x00,0x4e,0x90,
- 0x54,0x00,0x4f,0x90,0x26,0x18,0xc5,0x01,0x03,0x00,0x63,0x30,
- 0xff,0x00,0x78,0x30,0x26,0xc8,0xf8,0x01,0x54,0x00,0x59,0xa0,
- 0x58,0x00,0x48,0x90,0x56,0x00,0x49,0x90,0x00,0x00,0x00,0x00,
- 0x24,0x50,0x69,0x00,0x25,0x58,0x0a,0x01,0x60,0x11,0x00,0x0c,
- 0x58,0x00,0x4b,0xa0,0x14,0x00,0xbf,0x8f,0x30,0x00,0xbd,0x27,
- 0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0xe0,0xff,0xbd,0x27,
- 0x20,0x00,0xa4,0xaf,0x1c,0x00,0xbf,0xaf,0x80,0x92,0x84,0x8f,
- 0x58,0x11,0x00,0x0c,0x24,0x00,0xa5,0xaf,0x24,0x00,0xae,0x8f,
- 0x20,0x00,0xaf,0x8f,0x21,0x20,0x40,0x00,0x60,0x11,0x00,0x0c,
- 0x28,0x00,0xee,0xa5,0x1c,0x00,0xbf,0x8f,0x20,0x00,0xbd,0x27,
- 0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0xe0,0xff,0xbd,0x27,
- 0x14,0x00,0xbf,0xaf,0x21,0x30,0x80,0x00,0x24,0x00,0xc7,0x8c,
- 0x80,0x92,0x84,0x8f,0x20,0x00,0xa6,0xaf,0x24,0x00,0xa5,0xaf,
- 0x58,0x11,0x00,0x0c,0x1c,0x00,0xa7,0xaf,0x24,0x00,0xa5,0x8f,
- 0x20,0x00,0xa6,0x8f,0x1c,0x00,0xa7,0x8f,0x2c,0x00,0xc5,0xa4,
- 0x2c,0x00,0xc3,0x94,0x21,0x20,0x40,0x00,0x0f,0x00,0x65,0x30,
- 0x04,0x00,0xa1,0x2c,0x06,0x00,0x20,0x10,0x21,0x08,0xbc,0x00,
- 0x00,0x04,0x6e,0x30,0x03,0x00,0xc0,0x11,0x21,0x08,0xbc,0x00,
- 0x21,0x28,0x00,0x00,0x21,0x08,0xbc,0x00,0x90,0x8a,0x22,0x90,
- 0x00,0x00,0x00,0x00,0x08,0x00,0xe2,0xa0,0x0c,0x00,0xe2,0xa0,
- 0x60,0x11,0x00,0x0c,0x20,0x00,0xa6,0xaf,0x20,0x00,0xa6,0x8f,
- 0x21,0x28,0x00,0x00,0x16,0x17,0x00,0x0c,0x21,0x20,0xc0,0x00,
- 0x14,0x00,0xbf,0x8f,0x20,0x00,0xbd,0x27,0x08,0x00,0xe0,0x03,
- 0x00,0x00,0x00,0x00,0xe8,0xff,0xbd,0x27,0x21,0x18,0x80,0x00,
- 0x14,0x00,0xbf,0xaf,0x80,0x92,0x84,0x8f,0x1c,0x00,0xa5,0xaf,
- 0x58,0x11,0x00,0x0c,0x18,0x00,0xa3,0xaf,0x1c,0x00,0xa5,0x8f,
- 0x7f,0xff,0x01,0x24,0x18,0x00,0xa3,0x8f,0x24,0x70,0xa1,0x00,
- 0x0b,0x00,0xc0,0x11,0x21,0x20,0x40,0x00,0x50,0x00,0x62,0x94,
- 0x00,0x00,0x00,0x00,0x80,0x00,0x4f,0x30,0x04,0x00,0xe0,0x15,
- 0x80,0x00,0x58,0x34,0x50,0x00,0x62,0x94,0x63,0x00,0x60,0xa0,
- 0x80,0x00,0x58,0x34,0x05,0x00,0x00,0x10,0x50,0x00,0x78,0xa4,
- 0x50,0x00,0x79,0x94,0x00,0x00,0x00,0x00,0x7f,0xff,0x28,0x33,
- 0x50,0x00,0x68,0xa4,0x00,0x80,0x09,0x3c,0x00,0x80,0x0a,0x3c,
- 0xa4,0x35,0x29,0x25,0x20,0x44,0x4a,0x25,0x04,0x00,0x69,0xac,
- 0x74,0x00,0x60,0xac,0x34,0x00,0x6a,0xac,0x60,0x11,0x00,0x0c,
- 0x2a,0x00,0x65,0xa4,0x14,0x00,0xbf,0x8f,0x18,0x00,0xbd,0x27,
- 0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0xe8,0xff,0xbd,0x27,
- 0x18,0x00,0xa4,0xaf,0x14,0x00,0xbf,0xaf,0x80,0x92,0x84,0x8f,
- 0x58,0x11,0x00,0x0c,0x00,0x00,0x00,0x00,0x60,0x11,0x00,0x0c,
- 0x21,0x20,0x40,0x00,0x14,0x00,0xbf,0x8f,0x18,0x00,0xbd,0x27,
- 0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0xe0,0xff,0xbd,0x27,
- 0x20,0x00,0xa4,0xaf,0x1c,0x00,0xbf,0xaf,0x80,0x92,0x84,0x8f,
- 0x58,0x11,0x00,0x0c,0x24,0x00,0xa5,0xaf,0x24,0x00,0xae,0x8f,
- 0x20,0x00,0xaf,0x8f,0x21,0x20,0x40,0x00,0x60,0x11,0x00,0x0c,
- 0x68,0x00,0xee,0xa1,0x1c,0x00,0xbf,0x8f,0x20,0x00,0xbd,0x27,
- 0x08,0x00,0xe0,0x03,0x00,0x00,0x00,0x00,0xd0,0xff,0xbd,0x27,
- 0x14,0x00,0xbf,0xaf,0x21,0x30,0x80,0x00,0x48,0x00,0xc2,0x90,
- 0x00,0x00,0x00,0x00,0x08,0x00,0x41,0x2c,0x06,0x00,0x20,0x10,
- 0x08,0x00,0x01,0x24,0x01,0x1c,0x00,0x0c,0x21,0x20,0xc0,0x00,
- 0x8d,0x00,0x00,0x10,0x14,0x00,0xbf,0x8f,0x08,0x00,0x01,0x24,
- 0x8a,0x00,0x41,0x14,0x14,0x00,0xbf,0x8f,0x65,0x00,0xce,0x90,
- 0x00,0x00,0x00,0x00,0x80,0x78,0x0e,0x00,0x23,0x78,0xee,0x01,
- 0x80,0x78,0x0f,0x00,0x23,0x78,0xee,0x01,0x80,0x78,0x0f,0x00,
- 0x21,0x08,0xfc,0x01,0x38,0x94,0x38,0x8c,0x06,0x00,0x01,0x24,
- 0x7e,0x00,0x01,0x13,0x14,0x00,0xbf,0x8f,0x24,0x00,0xc5,0x8c,
- 0x80,0x92,0x84,0x8f,0x30,0x00,0xa6,0xaf,0x58,0x11,0x00,0x0c,
- 0x28,0x00,0xa5,0xaf,0x30,0x00,0xa6,0x8f,0x28,0x00,0xa5,0x8f,
- 0x00,0x20,0x01,0x3c,0x25,0x18,0xc1,0x00,0x0a,0x00,0x60,0xa4,
- 0x0c,0x00,0x60,0xa4,0x12,0x00,0x60,0xa4,0x14,0x00,0x60,0xa4,
- 0xff,0xff,0x19,0x34,0x01,0x00,0x04,0x24,0x18,0x00,0xc0,0xa4,
- 0x1a,0x00,0xc0,0xa4,0x1c,0x00,0xd9,0xa4,0x28,0x00,0xc0,0xa4,
- 0x2a,0x00,0xc0,0xa4,0x2c,0x00,0xc0,0xa4,0x40,0x00,0xc0,0xac,
- 0x44,0x00,0xc0,0xac,0x4b,0x00,0xc0,0xa0,0x4c,0x00,0x64,0xa0,
- 0x4d,0x00,0x64,0xa0,0x4e,0x00,0x64,0xa0,0x4f,0x00,0x60,0xa0,
- 0x56,0x00,0x60,0xa0,0x20,0x00,0x08,0x24,0x50,0x00,0xc8,0xa4,
- 0x49,0x00,0xc0,0xa0,0x4a,0x00,0xc0,0xa0,0x54,0x00,0x60,0xa0,
- 0x57,0x00,0x60,0xa0,0x58,0x00,0x60,0xa0,0x59,0x00,0x60,0xa0,
- 0x5a,0x00,0x60,0xa0,0x5b,0x00,0x60,0xa0,0x00,0x80,0x09,0x3c,
- 0x00,0x80,0x0a,0x3c,0xa4,0x35,0x29,0x25,0x20,0x44,0x4a,0x25,
- 0x5c,0x00,0xc0,0xa0,0x5d,0x00,0xc0,0xa0,0x5e,0x00,0xc0,0xa0,
- 0x5f,0x00,0xc0,0xa0,0x60,0x00,0xc0,0xa0,0x61,0x00,0xc0,0xa0,
- 0x62,0x00,0xc0,0xa0,0x63,0x00,0xc0,0xa0,0x64,0x00,0xc0,0xa0,
- 0x66,0x00,0xc0,0xa0,0x67,0x00,0xc0,0xa0,0x68,0x00,0xc0,0xa0,
- 0x69,0x00,0xc0,0xa0,0x6a,0x00,0xc0,0xa4,0x6c,0x00,0xc0,0xac,
- 0x04,0x00,0xc9,0xac,0x74,0x00,0xc0,0xac,0x34,0x00,0xca,0xac,
- 0x10,0x27,0x0b,0x24,0x28,0x00,0xa0,0xa0,0x21,0x38,0x40,0x00,
- 0x20,0x00,0xab,0xaf,0x20,0x00,0xa2,0x8f,0x20,0x00,0xac,0x8f,
- 0x00,0x00,0x00,0x00,0xff,0xff,0x8d,0x25,0x0f,0x00,0x40,0x10,
- 0x20,0x00,0xad,0xaf,0x2c,0x00,0xae,0x90,0x00,0x00,0x00,0x00,
- 0x0c,0x00,0xc0,0x11,0x80,0x00,0x08,0x24,0x20,0x00,0xa2,0x8f,
- 0x20,0x00,0xaf,0x8f,0x00,0x00,0x00,0x00,0xff,0xff,0xf8,0x25,
- 0x05,0x00,0x40,0x10,0x20,0x00,0xb8,0xaf,0x2c,0x00,0xb9,0x90,
- 0x00,0x00,0x00,0x00,0xf8,0xff,0x20,0x17,0x20,0x00,0xa2,0x8f,
- 0x80,0x00,0x08,0x24,0x2c,0x00,0xa8,0xa0,0x10,0x27,0x09,0x24,
- 0x18,0x00,0xa9,0xaf,0x18,0x00,0xa2,0x8f,0x18,0x00,0xaa,0x8f,
- 0x00,0x00,0x00,0x00,0xff,0xff,0x4b,0x25,0x0f,0x00,0x40,0x10,
- 0x18,0x00,0xab,0xaf,0x2c,0x00,0xac,0x90,0x00,0x00,0x00,0x00,
- 0x0c,0x00,0x80,0x11,0x41,0x00,0x18,0x24,0x18,0x00,0xa2,0x8f,
- 0x18,0x00,0xad,0x8f,0x00,0x00,0x00,0x00,0xff,0xff,0xae,0x25,
- 0x05,0x00,0x40,0x10,0x18,0x00,0xae,0xaf,0x2c,0x00,0xaf,0x90,
- 0x00,0x00,0x00,0x00,0xf8,0xff,0xe0,0x15,0x18,0x00,0xa2,0x8f,
- 0x41,0x00,0x18,0x24,0x2c,0x00,0xb8,0xa0,0x09,0x00,0x19,0x24,
- 0x78,0x00,0xb9,0xa0,0x90,0x8a,0x88,0x93,0x21,0x20,0xe0,0x00,
- 0x21,0x10,0x00,0x01,0x08,0x00,0xa8,0xa0,0x0c,0x00,0xa2,0xa0,
- 0x60,0x11,0x00,0x0c,0x30,0x00,0xa6,0xaf,0x30,0x00,0xa6,0x8f,
- 0x21,0x28,0x00,0x00,0x16,0x17,0x00,0x0c,0x21,0x20,0xc0,0x00,
- 0x14,0x00,0xbf,0x8f,0x30,0x00,0xbd,0x27,0x08,0x00,0xe0,0x03,
- 0x00,0x00,0x00,0x00,0x10,0x94,0x8e,0x27,0x23,0x78,0xae,0x00,
- 0x2c,0x00,0x01,0x24,0x1a,0x00,0xe1,0x01,0xe8,0xff,0xbd,0x27,
- 0x14,0x00,0xbf,0xaf,0x08,0x00,0xc1,0x28,0x48,0x00,0x86,0xa0,
- 0x12,0xc0,0x00,0x00,0x65,0x00,0x98,0xa0,0x08,0x00,0x20,0x10,
- 0x08,0x00,0x01,0x24,0x04,0x00,0xb9,0x8c,0x40,0x41,0x06,0x00,
- 0x21,0x48,0x28,0x03,0x00,0x01,0x2a,0x25,0x0c,0x00,0x00,0x10,
- 0x24,0x00,0x8a,0xac,0x08,0x00,0x01,0x24,0x25,0x00,0xc1,0x14,
- 0x14,0x00,0xbf,0x8f,0x28,0x00,0xab,0x8c,0x06,0x00,0x01,0x24,
- 0x21,0x00,0x61,0x11,0x14,0x00,0xbf,0x8f,0x04,0x00,0xac,0x8c,
- 0x00,0x00,0x00,0x00,0x00,0x08,0x8d,0x25,0x24,0x00,0x8d,0xac,
- 0x08,0x00,0xc1,0x28,0x06,0x00,0x20,0x10,0x00,0x00,0x00,0x00,
- 0x01,0x1c,0x00,0x0c,0x18,0x00,0xa4,0xaf,0x18,0x00,0xa4,0x8f,
- 0x05,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0xdb,0x1d,0x00,0x0c,
- 0x18,0x00,0xa4,0xaf,0x18,0x00,0xa4,0x8f,0x00,0x00,0x00,0x00,
- 0xbc,0x92,0x8e,0x8f,0x00,0x00,0x00,0x00,0x03,0x00,0xc0,0x15,
- 0x00,0x00,0x00,0x00,0x09,0x00,0x00,0x10,0x30,0x00,0x84,0xac,
- 0xbc,0x92,0x8f,0x8f,0x00,0x00,0x00,0x00,0x30,0x00,0xf8,0x8d,
- 0x00,0x00,0x00,0x00,0x30,0x00,0x98,0xac,0xbc,0x92,0x99,0x8f,
- 0x00,0x00,0x00,0x00,0x30,0x00,0x24,0xaf,0xbc,0x92,0x84,0xaf,
- 0x14,0x00,0xbf,0x8f,0x18,0x00,0xbd,0x27,0x08,0x00,0xe0,0x03,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x2e,0x2e,0x2f,0x65,0x78,0x63,0x65,0x70,0x74,0x69,0x6f,0x6e,
- 0x2e,0x73,0x00,0x00,0x84,0x46,0x00,0x80,0xc0,0x46,0x00,0x80,
- 0xfc,0x46,0x00,0x80,0x2c,0x47,0x00,0x80,0x5c,0x47,0x00,0x80,
- 0x28,0x49,0x00,0x80,0x8c,0x47,0x00,0x80,0x28,0x49,0x00,0x80,
- 0xa4,0x47,0x00,0x80,0xcc,0x47,0x00,0x80,0xf8,0x47,0x00,0x80,
- 0x0c,0x48,0x00,0x80,0x1c,0x48,0x00,0x80,0x28,0x49,0x00,0x80,
- 0x24,0x48,0x00,0x80,0x34,0x48,0x00,0x80,0x44,0x48,0x00,0x80,
- 0x28,0x49,0x00,0x80,0x28,0x49,0x00,0x80,0x78,0x48,0x00,0x80,
- 0x8c,0x48,0x00,0x80,0xb8,0x48,0x00,0x80,0xcc,0x48,0x00,0x80,
- 0xe8,0x49,0x00,0x80,0x24,0x4a,0x00,0x80,0x60,0x4a,0x00,0x80,
- 0x90,0x4a,0x00,0x80,0xc0,0x4a,0x00,0x80,0x88,0x4c,0x00,0x80,
- 0xf0,0x4a,0x00,0x80,0x88,0x4c,0x00,0x80,0x08,0x4b,0x00,0x80,
- 0x2c,0x4b,0x00,0x80,0x58,0x4b,0x00,0x80,0x6c,0x4b,0x00,0x80,
- 0x7c,0x4b,0x00,0x80,0x88,0x4c,0x00,0x80,0x84,0x4b,0x00,0x80,
- 0x94,0x4b,0x00,0x80,0xa4,0x4b,0x00,0x80,0x88,0x4c,0x00,0x80,
- 0x88,0x4c,0x00,0x80,0xd8,0x4b,0x00,0x80,0xec,0x4b,0x00,0x80,
- 0x18,0x4c,0x00,0x80,0x2c,0x4c,0x00,0x80,0x54,0x53,0x00,0x80,
- 0xe4,0x54,0x00,0x80,0x54,0x53,0x00,0x80,0xb0,0x53,0x00,0x80,
- 0xe4,0x54,0x00,0x80,0xd8,0x53,0x00,0x80,0xd8,0x53,0x00,0x80,
- 0xd8,0x53,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x34,0x36,0x00,0x80,0xc8,0x35,0x00,0x80,0x04,0x36,0x00,0x80,
- 0x34,0x36,0x00,0x80,0xcc,0x3c,0x00,0x80,0xd8,0x3a,0x00,0x80,
- 0xcc,0x3c,0x00,0x80,0x5c,0x3b,0x00,0x80,0x28,0x38,0x00,0x80,
- 0x70,0x37,0x00,0x80,0x28,0x38,0x00,0x80,0x08,0x3d,0x00,0x80,
- 0xd0,0x36,0x00,0x80,0xd0,0x36,0x00,0x80,0xd0,0x36,0x00,0x80,
- 0xd0,0x36,0x00,0x80,0x68,0x36,0x00,0x80,0x68,0x36,0x00,0x80,
- 0x68,0x36,0x00,0x80,0x68,0x36,0x00,0x80,0x68,0x36,0x00,0x80,
- 0x68,0x36,0x00,0x80,0x68,0x36,0x00,0x80,0x68,0x36,0x00,0x80,
- 0xf8,0x36,0x00,0x80,0xf8,0x36,0x00,0x80,0xf8,0x36,0x00,0x80,
- 0xf8,0x36,0x00,0x80,0xf8,0x36,0x00,0x80,0xf8,0x36,0x00,0x80,
- 0xf8,0x36,0x00,0x80,0xf8,0x36,0x00,0x80,0xf8,0x36,0x00,0x80,
- 0xf8,0x36,0x00,0x80,0xf8,0x36,0x00,0x80,0xf8,0x36,0x00,0x80,
- 0xf8,0x36,0x00,0x80,0xf8,0x36,0x00,0x80,0xf8,0x36,0x00,0x80,
- 0xf8,0x36,0x00,0x80,0xc0,0x3d,0x00,0x80,0xc0,0x3d,0x00,0x80,
- 0xc0,0x3d,0x00,0x80,0xc0,0x3d,0x00,0x80,0xc0,0x3d,0x00,0x80,
- 0xc0,0x3d,0x00,0x80,0xc0,0x3d,0x00,0x80,0xc0,0x3d,0x00,0x80,
- 0xa4,0x3e,0x00,0x80,0xc0,0x3e,0x00,0x80,0x58,0x3f,0x00,0x80,
- 0x30,0x3f,0x00,0x80,0x44,0x3f,0x00,0x80,0xa0,0x3f,0x00,0x80,
- 0xc0,0x3d,0x00,0x80,0xc0,0x3d,0x00,0x80,0xc0,0x3d,0x00,0x80,
- 0xc0,0x3d,0x00,0x80,0xc0,0x3d,0x00,0x80,0xc0,0x3d,0x00,0x80,
- 0xc0,0x3d,0x00,0x80,0xc0,0x3d,0x00,0x80,0xc0,0x3d,0x00,0x80,
- 0xc0,0x3d,0x00,0x80,0xc0,0x3d,0x00,0x80,0xc0,0x3d,0x00,0x80,
- 0xc0,0x3d,0x00,0x80,0xc0,0x3d,0x00,0x80,0xc0,0x3d,0x00,0x80,
- 0xc0,0x3d,0x00,0x80,0xc0,0x3d,0x00,0x80,0xc0,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0x5c,0x3e,0x00,0x80,0x5c,0x3e,0x00,0x80,0x5c,0x3e,0x00,0x80,
- 0x5c,0x3e,0x00,0x80,0x5c,0x3e,0x00,0x80,0x5c,0x3e,0x00,0x80,
- 0x5c,0x3e,0x00,0x80,0x5c,0x3e,0x00,0x80,0x5c,0x3e,0x00,0x80,
- 0x5c,0x3e,0x00,0x80,0x5c,0x3e,0x00,0x80,0x5c,0x3e,0x00,0x80,
- 0x5c,0x3e,0x00,0x80,0x5c,0x3e,0x00,0x80,0x5c,0x3e,0x00,0x80,
- 0x5c,0x3e,0x00,0x80,0x5c,0x3e,0x00,0x80,0x5c,0x3e,0x00,0x80,
- 0x5c,0x3e,0x00,0x80,0x5c,0x3e,0x00,0x80,0x5c,0x3e,0x00,0x80,
- 0x5c,0x3e,0x00,0x80,0x5c,0x3e,0x00,0x80,0x5c,0x3e,0x00,0x80,
- 0x5c,0x3e,0x00,0x80,0x5c,0x3e,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xf8,0x3d,0x00,0x80,0x90,0x3e,0x00,0x80,
- 0x90,0x3e,0x00,0x80,0x90,0x3e,0x00,0x80,0x90,0x3e,0x00,0x80,
- 0x90,0x3e,0x00,0x80,0x90,0x3e,0x00,0x80,0x90,0x3e,0x00,0x80,
- 0x90,0x3e,0x00,0x80,0x90,0x3e,0x00,0x80,0x90,0x3e,0x00,0x80,
- 0x90,0x3e,0x00,0x80,0x90,0x3e,0x00,0x80,0x90,0x3e,0x00,0x80,
- 0x90,0x3e,0x00,0x80,0x90,0x3e,0x00,0x80,0x90,0x3e,0x00,0x80,
- 0x90,0x3e,0x00,0x80,0x90,0x3e,0x00,0x80,0x90,0x3e,0x00,0x80,
- 0x90,0x3e,0x00,0x80,0x90,0x3e,0x00,0x80,0x90,0x3e,0x00,0x80,
- 0x90,0x3e,0x00,0x80,0x90,0x3e,0x00,0x80,0x90,0x3e,0x00,0x80,
- 0x90,0x3e,0x00,0x80,0x0c,0x3e,0x00,0x80,0x20,0x3e,0x00,0x80,
- 0x34,0x3e,0x00,0x80,0x48,0x3e,0x00,0x80,0xc0,0x3d,0x00,0x80,
- 0xc0,0x3d,0x00,0x80,0xc0,0x3d,0x00,0x80,0xc0,0x3d,0x00,0x80,
- 0xc0,0x3d,0x00,0x80,0xc0,0x3d,0x00,0x80,0xc0,0x3d,0x00,0x80,
- 0xc0,0x3d,0x00,0x80,0xc0,0x3d,0x00,0x80,0xc0,0x3d,0x00,0x80,
- 0xc0,0x3d,0x00,0x80,0xc0,0x3d,0x00,0x80,0xc0,0x3d,0x00,0x80,
- 0xc0,0x3d,0x00,0x80,0xc0,0x3d,0x00,0x80,0xc0,0x3d,0x00,0x80,
- 0xc0,0x3d,0x00,0x80,0xc0,0x3d,0x00,0x80,0xc0,0x3d,0x00,0x80,
- 0xc0,0x3d,0x00,0x80,0xc0,0x3d,0x00,0x80,0xc0,0x3d,0x00,0x80,
- 0xc0,0x3d,0x00,0x80,0xc0,0x3d,0x00,0x80,0xc0,0x3d,0x00,0x80,
- 0xc0,0x3d,0x00,0x80,0xc0,0x3d,0x00,0x80,0xc0,0x3d,0x00,0x80,
- 0xc0,0x3d,0x00,0x80,0xc0,0x3d,0x00,0x80,0xc0,0x3d,0x00,0x80,
- 0xc0,0x3d,0x00,0x80,0xc0,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,
- 0xbc,0x3d,0x00,0x80,0xbc,0x3d,0x00,0x80,0xe8,0x3b,0x00,0x80,
- 0xe8,0x3b,0x00,0x80,0xe8,0x3b,0x00,0x80,0xe8,0x3b,0x00,0x80,
- 0xe8,0x3b,0x00,0x80,0xe8,0x3b,0x00,0x80,0xe8,0x3b,0x00,0x80,
- 0xe8,0x3b,0x00,0x80,0x18,0x3c,0x00,0x80,0x90,0x3c,0x00,0x80,
- 0x28,0x3c,0x00,0x80,0xe8,0x3b,0x00,0x80,0xe8,0x3b,0x00,0x80,
- 0x5c,0x3c,0x00,0x80,0xe8,0x3b,0x00,0x80,0xe8,0x3b,0x00,0x80,
- 0xe8,0x3b,0x00,0x80,0xe8,0x3b,0x00,0x80,0xe8,0x3b,0x00,0x80,
- 0xe8,0x3b,0x00,0x80,0xe8,0x3b,0x00,0x80,0xe8,0x3b,0x00,0x80,
- 0xe8,0x3b,0x00,0x80,0xe8,0x3b,0x00,0x80,0xe8,0x3b,0x00,0x80,
- 0xe8,0x3b,0x00,0x80,0xe8,0x3b,0x00,0x80,0xe8,0x3b,0x00,0x80,
- 0xe8,0x3b,0x00,0x80,0xe8,0x3b,0x00,0x80,0xe8,0x3b,0x00,0x80,
- 0xe8,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xd4,0x3b,0x00,0x80,0xd4,0x3b,0x00,0x80,0xd4,0x3b,0x00,0x80,
- 0xd4,0x3b,0x00,0x80,0xd4,0x3b,0x00,0x80,0xd4,0x3b,0x00,0x80,
- 0xd4,0x3b,0x00,0x80,0xd4,0x3b,0x00,0x80,0xd4,0x3b,0x00,0x80,
- 0xd4,0x3b,0x00,0x80,0xd4,0x3b,0x00,0x80,0xd4,0x3b,0x00,0x80,
- 0xd4,0x3b,0x00,0x80,0xd4,0x3b,0x00,0x80,0xd4,0x3b,0x00,0x80,
- 0xd4,0x3b,0x00,0x80,0xd4,0x3b,0x00,0x80,0xd4,0x3b,0x00,0x80,
- 0xd4,0x3b,0x00,0x80,0xd4,0x3b,0x00,0x80,0xd4,0x3b,0x00,0x80,
- 0xd4,0x3b,0x00,0x80,0xd4,0x3b,0x00,0x80,0xd4,0x3b,0x00,0x80,
- 0xd4,0x3b,0x00,0x80,0xd4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe8,0x3b,0x00,0x80,0xe8,0x3b,0x00,0x80,0xe8,0x3b,0x00,0x80,
- 0xe8,0x3b,0x00,0x80,0xe8,0x3b,0x00,0x80,0xe8,0x3b,0x00,0x80,
- 0xe8,0x3b,0x00,0x80,0xe8,0x3b,0x00,0x80,0xe8,0x3b,0x00,0x80,
- 0xe8,0x3b,0x00,0x80,0xe8,0x3b,0x00,0x80,0xe8,0x3b,0x00,0x80,
- 0xe8,0x3b,0x00,0x80,0xe8,0x3b,0x00,0x80,0xe8,0x3b,0x00,0x80,
- 0xe8,0x3b,0x00,0x80,0xe8,0x3b,0x00,0x80,0xe8,0x3b,0x00,0x80,
- 0xe8,0x3b,0x00,0x80,0xe8,0x3b,0x00,0x80,0xe8,0x3b,0x00,0x80,
- 0xe8,0x3b,0x00,0x80,0xe8,0x3b,0x00,0x80,0xe8,0x3b,0x00,0x80,
- 0xe8,0x3b,0x00,0x80,0xe8,0x3b,0x00,0x80,0xe8,0x3b,0x00,0x80,
- 0xe8,0x3b,0x00,0x80,0xe8,0x3b,0x00,0x80,0xe8,0x3b,0x00,0x80,
- 0xe8,0x3b,0x00,0x80,0xe8,0x3b,0x00,0x80,0xe8,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,0xe4,0x3b,0x00,0x80,
- 0x04,0x39,0x00,0x80,0x30,0x42,0x00,0x80,0x84,0x41,0x00,0x80,
- 0x84,0x41,0x00,0x80,0x04,0x39,0x00,0x80,0x30,0x42,0x00,0x80,
- 0x84,0x41,0x00,0x80,0x84,0x41,0x00,0x80,0x04,0x39,0x00,0x80,
- 0x30,0x42,0x00,0x80,0x84,0x41,0x00,0x80,0x84,0x41,0x00,0x80,
- 0x04,0x39,0x00,0x80,0x30,0x42,0x00,0x80,0x84,0x41,0x00,0x80,
- 0x84,0x41,0x00,0x80,0xd0,0x38,0x00,0x80,0x30,0x42,0x00,0x80,
- 0x84,0x41,0x00,0x80,0x84,0x41,0x00,0x80,0x4c,0x42,0x00,0x80,
- 0x30,0x42,0x00,0x80,0x84,0x41,0x00,0x80,0x84,0x41,0x00,0x80,
- 0xd0,0x40,0x00,0x80,0x30,0x42,0x00,0x80,0x84,0x41,0x00,0x80,
- 0x84,0x41,0x00,0x80,0xa0,0x40,0x00,0x80,0x30,0x42,0x00,0x80,
- 0x84,0x41,0x00,0x80,0x84,0x41,0x00,0x80,0xc0,0x3d,0x00,0x80,
- 0xe0,0x3e,0x00,0x80,0xf8,0x3e,0x00,0x80,0x00,0x3f,0x00,0x80,
- 0xc0,0x3d,0x00,0x80,0xe8,0x3f,0x00,0x80,0xf4,0x3f,0x00,0x80,
- 0xfc,0x3f,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x2e,0x2e,0x2f,0x73,0x6d,0x61,0x72,0x74,0x66,0x65,0x70,0x2e,
- 0x63,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x2e,0x2e,0x2f,0x73,0x6d,0x61,0x72,0x74,0x6d,0x61,0x69,0x6e,
- 0x2e,0x63,0x00,0x00,0x2e,0x2e,0x2f,0x73,0x6d,0x61,0x72,0x74,
- 0x6d,0x61,0x69,0x6e,0x2e,0x63,0x00,0x00,0x2e,0x2e,0x2f,0x63,
- 0x6f,0x6d,0x6d,0x6f,0x6e,0x2e,0x63,0x00,0x2e,0x2e,0x2f,0x63,
- 0x6f,0x6d,0x6d,0x6f,0x6e,0x2e,0x63,0x00,0x2e,0x2e,0x2f,0x63,
- 0x6f,0x6d,0x6d,0x6f,0x6e,0x2e,0x63,0x00,0x2e,0x2e,0x2f,0x63,
- 0x6f,0x6d,0x6d,0x6f,0x6e,0x2e,0x63,0x00,0x0c,0x00,0x34,0x00,
- 0x00,0x00,0x41,0x0b,0x00,0x00,0x0b,0x00,0x0c,0x00,0xe2,0x00,
- 0x00,0x00,0x40,0x00,0x0c,0x00,0x74,0x00,0x04,0x00,0x6e,0x00,
- 0x04,0x00,0x00,0x00,0x0c,0x00,0xe4,0x00,0x04,0x00,0x40,0x00,
- 0x0c,0x00,0xb4,0x00,0x08,0x00,0x00,0x00,0x08,0x00,0x00,0x00,
- 0x0c,0x00,0xe8,0x00,0x08,0x00,0x40,0x00,0x2e,0x2e,0x2f,0x74,
- 0x69,0x6d,0x65,0x72,0x2e,0x63,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x12,0x00,0x00,0x00,
- 0x93,0x00,0x00,0x00,0xb4,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x01,0x00,0x2e,0x2e,0x2f,0x74,0x69,0x6d,0x65,0x72,
- 0x69,0x6e,0x74,0x2e,0x63,0x00,0x00,0x00,0x2e,0x2e,0x2f,0x74,
- 0x69,0x6d,0x65,0x72,0x69,0x6e,0x74,0x2e,0x63,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x24,
- 0x00,0x18,0x5d,0x10,0x6f,0x0d,0x00,0x0c,0x00,0x09,0x00,0x06,
- 0x00,0x03,0x80,0x01,0x00,0x01,0xc0,0x00,0x60,0x00,0x30,0x00,
- 0x18,0x00,0x0c,0x00,0x30,0x00,0x08,0x00,0x06,0x00,0x04,0x00,
- 0x20,0x00,0x08,0x00,0x02,0x00,0x06,0x00,0x04,0x00,0x02,0x00,
- 0x10,0x00,0xc0,0x00,0x60,0x00,0x30,0x00,0x18,0x00,0x0c,0x00,
- 0x04,0xfa,0xc8,0x96,0x64,0x32,0x19,0x14,0x0f,0x0a,0x08,0x06,
- 0x05,0x04,0x04,0x04,0x40,0x28,0x23,0x29,0x63,0x68,0x61,0x6e,
- 0x6e,0x65,0x6c,0x2e,0x68,0x20,0x20,0x20,0x20,0x20,0x33,0x2e,
- 0x37,0x20,0x20,0x39,0x2f,0x32,0x30,0x2f,0x39,0x33,0x00,0x40,
- 0x28,0x23,0x29,0x63,0x6f,0x6d,0x6d,0x6f,0x6e,0x2e,0x63,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x33,0x2e,0x38,0x20,0x20,0x34,0x2f,
- 0x31,0x38,0x2f,0x39,0x34,0x00,0x40,0x28,0x23,0x29,0x63,0x6f,
- 0x6d,0x6d,0x6f,0x6e,0x2e,0x6d,0x6b,0x20,0x20,0x20,0x20,0x20,
- 0x33,0x2e,0x31,0x30,0x20,0x20,0x31,0x2f,0x36,0x2f,0x39,0x34,
- 0x00,0x40,0x28,0x23,0x29,0x63,0x6f,0x6e,0x63,0x62,0x69,0x6f,
- 0x73,0x2e,0x68,0x20,0x20,0x20,0x20,0x32,0x2e,0x38,0x20,0x20,
- 0x36,0x2f,0x33,0x30,0x2f,0x39,0x32,0x00,0x40,0x28,0x23,0x29,
- 0x64,0x65,0x66,0x73,0x2e,0x68,0x20,0x20,0x20,0x20,0x20,0x20,
- 0x20,0x20,0x33,0x2e,0x32,0x20,0x20,0x34,0x2f,0x36,0x2f,0x39,
- 0x34,0x00,0x40,0x28,0x23,0x29,0x64,0x65,0x76,0x69,0x63,0x65,
- 0x2e,0x68,0x20,0x20,0x20,0x20,0x20,0x20,0x33,0x2e,0x38,0x20,
- 0x20,0x34,0x2f,0x31,0x34,0x2f,0x39,0x34,0x00,0x40,0x28,0x23,
- 0x29,0x65,0x78,0x63,0x65,0x70,0x74,0x69,0x6f,0x6e,0x2e,0x73,
- 0x20,0x20,0x20,0x33,0x2e,0x32,0x20,0x20,0x38,0x2f,0x32,0x30,
- 0x2f,0x39,0x33,0x00,0x40,0x28,0x23,0x29,0x68,0x6f,0x73,0x74,
- 0x63,0x6f,0x6d,0x6d,0x2e,0x68,0x20,0x20,0x20,0x20,0x33,0x2e,
- 0x33,0x20,0x20,0x33,0x2f,0x32,0x32,0x2f,0x39,0x33,0x00,0x40,
- 0x28,0x23,0x29,0x68,0x6f,0x73,0x74,0x69,0x6e,0x69,0x74,0x2e,
- 0x73,0x20,0x20,0x20,0x20,0x33,0x2e,0x33,0x20,0x20,0x38,0x2f,
- 0x32,0x30,0x2f,0x39,0x33,0x00,0x40,0x28,0x23,0x29,0x6d,0x69,
- 0x64,0x2e,0x68,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
- 0x33,0x2e,0x33,0x20,0x20,0x34,0x2f,0x36,0x2f,0x39,0x34,0x00,
- 0x40,0x28,0x23,0x29,0x6d,0x6f,0x64,0x75,0x6c,0x65,0x2e,0x63,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x32,0x2e,0x31,0x20,0x20,0x33,
- 0x2f,0x31,0x2f,0x39,0x32,0x00,0x40,0x28,0x23,0x29,0x6d,0x6f,
- 0x64,0x75,0x6c,0x65,0x2e,0x68,0x20,0x20,0x20,0x20,0x20,0x20,
- 0x33,0x2e,0x31,0x20,0x20,0x38,0x2f,0x32,0x30,0x2f,0x39,0x33,
- 0x00,0x40,0x28,0x23,0x29,0x70,0x61,0x72,0x61,0x6c,0x6c,0x65,
- 0x6c,0x2e,0x63,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
- 0x31,0x2e,0x38,0x20,0x20,0x34,0x2f,0x31,0x38,0x2f,0x39,0x34,
- 0x00,0x40,0x28,0x23,0x29,0x70,0x61,0x72,0x61,0x2e,0x68,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x31,0x2e,0x31,0x20,0x20,
- 0x37,0x2f,0x37,0x2f,0x39,0x33,0x00,0x40,0x28,0x23,0x29,0x70,
- 0x62,0x75,0x73,0x2e,0x68,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
- 0x20,0x33,0x2e,0x32,0x20,0x20,0x34,0x2f,0x36,0x2f,0x39,0x34,
- 0x00,0x40,0x28,0x23,0x29,0x70,0x6f,0x6c,0x6c,0x2e,0x73,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x33,0x2e,0x31,0x33,0x20,
- 0x20,0x35,0x2f,0x32,0x34,0x2f,0x39,0x34,0x00,0x40,0x28,0x23,
- 0x29,0x70,0x72,0x6f,0x74,0x6f,0x63,0x6f,0x6c,0x2e,0x68,0x20,
- 0x20,0x20,0x20,0x33,0x2e,0x31,0x20,0x20,0x34,0x2f,0x31,0x39,
- 0x2f,0x39,0x33,0x00,0x40,0x28,0x23,0x29,0x72,0x65,0x67,0x2e,
- 0x68,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x33,0x2e,
- 0x32,0x20,0x20,0x38,0x2f,0x32,0x35,0x2f,0x39,0x33,0x00,0x40,
- 0x28,0x23,0x29,0x72,0x65,0x6c,0x65,0x61,0x73,0x65,0x2e,0x68,
- 0x20,0x20,0x20,0x20,0x20,0x33,0x2e,0x39,0x20,0x20,0x38,0x2f,
- 0x31,0x37,0x2f,0x39,0x34,0x00,0x40,0x28,0x23,0x29,0x72,0x77,
- 0x2e,0x63,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
- 0x33,0x2e,0x31,0x20,0x20,0x31,0x31,0x2f,0x35,0x2f,0x39,0x32,
- 0x00,0x40,0x28,0x23,0x29,0x72,0x77,0x2e,0x68,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x32,0x2e,0x31,0x20,0x20,
- 0x33,0x2f,0x31,0x2f,0x39,0x32,0x00,0x40,0x28,0x23,0x29,0x73,
- 0x63,0x68,0x65,0x64,0x2e,0x63,0x20,0x20,0x20,0x20,0x20,0x20,
- 0x20,0x33,0x2e,0x32,0x20,0x20,0x38,0x2f,0x32,0x30,0x2f,0x39,
- 0x33,0x00,0x40,0x28,0x23,0x29,0x73,0x63,0x68,0x65,0x64,0x2e,
- 0x68,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x33,0x2e,0x31,0x20,
- 0x20,0x38,0x2f,0x32,0x30,0x2f,0x39,0x33,0x00,0x40,0x28,0x23,
- 0x29,0x73,0x6d,0x61,0x72,0x74,0x62,0x69,0x6f,0x73,0x2e,0x68,
- 0x20,0x20,0x20,0x33,0x2e,0x31,0x20,0x20,0x38,0x2f,0x32,0x30,
- 0x2f,0x39,0x33,0x00,0x40,0x28,0x23,0x29,0x73,0x6d,0x61,0x72,
- 0x74,0x66,0x65,0x70,0x2e,0x63,0x20,0x20,0x20,0x20,0x33,0x2e,
- 0x31,0x31,0x20,0x20,0x34,0x2f,0x31,0x38,0x2f,0x39,0x34,0x00,
- 0x40,0x28,0x23,0x29,0x73,0x6d,0x61,0x72,0x74,0x6d,0x61,0x69,
- 0x6e,0x2e,0x63,0x20,0x20,0x20,0x33,0x2e,0x31,0x20,0x20,0x38,
- 0x2f,0x32,0x30,0x2f,0x39,0x33,0x00,0x40,0x28,0x23,0x29,0x73,
- 0x78,0x66,0x65,0x70,0x2e,0x6d,0x6b,0x20,0x20,0x20,0x20,0x20,
- 0x20,0x33,0x2e,0x32,0x20,0x20,0x38,0x2f,0x32,0x30,0x2f,0x39,
- 0x33,0x00,0x40,0x28,0x23,0x29,0x74,0x69,0x6d,0x65,0x72,0x2e,
- 0x63,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x33,0x2e,0x33,0x20,
- 0x20,0x37,0x2f,0x37,0x2f,0x39,0x33,0x00,0x40,0x28,0x23,0x29,
- 0x74,0x69,0x6d,0x65,0x72,0x2e,0x68,0x20,0x20,0x20,0x20,0x20,
- 0x20,0x20,0x33,0x2e,0x33,0x20,0x20,0x34,0x2f,0x36,0x2f,0x39,
- 0x34,0x00,0x40,0x28,0x23,0x29,0x74,0x69,0x6d,0x65,0x72,0x69,
- 0x6e,0x74,0x2e,0x63,0x20,0x20,0x20,0x20,0x33,0x2e,0x31,0x20,
- 0x20,0x38,0x2f,0x32,0x30,0x2f,0x39,0x33,0x00,0x40,0x28,0x23,
- 0x29,0x75,0x61,0x72,0x74,0x2e,0x63,0x20,0x20,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x33,0x2e,0x38,0x20,0x20,0x35,0x2f,0x32,0x34,
- 0x2f,0x39,0x34,0x00,0x40,0x28,0x23,0x29,0x75,0x61,0x72,0x74,
- 0x2e,0x68,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x33,0x2e,
- 0x31,0x20,0x20,0x34,0x2f,0x36,0x2f,0x39,0x34,0x00,0x40,0x28,
- 0x23,0x29,0x75,0x74,0x69,0x6c,0x2e,0x73,0x20,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x33,0x2e,0x33,0x20,0x20,0x37,0x2f,0x31,
- 0x2f,0x39,0x34,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00
-};
-
-static unsigned pcem_ncook=sizeof(pcem_cook);
diff --git a/sys/dev/dgb/dgmreg.h b/sys/dev/dgb/dgmreg.h
deleted file mode 100644
index 2f052b530c11..000000000000
--- a/sys/dev/dgb/dgmreg.h
+++ /dev/null
@@ -1,422 +0,0 @@
-/*-
- * dgmreg.h $FreeBSD$
- *
- * Digiboard driver.
- *
- * Stage 1. "Better than nothing".
- *
- * Based on sio driver by Bruce Evans and on Linux driver by Troy
- * De Jongh <troyd@digibd.com> or <troyd@skypoint.com>
- * which is under GNU General Public License version 2 so this driver
- * is forced to be under GPL 2 too.
- *
- * Written by Serge Babkin,
- * Joint Stock Commercial Bank "Chelindbank"
- * (Chelyabinsk, Russia)
- * babkin@hq.icb.chel.su
- */
-
-#define MAX_DGM_PORTS 64
-
-/* digi.h */
-/* Definitions for DigiBoard ditty(1) command. */
-
-#if !defined(TIOCMODG)
-#define TIOCMODG ('d'<<8) | 250 /* get modem ctrl state */
-#define TIOCMODS ('d'<<8) | 251 /* set modem ctrl state */
-#endif
-
-#if !defined(TIOCMSET)
-#define TIOCMSET ('d'<<8) | 252 /* set modem ctrl state */
-#define TIOCMGET ('d'<<8) | 253 /* set modem ctrl state */
-#endif
-
-#if !defined(TIOCMBIC)
-#define TIOCMBIC ('d'<<8) | 254 /* set modem ctrl state */
-#define TIOCMBIS ('d'<<8) | 255 /* set modem ctrl state */
-#endif
-
-#if !defined(TIOCSDTR)
-#define TIOCSDTR ('e'<<8) | 0 /* set DTR */
-#define TIOCCDTR ('e'<<8) | 1 /* clear DTR */
-#endif
-
-/************************************************************************
- * Ioctl command arguments for DIGI parameters.
- ************************************************************************/
-#define DIGI_GETA ('e'<<8) | 94 /* Read params */
-
-#define DIGI_SETA ('e'<<8) | 95 /* Set params */
-#define DIGI_SETAW ('e'<<8) | 96 /* Drain & set params */
-#define DIGI_SETAF ('e'<<8) | 97 /* Drain, flush & set params */
-
-#define DIGI_GETFLOW ('e'<<8) | 99 /* Get startc/stopc flow */
- /* control characters */
-#define DIGI_SETFLOW ('e'<<8) | 100 /* Set startc/stopc flow */
- /* control characters */
-#define DIGI_GETAFLOW ('e'<<8) | 101 /* Get Aux. startc/stopc */
- /* flow control chars */
-#define DIGI_SETAFLOW ('e'<<8) | 102 /* Set Aux. startc/stopc */
- /* flow control chars */
-
-struct digiflow_struct {
- unsigned char startc; /* flow cntl start char */
- unsigned char stopc; /* flow cntl stop char */
-};
-
-typedef struct digiflow_struct digiflow_t;
-
-
-/************************************************************************
- * Values for digi_flags
- ************************************************************************/
-#define DIGI_IXON 0x0001 /* Handle IXON in the FEP */
-#define DIGI_FAST 0x0002 /* Fast baud rates */
-#define RTSPACE 0x0004 /* RTS input flow control */
-#define CTSPACE 0x0008 /* CTS output flow control */
-#define DSRPACE 0x0010 /* DSR output flow control */
-#define DCDPACE 0x0020 /* DCD output flow control */
-#define DTRPACE 0x0040 /* DTR input flow control */
-#define DIGI_FORCEDCD 0x0100 /* Force carrier */
-#define DIGI_ALTPIN 0x0200 /* Alternate RJ-45 pin config */
-#define DIGI_AIXON 0x0400 /* Aux flow control in fep */
-
-
-/************************************************************************
- * Structure used with ioctl commands for DIGI parameters.
- ************************************************************************/
-struct digi_struct {
- unsigned short digi_flags; /* Flags (see above) */
-};
-
-typedef struct digi_struct digi_t;
-
-/* fep.h */
-
-#define FEP_CSTART 0x400L
-#define FEP_CMAX 0x800L
-#define FEP_ISTART 0x800L
-#define FEP_IMAX 0xC00L
-#define FEP_CIN 0xD10L
-#define FEP_GLOBAL 0xD10L
-#define FEP_EIN 0xD18L
-#define FEPSTAT 0xD20L
-#define CHANSTRUCT 0x1000L
-#define RXTXBUF 0x4000L
-
-
-struct global_data {
- volatile ushort cin;
- volatile ushort cout;
- volatile ushort cstart;
- volatile ushort cmax;
- volatile ushort ein;
- volatile ushort eout;
- volatile ushort istart;
- volatile ushort imax;
-};
-
-
-struct board_chan {
- int filler1;
- int filler2;
- volatile ushort tseg;
- volatile ushort tin;
- volatile ushort tout;
- volatile ushort tmax;
-
- volatile ushort rseg;
- volatile ushort rin;
- volatile ushort rout;
- volatile ushort rmax;
-
- volatile ushort tlow;
- volatile ushort rlow;
- volatile ushort rhigh;
- volatile ushort incr;
-
- volatile ushort etime;
- volatile ushort edelay;
- volatile u_char *dev;
-
- volatile ushort iflag;
- volatile ushort oflag;
- volatile ushort cflag;
- volatile ushort gmask;
-
- volatile ushort col;
- volatile ushort delay;
- volatile ushort imask;
- volatile ushort tflush;
-
- int filler3;
- int filler4;
- int filler5;
- int filler6;
-
- volatile u_char num;
- volatile u_char ract;
- volatile u_char bstat;
- volatile u_char tbusy;
- volatile u_char iempty;
- volatile u_char ilow;
- volatile u_char idata;
- volatile u_char eflag;
-
- volatile u_char tflag;
- volatile u_char rflag;
- volatile u_char xmask;
- volatile u_char xval;
- volatile u_char mstat;
- volatile u_char mchange;
- volatile u_char mint;
- volatile u_char lstat;
-
- volatile u_char mtran;
- volatile u_char orun;
- volatile u_char startca;
- volatile u_char stopca;
- volatile u_char startc;
- volatile u_char stopc;
- volatile u_char vnext;
- volatile u_char hflow;
-
- volatile u_char fillc;
- volatile u_char ochar;
- volatile u_char omask;
-
- u_char filler7;
- u_char filler8[28];
-};
-
-
-#define SRXLWATER 0xE0
-#define SRXHWATER 0xE1
-#define STOUT 0xE2
-#define PAUSETX 0xE3
-#define RESUMETX 0xE4
-#define SAUXONOFFC 0xE6
-#define SENDBREAK 0xE8
-#define SETMODEM 0xE9
-#define SETIFLAGS 0xEA
-#define SONOFFC 0xEB
-#define STXLWATER 0xEC
-#define PAUSERX 0xEE
-#define RESUMERX 0xEF
-#define SETBUFFER 0xF2
-#define SETCOOKED 0xF3
-#define SETHFLOW 0xF4
-#define SETCTRLFLAGS 0xF5
-#define SETVNEXT 0xF6
-
-
-
-#define BREAK_IND 0x01
-#define LOWTX_IND 0x02
-#define EMPTYTX_IND 0x04
-#define DATA_IND 0x08
-#define MODEMCHG_IND 0x20
-
-#define ALL_IND (BREAK_IND|LOWTX_IND|EMPTYTX_IND|DATA_IND|MODEMCHG_IND)
-
-#define CD 0x80
-#define DSR 0x20
-#define CTS 0x10
-#define DTR 0x01
-#define RTS 0x02
-#define RI 0x40
-
-#define FEPCODESEG 0x0200L
-#define FEPCODE 0x2000L
-#define BIOSCODE 0xf800L
-#define BIOSOFFSET 0x1000L
-
-#define MISCGLOBAL 0x0C00L
-#define NPORT 0x0C02L
-#define MBOX 0x0C40L
-#define BOTWIN 0x100L
-#define TOPWIN 0xFF00L
-
-#define FEPCLR 0x00
-#define FEPMEM 0x02
-#define FEPRST 0x04
-#define FEPINT 0x08
-#define FEPMASK 0x0e
-#define FEPWIN 0x80
-
-#define PCXI 0
-#define PCXE 1
-#define PCXEVE 2
-#define PCXEM 3
-
-static char * const board_desc[] = {
- "PC/Xi (64K)",
- "PC/Xe (64K)",
- "PC/Xe (8K) ",
- "PC/Xem ",
-};
-
-#define STARTC 021
-#define STOPC 023
-#define IAIXON 0x2000
-
-
-struct board_info {
- u_char status;
- u_char type;
- u_char altpin;
- ushort numports;
- ushort port;
- u_long membase;
-};
-
-
-#define TXSTOPPED 0x1
-#define LOWWAIT 0x2
-#define EMPTYWAIT 0x4
-
-#define DISABLED 0
-#define ENABLED 1
-#define OFF 0
-#define ON 1
-
-#define FEPTIMEOUT 200000
-#define SERIAL_TYPE_NORMAL 1
-#define SERIAL_TYPE_CALLOUT 2
-#define PCXE_EVENT_HANGUP 1
-
-struct channel {
- u_char unit; /* board unit number */
- u_char omodem; /* FEP output modem status */
- u_char imodem; /* FEP input modem status */
- u_char modemfake; /* Modem values to be forced */
- u_char modem; /* Force values */
- u_char hflow;
- u_char dsr;
- u_char dcd;
- u_char stopc;
- u_char startc;
- u_char stopca;
- u_char startca;
- u_char fepstopc;
- u_char fepstartc;
- u_char fepstopca;
- u_char fepstartca;
- u_char txwin;
- u_char rxwin;
- ushort fepiflag;
- ushort fepcflag;
- ushort fepoflag;
- ushort txbufhead;
- ushort txbufsize;
- ushort rxbufhead;
- ushort rxbufsize;
- int close_delay;
- int count;
- int blocked_open;
- int event;
- int asyncflags;
- uint dev;
- long session;
- long pgrp;
- u_long statusflags;
- u_long c_iflag;
- u_long c_cflag;
- u_long c_lflag;
- u_long c_oflag;
- u_char *txptr;
- u_char *rxptr;
- struct board_info *board;
- struct board_chan *brdchan;
- struct digi_struct digiext;
- struct tty *tty;
- struct termios normal_termios;
- struct termios callout_termios;
- volatile struct global_data *mailbox;
-};
-
-/* flags for configuring */
-
-#define DGBFLAG_ALTPIN 0x0001 /* chande DCD and DCD */
-#define DGBFLAG_NOWIN 0x0002 /* use windowed PC/Xe as non-windowed */
-
-#define DB_RD 0x0001
-#define DB_WR 0x0002
-#define DB_WIN 0x0004
-#define DB_INFO 0x0008
-#define DB_EXCEPT 0x0010
-#define DB_OPEN 0x0100
-#define DB_CLOSE 0x0200
-#define DB_DATA 0x0400
-#define DB_RXDATA 0x0401
-#define DB_TXDATA 0x0402
-#define DB_EVENT 0x0800
-#define DB_MODEM 0x1000
-#define DB_BREAK 0x2000
-#define DB_PARAM 0x4000
-#define DB_FEP 0x8000
-
-/* debugging printout */
-
-#ifdef DEBUG
-#define DPRINT1(l,a1) (dgmdebug&l ? printf(a1) : 0)
-#define DPRINT2(l,a1,a2) (dgmdebug&l ? printf(a1,a2) : 0)
-#define DPRINT3(l,a1,a2,a3) (dgmdebug&l ? printf(a1,a2,a3) : 0)
-#define DPRINT4(l,a1,a2,a3,a4) (dgmdebug&l ? printf(a1,a2,a3,a4) : 0)
-#define DPRINT5(l,a1,a2,a3,a4,a5) (dgmdebug&l ? printf(a1,a2,a3,a4,a5) : 0)
-#define DPRINT6(l,a1,a2,a3,a4,a5,a6) (dgmdebug&l ? printf(a1,a2,a3,a4,a5,a6) : 0)
-#define DPRINT7(l,a1,a2,a3,a4,a5,a6,a7) (dgmdebug&l ? printf(a1,a2,a3,a4,a5,a6,a7) : 0)
-#else
-#define DPRINT1(l,a1)
-#define DPRINT2(l,a1,a2)
-#define DPRINT3(l,a1,a2,a3)
-#define DPRINT4(l,a1,a2,a3,a4)
-#define DPRINT5(l,a1,a2,a3,a4,a5)
-#define DPRINT6(l,a1,a2,a3,a4,a5,a6)
-#define DPRINT7(l,a1,a2,a3,a4,a5,a6,a7)
-#endif
-
-
- /* These are termios bits as the FEP understands them */
-
-/* c_cflag bits */
-#define FEP_CBAUD 0x00000f
-#define FEP_B0 0x000000 /* hang up */
-#define FEP_B50 0x000001
-#define FEP_B75 0x000002
-#define FEP_B110 0x000003
-#define FEP_B134 0x000004
-#define FEP_B150 0x000005
-#define FEP_B200 0x000006
-#define FEP_B300 0x000007
-#define FEP_B600 0x000008
-#define FEP_B1200 0x000009
-#define FEP_B1800 0x00000a
-#define FEP_B2400 0x00000b
-#define FEP_B4800 0x00000c
-#define FEP_B9600 0x00000d
-#define FEP_B19200 0x00000e
-#define FEP_B38400 0x00000f
-#define FEP_EXTA FEP_B19200
-#define FEP_EXTB FEP_B38400
-#define FEP_CSIZE 0x000030
-#define FEP_CS5 0x000000
-#define FEP_CS6 0x000010
-#define FEP_CS7 0x000020
-#define FEP_CS8 0x000030
-#define FEP_CSTOPB 0x000040
-#define FEP_CREAD 0x000080
-#define FEP_PARENB 0x000100
-#define FEP_PARODD 0x000200
-#define FEP_CLOCAL 0x000800
-#define FEP_FASTBAUD 0x000400
-/* c_iflag bits */
-#define FEP_IGNBRK 0000001
-#define FEP_BRKINT 0000002
-#define FEP_IGNPAR 0000004
-#define FEP_PARMRK 0000010
-#define FEP_INPCK 0000020
-#define FEP_ISTRIP 0000040
-#define FEP_IXON 0002000
-#define FEP_IXANY 0004000
-#define FEP_IXOFF 0010000
diff --git a/sys/dev/dgb/dgreg.h b/sys/dev/dgb/dgreg.h
deleted file mode 100644
index 73c29624294e..000000000000
--- a/sys/dev/dgb/dgreg.h
+++ /dev/null
@@ -1,424 +0,0 @@
-/*-
- * dgreg.h $FreeBSD$
- *
- * Digiboard driver.
- *
- * Stage 1. "Better than nothing".
- *
- * Based on sio driver by Bruce Evans and on Linux driver by Troy
- * De Jongh <troyd@digibd.com> or <troyd@skypoint.com>
- * which is under GNU General Public License version 2 so this driver
- * is forced to be under GPL 2 too.
- *
- * Written by Serge Babkin,
- * Joint Stock Commercial Bank "Chelindbank"
- * (Chelyabinsk, Russia)
- * babkin@hq.icb.chel.su
- */
-
-#define MAX_DGB_PORTS 32
-
-/* digi.h */
-/* Definitions for DigiBoard ditty(1) command. */
-
-#if !defined(TIOCMODG)
-#define TIOCMODG ('d'<<8) | 250 /* get modem ctrl state */
-#define TIOCMODS ('d'<<8) | 251 /* set modem ctrl state */
-#endif
-
-#if !defined(TIOCMSET)
-#define TIOCMSET ('d'<<8) | 252 /* set modem ctrl state */
-#define TIOCMGET ('d'<<8) | 253 /* set modem ctrl state */
-#endif
-
-#if !defined(TIOCMBIC)
-#define TIOCMBIC ('d'<<8) | 254 /* set modem ctrl state */
-#define TIOCMBIS ('d'<<8) | 255 /* set modem ctrl state */
-#endif
-
-#if !defined(TIOCSDTR)
-#define TIOCSDTR ('e'<<8) | 0 /* set DTR */
-#define TIOCCDTR ('e'<<8) | 1 /* clear DTR */
-#endif
-
-/************************************************************************
- * Ioctl command arguments for DIGI parameters.
- ************************************************************************/
-#define DIGI_GETA ('e'<<8) | 94 /* Read params */
-
-#define DIGI_SETA ('e'<<8) | 95 /* Set params */
-#define DIGI_SETAW ('e'<<8) | 96 /* Drain & set params */
-#define DIGI_SETAF ('e'<<8) | 97 /* Drain, flush & set params */
-
-#define DIGI_GETFLOW ('e'<<8) | 99 /* Get startc/stopc flow */
- /* control characters */
-#define DIGI_SETFLOW ('e'<<8) | 100 /* Set startc/stopc flow */
- /* control characters */
-#define DIGI_GETAFLOW ('e'<<8) | 101 /* Get Aux. startc/stopc */
- /* flow control chars */
-#define DIGI_SETAFLOW ('e'<<8) | 102 /* Set Aux. startc/stopc */
- /* flow control chars */
-
-struct digiflow_struct {
- unsigned char startc; /* flow cntl start char */
- unsigned char stopc; /* flow cntl stop char */
-};
-
-typedef struct digiflow_struct digiflow_t;
-
-
-/************************************************************************
- * Values for digi_flags
- ************************************************************************/
-#define DIGI_IXON 0x0001 /* Handle IXON in the FEP */
-#define DIGI_FAST 0x0002 /* Fast baud rates */
-#define RTSPACE 0x0004 /* RTS input flow control */
-#define CTSPACE 0x0008 /* CTS output flow control */
-#define DSRPACE 0x0010 /* DSR output flow control */
-#define DCDPACE 0x0020 /* DCD output flow control */
-#define DTRPACE 0x0040 /* DTR input flow control */
-#define DIGI_FORCEDCD 0x0100 /* Force carrier */
-#define DIGI_ALTPIN 0x0200 /* Alternate RJ-45 pin config */
-#define DIGI_AIXON 0x0400 /* Aux flow control in fep */
-
-
-/************************************************************************
- * Structure used with ioctl commands for DIGI parameters.
- ************************************************************************/
-struct digi_struct {
- unsigned short digi_flags; /* Flags (see above) */
-};
-
-typedef struct digi_struct digi_t;
-
-/* fep.h */
-
-#define FEP_CSTART 0x400L
-#define FEP_CMAX 0x800L
-#define FEP_ISTART 0x800L
-#define FEP_IMAX 0xC00L
-#define FEP_CIN 0xD10L
-#define FEP_GLOBAL 0xD10L
-#define FEP_EIN 0xD18L
-#define FEPSTAT 0xD20L
-#define CHANSTRUCT 0x1000L
-#define RXTXBUF 0x4000L
-
-
-struct global_data {
- volatile ushort cin;
- volatile ushort cout;
- volatile ushort cstart;
- volatile ushort cmax;
- volatile ushort ein;
- volatile ushort eout;
- volatile ushort istart;
- volatile ushort imax;
-};
-
-
-struct board_chan {
- int filler1;
- int filler2;
- volatile ushort tseg;
- volatile ushort tin;
- volatile ushort tout;
- volatile ushort tmax;
-
- volatile ushort rseg;
- volatile ushort rin;
- volatile ushort rout;
- volatile ushort rmax;
-
- volatile ushort tlow;
- volatile ushort rlow;
- volatile ushort rhigh;
- volatile ushort incr;
-
- volatile ushort etime;
- volatile ushort edelay;
- volatile u_char *dev;
-
- volatile ushort iflag;
- volatile ushort oflag;
- volatile ushort cflag;
- volatile ushort gmask;
-
- volatile ushort col;
- volatile ushort delay;
- volatile ushort imask;
- volatile ushort tflush;
-
- int filler3;
- int filler4;
- int filler5;
- int filler6;
-
- volatile u_char num;
- volatile u_char ract;
- volatile u_char bstat;
- volatile u_char tbusy;
- volatile u_char iempty;
- volatile u_char ilow;
- volatile u_char idata;
- volatile u_char eflag;
-
- volatile u_char tflag;
- volatile u_char rflag;
- volatile u_char xmask;
- volatile u_char xval;
- volatile u_char mstat;
- volatile u_char mchange;
- volatile u_char mint;
- volatile u_char lstat;
-
- volatile u_char mtran;
- volatile u_char orun;
- volatile u_char startca;
- volatile u_char stopca;
- volatile u_char startc;
- volatile u_char stopc;
- volatile u_char vnext;
- volatile u_char hflow;
-
- volatile u_char fillc;
- volatile u_char ochar;
- volatile u_char omask;
-
- u_char filler7;
- u_char filler8[28];
-};
-
-
-#define SRXLWATER 0xE0
-#define SRXHWATER 0xE1
-#define STOUT 0xE2
-#define PAUSETX 0xE3
-#define RESUMETX 0xE4
-#define SAUXONOFFC 0xE6
-#define SENDBREAK 0xE8
-#define SETMODEM 0xE9
-#define SETIFLAGS 0xEA
-#define SONOFFC 0xEB
-#define STXLWATER 0xEC
-#define PAUSERX 0xEE
-#define RESUMERX 0xEF
-#define SETBUFFER 0xF2
-#define SETCOOKED 0xF3
-#define SETHFLOW 0xF4
-#define SETCTRLFLAGS 0xF5
-#define SETVNEXT 0xF6
-
-
-
-#define BREAK_IND 0x01
-#define LOWTX_IND 0x02
-#define EMPTYTX_IND 0x04
-#define DATA_IND 0x08
-#define MODEMCHG_IND 0x20
-
-#define ALL_IND (BREAK_IND|LOWTX_IND|EMPTYTX_IND|DATA_IND|MODEMCHG_IND)
-
-
-#define RTS 0x02
-#define CD 0x08
-#define DSR 0x10
-#define CTS 0x20
-#define RI 0x40
-#define DTR 0x80
-
-/* pcxx.h */
-
-#define FEPCODESEG 0x0200L
-#define FEPCODE 0x2000L
-#define BIOSCODE 0xf800L
-
-#define MISCGLOBAL 0x0C00L
-#define NPORT 0x0C22L
-#define MBOX 0x0C40L
-#define PORTBASE 0x0C90L
-#define BOTWIN 0x100L
-#define TOPWIN 0xFF00L
-
-#define FEPCLR 0x00
-#define FEPMEM 0x02
-#define FEPRST 0x04
-#define FEPINT 0x08
-#define FEPMASK 0x0e
-#define FEPWIN 0x80
-
-#define PCXI 0
-#define PCXE 1
-#define PCXEVE 2
-
-static char * const board_desc[] = {
- "PC/Xi (64K)",
- "PC/Xe (64K)",
- "PC/Xe (8K) ",
-};
-
-#define STARTC 021
-#define STOPC 023
-#define IAIXON 0x2000
-
-
-struct board_info {
- u_char status;
- u_char type;
- u_char altpin;
- ushort numports;
- ushort port;
- u_long membase;
-};
-
-
-#define TXSTOPPED 0x1
-#define LOWWAIT 0x2
-#define EMPTYWAIT 0x4
-
-#define DISABLED 0
-#define ENABLED 1
-#define OFF 0
-#define ON 1
-
-#define FEPTIMEOUT 200000
-#define SERIAL_TYPE_NORMAL 1
-#define SERIAL_TYPE_CALLOUT 2
-#define PCXE_EVENT_HANGUP 1
-
-struct channel {
- u_char unit; /* board unit number */
- u_char omodem; /* FEP output modem status */
- u_char imodem; /* FEP input modem status */
- u_char modemfake; /* Modem values to be forced */
- u_char modem; /* Force values */
- u_char hflow;
- u_char dsr;
- u_char dcd;
- u_char stopc;
- u_char startc;
- u_char stopca;
- u_char startca;
- u_char fepstopc;
- u_char fepstartc;
- u_char fepstopca;
- u_char fepstartca;
- u_char txwin;
- u_char rxwin;
- ushort fepiflag;
- ushort fepcflag;
- ushort fepoflag;
- ushort txbufhead;
- ushort txbufsize;
- ushort rxbufhead;
- ushort rxbufsize;
- int close_delay;
- int count;
- int blocked_open;
- int event;
- int asyncflags;
- uint dev;
- long session;
- long pgrp;
- u_long statusflags;
- u_long c_iflag;
- u_long c_cflag;
- u_long c_lflag;
- u_long c_oflag;
- u_char *txptr;
- u_char *rxptr;
- struct board_info *board;
- struct board_chan *brdchan;
- struct digi_struct digiext;
- struct tty *tty;
- struct termios normal_termios;
- struct termios callout_termios;
- volatile struct global_data *mailbox;
-};
-
-/* flags for configuring */
-
-#define DGBFLAG_ALTPIN 0x0001 /* chande DCD and DCD */
-#define DGBFLAG_NOWIN 0x0002 /* use windowed PC/Xe as non-windowed */
-
-#define DB_RD 0x0001
-#define DB_WR 0x0002
-#define DB_WIN 0x0004
-#define DB_INFO 0x0008
-#define DB_EXCEPT 0x0010
-#define DB_OPEN 0x0100
-#define DB_CLOSE 0x0200
-#define DB_DATA 0x0400
-#define DB_RXDATA 0x0401
-#define DB_TXDATA 0x0402
-#define DB_EVENT 0x0800
-#define DB_MODEM 0x1000
-#define DB_BREAK 0x2000
-#define DB_PARAM 0x4000
-#define DB_FEP 0x8000
-
-/* debugging printout */
-
-#ifdef DGB_DEBUG
-#define DPRINT1(l,a1) (dgbdebug&l ? printf(a1) : 0)
-#define DPRINT2(l,a1,a2) (dgbdebug&l ? printf(a1,a2) : 0)
-#define DPRINT3(l,a1,a2,a3) (dgbdebug&l ? printf(a1,a2,a3) : 0)
-#define DPRINT4(l,a1,a2,a3,a4) (dgbdebug&l ? printf(a1,a2,a3,a4) : 0)
-#define DPRINT5(l,a1,a2,a3,a4,a5) (dgbdebug&l ? printf(a1,a2,a3,a4,a5) : 0)
-#define DPRINT6(l,a1,a2,a3,a4,a5,a6) (dgbdebug&l ? printf(a1,a2,a3,a4,a5,a6) : 0)
-#define DPRINT7(l,a1,a2,a3,a4,a5,a6,a7) (dgbdebug&l ? printf(a1,a2,a3,a4,a5,a6,a7) : 0)
-#else
-#define DPRINT1(l,a1)
-#define DPRINT2(l,a1,a2)
-#define DPRINT3(l,a1,a2,a3)
-#define DPRINT4(l,a1,a2,a3,a4)
-#define DPRINT5(l,a1,a2,a3,a4,a5)
-#define DPRINT6(l,a1,a2,a3,a4,a5,a6)
-#define DPRINT7(l,a1,a2,a3,a4,a5,a6,a7)
-#endif
-
-
- /* These are termios bits as the FEP understands them */
-
-/* c_cflag bits */
-#define FEP_CBAUD 0x00000f
-#define FEP_B0 0x000000 /* hang up */
-#define FEP_B50 0x000001
-#define FEP_B75 0x000002
-#define FEP_B110 0x000003
-#define FEP_B134 0x000004
-#define FEP_B150 0x000005
-#define FEP_B200 0x000006
-#define FEP_B300 0x000007
-#define FEP_B600 0x000008
-#define FEP_B1200 0x000009
-#define FEP_B1800 0x00000a
-#define FEP_B2400 0x00000b
-#define FEP_B4800 0x00000c
-#define FEP_B9600 0x00000d
-#define FEP_B19200 0x00000e
-#define FEP_B38400 0x00000f
-#define FEP_EXTA FEP_B19200
-#define FEP_EXTB FEP_B38400
-#define FEP_CSIZE 0x000030
-#define FEP_CS5 0x000000
-#define FEP_CS6 0x000010
-#define FEP_CS7 0x000020
-#define FEP_CS8 0x000030
-#define FEP_CSTOPB 0x000040
-#define FEP_CREAD 0x000080
-#define FEP_PARENB 0x000100
-#define FEP_PARODD 0x000200
-#define FEP_CLOCAL 0x000800
-#define FEP_FASTBAUD 0x000400
-/* c_iflag bits */
-#define FEP_IGNBRK 0000001
-#define FEP_BRKINT 0000002
-#define FEP_IGNPAR 0000004
-#define FEP_PARMRK 0000010
-#define FEP_INPCK 0000020
-#define FEP_ISTRIP 0000040
-#define FEP_IXON 0002000
-#define FEP_IXANY 0004000
-#define FEP_IXOFF 0010000
-
diff --git a/sys/dev/en/if_en_pci.c b/sys/dev/en/if_en_pci.c
deleted file mode 100644
index a72a292e874a..000000000000
--- a/sys/dev/en/if_en_pci.c
+++ /dev/null
@@ -1,439 +0,0 @@
-/* $NetBSD: if_en_pci.c,v 1.1 1996/06/22 02:00:31 chuck Exp $ */
-
-/*
- *
- * Copyright (c) 1996 Charles D. Cranor and Washington University.
- * 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 Charles D. Cranor and
- * Washington University.
- * 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.
- *
- * $FreeBSD$
- */
-
-/*
- *
- * i f _ e n _ p c i . c
- *
- * author: Chuck Cranor <chuck@ccrc.wustl.edu>
- * started: spring, 1996.
- *
- * FreeBSD PCI glue for the eni155p card.
- * thanks to Matt Thomas for figuring out FreeBSD vs NetBSD vs etc.. diffs.
- */
-
-#include "en.h"
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#if defined(__FreeBSD__)
-#include <sys/eventhandler.h>
-#endif
-#include <sys/malloc.h>
-#include <sys/socket.h>
-
-#include <machine/clock.h> /* for DELAY */
-
-#include <net/if.h>
-
-#include <pci/pcivar.h>
-#include <pci/pcireg.h>
-
-#include <dev/en/midwayreg.h>
-#include <dev/en/midwayvar.h>
-
-
-/*
- * prototypes
- */
-
-static void en_pci_attach __P((pcici_t, int));
-static const char *en_pci_probe __P((pcici_t, pcidi_t));
-static void en_pci_shutdown __P((void *, int));
-
-/*
- * local structures
- */
-
-struct en_pci_softc {
- /* bus independent stuff */
- struct en_softc esc; /* includes "device" structure */
-
- /* PCI bus glue */
- void *sc_ih; /* interrupt handle */
- pci_chipset_tag_t en_pc; /* for PCI calls */
- pcici_t en_confid; /* config id */
-};
-
-#if !defined(MIDWAY_ENIONLY)
-static void eni_get_macaddr __P((struct en_pci_softc *));
-#endif
-#if !defined(MIDWAY_ADPONLY)
-static void adp_get_macaddr __P((struct en_pci_softc *));
-#endif
-
-/*
- * pointers to softcs (we alloc)
- */
-
-static struct en_pci_softc *enpcis[NEN] = {0};
-extern struct cfdriver en_cd;
-
-/*
- * autoconfig structures
- */
-
-static u_long en_pci_count;
-
-static struct pci_device endevice = {
- "en",
- en_pci_probe,
- en_pci_attach,
- &en_pci_count,
- NULL,
-};
-
-COMPAT_PCI_DRIVER (en, endevice);
-
-/*
- * local defines (PCI specific stuff)
- */
-
-/*
- * address of config base memory address register in PCI config space
- * (this is card specific)
- */
-
-#define PCI_CBMA 0x10
-
-/*
- * tonga (pci bridge). ENI cards only!
- */
-
-#define EN_TONGA 0x60 /* PCI config addr of tonga reg */
-
-#define TONGA_SWAP_DMA 0x80 /* endian swap control */
-#define TONGA_SWAP_BYTE 0x40
-#define TONGA_SWAP_WORD 0x20
-
-/*
- * adaptec pci bridge. ADP cards only!
- */
-
-#define ADP_PCIREG 0x050040 /* PCI control register */
-
-#define ADP_PCIREG_RESET 0x1 /* reset card */
-#define ADP_PCIREG_IENABLE 0x2 /* interrupt enable */
-#define ADP_PCIREG_SWAP_WORD 0x4 /* swap byte on slave access */
-#define ADP_PCIREG_SWAP_DMA 0x8 /* swap byte on DMA */
-
-#define PCI_VENDOR_EFFICIENTNETS 0x111a /* Efficent Networks */
-#define PCI_PRODUCT_EFFICIENTNETS_ENI155PF 0x0000 /* ENI-155P ATM */
-#define PCI_PRODUCT_EFFICIENTNETS_ENI155PA 0x0002 /* ENI-155P ATM */
-#define PCI_VENDOR_ADP 0x9004 /* adaptec */
-#define PCI_PRODUCT_ADP_AIC5900 0x5900
-#define PCI_PRODUCT_ADP_AIC5905 0x5905
-#define PCI_VENDOR(x) ((x) & 0xFFFF)
-#define PCI_CHIPID(x) (((x) >> 16) & 0xFFFF)
-
-#if !defined(MIDWAY_ENIONLY)
-
-static void adp_busreset __P((void *));
-
-/*
- * bus specific reset function [ADP only!]
- */
-
-static void adp_busreset(v)
-
-void *v;
-
-{
- struct en_softc *sc = (struct en_softc *) v;
- u_int32_t dummy;
-
- bus_space_write_4(sc->en_memt, sc->en_base, ADP_PCIREG, ADP_PCIREG_RESET);
- DELAY(1000); /* let it reset */
- dummy = bus_space_read_4(sc->en_memt, sc->en_base, ADP_PCIREG);
- bus_space_write_4(sc->en_memt, sc->en_base, ADP_PCIREG,
- (ADP_PCIREG_SWAP_WORD|ADP_PCIREG_SWAP_DMA|ADP_PCIREG_IENABLE));
- dummy = bus_space_read_4(sc->en_memt, sc->en_base, ADP_PCIREG);
- if ((dummy & (ADP_PCIREG_SWAP_WORD|ADP_PCIREG_SWAP_DMA)) !=
- (ADP_PCIREG_SWAP_WORD|ADP_PCIREG_SWAP_DMA))
- printf("adp_busreset: Adaptec ATM did NOT reset!\n");
-}
-#endif
-
-/***********************************************************************/
-
-/*
- * autoconfig stuff
- */
-
-static const char *en_pci_probe(config_id, device_id)
-
-pcici_t config_id;
-pcidi_t device_id;
-
-{
-#if !defined(MIDWAY_ADPONLY)
- if (PCI_VENDOR(device_id) == PCI_VENDOR_EFFICIENTNETS &&
- (PCI_CHIPID(device_id) == PCI_PRODUCT_EFFICIENTNETS_ENI155PF ||
- PCI_CHIPID(device_id) == PCI_PRODUCT_EFFICIENTNETS_ENI155PA))
- return "Efficient Networks ENI-155p";
-#endif
-
-#if !defined(MIDWAY_ENIONLY)
- if (PCI_VENDOR(device_id) == PCI_VENDOR_ADP &&
- (PCI_CHIPID(device_id) == PCI_PRODUCT_ADP_AIC5900 ||
- PCI_CHIPID(device_id) == PCI_PRODUCT_ADP_AIC5905))
- return "Adaptec 155 ATM";
-#endif
-
- return 0;
-}
-
-static void en_pci_attach(config_id, unit)
-
-pcici_t config_id;
-int unit;
-
-{
- struct en_softc *sc;
- struct en_pci_softc *scp;
- pcidi_t device_id;
- int retval;
- vm_offset_t pa;
-
- if (unit >= NEN) {
- printf("en%d: not configured; kernel is built for only %d device%s.\n",
- unit, NEN, NEN == 1 ? "" : "s");
- return;
- }
-
- scp = (struct en_pci_softc *) malloc(sizeof(*scp), M_DEVBUF, M_NOWAIT);
- if (scp == NULL)
- return;
- bzero(scp, sizeof(*scp)); /* zero */
- sc = &scp->esc;
-
- retval = pci_map_mem(config_id, PCI_CBMA, (vm_offset_t *) &sc->en_base, &pa);
-
- if (!retval) {
- free((caddr_t) scp, M_DEVBUF);
- return;
- }
- enpcis[unit] = scp; /* lock it in */
- en_cd.cd_devs[unit] = sc; /* fake a cfdriver structure */
- en_cd.cd_ndevs = NEN;
- snprintf(sc->sc_dev.dv_xname, sizeof(sc->sc_dev.dv_xname), "en%d", unit);
- sc->enif.if_unit = unit;
- sc->enif.if_name = "en";
- scp->en_confid = config_id;
-
- /*
- * figure out if we are an adaptec card or not.
- * XXX: why do we have to re-read PC_ID_REG when en_pci_probe already
- * had that info?
- */
-
- device_id = pci_conf_read(config_id, PCI_ID_REG);
- sc->is_adaptec = (PCI_VENDOR(device_id) == PCI_VENDOR_ADP) ? 1 : 0;
-
- /*
- * Add shutdown hook so that DMA is disabled prior to reboot. Not
- * doing so could allow DMA to corrupt kernel memory during the
- * reboot before the driver initializes.
- */
- EVENTHANDLER_REGISTER(shutdown_post_sync, en_pci_shutdown, scp,
- SHUTDOWN_PRI_DEFAULT);
-
- if (!pci_map_int(config_id, en_intr, (void *) sc, &net_imask)) {
- printf("%s: couldn't establish interrupt\n", sc->sc_dev.dv_xname);
- return;
- }
- sc->ipl = 1; /* XXX */
-
- /*
- * set up pci bridge
- */
-
-#if !defined(MIDWAY_ENIONLY)
- if (sc->is_adaptec) {
- adp_get_macaddr(scp);
- sc->en_busreset = adp_busreset;
- adp_busreset(sc);
- }
-#endif
-
-#if !defined(MIDWAY_ADPONLY)
- if (!sc->is_adaptec) {
- eni_get_macaddr(scp);
- sc->en_busreset = NULL;
- pci_conf_write(config_id, EN_TONGA, (TONGA_SWAP_DMA|TONGA_SWAP_WORD));
- }
-#endif
-
- /*
- * done PCI specific stuff
- */
-
- en_attach(sc);
-
-}
-
-static void
-en_pci_shutdown(
- void *sc,
- int howto)
-{
- struct en_pci_softc *psc = (struct en_pci_softc *)sc;
-
- en_reset(&psc->esc);
- DELAY(10);
-}
-
-#if !defined(MIDWAY_ENIONLY)
-
-#if defined(sparc) || defined(__FreeBSD__)
-#define bus_space_read_1(t, h, o) \
- ((void)t, (*(volatile u_int8_t *)((h) + (o))))
-#endif
-
-static void
-adp_get_macaddr(scp)
- struct en_pci_softc *scp;
-{
- struct en_softc * sc = (struct en_softc *)scp;
- int lcv;
-
- for (lcv = 0; lcv < sizeof(sc->macaddr); lcv++)
- sc->macaddr[lcv] = bus_space_read_1(sc->en_memt, sc->en_base,
- MID_ADPMACOFF + lcv);
-}
-
-#endif /* MIDWAY_ENIONLY */
-
-#if !defined(MIDWAY_ADPONLY)
-
-/*
- * Read station (MAC) address from serial EEPROM.
- * derived from linux drivers/atm/eni.c by Werner Almesberger, EPFL LRC.
- */
-#define EN_PROM_MAGIC 0x0c
-#define EN_PROM_DATA 0x02
-#define EN_PROM_CLK 0x01
-#define EN_ESI 64
-
-static void
-eni_get_macaddr(scp)
- struct en_pci_softc *scp;
-{
- struct en_softc * sc = (struct en_softc *)scp;
- pcici_t id = scp->en_confid;
- int i, j, address, status;
- u_int32_t data, t_data;
- u_int8_t tmp;
-
- t_data = pci_conf_read(id, EN_TONGA) & 0xffffff00;
-
- data = EN_PROM_MAGIC | EN_PROM_DATA | EN_PROM_CLK;
- pci_conf_write(id, EN_TONGA, data);
-
- for (i = 0; i < sizeof(sc->macaddr); i ++){
- /* start operation */
- data |= EN_PROM_DATA ;
- pci_conf_write(id, EN_TONGA, data);
- data |= EN_PROM_CLK ;
- pci_conf_write(id, EN_TONGA, data);
- data &= ~EN_PROM_DATA ;
- pci_conf_write(id, EN_TONGA, data);
- data &= ~EN_PROM_CLK ;
- pci_conf_write(id, EN_TONGA, data);
- /* send address with serial line */
- address = ((i + EN_ESI) << 1) + 1;
- for ( j = 7 ; j >= 0 ; j --){
- data = (address >> j) & 1 ? data | EN_PROM_DATA :
- data & ~EN_PROM_DATA;
- pci_conf_write(id, EN_TONGA, data);
- data |= EN_PROM_CLK ;
- pci_conf_write(id, EN_TONGA, data);
- data &= ~EN_PROM_CLK ;
- pci_conf_write(id, EN_TONGA, data);
- }
- /* get ack */
- data |= EN_PROM_DATA ;
- pci_conf_write(id, EN_TONGA, data);
- data |= EN_PROM_CLK ;
- pci_conf_write(id, EN_TONGA, data);
- data = pci_conf_read(id, EN_TONGA);
- status = data & EN_PROM_DATA;
- data &= ~EN_PROM_CLK ;
- pci_conf_write(id, EN_TONGA, data);
- data |= EN_PROM_DATA ;
- pci_conf_write(id, EN_TONGA, data);
-
- tmp = 0;
-
- for ( j = 7 ; j >= 0 ; j --){
- tmp <<= 1;
- data |= EN_PROM_DATA ;
- pci_conf_write(id, EN_TONGA, data);
- data |= EN_PROM_CLK ;
- pci_conf_write(id, EN_TONGA, data);
- data = pci_conf_read(id, EN_TONGA);
- if(data & EN_PROM_DATA) tmp |= 1;
- data &= ~EN_PROM_CLK ;
- pci_conf_write(id, EN_TONGA, data);
- data |= EN_PROM_DATA ;
- pci_conf_write(id, EN_TONGA, data);
- }
- /* get ack */
- data |= EN_PROM_DATA ;
- pci_conf_write(id, EN_TONGA, data);
- data |= EN_PROM_CLK ;
- pci_conf_write(id, EN_TONGA, data);
- data = pci_conf_read(id, EN_TONGA);
- status = data & EN_PROM_DATA;
- data &= ~EN_PROM_CLK ;
- pci_conf_write(id, EN_TONGA, data);
- data |= EN_PROM_DATA ;
- pci_conf_write(id, EN_TONGA, data);
-
- sc->macaddr[i] = tmp;
- }
- /* stop operation */
- data &= ~EN_PROM_DATA;
- pci_conf_write(id, EN_TONGA, data);
- data |= EN_PROM_CLK;
- pci_conf_write(id, EN_TONGA, data);
- data |= EN_PROM_DATA;
- pci_conf_write(id, EN_TONGA, data);
- pci_conf_write(id, EN_TONGA, t_data);
-}
-
-#endif /* !MIDWAY_ADPONLY */
diff --git a/sys/dev/fb/splash_bmp.c b/sys/dev/fb/splash_bmp.c
deleted file mode 100644
index 71a53b9c38a4..000000000000
--- a/sys/dev/fb/splash_bmp.c
+++ /dev/null
@@ -1,582 +0,0 @@
-/*-
- * Copyright (c) 1999 Michael Smith <msmith@freebsd.org>
- * Copyright (c) 1999 Kazutaka YOKOTA <yokota@freebsd.org>
- * 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 AUTHORS 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 AUTHORS 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/linker.h>
-#include <sys/fbio.h>
-
-#include <dev/fb/fbreg.h>
-#include <dev/fb/splashreg.h>
-
-#define FADE_TIMEOUT 15 /* sec */
-#define FADE_LEVELS 10
-
-static int splash_mode = -1;
-static int splash_on = FALSE;
-
-static int bmp_start(video_adapter_t *adp);
-static int bmp_end(video_adapter_t *adp);
-static int bmp_splash(video_adapter_t *adp, int on);
-static int bmp_Init(const char *data, int swidth, int sheight, int sdepth);
-static int bmp_Draw(video_adapter_t *adp);
-
-static splash_decoder_t bmp_decoder = {
- "splash_bmp", bmp_start, bmp_end, bmp_splash, SPLASH_IMAGE,
-};
-
-SPLASH_DECODER(splash_bmp, bmp_decoder);
-
-static int
-bmp_start(video_adapter_t *adp)
-{
- /* currently only 256-color modes are supported XXX */
- static int modes[] = {
- M_VESA_CG640x480,
- M_VESA_CG800x600,
- M_VESA_CG1024x768,
- /*
- * As 320x200 doesn't generally look great,
- * it's least preferred here.
- */
- M_VGA_CG320,
- -1,
- };
- video_info_t info;
- int i;
-
- if ((bmp_decoder.data == NULL) || (bmp_decoder.data_size <= 0)) {
- printf("splash_bmp: No bitmap file found\n");
- return ENODEV;
- }
- for (i = 0; modes[i] >= 0; ++i) {
- if (((*vidsw[adp->va_index]->get_info)(adp, modes[i], &info) == 0)
- && (bmp_Init((u_char *)bmp_decoder.data,
- info.vi_width, info.vi_height, info.vi_depth) == 0))
- break;
- }
- splash_mode = modes[i];
- if (splash_mode < 0)
- printf("splash_bmp: No appropriate video mode found\n");
- if (bootverbose)
- printf("bmp_start(): splash_mode:%d\n", splash_mode);
- return ((splash_mode < 0) ? ENODEV : 0);
-}
-
-static int
-bmp_end(video_adapter_t *adp)
-{
- /* nothing to do */
- return 0;
-}
-
-static int
-bmp_splash(video_adapter_t *adp, int on)
-{
- static u_char pal[256*3];
- static long time_stamp;
- u_char tpal[256*3];
- static int fading = TRUE, brightness = FADE_LEVELS;
- struct timeval tv;
- int i;
-
- if (on) {
- if (!splash_on) {
- /* set up the video mode and draw something */
- if ((*vidsw[adp->va_index]->set_mode)(adp, splash_mode))
- return 1;
- if (bmp_Draw(adp))
- return 1;
- (*vidsw[adp->va_index]->save_palette)(adp, pal);
- time_stamp = 0;
- splash_on = TRUE;
- }
- /*
- * This is a kludge to fade the image away. This section of the
- * code takes effect only after the system is completely up.
- * FADE_TIMEOUT should be configurable.
- */
- if (!cold) {
- getmicrotime(&tv);
- if (time_stamp == 0)
- time_stamp = tv.tv_sec;
- if (tv.tv_sec > time_stamp + FADE_TIMEOUT) {
- if (fading)
- if (brightness == 0) {
- fading = FALSE;
- brightness++;
- }
- else brightness--;
- else
- if (brightness == FADE_LEVELS) {
- fading = TRUE;
- brightness--;
- }
- else brightness++;
- for (i = 0; i < sizeof(pal); ++i) {
- tpal[i] = pal[i] * brightness / FADE_LEVELS;
- }
- (*vidsw[adp->va_index]->load_palette)(adp, tpal);
- time_stamp = tv.tv_sec;
- }
- }
- return 0;
- } else {
- /* the video mode will be restored by the caller */
- splash_on = FALSE;
- return 0;
- }
-}
-
-/*
-** Code to handle Microsoft DIB (".BMP") format images.
-**
-** Blame me (msmith@freebsd.org) if this is broken, not Soren.
-*/
-
-typedef struct tagBITMAPFILEHEADER { /* bmfh */
- u_short bfType __attribute__ ((packed));
- int bfSize __attribute__ ((packed));
- u_short bfReserved1 __attribute__ ((packed));
- u_short bfReserved2 __attribute__ ((packed));
- int bfOffBits __attribute__ ((packed));
-} BITMAPFILEHEADER;
-
-typedef struct tagBITMAPINFOHEADER { /* bmih */
- int biSize __attribute__ ((packed));
- int biWidth __attribute__ ((packed));
- int biHeight __attribute__ ((packed));
- short biPlanes __attribute__ ((packed));
- short biBitCount __attribute__ ((packed));
- int biCompression __attribute__ ((packed));
- int biSizeImage __attribute__ ((packed));
- int biXPelsPerMeter __attribute__ ((packed));
- int biYPelsPerMeter __attribute__ ((packed));
- int biClrUsed __attribute__ ((packed));
- int biClrImportant __attribute__ ((packed));
-} BITMAPINFOHEADER;
-
-typedef struct tagRGBQUAD { /* rgbq */
- u_char rgbBlue __attribute__ ((packed));
- u_char rgbGreen __attribute__ ((packed));
- u_char rgbRed __attribute__ ((packed));
- u_char rgbReserved __attribute__ ((packed));
-} RGBQUAD;
-
-typedef struct tagBITMAPINFO { /* bmi */
- BITMAPINFOHEADER bmiHeader __attribute__ ((packed));
- RGBQUAD bmiColors[256] __attribute__ ((packed));
-} BITMAPINFO;
-
-typedef struct tagBITMAPF
-{
- BITMAPFILEHEADER bmfh __attribute__ ((packed));
- BITMAPINFO bmfi __attribute__ ((packed));
-} BITMAPF;
-
-#define BI_RGB 0
-#define BI_RLE8 1
-#define BI_RLE4 2
-
-/*
-** all we actually care about the image
-*/
-typedef struct
-{
- int width,height; /* image dimensions */
- int swidth,sheight; /* screen dimensions for the current mode */
- u_char sdepth; /* screen depth (1, 4, 8 bpp) */
- int ncols; /* number of colours */
- u_char palette[256][3]; /* raw palette data */
- u_char format; /* one of the BI_* constants above */
- u_char *data; /* pointer to the raw data */
- u_char *index; /* running pointer to the data while drawing */
- u_char *vidmem; /* video memory allocated for drawing */
- video_adapter_t *adp;
- int bank;
-} BMP_INFO;
-
-static BMP_INFO bmp_info;
-
-static void
-fill(BMP_INFO *info, int x, int y, int xsize, int ysize)
-{
- u_char *window;
- int banksize;
- int bank;
- int p;
-
- banksize = info->adp->va_window_size;
- bank = (info->adp->va_line_width*y + x)/banksize;
- window = (u_char *)info->adp->va_window;
- (*vidsw[info->adp->va_index]->set_win_org)(info->adp, bank*banksize);
- while (ysize > 0) {
- p = (info->adp->va_line_width*y + x)%banksize;
- for (; (p + xsize <= banksize) && ysize > 0; --ysize, ++y) {
- generic_bzero(window + p, xsize);
- p += info->adp->va_line_width;
- }
- if (ysize <= 0)
- break;
- if (p < banksize) {
- /* the last line crosses the window boundary */
- generic_bzero(window + p, banksize - p);
- }
- ++bank; /* next bank */
- (*vidsw[info->adp->va_index]->set_win_org)(info->adp, bank*banksize);
- if (p < banksize) {
- /* the remaining part of the last line */
- generic_bzero(window, p + xsize - banksize);
- ++y;
- --ysize;
- }
- }
- info->bank = bank;
-}
-
-/*
-** bmp_SetPix
-**
-** Given (info), set the pixel at (x),(y) to (val)
-**
-*/
-static void
-bmp_SetPix(BMP_INFO *info, int x, int y, u_char val)
-{
- int sofs, bofs;
- u_char tpv, mask;
- int newbank;
-
- /*
- * range check to avoid explosions
- */
- if ((x < 0) || (x >= info->swidth) || (y < 0) || (y >= info->sheight))
- return;
-
- /*
- * calculate offset into video memory;
- * because 0,0 is bottom-left for DIB, we have to convert.
- */
- sofs = ((info->height - (y+1) + (info->sheight - info->height) / 2)
- * info->adp->va_line_width);
-
- switch(info->sdepth) {
- case 1:
- sofs += ((x + (info->swidth - info->width) / 2) >> 3);
- bofs = x & 0x7; /* offset within byte */
-
- val &= 1; /* mask pixel value */
- mask = ~(0x80 >> bofs); /* calculate bit mask */
- tpv = *(info->vidmem+sofs) & mask; /* get screen contents, excluding masked bit */
- *(info->vidmem+sofs) = tpv | (val << (8-bofs)); /* write new bit */
- break;
-
- /* XXX only correct for non-interleaved modes */
- case 4:
- sofs += ((x + (info->swidth - info->width) / 2) >> 1);
- bofs = x & 0x1; /* offset within byte */
-
- val &= 0xf; /* mask pixel value */
- mask = bofs ? 0x0f : 0xf0; /* calculate bit mask */
- tpv = *(info->vidmem+sofs) & mask; /* get screen contents, excluding masked bits */
- *(info->vidmem+sofs) = tpv | (val << (bofs ? 0 : 4)); /* write new bits */
- break;
-
- case 8:
- sofs += x + (info->swidth - info->width) / 2;
- newbank = sofs/info->adp->va_window_size;
- if (info->bank != newbank) {
- (*vidsw[info->adp->va_index]->set_win_org)(info->adp, newbank*info->adp->va_window_size);
- info->bank = newbank;
- }
- sofs %= info->adp->va_window_size;
- *(info->vidmem+sofs) = val;
- break;
- }
-}
-
-/*
-** bmp_DecodeRLE4
-**
-** Given (data) pointing to a line of RLE4-format data and (line) being the starting
-** line onscreen, decode the line.
-*/
-static void
-bmp_DecodeRLE4(BMP_INFO *info, int line)
-{
- int count; /* run count */
- u_char val;
- int x,y; /* screen position */
-
- x = 0; /* starting position */
- y = line;
-
- /* loop reading data */
- for (;;) {
- /*
- * encoded mode starts with a run length, and then a byte with
- * two colour indexes to alternate between for the run
- */
- if (*info->index) {
- for (count = 0; count < *info->index; count++, x++) {
- if (count & 1) { /* odd count, low nybble */
- bmp_SetPix(info, x, y, *(info->index+1) & 0x0f);
- } else { /* even count, high nybble */
- bmp_SetPix(info, x, y, (*(info->index+1) >>4) & 0x0f);
- }
- }
- info->index += 2;
- /*
- * A leading zero is an escape; it may signal the end of the
- * bitmap, a cursor move, or some absolute data.
- */
- } else { /* zero tag may be absolute mode or an escape */
- switch (*(info->index+1)) {
- case 0: /* end of line */
- info->index += 2;
- return;
- case 1: /* end of bitmap */
- info->index = NULL;
- return;
- case 2: /* move */
- x += *(info->index + 2); /* new coords */
- y += *(info->index + 3);
- info->index += 4;
- break;
- default: /* literal bitmap data */
- for (count = 0; count < *(info->index + 1); count++, x++) {
- val = *(info->index + 2 + (count / 2)); /* byte with nybbles */
- if (count & 1) {
- val &= 0xf; /* get low nybble */
- } else {
- val = (val >> 4); /* get high nybble */
- }
- bmp_SetPix(info, x, y, val);
- }
- /* warning, this depends on integer truncation, do not hand-optimise! */
- info->index += 2 + ((count + 3) / 4) * 2;
- break;
- }
- }
- }
-}
-
-/*
-** bmp_DecodeRLE8
-** Given (data) pointing to a line of RLE4-format data and (line) being the starting
-** line onscreen, decode the line.
-*/
-static void
-bmp_DecodeRLE8(BMP_INFO *info, int line)
-{
- int count; /* run count */
- int x,y; /* screen position */
-
- x = 0; /* starting position */
- y = line;
-
- /* loop reading data */
- for(;;) {
- /*
- * encoded mode starts with a run length, and then a byte with
- * two colour indexes to alternate between for the run
- */
- if (*info->index) {
- for (count = 0; count < *info->index; count++, x++)
- bmp_SetPix(info, x, y, *(info->index+1));
- info->index += 2;
- /*
- * A leading zero is an escape; it may signal the end of the
- * bitmap, a cursor move, or some absolute data.
- */
- } else { /* zero tag may be absolute mode or an escape */
- switch(*(info->index+1)) {
- case 0: /* end of line */
- info->index += 2;
- return;
- case 1: /* end of bitmap */
- info->index = NULL;
- return;
- case 2: /* move */
- x += *(info->index + 2); /* new coords */
- y += *(info->index + 3);
- info->index += 4;
- break;
- default: /* literal bitmap data */
- for (count = 0; count < *(info->index + 1); count++, x++)
- bmp_SetPix(info, x, y, *(info->index + 2 + count));
- /* must be an even count */
- info->index += 2 + count + (count & 1);
- break;
- }
- }
- }
-}
-
-/*
-** bmp_DecodeLine
-**
-** Given (info) pointing to an image being decoded, (line) being the line currently
-** being displayed, decode a line of data.
-*/
-static void
-bmp_DecodeLine(BMP_INFO *info, int line)
-{
- int x;
-
- switch(info->format) {
- case BI_RGB:
- for (x = 0; x < info->width; x++, info->index++)
- bmp_SetPix(info, x, line, *info->index);
- info->index += 3 - (--x % 4);
- break;
- case BI_RLE4:
- bmp_DecodeRLE4(info, line);
- break;
- case BI_RLE8:
- bmp_DecodeRLE8(info, line);
- break;
- }
-}
-
-/*
-** bmp_Init
-**
-** Given a pointer (data) to the image of a BMP file, fill in bmp_info with what
-** can be learnt from it. Return nonzero if the file isn't usable.
-**
-** Take screen dimensions (swidth), (sheight) and (sdepth) and make sure we
-** can work with these.
-*/
-static int
-bmp_Init(const char *data, int swidth, int sheight, int sdepth)
-{
- BITMAPF *bmf = (BITMAPF *)data;
- int pind;
-
- bmp_info.data = NULL; /* assume setup failed */
-
- /* check file ID */
- if (bmf->bmfh.bfType != 0x4d42) {
- printf("splash_bmp: not a BMP file\n");
- return(1); /* XXX check word ordering for big-endian ports? */
- }
-
- /* do we understand this bitmap format? */
- if (bmf->bmfi.bmiHeader.biSize > sizeof(bmf->bmfi.bmiHeader)) {
- printf("splash_bmp: unsupported BMP format (size=%d)\n",
- bmf->bmfi.bmiHeader.biSize);
- return(1);
- }
-
- /* save what we know about the screen */
- bmp_info.swidth = swidth;
- bmp_info.sheight = sheight;
- bmp_info.sdepth = sdepth;
-
- /* where's the data? */
- bmp_info.data = (u_char *)data + bmf->bmfh.bfOffBits;
-
- /* image parameters */
- bmp_info.width = bmf->bmfi.bmiHeader.biWidth;
- bmp_info.height = bmf->bmfi.bmiHeader.biHeight;
- bmp_info.format = bmf->bmfi.bmiHeader.biCompression;
-
- switch(bmp_info.format) { /* check compression format */
- case BI_RGB:
- case BI_RLE4:
- case BI_RLE8:
- break;
- default:
- printf("splash_bmp: unsupported compression format\n");
- return(1); /* unsupported compression format */
- }
-
- /* palette details */
- bmp_info.ncols = (bmf->bmfi.bmiHeader.biClrUsed);
- bzero(bmp_info.palette,sizeof(bmp_info.palette));
- if (bmp_info.ncols == 0) { /* uses all of them */
- bmp_info.ncols = 1 << bmf->bmfi.bmiHeader.biBitCount;
- }
- if ((bmf->bmfi.bmiHeader.biBitCount != sdepth)
- || (bmp_info.ncols > (1 << sdepth))) {
- printf("splash_bmp: unsupported color depth (%d bits, %d colors)\n",
- bmf->bmfi.bmiHeader.biBitCount, bmp_info.ncols);
- return(1);
- }
- if ((bmp_info.height > bmp_info.sheight) ||
- (bmp_info.width > bmp_info.swidth) ||
- (bmp_info.ncols > (1 << sdepth))) {
- return(1); /* beyond screen capacity */
- }
-
- /* read palette */
- for (pind = 0; pind < bmp_info.ncols; pind++) {
- bmp_info.palette[pind][0] = bmf->bmfi.bmiColors[pind].rgbRed;
- bmp_info.palette[pind][1] = bmf->bmfi.bmiColors[pind].rgbGreen;
- bmp_info.palette[pind][2] = bmf->bmfi.bmiColors[pind].rgbBlue;
- }
- return(0);
-}
-
-/*
-** bmp_Draw
-**
-** Render the image. Return nonzero if that's not possible.
-**
-*/
-static int
-bmp_Draw(video_adapter_t *adp)
-{
- int line;
-
- if (bmp_info.data == NULL) { /* init failed, do nothing */
- return(1);
- }
-
- /* clear the screen */
- bmp_info.vidmem = (u_char *)adp->va_window;
- bmp_info.adp = adp;
- /* XXX; the following line is correct only for 8bpp modes */
- fill(&bmp_info, 0, 0, bmp_info.swidth, bmp_info.sheight);
- (*vidsw[adp->va_index]->set_win_org)(adp, 0);
- bmp_info.bank = 0;
-
- /* initialise the info structure for drawing */
- bmp_info.index = bmp_info.data;
-
- /* set the palette for our image */
- (*vidsw[adp->va_index]->load_palette)(adp, (u_char *)&bmp_info.palette);
-
- for (line = 0; (line < bmp_info.height) && bmp_info.index; line++) {
- bmp_DecodeLine(&bmp_info, line);
- }
- return(0);
-}
diff --git a/sys/dev/fb/splash_pcx.c b/sys/dev/fb/splash_pcx.c
deleted file mode 100644
index 544e8c795785..000000000000
--- a/sys/dev/fb/splash_pcx.c
+++ /dev/null
@@ -1,261 +0,0 @@
-/*-
- * Copyright (c) 1999 Michael Smith <msmith@freebsd.org>
- * Copyright (c) 1999 Kazutaka YOKOTA <yokota@freebsd.org>
- * Copyright (c) 1999 Dag-Erling Coïdan Smørgrav
- * 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
- * in this position and unchanged.
- * 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/linker.h>
-#include <sys/fbio.h>
-
-#include <dev/fb/fbreg.h>
-#include <dev/fb/splashreg.h>
-
-#define FADE_TIMEOUT 300 /* sec */
-
-static int splash_mode = -1;
-static int splash_on = FALSE;
-
-static int pcx_start(video_adapter_t *adp);
-static int pcx_end(video_adapter_t *adp);
-static int pcx_splash(video_adapter_t *adp, int on);
-static int pcx_init(const char *data, int sdepth);
-static int pcx_draw(video_adapter_t *adp);
-
-static splash_decoder_t pcx_decoder = {
- "splash_pcx", pcx_start, pcx_end, pcx_splash, SPLASH_IMAGE,
-};
-
-SPLASH_DECODER(splash_pcx, pcx_decoder);
-
-static struct
-{
- int width, height, bpsl;
- int bpp, planes, zlen;
- const u_char *zdata, *palette;
-} pcx_info;
-
-static int
-pcx_start(video_adapter_t *adp)
-{
- static int modes[] = {
- M_VGA_CG320,
- M_VESA_CG640x480,
- M_VESA_CG800x600,
- M_VESA_CG1024x768,
- -1,
- };
- video_info_t info;
- int i;
-
- if (pcx_decoder.data == NULL
- || pcx_decoder.data_size <= 0
- || pcx_init((u_char *)pcx_decoder.data, pcx_decoder.data_size))
- return ENODEV;
-
- if (bootverbose)
- printf("splash_pcx: image good:\n"
- " width = %d\n"
- " height = %d\n"
- " depth = %d\n"
- " planes = %d\n",
- pcx_info.width, pcx_info.height,
- pcx_info.bpp, pcx_info.planes);
-
- for (i = 0; modes[i] >= 0; ++i) {
- if (get_mode_info(adp, modes[i], &info) != 0)
- continue;
- if (bootverbose)
- printf("splash_pcx: considering mode %d:\n"
- " vi_width = %d\n"
- " vi_height = %d\n"
- " vi_depth = %d\n"
- " vi_planes = %d\n",
- modes[i],
- info.vi_width, info.vi_height,
- info.vi_depth, info.vi_planes);
- if (info.vi_width >= pcx_info.width
- && info.vi_height >= pcx_info.height
- && info.vi_depth == pcx_info.bpp
- && info.vi_planes == pcx_info.planes)
- break;
- }
-
- splash_mode = modes[i];
- if (splash_mode == -1)
- return ENODEV;
- if (bootverbose)
- printf("pcx_splash: selecting mode %d\n", splash_mode);
- return 0;
-}
-
-static int
-pcx_end(video_adapter_t *adp)
-{
- /* nothing to do */
- return 0;
-}
-
-static int
-pcx_splash(video_adapter_t *adp, int on)
-{
- if (on) {
- if (!splash_on) {
- if (set_video_mode(adp, splash_mode) || pcx_draw(adp))
- return 1;
- splash_on = TRUE;
- }
- return 0;
- } else {
- splash_on = FALSE;
- return 0;
- }
-}
-
-struct pcxheader {
- u_char manufactor;
- u_char version;
- u_char encoding;
- u_char bpp;
- u_short xmin, ymin, xmax, ymax;
- u_short hres, vres;
- u_char colormap[48];
- u_char rsvd;
- u_char nplanes;
- u_short bpsl;
- u_short palinfo;
- u_short hsize, vsize;
-};
-
-#define MAXSCANLINE 1024
-
-static int
-pcx_init(const char *data, int size)
-{
- const struct pcxheader *hdr;
-
- hdr = (const struct pcxheader *)data;
-
- if (size < 128 + 1 + 1 + 768
- || hdr->manufactor != 10
- || hdr->version != 5
- || hdr->encoding != 1
- || hdr->nplanes != 1
- || hdr->bpp != 8
- || hdr->bpsl > MAXSCANLINE
- || data[size-769] != 12) {
- printf("splash_pcx: invalid PCX image\n");
- return 1;
- }
- pcx_info.width = hdr->xmax - hdr->xmin + 1;
- pcx_info.height = hdr->ymax - hdr->ymin + 1;
- pcx_info.bpsl = hdr->bpsl;
- pcx_info.bpp = hdr->bpp;
- pcx_info.planes = hdr->nplanes;
- pcx_info.zlen = size - (128 + 1 + 768);
- pcx_info.zdata = data + 128;
- pcx_info.palette = data + size - 768;
- return 0;
-}
-
-static int
-pcx_draw(video_adapter_t *adp)
-{
- u_char *vidmem;
- int swidth, sheight, sbpsl, sdepth, splanes;
- int banksize, origin;
- int c, i, j, pos, scan, x, y;
- u_char line[MAXSCANLINE];
-
- if (pcx_info.zlen < 1)
- return 1;
-
- load_palette(adp, pcx_info.palette);
-
- vidmem = (u_char *)adp->va_window;
- swidth = adp->va_info.vi_width;
- sheight = adp->va_info.vi_height;
- sbpsl = adp->va_line_width;
- sdepth = adp->va_info.vi_depth;
- splanes = adp->va_info.vi_planes;
- banksize = adp->va_window_size;
-
- for (origin = 0; origin < sheight*sbpsl; origin += banksize) {
- set_origin(adp, origin);
- bzero(vidmem, banksize);
- }
-
- x = (swidth - pcx_info.width) / 2;
- y = (sheight - pcx_info.height) / 2;
- origin = 0;
- pos = y * sbpsl + x;
- while (pos > banksize) {
- pos -= banksize;
- origin += banksize;
- }
- set_origin(adp, origin);
-
- for (scan = i = 0; scan < pcx_info.height; ++scan, ++y, pos += sbpsl) {
- for (j = 0; j < pcx_info.bpsl && i < pcx_info.zlen; ++i) {
- if ((pcx_info.zdata[i] & 0xc0) == 0xc0) {
- c = pcx_info.zdata[i++] & 0x3f;
- if (i >= pcx_info.zlen)
- return 1;
- } else {
- c = 1;
- }
- if (j + c > pcx_info.bpsl)
- return 1;
- while (c--)
- line[j++] = pcx_info.zdata[i];
- }
-
- if (pos > banksize) {
- origin += banksize;
- pos -= banksize;
- set_origin(adp, origin);
- }
-
- if (pos + pcx_info.width > banksize) {
- /* scanline crosses bank boundary */
- j = banksize - pos;
- bcopy(line, vidmem + pos, j);
- origin += banksize;
- pos -= banksize;
- set_origin(adp, origin);
- bcopy(line + j, vidmem, pcx_info.width - j);
- } else {
- bcopy(line, vidmem + pos, pcx_info.width);
- }
- }
-
- return 0;
-}
diff --git a/sys/dev/fdc/fdc.c b/sys/dev/fdc/fdc.c
deleted file mode 100644
index 5cb6e7230f6c..000000000000
--- a/sys/dev/fdc/fdc.c
+++ /dev/null
@@ -1,2390 +0,0 @@
-/*
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Don Ahn.
- *
- * Libretto PCMCIA floppy support by David Horwitt (dhorwitt@ucsd.edu)
- * aided by the Linux floppy driver modifications from David Bateman
- * (dbateman@eng.uts.edu.au).
- *
- * Copyright (c) 1993, 1994 by
- * jc@irbs.UUCP (John Capo)
- * vak@zebub.msk.su (Serge Vakulenko)
- * ache@astral.msk.su (Andrew A. Chernov)
- *
- * Copyright (c) 1993, 1994, 1995 by
- * joerg_wunsch@uriah.sax.de (Joerg Wunsch)
- * dufault@hda.com (Peter Dufault)
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)fd.c 7.4 (Berkeley) 5/25/91
- * $FreeBSD$
- *
- */
-
-#include "opt_fdc.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/buf.h>
-#include <sys/bus.h>
-#include <sys/conf.h>
-#include <sys/disklabel.h>
-#include <sys/devicestat.h>
-#include <sys/fcntl.h>
-#include <sys/malloc.h>
-#include <sys/module.h>
-#include <sys/proc.h>
-#include <sys/syslog.h>
-
-#include <sys/bus.h>
-#include <machine/bus.h>
-#include <sys/rman.h>
-
-#include <machine/clock.h>
-#include <machine/ioctl_fd.h>
-#include <machine/resource.h>
-#include <machine/stdarg.h>
-
-#include <isa/isavar.h>
-#include <isa/isareg.h>
-#include <isa/fdreg.h>
-#include <isa/fdc.h>
-#include <isa/rtc.h>
-
-/* misuse a flag to identify format operation */
-#define B_FORMAT B_XXX
-
-/* configuration flags */
-#define FDC_PRETEND_D0 (1 << 0) /* pretend drive 0 to be there */
-#define FDC_NO_FIFO (1 << 2) /* do not enable FIFO */
-
-/* internally used only, not really from CMOS: */
-#define RTCFDT_144M_PRETENDED 0x1000
-
-/* error returns for fd_cmd() */
-#define FD_FAILED -1
-#define FD_NOT_VALID -2
-#define FDC_ERRMAX 100 /* do not log more */
-
-#define NUMTYPES 17
-#define NUMDENS (NUMTYPES - 7)
-
-/* These defines (-1) must match index for fd_types */
-#define F_TAPE_TYPE 0x020 /* bit for fd_types to indicate tape */
-#define NO_TYPE 0 /* must match NO_TYPE in ft.c */
-#define FD_1720 1
-#define FD_1480 2
-#define FD_1440 3
-#define FD_1200 4
-#define FD_820 5
-#define FD_800 6
-#define FD_720 7
-#define FD_360 8
-#define FD_640 9
-#define FD_1232 10
-
-#define FD_1480in5_25 11
-#define FD_1440in5_25 12
-#define FD_820in5_25 13
-#define FD_800in5_25 14
-#define FD_720in5_25 15
-#define FD_360in5_25 16
-#define FD_640in5_25 17
-
-
-static struct fd_type fd_types[NUMTYPES] =
-{
-{ 21,2,0xFF,0x04,82,3444,1,FDC_500KBPS,2,0x0C,2 }, /* 1.72M in HD 3.5in */
-{ 18,2,0xFF,0x1B,82,2952,1,FDC_500KBPS,2,0x6C,1 }, /* 1.48M in HD 3.5in */
-{ 18,2,0xFF,0x1B,80,2880,1,FDC_500KBPS,2,0x6C,1 }, /* 1.44M in HD 3.5in */
-{ 15,2,0xFF,0x1B,80,2400,1,FDC_500KBPS,2,0x54,1 }, /* 1.2M in HD 5.25/3.5 */
-{ 10,2,0xFF,0x10,82,1640,1,FDC_250KBPS,2,0x2E,1 }, /* 820K in HD 3.5in */
-{ 10,2,0xFF,0x10,80,1600,1,FDC_250KBPS,2,0x2E,1 }, /* 800K in HD 3.5in */
-{ 9,2,0xFF,0x20,80,1440,1,FDC_250KBPS,2,0x50,1 }, /* 720K in HD 3.5in */
-{ 9,2,0xFF,0x2A,40, 720,1,FDC_250KBPS,2,0x50,1 }, /* 360K in DD 5.25in */
-{ 8,2,0xFF,0x2A,80,1280,1,FDC_250KBPS,2,0x50,1 }, /* 640K in DD 5.25in */
-{ 8,3,0xFF,0x35,77,1232,1,FDC_500KBPS,2,0x74,1 }, /* 1.23M in HD 5.25in */
-
-{ 18,2,0xFF,0x02,82,2952,1,FDC_500KBPS,2,0x02,2 }, /* 1.48M in HD 5.25in */
-{ 18,2,0xFF,0x02,80,2880,1,FDC_500KBPS,2,0x02,2 }, /* 1.44M in HD 5.25in */
-{ 10,2,0xFF,0x10,82,1640,1,FDC_300KBPS,2,0x2E,1 }, /* 820K in HD 5.25in */
-{ 10,2,0xFF,0x10,80,1600,1,FDC_300KBPS,2,0x2E,1 }, /* 800K in HD 5.25in */
-{ 9,2,0xFF,0x20,80,1440,1,FDC_300KBPS,2,0x50,1 }, /* 720K in HD 5.25in */
-{ 9,2,0xFF,0x23,40, 720,2,FDC_300KBPS,2,0x50,1 }, /* 360K in HD 5.25in */
-{ 8,2,0xFF,0x2A,80,1280,1,FDC_300KBPS,2,0x50,1 }, /* 640K in HD 5.25in */
-};
-
-#define DRVS_PER_CTLR 2 /* 2 floppies */
-
-/***********************************************************************\
-* Per controller structure. *
-\***********************************************************************/
-static devclass_t fdc_devclass;
-
-/***********************************************************************\
-* Per drive structure. *
-* N per controller (DRVS_PER_CTLR) *
-\***********************************************************************/
-struct fd_data {
- struct fdc_data *fdc; /* pointer to controller structure */
- int fdsu; /* this units number on this controller */
- int type; /* Drive type (FD_1440...) */
- struct fd_type *ft; /* pointer to the type descriptor */
- int flags;
-#define FD_OPEN 0x01 /* it's open */
-#define FD_ACTIVE 0x02 /* it's active */
-#define FD_MOTOR 0x04 /* motor should be on */
-#define FD_MOTOR_WAIT 0x08 /* motor coming up */
- int skip;
- int hddrv;
-#define FD_NO_TRACK -2
- int track; /* where we think the head is */
- int options; /* user configurable options, see ioctl_fd.h */
- struct callout_handle toffhandle;
- struct callout_handle tohandle;
- struct devstat device_stats;
- device_t dev;
- fdu_t fdu;
-};
-
-struct fdc_ivars {
- int fdunit;
-};
-static devclass_t fd_devclass;
-
-/***********************************************************************\
-* Throughout this file the following conventions will be used: *
-* fd is a pointer to the fd_data struct for the drive in question *
-* fdc is a pointer to the fdc_data struct for the controller *
-* fdu is the floppy drive unit number *
-* fdcu is the floppy controller unit number *
-* fdsu is the floppy drive unit number on that controller. (sub-unit) *
-\***********************************************************************/
-
-/* needed for ft driver, thus exported */
-int in_fdc(struct fdc_data *);
-int out_fdc(struct fdc_data *, int);
-
-/* internal functions */
-static void fdc_intr(void *);
-static void set_motor(struct fdc_data *, int, int);
-# define TURNON 1
-# define TURNOFF 0
-static timeout_t fd_turnoff;
-static timeout_t fd_motor_on;
-static void fd_turnon(struct fd_data *);
-static void fdc_reset(fdc_p);
-static int fd_in(struct fdc_data *, int *);
-static void fdstart(struct fdc_data *);
-static timeout_t fd_iotimeout;
-static timeout_t fd_pseudointr;
-static int fdstate(struct fdc_data *);
-static int retrier(struct fdc_data *);
-static int fdformat(dev_t, struct fd_formb *, struct proc *);
-
-static int enable_fifo(fdc_p fdc);
-
-static int fifo_threshold = 8; /* XXX: should be accessible via sysctl */
-
-
-#define DEVIDLE 0
-#define FINDWORK 1
-#define DOSEEK 2
-#define SEEKCOMPLETE 3
-#define IOCOMPLETE 4
-#define RECALCOMPLETE 5
-#define STARTRECAL 6
-#define RESETCTLR 7
-#define SEEKWAIT 8
-#define RECALWAIT 9
-#define MOTORWAIT 10
-#define IOTIMEDOUT 11
-#define RESETCOMPLETE 12
-#define PIOREAD 13
-
-#ifdef FDC_DEBUG
-static char const * const fdstates[] =
-{
-"DEVIDLE",
-"FINDWORK",
-"DOSEEK",
-"SEEKCOMPLETE",
-"IOCOMPLETE",
-"RECALCOMPLETE",
-"STARTRECAL",
-"RESETCTLR",
-"SEEKWAIT",
-"RECALWAIT",
-"MOTORWAIT",
-"IOTIMEDOUT",
-"RESETCOMPLETE",
-"PIOREAD",
-};
-
-/* CAUTION: fd_debug causes huge amounts of logging output */
-static int volatile fd_debug = 0;
-#define TRACE0(arg) if(fd_debug) printf(arg)
-#define TRACE1(arg1, arg2) if(fd_debug) printf(arg1, arg2)
-#else /* FDC_DEBUG */
-#define TRACE0(arg)
-#define TRACE1(arg1, arg2)
-#endif /* FDC_DEBUG */
-
-static void
-fdout_wr(fdc_p fdc, u_int8_t v)
-{
- bus_space_write_1(fdc->portt, fdc->porth, FDOUT+fdc->port_off, v);
-}
-
-static u_int8_t
-fdsts_rd(fdc_p fdc)
-{
- return bus_space_read_1(fdc->portt, fdc->porth, FDSTS+fdc->port_off);
-}
-
-static void
-fddata_wr(fdc_p fdc, u_int8_t v)
-{
- bus_space_write_1(fdc->portt, fdc->porth, FDDATA+fdc->port_off, v);
-}
-
-static u_int8_t
-fddata_rd(fdc_p fdc)
-{
- return bus_space_read_1(fdc->portt, fdc->porth, FDDATA+fdc->port_off);
-}
-
-static void
-fdctl_wr(fdc_p fdc, u_int8_t v)
-{
- bus_space_write_1(fdc->ctlt, fdc->ctlh, 0, v);
-}
-
-#if 0
-
-static u_int8_t
-fdin_rd(fdc_p fdc)
-{
- return bus_space_read_1(fdc->portt, fdc->porth, FDIN);
-}
-
-#endif
-
-#ifdef FDC_YE
-#if NCARD > 0
-#include <sys/select.h>
-#include <sys/module.h>
-#include <pccard/cardinfo.h>
-#include <pccard/driver.h>
-#include <pccard/slot.h>
-
-/*
- * PC-Card (PCMCIA) specific code.
- */
-static int yeinit(struct pccard_devinfo *); /* init device */
-static void yeunload(struct pccard_devinfo *); /* Disable driver */
-static int yeintr(struct pccard_devinfo *); /* Interrupt handler */
-
-PCCARD_MODULE(fdc, yeinit, yeunload, yeintr, 0, bio_imask);
-
-/*
- * Initialize the device - called from Slot manager.
- */
-static int yeinit(struct pccard_devinfo *devi)
-{
- fdc_p fdc = &fdc_data[devi->isahd.id_unit];
-
- fdc->baseport = devi->isahd.id_iobase;
- /*
- * reset controller
- */
- fdout_wr(fdc, 0);
- DELAY(100);
- fdout_wr(fdc, FDO_FRST);
-
- /*
- * wire into system
- */
- if (yeattach(&devi->isahd) == 0)
- return(ENXIO);
-
- return(0);
-}
-
-/*
- * yeunload - unload the driver and clear the table.
- * XXX TODO:
- * This is usually called when the card is ejected, but
- * can be caused by a modunload of a controller driver.
- * The idea is to reset the driver's view of the device
- * and ensure that any driver entry points such as
- * read and write do not hang.
- */
-static void yeunload(struct pccard_devinfo *devi)
-{
- if (fd_data[devi->isahd.id_unit].type == NO_TYPE)
- return;
-
- /*
- * this prevents Fdopen() and fdstrategy() from attempting
- * to access unloaded controller
- */
- fd_data[devi->isahd.id_unit].type = NO_TYPE;
-
- printf("fdc%d: unload\n", devi->isahd.id_unit);
-}
-
-/*
- * yeintr - Shared interrupt called from
- * front end of PC-Card handler.
- */
-static int yeintr(struct pccard_devinfo *devi)
-{
- fdintr((fdcu_t)devi->isahd.id_unit);
- return(1);
-}
-#endif /* NCARD > 0 */
-#endif /* FDC_YE */
-
-static d_open_t Fdopen; /* NOTE, not fdopen */
-static d_close_t fdclose;
-static d_ioctl_t fdioctl;
-static d_strategy_t fdstrategy;
-
-#define CDEV_MAJOR 9
-#define BDEV_MAJOR 2
-
-static struct cdevsw fd_cdevsw = {
- /* open */ Fdopen,
- /* close */ fdclose,
- /* read */ physread,
- /* write */ physwrite,
- /* ioctl */ fdioctl,
- /* poll */ nopoll,
- /* mmap */ nommap,
- /* strategy */ fdstrategy,
- /* name */ "fd",
- /* maj */ CDEV_MAJOR,
- /* dump */ nodump,
- /* psize */ nopsize,
- /* flags */ D_DISK,
- /* bmaj */ BDEV_MAJOR
-};
-
-static int
-fdc_err(struct fdc_data *fdc, const char *s)
-{
- fdc->fdc_errs++;
- if (s) {
- if (fdc->fdc_errs < FDC_ERRMAX)
- device_printf(fdc->fdc_dev, "%s", s);
- else if (fdc->fdc_errs == FDC_ERRMAX)
- device_printf(fdc->fdc_dev, "too many errors, not "
- "logging any more\n");
- }
-
- return FD_FAILED;
-}
-
-/*
- * fd_cmd: Send a command to the chip. Takes a varargs with this structure:
- * Unit number,
- * # of output bytes, output bytes as ints ...,
- * # of input bytes, input bytes as ints ...
- */
-static int
-fd_cmd(struct fdc_data *fdc, int n_out, ...)
-{
- u_char cmd;
- int n_in;
- int n;
- va_list ap;
-
- va_start(ap, n_out);
- cmd = (u_char)(va_arg(ap, int));
- va_end(ap);
- va_start(ap, n_out);
- for (n = 0; n < n_out; n++)
- {
- if (out_fdc(fdc, va_arg(ap, int)) < 0)
- {
- char msg[50];
- snprintf(msg, sizeof(msg),
- "cmd %x failed at out byte %d of %d\n",
- cmd, n + 1, n_out);
- return fdc_err(fdc, msg);
- }
- }
- n_in = va_arg(ap, int);
- for (n = 0; n < n_in; n++)
- {
- int *ptr = va_arg(ap, int *);
- if (fd_in(fdc, ptr) < 0)
- {
- char msg[50];
- snprintf(msg, sizeof(msg),
- "cmd %02x failed at in byte %d of %d\n",
- cmd, n + 1, n_in);
- return fdc_err(fdc, msg);
- }
- }
-
- return 0;
-}
-
-static int
-enable_fifo(fdc_p fdc)
-{
- int i, j;
-
- if ((fdc->flags & FDC_HAS_FIFO) == 0) {
-
- /*
- * XXX:
- * Cannot use fd_cmd the normal way here, since
- * this might be an invalid command. Thus we send the
- * first byte, and check for an early turn of data directon.
- */
-
- if (out_fdc(fdc, I8207X_CONFIGURE) < 0)
- return fdc_err(fdc, "Enable FIFO failed\n");
-
- /* If command is invalid, return */
- j = 100000;
- while ((i = fdsts_rd(fdc) & (NE7_DIO | NE7_RQM))
- != NE7_RQM && j-- > 0)
- if (i == (NE7_DIO | NE7_RQM)) {
- fdc_reset(fdc);
- return FD_FAILED;
- }
- if (j<0 ||
- fd_cmd(fdc, 3,
- 0, (fifo_threshold - 1) & 0xf, 0, 0) < 0) {
- fdc_reset(fdc);
- return fdc_err(fdc, "Enable FIFO failed\n");
- }
- fdc->flags |= FDC_HAS_FIFO;
- return 0;
- }
- if (fd_cmd(fdc, 4,
- I8207X_CONFIGURE, 0, (fifo_threshold - 1) & 0xf, 0, 0) < 0)
- return fdc_err(fdc, "Re-enable FIFO failed\n");
- return 0;
-}
-
-static int
-fd_sense_drive_status(fdc_p fdc, int *st3p)
-{
- int st3;
-
- if (fd_cmd(fdc, 2, NE7CMD_SENSED, fdc->fdu, 1, &st3))
- {
- return fdc_err(fdc, "Sense Drive Status failed\n");
- }
- if (st3p)
- *st3p = st3;
-
- return 0;
-}
-
-static int
-fd_sense_int(fdc_p fdc, int *st0p, int *cylp)
-{
- int cyl, st0, ret;
-
- ret = fd_cmd(fdc, 1, NE7CMD_SENSEI, 1, &st0);
- if (ret) {
- (void)fdc_err(fdc,
- "sense intr err reading stat reg 0\n");
- return ret;
- }
-
- if (st0p)
- *st0p = st0;
-
- if ((st0 & NE7_ST0_IC) == NE7_ST0_IC_IV) {
- /*
- * There doesn't seem to have been an interrupt.
- */
- return FD_NOT_VALID;
- }
-
- if (fd_in(fdc, &cyl) < 0) {
- return fdc_err(fdc, "can't get cyl num\n");
- }
-
- if (cylp)
- *cylp = cyl;
-
- return 0;
-}
-
-
-static int
-fd_read_status(fdc_p fdc, int fdsu)
-{
- int i, ret;
-
- for (i = 0; i < 7; i++) {
- /*
- * XXX types are poorly chosen. Only bytes can by read
- * from the hardware, but fdc->status[] wants u_ints and
- * fd_in() gives ints.
- */
- int status;
-
- ret = fd_in(fdc, &status);
- fdc->status[i] = status;
- if (ret != 0)
- break;
- }
-
- if (ret == 0)
- fdc->flags |= FDC_STAT_VALID;
- else
- fdc->flags &= ~FDC_STAT_VALID;
-
- return ret;
-}
-
-/****************************************************************************/
-/* autoconfiguration stuff */
-/****************************************************************************/
-
-static int
-fdc_alloc_resources(struct fdc_data *fdc)
-{
- device_t dev;
- int ispnp;
-
- dev = fdc->fdc_dev;
- ispnp = fdc->fdc_ispnp;
- fdc->rid_ioport = fdc->rid_irq = fdc->rid_drq = 0;
- fdc->res_ioport = fdc->res_irq = fdc->res_drq = 0;
-
- /*
- * We don't just use an 8 port range (e.g. 0x3f0-0x3f7) since that
- * covers an IDE control register at 0x3f6.
- * Isn't PC hardware wonderful.
- */
- fdc->res_ioport = bus_alloc_resource(dev, SYS_RES_IOPORT,
- &fdc->rid_ioport, 0ul, ~0ul,
- ispnp ? 1 : 6, RF_ACTIVE);
- if (fdc->res_ioport == 0) {
- device_printf(dev, "cannot reserve I/O port range\n");
- return ENXIO;
- }
- fdc->portt = rman_get_bustag(fdc->res_ioport);
- fdc->porth = rman_get_bushandle(fdc->res_ioport);
-
- /*
- * Some BIOSen report the device at 0x3f2-0x3f5,0x3f7 and some at
- * 0x3f0-0x3f5,0x3f7. We detect the former by checking the size
- * and adjust the port address accordingly.
- */
- if (bus_get_resource_count(dev, SYS_RES_IOPORT, 0) == 4)
- fdc->port_off = -2;
-
- /*
- * Register the control port range as rid 1 if it isn't there
- * already. Most PnP BIOSen will have already done this but
- * non-PnP configurations don't.
- *
- * And some (!!) report 0x3f2-0x3f5 and completely leave out the
- * control register! It seems that some non-antique controller chips
- * have a different method of programming the transfer speed which
- * doesn't require the control register, but it's mighty bogus as the
- * chip still responds to the address for the control register.
- */
- if (bus_get_resource_count(dev, SYS_RES_IOPORT, 1) == 0) {
- u_long ctlstart;
-
- /* Find the control port, usually 0x3f7 */
- ctlstart = rman_get_start(fdc->res_ioport) + fdc->port_off + 7;
-
- bus_set_resource(dev, SYS_RES_IOPORT, 1, ctlstart, 1);
- }
-
- /*
- * Now (finally!) allocate the control port.
- */
- fdc->rid_ctl = 1;
- fdc->res_ctl = bus_alloc_resource(dev, SYS_RES_IOPORT, &fdc->rid_ctl,
- 0ul, ~0ul, 1, RF_ACTIVE);
- if (fdc->res_ctl == 0) {
- device_printf(dev, "cannot reserve control I/O port range\n");
- return ENXIO;
- }
- fdc->ctlt = rman_get_bustag(fdc->res_ctl);
- fdc->ctlh = rman_get_bushandle(fdc->res_ctl);
-
- fdc->res_irq = bus_alloc_resource(dev, SYS_RES_IRQ,
- &fdc->rid_irq, 0ul, ~0ul, 1,
- RF_ACTIVE);
- if (fdc->res_irq == 0) {
- device_printf(dev, "cannot reserve interrupt line\n");
- return ENXIO;
- }
- fdc->res_drq = bus_alloc_resource(dev, SYS_RES_DRQ,
- &fdc->rid_drq, 0ul, ~0ul, 1,
- RF_ACTIVE);
- if (fdc->res_drq == 0) {
- device_printf(dev, "cannot reserve DMA request line\n");
- return ENXIO;
- }
- fdc->dmachan = fdc->res_drq->r_start;
-
- return 0;
-}
-
-static void
-fdc_release_resources(struct fdc_data *fdc)
-{
- device_t dev;
-
- dev = fdc->fdc_dev;
- if (fdc->res_irq != 0) {
- bus_deactivate_resource(dev, SYS_RES_IRQ, fdc->rid_irq,
- fdc->res_irq);
- bus_release_resource(dev, SYS_RES_IRQ, fdc->rid_irq,
- fdc->res_irq);
- }
- if (fdc->res_ctl != 0) {
- bus_deactivate_resource(dev, SYS_RES_IOPORT, fdc->rid_ctl,
- fdc->res_ctl);
- bus_release_resource(dev, SYS_RES_IOPORT, fdc->rid_ctl,
- fdc->res_ctl);
- }
- if (fdc->res_ioport != 0) {
- bus_deactivate_resource(dev, SYS_RES_IOPORT, fdc->rid_ioport,
- fdc->res_ioport);
- bus_release_resource(dev, SYS_RES_IOPORT, fdc->rid_ioport,
- fdc->res_ioport);
- }
- if (fdc->res_drq != 0) {
- bus_deactivate_resource(dev, SYS_RES_DRQ, fdc->rid_drq,
- fdc->res_drq);
- bus_release_resource(dev, SYS_RES_DRQ, fdc->rid_drq,
- fdc->res_drq);
- }
-}
-
-/****************************************************************************/
-/* autoconfiguration stuff */
-/****************************************************************************/
-
-static struct isa_pnp_id fdc_ids[] = {
- {0x0007d041, "PC standard floppy disk controller"}, /* PNP0700 */
- {0x0107d041, "Standard floppy controller supporting MS Device Bay Spec"}, /* PNP0701 */
- {0}
-};
-
-static int
-fdc_read_ivar(device_t dev, device_t child, int which, u_long *result)
-{
- struct fdc_ivars *ivars = device_get_ivars(child);
-
- switch (which) {
- case FDC_IVAR_FDUNIT:
- *result = ivars->fdunit;
- break;
- default:
- return ENOENT;
- }
- return 0;
-}
-
-/*
- * fdc controller section.
- */
-static int
-fdc_probe(device_t dev)
-{
- int error, ic_type;
- struct fdc_data *fdc;
-
- fdc = device_get_softc(dev);
- bzero(fdc, sizeof *fdc);
- fdc->fdc_dev = dev;
-
- /* Check pnp ids */
- error = ISA_PNP_PROBE(device_get_parent(dev), dev, fdc_ids);
- if (error == ENXIO)
- return ENXIO;
- fdc->fdc_ispnp = (error == 0);
-
- /* Attempt to allocate our resources for the duration of the probe */
- error = fdc_alloc_resources(fdc);
- if (error)
- goto out;
-
- /* First - lets reset the floppy controller */
- fdout_wr(fdc, 0);
- DELAY(100);
- fdout_wr(fdc, FDO_FRST);
-
- /* see if it can handle a command */
- if (fd_cmd(fdc, 3, NE7CMD_SPECIFY, NE7_SPEC_1(3, 240),
- NE7_SPEC_2(2, 0), 0)) {
- error = ENXIO;
- goto out;
- }
-
- if (fd_cmd(fdc, 1, NE7CMD_VERSION, 1, &ic_type) == 0) {
- ic_type = (u_char)ic_type;
- switch (ic_type) {
- case 0x80:
- device_set_desc(dev, "NEC 765 or clone");
- fdc->fdct = FDC_NE765;
- break;
- case 0x81:
- device_set_desc(dev, "Intel 82077 or clone");
- fdc->fdct = FDC_I82077;
- break;
- case 0x90:
- device_set_desc(dev, "NEC 72065B or clone");
- fdc->fdct = FDC_NE72065;
- break;
- default:
- device_set_desc(dev, "generic floppy controller");
- fdc->fdct = FDC_UNKNOWN;
- break;
- }
- }
-
-out:
- fdc_release_resources(fdc);
- return (error);
-}
-
-/*
- * Add a child device to the fdc controller. It will then be probed etc.
- */
-static void
-fdc_add_child(device_t dev, const char *name, int unit)
-{
- int disabled;
- struct fdc_ivars *ivar;
- device_t child;
-
- ivar = malloc(sizeof *ivar, M_DEVBUF /* XXX */, M_NOWAIT);
- if (ivar == NULL)
- return;
- bzero(ivar, sizeof *ivar);
- if (resource_int_value(name, unit, "drive", &ivar->fdunit) != 0)
- ivar->fdunit = 0;
- child = device_add_child(dev, name, unit);
- if (child == NULL)
- return;
- device_set_ivars(child, ivar);
- if (resource_int_value(name, unit, "disabled", &disabled) == 0
- && disabled != 0)
- device_disable(child);
-}
-
-static int
-fdc_attach(device_t dev)
-{
- struct fdc_data *fdc;
- int i, error;
-
- fdc = device_get_softc(dev);
- error = fdc_alloc_resources(fdc);
- if (error) {
- device_printf(dev, "cannot re-aquire resources\n");
- return error;
- }
- error = BUS_SETUP_INTR(device_get_parent(dev), dev, fdc->res_irq,
- INTR_TYPE_BIO, fdc_intr, fdc, &fdc->fdc_intr);
- if (error) {
- device_printf(dev, "cannot setup interrupt\n");
- return error;
- }
- fdc->fdcu = device_get_unit(dev);
- fdc->flags |= FDC_ATTACHED;
-
- /* Acquire the DMA channel forever, The driver will do the rest */
- /* XXX should integrate with rman */
- isa_dma_acquire(fdc->dmachan);
- isa_dmainit(fdc->dmachan, 128 << 3 /* XXX max secsize */);
- fdc->state = DEVIDLE;
-
- /* reset controller, turn motor off, clear fdout mirror reg */
- fdout_wr(fdc, ((fdc->fdout = 0)));
- bufq_init(&fdc->head);
-
- /*
- * Probe and attach any children. We should probably detect
- * devices from the BIOS unless overridden.
- */
- for (i = resource_query_string(-1, "at", device_get_nameunit(dev));
- i != -1;
- i = resource_query_string(i, "at", device_get_nameunit(dev)))
- fdc_add_child(dev, resource_query_name(i),
- resource_query_unit(i));
-
- return (bus_generic_attach(dev));
-}
-
-static int
-fdc_print_child(device_t me, device_t child)
-{
- int retval = 0;
-
- retval += bus_print_child_header(me, child);
- retval += printf(" on %s drive %d\n", device_get_nameunit(me),
- fdc_get_fdunit(child));
-
- return (retval);
-}
-
-static device_method_t fdc_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, fdc_probe),
- DEVMETHOD(device_attach, fdc_attach),
- DEVMETHOD(device_detach, bus_generic_detach),
- DEVMETHOD(device_shutdown, bus_generic_shutdown),
- DEVMETHOD(device_suspend, bus_generic_suspend),
- DEVMETHOD(device_resume, bus_generic_resume),
-
- /* Bus interface */
- DEVMETHOD(bus_print_child, fdc_print_child),
- DEVMETHOD(bus_read_ivar, fdc_read_ivar),
- /* Our children never use any other bus interface methods. */
-
- { 0, 0 }
-};
-
-static driver_t fdc_driver = {
- "fdc",
- fdc_methods,
- sizeof(struct fdc_data)
-};
-
-DRIVER_MODULE(fdc, isa, fdc_driver, fdc_devclass, 0, 0);
-
-/******************************************************************/
-/*
- * devices attached to the controller section.
- */
-static int
-fd_probe(device_t dev)
-{
- int i;
- u_int fdt, st0, st3;
- struct fd_data *fd;
- struct fdc_data *fdc;
- fdsu_t fdsu;
- static int fd_fifo = 0;
-
- fdsu = *(int *)device_get_ivars(dev); /* xxx cheat a bit... */
- fd = device_get_softc(dev);
- fdc = device_get_softc(device_get_parent(dev));
-
- bzero(fd, sizeof *fd);
- fd->dev = dev;
- fd->fdc = fdc;
- fd->fdsu = fdsu;
- fd->fdu = device_get_unit(dev);
-
-#ifdef __i386__
- /* look up what bios thinks we have */
- switch (fd->fdu) {
- case 0:
- if (device_get_flags(fdc->fdc_dev) & FDC_PRETEND_D0)
- fdt = RTCFDT_144M | RTCFDT_144M_PRETENDED;
- else
- fdt = (rtcin(RTC_FDISKETTE) & 0xf0);
- break;
- case 1:
- fdt = ((rtcin(RTC_FDISKETTE) << 4) & 0xf0);
- break;
- default:
- fdt = RTCFDT_NONE;
- break;
- }
-#else
- fdt = RTCFDT_144M; /* XXX probably */
-#endif
-
- /* is there a unit? */
- if (fdt == RTCFDT_NONE)
- return (ENXIO);
-
- /* select it */
- set_motor(fdc, fdsu, TURNON);
- DELAY(1000000); /* 1 sec */
-
- /* XXX This doesn't work before the first set_motor() */
- if (fd_fifo == 0 && fdc->fdct != FDC_NE765 && fdc->fdct != FDC_UNKNOWN
- && (device_get_flags(fdc->fdc_dev) & FDC_NO_FIFO) == 0
- && enable_fifo(fdc) == 0) {
- device_printf(device_get_parent(dev),
- "FIFO enabled, %d bytes threshold\n", fifo_threshold);
- }
- fd_fifo = 1;
-
- if ((fd_cmd(fdc, 2, NE7CMD_SENSED, fdsu, 1, &st3) == 0)
- && (st3 & NE7_ST3_T0)) {
- /* if at track 0, first seek inwards */
- /* seek some steps: */
- fd_cmd(fdc, 3, NE7CMD_SEEK, fdsu, 10, 0);
- DELAY(300000); /* ...wait a moment... */
- fd_sense_int(fdc, 0, 0); /* make ctrlr happy */
- }
-
- /* If we're at track 0 first seek inwards. */
- if ((fd_sense_drive_status(fdc, &st3) == 0) && (st3 & NE7_ST3_T0)) {
- /* Seek some steps... */
- if (fd_cmd(fdc, 3, NE7CMD_SEEK, fdsu, 10, 0) == 0) {
- /* ...wait a moment... */
- DELAY(300000);
- /* make ctrlr happy: */
- fd_sense_int(fdc, 0, 0);
- }
- }
-
- for (i = 0; i < 2; i++) {
- /*
- * we must recalibrate twice, just in case the
- * heads have been beyond cylinder 76, since most
- * FDCs still barf when attempting to recalibrate
- * more than 77 steps
- */
- /* go back to 0: */
- if (fd_cmd(fdc, 2, NE7CMD_RECAL, fdsu, 0) == 0) {
- /* a second being enough for full stroke seek*/
- DELAY(i == 0 ? 1000000 : 300000);
-
- /* anything responding? */
- if (fd_sense_int(fdc, &st0, 0) == 0 &&
- (st0 & NE7_ST0_EC) == 0)
- break; /* already probed succesfully */
- }
- }
-
- set_motor(fdc, fdsu, TURNOFF);
-
- if (st0 & NE7_ST0_EC) /* no track 0 -> no drive present */
- return (ENXIO);
-
- fd->track = FD_NO_TRACK;
- fd->fdc = fdc;
- fd->fdsu = fdsu;
- fd->options = 0;
- callout_handle_init(&fd->toffhandle);
- callout_handle_init(&fd->tohandle);
-
- switch (fdt) {
- case RTCFDT_12M:
- device_set_desc(dev, "1200-KB 5.25\" drive");
- fd->type = FD_1200;
- break;
- case RTCFDT_144M | RTCFDT_144M_PRETENDED:
- device_set_desc(dev, "config-pretended 1440-MB 3.5\" drive");
- fdt = RTCFDT_144M;
- fd->type = FD_1440;
- case RTCFDT_144M:
- device_set_desc(dev, "1440-KB 3.5\" drive");
- fd->type = FD_1440;
- break;
- case RTCFDT_288M:
- case RTCFDT_288M_1:
- device_set_desc(dev, "2880-KB 3.5\" drive (in 1440-KB mode)");
- fd->type = FD_1440;
- break;
- case RTCFDT_360K:
- device_set_desc(dev, "360-KB 5.25\" drive");
- fd->type = FD_360;
- break;
- case RTCFDT_720K:
- printf("720-KB 3.5\" drive");
- fd->type = FD_720;
- break;
- default:
- return (ENXIO);
- }
- return (0);
-}
-
-static int
-fd_attach(device_t dev)
-{
- struct fd_data *fd;
-#if 0
- int i;
- int mynor;
- int typemynor;
- int typesize;
-#endif
-
- fd = device_get_softc(dev);
-
- cdevsw_add(&fd_cdevsw); /* XXX */
- make_dev(&fd_cdevsw, (fd->fdu << 6),
- UID_ROOT, GID_OPERATOR, 0640, "rfd%d", fd->fdu);
-
-#if 0
- /* Other make_dev() go here. */
-#endif
-
- /*
- * Export the drive to the devstat interface.
- */
- devstat_add_entry(&fd->device_stats, device_get_name(dev),
- device_get_unit(dev), 512, DEVSTAT_NO_ORDERED_TAGS,
- DEVSTAT_TYPE_FLOPPY | DEVSTAT_TYPE_IF_OTHER,
- DEVSTAT_PRIORITY_FD);
- return (0);
-}
-
-static device_method_t fd_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, fd_probe),
- DEVMETHOD(device_attach, fd_attach),
- DEVMETHOD(device_detach, bus_generic_detach),
- DEVMETHOD(device_shutdown, bus_generic_shutdown),
- DEVMETHOD(device_suspend, bus_generic_suspend), /* XXX */
- DEVMETHOD(device_resume, bus_generic_resume), /* XXX */
-
- { 0, 0 }
-};
-
-static driver_t fd_driver = {
- "fd",
- fd_methods,
- sizeof(struct fd_data)
-};
-
-DRIVER_MODULE(fd, fdc, fd_driver, fd_devclass, 0, 0);
-
-/******************************************************************/
-
-#ifdef FDC_YE
-/*
- * this is a subset of fdattach() optimized for the Y-E Data
- * PCMCIA floppy drive.
- */
-static int yeattach(struct isa_device *dev)
-{
- fdcu_t fdcu = dev->id_unit;
- fdc_p fdc = fdc_data + fdcu;
- fdsu_t fdsu = 0; /* assume 1 drive per YE controller */
- fdu_t fdu;
- fd_p fd;
- int st0, st3, i;
- fdc->fdcu = fdcu;
- /*
- * the FDC_NODMA flag is used to to indicate special PIO is used
- * instead of DMA
- */
- fdc->flags = FDC_ATTACHED|FDC_NODMA;
- fdc->state = DEVIDLE;
- /* reset controller, turn motor off, clear fdout mirror reg */
- fdout_wr(fdc, ((fdc->fdout = 0)));
- bufq_init(&fdc->head);
- /*
- * assume 2 drives/ "normal" controller
- */
- fdu = fdcu * 2;
- if (fdu >= NFD) {
- printf("fdu %d >= NFD\n",fdu);
- return(0);
- };
- fd = &fd_data[fdu];
-
- set_motor(fdcu, fdsu, TURNON);
- DELAY(1000000); /* 1 sec */
- fdc->fdct = FDC_NE765;
-
- if ((fd_cmd(fdcu, 2, NE7CMD_SENSED, fdsu, 1, &st3) == 0) &&
- (st3 & NE7_ST3_T0)) {
- /* if at track 0, first seek inwards */
- /* seek some steps: */
- (void)fd_cmd(fdcu, 3, NE7CMD_SEEK, fdsu, 10, 0);
- DELAY(300000); /* ...wait a moment... */
- (void)fd_sense_int(fdc, 0, 0); /* make ctrlr happy */
- }
-
- /* If we're at track 0 first seek inwards. */
- if ((fd_sense_drive_status(fdc, &st3) == 0) && (st3 & NE7_ST3_T0)) {
- /* Seek some steps... */
- if (fd_cmd(fdcu, 3, NE7CMD_SEEK, fdsu, 10, 0) == 0) {
- /* ...wait a moment... */
- DELAY(300000);
- /* make ctrlr happy: */
- (void)fd_sense_int(fdc, 0, 0);
- }
- }
-
- for(i = 0; i < 2; i++) {
- /*
- * we must recalibrate twice, just in case the
- * heads have been beyond cylinder 76, since most
- * FDCs still barf when attempting to recalibrate
- * more than 77 steps
- */
- /* go back to 0: */
- if (fd_cmd(fdcu, 2, NE7CMD_RECAL, fdsu, 0) == 0) {
- /* a second being enough for full stroke seek*/
- DELAY(i == 0? 1000000: 300000);
-
- /* anything responding? */
- if (fd_sense_int(fdc, &st0, 0) == 0 &&
- (st0 & NE7_ST0_EC) == 0)
- break; /* already probed succesfully */
- }
- }
-
- set_motor(fdcu, fdsu, TURNOFF);
-
- if (st0 & NE7_ST0_EC) /* no track 0 -> no drive present */
- return(0);
-
- fd->track = FD_NO_TRACK;
- fd->fdc = fdc;
- fd->fdsu = fdsu;
- fd->options = 0;
- printf("fdc%d: 1.44MB 3.5in PCMCIA\n", fdcu);
- fd->type = FD_1440;
-
- return (1);
-}
-#endif
-
-/****************************************************************************/
-/* motor control stuff */
-/* remember to not deselect the drive we're working on */
-/****************************************************************************/
-static void
-set_motor(struct fdc_data *fdc, int fdsu, int turnon)
-{
- int fdout = fdc->fdout;
- int needspecify = 0;
-
- if(turnon) {
- fdout &= ~FDO_FDSEL;
- fdout |= (FDO_MOEN0 << fdsu) + fdsu;
- } else
- fdout &= ~(FDO_MOEN0 << fdsu);
-
- if(!turnon
- && (fdout & (FDO_MOEN0+FDO_MOEN1+FDO_MOEN2+FDO_MOEN3)) == 0)
- /* gonna turn off the last drive, put FDC to bed */
- fdout &= ~ (FDO_FRST|FDO_FDMAEN);
- else {
- /* make sure controller is selected and specified */
- if((fdout & (FDO_FRST|FDO_FDMAEN)) == 0)
- needspecify = 1;
- fdout |= (FDO_FRST|FDO_FDMAEN);
- }
-
- fdout_wr(fdc, fdout);
- fdc->fdout = fdout;
- TRACE1("[0x%x->FDOUT]", fdout);
-
- if (needspecify) {
- /*
- * XXX
- * special case: since we have just woken up the FDC
- * from its sleep, we silently assume the command will
- * be accepted, and do not test for a timeout
- */
- (void)fd_cmd(fdc, 3, NE7CMD_SPECIFY,
- NE7_SPEC_1(3, 240), NE7_SPEC_2(2, 0),
- 0);
- if (fdc->flags & FDC_HAS_FIFO)
- (void) enable_fifo(fdc);
- }
-}
-
-static void
-fd_turnoff(void *xfd)
-{
- int s;
- fd_p fd = xfd;
-
- TRACE1("[fd%d: turnoff]", fd->fdu);
-
- /*
- * Don't turn off the motor yet if the drive is active.
- * XXX shouldn't even schedule turnoff until drive is inactive
- * and nothing is queued on it.
- */
- if (fd->fdc->state != DEVIDLE && fd->fdc->fdu == fd->fdu) {
- fd->toffhandle = timeout(fd_turnoff, fd, 4 * hz);
- return;
- }
-
- s = splbio();
- fd->flags &= ~FD_MOTOR;
- set_motor(fd->fdc, fd->fdsu, TURNOFF);
- splx(s);
-}
-
-static void
-fd_motor_on(void *xfd)
-{
- int s;
- fd_p fd = xfd;
-
- s = splbio();
- fd->flags &= ~FD_MOTOR_WAIT;
- if((fd->fdc->fd == fd) && (fd->fdc->state == MOTORWAIT))
- {
- fdc_intr(fd->fdc);
- }
- splx(s);
-}
-
-static void
-fd_turnon(fd_p fd)
-{
- if(!(fd->flags & FD_MOTOR))
- {
- fd->flags |= (FD_MOTOR + FD_MOTOR_WAIT);
- set_motor(fd->fdc, fd->fdsu, TURNON);
- timeout(fd_motor_on, fd, hz); /* in 1 sec its ok */
- }
-}
-
-static void
-fdc_reset(fdc_p fdc)
-{
- /* Try a reset, keep motor on */
- fdout_wr(fdc, fdc->fdout & ~(FDO_FRST|FDO_FDMAEN));
- TRACE1("[0x%x->FDOUT]", fdc->fdout & ~(FDO_FRST|FDO_FDMAEN));
- DELAY(100);
- /* enable FDC, but defer interrupts a moment */
- fdout_wr(fdc, fdc->fdout & ~FDO_FDMAEN);
- TRACE1("[0x%x->FDOUT]", fdc->fdout & ~FDO_FDMAEN);
- DELAY(100);
- fdout_wr(fdc, fdc->fdout);
- TRACE1("[0x%x->FDOUT]", fdc->fdout);
-
- /* XXX after a reset, silently believe the FDC will accept commands */
- (void)fd_cmd(fdc, 3, NE7CMD_SPECIFY,
- NE7_SPEC_1(3, 240), NE7_SPEC_2(2, 0),
- 0);
- if (fdc->flags & FDC_HAS_FIFO)
- (void) enable_fifo(fdc);
-}
-
-/****************************************************************************/
-/* fdc in/out */
-/****************************************************************************/
-int
-in_fdc(struct fdc_data *fdc)
-{
- int i, j = 100000;
- while ((i = fdsts_rd(fdc) & (NE7_DIO|NE7_RQM))
- != (NE7_DIO|NE7_RQM) && j-- > 0)
- if (i == NE7_RQM)
- return fdc_err(fdc, "ready for output in input\n");
- if (j <= 0)
- return fdc_err(fdc, bootverbose? "input ready timeout\n": 0);
-#ifdef FDC_DEBUG
- i = fddata_rd(fdc);
- TRACE1("[FDDATA->0x%x]", (unsigned char)i);
- return(i);
-#else /* !FDC_DEBUG */
- return fddata_rd(fdc);
-#endif /* FDC_DEBUG */
-}
-
-/*
- * fd_in: Like in_fdc, but allows you to see if it worked.
- */
-static int
-fd_in(struct fdc_data *fdc, int *ptr)
-{
- int i, j = 100000;
- while ((i = fdsts_rd(fdc) & (NE7_DIO|NE7_RQM))
- != (NE7_DIO|NE7_RQM) && j-- > 0)
- if (i == NE7_RQM)
- return fdc_err(fdc, "ready for output in input\n");
- if (j <= 0)
- return fdc_err(fdc, bootverbose? "input ready timeout\n": 0);
-#ifdef FDC_DEBUG
- i = fddata_rd(fdc);
- TRACE1("[FDDATA->0x%x]", (unsigned char)i);
- *ptr = i;
- return 0;
-#else /* !FDC_DEBUG */
- i = fddata_rd(fdc);
- if (ptr)
- *ptr = i;
- return 0;
-#endif /* FDC_DEBUG */
-}
-
-int
-out_fdc(struct fdc_data *fdc, int x)
-{
- int i;
-
- /* Check that the direction bit is set */
- i = 100000;
- while ((fdsts_rd(fdc) & NE7_DIO) && i-- > 0);
- if (i <= 0) return fdc_err(fdc, "direction bit not set\n");
-
- /* Check that the floppy controller is ready for a command */
- i = 100000;
- while ((fdsts_rd(fdc) & NE7_RQM) == 0 && i-- > 0);
- if (i <= 0)
- return fdc_err(fdc, bootverbose? "output ready timeout\n": 0);
-
- /* Send the command and return */
- fddata_wr(fdc, x);
- TRACE1("[0x%x->FDDATA]", x);
- return (0);
-}
-
-/****************************************************************************/
-/* fdopen/fdclose */
-/****************************************************************************/
-int
-Fdopen(dev_t dev, int flags, int mode, struct proc *p)
-{
- fdu_t fdu = FDUNIT(minor(dev));
- int type = FDTYPE(minor(dev));
- fd_p fd;
- fdc_p fdc;
-
- /* check bounds */
- if ((fd = devclass_get_softc(fd_devclass, fdu)) == 0)
- return (ENXIO);
- fdc = fd->fdc;
- if ((fdc == NULL) || (fd->type == NO_TYPE))
- return (ENXIO);
- if (type > NUMDENS)
- return (ENXIO);
- if (type == 0)
- type = fd->type;
- else {
- /*
- * For each type of basic drive, make sure we are trying
- * to open a type it can do,
- */
- if (type != fd->type) {
- switch (fd->type) {
- case FD_360:
- return (ENXIO);
- case FD_720:
- if ( type != FD_820
- && type != FD_800
- && type != FD_640
- )
- return (ENXIO);
- break;
- case FD_1200:
- switch (type) {
- case FD_1480:
- type = FD_1480in5_25;
- break;
- case FD_1440:
- type = FD_1440in5_25;
- break;
- case FD_1232:
- break;
- case FD_820:
- type = FD_820in5_25;
- break;
- case FD_800:
- type = FD_800in5_25;
- break;
- case FD_720:
- type = FD_720in5_25;
- break;
- case FD_640:
- type = FD_640in5_25;
- break;
- case FD_360:
- type = FD_360in5_25;
- break;
- default:
- return(ENXIO);
- }
- break;
- case FD_1440:
- if ( type != FD_1720
- && type != FD_1480
- && type != FD_1200
- && type != FD_820
- && type != FD_800
- && type != FD_720
- && type != FD_640
- )
- return(ENXIO);
- break;
- }
- }
- }
- fd->ft = fd_types + type - 1;
- fd->flags |= FD_OPEN;
- device_busy(fd->dev);
- device_busy(fd->fdc->fdc_dev);
- return 0;
-}
-
-int
-fdclose(dev_t dev, int flags, int mode, struct proc *p)
-{
- fdu_t fdu = FDUNIT(minor(dev));
- struct fd_data *fd;
-
- fd = devclass_get_softc(fd_devclass, fdu);
- fd->flags &= ~FD_OPEN;
- fd->options &= ~FDOPT_NORETRY;
-
- return (0);
-}
-
-/****************************************************************************/
-/* fdstrategy */
-/****************************************************************************/
-void
-fdstrategy(struct buf *bp)
-{
- unsigned nblocks, blknum, cando;
- int s;
- fdu_t fdu;
- fdc_p fdc;
- fd_p fd;
- size_t fdblk;
-
- fdu = FDUNIT(minor(bp->b_dev));
- fd = devclass_get_softc(fd_devclass, fdu);
- if (fd == 0)
- panic("fdstrategy: buf for nonexistent device (%#lx, %#lx)",
- (u_long)major(bp->b_dev), (u_long)minor(bp->b_dev));
- fdc = fd->fdc;
- if (fd->type == NO_TYPE) {
- bp->b_error = ENXIO;
- bp->b_flags |= B_ERROR;
- goto bad;
- };
-
- fdblk = 128 << (fd->ft->secsize);
- if (!(bp->b_flags & B_FORMAT)) {
- if (bp->b_blkno < 0) {
- printf(
- "fd%d: fdstrat: bad request blkno = %lu, bcount = %ld\n",
- fdu, (u_long)bp->b_blkno, bp->b_bcount);
- bp->b_error = EINVAL;
- bp->b_flags |= B_ERROR;
- goto bad;
- }
- if ((bp->b_bcount % fdblk) != 0) {
- bp->b_error = EINVAL;
- bp->b_flags |= B_ERROR;
- goto bad;
- }
- }
-
- /*
- * Set up block calculations.
- */
- if (bp->b_blkno > 20000000) {
- /*
- * Reject unreasonably high block number, prevent the
- * multiplication below from overflowing.
- */
- bp->b_error = EINVAL;
- bp->b_flags |= B_ERROR;
- goto bad;
- }
- blknum = (unsigned) bp->b_blkno * DEV_BSIZE/fdblk;
- nblocks = fd->ft->size;
- bp->b_resid = 0;
- if (blknum + (bp->b_bcount / fdblk) > nblocks) {
- if (blknum <= nblocks) {
- cando = (nblocks - blknum) * fdblk;
- bp->b_resid = bp->b_bcount - cando;
- if (cando == 0)
- goto bad; /* not actually bad but EOF */
- } else {
- bp->b_error = EINVAL;
- bp->b_flags |= B_ERROR;
- goto bad;
- }
- }
- bp->b_pblkno = bp->b_blkno;
- s = splbio();
- bufqdisksort(&fdc->head, bp);
- untimeout(fd_turnoff, fd, fd->toffhandle); /* a good idea */
-
- /* Tell devstat we are starting on the transaction */
- devstat_start_transaction(&fd->device_stats);
-
- fdstart(fdc);
- splx(s);
- return;
-
-bad:
- biodone(bp);
-}
-
-/***************************************************************\
-* fdstart *
-* We have just queued something.. if the controller is not busy *
-* then simulate the case where it has just finished a command *
-* So that it (the interrupt routine) looks on the queue for more*
-* work to do and picks up what we just added. *
-* If the controller is already busy, we need do nothing, as it *
-* will pick up our work when the present work completes *
-\***************************************************************/
-static void
-fdstart(struct fdc_data *fdc)
-{
- int s;
-
- s = splbio();
- if(fdc->state == DEVIDLE)
- {
- fdc_intr(fdc);
- }
- splx(s);
-}
-
-static void
-fd_iotimeout(void *xfdc)
-{
- fdc_p fdc;
- int s;
-
- fdc = xfdc;
- TRACE1("fd%d[fd_iotimeout()]", fdc->fdu);
-
- /*
- * Due to IBM's brain-dead design, the FDC has a faked ready
- * signal, hardwired to ready == true. Thus, any command
- * issued if there's no diskette in the drive will _never_
- * complete, and must be aborted by resetting the FDC.
- * Many thanks, Big Blue!
- * The FDC must not be reset directly, since that would
- * interfere with the state machine. Instead, pretend that
- * the command completed but was invalid. The state machine
- * will reset the FDC and retry once.
- */
- s = splbio();
- fdc->status[0] = NE7_ST0_IC_IV;
- fdc->flags &= ~FDC_STAT_VALID;
- fdc->state = IOTIMEDOUT;
- fdc_intr(fdc);
- splx(s);
-}
-
-/* just ensure it has the right spl */
-static void
-fd_pseudointr(void *xfdc)
-{
- int s;
-
- s = splbio();
- fdc_intr(xfdc);
- splx(s);
-}
-
-/***********************************************************************\
-* fdintr *
-* keep calling the state machine until it returns a 0 *
-* ALWAYS called at SPLBIO *
-\***********************************************************************/
-static void
-fdc_intr(void *xfdc)
-{
- fdc_p fdc = xfdc;
- while(fdstate(fdc))
- ;
-}
-
-/*
- * magic pseudo-DMA initialization for YE FDC. Sets count and
- * direction
- */
-#define SET_BCDR(fdc,wr,cnt,port) \
- bus_space_write_1(fdc->portt, fdc->porth, fdc->port_off + port, \
- ((cnt)-1) & 0xff); \
- bus_space_write_1(fdc->portt, fdc->porth, fdc->port_off + port + 1, \
- ((wr ? 0x80 : 0) | ((((cnt)-1) >> 8) & 0x7f)));
-
-/*
- * fdcpio(): perform programmed IO read/write for YE PCMCIA floppy
- */
-static int fdcpio(fdc_p fdc, long flags, caddr_t addr, u_int count)
-{
- u_char *cptr = (u_char *)addr;
-
- if (flags & B_READ) {
- if (fdc->state != PIOREAD) {
- fdc->state = PIOREAD;
- return(0);
- };
- SET_BCDR(fdc, 0, count, 0);
- bus_space_read_multi_1(fdc->portt, fdc->porth, fdc->port_off +
- FDC_YE_DATAPORT, cptr, count);
- } else {
- bus_space_write_multi_1(fdc->portt, fdc->porth, fdc->port_off +
- FDC_YE_DATAPORT, cptr, count);
- SET_BCDR(fdc, 0, count, 0);
- };
- return(1);
-}
-
-/***********************************************************************\
-* The controller state machine. *
-* if it returns a non zero value, it should be called again immediatly *
-\***********************************************************************/
-static int
-fdstate(fdc_p fdc)
-{
- int read, format, head, i, sec = 0, sectrac, st0, cyl, st3;
- unsigned blknum = 0, b_cylinder = 0;
- fdu_t fdu = fdc->fdu;
- fd_p fd;
- register struct buf *bp;
- struct fd_formb *finfo = NULL;
- size_t fdblk;
-
- bp = fdc->bp;
- if (bp == NULL) {
- bp = bufq_first(&fdc->head);
- if (bp != NULL) {
- bufq_remove(&fdc->head, bp);
- fdc->bp = bp;
- }
- }
- if (bp == NULL) {
- /***********************************************\
- * nothing left for this controller to do *
- * Force into the IDLE state, *
- \***********************************************/
- fdc->state = DEVIDLE;
- if (fdc->fd) {
- device_printf(fdc->fdc_dev,
- "unexpected valid fd pointer\n");
- fdc->fd = (fd_p) 0;
- fdc->fdu = -1;
- }
- TRACE1("[fdc%d IDLE]", fdc->fdcu);
- return (0);
- }
- fdu = FDUNIT(minor(bp->b_dev));
- fd = devclass_get_softc(fd_devclass, fdu);
- fdblk = 128 << fd->ft->secsize;
- if (fdc->fd && (fd != fdc->fd))
- device_printf(fd->dev, "confused fd pointers\n");
- read = bp->b_flags & B_READ;
- format = bp->b_flags & B_FORMAT;
- if (format) {
- finfo = (struct fd_formb *)bp->b_data;
- fd->skip = (char *)&(finfo->fd_formb_cylno(0))
- - (char *)finfo;
- }
- if (fdc->state == DOSEEK || fdc->state == SEEKCOMPLETE) {
- blknum = (unsigned) bp->b_pblkno * DEV_BSIZE/fdblk +
- fd->skip/fdblk;
- b_cylinder = blknum / (fd->ft->sectrac * fd->ft->heads);
- }
- TRACE1("fd%d", fdu);
- TRACE1("[%s]", fdstates[fdc->state]);
- TRACE1("(0x%x)", fd->flags);
- untimeout(fd_turnoff, fd, fd->toffhandle);
- fd->toffhandle = timeout(fd_turnoff, fd, 4 * hz);
- switch (fdc->state)
- {
- case DEVIDLE:
- case FINDWORK: /* we have found new work */
- fdc->retry = 0;
- fd->skip = 0;
- fdc->fd = fd;
- fdc->fdu = fdu;
- fdctl_wr(fdc, fd->ft->trans);
- TRACE1("[0x%x->FDCTL]", fd->ft->trans);
- /*******************************************************\
- * If the next drive has a motor startup pending, then *
- * it will start up in its own good time *
- \*******************************************************/
- if(fd->flags & FD_MOTOR_WAIT) {
- fdc->state = MOTORWAIT;
- return (0); /* come back later */
- }
- /*******************************************************\
- * Maybe if it's not starting, it SHOULD be starting *
- \*******************************************************/
- if (!(fd->flags & FD_MOTOR))
- {
- fdc->state = MOTORWAIT;
- fd_turnon(fd);
- return (0);
- }
- else /* at least make sure we are selected */
- {
- set_motor(fdc, fd->fdsu, TURNON);
- }
- if (fdc->flags & FDC_NEEDS_RESET) {
- fdc->state = RESETCTLR;
- fdc->flags &= ~FDC_NEEDS_RESET;
- } else
- fdc->state = DOSEEK;
- break;
- case DOSEEK:
- if (b_cylinder == (unsigned)fd->track)
- {
- fdc->state = SEEKCOMPLETE;
- break;
- }
- if (fd_cmd(fdc, 3, NE7CMD_SEEK,
- fd->fdsu, b_cylinder * fd->ft->steptrac,
- 0))
- {
- /*
- * seek command not accepted, looks like
- * the FDC went off to the Saints...
- */
- fdc->retry = 6; /* try a reset */
- return(retrier(fdc));
- }
- fd->track = FD_NO_TRACK;
- fdc->state = SEEKWAIT;
- return(0); /* will return later */
- case SEEKWAIT:
- /* allow heads to settle */
- timeout(fd_pseudointr, fdc, hz / 16);
- fdc->state = SEEKCOMPLETE;
- return(0); /* will return later */
- case SEEKCOMPLETE : /* SEEK DONE, START DMA */
- /* Make sure seek really happened*/
- if(fd->track == FD_NO_TRACK) {
- int descyl = b_cylinder * fd->ft->steptrac;
- do {
- /*
- * This might be a "ready changed" interrupt,
- * which cannot really happen since the
- * RDY pin is hardwired to + 5 volts. This
- * generally indicates a "bouncing" intr
- * line, so do one of the following:
- *
- * When running on an enhanced FDC that is
- * known to not go stuck after responding
- * with INVALID, fetch all interrupt states
- * until seeing either an INVALID or a
- * real interrupt condition.
- *
- * When running on a dumb old NE765, give
- * up immediately. The controller will
- * provide up to four dummy RC interrupt
- * conditions right after reset (for the
- * corresponding four drives), so this is
- * our only chance to get notice that it
- * was not the FDC that caused the interrupt.
- */
- if (fd_sense_int(fdc, &st0, &cyl)
- == FD_NOT_VALID)
- return 0;
- if(fdc->fdct == FDC_NE765
- && (st0 & NE7_ST0_IC) == NE7_ST0_IC_RC)
- return 0; /* hope for a real intr */
- } while ((st0 & NE7_ST0_IC) == NE7_ST0_IC_RC);
-
- if (0 == descyl) {
- int failed = 0;
- /*
- * seek to cyl 0 requested; make sure we are
- * really there
- */
- if (fd_sense_drive_status(fdc, &st3))
- failed = 1;
- if ((st3 & NE7_ST3_T0) == 0) {
- printf(
- "fd%d: Seek to cyl 0, but not really there (ST3 = %b)\n",
- fdu, st3, NE7_ST3BITS);
- failed = 1;
- }
-
- if (failed) {
- if(fdc->retry < 3)
- fdc->retry = 3;
- return (retrier(fdc));
- }
- }
-
- if (cyl != descyl) {
- printf(
- "fd%d: Seek to cyl %d failed; am at cyl %d (ST0 = 0x%x)\n",
- fdu, descyl, cyl, st0);
- if (fdc->retry < 3)
- fdc->retry = 3;
- return (retrier(fdc));
- }
- }
-
- fd->track = b_cylinder;
- if (!(fdc->flags & FDC_NODMA))
- isa_dmastart(bp->b_flags, bp->b_data+fd->skip,
- format ? bp->b_bcount : fdblk, fdc->dmachan);
- sectrac = fd->ft->sectrac;
- sec = blknum % (sectrac * fd->ft->heads);
- head = sec / sectrac;
- sec = sec % sectrac + 1;
- fd->hddrv = ((head&1)<<2)+fdu;
-
- if(format || !read)
- {
- /* make sure the drive is writable */
- if(fd_sense_drive_status(fdc, &st3) != 0)
- {
- /* stuck controller? */
- isa_dmadone(bp->b_flags, bp->b_data + fd->skip,
- format ? bp->b_bcount : fdblk,
- fdc->dmachan);
- fdc->retry = 6; /* reset the beast */
- return (retrier(fdc));
- }
- if(st3 & NE7_ST3_WP)
- {
- /*
- * XXX YES! this is ugly.
- * in order to force the current operation
- * to fail, we will have to fake an FDC
- * error - all error handling is done
- * by the retrier()
- */
- fdc->status[0] = NE7_ST0_IC_AT;
- fdc->status[1] = NE7_ST1_NW;
- fdc->status[2] = 0;
- fdc->status[3] = fd->track;
- fdc->status[4] = head;
- fdc->status[5] = sec;
- fdc->retry = 8; /* break out immediately */
- fdc->state = IOTIMEDOUT; /* not really... */
- return (1);
- }
- }
-
- if (format) {
- if (fdc->flags & FDC_NODMA)
- (void)fdcpio(fdc,bp->b_flags,
- bp->b_data+fd->skip,
- bp->b_bcount);
- /* formatting */
- if(fd_cmd(fdc, 6, NE7CMD_FORMAT, head << 2 | fdu,
- finfo->fd_formb_secshift,
- finfo->fd_formb_nsecs,
- finfo->fd_formb_gaplen,
- finfo->fd_formb_fillbyte, 0)) {
- /* controller fell over */
- isa_dmadone(bp->b_flags, bp->b_data + fd->skip,
- format ? bp->b_bcount : fdblk,
- fdc->dmachan);
- fdc->retry = 6;
- return (retrier(fdc));
- }
- } else {
- if (fdc->flags & FDC_NODMA) {
- /*
- * this seems to be necessary even when
- * reading data
- */
- SET_BCDR(fdc, 1, fdblk, 0);
-
- /*
- * perform the write pseudo-DMA before
- * the WRITE command is sent
- */
- if (!read)
- (void)fdcpio(fdc,bp->b_flags,
- bp->b_data+fd->skip,
- fdblk);
- }
- if (fd_cmd(fdc, 9,
- (read ? NE7CMD_READ : NE7CMD_WRITE),
- head << 2 | fdu, /* head & unit */
- fd->track, /* track */
- head,
- sec, /* sector + 1 */
- fd->ft->secsize, /* sector size */
- sectrac, /* sectors/track */
- fd->ft->gap, /* gap size */
- fd->ft->datalen, /* data length */
- 0)) {
- /* the beast is sleeping again */
- isa_dmadone(bp->b_flags, bp->b_data + fd->skip,
- format ? bp->b_bcount : fdblk,
- fdc->dmachan);
- fdc->retry = 6;
- return (retrier(fdc));
- }
- }
- if (fdc->flags & FDC_NODMA)
- /*
- * if this is a read, then simply await interrupt
- * before performing PIO
- */
- if (read && !fdcpio(fdc,bp->b_flags,
- bp->b_data+fd->skip,fdblk)) {
- fd->tohandle = timeout(fd_iotimeout, fdc, hz);
- return(0); /* will return later */
- };
-
- /*
- * write (or format) operation will fall through and
- * await completion interrupt
- */
- fdc->state = IOCOMPLETE;
- fd->tohandle = timeout(fd_iotimeout, fdc, hz);
- return (0); /* will return later */
- case PIOREAD:
- /*
- * actually perform the PIO read. The IOCOMPLETE case
- * removes the timeout for us.
- */
- (void)fdcpio(fdc,bp->b_flags,bp->b_data+fd->skip,fdblk);
- fdc->state = IOCOMPLETE;
- /* FALLTHROUGH */
- case IOCOMPLETE: /* IO DONE, post-analyze */
- untimeout(fd_iotimeout, fdc, fd->tohandle);
-
- if (fd_read_status(fdc, fd->fdsu)) {
- isa_dmadone(bp->b_flags, bp->b_data + fd->skip,
- format ? bp->b_bcount : fdblk,
- fdc->dmachan);
- if (fdc->retry < 6)
- fdc->retry = 6; /* force a reset */
- return (retrier(fdc));
- }
-
- fdc->state = IOTIMEDOUT;
-
- /* FALLTHROUGH */
-
- case IOTIMEDOUT:
- if (!(fdc->flags & FDC_NODMA))
- isa_dmadone(bp->b_flags, bp->b_data + fd->skip,
- format ? bp->b_bcount : fdblk, fdc->dmachan);
- if (fdc->status[0] & NE7_ST0_IC) {
- if ((fdc->status[0] & NE7_ST0_IC) == NE7_ST0_IC_AT
- && fdc->status[1] & NE7_ST1_OR) {
- /*
- * DMA overrun. Someone hogged the bus
- * and didn't release it in time for the
- * next FDC transfer.
- * Just restart it, don't increment retry
- * count. (vak)
- */
- fdc->state = SEEKCOMPLETE;
- return (1);
- }
- else if((fdc->status[0] & NE7_ST0_IC) == NE7_ST0_IC_IV
- && fdc->retry < 6)
- fdc->retry = 6; /* force a reset */
- else if((fdc->status[0] & NE7_ST0_IC) == NE7_ST0_IC_AT
- && fdc->status[2] & NE7_ST2_WC
- && fdc->retry < 3)
- fdc->retry = 3; /* force recalibrate */
- return (retrier(fdc));
- }
- /* All OK */
- fd->skip += fdblk;
- if (!format && fd->skip < bp->b_bcount - bp->b_resid) {
- /* set up next transfer */
- fdc->state = DOSEEK;
- } else {
- /* ALL DONE */
- fd->skip = 0;
- fdc->bp = NULL;
- devstat_end_transaction_buf(&fd->device_stats, bp);
- biodone(bp);
- fdc->fd = (fd_p) 0;
- fdc->fdu = -1;
- fdc->state = FINDWORK;
- }
- return (1);
- case RESETCTLR:
- fdc_reset(fdc);
- fdc->retry++;
- fdc->state = RESETCOMPLETE;
- return (0);
- case RESETCOMPLETE:
- /*
- * Discard all the results from the reset so that they
- * can't cause an unexpected interrupt later.
- */
- for (i = 0; i < 4; i++)
- (void)fd_sense_int(fdc, &st0, &cyl);
- fdc->state = STARTRECAL;
- /* Fall through. */
- case STARTRECAL:
- if(fd_cmd(fdc, 2, NE7CMD_RECAL, fdu, 0)) {
- /* arrgl */
- fdc->retry = 6;
- return (retrier(fdc));
- }
- fdc->state = RECALWAIT;
- return (0); /* will return later */
- case RECALWAIT:
- /* allow heads to settle */
- timeout(fd_pseudointr, fdc, hz / 8);
- fdc->state = RECALCOMPLETE;
- return (0); /* will return later */
- case RECALCOMPLETE:
- do {
- /*
- * See SEEKCOMPLETE for a comment on this:
- */
- if (fd_sense_int(fdc, &st0, &cyl) == FD_NOT_VALID)
- return 0;
- if(fdc->fdct == FDC_NE765
- && (st0 & NE7_ST0_IC) == NE7_ST0_IC_RC)
- return 0; /* hope for a real intr */
- } while ((st0 & NE7_ST0_IC) == NE7_ST0_IC_RC);
- if ((st0 & NE7_ST0_IC) != NE7_ST0_IC_NT || cyl != 0)
- {
- if(fdc->retry > 3)
- /*
- * a recalibrate from beyond cylinder 77
- * will "fail" due to the FDC limitations;
- * since people used to complain much about
- * the failure message, try not logging
- * this one if it seems to be the first
- * time in a line
- */
- printf("fd%d: recal failed ST0 %b cyl %d\n",
- fdu, st0, NE7_ST0BITS, cyl);
- if(fdc->retry < 3) fdc->retry = 3;
- return (retrier(fdc));
- }
- fd->track = 0;
- /* Seek (probably) necessary */
- fdc->state = DOSEEK;
- return (1); /* will return immediatly */
- case MOTORWAIT:
- if(fd->flags & FD_MOTOR_WAIT)
- {
- return (0); /* time's not up yet */
- }
- if (fdc->flags & FDC_NEEDS_RESET) {
- fdc->state = RESETCTLR;
- fdc->flags &= ~FDC_NEEDS_RESET;
- } else {
- /*
- * If all motors were off, then the controller was
- * reset, so it has lost track of the current
- * cylinder. Recalibrate to handle this case.
- * But first, discard the results of the reset.
- */
- fdc->state = RESETCOMPLETE;
- }
- return (1); /* will return immediatly */
- default:
- device_printf(fdc->fdc_dev, "unexpected FD int->");
- if (fd_read_status(fdc, fd->fdsu) == 0)
- printf("FDC status :%x %x %x %x %x %x %x ",
- fdc->status[0],
- fdc->status[1],
- fdc->status[2],
- fdc->status[3],
- fdc->status[4],
- fdc->status[5],
- fdc->status[6] );
- else
- printf("No status available ");
- if (fd_sense_int(fdc, &st0, &cyl) != 0)
- {
- printf("[controller is dead now]\n");
- return (0);
- }
- printf("ST0 = %x, PCN = %x\n", st0, cyl);
- return (0);
- }
- /*XXX confusing: some branches return immediately, others end up here*/
- return (1); /* Come back immediatly to new state */
-}
-
-static int
-retrier(struct fdc_data *fdc)
-{
- register struct buf *bp;
- struct fd_data *fd;
- int fdu;
-
- bp = fdc->bp;
-
- /* XXX shouldn't this be cached somewhere? */
- fdu = FDUNIT(minor(bp->b_dev));
- fd = devclass_get_softc(fd_devclass, fdu);
- if (fd->options & FDOPT_NORETRY)
- goto fail;
-
- switch (fdc->retry) {
- case 0: case 1: case 2:
- fdc->state = SEEKCOMPLETE;
- break;
- case 3: case 4: case 5:
- fdc->state = STARTRECAL;
- break;
- case 6:
- fdc->state = RESETCTLR;
- break;
- case 7:
- break;
- default:
- fail:
- {
- dev_t sav_b_dev = bp->b_dev;
- /* Trick diskerr */
- bp->b_dev = makedev(major(bp->b_dev),
- (FDUNIT(minor(bp->b_dev))<<3)|RAW_PART);
- diskerr(bp, "hard error", LOG_PRINTF,
- fdc->fd->skip / DEV_BSIZE,
- (struct disklabel *)NULL);
- bp->b_dev = sav_b_dev;
- if (fdc->flags & FDC_STAT_VALID)
- {
- printf(
- " (ST0 %b ST1 %b ST2 %b cyl %u hd %u sec %u)\n",
- fdc->status[0], NE7_ST0BITS,
- fdc->status[1], NE7_ST1BITS,
- fdc->status[2], NE7_ST2BITS,
- fdc->status[3], fdc->status[4],
- fdc->status[5]);
- }
- else
- printf(" (No status)\n");
- }
- bp->b_flags |= B_ERROR;
- bp->b_error = EIO;
- bp->b_resid += bp->b_bcount - fdc->fd->skip;
- fdc->bp = NULL;
- fdc->fd->skip = 0;
- devstat_end_transaction_buf(&fdc->fd->device_stats, bp);
- biodone(bp);
- fdc->state = FINDWORK;
- fdc->flags |= FDC_NEEDS_RESET;
- fdc->fd = (fd_p) 0;
- fdc->fdu = -1;
- return (1);
- }
- fdc->retry++;
- return (1);
-}
-
-static int
-fdformat(dev, finfo, p)
- dev_t dev;
- struct fd_formb *finfo;
- struct proc *p;
-{
- fdu_t fdu;
- fd_p fd;
-
- struct buf *bp;
- int rv = 0, s;
- size_t fdblk;
-
- fdu = FDUNIT(minor(dev));
- fd = devclass_get_softc(fd_devclass, fdu);
- fdblk = 128 << fd->ft->secsize;
-
- /* set up a buffer header for fdstrategy() */
- bp = (struct buf *)malloc(sizeof(struct buf), M_TEMP, M_NOWAIT);
- if(bp == 0)
- return ENOBUFS;
- /*
- * keep the process from being swapped
- */
- PHOLD(p);
- bzero((void *)bp, sizeof(struct buf));
- BUF_LOCKINIT(bp);
- BUF_LOCK(bp, LK_EXCLUSIVE);
- bp->b_flags = B_PHYS | B_FORMAT;
-
- /*
- * calculate a fake blkno, so fdstrategy() would initiate a
- * seek to the requested cylinder
- */
- bp->b_blkno = (finfo->cyl * (fd->ft->sectrac * fd->ft->heads)
- + finfo->head * fd->ft->sectrac) * fdblk / DEV_BSIZE;
-
- bp->b_bcount = sizeof(struct fd_idfield_data) * finfo->fd_formb_nsecs;
- bp->b_data = (caddr_t)finfo;
-
- /* now do the format */
- bp->b_dev = dev;
- BUF_STRATEGY(bp, 0);
-
- /* ...and wait for it to complete */
- s = splbio();
- while(!(bp->b_flags & B_DONE)) {
- rv = tsleep((caddr_t)bp, PRIBIO, "fdform", 20 * hz);
- if (rv == EWOULDBLOCK)
- break;
- }
- splx(s);
-
- if (rv == EWOULDBLOCK) {
- /* timed out */
- rv = EIO;
- biodone(bp);
- }
- if (bp->b_flags & B_ERROR)
- rv = bp->b_error;
- /*
- * allow the process to be swapped
- */
- PRELE(p);
- BUF_UNLOCK(bp);
- BUF_LOCKFREE(bp);
- free(bp, M_TEMP);
- return rv;
-}
-
-/*
- * TODO: don't allocate buffer on stack.
- */
-
-static int
-fdioctl(dev, cmd, addr, flag, p)
- dev_t dev;
- u_long cmd;
- caddr_t addr;
- int flag;
- struct proc *p;
-{
- fdu_t fdu = FDUNIT(minor(dev));
- fd_p fd = devclass_get_softc(fd_devclass, fdu);
- size_t fdblk;
-
- struct fd_type *fdt;
- struct disklabel *dl;
- char buffer[DEV_BSIZE];
- int error = 0;
-
- fdblk = 128 << fd->ft->secsize;
-
- switch (cmd) {
- case DIOCGDINFO:
- bzero(buffer, sizeof (buffer));
- dl = (struct disklabel *)buffer;
- dl->d_secsize = fdblk;
- fdt = fd->ft;
- dl->d_secpercyl = fdt->size / fdt->tracks;
- dl->d_type = DTYPE_FLOPPY;
-
- if (readdisklabel(dkmodpart(dev, RAW_PART), dl)
- == NULL)
- error = 0;
- else
- error = EINVAL;
-
- *(struct disklabel *)addr = *dl;
- break;
-
- case DIOCSDINFO:
- if ((flag & FWRITE) == 0)
- error = EBADF;
- break;
-
- case DIOCWLABEL:
- if ((flag & FWRITE) == 0)
- error = EBADF;
- break;
-
- case DIOCWDINFO:
- if ((flag & FWRITE) == 0) {
- error = EBADF;
- break;
- }
-
- dl = (struct disklabel *)addr;
-
- if ((error = setdisklabel((struct disklabel *)buffer, dl,
- (u_long)0)) != 0)
- break;
-
- error = writedisklabel(dev, (struct disklabel *)buffer);
- break;
- case FD_FORM:
- if ((flag & FWRITE) == 0)
- error = EBADF; /* must be opened for writing */
- else if (((struct fd_formb *)addr)->format_version !=
- FD_FORMAT_VERSION)
- error = EINVAL; /* wrong version of formatting prog */
- else
- error = fdformat(dev, (struct fd_formb *)addr, p);
- break;
-
- case FD_GTYPE: /* get drive type */
- *(struct fd_type *)addr = *fd->ft;
- break;
-
- case FD_STYPE: /* set drive type */
- /* this is considered harmful; only allow for superuser */
- if (suser(p) != 0)
- return EPERM;
- *fd->ft = *(struct fd_type *)addr;
- break;
-
- case FD_GOPTS: /* get drive options */
- *(int *)addr = fd->options;
- break;
-
- case FD_SOPTS: /* set drive options */
- fd->options = *(int *)addr;
- break;
-
- default:
- error = ENOTTY;
- break;
- }
- return (error);
-}
-
-/*
- * Hello emacs, these are the
- * Local Variables:
- * c-indent-level: 8
- * c-continued-statement-offset: 8
- * c-continued-brace-offset: 0
- * c-brace-offset: -8
- * c-brace-imaginary-offset: 0
- * c-argdecl-indent: 8
- * c-label-offset: -8
- * c++-hanging-braces: 1
- * c++-access-specifier-offset: -8
- * c++-empty-arglist-indent: 8
- * c++-friend-offset: 0
- * End:
- */
diff --git a/sys/dev/fdc/fdcreg.h b/sys/dev/fdc/fdcreg.h
deleted file mode 100644
index f0b8eebbdb68..000000000000
--- a/sys/dev/fdc/fdcreg.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*-
- * 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. 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, Berkeley and its contributors.
- * 4. 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: @(#)fdreg.h 7.1 (Berkeley) 5/9/91
- * $FreeBSD$
- */
-
-/*
- * AT floppy controller registers and bitfields
- */
-
-/* uses NEC765 controller */
-#include <isa/ic/nec765.h>
-
-/* registers */
-#define FDOUT 2 /* Digital Output Register (W) */
-#define FDO_FDSEL 0x03 /* floppy device select */
-#define FDO_FRST 0x04 /* floppy controller reset */
-#define FDO_FDMAEN 0x08 /* enable floppy DMA and Interrupt */
-#define FDO_MOEN0 0x10 /* motor enable drive 0 */
-#define FDO_MOEN1 0x20 /* motor enable drive 1 */
-#define FDO_MOEN2 0x40 /* motor enable drive 2 */
-#define FDO_MOEN3 0x80 /* motor enable drive 3 */
-
-#define FDSTS 4 /* NEC 765 Main Status Register (R) */
-#define FDDATA 5 /* NEC 765 Data Register (R/W) */
-#define FDCTL 7 /* Control Register (W) */
-
-#ifndef FDC_500KBPS
-# define FDC_500KBPS 0x00 /* 500KBPS MFM drive transfer rate */
-# define FDC_300KBPS 0x01 /* 300KBPS MFM drive transfer rate */
-# define FDC_250KBPS 0x02 /* 250KBPS MFM drive transfer rate */
-# define FDC_125KBPS 0x03 /* 125KBPS FM drive transfer rate */
- /* for some controllers 1MPBS instead */
-#endif /* FDC_500KBPS */
-
-/*
- * this is the secret PIO data port (offset from base)
- */
-#define FDC_YE_DATAPORT 6
-
-#define FDIN 7 /* Digital Input Register (R) */
-#define FDI_DCHG 0x80 /* diskette has been changed */
- /* requires drive and motor being selected */
- /* is cleared by any step pulse to drive */
diff --git a/sys/dev/fe/if_fe.c b/sys/dev/fe/if_fe.c
deleted file mode 100644
index 49d759af91a5..000000000000
--- a/sys/dev/fe/if_fe.c
+++ /dev/null
@@ -1,4206 +0,0 @@
-/*
- * All Rights Reserved, Copyright (C) Fujitsu Limited 1995
- *
- * This software may be used, modified, copied, distributed, and sold, in
- * both source and binary form provided that the above copyright, these
- * terms and the following disclaimer are retained. The name of the author
- * and/or the contributor 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 AND THE CONTRIBUTOR ``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 THE CONTRIBUTOR 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.
- */
-
-/*
- * $FreeBSD$
- *
- * Device driver for Fujitsu MB86960A/MB86965A based Ethernet cards.
- * To be used with FreeBSD 3.x
- * Contributed by M. Sekiguchi. <seki@sysrap.cs.fujitsu.co.jp>
- *
- * This version is intended to be a generic template for various
- * MB86960A/MB86965A based Ethernet cards. It currently supports
- * Fujitsu FMV-180 series for ISA and Allied-Telesis AT1700/RE2000
- * series for ISA, as well as Fujitsu MBH10302 PC card.
- * There are some currently-
- * unused hooks embedded, which are primarily intended to support
- * other types of Ethernet cards, but the author is not sure whether
- * they are useful.
- *
- * This version also includes some alignments to support RE1000,
- * C-NET(98)P2 and so on. These cards are not for AT-compatibles,
- * but for NEC PC-98 bus -- a proprietary bus architecture available
- * only in Japan. Confusingly, it is different from the Microsoft's
- * PC98 architecture. :-{
- * Further work for PC-98 version will be available as a part of
- * FreeBSD(98) project.
- *
- * This software is a derivative work of if_ed.c version 1.56 by David
- * Greenman available as a part of FreeBSD 2.0 RELEASE source distribution.
- *
- * The following lines are retained from the original if_ed.c:
- *
- * Copyright (C) 1993, David Greenman. This software may be used, modified,
- * copied, distributed, and sold, in both source and binary form provided
- * that the above copyright and these terms are retained. Under no
- * circumstances is the author responsible for the proper functioning
- * of this software, nor does the author assume any responsibility
- * for damages incurred with its use.
- */
-
-/*
- * TODO:
- * o To support ISA PnP auto configuration for FMV-183/184.
- * o To reconsider mbuf usage.
- * o To reconsider transmission buffer usage, including
- * transmission buffer size (currently 4KB x 2) and pros-and-
- * cons of multiple frame transmission.
- * o To test IPX codes.
- * o To test FreeBSD3.0-current.
- * o To test BRIDGE codes.
- */
-
-#include "fe.h"
-#include "opt_fe.h"
-#include "opt_inet.h"
-#include "opt_ipx.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/sockio.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-
-#include <net/ethernet.h>
-#include <net/if.h>
-#include <net/if_dl.h>
-#include <net/if_mib.h>
-#include <net/if_media.h>
-#include <net/if_types.h>
-
-#include <netinet/in.h>
-#include <netinet/if_ether.h>
-
-#include <net/bpf.h>
-
-#ifdef BRIDGE
-#include <net/bridge.h>
-#endif
-
-#include <machine/clock.h>
-
-#include <i386/isa/isa_device.h>
-#include <i386/isa/icu.h>
-
-/* PCCARD suport */
-/* XXX FIXME! doesn't work with new pccard code, must be converted! */
-#ifdef notdef
-#include "card.h"
-#endif
-#if NCARD > 0
-#include <sys/kernel.h>
-#include <sys/select.h>
-#include <sys/module.h>
-#include <pccard/cardinfo.h>
-#include <pccard/slot.h>
-#endif
-
-#include <i386/isa/ic/mb86960.h>
-#include <i386/isa/if_fereg.h>
-
-/*
- * Default settings for fe driver specific options.
- * They can be set in config file by "options" statements.
- */
-
-/*
- * Transmit just one packet per a "send" command to 86960.
- * This option is intended for performance test. An EXPERIMENTAL option.
- */
-#ifndef FE_SINGLE_TRANSMISSION
-#define FE_SINGLE_TRANSMISSION 0
-#endif
-
-/*
- * Maximum loops when interrupt.
- * This option prevents an infinite loop due to hardware failure.
- * (Some laptops make an infinite loop after PC-Card is ejected.)
- */
-#ifndef FE_MAX_LOOP
-#define FE_MAX_LOOP 0x800
-#endif
-
-/*
- * If you define this option, 8-bit cards are also supported.
- */
-/*#define FE_8BIT_SUPPORT*/
-
-/*
- * Device configuration flags.
- */
-
-/* DLCR6 settings. */
-#define FE_FLAGS_DLCR6_VALUE 0x007F
-
-/* Force DLCR6 override. */
-#define FE_FLAGS_OVERRIDE_DLCR6 0x0080
-
-/* Shouldn't these be defined somewhere else such as isa_device.h? */
-#define NO_IOADDR (-1)
-#define NO_IRQ 0
-
-/*
- * Data type for a multicast address filter on 8696x.
- */
-struct fe_filter { u_char data [ FE_FILTER_LEN ]; };
-
-/*
- * Special filter values.
- */
-static struct fe_filter const fe_filter_nothing = { FE_FILTER_NOTHING };
-static struct fe_filter const fe_filter_all = { FE_FILTER_ALL };
-
-/* How many registers does an fe-supported adapter have at maximum? */
-#define MAXREGISTERS 32
-
-/*
- * fe_softc: per line info and status
- */
-static struct fe_softc {
-
- /* Used by "common" codes. */
- struct arpcom arpcom; /* Ethernet common */
-
- /* Used by config codes. */
-
- /* Set by probe() and not modified in later phases. */
- char const * typestr; /* printable name of the interface. */
- u_short iobase; /* base I/O address of the adapter. */
- u_short ioaddr [ MAXREGISTERS ]; /* I/O addresses of registers. */
- u_short txb_size; /* size of TX buffer, in bytes */
- u_char proto_dlcr4; /* DLCR4 prototype. */
- u_char proto_dlcr5; /* DLCR5 prototype. */
- u_char proto_dlcr6; /* DLCR6 prototype. */
- u_char proto_dlcr7; /* DLCR7 prototype. */
- u_char proto_bmpr13; /* BMPR13 prototype. */
- u_char stability; /* How stable is this? */
- u_short priv_info; /* info specific to a vendor/model. */
-
- /* Vendor/model specific hooks. */
- void (*init)(struct fe_softc *); /* Just before fe_init(). */
- void (*stop)(struct fe_softc *); /* Just after fe_stop(). */
-
- /* Transmission buffer management. */
- u_short txb_free; /* free bytes in TX buffer */
- u_char txb_count; /* number of packets in TX buffer */
- u_char txb_sched; /* number of scheduled packets */
-
- /* Excessive collision counter (see fe_tint() for details.) */
- u_char tx_excolls; /* # of excessive collisions. */
-
- /* Multicast address filter management. */
- u_char filter_change; /* MARs must be changed ASAP. */
- struct fe_filter filter;/* new filter value. */
-
- /* Network management. */
- struct ifmib_iso_8802_3 mibdata;
-
- /* Media information. */
- struct ifmedia media; /* used by if_media. */
- u_short mbitmap; /* bitmap for supported media; see bit2media */
- int defmedia; /* default media */
- void (* msel)(struct fe_softc *); /* media selector. */
-
-} fe_softc[NFE];
-
-#define sc_if arpcom.ac_if
-#define sc_unit arpcom.ac_if.if_unit
-#define sc_enaddr arpcom.ac_enaddr
-
-/* Standard driver entry points. These can be static. */
-static int fe_probe ( struct isa_device * );
-static int fe_attach ( struct isa_device * );
-static void fe_init ( void * );
-static ointhand2_t feintr;
-static int fe_ioctl ( struct ifnet *, u_long, caddr_t );
-static void fe_start ( struct ifnet * );
-static void fe_watchdog ( struct ifnet * );
-static int fe_medchange ( struct ifnet * );
-static void fe_medstat ( struct ifnet *, struct ifmediareq * );
-
-/* Local functions. Order of declaration is confused. FIXME. */
-static int fe_probe_ssi ( struct isa_device *, struct fe_softc * );
-static int fe_probe_jli ( struct isa_device *, struct fe_softc * );
-static int fe_probe_fmv ( struct isa_device *, struct fe_softc * );
-static int fe_probe_lnx ( struct isa_device *, struct fe_softc * );
-static int fe_probe_gwy ( struct isa_device *, struct fe_softc * );
-static int fe_probe_ubn ( struct isa_device *, struct fe_softc * );
-#ifdef PC98
-static int fe_probe_re1000 ( struct isa_device *, struct fe_softc * );
-static int fe_probe_cnet9ne( struct isa_device *, struct fe_softc * );
-#endif
-#if NCARD > 0
-static int fe_probe_mbh ( struct isa_device *, struct fe_softc * );
-static int fe_probe_tdk ( struct isa_device *, struct fe_softc * );
-#endif
-static int fe_get_packet ( struct fe_softc *, u_short );
-static void fe_stop ( struct fe_softc * );
-static void fe_tint ( struct fe_softc *, u_char );
-static void fe_rint ( struct fe_softc *, u_char );
-static void fe_xmit ( struct fe_softc * );
-static void fe_write_mbufs ( struct fe_softc *, struct mbuf * );
-static void fe_setmode ( struct fe_softc * );
-static void fe_loadmar ( struct fe_softc * );
-
-#ifdef DIAGNOSTIC
-static void fe_emptybuffer ( struct fe_softc * );
-#endif
-
-/* Driver struct used in the config code. This must be public (external.) */
-struct isa_driver fedriver =
-{
- fe_probe,
- fe_attach,
- "fe",
- 1 /* It's safe to mark as "sensitive" */
-};
-
-/*
- * Fe driver specific constants which relate to 86960/86965.
- */
-
-/* Interrupt masks */
-#define FE_TMASK ( FE_D2_COLL16 | FE_D2_TXDONE )
-#define FE_RMASK ( FE_D3_OVRFLO | FE_D3_CRCERR \
- | FE_D3_ALGERR | FE_D3_SRTPKT | FE_D3_PKTRDY )
-
-/* Maximum number of iterations for a receive interrupt. */
-#define FE_MAX_RECV_COUNT ( ( 65536 - 2048 * 2 ) / 64 )
- /*
- * Maximum size of SRAM is 65536,
- * minimum size of transmission buffer in fe is 2x2KB,
- * and minimum amount of received packet including headers
- * added by the chip is 64 bytes.
- * Hence FE_MAX_RECV_COUNT is the upper limit for number
- * of packets in the receive buffer.
- */
-
-/*
- * Miscellaneous definitions not directly related to hardware.
- */
-
-/* Flags for stability. */
-#define UNSTABLE_IRQ 0x01 /* IRQ setting may be incorrect. */
-#define UNSTABLE_MAC 0x02 /* Probed MAC address may be incorrect. */
-#define UNSTABLE_TYPE 0x04 /* Probed vendor/model may be incorrect. */
-
-/* The following line must be delete when "net/if_media.h" support it. */
-#ifndef IFM_10_FL
-#define IFM_10_FL /* 13 */ IFM_10_5
-#endif
-
-#if 0
-/* Mapping between media bitmap (in fe_softc.mbitmap) and ifm_media. */
-static int const bit2media [] = {
-#define MB_HA 0x0001
- IFM_HDX | IFM_ETHER | IFM_AUTO,
-#define MB_HM 0x0002
- IFM_HDX | IFM_ETHER | IFM_MANUAL,
-#define MB_HT 0x0004
- IFM_HDX | IFM_ETHER | IFM_10_T,
-#define MB_H2 0x0008
- IFM_HDX | IFM_ETHER | IFM_10_2,
-#define MB_H5 0x0010
- IFM_HDX | IFM_ETHER | IFM_10_5,
-#define MB_HF 0x0020
- IFM_HDX | IFM_ETHER | IFM_10_FL,
-#define MB_FT 0x0040
- IFM_FDX | IFM_ETHER | IFM_10_T,
- /* More can be come here... */
- 0
-};
-#else
-/* Mapping between media bitmap (in fe_softc.mbitmap) and ifm_media. */
-static int const bit2media [] = {
-#define MB_HA 0x0001
- IFM_ETHER | IFM_AUTO,
-#define MB_HM 0x0002
- IFM_ETHER | IFM_MANUAL,
-#define MB_HT 0x0004
- IFM_ETHER | IFM_10_T,
-#define MB_H2 0x0008
- IFM_ETHER | IFM_10_2,
-#define MB_H5 0x0010
- IFM_ETHER | IFM_10_5,
-#define MB_HF 0x0020
- IFM_ETHER | IFM_10_FL,
-#define MB_FT 0x0040
- IFM_ETHER | IFM_10_T,
- /* More can be come here... */
- 0
-};
-#endif
-
-/*
- * Routines to access contiguous I/O ports.
- */
-
-static void
-inblk ( struct fe_softc * sc, int offs, u_char * mem, int len )
-{
- while ( --len >= 0 ) {
- *mem++ = inb( sc->ioaddr[ offs++ ] );
- }
-}
-
-static void
-outblk ( struct fe_softc * sc, int offs, u_char const * mem, int len )
-{
- while ( --len >= 0 ) {
- outb( sc->ioaddr[ offs++ ], *mem++ );
- }
-}
-
-/* PCCARD Support */
-#if NCARD > 0
-/*
- * PC-Card (PCMCIA) specific code.
- */
-static int feinit (struct pccard_devinfo *);
-static void feunload (struct pccard_devinfo *);
-static int fe_card_intr (struct pccard_devinfo *);
-
-PCCARD_MODULE(fe, feinit, feunload, fe_card_intr, 0, net_imask);
-
-/*
- * Initialize the device - called from Slot manager.
- */
-static int
-feinit(struct pccard_devinfo *devi)
-{
- struct fe_softc *sc;
-
- /* validate unit number. */
- if (devi->isahd.id_unit >= NFE) return ENODEV;
-
- /* Prepare for the device probe process. */
- sc = &fe_softc[devi->isahd.id_unit];
- sc->sc_unit = devi->isahd.id_unit;
- sc->iobase = devi->isahd.id_iobase;
-
- /*
- * When the feinit() is called, the devi->misc holds a
- * six-byte value set by the pccard daemon. If the
- * corresponding entry in /etc/pccard.conf has an "ether"
- * keyword, the value is the Ethernet MAC address extracted
- * from CIS area of the card. If the entry has no "ether"
- * keyword, the daemon fills the field with binary zero,
- * instead. We passes the value (either MAC address or zero)
- * to model-specific sub-probe routines through sc->sc_enaddr
- * (it actually is sc->sc_arpcom.ar_enaddr, BTW) so that the
- * sub-probe routies can use that info.
- */
- bcopy(devi->misc, sc->sc_enaddr, ETHER_ADDR_LEN);
-
- /* Probe for supported cards. */
- if (fe_probe_mbh(&devi->isahd, sc) == 0
- && fe_probe_tdk(&devi->isahd, sc) == 0) return ENXIO;
-
- /* We've got a supported card. Attach it, then. */
- if (fe_attach(&devi->isahd) == 0) return ENXIO;
-
- return 0;
-}
-
-/*
- * feunload - unload the driver and clear the table.
- * XXX TODO:
- * This is usually called when the card is ejected, but
- * can be caused by a modunload of a controller driver.
- * The idea is to reset the driver's view of the device
- * and ensure that any driver entry points such as
- * read and write do not hang.
- */
-static void
-feunload(struct pccard_devinfo *devi)
-{
- struct fe_softc *sc = &fe_softc[devi->isahd.id_unit];
- printf("fe%d: unload\n", sc->sc_unit);
- fe_stop(sc);
- if_down(&sc->arpcom.ac_if);
-}
-
-/*
- * fe_card_intr - Shared interrupt called from
- * front end of PC-Card handler.
- */
-static int
-fe_card_intr(struct pccard_devinfo *devi)
-{
- feintr(devi->isahd.id_unit);
- return (1);
-}
-#endif /* NCARD > 0 */
-
-
-/*
- * Hardware probe routines.
- *
- * In older versions of this driver, we provided an automatic I/O
- * address detection. The features is, however, removed from this
- * version, for simplicity. Any comments?
- */
-
-/*
- * Determine if the device is present at a specified I/O address. The
- * main entry to the driver.
- */
-
-static int
-fe_probe (struct isa_device * dev)
-{
- struct fe_softc * sc;
- int nports;
-
-#ifdef DIAGNOSTIC
- if (dev->id_unit >= NFE) {
- printf("fe%d: too large unit number for the current config\n",
- dev->id_unit);
- return 0;
- }
-#endif
-
- /* Prepare for the softc struct. */
- sc = &fe_softc[dev->id_unit];
- sc->sc_unit = dev->id_unit;
- sc->iobase = dev->id_iobase;
-
- /* Probe for supported boards. */
- nports = 0;
-#ifdef PC98
- if (!nports) nports = fe_probe_re1000(dev, sc);
- if (!nports) nports = fe_probe_cnet9ne(dev, sc);
-#endif
- if (!nports) nports = fe_probe_ssi(dev, sc);
- if (!nports) nports = fe_probe_jli(dev, sc);
- if (!nports) nports = fe_probe_fmv(dev, sc);
- if (!nports) nports = fe_probe_lnx(dev, sc);
- if (!nports) nports = fe_probe_ubn(dev, sc);
- if (!nports) nports = fe_probe_gwy(dev, sc);
-
- /* We found supported board. */
- return nports;
-}
-
-/*
- * Check for specific bits in specific registers have specific values.
- * A common utility function called from various sub-probe routines.
- */
-
-struct fe_simple_probe_struct
-{
- u_char port; /* Offset from the base I/O address. */
- u_char mask; /* Bits to be checked. */
- u_char bits; /* Values to be compared against. */
-};
-
-static int
-fe_simple_probe ( struct fe_softc const * sc,
- struct fe_simple_probe_struct const * sp )
-{
- struct fe_simple_probe_struct const * p;
-
- for ( p = sp; p->mask != 0; p++ ) {
-#ifdef FE_DEBUG
- unsigned a = sc->ioaddr[p->port];
- printf("fe%d: Probing %02x (%04x): %02x (%02x, %02x): %s\n",
- sc->sc_unit, p->port, a, inb(a), p->mask, p->bits,
- (inb(a) & p->mask) == p->bits ? "OK" : "NG");
-#endif
- if ( ( inb( sc->ioaddr[ p->port ] ) & p->mask ) != p->bits )
- {
- return ( 0 );
- }
- }
- return ( 1 );
-}
-
-/* Test if a given 6 byte value is a valid Ethernet station (MAC)
- address. "Vendor" is an expected vendor code (first three bytes,)
- or a zero when nothing expected. */
-static int
-valid_Ether_p (u_char const * addr, unsigned vendor)
-{
-#ifdef FE_DEBUG
- printf("fe?: validating %6D against %06x\n", addr, ":", vendor);
-#endif
-
- /* All zero is not allowed as a vendor code. */
- if (addr[0] == 0 && addr[1] == 0 && addr[2] == 0) return 0;
-
- switch (vendor) {
- case 0x000000:
- /* Legal Ethernet address (stored in ROM) must have
- its Group and Local bits cleared. */
- if ((addr[0] & 0x03) != 0) return 0;
- break;
- case 0x020000:
- /* Same as above, but a local address is allowed in
- this context. */
- if ((addr[0] & 0x01) != 0) return 0;
- break;
- default:
- /* Make sure the vendor part matches if one is given. */
- if ( addr[0] != ((vendor >> 16) & 0xFF)
- || addr[1] != ((vendor >> 8) & 0xFF)
- || addr[2] != ((vendor ) & 0xFF)) return 0;
- break;
- }
-
- /* Host part must not be all-zeros nor all-ones. */
- if (addr[3] == 0xFF && addr[4] == 0xFF && addr[5] == 0xFF) return 0;
- if (addr[3] == 0x00 && addr[4] == 0x00 && addr[5] == 0x00) return 0;
-
- /* Given addr looks like an Ethernet address. */
- return 1;
-}
-
-/* Fill our softc struct with default value. */
-static void
-fe_softc_defaults (struct fe_softc *sc)
-{
- int i;
-
- /* Initialize I/O address re-mapping table for the standard
- (contiguous) register layout. This routine doesn't use
- ioaddr[], so the caller can safely override it after
- calling fe_softc_defaults, if needed. */
- for (i = 0; i < MAXREGISTERS; i++) sc->ioaddr[i] = sc->iobase + i;
-
- /* Prepare for typical register prototypes. We assume a
- "typical" board has <32KB> of <fast> SRAM connected with a
- <byte-wide> data lines. */
- sc->proto_dlcr4 = FE_D4_LBC_DISABLE | FE_D4_CNTRL;
- sc->proto_dlcr5 = 0;
- sc->proto_dlcr6 = FE_D6_BUFSIZ_32KB | FE_D6_TXBSIZ_2x4KB
- | FE_D6_BBW_BYTE | FE_D6_SBW_WORD | FE_D6_SRAM_100ns;
- sc->proto_dlcr7 = FE_D7_BYTSWP_LH;
- sc->proto_bmpr13 = 0;
-
- /* Assume the probe process (to be done later) is stable. */
- sc->stability = 0;
-
- /* A typical board needs no hooks. */
- sc->init = NULL;
- sc->stop = NULL;
-
- /* Assume the board has no software-controllable media selection. */
- sc->mbitmap = MB_HM;
- sc->defmedia = MB_HM;
- sc->msel = NULL;
-}
-
-/* Common error reporting routine used in probe routines for
- "soft configured IRQ"-type boards. */
-static void
-fe_irq_failure (char const *name, int unit, int irq, char const *list)
-{
- printf("fe%d: %s board is detected, but %s IRQ was given\n",
- unit, name, (irq == NO_IRQ ? "no" : "invalid"));
- if (list != NULL) {
- printf("fe%d: specify an IRQ from %s in kernel config\n",
- unit, list);
- }
-}
-
-/*
- * Hardware (vendor) specific probe routines and hooks.
- */
-
-/*
- * Machine independent routines.
- */
-
-/*
- * Generic media selection scheme for MB86965 based boards.
- */
-static void
-fe_msel_965 (struct fe_softc *sc)
-{
- u_char b13;
-
- /* Find the appropriate bits for BMPR13 tranceiver control. */
- switch (IFM_SUBTYPE(sc->media.ifm_media)) {
- case IFM_AUTO: b13 = FE_B13_PORT_AUTO | FE_B13_TPTYPE_UTP; break;
- case IFM_10_T: b13 = FE_B13_PORT_TP | FE_B13_TPTYPE_UTP; break;
- default: b13 = FE_B13_PORT_AUI; break;
- }
-
- /* Write it into the register. It takes effect immediately. */
- outb(sc->ioaddr[FE_BMPR13], sc->proto_bmpr13 | b13);
-}
-
-/*
- * Fujitsu MB86965 JLI mode support routines.
- */
-
-/* Datasheet for 86965 explicitly states that it only supports serial
- * EEPROM with 16 words (32 bytes) capacity. (I.e., 93C06.) However,
- * ones with 64 words (128 bytes) are available in the marked, namely
- * 93C46, and are also fully compatible with 86965. It is known that
- * some boards (e.g., ICL) actually have 93C46 on them and use extra
- * storage to keep various config info. */
-#define JLI_EEPROM_SIZE 128
-
-/*
- * Routines to read all bytes from the config EEPROM through MB86965A.
- * It is a MicroWire (3-wire) serial EEPROM with 6-bit address.
- * (93C06 or 93C46.)
- */
-static void
-fe_strobe_eeprom_jli ( u_short bmpr16 )
-{
- /*
- * We must guarantee 1us (or more) interval to access slow
- * EEPROMs. The following redundant code provides enough
- * delay with ISA timing. (Even if the bus clock is "tuned.")
- * Some modification will be needed on faster busses.
- */
- outb( bmpr16, FE_B16_SELECT );
- outb( bmpr16, FE_B16_SELECT | FE_B16_CLOCK );
- outb( bmpr16, FE_B16_SELECT | FE_B16_CLOCK );
- outb( bmpr16, FE_B16_SELECT );
-}
-
-static void
-fe_read_eeprom_jli ( struct fe_softc * sc, u_char * data )
-{
- u_short bmpr16 = sc->ioaddr[ FE_BMPR16 ];
- u_short bmpr17 = sc->ioaddr[ FE_BMPR17 ];
- u_char n, val, bit;
- u_char save16, save17;
-
- /* Save the current value of the EEPROM interface registers. */
- save16 = inb(bmpr16);
- save17 = inb(bmpr17);
-
- /* Read bytes from EEPROM; two bytes per an iteration. */
- for ( n = 0; n < JLI_EEPROM_SIZE / 2; n++ ) {
-
- /* Reset the EEPROM interface. */
- outb( bmpr16, 0x00 );
- outb( bmpr17, 0x00 );
-
- /* Start EEPROM access. */
- outb( bmpr16, FE_B16_SELECT );
- outb( bmpr17, FE_B17_DATA );
- fe_strobe_eeprom_jli( bmpr16 );
-
- /* Pass the iteration count as well as a READ command. */
- val = 0x80 | n;
- for ( bit = 0x80; bit != 0x00; bit >>= 1 ) {
- outb( bmpr17, ( val & bit ) ? FE_B17_DATA : 0 );
- fe_strobe_eeprom_jli( bmpr16 );
- }
- outb( bmpr17, 0x00 );
-
- /* Read a byte. */
- val = 0;
- for ( bit = 0x80; bit != 0x00; bit >>= 1 ) {
- fe_strobe_eeprom_jli( bmpr16 );
- if ( inb( bmpr17 ) & FE_B17_DATA ) {
- val |= bit;
- }
- }
- *data++ = val;
-
- /* Read one more byte. */
- val = 0;
- for ( bit = 0x80; bit != 0x00; bit >>= 1 ) {
- fe_strobe_eeprom_jli( bmpr16 );
- if ( inb( bmpr17 ) & FE_B17_DATA ) {
- val |= bit;
- }
- }
- *data++ = val;
- }
-
-#if 0
- /* Reset the EEPROM interface, again. */
- outb( bmpr16, 0x00 );
- outb( bmpr17, 0x00 );
-#else
- /* Make sure to restore the original value of EEPROM interface
- registers, since we are not yet sure we have MB86965A on
- the address. */
- outb(bmpr17, save17);
- outb(bmpr16, save16);
-#endif
-
-#if 1
- /* Report what we got. */
- if (bootverbose) {
- int i;
- data -= JLI_EEPROM_SIZE;
- for (i = 0; i < JLI_EEPROM_SIZE; i += 16) {
- printf("fe%d: EEPROM(JLI):%3x: %16D\n",
- sc->sc_unit, i, data + i, " ");
- }
- }
-#endif
-}
-
-static void
-fe_init_jli (struct fe_softc * sc)
-{
- /* "Reset" by writing into a magic location. */
- DELAY(200);
- outb(sc->ioaddr[0x1E], inb(sc->ioaddr[0x1E]));
- DELAY(300);
-}
-
-/*
- * SSi 78Q8377A support routines.
- */
-
-#define SSI_EEPROM_SIZE 512
-#define SSI_DIN 0x01
-#define SSI_DAT 0x01
-#define SSI_CSL 0x02
-#define SSI_CLK 0x04
-#define SSI_EEP 0x10
-
-/*
- * Routines to read all bytes from the config EEPROM through 78Q8377A.
- * It is a MicroWire (3-wire) serial EEPROM with 8-bit address. (I.e.,
- * 93C56 or 93C66.)
- *
- * As I don't have SSi manuals, (hmm, an old song again!) I'm not exactly
- * sure the following code is correct... It is just stolen from the
- * C-NET(98)P2 support routine in FreeBSD(98).
- */
-
-static void
-fe_read_eeprom_ssi (struct fe_softc *sc, u_char *data)
-{
- u_short bmpr12 = sc->ioaddr[FE_DLCR12];
- u_char val, bit;
- int n;
- u_char save6, save7, save12;
-
- /* Save the current value for the DLCR registers we are about
- to destroy. */
- save6 = inb(sc->ioaddr[FE_DLCR6]);
- save7 = inb(sc->ioaddr[FE_DLCR7]);
-
- /* Put the 78Q8377A into a state that we can access the EEPROM. */
- outb(sc->ioaddr[FE_DLCR6],
- FE_D6_BBW_WORD | FE_D6_SBW_WORD | FE_D6_DLC_DISABLE);
- outb(sc->ioaddr[FE_DLCR7],
- FE_D7_BYTSWP_LH | FE_D7_RBS_BMPR | FE_D7_RDYPNS | FE_D7_POWER_UP);
-
- /* Save the current value for the BMPR12 register, too. */
- save12 = inb(bmpr12);
-
- /* Read bytes from EEPROM; two bytes per an iteration. */
- for ( n = 0; n < SSI_EEPROM_SIZE / 2; n++ ) {
-
- /* Start EEPROM access */
- outb(bmpr12, SSI_EEP);
- outb(bmpr12, SSI_EEP | SSI_CSL);
-
- /* Send the following four bits to the EEPROM in the
- specified order: a dummy bit, a start bit, and
- command bits (10) for READ. */
- outb(bmpr12, SSI_EEP | SSI_CSL );
- outb(bmpr12, SSI_EEP | SSI_CSL | SSI_CLK ); /* 0 */
- outb(bmpr12, SSI_EEP | SSI_CSL | SSI_DAT);
- outb(bmpr12, SSI_EEP | SSI_CSL | SSI_CLK | SSI_DAT); /* 1 */
- outb(bmpr12, SSI_EEP | SSI_CSL | SSI_DAT);
- outb(bmpr12, SSI_EEP | SSI_CSL | SSI_CLK | SSI_DAT); /* 1 */
- outb(bmpr12, SSI_EEP | SSI_CSL );
- outb(bmpr12, SSI_EEP | SSI_CSL | SSI_CLK ); /* 0 */
-
- /* Pass the iteration count to the chip. */
- for ( bit = 0x80; bit != 0x00; bit >>= 1 ) {
- val = ( n & bit ) ? SSI_DAT : 0;
- outb(bmpr12, SSI_EEP | SSI_CSL | val);
- outb(bmpr12, SSI_EEP | SSI_CSL | SSI_CLK | val);
- }
-
- /* Read a byte. */
- val = 0;
- for ( bit = 0x80; bit != 0x00; bit >>= 1 ) {
- outb(bmpr12, SSI_EEP | SSI_CSL);
- outb(bmpr12, SSI_EEP | SSI_CSL | SSI_CLK);
- if (inb(bmpr12) & SSI_DIN) val |= bit;
- }
- *data++ = val;
-
- /* Read one more byte. */
- val = 0;
- for ( bit = 0x80; bit != 0x00; bit >>= 1 ) {
- outb(bmpr12, SSI_EEP | SSI_CSL);
- outb(bmpr12, SSI_EEP | SSI_CSL | SSI_CLK);
- if (inb(bmpr12) & SSI_DIN) val |= bit;
- }
- *data++ = val;
-
- outb(bmpr12, SSI_EEP);
- }
-
- /* Reset the EEPROM interface. (For now.) */
- outb( bmpr12, 0x00 );
-
- /* Restore the saved register values, for the case that we
- didn't have 78Q8377A at the given address. */
- outb(bmpr12, save12);
- outb(sc->ioaddr[FE_DLCR7], save7);
- outb(sc->ioaddr[FE_DLCR6], save6);
-
-#if 1
- /* Report what we got. */
- if (bootverbose) {
- int i;
- data -= SSI_EEPROM_SIZE;
- for (i = 0; i < SSI_EEPROM_SIZE; i += 16) {
- printf("fe%d: EEPROM(SSI):%3x: %16D\n",
- sc->sc_unit, i, data + i, " ");
- }
- }
-#endif
-}
-
-#define FE_SSI_EEP_IRQ 9 /* Irq ??? */
-#define FE_SSI_EEP_ADDR 16 /* Station(MAC) address */
-#define FE_SSI_EEP_DUPLEX 25 /* Duplex mode ??? */
-
-/*
- * TDK/LANX boards support routines.
- */
-
-/* AX012/AX013 equips an X24C01 chip, which has 128 bytes of memory cells. */
-#define LNX_EEPROM_SIZE 128
-
-/* Bit assignments and command definitions for the serial EEPROM
- interface register in LANX ASIC. */
-#define LNX_SDA_HI 0x08 /* Drive SDA line high (logical 1.) */
-#define LNX_SDA_LO 0x00 /* Drive SDA line low (logical 0.) */
-#define LNX_SDA_FL 0x08 /* Float (don't drive) SDA line. */
-#define LNX_SDA_IN 0x01 /* Mask for reading SDA line. */
-#define LNX_CLK_HI 0x04 /* Drive clock line high (active.) */
-#define LNX_CLK_LO 0x00 /* Drive clock line low (inactive.) */
-
-/* It is assumed that the CLK line is low and SDA is high (float) upon entry. */
-#define LNX_PH(D,K,N) \
- ((LNX_SDA_##D | LNX_CLK_##K) << N)
-#define LNX_CYCLE(D1,D2,D3,D4,K1,K2,K3,K4) \
- (LNX_PH(D1,K1,0)|LNX_PH(D2,K2,8)|LNX_PH(D3,K3,16)|LNX_PH(D4,K4,24))
-
-#define LNX_CYCLE_START LNX_CYCLE(HI,LO,LO,HI, HI,HI,LO,LO)
-#define LNX_CYCLE_STOP LNX_CYCLE(LO,LO,HI,HI, LO,HI,HI,LO)
-#define LNX_CYCLE_HI LNX_CYCLE(HI,HI,HI,HI, LO,HI,LO,LO)
-#define LNX_CYCLE_LO LNX_CYCLE(LO,LO,LO,HI, LO,HI,LO,LO)
-#define LNX_CYCLE_INIT LNX_CYCLE(LO,HI,HI,HI, LO,LO,LO,LO)
-
-static void
-fe_eeprom_cycle_lnx (u_short reg20, u_long cycle)
-{
- outb(reg20, (cycle ) & 0xFF);
- DELAY(15);
- outb(reg20, (cycle >> 8) & 0xFF);
- DELAY(15);
- outb(reg20, (cycle >> 16) & 0xFF);
- DELAY(15);
- outb(reg20, (cycle >> 24) & 0xFF);
- DELAY(15);
-}
-
-static u_char
-fe_eeprom_receive_lnx (u_short reg20)
-{
- u_char dat;
-
- outb(reg20, LNX_CLK_HI | LNX_SDA_FL);
- DELAY(15);
- dat = inb(reg20);
- outb(reg20, LNX_CLK_LO | LNX_SDA_FL);
- DELAY(15);
- return (dat & LNX_SDA_IN);
-}
-
-static void
-fe_read_eeprom_lnx (struct fe_softc *sc, u_char *data)
-{
- int i;
- u_char n, bit, val;
- u_char save20;
- u_short reg20 = sc->ioaddr[0x14];
-
- save20 = inb(reg20);
-
- /* NOTE: DELAY() timing constants are approximately three
- times longer (slower) than the required minimum. This is
- to guarantee a reliable operation under some tough
- conditions... Fortunately, this routine is only called
- during the boot phase, so the speed is less important than
- stability. */
-
-#if 1
- /* Reset the X24C01's internal state machine and put it into
- the IDLE state. We usually don't need this, but *if*
- someone (e.g., probe routine of other driver) write some
- garbage into the register at 0x14, synchronization will be
- lost, and the normal EEPROM access protocol won't work.
- Moreover, as there are no easy way to reset, we need a
- _manoeuvre_ here. (It even lacks a reset pin, so pushing
- the RESET button on the PC doesn't help!) */
- fe_eeprom_cycle_lnx(reg20, LNX_CYCLE_INIT);
- for (i = 0; i < 10; i++) {
- fe_eeprom_cycle_lnx(reg20, LNX_CYCLE_START);
- }
- fe_eeprom_cycle_lnx(reg20, LNX_CYCLE_STOP);
- DELAY(10000);
-#endif
-
- /* Issue a start condition. */
- fe_eeprom_cycle_lnx(reg20, LNX_CYCLE_START);
-
- /* Send seven bits of the starting address (zero, in this
- case) and a command bit for READ. */
- val = 0x01;
- for (bit = 0x80; bit != 0x00; bit >>= 1) {
- if (val & bit) {
- fe_eeprom_cycle_lnx(reg20, LNX_CYCLE_HI);
- } else {
- fe_eeprom_cycle_lnx(reg20, LNX_CYCLE_LO);
- }
- }
-
- /* Receive an ACK bit. */
- if (fe_eeprom_receive_lnx(reg20)) {
- /* ACK was not received. EEPROM is not present (i.e.,
- this board was not a TDK/LANX) or not working
- properly. */
- if (bootverbose) {
- printf("fe%d: no ACK received from EEPROM(LNX)\n",
- sc->sc_unit);
- }
- /* Clear the given buffer to indicate we could not get
- any info. and return. */
- bzero(data, LNX_EEPROM_SIZE);
- goto RET;
- }
-
- /* Read bytes from EEPROM. */
- for (n = 0; n < LNX_EEPROM_SIZE; n++) {
-
- /* Read a byte and store it into the buffer. */
- val = 0x00;
- for (bit = 0x80; bit != 0x00; bit >>= 1) {
- if (fe_eeprom_receive_lnx(reg20)) val |= bit;
- }
- *data++ = val;
-
- /* Acknowledge if we have to read more. */
- if (n < LNX_EEPROM_SIZE - 1) {
- fe_eeprom_cycle_lnx(reg20, LNX_CYCLE_LO);
- }
- }
-
- /* Issue a STOP condition, de-activating the clock line.
- It will be safer to keep the clock line low than to leave
- it high. */
- fe_eeprom_cycle_lnx(reg20, LNX_CYCLE_STOP);
-
- RET:
- outb(reg20, save20);
-
-#if 1
- /* Report what we got. */
- if (bootverbose) {
- data -= LNX_EEPROM_SIZE;
- for (i = 0; i < LNX_EEPROM_SIZE; i += 16) {
- printf("fe%d: EEPROM(LNX):%3x: %16D\n",
- sc->sc_unit, i, data + i, " ");
- }
- }
-#endif
-}
-
-static void
-fe_init_lnx ( struct fe_softc * sc )
-{
- /* Reset the 86960. Do we need this? FIXME. */
- outb(sc->ioaddr[0x12], 0x06);
- DELAY(100);
- outb(sc->ioaddr[0x12], 0x07);
- DELAY(100);
-
- /* Setup IRQ control register on the ASIC. */
- outb(sc->ioaddr[0x14], sc->priv_info);
-}
-
-/*
- * Ungermann-Bass boards support routine.
- */
-static void
-fe_init_ubn ( struct fe_softc * sc )
-{
- /* Do we need this? FIXME. */
- outb(sc->ioaddr[FE_DLCR7],
- sc->proto_dlcr7 | FE_D7_RBS_BMPR | FE_D7_POWER_UP);
- outb(sc->ioaddr[0x18], 0x00);
- DELAY( 200 );
-
- /* Setup IRQ control register on the ASIC. */
- outb(sc->ioaddr[0x14], sc->priv_info);
-}
-
-/*
- * Machine dependent probe routines.
- */
-
-#ifdef PC98
-static int
-fe_probe_fmv ( struct isa_device * dev, struct fe_softc * sc )
-{
- /* PC-98 has no board of this architechture. */
- return 0;
-}
-
-/* ioaddr for RE1000/1000Plus - Very dirty! */
-static u_short ioaddr_re1000[MAXREGISTERS] = {
- 0x0000, 0x0001, 0x0200, 0x0201, 0x0400, 0x0401, 0x0600, 0x0601,
- 0x0800, 0x0801, 0x0a00, 0x0a01, 0x0c00, 0x0c01, 0x0e00, 0x0e01,
- 0x1000, 0x1200, 0x1400, 0x1600, 0x1800, 0x1a00, 0x1c00, 0x1e00,
- 0x1001, 0x1201, 0x1401, 0x1601, 0x1801, 0x1a01, 0x1c01, 0x1e01,
-};
-
-/*
- * Probe and initialization for Allied-Telesis RE1000 series.
- */
-static void
-fe_init_re1000 ( struct fe_softc * sc )
-{
- /* Setup IRQ control register on the ASIC. */
- outb(sc->ioaddr[FE_RE1000_IRQCONF], sc->priv_info);
-}
-
-static int
-fe_probe_re1000 ( struct isa_device * dev, struct fe_softc * sc )
-{
- int i, n;
- u_char sum;
-
- static struct fe_simple_probe_struct probe_table [] = {
- { FE_DLCR2, 0x58, 0x00 },
- { FE_DLCR4, 0x08, 0x00 },
- { 0 }
- };
-
- /* See if the specified I/O address is possible for RE1000. */
- /* [01]D[02468ACE] are allowed. */
- if ((sc->iobase & ~0x10E) != 0xD0) return 0;
-
- /* Setup an I/O address mapping table and some others. */
- fe_softc_defaults(sc);
-
- /* Re-map ioaddr for RE1000. */
- for (i = 0; i < MAXREGISTERS; i++)
- sc->ioaddr[i] = sc->iobase + ioaddr_re1000[i];
-
- /* See if the card is on its address. */
- if (!fe_simple_probe(sc, probe_table)) return 0;
-
- /* Get our station address from EEPROM. */
- inblk(sc, 0x18, sc->sc_enaddr, ETHER_ADDR_LEN);
-
- /* Make sure it is Allied-Telesis's. */
- if (!valid_Ether_p(sc->sc_enaddr, 0x0000F4)) return 0;
-#if 1
- /* Calculate checksum. */
- sum = inb(sc->ioaddr[0x1e]);
- for (i = 0; i < ETHER_ADDR_LEN; i++) {
- sum ^= sc->sc_enaddr[i];
- }
- if (sum != 0) return 0;
-#endif
- /* Setup the board type. */
- sc->typestr = "RE1000";
-
- /* This looks like an RE1000 board. It requires an
- explicit IRQ setting in config. Make sure we have one,
- determining an appropriate value for the IRQ control
- register. */
- switch (dev->id_irq) {
- case IRQ3: n = 0x10; break;
- case IRQ5: n = 0x20; break;
- case IRQ6: n = 0x40; break;
- case IRQ12: n = 0x80; break;
- default:
- fe_irq_failure(sc->typestr,
- sc->sc_unit, dev->id_irq, "3/5/6/12");
- return 0;
- }
- sc->priv_info = inb(sc->ioaddr[FE_RE1000_IRQCONF]) & 0x0f | n;
-
- /* Setup hooks. We need a special initialization procedure. */
- sc->init = fe_init_re1000;
-
- /* The I/O address range is fragmented in the RE1000.
- It occupies 2*16 I/O addresses, by the way. */
- return 2;
-}
-
-/* JLI sub-probe for Allied-Telesis RE1000Plus/ME1500 series. */
-static u_short const *
-fe_probe_jli_re1000p (struct fe_softc * sc, u_char const * eeprom)
-{
- int i;
- static u_short const irqmaps_re1000p [4] = { IRQ3, IRQ5, IRQ6, IRQ12 };
-
- /* Make sure the EEPROM contains Allied-Telesis bit pattern. */
- if (eeprom[1] != 0xFF) return NULL;
- for (i = 2; i < 8; i++) if (eeprom[i] != 0xFF) return NULL;
- for (i = 14; i < 24; i++) if (eeprom[i] != 0xFF) return NULL;
-
- /* Get our station address from EEPROM, and make sure the
- EEPROM contains Allied-Telesis's address. */
- bcopy(eeprom+8, sc->sc_enaddr, ETHER_ADDR_LEN);
- if (!valid_Ether_p(sc->sc_enaddr, 0x0000F4)) return NULL;
-
- /* I don't know any sub-model identification. */
- sc->typestr = "RE1000Plus/ME1500";
-
- /* Returns the IRQ table for the RE1000Plus. */
- return irqmaps_re1000p;
-}
-
-/*
- * Probe for Allied-Telesis RE1000Plus/ME1500 series.
- */
-static int
-fe_probe_jli (struct isa_device * dev, struct fe_softc * sc)
-{
- int i, n;
- int irq;
- u_char eeprom [JLI_EEPROM_SIZE];
- u_short const * irqmap;
-
- static u_short const baseaddr [8] =
- { 0x1D6, 0x1D8, 0x1DA, 0x1D4, 0x0D4, 0x0D2, 0x0D8, 0x0D0 };
- static struct fe_simple_probe_struct const probe_table [] = {
- /* { FE_DLCR1, 0x20, 0x00 }, Doesn't work. */
- { FE_DLCR2, 0x50, 0x00 },
- { FE_DLCR4, 0x08, 0x00 },
- /* { FE_DLCR5, 0x80, 0x00 }, Doesn't work. */
-#if 0
- { FE_BMPR16, 0x1B, 0x00 },
- { FE_BMPR17, 0x7F, 0x00 },
-#endif
- { 0 }
- };
-
- /*
- * See if the specified address is possible for MB86965A JLI mode.
- */
- for (i = 0; i < 8; i++) {
- if (baseaddr[i] == sc->iobase) break;
- }
- if (i == 8) return 0;
-
- /* Fill the softc struct with reasonable default. */
- fe_softc_defaults(sc);
-
- /* Re-map ioaddr for RE1000Plus. */
- for (i = 0; i < MAXREGISTERS; i++)
- sc->ioaddr[i] = sc->iobase + ioaddr_re1000[i];
-
- /*
- * We should test if MB86965A is on the base address now.
- * Unfortunately, it is very hard to probe it reliably, since
- * we have no way to reset the chip under software control.
- * On cold boot, we could check the "signature" bit patterns
- * described in the Fujitsu document. On warm boot, however,
- * we can predict almost nothing about register values.
- */
- if (!fe_simple_probe(sc, probe_table)) return 0;
-
- /* Check if our I/O address matches config info on 86965. */
- n = (inb(sc->ioaddr[FE_BMPR19]) & FE_B19_ADDR) >> FE_B19_ADDR_SHIFT;
- if (baseaddr[n] != sc->iobase) return 0;
-
- /*
- * We are now almost sure we have an MB86965 at the given
- * address. So, read EEPROM through it. We have to write
- * into LSI registers to read from EEPROM. I want to avoid it
- * at this stage, but I cannot test the presence of the chip
- * any further without reading EEPROM. FIXME.
- */
- fe_read_eeprom_jli(sc, eeprom);
-
- /* Make sure that config info in EEPROM and 86965 agree. */
- if (eeprom[FE_EEPROM_CONF] != inb(sc->ioaddr[FE_BMPR19])) {
- return 0;
- }
-
- /* Use 86965 media selection scheme, unless othewise
- specified. It is "AUTO always" and "select with BMPR13".
- This behaviour covers most of the 86965 based board (as
- minimum requirements.) It is backward compatible with
- previous versions, also. */
- sc->mbitmap = MB_HA;
- sc->defmedia = MB_HA;
- sc->msel = fe_msel_965;
-
- /* Perform board-specific probe. */
- if ((irqmap = fe_probe_jli_re1000p(sc, eeprom)) == NULL) return 0;
-
- /* Find the IRQ read from EEPROM. */
- n = (inb(sc->ioaddr[FE_BMPR19]) & FE_B19_IRQ) >> FE_B19_IRQ_SHIFT;
- irq = irqmap[n];
-
- /* Try to determine IRQ setting. */
- if (dev->id_irq == NO_IRQ && irq == NO_IRQ) {
- /* The device must be configured with an explicit IRQ. */
- printf("fe%d: IRQ auto-detection does not work\n",
- sc->sc_unit);
- return 0;
- } else if (dev->id_irq == NO_IRQ && irq != NO_IRQ) {
- /* Just use the probed IRQ value. */
- dev->id_irq = irq;
- } else if (dev->id_irq != NO_IRQ && irq == NO_IRQ) {
- /* No problem. Go ahead. */
- } else if (dev->id_irq == irq) {
- /* Good. Go ahead. */
- } else {
- /* User must be warned in this case. */
- sc->stability |= UNSTABLE_IRQ;
- }
-
- /* Setup a hook, which resets te 86965 when the driver is being
- initialized. This may solve a nasty bug. FIXME. */
- sc->init = fe_init_jli;
-
- /* The I/O address range is fragmented in the RE1000Plus.
- It occupies 2*16 I/O addresses, by the way. */
- return 2;
-}
-
-/*
- * Probe and initialization for Contec C-NET(9N)E series.
- */
-
-/* TODO: Should be in "if_fereg.h" */
-#define FE_CNET9NE_INTR 0x10 /* Interrupt Mask? */
-
-static void
-fe_init_cnet9ne ( struct fe_softc * sc )
-{
- /* Enable interrupt? FIXME. */
- outb(sc->ioaddr[FE_CNET9NE_INTR], 0x10);
-}
-
-static int
-fe_probe_cnet9ne ( struct isa_device * dev, struct fe_softc * sc )
-{
- int i;
-
- static struct fe_simple_probe_struct probe_table [] = {
- { FE_DLCR2, 0x58, 0x00 },
- { FE_DLCR4, 0x08, 0x00 },
- { 0 }
- };
- static u_short ioaddr[MAXREGISTERS - 16] = {
- /* 0x000, 0x001, 0x002, 0x003, 0x004, 0x005, 0x006, 0x007, */
- /* 0x008, 0x009, 0x00a, 0x00b, 0x00c, 0x00d, 0x00e, 0x00f, */
- 0x400, 0x402, 0x404, 0x406, 0x408, 0x40a, 0x40c, 0x40e,
- 0x401, 0x403, 0x405, 0x407, 0x409, 0x40b, 0x40d, 0x40f,
- };
-
- /* See if the specified I/O address is possible for C-NET(9N)E. */
- if (sc->iobase != 0x73D0) return 0;
-
- /* Setup an I/O address mapping table and some others. */
- fe_softc_defaults(sc);
-
- /* Re-map ioaddr for C-NET(9N)E. */
- for (i = 16; i < MAXREGISTERS; i++)
- sc->ioaddr[i] = sc->iobase + ioaddr[i - 16];
-
- /* See if the card is on its address. */
- if (!fe_simple_probe(sc, probe_table)) return 0;
-
- /* Get our station address from EEPROM. */
- inblk(sc, 0x18, sc->sc_enaddr, ETHER_ADDR_LEN);
-
- /* Make sure it is Contec's. */
- if (!valid_Ether_p(sc->sc_enaddr, 0x00804C)) return 0;
-
- /* Determine the card type. */
- if (sc->sc_enaddr[3] == 0x06) {
- sc->typestr = "C-NET(9N)C";
-
- /* We seems to need our own IDENT bits... FIXME. */
- sc->proto_dlcr7 = FE_D7_BYTSWP_LH | FE_D7_IDENT_NICE;
-
- /* C-NET(9N)C requires an explicit IRQ to work. */
- if (dev->id_irq == NO_IRQ) {
- fe_irq_failure(sc->typestr, sc->sc_unit, NO_IRQ, NULL);
- return 0;
- }
- } else {
- sc->typestr = "C-NET(9N)E";
-
- /* C-NET(9N)E works only IRQ5. */
- if (dev->id_irq != IRQ5) {
- fe_irq_failure(sc->typestr,
- sc->sc_unit, dev->id_irq, "5");
- return 0;
- }
-
- /* We need an init hook to initialize ASIC before we start. */
- sc->init = fe_init_cnet9ne;
- }
-
- /* C-NET(9N)E has 64KB SRAM. */
- sc->proto_dlcr6 = FE_D6_BUFSIZ_64KB | FE_D6_TXBSIZ_2x4KB
- | FE_D6_BBW_WORD | FE_D6_SBW_WORD | FE_D6_SRAM;
-
- /* The I/O address range is fragmented in the C-NET(9N)E.
- This is the number of regs at iobase. */
- return 16;
-}
-
-/*
- * Probe for Contec C-NET(98)P2 series.
- * (Logitec LAN-98TP/LAN-98T25P - parhaps)
- */
-static int
-fe_probe_ssi (struct isa_device *dev, struct fe_softc *sc)
-{
- u_char eeprom [SSI_EEPROM_SIZE];
-
- static struct fe_simple_probe_struct probe_table [] = {
- { FE_DLCR2, 0x08, 0x00 },
- { FE_DLCR4, 0x08, 0x00 },
- { 0 }
- };
- static u_short const irqmap[] = {
- /* INT0 INT1 INT2 */
- NO_IRQ, NO_IRQ, NO_IRQ, IRQ3 , NO_IRQ, IRQ5 , IRQ6 , NO_IRQ,
- NO_IRQ, IRQ9 , IRQ10 , NO_IRQ, IRQ12 , IRQ13 , NO_IRQ, NO_IRQ,
- /* INT3 INT41 INT5 INT6 */
- };
-
- /* See if the specified I/O address is possible for 78Q8377A. */
- /* [0-D]3D0 are allowed. */
- if ((sc->iobase & 0xFFF) != 0x3D0) return 0; /* XXX */
-
- /* Fill the softc struct with default values. */
- fe_softc_defaults(sc);
-
- /* See if the card is on its address. */
- if (!fe_simple_probe(sc, probe_table)) return 0;
-
- /* We now have to read the config EEPROM. We should be very
- careful, since doing so destroys a register. (Remember, we
- are not yet sure we have a C-NET(98)P2 board here.) Don't
- remember to select BMPRs bofore reading EEPROM, since other
- register bank may be selected before the probe() is called. */
- fe_read_eeprom_ssi(sc, eeprom);
-
- /* Make sure the Ethernet (MAC) station address is of Contec's. */
- if (!valid_Ether_p(eeprom+FE_SSI_EEP_ADDR, 0x00804C)) return 0;
- bcopy(eeprom+FE_SSI_EEP_ADDR, sc->sc_enaddr, ETHER_ADDR_LEN);
-
- /* Setup the board type. */
- sc->typestr = "C-NET(98)P2";
-
- /* Get IRQ configuration from EEPROM. */
- dev->id_irq = irqmap[eeprom[FE_SSI_EEP_IRQ]];
- if (dev->id_irq == NO_IRQ) {
- fe_irq_failure(sc->typestr,
- sc->sc_unit, dev->id_irq, "3/5/6/9/10/12/13");
- return 0;
- }
-
- /* Get Duplex-mode configuration from EEPROM. */
- sc->proto_dlcr4 |= (eeprom[FE_SSI_EEP_DUPLEX] & FE_D4_DSC);
-
- /* Fill softc struct accordingly. */
- sc->mbitmap = MB_HT;
- sc->defmedia = MB_HT;
-
- /* We have 16 registers. */
- return 16;
-}
-
-/*
- * Probe for TDK LAC-98012/013/025/9N011 - parhaps.
- */
-static int
-fe_probe_lnx (struct isa_device *dev, struct fe_softc *sc)
-{
-#ifndef FE_8BIT_SUPPORT
- printf("fe%d: skip LAC-98012/013(only 16-bit cards are supported)\n",
- sc->sc_unit);
- return 0;
-#else
- int i;
- u_char eeprom [LNX_EEPROM_SIZE];
-
- static struct fe_simple_probe_struct probe_table [] = {
- { FE_DLCR2, 0x58, 0x00 },
- { FE_DLCR4, 0x08, 0x00 },
- { 0 }
- };
-
- /* See if the specified I/O address is possible for TDK/LANX boards. */
- /* 0D0, 4D0, 8D0, and CD0 are allowed. */
- if ((sc->iobase & ~0xC00) != 0xD0) return 0;
-
- /* Fill the softc struct with default values. */
- fe_softc_defaults(sc);
-
- /* Re-map ioaddr for LAC-98.
- * 0x000, 0x002, 0x004, 0x006, 0x008, 0x00a, 0x00c, 0x00e,
- * 0x100, 0x102, 0x104, 0x106, 0x108, 0x10a, 0x10c, 0x10e,
- * 0x200, 0x202, 0x204, 0x206, 0x208, 0x20a, 0x20c, 0x20e,
- * 0x300, 0x302, 0x304, 0x306, 0x308, 0x30a, 0x30c, 0x30e,
- */
- for (i = 0; i < MAXREGISTERS; i++)
- sc->ioaddr[i] = sc->iobase + ((i & 7) << 1) + ((i & 0x18) << 5);
-
- /* See if the card is on its address. */
- if (!fe_simple_probe(sc, probe_table)) return 0;
-
- /* We now have to read the config EEPROM. We should be very
- careful, since doing so destroys a register. (Remember, we
- are not yet sure we have a LAC-98012/98013 board here.) */
- fe_read_eeprom_lnx(sc, eeprom);
-
- /* Make sure the Ethernet (MAC) station address is of TDK/LANX's. */
- if (!valid_Ether_p(eeprom, 0x008098)) return 0;
- bcopy(eeprom, sc->sc_enaddr, ETHER_ADDR_LEN);
-
- /* Setup the board type. */
- sc->typestr = "LAC-98012/98013";
-
- /* This looks like a TDK/LANX board. It requires an
- explicit IRQ setting in config. Make sure we have one,
- determining an appropriate value for the IRQ control
- register. */
- switch (dev->id_irq) {
- case IRQ3 : sc->priv_info = 0x10 | LNX_CLK_LO | LNX_SDA_HI; break;
- case IRQ5 : sc->priv_info = 0x20 | LNX_CLK_LO | LNX_SDA_HI; break;
- case IRQ6 : sc->priv_info = 0x40 | LNX_CLK_LO | LNX_SDA_HI; break;
- case IRQ12: sc->priv_info = 0x80 | LNX_CLK_LO | LNX_SDA_HI; break;
- default:
- fe_irq_failure(sc->typestr,
- sc->sc_unit, dev->id_irq, "3/5/6/12");
- return 0;
- }
-
- /* LAC-98's system bus width is 8-bit. */
- sc->proto_dlcr6 = FE_D6_BUFSIZ_32KB | FE_D6_TXBSIZ_2x2KB
- | FE_D6_BBW_BYTE | FE_D6_SBW_BYTE | FE_D6_SRAM_150ns;
-
- /* Setup hooks. We need a special initialization procedure. */
- sc->init = fe_init_lnx;
-
- /* The I/O address range is fragmented in the LAC-98.
- It occupies 16*4 I/O addresses, by the way. */
- return 16;
-#endif /* FE_8BIT_SUPPORT */
-}
-
-/*
- * Probe for Gateway Communications' old cards.
- * (both as Generic MB86960 probe routine)
- */
-static int
-fe_probe_gwy ( struct isa_device * dev, struct fe_softc * sc )
-{
- static struct fe_simple_probe_struct probe_table [] = {
- /* { FE_DLCR2, 0x70, 0x00 }, */
- { FE_DLCR2, 0x58, 0x00 },
- { FE_DLCR4, 0x08, 0x00 },
- { 0 }
- };
-
- /* I'm not sure which address is possible, so accepts any. FIXME. */
-
- /* Setup an I/O address mapping table and some others. */
- fe_softc_defaults(sc);
-
- /* Does we need to re-map ioaddr? FIXME. */
-
- /* See if the card is on its address. */
- if ( !fe_simple_probe( sc, probe_table ) ) return 0;
-
- /* Get our station address from EEPROM. */
- inblk( sc, 0x18, sc->sc_enaddr, ETHER_ADDR_LEN );
- if (!valid_Ether_p(sc->sc_enaddr, 0x000000)) return 0;
-
- /* Determine the card type. */
- sc->typestr = "Generic MB86960 Ethernet";
- if (valid_Ether_p(sc->sc_enaddr, 0x000061))
- sc->typestr = "Gateway Ethernet (Fujitsu chipset)";
-
- /* Gateway's board requires an explicit IRQ to work, since it
- is not possible to probe the setting of jumpers. */
- if (dev->id_irq == NO_IRQ) {
- fe_irq_failure(sc->typestr, sc->sc_unit, NO_IRQ, NULL);
- return 0;
- }
-
- /* We should change return value when re-mapping ioaddr. FIXME. */
- return 32;
-}
-
-/*
- * Probe for Ungermann-Bass Access/PC N98C+(Model 85152).
- */
-static int
-fe_probe_ubn (struct isa_device * dev, struct fe_softc * sc)
-{
- u_char sum, save7;
- int i;
- static struct fe_simple_probe_struct const probe_table [] = {
- { FE_DLCR2, 0x58, 0x00 },
- { FE_DLCR4, 0x08, 0x00 },
- { 0 }
- };
-
- /* See if the specified I/O address is possible for Access/PC. */
- /* [01][048C]D0 are allowed. */
- if ((sc->iobase & ~0x1C00) != 0xD0) return 0;
-
- /* Setup an I/O address mapping table and some others. */
- fe_softc_defaults(sc);
-
- /* Re-map ioaddr for Access/PC N98C+.
- * 0x000, 0x001, 0x002, 0x003, 0x004, 0x005, 0x006, 0x007,
- * 0x008, 0x009, 0x00a, 0x00b, 0x00c, 0x00d, 0x00e, 0x00f,
- * 0x200, 0x201, 0x202, 0x203, 0x204, 0x205, 0x206, 0x207,
- * 0x208, 0x209, 0x20a, 0x20b, 0x20c, 0x20d, 0x20e, 0x20f,
- */
- for (i = 16; i < MAXREGISTERS; i++)
- sc->ioaddr[i] = sc->iobase + 0x200 - 16 + i;
-
- /* Simple probe. */
- if (!fe_simple_probe(sc, probe_table)) return 0;
-
- /* NOTE: Access/NOTE N98 sometimes freeze when reading station
- address. In case of using it togather with C-NET(9N)C,
- this problem usually happens.
- Writing DLCR7 prevents freezing, but I don't know why. FIXME. */
-
- /* Save the current value for the DLCR7 register we are about
- to destroy. */
- save7 = inb(sc->ioaddr[FE_DLCR7]);
- outb(sc->ioaddr[FE_DLCR7],
- sc->proto_dlcr7 | FE_D7_RBS_BMPR | FE_D7_POWER_UP);
-
- /* Get our station address form ID ROM and make sure it is UBN's. */
- inblk(sc, 0x18, sc->sc_enaddr, ETHER_ADDR_LEN);
- if (!valid_Ether_p(sc->sc_enaddr, 0x00DD01)) goto fail_ubn;
-#if 1
- /* Calculate checksum. */
- sum = inb(sc->ioaddr[0x1e]);
- for (i = 0; i < ETHER_ADDR_LEN; i++) {
- sum ^= sc->sc_enaddr[i];
- }
- if (sum != 0) goto fail_ubn;
-#endif
- /* Setup the board type. */
- sc->typestr = "Access/PC";
-
- /* This looks like an AccessPC/N98C+ board. It requires an
- explicit IRQ setting in config. Make sure we have one,
- determining an appropriate value for the IRQ control
- register. */
- switch (dev->id_irq) {
- case IRQ3: sc->priv_info = 0x01; break;
- case IRQ5: sc->priv_info = 0x02; break;
- case IRQ6: sc->priv_info = 0x04; break;
- case IRQ12: sc->priv_info = 0x08; break;
- default:
- fe_irq_failure(sc->typestr,
- sc->sc_unit, dev->id_irq, "3/5/6/12");
- goto fail_ubn;
- }
-
- /* Setup hooks. We need a special initialization procedure. */
- sc->init = fe_init_ubn;
-
- /* The I/O address range is fragmented in the Access/PC N98C+.
- This is the number of regs at iobase. */
- return 16;
-
-fail_ubn:
- outb(sc->ioaddr[FE_DLCR7], save7);
- return 0;
-}
-
-#else /* !PC98 */
-/*
- * Probe and initialization for Fujitsu FMV-180 series boards
- */
-
-static void
-fe_init_fmv (struct fe_softc *sc)
-{
- /* Initialize ASIC. */
- outb( sc->ioaddr[ FE_FMV3 ], 0 );
- outb( sc->ioaddr[ FE_FMV10 ], 0 );
-
-#if 0
- /* "Refresh" hardware configuration. FIXME. */
- outb( sc->ioaddr[ FE_FMV2 ], inb( sc->ioaddr[ FE_FMV2 ] ) );
-#endif
-
- /* Turn the "master interrupt control" flag of ASIC on. */
- outb( sc->ioaddr[ FE_FMV3 ], FE_FMV3_IRQENB );
-}
-
-static void
-fe_msel_fmv184 (struct fe_softc *sc)
-{
- u_char port;
-
- /* FMV-184 has a special "register" to switch between AUI/BNC.
- Determine the value to write into the register, based on the
- user-specified media selection. */
- port = (IFM_SUBTYPE(sc->media.ifm_media) == IFM_10_2) ? 0x00 : 0x01;
-
- /* The register is #5 on exntesion register bank...
- (Details of the register layout is not yet discovered.) */
- outb(sc->ioaddr[0x1B], 0x46); /* ??? */
- outb(sc->ioaddr[0x1E], 0x04); /* select ex-reg #4. */
- outb(sc->ioaddr[0x1F], 0xC8); /* ??? */
- outb(sc->ioaddr[0x1E], 0x05); /* select ex-reg #5. */
- outb(sc->ioaddr[0x1F], port); /* Switch the media. */
- outb(sc->ioaddr[0x1E], 0x04); /* select ex-reg #4. */
- outb(sc->ioaddr[0x1F], 0x00); /* ??? */
- outb(sc->ioaddr[0x1B], 0x00); /* ??? */
-
- /* Make sure to select "external tranceiver" on MB86964. */
- outb(sc->ioaddr[FE_BMPR13], sc->proto_bmpr13 | FE_B13_PORT_AUI);
-}
-
-static int
-fe_probe_fmv ( struct isa_device * dev, struct fe_softc * sc )
-{
- int n;
-
- static u_short const irqmap [ 4 ] =
- { IRQ3, IRQ7, IRQ10, IRQ15 };
-
- static struct fe_simple_probe_struct const probe_table [] = {
- { FE_DLCR2, 0x71, 0x00 },
- { FE_DLCR4, 0x08, 0x00 },
-
- { FE_FMV0, 0x78, 0x50 }, /* ERRDY+PRRDY */
- { FE_FMV1, 0xB0, 0x00 }, /* FMV-183/4 has 0x48 bits. */
- { FE_FMV3, 0x7F, 0x00 },
-
- { 0 }
- };
-
- /* Board subtypes; it lists known FMV-180 variants. */
- struct subtype {
- u_short mcode;
- u_short mbitmap;
- u_short defmedia;
- char const * str;
- };
- static struct subtype const typelist [] = {
- { 0x0005, MB_HA|MB_HT|MB_H5, MB_HA, "FMV-181" },
- { 0x0105, MB_HA|MB_HT|MB_H5, MB_HA, "FMV-181A" },
- { 0x0003, MB_HM, MB_HM, "FMV-182" },
- { 0x0103, MB_HM, MB_HM, "FMV-182A" },
- { 0x0804, MB_HT, MB_HT, "FMV-183" },
- { 0x0C04, MB_HT, MB_HT, "FMV-183 (on-board)" },
- { 0x0803, MB_H2|MB_H5, MB_H2, "FMV-184" },
- { 0, MB_HA, MB_HA, "unknown FMV-180 (?)" },
- };
- struct subtype const * type;
-
- /* Media indicator and "Hardware revision ID" */
- u_short mcode;
-
- /* See if the specified address is possible for FMV-180
- series. 220, 240, 260, 280, 2A0, 2C0, 300, and 340 are
- allowed for all boards, and 200, 2E0, 320, 360, 380, 3A0,
- 3C0, and 3E0 for PnP boards. */
- if ((sc->iobase & ~0x1E0) != 0x200) return 0;
-
- /* Setup an I/O address mapping table and some others. */
- fe_softc_defaults(sc);
-
- /* Simple probe. */
- if (!fe_simple_probe(sc, probe_table)) return 0;
-
- /* Get our station address from EEPROM, and make sure it is
- Fujitsu's. */
- inblk(sc, FE_FMV4, sc->sc_enaddr, ETHER_ADDR_LEN);
- if (!valid_Ether_p(sc->sc_enaddr, 0x00000E)) return 0;
-
- /* Find the supported media and "hardware revision" to know
- the model identification. */
- mcode = (inb(sc->ioaddr[FE_FMV0]) & FE_FMV0_MEDIA)
- | ((inb(sc->ioaddr[FE_FMV1]) & FE_FMV1_REV) << 8);
-
- /* Determine the card type. */
- for (type = typelist; type->mcode != 0; type++) {
- if (type->mcode == mcode) break;
- }
- if (type->mcode == 0) {
- /* Unknown card type... Hope the driver works. */
- sc->stability |= UNSTABLE_TYPE;
- if (bootverbose) {
- printf("fe%d: unknown config: %x-%x-%x-%x\n",
- sc->sc_unit,
- inb(sc->ioaddr[FE_FMV0]),
- inb(sc->ioaddr[FE_FMV1]),
- inb(sc->ioaddr[FE_FMV2]),
- inb(sc->ioaddr[FE_FMV3]));
- }
- }
-
- /* Setup the board type and media information. */
- sc->typestr = type->str;
- sc->mbitmap = type->mbitmap;
- sc->defmedia = type->defmedia;
- sc->msel = fe_msel_965;
-
- if (type->mbitmap == (MB_H2 | MB_H5)) {
- /* FMV184 requires a special media selection procedure. */
- sc->msel = fe_msel_fmv184;
- }
-
- /*
- * An FMV-180 has been probed.
- * Determine which IRQ to be used.
- *
- * In this version, we give a priority to the kernel config file.
- * If the EEPROM and config don't match, say it to the user for
- * an attention.
- */
- n = ( inb( sc->ioaddr[ FE_FMV2 ] ) & FE_FMV2_IRS )
- >> FE_FMV2_IRS_SHIFT;
- if ( dev->id_irq == NO_IRQ ) {
- /* Just use the probed value. */
- dev->id_irq = irqmap[ n ];
- } else if ( dev->id_irq != irqmap[ n ] ) {
- /* Don't match. */
- sc->stability |= UNSTABLE_IRQ;
- }
-
- /* We need an init hook to initialize ASIC before we start. */
- sc->init = fe_init_fmv;
-
- /*
- * That's all. FMV-180 occupies 32 I/O addresses, by the way.
- */
- return 32;
-}
-
-/*
- * Fujitsu MB86965 JLI mode probe routines.
- *
- * 86965 has a special operating mode called JLI (mode 0), under which
- * the chip interfaces with ISA bus with a software-programmable
- * configuration. (The Fujitsu document calls the feature "Plug and
- * play," but it is not compatible with the ISA-PnP spec. designed by
- * Intel and Microsoft.) Ethernet cards designed to use JLI are
- * almost same, but there are two things which require board-specific
- * probe routines: EEPROM layout and IRQ pin connection.
- *
- * JLI provides a handy way to access EEPROM which should contains the
- * chip configuration information (such as I/O port address) as well
- * as Ethernet station (MAC) address. The chip configuration info. is
- * stored on a fixed location. However, the station address can be
- * located anywhere in the EEPROM; it is up to the board designer to
- * determine the location. (The manual just says "somewhere in the
- * EEPROM.") The fe driver must somehow find out the correct
- * location.
- *
- * Another problem resides in the IRQ pin connection. JLI provides a
- * user to choose an IRQ from up to four predefined IRQs. The 86965
- * chip has a register to select one out of the four possibilities.
- * However, the selection is against the four IRQ pins on the chip.
- * (So-called IRQ-A, -B, -C and -D.) It is (again) up to the board
- * designer to determine which pin to connect which IRQ line on the
- * ISA bus. We need a vendor (or model, for some vendor) specific IRQ
- * mapping table.
- *
- * The routine fe_probe_jli() provides all probe and initialization
- * processes which are common to all JLI implementation, and sub-probe
- * routines supply board-specific actions.
- *
- * JLI sub-probe routine has the following template:
- *
- * u_short const * func (struct fe_softc * sc, u_char const * eeprom);
- *
- * where eeprom is a pointer to an array of 32 byte data read from the
- * config EEPROM on the board. It retuns an IRQ mapping table for the
- * board, when the corresponding implementation is detected. It
- * returns a NULL otherwise.
- *
- * Primary purpose of the functin is to analize the config EEPROM,
- * determine if it matches with the pattern of that of supported card,
- * and extract necessary information from it. One of the information
- * expected to be extracted from EEPROM is the Ethernet station (MAC)
- * address, which must be set to the softc table of the interface by
- * the board-specific routine.
- */
-
-/* JLI sub-probe for Allied-Telesyn/Allied-Telesis AT1700/RE2000 series. */
-static u_short const *
-fe_probe_jli_ati (struct fe_softc * sc, u_char const * eeprom)
-{
- int i;
- static u_short const irqmaps_ati [4][4] =
- {
- { IRQ3, IRQ4, IRQ5, IRQ9 },
- { IRQ10, IRQ11, IRQ12, IRQ15 },
- { IRQ3, IRQ11, IRQ5, IRQ15 },
- { IRQ10, IRQ11, IRQ14, IRQ15 },
- };
-
- /* Make sure the EEPROM contains Allied-Telesis/Allied-Telesyn
- bit pattern. */
- if (eeprom[1] != 0x00) return NULL;
- for (i = 2; i < 8; i++) if (eeprom[i] != 0xFF) return NULL;
- for (i = 14; i < 24; i++) if (eeprom[i] != 0xFF) return NULL;
-
- /* Get our station address from EEPROM, and make sure the
- EEPROM contains ATI's address. */
- bcopy(eeprom+8, sc->sc_enaddr, ETHER_ADDR_LEN);
- if (!valid_Ether_p(sc->sc_enaddr, 0x0000F4)) return NULL;
-
- /*
- * The following model identification codes are stolen
- * from the NetBSD port of the fe driver. My reviewers
- * suggested minor revision.
- */
-
- /* Determine the card type. */
- switch (eeprom[FE_ATI_EEP_MODEL]) {
- case FE_ATI_MODEL_AT1700T:
- sc->typestr = "AT-1700T/RE2001";
- sc->mbitmap = MB_HT;
- sc->defmedia = MB_HT;
- break;
- case FE_ATI_MODEL_AT1700BT:
- sc->typestr = "AT-1700BT/RE2003";
- sc->mbitmap = MB_HA | MB_HT | MB_H2;
- break;
- case FE_ATI_MODEL_AT1700FT:
- sc->typestr = "AT-1700FT/RE2009";
- sc->mbitmap = MB_HA | MB_HT | MB_HF;
- break;
- case FE_ATI_MODEL_AT1700AT:
- sc->typestr = "AT-1700AT/RE2005";
- sc->mbitmap = MB_HA | MB_HT | MB_H5;
- break;
- default:
- sc->typestr = "unknown AT-1700/RE2000";
- sc->stability |= UNSTABLE_TYPE | UNSTABLE_IRQ;
- break;
- }
-
-#if 0
- /* Should we extract default media from eeprom? Linux driver
- for AT1700 does it, although previous releases of FreeBSD
- don't. FIXME. */
- /* Determine the default media selection from the config
- EEPROM. The byte at offset EEP_MEDIA is believed to
- contain BMPR13 value to be set. We just ignore STP bit or
- squelch bit, since we don't support those. (It is
- intentional.) */
- switch (eeprom[FE_ATI_EEP_MEDIA] & FE_B13_PORT) {
- case FE_B13_AUTO:
- sc->defmedia = MB_HA;
- break;
- case FE_B13_TP:
- sc->defmedia = MB_HT;
- break;
- case FE_B13_AUI:
- sc->defmedia = sc->mbitmap & (MB_H2|MB_H5|MB_H5); /*XXX*/
- break;
- default:
- sc->defmedia = MB_HA;
- break;
- }
-
- /* Make sure the default media is compatible with the supported
- ones. */
- if ((sc->defmedia & sc->mbitmap) == 0) {
- if (sc->defmedia == MB_HA) {
- sc->defmedia = MB_HT;
- } else {
- sc->defmedia = MB_HA;
- }
- }
-#endif
-
- /*
- * Try to determine IRQ settings.
- * Different models use different ranges of IRQs.
- */
- switch ((eeprom[FE_ATI_EEP_REVISION] & 0xf0)
- |(eeprom[FE_ATI_EEP_MAGIC] & 0x04)) {
- case 0x30: case 0x34: return irqmaps_ati[3];
- case 0x10: case 0x14:
- case 0x50: case 0x54: return irqmaps_ati[2];
- case 0x44: case 0x64: return irqmaps_ati[1];
- default: return irqmaps_ati[0];
- }
-}
-
-/* JLI sub-probe and msel hook for ICL Ethernet. */
-
-static void
-fe_msel_icl (struct fe_softc *sc)
-{
- u_char d4;
-
- /* Switch between UTP and "external tranceiver" as always. */
- fe_msel_965(sc);
-
- /* The board needs one more bit (on DLCR4) be set appropriately. */
- if (IFM_SUBTYPE(sc->media.ifm_media) == IFM_10_5) {
- d4 = sc->proto_dlcr4 | FE_D4_CNTRL;
- } else {
- d4 = sc->proto_dlcr4 & ~FE_D4_CNTRL;
- }
- outb(sc->ioaddr[FE_DLCR4], d4);
-}
-
-static u_short const *
-fe_probe_jli_icl (struct fe_softc * sc, u_char const * eeprom)
-{
- int i;
- u_short defmedia;
- u_char d6;
- static u_short const irqmap_icl [4] = { IRQ9, IRQ10, IRQ5, IRQ15 };
-
- /* Make sure the EEPROM contains ICL bit pattern. */
- for (i = 24; i < 39; i++) {
- if (eeprom[i] != 0x20 && (eeprom[i] & 0xF0) != 0x30) return NULL;
- }
- for (i = 112; i < 122; i++) {
- if (eeprom[i] != 0x20 && (eeprom[i] & 0xF0) != 0x30) return NULL;
- }
-
- /* Make sure the EEPROM contains ICL's permanent station
- address. If it isn't, probably this board is not an
- ICL's. */
- if (!valid_Ether_p(eeprom+122, 0x00004B)) return NULL;
-
- /* Check if the "configured" Ethernet address in the EEPROM is
- valid. Use it if it is, or use the "permanent" address instead. */
- if (valid_Ether_p(eeprom+4, 0x020000)) {
- /* The configured address is valid. Use it. */
- bcopy(eeprom+4, sc->sc_enaddr, ETHER_ADDR_LEN);
- } else {
- /* The configured address is invalid. Use permanent. */
- bcopy(eeprom+122, sc->sc_enaddr, ETHER_ADDR_LEN);
- }
-
- /* Determine model and supported media. */
- switch (eeprom[0x5E]) {
- case 0:
- sc->typestr = "EtherTeam16i/COMBO";
- sc->mbitmap = MB_HA | MB_HT | MB_H5 | MB_H2;
- break;
- case 1:
- sc->typestr = "EtherTeam16i/TP";
- sc->mbitmap = MB_HT;
- break;
- case 2:
- sc->typestr = "EtherTeam16i/ErgoPro";
- sc->mbitmap = MB_HA | MB_HT | MB_H5;
- break;
- case 4:
- sc->typestr = "EtherTeam16i/DUO";
- sc->mbitmap = MB_HA | MB_HT | MB_H2;
- break;
- default:
- sc->typestr = "EtherTeam16i";
- sc->stability |= UNSTABLE_TYPE;
- if (bootverbose) {
- printf("fe%d: unknown model code %02x for EtherTeam16i\n",
- sc->sc_unit, eeprom[0x5E]);
- }
- break;
- }
-
- /* I'm not sure the following msel hook is required by all
- models or COMBO only... FIXME. */
- sc->msel = fe_msel_icl;
-
- /* Make the configured media selection the default media. */
- switch (eeprom[0x28]) {
- case 0: defmedia = MB_HA; break;
- case 1: defmedia = MB_H5; break;
- case 2: defmedia = MB_HT; break;
- case 3: defmedia = MB_H2; break;
- default:
- if (bootverbose) {
- printf("fe%d: unknown default media: %02x\n",
- sc->sc_unit, eeprom[0x28]);
- }
- defmedia = MB_HA;
- break;
- }
-
- /* Make sure the default media is compatible with the
- supported media. */
- if ((defmedia & sc->mbitmap) == 0) {
- if (bootverbose) {
- printf("fe%d: default media adjusted\n", sc->sc_unit);
- }
- defmedia = sc->mbitmap;
- }
-
- /* Keep the determined default media. */
- sc->defmedia = defmedia;
-
- /* ICL has "fat" models. We have to program 86965 to properly
- reflect the hardware. */
- d6 = sc->proto_dlcr6 & ~(FE_D6_BUFSIZ | FE_D6_BBW);
- switch ((eeprom[0x61] << 8) | eeprom[0x60]) {
- case 0x2008: d6 |= FE_D6_BUFSIZ_32KB | FE_D6_BBW_BYTE; break;
- case 0x4010: d6 |= FE_D6_BUFSIZ_64KB | FE_D6_BBW_WORD; break;
- default:
- /* We can't support it, since we don't know which bits
- to set in DLCR6. */
- printf("fe%d: unknown SRAM config for ICL\n", sc->sc_unit);
- return NULL;
- }
- sc->proto_dlcr6 = d6;
-
- /* Returns the IRQ table for the ICL board. */
- return irqmap_icl;
-}
-
-/* JLI sub-probe for RATOC REX-5586/5587. */
-static u_short const *
-fe_probe_jli_rex (struct fe_softc * sc, u_char const * eeprom)
-{
- int i;
- static u_short const irqmap_rex [4] = { IRQ3, IRQ4, IRQ5, NO_IRQ };
-
- /* Make sure the EEPROM contains RATOC's config pattern. */
- if (eeprom[1] != eeprom[0]) return NULL;
- for (i = 8; i < 32; i++) if (eeprom[i] != 0xFF) return NULL;
-
- /* Get our station address from EEPROM. Note that RATOC
- stores it "byte-swapped" in each word. (I don't know why.)
- So, we just can't use bcopy().*/
- sc->sc_enaddr[0] = eeprom[3];
- sc->sc_enaddr[1] = eeprom[2];
- sc->sc_enaddr[2] = eeprom[5];
- sc->sc_enaddr[3] = eeprom[4];
- sc->sc_enaddr[4] = eeprom[7];
- sc->sc_enaddr[5] = eeprom[6];
-
- /* Make sure the EEPROM contains RATOC's station address. */
- if (!valid_Ether_p(sc->sc_enaddr, 0x00C0D0)) return NULL;
-
- /* I don't know any sub-model identification. */
- sc->typestr = "REX-5586/5587";
-
- /* Returns the IRQ for the RATOC board. */
- return irqmap_rex;
-}
-
-/* JLI sub-probe for Unknown board. */
-static u_short const *
-fe_probe_jli_unk (struct fe_softc * sc, u_char const * eeprom)
-{
- int i, n, romsize;
- static u_short const irqmap [4] = { NO_IRQ, NO_IRQ, NO_IRQ, NO_IRQ };
-
- /* The generic JLI probe considered this board has an 86965
- in JLI mode, but any other board-specific routines could
- not find the matching implementation. So, we "guess" the
- location by looking for a bit pattern which looks like a
- MAC address. */
-
- /* Determine how large the EEPROM is. */
- for (romsize = JLI_EEPROM_SIZE/2; romsize > 16; romsize >>= 1) {
- for (i = 0; i < romsize; i++) {
- if (eeprom[i] != eeprom[i+romsize]) break;
- }
- if (i < romsize) break;
- }
- romsize <<= 1;
-
- /* Look for a bit pattern which looks like a MAC address. */
- for (n = 2; n <= romsize - ETHER_ADDR_LEN; n += 2) {
- if (!valid_Ether_p(eeprom + n, 0x000000)) continue;
- }
-
- /* If no reasonable address was found, we can't go further. */
- if (n > romsize - ETHER_ADDR_LEN) return NULL;
-
- /* Extract our (guessed) station address. */
- bcopy(eeprom+n, sc->sc_enaddr, ETHER_ADDR_LEN);
-
- /* We are not sure what type of board it is... */
- sc->typestr = "(unknown JLI)";
- sc->stability |= UNSTABLE_TYPE | UNSTABLE_MAC;
-
- /* Returns the totally unknown IRQ mapping table. */
- return irqmap;
-}
-
-/*
- * Probe and initialization for all JLI implementations.
- */
-
-static int
-fe_probe_jli (struct isa_device * dev, struct fe_softc * sc)
-{
- int i, n;
- int irq;
- u_char eeprom [JLI_EEPROM_SIZE];
- u_short const * irqmap;
-
- static u_short const baseaddr [8] =
- { 0x260, 0x280, 0x2A0, 0x240, 0x340, 0x320, 0x380, 0x300 };
- static struct fe_simple_probe_struct const probe_table [] = {
- { FE_DLCR1, 0x20, 0x00 },
- { FE_DLCR2, 0x50, 0x00 },
- { FE_DLCR4, 0x08, 0x00 },
- { FE_DLCR5, 0x80, 0x00 },
-#if 0
- { FE_BMPR16, 0x1B, 0x00 },
- { FE_BMPR17, 0x7F, 0x00 },
-#endif
- { 0 }
- };
-
- /*
- * See if the specified address is possible for MB86965A JLI mode.
- */
- for (i = 0; i < 8; i++) {
- if (baseaddr[i] == sc->iobase) break;
- }
- if (i == 8) return 0;
-
- /* Fill the softc struct with reasonable default. */
- fe_softc_defaults(sc);
-
- /*
- * We should test if MB86965A is on the base address now.
- * Unfortunately, it is very hard to probe it reliably, since
- * we have no way to reset the chip under software control.
- * On cold boot, we could check the "signature" bit patterns
- * described in the Fujitsu document. On warm boot, however,
- * we can predict almost nothing about register values.
- */
- if (!fe_simple_probe(sc, probe_table)) return 0;
-
- /* Check if our I/O address matches config info on 86965. */
- n = (inb(sc->ioaddr[FE_BMPR19]) & FE_B19_ADDR) >> FE_B19_ADDR_SHIFT;
- if (baseaddr[n] != sc->iobase) return 0;
-
- /*
- * We are now almost sure we have an MB86965 at the given
- * address. So, read EEPROM through it. We have to write
- * into LSI registers to read from EEPROM. I want to avoid it
- * at this stage, but I cannot test the presence of the chip
- * any further without reading EEPROM. FIXME.
- */
- fe_read_eeprom_jli(sc, eeprom);
-
- /* Make sure that config info in EEPROM and 86965 agree. */
- if (eeprom[FE_EEPROM_CONF] != inb(sc->ioaddr[FE_BMPR19])) {
- return 0;
- }
-
- /* Use 86965 media selection scheme, unless othewise
- specified. It is "AUTO always" and "select with BMPR13."
- This behaviour covers most of the 86965 based board (as
- minimum requirements.) It is backward compatible with
- previous versions, also. */
- sc->mbitmap = MB_HA;
- sc->defmedia = MB_HA;
- sc->msel = fe_msel_965;
-
- /* Perform board-specific probe, one by one. Note that the
- order of probe is important and should not be changed
- arbitrarily. */
- if ((irqmap = fe_probe_jli_ati(sc, eeprom)) == NULL
- && (irqmap = fe_probe_jli_rex(sc, eeprom)) == NULL
- && (irqmap = fe_probe_jli_icl(sc, eeprom)) == NULL
- && (irqmap = fe_probe_jli_unk(sc, eeprom)) == NULL) return 0;
-
- /* Find the IRQ read from EEPROM. */
- n = (inb(sc->ioaddr[FE_BMPR19]) & FE_B19_IRQ) >> FE_B19_IRQ_SHIFT;
- irq = irqmap[n];
-
- /* Try to determine IRQ setting. */
- if (dev->id_irq == NO_IRQ && irq == NO_IRQ) {
- /* The device must be configured with an explicit IRQ. */
- printf("fe%d: IRQ auto-detection does not work\n",
- sc->sc_unit);
- return 0;
- } else if (dev->id_irq == NO_IRQ && irq != NO_IRQ) {
- /* Just use the probed IRQ value. */
- dev->id_irq = irq;
- } else if (dev->id_irq != NO_IRQ && irq == NO_IRQ) {
- /* No problem. Go ahead. */
- } else if (dev->id_irq == irq) {
- /* Good. Go ahead. */
- } else {
- /* User must be warned in this case. */
- sc->stability |= UNSTABLE_IRQ;
- }
-
- /* Setup a hook, which resets te 86965 when the driver is being
- initialized. This may solve a nasty bug. FIXME. */
- sc->init = fe_init_jli;
-
- /*
- * That's all. 86965 JLI occupies 32 I/O addresses, by the way.
- */
- return 32;
-}
-
-/* Probe for TDK LAK-AX031, which is an SSi 78Q8377A based board. */
-
-static int
-fe_probe_ssi (struct isa_device *dev, struct fe_softc *sc)
-{
- u_char eeprom [SSI_EEPROM_SIZE];
-
- static struct fe_simple_probe_struct probe_table [] = {
- { FE_DLCR2, 0x08, 0x00 },
- { FE_DLCR4, 0x08, 0x00 },
- { 0 }
- };
-
- /* See if the specified I/O address is possible for 78Q8377A. */
- if ((sc->iobase & ~0x3F0) != 0x000) return 0;
-
- /* Fill the softc struct with default values. */
- fe_softc_defaults(sc);
-
- /* See if the card is on its address. */
- if (!fe_simple_probe(sc, probe_table)) return 0;
-
- /* We now have to read the config EEPROM. We should be very
- careful, since doing so destroys a register. (Remember, we
- are not yet sure we have a LAK-AX031 board here.) Don't
- remember to select BMPRs bofore reading EEPROM, since other
- register bank may be selected before the probe() is called. */
- fe_read_eeprom_ssi(sc, eeprom);
-
- /* Make sure the Ethernet (MAC) station address is of TDK's. */
- if (!valid_Ether_p(eeprom+FE_SSI_EEP_ADDR, 0x008098)) return 0;
- bcopy(eeprom+FE_SSI_EEP_ADDR, sc->sc_enaddr, ETHER_ADDR_LEN);
-
- /* This looks like a TDK-AX031 board. It requires an explicit
- IRQ setting in config, since we currently don't know how we
- can find the IRQ value assigned by ISA PnP manager. */
- if (dev->id_irq == NO_IRQ) {
- fe_irq_failure("LAK-AX031", sc->sc_unit, dev->id_irq, NULL);
- return 0;
- }
-
- /* Fill softc struct accordingly. */
- sc->typestr = "LAK-AX031";
- sc->mbitmap = MB_HT;
- sc->defmedia = MB_HT;
-
- /* We have 16 registers. */
- return 16;
-}
-
-/*
- * Probe and initialization for TDK/LANX LAC-AX012/013 boards.
- */
-static int
-fe_probe_lnx (struct isa_device *dev, struct fe_softc *sc)
-{
- u_char eeprom [LNX_EEPROM_SIZE];
-
- static struct fe_simple_probe_struct probe_table [] = {
- { FE_DLCR2, 0x58, 0x00 },
- { FE_DLCR4, 0x08, 0x00 },
- { 0 }
- };
-
- /* See if the specified I/O address is possible for TDK/LANX boards. */
- /* 300, 320, 340, and 360 are allowed. */
- if ((sc->iobase & ~0x060) != 0x300) return 0;
-
- /* Fill the softc struct with default values. */
- fe_softc_defaults(sc);
-
- /* See if the card is on its address. */
- if (!fe_simple_probe(sc, probe_table)) return 0;
-
- /* We now have to read the config EEPROM. We should be very
- careful, since doing so destroys a register. (Remember, we
- are not yet sure we have a LAC-AX012/AX013 board here.) */
- fe_read_eeprom_lnx(sc, eeprom);
-
- /* Make sure the Ethernet (MAC) station address is of TDK/LANX's. */
- if (!valid_Ether_p(eeprom, 0x008098)) return 0;
- bcopy(eeprom, sc->sc_enaddr, ETHER_ADDR_LEN);
-
- /* This looks like a TDK/LANX board. It requires an
- explicit IRQ setting in config. Make sure we have one,
- determining an appropriate value for the IRQ control
- register. */
- switch (dev->id_irq) {
- case IRQ3: sc->priv_info = 0x40 | LNX_CLK_LO | LNX_SDA_HI; break;
- case IRQ4: sc->priv_info = 0x20 | LNX_CLK_LO | LNX_SDA_HI; break;
- case IRQ5: sc->priv_info = 0x10 | LNX_CLK_LO | LNX_SDA_HI; break;
- case IRQ9: sc->priv_info = 0x80 | LNX_CLK_LO | LNX_SDA_HI; break;
- default:
- fe_irq_failure("LAC-AX012/AX013",
- sc->sc_unit, dev->id_irq, "3/4/5/9");
- return 0;
- }
-
- /* Fill softc struct accordingly. */
- sc->typestr = "LAC-AX012/AX013";
- sc->init = fe_init_lnx;
-
- /* We have 32 registers. */
- return 32;
-}
-
-/*
- * Probe and initialization for Gateway Communications' old cards.
- */
-static int
-fe_probe_gwy ( struct isa_device * dev, struct fe_softc * sc )
-{
- static struct fe_simple_probe_struct probe_table [] = {
- /* { FE_DLCR2, 0x70, 0x00 }, */
- { FE_DLCR2, 0x58, 0x00 },
- { FE_DLCR4, 0x08, 0x00 },
- { 0 }
- };
-
- /* See if the specified I/O address is possible for Gateway boards. */
- if ((sc->iobase & ~0x1E0) != 0x200) return 0;
-
- /* Setup an I/O address mapping table and some others. */
- fe_softc_defaults(sc);
-
- /* See if the card is on its address. */
- if ( !fe_simple_probe( sc, probe_table ) ) return 0;
-
- /* Get our station address from EEPROM. */
- inblk( sc, 0x18, sc->sc_enaddr, ETHER_ADDR_LEN );
-
- /* Make sure it is Gateway Communication's. */
- if (!valid_Ether_p(sc->sc_enaddr, 0x000061)) return 0;
-
- /* Gateway's board requires an explicit IRQ to work, since it
- is not possible to probe the setting of jumpers. */
- if (dev->id_irq == NO_IRQ) {
- fe_irq_failure("Gateway Ethernet", sc->sc_unit, NO_IRQ, NULL);
- return 0;
- }
-
- /* Fill softc struct accordingly. */
- sc->typestr = "Gateway Ethernet (Fujitsu chipset)";
-
- /* That's all. The card occupies 32 I/O addresses, as always. */
- return 32;
-}
-
-/* Probe and initialization for Ungermann-Bass Network
- K.K. "Access/PC" boards. */
-static int
-fe_probe_ubn (struct isa_device * dev, struct fe_softc * sc)
-{
-#if 0
- u_char sum;
-#endif
- static struct fe_simple_probe_struct const probe_table [] = {
- { FE_DLCR2, 0x58, 0x00 },
- { FE_DLCR4, 0x08, 0x00 },
- { 0 }
- };
-
- /* See if the specified I/O address is possible for AccessPC/ISA. */
- if ((sc->iobase & ~0x0E0) != 0x300) return 0;
-
- /* Setup an I/O address mapping table and some others. */
- fe_softc_defaults(sc);
-
- /* Simple probe. */
- if (!fe_simple_probe(sc, probe_table)) return 0;
-
- /* Get our station address form ID ROM and make sure it is UBN's. */
- inblk(sc, 0x18, sc->sc_enaddr, ETHER_ADDR_LEN);
- if (!valid_Ether_p(sc->sc_enaddr, 0x00DD01)) return 0;
-#if 0
- /* Calculate checksum. */
- sum = inb(sc->ioaddr[0x1e]);
- for (i = 0; i < ETHER_ADDR_LEN; i++) {
- sum ^= sc->sc_enaddr[i];
- }
- if (sum != 0) return 0;
-#endif
- /* This looks like an AccessPC/ISA board. It requires an
- explicit IRQ setting in config. Make sure we have one,
- determining an appropriate value for the IRQ control
- register. */
- switch (dev->id_irq) {
- case IRQ3: sc->priv_info = 0x02; break;
- case IRQ4: sc->priv_info = 0x04; break;
- case IRQ5: sc->priv_info = 0x08; break;
- case IRQ10: sc->priv_info = 0x10; break;
- default:
- fe_irq_failure("Access/PC",
- sc->sc_unit, dev->id_irq, "3/4/5/10");
- return 0;
- }
-
- /* Fill softc struct accordingly. */
- sc->typestr = "Access/PC";
- sc->init = fe_init_ubn;
-
- /* We have 32 registers. */
- return 32;
-}
-#endif /* PC98 */
-
-#if NCARD > 0
-/*
- * Probe and initialization for Fujitsu MBH10302 PCMCIA Ethernet interface.
- * Note that this is for 10302 only; MBH10304 is handled by fe_probe_tdk().
- */
-
-static void
-fe_init_mbh ( struct fe_softc * sc )
-{
- /* Minimal initialization of 86960. */
- DELAY( 200 );
- outb( sc->ioaddr[ FE_DLCR6 ], sc->proto_dlcr6 | FE_D6_DLC_DISABLE );
- DELAY( 200 );
-
- /* Disable all interrupts. */
- outb( sc->ioaddr[ FE_DLCR2 ], 0 );
- outb( sc->ioaddr[ FE_DLCR3 ], 0 );
-
- /* Enable master interrupt flag. */
- outb( sc->ioaddr[ FE_MBH0 ], FE_MBH0_MAGIC | FE_MBH0_INTR_ENABLE );
-}
-
-static int
-fe_probe_mbh ( struct isa_device * dev, struct fe_softc * sc )
-{
- static struct fe_simple_probe_struct probe_table [] = {
- { FE_DLCR2, 0x58, 0x00 },
- { FE_DLCR4, 0x08, 0x00 },
- { FE_DLCR6, 0xFF, 0xB6 },
- { 0 }
- };
-
-#ifdef DIAGNOSTIC
- /* We need an explicit IRQ. */
- if (dev->id_irq == NO_IRQ) return 0;
-#endif
-
- /* Ethernet MAC address should *NOT* have been given by pccardd,
- if this is a true MBH10302; i.e., Ethernet address must be
- "all-zero" upon entry. */
- if (sc->sc_enaddr[0] || sc->sc_enaddr[1] || sc->sc_enaddr[2] ||
- sc->sc_enaddr[3] || sc->sc_enaddr[4] || sc->sc_enaddr[5]) {
- return 0;
- }
-
- /* Fill the softc struct with default values. */
- fe_softc_defaults(sc);
-
- /*
- * See if MBH10302 is on its address.
- * I'm not sure the following probe code works. FIXME.
- */
- if ( !fe_simple_probe( sc, probe_table ) ) return 0;
-
- /* Get our station address from EEPROM. */
- inblk( sc, FE_MBH10, sc->sc_enaddr, ETHER_ADDR_LEN );
-
- /* Make sure we got a valid station address. */
- if (!valid_Ether_p(sc->sc_enaddr, 0)) return 0;
-
- /* Determine the card type. */
- sc->typestr = "MBH10302 (PCMCIA)";
-
- /* We seems to need our own IDENT bits... FIXME. */
- sc->proto_dlcr7 = FE_D7_BYTSWP_LH | FE_D7_IDENT_NICE;
-
- /* Setup hooks. We need a special initialization procedure. */
- sc->init = fe_init_mbh;
-
- /*
- * That's all. MBH10302 occupies 32 I/O addresses, by the way.
- */
- return 32;
-}
-
-/*
- * Probe and initialization for TDK/CONTEC PCMCIA Ethernet interface.
- * by MASUI Kenji <masui@cs.titech.ac.jp>
- *
- * (Contec uses TDK Ethenet chip -- hosokawa)
- *
- * This version of fe_probe_tdk has been rewrote to handle
- * *generic* PC card implementation of Fujitsu MB8696x family. The
- * name _tdk is just for a historical reason. :-)
- */
-static int
-fe_probe_tdk ( struct isa_device * dev, struct fe_softc * sc )
-{
- static struct fe_simple_probe_struct probe_table [] = {
- { FE_DLCR2, 0x50, 0x00 },
- { FE_DLCR4, 0x08, 0x00 },
- /* { FE_DLCR5, 0x80, 0x00 }, Does not work well. */
- { 0 }
- };
-
- if ( dev->id_irq == NO_IRQ ) {
- return ( 0 );
- }
-
- fe_softc_defaults(sc);
-
- /*
- * See if C-NET(PC)C is on its address.
- */
-
- if ( !fe_simple_probe( sc, probe_table ) ) return 0;
-
- /* Determine the card type. */
- sc->typestr = "Generic MB8696x/78Q837x Ethernet (PCMCIA)";
-
- /*
- * Initialize constants in the per-line structure.
- */
-
- /* Make sure we got a valid station address. */
- if (!valid_Ether_p(sc->sc_enaddr, 0)) return 0;
-
- /*
- * That's all. C-NET(PC)C occupies 16 I/O addresses.
- * XXX: Are there any card with 32 I/O addresses? FIXME.
- */
- return 16;
-}
-#endif /* NCARD > 0 */
-
-/*
- * Install interface into kernel networking data structures
- */
-static int
-fe_attach ( struct isa_device * dev )
-{
-#if NCARD > 0
- static int already_ifattach[NFE];
-#endif
- struct fe_softc *sc = &fe_softc[dev->id_unit];
- int b;
-
- dev->id_ointr = feintr;
-
- /*
- * Initialize ifnet structure
- */
- sc->sc_if.if_softc = sc;
- sc->sc_if.if_unit = sc->sc_unit;
- sc->sc_if.if_name = "fe";
- sc->sc_if.if_output = ether_output;
- sc->sc_if.if_start = fe_start;
- sc->sc_if.if_ioctl = fe_ioctl;
- sc->sc_if.if_watchdog = fe_watchdog;
- sc->sc_if.if_init = fe_init;
- sc->sc_if.if_linkmib = &sc->mibdata;
- sc->sc_if.if_linkmiblen = sizeof (sc->mibdata);
-
-#if 0 /* I'm not sure... */
- sc->mibdata.dot3Compliance = DOT3COMPLIANCE_COLLS;
-#endif
-
- /*
- * Set fixed interface flags.
- */
- sc->sc_if.if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
-
-#if 1
- /*
- * Set maximum size of output queue, if it has not been set.
- * It is done here as this driver may be started after the
- * system initialization (i.e., the interface is PCMCIA.)
- *
- * I'm not sure this is really necessary, but, even if it is,
- * it should be done somewhere else, e.g., in if_attach(),
- * since it must be a common workaround for all network drivers.
- * FIXME.
- */
- if ( sc->sc_if.if_snd.ifq_maxlen == 0 ) {
- sc->sc_if.if_snd.ifq_maxlen = ifqmaxlen;
- }
-#endif
-
-#if FE_SINGLE_TRANSMISSION
- /* Override txb config to allocate minimum. */
- sc->proto_dlcr6 &= ~FE_D6_TXBSIZ
- sc->proto_dlcr6 |= FE_D6_TXBSIZ_2x2KB;
-#endif
-
- /* Modify hardware config if it is requested. */
- if ( dev->id_flags & FE_FLAGS_OVERRIDE_DLCR6 ) {
- sc->proto_dlcr6 = dev->id_flags & FE_FLAGS_DLCR6_VALUE;
- }
-
- /* Find TX buffer size, based on the hardware dependent proto. */
- switch ( sc->proto_dlcr6 & FE_D6_TXBSIZ ) {
- case FE_D6_TXBSIZ_2x2KB: sc->txb_size = 2048; break;
- case FE_D6_TXBSIZ_2x4KB: sc->txb_size = 4096; break;
- case FE_D6_TXBSIZ_2x8KB: sc->txb_size = 8192; break;
- default:
- /* Oops, we can't work with single buffer configuration. */
- if (bootverbose) {
- printf("fe%d: strange TXBSIZ config; fixing\n",
- sc->sc_unit);
- }
- sc->proto_dlcr6 &= ~FE_D6_TXBSIZ;
- sc->proto_dlcr6 |= FE_D6_TXBSIZ_2x2KB;
- sc->txb_size = 2048;
- break;
- }
-
- /* Initialize the if_media interface. */
- ifmedia_init(&sc->media, 0, fe_medchange, fe_medstat );
- for (b = 0; bit2media[b] != 0; b++) {
- if (sc->mbitmap & (1 << b)) {
- ifmedia_add(&sc->media, bit2media[b], 0, NULL);
- }
- }
- for (b = 0; bit2media[b] != 0; b++) {
- if (sc->defmedia & (1 << b)) {
- ifmedia_set(&sc->media, bit2media[b]);
- break;
- }
- }
-#if 0 /* Turned off; this is called later, when the interface UPs. */
- fe_medchange(sc);
-#endif
-
- /* Attach and stop the interface. */
-#if NCARD > 0
- if (already_ifattach[dev->id_unit] != 1) {
- if_attach(&sc->sc_if);
- already_ifattach[dev->id_unit] = 1;
- }
-#else
- if_attach(&sc->sc_if);
-#endif
- fe_stop(sc);
- ether_ifattach(&sc->sc_if);
-
- /* Print additional info when attached. */
- printf("fe%d: address %6D, type %s%s\n", sc->sc_unit,
- sc->sc_enaddr, ":" , sc->typestr,
- (sc->proto_dlcr4 & FE_D4_DSC) ? ", full duplex" : "");
- if (bootverbose) {
- int buf, txb, bbw, sbw, ram;
-
- buf = txb = bbw = sbw = ram = -1;
- switch ( sc->proto_dlcr6 & FE_D6_BUFSIZ ) {
- case FE_D6_BUFSIZ_8KB: buf = 8; break;
- case FE_D6_BUFSIZ_16KB: buf = 16; break;
- case FE_D6_BUFSIZ_32KB: buf = 32; break;
- case FE_D6_BUFSIZ_64KB: buf = 64; break;
- }
- switch ( sc->proto_dlcr6 & FE_D6_TXBSIZ ) {
- case FE_D6_TXBSIZ_2x2KB: txb = 2; break;
- case FE_D6_TXBSIZ_2x4KB: txb = 4; break;
- case FE_D6_TXBSIZ_2x8KB: txb = 8; break;
- }
- switch ( sc->proto_dlcr6 & FE_D6_BBW ) {
- case FE_D6_BBW_BYTE: bbw = 8; break;
- case FE_D6_BBW_WORD: bbw = 16; break;
- }
- switch ( sc->proto_dlcr6 & FE_D6_SBW ) {
- case FE_D6_SBW_BYTE: sbw = 8; break;
- case FE_D6_SBW_WORD: sbw = 16; break;
- }
- switch ( sc->proto_dlcr6 & FE_D6_SRAM ) {
- case FE_D6_SRAM_100ns: ram = 100; break;
- case FE_D6_SRAM_150ns: ram = 150; break;
- }
- printf("fe%d: SRAM %dKB %dbit %dns, TXB %dKBx2, %dbit I/O\n",
- sc->sc_unit, buf, bbw, ram, txb, sbw);
- }
- if (sc->stability & UNSTABLE_IRQ) {
- printf("fe%d: warning: IRQ number may be incorrect\n",
- sc->sc_unit);
- }
- if (sc->stability & UNSTABLE_MAC) {
- printf("fe%d: warning: above MAC address may be incorrect\n",
- sc->sc_unit);
- }
- if (sc->stability & UNSTABLE_TYPE) {
- printf("fe%d: warning: hardware type was not validated\n",
- sc->sc_unit);
- }
-
- /* If BPF is in the kernel, call the attach for it. */
- bpfattach(&sc->sc_if, DLT_EN10MB, sizeof(struct ether_header));
- return 1;
-}
-
-/*
- * Reset interface, after some (hardware) trouble is deteced.
- */
-static void
-fe_reset (struct fe_softc *sc)
-{
- /* Record how many packets are lost by this accident. */
- sc->sc_if.if_oerrors += sc->txb_sched + sc->txb_count;
- sc->mibdata.dot3StatsInternalMacTransmitErrors++;
-
- /* Put the interface into known initial state. */
- fe_stop(sc);
- if (sc->sc_if.if_flags & IFF_UP) fe_init(sc);
-}
-
-/*
- * Stop everything on the interface.
- *
- * All buffered packets, both transmitting and receiving,
- * if any, will be lost by stopping the interface.
- */
-static void
-fe_stop (struct fe_softc *sc)
-{
- int s;
-
- s = splimp();
-
- /* Disable interrupts. */
- outb( sc->ioaddr[ FE_DLCR2 ], 0x00 );
- outb( sc->ioaddr[ FE_DLCR3 ], 0x00 );
-
- /* Stop interface hardware. */
- DELAY( 200 );
- outb( sc->ioaddr[ FE_DLCR6 ], sc->proto_dlcr6 | FE_D6_DLC_DISABLE );
- DELAY( 200 );
-
- /* Clear all interrupt status. */
- outb( sc->ioaddr[ FE_DLCR0 ], 0xFF );
- outb( sc->ioaddr[ FE_DLCR1 ], 0xFF );
-
- /* Put the chip in stand-by mode. */
- DELAY( 200 );
- outb( sc->ioaddr[ FE_DLCR7 ], sc->proto_dlcr7 | FE_D7_POWER_DOWN );
- DELAY( 200 );
-
- /* Reset transmitter variables and interface flags. */
- sc->sc_if.if_flags &= ~( IFF_OACTIVE | IFF_RUNNING );
- sc->sc_if.if_timer = 0;
- sc->txb_free = sc->txb_size;
- sc->txb_count = 0;
- sc->txb_sched = 0;
-
- /* MAR loading can be delayed. */
- sc->filter_change = 0;
-
- /* Call a device-specific hook. */
- if ( sc->stop ) sc->stop( sc );
-
- (void) splx(s);
-}
-
-/*
- * Device timeout/watchdog routine. Entered if the device neglects to
- * generate an interrupt after a transmit has been started on it.
- */
-static void
-fe_watchdog ( struct ifnet *ifp )
-{
- struct fe_softc *sc = (struct fe_softc *)ifp;
-
- /* A "debug" message. */
- printf("fe%d: transmission timeout (%d+%d)%s\n",
- ifp->if_unit, sc->txb_sched, sc->txb_count,
- (ifp->if_flags & IFF_UP) ? "" : " when down");
- if ( sc->sc_if.if_opackets == 0 && sc->sc_if.if_ipackets == 0 ) {
- printf("fe%d: wrong IRQ setting in config?\n", ifp->if_unit);
- }
- fe_reset( sc );
-}
-
-/*
- * Initialize device.
- */
-static void
-fe_init (void * xsc)
-{
- struct fe_softc *sc = xsc;
- int s;
-
- /* We need an address. */
- if (TAILQ_EMPTY(&sc->sc_if.if_addrhead)) { /* XXX unlikely */
-#ifdef DIAGNOSTIC
- printf("fe%d: init() without any address\n", sc->sc_unit);
-#endif
- return;
- }
-
- /* Start initializing 86960. */
- s = splimp();
-
- /* Call a hook before we start initializing the chip. */
- if ( sc->init ) sc->init( sc );
-
- /*
- * Make sure to disable the chip, also.
- * This may also help re-programming the chip after
- * hot insertion of PCMCIAs.
- */
- DELAY( 200 );
- outb( sc->ioaddr[ FE_DLCR6 ], sc->proto_dlcr6 | FE_D6_DLC_DISABLE );
- DELAY( 200 );
-
- /* Power up the chip and select register bank for DLCRs. */
- DELAY( 200 );
- outb( sc->ioaddr[ FE_DLCR7 ],
- sc->proto_dlcr7 | FE_D7_RBS_DLCR | FE_D7_POWER_UP );
- DELAY( 200 );
-
- /* Feed the station address. */
- outblk( sc, FE_DLCR8, sc->sc_enaddr, ETHER_ADDR_LEN );
-
- /* Clear multicast address filter to receive nothing. */
- outb( sc->ioaddr[ FE_DLCR7 ],
- sc->proto_dlcr7 | FE_D7_RBS_MAR | FE_D7_POWER_UP );
- outblk( sc, FE_MAR8, fe_filter_nothing.data, FE_FILTER_LEN );
-
- /* Select the BMPR bank for runtime register access. */
- outb( sc->ioaddr[ FE_DLCR7 ],
- sc->proto_dlcr7 | FE_D7_RBS_BMPR | FE_D7_POWER_UP );
-
- /* Initialize registers. */
- outb( sc->ioaddr[ FE_DLCR0 ], 0xFF ); /* Clear all bits. */
- outb( sc->ioaddr[ FE_DLCR1 ], 0xFF ); /* ditto. */
- outb( sc->ioaddr[ FE_DLCR2 ], 0x00 );
- outb( sc->ioaddr[ FE_DLCR3 ], 0x00 );
- outb( sc->ioaddr[ FE_DLCR4 ], sc->proto_dlcr4 );
- outb( sc->ioaddr[ FE_DLCR5 ], sc->proto_dlcr5 );
- outb( sc->ioaddr[ FE_BMPR10 ], 0x00 );
- outb( sc->ioaddr[ FE_BMPR11 ], FE_B11_CTRL_SKIP | FE_B11_MODE1 );
- outb( sc->ioaddr[ FE_BMPR12 ], 0x00 );
- outb( sc->ioaddr[ FE_BMPR13 ], sc->proto_bmpr13 );
- outb( sc->ioaddr[ FE_BMPR14 ], 0x00 );
- outb( sc->ioaddr[ FE_BMPR15 ], 0x00 );
-
- /* Enable interrupts. */
- outb( sc->ioaddr[ FE_DLCR2 ], FE_TMASK );
- outb( sc->ioaddr[ FE_DLCR3 ], FE_RMASK );
-
- /* Select requested media, just before enabling DLC. */
- if (sc->msel) sc->msel(sc);
-
- /* Enable transmitter and receiver. */
- DELAY( 200 );
- outb( sc->ioaddr[ FE_DLCR6 ], sc->proto_dlcr6 | FE_D6_DLC_ENABLE );
- DELAY( 200 );
-
-#ifdef DIAGNOSTIC
- /*
- * Make sure to empty the receive buffer.
- *
- * This may be redundant, but *if* the receive buffer were full
- * at this point, then the driver would hang. I have experienced
- * some strange hang-up just after UP. I hope the following
- * code solve the problem.
- *
- * I have changed the order of hardware initialization.
- * I think the receive buffer cannot have any packets at this
- * point in this version. The following code *must* be
- * redundant now. FIXME.
- *
- * I've heard a rumore that on some PC card implementation of
- * 8696x, the receive buffer can have some data at this point.
- * The following message helps discovering the fact. FIXME.
- */
- if ( !( inb( sc->ioaddr[ FE_DLCR5 ] ) & FE_D5_BUFEMP ) ) {
- printf("fe%d: receive buffer has some data after reset\n",
- sc->sc_unit);
- fe_emptybuffer( sc );
- }
-
- /* Do we need this here? Actually, no. I must be paranoia. */
- outb( sc->ioaddr[ FE_DLCR0 ], 0xFF ); /* Clear all bits. */
- outb( sc->ioaddr[ FE_DLCR1 ], 0xFF ); /* ditto. */
-#endif
-
- /* Set 'running' flag, because we are now running. */
- sc->sc_if.if_flags |= IFF_RUNNING;
-
- /*
- * At this point, the interface is running properly,
- * except that it receives *no* packets. we then call
- * fe_setmode() to tell the chip what packets to be
- * received, based on the if_flags and multicast group
- * list. It completes the initialization process.
- */
- fe_setmode( sc );
-
-#if 0
- /* ...and attempt to start output queued packets. */
- /* TURNED OFF, because the semi-auto media prober wants to UP
- the interface keeping it idle. The upper layer will soon
- start the interface anyway, and there are no significant
- delay. */
- fe_start( &sc->sc_if );
-#endif
-
- (void) splx(s);
-}
-
-/*
- * This routine actually starts the transmission on the interface
- */
-static void
-fe_xmit ( struct fe_softc * sc )
-{
- /*
- * Set a timer just in case we never hear from the board again.
- * We use longer timeout for multiple packet transmission.
- * I'm not sure this timer value is appropriate. FIXME.
- */
- sc->sc_if.if_timer = 1 + sc->txb_count;
-
- /* Update txb variables. */
- sc->txb_sched = sc->txb_count;
- sc->txb_count = 0;
- sc->txb_free = sc->txb_size;
- sc->tx_excolls = 0;
-
- /* Start transmitter, passing packets in TX buffer. */
- outb( sc->ioaddr[ FE_BMPR10 ], sc->txb_sched | FE_B10_START );
-}
-
-/*
- * Start output on interface.
- * We make two assumptions here:
- * 1) that the current priority is set to splimp _before_ this code
- * is called *and* is returned to the appropriate priority after
- * return
- * 2) that the IFF_OACTIVE flag is checked before this code is called
- * (i.e. that the output part of the interface is idle)
- */
-void
-fe_start ( struct ifnet *ifp )
-{
- struct fe_softc *sc = ifp->if_softc;
- struct mbuf *m;
-
-#ifdef DIAGNOSTIC
- /* Just a sanity check. */
- if ( ( sc->txb_count == 0 ) != ( sc->txb_free == sc->txb_size ) ) {
- /*
- * Txb_count and txb_free co-works to manage the
- * transmission buffer. Txb_count keeps track of the
- * used potion of the buffer, while txb_free does unused
- * potion. So, as long as the driver runs properly,
- * txb_count is zero if and only if txb_free is same
- * as txb_size (which represents whole buffer.)
- */
- printf("fe%d: inconsistent txb variables (%d, %d)\n",
- sc->sc_unit, sc->txb_count, sc->txb_free);
- /*
- * So, what should I do, then?
- *
- * We now know txb_count and txb_free contradicts. We
- * cannot, however, tell which is wrong. More
- * over, we cannot peek 86960 transmission buffer or
- * reset the transmission buffer. (In fact, we can
- * reset the entire interface. I don't want to do it.)
- *
- * If txb_count is incorrect, leaving it as-is will cause
- * sending of garbage after next interrupt. We have to
- * avoid it. Hence, we reset the txb_count here. If
- * txb_free was incorrect, resetting txb_count just loose
- * some packets. We can live with it.
- */
- sc->txb_count = 0;
- }
-#endif
-
- /*
- * First, see if there are buffered packets and an idle
- * transmitter - should never happen at this point.
- */
- if ( ( sc->txb_count > 0 ) && ( sc->txb_sched == 0 ) ) {
- printf("fe%d: transmitter idle with %d buffered packets\n",
- sc->sc_unit, sc->txb_count);
- fe_xmit( sc );
- }
-
- /*
- * Stop accepting more transmission packets temporarily, when
- * a filter change request is delayed. Updating the MARs on
- * 86960 flushes the transmission buffer, so it is delayed
- * until all buffered transmission packets have been sent
- * out.
- */
- if ( sc->filter_change ) {
- /*
- * Filter change request is delayed only when the DLC is
- * working. DLC soon raise an interrupt after finishing
- * the work.
- */
- goto indicate_active;
- }
-
- for (;;) {
-
- /*
- * See if there is room to put another packet in the buffer.
- * We *could* do better job by peeking the send queue to
- * know the length of the next packet. Current version just
- * tests against the worst case (i.e., longest packet). FIXME.
- *
- * When adding the packet-peek feature, don't forget adding a
- * test on txb_count against QUEUEING_MAX.
- * There is a little chance the packet count exceeds
- * the limit. Assume transmission buffer is 8KB (2x8KB
- * configuration) and an application sends a bunch of small
- * (i.e., minimum packet sized) packets rapidly. An 8KB
- * buffer can hold 130 blocks of 62 bytes long...
- */
- if ( sc->txb_free
- < ETHER_MAX_LEN - ETHER_CRC_LEN + FE_DATA_LEN_LEN ) {
- /* No room. */
- goto indicate_active;
- }
-
-#if FE_SINGLE_TRANSMISSION
- if ( sc->txb_count > 0 ) {
- /* Just one packet per a transmission buffer. */
- goto indicate_active;
- }
-#endif
-
- /*
- * Get the next mbuf chain for a packet to send.
- */
- IF_DEQUEUE( &sc->sc_if.if_snd, m );
- if ( m == NULL ) {
- /* No more packets to send. */
- goto indicate_inactive;
- }
-
- /*
- * Copy the mbuf chain into the transmission buffer.
- * txb_* variables are updated as necessary.
- */
- fe_write_mbufs( sc, m );
-
- /* Start transmitter if it's idle. */
- if ( ( sc->txb_count > 0 ) && ( sc->txb_sched == 0 ) ) {
- fe_xmit( sc );
- }
-
- /*
- * Tap off here if there is a bpf listener,
- * and the device is *not* in promiscuous mode.
- * (86960 receives self-generated packets if
- * and only if it is in "receive everything"
- * mode.)
- */
- if ( sc->sc_if.if_bpf
- && !( sc->sc_if.if_flags & IFF_PROMISC ) ) {
- bpf_mtap( &sc->sc_if, m );
- }
-
- m_freem( m );
- }
-
- indicate_inactive:
- /*
- * We are using the !OACTIVE flag to indicate to
- * the outside world that we can accept an
- * additional packet rather than that the
- * transmitter is _actually_ active. Indeed, the
- * transmitter may be active, but if we haven't
- * filled all the buffers with data then we still
- * want to accept more.
- */
- sc->sc_if.if_flags &= ~IFF_OACTIVE;
- return;
-
- indicate_active:
- /*
- * The transmitter is active, and there are no room for
- * more outgoing packets in the transmission buffer.
- */
- sc->sc_if.if_flags |= IFF_OACTIVE;
- return;
-}
-
-/*
- * Drop (skip) a packet from receive buffer in 86960 memory.
- */
-static void
-fe_droppacket ( struct fe_softc * sc, int len )
-{
- int i;
-
- /*
- * 86960 manual says that we have to read 8 bytes from the buffer
- * before skip the packets and that there must be more than 8 bytes
- * remaining in the buffer when issue a skip command.
- * Remember, we have already read 4 bytes before come here.
- */
- if ( len > 12 ) {
- /* Read 4 more bytes, and skip the rest of the packet. */
-#ifdef FE_8BIT_SUPPORT
- if ((sc->proto_dlcr6 & FE_D6_SBW) == FE_D6_SBW_BYTE)
- {
- ( void )inb( sc->ioaddr[ FE_BMPR8 ] );
- ( void )inb( sc->ioaddr[ FE_BMPR8 ] );
- ( void )inb( sc->ioaddr[ FE_BMPR8 ] );
- ( void )inb( sc->ioaddr[ FE_BMPR8 ] );
- }
- else
-#endif
- {
- ( void )inw( sc->ioaddr[ FE_BMPR8 ] );
- ( void )inw( sc->ioaddr[ FE_BMPR8 ] );
- }
- outb( sc->ioaddr[ FE_BMPR14 ], FE_B14_SKIP );
- } else {
- /* We should not come here unless receiving RUNTs. */
-#ifdef FE_8BIT_SUPPORT
- if ((sc->proto_dlcr6 & FE_D6_SBW) == FE_D6_SBW_BYTE)
- {
- for ( i = 0; i < len; i++ ) {
- ( void )inb( sc->ioaddr[ FE_BMPR8 ] );
- }
- }
- else
-#endif
- {
- for ( i = 0; i < len; i += 2 ) {
- ( void )inw( sc->ioaddr[ FE_BMPR8 ] );
- }
- }
- }
-}
-
-#ifdef DIAGNOSTIC
-/*
- * Empty receiving buffer.
- */
-static void
-fe_emptybuffer ( struct fe_softc * sc )
-{
- int i;
- u_char saved_dlcr5;
-
-#ifdef FE_DEBUG
- printf("fe%d: emptying receive buffer\n", sc->sc_unit);
-#endif
-
- /*
- * Stop receiving packets, temporarily.
- */
- saved_dlcr5 = inb( sc->ioaddr[ FE_DLCR5 ] );
- outb( sc->ioaddr[ FE_DLCR5 ], sc->proto_dlcr5 );
- DELAY(1300);
-
- /*
- * When we come here, the receive buffer management may
- * have been broken. So, we cannot use skip operation.
- * Just discard everything in the buffer.
- */
-#ifdef FE_8BIT_SUPPORT
- if ((sc->proto_dlcr6 & FE_D6_SBW) == FE_D6_SBW_BYTE)
- {
- for ( i = 0; i < 65536; i++ ) {
- if ( inb( sc->ioaddr[ FE_DLCR5 ] ) & FE_D5_BUFEMP ) break;
- ( void )inb( sc->ioaddr[ FE_BMPR8 ] );
- }
- }
- else
-#endif
- {
- for ( i = 0; i < 65536; i += 2 ) {
- if ( inb( sc->ioaddr[ FE_DLCR5 ] ) & FE_D5_BUFEMP ) break;
- ( void )inw( sc->ioaddr[ FE_BMPR8 ] );
- }
- }
-
- /*
- * Double check.
- */
- if ( inb( sc->ioaddr[ FE_DLCR5 ] ) & FE_D5_BUFEMP ) {
- printf("fe%d: could not empty receive buffer\n", sc->sc_unit);
- /* Hmm. What should I do if this happens? FIXME. */
- }
-
- /*
- * Restart receiving packets.
- */
- outb( sc->ioaddr[ FE_DLCR5 ], saved_dlcr5 );
-}
-#endif
-
-/*
- * Transmission interrupt handler
- * The control flow of this function looks silly. FIXME.
- */
-static void
-fe_tint ( struct fe_softc * sc, u_char tstat )
-{
- int left;
- int col;
-
- /*
- * Handle "excessive collision" interrupt.
- */
- if ( tstat & FE_D0_COLL16 ) {
-
- /*
- * Find how many packets (including this collided one)
- * are left unsent in transmission buffer.
- */
- left = inb( sc->ioaddr[ FE_BMPR10 ] );
- printf("fe%d: excessive collision (%d/%d)\n",
- sc->sc_unit, left, sc->txb_sched);
-
- /*
- * Clear the collision flag (in 86960) here
- * to avoid confusing statistics.
- */
- outb( sc->ioaddr[ FE_DLCR0 ], FE_D0_COLLID );
-
- /*
- * Restart transmitter, skipping the
- * collided packet.
- *
- * We *must* skip the packet to keep network running
- * properly. Excessive collision error is an
- * indication of the network overload. If we
- * tried sending the same packet after excessive
- * collision, the network would be filled with
- * out-of-time packets. Packets belonging
- * to reliable transport (such as TCP) are resent
- * by some upper layer.
- */
- outb( sc->ioaddr[ FE_BMPR11 ],
- FE_B11_CTRL_SKIP | FE_B11_MODE1 );
-
- /* Update statistics. */
- sc->tx_excolls++;
- }
-
- /*
- * Handle "transmission complete" interrupt.
- */
- if ( tstat & FE_D0_TXDONE ) {
-
- /*
- * Add in total number of collisions on last
- * transmission. We also clear "collision occurred" flag
- * here.
- *
- * 86960 has a design flaw on collision count on multiple
- * packet transmission. When we send two or more packets
- * with one start command (that's what we do when the
- * transmission queue is crowded), 86960 informs us number
- * of collisions occurred on the last packet on the
- * transmission only. Number of collisions on previous
- * packets are lost. I have told that the fact is clearly
- * stated in the Fujitsu document.
- *
- * I considered not to mind it seriously. Collision
- * count is not so important, anyway. Any comments? FIXME.
- */
-
- if ( inb( sc->ioaddr[ FE_DLCR0 ] ) & FE_D0_COLLID ) {
-
- /* Clear collision flag. */
- outb( sc->ioaddr[ FE_DLCR0 ], FE_D0_COLLID );
-
- /* Extract collision count from 86960. */
- col = inb( sc->ioaddr[ FE_DLCR4 ] );
- col = ( col & FE_D4_COL ) >> FE_D4_COL_SHIFT;
- if ( col == 0 ) {
- /*
- * Status register indicates collisions,
- * while the collision count is zero.
- * This can happen after multiple packet
- * transmission, indicating that one or more
- * previous packet(s) had been collided.
- *
- * Since the accurate number of collisions
- * has been lost, we just guess it as 1;
- * Am I too optimistic? FIXME.
- */
- col = 1;
- }
- sc->sc_if.if_collisions += col;
- if ( col == 1 ) {
- sc->mibdata.dot3StatsSingleCollisionFrames++;
- } else {
- sc->mibdata.dot3StatsMultipleCollisionFrames++;
- }
- sc->mibdata.dot3StatsCollFrequencies[col-1]++;
- }
-
- /*
- * Update transmission statistics.
- * Be sure to reflect number of excessive collisions.
- */
- col = sc->tx_excolls;
- sc->sc_if.if_opackets += sc->txb_sched - col;
- sc->sc_if.if_oerrors += col;
- sc->sc_if.if_collisions += col * 16;
- sc->mibdata.dot3StatsExcessiveCollisions += col;
- sc->mibdata.dot3StatsCollFrequencies[15] += col;
- sc->txb_sched = 0;
-
- /*
- * The transmitter is no more active.
- * Reset output active flag and watchdog timer.
- */
- sc->sc_if.if_flags &= ~IFF_OACTIVE;
- sc->sc_if.if_timer = 0;
-
- /*
- * If more data is ready to transmit in the buffer, start
- * transmitting them. Otherwise keep transmitter idle,
- * even if more data is queued. This gives receive
- * process a slight priority.
- */
- if ( sc->txb_count > 0 ) fe_xmit( sc );
- }
-}
-
-/*
- * Ethernet interface receiver interrupt.
- */
-static void
-fe_rint ( struct fe_softc * sc, u_char rstat )
-{
- u_short len;
- u_char status;
- int i;
-
- /*
- * Update statistics if this interrupt is caused by an error.
- * Note that, when the system was not sufficiently fast, the
- * receive interrupt might not be acknowledged immediately. If
- * one or more errornous frames were received before this routine
- * was scheduled, they are ignored, and the following error stats
- * give less than real values.
- */
- if ( rstat & ( FE_D1_OVRFLO | FE_D1_CRCERR
- | FE_D1_ALGERR | FE_D1_SRTPKT ) ) {
- if ( rstat & FE_D1_OVRFLO )
- sc->mibdata.dot3StatsInternalMacReceiveErrors++;
- if ( rstat & FE_D1_CRCERR )
- sc->mibdata.dot3StatsFCSErrors++;
- if ( rstat & FE_D1_ALGERR )
- sc->mibdata.dot3StatsAlignmentErrors++;
-#if 0
- /* The reference MAC receiver defined in 802.3
- silently ignores short frames (RUNTs) without
- notifying upper layer. RFC 1650 (dot3 MIB) is
- based on the 802.3, and it has no stats entry for
- RUNTs... */
- if ( rstat & FE_D1_SRTPKT )
- sc->mibdata.dot3StatsFrameTooShorts++; /* :-) */
-#endif
- sc->sc_if.if_ierrors++;
- }
-
- /*
- * MB86960 has a flag indicating "receive queue empty."
- * We just loop, checking the flag, to pull out all received
- * packets.
- *
- * We limit the number of iterations to avoid infinite-loop.
- * The upper bound is set to unrealistic high value.
- */
- for ( i = 0; i < FE_MAX_RECV_COUNT * 2; i++ ) {
-
- /* Stop the iteration if 86960 indicates no packets. */
- if ( inb( sc->ioaddr[ FE_DLCR5 ] ) & FE_D5_BUFEMP ) return;
-
- /*
- * Extract a receive status byte.
- * As our 86960 is in 16 bit bus access mode, we have to
- * use inw() to get the status byte. The significant
- * value is returned in lower 8 bits.
- */
-#ifdef FE_8BIT_SUPPORT
- if ((sc->proto_dlcr6 & FE_D6_SBW) == FE_D6_SBW_BYTE)
- {
- status = inb( sc->ioaddr[ FE_BMPR8 ] );
- ( void ) inb( sc->ioaddr[ FE_BMPR8 ] );
- }
- else
-#endif
- {
- status = ( u_char )inw( sc->ioaddr[ FE_BMPR8 ] );
- }
-
- /*
- * Extract the packet length.
- * It is a sum of a header (14 bytes) and a payload.
- * CRC has been stripped off by the 86960.
- */
-#ifdef FE_8BIT_SUPPORT
- if ((sc->proto_dlcr6 & FE_D6_SBW) == FE_D6_SBW_BYTE)
- {
- len = inb( sc->ioaddr[ FE_BMPR8 ] );
- len |= ( inb( sc->ioaddr[ FE_BMPR8 ] ) << 8 );
- }
- else
-#endif
- {
- len = inw( sc->ioaddr[ FE_BMPR8 ] );
- }
-
- /*
- * AS our 86960 is programed to ignore errored frame,
- * we must not see any error indication in the
- * receive buffer. So, any error condition is a
- * serious error, e.g., out-of-sync of the receive
- * buffer pointers.
- */
- if ( ( status & 0xF0 ) != 0x20
- || len > ETHER_MAX_LEN - ETHER_CRC_LEN
- || len < ETHER_MIN_LEN - ETHER_CRC_LEN ) {
- printf("fe%d: RX buffer out-of-sync\n", sc->sc_unit);
- sc->sc_if.if_ierrors++;
- sc->mibdata.dot3StatsInternalMacReceiveErrors++;
- fe_reset(sc);
- return;
- }
-
- /*
- * Go get a packet.
- */
- if ( fe_get_packet( sc, len ) < 0 ) {
- /*
- * Negative return from fe_get_packet()
- * indicates no available mbuf. We stop
- * receiving packets, even if there are more
- * in the buffer. We hope we can get more
- * mbuf next time.
- */
- sc->sc_if.if_ierrors++;
- sc->mibdata.dot3StatsMissedFrames++;
- fe_droppacket( sc, len );
- return;
- }
-
- /* Successfully received a packet. Update stat. */
- sc->sc_if.if_ipackets++;
- }
-
- /* Maximum number of frames has been received. Something
- strange is happening here... */
- printf("fe%d: unusual receive flood\n", sc->sc_unit);
- sc->mibdata.dot3StatsInternalMacReceiveErrors++;
- fe_reset(sc);
-}
-
-/*
- * Ethernet interface interrupt processor
- */
-static void
-feintr ( int unit )
-{
- struct fe_softc *sc = &fe_softc[unit];
- u_char tstat, rstat;
- int loop_count = FE_MAX_LOOP;
-
- /* Loop until there are no more new interrupt conditions. */
- while (loop_count-- > 0) {
- /*
- * Get interrupt conditions, masking unneeded flags.
- */
- tstat = inb( sc->ioaddr[ FE_DLCR0 ] ) & FE_TMASK;
- rstat = inb( sc->ioaddr[ FE_DLCR1 ] ) & FE_RMASK;
- if ( tstat == 0 && rstat == 0 ) return;
-
- /*
- * Reset the conditions we are acknowledging.
- */
- outb( sc->ioaddr[ FE_DLCR0 ], tstat );
- outb( sc->ioaddr[ FE_DLCR1 ], rstat );
-
- /*
- * Handle transmitter interrupts.
- */
- if ( tstat ) {
- fe_tint( sc, tstat );
- }
-
- /*
- * Handle receiver interrupts
- */
- if ( rstat ) {
- fe_rint( sc, rstat );
- }
-
- /*
- * Update the multicast address filter if it is
- * needed and possible. We do it now, because
- * we can make sure the transmission buffer is empty,
- * and there is a good chance that the receive queue
- * is empty. It will minimize the possibility of
- * packet loss.
- */
- if ( sc->filter_change
- && sc->txb_count == 0 && sc->txb_sched == 0 ) {
- fe_loadmar(sc);
- sc->sc_if.if_flags &= ~IFF_OACTIVE;
- }
-
- /*
- * If it looks like the transmitter can take more data,
- * attempt to start output on the interface. This is done
- * after handling the receiver interrupt to give the
- * receive operation priority.
- *
- * BTW, I'm not sure in what case the OACTIVE is on at
- * this point. Is the following test redundant?
- *
- * No. This routine polls for both transmitter and
- * receiver interrupts. 86960 can raise a receiver
- * interrupt when the transmission buffer is full.
- */
- if ( ( sc->sc_if.if_flags & IFF_OACTIVE ) == 0 ) {
- fe_start( &sc->sc_if );
- }
-
- }
-
- printf("fe%d: too many loops\n", sc->sc_unit);
- return;
-}
-
-/*
- * Process an ioctl request. This code needs some work - it looks
- * pretty ugly.
- */
-static int
-fe_ioctl ( struct ifnet * ifp, u_long command, caddr_t data )
-{
- struct fe_softc *sc = ifp->if_softc;
- struct ifreq *ifr = (struct ifreq *)data;
- int s, error = 0;
-
- s = splimp();
-
- switch (command) {
-
- case SIOCSIFADDR:
- case SIOCGIFADDR:
- case SIOCSIFMTU:
- /* Just an ordinary action. */
- error = ether_ioctl(ifp, command, data);
- break;
-
- case SIOCSIFFLAGS:
- /*
- * Switch interface state between "running" and
- * "stopped", reflecting the UP flag.
- */
- if ( sc->sc_if.if_flags & IFF_UP ) {
- if ( ( sc->sc_if.if_flags & IFF_RUNNING ) == 0 ) {
- fe_init(sc);
- }
- } else {
- if ( ( sc->sc_if.if_flags & IFF_RUNNING ) != 0 ) {
- fe_stop(sc);
- }
- }
-
- /*
- * Promiscuous and/or multicast flags may have changed,
- * so reprogram the multicast filter and/or receive mode.
- */
- fe_setmode( sc );
-
- /* Done. */
- break;
-
- case SIOCADDMULTI:
- case SIOCDELMULTI:
- /*
- * Multicast list has changed; set the hardware filter
- * accordingly.
- */
- fe_setmode( sc );
- break;
-
- case SIOCSIFMEDIA:
- case SIOCGIFMEDIA:
- /* Let if_media to handle these commands and to call
- us back. */
- error = ifmedia_ioctl(ifp, ifr, &sc->media, command);
- break;
-
- default:
- error = EINVAL;
- break;
- }
-
- (void) splx(s);
- return (error);
-}
-
-/*
- * Retrieve packet from receive buffer and send to the next level up via
- * ether_input(). If there is a BPF listener, give a copy to BPF, too.
- * Returns 0 if success, -1 if error (i.e., mbuf allocation failure).
- */
-static int
-fe_get_packet ( struct fe_softc * sc, u_short len )
-{
- struct ether_header *eh;
- struct mbuf *m;
-
- /*
- * NFS wants the data be aligned to the word (4 byte)
- * boundary. Ethernet header has 14 bytes. There is a
- * 2-byte gap.
- */
-#define NFS_MAGIC_OFFSET 2
-
- /*
- * This function assumes that an Ethernet packet fits in an
- * mbuf (with a cluster attached when necessary.) On FreeBSD
- * 2.0 for x86, which is the primary target of this driver, an
- * mbuf cluster has 4096 bytes, and we are happy. On ancient
- * BSDs, such as vanilla 4.3 for 386, a cluster size was 1024,
- * however. If the following #error message were printed upon
- * compile, you need to rewrite this function.
- */
-#if ( MCLBYTES < ETHER_MAX_LEN - ETHER_CRC_LEN + NFS_MAGIC_OFFSET )
-#error "Too small MCLBYTES to use fe driver."
-#endif
-
- /*
- * Our strategy has one more problem. There is a policy on
- * mbuf cluster allocation. It says that we must have at
- * least MINCLSIZE (208 bytes on FreeBSD 2.0 for x86) to
- * allocate a cluster. For a packet of a size between
- * (MHLEN - 2) to (MINCLSIZE - 2), our code violates the rule...
- * On the other hand, the current code is short, simple,
- * and fast, however. It does no harmful thing, just waists
- * some memory. Any comments? FIXME.
- */
-
- /* Allocate an mbuf with packet header info. */
- MGETHDR(m, M_DONTWAIT, MT_DATA);
- if ( m == NULL ) return -1;
-
- /* Attach a cluster if this packet doesn't fit in a normal mbuf. */
- if ( len > MHLEN - NFS_MAGIC_OFFSET ) {
- MCLGET( m, M_DONTWAIT );
- if ( !( m->m_flags & M_EXT ) ) {
- m_freem( m );
- return -1;
- }
- }
-
- /* Initialize packet header info. */
- m->m_pkthdr.rcvif = &sc->sc_if;
- m->m_pkthdr.len = len;
-
- /* Set the length of this packet. */
- m->m_len = len;
-
- /* The following silliness is to make NFS happy */
- m->m_data += NFS_MAGIC_OFFSET;
-
- /* Get (actually just point to) the header part. */
- eh = mtod(m, struct ether_header *);
-
- /* Get a packet. */
-#ifdef FE_8BIT_SUPPORT
- if ((sc->proto_dlcr6 & FE_D6_SBW) == FE_D6_SBW_BYTE)
- {
- insb( sc->ioaddr[ FE_BMPR8 ], eh, len );
- }
- else
-#endif
- {
- insw( sc->ioaddr[ FE_BMPR8 ], eh, ( len + 1 ) >> 1 );
- }
-
-#define ETHER_ADDR_IS_MULTICAST(A) (*(char *)(A) & 1)
-
- /*
- * Check if there's a BPF listener on this interface.
- * If it is, hand off the raw packet to bpf.
- */
- if ( sc->sc_if.if_bpf ) {
- bpf_mtap( &sc->sc_if, m );
- }
-
-#ifdef BRIDGE
- if (do_bridge) {
- struct ifnet *ifp;
-
- ifp = bridge_in(m);
- if (ifp == BDG_DROP) {
- m_freem(m);
- return 0;
- }
- if (ifp != BDG_LOCAL)
- bdg_forward(&m, ifp); /* not local, need forwarding */
- if (ifp == BDG_LOCAL || ifp == BDG_BCAST || ifp == BDG_MCAST)
- goto getit;
- /* not local and not multicast, just drop it */
- if (m)
- m_freem(m);
- return 0;
- }
-#endif
-
- /*
- * Make sure this packet is (or may be) directed to us.
- * That is, the packet is either unicasted to our address,
- * or broad/multi-casted. If any other packets are
- * received, it is an indication of an error -- probably
- * 86960 is in a wrong operation mode.
- * Promiscuous mode is an exception. Under the mode, all
- * packets on the media must be received. (We must have
- * programmed the 86960 so.)
- */
-
- if ( ( sc->sc_if.if_flags & IFF_PROMISC )
- && !ETHER_ADDR_IS_MULTICAST( eh->ether_dhost )
- && bcmp( eh->ether_dhost, sc->sc_enaddr, ETHER_ADDR_LEN ) != 0 ) {
- /*
- * The packet was not for us. This is normal since
- * we are now in promiscuous mode. Just drop the packet.
- */
- m_freem( m );
- return 0;
- }
-
-#ifdef BRIDGE
-getit:
-#endif
- /* Strip off the Ethernet header. */
- m->m_pkthdr.len -= sizeof ( struct ether_header );
- m->m_len -= sizeof ( struct ether_header );
- m->m_data += sizeof ( struct ether_header );
-
- /* Feed the packet to upper layer. */
- ether_input( &sc->sc_if, eh, m );
- return 0;
-}
-
-/*
- * Write an mbuf chain to the transmission buffer memory using 16 bit PIO.
- * Returns number of bytes actually written, including length word.
- *
- * If an mbuf chain is too long for an Ethernet frame, it is not sent.
- * Packets shorter than Ethernet minimum are legal, and we pad them
- * before sending out. An exception is "partial" packets which are
- * shorter than mandatory Ethernet header.
- */
-static void
-fe_write_mbufs ( struct fe_softc *sc, struct mbuf *m )
-{
- u_short addr_bmpr8 = sc->ioaddr[ FE_BMPR8 ];
- u_short length, len;
- struct mbuf *mp;
- u_char *data;
- u_short savebyte; /* WARNING: Architecture dependent! */
-#define NO_PENDING_BYTE 0xFFFF
-
- static u_char padding [ ETHER_MIN_LEN - ETHER_CRC_LEN - ETHER_HDR_LEN ];
-
-#ifdef DIAGNOSTIC
- /* First, count up the total number of bytes to copy */
- length = 0;
- for ( mp = m; mp != NULL; mp = mp->m_next ) {
- length += mp->m_len;
- }
- /* Check if this matches the one in the packet header. */
- if ( length != m->m_pkthdr.len ) {
- printf("fe%d: packet length mismatch? (%d/%d)\n", sc->sc_unit,
- length, m->m_pkthdr.len);
- }
-#else
- /* Just use the length value in the packet header. */
- length = m->m_pkthdr.len;
-#endif
-
-#ifdef DIAGNOSTIC
- /*
- * Should never send big packets. If such a packet is passed,
- * it should be a bug of upper layer. We just ignore it.
- * ... Partial (too short) packets, neither.
- */
- if ( length < ETHER_HDR_LEN
- || length > ETHER_MAX_LEN - ETHER_CRC_LEN ) {
- printf("fe%d: got an out-of-spec packet (%u bytes) to send\n",
- sc->sc_unit, length);
- sc->sc_if.if_oerrors++;
- sc->mibdata.dot3StatsInternalMacTransmitErrors++;
- return;
- }
-#endif
-
- /*
- * Put the length word for this frame.
- * Does 86960 accept odd length? -- Yes.
- * Do we need to pad the length to minimum size by ourselves?
- * -- Generally yes. But for (or will be) the last
- * packet in the transmission buffer, we can skip the
- * padding process. It may gain performance slightly. FIXME.
- */
-#ifdef FE_8BIT_SUPPORT
- if ((sc->proto_dlcr6 & FE_D6_SBW) == FE_D6_SBW_BYTE)
- {
- len = max( length, ETHER_MIN_LEN - ETHER_CRC_LEN );
- outb( addr_bmpr8, len & 0x00ff );
- outb( addr_bmpr8, ( len & 0xff00 ) >> 8 );
- }
- else
-#endif
- {
- outw( addr_bmpr8, max( length, ETHER_MIN_LEN - ETHER_CRC_LEN ) );
- }
-
- /*
- * Update buffer status now.
- * Truncate the length up to an even number, since we use outw().
- */
-#ifdef FE_8BIT_SUPPORT
- if ((sc->proto_dlcr6 & FE_D6_SBW) != FE_D6_SBW_BYTE)
-#endif
- {
- length = ( length + 1 ) & ~1;
- }
- sc->txb_free -= FE_DATA_LEN_LEN + max( length, ETHER_MIN_LEN - ETHER_CRC_LEN);
- sc->txb_count++;
-
- /*
- * Transfer the data from mbuf chain to the transmission buffer.
- * MB86960 seems to require that data be transferred as words, and
- * only words. So that we require some extra code to patch
- * over odd-length mbufs.
- */
-#ifdef FE_8BIT_SUPPORT
- if ((sc->proto_dlcr6 & FE_D6_SBW) == FE_D6_SBW_BYTE)
- {
- /* 8-bit cards are easy. */
- for ( mp = m; mp != 0; mp = mp->m_next ) {
- if ( mp->m_len ) {
- outsb( addr_bmpr8, mtod(mp, caddr_t), mp->m_len );
- }
- }
- }
- else
-#endif
- {
- /* 16-bit cards are a pain. */
- savebyte = NO_PENDING_BYTE;
- for ( mp = m; mp != 0; mp = mp->m_next ) {
-
- /* Ignore empty mbuf. */
- len = mp->m_len;
- if ( len == 0 ) continue;
-
- /* Find the actual data to send. */
- data = mtod(mp, caddr_t);
-
- /* Finish the last byte. */
- if ( savebyte != NO_PENDING_BYTE ) {
- outw( addr_bmpr8, savebyte | ( *data << 8 ) );
- data++;
- len--;
- savebyte = NO_PENDING_BYTE;
- }
-
- /* output contiguous words */
- if (len > 1) {
- outsw( addr_bmpr8, data, len >> 1);
- data += len & ~1;
- len &= 1;
- }
-
- /* Save a remaining byte, if there is one. */
- if ( len > 0 ) {
- savebyte = *data;
- }
- }
-
- /* Spit the last byte, if the length is odd. */
- if ( savebyte != NO_PENDING_BYTE ) {
- outw( addr_bmpr8, savebyte );
- }
- }
-
- /* Pad to the Ethernet minimum length, if the packet is too short. */
- if ( length < ETHER_MIN_LEN - ETHER_CRC_LEN ) {
-#ifdef FE_8BIT_SUPPORT
- if ((sc->proto_dlcr6 & FE_D6_SBW) == FE_D6_SBW_BYTE)
- {
- outsb( addr_bmpr8, padding, ETHER_MIN_LEN - ETHER_CRC_LEN - length );
- }
- else
-#endif
- {
- outsw( addr_bmpr8, padding, ( ETHER_MIN_LEN - ETHER_CRC_LEN - length ) >> 1);
- }
- }
-}
-
-/*
- * Compute hash value for an Ethernet address
- */
-static int
-fe_hash ( u_char * ep )
-{
-#define FE_HASH_MAGIC_NUMBER 0xEDB88320L
-
- u_long hash = 0xFFFFFFFFL;
- int i, j;
- u_char b;
- u_long m;
-
- for ( i = ETHER_ADDR_LEN; --i >= 0; ) {
- b = *ep++;
- for ( j = 8; --j >= 0; ) {
- m = hash;
- hash >>= 1;
- if ( ( m ^ b ) & 1 ) hash ^= FE_HASH_MAGIC_NUMBER;
- b >>= 1;
- }
- }
- return ( ( int )( hash >> 26 ) );
-}
-
-/*
- * Compute the multicast address filter from the
- * list of multicast addresses we need to listen to.
- */
-static struct fe_filter
-fe_mcaf ( struct fe_softc *sc )
-{
- int index;
- struct fe_filter filter;
- struct ifmultiaddr *ifma;
-
- filter = fe_filter_nothing;
- for (ifma = sc->arpcom.ac_if.if_multiaddrs.lh_first; ifma;
- ifma = ifma->ifma_link.le_next) {
- if (ifma->ifma_addr->sa_family != AF_LINK)
- continue;
- index = fe_hash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
-#ifdef FE_DEBUG
- printf("fe%d: hash(%6D) == %d\n",
- sc->sc_unit, enm->enm_addrlo , ":", index);
-#endif
-
- filter.data[index >> 3] |= 1 << (index & 7);
- }
- return ( filter );
-}
-
-/*
- * Calculate a new "multicast packet filter" and put the 86960
- * receiver in appropriate mode.
- */
-static void
-fe_setmode ( struct fe_softc *sc )
-{
- int flags = sc->sc_if.if_flags;
-
- /*
- * If the interface is not running, we postpone the update
- * process for receive modes and multicast address filter
- * until the interface is restarted. It reduces some
- * complicated job on maintaining chip states. (Earlier versions
- * of this driver had a bug on that point...)
- *
- * To complete the trick, fe_init() calls fe_setmode() after
- * restarting the interface.
- */
- if ( !( flags & IFF_RUNNING ) ) return;
-
- /*
- * Promiscuous mode is handled separately.
- */
- if ( flags & IFF_PROMISC ) {
- /*
- * Program 86960 to receive all packets on the segment
- * including those directed to other stations.
- * Multicast filter stored in MARs are ignored
- * under this setting, so we don't need to update it.
- *
- * Promiscuous mode in FreeBSD 2 is used solely by
- * BPF, and BPF only listens to valid (no error) packets.
- * So, we ignore erroneous ones even in this mode.
- * (Older versions of fe driver mistook the point.)
- */
- outb( sc->ioaddr[ FE_DLCR5 ],
- sc->proto_dlcr5 | FE_D5_AFM0 | FE_D5_AFM1 );
- sc->filter_change = 0;
- return;
- }
-
- /*
- * Turn the chip to the normal (non-promiscuous) mode.
- */
- outb( sc->ioaddr[ FE_DLCR5 ], sc->proto_dlcr5 | FE_D5_AFM1 );
-
- /*
- * Find the new multicast filter value.
- */
- if ( flags & IFF_ALLMULTI ) {
- sc->filter = fe_filter_all;
- } else {
- sc->filter = fe_mcaf( sc );
- }
- sc->filter_change = 1;
-
- /*
- * We have to update the multicast filter in the 86960, A.S.A.P.
- *
- * Note that the DLC (Data Link Control unit, i.e. transmitter
- * and receiver) must be stopped when feeding the filter, and
- * DLC trashes all packets in both transmission and receive
- * buffers when stopped.
- *
- * To reduce the packet loss, we delay the filter update
- * process until buffers are empty.
- */
- if ( sc->txb_sched == 0 && sc->txb_count == 0
- && !( inb( sc->ioaddr[ FE_DLCR1 ] ) & FE_D1_PKTRDY ) ) {
- /*
- * Buffers are (apparently) empty. Load
- * the new filter value into MARs now.
- */
- fe_loadmar(sc);
- } else {
- /*
- * Buffers are not empty. Mark that we have to update
- * the MARs. The new filter will be loaded by feintr()
- * later.
- */
- }
-}
-
-/*
- * Load a new multicast address filter into MARs.
- *
- * The caller must have splimp'ed before fe_loadmar.
- * This function starts the DLC upon return. So it can be called only
- * when the chip is working, i.e., from the driver's point of view, when
- * a device is RUNNING. (I mistook the point in previous versions.)
- */
-static void
-fe_loadmar ( struct fe_softc * sc )
-{
- /* Stop the DLC (transmitter and receiver). */
- DELAY( 200 );
- outb( sc->ioaddr[ FE_DLCR6 ], sc->proto_dlcr6 | FE_D6_DLC_DISABLE );
- DELAY( 200 );
-
- /* Select register bank 1 for MARs. */
- outb( sc->ioaddr[ FE_DLCR7 ],
- sc->proto_dlcr7 | FE_D7_RBS_MAR | FE_D7_POWER_UP );
-
- /* Copy filter value into the registers. */
- outblk( sc, FE_MAR8, sc->filter.data, FE_FILTER_LEN );
-
- /* Restore the bank selection for BMPRs (i.e., runtime registers). */
- outb( sc->ioaddr[ FE_DLCR7 ],
- sc->proto_dlcr7 | FE_D7_RBS_BMPR | FE_D7_POWER_UP );
-
- /* Restart the DLC. */
- DELAY( 200 );
- outb( sc->ioaddr[ FE_DLCR6 ], sc->proto_dlcr6 | FE_D6_DLC_ENABLE );
- DELAY( 200 );
-
- /* We have just updated the filter. */
- sc->filter_change = 0;
-}
-
-/* Change the media selection. */
-static int
-fe_medchange (struct ifnet *ifp)
-{
- struct fe_softc *sc = (struct fe_softc *)ifp->if_softc;
-
-#ifdef DIAGNOSTIC
- /* If_media should not pass any request for a media which this
- interface doesn't support. */
- int b;
-
- for (b = 0; bit2media[b] != 0; b++) {
- if (bit2media[b] == sc->media.ifm_media) break;
- }
- if (((1 << b) & sc->mbitmap) == 0) {
- printf("fe%d: got an unsupported media request (0x%x)\n",
- sc->sc_unit, sc->media.ifm_media);
- return EINVAL;
- }
-#endif
-
- /* We don't actually change media when the interface is down.
- fe_init() will do the job, instead. Should we also wait
- until the transmission buffer being empty? Changing the
- media when we are sending a frame will cause two garbages
- on wires, one on old media and another on new. FIXME */
- if (sc->sc_if.if_flags & IFF_UP) {
- if (sc->msel) sc->msel(sc);
- }
-
- return 0;
-}
-
-/* I don't know how I can support media status callback... FIXME. */
-static void
-fe_medstat (struct ifnet *ifp, struct ifmediareq *ifmr)
-{
- (void)ifp;
- (void)ifmr;
-}
diff --git a/sys/dev/fe/if_fereg.h b/sys/dev/fe/if_fereg.h
deleted file mode 100644
index 7e28201f6987..000000000000
--- a/sys/dev/fe/if_fereg.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Hardware specification of various 8696x based Ethernet cards.
- * Contributed by M. Sekiguchi <seki@sysrap.cs.fujitsu.co.jp>
- *
- * All Rights Reserved, Copyright (C) Fujitsu Limited 1995
- *
- * This software may be used, modified, copied, distributed, and sold,
- * in both source and binary form provided that the above copyright,
- * these terms and the following disclaimer are retained. The name of
- * the author and/or the contributor 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 AND THE CONTRIBUTOR ``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 THE CONTRIBUTOR 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.
- */
-
-/* $FreeBSD$ */
-
-/*
- * Registers on FMV-180 series' ISA bus interface ASIC.
- * I'm not sure the following register names are appropriate.
- * Doesn't it look silly, eh? FIXME.
- */
-
-#define FE_FMV0 16 /* Card status register #0 */
-#define FE_FMV1 17 /* Card status register #1 */
-#define FE_FMV2 18 /* Card config register #0 */
-#define FE_FMV3 19 /* Card config register #1 */
-#define FE_FMV4 20 /* Station address #1 */
-#define FE_FMV5 21 /* Station address #2 */
-#define FE_FMV6 22 /* Station address #3 */
-#define FE_FMV7 23 /* Station address #4 */
-#define FE_FMV8 24 /* Station address #5 */
-#define FE_FMV9 25 /* Station address #6 */
-#define FE_FMV10 26 /* Buffer RAM control register */
-#define FE_FMV11 27 /* Buffer RAM data register */
-
-/*
- * FMV-180 series' ASIC register values.
- */
-
-/* FMV0: Card status register #0: Misc info? */
-#define FE_FMV0_MEDIA 0x07 /* Supported physical media. */
-#define FE_FMV0_PRRDY 0x10 /* ??? */
-#define FE_FMV0_PRERR 0x20 /* ??? */
-#define FE_FMV0_ERRDY 0x40 /* ??? */
-#define FE_FMV0_IREQ 0x80 /* ??? */
-
-#define FE_FMV0_MEDIUM_5 0x01 /* 10base5/Dsub */
-#define FE_FMV0_MEDIUM_2 0x02 /* 10base2/BNC */
-#define FE_FMV0_MEDIUM_T 0x04 /* 10baseT/RJ45 */
-
-/* Card status register #1: Hardware revision. */
-#define FE_FMV1_REV 0x0F /* Card revision */
-#define FE_FMV1_UPPER 0xF0 /* Usage unknown */
-
-/* Card config register #0: I/O port address assignment. */
-#define FE_FMV2_IOS 0x07 /* I/O selection. */
-#define FE_FMV2_MES 0x38 /* ??? boot ROM? */
-#define FE_FMV2_IRS 0xC0 /* IRQ selection. */
-
-#define FE_FMV2_IOS_SHIFT 0
-#define FE_FMV2_MES_SHIFT 3
-#define FE_FMV2_IRS_SHIFT 6
-
-/* Card config register #1: IRQ enable */
-#define FE_FMV3_IRQENB 0x80 /* IRQ enable. */
-
-/*
- * Register(?) specific to AT1700/RE2000.
- */
-
-#define FE_ATI_RESET 0x1F /* Write to reset the 86965. */
-
-/* EEPROM allocation (offsets) of AT1700/RE2000. */
-#define FE_ATI_EEP_ADDR 0x08 /* Station address. (8-13) */
-#define FE_ATI_EEP_MEDIA 0x18 /* Media type. */
-#define FE_ATI_EEP_MAGIC 0x19 /* XXX Magic. */
-#define FE_ATI_EEP_MODEL 0x1e /* Hardware type. */
-#define FE_ATI_EEP_REVISION 0x1f /* Hardware revision. */
-
-/* Value for FE_ATI_EEP_MODEL. */
-#define FE_ATI_MODEL_AT1700T 0x00
-#define FE_ATI_MODEL_AT1700BT 0x01
-#define FE_ATI_MODEL_AT1700FT 0x02
-#define FE_ATI_MODEL_AT1700AT 0x03
-
-/*
- * Registers on MBH10302.
- */
-
-#define FE_MBH0 0x10 /* ??? Including interrupt. */
-#define FE_MBH1 0x11 /* ??? */
-#define FE_MBH10 0x1A /* Station address. (10 - 15) */
-
-/* Values to be set in MBH0 register. */
-#define FE_MBH0_MAGIC 0x0D /* Just a magic constant? */
-#define FE_MBH0_INTR 0x10 /* Master interrupt control. */
-
-#define FE_MBH0_INTR_ENABLE 0x10 /* Enable interrupts. */
-#define FE_MBH0_INTR_DISABLE 0x00 /* Disable interrupts. */
-
-/*
- * Registers on RE1000. (*NOT* on RE1000 Plus.)
- */
-
-/* IRQ configuration. */
-#define FE_RE1000_IRQCONF 0x10
diff --git a/sys/dev/fe/mb86960.h b/sys/dev/fe/mb86960.h
deleted file mode 100644
index cffe0a01c7a2..000000000000
--- a/sys/dev/fe/mb86960.h
+++ /dev/null
@@ -1,338 +0,0 @@
-/*
- * All Rights Reserved, Copyright (C) Fujitsu Limited 1995
- *
- * This software may be used, modified, copied, distributed, and sold, in
- * both source and binary form provided that the above copyright, these
- * terms and the following disclaimer are retained. The name of the author
- * and/or the contributor 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 AND THE CONTRIBUTOR ``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 THE CONTRIBUTOR 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.
- */
-
-/*
- * Registers of Fujitsu MB86960A/MB86965A series Ethernet controllers.
- * Written and contributed by M.S. <seki@sysrap.cs.fujitsu.co.jp>
- */
-
-/*
- * Notes on register naming:
- *
- * Fujitsu documents for MB86960A/MB86965A uses no mnemorable names
- * for their registers. They defined only three names for 32
- * registers and appended numbers to distinguish registers of
- * same name. Surprisingly, the numbers represent I/O address
- * offsets of the registers from the base addresses, and their
- * names correspond to the "bank" the registers are allocated.
- * All this means that, for example, to say "read DLCR8" has no more
- * than to say "read a register at offset 8 on bank DLCR."
- *
- * The following definitions may look silly, but that's what Fujitsu
- * did, and it is necessary to know these names to read Fujitsu
- * documents..
- */
-
-/* Data Link Control Registrs, on invaliant port addresses. */
-#define FE_DLCR0 0
-#define FE_DLCR1 1
-#define FE_DLCR2 2
-#define FE_DLCR3 3
-#define FE_DLCR4 4
-#define FE_DLCR5 5
-#define FE_DLCR6 6
-#define FE_DLCR7 7
-
-/* More DLCRs, on register bank #0. */
-#define FE_DLCR8 8
-#define FE_DLCR9 9
-#define FE_DLCR10 10
-#define FE_DLCR11 11
-#define FE_DLCR12 12
-#define FE_DLCR13 13
-#define FE_DLCR14 14
-#define FE_DLCR15 15
-
-/* Malticast Address Registers. On register bank #1. */
-#define FE_MAR8 8
-#define FE_MAR9 9
-#define FE_MAR10 10
-#define FE_MAR11 11
-#define FE_MAR12 12
-#define FE_MAR13 13
-#define FE_MAR14 14
-#define FE_MAR15 15
-
-/* Buffer Memory Port Registers. On register back #2. */
-#define FE_BMPR8 8
-#define FE_BMPR9 9
-#define FE_BMPR10 10
-#define FE_BMPR11 11
-#define FE_BMPR12 12
-#define FE_BMPR13 13
-#define FE_BMPR14 14
-#define FE_BMPR15 15
-
-/* More BMPRs, only on 86965, accessible only when JLI mode. */
-#define FE_BMPR16 16
-#define FE_BMPR17 17
-#define FE_BMPR18 18
-#define FE_BMPR19 19
-
-/*
- * Definitions of registers.
- * I don't have Fujitsu documents of MB86960A/MB86965A, so I don't
- * know the official names for each flags and fields. The following
- * names are assigned by me (the author of this file,) since I cannot
- * mnemorize hexadecimal constants for all of these functions.
- * Comments?
- *
- * I've got documents from Fujitsu web site, recently. However, it's
- * too late. Names for some fields (bits) are kept different from
- * those used in the Fujitsu documents...
- */
-
-/* DLCR0 -- transmitter status */
-#define FE_D0_BUSERR 0x01 /* Bus write error? */
-#define FE_D0_COLL16 0x02 /* Collision limit (16) encountered */
-#define FE_D0_COLLID 0x04 /* Collision on last transmission */
-#define FE_D0_JABBER 0x08 /* Jabber */
-#define FE_D0_CRLOST 0x10 /* Carrier lost on last transmission */
-#define FE_D0_PKTRCD 0x20 /* Last packet looped back correctly */
-#define FE_D0_NETBSY 0x40 /* Network Busy (Carrier Detected) */
-#define FE_D0_TXDONE 0x80 /* Transmission complete */
-
-/* DLCR1 -- receiver status */
-#define FE_D1_OVRFLO 0x01 /* Receiver buffer overflow */
-#define FE_D1_CRCERR 0x02 /* CRC error on last packet */
-#define FE_D1_ALGERR 0x04 /* Alignment error on last packet */
-#define FE_D1_SRTPKT 0x08 /* Short (RUNT) packet is received */
-#define FE_D1_RMTRST 0x10 /* Remote reset packet (type = 0x0900) */
-#define FE_D1_DMAEOP 0x20 /* Host asserted End of DMA OPeration */
-#define FE_D1_BUSERR 0x40 /* Bus read error */
-#define FE_D1_PKTRDY 0x80 /* Packet(s) ready on receive buffer */
-
-/* DLCR2 -- transmitter interrupt control; same layout as DLCR0 */
-#define FE_D2_BUSERR FE_D0_BUSERR
-#define FE_D2_COLL16 FE_D0_COLL16
-#define FE_D2_COLLID FE_D0_COLLID
-#define FE_D2_JABBER FE_D0_JABBER
-#define FE_D2_TXDONE FE_D0_TXDONE
-
-#define FE_D2_RESERVED 0x70
-
-/* DLCR3 -- receiver interrupt control; same layout as DLCR1 */
-#define FE_D3_OVRFLO FE_D1_OVRFLO
-#define FE_D3_CRCERR FE_D1_CRCERR
-#define FE_D3_ALGERR FE_D1_ALGERR
-#define FE_D3_SRTPKT FE_D1_SRTPKT
-#define FE_D3_RMTRST FE_D1_RMTRST
-#define FE_D3_DMAEOP FE_D1_DMAEOP
-#define FE_D3_BUSERR FE_D1_BUSERR
-#define FE_D3_PKTRDY FE_D1_PKTRDY
-
-/* DLCR4 -- transmitter operation mode */
-#define FE_D4_DSC 0x01 /* Disable carrier sense on trans. */
-#define FE_D4_LBC 0x02 /* Loop back test control */
-#define FE_D4_CNTRL 0x04 /* - tied to CNTRL pin of the chip */
-#define FE_D4_TEST1 0x08 /* Test output #1 */
-#define FE_D4_COL 0xF0 /* Collision counter */
-
-#define FE_D4_LBC_ENABLE 0x00 /* Perform loop back test */
-#define FE_D4_LBC_DISABLE 0x02 /* Normal operation */
-
-#define FE_D4_COL_SHIFT 4
-
-/* DLCR5 -- receiver operation mode */
-#define FE_D5_AFM0 0x01 /* Receive packets for other stations */
-#define FE_D5_AFM1 0x02 /* Receive packets for this station */
-#define FE_D5_RMTRST 0x04 /* Enable remote reset operation */
-#define FE_D5_SRTPKT 0x08 /* Accept short (RUNT) packets */
-#define FE_D5_SRTADR 0x10 /* Short (16 bits?) MAC address */
-#define FE_D5_BADPKT 0x20 /* Accept packets with error */
-#define FE_D5_BUFEMP 0x40 /* Receive buffer is empty */
-#define FE_D5_TEST2 0x80 /* Test output #2 */
-
-/* DLCR6 -- hardware configuration #0 */
-#define FE_D6_BUFSIZ 0x03 /* Size of NIC buffer SRAM */
-#define FE_D6_TXBSIZ 0x0C /* Size (and config)of trans. buffer */
-#define FE_D6_BBW 0x10 /* Buffer SRAM bus width */
-#define FE_D6_SBW 0x20 /* System bus width */
-#define FE_D6_SRAM 0x40 /* Buffer SRAM access time */
-#define FE_D6_DLC 0x80 /* Disable DLC (recever/transmitter) */
-
-#define FE_D6_BUFSIZ_8KB 0x00 /* The board has 8KB SRAM */
-#define FE_D6_BUFSIZ_16KB 0x01 /* The board has 16KB SRAM */
-#define FE_D6_BUFSIZ_32KB 0x02 /* The board has 32KB SRAM */
-#define FE_D6_BUFSIZ_64KB 0x03 /* The board has 64KB SRAM */
-
-#define FE_D6_TXBSIZ_1x2KB 0x00 /* Single 2KB buffer for trans. */
-#define FE_D6_TXBSIZ_2x2KB 0x04 /* Double 2KB buffers */
-#define FE_D6_TXBSIZ_2x4KB 0x08 /* Double 4KB buffers */
-#define FE_D6_TXBSIZ_2x8KB 0x0C /* Double 8KB buffers */
-
-#define FE_D6_BBW_WORD 0x00 /* SRAM has 16 bit data line */
-#define FE_D6_BBW_BYTE 0x10 /* SRAM has 8 bit data line */
-
-#define FE_D6_SBW_WORD 0x00 /* Access with 16 bit (AT) bus */
-#define FE_D6_SBW_BYTE 0x20 /* Access with 8 bit (XT) bus */
-
-#define FE_D6_SRAM_150ns 0x00 /* The board has slow SRAM */
-#define FE_D6_SRAM_100ns 0x40 /* The board has fast SRAM */
-
-#define FE_D6_DLC_ENABLE 0x00 /* Normal operation */
-#define FE_D6_DLC_DISABLE 0x80 /* Stop sending/receiving */
-
-/* DLC7 -- hardware configuration #1 */
-#define FE_D7_BYTSWP 0x01 /* Host byte order control */
-#define FE_D7_EOPPOL 0x02 /* Polarity of DMA EOP signal */
-#define FE_D7_RBS 0x0C /* Register bank select */
-#define FE_D7_RDYPNS 0x10 /* Senses RDYPNSEL input signal */
-#define FE_D7_POWER 0x20 /* Stand-by (power down) mode control */
-#define FE_D7_IDENT 0xC0 /* Chip identification */
-
-#define FE_D7_BYTSWP_LH 0x00 /* DEC/Intel byte order */
-#define FE_D7_BYTSWP_HL 0x01 /* IBM/Motorolla byte order */
-
-#define FE_D7_RBS_DLCR 0x00 /* Select DLCR8-15 */
-#define FE_D7_RBS_MAR 0x04 /* Select MAR8-15 */
-#define FE_D7_RBS_BMPR 0x08 /* Select BMPR8-15 */
-
-#define FE_D7_POWER_DOWN 0x00 /* Power down (stand-by) mode */
-#define FE_D7_POWER_UP 0x20 /* Normal operation */
-
-#define FE_D7_IDENT_TDK 0x00 /* TDK chips? */
-#define FE_D7_IDENT_NICE 0x80 /* Fujitsu NICE (86960) */
-#define FE_D7_IDENT_EC 0xC0 /* Fujitsu EtherCoupler (86965) */
-
-/* DLCR8 thru DLCR13 are for Ethernet station address. */
-
-/* DLCR14 and DLCR15 are for TDR. (TDR is used for cable diagnostic.) */
-
-/* MAR8 thru MAR15 are for Multicast address filter. */
-
-/* BMPR8 and BMPR9 are for packet data. */
-
-/* BMPR10 -- transmitter start trigger */
-#define FE_B10_START 0x80 /* Start transmitter */
-#define FE_B10_COUNT 0x7F /* Packet count */
-
-/* BMPR11 -- 16 collisions control */
-#define FE_B11_CTRL 0x01 /* Skip or resend errored packets */
-#define FE_B11_MODE1 0x02 /* Restart transmitter after COLL16 */
-#define FE_B11_MODE2 0x04 /* Automatic restart enable */
-
-#define FE_B11_CTRL_RESEND 0x00 /* Re-send the collided packet */
-#define FE_B11_CTRL_SKIP 0x01 /* Skip the collided packet */
-
-/* BMPR12 -- DMA enable */
-#define FE_B12_TXDMA 0x01 /* Enable transmitter DMA */
-#define FE_B12_RXDMA 0x02 /* Enable receiver DMA */
-
-/* BMPR13 -- DMA control */
-#define FE_B13_BSTCTL 0x03 /* DMA burst mode control */
-#define FE_B13_TPTYPE 0x04 /* Twisted pair cable impedance */
-#define FE_B13_PORT 0x18 /* Port (TP/AUI) selection */
-#define FE_B13_LNKTST 0x20 /* Link test enable */
-#define FE_B13_SQTHLD 0x40 /* Lower squelch threshold */
-#define FE_B13_IOUNLK 0x80 /* Change I/O base address, on JLI mode */
-
-#define FE_B13_BSTCTL_1 0x00
-#define FE_B13_BSTCTL_4 0x01
-#define FE_B13_BSTCTL_8 0x02
-#define FE_B13_BSTCLT_12 0x03
-
-#define FE_B13_TPTYPE_UTP 0x00 /* Unshielded (standard) cable */
-#define FE_B13_TPTYPE_STP 0x04 /* Shielded (IBM) cable */
-
-#define FE_B13_PORT_AUTO 0x00 /* Auto detected */
-#define FE_B13_PORT_TP 0x08 /* Force TP */
-#define FE_B13_PORT_AUI 0x18 /* Force AUI */
-
-/* BMPR14 -- More receiver control and more transmission interrupts */
-#define FE_B14_FILTER 0x01 /* Filter out self-originated packets */
-#define FE_B14_SQE 0x02 /* SQE interrupt enable */
-#define FE_B14_SKIP 0x04 /* Skip a received packet */
-#define FE_B14_RJAB 0x20 /* RJAB interrupt enable */
-#define FE_B14_LLD 0x40 /* Local-link-down interrupt enable */
-#define FE_B14_RLD 0x80 /* Remote-link-down interrupt enable */
-
-/* BMPR15 -- More transmitter status; basically same layout as BMPR14 */
-#define FE_B15_SQE FE_B14_SQE
-#define FE_B15_RCVPOL 0x08 /* Reversed receive line polarity */
-#define FE_B15_RMTPRT 0x10 /* ??? */
-#define FE_B15_RAJB FE_B14_RJAB
-#define FE_B15_LLD FE_B14_LLD
-#define FE_B15_RLD FE_B14_RLD
-
-/* BMPR16 -- EEPROM control */
-#define FE_B16_DOUT 0x04 /* EEPROM Data in (CPU to EEPROM) */
-#define FE_B16_SELECT 0x20 /* EEPROM chip select */
-#define FE_B16_CLOCK 0x40 /* EEPROM shift clock */
-#define FE_B16_DIN 0x80 /* EEPROM data out (EEPROM to CPU) */
-
-/* BMPR17 -- EEPROM data */
-#define FE_B17_DATA 0x80 /* EEPROM data bit */
-
-/* BMPR18 -- cycle I/O address setting in JLI mode */
-
-/* BMPR19 -- ISA interface configuration in JLI mode */
-#define FE_B19_IRQ 0xC0
-#define FE_B19_IRQ_SHIFT 6
-
-#define FE_B19_ROM 0x38
-#define FE_B19_ROM_SHIFT 3
-
-#define FE_B19_ADDR 0x07
-#define FE_B19_ADDR_SHIFT 0
-
-/*
- * An extra I/O port address to reset 86965. This location is called
- * "ID ROM area" by Fujitsu document.
- */
-
-/*
- * Flags in Receive Packet Header... Basically same layout as DLCR1.
- */
-#define FE_RPH_OVRFLO FE_D1_OVRFLO
-#define FE_RPH_CRCERR FE_D1_CRCERR
-#define FE_RPH_ALGERR FE_D1_ALGERR
-#define FE_RPH_SRTPKT FE_D1_SRTPKT
-#define FE_RPH_RMTRST FE_D1_RMTRST
-#define FE_RPH_GOOD 0x20 /* Good packet follows */
-
-/*
- * EEPROM specification (of JLI mode).
- */
-
-/* Number of bytes in an EEPROM accessible through 86965. */
-#define FE_EEPROM_SIZE 32
-
-/* Offset for JLI config; automatically copied into BMPR19 at startup. */
-#define FE_EEPROM_CONF 0
-
-/*
- * Some 8696x specific constants.
- */
-
-/* Length (in bytes) of a Multicast Address Filter. */
-#define FE_FILTER_LEN 8
-
-/* How many packets we can put in the transmission buffer on NIC memory. */
-#define FE_QUEUEING_MAX 127
-
-/* Length (in bytes) of a "packet length" word in transmission buffer. */
-#define FE_DATA_LEN_LEN 2
-
-/* Special Multicast Address Filter value. */
-#define FE_FILTER_NOTHING { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }
-#define FE_FILTER_ALL { 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF }
diff --git a/sys/dev/fxp/if_fxp.c b/sys/dev/fxp/if_fxp.c
deleted file mode 100644
index d98a0f210b8b..000000000000
--- a/sys/dev/fxp/if_fxp.c
+++ /dev/null
@@ -1,1997 +0,0 @@
-/*
- * Copyright (c) 1995, David Greenman
- * All rights reserved.
- *
- * Modifications to support NetBSD and media selection:
- * Copyright (c) 1997 Jason R. Thorpe. 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 unmodified, 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Intel EtherExpress Pro/100B PCI Fast Ethernet driver
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <sys/malloc.h>
-#include <sys/kernel.h>
-#include <sys/socket.h>
-
-#include <net/if.h>
-#include <net/if_dl.h>
-#include <net/if_media.h>
-
-#ifdef NS
-#include <netns/ns.h>
-#include <netns/ns_if.h>
-#endif
-
-#include <net/bpf.h>
-
-#if defined(__NetBSD__)
-
-#include <sys/ioctl.h>
-#include <sys/errno.h>
-#include <sys/device.h>
-
-#include <net/if_dl.h>
-#include <net/if_ether.h>
-
-#include <netinet/if_inarp.h>
-
-#include <vm/vm.h>
-
-#include <machine/cpu.h>
-#include <machine/bus.h>
-#include <machine/intr.h>
-
-#include <dev/pci/if_fxpreg.h>
-#include <dev/pci/if_fxpvar.h>
-
-#include <dev/pci/pcivar.h>
-#include <dev/pci/pcireg.h>
-#include <dev/pci/pcidevs.h>
-
-
-#else /* __FreeBSD__ */
-
-#include <sys/sockio.h>
-#include <sys/bus.h>
-#include <machine/bus.h>
-#include <sys/rman.h>
-#include <machine/resource.h>
-
-#include <net/ethernet.h>
-#include <net/if_arp.h>
-
-#include <vm/vm.h> /* for vtophys */
-#include <vm/pmap.h> /* for vtophys */
-#include <machine/clock.h> /* for DELAY */
-
-#include <pci/pcivar.h>
-#include <pci/pcireg.h> /* for PCIM_CMD_xxx */
-#include <pci/if_fxpreg.h>
-#include <pci/if_fxpvar.h>
-
-#endif /* __NetBSD__ */
-
-#ifdef __alpha__ /* XXX */
-/* XXX XXX NEED REAL DMA MAPPING SUPPORT XXX XXX */
-#undef vtophys
-#define vtophys(va) alpha_XXX_dmamap((vm_offset_t)(va))
-#endif /* __alpha__ */
-
-
-#include "opt_bdg.h"
-#ifdef BRIDGE
-#include <net/if_types.h>
-#include <net/bridge.h>
-#endif
-
-/*
- * NOTE! On the Alpha, we have an alignment constraint. The
- * card DMAs the packet immediately following the RFA. However,
- * the first thing in the packet is a 14-byte Ethernet header.
- * This means that the packet is misaligned. To compensate,
- * we actually offset the RFA 2 bytes into the cluster. This
- * alignes the packet after the Ethernet header at a 32-bit
- * boundary. HOWEVER! This means that the RFA is misaligned!
- */
-#define RFA_ALIGNMENT_FUDGE 2
-
-/*
- * Inline function to copy a 16-bit aligned 32-bit quantity.
- */
-static __inline void fxp_lwcopy __P((volatile u_int32_t *,
- volatile u_int32_t *));
-static __inline void
-fxp_lwcopy(src, dst)
- volatile u_int32_t *src, *dst;
-{
- volatile u_int16_t *a = (volatile u_int16_t *)src;
- volatile u_int16_t *b = (volatile u_int16_t *)dst;
-
- b[0] = a[0];
- b[1] = a[1];
-}
-
-/*
- * Template for default configuration parameters.
- * See struct fxp_cb_config for the bit definitions.
- */
-static u_char fxp_cb_config_template[] = {
- 0x0, 0x0, /* cb_status */
- 0x80, 0x2, /* cb_command */
- 0xff, 0xff, 0xff, 0xff, /* link_addr */
- 0x16, /* 0 */
- 0x8, /* 1 */
- 0x0, /* 2 */
- 0x0, /* 3 */
- 0x0, /* 4 */
- 0x80, /* 5 */
- 0xb2, /* 6 */
- 0x3, /* 7 */
- 0x1, /* 8 */
- 0x0, /* 9 */
- 0x26, /* 10 */
- 0x0, /* 11 */
- 0x60, /* 12 */
- 0x0, /* 13 */
- 0xf2, /* 14 */
- 0x48, /* 15 */
- 0x0, /* 16 */
- 0x40, /* 17 */
- 0xf3, /* 18 */
- 0x0, /* 19 */
- 0x3f, /* 20 */
- 0x5 /* 21 */
-};
-
-/* Supported media types. */
-struct fxp_supported_media {
- const int fsm_phy; /* PHY type */
- const int *fsm_media; /* the media array */
- const int fsm_nmedia; /* the number of supported media */
- const int fsm_defmedia; /* default media for this PHY */
-};
-
-static const int fxp_media_standard[] = {
- IFM_ETHER|IFM_10_T,
- IFM_ETHER|IFM_10_T|IFM_FDX,
- IFM_ETHER|IFM_100_TX,
- IFM_ETHER|IFM_100_TX|IFM_FDX,
- IFM_ETHER|IFM_AUTO,
-};
-#define FXP_MEDIA_STANDARD_DEFMEDIA (IFM_ETHER|IFM_AUTO)
-
-static const int fxp_media_default[] = {
- IFM_ETHER|IFM_MANUAL, /* XXX IFM_AUTO ? */
-};
-#define FXP_MEDIA_DEFAULT_DEFMEDIA (IFM_ETHER|IFM_MANUAL)
-
-static const struct fxp_supported_media fxp_media[] = {
- { FXP_PHY_DP83840, fxp_media_standard,
- sizeof(fxp_media_standard) / sizeof(fxp_media_standard[0]),
- FXP_MEDIA_STANDARD_DEFMEDIA },
- { FXP_PHY_DP83840A, fxp_media_standard,
- sizeof(fxp_media_standard) / sizeof(fxp_media_standard[0]),
- FXP_MEDIA_STANDARD_DEFMEDIA },
- { FXP_PHY_82553A, fxp_media_standard,
- sizeof(fxp_media_standard) / sizeof(fxp_media_standard[0]),
- FXP_MEDIA_STANDARD_DEFMEDIA },
- { FXP_PHY_82553C, fxp_media_standard,
- sizeof(fxp_media_standard) / sizeof(fxp_media_standard[0]),
- FXP_MEDIA_STANDARD_DEFMEDIA },
- { FXP_PHY_82555, fxp_media_standard,
- sizeof(fxp_media_standard) / sizeof(fxp_media_standard[0]),
- FXP_MEDIA_STANDARD_DEFMEDIA },
- { FXP_PHY_82555B, fxp_media_standard,
- sizeof(fxp_media_standard) / sizeof(fxp_media_standard[0]),
- FXP_MEDIA_STANDARD_DEFMEDIA },
- { FXP_PHY_80C24, fxp_media_default,
- sizeof(fxp_media_default) / sizeof(fxp_media_default[0]),
- FXP_MEDIA_DEFAULT_DEFMEDIA },
-};
-#define NFXPMEDIA (sizeof(fxp_media) / sizeof(fxp_media[0]))
-
-static int fxp_mediachange __P((struct ifnet *));
-static void fxp_mediastatus __P((struct ifnet *, struct ifmediareq *));
-static void fxp_set_media __P((struct fxp_softc *, int));
-static __inline void fxp_scb_wait __P((struct fxp_softc *));
-static FXP_INTR_TYPE fxp_intr __P((void *));
-static void fxp_start __P((struct ifnet *));
-static int fxp_ioctl __P((struct ifnet *,
- FXP_IOCTLCMD_TYPE, caddr_t));
-static void fxp_init __P((void *));
-static void fxp_stop __P((struct fxp_softc *));
-static void fxp_watchdog __P((struct ifnet *));
-static int fxp_add_rfabuf __P((struct fxp_softc *, struct mbuf *));
-static int fxp_mdi_read __P((struct fxp_softc *, int, int));
-static void fxp_mdi_write __P((struct fxp_softc *, int, int, int));
-static void fxp_read_eeprom __P((struct fxp_softc *, u_int16_t *,
- int, int));
-static int fxp_attach_common __P((struct fxp_softc *, u_int8_t *));
-static void fxp_stats_update __P((void *));
-static void fxp_mc_setup __P((struct fxp_softc *));
-
-/*
- * Set initial transmit threshold at 64 (512 bytes). This is
- * increased by 64 (512 bytes) at a time, to maximum of 192
- * (1536 bytes), if an underrun occurs.
- */
-static int tx_threshold = 64;
-
-/*
- * Number of transmit control blocks. This determines the number
- * of transmit buffers that can be chained in the CB list.
- * This must be a power of two.
- */
-#define FXP_NTXCB 128
-
-/*
- * Number of completed TX commands at which point an interrupt
- * will be generated to garbage collect the attached buffers.
- * Must be at least one less than FXP_NTXCB, and should be
- * enough less so that the transmitter doesn't becomes idle
- * during the buffer rundown (which would reduce performance).
- */
-#define FXP_CXINT_THRESH 120
-
-/*
- * TxCB list index mask. This is used to do list wrap-around.
- */
-#define FXP_TXCB_MASK (FXP_NTXCB - 1)
-
-/*
- * Number of receive frame area buffers. These are large so chose
- * wisely.
- */
-#define FXP_NRFABUFS 64
-
-/*
- * Maximum number of seconds that the receiver can be idle before we
- * assume it's dead and attempt to reset it by reprogramming the
- * multicast filter. This is part of a work-around for a bug in the
- * NIC. See fxp_stats_update().
- */
-#define FXP_MAX_RX_IDLE 15
-
-/*
- * Wait for the previous command to be accepted (but not necessarily
- * completed).
- */
-static __inline void
-fxp_scb_wait(sc)
- struct fxp_softc *sc;
-{
- int i = 10000;
-
- while (CSR_READ_1(sc, FXP_CSR_SCB_COMMAND) && --i);
-}
-
-/*************************************************************
- * Operating system-specific autoconfiguration glue
- *************************************************************/
-
-#if defined(__NetBSD__)
-
-#ifdef __BROKEN_INDIRECT_CONFIG
-static int fxp_match __P((struct device *, void *, void *));
-#else
-static int fxp_match __P((struct device *, struct cfdata *, void *));
-#endif
-static void fxp_attach __P((struct device *, struct device *, void *));
-
-static void fxp_shutdown __P((void *));
-
-/* Compensate for lack of a generic ether_ioctl() */
-static int fxp_ether_ioctl __P((struct ifnet *,
- FXP_IOCTLCMD_TYPE, caddr_t));
-#define ether_ioctl fxp_ether_ioctl
-
-struct cfattach fxp_ca = {
- sizeof(struct fxp_softc), fxp_match, fxp_attach
-};
-
-struct cfdriver fxp_cd = {
- NULL, "fxp", DV_IFNET
-};
-
-/*
- * Check if a device is an 82557.
- */
-static int
-fxp_match(parent, match, aux)
- struct device *parent;
-#ifdef __BROKEN_INDIRECT_CONFIG
- void *match;
-#else
- struct cfdata *match;
-#endif
- void *aux;
-{
- struct pci_attach_args *pa = aux;
-
- if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_INTEL)
- return (0);
-
- switch (PCI_PRODUCT(pa->pa_id)) {
- case PCI_PRODUCT_INTEL_82557:
- return (1);
- }
-
- return (0);
-}
-
-static void
-fxp_attach(parent, self, aux)
- struct device *parent, *self;
- void *aux;
-{
- struct fxp_softc *sc = (struct fxp_softc *)self;
- struct pci_attach_args *pa = aux;
- pci_chipset_tag_t pc = pa->pa_pc;
- pci_intr_handle_t ih;
- const char *intrstr = NULL;
- u_int8_t enaddr[6];
- struct ifnet *ifp;
-
- /*
- * Map control/status registers.
- */
- if (pci_mapreg_map(pa, FXP_PCI_MMBA, PCI_MAPREG_TYPE_MEM, 0,
- &sc->sc_st, &sc->sc_sh, NULL, NULL)) {
- printf(": can't map registers\n");
- return;
- }
- printf(": Intel EtherExpress Pro 10/100B Ethernet\n");
-
- /*
- * Allocate our interrupt.
- */
- if (pci_intr_map(pc, pa->pa_intrtag, pa->pa_intrpin,
- pa->pa_intrline, &ih)) {
- printf("%s: couldn't map interrupt\n", sc->sc_dev.dv_xname);
- return;
- }
- intrstr = pci_intr_string(pc, ih);
- sc->sc_ih = pci_intr_establish(pc, ih, IPL_NET, fxp_intr, sc);
- if (sc->sc_ih == NULL) {
- printf("%s: couldn't establish interrupt",
- sc->sc_dev.dv_xname);
- if (intrstr != NULL)
- printf(" at %s", intrstr);
- printf("\n");
- return;
- }
- printf("%s: interrupting at %s\n", sc->sc_dev.dv_xname, intrstr);
-
- /* Do generic parts of attach. */
- if (fxp_attach_common(sc, enaddr)) {
- /* Failed! */
- return;
- }
-
- printf("%s: Ethernet address %s%s\n", sc->sc_dev.dv_xname,
- ether_sprintf(enaddr), sc->phy_10Mbps_only ? ", 10Mbps" : "");
-
- ifp = &sc->sc_ethercom.ec_if;
- bcopy(sc->sc_dev.dv_xname, ifp->if_xname, IFNAMSIZ);
- ifp->if_softc = sc;
- ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
- ifp->if_ioctl = fxp_ioctl;
- ifp->if_start = fxp_start;
- ifp->if_watchdog = fxp_watchdog;
-
- /*
- * Attach the interface.
- */
- if_attach(ifp);
- /*
- * Let the system queue as many packets as we have available
- * TX descriptors.
- */
- ifp->if_snd.ifq_maxlen = FXP_NTXCB - 1;
- ether_ifattach(ifp, enaddr);
- bpfattach(&sc->sc_ethercom.ec_if.if_bpf, ifp, DLT_EN10MB,
- sizeof(struct ether_header));
-
- /*
- * Add shutdown hook so that DMA is disabled prior to reboot. Not
- * doing do could allow DMA to corrupt kernel memory during the
- * reboot before the driver initializes.
- */
- shutdownhook_establish(fxp_shutdown, sc);
-}
-
-/*
- * Device shutdown routine. Called at system shutdown after sync. The
- * main purpose of this routine is to shut off receiver DMA so that
- * kernel memory doesn't get clobbered during warmboot.
- */
-static void
-fxp_shutdown(sc)
- void *sc;
-{
- fxp_stop((struct fxp_softc *) sc);
-}
-
-static int
-fxp_ether_ioctl(ifp, cmd, data)
- struct ifnet *ifp;
- FXP_IOCTLCMD_TYPE cmd;
- caddr_t data;
-{
- struct ifaddr *ifa = (struct ifaddr *) data;
- struct fxp_softc *sc = ifp->if_softc;
-
- switch (cmd) {
- case SIOCSIFADDR:
- ifp->if_flags |= IFF_UP;
-
- switch (ifa->ifa_addr->sa_family) {
-#ifdef INET
- case AF_INET:
- fxp_init(sc);
- arp_ifinit(ifp, ifa);
- break;
-#endif
-#ifdef NS
- case AF_NS:
- {
- register struct ns_addr *ina = &IA_SNS(ifa)->sns_addr;
-
- if (ns_nullhost(*ina))
- ina->x_host = *(union ns_host *)
- LLADDR(ifp->if_sadl);
- else
- bcopy(ina->x_host.c_host, LLADDR(ifp->if_sadl),
- ifp->if_addrlen);
- /* Set new address. */
- fxp_init(sc);
- break;
- }
-#endif
- default:
- fxp_init(sc);
- break;
- }
- break;
-
- default:
- return (EINVAL);
- }
-
- return (0);
-}
-
-#else /* __FreeBSD__ */
-
-/*
- * Return identification string if this is device is ours.
- */
-static int
-fxp_probe(device_t dev)
-{
- if ((pci_get_vendor(dev) == FXP_VENDORID_INTEL) &&
- (pci_get_device(dev) == FXP_DEVICEID_i82557)) {
- device_set_desc(dev, "Intel EtherExpress Pro 10/100B Ethernet");
- return 0;
- }
- if ((pci_get_vendor(dev) == FXP_VENDORID_INTEL) &&
- (pci_get_device(dev) == FXP_DEVICEID_i82559)) {
- device_set_desc(dev, "Intel InBusiness 10/100 Ethernet");
- return 0;
- }
-
- return ENXIO;
-}
-
-static int
-fxp_attach(device_t dev)
-{
- int error = 0;
- struct fxp_softc *sc = device_get_softc(dev);
- struct ifnet *ifp;
- int s;
- u_long val;
- int rid;
-
- callout_handle_init(&sc->stat_ch);
-
- s = splimp();
-
- /*
- * Enable bus mastering.
- */
- val = pci_read_config(dev, PCIR_COMMAND, 2);
- val |= (PCIM_CMD_MEMEN|PCIM_CMD_BUSMASTEREN);
- pci_write_config(dev, PCIR_COMMAND, val, 2);
-
- /*
- * Map control/status registers.
- */
- rid = FXP_PCI_MMBA;
- sc->mem = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid,
- 0, ~0, 1, RF_ACTIVE);
- if (!sc->mem) {
- device_printf(dev, "could not map memory\n");
- error = ENXIO;
- goto fail;
- }
-
- sc->sc_st = rman_get_bustag(sc->mem);
- sc->sc_sh = rman_get_bushandle(sc->mem);
-
- /*
- * Allocate our interrupt.
- */
- rid = 0;
- sc->irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1,
- RF_SHAREABLE | RF_ACTIVE);
- if (sc->irq == NULL) {
- device_printf(dev, "could not map interrupt\n");
- error = ENXIO;
- goto fail;
- }
-
- error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET,
- fxp_intr, sc, &sc->ih);
- if (error) {
- device_printf(dev, "could not setup irq\n");
- goto fail;
- }
-
- /* Do generic parts of attach. */
- if (fxp_attach_common(sc, sc->arpcom.ac_enaddr)) {
- /* Failed! */
- bus_teardown_intr(dev, sc->irq, sc->ih);
- bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq);
- bus_release_resource(dev, SYS_RES_MEMORY, FXP_PCI_MMBA, sc->mem);
- error = ENXIO;
- goto fail;
- }
-
- device_printf(dev, "Ethernet address %6D%s\n",
- sc->arpcom.ac_enaddr, ":", sc->phy_10Mbps_only ? ", 10Mbps" : "");
-
- ifp = &sc->arpcom.ac_if;
- ifp->if_unit = device_get_unit(dev);
- ifp->if_name = "fxp";
- ifp->if_output = ether_output;
- ifp->if_baudrate = 100000000;
- ifp->if_init = fxp_init;
- ifp->if_softc = sc;
- ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
- ifp->if_ioctl = fxp_ioctl;
- ifp->if_start = fxp_start;
- ifp->if_watchdog = fxp_watchdog;
-
- /*
- * Attach the interface.
- */
- if_attach(ifp);
- /*
- * Let the system queue as many packets as we have available
- * TX descriptors.
- */
- ifp->if_snd.ifq_maxlen = FXP_NTXCB - 1;
- ether_ifattach(ifp);
- bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
-
- splx(s);
- return 0;
-
- fail:
- splx(s);
- return error;
-}
-
-/*
- * Detach interface.
- */
-static int
-fxp_detach(device_t dev)
-{
- struct fxp_softc *sc = device_get_softc(dev);
- int s;
-
- s = splimp();
-
- /*
- * Close down routes etc.
- */
- if_detach(&sc->arpcom.ac_if);
-
- /*
- * Stop DMA and drop transmit queue.
- */
- fxp_stop(sc);
-
- /*
- * Deallocate resources.
- */
- bus_teardown_intr(dev, sc->irq, sc->ih);
- bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq);
- bus_release_resource(dev, SYS_RES_MEMORY, FXP_PCI_MMBA, sc->mem);
-
- /*
- * Free all the receive buffers.
- */
- if (sc->rfa_headm != NULL)
- m_freem(sc->rfa_headm);
-
- /*
- * Free all media structures.
- */
- ifmedia_removeall(&sc->sc_media);
-
- /*
- * Free anciliary structures.
- */
- free(sc->cbl_base, M_DEVBUF);
- free(sc->fxp_stats, M_DEVBUF);
- free(sc->mcsp, M_DEVBUF);
-
- splx(s);
-
- return 0;
-}
-
-/*
- * Device shutdown routine. Called at system shutdown after sync. The
- * main purpose of this routine is to shut off receiver DMA so that
- * kernel memory doesn't get clobbered during warmboot.
- */
-static int
-fxp_shutdown(device_t dev)
-{
- /*
- * Make sure that DMA is disabled prior to reboot. Not doing
- * do could allow DMA to corrupt kernel memory during the
- * reboot before the driver initializes.
- */
- fxp_stop((struct fxp_softc *) device_get_softc(dev));
- return 0;
-}
-
-static device_method_t fxp_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, fxp_probe),
- DEVMETHOD(device_attach, fxp_attach),
- DEVMETHOD(device_detach, fxp_detach),
- DEVMETHOD(device_shutdown, fxp_shutdown),
-
- { 0, 0 }
-};
-
-static driver_t fxp_driver = {
- "fxp",
- fxp_methods,
- sizeof(struct fxp_softc),
-};
-
-static devclass_t fxp_devclass;
-
-DRIVER_MODULE(if_fxp, pci, fxp_driver, fxp_devclass, 0, 0);
-
-#endif /* __NetBSD__ */
-
-/*************************************************************
- * End of operating system-specific autoconfiguration glue
- *************************************************************/
-
-/*
- * Do generic parts of attach.
- */
-static int
-fxp_attach_common(sc, enaddr)
- struct fxp_softc *sc;
- u_int8_t *enaddr;
-{
- u_int16_t data;
- int i, nmedia, defmedia;
- const int *media;
-
- /*
- * Reset to a stable state.
- */
- CSR_WRITE_4(sc, FXP_CSR_PORT, FXP_PORT_SELECTIVE_RESET);
- DELAY(10);
-
- sc->cbl_base = malloc(sizeof(struct fxp_cb_tx) * FXP_NTXCB,
- M_DEVBUF, M_NOWAIT);
- if (sc->cbl_base == NULL)
- goto fail;
- bzero(sc->cbl_base, sizeof(struct fxp_cb_tx) * FXP_NTXCB);
-
- sc->fxp_stats = malloc(sizeof(struct fxp_stats), M_DEVBUF, M_NOWAIT);
- if (sc->fxp_stats == NULL)
- goto fail;
- bzero(sc->fxp_stats, sizeof(struct fxp_stats));
-
- sc->mcsp = malloc(sizeof(struct fxp_cb_mcs), M_DEVBUF, M_NOWAIT);
- if (sc->mcsp == NULL)
- goto fail;
-
- /*
- * Pre-allocate our receive buffers.
- */
- for (i = 0; i < FXP_NRFABUFS; i++) {
- if (fxp_add_rfabuf(sc, NULL) != 0) {
- goto fail;
- }
- }
-
- /*
- * Get info about the primary PHY
- */
- fxp_read_eeprom(sc, (u_int16_t *)&data, 6, 1);
- sc->phy_primary_addr = data & 0xff;
- sc->phy_primary_device = (data >> 8) & 0x3f;
- sc->phy_10Mbps_only = data >> 15;
-
- /*
- * Read MAC address.
- */
- fxp_read_eeprom(sc, (u_int16_t *)enaddr, 0, 3);
-
- /*
- * Initialize the media structures.
- */
-
- media = fxp_media_default;
- nmedia = sizeof(fxp_media_default) / sizeof(fxp_media_default[0]);
- defmedia = FXP_MEDIA_DEFAULT_DEFMEDIA;
-
- for (i = 0; i < NFXPMEDIA; i++) {
- if (sc->phy_primary_device == fxp_media[i].fsm_phy) {
- media = fxp_media[i].fsm_media;
- nmedia = fxp_media[i].fsm_nmedia;
- defmedia = fxp_media[i].fsm_defmedia;
- }
- }
-
- ifmedia_init(&sc->sc_media, 0, fxp_mediachange, fxp_mediastatus);
- for (i = 0; i < nmedia; i++) {
- if (IFM_SUBTYPE(media[i]) == IFM_100_TX && sc->phy_10Mbps_only)
- continue;
- ifmedia_add(&sc->sc_media, media[i], 0, NULL);
- }
- ifmedia_set(&sc->sc_media, defmedia);
-
- return (0);
-
- fail:
- printf(FXP_FORMAT ": Failed to malloc memory\n", FXP_ARGS(sc));
- if (sc->cbl_base)
- free(sc->cbl_base, M_DEVBUF);
- if (sc->fxp_stats)
- free(sc->fxp_stats, M_DEVBUF);
- if (sc->mcsp)
- free(sc->mcsp, M_DEVBUF);
- /* frees entire chain */
- if (sc->rfa_headm)
- m_freem(sc->rfa_headm);
-
- return (ENOMEM);
-}
-
-/*
- * Read from the serial EEPROM. Basically, you manually shift in
- * the read opcode (one bit at a time) and then shift in the address,
- * and then you shift out the data (all of this one bit at a time).
- * The word size is 16 bits, so you have to provide the address for
- * every 16 bits of data.
- */
-static void
-fxp_read_eeprom(sc, data, offset, words)
- struct fxp_softc *sc;
- u_short *data;
- int offset;
- int words;
-{
- u_int16_t reg;
- int i, x;
-
- for (i = 0; i < words; i++) {
- CSR_WRITE_2(sc, FXP_CSR_EEPROMCONTROL, FXP_EEPROM_EECS);
- /*
- * Shift in read opcode.
- */
- for (x = 3; x > 0; x--) {
- if (FXP_EEPROM_OPC_READ & (1 << (x - 1))) {
- reg = FXP_EEPROM_EECS | FXP_EEPROM_EEDI;
- } else {
- reg = FXP_EEPROM_EECS;
- }
- CSR_WRITE_2(sc, FXP_CSR_EEPROMCONTROL, reg);
- CSR_WRITE_2(sc, FXP_CSR_EEPROMCONTROL,
- reg | FXP_EEPROM_EESK);
- DELAY(1);
- CSR_WRITE_2(sc, FXP_CSR_EEPROMCONTROL, reg);
- DELAY(1);
- }
- /*
- * Shift in address.
- */
- for (x = 6; x > 0; x--) {
- if ((i + offset) & (1 << (x - 1))) {
- reg = FXP_EEPROM_EECS | FXP_EEPROM_EEDI;
- } else {
- reg = FXP_EEPROM_EECS;
- }
- CSR_WRITE_2(sc, FXP_CSR_EEPROMCONTROL, reg);
- CSR_WRITE_2(sc, FXP_CSR_EEPROMCONTROL,
- reg | FXP_EEPROM_EESK);
- DELAY(1);
- CSR_WRITE_2(sc, FXP_CSR_EEPROMCONTROL, reg);
- DELAY(1);
- }
- reg = FXP_EEPROM_EECS;
- data[i] = 0;
- /*
- * Shift out data.
- */
- for (x = 16; x > 0; x--) {
- CSR_WRITE_2(sc, FXP_CSR_EEPROMCONTROL,
- reg | FXP_EEPROM_EESK);
- DELAY(1);
- if (CSR_READ_2(sc, FXP_CSR_EEPROMCONTROL) &
- FXP_EEPROM_EEDO)
- data[i] |= (1 << (x - 1));
- CSR_WRITE_2(sc, FXP_CSR_EEPROMCONTROL, reg);
- DELAY(1);
- }
- CSR_WRITE_2(sc, FXP_CSR_EEPROMCONTROL, 0);
- DELAY(1);
- }
-}
-
-/*
- * Start packet transmission on the interface.
- */
-static void
-fxp_start(ifp)
- struct ifnet *ifp;
-{
- struct fxp_softc *sc = ifp->if_softc;
- struct fxp_cb_tx *txp;
-
- /*
- * See if we need to suspend xmit until the multicast filter
- * has been reprogrammed (which can only be done at the head
- * of the command chain).
- */
- if (sc->need_mcsetup)
- return;
-
- txp = NULL;
-
- /*
- * We're finished if there is nothing more to add to the list or if
- * we're all filled up with buffers to transmit.
- * NOTE: One TxCB is reserved to guarantee that fxp_mc_setup() can add
- * a NOP command when needed.
- */
- while (ifp->if_snd.ifq_head != NULL && sc->tx_queued < FXP_NTXCB - 1) {
- struct mbuf *m, *mb_head;
- int segment;
-
- /*
- * Grab a packet to transmit.
- */
- IF_DEQUEUE(&ifp->if_snd, mb_head);
-
- /*
- * Get pointer to next available tx desc.
- */
- txp = sc->cbl_last->next;
-
- /*
- * Go through each of the mbufs in the chain and initialize
- * the transmit buffer descriptors with the physical address
- * and size of the mbuf.
- */
-tbdinit:
- for (m = mb_head, segment = 0; m != NULL; m = m->m_next) {
- if (m->m_len != 0) {
- if (segment == FXP_NTXSEG)
- break;
- txp->tbd[segment].tb_addr =
- vtophys(mtod(m, vm_offset_t));
- txp->tbd[segment].tb_size = m->m_len;
- segment++;
- }
- }
- if (m != NULL) {
- struct mbuf *mn;
-
- /*
- * We ran out of segments. We have to recopy this mbuf
- * chain first. Bail out if we can't get the new buffers.
- */
- MGETHDR(mn, M_DONTWAIT, MT_DATA);
- if (mn == NULL) {
- m_freem(mb_head);
- break;
- }
- if (mb_head->m_pkthdr.len > MHLEN) {
- MCLGET(mn, M_DONTWAIT);
- if ((mn->m_flags & M_EXT) == 0) {
- m_freem(mn);
- m_freem(mb_head);
- break;
- }
- }
- m_copydata(mb_head, 0, mb_head->m_pkthdr.len,
- mtod(mn, caddr_t));
- mn->m_pkthdr.len = mn->m_len = mb_head->m_pkthdr.len;
- m_freem(mb_head);
- mb_head = mn;
- goto tbdinit;
- }
-
- txp->tbd_number = segment;
- txp->mb_head = mb_head;
- txp->cb_status = 0;
- if (sc->tx_queued != FXP_CXINT_THRESH - 1) {
- txp->cb_command =
- FXP_CB_COMMAND_XMIT | FXP_CB_COMMAND_SF | FXP_CB_COMMAND_S;
- } else {
- txp->cb_command =
- FXP_CB_COMMAND_XMIT | FXP_CB_COMMAND_SF | FXP_CB_COMMAND_S | FXP_CB_COMMAND_I;
- /*
- * Set a 5 second timer just in case we don't hear from the
- * card again.
- */
- ifp->if_timer = 5;
- }
- txp->tx_threshold = tx_threshold;
-
- /*
- * Advance the end of list forward.
- */
- sc->cbl_last->cb_command &= ~FXP_CB_COMMAND_S;
- sc->cbl_last = txp;
-
- /*
- * Advance the beginning of the list forward if there are
- * no other packets queued (when nothing is queued, cbl_first
- * sits on the last TxCB that was sent out).
- */
- if (sc->tx_queued == 0)
- sc->cbl_first = txp;
-
- sc->tx_queued++;
-
- /*
- * Pass packet to bpf if there is a listener.
- */
- if (ifp->if_bpf)
- bpf_mtap(FXP_BPFTAP_ARG(ifp), mb_head);
- }
-
- /*
- * We're finished. If we added to the list, issue a RESUME to get DMA
- * going again if suspended.
- */
- if (txp != NULL) {
- fxp_scb_wait(sc);
- CSR_WRITE_1(sc, FXP_CSR_SCB_COMMAND, FXP_SCB_COMMAND_CU_RESUME);
- }
-}
-
-/*
- * Process interface interrupts.
- */
-static FXP_INTR_TYPE
-fxp_intr(arg)
- void *arg;
-{
- struct fxp_softc *sc = arg;
- struct ifnet *ifp = &sc->sc_if;
- u_int8_t statack;
-#if defined(__NetBSD__)
- int claimed = 0;
-#endif
-
- while ((statack = CSR_READ_1(sc, FXP_CSR_SCB_STATACK)) != 0) {
-#if defined(__NetBSD__)
- claimed = 1;
-#endif
- /*
- * First ACK all the interrupts in this pass.
- */
- CSR_WRITE_1(sc, FXP_CSR_SCB_STATACK, statack);
-
- /*
- * Free any finished transmit mbuf chains.
- */
- if (statack & FXP_SCB_STATACK_CXTNO) {
- struct fxp_cb_tx *txp;
-
- for (txp = sc->cbl_first; sc->tx_queued &&
- (txp->cb_status & FXP_CB_STATUS_C) != 0;
- txp = txp->next) {
- if (txp->mb_head != NULL) {
- m_freem(txp->mb_head);
- txp->mb_head = NULL;
- }
- sc->tx_queued--;
- }
- sc->cbl_first = txp;
- ifp->if_timer = 0;
- if (sc->tx_queued == 0) {
- if (sc->need_mcsetup)
- fxp_mc_setup(sc);
- }
- /*
- * Try to start more packets transmitting.
- */
- if (ifp->if_snd.ifq_head != NULL)
- fxp_start(ifp);
- }
- /*
- * Process receiver interrupts. If a no-resource (RNR)
- * condition exists, get whatever packets we can and
- * re-start the receiver.
- */
- if (statack & (FXP_SCB_STATACK_FR | FXP_SCB_STATACK_RNR)) {
- struct mbuf *m;
- struct fxp_rfa *rfa;
-rcvloop:
- m = sc->rfa_headm;
- rfa = (struct fxp_rfa *)(m->m_ext.ext_buf +
- RFA_ALIGNMENT_FUDGE);
-
- if (rfa->rfa_status & FXP_RFA_STATUS_C) {
- /*
- * Remove first packet from the chain.
- */
- sc->rfa_headm = m->m_next;
- m->m_next = NULL;
-
- /*
- * Add a new buffer to the receive chain.
- * If this fails, the old buffer is recycled
- * instead.
- */
- if (fxp_add_rfabuf(sc, m) == 0) {
- struct ether_header *eh;
- u_int16_t total_len;
-
- total_len = rfa->actual_size &
- (MCLBYTES - 1);
- if (total_len <
- sizeof(struct ether_header)) {
- m_freem(m);
- goto rcvloop;
- }
- m->m_pkthdr.rcvif = ifp;
- m->m_pkthdr.len = m->m_len =
- total_len ;
- eh = mtod(m, struct ether_header *);
- if (ifp->if_bpf)
- bpf_tap(FXP_BPFTAP_ARG(ifp),
- mtod(m, caddr_t),
- total_len);
-#ifdef BRIDGE
- if (do_bridge) {
- struct ifnet *bdg_ifp ;
- bdg_ifp = bridge_in(m);
- if (bdg_ifp == BDG_DROP)
- goto dropit ;
- if (bdg_ifp != BDG_LOCAL)
- bdg_forward(&m, bdg_ifp);
- if (bdg_ifp != BDG_LOCAL &&
- bdg_ifp != BDG_BCAST &&
- bdg_ifp != BDG_MCAST)
- goto dropit ;
- goto getit ;
- }
-#endif
- /*
- * Only pass this packet up
- * if it is for us.
- */
- if ((ifp->if_flags &
- IFF_PROMISC) &&
- (rfa->rfa_status &
- FXP_RFA_STATUS_IAMATCH) &&
- (eh->ether_dhost[0] & 1)
- == 0) {
-#ifdef BRIDGE
-dropit:
-#endif
- if (m)
- m_freem(m);
- goto rcvloop;
- }
-#ifdef BRIDGE
-getit:
-#endif
- m->m_data +=
- sizeof(struct ether_header);
- m->m_len -=
- sizeof(struct ether_header);
- m->m_pkthdr.len = m->m_len ;
- ether_input(ifp, eh, m);
- }
- goto rcvloop;
- }
- if (statack & FXP_SCB_STATACK_RNR) {
- fxp_scb_wait(sc);
- CSR_WRITE_4(sc, FXP_CSR_SCB_GENERAL,
- vtophys(sc->rfa_headm->m_ext.ext_buf) +
- RFA_ALIGNMENT_FUDGE);
- CSR_WRITE_1(sc, FXP_CSR_SCB_COMMAND,
- FXP_SCB_COMMAND_RU_START);
- }
- }
- }
-#if defined(__NetBSD__)
- return (claimed);
-#endif
-}
-
-/*
- * Update packet in/out/collision statistics. The i82557 doesn't
- * allow you to access these counters without doing a fairly
- * expensive DMA to get _all_ of the statistics it maintains, so
- * we do this operation here only once per second. The statistics
- * counters in the kernel are updated from the previous dump-stats
- * DMA and then a new dump-stats DMA is started. The on-chip
- * counters are zeroed when the DMA completes. If we can't start
- * the DMA immediately, we don't wait - we just prepare to read
- * them again next time.
- */
-static void
-fxp_stats_update(arg)
- void *arg;
-{
- struct fxp_softc *sc = arg;
- struct ifnet *ifp = &sc->sc_if;
- struct fxp_stats *sp = sc->fxp_stats;
- struct fxp_cb_tx *txp;
- int s;
-
- ifp->if_opackets += sp->tx_good;
- ifp->if_collisions += sp->tx_total_collisions;
- if (sp->rx_good) {
- ifp->if_ipackets += sp->rx_good;
- sc->rx_idle_secs = 0;
- } else {
- /*
- * Receiver's been idle for another second.
- */
- sc->rx_idle_secs++;
- }
- ifp->if_ierrors +=
- sp->rx_crc_errors +
- sp->rx_alignment_errors +
- sp->rx_rnr_errors +
- sp->rx_overrun_errors;
- /*
- * If any transmit underruns occured, bump up the transmit
- * threshold by another 512 bytes (64 * 8).
- */
- if (sp->tx_underruns) {
- ifp->if_oerrors += sp->tx_underruns;
- if (tx_threshold < 192)
- tx_threshold += 64;
- }
- s = splimp();
- /*
- * Release any xmit buffers that have completed DMA. This isn't
- * strictly necessary to do here, but it's advantagous for mbufs
- * with external storage to be released in a timely manner rather
- * than being defered for a potentially long time. This limits
- * the delay to a maximum of one second.
- */
- for (txp = sc->cbl_first; sc->tx_queued &&
- (txp->cb_status & FXP_CB_STATUS_C) != 0;
- txp = txp->next) {
- if (txp->mb_head != NULL) {
- m_freem(txp->mb_head);
- txp->mb_head = NULL;
- }
- sc->tx_queued--;
- }
- sc->cbl_first = txp;
- /*
- * If we haven't received any packets in FXP_MAC_RX_IDLE seconds,
- * then assume the receiver has locked up and attempt to clear
- * the condition by reprogramming the multicast filter. This is
- * a work-around for a bug in the 82557 where the receiver locks
- * up if it gets certain types of garbage in the syncronization
- * bits prior to the packet header. This bug is supposed to only
- * occur in 10Mbps mode, but has been seen to occur in 100Mbps
- * mode as well (perhaps due to a 10/100 speed transition).
- */
- if (sc->rx_idle_secs > FXP_MAX_RX_IDLE) {
- sc->rx_idle_secs = 0;
- fxp_mc_setup(sc);
- }
- /*
- * If there is no pending command, start another stats
- * dump. Otherwise punt for now.
- */
- if (CSR_READ_1(sc, FXP_CSR_SCB_COMMAND) == 0) {
- /*
- * Start another stats dump.
- */
- CSR_WRITE_1(sc, FXP_CSR_SCB_COMMAND,
- FXP_SCB_COMMAND_CU_DUMPRESET);
- } else {
- /*
- * A previous command is still waiting to be accepted.
- * Just zero our copy of the stats and wait for the
- * next timer event to update them.
- */
- sp->tx_good = 0;
- sp->tx_underruns = 0;
- sp->tx_total_collisions = 0;
-
- sp->rx_good = 0;
- sp->rx_crc_errors = 0;
- sp->rx_alignment_errors = 0;
- sp->rx_rnr_errors = 0;
- sp->rx_overrun_errors = 0;
- }
- splx(s);
- /*
- * Schedule another timeout one second from now.
- */
- sc->stat_ch = timeout(fxp_stats_update, sc, hz);
-}
-
-/*
- * Stop the interface. Cancels the statistics updater and resets
- * the interface.
- */
-static void
-fxp_stop(sc)
- struct fxp_softc *sc;
-{
- struct ifnet *ifp = &sc->sc_if;
- struct fxp_cb_tx *txp;
- int i;
-
- /*
- * Cancel stats updater.
- */
- untimeout(fxp_stats_update, sc, sc->stat_ch);
-
- /*
- * Issue software reset
- */
- CSR_WRITE_4(sc, FXP_CSR_PORT, FXP_PORT_SELECTIVE_RESET);
- DELAY(10);
-
- /*
- * Release any xmit buffers.
- */
- txp = sc->cbl_base;
- if (txp != NULL) {
- for (i = 0; i < FXP_NTXCB; i++) {
- if (txp[i].mb_head != NULL) {
- m_freem(txp[i].mb_head);
- txp[i].mb_head = NULL;
- }
- }
- }
- sc->tx_queued = 0;
-
- /*
- * Free all the receive buffers then reallocate/reinitialize
- */
- if (sc->rfa_headm != NULL)
- m_freem(sc->rfa_headm);
- sc->rfa_headm = NULL;
- sc->rfa_tailm = NULL;
- for (i = 0; i < FXP_NRFABUFS; i++) {
- if (fxp_add_rfabuf(sc, NULL) != 0) {
- /*
- * This "can't happen" - we're at splimp()
- * and we just freed all the buffers we need
- * above.
- */
- panic("fxp_stop: no buffers!");
- }
- }
-
- ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
- ifp->if_timer = 0;
-}
-
-/*
- * Watchdog/transmission transmit timeout handler. Called when a
- * transmission is started on the interface, but no interrupt is
- * received before the timeout. This usually indicates that the
- * card has wedged for some reason.
- */
-static void
-fxp_watchdog(ifp)
- struct ifnet *ifp;
-{
- struct fxp_softc *sc = ifp->if_softc;
-
- printf(FXP_FORMAT ": device timeout\n", FXP_ARGS(sc));
- ifp->if_oerrors++;
-
- fxp_init(sc);
-}
-
-static void
-fxp_init(xsc)
- void *xsc;
-{
- struct fxp_softc *sc = xsc;
- struct ifnet *ifp = &sc->sc_if;
- struct fxp_cb_config *cbp;
- struct fxp_cb_ias *cb_ias;
- struct fxp_cb_tx *txp;
- int i, s, prm;
-
- s = splimp();
- /*
- * Cancel any pending I/O
- */
- fxp_stop(sc);
-
- prm = (ifp->if_flags & IFF_PROMISC) ? 1 : 0;
-
- /*
- * Initialize base of CBL and RFA memory. Loading with zero
- * sets it up for regular linear addressing.
- */
- CSR_WRITE_4(sc, FXP_CSR_SCB_GENERAL, 0);
- CSR_WRITE_1(sc, FXP_CSR_SCB_COMMAND, FXP_SCB_COMMAND_CU_BASE);
-
- fxp_scb_wait(sc);
- CSR_WRITE_1(sc, FXP_CSR_SCB_COMMAND, FXP_SCB_COMMAND_RU_BASE);
-
- /*
- * Initialize base of dump-stats buffer.
- */
- fxp_scb_wait(sc);
- CSR_WRITE_4(sc, FXP_CSR_SCB_GENERAL, vtophys(sc->fxp_stats));
- CSR_WRITE_1(sc, FXP_CSR_SCB_COMMAND, FXP_SCB_COMMAND_CU_DUMP_ADR);
-
- /*
- * We temporarily use memory that contains the TxCB list to
- * construct the config CB. The TxCB list memory is rebuilt
- * later.
- */
- cbp = (struct fxp_cb_config *) sc->cbl_base;
-
- /*
- * This bcopy is kind of disgusting, but there are a bunch of must be
- * zero and must be one bits in this structure and this is the easiest
- * way to initialize them all to proper values.
- */
- bcopy(fxp_cb_config_template, (volatile void *)&cbp->cb_status,
- sizeof(fxp_cb_config_template));
-
- cbp->cb_status = 0;
- cbp->cb_command = FXP_CB_COMMAND_CONFIG | FXP_CB_COMMAND_EL;
- cbp->link_addr = -1; /* (no) next command */
- cbp->byte_count = 22; /* (22) bytes to config */
- cbp->rx_fifo_limit = 8; /* rx fifo threshold (32 bytes) */
- cbp->tx_fifo_limit = 0; /* tx fifo threshold (0 bytes) */
- cbp->adaptive_ifs = 0; /* (no) adaptive interframe spacing */
- cbp->rx_dma_bytecount = 0; /* (no) rx DMA max */
- cbp->tx_dma_bytecount = 0; /* (no) tx DMA max */
- cbp->dma_bce = 0; /* (disable) dma max counters */
- cbp->late_scb = 0; /* (don't) defer SCB update */
- cbp->tno_int = 0; /* (disable) tx not okay interrupt */
- cbp->ci_int = 1; /* interrupt on CU idle */
- cbp->save_bf = prm; /* save bad frames */
- cbp->disc_short_rx = !prm; /* discard short packets */
- cbp->underrun_retry = 1; /* retry mode (1) on DMA underrun */
- cbp->mediatype = !sc->phy_10Mbps_only; /* interface mode */
- cbp->nsai = 1; /* (don't) disable source addr insert */
- cbp->preamble_length = 2; /* (7 byte) preamble */
- cbp->loopback = 0; /* (don't) loopback */
- cbp->linear_priority = 0; /* (normal CSMA/CD operation) */
- cbp->linear_pri_mode = 0; /* (wait after xmit only) */
- cbp->interfrm_spacing = 6; /* (96 bits of) interframe spacing */
- cbp->promiscuous = prm; /* promiscuous mode */
- cbp->bcast_disable = 0; /* (don't) disable broadcasts */
- cbp->crscdt = 0; /* (CRS only) */
- cbp->stripping = !prm; /* truncate rx packet to byte count */
- cbp->padding = 1; /* (do) pad short tx packets */
- cbp->rcv_crc_xfer = 0; /* (don't) xfer CRC to host */
- cbp->force_fdx = 0; /* (don't) force full duplex */
- cbp->fdx_pin_en = 1; /* (enable) FDX# pin */
- cbp->multi_ia = 0; /* (don't) accept multiple IAs */
- cbp->mc_all = sc->all_mcasts;/* accept all multicasts */
-
- /*
- * Start the config command/DMA.
- */
- fxp_scb_wait(sc);
- CSR_WRITE_4(sc, FXP_CSR_SCB_GENERAL, vtophys(&cbp->cb_status));
- CSR_WRITE_1(sc, FXP_CSR_SCB_COMMAND, FXP_SCB_COMMAND_CU_START);
- /* ...and wait for it to complete. */
- while (!(cbp->cb_status & FXP_CB_STATUS_C));
-
- /*
- * Now initialize the station address. Temporarily use the TxCB
- * memory area like we did above for the config CB.
- */
- cb_ias = (struct fxp_cb_ias *) sc->cbl_base;
- cb_ias->cb_status = 0;
- cb_ias->cb_command = FXP_CB_COMMAND_IAS | FXP_CB_COMMAND_EL;
- cb_ias->link_addr = -1;
-#if defined(__NetBSD__)
- bcopy(LLADDR(ifp->if_sadl), (void *)cb_ias->macaddr, 6);
-#else
- bcopy(sc->arpcom.ac_enaddr, (volatile void *)cb_ias->macaddr,
- sizeof(sc->arpcom.ac_enaddr));
-#endif /* __NetBSD__ */
-
- /*
- * Start the IAS (Individual Address Setup) command/DMA.
- */
- fxp_scb_wait(sc);
- CSR_WRITE_1(sc, FXP_CSR_SCB_COMMAND, FXP_SCB_COMMAND_CU_START);
- /* ...and wait for it to complete. */
- while (!(cb_ias->cb_status & FXP_CB_STATUS_C));
-
- /*
- * Initialize transmit control block (TxCB) list.
- */
-
- txp = sc->cbl_base;
- bzero(txp, sizeof(struct fxp_cb_tx) * FXP_NTXCB);
- for (i = 0; i < FXP_NTXCB; i++) {
- txp[i].cb_status = FXP_CB_STATUS_C | FXP_CB_STATUS_OK;
- txp[i].cb_command = FXP_CB_COMMAND_NOP;
- txp[i].link_addr = vtophys(&txp[(i + 1) & FXP_TXCB_MASK].cb_status);
- txp[i].tbd_array_addr = vtophys(&txp[i].tbd[0]);
- txp[i].next = &txp[(i + 1) & FXP_TXCB_MASK];
- }
- /*
- * Set the suspend flag on the first TxCB and start the control
- * unit. It will execute the NOP and then suspend.
- */
- txp->cb_command = FXP_CB_COMMAND_NOP | FXP_CB_COMMAND_S;
- sc->cbl_first = sc->cbl_last = txp;
- sc->tx_queued = 1;
-
- fxp_scb_wait(sc);
- CSR_WRITE_1(sc, FXP_CSR_SCB_COMMAND, FXP_SCB_COMMAND_CU_START);
-
- /*
- * Initialize receiver buffer area - RFA.
- */
- fxp_scb_wait(sc);
- CSR_WRITE_4(sc, FXP_CSR_SCB_GENERAL,
- vtophys(sc->rfa_headm->m_ext.ext_buf) + RFA_ALIGNMENT_FUDGE);
- CSR_WRITE_1(sc, FXP_CSR_SCB_COMMAND, FXP_SCB_COMMAND_RU_START);
-
- /*
- * Set current media.
- */
- fxp_set_media(sc, sc->sc_media.ifm_cur->ifm_media);
-
- ifp->if_flags |= IFF_RUNNING;
- ifp->if_flags &= ~IFF_OACTIVE;
- splx(s);
-
- /*
- * Start stats updater.
- */
- sc->stat_ch = timeout(fxp_stats_update, sc, hz);
-}
-
-static void
-fxp_set_media(sc, media)
- struct fxp_softc *sc;
- int media;
-{
-
- switch (sc->phy_primary_device) {
- case FXP_PHY_DP83840:
- case FXP_PHY_DP83840A:
- fxp_mdi_write(sc, sc->phy_primary_addr, FXP_DP83840_PCR,
- fxp_mdi_read(sc, sc->phy_primary_addr, FXP_DP83840_PCR) |
- FXP_DP83840_PCR_LED4_MODE | /* LED4 always indicates duplex */
- FXP_DP83840_PCR_F_CONNECT | /* force link disconnect bypass */
- FXP_DP83840_PCR_BIT10); /* XXX I have no idea */
- /* fall through */
- case FXP_PHY_82553A:
- case FXP_PHY_82553C: /* untested */
- case FXP_PHY_82555:
- case FXP_PHY_82555B:
- if (IFM_SUBTYPE(media) != IFM_AUTO) {
- int flags;
-
- flags = (IFM_SUBTYPE(media) == IFM_100_TX) ?
- FXP_PHY_BMCR_SPEED_100M : 0;
- flags |= (media & IFM_FDX) ?
- FXP_PHY_BMCR_FULLDUPLEX : 0;
- fxp_mdi_write(sc, sc->phy_primary_addr,
- FXP_PHY_BMCR,
- (fxp_mdi_read(sc, sc->phy_primary_addr,
- FXP_PHY_BMCR) &
- ~(FXP_PHY_BMCR_AUTOEN | FXP_PHY_BMCR_SPEED_100M |
- FXP_PHY_BMCR_FULLDUPLEX)) | flags);
- } else {
- fxp_mdi_write(sc, sc->phy_primary_addr,
- FXP_PHY_BMCR,
- (fxp_mdi_read(sc, sc->phy_primary_addr,
- FXP_PHY_BMCR) | FXP_PHY_BMCR_AUTOEN));
- }
- break;
- /*
- * The Seeq 80c24 doesn't have a PHY programming interface, so do
- * nothing.
- */
- case FXP_PHY_80C24:
- break;
- default:
- printf(FXP_FORMAT
- ": warning: unsupported PHY, type = %d, addr = %d\n",
- FXP_ARGS(sc), sc->phy_primary_device,
- sc->phy_primary_addr);
- }
-}
-
-/*
- * Change media according to request.
- */
-int
-fxp_mediachange(ifp)
- struct ifnet *ifp;
-{
- struct fxp_softc *sc = ifp->if_softc;
- struct ifmedia *ifm = &sc->sc_media;
-
- if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER)
- return (EINVAL);
-
- fxp_set_media(sc, ifm->ifm_media);
- return (0);
-}
-
-/*
- * Notify the world which media we're using.
- */
-void
-fxp_mediastatus(ifp, ifmr)
- struct ifnet *ifp;
- struct ifmediareq *ifmr;
-{
- struct fxp_softc *sc = ifp->if_softc;
- int flags, stsflags;
-
- switch (sc->phy_primary_device) {
- case FXP_PHY_82555:
- case FXP_PHY_82555B:
- case FXP_PHY_DP83840:
- case FXP_PHY_DP83840A:
- ifmr->ifm_status = IFM_AVALID; /* IFM_ACTIVE will be valid */
- ifmr->ifm_active = IFM_ETHER;
- /*
- * the following is not an error.
- * You need to read this register twice to get current
- * status. This is correct documented behaviour, the
- * first read gets latched values.
- */
- stsflags = fxp_mdi_read(sc, sc->phy_primary_addr, FXP_PHY_STS);
- stsflags = fxp_mdi_read(sc, sc->phy_primary_addr, FXP_PHY_STS);
- if (stsflags & FXP_PHY_STS_LINK_STS)
- ifmr->ifm_status |= IFM_ACTIVE;
-
- /*
- * If we are in auto mode, then try report the result.
- */
- flags = fxp_mdi_read(sc, sc->phy_primary_addr, FXP_PHY_BMCR);
- if (flags & FXP_PHY_BMCR_AUTOEN) {
- ifmr->ifm_active |= IFM_AUTO; /* XXX presently 0 */
- if (stsflags & FXP_PHY_STS_AUTO_DONE) {
- /*
- * Intel and National parts report
- * differently on what they found.
- */
- if ((sc->phy_primary_device == FXP_PHY_82555)
- || (sc->phy_primary_device == FXP_PHY_82555B)) {
- flags = fxp_mdi_read(sc,
- sc->phy_primary_addr,
- FXP_PHY_USC);
-
- if (flags & FXP_PHY_USC_SPEED)
- ifmr->ifm_active |= IFM_100_TX;
- else
- ifmr->ifm_active |= IFM_10_T;
-
- if (flags & FXP_PHY_USC_DUPLEX)
- ifmr->ifm_active |= IFM_FDX;
- } else { /* it's National. only know speed */
- flags = fxp_mdi_read(sc,
- sc->phy_primary_addr,
- FXP_DP83840_PAR);
-
- if (flags & FXP_DP83840_PAR_SPEED_10)
- ifmr->ifm_active |= IFM_10_T;
- else
- ifmr->ifm_active |= IFM_100_TX;
- }
- }
- } else { /* in manual mode.. just report what we were set to */
- if (flags & FXP_PHY_BMCR_SPEED_100M)
- ifmr->ifm_active |= IFM_100_TX;
- else
- ifmr->ifm_active |= IFM_10_T;
-
- if (flags & FXP_PHY_BMCR_FULLDUPLEX)
- ifmr->ifm_active |= IFM_FDX;
- }
- break;
-
- case FXP_PHY_80C24:
- default:
- ifmr->ifm_active = IFM_ETHER|IFM_MANUAL; /* XXX IFM_AUTO ? */
- }
-}
-
-/*
- * Add a buffer to the end of the RFA buffer list.
- * Return 0 if successful, 1 for failure. A failure results in
- * adding the 'oldm' (if non-NULL) on to the end of the list -
- * tossing out its old contents and recycling it.
- * The RFA struct is stuck at the beginning of mbuf cluster and the
- * data pointer is fixed up to point just past it.
- */
-static int
-fxp_add_rfabuf(sc, oldm)
- struct fxp_softc *sc;
- struct mbuf *oldm;
-{
- u_int32_t v;
- struct mbuf *m;
- struct fxp_rfa *rfa, *p_rfa;
-
- MGETHDR(m, M_DONTWAIT, MT_DATA);
- if (m != NULL) {
- MCLGET(m, M_DONTWAIT);
- if ((m->m_flags & M_EXT) == 0) {
- m_freem(m);
- if (oldm == NULL)
- return 1;
- m = oldm;
- m->m_data = m->m_ext.ext_buf;
- }
- } else {
- if (oldm == NULL)
- return 1;
- m = oldm;
- m->m_data = m->m_ext.ext_buf;
- }
-
- /*
- * Move the data pointer up so that the incoming data packet
- * will be 32-bit aligned.
- */
- m->m_data += RFA_ALIGNMENT_FUDGE;
-
- /*
- * Get a pointer to the base of the mbuf cluster and move
- * data start past it.
- */
- rfa = mtod(m, struct fxp_rfa *);
- m->m_data += sizeof(struct fxp_rfa);
- rfa->size = (u_int16_t)(MCLBYTES - sizeof(struct fxp_rfa) - RFA_ALIGNMENT_FUDGE);
-
- /*
- * Initialize the rest of the RFA. Note that since the RFA
- * is misaligned, we cannot store values directly. Instead,
- * we use an optimized, inline copy.
- */
-
- rfa->rfa_status = 0;
- rfa->rfa_control = FXP_RFA_CONTROL_EL;
- rfa->actual_size = 0;
-
- v = -1;
- fxp_lwcopy(&v, (volatile u_int32_t *) rfa->link_addr);
- fxp_lwcopy(&v, (volatile u_int32_t *) rfa->rbd_addr);
-
- /*
- * If there are other buffers already on the list, attach this
- * one to the end by fixing up the tail to point to this one.
- */
- if (sc->rfa_headm != NULL) {
- p_rfa = (struct fxp_rfa *) (sc->rfa_tailm->m_ext.ext_buf +
- RFA_ALIGNMENT_FUDGE);
- sc->rfa_tailm->m_next = m;
- v = vtophys(rfa);
- fxp_lwcopy(&v, (volatile u_int32_t *) p_rfa->link_addr);
- p_rfa->rfa_control &= ~FXP_RFA_CONTROL_EL;
- } else {
- sc->rfa_headm = m;
- }
- sc->rfa_tailm = m;
-
- return (m == oldm);
-}
-
-static volatile int
-fxp_mdi_read(sc, phy, reg)
- struct fxp_softc *sc;
- int phy;
- int reg;
-{
- int count = 10000;
- int value;
-
- CSR_WRITE_4(sc, FXP_CSR_MDICONTROL,
- (FXP_MDI_READ << 26) | (reg << 16) | (phy << 21));
-
- while (((value = CSR_READ_4(sc, FXP_CSR_MDICONTROL)) & 0x10000000) == 0
- && count--)
- DELAY(10);
-
- if (count <= 0)
- printf(FXP_FORMAT ": fxp_mdi_read: timed out\n",
- FXP_ARGS(sc));
-
- return (value & 0xffff);
-}
-
-static void
-fxp_mdi_write(sc, phy, reg, value)
- struct fxp_softc *sc;
- int phy;
- int reg;
- int value;
-{
- int count = 10000;
-
- CSR_WRITE_4(sc, FXP_CSR_MDICONTROL,
- (FXP_MDI_WRITE << 26) | (reg << 16) | (phy << 21) |
- (value & 0xffff));
-
- while((CSR_READ_4(sc, FXP_CSR_MDICONTROL) & 0x10000000) == 0 &&
- count--)
- DELAY(10);
-
- if (count <= 0)
- printf(FXP_FORMAT ": fxp_mdi_write: timed out\n",
- FXP_ARGS(sc));
-}
-
-static int
-fxp_ioctl(ifp, command, data)
- struct ifnet *ifp;
- FXP_IOCTLCMD_TYPE command;
- caddr_t data;
-{
- struct fxp_softc *sc = ifp->if_softc;
- struct ifreq *ifr = (struct ifreq *)data;
- int s, error = 0;
-
- s = splimp();
-
- switch (command) {
-
- case SIOCSIFADDR:
-#if !defined(__NetBSD__)
- case SIOCGIFADDR:
- case SIOCSIFMTU:
-#endif
- error = ether_ioctl(ifp, command, data);
- break;
-
- case SIOCSIFFLAGS:
- sc->all_mcasts = (ifp->if_flags & IFF_ALLMULTI) ? 1 : 0;
-
- /*
- * If interface is marked up and not running, then start it.
- * If it is marked down and running, stop it.
- * XXX If it's up then re-initialize it. This is so flags
- * such as IFF_PROMISC are handled.
- */
- if (ifp->if_flags & IFF_UP) {
- fxp_init(sc);
- } else {
- if (ifp->if_flags & IFF_RUNNING)
- fxp_stop(sc);
- }
- break;
-
- case SIOCADDMULTI:
- case SIOCDELMULTI:
- sc->all_mcasts = (ifp->if_flags & IFF_ALLMULTI) ? 1 : 0;
-#if defined(__NetBSD__)
- error = (command == SIOCADDMULTI) ?
- ether_addmulti(ifr, &sc->sc_ethercom) :
- ether_delmulti(ifr, &sc->sc_ethercom);
-
- if (error == ENETRESET) {
- /*
- * Multicast list has changed; set the hardware
- * filter accordingly.
- */
- if (!sc->all_mcasts)
- fxp_mc_setup(sc);
- /*
- * fxp_mc_setup() can turn on all_mcasts if we run
- * out of space, so check it again rather than else {}.
- */
- if (sc->all_mcasts)
- fxp_init(sc);
- error = 0;
- }
-#else /* __FreeBSD__ */
- /*
- * Multicast list has changed; set the hardware filter
- * accordingly.
- */
- if (!sc->all_mcasts)
- fxp_mc_setup(sc);
- /*
- * fxp_mc_setup() can turn on sc->all_mcasts, so check it
- * again rather than else {}.
- */
- if (sc->all_mcasts)
- fxp_init(sc);
- error = 0;
-#endif /* __NetBSD__ */
- break;
-
- case SIOCSIFMEDIA:
- case SIOCGIFMEDIA:
- error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, command);
- break;
-
- default:
- error = EINVAL;
- }
- (void) splx(s);
- return (error);
-}
-
-/*
- * Program the multicast filter.
- *
- * We have an artificial restriction that the multicast setup command
- * must be the first command in the chain, so we take steps to ensure
- * this. By requiring this, it allows us to keep up the performance of
- * the pre-initialized command ring (esp. link pointers) by not actually
- * inserting the mcsetup command in the ring - i.e. its link pointer
- * points to the TxCB ring, but the mcsetup descriptor itself is not part
- * of it. We then can do 'CU_START' on the mcsetup descriptor and have it
- * lead into the regular TxCB ring when it completes.
- *
- * This function must be called at splimp.
- */
-static void
-fxp_mc_setup(sc)
- struct fxp_softc *sc;
-{
- struct fxp_cb_mcs *mcsp = sc->mcsp;
- struct ifnet *ifp = &sc->sc_if;
- struct ifmultiaddr *ifma;
- int nmcasts;
-
- /*
- * If there are queued commands, we must wait until they are all
- * completed. If we are already waiting, then add a NOP command
- * with interrupt option so that we're notified when all commands
- * have been completed - fxp_start() ensures that no additional
- * TX commands will be added when need_mcsetup is true.
- */
- if (sc->tx_queued) {
- struct fxp_cb_tx *txp;
-
- /*
- * need_mcsetup will be true if we are already waiting for the
- * NOP command to be completed (see below). In this case, bail.
- */
- if (sc->need_mcsetup)
- return;
- sc->need_mcsetup = 1;
-
- /*
- * Add a NOP command with interrupt so that we are notified when all
- * TX commands have been processed.
- */
- txp = sc->cbl_last->next;
- txp->mb_head = NULL;
- txp->cb_status = 0;
- txp->cb_command = FXP_CB_COMMAND_NOP | FXP_CB_COMMAND_S | FXP_CB_COMMAND_I;
- /*
- * Advance the end of list forward.
- */
- sc->cbl_last->cb_command &= ~FXP_CB_COMMAND_S;
- sc->cbl_last = txp;
- sc->tx_queued++;
- /*
- * Issue a resume in case the CU has just suspended.
- */
- fxp_scb_wait(sc);
- CSR_WRITE_1(sc, FXP_CSR_SCB_COMMAND, FXP_SCB_COMMAND_CU_RESUME);
- /*
- * Set a 5 second timer just in case we don't hear from the
- * card again.
- */
- ifp->if_timer = 5;
-
- return;
- }
- sc->need_mcsetup = 0;
-
- /*
- * Initialize multicast setup descriptor.
- */
- mcsp->next = sc->cbl_base;
- mcsp->mb_head = NULL;
- mcsp->cb_status = 0;
- mcsp->cb_command = FXP_CB_COMMAND_MCAS | FXP_CB_COMMAND_S | FXP_CB_COMMAND_I;
- mcsp->link_addr = vtophys(&sc->cbl_base->cb_status);
-
- nmcasts = 0;
- if (!sc->all_mcasts) {
- for (ifma = ifp->if_multiaddrs.lh_first; ifma != NULL;
- ifma = ifma->ifma_link.le_next) {
- if (ifma->ifma_addr->sa_family != AF_LINK)
- continue;
- if (nmcasts >= MAXMCADDR) {
- sc->all_mcasts = 1;
- nmcasts = 0;
- break;
- }
- bcopy(LLADDR((struct sockaddr_dl *)ifma->ifma_addr),
- (volatile void *) &sc->mcsp->mc_addr[nmcasts][0], 6);
- nmcasts++;
- }
- }
- mcsp->mc_cnt = nmcasts * 6;
- sc->cbl_first = sc->cbl_last = (struct fxp_cb_tx *) mcsp;
- sc->tx_queued = 1;
-
- /*
- * Wait until command unit is not active. This should never
- * be the case when nothing is queued, but make sure anyway.
- */
- while ((CSR_READ_1(sc, FXP_CSR_SCB_RUSCUS) >> 6) ==
- FXP_SCB_CUS_ACTIVE) ;
-
- /*
- * Start the multicast setup command.
- */
- fxp_scb_wait(sc);
- CSR_WRITE_4(sc, FXP_CSR_SCB_GENERAL, vtophys(&mcsp->cb_status));
- CSR_WRITE_1(sc, FXP_CSR_SCB_COMMAND, FXP_SCB_COMMAND_CU_START);
-
- ifp->if_timer = 2;
- return;
-}
diff --git a/sys/dev/fxp/if_fxpreg.h b/sys/dev/fxp/if_fxpreg.h
deleted file mode 100644
index 55808130fee6..000000000000
--- a/sys/dev/fxp/if_fxpreg.h
+++ /dev/null
@@ -1,423 +0,0 @@
-/*
- * Copyright (c) 1995, David Greenman
- * 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 unmodified, 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#define FXP_VENDORID_INTEL 0x8086
-#define FXP_DEVICEID_i82557 0x1229 /* 82557 - 82559 "classic" */
-#define FXP_DEVICEID_i82559 0x1030 /* New 82559 device id.. */
-
-#define FXP_PCI_MMBA 0x10
-#define FXP_PCI_IOBA 0x14
-
-/*
- * Control/status registers.
- */
-#define FXP_CSR_SCB_RUSCUS 0 /* scb_rus/scb_cus (1 byte) */
-#define FXP_CSR_SCB_STATACK 1 /* scb_statack (1 byte) */
-#define FXP_CSR_SCB_COMMAND 2 /* scb_command (1 byte) */
-#define FXP_CSR_SCB_INTRCNTL 3 /* scb_intrcntl (1 byte) */
-#define FXP_CSR_SCB_GENERAL 4 /* scb_general (4 bytes) */
-#define FXP_CSR_PORT 8 /* port (4 bytes) */
-#define FXP_CSR_FLASHCONTROL 12 /* flash control (2 bytes) */
-#define FXP_CSR_EEPROMCONTROL 14 /* eeprom control (2 bytes) */
-#define FXP_CSR_MDICONTROL 16 /* mdi control (4 bytes) */
-
-/*
- * FOR REFERENCE ONLY, the old definition of FXP_CSR_SCB_RUSCUS:
- *
- * volatile u_int8_t :2,
- * scb_rus:4,
- * scb_cus:2;
- */
-
-#define FXP_PORT_SOFTWARE_RESET 0
-#define FXP_PORT_SELFTEST 1
-#define FXP_PORT_SELECTIVE_RESET 2
-#define FXP_PORT_DUMP 3
-
-#define FXP_SCB_RUS_IDLE 0
-#define FXP_SCB_RUS_SUSPENDED 1
-#define FXP_SCB_RUS_NORESOURCES 2
-#define FXP_SCB_RUS_READY 4
-#define FXP_SCB_RUS_SUSP_NORBDS 9
-#define FXP_SCB_RUS_NORES_NORBDS 10
-#define FXP_SCB_RUS_READY_NORBDS 12
-
-#define FXP_SCB_CUS_IDLE 0
-#define FXP_SCB_CUS_SUSPENDED 1
-#define FXP_SCB_CUS_ACTIVE 2
-
-#define FXP_SCB_STATACK_SWI 0x04
-#define FXP_SCB_STATACK_MDI 0x08
-#define FXP_SCB_STATACK_RNR 0x10
-#define FXP_SCB_STATACK_CNA 0x20
-#define FXP_SCB_STATACK_FR 0x40
-#define FXP_SCB_STATACK_CXTNO 0x80
-
-#define FXP_SCB_COMMAND_CU_NOP 0x00
-#define FXP_SCB_COMMAND_CU_START 0x10
-#define FXP_SCB_COMMAND_CU_RESUME 0x20
-#define FXP_SCB_COMMAND_CU_DUMP_ADR 0x40
-#define FXP_SCB_COMMAND_CU_DUMP 0x50
-#define FXP_SCB_COMMAND_CU_BASE 0x60
-#define FXP_SCB_COMMAND_CU_DUMPRESET 0x70
-
-#define FXP_SCB_COMMAND_RU_NOP 0
-#define FXP_SCB_COMMAND_RU_START 1
-#define FXP_SCB_COMMAND_RU_RESUME 2
-#define FXP_SCB_COMMAND_RU_ABORT 4
-#define FXP_SCB_COMMAND_RU_LOADHDS 5
-#define FXP_SCB_COMMAND_RU_BASE 6
-#define FXP_SCB_COMMAND_RU_RBDRESUME 7
-
-/*
- * Command block definitions
- */
-struct fxp_cb_nop {
- void *fill[2];
- volatile u_int16_t cb_status;
- volatile u_int16_t cb_command;
- volatile u_int32_t link_addr;
-};
-struct fxp_cb_ias {
- void *fill[2];
- volatile u_int16_t cb_status;
- volatile u_int16_t cb_command;
- volatile u_int32_t link_addr;
- volatile u_int8_t macaddr[6];
-};
-/* I hate bit-fields :-( */
-struct fxp_cb_config {
- void *fill[2];
- volatile u_int16_t cb_status;
- volatile u_int16_t cb_command;
- volatile u_int32_t link_addr;
- volatile u_int byte_count:6,
- :2;
- volatile u_int rx_fifo_limit:4,
- tx_fifo_limit:3,
- :1;
- volatile u_int8_t adaptive_ifs;
- volatile u_int :8;
- volatile u_int rx_dma_bytecount:7,
- :1;
- volatile u_int tx_dma_bytecount:7,
- dma_bce:1;
- volatile u_int late_scb:1,
- :1,
- tno_int:1,
- ci_int:1,
- :3,
- save_bf:1;
- volatile u_int disc_short_rx:1,
- underrun_retry:2,
- :5;
- volatile u_int mediatype:1,
- :7;
- volatile u_int :8;
- volatile u_int :3,
- nsai:1,
- preamble_length:2,
- loopback:2;
- volatile u_int linear_priority:3,
- :5;
- volatile u_int linear_pri_mode:1,
- :3,
- interfrm_spacing:4;
- volatile u_int :8;
- volatile u_int :8;
- volatile u_int promiscuous:1,
- bcast_disable:1,
- :5,
- crscdt:1;
- volatile u_int :8;
- volatile u_int :8;
- volatile u_int stripping:1,
- padding:1,
- rcv_crc_xfer:1,
- :5;
- volatile u_int :6,
- force_fdx:1,
- fdx_pin_en:1;
- volatile u_int :6,
- multi_ia:1,
- :1;
- volatile u_int :3,
- mc_all:1,
- :4;
-};
-
-#define MAXMCADDR 80
-struct fxp_cb_mcs {
- struct fxp_cb_tx *next;
- struct mbuf *mb_head;
- volatile u_int16_t cb_status;
- volatile u_int16_t cb_command;
- volatile u_int32_t link_addr;
- volatile u_int16_t mc_cnt;
- volatile u_int8_t mc_addr[MAXMCADDR][6];
-};
-
-/*
- * Number of DMA segments in a TxCB. Note that this is carefully
- * chosen to make the total struct size an even power of two. It's
- * critical that no TxCB be split across a page boundry since
- * no attempt is made to allocate physically contiguous memory.
- *
- */
-#ifdef __alpha__ /* XXX - should be conditional on pointer size */
-#define FXP_NTXSEG 28
-#else
-#define FXP_NTXSEG 29
-#endif
-
-struct fxp_tbd {
- volatile u_int32_t tb_addr;
- volatile u_int32_t tb_size;
-};
-struct fxp_cb_tx {
- struct fxp_cb_tx *next;
- struct mbuf *mb_head;
- volatile u_int16_t cb_status;
- volatile u_int16_t cb_command;
- volatile u_int32_t link_addr;
- volatile u_int32_t tbd_array_addr;
- volatile u_int16_t byte_count;
- volatile u_int8_t tx_threshold;
- volatile u_int8_t tbd_number;
- /*
- * The following isn't actually part of the TxCB.
- */
- volatile struct fxp_tbd tbd[FXP_NTXSEG];
-};
-
-/*
- * Control Block (CB) definitions
- */
-
-/* status */
-#define FXP_CB_STATUS_OK 0x2000
-#define FXP_CB_STATUS_C 0x8000
-/* commands */
-#define FXP_CB_COMMAND_NOP 0x0
-#define FXP_CB_COMMAND_IAS 0x1
-#define FXP_CB_COMMAND_CONFIG 0x2
-#define FXP_CB_COMMAND_MCAS 0x3
-#define FXP_CB_COMMAND_XMIT 0x4
-#define FXP_CB_COMMAND_RESRV 0x5
-#define FXP_CB_COMMAND_DUMP 0x6
-#define FXP_CB_COMMAND_DIAG 0x7
-/* command flags */
-#define FXP_CB_COMMAND_SF 0x0008 /* simple/flexible mode */
-#define FXP_CB_COMMAND_I 0x2000 /* generate interrupt on completion */
-#define FXP_CB_COMMAND_S 0x4000 /* suspend on completion */
-#define FXP_CB_COMMAND_EL 0x8000 /* end of list */
-
-/*
- * RFA definitions
- */
-
-struct fxp_rfa {
- volatile u_int16_t rfa_status;
- volatile u_int16_t rfa_control;
- volatile u_int8_t link_addr[4];
- volatile u_int8_t rbd_addr[4];
- volatile u_int16_t actual_size;
- volatile u_int16_t size;
-};
-#define FXP_RFA_STATUS_RCOL 0x0001 /* receive collision */
-#define FXP_RFA_STATUS_IAMATCH 0x0002 /* 0 = matches station address */
-#define FXP_RFA_STATUS_S4 0x0010 /* receive error from PHY */
-#define FXP_RFA_STATUS_TL 0x0020 /* type/length */
-#define FXP_RFA_STATUS_FTS 0x0080 /* frame too short */
-#define FXP_RFA_STATUS_OVERRUN 0x0100 /* DMA overrun */
-#define FXP_RFA_STATUS_RNR 0x0200 /* no resources */
-#define FXP_RFA_STATUS_ALIGN 0x0400 /* alignment error */
-#define FXP_RFA_STATUS_CRC 0x0800 /* CRC error */
-#define FXP_RFA_STATUS_OK 0x2000 /* packet received okay */
-#define FXP_RFA_STATUS_C 0x8000 /* packet reception complete */
-#define FXP_RFA_CONTROL_SF 0x08 /* simple/flexible memory mode */
-#define FXP_RFA_CONTROL_H 0x10 /* header RFD */
-#define FXP_RFA_CONTROL_S 0x4000 /* suspend after reception */
-#define FXP_RFA_CONTROL_EL 0x8000 /* end of list */
-
-/*
- * Statistics dump area definitions
- */
-struct fxp_stats {
- volatile u_int32_t tx_good;
- volatile u_int32_t tx_maxcols;
- volatile u_int32_t tx_latecols;
- volatile u_int32_t tx_underruns;
- volatile u_int32_t tx_lostcrs;
- volatile u_int32_t tx_deffered;
- volatile u_int32_t tx_single_collisions;
- volatile u_int32_t tx_multiple_collisions;
- volatile u_int32_t tx_total_collisions;
- volatile u_int32_t rx_good;
- volatile u_int32_t rx_crc_errors;
- volatile u_int32_t rx_alignment_errors;
- volatile u_int32_t rx_rnr_errors;
- volatile u_int32_t rx_overrun_errors;
- volatile u_int32_t rx_cdt_errors;
- volatile u_int32_t rx_shortframes;
- volatile u_int32_t completion_status;
-};
-#define FXP_STATS_DUMP_COMPLETE 0xa005
-#define FXP_STATS_DR_COMPLETE 0xa007
-
-/*
- * Serial EEPROM control register bits
- */
-/* shift clock */
-#define FXP_EEPROM_EESK 0x01
-/* chip select */
-#define FXP_EEPROM_EECS 0x02
-/* data in */
-#define FXP_EEPROM_EEDI 0x04
-/* data out */
-#define FXP_EEPROM_EEDO 0x08
-
-/*
- * Serial EEPROM opcodes, including start bit
- */
-#define FXP_EEPROM_OPC_ERASE 0x4
-#define FXP_EEPROM_OPC_WRITE 0x5
-#define FXP_EEPROM_OPC_READ 0x6
-
-/*
- * Management Data Interface opcodes
- */
-#define FXP_MDI_WRITE 0x1
-#define FXP_MDI_READ 0x2
-
-/*
- * PHY device types
- */
-#define FXP_PHY_NONE 0
-#define FXP_PHY_82553A 1
-#define FXP_PHY_82553C 2
-#define FXP_PHY_82503 3
-#define FXP_PHY_DP83840 4
-#define FXP_PHY_80C240 5
-#define FXP_PHY_80C24 6
-#define FXP_PHY_82555 7
-#define FXP_PHY_DP83840A 10
-#define FXP_PHY_82555B 11
-
-/*
- * PHY BMCR Basic Mode Control Register
- * Should probably be in i82555.h or dp83840.h (Intel/National names).
- * (Called "Management Data Interface Control Reg" in some Intel data books).
- * (*) indicates bit ignored in auto negotiation mode.
- */
-#define FXP_PHY_BMCR 0x0
-#define FXP_PHY_BMCR_COLTEST 0x0080 /* not on Intel parts */
-#define FXP_PHY_BMCR_FULLDUPLEX 0x0100 /* 1 = Fullduplex (*) */
-#define FXP_PHY_BMCR_RESTART_NEG 0x0200 /* ==> 1 to restart autoneg */
-#define FXP_PHY_BMCR_ISOLATE 0x0400 /* not on Intel parts */
-#define FXP_PHY_BMCR_POWERDOWN 0x0800 /* 1 = low power mode */
-#define FXP_PHY_BMCR_AUTOEN 0x1000 /* 1 = for auto mode */
-#define FXP_PHY_BMCR_SPEED_100M 0x2000 /* 1 = for 100Mb/sec (*) */
-#define FXP_PHY_BMCR_LOOPBACK 0x4000 /* 1 = loopback at the PHY */
-#define FXP_PHY_BMCR_RESET 0x8000 /* ==> 1 sets to defaults */
-
-/*
- * Basic Mode Status Register (National name)
- * Management Data Interface Status reg. (Intel name)
- * in both Intel and National parts.
- */
-#define FXP_PHY_STS 0x1
-#define FXP_PHY_STS_EXND 0x0001 /* Extended regs enabled */
-#define FXP_PHY_STS_JABR 0x0002 /* Jabber detected */
-#define FXP_PHY_STS_LINK_STS 0x0004 /* Link valid */
-#define FXP_PHY_STS_CAN_AUTO 0x0008 /* Auto detection available */
-#define FXP_PHY_STS_REMT_FAULT 0x0010 /* remote fault detected */
-#define FXP_PHY_STS_AUTO_DONE 0x0020 /* auto negotiation completed */
-#define FXP_PHY_STS_MGMT_PREAMBLE 0x0040 /* real complicated */
-#define FXP_PHY_STS_10HDX_OK 0x0800 /* can do 10Mb HDX */
-#define FXP_PHY_STS_10FDX_OK 0x1000 /* can do 10Mb FDX */
-#define FXP_PHY_STS_100HDX_OK 0x2000 /* can do 100Mb HDX */
-#define FXP_PHY_STS_100FDX_OK 0x4000 /* can do 100Mb FDX */
-#define FXP_PHY_STS_100T4_OK 0x8000 /* can do 100bT4 -not Intel */
-
-/*
- * More Phy regs
- */
-#define FXP_PHY_ID1 0x2
-#define FXP_PHY_ID2 0x3
-
-/*
- * MDI Auto negotiation advertisement register.
- * What we advertise we can do..
- * The same bits are used to indicate the response too.
- */
-#define FXP_PHY_ADVRT 0x4
-#define FXP_PHY_RMT_ADVRT 0x5 /* what the other end said */
-#define FXP_PHY_ADVRT_SELECT 0x001F /* real complicated */
-#define FXP_PHY_ADVRT_TECH_AVAIL 0x1FE0 /* can do 10Mb HDX */
-#define FXP_PHY_ADVRT_RMT_FAULT 0x2000 /* can do 10Mb FDX */
-#define FXP_PHY_ADVRT_ACK 0x4000 /* Acked */
-#define FXP_PHY_ADVRT_NXT_PAGE 0x8000 /* can do 100Mb FDX */
-
-/*
- * Phy Unit Status and Control Register (another one)
- * This is not in the National part!
- */
-#define FXP_PHY_USC 0x10
-#define FXP_PHY_USC_DUPLEX 0x0001 /* in FDX mode */
-#define FXP_PHY_USC_SPEED 0x0002 /* 1 = in 100Mb mode */
-#define FXP_PHY_USC_POLARITY 0x0100 /* 1 = reverse polarity */
-#define FXP_PHY_USC_10_PWRDOWN 0x0200 /* 10Mb PHY powered down */
-#define FXP_PHY_USC_100_PWRDOWN 0x0400 /* 100Mb PHY powered down */
-#define FXP_PHY_USC_INSYNC 0x0800 /* 100Mb PHY is in sync */
-#define FXP_PHY_USC_TX_FLOWCNTRL 0x1000 /* TX FC mode in use */
-#define FXP_PHY_USC_PHY_FLOWCNTRL 0x8000 /* PHY FC mode in use */
-
-
-/*
- * DP83830 PHY, PCS Configuration Register
- * NOT compatible with Intel parts,
- * (where it is the 100BTX premature eof counter).
- */
-#define FXP_DP83840_PCR 0x17
-#define FXP_DP83840_PCR_LED4_MODE 0x0002 /* 1 = LED4 always = FDX */
-#define FXP_DP83840_PCR_F_CONNECT 0x0020 /* 1 = link disconnect bypass */
-#define FXP_DP83840_PCR_BIT8 0x0100
-#define FXP_DP83840_PCR_BIT10 0x0400
-
-/*
- * DP83830 PHY, Address/status Register
- * NOT compatible with Intel parts,
- * (where it is the 10BT jabber detect counter).
- */
-#define FXP_DP83840_PAR 0x19
-#define FXP_DP83840_PAR_PHYADDR 0x1F
-#define FXP_DP83840_PAR_CON_STATUS 0x20
-#define FXP_DP83840_PAR_SPEED_10 0x40 /* 1 == running at 10 Mb/Sec */
-
diff --git a/sys/dev/fxp/if_fxpvar.h b/sys/dev/fxp/if_fxpvar.h
deleted file mode 100644
index 97c2b4019ff0..000000000000
--- a/sys/dev/fxp/if_fxpvar.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (c) 1995, David Greenman
- * All rights reserved.
- *
- * Modifications to support NetBSD:
- * Copyright (c) 1997 Jason R. Thorpe. 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 unmodified, 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Misc. defintions for the Intel EtherExpress Pro/100B PCI Fast
- * Ethernet driver
- */
-/*
- * NOTE: Elements are ordered for optimal cacheline behavior, and NOT
- * for functional grouping.
- */
-struct fxp_softc {
-#if defined(__NetBSD__)
- struct device sc_dev; /* generic device structures */
- void *sc_ih; /* interrupt handler cookie */
- struct ethercom sc_ethercom; /* ethernet common part */
-#else
- struct arpcom arpcom; /* per-interface network data */
- struct resource *mem; /* resource descriptor for registers */
- struct resource *irq; /* resource descriptor for interrupt */
- void *ih; /* interrupt handler cookie */
-#endif /* __NetBSD__ */
- bus_space_tag_t sc_st; /* bus space tag */
- bus_space_handle_t sc_sh; /* bus space handle */
- struct mbuf *rfa_headm; /* first mbuf in receive frame area */
- struct mbuf *rfa_tailm; /* last mbuf in receive frame area */
- struct fxp_cb_tx *cbl_first; /* first active TxCB in list */
- int tx_queued; /* # of active TxCB's */
- int need_mcsetup; /* multicast filter needs programming */
- struct fxp_cb_tx *cbl_last; /* last active TxCB in list */
- struct fxp_stats *fxp_stats; /* Pointer to interface stats */
- int rx_idle_secs; /* # of seconds RX has been idle */
- struct callout_handle stat_ch; /* Handle for canceling our stat timeout */
- struct fxp_cb_tx *cbl_base; /* base of TxCB list */
- struct fxp_cb_mcs *mcsp; /* Pointer to mcast setup descriptor */
- int all_mcasts; /* receive all multicasts */
- struct ifmedia sc_media; /* media information */
- int phy_primary_addr; /* address of primary PHY */
- int phy_primary_device; /* device type of primary PHY */
- int phy_10Mbps_only; /* PHY is 10Mbps-only device */
-};
-
-/* Macros to ease CSR access. */
-#define CSR_READ_1(sc, reg) \
- bus_space_read_1((sc)->sc_st, (sc)->sc_sh, (reg))
-#define CSR_READ_2(sc, reg) \
- bus_space_read_2((sc)->sc_st, (sc)->sc_sh, (reg))
-#define CSR_READ_4(sc, reg) \
- bus_space_read_4((sc)->sc_st, (sc)->sc_sh, (reg))
-#define CSR_WRITE_1(sc, reg, val) \
- bus_space_write_1((sc)->sc_st, (sc)->sc_sh, (reg), (val))
-#define CSR_WRITE_2(sc, reg, val) \
- bus_space_write_2((sc)->sc_st, (sc)->sc_sh, (reg), (val))
-#define CSR_WRITE_4(sc, reg, val) \
- bus_space_write_4((sc)->sc_st, (sc)->sc_sh, (reg), (val))
-
-/* Deal with slight differences in software interfaces. */
-#if defined(__NetBSD__)
-#define sc_if sc_ethercom.ec_if
-#define FXP_FORMAT "%s"
-#define FXP_ARGS(sc) (sc)->sc_dev.dv_xname
-#define FXP_INTR_TYPE int
-#define FXP_IOCTLCMD_TYPE u_long
-#define FXP_BPFTAP_ARG(ifp) (ifp)->if_bpf
-#else /* __FreeBSD__ */
-#define sc_if arpcom.ac_if
-#define FXP_FORMAT "fxp%d"
-#define FXP_ARGS(sc) (sc)->arpcom.ac_if.if_unit
-#define FXP_INTR_TYPE void
-#define FXP_IOCTLCMD_TYPE u_long
-#define FXP_BPFTAP_ARG(ifp) ifp
-#endif /* __NetBSD__ */
diff --git a/sys/dev/ic/cd1400.h b/sys/dev/ic/cd1400.h
deleted file mode 100644
index 90672c4ee7e6..000000000000
--- a/sys/dev/ic/cd1400.h
+++ /dev/null
@@ -1,203 +0,0 @@
-/*-
- * cyclades cyclom-y serial driver
- * Andrew Herbert <andrew@werple.apana.org.au>, 17 August 1993
- *
- * Copyright (c) 1993 Andrew Herbert.
- * 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 Andrew Herbert may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY ``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 I 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Definitions for Cirrus Logic CD1400 serial/parallel chips.
- */
-
-#define CD1400_NO_OF_CHANNELS 4 /* 4 serial channels per chip */
-#define CD1400_RX_FIFO_SIZE 12
-#define CD1400_TX_FIFO_SIZE 12
-
-/*
- * Global registers.
- */
-#define CD1400_GFRCR 0x40 /* global firmware revision code */
-#define CD1400_CAR 0x68 /* channel access */
-#define CD1400_CAR_CHAN (3<<0) /* channel select */
-#define CD1400_GCR 0x4B /* global configuration */
-#define CD1400_GCR_PARALLEL (1<<7) /* channel 0 is parallel */
-#define CD1400_SVRR 0x67 /* service request */
-#define CD1400_SVRR_MDMCH (1<<2)
-#define CD1400_SVRR_TXRDY (1<<1)
-#define CD1400_SVRR_RXRDY (1<<0)
-#define CD1400_RICR 0x44 /* receive interrupting channel */
-#define CD1400_TICR 0x45 /* transmit interrupting channel */
-#define CD1400_MICR 0x46 /* modem interrupting channel */
-#define CD1400_RIR 0x6B /* receive interrupt status */
-#define CD1400_RIR_RDIREQ (1<<7) /* rx service required */
-#define CD1400_RIR_RBUSY (1<<6) /* rx service in progress */
-#define CD1400_RIR_CHAN (3<<0) /* channel select */
-#define CD1400_TIR 0x6A /* transmit interrupt status */
-#define CD1400_TIR_RDIREQ (1<<7) /* tx service required */
-#define CD1400_TIR_RBUSY (1<<6) /* tx service in progress */
-#define CD1400_TIR_CHAN (3<<0) /* channel select */
-#define CD1400_MIR 0x69 /* modem interrupt status */
-#define CD1400_MIR_RDIREQ (1<<7) /* modem service required */
-#define CD1400_MIR_RBUSY (1<<6) /* modem service in progress */
-#define CD1400_MIR_CHAN (3<<0) /* channel select */
-#define CD1400_PPR 0x7E /* prescaler period */
-#define CD1400_PPR_PRESCALER 512
-
-/*
- * Virtual registers.
- */
-#define CD1400_RIVR 0x43 /* receive interrupt vector */
-#define CD1400_RIVR_EXCEPTION (1<<2) /* receive exception bit */
-#define CD1400_TIVR 0x42 /* transmit interrupt vector */
-#define CD1400_MIVR 0x41 /* modem interrupt vector */
-#define CD1400_TDR 0x63 /* transmit data */
-#define CD1400_RDSR 0x62 /* receive data/status */
-#define CD1400_RDSR_TIMEOUT (1<<7) /* rx timeout */
-#define CD1400_RDSR_SPECIAL_SHIFT 4 /* rx special char shift */
-#define CD1400_RDSR_SPECIAL (7<<4) /* rx special char */
-#define CD1400_RDSR_BREAK (1<<3) /* rx break */
-#define CD1400_RDSR_PE (1<<2) /* rx parity error */
-#define CD1400_RDSR_FE (1<<1) /* rx framing error */
-#define CD1400_RDSR_OE (1<<0) /* rx overrun error */
-#define CD1400_MISR 0x4C /* modem interrupt status */
-#define CD1400_MISR_DSRd (1<<7) /* DSR delta */
-#define CD1400_MISR_CTSd (1<<6) /* CTS delta */
-#define CD1400_MISR_RId (1<<5) /* RI delta */
-#define CD1400_MISR_CDd (1<<4) /* CD delta */
-#define CD1400_EOSRR 0x60 /* end of service request */
-
-/*
- * Channel registers.
- */
-#define CD1400_LIVR 0x18 /* local interrupt vector */
-#define CD1400_CCR 0x05 /* channel control */
-#define CD1400_CCR_CMDRESET (1<<7) /* enables following: */
-#define CD1400_CCR_FTF (1<<1) /* flush tx fifo */
-#define CD1400_CCR_FULLRESET (1<<0) /* full reset */
-#define CD1400_CCR_CHANRESET 0 /* current channel */
-#define CD1400_CCR_CMDCORCHG (1<<6) /* enables following: */
-#define CD1400_CCR_COR3 (1<<3) /* COR3 changed */
-#define CD1400_CCR_COR2 (1<<2) /* COR2 changed */
-#define CD1400_CCR_COR1 (1<<1) /* COR1 changed */
-#define CD1400_CCR_CMDSENDSC (1<<5) /* enables following: */
-#define CD1400_CCR_SC (7<<0) /* special char 1-4 */
-#define CD1400_CCR_CMDCHANCTL (1<<4) /* enables following: */
-#define CD1400_CCR_XMTEN (1<<3) /* tx enable */
-#define CD1400_CCR_XMTDIS (1<<2) /* tx disable */
-#define CD1400_CCR_RCVEN (1<<1) /* rx enable */
-#define CD1400_CCR_RCVDIS (1<<0) /* rx disable */
-#define CD1400_SRER 0x06 /* service request enable */
-#define CD1400_SRER_MDMCH (1<<7) /* modem change */
-#define CD1400_SRER_RXDATA (1<<4) /* rx data */
-#define CD1400_SRER_TXRDY (1<<2) /* tx fifo empty */
-#define CD1400_SRER_TXMPTY (1<<1) /* tx shift reg empty */
-#define CD1400_SRER_NNDT (1<<0) /* no new data */
-#define CD1400_COR1 0x08 /* channel option 1 */
-#define CD1400_COR1_PARODD (1<<7)
-#define CD1400_COR1_PARNORMAL (2<<5)
-#define CD1400_COR1_PARFORCE (1<<5) /* odd/even = force 1/0 */
-#define CD1400_COR1_PARNONE (0<<5)
-#define CD1400_COR1_NOINPCK (1<<4)
-#define CD1400_COR1_STOP2 (2<<2)
-#define CD1400_COR1_STOP15 (1<<2) /* 1.5 stop bits */
-#define CD1400_COR1_STOP1 (0<<2)
-#define CD1400_COR1_CS8 (3<<0)
-#define CD1400_COR1_CS7 (2<<0)
-#define CD1400_COR1_CS6 (1<<0)
-#define CD1400_COR1_CS5 (0<<0)
-#define CD1400_COR2 0x09 /* channel option 2 */
-#define CD1400_COR2_IXANY (1<<7) /* implied XON mode */
-#define CD1400_COR2_IXOFF (1<<6) /* in-band tx flow control */
-#define CD1400_COR2_ETC (1<<5) /* embedded tx command */
-#define CD1400_ETC_CMD 0x00 /* start an ETC */
-#define CD1400_ETC_SENDBREAK 0x81
-#define CD1400_ETC_INSERTDELAY 0x82
-#define CD1400_ETC_STOPBREAK 0x83
-#define CD1400_COR2_LLM (1<<4) /* local loopback mode */
-#define CD1400_COR2_RLM (1<<3) /* remote loopback mode */
-#define CD1400_COR2_RTSAO (1<<2) /* RTS auto output */
-#define CD1400_COR2_CCTS_OFLOW (1<<1) /* CTS auto enable */
-#define CD1400_COR2_CDSR_OFLOW (1<<0) /* DSR auto enable */
-#define CD1400_COR3 0x0A /* channel option 3 */
-#define CD1400_COR3_SCDRNG (1<<7) /* special char detect range */
-#define CD1400_COR3_SCD34 (1<<6) /* special char detect 3-4 */
-#define CD1400_COR3_FTC (1<<5) /* flow control transparency */
-#define CD1400_COR3_SCD12 (1<<4) /* special char detect 1-2 */
-#define CD1400_COR3_RXTH (15<<0) /* rx fifo threshold */
-#define CD1400_COR4 0x1E /* channel option 4 */
-#define CD1400_COR4_IGNCR (1<<7)
-#define CD1400_COR4_ICRNL (1<<6)
-#define CD1400_COR4_INLCR (1<<5)
-#define CD1400_COR4_IGNBRK (1<<4)
-#define CD1400_COR4_NOBRKINT (1<<3)
-#define CD1400_COR4_PFO_ESC (4<<0) /* parity/framing/overrun... */
-#define CD1400_COR4_PFO_NUL (3<<0)
-#define CD1400_COR4_PFO_DISCARD (2<<0)
-#define CD1400_COR4_PFO_GOOD (1<<0)
-#define CD1400_COR4_PFO_EXCEPTION (0<<0)
-#define CD1400_COR5 0x1F /* channel option 5 */
-#define CD1400_COR5_ISTRIP (1<<7)
-#define CD1400_COR5_LNEXT (1<<6)
-#define CD1400_COR5_CMOE (1<<5) /* char matching on error */
-#define CD1400_COR5_EBD (1<<2) /* end of break detected */
-#define CD1400_COR5_ONLCR (1<<1)
-#define CD1400_COR5_OCRNL (1<<0)
-#define CD1400_CCSR 0x0B /* channel control status */
-#define CD1400_RDCR 0x0E /* received data count */
-#define CD1400_SCHR1 0x1A /* special character 1 */
-#define CD1400_SCHR2 0x1B /* special character 2 */
-#define CD1400_SCHR3 0x1C /* special character 3 */
-#define CD1400_SCHR4 0x1D /* special character 4 */
-#define CD1400_SCRL 0x22 /* special character range, low */
-#define CD1400_SCRH 0x23 /* special character range, high */
-#define CD1400_LNC 0x24 /* lnext character */
-#define CD1400_MCOR1 0x15 /* modem change option 1 */
-#define CD1400_MCOR1_DSRzd (1<<7) /* DSR one-to-zero delta */
-#define CD1400_MCOR1_CTSzd (1<<6)
-#define CD1400_MCOR1_RIzd (1<<5)
-#define CD1400_MCOR1_CDzd (1<<4)
-#define CD1400_MCOR1_DTRth (15<<0) /* dtrflow threshold */
-#define CD1400_MCOR2 0x16 /* modem change option 2 */
-#define CD1400_MCOR2_DSRod (1<<7) /* DSR zero-to-one delta */
-#define CD1400_MCOR2_CTSod (1<<6)
-#define CD1400_MCOR2_RIod (1<<5)
-#define CD1400_MCOR2_CDod (1<<4)
-#define CD1400_RTPR 0x21 /* receive timeout period */
-#define CD1400_MSVR1 0x6C /* modem signal value 1 */
-#define CD1400_MSVR1_RTS (1<<0) /* RTS line (r/w) */
-#define CD1400_MSVR2 0x6D /* modem signal value 2 */
-#define CD1400_MSVR2_DSR (1<<7) /* !DSR line (r) */
-#define CD1400_MSVR2_CTS (1<<6) /* !CTS line (r) */
-#define CD1400_MSVR2_RI (1<<5) /* !RI line (r) */
-#define CD1400_MSVR2_CD (1<<4) /* !CD line (r) */
-#define CD1400_MSVR2_DTR (1<<1) /* DTR line (r/w) */
-#define CD1400_PSVR 0x6F /* printer signal value */
-#define CD1400_RBPR 0x78 /* receive baud rate period */
-#define CD1400_RCOR 0x7C /* receive clock option */
-#define CD1400_TBPR 0x72 /* transmit baud rate period */
-#define CD1400_TCOR 0x76 /* transmit clock option */
diff --git a/sys/dev/ic/cd180.h b/sys/dev/ic/cd180.h
deleted file mode 100644
index 5783ebd2db56..000000000000
--- a/sys/dev/ic/cd180.h
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * Copyright (C) 1995 by Pavel Antonov, Moscow, Russia.
- * Copyright (C) 1995 by Andrey A. Chernov, Moscow, Russia.
- * 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 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 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.
- */
-
-/*
- * Cirrus Logic CD180 registers
- */
-
-/* Global registers */
-#define CD180_GIVR 0x40 /* Global Interrupt Verctor Register */
-#define CD180_GICR 0x41 /* Global Interrupting Channel Register */
-#define CD180_PILR1 0x61 /* Priority Interrupt Level Register 1 */
-#define CD180_PILR2 0x62 /* Priority Interrupt Level Register 2 */
-#define CD180_PILR3 0x63 /* Priority Interrupt Level Register 3 */
-#define CD180_CAR 0x64 /* Channel Access Register */
-#define CD180_GFRCR 0x6B /* Global Firmware Revision Code Register */
-#define CD180_PPRH 0x70 /* Prescaler Period Register MSB */
-#define CD180_PPRL 0x71 /* Prescaler Period Register LSB */
-#define CD180_RDR 0x78 /* Receiver Data Register */
-#define CD180_RCSR 0x7A /* Receiver Character Status Register */
-#define CD180_TDR 0x7B /* Transmit Data Register */
-#define CD180_EOIR 0x7F /* End of Interrupt Register */
-
-/* Channel Registers */
-#define CD180_CCR 0x01 /* Channel Command Register */
-#define CD180_IER 0x02 /* Interrupt Enable Register */
-#define CD180_COR1 0x03 /* Channel Option Register 1 */
-#define CD180_COR2 0x04 /* Channel Option Register 1 */
-#define CD180_COR3 0x05 /* Channel Option Register 1 */
-#define CD180_CCSR 0x06 /* Channel Control STatus Register */
-#define CD180_RDCR 0x07 /* Receive Data Count Register */
-#define CD180_SCHR1 0x09 /* Special Character Register 1 */
-#define CD180_SCHR2 0x0A /* Special Character Register 2 */
-#define CD180_SCHR3 0x0B /* Special Character Register 3 */
-#define CD180_SCHR4 0x0C /* Special Character Register 4 */
-#define CD180_MCOR1 0x10 /* Modem Change Option 1 Register */
-#define CD180_MCOR2 0x11 /* Modem Change Option 2 Register */
-#define CD180_MCR 0x12 /* Modem Change Register */
-#define CD180_RTPR 0x18 /* Receive Timeout Period Register */
-#define CD180_MSVR 0x28 /* Modem Signal Value Register */
-#define CD180_RBPRH 0x31 /* Receive Baud Rate Period Register MSB */
-#define CD180_RBPRL 0x32 /* Receive Baud Rate Period Register LSB */
-#define CD180_TBPRH 0x39 /* Transmit Baud Rate Period Register MSB */
-#define CD180_TBPRL 0x3A /* Transmit Baud Rate Period Register LSB */
-
-/** Register descritpions **/
-
-/* Global Interrupt Vector Register */
-#define GIVR_IT_MSCI 0x01 /* Modem Signal Change Interrupt */
-#define GIVR_IT_TDI 0x02 /* Transmit Data Interrupt */
-#define GIVR_IT_RGDI 0x03 /* Receive Good Data Interrupt */
-#define GIVR_IT_REI 0x07 /* Receive Exception Interrupt */
-
-/* Global Interrupt Channel Register */
-#define GICR_CHAN 0x1C /* Channel Number Mask */
-#define GICR_LSH 2 /* Channel Number Shift */
-
-/* Channel Address Register */
-#define CAR_CHAN 0x07 /* Channel Number Mask */
-#define CAR_A7 0x08 /* Addres bit 7 (unused) */
-
-/* Receive Character Status Register */
-#define RCSR_OE 0x01 /* Overrun Error */
-#define RCSR_FE 0x02 /* Frame Error */
-#define RCSR_PE 0x04 /* Parity Error */
-#define RCSR_Break 0x08 /* Break detected */
-#define RCSR_Timeout 0x80 /* Rx Timeout */
-#define RCSR_SCMASK 0x70 /* Special Character Detected Mask */
-#define RCSR_SC1 0x10 /* Special Char 1 (or 1 & 3 seq matched) */
-#define RCSR_SC2 0x20 /* Special Char 2 (or 2 & 4 seq matched) */
-#define RCSR_SC3 0x30 /* Special Char 3 */
-#define RCSR_SC4 0x40 /* Special Char 4 */
-
-/* Channel Command Register */
-#define CCR_ResetChan 0x80 /* Reset Channel */
-#define CCR_HWRESET 0x81 /* Hardware Reset (all channels) */
-#define CCR_CORCHG1 0x42 /* Channel Option Register 1 Changed */
-#define CCR_CORCHG2 0x44 /* Channel Option Register 2 Changed */
-#define CCR_CORCHG3 0x48 /* Channel Option Register 3 Changed */
-#define CCR_SENDSPCH1 0x21 /* Send Special Character 1 */
-#define CCR_SENDSPCH2 0x22 /* Send Special Character 2 */
-#define CCR_SENDSPCH3 0x23 /* Send Special Character 3 */
-#define CCR_SENDSPCH4 0x24 /* Send Special Character 4 */
-#define CCR_RCVRDIS 0x11 /* Receiver Disable */
-#define CCR_RCVREN 0x12 /* Receiver Enable */
-#define CCR_XMTRDIS 0x14 /* Transmitter Disable */
-#define CCR_XMTREN 0x18 /* Transmitter Enable */
-
-/* Interrupt Enable Register */
-#define IER_DSR 0x80 /* Enable interrupt on DSR change */
-#define IER_CD 0x40 /* Enable interrupt on CD change */
-#define IER_CTS 0x20 /* Enable interrupt on CTS change */
-#define IER_RxData 0x10 /* Enable interrupt on Receive Data */
-#define IER_RxSC 0x08 /* Enable interrupt on Receive Spec. Char */
-#define IER_TxRdy 0x04 /* Enable interrupt on TX FIFO empty */
-#define IER_TxMpty 0x02 /* Enable interrupt on TX completely empty*/
-#define IER_RET 0x01 /* Enable interrupt on RX Except. Timeout */
-
-/* Channel Option Register 1 */
-#define COR1_ODDP 0x80 /* Odd Parity */
-#define COR1_ParMMASK 0x60 /* Parity Mode mask */
-#define COR1_NOPAR 0x02 /* No Parity */
-#define COR1_FORCEPAR 0x20 /* Force Parity */
-#define COR1_NORMPAR 0x40 /* Normal Parity */
-#define COR1_Ignore 0x10 /* Ignore Parity on RX */
-#define COR1_StopMASK 0x0C /* Stop Bits mode mask */
-#define COR1_1SB 0x00 /* 1 Stop Bit */
-#define COR1_15SB 0x04 /* 1.5 Stop Bits */
-#define COR1_2SB 0x08 /* 2 Stop Bits */
-#define COR1_CHLMASK 0x03 /* Character Length mask */
-#define COR1_5BITS 0x00 /* 5 bits */
-#define COR1_6BITS 0x01 /* 6 bits */
-#define COR1_7BITS 0x02 /* 7 bits */
-#define COR1_8BITS 0x03 /* 8 bits */
-
-/* Channel Option Register 2 */
-#define COR2_IXM 0x80 /* Implied XON mode */
-#define COR2_TxIBE 0x40 /* Enable In-Band XON/XOFF Flow Control */
-#define COR2_ETC 0x20 /* Embedded Tx Commands Enable */
-#define COR2_LLM 0x10 /* Local Loopback Mode */
-#define COR2_RLM 0x08 /* Remote Loopback Mode */
-#define COR2_RtsAO 0x04 /* RTS Automatic Output Enable */
-#define COR2_CtsAE 0x02 /* CTS Automatic Enable */
-#define COR2_DsrAE 0x01 /* DSR Automatic Enable */
-
-/* Channel Option Register 3 */
-#define COR3_XonCH 0x80 /* XON is a double seq (1 & 3) */
-#define COR3_XoffCH 0x40 /* XOFF is a double seq (1 & 3) */
-#define COR3_FCT 0x20 /* Flow-Control Transparency Mode */
-#define COR3_SCDE 0x10 /* Special Character Detection Enable */
-#define COR3_RxTHMASK 0x0F /* RX FIFO Threshold value (1-8) */
-
-/* Channel Control Status Register */
-#define CCSR_RxEn 0x80 /* Revceiver Enabled */
-#define CCSR_RxFloff 0x40 /* Receive Flow Off (XOFF sent) */
-#define CCSR_RxFlon 0x20 /* Receive Flow On (XON sent) */
-#define CCSR_TxEn 0x08 /* Transmitter Enabled */
-#define CCSR_TxFloff 0x04 /* Transmit Flow Off (got XOFF) */
-#define CCSR_TxFlon 0x02 /* Transmit Flow On (got XON) */
-
-/* Modem Change Option Register 1 */
-#define MCOR1_DSRzd 0x80 /* Detect 0->1 transition of DSR */
-#define MCOR1_CDzd 0x40 /* Detect 0->1 transition of CD */
-#define MCOR1_CTSzd 0x20 /* Detect 0->1 transition of CTS */
-#define MCOR1_DTRthMASK 0x0F /* Automatic DTR FC Threshold (1-8) chars */
-
-/* Modem Change Option Register 2 */
-#define MCOR2_DSRod 0x80 /* Detect 1->0 transition of DSR */
-#define MCOR2_CDod 0x40 /* Detect 1->0 transition of CD */
-#define MCOR2_CTSod 0x20 /* Detect 1->0 transition of CTS */
-
-/* Modem Change Register */
-#define MCR_DSRchg 0x80 /* DSR Changed */
-#define MCR_CDchg 0x40 /* CD Changed */
-#define MCR_CTSchg 0x20 /* CTS Changed */
-
-/* Modem Signal Value Register */
-#define MSVR_DSR 0x80 /* Current state of DSR input */
-#define MSVR_CD 0x40 /* Current state of DSR input */
-#define MSVR_CTS 0x20 /* Current state of CTS input */
-#define MSVR_DTR 0x02 /* Current state of DTR output */
-#define MSVR_RTS 0x01 /* Current state of RTS output */
-
-/* Escape characters */
-#define CD180_C_ESC 0x00 /* Escape character */
-#define CD180_C_SBRK 0x81 /* Start sending BREAK */
-#define CD180_C_DELAY 0x82 /* Delay output */
-#define CD180_C_EBRK 0x83 /* Stop sending BREAK */
-
-/* Miscellaneous */
-#define CD180_NCHAN 8 /* 8 channels per chip */
-#define CD180_CTICKS 16 /* 16 ticks for character processing */
-#define CD180_NFIFO 8 /* 8 bytes in FIFO */
diff --git a/sys/dev/ic/esp.h b/sys/dev/ic/esp.h
deleted file mode 100644
index a381ee7d22aa..000000000000
--- a/sys/dev/ic/esp.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*-
- * Copyright (c) 1995 Sean Eric Fagan.
- * 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 author nor the names of contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _IC_ESP_H_
-#define _IC_ESP_H_
-
-/*
- * Definitions for Hayes ESP serial cards.
- */
-
-/*
- * CMD1 and CMD2 are the command ports, offsets from <esp_iobase>.
- */
-#define ESP_CMD1 4
-#define ESP_CMD2 5
-
-/*
- * STAT1 and STAT2 are to get return values and status bytes;
- * they overload CMD1 and CMD2.
- */
-#define ESP_STATUS1 ESP_CMD1
-#define ESP_STATUS2 ESP_CMD2
-
-/*
- * Commands. Commands are given by writing the command value to
- * ESP_CMD1 and then writing or reading some number of bytes from
- * ESP_CMD2 or ESP_STATUS2.
- */
-#define ESP_GETTEST 0x01 /* self-test command (1 byte + extras) */
-#define ESP_GETDIPS 0x02 /* get on-board DIP switches (1 byte) */
-#define ESP_SETFLOWTYPE 0x08 /* set type of flow-control (2 bytes) */
-#define ESP_SETRXFLOW 0x0a /* set Rx FIFO flow control levels (4 bytes) */
-#define ESP_SETMODE 0x10 /* set board mode (1 byte) */
-
-/* Mode bits (ESP_SETMODE). */
-#define ESP_MODE_FIFO 0x02 /* act like a 16550 (compatibility mode) */
-#define ESP_MODE_RTS 0x04 /* use RTS hardware flow control */
-#define ESP_MODE_SCALE 0x80 /* scale FIFO trigger levels */
-
-/* Flow control type bits (ESP_SETFLOWTYPE). */
-#define ESP_FLOW_RTS 0x04 /* cmd1: local Rx sends RTS flow control */
-#define ESP_FLOW_CTS 0x10 /* cmd2: local transmitter responds to CTS */
-
-/* Used by ESP_SETRXFLOW. */
-#define HIBYTE(w) (((w) >> 8) & 0xff)
-#define LOBYTE(w) ((w) & 0xff)
-
-#endif /* !_IC_ESP_H_ */
diff --git a/sys/dev/ic/i8237.h b/sys/dev/ic/i8237.h
deleted file mode 100644
index 2bc8a08317c6..000000000000
--- a/sys/dev/ic/i8237.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * Intel 8237 DMA Controller
- *
- * $FreeBSD$
- */
-
-#define DMA37MD_SINGLE 0x40 /* single pass mode */
-#define DMA37MD_CASCADE 0xc0 /* cascade mode */
-#define DMA37MD_AUTO 0x50 /* autoinitialise single pass mode */
-#define DMA37MD_WRITE 0x04 /* read the device, write memory operation */
-#define DMA37MD_READ 0x08 /* write the device, read memory operation */
-
diff --git a/sys/dev/ic/i82586.h b/sys/dev/ic/i82586.h
deleted file mode 100644
index 964621bd3677..000000000000
--- a/sys/dev/ic/i82586.h
+++ /dev/null
@@ -1,332 +0,0 @@
-/*-
- * Copyright (c) 1992, University of Vermont and State Agricultural College.
- * Copyright (c) 1992, Garrett A. Wollman.
- * 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 the University of
- * Vermont and State Agricultural College and Garrett A. Wollman.
- * 4. Neither the name of the University nor the name of the author
- * 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 UNIVERSITY OR 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Intel 82586 Ethernet chip
- * Register, bit, and structure definitions.
- *
- * Written by GAW with reference to the Clarkson Packet Driver code for this
- * chip written by Russ Nelson and others.
- */
-
-struct ie_en_addr {
- u_char data[6];
-};
-
-/*
- * This is the master configuration block. It tells the hardware where all
- * the rest of the stuff is.
- */
-struct ie_sys_conf_ptr {
- u_short mbz; /* must be zero */
- u_char ie_bus_use; /* true if 8-bit only */
- u_char mbz2[5]; /* must be zero */
- caddr_t ie_iscp_ptr; /* 24-bit physaddr of ISCP */
-};
-
-/*
- * Note that this is wired in hardware; the SCP is always located here, no
- * matter what.
- */
-#define IE_SCP_ADDR 0xfffff4
-
-/*
- * The tells the hardware where all the rest of the stuff is, too.
- * FIXME: some of these should be re-commented after we figure out their
- * REAL function.
- */
-struct ie_int_sys_conf_ptr {
- u_char ie_busy; /* zeroed after init */
- u_char mbz;
- u_short ie_scb_offset; /* 16-bit physaddr of next struct */
- caddr_t ie_base; /* 24-bit physaddr for all 16-bit vars */
-};
-
-/*
- * This FINALLY tells the hardware what to do and where to put it.
- */
-struct ie_sys_ctl_block {
- u_short ie_status; /* status word */
- u_short ie_command; /* command word */
- u_short ie_command_list; /* 16-pointer to command block list */
- u_short ie_recv_list; /* 16-pointer to receive frame list */
- u_short ie_err_crc; /* CRC errors */
- u_short ie_err_align; /* Alignment errors */
- u_short ie_err_resource; /* Resource errors */
- u_short ie_err_overrun; /* Overrun errors */
-};
-
-/* Command values */
-#define IE_RU_COMMAND 0x0070 /* mask for RU command */
-#define IE_RU_NOP 0 /* for completeness */
-#define IE_RU_START 0x0010 /* start receive unit command */
-#define IE_RU_ENABLE 0x0020 /* enable receiver command */
-#define IE_RU_DISABLE 0x0030 /* disable receiver command */
-#define IE_RU_ABORT 0x0040 /* abort current receive operation */
-
-#define IE_CU_COMMAND 0x0700 /* mask for CU command */
-#define IE_CU_NOP 0 /* included for completeness */
-#define IE_CU_START 0x0100 /* do-command command */
-#define IE_CU_RESUME 0x0200 /* resume a suspended cmd list */
-#define IE_CU_STOP 0x0300 /* SUSPEND was already taken */
-#define IE_CU_ABORT 0x0400 /* abort current command */
-
-#define IE_ACK_COMMAND 0xf000 /* mask for ACK command */
-#define IE_ACK_CX 0x8000 /* ack IE_ST_DONE */
-#define IE_ACK_FR 0x4000 /* ack IE_ST_RECV */
-#define IE_ACK_CNA 0x2000 /* ack IE_ST_ALLDONE */
-#define IE_ACK_RNR 0x1000 /* ack IE_ST_RNR */
-
-#define IE_ACTION_COMMAND(x) (((x) & IE_CU_COMMAND) == IE_CU_START)
- /* is this command an action command? */
-
-/* Status values */
-#define IE_ST_WHENCE 0xf000 /* mask for cause of interrupt */
-#define IE_ST_DONE 0x8000 /* command with I bit completed */
-#define IE_ST_RECV 0x4000 /* frame received */
-#define IE_ST_ALLDONE 0x2000 /* all commands completed */
-#define IE_ST_RNR 0x1000 /* receive not ready */
-
-#define IE_CU_STATUS 0x700 /* mask for command unit status */
-#define IE_CU_ACTIVE 0x200 /* command unit is active */
-#define IE_CU_SUSPEND 0x100 /* command unit is suspended */
-
-#define IE_RU_STATUS 0x70 /* mask for receiver unit status */
-#define IE_RU_SUSPEND 0x10 /* receiver is suspended */
-#define IE_RU_NOSPACE 0x20 /* receiver has no resources */
-#define IE_RU_READY 0x40 /* reveiver is ready */
-
-/*
- * This is filled in partially by the chip, partially by us.
- */
-struct ie_recv_frame_desc {
- u_short ie_fd_status; /* status for this frame */
- u_short ie_fd_last; /* end of frame list flag */
- u_short ie_fd_next; /* 16-pointer to next RFD */
- u_short ie_fd_buf_desc; /* 16-pointer to list of buffer desc's */
- struct ie_en_addr dest; /* destination ether */
- struct ie_en_addr src; /* source ether */
- u_short ie_length; /* 802 length/Ether type */
- u_short mbz; /* must be zero */
-};
-
-#define IE_FD_LAST 0x8000 /* last rfd in list */
-#define IE_FD_SUSP 0x4000 /* suspend RU after receipt */
-
-#define IE_FD_COMPLETE 0x8000 /* frame is complete */
-#define IE_FD_BUSY 0x4000 /* frame is busy */
-#define IE_FD_OK 0x2000 /* frame is bad */
-#define IE_FD_RNR 0x0200 /* receiver out of resources here */
-
-/*
- * linked list of buffers...
- */
-struct ie_recv_buf_desc {
- u_short ie_rbd_actual; /* status for this buffer */
- u_short ie_rbd_next; /* 16-pointer to next RBD */
- caddr_t ie_rbd_buffer; /* 24-pointer to buffer for this RBD */
- u_short ie_rbd_length; /* length of the buffer */
- u_short mbz; /* must be zero */
-};
-
-#define IE_RBD_LAST 0x8000 /* last buffer */
-#define IE_RBD_USED 0x4000 /* this buffer has data */
-/*
- * All commands share this in common.
- */
-struct ie_cmd_common {
- u_short ie_cmd_status; /* status of this command */
- u_short ie_cmd_cmd; /* command word */
- u_short ie_cmd_link; /* link to next command */
-};
-
-#define IE_STAT_COMPL 0x8000 /* command is completed */
-#define IE_STAT_BUSY 0x4000 /* command is running now */
-#define IE_STAT_OK 0x2000 /* command completed successfully */
-
-#define IE_CMD_NOP 0x0000 /* NOP */
-#define IE_CMD_IASETUP 0x0001 /* initial address setup */
-#define IE_CMD_CONFIG 0x0002 /* configure command */
-#define IE_CMD_MCAST 0x0003 /* multicast setup command */
-#define IE_CMD_XMIT 0x0004 /* transmit command */
-#define IE_CMD_TDR 0x0005 /* time-domain reflectometer command */
-#define IE_CMD_DUMP 0x0006 /* dump command */
-#define IE_CMD_DIAGNOSE 0x0007 /* diagnostics command */
-
-#define IE_CMD_LAST 0x8000 /* this is the last command in the list */
-#define IE_CMD_SUSPEND 0x4000 /* suspend CU after this command */
-#define IE_CMD_INTR 0x2000 /* post an interrupt after completion */
-
-/*
- * This is the command to transmit a frame.
- */
-struct ie_xmit_cmd {
- struct ie_cmd_common com; /* common part */
-#define ie_xmit_status com.ie_cmd_status
-
- u_short ie_xmit_desc; /* 16-pointer to buffer descriptor */
- struct ie_en_addr ie_xmit_addr; /* destination address */
-
- u_short ie_xmit_length; /* 802.3 length/Ether type field */
-};
-
-#define IE_XS_MAXCOLL 0x000f /* number of collisions during transmit */
-#define IE_XS_EXCMAX 0x0020 /* exceeded maximum number of collisions */
-#define IE_XS_SQE 0x0040 /* SQE positive */
-#define IE_XS_DEFERRED 0x0080 /* transmission deferred */
-#define IE_XS_UNDERRUN 0x0100 /* DMA underrun */
-#define IE_XS_LOSTCTS 0x0200 /* Lost CTS */
-#define IE_XS_NOCARRIER 0x0400 /* No Carrier */
-#define IE_XS_LATECOLL 0x0800 /* Late collision */
-
-/*
- * This is a buffer descriptor for a frame to be transmitted.
- */
-
-struct ie_xmit_buf {
- u_short ie_xmit_flags; /* see below */
- u_short ie_xmit_next; /* 16-pointer to next desc. */
- caddr_t ie_xmit_buf; /* 24-pointer to the actual buffer */
-};
-
-#define IE_XMIT_LAST 0x8000 /* this TBD is the last one */
-/* The rest of the `flags' word is actually the length. */
-
-/*
- * Multicast setup command.
- */
-
-#define MAXMCAST 50 /* must fit in transmit buffer */
-
-struct ie_mcast_cmd {
- struct ie_cmd_common com; /* common part */
-#define ie_mcast_status com.ie_cmd_status
-
- u_short ie_mcast_bytes; /* size (in bytes) of multicast addresses */
- struct ie_en_addr ie_mcast_addrs[MAXMCAST + 1]; /* space for them */
-};
-
-/*
- * Time Domain Reflectometer command.
- */
-
-struct ie_tdr_cmd {
- struct ie_cmd_common com; /* common part */
-#define ie_tdr_status com.ie_cmd_status
-
- u_short ie_tdr_time; /* error bits and time */
-};
-
-#define IE_TDR_SUCCESS 0x8000 /* TDR succeeded without error */
-#define IE_TDR_XCVR 0x4000 /* detected a transceiver problem */
-#define IE_TDR_OPEN 0x2000 /* detected an open */
-#define IE_TDR_SHORT 0x1000 /* TDR detected a short */
-#define IE_TDR_TIME 0x07ff /* mask for reflection time */
-
-/*
- * Initial Address Setup command
- */
-struct ie_iasetup_cmd {
- struct ie_cmd_common com;
-#define ie_iasetup_status com.ie_cmd_status
-
- struct ie_en_addr ie_address;
-};
-
-/*
- * Configuration command
- */
-struct ie_config_cmd {
- struct ie_cmd_common com; /* common part */
-#define ie_config_status com.ie_cmd_status
-
- u_char ie_config_count; /* byte count (0x0c) */
- u_char ie_fifo; /* fifo (8) */
- u_char ie_save_bad; /* save bad frames (0x40) */
- u_char ie_addr_len; /* address length (0x2e) (AL-LOC == 1) */
- u_char ie_priority; /* priority and backoff (0x0) */
- u_char ie_ifs; /* inter-frame spacing (0x60) */
- u_char ie_slot_low; /* slot time, LSB (0x0) */
- u_char ie_slot_high; /* slot time, MSN, and retries (0xf2) */
- u_char ie_promisc; /* 1 if promiscuous, else 0 */
- u_char ie_crs_cdt; /* CSMA/CD parameters (0x0) */
- u_char ie_min_len; /* min frame length (0x40) */
- u_char ie_junk; /* stuff for 82596 (0xff) */
-};
-
-/*
- * Here are a few useful functions. We could have done these as macros,
- * but since we have the inline facility, it makes sense to use that
- * instead.
- */
-static __inline void
-ie_setup_config(volatile struct ie_config_cmd *cmd,
- int promiscuous, int manchester) {
- cmd->ie_config_count = 0x0c;
- cmd->ie_fifo = 8;
- cmd->ie_save_bad = 0x40;
- cmd->ie_addr_len = 0x2e;
- cmd->ie_priority = 0;
- cmd->ie_ifs = 0x60;
- cmd->ie_slot_low = 0;
- cmd->ie_slot_high = 0xf2;
- cmd->ie_promisc = !!promiscuous | manchester << 2;
- cmd->ie_crs_cdt = 0;
- cmd->ie_min_len = 64;
- cmd->ie_junk = 0xff;
-}
-
-static __inline void *
-Align(void *ptr) {
- uintptr_t l = (uintptr_t)ptr;
- l = (l + 3) & ~3L;
- return (void *)l;
-}
-
-static __inline volatile void *
-Alignvol(volatile void *ptr) {
- uintptr_t l = (uintptr_t)ptr;
- l = (l + 3) & ~3L;
- return (volatile void *)l;
-}
-
-static __inline void
-ie_ack(volatile struct ie_sys_ctl_block *scb,
- u_int mask, int unit,
- void (*ca)(int)) {
- scb->ie_command = scb->ie_status & mask;
- (*ca)(unit);
-}
diff --git a/sys/dev/ic/nec765.h b/sys/dev/ic/nec765.h
deleted file mode 100644
index c08b73b7d600..000000000000
--- a/sys/dev/ic/nec765.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/*-
- * 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. 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, Berkeley and its contributors.
- * 4. 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: @(#)nec765.h 7.1 (Berkeley) 5/9/91
- * $FreeBSD$
- */
-
-/*
- * Nec 765 floppy disc controller definitions
- */
-
-/* Main status register */
-#define NE7_DAB 0x01 /* Diskette drive A is seeking, thus busy */
-#define NE7_DBB 0x02 /* Diskette drive B is seeking, thus busy */
-#define NE7_CB 0x10 /* Diskette Controller Busy */
-#define NE7_NDM 0x20 /* Diskette Controller in Non Dma Mode */
-#define NE7_DIO 0x40 /* Diskette Controller Data register I/O */
-#define NE7_RQM 0x80 /* Diskette Controller ReQuest for Master */
-
-/* Status register ST0 */
-#define NE7_ST0BITS "\020\010invld\007abnrml\006seek_cmplt\005equ_chck\004drive_notrdy\003top_head"
-
-#define NE7_ST0_IC 0xc0 /* interrupt completion code */
-
-#define NE7_ST0_IC_RC 0xc0 /* terminated due to ready changed, n/a */
-#define NE7_ST0_IC_IV 0x80 /* invalid command; must reset FDC */
-#define NE7_ST0_IC_AT 0x40 /* abnormal termination, check error stat */
-#define NE7_ST0_IC_NT 0x00 /* normal termination */
-
-#define NE7_ST0_SE 0x20 /* seek end */
-#define NE7_ST0_EC 0x10 /* equipment check, recalibrated but no trk0 */
-#define NE7_ST0_NR 0x08 /* not ready (n/a) */
-#define NE7_ST0_HD 0x04 /* upper head selected */
-#define NE7_ST0_DR 0x03 /* drive code */
-
-/* Status register ST1 */
-#define NE7_ST1BITS "\020\010end_of_cyl\006bad_crc\005data_overrun\003sec_not_fnd\002write_protect\001no_am"
-
-#define NE7_ST1_EN 0x80 /* end of cylinder, access past last record */
-#define NE7_ST1_DE 0x20 /* data error, CRC fail in ID or data */
-#define NE7_ST1_OR 0x10 /* DMA overrun, DMA failed to do i/o quickly */
-#define NE7_ST1_ND 0x04 /* no data, sector not found or CRC in ID f. */
-#define NE7_ST1_NW 0x02 /* not writeable, attempt to violate WP */
-#define NE7_ST1_MA 0x01 /* missing address mark (in ID or data field)*/
-
-/* Status register ST2 */
-#define NE7_ST2BITS "\020\007ctrl_mrk\006bad_crc\005wrong_cyl\004scn_eq\003scn_not_fnd\002bad_cyl\001no_dam"
-
-#define NE7_ST2_CM 0x40 /* control mark; found deleted data */
-#define NE7_ST2_DD 0x20 /* data error in data field, CRC fail */
-#define NE7_ST2_WC 0x10 /* wrong cylinder, ID field mismatches cmd */
-#define NE7_ST2_SH 0x08 /* scan equal hit */
-#define NE7_ST2_SN 0x04 /* scan not satisfied */
-#define NE7_ST2_BC 0x02 /* bad cylinder, cylinder marked 0xff */
-#define NE7_ST2_MD 0x01 /* missing address mark in data field */
-
-/* Status register ST3 */
-#define NE7_ST3BITS "\020\010fault\007write_protect\006drdy\005tk0\004two_side\003side_sel\002"
-
-#define NE7_ST3_FT 0x80 /* fault; PC: n/a */
-#define NE7_ST3_WP 0x40 /* write protected */
-#define NE7_ST3_RD 0x20 /* ready; PC: always true */
-#define NE7_ST3_T0 0x10 /* track 0 */
-#define NE7_ST3_TS 0x08 /* two-sided; PC: n/a */
-#define NE7_ST3_HD 0x04 /* upper head select */
-#define NE7_ST3_US 0x03 /* unit select */
-
-/* Commands */
-/*
- * the top three bits -- where appropriate -- are set as follows:
- *
- * 0x80 - MT multi-track; allow both sides to be handled in single cmd
- * 0x40 - MFM modified frequency modulation; use MFM encoding
- * 0x20 - SK skip; skip sectors marked as "deleted"
- */
-#define NE7CMD_READTRK 0x42 /* read whole track */
-#define NE7CMD_SPECIFY 3 /* specify drive parameters - requires unit
- parameters byte */
-#define NE7CMD_SENSED 4 /* sense drive - requires unit select byte */
-#define NE7CMD_WRITE 0xc5 /* write - requires eight additional bytes */
-#define NE7CMD_READ 0xe6 /* read - requires eight additional bytes */
-#define NE7CMD_RECAL 7 /* recalibrate drive - requires
- unit select byte */
-#define NE7CMD_SENSEI 8 /* sense controller interrupt status */
-#define NE7CMD_WRITEDEL 0xc9 /* write deleted data */
-#define NE7CMD_READID 0x4a /* read ID field */
-#define NE7CMD_READDEL 0xec /* read deleted data */
-#define NE7CMD_FORMAT 0x4d /* format - requires five additional bytes */
-#define NE7CMD_SEEK 0x0f /* seek drive - requires unit select byte
- and new cyl byte */
-#define NE7CMD_SCNEQU 0xf1 /* scan equal */
-#define NE7CMD_SCNLE 0xf9 /* scan less or equal */
-#define NE7CMD_SCNGE 0xfd /* scan greater or equal */
-
-/*
- * Enhanced controller commands:
- */
-#define NE7CMD_VERSION 0x10 /* version (ok for all controllers) */
-
-#define I8207X_CONFIGURE 0x13 /* configure enhanced features */
-
-/*
- * "specify" definitions
- *
- * acronyms (times are relative to a FDC clock of 8 MHz):
- * srt - step rate; PC usually 3 ms
- * hut - head unload time; PC usually maximum of 240 ms
- * hlt - head load time; PC usually minimum of 2 ms
- * nd - no DMA flag; PC usually not set (0)
- */
-
-#define NE7_SPEC_1(srt, hut) (((16 - (srt)) << 4) | (((hut) / 16)))
-#define NE7_SPEC_2(hlt, nd) (((hlt) & 0xFE) | ((nd) & 1))
diff --git a/sys/dev/ic/ns16550.h b/sys/dev/ic/ns16550.h
deleted file mode 100644
index e8fad7da832e..000000000000
--- a/sys/dev/ic/ns16550.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*-
- * 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. 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, Berkeley and its contributors.
- * 4. 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: @(#)ns16550.h 7.1 (Berkeley) 5/9/91
- * $FreeBSD$
- */
-
-/*
- * NS16550 UART registers
- */
-#ifdef PC98
-#define com_data 0x000 /* data register (R/W) */
-#define com_dlbl 0x000 /* divisor latch low (W) */
-#define com_dlbh 0x100 /* divisor latch high (W) */
-#define com_ier 0x100 /* interrupt enable (W) */
-#define com_iir 0x200 /* interrupt identification (R) */
-#define com_fifo 0x200 /* FIFO control (W) */
-#define com_lctl 0x300 /* line control register (R/W) */
-#define com_cfcr 0x300 /* line control register (R/W) */
-#define com_mcr 0x400 /* modem control register (R/W) */
-#define com_lsr 0x500 /* line status register (R/W) */
-#define com_msr 0x600 /* modem status register (R/W) */
-#else /* IBM-PC */
-#define com_data 0 /* data register (R/W) */
-#define com_dlbl 0 /* divisor latch low (W) */
-#define com_dlbh 1 /* divisor latch high (W) */
-#define com_ier 1 /* interrupt enable (W) */
-#define com_iir 2 /* interrupt identification (R) */
-#define com_fifo 2 /* FIFO control (W) */
-#define com_lctl 3 /* line control register (R/W) */
-#define com_cfcr 3 /* line control register (R/W) */
-#define com_mcr 4 /* modem control register (R/W) */
-#define com_lsr 5 /* line status register (R/W) */
-#define com_msr 6 /* modem status register (R/W) */
-#endif /* PC98 */
diff --git a/sys/dev/iicbus/iic.h b/sys/dev/iicbus/iic.h
deleted file mode 100644
index 5d362c1a2dd4..000000000000
--- a/sys/dev/iicbus/iic.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*-
- * Copyright (c) 1998 Nicolas Souchu
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- *
- */
-#ifndef __IIC_H
-#define __IIC_H
-
-#include <sys/ioccom.h>
-
-struct iiccmd {
- u_char slave;
- int count;
- int last;
- char *buf;
-};
-
-#define I2CSTART _IOW('i', 1, struct iiccmd) /* start condition */
-#define I2CSTOP _IO('i', 2) /* stop condition */
-#define I2CRSTCARD _IOW('i', 3, struct iiccmd) /* reset the card */
-#define I2CWRITE _IOW('i', 4, struct iiccmd) /* send data */
-#define I2CREAD _IOW('i', 5, struct iiccmd) /* receive data */
-
-#endif
diff --git a/sys/dev/isp/isp_pci.c b/sys/dev/isp/isp_pci.c
deleted file mode 100644
index b2f72d4f519f..000000000000
--- a/sys/dev/isp/isp_pci.c
+++ /dev/null
@@ -1,1769 +0,0 @@
-/* $FreeBSD$ */
-/*
- * PCI specific probe and attach routines for Qlogic ISP SCSI adapters.
- * FreeBSD Version.
- *
- *---------------------------------------
- * Copyright (c) 1997, 1998, 1999 by Matthew Jacob
- * NASA/Ames Research Center
- * 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 immediately at the beginning of the file, without modification,
- * 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 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 AUTHOR 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 <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/bus.h>
-
-#include <pci/pcireg.h>
-#include <pci/pcivar.h>
-
-#include <machine/bus_memio.h>
-#include <machine/bus_pio.h>
-#include <machine/bus.h>
-#include <machine/resource.h>
-#include <machine/clock.h>
-#include <sys/rman.h>
-#include <sys/malloc.h>
-
-#include <dev/isp/isp_freebsd.h>
-#include <dev/isp/asm_pci.h>
-
-static u_int16_t isp_pci_rd_reg __P((struct ispsoftc *, int));
-static void isp_pci_wr_reg __P((struct ispsoftc *, int, u_int16_t));
-#if !defined(ISP_DISABLE_1080_SUPPORT) || !defined(ISP_DISABLE_12160_SUPPORT)
-static u_int16_t isp_pci_rd_reg_1080 __P((struct ispsoftc *, int));
-static void isp_pci_wr_reg_1080 __P((struct ispsoftc *, int, u_int16_t));
-#endif
-static int isp_pci_mbxdma __P((struct ispsoftc *));
-static int isp_pci_dmasetup __P((struct ispsoftc *, ISP_SCSI_XFER_T *,
- ispreq_t *, u_int16_t *, u_int16_t));
-static void
-isp_pci_dmateardown __P((struct ispsoftc *, ISP_SCSI_XFER_T *, u_int32_t));
-
-static void isp_pci_reset1 __P((struct ispsoftc *));
-static void isp_pci_dumpregs __P((struct ispsoftc *));
-
-#ifndef ISP_CODE_ORG
-#define ISP_CODE_ORG 0x1000
-#endif
-#ifndef ISP_1040_RISC_CODE
-#define ISP_1040_RISC_CODE NULL
-#endif
-#ifndef ISP_1080_RISC_CODE
-#define ISP_1080_RISC_CODE NULL
-#endif
-#ifndef ISP_12160_RISC_CODE
-#define ISP_12160_RISC_CODE NULL
-#endif
-#ifndef ISP_2100_RISC_CODE
-#define ISP_2100_RISC_CODE NULL
-#endif
-#ifndef ISP_2200_RISC_CODE
-#define ISP_2200_RISC_CODE NULL
-#endif
-
-#ifndef ISP_DISABLE_1020_SUPPORT
-static struct ispmdvec mdvec = {
- isp_pci_rd_reg,
- isp_pci_wr_reg,
- isp_pci_mbxdma,
- isp_pci_dmasetup,
- isp_pci_dmateardown,
- NULL,
- isp_pci_reset1,
- isp_pci_dumpregs,
- ISP_1040_RISC_CODE,
- 0,
- ISP_CODE_ORG,
- 0,
- BIU_BURST_ENABLE|BIU_PCI_CONF1_FIFO_64,
- 0
-};
-#endif
-
-#ifndef ISP_DISABLE_1080_SUPPORT
-static struct ispmdvec mdvec_1080 = {
- isp_pci_rd_reg_1080,
- isp_pci_wr_reg_1080,
- isp_pci_mbxdma,
- isp_pci_dmasetup,
- isp_pci_dmateardown,
- NULL,
- isp_pci_reset1,
- isp_pci_dumpregs,
- ISP_1080_RISC_CODE,
- 0,
- ISP_CODE_ORG,
- 0,
- BIU_BURST_ENABLE|BIU_PCI_CONF1_FIFO_64,
- 0
-};
-#endif
-
-#ifndef ISP_DISABLE_12160_SUPPORT
-static struct ispmdvec mdvec_12160 = {
- isp_pci_rd_reg_1080,
- isp_pci_wr_reg_1080,
- isp_pci_mbxdma,
- isp_pci_dmasetup,
- isp_pci_dmateardown,
- NULL,
- isp_pci_reset1,
- isp_pci_dumpregs,
- ISP_12160_RISC_CODE,
- 0,
- ISP_CODE_ORG,
- 0,
- BIU_BURST_ENABLE|BIU_PCI_CONF1_FIFO_64,
- 0
-};
-#endif
-
-#ifndef ISP_DISABLE_2100_SUPPORT
-static struct ispmdvec mdvec_2100 = {
- isp_pci_rd_reg,
- isp_pci_wr_reg,
- isp_pci_mbxdma,
- isp_pci_dmasetup,
- isp_pci_dmateardown,
- NULL,
- isp_pci_reset1,
- isp_pci_dumpregs,
- ISP_2100_RISC_CODE,
- 0,
- ISP_CODE_ORG,
- 0,
- 0,
- 0
-};
-#endif
-
-#ifndef ISP_DISABLE_2200_SUPPORT
-static struct ispmdvec mdvec_2200 = {
- isp_pci_rd_reg,
- isp_pci_wr_reg,
- isp_pci_mbxdma,
- isp_pci_dmasetup,
- isp_pci_dmateardown,
- NULL,
- isp_pci_reset1,
- isp_pci_dumpregs,
- ISP_2200_RISC_CODE,
- 0,
- ISP_CODE_ORG,
- 0,
- 0,
- 0
-};
-#endif
-
-#ifndef SCSI_ISP_PREFER_MEM_MAP
-#define SCSI_ISP_PREFER_MEM_MAP 0
-#endif
-
-#ifndef PCIM_CMD_INVEN
-#define PCIM_CMD_INVEN 0x10
-#endif
-#ifndef PCIM_CMD_BUSMASTEREN
-#define PCIM_CMD_BUSMASTEREN 0x0004
-#endif
-#ifndef PCIM_CMD_PERRESPEN
-#define PCIM_CMD_PERRESPEN 0x0040
-#endif
-#ifndef PCIM_CMD_SEREN
-#define PCIM_CMD_SEREN 0x0100
-#endif
-
-#ifndef PCIR_COMMAND
-#define PCIR_COMMAND 0x04
-#endif
-
-#ifndef PCIR_CACHELNSZ
-#define PCIR_CACHELNSZ 0x0c
-#endif
-
-#ifndef PCIR_LATTIMER
-#define PCIR_LATTIMER 0x0d
-#endif
-
-#ifndef PCIR_ROMADDR
-#define PCIR_ROMADDR 0x30
-#endif
-
-#ifndef PCI_VENDOR_QLOGIC
-#define PCI_VENDOR_QLOGIC 0x1077
-#endif
-
-#ifndef PCI_PRODUCT_QLOGIC_ISP1020
-#define PCI_PRODUCT_QLOGIC_ISP1020 0x1020
-#endif
-
-#ifndef PCI_PRODUCT_QLOGIC_ISP1080
-#define PCI_PRODUCT_QLOGIC_ISP1080 0x1080
-#endif
-
-#ifndef PCI_PRODUCT_QLOGIC_ISP12160
-#define PCI_PRODUCT_QLOGIC_ISP12160 0x1216
-#endif
-
-#ifndef PCI_PRODUCT_QLOGIC_ISP1240
-#define PCI_PRODUCT_QLOGIC_ISP1240 0x1240
-#endif
-
-#ifndef PCI_PRODUCT_QLOGIC_ISP1280
-#define PCI_PRODUCT_QLOGIC_ISP1280 0x1280
-#endif
-
-#ifndef PCI_PRODUCT_QLOGIC_ISP2100
-#define PCI_PRODUCT_QLOGIC_ISP2100 0x2100
-#endif
-
-#ifndef PCI_PRODUCT_QLOGIC_ISP2200
-#define PCI_PRODUCT_QLOGIC_ISP2200 0x2200
-#endif
-
-#define PCI_QLOGIC_ISP ((PCI_PRODUCT_QLOGIC_ISP1020 << 16) | PCI_VENDOR_QLOGIC)
-
-#define PCI_QLOGIC_ISP1080 \
- ((PCI_PRODUCT_QLOGIC_ISP1080 << 16) | PCI_VENDOR_QLOGIC)
-
-#define PCI_QLOGIC_ISP12160 \
- ((PCI_PRODUCT_QLOGIC_ISP12160 << 16) | PCI_VENDOR_QLOGIC)
-
-#define PCI_QLOGIC_ISP1240 \
- ((PCI_PRODUCT_QLOGIC_ISP1240 << 16) | PCI_VENDOR_QLOGIC)
-
-#define PCI_QLOGIC_ISP1280 \
- ((PCI_PRODUCT_QLOGIC_ISP1280 << 16) | PCI_VENDOR_QLOGIC)
-
-#define PCI_QLOGIC_ISP2100 \
- ((PCI_PRODUCT_QLOGIC_ISP2100 << 16) | PCI_VENDOR_QLOGIC)
-
-#define PCI_QLOGIC_ISP2200 \
- ((PCI_PRODUCT_QLOGIC_ISP2200 << 16) | PCI_VENDOR_QLOGIC)
-
-#define IO_MAP_REG 0x10
-#define MEM_MAP_REG 0x14
-
-#define PCI_DFLT_LTNCY 0x40
-#define PCI_DFLT_LNSZ 0x10
-
-static int isp_pci_probe (device_t);
-static int isp_pci_attach (device_t);
-
-/* This distinguishing define is not right, but it does work */
-#ifdef __alpha__
-#define IO_SPACE_MAPPING ALPHA_BUS_SPACE_IO
-#define MEM_SPACE_MAPPING ALPHA_BUS_SPACE_MEM
-#else
-#define IO_SPACE_MAPPING I386_BUS_SPACE_IO
-#define MEM_SPACE_MAPPING I386_BUS_SPACE_MEM
-#endif
-
-struct isp_pcisoftc {
- struct ispsoftc pci_isp;
- device_t pci_dev;
- struct resource * pci_reg;
- bus_space_tag_t pci_st;
- bus_space_handle_t pci_sh;
- void * ih;
- int16_t pci_poff[_NREG_BLKS];
- bus_dma_tag_t parent_dmat;
- bus_dma_tag_t cntrol_dmat;
- bus_dmamap_t cntrol_dmap;
- bus_dmamap_t *dmaps;
-};
-
-static device_method_t isp_pci_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, isp_pci_probe),
- DEVMETHOD(device_attach, isp_pci_attach),
- { 0, 0 }
-};
-
-static driver_t isp_pci_driver = {
- "isp", isp_pci_methods, sizeof (struct isp_pcisoftc)
-};
-static devclass_t isp_devclass;
-DRIVER_MODULE(isp, pci, isp_pci_driver, isp_devclass, 0, 0);
-
-static int
-isp_pci_probe(device_t dev)
-{
- switch ((pci_get_device(dev) << 16) | (pci_get_vendor(dev))) {
-#ifndef ISP_DISABLE_1020_SUPPORT
- case PCI_QLOGIC_ISP:
- device_set_desc(dev, "Qlogic ISP 1020/1040 PCI SCSI Adapter");
- break;
-#endif
-#ifndef ISP_DISABLE_1080_SUPPORT
- case PCI_QLOGIC_ISP1080:
- device_set_desc(dev, "Qlogic ISP 1080 PCI SCSI Adapter");
- break;
- case PCI_QLOGIC_ISP1240:
- device_set_desc(dev, "Qlogic ISP 1240 PCI SCSI Adapter");
- break;
- case PCI_QLOGIC_ISP1280:
- device_set_desc(dev, "Qlogic ISP 1280 PCI SCSI Adapter");
- break;
-#endif
-#ifndef ISP_DISABLE_12160_SUPPORT
- case PCI_QLOGIC_ISP12160:
- device_set_desc(dev, "Qlogic ISP 12160 PCI SCSI Adapter");
- break;
-#endif
-#ifndef ISP_DISABLE_2100_SUPPORT
- case PCI_QLOGIC_ISP2100:
- device_set_desc(dev, "Qlogic ISP 2100 PCI FC-AL Adapter");
- break;
-#endif
-#ifndef ISP_DISABLE_2200_SUPPORT
- case PCI_QLOGIC_ISP2200:
- device_set_desc(dev, "Qlogic ISP 2200 PCI FC-AL Adapter");
- break;
-#endif
- default:
- return (ENXIO);
- }
- if (device_get_unit(dev) == 0) {
- CFGPRINTF("Qlogic ISP Driver, FreeBSD Version %d.%d, "
- "Core Version %d.%d\n",
- ISP_PLATFORM_VERSION_MAJOR, ISP_PLATFORM_VERSION_MINOR,
- ISP_CORE_VERSION_MAJOR, ISP_CORE_VERSION_MINOR);
- }
- return (0);
-}
-
-static int
-isp_pci_attach(device_t dev)
-{
-#ifdef SCSI_ISP_WWN
- const char *name = SCSI_ISP_WWN;
- char *vtp = NULL;
-#endif
- struct resource *regs, *irq;
- int unit, bitmap, rtp, rgd, iqd, m1, m2;
- u_int32_t data, cmd, linesz, psize, basetype;
- struct isp_pcisoftc *pcs;
- struct ispsoftc *isp;
- struct ispmdvec *mdvp;
- bus_size_t lim;
- ISP_LOCKVAL_DECL;
-
- /*
- * Figure out if we're supposed to skip this one.
- */
- unit = device_get_unit(dev);
- if (getenv_int("isp_disable", &bitmap)) {
- if (bitmap & (1 << unit)) {
- device_printf(dev, "not configuring\n");
- return (ENODEV);
- }
- }
-
- pcs = malloc(sizeof (struct isp_pcisoftc), M_DEVBUF, M_NOWAIT);
- if (pcs == NULL) {
- device_printf(dev, "cannot allocate softc\n");
- return (ENOMEM);
- }
- bzero(pcs, sizeof (struct isp_pcisoftc));
-
- /*
- * Figure out which we should try first - memory mapping or i/o mapping?
- */
-#if SCSI_ISP_PREFER_MEM_MAP == 1
- m1 = PCIM_CMD_MEMEN;
- m2 = PCIM_CMD_PORTEN;
-#else
- m1 = PCIM_CMD_PORTEN;
- m2 = PCIM_CMD_MEMEN;
-#endif
- bitmap = 0;
- if (getenv_int("isp_mem_map", &bitmap)) {
- if (bitmap & (1 << unit)) {
- m1 = PCIM_CMD_MEMEN;
- m2 = PCIM_CMD_PORTEN;
- }
- }
- bitmap = 0;
- if (getenv_int("isp_io_map", &bitmap)) {
- if (bitmap & (1 << unit)) {
- m1 = PCIM_CMD_PORTEN;
- m2 = PCIM_CMD_MEMEN;
- }
- }
-
- linesz = PCI_DFLT_LNSZ;
- irq = regs = NULL;
- rgd = rtp = iqd = 0;
-
- cmd = pci_read_config(dev, PCIR_COMMAND, 1);
- if (cmd & m1) {
- rtp = (m1 == PCIM_CMD_MEMEN)? SYS_RES_MEMORY : SYS_RES_IOPORT;
- rgd = (m1 == PCIM_CMD_MEMEN)? MEM_MAP_REG : IO_MAP_REG;
- regs = bus_alloc_resource(dev, rtp, &rgd, 0, ~0, 1, RF_ACTIVE);
- }
- if (regs == NULL && (cmd & m2)) {
- rtp = (m2 == PCIM_CMD_MEMEN)? SYS_RES_MEMORY : SYS_RES_IOPORT;
- rgd = (m2 == PCIM_CMD_MEMEN)? MEM_MAP_REG : IO_MAP_REG;
- regs = bus_alloc_resource(dev, rtp, &rgd, 0, ~0, 1, RF_ACTIVE);
- }
- if (regs == NULL) {
- device_printf(dev, "unable to map any ports\n");
- goto bad;
- }
- if (bootverbose)
- printf("isp%d: using %s space register mapping\n", unit,
- (rgd == IO_MAP_REG)? "I/O" : "Memory");
- pcs->pci_dev = dev;
- pcs->pci_reg = regs;
- pcs->pci_st = rman_get_bustag(regs);
- pcs->pci_sh = rman_get_bushandle(regs);
-
- pcs->pci_poff[BIU_BLOCK >> _BLK_REG_SHFT] = BIU_REGS_OFF;
- pcs->pci_poff[MBOX_BLOCK >> _BLK_REG_SHFT] = PCI_MBOX_REGS_OFF;
- pcs->pci_poff[SXP_BLOCK >> _BLK_REG_SHFT] = PCI_SXP_REGS_OFF;
- pcs->pci_poff[RISC_BLOCK >> _BLK_REG_SHFT] = PCI_RISC_REGS_OFF;
- pcs->pci_poff[DMA_BLOCK >> _BLK_REG_SHFT] = DMA_REGS_OFF;
- /*
- * GCC!
- */
- mdvp = &mdvec;
- basetype = ISP_HA_SCSI_UNKNOWN;
- psize = sizeof (sdparam);
- lim = BUS_SPACE_MAXSIZE_32BIT;
-#ifndef ISP_DISABLE_1020_SUPPORT
- if (pci_get_devid(dev) == PCI_QLOGIC_ISP) {
- mdvp = &mdvec;
- basetype = ISP_HA_SCSI_UNKNOWN;
- psize = sizeof (sdparam);
- lim = BUS_SPACE_MAXSIZE_24BIT;
- }
-#endif
-#ifndef ISP_DISABLE_1080_SUPPORT
- if (pci_get_devid(dev) == PCI_QLOGIC_ISP1080) {
- mdvp = &mdvec_1080;
- basetype = ISP_HA_SCSI_1080;
- psize = sizeof (sdparam);
- pcs->pci_poff[DMA_BLOCK >> _BLK_REG_SHFT] =
- ISP1080_DMA_REGS_OFF;
- }
- if (pci_get_devid(dev) == PCI_QLOGIC_ISP1240) {
- mdvp = &mdvec_1080;
- basetype = ISP_HA_SCSI_1240;
- psize = 2 * sizeof (sdparam);
- pcs->pci_poff[DMA_BLOCK >> _BLK_REG_SHFT] =
- ISP1080_DMA_REGS_OFF;
- }
- if (pci_get_devid(dev) == PCI_QLOGIC_ISP1280) {
- mdvp = &mdvec_1080;
- basetype = ISP_HA_SCSI_1280;
- psize = 2 * sizeof (sdparam);
- pcs->pci_poff[DMA_BLOCK >> _BLK_REG_SHFT] =
- ISP1080_DMA_REGS_OFF;
- }
-#endif
-#ifndef ISP_DISABLE_12160_SUPPORT
- if (pci_get_devid(dev) == PCI_QLOGIC_ISP12160) {
- mdvp = &mdvec_12160;
- basetype = ISP_HA_SCSI_12160;
- psize = 2 * sizeof (sdparam);
- pcs->pci_poff[DMA_BLOCK >> _BLK_REG_SHFT] =
- ISP1080_DMA_REGS_OFF;
- }
-#endif
-#ifndef ISP_DISABLE_2100_SUPPORT
- if (pci_get_devid(dev) == PCI_QLOGIC_ISP2100) {
- mdvp = &mdvec_2100;
- basetype = ISP_HA_FC_2100;
- psize = sizeof (fcparam);
- pcs->pci_poff[MBOX_BLOCK >> _BLK_REG_SHFT] =
- PCI_MBOX_REGS2100_OFF;
- if (pci_get_revid(dev) < 3) {
- /*
- * XXX: Need to get the actual revision
- * XXX: number of the 2100 FB. At any rate,
- * XXX: lower cache line size for early revision
- * XXX; boards.
- */
- linesz = 1;
- }
- }
-#endif
-#ifndef ISP_DISABLE_2200_SUPPORT
- if (pci_get_devid(dev) == PCI_QLOGIC_ISP2200) {
- mdvp = &mdvec_2200;
- basetype = ISP_HA_FC_2200;
- psize = sizeof (fcparam);
- pcs->pci_poff[MBOX_BLOCK >> _BLK_REG_SHFT] =
- PCI_MBOX_REGS2100_OFF;
- }
-#endif
- isp = &pcs->pci_isp;
- isp->isp_param = malloc(psize, M_DEVBUF, M_NOWAIT);
- if (isp->isp_param == NULL) {
- device_printf(dev, "cannot allocate parameter data\n");
- goto bad;
- }
- bzero(isp->isp_param, psize);
- isp->isp_mdvec = mdvp;
- isp->isp_type = basetype;
- isp->isp_revision = pci_get_revid(dev);
- (void) snprintf(isp->isp_name, sizeof (isp->isp_name), "isp%d", unit);
- isp->isp_osinfo.unit = unit;
-
- ISP_LOCK(isp);
- /*
- * Make sure that SERR, PERR, WRITE INVALIDATE and BUSMASTER
- * are set.
- */
- cmd |= PCIM_CMD_SEREN | PCIM_CMD_PERRESPEN |
- PCIM_CMD_BUSMASTEREN | PCIM_CMD_INVEN;
- pci_write_config(dev, PCIR_COMMAND, cmd, 1);
-
- /*
- * Make sure the Cache Line Size register is set sensibly.
- */
- data = pci_read_config(dev, PCIR_CACHELNSZ, 1);
- if (data != linesz) {
- data = PCI_DFLT_LNSZ;
- CFGPRINTF("%s: set PCI line size to %d\n", isp->isp_name, data);
- pci_write_config(dev, PCIR_CACHELNSZ, data, 1);
- }
-
- /*
- * Make sure the Latency Timer is sane.
- */
- data = pci_read_config(dev, PCIR_LATTIMER, 1);
- if (data < PCI_DFLT_LTNCY) {
- data = PCI_DFLT_LTNCY;
- CFGPRINTF("%s: set PCI latency to %d\n", isp->isp_name, data);
- pci_write_config(dev, PCIR_LATTIMER, data, 1);
- }
-
- /*
- * Make sure we've disabled the ROM.
- */
- data = pci_read_config(dev, PCIR_ROMADDR, 4);
- data &= ~1;
- pci_write_config(dev, PCIR_ROMADDR, data, 4);
- ISP_UNLOCK(isp);
-
- if (bus_dma_tag_create(NULL, 1, 0, BUS_SPACE_MAXADDR_32BIT,
- BUS_SPACE_MAXADDR, NULL, NULL, lim + 1,
- 255, lim, 0, &pcs->parent_dmat) != 0) {
- printf("%s: could not create master dma tag\n", isp->isp_name);
- free(isp->isp_param, M_DEVBUF);
- free(pcs, M_DEVBUF);
- return (ENXIO);
- }
-
- iqd = 0;
- irq = bus_alloc_resource(dev, SYS_RES_IRQ, &iqd, 0, ~0,
- 1, RF_ACTIVE | RF_SHAREABLE);
- if (irq == NULL) {
- device_printf(dev, "could not allocate interrupt\n");
- goto bad;
- }
-
-#ifdef SCSI_ISP_NO_FWLOAD_MASK
- if (SCSI_ISP_NO_FWLOAD_MASK && (SCSI_ISP_NO_FWLOAD_MASK & (1 << unit)))
- isp->isp_confopts |= ISP_CFG_NORELOAD;
-#endif
- if (getenv_int("isp_no_fwload", &bitmap)) {
- if (bitmap & (1 << unit))
- isp->isp_confopts |= ISP_CFG_NORELOAD;
- }
- if (getenv_int("isp_fwload", &bitmap)) {
- if (bitmap & (1 << unit))
- isp->isp_confopts &= ~ISP_CFG_NORELOAD;
- }
-
-#ifdef SCSI_ISP_NO_NVRAM_MASK
- if (SCSI_ISP_NO_NVRAM_MASK && (SCSI_ISP_NO_NVRAM_MASK & (1 << unit))) {
- printf("%s: ignoring NVRAM\n", isp->isp_name);
- isp->isp_confopts |= ISP_CFG_NONVRAM;
- }
-#endif
- if (getenv_int("isp_no_nvram", &bitmap)) {
- if (bitmap & (1 << unit))
- isp->isp_confopts |= ISP_CFG_NONVRAM;
- }
- if (getenv_int("isp_nvram", &bitmap)) {
- if (bitmap & (1 << unit))
- isp->isp_confopts &= ~ISP_CFG_NONVRAM;
- }
-
-#ifdef SCSI_ISP_FCDUPLEX
- if (IS_FC(isp)) {
- if (SCSI_ISP_FCDUPLEX && (SCSI_ISP_FCDUPLEX & (1 << unit))) {
- isp->isp_confopts |= ISP_CFG_FULL_DUPLEX;
- }
- }
-#endif
- if (getenv_int("isp_fcduplex", &bitmap)) {
- if (bitmap & (1 << unit))
- isp->isp_confopts |= ISP_CFG_FULL_DUPLEX;
- }
- if (getenv_int("isp_no_fcduplex", &bitmap)) {
- if (bitmap & (1 << unit))
- isp->isp_confopts &= ~ISP_CFG_FULL_DUPLEX;
- }
- if (getenv_int("isp_nport", &bitmap)) {
- if (bitmap & (1 << unit))
- isp->isp_confopts |= ISP_CFG_NPORT;
- }
- /*
- * Look for overriding WWN. This is a Node WWN so it binds to
- * all FC instances. A Port WWN will be constructed from it
- * as appropriate.
- */
-#ifdef SCSI_ISP_WWN
- isp->isp_osinfo.default_wwn = strtoq(name, &vtp, 16);
- if (vtp != name && *vtp == 0) {
- isp->isp_confopts |= ISP_CFG_OWNWWN;
- } else
-#endif
- if (!getenv_quad("isp_wwn", (quad_t *) &isp->isp_osinfo.default_wwn)) {
- int i;
- u_int64_t seed = (u_int64_t) (intptr_t) isp;
-
- seed <<= 16;
- seed &= ((1LL << 48) - 1LL);
- /*
- * This isn't very random, but it's the best we can do for
- * the real edge case of cards that don't have WWNs. If
- * you recompile a new vers.c, you'll get a different WWN.
- */
- for (i = 0; version[i] != 0; i++) {
- seed += version[i];
- }
- /*
- * Make sure the top nibble has something vaguely sensible.
- */
- isp->isp_osinfo.default_wwn |= (4LL << 60) | seed;
- } else {
- isp->isp_confopts |= ISP_CFG_OWNWWN;
- }
- (void) getenv_int("isp_debug", &isp_debug);
-#ifdef ISP_TARGET_MODE
- (void) getenv_int("isp_tdebug", &isp_tdebug);
-#endif
- ISP_LOCK(isp);
- if (bus_setup_intr(dev, irq, INTR_TYPE_CAM, (void (*)(void *))isp_intr,
- isp, &pcs->ih)) {
- ISP_UNLOCK(isp);
- device_printf(dev, "could not setup interrupt\n");
- goto bad;
- }
-
- isp_reset(isp);
- if (isp->isp_state != ISP_RESETSTATE) {
- ISP_UNLOCK(isp);
- goto bad;
- }
- isp_init(isp);
- if (isp->isp_state != ISP_INITSTATE) {
- /* If we're a Fibre Channel Card, we allow deferred attach */
- if (IS_SCSI(isp)) {
- isp_uninit(isp);
- ISP_UNLOCK(isp);
- goto bad;
- }
- }
- isp_attach(isp);
- if (isp->isp_state != ISP_RUNSTATE) {
- /* If we're a Fibre Channel Card, we allow deferred attach */
- if (IS_SCSI(isp)) {
- isp_uninit(isp);
- ISP_UNLOCK(isp);
- goto bad;
- }
- }
- ISP_UNLOCK(isp);
- return (0);
-
-bad:
-
- if (pcs && pcs->ih) {
- (void) bus_teardown_intr(dev, irq, pcs->ih);
- }
-
- if (irq) {
- (void) bus_release_resource(dev, SYS_RES_IRQ, iqd, irq);
- }
- if (regs) {
- (void) bus_release_resource(dev, rtp, rgd, regs);
- }
- if (pcs) {
- if (pcs->pci_isp.isp_param)
- free(pcs->pci_isp.isp_param, M_DEVBUF);
- free(pcs, M_DEVBUF);
- }
- return (ENXIO);
-}
-
-static u_int16_t
-isp_pci_rd_reg(isp, regoff)
- struct ispsoftc *isp;
- int regoff;
-{
- u_int16_t rv;
- struct isp_pcisoftc *pcs = (struct isp_pcisoftc *) isp;
- int offset, oldconf = 0;
-
- if ((regoff & _BLK_REG_MASK) == SXP_BLOCK) {
- /*
- * We will assume that someone has paused the RISC processor.
- */
- oldconf = isp_pci_rd_reg(isp, BIU_CONF1);
- isp_pci_wr_reg(isp, BIU_CONF1, oldconf | BIU_PCI_CONF1_SXP);
- }
- offset = pcs->pci_poff[(regoff & _BLK_REG_MASK) >> _BLK_REG_SHFT];
- offset += (regoff & 0xff);
- rv = bus_space_read_2(pcs->pci_st, pcs->pci_sh, offset);
- if ((regoff & _BLK_REG_MASK) == SXP_BLOCK) {
- isp_pci_wr_reg(isp, BIU_CONF1, oldconf);
- }
- return (rv);
-}
-
-static void
-isp_pci_wr_reg(isp, regoff, val)
- struct ispsoftc *isp;
- int regoff;
- u_int16_t val;
-{
- struct isp_pcisoftc *pcs = (struct isp_pcisoftc *) isp;
- int offset, oldconf = 0;
-
- if ((regoff & _BLK_REG_MASK) == SXP_BLOCK) {
- /*
- * We will assume that someone has paused the RISC processor.
- */
- oldconf = isp_pci_rd_reg(isp, BIU_CONF1);
- isp_pci_wr_reg(isp, BIU_CONF1, oldconf | BIU_PCI_CONF1_SXP);
- }
- offset = pcs->pci_poff[(regoff & _BLK_REG_MASK) >> _BLK_REG_SHFT];
- offset += (regoff & 0xff);
- bus_space_write_2(pcs->pci_st, pcs->pci_sh, offset, val);
- if ((regoff & _BLK_REG_MASK) == SXP_BLOCK) {
- isp_pci_wr_reg(isp, BIU_CONF1, oldconf);
- }
-}
-
-#if !defined(ISP_DISABLE_1080_SUPPORT) || !defined(ISP_DISABLE_12160_SUPPORT)
-static u_int16_t
-isp_pci_rd_reg_1080(isp, regoff)
- struct ispsoftc *isp;
- int regoff;
-{
- u_int16_t rv, oc = 0;
- struct isp_pcisoftc *pcs = (struct isp_pcisoftc *) isp;
- int offset;
-
- if ((regoff & _BLK_REG_MASK) == SXP_BLOCK ||
- (regoff & _BLK_REG_MASK) == (SXP_BLOCK|SXP_BANK1_SELECT)) {
- u_int16_t tc;
- /*
- * We will assume that someone has paused the RISC processor.
- */
- oc = isp_pci_rd_reg(isp, BIU_CONF1);
- tc = oc & ~BIU_PCI1080_CONF1_DMA;
- if (regoff & SXP_BANK1_SELECT)
- tc |= BIU_PCI1080_CONF1_SXP1;
- else
- tc |= BIU_PCI1080_CONF1_SXP0;
- isp_pci_wr_reg(isp, BIU_CONF1, tc);
- } else if ((regoff & _BLK_REG_MASK) == DMA_BLOCK) {
- oc = isp_pci_rd_reg(isp, BIU_CONF1);
- isp_pci_wr_reg(isp, BIU_CONF1, oc | BIU_PCI1080_CONF1_DMA);
- }
- offset = pcs->pci_poff[(regoff & _BLK_REG_MASK) >> _BLK_REG_SHFT];
- offset += (regoff & 0xff);
- rv = bus_space_read_2(pcs->pci_st, pcs->pci_sh, offset);
- if (oc) {
- isp_pci_wr_reg(isp, BIU_CONF1, oc);
- }
- return (rv);
-}
-
-static void
-isp_pci_wr_reg_1080(isp, regoff, val)
- struct ispsoftc *isp;
- int regoff;
- u_int16_t val;
-{
- struct isp_pcisoftc *pcs = (struct isp_pcisoftc *) isp;
- int offset, oc = 0;
-
- if ((regoff & _BLK_REG_MASK) == SXP_BLOCK ||
- (regoff & _BLK_REG_MASK) == (SXP_BLOCK|SXP_BANK1_SELECT)) {
- u_int16_t tc;
- /*
- * We will assume that someone has paused the RISC processor.
- */
- oc = isp_pci_rd_reg(isp, BIU_CONF1);
- tc = oc & ~BIU_PCI1080_CONF1_DMA;
- if (regoff & SXP_BANK1_SELECT)
- tc |= BIU_PCI1080_CONF1_SXP1;
- else
- tc |= BIU_PCI1080_CONF1_SXP0;
- isp_pci_wr_reg(isp, BIU_CONF1, tc);
- } else if ((regoff & _BLK_REG_MASK) == DMA_BLOCK) {
- oc = isp_pci_rd_reg(isp, BIU_CONF1);
- isp_pci_wr_reg(isp, BIU_CONF1, oc | BIU_PCI1080_CONF1_DMA);
- }
- offset = pcs->pci_poff[(regoff & _BLK_REG_MASK) >> _BLK_REG_SHFT];
- offset += (regoff & 0xff);
- bus_space_write_2(pcs->pci_st, pcs->pci_sh, offset, val);
- if (oc) {
- isp_pci_wr_reg(isp, BIU_CONF1, oc);
- }
-}
-#endif
-
-
-static void isp_map_rquest __P((void *, bus_dma_segment_t *, int, int));
-static void isp_map_result __P((void *, bus_dma_segment_t *, int, int));
-static void isp_map_fcscrt __P((void *, bus_dma_segment_t *, int, int));
-
-struct imush {
- struct ispsoftc *isp;
- int error;
-};
-
-static void
-isp_map_rquest(void *arg, bus_dma_segment_t *segs, int nseg, int error)
-{
- struct imush *imushp = (struct imush *) arg;
- if (error) {
- imushp->error = error;
- } else {
- imushp->isp->isp_rquest_dma = segs->ds_addr;
- }
-}
-
-static void
-isp_map_result(void *arg, bus_dma_segment_t *segs, int nseg, int error)
-{
- struct imush *imushp = (struct imush *) arg;
- if (error) {
- imushp->error = error;
- } else {
- imushp->isp->isp_result_dma = segs->ds_addr;
- }
-}
-
-static void
-isp_map_fcscrt(void *arg, bus_dma_segment_t *segs, int nseg, int error)
-{
- struct imush *imushp = (struct imush *) arg;
- if (error) {
- imushp->error = error;
- } else {
- fcparam *fcp = imushp->isp->isp_param;
- fcp->isp_scdma = segs->ds_addr;
- }
-}
-
-static int
-isp_pci_mbxdma(struct ispsoftc *isp)
-{
- struct isp_pcisoftc *pci = (struct isp_pcisoftc *)isp;
- caddr_t base;
- u_int32_t len;
- int i, error;
- bus_size_t lim;
- struct imush im;
-
-
- /*
- * Already been here? If so, leave...
- */
- if (isp->isp_rquest) {
- return (0);
- }
-
- len = sizeof (ISP_SCSI_XFER_T **) * isp->isp_maxcmds;
- isp->isp_xflist = (ISP_SCSI_XFER_T **) malloc(len, M_DEVBUF, M_WAITOK);
- if (isp->isp_xflist == NULL) {
- printf("%s: can't alloc xflist array\n", isp->isp_name);
- return (1);
- }
- bzero(isp->isp_xflist, len);
- len = sizeof (bus_dmamap_t) * isp->isp_maxcmds;
- pci->dmaps = (bus_dmamap_t *) malloc(len, M_DEVBUF, M_WAITOK);
- if (pci->dmaps == NULL) {
- printf("%s: can't alloc dma maps\n", isp->isp_name);
- free(isp->isp_xflist, M_DEVBUF);
- return (1);
- }
-
- if (IS_FC(isp) || IS_ULTRA2(isp))
- lim = BUS_SPACE_MAXADDR + 1;
- else
- lim = BUS_SPACE_MAXADDR_24BIT + 1;
-
- /*
- * Allocate and map the request, result queues, plus FC scratch area.
- */
- len = ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN);
- len += ISP_QUEUE_SIZE(RESULT_QUEUE_LEN);
- if (IS_FC(isp)) {
- len += ISP2100_SCRLEN;
- }
- if (bus_dma_tag_create(pci->parent_dmat, PAGE_SIZE, lim,
- BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, len, 1,
- BUS_SPACE_MAXSIZE_32BIT, 0, &pci->cntrol_dmat) != 0) {
- printf("%s: cannot create a dma tag for control spaces\n",
- isp->isp_name);
- free(isp->isp_xflist, M_DEVBUF);
- free(pci->dmaps, M_DEVBUF);
- return (1);
- }
- if (bus_dmamem_alloc(pci->cntrol_dmat, (void **)&base,
- BUS_DMA_NOWAIT, &pci->cntrol_dmap) != 0) {
- printf("%s: cannot allocate %d bytes of CCB memory\n",
- isp->isp_name, len);
- free(isp->isp_xflist, M_DEVBUF);
- free(pci->dmaps, M_DEVBUF);
- return (1);
- }
-
- isp->isp_rquest = base;
- im.isp = isp;
- im.error = 0;
- bus_dmamap_load(pci->cntrol_dmat, pci->cntrol_dmap, isp->isp_rquest,
- ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN), isp_map_rquest, &im, 0);
- if (im.error) {
- printf("%s: error %d loading dma map for DMA request queue\n",
- isp->isp_name, im.error);
- free(isp->isp_xflist, M_DEVBUF);
- free(pci->dmaps, M_DEVBUF);
- isp->isp_rquest = NULL;
- return (1);
- }
- isp->isp_result = base + ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN);
- im.error = 0;
- bus_dmamap_load(pci->cntrol_dmat, pci->cntrol_dmap, isp->isp_result,
- ISP_QUEUE_SIZE(RESULT_QUEUE_LEN), isp_map_result, &im, 0);
- if (im.error) {
- printf("%s: error %d loading dma map for DMA result queue\n",
- isp->isp_name, im.error);
- free(isp->isp_xflist, M_DEVBUF);
- free(pci->dmaps, M_DEVBUF);
- isp->isp_rquest = NULL;
- return (1);
- }
-
- for (i = 0; i < isp->isp_maxcmds; i++) {
- error = bus_dmamap_create(pci->parent_dmat, 0, &pci->dmaps[i]);
- if (error) {
- printf("%s: error %d creating per-cmd DMA maps\n",
- isp->isp_name, error);
- free(isp->isp_xflist, M_DEVBUF);
- free(pci->dmaps, M_DEVBUF);
- isp->isp_rquest = NULL;
- return (1);
- }
- }
-
- if (IS_FC(isp)) {
- fcparam *fcp = (fcparam *) isp->isp_param;
- fcp->isp_scratch = base +
- ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN) +
- ISP_QUEUE_SIZE(RESULT_QUEUE_LEN);
- im.error = 0;
- bus_dmamap_load(pci->cntrol_dmat, pci->cntrol_dmap,
- fcp->isp_scratch, ISP2100_SCRLEN, isp_map_fcscrt, &im, 0);
- if (im.error) {
- printf("%s: error %d loading FC scratch area\n",
- isp->isp_name, im.error);
- free(isp->isp_xflist, M_DEVBUF);
- free(pci->dmaps, M_DEVBUF);
- isp->isp_rquest = NULL;
- return (1);
- }
- }
- return (0);
-}
-
-typedef struct {
- struct ispsoftc *isp;
- void *cmd_token;
- void *rq;
- u_int16_t *iptrp;
- u_int16_t optr;
- u_int error;
-} mush_t;
-
-#define MUSHERR_NOQENTRIES -2
-
-#ifdef ISP_TARGET_MODE
-/*
- * We need to handle DMA for target mode differently from initiator mode.
- *
- * DMA mapping and construction and submission of CTIO Request Entries
- * and rendevous for completion are very tightly coupled because we start
- * out by knowing (per platform) how much data we have to move, but we
- * don't know, up front, how many DMA mapping segments will have to be used
- * cover that data, so we don't know how many CTIO Request Entries we
- * will end up using. Further, for performance reasons we may want to
- * (on the last CTIO for Fibre Channel), send status too (if all went well).
- *
- * The standard vector still goes through isp_pci_dmasetup, but the callback
- * for the DMA mapping routines comes here instead with the whole transfer
- * mapped and a pointer to a partially filled in already allocated request
- * queue entry. We finish the job.
- */
-static void dma2_tgt __P((void *, bus_dma_segment_t *, int, int));
-static void dma2_tgt_fc __P((void *, bus_dma_segment_t *, int, int));
-
-static void
-dma2_tgt(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error)
-{
- mush_t *mp;
- struct ccb_scsiio *csio;
- struct isp_pcisoftc *pci;
- bus_dmamap_t *dp;
- u_int8_t scsi_status, send_status;
- ct_entry_t *cto;
- u_int32_t handle;
- int nctios;
-
- mp = (mush_t *) arg;
- if (error) {
- mp->error = error;
- return;
- }
-
- csio = mp->cmd_token;
- cto = mp->rq;
-
- cto->ct_xfrlen = 0;
- cto->ct_resid = 0;
- cto->ct_seg_count = 0;
- bzero(cto->ct_dataseg, sizeof (cto->ct_dataseg));
- if (nseg == 0) {
- cto->ct_header.rqs_entry_count = 1;
- ISP_TDQE(mp->isp, "dma2_tgt[no data]", *mp->iptrp, cto);
- if (isp_tdebug) {
- printf("%s:CTIO lun %d->iid%d flgs 0x%x sts 0x%x ssts "
- "0x%x res %u\n", mp->isp->isp_name,
- csio->ccb_h.target_lun, cto->ct_iid, cto->ct_flags,
- cto->ct_status, cto->ct_scsi_status, cto->ct_resid);
- }
- ISP_SWIZ_CTIO(isp, cto, cto);
- return;
- }
-
- /*
- * Save handle, and potentially any SCSI status, which
- * we'll reinsert on the last CTIO we're going to send.
- */
- handle = cto->ct_reserved;
- cto->ct_reserved = 0;
- scsi_status = cto->ct_scsi_status;
- cto->ct_scsi_status = 0;
- send_status = cto->ct_flags & CT_SENDSTATUS;
- cto->ct_flags &= ~CT_SENDSTATUS;
-
- nctios = nseg / ISP_RQDSEG;
- if (nseg % ISP_RQDSEG) {
- nctios++;
- }
-
- pci = (struct isp_pcisoftc *)mp->isp;
- dp = &pci->dmaps[handle - 1];
- if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
- bus_dmamap_sync(pci->parent_dmat, *dp, BUS_DMASYNC_PREREAD);
- } else {
- bus_dmamap_sync(pci->parent_dmat, *dp, BUS_DMASYNC_PREWRITE);
- }
-
-
- while (nctios--) {
- int seg, seglim;
-
- seglim = nseg;
- if (seglim > ISP_RQDSEG)
- seglim = ISP_RQDSEG;
-
- for (seg = 0; seg < seglim; seg++) {
- cto->ct_dataseg[seg].ds_base = dm_segs->ds_addr;
- cto->ct_dataseg[seg].ds_count = dm_segs->ds_len;
- cto->ct_xfrlen += dm_segs->ds_len;
- dm_segs++;
- }
-
- cto->ct_seg_count = seg;
- cto->ct_flags &= CT_DATAMASK;
- if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
- cto->ct_flags |= CT_DATA_IN;
- } else {
- cto->ct_flags |= CT_DATA_OUT;
- }
-
- if (nctios == 0) {
- /*
- * We're the last in a sequence of CTIOs, so mark this
- * CTIO and save the handle to the CCB such that when
- * this CTIO completes we can free dma resources and
- * do whatever else we need to do to finish the rest
- * of the command.
- */
- cto->ct_header.rqs_seqno = 1;
- cto->ct_reserved = handle;
- cto->ct_scsi_status = scsi_status;
- cto->ct_flags |= send_status;
- ISP_TDQE(mp->isp, "last dma2_tgt", *mp->iptrp, cto);
- if (isp_tdebug) {
- printf("%s:CTIO lun %d->iid%d flgs 0x%x sts "
- "0x%x ssts 0x%x res %u\n",
- mp->isp->isp_name, csio->ccb_h.target_lun,
- cto->ct_iid, cto->ct_flags, cto->ct_status,
- cto->ct_scsi_status, cto->ct_resid);
- }
- ISP_SWIZ_CTIO(isp, cto, cto);
- } else {
- ct_entry_t *octo = cto;
- cto->ct_reserved = 0;
- cto->ct_header.rqs_seqno = 0;
- ISP_TDQE(mp->isp, "dma2_tgt", *mp->iptrp, cto);
- if (isp_tdebug) {
- printf("%s:CTIO lun %d->iid%d flgs 0x%x res"
- " %u\n", mp->isp->isp_name,
- csio->ccb_h.target_lun, cto->ct_iid,
- cto->ct_flags, cto->ct_resid);
- }
- cto = (ct_entry_t *)
- ISP_QUEUE_ENTRY(mp->isp->isp_rquest, *mp->iptrp);
- *mp->iptrp =
- ISP_NXT_QENTRY(*mp->iptrp, RQUEST_QUEUE_LEN);
- if (*mp->iptrp == mp->optr) {
- printf("%s: Queue Overflow in dma2_tgt\n",
- mp->isp->isp_name);
- mp->error = MUSHERR_NOQENTRIES;
- return;
- }
- /*
- * Fill in the new CTIO with info from the old one.
- */
- cto->ct_header.rqs_entry_type = RQSTYPE_CTIO;
- cto->ct_header.rqs_entry_count = 1;
- cto->ct_header.rqs_flags = 0;
- /* ct_header.rqs_seqno && ct_reserved filled in later */
- cto->ct_lun = octo->ct_lun;
- cto->ct_iid = octo->ct_iid;
- cto->ct_reserved2 = octo->ct_reserved2;
- cto->ct_tgt = octo->ct_tgt;
- cto->ct_flags = octo->ct_flags & ~CT_DATAMASK;
- cto->ct_status = 0;
- cto->ct_scsi_status = 0;
- cto->ct_tag_val = octo->ct_tag_val;
- cto->ct_tag_type = octo->ct_tag_type;
- cto->ct_xfrlen = 0;
- cto->ct_resid = 0;
- cto->ct_timeout = octo->ct_timeout;
- cto->ct_seg_count = 0;
- bzero(cto->ct_dataseg, sizeof (cto->ct_dataseg));
- ISP_SWIZ_CTIO(isp, octo, octo);
- }
- }
-}
-
-static void
-dma2_tgt_fc(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error)
-{
- mush_t *mp;
- struct ccb_scsiio *csio;
- struct isp_pcisoftc *pci;
- bus_dmamap_t *dp;
- ct2_entry_t *cto;
- u_int16_t scsi_status, send_status, send_sense;
- u_int32_t handle, totxfr;
- u_int8_t sense[QLTM_SENSELEN];
- int nctios;
- int32_t resid;
-
- mp = (mush_t *) arg;
- if (error) {
- mp->error = error;
- return;
- }
-
- csio = mp->cmd_token;
- cto = mp->rq;
-
- if (nseg == 0) {
- if ((cto->ct_flags & CT2_FLAG_MMASK) != CT2_FLAG_MODE1) {
- printf("%s: dma2_tgt_fc, a status CTIO2 without MODE1 "
- "set (0x%x)\n", mp->isp->isp_name, cto->ct_flags);
- mp->error = EINVAL;
- return;
- }
- cto->ct_header.rqs_entry_count = 1;
- /* ct_reserved contains the handle set by caller */
- /*
- * We preserve ct_lun, ct_iid, ct_rxid. We set the data
- * flags to NO DATA and clear relative offset flags.
- * We preserve the ct_resid and the response area.
- */
- cto->ct_flags |= CT2_NO_DATA;
- cto->ct_seg_count = 0;
- cto->ct_reloff = 0;
- ISP_TDQE(mp->isp, "dma2_tgt_fc[no data]", *mp->iptrp, cto);
- if (isp_tdebug) {
- scsi_status = cto->rsp.m1.ct_scsi_status;
- printf("%s:CTIO2 RX_ID 0x%x lun %d->iid%d flgs 0x%x "
- "sts 0x%x ssts 0x%x res %u\n", mp->isp->isp_name,
- cto->ct_rxid, csio->ccb_h.target_lun, cto->ct_iid,
- cto->ct_flags, cto->ct_status,
- cto->rsp.m1.ct_scsi_status, cto->ct_resid);
- }
- ISP_SWIZ_CTIO2(isp, cto, cto);
- return;
- }
-
- if ((cto->ct_flags & CT2_FLAG_MMASK) != CT2_FLAG_MODE0) {
- printf("%s: dma2_tgt_fc, a data CTIO2 without MODE0 set "
- "(0x%x)\n\n", mp->isp->isp_name, cto->ct_flags);
- mp->error = EINVAL;
- return;
- }
-
-
- nctios = nseg / ISP_RQDSEG_T2;
- if (nseg % ISP_RQDSEG_T2) {
- nctios++;
- }
-
- /*
- * Save the handle, status, reloff, and residual. We'll reinsert the
- * handle into the last CTIO2 we're going to send, and reinsert status
- * and residual (and possibly sense data) if that's to be sent as well.
- *
- * We preserve ct_reloff and adjust it for each data CTIO2 we send past
- * the first one. This is needed so that the FCP DATA IUs being sent
- * out have the correct offset (they can arrive at the other end out
- * of order).
- */
-
- handle = cto->ct_reserved;
- cto->ct_reserved = 0;
-
- if ((send_status = (cto->ct_flags & CT2_SENDSTATUS)) != 0) {
- cto->ct_flags &= ~CT2_SENDSTATUS;
-
- /*
- * Preserve residual.
- */
- resid = cto->ct_resid;
-
- /*
- * Save actual SCSI status. We'll reinsert the
- * CT2_SNSLEN_VALID later if appropriate.
- */
- scsi_status = cto->rsp.m0.ct_scsi_status & 0xff;
- send_sense = cto->rsp.m0.ct_scsi_status & CT2_SNSLEN_VALID;
-
- /*
- * If we're sending status and have a CHECK CONDTION and
- * have sense data, we send one more CTIO2 with just the
- * status and sense data. The upper layers have stashed
- * the sense data in the dataseg structure for us.
- */
-
- if ((scsi_status & 0xf) == SCSI_STATUS_CHECK_COND &&
- send_sense) {
- bcopy(cto->rsp.m0.ct_dataseg, sense, QLTM_SENSELEN);
- nctios++;
- }
- } else {
- scsi_status = send_sense = resid = 0;
- }
-
- totxfr = cto->ct_resid = 0;
- cto->rsp.m0.ct_scsi_status = 0;
- bzero(&cto->rsp, sizeof (cto->rsp));
-
- pci = (struct isp_pcisoftc *)mp->isp;
- dp = &pci->dmaps[handle - 1];
- if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
- bus_dmamap_sync(pci->parent_dmat, *dp, BUS_DMASYNC_PREREAD);
- } else {
- bus_dmamap_sync(pci->parent_dmat, *dp, BUS_DMASYNC_PREWRITE);
- }
-
- while (nctios--) {
- int seg, seglim;
-
- seglim = nseg;
- if (seglim) {
- if (seglim > ISP_RQDSEG_T2)
- seglim = ISP_RQDSEG_T2;
-
- for (seg = 0; seg < seglim; seg++) {
- cto->rsp.m0.ct_dataseg[seg].ds_base =
- dm_segs->ds_addr;
- cto->rsp.m0.ct_dataseg[seg].ds_count =
- dm_segs->ds_len;
- cto->rsp.m0.ct_xfrlen += dm_segs->ds_len;
- totxfr += dm_segs->ds_len;
- dm_segs++;
- }
- cto->ct_seg_count = seg;
- } else {
- /*
- * This case should only happen when we're sending a
- * synthesized MODE1 final status with sense data.
- */
- if (send_sense == 0) {
- printf("%s: dma2_tgt_fc ran out of segments, "
- "no SENSE DATA\n", mp->isp->isp_name);
- mp->error = EINVAL;
- return;
- }
- }
-
- /*
- * At this point, the fields ct_lun, ct_iid, ct_rxid,
- * ct_timeout have been carried over unchanged from what
- * our caller had set.
- *
- * The field ct_reloff is either what the caller set, or
- * what we've added to below.
- *
- * The dataseg fields and the seg_count fields we just got
- * through setting. The data direction we've preserved all
- * along and only clear it if we're sending a MODE1 status
- * as the last CTIO.
- *
- */
-
- if (nctios == 0) {
-
- /*
- * We're the last in a sequence of CTIO2s, so mark this
- * CTIO2 and save the handle to the CCB such that when
- * this CTIO2 completes we can free dma resources and
- * do whatever else we need to do to finish the rest
- * of the command.
- */
-
- cto->ct_reserved = handle;
- cto->ct_header.rqs_seqno = 1;
-
- if (send_status) {
- if (send_sense) {
- bcopy(sense, cto->rsp.m1.ct_resp,
- QLTM_SENSELEN);
- cto->rsp.m1.ct_senselen =
- QLTM_SENSELEN;
- scsi_status |= CT2_SNSLEN_VALID;
- cto->rsp.m1.ct_scsi_status =
- scsi_status;
- cto->ct_flags &= CT2_FLAG_MMASK;
- cto->ct_flags |= CT2_FLAG_MODE1 |
- CT2_NO_DATA| CT2_SENDSTATUS;
- } else {
- cto->rsp.m0.ct_scsi_status =
- scsi_status;
- cto->ct_flags |= CT2_SENDSTATUS;
- }
- cto->ct_resid = resid - totxfr;
- }
- ISP_TDQE(mp->isp, "last dma2_tgt_fc", *mp->iptrp, cto);
- if (isp_tdebug) {
- printf("%s:CTIO2 RX_ID 0x%x lun %d->iid%d flgs"
- "0x%x sts 0x%x ssts 0x%x res %u\n",
- mp->isp->isp_name, cto->ct_rxid,
- csio->ccb_h.target_lun, (int) cto->ct_iid,
- cto->ct_flags, cto->ct_status,
- cto->rsp.m1.ct_scsi_status, cto->ct_resid);
- }
- ISP_SWIZ_CTIO2(isp, cto, cto);
- } else {
- ct2_entry_t *octo = cto;
-
- /*
- * Make sure handle fields are clean
- */
- cto->ct_reserved = 0;
- cto->ct_header.rqs_seqno = 0;
-
- ISP_TDQE(mp->isp, "dma2_tgt_fc", *mp->iptrp, cto);
- if (isp_tdebug) {
- printf("%s:CTIO2 RX_ID 0x%x lun %d->iid%d flgs"
- "0x%x\n", mp->isp->isp_name, cto->ct_rxid,
- csio->ccb_h.target_lun, (int) cto->ct_iid,
- cto->ct_flags);
- }
- /*
- * Get a new CTIO2
- */
- cto = (ct2_entry_t *)
- ISP_QUEUE_ENTRY(mp->isp->isp_rquest, *mp->iptrp);
- *mp->iptrp =
- ISP_NXT_QENTRY(*mp->iptrp, RQUEST_QUEUE_LEN);
- if (*mp->iptrp == mp->optr) {
- printf("%s: Queue Overflow in dma2_tgt_fc\n",
- mp->isp->isp_name);
- mp->error = MUSHERR_NOQENTRIES;
- return;
- }
-
- /*
- * Fill in the new CTIO2 with info from the old one.
- */
- cto->ct_header.rqs_entry_type = RQSTYPE_CTIO2;
- cto->ct_header.rqs_entry_count = 1;
- cto->ct_header.rqs_flags = 0;
- /* ct_header.rqs_seqno && ct_reserved done later */
- cto->ct_lun = octo->ct_lun;
- cto->ct_iid = octo->ct_iid;
- cto->ct_rxid = octo->ct_rxid;
- cto->ct_flags = octo->ct_flags;
- cto->ct_status = 0;
- cto->ct_resid = 0;
- cto->ct_timeout = octo->ct_timeout;
- cto->ct_seg_count = 0;
- /*
- * Adjust the new relative offset by the amount which
- * is recorded in the data segment of the old CTIO2 we
- * just finished filling out.
- */
- cto->ct_reloff += octo->rsp.m0.ct_xfrlen;
- bzero(&cto->rsp, sizeof (cto->rsp));
- ISP_SWIZ_CTIO2(isp, cto, cto);
- }
- }
-}
-#endif
-
-static void dma2 __P((void *, bus_dma_segment_t *, int, int));
-
-static void
-dma2(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error)
-{
- mush_t *mp;
- struct ccb_scsiio *csio;
- struct isp_pcisoftc *pci;
- bus_dmamap_t *dp;
- bus_dma_segment_t *eseg;
- ispreq_t *rq;
- ispcontreq_t *crq;
- int seglim, datalen;
-
- mp = (mush_t *) arg;
- if (error) {
- mp->error = error;
- return;
- }
-
- if (nseg < 1) {
- printf("%s: bad segment count (%d)\n", mp->isp->isp_name, nseg);
- mp->error = EFAULT;
- return;
- }
- csio = mp->cmd_token;
- rq = mp->rq;
- pci = (struct isp_pcisoftc *)mp->isp;
- dp = &pci->dmaps[rq->req_handle - 1];
-
- if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
- bus_dmamap_sync(pci->parent_dmat, *dp, BUS_DMASYNC_PREREAD);
- } else {
- bus_dmamap_sync(pci->parent_dmat, *dp, BUS_DMASYNC_PREWRITE);
- }
-
- datalen = XS_XFRLEN(csio);
-
- /*
- * We're passed an initial partially filled in entry that
- * has most fields filled in except for data transfer
- * related values.
- *
- * Our job is to fill in the initial request queue entry and
- * then to start allocating and filling in continuation entries
- * until we've covered the entire transfer.
- */
-
- if (IS_FC(mp->isp)) {
- seglim = ISP_RQDSEG_T2;
- ((ispreqt2_t *)rq)->req_totalcnt = datalen;
- if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
- ((ispreqt2_t *)rq)->req_flags |= REQFLAG_DATA_IN;
- } else {
- ((ispreqt2_t *)rq)->req_flags |= REQFLAG_DATA_OUT;
- }
- } else {
- if (csio->cdb_len > 12) {
- seglim = 0;
- } else {
- seglim = ISP_RQDSEG;
- }
- if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
- rq->req_flags |= REQFLAG_DATA_IN;
- } else {
- rq->req_flags |= REQFLAG_DATA_OUT;
- }
- }
-
- eseg = dm_segs + nseg;
-
- while (datalen != 0 && rq->req_seg_count < seglim && dm_segs != eseg) {
- if (IS_FC(mp->isp)) {
- ispreqt2_t *rq2 = (ispreqt2_t *)rq;
- rq2->req_dataseg[rq2->req_seg_count].ds_base =
- dm_segs->ds_addr;
- rq2->req_dataseg[rq2->req_seg_count].ds_count =
- dm_segs->ds_len;
- } else {
- rq->req_dataseg[rq->req_seg_count].ds_base =
- dm_segs->ds_addr;
- rq->req_dataseg[rq->req_seg_count].ds_count =
- dm_segs->ds_len;
- }
- datalen -= dm_segs->ds_len;
-#if 0
- if (IS_FC(mp->isp)) {
- ispreqt2_t *rq2 = (ispreqt2_t *)rq;
- printf("%s: seg0[%d] cnt 0x%x paddr 0x%08x\n",
- mp->isp->isp_name, rq->req_seg_count,
- rq2->req_dataseg[rq2->req_seg_count].ds_count,
- rq2->req_dataseg[rq2->req_seg_count].ds_base);
- } else {
- printf("%s: seg0[%d] cnt 0x%x paddr 0x%08x\n",
- mp->isp->isp_name, rq->req_seg_count,
- rq->req_dataseg[rq->req_seg_count].ds_count,
- rq->req_dataseg[rq->req_seg_count].ds_base);
- }
-#endif
- rq->req_seg_count++;
- dm_segs++;
- }
-
- while (datalen > 0 && dm_segs != eseg) {
- crq = (ispcontreq_t *)
- ISP_QUEUE_ENTRY(mp->isp->isp_rquest, *mp->iptrp);
- *mp->iptrp = ISP_NXT_QENTRY(*mp->iptrp, RQUEST_QUEUE_LEN);
- if (*mp->iptrp == mp->optr) {
-#if 0
- printf("%s: Request Queue Overflow++\n",
- mp->isp->isp_name);
-#endif
- mp->error = MUSHERR_NOQENTRIES;
- return;
- }
- rq->req_header.rqs_entry_count++;
- bzero((void *)crq, sizeof (*crq));
- crq->req_header.rqs_entry_count = 1;
- crq->req_header.rqs_entry_type = RQSTYPE_DATASEG;
-
- seglim = 0;
- while (datalen > 0 && seglim < ISP_CDSEG && dm_segs != eseg) {
- crq->req_dataseg[seglim].ds_base =
- dm_segs->ds_addr;
- crq->req_dataseg[seglim].ds_count =
- dm_segs->ds_len;
-#if 0
- printf("%s: seg%d[%d] cnt 0x%x paddr 0x%08x\n",
- mp->isp->isp_name, rq->req_header.rqs_entry_count-1,
- seglim, crq->req_dataseg[seglim].ds_count,
- crq->req_dataseg[seglim].ds_base);
-#endif
- rq->req_seg_count++;
- dm_segs++;
- seglim++;
- datalen -= dm_segs->ds_len;
- }
- }
-}
-
-static int
-isp_pci_dmasetup(struct ispsoftc *isp, struct ccb_scsiio *csio, ispreq_t *rq,
- u_int16_t *iptrp, u_int16_t optr)
-{
- struct isp_pcisoftc *pci = (struct isp_pcisoftc *)isp;
- bus_dmamap_t *dp = NULL;
- mush_t mush, *mp;
- void (*eptr) __P((void *, bus_dma_segment_t *, int, int));
-
-#ifdef ISP_TARGET_MODE
- if (csio->ccb_h.func_code == XPT_CONT_TARGET_IO) {
- if (IS_FC(isp)) {
- eptr = dma2_tgt_fc;
- } else {
- eptr = dma2_tgt;
- }
- if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_NONE) {
- rq->req_seg_count = 1;
- mp = &mush;
- mp->isp = isp;
- mp->cmd_token = csio;
- mp->rq = rq;
- mp->iptrp = iptrp;
- mp->optr = optr;
- mp->error = 0;
- (*eptr)(mp, NULL, 0, 0);
- goto exit;
- }
- } else
-#endif
- eptr = dma2;
-
- /*
- * NB: if we need to do request queue entry swizzling,
- * NB: this is where it would need to be done for cmds
- * NB: that move no data. For commands that move data,
- * NB: swizzling would take place in those functions.
- */
- if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_NONE) {
- rq->req_seg_count = 1;
- return (CMD_QUEUED);
- }
-
- /*
- * Do a virtual grapevine step to collect info for
- * the callback dma allocation that we have to use...
- */
- mp = &mush;
- mp->isp = isp;
- mp->cmd_token = csio;
- mp->rq = rq;
- mp->iptrp = iptrp;
- mp->optr = optr;
- mp->error = 0;
-
- if ((csio->ccb_h.flags & CAM_SCATTER_VALID) == 0) {
- if ((csio->ccb_h.flags & CAM_DATA_PHYS) == 0) {
- int error, s;
- dp = &pci->dmaps[rq->req_handle - 1];
- s = splsoftvm();
- error = bus_dmamap_load(pci->parent_dmat, *dp,
- csio->data_ptr, csio->dxfer_len, eptr, mp, 0);
- if (error == EINPROGRESS) {
- bus_dmamap_unload(pci->parent_dmat, *dp);
- mp->error = EINVAL;
- printf("%s: deferred dma allocation not "
- "supported\n", isp->isp_name);
- } else if (error && mp->error == 0) {
-#ifdef DIAGNOSTIC
- printf("%s: error %d in dma mapping code\n",
- isp->isp_name, error);
-#endif
- mp->error = error;
- }
- splx(s);
- } else {
- /* Pointer to physical buffer */
- struct bus_dma_segment seg;
- seg.ds_addr = (bus_addr_t)csio->data_ptr;
- seg.ds_len = csio->dxfer_len;
- (*eptr)(mp, &seg, 1, 0);
- }
- } else {
- struct bus_dma_segment *segs;
-
- if ((csio->ccb_h.flags & CAM_DATA_PHYS) != 0) {
- printf("%s: Physical segment pointers unsupported",
- isp->isp_name);
- mp->error = EINVAL;
- } else if ((csio->ccb_h.flags & CAM_SG_LIST_PHYS) == 0) {
- printf("%s: Virtual segment addresses unsupported",
- isp->isp_name);
- mp->error = EINVAL;
- } else {
- /* Just use the segments provided */
- segs = (struct bus_dma_segment *) csio->data_ptr;
- (*eptr)(mp, segs, csio->sglist_cnt, 0);
- }
- }
-#ifdef ISP_TARGET_MODE
-exit:
-#endif
- if (mp->error) {
- int retval = CMD_COMPLETE;
- if (mp->error == MUSHERR_NOQENTRIES) {
- retval = CMD_EAGAIN;
- } else if (mp->error == EFBIG) {
- XS_SETERR(csio, CAM_REQ_TOO_BIG);
- } else if (mp->error == EINVAL) {
- XS_SETERR(csio, CAM_REQ_INVALID);
- } else {
- XS_SETERR(csio, CAM_UNREC_HBA_ERROR);
- }
- return (retval);
- } else {
- /*
- * Check to see if we weren't cancelled while sleeping on
- * getting DMA resources...
- */
- if ((csio->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_INPROG) {
- if (dp) {
- bus_dmamap_unload(pci->parent_dmat, *dp);
- }
- return (CMD_COMPLETE);
- }
- return (CMD_QUEUED);
- }
-}
-
-static void
-isp_pci_dmateardown(struct ispsoftc *isp, ISP_SCSI_XFER_T *xs, u_int32_t handle)
-{
- struct isp_pcisoftc *pci = (struct isp_pcisoftc *)isp;
- bus_dmamap_t *dp = &pci->dmaps[handle - 1];
- KASSERT((handle > 0 && handle <= isp->isp_maxcmds),
- ("bad handle in isp_pci_dmateardonw"));
- if ((xs->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
- bus_dmamap_sync(pci->parent_dmat, *dp, BUS_DMASYNC_POSTREAD);
- } else {
- bus_dmamap_sync(pci->parent_dmat, *dp, BUS_DMASYNC_POSTWRITE);
- }
- bus_dmamap_unload(pci->parent_dmat, *dp);
-}
-
-
-static void
-isp_pci_reset1(struct ispsoftc *isp)
-{
- /* Make sure the BIOS is disabled */
- isp_pci_wr_reg(isp, HCCR, PCI_HCCR_CMD_BIOS);
-}
-
-static void
-isp_pci_dumpregs(struct ispsoftc *isp)
-{
- struct isp_pcisoftc *pci = (struct isp_pcisoftc *)isp;
- printf("%s: PCI Status Command/Status=%x\n", pci->pci_isp.isp_name,
- pci_read_config(pci->pci_dev, PCIR_COMMAND, 1));
-}
diff --git a/sys/dev/joy/joy.c b/sys/dev/joy/joy.c
deleted file mode 100644
index b12e201553af..000000000000
--- a/sys/dev/joy/joy.c
+++ /dev/null
@@ -1,275 +0,0 @@
-/*-
- * Copyright (c) 1995 Jean-Marc Zucconi
- * 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
- * in this position and unchanged.
- * 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 withough 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/conf.h>
-#include <sys/uio.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/bus.h>
-#include <machine/bus.h>
-#include <machine/resource.h>
-#include <sys/rman.h>
-#include <sys/time.h>
-#include <sys/joystick.h>
-
-#include <isa/isavar.h>
-#include "isa_if.h"
-
-/* The game port can manage 4 buttons and 4 variable resistors (usually 2
- * joysticks, each with 2 buttons and 2 pots.) via the port at address 0x201.
- * Getting the state of the buttons is done by reading the game port:
- * buttons 1-4 correspond to bits 4-7 and resistors 1-4 (X1, Y1, X2, Y2)
- * to bits 0-3.
- * if button 1 (resp 2, 3, 4) is pressed, the bit 4 (resp 5, 6, 7) is set to 0
- * to get the value of a resistor, write the value 0xff at port and
- * wait until the corresponding bit returns to 0.
- */
-
-#define joypart(d) (minor(d)&1)
-#define UNIT(d) ((minor(d)>>1)&3)
-#ifndef JOY_TIMEOUT
-#define JOY_TIMEOUT 2000 /* 2 milliseconds */
-#endif
-
-struct joy_softc {
- bus_space_tag_t bt;
- bus_space_handle_t port;
- int x_off[2], y_off[2];
- int timeout[2];
-};
-
-#define JOY_SOFTC(unit) (struct joy_softc *) \
- devclass_get_softc(joy_devclass,(unit))
-
-static int joy_probe (device_t);
-static int joy_attach (device_t);
-
-#define CDEV_MAJOR 51
-static d_open_t joyopen;
-static d_close_t joyclose;
-static d_read_t joyread;
-static d_ioctl_t joyioctl;
-
-static struct cdevsw joy_cdevsw = {
- /* open */ joyopen,
- /* close */ joyclose,
- /* read */ joyread,
- /* write */ nowrite,
- /* ioctl */ joyioctl,
- /* poll */ nopoll,
- /* mmap */ nommap,
- /* strategy */ nostrategy,
- /* name */ "joy",
- /* maj */ CDEV_MAJOR,
- /* dump */ nodump,
- /* psize */ nopsize,
- /* flags */ 0,
- /* bmaj */ -1
-};
-
-devclass_t joy_devclass;
-
-static struct isa_pnp_id joy_ids[] = {
- {0x0100630e, "CSC0001 PnP Joystick"}, /* CSC0001 */
- {0x0101630e, "CSC0101 PnP Joystick"}, /* CSC0101 */
- {0x01100002, "ALS0110 PnP Joystick"}, /* @P@1001 */
- {0x01100002, "ALS0120 PnP Joystick"}, /* @P@2001 */
- {0x01007316, "ESS0001 PnP Joystick"}, /* ESS0001 */
- {0x2fb0d041, "Generic PnP Joystick"}, /* PNPb02f */
- {0x2200a865, "YMH0022 PnP Joystick"}, /* YMH0022 */
- {0x82719304, NULL}, /* ADS7182 */
- {0}
-};
-
-static int
-joy_probe (device_t dev)
-{
- if (ISA_PNP_PROBE(device_get_parent(dev), dev, joy_ids) == ENXIO)
- return ENXIO;
-#ifdef WANT_JOYSTICK_CONNECTED
-#ifdef notyet
- outb (dev->id_iobase, 0xff);
- DELAY (10000); /* 10 ms delay */
- return (inb (dev->id_iobase) & 0x0f) != 0x0f;
-#endif
-#else
- return 0;
-#endif
-}
-
-static int
-joy_attach (device_t dev)
-{
- int unit = device_get_unit(dev);
- int rid = 0;
- struct resource *res;
- struct joy_softc *joy = device_get_softc(dev);
-
- res = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, 1, RF_ACTIVE);
- if (res == NULL)
- return ENXIO;
- joy->bt = rman_get_bustag(res);
- joy->port = rman_get_bushandle(res);
- joy->timeout[0] = joy->timeout[1] = 0;
- make_dev(&joy_cdevsw, 0, 0, 0, 0600, "joy%d", unit);
- return 0;
-}
-
-static device_method_t joy_methods[] = {
- DEVMETHOD(device_probe, joy_probe),
- DEVMETHOD(device_attach, joy_attach),
- { 0, 0 }
-};
-
-static driver_t joy_isa_driver = {
- "joy",
- joy_methods,
- sizeof (struct joy_softc)
-};
-
-DRIVER_MODULE(joy, isa, joy_isa_driver, joy_devclass, 0, 0);
-
-static int
-joyopen(dev_t dev, int flags, int fmt, struct proc *p)
-{
- int i = joypart (dev);
- struct joy_softc *joy = JOY_SOFTC(UNIT(dev));
-
- if (joy->timeout[i])
- return EBUSY;
- joy->x_off[i] = joy->y_off[i] = 0;
- joy->timeout[i] = JOY_TIMEOUT;
- return 0;
-}
-
-static int
-joyclose(dev_t dev, int flags, int fmt, struct proc *p)
-{
- int i = joypart (dev);
- struct joy_softc *joy = JOY_SOFTC(UNIT(dev));
-
- joy->timeout[i] = 0;
- return 0;
-}
-
-static int
-joyread(dev_t dev, struct uio *uio, int flag)
-{
- struct joy_softc *joy = JOY_SOFTC(UNIT(dev));
- bus_space_handle_t port = joy->port;
- bus_space_tag_t bt = joy->bt;
- struct timespec t, start, end;
- int state = 0;
- struct timespec x, y;
- struct joystick c;
-#ifndef i386
- int s;
-
- s = splhigh();
-#else
- disable_intr ();
-#endif
- bus_space_write_1 (bt, port, 0, 0xff);
- nanotime(&start);
- end.tv_sec = 0;
- end.tv_nsec = joy->timeout[joypart(dev)] * 1000;
- timespecadd(&end, &start);
- t = start;
- timespecclear(&x);
- timespecclear(&y);
- while (timespeccmp(&t, &end, <)) {
- state = bus_space_read_1 (bt, port, 0);
- if (joypart(dev) == 1)
- state >>= 2;
- nanotime(&t);
- if (!timespecisset(&x) && !(state & 0x01))
- x = t;
- if (!timespecisset(&y) && !(state & 0x02))
- y = t;
- if (timespecisset(&x) && timespecisset(&y))
- break;
- }
-#ifndef i386
- splx(s);
-#else
- enable_intr ();
-#endif
- if (timespecisset(&x)) {
- timespecsub(&x, &start);
- c.x = joy->x_off[joypart(dev)] + x.tv_nsec / 1000;
- } else
- c.x = 0x80000000;
- if (timespecisset(&y)) {
- timespecsub(&y, &start);
- c.y = joy->y_off[joypart(dev)] + y.tv_nsec / 1000;
- } else
- c.y = 0x80000000;
- state >>= 4;
- c.b1 = ~state & 1;
- c.b2 = ~(state >> 1) & 1;
- return uiomove ((caddr_t)&c, sizeof(struct joystick), uio);
-}
-
-static int
-joyioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
-{
- struct joy_softc *joy = JOY_SOFTC(UNIT(dev));
- int i = joypart (dev);
- int x;
-
- switch (cmd) {
- case JOY_SETTIMEOUT:
- x = *(int *) data;
- if (x < 1 || x > 10000) /* 10ms maximum! */
- return EINVAL;
- joy->timeout[i] = x;
- break;
- case JOY_GETTIMEOUT:
- *(int *) data = joy->timeout[i];
- break;
- case JOY_SET_X_OFFSET:
- joy->x_off[i] = *(int *) data;
- break;
- case JOY_SET_Y_OFFSET:
- joy->y_off[i] = *(int *) data;
- break;
- case JOY_GET_X_OFFSET:
- *(int *) data = joy->x_off[i];
- break;
- case JOY_GET_Y_OFFSET:
- *(int *) data = joy->y_off[i];
- break;
- default:
- return ENXIO;
- }
- return 0;
-}
diff --git a/sys/dev/lnc/if_lnc.c b/sys/dev/lnc/if_lnc.c
deleted file mode 100644
index 9acef11066c0..000000000000
--- a/sys/dev/lnc/if_lnc.c
+++ /dev/null
@@ -1,2022 +0,0 @@
-/*-
- * Copyright (c) 1994-1998
- * Paul Richards. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 Paul Richards.
- * 4. The name Paul Richards may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY PAUL RICHARDS ``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 PAUL RICHARDS 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.
- *
- * $FreeBSD$
- */
-
-/*
-#define DIAGNOSTIC
-#define DEBUG
- *
- * TODO ----
- *
- * This driver will need bounce buffer support when dma'ing to mbufs above the
- * 16Mb mark.
- *
- * Check all the XXX comments -- some of them are just things I've left
- * unfinished rather than "difficult" problems that were hacked around.
- *
- * Check log settings.
- *
- * Check how all the arpcom flags get set and used.
- *
- * Re-inline and re-static all routines after debugging.
- *
- * Remember to assign iobase in SHMEM probe routines.
- *
- * Replace all occurences of LANCE-controller-card etc in prints by the name
- * strings of the appropriate type -- nifty window dressing
- *
- * Add DEPCA support -- mostly done.
- *
- */
-
-#include "pci.h"
-#include "lnc.h"
-
-#include "opt_inet.h"
-
-/* Some defines that should really be in generic locations */
-#define FCS_LEN 4
-#define MULTICAST_FILTER_LEN 8
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/conf.h>
-#include <sys/sockio.h>
-#include <sys/malloc.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <sys/syslog.h>
-
-#include <net/ethernet.h>
-#include <net/if.h>
-#include <net/if_dl.h>
-#include <net/if_types.h>
-
-#include <netinet/in.h>
-#include <netinet/if_ether.h>
-
-#include <net/bpf.h>
-
-#include "opt_bdg.h"
-#ifdef BRIDGE
-#include <net/bridge.h>
-#endif
-
-#ifdef PC98
-#include <machine/clock.h>
-#endif
-#include <machine/md_var.h>
-
-#include <i386/isa/isa_device.h>
-#include <i386/isa/if_lnc.h>
-
-struct lnc_softc {
- struct arpcom arpcom; /* see ../../net/if_arp.h */
- struct nic_info nic; /* NIC specific info */
- int nrdre;
- struct host_ring_entry *recv_ring; /* start of alloc'd mem */
- int recv_next;
- int ntdre;
- struct host_ring_entry *trans_ring;
- int trans_next;
- struct init_block *init_block; /* Initialisation block */
- int pending_transmits; /* No. of transmit descriptors in use */
- int next_to_send;
- struct mbuf *mbufs;
- int mbuf_count;
- int flags;
- int rap;
- int rdp;
- int bdp;
-#ifdef DEBUG
- int lnc_debug;
-#endif
- LNCSTATS_STRUCT
-};
-
-static struct lnc_softc lnc_softc[NLNC];
-
-static char const * const nic_ident[] = {
- "Unknown",
- "BICC",
- "NE2100",
- "DEPCA",
- "CNET98S", /* PC-98 */
-};
-
-static char const * const ic_ident[] = {
- "Unknown",
- "LANCE",
- "C-LANCE",
- "PCnet-ISA",
- "PCnet-ISA+",
- "PCnet-ISA II",
- "PCnet-32 VL-Bus",
- "PCnet-PCI",
- "PCnet-PCI II",
- "PCnet-FAST",
- "PCnet-FAST+",
- "PCnet-Home",
-};
-
-static void lnc_setladrf __P((struct lnc_softc *sc));
-static void lnc_stop __P((struct lnc_softc *sc));
-static void lnc_reset __P((struct lnc_softc *sc));
-static void lnc_free_mbufs __P((struct lnc_softc *sc));
-static __inline int alloc_mbuf_cluster __P((struct lnc_softc *sc,
- struct host_ring_entry *desc));
-static __inline struct mbuf *chain_mbufs __P((struct lnc_softc *sc,
- int start_of_packet,
- int pkt_len));
-static __inline struct mbuf *mbuf_packet __P((struct lnc_softc *sc,
- int start_of_packet,
- int pkt_len));
-static __inline void lnc_rint __P((struct lnc_softc *sc));
-static __inline void lnc_tint __P((struct lnc_softc *sc));
-static int lnc_probe __P((struct isa_device *isa_dev));
-#ifdef PC98
-static int cnet98s_probe __P((struct lnc_softc *sc, unsigned iobase));
-#endif
-static int ne2100_probe __P((struct lnc_softc *sc, unsigned iobase));
-static int bicc_probe __P((struct lnc_softc *sc, unsigned iobase));
-static int dec_macaddr_extract __P((u_char ring[], struct lnc_softc *sc));
-static int depca_probe __P((struct lnc_softc *sc, unsigned iobase));
-static int lance_probe __P((struct lnc_softc *sc));
-static int pcnet_probe __P((struct lnc_softc *sc));
-static int lnc_attach_sc __P((struct lnc_softc *sc, int unit));
-static int lnc_attach __P((struct isa_device *isa_dev));
-static void lnc_init __P((void *));
-static ointhand2_t lncintr;
-static __inline int mbuf_to_buffer __P((struct mbuf *m, char *buffer));
-static __inline struct mbuf *chain_to_cluster __P((struct mbuf *m));
-static void lnc_start __P((struct ifnet *ifp));
-static int lnc_ioctl __P((struct ifnet *ifp, u_long command, caddr_t data));
-static void lnc_watchdog __P((struct ifnet *ifp));
-#ifdef DEBUG
-void lnc_dump_state __P((struct lnc_softc *sc));
-void mbuf_dump_chain __P((struct mbuf *m));
-#endif
-
-#if NPCI > 0
-void *lnc_attach_ne2100_pci __P((int unit, unsigned iobase));
-#endif
-void lncintr_sc __P((struct lnc_softc *sc));
-
-struct isa_driver lncdriver = {lnc_probe, lnc_attach, "lnc"};
-
-static __inline void
-write_csr(struct lnc_softc *sc, u_short port, u_short val)
-{
- outw(sc->rap, port);
- outw(sc->rdp, val);
-}
-
-static __inline u_short
-read_csr(struct lnc_softc *sc, u_short port)
-{
- outw(sc->rap, port);
- return (inw(sc->rdp));
-}
-
-static __inline void
-write_bcr(struct lnc_softc *sc, u_short port, u_short val)
-{
- outw(sc->rap, port);
- outw(sc->bdp, val);
-}
-
-static __inline u_short
-read_bcr(struct lnc_softc *sc, u_short port)
-{
- outw(sc->rap, port);
- return (inw(sc->bdp));
-}
-
-static __inline u_long
-ether_crc(const u_char *ether_addr)
-{
-#define POLYNOMIAL 0xEDB88320UL
- u_char i, j, addr;
- u_int crc = 0xFFFFFFFFUL;
-
- for (i = 0; i < ETHER_ADDR_LEN; i++) {
- addr = *ether_addr++;
- for (j = 0; j < MULTICAST_FILTER_LEN; j++) {
- crc = (crc >> 1) ^ (((crc ^ addr) & 1) ? POLYNOMIAL : 0);
- addr >>= 1;
- }
- }
- return crc;
-#undef POLYNOMIAL
-}
-
-/*
- * Set up the logical address filter for multicast packets
- */
-static __inline void
-lnc_setladrf(struct lnc_softc *sc)
-{
- struct ifnet *ifp = &sc->arpcom.ac_if;
- struct ifmultiaddr *ifma;
- u_long index;
- int i;
-
- if (sc->flags & IFF_ALLMULTI) {
- for (i=0; i < MULTICAST_FILTER_LEN; i++)
- sc->init_block->ladrf[i] = 0xFF;
- return;
- }
-
- /*
- * For each multicast address, calculate a crc for that address and
- * then use the high order 6 bits of the crc as a hash code where
- * bits 3-5 select the byte of the address filter and bits 0-2 select
- * the bit within that byte.
- */
-
- bzero(sc->init_block->ladrf, MULTICAST_FILTER_LEN);
- for (ifma = ifp->if_multiaddrs.lh_first; ifma;
- ifma = ifma->ifma_link.le_next) {
- if (ifma->ifma_addr->sa_family != AF_LINK)
- continue;
-
- index = ether_crc(LLADDR((struct sockaddr_dl *)ifma->ifma_addr))
- >> 26;
- sc->init_block->ladrf[index >> 3] |= 1 << (index & 7);
- }
-}
-
-static void
-lnc_stop(struct lnc_softc *sc)
-{
- write_csr(sc, CSR0, STOP);
-}
-
-static void
-lnc_reset(struct lnc_softc *sc)
-{
- lnc_init(sc);
-}
-
-static void
-lnc_free_mbufs(struct lnc_softc *sc)
-{
- int i;
-
- /*
- * We rely on other routines to keep the buff.mbuf field valid. If
- * it's not NULL then we assume it points to an allocated mbuf.
- */
-
- for (i = 0; i < NDESC(sc->nrdre); i++)
- if ((sc->recv_ring + i)->buff.mbuf)
- m_free((sc->recv_ring + i)->buff.mbuf);
-
- for (i = 0; i < NDESC(sc->ntdre); i++)
- if ((sc->trans_ring + i)->buff.mbuf)
- m_free((sc->trans_ring + i)->buff.mbuf);
-
- if (sc->mbuf_count)
- m_freem(sc->mbufs);
-}
-
-static __inline int
-alloc_mbuf_cluster(struct lnc_softc *sc, struct host_ring_entry *desc)
-{
- register struct mds *md = desc->md;
- struct mbuf *m=0;
- int addr;
-
- /* Try and get cluster off local cache */
- if (sc->mbuf_count) {
- sc->mbuf_count--;
- m = sc->mbufs;
- sc->mbufs = m->m_next;
- /* XXX m->m_data = m->m_ext.ext_buf;*/
- } else {
- MGET(m, M_DONTWAIT, MT_DATA);
- if (!m)
- return(1);
- MCLGET(m, M_DONTWAIT);
- if (!m->m_ext.ext_buf) {
- m_free(m);
- return(1);
- }
- }
-
- desc->buff.mbuf = m;
- addr = kvtop(m->m_data);
- md->md0 = addr;
- md->md1= ((addr >> 16) & 0xff) | OWN;
- md->md2 = -(short)(MCLBYTES - sizeof(struct pkthdr));
- md->md3 = 0;
- return(0);
-}
-
-static __inline struct mbuf *
-chain_mbufs(struct lnc_softc *sc, int start_of_packet, int pkt_len)
-{
- struct mbuf *head, *m;
- struct host_ring_entry *desc;
-
- /*
- * Turn head into a pkthdr mbuf --
- * assumes a pkthdr type mbuf was
- * allocated to the descriptor
- * originally.
- */
-
- desc = sc->recv_ring + start_of_packet;
-
- head = desc->buff.mbuf;
- head->m_flags |= M_PKTHDR;
-
- m = head;
- do {
- m = desc->buff.mbuf;
- m->m_len = min((MCLBYTES - sizeof(struct pkthdr)), pkt_len);
- pkt_len -= m->m_len;
- if (alloc_mbuf_cluster(sc, desc))
- return((struct mbuf *)NULL);
- INC_MD_PTR(start_of_packet, sc->nrdre)
- desc = sc->recv_ring + start_of_packet;
- m->m_next = desc->buff.mbuf;
- } while (start_of_packet != sc->recv_next);
-
- m->m_next = 0;
- return(head);
-}
-
-static __inline struct mbuf *
-mbuf_packet(struct lnc_softc *sc, int start_of_packet, int pkt_len)
-{
-
- struct host_ring_entry *start;
- struct mbuf *head,*m,*m_prev;
- char *data,*mbuf_data;
- short blen;
- int amount;
-
- /* Get a pkthdr mbuf for the start of packet */
- MGETHDR(head, M_DONTWAIT, MT_DATA);
- if (!head) {
- LNCSTATS(drop_packet)
- return(0);
- }
-
- m = head;
- m->m_len = 0;
- start = sc->recv_ring + start_of_packet;
- /*blen = -(start->md->md2);*/
- blen = RECVBUFSIZE; /* XXX More PCnet-32 crap */
- data = start->buff.data;
- mbuf_data = m->m_data;
-
- while (start_of_packet != sc->recv_next) {
- /*
- * If the data left fits in a single buffer then set
- * blen to the size of the data left.
- */
- if (pkt_len < blen)
- blen = pkt_len;
-
- /*
- * amount is least of data in current ring buffer and
- * amount of space left in current mbuf.
- */
- amount = min(blen, M_TRAILINGSPACE(m));
- if (amount == 0) {
- /* mbuf must be empty */
- m_prev = m;
- MGET(m, M_DONTWAIT, MT_DATA);
- if (!m) {
- m_freem(head);
- return(0);
- }
- if (pkt_len >= MINCLSIZE)
- MCLGET(m, M_DONTWAIT);
- m->m_len = 0;
- m_prev->m_next = m;
- amount = min(blen, M_TRAILINGSPACE(m));
- mbuf_data = m->m_data;
- }
- bcopy(data, mbuf_data, amount);
- blen -= amount;
- pkt_len -= amount;
- m->m_len += amount;
- data += amount;
- mbuf_data += amount;
-
- if (blen == 0) {
- start->md->md1 &= HADR;
- start->md->md1 |= OWN;
- start->md->md2 = -RECVBUFSIZE; /* XXX - shouldn't be necessary */
- INC_MD_PTR(start_of_packet, sc->nrdre)
- start = sc->recv_ring + start_of_packet;
- data = start->buff.data;
- /*blen = -(start->md->md2);*/
- blen = RECVBUFSIZE; /* XXX More PCnet-32 crap */
- }
- }
- return(head);
-}
-
-
-static __inline void
-lnc_rint(struct lnc_softc *sc)
-{
- struct host_ring_entry *next, *start;
- int start_of_packet;
- struct mbuf *head;
- struct ether_header *eh;
- int lookahead;
- int flags;
- int pkt_len;
-
- /*
- * The LANCE will issue a RINT interrupt when the ownership of the
- * last buffer of a receive packet has been relinquished by the LANCE.
- * Therefore, it can be assumed that a complete packet can be found
- * before hitting buffers that are still owned by the LANCE, if not
- * then there is a bug in the driver that is causing the descriptors
- * to get out of sync.
- */
-
-#ifdef DIAGNOSTIC
- if ((sc->recv_ring + sc->recv_next)->md->md1 & OWN) {
- int unit = sc->arpcom.ac_if.if_unit;
- log(LOG_ERR, "lnc%d: Receive interrupt with buffer still owned by controller -- Resetting\n", unit);
- lnc_reset(sc);
- return;
- }
- if (!((sc->recv_ring + sc->recv_next)->md->md1 & STP)) {
- int unit = sc->arpcom.ac_if.if_unit;
- log(LOG_ERR, "lnc%d: Receive interrupt but not start of packet -- Resetting\n", unit);
- lnc_reset(sc);
- return;
- }
-#endif
-
- lookahead = 0;
- next = sc->recv_ring + sc->recv_next;
- while ((flags = next->md->md1) & STP) {
-
- /* Make a note of the start of the packet */
- start_of_packet = sc->recv_next;
-
- /*
- * Find the end of the packet. Even if not data chaining,
- * jabber packets can overrun into a second descriptor.
- * If there is no error, then the ENP flag is set in the last
- * descriptor of the packet. If there is an error then the ERR
- * flag will be set in the descriptor where the error occured.
- * Therefore, to find the last buffer of a packet we search for
- * either ERR or ENP.
- */
-
- if (!(flags & (ENP | MDERR))) {
- do {
- INC_MD_PTR(sc->recv_next, sc->nrdre)
- next = sc->recv_ring + sc->recv_next;
- flags = next->md->md1;
- } while (!(flags & (STP | OWN | ENP | MDERR)));
-
- if (flags & STP) {
- int unit = sc->arpcom.ac_if.if_unit;
- log(LOG_ERR, "lnc%d: Start of packet found before end of previous in receive ring -- Resetting\n", unit);
- lnc_reset(sc);
- return;
- }
- if (flags & OWN) {
- if (lookahead) {
- /*
- * Looked ahead into a packet still
- * being received
- */
- sc->recv_next = start_of_packet;
- break;
- } else {
- int unit = sc->arpcom.ac_if.if_unit;
- log(LOG_ERR, "lnc%d: End of received packet not found-- Resetting\n", unit);
- lnc_reset(sc);
- return;
- }
- }
- }
-
- pkt_len = (next->md->md3 & MCNT) - FCS_LEN;
-
- /* Move pointer onto start of next packet */
- INC_MD_PTR(sc->recv_next, sc->nrdre)
- next = sc->recv_ring + sc->recv_next;
-
- if (flags & MDERR) {
- int unit = sc->arpcom.ac_if.if_unit;
- if (flags & RBUFF) {
- LNCSTATS(rbuff)
- log(LOG_ERR, "lnc%d: Receive buffer error\n", unit);
- }
- if (flags & OFLO) {
- /* OFLO only valid if ENP is not set */
- if (!(flags & ENP)) {
- LNCSTATS(oflo)
- log(LOG_ERR, "lnc%d: Receive overflow error \n", unit);
- }
- } else if (flags & ENP) {
- if ((sc->arpcom.ac_if.if_flags & IFF_PROMISC)==0) {
- /*
- * FRAM and CRC are valid only if ENP
- * is set and OFLO is not.
- */
- if (flags & FRAM) {
- LNCSTATS(fram)
- log(LOG_ERR, "lnc%d: Framing error\n", unit);
- /*
- * FRAM is only set if there's a CRC
- * error so avoid multiple messages
- */
- } else if (flags & CRC) {
- LNCSTATS(crc)
- log(LOG_ERR, "lnc%d: Receive CRC error\n", unit);
- }
- }
- }
-
- /* Drop packet */
- LNCSTATS(rerr)
- sc->arpcom.ac_if.if_ierrors++;
- while (start_of_packet != sc->recv_next) {
- start = sc->recv_ring + start_of_packet;
- start->md->md2 = -RECVBUFSIZE; /* XXX - shouldn't be necessary */
- start->md->md1 &= HADR;
- start->md->md1 |= OWN;
- INC_MD_PTR(start_of_packet, sc->nrdre)
- }
- } else { /* Valid packet */
-
- sc->arpcom.ac_if.if_ipackets++;
-
-
- if (sc->nic.mem_mode == DMA_MBUF)
- head = chain_mbufs(sc, start_of_packet, pkt_len);
- else
- head = mbuf_packet(sc, start_of_packet, pkt_len);
-
- if (head) {
- /*
- * First mbuf in packet holds the
- * ethernet and packet headers
- */
- head->m_pkthdr.rcvif = &sc->arpcom.ac_if;
- head->m_pkthdr.len = pkt_len ;
-
- /*
- * BPF expects the ether header to be in the first
- * mbuf of the chain so point eh at the right place
- * but don't increment the mbuf pointers before
- * the bpf tap.
- */
-
- eh = (struct ether_header *) head->m_data;
-
- if (sc->arpcom.ac_if.if_bpf)
- bpf_mtap(&sc->arpcom.ac_if, head);
-#ifdef BRIDGE
- if (do_bridge) {
- struct ifnet *bdg_ifp ;
-
- bdg_ifp = bridge_in(head);
- if (bdg_ifp == BDG_DROP)
- m_freem(head);
- else {
- if (bdg_ifp != BDG_LOCAL)
- bdg_forward(&head, bdg_ifp);
- if ( bdg_ifp == BDG_LOCAL ||
- bdg_ifp == BDG_BCAST ||
- bdg_ifp == BDG_MCAST )
- goto getit;
- else if (head)
- m_freem(head);
- }
- } else
-#endif
- /* Check this packet is really for us */
-
- if ((sc->arpcom.ac_if.if_flags & IFF_PROMISC) &&
- !(eh->ether_dhost[0] & 1) && /* Broadcast and multicast */
- (bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr,
- sizeof(eh->ether_dhost))))
- m_freem(head);
- else
- {
-#ifdef BRIDGE
-getit:
-#endif
- /* Skip over the ether header */
- head->m_data += sizeof *eh;
- head->m_len -= sizeof *eh;
- head->m_pkthdr.len -= sizeof *eh;
-
- ether_input(&sc->arpcom.ac_if, eh, head);
- }
-
- } else {
- int unit = sc->arpcom.ac_if.if_unit;
- log(LOG_ERR,"lnc%d: Packet dropped, no mbufs\n",unit);
- LNCSTATS(drop_packet)
- }
- }
-
- lookahead++;
- }
-
- /*
- * At this point all completely received packets have been processed
- * so clear RINT since any packets that have arrived while we were in
- * here have been dealt with.
- */
-
- outw(sc->rdp, RINT | INEA);
-}
-
-static __inline void
-lnc_tint(struct lnc_softc *sc)
-{
- struct host_ring_entry *next, *start;
- int start_of_packet;
- int lookahead;
-
- /*
- * If the driver is reset in this routine then we return immediately to
- * the interrupt driver routine. Any interrupts that have occured
- * since the reset will be dealt with there. sc->trans_next
- * should point to the start of the first packet that was awaiting
- * transmission after the last transmit interrupt was dealt with. The
- * LANCE should have relinquished ownership of that descriptor before
- * the interrupt. Therefore, sc->trans_next should point to a
- * descriptor with STP set and OWN cleared. If not then the driver's
- * pointers are out of sync with the LANCE, which signifies a bug in
- * the driver. Therefore, the following two checks are really
- * diagnostic, since if the driver is working correctly they should
- * never happen.
- */
-
-#ifdef DIAGNOSTIC
- if ((sc->trans_ring + sc->trans_next)->md->md1 & OWN) {
- int unit = sc->arpcom.ac_if.if_unit;
- log(LOG_ERR, "lnc%d: Transmit interrupt with buffer still owned by controller -- Resetting\n", unit);
- lnc_reset(sc);
- return;
- }
-#endif
-
-
- /*
- * The LANCE will write the status information for the packet it just
- * tried to transmit in one of two places. If the packet was
- * transmitted successfully then the status will be written into the
- * last descriptor of the packet. If the transmit failed then the
- * status will be written into the descriptor that was being accessed
- * when the error occured and all subsequent descriptors in that
- * packet will have been relinquished by the LANCE.
- *
- * At this point we know that sc->trans_next points to the start
- * of a packet that the LANCE has just finished trying to transmit.
- * We now search for a buffer with either ENP or ERR set.
- */
-
- lookahead = 0;
-
- do {
- start_of_packet = sc->trans_next;
- next = sc->trans_ring + sc->trans_next;
-
-#ifdef DIAGNOSTIC
- if (!(next->md->md1 & STP)) {
- int unit = sc->arpcom.ac_if.if_unit;
- log(LOG_ERR, "lnc%d: Transmit interrupt but not start of packet -- Resetting\n", unit);
- lnc_reset(sc);
- return;
- }
-#endif
-
- /*
- * Find end of packet.
- */
-
- if (!(next->md->md1 & (ENP | MDERR))) {
- do {
- INC_MD_PTR(sc->trans_next, sc->ntdre)
- next = sc->trans_ring + sc->trans_next;
- } while (!(next->md->md1 & (STP | OWN | ENP | MDERR)));
-
- if (next->md->md1 & STP) {
- int unit = sc->arpcom.ac_if.if_unit;
- log(LOG_ERR, "lnc%d: Start of packet found before end of previous in transmit ring -- Resetting\n", unit);
- lnc_reset(sc);
- return;
- }
- if (next->md->md1 & OWN) {
- if (lookahead) {
- /*
- * Looked ahead into a packet still
- * being transmitted
- */
- sc->trans_next = start_of_packet;
- break;
- } else {
- int unit = sc->arpcom.ac_if.if_unit;
- log(LOG_ERR, "lnc%d: End of transmitted packet not found -- Resetting\n", unit);
- lnc_reset(sc);
- return;
- }
- }
- }
- /*
- * Check for ERR first since other flags are irrelevant if an
- * error occurred.
- */
- if (next->md->md1 & MDERR) {
-
- int unit = sc->arpcom.ac_if.if_unit;
-
- LNCSTATS(terr)
- sc->arpcom.ac_if.if_oerrors++;
-
- if (next->md->md3 & LCOL) {
- LNCSTATS(lcol)
- log(LOG_ERR, "lnc%d: Transmit late collision -- Net error?\n", unit);
- sc->arpcom.ac_if.if_collisions++;
- /*
- * Clear TBUFF since it's not valid when LCOL
- * set
- */
- next->md->md3 &= ~TBUFF;
- }
- if (next->md->md3 & LCAR) {
- LNCSTATS(lcar)
- log(LOG_ERR, "lnc%d: Loss of carrier during transmit -- Net error?\n", unit);
- }
- if (next->md->md3 & RTRY) {
- LNCSTATS(rtry)
- log(LOG_ERR, "lnc%d: Transmit of packet failed after 16 attempts -- TDR = %d\n", unit, ((sc->trans_ring + sc->trans_next)->md->md3 & TDR));
- sc->arpcom.ac_if.if_collisions += 16;
- /*
- * Clear TBUFF since it's not valid when RTRY
- * set
- */
- next->md->md3 &= ~TBUFF;
- }
- /*
- * TBUFF is only valid if neither LCOL nor RTRY are set.
- * We need to check UFLO after LCOL and RTRY so that we
- * know whether or not TBUFF is valid. If either are
- * set then TBUFF will have been cleared above. A
- * UFLO error will turn off the transmitter so we
- * have to reset.
- *
- */
-
- if (next->md->md3 & UFLO) {
- LNCSTATS(uflo)
- /*
- * If an UFLO has occured it's possibly due
- * to a TBUFF error
- */
- if (next->md->md3 & TBUFF) {
- LNCSTATS(tbuff)
- log(LOG_ERR, "lnc%d: Transmit buffer error -- Resetting\n", unit);
- } else
- log(LOG_ERR, "lnc%d: Transmit underflow error -- Resetting\n", unit);
- lnc_reset(sc);
- return;
- }
- do {
- INC_MD_PTR(sc->trans_next, sc->ntdre)
- next = sc->trans_ring + sc->trans_next;
- } while (!(next->md->md1 & STP) && (sc->trans_next != sc->next_to_send));
-
- } else {
- /*
- * Since we check for ERR first then if we get here
- * the packet was transmitted correctly. There may
- * still have been non-fatal errors though.
- * Don't bother checking for DEF, waste of time.
- */
-
- sc->arpcom.ac_if.if_opackets++;
-
- if (next->md->md1 & MORE) {
- LNCSTATS(more)
- sc->arpcom.ac_if.if_collisions += 2;
- }
-
- /*
- * ONE is invalid if LCOL is set. If LCOL was set then
- * ERR would have also been set and we would have
- * returned from lnc_tint above. Therefore we can
- * assume if we arrive here that ONE is valid.
- *
- */
-
- if (next->md->md1 & ONE) {
- LNCSTATS(one)
- sc->arpcom.ac_if.if_collisions++;
- }
- INC_MD_PTR(sc->trans_next, sc->ntdre)
- next = sc->trans_ring + sc->trans_next;
- }
-
- /*
- * Clear descriptors and free any mbufs.
- */
-
- do {
- start = sc->trans_ring + start_of_packet;
- start->md->md1 &= HADR;
- if (sc->nic.mem_mode == DMA_MBUF) {
- /* Cache clusters on a local queue */
- if ((start->buff.mbuf->m_flags & M_EXT) && (sc->mbuf_count < MBUF_CACHE_LIMIT)) {
- if (sc->mbuf_count) {
- start->buff.mbuf->m_next = sc->mbufs;
- sc->mbufs = start->buff.mbuf;
- } else
- sc->mbufs = start->buff.mbuf;
- sc->mbuf_count++;
- start->buff.mbuf = 0;
- } else {
- struct mbuf *junk;
- MFREE(start->buff.mbuf, junk);
- start->buff.mbuf = 0;
- }
- }
- sc->pending_transmits--;
- INC_MD_PTR(start_of_packet, sc->ntdre)
- }while (start_of_packet != sc->trans_next);
-
- /*
- * There's now at least one free descriptor
- * in the ring so indicate that we can accept
- * more packets again.
- */
-
- sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE;
-
- lookahead++;
-
- } while (sc->pending_transmits && !(next->md->md1 & OWN));
-
- /*
- * Clear TINT since we've dealt with all
- * the completed transmissions.
- */
-
- outw(sc->rdp, TINT | INEA);
-
- /* XXX only while doing if_is comparisons */
- if (!(sc->arpcom.ac_if.if_flags & IFF_OACTIVE))
- lnc_start(&sc->arpcom.ac_if);
-
-}
-
-static int
-lnc_probe(struct isa_device * isa_dev)
-{
- int nports;
- int unit = isa_dev->id_unit;
- struct lnc_softc *sc = &lnc_softc[unit];
- unsigned iobase = isa_dev->id_iobase;
-
-#ifdef DIAGNOSTIC
- int vsw;
- vsw = inw(isa_dev->id_iobase + PCNET_VSW);
- printf("Vendor Specific Word = %x\n", vsw);
-#endif
-
- nports = bicc_probe(sc, iobase);
- if (nports == 0)
- nports = ne2100_probe(sc, iobase);
- if (nports == 0)
- nports = depca_probe(sc, iobase);
-#ifdef PC98
- if (nports == 0)
- nports = cnet98s_probe(sc, iobase);
-#endif
- return (nports);
-}
-
-#ifdef PC98
-/* ISA Bus Configuration Registers */
-/* XXX - Should be in ic/Am7990.h */
-#define MSRDA 0x0000 /* ISACSR0: Master Mode Read Activity */
-#define MSWRA 0x0001 /* ISACSR1: Master Mode Write Activity */
-#define MC 0x0002 /* ISACSR2: Miscellaneous Configuration */
-
-#define LED1 0x0005 /* ISACSR5: LED1 Status */
-#define LED2 0x0006 /* ISACSR6: LED2 Status */
-#define LED3 0x0007 /* ISACSR7: LED3 Status */
-
-#define LED_PSE 0x0080 /* Pulse Stretcher */
-#define LED_XMTE 0x0010 /* Transmit Status */
-#define LED_RVPOLE 0x0008 /* Receive Polarity */
-#define LED_RCVE 0x0004 /* Receive Status */
-#define LED_JABE 0x0002 /* Jabber */
-#define LED_COLE 0x0001 /* Collision */
-
-static int
-cnet98s_probe(struct lnc_softc *sc, unsigned iobase)
-{
- int i;
- ushort tmp;
-
- sc->rap = iobase + CNET98S_RAP;
- sc->rdp = iobase + CNET98S_RDP;
-
- /* Reset */
- tmp = inw(iobase + CNET98S_RESET);
- outw(iobase + CNET98S_RESET, tmp);
- DELAY(500);
-
- sc->nic.ic = pcnet_probe(sc);
- if ((sc->nic.ic == UNKNOWN) || (sc->nic.ic > PCnet_32)) {
- return (0);
- }
-
- sc->nic.ident = CNET98S;
- sc->nic.mem_mode = DMA_FIXED;
-
- /* XXX - For now just use the defines */
- sc->nrdre = NRDRE;
- sc->ntdre = NTDRE;
-
- /* Extract MAC address from PROM */
- for (i = 0; i < ETHER_ADDR_LEN; i++) {
- sc->arpcom.ac_enaddr[i] = inb(iobase + (i * 2));
- }
-
- /*
- * ISA Configuration
- *
- * XXX - Following parameters are Contec C-NET(98)S only.
- * So, check the Ethernet address here.
- *
- * Contec uses 00 80 4c ?? ?? ??
- */
- if (sc->arpcom.ac_enaddr[0] == (u_char)0x00
- && sc->arpcom.ac_enaddr[1] == (u_char)0x80
- && sc->arpcom.ac_enaddr[2] == (u_char)0x4c) {
- outw(sc->rap, MSRDA);
- outw(iobase + CNET98S_IDP, 0x0006);
- outw(sc->rap, MSWRA);
- outw(iobase + CNET98S_IDP, 0x0006);
-#ifdef DIAGNOSTIC
- outw(sc->rap, MC);
- printf("ISACSR2 = %x\n", inw(iobase + CNET98S_IDP));
-#endif
- outw(sc->rap, LED1);
- outw(iobase + CNET98S_IDP, LED_PSE | LED_XMTE);
- outw(sc->rap, LED2);
- outw(iobase + CNET98S_IDP, LED_PSE | LED_RCVE);
- outw(sc->rap, LED3);
- outw(iobase + CNET98S_IDP, LED_PSE | LED_COLE);
- }
-
- return (CNET98S_IOSIZE);
-}
-#endif
-
-static int
-ne2100_probe(struct lnc_softc *sc, unsigned iobase)
-{
- int i;
-
- sc->rap = iobase + PCNET_RAP;
- sc->rdp = iobase + PCNET_RDP;
-
- sc->nic.ic = pcnet_probe(sc);
- if ((sc->nic.ic > 0) && (sc->nic.ic < PCnet_PCI)) {
- sc->nic.ident = NE2100;
- sc->nic.mem_mode = DMA_FIXED;
-
- /* XXX - For now just use the defines */
- sc->nrdre = NRDRE;
- sc->ntdre = NTDRE;
-
- /* Extract MAC address from PROM */
- for (i = 0; i < ETHER_ADDR_LEN; i++)
- sc->arpcom.ac_enaddr[i] = inb(iobase + i);
- return (NE2100_IOSIZE);
- } else {
- return (0);
- }
-}
-
-static int
-bicc_probe(struct lnc_softc *sc, unsigned iobase)
-{
- int i;
-
- /*
- * There isn't any way to determine if a NIC is a BICC. Basically, if
- * the lance probe succeeds using the i/o addresses of the BICC then
- * we assume it's a BICC.
- *
- */
-
- sc->rap = iobase + BICC_RAP;
- sc->rdp = iobase + BICC_RDP;
-
- /* I think all these cards us the Am7990 */
-
- if ((sc->nic.ic = lance_probe(sc))) {
- sc->nic.ident = BICC;
- sc->nic.mem_mode = DMA_FIXED;
-
- /* XXX - For now just use the defines */
- sc->nrdre = NRDRE;
- sc->ntdre = NTDRE;
-
- /* Extract MAC address from PROM */
- for (i = 0; i < ETHER_ADDR_LEN; i++)
- sc->arpcom.ac_enaddr[i] = inb(iobase + (i * 2));
-
- return (BICC_IOSIZE);
- } else {
- return (0);
- }
-}
-
-/*
- * I don't have data sheets for the dec cards but it looks like the mac
- * address is contained in a 32 byte ring. Each time you read from the port
- * you get the next byte in the ring. The mac address is stored after a
- * signature so keep searching for the signature first.
- */
-static int
-dec_macaddr_extract(u_char ring[], struct lnc_softc * sc)
-{
- const unsigned char signature[] = {0xff, 0x00, 0x55, 0xaa, 0xff, 0x00, 0x55, 0xaa};
-
- int i, j, rindex;
-
- for (i = 0; i < sizeof ring; i++) {
- for (j = 0, rindex = i; j < sizeof signature; j++) {
- if (ring[rindex] != signature[j])
- break;
- if (++rindex > sizeof ring)
- rindex = 0;
- }
- if (j == sizeof signature) {
- for (j = 0, rindex = i; j < ETHER_ADDR_LEN; j++) {
- sc->arpcom.ac_enaddr[j] = ring[rindex];
- if (++rindex > sizeof ring)
- rindex = 0;
- }
- return (1);
- }
- }
- return (0);
-}
-
-static int
-depca_probe(struct lnc_softc *sc, unsigned iobase)
-{
- int i;
- unsigned char maddr_ring[DEPCA_ADDR_ROM_SIZE];
-
- sc->rap = iobase + DEPCA_RAP;
- sc->rdp = iobase + DEPCA_RDP;
-
- if ((sc->nic.ic = lance_probe(sc))) {
- sc->nic.ident = DEPCA;
- sc->nic.mem_mode = SHMEM;
-
- /* Extract MAC address from PROM */
- for (i = 0; i < DEPCA_ADDR_ROM_SIZE; i++)
- maddr_ring[i] = inb(iobase + DEPCA_ADP);
- if (dec_macaddr_extract(maddr_ring, sc)) {
- return (DEPCA_IOSIZE);
- }
- }
- return (0);
-}
-
-static int
-lance_probe(struct lnc_softc *sc)
-{
- write_csr(sc, CSR0, STOP);
-
- if ((inw(sc->rdp) & STOP) && !(read_csr(sc, CSR3))) {
- /*
- * Check to see if it's a C-LANCE. For the LANCE the INEA bit
- * cannot be set while the STOP bit is. This restriction is
- * removed for the C-LANCE.
- */
- write_csr(sc, CSR0, INEA);
- if (read_csr(sc, CSR0) & INEA)
- return (C_LANCE);
- else
- return (LANCE);
- } else
- return (UNKNOWN);
-}
-
-static int
-pcnet_probe(struct lnc_softc *sc)
-{
- u_long chip_id;
- int type;
-
- /*
- * The PCnet family don't reset the RAP register on reset so we'll
- * have to write during the probe :-) It does have an ID register
- * though so the probe is just a matter of reading it.
- */
-
- if ((type = lance_probe(sc))) {
- chip_id = read_csr(sc, CSR89);
- chip_id <<= 16;
- chip_id |= read_csr(sc, CSR88);
- if (chip_id & AMD_MASK) {
- chip_id >>= 12;
- switch (chip_id & PART_MASK) {
- case Am79C960:
- return (PCnet_ISA);
- case Am79C961:
- return (PCnet_ISAplus);
- case Am79C961A:
- return (PCnet_ISA_II);
- case Am79C965:
- return (PCnet_32);
- case Am79C970:
- return (PCnet_PCI);
- case Am79C970A:
- return (PCnet_PCI_II);
- case Am79C971:
- return (PCnet_FAST);
- case Am79C972:
- return (PCnet_FASTplus);
- case Am79C978:
- return (PCnet_Home);
- default:
- break;
- }
- }
- }
- return (type);
-}
-
-static int
-lnc_attach_sc(struct lnc_softc *sc, int unit)
-{
- int lnc_mem_size;
-
- /*
- * Allocate memory for use by the controller.
- *
- * XXX -- the Am7990 and Am79C960 only have 24 address lines and so can
- * only access the lower 16Mb of physical memory. For the moment we
- * assume that malloc will allocate memory within the lower 16Mb
- * range. This is not a very valid assumption but there's nothing
- * that can be done about it yet. For shared memory NICs this isn't
- * relevant.
- *
- */
-
- lnc_mem_size = ((NDESC(sc->nrdre) + NDESC(sc->ntdre)) *
- sizeof(struct host_ring_entry));
-
- if (sc->nic.mem_mode != SHMEM)
- lnc_mem_size += sizeof(struct init_block) + (sizeof(struct mds) *
- (NDESC(sc->nrdre) + NDESC(sc->ntdre))) +
- MEM_SLEW;
-
- /* If using DMA to fixed host buffers then allocate memory for them */
-
- if (sc->nic.mem_mode == DMA_FIXED)
- lnc_mem_size += (NDESC(sc->nrdre) * RECVBUFSIZE) + (NDESC(sc->ntdre) * TRANSBUFSIZE);
-
- if (sc->nic.mem_mode != SHMEM) {
- if (sc->nic.ic < PCnet_32) {
- /* ISA based cards */
- sc->recv_ring = contigmalloc(lnc_mem_size, M_DEVBUF, M_NOWAIT,
- 0ul, 0xfffffful, 4ul, 0x1000000);
- } else {
- /* Non-ISA based cards, 32 bit capable */
-#ifdef notyet
- /*
- * For the 32 bit driver we're not fussed where we DMA to
- * though it'll still need to be contiguous
- */
- sc->recv_ring = malloc(lnc_mem_size, M_DEVBUF, M_NOWAIT);
-#else
- /*
- * For now it still needs to be below 16MB because the
- * descriptor's can only hold 16 bit addresses.
- */
- sc->recv_ring = contigmalloc(lnc_mem_size, M_DEVBUF, M_NOWAIT,
- 0ul, 0xfffffful, 4ul, 0x1000000);
-#endif
- }
- }
-
- if (!sc->recv_ring) {
- log(LOG_ERR, "lnc%d: Couldn't allocate memory for NIC\n", unit);
- return (0); /* XXX -- attach failed -- not tested in
- * calling routines */
- }
-
- /* Set default mode */
- sc->nic.mode = NORMAL;
-
- /* Fill in arpcom structure entries */
-
- sc->arpcom.ac_if.if_softc = sc;
- sc->arpcom.ac_if.if_name = lncdriver.name;
- sc->arpcom.ac_if.if_unit = unit;
- sc->arpcom.ac_if.if_mtu = ETHERMTU;
- sc->arpcom.ac_if.if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
- sc->arpcom.ac_if.if_timer = 0;
- sc->arpcom.ac_if.if_output = ether_output;
- sc->arpcom.ac_if.if_start = lnc_start;
- sc->arpcom.ac_if.if_ioctl = lnc_ioctl;
- sc->arpcom.ac_if.if_watchdog = lnc_watchdog;
- sc->arpcom.ac_if.if_init = lnc_init;
- sc->arpcom.ac_if.if_type = IFT_ETHER;
- sc->arpcom.ac_if.if_addrlen = ETHER_ADDR_LEN;
- sc->arpcom.ac_if.if_hdrlen = ETHER_HDR_LEN;
- sc->arpcom.ac_if.if_snd.ifq_maxlen = IFQ_MAXLEN;
-
- /*
- * XXX -- should check return status of if_attach
- */
-
- if_attach(&sc->arpcom.ac_if);
- ether_ifattach(&sc->arpcom.ac_if);
-
- printf("lnc%d: ", unit);
- if (sc->nic.ic == LANCE || sc->nic.ic == C_LANCE)
- printf("%s (%s)",
- nic_ident[sc->nic.ident], ic_ident[sc->nic.ic]);
- else
- printf("%s", ic_ident[sc->nic.ic]);
- printf(" address %6D\n", sc->arpcom.ac_enaddr, ":");
-
- bpfattach(&sc->arpcom.ac_if, DLT_EN10MB, sizeof(struct ether_header));
-
- return (1);
-}
-
-static int
-lnc_attach(struct isa_device * isa_dev)
-{
- int unit = isa_dev->id_unit;
- struct lnc_softc *sc = &lnc_softc[unit];
- int result;
-
- isa_dev->id_ointr = lncintr;
- result = lnc_attach_sc (sc, unit);
- if (result == 0)
- return (0);
-
-#ifndef PC98
- /*
- * XXX - is it safe to call isa_dmacascade() after if_attach()
- * and ether_ifattach() have been called in lnc_attach() ???
- */
- if ((sc->nic.mem_mode != SHMEM) &&
- (sc->nic.ic < PCnet_32))
- isa_dmacascade(isa_dev->id_drq);
-#endif
-
- return result;
-}
-
-#if NPCI > 0
-void *
-lnc_attach_ne2100_pci(int unit, unsigned iobase)
-{
- int i;
- struct lnc_softc *sc = malloc(sizeof *sc, M_DEVBUF, M_NOWAIT);
-
- if (sc) {
- bzero (sc, sizeof *sc);
-
- sc->rap = iobase + PCNET_RAP;
- sc->rdp = iobase + PCNET_RDP;
- sc->bdp = iobase + PCNET_BDP;
-
- sc->nic.ic = pcnet_probe(sc);
- if (sc->nic.ic >= PCnet_32) {
- sc->nic.ident = NE2100;
- sc->nic.mem_mode = DMA_FIXED;
-
- /* XXX - For now just use the defines */
- sc->nrdre = NRDRE;
- sc->ntdre = NTDRE;
-
- /* Extract MAC address from PROM */
- for (i = 0; i < ETHER_ADDR_LEN; i++)
- sc->arpcom.ac_enaddr[i] = inb(iobase + i);
-
- if (lnc_attach_sc(sc, unit) == 0) {
- free(sc, M_DEVBUF);
- sc = NULL;
- }
- }
- else {
- free(sc, M_DEVBUF);
- sc = NULL;
- }
- }
- return sc;
-}
-#endif
-
-static void
-lnc_init(xsc)
- void *xsc;
-{
- struct lnc_softc *sc = xsc;
- int s, i;
- char *lnc_mem;
-
- /* Check that interface has valid address */
-
- if (TAILQ_EMPTY(&sc->arpcom.ac_if.if_addrhead)) /* XXX unlikely */
- return;
-
- /* Shut down interface */
-
- s = splimp();
- lnc_stop(sc);
- sc->arpcom.ac_if.if_flags |= IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; /* XXX??? */
-
- /*
- * This sets up the memory area for the controller. Memory is set up for
- * the initialisation block (12 words of contiguous memory starting
- * on a word boundary),the transmit and receive ring structures (each
- * entry is 4 words long and must start on a quadword boundary) and
- * the data buffers.
- *
- * The alignment tests are particularly paranoid.
- */
-
-
-
- sc->recv_next = 0;
- sc->trans_ring = sc->recv_ring + NDESC(sc->nrdre);
- sc->trans_next = 0;
-
- if (sc->nic.mem_mode == SHMEM)
- lnc_mem = (char *) sc->nic.iobase;
- else
- lnc_mem = (char *) (sc->trans_ring + NDESC(sc->ntdre));
-
- lnc_mem = (char *)(((int)lnc_mem + 1) & ~1);
- sc->init_block = (struct init_block *) ((int) lnc_mem & ~1);
- lnc_mem = (char *) (sc->init_block + 1);
- lnc_mem = (char *)(((int)lnc_mem + 7) & ~7);
-
- /* Initialise pointers to descriptor entries */
- for (i = 0; i < NDESC(sc->nrdre); i++) {
- (sc->recv_ring + i)->md = (struct mds *) lnc_mem;
- lnc_mem += sizeof(struct mds);
- }
- for (i = 0; i < NDESC(sc->ntdre); i++) {
- (sc->trans_ring + i)->md = (struct mds *) lnc_mem;
- lnc_mem += sizeof(struct mds);
- }
-
- /* Initialise the remaining ring entries */
-
- if (sc->nic.mem_mode == DMA_MBUF) {
-
- sc->mbufs = 0;
- sc->mbuf_count = 0;
-
- /* Free previously allocated mbufs */
- if (sc->flags & LNC_INITIALISED)
- lnc_free_mbufs(sc);
-
-
- for (i = 0; i < NDESC(sc->nrdre); i++) {
- if (alloc_mbuf_cluster(sc, sc->recv_ring+i)) {
- log(LOG_ERR, "Initialisation failed -- no mbufs\n");
- splx(s);
- return;
- }
- }
-
- for (i = 0; i < NDESC(sc->ntdre); i++) {
- (sc->trans_ring + i)->buff.mbuf = 0;
- (sc->trans_ring + i)->md->md0 = 0;
- (sc->trans_ring + i)->md->md1 = 0;
- (sc->trans_ring + i)->md->md2 = 0;
- (sc->trans_ring + i)->md->md3 = 0;
- }
- } else {
- for (i = 0; i < NDESC(sc->nrdre); i++) {
- (sc->recv_ring + i)->md->md0 = kvtop(lnc_mem);
- (sc->recv_ring + i)->md->md1 = ((kvtop(lnc_mem) >> 16) & 0xff) | OWN;
- (sc->recv_ring + i)->md->md2 = -RECVBUFSIZE;
- (sc->recv_ring + i)->md->md3 = 0;
- (sc->recv_ring + i)->buff.data = lnc_mem;
- lnc_mem += RECVBUFSIZE;
- }
- for (i = 0; i < NDESC(sc->ntdre); i++) {
- (sc->trans_ring + i)->md->md0 = kvtop(lnc_mem);
- (sc->trans_ring + i)->md->md1 = ((kvtop(lnc_mem) >> 16) & 0xff);
- (sc->trans_ring + i)->md->md2 = 0;
- (sc->trans_ring + i)->md->md3 = 0;
- (sc->trans_ring + i)->buff.data = lnc_mem;
- lnc_mem += TRANSBUFSIZE;
- }
- }
-
- sc->next_to_send = 0;
-
- /* Set up initialisation block */
-
- sc->init_block->mode = sc->nic.mode;
-
- for (i = 0; i < ETHER_ADDR_LEN; i++)
- sc->init_block->padr[i] = sc->arpcom.ac_enaddr[i];
-
- lnc_setladrf(sc);
-
- sc->init_block->rdra = kvtop(sc->recv_ring->md);
- sc->init_block->rlen = ((kvtop(sc->recv_ring->md) >> 16) & 0xff) | (sc->nrdre << 13);
- sc->init_block->tdra = kvtop(sc->trans_ring->md);
- sc->init_block->tlen = ((kvtop(sc->trans_ring->md) >> 16) & 0xff) | (sc->ntdre << 13);
-
-
- /* Set flags to show that the memory area is valid */
- sc->flags |= LNC_INITIALISED;
-
- sc->pending_transmits = 0;
-
- /* Give the LANCE the physical address of the initialisation block */
-
- if (sc->nic.ic == PCnet_Home) {
- u_short media;
- /* Set PHY_SEL to HomeRun */
- media = read_bcr(sc, BCR49);
- media &= ~3;
- media |= 1;
- write_bcr(sc, BCR49, media);
- }
-
- write_csr(sc, CSR1, kvtop(sc->init_block));
- write_csr(sc, CSR2, (kvtop(sc->init_block) >> 16) & 0xff);
-
- /*
- * Depending on which controller this is, CSR3 has different meanings.
- * For the Am7990 it controls DMA operations, for the Am79C960 it
- * controls interrupt masks and transmitter algorithms. In either
- * case, none of the flags are set.
- *
- */
-
- write_csr(sc, CSR3, 0);
-
- /* Let's see if it starts */
-
- write_csr(sc, CSR0, INIT);
- for (i = 0; i < 1000; i++)
- if (read_csr(sc, CSR0) & IDON)
- break;
-
- /*
- * Now that the initialisation is complete there's no reason to
- * access anything except CSR0, so we leave RAP pointing there
- * so we can just access RDP from now on, saving an outw each
- * time.
- */
-
- if (read_csr(sc, CSR0) & IDON) {
- /*
- * Enable interrupts, start the LANCE, mark the interface as
- * running and transmit any pending packets.
- */
- write_csr(sc, CSR0, STRT | INEA);
- sc->arpcom.ac_if.if_flags |= IFF_RUNNING;
- sc->arpcom.ac_if.if_flags &= ~IFF_OACTIVE;
- lnc_start(&sc->arpcom.ac_if);
- } else
- log(LOG_ERR, "lnc%d: Initialisation failed\n",
- sc->arpcom.ac_if.if_unit);
-
- splx(s);
-}
-
-/*
- * The interrupt flag (INTR) will be set and provided that the interrupt enable
- * flag (INEA) is also set, the interrupt pin will be driven low when any of
- * the following occur:
- *
- * 1) Completion of the initialisation routine (IDON). 2) The reception of a
- * packet (RINT). 3) The transmission of a packet (TINT). 4) A transmitter
- * timeout error (BABL). 5) A missed packet (MISS). 6) A memory error (MERR).
- *
- * The interrupt flag is cleared when all of the above conditions are cleared.
- *
- * If the driver is reset from this routine then it first checks to see if any
- * interrupts have ocurred since the reset and handles them before returning.
- * This is because the NIC may signify a pending interrupt in CSR0 using the
- * INTR flag even if a hardware interrupt is currently inhibited (at least I
- * think it does from reading the data sheets). We may as well deal with
- * these pending interrupts now rather than get the overhead of another
- * hardware interrupt immediately upon returning from the interrupt handler.
- *
- */
-
-void
-lncintr_sc(struct lnc_softc *sc)
-{
- int unit = sc->arpcom.ac_if.if_unit;
- u_short csr0;
-
- /*
- * INEA is the only bit that can be cleared by writing a 0 to it so
- * we have to include it in any writes that clear other flags.
- */
-
- while ((csr0 = inw(sc->rdp)) & INTR) {
-
- /*
- * Clear interrupt flags early to avoid race conditions. The
- * controller can still set these flags even while we're in
- * this interrupt routine. If the flag is still set from the
- * event that caused this interrupt any new events will
- * be missed.
- */
-
-/* outw(sc->rdp, IDON | CERR | BABL | MISS | MERR | RINT | TINT | INEA); */
- outw(sc->rdp, csr0);
-
- /* We don't do anything with the IDON flag */
-
- if (csr0 & ERR) {
- if (csr0 & CERR) {
- log(LOG_ERR, "lnc%d: Heartbeat error -- SQE test failed\n", unit);
- LNCSTATS(cerr)
- }
- if (csr0 & BABL) {
- log(LOG_ERR, "lnc%d: Babble error - more than 1519 bytes transmitted\n", unit);
- LNCSTATS(babl)
- sc->arpcom.ac_if.if_oerrors++;
- }
- if (csr0 & MISS) {
- log(LOG_ERR, "lnc%d: Missed packet -- no receive buffer\n", unit);
- LNCSTATS(miss)
- sc->arpcom.ac_if.if_ierrors++;
- }
- if (csr0 & MERR) {
- log(LOG_ERR, "lnc%d: Memory error -- Resetting\n", unit);
- LNCSTATS(merr)
- lnc_reset(sc);
- continue;
- }
- }
- if (csr0 & RINT) {
- LNCSTATS(rint)
- lnc_rint(sc);
- }
- if (csr0 & TINT) {
- LNCSTATS(tint)
- sc->arpcom.ac_if.if_timer = 0;
- lnc_tint(sc);
- }
-
- /*
- * If there's room in the transmit descriptor ring then queue
- * some more transmit packets.
- */
-
- if (!(sc->arpcom.ac_if.if_flags & IFF_OACTIVE))
- lnc_start(&sc->arpcom.ac_if);
- }
-}
-
-static void
-lncintr(int unit)
-{
- struct lnc_softc *sc = &lnc_softc[unit];
- lncintr_sc (sc);
-}
-
-static __inline int
-mbuf_to_buffer(struct mbuf *m, char *buffer)
-{
-
- int len=0;
-
- for( ; m; m = m->m_next) {
- bcopy(mtod(m, caddr_t), buffer, m->m_len);
- buffer += m->m_len;
- len += m->m_len;
- }
-
- return(len);
-}
-
-static __inline struct mbuf *
-chain_to_cluster(struct mbuf *m)
-{
- struct mbuf *new;
-
- MGET(new, M_DONTWAIT, MT_DATA);
- if (new) {
- MCLGET(new, M_DONTWAIT);
- if (new->m_ext.ext_buf) {
- new->m_len = mbuf_to_buffer(m, new->m_data);
- m_freem(m);
- return(new);
- } else
- m_free(new);
- }
- return(0);
-}
-
-/*
- * IFF_OACTIVE and IFF_RUNNING are checked in ether_output so it's redundant
- * to check them again since we wouldn't have got here if they were not
- * appropriately set. This is also called from lnc_init and lncintr but the
- * flags should be ok at those points too.
- */
-
-static void
-lnc_start(struct ifnet *ifp)
-{
-
- struct lnc_softc *sc = ifp->if_softc;
- struct host_ring_entry *desc;
- int tmp;
- int end_of_packet;
- struct mbuf *head, *m;
- int len, chunk;
- int addr;
- int no_entries_needed;
-
- do {
-
- IF_DEQUEUE(&sc->arpcom.ac_if.if_snd, head);
- if (!head)
- return;
-
- if (sc->nic.mem_mode == DMA_MBUF) {
-
- no_entries_needed = 0;
- for (m=head; m; m = m->m_next)
- no_entries_needed++;
-
- /*
- * We try and avoid bcopy as much as possible
- * but there are two cases when we use it.
- *
- * 1) If there are not enough free entries in the ring
- * to hold each mbuf in the chain then compact the
- * chain into a single cluster.
- *
- * 2) The Am7990 and Am79C90 must not have less than
- * 100 bytes in the first descriptor of a chained
- * packet so it's necessary to shuffle the mbuf
- * contents to ensure this.
- */
-
-
- if (no_entries_needed > (NDESC(sc->ntdre) - sc->pending_transmits)) {
- if (!(head = chain_to_cluster(head))) {
- log(LOG_ERR, "lnc%d: Couldn't get mbuf for transmit packet -- Resetting \n ",ifp->if_unit);
- lnc_reset(sc);
- return;
- }
- } else if ((sc->nic.ic == LANCE) || (sc->nic.ic == C_LANCE)) {
- if ((head->m_len < 100) && (head->m_next)) {
- len = 100 - head->m_len;
- if (M_TRAILINGSPACE(head) < len) {
- /*
- * Move data to start of data
- * area. We assume the first
- * mbuf has a packet header
- * and is not a cluster.
- */
- bcopy((caddr_t)head->m_data, (caddr_t)head->m_pktdat, head->m_len);
- head->m_data = head->m_pktdat;
- }
- m = head->m_next;
- while (m && (len > 0)) {
- chunk = min(len, m->m_len);
- bcopy(mtod(m, caddr_t), mtod(head, caddr_t) + head->m_len, chunk);
- len -= chunk;
- head->m_len += chunk;
- m->m_len -= chunk;
- m->m_data += chunk;
- if (m->m_len <= 0) {
- MFREE(m, head->m_next);
- m = head->m_next;
- }
- }
- }
- }
-
- tmp = sc->next_to_send;
-
- /*
- * On entering this loop we know that tmp points to a
- * descriptor with a clear OWN bit.
- */
-
- desc = sc->trans_ring + tmp;
- len = ETHER_MIN_LEN;
- for (m = head; m; m = m->m_next) {
- desc->buff.mbuf = m;
- addr = kvtop(m->m_data);
- desc->md->md0 = addr;
- desc->md->md1 = ((addr >> 16) & 0xff);
- desc->md->md3 = 0;
- desc->md->md2 = -m->m_len;
- sc->pending_transmits++;
- len -= m->m_len;
-
- INC_MD_PTR(tmp, sc->ntdre)
- desc = sc->trans_ring + tmp;
- }
-
- end_of_packet = tmp;
- DEC_MD_PTR(tmp, sc->ntdre)
- desc = sc->trans_ring + tmp;
- desc->md->md1 |= ENP;
-
- if (len > 0)
- desc->md->md2 -= len;
-
- /*
- * Set OWN bits in reverse order, otherwise the Lance
- * could start sending the packet before all the
- * buffers have been relinquished by the host.
- */
-
- while (tmp != sc->next_to_send) {
- desc->md->md1 |= OWN;
- DEC_MD_PTR(tmp, sc->ntdre)
- desc = sc->trans_ring + tmp;
- }
- sc->next_to_send = end_of_packet;
- desc->md->md1 |= STP | OWN;
- } else {
- sc->pending_transmits++;
- desc = sc->trans_ring + sc->next_to_send;
- len = mbuf_to_buffer(head, desc->buff.data);
- desc->md->md3 = 0;
- desc->md->md2 = -max(len, ETHER_MIN_LEN - ETHER_CRC_LEN);
- desc->md->md1 |= OWN | STP | ENP;
- INC_MD_PTR(sc->next_to_send, sc->ntdre)
- }
-
- /* Force an immediate poll of the transmit ring */
- outw(sc->rdp, TDMD | INEA);
-
- /*
- * Set a timer so if the buggy Am7990.h shuts
- * down we can wake it up.
- */
-
- ifp->if_timer = 2;
-
- if (sc->arpcom.ac_if.if_bpf)
- bpf_mtap(&sc->arpcom.ac_if, head);
-
- if (sc->nic.mem_mode != DMA_MBUF)
- m_freem(head);
-
- } while (sc->pending_transmits < NDESC(sc->ntdre));
-
- /*
- * Transmit ring is full so set IFF_OACTIVE
- * since we can't buffer any more packets.
- */
-
- sc->arpcom.ac_if.if_flags |= IFF_OACTIVE;
- LNCSTATS(trans_ring_full)
-}
-
-static int
-lnc_ioctl(struct ifnet * ifp, u_long command, caddr_t data)
-{
-
- struct lnc_softc *sc = ifp->if_softc;
- int s, error = 0;
-
- s = splimp();
-
- switch (command) {
- case SIOCSIFADDR:
- case SIOCGIFADDR:
- case SIOCSIFMTU:
- error = ether_ioctl(ifp, command, data);
- break;
-
- case SIOCSIFFLAGS:
-#ifdef DEBUG
- if (ifp->if_flags & IFF_DEBUG)
- sc->lnc_debug = 1;
- else
- sc->lnc_debug = 0;
-#endif
- if (ifp->if_flags & IFF_PROMISC) {
- if (!(sc->nic.mode & PROM)) {
- sc->nic.mode |= PROM;
- lnc_init(sc);
- }
- } else if (sc->nic.mode & PROM) {
- sc->nic.mode &= ~PROM;
- lnc_init(sc);
- }
-
- if ((ifp->if_flags & IFF_ALLMULTI) &&
- !(sc->flags & LNC_ALLMULTI)) {
- sc->flags |= LNC_ALLMULTI;
- lnc_init(sc);
- } else if (!(ifp->if_flags & IFF_ALLMULTI) &&
- (sc->flags & LNC_ALLMULTI)) {
- sc->flags &= ~LNC_ALLMULTI;
- lnc_init(sc);
- }
-
- if ((ifp->if_flags & IFF_UP) == 0 &&
- (ifp->if_flags & IFF_RUNNING) != 0) {
- /*
- * If interface is marked down and it is running,
- * then stop it.
- */
- lnc_stop(sc);
- ifp->if_flags &= ~IFF_RUNNING;
- } else if ((ifp->if_flags & IFF_UP) != 0 &&
- (ifp->if_flags & IFF_RUNNING) == 0) {
- /*
- * If interface is marked up and it is stopped, then
- * start it.
- */
- lnc_init(sc);
- }
- break;
- case SIOCADDMULTI:
- case SIOCDELMULTI:
- lnc_init(sc);
- error = 0;
- break;
- default:
- error = EINVAL;
- }
- (void) splx(s);
- return error;
-}
-
-static void
-lnc_watchdog(struct ifnet *ifp)
-{
- log(LOG_ERR, "lnc%d: Device timeout -- Resetting\n", ifp->if_unit);
- ifp->if_oerrors++;
- lnc_reset(ifp->if_softc);
-}
-
-#ifdef DEBUG
-void
-lnc_dump_state(struct lnc_softc *sc)
-{
- int i;
-
- printf("\nDriver/NIC [%d] state dump\n", sc->arpcom.ac_if.if_unit);
- printf("Memory access mode: %b\n", sc->nic.mem_mode, MEM_MODES);
- printf("Host memory\n");
- printf("-----------\n");
-
- printf("Receive ring: base = %p, next = %p\n",
- (void *)sc->recv_ring, (void *)(sc->recv_ring + sc->recv_next));
- for (i = 0; i < NDESC(sc->nrdre); i++)
- printf("\t%d:%p md = %p buff = %p\n",
- i, (void *)(sc->recv_ring + i),
- (void *)(sc->recv_ring + i)->md,
- (void *)(sc->recv_ring + i)->buff.data);
-
- printf("Transmit ring: base = %p, next = %p\n",
- (void *)sc->trans_ring, (void *)(sc->trans_ring + sc->trans_next));
- for (i = 0; i < NDESC(sc->ntdre); i++)
- printf("\t%d:%p md = %p buff = %p\n",
- i, (void *)(sc->trans_ring + i),
- (void *)(sc->trans_ring + i)->md,
- (void *)(sc->trans_ring + i)->buff.data);
- printf("Lance memory (may be on host(DMA) or card(SHMEM))\n");
- printf("Init block = %p\n", (void *)sc->init_block);
- printf("\tmode = %b rlen:rdra = %x:%x tlen:tdra = %x:%x\n",
- sc->init_block->mode, INIT_MODE, sc->init_block->rlen,
- sc->init_block->rdra, sc->init_block->tlen, sc->init_block->tdra);
- printf("Receive descriptor ring\n");
- for (i = 0; i < NDESC(sc->nrdre); i++)
- printf("\t%d buffer = 0x%x%x, BCNT = %d,\tMCNT = %u,\tflags = %b\n",
- i, ((sc->recv_ring + i)->md->md1 & HADR),
- (sc->recv_ring + i)->md->md0,
- -(short) (sc->recv_ring + i)->md->md2,
- (sc->recv_ring + i)->md->md3,
- (((sc->recv_ring + i)->md->md1 & ~HADR) >> 8), RECV_MD1);
- printf("Transmit descriptor ring\n");
- for (i = 0; i < NDESC(sc->ntdre); i++)
- printf("\t%d buffer = 0x%x%x, BCNT = %d,\tflags = %b %b\n",
- i, ((sc->trans_ring + i)->md->md1 & HADR),
- (sc->trans_ring + i)->md->md0,
- -(short) (sc->trans_ring + i)->md->md2,
- ((sc->trans_ring + i)->md->md1 >> 8), TRANS_MD1,
- ((sc->trans_ring + i)->md->md3 >> 10), TRANS_MD3);
- printf("\nnext_to_send = %x\n", sc->next_to_send);
- printf("\n CSR0 = %b CSR1 = %x CSR2 = %x CSR3 = %x\n\n",
- read_csr(sc, CSR0), CSR0_FLAGS, read_csr(sc, CSR1),
- read_csr(sc, CSR2), read_csr(sc, CSR3));
-
- /* Set RAP back to CSR0 */
- outw(sc->rap, CSR0);
-}
-
-void
-mbuf_dump_chain(struct mbuf * m)
-{
-
-#define MBUF_FLAGS \
- "\20\1M_EXT\2M_PKTHDR\3M_EOR\4UNKNOWN\5M_BCAST\6M_MCAST"
-
- if (!m)
- log(LOG_DEBUG, "m == NULL\n");
- do {
- log(LOG_DEBUG, "m = %p\n", (void *)m);
- log(LOG_DEBUG, "m_hdr.mh_next = %p\n",
- (void *)m->m_hdr.mh_next);
- log(LOG_DEBUG, "m_hdr.mh_nextpkt = %p\n",
- (void *)m->m_hdr.mh_nextpkt);
- log(LOG_DEBUG, "m_hdr.mh_len = %d\n", m->m_hdr.mh_len);
- log(LOG_DEBUG, "m_hdr.mh_data = %p\n",
- (void *)m->m_hdr.mh_data);
- log(LOG_DEBUG, "m_hdr.mh_type = %d\n", m->m_hdr.mh_type);
- log(LOG_DEBUG, "m_hdr.mh_flags = %b\n", m->m_hdr.mh_flags,
- MBUF_FLAGS);
- if (!(m->m_hdr.mh_flags & (M_PKTHDR | M_EXT)))
- log(LOG_DEBUG, "M_dat.M_databuf = %p\n",
- (void *)m->M_dat.M_databuf);
- else {
- if (m->m_hdr.mh_flags & M_PKTHDR) {
- log(LOG_DEBUG, "M_dat.MH.MH_pkthdr.len = %d\n",
- m->M_dat.MH.MH_pkthdr.len);
- log(LOG_DEBUG,
- "M_dat.MH.MH_pkthdr.rcvif = %p\n",
- (void *)m->M_dat.MH.MH_pkthdr.rcvif);
- if (!(m->m_hdr.mh_flags & M_EXT))
- log(LOG_DEBUG,
- "M_dat.MH.MH_dat.MH_databuf = %p\n",
- (void *)m->M_dat.MH.MH_dat.MH_databuf);
- }
- if (m->m_hdr.mh_flags & M_EXT) {
- log(LOG_DEBUG,
- "M_dat.MH.MH_dat.MH_ext.ext_buff %p\n",
- (void *)m->M_dat.MH.MH_dat.MH_ext.ext_buf);
- log(LOG_DEBUG,
- "M_dat.MH.MH_dat.MH_ext.ext_free %p\n",
- (void *)m->M_dat.MH.MH_dat.MH_ext.ext_free);
- log(LOG_DEBUG,
- "M_dat.MH.MH_dat.MH_ext.ext_size %d\n",
- m->M_dat.MH.MH_dat.MH_ext.ext_size);
- }
- }
- } while ((m = m->m_next) != NULL);
-}
-#endif
diff --git a/sys/dev/lnc/if_lnc_pci.c b/sys/dev/lnc/if_lnc_pci.c
deleted file mode 100644
index 33c7212295ee..000000000000
--- a/sys/dev/lnc/if_lnc_pci.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- *
- * Copyright (c) 1996 Stefan Esser <se@freebsd.org>
- * 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 immediately at the beginning of the file, without modification,
- * 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. Absolutely no warranty of function or purpose is made by the author
- * Stefan Esser.
- * 4. Modifications may be freely made to this file if the above conditions
- * are met.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/malloc.h>
-#include <sys/kernel.h>
-#include <pci/pcireg.h>
-#include <pci/pcivar.h>
-
-#include "lnc.h"
-
-#define PCI_DEVICE_ID_PCNet_PCI 0x20001022
-#define PCI_DEVICE_ID_PCHome_PCI 0x20011022
-
-extern void *lnc_attach_ne2100_pci __P((int unit, unsigned iobase));
-
-static const char* lnc_pci_probe __P((pcici_t tag, pcidi_t type));
-static void lnc_pci_attach __P((pcici_t config_id, int unit));
-
-static u_long lnc_pci_count = NLNC;
-
-static struct pci_device lnc_pci_driver = {
- "lnc",
- lnc_pci_probe,
- lnc_pci_attach,
- &lnc_pci_count,
- NULL
-};
-
-COMPAT_PCI_DRIVER (lnc_pci, lnc_pci_driver);
-
-static const char*
-lnc_pci_probe (pcici_t tag, pcidi_t type)
-{
- switch(type) {
- case PCI_DEVICE_ID_PCNet_PCI:
- return ("PCNet/PCI Ethernet adapter");
- break;
- case PCI_DEVICE_ID_PCHome_PCI:
- return ("PCHome/PCI Ethernet adapter");
- break;
- default:
- break;
- }
- return (0);
-}
-
-void lncintr_sc (void*);
-
-static void
-lnc_pci_attach(config_id, unit)
- pcici_t config_id;
- int unit;
-{
- unsigned iobase;
- unsigned data; /* scratch to make this device a bus master*/
- void *lnc; /* device specific data for interrupt handler ... */
-
- if ( !pci_map_port(config_id,PCI_MAP_REG_START,(u_short *)&iobase) )
- printf("lnc%d: pci_port_map_attach failed?!\n",unit);
-
-
- /* Make this device a bus master. This was implictly done by
- pci_map_port under 2.2.x -- tvf */
-
- data = pci_cfgread(config_id, PCIR_COMMAND, 4);
- data |= PCIM_CMD_PORTEN | PCIM_CMD_BUSMASTEREN;
- pci_cfgwrite(config_id, PCIR_COMMAND, data, 4);
-
- lnc = lnc_attach_ne2100_pci(unit, iobase);
-
- if (!lnc)
- return;
- if(!(pci_map_int(config_id, lncintr_sc, (void *)lnc, &net_imask))) {
- free (lnc, M_DEVBUF);
- return;
- }
-
- return;
-}
diff --git a/sys/dev/lnc/if_lncreg.h b/sys/dev/lnc/if_lncreg.h
deleted file mode 100644
index 82efff9d5e32..000000000000
--- a/sys/dev/lnc/if_lncreg.h
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Am7990, Local Area Network Controller for Ethernet (LANCE)
- *
- * Copyright (c) 1994, Paul Richards. This software may be used,
- * modified, copied, distributed, and sold, in both source and binary
- * form provided that the above copyright and these terms are retained.
- * Under no circumstances is the author responsible for the proper
- * functioning of this software, nor does the author assume any
- * responsibility for damages incurred with its use.
- *
- */
-
-/*
- * The LANCE has four Control and Status Registers(CSRs) which are accessed
- * through two bus addressable ports, the address port (RAP) and the data
- * port (RDP).
- *
- */
-
-#define CSR0 0
-#define CSR1 1
-#define CSR2 2
-#define CSR3 3
-#define CSR88 88
-#define CSR89 89
-
-#define BCR49 49
-#define BCR32 32
-#define BCR33 33
-#define BCR34 34
-
-
-/* Control and Status Register Masks */
-
-/* CSR0 */
-
-#define ERR 0x8000
-#define BABL 0x4000
-#define CERR 0x2000
-#define MISS 0x1000
-#define MERR 0x0800
-#define RINT 0x0400
-#define TINT 0x0200
-#define IDON 0x0100
-#define INTR 0x0080
-#define INEA 0x0040
-#define RXON 0x0020
-#define TXON 0x0010
-#define TDMD 0x0008
-#define STOP 0x0004
-#define STRT 0x0002
-#define INIT 0x0001
-
-/*
- * CSR3
- *
- * Bits 3-15 are reserved.
- *
- */
-
-#define BSWP 0x0004
-#define ACON 0x0002
-#define BCON 0x0001
-
-/* Initialisation block */
-
-struct init_block {
- u_short mode; /* Mode register */
- u_char padr[6]; /* Ethernet address */
- u_char ladrf[8]; /* Logical address filter (multicast) */
- u_short rdra; /* Low order pointer to receive ring */
- u_short rlen; /* High order pointer and no. rings */
- u_short tdra; /* Low order pointer to transmit ring */
- u_short tlen; /* High order pointer and no rings */
-};
-
-/* Initialisation Block Mode Register Masks */
-
-#define PROM 0x8000 /* Promiscuous Mode */
-#define DRCVBC 0x4000 /* Disable Receive Broadcast */
-#define DRCVPA 0x2000 /* Disable Receive Physical Address */
-#define DLNKTST 0x1000 /* Disable Link Status */
-#define DAPC 0x0800 /* Disable Automatic Polarity Correction */
-#define MENDECL 0x0400 /* MENDEC Loopback Mode */
-#define LRT 0x0200 /* Low Receive Threshold (T-MAU mode only) */
-#define TSEL 0x0200 /* Transmit Mode Select (AUI mode only) */
-#define PORTSEL 0x0180 /* Port Select bits */
-#define INTL 0x0040 /* Internal Loopback */
-#define DRTY 0x0020 /* Disable Retry */
-#define FCOLL 0x0010 /* Force Collision */
-#define DXMTFCS 0x0008 /* Disable transmit CRC (FCS) */
-#define LOOP 0x0004 /* Loopback Enabl */
-#define DTX 0x0002 /* Disable the transmitter */
-#define DRX 0x0001 /* Disable the receiver */
-
-/*
- * Message Descriptor Structure
- *
- * Each transmit or receive descriptor ring entry (RDRE's and TDRE's)
- * is composed of 4, 16-bit, message descriptors. They contain the following
- * information.
- *
- * 1. The address of the actual message data buffer in user (host) memory.
- * 2. The length of that message buffer.
- * 3. The status information for that particular buffer. The eight most
- * significant bits of md1 are collectively termed the STATUS of the
- * descriptor.
- *
- * Descriptor md0 contains LADR 0-15, the low order 16 bits of the 24-bit
- * address of the actual data buffer. Bits 0-7 of descriptor md1 contain
- * HADR, the high order 8-bits of the 24-bit data buffer address. Bits 8-15
- * of md1 contain the status flags of the buffer. Descriptor md2 contains the
- * buffer byte count in bits 0-11 as a two's complement number and must have
- * 1's written to bits 12-15. For the receive entry md3 has the Message Byte
- * Count in bits 0-11, this is the length of the received message and is valid
- * only when ERR is cleared and ENP is set. For the transmit entry it contains
- * more status information.
- *
- */
-
-struct mds {
- u_short md0;
- u_short md1;
- short md2;
- u_short md3;
-};
-
-/* Receive STATUS flags for md1 */
-
-#define OWN 0x8000 /* Owner bit, 0=host, 1=Lance */
-#define MDERR 0x4000 /* Error */
-#define FRAM 0x2000 /* Framing error error */
-#define OFLO 0x1000 /* Silo overflow */
-#define CRC 0x0800 /* CRC error */
-#define RBUFF 0x0400 /* Buffer error */
-#define STP 0x0200 /* Start of packet */
-#define ENP 0x0100 /* End of packet */
-#define HADR 0x00FF /* High order address bits */
-
-/* Receive STATUS flags for md2 */
-
-#define BCNT 0x0FFF /* Size of data buffer as 2's comp. no. */
-
-/* Receive STATUS flags for md3 */
-
-#define MCNT 0x0FFF /* Total size of data for received packet */
-
-/* Transmit STATUS flags for md1 */
-
-#define ADD_FCS 0x2000 /* Controls generation of FCS */
-#define MORE 0x1000 /* Indicates more than one retry was needed */
-#define ONE 0x0800 /* Exactly one retry was needed */
-#define DEF 0x0400 /* Packet transmit deferred -- channel busy */
-
-/*
- * Transmit status flags for md2
- *
- * Same as for receive descriptor.
- *
- * BCNT 0x0FFF Size of data buffer as 2's complement number.
- *
- */
-
-/* Transmit status flags for md3 */
-
-#define TBUFF 0x8000 /* Buffer error */
-#define UFLO 0x4000 /* Silo underflow */
-#define LCOL 0x1000 /* Late collision */
-#define LCAR 0x0800 /* Loss of carrier */
-#define RTRY 0x0400 /* Tried 16 times */
-#define TDR 0x03FF /* Time domain reflectometry */
-
diff --git a/sys/dev/lnc/if_lncvar.h b/sys/dev/lnc/if_lncvar.h
deleted file mode 100644
index cda83648663c..000000000000
--- a/sys/dev/lnc/if_lncvar.h
+++ /dev/null
@@ -1,215 +0,0 @@
-/*-
- * Copyright (c) 1994-1998
- * Paul Richards. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 Paul Richards.
- * 4. The name Paul Richards may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY PAUL RICHARDS ``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 PAUL RICHARDS 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.
- *
- * $FreeBSD$
- */
-
-#include <i386/isa/ic/Am7990.h>
-
-/*
- * Initialize multicast address hashing registers to accept
- * all multicasts (only used when in promiscuous mode)
- */
-#define MULTI_INIT_ADDR 0xff
-
-#define NORMAL 0
-
-#define NRDRE 3
-#define NTDRE 3
-#define RECVBUFSIZE 1518 /* Packet size rounded to dword boundary */
-#define TRANSBUFSIZE 1518
-#define MBUF_CACHE_LIMIT 0
-
-#define MEM_SLEW 8
-
-/* LNC Flags */
-#define LNC_INITIALISED 1
-#define LNC_ALLMULTI 2
-
-/* BICC port addresses */
-#define BICC_IOSIZE 16
-#define BICC_RDP 0x0c /* Register Data Port */
-#define BICC_RAP 0x0e /* Register Address Port */
-
-/* NE2100 port addresses */
-#define NE2100_IOSIZE 24
-#define PCNET_RDP 0x10 /* Register Data Port */
-#define PCNET_RAP 0x12 /* Register Address Port */
-#define PCNET_RESET 0x14
-#define PCNET_BDP 0x16
-#define PCNET_VSW 0x18
-
-/* DEPCA port addresses */
-#define DEPCA_IOSIZE 16
-#define DEPCA_CTRL 0x00 /* NIC Control and status register */
-#define DEPCA_RDP 0x04 /* Register Data Port */
-#define DEPCA_RAP 0x06 /* Register Address Port */
-#define DEPCA_ADP 0x0c
-
-/* DEPCA specific defines */
-#define DEPCA_ADDR_ROM_SIZE 32
-
-#ifdef PC98
-/* C-NET(98)S port addresses */
-#define CNET98S_RDP 0x400 /* Register Data Port */
-#define CNET98S_RAP 0x402 /* Register Address Port */
-#define CNET98S_RESET 0x404
-#define CNET98S_IDP 0x406
-#define CNET98S_EEPROM 0x40e
-/*
- * XXX - The I/O address range is fragmented in the C-NET(98)S.
- * This is the number of regs at iobase.
- */
-#define CNET98S_IOSIZE 16 /* # of i/o addresses used. */
-#endif
-
-/* Chip types */
-#define LANCE 1 /* Am7990 */
-#define C_LANCE 2 /* Am79C90 */
-#define PCnet_ISA 3 /* Am79C960 */
-#define PCnet_ISAplus 4 /* Am79C961 */
-#define PCnet_ISA_II 5 /* Am79C961A */
-#define PCnet_32 6 /* Am79C965 */
-#define PCnet_PCI 7 /* Am79C970 */
-#define PCnet_PCI_II 8 /* Am79C970A */
-#define PCnet_FAST 9 /* Am79C971 */
-#define PCnet_FASTplus 10 /* Am79C972 */
-#define PCnet_Home 11 /* Am79C978 */
-
-
-/* CSR88-89: Chip ID masks */
-#define AMD_MASK 0x003
-#define PART_MASK 0xffff
-#define Am79C960 0x0003
-#define Am79C961 0x2260
-#define Am79C961A 0x2261
-#define Am79C965 0x2430
-#define Am79C970 0x0242
-#define Am79C970A 0x2621
-#define Am79C971 0x2623
-#define Am79C972 0x2624
-#define Am79C978 0x2626
-
-/* Board types */
-#define UNKNOWN 0
-#define BICC 1
-#define NE2100 2
-#define DEPCA 3
-#define CNET98S 4 /* PC-98 */
-
-/* mem_mode values */
-#define DMA_FIXED 1
-#define DMA_MBUF 2
-#define SHMEM 4
-
-#define MEM_MODES \
- "\20\3SHMEM\2DMA_MBUF\1DMA_FIXED"
-
-#define CSR0_FLAGS \
- "\20\20ERR\17BABL\16CERR\15MISS\14MERR\13RINT\12TINT\11IDON\
- \10INTR\07INEA\06RXON\05TXON\04TDMD\03STOP\02STRT\01INIT"
-
-#define INIT_MODE \
- "\20\20PROM\07INTL\06DRTY\05COLL\04DTCR\03LOOP\02DTX\01DRX"
-
-#define RECV_MD1 \
- "\20\10OWN\7ERR\6FRAM\5OFLO\4CRC\3BUFF\2STP\1ENP"
-
-#define TRANS_MD1 \
- "\20\10OWN\7ERR\6RES\5MORE\4ONE\3DEF\2STP\1ENP"
-
-#define TRANS_MD3 \
- "\20\6BUFF\5UFLO\4RES\3LCOL\2LCAR\1RTRY"
-
-struct nic_info {
- int ident; /* Type of card */
- int ic; /* Type of ic, Am7990, Am79C960 etc. */
- int mem_mode;
- int iobase;
- int mode; /* Mode setting at initialization */
-};
-
-struct host_ring_entry {
- struct mds *md;
- union {
- struct mbuf *mbuf;
- char *data;
- }buff;
-};
-
-#ifdef LNC_KEEP_STATS
-#define LNCSTATS_STRUCT \
- struct lnc_stats { \
- int idon; \
- int rint; \
- int tint; \
- int cerr; \
- int babl; \
- int miss; \
- int merr; \
- int rxoff; \
- int txoff; \
- int terr; \
- int lcol; \
- int lcar; \
- int tbuff; \
- int def; \
- int more; \
- int one; \
- int uflo; \
- int rtry; \
- int rerr; \
- int fram; \
- int oflo; \
- int crc; \
- int rbuff; \
- int drop_packet; \
- int trans_ring_full; \
- } lnc_stats;
-#define LNCSTATS(X) ++(sc->lnc_stats.X);
-#else
-#define LNCSTATS_STRUCT
-#define LNCSTATS(X)
-#endif
-
-#define NDESC(len2) (1 << len2)
-
-#define INC_MD_PTR(ptr, no_entries) \
- if (++ptr >= NDESC(no_entries)) \
- ptr = 0;
-
-#define DEC_MD_PTR(ptr, no_entries) \
- if (--ptr < 0) \
- ptr = NDESC(no_entries) - 1;
-
-#define RECV_NEXT (sc->recv_ring->base + sc->recv_next)
-#define TRANS_NEXT (sc->trans_ring->base + sc->trans_next)
diff --git a/sys/dev/mc146818/mc146818reg.h b/sys/dev/mc146818/mc146818reg.h
deleted file mode 100644
index 18cc979fd50a..000000000000
--- a/sys/dev/mc146818/mc146818reg.h
+++ /dev/null
@@ -1,186 +0,0 @@
-/* $NetBSD: mc146818reg.h,v 1.2 1997/03/12 06:53:42 cgd Exp $ */
-
-/*
- * Copyright (c) 1995 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 the
- * rights to redistribute these changes.
- */
-
-/*
- * Definitions for the Motorola MC146818A Real Time Clock.
- * They also apply for the (compatible) Dallas Semicontuctor DS1287A RTC.
- *
- * Though there are undoubtedly other (better) sources, this material was
- * culled from the DEC "KN121 System Module Programmer's Reference
- * Information."
- *
- * The MC146818A has 16 registers. The first 10 contain time-of-year
- * and alarm data. The rest contain various control and status bits.
- *
- * To read or write the registers, one writes the register number to
- * the RTC's control port, then either reads from or writes the new
- * data to the RTC's data port. Since the locations of these ports
- * and the method used to access them can be machine-dependent, the
- * low-level details of reading and writing the RTC's registers are
- * handled by machine-specific functions.
- *
- * The time-of-year and alarm data can be expressed in either binary
- * or BCD, and they are selected by a bit in register B.
- *
- * The "hour" time-of-year and alarm fields can either be expressed in
- * AM/PM format, or in 24-hour format. If AM/PM format is chosen, the
- * hour fields can have the values: 1-12 and 81-92 (the latter being
- * PM). If the 24-hour format is chosen, they can have the values
- * 0-24. The hour format is selectable by a bit in register B.
- * (XXX IS AM/PM MODE DESCRIPTION CORRECT?)
- *
- * It is assumed the if systems are going to use BCD (rather than
- * binary) mode, or AM/PM hour format, they'll do the appropriate
- * conversions in machine-dependent code. Also, if the clock is
- * switched between BCD and binary mode, or between AM/PM mode and
- * 24-hour mode, the time-of-day and alarm registers are NOT
- * automatically reset; they must be reprogrammed with correct values.
- */
-
-/*
- * The registers, and the bits within each register.
- */
-
-#define MC_SEC 0x0 /* Time of year: seconds (0-59) */
-#define MC_ASEC 0x1 /* Alarm: seconds */
-#define MC_MIN 0x2 /* Time of year: minutes (0-59) */
-#define MC_AMIN 0x3 /* Alarm: minutes */
-#define MC_HOUR 0x4 /* Time of year: hour (see above) */
-#define MC_AHOUR 0x5 /* Alarm: hour */
-#define MC_DOW 0x6 /* Time of year: day of week (1-7) */
-#define MC_DOM 0x7 /* Time of year: day of month (1-31) */
-#define MC_MONTH 0x8 /* Time of year: month (1-12) */
-#define MC_YEAR 0x9 /* Time of year: year in century (0-99) */
-
-#define MC_REGA 0xa /* Control register A */
-
-#define MC_REGA_RSMASK 0x0f /* Interrupt rate select mask (see below) */
-#define MC_REGA_DVMASK 0x70 /* Divisor select mask (see below) */
-#define MC_REGA_UIP 0x80 /* Update in progress; read only. */
-
-#define MC_REGB 0xb /* Control register B */
-
-#define MC_REGB_DSE 0x01 /* Daylight Savings Enable */
-#define MC_REGB_24HR 0x02 /* 24-hour mode (AM/PM mode when clear) */
-#define MC_REGB_BINARY 0x04 /* Binary mode (BCD mode when clear) */
-#define MC_REGB_SQWE 0x08 /* Square Wave Enable */
-#define MC_REGB_UIE 0x10 /* Update End interrupt enable */
-#define MC_REGB_AIE 0x20 /* Alarm interrupt enable */
-#define MC_REGB_PIE 0x40 /* Periodic interrupt enable */
-#define MC_REGB_SET 0x80 /* Allow time to be set; stops updates */
-
-#define MC_REGC 0xc /* Control register C */
-
-/* MC_REGC_UNUSED 0x0f UNUSED */
-#define MC_REGC_UF 0x10 /* Update End interrupt flag */
-#define MC_REGC_AF 0x20 /* Alarm interrupt flag */
-#define MC_REGC_PF 0x40 /* Periodic interrupt flag */
-#define MC_REGC_IRQF 0x80 /* Interrupt request pending flag */
-
-#define MC_REGD 0xd /* Control register D */
-
-/* MC_REGD_UNUSED 0x7f UNUSED */
-#define MC_REGD_VRT 0x80 /* Valid RAM and Time bit */
-
-
-#define MC_NREGS 0xe /* 14 registers; CMOS follows */
-#define MC_NTODREGS 0xa /* 10 of those regs are for TOD and alarm */
-
-#define MC_NVRAM_START 0xe /* start of NVRAM: offset 14 */
-#define MC_NVRAM_SIZE 50 /* 50 bytes of NVRAM */
-
-/*
- * Periodic Interrupt Rate Select constants (Control register A)
- */
-#define MC_RATE_NONE 0x0 /* No periodic interrupt */
-#define MC_RATE_1 0x1 /* 256 Hz if MC_BASE_32_KHz, else 32768 Hz */
-#define MC_RATE_2 0x2 /* 128 Hz if MC_BASE_32_KHz, else 16384 Hz */
-#define MC_RATE_8192_Hz 0x3 /* 122.070 us period */
-#define MC_RATE_4096_Hz 0x4 /* 244.141 us period */
-#define MC_RATE_2048_Hz 0x5 /* 488.281 us period */
-#define MC_RATE_1024_Hz 0x6 /* 976.562 us period */
-#define MC_RATE_512_Hz 0x7 /* 1.953125 ms period */
-#define MC_RATE_256_Hz 0x8 /* 3.90625 ms period */
-#define MC_RATE_128_Hz 0x9 /* 7.8125 ms period */
-#define MC_RATE_64_Hz 0xa /* 15.625 ms period */
-#define MC_RATE_32_Hz 0xb /* 31.25 ms period */
-#define MC_RATE_16_Hz 0xc /* 62.5 ms period */
-#define MC_RATE_8_Hz 0xd /* 125 ms period */
-#define MC_RATE_4_Hz 0xe /* 250 ms period */
-#define MC_RATE_2_Hz 0xf /* 500 ms period */
-
-/*
- * Time base (divisor select) constants (Control register A)
- */
-#define MC_BASE_4_MHz 0x00 /* 4MHz crystal */
-#define MC_BASE_1_MHz 0x10 /* 1MHz crystal */
-#define MC_BASE_32_KHz 0x20 /* 32KHz crystal */
-#define MC_BASE_NONE 0x60 /* actually, both of these reset */
-#define MC_BASE_RESET 0x70
-
-/*
- * A collection of TOD/Alarm registers.
- */
-typedef u_int mc_todregs[MC_NTODREGS];
-
-/*
- * Get all of the TOD/Alarm registers
- * Must be called at splhigh(), and with the RTC properly set up.
- */
-#define MC146818_GETTOD(dev, regs) \
- do { \
- int i; \
- \
- /* update in progress; spin loop */ \
- while (MCCLOCK_READ(dev, MC_REGA) & MC_REGA_UIP) \
- ; \
- \
- /* read all of the tod/alarm regs */ \
- for (i = 0; i < MC_NTODREGS; i++) \
- (*regs)[i] = MCCLOCK_READ(dev, i); \
- } while (0);
-
-/*
- * Set all of the TOD/Alarm registers
- * Must be called at splhigh(), and with the RTC properly set up.
- */
-#define MC146818_PUTTOD(dev, regs) \
- do { \
- int i; \
- \
- /* stop updates while setting */ \
- MCCLOCK_WRITE(dev, MC_REGB, \
- MCCLOCK_READ(dev, MC_REGB) | MC_REGB_SET); \
- \
- /* write all of the tod/alarm regs */ \
- for (i = 0; i < MC_NTODREGS; i++) \
- MCCLOCK_WRITE(dev, i, (*regs)[i]); \
- \
- /* reenable updates */ \
- MCCLOCK_WRITE(dev, MC_REGB, \
- MCCLOCK_READ(dev, MC_REGB) & ~MC_REGB_SET); \
- } while (0);
diff --git a/sys/dev/mcd/mcd.c b/sys/dev/mcd/mcd.c
deleted file mode 100644
index 923ec0f8fc74..000000000000
--- a/sys/dev/mcd/mcd.c
+++ /dev/null
@@ -1,1833 +0,0 @@
-/*
- * Copyright 1993 by Holger Veit (data part)
- * Copyright 1993 by Brian Moore (audio part)
- * Changes Copyright 1993 by Gary Clark II
- * Changes Copyright (C) 1994-1995 by Andrey A. Chernov, Moscow, Russia
- *
- * Rewrote probe routine to work on newer Mitsumi drives.
- * Additional changes (C) 1994 by Jordan K. Hubbard
- *
- * 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 was developed by Holger Veit and Brian Moore
- * for use with "386BSD" and similar operating systems.
- * "Similar operating systems" includes mainly non-profit oriented
- * systems for research and education, including but not restricted to
- * "NetBSD", "FreeBSD", "Mach" (by CMU).
- * 4. Neither the name of the developer(s) nor the name "386BSD"
- * may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPER(S) ``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(S) 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.
- *
- * $FreeBSD$
- */
-static const char COPYRIGHT[] = "mcd-driver (C)1993 by H.Veit & B.Moore";
-
-#include "mcd.h"
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/conf.h>
-#include <sys/fcntl.h>
-#include <sys/buf.h>
-#include <sys/cdio.h>
-#include <sys/disklabel.h>
-#include <sys/kernel.h>
-
-#include <machine/clock.h>
-
-#include <i386/isa/isa_device.h>
-#include <i386/isa/mcdreg.h>
-
-#define MCD_TRACE(format, args...) \
-{ \
- if (mcd_data[unit].debug) { \
- printf("mcd%d: status=0x%02x: ", \
- unit, mcd_data[unit].status); \
- printf(format, ## args); \
- } \
-}
-
-#define mcd_part(dev) ((minor(dev)) & 7)
-#define mcd_unit(dev) (((minor(dev)) & 0x38) >> 3)
-#define mcd_phys(dev) (((minor(dev)) & 0x40) >> 6)
-#define RAW_PART 2
-
-/* flags */
-#define MCDVALID 0x0001 /* parameters loaded */
-#define MCDINIT 0x0002 /* device is init'd */
-#define MCDNEWMODEL 0x0004 /* device is new model */
-#define MCDLABEL 0x0008 /* label is read */
-#define MCDPROBING 0x0010 /* probing */
-#define MCDREADRAW 0x0020 /* read raw mode (2352 bytes) */
-#define MCDVOLINFO 0x0040 /* already read volinfo */
-#define MCDTOC 0x0080 /* already read toc */
-#define MCDMBXBSY 0x0100 /* local mbx is busy */
-
-/* status */
-#define MCDAUDIOBSY MCD_ST_AUDIOBSY /* playing audio */
-#define MCDDSKCHNG MCD_ST_DSKCHNG /* sensed change of disk */
-#define MCDDSKIN MCD_ST_DSKIN /* sensed disk in drive */
-#define MCDDOOROPEN MCD_ST_DOOROPEN /* sensed door open */
-
-/* These are apparently the different states a mitsumi can get up to */
-#define MCDCDABSENT 0x0030
-#define MCDCDPRESENT 0x0020
-#define MCDSCLOSED 0x0080
-#define MCDSOPEN 0x00a0
-
-#define MCD_MD_UNKNOWN (-1)
-
-/* toc */
-#define MCD_MAXTOCS 104 /* from the Linux driver */
-#define MCD_LASTPLUS1 170 /* special toc entry */
-
-#define MCD_TYPE_UNKNOWN 0
-#define MCD_TYPE_LU002S 1
-#define MCD_TYPE_LU005S 2
-#define MCD_TYPE_LU006S 3
-#define MCD_TYPE_FX001 4
-#define MCD_TYPE_FX001D 5
-
-struct mcd_mbx {
- short unit;
- short port;
- short retry;
- short nblk;
- int sz;
- u_long skip;
- struct buf *bp;
- int p_offset;
- short count;
- short mode;
-};
-
-static struct mcd_data {
- short type;
- char *name;
- short config;
- short flags;
- u_char read_command;
- short status;
- int blksize;
- u_long disksize;
- int iobase;
- struct disklabel dlabel;
- int partflags[MAXPARTITIONS];
- int openflags;
- struct mcd_volinfo volinfo;
- struct mcd_qchninfo toc[MCD_MAXTOCS];
- short audio_status;
- short curr_mode;
- struct mcd_read2 lastpb;
- short debug;
- struct buf_queue_head head; /* head of buf queue */
- struct mcd_mbx mbx;
-} mcd_data[NMCD];
-
-/* reader state machine */
-#define MCD_S_BEGIN 0
-#define MCD_S_BEGIN1 1
-#define MCD_S_WAITSTAT 2
-#define MCD_S_WAITMODE 3
-#define MCD_S_WAITREAD 4
-
-/* prototypes */
-static void mcd_start(int unit);
-static int mcd_getdisklabel(int unit);
-#ifdef NOTYET
-static void mcd_configure(struct mcd_data *cd);
-#endif
-static int mcd_get(int unit, char *buf, int nmax);
-static int mcd_setflags(int unit,struct mcd_data *cd);
-static int mcd_getstat(int unit,int sflg);
-static int mcd_send(int unit, int cmd,int nretrys);
-static void hsg2msf(int hsg, bcd_t *msf);
-static int msf2hsg(bcd_t *msf, int relative);
-static int mcd_volinfo(int unit);
-static ointhand2_t mcdintr;
-static int mcd_waitrdy(int port,int dly);
-static timeout_t mcd_timeout;
-static void mcd_doread(int state, struct mcd_mbx *mbxin);
-static void mcd_soft_reset(int unit);
-static int mcd_hard_reset(int unit);
-static int mcd_setmode(int unit, int mode);
-static int mcd_getqchan(int unit, struct mcd_qchninfo *q);
-static int mcd_subchan(int unit, struct ioc_read_subchannel *sc);
-static int mcd_toc_header(int unit, struct ioc_toc_header *th);
-static int mcd_read_toc(int unit);
-static int mcd_toc_entrys(int unit, struct ioc_read_toc_entry *te);
-#if 0
-static int mcd_toc_entry(int unit, struct ioc_read_toc_single_entry *te);
-#endif
-static int mcd_stop(int unit);
-static int mcd_eject(int unit);
-static int mcd_inject(int unit);
-static int mcd_playtracks(int unit, struct ioc_play_track *pt);
-static int mcd_play(int unit, struct mcd_read2 *pb);
-static int mcd_playmsf(int unit, struct ioc_play_msf *pt);
-static int mcd_playblocks(int unit, struct ioc_play_blocks *);
-static int mcd_pause(int unit);
-static int mcd_resume(int unit);
-static int mcd_lock_door(int unit, int lock);
-static int mcd_close_tray(int unit);
-
-static int mcd_probe(struct isa_device *dev);
-static int mcd_attach(struct isa_device *dev);
-struct isa_driver mcddriver = { mcd_probe, mcd_attach, "mcd" };
-
-static d_open_t mcdopen;
-static d_close_t mcdclose;
-static d_ioctl_t mcdioctl;
-static d_psize_t mcdsize;
-static d_strategy_t mcdstrategy;
-
-#define CDEV_MAJOR 29
-#define BDEV_MAJOR 7
-
-
-
-static struct cdevsw mcd_cdevsw = {
- /* open */ mcdopen,
- /* close */ mcdclose,
- /* read */ physread,
- /* write */ nowrite,
- /* ioctl */ mcdioctl,
- /* poll */ nopoll,
- /* mmap */ nommap,
- /* strategy */ mcdstrategy,
- /* name */ "mcd",
- /* maj */ CDEV_MAJOR,
- /* dump */ nodump,
- /* psize */ nopsize,
- /* flags */ D_DISK,
- /* bmaj */ BDEV_MAJOR
-};
-
-#define mcd_put(port,byte) outb(port,byte)
-
-#define MCD_RETRYS 5
-#define MCD_RDRETRYS 8
-
-#define CLOSE_TRAY_SECS 8
-#define DISK_SENSE_SECS 3
-#define WAIT_FRAC 4
-
-/* several delays */
-#define RDELAY_WAITSTAT 300
-#define RDELAY_WAITMODE 300
-#define RDELAY_WAITREAD 800
-
-#define MIN_DELAY 15
-#define DELAY_GETREPLY 5000000
-
-int mcd_attach(struct isa_device *dev)
-{
- int unit = dev->id_unit;
- struct mcd_data *cd = mcd_data + unit;
-
- dev->id_ointr = mcdintr;
- cd->iobase = dev->id_iobase;
- cd->flags |= MCDINIT;
- mcd_soft_reset(unit);
- bufq_init(&cd->head);
-
-#ifdef NOTYET
- /* wire controller for interrupts and dma */
- mcd_configure(cd);
-#endif
- /* name filled in probe */
- make_dev(&mcd_cdevsw, dkmakeminor(unit, 0, 0),
- UID_ROOT, GID_OPERATOR, 0640, "rmcd%da", unit);
- make_dev(&mcd_cdevsw, dkmakeminor(unit, 0, RAW_PART),
- UID_ROOT, GID_OPERATOR, 0640, "rmcd%dc", unit);
- make_dev(&mcd_cdevsw, dkmakeminor(unit, 0, 0),
- UID_ROOT, GID_OPERATOR, 0640, "mcd%da", unit);
- make_dev(&mcd_cdevsw, dkmakeminor(unit, 0, RAW_PART),
- UID_ROOT, GID_OPERATOR, 0640, "mcd%dc", unit);
- return 1;
-}
-
-int mcdopen(dev_t dev, int flags, int fmt, struct proc *p)
-{
- int unit,part,phys,r,retry;
- struct mcd_data *cd;
-
- unit = mcd_unit(dev);
- if (unit >= NMCD)
- return ENXIO;
-
- cd = mcd_data + unit;
- part = mcd_part(dev);
- phys = mcd_phys(dev);
-
- /* not initialized*/
- if (!(cd->flags & MCDINIT))
- return ENXIO;
-
- /* invalidated in the meantime? mark all open part's invalid */
- if (!(cd->flags & MCDVALID) && cd->openflags)
- return ENXIO;
-
- if (mcd_getstat(unit,1) == -1)
- return EIO;
-
- if ( (cd->status & (MCDDSKCHNG|MCDDOOROPEN))
- || !(cd->status & MCDDSKIN))
- for (retry = 0; retry < DISK_SENSE_SECS * WAIT_FRAC; retry++) {
- (void) tsleep((caddr_t)cd, PSOCK | PCATCH, "mcdsn1", hz/WAIT_FRAC);
- if ((r = mcd_getstat(unit,1)) == -1)
- return EIO;
- if (r != -2)
- break;
- }
-
- if (( (cd->status & (MCDDOOROPEN|MCDDSKCHNG))
- || !(cd->status & MCDDSKIN)
- )
- && major(dev) == CDEV_MAJOR && part == RAW_PART
- ) {
- cd->openflags |= (1<<part);
- if (phys)
- cd->partflags[part] |= MCDREADRAW;
- return 0;
- }
- if (cd->status & MCDDOOROPEN) {
- printf("mcd%d: door is open\n", unit);
- return ENXIO;
- }
- if (!(cd->status & MCDDSKIN)) {
- printf("mcd%d: no CD inside\n", unit);
- return ENXIO;
- }
- if (cd->status & MCDDSKCHNG) {
- printf("mcd%d: CD not sensed\n", unit);
- return ENXIO;
- }
-
- if (mcdsize(dev) < 0) {
- if (major(dev) == CDEV_MAJOR && part == RAW_PART) {
- cd->openflags |= (1<<part);
- if (phys)
- cd->partflags[part] |= MCDREADRAW;
- return 0;
- }
- printf("mcd%d: failed to get disk size\n",unit);
- return ENXIO;
- } else
- cd->flags |= MCDVALID;
-
- /* XXX get a default disklabel */
- mcd_getdisklabel(unit);
-
-MCD_TRACE("open: partition=%d, disksize = %ld, blksize=%d\n",
- part, cd->disksize, cd->blksize);
-
- dev->si_bsize_phys = cd->blksize;
-
- if (part == RAW_PART ||
- (part < cd->dlabel.d_npartitions &&
- cd->dlabel.d_partitions[part].p_fstype != FS_UNUSED)) {
- cd->openflags |= (1<<part);
- if (part == RAW_PART && phys)
- cd->partflags[part] |= MCDREADRAW;
- (void) mcd_lock_door(unit, MCD_LK_LOCK);
- if (!(cd->flags & MCDVALID))
- return ENXIO;
- return 0;
- }
-
- return ENXIO;
-}
-
-int mcdclose(dev_t dev, int flags, int fmt, struct proc *p)
-{
- int unit,part;
- struct mcd_data *cd;
-
- unit = mcd_unit(dev);
- if (unit >= NMCD)
- return ENXIO;
-
- cd = mcd_data + unit;
- part = mcd_part(dev);
-
- if (!(cd->flags & MCDINIT) || !(cd->openflags & (1<<part)))
- return ENXIO;
-
- MCD_TRACE("close: partition=%d\n", part);
-
- (void) mcd_lock_door(unit, MCD_LK_UNLOCK);
- cd->openflags &= ~(1<<part);
- cd->partflags[part] &= ~MCDREADRAW;
-
- return 0;
-}
-
-void
-mcdstrategy(struct buf *bp)
-{
- struct mcd_data *cd;
- int s;
-
- int unit = mcd_unit(bp->b_dev);
-
- cd = mcd_data + unit;
-
- /* test validity */
-/*MCD_TRACE("strategy: buf=0x%lx, unit=%ld, block#=%ld bcount=%ld\n",
- bp,unit,bp->b_blkno,bp->b_bcount);*/
- if (unit >= NMCD || bp->b_blkno < 0) {
- printf("mcdstrategy: unit = %d, blkno = %ld, bcount = %ld\n",
- unit, (long)bp->b_blkno, bp->b_bcount);
- printf("mcd: mcdstratregy failure");
- bp->b_error = EINVAL;
- bp->b_flags |= B_ERROR;
- goto bad;
- }
-
- /* if device invalidated (e.g. media change, door open), error */
- if (!(cd->flags & MCDVALID)) {
-MCD_TRACE("strategy: drive not valid\n");
- bp->b_error = EIO;
- goto bad;
- }
-
- /* read only */
- if (!(bp->b_flags & B_READ)) {
- bp->b_error = EROFS;
- goto bad;
- }
-
- /* no data to read */
- if (bp->b_bcount == 0)
- goto done;
-
- /* for non raw access, check partition limits */
- if (mcd_part(bp->b_dev) != RAW_PART) {
- if (!(cd->flags & MCDLABEL)) {
- bp->b_error = EIO;
- goto bad;
- }
- /* adjust transfer if necessary */
- if (bounds_check_with_label(bp,&cd->dlabel,1) <= 0) {
- goto done;
- }
- } else {
- bp->b_pblkno = bp->b_blkno;
- bp->b_resid = 0;
- }
-
- /* queue it */
- s = splbio();
- bufqdisksort(&cd->head, bp);
- splx(s);
-
- /* now check whether we can perform processing */
- mcd_start(unit);
- return;
-
-bad:
- bp->b_flags |= B_ERROR;
-done:
- bp->b_resid = bp->b_bcount;
- biodone(bp);
- return;
-}
-
-static void mcd_start(int unit)
-{
- struct mcd_data *cd = mcd_data + unit;
- struct partition *p;
- struct buf *bp;
- int s = splbio();
-
- if (cd->flags & MCDMBXBSY) {
- splx(s);
- return;
- }
-
- bp = bufq_first(&cd->head);
- if (bp != 0) {
- /* block found to process, dequeue */
- /*MCD_TRACE("mcd_start: found block bp=0x%x\n",bp,0,0,0);*/
- bufq_remove(&cd->head, bp);
- splx(s);
- } else {
- /* nothing to do */
- splx(s);
- return;
- }
-
- /* changed media? */
- if (!(cd->flags & MCDVALID)) {
- MCD_TRACE("mcd_start: drive not valid\n");
- return;
- }
-
- p = cd->dlabel.d_partitions + mcd_part(bp->b_dev);
-
- cd->flags |= MCDMBXBSY;
- if (cd->partflags[mcd_part(bp->b_dev)] & MCDREADRAW)
- cd->flags |= MCDREADRAW;
- cd->mbx.unit = unit;
- cd->mbx.port = cd->iobase;
- cd->mbx.retry = MCD_RETRYS;
- cd->mbx.bp = bp;
- cd->mbx.p_offset = p->p_offset;
-
- /* calling the read routine */
- mcd_doread(MCD_S_BEGIN,&(cd->mbx));
- /* triggers mcd_start, when successful finished */
- return;
-}
-
-int mcdioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p)
-{
- struct mcd_data *cd;
- int unit,part,retry,r;
-
- unit = mcd_unit(dev);
- part = mcd_part(dev);
- cd = mcd_data + unit;
-
- if (mcd_getstat(unit, 1) == -1) /* detect disk change too */
- return EIO;
-MCD_TRACE("ioctl called 0x%lx\n", cmd);
-
- switch (cmd) {
- case CDIOCSETPATCH:
- case CDIOCGETVOL:
- case CDIOCSETVOL:
- case CDIOCSETMONO:
- case CDIOCSETSTERIO:
- case CDIOCSETMUTE:
- case CDIOCSETLEFT:
- case CDIOCSETRIGHT:
- return EINVAL;
- case CDIOCEJECT:
- return mcd_eject(unit);
- case CDIOCSETDEBUG:
- cd->debug = 1;
- return 0;
- case CDIOCCLRDEBUG:
- cd->debug = 0;
- return 0;
- case CDIOCRESET:
- return mcd_hard_reset(unit);
- case CDIOCALLOW:
- return mcd_lock_door(unit, MCD_LK_UNLOCK);
- case CDIOCPREVENT:
- return mcd_lock_door(unit, MCD_LK_LOCK);
- case CDIOCCLOSE:
- return mcd_inject(unit);
- }
-
- if (!(cd->flags & MCDVALID)) {
- if ( major(dev) != CDEV_MAJOR
- || part != RAW_PART
- || !(cd->openflags & (1<<RAW_PART))
- )
- return ENXIO;
- if ( (cd->status & (MCDDSKCHNG|MCDDOOROPEN))
- || !(cd->status & MCDDSKIN))
- for (retry = 0; retry < DISK_SENSE_SECS * WAIT_FRAC; retry++) {
- (void) tsleep((caddr_t)cd, PSOCK | PCATCH, "mcdsn2", hz/WAIT_FRAC);
- if ((r = mcd_getstat(unit,1)) == -1)
- return EIO;
- if (r != -2)
- break;
- }
- if ( (cd->status & (MCDDOOROPEN|MCDDSKCHNG))
- || !(cd->status & MCDDSKIN)
- || mcdsize(dev) < 0
- )
- return ENXIO;
- cd->flags |= MCDVALID;
- mcd_getdisklabel(unit);
- if (mcd_phys(dev))
- cd->partflags[part] |= MCDREADRAW;
- (void) mcd_lock_door(unit, MCD_LK_LOCK);
- if (!(cd->flags & MCDVALID))
- return ENXIO;
- }
-
- switch (cmd) {
- case DIOCGDINFO:
- *(struct disklabel *) addr = cd->dlabel;
- return 0;
- case DIOCGPART:
- ((struct partinfo *) addr)->disklab = &cd->dlabel;
- ((struct partinfo *) addr)->part =
- &cd->dlabel.d_partitions[mcd_part(dev)];
- return 0;
-
- /*
- * a bit silly, but someone might want to test something on a
- * section of cdrom.
- */
- case DIOCWDINFO:
- case DIOCSDINFO:
- if ((flags & FWRITE) == 0)
- return EBADF;
- else {
- return setdisklabel(&cd->dlabel,
- (struct disklabel *) addr,
- 0);
- }
- case DIOCWLABEL:
- return EBADF;
- case CDIOCPLAYTRACKS:
- return mcd_playtracks(unit, (struct ioc_play_track *) addr);
- case CDIOCPLAYBLOCKS:
- return mcd_playblocks(unit, (struct ioc_play_blocks *) addr);
- case CDIOCPLAYMSF:
- return mcd_playmsf(unit, (struct ioc_play_msf *) addr);
- case CDIOCREADSUBCHANNEL:
- return mcd_subchan(unit, (struct ioc_read_subchannel *) addr);
- case CDIOREADTOCHEADER:
- return mcd_toc_header(unit, (struct ioc_toc_header *) addr);
- case CDIOREADTOCENTRYS:
- return mcd_toc_entrys(unit, (struct ioc_read_toc_entry *) addr);
- case CDIOCRESUME:
- return mcd_resume(unit);
- case CDIOCPAUSE:
- return mcd_pause(unit);
- case CDIOCSTART:
- if (mcd_setmode(unit, MCD_MD_COOKED) != 0)
- return EIO;
- return 0;
- case CDIOCSTOP:
- return mcd_stop(unit);
- default:
- return ENOTTY;
- }
- /*NOTREACHED*/
-}
-
-/* this could have been taken from scsi/cd.c, but it is not clear
- * whether the scsi cd driver is linked in
- */
-static int mcd_getdisklabel(int unit)
-{
- struct mcd_data *cd = mcd_data + unit;
-
- if (cd->flags & MCDLABEL)
- return -1;
-
- bzero(&cd->dlabel,sizeof(struct disklabel));
- /* filled with spaces first */
- strncpy(cd->dlabel.d_typename," ",
- sizeof(cd->dlabel.d_typename));
- strncpy(cd->dlabel.d_typename, cd->name,
- min(strlen(cd->name), sizeof(cd->dlabel.d_typename) - 1));
- strncpy(cd->dlabel.d_packname,"unknown ",
- sizeof(cd->dlabel.d_packname));
- cd->dlabel.d_secsize = cd->blksize;
- cd->dlabel.d_nsectors = 100;
- cd->dlabel.d_ntracks = 1;
- cd->dlabel.d_ncylinders = (cd->disksize/100)+1;
- cd->dlabel.d_secpercyl = 100;
- cd->dlabel.d_secperunit = cd->disksize;
- cd->dlabel.d_rpm = 300;
- cd->dlabel.d_interleave = 1;
- cd->dlabel.d_flags = D_REMOVABLE;
- cd->dlabel.d_npartitions= 1;
- cd->dlabel.d_partitions[0].p_offset = 0;
- cd->dlabel.d_partitions[0].p_size = cd->disksize;
- cd->dlabel.d_partitions[0].p_fstype = 9;
- cd->dlabel.d_magic = DISKMAGIC;
- cd->dlabel.d_magic2 = DISKMAGIC;
- cd->dlabel.d_checksum = dkcksum(&cd->dlabel);
-
- cd->flags |= MCDLABEL;
- return 0;
-}
-
-int mcdsize(dev_t dev)
-{
- int size;
- int unit = mcd_unit(dev);
- struct mcd_data *cd = mcd_data + unit;
-
- if (mcd_volinfo(unit) == 0) {
- cd->blksize = MCDBLK;
- size = msf2hsg(cd->volinfo.vol_msf, 0);
- cd->disksize = size * (MCDBLK/DEV_BSIZE);
- return 0;
- }
- return -1;
-}
-
-/***************************************************************
- * lower level of driver starts here
- **************************************************************/
-
-#ifdef NOTDEF
-static char
-irqs[] = {
- 0x00,0x00,0x10,0x20,0x00,0x30,0x00,0x00,
- 0x00,0x10,0x40,0x50,0x00,0x00,0x00,0x00
-};
-
-static char
-drqs[] = {
- 0x00,0x01,0x00,0x03,0x00,0x05,0x06,0x07,
-};
-#endif
-
-#ifdef NOT_YET
-static void
-mcd_configure(struct mcd_data *cd)
-{
- outb(cd->iobase+mcd_config,cd->config);
-}
-#endif
-
-/* Wait for non-busy - return 0 on timeout */
-static int
-twiddle_thumbs(int port, int unit, int count, char *whine)
-{
- int i;
-
- for (i = 0; i < count; i++) {
- if (!(inb(port+MCD_FLAGS) & MFL_STATUS_NOT_AVAIL))
- return 1;
- }
- if (bootverbose)
- printf("mcd%d: timeout %s\n", unit, whine);
- return 0;
-}
-
-/* check to see if a Mitsumi CD-ROM is attached to the ISA bus */
-
-int
-mcd_probe(struct isa_device *dev)
-{
- int port = dev->id_iobase;
- int unit = dev->id_unit;
- int i, j;
- unsigned char stbytes[3];
- static int once;
-
- if (!once++)
- cdevsw_add(&mcd_cdevsw);
-
- mcd_data[unit].flags = MCDPROBING;
-
-#ifdef NOTDEF
- /* get irq/drq configuration word */
- mcd_data[unit].config = irqs[dev->id_irq]; /* | drqs[dev->id_drq];*/
-#else
- mcd_data[unit].config = 0;
-#endif
-
- /* send a reset */
- outb(port+MCD_FLAGS, M_RESET);
-
- /*
- * delay awhile by getting any pending garbage (old data) and
- * throwing it away.
- */
- for (i = 1000000; i != 0; i--)
- inb(port+MCD_FLAGS);
-
- /* Get status */
- outb(port+MCD_DATA, MCD_CMDGETSTAT);
- if (!twiddle_thumbs(port, unit, 1000000, "getting status"))
- return 0; /* Timeout */
- /* Get version information */
- outb(port+MCD_DATA, MCD_CMDCONTINFO);
- for (j = 0; j < 3; j++) {
- if (!twiddle_thumbs(port, unit, 3000, "getting version info"))
- return 0;
- stbytes[j] = (inb(port+MCD_DATA) & 0xFF);
- }
- if (stbytes[1] == stbytes[2])
- return 0;
- if (stbytes[2] >= 4 || stbytes[1] != 'M') {
- outb(port+MCD_CTRL, M_PICKLE);
- mcd_data[unit].flags |= MCDNEWMODEL;
- }
- mcd_data[unit].read_command = MCD_CMDSINGLESPEEDREAD;
- switch (stbytes[1]) {
- case 'M':
- if (stbytes[2] <= 2) {
- mcd_data[unit].type = MCD_TYPE_LU002S;
- mcd_data[unit].name = "Mitsumi LU002S";
- } else if (stbytes[2] <= 5) {
- mcd_data[unit].type = MCD_TYPE_LU005S;
- mcd_data[unit].name = "Mitsumi LU005S";
- } else {
- mcd_data[unit].type = MCD_TYPE_LU006S;
- mcd_data[unit].name = "Mitsumi LU006S";
- }
- break;
- case 'F':
- mcd_data[unit].type = MCD_TYPE_FX001;
- mcd_data[unit].name = "Mitsumi FX001";
- break;
- case 'D':
- mcd_data[unit].type = MCD_TYPE_FX001D;
- mcd_data[unit].name = "Mitsumi FX001D";
- mcd_data[unit].read_command = MCD_CMDDOUBLESPEEDREAD;
- break;
- default:
- mcd_data[unit].type = MCD_TYPE_UNKNOWN;
- mcd_data[unit].name = "Mitsumi ???";
- break;
- }
- printf("mcd%d: type %s, version info: %c %x\n", unit, mcd_data[unit].name,
- stbytes[1], stbytes[2]);
-
- return 4;
-}
-
-
-static int
-mcd_waitrdy(int port,int dly)
-{
- int i;
-
- /* wait until flag port senses status ready */
- for (i=0; i<dly; i+=MIN_DELAY) {
- if (!(inb(port+MCD_FLAGS) & MFL_STATUS_NOT_AVAIL))
- return 0;
- DELAY(MIN_DELAY);
- }
- return -1;
-}
-
-static int
-mcd_getreply(int unit,int dly)
-{
- struct mcd_data *cd = mcd_data + unit;
- int port = cd->iobase;
-
- /* wait data to become ready */
- if (mcd_waitrdy(port,dly)<0) {
- printf("mcd%d: timeout getreply\n",unit);
- return -1;
- }
-
- /* get the data */
- return inb(port+mcd_status) & 0xFF;
-}
-
-static int
-mcd_getstat(int unit,int sflg)
-{
- int i;
- struct mcd_data *cd = mcd_data + unit;
- int port = cd->iobase;
-
- /* get the status */
- if (sflg)
- outb(port+mcd_command, MCD_CMDGETSTAT);
- i = mcd_getreply(unit,DELAY_GETREPLY);
- if (i<0 || (i & MCD_ST_CMDCHECK)) {
- cd->curr_mode = MCD_MD_UNKNOWN;
- return -1;
- }
-
- cd->status = i;
-
- if (mcd_setflags(unit,cd) < 0)
- return -2;
- return cd->status;
-}
-
-static int
-mcd_setflags(int unit, struct mcd_data *cd)
-{
- /* check flags */
- if ( (cd->status & (MCDDSKCHNG|MCDDOOROPEN))
- || !(cd->status & MCDDSKIN)) {
- MCD_TRACE("setflags: sensed DSKCHNG or DOOROPEN or !DSKIN\n");
- mcd_soft_reset(unit);
- return -1;
- }
-
- if (cd->status & MCDAUDIOBSY)
- cd->audio_status = CD_AS_PLAY_IN_PROGRESS;
- else if (cd->audio_status == CD_AS_PLAY_IN_PROGRESS)
- cd->audio_status = CD_AS_PLAY_COMPLETED;
- return 0;
-}
-
-static int
-mcd_get(int unit, char *buf, int nmax)
-{
- int i,k;
-
- for (i=0; i<nmax; i++) {
- /* wait for data */
- if ((k = mcd_getreply(unit,DELAY_GETREPLY)) < 0) {
- printf("mcd%d: timeout mcd_get\n",unit);
- return -1;
- }
- buf[i] = k;
- }
- return i;
-}
-
-static int
-mcd_send(int unit, int cmd,int nretrys)
-{
- int i,k=0;
- int port = mcd_data[unit].iobase;
-
-/*MCD_TRACE("mcd_send: command = 0x%02x\n",cmd,0,0,0);*/
- for (i=0; i<nretrys; i++) {
- outb(port+mcd_command, cmd);
- if ((k=mcd_getstat(unit,0)) != -1)
- break;
- }
- if (k == -2) {
- printf("mcd%d: media changed\n",unit);
- return -1;
- }
- if (i == nretrys) {
- printf("mcd%d: mcd_send retry cnt exceeded\n",unit);
- return -1;
- }
-/*MCD_TRACE("mcd_send: done\n",0,0,0,0);*/
- return 0;
-}
-
-static void
-hsg2msf(int hsg, bcd_t *msf)
-{
- hsg += 150;
- F_msf(msf) = bin2bcd(hsg % 75);
- hsg /= 75;
- S_msf(msf) = bin2bcd(hsg % 60);
- hsg /= 60;
- M_msf(msf) = bin2bcd(hsg);
-}
-
-static int
-msf2hsg(bcd_t *msf, int relative)
-{
- return (bcd2bin(M_msf(msf)) * 60 + bcd2bin(S_msf(msf))) * 75 +
- bcd2bin(F_msf(msf)) - (!relative) * 150;
-}
-
-static int
-mcd_volinfo(int unit)
-{
- struct mcd_data *cd = mcd_data + unit;
-
- /* Just return if we already have it */
- if (cd->flags & MCDVOLINFO) return 0;
-
-/*MCD_TRACE("mcd_volinfo: enter\n",0,0,0,0);*/
-
- /* send volume info command */
- if (mcd_send(unit,MCD_CMDGETVOLINFO,MCD_RETRYS) < 0)
- return EIO;
-
- /* get data */
- if (mcd_get(unit,(char*) &cd->volinfo,sizeof(struct mcd_volinfo)) < 0) {
- printf("mcd%d: mcd_volinfo: error read data\n",unit);
- return EIO;
- }
-
- if (cd->volinfo.trk_low > 0 &&
- cd->volinfo.trk_high >= cd->volinfo.trk_low
- ) {
- cd->flags |= MCDVOLINFO; /* volinfo is OK */
- return 0;
- }
-
- return EINVAL;
-}
-
-static void
-mcdintr(unit)
- int unit;
-{
- MCD_TRACE("stray interrupt\n");
-}
-
-/* state machine to process read requests
- * initialize with MCD_S_BEGIN: calculate sizes, and read status
- * MCD_S_WAITSTAT: wait for status reply, set mode
- * MCD_S_WAITMODE: waits for status reply from set mode, set read command
- * MCD_S_WAITREAD: wait for read ready, read data
- */
-static struct mcd_mbx *mbxsave;
-static struct callout_handle tohandle = CALLOUT_HANDLE_INITIALIZER(&tohandle);
-
-static void
-mcd_timeout(void *arg)
-{
- mcd_doread((int)arg, mbxsave);
-}
-
-static void
-mcd_doread(int state, struct mcd_mbx *mbxin)
-{
- struct mcd_mbx *mbx = (state!=MCD_S_BEGIN) ? mbxsave : mbxin;
- int unit = mbx->unit;
- int port = mbx->port;
- int com_port = mbx->port + mcd_command;
- int data_port = mbx->port + mcd_rdata;
- struct buf *bp = mbx->bp;
- struct mcd_data *cd = mcd_data + unit;
-
- int rm,i,k;
- struct mcd_read2 rbuf;
- int blknum;
- caddr_t addr;
-
-loop:
- switch (state) {
- case MCD_S_BEGIN:
- mbx = mbxsave = mbxin;
-
- case MCD_S_BEGIN1:
-retry_status:
- /* get status */
- outb(com_port, MCD_CMDGETSTAT);
- mbx->count = RDELAY_WAITSTAT;
- tohandle = timeout(mcd_timeout,
- (caddr_t)MCD_S_WAITSTAT,hz/100); /* XXX */
- return;
- case MCD_S_WAITSTAT:
- untimeout(mcd_timeout,(caddr_t)MCD_S_WAITSTAT, tohandle);
- if (mbx->count-- >= 0) {
- if (inb(port+MCD_FLAGS) & MFL_STATUS_NOT_AVAIL) {
- timeout(mcd_timeout,
- (caddr_t)MCD_S_WAITSTAT,hz/100); /* XXX */
- return;
- }
- cd->status = inb(port+mcd_status) & 0xFF;
- if (cd->status & MCD_ST_CMDCHECK)
- goto retry_status;
- if (mcd_setflags(unit,cd) < 0)
- goto changed;
- MCD_TRACE("got WAITSTAT delay=%d\n",
- RDELAY_WAITSTAT-mbx->count);
- /* reject, if audio active */
- if (cd->status & MCDAUDIOBSY) {
- printf("mcd%d: audio is active\n",unit);
- goto readerr;
- }
-
-retry_mode:
- /* to check for raw/cooked mode */
- if (cd->flags & MCDREADRAW) {
- rm = MCD_MD_RAW;
- mbx->sz = MCDRBLK;
- } else {
- rm = MCD_MD_COOKED;
- mbx->sz = cd->blksize;
- }
-
- if (rm == cd->curr_mode)
- goto modedone;
-
- mbx->count = RDELAY_WAITMODE;
-
- cd->curr_mode = MCD_MD_UNKNOWN;
- mbx->mode = rm;
- mcd_put(com_port, MCD_CMDSETMODE);
- mcd_put(com_port, rm);
-
- tohandle = timeout(mcd_timeout,
- (caddr_t)MCD_S_WAITMODE,hz/100); /* XXX */
- return;
- } else {
- printf("mcd%d: timeout getstatus\n",unit);
- goto readerr;
- }
-
- case MCD_S_WAITMODE:
- untimeout(mcd_timeout,(caddr_t)MCD_S_WAITMODE, tohandle);
- if (mbx->count-- < 0) {
- printf("mcd%d: timeout set mode\n",unit);
- goto readerr;
- }
- if (inb(port+MCD_FLAGS) & MFL_STATUS_NOT_AVAIL) {
- tohandle = timeout(mcd_timeout,
- (caddr_t)MCD_S_WAITMODE,hz/100);
- return;
- }
- cd->status = inb(port+mcd_status) & 0xFF;
- if (cd->status & MCD_ST_CMDCHECK) {
- cd->curr_mode = MCD_MD_UNKNOWN;
- goto retry_mode;
- }
- if (mcd_setflags(unit,cd) < 0)
- goto changed;
- cd->curr_mode = mbx->mode;
- MCD_TRACE("got WAITMODE delay=%d\n",
- RDELAY_WAITMODE-mbx->count);
-modedone:
- /* for first block */
- mbx->nblk = (bp->b_bcount + (mbx->sz-1)) / mbx->sz;
- mbx->skip = 0;
-
-nextblock:
- blknum = (bp->b_blkno / (mbx->sz/DEV_BSIZE))
- + mbx->p_offset + mbx->skip/mbx->sz;
-
- MCD_TRACE("mcd_doread: read blknum=%d for bp=%p\n",
- blknum, bp);
-
- /* build parameter block */
- hsg2msf(blknum,rbuf.start_msf);
-retry_read:
- /* send the read command */
- disable_intr();
- mcd_put(com_port,cd->read_command);
- mcd_put(com_port,rbuf.start_msf[0]);
- mcd_put(com_port,rbuf.start_msf[1]);
- mcd_put(com_port,rbuf.start_msf[2]);
- mcd_put(com_port,0);
- mcd_put(com_port,0);
- mcd_put(com_port,1);
- enable_intr();
-
- /* Spin briefly (<= 2ms) to avoid missing next block */
- for (i = 0; i < 20; i++) {
- k = inb(port+MCD_FLAGS);
- if (!(k & MFL_DATA_NOT_AVAIL))
- goto got_it;
- DELAY(100);
- }
-
- mbx->count = RDELAY_WAITREAD;
- tohandle = timeout(mcd_timeout,
- (caddr_t)MCD_S_WAITREAD,hz/100); /* XXX */
- return;
- case MCD_S_WAITREAD:
- untimeout(mcd_timeout,(caddr_t)MCD_S_WAITREAD, tohandle);
- if (mbx->count-- > 0) {
- k = inb(port+MCD_FLAGS);
- if (!(k & MFL_DATA_NOT_AVAIL)) { /* XXX */
- MCD_TRACE("got data delay=%d\n",
- RDELAY_WAITREAD-mbx->count);
- got_it:
- /* data is ready */
- addr = bp->b_data + mbx->skip;
-
- outb(port+mcd_ctl2,0x04); /* XXX */
- for (i=0; i<mbx->sz; i++)
- *addr++ = inb(data_port);
- outb(port+mcd_ctl2,0x0c); /* XXX */
-
- k = inb(port+MCD_FLAGS);
- /* If we still have some junk, read it too */
- if (!(k & MFL_DATA_NOT_AVAIL)) {
- outb(port+mcd_ctl2,0x04); /* XXX */
- (void)inb(data_port);
- (void)inb(data_port);
- outb(port+mcd_ctl2,0x0c); /* XXX */
- }
-
- if (--mbx->nblk > 0) {
- mbx->skip += mbx->sz;
- goto nextblock;
- }
-
- /* return buffer */
- bp->b_resid = 0;
- biodone(bp);
-
- cd->flags &= ~(MCDMBXBSY|MCDREADRAW);
- mcd_start(mbx->unit);
- return;
- }
- if (!(k & MFL_STATUS_NOT_AVAIL)) {
- cd->status = inb(port+mcd_status) & 0xFF;
- if (cd->status & MCD_ST_CMDCHECK)
- goto retry_read;
- if (mcd_setflags(unit,cd) < 0)
- goto changed;
- }
- tohandle = timeout(mcd_timeout,
- (caddr_t)MCD_S_WAITREAD,hz/100); /* XXX */
- return;
- } else {
- printf("mcd%d: timeout read data\n",unit);
- goto readerr;
- }
- }
-
-readerr:
- if (mbx->retry-- > 0) {
- printf("mcd%d: retrying\n",unit);
- state = MCD_S_BEGIN1;
- goto loop;
- }
-harderr:
- /* invalidate the buffer */
- bp->b_flags |= B_ERROR;
- bp->b_resid = bp->b_bcount;
- biodone(bp);
-
- cd->flags &= ~(MCDMBXBSY|MCDREADRAW);
- mcd_start(mbx->unit);
- return;
-
-changed:
- printf("mcd%d: media changed\n", unit);
- goto harderr;
-
-#ifdef NOTDEF
- printf("mcd%d: unit timeout, resetting\n",mbx->unit);
- outb(mbx->port+mcd_reset,MCD_CMDRESET);
- DELAY(300000);
- (void)mcd_getstat(mbx->unit,1);
- (void)mcd_getstat(mbx->unit,1);
- /*cd->status &= ~MCDDSKCHNG; */
- cd->debug = 1; /* preventive set debug mode */
-
-#endif
-
-}
-
-static int
-mcd_lock_door(int unit, int lock)
-{
- struct mcd_data *cd = mcd_data + unit;
- int port = cd->iobase;
-
- outb(port+mcd_command, MCD_CMDLOCKDRV);
- outb(port+mcd_command, lock);
- if (mcd_getstat(unit,0) == -1)
- return EIO;
- return 0;
-}
-
-static int
-mcd_close_tray(int unit)
-{
- struct mcd_data *cd = mcd_data + unit;
- int port = cd->iobase;
- int retry, r;
-
- if (mcd_getstat(unit,1) == -1)
- return EIO;
- if (cd->status & MCDDOOROPEN) {
- outb(port+mcd_command, MCD_CMDCLOSETRAY);
- for (retry = 0; retry < CLOSE_TRAY_SECS * WAIT_FRAC; retry++) {
- if (inb(port+MCD_FLAGS) & MFL_STATUS_NOT_AVAIL)
- (void) tsleep((caddr_t)cd, PSOCK | PCATCH, "mcdcls", hz/WAIT_FRAC);
- else {
- if ((r = mcd_getstat(unit,0)) == -1)
- return EIO;
- return 0;
- }
- }
- return ENXIO;
- }
- return 0;
-}
-
-static int
-mcd_eject(int unit)
-{
- struct mcd_data *cd = mcd_data + unit;
- int port = cd->iobase, r;
-
- if (mcd_getstat(unit,1) == -1) /* detect disk change too */
- return EIO;
- if (cd->status & MCDDOOROPEN)
- return 0;
- if ((r = mcd_stop(unit)) == EIO)
- return r;
- outb(port+mcd_command, MCD_CMDEJECTDISK);
- if (mcd_getstat(unit,0) == -1)
- return EIO;
- return 0;
-}
-
-static int
-mcd_inject(int unit)
-{
- struct mcd_data *cd = mcd_data + unit;
-
- if (mcd_getstat(unit,1) == -1) /* detect disk change too */
- return EIO;
- if (cd->status & MCDDOOROPEN)
- return mcd_close_tray(unit);
- return 0;
-}
-
-static int
-mcd_hard_reset(int unit)
-{
- struct mcd_data *cd = mcd_data + unit;
- int port = cd->iobase;
-
- outb(port+mcd_reset,MCD_CMDRESET);
- cd->curr_mode = MCD_MD_UNKNOWN;
- cd->audio_status = CD_AS_AUDIO_INVALID;
- return 0;
-}
-
-static void
-mcd_soft_reset(int unit)
-{
- struct mcd_data *cd = mcd_data + unit;
- int i;
-
- cd->flags &= (MCDINIT|MCDPROBING|MCDNEWMODEL);
- cd->curr_mode = MCD_MD_UNKNOWN;
- for (i=0; i<MAXPARTITIONS; i++) cd->partflags[i] = 0;
- cd->audio_status = CD_AS_AUDIO_INVALID;
-}
-
-static int
-mcd_setmode(int unit, int mode)
-{
- struct mcd_data *cd = mcd_data + unit;
- int port = cd->iobase;
- int retry, st;
-
- if (cd->curr_mode == mode)
- return 0;
- if (cd->debug)
- printf("mcd%d: setting mode to %d\n", unit, mode);
- for(retry=0; retry<MCD_RETRYS; retry++)
- {
- cd->curr_mode = MCD_MD_UNKNOWN;
- outb(port+mcd_command, MCD_CMDSETMODE);
- outb(port+mcd_command, mode);
- if ((st = mcd_getstat(unit, 0)) >= 0) {
- cd->curr_mode = mode;
- return 0;
- }
- if (st == -2) {
- printf("mcd%d: media changed\n", unit);
- break;
- }
- }
-
- return -1;
-}
-
-static int
-mcd_toc_header(int unit, struct ioc_toc_header *th)
-{
- struct mcd_data *cd = mcd_data + unit;
- int r;
-
- if ((r = mcd_volinfo(unit)) != 0)
- return r;
-
- th->starting_track = bcd2bin(cd->volinfo.trk_low);
- th->ending_track = bcd2bin(cd->volinfo.trk_high);
- th->len = 2 * sizeof(u_char) /* start & end tracks */ +
- (th->ending_track + 1 - th->starting_track + 1) *
- sizeof(struct cd_toc_entry);
-
- return 0;
-}
-
-static int
-mcd_read_toc(int unit)
-{
- struct mcd_data *cd = mcd_data + unit;
- struct ioc_toc_header th;
- struct mcd_qchninfo q;
- int rc, trk, idx, retry;
-
- /* Only read TOC if needed */
- if (cd->flags & MCDTOC)
- return 0;
-
- if (cd->debug)
- printf("mcd%d: reading toc header\n", unit);
-
- if ((rc = mcd_toc_header(unit, &th)) != 0)
- return rc;
-
- if (mcd_send(unit, MCD_CMDSTOPAUDIO, MCD_RETRYS) < 0)
- return EIO;
-
- if (mcd_setmode(unit, MCD_MD_TOC) != 0)
- return EIO;
-
- if (cd->debug)
- printf("mcd%d: get_toc reading qchannel info\n",unit);
-
- for(trk=th.starting_track; trk<=th.ending_track; trk++)
- cd->toc[trk].idx_no = 0;
- trk = th.ending_track - th.starting_track + 1;
- for(retry=0; retry<600 && trk>0; retry++)
- {
- if (mcd_getqchan(unit, &q) < 0) break;
- idx = bcd2bin(q.idx_no);
- if (idx>=th.starting_track && idx<=th.ending_track && q.trk_no==0) {
- if (cd->toc[idx].idx_no == 0) {
- cd->toc[idx] = q;
- trk--;
- }
- }
- }
-
- if (mcd_setmode(unit, MCD_MD_COOKED) != 0)
- return EIO;
-
- if (trk != 0)
- return ENXIO;
-
- /* add a fake last+1 */
- idx = th.ending_track + 1;
- cd->toc[idx].control = cd->toc[idx-1].control;
- cd->toc[idx].addr_type = cd->toc[idx-1].addr_type;
- cd->toc[idx].trk_no = 0;
- cd->toc[idx].idx_no = MCD_LASTPLUS1;
- cd->toc[idx].hd_pos_msf[0] = cd->volinfo.vol_msf[0];
- cd->toc[idx].hd_pos_msf[1] = cd->volinfo.vol_msf[1];
- cd->toc[idx].hd_pos_msf[2] = cd->volinfo.vol_msf[2];
-
- if (cd->debug)
- { int i;
- for (i = th.starting_track; i <= idx; i++)
- printf("mcd%d: trk %d idx %d pos %d %d %d\n",
- unit, i,
- cd->toc[i].idx_no > 0x99 ? cd->toc[i].idx_no :
- bcd2bin(cd->toc[i].idx_no),
- bcd2bin(cd->toc[i].hd_pos_msf[0]),
- bcd2bin(cd->toc[i].hd_pos_msf[1]),
- bcd2bin(cd->toc[i].hd_pos_msf[2]));
- }
-
- cd->flags |= MCDTOC;
-
- return 0;
-}
-
-#if 0
-static int
-mcd_toc_entry(int unit, struct ioc_read_toc_single_entry *te)
-{
- struct mcd_data *cd = mcd_data + unit;
- struct ioc_toc_header th;
- int rc, trk;
-
- if (te->address_format != CD_MSF_FORMAT
- && te->address_format != CD_LBA_FORMAT)
- return EINVAL;
-
- /* Copy the toc header */
- if ((rc = mcd_toc_header(unit, &th)) != 0)
- return rc;
-
- /* verify starting track */
- trk = te->track;
- if (trk == 0)
- trk = th.starting_track;
- else if (trk == MCD_LASTPLUS1)
- trk = th.ending_track + 1;
- else if (trk < th.starting_track || trk > th.ending_track + 1)
- return EINVAL;
-
- /* Make sure we have a valid toc */
- if ((rc=mcd_read_toc(unit)) != 0)
- return rc;
-
- /* Copy the TOC data. */
- if (cd->toc[trk].idx_no == 0)
- return EIO;
-
- te->entry.control = cd->toc[trk].control;
- te->entry.addr_type = cd->toc[trk].addr_type;
- te->entry.track =
- cd->toc[trk].idx_no > 0x99 ? cd->toc[trk].idx_no :
- bcd2bin(cd->toc[trk].idx_no);
- switch (te->address_format) {
- case CD_MSF_FORMAT:
- te->entry.addr.msf.unused = 0;
- te->entry.addr.msf.minute = bcd2bin(cd->toc[trk].hd_pos_msf[0]);
- te->entry.addr.msf.second = bcd2bin(cd->toc[trk].hd_pos_msf[1]);
- te->entry.addr.msf.frame = bcd2bin(cd->toc[trk].hd_pos_msf[2]);
- break;
- case CD_LBA_FORMAT:
- te->entry.addr.lba = htonl(msf2hsg(cd->toc[trk].hd_pos_msf, 0));
- break;
- }
- return 0;
-}
-#endif
-
-static int
-mcd_toc_entrys(int unit, struct ioc_read_toc_entry *te)
-{
- struct mcd_data *cd = mcd_data + unit;
- struct cd_toc_entry entries[MCD_MAXTOCS];
- struct ioc_toc_header th;
- int rc, n, trk, len;
-
- if ( te->data_len < sizeof(entries[0])
- || (te->data_len % sizeof(entries[0])) != 0
- || (te->address_format != CD_MSF_FORMAT
- && te->address_format != CD_LBA_FORMAT)
- )
- return EINVAL;
-
- /* Copy the toc header */
- if ((rc = mcd_toc_header(unit, &th)) != 0)
- return rc;
-
- /* verify starting track */
- trk = te->starting_track;
- if (trk == 0)
- trk = th.starting_track;
- else if (trk == MCD_LASTPLUS1)
- trk = th.ending_track + 1;
- else if (trk < th.starting_track || trk > th.ending_track + 1)
- return EINVAL;
-
- len = ((th.ending_track + 1 - trk) + 1) *
- sizeof(entries[0]);
- if (te->data_len < len)
- len = te->data_len;
- if (len > sizeof(entries))
- return EINVAL;
-
- /* Make sure we have a valid toc */
- if ((rc=mcd_read_toc(unit)) != 0)
- return rc;
-
- /* Copy the TOC data. */
- for (n = 0; len > 0 && trk <= th.ending_track + 1; trk++) {
- if (cd->toc[trk].idx_no == 0)
- continue;
- entries[n].control = cd->toc[trk].control;
- entries[n].addr_type = cd->toc[trk].addr_type;
- entries[n].track =
- cd->toc[trk].idx_no > 0x99 ? cd->toc[trk].idx_no :
- bcd2bin(cd->toc[trk].idx_no);
- switch (te->address_format) {
- case CD_MSF_FORMAT:
- entries[n].addr.msf.unused = 0;
- entries[n].addr.msf.minute = bcd2bin(cd->toc[trk].hd_pos_msf[0]);
- entries[n].addr.msf.second = bcd2bin(cd->toc[trk].hd_pos_msf[1]);
- entries[n].addr.msf.frame = bcd2bin(cd->toc[trk].hd_pos_msf[2]);
- break;
- case CD_LBA_FORMAT:
- entries[n].addr.lba = htonl(msf2hsg(cd->toc[trk].hd_pos_msf, 0));
- break;
- }
- len -= sizeof(struct cd_toc_entry);
- n++;
- }
-
- /* copy the data back */
- return copyout(entries, te->data, n * sizeof(struct cd_toc_entry));
-}
-
-static int
-mcd_stop(int unit)
-{
- struct mcd_data *cd = mcd_data + unit;
-
- /* Verify current status */
- if (cd->audio_status != CD_AS_PLAY_IN_PROGRESS &&
- cd->audio_status != CD_AS_PLAY_PAUSED &&
- cd->audio_status != CD_AS_PLAY_COMPLETED) {
- if (cd->debug)
- printf("mcd%d: stop attempted when not playing, audio status %d\n",
- unit, cd->audio_status);
- return EINVAL;
- }
- if (cd->audio_status == CD_AS_PLAY_IN_PROGRESS)
- if (mcd_send(unit, MCD_CMDSTOPAUDIO, MCD_RETRYS) < 0)
- return EIO;
- cd->audio_status = CD_AS_PLAY_COMPLETED;
- return 0;
-}
-
-static int
-mcd_getqchan(int unit, struct mcd_qchninfo *q)
-{
- struct mcd_data *cd = mcd_data + unit;
-
- if (mcd_send(unit, MCD_CMDGETQCHN, MCD_RETRYS) < 0)
- return -1;
- if (mcd_get(unit, (char *) q, sizeof(struct mcd_qchninfo)) < 0)
- return -1;
- if (cd->debug) {
- printf("mcd%d: getqchan control=0x%x addr_type=0x%x trk=%d ind=%d ttm=%d:%d.%d dtm=%d:%d.%d\n",
- unit,
- q->control, q->addr_type, bcd2bin(q->trk_no),
- bcd2bin(q->idx_no),
- bcd2bin(q->trk_size_msf[0]), bcd2bin(q->trk_size_msf[1]),
- bcd2bin(q->trk_size_msf[2]),
- bcd2bin(q->hd_pos_msf[0]), bcd2bin(q->hd_pos_msf[1]),
- bcd2bin(q->hd_pos_msf[2]));
- }
- return 0;
-}
-
-static int
-mcd_subchan(int unit, struct ioc_read_subchannel *sc)
-{
- struct mcd_data *cd = mcd_data + unit;
- struct mcd_qchninfo q;
- struct cd_sub_channel_info data;
- int lba;
-
- if (cd->debug)
- printf("mcd%d: subchan af=%d, df=%d\n", unit,
- sc->address_format,
- sc->data_format);
-
- if (sc->address_format != CD_MSF_FORMAT &&
- sc->address_format != CD_LBA_FORMAT)
- return EINVAL;
-
- if (sc->data_format != CD_CURRENT_POSITION &&
- sc->data_format != CD_MEDIA_CATALOG)
- return EINVAL;
-
- if (mcd_setmode(unit, MCD_MD_COOKED) != 0)
- return EIO;
-
- if (mcd_getqchan(unit, &q) < 0)
- return EIO;
-
- data.header.audio_status = cd->audio_status;
- data.what.position.data_format = sc->data_format;
-
- switch (sc->data_format) {
- case CD_MEDIA_CATALOG:
- data.what.media_catalog.mc_valid = 1;
- data.what.media_catalog.mc_number[0] = '\0';
- break;
-
- case CD_CURRENT_POSITION:
- data.what.position.control = q.control;
- data.what.position.addr_type = q.addr_type;
- data.what.position.track_number = bcd2bin(q.trk_no);
- data.what.position.index_number = bcd2bin(q.idx_no);
- switch (sc->address_format) {
- case CD_MSF_FORMAT:
- data.what.position.reladdr.msf.unused = 0;
- data.what.position.reladdr.msf.minute = bcd2bin(q.trk_size_msf[0]);
- data.what.position.reladdr.msf.second = bcd2bin(q.trk_size_msf[1]);
- data.what.position.reladdr.msf.frame = bcd2bin(q.trk_size_msf[2]);
- data.what.position.absaddr.msf.unused = 0;
- data.what.position.absaddr.msf.minute = bcd2bin(q.hd_pos_msf[0]);
- data.what.position.absaddr.msf.second = bcd2bin(q.hd_pos_msf[1]);
- data.what.position.absaddr.msf.frame = bcd2bin(q.hd_pos_msf[2]);
- break;
- case CD_LBA_FORMAT:
- lba = msf2hsg(q.trk_size_msf, 1);
- /*
- * Pre-gap has index number of 0, and decreasing MSF
- * address. Must be converted to negative LBA, per
- * SCSI spec.
- */
- if (data.what.position.index_number == 0)
- lba = -lba;
- data.what.position.reladdr.lba = htonl(lba);
- data.what.position.absaddr.lba = htonl(msf2hsg(q.hd_pos_msf, 0));
- break;
- }
- break;
- }
-
- return copyout(&data, sc->data, min(sizeof(struct cd_sub_channel_info), sc->data_len));
-}
-
-static int
-mcd_playmsf(int unit, struct ioc_play_msf *p)
-{
- struct mcd_data *cd = mcd_data + unit;
- struct mcd_read2 pb;
-
- if (cd->debug)
- printf("mcd%d: playmsf: from %d:%d.%d to %d:%d.%d\n",
- unit,
- p->start_m, p->start_s, p->start_f,
- p->end_m, p->end_s, p->end_f);
-
- if ((p->start_m * 60 * 75 + p->start_s * 75 + p->start_f) >=
- (p->end_m * 60 * 75 + p->end_s * 75 + p->end_f) ||
- (p->end_m * 60 * 75 + p->end_s * 75 + p->end_f) >
- M_msf(cd->volinfo.vol_msf) * 60 * 75 +
- S_msf(cd->volinfo.vol_msf) * 75 +
- F_msf(cd->volinfo.vol_msf))
- return EINVAL;
-
- pb.start_msf[0] = bin2bcd(p->start_m);
- pb.start_msf[1] = bin2bcd(p->start_s);
- pb.start_msf[2] = bin2bcd(p->start_f);
- pb.end_msf[0] = bin2bcd(p->end_m);
- pb.end_msf[1] = bin2bcd(p->end_s);
- pb.end_msf[2] = bin2bcd(p->end_f);
-
- if (mcd_setmode(unit, MCD_MD_COOKED) != 0)
- return EIO;
-
- return mcd_play(unit, &pb);
-}
-
-static int
-mcd_playtracks(int unit, struct ioc_play_track *pt)
-{
- struct mcd_data *cd = mcd_data + unit;
- struct mcd_read2 pb;
- int a = pt->start_track;
- int z = pt->end_track;
- int rc, i;
-
- if ((rc = mcd_read_toc(unit)) != 0)
- return rc;
-
- if (cd->debug)
- printf("mcd%d: playtracks from %d:%d to %d:%d\n", unit,
- a, pt->start_index, z, pt->end_index);
-
- if ( a < bcd2bin(cd->volinfo.trk_low)
- || a > bcd2bin(cd->volinfo.trk_high)
- || a > z
- || z < bcd2bin(cd->volinfo.trk_low)
- || z > bcd2bin(cd->volinfo.trk_high))
- return EINVAL;
-
- for (i = 0; i < 3; i++) {
- pb.start_msf[i] = cd->toc[a].hd_pos_msf[i];
- pb.end_msf[i] = cd->toc[z+1].hd_pos_msf[i];
- }
-
- if (mcd_setmode(unit, MCD_MD_COOKED) != 0)
- return EIO;
-
- return mcd_play(unit, &pb);
-}
-
-static int
-mcd_playblocks(int unit, struct ioc_play_blocks *p)
-{
- struct mcd_data *cd = mcd_data + unit;
- struct mcd_read2 pb;
-
- if (cd->debug)
- printf("mcd%d: playblocks: blkno %d length %d\n",
- unit, p->blk, p->len);
-
- if (p->blk > cd->disksize || p->len > cd->disksize ||
- p->blk < 0 || p->len < 0 ||
- (p->blk + p->len) > cd->disksize)
- return EINVAL;
-
- hsg2msf(p->blk, pb.start_msf);
- hsg2msf(p->blk + p->len, pb.end_msf);
-
- if (mcd_setmode(unit, MCD_MD_COOKED) != 0)
- return EIO;
-
- return mcd_play(unit, &pb);
-}
-
-static int
-mcd_play(int unit, struct mcd_read2 *pb)
-{
- struct mcd_data *cd = mcd_data + unit;
- int com_port = cd->iobase + mcd_command;
- int retry, st = -1, status;
-
- cd->lastpb = *pb;
- for(retry=0; retry<MCD_RETRYS; retry++) {
-
- disable_intr();
- outb(com_port, MCD_CMDSINGLESPEEDREAD);
- outb(com_port, pb->start_msf[0]);
- outb(com_port, pb->start_msf[1]);
- outb(com_port, pb->start_msf[2]);
- outb(com_port, pb->end_msf[0]);
- outb(com_port, pb->end_msf[1]);
- outb(com_port, pb->end_msf[2]);
- enable_intr();
-
- status=mcd_getstat(unit, 0);
- if (status == -1)
- continue;
- else if (status != -2)
- st = 0;
- break;
- }
-
- if (status == -2) {
- printf("mcd%d: media changed\n", unit);
- return ENXIO;
- }
- if (cd->debug)
- printf("mcd%d: mcd_play retry=%d, status=0x%02x\n", unit, retry, status);
- if (st < 0)
- return ENXIO;
- cd->audio_status = CD_AS_PLAY_IN_PROGRESS;
- return 0;
-}
-
-static int
-mcd_pause(int unit)
-{
- struct mcd_data *cd = mcd_data + unit;
- struct mcd_qchninfo q;
- int rc;
-
- /* Verify current status */
- if (cd->audio_status != CD_AS_PLAY_IN_PROGRESS &&
- cd->audio_status != CD_AS_PLAY_PAUSED) {
- if (cd->debug)
- printf("mcd%d: pause attempted when not playing, audio status %d\n",
- unit, cd->audio_status);
- return EINVAL;
- }
-
- /* Get the current position */
- if (mcd_getqchan(unit, &q) < 0)
- return EIO;
-
- /* Copy it into lastpb */
- cd->lastpb.start_msf[0] = q.hd_pos_msf[0];
- cd->lastpb.start_msf[1] = q.hd_pos_msf[1];
- cd->lastpb.start_msf[2] = q.hd_pos_msf[2];
-
- /* Stop playing */
- if ((rc=mcd_stop(unit)) != 0)
- return rc;
-
- /* Set the proper status and exit */
- cd->audio_status = CD_AS_PLAY_PAUSED;
- return 0;
-}
-
-static int
-mcd_resume(int unit)
-{
- struct mcd_data *cd = mcd_data + unit;
-
- if (cd->audio_status != CD_AS_PLAY_PAUSED)
- return EINVAL;
- return mcd_play(unit, &cd->lastpb);
-}
diff --git a/sys/dev/mcd/mcdreg.h b/sys/dev/mcd/mcdreg.h
deleted file mode 100644
index f0f75f7b2254..000000000000
--- a/sys/dev/mcd/mcdreg.h
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * Copyright 1993 by Holger Veit (data part)
- * Copyright 1993 by Brian Moore (audio part)
- * Changes Copyright 1993 by Gary Clark II
- * 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 was developed by Holger Veit and Brian Moore
- * for use with "386BSD" and similar operating systems.
- * "Similar operating systems" includes mainly non-profit oriented
- * systems for research and education, including but not restricted to
- * "NetBSD", "FreeBSD", "Mach" (by CMU).
- * 4. Neither the name of the developer(s) nor the name "386BSD"
- * may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPER(S) ``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(S) 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.
- *
- * This file contains definitions for some cdrom control commands
- * and status codes. This info was "inherited" from the DOS MTMCDE.SYS
- * driver, and is thus not complete (and may even be wrong). Some day
- * the manufacturer or anyone else might provide better documentation,
- * so this file (and the driver) will then have a better quality.
- *
- * $FreeBSD$
- */
-
-#ifndef MCD_H
-#define MCD_H
-
-#ifdef __GNUC__
-#if __GNUC__ >= 2
-#pragma pack(1)
-#endif
-#endif
-
-typedef unsigned char bcd_t;
-#define M_msf(msf) msf[0]
-#define S_msf(msf) msf[1]
-#define F_msf(msf) msf[2]
-
-/* io lines used */
-#define MCD_IO_BASE 0x300
-
-#define mcd_command 0
-#define mcd_status 0
-#define mcd_rdata 0
-
-#define mcd_reset 1
-#define mcd_ctl2 2 /* XXX Is this right? */
-#define mcd_config 3
-
-#define MCD_MASK_DMA 0x07 /* bits 2-0 = DMA channel */
-#define MCD_MASK_IRQ 0x70 /* bits 6-4 = INT number */
- /* 001 = int 2,9 */
- /* 010 = int 3 */
- /* 011 = int 5 */
- /* 100 = int 10 */
- /* 101 = int 11 */
-/* flags */
-#define MFL_DATA_NOT_AVAIL 0x02
-#define MFL_STATUS_NOT_AVAIL 0x04
-
-/* New Commands */
-#define M_RESET 0x00
-#define M_PICKLE 0x04
-
-/* ports */
-#define MCD_DATA 0
-#define MCD_FLAGS 1
-#define MCD_CTRL 2
-#define CHANNEL 3 /* XXX ??? */
-
-/* Status bits */
-#define MCD_ST_DOOROPEN 0x80
-#define MCD_ST_DSKIN 0x40
-#define MCD_ST_DSKCHNG 0x20
-#define MCD_ST_SPINNING 0x10
-#define MCD_ST_AUDIODISK 0x08 /* Audio Disk is in */
-#define MCD_ST_BUSY 0x04
-#define MCD_ST_AUDIOBSY 0x02 /* Audio Disk is Playing */
-#define MCD_ST_CMDCHECK 0x01 /* Command error */
-
-/* commands known by the controller */
-#define MCD_CMDRESET 0x00
-#define MCD_CMDGETVOLINFO 0x10 /* gets mcd_volinfo */
-#define MCD_CMDGETDISKINFO 0x11 /* gets mcd_disk information */
-#define MCD_CMDGETQCHN 0x20 /* gets mcd_qchninfo */
-#define MCD_CMDGETSENSE 0x30 /* gets sense info */
-#define MCD_CMDGETSTAT 0x40 /* gets a byte of status */
-
-#define MCD_CMDSETMODE 0x50 /* set transmission mode, needs byte */
-
-#define MCD_MDBIT_TESTMODE 0x80 /* 0 = DATALENGTH setting is valid */
-#define MCD_MDBIT_DATALENGTH 0x40 /* 0 = Read User Data Only */
- /* 1 = Read Raw sectors (2352 bytes) */
-
-#define MCDBLK 2048 /* for cooked mode */
-#define MCDRBLK sizeof(struct mcd_rawsector) /* for raw mode */
-
-#define MCD_MDBIT_ECCMODE 0x20 /* 0 = Use secondary correction */
- /* 1 = Don't use secondary ECC */
-#define MCD_MDBIT_SPINDOWN 0x08 /* 0 = Spin Up, 1 = Spin Down */
-#define MCD_MDBIT_GET_TOC 0x04 /* 0 = Get UPC on next GETQCHAN */
- /* 1 = Get TOC on GETQCHAN */
-#define MCD_MDBIT_MUTEDATA 0x01 /* 1 = Don't play back Data as audio */
-
-#define MCD_MD_RAW (MCD_MDBIT_DATALENGTH|MCD_MDBIT_ECCMODE|MCD_MDBIT_MUTEDATA)
-#define MCD_MD_COOKED (MCD_MDBIT_MUTEDATA)
-#define MCD_MD_TOC (MCD_MDBIT_GET_TOC|MCD_MDBIT_MUTEDATA)
-
-#define MCD_CMDSTOPAUDIO 0x70
-#define MCD_CMDSTOPAUDIOTIME 0x80
-#define MCD_CMDGETVOLUME 0x8E /* gets mcd_volume */
-#define MCD_CMDSETDRIVEMODE 0xA0 /* Set drive mode */
-#define MCD_READUPC 0xA2 /* Get UPC info */
-#define MCD_CMDSETVOLUME 0xAE /* sets mcd_volume */
-#define MCD_CMDREAD1 0xB0 /* read n sectors */
-#define MCD_CMDSINGLESPEEDREAD 0xC0 /* read from-to */
-#define MCD_CMDSTARTAUDIOMSF 0xC1 /* read audio data */
-#define MCD_CMDDOUBLESPEEDREAD 0xC1 /* Read lots of data from the drive */
-#define MCD_CMDGETDRIVEMODE 0xC2 /* Get the drive mode */
-#define MCD_CMDREAD 0xC3 /* Read data from the drive */
-#define MCD_CMDSETINTERLEAVE 0xC8 /* Adjust the interleave */
-#define MCD_CMDCONTINFO 0xDC /* Get controller info */
-#define MCD_CMDSTOP 0xF0 /* Stop everything */
-#define MCD_CMDEJECTDISK 0xF6
-#define MCD_CMDCLOSETRAY 0xF8
-
-#define MCD_CMDLOCKDRV 0xFE /* needs byte */
-#define MCD_LK_UNLOCK 0x00
-#define MCD_LK_LOCK 0x01
-#define MCD_LK_TEST 0x02
-
-/* DMA Enable Stuff */
-#define MCD_DMA_IRQFLAGS 0x10 /* Set data0 for IRQ click */
-
-#define MCD_DMA_PREIRQ 0x01 /* All of these are for */
-#define MCD_DMA_POSTIRQ 0x02 /* MCD_DMA_IRQFLAG... */
-#define MCD_DMA_ERRIRQ 0x04 /* */
-
-#define MCD_DMA_TIMEOUT 0x08 /* Set data0 for DMA timeout */
-#define MCD_DMA_UPCFLAG 0x04 /* 1 = Next command will be READUPC */
-
-#define MCD_DMA_DMAMODE 0x02 /* 1 = Data uses DMA */
-#define MCD_DMA_TRANSFERLENGTH 0x01 /* data0 = MSB, data1 = LSB of block length */
-
-struct mcd_dma_mode {
- u_char dma_mode;
- u_char data0; /* If dma_mode & 0x10: Use IRQ settings */
- u_char data1; /* Used if dma_mode & 0x01 */
-};
-
-struct mcd_volinfo {
- bcd_t trk_low;
- bcd_t trk_high;
- bcd_t vol_msf[3];
- bcd_t trk1_msf[3];
-};
-
-struct mcd_qchninfo {
- u_char addr_type:4;
- u_char control:4;
- u_char trk_no;
- u_char idx_no;
- bcd_t trk_size_msf[3];
- u_char :8;
- bcd_t hd_pos_msf[3];
-};
-
-struct mcd_volume {
- u_char v0l;
- u_char v0rs;
- u_char v0r;
- u_char v0ls;
-};
-
-struct mcd_holdtime {
- u_char units_of_ten_seconds;
- /* If this is 0, the default (12) is used */
-};
-
-struct mcd_read1 {
- bcd_t start_msf[3];
- u_char nsec[3];
-};
-
-struct mcd_read2 {
- bcd_t start_msf[3];
- bcd_t end_msf[3];
-};
-
-struct mcd_rawsector {
- u_char sync1[12];
- u_char header[4];
- u_char subheader1[4];
- u_char subheader2[4];
- u_char data[MCDBLK];
- u_char ecc_bits[280];
-};
-
-#ifdef __GNUC__
-#if __GNUC__ >= 2
-#pragma pack(4)
-#endif
-#endif
-#endif /* MCD_H */
diff --git a/sys/dev/mse/mse.c b/sys/dev/mse/mse.c
deleted file mode 100644
index 5dd8376702c8..000000000000
--- a/sys/dev/mse/mse.c
+++ /dev/null
@@ -1,768 +0,0 @@
-/*
- * Copyright 1992 by the University of Guelph
- *
- * Permission to use, copy and modify this
- * software and its documentation for any purpose and without
- * fee is hereby granted, provided that the above copyright
- * notice appear in all copies and that both that copyright
- * notice and this permission notice appear in supporting
- * documentation.
- * University of Guelph makes no representations about the suitability of
- * this software for any purpose. It is provided "as is"
- * without express or implied warranty.
- *
- * $FreeBSD$
- */
-/*
- * Driver for the Logitech and ATI Inport Bus mice for use with 386bsd and
- * the X386 port, courtesy of
- * Rick Macklem, rick@snowhite.cis.uoguelph.ca
- * Caveats: The driver currently uses spltty(), but doesn't use any
- * generic tty code. It could use splmse() (that only masks off the
- * bus mouse interrupt, but that would require hacking in i386/isa/icu.s.
- * (This may be worth the effort, since the Logitech generates 30/60
- * interrupts/sec continuously while it is open.)
- * NB: The ATI has NOT been tested yet!
- */
-
-/*
- * Modification history:
- * Sep 6, 1994 -- Lars Fredriksen(fredriks@mcs.com)
- * improved probe based on input from Logitech.
- *
- * Oct 19, 1992 -- E. Stark (stark@cs.sunysb.edu)
- * fixes to make it work with Microsoft InPort busmouse
- *
- * Jan, 1993 -- E. Stark (stark@cs.sunysb.edu)
- * added patches for new "select" interface
- *
- * May 4, 1993 -- E. Stark (stark@cs.sunysb.edu)
- * changed position of some spl()'s in mseread
- *
- * October 8, 1993 -- E. Stark (stark@cs.sunysb.edu)
- * limit maximum negative x/y value to -127 to work around XFree problem
- * that causes spurious button pushes.
- */
-
-#include "mse.h"
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/conf.h>
-#include <sys/kernel.h>
-#include <sys/poll.h>
-#include <sys/select.h>
-#include <sys/uio.h>
-
-#include <machine/clock.h>
-#include <machine/mouse.h>
-
-#include <i386/isa/isa_device.h>
-
-/* driver configuration flags (config) */
-#define MSE_CONFIG_ACCEL 0x00f0 /* acceleration factor */
-#define MSE_CONFIG_FLAGS (MSE_CONFIG_ACCEL)
-
-static int mseprobe(struct isa_device *);
-static int mseattach(struct isa_device *);
-
-struct isa_driver msedriver = {
- mseprobe, mseattach, "mse"
-};
-
-static d_open_t mseopen;
-static d_close_t mseclose;
-static d_read_t mseread;
-static d_ioctl_t mseioctl;
-static d_poll_t msepoll;
-
-#define CDEV_MAJOR 27
-static struct cdevsw mse_cdevsw = {
- /* open */ mseopen,
- /* close */ mseclose,
- /* read */ mseread,
- /* write */ nowrite,
- /* ioctl */ mseioctl,
- /* poll */ msepoll,
- /* mmap */ nommap,
- /* strategy */ nostrategy,
- /* name */ "mse",
- /* maj */ CDEV_MAJOR,
- /* dump */ nodump,
- /* psize */ nopsize,
- /* flags */ 0,
- /* bmaj */ -1
-};
-
-static ointhand2_t mseintr;
-
-/*
- * Software control structure for mouse. The sc_enablemouse(),
- * sc_disablemouse() and sc_getmouse() routines must be called spl'd().
- */
-static struct mse_softc {
- int sc_flags;
- int sc_mousetype;
- struct selinfo sc_selp;
- u_int sc_port;
- void (*sc_enablemouse) __P((u_int port));
- void (*sc_disablemouse) __P((u_int port));
- void (*sc_getmouse) __P((u_int port, int *dx, int *dy, int *but));
- int sc_deltax;
- int sc_deltay;
- int sc_obuttons;
- int sc_buttons;
- int sc_bytesread;
- u_char sc_bytes[MOUSE_SYS_PACKETSIZE];
- mousehw_t hw;
- mousemode_t mode;
- mousestatus_t status;
-} mse_sc[NMSE];
-
-/* Flags */
-#define MSESC_OPEN 0x1
-#define MSESC_WANT 0x2
-
-/* and Mouse Types */
-#define MSE_NONE 0 /* don't move this! */
-#define MSE_LOGITECH 0x1
-#define MSE_ATIINPORT 0x2
-#define MSE_LOGI_SIG 0xA5
-
-#define MSE_PORTA 0
-#define MSE_PORTB 1
-#define MSE_PORTC 2
-#define MSE_PORTD 3
-
-#define MSE_UNIT(dev) (minor(dev) >> 1)
-#define MSE_NBLOCKIO(dev) (minor(dev) & 0x1)
-
-/*
- * Logitech bus mouse definitions
- */
-#define MSE_SETUP 0x91 /* What does this mean? */
- /* The definition for the control port */
- /* is as follows: */
-
- /* D7 = Mode set flag (1 = active) */
- /* D6,D5 = Mode selection (port A) */
- /* 00 = Mode 0 = Basic I/O */
- /* 01 = Mode 1 = Strobed I/O */
- /* 10 = Mode 2 = Bi-dir bus */
- /* D4 = Port A direction (1 = input)*/
- /* D3 = Port C (upper 4 bits) */
- /* direction. (1 = input) */
- /* D2 = Mode selection (port B & C) */
- /* 0 = Mode 0 = Basic I/O */
- /* 1 = Mode 1 = Strobed I/O */
- /* D1 = Port B direction (1 = input)*/
- /* D0 = Port C (lower 4 bits) */
- /* direction. (1 = input) */
-
- /* So 91 means Basic I/O on all 3 ports,*/
- /* Port A is an input port, B is an */
- /* output port, C is split with upper */
- /* 4 bits being an output port and lower*/
- /* 4 bits an input port, and enable the */
- /* sucker. */
- /* Courtesy Intel 8255 databook. Lars */
-#define MSE_HOLD 0x80
-#define MSE_RXLOW 0x00
-#define MSE_RXHIGH 0x20
-#define MSE_RYLOW 0x40
-#define MSE_RYHIGH 0x60
-#define MSE_DISINTR 0x10
-#define MSE_INTREN 0x00
-
-static int mse_probelogi __P((struct isa_device *idp));
-static void mse_disablelogi __P((u_int port));
-static void mse_getlogi __P((u_int port, int *dx, int *dy, int *but));
-static void mse_enablelogi __P((u_int port));
-
-/*
- * ATI Inport mouse definitions
- */
-#define MSE_INPORT_RESET 0x80
-#define MSE_INPORT_STATUS 0x00
-#define MSE_INPORT_DX 0x01
-#define MSE_INPORT_DY 0x02
-#define MSE_INPORT_MODE 0x07
-#define MSE_INPORT_HOLD 0x20
-#define MSE_INPORT_INTREN 0x09
-
-static int mse_probeati __P((struct isa_device *idp));
-static void mse_enableati __P((u_int port));
-static void mse_disableati __P((u_int port));
-static void mse_getati __P((u_int port, int *dx, int *dy, int *but));
-
-#define MSEPRI (PZERO + 3)
-
-/*
- * Table of mouse types.
- * Keep the Logitech last, since I haven't figured out how to probe it
- * properly yet. (Someday I'll have the documentation.)
- */
-static struct mse_types {
- int m_type; /* Type of bus mouse */
- int (*m_probe) __P((struct isa_device *idp));
- /* Probe routine to test for it */
- void (*m_enable) __P((u_int port));
- /* Start routine */
- void (*m_disable) __P((u_int port));
- /* Disable interrupts routine */
- void (*m_get) __P((u_int port, int *dx, int *dy, int *but));
- /* and get mouse status */
- mousehw_t m_hw; /* buttons iftype type model hwid */
- mousemode_t m_mode; /* proto rate res accel level size mask */
-} mse_types[] = {
- { MSE_ATIINPORT,
- mse_probeati, mse_enableati, mse_disableati, mse_getati,
- { 2, MOUSE_IF_INPORT, MOUSE_MOUSE, MOUSE_MODEL_GENERIC, 0, },
- { MOUSE_PROTO_INPORT, -1, -1, 0, 0, MOUSE_MSC_PACKETSIZE,
- { MOUSE_MSC_SYNCMASK, MOUSE_MSC_SYNC, }, }, },
- { MSE_LOGITECH,
- mse_probelogi, mse_enablelogi, mse_disablelogi, mse_getlogi,
- { 2, MOUSE_IF_BUS, MOUSE_MOUSE, MOUSE_MODEL_GENERIC, 0, },
- { MOUSE_PROTO_BUS, -1, -1, 0, 0, MOUSE_MSC_PACKETSIZE,
- { MOUSE_MSC_SYNCMASK, MOUSE_MSC_SYNC, }, }, },
- { 0, },
-};
-
-int
-mseprobe(idp)
- register struct isa_device *idp;
-{
- register struct mse_softc *sc = &mse_sc[idp->id_unit];
- register int i;
-
- /*
- * Check for each mouse type in the table.
- */
- i = 0;
- while (mse_types[i].m_type) {
- if ((*mse_types[i].m_probe)(idp)) {
- sc->sc_mousetype = mse_types[i].m_type;
- sc->sc_enablemouse = mse_types[i].m_enable;
- sc->sc_disablemouse = mse_types[i].m_disable;
- sc->sc_getmouse = mse_types[i].m_get;
- sc->hw = mse_types[i].m_hw;
- sc->mode = mse_types[i].m_mode;
- return (1);
- }
- i++;
- }
- return (0);
-}
-
-int
-mseattach(idp)
- struct isa_device *idp;
-{
- int unit = idp->id_unit;
- struct mse_softc *sc = &mse_sc[unit];
-
- idp->id_ointr = mseintr;
- sc->sc_port = idp->id_iobase;
- sc->mode.accelfactor = (idp->id_flags & MSE_CONFIG_ACCEL) >> 4;
- make_dev(&mse_cdevsw, unit << 1, 0, 0, 0600, "mse%d", unit);
- make_dev(&mse_cdevsw, (unit<<1)+1, 0, 0, 0600, "nmse%d", unit);
- return (1);
-}
-
-/*
- * Exclusive open the mouse, initialize it and enable interrupts.
- */
-static int
-mseopen(dev, flags, fmt, p)
- dev_t dev;
- int flags;
- int fmt;
- struct proc *p;
-{
- register struct mse_softc *sc;
- int s;
-
- if (MSE_UNIT(dev) >= NMSE)
- return (ENXIO);
- sc = &mse_sc[MSE_UNIT(dev)];
- if (sc->sc_mousetype == MSE_NONE)
- return (ENXIO);
- if (sc->sc_flags & MSESC_OPEN)
- return (EBUSY);
- sc->sc_flags |= MSESC_OPEN;
- sc->sc_obuttons = sc->sc_buttons = MOUSE_MSC_BUTTONS;
- sc->sc_deltax = sc->sc_deltay = 0;
- sc->sc_bytesread = sc->mode.packetsize = MOUSE_MSC_PACKETSIZE;
- sc->mode.level = 0;
- sc->status.flags = 0;
- sc->status.button = sc->status.obutton = 0;
- sc->status.dx = sc->status.dy = sc->status.dz = 0;
-
- /*
- * Initialize mouse interface and enable interrupts.
- */
- s = spltty();
- (*sc->sc_enablemouse)(sc->sc_port);
- splx(s);
- return (0);
-}
-
-/*
- * mseclose: just turn off mouse innterrupts.
- */
-static int
-mseclose(dev, flags, fmt, p)
- dev_t dev;
- int flags;
- int fmt;
- struct proc *p;
-{
- struct mse_softc *sc = &mse_sc[MSE_UNIT(dev)];
- int s;
-
- s = spltty();
- (*sc->sc_disablemouse)(sc->sc_port);
- sc->sc_flags &= ~MSESC_OPEN;
- splx(s);
- return(0);
-}
-
-/*
- * mseread: return mouse info using the MSC serial protocol, but without
- * using bytes 4 and 5.
- * (Yes this is cheesy, but it makes the X386 server happy, so...)
- */
-static int
-mseread(dev, uio, ioflag)
- dev_t dev;
- struct uio *uio;
- int ioflag;
-{
- register struct mse_softc *sc = &mse_sc[MSE_UNIT(dev)];
- int xfer, s, error;
-
- /*
- * If there are no protocol bytes to be read, set up a new protocol
- * packet.
- */
- s = spltty(); /* XXX Should be its own spl, but where is imlXX() */
- if (sc->sc_bytesread >= sc->mode.packetsize) {
- while (sc->sc_deltax == 0 && sc->sc_deltay == 0 &&
- (sc->sc_obuttons ^ sc->sc_buttons) == 0) {
- if (MSE_NBLOCKIO(dev)) {
- splx(s);
- return (0);
- }
- sc->sc_flags |= MSESC_WANT;
- error = tsleep((caddr_t)sc, MSEPRI | PCATCH,
- "mseread", 0);
- if (error) {
- splx(s);
- return (error);
- }
- }
-
- /*
- * Generate protocol bytes.
- * For some reason X386 expects 5 bytes but never uses
- * the fourth or fifth?
- */
- sc->sc_bytes[0] = sc->mode.syncmask[1]
- | (sc->sc_buttons & ~sc->mode.syncmask[0]);
- if (sc->sc_deltax > 127)
- sc->sc_deltax = 127;
- if (sc->sc_deltax < -127)
- sc->sc_deltax = -127;
- sc->sc_deltay = -sc->sc_deltay; /* Otherwise mousey goes wrong way */
- if (sc->sc_deltay > 127)
- sc->sc_deltay = 127;
- if (sc->sc_deltay < -127)
- sc->sc_deltay = -127;
- sc->sc_bytes[1] = sc->sc_deltax;
- sc->sc_bytes[2] = sc->sc_deltay;
- sc->sc_bytes[3] = sc->sc_bytes[4] = 0;
- sc->sc_bytes[5] = sc->sc_bytes[6] = 0;
- sc->sc_bytes[7] = MOUSE_SYS_EXTBUTTONS;
- sc->sc_obuttons = sc->sc_buttons;
- sc->sc_deltax = sc->sc_deltay = 0;
- sc->sc_bytesread = 0;
- }
- splx(s);
- xfer = min(uio->uio_resid, sc->mode.packetsize - sc->sc_bytesread);
- error = uiomove(&sc->sc_bytes[sc->sc_bytesread], xfer, uio);
- if (error)
- return (error);
- sc->sc_bytesread += xfer;
- return(0);
-}
-
-/*
- * mseioctl: process ioctl commands.
- */
-static int
-mseioctl(dev, cmd, addr, flag, p)
- dev_t dev;
- u_long cmd;
- caddr_t addr;
- int flag;
- struct proc *p;
-{
- register struct mse_softc *sc = &mse_sc[MSE_UNIT(dev)];
- mousestatus_t status;
- int err = 0;
- int s;
-
- switch (cmd) {
-
- case MOUSE_GETHWINFO:
- s = spltty();
- *(mousehw_t *)addr = sc->hw;
- if (sc->mode.level == 0)
- ((mousehw_t *)addr)->model = MOUSE_MODEL_GENERIC;
- splx(s);
- break;
-
- case MOUSE_GETMODE:
- s = spltty();
- *(mousemode_t *)addr = sc->mode;
- switch (sc->mode.level) {
- case 0:
- break;
- case 1:
- ((mousemode_t *)addr)->protocol = MOUSE_PROTO_SYSMOUSE;
- ((mousemode_t *)addr)->syncmask[0] = MOUSE_SYS_SYNCMASK;
- ((mousemode_t *)addr)->syncmask[1] = MOUSE_SYS_SYNC;
- break;
- }
- splx(s);
- break;
-
- case MOUSE_SETMODE:
- switch (((mousemode_t *)addr)->level) {
- case 0:
- case 1:
- break;
- default:
- return (EINVAL);
- }
- if (((mousemode_t *)addr)->accelfactor < -1)
- return (EINVAL);
- else if (((mousemode_t *)addr)->accelfactor >= 0)
- sc->mode.accelfactor =
- ((mousemode_t *)addr)->accelfactor;
- sc->mode.level = ((mousemode_t *)addr)->level;
- switch (sc->mode.level) {
- case 0:
- sc->sc_bytesread = sc->mode.packetsize
- = MOUSE_MSC_PACKETSIZE;
- break;
- case 1:
- sc->sc_bytesread = sc->mode.packetsize
- = MOUSE_SYS_PACKETSIZE;
- break;
- }
- break;
-
- case MOUSE_GETLEVEL:
- *(int *)addr = sc->mode.level;
- break;
-
- case MOUSE_SETLEVEL:
- switch (*(int *)addr) {
- case 0:
- sc->mode.level = *(int *)addr;
- sc->sc_bytesread = sc->mode.packetsize
- = MOUSE_MSC_PACKETSIZE;
- break;
- case 1:
- sc->mode.level = *(int *)addr;
- sc->sc_bytesread = sc->mode.packetsize
- = MOUSE_SYS_PACKETSIZE;
- break;
- default:
- return (EINVAL);
- }
- break;
-
- case MOUSE_GETSTATUS:
- s = spltty();
- status = sc->status;
- sc->status.flags = 0;
- sc->status.obutton = sc->status.button;
- sc->status.button = 0;
- sc->status.dx = 0;
- sc->status.dy = 0;
- sc->status.dz = 0;
- splx(s);
- *(mousestatus_t *)addr = status;
- break;
-
- case MOUSE_READSTATE:
- case MOUSE_READDATA:
- return (ENODEV);
-
-#if (defined(MOUSE_GETVARS))
- case MOUSE_GETVARS:
- case MOUSE_SETVARS:
- return (ENODEV);
-#endif
-
- default:
- return (ENOTTY);
- }
- return (err);
-}
-
-/*
- * msepoll: check for mouse input to be processed.
- */
-static int
-msepoll(dev, events, p)
- dev_t dev;
- int events;
- struct proc *p;
-{
- register struct mse_softc *sc = &mse_sc[MSE_UNIT(dev)];
- int s;
- int revents = 0;
-
- s = spltty();
- if (events & (POLLIN | POLLRDNORM)) {
- if (sc->sc_bytesread != sc->mode.packetsize ||
- sc->sc_deltax != 0 || sc->sc_deltay != 0 ||
- (sc->sc_obuttons ^ sc->sc_buttons) != 0)
- revents |= events & (POLLIN | POLLRDNORM);
- else {
- /*
- * Since this is an exclusive open device, any previous
- * proc pointer is trash now, so we can just assign it.
- */
- selrecord(p, &sc->sc_selp);
- }
- }
- splx(s);
- return (revents);
-}
-
-/*
- * mseintr: update mouse status. sc_deltax and sc_deltay are accumulative.
- */
-static void
-mseintr(unit)
- int unit;
-{
- /*
- * the table to turn MouseSystem button bits (MOUSE_MSC_BUTTON?UP)
- * into `mousestatus' button bits (MOUSE_BUTTON?DOWN).
- */
- static int butmap[8] = {
- 0,
- MOUSE_BUTTON3DOWN,
- MOUSE_BUTTON2DOWN,
- MOUSE_BUTTON2DOWN | MOUSE_BUTTON3DOWN,
- MOUSE_BUTTON1DOWN,
- MOUSE_BUTTON1DOWN | MOUSE_BUTTON3DOWN,
- MOUSE_BUTTON1DOWN | MOUSE_BUTTON2DOWN,
- MOUSE_BUTTON1DOWN | MOUSE_BUTTON2DOWN | MOUSE_BUTTON3DOWN
- };
- register struct mse_softc *sc = &mse_sc[unit];
- int dx, dy, but;
- int sign;
-
-#ifdef DEBUG
- static int mse_intrcnt = 0;
- if((mse_intrcnt++ % 10000) == 0)
- printf("mseintr\n");
-#endif /* DEBUG */
- if ((sc->sc_flags & MSESC_OPEN) == 0)
- return;
-
- (*sc->sc_getmouse)(sc->sc_port, &dx, &dy, &but);
- if (sc->mode.accelfactor > 0) {
- sign = (dx < 0);
- dx = dx * dx / sc->mode.accelfactor;
- if (dx == 0)
- dx = 1;
- if (sign)
- dx = -dx;
- sign = (dy < 0);
- dy = dy * dy / sc->mode.accelfactor;
- if (dy == 0)
- dy = 1;
- if (sign)
- dy = -dy;
- }
- sc->sc_deltax += dx;
- sc->sc_deltay += dy;
- sc->sc_buttons = but;
-
- but = butmap[~but & MOUSE_MSC_BUTTONS];
- sc->status.dx += dx;
- sc->status.dy += dy;
- sc->status.flags |= ((dx || dy) ? MOUSE_POSCHANGED : 0)
- | (sc->status.button ^ but);
- sc->status.button = but;
-
- /*
- * If mouse state has changed, wake up anyone wanting to know.
- */
- if (sc->sc_deltax != 0 || sc->sc_deltay != 0 ||
- (sc->sc_obuttons ^ sc->sc_buttons) != 0) {
- if (sc->sc_flags & MSESC_WANT) {
- sc->sc_flags &= ~MSESC_WANT;
- wakeup((caddr_t)sc);
- }
- selwakeup(&sc->sc_selp);
- }
-}
-
-/*
- * Routines for the Logitech mouse.
- */
-/*
- * Test for a Logitech bus mouse and return 1 if it is.
- * (until I know how to use the signature port properly, just disable
- * interrupts and return 1)
- */
-static int
-mse_probelogi(idp)
- register struct isa_device *idp;
-{
-
- int sig;
-
- outb(idp->id_iobase + MSE_PORTD, MSE_SETUP);
- /* set the signature port */
- outb(idp->id_iobase + MSE_PORTB, MSE_LOGI_SIG);
-
- DELAY(30000); /* 30 ms delay */
- sig = inb(idp->id_iobase + MSE_PORTB) & 0xFF;
- if (sig == MSE_LOGI_SIG) {
- outb(idp->id_iobase + MSE_PORTC, MSE_DISINTR);
- return(1);
- } else {
- if (bootverbose)
- printf("mse%d: wrong signature %x\n",idp->id_unit,sig);
- return(0);
- }
-}
-
-/*
- * Initialize Logitech mouse and enable interrupts.
- */
-static void
-mse_enablelogi(port)
- register u_int port;
-{
- int dx, dy, but;
-
- outb(port + MSE_PORTD, MSE_SETUP);
- mse_getlogi(port, &dx, &dy, &but);
-}
-
-/*
- * Disable interrupts for Logitech mouse.
- */
-static void
-mse_disablelogi(port)
- register u_int port;
-{
-
- outb(port + MSE_PORTC, MSE_DISINTR);
-}
-
-/*
- * Get the current dx, dy and button up/down state.
- */
-static void
-mse_getlogi(port, dx, dy, but)
- register u_int port;
- int *dx;
- int *dy;
- int *but;
-{
- register char x, y;
-
- outb(port + MSE_PORTC, MSE_HOLD | MSE_RXLOW);
- x = inb(port + MSE_PORTA);
- *but = (x >> 5) & MOUSE_MSC_BUTTONS;
- x &= 0xf;
- outb(port + MSE_PORTC, MSE_HOLD | MSE_RXHIGH);
- x |= (inb(port + MSE_PORTA) << 4);
- outb(port + MSE_PORTC, MSE_HOLD | MSE_RYLOW);
- y = (inb(port + MSE_PORTA) & 0xf);
- outb(port + MSE_PORTC, MSE_HOLD | MSE_RYHIGH);
- y |= (inb(port + MSE_PORTA) << 4);
- *dx = x;
- *dy = y;
- outb(port + MSE_PORTC, MSE_INTREN);
-}
-
-/*
- * Routines for the ATI Inport bus mouse.
- */
-/*
- * Test for a ATI Inport bus mouse and return 1 if it is.
- * (do not enable interrupts)
- */
-static int
-mse_probeati(idp)
- register struct isa_device *idp;
-{
- int i;
-
- for (i = 0; i < 2; i++)
- if (inb(idp->id_iobase + MSE_PORTC) == 0xde)
- return (1);
- return (0);
-}
-
-/*
- * Initialize ATI Inport mouse and enable interrupts.
- */
-static void
-mse_enableati(port)
- register u_int port;
-{
-
- outb(port + MSE_PORTA, MSE_INPORT_RESET);
- outb(port + MSE_PORTA, MSE_INPORT_MODE);
- outb(port + MSE_PORTB, MSE_INPORT_INTREN);
-}
-
-/*
- * Disable interrupts for ATI Inport mouse.
- */
-static void
-mse_disableati(port)
- register u_int port;
-{
-
- outb(port + MSE_PORTA, MSE_INPORT_MODE);
- outb(port + MSE_PORTB, 0);
-}
-
-/*
- * Get current dx, dy and up/down button state.
- */
-static void
-mse_getati(port, dx, dy, but)
- register u_int port;
- int *dx;
- int *dy;
- int *but;
-{
- register char byte;
-
- outb(port + MSE_PORTA, MSE_INPORT_MODE);
- outb(port + MSE_PORTB, MSE_INPORT_HOLD);
- outb(port + MSE_PORTA, MSE_INPORT_STATUS);
- *but = ~inb(port + MSE_PORTB) & MOUSE_MSC_BUTTONS;
- outb(port + MSE_PORTA, MSE_INPORT_DX);
- byte = inb(port + MSE_PORTB);
- *dx = byte;
- outb(port + MSE_PORTA, MSE_INPORT_DY);
- byte = inb(port + MSE_PORTB);
- *dy = byte;
- outb(port + MSE_PORTA, MSE_INPORT_MODE);
- outb(port + MSE_PORTB, MSE_INPORT_INTREN);
-}
diff --git a/sys/dev/pcf/pcf.c b/sys/dev/pcf/pcf.c
deleted file mode 100644
index e37823e400c3..000000000000
--- a/sys/dev/pcf/pcf.c
+++ /dev/null
@@ -1,634 +0,0 @@
-/*-
- * Copyright (c) 1998 Nicolas Souchu, Marc Bouget
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- *
- */
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/bus.h>
-#include <sys/malloc.h>
-
-#include <machine/clock.h>
-#include <machine/bus.h>
-#include <machine/resource.h>
-#include <sys/rman.h>
-
-#include <isa/isareg.h>
-#include <isa/isavar.h>
-
-#include <i386/isa/isa_device.h>
-
-#include <dev/iicbus/iiconf.h>
-#include "iicbus_if.h"
-
-#define IO_PCFSIZE 2
-
-#define TIMEOUT 9999 /* XXX */
-
-/* Status bits of S1 register (read only) */
-#define nBB 0x01 /* busy when low set/reset by STOP/START*/
-#define LAB 0x02 /* lost arbitration bit in multi-master mode */
-#define AAS 0x04 /* addressed as slave */
-#define LRB 0x08 /* last received byte when not AAS */
-#define AD0 0x08 /* general call received when AAS */
-#define BER 0x10 /* bus error, misplaced START or STOP */
-#define STS 0x20 /* STOP detected in slave receiver mode */
-#define PIN 0x80 /* pending interrupt not (r/w) */
-
-/* Control bits of S1 register (write only) */
-#define ACK 0x01
-#define STO 0x02
-#define STA 0x04
-#define ENI 0x08
-#define ES2 0x10
-#define ES1 0x20
-#define ES0 0x40
-
-#define BUFSIZE 2048
-
-#define SLAVE_TRANSMITTER 0x1
-#define SLAVE_RECEIVER 0x2
-
-#define PCF_DEFAULT_ADDR 0xaa
-
-struct pcf_softc {
-
- int pcf_base; /* isa port */
- int pcf_flags;
- u_char pcf_addr; /* interface I2C address */
-
- int pcf_slave_mode; /* receiver or transmitter */
- int pcf_started; /* 1 if start condition sent */
-
- device_t iicbus; /* the corresponding iicbus */
-
- int rid_irq, rid_ioport;
- struct resource *res_irq, *res_ioport;
- void *intr_cookie;
-};
-
-static int pcf_probe(device_t);
-static int pcf_attach(device_t);
-static void pcfintr(void *arg);
-
-static int pcf_print_child(device_t, device_t);
-
-static int pcf_repeated_start(device_t, u_char, int);
-static int pcf_start(device_t, u_char, int);
-static int pcf_stop(device_t);
-static int pcf_write(device_t, char *, int, int *, int);
-static int pcf_read(device_t, char *, int, int *, int, int);
-static int pcf_rst_card(device_t, u_char, u_char, u_char *);
-
-static device_method_t pcf_methods[] = {
- /* device interface */
- DEVMETHOD(device_probe, pcf_probe),
- DEVMETHOD(device_attach, pcf_attach),
-
- /* bus interface */
- DEVMETHOD(bus_print_child, pcf_print_child),
-
- /* iicbus interface */
- DEVMETHOD(iicbus_callback, iicbus_null_callback),
- DEVMETHOD(iicbus_repeated_start, pcf_repeated_start),
- DEVMETHOD(iicbus_start, pcf_start),
- DEVMETHOD(iicbus_stop, pcf_stop),
- DEVMETHOD(iicbus_write, pcf_write),
- DEVMETHOD(iicbus_read, pcf_read),
- DEVMETHOD(iicbus_reset, pcf_rst_card),
-
- { 0, 0 }
-};
-
-static driver_t pcf_driver = {
- "pcf",
- pcf_methods,
- sizeof(struct pcf_softc),
-};
-
-static devclass_t pcf_devclass;
-
-#define DEVTOSOFTC(dev) ((struct pcf_softc *)device_get_softc(dev))
-
-static int
-pcf_probe(device_t pcfdev)
-{
- struct pcf_softc *pcf = DEVTOSOFTC(pcfdev);
- device_t parent = device_get_parent(pcfdev);
-
- device_set_desc(pcfdev, "PCF8584 I2C bus controller");
-
- pcf = DEVTOSOFTC(pcfdev);
- bzero(pcf, sizeof(struct pcf_softc));
-
- pcf->rid_irq = pcf->rid_ioport = 0;
- pcf->res_irq = pcf->res_ioport = 0;
-
- /* IO port is mandatory */
- pcf->res_ioport = bus_alloc_resource(pcfdev, SYS_RES_IOPORT,
- &pcf->rid_ioport, 0ul, ~0ul,
- IO_PCFSIZE, RF_ACTIVE);
- if (pcf->res_ioport == 0) {
- device_printf(pcfdev, "cannot reserve I/O port range\n");
- goto error;
- }
- BUS_READ_IVAR(parent, pcfdev, ISA_IVAR_PORT, &pcf->pcf_base);
-
- pcf->pcf_flags = device_get_flags(pcfdev);
-
- if (!(pcf->pcf_flags & IIC_POLLED)) {
- pcf->res_irq = bus_alloc_resource(pcfdev, SYS_RES_IRQ, &pcf->rid_irq,
- 0ul, ~0ul, 1, RF_ACTIVE);
- if (pcf->res_irq == 0) {
- device_printf(pcfdev, "can't reserve irq, polled mode.\n");
- pcf->pcf_flags |= IIC_POLLED;
- }
- }
-
- /* reset the chip */
- pcf_rst_card(pcfdev, IIC_FASTEST, PCF_DEFAULT_ADDR, NULL);
-
- return (0);
-error:
- if (pcf->res_ioport != 0) {
- bus_deactivate_resource(pcfdev, SYS_RES_IOPORT, pcf->rid_ioport,
- pcf->res_ioport);
- bus_release_resource(pcfdev, SYS_RES_IOPORT, pcf->rid_ioport,
- pcf->res_ioport);
- }
- return (ENXIO);
-}
-
-static int
-pcf_attach(device_t pcfdev)
-{
- struct pcf_softc *pcf = DEVTOSOFTC(pcfdev);
- device_t parent = device_get_parent(pcfdev);
- int error = 0;
-
- if (pcf->res_irq) {
- /* default to the tty mask for registration */ /* XXX */
- error = BUS_SETUP_INTR(parent, pcfdev, pcf->res_irq, INTR_TYPE_NET,
- pcfintr, pcfdev, &pcf->intr_cookie);
- if (error)
- return (error);
- }
-
- pcf->iicbus = iicbus_alloc_bus(pcfdev);
-
- /* probe and attach the iicbus */
- device_probe_and_attach(pcf->iicbus);
-
- return (0);
-}
-
-static int
-pcf_print_child(device_t bus, device_t dev)
-{
- struct pcf_softc *pcf = (struct pcf_softc *)device_get_softc(bus);
- int retval = 0;
-
- retval += bus_print_child_header(bus, dev);
- retval += printf(" on %s addr 0x%x\n", device_get_nameunit(bus),
- (int)pcf->pcf_addr);
-
- return (retval);
-}
-
-/*
- * PCF8584 datasheet : when operate at 8 MHz or more, a minimun time of
- * 6 clocks cycles must be left between two consecutives access
- */
-#define pcf_nops() DELAY(10)
-
-#define dummy_read(pcf) PCF_GET_S0(pcf)
-#define dummy_write(pcf) PCF_SET_S0(pcf, 0)
-
-/*
- * Specific register access to PCF8584
- */
-static void PCF_SET_S0(struct pcf_softc *pcf, int data)
-{
- outb(pcf->pcf_base, data);
- pcf_nops();
-}
-
-static void PCF_SET_S1(struct pcf_softc *pcf, int data)
-{
- outb(pcf->pcf_base+1, data);
- pcf_nops();
-}
-
-static char PCF_GET_S0(struct pcf_softc *pcf)
-{
- char data;
-
- data = inb(pcf->pcf_base);
- pcf_nops();
-
- return (data);
-}
-
-static char PCF_GET_S1(struct pcf_softc *pcf)
-{
- char data;
-
- data = inb(pcf->pcf_base+1);
- pcf_nops();
-
- return (data);
-}
-
-/*
- * Polling mode for master operations wait for a new
- * byte incomming or outgoing
- */
-static int pcf_wait_byte(struct pcf_softc *pcf)
-{
- int counter = TIMEOUT;
-
- while (counter--) {
-
- if ((PCF_GET_S1(pcf) & PIN) == 0)
- return (0);
- }
-
- return (IIC_ETIMEOUT);
-}
-
-static int pcf_stop(device_t pcfdev)
-{
- struct pcf_softc *pcf = DEVTOSOFTC(pcfdev);
-
- /*
- * Send STOP condition iff the START condition was previously sent.
- * STOP is sent only once even if a iicbus_stop() is called after
- * an iicbus_read()... see pcf_read(): the pcf needs to send the stop
- * before the last char is read.
- */
- if (pcf->pcf_started) {
- /* set stop condition and enable IT */
- PCF_SET_S1(pcf, PIN|ES0|ENI|STO|ACK);
-
- pcf->pcf_started = 0;
- }
-
- return (0);
-}
-
-
-static int pcf_noack(struct pcf_softc *pcf, int timeout)
-{
- int noack;
- int k = timeout/10;
-
- do {
- noack = PCF_GET_S1(pcf) & LRB;
- if (!noack)
- break;
- DELAY(10); /* XXX wait 10 us */
- } while (k--);
-
- return (noack);
-}
-
-static int pcf_repeated_start(device_t pcfdev, u_char slave, int timeout)
-{
- struct pcf_softc *pcf = DEVTOSOFTC(pcfdev);
- int error = 0;
-
- /* repeated start */
- PCF_SET_S1(pcf, ES0|STA|STO|ACK);
-
- /* set slave address to PCF. Last bit (LSB) must be set correctly
- * according to transfer direction */
- PCF_SET_S0(pcf, slave);
-
- /* wait for address sent, polling */
- if ((error = pcf_wait_byte(pcf)))
- goto error;
-
- /* check for ack */
- if (pcf_noack(pcf, timeout)) {
- error = IIC_ENOACK;
- goto error;
- }
-
- return (0);
-
-error:
- pcf_stop(pcfdev);
- return (error);
-}
-
-static int pcf_start(device_t pcfdev, u_char slave, int timeout)
-{
- struct pcf_softc *pcf = DEVTOSOFTC(pcfdev);
- int error = 0;
-
- if ((PCF_GET_S1(pcf) & nBB) == 0)
- return (IIC_EBUSBSY);
-
- /* set slave address to PCF. Last bit (LSB) must be set correctly
- * according to transfer direction */
- PCF_SET_S0(pcf, slave);
-
- /* START only */
- PCF_SET_S1(pcf, PIN|ES0|STA|ACK);
-
- pcf->pcf_started = 1;
-
- /* wait for address sent, polling */
- if ((error = pcf_wait_byte(pcf)))
- goto error;
-
- /* check for ACK */
- if (pcf_noack(pcf, timeout)) {
- error = IIC_ENOACK;
- goto error;
- }
-
- return (0);
-
-error:
- pcf_stop(pcfdev);
- return (error);
-}
-
-static void
-pcfintr(void *arg)
-{
- device_t pcfdev = (device_t)arg;
- struct pcf_softc *pcf = DEVTOSOFTC(pcfdev);
-
- char data, status, addr;
- char error = 0;
-
- status = PCF_GET_S1(pcf);
-
- if (status & PIN) {
- device_printf(pcfdev, "spurious interrupt, status=0x%x\n", status & 0xff);
-
- goto error;
- }
-
- if (status & LAB)
- device_printf(pcfdev, "bus arbitration lost!\n");
-
- if (status & BER) {
- error = IIC_EBUSERR;
- iicbus_intr(pcf->iicbus, INTR_ERROR, &error);
-
- goto error;
- }
-
- do {
- status = PCF_GET_S1(pcf);
-
- switch(pcf->pcf_slave_mode) {
-
- case SLAVE_TRANSMITTER:
- if (status & LRB) {
- /* ack interrupt line */
- dummy_write(pcf);
-
- /* no ack, don't send anymore */
- pcf->pcf_slave_mode = SLAVE_RECEIVER;
-
- iicbus_intr(pcf->iicbus, INTR_NOACK, NULL);
- break;
- }
-
- /* get data from upper code */
- iicbus_intr(pcf->iicbus, INTR_TRANSMIT, &data);
-
- PCF_SET_S0(pcf, data);
- break;
-
- case SLAVE_RECEIVER:
- if (status & AAS) {
- addr = PCF_GET_S0(pcf);
-
- if (status & AD0)
- iicbus_intr(pcf->iicbus, INTR_GENERAL, &addr);
- else
- iicbus_intr(pcf->iicbus, INTR_START, &addr);
-
- if (addr & LSB) {
- pcf->pcf_slave_mode = SLAVE_TRANSMITTER;
-
- /* get the first char from upper code */
- iicbus_intr(pcf->iicbus, INTR_TRANSMIT, &data);
-
- /* send first data byte */
- PCF_SET_S0(pcf, data);
- }
-
- break;
- }
-
- /* stop condition received? */
- if (status & STS) {
- /* ack interrupt line */
- dummy_read(pcf);
-
- /* emulate intr stop condition */
- iicbus_intr(pcf->iicbus, INTR_STOP, NULL);
-
- } else {
- /* get data, ack interrupt line */
- data = PCF_GET_S0(pcf);
-
- /* deliver the character */
- iicbus_intr(pcf->iicbus, INTR_RECEIVE, &data);
- }
- break;
-
- default:
- panic("%s: unknown slave mode (%d)!", __FUNCTION__,
- pcf->pcf_slave_mode);
- }
-
- } while ((PCF_GET_S1(pcf) & PIN) == 0);
-
- return;
-
-error:
- /* unknown event on bus...reset PCF */
- PCF_SET_S1(pcf, PIN|ES0|ENI|ACK);
-
- pcf->pcf_slave_mode = SLAVE_RECEIVER;
-
- return;
-}
-
-static int pcf_rst_card(device_t pcfdev, u_char speed, u_char addr, u_char *oldaddr)
-{
- struct pcf_softc *pcf = DEVTOSOFTC(pcfdev);
-
- if (oldaddr)
- *oldaddr = pcf->pcf_addr;
-
- /* retrieve own address from bus level */
- if (!addr)
- pcf->pcf_addr = PCF_DEFAULT_ADDR;
- else
- pcf->pcf_addr = addr;
-
- PCF_SET_S1(pcf, PIN); /* initialize S1 */
-
- /* own address S'O<>0 */
- PCF_SET_S0(pcf, pcf->pcf_addr >> 1);
-
- /* select clock register */
- PCF_SET_S1(pcf, PIN|ES1);
-
- /* select bus speed : 18=90kb, 19=45kb, 1A=11kb, 1B=1.5kb */
- switch (speed) {
- case IIC_SLOW:
- PCF_SET_S0(pcf, 0x1b);
- break;
-
- case IIC_FAST:
- PCF_SET_S0(pcf, 0x19);
- break;
-
- case IIC_UNKNOWN:
- case IIC_FASTEST:
- default:
- PCF_SET_S0(pcf, 0x18);
- break;
- }
-
- /* set bus on, ack=yes, INT=yes */
- PCF_SET_S1(pcf, PIN|ES0|ENI|ACK);
-
- pcf->pcf_slave_mode = SLAVE_RECEIVER;
-
- return (0);
-}
-
-static int
-pcf_write(device_t pcfdev, char *buf, int len, int *sent, int timeout /* us */)
-{
- struct pcf_softc *pcf = DEVTOSOFTC(pcfdev);
- int bytes, error = 0;
-
-#ifdef PCFDEBUG
- printf("pcf%d: >> writing %d bytes\n", device_get_unit(pcfdev), len);
-#endif
-
- bytes = 0;
- while (len) {
-
- PCF_SET_S0(pcf, *buf++);
-
- /* wait for the byte to be send */
- if ((error = pcf_wait_byte(pcf)))
- goto error;
-
- /* check if ack received */
- if (pcf_noack(pcf, timeout)) {
- error = IIC_ENOACK;
- goto error;
- }
-
- len --;
- bytes ++;
- }
-
-error:
- *sent = bytes;
-
-#ifdef PCFDEBUG
- printf("pcf%d: >> %d bytes written (%d)\n",
- device_get_unit(pcfdev), bytes, error);
-#endif
-
- return (error);
-}
-
-static int
-pcf_read(device_t pcfdev, char *buf, int len, int *read, int last,
- int delay /* us */)
-{
- struct pcf_softc *pcf = DEVTOSOFTC(pcfdev);
- int bytes, error = 0;
-
-#ifdef PCFDEBUG
- printf("pcf%d: << reading %d bytes\n", device_get_unit(pcfdev), len);
-#endif
-
- /* trig the bus to get the first data byte in S0 */
- if (len) {
- if (len == 1 && last)
- /* just one byte to read */
- PCF_SET_S1(pcf, ES0); /* no ack */
-
- dummy_read(pcf);
- }
-
- bytes = 0;
- while (len) {
-
- /* XXX delay needed here */
-
- /* wait for trigged byte */
- if ((error = pcf_wait_byte(pcf))) {
- pcf_stop(pcfdev);
- goto error;
- }
-
- if (len == 1 && last)
- /* ok, last data byte already in S0, no I2C activity
- * on next PCF_GET_S0() */
- pcf_stop(pcfdev);
-
- else if (len == 2 && last)
- /* next trigged byte with no ack */
- PCF_SET_S1(pcf, ES0);
-
- /* receive byte, trig next byte */
- *buf++ = PCF_GET_S0(pcf);
-
- len --;
- bytes ++;
- };
-
-error:
- *read = bytes;
-
-#ifdef PCFDEBUG
- printf("pcf%d: << %d bytes read (%d)\n",
- device_get_unit(pcfdev), bytes, error);
-#endif
-
- return (error);
-}
-
-DRIVER_MODULE(pcf, isa, pcf_driver, pcf_devclass, 0, 0);
diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c
deleted file mode 100644
index bbb9dff7db82..000000000000
--- a/sys/dev/pci/pci.c
+++ /dev/null
@@ -1,1468 +0,0 @@
-/*
- * Copyright (c) 1997, Stefan Esser <se@freebsd.org>
- * 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 unmodified, 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.
- *
- * $FreeBSD$
- *
- */
-
-#include "opt_bus.h"
-
-#include "opt_simos.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/malloc.h>
-#include <sys/module.h>
-#include <sys/fcntl.h>
-#include <sys/conf.h>
-#include <sys/kernel.h>
-#include <sys/queue.h>
-#include <sys/types.h>
-#include <sys/buf.h>
-
-#include <vm/vm.h>
-#include <vm/pmap.h>
-#include <vm/vm_extern.h>
-
-#include <sys/bus.h>
-#include <machine/bus.h>
-#include <sys/rman.h>
-#include <machine/resource.h>
-#include <machine/md_var.h> /* For the Alpha */
-
-#include <pci/pcireg.h>
-#include <pci/pcivar.h>
-#include <sys/pciio.h>
-
-#ifdef APIC_IO
-#include <machine/smp.h>
-#endif /* APIC_IO */
-
-struct pci_quirk {
- u_int32_t devid; /* Vendor/device of the card */
- int type;
-#define PCI_QUIRK_MAP_REG 1 /* PCI map register in wierd place */
- int arg1;
- int arg2;
-};
-
-struct pci_quirk pci_quirks[] = {
- /*
- * The Intel 82371AB has a map register at offset 0x90.
- */
- { 0x71138086, PCI_QUIRK_MAP_REG, 0x90, 0 },
-
- { 0 }
-};
-
-/* map register information */
-#define PCI_MAPMEM 0x01 /* memory map */
-#define PCI_MAPMEMP 0x02 /* prefetchable memory map */
-#define PCI_MAPPORT 0x04 /* port map */
-
-struct pci_devinfo {
- STAILQ_ENTRY(pci_devinfo) pci_links;
- struct resource_list resources;
- pcicfgregs cfg;
- struct pci_conf conf;
-};
-
-static STAILQ_HEAD(devlist, pci_devinfo) pci_devq;
-u_int32_t pci_numdevs = 0;
-static u_int32_t pci_generation = 0;
-
-/* return base address of memory or port map */
-
-static u_int32_t
-pci_mapbase(unsigned mapreg)
-{
- int mask = 0x03;
- if ((mapreg & 0x01) == 0)
- mask = 0x0f;
- return (mapreg & ~mask);
-}
-
-/* return map type of memory or port map */
-
-static int
-pci_maptype(unsigned mapreg)
-{
- static u_int8_t maptype[0x10] = {
- PCI_MAPMEM, PCI_MAPPORT,
- PCI_MAPMEM, 0,
- PCI_MAPMEM, PCI_MAPPORT,
- 0, 0,
- PCI_MAPMEM|PCI_MAPMEMP, PCI_MAPPORT,
- PCI_MAPMEM|PCI_MAPMEMP, 0,
- PCI_MAPMEM|PCI_MAPMEMP, PCI_MAPPORT,
- 0, 0,
- };
-
- return maptype[mapreg & 0x0f];
-}
-
-/* return log2 of map size decoded for memory or port map */
-
-static int
-pci_mapsize(unsigned testval)
-{
- int ln2size;
-
- testval = pci_mapbase(testval);
- ln2size = 0;
- if (testval != 0) {
- while ((testval & 1) == 0)
- {
- ln2size++;
- testval >>= 1;
- }
- }
- return (ln2size);
-}
-
-/* return log2 of address range supported by map register */
-
-static int
-pci_maprange(unsigned mapreg)
-{
- int ln2range = 0;
- switch (mapreg & 0x07) {
- case 0x00:
- case 0x01:
- case 0x05:
- ln2range = 32;
- break;
- case 0x02:
- ln2range = 20;
- break;
- case 0x04:
- ln2range = 64;
- break;
- }
- return (ln2range);
-}
-
-/* adjust some values from PCI 1.0 devices to match 2.0 standards ... */
-
-static void
-pci_fixancient(pcicfgregs *cfg)
-{
- if (cfg->hdrtype != 0)
- return;
-
- /* PCI to PCI bridges use header type 1 */
- if (cfg->baseclass == PCIC_BRIDGE && cfg->subclass == PCIS_BRIDGE_PCI)
- cfg->hdrtype = 1;
-}
-
-/* read config data specific to header type 1 device (PCI to PCI bridge) */
-
-static void *
-pci_readppb(pcicfgregs *cfg)
-{
- pcih1cfgregs *p;
-
- p = malloc(sizeof (pcih1cfgregs), M_DEVBUF, M_WAITOK);
- if (p == NULL)
- return (NULL);
-
- bzero(p, sizeof *p);
-
- p->secstat = pci_cfgread(cfg, PCIR_SECSTAT_1, 2);
- p->bridgectl = pci_cfgread(cfg, PCIR_BRIDGECTL_1, 2);
-
- p->seclat = pci_cfgread(cfg, PCIR_SECLAT_1, 1);
-
- p->iobase = PCI_PPBIOBASE (pci_cfgread(cfg, PCIR_IOBASEH_1, 2),
- pci_cfgread(cfg, PCIR_IOBASEL_1, 1));
- p->iolimit = PCI_PPBIOLIMIT (pci_cfgread(cfg, PCIR_IOLIMITH_1, 2),
- pci_cfgread(cfg, PCIR_IOLIMITL_1, 1));
-
- p->membase = PCI_PPBMEMBASE (0,
- pci_cfgread(cfg, PCIR_MEMBASE_1, 2));
- p->memlimit = PCI_PPBMEMLIMIT (0,
- pci_cfgread(cfg, PCIR_MEMLIMIT_1, 2));
-
- p->pmembase = PCI_PPBMEMBASE (
- (pci_addr_t)pci_cfgread(cfg, PCIR_PMBASEH_1, 4),
- pci_cfgread(cfg, PCIR_PMBASEL_1, 2));
-
- p->pmemlimit = PCI_PPBMEMLIMIT (
- (pci_addr_t)pci_cfgread(cfg, PCIR_PMLIMITH_1, 4),
- pci_cfgread(cfg, PCIR_PMLIMITL_1, 2));
- return (p);
-}
-
-/* read config data specific to header type 2 device (PCI to CardBus bridge) */
-
-static void *
-pci_readpcb(pcicfgregs *cfg)
-{
- pcih2cfgregs *p;
-
- p = malloc(sizeof (pcih2cfgregs), M_DEVBUF, M_WAITOK);
- if (p == NULL)
- return (NULL);
-
- bzero(p, sizeof *p);
-
- p->secstat = pci_cfgread(cfg, PCIR_SECSTAT_2, 2);
- p->bridgectl = pci_cfgread(cfg, PCIR_BRIDGECTL_2, 2);
-
- p->seclat = pci_cfgread(cfg, PCIR_SECLAT_2, 1);
-
- p->membase0 = pci_cfgread(cfg, PCIR_MEMBASE0_2, 4);
- p->memlimit0 = pci_cfgread(cfg, PCIR_MEMLIMIT0_2, 4);
- p->membase1 = pci_cfgread(cfg, PCIR_MEMBASE1_2, 4);
- p->memlimit1 = pci_cfgread(cfg, PCIR_MEMLIMIT1_2, 4);
-
- p->iobase0 = pci_cfgread(cfg, PCIR_IOBASE0_2, 4);
- p->iolimit0 = pci_cfgread(cfg, PCIR_IOLIMIT0_2, 4);
- p->iobase1 = pci_cfgread(cfg, PCIR_IOBASE1_2, 4);
- p->iolimit1 = pci_cfgread(cfg, PCIR_IOLIMIT1_2, 4);
-
- p->pccardif = pci_cfgread(cfg, PCIR_PCCARDIF_2, 4);
- return p;
-}
-
-/* extract header type specific config data */
-
-static void
-pci_hdrtypedata(pcicfgregs *cfg)
-{
- switch (cfg->hdrtype) {
- case 0:
- cfg->subvendor = pci_cfgread(cfg, PCIR_SUBVEND_0, 2);
- cfg->subdevice = pci_cfgread(cfg, PCIR_SUBDEV_0, 2);
- cfg->nummaps = PCI_MAXMAPS_0;
- break;
- case 1:
- cfg->subvendor = pci_cfgread(cfg, PCIR_SUBVEND_1, 2);
- cfg->subdevice = pci_cfgread(cfg, PCIR_SUBDEV_1, 2);
- cfg->secondarybus = pci_cfgread(cfg, PCIR_SECBUS_1, 1);
- cfg->subordinatebus = pci_cfgread(cfg, PCIR_SUBBUS_1, 1);
- cfg->nummaps = PCI_MAXMAPS_1;
- cfg->hdrspec = pci_readppb(cfg);
- break;
- case 2:
- cfg->subvendor = pci_cfgread(cfg, PCIR_SUBVEND_2, 2);
- cfg->subdevice = pci_cfgread(cfg, PCIR_SUBDEV_2, 2);
- cfg->secondarybus = pci_cfgread(cfg, PCIR_SECBUS_2, 1);
- cfg->subordinatebus = pci_cfgread(cfg, PCIR_SUBBUS_2, 1);
- cfg->nummaps = PCI_MAXMAPS_2;
- cfg->hdrspec = pci_readpcb(cfg);
- break;
- }
-}
-
-/* read configuration header into pcicfgrect structure */
-
-static struct pci_devinfo *
-pci_readcfg(pcicfgregs *probe)
-{
- pcicfgregs *cfg = NULL;
- struct pci_devinfo *devlist_entry;
- struct devlist *devlist_head;
-
- devlist_head = &pci_devq;
-
- devlist_entry = NULL;
-
- if (pci_cfgread(probe, PCIR_DEVVENDOR, 4) != -1) {
-
- devlist_entry = malloc(sizeof(struct pci_devinfo),
- M_DEVBUF, M_WAITOK);
- if (devlist_entry == NULL)
- return (NULL);
- bzero(devlist_entry, sizeof *devlist_entry);
-
- cfg = &devlist_entry->cfg;
-
- cfg->hose = probe->hose;
- cfg->bus = probe->bus;
- cfg->slot = probe->slot;
- cfg->func = probe->func;
- cfg->vendor = pci_cfgread(cfg, PCIR_VENDOR, 2);
- cfg->device = pci_cfgread(cfg, PCIR_DEVICE, 2);
- cfg->cmdreg = pci_cfgread(cfg, PCIR_COMMAND, 2);
- cfg->statreg = pci_cfgread(cfg, PCIR_STATUS, 2);
- cfg->baseclass = pci_cfgread(cfg, PCIR_CLASS, 1);
- cfg->subclass = pci_cfgread(cfg, PCIR_SUBCLASS, 1);
- cfg->progif = pci_cfgread(cfg, PCIR_PROGIF, 1);
- cfg->revid = pci_cfgread(cfg, PCIR_REVID, 1);
- cfg->hdrtype = pci_cfgread(cfg, PCIR_HEADERTYPE, 1);
- cfg->cachelnsz = pci_cfgread(cfg, PCIR_CACHELNSZ, 1);
- cfg->lattimer = pci_cfgread(cfg, PCIR_LATTIMER, 1);
- cfg->intpin = pci_cfgread(cfg, PCIR_INTPIN, 1);
- cfg->intline = pci_cfgread(cfg, PCIR_INTLINE, 1);
-#ifdef __alpha__
- alpha_platform_assign_pciintr(cfg);
-#endif
-
-#ifdef APIC_IO
- if (cfg->intpin != 0) {
- int airq;
-
- airq = pci_apic_irq(cfg->bus, cfg->slot, cfg->intpin);
- if (airq >= 0) {
- /* PCI specific entry found in MP table */
- if (airq != cfg->intline) {
- undirect_pci_irq(cfg->intline);
- cfg->intline = airq;
- }
- } else {
- /*
- * PCI interrupts might be redirected to the
- * ISA bus according to some MP tables. Use the
- * same methods as used by the ISA devices
- * devices to find the proper IOAPIC int pin.
- */
- airq = isa_apic_irq(cfg->intline);
- if ((airq >= 0) && (airq != cfg->intline)) {
- /* XXX: undirect_pci_irq() ? */
- undirect_isa_irq(cfg->intline);
- cfg->intline = airq;
- }
- }
- }
-#endif /* APIC_IO */
-
- cfg->mingnt = pci_cfgread(cfg, PCIR_MINGNT, 1);
- cfg->maxlat = pci_cfgread(cfg, PCIR_MAXLAT, 1);
-
- cfg->mfdev = (cfg->hdrtype & PCIM_MFDEV) != 0;
- cfg->hdrtype &= ~PCIM_MFDEV;
-
- pci_fixancient(cfg);
- pci_hdrtypedata(cfg);
-
- STAILQ_INSERT_TAIL(devlist_head, devlist_entry, pci_links);
-
- devlist_entry->conf.pc_sel.pc_bus = cfg->bus;
- devlist_entry->conf.pc_sel.pc_dev = cfg->slot;
- devlist_entry->conf.pc_sel.pc_func = cfg->func;
- devlist_entry->conf.pc_hdr = cfg->hdrtype;
-
- devlist_entry->conf.pc_subvendor = cfg->subvendor;
- devlist_entry->conf.pc_subdevice = cfg->subdevice;
- devlist_entry->conf.pc_vendor = cfg->vendor;
- devlist_entry->conf.pc_device = cfg->device;
-
- devlist_entry->conf.pc_class = cfg->baseclass;
- devlist_entry->conf.pc_subclass = cfg->subclass;
- devlist_entry->conf.pc_progif = cfg->progif;
- devlist_entry->conf.pc_revid = cfg->revid;
-
- pci_numdevs++;
- pci_generation++;
- }
- return (devlist_entry);
-}
-
-#if 0
-/* free pcicfgregs structure and all depending data structures */
-
-static int
-pci_freecfg(struct pci_devinfo *dinfo)
-{
- struct devlist *devlist_head;
-
- devlist_head = &pci_devq;
-
- if (dinfo->cfg.hdrspec != NULL)
- free(dinfo->cfg.hdrspec, M_DEVBUF);
- if (dinfo->cfg.map != NULL)
- free(dinfo->cfg.map, M_DEVBUF);
- /* XXX this hasn't been tested */
- STAILQ_REMOVE(devlist_head, dinfo, pci_devinfo, pci_links);
- free(dinfo, M_DEVBUF);
-
- /* increment the generation count */
- pci_generation++;
-
- /* we're losing one device */
- pci_numdevs--;
- return (0);
-}
-#endif
-
-
-/*
- * This is the user interface to PCI configuration space.
- */
-
-static int
-pci_open(dev_t dev, int oflags, int devtype, struct proc *p)
-{
- if ((oflags & FWRITE) && securelevel > 0) {
- return EPERM;
- }
- return 0;
-}
-
-static int
-pci_close(dev_t dev, int flag, int devtype, struct proc *p)
-{
- return 0;
-}
-
-/*
- * Match a single pci_conf structure against an array of pci_match_conf
- * structures. The first argument, 'matches', is an array of num_matches
- * pci_match_conf structures. match_buf is a pointer to the pci_conf
- * structure that will be compared to every entry in the matches array.
- * This function returns 1 on failure, 0 on success.
- */
-static int
-pci_conf_match(struct pci_match_conf *matches, int num_matches,
- struct pci_conf *match_buf)
-{
- int i;
-
- if ((matches == NULL) || (match_buf == NULL) || (num_matches <= 0))
- return(1);
-
- for (i = 0; i < num_matches; i++) {
- /*
- * I'm not sure why someone would do this...but...
- */
- if (matches[i].flags == PCI_GETCONF_NO_MATCH)
- continue;
-
- /*
- * Look at each of the match flags. If it's set, do the
- * comparison. If the comparison fails, we don't have a
- * match, go on to the next item if there is one.
- */
- if (((matches[i].flags & PCI_GETCONF_MATCH_BUS) != 0)
- && (match_buf->pc_sel.pc_bus != matches[i].pc_sel.pc_bus))
- continue;
-
- if (((matches[i].flags & PCI_GETCONF_MATCH_DEV) != 0)
- && (match_buf->pc_sel.pc_dev != matches[i].pc_sel.pc_dev))
- continue;
-
- if (((matches[i].flags & PCI_GETCONF_MATCH_FUNC) != 0)
- && (match_buf->pc_sel.pc_func != matches[i].pc_sel.pc_func))
- continue;
-
- if (((matches[i].flags & PCI_GETCONF_MATCH_VENDOR) != 0)
- && (match_buf->pc_vendor != matches[i].pc_vendor))
- continue;
-
- if (((matches[i].flags & PCI_GETCONF_MATCH_DEVICE) != 0)
- && (match_buf->pc_device != matches[i].pc_device))
- continue;
-
- if (((matches[i].flags & PCI_GETCONF_MATCH_CLASS) != 0)
- && (match_buf->pc_class != matches[i].pc_class))
- continue;
-
- if (((matches[i].flags & PCI_GETCONF_MATCH_UNIT) != 0)
- && (match_buf->pd_unit != matches[i].pd_unit))
- continue;
-
- if (((matches[i].flags & PCI_GETCONF_MATCH_NAME) != 0)
- && (strncmp(matches[i].pd_name, match_buf->pd_name,
- sizeof(match_buf->pd_name)) != 0))
- continue;
-
- return(0);
- }
-
- return(1);
-}
-
-/*
- * Locate the parent of a PCI device by scanning the PCI devlist
- * and return the entry for the parent.
- * For devices on PCI Bus 0 (the host bus), this is the PCI Host.
- * For devices on secondary PCI busses, this is that bus' PCI-PCI Bridge.
- */
-
-pcicfgregs *
-pci_devlist_get_parent(pcicfgregs *cfg)
-{
- struct devlist *devlist_head;
- struct pci_devinfo *dinfo;
- pcicfgregs *bridge_cfg;
- int i;
-
- dinfo = STAILQ_FIRST(devlist_head = &pci_devq);
-
- /* If the device is on PCI bus 0, look for the host */
- if (cfg->bus == 0) {
- for (i = 0; (dinfo != NULL) && (i < pci_numdevs);
- dinfo = STAILQ_NEXT(dinfo, pci_links), i++) {
- bridge_cfg = &dinfo->cfg;
- if (bridge_cfg->baseclass == PCIC_BRIDGE
- && bridge_cfg->subclass == PCIS_BRIDGE_HOST
- && bridge_cfg->bus == cfg->bus) {
- return bridge_cfg;
- }
- }
- }
-
- /* If the device is not on PCI bus 0, look for the PCI-PCI bridge */
- if (cfg->bus > 0) {
- for (i = 0; (dinfo != NULL) && (i < pci_numdevs);
- dinfo = STAILQ_NEXT(dinfo, pci_links), i++) {
- bridge_cfg = &dinfo->cfg;
- if (bridge_cfg->baseclass == PCIC_BRIDGE
- && bridge_cfg->subclass == PCIS_BRIDGE_PCI
- && bridge_cfg->secondarybus == cfg->bus) {
- return bridge_cfg;
- }
- }
- }
-
- return NULL;
-}
-
-static int
-pci_ioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
-{
- struct pci_io *io;
- const char *name;
- int error;
-
- if (!(flag & FWRITE))
- return EPERM;
-
-
- switch(cmd) {
- case PCIOCGETCONF:
- {
- struct pci_devinfo *dinfo;
- struct pci_conf_io *cio;
- struct devlist *devlist_head;
- struct pci_match_conf *pattern_buf;
- int num_patterns;
- size_t iolen;
- int ionum, i;
-
- cio = (struct pci_conf_io *)data;
-
- num_patterns = 0;
- dinfo = NULL;
-
- /*
- * Hopefully the user won't pass in a null pointer, but it
- * can't hurt to check.
- */
- if (cio == NULL) {
- error = EINVAL;
- break;
- }
-
- /*
- * If the user specified an offset into the device list,
- * but the list has changed since they last called this
- * ioctl, tell them that the list has changed. They will
- * have to get the list from the beginning.
- */
- if ((cio->offset != 0)
- && (cio->generation != pci_generation)){
- cio->num_matches = 0;
- cio->status = PCI_GETCONF_LIST_CHANGED;
- error = 0;
- break;
- }
-
- /*
- * Check to see whether the user has asked for an offset
- * past the end of our list.
- */
- if (cio->offset >= pci_numdevs) {
- cio->num_matches = 0;
- cio->status = PCI_GETCONF_LAST_DEVICE;
- error = 0;
- break;
- }
-
- /* get the head of the device queue */
- devlist_head = &pci_devq;
-
- /*
- * Determine how much room we have for pci_conf structures.
- * Round the user's buffer size down to the nearest
- * multiple of sizeof(struct pci_conf) in case the user
- * didn't specify a multiple of that size.
- */
- iolen = min(cio->match_buf_len -
- (cio->match_buf_len % sizeof(struct pci_conf)),
- pci_numdevs * sizeof(struct pci_conf));
-
- /*
- * Since we know that iolen is a multiple of the size of
- * the pciconf union, it's okay to do this.
- */
- ionum = iolen / sizeof(struct pci_conf);
-
- /*
- * If this test is true, the user wants the pci_conf
- * structures returned to match the supplied entries.
- */
- if ((cio->num_patterns > 0)
- && (cio->pat_buf_len > 0)) {
- /*
- * pat_buf_len needs to be:
- * num_patterns * sizeof(struct pci_match_conf)
- * While it is certainly possible the user just
- * allocated a large buffer, but set the number of
- * matches correctly, it is far more likely that
- * their kernel doesn't match the userland utility
- * they're using. It's also possible that the user
- * forgot to initialize some variables. Yes, this
- * may be overly picky, but I hazard to guess that
- * it's far more likely to just catch folks that
- * updated their kernel but not their userland.
- */
- if ((cio->num_patterns *
- sizeof(struct pci_match_conf)) != cio->pat_buf_len){
- /* The user made a mistake, return an error*/
- cio->status = PCI_GETCONF_ERROR;
- printf("pci_ioctl: pat_buf_len %d != "
- "num_patterns (%d) * sizeof(struct "
- "pci_match_conf) (%d)\npci_ioctl: "
- "pat_buf_len should be = %d\n",
- cio->pat_buf_len, cio->num_patterns,
- (int)sizeof(struct pci_match_conf),
- (int)sizeof(struct pci_match_conf) *
- cio->num_patterns);
- printf("pci_ioctl: do your headers match your "
- "kernel?\n");
- cio->num_matches = 0;
- error = EINVAL;
- break;
- }
-
- /*
- * Check the user's buffer to make sure it's readable.
- */
- if (!useracc((caddr_t)cio->patterns,
- cio->pat_buf_len, VM_PROT_READ)) {
- printf("pci_ioctl: pattern buffer %p, "
- "length %u isn't user accessible for"
- " READ\n", cio->patterns,
- cio->pat_buf_len);
- error = EACCES;
- break;
- }
- /*
- * Allocate a buffer to hold the patterns.
- */
- pattern_buf = malloc(cio->pat_buf_len, M_TEMP,
- M_WAITOK);
- error = copyin(cio->patterns, pattern_buf,
- cio->pat_buf_len);
- if (error != 0)
- break;
- num_patterns = cio->num_patterns;
-
- } else if ((cio->num_patterns > 0)
- || (cio->pat_buf_len > 0)) {
- /*
- * The user made a mistake, spit out an error.
- */
- cio->status = PCI_GETCONF_ERROR;
- cio->num_matches = 0;
- printf("pci_ioctl: invalid GETCONF arguments\n");
- error = EINVAL;
- break;
- } else
- pattern_buf = NULL;
-
- /*
- * Make sure we can write to the match buffer.
- */
- if (!useracc((caddr_t)cio->matches,
- cio->match_buf_len, VM_PROT_WRITE)) {
- printf("pci_ioctl: match buffer %p, length %u "
- "isn't user accessible for WRITE\n",
- cio->matches, cio->match_buf_len);
- error = EACCES;
- break;
- }
-
- /*
- * Go through the list of devices and copy out the devices
- * that match the user's criteria.
- */
- for (cio->num_matches = 0, error = 0, i = 0,
- dinfo = STAILQ_FIRST(devlist_head);
- (dinfo != NULL) && (cio->num_matches < ionum)
- && (error == 0) && (i < pci_numdevs);
- dinfo = STAILQ_NEXT(dinfo, pci_links), i++) {
-
- if (i < cio->offset)
- continue;
-
- /* Populate pd_name and pd_unit */
- name = NULL;
- if (dinfo->cfg.dev && dinfo->conf.pd_name[0] == '\0')
- name = device_get_name(dinfo->cfg.dev);
- if (name) {
- strncpy(dinfo->conf.pd_name, name,
- sizeof(dinfo->conf.pd_name));
- dinfo->conf.pd_name[PCI_MAXNAMELEN] = 0;
- dinfo->conf.pd_unit =
- device_get_unit(dinfo->cfg.dev);
- }
-
- if ((pattern_buf == NULL) ||
- (pci_conf_match(pattern_buf, num_patterns,
- &dinfo->conf) == 0)) {
-
- /*
- * If we've filled up the user's buffer,
- * break out at this point. Since we've
- * got a match here, we'll pick right back
- * up at the matching entry. We can also
- * tell the user that there are more matches
- * left.
- */
- if (cio->num_matches >= ionum)
- break;
-
- error = copyout(&dinfo->conf,
- &cio->matches[cio->num_matches],
- sizeof(struct pci_conf));
- cio->num_matches++;
- }
- }
-
- /*
- * Set the pointer into the list, so if the user is getting
- * n records at a time, where n < pci_numdevs,
- */
- cio->offset = i;
-
- /*
- * Set the generation, the user will need this if they make
- * another ioctl call with offset != 0.
- */
- cio->generation = pci_generation;
-
- /*
- * If this is the last device, inform the user so he won't
- * bother asking for more devices. If dinfo isn't NULL, we
- * know that there are more matches in the list because of
- * the way the traversal is done.
- */
- if (dinfo == NULL)
- cio->status = PCI_GETCONF_LAST_DEVICE;
- else
- cio->status = PCI_GETCONF_MORE_DEVS;
-
- if (pattern_buf != NULL)
- free(pattern_buf, M_TEMP);
-
- break;
- }
- case PCIOCREAD:
- io = (struct pci_io *)data;
- switch(io->pi_width) {
- pcicfgregs probe;
- case 4:
- case 2:
- case 1:
- probe.hose = -1;
- probe.bus = io->pi_sel.pc_bus;
- probe.slot = io->pi_sel.pc_dev;
- probe.func = io->pi_sel.pc_func;
- io->pi_data = pci_cfgread(&probe,
- io->pi_reg, io->pi_width);
- error = 0;
- break;
- default:
- error = ENODEV;
- break;
- }
- break;
-
- case PCIOCWRITE:
- io = (struct pci_io *)data;
- switch(io->pi_width) {
- pcicfgregs probe;
- case 4:
- case 2:
- case 1:
- probe.hose = -1;
- probe.bus = io->pi_sel.pc_bus;
- probe.slot = io->pi_sel.pc_dev;
- probe.func = io->pi_sel.pc_func;
- pci_cfgwrite(&probe,
- io->pi_reg, io->pi_data, io->pi_width);
- error = 0;
- break;
- default:
- error = ENODEV;
- break;
- }
- break;
-
- default:
- error = ENOTTY;
- break;
- }
-
- return (error);
-}
-
-#define PCI_CDEV 78
-
-static struct cdevsw pcicdev = {
- /* open */ pci_open,
- /* close */ pci_close,
- /* read */ noread,
- /* write */ nowrite,
- /* ioctl */ pci_ioctl,
- /* poll */ nopoll,
- /* mmap */ nommap,
- /* strategy */ nostrategy,
- /* name */ "pci",
- /* maj */ PCI_CDEV,
- /* dump */ nodump,
- /* psize */ nopsize,
- /* flags */ 0,
- /* bmaj */ -1
-};
-
-#include "pci_if.h"
-
-/*
- * A simple driver to wrap the old pci driver mechanism for back-compat.
- */
-
-static int
-pci_compat_probe(device_t dev)
-{
- struct pci_device *dvp;
- struct pci_devinfo *dinfo;
- pcicfgregs *cfg;
- const char *name;
- int error;
-
- dinfo = device_get_ivars(dev);
- cfg = &dinfo->cfg;
- dvp = device_get_driver(dev)->priv;
-
- /*
- * Do the wrapped probe.
- */
- error = ENXIO;
- if (dvp && dvp->pd_probe) {
- name = dvp->pd_probe(cfg, (cfg->device << 16) + cfg->vendor);
- if (name) {
- device_set_desc_copy(dev, name);
- /* Allow newbus drivers to match "better" */
- error = -200;
- }
- }
-
- return error;
-}
-
-static int
-pci_compat_attach(device_t dev)
-{
- struct pci_device *dvp;
- struct pci_devinfo *dinfo;
- pcicfgregs *cfg;
- int unit;
-
- dinfo = device_get_ivars(dev);
- cfg = &dinfo->cfg;
- dvp = device_get_driver(dev)->priv;
-
- unit = device_get_unit(dev);
- if (unit > *dvp->pd_count)
- *dvp->pd_count = unit;
- if (dvp->pd_attach)
- dvp->pd_attach(cfg, unit);
- device_printf(dev, "driver is using old-style compatability shims\n");
- return 0;
-}
-
-static device_method_t pci_compat_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, pci_compat_probe),
- DEVMETHOD(device_attach, pci_compat_attach),
-
- { 0, 0 }
-};
-
-static devclass_t pci_devclass;
-
-/*
- * Create a new style driver around each old pci driver.
- */
-int
-compat_pci_handler(module_t mod, int type, void *data)
-{
- struct pci_device *dvp = (struct pci_device *)data;
- driver_t *driver;
-
- switch (type) {
- case MOD_LOAD:
- driver = malloc(sizeof(driver_t), M_DEVBUF, M_NOWAIT);
- if (!driver)
- return ENOMEM;
- bzero(driver, sizeof(driver_t));
- driver->name = dvp->pd_name;
- driver->methods = pci_compat_methods;
- driver->softc = sizeof(struct pci_devinfo *);
- driver->priv = dvp;
- devclass_add_driver(pci_devclass, driver);
- break;
- case MOD_UNLOAD:
- printf("%s: module unload not supported!\n", dvp->pd_name);
- return EOPNOTSUPP;
- default:
- break;
- }
- return 0;
-}
-
-/*
- * New style pci driver. Parent device is either a pci-host-bridge or a
- * pci-pci-bridge. Both kinds are represented by instances of pcib.
- */
-
-static void
-pci_print_verbose(struct pci_devinfo *dinfo)
-{
- if (bootverbose) {
- pcicfgregs *cfg = &dinfo->cfg;
-
- printf("found->\tvendor=0x%04x, dev=0x%04x, revid=0x%02x\n",
- cfg->vendor, cfg->device, cfg->revid);
- printf("\tclass=%02x-%02x-%02x, hdrtype=0x%02x, mfdev=%d\n",
- cfg->baseclass, cfg->subclass, cfg->progif,
- cfg->hdrtype, cfg->mfdev);
- printf("\tsubordinatebus=%x \tsecondarybus=%x\n",
- cfg->subordinatebus, cfg->secondarybus);
-#ifdef PCI_DEBUG
- printf("\tcmdreg=0x%04x, statreg=0x%04x, cachelnsz=%d (dwords)\n",
- cfg->cmdreg, cfg->statreg, cfg->cachelnsz);
- printf("\tlattimer=0x%02x (%d ns), mingnt=0x%02x (%d ns), maxlat=0x%02x (%d ns)\n",
- cfg->lattimer, cfg->lattimer * 30,
- cfg->mingnt, cfg->mingnt * 250, cfg->maxlat, cfg->maxlat * 250);
-#endif /* PCI_DEBUG */
- if (cfg->intpin > 0)
- printf("\tintpin=%c, irq=%d\n", cfg->intpin +'a' -1, cfg->intline);
- }
-}
-
-static int
-pci_porten(pcicfgregs *cfg)
-{
- return ((cfg->cmdreg & PCIM_CMD_PORTEN) != 0);
-}
-
-static int
-pci_memen(pcicfgregs *cfg)
-{
- return ((cfg->cmdreg & PCIM_CMD_MEMEN) != 0);
-}
-
-/*
- * Add a resource based on a pci map register. Return 1 if the map
- * register is a 32bit map register or 2 if it is a 64bit register.
- */
-static int
-pci_add_map(device_t dev, pcicfgregs* cfg, int reg)
-{
- struct pci_devinfo *dinfo = device_get_ivars(dev);
- struct resource_list *rl = &dinfo->resources;
- u_int32_t map;
- u_int64_t base;
- u_int8_t ln2size;
- u_int8_t ln2range;
- u_int32_t testval;
-
- int type;
-
- map = pci_cfgread(cfg, reg, 4);
-
- if (map == 0 || map == 0xffffffff)
- return 1; /* skip invalid entry */
-
- pci_cfgwrite(cfg, reg, 0xffffffff, 4);
- testval = pci_cfgread(cfg, reg, 4);
- pci_cfgwrite(cfg, reg, map, 4);
-
- base = pci_mapbase(map);
- if (pci_maptype(map) & PCI_MAPMEM)
- type = SYS_RES_MEMORY;
- else
- type = SYS_RES_IOPORT;
- ln2size = pci_mapsize(testval);
- ln2range = pci_maprange(testval);
- if (ln2range == 64) {
- /* Read the other half of a 64bit map register */
- base |= (u_int64_t) pci_cfgread(cfg, reg + 4, 4) << 32;
- }
-
-#ifdef __alpha__
- /*
- * XXX: encode hose number in the base addr,
- * This will go away once the bus_space functions
- * can deal with multiple hoses
- */
-
- if(cfg->hose){
- if (base & 0x80000000) {
- printf("base addr = 0x%lx\n", base);
- printf("hacked addr = 0x%lx\n",
- base | ((u_int64_t)cfg->hose << 31));
-
- panic("hose encoding hack would clobber base addr");
- }
- if (cfg->hose > 1)
- panic("only one hose supported!");
- base |= ((u_int64_t)cfg->hose << 31);
- }
-#endif
- if (type == SYS_RES_IOPORT && !pci_porten(cfg))
- return 1;
- if (type == SYS_RES_MEMORY && !pci_memen(cfg))
- return 1;
-
- resource_list_add(rl, type, reg,
- base, base + (1 << ln2size) - 1,
- (1 << ln2size));
-
- if (bootverbose) {
- printf("\tmap[%02x]: type %x, range %2d, base %08x, size %2d\n",
- reg, pci_maptype(base), ln2range,
- (unsigned int) base, ln2size);
- }
-
- return (ln2range == 64) ? 2 : 1;
-}
-
-static void
-pci_add_resources(device_t dev, pcicfgregs* cfg)
-{
- struct pci_devinfo *dinfo = device_get_ivars(dev);
- struct resource_list *rl = &dinfo->resources;
- struct pci_quirk *q;
- int i;
-
- for (i = 0; i < cfg->nummaps;) {
- i += pci_add_map(dev, cfg, PCIR_MAPS + i*4);
- }
-
- for (q = &pci_quirks[0]; q->devid; q++) {
- if (q->devid == ((cfg->device << 16) | cfg->vendor)
- && q->type == PCI_QUIRK_MAP_REG)
- pci_add_map(dev, cfg, q->arg1);
- }
-
- if (cfg->intpin > 0 && cfg->intline != 255)
- resource_list_add(rl, SYS_RES_IRQ, 0,
- cfg->intline, cfg->intline, 1);
-}
-
-static void
-pci_add_children(device_t dev, int busno)
-{
- pcicfgregs probe;
-
-#ifdef SIMOS
-#undef PCI_SLOTMAX
-#define PCI_SLOTMAX 0
-#endif
-
- bzero(&probe, sizeof probe);
-#ifdef __alpha__
- probe.hose = pcib_get_hose(dev);
-#endif
-#ifdef __i386__
- probe.hose = 0;
-#endif
- probe.bus = busno;
-
- for (probe.slot = 0; probe.slot <= PCI_SLOTMAX; probe.slot++) {
- int pcifunchigh = 0;
- for (probe.func = 0; probe.func <= pcifunchigh; probe.func++) {
- struct pci_devinfo *dinfo = pci_readcfg(&probe);
- if (dinfo != NULL) {
- if (dinfo->cfg.mfdev)
- pcifunchigh = 7;
-
- pci_print_verbose(dinfo);
- dinfo->cfg.dev = device_add_child(dev, NULL, -1);
- device_set_ivars(dinfo->cfg.dev, dinfo);
- pci_add_resources(dinfo->cfg.dev, &dinfo->cfg);
- }
- }
- }
-}
-
-static int
-pci_new_probe(device_t dev)
-{
- static int once;
-
- device_set_desc(dev, "PCI bus");
- pci_add_children(dev, device_get_unit(dev));
- if (!once) {
- make_dev(&pcicdev, 0, UID_ROOT, GID_WHEEL, 0644, "pci");
- once++;
- }
-
- return 0;
-}
-
-static int
-pci_print_resources(struct resource_list *rl, const char *name, int type,
- const char *format)
-{
- struct resource_list_entry *rle;
- int printed, retval;
-
- printed = 0;
- retval = 0;
- /* Yes, this is kinda cheating */
- SLIST_FOREACH(rle, rl, link) {
- if (rle->type == type) {
- if (printed == 0)
- retval += printf(" %s ", name);
- else if (printed > 0)
- retval += printf(",");
- printed++;
- retval += printf(format, rle->start);
- if (rle->count > 1) {
- retval += printf("-");
- retval += printf(format, rle->start +
- rle->count - 1);
- }
- }
- }
- return retval;
-}
-
-static int
-pci_print_child(device_t dev, device_t child)
-{
- struct pci_devinfo *dinfo;
- struct resource_list *rl;
- pcicfgregs *cfg;
- int retval = 0;
-
- dinfo = device_get_ivars(child);
- cfg = &dinfo->cfg;
- rl = &dinfo->resources;
-
- retval += bus_print_child_header(dev, child);
-
- retval += pci_print_resources(rl, "port", SYS_RES_IOPORT, "%#lx");
- retval += pci_print_resources(rl, "mem", SYS_RES_MEMORY, "%#lx");
- retval += pci_print_resources(rl, "irq", SYS_RES_IRQ, "%ld");
- if (device_get_flags(dev))
- retval += printf(" flags %#x", device_get_flags(dev));
-
- retval += printf(" at device %d.%d", pci_get_slot(child),
- pci_get_function(child));
-
- retval += bus_print_child_footer(dev, child);
-
- return (retval);
-}
-
-static void
-pci_probe_nomatch(device_t dev, device_t child)
-{
- struct pci_devinfo *dinfo;
- pcicfgregs *cfg;
- const char *desc;
- int unknown;
-
- unknown = 0;
- dinfo = device_get_ivars(child);
- cfg = &dinfo->cfg;
- desc = pci_ata_match(child);
- if (!desc) desc = pci_usb_match(child);
- if (!desc) desc = pci_vga_match(child);
- if (!desc) {
- desc = "unknown card";
- unknown++;
- }
- device_printf(dev, "<%s>", desc);
- if (bootverbose || unknown) {
- printf(" (vendor=0x%04x, dev=0x%04x)",
- cfg->vendor,
- cfg->device);
- }
- printf(" at %d.%d",
- pci_get_slot(child),
- pci_get_function(child));
- if (cfg->intpin > 0 && cfg->intline != 255) {
- printf(" irq %d", cfg->intline);
- }
- printf("\n");
-
- return;
-}
-
-static int
-pci_read_ivar(device_t dev, device_t child, int which, u_long *result)
-{
- struct pci_devinfo *dinfo;
- pcicfgregs *cfg;
-
- dinfo = device_get_ivars(child);
- cfg = &dinfo->cfg;
-
- switch (which) {
- case PCI_IVAR_SUBVENDOR:
- *result = cfg->subvendor;
- break;
- case PCI_IVAR_SUBDEVICE:
- *result = cfg->subdevice;
- break;
- case PCI_IVAR_VENDOR:
- *result = cfg->vendor;
- break;
- case PCI_IVAR_DEVICE:
- *result = cfg->device;
- break;
- case PCI_IVAR_DEVID:
- *result = (cfg->device << 16) | cfg->vendor;
- break;
- case PCI_IVAR_CLASS:
- *result = cfg->baseclass;
- break;
- case PCI_IVAR_SUBCLASS:
- *result = cfg->subclass;
- break;
- case PCI_IVAR_PROGIF:
- *result = cfg->progif;
- break;
- case PCI_IVAR_REVID:
- *result = cfg->revid;
- break;
- case PCI_IVAR_INTPIN:
- *result = cfg->intpin;
- break;
- case PCI_IVAR_IRQ:
- *result = cfg->intline;
- break;
- case PCI_IVAR_BUS:
- *result = cfg->bus;
- break;
- case PCI_IVAR_SLOT:
- *result = cfg->slot;
- break;
- case PCI_IVAR_FUNCTION:
- *result = cfg->func;
- break;
- case PCI_IVAR_SECONDARYBUS:
- *result = cfg->secondarybus;
- break;
- case PCI_IVAR_SUBORDINATEBUS:
- *result = cfg->subordinatebus;
- break;
- case PCI_IVAR_HOSE:
- /*
- * Pass up to parent bridge.
- */
- *result = pcib_get_hose(dev);
- break;
- default:
- return ENOENT;
- }
- return 0;
-}
-
-static int
-pci_write_ivar(device_t dev, device_t child, int which, uintptr_t value)
-{
- struct pci_devinfo *dinfo;
- pcicfgregs *cfg;
-
- dinfo = device_get_ivars(child);
- cfg = &dinfo->cfg;
-
- switch (which) {
- case PCI_IVAR_SUBVENDOR:
- case PCI_IVAR_SUBDEVICE:
- case PCI_IVAR_VENDOR:
- case PCI_IVAR_DEVICE:
- case PCI_IVAR_DEVID:
- case PCI_IVAR_CLASS:
- case PCI_IVAR_SUBCLASS:
- case PCI_IVAR_PROGIF:
- case PCI_IVAR_REVID:
- case PCI_IVAR_INTPIN:
- case PCI_IVAR_IRQ:
- case PCI_IVAR_BUS:
- case PCI_IVAR_SLOT:
- case PCI_IVAR_FUNCTION:
- return EINVAL; /* disallow for now */
-
- case PCI_IVAR_SECONDARYBUS:
- cfg->secondarybus = value;
- break;
- case PCI_IVAR_SUBORDINATEBUS:
- cfg->subordinatebus = value;
- break;
- default:
- return ENOENT;
- }
- return 0;
-}
-
-static struct resource *
-pci_alloc_resource(device_t dev, device_t child, int type, int *rid,
- u_long start, u_long end, u_long count, u_int flags)
-{
- struct pci_devinfo *dinfo = device_get_ivars(child);
- struct resource_list *rl = &dinfo->resources;
-
- return resource_list_alloc(rl, dev, child, type, rid,
- start, end, count, flags);
-}
-
-static int
-pci_release_resource(device_t dev, device_t child, int type, int rid,
- struct resource *r)
-{
- struct pci_devinfo *dinfo = device_get_ivars(child);
- struct resource_list *rl = &dinfo->resources;
-
- return resource_list_release(rl, dev, child, type, rid, r);
-}
-
-static int
-pci_set_resource(device_t dev, device_t child, int type, int rid,
- u_long start, u_long count)
-{
- struct pci_devinfo *dinfo = device_get_ivars(child);
- struct resource_list *rl = &dinfo->resources;
-
- resource_list_add(rl, type, rid, start, start + count - 1, count);
- return 0;
-}
-
-static int
-pci_get_resource(device_t dev, device_t child, int type, int rid,
- u_long *startp, u_long *countp)
-{
- struct pci_devinfo *dinfo = device_get_ivars(child);
- struct resource_list *rl = &dinfo->resources;
- struct resource_list_entry *rle;
-
- rle = resource_list_find(rl, type, rid);
- if (!rle)
- return ENOENT;
-
- if (startp)
- *startp = rle->start;
- if (countp)
- *countp = rle->count;
-
- return 0;
-}
-
-static void
-pci_delete_resource(device_t dev, device_t child, int type, int rid)
-{
- printf("pci_delete_resource: PCI resources can not be deleted\n");
-}
-
-static u_int32_t
-pci_read_config_method(device_t dev, device_t child, int reg, int width)
-{
- struct pci_devinfo *dinfo = device_get_ivars(child);
- pcicfgregs *cfg = &dinfo->cfg;
- return pci_cfgread(cfg, reg, width);
-}
-
-static void
-pci_write_config_method(device_t dev, device_t child, int reg,
- u_int32_t val, int width)
-{
- struct pci_devinfo *dinfo = device_get_ivars(child);
- pcicfgregs *cfg = &dinfo->cfg;
- pci_cfgwrite(cfg, reg, val, width);
-}
-
-static int
-pci_modevent(module_t mod, int what, void *arg)
-{
- switch (what) {
- case MOD_LOAD:
- STAILQ_INIT(&pci_devq);
- break;
-
- case MOD_UNLOAD:
- break;
- }
-
- return 0;
-}
-
-static device_method_t pci_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, pci_new_probe),
- DEVMETHOD(device_attach, bus_generic_attach),
- DEVMETHOD(device_shutdown, bus_generic_shutdown),
- DEVMETHOD(device_suspend, bus_generic_suspend),
- DEVMETHOD(device_resume, bus_generic_resume),
-
- /* Bus interface */
- DEVMETHOD(bus_print_child, pci_print_child),
- DEVMETHOD(bus_probe_nomatch, pci_probe_nomatch),
- DEVMETHOD(bus_read_ivar, pci_read_ivar),
- DEVMETHOD(bus_write_ivar, pci_write_ivar),
- DEVMETHOD(bus_driver_added, bus_generic_driver_added),
- DEVMETHOD(bus_alloc_resource, pci_alloc_resource),
- DEVMETHOD(bus_release_resource, pci_release_resource),
- DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
- DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
- DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
- DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
- DEVMETHOD(bus_set_resource, pci_set_resource),
- DEVMETHOD(bus_get_resource, pci_get_resource),
- DEVMETHOD(bus_delete_resource, pci_delete_resource),
-
- /* PCI interface */
- DEVMETHOD(pci_read_config, pci_read_config_method),
- DEVMETHOD(pci_write_config, pci_write_config_method),
-
- { 0, 0 }
-};
-
-static driver_t pci_driver = {
- "pci",
- pci_methods,
- 1, /* no softc */
-};
-
-DRIVER_MODULE(pci, pcib, pci_driver, pci_devclass, pci_modevent, 0);
diff --git a/sys/dev/pci/pci_if.m b/sys/dev/pci/pci_if.m
deleted file mode 100644
index 95b0081ca32b..000000000000
--- a/sys/dev/pci/pci_if.m
+++ /dev/null
@@ -1,44 +0,0 @@
-#
-# Copyright (c) 1998 Doug Rabson
-# 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 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 AUTHOR 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.
-#
-# $FreeBSD$
-#
-
-INTERFACE pci;
-
-METHOD u_int32_t read_config {
- device_t dev;
- device_t child;
- int reg;
- int width;
-};
-
-METHOD void write_config {
- device_t dev;
- device_t child;
- int reg;
- u_int32_t val;
- int width;
-};
diff --git a/sys/dev/pci/pcireg.h b/sys/dev/pci/pcireg.h
deleted file mode 100644
index 0f6fb28e07d4..000000000000
--- a/sys/dev/pci/pcireg.h
+++ /dev/null
@@ -1,260 +0,0 @@
-#ifndef PCI_COMPAT
-#define PCI_COMPAT
-#endif
-/*
- * Copyright (c) 1997, Stefan Esser <se@freebsd.org>
- * 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 unmodified, 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.
- *
- * $FreeBSD$
- *
- */
-
-/*
- * PCIM_xxx: mask to locate subfield in register
- * PCIR_xxx: config register offset
- * PCIC_xxx: device class
- * PCIS_xxx: device subclass
- * PCIP_xxx: device programming interface
- * PCIV_xxx: PCI vendor ID (only required to fixup ancient devices)
- * PCID_xxx: device ID
- */
-
-/* some PCI bus constants */
-
-#define PCI_BUSMAX 255
-#define PCI_SLOTMAX 31
-#define PCI_FUNCMAX 7
-#define PCI_REGMAX 255
-
-/* PCI config header registers for all devices */
-
-#define PCIR_DEVVENDOR 0x00
-#define PCIR_VENDOR 0x00
-#define PCIR_DEVICE 0x02
-#define PCIR_COMMAND 0x04
-#define PCIM_CMD_PORTEN 0x0001
-#define PCIM_CMD_MEMEN 0x0002
-#define PCIM_CMD_BUSMASTEREN 0x0004
-#define PCIM_CMD_PERRESPEN 0x0040
-#define PCIR_STATUS 0x06
-#define PCIR_REVID 0x08
-#define PCIR_PROGIF 0x09
-#define PCIR_SUBCLASS 0x0a
-#define PCIR_CLASS 0x0b
-#define PCIR_CACHELNSZ 0x0c
-#define PCIR_LATTIMER 0x0d
-#define PCIR_HEADERTYPE 0x0e
-#define PCIM_MFDEV 0x80
-#define PCIR_BIST 0x0f
-
-/* config registers for header type 0 devices */
-
-#define PCIR_MAPS 0x10
-#define PCIR_CARDBUSCIS 0x28
-#define PCIR_SUBVEND_0 0x2c
-#define PCIR_SUBDEV_0 0x2e
-#define PCIR_BIOS 0x30
-#define PCIM_BIOS_ENABLE 0x01
-#define PCIR_INTLINE 0x3c
-#define PCIR_INTPIN 0x3d
-#define PCIR_MINGNT 0x3e
-#define PCIR_MAXLAT 0x3f
-
-/* config registers for header type 1 devices */
-
-#define PCIR_SECSTAT_1 0 /**/
-
-#define PCIR_PRIBUS_1 0x18
-#define PCIR_SECBUS_1 0x19
-#define PCIR_SUBBUS_1 0x1a
-#define PCIR_SECLAT_1 0x1b
-
-#define PCIR_IOBASEL_1 0x1c
-#define PCIR_IOLIMITL_1 0x1d
-#define PCIR_IOBASEH_1 0 /**/
-#define PCIR_IOLIMITH_1 0 /**/
-
-#define PCIR_MEMBASE_1 0x20
-#define PCIR_MEMLIMIT_1 0x22
-
-#define PCIR_PMBASEL_1 0x24
-#define PCIR_PMLIMITL_1 0x26
-#define PCIR_PMBASEH_1 0 /**/
-#define PCIR_PMLIMITH_1 0 /**/
-
-#define PCIR_BRIDGECTL_1 0 /**/
-
-#define PCIR_SUBVEND_1 0x34
-#define PCIR_SUBDEV_1 0x36
-
-/* config registers for header type 2 devices */
-
-#define PCIR_SECSTAT_2 0x16
-
-#define PCIR_PRIBUS_2 0x18
-#define PCIR_SECBUS_2 0x19
-#define PCIR_SUBBUS_2 0x1a
-#define PCIR_SECLAT_2 0x1b
-
-#define PCIR_MEMBASE0_2 0x1c
-#define PCIR_MEMLIMIT0_2 0x20
-#define PCIR_MEMBASE1_2 0x24
-#define PCIR_MEMLIMIT1_2 0x28
-#define PCIR_IOBASE0_2 0x2c
-#define PCIR_IOLIMIT0_2 0x30
-#define PCIR_IOBASE1_2 0x34
-#define PCIR_IOLIMIT1_2 0x38
-
-#define PCIR_BRIDGECTL_2 0x3e
-
-#define PCIR_SUBVEND_2 0x40
-#define PCIR_SUBDEV_2 0x42
-
-#define PCIR_PCCARDIF_2 0x44
-
-/* PCI device class, subclass and programming interface definitions */
-
-#define PCIC_OLD 0x00
-#define PCIS_OLD_NONVGA 0x00
-#define PCIS_OLD_VGA 0x01
-
-#define PCIC_STORAGE 0x01
-#define PCIS_STORAGE_SCSI 0x00
-#define PCIS_STORAGE_IDE 0x01
-#define PCIP_STORAGE_IDE_MODEPRIM 0x01
-#define PCIP_STORAGE_IDE_PROGINDPRIM 0x02
-#define PCIP_STORAGE_IDE_MODESEC 0x04
-#define PCIP_STORAGE_IDE_PROGINDSEC 0x08
-#define PCIP_STORAGE_IDE_MASTERDEV 0x80
-#define PCIS_STORAGE_FLOPPY 0x02
-#define PCIS_STORAGE_IPI 0x03
-#define PCIS_STORAGE_RAID 0x04
-#define PCIS_STORAGE_OTHER 0x80
-
-#define PCIC_NETWORK 0x02
-#define PCIS_NETWORK_ETHERNET 0x00
-#define PCIS_NETWORK_TOKENRING 0x01
-#define PCIS_NETWORK_FDDI 0x02
-#define PCIS_NETWORK_ATM 0x03
-#define PCIS_NETWORK_OTHER 0x80
-
-#define PCIC_DISPLAY 0x03
-#define PCIS_DISPLAY_VGA 0x00
-#define PCIS_DISPLAY_XGA 0x01
-#define PCIS_DISPLAY_OTHER 0x80
-
-#define PCIC_MULTIMEDIA 0x04
-#define PCIS_MULTIMEDIA_VIDEO 0x00
-#define PCIS_MULTIMEDIA_AUDIO 0x01
-#define PCIS_MULTIMEDIA_OTHER 0x80
-
-#define PCIC_MEMORY 0x05
-#define PCIS_MEMORY_RAM 0x00
-#define PCIS_MEMORY_FLASH 0x01
-#define PCIS_MEMORY_OTHER 0x80
-
-#define PCIC_BRIDGE 0x06
-#define PCIS_BRIDGE_HOST 0x00
-#define PCIS_BRIDGE_ISA 0x01
-#define PCIS_BRIDGE_EISA 0x02
-#define PCIS_BRIDGE_MCA 0x03
-#define PCIS_BRIDGE_PCI 0x04
-#define PCIS_BRIDGE_PCMCIA 0x05
-#define PCIS_BRIDGE_NUBUS 0x06
-#define PCIS_BRIDGE_CARDBUS 0x07
-#define PCIS_BRIDGE_OTHER 0x80
-
-#define PCIC_SIMPLECOMM 0x07
-#define PCIS_SIMPLECOMM_UART 0x00
-#define PCIP_SIMPLECOMM_UART_16550A 0x02
-#define PCIS_SIMPLECOMM_PAR 0x01
-#define PCIS_SIMPLECOMM_OTHER 0x80
-
-#define PCIC_BASEPERIPH 0x08
-#define PCIS_BASEPERIPH_PIC 0x00
-#define PCIS_BASEPERIPH_DMA 0x01
-#define PCIS_BASEPERIPH_TIMER 0x02
-#define PCIS_BASEPERIPH_RTC 0x03
-#define PCIS_BASEPERIPH_OTHER 0x80
-
-#define PCIC_INPUTDEV 0x09
-#define PCIS_INPUTDEV_KEYBOARD 0x00
-#define PCIS_INPUTDEV_DIGITIZER 0x01
-#define PCIS_INPUTDEV_MOUSE 0x02
-#define PCIS_INPUTDEV_OTHER 0x80
-
-#define PCIC_DOCKING 0x0a
-#define PCIS_DOCKING_GENERIC 0x00
-#define PCIS_DOCKING_OTHER 0x80
-
-#define PCIC_PROCESSOR 0x0b
-#define PCIS_PROCESSOR_386 0x00
-#define PCIS_PROCESSOR_486 0x01
-#define PCIS_PROCESSOR_PENTIUM 0x02
-#define PCIS_PROCESSOR_ALPHA 0x10
-#define PCIS_PROCESSOR_POWERPC 0x20
-#define PCIS_PROCESSOR_COPROC 0x40
-
-#define PCIC_SERIALBUS 0x0c
-#define PCIS_SERIALBUS_FW 0x00
-#define PCIS_SERIALBUS_ACCESS 0x01
-#define PCIS_SERIALBUS_SSA 0x02
-#define PCIS_SERIALBUS_USB 0x03
-#define PCIS_SERIALBUS_FC 0x04
-#define PCIS_SERIALBUS
-#define PCIS_SERIALBUS
-
-#define PCIC_OTHER 0xff
-
-/* some PCI vendor definitions (only used to identify ancient devices !!! */
-
-#define PCIV_INTEL 0x8086
-
-#define PCID_INTEL_SATURN 0x0483
-#define PCID_INTEL_ORION 0x84c4
-
-/* for compatibility to FreeBSD-2.2 version of PCI code */
-
-#ifdef PCI_COMPAT
-
-#define PCI_ID_REG 0x00
-#define PCI_COMMAND_STATUS_REG 0x04
-#define PCI_COMMAND_IO_ENABLE 0x00000001
-#define PCI_COMMAND_MEM_ENABLE 0x00000002
-#define PCI_CLASS_REG 0x08
-#define PCI_CLASS_MASK 0xff000000
-#define PCI_SUBCLASS_MASK 0x00ff0000
-#define PCI_REVISION_MASK 0x000000ff
-#define PCI_CLASS_PREHISTORIC 0x00000000
-#define PCI_SUBCLASS_PREHISTORIC_VGA 0x00010000
-#define PCI_CLASS_MASS_STORAGE 0x01000000
-#define PCI_CLASS_DISPLAY 0x03000000
-#define PCI_SUBCLASS_DISPLAY_VGA 0x00000000
-#define PCI_CLASS_BRIDGE 0x06000000
-#define PCI_MAP_REG_START 0x10
-#define PCI_MAP_REG_END 0x28
-#define PCI_MAP_IO 0x00000001
-#define PCI_INTERRUPT_REG 0x3c
-
-#endif /* PCI_COMPAT */
diff --git a/sys/dev/pci/pcivar.h b/sys/dev/pci/pcivar.h
deleted file mode 100644
index 9c345c08d969..000000000000
--- a/sys/dev/pci/pcivar.h
+++ /dev/null
@@ -1,327 +0,0 @@
-/*
- * Copyright (c) 1997, Stefan Esser <se@freebsd.org>
- * 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 unmodified, 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.
- *
- * $FreeBSD$
- *
- */
-
-#ifndef _PCIVAR_H_
-#define _PCIVAR_H_
-
-#ifndef PCI_COMPAT
-#define PCI_COMPAT
-#endif
-
-#include <sys/queue.h>
-
-/* some PCI bus constants */
-
-#define PCI_BUSMAX 255 /* highest supported bus number */
-#define PCI_SLOTMAX 31 /* highest supported slot number */
-#define PCI_FUNCMAX 7 /* highest supported function number */
-#define PCI_REGMAX 255 /* highest supported config register addr. */
-
-#define PCI_MAXMAPS_0 6 /* max. no. of memory/port maps */
-#define PCI_MAXMAPS_1 2 /* max. no. of maps for PCI to PCI bridge */
-#define PCI_MAXMAPS_2 1 /* max. no. of maps for CardBus bridge */
-
-/* pci_addr_t covers this system's PCI bus address space: 32 or 64 bit */
-
-#ifdef PCI_A64
-typedef u_int64_t pci_addr_t; /* u_int64_t for system with 64bit addresses */
-#else
-typedef u_int32_t pci_addr_t; /* u_int64_t for system with 64bit addresses */
-#endif
-
-/* config header information common to all header types */
-
-typedef struct pcicfg {
- struct device *dev; /* device which owns this */
- void *hdrspec; /* pointer to header type specific data */
-
- u_int16_t subvendor; /* card vendor ID */
- u_int16_t subdevice; /* card device ID, assigned by card vendor */
- u_int16_t vendor; /* chip vendor ID */
- u_int16_t device; /* chip device ID, assigned by chip vendor */
-
- u_int16_t cmdreg; /* disable/enable chip and PCI options */
- u_int16_t statreg; /* supported PCI features and error state */
-
- u_int8_t baseclass; /* chip PCI class */
- u_int8_t subclass; /* chip PCI subclass */
- u_int8_t progif; /* chip PCI programming interface */
- u_int8_t revid; /* chip revision ID */
-
- u_int8_t hdrtype; /* chip config header type */
- u_int8_t cachelnsz; /* cache line size in 4byte units */
- u_int8_t intpin; /* PCI interrupt pin */
- u_int8_t intline; /* interrupt line (IRQ for PC arch) */
-
- u_int8_t mingnt; /* min. useful bus grant time in 250ns units */
- u_int8_t maxlat; /* max. tolerated bus grant latency in 250ns */
- u_int8_t lattimer; /* latency timer in units of 30ns bus cycles */
-
- u_int8_t mfdev; /* multi-function device (from hdrtype reg) */
- u_int8_t nummaps; /* actual number of PCI maps used */
-
- u_int8_t hose; /* hose which bus is attached to */
- u_int8_t bus; /* config space bus address */
- u_int8_t slot; /* config space slot address */
- u_int8_t func; /* config space function number */
-
- u_int8_t secondarybus; /* bus on secondary side of bridge, if any */
- u_int8_t subordinatebus; /* topmost bus number behind bridge, if any */
-} pcicfgregs;
-
-/* additional type 1 device config header information (PCI to PCI bridge) */
-
-#ifdef PCI_A64
-#define PCI_PPBMEMBASE(h,l) ((((pci_addr_t)(h) << 32) + ((l)<<16)) & ~0xfffff)
-#define PCI_PPBMEMLIMIT(h,l) ((((pci_addr_t)(h) << 32) + ((l)<<16)) | 0xfffff)
-#else
-#define PCI_PPBMEMBASE(h,l) (((l)<<16) & ~0xfffff)
-#define PCI_PPBMEMLIMIT(h,l) (((l)<<16) | 0xfffff)
-#endif /* PCI_A64 */
-
-#define PCI_PPBIOBASE(h,l) ((((h)<<16) + ((l)<<8)) & ~0xfff)
-#define PCI_PPBIOLIMIT(h,l) ((((h)<<16) + ((l)<<8)) | 0xfff)
-
-typedef struct {
- pci_addr_t pmembase; /* base address of prefetchable memory */
- pci_addr_t pmemlimit; /* topmost address of prefetchable memory */
- u_int32_t membase; /* base address of memory window */
- u_int32_t memlimit; /* topmost address of memory window */
- u_int32_t iobase; /* base address of port window */
- u_int32_t iolimit; /* topmost address of port window */
- u_int16_t secstat; /* secondary bus status register */
- u_int16_t bridgectl; /* bridge control register */
- u_int8_t seclat; /* CardBus latency timer */
-} pcih1cfgregs;
-
-/* additional type 2 device config header information (CardBus bridge) */
-
-typedef struct {
- u_int32_t membase0; /* base address of memory window */
- u_int32_t memlimit0; /* topmost address of memory window */
- u_int32_t membase1; /* base address of memory window */
- u_int32_t memlimit1; /* topmost address of memory window */
- u_int32_t iobase0; /* base address of port window */
- u_int32_t iolimit0; /* topmost address of port window */
- u_int32_t iobase1; /* base address of port window */
- u_int32_t iolimit1; /* topmost address of port window */
- u_int32_t pccardif; /* PC Card 16bit IF legacy more base addr. */
- u_int16_t secstat; /* secondary bus status register */
- u_int16_t bridgectl; /* bridge control register */
- u_int8_t seclat; /* CardBus latency timer */
-} pcih2cfgregs;
-
-/* PCI bus attach definitions (there could be multiple PCI bus *trees* ... */
-
-typedef struct pciattach {
- int unit;
- int pcibushigh;
- struct pciattach *next;
-} pciattach;
-
-extern u_int32_t pci_numdevs;
-
-
-/* externally visible functions */
-
-const char *pci_ata_match(struct device *dev);
-const char *pci_usb_match(struct device *dev);
-const char *pci_vga_match(struct device *dev);
-
-/* low level PCI config register functions provided by pcibus.c */
-
-int pci_cfgread (pcicfgregs *cfg, int reg, int bytes);
-void pci_cfgwrite (pcicfgregs *cfg, int reg, int data, int bytes);
-#ifdef __alpha__
-vm_offset_t pci_cvt_to_dense (vm_offset_t);
-vm_offset_t pci_cvt_to_bwx (vm_offset_t);
-#endif /* __alpha__ */
-
-/* low level devlist operations for the 2.2 compatibility code in pci.c */
-pcicfgregs * pci_devlist_get_parent(pcicfgregs *cfg);
-
-#ifdef _SYS_BUS_H_
-
-#include "pci_if.h"
-
-/*
- * Define pci-specific resource flags for accessing memory via dense
- * or bwx memory spaces. These flags are ignored on i386.
- */
-#define PCI_RF_DENSE 0x10000
-#define PCI_RF_BWX 0x20000
-
-enum pci_device_ivars {
- PCI_IVAR_SUBVENDOR,
- PCI_IVAR_SUBDEVICE,
- PCI_IVAR_VENDOR,
- PCI_IVAR_DEVICE,
- PCI_IVAR_DEVID,
- PCI_IVAR_CLASS,
- PCI_IVAR_SUBCLASS,
- PCI_IVAR_PROGIF,
- PCI_IVAR_REVID,
- PCI_IVAR_INTPIN,
- PCI_IVAR_IRQ,
- PCI_IVAR_BUS,
- PCI_IVAR_SLOT,
- PCI_IVAR_FUNCTION,
- PCI_IVAR_SECONDARYBUS,
- PCI_IVAR_SUBORDINATEBUS,
- PCI_IVAR_HOSE,
-};
-
-/*
- * Simplified accessors for pci devices
- */
-#define PCI_ACCESSOR(A, B, T) \
- \
-static __inline T pci_get_ ## A(device_t dev) \
-{ \
- uintptr_t v; \
- BUS_READ_IVAR(device_get_parent(dev), dev, PCI_IVAR_ ## B, &v); \
- return (T) v; \
-} \
- \
-static __inline void pci_set_ ## A(device_t dev, T t) \
-{ \
- u_long v = (u_long) t; \
- BUS_WRITE_IVAR(device_get_parent(dev), dev, PCI_IVAR_ ## B, v); \
-}
-
-PCI_ACCESSOR(subvendor, SUBVENDOR, u_int16_t)
-PCI_ACCESSOR(subdevice, SUBDEVICE, u_int16_t)
-PCI_ACCESSOR(vendor, VENDOR, u_int16_t)
-PCI_ACCESSOR(device, DEVICE, u_int16_t)
-PCI_ACCESSOR(devid, DEVID, u_int32_t)
-PCI_ACCESSOR(class, CLASS, u_int8_t)
-PCI_ACCESSOR(subclass, SUBCLASS, u_int8_t)
-PCI_ACCESSOR(progif, PROGIF, u_int8_t)
-PCI_ACCESSOR(revid, REVID, u_int8_t)
-PCI_ACCESSOR(intpin, INTPIN, u_int8_t)
-PCI_ACCESSOR(irq, IRQ, u_int8_t)
-PCI_ACCESSOR(bus, BUS, u_int8_t)
-PCI_ACCESSOR(slot, SLOT, u_int8_t)
-PCI_ACCESSOR(function, FUNCTION, u_int8_t)
-PCI_ACCESSOR(secondarybus, SECONDARYBUS, u_int8_t)
-PCI_ACCESSOR(subordinatebus, SUBORDINATEBUS, u_int8_t)
-PCI_ACCESSOR(hose, HOSE, u_int32_t)
-
-static __inline u_int32_t
-pci_read_config(device_t dev, int reg, int width)
-{
- return PCI_READ_CONFIG(device_get_parent(dev), dev, reg, width);
-}
-
-static __inline void
-pci_write_config(device_t dev, int reg, u_int32_t val, int width)
-{
- PCI_WRITE_CONFIG(device_get_parent(dev), dev, reg, val, width);
-}
-
-/*
- * Ivars for pci bridges.
- */
-
-/*typedef enum pci_device_ivars pcib_device_ivars;*/
-enum pcib_device_ivars {
- PCIB_IVAR_HOSE,
-};
-
-#define PCIB_ACCESSOR(A, B, T) \
- \
-static __inline T pcib_get_ ## A(device_t dev) \
-{ \
- uintptr_t v; \
- BUS_READ_IVAR(device_get_parent(dev), dev, PCIB_IVAR_ ## B, &v); \
- return (T) v; \
-} \
- \
-static __inline void pcib_set_ ## A(device_t dev, T t) \
-{ \
- u_long v = (u_long) t; \
- BUS_WRITE_IVAR(device_get_parent(dev), dev, PCIB_IVAR_ ## B, v); \
-}
-
-PCIB_ACCESSOR(hose, HOSE, u_int32_t)
-
-#endif
-
-/* for compatibility to FreeBSD-2.2 version of PCI code */
-
-#ifdef PCI_COMPAT
-
-typedef pcicfgregs *pcici_t;
-typedef unsigned pcidi_t;
-typedef void pci_inthand_t(void *arg);
-
-#define pci_max_burst_len (3)
-
-/* just copied from old PCI code for now ... */
-
-struct pci_device {
- char* pd_name;
- const char* (*pd_probe ) (pcici_t tag, pcidi_t type);
- void (*pd_attach) (pcici_t tag, int unit);
- u_long *pd_count;
- int (*pd_shutdown) (int, int);
-};
-
-#ifdef __i386__
-typedef u_short pci_port_t;
-#else
-typedef u_int pci_port_t;
-#endif
-
-u_long pci_conf_read (pcici_t tag, u_long reg);
-void pci_conf_write (pcici_t tag, u_long reg, u_long data);
-int pci_map_port (pcici_t tag, u_long reg, pci_port_t* pa);
-int pci_map_mem (pcici_t tag, u_long reg, vm_offset_t* va, vm_offset_t* pa);
-int pci_map_int (pcici_t tag, pci_inthand_t *handler, void *arg,
- intrmask_t *maskptr);
-int pci_map_int_right(pcici_t cfg, pci_inthand_t *handler, void *arg,
- intrmask_t *maskptr, u_int flags);
-int pci_unmap_int (pcici_t tag);
-
-pcici_t pci_get_parent_from_tag(pcici_t tag);
-int pci_get_bus_from_tag(pcici_t tag);
-
-struct module;
-int compat_pci_handler (struct module *, int, void *);
-#define COMPAT_PCI_DRIVER(name, pcidata) \
-static moduledata_t name##_mod = { \
- #name, \
- compat_pci_handler, \
- &pcidata \
-}; \
-DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_ANY)
-
-
-#endif /* PCI_COMPAT */
-#endif /* _PCIVAR_H_ */
diff --git a/sys/dev/ppbus/lptio.h b/sys/dev/ppbus/lptio.h
deleted file mode 100644
index 56d196a62fef..000000000000
--- a/sys/dev/ppbus/lptio.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 1994 Geoffrey M. Rehmet
- *
- * This program is free software; you may redistribute it and/or
- * modify it, provided that it retain the above copyright notice
- * and the following disclaimer.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Geoff Rehmet, Rhodes University, South Africa <csgr@cs.ru.ac.za>
- *
- * $FreeBSD$
- */
-
-#ifndef _MACHINE_LPT_H_
-#define _MACHINE_LPT_H_
-
-#include <sys/ioccom.h>
-
-#define LPT_IRQ _IOW('p', 1, long) /* set interrupt status */
-
-#endif /* !_MACHINE_LPT_H_ */
diff --git a/sys/dev/ppc/ppc.c b/sys/dev/ppc/ppc.c
deleted file mode 100644
index eb49870e8403..000000000000
--- a/sys/dev/ppc/ppc.c
+++ /dev/null
@@ -1,2009 +0,0 @@
-/*-
- * Copyright (c) 1997-2000 Nicolas Souchu
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- *
- */
-
-#include "opt_ppc.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/bus.h>
-#include <sys/malloc.h>
-
-#include <vm/vm.h>
-#include <vm/pmap.h>
-#include <machine/clock.h>
-#include <machine/bus.h>
-#include <machine/resource.h>
-#include <machine/vmparam.h>
-#include <sys/rman.h>
-
-#include <isa/isareg.h>
-#include <isa/isavar.h>
-
-#include <dev/ppbus/ppbconf.h>
-#include <dev/ppbus/ppb_msq.h>
-
-#include <isa/ppcreg.h>
-
-#include "ppbus_if.h"
-
-#define LOG_PPC(function, ppc, string) \
- if (bootverbose) printf("%s: %s\n", function, string)
-
-
-#define DEVTOSOFTC(dev) ((struct ppc_data *)device_get_softc(dev))
-
-devclass_t ppc_devclass;
-
-static int ppc_probe(device_t dev);
-static int ppc_attach(device_t dev);
-static int ppc_read_ivar(device_t bus, device_t dev, int index, uintptr_t *val);
-
-static void ppc_reset_epp(device_t);
-static void ppc_ecp_sync(device_t);
-static void ppcintr(void *arg);
-
-static int ppc_exec_microseq(device_t, struct ppb_microseq **);
-static int ppc_setmode(device_t, int);
-
-static int ppc_read(device_t, char *, int, int);
-static int ppc_write(device_t, char *, int, int);
-
-static u_char ppc_io(device_t, int, u_char *, int, u_char);
-
-static int ppc_setup_intr(device_t, device_t, struct resource *, int,
- void (*)(void *), void *, void **);
-static int ppc_teardown_intr(device_t, device_t, struct resource *, void *);
-
-static device_method_t ppc_methods[] = {
- /* device interface */
- DEVMETHOD(device_probe, ppc_probe),
- DEVMETHOD(device_attach, ppc_attach),
-
- /* bus interface */
- DEVMETHOD(bus_read_ivar, ppc_read_ivar),
- DEVMETHOD(bus_setup_intr, ppc_setup_intr),
- DEVMETHOD(bus_teardown_intr, ppc_teardown_intr),
- DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
-
- /* ppbus interface */
- DEVMETHOD(ppbus_io, ppc_io),
- DEVMETHOD(ppbus_exec_microseq, ppc_exec_microseq),
- DEVMETHOD(ppbus_reset_epp, ppc_reset_epp),
- DEVMETHOD(ppbus_setmode, ppc_setmode),
- DEVMETHOD(ppbus_ecp_sync, ppc_ecp_sync),
- DEVMETHOD(ppbus_read, ppc_read),
- DEVMETHOD(ppbus_write, ppc_write),
-
- { 0, 0 }
- };
-
-static driver_t ppc_driver = {
- "ppc",
- ppc_methods,
- sizeof(struct ppc_data),
-};
-
-static char *ppc_models[] = {
- "SMC-like", "SMC FDC37C665GT", "SMC FDC37C666GT", "PC87332", "PC87306",
- "82091AA", "Generic", "W83877F", "W83877AF", "Winbond", "PC87334", 0
-};
-
-/* list of available modes */
-static char *ppc_avms[] = {
- "COMPATIBLE", "NIBBLE-only", "PS2-only", "PS2/NIBBLE", "EPP-only",
- "EPP/NIBBLE", "EPP/PS2", "EPP/PS2/NIBBLE", "ECP-only",
- "ECP/NIBBLE", "ECP/PS2", "ECP/PS2/NIBBLE", "ECP/EPP",
- "ECP/EPP/NIBBLE", "ECP/EPP/PS2", "ECP/EPP/PS2/NIBBLE", 0
-};
-
-/* list of current executing modes
- * Note that few modes do not actually exist.
- */
-static char *ppc_modes[] = {
- "COMPATIBLE", "NIBBLE", "PS/2", "PS/2", "EPP",
- "EPP", "EPP", "EPP", "ECP",
- "ECP", "ECP+PS2", "ECP+PS2", "ECP+EPP",
- "ECP+EPP", "ECP+EPP", "ECP+EPP", 0
-};
-
-static char *ppc_epp_protocol[] = { " (EPP 1.9)", " (EPP 1.7)", 0 };
-
-#ifdef __i386__
-/*
- * BIOS printer list - used by BIOS probe.
- */
-#define BIOS_PPC_PORTS 0x408
-#define BIOS_PORTS (short *)(KERNBASE+BIOS_PPC_PORTS)
-#define BIOS_MAX_PPC 4
-#endif
-
-/*
- * ppc_ecp_sync() XXX
- */
-static void
-ppc_ecp_sync(device_t dev) {
-
- int i, r;
- struct ppc_data *ppc = DEVTOSOFTC(dev);
-
- if (!(ppc->ppc_avm & PPB_ECP))
- return;
-
- r = r_ecr(ppc);
- if ((r & 0xe0) != PPC_ECR_EPP)
- return;
-
- for (i = 0; i < 100; i++) {
- r = r_ecr(ppc);
- if (r & 0x1)
- return;
- DELAY(100);
- }
-
- printf("ppc%d: ECP sync failed as data still " \
- "present in FIFO.\n", ppc->ppc_unit);
-
- return;
-}
-
-/*
- * ppc_detect_fifo()
- *
- * Detect parallel port FIFO
- */
-static int
-ppc_detect_fifo(struct ppc_data *ppc)
-{
- char ecr_sav;
- char ctr_sav, ctr, cc;
- short i;
-
- /* save registers */
- ecr_sav = r_ecr(ppc);
- ctr_sav = r_ctr(ppc);
-
- /* enter ECP configuration mode, no interrupt, no DMA */
- w_ecr(ppc, 0xf4);
-
- /* read PWord size - transfers in FIFO mode must be PWord aligned */
- ppc->ppc_pword = (r_cnfgA(ppc) & PPC_PWORD_MASK);
-
- /* XXX 16 and 32 bits implementations not supported */
- if (ppc->ppc_pword != PPC_PWORD_8) {
- LOG_PPC(__FUNCTION__, ppc, "PWord not supported");
- goto error;
- }
-
- w_ecr(ppc, 0x34); /* byte mode, no interrupt, no DMA */
- ctr = r_ctr(ppc);
- w_ctr(ppc, ctr | PCD); /* set direction to 1 */
-
- /* enter ECP test mode, no interrupt, no DMA */
- w_ecr(ppc, 0xd4);
-
- /* flush the FIFO */
- for (i=0; i<1024; i++) {
- if (r_ecr(ppc) & PPC_FIFO_EMPTY)
- break;
- cc = r_fifo(ppc);
- }
-
- if (i >= 1024) {
- LOG_PPC(__FUNCTION__, ppc, "can't flush FIFO");
- goto error;
- }
-
- /* enable interrupts, no DMA */
- w_ecr(ppc, 0xd0);
-
- /* determine readIntrThreshold
- * fill the FIFO until serviceIntr is set
- */
- for (i=0; i<1024; i++) {
- w_fifo(ppc, (char)i);
- if (!ppc->ppc_rthr && (r_ecr(ppc) & PPC_SERVICE_INTR)) {
- /* readThreshold reached */
- ppc->ppc_rthr = i+1;
- }
- if (r_ecr(ppc) & PPC_FIFO_FULL) {
- ppc->ppc_fifo = i+1;
- break;
- }
- }
-
- if (i >= 1024) {
- LOG_PPC(__FUNCTION__, ppc, "can't fill FIFO");
- goto error;
- }
-
- w_ecr(ppc, 0xd4); /* test mode, no interrupt, no DMA */
- w_ctr(ppc, ctr & ~PCD); /* set direction to 0 */
- w_ecr(ppc, 0xd0); /* enable interrupts */
-
- /* determine writeIntrThreshold
- * empty the FIFO until serviceIntr is set
- */
- for (i=ppc->ppc_fifo; i>0; i--) {
- if (r_fifo(ppc) != (char)(ppc->ppc_fifo-i)) {
- LOG_PPC(__FUNCTION__, ppc, "invalid data in FIFO");
- goto error;
- }
- if (r_ecr(ppc) & PPC_SERVICE_INTR) {
- /* writeIntrThreshold reached */
- ppc->ppc_wthr = ppc->ppc_fifo - i+1;
- }
- /* if FIFO empty before the last byte, error */
- if (i>1 && (r_ecr(ppc) & PPC_FIFO_EMPTY)) {
- LOG_PPC(__FUNCTION__, ppc, "data lost in FIFO");
- goto error;
- }
- }
-
- /* FIFO must be empty after the last byte */
- if (!(r_ecr(ppc) & PPC_FIFO_EMPTY)) {
- LOG_PPC(__FUNCTION__, ppc, "can't empty the FIFO");
- goto error;
- }
-
- w_ctr(ppc, ctr_sav);
- w_ecr(ppc, ecr_sav);
-
- return (0);
-
-error:
- w_ctr(ppc, ctr_sav);
- w_ecr(ppc, ecr_sav);
-
- return (EINVAL);
-}
-
-static int
-ppc_detect_port(struct ppc_data *ppc)
-{
-
- w_ctr(ppc, 0x0c); /* To avoid missing PS2 ports */
- w_dtr(ppc, 0xaa);
- if (r_dtr(ppc) != 0xaa)
- return (0);
-
- return (1);
-}
-
-/*
- * EPP timeout, according to the PC87332 manual
- * Semantics of clearing EPP timeout bit.
- * PC87332 - reading SPP_STR does it...
- * SMC - write 1 to EPP timeout bit XXX
- * Others - (?) write 0 to EPP timeout bit
- */
-static void
-ppc_reset_epp_timeout(struct ppc_data *ppc)
-{
- register char r;
-
- r = r_str(ppc);
- w_str(ppc, r | 0x1);
- w_str(ppc, r & 0xfe);
-
- return;
-}
-
-static int
-ppc_check_epp_timeout(struct ppc_data *ppc)
-{
- ppc_reset_epp_timeout(ppc);
-
- return (!(r_str(ppc) & TIMEOUT));
-}
-
-/*
- * Configure current operating mode
- */
-static int
-ppc_generic_setmode(struct ppc_data *ppc, int mode)
-{
- u_char ecr = 0;
-
- /* check if mode is available */
- if (mode && !(ppc->ppc_avm & mode))
- return (EINVAL);
-
- /* if ECP mode, configure ecr register */
- if (ppc->ppc_avm & PPB_ECP) {
- /* return to byte mode (keeping direction bit),
- * no interrupt, no DMA to be able to change to
- * ECP
- */
- w_ecr(ppc, PPC_ECR_RESET);
- ecr = PPC_DISABLE_INTR;
-
- if (mode & PPB_EPP)
- return (EINVAL);
- else if (mode & PPB_ECP)
- /* select ECP mode */
- ecr |= PPC_ECR_ECP;
- else if (mode & PPB_PS2)
- /* select PS2 mode with ECP */
- ecr |= PPC_ECR_PS2;
- else
- /* select COMPATIBLE/NIBBLE mode */
- ecr |= PPC_ECR_STD;
-
- w_ecr(ppc, ecr);
- }
-
- ppc->ppc_mode = mode;
-
- return (0);
-}
-
-/*
- * The ppc driver is free to choose options like FIFO or DMA
- * if ECP mode is available.
- *
- * The 'RAW' option allows the upper drivers to force the ppc mode
- * even with FIFO, DMA available.
- */
-static int
-ppc_smclike_setmode(struct ppc_data *ppc, int mode)
-{
- u_char ecr = 0;
-
- /* check if mode is available */
- if (mode && !(ppc->ppc_avm & mode))
- return (EINVAL);
-
- /* if ECP mode, configure ecr register */
- if (ppc->ppc_avm & PPB_ECP) {
- /* return to byte mode (keeping direction bit),
- * no interrupt, no DMA to be able to change to
- * ECP or EPP mode
- */
- w_ecr(ppc, PPC_ECR_RESET);
- ecr = PPC_DISABLE_INTR;
-
- if (mode & PPB_EPP)
- /* select EPP mode */
- ecr |= PPC_ECR_EPP;
- else if (mode & PPB_ECP)
- /* select ECP mode */
- ecr |= PPC_ECR_ECP;
- else if (mode & PPB_PS2)
- /* select PS2 mode with ECP */
- ecr |= PPC_ECR_PS2;
- else
- /* select COMPATIBLE/NIBBLE mode */
- ecr |= PPC_ECR_STD;
-
- w_ecr(ppc, ecr);
- }
-
- ppc->ppc_mode = mode;
-
- return (0);
-}
-
-#ifdef PPC_PROBE_CHIPSET
-/*
- * ppc_pc873xx_detect
- *
- * Probe for a Natsemi PC873xx-family part.
- *
- * References in this function are to the National Semiconductor
- * PC87332 datasheet TL/C/11930, May 1995 revision.
- */
-static int pc873xx_basetab[] = {0x0398, 0x026e, 0x015c, 0x002e, 0};
-static int pc873xx_porttab[] = {0x0378, 0x03bc, 0x0278, 0};
-static int pc873xx_irqtab[] = {5, 7, 5, 0};
-
-static int pc873xx_regstab[] = {
- PC873_FER, PC873_FAR, PC873_PTR,
- PC873_FCR, PC873_PCR, PC873_PMC,
- PC873_TUP, PC873_SID, PC873_PNP0,
- PC873_PNP1, PC873_LPTBA, -1
-};
-
-static char *pc873xx_rnametab[] = {
- "FER", "FAR", "PTR", "FCR", "PCR",
- "PMC", "TUP", "SID", "PNP0", "PNP1",
- "LPTBA", NULL
-};
-
-static int
-ppc_pc873xx_detect(struct ppc_data *ppc, int chipset_mode) /* XXX mode never forced */
-{
- static int index = 0;
- int idport, irq;
- int ptr, pcr, val, i;
-
- while ((idport = pc873xx_basetab[index++])) {
-
- /* XXX should check first to see if this location is already claimed */
-
- /*
- * Pull the 873xx through the power-on ID cycle (2.2,1.).
- * We can't use this to locate the chip as it may already have
- * been used by the BIOS.
- */
- (void)inb(idport); (void)inb(idport);
- (void)inb(idport); (void)inb(idport);
-
- /*
- * Read the SID byte. Possible values are :
- *
- * 01010xxx PC87334
- * 0001xxxx PC87332
- * 01110xxx PC87306
- */
- outb(idport, PC873_SID);
- val = inb(idport + 1);
- if ((val & 0xf0) == 0x10) {
- ppc->ppc_model = NS_PC87332;
- } else if ((val & 0xf8) == 0x70) {
- ppc->ppc_model = NS_PC87306;
- } else if ((val & 0xf8) == 0x50) {
- ppc->ppc_model = NS_PC87334;
- } else {
- if (bootverbose && (val != 0xff))
- printf("PC873xx probe at 0x%x got unknown ID 0x%x\n", idport, val);
- continue ; /* not recognised */
- }
-
- /* print registers */
- if (bootverbose) {
- printf("PC873xx");
- for (i=0; pc873xx_regstab[i] != -1; i++) {
- outb(idport, pc873xx_regstab[i]);
- printf(" %s=0x%x", pc873xx_rnametab[i],
- inb(idport + 1) & 0xff);
- }
- printf("\n");
- }
-
- /*
- * We think we have one. Is it enabled and where we want it to be?
- */
- outb(idport, PC873_FER);
- val = inb(idport + 1);
- if (!(val & PC873_PPENABLE)) {
- if (bootverbose)
- printf("PC873xx parallel port disabled\n");
- continue;
- }
- outb(idport, PC873_FAR);
- val = inb(idport + 1) & 0x3;
- /* XXX we should create a driver instance for every port found */
- if (pc873xx_porttab[val] != ppc->ppc_base) {
- if (bootverbose)
- printf("PC873xx at 0x%x not for driver at port 0x%x\n",
- pc873xx_porttab[val], ppc->ppc_base);
- continue;
- }
-
- outb(idport, PC873_PTR);
- ptr = inb(idport + 1);
-
- /* get irq settings */
- if (ppc->ppc_base == 0x378)
- irq = (ptr & PC873_LPTBIRQ7) ? 7 : 5;
- else
- irq = pc873xx_irqtab[val];
-
- if (bootverbose)
- printf("PC873xx irq %d at 0x%x\n", irq, ppc->ppc_base);
-
- /*
- * Check if irq settings are correct
- */
- if (irq != ppc->ppc_irq) {
- /*
- * If the chipset is not locked and base address is 0x378,
- * we have another chance
- */
- if (ppc->ppc_base == 0x378 && !(ptr & PC873_CFGLOCK)) {
- if (ppc->ppc_irq == 7) {
- outb(idport + 1, (ptr | PC873_LPTBIRQ7));
- outb(idport + 1, (ptr | PC873_LPTBIRQ7));
- } else {
- outb(idport + 1, (ptr & ~PC873_LPTBIRQ7));
- outb(idport + 1, (ptr & ~PC873_LPTBIRQ7));
- }
- if (bootverbose)
- printf("PC873xx irq set to %d\n", ppc->ppc_irq);
- } else {
- if (bootverbose)
- printf("PC873xx sorry, can't change irq setting\n");
- }
- } else {
- if (bootverbose)
- printf("PC873xx irq settings are correct\n");
- }
-
- outb(idport, PC873_PCR);
- pcr = inb(idport + 1);
-
- if ((ptr & PC873_CFGLOCK) || !chipset_mode) {
- if (bootverbose)
- printf("PC873xx %s", (ptr & PC873_CFGLOCK)?"locked":"unlocked");
-
- ppc->ppc_avm |= PPB_NIBBLE;
- if (bootverbose)
- printf(", NIBBLE");
-
- if (pcr & PC873_EPPEN) {
- ppc->ppc_avm |= PPB_EPP;
-
- if (bootverbose)
- printf(", EPP");
-
- if (pcr & PC873_EPP19)
- ppc->ppc_epp = EPP_1_9;
- else
- ppc->ppc_epp = EPP_1_7;
-
- if ((ppc->ppc_model == NS_PC87332) && bootverbose) {
- outb(idport, PC873_PTR);
- ptr = inb(idport + 1);
- if (ptr & PC873_EPPRDIR)
- printf(", Regular mode");
- else
- printf(", Automatic mode");
- }
- } else if (pcr & PC873_ECPEN) {
- ppc->ppc_avm |= PPB_ECP;
- if (bootverbose)
- printf(", ECP");
-
- if (pcr & PC873_ECPCLK) { /* XXX */
- ppc->ppc_avm |= PPB_PS2;
- if (bootverbose)
- printf(", PS/2");
- }
- } else {
- outb(idport, PC873_PTR);
- ptr = inb(idport + 1);
- if (ptr & PC873_EXTENDED) {
- ppc->ppc_avm |= PPB_SPP;
- if (bootverbose)
- printf(", SPP");
- }
- }
- } else {
- if (bootverbose)
- printf("PC873xx unlocked");
-
- if (chipset_mode & PPB_ECP) {
- if ((chipset_mode & PPB_EPP) && bootverbose)
- printf(", ECP+EPP not supported");
-
- pcr &= ~PC873_EPPEN;
- pcr |= (PC873_ECPEN | PC873_ECPCLK); /* XXX */
- outb(idport + 1, pcr);
- outb(idport + 1, pcr);
-
- if (bootverbose)
- printf(", ECP");
-
- } else if (chipset_mode & PPB_EPP) {
- pcr &= ~(PC873_ECPEN | PC873_ECPCLK);
- pcr |= (PC873_EPPEN | PC873_EPP19);
- outb(idport + 1, pcr);
- outb(idport + 1, pcr);
-
- ppc->ppc_epp = EPP_1_9; /* XXX */
-
- if (bootverbose)
- printf(", EPP1.9");
-
- /* enable automatic direction turnover */
- if (ppc->ppc_model == NS_PC87332) {
- outb(idport, PC873_PTR);
- ptr = inb(idport + 1);
- ptr &= ~PC873_EPPRDIR;
- outb(idport + 1, ptr);
- outb(idport + 1, ptr);
-
- if (bootverbose)
- printf(", Automatic mode");
- }
- } else {
- pcr &= ~(PC873_ECPEN | PC873_ECPCLK | PC873_EPPEN);
- outb(idport + 1, pcr);
- outb(idport + 1, pcr);
-
- /* configure extended bit in PTR */
- outb(idport, PC873_PTR);
- ptr = inb(idport + 1);
-
- if (chipset_mode & PPB_PS2) {
- ptr |= PC873_EXTENDED;
-
- if (bootverbose)
- printf(", PS/2");
-
- } else {
- /* default to NIBBLE mode */
- ptr &= ~PC873_EXTENDED;
-
- if (bootverbose)
- printf(", NIBBLE");
- }
- outb(idport + 1, ptr);
- outb(idport + 1, ptr);
- }
-
- ppc->ppc_avm = chipset_mode;
- }
-
- if (bootverbose)
- printf("\n");
-
- ppc->ppc_type = PPC_TYPE_GENERIC;
- ppc_generic_setmode(ppc, chipset_mode);
-
- return(chipset_mode);
- }
- return(-1);
-}
-
-/*
- * ppc_smc37c66xgt_detect
- *
- * SMC FDC37C66xGT configuration.
- */
-static int
-ppc_smc37c66xgt_detect(struct ppc_data *ppc, int chipset_mode)
-{
- int s, i;
- u_char r;
- int type = -1;
- int csr = SMC66x_CSR; /* initial value is 0x3F0 */
-
- int port_address[] = { -1 /* disabled */ , 0x3bc, 0x378, 0x278 };
-
-
-#define cio csr+1 /* config IO port is either 0x3F1 or 0x371 */
-
- /*
- * Detection: enter configuration mode and read CRD register.
- */
-
- s = splhigh();
- outb(csr, SMC665_iCODE);
- outb(csr, SMC665_iCODE);
- splx(s);
-
- outb(csr, 0xd);
- if (inb(cio) == 0x65) {
- type = SMC_37C665GT;
- goto config;
- }
-
- for (i = 0; i < 2; i++) {
- s = splhigh();
- outb(csr, SMC666_iCODE);
- outb(csr, SMC666_iCODE);
- splx(s);
-
- outb(csr, 0xd);
- if (inb(cio) == 0x66) {
- type = SMC_37C666GT;
- break;
- }
-
- /* Another chance, CSR may be hard-configured to be at 0x370 */
- csr = SMC666_CSR;
- }
-
-config:
- /*
- * If chipset not found, do not continue.
- */
- if (type == -1)
- return (-1);
-
- /* select CR1 */
- outb(csr, 0x1);
-
- /* read the port's address: bits 0 and 1 of CR1 */
- r = inb(cio) & SMC_CR1_ADDR;
- if (port_address[(int)r] != ppc->ppc_base)
- return (-1);
-
- ppc->ppc_model = type;
-
- /*
- * CR1 and CR4 registers bits 3 and 0/1 for mode configuration
- * If SPP mode is detected, try to set ECP+EPP mode
- */
-
- if (bootverbose) {
- outb(csr, 0x1);
- printf("ppc%d: SMC registers CR1=0x%x", ppc->ppc_unit,
- inb(cio) & 0xff);
-
- outb(csr, 0x4);
- printf(" CR4=0x%x", inb(cio) & 0xff);
- }
-
- /* select CR1 */
- outb(csr, 0x1);
-
- if (!chipset_mode) {
- /* autodetect mode */
-
- /* 666GT is ~certainly~ hardwired to an extended ECP+EPP mode */
- if (type == SMC_37C666GT) {
- ppc->ppc_avm |= PPB_ECP | PPB_EPP | PPB_SPP;
- if (bootverbose)
- printf(" configuration hardwired, supposing " \
- "ECP+EPP SPP");
-
- } else
- if ((inb(cio) & SMC_CR1_MODE) == 0) {
- /* already in extended parallel port mode, read CR4 */
- outb(csr, 0x4);
- r = (inb(cio) & SMC_CR4_EMODE);
-
- switch (r) {
- case SMC_SPP:
- ppc->ppc_avm |= PPB_SPP;
- if (bootverbose)
- printf(" SPP");
- break;
-
- case SMC_EPPSPP:
- ppc->ppc_avm |= PPB_EPP | PPB_SPP;
- if (bootverbose)
- printf(" EPP SPP");
- break;
-
- case SMC_ECP:
- ppc->ppc_avm |= PPB_ECP | PPB_SPP;
- if (bootverbose)
- printf(" ECP SPP");
- break;
-
- case SMC_ECPEPP:
- ppc->ppc_avm |= PPB_ECP | PPB_EPP | PPB_SPP;
- if (bootverbose)
- printf(" ECP+EPP SPP");
- break;
- }
- } else {
- /* not an extended port mode */
- ppc->ppc_avm |= PPB_SPP;
- if (bootverbose)
- printf(" SPP");
- }
-
- } else {
- /* mode forced */
- ppc->ppc_avm = chipset_mode;
-
- /* 666GT is ~certainly~ hardwired to an extended ECP+EPP mode */
- if (type == SMC_37C666GT)
- goto end_detect;
-
- r = inb(cio);
- if ((chipset_mode & (PPB_ECP | PPB_EPP)) == 0) {
- /* do not use ECP when the mode is not forced to */
- outb(cio, r | SMC_CR1_MODE);
- if (bootverbose)
- printf(" SPP");
- } else {
- /* an extended mode is selected */
- outb(cio, r & ~SMC_CR1_MODE);
-
- /* read CR4 register and reset mode field */
- outb(csr, 0x4);
- r = inb(cio) & ~SMC_CR4_EMODE;
-
- if (chipset_mode & PPB_ECP) {
- if (chipset_mode & PPB_EPP) {
- outb(cio, r | SMC_ECPEPP);
- if (bootverbose)
- printf(" ECP+EPP");
- } else {
- outb(cio, r | SMC_ECP);
- if (bootverbose)
- printf(" ECP");
- }
- } else {
- /* PPB_EPP is set */
- outb(cio, r | SMC_EPPSPP);
- if (bootverbose)
- printf(" EPP SPP");
- }
- }
- ppc->ppc_avm = chipset_mode;
- }
-
- /* set FIFO threshold to 16 */
- if (ppc->ppc_avm & PPB_ECP) {
- /* select CRA */
- outb(csr, 0xa);
- outb(cio, 16);
- }
-
-end_detect:
-
- if (bootverbose)
- printf ("\n");
-
- if (ppc->ppc_avm & PPB_EPP) {
- /* select CR4 */
- outb(csr, 0x4);
- r = inb(cio);
-
- /*
- * Set the EPP protocol...
- * Low=EPP 1.9 (1284 standard) and High=EPP 1.7
- */
- if (ppc->ppc_epp == EPP_1_9)
- outb(cio, (r & ~SMC_CR4_EPPTYPE));
- else
- outb(cio, (r | SMC_CR4_EPPTYPE));
- }
-
- /* end config mode */
- outb(csr, 0xaa);
-
- ppc->ppc_type = PPC_TYPE_SMCLIKE;
- ppc_smclike_setmode(ppc, chipset_mode);
-
- return (chipset_mode);
-}
-
-/*
- * Winbond W83877F stuff
- *
- * EFER: extended function enable register
- * EFIR: extended function index register
- * EFDR: extended function data register
- */
-#define efir ((efer == 0x250) ? 0x251 : 0x3f0)
-#define efdr ((efer == 0x250) ? 0x252 : 0x3f1)
-
-static int w83877f_efers[] = { 0x250, 0x3f0, 0x3f0, 0x250 };
-static int w83877f_keys[] = { 0x89, 0x86, 0x87, 0x88 };
-static int w83877f_keyiter[] = { 1, 2, 2, 1 };
-static int w83877f_hefs[] = { WINB_HEFERE, WINB_HEFRAS, WINB_HEFERE | WINB_HEFRAS, 0 };
-
-static int
-ppc_w83877f_detect(struct ppc_data *ppc, int chipset_mode)
-{
- int i, j, efer;
- unsigned char r, hefere, hefras;
-
- for (i = 0; i < 4; i ++) {
- /* first try to enable configuration registers */
- efer = w83877f_efers[i];
-
- /* write the key to the EFER */
- for (j = 0; j < w83877f_keyiter[i]; j ++)
- outb (efer, w83877f_keys[i]);
-
- /* then check HEFERE and HEFRAS bits */
- outb (efir, 0x0c);
- hefere = inb(efdr) & WINB_HEFERE;
-
- outb (efir, 0x16);
- hefras = inb(efdr) & WINB_HEFRAS;
-
- /*
- * HEFRAS HEFERE
- * 0 1 write 89h to 250h (power-on default)
- * 1 0 write 86h twice to 3f0h
- * 1 1 write 87h twice to 3f0h
- * 0 0 write 88h to 250h
- */
- if ((hefere | hefras) == w83877f_hefs[i])
- goto found;
- }
-
- return (-1); /* failed */
-
-found:
- /* check base port address - read from CR23 */
- outb(efir, 0x23);
- if (ppc->ppc_base != inb(efdr) * 4) /* 4 bytes boundaries */
- return (-1);
-
- /* read CHIP ID from CR9/bits0-3 */
- outb(efir, 0x9);
-
- switch (inb(efdr) & WINB_CHIPID) {
- case WINB_W83877F_ID:
- ppc->ppc_model = WINB_W83877F;
- break;
-
- case WINB_W83877AF_ID:
- ppc->ppc_model = WINB_W83877AF;
- break;
-
- default:
- ppc->ppc_model = WINB_UNKNOWN;
- }
-
- if (bootverbose) {
- /* dump of registers */
- printf("ppc%d: 0x%x - ", ppc->ppc_unit, w83877f_keys[i]);
- for (i = 0; i <= 0xd; i ++) {
- outb(efir, i);
- printf("0x%x ", inb(efdr));
- }
- for (i = 0x10; i <= 0x17; i ++) {
- outb(efir, i);
- printf("0x%x ", inb(efdr));
- }
- outb(efir, 0x1e);
- printf("0x%x ", inb(efdr));
- for (i = 0x20; i <= 0x29; i ++) {
- outb(efir, i);
- printf("0x%x ", inb(efdr));
- }
- printf("\n");
- printf("ppc%d:", ppc->ppc_unit);
- }
-
- ppc->ppc_type = PPC_TYPE_GENERIC;
-
- if (!chipset_mode) {
- /* autodetect mode */
-
- /* select CR0 */
- outb(efir, 0x0);
- r = inb(efdr) & (WINB_PRTMODS0 | WINB_PRTMODS1);
-
- /* select CR9 */
- outb(efir, 0x9);
- r |= (inb(efdr) & WINB_PRTMODS2);
-
- switch (r) {
- case WINB_W83757:
- if (bootverbose)
- printf("ppc%d: W83757 compatible mode\n",
- ppc->ppc_unit);
- return (-1); /* generic or SMC-like */
-
- case WINB_EXTFDC:
- case WINB_EXTADP:
- case WINB_EXT2FDD:
- case WINB_JOYSTICK:
- if (bootverbose)
- printf(" not in parallel port mode\n");
- return (-1);
-
- case (WINB_PARALLEL | WINB_EPP_SPP):
- ppc->ppc_avm |= PPB_EPP | PPB_SPP;
- if (bootverbose)
- printf(" EPP SPP");
- break;
-
- case (WINB_PARALLEL | WINB_ECP):
- ppc->ppc_avm |= PPB_ECP | PPB_SPP;
- if (bootverbose)
- printf(" ECP SPP");
- break;
-
- case (WINB_PARALLEL | WINB_ECP_EPP):
- ppc->ppc_avm |= PPB_ECP | PPB_EPP | PPB_SPP;
- ppc->ppc_type = PPC_TYPE_SMCLIKE;
-
- if (bootverbose)
- printf(" ECP+EPP SPP");
- break;
- default:
- printf("%s: unknown case (0x%x)!\n", __FUNCTION__, r);
- }
-
- } else {
- /* mode forced */
-
- /* select CR9 and set PRTMODS2 bit */
- outb(efir, 0x9);
- outb(efdr, inb(efdr) & ~WINB_PRTMODS2);
-
- /* select CR0 and reset PRTMODSx bits */
- outb(efir, 0x0);
- outb(efdr, inb(efdr) & ~(WINB_PRTMODS0 | WINB_PRTMODS1));
-
- if (chipset_mode & PPB_ECP) {
- if (chipset_mode & PPB_EPP) {
- outb(efdr, inb(efdr) | WINB_ECP_EPP);
- if (bootverbose)
- printf(" ECP+EPP");
-
- ppc->ppc_type = PPC_TYPE_SMCLIKE;
-
- } else {
- outb(efdr, inb(efdr) | WINB_ECP);
- if (bootverbose)
- printf(" ECP");
- }
- } else {
- /* select EPP_SPP otherwise */
- outb(efdr, inb(efdr) | WINB_EPP_SPP);
- if (bootverbose)
- printf(" EPP SPP");
- }
- ppc->ppc_avm = chipset_mode;
- }
-
- if (bootverbose)
- printf("\n");
-
- /* exit configuration mode */
- outb(efer, 0xaa);
-
- switch (ppc->ppc_type) {
- case PPC_TYPE_SMCLIKE:
- ppc_smclike_setmode(ppc, chipset_mode);
- break;
- default:
- ppc_generic_setmode(ppc, chipset_mode);
- break;
- }
-
- return (chipset_mode);
-}
-#endif
-
-/*
- * ppc_generic_detect
- */
-static int
-ppc_generic_detect(struct ppc_data *ppc, int chipset_mode)
-{
- /* default to generic */
- ppc->ppc_type = PPC_TYPE_GENERIC;
-
- if (bootverbose)
- printf("ppc%d:", ppc->ppc_unit);
-
- if (!chipset_mode) {
- /* first, check for ECP */
- w_ecr(ppc, PPC_ECR_PS2);
- if ((r_ecr(ppc) & 0xe0) == PPC_ECR_PS2) {
- ppc->ppc_avm |= PPB_ECP | PPB_SPP;
- if (bootverbose)
- printf(" ECP SPP");
-
- /* search for SMC style ECP+EPP mode */
- w_ecr(ppc, PPC_ECR_EPP);
- }
-
- /* try to reset EPP timeout bit */
- if (ppc_check_epp_timeout(ppc)) {
- ppc->ppc_avm |= PPB_EPP;
-
- if (ppc->ppc_avm & PPB_ECP) {
- /* SMC like chipset found */
- ppc->ppc_model = SMC_LIKE;
- ppc->ppc_type = PPC_TYPE_SMCLIKE;
-
- if (bootverbose)
- printf(" ECP+EPP");
- } else {
- if (bootverbose)
- printf(" EPP");
- }
- } else {
- /* restore to standard mode */
- w_ecr(ppc, PPC_ECR_STD);
- }
-
- /* XXX try to detect NIBBLE and PS2 modes */
- ppc->ppc_avm |= PPB_NIBBLE;
-
- if (bootverbose)
- printf(" SPP");
-
- } else {
- ppc->ppc_avm = chipset_mode;
- }
-
- if (bootverbose)
- printf("\n");
-
- switch (ppc->ppc_type) {
- case PPC_TYPE_SMCLIKE:
- ppc_smclike_setmode(ppc, chipset_mode);
- break;
- default:
- ppc_generic_setmode(ppc, chipset_mode);
- break;
- }
-
- return (chipset_mode);
-}
-
-/*
- * ppc_detect()
- *
- * mode is the mode suggested at boot
- */
-static int
-ppc_detect(struct ppc_data *ppc, int chipset_mode) {
-
-#ifdef PPC_PROBE_CHIPSET
- int i, mode;
-
- /* list of supported chipsets */
- int (*chipset_detect[])(struct ppc_data *, int) = {
- ppc_pc873xx_detect,
- ppc_smc37c66xgt_detect,
- ppc_w83877f_detect,
- ppc_generic_detect,
- NULL
- };
-#endif
-
- /* if can't find the port and mode not forced return error */
- if (!ppc_detect_port(ppc) && chipset_mode == 0)
- return (EIO); /* failed, port not present */
-
- /* assume centronics compatible mode is supported */
- ppc->ppc_avm = PPB_COMPATIBLE;
-
-#ifdef PPC_PROBE_CHIPSET
- /* we have to differenciate available chipset modes,
- * chipset running modes and IEEE-1284 operating modes
- *
- * after detection, the port must support running in compatible mode
- */
- if (ppc->ppc_flags & 0x40) {
- if (bootverbose)
- printf("ppc: chipset forced to generic\n");
-#endif
-
- ppc->ppc_mode = ppc_generic_detect(ppc, chipset_mode);
-
-#ifdef PPC_PROBE_CHIPSET
- } else {
- for (i=0; chipset_detect[i] != NULL; i++) {
- if ((mode = chipset_detect[i](ppc, chipset_mode)) != -1) {
- ppc->ppc_mode = mode;
- break;
- }
- }
- }
-#endif
-
- /* configure/detect ECP FIFO */
- if ((ppc->ppc_avm & PPB_ECP) && !(ppc->ppc_flags & 0x80))
- ppc_detect_fifo(ppc);
-
- return (0);
-}
-
-/*
- * ppc_exec_microseq()
- *
- * Execute a microsequence.
- * Microsequence mechanism is supposed to handle fast I/O operations.
- */
-static int
-ppc_exec_microseq(device_t dev, struct ppb_microseq **p_msq)
-{
- struct ppc_data *ppc = DEVTOSOFTC(dev);
- struct ppb_microseq *mi;
- char cc, *p;
- int i, iter, len;
- int error;
-
- register int reg;
- register char mask;
- register int accum = 0;
- register char *ptr = 0;
-
- struct ppb_microseq *stack = 0;
-
-/* microsequence registers are equivalent to PC-like port registers */
-#define r_reg(register,ppc) (inb((ppc)->ppc_base + register))
-#define w_reg(register,ppc,byte) outb((ppc)->ppc_base + register, byte)
-
-#define INCR_PC (mi ++) /* increment program counter */
-
- mi = *p_msq;
- for (;;) {
- switch (mi->opcode) {
- case MS_OP_RSET:
- cc = r_reg(mi->arg[0].i, ppc);
- cc &= (char)mi->arg[2].i; /* clear mask */
- cc |= (char)mi->arg[1].i; /* assert mask */
- w_reg(mi->arg[0].i, ppc, cc);
- INCR_PC;
- break;
-
- case MS_OP_RASSERT_P:
- reg = mi->arg[1].i;
- ptr = ppc->ppc_ptr;
-
- if ((len = mi->arg[0].i) == MS_ACCUM) {
- accum = ppc->ppc_accum;
- for (; accum; accum--)
- w_reg(reg, ppc, *ptr++);
- ppc->ppc_accum = accum;
- } else
- for (i=0; i<len; i++)
- w_reg(reg, ppc, *ptr++);
- ppc->ppc_ptr = ptr;
-
- INCR_PC;
- break;
-
- case MS_OP_RFETCH_P:
- reg = mi->arg[1].i;
- mask = (char)mi->arg[2].i;
- ptr = ppc->ppc_ptr;
-
- if ((len = mi->arg[0].i) == MS_ACCUM) {
- accum = ppc->ppc_accum;
- for (; accum; accum--)
- *ptr++ = r_reg(reg, ppc) & mask;
- ppc->ppc_accum = accum;
- } else
- for (i=0; i<len; i++)
- *ptr++ = r_reg(reg, ppc) & mask;
- ppc->ppc_ptr = ptr;
-
- INCR_PC;
- break;
-
- case MS_OP_RFETCH:
- *((char *) mi->arg[2].p) = r_reg(mi->arg[0].i, ppc) &
- (char)mi->arg[1].i;
- INCR_PC;
- break;
-
- case MS_OP_RASSERT:
- case MS_OP_DELAY:
-
- /* let's suppose the next instr. is the same */
- prefetch:
- for (;mi->opcode == MS_OP_RASSERT; INCR_PC)
- w_reg(mi->arg[0].i, ppc, (char)mi->arg[1].i);
-
- if (mi->opcode == MS_OP_DELAY) {
- DELAY(mi->arg[0].i);
- INCR_PC;
- goto prefetch;
- }
- break;
-
- case MS_OP_ADELAY:
- if (mi->arg[0].i)
- tsleep(NULL, PPBPRI, "ppbdelay",
- mi->arg[0].i * (hz/1000));
- INCR_PC;
- break;
-
- case MS_OP_TRIG:
- reg = mi->arg[0].i;
- iter = mi->arg[1].i;
- p = (char *)mi->arg[2].p;
-
- /* XXX delay limited to 255 us */
- for (i=0; i<iter; i++) {
- w_reg(reg, ppc, *p++);
- DELAY((unsigned char)*p++);
- }
- INCR_PC;
- break;
-
- case MS_OP_SET:
- ppc->ppc_accum = mi->arg[0].i;
- INCR_PC;
- break;
-
- case MS_OP_DBRA:
- if (--ppc->ppc_accum > 0)
- mi += mi->arg[0].i;
- INCR_PC;
- break;
-
- case MS_OP_BRSET:
- cc = r_str(ppc);
- if ((cc & (char)mi->arg[0].i) == (char)mi->arg[0].i)
- mi += mi->arg[1].i;
- INCR_PC;
- break;
-
- case MS_OP_BRCLEAR:
- cc = r_str(ppc);
- if ((cc & (char)mi->arg[0].i) == 0)
- mi += mi->arg[1].i;
- INCR_PC;
- break;
-
- case MS_OP_BRSTAT:
- cc = r_str(ppc);
- if ((cc & ((char)mi->arg[0].i | (char)mi->arg[1].i)) ==
- (char)mi->arg[0].i)
- mi += mi->arg[2].i;
- INCR_PC;
- break;
-
- case MS_OP_C_CALL:
- /*
- * If the C call returns !0 then end the microseq.
- * The current state of ptr is passed to the C function
- */
- if ((error = mi->arg[0].f(mi->arg[1].p, ppc->ppc_ptr)))
- return (error);
-
- INCR_PC;
- break;
-
- case MS_OP_PTR:
- ppc->ppc_ptr = (char *)mi->arg[0].p;
- INCR_PC;
- break;
-
- case MS_OP_CALL:
- if (stack)
- panic("%s: too much calls", __FUNCTION__);
-
- if (mi->arg[0].p) {
- /* store the state of the actual
- * microsequence
- */
- stack = mi;
-
- /* jump to the new microsequence */
- mi = (struct ppb_microseq *)mi->arg[0].p;
- } else
- INCR_PC;
-
- break;
-
- case MS_OP_SUBRET:
- /* retrieve microseq and pc state before the call */
- mi = stack;
-
- /* reset the stack */
- stack = 0;
-
- /* XXX return code */
-
- INCR_PC;
- break;
-
- case MS_OP_PUT:
- case MS_OP_GET:
- case MS_OP_RET:
- /* can't return to ppb level during the execution
- * of a submicrosequence */
- if (stack)
- panic("%s: can't return to ppb level",
- __FUNCTION__);
-
- /* update pc for ppb level of execution */
- *p_msq = mi;
-
- /* return to ppb level of execution */
- return (0);
-
- default:
- panic("%s: unknown microsequence opcode 0x%x",
- __FUNCTION__, mi->opcode);
- }
- }
-
- /* unreached */
-}
-
-static void
-ppcintr(void *arg)
-{
- device_t dev = (device_t)arg;
- struct ppc_data *ppc = (struct ppc_data *)device_get_softc(dev);
- u_char ctr, ecr, str;
-
- str = r_str(ppc);
- ctr = r_ctr(ppc);
- ecr = r_ecr(ppc);
-
-#if PPC_DEBUG > 1
- printf("![%x/%x/%x]", ctr, ecr, str);
-#endif
-
- /* don't use ecp mode with IRQENABLE set */
- if (ctr & IRQENABLE) {
- return;
- }
-
- /* interrupts are generated by nFault signal
- * only in ECP mode */
- if ((str & nFAULT) && (ppc->ppc_mode & PPB_ECP)) {
- /* check if ppc driver has programmed the
- * nFault interrupt */
- if (ppc->ppc_irqstat & PPC_IRQ_nFAULT) {
-
- w_ecr(ppc, ecr | PPC_nFAULT_INTR);
- ppc->ppc_irqstat &= ~PPC_IRQ_nFAULT;
- } else {
- /* shall be handled by underlying layers XXX */
- return;
- }
- }
-
- if (ppc->ppc_irqstat & PPC_IRQ_DMA) {
- /* disable interrupts (should be done by hardware though) */
- w_ecr(ppc, ecr | PPC_SERVICE_INTR);
- ppc->ppc_irqstat &= ~PPC_IRQ_DMA;
- ecr = r_ecr(ppc);
-
- /* check if DMA completed */
- if ((ppc->ppc_avm & PPB_ECP) && (ecr & PPC_ENABLE_DMA)) {
-#ifdef PPC_DEBUG
- printf("a");
-#endif
- /* stop DMA */
- w_ecr(ppc, ecr & ~PPC_ENABLE_DMA);
- ecr = r_ecr(ppc);
-
- if (ppc->ppc_dmastat == PPC_DMA_STARTED) {
-#ifdef PPC_DEBUG
- printf("d");
-#endif
- isa_dmadone(
- ppc->ppc_dmaflags,
- ppc->ppc_dmaddr,
- ppc->ppc_dmacnt,
- ppc->ppc_dmachan);
-
- ppc->ppc_dmastat = PPC_DMA_COMPLETE;
-
- /* wakeup the waiting process */
- wakeup((caddr_t)ppc);
- }
- }
- } else if (ppc->ppc_irqstat & PPC_IRQ_FIFO) {
-
- /* classic interrupt I/O */
- ppc->ppc_irqstat &= ~PPC_IRQ_FIFO;
- }
-
- return;
-}
-
-static int
-ppc_read(device_t dev, char *buf, int len, int mode)
-{
- return (EINVAL);
-}
-
-/*
- * Call this function if you want to send data in any advanced mode
- * of your parallel port: FIFO, DMA
- *
- * If what you want is not possible (no ECP, no DMA...),
- * EINVAL is returned
- */
-static int
-ppc_write(device_t dev, char *buf, int len, int how)
-{
- struct ppc_data *ppc = DEVTOSOFTC(dev);
- char ecr, ecr_sav, ctr, ctr_sav;
- int s, error = 0;
- int spin;
-
-#ifdef PPC_DEBUG
- printf("w");
-#endif
-
- ecr_sav = r_ecr(ppc);
- ctr_sav = r_ctr(ppc);
-
- /*
- * Send buffer with DMA, FIFO and interrupts
- */
- if ((ppc->ppc_avm & PPB_ECP) && (ppc->ppc_registered)) {
-
- if (ppc->ppc_dmachan >= 0) {
-
- /* byte mode, no intr, no DMA, dir=0, flush fifo
- */
- ecr = PPC_ECR_STD | PPC_DISABLE_INTR;
- w_ecr(ppc, ecr);
-
- /* disable nAck interrupts */
- ctr = r_ctr(ppc);
- ctr &= ~IRQENABLE;
- w_ctr(ppc, ctr);
-
- ppc->ppc_dmaflags = 0;
- ppc->ppc_dmaddr = (caddr_t)buf;
- ppc->ppc_dmacnt = (u_int)len;
-
- switch (ppc->ppc_mode) {
- case PPB_COMPATIBLE:
- /* compatible mode with FIFO, no intr, DMA, dir=0 */
- ecr = PPC_ECR_FIFO | PPC_DISABLE_INTR | PPC_ENABLE_DMA;
- break;
- case PPB_ECP:
- ecr = PPC_ECR_ECP | PPC_DISABLE_INTR | PPC_ENABLE_DMA;
- break;
- default:
- error = EINVAL;
- goto error;
- }
-
- w_ecr(ppc, ecr);
- ecr = r_ecr(ppc);
-
- /* enter splhigh() not to be preempted
- * by the dma interrupt, we may miss
- * the wakeup otherwise
- */
- s = splhigh();
-
- ppc->ppc_dmastat = PPC_DMA_INIT;
-
- /* enable interrupts */
- ecr &= ~PPC_SERVICE_INTR;
- ppc->ppc_irqstat = PPC_IRQ_DMA;
- w_ecr(ppc, ecr);
-
- isa_dmastart(
- ppc->ppc_dmaflags,
- ppc->ppc_dmaddr,
- ppc->ppc_dmacnt,
- ppc->ppc_dmachan);
-#ifdef PPC_DEBUG
- printf("s%d", ppc->ppc_dmacnt);
-#endif
- ppc->ppc_dmastat = PPC_DMA_STARTED;
-
- /* Wait for the DMA completed interrupt. We hope we won't
- * miss it, otherwise a signal will be necessary to unlock the
- * process.
- */
- do {
- /* release CPU */
- error = tsleep((caddr_t)ppc,
- PPBPRI | PCATCH, "ppcdma", 0);
-
- } while (error == EWOULDBLOCK);
-
- splx(s);
-
- if (error) {
-#ifdef PPC_DEBUG
- printf("i");
-#endif
- /* stop DMA */
- isa_dmadone(
- ppc->ppc_dmaflags, ppc->ppc_dmaddr,
- ppc->ppc_dmacnt, ppc->ppc_dmachan);
-
- /* no dma, no interrupt, flush the fifo */
- w_ecr(ppc, PPC_ECR_RESET);
-
- ppc->ppc_dmastat = PPC_DMA_INTERRUPTED;
- goto error;
- }
-
- /* wait for an empty fifo */
- while (!(r_ecr(ppc) & PPC_FIFO_EMPTY)) {
-
- for (spin=100; spin; spin--)
- if (r_ecr(ppc) & PPC_FIFO_EMPTY)
- goto fifo_empty;
-#ifdef PPC_DEBUG
- printf("Z");
-#endif
- error = tsleep((caddr_t)ppc, PPBPRI | PCATCH, "ppcfifo", hz/100);
- if (error != EWOULDBLOCK) {
-#ifdef PPC_DEBUG
- printf("I");
-#endif
- /* no dma, no interrupt, flush the fifo */
- w_ecr(ppc, PPC_ECR_RESET);
-
- ppc->ppc_dmastat = PPC_DMA_INTERRUPTED;
- error = EINTR;
- goto error;
- }
- }
-
-fifo_empty:
- /* no dma, no interrupt, flush the fifo */
- w_ecr(ppc, PPC_ECR_RESET);
-
- } else
- error = EINVAL; /* XXX we should FIFO and
- * interrupts */
- } else
- error = EINVAL;
-
-error:
-
- /* PDRQ must be kept unasserted until nPDACK is
- * deasserted for a minimum of 350ns (SMC datasheet)
- *
- * Consequence may be a FIFO that never empty
- */
- DELAY(1);
-
- w_ecr(ppc, ecr_sav);
- w_ctr(ppc, ctr_sav);
-
- return (error);
-}
-
-static void
-ppc_reset_epp(device_t dev)
-{
- struct ppc_data *ppc = DEVTOSOFTC(dev);
-
- ppc_reset_epp_timeout(ppc);
-
- return;
-}
-
-static int
-ppc_setmode(device_t dev, int mode)
-{
- struct ppc_data *ppc = DEVTOSOFTC(dev);
-
- switch (ppc->ppc_type) {
- case PPC_TYPE_SMCLIKE:
- return (ppc_smclike_setmode(ppc, mode));
- break;
-
- case PPC_TYPE_GENERIC:
- default:
- return (ppc_generic_setmode(ppc, mode));
- break;
- }
-
- /* not reached */
- return (ENXIO);
-}
-
-static int
-ppc_probe(device_t dev)
-{
-#ifdef __i386__
- static short next_bios_ppc = 0;
-#endif
- struct ppc_data *ppc;
- device_t parent;
- int error;
- u_long port;
-
- /* If we are a PNP device, abort. Otherwise we attach to *everthing* */
- if (isa_get_logicalid(dev))
- return ENXIO;
-
- parent = device_get_parent(dev);
-
- /* XXX shall be set after detection */
- device_set_desc(dev, "Parallel port");
-
- /*
- * Allocate the ppc_data structure.
- */
- ppc = DEVTOSOFTC(dev);
- bzero(ppc, sizeof(struct ppc_data));
-
- ppc->rid_irq = ppc->rid_drq = ppc->rid_ioport = 0;
- ppc->res_irq = ppc->res_drq = ppc->res_ioport = 0;
-
- /* retrieve ISA parameters */
- error = bus_get_resource(dev, SYS_RES_IOPORT, 0, &port, NULL);
-
-#ifdef __i386__
- /*
- * If port not specified, use bios list.
- */
- if (error) {
- if((next_bios_ppc < BIOS_MAX_PPC) &&
- (*(BIOS_PORTS+next_bios_ppc) != 0) ) {
- port = *(BIOS_PORTS+next_bios_ppc++);
- if (bootverbose)
- device_printf(dev, "parallel port found at 0x%x\n",
- (int) port);
- } else {
- device_printf(dev, "parallel port not found.\n");
- return ENXIO;
- }
- bus_set_resource(dev, SYS_RES_IOPORT, 0, port, IO_LPTSIZE);
- }
-#endif
-#ifdef __alpha__
- /*
- * There isn't a bios list on alpha. Put it in the usual place.
- */
- if (error) {
- bus_set_resource(dev, SYS_RES_IOPORT, 0, 0x3bc, IO_LPTSIZE);
- }
-#endif
-
- /* IO port is mandatory */
- ppc->res_ioport = bus_alloc_resource(dev, SYS_RES_IOPORT,
- &ppc->rid_ioport, 0, ~0,
- IO_LPTSIZE, RF_ACTIVE);
- if (ppc->res_ioport == 0) {
- device_printf(dev, "cannot reserve I/O port range\n");
- goto error;
- }
- ppc->ppc_base = rman_get_start(ppc->res_ioport);
-
- ppc->ppc_flags = device_get_flags(dev);
-
- if (!(ppc->ppc_flags & 0x20)) {
- ppc->res_irq = bus_alloc_resource(dev, SYS_RES_IRQ, &ppc->rid_irq,
- 0ul, ~0ul, 1, RF_SHAREABLE);
- ppc->res_drq = bus_alloc_resource(dev, SYS_RES_DRQ, &ppc->rid_drq,
- 0ul, ~0ul, 1, RF_ACTIVE);
- }
-
- if (ppc->res_irq)
- ppc->ppc_irq = rman_get_start(ppc->res_irq);
- if (ppc->res_drq)
- ppc->ppc_dmachan = rman_get_start(ppc->res_drq);
-
- ppc->ppc_unit = device_get_unit(dev);
- ppc->ppc_model = GENERIC;
-
- ppc->ppc_mode = PPB_COMPATIBLE;
- ppc->ppc_epp = (ppc->ppc_flags & 0x10) >> 4;
-
- ppc->ppc_type = PPC_TYPE_GENERIC;
-
- /*
- * Try to detect the chipset and its mode.
- */
- if (ppc_detect(ppc, ppc->ppc_flags & 0xf))
- goto error;
-
- return (0);
-
-error:
- if (ppc->res_irq != 0) {
- bus_release_resource(dev, SYS_RES_IRQ, ppc->rid_irq,
- ppc->res_irq);
- }
- if (ppc->res_ioport != 0) {
- bus_deactivate_resource(dev, SYS_RES_IOPORT, ppc->rid_ioport,
- ppc->res_ioport);
- bus_release_resource(dev, SYS_RES_IOPORT, ppc->rid_ioport,
- ppc->res_ioport);
- }
- if (ppc->res_drq != 0) {
- bus_deactivate_resource(dev, SYS_RES_DRQ, ppc->rid_drq,
- ppc->res_drq);
- bus_release_resource(dev, SYS_RES_DRQ, ppc->rid_drq,
- ppc->res_drq);
- }
- return (ENXIO);
-}
-
-static int
-ppc_attach(device_t dev)
-{
- struct ppc_data *ppc = DEVTOSOFTC(dev);
-
- device_t ppbus;
- device_t parent = device_get_parent(dev);
-
- device_printf(dev, "%s chipset (%s) in %s mode%s\n",
- ppc_models[ppc->ppc_model], ppc_avms[ppc->ppc_avm],
- ppc_modes[ppc->ppc_mode], (PPB_IS_EPP(ppc->ppc_mode)) ?
- ppc_epp_protocol[ppc->ppc_epp] : "");
-
- if (ppc->ppc_fifo)
- device_printf(dev, "FIFO with %d/%d/%d bytes threshold\n",
- ppc->ppc_fifo, ppc->ppc_wthr, ppc->ppc_rthr);
-
- if ((ppc->ppc_avm & PPB_ECP) && (ppc->ppc_dmachan > 0)) {
- /* acquire the DMA channel forever */ /* XXX */
- isa_dma_acquire(ppc->ppc_dmachan);
- isa_dmainit(ppc->ppc_dmachan, 1024); /* nlpt.BUFSIZE */
- }
-
- /* add ppbus as a child of this isa to parallel bridge */
- ppbus = device_add_child(dev, "ppbus", -1);
-
- /*
- * Probe the ppbus and attach devices found.
- */
- device_probe_and_attach(ppbus);
-
- /* register the ppc interrupt handler as default */
- if (ppc->res_irq) {
- /* default to the tty mask for registration */ /* XXX */
- if (BUS_SETUP_INTR(parent, dev, ppc->res_irq, INTR_TYPE_TTY,
- ppcintr, dev, &ppc->intr_cookie) == 0) {
-
- /* remember the ppcintr is registered */
- ppc->ppc_registered = 1;
- }
- }
-
- return (0);
-}
-
-static u_char
-ppc_io(device_t ppcdev, int iop, u_char *addr, int cnt, u_char byte)
-{
- struct ppc_data *ppc = DEVTOSOFTC(ppcdev);
- switch (iop) {
- case PPB_OUTSB_EPP:
- outsb(ppc->ppc_base + PPC_EPP_DATA, addr, cnt);
- break;
- case PPB_OUTSW_EPP:
- outsw(ppc->ppc_base + PPC_EPP_DATA, addr, cnt);
- break;
- case PPB_OUTSL_EPP:
- outsl(ppc->ppc_base + PPC_EPP_DATA, addr, cnt);
- break;
- case PPB_INSB_EPP:
- insb(ppc->ppc_base + PPC_EPP_DATA, addr, cnt);
- break;
- case PPB_INSW_EPP:
- insw(ppc->ppc_base + PPC_EPP_DATA, addr, cnt);
- break;
- case PPB_INSL_EPP:
- insl(ppc->ppc_base + PPC_EPP_DATA, addr, cnt);
- break;
- case PPB_RDTR:
- return (r_dtr(ppc));
- break;
- case PPB_RSTR:
- return (r_str(ppc));
- break;
- case PPB_RCTR:
- return (r_ctr(ppc));
- break;
- case PPB_REPP_A:
- return (r_epp_A(ppc));
- break;
- case PPB_REPP_D:
- return (r_epp_D(ppc));
- break;
- case PPB_RECR:
- return (r_ecr(ppc));
- break;
- case PPB_RFIFO:
- return (r_fifo(ppc));
- break;
- case PPB_WDTR:
- w_dtr(ppc, byte);
- break;
- case PPB_WSTR:
- w_str(ppc, byte);
- break;
- case PPB_WCTR:
- w_ctr(ppc, byte);
- break;
- case PPB_WEPP_A:
- w_epp_A(ppc, byte);
- break;
- case PPB_WEPP_D:
- w_epp_D(ppc, byte);
- break;
- case PPB_WECR:
- w_ecr(ppc, byte);
- break;
- case PPB_WFIFO:
- w_fifo(ppc, byte);
- break;
- default:
- panic("%s: unknown I/O operation", __FUNCTION__);
- break;
- }
-
- return (0); /* not significative */
-}
-
-static int
-ppc_read_ivar(device_t bus, device_t dev, int index, uintptr_t *val)
-{
- struct ppc_data *ppc = (struct ppc_data *)device_get_softc(bus);
-
- switch (index) {
- case PPC_IVAR_EPP_PROTO:
- *val = (u_long)ppc->ppc_epp;
- break;
- case PPC_IVAR_IRQ:
- *val = (u_long)ppc->ppc_irq;
- break;
- default:
- return (ENOENT);
- }
-
- return (0);
-}
-
-/*
- * Resource is useless here since ppbus devices' interrupt handlers are
- * multiplexed to the same resource initially allocated by ppc
- */
-static int
-ppc_setup_intr(device_t bus, device_t child, struct resource *r, int flags,
- void (*ihand)(void *), void *arg, void **cookiep)
-{
- int error;
- struct ppc_data *ppc = DEVTOSOFTC(bus);
-
- if (ppc->ppc_registered) {
- /* XXX refuse registration if DMA is in progress */
-
- /* first, unregister the default interrupt handler */
- if ((error = BUS_TEARDOWN_INTR(device_get_parent(bus),
- bus, ppc->res_irq, ppc->intr_cookie)))
- return (error);
-
-/* bus_deactivate_resource(bus, SYS_RES_IRQ, ppc->rid_irq, */
-/* ppc->res_irq); */
-
- /* DMA/FIFO operation won't be possible anymore */
- ppc->ppc_registered = 0;
- }
-
- /* pass registration to the upper layer, ignore the incoming resource */
- return (BUS_SETUP_INTR(device_get_parent(bus), child,
- r, flags, ihand, arg, cookiep));
-}
-
-/*
- * When no underlying device has a registered interrupt, register the ppc
- * layer one
- */
-static int
-ppc_teardown_intr(device_t bus, device_t child, struct resource *r, void *ih)
-{
- int error;
- struct ppc_data *ppc = DEVTOSOFTC(bus);
- device_t parent = device_get_parent(bus);
-
- /* pass unregistration to the upper layer */
- if ((error = BUS_TEARDOWN_INTR(parent, child, r, ih)))
- return (error);
-
- /* default to the tty mask for registration */ /* XXX */
- if (ppc->ppc_irq &&
- !(error = BUS_SETUP_INTR(parent, bus, ppc->res_irq,
- INTR_TYPE_TTY, ppcintr, bus, &ppc->intr_cookie))) {
-
- /* remember the ppcintr is registered */
- ppc->ppc_registered = 1;
- }
-
- return (error);
-}
-
-DRIVER_MODULE(ppc, isa, ppc_driver, ppc_devclass, 0, 0);
diff --git a/sys/dev/ppc/ppcreg.h b/sys/dev/ppc/ppcreg.h
deleted file mode 100644
index ec17806d1087..000000000000
--- a/sys/dev/ppc/ppcreg.h
+++ /dev/null
@@ -1,238 +0,0 @@
-/*-
- * Copyright (c) 1997 Nicolas Souchu
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- *
- */
-#ifndef __PPCREG_H
-#define __PPCREG_H
-
-/*
- * Parallel Port Chipset type.
- */
-#define SMC_LIKE 0
-#define SMC_37C665GT 1
-#define SMC_37C666GT 2
-#define NS_PC87332 3
-#define NS_PC87306 4
-#define INTEL_820191AA 5 /* XXX not implemented */
-#define GENERIC 6
-#define WINB_W83877F 7
-#define WINB_W83877AF 8
-#define WINB_UNKNOWN 9
-#define NS_PC87334 10
-
-/*
- * Parallel Port Chipset Type. SMC versus GENERIC (others)
- */
-#define PPC_TYPE_SMCLIKE 0
-#define PPC_TYPE_GENERIC 1
-
-/*
- * Generic structure to hold parallel port chipset info.
- */
-struct ppc_data {
-
- int ppc_unit;
- int ppc_model; /* chipset model if detected */
- int ppc_type; /* generic or smclike chipset type */
-
- int ppc_mode; /* chipset current mode */
- int ppc_avm; /* chipset available modes */
-
-#define PPC_IRQ_NONE 0x0
-#define PPC_IRQ_nACK 0x1
-#define PPC_IRQ_DMA 0x2
-#define PPC_IRQ_FIFO 0x4
-#define PPC_IRQ_nFAULT 0x8
- int ppc_irqstat; /* remind irq settings */
-
-#define PPC_DMA_INIT 0x01
-#define PPC_DMA_STARTED 0x02
-#define PPC_DMA_COMPLETE 0x03
-#define PPC_DMA_INTERRUPTED 0x04
-#define PPC_DMA_ERROR 0x05
- int ppc_dmastat; /* dma state */
- int ppc_dmachan; /* dma channel */
- int ppc_dmaflags; /* dma transfer flags */
- caddr_t ppc_dmaddr; /* buffer address */
- u_int ppc_dmacnt; /* count of bytes sent with dma */
-
-#define PPC_PWORD_MASK 0x30
-#define PPC_PWORD_16 0x00
-#define PPC_PWORD_8 0x10
-#define PPC_PWORD_32 0x20
- char ppc_pword; /* PWord size */
- short ppc_fifo; /* FIFO threshold */
-
- short ppc_wthr; /* writeIntrThresold */
- short ppc_rthr; /* readIntrThresold */
-
- char *ppc_ptr; /* microseq current pointer */
- int ppc_accum; /* microseq accumulator */
- int ppc_base; /* parallel port base address */
- int ppc_epp; /* EPP mode (1.7 or 1.9) */
- int ppc_irq;
-
- unsigned char ppc_flags;
-
- device_t ppbus; /* parallel port chipset corresponding ppbus */
-
- int rid_irq, rid_drq, rid_ioport;
- struct resource *res_irq, *res_drq, *res_ioport;
-
- void *intr_cookie;
-
- int ppc_registered; /* 1 if ppcintr() is the registered interrupt */
-};
-
-/*
- * Parallel Port Chipset registers.
- */
-#define PPC_SPP_DTR 0 /* SPP data register */
-#define PPC_ECP_A_FIFO 0 /* ECP Address fifo register */
-#define PPC_SPP_STR 1 /* SPP status register */
-#define PPC_SPP_CTR 2 /* SPP control register */
-#define PPC_EPP_ADDR 3 /* EPP address register (8 bit) */
-#define PPC_EPP_DATA 4 /* EPP data register (8, 16 or 32 bit) */
-#define PPC_ECP_D_FIFO 0x400 /* ECP Data fifo register */
-#define PPC_ECP_CNFGA 0x400 /* Configuration register A */
-#define PPC_ECP_CNFGB 0x401 /* Configuration register B */
-#define PPC_ECP_ECR 0x402 /* ECP extended control register */
-
-#define PPC_FIFO_EMPTY 0x1 /* ecr register - bit 0 */
-#define PPC_FIFO_FULL 0x2 /* ecr register - bit 1 */
-#define PPC_SERVICE_INTR 0x4 /* ecr register - bit 2 */
-#define PPC_ENABLE_DMA 0x8 /* ecr register - bit 3 */
-#define PPC_nFAULT_INTR 0x10 /* ecr register - bit 4 */
-#define PPC_ECR_STD 0x0
-#define PPC_ECR_PS2 0x20
-#define PPC_ECR_FIFO 0x40
-#define PPC_ECR_ECP 0x60
-#define PPC_ECR_EPP 0x80
-
-#define PPC_DISABLE_INTR (PPC_SERVICE_INTR | PPC_nFAULT_INTR)
-#define PPC_ECR_RESET (PPC_ECR_PS2 | PPC_DISABLE_INTR)
-
-#define r_dtr(ppc) (inb((ppc)->ppc_base + PPC_SPP_DTR))
-#define r_str(ppc) (inb((ppc)->ppc_base + PPC_SPP_STR))
-#define r_ctr(ppc) (inb((ppc)->ppc_base + PPC_SPP_CTR))
-#define r_epp_A(ppc) (inb((ppc)->ppc_base + PPC_EPP_ADDR))
-#define r_epp_D(ppc) (inb((ppc)->ppc_base + PPC_EPP_DATA))
-#define r_cnfgA(ppc) (inb((ppc)->ppc_base + PPC_ECP_CNFGA))
-#define r_cnfgB(ppc) (inb((ppc)->ppc_base + PPC_ECP_CNFGB))
-#define r_ecr(ppc) (inb((ppc)->ppc_base + PPC_ECP_ECR))
-#define r_fifo(ppc) (inb((ppc)->ppc_base + PPC_ECP_D_FIFO))
-
-#define w_dtr(ppc,byte) outb((ppc)->ppc_base + PPC_SPP_DTR, byte)
-#define w_str(ppc,byte) outb((ppc)->ppc_base + PPC_SPP_STR, byte)
-#define w_ctr(ppc,byte) outb((ppc)->ppc_base + PPC_SPP_CTR, byte)
-#define w_epp_A(ppc,byte) outb((ppc)->ppc_base + PPC_EPP_ADDR, byte)
-#define w_epp_D(ppc,byte) outb((ppc)->ppc_base + PPC_EPP_DATA, byte)
-#define w_ecr(ppc,byte) outb((ppc)->ppc_base + PPC_ECP_ECR, byte)
-#define w_fifo(ppc,byte) outb((ppc)->ppc_base + PPC_ECP_D_FIFO, byte)
-
-/*
- * Register defines for the PC873xx parts
- */
-
-#define PC873_FER 0x00
-#define PC873_PPENABLE (1<<0)
-#define PC873_FAR 0x01
-#define PC873_PTR 0x02
-#define PC873_CFGLOCK (1<<6)
-#define PC873_EPPRDIR (1<<7)
-#define PC873_EXTENDED (1<<7)
-#define PC873_LPTBIRQ7 (1<<3)
-#define PC873_FCR 0x03
-#define PC873_ZWS (1<<5)
-#define PC873_ZWSPWDN (1<<6)
-#define PC873_PCR 0x04
-#define PC873_EPPEN (1<<0)
-#define PC873_EPP19 (1<<1)
-#define PC873_ECPEN (1<<2)
-#define PC873_ECPCLK (1<<3)
-#define PC873_PMC 0x06
-#define PC873_TUP 0x07
-#define PC873_SID 0x08
-#define PC873_PNP0 0x1b
-#define PC873_PNP1 0x1c
-#define PC873_LPTBA 0x19
-
-/*
- * Register defines for the SMC FDC37C66xGT parts
- */
-
-/* Init codes */
-#define SMC665_iCODE 0x55
-#define SMC666_iCODE 0x44
-
-/* Base configuration ports */
-#define SMC66x_CSR 0x3F0
-#define SMC666_CSR 0x370 /* hard-configured value for 666 */
-
-/* Bits */
-#define SMC_CR1_ADDR 0x3 /* bit 0 and 1 */
-#define SMC_CR1_MODE (1<<3) /* bit 3 */
-#define SMC_CR4_EMODE 0x3 /* bits 0 and 1 */
-#define SMC_CR4_EPPTYPE (1<<6) /* bit 6 */
-
-/* Extended modes */
-#define SMC_SPP 0x0 /* SPP */
-#define SMC_EPPSPP 0x1 /* EPP and SPP */
-#define SMC_ECP 0x2 /* ECP */
-#define SMC_ECPEPP 0x3 /* ECP and EPP */
-
-/*
- * Register defines for the Winbond W83877F parts
- */
-
-#define WINB_W83877F_ID 0xa
-#define WINB_W83877AF_ID 0xb
-
-/* Configuration bits */
-#define WINB_HEFERE (1<<5) /* CROC bit 5 */
-#define WINB_HEFRAS (1<<0) /* CR16 bit 0 */
-
-#define WINB_PNPCVS (1<<2) /* CR16 bit 2 */
-#define WINB_CHIPID 0xf /* CR9 bits 0-3 */
-
-#define WINB_PRTMODS0 (1<<2) /* CR0 bit 2 */
-#define WINB_PRTMODS1 (1<<3) /* CR0 bit 3 */
-#define WINB_PRTMODS2 (1<<7) /* CR9 bit 7 */
-
-/* W83877F modes: CR9/bit7 | CR0/bit3 | CR0/bit2 */
-#define WINB_W83757 0x0
-#define WINB_EXTFDC 0x4
-#define WINB_EXTADP 0x8
-#define WINB_EXT2FDD 0xc
-#define WINB_JOYSTICK 0x80
-
-#define WINB_PARALLEL 0x80
-#define WINB_EPP_SPP 0x4
-#define WINB_ECP 0x8
-#define WINB_ECP_EPP 0xc
-
-#endif
diff --git a/sys/dev/ray/if_ray.c b/sys/dev/ray/if_ray.c
deleted file mode 100644
index d64b01927766..000000000000
--- a/sys/dev/ray/if_ray.c
+++ /dev/null
@@ -1,3640 +0,0 @@
-/*
- * Copyright (C) 2000
- * Dr. Duncan McLennan Barclay, dmlb@ragnet.demon.co.uk.
- *
- * 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 author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY DUNCAN BARCLAY 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 DUNCAN BARCLAY 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.
- *
- * $Id: if_ray.c,v 1.8 2000/03/08 08:53:36 dmlb Exp $
- *
- */
-
-/* $NetBSD: if_ray.c,v 1.12 2000/02/07 09:36:27 augustss Exp $ */
-/*
- * Copyright (c) 2000 Christian E. Hopps
- * 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 author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- */
-
-/*
- *
- * Card configuration
- * ==================
- *
- * This card is unusual in that it uses both common and attribute
- * memory whilst working. The -stable versions of FreeBSD have a real
- * problem managing and setting up the correct memory maps. This
- * driver should reset the memory maps correctly under PAO and non-PAO
- * -stable systems. Work is in hand to fix these problems for -current.
- *
- * So, if you want to use this driver make sure that
- * options RAY_NEED_CM_FIXUP
- * options RAY_NEED_CM_REMAPPING
- * are in your kernel configuration file.
- *
- * The first fixes the brain deadness of pccardd (where it reads the
- * CIS for common memory, sets it all up and then throws it all away
- * assuming the card is an ed driver...). Note that this could be
- * dangerous (because it doesn't interact with pccardd) if you
- * use other memory mapped cards at the same time.
- *
- * The second option ensures that common memory is remapped whenever
- * we are going to access it (we can't just do it once, as something
- * like pccardd may have read the attribute memory and pccard.c
- * doesn't re-map the last active window - it remaps the last
- * non-active window...).
- *
- *
- * Ad-hoc and infra-structure modes
- * ================================
- *
- * At present only the ad-hoc mode is being worked on.
- *
- * Apart from just writing the code for infrastructure mode I have a
- * few concerns about both the Linux and NetBSD drivers in this area.
- * They don't seem to differentiate between the MAC address of the AP
- * and the BSS_ID of the network. I presume this is handled when
- * joining a managed n/w and the network parameters are updated, but
- * I'm not sure. How does this interact with ARP? For mobility we want
- * to be able to move around without worrying about which AP we are
- * actually talking to - we should always talk to the BSS_ID.
- *
- * The Linux driver also seems to have the capability to act as an AP.
- * I wonder what facilities the "AP" can provide within a driver? We can
- * probably use the BRIDGE code to form an ESS but I don't think
- * power saving etc. is easy.
- *
- *
- * Packet translation/encapsulation
- * ================================
- *
- * Currently we only support the Webgear encapsulation
- * 802.11 header <net/if_ieee80211.h>struct ieee80211_header
- * 802.3 header <net/ethernet.h>struct ether_header
- * 802.2 LLC header
- * 802.2 SNAP header
- *
- * We should support whatever packet types the following drivers have
- * if_wi.c FreeBSD, RFC1042
- * if_ray.c NetBSD Webgear, RFC1042
- * rayctl.c Linux Webgear, RFC1042
- * also whatever we can divine from the NDC Access points and Kanda's boxes.
- *
- * Most drivers appear to have a RFC1042 translation. The incoming packet is
- * 802.11 header <net/if_ieee80211.h>struct ieee80211_header
- * 802.2 LLC header
- * 802.2 SNAP header
- *
- * This is translated to
- * 802.3 header <net/ethernet.h>struct ether_header
- * 802.2 LLC header
- * 802.2 SNAP header
- *
- * Linux seems to look at the SNAP org_code and do some translations
- * for IPX and APPLEARP on that. This just may be how Linux does IPX
- * and NETATALK. Need to see how FreeBSD does these.
- *
- * Translation should be selected via if_media stuff or link types.
- */
-
-/*
- * TODO
- *
- * _stop - mostly done
- * would be nice to understand shutdown/or power save to prevent RX
- * _reset - done
- * just needs calling in the right places
- * converted panics to resets - when tx packets are the wrong length
- * may be needed in a couple of other places when I do more commands
- * havenet - mostly done
- * i think i've got all the places to set it right, but not so sure
- * we reset it in all the right places
- * _unload - done
- * recreated most of stop but as card is unplugged don't try and
- * access it to turn it off
- * TX bpf - done
- * RX bpf - done
- * I would much prefer to have the complete 802.11 packet dropped to
- * the bpf tap and then have a user land program parse the headers
- * as needed. This way, tcpdump -w can be used to grab the raw data. If
- * needed the 802.11 aware program can "translate" the .11 to ethernet
- * for tcpdump -r
- * use std timeout code for download - done
- * was mainly moving a call and removing a load of stuff in
- * download_done as it duplicates check_ccs and ccs_done
- * promisoius - done
- * add the start_join_net - done
- * i needed it anyway
- * remove startccs and startcmd - done
- * as those were used for the NetBSD start timeout
- * multicast - done but UNTESTED
- * I don't have the ability/facilty to test this
- * rxlevel - done
- * stats reported via raycontrol
- * getparams ioctl - done
- * reported via raycontrol
- * start_join_done needs a restart in download_done - done
- * now use netbsd style start up
- *
- * shutdown
- * ifp->if_hdr length
- * _reset - check where needed
- * apm
- * ioctls - translation, BSS_ID, countrycode, changing mode
- * faster TX routine
- * more translations
- * infrastructure mode - maybe need some of the old stuff for checking?
- * differeniate between parameters set in attach and init
- * spinning in ray_issue_cmd
- * fix the XXX code in start_join_done
- *
- * callout handles need rationalising. can probably remove timerh and
- * use ccs_timerh for download and sj_timerh
- *
- * ray_update_params_done needs work
- *
- * make RAY_DEBUG a knob somehow - either sysctl or IFF_DEBUG
- *
- */
-
-#define XXX 0
-#define XXX_NETBSDTX 0
-#define XXX_PROM 0
-#define XXX_IOCTL 0
-
-/*
- * XXX build options - move to LINT
- */
-
-/*
- * RAY_DEBUG settings
- *
- * 2 Recoverable error's
- * 6 Subroutine entry
- * 11 Startup CM dump
- * 16 State transitions for start/join
- * 21 CCS info
- * 31 IOCTL calls
- * 51 MBUFs dumped/packet types reported
- */
-#ifndef RAY_DEBUG
-#define RAY_DEBUG 2
-#endif
-
-#define RAY_CCS_TIMEOUT (hz/2) /* Timeout for CCS commands */
-#define RAY_CHECK_SCHED_TIMEOUT (hz) /* Time to wait until command retry, should be > RAY_CCS_TIMEOUT */
-
-#define RAY_NEED_STARTJOIN_TIMO 0 /* Might be needed with build 4 */
-#define RAY_SJ_TIMEOUT (90*hz) /* Timeout for failing STARTJOIN commands - only used with RAY_NEED_STARTJOIN_TIMO */
-
-#define RAY_NEED_CM_FIXUP 1 /* Needed until pccardd hacks for ed drivers are removed (pccardd forces 16bit memory and 0x4000 size) THIS IS A DANGEROUS THING TO USE IF YOU USE OTHER MEMORY MAPPED PCCARDS */
-
-#define RAY_NEED_CM_REMAPPING 1 /* Needed until pccard maps more than one memory area */
-
-#define RAY_DUMP_CM_ON_GIFMEDIA 1 /* Dump some common memory when the SIOCGIFMEDIA ioctl is issued - a nasty hack for debugging and will be placed by an ioctl and control program */
-
-#define RAY_RESET_TIMEOUT (5*hz) /* Timeout for resetting the card */
-
-#define RAY_USE_CALLOUT_STOP 0 /* Set for kernels with callout_stop function - 3.3 and above */
-
-#define RAY_SIMPLE_TX 1 /* Simple TX routine */
-#define RAY_DECENT_TX 0 /* Decent TX routine - tbd */
-/*
- * XXX build options - move to LINT
- */
-
-/*
- * Debugging odds and odds
- */
-#ifndef RAY_DEBUG
-#define RAY_DEBUG 0
-#endif /* RAY_DEBUG */
-
-#if RAY_DEBUG > 0
-
-/* XXX This macro assumes that common memory is mapped into kernel space and
- * XXX does not indirect through SRAM macros - it should
- */
-#define RAY_DHEX8(p, l) do { if (RAY_DEBUG > 10) { \
- u_int8_t *i; \
- for (i = p; i < (u_int8_t *)(p+l); i += 8) \
- printf(" 0x%08lx %8D\n", \
- (unsigned long)i, (unsigned char *)i, " "); \
-} } while (0)
-
-#define RAY_DPRINTFN(l, x) do { if (RAY_DEBUG > l) { \
- printf x ; \
-} } while (0)
-
-#define RAY_DNET_DUMP(sc, s) do { if (RAY_DEBUG) { \
- printf("ray%d: Current network parameters%s\n", (sc)->unit, (s)); \
- printf(" bss_id %6D\n", (sc)->sc_c.np_bss_id, ":"); \
- printf(" inited 0x%02x\n", (sc)->sc_c.np_inited); \
- printf(" def_txrate 0x%02x\n", (sc)->sc_c.np_def_txrate); \
- printf(" encrypt 0x%02x\n", (sc)->sc_c.np_encrypt); \
- printf(" net_type 0x%02x\n", (sc)->sc_c.np_net_type); \
- printf(" ssid \"%.32s\"\n", (sc)->sc_c.np_ssid); \
- printf(" %8D\n", (sc)->sc_c.np_ssid, " "); \
- printf(" %8D\n", (sc)->sc_c.np_ssid+8, " "); \
- printf(" %8D\n", (sc)->sc_c.np_ssid+16, " "); \
- printf(" %8D\n", (sc)->sc_c.np_ssid+24, " "); \
- printf(" priv_start 0x%02x\n", (sc)->sc_c.np_priv_start); \
- printf(" priv_join 0x%02x\n", (sc)->sc_c.np_priv_join); \
- printf("ray%d: Desired network parameters%s\n", (sc)->unit, (s)); \
- printf(" bss_id %6D\n", (sc)->sc_d.np_bss_id, ":"); \
- printf(" inited 0x%02x\n", (sc)->sc_d.np_inited); \
- printf(" def_txrate 0x%02x\n", (sc)->sc_d.np_def_txrate); \
- printf(" encrypt 0x%02x\n", (sc)->sc_d.np_encrypt); \
- printf(" net_type 0x%02x\n", (sc)->sc_d.np_net_type); \
- printf(" ssid \"%.32s\"\n", (sc)->sc_d.np_ssid); \
- printf(" %8D\n", (sc)->sc_c.np_ssid, " "); \
- printf(" %8D\n", (sc)->sc_c.np_ssid+8, " "); \
- printf(" %8D\n", (sc)->sc_c.np_ssid+16, " "); \
- printf(" %8D\n", (sc)->sc_c.np_ssid+24, " "); \
- printf(" priv_start 0x%02x\n", (sc)->sc_d.np_priv_start); \
- printf(" priv_join 0x%02x\n", (sc)->sc_d.np_priv_join); \
-} } while (0)
-
-#else
-#define RAY_DHEX8(p, l)
-#define RAY_DPRINTFN(l,x)
-#define RAY_DNET_DUMP(sc, s)
-#endif /* RAY_DEBUG > 0 */
-
-#if RAY_DEBUG > 50
-#define RAY_DMBUF_DUMP(sc, m, s) ray_dump_mbuf((sc), (m), (s))
-#else
-#define RAY_DMBUF_DUMP(sc, m, s)
-#endif /* RAY_DEBUG > 10 */
-
-#include "ray.h"
-#include "card.h"
-#include "apm.h"
-#include "bpfilter.h"
-
-#if NRAY > 0
-
-#include <sys/param.h>
-#include <sys/cdefs.h>
-#include <sys/conf.h>
-#include <sys/errno.h>
-#include <sys/kernel.h>
-#include <sys/malloc.h>
-#include <sys/mbuf.h>
-#include <sys/callout.h>
-#include <sys/select.h>
-#include <sys/socket.h>
-#include <sys/sockio.h>
-#include <sys/systm.h>
-#include <sys/sysctl.h>
-#include <sys/uio.h>
-#include <sys/proc.h>
-#include <sys/ucred.h>
-
-#include <net/if.h>
-#include <net/if_arp.h>
-#include <net/ethernet.h>
-#include <net/if_dl.h>
-#include <net/if_media.h>
-#include <net/if_mib.h>
-
-#if NBPFILTER > 0
-#include <net/bpf.h>
-#endif /* NBPFILTER */
-
-#include <machine/clock.h>
-#include <machine/md_var.h>
-#include <machine/bus_pio.h>
-#include <machine/bus.h>
-
-#include <i386/isa/isa.h>
-#include <i386/isa/isa_device.h>
-
-#include <i386/isa/if_ieee80211.h>
-#include <i386/isa/if_rayreg.h>
-#include <i386/isa/if_raymib.h>
-
-#if NCARD > 0
-#include <pccard/cardinfo.h>
-#include <pccard/cis.h>
-#include <pccard/driver.h>
-#include <pccard/slot.h>
-#endif /* NCARD */
-
-#if NAPM > 0
-#include <machine/apm_bios.h>
-#endif /* NAPM */
-
-/*
- * Sysctl knobs
- */
-static int ray_debug = RAY_DEBUG;
-
-SYSCTL_NODE(_hw, OID_AUTO, ray, CTLFLAG_RW, 0, "Raylink Driver");
-SYSCTL_INT(_hw_ray, OID_AUTO, debug, CTLFLAG_RW, &ray_debug, RAY_DEBUG, "");
-
-/*
- * Network parameters, used twice in sotfc to store what we want and what
- * we have.
- *
- * XXX promisc in here too?
- * XXX sc_station_addr in here too (for changing mac address)
- */
-struct ray_nw_param {
- struct ray_cmd_net p_1;
- u_int8_t np_ap_status;
- struct ray_net_params \
- p_2;
- u_int8_t np_countrycode;
-};
-#define np_upd_param p_1.c_upd_param
-#define np_bss_id p_1.c_bss_id
-#define np_inited p_1.c_inited
-#define np_def_txrate p_1.c_def_txrate
-#define np_encrypt p_1.c_encrypt
-#define np_net_type p_2.p_net_type
-#define np_ssid p_2.p_ssid
-#define np_priv_start p_2.p_privacy_must_start
-#define np_priv_join p_2.p_privacy_can_join
-
-/*
- * One of these structures per allocated device
- */
-struct ray_softc {
-
- struct arpcom arpcom; /* Ethernet common */
- struct ifmedia ifmedia; /* Ifnet common */
- struct callout_handle \
- ccs_timerh; /* Handle for ccs timeouts */
- struct callout_handle \
- reset_timerh; /* Handle for reset timer */
- struct callout_handle \
- start_timerh; /* Handle for start timer */
-#if RAY_NEED_STARTJOIN_TIMO
- struct callout_handle \
- sj_timerh; /* Handle for start_join timer */
-#endif /* RAY_NEED_STARTJOIN_TIMO */
- char *card_type; /* Card model name */
- char *vendor; /* Card manufacturer */
-
- int unit; /* Unit number */
- u_char gone; /* 1 = Card bailed out */
- caddr_t maddr; /* Shared RAM Address */
- int flags; /* Start up flags */
-
- int translation; /* Packet translation types */
-
-#if (RAY_NEED_CM_REMAPPING | RAY_NEED_CM_FIXUP)
- int slotnum; /* Slot number */
- struct mem_desc md; /* Map info for common memory */
-#endif /* (RAY_NEED_CM_REMAPPING | RAY_NEED_CM_FIXUP) */
-
- struct ray_ecf_startup_v5 \
- sc_ecf_startup; /* Startup info from card */
-
- struct ray_nw_param sc_c; /* current network params */
- struct ray_nw_param sc_d; /* desired network params */
- int sc_havenet; /* true if we have a network */
- int sc_promisc; /* current set value */
- int sc_running; /* things we are doing */
- int sc_scheduled; /* things we need to do */
- int sc_timoneed; /* set if timeout is sched */
- int sc_timocheck; /* set if timeout is sched */
- u_int8_t sc_ccsinuse[64];/* ccss' in use -- not for tx */
-
- int sc_checkcounters;
- u_int64_t sc_rxoverflow; /* Number of rx overflows */
- u_int64_t sc_rxcksum; /* Number of checksum errors */
- u_int64_t sc_rxhcksum; /* Number of header checksum errors */
- u_int8_t sc_rxnoise; /* Average receiver level */
-
- struct ray_param_req \
- *sc_repreq; /* used to return values */
- struct ray_param_req \
- *sc_updreq; /* to the user */
-};
-static struct ray_softc ray_softc[NRAY];
-
-#define sc_station_addr sc_ecf_startup.e_station_addr
-#define sc_version sc_ecf_startup.e_fw_build_string
-#define sc_tibsize sc_ecf_startup.e_tibsize
-
-/* Commands -- priority given to LSB */
-#define SCP_FIRST 0x0001
-#define SCP_UPDATESUBCMD 0x0001
-#define SCP_STARTASSOC 0x0002
-#define SCP_REPORTPARAMS 0x0004
-#define SCP_IFSTART 0x0008
-
-/* Update sub commands -- issues are serialized priority to LSB */
-#define SCP_UPD_FIRST 0x0100
-#define SCP_UPD_STARTUP 0x0100
-#define SCP_UPD_STARTJOIN 0x0200
-#define SCP_UPD_PROMISC 0x0400
-#define SCP_UPD_MCAST 0x0800
-#define SCP_UPD_UPDATEPARAMS 0x1000
-#define SCP_UPD_SHIFT 8
-#define SCP_UPD_MASK 0xff00
-
-/* These command (a subset of the update set) require timeout checking */
-#define SCP_TIMOCHECK_CMD_MASK \
- (SCP_UPD_UPDATEPARAMS | SCP_UPD_STARTUP | SCP_UPD_MCAST | \
- SCP_UPD_PROMISC)
-
-/*
- * Translation types
- */
-/* XXX maybe better as part of the if structure? */
-#define SC_TRANSLATE_WEBGEAR 0
-
-/*
- * Prototyping
- */
-static int ray_attach __P((struct isa_device *dev));
-static int ray_alloc_ccs __P((struct ray_softc *sc, size_t *ccsp, u_int cmd, u_int track));
-static void ray_ccs_done __P((struct ray_softc *sc, size_t ccs));
-static void ray_check_ccs __P((void *arg));
-static void ray_check_scheduled __P((void *arg));
-static void ray_cmd_cancel __P((struct ray_softc *sc, int cmdf));
-static void ray_cmd_done __P((struct ray_softc *sc, int cmdf));
-static int ray_cmd_is_running __P((struct ray_softc *sc, int cmdf));
-static int ray_cmd_is_scheduled __P((struct ray_softc *sc, int cmdf));
-static void ray_cmd_ran __P((struct ray_softc *sc, int cmdf));
-static void ray_cmd_schedule __P((struct ray_softc *sc, int cmdf));
-static void ray_download_done __P((struct ray_softc *sc));
-static void ray_download_params __P((struct ray_softc *sc));
-#if RAY_DEBUG > 50
-static void ray_dump_mbuf __P((struct ray_softc *sc, struct mbuf *m, char *s));
-#endif /* RAY_DEBUG > 50 */
-static u_int8_t ray_free_ccs __P((struct ray_softc *sc, size_t ccs));
-#if XXX_NETBSDTX
-static void ray_free_ccs_chain __P((struct ray_softc *sc, u_int ni));
-#endif /* XXX_NETBSDTX */
-static int ray_intr __P((struct pccard_devinfo *dev_p));
-static int ray_ioctl __P((struct ifnet *ifp, u_long command, caddr_t data));
-static void ray_init __P((void *xsc));
-static int ray_issue_cmd __P((struct ray_softc *sc, size_t ccs, u_int track));
-static int ray_pccard_init __P((struct pccard_devinfo *dev_p));
-static int ray_pccard_intr __P((struct pccard_devinfo *dev_p));
-static void ray_pccard_unload __P((struct pccard_devinfo *dev_p));
-static int ray_probe __P((struct isa_device *dev));
-static void ray_rcs_intr __P((struct ray_softc *sc, size_t ccs));
-
-static void ray_report_params __P((struct ray_softc *sc));
-static void ray_reset __P((struct ray_softc *sc));
-static void ray_reset_timo __P((void *xsc));
-static void ray_rx __P((struct ray_softc *sc, size_t rcs));
-static void ray_set_pending __P((struct ray_softc *sc, u_int cmdf));
-static int ray_simple_cmd __P((struct ray_softc *sc, u_int cmd, u_int track));
-static void ray_start __P((struct ifnet *ifp));
-static void ray_start_assoc __P((struct ray_softc *sc));
-static void ray_start_done __P((struct ray_softc *sc, size_t ccs, u_int8_t status));
-static void ray_start_sc __P((struct ray_softc *sc));
-static void ray_start_timo __P((void *xsc));
-static size_t ray_start_wrhdr __P((struct ray_softc *sc, struct ether_header *eh, size_t bufp));
-static void ray_start_join_done __P((struct ray_softc *sc, size_t ccs, u_int8_t status));
-static void ray_start_join_net __P((struct ray_softc *sc));
-#if RAY_NEED_STARTJOIN_TIMO
-static void ray_start_join_timo __P((void *xsc));
-#endif /* RAY_NEED_STARTJOIN_TIMO */
-static void ray_stop __P((struct ray_softc *sc));
-static void ray_update_error_counters \
- __P((struct ray_softc *sc));
-static void ray_update_mcast __P((struct ray_softc *sc));
-static void ray_update_params __P((struct ray_softc *sc));
-static void ray_update_params_done __P((struct ray_softc *sc, size_t ccs, u_int stat));
-static void ray_update_promisc __P((struct ray_softc *sc));
-static void ray_update_subcmd __P((struct ray_softc *sc));
-static int ray_user_update_params __P((struct ray_softc *sc, struct ray_param_req *pr));
-static int ray_user_report_params __P((struct ray_softc *sc, struct ray_param_req *pr));
-static int ray_user_report_stats __P((struct ray_softc *sc, struct ray_stats_req *sr));
-static void ray_watchdog __P((struct ifnet *ifp));
-
-/*
- * PCMCIA driver definition
- */
-PCCARD_MODULE(ray, ray_pccard_init, ray_pccard_unload, ray_pccard_intr, 0, net_imask);
-
-/*
- * ISA driver definition
- */
-struct isa_driver raydriver = {
- ray_probe,
- ray_attach,
- "ray",
- 1
-};
-
-/*
- * Command function tables - based on bit index in SCP_xx
- */
-typedef void (*ray_cmd_func_t)(struct ray_softc *);
-static ray_cmd_func_t ray_cmdtab[] = {
- ray_update_subcmd, /* SCP_UPDATESUBCMD */
- ray_start_assoc, /* SCP_STARTASSOC */
- ray_report_params, /* SCP_REPORTPARAMS */
- ray_start_sc /* SCP_IFSTART */
-};
-static int ray_ncmdtab = sizeof(ray_cmdtab) / sizeof(*ray_cmdtab);
-
-static ray_cmd_func_t ray_subcmdtab[] = {
- ray_download_params, /* SCP_UPD_STARTUP */
- ray_start_join_net, /* SCP_UPD_STARTJOIN */
- ray_update_promisc, /* SCP_UPD_PROMISC */
- ray_update_mcast, /* SCP_UPD_MCAST */
- ray_update_params /* SCP_UPD_UPDATEPARAMS */
-};
-static int ray_nsubcmdtab = sizeof(ray_subcmdtab) / sizeof(*ray_subcmdtab);
-
-/*
- * Indirections for reading/writing shared memory - from NetBSD/if_ray.c
- */
-#ifndef offsetof
-#define offsetof(type, member) \
- ((size_t)(&((type *)0)->member))
-#endif /* offsetof */
-
-#define SRAM_READ_1(sc, off) \
- (u_int8_t)*((sc)->maddr + (off))
-/* ((u_int8_t)bus_space_read_1((sc)->sc_memt, (sc)->sc_memh, (off))) */
-
-#define SRAM_READ_FIELD_1(sc, off, s, f) \
- SRAM_READ_1(sc, (off) + offsetof(struct s, f))
-
-#define SRAM_READ_FIELD_2(sc, off, s, f) \
- ((((u_int16_t)SRAM_READ_1(sc, (off) + offsetof(struct s, f)) << 8) \
- |(SRAM_READ_1(sc, (off) + 1 + offsetof(struct s, f)))))
-
-#define SRAM_READ_FIELD_N(sc, off, s, f, p, n) \
- ray_read_region(sc, (off) + offsetof(struct s, f), (p), (n))
-
-#define ray_read_region(sc, off, vp, n) \
- bcopy((sc)->maddr + (off), (vp), (n))
-
-#define SRAM_WRITE_1(sc, off, val) \
- *((sc)->maddr + (off)) = (val)
-/* bus_space_write_1((sc)->sc_memt, (sc)->sc_memh, (off), (val)) */
-
-#define SRAM_WRITE_FIELD_1(sc, off, s, f, v) \
- SRAM_WRITE_1(sc, (off) + offsetof(struct s, f), (v))
-
-#define SRAM_WRITE_FIELD_2(sc, off, s, f, v) do { \
- SRAM_WRITE_1(sc, (off) + offsetof(struct s, f), (((v) >> 8 ) & 0xff)); \
- SRAM_WRITE_1(sc, (off) + 1 + offsetof(struct s, f), ((v) & 0xff)); \
-} while (0)
-
-#define SRAM_WRITE_FIELD_N(sc, off, s, f, p, n) \
- ray_write_region(sc, (off) + offsetof(struct s, f), (p), (n))
-
-#define ray_write_region(sc, off, vp, n) \
- bcopy((vp), (sc)->maddr + (off), (n))
-
-/*
- * Macro's and constants
- */
-#ifndef RAY_CCS_TIMEOUT
-#define RAY_CCS_TIMEOUT (hz / 2)
-#endif
-#ifndef RAY_CHECK_SCHED_TIMEOUT
-#define RAY_CHECK_SCHED_TIMEOUT (hz)
-#endif
-#ifndef RAY_RESET_TIMEOUT
-#define RAY_RESET_TIMEOUT (10 * hz)
-#endif
-#ifndef RAY_START_TIMEOUT
-#define RAY_START_TIMEOUT (hz / 2)
-#endif
-#if RAY_SIMPLE_TX
-#define RAY_IFQ_MAXLEN (2)
-#else if RAY_DECENT_TX
-#define RAY_IFQ_MAXLEN (RAY_CCS_TX_LAST+1)
-#endif
-#define RAY_CCS_FREE(sc, ccs) \
- SRAM_WRITE_FIELD_1((sc), (ccs), ray_cmd, c_status, RAY_CCS_STATUS_FREE)
-#define RAY_ECF_READY(sc) (!(ray_read_reg(sc, RAY_ECFIR) & RAY_ECFIR_IRQ))
-#define RAY_ECF_START_CMD(sc) ray_attr_write((sc), RAY_ECFIR, RAY_ECFIR_IRQ)
-#define RAY_HCS_CLEAR_INTR(sc) ray_attr_write((sc), RAY_HCSIR, 0)
-#define RAY_HCS_INTR(sc) (ray_read_reg(sc, RAY_HCSIR) & RAY_HCSIR_IRQ)
-
-/*
- * As described in if_xe.c...
- *
- * Horrid stuff for accessing CIS tuples and remapping common memory...
- */
-#define CARD_MAJOR 50
-static int ray_attr_write __P((struct ray_softc *sc, off_t offset, u_int8_t byte));
-static int ray_attr_read __P((struct ray_softc *sc, off_t offset, u_int8_t *buf, int size));
-static u_int8_t ray_read_reg __P((struct ray_softc *sc, off_t reg));
-
-#if (RAY_NEED_CM_REMAPPING | RAY_NEED_CM_FIXUP)
-static void ray_attr_getmap __P((struct ray_softc *sc));
-static void ray_attr_cm __P((struct ray_softc *sc));
-#define RAY_MAP_CM(sc) ray_attr_cm(sc)
-#else
-#define RAY_MAP_CM(sc)
-#endif /* (RAY_NEED_CM_REMAPPING | RAY_NEED_CM_FIXUP) */
-
-/*
- * PCCard initialise.
- */
-static int
-ray_pccard_init (dev_p)
- struct pccard_devinfo *dev_p;
-{
- struct ray_softc *sc;
- int doRemap;
-
- RAY_DPRINTFN(5, ("ray%d: PCCard probe\n", dev_p->isahd.id_unit));
-
- if (dev_p->isahd.id_unit >= NRAY)
- return (ENODEV);
-
- sc = &ray_softc[dev_p->isahd.id_unit];
-
-#if (RAY_NEED_CM_REMAPPING | RAY_NEED_CM_FIXUP)
- sc->slotnum = dev_p->slt->slotnum;
- ray_attr_getmap(sc);
- RAY_DPRINTFN(1, ("ray%d: Memory window flags 0x%02x, start %p, size 0x%x, card address 0x%lx\n", sc->unit, sc->md.flags, sc->md.start, sc->md.size, sc->md.card));
-#endif /* (RAY_NEED_CM_REMAPPING | RAY_NEED_CM_FIXUP) */
-
-#if RAY_NEED_CM_FIXUP
- doRemap = 0;
- if (sc->md.start == 0x0) {
- printf("ray%d: pccardd did not map CM - giving up\n", sc->unit);
- return (ENXIO);
- }
- if (sc->md.flags != MDF_ACTIVE) {
- printf("ray%d: Fixing up CM flags from 0x%x to 0x40\n",
- sc->unit, sc->md.flags);
- doRemap = 1;
- sc->md.flags = MDF_ACTIVE;
- }
- if (sc->md.size != 0xc000) {
- printf("ray%d: Fixing up CM size from 0x%x to 0xc000\n",
- sc->unit, sc->md.size);
- doRemap = 1;
- sc->md.size = 0xc000;
- dev_p->isahd.id_msize = sc->md.size;
- }
- if (sc->md.card != 0) {
- printf("ray%d: Fixing up CM card address from 0x%lx to 0x0\n",
- sc->unit, sc->md.card);
- doRemap = 1;
- sc->md.card = 0;
- }
- if (doRemap)
- ray_attr_cm(sc);
-#endif /* RAY_NEED_CM_FIXUP */
-
- sc->gone = 0;
- sc->unit = dev_p->isahd.id_unit;
- sc->maddr = dev_p->isahd.id_maddr;
- sc->flags = dev_p->isahd.id_flags;
-
- printf("ray%d: <Raylink/IEEE 802.11> maddr %p msize 0x%x irq %d flags 0x%x on isa (PC-Card slot %d)\n",
- sc->unit,
- sc->maddr,
- dev_p->isahd.id_msize,
- ffs(dev_p->isahd.id_irq) - 1,
- sc->flags,
- sc->slotnum);
-
- if (ray_attach(&dev_p->isahd))
- return (ENXIO);
-
- return (0);
-}
-
-/*
- * PCCard unload.
- */
-static void
-ray_pccard_unload (dev_p)
- struct pccard_devinfo *dev_p;
-{
- struct ray_softc *sc;
- struct ifnet *ifp;
-
- RAY_DPRINTFN(5, ("ray%d: PCCard unload\n", dev_p->isahd.id_unit));
-
- sc = &ray_softc[dev_p->isahd.id_unit];
- ifp = &sc->arpcom.ac_if;
-
- if (sc->gone) {
- printf("ray%d: already unloaded\n", sc->unit);
- return;
- }
-
- /*
- * Clear out timers and sort out driver state
- *
- * We use callout_stop to unconditionally kill the ccs and general
- * timers as they are used with multiple arguments.
- */
-#if RAY_USE_CALLOUT_STOP
- callout_stop(sc->ccs_timerh);
- callout_stop(sc->reset_timerh);
-#else
- untimeout(ray_check_ccs, sc, sc->ccs_timerh);
- untimeout(ray_check_scheduled, sc, sc->ccs_timerh);
- untimeout(ray_reset_timo, sc, sc->reset_timerh);
-#endif /* RAY_USE_CALLOUT_STOP */
-#if RAY_NEED_STARTJOIN_TIMO
- untimeout(ray_start_join_timo, sc, sc->sj_timerh);
-#endif /* RAY_NEED_STARTJOIN_TIMO */
- untimeout(ray_start_timo, sc, sc->start_timerh);
- sc->sc_havenet = 0;
-
- /*
- * Mark as not running
- */
- ifp->if_flags &= ~IFF_RUNNING;
- ifp->if_flags &= ~IFF_OACTIVE;
-
- /*
- * Cleardown interface
- */
- if_down(ifp); /* XXX should be if_detach for -current */
-
- /*
- * Mark card as gone
- */
- sc->gone = 1;
- printf("ray%d: unloaded\n", sc->unit);
-
- return;
-}
-
-/*
- * process an interrupt
- */
-static int
-ray_pccard_intr (dev_p)
- struct pccard_devinfo *dev_p;
-{
- return (ray_intr(dev_p));
-}
-
-/*
- * ISA probe routine.
- */
-static int
-ray_probe (dev_p)
- struct isa_device *dev_p;
-{
-
- RAY_DPRINTFN(5, ("ray%d: ISA probe\n", dev_p->id_unit));
-
- return (0);
-}
-
-/*
- * ISA/PCCard attach.
- */
-static int
-ray_attach (dev_p)
- struct isa_device *dev_p;
-{
- struct ray_softc *sc;
- struct ray_ecf_startup_v5 *ep;
- struct ifnet *ifp;
- char ifname[IFNAMSIZ];
-
- RAY_DPRINTFN(5, ("ray%d: ISA/PCCard attach\n", dev_p->id_unit));
-
- sc = &ray_softc[dev_p->id_unit];
- RAY_MAP_CM(sc);
-
- if (sc->gone) {
- printf("ray%d: unloaded before attach!\n", sc->unit);
- return (1);
- }
-
- /*
- * Read startup results, check the card is okay and work out what
- * version we are using.
- */
- ep = &sc->sc_ecf_startup;
- ray_read_region(sc, RAY_ECF_TO_HOST_BASE, ep, sizeof(sc->sc_ecf_startup));
- if (ep->e_status != RAY_ECFS_CARD_OK) {
- printf("ray%d: card failed self test: status 0x%b\n", sc->unit,
- ep->e_status,
- "\020" /* print in hex */
- "\001RESERVED0"
- "\002PROC_SELF_TEST"
- "\003PROG_MEM_CHECKSUM"
- "\004DATA_MEM_TEST"
- "\005RX_CALIBRATION"
- "\006FW_VERSION_COMPAT"
- "\007RERSERVED1"
- "\008TEST_COMPLETE"
- );
- return (1);
- }
- if (sc->sc_version != RAY_ECFS_BUILD_4 &&
- sc->sc_version != RAY_ECFS_BUILD_5
- ) {
- printf("ray%d: unsupported firmware version 0x%0x\n", sc->unit,
- ep->e_fw_build_string);
- return (1);
- }
-
- if (bootverbose || RAY_DEBUG) {
- printf("ray%d: Start Up Results\n", sc->unit);
- if (sc->sc_version == RAY_ECFS_BUILD_4)
- printf(" Firmware version 4\n");
- else
- printf(" Firmware version 5\n");
- printf(" Status 0x%x\n", ep->e_status);
- printf(" Ether address %6D\n", ep->e_station_addr, ":");
- if (sc->sc_version == RAY_ECFS_BUILD_4) {
- printf(" Program checksum %0x\n", ep->e_resv0);
- printf(" CIS checksum %0x\n", ep->e_rates[0]);
- } else {
- printf(" (reserved word) %0x\n", ep->e_resv0);
- printf(" Supported rates %8D\n", ep->e_rates, ":");
- }
- printf(" Japan call sign %12D\n", ep->e_japan_callsign, ":");
- if (sc->sc_version == RAY_ECFS_BUILD_5) {
- printf(" Program checksum %0x\n", ep->e_prg_cksum);
- printf(" CIS checksum %0x\n", ep->e_cis_cksum);
- printf(" Firmware version %0x\n", ep->e_fw_build_string);
- printf(" Firmware revision %0x\n", ep->e_fw_build);
- printf(" (reserved word) %0x\n", ep->e_fw_resv);
- printf(" ASIC version %0x\n", ep->e_asic_version);
- printf(" TIB size %0x\n", ep->e_tibsize);
- }
- }
-
- /* Reset any pending interrupts */
- RAY_HCS_CLEAR_INTR(sc);
-
- /*
- * Set the parameters that will survive stop/init
- *
- * Do not update these in ray_init's parameter setup
- */
-#if XXX
- see the ray_init section for stuff to move
-#endif
- bzero(&sc->sc_d, sizeof(struct ray_nw_param));
- bzero(&sc->sc_c, sizeof(struct ray_nw_param));
-
- /*
- * Initialise the network interface structure
- */
- bcopy((char *)&ep->e_station_addr,
- (char *)&sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
- ifp = &sc->arpcom.ac_if;
- ifp->if_softc = sc;
- ifp->if_name = "ray";
- ifp->if_unit = sc->unit;
- ifp->if_timer = 0;
- ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
-#if XXX
- ifp->if_hdr = ...; make this big enough to hold the .11 and .3 headers
-#endif
- ifp->if_baudrate = 1000000; /* Is this baud or bps ;-) */
-
- ifp->if_output = ether_output;
- ifp->if_start = ray_start;
- ifp->if_ioctl = ray_ioctl;
- ifp->if_watchdog = ray_watchdog;
- ifp->if_init = ray_init;
- ifp->if_snd.ifq_maxlen = RAY_IFQ_MAXLEN;
-
- /*
- * If this logical interface has already been attached,
- * don't attach it again or chaos will ensue.
- */
- sprintf(ifname, "ray%d", sc->unit);
-
- if (ifunit(ifname) == NULL) {
- callout_handle_init(&sc->ccs_timerh);
- callout_handle_init(&sc->reset_timerh);
-#if RAY_NEED_STARTJOIN_TIMO
- callout_handle_init(&sc->sj_timerh);
-#endif /* RAY_NEED_STARTJOIN_TIMO */
- callout_handle_init(&sc->start_timerh);
- if_attach(ifp);
- ether_ifattach(ifp);
-#if NBPFILTER > 0
- bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
-#endif /* NBFFILTER */
-
-#if XXX
- this looks like a good idea
- at_shutdown(ray_shutdown, sc, SHUTDOWN_POST_SYNC);
-#endif /* XXX */
- }
-
- return (0);
-}
-
-/*
- * Network initialisation.
- *
- * Start up flow is as follows.
- * The kernel calls ray_init when the interface is assigned an address.
- *
- * ray_init does a bit of house keeping before calling ray_download_params.
- *
- * ray_download_params fills the startup parameter structure out and
- * sends it to the card. The download command simply completes, so we
- * use the timeout code in ray_check_ccs instead of spin locking. The
- * passes flow to the standard ccs handler and we eventually end up in
- * ray_download_done.
- *
- * ray_download_done tells the card to start an adhoc network or join
- * a managed network. This should complete via the interrupt
- * mechanism, but the NetBSD driver includes a timeout for some buggy
- * stuff somewhere - I've left the hooks in but don't use them. The
- * interrupt handler passes control to ray_start_join_done - the ccs
- * is handled by the interrupt mechanism.
- *
- * Once ray_start_join_done has checked the ccs and uploaded/updated
- * the network parameters we are ready to process packets. It is then
- * safe to call ray_start which is done by the interrupt handler.
- */
-static void
-ray_init (xsc)
- void *xsc;
-{
- struct ray_softc *sc = xsc;
- struct ray_ecf_startup_v5 *ep;
- struct ifnet *ifp;
- size_t ccs;
- int i;
-
- RAY_DPRINTFN(5, ("ray%d: Network init\n", sc->unit));
- RAY_MAP_CM(sc);
-
- if (sc->gone) {
- printf("ray%d: unloaded before init!\n", sc->unit);
- return;
- }
-
- ifp = &sc->arpcom.ac_if;
-
- if ((ifp->if_flags & IFF_RUNNING))
- ray_stop(sc);
-
- /*
- * Reset instance variables
- *
- * The first set are network parameters that are read back when
- * the card starts or joins the network.
- *
- * The second set are network parameters that are downloaded to
- * the card.
- *
- * The third set are driver parameters.
- *
- * All of the variables in these sets can be updated by the card or ioctls.
- */
-#if XXX
- see the ray_attach section for stuff to move
-#endif
- sc->sc_d.np_upd_param = 0;
- bzero(sc->sc_d.np_bss_id, sizeof(sc->sc_d.np_bss_id));
- sc->sc_d.np_inited = 0;
- sc->sc_d.np_def_txrate = RAY_MIB_BASIC_RATE_SET_2000K;
- sc->sc_d.np_encrypt = 0;
-
- sc->sc_d.np_ap_status = RAY_MIB_AP_STATUS_DEFAULT;
- sc->sc_d.np_net_type = RAY_MIB_NET_TYPE_DEFAULT;
- bzero(sc->sc_d.np_ssid, IEEE80211_NWID_LEN);
- strncpy(sc->sc_d.np_ssid, RAY_MIB_SSID_DEFAULT, IEEE80211_NWID_LEN);
- sc->sc_d.np_priv_start = RAY_MIB_PRIVACY_MUST_START_DEFAULT;
- sc->sc_d.np_priv_join = RAY_MIB_PRIVACY_CAN_JOIN_DEFAULT;
- sc->sc_promisc = !!(ifp->if_flags & (IFF_PROMISC|IFF_ALLMULTI));
-
- sc->sc_havenet = 0;
- sc->translation = SC_TRANSLATE_WEBGEAR;
-
- /* Set all ccs to be free */
- bzero(sc->sc_ccsinuse, sizeof(sc->sc_ccsinuse));
- ccs = RAY_CCS_ADDRESS(0);
- for (i = 0; i < RAY_CCS_LAST; ccs += RAY_CCS_SIZE, i++)
- RAY_CCS_FREE(sc, ccs);
-
- /* Clear any pending interrupts */
- RAY_HCS_CLEAR_INTR(sc);
-
-#if XXX
- Not sure why I really need this - maybe best to deal with
- this when resets are requested by me?
-#endif /* XXX */
- /*
- * Get startup results - the card may have been reset
- */
- ep = &sc->sc_ecf_startup;
- ray_read_region(sc, RAY_ECF_TO_HOST_BASE, ep, sizeof(sc->sc_ecf_startup));
- if (ep->e_status != RAY_ECFS_CARD_OK) {
- printf("ray%d: card failed self test: status 0x%b\n", sc->unit,
- ep->e_status,
- "\020" /* print in hex */
- "\001RESERVED0"
- "\002PROC_SELF_TEST"
- "\003PROG_MEM_CHECKSUM"
- "\004DATA_MEM_TEST"
- "\005RX_CALIBRATION"
- "\006FW_VERSION_COMPAT"
- "\007RERSERVED1"
- "\008TEST_COMPLETE"
- );
- return; /* XXX This doesn't mark the interface as down */
- }
-
- /*
- * Fixup tib size to be correct - on build 4 it is garbage
- */
- if (sc->sc_version == RAY_ECFS_BUILD_4 && sc->sc_tibsize == 0x55)
- sc->sc_tibsize = sizeof(struct ray_tx_tib);
-
- /*
- * We are now up and running. Next we have to download network
- * configuration into the card. We are busy until download is done.
- */
- ifp->if_flags |= IFF_RUNNING | IFF_OACTIVE;
-
- ray_download_params(sc);
-
- return;
-}
-
-/*
- * Network stop.
- *
- * Assumes that a ray_init is used to restart the card.
- *
- */
-static void
-ray_stop (sc)
- struct ray_softc *sc;
-{
- struct ifnet *ifp;
- int s;
-
- RAY_DPRINTFN(5, ("ray%d: Network stop\n", sc->unit));
- RAY_MAP_CM(sc);
-
- if (sc->gone) {
- printf("ray%d: unloaded before stop!\n", sc->unit);
- return;
- }
-
- ifp = &sc->arpcom.ac_if;
-
- /*
- * Clear out timers and sort out driver state
- */
-#if RAY_USE_CALLOUT_STOP
- callout_stop(sc->ccs_timerh);
- callout_stop(sc->reset_timerh);
-#else
- untimeout(ray_check_ccs, sc, sc->ccs_timerh);
- untimeout(ray_check_scheduled, sc, sc->ccs_timerh);
- untimeout(ray_reset_timo, sc, sc->reset_timerh);
-#endif /* RAY_USE_CALLOUT_STOP */
-#if RAY_NEED_STARTJOIN_TIMO
- untimeout(ray_start_join_timo, sc, sc->sj_timerh);
-#endif /* RAY_NEED_STARTJOIN_TIMO */
- untimeout(ray_start_timo, sc, sc->start_timerh);
- sc->sc_havenet = 0;
- sc->sc_rxoverflow = 0;
- sc->sc_rxcksum = 0;
- sc->sc_rxhcksum = 0;
- sc->sc_rxnoise = 0;
-
- /*
- * Inhibit card - if we can't prevent reception then do not worry;
- * stopping a NIC only guarantees no TX.
- */
- s = splimp();
- /* XXX what does the SHUTDOWN command do? Or power saving in COR */
- splx(s);
-
- /*
- * Mark as not running
- */
- ifp->if_flags &= ~IFF_RUNNING;
- ifp->if_flags &= ~IFF_OACTIVE;
-
- return;
-}
-
-/*
- * Reset the card
- *
- * I'm using the soft reset command in the COR register. I'm not sure
- * if the sequence is right but it does seem to do the right thing. A
- * nano second after reset is written the flashing light goes out, and
- * a few seconds after the default is written the main card light goes
- * out. We wait a while and then re-init the card.
- */
-static void
-ray_reset (sc)
- struct ray_softc *sc;
-{
- struct ifnet *ifp;
-
- RAY_DPRINTFN(5, ("ray%d: ray_reset\n", sc->unit));
- RAY_MAP_CM(sc);
-
- ifp = &sc->arpcom.ac_if;
-
- if (ifp->if_flags & IFF_RUNNING)
- ray_stop(sc);
-
- printf("ray%d: resetting card\n", sc->unit);
- ray_attr_write((sc), RAY_COR, RAY_COR_RESET);
- ray_attr_write((sc), RAY_COR, RAY_COR_DEFAULT);
- sc->reset_timerh = timeout(ray_reset_timo, sc, RAY_RESET_TIMEOUT);
-
- return;
-}
-
-/*
- * Finishing resetting and restarting the card
- */
-static void
-ray_reset_timo (xsc)
- void *xsc;
-{
- struct ray_softc *sc = xsc;
-
- RAY_DPRINTFN(5, ("ray%d: ray_reset_timo\n", sc->unit));
- RAY_MAP_CM(sc);
-
- if (!RAY_ECF_READY(sc)) {
- RAY_DPRINTFN(1, ("ray%d: ray_reset_timo still busy, re-schedule\n",
- sc->unit));
- sc->reset_timerh = timeout(ray_reset_timo, sc, RAY_RESET_TIMEOUT);
- return;
- }
-
- RAY_HCS_CLEAR_INTR(sc);
- ray_init(sc);
-
- return;
-}
-
-static void
-ray_watchdog (ifp)
- register struct ifnet *ifp;
-{
- struct ray_softc *sc;
-
- RAY_DPRINTFN(5, ("ray%d: Network watchdog\n", ifp->if_unit));
-
- sc = ifp->if_softc;
- RAY_MAP_CM(sc);
-
- if (sc->gone) {
- printf("ray%d: unloaded before watchdog!\n", sc->unit);
- return;
- }
-
- printf("ray%d: watchdog timeout\n", sc->unit);
-
-/* XXX may need to have remedial action here
- for example
- ray_reset
- ray_stop
- ...
- ray_init
-
- do we only use on TX?
- if so then we should clear OACTIVE etc.
-
-*/
-
- return;
-}
-
-/*
- * Network ioctl request.
- */
-static int
-ray_ioctl (ifp, command, data)
- register struct ifnet *ifp;
- u_long command;
- caddr_t data;
-{
- struct ray_softc *sc;
- struct ray_param_req pr;
- struct ray_stats_req sr;
- struct ifreq *ifr;
- int s, error, error2;
-
- RAY_DPRINTFN(5, ("ray%d: Network ioctl\n", ifp->if_unit));
-
- sc = ifp->if_softc;
- RAY_MAP_CM(sc);
-
- if (sc->gone) {
- printf("ray%d: unloaded before ioctl!\n", sc->unit);
- ifp->if_flags &= ~IFF_RUNNING;
- return (ENXIO);
- }
-
- ifr = (struct ifreq *)data;
- error = 0;
- error2 = 0;
-
- s = splimp();
-
- switch (command) {
-
- case SIOCSIFADDR:
- case SIOCGIFADDR:
- case SIOCSIFMTU:
- RAY_DPRINTFN(30, ("ray%d: ioctl SIFADDR/GIFADDR/SIFMTU\n", sc->unit));
- error = ether_ioctl(ifp, command, data);
- break;
-
- case SIOCSIFFLAGS:
- RAY_DPRINTFN(30, ("ray%d: for SIFFLAGS\n", sc->unit));
- /*
- * If the interface is marked up and stopped, then start
- * it. If it is marked down and running, then stop it.
- */
- if (ifp->if_flags & IFF_UP) {
- if (!(ifp->if_flags & IFF_RUNNING))
- ray_init(sc);
- ray_update_promisc(sc);
- } else {
- if (ifp->if_flags & IFF_RUNNING)
- ray_stop(sc);
- }
- /* XXX DROP THROUGH or not? */
-
- case SIOCADDMULTI:
- case SIOCDELMULTI:
- RAY_DPRINTFN(30, ("ray%d: ioctl called for ADDMULTI/DELMULTI\n", sc->unit));
- ray_update_mcast(sc);
- error = 0;
- break;
-
- case SIOCSRAYPARAM:
- RAY_DPRINTFN(30, ("ray%d: ioctl called for SRAYPARAM\n", sc->unit));
- error = EINVAL;
- break;
-
- case SIOCGRAYPARAM:
- RAY_DPRINTFN(30, ("ray%d: ioctl called for GRAYPARAM\n", sc->unit));
- if ((error = copyin(ifr->ifr_data, &pr, sizeof(pr))))
- break;
- error = ray_user_report_params(sc, &pr);
- error2 = copyout(&pr, ifr->ifr_data, sizeof(pr));
- error = error2 ? error2 : error;
- break;
-
- case SIOCGRAYSTATS:
- RAY_DPRINTFN(30, ("ray%d: ioctl called for GRAYSTATS\n", sc->unit));
- error = ray_user_report_stats(sc, &sr);
- error2 = copyout(&sr, ifr->ifr_data, sizeof(sr));
- error = error2 ? error2 : error;
- break;
-
- case SIOCGIFFLAGS:
- RAY_DPRINTFN(30, ("ray%d: ioctl called for GIFFLAGS\n", sc->unit));
- error = EINVAL;
- break;
-
- case SIOCGIFMETRIC:
- RAY_DPRINTFN(30, ("ray%d: ioctl called for GIFMETRIC\n", sc->unit));
- error = EINVAL;
- break;
-
- case SIOCGIFMTU:
- RAY_DPRINTFN(30, ("ray%d: ioctl called for GIFMTU\n", sc->unit));
- error = EINVAL;
- break;
-
- case SIOCGIFPHYS:
- RAY_DPRINTFN(30, ("ray%d: ioctl called for GIFPYHS\n", sc->unit));
- error = EINVAL;
- break;
-
- case SIOCSIFMEDIA:
- RAY_DPRINTFN(30, ("ray%d: ioctl called for SIFMEDIA\n", sc->unit));
- error = EINVAL;
- break;
-
- case SIOCGIFMEDIA:
- RAY_DPRINTFN(30, ("ray%d: ioctl called for GIFMEDIA\n", sc->unit));
-#if RAY_DUMP_CM_ON_GIFMEDIA
- RAY_DPRINTFN(10, ("ray%d: RAY_STATUS\n", sc->unit));
- RAY_DNET_DUMP(sc, ".");
-#endif /* RAY_DUMP_CM_ON_GIFMEDIA */
- error = EINVAL;
- break;
-
- default:
- error = EINVAL;
- }
-
- splx(s);
-
- return (error);
-}
-
-/*
- * Network start.
- *
- * Start sending a packet.
- *
- * We make two assumptions here:
- * 1) That the current priority is set to splimp _before_ this code
- * is called *and* is returned to the appropriate priority after
- * return
- * 2) That the IFF_OACTIVE flag is checked before this code is called
- * (i.e. that the output part of the interface is idle)
- */
-static void
-ray_start (ifp)
- struct ifnet *ifp;
-{
- RAY_DPRINTFN(5, ("ray%d: ray_start\n", ifp->if_unit));
-
- ray_start_sc(ifp->if_softc);
-}
-
-static void
-ray_start_sc (sc)
- struct ray_softc *sc;
-{
- struct ifnet *ifp;
- struct mbuf *m0, *m;
- struct ether_header *eh;
- size_t ccs, bufp;
- int i, pktlen, len;
- u_int8_t status;
-
- RAY_DPRINTFN(5, ("ray%d: ray_start_sc\n", sc->unit));
- RAY_MAP_CM(sc);
-
- ifp = &sc->arpcom.ac_if;
-
- /*
- * Some simple checks first
- */
- if (sc->gone) {
- printf("ray%d: unloaded before start!\n", sc->unit);
- return;
- }
- if ((ifp->if_flags & IFF_RUNNING) == 0 || !sc->sc_havenet)
- return;
- if (!RAY_ECF_READY(sc)) {
- RAY_DPRINTFN(1, ("ray%d: ray_start busy, schedule a timeout\n",
- sc->unit));
- sc->start_timerh = timeout(ray_start_timo, sc, RAY_START_TIMEOUT);
- return;
- } else
- untimeout(ray_start_timo, sc, sc->start_timerh);
-
- /*
- * Simple one packet at a time TX routine - probably appaling performance
- * and we certainly chew CPU. However bing to windows boxes shows
- * a reliance on the far end too:
- *
- * 1500k default rate
- *
- * Libretto 50CT (75MHz Pentium) with FreeBSD-3.1 to
- * Nonname box Windows 95C (133MHz AMD 5x86) 996109bps
- * AST J30 Windows 95A (100MHz Pentium) 1307791bps
- *
- * 2000k default rate
- *
- * Libretto 50CT (75MHz Pentium) with FreeBSD-3.1 to
- * Nonname box Windows 95C (133MHz AMD 5x86) 1087049bps
- * AST J30 Windows 95A (100MHz Pentium) 1307791bps
- *
- * Flow is
- * get a ccs
- * build the packet
- * set IFF_OACTIVE
- * interrupt the card to send the packet
- * exit
- *
- * wait for interrupt telling us the packet has been sent
- * clear IFF_OACTIVE
- * get called by the interrupt routine if any packets left
- */
-
- /*
- * Find a free ccs; if none available wave good bye and exit.
- *
- * We find a ccs before we process the mbuf so that we are sure it
- * is worthwhile processing the packet. All errors in the mbuf
- * processing are either errors in the mbuf or gross configuration
- * errors and the packet wouldn't get through anyway.
- *
- * Don't forget to clear the ccs on errors.
- */
- i = RAY_CCS_TX_FIRST;
- do {
- status = SRAM_READ_FIELD_1(sc, RAY_CCS_ADDRESS(i), ray_cmd, c_status);
- if (status == RAY_CCS_STATUS_FREE)
- break;
- i++;
- } while (i <= RAY_CCS_TX_LAST);
- if (i > RAY_CCS_TX_LAST) {
- ifp->if_flags |= IFF_OACTIVE;
- return;
- }
- RAY_DPRINTFN(20, ("ray%d: ray_start using ccs 0x%02x\n", sc->unit, i));
-
- /*
- * Reserve and fill the ccs - must do the length later.
- *
- * Even though build 4 and build 5 have different fields all these
- * are common apart from tx_rate. This will be overwritten later if
- * needed.
- */
- ccs = RAY_CCS_ADDRESS(i);
- bufp = RAY_TX_BASE + i * RAY_TX_BUF_SIZE;
- bufp += sc->sc_tibsize;
- SRAM_WRITE_FIELD_1(sc, ccs, ray_cmd_tx, c_status, RAY_CCS_STATUS_BUSY);
- SRAM_WRITE_FIELD_1(sc, ccs, ray_cmd_tx, c_cmd, RAY_CMD_TX_REQ);
- SRAM_WRITE_FIELD_1(sc, ccs, ray_cmd_tx, c_link, RAY_CCS_LINK_NULL);
- SRAM_WRITE_FIELD_2(sc, ccs, ray_cmd_tx, c_bufp, bufp);
- SRAM_WRITE_FIELD_1(sc, ccs, ray_cmd_tx, c_tx_rate, sc->sc_c.np_def_txrate);
- SRAM_WRITE_FIELD_1(sc, ccs, ray_cmd_tx, c_apm_mode, 0);
- SRAM_WRITE_FIELD_1(sc, ccs, ray_cmd_tx, c_antenna, 0);
- bufp += sizeof(struct ray_tx_phy_header);
-
- /*
- * Get the mbuf and process it - we have to remember to free the
- * ccs if there are any errors
- */
- IF_DEQUEUE(&ifp->if_snd, m0);
- if (m0 == NULL) {
- RAY_CCS_FREE(sc, ccs);
- return;
- }
-
- for (pktlen = 0, m = m0; m != NULL; m = m->m_next) {
- pktlen += m->m_len;
- }
- if (pktlen > ETHER_MAX_LEN - ETHER_CRC_LEN) {
- RAY_DPRINTFN(1, ("ray%d: mbuf too long %d\n", sc->unit, pktlen));
- RAY_CCS_FREE(sc, ccs);
- ifp->if_oerrors++;
- m_freem(m0);
- return;
- }
-
- /* XXX
- * I would much prefer to have the complete 802.11 packet dropped to
- * the bpf tap and then have a user land program parse the headers
- * as needed. This way, tcpdump -w can be used to grab the raw data. If
- * needed the 802.11 aware program can "translate" the .11 to ethernet
- * for tcpdump -r.
- */
-#if NBPFILTER > 0
- if (ifp->if_bpf)
- bpf_mtap(ifp, m0);
-#endif /* NBPFILTER */
-
- /*
- * Translation - capability as described earlier
- *
- * Each case must write the 802.11 header using ray_start_wrhdr,
- * passing a pointer to the ethernet header in and getting a new
- * tc buffer pointer. Next remove/modify/addto the 802.3 and 802.2
- * headers as needed.
- *
- * We've pulled up the mbuf for you.
- *
- */
- if (m0->m_len < sizeof(struct ether_header))
- m = m_pullup(m, sizeof(struct ether_header));
- if (m0 == NULL) {
- RAY_DPRINTFN(1, ("ray%d: ray_start could not pullup ether\n", sc->unit));
- RAY_CCS_FREE(sc, ccs);
- ifp->if_oerrors++;
- return;
- }
- eh = mtod(m0, struct ether_header *);
- switch (sc->translation) {
-
- case SC_TRANSLATE_WEBGEAR:
- bufp = ray_start_wrhdr(sc, eh, bufp);
- break;
-
- default:
- printf("ray%d: ray_start unknown translation type 0x%x - why?\n",
- sc->unit, sc->translation);
- RAY_CCS_FREE(sc, ccs);
- ifp->if_oerrors++;
- m0 = m_free(m0);
- return;
-
- }
- if (m0 == NULL) {
- RAY_DPRINTFN(1, ("ray%d: ray_start could not translate mbuf\n", sc->unit));
- RAY_CCS_FREE(sc, ccs);
- ifp->if_oerrors++;
- return;
- }
- pktlen = sizeof(struct ieee80211_header);
-
- /*
- * Copy the mbuf to the buffer in common memory
- *
- * We panic and don't bother wrapping as ethernet packets are 1518
- * bytes, we checked the mbuf earlier, and our TX buffers are 2048
- * bytes. We don't have 530 bytes of headers etc. so something
- * must be fubar.
- */
- for (m = m0; m != NULL; m = m->m_next) {
- pktlen += m->m_len;
- if ((len = m->m_len) == 0)
- continue;
- if ((bufp + len) < RAY_TX_END)
- ray_write_region(sc, bufp, mtod(m, u_int8_t *), len);
- else
- panic("ray%d: ray_start tx buffer overflow\n", sc->unit);
- bufp += len;
- }
- RAY_DMBUF_DUMP(sc, m0, "ray_start");
-
- m_free(m0);
-
- /*
- * Fill in a few loose ends and kick the card to send the packet
- */
- if (!RAY_ECF_READY(sc)) {
- /*
- * From NetBSD code:
- *
- * If this can really happen perhaps we need to save
- * the chain and use it later. I think this might
- * be a confused state though because we check above
- * and don't issue any commands between.
- */
- printf("ray%d: ray_tx device busy\n", sc->unit);
- RAY_CCS_FREE(sc, ccs);
- ifp->if_oerrors++;
- return;
- }
- SRAM_WRITE_FIELD_2(sc, ccs, ray_cmd_tx, c_len, pktlen);
- SRAM_WRITE_1(sc, RAY_SCB_CCSI, ccs);
- ifp->if_opackets++;
- ifp->if_flags |= IFF_OACTIVE;
- RAY_ECF_START_CMD(sc);
-
- return;
-}
-#if XXX_NETBSDTX
-netbsd
-
-driver uses a loop
- repeat
- get a ccs
- get a mbuf
- translate and send packet to shared ram
- until (no more ccs's) || (no more mbuf's)
-
- send ccs chain to card
-
- exit
-
-Linux
-
-driver is simple single shot packet (with a lot of spinlocks!)
-
-general
-
-the tx space is 0x7000 = 28kB, and TX buffer size is 2048 so there
-can be 14 requests at 2kB each
-
-from this 2k we have to remove the TIB - whatever that is - for data
-
-
-netbsd:
- we need to call _start after receiveing a packet to see
- if any packets were queued whilst in the interrupt
-
- there is a potential race in obtaining ccss for the tx, in that
- we might be in _start synchronously and then an rx interrupt
- occurs. the rx will call _start and steal tx ccs from underneath
- the interrupted entry.
-
- toptions
- dont call _start from rx interrupt
-
- find a safe way of locking
-
- find a better way of obtaining ccs using next free avilable?
-
- look at other drivers
-
- use tsleep/wakeup
-
- some form of ring to hold ccs
-
- free lsit
-
- rework calling
-#endif XXX_NETBSDTX
-
-/*
- * TX completion routine.
- *
- * Clear ccs and network flags.
- */
-static void
-ray_start_done (sc, ccs, status)
- struct ray_softc *sc;
- size_t ccs;
- u_int8_t status;
-{
- struct ifnet *ifp;
- char *status_string[] = RAY_CCS_STATUS_STRINGS;
-
- RAY_DPRINTFN(5, ("ray%d: ray_start_done\n", sc->unit));
- RAY_MAP_CM(sc);
-
- ifp = &sc->arpcom.ac_if;
-
- if (status != RAY_CCS_STATUS_COMPLETE) {
- printf("ray%d: ray_start tx completed but status is %s.\n",
- sc->unit, status_string[status]);
- ifp->if_oerrors++;
- }
-
- RAY_CCS_FREE(sc, ccs);
- ifp->if_timer = 0;
- if (ifp->if_flags & IFF_OACTIVE)
- ifp->if_flags &= ~IFF_OACTIVE;
-
- return;
-}
-
-/*
- * Start timeout routine.
- *
- * Used when card was busy but we needed to send a packet.
- */
-static void
-ray_start_timo (xsc)
- void *xsc;
-{
- struct ray_softc *sc = xsc;
- struct ifnet *ifp;
- int s;
-
- RAY_DPRINTFN(5, ("ray%d: ray_start_timo\n", sc->unit));
- RAY_MAP_CM(sc);
-
- ifp = &sc->arpcom.ac_if;
-
- if (!(ifp->if_flags & IFF_OACTIVE) && (ifp->if_snd.ifq_head != NULL)) {
- s = splimp();
- ray_start(ifp);
- splx(s);
- }
-
- return;
-}
-
-/*
- * Write an 802.11 header into the TX buffer and return the
- * adjusted buffer pointer.
- */
-static size_t
-ray_start_wrhdr (sc, eh, bufp)
- struct ray_softc *sc;
- struct ether_header *eh;
- size_t bufp;
-{
- struct ieee80211_header header;
-
- RAY_DPRINTFN(5, ("ray%d: ray_start_wrhdr\n", sc->unit));
- RAY_MAP_CM(sc);
-
- bzero(&header, sizeof(struct ieee80211_header));
-
- header.i_fc[0] = (IEEE80211_FC0_VERSION_0 | IEEE80211_FC0_TYPE_DATA);
- if (sc->sc_c.np_net_type == RAY_MIB_NET_TYPE_ADHOC) {
-
- header.i_fc[1] = IEEE80211_FC1_STA_TO_STA;
- bcopy(eh->ether_dhost, header.i_addr1, ETHER_ADDR_LEN);
- bcopy(eh->ether_shost, header.i_addr2, ETHER_ADDR_LEN);
- bcopy(sc->sc_c.np_bss_id, header.i_addr3, ETHER_ADDR_LEN);
-
- } else {
- if (sc->sc_c.np_ap_status == RAY_MIB_AP_STATUS_TERMINAL) {
-
- header.i_fc[1] = IEEE80211_FC1_STA_TO_AP;
- bcopy(sc->sc_c.np_bss_id, header.i_addr1, ETHER_ADDR_LEN);
- bcopy(eh->ether_shost, header.i_addr2, ETHER_ADDR_LEN);
- bcopy(eh->ether_dhost, header.i_addr3, ETHER_ADDR_LEN);
-
- } else
- printf("ray%d: ray_start can't be an AP yet\n", sc->unit);
- }
-
- ray_write_region(sc, bufp, (u_int8_t *)&header,
- sizeof(struct ieee80211_header));
-
- return (bufp + sizeof(struct ieee80211_header));
-}
-
-/*
- * recevice a packet from the card
- */
-static void
-ray_rx (sc, rcs)
- struct ray_softc *sc;
- size_t rcs;
-{
- struct ieee80211_header *header;
- struct ether_header *eh;
- struct ifnet *ifp;
- struct mbuf *m0;
- size_t pktlen, fraglen, readlen, tmplen;
- size_t bufp, ebufp;
- u_int8_t *dst, *src;
- u_int8_t fc;
- u_int first, ni, i;
-
- RAY_DPRINTFN(5, ("ray%d: ray_rx\n", sc->unit));
- RAY_MAP_CM(sc);
-
- RAY_DPRINTFN(20, ("ray%d: rcs chain - using rcs 0x%x\n", sc->unit, rcs));
-
- ifp = &sc->arpcom.ac_if;
- m0 = NULL;
- readlen = 0;
-
- /*
- * Get first part of packet and the length. Do some sanity checks
- * and get a mbuf.
- */
- first = RAY_CCS_INDEX(rcs);
- pktlen = SRAM_READ_FIELD_2(sc, rcs, ray_cmd_rx, c_pktlen);
-
- if ((pktlen > MCLBYTES) || (pktlen < sizeof(struct ieee80211_header))) {
- RAY_DPRINTFN(1, ("ray%d: ray_rx packet is too big or too small\n",
- sc->unit));
- ifp->if_ierrors++;
- goto skip_read;
- }
-
- MGETHDR(m0, M_DONTWAIT, MT_DATA);
- if (m0 == NULL) {
- RAY_DPRINTFN(1, ("ray%d: ray_rx MGETHDR failed\n", sc->unit));
- ifp->if_ierrors++;
- goto skip_read;
- }
- if (pktlen > MHLEN) {
- MCLGET(m0, M_DONTWAIT);
- if ((m0->m_flags & M_EXT) == 0) {
- RAY_DPRINTFN(1, ("ray%d: ray_rx MCLGET failed\n", sc->unit));
- ifp->if_ierrors++;
- m_freem(m0);
- m0 = NULL;
- goto skip_read;
- }
- }
- m0->m_pkthdr.rcvif = ifp;
- m0->m_pkthdr.len = pktlen;
- m0->m_len = pktlen;
- dst = mtod(m0, u_int8_t *);
-
- /*
- * Walk the fragment chain to build the complete packet.
- *
- * The use of two index variables removes a race with the
- * hardware. If one index were used the clearing of the CCS would
- * happen before reading the next pointer and the hardware can get in.
- * Not my idea but verbatim from the NetBSD driver.
- */
- i = ni = first;
- while ((i = ni) && (i != RAY_CCS_LINK_NULL)) {
- rcs = RAY_CCS_ADDRESS(i);
- ni = SRAM_READ_FIELD_1(sc, rcs, ray_cmd_rx, c_nextfrag);
- bufp = SRAM_READ_FIELD_2(sc, rcs, ray_cmd_rx, c_bufp);
- fraglen = SRAM_READ_FIELD_2(sc, rcs, ray_cmd_rx, c_len);
- RAY_DPRINTFN(50, ("ray%d: ray_rx frag index %d len %d bufp 0x%x ni %d\n",
- sc->unit, i, fraglen, (int)bufp, ni));
-
- if (fraglen + readlen > pktlen) {
- RAY_DPRINTFN(1, ("ray%d: ray_rx bad length current 0x%x pktlen 0x%x\n",
- sc->unit, fraglen + readlen, pktlen));
- ifp->if_ierrors++;
- m_freem(m0);
- m0 = NULL;
- goto skip_read;
- }
- if ((i < RAY_RCS_FIRST) || (i > RAY_RCS_LAST)) {
- printf("ray%d: ray_rx bad rcs index 0x%x\n", sc->unit, i);
- ifp->if_ierrors++;
- m_freem(m0);
- m0 = NULL;
- goto skip_read;
- }
-
- ebufp = bufp + fraglen;
- if (ebufp <= RAY_RX_END)
- ray_read_region(sc, bufp, dst, fraglen);
- else {
- ray_read_region(sc, bufp, dst, (tmplen = RAY_RX_END - bufp));
- ray_read_region(sc, RAY_RX_BASE, dst + tmplen, ebufp - RAY_RX_END);
- }
- dst += fraglen;
- readlen += fraglen;
- }
-
-skip_read:
-
- /*
- * Walk the chain again to free the rcss.
- */
- i = ni = first;
- while ((i = ni) && (i != RAY_CCS_LINK_NULL)) {
- rcs = RAY_CCS_ADDRESS(i);
- ni = SRAM_READ_FIELD_1(sc, rcs, ray_cmd_rx, c_nextfrag);
- RAY_CCS_FREE(sc, rcs);
- }
-
- if (m0 == NULL)
- return;
-
- RAY_DMBUF_DUMP(sc, m0, "ray_rx");
-
- /*
- * Check the 802.11 packet type and obtain the .11 src addresses.
- *
- * XXX CTL and MGT packets will have separate functions, DATA with here
- *
- * XXX This needs some work for INFRA mode
- */
- header = mtod(m0, struct ieee80211_header *);
- fc = header->i_fc[0];
- if ((fc & IEEE80211_FC0_VERSION_MASK) != IEEE80211_FC0_VERSION_0) {
- RAY_DPRINTFN(1, ("ray%d: header not version 0 fc 0x%x\n", sc->unit, fc));
- ifp->if_ierrors++;
- m_freem(m0);
- return;
- }
- switch (fc & IEEE80211_FC0_TYPE_MASK) {
-
- case IEEE80211_FC0_TYPE_MGT:
- printf("ray%d: ray_rx got a MGT packet - why?\n", sc->unit);
- ifp->if_ierrors++;
- m_freem(m0);
- return;
-
- case IEEE80211_FC0_TYPE_CTL:
- printf("ray%d: ray_rx got a CTL packet - why?\n", sc->unit);
- ifp->if_ierrors++;
- m_freem(m0);
- return;
-
- case IEEE80211_FC0_TYPE_DATA:
- RAY_DPRINTFN(50, ("ray%d: ray_rx got a DATA packet\n", sc->unit));
- break;
-
- default:
- printf("ray%d: ray_rx got a unknown packet fc0 0x%x - why?\n",
- sc->unit, fc);
- ifp->if_ierrors++;
- m_freem(m0);
- return;
-
- }
- fc = header->i_fc[1];
- switch (fc & IEEE80211_FC1_DS_MASK) {
-
- case IEEE80211_FC1_STA_TO_STA:
- src = header->i_addr2;
- RAY_DPRINTFN(50, ("ray%d: ray_rx packet from sta %6D\n",
- sc->unit, src, ":"));
- break;
-
- case IEEE80211_FC1_STA_TO_AP:
- RAY_DPRINTFN(1, ("ray%d: ray_rx packet from sta %6D to ap %6D\n",
- sc->unit,
- header->i_addr2, ":", header->i_addr3, ":"));
- ifp->if_ierrors++;
- m_freem(m0);
- break;
-
- case IEEE80211_FC1_AP_TO_STA:
- RAY_DPRINTFN(1, ("ray%d: ray_rx packet from ap %6D\n",
- sc->unit,
- header->i_addr3, ":"));
- ifp->if_ierrors++;
- m_freem(m0);
- break;
-
- case IEEE80211_FC1_AP_TO_AP:
- RAY_DPRINTFN(1, ("ray%d: ray_rx saw packet between aps %6D %6D\n",
- sc->unit,
- header->i_addr1, ":", header->i_addr2, ":"));
- ifp->if_ierrors++;
- m_freem(m0);
- return;
-
- default:
- printf("ray%d: ray_rx packet type unknown fc1 0x%x - why?\n",
- sc->unit, fc);
- ifp->if_ierrors++;
- m_freem(m0);
- return;
- }
-
- /*
- * Translation - capability as described earlier
- *
- * Each case must remove the 802.11 header and leave an 802.3
- * header in the mbuf copy addresses as needed.
- */
- switch (sc->translation) {
-
- case SC_TRANSLATE_WEBGEAR:
- /* Nice and easy - just trim the 802.11 header */
- m_adj(m0, sizeof(struct ieee80211_header));
- break;
-
- default:
- printf("ray%d: ray_rx unknown translation type 0x%x - why?\n",
- sc->unit, sc->translation);
- ifp->if_ierrors++;
- m_freem(m0);
- return;
-
- }
-
- /*
- * Finally, do a bit of house keeping before sending the packet
- * up the stack.
- */
- ifp->if_ipackets++;
-#if NBPFILTER > 0
- if (ifp->if_bpf)
- bpf_mtap(ifp, m0);
-#endif /* NBPFILTER */
-#if XXX_PROM
-if_wi.c - might be needed if we hear our own broadcasts in promiscuous mode
-but will not be if we dont see them
- if ((ifp->if_flags & IFF_PROMISC) &&
- (bcmp(eh->ether_shost, sc->arpcom.ac_enaddr, ETHER_ADDR_LEN) &&
- (eh->ether_dhost[0] & 1) == 0)
- ) {
- m_freem(m0);
- return;
- }
-#endif /* XXX_PROM */
- eh = mtod(m0, struct ether_header *);
- m_adj(m0, sizeof(struct ether_header));
- ether_input(ifp, eh, m0);
-
- return;
-}
-
-/******************************************************************************
- * XXX NOT KNF FROM HERE UP
- ******************************************************************************/
-/*
- * an update params command has completed lookup which command and
- * the status
- *
- * XXX this isn't finished yet, we need to grok the command used
- */
-static void
-ray_update_params_done(struct ray_softc *sc, size_t ccs, u_int stat)
-{
- RAY_DPRINTFN(5, ("ray%d: ray_update_params_done\n", sc->unit));
- RAY_MAP_CM(sc);
-
- RAY_DPRINTFN(20, ("ray%d: ray_update_params_done stat %d\n",
- sc->unit, stat));
-
- /* this will get more complex as we add commands */
- if (stat == RAY_CCS_STATUS_FAIL) {
- printf("ray%d: failed to update a promisc\n", sc->unit);
- /* XXX should probably reset */
- /* rcmd = ray_reset; */
- }
-
- if (sc->sc_running & SCP_UPD_PROMISC) {
- ray_cmd_done(sc, SCP_UPD_PROMISC);
- sc->sc_promisc = SRAM_READ_1(sc, RAY_HOST_TO_ECF_BASE);
- RAY_DPRINTFN(20, ("ray%d: new promisc value %d\n", sc->unit,
- sc->sc_promisc));
- } else if (sc->sc_updreq) {
- ray_cmd_done(sc, SCP_UPD_UPDATEPARAMS);
- /* get the update parameter */
- sc->sc_updreq->r_failcause =
- SRAM_READ_FIELD_1(sc, ccs, ray_cmd_update, c_failcause);
- sc->sc_updreq = 0;
- wakeup(ray_update_params);
- ray_start_join_net(sc);
- }
-}
-
-/*
- * check too see if we have any pending commands.
- */
-static void
-ray_check_scheduled(void *arg)
-{
- struct ray_softc *sc;
- int s, i, mask;
-
- s = splnet();
- sc = arg;
-
- RAY_DPRINTFN(5, ("ray%d: ray_check_scheduled\n", sc->unit));
- RAY_MAP_CM(sc);
-
- RAY_DPRINTFN(20, (
- "ray%d: ray_check_scheduled schd 0x%x running 0x%x ready %d\n",
- sc->unit, sc->sc_scheduled, sc->sc_running, RAY_ECF_READY(sc)));
-
- if (sc->sc_timoneed) {
- untimeout(ray_check_scheduled, sc, sc->ccs_timerh);
- sc->sc_timoneed = 0;
- }
-
- /* if update subcmd is running -- clear it in scheduled */
- if (sc->sc_running & SCP_UPDATESUBCMD)
- sc->sc_scheduled &= ~SCP_UPDATESUBCMD;
-
- mask = SCP_FIRST;
- for (i = 0; i < ray_ncmdtab; mask <<= 1, i++) {
- if ((sc->sc_scheduled & ~SCP_UPD_MASK) == 0)
- break;
- if (!RAY_ECF_READY(sc))
- break;
- if (sc->sc_scheduled & mask)
- (*ray_cmdtab[i])(sc);
- }
-
- RAY_DPRINTFN(20, (
- "ray%d: ray_check_scheduled sched 0x%x running 0x%x ready %d\n",
- sc->unit, sc->sc_scheduled, sc->sc_running, RAY_ECF_READY(sc)));
-
- if (sc->sc_scheduled & ~SCP_UPD_MASK)
- ray_set_pending(sc, sc->sc_scheduled);
-
- splx(s);
-}
-
-/*
- * check for unreported returns
- *
- * this routine is coded to only expect one outstanding request for the
- * timed out requests at a time, but thats all that can be outstanding
- * per hardware limitations
- */
-static void
-ray_check_ccs(void *arg)
-{
- struct ray_softc *sc;
- u_int i, cmd, stat;
- size_t ccs;
- int s;
-
- s = splnet();
- sc = arg;
-
- RAY_DPRINTFN(5, ("ray%d: ray_check_ccs\n", sc->unit));
- RAY_MAP_CM(sc);
-
- ccs = 0;
- stat = RAY_CCS_STATUS_FAIL;
- sc->sc_timocheck = 0;
- for (i = RAY_CCS_CMD_FIRST; i <= RAY_CCS_CMD_LAST; i++) {
- if (!sc->sc_ccsinuse[i])
- continue;
- ccs = RAY_CCS_ADDRESS(i);
- cmd = SRAM_READ_FIELD_1(sc, ccs, ray_cmd, c_cmd);
- switch (cmd) {
- case RAY_CMD_START_PARAMS:
- case RAY_CMD_UPDATE_MCAST:
- case RAY_CMD_UPDATE_PARAMS:
- stat = SRAM_READ_FIELD_1(sc, ccs, ray_cmd, c_status);
- RAY_DPRINTFN(20, ("ray%d: check ccs idx %d ccs 0x%x "
- "cmd 0x%x stat %d\n", sc->unit, i,
- ccs, cmd, stat));
- goto breakout;
- }
- }
-breakout:
- /* see if we got one of the commands we are looking for */
- if (i > RAY_CCS_CMD_LAST)
- ; /* nothign */
- else if (stat == RAY_CCS_STATUS_FREE) {
- stat = RAY_CCS_STATUS_COMPLETE;
- ray_ccs_done(sc, ccs);
- } else if (stat != RAY_CCS_STATUS_BUSY) {
- if (sc->sc_ccsinuse[i] == 1) {
- /* give a chance for the interrupt to occur */
- sc->sc_ccsinuse[i] = 2;
- if (!sc->sc_timocheck) {
- sc->ccs_timerh = timeout(ray_check_ccs, sc, 1);
- sc->sc_timocheck = 1;
- }
- } else
- ray_ccs_done(sc, ccs);
- } else {
- sc->ccs_timerh = timeout(ray_check_ccs, sc, RAY_CCS_TIMEOUT);
- sc->sc_timocheck = 1;
- }
- splx(s);
-}
-
-/*
- * read the counters, the card implements the following protocol
- * to keep the values from being changed while read: It checks
- * the `own' bit and if zero writes the current internal counter
- * value, it then sets the `own' bit to 1. If the `own' bit was 1 it
- * incremenets its internal counter. The user thus reads the counter
- * if the `own' bit is one and then sets the own bit to 0.
- */
-static void
-ray_update_error_counters(struct ray_softc *sc)
-{
- size_t csc;
-
- RAY_DPRINTFN(5, ("ray%d: ray_update_error_counters\n", sc->unit));
- RAY_MAP_CM(sc);
-
- /* try and update the error counters */
- csc = RAY_STATUS_BASE;
- if (SRAM_READ_FIELD_1(sc, csc, ray_csc, csc_mrxo_own)) {
- sc->sc_rxoverflow +=
- SRAM_READ_FIELD_2(sc, csc, ray_csc, csc_mrx_overflow);
- SRAM_WRITE_FIELD_1(sc, csc, ray_csc, csc_mrxo_own, 0);
- }
- if (SRAM_READ_FIELD_1(sc, csc, ray_csc, csc_mrxc_own)) {
- sc->sc_rxcksum +=
- SRAM_READ_FIELD_2(sc, csc, ray_csc, csc_mrx_overflow);
- SRAM_WRITE_FIELD_1(sc, csc, ray_csc, csc_mrxc_own, 0);
- }
- if (SRAM_READ_FIELD_1(sc, csc, ray_csc, csc_rxhc_own)) {
- sc->sc_rxhcksum +=
- SRAM_READ_FIELD_2(sc, csc, ray_csc, csc_rx_hcksum);
- SRAM_WRITE_FIELD_1(sc, csc, ray_csc, csc_rxhc_own, 0);
- }
- sc->sc_rxnoise = SRAM_READ_FIELD_1(sc, csc, ray_csc, csc_rx_noise);
-}
-
-/*
- * Process CCS command completion - called from ray_intr
- */
-static void
-ray_ccs_done(struct ray_softc *sc, size_t ccs)
-{
- u_int cmd, stat;
-
- RAY_DPRINTFN(5, ("ray%d: ray_ccs_done\n", sc->unit));
- RAY_MAP_CM(sc);
-
- cmd = SRAM_READ_FIELD_1(sc, ccs, ray_cmd, c_cmd);
- stat = SRAM_READ_FIELD_1(sc, ccs, ray_cmd, c_status);
-
- RAY_DPRINTFN(20, ("ray%d: ccs idx %d ccs 0x%x cmd 0x%x status %d\n",
- sc->unit, RAY_CCS_INDEX(ccs), ccs, cmd, stat));
-
- switch (cmd) {
-
- case RAY_CMD_START_PARAMS:
- RAY_DPRINTFN(20, ("ray%d: ray_ccs_done got START_PARAMS\n",
- sc->unit));
- ray_download_done(sc);
- break;
-
- case RAY_CMD_UPDATE_PARAMS:
- RAY_DPRINTFN(20, ("ray%d: ray_ccs_done got UPDATE_PARAMS\n",
- sc->unit));
- ray_update_params_done(sc, ccs, stat);
- break;
-
- case RAY_CMD_REPORT_PARAMS:
- RAY_DPRINTFN(20, ("ray%d: ray_ccs_done got REPORT_PARAMS\n",
- sc->unit));
- /* get the reported parameters */
- ray_cmd_done(sc, SCP_REPORTPARAMS);
- if (!sc->sc_repreq)
- break;
- sc->sc_repreq->r_failcause =
- SRAM_READ_FIELD_1(sc, ccs, ray_cmd_report, c_failcause);
- sc->sc_repreq->r_len =
- SRAM_READ_FIELD_1(sc, ccs, ray_cmd_report, c_len);
- ray_read_region(sc, RAY_ECF_TO_HOST_BASE, sc->sc_repreq->r_data,
- sc->sc_repreq->r_len);
- sc->sc_repreq = 0;
- wakeup(ray_report_params);
- break;
-
- case RAY_CMD_UPDATE_MCAST:
- RAY_DPRINTFN(20, ("ray%d: ray_ccs_done got UPDATE_MCAST\n",
- sc->unit));
- ray_cmd_done(sc, SCP_UPD_MCAST);
- if (stat == RAY_CCS_STATUS_FAIL)
- ray_reset(sc);
- break;
-
- case RAY_CMD_START_NET:
- case RAY_CMD_JOIN_NET:
- RAY_DPRINTFN(20, ("ray%d: ray_ccs_done got START|JOIN_NET\n",
- sc->unit));
- ray_start_join_done(sc, ccs, stat);
- break;
-
- case RAY_CMD_TX_REQ:
- RAY_DPRINTFN(20, ("ray%d: ray_ccs_done got TX_REQ\n",
- sc->unit));
- ray_start_done(sc, ccs, stat);
- goto done;
-
- case RAY_CMD_START_ASSOC:
- RAY_DPRINTFN(20, ("ray%d: ray_ccs_done got START_ASSOC\n",
- sc->unit));
- ray_cmd_done(sc, SCP_STARTASSOC);
- if (stat == RAY_CCS_STATUS_FAIL)
- ray_start_join_net(sc); /* XXX check */
- else {
- sc->sc_havenet = 1;
- }
- break;
-
- case RAY_CMD_UPDATE_APM:
- RAY_DPRINTFN(20, ("ray%d: ray_ccs_done got UPDATE_APM\n",
- sc->unit));
- XXX;
- break;
-
- case RAY_CMD_TEST_MEM:
- printf("ray%d: ray_ccs_done got TEST_MEM - why?\n", sc->unit);
- break;
-
- case RAY_CMD_SHUTDOWN:
- printf("ray%d: ray_ccs_done got SHUTDOWN - why?\n", sc->unit);
- break;
-
- case RAY_CMD_DUMP_MEM:
- printf("ray%d: ray_ccs_done got DUMP_MEM - why?\n", sc->unit);
- break;
-
- case RAY_CMD_START_TIMER:
- printf("ray%d: ray_ccs_done got START_TIMER - why?\n",
- sc->unit);
- break;
-
- default:
- printf("ray%d: ray_ccs_done unknown command 0x%x\n",
- sc->unit, cmd);
- break;
- }
-
- ray_free_ccs(sc, ccs);
-done:
- /*
- * see if needed things can be done now that a command
- * has completed
- */
- ray_check_scheduled(sc);
-}
-
-/*
- * Process ECF command request - called from ray_intr
- */
-static void
-ray_rcs_intr(struct ray_softc *sc, size_t rcs)
-{
- struct ifnet *ifp;
- u_int cmd, status;
-
- RAY_DPRINTFN(5, ("ray%d: ray_rcs_intr\n", sc->unit));
- RAY_MAP_CM(sc);
-
- ifp = &sc->arpcom.ac_if;
-
- cmd = SRAM_READ_FIELD_1(sc, rcs, ray_cmd, c_cmd);
- status = SRAM_READ_FIELD_1(sc, rcs, ray_cmd, c_status);
- RAY_DPRINTFN(20, ("ray%d: rcs idx %d rcs 0x%x cmd 0x%x status %d\n",
- sc->unit, RAY_CCS_INDEX(rcs), rcs, cmd, status));
-
- switch (cmd) {
-
- case RAY_ECMD_RX_DONE:
- RAY_DPRINTFN(20, ("ray%d: ray_rcs_intr got RX_DONE\n",
- sc->unit));
- ray_rx(sc, rcs);
- break;
-
- case RAY_ECMD_REJOIN_DONE:
- RAY_DPRINTFN(20, ("ray%d: ray_rcs_intr got REJOIN_DONE\n",
- sc->unit));
- sc->sc_havenet = 1; /* Should not be here but in function */
- XXX;
- break;
-
- case RAY_ECMD_ROAM_START:
- RAY_DPRINTFN(20, ("ray%d: ray_rcs_intr got ROAM_START\n",
- sc->unit));
- sc->sc_havenet = 0; /* Should not be here but in function */
- XXX;
- break;
-
- case RAY_ECMD_JAPAN_CALL_SIGNAL:
- printf("ray%d: ray_rcs_intr got JAPAN_CALL_SIGNAL - why?\n",
- sc->unit);
- break;
-
- default:
- printf("ray%d: ray_rcs_intr unknown command 0x%x\n",
- sc->unit, cmd);
- break;
- }
-
- RAY_CCS_FREE(sc, rcs);
-}
-
-/*
- * process an interrupt
- */
-static int
-ray_intr(struct pccard_devinfo *dev_p)
-{
- struct ray_softc *sc;
- struct ifnet *ifp;
- int i, count;
-
- sc = &ray_softc[dev_p->isahd.id_unit];
-
- RAY_DPRINTFN(5, ("ray%d: ray_intr\n", sc->unit));
- RAY_MAP_CM(sc);
-
- ifp = &sc->arpcom.ac_if;
-
- if (sc->gone) {
- printf("ray%d: unloaded before interrupt!\n", sc->unit);
- return (0);
- }
-
- if ((++sc->sc_checkcounters % 32) == 0)
- ray_update_error_counters(sc);
-
- /*
- * Check that the interrupt was for us, if so get the rcs/ccs
- * and vector on the command contained within it.
- */
- if (!RAY_HCS_INTR(sc))
- count = 0;
- else {
- count = 1;
- i = SRAM_READ_1(sc, RAY_SCB_RCSI);
- if (i <= RAY_CCS_LAST)
- ray_ccs_done(sc, RAY_CCS_ADDRESS(i));
- else if (i <= RAY_RCS_LAST)
- ray_rcs_intr(sc, RAY_CCS_ADDRESS(i));
- else
- printf("ray%d: ray_intr bad ccs index %d\n", sc->unit, i);
- }
-
- if (count)
- RAY_HCS_CLEAR_INTR(sc);
-
- RAY_DPRINTFN(10, ("ray%d: interrupt %s handled\n",
- sc->unit, count?"was":"not"));
-
- /* Send any packets lying around */
- if (!(ifp->if_flags & IFF_OACTIVE) && (ifp->if_snd.ifq_head != NULL))
- ray_start(ifp);
-
- return (count);
-}
-
-/*
- * Generic CCS handling
- */
-
-#if XXX_NETBSDTX
-/*
- * free the chain of descriptors -- used for freeing allocated tx chains
- */
-static void
-ray_free_ccs_chain(struct ray_softc *sc, u_int ni)
-{
- u_int i;
-
- RAY_DPRINTFN(5, ("ray%d: ray_free_ccs_chain\n", sc->unit));
- RAY_MAP_CM(sc);
-
- while ((i = ni) != RAY_CCS_LINK_NULL) {
- ni = SRAM_READ_FIELD_1(sc, RAY_CCS_ADDRESS(i), ray_cmd, c_link);
- RAY_CCS_FREE(sc, RAY_CCS_ADDRESS(i));
- }
-}
-#endif XXX_NETBSDTX
-
-/*
- * free up a cmd and return the old status.
- * this routine is only used for commands.
- */
-static u_int8_t
-ray_free_ccs(struct ray_softc *sc, size_t ccs)
-{
- u_int8_t stat;
-
- RAY_DPRINTFN(5, ("ray%d: ray_free_ccs\n", sc->unit));
- RAY_MAP_CM(sc);
-
- stat = SRAM_READ_FIELD_1(sc, ccs, ray_cmd, c_status);
- RAY_CCS_FREE(sc, ccs);
- if (ccs <= RAY_CCS_ADDRESS(RAY_CCS_LAST))
- sc->sc_ccsinuse[RAY_CCS_INDEX(ccs)] = 0;
- RAY_DPRINTFN(20, ("ray%d: ray_free_ccs freed 0x%02x\n",
- sc->unit, RAY_CCS_INDEX(ccs)));
-
- return (stat);
-}
-
-/*
- * Obtain a free ccs buffer.
- *
- * returns 1 and in `ccsp' the bus offset of the free ccs
- * or 0 if none are free
- *
- * If `track' is not zero, handles tracking this command
- * possibly indicating a callback is needed and setting a timeout
- * also if ECF isn't ready we terminate earlier to avoid overhead.
- *
- * this routine is only used for commands
- */
-static int
-ray_alloc_ccs(struct ray_softc *sc, size_t *ccsp, u_int cmd, u_int track)
-{
- size_t ccs;
- u_int i;
-
- RAY_DPRINTFN(5, ("ray%d: ray_alloc_ccs\n", sc->unit));
- RAY_MAP_CM(sc);
-
- /* for tracked commands, if not ready just set pending */
- if (track && !RAY_ECF_READY(sc)) {
- ray_cmd_schedule(sc, track);
- return (0);
- }
-
- for (i = RAY_CCS_CMD_FIRST; i <= RAY_CCS_CMD_LAST; i++) {
- /* probe here to make the card go */
- (void)SRAM_READ_FIELD_1(sc, RAY_CCS_ADDRESS(i), ray_cmd,
- c_status);
- if (!sc->sc_ccsinuse[i])
- break;
- }
- if (i > RAY_CCS_CMD_LAST) {
- if (track)
- ray_cmd_schedule(sc, track);
- return (0);
- }
- sc->sc_ccsinuse[i] = 1;
- ccs = RAY_CCS_ADDRESS(i);
- SRAM_WRITE_FIELD_1(sc, ccs, ray_cmd, c_status, RAY_CCS_STATUS_BUSY);
- SRAM_WRITE_FIELD_1(sc, ccs, ray_cmd, c_cmd, cmd);
- SRAM_WRITE_FIELD_1(sc, ccs, ray_cmd, c_link, RAY_CCS_LINK_NULL);
-
- *ccsp = ccs;
- return (1);
-}
-
-/*
- * this function sets the pending bit for the command given in 'need'
- * and schedules a timeout if none is scheduled already. Any command
- * that uses the `host to ecf' region must be serialized.
- */
-static void
-ray_set_pending(struct ray_softc *sc, u_int cmdf)
-{
- RAY_DPRINTFN(5, ("ray%d: ray_set_pending\n", sc->unit));
- RAY_MAP_CM(sc);
- RAY_DPRINTFN(20, ("ray%d: ray_set_pending 0x%0x\n", sc->unit, cmdf));
-
- sc->sc_scheduled |= cmdf;
- if (!sc->sc_timoneed) {
- RAY_DPRINTFN(20, ("ray%d: ray_set_pending new timo\n",
- sc->unit));
- sc->ccs_timerh = timeout(ray_check_scheduled, sc,
- RAY_CHECK_SCHED_TIMEOUT);
- sc->sc_timoneed = 1;
- }
-}
-
-/*
- * schedule the `cmdf' for completion later
- */
-static void
-ray_cmd_schedule(struct ray_softc *sc, int cmdf)
-{
- int track;
-
- RAY_DPRINTFN(5, ("ray%d: ray_cmd_schedule\n", sc->unit));
- RAY_MAP_CM(sc);
- RAY_DPRINTFN(20, ("ray%d: ray_cmd_schedule 0x%x\n", sc->unit, cmdf));
-
- track = cmdf;
- if ((cmdf & SCP_UPD_MASK) == 0)
- ray_set_pending(sc, track);
- else if (ray_cmd_is_running(sc, SCP_UPDATESUBCMD)) {
- /* don't do timeout mechaniscm if subcmd already going */
- sc->sc_scheduled |= cmdf;
- } else
- ray_set_pending(sc, cmdf | SCP_UPDATESUBCMD);
-}
-
-/*
- * check to see if `cmdf' has been scheduled
- */
-static int
-ray_cmd_is_scheduled(struct ray_softc *sc, int cmdf)
-{
- RAY_DPRINTFN(5, ("ray%d: ray_cmd_is_scheduled\n", sc->unit));
- RAY_MAP_CM(sc);
- RAY_DPRINTFN(20, ("ray%d: ray_cmd_is_scheduled 0x%x\n",
- sc->unit, cmdf));
-
- return ((sc->sc_scheduled & cmdf) ? 1 : 0);
-}
-
-/*
- * cancel a scheduled command (not a running one though!)
- */
-static void
-ray_cmd_cancel(struct ray_softc *sc, int cmdf)
-{
- RAY_DPRINTFN(5, ("ray%d: ray_cmd_cancel\n", sc->unit));
- RAY_MAP_CM(sc);
- RAY_DPRINTFN(20, ("ray%d: ray_cmd_cancel 0x%x\n", sc->unit, cmdf));
-
- sc->sc_scheduled &= ~cmdf;
- if ((cmdf & SCP_UPD_MASK) && (sc->sc_scheduled & SCP_UPD_MASK) == 0)
- sc->sc_scheduled &= ~SCP_UPDATESUBCMD;
-
- /* if nothing else needed cancel the timer */
- if (sc->sc_scheduled == 0 && sc->sc_timoneed) {
- untimeout(ray_check_scheduled, sc, sc->ccs_timerh);
- sc->sc_timoneed = 0;
- }
-}
-
-/*
- * called to indicate the 'cmdf' has been issued
- */
-static void
-ray_cmd_ran(struct ray_softc *sc, int cmdf)
-{
- RAY_DPRINTFN(5, ("ray%d: ray_cmd_ran\n", sc->unit));
- RAY_MAP_CM(sc);
- RAY_DPRINTFN(20, ("ray%d: ray_cmd_ran 0x%x\n", sc->unit, cmdf));
-
- if (cmdf & SCP_UPD_MASK)
- sc->sc_running |= cmdf | SCP_UPDATESUBCMD;
- else
- sc->sc_running |= cmdf;
-
- if ((cmdf & SCP_TIMOCHECK_CMD_MASK) && !sc->sc_timocheck) {
- sc->ccs_timerh = timeout(ray_check_ccs, sc, RAY_CCS_TIMEOUT);
- sc->sc_timocheck = 1;
- }
-}
-
-/*
- * check to see if `cmdf' has been issued
- */
-static int
-ray_cmd_is_running(struct ray_softc *sc, int cmdf)
-{
- RAY_DPRINTFN(5, ("ray%d: ray_cmd_is_running\n", sc->unit));
- RAY_MAP_CM(sc);
- RAY_DPRINTFN(20, ("ray%d: ray_cmd_is_running 0x%x\n", sc->unit, cmdf));
-
- return ((sc->sc_running & cmdf) ? 1 : 0);
-}
-
-/*
- * the given `cmdf' that was issued has completed
- */
-static void
-ray_cmd_done(struct ray_softc *sc, int cmdf)
-{
- RAY_DPRINTFN(5, ("ray%d: ray_cmd_done\n", sc->unit));
- RAY_MAP_CM(sc);
- RAY_DPRINTFN(20, ("ray%d: ray_cmd_done 0x%x\n", sc->unit, cmdf));
-
- sc->sc_running &= ~cmdf;
- if (cmdf & SCP_UPD_MASK) {
- sc->sc_running &= ~SCP_UPDATESUBCMD;
- if (sc->sc_scheduled & SCP_UPD_MASK)
- ray_cmd_schedule(sc, sc->sc_scheduled & SCP_UPD_MASK);
- }
- if ((sc->sc_running & SCP_TIMOCHECK_CMD_MASK) == 0 && sc->sc_timocheck){
- untimeout(ray_check_ccs, sc, sc->ccs_timerh);
- sc->sc_timocheck = 0;
- }
-}
-
-/*
- * issue the command
- * only used for commands not tx
- */
-static int
-ray_issue_cmd(struct ray_softc *sc, size_t ccs, u_int track)
-{
- u_int i;
-
- RAY_DPRINTFN(5, ("ray%d: ray_cmd_issue\n", sc->unit));
- RAY_MAP_CM(sc);
-
- /*
- * XXX other drivers did this, but I think
- * what we really want to do is just make sure we don't
- * get here or that spinning is ok
- */
- i = 0;
- while (!RAY_ECF_READY(sc))
- if (++i > 50) {
- printf("\n");
- (void)ray_free_ccs(sc, ccs);
- if (track)
- ray_cmd_schedule(sc, track);
- return (0);
- } else if (i == 1)
- printf("ray%d: ray_issue_cmd spinning", sc->unit);
- else
- printf(".");
-
- SRAM_WRITE_1(sc, RAY_SCB_CCSI, RAY_CCS_INDEX(ccs));
- RAY_ECF_START_CMD(sc);
- ray_cmd_ran(sc, track);
-
- return (1);
-}
-
-/*
- * send a simple command if we can
- */
-static int
-ray_simple_cmd(struct ray_softc *sc, u_int cmd, u_int track)
-{
- size_t ccs;
-
- RAY_DPRINTFN(5, ("ray%d: ray_simple_cmd\n", sc->unit));
- RAY_MAP_CM(sc);
-
- return (ray_alloc_ccs(sc, &ccs, cmd, track) &&
- ray_issue_cmd(sc, ccs, track));
-}
-
-/*
- * Functions based on CCS commands
- */
-
-/*
- * run a update subcommand
- */
-static void
-ray_update_subcmd(struct ray_softc *sc)
-{
- struct ifnet *ifp;
- int submask, i;
-
- RAY_DPRINTFN(5, ("ray%d: ray_update_subcmd\n", sc->unit));
- RAY_MAP_CM(sc);
-
- ray_cmd_cancel(sc, SCP_UPDATESUBCMD);
-
- ifp = &sc->arpcom.ac_if;
- if ((ifp->if_flags & IFF_RUNNING) == 0)
- return;
- submask = SCP_UPD_FIRST;
- for (i = 0; i < ray_nsubcmdtab; submask <<= 1, i++) {
- if ((sc->sc_scheduled & SCP_UPD_MASK) == 0)
- break;
- /* when done the next command will be scheduled */
- if (ray_cmd_is_running(sc, SCP_UPDATESUBCMD))
- break;
- if (!RAY_ECF_READY(sc))
- break;
- /*
- * give priority to LSB -- e.g., if previous loop reschuled
- * doing this command after calling the function won't catch
- * if a later command sets an earlier bit
- */
- if (sc->sc_scheduled & ((submask - 1) & SCP_UPD_MASK))
- break;
- if (sc->sc_scheduled & submask)
- (*ray_subcmdtab[i])(sc);
- }
-}
-
-/*
- * report a parameter
- */
-static void
-ray_report_params(struct ray_softc *sc)
-{
- struct ifnet *ifp;
- size_t ccs;
-
- RAY_DPRINTFN(5, ("ray%d: ray_report_params\n", sc->unit));
- RAY_MAP_CM(sc);
-
- ray_cmd_cancel(sc, SCP_REPORTPARAMS);
-
- ifp = &sc->arpcom.ac_if;
-
- if (!sc->sc_repreq)
- return;
-
- /* do the issue check before equality check */
- if ((ifp->if_flags & IFF_RUNNING) == 0)
- return;
- else if (ray_cmd_is_running(sc, SCP_REPORTPARAMS)) {
- ray_cmd_schedule(sc, SCP_REPORTPARAMS);
- return;
- } else if (!ray_alloc_ccs(sc, &ccs, RAY_CMD_REPORT_PARAMS,
- SCP_REPORTPARAMS))
- return;
-
- SRAM_WRITE_FIELD_1(sc, ccs, ray_cmd_report, c_paramid,
- sc->sc_repreq->r_paramid);
- SRAM_WRITE_FIELD_1(sc, ccs, ray_cmd_report, c_nparam, 1);
- (void)ray_issue_cmd(sc, ccs, SCP_REPORTPARAMS);
-}
-
-/*
- * start an association
- */
-static void
-ray_start_assoc(struct ray_softc *sc)
-{
- struct ifnet *ifp;
-
- RAY_DPRINTFN(5, ("ray%d: ray_start_assoc\n", sc->unit));
- RAY_MAP_CM(sc);
-
- ifp = &sc->arpcom.ac_if;
-
- ray_cmd_cancel(sc, SCP_STARTASSOC);
- if ((ifp->if_flags & IFF_RUNNING) == 0)
- return;
- else if (ray_cmd_is_running(sc, SCP_STARTASSOC))
- return;
- (void)ray_simple_cmd(sc, RAY_CMD_START_ASSOC, SCP_STARTASSOC);
-}
-
-/******************************************************************************
- * XXX NOT KNF FROM HERE DOWN *
- ******************************************************************************/
-/*
- * Subcommand functions that use the SCP_UPDATESUBCMD command
- * (and are serialized with respect to other update sub commands
- */
-
-/*
- * Download start up structures to card.
- *
- * Part of ray_init, download, startjoin control flow.
- */
-static void
-ray_download_params (sc)
- struct ray_softc *sc;
-{
- struct ray_mib_4 ray_mib_4_default;
- struct ray_mib_5 ray_mib_5_default;
-
- RAY_DPRINTFN(5, ("ray%d: Downloading startup parameters\n", sc->unit));
- RAY_MAP_CM(sc);
-
- ray_cmd_cancel(sc, SCP_UPD_STARTUP);
-
-#define MIB4(m) ray_mib_4_default.##m
-#define MIB5(m) ray_mib_5_default.##m
-#define PUT2(p, v) \
- do { (p)[0] = ((v >> 8) & 0xff); (p)[1] = (v & 0xff); } while(0)
-
- /*
- * Firmware version 4 defaults - see if_raymib.h for details
- */
- MIB4(mib_net_type) = sc->sc_d.np_net_type;
- MIB4(mib_ap_status) = sc->sc_d.np_ap_status;
- bcopy(sc->sc_d.np_ssid, MIB4(mib_ssid), IEEE80211_NWID_LEN);
- MIB4(mib_scan_mode) = RAY_MIB_SCAN_MODE_DEFAULT;
- MIB4(mib_apm_mode) = RAY_MIB_APM_MODE_DEFAULT;
- bcopy(sc->sc_station_addr, MIB4(mib_mac_addr), ETHER_ADDR_LEN);
-PUT2(MIB4(mib_frag_thresh), RAY_MIB_FRAG_THRESH_DEFAULT);
-PUT2(MIB4(mib_dwell_time), RAY_MIB_DWELL_TIME_V4);
-PUT2(MIB4(mib_beacon_period), RAY_MIB_BEACON_PERIOD_V4);
- MIB4(mib_dtim_interval) = RAY_MIB_DTIM_INTERVAL_DEFAULT;
- MIB4(mib_max_retry) = RAY_MIB_MAX_RETRY_DEFAULT;
- MIB4(mib_ack_timo) = RAY_MIB_ACK_TIMO_DEFAULT;
- MIB4(mib_sifs) = RAY_MIB_SIFS_DEFAULT;
- MIB4(mib_difs) = RAY_MIB_DIFS_DEFAULT;
- MIB4(mib_pifs) = RAY_MIB_PIFS_V4;
-PUT2(MIB4(mib_rts_thresh), RAY_MIB_RTS_THRESH_DEFAULT);
-PUT2(MIB4(mib_scan_dwell), RAY_MIB_SCAN_DWELL_V4);
-PUT2(MIB4(mib_scan_max_dwell), RAY_MIB_SCAN_MAX_DWELL_V4);
- MIB4(mib_assoc_timo) = RAY_MIB_ASSOC_TIMO_DEFAULT;
- MIB4(mib_adhoc_scan_cycle) = RAY_MIB_ADHOC_SCAN_CYCLE_DEFAULT;
- MIB4(mib_infra_scan_cycle) = RAY_MIB_INFRA_SCAN_CYCLE_DEFAULT;
- MIB4(mib_infra_super_scan_cycle) = RAY_MIB_INFRA_SUPER_SCAN_CYCLE_DEFAULT;
- MIB4(mib_promisc) = RAY_MIB_PROMISC_DEFAULT;
-PUT2(MIB4(mib_uniq_word), RAY_MIB_UNIQ_WORD_DEFAULT);
- MIB4(mib_slot_time) = RAY_MIB_SLOT_TIME_V4;
- MIB4(mib_roam_low_snr_thresh) = RAY_MIB_ROAM_LOW_SNR_THRESH_DEFAULT;
- MIB4(mib_low_snr_count) = RAY_MIB_LOW_SNR_COUNT_DEFAULT;
- MIB4(mib_infra_missed_beacon_count)= RAY_MIB_INFRA_MISSED_BEACON_COUNT_DEFAULT;
- MIB4(mib_adhoc_missed_beacon_count)= RAY_MIB_ADHOC_MISSED_BEACON_COUNT_DEFAULT;
- MIB4(mib_country_code) = RAY_MIB_COUNTRY_CODE_DEFAULT;
- MIB4(mib_hop_seq) = RAY_MIB_HOP_SEQ_DEFAULT;
- MIB4(mib_hop_seq_len) = RAY_MIB_HOP_SEQ_LEN_V4;
- MIB4(mib_cw_max) = RAY_MIB_CW_MAX_V4;
- MIB4(mib_cw_min) = RAY_MIB_CW_MIN_V4;
- MIB4(mib_noise_filter_gain) = RAY_MIB_NOISE_FILTER_GAIN_DEFAULT;
- MIB4(mib_noise_limit_offset) = RAY_MIB_NOISE_LIMIT_OFFSET_DEFAULT;
- MIB4(mib_rssi_thresh_offset) = RAY_MIB_RSSI_THRESH_OFFSET_DEFAULT;
- MIB4(mib_busy_thresh_offset) = RAY_MIB_BUSY_THRESH_OFFSET_DEFAULT;
- MIB4(mib_sync_thresh) = RAY_MIB_SYNC_THRESH_DEFAULT;
- MIB4(mib_test_mode) = RAY_MIB_TEST_MODE_DEFAULT;
- MIB4(mib_test_min_chan) = RAY_MIB_TEST_MIN_CHAN_DEFAULT;
- MIB4(mib_test_max_chan) = RAY_MIB_TEST_MAX_CHAN_DEFAULT;
-
- /*
- * Firmware version 5 defaults - see if_raymib.h for details
- */
- MIB5(mib_net_type) = sc->sc_d.np_net_type;
- MIB4(mib_ap_status) = sc->sc_d.np_ap_status;
- bcopy(sc->sc_d.np_ssid, MIB5(mib_ssid), IEEE80211_NWID_LEN);
- MIB5(mib_scan_mode) = RAY_MIB_SCAN_MODE_DEFAULT;
- MIB5(mib_apm_mode) = RAY_MIB_APM_MODE_DEFAULT;
- bcopy(sc->sc_station_addr, MIB5(mib_mac_addr), ETHER_ADDR_LEN);
-PUT2(MIB5(mib_frag_thresh), RAY_MIB_FRAG_THRESH_DEFAULT);
-PUT2(MIB5(mib_dwell_time), RAY_MIB_DWELL_TIME_V5);
-PUT2(MIB5(mib_beacon_period), RAY_MIB_BEACON_PERIOD_V5);
- MIB5(mib_dtim_interval) = RAY_MIB_DTIM_INTERVAL_DEFAULT;
- MIB5(mib_max_retry) = RAY_MIB_MAX_RETRY_DEFAULT;
- MIB5(mib_ack_timo) = RAY_MIB_ACK_TIMO_DEFAULT;
- MIB5(mib_sifs) = RAY_MIB_SIFS_DEFAULT;
- MIB5(mib_difs) = RAY_MIB_DIFS_DEFAULT;
- MIB5(mib_pifs) = RAY_MIB_PIFS_V5;
-PUT2(MIB5(mib_rts_thresh), RAY_MIB_RTS_THRESH_DEFAULT);
-PUT2(MIB5(mib_scan_dwell), RAY_MIB_SCAN_DWELL_V5);
-PUT2(MIB5(mib_scan_max_dwell), RAY_MIB_SCAN_MAX_DWELL_V5);
- MIB5(mib_assoc_timo) = RAY_MIB_ASSOC_TIMO_DEFAULT;
- MIB5(mib_adhoc_scan_cycle) = RAY_MIB_ADHOC_SCAN_CYCLE_DEFAULT;
- MIB5(mib_infra_scan_cycle) = RAY_MIB_INFRA_SCAN_CYCLE_DEFAULT;
- MIB5(mib_infra_super_scan_cycle) = RAY_MIB_INFRA_SUPER_SCAN_CYCLE_DEFAULT;
- MIB5(mib_promisc) = RAY_MIB_PROMISC_DEFAULT;
-PUT2(MIB5(mib_uniq_word), RAY_MIB_UNIQ_WORD_DEFAULT);
- MIB5(mib_slot_time) = RAY_MIB_SLOT_TIME_V5;
- MIB5(mib_roam_low_snr_thresh) = RAY_MIB_ROAM_LOW_SNR_THRESH_DEFAULT;
- MIB5(mib_low_snr_count) = RAY_MIB_LOW_SNR_COUNT_DEFAULT;
- MIB5(mib_infra_missed_beacon_count)= RAY_MIB_INFRA_MISSED_BEACON_COUNT_DEFAULT;
- MIB5(mib_adhoc_missed_beacon_count)= RAY_MIB_ADHOC_MISSED_BEACON_COUNT_DEFAULT;
- MIB5(mib_country_code) = RAY_MIB_COUNTRY_CODE_DEFAULT;
- MIB5(mib_hop_seq) = RAY_MIB_HOP_SEQ_DEFAULT;
- MIB5(mib_hop_seq_len) = RAY_MIB_HOP_SEQ_LEN_V5;
-PUT2(MIB5(mib_cw_max), RAY_MIB_CW_MAX_V5);
-PUT2(MIB5(mib_cw_min), RAY_MIB_CW_MIN_V5);
- MIB5(mib_noise_filter_gain) = RAY_MIB_NOISE_FILTER_GAIN_DEFAULT;
- MIB5(mib_noise_limit_offset) = RAY_MIB_NOISE_LIMIT_OFFSET_DEFAULT;
- MIB5(mib_rssi_thresh_offset) = RAY_MIB_RSSI_THRESH_OFFSET_DEFAULT;
- MIB5(mib_busy_thresh_offset) = RAY_MIB_BUSY_THRESH_OFFSET_DEFAULT;
- MIB5(mib_sync_thresh) = RAY_MIB_SYNC_THRESH_DEFAULT;
- MIB5(mib_test_mode) = RAY_MIB_TEST_MODE_DEFAULT;
- MIB5(mib_test_min_chan) = RAY_MIB_TEST_MIN_CHAN_DEFAULT;
- MIB5(mib_test_max_chan) = RAY_MIB_TEST_MAX_CHAN_DEFAULT;
- MIB5(mib_allow_probe_resp) = RAY_MIB_ALLOW_PROBE_RESP_DEFAULT;
- MIB5(mib_privacy_must_start) = RAY_MIB_PRIVACY_MUST_START_DEFAULT;
- MIB5(mib_privacy_can_join) = sc->sc_d.np_priv_start;
- MIB5(mib_basic_rate_set[0]) = sc->sc_d.np_priv_join;
-
- if (!RAY_ECF_READY(sc)) {
- printf("ray%d: ray_download_params something is already happening\n",
- sc->unit);
- ray_reset(sc);
- }
-
- if (sc->sc_version == RAY_ECFS_BUILD_4)
- ray_write_region(sc, RAY_HOST_TO_ECF_BASE,
- &ray_mib_4_default, sizeof(ray_mib_4_default));
- else
- ray_write_region(sc, RAY_HOST_TO_ECF_BASE,
- &ray_mib_5_default, sizeof(ray_mib_5_default));
-
- if (!ray_simple_cmd(sc, RAY_CMD_START_PARAMS, SCP_UPD_STARTUP))
- printf("ray%d: ray_download_params can't issue command\n", sc->unit);
-
- RAY_DPRINTFN(15, ("ray%d: Download now awaiting completion\n", sc->unit));
-
- return;
-}
-
-/*
- * Download completion routine.
- *
- * Part of ray_init, download, start_join control flow.
- *
- * As START_PARAMS is an update command ray_check_ccs has checked the
- * ccs status and re-scheduled timeouts if needed.
- */
-static void
-ray_download_done (sc)
- struct ray_softc *sc;
-{
-
- RAY_DPRINTFN(5, ("ray%d: ray_download_done\n", sc->unit));
- RAY_MAP_CM(sc);
-
- ray_cmd_done(sc, SCP_UPD_STARTUP);
-
- /*
- * Fake the current network parameter settings so start_join_net
- * will not bother updating them to the card (we would need to
- * zero these anyway, so we might as well copy).
- */
- sc->sc_c.np_net_type = sc->sc_d.np_net_type;
- bcopy(sc->sc_d.np_ssid, sc->sc_c.np_ssid, IEEE80211_NWID_LEN);
-
- ray_start_join_net(sc);
-}
-
-/*
- * start or join a network
- */
-static void
-ray_start_join_net(struct ray_softc *sc)
-{
- struct ray_net_params np;
- struct ifnet *ifp;
- size_t ccs;
- int cmd, update;
-
-
- RAY_DPRINTFN(5, ("ray%d: ray_start_join_net\n", sc->unit));
- RAY_MAP_CM(sc);
-
- ifp = &sc->arpcom.ac_if;
-
- ray_cmd_cancel(sc, SCP_UPD_STARTJOIN);
- if ((ifp->if_flags & IFF_RUNNING) == 0)
- return;
-
- /* XXX check we may not want to re-issue */
- if (ray_cmd_is_running(sc, SCP_UPDATESUBCMD)) {
- ray_cmd_schedule(sc, SCP_UPD_STARTJOIN);
- return;
- }
-
- if (sc->sc_d.np_net_type == RAY_MIB_NET_TYPE_ADHOC)
- cmd = RAY_CMD_START_NET;
- else
- cmd = RAY_CMD_JOIN_NET;
-
- if (!ray_alloc_ccs(sc, &ccs, cmd, SCP_UPD_STARTJOIN)) {
- printf("ray%d: ray_start_join_net can't get a CCS\n", sc->unit);
- ray_reset(sc);
- }
-
- update = 0;
- if (bcmp(sc->sc_c.np_ssid, sc->sc_d.np_ssid, IEEE80211_NWID_LEN))
- update++;
- if (sc->sc_c.np_net_type != sc->sc_d.np_net_type)
- update++;
-
- if (update) {
- sc->sc_havenet = 0;
-
- bzero(&np, sizeof(np));
- np.p_net_type = sc->sc_d.np_net_type;
- bcopy(sc->sc_d.np_ssid, np.p_ssid, IEEE80211_NWID_LEN);
- np.p_privacy_must_start = sc->sc_d.np_priv_start;
- np.p_privacy_can_join = sc->sc_d.np_priv_join;
-
- ray_write_region(sc, RAY_HOST_TO_ECF_BASE, &np, sizeof(np));
- SRAM_WRITE_FIELD_1(sc, ccs, ray_cmd_net, c_upd_param, 1);
- } else
- SRAM_WRITE_FIELD_1(sc, ccs, ray_cmd_net, c_upd_param, 0);
-
- RAY_DPRINTFN(15, ("ray%d: ray_start_join_net %s updating nw params\n",
- sc->unit, update?"is":"not"));
-
- if (!ray_issue_cmd(sc, ccs, SCP_UPD_STARTJOIN)) {
- printf("ray%d: ray_start_join_net can't issue cmd\n", sc->unit);
- ray_reset(sc);
- }
-
-#if RAY_NEED_STARTJOIN_TIMO
- sc->sj_timerh = timeout(ray_start_join_timo, sc, RAY_SJ_TIMEOUT);
-#endif /* RAY_NEED_STARTJOIN_TIMO */
-}
-
-#if RAY_NEED_STARTJOIN_TIMO
-/*
- * Back stop catcher for start_join command. The NetBSD driver
- * suggests that they need it to catch a bug in the firmware or the
- * parameters they use - they are not sure. I'll just panic as I seem
- * to get interrupts back fine and I have version 4 firmware.
- */
-static void
-ray_start_join_timo (xsc)
- void *xsc;
-{
- struct ray_softc *sc = xsc;
-
- RAY_DPRINTFN(5, ("ray%d: ray_start_join_timo\n", sc->unit));
- RAY_MAP_CM(sc);
-
- panic("ray%d: ray-start_join_timo occured\n", sc->unit);
-
- return;
-}
-#endif /* RAY_NEED_STARTJOIN_TIMO */
-
-/*
- * Complete start or join command.
- *
- * Part of ray_init, download, start_join control flow.
- */
-static void
-ray_start_join_done (sc, ccs, status)
- struct ray_softc *sc;
- size_t ccs;
- u_int8_t status;
-{
- struct ifnet *ifp;
- u_int8_t o_net_type;
-
- RAY_DPRINTFN(5, ("ray%d: ray_start_join_done\n", sc->unit));
- RAY_MAP_CM(sc);
-
- ifp = &sc->arpcom.ac_if;
-
-#if RAY_NEED_STARTJOIN_TIMO
- untimeout(ray_start_join_timo, sc, sc->sj_timerh);
-#endif /* RAY_NEED_STARTJOIN_TIMO */
-
- ray_cmd_done(sc, SCP_UPD_STARTJOIN);
-
- /*
- * XXX This switch and the following test are badly done. I
- * XXX need to take remedial action in each case branch and
- * XXX return from there. Then remove the test.
- * XXX FAIL comment
- * XXX if we fired the start command we successfully set the card up
- * XXX so just restart ray_start_join sequence and dont reset the card
- * XXX may need to split download_done for this
- * XXX FREE
- * XXX not sure
- * XXX BUSY
- * XXX maybe timeout but why would we get an interrupt when
- * XXX the card is not finished?
- */
- switch (status) {
-
- case RAY_CCS_STATUS_FREE:
- case RAY_CCS_STATUS_BUSY:
- printf("ray%d: ray_start_join_done status is FREE/BUSY - why?\n",
- sc->unit);
- break;
-
- case RAY_CCS_STATUS_COMPLETE:
- break;
-
- case RAY_CCS_STATUS_FAIL:
- printf("ray%d: ray_start_join_done status is FAIL - why?\n",
- sc->unit);
- sc->sc_havenet = 0;
- break;
-
- default:
- printf("ray%d: ray_start_join_done unknown status 0x%x\n",
- sc->unit, status);
- break;
- }
- if (status != RAY_CCS_STATUS_COMPLETE)
- return;
-
- /*
- * If the command completed correctly, get a few network parameters
- * from the ccs and active the network.
- */
- ray_read_region(sc, ccs, &sc->sc_c.p_1, sizeof(struct ray_cmd_net));
-
- /* adjust values for buggy build 4 */
- if (sc->sc_c.np_def_txrate == 0x55)
- sc->sc_c.np_def_txrate = sc->sc_d.np_def_txrate;
- if (sc->sc_c.np_encrypt == 0x55)
- sc->sc_c.np_encrypt = sc->sc_d.np_encrypt;
-
- /* card is telling us to update the network parameters */
- if (sc->sc_c.np_upd_param) {
- RAY_DPRINTFN(1, ("ray%d: sj_done card updating parameters - why?\n",
- sc->unit));
- o_net_type = sc->sc_c.np_net_type; /* XXX this may be wrong? */
- ray_read_region(sc, RAY_HOST_TO_ECF_BASE,
- &sc->sc_c.p_2, sizeof(struct ray_net_params));
- if (sc->sc_c.np_net_type != o_net_type) {
- printf("ray%d: sj_done card changing network type - why?\n",
- sc->unit);
-#if XXX
- restart ray_start_join sequence
- may need to split download_done for this
-#endif
- }
- }
- RAY_DNET_DUMP(sc, " after start/join network completed.");
-
- /*
- * Hurrah! The network is now active.
- *
- * Clearing IFF_OACTIVE will ensure that the system will queue packets.
- * Just before we return from the interrupt context we check to
- * see if packets have been queued.
- */
- ray_cmd_schedule(sc, SCP_UPD_MCAST|SCP_UPD_PROMISC);
-
- if (SRAM_READ_FIELD_1(sc, ccs, ray_cmd, c_cmd) == RAY_CMD_JOIN_NET)
- ray_start_assoc(sc);
- else {
- sc->sc_havenet = 1;
- ifp->if_flags &= ~IFF_OACTIVE;
- }
-
- return;
-}
-
-/******************************************************************************
- * XXX NOT KNF FROM HERE UP
- ******************************************************************************/
-
-/*
- * set the card in/out of promiscuous mode
- */
-static void
-ray_update_promisc(struct ray_softc *sc)
-{
- struct ifnet *ifp;
- size_t ccs;
- int promisc;
-
- RAY_DPRINTFN(5, ("ray%d: ray_update_promisc\n", sc->unit));
- RAY_MAP_CM(sc);
-
- ifp = &sc->arpcom.ac_if;
- ray_cmd_cancel(sc, SCP_UPD_PROMISC);
-
- /* do the issue check before equality check */
- promisc = !!(ifp->if_flags & (IFF_PROMISC | IFF_ALLMULTI));
- if ((ifp->if_flags & IFF_RUNNING) == 0)
- return;
- else if (ray_cmd_is_running(sc, SCP_UPDATESUBCMD)) {
- ray_cmd_schedule(sc, SCP_UPD_PROMISC);
- return;
- } else if (promisc == sc->sc_promisc)
- return;
- else if (!ray_alloc_ccs(sc,&ccs,RAY_CMD_UPDATE_PARAMS, SCP_UPD_PROMISC))
- return;
- SRAM_WRITE_FIELD_1(sc, ccs, ray_cmd_update, c_paramid, RAY_MIB_PROMISC);
- SRAM_WRITE_FIELD_1(sc, ccs, ray_cmd_update, c_nparam, 1);
- SRAM_WRITE_1(sc, RAY_HOST_TO_ECF_BASE, promisc);
- (void)ray_issue_cmd(sc, ccs, SCP_UPD_PROMISC);
-}
-
-/*
- * update the parameter based on what the user passed in
- */
-static void
-ray_update_params(struct ray_softc *sc)
-{
- struct ifnet *ifp;
- size_t ccs;
-
- RAY_DPRINTFN(5, ("ray%d: ray_update_params\n", sc->unit));
- RAY_MAP_CM(sc);
-
- ifp = &sc->arpcom.ac_if;
-
- ray_cmd_cancel(sc, SCP_UPD_UPDATEPARAMS);
- if (!sc->sc_updreq) {
- /* XXX do we need to wakeup here? */
- return;
- }
-
- /* do the issue check before equality check */
- if ((ifp->if_flags & IFF_RUNNING) == 0)
- return;
- else if (ray_cmd_is_running(sc, SCP_UPDATESUBCMD)) {
- ray_cmd_schedule(sc, SCP_UPD_UPDATEPARAMS);
- return;
- } else if (!ray_alloc_ccs(sc, &ccs, RAY_CMD_UPDATE_PARAMS,
- SCP_UPD_UPDATEPARAMS))
- return;
-
- SRAM_WRITE_FIELD_1(sc, ccs, ray_cmd_update, c_paramid,
- sc->sc_updreq->r_paramid);
- SRAM_WRITE_FIELD_1(sc, ccs, ray_cmd_update, c_nparam, 1);
- ray_write_region(sc, RAY_HOST_TO_ECF_BASE, sc->sc_updreq->r_data,
- sc->sc_updreq->r_len);
-
- (void)ray_issue_cmd(sc, ccs, SCP_UPD_UPDATEPARAMS);
-}
-
-/*
- * set the multicast filter list
- */
-static void
-ray_update_mcast(struct ray_softc *sc)
-{
- struct ifnet *ifp;
- struct ifmultiaddr *ifma;
- size_t ccs, bufp;
- int count;
-
- RAY_DPRINTFN(5, ("ray%d: ray_update_mcast\n", sc->unit));
- RAY_MAP_CM(sc);
-
- ifp = &sc->arpcom.ac_if;
-
- ray_cmd_cancel(sc, SCP_UPD_MCAST);
-
- for (ifma = ifp->if_multiaddrs.lh_first, count = 0; ifma != NULL;
- ifma = ifma->ifma_link.le_next, count++)
-
- /* track this stuff even when not running */
- if (count > 16) {
- ifp->if_flags |= IFF_ALLMULTI;
- ray_update_promisc(sc);
- return;
- } else if (ifp->if_flags & IFF_ALLMULTI) {
- ifp->if_flags &= ~IFF_ALLMULTI;
- ray_update_promisc(sc);
- }
-
- if ((ifp->if_flags & IFF_RUNNING) == 0)
- return;
- else if (ray_cmd_is_running(sc, SCP_UPDATESUBCMD)) {
- ray_cmd_schedule(sc, SCP_UPD_MCAST);
- return;
- } else if (!ray_alloc_ccs(sc,&ccs, RAY_CMD_UPDATE_MCAST, SCP_UPD_MCAST))
- return;
- SRAM_WRITE_FIELD_1(sc, ccs, ray_cmd_update_mcast, c_nmcast, count);
- bufp = RAY_HOST_TO_ECF_BASE;
- for (ifma = ifp->if_multiaddrs.lh_first; ifma != NULL;
- ifma = ifma->ifma_link.le_next) {
- ray_write_region(
- sc,
- bufp,
- LLADDR((struct sockaddr_dl *)ifma->ifma_addr),
- ETHER_ADDR_LEN
- );
- bufp += ETHER_ADDR_LEN;
- }
- (void)ray_issue_cmd(sc, ccs, SCP_UPD_MCAST);
-}
-
-/*
- * User issued commands
- */
-
-/*
- * issue a update params
- *
- * expected to be called in sleapable context -- intended for user stuff
- */
-static int
-ray_user_update_params(struct ray_softc *sc, struct ray_param_req *pr)
-{
- struct ifnet *ifp;
- int rv;
-
- RAY_DPRINTFN(5, ("ray%d: ray_user_update_params\n", sc->unit));
- RAY_MAP_CM(sc);
-
- ifp = &sc->arpcom.ac_if;
-
- if ((ifp->if_flags & IFF_RUNNING) == 0) {
- pr->r_failcause = RAY_FAILCAUSE_EDEVSTOP;
- return (EIO);
- }
-
- /* wait to be able to issue the command */
- rv = 0;
- while (ray_cmd_is_running(sc, SCP_UPD_UPDATEPARAMS) ||
- ray_cmd_is_scheduled(sc, SCP_UPD_UPDATEPARAMS)) {
- rv = tsleep(ray_update_params, 0|PCATCH, "cmd in use", 0);
- if (rv)
- return (rv);
- if ((ifp->if_flags & IFF_RUNNING) == 0) {
- pr->r_failcause = RAY_FAILCAUSE_EDEVSTOP;
- return (EIO);
- }
- }
-
- pr->r_failcause = RAY_FAILCAUSE_WAITING;
- sc->sc_updreq = pr;
- ray_cmd_schedule(sc, SCP_UPD_UPDATEPARAMS);
- ray_check_scheduled(sc);
-
- while (pr->r_failcause == RAY_FAILCAUSE_WAITING)
- (void)tsleep(ray_update_params, 0, "waiting cmd", 0);
- wakeup(ray_update_params);
-
- return (0);
-}
-
-/*
- * issue a report params
- *
- * expected to be called in sleapable context -- intended for user stuff
- */
-static int
-ray_user_report_params(struct ray_softc *sc, struct ray_param_req *pr)
-{
- struct ifnet *ifp;
- int rv;
-
- RAY_DPRINTFN(5, ("ray%d: ray_user_report_params\n", sc->unit));
- RAY_MAP_CM(sc);
-
- ifp = &sc->arpcom.ac_if;
-
- if ((ifp->if_flags & IFF_RUNNING) == 0) {
- pr->r_failcause = RAY_FAILCAUSE_EDEVSTOP;
- return (EIO);
- }
-
- /* wait to be able to issue the command */
- rv = 0;
- while (ray_cmd_is_running(sc, SCP_REPORTPARAMS)
- || ray_cmd_is_scheduled(sc, SCP_REPORTPARAMS)) {
- rv = tsleep(ray_report_params, 0|PCATCH, "cmd in use", 0);
- if (rv)
- return (rv);
- if ((ifp->if_flags & IFF_RUNNING) == 0) {
- pr->r_failcause = RAY_FAILCAUSE_EDEVSTOP;
- return (EIO);
- }
- }
-
- pr->r_failcause = RAY_FAILCAUSE_WAITING;
- sc->sc_repreq = pr;
- ray_cmd_schedule(sc, SCP_REPORTPARAMS);
- ray_check_scheduled(sc);
-
- while (pr->r_failcause == RAY_FAILCAUSE_WAITING)
- (void)tsleep(ray_report_params, 0, "waiting cmd", 0);
- wakeup(ray_report_params);
-
- return (0);
-}
-
-/*
- * return the error counters
- */
-static int
-ray_user_report_stats(struct ray_softc *sc, struct ray_stats_req *sr)
-{
- struct ifnet *ifp;
-
- RAY_DPRINTFN(5, ("ray%d: ray_user_report_stats\n", sc->unit));
- RAY_MAP_CM(sc);
-
- ifp = &sc->arpcom.ac_if;
-
- if ((ifp->if_flags & IFF_RUNNING) == 0) {
- return (EIO);
- }
-
- sr->rxoverflow = sc->sc_rxoverflow;
- sr->rxcksum = sc->sc_rxcksum;
- sr->rxhcksum = sc->sc_rxhcksum;
- sr->rxnoise = sc->sc_rxnoise;
-
- return(0);
-}
-/******************************************************************************
- * XXX NOT KNF FROM HERE DOWN
- ******************************************************************************/
-
-/*
- * Routines to read from/write to the attribute memory.
- *
- * Taken from if_xe.c.
- *
- * Until there is a real way of accessing the attribute memory from a driver
- * these have to stay.
- *
- * The hack to use the crdread/crdwrite device functions causes the attribute
- * memory to be remapped into the controller and looses the mapping of
- * the common memory.
- *
- * We cheat by using PIOCSMEM and assume that the common memory window
- * is in window 0 of the card structure.
- *
- * Also
- * pccard/pcic.c/crdread does mark the unmapped window as inactive
- * pccard/pccard.c/map_mem toggles the mapping of a window on
- * successive calls
- *
- */
-#if (RAY_NEED_CM_REMAPPING | RAY_NEED_CM_FIXUP)
-static void
-ray_attr_getmap (struct ray_softc *sc)
-{
- struct ucred uc;
- struct pcred pc;
- struct proc p;
- int result;
-
- RAY_DPRINTFN(5, ("ray%d: attempting to get map for common memory\n",
- sc->unit));
-
- sc->md.window = 0;
-
- p.p_cred = &pc;
- p.p_cred->pc_ucred = &uc;
- p.p_cred->pc_ucred->cr_uid = 0;
-
- result = cdevsw[CARD_MAJOR]->d_ioctl(makedev(CARD_MAJOR, sc->slotnum), PIOCGMEM, (caddr_t)&sc->md, 0, &p);
-
- return;
-}
-
-static void
-ray_attr_cm (struct ray_softc *sc)
-{
- struct ucred uc;
- struct pcred pc;
- struct proc p;
-
- RAY_DPRINTFN(100, ("ray%d: attempting to remap common memory\n", sc->unit));
-
- p.p_cred = &pc;
- p.p_cred->pc_ucred = &uc;
- p.p_cred->pc_ucred->cr_uid = 0;
-
- cdevsw[CARD_MAJOR]->d_ioctl(makedev(CARD_MAJOR, sc->slotnum), PIOCSMEM, (caddr_t)&sc->md, 0, &p);
-
- return;
-}
-#endif /* (RAY_NEED_CM_REMAPPING | RAY_NEED_CM_FIXUP) */
-
-static int
-ray_attr_write (struct ray_softc *sc, off_t offset, u_int8_t byte)
-{
- struct iovec iov;
- struct uio uios;
- int err;
-
- iov.iov_base = &byte;
- iov.iov_len = sizeof(byte);
-
- uios.uio_iov = &iov;
- uios.uio_iovcnt = 1;
- uios.uio_offset = offset;
- uios.uio_resid = sizeof(byte);
- uios.uio_segflg = UIO_SYSSPACE;
- uios.uio_rw = UIO_WRITE;
- uios.uio_procp = 0;
-
- err = cdevsw[CARD_MAJOR]->d_write(makedev(CARD_MAJOR, sc->slotnum), &uios, 0);
-
-#if RAY_NEED_CM_REMAPPING
- ray_attr_cm(sc);
-#endif /* RAY_NEED_CM_REMAPPING */
-
- return (err);
-}
-
-static int
-ray_attr_read (struct ray_softc *sc, off_t offset, u_int8_t *buf, int size)
-{
- struct iovec iov;
- struct uio uios;
- int err;
-
- iov.iov_base = buf;
- iov.iov_len = size;
-
- uios.uio_iov = &iov;
- uios.uio_iovcnt = 1;
- uios.uio_offset = offset;
- uios.uio_resid = size;
- uios.uio_segflg = UIO_SYSSPACE;
- uios.uio_rw = UIO_READ;
- uios.uio_procp = 0;
-
- err = cdevsw[CARD_MAJOR]->d_read(makedev(CARD_MAJOR, sc->slotnum), &uios, 0);
-
-#if RAY_NEED_CM_REMAPPING
- ray_attr_cm(sc);
-#endif /* RAY_NEED_CM_REMAPPING */
-
- return (err);
-}
-
-static u_int8_t
-ray_read_reg (sc, reg)
- struct ray_softc *sc;
- off_t reg;
-{
- u_int8_t byte;
-
- ray_attr_read(sc, reg, &byte, 1);
-
- return (byte);
-}
-
-#if RAY_DEBUG > 50
-static void
-ray_dump_mbuf(sc, m, s)
- struct ray_softc *sc;
- struct mbuf *m;
- char *s;
-{
- u_int8_t *d, *ed;
- u_int i;
- char p[17];
-
- printf("ray%d: %s mbuf dump:", sc->unit, s);
- i = 0;
- bzero(p, 17);
- for (; m; m = m->m_next) {
- d = mtod(m, u_int8_t *);
- ed = d + m->m_len;
-
- for (; d < ed; i++, d++) {
- if ((i % 16) == 0) {
- printf(" %s\n\t", p);
- } else if ((i % 8) == 0)
- printf(" ");
- printf(" %02x", *d);
- p[i % 16] = ((*d >= 0x20) && (*d < 0x80)) ? *d : '.';
- }
- }
- if ((i - 1) % 16)
- printf("%s\n", p);
-}
-#endif /* RAY_DEBUG > 50 */
-
-
-#endif /* NRAY */ \ No newline at end of file
diff --git a/sys/dev/ray/if_raymib.h b/sys/dev/ray/if_raymib.h
deleted file mode 100644
index b7e5b8968293..000000000000
--- a/sys/dev/ray/if_raymib.h
+++ /dev/null
@@ -1,673 +0,0 @@
-/*
- * Copyright (C) 2000
- * Dr. Duncan McLennan Barclay, dmlb@ragnet.demon.co.uk.
- *
- * 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 author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY DUNCAN BARCLAY 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 DUNCAN BARCLAY 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.
- *
- * $Id: if_raymib.h,v 1.1 2000/02/27 19:47:06 dmlb Exp $
- *
- */
-
-struct ray_mib_common_head { /*Offset*/ /*Size*/
- u_int8_t mib_net_type; /*00*/
- u_int8_t mib_ap_status; /*01*/
- u_int8_t mib_ssid[IEEE80211_NWID_LEN]; /*02*/ /*20*/
- u_int8_t mib_scan_mode; /*22*/
- u_int8_t mib_apm_mode; /*23*/
- u_int8_t mib_mac_addr[ETHER_ADDR_LEN]; /*24*/ /*06*/
- u_int8_t mib_frag_thresh[2]; /*2a*/ /*02*/
- u_int8_t mib_dwell_time[2]; /*2c*/ /*02*/
- u_int8_t mib_beacon_period[2]; /*2e*/ /*02*/
- u_int8_t mib_dtim_interval; /*30*/
- u_int8_t mib_max_retry; /*31*/
- u_int8_t mib_ack_timo; /*32*/
- u_int8_t mib_sifs; /*33*/
- u_int8_t mib_difs; /*34*/
- u_int8_t mib_pifs; /*35*/
- u_int8_t mib_rts_thresh[2]; /*36*/ /*02*/
- u_int8_t mib_scan_dwell[2]; /*38*/ /*02*/
- u_int8_t mib_scan_max_dwell[2]; /*3a*/ /*02*/
- u_int8_t mib_assoc_timo; /*3c*/
- u_int8_t mib_adhoc_scan_cycle; /*3d*/
- u_int8_t mib_infra_scan_cycle; /*3e*/
- u_int8_t mib_infra_super_scan_cycle; /*3f*/
- u_int8_t mib_promisc; /*40*/
- u_int8_t mib_uniq_word[2]; /*41*/ /*02*/
- u_int8_t mib_slot_time; /*43*/
- u_int8_t mib_roam_low_snr_thresh; /*44*/
- u_int8_t mib_low_snr_count; /*45*/
- u_int8_t mib_infra_missed_beacon_count; /*46*/
- u_int8_t mib_adhoc_missed_beacon_count; /*47*/
- u_int8_t mib_country_code; /*48*/
- u_int8_t mib_hop_seq; /*49*/
- u_int8_t mib_hop_seq_len; /*4a*/
-} __attribute__((__packed__));
-
-struct ray_mib_common_tail {
- u_int8_t mib_noise_filter_gain; /*00*/
- u_int8_t mib_noise_limit_offset; /*01*/
- u_int8_t mib_rssi_thresh_offset; /*02*/
- u_int8_t mib_busy_thresh_offset; /*03*/
- u_int8_t mib_sync_thresh; /*04*/
- u_int8_t mib_test_mode; /*05*/
- u_int8_t mib_test_min_chan; /*06*/
- u_int8_t mib_test_max_chan; /*07*/
-} __attribute__((__packed__));
-
-struct ray_mib_4 {
- struct ray_mib_common_head mib_head; /*00*/
- u_int8_t mib_cw_max; /*4b*/
- u_int8_t mib_cw_min; /*4c*/
- struct ray_mib_common_tail mib_tail; /*4d*/
-} __attribute__((__packed__));
-
-struct ray_mib_5 {
- struct ray_mib_common_head mib_head; /*00*/
- u_int8_t mib_cw_max[2]; /*4b*/ /*02*/
- u_int8_t mib_cw_min[2]; /*4d*/ /*02*/
- struct ray_mib_common_tail mib_tail; /*4f*/
- u_int8_t mib_allow_probe_resp; /*57*/
- u_int8_t mib_privacy_must_start; /*58*/
- u_int8_t mib_privacy_can_join; /*59*/
- u_int8_t mib_basic_rate_set[8]; /*5a*/ /*08*/
-} __attribute__((__packed__));
-
-#define mib_net_type mib_head.mib_net_type
-#define mib_ap_status mib_head.mib_ap_status
-#define mib_ssid mib_head.mib_ssid
-#define mib_scan_mode mib_head.mib_scan_mode
-#define mib_apm_mode mib_head.mib_apm_mode
-#define mib_mac_addr mib_head.mib_mac_addr
-#define mib_frag_thresh mib_head.mib_frag_thresh
-#define mib_dwell_time mib_head.mib_dwell_time
-#define mib_beacon_period mib_head.mib_beacon_period
-#define mib_dtim_interval mib_head.mib_dtim_interval
-#define mib_max_retry mib_head.mib_max_retry
-#define mib_ack_timo mib_head.mib_ack_timo
-#define mib_sifs mib_head.mib_sifs
-#define mib_difs mib_head.mib_difs
-#define mib_pifs mib_head.mib_pifs
-#define mib_rts_thresh mib_head.mib_rts_thresh
-#define mib_scan_dwell mib_head.mib_scan_dwell
-#define mib_scan_max_dwell mib_head.mib_scan_max_dwell
-#define mib_assoc_timo mib_head.mib_assoc_timo
-#define mib_adhoc_scan_cycle mib_head.mib_adhoc_scan_cycle
-#define mib_infra_scan_cycle mib_head.mib_infra_scan_cycle
-#define mib_infra_super_scan_cycle \
- mib_head.mib_infra_super_scan_cycle
-#define mib_promisc mib_head.mib_promisc
-#define mib_uniq_word mib_head.mib_uniq_word
-#define mib_slot_time mib_head.mib_slot_time
-#define mib_roam_low_snr_thresh mib_head.mib_roam_low_snr_thresh
-#define mib_low_snr_count mib_head.mib_low_snr_count
-#define mib_infra_missed_beacon_count \
- mib_head.mib_infra_missed_beacon_count
-#define mib_adhoc_missed_beacon_count \
- mib_head.mib_adhoc_missed_beacon_count
-#define mib_country_code mib_head.mib_country_code
-#define mib_hop_seq mib_head.mib_hop_seq
-#define mib_hop_seq_len mib_head.mib_hop_seq_len
-
-#define mib_noise_filter_gain mib_tail.mib_noise_filter_gain
-#define mib_noise_limit_offset mib_tail.mib_noise_limit_offset
-#define mib_rssi_thresh_offset mib_tail.mib_rssi_thresh_offset
-#define mib_busy_thresh_offset mib_tail.mib_busy_thresh_offset
-#define mib_sync_thresh mib_tail.mib_sync_thresh
-#define mib_test_mode mib_tail.mib_test_mode
-#define mib_test_min_chan mib_tail.mib_test_min_chan
-#define mib_test_max_chan mib_tail.mib_test_max_chan
-
-/*
- * IOCTL support
- */
-struct ray_param_req {
- int r_failcause;
- u_int8_t r_paramid;
- u_int8_t r_len;
- u_int8_t r_data[256];
-};
-struct ray_stats_req {
- u_int64_t rxoverflow; /* Number of rx overflows */
- u_int64_t rxcksum; /* Number of checksum errors */
- u_int64_t rxhcksum; /* Number of header checksum errors */
- u_int8_t rxnoise; /* Average receiver level */
-};
-#define RAY_FAILCAUSE_EIDRANGE 1
-#define RAY_FAILCAUSE_ELENGTH 2
-/* device can possibly return up to 255 */
-#define RAY_FAILCAUSE_EDEVSTOP 256
-
-#ifdef KERNEL
-#define RAY_FAILCAUSE_WAITING 257
-#endif
-
-/* Get a param the data is a ray_param_req structure */
-#define SIOCSRAYPARAM SIOCSIFGENERIC
-#define SIOCGRAYPARAM SIOCGIFGENERIC
-/* Get the error counters the data is a ray_stats_req structure */
-#define SIOCGRAYSTATS _IOWR('i', 59, struct ifreq)
-
-/*
- * MIB IDs for the update/report param commands
- */
-#define RAY_MIB_NET_TYPE 0
-#define RAY_MIB_AP_STATUS 1
-#define RAY_MIB_SSID 2
-#define RAY_MIB_SCAN_MODE 3
-#define RAY_MIB_APM_MODE 4
-#define RAY_MIB_MAC_ADDR 5
-#define RAY_MIB_FRAG_THRESH 6
-#define RAY_MIB_DWELL_TIME 7
-#define RAY_MIB_BEACON_PERIOD 8
-#define RAY_MIB_DTIM_INTERVAL 9
-#define RAY_MIB_MAX_RETRY 10
-#define RAY_MIB_ACK_TIMO 11
-#define RAY_MIB_SIFS 12
-#define RAY_MIB_DIFS 13
-#define RAY_MIB_PIFS 14
-#define RAY_MIB_RTS_THRESH 15
-#define RAY_MIB_SCAN_DWELL 16
-#define RAY_MIB_SCAN_MAX_DWELL 17
-#define RAY_MIB_ASSOC_TIMO 18
-#define RAY_MIB_ADHOC_SCAN_CYCLE 19
-#define RAY_MIB_INFRA_SCAN_CYCLE 20
-#define RAY_MIB_INFRA_SUPER_SCAN_CYCLE 21
-#define RAY_MIB_PROMISC 22
-#define RAY_MIB_UNIQ_WORD 23
-#define RAY_MIB_SLOT_TIME 24
-#define RAY_MIB_ROAM_LOW_SNR_THRESH 25
-#define RAY_MIB_LOW_SNR_COUNT 26
-#define RAY_MIB_INFRA_MISSED_BEACON_COUNT 27
-#define RAY_MIB_ADHOC_MISSED_BEACON_COUNT 28
-#define RAY_MIB_COUNTRY_CODE 29
-#define RAY_MIB_HOP_SEQ 30
-#define RAY_MIB_HOP_SEQ_LEN 31
-#define RAY_MIB_CW_MAX 32
-#define RAY_MIB_CW_MIN 33
-#define RAY_MIB_NOISE_FILTER_GAIN 34
-#define RAY_MIB_NOISE_LIMIT_OFFSET 35
-#define RAY_MIB_RSSI_THRESH_OFFSET 36
-#define RAY_MIB_BUSY_THRESH_OFFSET 37
-#define RAY_MIB_SYNC_THRESH 38
-#define RAY_MIB_TEST_MODE 39
-#define RAY_MIB_TEST_MIN_CHAN 40
-#define RAY_MIB_TEST_MAX_CHAN 41
-#define RAY_MIB_ALLOW_PROBE_RESP 42
-#define RAY_MIB_PRIVACY_MUST_START 43
-#define RAY_MIB_PRIVACY_CAN_JOIN 44
-#define RAY_MIB_BASIC_RATE_SET 45
-#define RAY_MIB_MAX 46
-
-/*
- * Strings for the MIB
- */
-#define RAY_MIB_STRINGS { \
- "NET_TYPE", \
- "AP_STATUS", \
- "SSID", \
- "SCAN_MODE", \
- "APM_MODE", \
- "MAC_ADDR", \
- "FRAG_THRESH", \
- "DWELL_TIME", \
- "BEACON_PERIOD", \
- "DTIM_INTERVAL", \
- "MAX_RETRY", \
- "ACK_TIMO", \
- "SIFS", \
- "DIFS", \
- "PIFS", \
- "RTS_THRESH", \
- "SCAN_DWELL", \
- "SCAN_MAX_DWELL", \
- "ASSOC_TIMO", \
- "ADHOC_SCAN_CYCLE", \
- "INFRA_SCAN_CYCLE", \
- "INFRA_SUPER_SCAN_CYCLE", \
- "PROMISC", \
- "UNIQ_WORD", \
- "SLOT_TIME", \
- "ROAM_LOW_SNR_THRESH", \
- "LOW_SNR_COUNT", \
- "INFRA_MISSED_BEACON_COUNT", \
- "ADHOC_MISSED_BEACON_COUNT", \
- "COUNTRY_CODE", \
- "HOP_SEQ", \
- "HOP_SEQ_LEN", \
- "CW_MAX", \
- "CW_MIN", \
- "NOISE_FILTER_GAIN", \
- "NOISE_LIMIT_OFFSET", \
- "RSSI_THRESH_OFFSET", \
- "BUSY_THRESH_OFFSET", \
- "SYNC_THRESH", \
- "TEST_MODE", \
- "TEST_MIN_CHAN", \
- "TEST_MAX_CHAN", \
- "ALLOW_PROBE_RESP", \
- "PRIVACY_MUST_START", \
- "PRIVACY_CAN_JOIN", \
- "BASIC_RATE_SET" \
-}
-
-/*
- * Sizes for each MIB element
- */
-#define RAY_MIB_SIZES { \
- 1, /* RAY_MIB_NET_TYPE */ \
- 1, /* RAY_MIB_AP_STATUS */ \
- IEEE80211_NWID_LEN, /* RAY_MIB_SSID */ \
- 1, /* RAY_MIB_SCAN_MODE */ \
- 1, /* RAY_MIB_APM_MODE */ \
- ETHER_ADDR_LEN,/* RAY_MIB_MAC_ADDR */ \
- 2, /* RAY_MIB_FRAG_THRESH */ \
- 2, /* RAY_MIB_DWELL_TIME */ \
- 2, /* RAY_MIB_BEACON_PERIOD */ \
- 1, /* RAY_MIB_DTIM_INTERVAL */ \
- 1, /* RAY_MIB_MAX_RETRY */ \
- 1, /* RAY_MIB_ACK_TIMO */ \
- 1, /* RAY_MIB_SIFS */ \
- 1, /* RAY_MIB_DIFS */ \
- 1, /* RAY_MIB_PIFS */ \
- 2, /* RAY_MIB_RTS_THRESH */ \
- 2, /* RAY_MIB_SCAN_DWELL */ \
- 2, /* RAY_MIB_SCAN_MAX_DWELL */ \
- 1, /* RAY_MIB_ASSOC_TIMO */ \
- 1, /* RAY_MIB_ADHOC_SCAN_CYCLE */ \
- 1, /* RAY_MIB_INFRA_SCAN_CYCLE */ \
- 1, /* RAY_MIB_INFRA_SUPER_SCAN_CYCLE */ \
- 1, /* RAY_MIB_PROMISC */ \
- 2, /* RAY_MIB_UNIQ_WORD */ \
- 1, /* RAY_MIB_SLOT_TIME */ \
- 1, /* RAY_MIB_ROAM_LOW_SNR_THRESH */ \
- 1, /* RAY_MIB_LOW_SNR_COUNT */ \
- 1, /* RAY_MIB_INFRA_MISSED_BEACON_COUNT */ \
- 1, /* RAY_MIB_ADHOC_MISSED_BEACON_COUNT */ \
- 1, /* RAY_MIB_COUNTRY_CODE */ \
- 1, /* RAY_MIB_HOP_SEQ */ \
- 1, /* RAY_MIB_HOP_SEQ_LEN */ \
- 2, /* RAY_MIB_CW_MAX */ \
- 2, /* RAY_MIB_CW_MIN */ \
- 1, /* RAY_MIB_NOISE_FILTER_GAIN */ \
- 1, /* RAY_MIB_NOISE_LIMIT_OFFSET */ \
- 1, /* RAY_MIB_RSSI_THRESH_OFFSET */ \
- 1, /* RAY_MIB_BUSY_THRESH_OFFSET */ \
- 1, /* RAY_MIB_SYNC_THRESH */ \
- 1, /* RAY_MIB_TEST_MODE */ \
- 1, /* RAY_MIB_TEST_MIN_CHAN */ \
- 1, /* RAY_MIB_TEST_MAX_CHAN */ \
- 1, /* RAY_MIB_ALLOW_PROBE_RESP */ \
- 1, /* RAY_MIB_PRIVACY_MUST_START */ \
- 1, /* RAY_MIB_PRIVACY_CAN_JOIN */ \
- 8 /* RAY_MIB_BASIC_RATE_SET */ \
-}
-
-/*
- * MIB values
- *
- * I've included comments as to where the numbers have originated
- * from.
- *
- * Linux refers to ray_cs.c and rayctl.h from version 167 of the
- * Linux Raylink driver.
- *
- * NetBSD refers to if_ray.c from version 1.12 of the NetBSD Raylink
- * driver.
- *
- * Symb refers to numbers cleaned from the 802.11 specification,
- * discussion with 802.11 knowledgable people at Symbionics (i.e. me,
- * aps, ifo, hjl).
- *
- * V4 and V5 refer to settings for version 4 and version 5 of
- * the firmware.
- *
- */
-
-/*
- * ADHOC - I've not got an access point
- */
-#define RAY_MIB_NET_TYPE_ADHOC 0x00
-#define RAY_MIB_NET_TYPE_INFRA 0x01
-#define RAY_MIB_NET_TYPE_DEFAULT RAY_MIB_NET_TYPE_ADHOC
-
-/*
- * TERMINAL - but we might play with using the card as an AP
- */
-#define RAY_MIB_AP_STATUS_TERMINAL 0x00
-#define RAY_MIB_AP_STATUS_AP 0x01
-#define RAY_MIB_AP_STATUS_DEFAULT RAY_MIB_AP_STATUS_TERMINAL
-
-/*
- * - windows setting comes from the Aviator software v1.1
- */
-#define RAY_MIB_SSID_WINDOWS "NETWORK_NAME"
-#define RAY_MIB_SSID_NOT_WINDOWS "WIRELESS_NETWORK"
-#define RAY_MIB_SSID_DEFAULT RAY_MIB_SSID_WINDOWS
-
-#define RAY_MIB_SCAN_MODE_PASSIVE 0x00
-#define RAY_MIB_SCAN_MODE_ACTIVE 0x01
-#define RAY_MIB_SCAN_MODE_DEFAULT RAY_MIB_SCAN_MODE_ACTIVE
-
-/*
- * NONE - power saving only works with access points
- */
-#define RAY_MIB_APM_MODE_NONE 0x00
-#define RAY_MIB_APM_MODE_POWERSAVE 0x01
-#define RAY_MIB_APM_MODE_DEFAULT RAY_MIB_APM_MODE_NONE
-
-/*
- * Linux.h 0x0200
- * Linux.c-V4 0x7fff
- * Linux.c-V5 0x7fff
- * NetBSD.c 0x7fff - disabled
- * Symb 0xXXXX - you really should fragment but getting it wrong
- * crucifies the performance
- */
-#define RAY_MIB_FRAG_THRESH_DISABLE 0x7fff
-#define RAY_MIB_FRAG_THRESH_DEFAULT RAY_MIB_FRAG_THRESH_DISABLE
-
-/*
- * Linux.h - 16k * 2**n, n=0-4 in Kus
- * Linux.c-V4 0x0200
- * Linux.c-V5 0x0080 - 128 Kus
- * NetBSD-V4 0x0200 - from Linux
- * NetBSD-V4 0x0400 - "divined"
- * NetBSD-V5 0x0080
- * Symb-V4 0xXXXX - 802.11 dwell time is XXX Kus
- * Symb-V5 0xXXXX - 802.11 dwell time is XXX Kus
- * XXX - see init_startup_params in Linux.c
- */
-#define RAY_MIB_DWELL_TIME_V4 0x0400
-#define RAY_MIB_DWELL_TIME_V5 0x0080
-
-/*
- * Linux.h - n * a_hop_time in Kus
- * Linux.c-V4 0x0001
- * Linux.c-V5 0x0100 - 256 Kus
- * NetBSD-V4 0x0001 - from Linux
- * NetBSD-V4 0x0000 - "divined"
- * NetBSD-V5 0x0100
- * Symb-V4 0x0001 - best performance is one beacon each dwell XXX
- * Symb-V5 0x0080 - best performance is one beacon each dwell XXX
- * XXX - see init_startup_params in Linux.c
- */
-#define RAY_MIB_BEACON_PERIOD_V4 0x01
-#define RAY_MIB_BEACON_PERIOD_V5 RAY_MIB_DWELL_TIME_V5
-
-/*
- * Linux.h - in beacons
- * Linux.c 0x01
- * NetBSD 0x01
- * Symb 0xXX - need to find out what DTIM is
- */
-#define RAY_MIB_DTIM_INTERVAL_DEFAULT 0x01
-
-/*
- * Linux.c 0x07
- * NetBSD 0x01 - documented default for 5/6
- * NetBSD 0x07 - from Linux
- * NetBSD 0x03 - "divined"
- * Symb 0xXX - 7 retries seems okay but check with APS
- */
-#define RAY_MIB_MAX_RETRY_DEFAULT 0x07
-
-/*
- * Linux.c 0xa3
- * NetBSD 0x86 - documented default for 5/6
- * NetBSD 0xa3 - from Linux
- * NetBSD 0xa3 - "divined"
- * Symb 0xXX - this must be a 802.11 defined setting?
- */
-#define RAY_MIB_ACK_TIMO_DEFAULT 0xa3
-
-/*
- * Linux.c 0x1d
- * NetBSD 0x1c - documented default for 5/6
- * NetBSD 0x1d - from Linux
- * NetBSD 0x1d - "divined"
- * Symb 0xXX - default SIFS for 802.11
- */
-#define RAY_MIB_SIFS_DEFAULT 0x1d
-
-/*
- * Linux.c 0x82
- * NetBSD 0x82 - documented default for 5/6
- * NetBSD 0x82 - from Linux
- * Symb 0xXX - default DIFS for 802.11
- */
-#define RAY_MIB_DIFS_DEFAULT 0x82
-
-/*
- * Linux.c-V4 0xce
- * Linux.c-V5 0x4e
- * NetBSD 0x00 - documented default for 5/6
- * NetBSD-V4 0xce - from Linux
- * NetBSD-V5 0x4e - from Linux
- * Symb 0xXX - default PIFS for 802.11
- */
-#define RAY_MIB_PIFS_V4 0xce
-#define RAY_MIB_PIFS_V5 0x4e
-
-/*
- * Linux.c 0x7fff
- * NetBSD 0x7fff - disabled
- * Symb 0xXXXX - need to set this realistically to get CTS/RTS mode
- * working right
- */
-#define RAY_MIB_RTS_THRESH_DISABLE 0x7fff
-#define RAY_MIB_RTS_THRESH_DEFAULT RAY_MIB_RTS_THRESH_DISABLE
-
-/*
- * Linux.c-V4 0xfb1e
- * Linix.c-V5 0x04e2
- * NetBSD-V4 0xfb1e
- * NetBSD-V5 0x04e2
- * Symb 0xXXXX - this might be the time to dwell on a channel
- * whilst scanning for the n/w. In that case it should
- * be tied to the dwell time above.
- * V5 numbers could be Kus,
- * 0x04e2Kus = 1250*1024us = 1.28 seconds
- */
-#define RAY_MIB_SCAN_DWELL_V4 0xfb1e
-#define RAY_MIB_SCAN_DWELL_V5 0x04e2
-
-/*
- * Linux.c-V4 0xc75c
- * Linix.c-V5 0x38a4
- * NetBSD-V4 0xc75c
- * NetBSD-V5 0x38a4
- * Symb 0xXXXX - see above - this may be total time before giving up
- * but 0x38a4 Kus is about 14 seconds
- * i.e. not 79*SCAN_DWELL
- */
-#define RAY_MIB_SCAN_MAX_DWELL_V4 0xc75c
-#define RAY_MIB_SCAN_MAX_DWELL_V5 0x38a4
-
-/*
- * Linix.c 0x05
- * NetBSD 0x05
- * Symb 0xXX - can't be in Kus too short
- */
-#define RAY_MIB_ASSOC_TIMO_DEFAULT 0x05
-
-/*
- * Linix.c-V4 0x04
- * Linux.c-V5 0x08
- * NetBSD-V4 0x04 - Linux
- * NetBSD-V4 0x08 - "divined"
- * NetBSD-V5 0x08
- * Symb 0xXX - hmm maybe this ties in with the DWELL_SCAN above?
- */
-#define RAY_MIB_ADHOC_SCAN_CYCLE_DEFAULT 0x08
-
-/*
- * Linix.c 0x02
- * NetBSD-V4 0x02 - Linux
- * NetBSD-V4 0x01 - "divined"
- * NetBSD-V5 0x02
- * Symb 0xXX - hmm maybe this ties in with the DWELL_SCAN above?
- */
-#define RAY_MIB_INFRA_SCAN_CYCLE_DEFAULT 0x02
-
-/*
- * Linix.c-V4 0x04
- * Linux.c-V5 0x08
- * NetBSD-V4 0x04 - Linux
- * NetBSD-V4 0x18 - "divined"
- * NetBSD-V5 0x08
- * Symb 0xXX - hmm maybe this ties in with the DWELL_SCAN above?
- */
-#define RAY_MIB_INFRA_SUPER_SCAN_CYCLE_DEFAULT 0x08
-
-#define RAY_MIB_PROMISC_DEFAULT 0x00
-
-#define RAY_MIB_UNIQ_WORD_DEFAULT 0x0cbd
-
-/*
- * Linux.c-V4 0x4e
- * Linix.c-V5 0x32
- * NetBSD-V4 0x4e - Linux
- * NetBSD-V4 0x18 - "divined"
- * NetBSD-V5 0x32 - mentions spec. is 50us i.e. 0x32
- * Symb 0xXX - wtf 0x4e = 78
- */
-#define RAY_MIB_SLOT_TIME_V4 0x4e
-#define RAY_MIB_SLOT_TIME_V5 0x32
-
-/*
- * Linux.c 0xff
- * NetBSD-V4 0xff - Linux
- * NetBSD-V4 0x30 - "divined"
- * NetBSD-V5 0xff - disabled
- * NetBSD.h - if below this inc count
- * Symb 0xXX - hmm is 0xff really disabled? need this to work
- */
-#define RAY_MIB_ROAM_LOW_SNR_THRESH_DISABLED 0xff
-#define RAY_MIB_ROAM_LOW_SNR_THRESH_DEFAULT RAY_MIB_ROAM_LOW_SNR_THRESH_DISABLED
-
-/*
- * Linux.c 0xff
- * NetBSD 0x07 - "divined - check" and marked as disabled
- * NetBSD 0xff - disabled
- * NetBSD.h - roam after cnt below thrsh
- * Symb 0xXX - hmm is 0xff really disabled? need this to work
- */
-#define RAY_MIB_LOW_SNR_COUNT_DISABLED 0xff
-#define RAY_MIB_LOW_SNR_COUNT_DEFAULT RAY_MIB_LOW_SNR_COUNT_DISABLED
-
-/*
- * Linux.c 0x05
- * NetBSD 0x02 - documented default for 5/6
- * NetBSD 0x05 - Linux
- * NetBSD 0x07 - "divined - check, looks fishy"
- * Symb 0xXX - 5 missed beacons is probably okay
- */
-#define RAY_MIB_INFRA_MISSED_BEACON_COUNT_DEFAULT 0x05
-
-/*
- * Linux.c 0xff
- * NetBSD 0xff
- * Symb 0xXX - so what happens in adhoc if the beacon is missed?
- * do we create our own beacon
- */
-#define RAY_MIB_ADHOC_MISSED_BEACON_COUNT_DISABLED 0xff
-#define RAY_MIB_ADHOC_MISSED_BEACON_COUNT_DEFAULT RAY_MIB_ADHOC_MISSED_BEACON_COUNT_DISABLED
-
-#define RAY_MIB_COUNTRY_CODE_USA 0x1
-#define RAY_MIB_COUNTRY_CODE_EUROPE 0x2
-#define RAY_MIB_COUNTRY_CODE_JAPAN 0x3
-#define RAY_MIB_COUNTRY_CODE_KOREA 0x4
-#define RAY_MIB_COUNTRY_CODE_SPAIN 0x5
-#define RAY_MIB_COUNTRY_CODE_FRANCE 0x6
-#define RAY_MIB_COUNTRY_CODE_ISRAEL 0x7
-#define RAY_MIB_COUNTRY_CODE_AUSTRALIA 0x8
-#define RAY_MIB_COUNTRY_CODE_JAPAN_TEST 0x9
-#define RAY_MIB_COUNTRY_CODE_MAX 0xa
-#define RAY_MIB_COUNTRY_CODE_DEFAULT RAY_MIB_COUNTRY_CODE_USA
-
-/*
- * NetBSD.h - no longer supported
- */
-#define RAY_MIB_HOP_SEQ_DEFAULT 0x0b
-
-/*
- * Linux.c-V4 0x4e
- * Linix.c-V5 0x4f
- * NetBSD-V4 0x4e
- * NetBSD-V5 0x4f
- * Symb 0xXX - 0x4e = 78 so is it a cock up?
- */
-#define RAY_MIB_HOP_SEQ_LEN_V4 0x4e
-#define RAY_MIB_HOP_SEQ_LEN_V5 0x4f
-
-/*
- * All from here down are the same in Linux/NetBSD and seem to be sane.
- */
-#define RAY_MIB_CW_MAX_V4 0x3f
-#define RAY_MIB_CW_MAX_V5 0x003f
-
-#define RAY_MIB_CW_MIN_V4 0x0f
-#define RAY_MIB_CW_MIN_V5 0x000f
-
-/*
- * Symb 0xXX - these parameters will affect the clear channel
- * assesment false triggering
- *
- */
-#define RAY_MIB_NOISE_FILTER_GAIN_DEFAULT 0x04
-#define RAY_MIB_NOISE_LIMIT_OFFSET_DEFAULT 0x08
-#define RAY_MIB_RSSI_THRESH_OFFSET_DEFAULT 0x28
-#define RAY_MIB_BUSY_THRESH_OFFSET_DEFAULT 0x28
-#define RAY_MIB_SYNC_THRESH_DEFAULT 0x07
-
-#define RAY_MIB_TEST_MODE_NORMAL 0x0
-#define RAY_MIB_TEST_MODE_ANT_1 0x1
-#define RAY_MIB_TEST_MODE_ATN_2 0x2
-#define RAY_MIB_TEST_MODE_ATN_BOTH 0x3
-#define RAY_MIB_TEST_MODE_DEFAULT RAY_MIB_TEST_MODE_NORMAL
-
-#define RAY_MIB_TEST_MIN_CHAN_DEFAULT 0x02
-#define RAY_MIB_TEST_MAX_CHAN_DEFAULT 0x02
-
-#define RAY_MIB_ALLOW_PROBE_RESP_DISALLOW 0x0
-#define RAY_MIB_ALLOW_PROBE_RESP_ALLOW 0x1
-#define RAY_MIB_ALLOW_PROBE_RESP_DEFAULT RAY_MIB_ALLOW_PROBE_RESP_DISALLOW
-
-#define RAY_MIB_PRIVACY_MUST_START_NOWEP 0x0
-#define RAY_MIB_PRIVACY_MUST_START_WEP 0x1
-#define RAY_MIB_PRIVACY_MUST_START_DEFAULT RAY_MIB_PRIVACY_MUST_START_NOWEP
-
-#define RAY_MIB_PRIVACY_CAN_JOIN_NOWEP 0x0
-#define RAY_MIB_PRIVACY_CAN_JOIN_WEP 0x1
-#define RAY_MIB_PRIVACY_CAN_JOIN_DONT_CARE 0x2
-#define RAY_MIB_PRIVACY_CAN_JOIN_DEFAULT RAY_MIB_PRIVACY_CAN_JOIN_NOWEP
-
-#define RAY_MIB_BASIC_RATE_SET_500K 1
-#define RAY_MIB_BASIC_RATE_SET_1000K 2
-#define RAY_MIB_BASIC_RATE_SET_1500K 3
-#define RAY_MIB_BASIC_RATE_SET_2000K 4
-#define RAY_MIB_BASIC_RATE_SET_DEFAULT RAY_MIB_BASIC_RATE_SET_1000K
diff --git a/sys/dev/ray/if_rayreg.h b/sys/dev/ray/if_rayreg.h
deleted file mode 100644
index 7ce962f48292..000000000000
--- a/sys/dev/ray/if_rayreg.h
+++ /dev/null
@@ -1,466 +0,0 @@
-/*
- * Copyright (C) 2000
- * Dr. Duncan McLennan Barclay, dmlb@ragnet.demon.co.uk.
- *
- * 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 author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY DUNCAN BARCLAY 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 DUNCAN BARCLAY 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.
- *
- * $Id: if_rayreg.h,v 1.5 2000/03/05 22:04:09 dmlb Exp $
- *
- */
-
-/* $NetBSD: if_rayreg.h,v 1.1 2000/01/23 23:59:22 chopps Exp $ */
-/*
- * Copyright (c) 2000 Christian E. Hopps
- * 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 author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- */
-
-/*
- * CCR registers, appearing in the attribute memory space
- */
-#define RAY_CCR 0xf00 /* CCR register offset */
-#define RAY_COR (RAY_CCR + 0x00) /* config option register */
-#define RAY_CCSR (RAY_CCR + 0x01) /* config/status register */
-#define RAY_PIN (RAY_CCR + 0x02) /* not in hw */
-#define RAY_SOCKETCOPY (RAY_CCR + 0x03) /* not used by hw */
-#define RAY_HCSIR (RAY_CCR + 0x05) /* HCS intr register */
-#define RAY_ECFIR (RAY_CCR + 0x06) /* ECF intr register */
-/*
- * We don't seem to be able to access these in a simple manner
- */
-#define RAY_AR0 (RAY_CCR + 0x08) /* authorization register 0 (unused) */
-#define RAY_AR1 (RAY_CCR + 0x09) /* authorization register 1 (unused) */
-#define RAY_PMR (RAY_CCR + 0x0a) /* program mode register (unused) */
-#define RAY_TMR (RAY_CCR + 0x0b) /* pc test mode register (unused) */
-#define RAY_FCWR (RAY_CCR + 0x10) /* frequency control word register */
-#define RAY_TMC1 (RAY_CCR + 0x14) /* test mode control 1 (unused) */
-#define RAY_TMC2 (RAY_CCR + 0x15) /* test mode control 1 (unused) */
-#define RAY_TMC3 (RAY_CCR + 0x16) /* test mode control 1 (unused) */
-#define RAY_TMC4 (RAY_CCR + 0x17) /* test mode control 1 (unused) */
-
-/*
- * COR register bits
- */
-#define RAY_COR_CFG_NUM 0x01 /* currently ignored and set */
-#define RAY_COR_CFG_MASK 0x3f /* mask for function */
-#define RAY_COR_LEVEL_IRQ 0x40 /* currently ignored and set */
-#define RAY_COR_RESET 0x80 /* soft-reset the card */
-#define RAY_COR_DEFAULT (RAY_COR_CFG_NUM | RAY_COR_LEVEL_IRQ)
-
-/*
- * CCS register bits
- */
-/* XXX the linux driver indicates bit 0 is the irq bit */
-#define RAY_CCS_IRQ 0x02 /* interrupt pending */
-#define RAY_CCS_POWER_DOWN 0x04
-
-/*
- * HCSI register bits
- *
- * the host can only clear this bit.
- */
-#define RAY_HCSIR_IRQ 0x01 /* indicates an interrupt */
-
-/*
- * ECFI register values
- */
-#define RAY_ECFIR_IRQ 0x01 /* interrupt the card */
-
-/*
- * authorization register 0 values
- * -- used for testing/programming the card (unused)
- */
-#define RAY_AR0_ON 0x57
-
-/*
- * authorization register 1 values
- * -- used for testing/programming the card (unused)
- */
-#define RAY_AR1_ON 0x82
-
-/*
- * PMR bits -- these are used to program the card (unused)
- */
-#define RAY_PMR_PC2PM 0x02 /* grant access to firmware flash */
-#define RAY_PMR_PC2CAL 0x10 /* read access to the A/D modem inp */
-#define RAY_PMR_MLSE 0x20 /* read access to the MSLE prom */
-
-/*
- * TMR bits -- get access to test modes (unused)
- */
-#define RAY_TMR_TEST 0x08 /* test mode */
-
-/*
- * FCWR -- frequency control word, values from [0x02,0xA6] map to
- * RF frequency values.
- */
-
-/*
- * 48k of memory
- */
-#define RAY_SRAM_MEM_BASE 0
-#define RAY_SRAM_MEM_SIZE 0xc000
-
-/*
- * offsets into shared ram
- */
-#define RAY_SCB_BASE 0x0000 /* cfg/status/ctl area */
-#define RAY_STATUS_BASE 0x0100
-#define RAY_HOST_TO_ECF_BASE 0x0200
-#define RAY_ECF_TO_HOST_BASE 0x0300
-#define RAY_CCS_BASE 0x0400
-#define RAY_RCS_BASE 0x0800
-#define RAY_APOINT_TIM_BASE 0x0c00
-#define RAY_SSID_LIST_BASE 0x0d00
-#define RAY_TX_BASE 0x1000
-#define RAY_TX_SIZE 0x7000
-#define RAY_TX_END 0x8000
-#define RAY_RX_BASE 0x8000
-#define RAY_RX_END 0xc000
-#define RAY_RX_MASK 0x3fff
-
-/*
- * Startup reporting stucture
- */
-struct ray_ecf_startup_v4 {
- u_int8_t e_status;
- u_int8_t e_station_addr[ETHER_ADDR_LEN];
- u_int8_t e_prg_cksum;
- u_int8_t e_cis_cksum;
- u_int8_t e_resv0[7];
- u_int8_t e_japan_callsign[12];
-};
-struct ray_ecf_startup_v5 {
- u_int8_t e_status;
- u_int8_t e_station_addr[ETHER_ADDR_LEN];
- u_int8_t e_resv0;
- u_int8_t e_rates[8];
- u_int8_t e_japan_callsign[12];
- u_int8_t e_prg_cksum;
- u_int8_t e_cis_cksum;
- u_int8_t e_fw_build_string;
- u_int8_t e_fw_build;
- u_int8_t e_fw_resv;
- u_int8_t e_asic_version;
- u_int8_t e_tibsize;
- u_int8_t e_resv1[29];
-};
-
-/*
- * Startup status word result codes
- */
-#define RAY_ECFS_RESERVED0 0x01
-#define RAY_ECFS_PROC_SELF_TEST 0x02
-#define RAY_ECFS_PROG_MEM_CHECKSUM 0x04
-#define RAY_ECFS_DATA_MEM_TEST 0x08
-#define RAY_ECFS_RX_CALIBRATION 0x10
-#define RAY_ECFS_FW_VERSION_COMPAT 0x20
-#define RAY_ECFS_RERSERVED1 0x40
-#define RAY_ECFS_TEST_COMPLETE 0x80
-#define RAY_ECFS_CARD_OK RAY_ECFS_TEST_COMPLETE
-
-/*
- * Firmware build codes
- */
-#define RAY_ECFS_BUILD_4 0x55
-#define RAY_ECFS_BUILD_5 0x5
-
-/*
- * System Control Block
- */
-#define RAY_SCB_CCSI 0x00 /* host CCS index */
-#define RAY_SCB_RCSI 0x01 /* ecf RCS index */
-
-/*
- * command control structures (for CCSR commands)
- */
-
-/*
- * commands for CCSR
- */
-#define RAY_CMD_START_PARAMS 0x01 /* download start params */
-#define RAY_CMD_UPDATE_PARAMS 0x02 /* update params */
-#define RAY_CMD_REPORT_PARAMS 0x03 /* report params */
-#define RAY_CMD_UPDATE_MCAST 0x04 /* update mcast list */
-#define RAY_CMD_UPDATE_APM 0x05 /* update power saving mode */
-#define RAY_CMD_START_NET 0x06
-#define RAY_CMD_JOIN_NET 0x07
-#define RAY_CMD_START_ASSOC 0x08
-#define RAY_CMD_TX_REQ 0x09
-#define RAY_CMD_TEST_MEM 0x0a
-#define RAY_CMD_SHUTDOWN 0x0b
-#define RAY_CMD_DUMP_MEM 0x0c
-#define RAY_CMD_START_TIMER 0x0d
-#define RAY_CMD_MAX 0x0e
-
-/*
- * unsolicted commands from the ECF
- */
-#define RAY_ECMD_RX_DONE 0x80 /* process rx packet */
-#define RAY_ECMD_REJOIN_DONE 0x81 /* rejoined the network */
-#define RAY_ECMD_ROAM_START 0x82 /* romaining started */
-#define RAY_ECMD_JAPAN_CALL_SIGNAL 0x83 /* japan test thing */
-
-
-/*
- * Configure/status/control memory
- */
-struct ray_csc {
- u_int8_t csc_mrxo_own; /* 0 ECF writes, 1 host write */
- u_int8_t csc_mrxc_own; /* 0 ECF writes, 1 host write */
- u_int8_t csc_rxhc_own; /* 0 ECF writes, 1 host write */
- u_int8_t csc_resv;
- u_int16_t csc_mrx_overflow; /* ECF incs on rx overflow */
- u_int16_t csc_mrx_cksum; /* ECF incs on cksum error */
- u_int16_t csc_rx_hcksum; /* ECF incs on header cksum error */
- u_int8_t csc_rx_noise; /* average RSL measuremant */
-};
-
-/*
- * CCS area
- */
-#define RAY_CCS_LINK_NULL 0xff
-#define RAY_CCS_SIZE 16
-
-#define RAY_CCS_TX_FIRST 0
-#define RAY_CCS_TX_LAST 13
-#define RAY_CCS_NTX (RAY_CCS_TX_LAST - RAY_CCS_TX_FIRST + 1)
-#define RAY_TX_BUF_SIZE 2048
-#define RAY_CCS_CMD_FIRST 14
-#define RAY_CCS_CMD_LAST 63
-#define RAY_CCS_NCMD (RAY_CCS_CMD_LAST - RAY_CCS_CMD_FIRST + 1)
-#define RAY_CCS_LAST 63
-
-#define RAY_CCS_INDEX(ccs) (((ccs) - RAY_CCS_BASE) / RAY_CCS_SIZE)
-#define RAY_CCS_ADDRESS(i) (RAY_CCS_BASE + (i) * RAY_CCS_SIZE)
-
-/*
- * RCS area
- */
-#define RAY_RCS_FIRST 64
-#define RAY_RCS_LAST 127
-
-/*
- * CCS commands
- */
-struct ray_cmd {
- u_int8_t c_status; /* ccs generic header */
- u_int8_t c_cmd; /* " */
- u_int8_t c_link; /* " */
-};
-
-#define RAY_CCS_STATUS_FREE 0x0
-#define RAY_CCS_STATUS_BUSY 0x1
-#define RAY_CCS_STATUS_COMPLETE 0x2
-#define RAY_CCS_STATUS_FAIL 0x3
-#define RAY_CCS_STATUS_STRINGS { \
- "free", \
- "busy", \
- "complete", \
- "fail" \
-}
-
-/* RAY_CMD_UPDATE_PARAMS */
-struct ray_cmd_update {
- u_int8_t c_status; /* ccs generic header */
- u_int8_t c_cmd; /* " */
- u_int8_t c_link; /* " */
- u_int8_t c_paramid;
- u_int8_t c_nparam;
- u_int8_t c_failcause;
-};
-
-/* RAY_CMD_REPORT_PARAMS */
-struct ray_cmd_report {
- u_int8_t c_status; /* ccs generic header */
- u_int8_t c_cmd; /* " */
- u_int8_t c_link; /* " */
- u_int8_t c_paramid;
- u_int8_t c_nparam;
- u_int8_t c_failcause;
- u_int8_t c_len;
-};
-
-/* RAY_CMD_UPDATE_MCAST */
-struct ray_cmd_update_mcast {
- u_int8_t c_status; /* ccs generic header */
- u_int8_t c_cmd; /* " */
- u_int8_t c_link; /* " */
- u_int8_t c_nmcast;
-};
-
-/* RAY_CMD_UPDATE_APM */
-struct ray_cmd_udpate_apm {
- u_int8_t c_status; /* ccs generic header */
- u_int8_t c_cmd; /* " */
- u_int8_t c_link; /* " */
- u_int8_t c_mode;
-};
-
-/* RAY_CMD_START_NET and RAY_CMD_JOIN_NET */
-struct ray_cmd_net {
- u_int8_t c_status; /* ccs generic header */
- u_int8_t c_cmd; /* " */
- u_int8_t c_link; /* " */
- u_int8_t c_upd_param;
- u_int8_t c_bss_id[ETHER_ADDR_LEN];
- u_int8_t c_inited;
- u_int8_t c_def_txrate;
- u_int8_t c_encrypt;
-};
-/* Parameters passed in HOST_TO_ECF section when c_upd_param is set in
- * ray_cmd_net. */
-struct ray_net_params {
- u_int8_t p_net_type;
- u_int8_t p_ssid[32];
- u_int8_t p_privacy_must_start;
- u_int8_t p_privacy_can_join;
-};
-
-/* RAY_CMD_UPDATE_ASSOC */
-struct ray_cmd_update_assoc {
- u_int8_t c_status; /* ccs generic header */
- u_int8_t c_cmd; /* " */
- u_int8_t c_link; /* " */
- u_int8_t c_astatus;
- u_int8_t c_aid[2];
-};
-
-/* RAY_CMD_TX_REQ */
-struct ray_cmd_tx {
- u_int8_t c_status; /* ccs generic header */
- u_int8_t c_cmd; /* " */
- u_int8_t c_link; /* " */
- u_int8_t c_bufp[2];
- u_int8_t c_len[2];
- u_int8_t c_resv[5];
- u_int8_t c_tx_rate;
- u_int8_t c_apm_mode;
- u_int8_t c_nretry;
- u_int8_t c_antenna;
-};
-struct ray_cmd_tx_4 {
- u_int8_t c_status; /* ccs generic header */
- u_int8_t c_cmd; /* " */
- u_int8_t c_link; /* " */
- u_int8_t c_bufp[2];
- u_int8_t c_len[2];
- u_int8_t c_addr[ETHER_ADDR_LEN];
- u_int8_t c_apm_mode;
- u_int8_t c_nretry;
- u_int8_t c_antenna;
-};
-
-/* RAY_CMD_DUMP_MEM */
-struct ray_cmd_dump_mem {
- u_int8_t c_status; /* ccs generic header */
- u_int8_t c_cmd; /* " */
- u_int8_t c_link; /* " */
- u_int8_t c_memtype;
- u_int8_t c_memp[2];
- u_int8_t c_len;
-};
-
-/* RAY_CMD_START_TIMER */
-struct ray_cmd_start_timer {
- u_int8_t c_status; /* ccs generic header */
- u_int8_t c_cmd; /* " */
- u_int8_t c_link; /* " */
- u_int8_t c_duration[2];
-};
-
-/* RAY_ECMD_RX_DONE */
-struct ray_cmd_rx {
- u_int8_t c_status; /* ccs generic header */
- u_int8_t c_cmd; /* " */
- u_int8_t c_link; /* " */
- u_int8_t c_bufp[2]; /* buffer pointer */
- u_int8_t c_len[2]; /* length */
- u_int8_t c_siglev; /* signal level */
- u_int8_t c_nextfrag; /* next fragment in packet */
- u_int8_t c_pktlen[2]; /* total packet length */
- u_int8_t c_antenna; /* ant. with best reception */
- u_int8_t c_updbss; /* only 1 for beacon messages */
-};
-
-/*
- * Transmit scratch space and phy header structures
- */
-struct ray_tx_tib {
- u_int8_t t_ccs_index;
- u_int8_t t_psm;
- u_int8_t t_pass_fail;
- u_int8_t t_retry_count;
- u_int8_t t_max_retries;
- u_int8_t t_frags_remaining;
- u_int8_t t_no_rb;
- u_int8_t t_rts_reqd;
- u_int8_t t_csma_tx_cntrl_2;
- u_int8_t t_sifs_tx_cntrl_2;
- u_int8_t t_tx_dma_addr_1[2];
- u_int8_t t_tx_dma_addr_2[2];
- u_int8_t t_var_dur_2mhz[2];
- u_int8_t t_var_dur_1mhz[2];
- u_int8_t t_max_dur_2mhz[2];
- u_int8_t t_max_dur_1mhz[2];
- u_int8_t t_hdr_len;
- u_int8_t t_max_frag_len[2];
- u_int8_t t_var_len[2];
- u_int8_t t_phy_hdr_4;
- u_int8_t t_mac_hdr_1;
- u_int8_t t_mac_hdr_2;
- u_int8_t t_sid[2];
-};
-
-struct ray_tx_phy_header {
- u_int8_t t_sfd[2];
- u_int8_t t_hdr_3;
- u_int8_t t_hdr_4;
-};
diff --git a/sys/dev/rc/rc.c b/sys/dev/rc/rc.c
deleted file mode 100644
index ce6dab2cd789..000000000000
--- a/sys/dev/rc/rc.c
+++ /dev/null
@@ -1,1453 +0,0 @@
-/*
- * Copyright (C) 1995 by Pavel Antonov, Moscow, Russia.
- * Copyright (C) 1995 by Andrey A. Chernov, Moscow, Russia.
- * 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 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 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.
- *
- * $FreeBSD$
- *
- */
-
-/*
- * SDL Communications Riscom/8 (based on Cirrus Logic CL-CD180) driver
- *
- */
-
-#include "rc.h"
-
-/*#define RCDEBUG*/
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/tty.h>
-#include <sys/proc.h>
-#include <sys/conf.h>
-#include <sys/dkstat.h>
-#include <sys/fcntl.h>
-#include <sys/interrupt.h>
-#include <sys/kernel.h>
-#include <machine/clock.h>
-#include <machine/ipl.h>
-
-#include <i386/isa/isa_device.h>
-
-#include <i386/isa/ic/cd180.h>
-#include <i386/isa/rcreg.h>
-
-/* Prototypes */
-static int rcprobe __P((struct isa_device *));
-static int rcattach __P((struct isa_device *));
-
-#define rcin(port) RC_IN (nec, port)
-#define rcout(port,v) RC_OUT (nec, port, v)
-
-#define WAITFORCCR(u,c) rc_wait0(nec, (u), (c), __LINE__)
-#define CCRCMD(u,c,cmd) WAITFORCCR((u), (c)); rcout(CD180_CCR, (cmd))
-
-#define RC_IBUFSIZE 256
-#define RB_I_HIGH_WATER (TTYHOG - 2 * RC_IBUFSIZE)
-#define RC_OBUFSIZE 512
-#define RC_IHIGHWATER (3 * RC_IBUFSIZE / 4)
-#define INPUT_FLAGS_SHIFT (2 * RC_IBUFSIZE)
-#define LOTS_OF_EVENTS 64
-
-#define RC_FAKEID 0x10
-
-#define RC_PROBED 1
-#define RC_ATTACHED 2
-
-#define GET_UNIT(dev) (minor(dev) & 0x3F)
-#define CALLOUT(dev) (minor(dev) & 0x80)
-
-/* For isa routines */
-struct isa_driver rcdriver = {
- rcprobe, rcattach, "rc"
-};
-
-static d_open_t rcopen;
-static d_close_t rcclose;
-static d_ioctl_t rcioctl;
-
-#define CDEV_MAJOR 63
-static struct cdevsw rc_cdevsw = {
- /* open */ rcopen,
- /* close */ rcclose,
- /* read */ ttyread,
- /* write */ ttywrite,
- /* ioctl */ rcioctl,
- /* poll */ ttypoll,
- /* mmap */ nommap,
- /* strategy */ nostrategy,
- /* name */ "rc",
- /* maj */ CDEV_MAJOR,
- /* dump */ nodump,
- /* psize */ nopsize,
- /* flags */ D_TTY,
- /* bmaj */ -1
-};
-
-/* Per-board structure */
-static struct rc_softc {
- u_int rcb_probed; /* 1 - probed, 2 - attached */
- u_int rcb_addr; /* Base I/O addr */
- u_int rcb_unit; /* unit # */
- u_char rcb_dtr; /* DTR status */
- struct rc_chans *rcb_baserc; /* base rc ptr */
-} rc_softc[NRC];
-
-/* Per-channel structure */
-static struct rc_chans {
- struct rc_softc *rc_rcb; /* back ptr */
- u_short rc_flags; /* Misc. flags */
- int rc_chan; /* Channel # */
- u_char rc_ier; /* intr. enable reg */
- u_char rc_msvr; /* modem sig. status */
- u_char rc_cor2; /* options reg */
- u_char rc_pendcmd; /* special cmd pending */
- u_int rc_dtrwait; /* dtr timeout */
- u_int rc_dcdwaits; /* how many waits DCD in open */
- u_char rc_hotchar; /* end packed optimize */
- struct tty *rc_tp; /* tty struct */
- u_char *rc_iptr; /* Chars input buffer */
- u_char *rc_hiwat; /* hi-water mark */
- u_char *rc_bufend; /* end of buffer */
- u_char *rc_optr; /* ptr in output buf */
- u_char *rc_obufend; /* end of output buf */
- u_char rc_ibuf[4 * RC_IBUFSIZE]; /* input buffer */
- u_char rc_obuf[RC_OBUFSIZE]; /* output buffer */
-} rc_chans[NRC * CD180_NCHAN];
-
-static int rc_scheduled_event = 0;
-
-/* for pstat -t */
-static struct tty rc_tty[NRC * CD180_NCHAN];
-static const int nrc_tty = NRC * CD180_NCHAN;
-
-/* Flags */
-#define RC_DTR_OFF 0x0001 /* DTR wait, for close/open */
-#define RC_ACTOUT 0x0002 /* Dial-out port active */
-#define RC_RTSFLOW 0x0004 /* RTS flow ctl enabled */
-#define RC_CTSFLOW 0x0008 /* CTS flow ctl enabled */
-#define RC_DORXFER 0x0010 /* RXFER event planned */
-#define RC_DOXXFER 0x0020 /* XXFER event planned */
-#define RC_MODCHG 0x0040 /* Modem status changed */
-#define RC_OSUSP 0x0080 /* Output suspended */
-#define RC_OSBUSY 0x0100 /* start() routine in progress */
-#define RC_WAS_BUFOVFL 0x0200 /* low-level buffer ovferflow */
-#define RC_WAS_SILOVFL 0x0400 /* silo buffer overflow */
-#define RC_SEND_RDY 0x0800 /* ready to send */
-
-/* Table for translation of RCSR status bits to internal form */
-static int rc_rcsrt[16] = {
- 0, TTY_OE, TTY_FE,
- TTY_FE|TTY_OE, TTY_PE, TTY_PE|TTY_OE,
- TTY_PE|TTY_FE, TTY_PE|TTY_FE|TTY_OE, TTY_BI,
- TTY_BI|TTY_OE, TTY_BI|TTY_FE, TTY_BI|TTY_FE|TTY_OE,
- TTY_BI|TTY_PE, TTY_BI|TTY_PE|TTY_OE, TTY_BI|TTY_PE|TTY_FE,
- TTY_BI|TTY_PE|TTY_FE|TTY_OE
-};
-
-/* Static prototypes */
-static ointhand2_t rcintr;
-static void rc_hwreset __P((int, int, unsigned int));
-static int rc_test __P((int, int));
-static void rc_discard_output __P((struct rc_chans *));
-static void rc_hardclose __P((struct rc_chans *));
-static int rc_modctl __P((struct rc_chans *, int, int));
-static void rc_start __P((struct tty *));
-static void rc_stop __P((struct tty *, int rw));
-static int rc_param __P((struct tty *, struct termios *));
-static swihand_t rcpoll;
-static void rc_reinit __P((struct rc_softc *));
-#ifdef RCDEBUG
-static void printrcflags();
-#endif
-static timeout_t rc_dtrwakeup;
-static timeout_t rc_wakeup;
-static void disc_optim __P((struct tty *tp, struct termios *t, struct rc_chans *));
-static void rc_wait0 __P((int nec, int unit, int chan, int line));
-
-/**********************************************/
-
-/* Quick device probing */
-static int
-rcprobe(dvp)
- struct isa_device *dvp;
-{
- int irq = ffs(dvp->id_irq) - 1;
- register int nec = dvp->id_iobase;
-
- if (dvp->id_unit > NRC)
- return 0;
- if (!RC_VALIDADDR(nec)) {
- printf("rc%d: illegal base address %x\n", dvp->id_unit, nec);
- return 0;
- }
- if (!RC_VALIDIRQ(irq)) {
- printf("rc%d: illegal IRQ value %d\n", dvp->id_unit, irq);
- return 0;
- }
- rcout(CD180_PPRL, 0x22); /* Random values to Prescale reg. */
- rcout(CD180_PPRH, 0x11);
- if (rcin(CD180_PPRL) != 0x22 || rcin(CD180_PPRH) != 0x11)
- return 0;
- /* Now, test the board more thoroughly, with diagnostic */
- if (rc_test(nec, dvp->id_unit))
- return 0;
- rc_softc[dvp->id_unit].rcb_probed = RC_PROBED;
-
- return 0xF;
-}
-
-static int
-rcattach(dvp)
- struct isa_device *dvp;
-{
- register int chan, nec = dvp->id_iobase;
- struct rc_softc *rcb = &rc_softc[dvp->id_unit];
- struct rc_chans *rc = &rc_chans[dvp->id_unit * CD180_NCHAN];
- static int rc_started = 0;
- struct tty *tp;
-
- dvp->id_ointr = rcintr;
-
- /* Thorooughly test the device */
- if (rcb->rcb_probed != RC_PROBED)
- return 0;
- rcb->rcb_addr = nec;
- rcb->rcb_dtr = 0;
- rcb->rcb_baserc = rc;
- rcb->rcb_unit = dvp->id_unit;
- /*rcb->rcb_chipid = 0x10 + dvp->id_unit;*/
- printf("rc%d: %d chans, firmware rev. %c\n", rcb->rcb_unit,
- CD180_NCHAN, (rcin(CD180_GFRCR) & 0xF) + 'A');
-
- for (chan = 0; chan < CD180_NCHAN; chan++, rc++) {
- rc->rc_rcb = rcb;
- rc->rc_chan = chan;
- rc->rc_iptr = rc->rc_ibuf;
- rc->rc_bufend = &rc->rc_ibuf[RC_IBUFSIZE];
- rc->rc_hiwat = &rc->rc_ibuf[RC_IHIGHWATER];
- rc->rc_flags = rc->rc_ier = rc->rc_msvr = 0;
- rc->rc_cor2 = rc->rc_pendcmd = 0;
- rc->rc_optr = rc->rc_obufend = rc->rc_obuf;
- rc->rc_dtrwait = 3 * hz;
- rc->rc_dcdwaits= 0;
- rc->rc_hotchar = 0;
- tp = rc->rc_tp = &rc_tty[chan + (dvp->id_unit * CD180_NCHAN)];
- ttychars(tp);
- tp->t_lflag = tp->t_iflag = tp->t_oflag = 0;
- tp->t_cflag = TTYDEF_CFLAG;
- tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
- }
- rcb->rcb_probed = RC_ATTACHED;
- if (!rc_started) {
- cdevsw_add(&rc_cdevsw);
- register_swi(SWI_TTY, rcpoll);
- rc_wakeup((void *)NULL);
- rc_started = 1;
- }
- return 1;
-}
-
-/* RC interrupt handling */
-static void
-rcintr(unit)
- int unit;
-{
- register struct rc_softc *rcb = &rc_softc[unit];
- register struct rc_chans *rc;
- register int nec, resid;
- register u_char val, iack, bsr, ucnt, *optr;
- int good_data, t_state;
-
- if (rcb->rcb_probed != RC_ATTACHED) {
- printf("rc%d: bogus interrupt\n", unit);
- return;
- }
- nec = rcb->rcb_addr;
-
- bsr = ~(rcin(RC_BSR));
-
- if (!(bsr & (RC_BSR_TOUT|RC_BSR_RXINT|RC_BSR_TXINT|RC_BSR_MOINT))) {
- printf("rc%d: extra interrupt\n", unit);
- rcout(CD180_EOIR, 0);
- return;
- }
-
- while (bsr & (RC_BSR_TOUT|RC_BSR_RXINT|RC_BSR_TXINT|RC_BSR_MOINT)) {
-#ifdef RCDEBUG_DETAILED
- printf("rc%d: intr (%02x) %s%s%s%s\n", unit, bsr,
- (bsr & RC_BSR_TOUT)?"TOUT ":"",
- (bsr & RC_BSR_RXINT)?"RXINT ":"",
- (bsr & RC_BSR_TXINT)?"TXINT ":"",
- (bsr & RC_BSR_MOINT)?"MOINT":"");
-#endif
- if (bsr & RC_BSR_TOUT) {
- printf("rc%d: hardware failure, reset board\n", unit);
- rcout(RC_CTOUT, 0);
- rc_reinit(rcb);
- return;
- }
- if (bsr & RC_BSR_RXINT) {
- iack = rcin(RC_PILR_RX);
- good_data = (iack == (GIVR_IT_RGDI | RC_FAKEID));
- if (!good_data && iack != (GIVR_IT_REI | RC_FAKEID)) {
- printf("rc%d: fake rxint: %02x\n", unit, iack);
- goto more_intrs;
- }
- rc = rcb->rcb_baserc + ((rcin(CD180_GICR) & GICR_CHAN) >> GICR_LSH);
- t_state = rc->rc_tp->t_state;
- /* Do RTS flow control stuff */
- if ( (rc->rc_flags & RC_RTSFLOW)
- || !(t_state & TS_ISOPEN)
- ) {
- if ( ( !(t_state & TS_ISOPEN)
- || (t_state & TS_TBLOCK)
- )
- && (rc->rc_msvr & MSVR_RTS)
- )
- rcout(CD180_MSVR,
- rc->rc_msvr &= ~MSVR_RTS);
- else if (!(rc->rc_msvr & MSVR_RTS))
- rcout(CD180_MSVR,
- rc->rc_msvr |= MSVR_RTS);
- }
- ucnt = rcin(CD180_RDCR) & 0xF;
- resid = 0;
-
- if (t_state & TS_ISOPEN) {
- /* check for input buffer overflow */
- if ((rc->rc_iptr + ucnt) >= rc->rc_bufend) {
- resid = ucnt;
- ucnt = rc->rc_bufend - rc->rc_iptr;
- resid -= ucnt;
- if (!(rc->rc_flags & RC_WAS_BUFOVFL)) {
- rc->rc_flags |= RC_WAS_BUFOVFL;
- rc_scheduled_event++;
- }
- }
- optr = rc->rc_iptr;
- /* check foor good data */
- if (good_data) {
- while (ucnt-- > 0) {
- val = rcin(CD180_RDR);
- optr[0] = val;
- optr[INPUT_FLAGS_SHIFT] = 0;
- optr++;
- rc_scheduled_event++;
- if (val != 0 && val == rc->rc_hotchar)
- setsofttty();
- }
- } else {
- /* Store also status data */
- while (ucnt-- > 0) {
- iack = rcin(CD180_RCSR);
- if (iack & RCSR_Timeout)
- break;
- if ( (iack & RCSR_OE)
- && !(rc->rc_flags & RC_WAS_SILOVFL)) {
- rc->rc_flags |= RC_WAS_SILOVFL;
- rc_scheduled_event++;
- }
- val = rcin(CD180_RDR);
- /*
- Don't store PE if IGNPAR and BREAK if IGNBRK,
- this hack allows "raw" tty optimization
- works even if IGN* is set.
- */
- if ( !(iack & (RCSR_PE|RCSR_FE|RCSR_Break))
- || ((!(iack & (RCSR_PE|RCSR_FE))
- || !(rc->rc_tp->t_iflag & IGNPAR))
- && (!(iack & RCSR_Break)
- || !(rc->rc_tp->t_iflag & IGNBRK)))) {
- if ( (iack & (RCSR_PE|RCSR_FE))
- && (t_state & TS_CAN_BYPASS_L_RINT)
- && ((iack & RCSR_FE)
- || ((iack & RCSR_PE)
- && (rc->rc_tp->t_iflag & INPCK))))
- val = 0;
- else if (val != 0 && val == rc->rc_hotchar)
- setsofttty();
- optr[0] = val;
- optr[INPUT_FLAGS_SHIFT] = iack;
- optr++;
- rc_scheduled_event++;
- }
- }
- }
- rc->rc_iptr = optr;
- rc->rc_flags |= RC_DORXFER;
- } else
- resid = ucnt;
- /* Clear FIFO if necessary */
- while (resid-- > 0) {
- if (!good_data)
- iack = rcin(CD180_RCSR);
- else
- iack = 0;
- if (iack & RCSR_Timeout)
- break;
- (void) rcin(CD180_RDR);
- }
- goto more_intrs;
- }
- if (bsr & RC_BSR_MOINT) {
- iack = rcin(RC_PILR_MODEM);
- if (iack != (GIVR_IT_MSCI | RC_FAKEID)) {
- printf("rc%d: fake moint: %02x\n", unit, iack);
- goto more_intrs;
- }
- rc = rcb->rcb_baserc + ((rcin(CD180_GICR) & GICR_CHAN) >> GICR_LSH);
- iack = rcin(CD180_MCR);
- rc->rc_msvr = rcin(CD180_MSVR);
- rcout(CD180_MCR, 0);
-#ifdef RCDEBUG
- printrcflags(rc, "moint");
-#endif
- if (rc->rc_flags & RC_CTSFLOW) {
- if (rc->rc_msvr & MSVR_CTS)
- rc->rc_flags |= RC_SEND_RDY;
- else
- rc->rc_flags &= ~RC_SEND_RDY;
- } else
- rc->rc_flags |= RC_SEND_RDY;
- if ((iack & MCR_CDchg) && !(rc->rc_flags & RC_MODCHG)) {
- rc_scheduled_event += LOTS_OF_EVENTS;
- rc->rc_flags |= RC_MODCHG;
- setsofttty();
- }
- goto more_intrs;
- }
- if (bsr & RC_BSR_TXINT) {
- iack = rcin(RC_PILR_TX);
- if (iack != (GIVR_IT_TDI | RC_FAKEID)) {
- printf("rc%d: fake txint: %02x\n", unit, iack);
- goto more_intrs;
- }
- rc = rcb->rcb_baserc + ((rcin(CD180_GICR) & GICR_CHAN) >> GICR_LSH);
- if ( (rc->rc_flags & RC_OSUSP)
- || !(rc->rc_flags & RC_SEND_RDY)
- )
- goto more_intrs;
- /* Handle breaks and other stuff */
- if (rc->rc_pendcmd) {
- rcout(CD180_COR2, rc->rc_cor2 |= COR2_ETC);
- rcout(CD180_TDR, CD180_C_ESC);
- rcout(CD180_TDR, rc->rc_pendcmd);
- rcout(CD180_COR2, rc->rc_cor2 &= ~COR2_ETC);
- rc->rc_pendcmd = 0;
- goto more_intrs;
- }
- optr = rc->rc_optr;
- resid = rc->rc_obufend - optr;
- if (resid > CD180_NFIFO)
- resid = CD180_NFIFO;
- while (resid-- > 0)
- rcout(CD180_TDR, *optr++);
- rc->rc_optr = optr;
-
- /* output completed? */
- if (optr >= rc->rc_obufend) {
- rcout(CD180_IER, rc->rc_ier &= ~IER_TxRdy);
-#ifdef RCDEBUG
- printf("rc%d/%d: output completed\n", unit, rc->rc_chan);
-#endif
- if (!(rc->rc_flags & RC_DOXXFER)) {
- rc_scheduled_event += LOTS_OF_EVENTS;
- rc->rc_flags |= RC_DOXXFER;
- setsofttty();
- }
- }
- }
- more_intrs:
- rcout(CD180_EOIR, 0); /* end of interrupt */
- rcout(RC_CTOUT, 0);
- bsr = ~(rcin(RC_BSR));
- }
-}
-
-/* Feed characters to output buffer */
-static void rc_start(tp)
-register struct tty *tp;
-{
- register struct rc_chans *rc = &rc_chans[GET_UNIT(tp->t_dev)];
- register int nec = rc->rc_rcb->rcb_addr, s;
-
- if (rc->rc_flags & RC_OSBUSY)
- return;
- s = spltty();
- rc->rc_flags |= RC_OSBUSY;
- disable_intr();
- if (tp->t_state & TS_TTSTOP)
- rc->rc_flags |= RC_OSUSP;
- else
- rc->rc_flags &= ~RC_OSUSP;
- /* Do RTS flow control stuff */
- if ( (rc->rc_flags & RC_RTSFLOW)
- && (tp->t_state & TS_TBLOCK)
- && (rc->rc_msvr & MSVR_RTS)
- ) {
- rcout(CD180_CAR, rc->rc_chan);
- rcout(CD180_MSVR, rc->rc_msvr &= ~MSVR_RTS);
- } else if (!(rc->rc_msvr & MSVR_RTS)) {
- rcout(CD180_CAR, rc->rc_chan);
- rcout(CD180_MSVR, rc->rc_msvr |= MSVR_RTS);
- }
- enable_intr();
- if (tp->t_state & (TS_TIMEOUT|TS_TTSTOP))
- goto out;
-#ifdef RCDEBUG
- printrcflags(rc, "rcstart");
-#endif
- ttwwakeup(tp);
-#ifdef RCDEBUG
- printf("rcstart: outq = %d obuf = %d\n",
- tp->t_outq.c_cc, rc->rc_obufend - rc->rc_optr);
-#endif
- if (tp->t_state & TS_BUSY)
- goto out; /* output still in progress ... */
-
- if (tp->t_outq.c_cc > 0) {
- u_int ocnt;
-
- tp->t_state |= TS_BUSY;
- ocnt = q_to_b(&tp->t_outq, rc->rc_obuf, sizeof rc->rc_obuf);
- disable_intr();
- rc->rc_optr = rc->rc_obuf;
- rc->rc_obufend = rc->rc_optr + ocnt;
- enable_intr();
- if (!(rc->rc_ier & IER_TxRdy)) {
-#ifdef RCDEBUG
- printf("rc%d/%d: rcstart enable txint\n", rc->rc_rcb->rcb_unit, rc->rc_chan);
-#endif
- rcout(CD180_CAR, rc->rc_chan);
- rcout(CD180_IER, rc->rc_ier |= IER_TxRdy);
- }
- }
-out:
- rc->rc_flags &= ~RC_OSBUSY;
- (void) splx(s);
-}
-
-/* Handle delayed events. */
-void rcpoll()
-{
- register struct rc_chans *rc;
- register struct rc_softc *rcb;
- register u_char *tptr, *eptr;
- register struct tty *tp;
- register int chan, icnt, nec, unit;
-
- if (rc_scheduled_event == 0)
- return;
-repeat:
- for (unit = 0; unit < NRC; unit++) {
- rcb = &rc_softc[unit];
- rc = rcb->rcb_baserc;
- nec = rc->rc_rcb->rcb_addr;
- for (chan = 0; chan < CD180_NCHAN; rc++, chan++) {
- tp = rc->rc_tp;
-#ifdef RCDEBUG
- if (rc->rc_flags & (RC_DORXFER|RC_DOXXFER|RC_MODCHG|
- RC_WAS_BUFOVFL|RC_WAS_SILOVFL))
- printrcflags(rc, "rcevent");
-#endif
- if (rc->rc_flags & RC_WAS_BUFOVFL) {
- disable_intr();
- rc->rc_flags &= ~RC_WAS_BUFOVFL;
- rc_scheduled_event--;
- enable_intr();
- printf("rc%d/%d: interrupt-level buffer overflow\n",
- unit, chan);
- }
- if (rc->rc_flags & RC_WAS_SILOVFL) {
- disable_intr();
- rc->rc_flags &= ~RC_WAS_SILOVFL;
- rc_scheduled_event--;
- enable_intr();
- printf("rc%d/%d: silo overflow\n",
- unit, chan);
- }
- if (rc->rc_flags & RC_MODCHG) {
- disable_intr();
- rc->rc_flags &= ~RC_MODCHG;
- rc_scheduled_event -= LOTS_OF_EVENTS;
- enable_intr();
- (*linesw[tp->t_line].l_modem)(tp, !!(rc->rc_msvr & MSVR_CD));
- }
- if (rc->rc_flags & RC_DORXFER) {
- disable_intr();
- rc->rc_flags &= ~RC_DORXFER;
- eptr = rc->rc_iptr;
- if (rc->rc_bufend == &rc->rc_ibuf[2 * RC_IBUFSIZE])
- tptr = &rc->rc_ibuf[RC_IBUFSIZE];
- else
- tptr = rc->rc_ibuf;
- icnt = eptr - tptr;
- if (icnt > 0) {
- if (rc->rc_bufend == &rc->rc_ibuf[2 * RC_IBUFSIZE]) {
- rc->rc_iptr = rc->rc_ibuf;
- rc->rc_bufend = &rc->rc_ibuf[RC_IBUFSIZE];
- rc->rc_hiwat = &rc->rc_ibuf[RC_IHIGHWATER];
- } else {
- rc->rc_iptr = &rc->rc_ibuf[RC_IBUFSIZE];
- rc->rc_bufend = &rc->rc_ibuf[2 * RC_IBUFSIZE];
- rc->rc_hiwat =
- &rc->rc_ibuf[RC_IBUFSIZE + RC_IHIGHWATER];
- }
- if ( (rc->rc_flags & RC_RTSFLOW)
- && (tp->t_state & TS_ISOPEN)
- && !(tp->t_state & TS_TBLOCK)
- && !(rc->rc_msvr & MSVR_RTS)
- ) {
- rcout(CD180_CAR, chan);
- rcout(CD180_MSVR,
- rc->rc_msvr |= MSVR_RTS);
- }
- rc_scheduled_event -= icnt;
- }
- enable_intr();
-
- if (icnt <= 0 || !(tp->t_state & TS_ISOPEN))
- goto done1;
-
- if ( (tp->t_state & TS_CAN_BYPASS_L_RINT)
- && !(tp->t_state & TS_LOCAL)) {
- if ((tp->t_rawq.c_cc + icnt) >= RB_I_HIGH_WATER
- && ((rc->rc_flags & RC_RTSFLOW) || (tp->t_iflag & IXOFF))
- && !(tp->t_state & TS_TBLOCK))
- ttyblock(tp);
- tk_nin += icnt;
- tk_rawcc += icnt;
- tp->t_rawcc += icnt;
- if (b_to_q(tptr, icnt, &tp->t_rawq))
- printf("rc%d/%d: tty-level buffer overflow\n",
- unit, chan);
- ttwakeup(tp);
- if ((tp->t_state & TS_TTSTOP) && ((tp->t_iflag & IXANY)
- || (tp->t_cc[VSTART] == tp->t_cc[VSTOP]))) {
- tp->t_state &= ~TS_TTSTOP;
- tp->t_lflag &= ~FLUSHO;
- rc_start(tp);
- }
- } else {
- for (; tptr < eptr; tptr++)
- (*linesw[tp->t_line].l_rint)
- (tptr[0] |
- rc_rcsrt[tptr[INPUT_FLAGS_SHIFT] & 0xF], tp);
- }
-done1: ;
- }
- if (rc->rc_flags & RC_DOXXFER) {
- disable_intr();
- rc_scheduled_event -= LOTS_OF_EVENTS;
- rc->rc_flags &= ~RC_DOXXFER;
- rc->rc_tp->t_state &= ~TS_BUSY;
- enable_intr();
- (*linesw[tp->t_line].l_start)(tp);
- }
- }
- if (rc_scheduled_event == 0)
- break;
- }
- if (rc_scheduled_event >= LOTS_OF_EVENTS)
- goto repeat;
-}
-
-static void
-rc_stop(tp, rw)
- register struct tty *tp;
- int rw;
-{
- register struct rc_chans *rc = &rc_chans[GET_UNIT(tp->t_dev)];
- u_char *tptr, *eptr;
-
-#ifdef RCDEBUG
- printf("rc%d/%d: rc_stop %s%s\n", rc->rc_rcb->rcb_unit, rc->rc_chan,
- (rw & FWRITE)?"FWRITE ":"", (rw & FREAD)?"FREAD":"");
-#endif
- if (rw & FWRITE)
- rc_discard_output(rc);
- disable_intr();
- if (rw & FREAD) {
- rc->rc_flags &= ~RC_DORXFER;
- eptr = rc->rc_iptr;
- if (rc->rc_bufend == &rc->rc_ibuf[2 * RC_IBUFSIZE]) {
- tptr = &rc->rc_ibuf[RC_IBUFSIZE];
- rc->rc_iptr = &rc->rc_ibuf[RC_IBUFSIZE];
- } else {
- tptr = rc->rc_ibuf;
- rc->rc_iptr = rc->rc_ibuf;
- }
- rc_scheduled_event -= eptr - tptr;
- }
- if (tp->t_state & TS_TTSTOP)
- rc->rc_flags |= RC_OSUSP;
- else
- rc->rc_flags &= ~RC_OSUSP;
- enable_intr();
-}
-
-static int
-rcopen(dev, flag, mode, p)
- dev_t dev;
- int flag, mode;
- struct proc *p;
-{
- register struct rc_chans *rc;
- register struct tty *tp;
- int unit, nec, s, error = 0;
-
- unit = GET_UNIT(dev);
- if (unit >= NRC * CD180_NCHAN)
- return ENXIO;
- if (rc_softc[unit / CD180_NCHAN].rcb_probed != RC_ATTACHED)
- return ENXIO;
- rc = &rc_chans[unit];
- tp = rc->rc_tp;
- dev->si_tty = tp;
- nec = rc->rc_rcb->rcb_addr;
-#ifdef RCDEBUG
- printf("rc%d/%d: rcopen: dev %x\n", rc->rc_rcb->rcb_unit, unit, dev);
-#endif
- s = spltty();
-
-again:
- while (rc->rc_flags & RC_DTR_OFF) {
- error = tsleep(&(rc->rc_dtrwait), TTIPRI | PCATCH, "rcdtr", 0);
- if (error != 0)
- goto out;
- }
- if (tp->t_state & TS_ISOPEN) {
- if (CALLOUT(dev)) {
- if (!(rc->rc_flags & RC_ACTOUT)) {
- error = EBUSY;
- goto out;
- }
- } else {
- if (rc->rc_flags & RC_ACTOUT) {
- if (flag & O_NONBLOCK) {
- error = EBUSY;
- goto out;
- }
- error = tsleep(&rc->rc_rcb,
- TTIPRI|PCATCH, "rcbi", 0);
- if (error)
- goto out;
- goto again;
- }
- }
- if (tp->t_state & TS_XCLUDE &&
- suser(p)) {
- error = EBUSY;
- goto out;
- }
- } else {
- tp->t_oproc = rc_start;
- tp->t_param = rc_param;
- tp->t_stop = rc_stop;
- tp->t_dev = dev;
-
- if (CALLOUT(dev))
- tp->t_cflag |= CLOCAL;
- else
- tp->t_cflag &= ~CLOCAL;
-
- error = rc_param(tp, &tp->t_termios);
- if (error)
- goto out;
- (void) rc_modctl(rc, TIOCM_RTS|TIOCM_DTR, DMSET);
-
- if ((rc->rc_msvr & MSVR_CD) || CALLOUT(dev))
- (*linesw[tp->t_line].l_modem)(tp, 1);
- }
- if (!(tp->t_state & TS_CARR_ON) && !CALLOUT(dev)
- && !(tp->t_cflag & CLOCAL) && !(flag & O_NONBLOCK)) {
- rc->rc_dcdwaits++;
- error = tsleep(TSA_CARR_ON(tp), TTIPRI | PCATCH, "rcdcd", 0);
- rc->rc_dcdwaits--;
- if (error != 0)
- goto out;
- goto again;
- }
- error = (*linesw[tp->t_line].l_open)(dev, tp);
- disc_optim(tp, &tp->t_termios, rc);
- if ((tp->t_state & TS_ISOPEN) && CALLOUT(dev))
- rc->rc_flags |= RC_ACTOUT;
-out:
- (void) splx(s);
-
- if(rc->rc_dcdwaits == 0 && !(tp->t_state & TS_ISOPEN))
- rc_hardclose(rc);
-
- return error;
-}
-
-static int
-rcclose(dev, flag, mode, p)
- dev_t dev;
- int flag, mode;
- struct proc *p;
-{
- register struct rc_chans *rc;
- register struct tty *tp;
- int s, unit = GET_UNIT(dev);
-
- if (unit >= NRC * CD180_NCHAN)
- return ENXIO;
- rc = &rc_chans[unit];
- tp = rc->rc_tp;
-#ifdef RCDEBUG
- printf("rc%d/%d: rcclose dev %x\n", rc->rc_rcb->rcb_unit, unit, dev);
-#endif
- s = spltty();
- (*linesw[tp->t_line].l_close)(tp, flag);
- disc_optim(tp, &tp->t_termios, rc);
- rc_stop(tp, FREAD | FWRITE);
- rc_hardclose(rc);
- ttyclose(tp);
- splx(s);
- return 0;
-}
-
-static void rc_hardclose(rc)
-register struct rc_chans *rc;
-{
- register int s, nec = rc->rc_rcb->rcb_addr;
- register struct tty *tp = rc->rc_tp;
-
- s = spltty();
- rcout(CD180_CAR, rc->rc_chan);
-
- /* Disable rx/tx intrs */
- rcout(CD180_IER, rc->rc_ier = 0);
- if ( (tp->t_cflag & HUPCL)
- || (!(rc->rc_flags & RC_ACTOUT)
- && !(rc->rc_msvr & MSVR_CD)
- && !(tp->t_cflag & CLOCAL))
- || !(tp->t_state & TS_ISOPEN)
- ) {
- CCRCMD(rc->rc_rcb->rcb_unit, rc->rc_chan, CCR_ResetChan);
- WAITFORCCR(rc->rc_rcb->rcb_unit, rc->rc_chan);
- (void) rc_modctl(rc, TIOCM_RTS, DMSET);
- if (rc->rc_dtrwait) {
- timeout(rc_dtrwakeup, rc, rc->rc_dtrwait);
- rc->rc_flags |= RC_DTR_OFF;
- }
- }
- rc->rc_flags &= ~RC_ACTOUT;
- wakeup((caddr_t) &rc->rc_rcb); /* wake bi */
- wakeup(TSA_CARR_ON(tp));
- (void) splx(s);
-}
-
-/* Reset the bastard */
-static void rc_hwreset(unit, nec, chipid)
- register int unit, nec;
- unsigned int chipid;
-{
- CCRCMD(unit, -1, CCR_HWRESET); /* Hardware reset */
- DELAY(20000);
- WAITFORCCR(unit, -1);
-
- rcout(RC_CTOUT, 0); /* Clear timeout */
- rcout(CD180_GIVR, chipid);
- rcout(CD180_GICR, 0);
-
- /* Set Prescaler Registers (1 msec) */
- rcout(CD180_PPRL, ((RC_OSCFREQ + 999) / 1000) & 0xFF);
- rcout(CD180_PPRH, ((RC_OSCFREQ + 999) / 1000) >> 8);
-
- /* Initialize Priority Interrupt Level Registers */
- rcout(CD180_PILR1, RC_PILR_MODEM);
- rcout(CD180_PILR2, RC_PILR_TX);
- rcout(CD180_PILR3, RC_PILR_RX);
-
- /* Reset DTR */
- rcout(RC_DTREG, ~0);
-}
-
-/* Set channel parameters */
-static int rc_param(tp, ts)
- register struct tty *tp;
- struct termios *ts;
-{
- register struct rc_chans *rc = &rc_chans[GET_UNIT(tp->t_dev)];
- register int nec = rc->rc_rcb->rcb_addr;
- int idivs, odivs, s, val, cflag, iflag, lflag, inpflow;
-
- if ( ts->c_ospeed < 0 || ts->c_ospeed > 76800
- || ts->c_ispeed < 0 || ts->c_ispeed > 76800
- )
- return (EINVAL);
- if (ts->c_ispeed == 0)
- ts->c_ispeed = ts->c_ospeed;
- odivs = RC_BRD(ts->c_ospeed);
- idivs = RC_BRD(ts->c_ispeed);
-
- s = spltty();
-
- /* Select channel */
- rcout(CD180_CAR, rc->rc_chan);
-
- /* If speed == 0, hangup line */
- if (ts->c_ospeed == 0) {
- CCRCMD(rc->rc_rcb->rcb_unit, rc->rc_chan, CCR_ResetChan);
- WAITFORCCR(rc->rc_rcb->rcb_unit, rc->rc_chan);
- (void) rc_modctl(rc, TIOCM_DTR, DMBIC);
- }
-
- tp->t_state &= ~TS_CAN_BYPASS_L_RINT;
- cflag = ts->c_cflag;
- iflag = ts->c_iflag;
- lflag = ts->c_lflag;
-
- if (idivs > 0) {
- rcout(CD180_RBPRL, idivs & 0xFF);
- rcout(CD180_RBPRH, idivs >> 8);
- }
- if (odivs > 0) {
- rcout(CD180_TBPRL, odivs & 0xFF);
- rcout(CD180_TBPRH, odivs >> 8);
- }
-
- /* set timeout value */
- if (ts->c_ispeed > 0) {
- int itm = ts->c_ispeed > 2400 ? 5 : 10000 / ts->c_ispeed + 1;
-
- if ( !(lflag & ICANON)
- && ts->c_cc[VMIN] != 0 && ts->c_cc[VTIME] != 0
- && ts->c_cc[VTIME] * 10 > itm)
- itm = ts->c_cc[VTIME] * 10;
-
- rcout(CD180_RTPR, itm <= 255 ? itm : 255);
- }
-
- switch (cflag & CSIZE) {
- case CS5: val = COR1_5BITS; break;
- case CS6: val = COR1_6BITS; break;
- case CS7: val = COR1_7BITS; break;
- default:
- case CS8: val = COR1_8BITS; break;
- }
- if (cflag & PARENB) {
- val |= COR1_NORMPAR;
- if (cflag & PARODD)
- val |= COR1_ODDP;
- if (!(cflag & INPCK))
- val |= COR1_Ignore;
- } else
- val |= COR1_Ignore;
- if (cflag & CSTOPB)
- val |= COR1_2SB;
- rcout(CD180_COR1, val);
-
- /* Set FIFO threshold */
- val = ts->c_ospeed <= 4800 ? 1 : CD180_NFIFO / 2;
- inpflow = 0;
- if ( (iflag & IXOFF)
- && ( ts->c_cc[VSTOP] != _POSIX_VDISABLE
- && ( ts->c_cc[VSTART] != _POSIX_VDISABLE
- || (iflag & IXANY)
- )
- )
- ) {
- inpflow = 1;
- val |= COR3_SCDE|COR3_FCT;
- }
- rcout(CD180_COR3, val);
-
- /* Initialize on-chip automatic flow control */
- val = 0;
- rc->rc_flags &= ~(RC_CTSFLOW|RC_SEND_RDY);
- if (cflag & CCTS_OFLOW) {
- rc->rc_flags |= RC_CTSFLOW;
- val |= COR2_CtsAE;
- } else
- rc->rc_flags |= RC_SEND_RDY;
- if (tp->t_state & TS_TTSTOP)
- rc->rc_flags |= RC_OSUSP;
- else
- rc->rc_flags &= ~RC_OSUSP;
- if (cflag & CRTS_IFLOW)
- rc->rc_flags |= RC_RTSFLOW;
- else
- rc->rc_flags &= ~RC_RTSFLOW;
-
- if (inpflow) {
- if (ts->c_cc[VSTART] != _POSIX_VDISABLE)
- rcout(CD180_SCHR1, ts->c_cc[VSTART]);
- rcout(CD180_SCHR2, ts->c_cc[VSTOP]);
- val |= COR2_TxIBE;
- if (iflag & IXANY)
- val |= COR2_IXM;
- }
-
- rcout(CD180_COR2, rc->rc_cor2 = val);
-
- CCRCMD(rc->rc_rcb->rcb_unit, rc->rc_chan,
- CCR_CORCHG1 | CCR_CORCHG2 | CCR_CORCHG3);
-
- disc_optim(tp, ts, rc);
-
- /* modem ctl */
- val = cflag & CLOCAL ? 0 : MCOR1_CDzd;
- if (cflag & CCTS_OFLOW)
- val |= MCOR1_CTSzd;
- rcout(CD180_MCOR1, val);
-
- val = cflag & CLOCAL ? 0 : MCOR2_CDod;
- if (cflag & CCTS_OFLOW)
- val |= MCOR2_CTSod;
- rcout(CD180_MCOR2, val);
-
- /* enable i/o and interrupts */
- CCRCMD(rc->rc_rcb->rcb_unit, rc->rc_chan,
- CCR_XMTREN | ((cflag & CREAD) ? CCR_RCVREN : CCR_RCVRDIS));
- WAITFORCCR(rc->rc_rcb->rcb_unit, rc->rc_chan);
-
- rc->rc_ier = cflag & CLOCAL ? 0 : IER_CD;
- if (cflag & CCTS_OFLOW)
- rc->rc_ier |= IER_CTS;
- if (cflag & CREAD)
- rc->rc_ier |= IER_RxData;
- if (tp->t_state & TS_BUSY)
- rc->rc_ier |= IER_TxRdy;
- if (ts->c_ospeed != 0)
- rc_modctl(rc, TIOCM_DTR, DMBIS);
- if ((cflag & CCTS_OFLOW) && (rc->rc_msvr & MSVR_CTS))
- rc->rc_flags |= RC_SEND_RDY;
- rcout(CD180_IER, rc->rc_ier);
- (void) splx(s);
- return 0;
-}
-
-/* Re-initialize board after bogus interrupts */
-static void rc_reinit(rcb)
-struct rc_softc *rcb;
-{
- register struct rc_chans *rc, *rce;
- register int nec;
-
- nec = rcb->rcb_addr;
- rc_hwreset(rcb->rcb_unit, nec, RC_FAKEID);
- rc = &rc_chans[rcb->rcb_unit * CD180_NCHAN];
- rce = rc + CD180_NCHAN;
- for (; rc < rce; rc++)
- (void) rc_param(rc->rc_tp, &rc->rc_tp->t_termios);
-}
-
-static int
-rcioctl(dev, cmd, data, flag, p)
-dev_t dev;
-u_long cmd;
-int flag;
-caddr_t data;
-struct proc *p;
-{
- register struct rc_chans *rc = &rc_chans[GET_UNIT(dev)];
- register int s, error;
- struct tty *tp = rc->rc_tp;
-
- error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p);
- if (error != ENOIOCTL)
- return (error);
- error = ttioctl(tp, cmd, data, flag);
- disc_optim(tp, &tp->t_termios, rc);
- if (error != ENOIOCTL)
- return (error);
- s = spltty();
-
- switch (cmd) {
- case TIOCSBRK:
- rc->rc_pendcmd = CD180_C_SBRK;
- break;
-
- case TIOCCBRK:
- rc->rc_pendcmd = CD180_C_EBRK;
- break;
-
- case TIOCSDTR:
- (void) rc_modctl(rc, TIOCM_DTR, DMBIS);
- break;
-
- case TIOCCDTR:
- (void) rc_modctl(rc, TIOCM_DTR, DMBIC);
- break;
-
- case TIOCMGET:
- *(int *) data = rc_modctl(rc, 0, DMGET);
- break;
-
- case TIOCMSET:
- (void) rc_modctl(rc, *(int *) data, DMSET);
- break;
-
- case TIOCMBIC:
- (void) rc_modctl(rc, *(int *) data, DMBIC);
- break;
-
- case TIOCMBIS:
- (void) rc_modctl(rc, *(int *) data, DMBIS);
- break;
-
- case TIOCMSDTRWAIT:
- error = suser(p);
- if (error != 0) {
- splx(s);
- return (error);
- }
- rc->rc_dtrwait = *(int *)data * hz / 100;
- break;
-
- case TIOCMGDTRWAIT:
- *(int *)data = rc->rc_dtrwait * 100 / hz;
- break;
-
- default:
- (void) splx(s);
- return ENOTTY;
- }
- (void) splx(s);
- return 0;
-}
-
-
-/* Modem control routines */
-
-static int rc_modctl(rc, bits, cmd)
-register struct rc_chans *rc;
-int bits, cmd;
-{
- register int nec = rc->rc_rcb->rcb_addr;
- u_char *dtr = &rc->rc_rcb->rcb_dtr, msvr;
-
- rcout(CD180_CAR, rc->rc_chan);
-
- switch (cmd) {
- case DMSET:
- rcout(RC_DTREG, (bits & TIOCM_DTR) ?
- ~(*dtr |= 1 << rc->rc_chan) :
- ~(*dtr &= ~(1 << rc->rc_chan)));
- msvr = rcin(CD180_MSVR);
- if (bits & TIOCM_RTS)
- msvr |= MSVR_RTS;
- else
- msvr &= ~MSVR_RTS;
- if (bits & TIOCM_DTR)
- msvr |= MSVR_DTR;
- else
- msvr &= ~MSVR_DTR;
- rcout(CD180_MSVR, msvr);
- break;
-
- case DMBIS:
- if (bits & TIOCM_DTR)
- rcout(RC_DTREG, ~(*dtr |= 1 << rc->rc_chan));
- msvr = rcin(CD180_MSVR);
- if (bits & TIOCM_RTS)
- msvr |= MSVR_RTS;
- if (bits & TIOCM_DTR)
- msvr |= MSVR_DTR;
- rcout(CD180_MSVR, msvr);
- break;
-
- case DMGET:
- bits = TIOCM_LE;
- msvr = rc->rc_msvr = rcin(CD180_MSVR);
-
- if (msvr & MSVR_RTS)
- bits |= TIOCM_RTS;
- if (msvr & MSVR_CTS)
- bits |= TIOCM_CTS;
- if (msvr & MSVR_DSR)
- bits |= TIOCM_DSR;
- if (msvr & MSVR_DTR)
- bits |= TIOCM_DTR;
- if (msvr & MSVR_CD)
- bits |= TIOCM_CD;
- if (~rcin(RC_RIREG) & (1 << rc->rc_chan))
- bits |= TIOCM_RI;
- return bits;
-
- case DMBIC:
- if (bits & TIOCM_DTR)
- rcout(RC_DTREG, ~(*dtr &= ~(1 << rc->rc_chan)));
- msvr = rcin(CD180_MSVR);
- if (bits & TIOCM_RTS)
- msvr &= ~MSVR_RTS;
- if (bits & TIOCM_DTR)
- msvr &= ~MSVR_DTR;
- rcout(CD180_MSVR, msvr);
- break;
- }
- rc->rc_msvr = rcin(CD180_MSVR);
- return 0;
-}
-
-/* Test the board. */
-int rc_test(nec, unit)
- register int nec;
- int unit;
-{
- int chan = 0;
- int i = 0, rcnt, old_level;
- unsigned int iack, chipid;
- unsigned short divs;
- static u_char ctest[] = "\377\125\252\045\244\0\377";
-#define CTLEN 8
-#define ERR(s) { \
- printf("rc%d: ", unit); printf s ; printf("\n"); \
- (void) splx(old_level); return 1; }
-
- struct rtest {
- u_char txbuf[CD180_NFIFO]; /* TX buffer */
- u_char rxbuf[CD180_NFIFO]; /* RX buffer */
- int rxptr; /* RX pointer */
- int txptr; /* TX pointer */
- } tchans[CD180_NCHAN];
-
- old_level = spltty();
-
- chipid = RC_FAKEID;
-
- /* First, reset board to inital state */
- rc_hwreset(unit, nec, chipid);
-
- divs = RC_BRD(19200);
-
- /* Initialize channels */
- for (chan = 0; chan < CD180_NCHAN; chan++) {
-
- /* Select and reset channel */
- rcout(CD180_CAR, chan);
- CCRCMD(unit, chan, CCR_ResetChan);
- WAITFORCCR(unit, chan);
-
- /* Set speed */
- rcout(CD180_RBPRL, divs & 0xFF);
- rcout(CD180_RBPRH, divs >> 8);
- rcout(CD180_TBPRL, divs & 0xFF);
- rcout(CD180_TBPRH, divs >> 8);
-
- /* set timeout value */
- rcout(CD180_RTPR, 0);
-
- /* Establish local loopback */
- rcout(CD180_COR1, COR1_NOPAR | COR1_8BITS | COR1_1SB);
- rcout(CD180_COR2, COR2_LLM);
- rcout(CD180_COR3, CD180_NFIFO);
- CCRCMD(unit, chan, CCR_CORCHG1 | CCR_CORCHG2 | CCR_CORCHG3);
- CCRCMD(unit, chan, CCR_RCVREN | CCR_XMTREN);
- WAITFORCCR(unit, chan);
- rcout(CD180_MSVR, MSVR_RTS);
-
- /* Fill TXBUF with test data */
- for (i = 0; i < CD180_NFIFO; i++) {
- tchans[chan].txbuf[i] = ctest[i];
- tchans[chan].rxbuf[i] = 0;
- }
- tchans[chan].txptr = tchans[chan].rxptr = 0;
-
- /* Now, start transmit */
- rcout(CD180_IER, IER_TxMpty|IER_RxData);
- }
- /* Pseudo-interrupt poll stuff */
- for (rcnt = 10000; rcnt-- > 0; rcnt--) {
- i = ~(rcin(RC_BSR));
- if (i & RC_BSR_TOUT)
- ERR(("BSR timeout bit set\n"))
- else if (i & RC_BSR_TXINT) {
- iack = rcin(RC_PILR_TX);
- if (iack != (GIVR_IT_TDI | chipid))
- ERR(("Bad TX intr ack (%02x != %02x)\n",
- iack, GIVR_IT_TDI | chipid));
- chan = (rcin(CD180_GICR) & GICR_CHAN) >> GICR_LSH;
- /* If no more data to transmit, disable TX intr */
- if (tchans[chan].txptr >= CD180_NFIFO) {
- iack = rcin(CD180_IER);
- rcout(CD180_IER, iack & ~IER_TxMpty);
- } else {
- for (iack = tchans[chan].txptr;
- iack < CD180_NFIFO; iack++)
- rcout(CD180_TDR,
- tchans[chan].txbuf[iack]);
- tchans[chan].txptr = iack;
- }
- rcout(CD180_EOIR, 0);
- } else if (i & RC_BSR_RXINT) {
- u_char ucnt;
-
- iack = rcin(RC_PILR_RX);
- if (iack != (GIVR_IT_RGDI | chipid) &&
- iack != (GIVR_IT_REI | chipid))
- ERR(("Bad RX intr ack (%02x != %02x)\n",
- iack, GIVR_IT_RGDI | chipid))
- chan = (rcin(CD180_GICR) & GICR_CHAN) >> GICR_LSH;
- ucnt = rcin(CD180_RDCR) & 0xF;
- while (ucnt-- > 0) {
- iack = rcin(CD180_RCSR);
- if (iack & RCSR_Timeout)
- break;
- if (iack & 0xF)
- ERR(("Bad char chan %d (RCSR = %02X)\n",
- chan, iack))
- if (tchans[chan].rxptr > CD180_NFIFO)
- ERR(("Got extra chars chan %d\n",
- chan))
- tchans[chan].rxbuf[tchans[chan].rxptr++] =
- rcin(CD180_RDR);
- }
- rcout(CD180_EOIR, 0);
- }
- rcout(RC_CTOUT, 0);
- for (iack = chan = 0; chan < CD180_NCHAN; chan++)
- if (tchans[chan].rxptr >= CD180_NFIFO)
- iack++;
- if (iack == CD180_NCHAN)
- break;
- }
- for (chan = 0; chan < CD180_NCHAN; chan++) {
- /* Select and reset channel */
- rcout(CD180_CAR, chan);
- CCRCMD(unit, chan, CCR_ResetChan);
- }
-
- if (!rcnt)
- ERR(("looses characters during local loopback\n"))
- /* Now, check data */
- for (chan = 0; chan < CD180_NCHAN; chan++)
- for (i = 0; i < CD180_NFIFO; i++)
- if (ctest[i] != tchans[chan].rxbuf[i])
- ERR(("data mismatch chan %d ptr %d (%d != %d)\n",
- chan, i, ctest[i], tchans[chan].rxbuf[i]))
- (void) splx(old_level);
- return 0;
-}
-
-#ifdef RCDEBUG
-static void printrcflags(rc, comment)
-struct rc_chans *rc;
-char *comment;
-{
- u_short f = rc->rc_flags;
- register int nec = rc->rc_rcb->rcb_addr;
-
- printf("rc%d/%d: %s flags: %s%s%s%s%s%s%s%s%s%s%s%s\n",
- rc->rc_rcb->rcb_unit, rc->rc_chan, comment,
- (f & RC_DTR_OFF)?"DTR_OFF " :"",
- (f & RC_ACTOUT) ?"ACTOUT " :"",
- (f & RC_RTSFLOW)?"RTSFLOW " :"",
- (f & RC_CTSFLOW)?"CTSFLOW " :"",
- (f & RC_DORXFER)?"DORXFER " :"",
- (f & RC_DOXXFER)?"DOXXFER " :"",
- (f & RC_MODCHG) ?"MODCHG " :"",
- (f & RC_OSUSP) ?"OSUSP " :"",
- (f & RC_OSBUSY) ?"OSBUSY " :"",
- (f & RC_WAS_BUFOVFL) ?"BUFOVFL " :"",
- (f & RC_WAS_SILOVFL) ?"SILOVFL " :"",
- (f & RC_SEND_RDY) ?"SEND_RDY":"");
-
- rcout(CD180_CAR, rc->rc_chan);
-
- printf("rc%d/%d: msvr %02x ier %02x ccsr %02x\n",
- rc->rc_rcb->rcb_unit, rc->rc_chan,
- rcin(CD180_MSVR),
- rcin(CD180_IER),
- rcin(CD180_CCSR));
-}
-#endif /* RCDEBUG */
-
-static void
-rc_dtrwakeup(chan)
- void *chan;
-{
- struct rc_chans *rc;
-
- rc = (struct rc_chans *)chan;
- rc->rc_flags &= ~RC_DTR_OFF;
- wakeup(&rc->rc_dtrwait);
-}
-
-static void
-rc_discard_output(rc)
- struct rc_chans *rc;
-{
- disable_intr();
- if (rc->rc_flags & RC_DOXXFER) {
- rc_scheduled_event -= LOTS_OF_EVENTS;
- rc->rc_flags &= ~RC_DOXXFER;
- }
- rc->rc_optr = rc->rc_obufend;
- rc->rc_tp->t_state &= ~TS_BUSY;
- enable_intr();
- ttwwakeup(rc->rc_tp);
-}
-
-static void
-rc_wakeup(chan)
- void *chan;
-{
- timeout(rc_wakeup, (caddr_t)NULL, 1);
-
- if (rc_scheduled_event != 0) {
- int s;
-
- s = splsofttty();
- rcpoll();
- splx(s);
- }
-}
-
-static void
-disc_optim(tp, t, rc)
- struct tty *tp;
- struct termios *t;
- struct rc_chans *rc;
-{
-
- if (!(t->c_iflag & (ICRNL | IGNCR | IMAXBEL | INLCR | ISTRIP | IXON))
- && (!(t->c_iflag & BRKINT) || (t->c_iflag & IGNBRK))
- && (!(t->c_iflag & PARMRK)
- || (t->c_iflag & (IGNPAR | IGNBRK)) == (IGNPAR | IGNBRK))
- && !(t->c_lflag & (ECHO | ICANON | IEXTEN | ISIG | PENDIN))
- && linesw[tp->t_line].l_rint == ttyinput)
- tp->t_state |= TS_CAN_BYPASS_L_RINT;
- else
- tp->t_state &= ~TS_CAN_BYPASS_L_RINT;
- rc->rc_hotchar = linesw[tp->t_line].l_hotchar;
-}
-
-static void
-rc_wait0(nec, unit, chan, line)
- int nec, unit, chan, line;
-{
- int rcnt;
-
- for (rcnt = 50; rcnt && rcin(CD180_CCR); rcnt--)
- DELAY(30);
- if (rcnt == 0)
- printf("rc%d/%d: channel command timeout, rc.c line: %d\n",
- unit, chan, line);
-}
diff --git a/sys/dev/rc/rcreg.h b/sys/dev/rc/rcreg.h
deleted file mode 100644
index 75015f20d644..000000000000
--- a/sys/dev/rc/rcreg.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 1995 by Pavel Antonov, Moscow, Russia.
- * Copyright (C) 1995 by Andrey A. Chernov, Moscow, Russia.
- * 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 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 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.
- */
-
-/*
- * Cirrus Logic CD180 -based RISCom/8 board definitions
- */
-
-/* Oscillator frequency - 19660.08Mhz / 2 */
-#define RC_OSCFREQ 9830400
-
-#define RC_BRD(s) ((s) == 0 ? 0 : \
- (((RC_OSCFREQ + (s) / 2) / (s)) + CD180_CTICKS/2) / CD180_CTICKS)
-
-#define RC_VALIDADDR(a) ( (a) == 0x220 || (a) == 0x240 || (a) == 0x250 \
- || (a) == 0x260 || (a) == 0x2A0 || (a) == 0x2B0 \
- || (a) == 0x300 || (a) == 0x320)
-
-#define RC_VALIDIRQ(i) ((i) < 16 && \
- "\0\0\0\1\1\1\0\1\0\0\1\1\1\0\0\1"[(i) & 0xF])
-
-/* Riscom/8 board ISA I/O mapping */
-#define RC_IOMAP(r) ((((r) & 07) << 1) | (((r) & ~07) << 7))
-
-/* I/O commands */
-#define RC_OUT(p,i,d) outb(RC_IOMAP(i) + (p), (d))
-#define RC_IN(p,i) inb (RC_IOMAP(i) + (p))
-
-/* Riscom on-board registers (mapping assumed) */
-#define RC_RIREG 0x100 /* Ring Indicator Register (read-only) */
-#define RC_DTREG 0x100 /* DTR Register (write-only) */
-#define RC_BSR 0x101 /* Board Status Register (read-only) */
-#define RC_CTOUT 0x101 /* Clear Timeout (write-only) */
-
-/* Board Status Register */
-#define RC_BSR_TOUT 0x08 /* Timeout */
-#define RC_BSR_RXINT 0x04 /* Receiver Interrupt */
-#define RC_BSR_TXINT 0x02 /* Transmitter Interrupt */
-#define RC_BSR_MOINT 0x01 /* Modem Control Interrupt */
-
-/* Interrupt groups */
-#define RC_MODEMGRP 0x01 /* Modem interrupt group */
-#define RC_RXGRP 0x02 /* Receiver interrupt group */
-#define RC_TXGRP 0x04 /* Transmitter interrupt group */
-
-/* Priority Interrupt Level definitions */
-#define RC_PILR_MODEM (0x80 | RC_MODEMGRP)
-#define RC_PILR_RX (0x80 | RC_RXGRP )
-#define RC_PILR_TX (0x80 | RC_TXGRP )
diff --git a/sys/dev/rp/rp.c b/sys/dev/rp/rp.c
deleted file mode 100644
index bc846d5291fe..000000000000
--- a/sys/dev/rp/rp.c
+++ /dev/null
@@ -1,1985 +0,0 @@
-/*
- * Copyright (c) Comtrol Corporation <support@comtrol.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted prodived that the follwoing conditions
- * are met.
- * 1. Redistributions of source code must retain the above copyright
- * notive, this list of conditions and the following disclainer.
- * 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 prodided 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 Comtrol Corporation.
- * 4. The name of Comtrol Corporation may not be used to endorse or
- * promote products derived from this software without specific
- * prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY COMTROL CORPORATION ``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 COMTROL CORPORATION 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, LIFE 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.
- *
- * $FreeBSD$
- */
-
-/*
- * rp.c - for RocketPort FreeBSD
- */
-
-#include "opt_compat.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/fcntl.h>
-#include <sys/malloc.h>
-#include <sys/tty.h>
-#include <sys/proc.h>
-#include <sys/conf.h>
-#include <sys/kernel.h>
-
-#include <i386/isa/isa_device.h>
-
-#include <pci/pcivar.h>
-
-#define ROCKET_C
-#include <i386/isa/rpreg.h>
-#include <i386/isa/rpvar.h>
-
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-
-static Byte_t RData[RDATASIZE] =
-{
- 0x00, 0x09, 0xf6, 0x82,
- 0x02, 0x09, 0x86, 0xfb,
- 0x04, 0x09, 0x00, 0x0a,
- 0x06, 0x09, 0x01, 0x0a,
- 0x08, 0x09, 0x8a, 0x13,
- 0x0a, 0x09, 0xc5, 0x11,
- 0x0c, 0x09, 0x86, 0x85,
- 0x0e, 0x09, 0x20, 0x0a,
- 0x10, 0x09, 0x21, 0x0a,
- 0x12, 0x09, 0x41, 0xff,
- 0x14, 0x09, 0x82, 0x00,
- 0x16, 0x09, 0x82, 0x7b,
- 0x18, 0x09, 0x8a, 0x7d,
- 0x1a, 0x09, 0x88, 0x81,
- 0x1c, 0x09, 0x86, 0x7a,
- 0x1e, 0x09, 0x84, 0x81,
- 0x20, 0x09, 0x82, 0x7c,
- 0x22, 0x09, 0x0a, 0x0a
-};
-
-static Byte_t RRegData[RREGDATASIZE]=
-{
- 0x00, 0x09, 0xf6, 0x82, /* 00: Stop Rx processor */
- 0x08, 0x09, 0x8a, 0x13, /* 04: Tx software flow control */
- 0x0a, 0x09, 0xc5, 0x11, /* 08: XON char */
- 0x0c, 0x09, 0x86, 0x85, /* 0c: XANY */
- 0x12, 0x09, 0x41, 0xff, /* 10: Rx mask char */
- 0x14, 0x09, 0x82, 0x00, /* 14: Compare/Ignore #0 */
- 0x16, 0x09, 0x82, 0x7b, /* 18: Compare #1 */
- 0x18, 0x09, 0x8a, 0x7d, /* 1c: Compare #2 */
- 0x1a, 0x09, 0x88, 0x81, /* 20: Interrupt #1 */
- 0x1c, 0x09, 0x86, 0x7a, /* 24: Ignore/Replace #1 */
- 0x1e, 0x09, 0x84, 0x81, /* 28: Interrupt #2 */
- 0x20, 0x09, 0x82, 0x7c, /* 2c: Ignore/Replace #2 */
- 0x22, 0x09, 0x0a, 0x0a /* 30: Rx FIFO Enable */
-};
-
-static CONTROLLER_T sController[CTL_SIZE] =
-{
- {-1,-1,0,0,0,0,0,0,0,0,0,{0,0,0,0},{0,0,0,0},{-1,-1,-1,-1},{0,0,0,0}},
- {-1,-1,0,0,0,0,0,0,0,0,0,{0,0,0,0},{0,0,0,0},{-1,-1,-1,-1},{0,0,0,0}},
- {-1,-1,0,0,0,0,0,0,0,0,0,{0,0,0,0},{0,0,0,0},{-1,-1,-1,-1},{0,0,0,0}},
- {-1,-1,0,0,0,0,0,0,0,0,0,{0,0,0,0},{0,0,0,0},{-1,-1,-1,-1},{0,0,0,0}}
-};
-
-#if 0
-/* IRQ number to MUDBAC register 2 mapping */
-Byte_t sIRQMap[16] =
-{
- 0,0,0,0x10,0x20,0x30,0,0,0,0x40,0x50,0x60,0x70,0,0,0x80
-};
-#endif
-
-static Byte_t sBitMapClrTbl[8] =
-{
- 0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f
-};
-
-static Byte_t sBitMapSetTbl[8] =
-{
- 0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80
-};
-
-/***************************************************************************
-Function: sInitController
-Purpose: Initialization of controller global registers and controller
- structure.
-Call: sInitController(CtlP,CtlNum,MudbacIO,AiopIOList,AiopIOListSize,
- IRQNum,Frequency,PeriodicOnly)
- CONTROLLER_T *CtlP; Ptr to controller structure
- int CtlNum; Controller number
- ByteIO_t MudbacIO; Mudbac base I/O address.
- ByteIO_t *AiopIOList; List of I/O addresses for each AIOP.
- This list must be in the order the AIOPs will be found on the
- controller. Once an AIOP in the list is not found, it is
- assumed that there are no more AIOPs on the controller.
- int AiopIOListSize; Number of addresses in AiopIOList
- int IRQNum; Interrupt Request number. Can be any of the following:
- 0: Disable global interrupts
- 3: IRQ 3
- 4: IRQ 4
- 5: IRQ 5
- 9: IRQ 9
- 10: IRQ 10
- 11: IRQ 11
- 12: IRQ 12
- 15: IRQ 15
- Byte_t Frequency: A flag identifying the frequency
- of the periodic interrupt, can be any one of the following:
- FREQ_DIS - periodic interrupt disabled
- FREQ_137HZ - 137 Hertz
- FREQ_69HZ - 69 Hertz
- FREQ_34HZ - 34 Hertz
- FREQ_17HZ - 17 Hertz
- FREQ_9HZ - 9 Hertz
- FREQ_4HZ - 4 Hertz
- If IRQNum is set to 0 the Frequency parameter is
- overidden, it is forced to a value of FREQ_DIS.
- int PeriodicOnly: TRUE if all interrupts except the periodic
- interrupt are to be blocked.
- FALSE is both the periodic interrupt and
- other channel interrupts are allowed.
- If IRQNum is set to 0 the PeriodicOnly parameter is
- overidden, it is forced to a value of FALSE.
-Return: int: Number of AIOPs on the controller, or CTLID_NULL if controller
- initialization failed.
-
-Comments:
- If periodic interrupts are to be disabled but AIOP interrupts
- are allowed, set Frequency to FREQ_DIS and PeriodicOnly to FALSE.
-
- If interrupts are to be completely disabled set IRQNum to 0.
-
- Setting Frequency to FREQ_DIS and PeriodicOnly to TRUE is an
- invalid combination.
-
- This function performs initialization of global interrupt modes,
- but it does not actually enable global interrupts. To enable
- and disable global interrupts use functions sEnGlobalInt() and
- sDisGlobalInt(). Enabling of global interrupts is normally not
- done until all other initializations are complete.
-
- Even if interrupts are globally enabled, they must also be
- individually enabled for each channel that is to generate
- interrupts.
-
-Warnings: No range checking on any of the parameters is done.
-
- No context switches are allowed while executing this function.
-
- After this function all AIOPs on the controller are disabled,
- they can be enabled with sEnAiop().
-*/
-int sInitController( CONTROLLER_T *CtlP,
- int CtlNum,
- ByteIO_t MudbacIO,
- ByteIO_t *AiopIOList,
- int AiopIOListSize,
- int IRQNum,
- Byte_t Frequency,
- int PeriodicOnly)
-{
- int i;
- ByteIO_t io;
-
- CtlP->CtlNum = CtlNum;
- CtlP->BusType = isISA;
- CtlP->CtlID = CTLID_0001; /* controller release 1 */
-
- CtlP->MBaseIO = MudbacIO;
- CtlP->MReg1IO = MudbacIO + 1;
- CtlP->MReg2IO = MudbacIO + 2;
- CtlP->MReg3IO = MudbacIO + 3;
-#if 1
- CtlP->MReg2 = 0; /* interrupt disable */
- CtlP->MReg3 = 0; /* no periodic interrupts */
-#else
- if(sIRQMap[IRQNum] == 0) /* interrupts globally disabled */
- {
- CtlP->MReg2 = 0; /* interrupt disable */
- CtlP->MReg3 = 0; /* no periodic interrupts */
- }
- else
- {
- CtlP->MReg2 = sIRQMap[IRQNum]; /* set IRQ number */
- CtlP->MReg3 = Frequency; /* set frequency */
- if(PeriodicOnly) /* periodic interrupt only */
- {
- CtlP->MReg3 |= PERIODIC_ONLY;
- }
- }
-#endif
- sOutB(CtlP->MReg2IO,CtlP->MReg2);
- sOutB(CtlP->MReg3IO,CtlP->MReg3);
- sControllerEOI(CtlP); /* clear EOI if warm init */
-
- /* Init AIOPs */
- CtlP->NumAiop = 0;
- for(i=0; i < AiopIOListSize; i++)
- {
- io = AiopIOList[i];
- CtlP->AiopIO[i] = (WordIO_t)io;
- CtlP->AiopIntChanIO[i] = io + _INT_CHAN;
- sOutB(CtlP->MReg2IO,CtlP->MReg2 | (i & 0x03)); /* AIOP index */
- sOutB(MudbacIO,(Byte_t)(io >> 6)); /* set up AIOP I/O in MUDBAC */
- sEnAiop(CtlP,i); /* enable the AIOP */
-
- CtlP->AiopID[i] = sReadAiopID(io); /* read AIOP ID */
- if(CtlP->AiopID[i] == AIOPID_NULL) /* if AIOP does not exist */
- {
- sDisAiop(CtlP,i); /* disable AIOP */
- break; /* done looking for AIOPs */
- }
-
- CtlP->AiopNumChan[i] = sReadAiopNumChan((WordIO_t)io); /* num channels in AIOP */
- sOutW((WordIO_t)io + _INDX_ADDR,_CLK_PRE); /* clock prescaler */
- sOutB(io + _INDX_DATA,CLOCK_PRESC);
- CtlP->NumAiop++; /* bump count of AIOPs */
- sDisAiop(CtlP,i); /* disable AIOP */
- }
-
- if(CtlP->NumAiop == 0)
- return(-1);
- else
- return(CtlP->NumAiop);
-}
-
-int sPCIInitController( CONTROLLER_T *CtlP,
- int CtlNum,
- ByteIO_t *AiopIOList,
- int AiopIOListSize,
- int IRQNum,
- Byte_t Frequency,
- int PeriodicOnly)
-{
- int i;
- ByteIO_t io;
-
- CtlP->CtlNum = CtlNum;
- CtlP->BusType = isPCI;
- CtlP->CtlID = CTLID_0001; /* controller release 1 */
- CtlP->PCIIO = (WordIO_t)((ByteIO_t)AiopIOList[0] + _PCI_INT_FUNC);
-
- sPCIControllerEOI(CtlP);
-
- /* Init AIOPs */
- CtlP->NumAiop = 0;
- for(i=0; i < AiopIOListSize; i++)
- {
- io = AiopIOList[i];
- CtlP->AiopIO[i] = (WordIO_t)io;
- CtlP->AiopIntChanIO[i] = io + _INT_CHAN;
-
- CtlP->AiopID[i] = sReadAiopID(io); /* read AIOP ID */
- if(CtlP->AiopID[i] == AIOPID_NULL) /* if AIOP does not exist */
- {
- break; /* done looking for AIOPs */
- }
-
- CtlP->AiopNumChan[i] = sReadAiopNumChan((WordIO_t)io); /* num channels in AIOP */
- sOutW((WordIO_t)io + _INDX_ADDR,_CLK_PRE); /* clock prescaler */
- sOutB(io + _INDX_DATA,CLOCK_PRESC);
- CtlP->NumAiop++; /* bump count of AIOPs */
- }
-
- if(CtlP->NumAiop == 0)
- return(-1);
- else
- return(CtlP->NumAiop);
-}
-
-/***************************************************************************
-Function: sReadAiopID
-Purpose: Read the AIOP idenfication number directly from an AIOP.
-Call: sReadAiopID(io)
- ByteIO_t io: AIOP base I/O address
-Return: int: Flag AIOPID_XXXX if a valid AIOP is found, where X
- is replace by an identifying number.
- Flag AIOPID_NULL if no valid AIOP is found
-Warnings: No context switches are allowed while executing this function.
-
-*/
-int sReadAiopID(ByteIO_t io)
-{
- Byte_t AiopID; /* ID byte from AIOP */
-
- sOutB(io + _CMD_REG,RESET_ALL); /* reset AIOP */
- sOutB(io + _CMD_REG,0x0);
- AiopID = sInB(io + _CHN_STAT0) & 0x07;
- if(AiopID == 0x06)
- return(1);
- else /* AIOP does not exist */
- return(-1);
-}
-
-/***************************************************************************
-Function: sReadAiopNumChan
-Purpose: Read the number of channels available in an AIOP directly from
- an AIOP.
-Call: sReadAiopNumChan(io)
- WordIO_t io: AIOP base I/O address
-Return: int: The number of channels available
-Comments: The number of channels is determined by write/reads from identical
- offsets within the SRAM address spaces for channels 0 and 4.
- If the channel 4 space is mirrored to channel 0 it is a 4 channel
- AIOP, otherwise it is an 8 channel.
-Warnings: No context switches are allowed while executing this function.
-*/
-int sReadAiopNumChan(WordIO_t io)
-{
- Word_t x;
-
- sOutDW((DWordIO_t)io + _INDX_ADDR,0x12340000L); /* write to chan 0 SRAM */
- sOutW(io + _INDX_ADDR,0); /* read from SRAM, chan 0 */
- x = sInW(io + _INDX_DATA);
- sOutW(io + _INDX_ADDR,0x4000); /* read from SRAM, chan 4 */
- if(x != sInW(io + _INDX_DATA)) /* if different must be 8 chan */
- return(8);
- else
- return(4);
-}
-
-/***************************************************************************
-Function: sInitChan
-Purpose: Initialization of a channel and channel structure
-Call: sInitChan(CtlP,ChP,AiopNum,ChanNum)
- CONTROLLER_T *CtlP; Ptr to controller structure
- CHANNEL_T *ChP; Ptr to channel structure
- int AiopNum; AIOP number within controller
- int ChanNum; Channel number within AIOP
-Return: int: TRUE if initialization succeeded, FALSE if it fails because channel
- number exceeds number of channels available in AIOP.
-Comments: This function must be called before a channel can be used.
-Warnings: No range checking on any of the parameters is done.
-
- No context switches are allowed while executing this function.
-*/
-int sInitChan( CONTROLLER_T *CtlP,
- CHANNEL_T *ChP,
- int AiopNum,
- int ChanNum)
-{
- int i;
- WordIO_t AiopIO;
- WordIO_t ChIOOff;
- Byte_t *ChR;
- Word_t ChOff;
- static Byte_t R[4];
-
- if(ChanNum >= CtlP->AiopNumChan[AiopNum])
- return(FALSE); /* exceeds num chans in AIOP */
-
- /* Channel, AIOP, and controller identifiers */
- ChP->CtlP = CtlP;
- ChP->ChanID = CtlP->AiopID[AiopNum];
- ChP->AiopNum = AiopNum;
- ChP->ChanNum = ChanNum;
-
- /* Global direct addresses */
- AiopIO = CtlP->AiopIO[AiopNum];
- ChP->Cmd = (ByteIO_t)AiopIO + _CMD_REG;
- ChP->IntChan = (ByteIO_t)AiopIO + _INT_CHAN;
- ChP->IntMask = (ByteIO_t)AiopIO + _INT_MASK;
- ChP->IndexAddr = (DWordIO_t)AiopIO + _INDX_ADDR;
- ChP->IndexData = AiopIO + _INDX_DATA;
-
- /* Channel direct addresses */
- ChIOOff = AiopIO + ChP->ChanNum * 2;
- ChP->TxRxData = ChIOOff + _TD0;
- ChP->ChanStat = ChIOOff + _CHN_STAT0;
- ChP->TxRxCount = ChIOOff + _FIFO_CNT0;
- ChP->IntID = (ByteIO_t)AiopIO + ChP->ChanNum + _INT_ID0;
-
- /* Initialize the channel from the RData array */
- for(i=0; i < RDATASIZE; i+=4)
- {
- R[0] = RData[i];
- R[1] = RData[i+1] + 0x10 * ChanNum;
- R[2] = RData[i+2];
- R[3] = RData[i+3];
- sOutDW(ChP->IndexAddr,*((DWord_t *)&R[0]));
- }
-
- ChR = ChP->R;
- for(i=0; i < RREGDATASIZE; i+=4)
- {
- ChR[i] = RRegData[i];
- ChR[i+1] = RRegData[i+1] + 0x10 * ChanNum;
- ChR[i+2] = RRegData[i+2];
- ChR[i+3] = RRegData[i+3];
- }
-
- /* Indexed registers */
- ChOff = (Word_t)ChanNum * 0x1000;
-
- ChP->BaudDiv[0] = (Byte_t)(ChOff + _BAUD);
- ChP->BaudDiv[1] = (Byte_t)((ChOff + _BAUD) >> 8);
- ChP->BaudDiv[2] = (Byte_t)BRD9600;
- ChP->BaudDiv[3] = (Byte_t)(BRD9600 >> 8);
- sOutDW(ChP->IndexAddr,*(DWord_t *)&ChP->BaudDiv[0]);
-
- ChP->TxControl[0] = (Byte_t)(ChOff + _TX_CTRL);
- ChP->TxControl[1] = (Byte_t)((ChOff + _TX_CTRL) >> 8);
- ChP->TxControl[2] = 0;
- ChP->TxControl[3] = 0;
- sOutDW(ChP->IndexAddr,*(DWord_t *)&ChP->TxControl[0]);
-
- ChP->RxControl[0] = (Byte_t)(ChOff + _RX_CTRL);
- ChP->RxControl[1] = (Byte_t)((ChOff + _RX_CTRL) >> 8);
- ChP->RxControl[2] = 0;
- ChP->RxControl[3] = 0;
- sOutDW(ChP->IndexAddr,*(DWord_t *)&ChP->RxControl[0]);
-
- ChP->TxEnables[0] = (Byte_t)(ChOff + _TX_ENBLS);
- ChP->TxEnables[1] = (Byte_t)((ChOff + _TX_ENBLS) >> 8);
- ChP->TxEnables[2] = 0;
- ChP->TxEnables[3] = 0;
- sOutDW(ChP->IndexAddr,*(DWord_t *)&ChP->TxEnables[0]);
-
- ChP->TxCompare[0] = (Byte_t)(ChOff + _TXCMP1);
- ChP->TxCompare[1] = (Byte_t)((ChOff + _TXCMP1) >> 8);
- ChP->TxCompare[2] = 0;
- ChP->TxCompare[3] = 0;
- sOutDW(ChP->IndexAddr,*(DWord_t *)&ChP->TxCompare[0]);
-
- ChP->TxReplace1[0] = (Byte_t)(ChOff + _TXREP1B1);
- ChP->TxReplace1[1] = (Byte_t)((ChOff + _TXREP1B1) >> 8);
- ChP->TxReplace1[2] = 0;
- ChP->TxReplace1[3] = 0;
- sOutDW(ChP->IndexAddr,*(DWord_t *)&ChP->TxReplace1[0]);
-
- ChP->TxReplace2[0] = (Byte_t)(ChOff + _TXREP2);
- ChP->TxReplace2[1] = (Byte_t)((ChOff + _TXREP2) >> 8);
- ChP->TxReplace2[2] = 0;
- ChP->TxReplace2[3] = 0;
- sOutDW(ChP->IndexAddr,*(DWord_t *)&ChP->TxReplace2[0]);
-
- ChP->TxFIFOPtrs = ChOff + _TXF_OUTP;
- ChP->TxFIFO = ChOff + _TX_FIFO;
-
- sOutB(ChP->Cmd,(Byte_t)ChanNum | RESTXFCNT); /* apply reset Tx FIFO count */
- sOutB(ChP->Cmd,(Byte_t)ChanNum); /* remove reset Tx FIFO count */
- sOutW((WordIO_t)ChP->IndexAddr,ChP->TxFIFOPtrs); /* clear Tx in/out ptrs */
- sOutW(ChP->IndexData,0);
- ChP->RxFIFOPtrs = ChOff + _RXF_OUTP;
- ChP->RxFIFO = ChOff + _RX_FIFO;
-
- sOutB(ChP->Cmd,(Byte_t)ChanNum | RESRXFCNT); /* apply reset Rx FIFO count */
- sOutB(ChP->Cmd,(Byte_t)ChanNum); /* remove reset Rx FIFO count */
- sOutW((WordIO_t)ChP->IndexAddr,ChP->RxFIFOPtrs); /* clear Rx out ptr */
- sOutW(ChP->IndexData,0);
- sOutW((WordIO_t)ChP->IndexAddr,ChP->RxFIFOPtrs + 2); /* clear Rx in ptr */
- sOutW(ChP->IndexData,0);
- ChP->TxPrioCnt = ChOff + _TXP_CNT;
- sOutW((WordIO_t)ChP->IndexAddr,ChP->TxPrioCnt);
- sOutB(ChP->IndexData,0);
- ChP->TxPrioPtr = ChOff + _TXP_PNTR;
- sOutW((WordIO_t)ChP->IndexAddr,ChP->TxPrioPtr);
- sOutB(ChP->IndexData,0);
- ChP->TxPrioBuf = ChOff + _TXP_BUF;
- sEnRxProcessor(ChP); /* start the Rx processor */
-
- return(TRUE);
-}
-
-/***************************************************************************
-Function: sStopRxProcessor
-Purpose: Stop the receive processor from processing a channel.
-Call: sStopRxProcessor(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-
-Comments: The receive processor can be started again with sStartRxProcessor().
- This function causes the receive processor to skip over the
- stopped channel. It does not stop it from processing other channels.
-
-Warnings: No context switches are allowed while executing this function.
-
- Do not leave the receive processor stopped for more than one
- character time.
-
- After calling this function a delay of 4 uS is required to ensure
- that the receive processor is no longer processing this channel.
-*/
-void sStopRxProcessor(CHANNEL_T *ChP)
-{
- Byte_t R[4];
-
- R[0] = ChP->R[0];
- R[1] = ChP->R[1];
- R[2] = 0x0a;
- R[3] = ChP->R[3];
- sOutDW(ChP->IndexAddr,*(DWord_t *)&R[0]);
-}
-
-/***************************************************************************
-Function: sFlushRxFIFO
-Purpose: Flush the Rx FIFO
-Call: sFlushRxFIFO(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-Return: void
-Comments: To prevent data from being enqueued or dequeued in the Tx FIFO
- while it is being flushed the receive processor is stopped
- and the transmitter is disabled. After these operations a
- 4 uS delay is done before clearing the pointers to allow
- the receive processor to stop. These items are handled inside
- this function.
-Warnings: No context switches are allowed while executing this function.
-*/
-void sFlushRxFIFO(CHANNEL_T *ChP)
-{
- int i;
- Byte_t Ch; /* channel number within AIOP */
- int RxFIFOEnabled; /* TRUE if Rx FIFO enabled */
-
- if(sGetRxCnt(ChP) == 0) /* Rx FIFO empty */
- return; /* don't need to flush */
-
- RxFIFOEnabled = FALSE;
- if(ChP->R[0x32] == 0x08) /* Rx FIFO is enabled */
- {
- RxFIFOEnabled = TRUE;
- sDisRxFIFO(ChP); /* disable it */
- for(i=0; i < 2000/200; i++) /* delay 2 uS to allow proc to disable FIFO*/
- sInB(ChP->IntChan); /* depends on bus i/o timing */
- }
- sGetChanStatus(ChP); /* clear any pending Rx errors in chan stat */
- Ch = (Byte_t)sGetChanNum(ChP);
- sOutB(ChP->Cmd,Ch | RESRXFCNT); /* apply reset Rx FIFO count */
- sOutB(ChP->Cmd,Ch); /* remove reset Rx FIFO count */
- sOutW((WordIO_t)ChP->IndexAddr,ChP->RxFIFOPtrs); /* clear Rx out ptr */
- sOutW(ChP->IndexData,0);
- sOutW((WordIO_t)ChP->IndexAddr,ChP->RxFIFOPtrs + 2); /* clear Rx in ptr */
- sOutW(ChP->IndexData,0);
- if(RxFIFOEnabled)
- sEnRxFIFO(ChP); /* enable Rx FIFO */
-}
-
-/***************************************************************************
-Function: sFlushTxFIFO
-Purpose: Flush the Tx FIFO
-Call: sFlushTxFIFO(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-Return: void
-Comments: To prevent data from being enqueued or dequeued in the Tx FIFO
- while it is being flushed the receive processor is stopped
- and the transmitter is disabled. After these operations a
- 4 uS delay is done before clearing the pointers to allow
- the receive processor to stop. These items are handled inside
- this function.
-Warnings: No context switches are allowed while executing this function.
-*/
-void sFlushTxFIFO(CHANNEL_T *ChP)
-{
- int i;
- Byte_t Ch; /* channel number within AIOP */
- int TxEnabled; /* TRUE if transmitter enabled */
-
- if(sGetTxCnt(ChP) == 0) /* Tx FIFO empty */
- return; /* don't need to flush */
-
- TxEnabled = FALSE;
- if(ChP->TxControl[3] & TX_ENABLE)
- {
- TxEnabled = TRUE;
- sDisTransmit(ChP); /* disable transmitter */
- }
- sStopRxProcessor(ChP); /* stop Rx processor */
- for(i = 0; i < 4000/200; i++) /* delay 4 uS to allow proc to stop */
- sInB(ChP->IntChan); /* depends on bus i/o timing */
- Ch = (Byte_t)sGetChanNum(ChP);
- sOutB(ChP->Cmd,Ch | RESTXFCNT); /* apply reset Tx FIFO count */
- sOutB(ChP->Cmd,Ch); /* remove reset Tx FIFO count */
- sOutW((WordIO_t)ChP->IndexAddr,ChP->TxFIFOPtrs); /* clear Tx in/out ptrs */
- sOutW(ChP->IndexData,0);
- if(TxEnabled)
- sEnTransmit(ChP); /* enable transmitter */
- sStartRxProcessor(ChP); /* restart Rx processor */
-}
-
-/***************************************************************************
-Function: sWriteTxPrioByte
-Purpose: Write a byte of priority transmit data to a channel
-Call: sWriteTxPrioByte(ChP,Data)
- CHANNEL_T *ChP; Ptr to channel structure
- Byte_t Data; The transmit data byte
-
-Return: int: 1 if the bytes is successfully written, otherwise 0.
-
-Comments: The priority byte is transmitted before any data in the Tx FIFO.
-
-Warnings: No context switches are allowed while executing this function.
-*/
-int sWriteTxPrioByte(CHANNEL_T *ChP, Byte_t Data)
-{
- Byte_t DWBuf[4]; /* buffer for double word writes */
- Word_t *WordPtr; /* must be far because Win SS != DS */
- register DWordIO_t IndexAddr;
-
- if(sGetTxCnt(ChP) > 1) /* write it to Tx priority buffer */
- {
- IndexAddr = ChP->IndexAddr;
- sOutW((WordIO_t)IndexAddr,ChP->TxPrioCnt); /* get priority buffer status */
- if(sInB((ByteIO_t)ChP->IndexData) & PRI_PEND) /* priority buffer busy */
- return(0); /* nothing sent */
-
- WordPtr = (Word_t *)(&DWBuf[0]);
- *WordPtr = ChP->TxPrioBuf; /* data byte address */
-
- DWBuf[2] = Data; /* data byte value */
- sOutDW(IndexAddr,*((DWord_t *)(&DWBuf[0]))); /* write it out */
-
- *WordPtr = ChP->TxPrioCnt; /* Tx priority count address */
-
- DWBuf[2] = PRI_PEND + 1; /* indicate 1 byte pending */
- DWBuf[3] = 0; /* priority buffer pointer */
- sOutDW(IndexAddr,*((DWord_t *)(&DWBuf[0]))); /* write it out */
- }
- else /* write it to Tx FIFO */
- {
- sWriteTxByte(sGetTxRxDataIO(ChP),Data);
- }
- return(1); /* 1 byte sent */
-}
-
-/***************************************************************************
-Function: sEnInterrupts
-Purpose: Enable one or more interrupts for a channel
-Call: sEnInterrupts(ChP,Flags)
- CHANNEL_T *ChP; Ptr to channel structure
- Word_t Flags: Interrupt enable flags, can be any combination
- of the following flags:
- TXINT_EN: Interrupt on Tx FIFO empty
- RXINT_EN: Interrupt on Rx FIFO at trigger level (see
- sSetRxTrigger())
- SRCINT_EN: Interrupt on SRC (Special Rx Condition)
- MCINT_EN: Interrupt on modem input change
- CHANINT_EN: Allow channel interrupt signal to the AIOP's
- Interrupt Channel Register.
-Return: void
-Comments: If an interrupt enable flag is set in Flags, that interrupt will be
- enabled. If an interrupt enable flag is not set in Flags, that
- interrupt will not be changed. Interrupts can be disabled with
- function sDisInterrupts().
-
- This function sets the appropriate bit for the channel in the AIOP's
- Interrupt Mask Register if the CHANINT_EN flag is set. This allows
- this channel's bit to be set in the AIOP's Interrupt Channel Register.
-
- Interrupts must also be globally enabled before channel interrupts
- will be passed on to the host. This is done with function
- sEnGlobalInt().
-
- In some cases it may be desirable to disable interrupts globally but
- enable channel interrupts. This would allow the global interrupt
- status register to be used to determine which AIOPs need service.
-*/
-void sEnInterrupts(CHANNEL_T *ChP,Word_t Flags)
-{
- Byte_t Mask; /* Interrupt Mask Register */
-
- ChP->RxControl[2] |=
- ((Byte_t)Flags & (RXINT_EN | SRCINT_EN | MCINT_EN));
-
- sOutDW(ChP->IndexAddr,*(DWord_t *)&ChP->RxControl[0]);
-
- ChP->TxControl[2] |= ((Byte_t)Flags & TXINT_EN);
-
- sOutDW(ChP->IndexAddr,*(DWord_t *)&ChP->TxControl[0]);
-
- if(Flags & CHANINT_EN)
- {
- Mask = sInB(ChP->IntMask) | sBitMapSetTbl[ChP->ChanNum];
- sOutB(ChP->IntMask,Mask);
- }
-}
-
-/***************************************************************************
-Function: sDisInterrupts
-Purpose: Disable one or more interrupts for a channel
-Call: sDisInterrupts(ChP,Flags)
- CHANNEL_T *ChP; Ptr to channel structure
- Word_t Flags: Interrupt flags, can be any combination
- of the following flags:
- TXINT_EN: Interrupt on Tx FIFO empty
- RXINT_EN: Interrupt on Rx FIFO at trigger level (see
- sSetRxTrigger())
- SRCINT_EN: Interrupt on SRC (Special Rx Condition)
- MCINT_EN: Interrupt on modem input change
- CHANINT_EN: Disable channel interrupt signal to the
- AIOP's Interrupt Channel Register.
-Return: void
-Comments: If an interrupt flag is set in Flags, that interrupt will be
- disabled. If an interrupt flag is not set in Flags, that
- interrupt will not be changed. Interrupts can be enabled with
- function sEnInterrupts().
-
- This function clears the appropriate bit for the channel in the AIOP's
- Interrupt Mask Register if the CHANINT_EN flag is set. This blocks
- this channel's bit from being set in the AIOP's Interrupt Channel
- Register.
-*/
-void sDisInterrupts(CHANNEL_T *ChP,Word_t Flags)
-{
- Byte_t Mask; /* Interrupt Mask Register */
-
- ChP->RxControl[2] &=
- ~((Byte_t)Flags & (RXINT_EN | SRCINT_EN | MCINT_EN));
- sOutDW(ChP->IndexAddr,*(DWord_t *)&ChP->RxControl[0]);
- ChP->TxControl[2] &= ~((Byte_t)Flags & TXINT_EN);
- sOutDW(ChP->IndexAddr,*(DWord_t *)&ChP->TxControl[0]);
-
- if(Flags & CHANINT_EN)
- {
- Mask = sInB(ChP->IntMask) & sBitMapClrTbl[ChP->ChanNum];
- sOutB(ChP->IntMask,Mask);
- }
-}
-
-/*********************************************************************
- Begin FreeBsd-specific driver code
-**********************************************************************/
-
-static int rpprobe __P((struct isa_device *));
-static int rpattach __P((struct isa_device *));
-
-static const char* rp_pciprobe(pcici_t tag, pcidi_t type);
-static void rp_pciattach(pcici_t tag, int unit);
-static u_long rp_pcicount;
-
-static struct pci_device rp_pcidevice = {
- "rp",
- rp_pciprobe,
- rp_pciattach,
- &rp_pcicount,
- NULL
-};
-
-COMPAT_PCI_DRIVER (rp_pci, rp_pcidevice);
-
-static timeout_t rpdtrwakeup;
-
-struct isa_driver rpdriver = {
- rpprobe, rpattach, "rp"
- };
-
-static char driver_name[] = "rp";
-
-static d_open_t rpopen;
-static d_close_t rpclose;
-static d_write_t rpwrite;
-static d_ioctl_t rpioctl;
-
-#define CDEV_MAJOR 81
-static struct cdevsw rp_cdevsw = {
- /* open */ rpopen,
- /* close */ rpclose,
- /* read */ ttyread,
- /* write */ rpwrite,
- /* ioctl */ rpioctl,
- /* poll */ ttypoll,
- /* mmap */ nommap,
- /* strategy */ nostrategy,
- /* name */ driver_name,
- /* maj */ CDEV_MAJOR,
- /* dump */ nodump,
- /* psize */ nopsize,
- /* flags */ D_TTY,
- /* bmaj */ -1
-};
-
-static int rp_controller_port = 0;
-static int rp_num_ports_open = 0;
-static int ndevs = 0;
-static int minor_to_unit[128];
-#if 0
-static struct tty rp_tty[128];
-#endif
-
-static int rp_num_ports[4]; /* Number of ports on each controller */
-
-#define _INLINE_ __inline
-#define POLL_INTERVAL 1
-
-#define CALLOUT_MASK 0x80
-#define CONTROL_MASK 0x60
-#define CONTROL_INIT_STATE 0x20
-#define CONTROL_LOCK_STATE 0x40
-#define DEV_UNIT(dev) (MINOR_TO_UNIT(minor(dev))
-#define MINOR_MAGIC_MASK (CALLOUT_MASK | CONTROL_MASK)
-#define MINOR_MAGIC(dev) ((minor(dev)) & ~MINOR_MAGIC_MASK)
-#define IS_CALLOUT(dev) (minor(dev) & CALLOUT_MASK)
-#define IS_CONTROL(dev) (minor(dev) & CONTROL_MASK)
-
-#define RP_ISMULTIPORT(dev) ((dev)->id_flags & 0x1)
-#define RP_MPMASTER(dev) (((dev)->id_flags >> 8) & 0xff)
-#define RP_NOTAST4(dev) ((dev)->id_flags & 0x04)
-
-static struct rp_port *p_rp_addr[4];
-static struct rp_port *p_rp_table[MAX_RP_PORTS];
-#define rp_addr(unit) (p_rp_addr[unit])
-#define rp_table(port) (p_rp_table[port])
-
-/*
- * The top-level routines begin here
- */
-
-static int rpparam __P((struct tty *, struct termios *));
-static void rpstart __P((struct tty *));
-static void rpstop __P((struct tty *, int));
-static void rphardclose __P((struct rp_port *));
-static void rp_disc_optim __P((struct tty *tp, struct termios *t,
- struct rp_port *rp));
-
-static _INLINE_ void rp_do_receive(struct rp_port *rp, struct tty *tp,
- CHANNEL_t *cp, unsigned int ChanStatus)
-{
- int spl;
- unsigned int CharNStat;
- int ToRecv, ch;
-
- ToRecv = sGetRxCnt(cp);
- if(ToRecv == 0)
- return;
-
-/* If status indicates there are errored characters in the
- FIFO, then enter status mode (a word in FIFO holds
- characters and status)
-*/
-
- if(ChanStatus & (RXFOVERFL | RXBREAK | RXFRAME | RXPARITY)) {
- if(!(ChanStatus & STATMODE)) {
- ChanStatus |= STATMODE;
- sEnRxStatusMode(cp);
- }
- }
-/*
- if we previously entered status mode then read down the
- FIFO one word at a time, pulling apart the character and
- the status. Update error counters depending on status.
-*/
- if(ChanStatus & STATMODE) {
- while(ToRecv) {
- if(tp->t_state & TS_TBLOCK) {
- break;
- }
- CharNStat = sInW(sGetTxRxDataIO(cp));
- ch = CharNStat & 0xff;
-
- if((CharNStat & STMBREAK) || (CharNStat & STMFRAMEH))
- ch |= TTY_FE;
- else if (CharNStat & STMPARITYH)
- ch |= TTY_PE;
- else if (CharNStat & STMRCVROVRH)
- rp->rp_overflows++;
-
- (*linesw[tp->t_line].l_rint)(ch, tp);
- ToRecv--;
- }
-/*
- After emtying FIFO in status mode, turn off status mode
-*/
-
- if(sGetRxCnt(cp) == 0)
- sDisRxStatusMode(cp);
- }
- else {
- while (ToRecv) {
- if(tp->t_state & TS_TBLOCK) {
- break;
- }
- ch = (u_char) sInB(sGetTxRxDataIO(cp));
- spl = spltty();
- (*linesw[tp->t_line].l_rint)(ch, tp);
- splx(spl);
- ToRecv--;
- }
- }
-}
-
-static _INLINE_ void rp_handle_port(struct rp_port *rp)
-{
- CHANNEL_t *cp;
- struct tty *tp;
- unsigned int IntMask, ChanStatus;
- /* int oldcts; */
-
- if(!rp)
- return;
-
- cp = &rp->rp_channel;
- tp = rp->rp_tty;
- IntMask = sGetChanIntID(cp);
- IntMask = IntMask & rp->rp_intmask;
- ChanStatus = sGetChanStatus(cp);
- if(IntMask & RXF_TRIG)
- if(!(tp->t_state & TS_TBLOCK) && (tp->t_state & TS_CARR_ON) && (tp->t_state & TS_ISOPEN)) {
- rp_do_receive(rp, tp, cp, ChanStatus);
- }
- if(IntMask & DELTA_CD) {
- if(ChanStatus & CD_ACT) {
- if(!(tp->t_state & TS_CARR_ON) ) {
- (void)(*linesw[tp->t_line].l_modem)(tp, 1);
- }
- } else {
- if((tp->t_state & TS_CARR_ON)) {
- (void)(*linesw[tp->t_line].l_modem)(tp, 0);
- if((*linesw[tp->t_line].l_modem)(tp, 0) == 0) {
- rphardclose(rp);
- }
- }
- }
- }
-/* oldcts = rp->rp_cts;
- rp->rp_cts = ((ChanStatus & CTS_ACT) != 0);
- if(oldcts != rp->rp_cts) {
- printf("CTS change (now %s)... on port %d\n", rp->rp_cts ? "on" : "off", rp->rp_port);
- }
-*/
-}
-
-static void rp_do_poll(void *not_used)
-{
- CONTROLLER_t *ctl;
- struct rp_port *rp;
- struct tty *tp;
- int unit, aiop, ch, line, count;
- unsigned char CtlMask, AiopMask;
-
- for(unit = 0; unit <= ndevs; unit++) {
- rp = rp_addr(unit);
- ctl = rp->rp_ctlp;
- if(ctl->BusType == isPCI)
- CtlMask = sPCIGetControllerIntStatus(ctl);
- else
- CtlMask = sGetControllerIntStatus(ctl);
- for(aiop=0; CtlMask; CtlMask >>=1, aiop++) {
- if(CtlMask & 1) {
- AiopMask = sGetAiopIntStatus(ctl, aiop);
- for(ch = 0; AiopMask; AiopMask >>=1, ch++) {
- if(AiopMask & 1) {
- line = (unit << 5) | (aiop << 3) | ch;
- rp = rp_table(line);
- rp_handle_port(rp);
- }
- }
- }
- }
-
- for(line = 0, rp = rp_addr(unit); line < rp_num_ports[unit];
- line++, rp++) {
- tp = rp->rp_tty;
- if((tp->t_state & TS_BUSY) && (tp->t_state & TS_ISOPEN)) {
- count = sGetTxCnt(&rp->rp_channel);
- if(count == 0)
- tp->t_state &= ~(TS_BUSY);
- if(!(tp->t_state & TS_TTSTOP) &&
- (count <= rp->rp_restart)) {
- (*linesw[tp->t_line].l_start)(tp);
- }
- }
- }
- }
- if(rp_num_ports_open)
- timeout(rp_do_poll, (void *)NULL, POLL_INTERVAL);
-}
-
-static const char*
-rp_pciprobe(pcici_t tag, pcidi_t type)
-{
- int vendor_id;
-
- vendor_id = type & 0xffff;
- switch(vendor_id)
- case 0x11fe:
- return("rp");
- return(NULL);
-}
-
-static
-int
-rpprobe(dev)
-struct isa_device *dev;
-{
- int controller, unit;
- int aiop, num_aiops;
- unsigned int aiopio[MAX_AIOPS_PER_BOARD];
- CONTROLLER_t *ctlp;
-
- unit = dev->id_unit;
- if (dev->id_unit >= 4) {
- printf("rpprobe: unit number %d invalid.\n", dev->id_unit);
- return 1;
- }
- printf("probing for RocketPort(ISA) unit %d\n", unit);
- if (rp_controller_port)
- controller = rp_controller_port;
- else {
- controller = dev->id_iobase + 0x40;
- }
-
- for (aiop=0; aiop<MAX_AIOPS_PER_BOARD; aiop++)
- aiopio[aiop]= dev->id_iobase + (aiop * 0x400);
-
- ctlp = sCtlNumToCtlPtr(dev->id_unit);
- num_aiops = sInitController(ctlp, dev->id_unit,
- controller + ((unit-rp_pcicount)*0x400),
- aiopio, MAX_AIOPS_PER_BOARD, 0,
- FREQ_DIS, 0);
- if (num_aiops <= 0) {
- printf("board%d init failed\n", unit);
- return 0;
- }
-
- if (rp_controller_port) {
- dev->id_msize = 64;
- } else {
- dev->id_msize = 68;
- rp_controller_port = controller;
- }
-
- dev->id_irq = 0;
-
- return 1;
-}
-
-static void
-rp_pciattach(pcici_t tag, int unit)
-{
- int success, oldspl;
- u_short iobase;
- int num_ports, num_chan, num_aiops;
- int aiop, chan, port;
- int ChanStatus, line, i, count;
- unsigned int aiopio[MAX_AIOPS_PER_BOARD];
- struct rp_port *rp;
- struct tty *tty;
- CONTROLLER_t *ctlp;
-
- success = pci_map_port(tag, 0x10, &iobase);
- if(!success)
- printf("ioaddr mapping failed for RocketPort(PCI)\n");
-
- for(aiop=0; aiop < MAX_AIOPS_PER_BOARD; aiop++)
- aiopio[aiop] = iobase + (aiop * 0x40);
-
- ctlp = sCtlNumToCtlPtr(unit);
- num_aiops = sPCIInitController(ctlp, unit,
- aiopio, MAX_AIOPS_PER_BOARD, 0,
- FREQ_DIS, 0);
-
- num_ports = 0;
- for(aiop=0; aiop < num_aiops; aiop++) {
- sResetAiopByNum(ctlp, aiop);
- num_ports += sGetAiopNumChan(ctlp, aiop);
- }
- printf("RocketPort%d = %d ports\n", unit, num_ports);
- rp_num_ports[unit] = num_ports;
-
- rp = (struct rp_port *)
- malloc(sizeof(struct rp_port) * num_ports, M_TTYS, M_NOWAIT);
- if(rp == 0) {
- printf("rp_attach: Could not malloc rp_ports structures\n");
- return;
- }
-
- count = unit * 32; /* board times max ports per card SG */
- for(i=count;i < (count + rp_num_ports[unit]);i++)
- minor_to_unit[i] = unit;
-
- bzero(rp, sizeof(struct rp_port) * num_ports);
- tty = (struct tty *)
- malloc(sizeof(struct tty) * num_ports, M_TTYS, M_NOWAIT);
- if(tty == 0) {
- printf("rp_attach: Could not malloc tty structures\n");
- return;
- }
- bzero(tty, sizeof(struct tty) * num_ports);
-
- oldspl = spltty();
- rp_addr(unit) = rp;
- splx(oldspl);
-
- cdevsw_add(&rp_cdevsw);
-
- port = 0;
- for(aiop=0; aiop < num_aiops; aiop++) {
- num_chan = sGetAiopNumChan(ctlp, aiop);
- for(chan=0; chan < num_chan; chan++, port++, rp++, tty++) {
- rp->rp_tty = tty;
- rp->rp_port = port;
- rp->rp_ctlp = ctlp;
- rp->rp_unit = unit;
- rp->rp_chan = chan;
- rp->rp_aiop = aiop;
-
- tty->t_line = 0;
- /* tty->t_termios = deftermios;
- */
- rp->dtr_wait = 3 * hz;
- rp->it_in.c_iflag = 0;
- rp->it_in.c_oflag = 0;
- rp->it_in.c_cflag = TTYDEF_CFLAG;
- rp->it_in.c_lflag = 0;
- termioschars(&rp->it_in);
- /* termioschars(&tty->t_termios);
- */
- rp->it_in.c_ispeed = rp->it_in.c_ospeed = TTYDEF_SPEED;
- rp->it_out = rp->it_in;
-
- rp->rp_intmask = RXF_TRIG | TXFIFO_MT | SRC_INT |
- DELTA_CD | DELTA_CTS | DELTA_DSR;
- ChanStatus = sGetChanStatus(&rp->rp_channel);
- if(sInitChan(ctlp, &rp->rp_channel, aiop, chan) == 0) {
- printf("RocketPort sInitChan(%d, %d, %d) failed
- \n", unit, aiop, chan);
- return;
- }
- ChanStatus = sGetChanStatus(&rp->rp_channel);
- rp->rp_cts = (ChanStatus & CTS_ACT) != 0;
- line = (unit << 5) | (aiop << 3) | chan;
- rp_table(line) = rp;
- }
- }
-}
-
-static
-int
-rpattach(dev)
-struct isa_device *dev;
-{
- int iobase, unit, /*rpmajor,*/ oldspl;
- int num_ports, num_chan, num_aiops;
- int aiop, chan, port;
- int ChanStatus, line, i, count;
- unsigned int aiopio[MAX_AIOPS_PER_BOARD];
- struct rp_port *rp;
- struct tty *tty;
- CONTROLLER_t *ctlp;
-
- iobase = dev->id_iobase;
- unit = dev->id_unit;
- ndevs = unit;
-
- for(aiop=0; aiop < MAX_AIOPS_PER_BOARD; aiop++)
- aiopio[aiop] = iobase + (aiop * 0x400);
-
- ctlp = sCtlNumToCtlPtr(unit);
- num_aiops = sInitController(ctlp, unit,
- rp_controller_port + ((unit-rp_pcicount) * 0x400),
- aiopio, MAX_AIOPS_PER_BOARD, 0,
- FREQ_DIS, 0);
-
- num_ports = 0;
- for(aiop=0; aiop < num_aiops; aiop++) {
- sResetAiopByNum(ctlp, aiop);
- sEnAiop(ctlp, aiop);
- num_ports += sGetAiopNumChan(ctlp, aiop);
- }
- printf("RocketPort%d = %d ports\n", unit, num_ports);
- rp_num_ports[unit] = num_ports;
-
- rp = (struct rp_port *)
- malloc(sizeof(struct rp_port) * num_ports, M_TTYS, M_NOWAIT);
- if(rp == 0) {
- printf("rp_attach: Could not malloc rp_ports structures\n");
- return(0);
- }
-
- count = unit * 32; /* board # times max ports per card SG */
- for(i=count;i < (count + rp_num_ports[unit]);i++)
- minor_to_unit[i] = unit;
-
- bzero(rp, sizeof(struct rp_port) * num_ports);
- tty = (struct tty *)
- malloc(sizeof(struct tty) * num_ports, M_TTYS, M_NOWAIT);
- if(tty == 0) {
- printf("rp_attach: Could not malloc tty structures\n");
- return(0);
- }
- bzero(tty, sizeof(struct tty) * num_ports);
-
- oldspl = spltty();
- rp_addr(unit) = rp;
- splx(oldspl);
-
- cdevsw_add(&rp_cdevsw);
-
- port = 0;
- for(aiop=0; aiop < num_aiops; aiop++) {
- num_chan = sGetAiopNumChan(ctlp, aiop);
- for(chan=0; chan < num_chan; chan++, port++, rp++, tty++) {
- rp->rp_tty = tty;
- rp->rp_port = port;
- rp->rp_ctlp = ctlp;
- rp->rp_unit = unit;
- rp->rp_chan = chan;
- rp->rp_aiop = aiop;
-
- tty->t_line = 0;
- /* tty->t_termios = deftermios;
- */
- rp->dtr_wait = 3 * hz;
- rp->it_in.c_iflag = 0;
- rp->it_in.c_oflag = 0;
- rp->it_in.c_cflag = TTYDEF_CFLAG;
- rp->it_in.c_lflag = 0;
- termioschars(&rp->it_in);
- /* termioschars(&tty->t_termios);
- */
- rp->it_in.c_ispeed = rp->it_in.c_ospeed = TTYDEF_SPEED;
- rp->it_out = rp->it_in;
-
- rp->rp_intmask = RXF_TRIG | TXFIFO_MT | SRC_INT |
- DELTA_CD | DELTA_CTS | DELTA_DSR;
- ChanStatus = sGetChanStatus(&rp->rp_channel);
- if(sInitChan(ctlp, &rp->rp_channel, aiop, chan) == 0) {
- printf("RocketPort sInitChan(%d, %d, %d) failed
- \n", unit, aiop, chan);
- return(0);
- }
- ChanStatus = sGetChanStatus(&rp->rp_channel);
- rp->rp_cts = (ChanStatus & CTS_ACT) != 0;
- line = (unit << 5) | (aiop << 3) | chan;
- rp_table(line) = rp;
- }
- }
-
- return(1);
-}
-
-int
-rpopen(dev, flag, mode, p)
- dev_t dev;
- int flag, mode;
- struct proc *p;
-{
- struct rp_port *rp;
- int unit, port, mynor, umynor, flags; /* SG */
- struct tty *tp;
- int oldspl, error;
- unsigned int IntMask, ChanStatus;
-
-
- umynor = (((minor(dev) >> 16) -1) * 32); /* SG */
- port = (minor(dev) & 0x1f); /* SG */
- mynor = (port + umynor); /* SG */
- unit = minor_to_unit[mynor];
- if(IS_CONTROL(dev))
- return(0);
- rp = rp_addr(unit) + port;
-/* rp->rp_tty = &rp_tty[rp->rp_port];
-*/
- tp = rp->rp_tty;
- dev->si_tty = tp;
-
- oldspl = spltty();
-
-open_top:
- while(rp->state & ~SET_DTR) {
- error = tsleep(&rp->dtr_wait, TTIPRI | PCATCH, "rpdtr", 0);
- if(error != 0)
- goto out;
- }
-
- if(tp->t_state & TS_ISOPEN) {
- if(IS_CALLOUT(dev)) {
- if(!rp->active_out) {
- error = EBUSY;
- goto out;
- }
- } else {
- if(rp->active_out) {
- if(flag & O_NONBLOCK) {
- error = EBUSY;
- goto out;
- }
- error = tsleep(&rp->active_out,
- TTIPRI | PCATCH, "rpbi", 0);
- if(error != 0)
- goto out;
- goto open_top;
- }
- }
- if(tp->t_state & TS_XCLUDE &&
- suser(p)) {
- splx(oldspl);
- return(EBUSY);
- }
- }
- else {
- tp->t_dev = dev;
- tp->t_param = rpparam;
- tp->t_oproc = rpstart;
- tp->t_stop = rpstop;
- tp->t_line = 0;
- tp->t_termios = IS_CALLOUT(dev) ? rp->it_out : rp->it_in;
- flags = 0;
- flags |= SET_RTS;
- flags |= SET_DTR;
- rp->rp_channel.TxControl[3] =
- ((rp->rp_channel.TxControl[3]
- & ~(SET_RTS | SET_DTR)) | flags);
- sOutDW(rp->rp_channel.IndexAddr,
- *(DWord_t *) &(rp->rp_channel.TxControl[0]));
- sSetRxTrigger(&rp->rp_channel, TRIG_1);
- sDisRxStatusMode(&rp->rp_channel);
- sFlushRxFIFO(&rp->rp_channel);
- sFlushTxFIFO(&rp->rp_channel);
-
- sEnInterrupts(&rp->rp_channel,
- (TXINT_EN|MCINT_EN|RXINT_EN|SRCINT_EN|CHANINT_EN));
- sSetRxTrigger(&rp->rp_channel, TRIG_1);
-
- sDisRxStatusMode(&rp->rp_channel);
- sClrTxXOFF(&rp->rp_channel);
-
-/* sDisRTSFlowCtl(&rp->rp_channel);
- sDisCTSFlowCtl(&rp->rp_channel);
-*/
- sDisTxSoftFlowCtl(&rp->rp_channel);
-
- sStartRxProcessor(&rp->rp_channel);
-
- sEnRxFIFO(&rp->rp_channel);
- sEnTransmit(&rp->rp_channel);
-
-/* sSetDTR(&rp->rp_channel);
- sSetRTS(&rp->rp_channel);
-*/
-
- ++rp->wopeners;
- error = rpparam(tp, &tp->t_termios);
- --rp->wopeners;
- if(error != 0) {
- splx(oldspl);
- return(error);
- }
-
- rp_num_ports_open++;
-
- IntMask = sGetChanIntID(&rp->rp_channel);
- IntMask = IntMask & rp->rp_intmask;
- ChanStatus = sGetChanStatus(&rp->rp_channel);
- if((IntMask & DELTA_CD) || IS_CALLOUT(dev)) {
- if((ChanStatus & CD_ACT) || IS_CALLOUT(dev)) {
- (void)(*linesw[tp->t_line].l_modem)(tp, 1);
- }
- }
-
- if(rp_num_ports_open == 1)
- timeout(rp_do_poll, (void *)NULL, POLL_INTERVAL);
-
- }
-
- if(!(flag&O_NONBLOCK) && !(tp->t_cflag&CLOCAL) &&
- !(tp->t_state & TS_CARR_ON) && !(IS_CALLOUT(dev))) {
- ++rp->wopeners;
- error = tsleep(TSA_CARR_ON(tp), TTIPRI | PCATCH,
- "rpdcd", 0);
- --rp->wopeners;
- if(error != 0)
- goto out;
- goto open_top;
- }
- error = (*linesw[tp->t_line].l_open)(dev, tp);
-
- rp_disc_optim(tp, &tp->t_termios, rp);
- if(tp->t_state & TS_ISOPEN && IS_CALLOUT(dev))
- rp->active_out = TRUE;
-
-/* if(rp_num_ports_open == 1)
- timeout(rp_do_poll, (void *)NULL, POLL_INTERVAL);
-*/
-out:
- splx(oldspl);
- if(!(tp->t_state & TS_ISOPEN) && rp->wopeners == 0) {
- rphardclose(rp);
- }
- return(error);
-}
-
-int
-rpclose(dev, flag, mode, p)
- dev_t dev;
- int flag, mode;
- struct proc *p;
-{
- int oldspl, unit, mynor, umynor, port; /* SG */
- struct rp_port *rp;
- struct tty *tp;
- CHANNEL_t *cp;
-
- umynor = (((minor(dev) >> 16) -1) * 32); /* SG */
- port = (minor(dev) & 0x1f); /* SG */
- mynor = (port + umynor); /* SG */
- unit = minor_to_unit[mynor]; /* SG */
-
- if(IS_CONTROL(dev))
- return(0);
- rp = rp_addr(unit) + port;
- cp = &rp->rp_channel;
- tp = rp->rp_tty;
-
- oldspl = spltty();
- (*linesw[tp->t_line].l_close)(tp, flag);
- rp_disc_optim(tp, &tp->t_termios, rp);
- rpstop(tp, FREAD | FWRITE);
- rphardclose(rp);
-
- tp->t_state &= ~TS_BUSY;
- ttyclose(tp);
-
- splx(oldspl);
-
- return(0);
-}
-
-static void
-rphardclose(struct rp_port *rp)
-{
- int mynor;
- struct tty *tp;
- CHANNEL_t *cp;
-
- cp = &rp->rp_channel;
- tp = rp->rp_tty;
- mynor = MINOR_MAGIC(tp->t_dev);
-
- sFlushRxFIFO(cp);
- sFlushTxFIFO(cp);
- sDisTransmit(cp);
- sDisInterrupts(cp, TXINT_EN|MCINT_EN|RXINT_EN|SRCINT_EN|CHANINT_EN);
- sDisRTSFlowCtl(cp);
- sDisCTSFlowCtl(cp);
- sDisTxSoftFlowCtl(cp);
- sClrTxXOFF(cp);
-
- if(tp->t_cflag&HUPCL || !(tp->t_state&TS_ISOPEN) || !rp->active_out) {
- sClrDTR(cp);
- }
- if(IS_CALLOUT(tp->t_dev)) {
- sClrDTR(cp);
- }
- if(rp->dtr_wait != 0) {
- timeout(rpdtrwakeup, rp, rp->dtr_wait);
- rp->state |= ~SET_DTR;
- }
-
- rp->active_out = FALSE;
- wakeup(&rp->active_out);
- wakeup(TSA_CARR_ON(tp));
-}
-
-static
-int
-rpwrite(dev, uio, flag)
- dev_t dev;
- struct uio *uio;
- int flag;
-{
- struct rp_port *rp;
- struct tty *tp;
- int unit, mynor, port, umynor, error = 0; /* SG */
-
- umynor = (((minor(dev) >> 16) -1) * 32); /* SG */
- port = (minor(dev) & 0x1f); /* SG */
- mynor = (port + umynor); /* SG */
- unit = minor_to_unit[mynor]; /* SG */
-
- if(IS_CONTROL(dev))
- return(ENODEV);
- rp = rp_addr(unit) + port;
- tp = rp->rp_tty;
- while(rp->rp_disable_writes) {
- rp->rp_waiting = 1;
- error = ttysleep(tp, (caddr_t)rp, TTOPRI|PCATCH, "rp_write", 0);
- if (error)
- return(error);
- }
-
- error = (*linesw[tp->t_line].l_write)(tp, uio, flag);
- return error;
-}
-
-static void
-rpdtrwakeup(void *chan)
-{
- struct rp_port *rp;
-
- rp = (struct rp_port *)chan;
- rp->state &= SET_DTR;
- wakeup(&rp->dtr_wait);
-}
-
-int
-rpioctl(dev, cmd, data, flag, p)
- dev_t dev;
- u_long cmd;
- caddr_t data;
- int flag;
- struct proc *p;
-{
- struct rp_port *rp;
- CHANNEL_t *cp;
- struct tty *tp;
- int unit, mynor, port, umynor; /* SG */
- int oldspl;
- int error = 0;
- int arg, flags, result, ChanStatus;
- int oldcmd;
- struct termios term, *t;
-
- umynor = (((minor(dev) >> 16) -1) * 32); /* SG */
- port = (minor(dev) & 0x1f); /* SG */
- mynor = (port + umynor); /* SG */
- unit = minor_to_unit[mynor];
- rp = rp_addr(unit) + port;
-
- if(IS_CONTROL(dev)) {
- struct termios *ct;
-
- switch (IS_CONTROL(dev)) {
- case CONTROL_INIT_STATE:
- ct = IS_CALLOUT(dev) ? &rp->it_out : &rp->it_in;
- break;
- case CONTROL_LOCK_STATE:
- ct = IS_CALLOUT(dev) ? &rp->lt_out : &rp->lt_in;
- break;
- default:
- return(ENODEV); /* /dev/nodev */
- }
- switch (cmd) {
- case TIOCSETA:
- error = suser(p);
- if(error != 0)
- return(error);
- *ct = *(struct termios *)data;
- return(0);
- case TIOCGETA:
- *(struct termios *)data = *ct;
- return(0);
- case TIOCGETD:
- *(int *)data = TTYDISC;
- return(0);
- case TIOCGWINSZ:
- bzero(data, sizeof(struct winsize));
- return(0);
- default:
- return(ENOTTY);
- }
- }
-
- tp = rp->rp_tty;
- cp = &rp->rp_channel;
-
-#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
- term = tp->t_termios;
- oldcmd = cmd;
- error = ttsetcompat(tp, &cmd, data, &term);
- if(error != 0)
- return(error);
- if(cmd != oldcmd) {
- data = (caddr_t)&term;
- }
-#endif
- if((cmd == TIOCSETA) || (cmd == TIOCSETAW) || (cmd == TIOCSETAF)) {
- int cc;
- struct termios *dt = (struct termios *)data;
- struct termios *lt = IS_CALLOUT(dev)
- ? &rp->lt_out : &rp->lt_in;
-
- dt->c_iflag = (tp->t_iflag & lt->c_iflag)
- | (dt->c_iflag & ~lt->c_iflag);
- dt->c_oflag = (tp->t_oflag & lt->c_oflag)
- | (dt->c_oflag & ~lt->c_oflag);
- dt->c_cflag = (tp->t_cflag & lt->c_cflag)
- | (dt->c_cflag & ~lt->c_cflag);
- dt->c_lflag = (tp->t_lflag & lt->c_lflag)
- | (dt->c_lflag & ~lt->c_lflag);
- for(cc = 0; cc < NCCS; ++cc)
- if((lt->c_cc[cc] = tp->t_cc[cc]) != 0)
- dt->c_cc[cc] = tp->t_cc[cc];
- if(lt->c_ispeed != 0)
- dt->c_ispeed = tp->t_ispeed;
- if(lt->c_ospeed != 0)
- dt->c_ospeed = tp->t_ospeed;
- }
-
- t = &tp->t_termios;
-
- error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p);
- if(error != ENOIOCTL) {
- return(error);
- }
- oldspl = spltty();
-
- flags = rp->rp_channel.TxControl[3];
-
- error = ttioctl(tp, cmd, data, flag);
- flags = rp->rp_channel.TxControl[3];
- rp_disc_optim(tp, &tp->t_termios, rp);
- if(error != ENOIOCTL) {
- splx(oldspl);
- return(error);
- }
- switch(cmd) {
- case TIOCSBRK:
- sSendBreak(&rp->rp_channel);
- break;
-
- case TIOCCBRK:
- sClrBreak(&rp->rp_channel);
- break;
-
- case TIOCSDTR:
- sSetDTR(&rp->rp_channel);
- sSetRTS(&rp->rp_channel);
- break;
-
- case TIOCCDTR:
- sClrDTR(&rp->rp_channel);
- break;
-
- case TIOCMSET:
- arg = *(int *) data;
- flags = 0;
- if(arg & TIOCM_RTS)
- flags |= SET_RTS;
- if(arg & TIOCM_DTR)
- flags |= SET_DTR;
- rp->rp_channel.TxControl[3] =
- ((rp->rp_channel.TxControl[3]
- & ~(SET_RTS | SET_DTR)) | flags);
- sOutDW(rp->rp_channel.IndexAddr,
- *(DWord_t *) &(rp->rp_channel.TxControl[0]));
- break;
- case TIOCMBIS:
- arg = *(int *) data;
- flags = 0;
- if(arg & TIOCM_RTS)
- flags |= SET_RTS;
- if(arg & TIOCM_DTR)
- flags |= SET_DTR;
- rp->rp_channel.TxControl[3] |= flags;
- sOutDW(rp->rp_channel.IndexAddr,
- *(DWord_t *) &(rp->rp_channel.TxControl[0]));
- break;
- case TIOCMBIC:
- arg = *(int *) data;
- flags = 0;
- if(arg & TIOCM_RTS)
- flags |= SET_RTS;
- if(arg & TIOCM_DTR)
- flags |= SET_DTR;
- rp->rp_channel.TxControl[3] &= ~flags;
- sOutDW(rp->rp_channel.IndexAddr,
- *(DWord_t *) &(rp->rp_channel.TxControl[0]));
- break;
-
-
- case TIOCMGET:
- ChanStatus = sGetChanStatusLo(&rp->rp_channel);
- flags = rp->rp_channel.TxControl[3];
- result = TIOCM_LE; /* always on while open for some reason */
- result |= (((flags & SET_DTR) ? TIOCM_DTR : 0)
- | ((flags & SET_RTS) ? TIOCM_RTS : 0)
- | ((ChanStatus & CD_ACT) ? TIOCM_CAR : 0)
- | ((ChanStatus & DSR_ACT) ? TIOCM_DSR : 0)
- | ((ChanStatus & CTS_ACT) ? TIOCM_CTS : 0));
-
- if(rp->rp_channel.RxControl[2] & RTSFC_EN)
- {
- result |= TIOCM_RTS;
- }
-
- *(int *)data = result;
- break;
- case TIOCMSDTRWAIT:
- error = suser(p);
- if(error != 0) {
- splx(oldspl);
- return(error);
- }
- rp->dtr_wait = *(int *)data * hz/100;
- break;
- case TIOCMGDTRWAIT:
- *(int *)data = rp->dtr_wait * 100/hz;
- break;
- default:
- splx(oldspl);
- return ENOTTY;
- }
- splx(oldspl);
- return(0);
-}
-
-static struct speedtab baud_table[] = {
- B0, 0, B50, BRD50, B75, BRD75,
- B110, BRD110, B134, BRD134, B150, BRD150,
- B200, BRD200, B300, BRD300, B600, BRD600,
- B1200, BRD1200, B1800, BRD1800, B2400, BRD2400,
- B4800, BRD4800, B9600, BRD9600, B19200, BRD19200,
- B38400, BRD38400, B7200, BRD7200, B14400, BRD14400,
- B57600, BRD57600, B76800, BRD76800,
- B115200, BRD115200, B230400, BRD230400,
- -1, -1
-};
-
-static int
-rpparam(tp, t)
- struct tty *tp;
- struct termios *t;
-{
- struct rp_port *rp;
- CHANNEL_t *cp;
- int unit, mynor, port, umynor; /* SG */
- int oldspl, cflag, iflag, oflag, lflag;
- int ospeed;
-
-
- umynor = (((minor(tp->t_dev) >> 16) -1) * 32); /* SG */
- port = (minor(tp->t_dev) & 0x1f); /* SG */
- mynor = (port + umynor); /* SG */
-
- unit = minor_to_unit[mynor];
- rp = rp_addr(unit) + port;
- cp = &rp->rp_channel;
- oldspl = spltty();
-
- cflag = t->c_cflag;
- iflag = t->c_iflag;
- oflag = t->c_oflag;
- lflag = t->c_lflag;
-
- ospeed = ttspeedtab(t->c_ispeed, baud_table);
- if(ospeed < 0 || t->c_ispeed != t->c_ospeed)
- return(EINVAL);
-
- tp->t_ispeed = t->c_ispeed;
- tp->t_ospeed = t->c_ospeed;
- tp->t_cflag = cflag;
- tp->t_iflag = iflag;
- tp->t_oflag = oflag;
- tp->t_lflag = lflag;
-
- if(t->c_ospeed == 0) {
- sClrDTR(cp);
- return(0);
- }
- rp->rp_fifo_lw = ((t->c_ospeed*2) / 1000) +1;
-
- /* Set baud rate ----- we only pay attention to ispeed */
- sSetDTR(cp);
- sSetRTS(cp);
- sSetBaud(cp, ospeed);
-
- if(cflag & CSTOPB) {
- sSetStop2(cp);
- } else {
- sSetStop1(cp);
- }
-
- if(cflag & PARENB) {
- sEnParity(cp);
- if(cflag & PARODD) {
- sSetOddParity(cp);
- } else {
- sSetEvenParity(cp);
- }
- }
- else {
- sDisParity(cp);
- }
- if((cflag & CSIZE) == CS8) {
- sSetData8(cp);
- rp->rp_imask = 0xFF;
- } else {
- sSetData7(cp);
- rp->rp_imask = 0x7F;
- }
-
- if(iflag & ISTRIP) {
- rp->rp_imask &= 0x7F;
- }
-
- if(cflag & CLOCAL) {
- rp->rp_intmask &= ~DELTA_CD;
- } else {
- rp->rp_intmask |= DELTA_CD;
- }
-
- /* Put flow control stuff here */
-
- if(cflag & CCTS_OFLOW) {
- sEnCTSFlowCtl(cp);
- } else {
- sDisCTSFlowCtl(cp);
- }
-
- if(cflag & CRTS_IFLOW) {
- rp->rp_rts_iflow = 1;
- } else {
- rp->rp_rts_iflow = 0;
- }
-
- if(cflag & CRTS_IFLOW) {
- sEnRTSFlowCtl(cp);
- } else {
- sDisRTSFlowCtl(cp);
- }
- rp_disc_optim(tp, t, rp);
-
- if((cflag & CLOCAL) || (sGetChanStatusLo(cp) & CD_ACT)) {
- tp->t_state |= TS_CARR_ON;
- wakeup(TSA_CARR_ON(tp));
- }
-
-/* tp->t_state |= TS_CAN_BYPASS_L_RINT;
- flags = rp->rp_channel.TxControl[3];
- if(flags & SET_DTR)
- else
- if(flags & SET_RTS)
- else
-*/
- splx(oldspl);
-
- return(0);
-}
-
-static void
-rp_disc_optim(tp, t, rp)
-struct tty *tp;
-struct termios *t;
-struct rp_port *rp;
-{
- if(!(t->c_iflag & (ICRNL | IGNCR | IMAXBEL | INLCR | ISTRIP | IXON))
- &&(!(t->c_iflag & BRKINT) || (t->c_iflag & IGNBRK))
- &&(!(t->c_iflag & PARMRK)
- ||(t->c_iflag & (IGNPAR | IGNBRK)) == (IGNPAR | IGNBRK))
- && !(t->c_lflag & (ECHO | ICANON | IEXTEN | ISIG | PENDIN))
- && linesw[tp->t_line].l_rint == ttyinput)
- tp->t_state |= TS_CAN_BYPASS_L_RINT;
- else
- tp->t_state &= ~TS_CAN_BYPASS_L_RINT;
-}
-
-static void
-rpstart(tp)
- struct tty *tp;
-{
- struct rp_port *rp;
- CHANNEL_t *cp;
- struct clist *qp;
- int unit, mynor, port, umynor; /* SG */
- char ch, flags;
- int spl, xmit_fifo_room;
- int count;
-
-
- umynor = (((minor(tp->t_dev) >> 16) -1) * 32); /* SG */
- port = (minor(tp->t_dev) & 0x1f); /* SG */
- mynor = (port + umynor); /* SG */
- unit = minor_to_unit[mynor];
- rp = rp_addr(unit) + port;
- cp = &rp->rp_channel;
- flags = rp->rp_channel.TxControl[3];
- spl = spltty();
-
- if(tp->t_state & (TS_TIMEOUT | TS_TTSTOP)) {
- ttwwakeup(tp);
- splx(spl);
- return;
- }
- if(rp->rp_xmit_stopped) {
- sEnTransmit(cp);
- rp->rp_xmit_stopped = 0;
- }
- count = sGetTxCnt(cp);
-
- if(tp->t_outq.c_cc == 0) {
- if((tp->t_state & TS_BUSY) && (count == 0)) {
- tp->t_state &= ~TS_BUSY;
- }
- ttwwakeup(tp);
- splx(spl);
- return;
- }
- xmit_fifo_room = TXFIFO_SIZE - sGetTxCnt(cp);
- qp = &tp->t_outq;
- count = 0;
- if(xmit_fifo_room > 0 && qp->c_cc > 0) {
- tp->t_state |= TS_BUSY;
- }
- while(xmit_fifo_room > 0 && qp->c_cc > 0) {
- ch = getc(qp);
- sOutB(sGetTxRxDataIO(cp), ch);
- xmit_fifo_room--;
- count++;
- }
- rp->rp_restart = (qp->c_cc > 0) ? rp->rp_fifo_lw : 0;
-
- ttwwakeup(tp);
- splx(spl);
-}
-
-static
-void
-rpstop(tp, flag)
- register struct tty *tp;
- int flag;
-{
- struct rp_port *rp;
- CHANNEL_t *cp;
- int unit, mynor, port, umynor; /* SG */
- int spl;
-
- umynor = (((minor(tp->t_dev) >> 16) -1) * 32); /* SG */
- port = (minor(tp->t_dev) & 0x1f); /* SG */
- mynor = (port + umynor); /* SG */
- unit = minor_to_unit[mynor];
- rp = rp_addr(unit) + port;
- cp = &rp->rp_channel;
-
- spl = spltty();
-
- if(tp->t_state & TS_BUSY) {
- if((tp->t_state&TS_TTSTOP) == 0) {
- sFlushTxFIFO(cp);
- } else {
- if(rp->rp_xmit_stopped == 0) {
- sDisTransmit(cp);
- rp->rp_xmit_stopped = 1;
- }
- }
- }
- splx(spl);
- rpstart(tp);
-}
diff --git a/sys/dev/rp/rpreg.h b/sys/dev/rp/rpreg.h
deleted file mode 100644
index fcc100b9cd10..000000000000
--- a/sys/dev/rp/rpreg.h
+++ /dev/null
@@ -1,1043 +0,0 @@
-/*
- * Copyright (c) Comtrol Corporation <support@comtrol.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted prodived that the follwoing conditions
- * are met.
- * 1. Redistributions of source code must retain the above copyright
- * notive, this list of conditions and the following disclainer.
- * 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 prodided 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 Comtrol Corporation.
- * 4. The name of Comtrol Corporation may not be used to endorse or
- * promote products derived from this software without specific
- * prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY COMTROL CORPORATION ``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 COMTROL CORPORATION 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, LIFE 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 OS-specific defines - rpreg.h - for RocketPort FreeBSD
- */
-
-typedef unsigned char Byte_t;
-typedef unsigned int ByteIO_t;
-
-typedef unsigned int Word_t;
-typedef unsigned int WordIO_t;
-
-typedef unsigned long DWord_t;
-typedef unsigned int DWordIO_t;
-
-#define sOutB(a, b) outb(a, b)
-#define sOutW(a, b) outw(a, b)
-#define sOutDW(a, b) outl(a, b)
-#define sInB(a) (inb(a))
-#define sInW(a) (inw(a))
-#define sOutStrW(port, addr, count) outsw(port, addr, count)
-#define sInStrW(port, addr, count) insw(port, addr, count)
-
-/*
- * End of OS-specific defines
- */
-
-#define ROCKET_H
-
-#define CTL_SIZE 4
-#define AIOP_CTL_SIZE 4
-#define CHAN_AIOP_SIZE 8
-#define MAX_PORTS_PER_AIOP 8
-#define MAX_AIOPS_PER_BOARD 4
-#define MAX_PORTS_PER_BOARD 32
-
-/* Bus Type ID */
-#define isISA 0
-#define isPCI 1
-#define isMC 2
-
-/* Controller ID numbers */
-#define CTLID_NULL -1 /* no controller exists */
-#define CTLID_0001 0x0001 /* controller release 1 */
-
-/* PCI IDs */
-#define RP_VENDOR_ID 0x11FE
-#define RP_DEVICE_ID_8OCTA 0x0001
-#define RP_DEVICE_ID_8INTF 0x0002
-#define RP_DEVICE_ID_16INTF 0x0003
-#define RP_DEVICE_ID_32INTF 0x0004
-
-/* AIOP ID numbers, identifies AIOP type implementing channel */
-#define AIOPID_NULL -1 /* no AIOP or channel exists */
-#define AIOPID_0001 0x0001 /* AIOP release 1 */
-
-#define NULLDEV -1 /* identifies non-existant device */
-#define NULLCTL -1 /* identifies non-existant controller */
-#define NULLCTLPTR (CONTROLLER_T *)0 /* identifies non-existant controller */
-#define NULLAIOP -1 /* identifies non-existant AIOP */
-#define NULLCHAN -1 /* identifies non-existant channel */
-
-/************************************************************************
- Global Register Offsets - Direct Access - Fixed values
-************************************************************************/
-
-#define _CMD_REG 0x38 /* Command Register 8 Write */
-#define _INT_CHAN 0x39 /* Interrupt Channel Register 8 Read */
-#define _INT_MASK 0x3A /* Interrupt Mask Register 8 Read / Write */
-#define _UNUSED 0x3B /* Unused 8 */
-#define _INDX_ADDR 0x3C /* Index Register Address 16 Write */
-#define _INDX_DATA 0x3E /* Index Register Data 8/16 Read / Write */
-
-/************************************************************************
- Channel Register Offsets for 1st channel in AIOP - Direct Access
-************************************************************************/
-#define _TD0 0x00 /* Transmit Data 16 Write */
-#define _RD0 0x00 /* Receive Data 16 Read */
-#define _CHN_STAT0 0x20 /* Channel Status 8/16 Read / Write */
-#define _FIFO_CNT0 0x10 /* Transmit/Receive FIFO Count 16 Read */
-#define _INT_ID0 0x30 /* Interrupt Identification 8 Read */
-
-/************************************************************************
- Tx Control Register Offsets - Indexed - External - Fixed
-************************************************************************/
-#define _TX_ENBLS 0x980 /* Tx Processor Enables Register 8 Read / Write */
-#define _TXCMP1 0x988 /* Transmit Compare Value #1 8 Read / Write */
-#define _TXCMP2 0x989 /* Transmit Compare Value #2 8 Read / Write */
-#define _TXREP1B1 0x98A /* Tx Replace Value #1 - Byte 1 8 Read / Write */
-#define _TXREP1B2 0x98B /* Tx Replace Value #1 - Byte 2 8 Read / Write */
-#define _TXREP2 0x98C /* Transmit Replace Value #2 8 Read / Write */
-
-/************************************************************************
- Receive FIFO
-************************************************************************/
-#define RXFIFO_DATA 0x5f
-#define RXFIFO_OUT 0x5c
-#define RXFIFO_EN 0x08
-#define RXFIFO_DIS 0xa7
-
-/************************************************************************
-Memory Controller Register Offsets - Indexed - External - Fixed
-************************************************************************/
-#define _RX_FIFO 0x000 /* Rx FIFO */
-#define _TX_FIFO 0x800 /* Tx FIFO */
-#define _RXF_OUTP 0x990 /* Rx FIFO OUT pointer 16 Read / Write */
-#define _RXF_INP 0x992 /* Rx FIFO IN pointer 16 Read / Write */
-#define _TXF_OUTP 0x994 /* Tx FIFO OUT pointer 8 Read / Write */
-#define _TXF_INP 0x995 /* Tx FIFO IN pointer 8 Read / Write */
-#define _TXP_CNT 0x996 /* Tx Priority Count 8 Read / Write */
-#define _TXP_PNTR 0x997 /* Tx Priority Pointer 8 Read / Write */
-
-#define PRI_PEND 0x80 /* Priority data pending (bit7, Tx pri cnt) */
-#define TXFIFO_SIZE 255 /* size of Tx FIFO */
-#define RXFIFO_SIZE 1023 /* size of Rx FIFO */
-
-/************************************************************************
-Tx Priority Buffer - Indexed - External - Fixed
-************************************************************************/
-#define _TXP_BUF 0x9C0 /* Tx Priority Buffer 32 Bytes Read / Write */
-#define TXP_SIZE 0x20 /* 32 bytes */
-
-/************************************************************************
-Channel Register Offsets - Indexed - Internal - Fixed
-************************************************************************/
-
-#define _TX_CTRL 0xFF0 /* Transmit Control 16 Write */
-#define _RX_CTRL 0xFF2 /* Receive Control 8 Write */
-#define _BAUD 0xFF4 /* Baud Rate 16 Write */
-#define _CLK_PRE 0xFF6 /* Clock Prescaler 8 Write */
-
-#define CLOCK_PRESC 0x19 /* mod 9 (divide by 10) prescale */
-
-#define BRD50 4607
-#define BRD75 3071
-#define BRD110 2094
-#define BRD134 1712
-#define BRD150 1535
-#define BRD200 1151
-#define BRD300 767
-#define BRD600 383
-#define BRD1200 191
-#define BRD1800 127
-#define BRD2000 114
-#define BRD2400 95
-#define BRD3600 64
-#define BRD4800 47
-#define BRD7200 31
-#define BRD9600 23
-#define BRD14400 15
-#define BRD19200 11
-#define BRD38400 5
-#define BRD57600 3
-#define BRD76800 2
-#define BRD115200 1
-#define BRD230400 0
-
-#define STMBREAK 0x08 /* BREAK */
-#define STMFRAME 0x04 /* framing error */
-#define STMRCVROVR 0x02 /* receiver over run error */
-#define STMPARITY 0x01 /* parity error */
-#define STMERROR (STMBREAK | STMFRAME | STMPARITY)
-#define STMBREAKH 0x800 /* BREAK */
-#define STMFRAMEH 0x400 /* framing error */
-#define STMRCVROVRH 0x200 /* receiver over run error */
-#define STMPARITYH 0x100 /* parity error */
-#define STMERRORH (STMBREAKH | STMFRAMEH | STMPARITYH)
-
-#define CTS_ACT 0x20 /* CTS input asserted */
-#define DSR_ACT 0x10 /* DSR input asserted */
-#define CD_ACT 0x08 /* CD input asserted */
-#define TXFIFOMT 0x04 /* Tx FIFO is empty */
-#define TXSHRMT 0x02 /* Tx shift register is empty */
-#define RDA 0x01 /* Rx data available */
-#define DRAINED (TXFIFOMT | TXSHRMT) /* indicates Tx is drained */
-
-#define STATMODE 0x8000 /* status mode enable bit */
-#define RXFOVERFL 0x2000 /* receive FIFO overflow */
-#define RX2MATCH 0x1000 /* receive compare byte 2 match */
-#define RX1MATCH 0x0800 /* receive compare byte 1 match */
-#define RXBREAK 0x0400 /* received BREAK */
-#define RXFRAME 0x0200 /* received framing error */
-#define RXPARITY 0x0100 /* received parity error */
-#define STATERROR (RXBREAK | RXFRAME | RXPARITY)
-
-#define CTSFC_EN 0x80 /* CTS flow control enable bit */
-#define RTSTOG_EN 0x40 /* RTS toggle enable bit */
-#define TXINT_EN 0x10 /* transmit interrupt enable */
-#define STOP2 0x08 /* enable 2 stop bits (0 = 1 stop) */
-#define PARITY_EN 0x04 /* enable parity (0 = no parity) */
-#define EVEN_PAR 0x02 /* even parity (0 = odd parity) */
-#define DATA8BIT 0x01 /* 8 bit data (0 = 7 bit data) */
-
-#define SETBREAK 0x10 /* send break condition (must clear) */
-#define LOCALLOOP 0x08 /* local loopback set for test */
-#define SET_DTR 0x04 /* assert DTR */
-#define SET_RTS 0x02 /* assert RTS */
-#define TX_ENABLE 0x01 /* enable transmitter */
-
-#define RTSFC_EN 0x40 /* RTS flow control enable */
-#define RXPROC_EN 0x20 /* receive processor enable */
-#define TRIG_NO 0x00 /* Rx FIFO trigger level 0 (no trigger) */
-#define TRIG_1 0x08 /* trigger level 1 char */
-#define TRIG_1_2 0x10 /* trigger level 1/2 */
-#define TRIG_7_8 0x18 /* trigger level 7/8 */
-#define TRIG_MASK 0x18 /* trigger level mask */
-#define SRCINT_EN 0x04 /* special Rx condition interrupt enable */
-#define RXINT_EN 0x02 /* Rx interrupt enable */
-#define MCINT_EN 0x01 /* modem change interrupt enable */
-
-#define RXF_TRIG 0x20 /* Rx FIFO trigger level interrupt */
-#define TXFIFO_MT 0x10 /* Tx FIFO empty interrupt */
-#define SRC_INT 0x08 /* special receive condition interrupt */
-#define DELTA_CD 0x04 /* CD change interrupt */
-#define DELTA_CTS 0x02 /* CTS change interrupt */
-#define DELTA_DSR 0x01 /* DSR change interrupt */
-
-#define REP1W2_EN 0x10 /* replace byte 1 with 2 bytes enable */
-#define IGN2_EN 0x08 /* ignore byte 2 enable */
-#define IGN1_EN 0x04 /* ignore byte 1 enable */
-#define COMP2_EN 0x02 /* compare byte 2 enable */
-#define COMP1_EN 0x01 /* compare byte 1 enable */
-
-#define RESET_ALL 0x80 /* reset AIOP (all channels) */
-#define TXOVERIDE 0x40 /* Transmit software off override */
-#define RESETUART 0x20 /* reset channel's UART */
-#define RESTXFCNT 0x10 /* reset channel's Tx FIFO count register */
-#define RESRXFCNT 0x08 /* reset channel's Rx FIFO count register */
-
-#define INTSTAT0 0x01 /* AIOP 0 interrupt status */
-#define INTSTAT1 0x02 /* AIOP 1 interrupt status */
-#define INTSTAT2 0x04 /* AIOP 2 interrupt status */
-#define INTSTAT3 0x08 /* AIOP 3 interrupt status */
-
-#define INTR_EN 0x08 /* allow interrupts to host */
-#define INT_STROB 0x04 /* strobe and clear interrupt line (EOI) */
-
-/**************************************************************************
- MUDBAC remapped for PCI
-**************************************************************************/
-
-#define _CFG_INT_PCI 0x40
-#define _PCI_INT_FUNC 0x3A
-
-#define PCI_STROB 0x2000
-#define INTR_EN_PCI 0x0010
-
-#define CHAN3_EN 0x08 /* enable AIOP 3 */
-#define CHAN2_EN 0x04 /* enable AIOP 2 */
-#define CHAN1_EN 0x02 /* enable AIOP 1 */
-#define CHAN0_EN 0x01 /* enable AIOP 0 */
-#define FREQ_DIS 0x00
-#define FREQ_274HZ 0x60
-#define FREQ_137HZ 0x50
-#define FREQ_69HZ 0x40
-#define FREQ_34HZ 0x30
-#define FREQ_17HZ 0x20
-#define FREQ_9HZ 0x10
-#define PERIODIC_ONLY 0x80 /* only PERIODIC interrupt */
-
-#define CHANINT_EN 0x0100 /* flags to enable/disable channel ints */
-
-#define RDATASIZE 72
-#define RREGDATASIZE 52
-
-/* Controller level information structure */
-typedef struct
-{
- int CtlID;
- int CtlNum;
- int BusType;
- WordIO_t PCIIO;
- ByteIO_t MBaseIO;
- ByteIO_t MReg1IO;
- ByteIO_t MReg2IO;
- ByteIO_t MReg3IO;
- Byte_t MReg2;
- Byte_t MReg3;
- int NumAiop;
- WordIO_t AiopIO[AIOP_CTL_SIZE];
- ByteIO_t AiopIntChanIO[AIOP_CTL_SIZE];
- int AiopID[AIOP_CTL_SIZE];
- int AiopNumChan[AIOP_CTL_SIZE];
-} CONTROLLER_T;
-
-typedef CONTROLLER_T CONTROLLER_t;
-
-/* Channel level information structure */
-typedef struct
-{
- CONTROLLER_T *CtlP;
- int AiopNum;
- int ChanID;
- int ChanNum;
-
- ByteIO_t Cmd;
- ByteIO_t IntChan;
- ByteIO_t IntMask;
- DWordIO_t IndexAddr;
- WordIO_t IndexData;
-
- WordIO_t TxRxData;
- WordIO_t ChanStat;
- WordIO_t TxRxCount;
- ByteIO_t IntID;
-
- Word_t TxFIFO;
- Word_t TxFIFOPtrs;
- Word_t RxFIFO;
- Word_t RxFIFOPtrs;
- Word_t TxPrioCnt;
- Word_t TxPrioPtr;
- Word_t TxPrioBuf;
-
- Byte_t R[RREGDATASIZE];
-
- Byte_t BaudDiv[4];
- Byte_t TxControl[4];
- Byte_t RxControl[4];
- Byte_t TxEnables[4];
- Byte_t TxCompare[4];
- Byte_t TxReplace1[4];
- Byte_t TxReplace2[4];
-} CHANNEL_T;
-
-typedef CHANNEL_T CHANNEL_t;
-typedef CHANNEL_T * CHANPTR_T;
-
-/***************************************************************************
-Function: sClrBreak
-Purpose: Stop sending a transmit BREAK signal
-Call: sClrBreak(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-*/
-#define sClrBreak(ChP) \
-{ \
- (ChP)->TxControl[3] &= ~SETBREAK; \
- sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
-}
-
-/***************************************************************************
-Function: sClrDTR
-Purpose: Clr the DTR output
-Call: sClrDTR(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-*/
-#define sClrDTR(ChP) \
-{ \
- (ChP)->TxControl[3] &= ~SET_DTR; \
- sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
-}
-
-/***************************************************************************
-Function: sClrRTS
-Purpose: Clr the RTS output
-Call: sClrRTS(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-*/
-#define sClrRTS(ChP) \
-{ \
- (ChP)->TxControl[3] &= ~SET_RTS; \
- sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
-}
-
-/***************************************************************************
-Function: sClrTxXOFF
-Purpose: Clear any existing transmit software flow control off condition
-Call: sClrTxXOFF(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-*/
-#define sClrTxXOFF(ChP) \
-{ \
- sOutB((ChP)->Cmd,TXOVERIDE | (Byte_t)(ChP)->ChanNum); \
- sOutB((ChP)->Cmd,(Byte_t)(ChP)->ChanNum); \
-}
-
-/***************************************************************************
-Function: sCtlNumToCtlPtr
-Purpose: Convert a controller number to controller structure pointer
-Call: sCtlNumToCtlPtr(CtlNum)
- int CtlNum; Controller number
-Return: CONTROLLER_T *: Ptr to controller structure
-*/
-#define sCtlNumToCtlPtr(CTLNUM) &sController[CTLNUM]
-
-/***************************************************************************
-Function: sControllerEOI
-Purpose: Strobe the MUDBAC's End Of Interrupt bit.
-Call: sControllerEOI(CtlP)
- CONTROLLER_T *CtlP; Ptr to controller structure
-*/
-#define sControllerEOI(CTLP) sOutB((CTLP)->MReg2IO,(CTLP)->MReg2 | INT_STROB)
-
-
-/***************************************************************************
-Function: sPCIControllerEOI
-Purpose: Strobe the MUDBAC's End Of Interrupt bit.
-Call: sPCIControllerEOI(CtlP)
- CONTROLLER_T *CtlP; Ptr to controller structure
-*/
-#define sPCIControllerEOI(CTLP) sOutW((CTLP)->PCIIO, PCI_STROB)
-
-/***************************************************************************
-Function: sDisAiop
-Purpose: Disable I/O access to an AIOP
-Call: sDisAiop(CltP)
- CONTROLLER_T *CtlP; Ptr to controller structure
- int AiopNum; Number of AIOP on controller
-*/
-#define sDisAiop(CTLP,AIOPNUM) \
-{ \
- (CTLP)->MReg3 &= sBitMapClrTbl[AIOPNUM]; \
- sOutB((CTLP)->MReg3IO,(CTLP)->MReg3); \
-}
-
-/***************************************************************************
-Function: sDisCTSFlowCtl
-Purpose: Disable output flow control using CTS
-Call: sDisCTSFlowCtl(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-*/
-#define sDisCTSFlowCtl(ChP) \
-{ \
- (ChP)->TxControl[2] &= ~CTSFC_EN; \
- sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
-}
-
-/***************************************************************************
-Function: DisParity
-Purpose: Disable parity
-Call: sDisParity(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-Comments: Function sSetParity() can be used in place of functions sEnParity(),
- sDisParity(), sSetOddParity(), and sSetEvenParity().
-*/
-#define sDisParity(ChP) \
-{ \
- (ChP)->TxControl[2] &= ~PARITY_EN; \
- sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
-}
-
-/***************************************************************************
-Function: sDisRxFIFO
-Purpose: Disable Rx FIFO
-Call: sDisRxFIFO(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-*/
-#define sDisRxFIFO(ChP) \
-{ \
- (ChP)->R[0x32] = 0x0a; \
- sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->R[0x30]); \
-}
-
-/***************************************************************************
-Function: sDisRxStatusMode
-Purpose: Disable the Rx status mode
-Call: sDisRxStatusMode(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-Comments: This takes the channel out of the receive status mode. All
- subsequent reads of receive data using sReadRxWord() will return
- two data bytes.
-*/
-#define sDisRxStatusMode(ChP) sOutW((ChP)->ChanStat,0)
-
-/***************************************************************************
-Function: sDisTransmit
-Purpose: Disable transmit
-Call: sDisTransmit(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
- This disables movement of Tx data from the Tx FIFO into the 1 byte
- Tx buffer. Therefore there could be up to a 2 byte latency
- between the time sDisTransmit() is called and the transmit buffer
- and transmit shift register going completely empty.
-*/
-#define sDisTransmit(ChP) \
-{ \
- (ChP)->TxControl[3] &= ~TX_ENABLE; \
- sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
-}
-
-/***************************************************************************
-Function: sDisTxSoftFlowCtl
-Purpose: Disable Tx Software Flow Control
-Call: sDisTxSoftFlowCtl(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-*/
-#define sDisTxSoftFlowCtl(ChP) \
-{ \
- (ChP)->R[0x06] = 0x8a; \
- sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->R[0x04]); \
-}
-
-/***************************************************************************
-Function: sEnAiop
-Purpose: Enable I/O access to an AIOP
-Call: sEnAiop(CltP)
- CONTROLLER_T *CtlP; Ptr to controller structure
- int AiopNum; Number of AIOP on controller
-*/
-#define sEnAiop(CTLP,AIOPNUM) \
-{ \
- (CTLP)->MReg3 |= sBitMapSetTbl[AIOPNUM]; \
- sOutB((CTLP)->MReg3IO,(CTLP)->MReg3); \
-}
-
-/***************************************************************************
-Function: sEnCTSFlowCtl
-Purpose: Enable output flow control using CTS
-Call: sEnCTSFlowCtl(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-*/
-#define sEnCTSFlowCtl(ChP) \
-{ \
- (ChP)->TxControl[2] |= CTSFC_EN; \
- sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
-}
-
-/***************************************************************************
-Function: EnParity
-Purpose: Enable parity
-Call: sEnParity(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-Comments: Function sSetParity() can be used in place of functions sEnParity(),
- sDisParity(), sSetOddParity(), and sSetEvenParity().
-
-Warnings: Before enabling parity odd or even parity should be chosen using
- functions sSetOddParity() or sSetEvenParity().
-*/
-#define sEnParity(ChP) \
-{ \
- (ChP)->TxControl[2] |= PARITY_EN; \
- sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
-}
-
-/***************************************************************************
-Function: sEnRTSFlowCtl
-Return: void
-*/
-#define sEnRTSFlowCtl(ChP) \
-{ \
- (ChP)->TxControl[2] &= ~RTSTOG_EN; \
- (ChP)->TxControl[3] &= ~SET_RTS; \
- sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
- (ChP)->RxControl[2] |= RTSFC_EN; \
- sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->RxControl[0]); \
-}
-
-/***************************************************************************
-Function: sDisRTSFlowCtl
-Return: void
-*/
-#define sDisRTSFlowCtl(ChP) \
-{ \
- (ChP)->RxControl[2] &= ~RTSFC_EN; \
- sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->RxControl[0]); \
-}
-
-/***************************************************************************
-Function: sEnRxFIFO
-Purpose: Enable Rx FIFO
-Call: sEnRxFIFO(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-*/
-#define sEnRxFIFO(ChP) \
-{ \
- (ChP)->R[0x32] = 0x08; \
- sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->R[0x30]); \
-}
-
-/***************************************************************************
-Function: sEnRxProcessor
-Purpose: Enable the receive processor
-Call: sEnRxProcessor(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-Comments: This function is used to start the receive processor. When
- the channel is in the reset state the receive processor is not
- running. This is done to prevent the receive processor from
- executing invalid microcode instructions prior to the
- downloading of the microcode.
-
-Warnings: This function must be called after valid microcode has been
- downloaded to the AIOP, and it must not be called before the
- microcode has been downloaded.
-*/
-#define sEnRxProcessor(ChP) \
-{ \
- (ChP)->RxControl[2] |= RXPROC_EN; \
- sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->RxControl[0]); \
-}
-
-/***************************************************************************
-Function: sEnRxStatusMode
-Purpose: Enable the Rx status mode
-Call: sEnRxStatusMode(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-Comments: This places the channel in the receive status mode. All subsequent
- reads of receive data using sReadRxWord() will return a data byte
- in the low word and a status byte in the high word.
-
-*/
-#define sEnRxStatusMode(ChP) sOutW((ChP)->ChanStat,STATMODE)
-
-/***************************************************************************
-Function: sEnTransmit
-Purpose: Enable transmit
-Call: sEnTransmit(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-*/
-#define sEnTransmit(ChP) \
-{ \
- (ChP)->TxControl[3] |= TX_ENABLE; \
- sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
-}
-
-/***************************************************************************
-Function: sGetAiopIntStatus
-Purpose: Get the AIOP interrupt status
-Call: sGetAiopIntStatus(CtlP,AiopNum)
- CONTROLLER_T *CtlP; Ptr to controller structure
- int AiopNum; AIOP number
-Return: Byte_t: The AIOP interrupt status. Bits 0 through 7
- represent channels 0 through 7 respectively. If a
- bit is set that channel is interrupting.
-*/
-#define sGetAiopIntStatus(CTLP,AIOPNUM) sInB((CTLP)->AiopIntChanIO[AIOPNUM])
-
-/***************************************************************************
-Function: sGetAiopNumChan
-Purpose: Get the number of channels supported by an AIOP
-Call: sGetAiopNumChan(CtlP,AiopNum)
- CONTROLLER_T *CtlP; Ptr to controller structure
- int AiopNum; AIOP number
-Return: int: The number of channels supported by the AIOP
-*/
-#define sGetAiopNumChan(CTLP,AIOPNUM) (CTLP)->AiopNumChan[AIOPNUM]
-
-/***************************************************************************
-Function: sGetChanIntID
-Purpose: Get a channel's interrupt identification byte
-Call: sGetChanIntID(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-Return: Byte_t: The channel interrupt ID. Can be any
- combination of the following flags:
- RXF_TRIG: Rx FIFO trigger level interrupt
- TXFIFO_MT: Tx FIFO empty interrupt
- SRC_INT: Special receive condition interrupt
- DELTA_CD: CD change interrupt
- DELTA_CTS: CTS change interrupt
- DELTA_DSR: DSR change interrupt
-*/
-#define sGetChanIntID(ChP) (sInB((ChP)->IntID) & (RXF_TRIG | TXFIFO_MT | SRC_INT | DELTA_CD | DELTA_CTS | DELTA_DSR))
-
-/***************************************************************************
-Function: sGetChanNum
-Purpose: Get the number of a channel within an AIOP
-Call: sGetChanNum(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-Return: int: Channel number within AIOP, or NULLCHAN if channel does
- not exist.
-*/
-#define sGetChanNum(ChP) (ChP)->ChanNum
-
-/***************************************************************************
-Function: sGetChanStatus
-Purpose: Get the channel status
-Call: sGetChanStatus(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-Return: Word_t: The channel status. Can be any combination of
- the following flags:
- LOW BYTE FLAGS
- CTS_ACT: CTS input asserted
- DSR_ACT: DSR input asserted
- CD_ACT: CD input asserted
- TXFIFOMT: Tx FIFO is empty
- TXSHRMT: Tx shift register is empty
- RDA: Rx data available
-
- HIGH BYTE FLAGS
- STATMODE: status mode enable bit
- RXFOVERFL: receive FIFO overflow
- RX2MATCH: receive compare byte 2 match
- RX1MATCH: receive compare byte 1 match
- RXBREAK: received BREAK
- RXFRAME: received framing error
- RXPARITY: received parity error
-Warnings: This function will clear the high byte flags in the Channel
- Status Register.
-*/
-#define sGetChanStatus(ChP) sInW((ChP)->ChanStat)
-
-/***************************************************************************
-Function: sGetChanStatusLo
-Purpose: Get the low byte only of the channel status
-Call: sGetChanStatusLo(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-Return: Byte_t: The channel status low byte. Can be any combination
- of the following flags:
- CTS_ACT: CTS input asserted
- DSR_ACT: DSR input asserted
- CD_ACT: CD input asserted
- TXFIFOMT: Tx FIFO is empty
- TXSHRMT: Tx shift register is empty
- RDA: Rx data available
-*/
-#define sGetChanStatusLo(ChP) sInB((ByteIO_t)(ChP)->ChanStat)
-
-/***************************************************************************
-Function: sGetControllerIntStatus
-Purpose: Get the controller interrupt status
-Call: sGetControllerIntStatus(CtlP)
- CONTROLLER_T *CtlP; Ptr to controller structure
-Return: Byte_t: The controller interrupt status in the lower 4
- bits. Bits 0 through 3 represent AIOP's 0
- through 3 respectively. If a bit is set that
- AIOP is interrupting. Bits 4 through 7 will
- always be cleared.
-*/
-#define sGetControllerIntStatus(CTLP) (sInB((CTLP)->MReg1IO) & 0x0f)
-
-/***************************************************************************
-Function: sPCIGetControllerIntStatus
-Purpose: Get the controller interrupt status
-Call: sPCIGetControllerIntStatus(CtlP)
- CONTROLLER_T *CtlP; Ptr to controller structure
-Return: Byte_t: The controller interrupt status in the lower 4
- bits. Bits 0 through 3 represent AIOP's 0
- through 3 respectively. If a bit is set that
- AIOP is interrupting. Bits 4 through 7 will
- always be cleared.
-*/
-#define sPCIGetControllerIntStatus(CTLP) ((sInW((CTLP)->PCIIO) >> 8) & 0x1f)
-
-/***************************************************************************
-Function: sGetRxCnt
-Purpose: Get the number of data bytes in the Rx FIFO
-Call: sGetRxCnt(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-Return: int: The number of data bytes in the Rx FIFO.
-Comments: Byte read of count register is required to obtain Rx count.
-
-*/
-#define sGetRxCnt(ChP) sInW((ChP)->TxRxCount)
-
-/***************************************************************************
-Function: sGetTxCnt
-Purpose: Get the number of data bytes in the Tx FIFO
-Call: sGetTxCnt(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-Return: Byte_t: The number of data bytes in the Tx FIFO.
-Comments: Byte read of count register is required to obtain Tx count.
-
-*/
-#define sGetTxCnt(ChP) sInB((ByteIO_t)(ChP)->TxRxCount)
-
-/*****************************************************************************
-Function: sGetTxRxDataIO
-Purpose: Get the I/O address of a channel's TxRx Data register
-Call: sGetTxRxDataIO(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-Return: WordIO_t: I/O address of a channel's TxRx Data register
-*/
-#define sGetTxRxDataIO(ChP) (ChP)->TxRxData
-
-/***************************************************************************
-Function: sInitChanDefaults
-Purpose: Initialize a channel structure to its default state.
-Call: sInitChanDefaults(ChP)
- CHANNEL_T *ChP; Ptr to the channel structure
-Comments: This function must be called once for every channel structure
- that exists before any other SSCI calls can be made.
-
-*/
-#define sInitChanDefaults(ChP) \
-{ \
- (ChP)->CtlP = NULLCTLPTR; \
- (ChP)->AiopNum = NULLAIOP; \
- (ChP)->ChanID = AIOPID_NULL; \
- (ChP)->ChanNum = NULLCHAN; \
-}
-
-/***************************************************************************
-Function: sResetAiopByNum
-Purpose: Reset the AIOP by number
-Call: sResetAiopByNum(CTLP,AIOPNUM)
- CONTROLLER_T CTLP; Ptr to controller structure
- AIOPNUM; AIOP index
-*/
-#define sResetAiopByNum(CTLP,AIOPNUM) \
-{ \
- sOutB((CTLP)->AiopIO[(AIOPNUM)]+_CMD_REG,RESET_ALL); \
- sOutB((CTLP)->AiopIO[(AIOPNUM)]+_CMD_REG,0x0); \
-}
-
-/***************************************************************************
-Function: sSendBreak
-Purpose: Send a transmit BREAK signal
-Call: sSendBreak(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-*/
-#define sSendBreak(ChP) \
-{ \
- (ChP)->TxControl[3] |= SETBREAK; \
- sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
-}
-
-/***************************************************************************
-Function: sSetBaud
-Purpose: Set baud rate
-Call: sSetBaud(ChP,Divisor)
- CHANNEL_T *ChP; Ptr to channel structure
- Word_t Divisor; 16 bit baud rate divisor for channel
-*/
-#define sSetBaud(ChP,DIVISOR) \
-{ \
- (ChP)->BaudDiv[2] = (Byte_t)(DIVISOR); \
- (ChP)->BaudDiv[3] = (Byte_t)((DIVISOR) >> 8); \
- sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->BaudDiv[0]); \
-}
-
-/***************************************************************************
-Function: sSetData7
-Purpose: Set data bits to 7
-Call: sSetData7(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-*/
-#define sSetData7(ChP) \
-{ \
- (ChP)->TxControl[2] &= ~DATA8BIT; \
- sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
-}
-
-/***************************************************************************
-Function: sSetData8
-Purpose: Set data bits to 8
-Call: sSetData8(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-*/
-#define sSetData8(ChP) \
-{ \
- (ChP)->TxControl[2] |= DATA8BIT; \
- sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
-}
-
-/***************************************************************************
-Function: sSetDTR
-Purpose: Set the DTR output
-Call: sSetDTR(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-*/
-#define sSetDTR(ChP) \
-{ \
- (ChP)->TxControl[3] |= SET_DTR; \
- sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
-}
-
-/***************************************************************************
-Function: sSetEvenParity
-Purpose: Set even parity
-Call: sSetEvenParity(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-Comments: Function sSetParity() can be used in place of functions sEnParity(),
- sDisParity(), sSetOddParity(), and sSetEvenParity().
-
-Warnings: This function has no effect unless parity is enabled with function
- sEnParity().
-*/
-#define sSetEvenParity(ChP) \
-{ \
- (ChP)->TxControl[2] |= EVEN_PAR; \
- sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
-}
-
-/***************************************************************************
-Function: sSetOddParity
-Purpose: Set odd parity
-Call: sSetOddParity(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-Comments: Function sSetParity() can be used in place of functions sEnParity(),
- sDisParity(), sSetOddParity(), and sSetEvenParity().
-
-Warnings: This function has no effect unless parity is enabled with function
- sEnParity().
-*/
-#define sSetOddParity(ChP) \
-{ \
- (ChP)->TxControl[2] &= ~EVEN_PAR; \
- sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
-}
-
-/***************************************************************************
-Function: sSetRTS
-Purpose: Set the RTS output
-Call: sSetRTS(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-*/
-#define sSetRTS(ChP) \
-{ \
- (ChP)->TxControl[3] |= SET_RTS; \
- sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
-}
-
-/***************************************************************************
-Function: sSetRxTrigger
-Purpose: Set the Rx FIFO trigger level
-Call: sSetRxProcessor(ChP,Level)
- CHANNEL_T *ChP; Ptr to channel structure
- Byte_t Level; Number of characters in Rx FIFO at which the
- interrupt will be generated. Can be any of the following flags:
-
- TRIG_NO: no trigger
- TRIG_1: 1 character in FIFO
- TRIG_1_2: FIFO 1/2 full
- TRIG_7_8: FIFO 7/8 full
-Comments: An interrupt will be generated when the trigger level is reached
- only if function sEnInterrupt() has been called with flag
- RXINT_EN set. The RXF_TRIG flag in the Interrupt Idenfification
- register will be set whenever the trigger level is reached
- regardless of the setting of RXINT_EN.
-
-*/
-#define sSetRxTrigger(ChP,LEVEL) \
-{ \
- (ChP)->RxControl[2] &= ~TRIG_MASK; \
- (ChP)->RxControl[2] |= LEVEL; \
- sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->RxControl[0]); \
-}
-
-/***************************************************************************
-Function: sSetStop1
-Purpose: Set stop bits to 1
-Call: sSetStop1(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-*/
-#define sSetStop1(ChP) \
-{ \
- (ChP)->TxControl[2] &= ~STOP2; \
- sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
-}
-
-/***************************************************************************
-Function: sSetStop2
-Purpose: Set stop bits to 2
-Call: sSetStop2(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-*/
-#define sSetStop2(ChP) \
-{ \
- (ChP)->TxControl[2] |= STOP2; \
- sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->TxControl[0]); \
-}
-
-/***************************************************************************
-Function: sStartRxProcessor
-Purpose: Start a channel's receive processor
-Call: sStartRxProcessor(ChP)
- CHANNEL_T *ChP; Ptr to channel structure
-Comments: This function is used to start a Rx processor after it was
- stopped with sStopRxProcessor() or sStopSWInFlowCtl(). It
- will restart both the Rx processor and software input flow control.
-
-*/
-#define sStartRxProcessor(ChP) sOutDW((ChP)->IndexAddr,*(DWord_t *)&(ChP)->R[0])
-
-/***************************************************************************
-Function: sWriteTxByte
-Purpose: Write a transmit data byte to a channel.
- ByteIO_t io: Channel transmit register I/O address. This can
- be obtained with sGetTxRxDataIO().
- Byte_t Data; The transmit data byte.
-Warnings: This function writes the data byte without checking to see if
- sMaxTxSize is exceeded in the Tx FIFO.
-*/
-#define sWriteTxByte(IO,DATA) sOutB(IO,DATA)
-
-int sInitController( CONTROLLER_T *CtlP,
- int CtlNum,
- ByteIO_t MudbacIO,
- ByteIO_t *AiopIOList,
- int AiopIOListSize,
- int IRQNum,
- Byte_t Frequency,
- int PeriodicOnly);
-
-int sPCIInitController( CONTROLLER_T *CtlP,
- int CtlNum,
- ByteIO_t *AiopIOList,
- int AiopIOListSize,
- int IRQNum,
- Byte_t Frequency,
- int PeriodicOnly);
-
-int sReadAiopID(ByteIO_t io);
-int sReadAiopNumChan(WordIO_t io);
-int sInitChan( CONTROLLER_T *CtlP,
- CHANNEL_T *ChP,
- int AiopNum,
- int ChanNum);
-Byte_t sGetRxErrStatus(CHANNEL_T *ChP);
-void sStopRxProcessor(CHANNEL_T *ChP);
-void sStopSWInFlowCtl(CHANNEL_T *ChP);
-void sFlushRxFIFO(CHANNEL_T *ChP);
-void sFlushTxFIFO(CHANNEL_T *ChP);
-int sWriteTxPrioByte(CHANNEL_T *ChP, Byte_t Data);
-void sEnInterrupts(CHANNEL_T *ChP,Word_t Flags);
-void sDisInterrupts(CHANNEL_T *ChP,Word_t Flags);
-
-#ifndef ROCKET_C
-extern Byte_t R[RDATASIZE];
-extern CONTROLLER_T sController[CTL_SIZE];
-extern Byte_t sIRQMap[16];
-extern Byte_t sBitMapClrTbl[8];
-extern Byte_t sBitMapSetTbl[8];
-#endif
diff --git a/sys/dev/rp/rpvar.h b/sys/dev/rp/rpvar.h
deleted file mode 100644
index d1f9e83c3168..000000000000
--- a/sys/dev/rp/rpvar.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) Comtrol Corporation <support@comtrol.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted prodived that the follwoing conditions
- * are met.
- * 1. Redistributions of source code must retain the above copyright
- * notive, this list of conditions and the following disclainer.
- * 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 prodided 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 Comtrol Corporation.
- * 4. The name of Comtrol Corporation may not be used to endorse or
- * promote products derived from this software without specific
- * prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY COMTROL CORPORATION ``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 COMTROL CORPORATION 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, LIFE 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.
- */
-
-/*
- * rpvar.h --- RocketPort data structure includes for FreeBSD
- */
-
-#define RP_UNIT(x) dv_unit(x)
-#define RP_PORT(x) (minor(x) & 0x3f)
-#define MAX_RP_PORTS 128
-
-
-struct rp_port {
- struct tty * rp_tty; /* cross reference */
-
-/* Initial state */
- struct termios it_in;
- struct termios it_out;
-
-/* Lock state */
- struct termios lt_in;
- struct termios lt_out;
-
-/* Nonzero if callout device is open */
- unsigned char active_out;
- unsigned char state; /* state of dtr */
-
-/* Time to hold DTR down on close */
- int dtr_wait;
- int wopeners; /* processes waiting for DCD */
-
- int rp_port;
- int rp_flags;
- int rp_unit:2;
- int rp_aiop:2;
- int rp_chan:3;
- int rp_intmask;
- int rp_imask; /* Input mask */
- int rp_fifo_lw;
- int rp_restart;
- int rp_overflows;
- int rp_rts_iflow:1;
- int rp_disable_writes:1;
- int rp_cts:1;
- int rp_waiting:1;
- int rp_xmit_stopped:1;
- CONTROLLER_t * rp_ctlp;
- CHANNEL_t rp_channel;
-};
-
-struct termios deftermios = {
- TTYDEF_IFLAG,
- TTYDEF_OFLAG,
- TTYDEF_CFLAG,
- TTYDEF_LFLAG,
- { CEOF, CEOL, CEOL, CERASE, CWERASE, CKILL, CREPRINT,
- _POSIX_VDISABLE, CINTR, CQUIT, CSUSP, CDSUSP, CSTART, CSTOP, CLNEXT,
- CDISCARD, CMIN, CTIME, CSTATUS, _POSIX_VDISABLE },
- TTYDEF_SPEED,
- TTYDEF_SPEED
-};
diff --git a/sys/dev/scd/scd.c b/sys/dev/scd/scd.c
deleted file mode 100644
index b6e94608e299..000000000000
--- a/sys/dev/scd/scd.c
+++ /dev/null
@@ -1,1552 +0,0 @@
-/*-
- * Copyright (c) 1995 Mikael Hybsch
- * All rights reserved.
- *
- * Portions of this file are copied from mcd.c
- * which has the following copyrights:
- *
- * Copyright 1993 by Holger Veit (data part)
- * Copyright 1993 by Brian Moore (audio part)
- * Changes Copyright 1993 by Gary Clark II
- * Changes Copyright (C) 1994 by Andrew A. Chernov
- *
- * Rewrote probe routine to work on newer Mitsumi drives.
- * Additional changes (C) 1994 by Jordan K. Hubbard
- *
- * 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
- * in this position and unchanged.
- * 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 withough 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.
- *
- */
-
-
-/* $FreeBSD$ */
-
-/* Please send any comments to micke@dynas.se */
-
-#define SCD_DEBUG 0
-
-#include "scd.h"
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/conf.h>
-#include <sys/buf.h>
-#include <sys/cdio.h>
-#include <sys/disklabel.h>
-#include <sys/kernel.h>
-
-#include <machine/clock.h>
-#include <machine/stdarg.h>
-
-#include <i386/isa/isa_device.h>
-#include <i386/isa/scdreg.h>
-
-
-#define scd_part(dev) ((minor(dev)) & 7)
-#define scd_unit(dev) (((minor(dev)) & 0x38) >> 3)
-#define scd_phys(dev) (((minor(dev)) & 0x40) >> 6)
-#define RAW_PART 2
-
-/* flags */
-#define SCDOPEN 0x0001 /* device opened */
-#define SCDVALID 0x0002 /* parameters loaded */
-#define SCDINIT 0x0004 /* device is init'd */
-#define SCDPROBING 0x0020 /* probing */
-#define SCDTOC 0x0100 /* already read toc */
-#define SCDMBXBSY 0x0200 /* local mbx is busy */
-#define SCDSPINNING 0x0400 /* drive is spun up */
-
-#define SCD_S_BEGIN 0
-#define SCD_S_BEGIN1 1
-#define SCD_S_WAITSTAT 2
-#define SCD_S_WAITFIFO 3
-#define SCD_S_WAITSPIN 4
-#define SCD_S_WAITREAD 5
-#define SCD_S_WAITPARAM 6
-
-#define RDELAY_WAIT 300
-#define RDELAY_WAITREAD 300
-
-#define SCDBLKSIZE 2048
-
-#ifdef SCD_DEBUG
- static int scd_debuglevel = SCD_DEBUG;
-# define XDEBUG(level, data) {if (scd_debuglevel >= level) printf data;}
-#else
-# define XDEBUG(level, data)
-#endif
-
-struct scd_mbx {
- short unit;
- short port;
- short retry;
- short nblk;
- int sz;
- u_long skip;
- struct buf *bp;
- int p_offset;
- short count;
-};
-
-static struct scd_data {
- int iobase;
- char double_speed;
- char *name;
- short flags;
- int blksize;
- u_long disksize;
- struct disklabel dlabel;
- int openflag;
- struct {
- unsigned int adr :4;
- unsigned int ctl :4; /* xcdplayer needs this */
- unsigned char start_msf[3];
- } toc[MAX_TRACKS];
- short first_track;
- short last_track;
- struct ioc_play_msf last_play;
-
- short audio_status;
- struct buf_queue_head head; /* head of buf queue */
- struct scd_mbx mbx;
-} scd_data[NSCD];
-
-/* prototypes */
-static void hsg2msf(int hsg, bcd_t *msf);
-static int msf2hsg(bcd_t *msf);
-
-static void process_attention(unsigned unit);
-static __inline void write_control(unsigned port, unsigned data);
-static int waitfor_status_bits(int unit, int bits_set, int bits_clear);
-static int send_cmd(u_int unit, u_char cmd, u_int nargs, ...);
-static void init_drive(unsigned unit);
-static int spin_up(unsigned unit);
-static int read_toc(unsigned unit);
-static int get_result(u_int unit, int result_len, u_char *result);
-static void print_error(int unit, int errcode);
-
-static void scd_start(int unit);
-static timeout_t scd_timeout;
-static void scd_doread(int state, struct scd_mbx *mbxin);
-
-static int scd_eject(int unit);
-static int scd_stop(int unit);
-static int scd_pause(int unit);
-static int scd_resume(int unit);
-static int scd_playtracks(int unit, struct ioc_play_track *pt);
-static int scd_playmsf(int unit, struct ioc_play_msf *msf);
-static int scd_play(int unit, struct ioc_play_msf *msf);
-static int scd_subchan(int unit, struct ioc_read_subchannel *sc);
-static int read_subcode(int unit, struct sony_subchannel_position_data *sc);
-
-/* for xcdplayer */
-static int scd_toc_header(int unit, struct ioc_toc_header *th);
-static int scd_toc_entrys(int unit, struct ioc_read_toc_entry *te);
-static int scd_toc_entry(int unit, struct ioc_read_toc_single_entry *te);
-#define SCD_LASTPLUS1 170 /* don't ask, xcdplayer passes this in */
-
-static int scd_probe(struct isa_device *dev);
-static int scd_attach(struct isa_device *dev);
-struct isa_driver scddriver = { scd_probe, scd_attach, "scd" };
-
-/* For canceling our timeout */
-static struct callout_handle tohandle = CALLOUT_HANDLE_INITIALIZER(&tohanle);
-
-static d_open_t scdopen;
-static d_close_t scdclose;
-static d_ioctl_t scdioctl;
-static d_strategy_t scdstrategy;
-
-#define CDEV_MAJOR 45
-#define BDEV_MAJOR 16
-static struct cdevsw scd_cdevsw = {
- /* open */ scdopen,
- /* close */ scdclose,
- /* read */ physread,
- /* write */ nowrite,
- /* ioctl */ scdioctl,
- /* poll */ nopoll,
- /* mmap */ nommap,
- /* strategy */ scdstrategy,
- /* name */ "scd",
- /* maj */ CDEV_MAJOR,
- /* dump */ nodump,
- /* psize */ nopsize,
- /* flags */ D_DISK,
- /* bmaj */ BDEV_MAJOR
-};
-
-
-static int
-scd_attach(struct isa_device *dev)
-{
- int unit = dev->id_unit;
- struct scd_data *cd = scd_data + unit;
-
- cd->iobase = dev->id_iobase; /* Already set by probe, but ... */
-
- /* name filled in probe */
- printf("scd%d: <%s>\n", dev->id_unit, scd_data[dev->id_unit].name);
-
- init_drive(dev->id_unit);
-
- cd->flags = SCDINIT;
- cd->audio_status = CD_AS_AUDIO_INVALID;
- bufq_init(&cd->head);
-
- make_dev(&scd_cdevsw, dkmakeminor(unit, 0, 0),
- UID_ROOT, GID_OPERATOR, 0640, "rscd%da", unit);
- make_dev(&scd_cdevsw, dkmakeminor(unit, 0, RAW_PART),
- UID_ROOT, GID_OPERATOR, 0640, "rscd%dc", unit);
- make_dev(&scd_cdevsw, dkmakeminor(unit, 0, 0),
- UID_ROOT, GID_OPERATOR, 0640, "scd%da", unit);
- make_dev(&scd_cdevsw, dkmakeminor(unit, 0, RAW_PART),
- UID_ROOT, GID_OPERATOR, 0640, "scd%dc", unit);
- return 1;
-}
-
-static int
-scdopen(dev_t dev, int flags, int fmt, struct proc *p)
-{
- int unit,part,phys;
- int rc;
- struct scd_data *cd;
-
- unit = scd_unit(dev);
- if (unit >= NSCD)
- return ENXIO;
-
- cd = scd_data + unit;
- part = scd_part(dev);
- phys = scd_phys(dev);
-
- /* not initialized*/
- if (!(cd->flags & SCDINIT))
- return ENXIO;
-
- /* invalidated in the meantime? mark all open part's invalid */
- if (cd->openflag)
- return ENXIO;
-
- XDEBUG(1,("scd%d: DEBUG: status = 0x%x\n", unit, inb(cd->iobase+IREG_STATUS)));
-
- if ((rc = spin_up(unit)) != 0) {
- print_error(unit, rc);
- return EIO;
- }
- if (!(cd->flags & SCDTOC)) {
- int loop_count = 3;
-
- while (loop_count-- > 0 && (rc = read_toc(unit)) != 0) {
- if (rc == ERR_NOT_SPINNING) {
- rc = spin_up(unit);
- if (rc) {
- print_error(unit, rc);\
- return EIO;
- }
- continue;
- }
- printf("scd%d: TOC read error 0x%x\n", unit, rc);
- return EIO;
- }
- }
-
- dev->si_bsize_phys = cd->blksize;
-
- cd->openflag = 1;
- cd->flags |= SCDVALID;
-
- return 0;
-}
-
-static int
-scdclose(dev_t dev, int flags, int fmt, struct proc *p)
-{
- int unit,part,phys;
- struct scd_data *cd;
-
- unit = scd_unit(dev);
- if (unit >= NSCD)
- return ENXIO;
-
- cd = scd_data + unit;
- part = scd_part(dev);
- phys = scd_phys(dev);
-
- if (!(cd->flags & SCDINIT) || !cd->openflag)
- return ENXIO;
-
- if (cd->audio_status != CD_AS_PLAY_IN_PROGRESS) {
- (void)send_cmd(unit, CMD_SPIN_DOWN, 0);
- cd->flags &= ~SCDSPINNING;
- }
-
-
- /* close channel */
- cd->openflag = 0;
-
- return 0;
-}
-
-static void
-scdstrategy(struct buf *bp)
-{
- struct scd_data *cd;
- int s;
- int unit = scd_unit(bp->b_dev);
-
- cd = scd_data + unit;
-
- XDEBUG(2, ("scd%d: DEBUG: strategy: block=%ld, bcount=%ld\n",
- unit, (long)bp->b_blkno, bp->b_bcount));
-
- if (unit >= NSCD || bp->b_blkno < 0 || (bp->b_bcount % SCDBLKSIZE)) {
- printf("scd%d: strategy failure: blkno = %ld, bcount = %ld\n",
- unit, (long)bp->b_blkno, bp->b_bcount);
- bp->b_error = EINVAL;
- bp->b_flags |= B_ERROR;
- goto bad;
- }
-
- /* if device invalidated (e.g. media change, door open), error */
- if (!(cd->flags & SCDVALID)) {
- printf("scd%d: media changed\n", unit);
- bp->b_error = EIO;
- goto bad;
- }
-
- /* read only */
- if (!(bp->b_flags & B_READ)) {
- bp->b_error = EROFS;
- goto bad;
- }
-
- /* no data to read */
- if (bp->b_bcount == 0)
- goto done;
-
- if (!(cd->flags & SCDTOC)) {
- bp->b_error = EIO;
- goto bad;
- }
- /* adjust transfer if necessary */
- if (bounds_check_with_label(bp,&cd->dlabel,1) <= 0)
- goto done;
-
- bp->b_pblkno = bp->b_blkno;
- bp->b_resid = 0;
-
- /* queue it */
- s = splbio();
- bufqdisksort(&cd->head, bp);
- splx(s);
-
- /* now check whether we can perform processing */
- scd_start(unit);
- return;
-
-bad:
- bp->b_flags |= B_ERROR;
-done:
- bp->b_resid = bp->b_bcount;
- biodone(bp);
- return;
-}
-
-static void
-scd_start(int unit)
-{
- struct scd_data *cd = scd_data + unit;
- struct buf *bp;
- struct partition *p;
- int s = splbio();
-
- if (cd->flags & SCDMBXBSY) {
- splx(s);
- return;
- }
-
- bp = bufq_first(&cd->head);
- if (bp != 0) {
- /* block found to process, dequeue */
- bufq_remove(&cd->head, bp);
- cd->flags |= SCDMBXBSY;
- splx(s);
- } else {
- /* nothing to do */
- splx(s);
- return;
- }
-
- p = cd->dlabel.d_partitions + scd_part(bp->b_dev);
-
- cd->mbx.unit = unit;
- cd->mbx.port = cd->iobase;
- cd->mbx.retry = 3;
- cd->mbx.bp = bp;
- cd->mbx.p_offset = p->p_offset;
- splx(s);
-
- scd_doread(SCD_S_BEGIN,&(cd->mbx));
- return;
-}
-
-static int
-scdioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p)
-{
- struct scd_data *cd;
- int unit,part;
-
- unit = scd_unit(dev);
- part = scd_part(dev);
- cd = scd_data + unit;
-
- XDEBUG(1, ("scd%d: ioctl: cmd=0x%lx\n", unit, cmd));
-
- if (!(cd->flags & SCDVALID))
- return EIO;
-
- switch (cmd) {
- case DIOCGDINFO:
- *(struct disklabel *)addr = cd->dlabel;
- return 0;
- case DIOCGPART:
- ((struct partinfo *)addr)->disklab = &cd->dlabel;
- ((struct partinfo *)addr)->part =
- &cd->dlabel.d_partitions[0];
- return 0;
- case CDIOCPLAYTRACKS:
- return scd_playtracks(unit, (struct ioc_play_track *) addr);
- case CDIOCPLAYBLOCKS:
- return EINVAL;
- case CDIOCPLAYMSF:
- return scd_playmsf(unit, (struct ioc_play_msf *) addr);
- case CDIOCREADSUBCHANNEL:
- return scd_subchan(unit, (struct ioc_read_subchannel *) addr);
- case CDIOREADTOCHEADER:
- return scd_toc_header (unit, (struct ioc_toc_header *) addr);
- case CDIOREADTOCENTRYS:
- return scd_toc_entrys (unit, (struct ioc_read_toc_entry*) addr);
- case CDIOREADTOCENTRY:
- return scd_toc_entry (unit, (struct ioc_read_toc_single_entry*) addr);
- case CDIOCSETPATCH:
- case CDIOCGETVOL:
- case CDIOCSETVOL:
- case CDIOCSETMONO:
- case CDIOCSETSTERIO:
- case CDIOCSETMUTE:
- case CDIOCSETLEFT:
- case CDIOCSETRIGHT:
- return EINVAL;
- case CDIOCRESUME:
- return scd_resume(unit);
- case CDIOCPAUSE:
- return scd_pause(unit);
- case CDIOCSTART:
- return EINVAL;
- case CDIOCSTOP:
- return scd_stop(unit);
- case CDIOCEJECT:
- return scd_eject(unit);
- case CDIOCALLOW:
- return 0;
- case CDIOCSETDEBUG:
-#ifdef SCD_DEBUG
- scd_debuglevel++;
-#endif
- return 0;
- case CDIOCCLRDEBUG:
-#ifdef SCD_DEBUG
- scd_debuglevel = 0;
-
-#endif
- return 0;
- default:
- printf("scd%d: unsupported ioctl (cmd=0x%lx)\n", unit, cmd);
- return ENOTTY;
- }
-}
-
-/***************************************************************
- * lower level of driver starts here
- **************************************************************/
-
-static int
-scd_playtracks(int unit, struct ioc_play_track *pt)
-{
- struct scd_data *cd = scd_data + unit;
- struct ioc_play_msf msf;
- int a = pt->start_track;
- int z = pt->end_track;
- int rc;
-
- if (!(cd->flags & SCDTOC) && (rc = read_toc(unit)) != 0) {
- if (rc == -ERR_NOT_SPINNING) {
- if (spin_up(unit) != 0)
- return EIO;
- rc = read_toc(unit);
- }
- if (rc != 0) {
- print_error(unit, rc);
- return EIO;
- }
- }
-
- XDEBUG(1, ("scd%d: playtracks from %d:%d to %d:%d\n", unit,
- a, pt->start_index, z, pt->end_index));
-
- if ( a < cd->first_track
- || a > cd->last_track
- || a > z
- || z > cd->last_track)
- return EINVAL;
-
- bcopy(cd->toc[a].start_msf, &msf.start_m, 3);
- hsg2msf(msf2hsg(cd->toc[z+1].start_msf)-1, &msf.end_m);
-
- return scd_play(unit, &msf);
-}
-
-/* The start/end msf is expected to be in bin format */
-static int
-scd_playmsf(int unit, struct ioc_play_msf *msfin)
-{
- struct ioc_play_msf msf;
-
- msf.start_m = bin2bcd(msfin->start_m);
- msf.start_s = bin2bcd(msfin->start_s);
- msf.start_f = bin2bcd(msfin->start_f);
- msf.end_m = bin2bcd(msfin->end_m);
- msf.end_s = bin2bcd(msfin->end_s);
- msf.end_f = bin2bcd(msfin->end_f);
-
- return scd_play(unit, &msf);
-}
-
-/* The start/end msf is expected to be in bcd format */
-static int
-scd_play(int unit, struct ioc_play_msf *msf)
-{
- struct scd_data *cd = scd_data + unit;
- int i, rc;
-
- XDEBUG(1, ("scd%d: playing: %02x:%02x:%02x -> %02x:%02x:%02x\n", unit,
- msf->start_m, msf->start_s, msf->start_f,
- msf->end_m, msf->end_s, msf->end_f));
-
- for (i = 0; i < 2; i++) {
- rc = send_cmd(unit, CMD_PLAY_AUDIO, 7,
- 0x03,
- msf->start_m, msf->start_s, msf->start_f,
- msf->end_m, msf->end_s, msf->end_f);
- if (rc == -ERR_NOT_SPINNING) {
- cd->flags &= ~SCDSPINNING;
- if (spin_up(unit) != 0)
- return EIO;
- } else if (rc < 0) {
- print_error(unit, rc);
- return EIO;
- } else {
- break;
- }
- }
- cd->audio_status = CD_AS_PLAY_IN_PROGRESS;
- bcopy((char *)msf, (char *)&cd->last_play, sizeof(struct ioc_play_msf));
- return 0;
-}
-
-static int
-scd_stop(int unit)
-{
- struct scd_data *cd = scd_data + unit;
-
- (void)send_cmd(unit, CMD_STOP_AUDIO, 0);
- cd->audio_status = CD_AS_PLAY_COMPLETED;
- return 0;
-}
-
-static int
-scd_pause(int unit)
-{
- struct scd_data *cd = scd_data + unit;
- struct sony_subchannel_position_data subpos;
-
- if (cd->audio_status != CD_AS_PLAY_IN_PROGRESS)
- return EINVAL;
-
- if (read_subcode(unit, &subpos) != 0)
- return EIO;
-
- if (send_cmd(unit, CMD_STOP_AUDIO, 0) != 0)
- return EIO;
-
- cd->last_play.start_m = subpos.abs_msf[0];
- cd->last_play.start_s = subpos.abs_msf[1];
- cd->last_play.start_f = subpos.abs_msf[2];
- cd->audio_status = CD_AS_PLAY_PAUSED;
-
- XDEBUG(1, ("scd%d: pause @ %02x:%02x:%02x\n", unit,
- cd->last_play.start_m,
- cd->last_play.start_s,
- cd->last_play.start_f));
-
- return 0;
-}
-
-static int
-scd_resume(int unit)
-{
- if (scd_data[unit].audio_status != CD_AS_PLAY_PAUSED)
- return EINVAL;
- return scd_play(unit, &scd_data[unit].last_play);
-}
-
-static int
-scd_eject(int unit)
-{
- struct scd_data *cd = scd_data + unit;
-
- cd->audio_status = CD_AS_AUDIO_INVALID;
- cd->flags &= ~(SCDSPINNING|SCDTOC);
-
- if (send_cmd(unit, CMD_STOP_AUDIO, 0) != 0 ||
- send_cmd(unit, CMD_SPIN_DOWN, 0) != 0 ||
- send_cmd(unit, CMD_EJECT, 0) != 0)
- {
- return EIO;
- }
- return 0;
-}
-
-static int
-scd_subchan(int unit, struct ioc_read_subchannel *sc)
-{
- struct scd_data *cd = scd_data + unit;
- struct sony_subchannel_position_data q;
- struct cd_sub_channel_info data;
-
- XDEBUG(1, ("scd%d: subchan af=%d, df=%d\n", unit,
- sc->address_format,
- sc->data_format));
-
- if (sc->address_format != CD_MSF_FORMAT)
- return EINVAL;
-
- if (sc->data_format != CD_CURRENT_POSITION)
- return EINVAL;
-
- if (read_subcode(unit, &q) != 0)
- return EIO;
-
- data.header.audio_status = cd->audio_status;
- data.what.position.data_format = CD_MSF_FORMAT;
- data.what.position.track_number = bcd2bin(q.track_number);
- data.what.position.reladdr.msf.unused = 0;
- data.what.position.reladdr.msf.minute = bcd2bin(q.rel_msf[0]);
- data.what.position.reladdr.msf.second = bcd2bin(q.rel_msf[1]);
- data.what.position.reladdr.msf.frame = bcd2bin(q.rel_msf[2]);
- data.what.position.absaddr.msf.unused = 0;
- data.what.position.absaddr.msf.minute = bcd2bin(q.abs_msf[0]);
- data.what.position.absaddr.msf.second = bcd2bin(q.abs_msf[1]);
- data.what.position.absaddr.msf.frame = bcd2bin(q.abs_msf[2]);
-
- if (copyout(&data, sc->data, min(sizeof(struct cd_sub_channel_info), sc->data_len))!=0)
- return EFAULT;
- return 0;
-}
-
-static __inline void
-write_control(unsigned port, unsigned data)
-{
- outb(port + OREG_CONTROL, data);
-}
-
-static int
-scd_probe(struct isa_device *dev)
-{
- struct sony_drive_configuration drive_config;
- int unit = dev->id_unit;
- int rc;
- static char namebuf[8+16+8+3];
- char *s = namebuf;
- int loop_count = 0;
- static int once;
-
- if (!once++)
- cdevsw_add(&scd_cdevsw);
-
- scd_data[unit].flags = SCDPROBING;
- scd_data[unit].iobase = dev->id_iobase;
-
- bzero(&drive_config, sizeof(drive_config));
-
-again:
- /* Reset drive */
- write_control(dev->id_iobase, CBIT_RESET_DRIVE);
-
- /* Calm down */
- DELAY(300000);
-
- /* Only the ATTENTION bit may be set */
- if ((inb(dev->id_iobase+IREG_STATUS) & ~1) != 0) {
- XDEBUG(1, ("scd: too many bits set. probe failed.\n"));
- return 0;
- }
- rc = send_cmd(unit, CMD_GET_DRIVE_CONFIG, 0);
- if (rc != sizeof(drive_config)) {
- /* Sometimes if the drive is playing audio I get */
- /* the bad result 82. Fix by repeating the reset */
- if (rc > 0 && loop_count++ == 0)
- goto again;
- return 0;
- }
- if (get_result(unit, rc, (u_char *)&drive_config) != 0)
- return 0;
-
- bcopy(drive_config.vendor, namebuf, 8);
- s = namebuf+8;
- while (*(s-1) == ' ') /* Strip trailing spaces */
- s--;
- *s++ = ' ';
- bcopy(drive_config.product, s, 16);
- s += 16;
- while (*(s-1) == ' ')
- s--;
- *s++ = ' ';
- bcopy(drive_config.revision, s, 8);
- s += 8;
- while (*(s-1) == ' ')
- s--;
- *s = 0;
-
- scd_data[unit].name = namebuf;
-
- if (drive_config.config & 0x10)
- scd_data[unit].double_speed = 1;
- else
- scd_data[unit].double_speed = 0;
-
- return 4;
-}
-
-static int
-read_subcode(int unit, struct sony_subchannel_position_data *sc)
-{
- int rc;
-
- rc = send_cmd(unit, CMD_GET_SUBCHANNEL_DATA, 0);
- if (rc < 0 || rc < sizeof(*sc))
- return EIO;
- if (get_result(unit, rc, (u_char *)sc) != 0)
- return EIO;
- return 0;
-}
-
-/* State machine copied from mcd.c */
-
-/* This (and the code in mcd.c) will not work with more than one drive */
-/* because there is only one mbxsave below. Should fix that some day. */
-/* (mbxsave & state should probably be included in the scd_data struct and */
-/* the unit number used as first argument to scd_doread().) /Micke */
-
-/* state machine to process read requests
- * initialize with SCD_S_BEGIN: reset state machine
- * SCD_S_WAITSTAT: wait for ready (!busy)
- * SCD_S_WAITSPIN: wait for drive to spin up (if not spinning)
- * SCD_S_WAITFIFO: wait for param fifo to get ready, them exec. command.
- * SCD_S_WAITREAD: wait for data ready, read data
- * SCD_S_WAITPARAM: wait for command result params, read them, error if bad data read.
- */
-
-static struct scd_mbx *mbxsave;
-
-static void
-scd_timeout(void *arg)
-{
- scd_doread((int)arg, mbxsave);
-}
-
-static void
-scd_doread(int state, struct scd_mbx *mbxin)
-{
- struct scd_mbx *mbx = (state!=SCD_S_BEGIN) ? mbxsave : mbxin;
- int unit = mbx->unit;
- int port = mbx->port;
- struct buf *bp = mbx->bp;
- struct scd_data *cd = scd_data + unit;
- int reg,i;
- int blknum;
- caddr_t addr;
- static char sdata[3]; /* Must be preserved between calls to this function */
-
-loop:
- switch (state) {
- case SCD_S_BEGIN:
- mbx = mbxsave = mbxin;
-
- case SCD_S_BEGIN1:
- /* get status */
- mbx->count = RDELAY_WAIT;
-
- process_attention(unit);
- goto trystat;
-
- case SCD_S_WAITSTAT:
- untimeout(scd_timeout,(caddr_t)SCD_S_WAITSTAT, tohandle);
- if (mbx->count-- <= 0) {
- printf("scd%d: timeout. drive busy.\n",unit);
- goto harderr;
- }
-
-trystat:
- if (IS_BUSY(port)) {
- tohandle = timeout(scd_timeout,
- (caddr_t)SCD_S_WAITSTAT,hz/100); /* XXX */
- return;
- }
-
- process_attention(unit);
-
- /* reject, if audio active */
- if (cd->audio_status & CD_AS_PLAY_IN_PROGRESS) {
- printf("scd%d: audio is active\n",unit);
- goto harderr;
- }
-
- mbx->sz = cd->blksize;
-
- /* for first block */
- mbx->nblk = (bp->b_bcount + (mbx->sz-1)) / mbx->sz;
- mbx->skip = 0;
-
-nextblock:
- if (!(cd->flags & SCDVALID))
- goto changed;
-
- blknum = (bp->b_blkno / (mbx->sz/DEV_BSIZE))
- + mbx->p_offset + mbx->skip/mbx->sz;
-
- XDEBUG(2, ("scd%d: scd_doread: read blknum=%d\n", unit, blknum));
-
- /* build parameter block */
- hsg2msf(blknum, sdata);
-
- write_control(port, CBIT_RESULT_READY_CLEAR);
- write_control(port, CBIT_RPARAM_CLEAR);
- write_control(port, CBIT_DATA_READY_CLEAR);
-
- if (FSTATUS_BIT(port, FBIT_WPARAM_READY))
- goto writeparam;
-
- mbx->count = 100;
- tohandle = timeout(scd_timeout,
- (caddr_t)SCD_S_WAITFIFO,hz/100); /* XXX */
- return;
-
- case SCD_S_WAITSPIN:
- untimeout(scd_timeout,(caddr_t)SCD_S_WAITSPIN, tohandle);
- if (mbx->count-- <= 0) {
- printf("scd%d: timeout waiting for drive to spin up.\n", unit);
- goto harderr;
- }
- if (!STATUS_BIT(port, SBIT_RESULT_READY)) {
- tohandle = timeout(scd_timeout,
- (caddr_t)SCD_S_WAITSPIN,hz/100); /* XXX */
- return;
- }
- write_control(port, CBIT_RESULT_READY_CLEAR);
- switch ((i = inb(port+IREG_RESULT)) & 0xf0) {
- case 0x20:
- i = inb(port+IREG_RESULT);
- print_error(unit, i);
- goto harderr;
- case 0x00:
- (void)inb(port+IREG_RESULT);
- cd->flags |= SCDSPINNING;
- break;
- }
- XDEBUG(1, ("scd%d: DEBUG: spin up complete\n", unit));
-
- state = SCD_S_BEGIN1;
- goto loop;
-
- case SCD_S_WAITFIFO:
- untimeout(scd_timeout,(caddr_t)SCD_S_WAITFIFO, tohandle);
- if (mbx->count-- <= 0) {
- printf("scd%d: timeout. write param not ready.\n",unit);
- goto harderr;
- }
- if (!FSTATUS_BIT(port, FBIT_WPARAM_READY)) {
- tohandle = timeout(scd_timeout,
- (caddr_t)SCD_S_WAITFIFO,hz/100); /* XXX */
- return;
- }
- XDEBUG(1, ("scd%d: mbx->count (writeparamwait) = %d(%d)\n", unit, mbx->count, 100));
-
-writeparam:
- /* The reason this test isn't done 'till now is to make sure */
- /* that it is ok to send the SPIN_UP cmd below. */
- if (!(cd->flags & SCDSPINNING)) {
- XDEBUG(1, ("scd%d: spinning up drive ...\n", unit));
- outb(port+OREG_COMMAND, CMD_SPIN_UP);
- mbx->count = 300;
- tohandle = timeout(scd_timeout,
- (caddr_t)SCD_S_WAITSPIN,hz/100); /* XXX */
- return;
- }
-
- reg = port + OREG_WPARAMS;
- /* send the read command */
- disable_intr();
- outb(reg, sdata[0]);
- outb(reg, sdata[1]);
- outb(reg, sdata[2]);
- outb(reg, 0);
- outb(reg, 0);
- outb(reg, 1);
- outb(port+OREG_COMMAND, CMD_READ);
- enable_intr();
-
- mbx->count = RDELAY_WAITREAD;
- for (i = 0; i < 50; i++) {
- if (STATUS_BIT(port, SBIT_DATA_READY))
- goto got_data;
- DELAY(100);
- }
-
- tohandle = timeout(scd_timeout,
- (caddr_t)SCD_S_WAITREAD,hz/100); /* XXX */
- return;
-
- case SCD_S_WAITREAD:
- untimeout(scd_timeout,(caddr_t)SCD_S_WAITREAD, tohandle);
- if (mbx->count-- <= 0) {
- if (STATUS_BIT(port, SBIT_RESULT_READY))
- goto got_param;
- printf("scd%d: timeout while reading data\n",unit);
- goto readerr;
- }
- if (!STATUS_BIT(port, SBIT_DATA_READY)) {
- process_attention(unit);
- if (!(cd->flags & SCDVALID))
- goto changed;
- tohandle = timeout(scd_timeout,
- (caddr_t)SCD_S_WAITREAD,hz/100); /* XXX */
- return;
- }
- XDEBUG(2, ("scd%d: mbx->count (after RDY_BIT) = %d(%d)\n", unit, mbx->count, RDELAY_WAITREAD));
-
-got_data:
- /* data is ready */
- addr = bp->b_data + mbx->skip;
- write_control(port, CBIT_DATA_READY_CLEAR);
- insb(port+IREG_DATA, addr, mbx->sz);
-
- mbx->count = 100;
- for (i = 0; i < 20; i++) {
- if (STATUS_BIT(port, SBIT_RESULT_READY))
- goto waitfor_param;
- DELAY(100);
- }
- goto waitfor_param;
-
- case SCD_S_WAITPARAM:
- untimeout(scd_timeout,(caddr_t)SCD_S_WAITPARAM, tohandle);
- if (mbx->count-- <= 0) {
- printf("scd%d: timeout waiting for params\n",unit);
- goto readerr;
- }
-
-waitfor_param:
- if (!STATUS_BIT(port, SBIT_RESULT_READY)) {
- tohandle = timeout(scd_timeout,
- (caddr_t)SCD_S_WAITPARAM,hz/100); /* XXX */
- return;
- }
-#if SCD_DEBUG
- if (mbx->count < 100 && scd_debuglevel > 0)
- printf("scd%d: mbx->count (paramwait) = %d(%d)\n", unit, mbx->count, 100);
-#endif
-
-got_param:
- write_control(port, CBIT_RESULT_READY_CLEAR);
- switch ((i = inb(port+IREG_RESULT)) & 0xf0) {
- case 0x50:
- switch (i) {
- case ERR_FATAL_READ_ERROR1:
- case ERR_FATAL_READ_ERROR2:
- printf("scd%d: unrecoverable read error 0x%x\n", unit, i);
- goto harderr;
- }
- break;
- case 0x20:
- i = inb(port+IREG_RESULT);
- switch (i) {
- case ERR_NOT_SPINNING:
- XDEBUG(1, ("scd%d: read error: drive not spinning\n", unit));
- if (mbx->retry-- > 0) {
- state = SCD_S_BEGIN1;
- cd->flags &= ~SCDSPINNING;
- goto loop;
- }
- goto harderr;
- default:
- print_error(unit, i);
- goto readerr;
- }
- case 0x00:
- i = inb(port+IREG_RESULT);
- break;
- }
-
- if (--mbx->nblk > 0) {
- mbx->skip += mbx->sz;
- goto nextblock;
- }
-
- /* return buffer */
- bp->b_resid = 0;
- biodone(bp);
-
- cd->flags &= ~SCDMBXBSY;
- scd_start(mbx->unit);
- return;
- }
-
-readerr:
- if (mbx->retry-- > 0) {
- printf("scd%d: retrying ...\n",unit);
- state = SCD_S_BEGIN1;
- goto loop;
- }
-harderr:
- /* invalidate the buffer */
- bp->b_error = EIO;
- bp->b_flags |= B_ERROR;
- bp->b_resid = bp->b_bcount;
- biodone(bp);
-
- cd->flags &= ~SCDMBXBSY;
- scd_start(mbx->unit);
- return;
-
-changed:
- printf("scd%d: media changed\n", unit);
- goto harderr;
-}
-
-static void
-hsg2msf(int hsg, bcd_t *msf)
-{
- hsg += 150;
- M_msf(msf) = bin2bcd(hsg / 4500);
- hsg %= 4500;
- S_msf(msf) = bin2bcd(hsg / 75);
- F_msf(msf) = bin2bcd(hsg % 75);
-}
-
-static int
-msf2hsg(bcd_t *msf)
-{
- return (bcd2bin(M_msf(msf)) * 60 +
- bcd2bin(S_msf(msf))) * 75 +
- bcd2bin(F_msf(msf)) - 150;
-}
-
-static void
-process_attention(unsigned unit)
-{
- unsigned port = scd_data[unit].iobase;
- unsigned char code;
- int count = 0;
-
- while (IS_ATTENTION(port) && count++ < 30) {
- write_control(port, CBIT_ATTENTION_CLEAR);
- code = inb(port+IREG_RESULT);
-
-#if SCD_DEBUG
- if (scd_debuglevel > 0) {
- if (count == 1)
- printf("scd%d: DEBUG: ATTENTIONS = 0x%x", unit, code);
- else
- printf(",0x%x", code);
- }
-#endif
-
- switch (code) {
- case ATTEN_SPIN_DOWN:
- scd_data[unit].flags &= ~SCDSPINNING;
- break;
-
- case ATTEN_SPIN_UP_DONE:
- scd_data[unit].flags |= SCDSPINNING;
- break;
-
- case ATTEN_AUDIO_DONE:
- scd_data[unit].audio_status = CD_AS_PLAY_COMPLETED;
- break;
-
- case ATTEN_DRIVE_LOADED:
- scd_data[unit].flags &= ~(SCDTOC|SCDSPINNING|SCDVALID);
- scd_data[unit].audio_status = CD_AS_AUDIO_INVALID;
- break;
-
- case ATTEN_EJECT_PUSHED:
- scd_data[unit].flags &= ~SCDVALID;
- break;
- }
- DELAY(100);
- }
-#if SCD_DEBUG
- if (scd_debuglevel > 0 && count > 0)
- printf("\n");
-#endif
-}
-
-/* Returns 0 OR sony error code */
-static int
-spin_up(unsigned unit)
-{
- unsigned char res_reg[12];
- unsigned int res_size;
- int rc;
- int loop_count = 0;
-
-again:
- rc = send_cmd(unit, CMD_SPIN_UP, 0, 0, res_reg, &res_size);
- if (rc != 0) {
- XDEBUG(2, ("scd%d: CMD_SPIN_UP error 0x%x\n", unit, rc));
- return rc;
- }
-
- if (!(scd_data[unit].flags & SCDTOC)) {
- rc = send_cmd(unit, CMD_READ_TOC, 0);
- if (rc == ERR_NOT_SPINNING) {
- if (loop_count++ < 3)
- goto again;
- return rc;
- }
- if (rc != 0)
- return rc;
- }
-
- scd_data[unit].flags |= SCDSPINNING;
-
- return 0;
-}
-
-static struct sony_tracklist *
-get_tl(struct sony_toc *toc, int size)
-{
- struct sony_tracklist *tl = &toc->tracks[0];
-
- if (tl->track != 0xb0)
- return tl;
- (char *)tl += 9;
- if (tl->track != 0xb1)
- return tl;
- (char *)tl += 9;
- if (tl->track != 0xb2)
- return tl;
- (char *)tl += 9;
- if (tl->track != 0xb3)
- return tl;
- (char *)tl += 9;
- if (tl->track != 0xb4)
- return tl;
- (char *)tl += 9;
- if (tl->track != 0xc0)
- return tl;
- (char *)tl += 9;
- return tl;
-}
-
-static int
-read_toc(unsigned unit)
-{
- struct scd_data *cd;
- unsigned part = 0; /* For now ... */
- struct sony_toc toc;
- struct sony_tracklist *tl;
- int rc, i, j;
- u_long first, last;
-
- cd = scd_data + unit;
-
- rc = send_cmd(unit, CMD_GET_TOC, 1, part+1);
- if (rc < 0)
- return rc;
- if (rc > sizeof(toc)) {
- printf("scd%d: program error: toc too large (%d)\n", unit, rc);
- return EIO;
- }
- if (get_result(unit, rc, (u_char *)&toc) != 0)
- return EIO;
-
- XDEBUG(1, ("scd%d: toc read. len = %d, sizeof(toc) = %d\n", unit, rc, sizeof(toc)));
-
- tl = get_tl(&toc, rc);
- first = msf2hsg(tl->start_msf);
- last = msf2hsg(toc.lead_out_start_msf);
- cd->blksize = SCDBLKSIZE;
- cd->disksize = last*cd->blksize/DEV_BSIZE;
-
- XDEBUG(1, ("scd%d: firstsector = %ld, lastsector = %ld", unit,
- first, last));
-
- cd->first_track = bcd2bin(toc.first_track);
- cd->last_track = bcd2bin(toc.last_track);
- if (cd->last_track > (MAX_TRACKS-2))
- cd->last_track = MAX_TRACKS-2;
- for (j = 0, i = cd->first_track; i <= cd->last_track; i++, j++) {
- cd->toc[i].adr = tl[j].adr;
- cd->toc[i].ctl = tl[j].ctl; /* for xcdplayer */
- bcopy(tl[j].start_msf, cd->toc[i].start_msf, 3);
-#ifdef SCD_DEBUG
- if (scd_debuglevel > 0) {
- if ((j % 3) == 0)
- printf("\nscd%d: tracks ", unit);
- printf("[%03d: %2d %2d %2d] ", i,
- bcd2bin(cd->toc[i].start_msf[0]),
- bcd2bin(cd->toc[i].start_msf[1]),
- bcd2bin(cd->toc[i].start_msf[2]));
- }
-#endif
- }
- bcopy(toc.lead_out_start_msf, cd->toc[cd->last_track+1].start_msf, 3);
-#ifdef SCD_DEBUG
- if (scd_debuglevel > 0) {
- i = cd->last_track+1;
- printf("[END: %2d %2d %2d]\n",
- bcd2bin(cd->toc[i].start_msf[0]),
- bcd2bin(cd->toc[i].start_msf[1]),
- bcd2bin(cd->toc[i].start_msf[2]));
- }
-#endif
-
- bzero(&cd->dlabel,sizeof(struct disklabel));
- /* filled with spaces first */
- strncpy(cd->dlabel.d_typename," ",
- sizeof(cd->dlabel.d_typename));
- strncpy(cd->dlabel.d_typename, cd->name,
- min(strlen(cd->name), sizeof(cd->dlabel.d_typename) - 1));
- strncpy(cd->dlabel.d_packname,"unknown ",
- sizeof(cd->dlabel.d_packname));
- cd->dlabel.d_secsize = cd->blksize;
- cd->dlabel.d_nsectors = 100;
- cd->dlabel.d_ntracks = 1;
- cd->dlabel.d_ncylinders = (cd->disksize/100)+1;
- cd->dlabel.d_secpercyl = 100;
- cd->dlabel.d_secperunit = cd->disksize;
- cd->dlabel.d_rpm = 300;
- cd->dlabel.d_interleave = 1;
- cd->dlabel.d_flags = D_REMOVABLE;
- cd->dlabel.d_npartitions= 1;
- cd->dlabel.d_partitions[0].p_offset = 0;
- cd->dlabel.d_partitions[0].p_size = cd->disksize;
- cd->dlabel.d_partitions[0].p_fstype = 9;
- cd->dlabel.d_magic = DISKMAGIC;
- cd->dlabel.d_magic2 = DISKMAGIC;
- cd->dlabel.d_checksum = dkcksum(&cd->dlabel);
-
- cd->flags |= SCDTOC;
-
- return 0;
-}
-
-static void
-init_drive(unsigned unit)
-{
- int rc;
-
- rc = send_cmd(unit, CMD_SET_DRIVE_PARAM, 2,
- 0x05, 0x03 | ((scd_data[unit].double_speed) ? 0x04: 0));
- if (rc != 0)
- printf("scd%d: Unable to set parameters. Errcode = 0x%x\n", unit, rc);
-}
-
-/* Returns 0 or errno */
-static int
-get_result(u_int unit, int result_len, u_char *result)
-{
- unsigned int port = scd_data[unit].iobase;
- unsigned int res_reg = port + IREG_RESULT;
- int loop_index = 2; /* send_cmd() reads two bytes ... */
-
- XDEBUG(1, ("scd%d: DEBUG: get_result: bytes=%d\n", unit, result_len));
-
- while (result_len-- > 0) {
- if (loop_index++ >= 10) {
- loop_index = 1;
- if (waitfor_status_bits(unit, SBIT_RESULT_READY, 0))
- return EIO;
- write_control(port, CBIT_RESULT_READY_CLEAR);
- }
- if (result)
- *result++ = inb(res_reg);
- else
- (void)inb(res_reg);
- }
- return 0;
-}
-
-/* Returns -0x100 for timeout, -(drive error code) OR number of result bytes */
-static int
-send_cmd(u_int unit, u_char cmd, u_int nargs, ...)
-{
- va_list ap;
- u_int port = scd_data[unit].iobase;
- u_int reg;
- u_char c;
- int rc;
- int i;
-
- if (waitfor_status_bits(unit, 0, SBIT_BUSY)) {
- printf("scd%d: drive busy\n", unit);
- return -0x100;
- }
-
- XDEBUG(1,("scd%d: DEBUG: send_cmd: cmd=0x%x nargs=%d", unit, cmd, nargs));
-
- write_control(port, CBIT_RESULT_READY_CLEAR);
- write_control(port, CBIT_RPARAM_CLEAR);
-
- for (i = 0; i < 100; i++)
- if (FSTATUS_BIT(port, FBIT_WPARAM_READY))
- break;
- if (!FSTATUS_BIT(port, FBIT_WPARAM_READY)) {
- XDEBUG(1, ("\nscd%d: wparam timeout\n", unit));
- return -EIO;
- }
-
- va_start(ap, nargs);
- reg = port + OREG_WPARAMS;
- for (i = 0; i < nargs; i++) {
- c = (u_char)va_arg(ap, int);
- outb(reg, c);
- XDEBUG(1, (",{0x%x}", c));
- }
- va_end(ap);
- XDEBUG(1, ("\n"));
-
- outb(port+OREG_COMMAND, cmd);
-
- rc = waitfor_status_bits(unit, SBIT_RESULT_READY, SBIT_BUSY);
- if (rc)
- return -0x100;
-
- reg = port + IREG_RESULT;
- write_control(port, CBIT_RESULT_READY_CLEAR);
- switch ((rc = inb(reg)) & 0xf0) {
- case 0x20:
- rc = inb(reg);
- /* FALL TROUGH */
- case 0x50:
- XDEBUG(1, ("scd%d: DEBUG: send_cmd: drive_error=0x%x\n", unit, rc));
- return -rc;
- case 0x00:
- default:
- rc = inb(reg);
- XDEBUG(1, ("scd%d: DEBUG: send_cmd: result_len=%d\n", unit, rc));
- return rc;
- }
-}
-
-static void
-print_error(int unit, int errcode)
-{
- switch (errcode) {
- case -ERR_CD_NOT_LOADED:
- printf("scd%d: door is open\n", unit);
- break;
- case -ERR_NO_CD_INSIDE:
- printf("scd%d: no cd inside\n", unit);
- break;
- default:
- if (errcode == -0x100 || errcode > 0)
- printf("scd%d: device timeout\n", unit);
- else
- printf("scd%d: unexpected error 0x%x\n", unit, -errcode);
- break;
- }
-}
-
-/* Returns 0 or errno value */
-static int
-waitfor_status_bits(int unit, int bits_set, int bits_clear)
-{
- u_int port = scd_data[unit].iobase;
- u_int flags = scd_data[unit].flags;
- u_int reg = port + IREG_STATUS;
- u_int max_loop;
- u_char c = 0;
-
- if (flags & SCDPROBING) {
- max_loop = 0;
- while (max_loop++ < 1000) {
- c = inb(reg);
- if (c == 0xff)
- return EIO;
- if (c & SBIT_ATTENTION) {
- process_attention(unit);
- continue;
- }
- if ((c & bits_set) == bits_set &&
- (c & bits_clear) == 0)
- {
- break;
- }
- DELAY(10000);
- }
- } else {
- max_loop = 100;
- while (max_loop-- > 0) {
- c = inb(reg);
- if (c & SBIT_ATTENTION) {
- process_attention(unit);
- continue;
- }
- if ((c & bits_set) == bits_set &&
- (c & bits_clear) == 0)
- {
- break;
- }
- tsleep(waitfor_status_bits, PZERO - 1, "waitfor", hz/10);
- }
- }
- if ((c & bits_set) == bits_set &&
- (c & bits_clear) == 0)
- {
- return 0;
- }
-#ifdef SCD_DEBUG
- if (scd_debuglevel > 0)
- printf("scd%d: DEBUG: waitfor: TIMEOUT (0x%x,(0x%x,0x%x))\n", unit, c, bits_set, bits_clear);
- else
-#endif
- printf("scd%d: timeout.\n", unit);
- return EIO;
-}
-
-/* these two routines for xcdplayer - "borrowed" from mcd.c */
-static int
-scd_toc_header (int unit, struct ioc_toc_header* th)
-{
- struct scd_data *cd = scd_data + unit;
- int rc;
-
- if (!(cd->flags & SCDTOC) && (rc = read_toc(unit)) != 0) {
- print_error(unit, rc);
- return EIO;
- }
-
- th->starting_track = cd->first_track;
- th->ending_track = cd->last_track;
- th->len = 0; /* not used */
-
- return 0;
-}
-
-static int
-scd_toc_entrys (int unit, struct ioc_read_toc_entry *te)
-{
- struct scd_data *cd = scd_data + unit;
- struct cd_toc_entry toc_entry;
- int rc, i, len = te->data_len;
-
- if (!(cd->flags & SCDTOC) && (rc = read_toc(unit)) != 0) {
- print_error(unit, rc);
- return EIO;
- }
-
- /* find the toc to copy*/
- i = te->starting_track;
- if (i == SCD_LASTPLUS1)
- i = cd->last_track + 1;
-
- /* verify starting track */
- if (i < cd->first_track || i > cd->last_track+1)
- return EINVAL;
-
- /* valid length ? */
- if (len < sizeof(struct cd_toc_entry)
- || (len % sizeof(struct cd_toc_entry)) != 0)
- return EINVAL;
-
- /* copy the toc data */
- toc_entry.control = cd->toc[i].ctl;
- toc_entry.addr_type = te->address_format;
- toc_entry.track = i;
- if (te->address_format == CD_MSF_FORMAT) {
- toc_entry.addr.msf.unused = 0;
- toc_entry.addr.msf.minute = bcd2bin(cd->toc[i].start_msf[0]);
- toc_entry.addr.msf.second = bcd2bin(cd->toc[i].start_msf[1]);
- toc_entry.addr.msf.frame = bcd2bin(cd->toc[i].start_msf[2]);
- }
-
- /* copy the data back */
- if (copyout(&toc_entry, te->data, sizeof(struct cd_toc_entry)) != 0)
- return EFAULT;
-
- return 0;
-}
-
-
-static int
-scd_toc_entry (int unit, struct ioc_read_toc_single_entry *te)
-{
- struct scd_data *cd = scd_data + unit;
- struct cd_toc_entry toc_entry;
- int rc, i;
-
- if (!(cd->flags & SCDTOC) && (rc = read_toc(unit)) != 0) {
- print_error(unit, rc);
- return EIO;
- }
-
- /* find the toc to copy*/
- i = te->track;
- if (i == SCD_LASTPLUS1)
- i = cd->last_track + 1;
-
- /* verify starting track */
- if (i < cd->first_track || i > cd->last_track+1)
- return EINVAL;
-
- /* copy the toc data */
- toc_entry.control = cd->toc[i].ctl;
- toc_entry.addr_type = te->address_format;
- toc_entry.track = i;
- if (te->address_format == CD_MSF_FORMAT) {
- toc_entry.addr.msf.unused = 0;
- toc_entry.addr.msf.minute = bcd2bin(cd->toc[i].start_msf[0]);
- toc_entry.addr.msf.second = bcd2bin(cd->toc[i].start_msf[1]);
- toc_entry.addr.msf.frame = bcd2bin(cd->toc[i].start_msf[2]);
- }
-
- /* copy the data back */
- bcopy(&toc_entry, &te->entry, sizeof(struct cd_toc_entry));
-
- return 0;
-}
diff --git a/sys/dev/scd/scdreg.h b/sys/dev/scd/scdreg.h
deleted file mode 100644
index e9ce3b15a23f..000000000000
--- a/sys/dev/scd/scdreg.h
+++ /dev/null
@@ -1,151 +0,0 @@
-/*-
- * Copyright (c) 1995 Mikael Hybsch
- * 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
- * in this position and unchanged.
- * 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.
- *
- * $FreeBSD$
- *
- */
-
-#ifndef SCD_H
-#define SCD_H
-
-#ifdef __GNUC__
-#if __GNUC__ >= 2
-#pragma pack(1)
-#endif
-#endif
-
-typedef unsigned char bcd_t;
-#define M_msf(msf) msf[0]
-#define S_msf(msf) msf[1]
-#define F_msf(msf) msf[2]
-
-#define IS_ATTENTION(port) ((inb(port+IREG_STATUS) & SBIT_ATTENTION) != 0)
-#define IS_BUSY(port) ((inb(port+IREG_STATUS) & SBIT_BUSY) != 0)
-#define IS_DATA_RDY(port) ((inb(port+IREG_STATUS) & SBIT_DATA_READY) != 0)
-#define STATUS_BIT(port, bit) ((inb(port+IREG_STATUS) & (bit)) != 0)
-#define FSTATUS_BIT(port, bit) ((inb(port+IREG_FSTATUS) & (bit)) != 0)
-
-#define OREG_COMMAND 0
-#define OREG_WPARAMS 1
-#define OREG_CONTROL 3
-#define CBIT_ATTENTION_CLEAR 0x01
-#define CBIT_RESULT_READY_CLEAR 0x02
-#define CBIT_DATA_READY_CLEAR 0x04
-#define CBIT_RPARAM_CLEAR 0x40
-#define CBIT_RESET_DRIVE 0x80
-
-#define IREG_STATUS 0
-#define SBIT_ATTENTION 0x01
-#define SBIT_RESULT_READY 0x02
-#define SBIT_DATA_READY 0x04
-#define SBIT_BUSY 0x80
-
-#define IREG_RESULT 1
-#define IREG_DATA 2
-#define IREG_FSTATUS 3
-#define FBIT_WPARAM_READY 0x01
-
-#define CMD_GET_DRIVE_CONFIG 0x00
-#define CMD_SET_DRIVE_PARAM 0x10
-#define CMD_GET_SUBCHANNEL_DATA 0x21
-#define CMD_GET_TOC 0x24
-#define CMD_READ_TOC 0x30
-#define CMD_READ 0x34
-#define CMD_PLAY_AUDIO 0x40
-#define CMD_STOP_AUDIO 0x41
-#define CMD_EJECT 0x50
-#define CMD_SPIN_UP 0x51
-#define CMD_SPIN_DOWN 0x52
-
-#define ERR_CD_NOT_LOADED 0x20
-#define ERR_NO_CD_INSIDE 0x21
-#define ERR_NOT_SPINNING 0x22
-#define ERR_FATAL_READ_ERROR1 0x53
-#define ERR_FATAL_READ_ERROR2 0x57
-
-#define ATTEN_DRIVE_LOADED 0x80
-#define ATTEN_EJECT_PUSHED 0x81
-#define ATTEN_AUDIO_DONE 0x90
-#define ATTEN_SPIN_UP_DONE 0x24
-#define ATTEN_SPIN_DOWN 0x27
-#define ATTEN_EJECT_DONE 0x28
-
-
-struct sony_drive_configuration {
- char vendor[8];
- char product[16];
- char revision[8];
- u_short config;
-};
-
-/* Almost same as cd_sub_channel_position_data */
-struct sony_subchannel_position_data {
- u_char control:4;
- u_char addr_type:4;
- u_char track_number;
- u_char index_number;
- u_char rel_msf[3];
- u_char dummy;
- u_char abs_msf[3];
-};
-
-struct sony_tracklist {
- u_char adr :4; /* xcdplayer needs these two values */
- u_char ctl :4;
- u_char track;
- u_char start_msf[3];
-};
-
-#define MAX_TRACKS 100
-
-struct sony_toc {
- u_char session_number;
-
- u_char :8;
- u_char :8;
- u_char first_track;
- u_char :8;
- u_char :8;
-
- u_char :8;
- u_char :8;
- u_char last_track;
- u_char :8;
- u_char :8;
-
- u_char :8;
- u_char :8;
- u_char lead_out_start_msf[3];
-
- struct sony_tracklist tracks[MAX_TRACKS];
-
- /* The rest is just to take space in case all data is returned */
-
- u_char dummy[6*9];
-};
-
-#endif /* SCD_H */
diff --git a/sys/dev/sf/if_sf.c b/sys/dev/sf/if_sf.c
deleted file mode 100644
index 5af924b0658d..000000000000
--- a/sys/dev/sf/if_sf.c
+++ /dev/null
@@ -1,1492 +0,0 @@
-/*
- * Copyright (c) 1997, 1998, 1999
- * Bill Paul <wpaul@ctr.columbia.edu>. 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 Bill Paul.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY Bill Paul 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 Bill Paul OR THE VOICES IN HIS HEAD
- * 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Adaptec AIC-6915 "Starfire" PCI fast ethernet driver for FreeBSD.
- * Programming manual is available from:
- * ftp.adaptec.com:/pub/BBS/userguides/aic6915_pg.pdf.
- *
- * Written by Bill Paul <wpaul@ctr.columbia.edu>
- * Department of Electical Engineering
- * Columbia University, New York City
- */
-
-/*
- * The Adaptec AIC-6915 "Starfire" is a 64-bit 10/100 PCI ethernet
- * controller designed with flexibility and reducing CPU load in mind.
- * The Starfire offers high and low priority buffer queues, a
- * producer/consumer index mechanism and several different buffer
- * queue and completion queue descriptor types. Any one of a number
- * of different driver designs can be used, depending on system and
- * OS requirements. This driver makes use of type0 transmit frame
- * descriptors (since BSD fragments packets across an mbuf chain)
- * and two RX buffer queues prioritized on size (one queue for small
- * frames that will fit into a single mbuf, another with full size
- * mbuf clusters for everything else). The producer/consumer indexes
- * and completion queues are also used.
- *
- * One downside to the Starfire has to do with alignment: buffer
- * queues must be aligned on 256-byte boundaries, and receive buffers
- * must be aligned on longword boundaries. The receive buffer alignment
- * causes problems on the Alpha platform, where the packet payload
- * should be longword aligned. There is no simple way around this.
- *
- * For receive filtering, the Starfire offers 16 perfect filter slots
- * and a 512-bit hash table.
- *
- * The Starfire has no internal transceiver, relying instead on an
- * external MII-based transceiver. Accessing registers on external
- * PHYs is done through a special register map rather than with the
- * usual bitbang MDIO method.
- *
- * Acesssing the registers on the Starfire is a little tricky. The
- * Starfire has a 512K internal register space. When programmed for
- * PCI memory mapped mode, the entire register space can be accessed
- * directly. However in I/O space mode, only 256 bytes are directly
- * mapped into PCI I/O space. The other registers can be accessed
- * indirectly using the SF_INDIRECTIO_ADDR and SF_INDIRECTIO_DATA
- * registers inside the 256-byte I/O window.
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/sockio.h>
-#include <sys/mbuf.h>
-#include <sys/malloc.h>
-#include <sys/kernel.h>
-#include <sys/socket.h>
-
-#include <net/if.h>
-#include <net/if_arp.h>
-#include <net/ethernet.h>
-#include <net/if_dl.h>
-#include <net/if_media.h>
-
-#include <net/bpf.h>
-
-#include <vm/vm.h> /* for vtophys */
-#include <vm/pmap.h> /* for vtophys */
-#include <machine/clock.h> /* for DELAY */
-#include <machine/bus_pio.h>
-#include <machine/bus_memio.h>
-#include <machine/bus.h>
-#include <machine/resource.h>
-#include <sys/bus.h>
-#include <sys/rman.h>
-
-#include <dev/mii/mii.h>
-#include <dev/mii/miivar.h>
-
-/* "controller miibus0" required. See GENERIC if you get errors here. */
-#include "miibus_if.h"
-
-#include <pci/pcireg.h>
-#include <pci/pcivar.h>
-
-#define SF_USEIOSPACE
-
-#include <pci/if_sfreg.h>
-
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif
-
-static struct sf_type sf_devs[] = {
- { AD_VENDORID, AD_DEVICEID_STARFIRE,
- "Adaptec AIC-6915 10/100BaseTX" },
- { 0, 0, NULL }
-};
-
-static int sf_probe __P((device_t));
-static int sf_attach __P((device_t));
-static int sf_detach __P((device_t));
-static void sf_intr __P((void *));
-static void sf_stats_update __P((void *));
-static void sf_rxeof __P((struct sf_softc *));
-static void sf_txeof __P((struct sf_softc *));
-static int sf_encap __P((struct sf_softc *,
- struct sf_tx_bufdesc_type0 *,
- struct mbuf *));
-static void sf_start __P((struct ifnet *));
-static int sf_ioctl __P((struct ifnet *, u_long, caddr_t));
-static void sf_init __P((void *));
-static void sf_stop __P((struct sf_softc *));
-static void sf_watchdog __P((struct ifnet *));
-static void sf_shutdown __P((device_t));
-static int sf_ifmedia_upd __P((struct ifnet *));
-static void sf_ifmedia_sts __P((struct ifnet *, struct ifmediareq *));
-static void sf_reset __P((struct sf_softc *));
-static int sf_init_rx_ring __P((struct sf_softc *));
-static void sf_init_tx_ring __P((struct sf_softc *));
-static int sf_newbuf __P((struct sf_softc *,
- struct sf_rx_bufdesc_type0 *,
- struct mbuf *));
-static void sf_setmulti __P((struct sf_softc *));
-static int sf_setperf __P((struct sf_softc *, int, caddr_t));
-static int sf_sethash __P((struct sf_softc *, caddr_t, int));
-#ifdef notdef
-static int sf_setvlan __P((struct sf_softc *, int, u_int32_t));
-#endif
-
-static u_int8_t sf_read_eeprom __P((struct sf_softc *, int));
-static u_int32_t sf_calchash __P((caddr_t));
-
-static int sf_miibus_readreg __P((device_t, int, int));
-static int sf_miibus_writereg __P((device_t, int, int, int));
-static void sf_miibus_statchg __P((device_t));
-
-static u_int32_t csr_read_4 __P((struct sf_softc *, int));
-static void csr_write_4 __P((struct sf_softc *, int, u_int32_t));
-
-#ifdef SF_USEIOSPACE
-#define SF_RES SYS_RES_IOPORT
-#define SF_RID SF_PCI_LOIO
-#else
-#define SF_RES SYS_RES_MEMORY
-#define SF_RID SF_PCI_LOMEM
-#endif
-
-static device_method_t sf_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, sf_probe),
- DEVMETHOD(device_attach, sf_attach),
- DEVMETHOD(device_detach, sf_detach),
- DEVMETHOD(device_shutdown, sf_shutdown),
-
- /* bus interface */
- DEVMETHOD(bus_print_child, bus_generic_print_child),
- DEVMETHOD(bus_driver_added, bus_generic_driver_added),
-
- /* MII interface */
- DEVMETHOD(miibus_readreg, sf_miibus_readreg),
- DEVMETHOD(miibus_writereg, sf_miibus_writereg),
- DEVMETHOD(miibus_statchg, sf_miibus_statchg),
-
- { 0, 0 }
-};
-
-static driver_t sf_driver = {
- "sf",
- sf_methods,
- sizeof(struct sf_softc),
-};
-
-static devclass_t sf_devclass;
-
-DRIVER_MODULE(if_sf, pci, sf_driver, sf_devclass, 0, 0);
-DRIVER_MODULE(miibus, sf, miibus_driver, miibus_devclass, 0, 0);
-
-#define SF_SETBIT(sc, reg, x) \
- csr_write_4(sc, reg, csr_read_4(sc, reg) | x)
-
-#define SF_CLRBIT(sc, reg, x) \
- csr_write_4(sc, reg, csr_read_4(sc, reg) & ~x)
-
-static u_int32_t csr_read_4(sc, reg)
- struct sf_softc *sc;
- int reg;
-{
- u_int32_t val;
-
-#ifdef SF_USEIOSPACE
- CSR_WRITE_4(sc, SF_INDIRECTIO_ADDR, reg + SF_RMAP_INTREG_BASE);
- val = CSR_READ_4(sc, SF_INDIRECTIO_DATA);
-#else
- val = CSR_READ_4(sc, (reg + SF_RMAP_INTREG_BASE));
-#endif
-
- return(val);
-}
-
-static u_int8_t sf_read_eeprom(sc, reg)
- struct sf_softc *sc;
- int reg;
-{
- u_int8_t val;
-
- val = (csr_read_4(sc, SF_EEADDR_BASE +
- (reg & 0xFFFFFFFC)) >> (8 * (reg & 3))) & 0xFF;
-
- return(val);
-}
-
-static void csr_write_4(sc, reg, val)
- struct sf_softc *sc;
- int reg;
- u_int32_t val;
-{
-#ifdef SF_USEIOSPACE
- CSR_WRITE_4(sc, SF_INDIRECTIO_ADDR, reg + SF_RMAP_INTREG_BASE);
- CSR_WRITE_4(sc, SF_INDIRECTIO_DATA, val);
-#else
- CSR_WRITE_4(sc, (reg + SF_RMAP_INTREG_BASE), val);
-#endif
- return;
-}
-
-static u_int32_t sf_calchash(addr)
- caddr_t addr;
-{
- u_int32_t crc, carry;
- int i, j;
- u_int8_t c;
-
- /* Compute CRC for the address value. */
- crc = 0xFFFFFFFF; /* initial value */
-
- for (i = 0; i < 6; i++) {
- c = *(addr + i);
- for (j = 0; j < 8; j++) {
- carry = ((crc & 0x80000000) ? 1 : 0) ^ (c & 0x01);
- crc <<= 1;
- c >>= 1;
- if (carry)
- crc = (crc ^ 0x04c11db6) | carry;
- }
- }
-
- /* return the filter bit position */
- return(crc >> 23 & 0x1FF);
-}
-
-/*
- * Copy the address 'mac' into the perfect RX filter entry at
- * offset 'idx.' The perfect filter only has 16 entries so do
- * some sanity tests.
- */
-static int sf_setperf(sc, idx, mac)
- struct sf_softc *sc;
- int idx;
- caddr_t mac;
-{
- u_int16_t *p;
-
- if (idx < 0 || idx > SF_RXFILT_PERFECT_CNT)
- return(EINVAL);
-
- if (mac == NULL)
- return(EINVAL);
-
- p = (u_int16_t *)mac;
-
- csr_write_4(sc, SF_RXFILT_PERFECT_BASE +
- (idx * SF_RXFILT_PERFECT_SKIP), htons(p[2]));
- csr_write_4(sc, SF_RXFILT_PERFECT_BASE +
- (idx * SF_RXFILT_PERFECT_SKIP) + 4, htons(p[1]));
- csr_write_4(sc, SF_RXFILT_PERFECT_BASE +
- (idx * SF_RXFILT_PERFECT_SKIP) + 8, htons(p[0]));
-
- return(0);
-}
-
-/*
- * Set the bit in the 512-bit hash table that corresponds to the
- * specified mac address 'mac.' If 'prio' is nonzero, update the
- * priority hash table instead of the filter hash table.
- */
-static int sf_sethash(sc, mac, prio)
- struct sf_softc *sc;
- caddr_t mac;
- int prio;
-{
- u_int32_t h = 0;
-
- if (mac == NULL)
- return(EINVAL);
-
- h = sf_calchash(mac);
-
- if (prio) {
- SF_SETBIT(sc, SF_RXFILT_HASH_BASE + SF_RXFILT_HASH_PRIOOFF +
- (SF_RXFILT_HASH_SKIP * (h >> 4)), (1 << (h & 0xF)));
- } else {
- SF_SETBIT(sc, SF_RXFILT_HASH_BASE + SF_RXFILT_HASH_ADDROFF +
- (SF_RXFILT_HASH_SKIP * (h >> 4)), (1 << (h & 0xF)));
- }
-
- return(0);
-}
-
-#ifdef notdef
-/*
- * Set a VLAN tag in the receive filter.
- */
-static int sf_setvlan(sc, idx, vlan)
- struct sf_softc *sc;
- int idx;
- u_int32_t vlan;
-{
- if (idx < 0 || idx >> SF_RXFILT_HASH_CNT)
- return(EINVAL);
-
- csr_write_4(sc, SF_RXFILT_HASH_BASE +
- (idx * SF_RXFILT_HASH_SKIP) + SF_RXFILT_HASH_VLANOFF, vlan);
-
- return(0);
-}
-#endif
-
-static int sf_miibus_readreg(dev, phy, reg)
- device_t dev;
- int phy, reg;
-{
- struct sf_softc *sc;
- int i;
- u_int32_t val = 0;
-
- sc = device_get_softc(dev);
-
- for (i = 0; i < SF_TIMEOUT; i++) {
- val = csr_read_4(sc, SF_PHY_REG(phy, reg));
- if (val & SF_MII_DATAVALID)
- break;
- }
-
- if (i == SF_TIMEOUT)
- return(0);
-
- if ((val & 0x0000FFFF) == 0xFFFF)
- return(0);
-
- return(val & 0x0000FFFF);
-}
-
-static int sf_miibus_writereg(dev, phy, reg, val)
- device_t dev;
- int phy, reg, val;
-{
- struct sf_softc *sc;
- int i;
- int busy;
-
- sc = device_get_softc(dev);
-
- csr_write_4(sc, SF_PHY_REG(phy, reg), val);
-
- for (i = 0; i < SF_TIMEOUT; i++) {
- busy = csr_read_4(sc, SF_PHY_REG(phy, reg));
- if (!(busy & SF_MII_BUSY))
- break;
- }
-
- return(0);
-}
-
-static void sf_miibus_statchg(dev)
- device_t dev;
-{
- struct sf_softc *sc;
- struct mii_data *mii;
-
- sc = device_get_softc(dev);
- mii = device_get_softc(sc->sf_miibus);
-
- if ((mii->mii_media_active & IFM_GMASK) == IFM_FDX) {
- SF_SETBIT(sc, SF_MACCFG_1, SF_MACCFG1_FULLDUPLEX);
- csr_write_4(sc, SF_BKTOBKIPG, SF_IPGT_FDX);
- } else {
- SF_CLRBIT(sc, SF_MACCFG_1, SF_MACCFG1_FULLDUPLEX);
- csr_write_4(sc, SF_BKTOBKIPG, SF_IPGT_HDX);
- }
-
- return;
-}
-
-static void sf_setmulti(sc)
- struct sf_softc *sc;
-{
- struct ifnet *ifp;
- int i;
- struct ifmultiaddr *ifma;
- u_int8_t dummy[] = { 0, 0, 0, 0, 0, 0 };
-
- ifp = &sc->arpcom.ac_if;
-
- /* First zot all the existing filters. */
- for (i = 1; i < SF_RXFILT_PERFECT_CNT; i++)
- sf_setperf(sc, i, (char *)&dummy);
- for (i = SF_RXFILT_HASH_BASE;
- i < (SF_RXFILT_HASH_MAX + 1); i += 4)
- csr_write_4(sc, i, 0);
- SF_CLRBIT(sc, SF_RXFILT, SF_RXFILT_ALLMULTI);
-
- /* Now program new ones. */
- if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) {
- SF_SETBIT(sc, SF_RXFILT, SF_RXFILT_ALLMULTI);
- } else {
- i = 1;
- /* First find the tail of the list. */
- for (ifma = ifp->if_multiaddrs.lh_first; ifma != NULL;
- ifma = ifma->ifma_link.le_next) {
- if (ifma->ifma_link.le_next == NULL)
- break;
- }
- /* Now traverse the list backwards. */
- for (; ifma != NULL && ifma != (void *)&ifp->if_multiaddrs;
- ifma = (struct ifmultiaddr *)ifma->ifma_link.le_prev) {
- if (ifma->ifma_addr->sa_family != AF_LINK)
- continue;
- /*
- * Program the first 15 multicast groups
- * into the perfect filter. For all others,
- * use the hash table.
- */
- if (i < SF_RXFILT_PERFECT_CNT) {
- sf_setperf(sc, i,
- LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
- i++;
- continue;
- }
-
- sf_sethash(sc,
- LLADDR((struct sockaddr_dl *)ifma->ifma_addr), 0);
- }
- }
-
- return;
-}
-
-/*
- * Set media options.
- */
-static int sf_ifmedia_upd(ifp)
- struct ifnet *ifp;
-{
- struct sf_softc *sc;
- struct mii_data *mii;
-
- sc = ifp->if_softc;
- mii = device_get_softc(sc->sf_miibus);
- sc->sf_link = 0;
- if (mii->mii_instance) {
- struct mii_softc *miisc;
- for (miisc = LIST_FIRST(&mii->mii_phys); miisc != NULL;
- miisc = LIST_NEXT(miisc, mii_list))
- mii_phy_reset(miisc);
- }
- mii_mediachg(mii);
-
- return(0);
-}
-
-/*
- * Report current media status.
- */
-static void sf_ifmedia_sts(ifp, ifmr)
- struct ifnet *ifp;
- struct ifmediareq *ifmr;
-{
- struct sf_softc *sc;
- struct mii_data *mii;
-
- sc = ifp->if_softc;
- mii = device_get_softc(sc->sf_miibus);
-
- mii_pollstat(mii);
- ifmr->ifm_active = mii->mii_media_active;
- ifmr->ifm_status = mii->mii_media_status;
-
- return;
-}
-
-static int sf_ioctl(ifp, command, data)
- struct ifnet *ifp;
- u_long command;
- caddr_t data;
-{
- struct sf_softc *sc = ifp->if_softc;
- struct ifreq *ifr = (struct ifreq *) data;
- struct mii_data *mii;
- int s, error = 0;
-
- s = splimp();
-
- switch(command) {
- case SIOCSIFADDR:
- case SIOCGIFADDR:
- case SIOCSIFMTU:
- error = ether_ioctl(ifp, command, data);
- break;
- case SIOCSIFFLAGS:
- if (ifp->if_flags & IFF_UP) {
- if (ifp->if_flags & IFF_RUNNING &&
- ifp->if_flags & IFF_PROMISC &&
- !(sc->sf_if_flags & IFF_PROMISC)) {
- SF_SETBIT(sc, SF_RXFILT, SF_RXFILT_PROMISC);
- } else if (ifp->if_flags & IFF_RUNNING &&
- !(ifp->if_flags & IFF_PROMISC) &&
- sc->sf_if_flags & IFF_PROMISC) {
- SF_CLRBIT(sc, SF_RXFILT, SF_RXFILT_PROMISC);
- } else if (!(ifp->if_flags & IFF_RUNNING))
- sf_init(sc);
- } else {
- if (ifp->if_flags & IFF_RUNNING)
- sf_stop(sc);
- }
- sc->sf_if_flags = ifp->if_flags;
- error = 0;
- break;
- case SIOCADDMULTI:
- case SIOCDELMULTI:
- sf_setmulti(sc);
- error = 0;
- break;
- case SIOCGIFMEDIA:
- case SIOCSIFMEDIA:
- mii = device_get_softc(sc->sf_miibus);
- error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, command);
- break;
- default:
- error = EINVAL;
- break;
- }
-
- (void)splx(s);
-
- return(error);
-}
-
-static void sf_reset(sc)
- struct sf_softc *sc;
-{
- register int i;
-
- csr_write_4(sc, SF_GEN_ETH_CTL, 0);
- SF_SETBIT(sc, SF_MACCFG_1, SF_MACCFG1_SOFTRESET);
- DELAY(1000);
- SF_CLRBIT(sc, SF_MACCFG_1, SF_MACCFG1_SOFTRESET);
-
- SF_SETBIT(sc, SF_PCI_DEVCFG, SF_PCIDEVCFG_RESET);
-
- for (i = 0; i < SF_TIMEOUT; i++) {
- DELAY(10);
- if (!(csr_read_4(sc, SF_PCI_DEVCFG) & SF_PCIDEVCFG_RESET))
- break;
- }
-
- if (i == SF_TIMEOUT)
- printf("sf%d: reset never completed!\n", sc->sf_unit);
-
- /* Wait a little while for the chip to get its brains in order. */
- DELAY(1000);
- return;
-}
-
-/*
- * Probe for an Adaptec AIC-6915 chip. Check the PCI vendor and device
- * IDs against our list and return a device name if we find a match.
- * We also check the subsystem ID so that we can identify exactly which
- * NIC has been found, if possible.
- */
-static int sf_probe(dev)
- device_t dev;
-{
- struct sf_type *t;
-
- t = sf_devs;
-
- while(t->sf_name != NULL) {
- if ((pci_get_vendor(dev) == t->sf_vid) &&
- (pci_get_device(dev) == t->sf_did)) {
- switch((pci_read_config(dev,
- SF_PCI_SUBVEN_ID, 4) >> 16) & 0xFFFF) {
- case AD_SUBSYSID_62011_REV0:
- case AD_SUBSYSID_62011_REV1:
- device_set_desc(dev,
- "Adaptec ANA-62011 10/100BaseTX");
- return(0);
- break;
- case AD_SUBSYSID_62022:
- device_set_desc(dev,
- "Adaptec ANA-62022 10/100BaseTX");
- return(0);
- break;
- case AD_SUBSYSID_62044_REV0:
- case AD_SUBSYSID_62044_REV1:
- device_set_desc(dev,
- "Adaptec ANA-62044 10/100BaseTX");
- return(0);
- break;
- case AD_SUBSYSID_62020:
- device_set_desc(dev,
- "Adaptec ANA-62020 10/100BaseFX");
- return(0);
- break;
- case AD_SUBSYSID_69011:
- device_set_desc(dev,
- "Adaptec ANA-69011 10/100BaseTX");
- return(0);
- break;
- default:
- device_set_desc(dev, t->sf_name);
- return(0);
- break;
- }
- }
- t++;
- }
-
- return(ENXIO);
-}
-
-/*
- * Attach the interface. Allocate softc structures, do ifmedia
- * setup and ethernet/BPF attach.
- */
-static int sf_attach(dev)
- device_t dev;
-{
- int s, i;
- u_int32_t command;
- struct sf_softc *sc;
- struct ifnet *ifp;
- int unit, rid, error = 0;
-
- s = splimp();
-
- sc = device_get_softc(dev);
- unit = device_get_unit(dev);
- bzero(sc, sizeof(struct sf_softc));
-
- /*
- * Handle power management nonsense.
- */
- command = pci_read_config(dev, SF_PCI_CAPID, 4) & 0x000000FF;
- if (command == 0x01) {
-
- command = pci_read_config(dev, SF_PCI_PWRMGMTCTRL, 4);
- if (command & SF_PSTATE_MASK) {
- u_int32_t iobase, membase, irq;
-
- /* Save important PCI config data. */
- iobase = pci_read_config(dev, SF_PCI_LOIO, 4);
- membase = pci_read_config(dev, SF_PCI_LOMEM, 4);
- irq = pci_read_config(dev, SF_PCI_INTLINE, 4);
-
- /* Reset the power state. */
- printf("sf%d: chip is in D%d power mode "
- "-- setting to D0\n", unit, command & SF_PSTATE_MASK);
- command &= 0xFFFFFFFC;
- pci_write_config(dev, SF_PCI_PWRMGMTCTRL, command, 4);
-
- /* Restore PCI config data. */
- pci_write_config(dev, SF_PCI_LOIO, iobase, 4);
- pci_write_config(dev, SF_PCI_LOMEM, membase, 4);
- pci_write_config(dev, SF_PCI_INTLINE, irq, 4);
- }
- }
-
- /*
- * Map control/status registers.
- */
- command = pci_read_config(dev, PCI_COMMAND_STATUS_REG, 4);
- command |= (PCIM_CMD_PORTEN|PCIM_CMD_MEMEN|PCIM_CMD_BUSMASTEREN);
- pci_write_config(dev, PCI_COMMAND_STATUS_REG, command, 4);
- command = pci_read_config(dev, PCI_COMMAND_STATUS_REG, 4);
-
-#ifdef SF_USEIOSPACE
- if (!(command & PCIM_CMD_PORTEN)) {
- printf("sf%d: failed to enable I/O ports!\n", unit);
- error = ENXIO;
- goto fail;
- }
-#else
- if (!(command & PCIM_CMD_MEMEN)) {
- printf("sf%d: failed to enable memory mapping!\n", unit);
- error = ENXIO;
- goto fail;
- }
-#endif
-
- rid = SF_RID;
- sc->sf_res = bus_alloc_resource(dev, SF_RES, &rid,
- 0, ~0, 1, RF_ACTIVE);
-
- if (sc->sf_res == NULL) {
- printf ("sf%d: couldn't map ports\n", unit);
- error = ENXIO;
- goto fail;
- }
-
- sc->sf_btag = rman_get_bustag(sc->sf_res);
- sc->sf_bhandle = rman_get_bushandle(sc->sf_res);
-
- /* Allocate interrupt */
- rid = 0;
- sc->sf_irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1,
- RF_SHAREABLE | RF_ACTIVE);
-
- if (sc->sf_irq == NULL) {
- printf("sf%d: couldn't map interrupt\n", unit);
- bus_release_resource(dev, SF_RES, SF_RID, sc->sf_res);
- error = ENXIO;
- goto fail;
- }
-
- error = bus_setup_intr(dev, sc->sf_irq, INTR_TYPE_NET,
- sf_intr, sc, &sc->sf_intrhand);
-
- if (error) {
- bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sf_res);
- bus_release_resource(dev, SF_RES, SF_RID, sc->sf_res);
- printf("sf%d: couldn't set up irq\n", unit);
- goto fail;
- }
-
- callout_handle_init(&sc->sf_stat_ch);
-
- /* Reset the adapter. */
- sf_reset(sc);
-
- /*
- * Get station address from the EEPROM.
- */
- for (i = 0; i < ETHER_ADDR_LEN; i++)
- sc->arpcom.ac_enaddr[i] =
- sf_read_eeprom(sc, SF_EE_NODEADDR + ETHER_ADDR_LEN - i);
-
- /*
- * An Adaptec chip was detected. Inform the world.
- */
- printf("sf%d: Ethernet address: %6D\n", unit,
- sc->arpcom.ac_enaddr, ":");
-
- sc->sf_unit = unit;
-
- /* Allocate the descriptor queues. */
- sc->sf_ldata = contigmalloc(sizeof(struct sf_list_data), M_DEVBUF,
- M_NOWAIT, 0, 0xffffffff, PAGE_SIZE, 0);
-
- if (sc->sf_ldata == NULL) {
- printf("sf%d: no memory for list buffers!\n", unit);
- bus_teardown_intr(dev, sc->sf_irq, sc->sf_intrhand);
- bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sf_irq);
- bus_release_resource(dev, SF_RES, SF_RID, sc->sf_res);
- error = ENXIO;
- goto fail;
- }
-
- bzero(sc->sf_ldata, sizeof(struct sf_list_data));
-
- /* Do MII setup. */
- if (mii_phy_probe(dev, &sc->sf_miibus,
- sf_ifmedia_upd, sf_ifmedia_sts)) {
- printf("sf%d: MII without any phy!\n", sc->sf_unit);
- contigfree(sc->sf_ldata,sizeof(struct sf_list_data),M_DEVBUF);
- bus_teardown_intr(dev, sc->sf_irq, sc->sf_intrhand);
- bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sf_irq);
- bus_release_resource(dev, SF_RES, SF_RID, sc->sf_res);
- error = ENXIO;
- goto fail;
- }
-
- ifp = &sc->arpcom.ac_if;
- ifp->if_softc = sc;
- ifp->if_unit = unit;
- ifp->if_name = "sf";
- ifp->if_mtu = ETHERMTU;
- ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
- ifp->if_ioctl = sf_ioctl;
- ifp->if_output = ether_output;
- ifp->if_start = sf_start;
- ifp->if_watchdog = sf_watchdog;
- ifp->if_init = sf_init;
- ifp->if_baudrate = 10000000;
- ifp->if_snd.ifq_maxlen = SF_TX_DLIST_CNT - 1;
-
- /*
- * Call MI attach routines.
- */
- if_attach(ifp);
- ether_ifattach(ifp);
-
- bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
-
-fail:
- splx(s);
- return(error);
-}
-
-static int sf_detach(dev)
- device_t dev;
-{
- struct sf_softc *sc;
- struct ifnet *ifp;
- int s;
-
- s = splimp();
-
- sc = device_get_softc(dev);
- ifp = &sc->arpcom.ac_if;
-
- if_detach(ifp);
- sf_stop(sc);
-
- bus_generic_detach(dev);
- device_delete_child(dev, sc->sf_miibus);
-
- bus_teardown_intr(dev, sc->sf_irq, sc->sf_intrhand);
- bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sf_irq);
- bus_release_resource(dev, SF_RES, SF_RID, sc->sf_res);
-
- contigfree(sc->sf_ldata, sizeof(struct sf_list_data), M_DEVBUF);
-
- splx(s);
-
- return(0);
-}
-
-static int sf_init_rx_ring(sc)
- struct sf_softc *sc;
-{
- struct sf_list_data *ld;
- int i;
-
- ld = sc->sf_ldata;
-
- bzero((char *)ld->sf_rx_dlist_big,
- sizeof(struct sf_rx_bufdesc_type0) * SF_RX_DLIST_CNT);
- bzero((char *)ld->sf_rx_clist,
- sizeof(struct sf_rx_cmpdesc_type3) * SF_RX_CLIST_CNT);
-
- for (i = 0; i < SF_RX_DLIST_CNT; i++) {
- if (sf_newbuf(sc, &ld->sf_rx_dlist_big[i], NULL) == ENOBUFS)
- return(ENOBUFS);
- }
-
- return(0);
-}
-
-static void sf_init_tx_ring(sc)
- struct sf_softc *sc;
-{
- struct sf_list_data *ld;
- int i;
-
- ld = sc->sf_ldata;
-
- bzero((char *)ld->sf_tx_dlist,
- sizeof(struct sf_tx_bufdesc_type0) * SF_TX_DLIST_CNT);
- bzero((char *)ld->sf_tx_clist,
- sizeof(struct sf_tx_cmpdesc_type0) * SF_TX_CLIST_CNT);
-
- for (i = 0; i < SF_TX_DLIST_CNT; i++)
- ld->sf_tx_dlist[i].sf_id = SF_TX_BUFDESC_ID;
- for (i = 0; i < SF_TX_CLIST_CNT; i++)
- ld->sf_tx_clist[i].sf_type = SF_TXCMPTYPE_TX;
-
- ld->sf_tx_dlist[SF_TX_DLIST_CNT - 1].sf_end = 1;
- sc->sf_tx_cnt = 0;
-
- return;
-}
-
-static int sf_newbuf(sc, c, m)
- struct sf_softc *sc;
- struct sf_rx_bufdesc_type0 *c;
- struct mbuf *m;
-{
- struct mbuf *m_new = NULL;
-
- if (m == NULL) {
- MGETHDR(m_new, M_DONTWAIT, MT_DATA);
- if (m_new == NULL) {
- printf("sf%d: no memory for rx list -- "
- "packet dropped!\n", sc->sf_unit);
- return(ENOBUFS);
- }
-
- MCLGET(m_new, M_DONTWAIT);
- if (!(m_new->m_flags & M_EXT)) {
- printf("sf%d: no memory for rx list -- "
- "packet dropped!\n", sc->sf_unit);
- m_freem(m_new);
- return(ENOBUFS);
- }
- m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
- } else {
- m_new = m;
- m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
- m_new->m_data = m_new->m_ext.ext_buf;
- }
-
- m_adj(m_new, sizeof(u_int64_t));
-
- c->sf_mbuf = m_new;
- c->sf_addrlo = SF_RX_HOSTADDR(vtophys(mtod(m_new, caddr_t)));
- c->sf_valid = 1;
-
- return(0);
-}
-
-/*
- * The starfire is programmed to use 'normal' mode for packet reception,
- * which means we use the consumer/producer model for both the buffer
- * descriptor queue and the completion descriptor queue. The only problem
- * with this is that it involves a lot of register accesses: we have to
- * read the RX completion consumer and producer indexes and the RX buffer
- * producer index, plus the RX completion consumer and RX buffer producer
- * indexes have to be updated. It would have been easier if Adaptec had
- * put each index in a separate register, especially given that the damn
- * NIC has a 512K register space.
- *
- * In spite of all the lovely features that Adaptec crammed into the 6915,
- * it is marred by one truly stupid design flaw, which is that receive
- * buffer addresses must be aligned on a longword boundary. This forces
- * the packet payload to be unaligned, which is suboptimal on the x86 and
- * completely unuseable on the Alpha. Our only recourse is to copy received
- * packets into properly aligned buffers before handing them off.
- */
-
-static void sf_rxeof(sc)
- struct sf_softc *sc;
-{
- struct ether_header *eh;
- struct mbuf *m;
- struct ifnet *ifp;
- struct sf_rx_bufdesc_type0 *desc;
- struct sf_rx_cmpdesc_type3 *cur_rx;
- u_int32_t rxcons, rxprod;
- int cmpprodidx, cmpconsidx, bufprodidx;
-
- ifp = &sc->arpcom.ac_if;
-
- rxcons = csr_read_4(sc, SF_CQ_CONSIDX);
- rxprod = csr_read_4(sc, SF_RXDQ_PTR_Q1);
- cmpprodidx = SF_IDX_LO(csr_read_4(sc, SF_CQ_PRODIDX));
- cmpconsidx = SF_IDX_LO(rxcons);
- bufprodidx = SF_IDX_LO(rxprod);
-
- while (cmpconsidx != cmpprodidx) {
- struct mbuf *m0;
-
- cur_rx = &sc->sf_ldata->sf_rx_clist[cmpconsidx];
- desc = &sc->sf_ldata->sf_rx_dlist_big[cur_rx->sf_endidx];
- m = desc->sf_mbuf;
- SF_INC(cmpconsidx, SF_RX_CLIST_CNT);
- SF_INC(bufprodidx, SF_RX_DLIST_CNT);
-
- if (!(cur_rx->sf_status1 & SF_RXSTAT1_OK)) {
- ifp->if_ierrors++;
- sf_newbuf(sc, desc, m);
- continue;
- }
-
- m0 = m_devget(mtod(m, char *) - ETHER_ALIGN,
- cur_rx->sf_len + ETHER_ALIGN, 0, ifp, NULL);
- sf_newbuf(sc, desc, m);
- if (m0 == NULL) {
- ifp->if_ierrors++;
- continue;
- }
- m_adj(m0, ETHER_ALIGN);
- m = m0;
-
- eh = mtod(m, struct ether_header *);
- ifp->if_ipackets++;
-
- if (ifp->if_bpf) {
- bpf_mtap(ifp, m);
- if (ifp->if_flags & IFF_PROMISC &&
- (bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr,
- ETHER_ADDR_LEN) && !(eh->ether_dhost[0] & 1))) {
- m_freem(m);
- continue;
- }
- }
-
- /* Remove header from mbuf and pass it on. */
- m_adj(m, sizeof(struct ether_header));
- ether_input(ifp, eh, m);
-
- }
-
- csr_write_4(sc, SF_CQ_CONSIDX,
- (rxcons & ~SF_CQ_CONSIDX_RXQ1) | cmpconsidx);
- csr_write_4(sc, SF_RXDQ_PTR_Q1,
- (rxprod & ~SF_RXDQ_PRODIDX) | bufprodidx);
-
- return;
-}
-
-/*
- * Read the transmit status from the completion queue and release
- * mbufs. Note that the buffer descriptor index in the completion
- * descriptor is an offset from the start of the transmit buffer
- * descriptor list in bytes. This is important because the manual
- * gives the impression that it should match the producer/consumer
- * index, which is the offset in 8 byte blocks.
- */
-static void sf_txeof(sc)
- struct sf_softc *sc;
-{
- int txcons, cmpprodidx, cmpconsidx;
- struct sf_tx_cmpdesc_type1 *cur_cmp;
- struct sf_tx_bufdesc_type0 *cur_tx;
- struct ifnet *ifp;
-
- ifp = &sc->arpcom.ac_if;
-
- txcons = csr_read_4(sc, SF_CQ_CONSIDX);
- cmpprodidx = SF_IDX_HI(csr_read_4(sc, SF_CQ_PRODIDX));
- cmpconsidx = SF_IDX_HI(txcons);
-
- while (cmpconsidx != cmpprodidx) {
- cur_cmp = &sc->sf_ldata->sf_tx_clist[cmpconsidx];
- cur_tx = &sc->sf_ldata->sf_tx_dlist[cur_cmp->sf_index >> 7];
- SF_INC(cmpconsidx, SF_TX_CLIST_CNT);
-
- if (cur_cmp->sf_txstat & SF_TXSTAT_TX_OK)
- ifp->if_opackets++;
- else
- ifp->if_oerrors++;
-
- sc->sf_tx_cnt--;
- if (cur_tx->sf_mbuf != NULL) {
- m_freem(cur_tx->sf_mbuf);
- cur_tx->sf_mbuf = NULL;
- }
- }
-
- ifp->if_timer = 0;
- ifp->if_flags &= ~IFF_OACTIVE;
-
- csr_write_4(sc, SF_CQ_CONSIDX,
- (txcons & ~SF_CQ_CONSIDX_TXQ) |
- ((cmpconsidx << 16) & 0xFFFF0000));
-
- return;
-}
-
-static void sf_intr(arg)
- void *arg;
-{
- struct sf_softc *sc;
- struct ifnet *ifp;
- u_int32_t status;
-
- sc = arg;
- ifp = &sc->arpcom.ac_if;
-
- if (!(csr_read_4(sc, SF_ISR_SHADOW) & SF_ISR_PCIINT_ASSERTED))
- return;
-
- /* Disable interrupts. */
- csr_write_4(sc, SF_IMR, 0x00000000);
-
- for (;;) {
- status = csr_read_4(sc, SF_ISR);
- if (status)
- csr_write_4(sc, SF_ISR, status);
-
- if (!(status & SF_INTRS))
- break;
-
- if (status & SF_ISR_RXDQ1_DMADONE)
- sf_rxeof(sc);
-
- if (status & SF_ISR_TX_TXDONE)
- sf_txeof(sc);
-
- if (status & SF_ISR_ABNORMALINTR) {
- if (status & SF_ISR_STATSOFLOW) {
- untimeout(sf_stats_update, sc,
- sc->sf_stat_ch);
- sf_stats_update(sc);
- } else
- sf_init(sc);
- }
- }
-
- /* Re-enable interrupts. */
- csr_write_4(sc, SF_IMR, SF_INTRS);
-
- if (ifp->if_snd.ifq_head != NULL)
- sf_start(ifp);
-
- return;
-}
-
-static void sf_init(xsc)
- void *xsc;
-{
- struct sf_softc *sc;
- struct ifnet *ifp;
- struct mii_data *mii;
- int i, s;
-
- s = splimp();
-
- sc = xsc;
- ifp = &sc->arpcom.ac_if;
- mii = device_get_softc(sc->sf_miibus);
-
- sf_stop(sc);
- sf_reset(sc);
-
- /* Init all the receive filter registers */
- for (i = SF_RXFILT_PERFECT_BASE;
- i < (SF_RXFILT_HASH_MAX + 1); i += 4)
- csr_write_4(sc, i, 0);
-
- /* Empty stats counter registers. */
- for (i = 0; i < sizeof(struct sf_stats)/sizeof(u_int32_t); i++)
- csr_write_4(sc, SF_STATS_BASE +
- (i + sizeof(u_int32_t)), 0);
-
- /* Init our MAC address */
- csr_write_4(sc, SF_PAR0, *(u_int32_t *)(&sc->arpcom.ac_enaddr[0]));
- csr_write_4(sc, SF_PAR1, *(u_int32_t *)(&sc->arpcom.ac_enaddr[4]));
- sf_setperf(sc, 0, (caddr_t)&sc->arpcom.ac_enaddr);
-
- if (sf_init_rx_ring(sc) == ENOBUFS) {
- printf("sf%d: initialization failed: no "
- "memory for rx buffers\n", sc->sf_unit);
- (void)splx(s);
- return;
- }
-
- sf_init_tx_ring(sc);
-
- csr_write_4(sc, SF_RXFILT, SF_PERFMODE_NORMAL|SF_HASHMODE_WITHVLAN);
-
- /* If we want promiscuous mode, set the allframes bit. */
- if (ifp->if_flags & IFF_PROMISC) {
- SF_SETBIT(sc, SF_RXFILT, SF_RXFILT_PROMISC);
- } else {
- SF_CLRBIT(sc, SF_RXFILT, SF_RXFILT_PROMISC);
- }
-
- if (ifp->if_flags & IFF_BROADCAST) {
- SF_SETBIT(sc, SF_RXFILT, SF_RXFILT_BROAD);
- } else {
- SF_CLRBIT(sc, SF_RXFILT, SF_RXFILT_BROAD);
- }
-
- /* Init the completion queue indexes */
- csr_write_4(sc, SF_CQ_CONSIDX, 0);
- csr_write_4(sc, SF_CQ_PRODIDX, 0);
-
- /* Init the RX completion queue */
- csr_write_4(sc, SF_RXCQ_CTL_1,
- vtophys(sc->sf_ldata->sf_rx_clist) & SF_RXCQ_ADDR);
- SF_SETBIT(sc, SF_RXCQ_CTL_1, SF_RXCQTYPE_3);
-
- /* Init RX DMA control. */
- SF_SETBIT(sc, SF_RXDMA_CTL, SF_RXDMA_REPORTBADPKTS);
-
- /* Init the RX buffer descriptor queue. */
- csr_write_4(sc, SF_RXDQ_ADDR_Q1,
- vtophys(sc->sf_ldata->sf_rx_dlist_big));
- csr_write_4(sc, SF_RXDQ_CTL_1, (MCLBYTES << 16) | SF_DESCSPACE_16BYTES);
- csr_write_4(sc, SF_RXDQ_PTR_Q1, SF_RX_DLIST_CNT - 1);
-
- /* Init the TX completion queue */
- csr_write_4(sc, SF_TXCQ_CTL,
- vtophys(sc->sf_ldata->sf_tx_clist) & SF_RXCQ_ADDR);
-
- /* Init the TX buffer descriptor queue. */
- csr_write_4(sc, SF_TXDQ_ADDR_HIPRIO,
- vtophys(sc->sf_ldata->sf_tx_dlist));
- SF_SETBIT(sc, SF_TX_FRAMCTL, SF_TXFRMCTL_CPLAFTERTX);
- csr_write_4(sc, SF_TXDQ_CTL,
- SF_TXBUFDESC_TYPE0|SF_TXMINSPACE_128BYTES|SF_TXSKIPLEN_8BYTES);
- SF_SETBIT(sc, SF_TXDQ_CTL, SF_TXDQCTL_NODMACMP);
-
- /* Enable autopadding of short TX frames. */
- SF_SETBIT(sc, SF_MACCFG_1, SF_MACCFG1_AUTOPAD);
-
- /* Enable interrupts. */
- csr_write_4(sc, SF_IMR, SF_INTRS);
- SF_SETBIT(sc, SF_PCI_DEVCFG, SF_PCIDEVCFG_INTR_ENB);
-
- /* Enable the RX and TX engines. */
- SF_SETBIT(sc, SF_GEN_ETH_CTL, SF_ETHCTL_RX_ENB|SF_ETHCTL_RXDMA_ENB);
- SF_SETBIT(sc, SF_GEN_ETH_CTL, SF_ETHCTL_TX_ENB|SF_ETHCTL_TXDMA_ENB);
-
- /*mii_mediachg(mii);*/
- sf_ifmedia_upd(ifp);
-
- ifp->if_flags |= IFF_RUNNING;
- ifp->if_flags &= ~IFF_OACTIVE;
-
- sc->sf_stat_ch = timeout(sf_stats_update, sc, hz);
-
- splx(s);
-
- return;
-}
-
-static int sf_encap(sc, c, m_head)
- struct sf_softc *sc;
- struct sf_tx_bufdesc_type0 *c;
- struct mbuf *m_head;
-{
- int frag = 0;
- struct sf_frag *f = NULL;
- struct mbuf *m;
-
- m = m_head;
-
- for (m = m_head, frag = 0; m != NULL; m = m->m_next) {
- if (m->m_len != 0) {
- if (frag == SF_MAXFRAGS)
- break;
- f = &c->sf_frags[frag];
- if (frag == 0)
- f->sf_pktlen = m_head->m_pkthdr.len;
- f->sf_fraglen = m->m_len;
- f->sf_addr = vtophys(mtod(m, vm_offset_t));
- frag++;
- }
- }
-
- if (m != NULL) {
- struct mbuf *m_new = NULL;
-
- MGETHDR(m_new, M_DONTWAIT, MT_DATA);
- if (m_new == NULL) {
- printf("sf%d: no memory for tx list", sc->sf_unit);
- return(1);
- }
-
- if (m_head->m_pkthdr.len > MHLEN) {
- MCLGET(m_new, M_DONTWAIT);
- if (!(m_new->m_flags & M_EXT)) {
- m_freem(m_new);
- printf("sf%d: no memory for tx list",
- sc->sf_unit);
- return(1);
- }
- }
- m_copydata(m_head, 0, m_head->m_pkthdr.len,
- mtod(m_new, caddr_t));
- m_new->m_pkthdr.len = m_new->m_len = m_head->m_pkthdr.len;
- m_freem(m_head);
- m_head = m_new;
- f = &c->sf_frags[0];
- f->sf_fraglen = f->sf_pktlen = m_head->m_pkthdr.len;
- f->sf_addr = vtophys(mtod(m_head, caddr_t));
- frag = 1;
- }
-
- c->sf_mbuf = m_head;
- c->sf_id = SF_TX_BUFDESC_ID;
- c->sf_fragcnt = frag;
- c->sf_intr = 1;
- c->sf_caltcp = 0;
- c->sf_crcen = 1;
-
- return(0);
-}
-
-static void sf_start(ifp)
- struct ifnet *ifp;
-{
- struct sf_softc *sc;
- struct sf_tx_bufdesc_type0 *cur_tx = NULL;
- struct mbuf *m_head = NULL;
- int i, txprod;
-
- sc = ifp->if_softc;
-
- if (!sc->sf_link)
- return;
-
- if (ifp->if_flags & IFF_OACTIVE)
- return;
-
- txprod = csr_read_4(sc, SF_TXDQ_PRODIDX);
- i = SF_IDX_HI(txprod) >> 4;
-
- while(sc->sf_ldata->sf_tx_dlist[i].sf_mbuf == NULL) {
- IF_DEQUEUE(&ifp->if_snd, m_head);
- if (m_head == NULL)
- break;
-
- cur_tx = &sc->sf_ldata->sf_tx_dlist[i];
- sf_encap(sc, cur_tx, m_head);
-
- /*
- * If there's a BPF listener, bounce a copy of this frame
- * to him.
- */
- if (ifp->if_bpf)
- bpf_mtap(ifp, m_head);
-
- SF_INC(i, SF_TX_DLIST_CNT);
- sc->sf_tx_cnt++;
- if (sc->sf_tx_cnt == (SF_TX_DLIST_CNT - 2))
- break;
- }
-
- if (cur_tx == NULL)
- return;
-
- /* Transmit */
- csr_write_4(sc, SF_TXDQ_PRODIDX,
- (txprod & ~SF_TXDQ_PRODIDX_HIPRIO) |
- ((i << 20) & 0xFFFF0000));
-
- ifp->if_timer = 5;
-
- return;
-}
-
-static void sf_stop(sc)
- struct sf_softc *sc;
-{
- int i;
- struct ifnet *ifp;
-
- ifp = &sc->arpcom.ac_if;
-
- untimeout(sf_stats_update, sc, sc->sf_stat_ch);
-
- csr_write_4(sc, SF_GEN_ETH_CTL, 0);
- csr_write_4(sc, SF_CQ_CONSIDX, 0);
- csr_write_4(sc, SF_CQ_PRODIDX, 0);
- csr_write_4(sc, SF_RXDQ_ADDR_Q1, 0);
- csr_write_4(sc, SF_RXDQ_CTL_1, 0);
- csr_write_4(sc, SF_RXDQ_PTR_Q1, 0);
- csr_write_4(sc, SF_TXCQ_CTL, 0);
- csr_write_4(sc, SF_TXDQ_ADDR_HIPRIO, 0);
- csr_write_4(sc, SF_TXDQ_CTL, 0);
- sf_reset(sc);
-
- sc->sf_link = 0;
-
- for (i = 0; i < SF_RX_DLIST_CNT; i++) {
- if (sc->sf_ldata->sf_rx_dlist_big[i].sf_mbuf != NULL) {
- m_freem(sc->sf_ldata->sf_rx_dlist_big[i].sf_mbuf);
- sc->sf_ldata->sf_rx_dlist_big[i].sf_mbuf = NULL;
- }
- }
-
- for (i = 0; i < SF_TX_DLIST_CNT; i++) {
- if (sc->sf_ldata->sf_tx_dlist[i].sf_mbuf != NULL) {
- m_freem(sc->sf_ldata->sf_tx_dlist[i].sf_mbuf);
- sc->sf_ldata->sf_tx_dlist[i].sf_mbuf = NULL;
- }
- }
-
- ifp->if_flags &= ~(IFF_RUNNING|IFF_OACTIVE);
-
- return;
-}
-
-/*
- * Note: it is important that this function not be interrupted. We
- * use a two-stage register access scheme: if we are interrupted in
- * between setting the indirect address register and reading from the
- * indirect data register, the contents of the address register could
- * be changed out from under us.
- */
-static void sf_stats_update(xsc)
- void *xsc;
-{
- struct sf_softc *sc;
- struct ifnet *ifp;
- struct mii_data *mii;
- struct sf_stats stats;
- u_int32_t *ptr;
- int i, s;
-
- s = splimp();
-
- sc = xsc;
- ifp = &sc->arpcom.ac_if;
- mii = device_get_softc(sc->sf_miibus);
-
- ptr = (u_int32_t *)&stats;
- for (i = 0; i < sizeof(stats)/sizeof(u_int32_t); i++)
- ptr[i] = csr_read_4(sc, SF_STATS_BASE +
- (i + sizeof(u_int32_t)));
-
- for (i = 0; i < sizeof(stats)/sizeof(u_int32_t); i++)
- csr_write_4(sc, SF_STATS_BASE +
- (i + sizeof(u_int32_t)), 0);
-
- ifp->if_collisions += stats.sf_tx_single_colls +
- stats.sf_tx_multi_colls + stats.sf_tx_excess_colls;
-
- mii_tick(mii);
- if (!sc->sf_link) {
- mii_pollstat(mii);
- if (mii->mii_media_status & IFM_ACTIVE &&
- IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE)
- sc->sf_link++;
- if (ifp->if_snd.ifq_head != NULL)
- sf_start(ifp);
- }
-
- sc->sf_stat_ch = timeout(sf_stats_update, sc, hz);
-
- splx(s);
-
- return;
-}
-
-static void sf_watchdog(ifp)
- struct ifnet *ifp;
-{
- struct sf_softc *sc;
-
- sc = ifp->if_softc;
-
- ifp->if_oerrors++;
- printf("sf%d: watchdog timeout\n", sc->sf_unit);
-
- sf_stop(sc);
- sf_reset(sc);
- sf_init(sc);
-
- if (ifp->if_snd.ifq_head != NULL)
- sf_start(ifp);
-
- return;
-}
-
-static void sf_shutdown(dev)
- device_t dev;
-{
- struct sf_softc *sc;
-
- sc = device_get_softc(dev);
-
- sf_stop(sc);
-
- return;
-}
diff --git a/sys/dev/sf/if_sfreg.h b/sys/dev/sf/if_sfreg.h
deleted file mode 100644
index 49fdd5ae1afc..000000000000
--- a/sys/dev/sf/if_sfreg.h
+++ /dev/null
@@ -1,1054 +0,0 @@
-/*
- * Copyright (c) 1997, 1998, 1999
- * Bill Paul <wpaul@ctr.columbia.edu>. 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 Bill Paul.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY Bill Paul 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 Bill Paul OR THE VOICES IN HIS HEAD
- * 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Registers for the Adaptec AIC-6915 Starfire. The Starfire has a 512K
- * register space. These registers can be accessed in the following way:
- * - PCI config registers are always accessible through PCI config space
- * - Full 512K space mapped into memory using PCI memory mapped access
- * - 256-byte I/O space mapped through PCI I/O access
- * - Full 512K space mapped through indirect I/O using PCI I/O access
- * It's possible to use either memory mapped mode or I/O mode to access
- * the registers, but memory mapped is usually the easiest. All registers
- * are 32 bits wide and must be accessed using 32-bit operations.
- */
-
-/*
- * Adaptec PCI vendor ID.
- */
-#define AD_VENDORID 0x9004
-
-/*
- * AIC-6915 PCI device ID.
- */
-#define AD_DEVICEID_STARFIRE 0x6915
-
-/*
- * AIC-6915 subsystem IDs. Adaptec uses the subsystem ID to identify
- * the exact kind of NIC on which the ASIC is mounted. Currently there
- * are six different variations. Note: the Adaptec manual lists code 0x28
- * for two different NICs: the 62044 and the 69011/TX. This is a typo:
- * the code for the 62044 is really 0x18.
- *
- * Note that there also appears to be an 0x19 code for a newer rev
- * 62044 card.
- */
-#define AD_SUBSYSID_62011_REV0 0x0008 /* single port 10/100baseTX 64-bit */
-#define AD_SUBSYSID_62011_REV1 0x0009 /* single port 10/100baseTX 64-bit */
-#define AD_SUBSYSID_62022 0x0010 /* dual port 10/100baseTX 64-bit */
-#define AD_SUBSYSID_62044_REV0 0x0018 /* quad port 10/100baseTX 64-bit */
-#define AD_SUBSYSID_62044_REV1 0x0019 /* quad port 10/100baseTX 64-bit */
-#define AD_SUBSYSID_62020 0x0020 /* single port 10/100baseFX 64-bit */
-#define AD_SUBSYSID_69011 0x0028 /* single port 10/100baseTX 32-bit */
-
-/*
- * Starfire internal register space map. The entire register space
- * is available using PCI memory mapped mode. The SF_RMAP_INTREG
- * space is available using PCI I/O mode. The entire space can be
- * accessed using indirect I/O using the indirect I/O addr and
- * indirect I/O data registers located within the SF_RMAP_INTREG space.
- */
-#define SF_RMAP_ROMADDR_BASE 0x00000 /* Expansion ROM space */
-#define SF_RMAP_ROMADDR_MAX 0x3FFFF
-
-#define SF_RMAP_EXGPIO_BASE 0x40000 /* External general purpose regs */
-#define SF_RMAP_EXGPIO_MAX 0x3FFFF
-
-#define SF_RMAP_INTREG_BASE 0x50000 /* Internal functional registers */
-#define SF_RMAP_INTREG_MAX 0x500FF
-#define SF_RMAP_GENREG_BASE 0x50100 /* General purpose registers */
-#define SF_RMAP_GENREG_MAX 0x5FFFF
-
-#define SF_RMAP_FIFO_BASE 0x60000
-#define SF_RMAP_FIFO_MAX 0x6FFFF
-
-#define SF_RMAP_STS_BASE 0x70000
-#define SF_RMAP_STS_MAX 0x70083
-
-#define SF_RMAP_RSVD_BASE 0x70084
-#define SF_RMAP_RSVD_MAX 0x7FFFF
-
-/*
- * PCI config header registers, 0x0000 to 0x003F
- */
-#define SF_PCI_VENDOR_ID 0x0000
-#define SF_PCI_DEVICE_ID 0x0002
-#define SF_PCI_COMMAND 0x0004
-#define SF_PCI_STATUS 0x0006
-#define SF_PCI_REVID 0x0008
-#define SF_PCI_CLASSCODE 0x0009
-#define SF_PCI_CACHELEN 0x000C
-#define SF_PCI_LATENCY_TIMER 0x000D
-#define SF_PCI_HEADER_TYPE 0x000E
-#define SF_PCI_LOMEM 0x0010
-#define SF_PCI_LOIO 0x0014
-#define SF_PCI_SUBVEN_ID 0x002C
-#define SF_PCI_SYBSYS_ID 0x002E
-#define SF_PCI_BIOSROM 0x0030
-#define SF_PCI_INTLINE 0x003C
-#define SF_PCI_INTPIN 0x003D
-#define SF_PCI_MINGNT 0x003E
-#define SF_PCI_MINLAT 0x003F
-
-/*
- * PCI registers, 0x0040 to 0x006F
- */
-#define SF_PCI_DEVCFG 0x0040
-#define SF_BACCTL 0x0044
-#define SF_PCI_MON1 0x0048
-#define SF_PCI_MON2 0x004C
-#define SF_PCI_CAPID 0x0050 /* 8 bits */
-#define SF_PCI_NEXTPTR 0x0051 /* 8 bits */
-#define SF_PCI_PWRMGMTCAP 0x0052 /* 16 bits */
-#define SF_PCI_PWRMGMTCTRL 0x0054 /* 16 bits */
-#define SF_PCI_PME_EVENT 0x0058
-#define SF_PCI_EECTL 0x0060
-#define SF_PCI_COMPLIANCE 0x0064
-#define SF_INDIRECTIO_ADDR 0x0068
-#define SF_INDIRECTIO_DATA 0x006C
-
-#define SF_PCIDEVCFG_RESET 0x00000001
-#define SF_PCIDEVCFG_FORCE64 0x00000002
-#define SF_PCIDEVCFG_SYSTEM64 0x00000004
-#define SF_PCIDEVCFG_RSVD0 0x00000008
-#define SF_PCIDEVCFG_INCR_INB 0x00000010
-#define SF_PCIDEVCFG_ABTONPERR 0x00000020
-#define SF_PCIDEVCFG_STPONPERR 0x00000040
-#define SF_PCIDEVCFG_MR_ENB 0x00000080
-#define SF_PCIDEVCFG_FIFOTHR 0x00000F00
-#define SF_PCIDEVCFG_STPONCA 0x00001000
-#define SF_PCIDEVCFG_PCIMEN 0x00002000 /* enable PCI bus master */
-#define SF_PCIDEVCFG_LATSTP 0x00004000
-#define SF_PCIDEVCFG_BYTE_ENB 0x00008000
-#define SF_PCIDEVCFG_EECSWIDTH 0x00070000
-#define SF_PCIDEVCFG_STPMWCA 0x00080000
-#define SF_PCIDEVCFG_REGCSWIDTH 0x00700000
-#define SF_PCIDEVCFG_INTR_ENB 0x00800000
-#define SF_PCIDEVCFG_DPR_ENB 0x01000000
-#define SF_PCIDEVCFG_RSVD1 0x02000000
-#define SF_PCIDEVCFG_RSVD2 0x04000000
-#define SF_PCIDEVCFG_STA_ENB 0x08000000
-#define SF_PCIDEVCFG_RTA_ENB 0x10000000
-#define SF_PCIDEVCFG_RMA_ENB 0x20000000
-#define SF_PCIDEVCFG_SSE_ENB 0x40000000
-#define SF_PCIDEVCFG_DPE_ENB 0x80000000
-
-#define SF_BACCTL_BACDMA_ENB 0x00000001
-#define SF_BACCTL_PREFER_RXDMA 0x00000002
-#define SF_BACCTL_PREFER_TXDMA 0x00000004
-#define SF_BACCTL_SINGLE_DMA 0x00000008
-#define SF_BACCTL_SWAPMODE_DATA 0x00000030
-#define SF_BACCTL_SWAPMODE_DESC 0x000000C0
-
-#define SF_SWAPMODE_LE 0x00000000
-#define SF_SWAPMODE_BE 0x00000010
-
-#define SF_PSTATE_MASK 0x0003
-#define SF_PSTATE_D0 0x0000
-#define SF_PSTATE_D1 0x0001
-#define SF_PSTATE_D2 0x0002
-#define SF_PSTATE_D3 0x0003
-#define SF_PME_EN 0x0010
-#define SF_PME_STATUS 0x8000
-
-
-/*
- * Ethernet registers 0x0070 to 0x00FF
- */
-#define SF_GEN_ETH_CTL 0x0070
-#define SF_TIMER_CTL 0x0074
-#define SF_CURTIME 0x0078
-#define SF_ISR 0x0080
-#define SF_ISR_SHADOW 0x0084
-#define SF_IMR 0x0088
-#define SF_GPIO 0x008C
-#define SF_TXDQ_CTL 0x0090
-#define SF_TXDQ_ADDR_HIPRIO 0x0094
-#define SF_TXDQ_ADDR_LOPRIO 0x0098
-#define SF_TXDQ_ADDR_HIADDR 0x009C
-#define SF_TXDQ_PRODIDX 0x00A0
-#define SF_TXDQ_CONSIDX 0x00A4
-#define SF_TXDMA_STS1 0x00A8
-#define SF_TXDMA_STS2 0x00AC
-#define SF_TX_FRAMCTL 0x00B0
-#define SF_TXCQ_ADDR_HI 0x00B4
-#define SF_TXCQ_CTL 0x00B8
-#define SF_RXCQ_CTL_1 0x00BC
-#define SF_RXCQ_CTL_2 0x00C0
-#define SF_CQ_CONSIDX 0x00C4
-#define SF_CQ_PRODIDX 0x00C8
-#define SF_CQ_RXQ2 0x00CC
-#define SF_RXDMA_CTL 0x00D0
-#define SF_RXDQ_CTL_1 0x00D4
-#define SF_RXDQ_CTL_2 0x00D8
-#define SF_RXDQ_ADDR_HIADDR 0x00DC
-#define SF_RXDQ_ADDR_Q1 0x00E0
-#define SF_RXDQ_ADDR_Q2 0x00E4
-#define SF_RXDQ_PTR_Q1 0x00E8
-#define SF_RXDQ_PTR_Q2 0x00EC
-#define SF_RXDMA_STS 0x00F0
-#define SF_RXFILT 0x00F4
-#define SF_RX_FRAMETEST_OUT 0x00F8
-
-/* Ethernet control register */
-#define SF_ETHCTL_RX_ENB 0x00000001
-#define SF_ETHCTL_TX_ENB 0x00000002
-#define SF_ETHCTL_RXDMA_ENB 0x00000004
-#define SF_ETHCTL_TXDMA_ENB 0x00000008
-#define SF_ETHCTL_RXGFP_ENB 0x00000010
-#define SF_ETHCTL_TXGFP_ENB 0x00000020
-#define SF_ETHCTL_SOFTINTR 0x00000800
-
-/* Timer control register */
-#define SF_TIMER_IMASK_INTERVAL 0x0000001F
-#define SF_TIMER_IMASK_MODE 0x00000060
-#define SF_TIMER_SMALLFRAME_BYP 0x00000100
-#define SF_TIMER_SMALLRX_FRAME 0x00000600
-#define SF_TIMER_TIMES_TEN 0x00000800
-#define SF_TIMER_RXHIPRIO_BYP 0x00001000
-#define SF_TIMER_TX_DMADONE_DLY 0x00002000
-#define SF_TIMER_TX_QDONE_DLY 0x00004000
-#define SF_TIMER_TX_FRDONE_DLY 0x00008000
-#define SF_TIMER_GENTIMER 0x00FF0000
-#define SF_TIMER_ONESHOT 0x01000000
-#define SF_TIMER_GENTIMER_RES 0x02000000
-#define SF_TIMER_TIMEST_RES 0x04000000
-#define SF_TIMER_RXQ2DONE_DLY 0x10000000
-#define SF_TIMER_EARLYRX2_DLY 0x20000000
-#define SF_TIMER_RXQ1DONE_DLY 0x40000000
-#define SF_TIMER_EARLYRX1_DLY 0x80000000
-
-/* Interrupt status register */
-#define SF_ISR_PCIINT_ASSERTED 0x00000001
-#define SF_ISR_GFP_TX 0x00000002
-#define SF_ISR_GFP_RX 0x00000004
-#define SF_ISR_TX_BADID_HIPRIO 0x00000008
-#define SF_ISR_TX_BADID_LOPRIO 0x00000010
-#define SF_ISR_NO_TX_CSUM 0x00000020
-#define SF_ISR_RXDQ2_NOBUFS 0x00000040
-#define SF_ISR_RXGFP_NORESP 0x00000080
-#define SF_ISR_RXDQ1_DMADONE 0x00000100
-#define SF_ISR_RXDQ2_DMADONE 0x00000200
-#define SF_ISR_RXDQ1_EARLY 0x00000400
-#define SF_ISR_RXDQ2_EARLY 0x00000800
-#define SF_ISR_TX_QUEUEDONE 0x00001000
-#define SF_ISR_TX_DMADONE 0x00002000
-#define SF_ISR_TX_TXDONE 0x00004000
-#define SF_ISR_NORMALINTR 0x00008000
-#define SF_ISR_RXDQ1_NOBUFS 0x00010000
-#define SF_ISR_RXCQ2_NOBUFS 0x00020000
-#define SF_ISR_TX_LOFIFO 0x00040000
-#define SF_ISR_DMAERR 0x00080000
-#define SF_ISR_PCIINT 0x00100000
-#define SF_ISR_TXCQ_NOBUFS 0x00200000
-#define SF_ISR_RXCQ1_NOBUFS 0x00400000
-#define SF_ISR_SOFTINTR 0x00800000
-#define SF_ISR_GENTIMER 0x01000000
-#define SF_ISR_ABNORMALINTR 0x02000000
-#define SF_ISR_RSVD0 0x04000000
-#define SF_ISR_STATSOFLOW 0x08000000
-#define SF_ISR_GPIO 0xF0000000
-
-/*
- * Shadow interrupt status register. Unlike the normal IRQ register,
- * reading bits here does not automatically cause them to reset.
- */
-#define SF_SISR_PCIINT_ASSERTED 0x00000001
-#define SF_SISR_GFP_TX 0x00000002
-#define SF_SISR_GFP_RX 0x00000004
-#define SF_SISR_TX_BADID_HIPRIO 0x00000008
-#define SF_SISR_TX_BADID_LOPRIO 0x00000010
-#define SF_SISR_NO_TX_CSUM 0x00000020
-#define SF_SISR_RXDQ2_NOBUFS 0x00000040
-#define SF_SISR_RXGFP_NORESP 0x00000080
-#define SF_SISR_RXDQ1_DMADONE 0x00000100
-#define SF_SISR_RXDQ2_DMADONE 0x00000200
-#define SF_SISR_RXDQ1_EARLY 0x00000400
-#define SF_SISR_RXDQ2_EARLY 0x00000800
-#define SF_SISR_TX_QUEUEDONE 0x00001000
-#define SF_SISR_TX_DMADONE 0x00002000
-#define SF_SISR_TX_TXDONE 0x00004000
-#define SF_SISR_NORMALINTR 0x00008000
-#define SF_SISR_RXDQ1_NOBUFS 0x00010000
-#define SF_SISR_RXCQ2_NOBUFS 0x00020000
-#define SF_SISR_TX_LOFIFO 0x00040000
-#define SF_SISR_DMAERR 0x00080000
-#define SF_SISR_PCIINT 0x00100000
-#define SF_SISR_TXCQ_NOBUFS 0x00200000
-#define SF_SISR_RXCQ1_NOBUFS 0x00400000
-#define SF_SISR_SOFTINTR 0x00800000
-#define SF_SISR_GENTIMER 0x01000000
-#define SF_SISR_ABNORMALINTR 0x02000000
-#define SF_SISR_RSVD0 0x04000000
-#define SF_SISR_STATSOFLOW 0x08000000
-#define SF_SISR_GPIO 0xF0000000
-
-/* Interrupt mask register */
-#define SF_IMR_PCIINT_ASSERTED 0x00000001
-#define SF_IMR_GFP_TX 0x00000002
-#define SF_IMR_GFP_RX 0x00000004
-#define SF_IMR_TX_BADID_HIPRIO 0x00000008
-#define SF_IMR_TX_BADID_LOPRIO 0x00000010
-#define SF_IMR_NO_TX_CSUM 0x00000020
-#define SF_IMR_RXDQ2_NOBUFS 0x00000040
-#define SF_IMR_RXGFP_NORESP 0x00000080
-#define SF_IMR_RXDQ1_DMADONE 0x00000100
-#define SF_IMR_RXDQ2_DMADONE 0x00000200
-#define SF_IMR_RXDQ1_EARLY 0x00000400
-#define SF_IMR_RXDQ2_EARLY 0x00000800
-#define SF_IMR_TX_QUEUEDONE 0x00001000
-#define SF_IMR_TX_DMADONE 0x00002000
-#define SF_IMR_TX_TXDONE 0x00004000
-#define SF_IMR_NORMALINTR 0x00008000
-#define SF_IMR_RXDQ1_NOBUFS 0x00010000
-#define SF_IMR_RXCQ2_NOBUFS 0x00020000
-#define SF_IMR_TX_LOFIFO 0x00040000
-#define SF_IMR_DMAERR 0x00080000
-#define SF_IMR_PCIINT 0x00100000
-#define SF_IMR_TXCQ_NOBUFS 0x00200000
-#define SF_IMR_RXCQ1_NOBUFS 0x00400000
-#define SF_IMR_SOFTINTR 0x00800000
-#define SF_IMR_GENTIMER 0x01000000
-#define SF_IMR_ABNORMALINTR 0x02000000
-#define SF_IMR_RSVD0 0x04000000
-#define SF_IMR_STATSOFLOW 0x08000000
-#define SF_IMR_GPIO 0xF0000000
-
-#define SF_INTRS \
- (SF_IMR_RXDQ2_NOBUFS|SF_IMR_RXDQ1_DMADONE|SF_IMR_RXDQ2_DMADONE| \
- SF_IMR_TX_TXDONE|SF_IMR_RXDQ1_NOBUFS|SF_IMR_RXDQ2_DMADONE| \
- SF_IMR_NORMALINTR|SF_IMR_ABNORMALINTR|SF_IMR_TXCQ_NOBUFS| \
- SF_IMR_RXCQ1_NOBUFS|SF_IMR_RXCQ2_NOBUFS|SF_IMR_STATSOFLOW)
-
-/* TX descriptor queue control registers */
-#define SF_TXDQCTL_DESCTYPE 0x00000007
-#define SF_TXDQCTL_NODMACMP 0x00000008
-#define SF_TXDQCTL_MINSPACE 0x00000070
-#define SF_TXDQCTL_64BITADDR 0x00000080
-#define SF_TXDQCTL_BURSTLEN 0x00003F00
-#define SF_TXDQCTL_SKIPLEN 0x001F0000
-#define SF_TXDQCTL_HIPRIOTHRESH 0xFF000000
-
-#define SF_TXBUFDESC_TYPE0 0x00000000
-#define SF_TXBUFDESC_TYPE1 0x00000001
-#define SF_TXBUFDESC_TYPE2 0x00000002
-#define SF_TXBUFDESC_TYPE3 0x00000003
-#define SF_TXBUFDESC_TYPE4 0x00000004
-
-#define SF_TXMINSPACE_UNLIMIT 0x00000000
-#define SF_TXMINSPACE_32BYTES 0x00000010
-#define SF_TXMINSPACE_64BYTES 0x00000020
-#define SF_TXMINSPACE_128BYTES 0x00000030
-#define SF_TXMINSPACE_256BYTES 0x00000040
-
-#define SF_TXSKIPLEN_0BYTES 0x00000000
-#define SF_TXSKIPLEN_8BYTES 0x00010000
-#define SF_TXSKIPLEN_16BYTES 0x00020000
-#define SF_TXSKIPLEN_24BYTES 0x00030000
-#define SF_TXSKIPLEN_32BYTES 0x00040000
-
-/* TX frame control register */
-#define SF_TXFRMCTL_TXTHRESH 0x000000FF
-#define SF_TXFRMCTL_CPLAFTERTX 0x00000100
-#define SF_TXFRMCRL_DEBUG 0x0000FE00
-#define SF_TXFRMCTL_STATUS 0x01FF0000
-#define SF_TXFRMCTL_MAC_TXIF 0xFE000000
-
-/* TX completion queue control register */
-#define SF_TXCQ_THRESH 0x0000000F
-#define SF_TXCQ_COMMON 0x00000010
-#define SF_TXCQ_SIZE 0x00000020
-#define SF_TXCQ_WRITEENB 0x00000040
-#define SF_TXCQ_USE_64BIT 0x00000080
-#define SF_TXCQ_ADDR 0xFFFFFF00
-
-/* RX completion queue control register */
-#define SF_RXCQ_THRESH 0x0000000F
-#define SF_RXCQ_TYPE 0x00000030
-#define SF_RXCQ_WRITEENB 0x00000040
-#define SF_RXCQ_USE_64BIT 0x00000080
-#define SF_RXCQ_ADDR 0xFFFFFF00
-
-#define SF_RXCQTYPE_0 0x00000000
-#define SF_RXCQTYPE_1 0x00000010
-#define SF_RXCQTYPE_2 0x00000020
-#define SF_RXCQTYPE_3 0x00000030
-
-/* TX descriptor queue producer index register */
-#define SF_TXDQ_PRODIDX_LOPRIO 0x000007FF
-#define SF_TXDQ_PRODIDX_HIPRIO 0x07FF0000
-
-/* TX descriptor queue consumer index register */
-#define SF_TXDQ_CONSIDX_LOPRIO 0x000007FF
-#define SF_TXDQ_CONSIDX_HIPRIO 0x07FF0000
-
-/* Completion queue consumer index register */
-#define SF_CQ_CONSIDX_RXQ1 0x000003FF
-#define SF_CQ_CONSIDX_RXTHRMODE 0x00008000
-#define SF_CQ_CONSIDX_TXQ 0x03FF0000
-#define SF_CQ_CONSIDX_TXTHRMODE 0x80000000
-
-/* Completion queue producer index register */
-#define SF_CQ_PRODIDX_RXQ1 0x000003FF
-#define SF_CQ_PRODIDX_TXQ 0x03FF0000
-
-/* RX completion queue 2 consumer/producer index register */
-#define SF_CQ_RXQ2_CONSIDX 0x000003FF
-#define SF_CQ_RXQ2_RXTHRMODE 0x00008000
-#define SF_CQ_RXQ2_PRODIDX 0x03FF0000
-
-#define SF_CQ_RXTHRMODE_INT_ON 0x00008000
-#define SF_CQ_RXTHRMODE_INT_OFF 0x00000000
-#define SF_CQ_TXTHRMODE_INT_ON 0x80000000
-#define SF_CQ_TXTHRMODE_INT_OFF 0x00000000
-
-#define SF_IDX_LO(x) ((x) & 0x000007FF)
-#define SF_IDX_HI(x) (((x) >> 16) & 0x000007FF)
-
-/* RX DMA control register */
-#define SF_RXDMA_BURSTSIZE 0x0000007F
-#define SF_RXDMA_FPTESTMODE 0x00000080
-#define SF_RXDMA_HIPRIOTHRESH 0x00000F00
-#define SF_RXDMA_RXEARLYTHRESH 0x0001F000
-#define SF_RXDMA_DMACRC 0x00040000
-#define SF_RXDMA_USEBKUPQUEUE 0x00080000
-#define SF_RXDMA_QUEUEMODE 0x00700000
-#define SF_RXDMA_RXCQ2_ON 0x00800000
-#define SF_RXDMA_CSUMMODE 0x03000000
-#define SF_RXDMA_DMAPAUSEPKTS 0x04000000
-#define SF_RXDMA_DMACTLPKTS 0x08000000
-#define SF_RXDMA_DMACRXERRPKTS 0x10000000
-#define SF_RXDMA_DMABADPKTS 0x20000000
-#define SF_RXDMA_DMARUNTS 0x40000000
-#define SF_RXDMA_REPORTBADPKTS 0x80000000
-
-#define SF_RXDQMODE_Q1ONLY 0x00100000
-#define SF_RXDQMODE_Q2_ON_FP 0x00200000
-#define SF_RXDQMODE_Q2_ON_SHORT 0x00300000
-#define SF_RXDQMODE_Q2_ON_PRIO 0x00400000
-#define SF_RXDQMODE_SPLITHDR 0x00500000
-
-#define SF_RXCSUMMODE_IGNORE 0x00000000
-#define SF_RXCSUMMODE_REJECT_BAD_TCP 0x01000000
-#define SF_RXCSUMMODE_REJECT_BAD_TCPUDP 0x02000000
-#define SF_RXCSUMMODE_RSVD 0x03000000
-
-/* RX descriptor queue control registers */
-#define SF_RXDQCTL_MINDESCTHR 0x0000007F
-#define SF_RXDQCTL_Q1_WE 0x00000080
-#define SF_RXDQCTL_DESCSPACE 0x00000700
-#define SF_RXDQCTL_64BITDADDR 0x00000800
-#define SF_RXDQCTL_64BITBADDR 0x00001000
-#define SF_RXDQCTL_VARIABLE 0x00002000
-#define SF_RXDQCTL_ENTRIES 0x00004000
-#define SF_RXDQCTL_PREFETCH 0x00008000
-#define SF_RXDQCTL_BUFLEN 0xFFFF0000
-
-#define SF_DESCSPACE_4BYTES 0x00000000
-#define SF_DESCSPACE_8BYTES 0x00000100
-#define SF_DESCSPACE_16BYTES 0x00000200
-#define SF_DESCSPACE_32BYTES 0x00000300
-#define SF_DESCSPACE_64BYTES 0x00000400
-#define SF_DESCSPACE_128_BYTES 0x00000500
-
-/* RX buffer consumer/producer index registers */
-#define SF_RXDQ_PRODIDX 0x000007FF
-#define SF_RXDQ_CONSIDX 0x07FF0000
-
-/* RX filter control register */
-#define SF_RXFILT_PROMISC 0x00000001
-#define SF_RXFILT_ALLMULTI 0x00000002
-#define SF_RXFILT_BROAD 0x00000004
-#define SF_RXFILT_HASHPRIO 0x00000008
-#define SF_RXFILT_HASHMODE 0x00000030
-#define SF_RXFILT_PERFMODE 0x000000C0
-#define SF_RXFILT_VLANMODE 0x00000300
-#define SF_RXFILT_WAKEMODE 0x00000C00
-#define SF_RXFILT_MULTI_NOBROAD 0x00001000
-#define SF_RXFILT_MIN_VLANPRIO 0x0000E000
-#define SF_RXFILT_PEFECTPRIO 0xFFFF0000
-
-/* Hash filtering mode */
-#define SF_HASHMODE_OFF 0x00000000
-#define SF_HASHMODE_WITHVLAN 0x00000010
-#define SF_HASHMODE_ANYVLAN 0x00000020
-#define SF_HASHMODE_ANY 0x00000030
-
-/* Perfect filtering mode */
-#define SF_PERFMODE_OFF 0x00000000
-#define SF_PERFMODE_NORMAL 0x00000040
-#define SF_PERFMODE_INVERSE 0x00000080
-#define SF_PERFMODE_VLAN 0x000000C0
-
-/* VLAN mode */
-#define SF_VLANMODE_OFF 0x00000000
-#define SF_VLANMODE_NOSTRIP 0x00000100
-#define SF_VLANMODE_STRIP 0x00000200
-#define SF_VLANMODE_RSVD 0x00000300
-
-/* Wakeup mode */
-#define SF_WAKEMODE_OFF 0x00000000
-#define SF_WAKEMODE_FILTER 0x00000400
-#define SF_WAKEMODE_FP 0x00000800
-#define SF_WAKEMODE_HIPRIO 0x00000C00
-
-/*
- * Extra PCI registers 0x0100 to 0x0FFF
- */
-#define SF_PCI_TARGSTAT 0x0100
-#define SF_PCI_MASTSTAT1 0x0104
-#define SF_PCI_MASTSTAT2 0x0108
-#define SF_PCI_DMAHOSTADDR_LO 0x010C
-#define SF_BAC_DMADIAG0 0x0110
-#define SF_BAC_DMADIAG1 0x0114
-#define SF_BAC_DMADIAG2 0x0118
-#define SF_BAC_DMADIAG3 0x011C
-#define SF_PAR0 0x0120
-#define SF_PAR1 0x0124
-#define SF_PCICB_FUNCEVENT 0x0130
-#define SF_PCICB_FUNCEVENT_MASK 0x0134
-#define SF_PCICB_FUNCSTATE 0x0138
-#define SF_PCICB_FUNCFORCE 0x013C
-
-/*
- * Serial EEPROM registers 0x1000 to 0x1FFF
- * Presumeably the EEPROM is mapped into this 8K window.
- */
-#define SF_EEADDR_BASE 0x1000
-#define SF_EEADDR_MAX 0x1FFF
-
-#define SF_EE_NODEADDR 14
-
-/*
- * MII registers registers 0x2000 to 0x3FFF
- * There are 32 sets of 32 registers, one set for each possible
- * PHY address. Each 32 bit register is split into a 16-bit data
- * port and a couple of status bits.
- */
-
-#define SF_MIIADDR_BASE 0x2000
-#define SF_MIIADDR_MAX 0x3FFF
-#define SF_MII_BLOCKS 32
-
-#define SF_MII_DATAVALID 0x80000000
-#define SF_MII_BUSY 0x40000000
-#define SF_MII_DATAPORT 0x0000FFFF
-
-#define SF_PHY_REG(phy, reg) \
- (SF_MIIADDR_BASE + (phy * SF_MII_BLOCKS * sizeof(u_int32_t)) + \
- (reg * sizeof(u_int32_t)))
-
-/*
- * Ethernet extra registers 0x4000 to 0x4FFF
- */
-#define SF_TESTMODE 0x4000
-#define SF_RX_FRAMEPROC_CTL 0x4004
-#define SF_TX_FRAMEPROC_CTL 0x4008
-
-/*
- * MAC registers 0x5000 to 0x5FFF
- */
-#define SF_MACCFG_1 0x5000
-#define SF_MACCFG_2 0x5004
-#define SF_BKTOBKIPG 0x5008
-#define SF_NONBKTOBKIPG 0x500C
-#define SF_COLRETRY 0x5010
-#define SF_MAXLEN 0x5014
-#define SF_TXNIBBLECNT 0x5018
-#define SF_TXBYTECNT 0x501C
-#define SF_RETXCNT 0x5020
-#define SF_RANDNUM 0x5024
-#define SF_RANDNUM_MASK 0x5028
-#define SF_TOTALTXCNT 0x5034
-#define SF_RXBYTECNT 0x5040
-#define SF_TXPAUSETIMER 0x5060
-#define SF_VLANTYPE 0x5064
-#define SF_MIISTATUS 0x5070
-
-#define SF_MACCFG1_HUGEFRAMES 0x00000001
-#define SF_MACCFG1_FULLDUPLEX 0x00000002
-#define SF_MACCFG1_AUTOPAD 0x00000004
-#define SF_MACCFG1_HDJAM 0x00000008
-#define SF_MACCFG1_DELAYCRC 0x00000010
-#define SF_MACCFG1_NOBACKOFF 0x00000020
-#define SF_MACCFG1_LENGTHCHECK 0x00000040
-#define SF_MACCFG1_PUREPREAMBLE 0x00000080
-#define SF_MACCFG1_PASSALLRX 0x00000100
-#define SF_MACCFG1_PREAM_DETCNT 0x00000200
-#define SF_MACCFG1_RX_FLOWENB 0x00000400
-#define SF_MACCFG1_TX_FLOWENB 0x00000800
-#define SF_MACCFG1_TESTMODE 0x00003000
-#define SF_MACCFG1_MIILOOPBK 0x00004000
-#define SF_MACCFG1_SOFTRESET 0x00008000
-
-/*
- * There are the recommended IPG nibble counter settings
- * specified in the Adaptec manual for full duplex and
- * half duplex operation.
- */
-#define SF_IPGT_FDX 0x15
-#define SF_IPGT_HDX 0x11
-
-/*
- * RX filter registers 0x6000 to 0x6FFF
- */
-#define SF_RXFILT_PERFECT_BASE 0x6000
-#define SF_RXFILT_PERFECT_MAX 0x60FF
-#define SF_RXFILT_PERFECT_SKIP 0x0010
-#define SF_RXFILT_PERFECT_CNT 0x0010
-
-#define SF_RXFILT_HASH_BASE 0x6100
-#define SF_RXFILT_HASH_MAX 0x62FF
-#define SF_RXFILT_HASH_SKIP 0x0010
-#define SF_RXFILT_HASH_CNT 0x001F
-#define SF_RXFILT_HASH_ADDROFF 0x0000
-#define SF_RXFILT_HASH_PRIOOFF 0x0004
-#define SF_RXFILT_HASH_VLANOFF 0x0008
-
-/*
- * Statistics registers 0x7000 to 0x7FFF
- */
-#define SF_STATS_BASE 0x7000
-#define SF_STATS_END 0x7FFF
-
-/*
- * TX frame processor instruction space 0x8000 to 0x9FFF
- */
-
-/*
- * RX frame processor instruction space 0xA000 to 0xBFFF
- */
-
-/*
- * Ethernet FIFO access space 0xC000 to 0xDFFF
- */
-
-/*
- * Reserved 0xE000 to 0xFFFF
- */
-
-/*
- * Descriptor data structures.
- */
-
-
-/* Receive descriptor formats. */
-#define SF_RX_MINSPACING 8
-#define SF_RX_DLIST_CNT 256
-#define SF_RX_CLIST_CNT 1024
-#define SF_RX_HOSTADDR(x) (((x) >> 2) & 0x3FFFFFFF)
-
-/*
- * RX buffer descriptor type 0, 32-bit addressing. Note that we
- * program the RX buffer queue control register(s) to allow a
- * descriptor spacing of 16 bytes, which leaves room after each
- * descriptor to store a pointer to the mbuf for each buffer.
- */
-struct sf_rx_bufdesc_type0 {
- u_int32_t sf_valid:1,
- sf_end:1,
- sf_addrlo:30;
- u_int32_t sf_pad0;
-#ifdef __i386__
- u_int32_t sf_pad1;
-#endif
- struct mbuf *sf_mbuf;
-};
-
-/*
- * RX buffer descriptor type 0, 64-bit addressing.
- */
-struct sf_rx_bufdesc_type1 {
- u_int32_t sf_valid:1,
- sf_end:1,
- sf_addrlo:30;
- u_int32_t sf_addrhi;
-#ifdef __i386__
- u_int32_t sf_pad;
-#endif
- struct mbuf *sf_mbuf;
-};
-
-/*
- * RX completion descriptor, type 0 (short).
- */
-struct sf_rx_cmpdesc_type0 {
- u_int32_t sf_len:16,
- sf_endidx:11,
- sf_status1:3,
- sf_id:2;
-};
-
-/*
- * RX completion descriptor, type 1 (basic). Includes vlan ID
- * if this is a vlan-addressed packet, plus extended status.
- */
-struct sf_rx_cmpdesc_type1 {
- u_int32_t sf_len:16,
- sf_endidx:11,
- sf_status1:3,
- sf_id:2;
- u_int16_t sf_status2;
- u_int16_t sf_vlanid;
-};
-
-/*
- * RX completion descriptor, type 2 (checksum). Includes partial TCP/IP
- * checksum instead of vlan tag, plus extended status.
- */
-struct sf_rx_cmpdesc_type2 {
- u_int32_t sf_len:16,
- sf_endidx:11,
- sf_status1:3,
- sf_id:2;
- u_int16_t sf_status2;
- u_int16_t sf_cksum;
-};
-
-/*
- * RX completion descriptor type 3 (full). Includes timestamp, partial
- * TCP/IP checksum, vlan tag plus priority, two extended status fields.
- */
-struct sf_rx_cmpdesc_type3 {
- u_int32_t sf_len:16,
- sf_endidx:11,
- sf_status1:3,
- sf_id:2;
- u_int32_t sf_startidx:10,
- sf_status3:6,
- sf_status2:16;
- u_int16_t sf_cksum;
- u_int16_t sf_vlanid_prio;
- u_int32_t sf_timestamp;
-};
-
-#define SF_RXSTAT1_QUEUE 0x1
-#define SF_RXSTAT1_FIFOFULL 0x2
-#define SF_RXSTAT1_OK 0x4
-
- /* 0=unknown,5=unsupported */
-#define SF_RXSTAT2_FRAMETYPE 0x0007 /* 1=IPv4,2=IPv2,3=IPX,4=ICMP */
-#define SF_RXSTAT2_UDP 0x0008
-#define SF_RXSTAT2_TCP 0x0010
-#define SF_RXSTAT2_FRAG 0x0020
-#define SF_RXSTAT2_PCSUM_OK 0x0040 /* partial checksum ok */
-#define SF_RXSTAT2_CSUM_BAD 0x0080 /* TCP/IP checksum bad */
-#define SF_RXSTAT2_CSUM_OK 0x0100 /* TCP/IP checksum ok */
-#define SF_RXSTAT2_VLAN 0x0200
-#define SF_RXSTAT2_BADRXCODE 0x0400
-#define SF_RXSTAT2_DRIBBLE 0x0800
-#define SF_RXSTAT2_ISL_CRCERR 0x1000
-#define SF_RXSTAT2_CRCERR 0x2000
-#define SF_RXSTAT2_HASH 0x4000
-#define SF_RXSTAT2_PERFECT 0x8000
-
-#define SF_RXSTAT3_TRAILER 0x01
-#define SF_RXSTAT3_HEADER 0x02
-#define SF_RXSTAT3_CONTROL 0x04
-#define SF_RXSTAT3_PAUSE 0x08
-#define SF_RXSTAT3_ISL 0x10
-
-/*
- * Transmit descriptor formats.
- * Each transmit descriptor type allows for a skip field at the
- * start of each structure. The size of the skip field can vary,
- * however we always set it for 8 bytes, which is enough to hold
- * a pointer (32 bits on x86, 64-bits on alpha) that we can use
- * to hold the address of the head of the mbuf chain for the
- * frame or fragment associated with the descriptor. This saves
- * us from having to create a separate pointer array to hold
- * the mbuf addresses.
- */
-#define SF_TX_BUFDESC_ID 0xB
-#define SF_MAXFRAGS 14
-#define SF_TX_MINSPACING 128
-#define SF_TX_DLIST_CNT 128
-#define SF_TX_DLIST_SIZE 16384
-#define SF_TX_SKIPLEN 1
-#define SF_TX_CLIST_CNT 1024
-
-struct sf_frag {
- u_int32_t sf_addr;
- u_int16_t sf_fraglen;
- u_int16_t sf_pktlen;
-};
-
-struct sf_frag_msdos {
- u_int16_t sf_pktlen;
- u_int16_t sf_fraglen;
- u_int32_t sf_addr;
-};
-
-/*
- * TX frame descriptor type 0, 32-bit addressing. One descriptor can
- * be used to map multiple packet fragments. We use this format since
- * BSD networking fragments packet data across mbuf chains. Note that
- * the number of fragments can be variable depending on how the descriptor
- * spacing is specified in the TX descriptor queue control register.
- * We always use a spacing of 128 bytes, and a skipfield length of 8
- * bytes: this means 16 bytes for the descriptor, including the skipfield,
- * with 121 bytes left for fragment maps. Each fragment requires 8 bytes,
- * which allows for 14 fragments per descriptor. The total size of the
- * transmit buffer queue is limited to 16384 bytes, so with a spacing of
- * 128 bytes per descriptor, we have room for 128 descriptors in the queue.
- */
-struct sf_tx_bufdesc_type0 {
-#ifdef __i386__
- u_int32_t sf_pad;
-#endif
- struct mbuf *sf_mbuf;
- u_int32_t sf_rsvd0:24,
- sf_crcen:1,
- sf_caltcp:1,
- sf_end:1,
- sf_intr:1,
- sf_id:4;
- u_int8_t sf_fragcnt;
- u_int8_t sf_rsvd2;
- u_int16_t sf_rsvd1;
- struct sf_frag sf_frags[14];
-};
-
-/*
- * TX buffer descriptor type 1, 32-bit addressing. Each descriptor
- * maps a single fragment.
- */
-struct sf_tx_bufdesc_type1 {
-#ifdef __i386__
- u_int32_t sf_pad;
-#endif
- struct mbuf *sf_mbuf;
- u_int32_t sf_fraglen:16,
- sf_fragcnt:8,
- sf_crcen:1,
- sf_caltcp:1,
- sf_end:1,
- sf_intr:1,
- sf_id:4;
- u_int32_t sf_addr;
-};
-
-/*
- * TX buffer descriptor type 2, 64-bit addressing. Each descriptor
- * maps a single fragment.
- */
-struct sf_tx_bufdesc_type2 {
-#ifdef __i386__
- u_int32_t sf_pad;
-#endif
- struct mbuf *sf_mbuf;
- u_int32_t sf_fraglen:16,
- sf_fragcnt:8,
- sf_crcen:1,
- sf_caltcp:1,
- sf_end:1,
- sf_intr:1,
- sf_id:4;
- u_int32_t sf_addrlo;
- u_int32_t sf_addrhi;
-};
-
-/* TX buffer descriptor type 3 is not defined. */
-
-/*
- * TX frame descriptor type 4, 32-bit addressing. This is a special
- * case of the type 0 descriptor, identical except that the fragment
- * address and length fields are ordered differently. This is done
- * to optimize copies in MS-DOS and OS/2 drivers.
- */
-struct sf_tx_bufdesc_type4 {
-#ifdef __i386__
- u_int32_t sf_pad;
-#endif
- struct mbuf *sf_mbuf;
- u_int32_t sf_rsvd0:24,
- sf_crcen:1,
- sf_caltcp:1,
- sf_end:1,
- sf_intr:1,
- sf_id:4;
- u_int8_t sf_fragcnt;
- u_int8_t sf_rsvd2;
- u_int16_t sf_rsvd1;
- struct sf_frag_msdos sf_frags[14];
-};
-
-/*
- * Transmit completion queue descriptor formats.
- */
-
-/*
- * Transmit DMA completion descriptor, type 0.
- */
-#define SF_TXCMPTYPE_DMA 0x4
-struct sf_tx_cmpdesc_type0 {
- u_int32_t sf_index:15,
- sf_priority:1,
- sf_timestamp:13,
- sf_type:3;
-};
-
-/*
- * Transmit completion descriptor, type 1.
- */
-#define SF_TXCMPTYPE_TX 0x5
-struct sf_tx_cmpdesc_type1 {
- u_int32_t sf_index:15,
- sf_priority:1,
- sf_txstat:13,
- sf_type:3;
-};
-
-#define SF_TXSTAT_CRCERR 0x0001
-#define SF_TXSTAT_LENCHECKERR 0x0002
-#define SF_TXSTAT_LENRANGEERR 0x0004
-#define SF_TXSTAT_TX_OK 0x0008
-#define SF_TXSTAT_TX_DEFERED 0x0010
-#define SF_TXSTAT_EXCESS_DEFER 0x0020
-#define SF_TXSTAT_EXCESS_COLL 0x0040
-#define SF_TXSTAT_LATE_COLL 0x0080
-#define SF_TXSTAT_TOOBIG 0x0100
-#define SF_TXSTAT_TX_UNDERRUN 0x0200
-#define SF_TXSTAT_CTLFRAME_OK 0x0400
-#define SF_TXSTAT_PAUSEFRAME_OK 0x0800
-#define SF_TXSTAT_PAUSED 0x1000
-
-/* Statistics counters. */
-struct sf_stats {
- u_int32_t sf_tx_frames;
- u_int32_t sf_tx_single_colls;
- u_int32_t sf_tx_multi_colls;
- u_int32_t sf_tx_crcerrs;
- u_int32_t sf_tx_bytes;
- u_int32_t sf_tx_defered;
- u_int32_t sf_tx_late_colls;
- u_int32_t sf_tx_pause_frames;
- u_int32_t sf_tx_control_frames;
- u_int32_t sf_tx_excess_colls;
- u_int32_t sf_tx_excess_defer;
- u_int32_t sf_tx_mcast_frames;
- u_int32_t sf_tx_bcast_frames;
- u_int32_t sf_tx_frames_lost;
- u_int32_t sf_rx_rx_frames;
- u_int32_t sf_rx_crcerrs;
- u_int32_t sf_rx_alignerrs;
- u_int32_t sf_rx_bytes;
- u_int32_t sf_rx_control_frames;
- u_int32_t sf_rx_unsup_control_frames;
- u_int32_t sf_rx_giants;
- u_int32_t sf_rx_runts;
- u_int32_t sf_rx_jabbererrs;
- u_int32_t sf_rx_pkts_64;
- u_int32_t sf_rx_pkts_65_127;
- u_int32_t sf_rx_pkts_128_255;
- u_int32_t sf_rx_pkts_256_511;
- u_int32_t sf_rx_pkts_512_1023;
- u_int32_t sf_rx_pkts_1024_1518;
- u_int32_t sf_rx_frames_lost;
- u_int16_t sf_tx_underruns;
- u_int16_t sf_pad;
-};
-
-/*
- * register space access macros
- */
-#define CSR_WRITE_4(sc, reg, val) \
- bus_space_write_4(sc->sf_btag, sc->sf_bhandle, reg, val)
-
-#define CSR_READ_4(sc, reg) \
- bus_space_read_4(sc->sf_btag, sc->sf_bhandle, reg)
-
-#define CSR_READ_1(sc, reg) \
- bus_space_read_1(sc->sf_btag, sc->sf_bhandle, reg)
-
-
-struct sf_type {
- u_int16_t sf_vid;
- u_int16_t sf_did;
- char *sf_name;
-};
-
-#define SF_INC(x, y) (x) = (x + 1) % y
-
-#define ETHER_ALIGN 2
-
-/*
- * Note: alignment is important here: each list must be aligned to
- * a 256-byte boundary. It turns out that each ring is some multiple
- * of 4K in length, so we can stack them all on top of each other
- * and just worry about aligning the whole mess. There's one transmit
- * buffer ring and two receive buffer rings: one RX ring is for small
- * packets and the other is for large packets. Each buffer ring also
- * has a companion completion queue.
- */
-struct sf_list_data {
- struct sf_tx_bufdesc_type0 sf_tx_dlist[SF_TX_DLIST_CNT];
- struct sf_tx_cmpdesc_type1 sf_tx_clist[SF_TX_CLIST_CNT];
- struct sf_rx_bufdesc_type0 sf_rx_dlist_big[SF_RX_DLIST_CNT];
-#ifdef notdef
- /*
- * Unfortunately, because the Starfire doesn't allow arbitrary
- * byte alignment, we have to copy packets in the RX handler in
- * order to align the payload correctly. This means that we
- * don't gain anything by having separate large and small descriptor
- * lists, so for now we don't bother with the small one.
- */
- struct sf_rx_bufdesc_type0 sf_rx_dlist_small[SF_RX_DLIST_CNT];
-#endif
- struct sf_rx_cmpdesc_type3 sf_rx_clist[SF_RX_CLIST_CNT];
-};
-
-struct sf_softc {
- struct arpcom arpcom; /* interface info */
- bus_space_handle_t sf_bhandle; /* bus space handle */
- bus_space_tag_t sf_btag; /* bus space tag */
- void *sf_intrhand; /* interrupt handler cookie */
- struct resource *sf_irq; /* irq resource descriptor */
- struct resource *sf_res; /* mem/ioport resource */
- struct sf_type *sf_info; /* Starfire adapter info */
- device_t sf_miibus;
- u_int8_t sf_unit; /* interface number */
- struct sf_list_data *sf_ldata;
- int sf_tx_cnt;
- u_int8_t sf_link;
- int sf_if_flags;
- struct callout_handle sf_stat_ch;
-};
-
-#define SF_TIMEOUT 1000
-
-#ifdef __alpha__
-#undef vtophys
-#define vtophys(va) alpha_XXX_dmamap((vm_offset_t)va)
-#endif
diff --git a/sys/dev/sio/sio.c b/sys/dev/sio/sio.c
deleted file mode 100644
index 95b8bfeb1a48..000000000000
--- a/sys/dev/sio/sio.c
+++ /dev/null
@@ -1,3144 +0,0 @@
-/*-
- * 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- * from: @(#)com.c 7.5 (Berkeley) 5/16/91
- * from: i386/isa sio.c,v 1.234
- */
-
-#include "opt_comconsole.h"
-#include "opt_compat.h"
-#include "opt_ddb.h"
-#include "opt_sio.h"
-#include "card.h"
-#include "sio.h"
-
-/*
- * Serial driver, based on 386BSD-0.1 com driver.
- * Mostly rewritten to use pseudo-DMA.
- * Works for National Semiconductor NS8250-NS16550AF UARTs.
- * COM driver, based on HP dca driver.
- *
- * Changes for PC-Card integration:
- * - Added PC-Card driver table and handlers
- */
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/reboot.h>
-#include <sys/malloc.h>
-#include <sys/tty.h>
-#include <sys/proc.h>
-#include <sys/module.h>
-#include <sys/conf.h>
-#include <sys/dkstat.h>
-#include <sys/fcntl.h>
-#include <sys/interrupt.h>
-#include <sys/kernel.h>
-#include <sys/syslog.h>
-#include <sys/sysctl.h>
-#include <sys/bus.h>
-#include <machine/bus.h>
-#include <sys/rman.h>
-#include <sys/timepps.h>
-
-#include <isa/isareg.h>
-#include <isa/isavar.h>
-#include <machine/lock.h>
-
-#include <machine/clock.h>
-#include <machine/ipl.h>
-#ifndef SMP
-#include <machine/lock.h>
-#endif
-#include <machine/resource.h>
-
-#include <isa/sioreg.h>
-
-#ifdef COM_ESP
-#include <isa/ic/esp.h>
-#endif
-#include <isa/ic/ns16550.h>
-
-#ifndef __i386__
-#define disable_intr()
-#define enable_intr()
-#endif
-
-#ifdef SMP
-#define disable_intr() COM_DISABLE_INTR()
-#define enable_intr() COM_ENABLE_INTR()
-#endif /* SMP */
-
-#define LOTS_OF_EVENTS 64 /* helps separate urgent events from input */
-
-#define CALLOUT_MASK 0x80
-#define CONTROL_MASK 0x60
-#define CONTROL_INIT_STATE 0x20
-#define CONTROL_LOCK_STATE 0x40
-#define DEV_TO_UNIT(dev) (MINOR_TO_UNIT(minor(dev)))
-#define MINOR_MAGIC_MASK (CALLOUT_MASK | CONTROL_MASK)
-#define MINOR_TO_UNIT(mynor) ((mynor) & ~MINOR_MAGIC_MASK)
-
-#ifdef COM_MULTIPORT
-/* checks in flags for multiport and which is multiport "master chip"
- * for a given card
- */
-#define COM_ISMULTIPORT(flags) ((flags) & 0x01)
-#define COM_MPMASTER(flags) (((flags) >> 8) & 0x0ff)
-#define COM_NOTAST4(flags) ((flags) & 0x04)
-#endif /* COM_MULTIPORT */
-
-#define COM_CONSOLE(flags) ((flags) & 0x10)
-#define COM_FORCECONSOLE(flags) ((flags) & 0x20)
-#define COM_LLCONSOLE(flags) ((flags) & 0x40)
-#define COM_DEBUGGER(flags) ((flags) & 0x80)
-#define COM_LOSESOUTINTS(flags) ((flags) & 0x08)
-#define COM_NOFIFO(flags) ((flags) & 0x02)
-#define COM_ST16650A(flags) ((flags) & 0x20000)
-#define COM_C_NOPROBE (0x40000)
-#define COM_NOPROBE(flags) ((flags) & COM_C_NOPROBE)
-#define COM_C_IIR_TXRDYBUG (0x80000)
-#define COM_IIR_TXRDYBUG(flags) ((flags) & COM_C_IIR_TXRDYBUG)
-#define COM_FIFOSIZE(flags) (((flags) & 0xff000000) >> 24)
-
-#define com_scr 7 /* scratch register for 16450-16550 (R/W) */
-
-/*
- * com state bits.
- * (CS_BUSY | CS_TTGO) and (CS_BUSY | CS_TTGO | CS_ODEVREADY) must be higher
- * than the other bits so that they can be tested as a group without masking
- * off the low bits.
- *
- * The following com and tty flags correspond closely:
- * CS_BUSY = TS_BUSY (maintained by comstart(), siopoll() and
- * comstop())
- * CS_TTGO = ~TS_TTSTOP (maintained by comparam() and comstart())
- * CS_CTS_OFLOW = CCTS_OFLOW (maintained by comparam())
- * CS_RTS_IFLOW = CRTS_IFLOW (maintained by comparam())
- * TS_FLUSH is not used.
- * XXX I think TIOCSETA doesn't clear TS_TTSTOP when it clears IXON.
- * XXX CS_*FLOW should be CF_*FLOW in com->flags (control flags not state).
- */
-#define CS_BUSY 0x80 /* output in progress */
-#define CS_TTGO 0x40 /* output not stopped by XOFF */
-#define CS_ODEVREADY 0x20 /* external device h/w ready (CTS) */
-#define CS_CHECKMSR 1 /* check of MSR scheduled */
-#define CS_CTS_OFLOW 2 /* use CTS output flow control */
-#define CS_DTR_OFF 0x10 /* DTR held off */
-#define CS_ODONE 4 /* output completed */
-#define CS_RTS_IFLOW 8 /* use RTS input flow control */
-#define CSE_BUSYCHECK 1 /* siobusycheck() scheduled */
-
-static char const * const error_desc[] = {
-#define CE_OVERRUN 0
- "silo overflow",
-#define CE_INTERRUPT_BUF_OVERFLOW 1
- "interrupt-level buffer overflow",
-#define CE_TTY_BUF_OVERFLOW 2
- "tty-level buffer overflow",
-};
-
-#define CE_NTYPES 3
-#define CE_RECORD(com, errnum) (++(com)->delta_error_counts[errnum])
-
-/* types. XXX - should be elsewhere */
-typedef u_int Port_t; /* hardware port */
-typedef u_char bool_t; /* boolean */
-
-/* queue of linear buffers */
-struct lbq {
- u_char *l_head; /* next char to process */
- u_char *l_tail; /* one past the last char to process */
- struct lbq *l_next; /* next in queue */
- bool_t l_queued; /* nonzero if queued */
-};
-
-/* com device structure */
-struct com_s {
- u_int flags; /* Copy isa device flags */
- u_char state; /* miscellaneous flag bits */
- bool_t active_out; /* nonzero if the callout device is open */
- u_char cfcr_image; /* copy of value written to CFCR */
-#ifdef COM_ESP
- bool_t esp; /* is this unit a hayes esp board? */
-#endif
- u_char extra_state; /* more flag bits, separate for order trick */
- u_char fifo_image; /* copy of value written to FIFO */
- bool_t hasfifo; /* nonzero for 16550 UARTs */
- bool_t st16650a; /* Is a Startech 16650A or RTS/CTS compat */
- bool_t loses_outints; /* nonzero if device loses output interrupts */
- u_char mcr_image; /* copy of value written to MCR */
-#ifdef COM_MULTIPORT
- bool_t multiport; /* is this unit part of a multiport device? */
-#endif /* COM_MULTIPORT */
- bool_t no_irq; /* nonzero if irq is not attached */
- bool_t gone; /* hardware disappeared */
- bool_t poll; /* nonzero if polling is required */
- bool_t poll_output; /* nonzero if polling for output is required */
- int unit; /* unit number */
- int dtr_wait; /* time to hold DTR down on close (* 1/hz) */
- u_int tx_fifo_size;
- u_int wopeners; /* # processes waiting for DCD in open() */
-
- /*
- * The high level of the driver never reads status registers directly
- * because there would be too many side effects to handle conveniently.
- * Instead, it reads copies of the registers stored here by the
- * interrupt handler.
- */
- u_char last_modem_status; /* last MSR read by intr handler */
- u_char prev_modem_status; /* last MSR handled by high level */
-
- u_char hotchar; /* ldisc-specific char to be handled ASAP */
- u_char *ibuf; /* start of input buffer */
- u_char *ibufend; /* end of input buffer */
- u_char *ibufold; /* old input buffer, to be freed */
- u_char *ihighwater; /* threshold in input buffer */
- u_char *iptr; /* next free spot in input buffer */
- int ibufsize; /* size of ibuf (not include error bytes) */
- int ierroff; /* offset of error bytes in ibuf */
-
- struct lbq obufq; /* head of queue of output buffers */
- struct lbq obufs[2]; /* output buffers */
-
- Port_t data_port; /* i/o ports */
-#ifdef COM_ESP
- Port_t esp_port;
-#endif
- Port_t int_id_port;
- Port_t iobase;
- Port_t modem_ctl_port;
- Port_t line_status_port;
- Port_t modem_status_port;
- Port_t intr_ctl_port; /* Ports of IIR register */
-
- struct tty *tp; /* cross reference */
-
- /* Initial state. */
- struct termios it_in; /* should be in struct tty */
- struct termios it_out;
-
- /* Lock state. */
- struct termios lt_in; /* should be in struct tty */
- struct termios lt_out;
-
- bool_t do_timestamp;
- bool_t do_dcd_timestamp;
- struct timeval timestamp;
- struct timeval dcd_timestamp;
- struct pps_state pps;
-
- u_long bytes_in; /* statistics */
- u_long bytes_out;
- u_int delta_error_counts[CE_NTYPES];
- u_long error_counts[CE_NTYPES];
-
- struct resource *irqres;
- struct resource *ioportres;
- void *cookie;
-
- /*
- * Data area for output buffers. Someday we should build the output
- * buffer queue without copying data.
- */
- u_char obuf1[256];
- u_char obuf2[256];
-};
-
-#ifdef COM_ESP
-static int espattach __P((struct com_s *com, Port_t esp_port));
-#endif
-static int sioattach __P((device_t dev));
-static int sio_isa_attach __P((device_t dev));
-
-static timeout_t siobusycheck;
-static timeout_t siodtrwakeup;
-static void comhardclose __P((struct com_s *com));
-static void sioinput __P((struct com_s *com));
-static void siointr1 __P((struct com_s *com));
-static void siointr __P((void *arg));
-static int commctl __P((struct com_s *com, int bits, int how));
-static int comparam __P((struct tty *tp, struct termios *t));
-static swihand_t siopoll;
-static int sioprobe __P((device_t dev));
-static int sio_isa_probe __P((device_t dev));
-static void siosettimeout __P((void));
-static int siosetwater __P((struct com_s *com, speed_t speed));
-static void comstart __P((struct tty *tp));
-static void comstop __P((struct tty *tp, int rw));
-static timeout_t comwakeup;
-static void disc_optim __P((struct tty *tp, struct termios *t,
- struct com_s *com));
-
-#if NCARD > 0
-static int sio_pccard_attach __P((device_t dev));
-static int sio_pccard_detach __P((device_t dev));
-static int sio_pccard_probe __P((device_t dev));
-#endif /* NCARD > 0 */
-
-static char driver_name[] = "sio";
-
-/* table and macro for fast conversion from a unit number to its com struct */
-static devclass_t sio_devclass;
-#define com_addr(unit) ((struct com_s *) \
- devclass_get_softc(sio_devclass, unit))
-
-static device_method_t sio_isa_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, sio_isa_probe),
- DEVMETHOD(device_attach, sio_isa_attach),
-
- { 0, 0 }
-};
-
-static driver_t sio_isa_driver = {
- driver_name,
- sio_isa_methods,
- sizeof(struct com_s),
-};
-
-#if NCARD > 0
-static device_method_t sio_pccard_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, sio_pccard_probe),
- DEVMETHOD(device_attach, sio_pccard_attach),
- DEVMETHOD(device_detach, sio_pccard_detach),
-
- { 0, 0 }
-};
-
-static driver_t sio_pccard_driver = {
- driver_name,
- sio_pccard_methods,
- sizeof(struct com_s),
-};
-#endif (NCARD > 0)
-
-static d_open_t sioopen;
-static d_close_t sioclose;
-static d_read_t sioread;
-static d_write_t siowrite;
-static d_ioctl_t sioioctl;
-
-#define CDEV_MAJOR 28
-static struct cdevsw sio_cdevsw = {
- /* open */ sioopen,
- /* close */ sioclose,
- /* read */ sioread,
- /* write */ siowrite,
- /* ioctl */ sioioctl,
- /* poll */ ttypoll,
- /* mmap */ nommap,
- /* strategy */ nostrategy,
- /* name */ driver_name,
- /* maj */ CDEV_MAJOR,
- /* dump */ nodump,
- /* psize */ nopsize,
- /* flags */ D_TTY,
- /* bmaj */ -1
-};
-
-int comconsole = -1;
-static volatile speed_t comdefaultrate = CONSPEED;
-#ifdef __alpha__
-static volatile speed_t gdbdefaultrate = CONSPEED;
-#endif
-static u_int com_events; /* input chars + weighted output completions */
-static Port_t siocniobase;
-static int siocnunit;
-static Port_t siogdbiobase;
-static int siogdbunit = -1;
-static bool_t sio_registered;
-static int sio_timeout;
-static int sio_timeouts_until_log;
-static struct callout_handle sio_timeout_handle
- = CALLOUT_HANDLE_INITIALIZER(&sio_timeout_handle);
-static int sio_numunits;
-
-static struct speedtab comspeedtab[] = {
- { 0, 0 },
- { 50, COMBRD(50) },
- { 75, COMBRD(75) },
- { 110, COMBRD(110) },
- { 134, COMBRD(134) },
- { 150, COMBRD(150) },
- { 200, COMBRD(200) },
- { 300, COMBRD(300) },
- { 600, COMBRD(600) },
- { 1200, COMBRD(1200) },
- { 1800, COMBRD(1800) },
- { 2400, COMBRD(2400) },
- { 4800, COMBRD(4800) },
- { 9600, COMBRD(9600) },
- { 19200, COMBRD(19200) },
- { 38400, COMBRD(38400) },
- { 57600, COMBRD(57600) },
- { 115200, COMBRD(115200) },
- { -1, -1 }
-};
-
-#ifdef COM_ESP
-/* XXX configure this properly. */
-static Port_t likely_com_ports[] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, };
-static Port_t likely_esp_ports[] = { 0x140, 0x180, 0x280, 0 };
-#endif
-
-/*
- * handle sysctl read/write requests for console speed
- *
- * In addition to setting comdefaultrate for I/O through /dev/console,
- * also set the initial and lock values for the /dev/ttyXX device
- * if there is one associated with the console. Finally, if the /dev/tty
- * device has already been open, change the speed on the open running port
- * itself.
- */
-
-static int
-sysctl_machdep_comdefaultrate SYSCTL_HANDLER_ARGS
-{
- int error, s;
- speed_t newspeed;
- struct com_s *com;
- struct tty *tp;
-
- newspeed = comdefaultrate;
-
- error = sysctl_handle_opaque(oidp, &newspeed, sizeof newspeed, req);
- if (error || !req->newptr)
- return (error);
-
- comdefaultrate = newspeed;
-
- if (comconsole < 0) /* serial console not selected? */
- return (0);
-
- com = com_addr(comconsole);
- if (com == NULL)
- return (ENXIO);
-
- /*
- * set the initial and lock rates for /dev/ttydXX and /dev/cuaXX
- * (note, the lock rates really are boolean -- if non-zero, disallow
- * speed changes)
- */
- com->it_in.c_ispeed = com->it_in.c_ospeed =
- com->lt_in.c_ispeed = com->lt_in.c_ospeed =
- com->it_out.c_ispeed = com->it_out.c_ospeed =
- com->lt_out.c_ispeed = com->lt_out.c_ospeed = comdefaultrate;
-
- /*
- * if we're open, change the running rate too
- */
- tp = com->tp;
- if (tp && (tp->t_state & TS_ISOPEN)) {
- tp->t_termios.c_ispeed =
- tp->t_termios.c_ospeed = comdefaultrate;
- s = spltty();
- error = comparam(tp, &tp->t_termios);
- splx(s);
- }
- return error;
-}
-
-SYSCTL_PROC(_machdep, OID_AUTO, conspeed, CTLTYPE_INT | CTLFLAG_RW,
- 0, 0, sysctl_machdep_comdefaultrate, "I", "");
-
-#define SET_FLAG(dev, bit) device_set_flags(dev, device_get_flags(dev) | (bit))
-#define CLR_FLAG(dev, bit) device_set_flags(dev, device_get_flags(dev) & ~(bit))
-
-#if NCARD > 0
-static int
-sio_pccard_probe(dev)
- device_t dev;
-{
- /* Do not probe IRQ - pccard doesn't turn on the interrupt line */
- /* until bus_setup_intr */
- SET_FLAG(dev, COM_C_NOPROBE);
-
- return (sioprobe(dev));
-}
-
-static int
-sio_pccard_attach(dev)
- device_t dev;
-{
- return (sioattach(dev));
-}
-
-/*
- * sio_detach - unload the driver and clear the table.
- * XXX TODO:
- * This is usually called when the card is ejected, but
- * can be caused by a modunload of a controller driver.
- * The idea is to reset the driver's view of the device
- * and ensure that any driver entry points such as
- * read and write do not hang.
- */
-static int
-sio_pccard_detach(dev)
- device_t dev;
-{
- struct com_s *com;
-
- com = (struct com_s *) device_get_softc(dev);
- if (com == NULL) {
- device_printf(dev, "NULL com in siounload\n");
- return (0);
- }
- if (com->iobase == 0) {
- device_printf(dev, "already unloaded!\n");
- return (0);
- }
- com->gone = 1;
- if (com->irqres) {
- bus_teardown_intr(dev, com->irqres, com->cookie);
- bus_release_resource(dev, SYS_RES_IRQ, 0, com->irqres);
- }
- if (com->ioportres)
- bus_release_resource(dev, SYS_RES_IOPORT, 0, com->ioportres);
- if (com->tp && (com->tp->t_state & TS_ISOPEN)) {
- device_printf(dev, "still open, forcing close\n");
- com->tp->t_gen++;
- ttyclose(com->tp);
- ttwakeup(com->tp);
- ttwwakeup(com->tp);
- } else {
- if (com->ibuf != NULL)
- free(com->ibuf, M_DEVBUF);
- }
- device_printf(dev, "unloaded\n");
- return (0);
-}
-#endif /* NCARD > 0 */
-
-
-static struct isa_pnp_id sio_ids[] = {
- {0x0005d041, "Standard PC COM port"}, /* PNP0500 */
- {0x0105d041, "16550A-compatible COM port"}, /* PNP0501 */
- {0x0205d041, "Multiport serial device (non-intelligent 16550)"}, /* PNP0502 */
- {0x1005d041, "Generic IRDA-compatible device"}, /* PNP0510 */
- {0x1105d041, "Generic IRDA-compatible device"}, /* PNP0511 */
- /* Devices that do not have a compatid */
- {0x7602a904, NULL}, /* AEI0276 - 56K v.90 Fax Modem (LKT) */
- {0x00007905, NULL}, /* AKY0000 - 56K Plug&Play Modem */
- {0x01405407, NULL}, /* AZT4001 - AZT3000 PnP SOUND DEVICE, MODEM */
- {0x56039008, NULL}, /* BDP0356 - Best Data 56x2 */
- {0x36339008, NULL}, /* BDP3336 - Best Data Prods. 336F */
- {0x0014490a, NULL}, /* BRI1400 - Boca 33.6 PnP */
- {0x0015490a, NULL}, /* BRI1500 - Internal Fax Data */
- {0x0034490a, NULL}, /* BRI3400 - Internal ACF Modem */
- {0x00b4490a, NULL}, /* BRIB400 - Boca 56k PnP */
- {0x0030320d, NULL}, /* CIR3000 - Cirrus Logic V43 */
- {0x0100440e, NULL}, /* CRD0001 - Cardinal MVP288IV ? */
- {0x1200c31e, NULL}, /* GVC0012 - VF1128HV-R9 (win modem?) */
- {0x0303c31e, NULL}, /* GVC0303 - MaxTech 33.6 PnP D/F/V */
- {0x0505c31e, NULL}, /* GVC0505 - GVC 56k Faxmodem */
- {0x0050c31e, NULL}, /* GVC5000 - some GVC modem */
- {0x3800f91e, NULL}, /* GWY0038 - Telepath with v.90 */
- {0x9062f91e, NULL}, /* GWY6290 - Telepath with x2 Technology */
- {0x0000f435, NULL}, /* MOT0000 - Motorola ModemSURFR 33.6 Intern */
- {0x5015f435, NULL}, /* MOT1550 - Motorola ModemSURFR 56K Modem */
- {0xf015f435, NULL}, /* MOT15F0 - Motorola VoiceSURFR 56K Modem */
- {0x6045f435, NULL}, /* MOT4560 - Motorola ? */
- {0x61e7a338, NULL}, /* NECE761 - 33.6Modem */
- {0x39804f3f, NULL}, /* OZO8039 - Zoom 56k flex */
- {0x3024a341, NULL}, /* PMC2430 - Pace 56 Voice Internal Modem */
- {0x1000eb49, NULL}, /* ROK0010 - Rockwell ? */
- {0x5002734a, NULL}, /* RSS0250 - 5614Jx3(G) Internal Modem */
- {0xc100ad4d, NULL}, /* SMM00C1 - Leopard 56k PnP */
- {0x9012b04e, NULL}, /* SUP1290 - Supra ? */
- {0x1013b04e, NULL}, /* SUP1310 - SupraExpress 336i PnP */
- {0x8013b04e, NULL}, /* SUP1380 - SupraExpress 288i PnP Voice */
- {0x8113b04e, NULL}, /* SUP1381 - SupraExpress 336i PnP Voice */
- {0x5016b04e, NULL}, /* SUP1650 - Supra 336i Sp Intl */
- {0x7420b04e, NULL}, /* SUP2070 - Supra ? */
- {0x8020b04e, NULL}, /* SUP2080 - Supra ? */
- {0x8420b04e, NULL}, /* SUP2084 - SupraExpress 56i PnP */
- {0x7121b04e, NULL}, /* SUP2171 - SupraExpress 56i Sp? */
- {0x8024b04e, NULL}, /* SUP2480 - Supra ? */
- {0x01007256, NULL}, /* USR0001 - U.S. Robotics Inc., Sportster W */
- {0x02007256, NULL}, /* USR0002 - U.S. Robotics Inc. Sportster 33. */
- {0x04007256, NULL}, /* USR0004 - USR Sportster 14.4k */
- {0x06007256, NULL}, /* USR0006 - USR Sportster 33.6k */
- {0x11007256, NULL}, /* USR0011 - USR ? */
- {0x01017256, NULL}, /* USR0101 - USR ? */
- {0x30207256, NULL}, /* USR2030 - U.S.Robotics Inc. Sportster 560 */
- {0x50207256, NULL}, /* USR2050 - U.S.Robotics Inc. Sportster 33. */
- {0x70207256, NULL}, /* USR2070 - U.S.Robotics Inc. Sportster 560 */
- {0x30307256, NULL}, /* USR3030 - U.S. Robotics 56K FAX INT */
- {0x31307256, NULL}, /* USR3031 - U.S. Robotics 56K FAX INT */
- {0x70307256, NULL}, /* USR3070 - U.S. Robotics 56K Voice INT */
- {0x90307256, NULL}, /* USR3090 - USR ? */
- {0x90917256, NULL}, /* USR9190 - USR 56k Voice INT */
- {0x0300695c, NULL}, /* WCI0003 - Fax/Voice/Modem/Speakphone/Asvd */
- {0x61f7896a, NULL}, /* ZTIF761 - Zoom ComStar 33.6 */
- {0}
-};
-
-
-
-static int
-sio_isa_probe(dev)
- device_t dev;
-{
- /* Check isapnp ids */
- if (ISA_PNP_PROBE(device_get_parent(dev), dev, sio_ids) == ENXIO)
- return (ENXIO);
- return (sioprobe(dev));
-}
-
-static int
-sioprobe(dev)
- device_t dev;
-{
-#if 0
- static bool_t already_init;
- device_t xdev;
-#endif
- bool_t failures[10];
- int fn;
- device_t idev;
- Port_t iobase;
- intrmask_t irqmap[4];
- intrmask_t irqs;
- u_char mcr_image;
- int result;
- u_long xirq;
- u_int flags = device_get_flags(dev);
- int rid;
- struct resource *port;
-
- rid = 0;
- port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
- 0, ~0, IO_COMSIZE, RF_ACTIVE);
- if (!port)
- return (ENXIO);
-
-#if 0
- /*
- * XXX this is broken - when we are first called, there are no
- * previously configured IO ports. We could hard code
- * 0x3f8, 0x2f8, 0x3e8, 0x2e8 etc but that's probably worse.
- * This code has been doing nothing since the conversion since
- * "count" is zero the first time around.
- */
- if (!already_init) {
- /*
- * Turn off MCR_IENABLE for all likely serial ports. An unused
- * port with its MCR_IENABLE gate open will inhibit interrupts
- * from any used port that shares the interrupt vector.
- * XXX the gate enable is elsewhere for some multiports.
- */
- device_t *devs;
- int count, i, xioport;
-
- devclass_get_devices(sio_devclass, &devs, &count);
- for (i = 0; i < count; i++) {
- xdev = devs[i];
- if (device_is_enabled(xdev) &&
- bus_get_resource(xdev, SYS_RES_IOPORT, 0, &xioport,
- NULL) == 0)
- outb(xioport + com_mcr, 0);
- }
- free(devs, M_TEMP);
- already_init = TRUE;
- }
-#endif
-
- if (COM_LLCONSOLE(flags)) {
- printf("sio%d: reserved for low-level i/o\n",
- device_get_unit(dev));
- bus_release_resource(dev, SYS_RES_IOPORT, rid, port);
- return (ENXIO);
- }
-
- /*
- * If the device is on a multiport card and has an AST/4
- * compatible interrupt control register, initialize this
- * register and prepare to leave MCR_IENABLE clear in the mcr.
- * Otherwise, prepare to set MCR_IENABLE in the mcr.
- * Point idev to the device struct giving the correct id_irq.
- * This is the struct for the master device if there is one.
- */
- idev = dev;
- mcr_image = MCR_IENABLE;
-#ifdef COM_MULTIPORT
- if (COM_ISMULTIPORT(flags)) {
- Port_t xiobase;
- u_long io;
-
- idev = devclass_get_device(sio_devclass, COM_MPMASTER(flags));
- if (idev == NULL) {
- printf("sio%d: master device %d not configured\n",
- device_get_unit(dev), COM_MPMASTER(flags));
- idev = dev;
- }
- if (!COM_NOTAST4(flags)) {
- if (bus_get_resource(idev, SYS_RES_IOPORT, 0, &io,
- NULL) == 0) {
- xiobase = io;
- if (bus_get_resource(idev, SYS_RES_IRQ, 0,
- NULL, NULL) == 0)
- outb(xiobase + com_scr, 0x80);
- else
- outb(xiobase + com_scr, 0);
- }
- mcr_image = 0;
- }
- }
-#endif /* COM_MULTIPORT */
- if (bus_get_resource(idev, SYS_RES_IRQ, 0, NULL, NULL) != 0)
- mcr_image = 0;
-
- bzero(failures, sizeof failures);
- iobase = rman_get_start(port);
-
- /*
- * We don't want to get actual interrupts, just masked ones.
- * Interrupts from this line should already be masked in the ICU,
- * but mask them in the processor as well in case there are some
- * (misconfigured) shared interrupts.
- */
- disable_intr();
-/* EXTRA DELAY? */
-
- /*
- * Initialize the speed and the word size and wait long enough to
- * drain the maximum of 16 bytes of junk in device output queues.
- * The speed is undefined after a master reset and must be set
- * before relying on anything related to output. There may be
- * junk after a (very fast) soft reboot and (apparently) after
- * master reset.
- * XXX what about the UART bug avoided by waiting in comparam()?
- * We don't want to to wait long enough to drain at 2 bps.
- */
- if (iobase == siocniobase)
- DELAY((16 + 1) * 1000000 / (comdefaultrate / 10));
- else {
- outb(iobase + com_cfcr, CFCR_DLAB | CFCR_8BITS);
- outb(iobase + com_dlbl, COMBRD(SIO_TEST_SPEED) & 0xff);
- outb(iobase + com_dlbh, (u_int) COMBRD(SIO_TEST_SPEED) >> 8);
- outb(iobase + com_cfcr, CFCR_8BITS);
- DELAY((16 + 1) * 1000000 / (SIO_TEST_SPEED / 10));
- }
-
- /*
- * Enable the interrupt gate and disable device interupts. This
- * should leave the device driving the interrupt line low and
- * guarantee an edge trigger if an interrupt can be generated.
- */
-/* EXTRA DELAY? */
- outb(iobase + com_mcr, mcr_image);
- outb(iobase + com_ier, 0);
- DELAY(1000); /* XXX */
- irqmap[0] = isa_irq_pending();
-
- /*
- * Attempt to set loopback mode so that we can send a null byte
- * without annoying any external device.
- */
-/* EXTRA DELAY? */
- outb(iobase + com_mcr, mcr_image | MCR_LOOPBACK);
-
- /*
- * Attempt to generate an output interrupt. On 8250's, setting
- * IER_ETXRDY generates an interrupt independent of the current
- * setting and independent of whether the THR is empty. On 16450's,
- * setting IER_ETXRDY generates an interrupt independent of the
- * current setting. On 16550A's, setting IER_ETXRDY only
- * generates an interrupt when IER_ETXRDY is not already set.
- */
- outb(iobase + com_ier, IER_ETXRDY);
-
- /*
- * On some 16x50 incompatibles, setting IER_ETXRDY doesn't generate
- * an interrupt. They'd better generate one for actually doing
- * output. Loopback may be broken on the same incompatibles but
- * it's unlikely to do more than allow the null byte out.
- */
- outb(iobase + com_data, 0);
- DELAY((1 + 2) * 1000000 / (SIO_TEST_SPEED / 10));
-
- /*
- * Turn off loopback mode so that the interrupt gate works again
- * (MCR_IENABLE was hidden). This should leave the device driving
- * an interrupt line high. It doesn't matter if the interrupt
- * line oscillates while we are not looking at it, since interrupts
- * are disabled.
- */
-/* EXTRA DELAY? */
- outb(iobase + com_mcr, mcr_image);
-
- /*
- * Some pcmcia cards have the "TXRDY bug", so we check everyone
- * for IIR_TXRDY implementation ( Palido 321s, DC-1S... )
- */
- if (COM_NOPROBE(flags)) {
- /* Reading IIR register twice */
- for (fn = 0; fn < 2; fn ++) {
- DELAY(10000);
- failures[6] = inb(iobase + com_iir);
- }
- /* Check IIR_TXRDY clear ? */
- result = 0;
- if (failures[6] & IIR_TXRDY) {
- /* Nop, Double check with clearing IER */
- outb(iobase + com_ier, 0);
- if (inb(iobase + com_iir) & IIR_NOPEND) {
- /* Ok. we're familia this gang */
- SET_FLAG(dev, COM_C_IIR_TXRDYBUG);
- } else {
- /* Unknown, Just omit this chip.. XXX */
- result = ENXIO;
- }
- } else {
- /* OK. this is well-known guys */
- CLR_FLAG(dev, COM_C_IIR_TXRDYBUG);
- }
- outb(iobase + com_cfcr, CFCR_8BITS);
- enable_intr();
- bus_release_resource(dev, SYS_RES_IOPORT, rid, port);
- return (iobase == siocniobase ? 0 : result);
- }
-
- /*
- * Check that
- * o the CFCR, IER and MCR in UART hold the values written to them
- * (the values happen to be all distinct - this is good for
- * avoiding false positive tests from bus echoes).
- * o an output interrupt is generated and its vector is correct.
- * o the interrupt goes away when the IIR in the UART is read.
- */
-/* EXTRA DELAY? */
- failures[0] = inb(iobase + com_cfcr) - CFCR_8BITS;
- failures[1] = inb(iobase + com_ier) - IER_ETXRDY;
- failures[2] = inb(iobase + com_mcr) - mcr_image;
- DELAY(10000); /* Some internal modems need this time */
- irqmap[1] = isa_irq_pending();
- failures[4] = (inb(iobase + com_iir) & IIR_IMASK) - IIR_TXRDY;
- DELAY(1000); /* XXX */
- irqmap[2] = isa_irq_pending();
- failures[6] = (inb(iobase + com_iir) & IIR_IMASK) - IIR_NOPEND;
-
- /*
- * Turn off all device interrupts and check that they go off properly.
- * Leave MCR_IENABLE alone. For ports without a master port, it gates
- * the OUT2 output of the UART to
- * the ICU input. Closing the gate would give a floating ICU input
- * (unless there is another device driving it) and spurious interrupts.
- * (On the system that this was first tested on, the input floats high
- * and gives a (masked) interrupt as soon as the gate is closed.)
- */
- outb(iobase + com_ier, 0);
- outb(iobase + com_cfcr, CFCR_8BITS); /* dummy to avoid bus echo */
- failures[7] = inb(iobase + com_ier);
- DELAY(1000); /* XXX */
- irqmap[3] = isa_irq_pending();
- failures[9] = (inb(iobase + com_iir) & IIR_IMASK) - IIR_NOPEND;
-
- enable_intr();
-
- irqs = irqmap[1] & ~irqmap[0];
- if (bus_get_resource(idev, SYS_RES_IRQ, 0, &xirq, NULL) == 0 &&
- ((1 << xirq) & irqs) == 0)
- printf(
- "sio%d: configured irq %ld not in bitmap of probed irqs %#x\n",
- device_get_unit(dev), xirq, irqs);
- if (bootverbose)
- printf("sio%d: irq maps: %#x %#x %#x %#x\n",
- device_get_unit(dev),
- irqmap[0], irqmap[1], irqmap[2], irqmap[3]);
-
- result = 0;
- for (fn = 0; fn < sizeof failures; ++fn)
- if (failures[fn]) {
- outb(iobase + com_mcr, 0);
- result = ENXIO;
- if (bootverbose) {
- printf("sio%d: probe failed test(s):",
- device_get_unit(dev));
- for (fn = 0; fn < sizeof failures; ++fn)
- if (failures[fn])
- printf(" %d", fn);
- printf("\n");
- }
- break;
- }
- bus_release_resource(dev, SYS_RES_IOPORT, rid, port);
- return (iobase == siocniobase ? 0 : result);
-}
-
-#ifdef COM_ESP
-static int
-espattach(com, esp_port)
- struct com_s *com;
- Port_t esp_port;
-{
- u_char dips;
- u_char val;
-
- /*
- * Check the ESP-specific I/O port to see if we're an ESP
- * card. If not, return failure immediately.
- */
- if ((inb(esp_port) & 0xf3) == 0) {
- printf(" port 0x%x is not an ESP board?\n", esp_port);
- return (0);
- }
-
- /*
- * We've got something that claims to be a Hayes ESP card.
- * Let's hope so.
- */
-
- /* Get the dip-switch configuration */
- outb(esp_port + ESP_CMD1, ESP_GETDIPS);
- dips = inb(esp_port + ESP_STATUS1);
-
- /*
- * Bits 0,1 of dips say which COM port we are.
- */
- if (com->iobase == likely_com_ports[dips & 0x03])
- printf(" : ESP");
- else {
- printf(" esp_port has com %d\n", dips & 0x03);
- return (0);
- }
-
- /*
- * Check for ESP version 2.0 or later: bits 4,5,6 = 010.
- */
- outb(esp_port + ESP_CMD1, ESP_GETTEST);
- val = inb(esp_port + ESP_STATUS1); /* clear reg 1 */
- val = inb(esp_port + ESP_STATUS2);
- if ((val & 0x70) < 0x20) {
- printf("-old (%o)", val & 0x70);
- return (0);
- }
-
- /*
- * Check for ability to emulate 16550: bit 7 == 1
- */
- if ((dips & 0x80) == 0) {
- printf(" slave");
- return (0);
- }
-
- /*
- * Okay, we seem to be a Hayes ESP card. Whee.
- */
- com->esp = TRUE;
- com->esp_port = esp_port;
- return (1);
-}
-#endif /* COM_ESP */
-
-static int
-sio_isa_attach(dev)
- device_t dev;
-{
- return (sioattach(dev));
-}
-
-static int
-sioattach(dev)
- device_t dev;
-{
- struct com_s *com;
-#ifdef COM_ESP
- Port_t *espp;
-#endif
- Port_t iobase;
- int unit;
- u_int flags;
- int rid;
- struct resource *port;
- int ret;
-
- rid = 0;
- port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
- 0, ~0, IO_COMSIZE, RF_ACTIVE);
- if (!port)
- return (ENXIO);
-
- iobase = rman_get_start(port);
- unit = device_get_unit(dev);
- com = device_get_softc(dev);
- flags = device_get_flags(dev);
-
- if (unit >= sio_numunits)
- sio_numunits = unit + 1;
- /*
- * sioprobe() has initialized the device registers as follows:
- * o cfcr = CFCR_8BITS.
- * It is most important that CFCR_DLAB is off, so that the
- * data port is not hidden when we enable interrupts.
- * o ier = 0.
- * Interrupts are only enabled when the line is open.
- * o mcr = MCR_IENABLE, or 0 if the port has AST/4 compatible
- * interrupt control register or the config specifies no irq.
- * Keeping MCR_DTR and MCR_RTS off might stop the external
- * device from sending before we are ready.
- */
- bzero(com, sizeof *com);
- com->unit = unit;
- com->ioportres = port;
- com->cfcr_image = CFCR_8BITS;
- com->dtr_wait = 3 * hz;
- com->loses_outints = COM_LOSESOUTINTS(flags) != 0;
- com->no_irq = bus_get_resource(dev, SYS_RES_IRQ, 0, NULL, NULL) != 0;
- com->tx_fifo_size = 1;
- com->obufs[0].l_head = com->obuf1;
- com->obufs[1].l_head = com->obuf2;
-
- com->iobase = iobase;
- com->data_port = iobase + com_data;
- com->int_id_port = iobase + com_iir;
- com->modem_ctl_port = iobase + com_mcr;
- com->mcr_image = inb(com->modem_ctl_port);
- com->line_status_port = iobase + com_lsr;
- com->modem_status_port = iobase + com_msr;
- com->intr_ctl_port = iobase + com_ier;
-
- /*
- * We don't use all the flags from <sys/ttydefaults.h> since they
- * are only relevant for logins. It's important to have echo off
- * initially so that the line doesn't start blathering before the
- * echo flag can be turned off.
- */
- com->it_in.c_iflag = 0;
- com->it_in.c_oflag = 0;
- com->it_in.c_cflag = TTYDEF_CFLAG;
- com->it_in.c_lflag = 0;
- if (unit == comconsole) {
- com->it_in.c_iflag = TTYDEF_IFLAG;
- com->it_in.c_oflag = TTYDEF_OFLAG;
- com->it_in.c_cflag = TTYDEF_CFLAG | CLOCAL;
- com->it_in.c_lflag = TTYDEF_LFLAG;
- com->lt_out.c_cflag = com->lt_in.c_cflag = CLOCAL;
- com->lt_out.c_ispeed = com->lt_out.c_ospeed =
- com->lt_in.c_ispeed = com->lt_in.c_ospeed =
- com->it_in.c_ispeed = com->it_in.c_ospeed = comdefaultrate;
- } else
- com->it_in.c_ispeed = com->it_in.c_ospeed = TTYDEF_SPEED;
- if (siosetwater(com, com->it_in.c_ispeed) != 0) {
- enable_intr();
- /*
- * Leave i/o resources allocated if this is a `cn'-level
- * console, so that other devices can't snarf them.
- */
- if (iobase != siocniobase)
- bus_release_resource(dev, SYS_RES_IOPORT, rid, port);
- return (ENOMEM);
- }
- enable_intr();
- termioschars(&com->it_in);
- com->it_out = com->it_in;
-
- /* attempt to determine UART type */
- printf("sio%d: type", unit);
-
-
-#ifdef COM_MULTIPORT
- if (!COM_ISMULTIPORT(flags) && !COM_IIR_TXRDYBUG(flags))
-#else
- if (!COM_IIR_TXRDYBUG(flags))
-#endif
- {
- u_char scr;
- u_char scr1;
- u_char scr2;
-
- scr = inb(iobase + com_scr);
- outb(iobase + com_scr, 0xa5);
- scr1 = inb(iobase + com_scr);
- outb(iobase + com_scr, 0x5a);
- scr2 = inb(iobase + com_scr);
- outb(iobase + com_scr, scr);
- if (scr1 != 0xa5 || scr2 != 0x5a) {
- printf(" 8250");
- goto determined_type;
- }
- }
- outb(iobase + com_fifo, FIFO_ENABLE | FIFO_RX_HIGH);
- DELAY(100);
- com->st16650a = 0;
- switch (inb(com->int_id_port) & IIR_FIFO_MASK) {
- case FIFO_RX_LOW:
- printf(" 16450");
- break;
- case FIFO_RX_MEDL:
- printf(" 16450?");
- break;
- case FIFO_RX_MEDH:
- printf(" 16550?");
- break;
- case FIFO_RX_HIGH:
- if (COM_NOFIFO(flags)) {
- printf(" 16550A fifo disabled");
- } else {
- com->hasfifo = TRUE;
- if (COM_ST16650A(flags)) {
- com->st16650a = 1;
- com->tx_fifo_size = 32;
- printf(" ST16650A");
- } else {
- com->tx_fifo_size = COM_FIFOSIZE(flags);
- printf(" 16550A");
- }
- }
-#ifdef COM_ESP
- for (espp = likely_esp_ports; *espp != 0; espp++)
- if (espattach(com, *espp)) {
- com->tx_fifo_size = 1024;
- break;
- }
-#endif
- if (!com->st16650a) {
- if (!com->tx_fifo_size)
- com->tx_fifo_size = 16;
- else
- printf(" lookalike with %d bytes FIFO",
- com->tx_fifo_size);
- }
-
- break;
- }
-
-#ifdef COM_ESP
- if (com->esp) {
- /*
- * Set 16550 compatibility mode.
- * We don't use the ESP_MODE_SCALE bit to increase the
- * fifo trigger levels because we can't handle large
- * bursts of input.
- * XXX flow control should be set in comparam(), not here.
- */
- outb(com->esp_port + ESP_CMD1, ESP_SETMODE);
- outb(com->esp_port + ESP_CMD2, ESP_MODE_RTS | ESP_MODE_FIFO);
-
- /* Set RTS/CTS flow control. */
- outb(com->esp_port + ESP_CMD1, ESP_SETFLOWTYPE);
- outb(com->esp_port + ESP_CMD2, ESP_FLOW_RTS);
- outb(com->esp_port + ESP_CMD2, ESP_FLOW_CTS);
-
- /* Set flow-control levels. */
- outb(com->esp_port + ESP_CMD1, ESP_SETRXFLOW);
- outb(com->esp_port + ESP_CMD2, HIBYTE(768));
- outb(com->esp_port + ESP_CMD2, LOBYTE(768));
- outb(com->esp_port + ESP_CMD2, HIBYTE(512));
- outb(com->esp_port + ESP_CMD2, LOBYTE(512));
- }
-#endif /* COM_ESP */
- outb(iobase + com_fifo, 0);
-determined_type: ;
-
-#ifdef COM_MULTIPORT
- if (COM_ISMULTIPORT(flags)) {
- device_t masterdev;
-
- com->multiport = TRUE;
- printf(" (multiport");
- if (unit == COM_MPMASTER(flags))
- printf(" master");
- printf(")");
- masterdev = devclass_get_device(sio_devclass,
- COM_MPMASTER(flags));
- com->no_irq = (masterdev == NULL || bus_get_resource(masterdev,
- SYS_RES_IRQ, 0, NULL, NULL) != 0);
- }
-#endif /* COM_MULTIPORT */
- if (unit == comconsole)
- printf(", console");
- if (COM_IIR_TXRDYBUG(flags))
- printf(" with a bogus IIR_TXRDY register");
- printf("\n");
-
- if (!sio_registered) {
- register_swi(SWI_TTY, siopoll);
- sio_registered = TRUE;
- }
- make_dev(&sio_cdevsw, unit,
- UID_ROOT, GID_WHEEL, 0600, "ttyd%r", unit);
- make_dev(&sio_cdevsw, unit | CONTROL_INIT_STATE,
- UID_ROOT, GID_WHEEL, 0600, "ttyid%r", unit);
- make_dev(&sio_cdevsw, unit | CONTROL_LOCK_STATE,
- UID_ROOT, GID_WHEEL, 0600, "ttyld%r", unit);
- make_dev(&sio_cdevsw, unit | CALLOUT_MASK,
- UID_UUCP, GID_DIALER, 0660, "cuaa%r", unit);
- make_dev(&sio_cdevsw, unit | CALLOUT_MASK | CONTROL_INIT_STATE,
- UID_UUCP, GID_DIALER, 0660, "cuaia%r", unit);
- make_dev(&sio_cdevsw, unit | CALLOUT_MASK | CONTROL_LOCK_STATE,
- UID_UUCP, GID_DIALER, 0660, "cuala%r", unit);
- com->flags = flags;
- com->pps.ppscap = PPS_CAPTUREASSERT | PPS_CAPTURECLEAR;
- pps_init(&com->pps);
-
- rid = 0;
- com->irqres = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0ul, ~0ul, 1,
- RF_ACTIVE);
- if (com->irqres) {
- ret = BUS_SETUP_INTR(device_get_parent(dev), dev, com->irqres,
- INTR_TYPE_TTY | INTR_TYPE_FAST,
- siointr, com, &com->cookie);
- if (ret) {
- ret = BUS_SETUP_INTR(device_get_parent(dev), dev,
- com->irqres, INTR_TYPE_TTY,
- siointr, com, &com->cookie);
- if (ret == 0)
- device_printf(dev, "unable to activate interrupt in fast mode - using normal mode");
- }
- if (ret)
- device_printf(dev, "could not activate interrupt\n");
- }
-
- return (0);
-}
-
-static int
-sioopen(dev, flag, mode, p)
- dev_t dev;
- int flag;
- int mode;
- struct proc *p;
-{
- struct com_s *com;
- int error;
- Port_t iobase;
- int mynor;
- int s;
- struct tty *tp;
- int unit;
-
- mynor = minor(dev);
- unit = MINOR_TO_UNIT(mynor);
- com = com_addr(unit);
- if (com == NULL)
- return (ENXIO);
- if (com->gone)
- return (ENXIO);
- if (mynor & CONTROL_MASK)
- return (0);
- tp = dev->si_tty = com->tp = ttymalloc(com->tp);
- s = spltty();
- /*
- * We jump to this label after all non-interrupted sleeps to pick
- * up any changes of the device state.
- */
-open_top:
- while (com->state & CS_DTR_OFF) {
- error = tsleep(&com->dtr_wait, TTIPRI | PCATCH, "siodtr", 0);
- if (com_addr(unit) == NULL)
- return (ENXIO);
- if (error != 0 || com->gone)
- goto out;
- }
- if (tp->t_state & TS_ISOPEN) {
- /*
- * The device is open, so everything has been initialized.
- * Handle conflicts.
- */
- if (mynor & CALLOUT_MASK) {
- if (!com->active_out) {
- error = EBUSY;
- goto out;
- }
- } else {
- if (com->active_out) {
- if (flag & O_NONBLOCK) {
- error = EBUSY;
- goto out;
- }
- error = tsleep(&com->active_out,
- TTIPRI | PCATCH, "siobi", 0);
- if (com_addr(unit) == NULL)
- return (ENXIO);
- if (error != 0 || com->gone)
- goto out;
- goto open_top;
- }
- }
- if (tp->t_state & TS_XCLUDE &&
- suser(p)) {
- error = EBUSY;
- goto out;
- }
- } else {
- /*
- * The device isn't open, so there are no conflicts.
- * Initialize it. Initialization is done twice in many
- * cases: to preempt sleeping callin opens if we are
- * callout, and to complete a callin open after DCD rises.
- */
- tp->t_oproc = comstart;
- tp->t_param = comparam;
- tp->t_stop = comstop;
- tp->t_dev = dev;
- tp->t_termios = mynor & CALLOUT_MASK
- ? com->it_out : com->it_in;
- (void)commctl(com, TIOCM_DTR | TIOCM_RTS, DMSET);
- com->poll = com->no_irq;
- com->poll_output = com->loses_outints;
- ++com->wopeners;
- error = comparam(tp, &tp->t_termios);
- --com->wopeners;
- if (error != 0)
- goto out;
- /*
- * XXX we should goto open_top if comparam() slept.
- */
- iobase = com->iobase;
- if (com->hasfifo) {
- /*
- * (Re)enable and drain fifos.
- *
- * Certain SMC chips cause problems if the fifos
- * are enabled while input is ready. Turn off the
- * fifo if necessary to clear the input. We test
- * the input ready bit after enabling the fifos
- * since we've already enabled them in comparam()
- * and to handle races between enabling and fresh
- * input.
- */
- while (TRUE) {
- outb(iobase + com_fifo,
- FIFO_RCV_RST | FIFO_XMT_RST
- | com->fifo_image);
- /*
- * XXX the delays are for superstitious
- * historical reasons. It must be less than
- * the character time at the maximum
- * supported speed (87 usec at 115200 bps
- * 8N1). Otherwise we might loop endlessly
- * if data is streaming in. We used to use
- * delays of 100. That usually worked
- * because DELAY(100) used to usually delay
- * for about 85 usec instead of 100.
- */
- DELAY(50);
- if (!(inb(com->line_status_port) & LSR_RXRDY))
- break;
- outb(iobase + com_fifo, 0);
- DELAY(50);
- (void) inb(com->data_port);
- }
- }
-
- disable_intr();
- (void) inb(com->line_status_port);
- (void) inb(com->data_port);
- com->prev_modem_status = com->last_modem_status
- = inb(com->modem_status_port);
- if (COM_IIR_TXRDYBUG(com->flags)) {
- outb(com->intr_ctl_port, IER_ERXRDY | IER_ERLS
- | IER_EMSC);
- } else {
- outb(com->intr_ctl_port, IER_ERXRDY | IER_ETXRDY
- | IER_ERLS | IER_EMSC);
- }
- enable_intr();
- /*
- * Handle initial DCD. Callout devices get a fake initial
- * DCD (trapdoor DCD). If we are callout, then any sleeping
- * callin opens get woken up and resume sleeping on "siobi"
- * instead of "siodcd".
- */
- /*
- * XXX `mynor & CALLOUT_MASK' should be
- * `tp->t_cflag & (SOFT_CARRIER | TRAPDOOR_CARRIER) where
- * TRAPDOOR_CARRIER is the default initial state for callout
- * devices and SOFT_CARRIER is like CLOCAL except it hides
- * the true carrier.
- */
- if (com->prev_modem_status & MSR_DCD || mynor & CALLOUT_MASK)
- (*linesw[tp->t_line].l_modem)(tp, 1);
- }
- /*
- * Wait for DCD if necessary.
- */
- if (!(tp->t_state & TS_CARR_ON) && !(mynor & CALLOUT_MASK)
- && !(tp->t_cflag & CLOCAL) && !(flag & O_NONBLOCK)) {
- ++com->wopeners;
- error = tsleep(TSA_CARR_ON(tp), TTIPRI | PCATCH, "siodcd", 0);
- if (com_addr(unit) == NULL)
- return (ENXIO);
- --com->wopeners;
- if (error != 0 || com->gone)
- goto out;
- goto open_top;
- }
- error = (*linesw[tp->t_line].l_open)(dev, tp);
- disc_optim(tp, &tp->t_termios, com);
- if (tp->t_state & TS_ISOPEN && mynor & CALLOUT_MASK)
- com->active_out = TRUE;
- siosettimeout();
-out:
- splx(s);
- if (!(tp->t_state & TS_ISOPEN) && com->wopeners == 0)
- comhardclose(com);
- return (error);
-}
-
-static int
-sioclose(dev, flag, mode, p)
- dev_t dev;
- int flag;
- int mode;
- struct proc *p;
-{
- struct com_s *com;
- int mynor;
- int s;
- struct tty *tp;
-
- mynor = minor(dev);
- if (mynor & CONTROL_MASK)
- return (0);
- com = com_addr(MINOR_TO_UNIT(mynor));
- if (com == NULL)
- return (ENODEV);
- tp = com->tp;
- s = spltty();
- (*linesw[tp->t_line].l_close)(tp, flag);
- disc_optim(tp, &tp->t_termios, com);
- comstop(tp, FREAD | FWRITE);
- comhardclose(com);
- ttyclose(tp);
- siosettimeout();
- splx(s);
- if (com->gone) {
- printf("sio%d: gone\n", com->unit);
- s = spltty();
- if (com->ibuf != NULL)
- free(com->ibuf, M_DEVBUF);
- bzero(tp, sizeof *tp);
- splx(s);
- }
- return (0);
-}
-
-static void
-comhardclose(com)
- struct com_s *com;
-{
- Port_t iobase;
- int s;
- struct tty *tp;
- int unit;
-
- unit = com->unit;
- iobase = com->iobase;
- s = spltty();
- com->poll = FALSE;
- com->poll_output = FALSE;
- com->do_timestamp = FALSE;
- com->do_dcd_timestamp = FALSE;
- com->pps.ppsparam.mode = 0;
- outb(iobase + com_cfcr, com->cfcr_image &= ~CFCR_SBREAK);
- {
- outb(iobase + com_ier, 0);
- tp = com->tp;
- if (tp->t_cflag & HUPCL
- /*
- * XXX we will miss any carrier drop between here and the
- * next open. Perhaps we should watch DCD even when the
- * port is closed; it is not sufficient to check it at
- * the next open because it might go up and down while
- * we're not watching.
- */
- || (!com->active_out
- && !(com->prev_modem_status & MSR_DCD)
- && !(com->it_in.c_cflag & CLOCAL))
- || !(tp->t_state & TS_ISOPEN)) {
- (void)commctl(com, TIOCM_DTR, DMBIC);
- if (com->dtr_wait != 0 && !(com->state & CS_DTR_OFF)) {
- timeout(siodtrwakeup, com, com->dtr_wait);
- com->state |= CS_DTR_OFF;
- }
- }
- }
- if (com->hasfifo) {
- /*
- * Disable fifos so that they are off after controlled
- * reboots. Some BIOSes fail to detect 16550s when the
- * fifos are enabled.
- */
- outb(iobase + com_fifo, 0);
- }
- com->active_out = FALSE;
- wakeup(&com->active_out);
- wakeup(TSA_CARR_ON(tp)); /* restart any wopeners */
- splx(s);
-}
-
-static int
-sioread(dev, uio, flag)
- dev_t dev;
- struct uio *uio;
- int flag;
-{
- int mynor;
- struct com_s *com;
-
- mynor = minor(dev);
- if (mynor & CONTROL_MASK)
- return (ENODEV);
- com = com_addr(MINOR_TO_UNIT(mynor));
- if (com == NULL || com->gone)
- return (ENODEV);
- return ((*linesw[com->tp->t_line].l_read)(com->tp, uio, flag));
-}
-
-static int
-siowrite(dev, uio, flag)
- dev_t dev;
- struct uio *uio;
- int flag;
-{
- int mynor;
- struct com_s *com;
- int unit;
-
- mynor = minor(dev);
- if (mynor & CONTROL_MASK)
- return (ENODEV);
-
- unit = MINOR_TO_UNIT(mynor);
- com = com_addr(unit);
- if (com == NULL || com->gone)
- return (ENODEV);
- /*
- * (XXX) We disallow virtual consoles if the physical console is
- * a serial port. This is in case there is a display attached that
- * is not the console. In that situation we don't need/want the X
- * server taking over the console.
- */
- if (constty != NULL && unit == comconsole)
- constty = NULL;
- return ((*linesw[com->tp->t_line].l_write)(com->tp, uio, flag));
-}
-
-static void
-siobusycheck(chan)
- void *chan;
-{
- struct com_s *com;
- int s;
-
- com = (struct com_s *)chan;
-
- /*
- * Clear TS_BUSY if low-level output is complete.
- * spl locking is sufficient because siointr1() does not set CS_BUSY.
- * If siointr1() clears CS_BUSY after we look at it, then we'll get
- * called again. Reading the line status port outside of siointr1()
- * is safe because CS_BUSY is clear so there are no output interrupts
- * to lose.
- */
- s = spltty();
- if (com->state & CS_BUSY)
- com->extra_state &= ~CSE_BUSYCHECK; /* False alarm. */
- else if ((inb(com->line_status_port) & (LSR_TSRE | LSR_TXRDY))
- == (LSR_TSRE | LSR_TXRDY)) {
- com->tp->t_state &= ~TS_BUSY;
- ttwwakeup(com->tp);
- com->extra_state &= ~CSE_BUSYCHECK;
- } else
- timeout(siobusycheck, com, hz / 100);
- splx(s);
-}
-
-static void
-siodtrwakeup(chan)
- void *chan;
-{
- struct com_s *com;
-
- com = (struct com_s *)chan;
- com->state &= ~CS_DTR_OFF;
- wakeup(&com->dtr_wait);
-}
-
-static void
-sioinput(com)
- struct com_s *com;
-{
- u_char *buf;
- int incc;
- u_char line_status;
- int recv_data;
- struct tty *tp;
-
- buf = com->ibuf;
- tp = com->tp;
- if (!(tp->t_state & TS_ISOPEN) || !(tp->t_cflag & CREAD)) {
- com_events -= (com->iptr - com->ibuf);
- com->iptr = com->ibuf;
- return;
- }
- if (tp->t_state & TS_CAN_BYPASS_L_RINT) {
- /*
- * Avoid the grotesquely inefficient lineswitch routine
- * (ttyinput) in "raw" mode. It usually takes about 450
- * instructions (that's without canonical processing or echo!).
- * slinput is reasonably fast (usually 40 instructions plus
- * call overhead).
- */
- do {
- enable_intr();
- incc = com->iptr - buf;
- if (tp->t_rawq.c_cc + incc > tp->t_ihiwat
- && (com->state & CS_RTS_IFLOW
- || tp->t_iflag & IXOFF)
- && !(tp->t_state & TS_TBLOCK))
- ttyblock(tp);
- com->delta_error_counts[CE_TTY_BUF_OVERFLOW]
- += b_to_q((char *)buf, incc, &tp->t_rawq);
- buf += incc;
- tk_nin += incc;
- tk_rawcc += incc;
- tp->t_rawcc += incc;
- ttwakeup(tp);
- if (tp->t_state & TS_TTSTOP
- && (tp->t_iflag & IXANY
- || tp->t_cc[VSTART] == tp->t_cc[VSTOP])) {
- tp->t_state &= ~TS_TTSTOP;
- tp->t_lflag &= ~FLUSHO;
- comstart(tp);
- }
- disable_intr();
- } while (buf < com->iptr);
- } else {
- do {
- enable_intr();
- line_status = buf[com->ierroff];
- recv_data = *buf++;
- if (line_status
- & (LSR_BI | LSR_FE | LSR_OE | LSR_PE)) {
- if (line_status & LSR_BI)
- recv_data |= TTY_BI;
- if (line_status & LSR_FE)
- recv_data |= TTY_FE;
- if (line_status & LSR_OE)
- recv_data |= TTY_OE;
- if (line_status & LSR_PE)
- recv_data |= TTY_PE;
- }
- (*linesw[tp->t_line].l_rint)(recv_data, tp);
- disable_intr();
- } while (buf < com->iptr);
- }
- com_events -= (com->iptr - com->ibuf);
- com->iptr = com->ibuf;
-
- /*
- * There is now room for another low-level buffer full of input,
- * so enable RTS if it is now disabled and there is room in the
- * high-level buffer.
- */
- if ((com->state & CS_RTS_IFLOW) && !(com->mcr_image & MCR_RTS) &&
- !(tp->t_state & TS_TBLOCK))
- outb(com->modem_ctl_port, com->mcr_image |= MCR_RTS);
-}
-
-void
-siointr(arg)
- void *arg;
-{
-#ifndef COM_MULTIPORT
- COM_LOCK();
- siointr1((struct com_s *) arg);
- COM_UNLOCK();
-#else /* COM_MULTIPORT */
- bool_t possibly_more_intrs;
- int unit;
- struct com_s *com;
-
- /*
- * Loop until there is no activity on any port. This is necessary
- * to get an interrupt edge more than to avoid another interrupt.
- * If the IRQ signal is just an OR of the IRQ signals from several
- * devices, then the edge from one may be lost because another is
- * on.
- */
- COM_LOCK();
- do {
- possibly_more_intrs = FALSE;
- for (unit = 0; unit < sio_numunits; ++unit) {
- com = com_addr(unit);
- /*
- * XXX COM_LOCK();
- * would it work here, or be counter-productive?
- */
- if (com != NULL
- && !com->gone
- && (inb(com->int_id_port) & IIR_IMASK)
- != IIR_NOPEND) {
- siointr1(com);
- possibly_more_intrs = TRUE;
- }
- /* XXX COM_UNLOCK(); */
- }
- } while (possibly_more_intrs);
- COM_UNLOCK();
-#endif /* COM_MULTIPORT */
-}
-
-static void
-siointr1(com)
- struct com_s *com;
-{
- u_char line_status;
- u_char modem_status;
- u_char *ioptr;
- u_char recv_data;
- u_char int_ctl;
- u_char int_ctl_new;
- struct timecounter *tc;
- u_int count;
-
- int_ctl = inb(com->intr_ctl_port);
- int_ctl_new = int_ctl;
-
- while (!com->gone) {
- if (com->pps.ppsparam.mode & PPS_CAPTUREBOTH) {
- modem_status = inb(com->modem_status_port);
- if ((modem_status ^ com->last_modem_status) & MSR_DCD) {
- tc = timecounter;
- count = tc->tc_get_timecount(tc);
- pps_event(&com->pps, tc, count,
- (modem_status & MSR_DCD) ?
- PPS_CAPTUREASSERT : PPS_CAPTURECLEAR);
- }
- }
- line_status = inb(com->line_status_port);
-
- /* input event? (check first to help avoid overruns) */
- while (line_status & LSR_RCV_MASK) {
- /* break/unnattached error bits or real input? */
- if (!(line_status & LSR_RXRDY))
- recv_data = 0;
- else
- recv_data = inb(com->data_port);
- if (line_status & (LSR_BI | LSR_FE | LSR_PE)) {
- /*
- * Don't store BI if IGNBRK or FE/PE if IGNPAR.
- * Otherwise, push the work to a higher level
- * (to handle PARMRK) if we're bypassing.
- * Otherwise, convert BI/FE and PE+INPCK to 0.
- *
- * This makes bypassing work right in the
- * usual "raw" case (IGNBRK set, and IGNPAR
- * and INPCK clear).
- *
- * Note: BI together with FE/PE means just BI.
- */
- if (line_status & LSR_BI) {
-#if defined(DDB) && defined(BREAK_TO_DEBUGGER)
- if (com->unit == comconsole) {
- breakpoint();
- goto cont;
- }
-#endif
- if (com->tp == NULL
- || com->tp->t_iflag & IGNBRK)
- goto cont;
- } else {
- if (com->tp == NULL
- || com->tp->t_iflag & IGNPAR)
- goto cont;
- }
- if (com->tp->t_state & TS_CAN_BYPASS_L_RINT
- && (line_status & (LSR_BI | LSR_FE)
- || com->tp->t_iflag & INPCK))
- recv_data = 0;
- }
- ++com->bytes_in;
- if (com->hotchar != 0 && recv_data == com->hotchar)
- setsofttty();
- ioptr = com->iptr;
- if (ioptr >= com->ibufend)
- CE_RECORD(com, CE_INTERRUPT_BUF_OVERFLOW);
- else {
- if (com->do_timestamp)
- microtime(&com->timestamp);
- ++com_events;
- schedsofttty();
-#if 0 /* for testing input latency vs efficiency */
-if (com->iptr - com->ibuf == 8)
- setsofttty();
-#endif
- ioptr[0] = recv_data;
- ioptr[com->ierroff] = line_status;
- com->iptr = ++ioptr;
- if (ioptr == com->ihighwater
- && com->state & CS_RTS_IFLOW)
- outb(com->modem_ctl_port,
- com->mcr_image &= ~MCR_RTS);
- if (line_status & LSR_OE)
- CE_RECORD(com, CE_OVERRUN);
- }
-cont:
- /*
- * "& 0x7F" is to avoid the gcc-1.40 generating a slow
- * jump from the top of the loop to here
- */
- line_status = inb(com->line_status_port) & 0x7F;
- }
-
- /* modem status change? (always check before doing output) */
- modem_status = inb(com->modem_status_port);
- if (modem_status != com->last_modem_status) {
- if (com->do_dcd_timestamp
- && !(com->last_modem_status & MSR_DCD)
- && modem_status & MSR_DCD)
- microtime(&com->dcd_timestamp);
-
- /*
- * Schedule high level to handle DCD changes. Note
- * that we don't use the delta bits anywhere. Some
- * UARTs mess them up, and it's easy to remember the
- * previous bits and calculate the delta.
- */
- com->last_modem_status = modem_status;
- if (!(com->state & CS_CHECKMSR)) {
- com_events += LOTS_OF_EVENTS;
- com->state |= CS_CHECKMSR;
- setsofttty();
- }
-
- /* handle CTS change immediately for crisp flow ctl */
- if (com->state & CS_CTS_OFLOW) {
- if (modem_status & MSR_CTS)
- com->state |= CS_ODEVREADY;
- else
- com->state &= ~CS_ODEVREADY;
- }
- }
-
- /* output queued and everything ready? */
- if (line_status & LSR_TXRDY
- && com->state >= (CS_BUSY | CS_TTGO | CS_ODEVREADY)) {
- ioptr = com->obufq.l_head;
- if (com->tx_fifo_size > 1) {
- u_int ocount;
-
- ocount = com->obufq.l_tail - ioptr;
- if (ocount > com->tx_fifo_size)
- ocount = com->tx_fifo_size;
- com->bytes_out += ocount;
- do
- outb(com->data_port, *ioptr++);
- while (--ocount != 0);
- } else {
- outb(com->data_port, *ioptr++);
- ++com->bytes_out;
- }
- com->obufq.l_head = ioptr;
- if (COM_IIR_TXRDYBUG(com->flags)) {
- int_ctl_new = int_ctl | IER_ETXRDY;
- }
- if (ioptr >= com->obufq.l_tail) {
- struct lbq *qp;
-
- qp = com->obufq.l_next;
- qp->l_queued = FALSE;
- qp = qp->l_next;
- if (qp != NULL) {
- com->obufq.l_head = qp->l_head;
- com->obufq.l_tail = qp->l_tail;
- com->obufq.l_next = qp;
- } else {
- /* output just completed */
- if (COM_IIR_TXRDYBUG(com->flags)) {
- int_ctl_new = int_ctl & ~IER_ETXRDY;
- }
- com->state &= ~CS_BUSY;
- }
- if (!(com->state & CS_ODONE)) {
- com_events += LOTS_OF_EVENTS;
- com->state |= CS_ODONE;
- setsofttty(); /* handle at high level ASAP */
- }
- }
- if (COM_IIR_TXRDYBUG(com->flags) && (int_ctl != int_ctl_new)) {
- outb(com->intr_ctl_port, int_ctl_new);
- }
- }
-
- /* finished? */
-#ifndef COM_MULTIPORT
- if ((inb(com->int_id_port) & IIR_IMASK) == IIR_NOPEND)
-#endif /* COM_MULTIPORT */
- return;
- }
-}
-
-static int
-sioioctl(dev, cmd, data, flag, p)
- dev_t dev;
- u_long cmd;
- caddr_t data;
- int flag;
- struct proc *p;
-{
- struct com_s *com;
- int error;
- Port_t iobase;
- int mynor;
- int s;
- struct tty *tp;
-#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
- u_long oldcmd;
- struct termios term;
-#endif
-
- mynor = minor(dev);
- com = com_addr(MINOR_TO_UNIT(mynor));
- if (com == NULL || com->gone)
- return (ENODEV);
- iobase = com->iobase;
- if (mynor & CONTROL_MASK) {
- struct termios *ct;
-
- switch (mynor & CONTROL_MASK) {
- case CONTROL_INIT_STATE:
- ct = mynor & CALLOUT_MASK ? &com->it_out : &com->it_in;
- break;
- case CONTROL_LOCK_STATE:
- ct = mynor & CALLOUT_MASK ? &com->lt_out : &com->lt_in;
- break;
- default:
- return (ENODEV); /* /dev/nodev */
- }
- switch (cmd) {
- case TIOCSETA:
- error = suser(p);
- if (error != 0)
- return (error);
- *ct = *(struct termios *)data;
- return (0);
- case TIOCGETA:
- *(struct termios *)data = *ct;
- return (0);
- case TIOCGETD:
- *(int *)data = TTYDISC;
- return (0);
- case TIOCGWINSZ:
- bzero(data, sizeof(struct winsize));
- return (0);
- default:
- return (ENOTTY);
- }
- }
- tp = com->tp;
-#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
- term = tp->t_termios;
- oldcmd = cmd;
- error = ttsetcompat(tp, &cmd, data, &term);
- if (error != 0)
- return (error);
- if (cmd != oldcmd)
- data = (caddr_t)&term;
-#endif
- if (cmd == TIOCSETA || cmd == TIOCSETAW || cmd == TIOCSETAF) {
- int cc;
- struct termios *dt = (struct termios *)data;
- struct termios *lt = mynor & CALLOUT_MASK
- ? &com->lt_out : &com->lt_in;
-
- dt->c_iflag = (tp->t_iflag & lt->c_iflag)
- | (dt->c_iflag & ~lt->c_iflag);
- dt->c_oflag = (tp->t_oflag & lt->c_oflag)
- | (dt->c_oflag & ~lt->c_oflag);
- dt->c_cflag = (tp->t_cflag & lt->c_cflag)
- | (dt->c_cflag & ~lt->c_cflag);
- dt->c_lflag = (tp->t_lflag & lt->c_lflag)
- | (dt->c_lflag & ~lt->c_lflag);
- for (cc = 0; cc < NCCS; ++cc)
- if (lt->c_cc[cc] != 0)
- dt->c_cc[cc] = tp->t_cc[cc];
- if (lt->c_ispeed != 0)
- dt->c_ispeed = tp->t_ispeed;
- if (lt->c_ospeed != 0)
- dt->c_ospeed = tp->t_ospeed;
- }
- error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p);
- if (error != ENOIOCTL)
- return (error);
- s = spltty();
- error = ttioctl(tp, cmd, data, flag);
- disc_optim(tp, &tp->t_termios, com);
- if (error != ENOIOCTL) {
- splx(s);
- return (error);
- }
- switch (cmd) {
- case TIOCSBRK:
- outb(iobase + com_cfcr, com->cfcr_image |= CFCR_SBREAK);
- break;
- case TIOCCBRK:
- outb(iobase + com_cfcr, com->cfcr_image &= ~CFCR_SBREAK);
- break;
- case TIOCSDTR:
- (void)commctl(com, TIOCM_DTR, DMBIS);
- break;
- case TIOCCDTR:
- (void)commctl(com, TIOCM_DTR, DMBIC);
- break;
- /*
- * XXX should disallow changing MCR_RTS if CS_RTS_IFLOW is set. The
- * changes get undone on the next call to comparam().
- */
- case TIOCMSET:
- (void)commctl(com, *(int *)data, DMSET);
- break;
- case TIOCMBIS:
- (void)commctl(com, *(int *)data, DMBIS);
- break;
- case TIOCMBIC:
- (void)commctl(com, *(int *)data, DMBIC);
- break;
- case TIOCMGET:
- *(int *)data = commctl(com, 0, DMGET);
- break;
- case TIOCMSDTRWAIT:
- /* must be root since the wait applies to following logins */
- error = suser(p);
- if (error != 0) {
- splx(s);
- return (error);
- }
- com->dtr_wait = *(int *)data * hz / 100;
- break;
- case TIOCMGDTRWAIT:
- *(int *)data = com->dtr_wait * 100 / hz;
- break;
- case TIOCTIMESTAMP:
- com->do_timestamp = TRUE;
- *(struct timeval *)data = com->timestamp;
- break;
- case TIOCDCDTIMESTAMP:
- com->do_dcd_timestamp = TRUE;
- *(struct timeval *)data = com->dcd_timestamp;
- break;
- default:
- splx(s);
- error = pps_ioctl(cmd, data, &com->pps);
- if (error == ENODEV)
- error = ENOTTY;
- return (error);
- }
- splx(s);
- return (0);
-}
-
-static void
-siopoll()
-{
- int unit;
-
- if (com_events == 0)
- return;
-repeat:
- for (unit = 0; unit < sio_numunits; ++unit) {
- struct com_s *com;
- int incc;
- struct tty *tp;
-
- com = com_addr(unit);
- if (com == NULL)
- continue;
- tp = com->tp;
- if (tp == NULL || com->gone) {
- /*
- * Discard any events related to never-opened or
- * going-away devices.
- */
- disable_intr();
- incc = com->iptr - com->ibuf;
- com->iptr = com->ibuf;
- if (com->state & CS_CHECKMSR) {
- incc += LOTS_OF_EVENTS;
- com->state &= ~CS_CHECKMSR;
- }
- com_events -= incc;
- enable_intr();
- continue;
- }
- if (com->iptr != com->ibuf) {
- disable_intr();
- sioinput(com);
- enable_intr();
- }
- if (com->state & CS_CHECKMSR) {
- u_char delta_modem_status;
-
- disable_intr();
- delta_modem_status = com->last_modem_status
- ^ com->prev_modem_status;
- com->prev_modem_status = com->last_modem_status;
- com_events -= LOTS_OF_EVENTS;
- com->state &= ~CS_CHECKMSR;
- enable_intr();
- if (delta_modem_status & MSR_DCD)
- (*linesw[tp->t_line].l_modem)
- (tp, com->prev_modem_status & MSR_DCD);
- }
- if (com->state & CS_ODONE) {
- disable_intr();
- com_events -= LOTS_OF_EVENTS;
- com->state &= ~CS_ODONE;
- enable_intr();
- if (!(com->state & CS_BUSY)
- && !(com->extra_state & CSE_BUSYCHECK)) {
- timeout(siobusycheck, com, hz / 100);
- com->extra_state |= CSE_BUSYCHECK;
- }
- (*linesw[tp->t_line].l_start)(tp);
- }
- if (com_events == 0)
- break;
- }
- if (com_events >= LOTS_OF_EVENTS)
- goto repeat;
-}
-
-static int
-comparam(tp, t)
- struct tty *tp;
- struct termios *t;
-{
- u_int cfcr;
- int cflag;
- struct com_s *com;
- int divisor;
- u_char dlbh;
- u_char dlbl;
- Port_t iobase;
- int s;
- int unit;
-
- /* do historical conversions */
- if (t->c_ispeed == 0)
- t->c_ispeed = t->c_ospeed;
-
- /* check requested parameters */
- divisor = ttspeedtab(t->c_ospeed, comspeedtab);
- if (divisor < 0 || (divisor > 0 && t->c_ispeed != t->c_ospeed))
- return (EINVAL);
-
- /* parameters are OK, convert them to the com struct and the device */
- unit = DEV_TO_UNIT(tp->t_dev);
- com = com_addr(unit);
- if (com == NULL)
- return (ENODEV);
- iobase = com->iobase;
- s = spltty();
- if (divisor == 0)
- (void)commctl(com, TIOCM_DTR, DMBIC); /* hang up line */
- else
- (void)commctl(com, TIOCM_DTR, DMBIS);
- cflag = t->c_cflag;
- switch (cflag & CSIZE) {
- case CS5:
- cfcr = CFCR_5BITS;
- break;
- case CS6:
- cfcr = CFCR_6BITS;
- break;
- case CS7:
- cfcr = CFCR_7BITS;
- break;
- default:
- cfcr = CFCR_8BITS;
- break;
- }
- if (cflag & PARENB) {
- cfcr |= CFCR_PENAB;
- if (!(cflag & PARODD))
- cfcr |= CFCR_PEVEN;
- }
- if (cflag & CSTOPB)
- cfcr |= CFCR_STOPB;
-
- if (com->hasfifo && divisor != 0) {
- /*
- * Use a fifo trigger level low enough so that the input
- * latency from the fifo is less than about 16 msec and
- * the total latency is less than about 30 msec. These
- * latencies are reasonable for humans. Serial comms
- * protocols shouldn't expect anything better since modem
- * latencies are larger.
- */
- com->fifo_image = t->c_ospeed <= 4800
- ? FIFO_ENABLE : FIFO_ENABLE | FIFO_RX_HIGH;
-#ifdef COM_ESP
- /*
- * The Hayes ESP card needs the fifo DMA mode bit set
- * in compatibility mode. If not, it will interrupt
- * for each character received.
- */
- if (com->esp)
- com->fifo_image |= FIFO_DMA_MODE;
-#endif
- outb(iobase + com_fifo, com->fifo_image);
- }
-
- /*
- * This returns with interrupts disabled so that we can complete
- * the speed change atomically. Keeping interrupts disabled is
- * especially important while com_data is hidden.
- */
- (void) siosetwater(com, t->c_ispeed);
-
- if (divisor != 0) {
- outb(iobase + com_cfcr, cfcr | CFCR_DLAB);
- /*
- * Only set the divisor registers if they would change,
- * since on some 16550 incompatibles (UMC8669F), setting
- * them while input is arriving them loses sync until
- * data stops arriving.
- */
- dlbl = divisor & 0xFF;
- if (inb(iobase + com_dlbl) != dlbl)
- outb(iobase + com_dlbl, dlbl);
- dlbh = (u_int) divisor >> 8;
- if (inb(iobase + com_dlbh) != dlbh)
- outb(iobase + com_dlbh, dlbh);
- }
-
-
- outb(iobase + com_cfcr, com->cfcr_image = cfcr);
-
- if (!(tp->t_state & TS_TTSTOP))
- com->state |= CS_TTGO;
-
- if (cflag & CRTS_IFLOW) {
- if (com->st16650a) {
- outb(iobase + com_cfcr, 0xbf);
- outb(iobase + com_fifo, inb(iobase + com_fifo) | 0x40);
- }
- com->state |= CS_RTS_IFLOW;
- /*
- * If CS_RTS_IFLOW just changed from off to on, the change
- * needs to be propagated to MCR_RTS. This isn't urgent,
- * so do it later by calling comstart() instead of repeating
- * a lot of code from comstart() here.
- */
- } else if (com->state & CS_RTS_IFLOW) {
- com->state &= ~CS_RTS_IFLOW;
- /*
- * CS_RTS_IFLOW just changed from on to off. Force MCR_RTS
- * on here, since comstart() won't do it later.
- */
- outb(com->modem_ctl_port, com->mcr_image |= MCR_RTS);
- if (com->st16650a) {
- outb(iobase + com_cfcr, 0xbf);
- outb(iobase + com_fifo, inb(iobase + com_fifo) & ~0x40);
- }
- }
-
-
- /*
- * Set up state to handle output flow control.
- * XXX - worth handling MDMBUF (DCD) flow control at the lowest level?
- * Now has 10+ msec latency, while CTS flow has 50- usec latency.
- */
- com->state |= CS_ODEVREADY;
- com->state &= ~CS_CTS_OFLOW;
- if (cflag & CCTS_OFLOW) {
- com->state |= CS_CTS_OFLOW;
- if (!(com->last_modem_status & MSR_CTS))
- com->state &= ~CS_ODEVREADY;
- if (com->st16650a) {
- outb(iobase + com_cfcr, 0xbf);
- outb(iobase + com_fifo, inb(iobase + com_fifo) | 0x80);
- }
- } else {
- if (com->st16650a) {
- outb(iobase + com_cfcr, 0xbf);
- outb(iobase + com_fifo, inb(iobase + com_fifo) & ~0x80);
- }
- }
-
-
- outb(iobase + com_cfcr, com->cfcr_image);
-
-
- /* XXX shouldn't call functions while intrs are disabled. */
- disc_optim(tp, t, com);
- /*
- * Recover from fiddling with CS_TTGO. We used to call siointr1()
- * unconditionally, but that defeated the careful discarding of
- * stale input in sioopen().
- */
- if (com->state >= (CS_BUSY | CS_TTGO))
- siointr1(com);
-
- enable_intr();
- splx(s);
- comstart(tp);
- if (com->ibufold != NULL) {
- free(com->ibufold, M_DEVBUF);
- com->ibufold = NULL;
- }
- return (0);
-}
-
-static int
-siosetwater(com, speed)
- struct com_s *com;
- speed_t speed;
-{
- int cp4ticks;
- u_char *ibuf;
- int ibufsize;
- struct tty *tp;
-
- /*
- * Make the buffer size large enough to handle a softtty interrupt
- * latency of about 2 ticks without loss of throughput or data
- * (about 3 ticks if input flow control is not used or not honoured,
- * but a bit less for CS5-CS7 modes).
- */
- cp4ticks = speed / 10 / hz * 4;
- for (ibufsize = 128; ibufsize < cp4ticks;)
- ibufsize <<= 1;
- if (ibufsize == com->ibufsize) {
- disable_intr();
- return (0);
- }
-
- /*
- * Allocate input buffer. The extra factor of 2 in the size is
- * to allow for an error byte for each input byte.
- */
- ibuf = malloc(2 * ibufsize, M_DEVBUF, M_NOWAIT);
- if (ibuf == NULL) {
- disable_intr();
- return (ENOMEM);
- }
-
- /* Initialize non-critical variables. */
- com->ibufold = com->ibuf;
- com->ibufsize = ibufsize;
- tp = com->tp;
- if (tp != NULL) {
- tp->t_ififosize = 2 * ibufsize;
- tp->t_ispeedwat = (speed_t)-1;
- tp->t_ospeedwat = (speed_t)-1;
- }
-
- /*
- * Read current input buffer, if any. Continue with interrupts
- * disabled.
- */
- disable_intr();
- if (com->iptr != com->ibuf)
- sioinput(com);
-
- /*-
- * Initialize critical variables, including input buffer watermarks.
- * The external device is asked to stop sending when the buffer
- * exactly reaches high water, or when the high level requests it.
- * The high level is notified immediately (rather than at a later
- * clock tick) when this watermark is reached.
- * The buffer size is chosen so the watermark should almost never
- * be reached.
- * The low watermark is invisibly 0 since the buffer is always
- * emptied all at once.
- */
- com->iptr = com->ibuf = ibuf;
- com->ibufend = ibuf + ibufsize;
- com->ierroff = ibufsize;
- com->ihighwater = ibuf + 3 * ibufsize / 4;
- return (0);
-}
-
-static void
-comstart(tp)
- struct tty *tp;
-{
- struct com_s *com;
- int s;
- int unit;
-
- unit = DEV_TO_UNIT(tp->t_dev);
- com = com_addr(unit);
- if (com == NULL)
- return;
- s = spltty();
- disable_intr();
- if (tp->t_state & TS_TTSTOP)
- com->state &= ~CS_TTGO;
- else
- com->state |= CS_TTGO;
- if (tp->t_state & TS_TBLOCK) {
- if (com->mcr_image & MCR_RTS && com->state & CS_RTS_IFLOW)
- outb(com->modem_ctl_port, com->mcr_image &= ~MCR_RTS);
- } else {
- if (!(com->mcr_image & MCR_RTS) && com->iptr < com->ihighwater
- && com->state & CS_RTS_IFLOW)
- outb(com->modem_ctl_port, com->mcr_image |= MCR_RTS);
- }
- enable_intr();
- if (tp->t_state & (TS_TIMEOUT | TS_TTSTOP)) {
- ttwwakeup(tp);
- splx(s);
- return;
- }
- if (tp->t_outq.c_cc != 0) {
- struct lbq *qp;
- struct lbq *next;
-
- if (!com->obufs[0].l_queued) {
- com->obufs[0].l_tail
- = com->obuf1 + q_to_b(&tp->t_outq, com->obuf1,
- sizeof com->obuf1);
- com->obufs[0].l_next = NULL;
- com->obufs[0].l_queued = TRUE;
- disable_intr();
- if (com->state & CS_BUSY) {
- qp = com->obufq.l_next;
- while ((next = qp->l_next) != NULL)
- qp = next;
- qp->l_next = &com->obufs[0];
- } else {
- com->obufq.l_head = com->obufs[0].l_head;
- com->obufq.l_tail = com->obufs[0].l_tail;
- com->obufq.l_next = &com->obufs[0];
- com->state |= CS_BUSY;
- }
- enable_intr();
- }
- if (tp->t_outq.c_cc != 0 && !com->obufs[1].l_queued) {
- com->obufs[1].l_tail
- = com->obuf2 + q_to_b(&tp->t_outq, com->obuf2,
- sizeof com->obuf2);
- com->obufs[1].l_next = NULL;
- com->obufs[1].l_queued = TRUE;
- disable_intr();
- if (com->state & CS_BUSY) {
- qp = com->obufq.l_next;
- while ((next = qp->l_next) != NULL)
- qp = next;
- qp->l_next = &com->obufs[1];
- } else {
- com->obufq.l_head = com->obufs[1].l_head;
- com->obufq.l_tail = com->obufs[1].l_tail;
- com->obufq.l_next = &com->obufs[1];
- com->state |= CS_BUSY;
- }
- enable_intr();
- }
- tp->t_state |= TS_BUSY;
- }
- disable_intr();
- if (com->state >= (CS_BUSY | CS_TTGO))
- siointr1(com); /* fake interrupt to start output */
- enable_intr();
- ttwwakeup(tp);
- splx(s);
-}
-
-static void
-comstop(tp, rw)
- struct tty *tp;
- int rw;
-{
- struct com_s *com;
-
- com = com_addr(DEV_TO_UNIT(tp->t_dev));
- if (com == NULL || com->gone)
- return;
- disable_intr();
- if (rw & FWRITE) {
- if (com->hasfifo)
-#ifdef COM_ESP
- /* XXX avoid h/w bug. */
- if (!com->esp)
-#endif
- outb(com->iobase + com_fifo,
- FIFO_XMT_RST | com->fifo_image);
- com->obufs[0].l_queued = FALSE;
- com->obufs[1].l_queued = FALSE;
- if (com->state & CS_ODONE)
- com_events -= LOTS_OF_EVENTS;
- com->state &= ~(CS_ODONE | CS_BUSY);
- com->tp->t_state &= ~TS_BUSY;
- }
- if (rw & FREAD) {
- if (com->hasfifo)
-#ifdef COM_ESP
- /* XXX avoid h/w bug. */
- if (!com->esp)
-#endif
- outb(com->iobase + com_fifo,
- FIFO_RCV_RST | com->fifo_image);
- com_events -= (com->iptr - com->ibuf);
- com->iptr = com->ibuf;
- }
- enable_intr();
- comstart(tp);
-}
-
-static int
-commctl(com, bits, how)
- struct com_s *com;
- int bits;
- int how;
-{
- int mcr;
- int msr;
-
- if (how == DMGET) {
- bits = TIOCM_LE; /* XXX - always enabled while open */
- mcr = com->mcr_image;
- if (mcr & MCR_DTR)
- bits |= TIOCM_DTR;
- if (mcr & MCR_RTS)
- bits |= TIOCM_RTS;
- msr = com->prev_modem_status;
- if (msr & MSR_CTS)
- bits |= TIOCM_CTS;
- if (msr & MSR_DCD)
- bits |= TIOCM_CD;
- if (msr & MSR_DSR)
- bits |= TIOCM_DSR;
- /*
- * XXX - MSR_RI is naturally volatile, and we make MSR_TERI
- * more volatile by reading the modem status a lot. Perhaps
- * we should latch both bits until the status is read here.
- */
- if (msr & (MSR_RI | MSR_TERI))
- bits |= TIOCM_RI;
- return (bits);
- }
- mcr = 0;
- if (bits & TIOCM_DTR)
- mcr |= MCR_DTR;
- if (bits & TIOCM_RTS)
- mcr |= MCR_RTS;
- if (com->gone)
- return(0);
- disable_intr();
- switch (how) {
- case DMSET:
- outb(com->modem_ctl_port,
- com->mcr_image = mcr | (com->mcr_image & MCR_IENABLE));
- break;
- case DMBIS:
- outb(com->modem_ctl_port, com->mcr_image |= mcr);
- break;
- case DMBIC:
- outb(com->modem_ctl_port, com->mcr_image &= ~mcr);
- break;
- }
- enable_intr();
- return (0);
-}
-
-static void
-siosettimeout()
-{
- struct com_s *com;
- bool_t someopen;
- int unit;
-
- /*
- * Set our timeout period to 1 second if no polled devices are open.
- * Otherwise set it to max(1/200, 1/hz).
- * Enable timeouts iff some device is open.
- */
- untimeout(comwakeup, (void *)NULL, sio_timeout_handle);
- sio_timeout = hz;
- someopen = FALSE;
- for (unit = 0; unit < sio_numunits; ++unit) {
- com = com_addr(unit);
- if (com != NULL && com->tp != NULL
- && com->tp->t_state & TS_ISOPEN && !com->gone) {
- someopen = TRUE;
- if (com->poll || com->poll_output) {
- sio_timeout = hz > 200 ? hz / 200 : 1;
- break;
- }
- }
- }
- if (someopen) {
- sio_timeouts_until_log = hz / sio_timeout;
- sio_timeout_handle = timeout(comwakeup, (void *)NULL,
- sio_timeout);
- } else {
- /* Flush error messages, if any. */
- sio_timeouts_until_log = 1;
- comwakeup((void *)NULL);
- untimeout(comwakeup, (void *)NULL, sio_timeout_handle);
- }
-}
-
-static void
-comwakeup(chan)
- void *chan;
-{
- struct com_s *com;
- int unit;
-
- sio_timeout_handle = timeout(comwakeup, (void *)NULL, sio_timeout);
-
- /*
- * Recover from lost output interrupts.
- * Poll any lines that don't use interrupts.
- */
- for (unit = 0; unit < sio_numunits; ++unit) {
- com = com_addr(unit);
- if (com != NULL && !com->gone
- && (com->state >= (CS_BUSY | CS_TTGO) || com->poll)) {
- disable_intr();
- siointr1(com);
- enable_intr();
- }
- }
-
- /*
- * Check for and log errors, but not too often.
- */
- if (--sio_timeouts_until_log > 0)
- return;
- sio_timeouts_until_log = hz / sio_timeout;
- for (unit = 0; unit < sio_numunits; ++unit) {
- int errnum;
-
- com = com_addr(unit);
- if (com == NULL)
- continue;
- if (com->gone)
- continue;
- for (errnum = 0; errnum < CE_NTYPES; ++errnum) {
- u_int delta;
- u_long total;
-
- disable_intr();
- delta = com->delta_error_counts[errnum];
- com->delta_error_counts[errnum] = 0;
- enable_intr();
- if (delta == 0)
- continue;
- total = com->error_counts[errnum] += delta;
- log(LOG_ERR, "sio%d: %u more %s%s (total %lu)\n",
- unit, delta, error_desc[errnum],
- delta == 1 ? "" : "s", total);
- }
- }
-}
-
-static void
-disc_optim(tp, t, com)
- struct tty *tp;
- struct termios *t;
- struct com_s *com;
-{
- if (!(t->c_iflag & (ICRNL | IGNCR | IMAXBEL | INLCR | ISTRIP | IXON))
- && (!(t->c_iflag & BRKINT) || (t->c_iflag & IGNBRK))
- && (!(t->c_iflag & PARMRK)
- || (t->c_iflag & (IGNPAR | IGNBRK)) == (IGNPAR | IGNBRK))
- && !(t->c_lflag & (ECHO | ICANON | IEXTEN | ISIG | PENDIN))
- && linesw[tp->t_line].l_rint == ttyinput)
- tp->t_state |= TS_CAN_BYPASS_L_RINT;
- else
- tp->t_state &= ~TS_CAN_BYPASS_L_RINT;
- com->hotchar = linesw[tp->t_line].l_hotchar;
-}
-
-/*
- * Following are all routines needed for SIO to act as console
- */
-#include <sys/cons.h>
-
-struct siocnstate {
- u_char dlbl;
- u_char dlbh;
- u_char ier;
- u_char cfcr;
- u_char mcr;
-};
-
-static speed_t siocngetspeed __P((Port_t, struct speedtab *));
-static void siocnclose __P((struct siocnstate *sp, Port_t iobase));
-static void siocnopen __P((struct siocnstate *sp, Port_t iobase, int speed));
-static void siocntxwait __P((Port_t iobase));
-
-static cn_probe_t siocnprobe;
-static cn_init_t siocninit;
-static cn_checkc_t siocncheckc;
-static cn_getc_t siocngetc;
-static cn_putc_t siocnputc;
-
-#ifdef __i386__
-CONS_DRIVER(sio, siocnprobe, siocninit, NULL, siocngetc, siocncheckc,
- siocnputc, NULL);
-#endif
-
-/* To get the GDB related variables */
-#if DDB > 0
-#include <ddb/ddb.h>
-#endif
-
-static void
-siocntxwait(iobase)
- Port_t iobase;
-{
- int timo;
-
- /*
- * Wait for any pending transmission to finish. Required to avoid
- * the UART lockup bug when the speed is changed, and for normal
- * transmits.
- */
- timo = 100000;
- while ((inb(iobase + com_lsr) & (LSR_TSRE | LSR_TXRDY))
- != (LSR_TSRE | LSR_TXRDY) && --timo != 0)
- ;
-}
-
-/*
- * Read the serial port specified and try to figure out what speed
- * it's currently running at. We're assuming the serial port has
- * been initialized and is basicly idle. This routine is only intended
- * to be run at system startup.
- *
- * If the value read from the serial port doesn't make sense, return 0.
- */
-
-static speed_t
-siocngetspeed(iobase, table)
- Port_t iobase;
- struct speedtab *table;
-{
- int code;
- u_char dlbh;
- u_char dlbl;
- u_char cfcr;
-
- cfcr = inb(iobase + com_cfcr);
- outb(iobase + com_cfcr, CFCR_DLAB | cfcr);
-
- dlbl = inb(iobase + com_dlbl);
- dlbh = inb(iobase + com_dlbh);
-
- outb(iobase + com_cfcr, cfcr);
-
- code = dlbh << 8 | dlbl;
-
- for (; table->sp_speed != -1; table++)
- if (table->sp_code == code)
- return (table->sp_speed);
-
- return 0; /* didn't match anything sane */
-}
-
-static void
-siocnopen(sp, iobase, speed)
- struct siocnstate *sp;
- Port_t iobase;
- int speed;
-{
- int divisor;
- u_char dlbh;
- u_char dlbl;
-
- /*
- * Save all the device control registers except the fifo register
- * and set our default ones (cs8 -parenb speed=comdefaultrate).
- * We can't save the fifo register since it is read-only.
- */
- sp->ier = inb(iobase + com_ier);
- outb(iobase + com_ier, 0); /* spltty() doesn't stop siointr() */
- siocntxwait(iobase);
- sp->cfcr = inb(iobase + com_cfcr);
- outb(iobase + com_cfcr, CFCR_DLAB | CFCR_8BITS);
- sp->dlbl = inb(iobase + com_dlbl);
- sp->dlbh = inb(iobase + com_dlbh);
- /*
- * Only set the divisor registers if they would change, since on
- * some 16550 incompatibles (Startech), setting them clears the
- * data input register. This also reduces the effects of the
- * UMC8669F bug.
- */
- divisor = ttspeedtab(speed, comspeedtab);
- dlbl = divisor & 0xFF;
- if (sp->dlbl != dlbl)
- outb(iobase + com_dlbl, dlbl);
- dlbh = (u_int) divisor >> 8;
- if (sp->dlbh != dlbh)
- outb(iobase + com_dlbh, dlbh);
- outb(iobase + com_cfcr, CFCR_8BITS);
- sp->mcr = inb(iobase + com_mcr);
- /*
- * We don't want interrupts, but must be careful not to "disable"
- * them by clearing the MCR_IENABLE bit, since that might cause
- * an interrupt by floating the IRQ line.
- */
- outb(iobase + com_mcr, (sp->mcr & MCR_IENABLE) | MCR_DTR | MCR_RTS);
-}
-
-static void
-siocnclose(sp, iobase)
- struct siocnstate *sp;
- Port_t iobase;
-{
- /*
- * Restore the device control registers.
- */
- siocntxwait(iobase);
- outb(iobase + com_cfcr, CFCR_DLAB | CFCR_8BITS);
- if (sp->dlbl != inb(iobase + com_dlbl))
- outb(iobase + com_dlbl, sp->dlbl);
- if (sp->dlbh != inb(iobase + com_dlbh))
- outb(iobase + com_dlbh, sp->dlbh);
- outb(iobase + com_cfcr, sp->cfcr);
- /*
- * XXX damp oscillations of MCR_DTR and MCR_RTS by not restoring them.
- */
- outb(iobase + com_mcr, sp->mcr | MCR_DTR | MCR_RTS);
- outb(iobase + com_ier, sp->ier);
-}
-
-static void
-siocnprobe(cp)
- struct consdev *cp;
-{
- speed_t boot_speed;
- u_char cfcr;
- int s, unit;
- struct siocnstate sp;
-
- /*
- * Find our first enabled console, if any. If it is a high-level
- * console device, then initialize it and return successfully.
- * If it is a low-level console device, then initialize it and
- * return unsuccessfully. It must be initialized in both cases
- * for early use by console drivers and debuggers. Initializing
- * the hardware is not necessary in all cases, since the i/o
- * routines initialize it on the fly, but it is necessary if
- * input might arrive while the hardware is switched back to an
- * uninitialized state. We can't handle multiple console devices
- * yet because our low-level routines don't take a device arg.
- * We trust the user to set the console flags properly so that we
- * don't need to probe.
- */
- cp->cn_pri = CN_DEAD;
-
- for (unit = 0; unit < 16; unit++) { /* XXX need to know how many */
- int flags;
- int disabled;
- if (resource_int_value("sio", unit, "disabled", &disabled) == 0) {
- if (disabled)
- continue;
- }
- if (resource_int_value("sio", unit, "flags", &flags))
- continue;
- if (COM_CONSOLE(flags) || COM_DEBUGGER(flags)) {
- int port;
- Port_t iobase;
-
- if (resource_int_value("sio", unit, "port", &port))
- continue;
- iobase = port;
- s = spltty();
- if (boothowto & RB_SERIAL) {
- boot_speed = siocngetspeed(iobase, comspeedtab);
- if (boot_speed)
- comdefaultrate = boot_speed;
- }
-
- /*
- * Initialize the divisor latch. We can't rely on
- * siocnopen() to do this the first time, since it
- * avoids writing to the latch if the latch appears
- * to have the correct value. Also, if we didn't
- * just read the speed from the hardware, then we
- * need to set the speed in hardware so that
- * switching it later is null.
- */
- cfcr = inb(iobase + com_cfcr);
- outb(iobase + com_cfcr, CFCR_DLAB | cfcr);
- outb(iobase + com_dlbl,
- COMBRD(comdefaultrate) & 0xff);
- outb(iobase + com_dlbh,
- (u_int) COMBRD(comdefaultrate) >> 8);
- outb(iobase + com_cfcr, cfcr);
-
- siocnopen(&sp, iobase, comdefaultrate);
-
- splx(s);
- if (COM_CONSOLE(flags) && !COM_LLCONSOLE(flags)) {
- cp->cn_dev = makedev(CDEV_MAJOR, unit);
- cp->cn_pri = COM_FORCECONSOLE(flags)
- || boothowto & RB_SERIAL
- ? CN_REMOTE : CN_NORMAL;
- siocniobase = iobase;
- siocnunit = unit;
- }
- if (COM_DEBUGGER(flags)) {
- printf("sio%d: gdb debugging port\n", unit);
- siogdbiobase = iobase;
- siogdbunit = unit;
-#if DDB > 0
- gdbdev = makedev(CDEV_MAJOR, unit);
- gdb_getc = siocngetc;
- gdb_putc = siocnputc;
-#endif
- }
- }
- }
-#ifdef __i386__
-#if DDB > 0
- /*
- * XXX Ugly Compatability.
- * If no gdb port has been specified, set it to be the console
- * as some configuration files don't specify the gdb port.
- */
- if (gdbdev == NODEV && (boothowto & RB_GDB)) {
- printf("Warning: no GDB port specified. Defaulting to sio%d.\n",
- siocnunit);
- printf("Set flag 0x80 on desired GDB port in your\n");
- printf("configuration file (currently sio only).\n");
- siogdbiobase = siocniobase;
- siogdbunit = siocnunit;
- gdbdev = makedev(CDEV_MAJOR, siocnunit);
- gdb_getc = siocngetc;
- gdb_putc = siocnputc;
- }
-#endif
-#endif
-}
-
-#ifdef __alpha__
-
-CONS_DRIVER(sio, NULL, NULL, NULL, siocngetc, siocncheckc, siocnputc, NULL);
-
-int
-siocnattach(port, speed)
- int port;
- int speed;
-{
- int s;
- u_char cfcr;
- struct siocnstate sp;
-
- siocniobase = port;
- comdefaultrate = speed;
- sio_consdev.cn_pri = CN_NORMAL;
- sio_consdev.cn_dev = makedev(CDEV_MAJOR, 0);
-
- s = spltty();
-
- /*
- * Initialize the divisor latch. We can't rely on
- * siocnopen() to do this the first time, since it
- * avoids writing to the latch if the latch appears
- * to have the correct value. Also, if we didn't
- * just read the speed from the hardware, then we
- * need to set the speed in hardware so that
- * switching it later is null.
- */
- cfcr = inb(siocniobase + com_cfcr);
- outb(siocniobase + com_cfcr, CFCR_DLAB | cfcr);
- outb(siocniobase + com_dlbl,
- COMBRD(comdefaultrate) & 0xff);
- outb(siocniobase + com_dlbh,
- (u_int) COMBRD(comdefaultrate) >> 8);
- outb(siocniobase + com_cfcr, cfcr);
-
- siocnopen(&sp, siocniobase, comdefaultrate);
- splx(s);
-
- cn_tab = &sio_consdev;
- return 0;
-}
-
-int
-siogdbattach(port, speed)
- int port;
- int speed;
-{
- int s;
- u_char cfcr;
- struct siocnstate sp;
-
- siogdbiobase = port;
- gdbdefaultrate = speed;
-
- s = spltty();
-
- /*
- * Initialize the divisor latch. We can't rely on
- * siocnopen() to do this the first time, since it
- * avoids writing to the latch if the latch appears
- * to have the correct value. Also, if we didn't
- * just read the speed from the hardware, then we
- * need to set the speed in hardware so that
- * switching it later is null.
- */
- cfcr = inb(siogdbiobase + com_cfcr);
- outb(siogdbiobase + com_cfcr, CFCR_DLAB | cfcr);
- outb(siogdbiobase + com_dlbl,
- COMBRD(gdbdefaultrate) & 0xff);
- outb(siogdbiobase + com_dlbh,
- (u_int) COMBRD(gdbdefaultrate) >> 8);
- outb(siogdbiobase + com_cfcr, cfcr);
-
- siocnopen(&sp, siogdbiobase, gdbdefaultrate);
- splx(s);
-
- return 0;
-}
-
-#endif
-
-static void
-siocninit(cp)
- struct consdev *cp;
-{
- comconsole = DEV_TO_UNIT(cp->cn_dev);
-}
-
-static int
-siocncheckc(dev)
- dev_t dev;
-{
- int c;
- Port_t iobase;
- int s;
- struct siocnstate sp;
-
- if (minor(dev) == siogdbunit)
- iobase = siogdbiobase;
- else
- iobase = siocniobase;
- s = spltty();
- siocnopen(&sp, iobase, comdefaultrate);
- if (inb(iobase + com_lsr) & LSR_RXRDY)
- c = inb(iobase + com_data);
- else
- c = -1;
- siocnclose(&sp, iobase);
- splx(s);
- return (c);
-}
-
-
-int
-siocngetc(dev)
- dev_t dev;
-{
- int c;
- Port_t iobase;
- int s;
- struct siocnstate sp;
-
- if (minor(dev) == siogdbunit)
- iobase = siogdbiobase;
- else
- iobase = siocniobase;
- s = spltty();
- siocnopen(&sp, iobase, comdefaultrate);
- while (!(inb(iobase + com_lsr) & LSR_RXRDY))
- ;
- c = inb(iobase + com_data);
- siocnclose(&sp, iobase);
- splx(s);
- return (c);
-}
-
-void
-siocnputc(dev, c)
- dev_t dev;
- int c;
-{
- int s;
- struct siocnstate sp;
- Port_t iobase;
-
- if (minor(dev) == siogdbunit)
- iobase = siogdbiobase;
- else
- iobase = siocniobase;
- s = spltty();
- siocnopen(&sp, iobase, comdefaultrate);
- siocntxwait(iobase);
- outb(iobase + com_data, c);
- siocnclose(&sp, iobase);
- splx(s);
-}
-
-#ifdef __alpha__
-int
-siogdbgetc()
-{
- int c;
- Port_t iobase;
- int s;
- struct siocnstate sp;
-
- iobase = siogdbiobase;
- s = spltty();
- siocnopen(&sp, iobase, gdbdefaultrate);
- while (!(inb(iobase + com_lsr) & LSR_RXRDY))
- ;
- c = inb(iobase + com_data);
- siocnclose(&sp, iobase);
- splx(s);
- return (c);
-}
-
-void
-siogdbputc(c)
- int c;
-{
- int s;
- struct siocnstate sp;
-
- s = spltty();
- siocnopen(&sp, siogdbiobase, gdbdefaultrate);
- siocntxwait(siogdbiobase);
- outb(siogdbiobase + com_data, c);
- siocnclose(&sp, siogdbiobase);
- splx(s);
-}
-#endif
-
-DRIVER_MODULE(sio, isa, sio_isa_driver, sio_devclass, 0, 0);
-#if NCARD > 0
-DRIVER_MODULE(sio, pccard, sio_pccard_driver, sio_devclass, 0, 0);
-#endif
diff --git a/sys/dev/sio/sioreg.h b/sys/dev/sio/sioreg.h
deleted file mode 100644
index 052106525998..000000000000
--- a/sys/dev/sio/sioreg.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/*-
- * 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. 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, Berkeley and its contributors.
- * 4. 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: @(#)comreg.h 7.2 (Berkeley) 5/9/91
- * $FreeBSD$
- */
-
-
-/* 16 bit baud rate divisor (lower byte in dca_data, upper in dca_ier) */
-#define COMBRD(x) (1843200 / (16*(x)))
-#ifdef PC98
-#define COMBRD_RSA(x) (14745600 / (16*(x)))
-#endif
-
-/* interrupt enable register */
-#define IER_ERXRDY 0x1
-#define IER_ETXRDY 0x2
-#define IER_ERLS 0x4
-#define IER_EMSC 0x8
-
-/* interrupt identification register */
-#define IIR_IMASK 0xf
-#define IIR_RXTOUT 0xc
-#define IIR_RLS 0x6
-#define IIR_RXRDY 0x4
-#define IIR_TXRDY 0x2
-#define IIR_NOPEND 0x1
-#define IIR_MLSC 0x0
-#define IIR_FIFO_MASK 0xc0 /* set if FIFOs are enabled */
-
-/* fifo control register */
-#define FIFO_ENABLE 0x01
-#define FIFO_RCV_RST 0x02
-#define FIFO_XMT_RST 0x04
-#define FIFO_DMA_MODE 0x08
-#define FIFO_RX_LOW 0x00
-#define FIFO_RX_MEDL 0x40
-#define FIFO_RX_MEDH 0x80
-#define FIFO_RX_HIGH 0xc0
-
-/* character format control register */
-#define CFCR_DLAB 0x80
-#define CFCR_SBREAK 0x40
-#define CFCR_PZERO 0x30
-#define CFCR_PONE 0x20
-#define CFCR_PEVEN 0x10
-#define CFCR_PODD 0x00
-#define CFCR_PENAB 0x08
-#define CFCR_STOPB 0x04
-#define CFCR_8BITS 0x03
-#define CFCR_7BITS 0x02
-#define CFCR_6BITS 0x01
-#define CFCR_5BITS 0x00
-
-/* modem control register */
-#define MCR_LOOPBACK 0x10
-#define MCR_IENABLE 0x08
-#define MCR_DRS 0x04
-#define MCR_RTS 0x02
-#define MCR_DTR 0x01
-
-/* line status register */
-#define LSR_RCV_FIFO 0x80
-#define LSR_TSRE 0x40
-#define LSR_TXRDY 0x20
-#define LSR_BI 0x10
-#define LSR_FE 0x08
-#define LSR_PE 0x04
-#define LSR_OE 0x02
-#define LSR_RXRDY 0x01
-#define LSR_RCV_MASK 0x1f
-
-/* modem status register */
-#define MSR_DCD 0x80
-#define MSR_RI 0x40
-#define MSR_DSR 0x20
-#define MSR_CTS 0x10
-#define MSR_DDCD 0x08
-#define MSR_TERI 0x04
-#define MSR_DDSR 0x02
-#define MSR_DCTS 0x01
-
-#ifdef PC98
-/* Hardware extension mode register for RSB-2000/3000. */
-#define EMR_EXBUFF 0x04
-#define EMR_CTSFLW 0x08
-#define EMR_DSRFLW 0x10
-#define EMR_RTSFLW 0x20
-#define EMR_DTRFLW 0x40
-#define EMR_EFMODE 0x80
-#endif
-
-/* speed to initialize to during chip tests */
-#define SIO_TEST_SPEED 9600
-
-/* default serial console speed if not set with sysctl or probed from boot */
-#ifndef CONSPEED
-#define CONSPEED 9600
-#endif
diff --git a/sys/dev/sk/if_sk.c b/sys/dev/sk/if_sk.c
deleted file mode 100644
index edb941ff681f..000000000000
--- a/sys/dev/sk/if_sk.c
+++ /dev/null
@@ -1,1983 +0,0 @@
-/*
- * Copyright (c) 1997, 1998, 1999
- * Bill Paul <wpaul@ctr.columbia.edu>. 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 Bill Paul.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY Bill Paul 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 Bill Paul OR THE VOICES IN HIS HEAD
- * 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.
- *
- * $FreeBSD$
- */
-
-/*
- * SysKonnect SK-NET gigabit ethernet driver for FreeBSD. Supports
- * the SK-984x series adapters, both single port and dual port.
- * References:
- * The XaQti XMAC II datasheet, http://www.xaqti.com
- * The SysKonnect GEnesis manual, http://www.syskonnect.com
- *
- * Written by Bill Paul <wpaul@ee.columbia.edu>
- * Department of Electrical Engineering
- * Columbia University, New York City
- */
-
-/*
- * The SysKonnect gigabit ethernet adapters consist of two main
- * components: the SysKonnect GEnesis controller chip and the XaQti Corp.
- * XMAC II gigabit ethernet MAC. The XMAC provides all of the MAC
- * components and a PHY while the GEnesis controller provides a PCI
- * interface with DMA support. Each card may have between 512K and
- * 2MB of SRAM on board depending on the configuration.
- *
- * The SysKonnect GEnesis controller can have either one or two XMAC
- * chips connected to it, allowing single or dual port NIC configurations.
- * SysKonnect has the distinction of being the only vendor on the market
- * with a dual port gigabit ethernet NIC. The GEnesis provides dual FIFOs,
- * dual DMA queues, packet/MAC/transmit arbiters and direct access to the
- * XMAC registers. This driver takes advantage of these features to allow
- * both XMACs to operate as independent interfaces.
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/sockio.h>
-#include <sys/mbuf.h>
-#include <sys/malloc.h>
-#include <sys/kernel.h>
-#include <sys/socket.h>
-#include <sys/queue.h>
-
-#include <net/if.h>
-#include <net/if_arp.h>
-#include <net/ethernet.h>
-#include <net/if_dl.h>
-#include <net/if_media.h>
-
-#include <net/bpf.h>
-
-#include <vm/vm.h> /* for vtophys */
-#include <vm/pmap.h> /* for vtophys */
-#include <machine/clock.h> /* for DELAY */
-#include <machine/bus_pio.h>
-#include <machine/bus_memio.h>
-#include <machine/bus.h>
-#include <machine/resource.h>
-#include <sys/bus.h>
-#include <sys/rman.h>
-
-#include <pci/pcireg.h>
-#include <pci/pcivar.h>
-
-#define SK_USEIOSPACE
-
-#include <pci/if_skreg.h>
-#include <pci/xmaciireg.h>
-
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif
-
-static struct sk_type sk_devs[] = {
- { SK_VENDORID, SK_DEVICEID_GE, "SysKonnect Gigabit Ethernet" },
- { 0, 0, NULL }
-};
-
-static int sk_probe __P((device_t));
-static int sk_attach __P((device_t));
-static int sk_detach __P((device_t));
-static int sk_attach_xmac __P((struct sk_softc *, int));
-static void sk_intr __P((void *));
-static void sk_intr_xmac __P((struct sk_if_softc *));
-static void sk_rxeof __P((struct sk_if_softc *));
-static void sk_txeof __P((struct sk_if_softc *));
-static int sk_encap __P((struct sk_if_softc *, struct mbuf *,
- u_int32_t *));
-static void sk_start __P((struct ifnet *));
-static int sk_ioctl __P((struct ifnet *, u_long, caddr_t));
-static void sk_init __P((void *));
-static void sk_init_xmac __P((struct sk_if_softc *));
-static void sk_stop __P((struct sk_if_softc *));
-static void sk_watchdog __P((struct ifnet *));
-static void sk_shutdown __P((device_t));
-static int sk_ifmedia_upd __P((struct ifnet *));
-static void sk_ifmedia_sts __P((struct ifnet *, struct ifmediareq *));
-static void sk_reset __P((struct sk_softc *));
-static int sk_newbuf __P((struct sk_if_softc *,
- struct sk_chain *, struct mbuf *));
-static int sk_alloc_jumbo_mem __P((struct sk_if_softc *));
-static void *sk_jalloc __P((struct sk_if_softc *));
-static void sk_jfree __P((caddr_t, u_int));
-static void sk_jref __P((caddr_t, u_int));
-static int sk_init_rx_ring __P((struct sk_if_softc *));
-static void sk_init_tx_ring __P((struct sk_if_softc *));
-#ifdef notdef
-static u_int32_t sk_win_read_4 __P((struct sk_softc *, int));
-#endif
-static u_int16_t sk_win_read_2 __P((struct sk_softc *, int));
-static u_int8_t sk_win_read_1 __P((struct sk_softc *, int));
-static void sk_win_write_4 __P((struct sk_softc *, int, u_int32_t));
-static void sk_win_write_2 __P((struct sk_softc *, int, u_int32_t));
-static void sk_win_write_1 __P((struct sk_softc *, int, u_int32_t));
-static u_int8_t sk_vpd_readbyte __P((struct sk_softc *, int));
-static void sk_vpd_read_res __P((struct sk_softc *,
- struct vpd_res *, int));
-static void sk_vpd_read __P((struct sk_softc *));
-static u_int16_t sk_phy_readreg __P((struct sk_if_softc *, int));
-static void sk_phy_writereg __P((struct sk_if_softc *, int, u_int32_t));
-static u_int32_t sk_calchash __P((caddr_t));
-static void sk_setfilt __P((struct sk_if_softc *, caddr_t, int));
-static void sk_setmulti __P((struct sk_if_softc *));
-
-#ifdef SK_USEIOSPACE
-#define SK_RES SYS_RES_IOPORT
-#define SK_RID SK_PCI_LOIO
-#else
-#define SK_RES SYS_RES_MEMORY
-#define SK_RID SK_PCI_LOMEM
-#endif
-
-static device_method_t sk_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, sk_probe),
- DEVMETHOD(device_attach, sk_attach),
- DEVMETHOD(device_detach, sk_detach),
- DEVMETHOD(device_shutdown, sk_shutdown),
- { 0, 0 }
-};
-
-static driver_t sk_driver = {
- "skc",
- sk_methods,
- sizeof(struct sk_softc)
-};
-
-static devclass_t sk_devclass;
-
-DRIVER_MODULE(if_sk, pci, sk_driver, sk_devclass, 0, 0);
-
-#define SK_SETBIT(sc, reg, x) \
- CSR_WRITE_4(sc, reg, CSR_READ_4(sc, reg) | x)
-
-#define SK_CLRBIT(sc, reg, x) \
- CSR_WRITE_4(sc, reg, CSR_READ_4(sc, reg) & ~x)
-
-#define SK_WIN_SETBIT_4(sc, reg, x) \
- sk_win_write_4(sc, reg, sk_win_read_4(sc, reg) | x)
-
-#define SK_WIN_CLRBIT_4(sc, reg, x) \
- sk_win_write_4(sc, reg, sk_win_read_4(sc, reg) & ~x)
-
-#define SK_WIN_SETBIT_2(sc, reg, x) \
- sk_win_write_2(sc, reg, sk_win_read_2(sc, reg) | x)
-
-#define SK_WIN_CLRBIT_2(sc, reg, x) \
- sk_win_write_2(sc, reg, sk_win_read_2(sc, reg) & ~x)
-
-#ifdef notdef
-static u_int32_t sk_win_read_4(sc, reg)
- struct sk_softc *sc;
- int reg;
-{
- CSR_WRITE_4(sc, SK_RAP, SK_WIN(reg));
- return(CSR_READ_4(sc, SK_WIN_BASE + SK_REG(reg)));
-}
-#endif
-
-static u_int16_t sk_win_read_2(sc, reg)
- struct sk_softc *sc;
- int reg;
-{
- CSR_WRITE_4(sc, SK_RAP, SK_WIN(reg));
- return(CSR_READ_2(sc, SK_WIN_BASE + SK_REG(reg)));
-}
-
-static u_int8_t sk_win_read_1(sc, reg)
- struct sk_softc *sc;
- int reg;
-{
- CSR_WRITE_4(sc, SK_RAP, SK_WIN(reg));
- return(CSR_READ_1(sc, SK_WIN_BASE + SK_REG(reg)));
-}
-
-static void sk_win_write_4(sc, reg, val)
- struct sk_softc *sc;
- int reg;
- u_int32_t val;
-{
- CSR_WRITE_4(sc, SK_RAP, SK_WIN(reg));
- CSR_WRITE_4(sc, SK_WIN_BASE + SK_REG(reg), val);
- return;
-}
-
-static void sk_win_write_2(sc, reg, val)
- struct sk_softc *sc;
- int reg;
- u_int32_t val;
-{
- CSR_WRITE_4(sc, SK_RAP, SK_WIN(reg));
- CSR_WRITE_2(sc, SK_WIN_BASE + SK_REG(reg), (u_int32_t)val);
- return;
-}
-
-static void sk_win_write_1(sc, reg, val)
- struct sk_softc *sc;
- int reg;
- u_int32_t val;
-{
- CSR_WRITE_4(sc, SK_RAP, SK_WIN(reg));
- CSR_WRITE_1(sc, SK_WIN_BASE + SK_REG(reg), val);
- return;
-}
-
-/*
- * The VPD EEPROM contains Vital Product Data, as suggested in
- * the PCI 2.1 specification. The VPD data is separared into areas
- * denoted by resource IDs. The SysKonnect VPD contains an ID string
- * resource (the name of the adapter), a read-only area resource
- * containing various key/data fields and a read/write area which
- * can be used to store asset management information or log messages.
- * We read the ID string and read-only into buffers attached to
- * the controller softc structure for later use. At the moment,
- * we only use the ID string during sk_attach().
- */
-static u_int8_t sk_vpd_readbyte(sc, addr)
- struct sk_softc *sc;
- int addr;
-{
- int i;
-
- sk_win_write_2(sc, SK_PCI_REG(SK_PCI_VPD_ADDR), addr);
- for (i = 0; i < SK_TIMEOUT; i++) {
- DELAY(1);
- if (sk_win_read_2(sc,
- SK_PCI_REG(SK_PCI_VPD_ADDR)) & SK_VPD_FLAG)
- break;
- }
-
- if (i == SK_TIMEOUT)
- return(0);
-
- return(sk_win_read_1(sc, SK_PCI_REG(SK_PCI_VPD_DATA)));
-}
-
-static void sk_vpd_read_res(sc, res, addr)
- struct sk_softc *sc;
- struct vpd_res *res;
- int addr;
-{
- int i;
- u_int8_t *ptr;
-
- ptr = (u_int8_t *)res;
- for (i = 0; i < sizeof(struct vpd_res); i++)
- ptr[i] = sk_vpd_readbyte(sc, i + addr);
-
- return;
-}
-
-static void sk_vpd_read(sc)
- struct sk_softc *sc;
-{
- int pos = 0, i;
- struct vpd_res res;
-
- if (sc->sk_vpd_prodname != NULL)
- free(sc->sk_vpd_prodname, M_DEVBUF);
- if (sc->sk_vpd_readonly != NULL)
- free(sc->sk_vpd_readonly, M_DEVBUF);
- sc->sk_vpd_prodname = NULL;
- sc->sk_vpd_readonly = NULL;
-
- sk_vpd_read_res(sc, &res, pos);
-
- if (res.vr_id != VPD_RES_ID) {
- printf("skc%d: bad VPD resource id: expected %x got %x\n",
- sc->sk_unit, VPD_RES_ID, res.vr_id);
- return;
- }
-
- pos += sizeof(res);
- sc->sk_vpd_prodname = malloc(res.vr_len + 1, M_DEVBUF, M_NOWAIT);
- for (i = 0; i < res.vr_len; i++)
- sc->sk_vpd_prodname[i] = sk_vpd_readbyte(sc, i + pos);
- sc->sk_vpd_prodname[i] = '\0';
- pos += i;
-
- sk_vpd_read_res(sc, &res, pos);
-
- if (res.vr_id != VPD_RES_READ) {
- printf("skc%d: bad VPD resource id: expected %x got %x\n",
- sc->sk_unit, VPD_RES_READ, res.vr_id);
- return;
- }
-
- pos += sizeof(res);
- sc->sk_vpd_readonly = malloc(res.vr_len, M_DEVBUF, M_NOWAIT);
- for (i = 0; i < res.vr_len + 1; i++)
- sc->sk_vpd_readonly[i] = sk_vpd_readbyte(sc, i + pos);
-
- return;
-}
-
-static u_int16_t sk_phy_readreg(sc_if, reg)
- struct sk_if_softc *sc_if;
- int reg;
-{
- int i;
-
- SK_XM_WRITE_2(sc_if, XM_PHY_ADDR, reg);
- for (i = 0; i < SK_TIMEOUT; i++) {
- if (!(SK_XM_READ_2(sc_if, XM_MMUCMD) & XM_MMUCMD_PHYBUSY))
- break;
- }
-
- if (i == SK_TIMEOUT) {
- printf("sk%d: phy failed to come ready\n", sc_if->sk_unit);
- return(0);
- }
-
- return(SK_XM_READ_2(sc_if, XM_PHY_DATA));
-}
-
-static void sk_phy_writereg(sc_if, reg, val)
- struct sk_if_softc *sc_if;
- int reg;
- u_int32_t val;
-{
- int i;
-
- SK_XM_WRITE_2(sc_if, XM_PHY_ADDR, reg);
- for (i = 0; i < SK_TIMEOUT; i++) {
- if (!(SK_XM_READ_2(sc_if, XM_MMUCMD) & XM_MMUCMD_PHYBUSY))
- break;
- }
-
- if (i == SK_TIMEOUT) {
- printf("sk%d: phy failed to come ready\n", sc_if->sk_unit);
- return;
- }
-
- SK_XM_WRITE_2(sc_if, XM_PHY_DATA, val);
- for (i = 0; i < SK_TIMEOUT; i++) {
- if (!(SK_XM_READ_2(sc_if, XM_MMUCMD) & XM_MMUCMD_PHYBUSY))
- break;
- }
-
- if (i == SK_TIMEOUT)
- printf("sk%d: phy write timed out\n", sc_if->sk_unit);
-
- return;
-}
-
-#define SK_POLY 0xEDB88320
-#define SK_BITS 6
-
-static u_int32_t sk_calchash(addr)
- caddr_t addr;
-{
- u_int32_t idx, bit, data, crc;
-
- /* Compute CRC for the address value. */
- crc = 0xFFFFFFFF; /* initial value */
-
- for (idx = 0; idx < 6; idx++) {
- for (data = *addr++, bit = 0; bit < 8; bit++, data >>= 1)
- crc = (crc >> 1) ^ (((crc ^ data) & 1) ? SK_POLY : 0);
- }
-
- return (~crc & ((1 << SK_BITS) - 1));
-}
-
-static void sk_setfilt(sc_if, addr, slot)
- struct sk_if_softc *sc_if;
- caddr_t addr;
- int slot;
-{
- int base;
-
- base = XM_RXFILT_ENTRY(slot);
-
- SK_XM_WRITE_2(sc_if, base, *(u_int16_t *)(&addr[0]));
- SK_XM_WRITE_2(sc_if, base + 2, *(u_int16_t *)(&addr[2]));
- SK_XM_WRITE_2(sc_if, base + 4, *(u_int16_t *)(&addr[4]));
-
- return;
-}
-
-static void sk_setmulti(sc_if)
- struct sk_if_softc *sc_if;
-{
- struct ifnet *ifp;
- u_int32_t hashes[2] = { 0, 0 };
- int h, i;
- struct ifmultiaddr *ifma;
- u_int8_t dummy[] = { 0, 0, 0, 0, 0 ,0 };
-
- ifp = &sc_if->arpcom.ac_if;
-
- /* First, zot all the existing filters. */
- for (i = 1; i < XM_RXFILT_MAX; i++)
- sk_setfilt(sc_if, (caddr_t)&dummy, i);
- SK_XM_WRITE_4(sc_if, XM_MAR0, 0);
- SK_XM_WRITE_4(sc_if, XM_MAR2, 0);
-
- /* Now program new ones. */
- if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) {
- hashes[0] = 0xFFFFFFFF;
- hashes[1] = 0xFFFFFFFF;
- } else {
- i = 1;
- /* First find the tail of the list. */
- for (ifma = ifp->if_multiaddrs.lh_first; ifma != NULL;
- ifma = ifma->ifma_link.le_next) {
- if (ifma->ifma_link.le_next == NULL)
- break;
- }
- /* Now traverse the list backwards. */
- for (; ifma != NULL && ifma != (void *)&ifp->if_multiaddrs;
- ifma = (struct ifmultiaddr *)ifma->ifma_link.le_prev) {
- if (ifma->ifma_addr->sa_family != AF_LINK)
- continue;
- /*
- * Program the first XM_RXFILT_MAX multicast groups
- * into the perfect filter. For all others,
- * use the hash table.
- */
- if (i < XM_RXFILT_MAX) {
- sk_setfilt(sc_if,
- LLADDR((struct sockaddr_dl *)ifma->ifma_addr), i);
- i++;
- continue;
- }
-
- h = sk_calchash(
- LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
- if (h < 32)
- hashes[0] |= (1 << h);
- else
- hashes[1] |= (1 << (h - 32));
- }
- }
-
- SK_XM_SETBIT_4(sc_if, XM_MODE, XM_MODE_RX_USE_HASH|
- XM_MODE_RX_USE_PERFECT);
- SK_XM_WRITE_4(sc_if, XM_MAR0, hashes[0]);
- SK_XM_WRITE_4(sc_if, XM_MAR2, hashes[1]);
-
- return;
-}
-
-static int sk_init_rx_ring(sc_if)
- struct sk_if_softc *sc_if;
-{
- struct sk_chain_data *cd;
- struct sk_ring_data *rd;
- int i;
-
- cd = &sc_if->sk_cdata;
- rd = sc_if->sk_rdata;
-
- bzero((char *)rd->sk_rx_ring,
- sizeof(struct sk_rx_desc) * SK_RX_RING_CNT);
-
- for (i = 0; i < SK_RX_RING_CNT; i++) {
- cd->sk_rx_chain[i].sk_desc = &rd->sk_rx_ring[i];
- if (sk_newbuf(sc_if, &cd->sk_rx_chain[i], NULL) == ENOBUFS)
- return(ENOBUFS);
- if (i == (SK_RX_RING_CNT - 1)) {
- cd->sk_rx_chain[i].sk_next =
- &cd->sk_rx_chain[0];
- rd->sk_rx_ring[i].sk_next =
- vtophys(&rd->sk_rx_ring[0]);
- } else {
- cd->sk_rx_chain[i].sk_next =
- &cd->sk_rx_chain[i + 1];
- rd->sk_rx_ring[i].sk_next =
- vtophys(&rd->sk_rx_ring[i + 1]);
- }
- }
-
- sc_if->sk_cdata.sk_rx_prod = 0;
- sc_if->sk_cdata.sk_rx_cons = 0;
-
- return(0);
-}
-
-static void sk_init_tx_ring(sc_if)
- struct sk_if_softc *sc_if;
-{
- struct sk_chain_data *cd;
- struct sk_ring_data *rd;
- int i;
-
- cd = &sc_if->sk_cdata;
- rd = sc_if->sk_rdata;
-
- bzero((char *)sc_if->sk_rdata->sk_tx_ring,
- sizeof(struct sk_tx_desc) * SK_TX_RING_CNT);
-
- for (i = 0; i < SK_TX_RING_CNT; i++) {
- cd->sk_tx_chain[i].sk_desc = &rd->sk_tx_ring[i];
- if (i == (SK_TX_RING_CNT - 1)) {
- cd->sk_tx_chain[i].sk_next =
- &cd->sk_tx_chain[0];
- rd->sk_tx_ring[i].sk_next =
- vtophys(&rd->sk_tx_ring[0]);
- } else {
- cd->sk_tx_chain[i].sk_next =
- &cd->sk_tx_chain[i + 1];
- rd->sk_tx_ring[i].sk_next =
- vtophys(&rd->sk_tx_ring[i + 1]);
- }
- }
-
- sc_if->sk_cdata.sk_tx_prod = 0;
- sc_if->sk_cdata.sk_tx_cons = 0;
- sc_if->sk_cdata.sk_tx_cnt = 0;
-
- return;
-}
-
-static int sk_newbuf(sc_if, c, m)
- struct sk_if_softc *sc_if;
- struct sk_chain *c;
- struct mbuf *m;
-{
- struct mbuf *m_new = NULL;
- struct sk_rx_desc *r;
-
- if (m == NULL) {
- caddr_t *buf = NULL;
-
- MGETHDR(m_new, M_DONTWAIT, MT_DATA);
- if (m_new == NULL) {
- printf("sk%d: no memory for rx list -- "
- "packet dropped!\n", sc_if->sk_unit);
- return(ENOBUFS);
- }
-
- /* Allocate the jumbo buffer */
- buf = sk_jalloc(sc_if);
- if (buf == NULL) {
- m_freem(m_new);
-#ifdef SK_VERBOSE
- printf("sk%d: jumbo allocation failed "
- "-- packet dropped!\n", sc_if->sk_unit);
-#endif
- return(ENOBUFS);
- }
-
- /* Attach the buffer to the mbuf */
- m_new->m_data = m_new->m_ext.ext_buf = (void *)buf;
- m_new->m_flags |= M_EXT;
- m_new->m_ext.ext_size = m_new->m_pkthdr.len =
- m_new->m_len = SK_MCLBYTES;
- m_new->m_ext.ext_free = sk_jfree;
- m_new->m_ext.ext_ref = sk_jref;
- } else {
- /*
- * We're re-using a previously allocated mbuf;
- * be sure to re-init pointers and lengths to
- * default values.
- */
- m_new = m;
- m_new->m_len = m_new->m_pkthdr.len = SK_MCLBYTES;
- m_new->m_data = m_new->m_ext.ext_buf;
- }
-
- /*
- * Adjust alignment so packet payload begins on a
- * longword boundary. Mandatory for Alpha, useful on
- * x86 too.
- */
- m_adj(m_new, ETHER_ALIGN);
-
- r = c->sk_desc;
- c->sk_mbuf = m_new;
- r->sk_data_lo = vtophys(mtod(m_new, caddr_t));
- r->sk_ctl = m_new->m_len | SK_RXSTAT;
-
- return(0);
-}
-
-/*
- * Allocate jumbo buffer storage. The SysKonnect adapters support
- * "jumbograms" (9K frames), although SysKonnect doesn't currently
- * use them in their drivers. In order for us to use them, we need
- * large 9K receive buffers, however standard mbuf clusters are only
- * 2048 bytes in size. Consequently, we need to allocate and manage
- * our own jumbo buffer pool. Fortunately, this does not require an
- * excessive amount of additional code.
- */
-static int sk_alloc_jumbo_mem(sc_if)
- struct sk_if_softc *sc_if;
-{
- caddr_t ptr;
- register int i;
- struct sk_jpool_entry *entry;
-
- /* Grab a big chunk o' storage. */
- sc_if->sk_cdata.sk_jumbo_buf = contigmalloc(SK_JMEM, M_DEVBUF,
- M_NOWAIT, 0, 0xffffffff, PAGE_SIZE, 0);
-
- if (sc_if->sk_cdata.sk_jumbo_buf == NULL) {
- printf("sk%d: no memory for jumbo buffers!\n", sc_if->sk_unit);
- return(ENOBUFS);
- }
-
- SLIST_INIT(&sc_if->sk_jfree_listhead);
- SLIST_INIT(&sc_if->sk_jinuse_listhead);
-
- /*
- * Now divide it up into 9K pieces and save the addresses
- * in an array. Note that we play an evil trick here by using
- * the first few bytes in the buffer to hold the the address
- * of the softc structure for this interface. This is because
- * sk_jfree() needs it, but it is called by the mbuf management
- * code which will not pass it to us explicitly.
- */
- ptr = sc_if->sk_cdata.sk_jumbo_buf;
- for (i = 0; i < SK_JSLOTS; i++) {
- u_int64_t **aptr;
- aptr = (u_int64_t **)ptr;
- aptr[0] = (u_int64_t *)sc_if;
- ptr += sizeof(u_int64_t);
- sc_if->sk_cdata.sk_jslots[i].sk_buf = ptr;
- sc_if->sk_cdata.sk_jslots[i].sk_inuse = 0;
- ptr += SK_MCLBYTES;
- entry = malloc(sizeof(struct sk_jpool_entry),
- M_DEVBUF, M_NOWAIT);
- if (entry == NULL) {
- free(sc_if->sk_cdata.sk_jumbo_buf, M_DEVBUF);
- sc_if->sk_cdata.sk_jumbo_buf = NULL;
- printf("sk%d: no memory for jumbo "
- "buffer queue!\n", sc_if->sk_unit);
- return(ENOBUFS);
- }
- entry->slot = i;
- SLIST_INSERT_HEAD(&sc_if->sk_jfree_listhead,
- entry, jpool_entries);
- }
-
- return(0);
-}
-
-/*
- * Allocate a jumbo buffer.
- */
-static void *sk_jalloc(sc_if)
- struct sk_if_softc *sc_if;
-{
- struct sk_jpool_entry *entry;
-
- entry = SLIST_FIRST(&sc_if->sk_jfree_listhead);
-
- if (entry == NULL) {
-#ifdef SK_VERBOSE
- printf("sk%d: no free jumbo buffers\n", sc_if->sk_unit);
-#endif
- return(NULL);
- }
-
- SLIST_REMOVE_HEAD(&sc_if->sk_jfree_listhead, jpool_entries);
- SLIST_INSERT_HEAD(&sc_if->sk_jinuse_listhead, entry, jpool_entries);
- sc_if->sk_cdata.sk_jslots[entry->slot].sk_inuse = 1;
- return(sc_if->sk_cdata.sk_jslots[entry->slot].sk_buf);
-}
-
-/*
- * Adjust usage count on a jumbo buffer. In general this doesn't
- * get used much because our jumbo buffers don't get passed around
- * a lot, but it's implemented for correctness.
- */
-static void sk_jref(buf, size)
- caddr_t buf;
- u_int size;
-{
- struct sk_if_softc *sc_if;
- u_int64_t **aptr;
- register int i;
-
- /* Extract the softc struct pointer. */
- aptr = (u_int64_t **)(buf - sizeof(u_int64_t));
- sc_if = (struct sk_if_softc *)(aptr[0]);
-
- if (sc_if == NULL)
- panic("sk_jref: can't find softc pointer!");
-
- if (size != SK_MCLBYTES)
- panic("sk_jref: adjusting refcount of buf of wrong size!");
-
- /* calculate the slot this buffer belongs to */
-
- i = ((vm_offset_t)aptr
- - (vm_offset_t)sc_if->sk_cdata.sk_jumbo_buf) / SK_JLEN;
-
- if ((i < 0) || (i >= SK_JSLOTS))
- panic("sk_jref: asked to reference buffer "
- "that we don't manage!");
- else if (sc_if->sk_cdata.sk_jslots[i].sk_inuse == 0)
- panic("sk_jref: buffer already free!");
- else
- sc_if->sk_cdata.sk_jslots[i].sk_inuse++;
-
- return;
-}
-
-/*
- * Release a jumbo buffer.
- */
-static void sk_jfree(buf, size)
- caddr_t buf;
- u_int size;
-{
- struct sk_if_softc *sc_if;
- u_int64_t **aptr;
- int i;
- struct sk_jpool_entry *entry;
-
- /* Extract the softc struct pointer. */
- aptr = (u_int64_t **)(buf - sizeof(u_int64_t));
- sc_if = (struct sk_if_softc *)(aptr[0]);
-
- if (sc_if == NULL)
- panic("sk_jfree: can't find softc pointer!");
-
- if (size != SK_MCLBYTES)
- panic("sk_jfree: freeing buffer of wrong size!");
-
- /* calculate the slot this buffer belongs to */
-
- i = ((vm_offset_t)aptr
- - (vm_offset_t)sc_if->sk_cdata.sk_jumbo_buf) / SK_JLEN;
-
- if ((i < 0) || (i >= SK_JSLOTS))
- panic("sk_jfree: asked to free buffer that we don't manage!");
- else if (sc_if->sk_cdata.sk_jslots[i].sk_inuse == 0)
- panic("sk_jfree: buffer already free!");
- else {
- sc_if->sk_cdata.sk_jslots[i].sk_inuse--;
- if(sc_if->sk_cdata.sk_jslots[i].sk_inuse == 0) {
- entry = SLIST_FIRST(&sc_if->sk_jinuse_listhead);
- if (entry == NULL)
- panic("sk_jfree: buffer not in use!");
- entry->slot = i;
- SLIST_REMOVE_HEAD(&sc_if->sk_jinuse_listhead,
- jpool_entries);
- SLIST_INSERT_HEAD(&sc_if->sk_jfree_listhead,
- entry, jpool_entries);
- }
- }
-
- return;
-}
-
-/*
- * Set media options.
- */
-static int sk_ifmedia_upd(ifp)
- struct ifnet *ifp;
-{
- struct sk_if_softc *sc_if;
- struct ifmedia *ifm;
-
- sc_if = ifp->if_softc;
- ifm = &sc_if->ifmedia;
-
- if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER)
- return(EINVAL);
-
- switch(IFM_SUBTYPE(ifm->ifm_media)) {
- case IFM_AUTO:
- sk_phy_writereg(sc_if, XM_PHY_BMCR,
- XM_BMCR_RENEGOTIATE|XM_BMCR_AUTONEGENBL);
- break;
- case IFM_1000_LX:
- case IFM_1000_SX:
- case IFM_1000_CX:
- case IFM_1000_TX:
- if ((ifm->ifm_media & IFM_GMASK) == IFM_FDX)
- sk_phy_writereg(sc_if, XM_PHY_BMCR, XM_BMCR_DUPLEX);
- else
- sk_phy_writereg(sc_if, XM_PHY_BMCR, 0);
- break;
- default:
- printf("sk%d: invalid media selected\n", sc_if->sk_unit);
- return(EINVAL);
- break;
- }
-
- return(0);
-}
-
-/*
- * Report current media status.
- */
-static void sk_ifmedia_sts(ifp, ifmr)
- struct ifnet *ifp;
- struct ifmediareq *ifmr;
-{
- struct sk_softc *sc;
- struct sk_if_softc *sc_if;
- u_int16_t bmsr, extsts;
-
- sc_if = ifp->if_softc;
- sc = sc_if->sk_softc;
-
- ifmr->ifm_status = IFM_AVALID;
- ifmr->ifm_active = IFM_ETHER;
-
- bmsr = sk_phy_readreg(sc_if, XM_PHY_BMSR);
- extsts = sk_phy_readreg(sc_if, XM_PHY_EXTSTS);
-
- if (!(bmsr & XM_BMSR_LINKSTAT))
- return;
-
- ifmr->ifm_status |= IFM_ACTIVE;
- ifmr->ifm_active |= sc->sk_pmd;;
- if (extsts & XM_EXTSTS_FULLDUPLEX)
- ifmr->ifm_active |= IFM_FDX;
- else
- ifmr->ifm_active |= IFM_HDX;
-
- return;
-}
-
-static int sk_ioctl(ifp, command, data)
- struct ifnet *ifp;
- u_long command;
- caddr_t data;
-{
- struct sk_if_softc *sc_if = ifp->if_softc;
- struct ifreq *ifr = (struct ifreq *) data;
- int s, error = 0;
-
- s = splimp();
-
- switch(command) {
- case SIOCSIFADDR:
- case SIOCGIFADDR:
- error = ether_ioctl(ifp, command, data);
- break;
- case SIOCSIFMTU:
- if (ifr->ifr_mtu > SK_JUMBO_MTU)
- error = EINVAL;
- else {
- ifp->if_mtu = ifr->ifr_mtu;
- sk_init(sc_if);
- }
- break;
- case SIOCSIFFLAGS:
- if (ifp->if_flags & IFF_UP) {
- if (ifp->if_flags & IFF_RUNNING &&
- ifp->if_flags & IFF_PROMISC &&
- !(sc_if->sk_if_flags & IFF_PROMISC)) {
- SK_XM_SETBIT_4(sc_if, XM_MODE,
- XM_MODE_RX_PROMISC);
- sk_setmulti(sc_if);
- } else if (ifp->if_flags & IFF_RUNNING &&
- !(ifp->if_flags & IFF_PROMISC) &&
- sc_if->sk_if_flags & IFF_PROMISC) {
- SK_XM_CLRBIT_4(sc_if, XM_MODE,
- XM_MODE_RX_PROMISC);
- sk_setmulti(sc_if);
- } else
- sk_init(sc_if);
- } else {
- if (ifp->if_flags & IFF_RUNNING)
- sk_stop(sc_if);
- }
- sc_if->sk_if_flags = ifp->if_flags;
- error = 0;
- break;
- case SIOCADDMULTI:
- case SIOCDELMULTI:
- sk_setmulti(sc_if);
- error = 0;
- break;
- case SIOCGIFMEDIA:
- case SIOCSIFMEDIA:
- error = ifmedia_ioctl(ifp, ifr, &sc_if->ifmedia, command);
- break;
- default:
- error = EINVAL;
- break;
- }
-
- (void)splx(s);
-
- return(error);
-}
-
-/*
- * Probe for a SysKonnect GEnesis chip. Check the PCI vendor and device
- * IDs against our list and return a device name if we find a match.
- */
-static int sk_probe(dev)
- device_t dev;
-{
- struct sk_type *t;
-
- t = sk_devs;
-
- while(t->sk_name != NULL) {
- if ((pci_get_vendor(dev) == t->sk_vid) &&
- (pci_get_device(dev) == t->sk_did)) {
- device_set_desc(dev, t->sk_name);
- return(0);
- }
- t++;
- }
-
- return(ENXIO);
-}
-
-/*
- * Force the GEnesis into reset, then bring it out of reset.
- */
-static void sk_reset(sc)
- struct sk_softc *sc;
-{
- CSR_WRITE_4(sc, SK_CSR, SK_CSR_SW_RESET);
- CSR_WRITE_4(sc, SK_CSR, SK_CSR_MASTER_RESET);
- DELAY(1000);
- CSR_WRITE_4(sc, SK_CSR, SK_CSR_SW_UNRESET);
- CSR_WRITE_4(sc, SK_CSR, SK_CSR_MASTER_UNRESET);
-
- /* Configure packet arbiter */
- sk_win_write_2(sc, SK_PKTARB_CTL, SK_PKTARBCTL_UNRESET);
- sk_win_write_2(sc, SK_RXPA1_TINIT, SK_PKTARB_TIMEOUT);
- sk_win_write_2(sc, SK_TXPA1_TINIT, SK_PKTARB_TIMEOUT);
- sk_win_write_2(sc, SK_RXPA2_TINIT, SK_PKTARB_TIMEOUT);
- sk_win_write_2(sc, SK_TXPA2_TINIT, SK_PKTARB_TIMEOUT);
-
- /* Enable RAM interface */
- sk_win_write_4(sc, SK_RAMCTL, SK_RAMCTL_UNRESET);
-
- /*
- * Configure interrupt moderation. The moderation timer
- * defers interrupts specified in the interrupt moderation
- * timer mask based on the timeout specified in the interrupt
- * moderation timer init register. Each bit in the timer
- * register represents 18.825ns, so to specify a timeout in
- * microseconds, we have to multiply by 54.
- */
- sk_win_write_4(sc, SK_IMTIMERINIT, SK_IM_USECS(200));
- sk_win_write_4(sc, SK_IMMR, SK_ISR_TX1_S_EOF|SK_ISR_TX2_S_EOF|
- SK_ISR_RX1_EOF|SK_ISR_RX2_EOF);
- sk_win_write_1(sc, SK_IMTIMERCTL, SK_IMCTL_START);
-
- return;
-}
-
-/*
- * Each XMAC chip is attached as a separate logical IP interface.
- * Single port cards will have only one logical interface of course.
- */
-static int sk_attach_xmac(sc, port)
- struct sk_softc *sc;
- int port;
-{
- struct sk_if_softc *sc_if;
- struct ifnet *ifp;
- int i;
- char ifname[64];
-
- if (sc == NULL)
- return(EINVAL);
-
- if (port != SK_PORT_A && port != SK_PORT_B)
- return(EINVAL);
-
- sc_if = malloc(sizeof(struct sk_if_softc), M_DEVBUF, M_NOWAIT);
- if (sc_if == NULL) {
- printf("skc%d: no memory for interface softc!\n", sc->sk_unit);
- return(ENOMEM);
- }
- bzero((char *)sc_if, sizeof(struct sk_if_softc));
-
- for (i = 0; i < SK_MAXUNIT; i++) {
- sprintf(ifname, "sk%d", i);
- if (ifunit(ifname) == NULL)
- break;
- }
-
- if (i == SK_MAXUNIT) {
- printf("skc%d: too many sk units\n", sc->sk_unit);
- free(sc_if, M_DEVBUF);
- return(ENODEV);
- }
-
- sc_if->sk_unit = i;
- sc_if->sk_port = port;
- sc_if->sk_softc = sc;
- sc->sk_if[port] = sc_if;
- if (port == SK_PORT_A)
- sc_if->sk_tx_bmu = SK_BMU_TXS_CSR0;
- if (port == SK_PORT_B)
- sc_if->sk_tx_bmu = SK_BMU_TXS_CSR1;
-
- /*
- * Get station address for this interface. Note that
- * dual port cards actually come with three station
- * addresses: one for each port, plus an extra. The
- * extra one is used by the SysKonnect driver software
- * as a 'virtual' station address for when both ports
- * are operating in failover mode. Currently we don't
- * use this extra address.
- */
- for (i = 0; i < ETHER_ADDR_LEN; i++)
- sc_if->arpcom.ac_enaddr[i] =
- sk_win_read_1(sc, SK_MAC0_0 + (port * 8) + i);
-
- printf("sk%d: <XaQti Corp. XMAC II> at skc%d port %d\n",
- sc_if->sk_unit, sc->sk_unit, port);
-
- printf("sk%d: Ethernet address: %6D\n",
- sc_if->sk_unit, sc_if->arpcom.ac_enaddr, ":");
-
- /*
- * Set up RAM buffer addresses. The NIC will have a certain
- * amount of SRAM on it, somewhere between 512K and 2MB. We
- * need to divide this up a) between the transmitter and
- * receiver and b) between the two XMACs, if this is a
- * dual port NIC. Our algotithm is to divide up the memory
- * evenly so that everyone gets a fair share.
- */
- if (sk_win_read_1(sc, SK_CONFIG) & SK_CONFIG_SINGLEMAC) {
- u_int32_t chunk, val;
-
- chunk = sc->sk_ramsize / 2;
- val = sc->sk_rboff / sizeof(u_int64_t);
- sc_if->sk_rx_ramstart = val;
- val += (chunk / sizeof(u_int64_t));
- sc_if->sk_rx_ramend = val - 1;
- sc_if->sk_tx_ramstart = val;
- val += (chunk / sizeof(u_int64_t));
- sc_if->sk_tx_ramend = val - 1;
- } else {
- u_int32_t chunk, val;
-
- chunk = sc->sk_ramsize / 4;
- val = (sc->sk_rboff + (chunk * 2 * sc_if->sk_port)) /
- sizeof(u_int64_t);
- sc_if->sk_rx_ramstart = val;
- val += (chunk / sizeof(u_int64_t));
- sc_if->sk_rx_ramend = val - 1;
- sc_if->sk_tx_ramstart = val;
- val += (chunk / sizeof(u_int64_t));
- sc_if->sk_tx_ramend = val - 1;
- }
-
- /* Allocate the descriptor queues. */
- sc_if->sk_rdata = contigmalloc(sizeof(struct sk_ring_data), M_DEVBUF,
- M_NOWAIT, 0, 0xffffffff, PAGE_SIZE, 0);
-
- if (sc_if->sk_rdata == NULL) {
- printf("sk%d: no memory for list buffers!\n", sc_if->sk_unit);
- free(sc_if, M_DEVBUF);
- sc->sk_if[port] = NULL;
- return(ENOMEM);
- }
-
- bzero(sc_if->sk_rdata, sizeof(struct sk_ring_data));
-
- /* Try to allocate memory for jumbo buffers. */
- if (sk_alloc_jumbo_mem(sc_if)) {
- printf("sk%d: jumbo buffer allocation failed\n",
- sc_if->sk_unit);
- free(sc_if->sk_rdata, M_DEVBUF);
- free(sc_if, M_DEVBUF);
- sc->sk_if[port] = NULL;
- return(ENOMEM);
- }
-
- ifp = &sc_if->arpcom.ac_if;
- ifp->if_softc = sc_if;
- ifp->if_unit = sc_if->sk_unit;
- ifp->if_name = "sk";
- ifp->if_mtu = ETHERMTU;
- ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
- ifp->if_ioctl = sk_ioctl;
- ifp->if_output = ether_output;
- ifp->if_start = sk_start;
- ifp->if_watchdog = sk_watchdog;
- ifp->if_init = sk_init;
- ifp->if_baudrate = 1000000000;
- ifp->if_snd.ifq_maxlen = SK_TX_RING_CNT - 1;
-
- /*
- * Do ifmedia setup.
- */
- ifmedia_init(&sc_if->ifmedia, 0, sk_ifmedia_upd, sk_ifmedia_sts);
- ifmedia_add(&sc_if->ifmedia, IFM_ETHER|sc->sk_pmd, 0, NULL);
- ifmedia_add(&sc_if->ifmedia, IFM_ETHER|sc->sk_pmd|IFM_FDX, 0, NULL);
- ifmedia_add(&sc_if->ifmedia, IFM_ETHER|sc->sk_pmd|IFM_HDX, 0, NULL);
- ifmedia_add(&sc_if->ifmedia, IFM_ETHER|IFM_AUTO, 0, NULL);
- ifmedia_set(&sc_if->ifmedia, IFM_ETHER|IFM_AUTO);
-
- /*
- * Call MI attach routines.
- */
- if_attach(ifp);
- ether_ifattach(ifp);
-
- bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
-
- return(0);
-}
-
-/*
- * Attach the interface. Allocate softc structures, do ifmedia
- * setup and ethernet/BPF attach.
- */
-static int sk_attach(dev)
- device_t dev;
-{
- int s;
- u_int32_t command;
- struct sk_softc *sc;
- int unit, error = 0, rid;
-
- s = splimp();
-
- sc = device_get_softc(dev);
- unit = device_get_unit(dev);
- bzero(sc, sizeof(struct sk_softc));
-
- /*
- * Handle power management nonsense.
- */
- command = pci_read_config(dev, SK_PCI_CAPID, 4) & 0x000000FF;
- if (command == 0x01) {
-
- command = pci_read_config(dev, SK_PCI_PWRMGMTCTRL, 4);
- if (command & SK_PSTATE_MASK) {
- u_int32_t iobase, membase, irq;
-
- /* Save important PCI config data. */
- iobase = pci_read_config(dev, SK_PCI_LOIO, 4);
- membase = pci_read_config(dev, SK_PCI_LOMEM, 4);
- irq = pci_read_config(dev, SK_PCI_INTLINE, 4);
-
- /* Reset the power state. */
- printf("skc%d: chip is in D%d power mode "
- "-- setting to D0\n", unit, command & SK_PSTATE_MASK);
- command &= 0xFFFFFFFC;
- pci_write_config(dev, SK_PCI_PWRMGMTCTRL, command, 4);
-
- /* Restore PCI config data. */
- pci_write_config(dev, SK_PCI_LOIO, iobase, 4);
- pci_write_config(dev, SK_PCI_LOMEM, membase, 4);
- pci_write_config(dev, SK_PCI_INTLINE, irq, 4);
- }
- }
-
- /*
- * Map control/status registers.
- */
- command = pci_read_config(dev, PCI_COMMAND_STATUS_REG, 4);
- command |= (PCIM_CMD_PORTEN|PCIM_CMD_MEMEN|PCIM_CMD_BUSMASTEREN);
- pci_write_config(dev, PCI_COMMAND_STATUS_REG, command, 4);
- command = pci_read_config(dev, PCI_COMMAND_STATUS_REG, 4);
-
-#ifdef SK_USEIOSPACE
- if (!(command & PCIM_CMD_PORTEN)) {
- printf("skc%d: failed to enable I/O ports!\n", unit);
- error = ENXIO;
- goto fail;
- }
-#else
- if (!(command & PCIM_CMD_MEMEN)) {
- printf("skc%d: failed to enable memory mapping!\n", unit);
- error = ENXIO;
- goto fail;
- }
-#endif
-
- rid = SK_RID;
- sc->sk_res = bus_alloc_resource(dev, SK_RES, &rid,
- 0, ~0, 1, RF_ACTIVE);
-
- if (sc->sk_res == NULL) {
- printf("sk%d: couldn't map ports/memory\n", unit);
- error = ENXIO;
- goto fail;
- }
-
- sc->sk_btag = rman_get_bustag(sc->sk_res);
- sc->sk_bhandle = rman_get_bushandle(sc->sk_res);
-
- /* Allocate interrupt */
- rid = 0;
- sc->sk_irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1,
- RF_SHAREABLE | RF_ACTIVE);
-
- if (sc->sk_irq == NULL) {
- printf("skc%d: couldn't map interrupt\n", unit);
- bus_release_resource(dev, SK_RES, SK_RID, sc->sk_res);
- error = ENXIO;
- goto fail;
- }
-
- error = bus_setup_intr(dev, sc->sk_irq, INTR_TYPE_NET,
- sk_intr, sc, &sc->sk_intrhand);
-
- if (error) {
- printf("skc%d: couldn't set up irq\n", unit);
- bus_release_resource(dev, SK_RES, SK_RID, sc->sk_res);
- bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sk_res);
- goto fail;
- }
-
- /* Reset the adapter. */
- sk_reset(sc);
-
- sc->sk_unit = unit;
-
- /* Read and save vital product data from EEPROM. */
- sk_vpd_read(sc);
-
- /* Read and save RAM size and RAMbuffer offset */
- switch(sk_win_read_1(sc, SK_EPROM0)) {
- case SK_RAMSIZE_512K_64:
- sc->sk_ramsize = 0x80000;
- sc->sk_rboff = SK_RBOFF_0;
- break;
- case SK_RAMSIZE_1024K_64:
- sc->sk_ramsize = 0x100000;
- sc->sk_rboff = SK_RBOFF_80000;
- break;
- case SK_RAMSIZE_1024K_128:
- sc->sk_ramsize = 0x100000;
- sc->sk_rboff = SK_RBOFF_0;
- break;
- case SK_RAMSIZE_2048K_128:
- sc->sk_ramsize = 0x200000;
- sc->sk_rboff = SK_RBOFF_0;
- break;
- default:
- printf("skc%d: unknown ram size: %d\n",
- sc->sk_unit, sk_win_read_1(sc, SK_EPROM0));
- bus_teardown_intr(dev, sc->sk_irq, sc->sk_intrhand);
- bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sk_irq);
- bus_release_resource(dev, SK_RES, SK_RID, sc->sk_res);
- error = ENXIO;
- goto fail;
- break;
- }
-
- /* Read and save physical media type */
- switch(sk_win_read_1(sc, SK_PMDTYPE)) {
- case SK_PMD_1000BASESX:
- sc->sk_pmd = IFM_1000_SX;
- break;
- case SK_PMD_1000BASELX:
- sc->sk_pmd = IFM_1000_LX;
- break;
- case SK_PMD_1000BASECX:
- sc->sk_pmd = IFM_1000_CX;
- break;
- case SK_PMD_1000BASETX:
- sc->sk_pmd = IFM_1000_TX;
- break;
- default:
- printf("skc%d: unknown media type: 0x%x\n",
- sc->sk_unit, sk_win_read_1(sc, SK_PMDTYPE));
- bus_teardown_intr(dev, sc->sk_irq, sc->sk_intrhand);
- bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sk_irq);
- bus_release_resource(dev, SK_RES, SK_RID, sc->sk_res);
- error = ENXIO;
- goto fail;
- }
-
- /* Announce the product name. */
- printf("skc%d: %s\n", sc->sk_unit, sc->sk_vpd_prodname);
-
- sk_attach_xmac(sc, SK_PORT_A);
- if (!(sk_win_read_1(sc, SK_CONFIG) & SK_CONFIG_SINGLEMAC))
- sk_attach_xmac(sc, SK_PORT_B);
-
- /* Turn on the 'driver is loaded' LED. */
- CSR_WRITE_2(sc, SK_LED, SK_LED_GREEN_ON);
-
-fail:
- splx(s);
- return(error);
-}
-
-static int sk_detach(dev)
- device_t dev;
-{
- struct sk_softc *sc;
- struct sk_if_softc *sc_if0 = NULL, *sc_if1 = NULL;
- struct ifnet *ifp0 = NULL, *ifp1 = NULL;
- int s;
-
- s = splimp();
-
- sc = device_get_softc(dev);
- sc_if0 = sc->sk_if[SK_PORT_A];
- ifp0 = &sc_if0->arpcom.ac_if;
- sk_stop(sc_if0);
- if_detach(ifp0);
- contigfree(sc_if0->sk_cdata.sk_jumbo_buf, SK_JMEM, M_DEVBUF);
- ifmedia_removeall(&sc_if0->ifmedia);
- free(sc->sk_if[SK_PORT_A], M_DEVBUF);
- if (sc->sk_if[SK_PORT_B] != NULL) {
- sc_if1 = sc->sk_if[SK_PORT_B];
- ifp1 = &sc_if1->arpcom.ac_if;
- sk_stop(sc_if1);
- if_detach(ifp1);
- contigfree(sc_if1->sk_cdata.sk_jumbo_buf, SK_JMEM, M_DEVBUF);
- ifmedia_removeall(&sc_if1->ifmedia);
- free(sc->sk_if[SK_PORT_B], M_DEVBUF);
- }
-
- bus_teardown_intr(dev, sc->sk_irq, sc->sk_intrhand);
- bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sk_irq);
- bus_release_resource(dev, SK_RES, SK_RID, sc->sk_res);
-
- splx(s);
-
- return(0);
-}
-
-static int sk_encap(sc_if, m_head, txidx)
- struct sk_if_softc *sc_if;
- struct mbuf *m_head;
- u_int32_t *txidx;
-{
- struct sk_tx_desc *f = NULL;
- struct mbuf *m;
- u_int32_t frag, cur, cnt = 0;
-
- m = m_head;
- cur = frag = *txidx;
-
- /*
- * Start packing the mbufs in this chain into
- * the fragment pointers. Stop when we run out
- * of fragments or hit the end of the mbuf chain.
- */
- for (m = m_head; m != NULL; m = m->m_next) {
- if (m->m_len != 0) {
- if ((SK_TX_RING_CNT -
- (sc_if->sk_cdata.sk_tx_cnt + cnt)) < 2)
- return(ENOBUFS);
- f = &sc_if->sk_rdata->sk_tx_ring[frag];
- f->sk_data_lo = vtophys(mtod(m, vm_offset_t));
- f->sk_ctl = m->m_len | SK_OPCODE_DEFAULT;
- if (cnt == 0)
- f->sk_ctl |= SK_TXCTL_FIRSTFRAG;
- else
- f->sk_ctl |= SK_TXCTL_OWN;
- cur = frag;
- SK_INC(frag, SK_TX_RING_CNT);
- cnt++;
- }
- }
-
- if (m != NULL)
- return(ENOBUFS);
-
- sc_if->sk_rdata->sk_tx_ring[cur].sk_ctl |=
- SK_TXCTL_LASTFRAG|SK_TXCTL_EOF_INTR;
- sc_if->sk_cdata.sk_tx_chain[cur].sk_mbuf = m_head;
- sc_if->sk_rdata->sk_tx_ring[*txidx].sk_ctl |= SK_TXCTL_OWN;
- sc_if->sk_cdata.sk_tx_cnt += cnt;
-
- *txidx = frag;
-
- return(0);
-}
-
-static void sk_start(ifp)
- struct ifnet *ifp;
-{
- struct sk_softc *sc;
- struct sk_if_softc *sc_if;
- struct mbuf *m_head = NULL;
- u_int32_t idx;
-
- sc_if = ifp->if_softc;
- sc = sc_if->sk_softc;
-
- idx = sc_if->sk_cdata.sk_tx_prod;
-
- while(sc_if->sk_cdata.sk_tx_chain[idx].sk_mbuf == NULL) {
- IF_DEQUEUE(&ifp->if_snd, m_head);
- if (m_head == NULL)
- break;
-
- /*
- * Pack the data into the transmit ring. If we
- * don't have room, set the OACTIVE flag and wait
- * for the NIC to drain the ring.
- */
- if (sk_encap(sc_if, m_head, &idx)) {
- IF_PREPEND(&ifp->if_snd, m_head);
- ifp->if_flags |= IFF_OACTIVE;
- break;
- }
-
- /*
- * If there's a BPF listener, bounce a copy of this frame
- * to him.
- */
- if (ifp->if_bpf)
- bpf_mtap(ifp, m_head);
- }
-
- /* Transmit */
- sc_if->sk_cdata.sk_tx_prod = idx;
- CSR_WRITE_4(sc, sc_if->sk_tx_bmu, SK_TXBMU_TX_START);
-
- /* Set a timeout in case the chip goes out to lunch. */
- ifp->if_timer = 5;
-
- return;
-}
-
-
-static void sk_watchdog(ifp)
- struct ifnet *ifp;
-{
- struct sk_if_softc *sc_if;
-
- sc_if = ifp->if_softc;
-
- printf("sk%d: watchdog timeout\n", sc_if->sk_unit);
- sk_init(sc_if);
-
- return;
-}
-
-static void sk_shutdown(dev)
- device_t dev;
-{
- struct sk_softc *sc;
-
- sc = device_get_softc(dev);
-
- /* Turn off the 'driver is loaded' LED. */
- CSR_WRITE_2(sc, SK_LED, SK_LED_GREEN_OFF);
-
- /*
- * Reset the GEnesis controller. Doing this should also
- * assert the resets on the attached XMAC(s).
- */
- sk_reset(sc);
-
- return;
-}
-
-static void sk_rxeof(sc_if)
- struct sk_if_softc *sc_if;
-{
- struct ether_header *eh;
- struct mbuf *m;
- struct ifnet *ifp;
- struct sk_chain *cur_rx;
- int total_len = 0;
- int i;
- u_int32_t rxstat;
-
- ifp = &sc_if->arpcom.ac_if;
- i = sc_if->sk_cdata.sk_rx_prod;
- cur_rx = &sc_if->sk_cdata.sk_rx_chain[i];
-
- while(!(sc_if->sk_rdata->sk_rx_ring[i].sk_ctl & SK_RXCTL_OWN)) {
-
- cur_rx = &sc_if->sk_cdata.sk_rx_chain[i];
- rxstat = sc_if->sk_rdata->sk_rx_ring[i].sk_xmac_rxstat;
- m = cur_rx->sk_mbuf;
- cur_rx->sk_mbuf = NULL;
- total_len = SK_RXBYTES(sc_if->sk_rdata->sk_rx_ring[i].sk_ctl);
- SK_INC(i, SK_RX_RING_CNT);
-
- if (rxstat & XM_RXSTAT_ERRFRAME) {
- ifp->if_ierrors++;
- sk_newbuf(sc_if, cur_rx, m);
- continue;
- }
-
- /*
- * Try to allocate a new jumbo buffer. If that
- * fails, copy the packet to mbufs and put the
- * jumbo buffer back in the ring so it can be
- * re-used. If allocating mbufs fails, then we
- * have to drop the packet.
- */
- if (sk_newbuf(sc_if, cur_rx, NULL) == ENOBUFS) {
- struct mbuf *m0;
- m0 = m_devget(mtod(m, char *) - ETHER_ALIGN,
- total_len + ETHER_ALIGN, 0, ifp, NULL);
- sk_newbuf(sc_if, cur_rx, m);
- if (m0 == NULL) {
- printf("sk%d: no receive buffers "
- "available -- packet dropped!\n",
- sc_if->sk_unit);
- ifp->if_ierrors++;
- continue;
- }
- m_adj(m0, ETHER_ALIGN);
- m = m0;
- } else {
- m->m_pkthdr.rcvif = ifp;
- m->m_pkthdr.len = m->m_len = total_len;
- }
-
- ifp->if_ipackets++;
- eh = mtod(m, struct ether_header *);
-
- if (ifp->if_bpf) {
- bpf_mtap(ifp, m);
- if (ifp->if_flags & IFF_PROMISC &&
- (bcmp(eh->ether_dhost, sc_if->arpcom.ac_enaddr,
- ETHER_ADDR_LEN) && !(eh->ether_dhost[0] & 1))) {
- m_freem(m);
- continue;
- }
- }
-
- /* Remove header from mbuf and pass it on. */
- m_adj(m, sizeof(struct ether_header));
- ether_input(ifp, eh, m);
- }
-
- sc_if->sk_cdata.sk_rx_prod = i;
-
- return;
-}
-
-static void sk_txeof(sc_if)
- struct sk_if_softc *sc_if;
-{
- struct sk_tx_desc *cur_tx = NULL;
- struct ifnet *ifp;
- u_int32_t idx;
-
- ifp = &sc_if->arpcom.ac_if;
-
- /*
- * Go through our tx ring and free mbufs for those
- * frames that have been sent.
- */
- idx = sc_if->sk_cdata.sk_tx_cons;
- while(idx != sc_if->sk_cdata.sk_tx_prod) {
- cur_tx = &sc_if->sk_rdata->sk_tx_ring[idx];
- if (cur_tx->sk_ctl & SK_TXCTL_OWN)
- break;
- if (cur_tx->sk_ctl & SK_TXCTL_LASTFRAG)
- ifp->if_opackets++;
- if (sc_if->sk_cdata.sk_tx_chain[idx].sk_mbuf != NULL) {
- m_freem(sc_if->sk_cdata.sk_tx_chain[idx].sk_mbuf);
- sc_if->sk_cdata.sk_tx_chain[idx].sk_mbuf = NULL;
- }
- sc_if->sk_cdata.sk_tx_cnt--;
- SK_INC(idx, SK_TX_RING_CNT);
- ifp->if_timer = 0;
- }
-
- sc_if->sk_cdata.sk_tx_cons = idx;
-
- if (cur_tx != NULL)
- ifp->if_flags &= ~IFF_OACTIVE;
-
- return;
-}
-
-static void sk_intr_xmac(sc_if)
- struct sk_if_softc *sc_if;
-{
- struct sk_softc *sc;
- u_int16_t status;
- u_int16_t bmsr;
-
- sc = sc_if->sk_softc;
- status = SK_XM_READ_2(sc_if, XM_ISR);
-
- if (status & XM_ISR_LINKEVENT) {
- SK_XM_SETBIT_2(sc_if, XM_IMR, XM_IMR_LINKEVENT);
- if (sc_if->sk_link == 1) {
- printf("sk%d: gigabit link down\n", sc_if->sk_unit);
- sc_if->sk_link = 0;
- }
- }
-
- if (status & XM_ISR_AUTONEG_DONE) {
- bmsr = sk_phy_readreg(sc_if, XM_PHY_BMSR);
- if (bmsr & XM_BMSR_LINKSTAT) {
- sc_if->sk_link = 1;
- SK_XM_CLRBIT_2(sc_if, XM_IMR, XM_IMR_LINKEVENT);
- printf("sk%d: gigabit link up\n", sc_if->sk_unit);
- }
- }
-
- if (status & XM_IMR_TX_UNDERRUN)
- SK_XM_SETBIT_4(sc_if, XM_MODE, XM_MODE_FLUSH_TXFIFO);
-
- if (status & XM_IMR_RX_OVERRUN)
- SK_XM_SETBIT_4(sc_if, XM_MODE, XM_MODE_FLUSH_RXFIFO);
-
- return;
-}
-
-static void sk_intr(xsc)
- void *xsc;
-{
- struct sk_softc *sc = xsc;
- struct sk_if_softc *sc_if0 = NULL, *sc_if1 = NULL;
- struct ifnet *ifp0 = NULL, *ifp1 = NULL;
- u_int32_t status;
-
- sc_if0 = sc->sk_if[SK_PORT_A];
- sc_if1 = sc->sk_if[SK_PORT_B];
-
- if (sc_if0 != NULL)
- ifp0 = &sc_if0->arpcom.ac_if;
- if (sc_if1 != NULL)
- ifp1 = &sc_if0->arpcom.ac_if;
-
- for (;;) {
- status = CSR_READ_4(sc, SK_ISSR);
- if (!(status & sc->sk_intrmask))
- break;
-
- /* Handle receive interrupts first. */
- if (status & SK_ISR_RX1_EOF) {
- sk_rxeof(sc_if0);
- CSR_WRITE_4(sc, SK_BMU_RX_CSR0,
- SK_RXBMU_CLR_IRQ_EOF|SK_RXBMU_RX_START);
- }
- if (status & SK_ISR_RX2_EOF) {
- sk_rxeof(sc_if1);
- CSR_WRITE_4(sc, SK_BMU_RX_CSR1,
- SK_RXBMU_CLR_IRQ_EOF|SK_RXBMU_RX_START);
- }
-
- /* Then transmit interrupts. */
- if (status & SK_ISR_TX1_S_EOF) {
- sk_txeof(sc_if0);
- CSR_WRITE_4(sc, SK_BMU_TXS_CSR0,
- SK_TXBMU_CLR_IRQ_EOF);
- }
- if (status & SK_ISR_TX2_S_EOF) {
- sk_txeof(sc_if1);
- CSR_WRITE_4(sc, SK_BMU_TXS_CSR1,
- SK_TXBMU_CLR_IRQ_EOF);
- }
-
- /* Then MAC interrupts. */
- if (status & SK_ISR_MAC1)
- sk_intr_xmac(sc_if0);
-
- if (status & SK_ISR_MAC2)
- sk_intr_xmac(sc_if1);
- }
-
- CSR_WRITE_4(sc, SK_IMR, sc->sk_intrmask);
-
- if (ifp0 != NULL && ifp0->if_snd.ifq_head != NULL)
- sk_start(ifp0);
- if (ifp1 != NULL && ifp1->if_snd.ifq_head != NULL)
- sk_start(ifp1);
-
- return;
-}
-
-static void sk_init_xmac(sc_if)
- struct sk_if_softc *sc_if;
-{
- struct sk_softc *sc;
- struct ifnet *ifp;
-
- sc = sc_if->sk_softc;
- ifp = &sc_if->arpcom.ac_if;
-
- /* Unreset the XMAC. */
- SK_IF_WRITE_2(sc_if, 0, SK_TXF1_MACCTL, SK_TXMACCTL_XMAC_UNRESET);
- DELAY(1000);
-
- /* Save the XMAC II revision */
- sc_if->sk_xmac_rev = XM_XMAC_REV(SK_XM_READ_4(sc_if, XM_DEVID));
-
- /* Set station address */
- SK_XM_WRITE_2(sc_if, XM_PAR0,
- *(u_int16_t *)(&sc_if->arpcom.ac_enaddr[0]));
- SK_XM_WRITE_2(sc_if, XM_PAR1,
- *(u_int16_t *)(&sc_if->arpcom.ac_enaddr[2]));
- SK_XM_WRITE_2(sc_if, XM_PAR2,
- *(u_int16_t *)(&sc_if->arpcom.ac_enaddr[4]));
- SK_XM_SETBIT_4(sc_if, XM_MODE, XM_MODE_RX_USE_STATION);
-
- if (ifp->if_flags & IFF_PROMISC) {
- SK_XM_SETBIT_4(sc_if, XM_MODE, XM_MODE_RX_PROMISC);
- } else {
- SK_XM_CLRBIT_4(sc_if, XM_MODE, XM_MODE_RX_PROMISC);
- }
-
- if (ifp->if_flags & IFF_BROADCAST) {
- SK_XM_CLRBIT_4(sc_if, XM_MODE, XM_MODE_RX_NOBROAD);
- } else {
- SK_XM_SETBIT_4(sc_if, XM_MODE, XM_MODE_RX_NOBROAD);
- }
-
- /* We don't need the FCS appended to the packet. */
- SK_XM_SETBIT_2(sc_if, XM_RXCMD, XM_RXCMD_STRIPFCS);
-
- /* We want short frames padded to 60 bytes. */
- SK_XM_SETBIT_2(sc_if, XM_TXCMD, XM_TXCMD_AUTOPAD);
-
- /*
- * Enable the reception of all error frames. This is is
- * a necessary evil due to the design of the XMAC. The
- * XMAC's receive FIFO is only 8K in size, however jumbo
- * frames can be up to 9000 bytes in length. When bad
- * frame filtering is enabled, the XMAC's RX FIFO operates
- * in 'store and forward' mode. For this to work, the
- * entire frame has to fit into the FIFO, but that means
- * that jumbo frames larger than 8192 bytes will be
- * truncated. Disabling all bad frame filtering causes
- * the RX FIFO to operate in streaming mode, in which
- * case the XMAC will start transfering frames out of the
- * RX FIFO as soon as the FIFO threshold is reached.
- */
- SK_XM_SETBIT_4(sc_if, XM_MODE, XM_MODE_RX_BADFRAMES|
- XM_MODE_RX_GIANTS|XM_MODE_RX_RUNTS|XM_MODE_RX_CRCERRS|
- XM_MODE_RX_INRANGELEN);
-
- if (ifp->if_mtu > (ETHERMTU + ETHER_HDR_LEN + ETHER_CRC_LEN))
- SK_XM_SETBIT_2(sc_if, XM_RXCMD, XM_RXCMD_BIGPKTOK);
- else
- SK_XM_CLRBIT_2(sc_if, XM_RXCMD, XM_RXCMD_BIGPKTOK);
-
- /*
- * Bump up the transmit threshold. This helps hold off transmit
- * underruns when we're blasting traffic from both ports at once.
- */
- SK_XM_WRITE_2(sc_if, XM_TX_REQTHRESH, SK_XM_TX_FIFOTHRESH);
-
- /* Set multicast filter */
- sk_setmulti(sc_if);
-
- /* Clear and enable interrupts */
- SK_XM_READ_2(sc_if, XM_ISR);
- SK_XM_WRITE_2(sc_if, XM_IMR, XM_INTRS);
-
- sc_if->sk_link = 0;
-
- /* Configure MAC arbiter */
- switch(sc_if->sk_xmac_rev) {
- case XM_XMAC_REV_B2:
- sk_win_write_1(sc, SK_RCINIT_RX1, SK_RCINIT_XMAC_B2);
- sk_win_write_1(sc, SK_RCINIT_TX1, SK_RCINIT_XMAC_B2);
- sk_win_write_1(sc, SK_RCINIT_RX2, SK_RCINIT_XMAC_B2);
- sk_win_write_1(sc, SK_RCINIT_TX2, SK_RCINIT_XMAC_B2);
- sk_win_write_1(sc, SK_MINIT_RX1, SK_MINIT_XMAC_B2);
- sk_win_write_1(sc, SK_MINIT_TX1, SK_MINIT_XMAC_B2);
- sk_win_write_1(sc, SK_MINIT_RX2, SK_MINIT_XMAC_B2);
- sk_win_write_1(sc, SK_MINIT_TX2, SK_MINIT_XMAC_B2);
- sk_win_write_1(sc, SK_RECOVERY_CTL, SK_RECOVERY_XMAC_B2);
- break;
- case XM_XMAC_REV_C1:
- sk_win_write_1(sc, SK_RCINIT_RX1, SK_RCINIT_XMAC_C1);
- sk_win_write_1(sc, SK_RCINIT_TX1, SK_RCINIT_XMAC_C1);
- sk_win_write_1(sc, SK_RCINIT_RX2, SK_RCINIT_XMAC_C1);
- sk_win_write_1(sc, SK_RCINIT_TX2, SK_RCINIT_XMAC_C1);
- sk_win_write_1(sc, SK_MINIT_RX1, SK_MINIT_XMAC_C1);
- sk_win_write_1(sc, SK_MINIT_TX1, SK_MINIT_XMAC_C1);
- sk_win_write_1(sc, SK_MINIT_RX2, SK_MINIT_XMAC_C1);
- sk_win_write_1(sc, SK_MINIT_TX2, SK_MINIT_XMAC_C1);
- sk_win_write_1(sc, SK_RECOVERY_CTL, SK_RECOVERY_XMAC_B2);
- break;
- default:
- break;
- }
- sk_win_write_2(sc, SK_MACARB_CTL,
- SK_MACARBCTL_UNRESET|SK_MACARBCTL_FASTOE_OFF);
-
- return;
-}
-
-/*
- * Note that to properly initialize any part of the GEnesis chip,
- * you first have to take it out of reset mode.
- */
-static void sk_init(xsc)
- void *xsc;
-{
- struct sk_if_softc *sc_if = xsc;
- struct sk_softc *sc;
- struct ifnet *ifp;
- int s;
-
- s = splimp();
-
- ifp = &sc_if->arpcom.ac_if;
- sc = sc_if->sk_softc;
-
- /* Cancel pending I/O and free all RX/TX buffers. */
- sk_stop(sc_if);
-
- /* Configure LINK_SYNC LED */
- SK_IF_WRITE_1(sc_if, 0, SK_LINKLED1_CTL, SK_LINKLED_ON);
- SK_IF_WRITE_1(sc_if, 0, SK_LINKLED1_CTL, SK_LINKLED_LINKSYNC_ON);
-
- /* Configure RX LED */
- SK_IF_WRITE_1(sc_if, 0, SK_RXLED1_CTL, SK_RXLEDCTL_COUNTER_START);
-
- /* Configure TX LED */
- SK_IF_WRITE_1(sc_if, 0, SK_TXLED1_CTL, SK_TXLEDCTL_COUNTER_START);
-
- /* Configure I2C registers */
-
- /* Configure XMAC(s) */
- sk_init_xmac(sc_if);
-
- /* Configure MAC FIFOs */
- SK_IF_WRITE_4(sc_if, 0, SK_RXF1_CTL, SK_FIFO_UNRESET);
- SK_IF_WRITE_4(sc_if, 0, SK_RXF1_END, SK_FIFO_END);
- SK_IF_WRITE_4(sc_if, 0, SK_RXF1_CTL, SK_FIFO_ON);
-
- SK_IF_WRITE_4(sc_if, 0, SK_TXF1_CTL, SK_FIFO_UNRESET);
- SK_IF_WRITE_4(sc_if, 0, SK_TXF1_END, SK_FIFO_END);
- SK_IF_WRITE_4(sc_if, 0, SK_TXF1_CTL, SK_FIFO_ON);
-
- /* Configure transmit arbiter(s) */
- SK_IF_WRITE_1(sc_if, 0, SK_TXAR1_COUNTERCTL,
- SK_TXARCTL_ON|SK_TXARCTL_FSYNC_ON);
-
- /* Configure RAMbuffers */
- SK_IF_WRITE_4(sc_if, 0, SK_RXRB1_CTLTST, SK_RBCTL_UNRESET);
- SK_IF_WRITE_4(sc_if, 0, SK_RXRB1_START, sc_if->sk_rx_ramstart);
- SK_IF_WRITE_4(sc_if, 0, SK_RXRB1_WR_PTR, sc_if->sk_rx_ramstart);
- SK_IF_WRITE_4(sc_if, 0, SK_RXRB1_RD_PTR, sc_if->sk_rx_ramstart);
- SK_IF_WRITE_4(sc_if, 0, SK_RXRB1_END, sc_if->sk_rx_ramend);
- SK_IF_WRITE_4(sc_if, 0, SK_RXRB1_CTLTST, SK_RBCTL_ON);
-
- SK_IF_WRITE_4(sc_if, 1, SK_TXRBS1_CTLTST, SK_RBCTL_UNRESET);
- SK_IF_WRITE_4(sc_if, 1, SK_TXRBS1_CTLTST, SK_RBCTL_STORENFWD_ON);
- SK_IF_WRITE_4(sc_if, 1, SK_TXRBS1_START, sc_if->sk_tx_ramstart);
- SK_IF_WRITE_4(sc_if, 1, SK_TXRBS1_WR_PTR, sc_if->sk_tx_ramstart);
- SK_IF_WRITE_4(sc_if, 1, SK_TXRBS1_RD_PTR, sc_if->sk_tx_ramstart);
- SK_IF_WRITE_4(sc_if, 1, SK_TXRBS1_END, sc_if->sk_tx_ramend);
- SK_IF_WRITE_4(sc_if, 1, SK_TXRBS1_CTLTST, SK_RBCTL_ON);
-
- /* Configure BMUs */
- SK_IF_WRITE_4(sc_if, 0, SK_RXQ1_BMU_CSR, SK_RXBMU_ONLINE);
- SK_IF_WRITE_4(sc_if, 0, SK_RXQ1_CURADDR_LO,
- vtophys(&sc_if->sk_rdata->sk_rx_ring[0]));
- SK_IF_WRITE_4(sc_if, 0, SK_RXQ1_CURADDR_HI, 0);
-
- SK_IF_WRITE_4(sc_if, 1, SK_TXQS1_BMU_CSR, SK_TXBMU_ONLINE);
- SK_IF_WRITE_4(sc_if, 1, SK_TXQS1_CURADDR_LO,
- vtophys(&sc_if->sk_rdata->sk_tx_ring[0]));
- SK_IF_WRITE_4(sc_if, 1, SK_TXQS1_CURADDR_HI, 0);
-
- /* Init descriptors */
- if (sk_init_rx_ring(sc_if) == ENOBUFS) {
- printf("sk%d: initialization failed: no "
- "memory for rx buffers\n", sc_if->sk_unit);
- sk_stop(sc_if);
- (void)splx(s);
- return;
- }
- sk_init_tx_ring(sc_if);
-
- /* Configure interrupt handling */
- CSR_READ_4(sc, SK_ISSR);
- if (sc_if->sk_port == SK_PORT_A)
- sc->sk_intrmask |= SK_INTRS1;
- else
- sc->sk_intrmask |= SK_INTRS2;
- CSR_WRITE_4(sc, SK_IMR, sc->sk_intrmask);
-
- /* Start BMUs. */
- SK_IF_WRITE_4(sc_if, 0, SK_RXQ1_BMU_CSR, SK_RXBMU_RX_START);
-
- /* Enable XMACs TX and RX state machines */
- SK_XM_SETBIT_2(sc_if, XM_MMUCMD, XM_MMUCMD_TX_ENB|XM_MMUCMD_RX_ENB);
-
- ifp->if_flags |= IFF_RUNNING;
- ifp->if_flags &= ~IFF_OACTIVE;
-
- splx(s);
-
- return;
-}
-
-static void sk_stop(sc_if)
- struct sk_if_softc *sc_if;
-{
- int i;
- struct sk_softc *sc;
- struct ifnet *ifp;
-
- sc = sc_if->sk_softc;
- ifp = &sc_if->arpcom.ac_if;
-
- /* Turn off various components of this interface. */
- SK_IF_WRITE_2(sc_if, 0, SK_TXF1_MACCTL, SK_TXMACCTL_XMAC_RESET);
- SK_IF_WRITE_4(sc_if, 0, SK_RXF1_CTL, SK_FIFO_RESET);
- SK_IF_WRITE_4(sc_if, 0, SK_RXQ1_BMU_CSR, SK_RXBMU_OFFLINE);
- SK_IF_WRITE_4(sc_if, 0, SK_RXRB1_CTLTST, SK_RBCTL_RESET|SK_RBCTL_OFF);
- SK_IF_WRITE_4(sc_if, 1, SK_TXQS1_BMU_CSR, SK_TXBMU_OFFLINE);
- SK_IF_WRITE_4(sc_if, 1, SK_TXRBS1_CTLTST, SK_RBCTL_RESET|SK_RBCTL_OFF);
- SK_IF_WRITE_1(sc_if, 0, SK_TXAR1_COUNTERCTL, SK_TXARCTL_OFF);
- SK_IF_WRITE_1(sc_if, 0, SK_RXLED1_CTL, SK_RXLEDCTL_COUNTER_STOP);
- SK_IF_WRITE_1(sc_if, 0, SK_TXLED1_CTL, SK_RXLEDCTL_COUNTER_STOP);
- SK_IF_WRITE_1(sc_if, 0, SK_LINKLED1_CTL, SK_LINKLED_OFF);
- SK_IF_WRITE_1(sc_if, 0, SK_LINKLED1_CTL, SK_LINKLED_LINKSYNC_OFF);
-
- /* Disable interrupts */
- if (sc_if->sk_port == SK_PORT_A)
- sc->sk_intrmask &= ~SK_INTRS1;
- else
- sc->sk_intrmask &= ~SK_INTRS2;
- CSR_WRITE_4(sc, SK_IMR, sc->sk_intrmask);
-
- /* Free RX and TX mbufs still in the queues. */
- for (i = 0; i < SK_RX_RING_CNT; i++) {
- if (sc_if->sk_cdata.sk_rx_chain[i].sk_mbuf != NULL) {
- m_freem(sc_if->sk_cdata.sk_rx_chain[i].sk_mbuf);
- sc_if->sk_cdata.sk_rx_chain[i].sk_mbuf = NULL;
- }
- }
-
- for (i = 0; i < SK_TX_RING_CNT; i++) {
- if (sc_if->sk_cdata.sk_tx_chain[i].sk_mbuf != NULL) {
- m_freem(sc_if->sk_cdata.sk_tx_chain[i].sk_mbuf);
- sc_if->sk_cdata.sk_tx_chain[i].sk_mbuf = NULL;
- }
- }
-
- ifp->if_flags &= ~(IFF_RUNNING|IFF_OACTIVE);
-
- return;
-}
diff --git a/sys/dev/sk/if_skreg.h b/sys/dev/sk/if_skreg.h
deleted file mode 100644
index f30763665bf5..000000000000
--- a/sys/dev/sk/if_skreg.h
+++ /dev/null
@@ -1,1172 +0,0 @@
-/*
- * Copyright (c) 1997, 1998, 1999
- * Bill Paul <wpaul@ctr.columbia.edu>. 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 Bill Paul.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY Bill Paul 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 Bill Paul OR THE VOICES IN HIS HEAD
- * 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.
- *
- * $FreeBSD$
- */
-
-/*
- * SysKonnect PCI vendor ID
- */
-#define SK_VENDORID 0x1148
-
-/*
- * SK-NET gigabit ethernet device ID
- */
-#define SK_DEVICEID_GE 0x4300
-
-/*
- * GEnesis registers. The GEnesis chip has a 256-byte I/O window
- * but internally it has a 16K register space. This 16K space is
- * divided into 128-byte blocks. The first 128 bytes of the I/O
- * window represent the first block, which is permanently mapped
- * at the start of the window. The other 127 blocks can be mapped
- * to the second 128 bytes of the I/O window by setting the desired
- * block value in the RAP register in block 0. Not all of the 127
- * blocks are actually used. Most registers are 32 bits wide, but
- * there are a few 16-bit and 8-bit ones as well.
- */
-
-
-/* Start of remappable register window. */
-#define SK_WIN_BASE 0x0080
-
-/* Size of a window */
-#define SK_WIN_LEN 0x80
-
-#define SK_WIN_MASK 0x3F80
-#define SK_REG_MASK 0x7F
-
-/* Compute the window of a given register (for the RAP register) */
-#define SK_WIN(reg) (((reg) & SK_WIN_MASK) / SK_WIN_LEN)
-
-/* Compute the relative offset of a register within the window */
-#define SK_REG(reg) ((reg) & SK_REG_MASK)
-
-#define SK_PORT_A 0
-#define SK_PORT_B 1
-
-/*
- * Compute offset of port-specific register. Since there are two
- * ports, there are two of some GEnesis modules (e.g. two sets of
- * DMA queues, two sets of FIFO control registers, etc...). Normally,
- * the block for port 0 is at offset 0x0 and the block for port 1 is
- * at offset 0x80 (i.e. the next page over). However for the transmit
- * BMUs and RAMbuffers, there are two blocks for each port: one for
- * the sync transmit queue and one for the async queue (which we don't
- * use). However instead of ordering them like this:
- * TX sync 1 / TX sync 2 / TX async 1 / TX async 2
- * SysKonnect has instead ordered them like this:
- * TX sync 1 / TX async 1 / TX sync 2 / TX async 2
- * This means that when referencing the TX BMU and RAMbuffer registers,
- * we have to double the block offset (0x80 * 2) in order to reach the
- * second queue. This prevents us from using the same formula
- * (sk_port * 0x80) to compute the offsets for all of the port-specific
- * blocks: we need an extra offset for the BMU and RAMbuffer registers.
- * The simplest thing is to provide an extra argument to these macros:
- * the 'skip' parameter. The 'skip' value is the number of extra pages
- * for skip when computing the port0/port1 offsets. For most registers,
- * the skip value is 0; for the BMU and RAMbuffer registers, it's 1.
- */
-#define SK_IF_READ_4(sc_if, skip, reg) \
- sk_win_read_4(sc_if->sk_softc, reg + \
- ((sc_if->sk_port * (skip + 1)) * SK_WIN_LEN))
-#define SK_IF_READ_2(sc_if, skip, reg) \
- sk_win_read_2(sc_if->sk_softc, reg + \
- ((sc_if->sk_port * (skip + 1)) * SK_WIN_LEN))
-#define SK_IF_READ_1(sc_if, skip, reg) \
- sk_win_read_1(sc_if->sk_softc, reg + \
- ((sc_if->sk_port * (skip + 1)) * SK_WIN_LEN))
-
-#define SK_IF_WRITE_4(sc_if, skip, reg, val) \
- sk_win_write_4(sc_if->sk_softc, \
- reg + ((sc_if->sk_port * (skip + 1)) * SK_WIN_LEN), val)
-#define SK_IF_WRITE_2(sc_if, skip, reg, val) \
- sk_win_write_2(sc_if->sk_softc, \
- reg + ((sc_if->sk_port * (skip + 1)) * SK_WIN_LEN), val)
-#define SK_IF_WRITE_1(sc_if, skip, reg, val) \
- sk_win_write_1(sc_if->sk_softc, \
- reg + ((sc_if->sk_port * (skip + 1)) * SK_WIN_LEN), val)
-
-/* Block 0 registers, permanently mapped at iobase. */
-#define SK_RAP 0x0000
-#define SK_CSR 0x0004
-#define SK_LED 0x0006
-#define SK_ISR 0x0008 /* interrupt source */
-#define SK_IMR 0x000C /* interrupt mask */
-#define SK_IESR 0x0010 /* interrupt hardware error source */
-#define SK_IEMR 0x0014 /* interrupt hardware error mask */
-#define SK_ISSR 0x0018 /* special interrupt source */
-#define SK_XM_IMR0 0x0020
-#define SK_XM_ISR0 0x0028
-#define SK_XM_PHYADDR0 0x0030
-#define SK_XM_PHYDATA0 0x0034
-#define SK_XM_IMR1 0x0040
-#define SK_XM_ISR1 0x0048
-#define SK_XM_PHYADDR1 0x0050
-#define SK_XM_PHYDATA1 0x0054
-#define SK_BMU_RX_CSR0 0x0060
-#define SK_BMU_RX_CSR1 0x0064
-#define SK_BMU_TXS_CSR0 0x0068
-#define SK_BMU_TXA_CSR0 0x006C
-#define SK_BMU_TXS_CSR1 0x0070
-#define SK_BMU_TXA_CSR1 0x0074
-
-/* SK_CSR register */
-#define SK_CSR_SW_RESET 0x0001
-#define SK_CSR_SW_UNRESET 0x0002
-#define SK_CSR_MASTER_RESET 0x0004
-#define SK_CSR_MASTER_UNRESET 0x0008
-#define SK_CSR_MASTER_STOP 0x0010
-#define SK_CSR_MASTER_DONE 0x0020
-#define SK_CSR_SW_IRQ_CLEAR 0x0040
-#define SK_CSR_SW_IRQ_SET 0x0080
-#define SK_CSR_SLOTSIZE 0x0100 /* 1 == 64 bits, 0 == 32 */
-#define SK_CSR_BUSCLOCK 0x0200 /* 1 == 33/66 Mhz, = 33 */
-
-/* SK_LED register */
-#define SK_LED_GREEN_OFF 0x01
-#define SK_LED_GREEN_ON 0x02
-
-/* SK_ISR register */
-#define SK_ISR_TX2_AS_CHECK 0x00000001
-#define SK_ISR_TX2_AS_EOF 0x00000002
-#define SK_ISR_TX2_AS_EOB 0x00000004
-#define SK_ISR_TX2_S_CHECK 0x00000008
-#define SK_ISR_TX2_S_EOF 0x00000010
-#define SK_ISR_TX2_S_EOB 0x00000020
-#define SK_ISR_TX1_AS_CHECK 0x00000040
-#define SK_ISR_TX1_AS_EOF 0x00000080
-#define SK_ISR_TX1_AS_EOB 0x00000100
-#define SK_ISR_TX1_S_CHECK 0x00000200
-#define SK_ISR_TX1_S_EOF 0x00000400
-#define SK_ISR_TX1_S_EOB 0x00000800
-#define SK_ISR_RX2_CHECK 0x00001000
-#define SK_ISR_RX2_EOF 0x00002000
-#define SK_ISR_RX2_EOB 0x00004000
-#define SK_ISR_RX1_CHECK 0x00008000
-#define SK_ISR_RX1_EOF 0x00010000
-#define SK_ISR_RX1_EOB 0x00020000
-#define SK_ISR_LINK2_OFLOW 0x00040000
-#define SK_ISR_MAC2 0x00080000
-#define SK_ISR_LINK1_OFLOW 0x00100000
-#define SK_ISR_MAC1 0x00200000
-#define SK_ISR_TIMER 0x00400000
-#define SK_ISR_EXTERNAL_REG 0x00800000
-#define SK_ISR_SW 0x01000000
-#define SK_ISR_I2C_RDY 0x02000000
-#define SK_ISR_TX2_TIMEO 0x04000000
-#define SK_ISR_TX1_TIMEO 0x08000000
-#define SK_ISR_RX2_TIMEO 0x10000000
-#define SK_ISR_RX1_TIMEO 0x20000000
-#define SK_ISR_RSVD 0x40000000
-#define SK_ISR_HWERR 0x80000000
-
-/* SK_IMR register */
-#define SK_IMR_TX2_AS_CHECK 0x00000001
-#define SK_IMR_TX2_AS_EOF 0x00000002
-#define SK_IMR_TX2_AS_EOB 0x00000004
-#define SK_IMR_TX2_S_CHECK 0x00000008
-#define SK_IMR_TX2_S_EOF 0x00000010
-#define SK_IMR_TX2_S_EOB 0x00000020
-#define SK_IMR_TX1_AS_CHECK 0x00000040
-#define SK_IMR_TX1_AS_EOF 0x00000080
-#define SK_IMR_TX1_AS_EOB 0x00000100
-#define SK_IMR_TX1_S_CHECK 0x00000200
-#define SK_IMR_TX1_S_EOF 0x00000400
-#define SK_IMR_TX1_S_EOB 0x00000800
-#define SK_IMR_RX2_CHECK 0x00001000
-#define SK_IMR_RX2_EOF 0x00002000
-#define SK_IMR_RX2_EOB 0x00004000
-#define SK_IMR_RX1_CHECK 0x00008000
-#define SK_IMR_RX1_EOF 0x00010000
-#define SK_IMR_RX1_EOB 0x00020000
-#define SK_IMR_LINK2_OFLOW 0x00040000
-#define SK_IMR_MAC2 0x00080000
-#define SK_IMR_LINK1_OFLOW 0x00100000
-#define SK_IMR_MAC1 0x00200000
-#define SK_IMR_TIMER 0x00400000
-#define SK_IMR_EXTERNAL_REG 0x00800000
-#define SK_IMR_SW 0x01000000
-#define SK_IMR_I2C_RDY 0x02000000
-#define SK_IMR_TX2_TIMEO 0x04000000
-#define SK_IMR_TX1_TIMEO 0x08000000
-#define SK_IMR_RX2_TIMEO 0x10000000
-#define SK_IMR_RX1_TIMEO 0x20000000
-#define SK_IMR_RSVD 0x40000000
-#define SK_IMR_HWERR 0x80000000
-
-#define SK_INTRS1 \
- (SK_IMR_RX1_EOF|SK_IMR_TX1_S_EOF|SK_IMR_MAC1)
-
-#define SK_INTRS2 \
- (SK_IMR_RX2_EOF|SK_IMR_TX2_S_EOF|SK_IMR_MAC2)
-
-/* SK_IESR register */
-#define SK_IESR_PAR_RX2 0x00000001
-#define SK_IESR_PAR_RX1 0x00000002
-#define SK_IESR_PAR_MAC2 0x00000004
-#define SK_IESR_PAR_MAC1 0x00000008
-#define SK_IESR_PAR_WR_RAM 0x00000010
-#define SK_IESR_PAR_RD_RAM 0x00000020
-#define SK_IESR_NO_TSTAMP_MAC2 0x00000040
-#define SK_IESR_NO_TSTAMO_MAC1 0x00000080
-#define SK_IESR_NO_STS_MAC2 0x00000100
-#define SK_IESR_NO_STS_MAC1 0x00000200
-#define SK_IESR_IRQ_STS 0x00000400
-#define SK_IESR_MASTERERR 0x00000800
-
-/* SK_IEMR register */
-#define SK_IEMR_PAR_RX2 0x00000001
-#define SK_IEMR_PAR_RX1 0x00000002
-#define SK_IEMR_PAR_MAC2 0x00000004
-#define SK_IEMR_PAR_MAC1 0x00000008
-#define SK_IEMR_PAR_WR_RAM 0x00000010
-#define SK_IEMR_PAR_RD_RAM 0x00000020
-#define SK_IEMR_NO_TSTAMP_MAC2 0x00000040
-#define SK_IEMR_NO_TSTAMO_MAC1 0x00000080
-#define SK_IEMR_NO_STS_MAC2 0x00000100
-#define SK_IEMR_NO_STS_MAC1 0x00000200
-#define SK_IEMR_IRQ_STS 0x00000400
-#define SK_IEMR_MASTERERR 0x00000800
-
-/* Block 2 */
-#define SK_MAC0_0 0x0100
-#define SK_MAC0_1 0x0104
-#define SK_MAC1_0 0x0108
-#define SK_MAC1_1 0x010C
-#define SK_MAC2_0 0x0110
-#define SK_MAC2_1 0x0114
-#define SK_CONNTYPE 0x0118
-#define SK_PMDTYPE 0x0119
-#define SK_CONFIG 0x011A
-#define SK_CHIPVER 0x011B
-#define SK_EPROM0 0x011C
-#define SK_EPROM1 0x011D
-#define SK_EPROM2 0x011E
-#define SK_EPROM3 0x011F
-#define SK_EP_ADDR 0x0120
-#define SK_EP_DATA 0x0124
-#define SK_EP_LOADCTL 0x0128
-#define SK_EP_LOADTST 0x0129
-#define SK_TIMERINIT 0x0130
-#define SK_TIMER 0x0134
-#define SK_TIMERCTL 0x0138
-#define SK_TIMERTST 0x0139
-#define SK_IMTIMERINIT 0x0140
-#define SK_IMTIMER 0x0144
-#define SK_IMTIMERCTL 0x0148
-#define SK_IMTIMERTST 0x0149
-#define SK_IMMR 0x014C
-#define SK_IHWEMR 0x0150
-#define SK_TESTCTL1 0x0158
-#define SK_TESTCTL2 0x0159
-#define SK_GPIO 0x015C
-#define SK_I2CHWCTL 0x0160
-#define SK_I2CHWDATA 0x0164
-#define SK_I2CHWIRQ 0x0168
-#define SK_I2CSW 0x016C
-#define SK_BLNKINIT 0x0170
-#define SK_BLNKCOUNT 0x0174
-#define SK_BLNKCTL 0x0178
-#define SK_BLNKSTS 0x0179
-#define SK_BLNKTST 0x017A
-
-#define SK_IMCTL_STOP 0x02
-#define SK_IMCTL_START 0x04
-
-#define SK_IMTIMER_TICKS 54
-#define SK_IM_USECS(x) ((x) * SK_IMTIMER_TICKS)
-
-/*
- * The SK_EPROM0 register contains a byte that describes the
- * amount of SRAM mounted on the NIC. The value also tells if
- * the chips are 64K or 128K. This affects the RAMbuffer address
- * offset that we need to use.
- */
-#define SK_RAMSIZE_512K_64 0x1
-#define SK_RAMSIZE_1024K_128 0x2
-#define SK_RAMSIZE_1024K_64 0x3
-#define SK_RAMSIZE_2048K_128 0x4
-
-#define SK_RBOFF_0 0x0
-#define SK_RBOFF_80000 0x80000
-
-#define SK_CONFIG_SINGLEMAC 0x01
-#define SK_CONFIG_DIS_DSL_CLK 0x02
-
-#define SK_PMD_1000BASELX 0x4C
-#define SK_PMD_1000BASESX 0x53
-#define SK_PMD_1000BASECX 0x43
-#define SK_PMD_1000BASETX 0x54
-
-/* Block 3 Ram interface and MAC arbiter registers */
-#define SK_RAMADDR 0x0180
-#define SK_RAMDATA0 0x0184
-#define SK_RAMDATA1 0x0188
-#define SK_TO0 0x0190
-#define SK_TO1 0x0191
-#define SK_TO2 0x0192
-#define SK_TO3 0x0193
-#define SK_TO4 0x0194
-#define SK_TO5 0x0195
-#define SK_TO6 0x0196
-#define SK_TO7 0x0197
-#define SK_TO8 0x0198
-#define SK_TO9 0x0199
-#define SK_TO10 0x019A
-#define SK_TO11 0x019B
-#define SK_RITIMEO_TMR 0x019C
-#define SK_RAMCTL 0x01A0
-#define SK_RITIMER_TST 0x01A2
-
-#define SK_RAMCTL_RESET 0x0001
-#define SK_RAMCTL_UNRESET 0x0002
-#define SK_RAMCTL_CLR_IRQ_WPAR 0x0100
-#define SK_RAMCTL_CLR_IRQ_RPAR 0x0200
-
-/* Mac arbiter registers */
-#define SK_MINIT_RX1 0x01B0
-#define SK_MINIT_RX2 0x01B1
-#define SK_MINIT_TX1 0x01B2
-#define SK_MINIT_TX2 0x01B3
-#define SK_MTIMEO_RX1 0x01B4
-#define SK_MTIMEO_RX2 0x01B5
-#define SK_MTIMEO_TX1 0x01B6
-#define SK_MTIEMO_TX2 0x01B7
-#define SK_MACARB_CTL 0x01B8
-#define SK_MTIMER_TST 0x01BA
-#define SK_RCINIT_RX1 0x01C0
-#define SK_RCINIT_RX2 0x01C1
-#define SK_RCINIT_TX1 0x01C2
-#define SK_RCINIT_TX2 0x01C3
-#define SK_RCTIMEO_RX1 0x01C4
-#define SK_RCTIMEO_RX2 0x01C5
-#define SK_RCTIMEO_TX1 0x01C6
-#define SK_RCTIMEO_TX2 0x01C7
-#define SK_RECOVERY_CTL 0x01C8
-#define SK_RCTIMER_TST 0x01CA
-
-/* Packet arbiter registers */
-#define SK_RXPA1_TINIT 0x01D0
-#define SK_RXPA2_TINIT 0x01D4
-#define SK_TXPA1_TINIT 0x01D8
-#define SK_TXPA2_TINIT 0x01DC
-#define SK_RXPA1_TIMEO 0x01E0
-#define SK_RXPA2_TIMEO 0x01E4
-#define SK_TXPA1_TIMEO 0x01E8
-#define SK_TXPA2_TIMEO 0x01EC
-#define SK_PKTARB_CTL 0x01F0
-#define SK_PKTATB_TST 0x01F2
-
-#define SK_PKTARB_TIMEOUT 0x2000
-
-#define SK_PKTARBCTL_RESET 0x0001
-#define SK_PKTARBCTL_UNRESET 0x0002
-#define SK_PKTARBCTL_RXTO1_OFF 0x0004
-#define SK_PKTARBCTL_RXTO1_ON 0x0008
-#define SK_PKTARBCTL_RXTO2_OFF 0x0010
-#define SK_PKTARBCTL_RXTO2_ON 0x0020
-#define SK_PKTARBCTL_TXTO1_OFF 0x0040
-#define SK_PKTARBCTL_TXTO1_ON 0x0080
-#define SK_PKTARBCTL_TXTO2_OFF 0x0100
-#define SK_PKTARBCTL_TXTO2_ON 0x0200
-#define SK_PKTARBCTL_CLR_IRQ_RXTO1 0x0400
-#define SK_PKTARBCTL_CLR_IRQ_RXTO2 0x0800
-#define SK_PKTARBCTL_CLR_IRQ_TXTO1 0x1000
-#define SK_PKTARBCTL_CLR_IRQ_TXTO2 0x2000
-
-#define SK_MINIT_XMAC_B2 54
-#define SK_MINIT_XMAC_C1 63
-
-#define SK_MACARBCTL_RESET 0x0001
-#define SK_MACARBCTL_UNRESET 0x0002
-#define SK_MACARBCTL_FASTOE_OFF 0x0004
-#define SK_MACARBCRL_FASTOE_ON 0x0008
-
-#define SK_RCINIT_XMAC_B2 54
-#define SK_RCINIT_XMAC_C1 0
-
-#define SK_RECOVERYCTL_RX1_OFF 0x0001
-#define SK_RECOVERYCTL_RX1_ON 0x0002
-#define SK_RECOVERYCTL_RX2_OFF 0x0004
-#define SK_RECOVERYCTL_RX2_ON 0x0008
-#define SK_RECOVERYCTL_TX1_OFF 0x0010
-#define SK_RECOVERYCTL_TX1_ON 0x0020
-#define SK_RECOVERYCTL_TX2_OFF 0x0040
-#define SK_RECOVERYCTL_TX2_ON 0x0080
-
-#define SK_RECOVERY_XMAC_B2 \
- (SK_RECOVERYCTL_RX1_ON|SK_RECOVERYCTL_RX2_ON| \
- SK_RECOVERYCTL_TX1_ON|SK_RECOVERYCTL_TX2_ON)
-
-#define SK_RECOVERY_XMAC_C1 \
- (SK_RECOVERYCTL_RX1_OFF|SK_RECOVERYCTL_RX2_OFF| \
- SK_RECOVERYCTL_TX1_OFF|SK_RECOVERYCTL_TX2_OFF)
-
-/* Block 4 -- TX Arbiter MAC 1 */
-#define SK_TXAR1_TIMERINIT 0x0200
-#define SK_TXAR1_TIMERVAL 0x0204
-#define SK_TXAR1_LIMITINIT 0x0208
-#define SK_TXAR1_LIMITCNT 0x020C
-#define SK_TXAR1_COUNTERCTL 0x0210
-#define SK_TXAR1_COUNTERTST 0x0212
-#define SK_TXAR1_COUNTERSTS 0x0212
-
-/* Block 5 -- TX Arbiter MAC 2 */
-#define SK_TXAR2_TIMERINIT 0x0280
-#define SK_TXAR2_TIMERVAL 0x0284
-#define SK_TXAR2_LIMITINIT 0x0288
-#define SK_TXAR2_LIMITCNT 0x028C
-#define SK_TXAR2_COUNTERCTL 0x0290
-#define SK_TXAR2_COUNTERTST 0x0291
-#define SK_TXAR2_COUNTERSTS 0x0292
-
-#define SK_TXARCTL_OFF 0x01
-#define SK_TXARCTL_ON 0x02
-#define SK_TXARCTL_RATECTL_OFF 0x04
-#define SK_TXARCTL_RATECTL_ON 0x08
-#define SK_TXARCTL_ALLOC_OFF 0x10
-#define SK_TXARCTL_ALLOC_ON 0x20
-#define SK_TXARCTL_FSYNC_OFF 0x40
-#define SK_TXARCTL_FSYNC_ON 0x80
-
-/* Block 6 -- External registers */
-#define SK_EXTREG_BASE 0x300
-#define SK_EXTREG_END 0x37C
-
-/* Block 7 -- PCI config registers */
-#define SK_PCI_BASE 0x0380
-#define SK_PCI_END 0x03FC
-
-/* Compute offset of mirrored PCI register */
-#define SK_PCI_REG(reg) ((reg) + SK_PCI_BASE)
-
-/* Block 8 -- RX queue 1 */
-#define SK_RXQ1_BUFCNT 0x0400
-#define SK_RXQ1_BUFCTL 0x0402
-#define SK_RXQ1_NEXTDESC 0x0404
-#define SK_RXQ1_RXBUF_LO 0x0408
-#define SK_RXQ1_RXBUF_HI 0x040C
-#define SK_RXQ1_RXSTAT 0x0410
-#define SK_RXQ1_TIMESTAMP 0x0414
-#define SK_RXQ1_CSUM1 0x0418
-#define SK_RXQ1_CSUM2 0x041A
-#define SK_RXQ1_CSUM1_START 0x041C
-#define SK_RXQ1_CSUM2_START 0x041E
-#define SK_RXQ1_CURADDR_LO 0x0420
-#define SK_RXQ1_CURADDR_HI 0x0424
-#define SK_RXQ1_CURCNT_LO 0x0428
-#define SK_RXQ1_CURCNT_HI 0x042C
-#define SK_RXQ1_CURBYTES 0x0430
-#define SK_RXQ1_BMU_CSR 0x0434
-#define SK_RXQ1_WATERMARK 0x0438
-#define SK_RXQ1_FLAG 0x043A
-#define SK_RXQ1_TEST1 0x043C
-#define SK_RXQ1_TEST2 0x0440
-#define SK_RXQ1_TEST3 0x0444
-
-/* Block 9 -- RX queue 2 */
-#define SK_RXQ2_BUFCNT 0x0480
-#define SK_RXQ2_BUFCTL 0x0482
-#define SK_RXQ2_NEXTDESC 0x0484
-#define SK_RXQ2_RXBUF_LO 0x0488
-#define SK_RXQ2_RXBUF_HI 0x048C
-#define SK_RXQ2_RXSTAT 0x0490
-#define SK_RXQ2_TIMESTAMP 0x0494
-#define SK_RXQ2_CSUM1 0x0498
-#define SK_RXQ2_CSUM2 0x049A
-#define SK_RXQ2_CSUM1_START 0x049C
-#define SK_RXQ2_CSUM2_START 0x049E
-#define SK_RXQ2_CURADDR_LO 0x04A0
-#define SK_RXQ2_CURADDR_HI 0x04A4
-#define SK_RXQ2_CURCNT_LO 0x04A8
-#define SK_RXQ2_CURCNT_HI 0x04AC
-#define SK_RXQ2_CURBYTES 0x04B0
-#define SK_RXQ2_BMU_CSR 0x04B4
-#define SK_RXQ2_WATERMARK 0x04B8
-#define SK_RXQ2_FLAG 0x04BA
-#define SK_RXQ2_TEST1 0x04BC
-#define SK_RXQ2_TEST2 0x04C0
-#define SK_RXQ2_TEST3 0x04C4
-
-#define SK_RXBMU_CLR_IRQ_ERR 0x00000001
-#define SK_RXBMU_CLR_IRQ_EOF 0x00000002
-#define SK_RXBMU_CLR_IRQ_EOB 0x00000004
-#define SK_RXBMU_CLR_IRQ_PAR 0x00000008
-#define SK_RXBMU_RX_START 0x00000010
-#define SK_RXBMU_RX_STOP 0x00000020
-#define SK_RXBMU_POLL_OFF 0x00000040
-#define SK_RXBMU_POLL_ON 0x00000080
-#define SK_RXBMU_TRANSFER_SM_RESET 0x00000100
-#define SK_RXBMU_TRANSFER_SM_UNRESET 0x00000200
-#define SK_RXBMU_DESCWR_SM_RESET 0x00000400
-#define SK_RXBMU_DESCWR_SM_UNRESET 0x00000800
-#define SK_RXBMU_DESCRD_SM_RESET 0x00001000
-#define SK_RXBMU_DESCRD_SM_UNRESET 0x00002000
-#define SK_RXBMU_SUPERVISOR_SM_RESET 0x00004000
-#define SK_RXBMU_SUPERVISOR_SM_UNRESET 0x00008000
-#define SK_RXBMU_PFI_SM_RESET 0x00010000
-#define SK_RXBMU_PFI_SM_UNRESET 0x00020000
-#define SK_RXBMU_FIFO_RESET 0x00040000
-#define SK_RXBMU_FIFO_UNRESET 0x00080000
-#define SK_RXBMU_DESC_RESET 0x00100000
-#define SK_RXBMU_DESC_UNRESET 0x00200000
-#define SK_RXBMU_SUPERVISOR_IDLE 0x01000000
-
-#define SK_RXBMU_ONLINE \
- (SK_RXBMU_TRANSFER_SM_UNRESET|SK_RXBMU_DESCWR_SM_UNRESET| \
- SK_RXBMU_DESCRD_SM_UNRESET|SK_RXBMU_SUPERVISOR_SM_UNRESET| \
- SK_RXBMU_PFI_SM_UNRESET|SK_RXBMU_FIFO_UNRESET| \
- SK_RXBMU_DESC_UNRESET)
-
-#define SK_RXBMU_OFFLINE \
- (SK_RXBMU_TRANSFER_SM_RESET|SK_RXBMU_DESCWR_SM_RESET| \
- SK_RXBMU_DESCRD_SM_RESET|SK_RXBMU_SUPERVISOR_SM_RESET| \
- SK_RXBMU_PFI_SM_RESET|SK_RXBMU_FIFO_RESET| \
- SK_RXBMU_DESC_RESET)
-
-/* Block 12 -- TX sync queue 1 */
-#define SK_TXQS1_BUFCNT 0x0600
-#define SK_TXQS1_BUFCTL 0x0602
-#define SK_TXQS1_NEXTDESC 0x0604
-#define SK_TXQS1_RXBUF_LO 0x0608
-#define SK_TXQS1_RXBUF_HI 0x060C
-#define SK_TXQS1_RXSTAT 0x0610
-#define SK_TXQS1_CSUM_STARTVAL 0x0614
-#define SK_TXQS1_CSUM_STARTPOS 0x0618
-#define SK_TXQS1_CSUM_WRITEPOS 0x061A
-#define SK_TXQS1_CURADDR_LO 0x0620
-#define SK_TXQS1_CURADDR_HI 0x0624
-#define SK_TXQS1_CURCNT_LO 0x0628
-#define SK_TXQS1_CURCNT_HI 0x062C
-#define SK_TXQS1_CURBYTES 0x0630
-#define SK_TXQS1_BMU_CSR 0x0634
-#define SK_TXQS1_WATERMARK 0x0638
-#define SK_TXQS1_FLAG 0x063A
-#define SK_TXQS1_TEST1 0x063C
-#define SK_TXQS1_TEST2 0x0640
-#define SK_TXQS1_TEST3 0x0644
-
-/* Block 13 -- TX async queue 1 */
-#define SK_TXQA1_BUFCNT 0x0680
-#define SK_TXQA1_BUFCTL 0x0682
-#define SK_TXQA1_NEXTDESC 0x0684
-#define SK_TXQA1_RXBUF_LO 0x0688
-#define SK_TXQA1_RXBUF_HI 0x068C
-#define SK_TXQA1_RXSTAT 0x0690
-#define SK_TXQA1_CSUM_STARTVAL 0x0694
-#define SK_TXQA1_CSUM_STARTPOS 0x0698
-#define SK_TXQA1_CSUM_WRITEPOS 0x069A
-#define SK_TXQA1_CURADDR_LO 0x06A0
-#define SK_TXQA1_CURADDR_HI 0x06A4
-#define SK_TXQA1_CURCNT_LO 0x06A8
-#define SK_TXQA1_CURCNT_HI 0x06AC
-#define SK_TXQA1_CURBYTES 0x06B0
-#define SK_TXQA1_BMU_CSR 0x06B4
-#define SK_TXQA1_WATERMARK 0x06B8
-#define SK_TXQA1_FLAG 0x06BA
-#define SK_TXQA1_TEST1 0x06BC
-#define SK_TXQA1_TEST2 0x06C0
-#define SK_TXQA1_TEST3 0x06C4
-
-/* Block 14 -- TX sync queue 2 */
-#define SK_TXQS2_BUFCNT 0x0700
-#define SK_TXQS2_BUFCTL 0x0702
-#define SK_TXQS2_NEXTDESC 0x0704
-#define SK_TXQS2_RXBUF_LO 0x0708
-#define SK_TXQS2_RXBUF_HI 0x070C
-#define SK_TXQS2_RXSTAT 0x0710
-#define SK_TXQS2_CSUM_STARTVAL 0x0714
-#define SK_TXQS2_CSUM_STARTPOS 0x0718
-#define SK_TXQS2_CSUM_WRITEPOS 0x071A
-#define SK_TXQS2_CURADDR_LO 0x0720
-#define SK_TXQS2_CURADDR_HI 0x0724
-#define SK_TXQS2_CURCNT_LO 0x0728
-#define SK_TXQS2_CURCNT_HI 0x072C
-#define SK_TXQS2_CURBYTES 0x0730
-#define SK_TXQS2_BMU_CSR 0x0734
-#define SK_TXQS2_WATERMARK 0x0738
-#define SK_TXQS2_FLAG 0x073A
-#define SK_TXQS2_TEST1 0x073C
-#define SK_TXQS2_TEST2 0x0740
-#define SK_TXQS2_TEST3 0x0744
-
-/* Block 15 -- TX async queue 2 */
-#define SK_TXQA2_BUFCNT 0x0780
-#define SK_TXQA2_BUFCTL 0x0782
-#define SK_TXQA2_NEXTDESC 0x0784
-#define SK_TXQA2_RXBUF_LO 0x0788
-#define SK_TXQA2_RXBUF_HI 0x078C
-#define SK_TXQA2_RXSTAT 0x0790
-#define SK_TXQA2_CSUM_STARTVAL 0x0794
-#define SK_TXQA2_CSUM_STARTPOS 0x0798
-#define SK_TXQA2_CSUM_WRITEPOS 0x079A
-#define SK_TXQA2_CURADDR_LO 0x07A0
-#define SK_TXQA2_CURADDR_HI 0x07A4
-#define SK_TXQA2_CURCNT_LO 0x07A8
-#define SK_TXQA2_CURCNT_HI 0x07AC
-#define SK_TXQA2_CURBYTES 0x07B0
-#define SK_TXQA2_BMU_CSR 0x07B4
-#define SK_TXQA2_WATERMARK 0x07B8
-#define SK_TXQA2_FLAG 0x07BA
-#define SK_TXQA2_TEST1 0x07BC
-#define SK_TXQA2_TEST2 0x07C0
-#define SK_TXQA2_TEST3 0x07C4
-
-#define SK_TXBMU_CLR_IRQ_ERR 0x00000001
-#define SK_TXBMU_CLR_IRQ_EOF 0x00000002
-#define SK_TXBMU_CLR_IRQ_EOB 0x00000004
-#define SK_TXBMU_TX_START 0x00000010
-#define SK_TXBMU_TX_STOP 0x00000020
-#define SK_TXBMU_POLL_OFF 0x00000040
-#define SK_TXBMU_POLL_ON 0x00000080
-#define SK_TXBMU_TRANSFER_SM_RESET 0x00000100
-#define SK_TXBMU_TRANSFER_SM_UNRESET 0x00000200
-#define SK_TXBMU_DESCWR_SM_RESET 0x00000400
-#define SK_TXBMU_DESCWR_SM_UNRESET 0x00000800
-#define SK_TXBMU_DESCRD_SM_RESET 0x00001000
-#define SK_TXBMU_DESCRD_SM_UNRESET 0x00002000
-#define SK_TXBMU_SUPERVISOR_SM_RESET 0x00004000
-#define SK_TXBMU_SUPERVISOR_SM_UNRESET 0x00008000
-#define SK_TXBMU_PFI_SM_RESET 0x00010000
-#define SK_TXBMU_PFI_SM_UNRESET 0x00020000
-#define SK_TXBMU_FIFO_RESET 0x00040000
-#define SK_TXBMU_FIFO_UNRESET 0x00080000
-#define SK_TXBMU_DESC_RESET 0x00100000
-#define SK_TXBMU_DESC_UNRESET 0x00200000
-#define SK_TXBMU_SUPERVISOR_IDLE 0x01000000
-
-#define SK_TXBMU_ONLINE \
- (SK_TXBMU_TRANSFER_SM_UNRESET|SK_TXBMU_DESCWR_SM_UNRESET| \
- SK_TXBMU_DESCRD_SM_UNRESET|SK_TXBMU_SUPERVISOR_SM_UNRESET| \
- SK_TXBMU_PFI_SM_UNRESET|SK_TXBMU_FIFO_UNRESET| \
- SK_TXBMU_DESC_UNRESET)
-
-#define SK_TXBMU_OFFLINE \
- (SK_TXBMU_TRANSFER_SM_RESET|SK_TXBMU_DESCWR_SM_RESET| \
- SK_TXBMU_DESCRD_SM_RESET|SK_TXBMU_SUPERVISOR_SM_RESET| \
- SK_TXBMU_PFI_SM_RESET|SK_TXBMU_FIFO_RESET| \
- SK_TXBMU_DESC_RESET)
-
-/* Block 16 -- Receive RAMbuffer 1 */
-#define SK_RXRB1_START 0x0800
-#define SK_RXRB1_END 0x0804
-#define SK_RXRB1_WR_PTR 0x0808
-#define SK_RXRB1_RD_PTR 0x080C
-#define SK_RXRB1_UTHR_PAUSE 0x0810
-#define SK_RXRB1_LTHR_PAUSE 0x0814
-#define SK_RXRB1_UTHR_HIPRIO 0x0818
-#define SK_RXRB1_UTHR_LOPRIO 0x081C
-#define SK_RXRB1_PKTCNT 0x0820
-#define SK_RXRB1_LVL 0x0824
-#define SK_RXRB1_CTLTST 0x0828
-
-/* Block 17 -- Receive RAMbuffer 2 */
-#define SK_RXRB2_START 0x0880
-#define SK_RXRB2_END 0x0884
-#define SK_RXRB2_WR_PTR 0x0888
-#define SK_RXRB2_RD_PTR 0x088C
-#define SK_RXRB2_UTHR_PAUSE 0x0890
-#define SK_RXRB2_LTHR_PAUSE 0x0894
-#define SK_RXRB2_UTHR_HIPRIO 0x0898
-#define SK_RXRB2_UTHR_LOPRIO 0x089C
-#define SK_RXRB2_PKTCNT 0x08A0
-#define SK_RXRB2_LVL 0x08A4
-#define SK_RXRB2_CTLTST 0x08A8
-
-/* Block 20 -- Sync. Transmit RAMbuffer 1 */
-#define SK_TXRBS1_START 0x0A00
-#define SK_TXRBS1_END 0x0A04
-#define SK_TXRBS1_WR_PTR 0x0A08
-#define SK_TXRBS1_RD_PTR 0x0A0C
-#define SK_TXRBS1_PKTCNT 0x0A20
-#define SK_TXRBS1_LVL 0x0A24
-#define SK_TXRBS1_CTLTST 0x0A28
-
-/* Block 21 -- Async. Transmit RAMbuffer 1 */
-#define SK_TXRBA1_START 0x0A80
-#define SK_TXRBA1_END 0x0A84
-#define SK_TXRBA1_WR_PTR 0x0A88
-#define SK_TXRBA1_RD_PTR 0x0A8C
-#define SK_TXRBA1_PKTCNT 0x0AA0
-#define SK_TXRBA1_LVL 0x0AA4
-#define SK_TXRBA1_CTLTST 0x0AA8
-
-/* Block 22 -- Sync. Transmit RAMbuffer 2 */
-#define SK_TXRBS2_START 0x0B00
-#define SK_TXRBS2_END 0x0B04
-#define SK_TXRBS2_WR_PTR 0x0B08
-#define SK_TXRBS2_RD_PTR 0x0B0C
-#define SK_TXRBS2_PKTCNT 0x0B20
-#define SK_TXRBS2_LVL 0x0B24
-#define SK_TXRBS2_CTLTST 0x0B28
-
-/* Block 23 -- Async. Transmit RAMbuffer 2 */
-#define SK_TXRBA2_START 0x0B80
-#define SK_TXRBA2_END 0x0B84
-#define SK_TXRBA2_WR_PTR 0x0B88
-#define SK_TXRBA2_RD_PTR 0x0B8C
-#define SK_TXRBA2_PKTCNT 0x0BA0
-#define SK_TXRBA2_LVL 0x0BA4
-#define SK_TXRBA2_CTLTST 0x0BA8
-
-#define SK_RBCTL_RESET 0x00000001
-#define SK_RBCTL_UNRESET 0x00000002
-#define SK_RBCTL_OFF 0x00000004
-#define SK_RBCTL_ON 0x00000008
-#define SK_RBCTL_STORENFWD_OFF 0x00000010
-#define SK_RBCTL_STORENFWD_ON 0x00000020
-
-/* Block 24 -- RX MAC FIFO 1 regisrers and LINK_SYNC counter */
-#define SK_RXF1_END 0x0C00
-#define SK_RXF1_WPTR 0x0C04
-#define SK_RXF1_RPTR 0x0C0C
-#define SK_RXF1_PKTCNT 0x0C10
-#define SK_RXF1_LVL 0x0C14
-#define SK_RXF1_MACCTL 0x0C18
-#define SK_RXF1_CTL 0x0C1C
-#define SK_RXLED1_CNTINIT 0x0C20
-#define SK_RXLED1_COUNTER 0x0C24
-#define SK_RXLED1_CTL 0x0C28
-#define SK_RXLED1_TST 0x0C29
-#define SK_LINK_SYNC1_CINIT 0x0C30
-#define SK_LINK_SYNC1_COUNTER 0x0C34
-#define SK_LINK_SYNC1_CTL 0x0C38
-#define SK_LINK_SYNC1_TST 0x0C39
-#define SK_LINKLED1_CTL 0x0C3C
-
-#define SK_FIFO_END 0x3F
-
-/* Block 25 -- RX MAC FIFO 2 regisrers and LINK_SYNC counter */
-#define SK_RXF2_END 0x0C80
-#define SK_RXF2_WPTR 0x0C84
-#define SK_RXF2_RPTR 0x0C8C
-#define SK_RXF2_PKTCNT 0x0C90
-#define SK_RXF2_LVL 0x0C94
-#define SK_RXF2_MACCTL 0x0C98
-#define SK_RXF2_CTL 0x0C9C
-#define SK_RXLED2_CNTINIT 0x0CA0
-#define SK_RXLED2_COUNTER 0x0CA4
-#define SK_RXLED2_CTL 0x0CA8
-#define SK_RXLED2_TST 0x0CA9
-#define SK_LINK_SYNC2_CINIT 0x0CB0
-#define SK_LINK_SYNC2_COUNTER 0x0CB4
-#define SK_LINK_SYNC2_CTL 0x0CB8
-#define SK_LINK_SYNC2_TST 0x0CB9
-#define SK_LINKLED2_CTL 0x0CBC
-
-#define SK_RXMACCTL_CLR_IRQ_NOSTS 0x00000001
-#define SK_RXMACCTL_CLR_IRQ_NOTSTAMP 0x00000002
-#define SK_RXMACCTL_TSTAMP_OFF 0x00000004
-#define SK_RXMACCTL_RSTAMP_ON 0x00000008
-#define SK_RXMACCTL_FLUSH_OFF 0x00000010
-#define SK_RXMACCTL_FLUSH_ON 0x00000020
-#define SK_RXMACCTL_PAUSE_OFF 0x00000040
-#define SK_RXMACCTL_PAUSE_ON 0x00000080
-#define SK_RXMACCTL_AFULL_OFF 0x00000100
-#define SK_RXMACCTL_AFULL_ON 0x00000200
-#define SK_RXMACCTL_VALIDTIME_PATCH_OFF 0x00000400
-#define SK_RXMACCTL_VALIDTIME_PATCH_ON 0x00000800
-#define SK_RXMACCTL_RXRDY_PATCH_OFF 0x00001000
-#define SK_RXMACCTL_RXRDY_PATCH_ON 0x00002000
-#define SK_RXMACCTL_STS_TIMEO 0x00FF0000
-#define SK_RXMACCTL_TSTAMP_TIMEO 0xFF000000
-
-#define SK_RXLEDCTL_ENABLE 0x0001
-#define SK_RXLEDCTL_COUNTER_STOP 0x0002
-#define SK_RXLEDCTL_COUNTER_START 0x0004
-
-#define SK_LINKLED_OFF 0x0001
-#define SK_LINKLED_ON 0x0002
-#define SK_LINKLED_LINKSYNC_OFF 0x0004
-#define SK_LINKLED_LINKSYNC_ON 0x0008
-#define SK_LINKLED_BLINK_OFF 0x0010
-#define SK_LINKLED_BLINK_ON 0x0020
-
-/* Block 26 -- TX MAC FIFO 1 regisrers */
-#define SK_TXF1_END 0x0D00
-#define SK_TXF1_WPTR 0x0D04
-#define SK_TXF1_RPTR 0x0D0C
-#define SK_TXF1_PKTCNT 0x0D10
-#define SK_TXF1_LVL 0x0D14
-#define SK_TXF1_MACCTL 0x0D18
-#define SK_TXF1_CTL 0x0D1C
-#define SK_TXLED1_CNTINIT 0x0D20
-#define SK_TXLED1_COUNTER 0x0D24
-#define SK_TXLED1_CTL 0x0D28
-#define SK_TXLED1_TST 0x0D29
-
-/* Block 27 -- TX MAC FIFO 2 regisrers */
-#define SK_TXF2_END 0x0D80
-#define SK_TXF2_WPTR 0x0D84
-#define SK_TXF2_RPTR 0x0D8C
-#define SK_TXF2_PKTCNT 0x0D90
-#define SK_TXF2_LVL 0x0D94
-#define SK_TXF2_MACCTL 0x0D98
-#define SK_TXF2_CTL 0x0D9C
-#define SK_TXLED2_CNTINIT 0x0DA0
-#define SK_TXLED2_COUNTER 0x0DA4
-#define SK_TXLED2_CTL 0x0DA8
-#define SK_TXLED2_TST 0x0DA9
-
-#define SK_TXMACCTL_XMAC_RESET 0x00000001
-#define SK_TXMACCTL_XMAC_UNRESET 0x00000002
-#define SK_TXMACCTL_LOOP_OFF 0x00000004
-#define SK_TXMACCTL_LOOP_ON 0x00000008
-#define SK_TXMACCTL_FLUSH_OFF 0x00000010
-#define SK_TXMACCTL_FLUSH_ON 0x00000020
-#define SK_TXMACCTL_WAITEMPTY_OFF 0x00000040
-#define SK_TXMACCTL_WAITEMPTY_ON 0x00000080
-#define SK_TXMACCTL_AFULL_OFF 0x00000100
-#define SK_TXMACCTL_AFULL_ON 0x00000200
-#define SK_TXMACCTL_TXRDY_PATCH_OFF 0x00000400
-#define SK_TXMACCTL_RXRDY_PATCH_ON 0x00000800
-#define SK_TXMACCTL_PKT_RECOVERY_OFF 0x00001000
-#define SK_TXMACCTL_PKT_RECOVERY_ON 0x00002000
-#define SK_TXMACCTL_CLR_IRQ_PERR 0x00008000
-#define SK_TXMACCTL_WAITAFTERFLUSH 0x00010000
-
-#define SK_TXLEDCTL_ENABLE 0x0001
-#define SK_TXLEDCTL_COUNTER_STOP 0x0002
-#define SK_TXLEDCTL_COUNTER_START 0x0004
-
-#define SK_FIFO_RESET 0x00000001
-#define SK_FIFO_UNRESET 0x00000002
-#define SK_FIFO_OFF 0x00000004
-#define SK_FIFO_ON 0x00000008
-
-/* Block 0x40 to 0x4F -- XMAC 1 registers */
-#define SK_XMAC1_BASE 0x2000
-#define SK_XMAC1_END 0x23FF
-
-/* Block 0x60 to 0x6F -- XMAC 2 registers */
-#define SK_XMAC2_BASE 0x3000
-#define SK_XMAC2_END 0x33FF
-
-/* Compute relative offset of an XMAC register in the XMAC window(s). */
-#define SK_XMAC_REG(reg, mac) (((reg) * 2) + SK_XMAC1_BASE + \
- (mac * (SK_XMAC2_BASE - SK_XMAC1_BASE)))
-
-#define SK_XM_READ_4(sc, reg) \
- (sk_win_read_2(sc->sk_softc, \
- SK_XMAC_REG(reg, sc->sk_port)) & 0xFFFF) | \
- ((sk_win_read_2(sc->sk_softc, \
- SK_XMAC_REG(reg + 2, sc->sk_port)) << 16) & 0xFFFF0000)
-
-#define SK_XM_WRITE_4(sc, reg, val) \
- sk_win_write_2(sc->sk_softc, \
- SK_XMAC_REG(reg, sc->sk_port), ((val) & 0xFFFF)); \
- sk_win_write_2(sc->sk_softc, \
- SK_XMAC_REG(reg + 2, sc->sk_port), ((val) >> 16) & 0xFFFF);
-
-#define SK_XM_READ_2(sc, reg) \
- sk_win_read_2(sc->sk_softc, SK_XMAC_REG(reg, sc->sk_port))
-
-#define SK_XM_WRITE_2(sc, reg, val) \
- sk_win_write_2(sc->sk_softc, SK_XMAC_REG(reg, sc->sk_port), val)
-
-#define SK_XM_SETBIT_4(sc, reg, x) \
- SK_XM_WRITE_4(sc, reg, (SK_XM_READ_4(sc, reg)) | (x))
-
-#define SK_XM_CLRBIT_4(sc, reg, x) \
- SK_XM_WRITE_4(sc, reg, (SK_XM_READ_4(sc, reg)) & ~(x))
-
-#define SK_XM_SETBIT_2(sc, reg, x) \
- SK_XM_WRITE_2(sc, reg, (SK_XM_READ_2(sc, reg)) | (x))
-
-#define SK_XM_CLRBIT_2(sc, reg, x) \
- SK_XM_WRITE_2(sc, reg, (SK_XM_READ_2(sc, reg)) & ~(x))
-
-
-/*
- * The default FIFO threshold on the XMAC II is 4 bytes. On
- * dual port NICs, this often leads to transmit underruns, so we
- * bump the threshold a little.
- */
-#define SK_XM_TX_FIFOTHRESH 512
-
-#define SK_PCI_VENDOR_ID 0x0000
-#define SK_PCI_DEVICE_ID 0x0002
-#define SK_PCI_COMMAND 0x0004
-#define SK_PCI_STATUS 0x0006
-#define SK_PCI_REVID 0x0008
-#define SK_PCI_CLASSCODE 0x0009
-#define SK_PCI_CACHELEN 0x000C
-#define SK_PCI_LATENCY_TIMER 0x000D
-#define SK_PCI_HEADER_TYPE 0x000E
-#define SK_PCI_LOMEM 0x0010
-#define SK_PCI_LOIO 0x0014
-#define SK_PCI_SUBVEN_ID 0x002C
-#define SK_PCI_SYBSYS_ID 0x002E
-#define SK_PCI_BIOSROM 0x0030
-#define SK_PCI_INTLINE 0x003C
-#define SK_PCI_INTPIN 0x003D
-#define SK_PCI_MINGNT 0x003E
-#define SK_PCI_MINLAT 0x003F
-
-/* device specific PCI registers */
-#define SK_PCI_OURREG1 0x0040
-#define SK_PCI_OURREG2 0x0044
-#define SK_PCI_CAPID 0x0048 /* 8 bits */
-#define SK_PCI_NEXTPTR 0x0049 /* 8 bits */
-#define SK_PCI_PWRMGMTCAP 0x004A /* 16 bits */
-#define SK_PCI_PWRMGMTCTRL 0x004C /* 16 bits */
-#define SK_PCI_PME_EVENT 0x004F
-#define SK_PCI_VPD_CAPID 0x0050
-#define SK_PCI_VPD_NEXTPTR 0x0051
-#define SK_PCI_VPD_ADDR 0x0052
-#define SK_PCI_VPD_DATA 0x0054
-
-#define SK_PSTATE_MASK 0x0003
-#define SK_PSTATE_D0 0x0000
-#define SK_PSTATE_D1 0x0001
-#define SK_PSTATE_D2 0x0002
-#define SK_PSTATE_D3 0x0003
-#define SK_PME_EN 0x0010
-#define SK_PME_STATUS 0x8000
-
-/*
- * VPD flag bit. Set to 0 to initiate a read, will become 1 when
- * read is complete. Set to 1 to initiate a write, will become 0
- * when write is finished.
- */
-#define SK_VPD_FLAG 0x8000
-
-/* VPD structures */
-struct vpd_res {
- u_int8_t vr_id;
- u_int8_t vr_len;
- u_int8_t vr_pad;
-};
-
-struct vpd_key {
- char vk_key[2];
- u_int8_t vk_len;
-};
-
-#define VPD_RES_ID 0x82 /* ID string */
-#define VPD_RES_READ 0x90 /* start of read only area */
-#define VPD_RES_WRITE 0x81 /* start of read/write area */
-#define VPD_RES_END 0x78 /* end tag */
-
-#define CSR_WRITE_4(sc, reg, val) \
- bus_space_write_4(sc->sk_btag, sc->sk_bhandle, reg, val)
-#define CSR_WRITE_2(sc, reg, val) \
- bus_space_write_2(sc->sk_btag, sc->sk_bhandle, reg, val)
-#define CSR_WRITE_1(sc, reg, val) \
- bus_space_write_1(sc->sk_btag, sc->sk_bhandle, reg, val)
-
-#define CSR_READ_4(sc, reg) \
- bus_space_read_4(sc->sk_btag, sc->sk_bhandle, reg)
-#define CSR_READ_2(sc, reg) \
- bus_space_read_2(sc->sk_btag, sc->sk_bhandle, reg)
-#define CSR_READ_1(sc, reg) \
- bus_space_read_1(sc->sk_btag, sc->sk_bhandle, reg)
-
-struct sk_type {
- u_int16_t sk_vid;
- u_int16_t sk_did;
- char *sk_name;
-};
-
-/* RX queue descriptor data structure */
-struct sk_rx_desc {
- u_int32_t sk_ctl;
- u_int32_t sk_next;
- u_int32_t sk_data_lo;
- u_int32_t sk_data_hi;
- u_int32_t sk_xmac_rxstat;
- u_int32_t sk_timestamp;
- u_int16_t sk_csum2;
- u_int16_t sk_csum1;
- u_int16_t sk_csum2_start;
- u_int16_t sk_csum1_start;
-};
-
-#define SK_OPCODE_DEFAULT 0x00550000
-#define SK_OPCODE_CSUM 0x00560000
-
-#define SK_RXCTL_LEN 0x0000FFFF
-#define SK_RXCTL_OPCODE 0x00FF0000
-#define SK_RXCTL_TSTAMP_VALID 0x01000000
-#define SK_RXCTL_STATUS_VALID 0x02000000
-#define SK_RXCTL_DEV0 0x04000000
-#define SK_RXCTL_EOF_INTR 0x08000000
-#define SK_RXCTL_EOB_INTR 0x10000000
-#define SK_RXCTL_LASTFRAG 0x20000000
-#define SK_RXCTL_FIRSTFRAG 0x40000000
-#define SK_RXCTL_OWN 0x80000000
-
-#define SK_RXSTAT \
- (SK_OPCODE_DEFAULT|SK_RXCTL_EOF_INTR|SK_RXCTL_LASTFRAG| \
- SK_RXCTL_FIRSTFRAG|SK_RXCTL_OWN)
-
-struct sk_tx_desc {
- u_int32_t sk_ctl;
- u_int32_t sk_next;
- u_int32_t sk_data_lo;
- u_int32_t sk_data_hi;
- u_int32_t sk_xmac_txstat;
- u_int16_t sk_rsvd0;
- u_int16_t sk_csum_startval;
- u_int16_t sk_csum_startpos;
- u_int16_t sk_csum_writepos;
- u_int32_t sk_rsvd1;
-};
-
-#define SK_TXCTL_LEN 0x0000FFFF
-#define SK_TXCTL_OPCODE 0x00FF0000
-#define SK_TXCTL_SW 0x01000000
-#define SK_TXCTL_NOCRC 0x02000000
-#define SK_TXCTL_STORENFWD 0x04000000
-#define SK_TXCTL_EOF_INTR 0x08000000
-#define SK_TXCTL_EOB_INTR 0x10000000
-#define SK_TXCTL_LASTFRAG 0x20000000
-#define SK_TXCTL_FIRSTFRAG 0x40000000
-#define SK_TXCTL_OWN 0x80000000
-
-#define SK_TXSTAT \
- (SK_OPCODE_DEFAULT|SK_TXCTL_EOF_INTR|SK_TXCTL_LASTFRAG|SK_TXCTL_OWN)
-
-#define SK_RXBYTES(x) (x) & 0x0000FFFF;
-#define SK_TXBYTES SK_RXBYTES
-
-#define SK_TX_RING_CNT 512
-#define SK_RX_RING_CNT 256
-
-/*
- * Jumbo buffer stuff. Note that we must allocate more jumbo
- * buffers than there are descriptors in the receive ring. This
- * is because we don't know how long it will take for a packet
- * to be released after we hand it off to the upper protocol
- * layers. To be safe, we allocate 1.5 times the number of
- * receive descriptors.
- */
-#define SK_JUMBO_FRAMELEN 9018
-#define SK_JUMBO_MTU (SK_JUMBO_FRAMELEN-ETHER_HDR_LEN-ETHER_CRC_LEN)
-#define SK_JSLOTS 384
-
-#define SK_JRAWLEN (SK_JUMBO_FRAMELEN + ETHER_ALIGN + sizeof(u_int64_t))
-#define SK_JLEN (SK_JRAWLEN + (sizeof(u_int64_t) - \
- (SK_JRAWLEN % sizeof(u_int64_t))))
-#define SK_MCLBYTES (SK_JLEN - sizeof(u_int64_t))
-#define SK_JPAGESZ PAGE_SIZE
-#define SK_RESID (SK_JPAGESZ - (SK_JLEN * SK_JSLOTS) % SK_JPAGESZ)
-#define SK_JMEM ((SK_JLEN * SK_JSLOTS) + SK_RESID)
-
-struct sk_jslot {
- caddr_t sk_buf;
- int sk_inuse;
-};
-
-struct sk_jpool_entry {
- int slot;
- SLIST_ENTRY(sk_jpool_entry) jpool_entries;
-};
-
-struct sk_chain {
- void *sk_desc;
- struct mbuf *sk_mbuf;
- struct sk_chain *sk_next;
-};
-
-struct sk_chain_data {
- struct sk_chain sk_tx_chain[SK_TX_RING_CNT];
- struct sk_chain sk_rx_chain[SK_RX_RING_CNT];
- int sk_tx_prod;
- int sk_tx_cons;
- int sk_tx_cnt;
- int sk_rx_prod;
- int sk_rx_cons;
- int sk_rx_cnt;
- /* Stick the jumbo mem management stuff here too. */
- struct sk_jslot sk_jslots[SK_JSLOTS];
- void *sk_jumbo_buf;
-
-};
-
-struct sk_ring_data {
- struct sk_tx_desc sk_tx_ring[SK_TX_RING_CNT];
- struct sk_rx_desc sk_rx_ring[SK_RX_RING_CNT];
-};
-
-#define SK_INC(x, y) (x) = (x + 1) % y
-
-/* Forward decl. */
-struct sk_if_softc;
-
-/* Softc for the GEnesis controller. */
-struct sk_softc {
- bus_space_handle_t sk_bhandle; /* bus space handle */
- bus_space_tag_t sk_btag; /* bus space tag */
- void *sk_intrhand; /* irq handler handle */
- struct resource *sk_irq; /* IRQ resource handle */
- struct resource *sk_res; /* I/O or shared mem handle */
- u_int8_t sk_unit; /* controller number */
- u_int8_t sk_type;
- char *sk_vpd_prodname;
- char *sk_vpd_readonly;
- u_int32_t sk_rboff; /* RAMbuffer offset */
- u_int32_t sk_ramsize; /* amount of RAM on NIC */
- u_int32_t sk_pmd; /* physical media type */
- u_int32_t sk_intrmask;
- struct sk_if_softc *sk_if[2];
-};
-
-/* Softc for each logical interface */
-struct sk_if_softc {
- struct arpcom arpcom; /* interface info */
- struct ifmedia ifmedia; /* media info */
- u_int8_t sk_unit; /* interface number */
- u_int8_t sk_port; /* port # on controller */
- u_int8_t sk_xmac_rev; /* XMAC chip rev (B2 or C1) */
- u_int8_t sk_link;
- u_int32_t sk_rx_ramstart;
- u_int32_t sk_rx_ramend;
- u_int32_t sk_tx_ramstart;
- u_int32_t sk_tx_ramend;
- struct sk_chain_data sk_cdata;
- struct sk_ring_data *sk_rdata;
- struct sk_softc *sk_softc; /* parent controller */
- int sk_tx_bmu; /* TX BMU register */
- int sk_if_flags;
- SLIST_HEAD(__sk_jfreehead, sk_jpool_entry) sk_jfree_listhead;
- SLIST_HEAD(__sk_jinusehead, sk_jpool_entry) sk_jinuse_listhead;
-};
-
-#define SK_MAXUNIT 256
-#define SK_TIMEOUT 1000
-#define ETHER_ALIGN 2
-
-#ifdef __alpha__
-#undef vtophys
-#define vtophys(va) alpha_XXX_dmamap((vm_offset_t)va)
-#endif
diff --git a/sys/dev/sk/xmaciireg.h b/sys/dev/sk/xmaciireg.h
deleted file mode 100644
index f649e93a044e..000000000000
--- a/sys/dev/sk/xmaciireg.h
+++ /dev/null
@@ -1,393 +0,0 @@
-/*
- * Copyright (c) 1997, 1998, 1999
- * Bill Paul <wpaul@ctr.columbia.edu>. 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 Bill Paul.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY Bill Paul 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 Bill Paul OR THE VOICES IN HIS HEAD
- * 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Registers and data structures for the XaQti Corporation XMAC II
- * Gigabit Ethernet MAC. Datasheet is available from http://www.xaqti.com.
- * The XMAC can be programmed for 16-bit or 32-bit register access modes.
- * The SysKonnect gigabit ethernet adapters use 16-bit mode, so that's
- * how the registers are laid out here.
- */
-
-#define XM_DEVICEID 0x00E0AE20
-#define XM_XAQTI_OUI 0x00E0AE
-
-#define XM_XMAC_REV(x) (((x) & 0x000000E0) >> 5)
-
-#define XM_XMAC_REV_B2 0x0
-#define XM_XMAC_REV_C1 0x1
-
-#define XM_MMUCMD 0x0000
-#define XM_POFF 0x0008
-#define XM_BURST 0x000C
-#define XM_VLAN_TAGLEV1 0x0010
-#define XM_VLAN_TAGLEV2 0x0014
-#define XM_TXCMD 0x0020
-#define XM_TX_RETRYLIMIT 0x0024
-#define XM_TX_SLOTTIME 0x0028
-#define XM_TX_IPG 0x003C
-#define XM_RXCMD 0x0030
-#define XM_PHY_ADDR 0x0034
-#define XM_PHY_DATA 0x0038
-#define XM_GPIO 0x0040
-#define XM_IMR 0x0044
-#define XM_ISR 0x0048
-#define XM_HWCFG 0x004C
-#define XM_TX_LOWAT 0x0060
-#define XM_TX_HIWAT 0x0062
-#define XM_TX_REQTHRESH_LO 0x0064
-#define XM_TX_REQTHRESH_HI 0x0066
-#define XM_TX_REQTHRESH XM_TX_REQTHRESH_LO
-#define XM_PAUSEDST0 0x0068
-#define XM_PAUSEDST1 0x006A
-#define XM_PAUSEDST2 0x006C
-#define XM_CTLPARM_LO 0x0070
-#define XM_CTLPARM_HI 0x0072
-#define XM_CTLPARM XM_CTLPARM_LO
-#define XM_OPCODE_PAUSE_TIMER 0x0074
-#define XM_TXSTAT_LIFO 0x0078
-
-/*
- * Perfect filter registers. The XMAC has a table of 16 perfect
- * filter entries, spaced 8 bytes apart. This is in addition to
- * the station address registers, which appear below.
- */
-#define XM_RXFILT_BASE 0x0080
-#define XM_RXFILT_END 0x0107
-#define XM_RXFILT_MAX 16
-#define XM_RXFILT_ENTRY(ent) (XM_RXFILT_BASE + ((ent * 8)))
-
-/* Primary station address. */
-#define XM_PAR0 0x0108
-#define XM_PAR1 0x010A
-#define XM_PAR2 0x010C
-
-/* 64-bit multicast hash table registers */
-#define XM_MAR0 0x0110
-#define XM_MAR1 0x0112
-#define XM_MAR2 0x0114
-#define XM_MAR3 0x0116
-#define XM_RX_LOWAT 0x0118
-#define XM_RX_HIWAT 0x011A
-#define XM_RX_REQTHRESH_LO 0x011C
-#define XM_RX_REQTHRESH_HI 0x011E
-#define XM_RX_REQTHRESH XM_RX_REQTHRESH_LO
-#define XM_DEVID_LO 0x0120
-#define XM_DEVID_HI 0x0122
-#define XM_DEVID XM_DEVID_LO
-#define XM_MODE_LO 0x0124
-#define XM_MODE_HI 0x0126
-#define XM_MODE XM_MODE_LO
-#define XM_LASTSRC0 0x0128
-#define XM_LASTSRC1 0x012A
-#define XM_LASTSRC2 0x012C
-#define XM_TSTAMP_READ 0x0130
-#define XM_TSTAMP_LOAD 0x0134
-#define XM_STATS_CMD 0x0200
-#define XM_RXCNT_EVENT_LO 0x0204
-#define XM_RXCNT_EVENT_HI 0x0206
-#define XM_RXCNT_EVENT XM_RXCNT_EVENT_LO
-#define XM_TXCNT_EVENT_LO 0x0208
-#define XM_TXCNT_EVENT_HI 0x020A
-#define XM_TXCNT_EVENT XM_TXCNT_EVENT_LO
-#define XM_RXCNT_EVMASK_LO 0x020C
-#define XM_RXCNT_EVMASK_HI 0x020E
-#define XM_RXCNT_EVMASK XM_RXCNT_EVMASK_LO
-#define XM_TXCNT_EVMASK_LO 0x0210
-#define XM_TXCNT_EVMASK_HI 0x0212
-#define XM_TXCNT_EVMASK XM_TXCNT_EVMASK_LO
-
-/* Statistics command register */
-#define XM_STATCMD_CLR_TX 0x0001
-#define XM_STATCMD_CLR_RX 0x0002
-#define XM_STATCMD_COPY_TX 0x0004
-#define XM_STATCMD_COPY_RX 0x0008
-#define XM_STATCMD_SNAP_TX 0x0010
-#define XM_STATCMD_SNAP_RX 0x0020
-
-/* TX statistics registers */
-#define XM_TXSTATS_PKTSOK 0x280
-#define XM_TXSTATS_BYTESOK_HI 0x284
-#define XM_TXSTATS_BYTESOK_LO 0x288
-#define XM_TXSTATS_BCASTSOK 0x28C
-#define XM_TXSTATS_MCASTSOK 0x290
-#define XM_TXSTATS_UCASTSOK 0x294
-#define XM_TXSTATS_GIANTS 0x298
-#define XM_TXSTATS_BURSTCNT 0x29C
-#define XM_TXSTATS_PAUSEPKTS 0x2A0
-#define XM_TXSTATS_MACCTLPKTS 0x2A4
-#define XM_TXSTATS_SINGLECOLS 0x2A8
-#define XM_TXSTATS_MULTICOLS 0x2AC
-#define XM_TXSTATS_EXCESSCOLS 0x2B0
-#define XM_TXSTATS_LATECOLS 0x2B4
-#define XM_TXSTATS_DEFER 0x2B8
-#define XM_TXSTATS_EXCESSDEFER 0x2BC
-#define XM_TXSTATS_UNDERRUN 0x2C0
-#define XM_TXSTATS_CARRIERSENSE 0x2C4
-#define XM_TXSTATS_UTILIZATION 0x2C8
-#define XM_TXSTATS_64 0x2D0
-#define XM_TXSTATS_65_127 0x2D4
-#define XM_TXSTATS_128_255 0x2D8
-#define XM_TXSTATS_256_511 0x2DC
-#define XM_TXSTATS_512_1023 0x2E0
-#define XM_TXSTATS_1024_MAX 0x2E4
-
-/* RX statistics registers */
-#define XM_RXSTATS_PKTSOK 0x300
-#define XM_RXSTATS_BYTESOK_HI 0x304
-#define XM_RXSTATS_BYTESOK_LO 0x308
-#define XM_RXSTATS_BCASTSOK 0x30C
-#define XM_RXSTATS_MCASTSOK 0x310
-#define XM_RXSTATS_UCASTSOK 0x314
-#define XM_RXSTATS_PAUSEPKTS 0x318
-#define XM_RXSTATS_MACCTLPKTS 0x31C
-#define XM_RXSTATS_BADPAUSEPKTS 0x320
-#define XM_RXSTATS_BADMACCTLPKTS 0x324
-#define XM_RXSTATS_BURSTCNT 0x328
-#define XM_RXSTATS_MISSEDPKTS 0x32C
-#define XM_RXSTATS_FRAMEERRS 0x330
-#define XM_RXSTATS_OVERRUN 0x334
-#define XM_RXSTATS_JABBER 0x338
-#define XM_RXSTATS_CARRLOSS 0x33C
-#define XM_RXSTATS_INRNGLENERR 0x340
-#define XM_RXSTATS_SYMERR 0x344
-#define XM_RXSTATS_SHORTEVENT 0x348
-#define XM_RXSTATS_RUNTS 0x34C
-#define XM_RXSTATS_GIANTS 0x350
-#define XM_RXSTATS_CRCERRS 0x354
-#define XM_RXSTATS_CEXTERRS 0x35C
-#define XM_RXSTATS_UTILIZATION 0x360
-#define XM_RXSTATS_64 0x368
-#define XM_RXSTATS_65_127 0x36C
-#define XM_RXSTATS_128_255 0x370
-#define XM_RXSTATS_256_511 0x374
-#define XM_RXSTATS_512_1023 0x378
-#define XM_RXSTATS_1024_MAX 0x37C
-
-#define XM_MMUCMD_TX_ENB 0x0001
-#define XM_MMUCMD_RX_ENB 0x0002
-#define XM_MMUCMD_GMIILOOP 0x0004
-#define XM_MMUCMD_RATECTL 0x0008
-#define XM_MMUCMD_GMIIFDX 0x0010
-#define XM_MMUCMD_NO_MGMT_PRMB 0x0020
-#define XM_MMUCMD_SIMCOL 0x0040
-#define XM_MMUCMD_FORCETX 0x0080
-#define XM_MMUCMD_LOOPENB 0x0200
-#define XM_MMUCMD_IGNPAUSE 0x0400
-#define XM_MMUCMD_PHYBUSY 0x0800
-#define XM_MMUCMD_PHYDATARDY 0x1000
-
-#define XM_TXCMD_AUTOPAD 0x0001
-#define XM_TXCMD_NOCRC 0x0002
-#define XM_TXCMD_NOPREAMBLE 0x0004
-#define XM_TXCMD_NOGIGAMODE 0x0008
-#define XM_TXCMD_SAMPLELINE 0x0010
-#define XM_TXCMD_ENCBYPASS 0x0020
-#define XM_TXCMD_XMITBK2BK 0x0040
-#define XM_TXCMD_FAIRSHARE 0x0080
-
-#define XM_RXCMD_DISABLE_CEXT 0x0001
-#define XM_RXCMD_STRIPPAD 0x0002
-#define XM_RXCMD_SAMPLELINE 0x0004
-#define XM_RXCMD_SELFRX 0x0008
-#define XM_RXCMD_STRIPFCS 0x0010
-#define XM_RXCMD_TRANSPARENT 0x0020
-#define XM_RXCMD_IPGCAPTURE 0x0040
-#define XM_RXCMD_BIGPKTOK 0x0080
-#define XM_RXCMD_LENERROK 0x0100
-
-#define XM_IMR_RX_EOF 0x0001
-#define XM_IMR_TX_EOF 0x0002
-#define XM_IMR_TX_UNDERRUN 0x0004
-#define XM_IMR_RX_OVERRUN 0x0008
-#define XM_IMR_TX_STATS_OFLOW 0x0010
-#define XM_IMR_RX_STATS_OFLOW 0x0020
-#define XM_IMR_TSTAMP_OFLOW 0x0040
-#define XM_IMR_AUTONEG_DONE 0x0080
-#define XM_IMR_NEXTPAGE_RDY 0x0100
-#define XM_IMR_PAGE_RECEIVED 0x0200
-#define XM_IMR_LP_REQCFG 0x0400
-#define XM_IMR_GP0_SET 0x0800
-#define XM_IMR_FORCEINTR 0x1000
-#define XM_IMR_TX_ABORT 0x2000
-#define XM_IMR_LINKEVENT 0x4000
-
-#define XM_INTRS \
- (~(XM_IMR_LINKEVENT|XM_IMR_AUTONEG_DONE|XM_IMR_TX_UNDERRUN))
-
-#define XM_ISR_RX_EOF 0x0001
-#define XM_ISR_TX_EOF 0x0002
-#define XM_ISR_TX_UNDERRUN 0x0004
-#define XM_ISR_RX_OVERRUN 0x0008
-#define XM_ISR_TX_STATS_OFLOW 0x0010
-#define XM_ISR_RX_STATS_OFLOW 0x0020
-#define XM_ISR_TSTAMP_OFLOW 0x0040
-#define XM_ISR_AUTONEG_DONE 0x0080
-#define XM_ISR_NEXTPAGE_RDY 0x0100
-#define XM_ISR_PAGE_RECEIVED 0x0200
-#define XM_ISR_LP_REQCFG 0x0400
-#define XM_ISR_GP0_SET 0x0800
-#define XM_ISR_FORCEINTR 0x1000
-#define XM_ISR_TX_ABORT 0x2000
-#define XM_ISR_LINKEVENT 0x4000
-
-#define XM_MODE_FLUSH_RXFIFO 0x00000001
-#define XM_MODE_FLUSH_TXFIFO 0x00000002
-#define XM_MODE_BIGENDIAN 0x00000004
-#define XM_MODE_RX_PROMISC 0x00000008
-#define XM_MODE_RX_NOBROAD 0x00000010
-#define XM_MODE_RX_NOMULTI 0x00000020
-#define XM_MODE_RX_NOUNI 0x00000040
-#define XM_MODE_RX_BADFRAMES 0x00000080
-#define XM_MODE_RX_CRCERRS 0x00000100
-#define XM_MODE_RX_GIANTS 0x00000200
-#define XM_MODE_RX_INRANGELEN 0x00000400
-#define XM_MODE_RX_RUNTS 0x00000800
-#define XM_MODE_RX_MACCTL 0x00001000
-#define XM_MODE_RX_USE_PERFECT 0x00002000
-#define XM_MODE_RX_USE_STATION 0x00004000
-#define XM_MODE_RX_USE_HASH 0x00008000
-#define XM_MODE_RX_ADDRPAIR 0x00010000
-#define XM_MODE_PAUSEONHI 0x00020000
-#define XM_MODE_PAUSEONLO 0x00040000
-#define XM_MODE_TIMESTAMP 0x00080000
-#define XM_MODE_SENDPAUSE 0x00100000
-#define XM_MODE_SENDCONTINUOUS 0x00200000
-#define XM_MODE_LE_STATUSWORD 0x00400000
-#define XM_MODE_AUTOFIFOPAUSE 0x00800000
-#define XM_MODE_EXPAUSEGEN 0x02000000
-#define XM_MODE_RX_INVERSE 0x04000000
-
-#define XM_RXSTAT_MACCTL 0x00000001
-#define XM_RXSTAT_ERRFRAME 0x00000002
-#define XM_RXSTAT_CRCERR 0x00000004
-#define XM_RXSTAT_GIANT 0x00000008
-#define XM_RXSTAT_RUNT 0x00000010
-#define XM_RXSTAT_FRAMEERR 0x00000020
-#define XM_RXSTAT_INRANGEERR 0x00000040
-#define XM_RXSTAT_CARRIERERR 0x00000080
-#define XM_RXSTAT_COLLERR 0x00000100
-#define XM_RXSTAT_802_3 0x00000200
-#define XM_RXSTAT_CARREXTERR 0x00000400
-#define XM_RXSTAT_BURSTMODE 0x00000800
-#define XM_RXSTAT_UNICAST 0x00002000
-#define XM_RXSTAT_MULTICAST 0x00004000
-#define XM_RXSTAT_BROADCAST 0x00008000
-#define XM_RXSTAT_VLAN_LEV1 0x00010000
-#define XM_RXSTAT_VLAN_LEV2 0x00020000
-#define XM_RXSTAT_LEN 0xFFFC0000
-
-/*
- * XMAC PHY registers, indirectly accessed through
- * XM_PHY_ADDR and XM_PHY_REG.
- */
-
-#define XM_PHY_BMCR 0x0000 /* control */
-#define XM_PHY_BMSR 0x0001 /* status */
-#define XM_PHY_VENID 0x0002 /* vendor id */
-#define XM_PHY_DEVID 0x0003 /* device id */
-#define XM_PHY_ANAR 0x0004 /* autoneg advertisenemt */
-#define XM_PHY_LPAR 0x0005 /* link partner ability */
-#define XM_PHY_ANEXP 0x0006 /* autoneg expansion */
-#define XM_PHY_NEXTP 0x0007 /* nextpage */
-#define XM_PHY_LPNEXTP 0x0008 /* link partner's nextpage */
-#define XM_PHY_EXTSTS 0x000F /* extented status */
-#define XM_PHY_RESAB 0x0010 /* resolved ability */
-
-#define XM_BMCR_DUPLEX 0x0100
-#define XM_BMCR_RENEGOTIATE 0x0200
-#define XM_BMCR_AUTONEGENBL 0x1000
-#define XM_BMCR_LOOPBACK 0x4000
-#define XM_BMCR_RESET 0x8000
-
-#define XM_BMSR_EXTCAP 0x0001
-#define XM_BMSR_LINKSTAT 0x0004
-#define XM_BMSR_AUTONEGABLE 0x0008
-#define XM_BMSR_REMFAULT 0x0010
-#define XM_BMSR_AUTONEGDONE 0x0020
-#define XM_BMSR_EXTSTAT 0x0100
-
-#define XM_VENID_XAQTI 0xD14C
-#define XM_DEVID_XMAC 0x0002
-
-#define XM_ANAR_FULLDUPLEX 0x0020
-#define XM_ANAR_HALFDUPLEX 0x0040
-#define XM_ANAR_PAUSEBITS 0x0180
-#define XM_ANAR_REMFAULTBITS 0x1800
-#define XM_ANAR_ACK 0x4000
-#define XM_ANAR_NEXTPAGE 0x8000
-
-#define XM_LPAR_FULLDUPLEX 0x0020
-#define XM_LPAR_HALFDUPLEX 0x0040
-#define XM_LPAR_PAUSEBITS 0x0180
-#define XM_LPAR_REMFAULTBITS 0x1800
-#define XM_LPAR_ACK 0x4000
-#define XM_LPAR_NEXTPAGE 0x8000
-
-#define XM_PAUSE_NOPAUSE 0x0000
-#define XM_PAUSE_SYMPAUSE 0x0080
-#define XM_PAUSE_ASYMPAUSE 0x0100
-#define XM_PAUSE_BOTH 0x0180
-
-#define XM_REMFAULT_LINKOK 0x0000
-#define XM_REMFAULT_LINKFAIL 0x0800
-#define XM_REMFAULT_OFFLINE 0x1000
-#define XM_REMFAULT_ANEGERR 0x1800
-
-#define XM_ANEXP_GOTPAGE 0x0002
-#define XM_ANEXP_NEXTPAGE_SELF 0x0004
-#define XM_ANEXP_NEXTPAGE_LP 0x0008
-
-#define XM_NEXTP_MESSAGE 0x07FF
-#define XM_NEXTP_TOGGLE 0x0800
-#define XM_NEXTP_ACK2 0x1000
-#define XM_NEXTP_MPAGE 0x2000
-#define XM_NEXTP_ACK1 0x4000
-#define XM_NEXTP_NPAGE 0x8000
-
-#define XM_LPNEXTP_MESSAGE 0x07FF
-#define XM_LPNEXTP_TOGGLE 0x0800
-#define XM_LPNEXTP_ACK2 0x1000
-#define XM_LPNEXTP_MPAGE 0x2000
-#define XM_LPNEXTP_ACK1 0x4000
-#define XM_LPNEXTP_NPAGE 0x8000
-
-#define XM_EXTSTS_HALFDUPLEX 0x4000
-#define XM_EXTSTS_FULLDUPLEX 0x8000
-
-#define XM_RESAB_PAUSEMISMATCH 0x0008
-#define XM_RESAB_ABLMISMATCH 0x0010
-#define XM_RESAB_FDMODESEL 0x0020
-#define XM_RESAB_HDMODESEL 0x0040
-#define XM_RESAB_PAUSEBITS 0x0180
diff --git a/sys/dev/smbus/smb.h b/sys/dev/smbus/smb.h
deleted file mode 100644
index 7ed0a82f58fa..000000000000
--- a/sys/dev/smbus/smb.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*-
- * Copyright (c) 1998 Nicolas Souchu
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- *
- */
-#ifndef __SMB_H
-#define __SMB_H
-
-#include <sys/ioccom.h>
-
-struct smbcmd {
- char cmd;
- int count;
- u_char slave;
- union {
- char byte;
- short word;
-
- char *byte_ptr;
- short *word_ptr;
-
- struct {
- short sdata;
- short *rdata;
- } process;
- } data;
-};
-
-#define SMB_QUICK_WRITE _IOW('i', 1, struct smbcmd)
-#define SMB_QUICK_READ _IOW('i', 2, struct smbcmd)
-#define SMB_SENDB _IOW('i', 3, struct smbcmd)
-#define SMB_RECVB _IOW('i', 4, struct smbcmd)
-#define SMB_WRITEB _IOW('i', 5, struct smbcmd)
-#define SMB_WRITEW _IOW('i', 6, struct smbcmd)
-#define SMB_READB _IOW('i', 7, struct smbcmd)
-#define SMB_READW _IOW('i', 8, struct smbcmd)
-#define SMB_PCALL _IOW('i', 9, struct smbcmd)
-#define SMB_BWRITE _IOW('i', 10, struct smbcmd)
-#define SMB_BREAD _IOW('i', 11, struct smbcmd)
-
-#endif
diff --git a/sys/dev/snp/snp.c b/sys/dev/snp/snp.c
deleted file mode 100644
index 84ad3adf1d32..000000000000
--- a/sys/dev/snp/snp.c
+++ /dev/null
@@ -1,523 +0,0 @@
-/*
- * Copyright (c) 1995 Ugen J.S.Antsilevich
- *
- * Redistribution and use in source forms, with and without modification,
- * are permitted provided that this entire comment appears intact.
- *
- * Redistribution in binary form may occur without any restrictions.
- * Obviously, it would be nice if you gave credit where credit is due
- * but requiring it would be too onerous.
- *
- * This software is provided ``AS IS'' without any warranties of any kind.
- *
- * Snoop stuff.
- *
- * $FreeBSD$
- */
-
-#include "snp.h"
-#include "opt_compat.h"
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/filio.h>
-#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
-#include <sys/ioctl_compat.h>
-#endif
-#include <sys/proc.h>
-#include <sys/malloc.h>
-#include <sys/tty.h>
-#include <sys/conf.h>
-#include <sys/poll.h>
-#include <sys/kernel.h>
-#include <sys/snoop.h>
-#include <sys/vnode.h>
-
-static d_open_t snpopen;
-static d_close_t snpclose;
-static d_read_t snpread;
-static d_write_t snpwrite;
-static d_ioctl_t snpioctl;
-static d_poll_t snppoll;
-
-#define CDEV_MAJOR 53
-static struct cdevsw snp_cdevsw = {
- /* open */ snpopen,
- /* close */ snpclose,
- /* read */ snpread,
- /* write */ snpwrite,
- /* ioctl */ snpioctl,
- /* poll */ snppoll,
- /* mmap */ nommap,
- /* strategy */ nostrategy,
- /* name */ "snp",
- /* maj */ CDEV_MAJOR,
- /* dump */ nodump,
- /* psize */ nopsize,
- /* flags */ 0,
- /* bmaj */ -1
-};
-
-
-#ifndef MIN
-#define MIN(a,b) (((a)<(b))?(a):(b))
-#endif
-
-static struct snoop snoopsw[NSNP];
-
-static struct tty *snpdevtotty __P((dev_t dev));
-static int snp_detach __P((struct snoop *snp));
-
-static struct tty *
-snpdevtotty (dev)
- dev_t dev;
-{
- struct cdevsw *cdp;
-
- cdp = devsw(dev);
- if (cdp && cdp->d_flags & D_TTY)
- return (dev->si_tty);
- return (NULL);
-}
-
-#define SNP_INPUT_BUF 5 /* This is even too much,the maximal
- * interactive mode write is 3 bytes
- * length for function keys...
- */
-
-static int
-snpwrite(dev, uio, flag)
- dev_t dev;
- struct uio *uio;
- int flag;
-{
- int unit = minor(dev), len, i, error;
- struct snoop *snp = &snoopsw[unit];
- struct tty *tp;
- char c[SNP_INPUT_BUF];
-
- if (snp->snp_tty == NULL)
- return (EIO);
-
- tp = snp->snp_tty;
-
- if ((tp->t_sc == snp) && (tp->t_state & TS_SNOOP) &&
- (tp->t_line == OTTYDISC || tp->t_line == NTTYDISC))
- goto tty_input;
-
- printf("Snoop: attempt to write to bad tty.\n");
- return (EIO);
-
-tty_input:
- if (!(tp->t_state & TS_ISOPEN))
- return (EIO);
-
- while (uio->uio_resid > 0) {
- len = MIN(uio->uio_resid,SNP_INPUT_BUF);
- if ((error = uiomove(c, len, uio)) != 0)
- return (error);
- for (i=0;i<len;i++) {
- if (ttyinput(c[i] , tp))
- return (EIO);
- }
- }
- return 0;
-
-}
-
-
-static int
-snpread(dev, uio, flag)
- dev_t dev;
- struct uio *uio;
- int flag;
-{
- int unit = minor(dev), s;
- struct snoop *snp = &snoopsw[unit];
- int len, n, nblen, error = 0;
- caddr_t from;
- char *nbuf;
-
- KASSERT(snp->snp_len + snp->snp_base <= snp->snp_blen,
- ("snoop buffer error"));
-
- if (snp->snp_tty == NULL)
- return (EIO);
-
- snp->snp_flags &= ~SNOOP_RWAIT;
-
- do {
- if (snp->snp_len == 0) {
- if (flag & IO_NDELAY)
- return (EWOULDBLOCK);
- snp->snp_flags |= SNOOP_RWAIT;
- tsleep((caddr_t) snp, (PZERO + 1) | PCATCH, "snoopread", 0);
- }
- } while (snp->snp_len == 0);
-
- n = snp->snp_len;
-
- while (snp->snp_len > 0 && uio->uio_resid > 0 && error == 0) {
- len = MIN(uio->uio_resid, snp->snp_len);
- from = (caddr_t) (snp->snp_buf + snp->snp_base);
- if (len == 0)
- break;
-
- error = uiomove(from, len, uio);
- snp->snp_base += len;
- snp->snp_len -= len;
- }
- if ((snp->snp_flags & SNOOP_OFLOW) && (n < snp->snp_len)) {
- snp->snp_flags &= ~SNOOP_OFLOW;
- }
- s = spltty();
- nblen = snp->snp_blen;
- if (((nblen / 2) >= SNOOP_MINLEN) && (nblen / 2) >= snp->snp_len) {
- while (((nblen / 2) >= snp->snp_len) && ((nblen / 2) >= SNOOP_MINLEN))
- nblen = nblen / 2;
- if ((nbuf = malloc(nblen, M_TTYS, M_NOWAIT)) != NULL) {
- bcopy(snp->snp_buf + snp->snp_base, nbuf, snp->snp_len);
- free(snp->snp_buf, M_TTYS);
- snp->snp_buf = nbuf;
- snp->snp_blen = nblen;
- snp->snp_base = 0;
- }
- }
- splx(s);
-
- return error;
-}
-
-int
-snpinc(struct snoop *snp, char c)
-{
- char buf[1];
-
- buf[0]=c;
- return (snpin(snp,buf,1));
-}
-
-
-int
-snpin(snp, buf, n)
- struct snoop *snp;
- char *buf;
- int n;
-{
- int s_free, s_tail;
- int s, len, nblen;
- caddr_t from, to;
- char *nbuf;
-
- KASSERT(n >= 0, ("negative snoop char count"));
-
- if (n == 0)
- return 0;
-
-#ifdef DIAGNOSTIC
- if (!(snp->snp_flags & SNOOP_OPEN)) {
- printf("Snoop: data coming to closed device.\n");
- return 0;
- }
-#endif
- if (snp->snp_flags & SNOOP_DOWN) {
- printf("Snoop: more data to down interface.\n");
- return 0;
- }
-
- if (snp->snp_flags & SNOOP_OFLOW) {
- printf("Snoop: buffer overflow.\n");
- /*
- * On overflow we just repeat the standart close
- * procedure...yes , this is waste of space but.. Then next
- * read from device will fail if one would recall he is
- * snooping and retry...
- */
-
- return (snpdown(snp));
- }
- s_tail = snp->snp_blen - (snp->snp_len + snp->snp_base);
- s_free = snp->snp_blen - snp->snp_len;
-
-
- if (n > s_free) {
- s = spltty();
- nblen = snp->snp_blen;
- while ((n > s_free) && ((nblen * 2) <= SNOOP_MAXLEN)) {
- nblen = snp->snp_blen * 2;
- s_free = nblen - (snp->snp_len + snp->snp_base);
- }
- if ((n <= s_free) && (nbuf = malloc(nblen, M_TTYS, M_NOWAIT))) {
- bcopy(snp->snp_buf + snp->snp_base, nbuf, snp->snp_len);
- free(snp->snp_buf, M_TTYS);
- snp->snp_buf = nbuf;
- snp->snp_blen = nblen;
- snp->snp_base = 0;
- } else {
- snp->snp_flags |= SNOOP_OFLOW;
- if (snp->snp_flags & SNOOP_RWAIT) {
- snp->snp_flags &= ~SNOOP_RWAIT;
- wakeup((caddr_t) snp);
- }
- splx(s);
- return 0;
- }
- splx(s);
- }
- if (n > s_tail) {
- from = (caddr_t) (snp->snp_buf + snp->snp_base);
- to = (caddr_t) (snp->snp_buf);
- len = snp->snp_len;
- bcopy(from, to, len);
- snp->snp_base = 0;
- }
- to = (caddr_t) (snp->snp_buf + snp->snp_base + snp->snp_len);
- bcopy(buf, to, n);
- snp->snp_len += n;
-
- if (snp->snp_flags & SNOOP_RWAIT) {
- snp->snp_flags &= ~SNOOP_RWAIT;
- wakeup((caddr_t) snp);
- }
- selwakeup(&snp->snp_sel);
- snp->snp_sel.si_pid = 0;
-
- return n;
-}
-
-static int
-snpopen(dev, flag, mode, p)
- dev_t dev;
- int flag, mode;
- struct proc *p;
-{
- struct snoop *snp;
- register int unit, error;
-
- if ((error = suser(p)) != 0)
- return (error);
-
- if ((unit = minor(dev)) >= NSNP)
- return (ENXIO);
-
- snp = &snoopsw[unit];
-
- if (snp->snp_flags & SNOOP_OPEN)
- return (ENXIO);
-
- /*
- * We intentionally do not OR flags with SNOOP_OPEN,but set them so
- * all previous settings (especially SNOOP_OFLOW) will be cleared.
- */
- snp->snp_flags = SNOOP_OPEN;
-
- snp->snp_buf = malloc(SNOOP_MINLEN, M_TTYS, M_WAITOK);
- snp->snp_blen = SNOOP_MINLEN;
- snp->snp_base = 0;
- snp->snp_len = 0;
-
- /*
- * snp_tty == NULL is for inactive snoop devices.
- */
- snp->snp_tty = NULL;
- snp->snp_target = NODEV;
- return (0);
-}
-
-
-static int
-snp_detach(snp)
- struct snoop *snp;
-{
- struct tty *tp;
-
- snp->snp_base = 0;
- snp->snp_len = 0;
-
- /*
- * If line disc. changed we do not touch this pointer,SLIP/PPP will
- * change it anyway.
- */
-
- if (snp->snp_tty == NULL)
- goto detach_notty;
-
- tp = snp->snp_tty;
-
- if (tp && (tp->t_sc == snp) && (tp->t_state & TS_SNOOP) &&
- (tp->t_line == OTTYDISC || tp->t_line == NTTYDISC)) {
- tp->t_sc = NULL;
- tp->t_state &= ~TS_SNOOP;
- } else
- printf("Snoop: bad attached tty data.\n");
-
- snp->snp_tty = NULL;
- snp->snp_target = NODEV;
-
-detach_notty:
- selwakeup(&snp->snp_sel);
- snp->snp_sel.si_pid = 0;
-
- return (0);
-}
-
-static int
-snpclose(dev, flags, fmt, p)
- dev_t dev;
- int flags;
- int fmt;
- struct proc *p;
-{
- register int unit = minor(dev);
- struct snoop *snp = &snoopsw[unit];
-
- snp->snp_blen = 0;
- free(snp->snp_buf, M_TTYS);
- snp->snp_flags &= ~SNOOP_OPEN;
-
- return (snp_detach(snp));
-}
-
-int
-snpdown(snp)
- struct snoop *snp;
-{
- snp->snp_blen = SNOOP_MINLEN;
- free(snp->snp_buf, M_TTYS);
- snp->snp_buf = malloc(SNOOP_MINLEN, M_TTYS, M_WAITOK);
- snp->snp_flags |= SNOOP_DOWN;
-
- return (snp_detach(snp));
-}
-
-
-static int
-snpioctl(dev, cmd, data, flags, p)
- dev_t dev;
- u_long cmd;
- caddr_t data;
- int flags;
- struct proc *p;
-{
- int unit = minor(dev), s;
- dev_t tdev;
- struct snoop *snp = &snoopsw[unit];
- struct tty *tp, *tpo;
-
- switch (cmd) {
- case SNPSTTY:
- tdev = udev2dev(*((udev_t *) data), 0);
- if (tdev == NODEV)
- return (snpdown(snp));
-
- tp = snpdevtotty(tdev);
- if (!tp)
- return (EINVAL);
-
- if ((tp->t_sc != (caddr_t) snp) && (tp->t_state & TS_SNOOP))
- return (EBUSY);
-
- if ((tp->t_line != OTTYDISC) && (tp->t_line != NTTYDISC))
- return (EBUSY);
-
- s = spltty();
-
- if (snp->snp_target == NODEV) {
- tpo = snp->snp_tty;
- if (tpo)
- tpo->t_state &= ~TS_SNOOP;
- }
-
- tp->t_sc = (caddr_t) snp;
- tp->t_state |= TS_SNOOP;
- snp->snp_tty = tp;
- snp->snp_target = tdev;
-
- /*
- * Clean overflow and down flags -
- * we'll have a chance to get them in the future :)))
- */
- snp->snp_flags &= ~SNOOP_OFLOW;
- snp->snp_flags &= ~SNOOP_DOWN;
- splx(s);
- break;
-
- case SNPGTTY:
- /*
- * We keep snp_target field specially to make
- * SNPGTTY happy,else we can't know what is device
- * major/minor for tty.
- */
- *((dev_t *) data) = snp->snp_target;
- break;
-
- case FIONBIO:
- break;
-
- case FIOASYNC:
- if (*(int *) data)
- snp->snp_flags |= SNOOP_ASYNC;
- else
- snp->snp_flags &= ~SNOOP_ASYNC;
- break;
-
- case FIONREAD:
- s = spltty();
- if (snp->snp_tty != NULL)
- *(int *) data = snp->snp_len;
- else
- if (snp->snp_flags & SNOOP_DOWN) {
- if (snp->snp_flags & SNOOP_OFLOW)
- *(int *) data = SNP_OFLOW;
- else
- *(int *) data = SNP_TTYCLOSE;
- } else {
- *(int *) data = SNP_DETACH;
- }
- splx(s);
- break;
-
- default:
- return (ENOTTY);
- }
- return (0);
-}
-
-
-static int
-snppoll(dev, events, p)
- dev_t dev;
- int events;
- struct proc *p;
-{
- int unit = minor(dev);
- struct snoop *snp = &snoopsw[unit];
- int revents = 0;
-
-
- /*
- * If snoop is down,we don't want to poll() forever so we return 1.
- * Caller should see if we down via FIONREAD ioctl().The last should
- * return -1 to indicate down state.
- */
- if (events & (POLLIN | POLLRDNORM)) {
- if (snp->snp_flags & SNOOP_DOWN || snp->snp_len > 0)
- revents |= events & (POLLIN | POLLRDNORM);
- else
- selrecord(p, &snp->snp_sel);
- }
- return (revents);
-}
-
-static void snp_drvinit __P((void *unused));
-
-static void
-snp_drvinit(unused)
- void *unused;
-{
- int i;
-
- for (i = 0; i < NSNP; i++)
- make_dev(&snp_cdevsw, i, 0, 0, 0600, "snp%d", i);
-}
-
-SYSINIT(snpdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,snp_drvinit,NULL)
diff --git a/sys/dev/sound/isa/sb16.c b/sys/dev/sound/isa/sb16.c
deleted file mode 100644
index 216198272a3c..000000000000
--- a/sys/dev/sound/isa/sb16.c
+++ /dev/null
@@ -1,1204 +0,0 @@
-/*
- * Copyright (c) 1999 Cameron Grant <gandalf@vilnya.demon.co.uk>
- * Copyright 1997,1998 Luigi Rizzo.
- *
- * Derived from files in the Voxware 3.5 distribution,
- * Copyright by Hannu Savolainen 1994, under the same copyright
- * conditions.
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include <dev/sound/pcm/sound.h>
-
-#include "sbc.h"
-
-#define __SB_MIXER_C__ /* XXX warning... */
-#include <dev/sound/isa/sb.h>
-#include <dev/sound/chip.h>
-
-#define ESS_BUFFSIZE (65536 - 256)
-#define PLAIN_SB16(x) ((((x)->bd_flags) & (BD_F_SB16|BD_F_SB16X)) == BD_F_SB16)
-
-/* channel interface */
-static void *sbchan_init(void *devinfo, snd_dbuf *b, pcm_channel *c, int dir);
-static int sbchan_setdir(void *data, int dir);
-static int sbchan_setformat(void *data, u_int32_t format);
-static int sbchan_setspeed(void *data, u_int32_t speed);
-static int sbchan_setblocksize(void *data, u_int32_t blocksize);
-static int sbchan_trigger(void *data, int go);
-static int sbchan_getptr(void *data);
-static pcmchan_caps *sbchan_getcaps(void *data);
-
-/* channel interface for ESS */
-static void *esschan_init(void *devinfo, snd_dbuf *b, pcm_channel *c, int dir);
-static int esschan_setdir(void *data, int dir);
-static int esschan_setformat(void *data, u_int32_t format);
-static int esschan_setspeed(void *data, u_int32_t speed);
-static int esschan_setblocksize(void *data, u_int32_t blocksize);
-static int esschan_trigger(void *data, int go);
-static int esschan_getptr(void *data);
-static pcmchan_caps *esschan_getcaps(void *data);
-
-static pcmchan_caps sb_playcaps = {
- 4000, 22050,
- AFMT_U8,
- AFMT_U8
-};
-
-static pcmchan_caps sb_reccaps = {
- 4000, 13000,
- AFMT_U8,
- AFMT_U8
-};
-
-static pcmchan_caps sbpro_playcaps = {
- 4000, 45000,
- AFMT_STEREO | AFMT_U8,
- AFMT_STEREO | AFMT_U8
-};
-
-static pcmchan_caps sbpro_reccaps = {
- 4000, 15000,
- AFMT_STEREO | AFMT_U8,
- AFMT_STEREO | AFMT_U8
-};
-
-static pcmchan_caps sb16_hcaps = {
- 5000, 45000,
- AFMT_STEREO | AFMT_S16_LE,
- AFMT_STEREO | AFMT_S16_LE
-};
-
-static pcmchan_caps sb16_lcaps = {
- 5000, 45000,
- AFMT_STEREO | AFMT_U8,
- AFMT_STEREO | AFMT_U8
-};
-
-static pcmchan_caps sb16x_caps = {
- 5000, 49000,
- AFMT_STEREO | AFMT_U8 | AFMT_S16_LE,
- AFMT_STEREO | AFMT_S16_LE
-};
-
-static pcmchan_caps ess_playcaps = {
- 5000, 49000,
- AFMT_STEREO | AFMT_U8 | AFMT_S16_LE,
- AFMT_STEREO | AFMT_S16_LE
-};
-
-static pcmchan_caps ess_reccaps = {
- 5000, 49000,
- AFMT_STEREO | AFMT_U8 | AFMT_S16_LE,
- AFMT_STEREO | AFMT_S16_LE
-};
-
-static pcm_channel sb_chantemplate = {
- sbchan_init,
- sbchan_setdir,
- sbchan_setformat,
- sbchan_setspeed,
- sbchan_setblocksize,
- sbchan_trigger,
- sbchan_getptr,
- sbchan_getcaps,
-};
-
-static pcm_channel ess_chantemplate = {
- esschan_init,
- esschan_setdir,
- esschan_setformat,
- esschan_setspeed,
- esschan_setblocksize,
- esschan_trigger,
- esschan_getptr,
- esschan_getcaps,
-};
-
-struct sb_info;
-
-struct sb_chinfo {
- struct sb_info *parent;
- pcm_channel *channel;
- snd_dbuf *buffer;
- int dir;
- u_int32_t fmt, spd;
- int ess_dma_started;
-};
-
-struct sb_info {
- struct resource *io_base; /* I/O address for the board */
- struct resource *irq;
- struct resource *drq1;
- struct resource *drq2;
- bus_dma_tag_t parent_dmat;
-
- int bd_id;
- u_long bd_flags; /* board-specific flags */
- struct sb_chinfo pch, rch;
-};
-
-static int sb_rd(struct sb_info *sb, int reg);
-static void sb_wr(struct sb_info *sb, int reg, u_int8_t val);
-static int sb_dspready(struct sb_info *sb);
-static int sb_cmd(struct sb_info *sb, u_char val);
-static int sb_cmd1(struct sb_info *sb, u_char cmd, int val);
-static int sb_cmd2(struct sb_info *sb, u_char cmd, int val);
-static u_int sb_get_byte(struct sb_info *sb);
-static void sb_setmixer(struct sb_info *sb, u_int port, u_int value);
-static int sb_getmixer(struct sb_info *sb, u_int port);
-static int sb_reset_dsp(struct sb_info *sb);
-
-static void sb_intr(void *arg);
-static int sb_speed(struct sb_chinfo *ch);
-static int sb_start(struct sb_chinfo *ch);
-static int sb_stop(struct sb_chinfo *ch);
-
-static int ess_write(struct sb_info *sb, u_char reg, int val);
-static int ess_read(struct sb_info *sb, u_char reg);
-static void ess_intr(void *arg);
-static int ess_format(struct sb_chinfo *ch, u_int32_t format);
-static int ess_speed(struct sb_chinfo *ch, int speed);
-static int ess_start(struct sb_chinfo *ch);
-static int ess_stop(struct sb_chinfo *ch);
-static int ess_abort(struct sb_chinfo *ch);
-
-static int sbmix_init(snd_mixer *m);
-static int sbmix_set(snd_mixer *m, unsigned dev, unsigned left, unsigned right);
-static int sbmix_setrecsrc(snd_mixer *m, u_int32_t src);
-
-static snd_mixer sb_mixer = {
- "SoundBlaster mixer",
- sbmix_init,
- sbmix_set,
- sbmix_setrecsrc,
-};
-
-static devclass_t pcm_devclass;
-
-/*
- * Common code for the midi and pcm functions
- *
- * sb_cmd write a single byte to the CMD port.
- * sb_cmd1 write a CMD + 1 byte arg
- * sb_cmd2 write a CMD + 2 byte arg
- * sb_get_byte returns a single byte from the DSP data port
- *
- * ess_write is actually sb_cmd1
- * ess_read access ext. regs via sb_cmd(0xc0, reg) followed by sb_get_byte
- */
-
-static int
-port_rd(struct resource *port, int off)
-{
- return bus_space_read_1(rman_get_bustag(port),
- rman_get_bushandle(port),
- off);
-}
-
-static void
-port_wr(struct resource *port, int off, u_int8_t data)
-{
- return bus_space_write_1(rman_get_bustag(port),
- rman_get_bushandle(port),
- off, data);
-}
-
-static int
-sb_rd(struct sb_info *sb, int reg)
-{
- return port_rd(sb->io_base, reg);
-}
-
-static void
-sb_wr(struct sb_info *sb, int reg, u_int8_t val)
-{
- port_wr(sb->io_base, reg, val);
-}
-
-static int
-sb_dspready(struct sb_info *sb)
-{
- return ((sb_rd(sb, SBDSP_STATUS) & 0x80) == 0);
-}
-
-static int
-sb_dspwr(struct sb_info *sb, u_char val)
-{
- int i;
-
- for (i = 0; i < 1000; i++) {
- if (sb_dspready(sb)) {
- sb_wr(sb, SBDSP_CMD, val);
- return 1;
- }
- if (i > 10) DELAY((i > 100)? 1000 : 10);
- }
- printf("sb_dspwr(0x%02x) timed out.\n", val);
- return 0;
-}
-
-static int
-sb_cmd(struct sb_info *sb, u_char val)
-{
-#if 0
- printf("sb_cmd: %x\n", val);
-#endif
- return sb_dspwr(sb, val);
-}
-
-static int
-sb_cmd1(struct sb_info *sb, u_char cmd, int val)
-{
-#if 0
- printf("sb_cmd1: %x, %x\n", cmd, val);
-#endif
- if (sb_dspwr(sb, cmd)) {
- return sb_dspwr(sb, val & 0xff);
- } else return 0;
-}
-
-static int
-sb_cmd2(struct sb_info *sb, u_char cmd, int val)
-{
-#if 0
- printf("sb_cmd2: %x, %x\n", cmd, val);
-#endif
- if (sb_dspwr(sb, cmd)) {
- return sb_dspwr(sb, val & 0xff) &&
- sb_dspwr(sb, (val >> 8) & 0xff);
- } else return 0;
-}
-
-/*
- * in the SB, there is a set of indirect "mixer" registers with
- * address at offset 4, data at offset 5
- */
-static void
-sb_setmixer(struct sb_info *sb, u_int port, u_int value)
-{
- u_long flags;
-
- flags = spltty();
- sb_wr(sb, SB_MIX_ADDR, (u_char) (port & 0xff)); /* Select register */
- DELAY(10);
- sb_wr(sb, SB_MIX_DATA, (u_char) (value & 0xff));
- DELAY(10);
- splx(flags);
-}
-
-static int
-sb_getmixer(struct sb_info *sb, u_int port)
-{
- int val;
- u_long flags;
-
- flags = spltty();
- sb_wr(sb, SB_MIX_ADDR, (u_char) (port & 0xff)); /* Select register */
- DELAY(10);
- val = sb_rd(sb, SB_MIX_DATA);
- DELAY(10);
- splx(flags);
-
- return val;
-}
-
-static u_int
-sb_get_byte(struct sb_info *sb)
-{
- int i;
-
- for (i = 1000; i > 0; i--) {
- if (sb_rd(sb, DSP_DATA_AVAIL) & 0x80)
- return sb_rd(sb, DSP_READ);
- else
- DELAY(20);
- }
- return 0xffff;
-}
-
-static int
-ess_write(struct sb_info *sb, u_char reg, int val)
-{
- return sb_cmd1(sb, reg, val);
-}
-
-static int
-ess_read(struct sb_info *sb, u_char reg)
-{
- return (sb_cmd(sb, 0xc0) && sb_cmd(sb, reg))? sb_get_byte(sb) : 0xffff;
-}
-
-static int
-sb_reset_dsp(struct sb_info *sb)
-{
- sb_wr(sb, SBDSP_RST, 3);
- DELAY(100);
- sb_wr(sb, SBDSP_RST, 0);
- if (sb_get_byte(sb) != 0xAA) {
- DEB(printf("sb_reset_dsp 0x%lx failed\n",
- rman_get_start(d->io_base)));
- return ENXIO; /* Sorry */
- }
- if (sb->bd_flags & BD_F_ESS)
- sb_cmd(sb, 0xc6);
- return 0;
-}
-
-static void
-sb_release_resources(struct sb_info *sb, device_t dev)
-{
- /* should we bus_teardown_intr here? */
- if (sb->irq) {
- bus_release_resource(dev, SYS_RES_IRQ, 0, sb->irq);
- sb->irq = 0;
- }
- if (sb->drq1) {
- bus_release_resource(dev, SYS_RES_DRQ, 0, sb->drq1);
- sb->drq1 = 0;
- }
- if (sb->drq2) {
- bus_release_resource(dev, SYS_RES_DRQ, 1, sb->drq2);
- sb->drq2 = 0;
- }
- if (sb->io_base) {
- bus_release_resource(dev, SYS_RES_IOPORT, 0, sb->io_base);
- sb->io_base = 0;
- }
- free(sb, M_DEVBUF);
-}
-
-static int
-sb_alloc_resources(struct sb_info *sb, device_t dev)
-{
- int rid;
-
- rid = 0;
- if (!sb->io_base)
- sb->io_base = bus_alloc_resource(dev, SYS_RES_IOPORT,
- &rid, 0, ~0, 1,
- RF_ACTIVE);
- rid = 0;
- if (!sb->irq)
- sb->irq = bus_alloc_resource(dev, SYS_RES_IRQ,
- &rid, 0, ~0, 1,
- RF_ACTIVE);
- rid = 0;
- if (!sb->drq1)
- sb->drq1 = bus_alloc_resource(dev, SYS_RES_DRQ,
- &rid, 0, ~0, 1,
- RF_ACTIVE);
- rid = 1;
- if (!sb->drq2 && !(sb->bd_flags & BD_F_ESS))
- sb->drq2 = bus_alloc_resource(dev, SYS_RES_DRQ,
- &rid, 0, ~0, 1,
- RF_ACTIVE);
-
- if (sb->io_base && sb->drq1 && sb->irq) {
- int bs = (sb->bd_flags & BD_F_ESS)? ESS_BUFFSIZE : DSP_BUFFSIZE;
-
- isa_dma_acquire(rman_get_start(sb->drq1));
- isa_dmainit(rman_get_start(sb->drq1), bs);
-
- if (sb->drq2) {
- isa_dma_acquire(rman_get_start(sb->drq2));
- isa_dmainit(rman_get_start(sb->drq2), bs);
- }
-
- return 0;
- } else return ENXIO;
-}
-
-static void
-sb16_swap(void *v, int dir)
-{
- struct sb_info *sb = v;
- int pb = sb->pch.buffer->dl;
- int rb = sb->rch.buffer->dl;
- int pc = sb->pch.buffer->chan;
- int rc = sb->rch.buffer->chan;
- int swp = 0;
-
- if (!pb && !rb) {
- if (dir == PCMDIR_PLAY && pc < 4)
- swp = 1;
- else
- if (dir == PCMDIR_REC && rc < 4)
- swp = 1;
- if (sb->bd_flags & BD_F_SB16X)
- swp = !swp;
- if (swp) {
- int t;
-
- t = sb->pch.buffer->chan;
- sb->pch.buffer->chan = sb->rch.buffer->chan;
- sb->rch.buffer->chan = t;
- sb->pch.buffer->dir = B_WRITE;
- sb->rch.buffer->dir = B_READ;
- }
- }
-}
-
-static int
-sb_doattach(device_t dev, struct sb_info *sb)
-{
- snddev_info *d = device_get_softc(dev);
- void *ih;
- char status[SND_STATUSLEN];
- int bs = (sb->bd_flags & BD_F_ESS)? ESS_BUFFSIZE : DSP_BUFFSIZE;
-
- if (sb_alloc_resources(sb, dev))
- goto no;
- if (sb_reset_dsp(sb))
- goto no;
- mixer_init(d, &sb_mixer, sb);
-
- if (sb->bd_flags & BD_F_ESS)
- bus_setup_intr(dev, sb->irq, INTR_TYPE_TTY, ess_intr, sb, &ih);
- else
- bus_setup_intr(dev, sb->irq, INTR_TYPE_TTY, sb_intr, sb, &ih);
- if ((sb->bd_flags & BD_F_SB16) && !(sb->bd_flags & BD_F_SB16X))
- pcm_setswap(dev, sb16_swap);
- if (!sb->drq2)
- pcm_setflags(dev, pcm_getflags(dev) | SD_F_SIMPLEX);
-
- if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0,
- /*lowaddr*/BUS_SPACE_MAXADDR_24BIT,
- /*highaddr*/BUS_SPACE_MAXADDR,
- /*filter*/NULL, /*filterarg*/NULL,
- /*maxsize*/bs, /*nsegments*/1,
- /*maxsegz*/0x3ffff,
- /*flags*/0, &sb->parent_dmat) != 0) {
- device_printf(dev, "unable to create dma tag\n");
- goto no;
- }
-
- snprintf(status, SND_STATUSLEN, "at io 0x%lx irq %ld drq %ld",
- rman_get_start(sb->io_base), rman_get_start(sb->irq),
- rman_get_start(sb->drq1));
- if (sb->drq2)
- snprintf(status + strlen(status), SND_STATUSLEN - strlen(status),
- ":%ld", rman_get_start(sb->drq2));
-
- if (pcm_register(dev, sb, 1, 1))
- goto no;
- if (sb->bd_flags & BD_F_ESS) {
- pcm_addchan(dev, PCMDIR_REC, &ess_chantemplate, sb);
- pcm_addchan(dev, PCMDIR_PLAY, &ess_chantemplate, sb);
- } else {
- pcm_addchan(dev, PCMDIR_REC, &sb_chantemplate, sb);
- pcm_addchan(dev, PCMDIR_PLAY, &sb_chantemplate, sb);
- }
- pcm_setstatus(dev, status);
-
- return 0;
-
-no:
- sb_release_resources(sb, dev);
- return ENXIO;
-}
-
-static void
-sb_intr(void *arg)
-{
- struct sb_info *sb = (struct sb_info *)arg;
- int reason = 3, c;
-
- /*
- * SB < 4.0 is half duplex and has only 1 bit for int source,
- * so we fake it. SB 4.x (SB16) has the int source in a separate
- * register.
- * The Vibra16X has separate flags for 8 and 16 bit transfers, but
- * I have no idea how to tell capture from playback interrupts...
- */
- if (sb->bd_flags & BD_F_SB16) {
- c = sb_getmixer(sb, IRQ_STAT);
- /* this tells us if the source is 8-bit or 16-bit dma. We
- * have to check the io channel to map it to read or write...
- */
- reason = 0;
- if (c & 1) { /* 8-bit dma */
- if (sb->pch.fmt & AFMT_U8)
- reason |= 1;
- if (sb->rch.fmt & AFMT_U8)
- reason |= 2;
- }
- if (c & 2) { /* 16-bit dma */
- if (sb->pch.fmt & AFMT_S16_LE)
- reason |= 1;
- if (sb->rch.fmt & AFMT_S16_LE)
- reason |= 2;
- }
- } else c = 1;
-#if 0
- printf("sb_intr: reason=%d c=0x%x\n", reason, c);
-#endif
- if ((reason & 1) && (sb->pch.buffer->dl > 0))
- chn_intr(sb->pch.channel);
- if ((reason & 2) && (sb->rch.buffer->dl > 0))
- chn_intr(sb->rch.channel);
- if (c & 1)
- sb_rd(sb, DSP_DATA_AVAIL); /* 8-bit int ack */
- if (c & 2)
- sb_rd(sb, DSP_DATA_AVL16); /* 16-bit int ack */
-}
-
-static void
-ess_intr(void *arg)
-{
- struct sb_info *sb = (struct sb_info *)arg;
-
- sb_rd(sb, DSP_DATA_AVAIL); /* int ack */
-#ifdef notyet
- /*
- * XXX
- * for full-duplex mode:
- * should read port 0x6 to identify where interrupt came from.
- */
-#endif
- /*
- * We are transferring data in DSP normal mode,
- * so clear the dl to indicate the DMA is stopped.
- */
- if (sb->pch.buffer->dl > 0)
- chn_intr(sb->pch.channel);
- if (sb->rch.buffer->dl > 0)
- chn_intr(sb->rch.channel);
-}
-
-static int
-sb_speed(struct sb_chinfo *ch)
-{
- struct sb_info *sb = ch->parent;
- int play = (ch->dir == PCMDIR_PLAY)? 1 : 0;
- int stereo = (ch->fmt & AFMT_STEREO)? 1 : 0;
- int speed = ch->spd;
-
- if (sb->bd_flags & BD_F_SB16) {
- RANGE(speed, 5000, 45000);
- sb_cmd(sb, 0x42 - play);
- sb_cmd(sb, speed >> 8);
- sb_cmd(sb, speed & 0xff);
- } else {
- u_char tconst;
- int max_speed = 45000, tmp;
- u_long flags;
-
- /* here enforce speed limitations - max 22050 on sb 1.x*/
- if (sb->bd_id <= 0x200)
- max_speed = 22050;
-
- /*
- * SB models earlier than SB Pro have low limit for the
- * input rate. Note that this is only for input, but since
- * we do not support separate values for rec & play....
- */
- if (!play) {
- if (sb->bd_id <= 0x200)
- max_speed = 13000;
- else
- if (sb->bd_id < 0x300)
- max_speed = 15000;
- }
- RANGE(speed, 4000, max_speed);
- if (stereo)
- speed <<= 1;
-
- /*
- * Now the speed should be valid. Compute the value to be
- * programmed into the board.
- */
- if (speed > 22050) { /* High speed mode on 2.01/3.xx */
- tconst = (u_char)
- ((65536 - ((256000000 + speed / 2) / speed))
- >> 8);
- sb->bd_flags |= BD_F_HISPEED;
- tmp = 65536 - (tconst << 8);
- speed = (256000000 + tmp / 2) / tmp;
- } else {
- sb->bd_flags &= ~BD_F_HISPEED;
- tconst = (256 - ((1000000 + speed / 2) / speed)) & 0xff;
- tmp = 256 - tconst;
- speed = (1000000 + tmp / 2) / tmp;
- }
- flags = spltty();
- sb_cmd1(sb, 0x40, tconst); /* set time constant */
- splx(flags);
- if (stereo)
- speed >>= 1;
- }
- ch->spd = speed;
- return speed;
-}
-
-static int
-sb_start(struct sb_chinfo *ch)
-{
- struct sb_info *sb = ch->parent;
- int play = (ch->dir == PCMDIR_PLAY)? 1 : 0;
- int b16 = (ch->fmt & AFMT_S16_LE)? 1 : 0;
- int stereo = (ch->fmt & AFMT_STEREO)? 1 : 0;
- int l = ch->buffer->dl;
- int dh = ch->buffer->chan > 3;
- u_char i1, i2;
-
- if (b16 || dh)
- l >>= 1;
- l--;
-
- if (play)
- sb_cmd(sb, DSP_CMD_SPKON);
-
- if (sb->bd_flags & BD_F_SB16) {
- i1 = DSP_F16_AUTO | DSP_F16_FIFO_ON;
- i1 |= play? DSP_F16_DAC : DSP_F16_ADC;
- i1 |= (b16 || dh)? DSP_DMA16 : DSP_DMA8;
- i2 = (stereo? DSP_F16_STEREO : 0) | (b16? DSP_F16_SIGNED : 0);
- sb_cmd(sb, i1);
- sb_cmd2(sb, i2, l);
- } else {
- if (sb->bd_flags & BD_F_HISPEED)
- i1 = play? 0x90 : 0x98;
- else
- i1 = play? 0x1c : 0x2c;
- sb_setmixer(sb, 0x0e, stereo? 2 : 0);
- sb_cmd2(sb, 0x48, l);
- sb_cmd(sb, i1);
- }
- sb->bd_flags |= BD_F_DMARUN << b16;
- return 0;
-}
-
-static int
-sb_stop(struct sb_chinfo *ch)
-{
- struct sb_info *sb = ch->parent;
- int play = (ch->dir == PCMDIR_PLAY)? 1 : 0;
- int b16 = (ch->fmt & AFMT_S16_LE)? 1 : 0;
-
- if (sb->bd_flags & BD_F_HISPEED)
- sb_reset_dsp(sb);
- else {
- sb_cmd(sb, b16? DSP_CMD_DMAPAUSE_16 : DSP_CMD_DMAPAUSE_8);
- /*
- * The above seems to have the undocumented side effect of
- * blocking the other side as well. If the other
- * channel was active (SB16) I have to re-enable it :(
- */
- if (sb->bd_flags & (BD_F_DMARUN << (1 - b16)))
- sb_cmd(sb, b16? 0xd4 : 0xd6 );
- }
- if (play)
- sb_cmd(sb, DSP_CMD_SPKOFF); /* speaker off */
- sb->bd_flags &= ~(BD_F_DMARUN << b16);
- return 0;
-}
-
-/* channel interface */
-static void *
-sbchan_init(void *devinfo, snd_dbuf *b, pcm_channel *c, int dir)
-{
- struct sb_info *sb = devinfo;
- struct sb_chinfo *ch = (dir == PCMDIR_PLAY)? &sb->pch : &sb->rch;
- int dch, dl, dh;
-
- ch->parent = sb;
- ch->channel = c;
- ch->buffer = b;
- ch->buffer->bufsize = DSP_BUFFSIZE;
- if (chn_allocbuf(ch->buffer, sb->parent_dmat) == -1)
- return NULL;
- dch = (dir == PCMDIR_PLAY)? 1 : 0;
- if (sb->bd_flags & BD_F_SB16X)
- dch = !dch;
- dl = rman_get_start(sb->drq1);
- dh = sb->drq2? rman_get_start(sb->drq2) : dl;
- ch->buffer->chan = dch? dh : dl;
- return ch;
-}
-
-static int
-sbchan_setdir(void *data, int dir)
-{
- struct sb_chinfo *ch = data;
-
- ch->dir = dir;
- return 0;
-}
-
-static int
-sbchan_setformat(void *data, u_int32_t format)
-{
- struct sb_chinfo *ch = data;
-
- ch->fmt = format;
- return 0;
-}
-
-static int
-sbchan_setspeed(void *data, u_int32_t speed)
-{
- struct sb_chinfo *ch = data;
-
- ch->spd = speed;
- return sb_speed(ch);
-}
-
-static int
-sbchan_setblocksize(void *data, u_int32_t blocksize)
-{
- return blocksize;
-}
-
-static int
-sbchan_trigger(void *data, int go)
-{
- struct sb_chinfo *ch = data;
-
- if (go == PCMTRIG_EMLDMAWR)
- return 0;
-
- buf_isadma(ch->buffer, go);
- if (go == PCMTRIG_START)
- sb_start(ch);
- else
- sb_stop(ch);
- return 0;
-}
-
-static int
-sbchan_getptr(void *data)
-{
- struct sb_chinfo *ch = data;
-
- return buf_isadmaptr(ch->buffer);
-}
-
-static pcmchan_caps *
-sbchan_getcaps(void *data)
-{
- struct sb_chinfo *ch = data;
- int p = (ch->dir == PCMDIR_PLAY)? 1 : 0;
-
- if (ch->parent->bd_id < 0x300)
- return p? &sb_playcaps : &sb_reccaps;
- else if (ch->parent->bd_id < 0x400)
- return p? &sbpro_playcaps : &sbpro_reccaps;
- else if (ch->parent->bd_flags & BD_F_SB16X)
- return &sb16x_caps;
- else
- return (ch->buffer->chan >= 4)? &sb16_hcaps : &sb16_lcaps;
-}
-
-/* utility functions for ESS */
-static int
-ess_format(struct sb_chinfo *ch, u_int32_t format)
-{
- struct sb_info *sb = ch->parent;
- int play = (ch->dir == PCMDIR_PLAY)? 1 : 0;
- int b16 = (format & AFMT_S16_LE)? 1 : 0;
- int stereo = (format & AFMT_STEREO)? 1 : 0;
- u_char c;
-
- ch->fmt = format;
- sb_reset_dsp(sb);
- /* auto-init DMA mode */
- ess_write(sb, 0xb8, play ? 0x04 : 0x0e);
- /* mono/stereo */
- c = (ess_read(sb, 0xa8) & ~0x03) | 1;
- if (!stereo)
- c++;
- ess_write(sb, 0xa8, c);
- /* demand mode, 4 bytes/xfer */
- ess_write(sb, 0xb9, 2);
- /* setup dac/adc */
- if (play)
- ess_write(sb, 0xb6, b16? 0x00 : 0x80);
- ess_write(sb, 0xb7, 0x51 | (b16? 0x20 : 0x00));
- ess_write(sb, 0xb7, 0x98 + (b16? 0x24 : 0x00) + (stereo? 0x00 : 0x38));
- /* irq/drq control */
- ess_write(sb, 0xb1, (ess_read(sb, 0xb1) & 0x0f) | 0x50);
- ess_write(sb, 0xb2, (ess_read(sb, 0xb2) & 0x0f) | 0x50);
- return 0;
-}
-
-static int
-ess_speed(struct sb_chinfo *ch, int speed)
-{
- struct sb_info *sb = ch->parent;
- int t;
-
- RANGE (speed, 5000, 49000);
- if (speed > 22000) {
- t = (795500 + speed / 2) / speed;
- speed = (795500 + t / 2) / t;
- t = (256 - t ) | 0x80;
- } else {
- t = (397700 + speed / 2) / speed;
- speed = (397700 + t / 2) / t;
- t = 128 - t;
- }
- ess_write(sb, 0xa1, t); /* set time constant */
-#if 0
- d->play_speed = d->rec_speed = speed;
- speed = (speed * 9 ) / 20;
-#endif
- t = 256 - 7160000 / ((speed * 9 / 20) * 82);
- ess_write(sb, 0xa2, t);
- return speed;
-}
-
-static int
-ess_start(struct sb_chinfo *ch)
-{
- struct sb_info *sb = ch->parent;
- int play = (ch->dir == PCMDIR_PLAY)? 1 : 0;
- short c = - ch->buffer->dl;
- u_char c1;
-
- /*
- * clear bit 0 of register B8h
- */
-#if 1
- c1 = play ? 0x04 : 0x0e;
- ess_write(sb, 0xb8, c1++);
-#else
- c1 = ess_read(sb, 0xb8) & 0xfe;
- ess_write(sb, 0xb8, c1++);
-#endif
- /*
- * update ESS Transfer Count Register
- */
- ess_write(sb, 0xa4, (u_char)((u_short)c & 0xff));
- ess_write(sb, 0xa5, (u_char)(((u_short)c >> 8) & 0xff));
- /*
- * set bit 0 of register B8h
- */
- ess_write(sb, 0xb8, c1);
- if (play)
- sb_cmd(sb, DSP_CMD_SPKON);
- return 0;
-}
-
-static int
-ess_stop(struct sb_chinfo *ch)
-{
- struct sb_info *sb = ch->parent;
- /*
- * no need to send a stop command if the DMA has already stopped.
- */
- if (ch->buffer->dl > 0) {
- sb_cmd(sb, DSP_CMD_DMAPAUSE_8); /* pause dma. */
- }
- return 0;
-}
-
-static int
-ess_abort(struct sb_chinfo *ch)
-{
- struct sb_info *sb = ch->parent;
- int play = (ch->dir == PCMDIR_PLAY)? 1 : 0;
-
- if (play)
- sb_cmd(sb, DSP_CMD_SPKOFF); /* speaker off */
- sb_reset_dsp(sb);
- ess_format(ch, ch->fmt);
- ess_speed(ch, ch->channel->speed);
- return 0;
-}
-
-/* channel interface for ESS18xx */
-static void *
-esschan_init(void *devinfo, snd_dbuf *b, pcm_channel *c, int dir)
-{
- struct sb_info *sb = devinfo;
- struct sb_chinfo *ch = (dir == PCMDIR_PLAY)? &sb->pch : &sb->rch;
-
- ch->parent = sb;
- ch->channel = c;
- ch->buffer = b;
- ch->buffer->bufsize = ESS_BUFFSIZE;
- if (chn_allocbuf(ch->buffer, sb->parent_dmat) == -1)
- return NULL;
- ch->buffer->chan = rman_get_start(sb->drq1);
- return ch;
-}
-
-static int
-esschan_setdir(void *data, int dir)
-{
- struct sb_chinfo *ch = data;
-
- ch->dir = dir;
- return 0;
-}
-
-static int
-esschan_setformat(void *data, u_int32_t format)
-{
- struct sb_chinfo *ch = data;
-
- ess_format(ch, format);
- return 0;
-}
-
-static int
-esschan_setspeed(void *data, u_int32_t speed)
-{
- struct sb_chinfo *ch = data;
-
- return ess_speed(ch, speed);
-}
-
-static int
-esschan_setblocksize(void *data, u_int32_t blocksize)
-{
- return blocksize;
-}
-
-static int
-esschan_trigger(void *data, int go)
-{
- struct sb_chinfo *ch = data;
-
- if (go == PCMTRIG_EMLDMAWR)
- return 0;
- switch (go) {
- case PCMTRIG_START:
- if (!ch->ess_dma_started)
- buf_isadma(ch->buffer, go);
- ch->ess_dma_started = 1;
- ess_start(ch);
- break;
- case PCMTRIG_STOP:
- if (ch->buffer->dl >= 0) {
- buf_isadma(ch->buffer, go);
- ch->ess_dma_started = 0;
- ess_stop(ch);
- }
- break;
- case PCMTRIG_ABORT:
- default:
- ch->ess_dma_started = 0;
- ess_abort(ch);
- buf_isadma(ch->buffer, go);
- break;
- }
- return 0;
-}
-
-static int
-esschan_getptr(void *data)
-{
- struct sb_chinfo *ch = data;
-
- return buf_isadmaptr(ch->buffer);
-}
-
-static pcmchan_caps *
-esschan_getcaps(void *data)
-{
- struct sb_chinfo *ch = data;
-
- return (ch->dir == PCMDIR_PLAY)? &ess_playcaps : &ess_reccaps;
-}
-
-/************************************************************/
-
-static int
-sbmix_init(snd_mixer *m)
-{
- struct sb_info *sb = mix_getdevinfo(m);
-
- switch (sb->bd_flags & BD_F_MIX_MASK) {
- case BD_F_MIX_CT1345: /* SB 3.0 has 1345 mixer */
- mix_setdevs(m, SBPRO_MIXER_DEVICES);
- mix_setrecdevs(m, SBPRO_RECORDING_DEVICES);
- sb_setmixer(sb, 0, 1); /* reset mixer */
- if (!(sb->bd_flags & BD_F_ESS))
- sb_setmixer(sb, MIC_VOL, 0x6); /* mic volume max */
- sb_setmixer(sb, RECORD_SRC, 0x0); /* mic source */
- sb_setmixer(sb, FM_VOL, 0x0); /* no midi */
- break;
-
- case BD_F_MIX_CT1745: /* SB16 mixer ... */
- mix_setdevs(m, SB16_MIXER_DEVICES);
- mix_setrecdevs(m, SB16_RECORDING_DEVICES);
- sb_setmixer(sb, 0x3c, 0x1f); /* make all output active */
- sb_setmixer(sb, 0x3d, 0); /* make all inputs-l off */
- sb_setmixer(sb, 0x3e, 0); /* make all inputs-r off */
- }
- return 0;
-}
-
-static int
-sbmix_set(snd_mixer *m, unsigned dev, unsigned left, unsigned right)
-{
- struct sb_info *sb = mix_getdevinfo(m);
- int regoffs;
- u_char val;
- mixer_tab *iomap;
-
- switch (sb->bd_flags & BD_F_MIX_MASK) {
- case BD_F_MIX_CT1345:
- if (sb->bd_flags & BD_F_ESS)
- iomap = &ess_mix;
- else
- iomap = &sbpro_mix;
- break;
-
- case BD_F_MIX_CT1745:
- iomap = &sb16_mix;
- break;
-
- default:
- return -1;
- }
-
- /* Change left channel */
- regoffs = (*iomap)[dev][LEFT_CHN].regno;
- if (regoffs != 0) {
- val = sb_getmixer(sb, regoffs);
- change_bits(iomap, &val, dev, LEFT_CHN, left);
- sb_setmixer(sb, regoffs, val);
- }
-
- /* Change right channel */
- regoffs = (*iomap)[dev][RIGHT_CHN].regno;
- if (regoffs != 0) {
- val = sb_getmixer(sb, regoffs); /* Read the new one */
- change_bits(iomap, &val, dev, RIGHT_CHN, right);
- sb_setmixer(sb, regoffs, val);
- } else
- right = left;
-
- return left | (right << 8);
-}
-
-static int
-sbmix_setrecsrc(snd_mixer *m, u_int32_t src)
-{
- struct sb_info *sb = mix_getdevinfo(m);
- u_char recdev;
-
- switch (sb->bd_flags & BD_F_MIX_MASK) {
- case BD_F_MIX_CT1345:
- if (src == SOUND_MASK_LINE)
- recdev = 0x06;
- else if (src == SOUND_MASK_CD)
- recdev = 0x02;
- else { /* default: mic */
- src = SOUND_MASK_MIC;
- recdev = 0;
- }
- sb_setmixer(sb, RECORD_SRC, recdev |
- (sb_getmixer(sb, RECORD_SRC) & ~0x07));
- break;
-
- case BD_F_MIX_CT1745: /* sb16 */
- recdev = 0;
- if (src & SOUND_MASK_MIC)
- recdev |= 0x01; /* mono mic */
- if (src & SOUND_MASK_CD)
- recdev |= 0x06; /* l+r cd */
- if (src & SOUND_MASK_LINE)
- recdev |= 0x18; /* l+r line */
- if (src & SOUND_MASK_SYNTH)
- recdev |= 0x60; /* l+r midi */
- sb_setmixer(sb, SB16_IMASK_L, recdev);
- sb_setmixer(sb, SB16_IMASK_R, recdev);
- /*
- * since the same volume controls apply to the input and
- * output sections, the best approach to have a consistent
- * behaviour among cards would be to disable the output path
- * on devices which are used to record.
- * However, since users like to have feedback, we only disable
- * the mic -- permanently.
- */
- sb_setmixer(sb, SB16_OMASK, 0x1f & ~1);
- break;
- }
- return src;
-}
-
-static int
-sbsbc_probe(device_t dev)
-{
- char buf[64];
- uintptr_t func, ver, r, f;
-
- /* The parent device has already been probed. */
- r = BUS_READ_IVAR(device_get_parent(dev), dev, 0, &func);
- if (func != SCF_PCM)
- return (ENXIO);
-
- r = BUS_READ_IVAR(device_get_parent(dev), dev, 1, &ver);
- f = (ver & 0xffff0000) >> 16;
- ver &= 0x0000ffff;
- snprintf(buf, sizeof buf, "SB DSP %d.%02d%s%s", (int) ver >> 8, (int) ver & 0xff,
- (f & BD_F_ESS)? " (ESS mode)" : "",
- (f & BD_F_SB16X)? " (ViBRA16X)" : "");
- device_set_desc_copy(dev, buf);
-
- return 0;
-}
-
-static int
-sbsbc_attach(device_t dev)
-{
- struct sb_info *sb;
- uintptr_t ver;
-
- sb = (struct sb_info *)malloc(sizeof *sb, M_DEVBUF, M_NOWAIT);
- if (!sb)
- return ENXIO;
- bzero(sb, sizeof *sb);
-
- BUS_READ_IVAR(device_get_parent(dev), dev, 1, &ver);
- sb->bd_id = ver & 0x0000ffff;
- sb->bd_flags = (ver & 0xffff0000) >> 16;
-
- return sb_doattach(dev, sb);
-}
-
-static device_method_t sbsbc_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, sbsbc_probe),
- DEVMETHOD(device_attach, sbsbc_attach),
-
- { 0, 0 }
-};
-
-static driver_t sbsbc_driver = {
- "pcm",
- sbsbc_methods,
- sizeof(snddev_info),
-};
-
-DRIVER_MODULE(sbsbc, sbc, sbsbc_driver, pcm_devclass, 0, 0);
-
-
-
diff --git a/sys/dev/sound/isa/sb8.c b/sys/dev/sound/isa/sb8.c
deleted file mode 100644
index 216198272a3c..000000000000
--- a/sys/dev/sound/isa/sb8.c
+++ /dev/null
@@ -1,1204 +0,0 @@
-/*
- * Copyright (c) 1999 Cameron Grant <gandalf@vilnya.demon.co.uk>
- * Copyright 1997,1998 Luigi Rizzo.
- *
- * Derived from files in the Voxware 3.5 distribution,
- * Copyright by Hannu Savolainen 1994, under the same copyright
- * conditions.
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include <dev/sound/pcm/sound.h>
-
-#include "sbc.h"
-
-#define __SB_MIXER_C__ /* XXX warning... */
-#include <dev/sound/isa/sb.h>
-#include <dev/sound/chip.h>
-
-#define ESS_BUFFSIZE (65536 - 256)
-#define PLAIN_SB16(x) ((((x)->bd_flags) & (BD_F_SB16|BD_F_SB16X)) == BD_F_SB16)
-
-/* channel interface */
-static void *sbchan_init(void *devinfo, snd_dbuf *b, pcm_channel *c, int dir);
-static int sbchan_setdir(void *data, int dir);
-static int sbchan_setformat(void *data, u_int32_t format);
-static int sbchan_setspeed(void *data, u_int32_t speed);
-static int sbchan_setblocksize(void *data, u_int32_t blocksize);
-static int sbchan_trigger(void *data, int go);
-static int sbchan_getptr(void *data);
-static pcmchan_caps *sbchan_getcaps(void *data);
-
-/* channel interface for ESS */
-static void *esschan_init(void *devinfo, snd_dbuf *b, pcm_channel *c, int dir);
-static int esschan_setdir(void *data, int dir);
-static int esschan_setformat(void *data, u_int32_t format);
-static int esschan_setspeed(void *data, u_int32_t speed);
-static int esschan_setblocksize(void *data, u_int32_t blocksize);
-static int esschan_trigger(void *data, int go);
-static int esschan_getptr(void *data);
-static pcmchan_caps *esschan_getcaps(void *data);
-
-static pcmchan_caps sb_playcaps = {
- 4000, 22050,
- AFMT_U8,
- AFMT_U8
-};
-
-static pcmchan_caps sb_reccaps = {
- 4000, 13000,
- AFMT_U8,
- AFMT_U8
-};
-
-static pcmchan_caps sbpro_playcaps = {
- 4000, 45000,
- AFMT_STEREO | AFMT_U8,
- AFMT_STEREO | AFMT_U8
-};
-
-static pcmchan_caps sbpro_reccaps = {
- 4000, 15000,
- AFMT_STEREO | AFMT_U8,
- AFMT_STEREO | AFMT_U8
-};
-
-static pcmchan_caps sb16_hcaps = {
- 5000, 45000,
- AFMT_STEREO | AFMT_S16_LE,
- AFMT_STEREO | AFMT_S16_LE
-};
-
-static pcmchan_caps sb16_lcaps = {
- 5000, 45000,
- AFMT_STEREO | AFMT_U8,
- AFMT_STEREO | AFMT_U8
-};
-
-static pcmchan_caps sb16x_caps = {
- 5000, 49000,
- AFMT_STEREO | AFMT_U8 | AFMT_S16_LE,
- AFMT_STEREO | AFMT_S16_LE
-};
-
-static pcmchan_caps ess_playcaps = {
- 5000, 49000,
- AFMT_STEREO | AFMT_U8 | AFMT_S16_LE,
- AFMT_STEREO | AFMT_S16_LE
-};
-
-static pcmchan_caps ess_reccaps = {
- 5000, 49000,
- AFMT_STEREO | AFMT_U8 | AFMT_S16_LE,
- AFMT_STEREO | AFMT_S16_LE
-};
-
-static pcm_channel sb_chantemplate = {
- sbchan_init,
- sbchan_setdir,
- sbchan_setformat,
- sbchan_setspeed,
- sbchan_setblocksize,
- sbchan_trigger,
- sbchan_getptr,
- sbchan_getcaps,
-};
-
-static pcm_channel ess_chantemplate = {
- esschan_init,
- esschan_setdir,
- esschan_setformat,
- esschan_setspeed,
- esschan_setblocksize,
- esschan_trigger,
- esschan_getptr,
- esschan_getcaps,
-};
-
-struct sb_info;
-
-struct sb_chinfo {
- struct sb_info *parent;
- pcm_channel *channel;
- snd_dbuf *buffer;
- int dir;
- u_int32_t fmt, spd;
- int ess_dma_started;
-};
-
-struct sb_info {
- struct resource *io_base; /* I/O address for the board */
- struct resource *irq;
- struct resource *drq1;
- struct resource *drq2;
- bus_dma_tag_t parent_dmat;
-
- int bd_id;
- u_long bd_flags; /* board-specific flags */
- struct sb_chinfo pch, rch;
-};
-
-static int sb_rd(struct sb_info *sb, int reg);
-static void sb_wr(struct sb_info *sb, int reg, u_int8_t val);
-static int sb_dspready(struct sb_info *sb);
-static int sb_cmd(struct sb_info *sb, u_char val);
-static int sb_cmd1(struct sb_info *sb, u_char cmd, int val);
-static int sb_cmd2(struct sb_info *sb, u_char cmd, int val);
-static u_int sb_get_byte(struct sb_info *sb);
-static void sb_setmixer(struct sb_info *sb, u_int port, u_int value);
-static int sb_getmixer(struct sb_info *sb, u_int port);
-static int sb_reset_dsp(struct sb_info *sb);
-
-static void sb_intr(void *arg);
-static int sb_speed(struct sb_chinfo *ch);
-static int sb_start(struct sb_chinfo *ch);
-static int sb_stop(struct sb_chinfo *ch);
-
-static int ess_write(struct sb_info *sb, u_char reg, int val);
-static int ess_read(struct sb_info *sb, u_char reg);
-static void ess_intr(void *arg);
-static int ess_format(struct sb_chinfo *ch, u_int32_t format);
-static int ess_speed(struct sb_chinfo *ch, int speed);
-static int ess_start(struct sb_chinfo *ch);
-static int ess_stop(struct sb_chinfo *ch);
-static int ess_abort(struct sb_chinfo *ch);
-
-static int sbmix_init(snd_mixer *m);
-static int sbmix_set(snd_mixer *m, unsigned dev, unsigned left, unsigned right);
-static int sbmix_setrecsrc(snd_mixer *m, u_int32_t src);
-
-static snd_mixer sb_mixer = {
- "SoundBlaster mixer",
- sbmix_init,
- sbmix_set,
- sbmix_setrecsrc,
-};
-
-static devclass_t pcm_devclass;
-
-/*
- * Common code for the midi and pcm functions
- *
- * sb_cmd write a single byte to the CMD port.
- * sb_cmd1 write a CMD + 1 byte arg
- * sb_cmd2 write a CMD + 2 byte arg
- * sb_get_byte returns a single byte from the DSP data port
- *
- * ess_write is actually sb_cmd1
- * ess_read access ext. regs via sb_cmd(0xc0, reg) followed by sb_get_byte
- */
-
-static int
-port_rd(struct resource *port, int off)
-{
- return bus_space_read_1(rman_get_bustag(port),
- rman_get_bushandle(port),
- off);
-}
-
-static void
-port_wr(struct resource *port, int off, u_int8_t data)
-{
- return bus_space_write_1(rman_get_bustag(port),
- rman_get_bushandle(port),
- off, data);
-}
-
-static int
-sb_rd(struct sb_info *sb, int reg)
-{
- return port_rd(sb->io_base, reg);
-}
-
-static void
-sb_wr(struct sb_info *sb, int reg, u_int8_t val)
-{
- port_wr(sb->io_base, reg, val);
-}
-
-static int
-sb_dspready(struct sb_info *sb)
-{
- return ((sb_rd(sb, SBDSP_STATUS) & 0x80) == 0);
-}
-
-static int
-sb_dspwr(struct sb_info *sb, u_char val)
-{
- int i;
-
- for (i = 0; i < 1000; i++) {
- if (sb_dspready(sb)) {
- sb_wr(sb, SBDSP_CMD, val);
- return 1;
- }
- if (i > 10) DELAY((i > 100)? 1000 : 10);
- }
- printf("sb_dspwr(0x%02x) timed out.\n", val);
- return 0;
-}
-
-static int
-sb_cmd(struct sb_info *sb, u_char val)
-{
-#if 0
- printf("sb_cmd: %x\n", val);
-#endif
- return sb_dspwr(sb, val);
-}
-
-static int
-sb_cmd1(struct sb_info *sb, u_char cmd, int val)
-{
-#if 0
- printf("sb_cmd1: %x, %x\n", cmd, val);
-#endif
- if (sb_dspwr(sb, cmd)) {
- return sb_dspwr(sb, val & 0xff);
- } else return 0;
-}
-
-static int
-sb_cmd2(struct sb_info *sb, u_char cmd, int val)
-{
-#if 0
- printf("sb_cmd2: %x, %x\n", cmd, val);
-#endif
- if (sb_dspwr(sb, cmd)) {
- return sb_dspwr(sb, val & 0xff) &&
- sb_dspwr(sb, (val >> 8) & 0xff);
- } else return 0;
-}
-
-/*
- * in the SB, there is a set of indirect "mixer" registers with
- * address at offset 4, data at offset 5
- */
-static void
-sb_setmixer(struct sb_info *sb, u_int port, u_int value)
-{
- u_long flags;
-
- flags = spltty();
- sb_wr(sb, SB_MIX_ADDR, (u_char) (port & 0xff)); /* Select register */
- DELAY(10);
- sb_wr(sb, SB_MIX_DATA, (u_char) (value & 0xff));
- DELAY(10);
- splx(flags);
-}
-
-static int
-sb_getmixer(struct sb_info *sb, u_int port)
-{
- int val;
- u_long flags;
-
- flags = spltty();
- sb_wr(sb, SB_MIX_ADDR, (u_char) (port & 0xff)); /* Select register */
- DELAY(10);
- val = sb_rd(sb, SB_MIX_DATA);
- DELAY(10);
- splx(flags);
-
- return val;
-}
-
-static u_int
-sb_get_byte(struct sb_info *sb)
-{
- int i;
-
- for (i = 1000; i > 0; i--) {
- if (sb_rd(sb, DSP_DATA_AVAIL) & 0x80)
- return sb_rd(sb, DSP_READ);
- else
- DELAY(20);
- }
- return 0xffff;
-}
-
-static int
-ess_write(struct sb_info *sb, u_char reg, int val)
-{
- return sb_cmd1(sb, reg, val);
-}
-
-static int
-ess_read(struct sb_info *sb, u_char reg)
-{
- return (sb_cmd(sb, 0xc0) && sb_cmd(sb, reg))? sb_get_byte(sb) : 0xffff;
-}
-
-static int
-sb_reset_dsp(struct sb_info *sb)
-{
- sb_wr(sb, SBDSP_RST, 3);
- DELAY(100);
- sb_wr(sb, SBDSP_RST, 0);
- if (sb_get_byte(sb) != 0xAA) {
- DEB(printf("sb_reset_dsp 0x%lx failed\n",
- rman_get_start(d->io_base)));
- return ENXIO; /* Sorry */
- }
- if (sb->bd_flags & BD_F_ESS)
- sb_cmd(sb, 0xc6);
- return 0;
-}
-
-static void
-sb_release_resources(struct sb_info *sb, device_t dev)
-{
- /* should we bus_teardown_intr here? */
- if (sb->irq) {
- bus_release_resource(dev, SYS_RES_IRQ, 0, sb->irq);
- sb->irq = 0;
- }
- if (sb->drq1) {
- bus_release_resource(dev, SYS_RES_DRQ, 0, sb->drq1);
- sb->drq1 = 0;
- }
- if (sb->drq2) {
- bus_release_resource(dev, SYS_RES_DRQ, 1, sb->drq2);
- sb->drq2 = 0;
- }
- if (sb->io_base) {
- bus_release_resource(dev, SYS_RES_IOPORT, 0, sb->io_base);
- sb->io_base = 0;
- }
- free(sb, M_DEVBUF);
-}
-
-static int
-sb_alloc_resources(struct sb_info *sb, device_t dev)
-{
- int rid;
-
- rid = 0;
- if (!sb->io_base)
- sb->io_base = bus_alloc_resource(dev, SYS_RES_IOPORT,
- &rid, 0, ~0, 1,
- RF_ACTIVE);
- rid = 0;
- if (!sb->irq)
- sb->irq = bus_alloc_resource(dev, SYS_RES_IRQ,
- &rid, 0, ~0, 1,
- RF_ACTIVE);
- rid = 0;
- if (!sb->drq1)
- sb->drq1 = bus_alloc_resource(dev, SYS_RES_DRQ,
- &rid, 0, ~0, 1,
- RF_ACTIVE);
- rid = 1;
- if (!sb->drq2 && !(sb->bd_flags & BD_F_ESS))
- sb->drq2 = bus_alloc_resource(dev, SYS_RES_DRQ,
- &rid, 0, ~0, 1,
- RF_ACTIVE);
-
- if (sb->io_base && sb->drq1 && sb->irq) {
- int bs = (sb->bd_flags & BD_F_ESS)? ESS_BUFFSIZE : DSP_BUFFSIZE;
-
- isa_dma_acquire(rman_get_start(sb->drq1));
- isa_dmainit(rman_get_start(sb->drq1), bs);
-
- if (sb->drq2) {
- isa_dma_acquire(rman_get_start(sb->drq2));
- isa_dmainit(rman_get_start(sb->drq2), bs);
- }
-
- return 0;
- } else return ENXIO;
-}
-
-static void
-sb16_swap(void *v, int dir)
-{
- struct sb_info *sb = v;
- int pb = sb->pch.buffer->dl;
- int rb = sb->rch.buffer->dl;
- int pc = sb->pch.buffer->chan;
- int rc = sb->rch.buffer->chan;
- int swp = 0;
-
- if (!pb && !rb) {
- if (dir == PCMDIR_PLAY && pc < 4)
- swp = 1;
- else
- if (dir == PCMDIR_REC && rc < 4)
- swp = 1;
- if (sb->bd_flags & BD_F_SB16X)
- swp = !swp;
- if (swp) {
- int t;
-
- t = sb->pch.buffer->chan;
- sb->pch.buffer->chan = sb->rch.buffer->chan;
- sb->rch.buffer->chan = t;
- sb->pch.buffer->dir = B_WRITE;
- sb->rch.buffer->dir = B_READ;
- }
- }
-}
-
-static int
-sb_doattach(device_t dev, struct sb_info *sb)
-{
- snddev_info *d = device_get_softc(dev);
- void *ih;
- char status[SND_STATUSLEN];
- int bs = (sb->bd_flags & BD_F_ESS)? ESS_BUFFSIZE : DSP_BUFFSIZE;
-
- if (sb_alloc_resources(sb, dev))
- goto no;
- if (sb_reset_dsp(sb))
- goto no;
- mixer_init(d, &sb_mixer, sb);
-
- if (sb->bd_flags & BD_F_ESS)
- bus_setup_intr(dev, sb->irq, INTR_TYPE_TTY, ess_intr, sb, &ih);
- else
- bus_setup_intr(dev, sb->irq, INTR_TYPE_TTY, sb_intr, sb, &ih);
- if ((sb->bd_flags & BD_F_SB16) && !(sb->bd_flags & BD_F_SB16X))
- pcm_setswap(dev, sb16_swap);
- if (!sb->drq2)
- pcm_setflags(dev, pcm_getflags(dev) | SD_F_SIMPLEX);
-
- if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0,
- /*lowaddr*/BUS_SPACE_MAXADDR_24BIT,
- /*highaddr*/BUS_SPACE_MAXADDR,
- /*filter*/NULL, /*filterarg*/NULL,
- /*maxsize*/bs, /*nsegments*/1,
- /*maxsegz*/0x3ffff,
- /*flags*/0, &sb->parent_dmat) != 0) {
- device_printf(dev, "unable to create dma tag\n");
- goto no;
- }
-
- snprintf(status, SND_STATUSLEN, "at io 0x%lx irq %ld drq %ld",
- rman_get_start(sb->io_base), rman_get_start(sb->irq),
- rman_get_start(sb->drq1));
- if (sb->drq2)
- snprintf(status + strlen(status), SND_STATUSLEN - strlen(status),
- ":%ld", rman_get_start(sb->drq2));
-
- if (pcm_register(dev, sb, 1, 1))
- goto no;
- if (sb->bd_flags & BD_F_ESS) {
- pcm_addchan(dev, PCMDIR_REC, &ess_chantemplate, sb);
- pcm_addchan(dev, PCMDIR_PLAY, &ess_chantemplate, sb);
- } else {
- pcm_addchan(dev, PCMDIR_REC, &sb_chantemplate, sb);
- pcm_addchan(dev, PCMDIR_PLAY, &sb_chantemplate, sb);
- }
- pcm_setstatus(dev, status);
-
- return 0;
-
-no:
- sb_release_resources(sb, dev);
- return ENXIO;
-}
-
-static void
-sb_intr(void *arg)
-{
- struct sb_info *sb = (struct sb_info *)arg;
- int reason = 3, c;
-
- /*
- * SB < 4.0 is half duplex and has only 1 bit for int source,
- * so we fake it. SB 4.x (SB16) has the int source in a separate
- * register.
- * The Vibra16X has separate flags for 8 and 16 bit transfers, but
- * I have no idea how to tell capture from playback interrupts...
- */
- if (sb->bd_flags & BD_F_SB16) {
- c = sb_getmixer(sb, IRQ_STAT);
- /* this tells us if the source is 8-bit or 16-bit dma. We
- * have to check the io channel to map it to read or write...
- */
- reason = 0;
- if (c & 1) { /* 8-bit dma */
- if (sb->pch.fmt & AFMT_U8)
- reason |= 1;
- if (sb->rch.fmt & AFMT_U8)
- reason |= 2;
- }
- if (c & 2) { /* 16-bit dma */
- if (sb->pch.fmt & AFMT_S16_LE)
- reason |= 1;
- if (sb->rch.fmt & AFMT_S16_LE)
- reason |= 2;
- }
- } else c = 1;
-#if 0
- printf("sb_intr: reason=%d c=0x%x\n", reason, c);
-#endif
- if ((reason & 1) && (sb->pch.buffer->dl > 0))
- chn_intr(sb->pch.channel);
- if ((reason & 2) && (sb->rch.buffer->dl > 0))
- chn_intr(sb->rch.channel);
- if (c & 1)
- sb_rd(sb, DSP_DATA_AVAIL); /* 8-bit int ack */
- if (c & 2)
- sb_rd(sb, DSP_DATA_AVL16); /* 16-bit int ack */
-}
-
-static void
-ess_intr(void *arg)
-{
- struct sb_info *sb = (struct sb_info *)arg;
-
- sb_rd(sb, DSP_DATA_AVAIL); /* int ack */
-#ifdef notyet
- /*
- * XXX
- * for full-duplex mode:
- * should read port 0x6 to identify where interrupt came from.
- */
-#endif
- /*
- * We are transferring data in DSP normal mode,
- * so clear the dl to indicate the DMA is stopped.
- */
- if (sb->pch.buffer->dl > 0)
- chn_intr(sb->pch.channel);
- if (sb->rch.buffer->dl > 0)
- chn_intr(sb->rch.channel);
-}
-
-static int
-sb_speed(struct sb_chinfo *ch)
-{
- struct sb_info *sb = ch->parent;
- int play = (ch->dir == PCMDIR_PLAY)? 1 : 0;
- int stereo = (ch->fmt & AFMT_STEREO)? 1 : 0;
- int speed = ch->spd;
-
- if (sb->bd_flags & BD_F_SB16) {
- RANGE(speed, 5000, 45000);
- sb_cmd(sb, 0x42 - play);
- sb_cmd(sb, speed >> 8);
- sb_cmd(sb, speed & 0xff);
- } else {
- u_char tconst;
- int max_speed = 45000, tmp;
- u_long flags;
-
- /* here enforce speed limitations - max 22050 on sb 1.x*/
- if (sb->bd_id <= 0x200)
- max_speed = 22050;
-
- /*
- * SB models earlier than SB Pro have low limit for the
- * input rate. Note that this is only for input, but since
- * we do not support separate values for rec & play....
- */
- if (!play) {
- if (sb->bd_id <= 0x200)
- max_speed = 13000;
- else
- if (sb->bd_id < 0x300)
- max_speed = 15000;
- }
- RANGE(speed, 4000, max_speed);
- if (stereo)
- speed <<= 1;
-
- /*
- * Now the speed should be valid. Compute the value to be
- * programmed into the board.
- */
- if (speed > 22050) { /* High speed mode on 2.01/3.xx */
- tconst = (u_char)
- ((65536 - ((256000000 + speed / 2) / speed))
- >> 8);
- sb->bd_flags |= BD_F_HISPEED;
- tmp = 65536 - (tconst << 8);
- speed = (256000000 + tmp / 2) / tmp;
- } else {
- sb->bd_flags &= ~BD_F_HISPEED;
- tconst = (256 - ((1000000 + speed / 2) / speed)) & 0xff;
- tmp = 256 - tconst;
- speed = (1000000 + tmp / 2) / tmp;
- }
- flags = spltty();
- sb_cmd1(sb, 0x40, tconst); /* set time constant */
- splx(flags);
- if (stereo)
- speed >>= 1;
- }
- ch->spd = speed;
- return speed;
-}
-
-static int
-sb_start(struct sb_chinfo *ch)
-{
- struct sb_info *sb = ch->parent;
- int play = (ch->dir == PCMDIR_PLAY)? 1 : 0;
- int b16 = (ch->fmt & AFMT_S16_LE)? 1 : 0;
- int stereo = (ch->fmt & AFMT_STEREO)? 1 : 0;
- int l = ch->buffer->dl;
- int dh = ch->buffer->chan > 3;
- u_char i1, i2;
-
- if (b16 || dh)
- l >>= 1;
- l--;
-
- if (play)
- sb_cmd(sb, DSP_CMD_SPKON);
-
- if (sb->bd_flags & BD_F_SB16) {
- i1 = DSP_F16_AUTO | DSP_F16_FIFO_ON;
- i1 |= play? DSP_F16_DAC : DSP_F16_ADC;
- i1 |= (b16 || dh)? DSP_DMA16 : DSP_DMA8;
- i2 = (stereo? DSP_F16_STEREO : 0) | (b16? DSP_F16_SIGNED : 0);
- sb_cmd(sb, i1);
- sb_cmd2(sb, i2, l);
- } else {
- if (sb->bd_flags & BD_F_HISPEED)
- i1 = play? 0x90 : 0x98;
- else
- i1 = play? 0x1c : 0x2c;
- sb_setmixer(sb, 0x0e, stereo? 2 : 0);
- sb_cmd2(sb, 0x48, l);
- sb_cmd(sb, i1);
- }
- sb->bd_flags |= BD_F_DMARUN << b16;
- return 0;
-}
-
-static int
-sb_stop(struct sb_chinfo *ch)
-{
- struct sb_info *sb = ch->parent;
- int play = (ch->dir == PCMDIR_PLAY)? 1 : 0;
- int b16 = (ch->fmt & AFMT_S16_LE)? 1 : 0;
-
- if (sb->bd_flags & BD_F_HISPEED)
- sb_reset_dsp(sb);
- else {
- sb_cmd(sb, b16? DSP_CMD_DMAPAUSE_16 : DSP_CMD_DMAPAUSE_8);
- /*
- * The above seems to have the undocumented side effect of
- * blocking the other side as well. If the other
- * channel was active (SB16) I have to re-enable it :(
- */
- if (sb->bd_flags & (BD_F_DMARUN << (1 - b16)))
- sb_cmd(sb, b16? 0xd4 : 0xd6 );
- }
- if (play)
- sb_cmd(sb, DSP_CMD_SPKOFF); /* speaker off */
- sb->bd_flags &= ~(BD_F_DMARUN << b16);
- return 0;
-}
-
-/* channel interface */
-static void *
-sbchan_init(void *devinfo, snd_dbuf *b, pcm_channel *c, int dir)
-{
- struct sb_info *sb = devinfo;
- struct sb_chinfo *ch = (dir == PCMDIR_PLAY)? &sb->pch : &sb->rch;
- int dch, dl, dh;
-
- ch->parent = sb;
- ch->channel = c;
- ch->buffer = b;
- ch->buffer->bufsize = DSP_BUFFSIZE;
- if (chn_allocbuf(ch->buffer, sb->parent_dmat) == -1)
- return NULL;
- dch = (dir == PCMDIR_PLAY)? 1 : 0;
- if (sb->bd_flags & BD_F_SB16X)
- dch = !dch;
- dl = rman_get_start(sb->drq1);
- dh = sb->drq2? rman_get_start(sb->drq2) : dl;
- ch->buffer->chan = dch? dh : dl;
- return ch;
-}
-
-static int
-sbchan_setdir(void *data, int dir)
-{
- struct sb_chinfo *ch = data;
-
- ch->dir = dir;
- return 0;
-}
-
-static int
-sbchan_setformat(void *data, u_int32_t format)
-{
- struct sb_chinfo *ch = data;
-
- ch->fmt = format;
- return 0;
-}
-
-static int
-sbchan_setspeed(void *data, u_int32_t speed)
-{
- struct sb_chinfo *ch = data;
-
- ch->spd = speed;
- return sb_speed(ch);
-}
-
-static int
-sbchan_setblocksize(void *data, u_int32_t blocksize)
-{
- return blocksize;
-}
-
-static int
-sbchan_trigger(void *data, int go)
-{
- struct sb_chinfo *ch = data;
-
- if (go == PCMTRIG_EMLDMAWR)
- return 0;
-
- buf_isadma(ch->buffer, go);
- if (go == PCMTRIG_START)
- sb_start(ch);
- else
- sb_stop(ch);
- return 0;
-}
-
-static int
-sbchan_getptr(void *data)
-{
- struct sb_chinfo *ch = data;
-
- return buf_isadmaptr(ch->buffer);
-}
-
-static pcmchan_caps *
-sbchan_getcaps(void *data)
-{
- struct sb_chinfo *ch = data;
- int p = (ch->dir == PCMDIR_PLAY)? 1 : 0;
-
- if (ch->parent->bd_id < 0x300)
- return p? &sb_playcaps : &sb_reccaps;
- else if (ch->parent->bd_id < 0x400)
- return p? &sbpro_playcaps : &sbpro_reccaps;
- else if (ch->parent->bd_flags & BD_F_SB16X)
- return &sb16x_caps;
- else
- return (ch->buffer->chan >= 4)? &sb16_hcaps : &sb16_lcaps;
-}
-
-/* utility functions for ESS */
-static int
-ess_format(struct sb_chinfo *ch, u_int32_t format)
-{
- struct sb_info *sb = ch->parent;
- int play = (ch->dir == PCMDIR_PLAY)? 1 : 0;
- int b16 = (format & AFMT_S16_LE)? 1 : 0;
- int stereo = (format & AFMT_STEREO)? 1 : 0;
- u_char c;
-
- ch->fmt = format;
- sb_reset_dsp(sb);
- /* auto-init DMA mode */
- ess_write(sb, 0xb8, play ? 0x04 : 0x0e);
- /* mono/stereo */
- c = (ess_read(sb, 0xa8) & ~0x03) | 1;
- if (!stereo)
- c++;
- ess_write(sb, 0xa8, c);
- /* demand mode, 4 bytes/xfer */
- ess_write(sb, 0xb9, 2);
- /* setup dac/adc */
- if (play)
- ess_write(sb, 0xb6, b16? 0x00 : 0x80);
- ess_write(sb, 0xb7, 0x51 | (b16? 0x20 : 0x00));
- ess_write(sb, 0xb7, 0x98 + (b16? 0x24 : 0x00) + (stereo? 0x00 : 0x38));
- /* irq/drq control */
- ess_write(sb, 0xb1, (ess_read(sb, 0xb1) & 0x0f) | 0x50);
- ess_write(sb, 0xb2, (ess_read(sb, 0xb2) & 0x0f) | 0x50);
- return 0;
-}
-
-static int
-ess_speed(struct sb_chinfo *ch, int speed)
-{
- struct sb_info *sb = ch->parent;
- int t;
-
- RANGE (speed, 5000, 49000);
- if (speed > 22000) {
- t = (795500 + speed / 2) / speed;
- speed = (795500 + t / 2) / t;
- t = (256 - t ) | 0x80;
- } else {
- t = (397700 + speed / 2) / speed;
- speed = (397700 + t / 2) / t;
- t = 128 - t;
- }
- ess_write(sb, 0xa1, t); /* set time constant */
-#if 0
- d->play_speed = d->rec_speed = speed;
- speed = (speed * 9 ) / 20;
-#endif
- t = 256 - 7160000 / ((speed * 9 / 20) * 82);
- ess_write(sb, 0xa2, t);
- return speed;
-}
-
-static int
-ess_start(struct sb_chinfo *ch)
-{
- struct sb_info *sb = ch->parent;
- int play = (ch->dir == PCMDIR_PLAY)? 1 : 0;
- short c = - ch->buffer->dl;
- u_char c1;
-
- /*
- * clear bit 0 of register B8h
- */
-#if 1
- c1 = play ? 0x04 : 0x0e;
- ess_write(sb, 0xb8, c1++);
-#else
- c1 = ess_read(sb, 0xb8) & 0xfe;
- ess_write(sb, 0xb8, c1++);
-#endif
- /*
- * update ESS Transfer Count Register
- */
- ess_write(sb, 0xa4, (u_char)((u_short)c & 0xff));
- ess_write(sb, 0xa5, (u_char)(((u_short)c >> 8) & 0xff));
- /*
- * set bit 0 of register B8h
- */
- ess_write(sb, 0xb8, c1);
- if (play)
- sb_cmd(sb, DSP_CMD_SPKON);
- return 0;
-}
-
-static int
-ess_stop(struct sb_chinfo *ch)
-{
- struct sb_info *sb = ch->parent;
- /*
- * no need to send a stop command if the DMA has already stopped.
- */
- if (ch->buffer->dl > 0) {
- sb_cmd(sb, DSP_CMD_DMAPAUSE_8); /* pause dma. */
- }
- return 0;
-}
-
-static int
-ess_abort(struct sb_chinfo *ch)
-{
- struct sb_info *sb = ch->parent;
- int play = (ch->dir == PCMDIR_PLAY)? 1 : 0;
-
- if (play)
- sb_cmd(sb, DSP_CMD_SPKOFF); /* speaker off */
- sb_reset_dsp(sb);
- ess_format(ch, ch->fmt);
- ess_speed(ch, ch->channel->speed);
- return 0;
-}
-
-/* channel interface for ESS18xx */
-static void *
-esschan_init(void *devinfo, snd_dbuf *b, pcm_channel *c, int dir)
-{
- struct sb_info *sb = devinfo;
- struct sb_chinfo *ch = (dir == PCMDIR_PLAY)? &sb->pch : &sb->rch;
-
- ch->parent = sb;
- ch->channel = c;
- ch->buffer = b;
- ch->buffer->bufsize = ESS_BUFFSIZE;
- if (chn_allocbuf(ch->buffer, sb->parent_dmat) == -1)
- return NULL;
- ch->buffer->chan = rman_get_start(sb->drq1);
- return ch;
-}
-
-static int
-esschan_setdir(void *data, int dir)
-{
- struct sb_chinfo *ch = data;
-
- ch->dir = dir;
- return 0;
-}
-
-static int
-esschan_setformat(void *data, u_int32_t format)
-{
- struct sb_chinfo *ch = data;
-
- ess_format(ch, format);
- return 0;
-}
-
-static int
-esschan_setspeed(void *data, u_int32_t speed)
-{
- struct sb_chinfo *ch = data;
-
- return ess_speed(ch, speed);
-}
-
-static int
-esschan_setblocksize(void *data, u_int32_t blocksize)
-{
- return blocksize;
-}
-
-static int
-esschan_trigger(void *data, int go)
-{
- struct sb_chinfo *ch = data;
-
- if (go == PCMTRIG_EMLDMAWR)
- return 0;
- switch (go) {
- case PCMTRIG_START:
- if (!ch->ess_dma_started)
- buf_isadma(ch->buffer, go);
- ch->ess_dma_started = 1;
- ess_start(ch);
- break;
- case PCMTRIG_STOP:
- if (ch->buffer->dl >= 0) {
- buf_isadma(ch->buffer, go);
- ch->ess_dma_started = 0;
- ess_stop(ch);
- }
- break;
- case PCMTRIG_ABORT:
- default:
- ch->ess_dma_started = 0;
- ess_abort(ch);
- buf_isadma(ch->buffer, go);
- break;
- }
- return 0;
-}
-
-static int
-esschan_getptr(void *data)
-{
- struct sb_chinfo *ch = data;
-
- return buf_isadmaptr(ch->buffer);
-}
-
-static pcmchan_caps *
-esschan_getcaps(void *data)
-{
- struct sb_chinfo *ch = data;
-
- return (ch->dir == PCMDIR_PLAY)? &ess_playcaps : &ess_reccaps;
-}
-
-/************************************************************/
-
-static int
-sbmix_init(snd_mixer *m)
-{
- struct sb_info *sb = mix_getdevinfo(m);
-
- switch (sb->bd_flags & BD_F_MIX_MASK) {
- case BD_F_MIX_CT1345: /* SB 3.0 has 1345 mixer */
- mix_setdevs(m, SBPRO_MIXER_DEVICES);
- mix_setrecdevs(m, SBPRO_RECORDING_DEVICES);
- sb_setmixer(sb, 0, 1); /* reset mixer */
- if (!(sb->bd_flags & BD_F_ESS))
- sb_setmixer(sb, MIC_VOL, 0x6); /* mic volume max */
- sb_setmixer(sb, RECORD_SRC, 0x0); /* mic source */
- sb_setmixer(sb, FM_VOL, 0x0); /* no midi */
- break;
-
- case BD_F_MIX_CT1745: /* SB16 mixer ... */
- mix_setdevs(m, SB16_MIXER_DEVICES);
- mix_setrecdevs(m, SB16_RECORDING_DEVICES);
- sb_setmixer(sb, 0x3c, 0x1f); /* make all output active */
- sb_setmixer(sb, 0x3d, 0); /* make all inputs-l off */
- sb_setmixer(sb, 0x3e, 0); /* make all inputs-r off */
- }
- return 0;
-}
-
-static int
-sbmix_set(snd_mixer *m, unsigned dev, unsigned left, unsigned right)
-{
- struct sb_info *sb = mix_getdevinfo(m);
- int regoffs;
- u_char val;
- mixer_tab *iomap;
-
- switch (sb->bd_flags & BD_F_MIX_MASK) {
- case BD_F_MIX_CT1345:
- if (sb->bd_flags & BD_F_ESS)
- iomap = &ess_mix;
- else
- iomap = &sbpro_mix;
- break;
-
- case BD_F_MIX_CT1745:
- iomap = &sb16_mix;
- break;
-
- default:
- return -1;
- }
-
- /* Change left channel */
- regoffs = (*iomap)[dev][LEFT_CHN].regno;
- if (regoffs != 0) {
- val = sb_getmixer(sb, regoffs);
- change_bits(iomap, &val, dev, LEFT_CHN, left);
- sb_setmixer(sb, regoffs, val);
- }
-
- /* Change right channel */
- regoffs = (*iomap)[dev][RIGHT_CHN].regno;
- if (regoffs != 0) {
- val = sb_getmixer(sb, regoffs); /* Read the new one */
- change_bits(iomap, &val, dev, RIGHT_CHN, right);
- sb_setmixer(sb, regoffs, val);
- } else
- right = left;
-
- return left | (right << 8);
-}
-
-static int
-sbmix_setrecsrc(snd_mixer *m, u_int32_t src)
-{
- struct sb_info *sb = mix_getdevinfo(m);
- u_char recdev;
-
- switch (sb->bd_flags & BD_F_MIX_MASK) {
- case BD_F_MIX_CT1345:
- if (src == SOUND_MASK_LINE)
- recdev = 0x06;
- else if (src == SOUND_MASK_CD)
- recdev = 0x02;
- else { /* default: mic */
- src = SOUND_MASK_MIC;
- recdev = 0;
- }
- sb_setmixer(sb, RECORD_SRC, recdev |
- (sb_getmixer(sb, RECORD_SRC) & ~0x07));
- break;
-
- case BD_F_MIX_CT1745: /* sb16 */
- recdev = 0;
- if (src & SOUND_MASK_MIC)
- recdev |= 0x01; /* mono mic */
- if (src & SOUND_MASK_CD)
- recdev |= 0x06; /* l+r cd */
- if (src & SOUND_MASK_LINE)
- recdev |= 0x18; /* l+r line */
- if (src & SOUND_MASK_SYNTH)
- recdev |= 0x60; /* l+r midi */
- sb_setmixer(sb, SB16_IMASK_L, recdev);
- sb_setmixer(sb, SB16_IMASK_R, recdev);
- /*
- * since the same volume controls apply to the input and
- * output sections, the best approach to have a consistent
- * behaviour among cards would be to disable the output path
- * on devices which are used to record.
- * However, since users like to have feedback, we only disable
- * the mic -- permanently.
- */
- sb_setmixer(sb, SB16_OMASK, 0x1f & ~1);
- break;
- }
- return src;
-}
-
-static int
-sbsbc_probe(device_t dev)
-{
- char buf[64];
- uintptr_t func, ver, r, f;
-
- /* The parent device has already been probed. */
- r = BUS_READ_IVAR(device_get_parent(dev), dev, 0, &func);
- if (func != SCF_PCM)
- return (ENXIO);
-
- r = BUS_READ_IVAR(device_get_parent(dev), dev, 1, &ver);
- f = (ver & 0xffff0000) >> 16;
- ver &= 0x0000ffff;
- snprintf(buf, sizeof buf, "SB DSP %d.%02d%s%s", (int) ver >> 8, (int) ver & 0xff,
- (f & BD_F_ESS)? " (ESS mode)" : "",
- (f & BD_F_SB16X)? " (ViBRA16X)" : "");
- device_set_desc_copy(dev, buf);
-
- return 0;
-}
-
-static int
-sbsbc_attach(device_t dev)
-{
- struct sb_info *sb;
- uintptr_t ver;
-
- sb = (struct sb_info *)malloc(sizeof *sb, M_DEVBUF, M_NOWAIT);
- if (!sb)
- return ENXIO;
- bzero(sb, sizeof *sb);
-
- BUS_READ_IVAR(device_get_parent(dev), dev, 1, &ver);
- sb->bd_id = ver & 0x0000ffff;
- sb->bd_flags = (ver & 0xffff0000) >> 16;
-
- return sb_doattach(dev, sb);
-}
-
-static device_method_t sbsbc_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, sbsbc_probe),
- DEVMETHOD(device_attach, sbsbc_attach),
-
- { 0, 0 }
-};
-
-static driver_t sbsbc_driver = {
- "pcm",
- sbsbc_methods,
- sizeof(snddev_info),
-};
-
-DRIVER_MODULE(sbsbc, sbc, sbsbc_driver, pcm_devclass, 0, 0);
-
-
-
diff --git a/sys/dev/speaker/speaker.h b/sys/dev/speaker/speaker.h
deleted file mode 100644
index 78b55b6135e3..000000000000
--- a/sys/dev/speaker/speaker.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * speaker.h -- interface definitions for speaker ioctl()
- *
- * v1.4 by Eric S. Raymond (esr@snark.thyrsus.com) Aug 1993
- * modified for FreeBSD by Andrew A. Chernov <ache@astral.msk.su>
- *
- * $FreeBSD$
- */
-
-#ifndef _MACHINE_SPEAKER_H_
-#define _MACHINE_SPEAKER_H_
-
-#include <sys/ioccom.h>
-
-#define SPKRTONE _IOW('S', 1, tone_t) /* emit tone */
-#define SPKRTUNE _IO('S', 2) /* emit tone sequence*/
-
-typedef struct
-{
- int frequency; /* in hertz */
- int duration; /* in 1/100ths of a second */
-}
-tone_t;
-
-/*
- * Strings written to the speaker device are interpreted as tunes and played;
- * see the spkr(4) man page for details.
- */
-
-#endif /* !_MACHINE_SPEAKER_H_ */
diff --git a/sys/dev/speaker/spkr.c b/sys/dev/speaker/spkr.c
deleted file mode 100644
index 8f4b8aadcb35..000000000000
--- a/sys/dev/speaker/spkr.c
+++ /dev/null
@@ -1,596 +0,0 @@
-/*
- * spkr.c -- device driver for console speaker
- *
- * v1.4 by Eric S. Raymond (esr@snark.thyrsus.com) Aug 1993
- * modified for FreeBSD by Andrew A. Chernov <ache@astral.msk.su>
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/buf.h>
-#include <sys/uio.h>
-#include <sys/conf.h>
-#include <sys/ctype.h>
-#include <i386/isa/isa.h>
-#include <i386/isa/timerreg.h>
-#include <machine/clock.h>
-#include <machine/speaker.h>
-
-static d_open_t spkropen;
-static d_close_t spkrclose;
-static d_write_t spkrwrite;
-static d_ioctl_t spkrioctl;
-
-#define CDEV_MAJOR 26
-static struct cdevsw spkr_cdevsw = {
- /* open */ spkropen,
- /* close */ spkrclose,
- /* read */ noread,
- /* write */ spkrwrite,
- /* ioctl */ spkrioctl,
- /* poll */ nopoll,
- /* mmap */ nommap,
- /* strategy */ nostrategy,
- /* name */ "spkr",
- /* maj */ CDEV_MAJOR,
- /* dump */ nodump,
- /* psize */ nopsize,
- /* flags */ 0,
- /* bmaj */ -1
-};
-
-/**************** MACHINE DEPENDENT PART STARTS HERE *************************
- *
- * This section defines a function tone() which causes a tone of given
- * frequency and duration from the ISA console speaker.
- * Another function endtone() is defined to force sound off, and there is
- * also a rest() entry point to do pauses.
- *
- * Audible sound is generated using the Programmable Interval Timer (PIT) and
- * Programmable Peripheral Interface (PPI) attached to the ISA speaker. The
- * PPI controls whether sound is passed through at all; the PIT's channel 2 is
- * used to generate clicks (a square wave) of whatever frequency is desired.
- */
-
-/*
- * PPI control values.
- * XXX should be in a header and used in clock.c.
- */
-#define PPI_SPKR 0x03 /* turn these PPI bits on to pass sound */
-
-#define SPKRPRI PSOCK
-static char endtone, endrest;
-
-static void tone __P((unsigned int thz, unsigned int ticks));
-static void rest __P((int ticks));
-static void playinit __P((void));
-static void playtone __P((int pitch, int value, int sustain));
-static int abs __P((int n));
-static void playstring __P((char *cp, size_t slen));
-
-/* emit tone of frequency thz for given number of ticks */
-static void
-tone(thz, ticks)
- unsigned int thz, ticks;
-{
- unsigned int divisor;
- int sps;
-
- if (thz <= 0)
- return;
-
- divisor = timer_freq / thz;
-
-#ifdef DEBUG
- (void) printf("tone: thz=%d ticks=%d\n", thz, ticks);
-#endif /* DEBUG */
-
- /* set timer to generate clicks at given frequency in Hertz */
- sps = splclock();
-
- if (acquire_timer2(TIMER_SEL2 | TIMER_SQWAVE | TIMER_16BIT)) {
- /* enter list of waiting procs ??? */
- splx(sps);
- return;
- }
- splx(sps);
- disable_intr();
- outb(TIMER_CNTR2, (divisor & 0xff)); /* send lo byte */
- outb(TIMER_CNTR2, (divisor >> 8)); /* send hi byte */
- enable_intr();
-
- /* turn the speaker on */
- outb(IO_PPI, inb(IO_PPI) | PPI_SPKR);
-
- /*
- * Set timeout to endtone function, then give up the timeslice.
- * This is so other processes can execute while the tone is being
- * emitted.
- */
- if (ticks > 0)
- tsleep((caddr_t)&endtone, SPKRPRI | PCATCH, "spkrtn", ticks);
- outb(IO_PPI, inb(IO_PPI) & ~PPI_SPKR);
- sps = splclock();
- release_timer2();
- splx(sps);
-}
-
-/* rest for given number of ticks */
-static void
-rest(ticks)
- int ticks;
-{
- /*
- * Set timeout to endrest function, then give up the timeslice.
- * This is so other processes can execute while the rest is being
- * waited out.
- */
-#ifdef DEBUG
- (void) printf("rest: %d\n", ticks);
-#endif /* DEBUG */
- if (ticks > 0)
- tsleep((caddr_t)&endrest, SPKRPRI | PCATCH, "spkrrs", ticks);
-}
-
-/**************** PLAY STRING INTERPRETER BEGINS HERE **********************
- *
- * Play string interpretation is modelled on IBM BASIC 2.0's PLAY statement;
- * M[LNS] are missing; the ~ synonym and the _ slur mark and the octave-
- * tracking facility are added.
- * Requires tone(), rest(), and endtone(). String play is not interruptible
- * except possibly at physical block boundaries.
- */
-
-typedef int bool;
-#define TRUE 1
-#define FALSE 0
-
-#define dtoi(c) ((c) - '0')
-
-static int octave; /* currently selected octave */
-static int whole; /* whole-note time at current tempo, in ticks */
-static int value; /* whole divisor for note time, quarter note = 1 */
-static int fill; /* controls spacing of notes */
-static bool octtrack; /* octave-tracking on? */
-static bool octprefix; /* override current octave-tracking state? */
-
-/*
- * Magic number avoidance...
- */
-#define SECS_PER_MIN 60 /* seconds per minute */
-#define WHOLE_NOTE 4 /* quarter notes per whole note */
-#define MIN_VALUE 64 /* the most we can divide a note by */
-#define DFLT_VALUE 4 /* default value (quarter-note) */
-#define FILLTIME 8 /* for articulation, break note in parts */
-#define STACCATO 6 /* 6/8 = 3/4 of note is filled */
-#define NORMAL 7 /* 7/8ths of note interval is filled */
-#define LEGATO 8 /* all of note interval is filled */
-#define DFLT_OCTAVE 4 /* default octave */
-#define MIN_TEMPO 32 /* minimum tempo */
-#define DFLT_TEMPO 120 /* default tempo */
-#define MAX_TEMPO 255 /* max tempo */
-#define NUM_MULT 3 /* numerator of dot multiplier */
-#define DENOM_MULT 2 /* denominator of dot multiplier */
-
-/* letter to half-tone: A B C D E F G */
-static int notetab[8] = {9, 11, 0, 2, 4, 5, 7};
-
-/*
- * This is the American Standard A440 Equal-Tempered scale with frequencies
- * rounded to nearest integer. Thank Goddess for the good ol' CRC Handbook...
- * our octave 0 is standard octave 2.
- */
-#define OCTAVE_NOTES 12 /* semitones per octave */
-static int pitchtab[] =
-{
-/* C C# D D# E F F# G G# A A# B*/
-/* 0 */ 65, 69, 73, 78, 82, 87, 93, 98, 103, 110, 117, 123,
-/* 1 */ 131, 139, 147, 156, 165, 175, 185, 196, 208, 220, 233, 247,
-/* 2 */ 262, 277, 294, 311, 330, 349, 370, 392, 415, 440, 466, 494,
-/* 3 */ 523, 554, 587, 622, 659, 698, 740, 784, 831, 880, 932, 988,
-/* 4 */ 1047, 1109, 1175, 1245, 1319, 1397, 1480, 1568, 1661, 1760, 1865, 1975,
-/* 5 */ 2093, 2217, 2349, 2489, 2637, 2794, 2960, 3136, 3322, 3520, 3729, 3951,
-/* 6 */ 4186, 4435, 4698, 4978, 5274, 5588, 5920, 6272, 6644, 7040, 7459, 7902,
-};
-
-static void
-playinit()
-{
- octave = DFLT_OCTAVE;
- whole = (hz * SECS_PER_MIN * WHOLE_NOTE) / DFLT_TEMPO;
- fill = NORMAL;
- value = DFLT_VALUE;
- octtrack = FALSE;
- octprefix = TRUE; /* act as though there was an initial O(n) */
-}
-
-/* play tone of proper duration for current rhythm signature */
-static void
-playtone(pitch, value, sustain)
- int pitch, value, sustain;
-{
- register int sound, silence, snum = 1, sdenom = 1;
-
- /* this weirdness avoids floating-point arithmetic */
- for (; sustain; sustain--)
- {
- /* See the BUGS section in the man page for discussion */
- snum *= NUM_MULT;
- sdenom *= DENOM_MULT;
- }
-
- if (value == 0 || sdenom == 0)
- return;
-
- if (pitch == -1)
- rest(whole * snum / (value * sdenom));
- else
- {
- sound = (whole * snum) / (value * sdenom)
- - (whole * (FILLTIME - fill)) / (value * FILLTIME);
- silence = whole * (FILLTIME-fill) * snum / (FILLTIME * value * sdenom);
-
-#ifdef DEBUG
- (void) printf("playtone: pitch %d for %d ticks, rest for %d ticks\n",
- pitch, sound, silence);
-#endif /* DEBUG */
-
- tone(pitchtab[pitch], sound);
- if (fill != LEGATO)
- rest(silence);
- }
-}
-
-static int
-abs(n)
- int n;
-{
- if (n < 0)
- return(-n);
- else
- return(n);
-}
-
-/* interpret and play an item from a notation string */
-static void
-playstring(cp, slen)
- char *cp;
- size_t slen;
-{
- int pitch, oldfill, lastpitch = OCTAVE_NOTES * DFLT_OCTAVE;
-
-#define GETNUM(cp, v) for(v=0; isdigit(cp[1]) && slen > 0; ) \
- {v = v * 10 + (*++cp - '0'); slen--;}
- for (; slen--; cp++)
- {
- int sustain, timeval, tempo;
- register char c = toupper(*cp);
-
-#ifdef DEBUG
- (void) printf("playstring: %c (%x)\n", c, c);
-#endif /* DEBUG */
-
- switch (c)
- {
- case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G':
-
- /* compute pitch */
- pitch = notetab[c - 'A'] + octave * OCTAVE_NOTES;
-
- /* this may be followed by an accidental sign */
- if (cp[1] == '#' || cp[1] == '+')
- {
- ++pitch;
- ++cp;
- slen--;
- }
- else if (cp[1] == '-')
- {
- --pitch;
- ++cp;
- slen--;
- }
-
- /*
- * If octave-tracking mode is on, and there has been no octave-
- * setting prefix, find the version of the current letter note
- * closest to the last regardless of octave.
- */
- if (octtrack && !octprefix)
- {
- if (abs(pitch-lastpitch) > abs(pitch+OCTAVE_NOTES-lastpitch))
- {
- ++octave;
- pitch += OCTAVE_NOTES;
- }
-
- if (abs(pitch-lastpitch) > abs((pitch-OCTAVE_NOTES)-lastpitch))
- {
- --octave;
- pitch -= OCTAVE_NOTES;
- }
- }
- octprefix = FALSE;
- lastpitch = pitch;
-
- /* ...which may in turn be followed by an override time value */
- GETNUM(cp, timeval);
- if (timeval <= 0 || timeval > MIN_VALUE)
- timeval = value;
-
- /* ...and/or sustain dots */
- for (sustain = 0; cp[1] == '.'; cp++)
- {
- slen--;
- sustain++;
- }
-
- /* ...and/or a slur mark */
- oldfill = fill;
- if (cp[1] == '_')
- {
- fill = LEGATO;
- ++cp;
- slen--;
- }
-
- /* time to emit the actual tone */
- playtone(pitch, timeval, sustain);
-
- fill = oldfill;
- break;
-
- case 'O':
- if (cp[1] == 'N' || cp[1] == 'n')
- {
- octprefix = octtrack = FALSE;
- ++cp;
- slen--;
- }
- else if (cp[1] == 'L' || cp[1] == 'l')
- {
- octtrack = TRUE;
- ++cp;
- slen--;
- }
- else
- {
- GETNUM(cp, octave);
- if (octave >= sizeof(pitchtab) / sizeof(pitchtab[0]) / OCTAVE_NOTES)
- octave = DFLT_OCTAVE;
- octprefix = TRUE;
- }
- break;
-
- case '>':
- if (octave < sizeof(pitchtab) / sizeof(pitchtab[0]) / OCTAVE_NOTES - 1)
- octave++;
- octprefix = TRUE;
- break;
-
- case '<':
- if (octave > 0)
- octave--;
- octprefix = TRUE;
- break;
-
- case 'N':
- GETNUM(cp, pitch);
- for (sustain = 0; cp[1] == '.'; cp++)
- {
- slen--;
- sustain++;
- }
- oldfill = fill;
- if (cp[1] == '_')
- {
- fill = LEGATO;
- ++cp;
- slen--;
- }
- playtone(pitch - 1, value, sustain);
- fill = oldfill;
- break;
-
- case 'L':
- GETNUM(cp, value);
- if (value <= 0 || value > MIN_VALUE)
- value = DFLT_VALUE;
- break;
-
- case 'P':
- case '~':
- /* this may be followed by an override time value */
- GETNUM(cp, timeval);
- if (timeval <= 0 || timeval > MIN_VALUE)
- timeval = value;
- for (sustain = 0; cp[1] == '.'; cp++)
- {
- slen--;
- sustain++;
- }
- playtone(-1, timeval, sustain);
- break;
-
- case 'T':
- GETNUM(cp, tempo);
- if (tempo < MIN_TEMPO || tempo > MAX_TEMPO)
- tempo = DFLT_TEMPO;
- whole = (hz * SECS_PER_MIN * WHOLE_NOTE) / tempo;
- break;
-
- case 'M':
- if (cp[1] == 'N' || cp[1] == 'n')
- {
- fill = NORMAL;
- ++cp;
- slen--;
- }
- else if (cp[1] == 'L' || cp[1] == 'l')
- {
- fill = LEGATO;
- ++cp;
- slen--;
- }
- else if (cp[1] == 'S' || cp[1] == 's')
- {
- fill = STACCATO;
- ++cp;
- slen--;
- }
- break;
- }
- }
-}
-
-/******************* UNIX DRIVER HOOKS BEGIN HERE **************************
- *
- * This section implements driver hooks to run playstring() and the tone(),
- * endtone(), and rest() functions defined above.
- */
-
-static int spkr_active = FALSE; /* exclusion flag */
-static struct buf *spkr_inbuf; /* incoming buf */
-
-int
-spkropen(dev, flags, fmt, p)
- dev_t dev;
- int flags;
- int fmt;
- struct proc *p;
-{
-#ifdef DEBUG
- (void) printf("spkropen: entering with dev = %s\n", devtoname(dev));
-#endif /* DEBUG */
-
- if (minor(dev) != 0)
- return(ENXIO);
- else if (spkr_active)
- return(EBUSY);
- else
- {
-#ifdef DEBUG
- (void) printf("spkropen: about to perform play initialization\n");
-#endif /* DEBUG */
- playinit();
- spkr_inbuf = geteblk(DEV_BSIZE);
- spkr_active = TRUE;
- return(0);
- }
-}
-
-int
-spkrwrite(dev, uio, ioflag)
- dev_t dev;
- struct uio *uio;
- int ioflag;
-{
-#ifdef DEBUG
- printf("spkrwrite: entering with dev = %s, count = %d\n",
- devtoname(dev), uio->uio_resid);
-#endif /* DEBUG */
-
- if (minor(dev) != 0)
- return(ENXIO);
- else if (uio->uio_resid > (DEV_BSIZE - 1)) /* prevent system crashes */
- return(E2BIG);
- else
- {
- unsigned n;
- char *cp;
- int error;
-
- n = uio->uio_resid;
- cp = spkr_inbuf->b_data;
- error = uiomove(cp, n, uio);
- if (!error) {
- cp[n] = '\0';
- playstring(cp, n);
- }
- return(error);
- }
-}
-
-int
-spkrclose(dev, flags, fmt, p)
- dev_t dev;
- int flags;
- int fmt;
- struct proc *p;
-{
-#ifdef DEBUG
- (void) printf("spkrclose: entering with dev = %s\n", devtoname(dev));
-#endif /* DEBUG */
-
- if (minor(dev) != 0)
- return(ENXIO);
- else
- {
- wakeup((caddr_t)&endtone);
- wakeup((caddr_t)&endrest);
- brelse(spkr_inbuf);
- spkr_active = FALSE;
- return(0);
- }
-}
-
-int
-spkrioctl(dev, cmd, cmdarg, flags, p)
- dev_t dev;
- unsigned long cmd;
- caddr_t cmdarg;
- int flags;
- struct proc *p;
-{
-#ifdef DEBUG
- (void) printf("spkrioctl: entering with dev = %s, cmd = %lx\n",
- devtoname(dev), cmd);
-#endif /* DEBUG */
-
- if (minor(dev) != 0)
- return(ENXIO);
- else if (cmd == SPKRTONE)
- {
- tone_t *tp = (tone_t *)cmdarg;
-
- if (tp->frequency == 0)
- rest(tp->duration);
- else
- tone(tp->frequency, tp->duration);
- return 0;
- }
- else if (cmd == SPKRTUNE)
- {
- tone_t *tp = (tone_t *)(*(caddr_t *)cmdarg);
- tone_t ttp;
- int error;
-
- for (; ; tp++) {
- error = copyin(tp, &ttp, sizeof(tone_t));
- if (error)
- return(error);
- if (ttp.duration == 0)
- break;
- if (ttp.frequency == 0)
- rest(ttp.duration);
- else
- tone(ttp.frequency, ttp.duration);
- }
- return(0);
- }
- return(EINVAL);
-}
-
-static void
-spkr_drvinit(void *unused)
-{
- make_dev(&spkr_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "speaker");
-}
-
-SYSINIT(spkrdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,spkr_drvinit,NULL)
-
-
-/* spkr.c ends here */
diff --git a/sys/dev/sr/if_sr.c b/sys/dev/sr/if_sr.c
deleted file mode 100644
index c1348e3a3a9e..000000000000
--- a/sys/dev/sr/if_sr.c
+++ /dev/null
@@ -1,3552 +0,0 @@
-/*
- * Copyright (c) 1996 John Hay.
- * Copyright (c) 1996 SDL Communications, Inc.
- * 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 author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Programming assumptions and other issues.
- *
- * Only a 16K window will be used.
- *
- * The descriptors of a DMA channel will fit in a 16K memory window.
- *
- * The buffers of a transmit DMA channel will fit in a 16K memory window.
- *
- * When interface is going up, handshaking is set and it is only cleared
- * when the interface is down'ed.
- *
- * There should be a way to set/reset Raw HDLC/PPP, Loopback, DCE/DTE,
- * internal/external clock, etc.....
- *
- */
-
-#include "sr.h"
-#include "opt_netgraph.h"
-#ifdef NETGRAPH
-#include <i386/isa/if_sr.h>
-#else /* NETGRAPH */
-#ifdef notyet
-#include "fr.h"
-#else
-#define NFR 0
-#endif
-#endif /* NETGRAPH */
-
-#ifndef NETGRAPH
-#include "sppp.h"
-#if NSPPP <= 0
-#error Device 'sr' requires sppp.
-#endif
-#endif /* NETGRAPH */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/malloc.h>
-#include <sys/mbuf.h>
-#include <sys/sockio.h>
-#include <sys/socket.h>
-
-#include <net/if.h>
-#ifdef NETGRAPH
-#include <sys/syslog.h>
-#else /* NETGRAPH */
-#include <net/if_sppp.h>
-
-#include <net/bpf.h>
-#endif /* NETGRAPH */
-
-#include <machine/md_var.h>
-
-#include <i386/isa/if_srregs.h>
-#include <i386/isa/ic/hd64570.h>
-#include <i386/isa/isa_device.h>
-
-#ifdef NETGRAPH
-#include <netgraph/ng_message.h>
-#include <netgraph/netgraph.h>
-#endif /* NETGRAPH */
-/* #define USE_MODEMCK */
-
-#ifndef BUGGY
-#define BUGGY 0
-#endif
-
-#ifndef NETGRAPH
-#define PPP_HEADER_LEN 4
-#endif /* NETGRAPH */
-
-/*
- * These macros are used to hide the difference between the way the
- * ISA N2 cards and the PCI N2 cards access the Hitachi 64570 SCA.
- */
-#define SRC_GET8(base,off) (*hc->src_get8)(base,(u_int)&off)
-#define SRC_GET16(base,off) (*hc->src_get16)(base,(u_int)&off)
-#define SRC_PUT8(base,off,d) (*hc->src_put8)(base,(u_int)&off,d)
-#define SRC_PUT16(base,off,d) (*hc->src_put16)(base,(u_int)&off,d)
-
-/*
- * These macros enable/disable the DPRAM and select the correct
- * DPRAM page.
- */
-#define SRC_GET_WIN(addr) ((addr >> SRC_WIN_SHFT) & SR_PG_MSK)
-
-#define SRC_SET_ON(iobase) outb(iobase+SR_PCR, \
- SR_PCR_MEM_WIN | inb(iobase+SR_PCR))
-#define SRC_SET_MEM(iobase,win) outb(iobase+SR_PSR, SRC_GET_WIN(win) | \
- (inb(iobase+SR_PSR) & ~SR_PG_MSK))
-#define SRC_SET_OFF(iobase) outb(iobase+SR_PCR, \
- ~SR_PCR_MEM_WIN & inb(iobase+SR_PCR))
-
-/*
- * Define the hardware (card information) structure needed to keep
- * track of the device itself... There is only one per card.
- */
-struct sr_hardc {
- struct sr_hardc *next; /* PCI card linkage */
- struct sr_softc *sc; /* software channels */
- int cunit; /* card w/in system */
-
- u_short iobase; /* I/O Base Address */
- int cardtype;
- int numports; /* # of ports on cd */
- int mempages;
- u_int memsize; /* DPRAM size: bytes */
- u_int winmsk;
- vm_offset_t sca_base;
- vm_offset_t mem_pstart; /* start of buffer */
- caddr_t mem_start; /* start of DP RAM */
- caddr_t mem_end; /* end of DP RAM */
- caddr_t plx_base;
-
- sca_regs *sca; /* register array */
-
- /*
- * We vectorize the following functions to allow re-use between the
- * ISA card's needs and those of the PCI card.
- */
- void (*src_put8)(u_int base, u_int off, u_int val);
- void (*src_put16)(u_int base, u_int off, u_int val);
- u_int (*src_get8)(u_int base, u_int off);
- u_int (*src_get16)(u_int base, u_int off);
-};
-
-static int next_sc_unit = 0;
-#ifndef NETGRAPH
-static int sr_watcher = 0;
-#endif /* NETGRAPH */
-static struct sr_hardc sr_hardc[NSR];
-static struct sr_hardc *sr_hardc_pci;
-
-/*
- * Define the software interface for the card... There is one for
- * every channel (port).
- */
-struct sr_softc {
-#ifndef NETGRAPH
- struct sppp ifsppp; /* PPP service w/in system */
-#endif /* NETGRAPH */
- struct sr_hardc *hc; /* card-level information */
-
- int unit; /* With regard to all sr devices */
- int subunit; /* With regard to this card */
-
-#ifndef NETGRAPH
- int attached; /* attached to FR or PPP */
- int protocol; /* FR or PPP */
-#define N2_USE_FRP 2 /* Frame Relay Protocol */
-#define N2_USE_PPP 1 /* Point-to-Point Protocol */
-#endif /* NETGRAPH */
- struct buf_block {
- u_int txdesc; /* DPRAM offset */
- u_int txstart;/* DPRAM offset */
- u_int txend; /* DPRAM offset */
- u_int txtail; /* # of 1st free gran */
- u_int txmax; /* # of free grans */
- u_int txeda; /* err descr addr */
- } block[SR_TX_BLOCKS];
-
- char xmit_busy; /* Transmitter is busy */
- char txb_inuse; /* # of tx grans in use */
- u_int txb_new; /* ndx to new buffer */
- u_int txb_next_tx; /* ndx to next gran rdy tx */
-
- u_int rxdesc; /* DPRAM offset */
- u_int rxstart; /* DPRAM offset */
- u_int rxend; /* DPRAM offset */
- u_int rxhind; /* ndx to the hd of rx bufrs */
- u_int rxmax; /* # of avail grans */
-
- u_int clk_cfg; /* Clock configuration */
-
- int scachan; /* channel # on card */
-#ifdef NETGRAPH
- int running; /* something is attached so we are running */
- int dcd; /* do we have dcd? */
- /* ---netgraph bits --- */
- char nodename[NG_NODELEN + 1]; /* store our node name */
- int datahooks; /* number of data hooks attached */
- node_p node; /* netgraph node */
- hook_p hook; /* data hook */
- hook_p debug_hook;
- struct ifqueue xmitq_hipri; /* hi-priority transmit queue */
- struct ifqueue xmitq; /* transmit queue */
- int flags; /* state */
-#define SCF_RUNNING 0x01 /* board is active */
-#define SCF_OACTIVE 0x02 /* output is active */
- int out_dog; /* watchdog cycles output count-down */
-#if ( __FreeBSD__ >= 3 )
- struct callout_handle handle; /* timeout(9) handle */
-#endif
- u_long inbytes, outbytes; /* stats */
- u_long lastinbytes, lastoutbytes; /* a second ago */
- u_long inrate, outrate; /* highest rate seen */
- u_long inlast; /* last input N secs ago */
- u_long out_deficit; /* output since last input */
- u_long oerrors, ierrors[6];
- u_long opackets, ipackets;
-#endif /* NETGRAPH */
-};
-
-#ifdef NETGRAPH
-#define DOG_HOLDOFF 6 /* dog holds off for 6 secs */
-#define QUITE_A_WHILE 300 /* 5 MINUTES */
-#define LOTS_OF_PACKETS 100
-#endif /* NETGRAPH */
-
-/*
- * List of valid interrupt numbers for the N2 ISA card.
- */
-static int sr_irqtable[16] = {
- 0, /* 0 */
- 0, /* 1 */
- 0, /* 2 */
- 1, /* 3 */
- 1, /* 4 */
- 1, /* 5 */
- 0, /* 6 */
- 1, /* 7 */
- 0, /* 8 */
- 0, /* 9 */
- 1, /* 10 */
- 1, /* 11 */
- 1, /* 12 */
- 0, /* 13 */
- 0, /* 14 */
- 1 /* 15 */
-};
-
-static int srprobe(struct isa_device *id);
-static int srattach_isa(struct isa_device *id);
-
-struct isa_driver srdriver = {srprobe, srattach_isa, "src"};
-
-/*
- * Baud Rate table for Sync Mode.
- * Each entry consists of 3 elements:
- * Baud Rate (x100) , TMC, BR
- *
- * Baud Rate = FCLK / TMC / 2^BR
- * Baud table for Crystal freq. of 9.8304 Mhz
- */
-#ifdef N2_TEST_SPEED
-struct rate_line {
- int target; /* target rate/100 */
- int tmc_reg; /* TMC register value */
- int br_reg; /* BR (BaudRateClk) selector */
-} n2_rates[] = {
- /* Baudx100 TMC BR */
- { 3, 128, 8 },
- { 6, 128, 7 },
- { 12, 128, 6 },
- { 24, 128, 5 },
- { 48, 128, 4 },
- { 96, 128, 3 },
- { 192, 128, 2 },
- { 384, 128, 1 },
- { 560, 88, 1 },
- { 640, 77, 1 },
- { 1280, 38, 1 },
- { 2560, 19, 1 },
- { 5120, 10, 1 },
- { 10000, 5, 1 },
- { 15000, 3, 1 },
- { 25000, 2, 1 },
- { 50000, 1, 1 },
- { 0, 0, 0 }
-};
-
-int sr_test_speed[] = {
- N2_TEST_SPEED,
- N2_TEST_SPEED
-};
-
-int etc0vals[] = {
- SR_MCR_ETC0, /* ISA channel 0 */
- SR_MCR_ETC1, /* ISA channel 1 */
- SR_FECR_ETC0, /* PCI channel 0 */
- SR_FECR_ETC1 /* PCI channel 1 */
-};
-#endif
-
-struct sr_hardc *srattach_pci(int unit, vm_offset_t plx_vaddr,
- vm_offset_t sca_vaddr);
-void srintr_hc(struct sr_hardc *hc);
-
-static ointhand2_t srintr;
-
-static int srattach(struct sr_hardc *hc);
-static void sr_xmit(struct sr_softc *sc);
-#ifndef NETGRAPH
-static void srstart(struct ifnet *ifp);
-static int srioctl(struct ifnet *ifp, u_long cmd, caddr_t data);
-static void srwatchdog(struct ifnet *ifp);
-#else
-static void srstart(struct sr_softc *sc);
-static void srwatchdog(struct sr_softc *sc);
-#endif /* NETGRAPH */
-static int sr_packet_avail(struct sr_softc *sc, int *len, u_char *rxstat);
-static void sr_copy_rxbuf(struct mbuf *m, struct sr_softc *sc, int len);
-static void sr_eat_packet(struct sr_softc *sc, int single);
-static void sr_get_packets(struct sr_softc *sc);
-
-static void sr_up(struct sr_softc *sc);
-static void sr_down(struct sr_softc *sc);
-static void src_init(struct sr_hardc *hc);
-static void sr_init_sca(struct sr_hardc *hc);
-static void sr_init_msci(struct sr_softc *sc);
-static void sr_init_rx_dmac(struct sr_softc *sc);
-static void sr_init_tx_dmac(struct sr_softc *sc);
-static void sr_dmac_intr(struct sr_hardc *hc, u_char isr);
-static void sr_msci_intr(struct sr_hardc *hc, u_char isr);
-static void sr_timer_intr(struct sr_hardc *hc, u_char isr);
-#ifndef NETGRAPH
-static void sr_modemck(void *x);
-#else
-static void sr_modemck(struct sr_softc *x);
-#endif /* NETGRAPH */
-
-static u_int src_get8_io(u_int base, u_int off);
-static u_int src_get16_io(u_int base, u_int off);
-static void src_put8_io(u_int base, u_int off, u_int val);
-static void src_put16_io(u_int base, u_int off, u_int val);
-static u_int src_get8_mem(u_int base, u_int off);
-static u_int src_get16_mem(u_int base, u_int off);
-static void src_put8_mem(u_int base, u_int off, u_int val);
-static void src_put16_mem(u_int base, u_int off, u_int val);
-
-#ifndef NETGRAPH
-#if NFR > 0
-extern void fr_detach(struct ifnet *);
-extern int fr_attach(struct ifnet *);
-extern int fr_ioctl(struct ifnet *, int, caddr_t);
-extern void fr_flush(struct ifnet *);
-extern int fr_input(struct ifnet *, struct mbuf *);
-extern struct mbuf *fr_dequeue(struct ifnet *);
-#endif
-#else
-static void ngsr_watchdog_frame(void * arg);
-static void ngsr_init(void* ignored);
-
-static ng_constructor_t ngsr_constructor;
-static ng_rcvmsg_t ngsr_rcvmsg;
-static ng_shutdown_t ngsr_rmnode;
-static ng_newhook_t ngsr_newhook;
-/*static ng_findhook_t ngsr_findhook; */
-static ng_connect_t ngsr_connect;
-static ng_rcvdata_t ngsr_rcvdata;
-static ng_disconnect_t ngsr_disconnect;
-
-static struct ng_type typestruct = {
- NG_VERSION,
- NG_SR_NODE_TYPE,
- NULL,
- ngsr_constructor,
- ngsr_rcvmsg,
- ngsr_rmnode,
- ngsr_newhook,
- NULL,
- ngsr_connect,
- ngsr_rcvdata,
- ngsr_rcvdata,
- ngsr_disconnect,
- NULL
-};
-
-static int ngsr_done_init = 0;
-#endif /* NETGRAPH */
-
-/*
- * I/O for ISA N2 card(s)
- */
-#define SRC_REG(iobase,y) ((((y) & 0xf) + (((y) & 0xf0) << 6) + \
- (iobase)) | 0x8000)
-
-static u_int
-src_get8_io(u_int base, u_int off)
-{
- return inb(SRC_REG(base, off));
-}
-
-static u_int
-src_get16_io(u_int base, u_int off)
-{
- return inw(SRC_REG(base, off));
-}
-
-static void
-src_put8_io(u_int base, u_int off, u_int val)
-{
- outb(SRC_REG(base, off), val);
-}
-
-static void
-src_put16_io(u_int base, u_int off, u_int val)
-{
- outw(SRC_REG(base, off), val);
-}
-
-/*
- * I/O for PCI N2 card(s)
- */
-#define SRC_PCI_SCA_REG(y) ((y & 2) ? ((y & 0xfd) + 0x100) : y)
-
-static u_int
-src_get8_mem(u_int base, u_int off)
-{
- return *((u_char *)(base + SRC_PCI_SCA_REG(off)));
-}
-
-static u_int
-src_get16_mem(u_int base, u_int off)
-{
- return *((u_short *)(base + SRC_PCI_SCA_REG(off)));
-}
-
-static void
-src_put8_mem(u_int base, u_int off, u_int val)
-{
- *((u_char *)(base + SRC_PCI_SCA_REG(off))) = (u_char)val;
-}
-
-static void
-src_put16_mem(u_int base, u_int off, u_int val)
-{
- *((u_short *)(base + SRC_PCI_SCA_REG(off))) = (u_short)val;
-}
-
-/*
- * Probe for an ISA card. If it is there, size its memory. Then get the
- * rest of its information and fill it in.
- */
-static int
-srprobe(struct isa_device *id)
-{
- struct sr_hardc *hc = &sr_hardc[id->id_unit];
- u_int pgs, i, tmp;
- u_short port;
- u_short *smem;
- u_char mar;
- sca_regs *sca = 0;
-
- /*
- * Now see if the card is realy there.
- */
- hc->cardtype = SR_CRD_N2;
-
- /*
- * We have to fill these in early because the SRC_PUT* and SRC_GET*
- * macros use them.
- */
- hc->src_get8 = src_get8_io;
- hc->src_get16 = src_get16_io;
- hc->src_put8 = src_put8_io;
- hc->src_put16 = src_put16_io;
-
- hc->sca = 0;
- port = id->id_iobase;
- hc->numports = NCHAN; /* assumed # of channels on the card */
-
- if (id->id_flags & SR_FLAGS_NCHAN_MSK)
- hc->numports = id->id_flags & SR_FLAGS_NCHAN_MSK;
-
- outb(port + SR_PCR, 0); /* turn off the card */
-
- /*
- * Next, we'll test the Base Address Register to retension of
- * data... ... seeing if we're *really* talking to an N2.
- */
- for (i = 0; i < 0x100; i++) {
- outb(port + SR_BAR, i);
- inb(port + SR_PCR);
- tmp = inb(port + SR_BAR);
- if (tmp != i) {
- printf("sr%d: probe failed BAR %x, %x.\n",
- id->id_unit, i, tmp);
- return 0;
- }
- }
-
- /*
- * Now see if we can see the SCA.
- */
- outb(port + SR_PCR, SR_PCR_SCARUN | inb(port + SR_PCR));
- SRC_PUT8(port, sca->wcrl, 0);
- SRC_PUT8(port, sca->wcrm, 0);
- SRC_PUT8(port, sca->wcrh, 0);
- SRC_PUT8(port, sca->pcr, 0);
- SRC_PUT8(port, sca->msci[0].tmc, 0);
- inb(port);
-
- tmp = SRC_GET8(port, sca->msci[0].tmc);
- if (tmp != 0) {
- printf("sr%d: Error reading SCA 0, %x\n", id->id_unit, tmp);
- return 0;
- }
- SRC_PUT8(port, sca->msci[0].tmc, 0x5A);
- inb(port);
-
- tmp = SRC_GET8(port, sca->msci[0].tmc);
- if (tmp != 0x5A) {
- printf("sr%d: Error reading SCA 0x5A, %x\n", id->id_unit, tmp);
- return 0;
- }
- SRC_PUT16(port, sca->dmac[0].cda, 0);
- inb(port);
-
- tmp = SRC_GET16(port, sca->dmac[0].cda);
- if (tmp != 0) {
- printf("sr%d: Error reading SCA 0, %x\n", id->id_unit, tmp);
- return 0;
- }
- SRC_PUT16(port, sca->dmac[0].cda, 0x55AA);
- inb(port);
-
- tmp = SRC_GET16(port, sca->dmac[0].cda);
- if (tmp != 0x55AA) {
- printf("sr%d: Error reading SCA 0x55AA, %x\n",
- id->id_unit, tmp);
- return 0;
- }
- /*
- * OK, the board's interface registers seem to work. Now we'll see
- * if the Dual-Ported RAM is fully accessible...
- */
- outb(port + SR_PCR, SR_PCR_EN_VPM | SR_PCR_ISA16);
- outb(port + SR_PSR, SR_PSR_WIN_16K);
-
- /*
- * Take the kernel "virtual" address supplied to us and convert
- * it to a "real" address. Then program the card to use that.
- */
- mar = (kvtop(id->id_maddr) >> 16) & SR_PCR_16M_SEL;
- outb(port + SR_PCR, mar | inb(port + SR_PCR));
- mar = kvtop(id->id_maddr) >> 12;
- outb(port + SR_BAR, mar);
- outb(port + SR_PCR, inb(port + SR_PCR) | SR_PCR_MEM_WIN);
- smem = (u_short *)id->id_maddr; /* DP RAM Address */
-
- /*
- * Here we will perform the memory scan to size the device.
- *
- * This is done by marking each potential page with a magic number.
- * We then loop through the pages looking for that magic number. As
- * soon as we no longer see that magic number, we'll quit the scan,
- * knowing that no more memory is present. This provides the number
- * of pages present on the card.
- *
- * Note: We're sizing 16K memory granules.
- */
- for (i = 0; i <= SR_PSR_PG_SEL; i++) {
- outb(port + SR_PSR,
- (inb(port + SR_PSR) & ~SR_PSR_PG_SEL) | i);
-
- *smem = 0xAA55;
- }
-
- for (i = 0; i <= SR_PSR_PG_SEL; i++) {
- outb(port + SR_PSR,
- (inb(port + SR_PSR) & ~SR_PSR_PG_SEL) | i);
-
- if (*smem != 0xAA55) {
- /*
- * If we have less than 64k of memory, give up. That
- * is 4 x 16k pages.
- */
- if (i < 4) {
- printf("sr%d: Bad mem page %d, mem %x, %x.\n",
- id->id_unit, i, 0xAA55, *smem);
- return 0;
- }
- break;
- }
- *smem = i;
- }
-
- hc->mempages = i;
- hc->memsize = i * SRC_WIN_SIZ;
- hc->winmsk = SRC_WIN_MSK;
- pgs = i; /* final count of 16K pages */
-
- /*
- * This next loop erases the contents of that page in DPRAM
- */
- for (i = 0; i <= pgs; i++) {
- outb(port + SR_PSR,
- (inb(port + SR_PSR) & ~SR_PSR_PG_SEL) | i);
- bzero(smem, SRC_WIN_SIZ);
- }
-
- SRC_SET_OFF(port);
-
- /*
- * We have a card here, fill in what we can.
- */
- id->id_msize = SRC_WIN_SIZ;
- hc->iobase = id->id_iobase;
- hc->sca_base = id->id_iobase;
- hc->mem_start = id->id_maddr;
- hc->mem_end = (id->id_maddr + id->id_msize) - 1;
- hc->mem_pstart = 0;
- hc->cunit = id->id_unit;
-
- /*
- * Do a little sanity check.
- */
- if (sr_irqtable[ffs(id->id_irq) - 1] == 0)
- printf("sr%d: Warning: illegal interrupt %d chosen.\n",
- id->id_unit, ffs(id->id_irq) - 1);
-
- /*
- * Bogus card configuration
- */
- if ((hc->numports > NCHAN) /* only 2 ports/card */
- ||(hc->memsize > (512 * 1024))) /* no more than 256K */
- return 0;
-
- return SRC_IO_SIZ; /* return the amount of IO addresses used. */
-}
-
-/*
- * srattach_isa and srattach_pci allocate memory for hardc, softc and
- * data buffers. It also does any initialization that is bus specific.
- * At the end they call the common srattach() function.
- */
-static int
-srattach_isa(struct isa_device *id)
-{
- u_char mar;
- struct sr_hardc *hc = &sr_hardc[id->id_unit];
-
- /*
- * Allocate the software interface table(s)
- */
- MALLOC(hc->sc, struct sr_softc *,
- hc->numports * sizeof(struct sr_softc), M_DEVBUF, M_WAITOK);
- if (hc->sc == NULL)
- return(0);
- bzero(hc->sc, hc->numports * sizeof(struct sr_softc));
-
- id->id_ointr = srintr;
-
- outb(hc->iobase + SR_PCR, inb(hc->iobase + SR_PCR) | SR_PCR_SCARUN);
- outb(hc->iobase + SR_PSR, inb(hc->iobase + SR_PSR) | SR_PSR_EN_SCA_DMA);
- outb(hc->iobase + SR_MCR,
- SR_MCR_DTR0 | SR_MCR_DTR1 | SR_MCR_TE0 | SR_MCR_TE1);
-
- SRC_SET_ON(hc->iobase);
-
- /*
- * Configure the card. Mem address, irq,
- */
- mar = (kvtop(id->id_maddr) >> 16) & SR_PCR_16M_SEL;
- outb(hc->iobase + SR_PCR,
- mar | (inb(hc->iobase + SR_PCR) & ~SR_PCR_16M_SEL));
- mar = kvtop(id->id_maddr) >> 12;
- outb(hc->iobase + SR_BAR, mar);
-
- /*
- * Get the TX clock direction and configuration. The default is a
- * single external clock which is used by RX and TX.
- */
-#ifdef N2_TEST_SPEED
- if (sr_test_speed[0] > 0)
- hc->sc[0].clk_cfg = SR_FLAGS_INT_CLK;
- else if (id->id_flags & SR_FLAGS_0_CLK_MSK)
- hc->sc[0].clk_cfg =
- (id->id_flags & SR_FLAGS_0_CLK_MSK)
- >> SR_FLAGS_CLK_SHFT;
-#else
- if (id->id_flags & SR_FLAGS_0_CLK_MSK)
- hc->sc[0].clk_cfg =
- (id->id_flags & SR_FLAGS_0_CLK_MSK)
- >> SR_FLAGS_CLK_SHFT;
-#endif
-
- if (hc->numports == 2)
-#ifdef N2_TEST_SPEED
- if (sr_test_speed[1] > 0)
- hc->sc[0].clk_cfg = SR_FLAGS_INT_CLK;
- else
-#endif
- if (id->id_flags & SR_FLAGS_1_CLK_MSK)
- hc->sc[1].clk_cfg = (id->id_flags & SR_FLAGS_1_CLK_MSK)
- >> (SR_FLAGS_CLK_SHFT + SR_FLAGS_CLK_CHAN_SHFT);
-
- return srattach(hc);
-}
-
-struct sr_hardc *
-srattach_pci(int unit, vm_offset_t plx_vaddr, vm_offset_t sca_vaddr)
-{
- int numports, pndx;
- u_int fecr, *fecrp = (u_int *)(sca_vaddr + SR_FECR);
- struct sr_hardc *hc, **hcp;
-
- /*
- * Configure the PLX. This is magic. I'm doing it just like I'm told
- * to. :-)
- *
- * offset
- * 0x00 - Map Range - Mem-mapped to locate anywhere
- * 0x04 - Re-Map - PCI address decode enable
- * 0x18 - Bus Region - 32-bit bus, ready enable
- * 0x1c - Master Range - include all 16 MB
- * 0x20 - Master RAM - Map SCA Base at 0
- * 0x28 - Master Remap - direct master memory enable
- * 0x68 - Interrupt - Enable interrupt (0 to disable)
- *
- * Note: This is "cargo cult" stuff. - jrc
- */
- *((u_int *)(plx_vaddr + 0x00)) = 0xfffff000;
- *((u_int *)(plx_vaddr + 0x04)) = 1;
- *((u_int *)(plx_vaddr + 0x18)) = 0x40030043;
- *((u_int *)(plx_vaddr + 0x1c)) = 0xff000000;
- *((u_int *)(plx_vaddr + 0x20)) = 0;
- *((u_int *)(plx_vaddr + 0x28)) = 0xe9;
- *((u_int *)(plx_vaddr + 0x68)) = 0x10900;
-
- /*
- * Get info from card.
- *
- * Only look for the second port if the first exists. Too many things
- * will break if we have only a second port.
- */
- fecr = *fecrp;
- numports = 0;
-
- if (((fecr & SR_FECR_ID0) >> SR_FE_ID0_SHFT) != SR_FE_ID_NONE) {
- numports++;
- if (((fecr & SR_FECR_ID1) >> SR_FE_ID1_SHFT) != SR_FE_ID_NONE)
- numports++;
- }
- if (numports == 0)
- return NULL;
-
- hc = sr_hardc_pci;
- hcp = &sr_hardc_pci;
-
- while (hc) {
- hcp = &hc->next;
- hc = hc->next;
- }
-
- MALLOC(hc, struct sr_hardc *, sizeof(*hc), M_DEVBUF, M_WAITOK);
- if (hc == NULL)
- return NULL;
- bzero(hc, sizeof(*hc));
-
- MALLOC(hc->sc, struct sr_softc *,
- numports * sizeof(struct sr_softc), M_DEVBUF, M_WAITOK);
- if (hc->sc == NULL) {
- FREE(hc, M_DEVBUF);
- return NULL;
- }
- bzero(hc->sc, numports * sizeof(struct sr_softc));
- *hcp = hc;
-
- hc->numports = numports;
- hc->cunit = unit;
- hc->cardtype = SR_CRD_N2PCI;
- hc->plx_base = (caddr_t)plx_vaddr;
- hc->sca_base = sca_vaddr;
-
- hc->src_put8 = src_put8_mem;
- hc->src_put16 = src_put16_mem;
- hc->src_get8 = src_get8_mem;
- hc->src_get16 = src_get16_mem;
-
- /*
- * Malloc area for tx and rx buffers. For now allocate SRC_WIN_SIZ
- * (16k) for each buffer.
- *
- * Allocate the block below 16M because the N2pci card can only access
- * 16M memory at a time.
- *
- * (We could actually allocate a contiguous block above the 16MB limit,
- * but this would complicate card programming more than we want to
- * right now -jrc)
- */
- hc->memsize = 2 * hc->numports * SRC_WIN_SIZ;
- hc->mem_start = contigmalloc(hc->memsize,
- M_DEVBUF,
- M_NOWAIT,
- 0ul,
- 0xfffffful,
- 0x10000,
- 0x1000000);
-
- if (hc->mem_start == NULL) {
- printf("src%d: pci: failed to allocate buffer space.\n", unit);
- return NULL;
- }
- hc->winmsk = 0xffffffff;
- hc->mem_end = (caddr_t)((u_int)hc->mem_start + hc->memsize);
- hc->mem_pstart = kvtop(hc->mem_start);
- bzero(hc->mem_start, hc->memsize);
-
- for (pndx = 0; pndx < numports; pndx++) {
- int intf_sw;
- struct sr_softc *sc;
-
- sc = &hc->sc[pndx];
-
- switch (pndx) {
- case 1:
- intf_sw = fecr & SR_FECR_ID1 >> SR_FE_ID1_SHFT;
- break;
- case 0:
- default:
- intf_sw = fecr & SR_FECR_ID0 >> SR_FE_ID0_SHFT;
- }
-
-#ifdef N2_TEST_SPEED
- if (sr_test_speed[pndx] > 0)
- sc->clk_cfg = SR_FLAGS_INT_CLK;
- else
-#endif
- switch (intf_sw) {
- default:
- case SR_FE_ID_RS232:
- case SR_FE_ID_HSSI:
- case SR_FE_ID_RS422:
- case SR_FE_ID_TEST:
- break;
-
- case SR_FE_ID_V35:
- sc->clk_cfg = SR_FLAGS_EXT_SEP_CLK;
- break;
-
- case SR_FE_ID_X21:
- sc->clk_cfg = SR_FLAGS_EXT_CLK;
- break;
- }
- }
-
- *fecrp = SR_FECR_DTR0
- | SR_FECR_DTR1
- | SR_FECR_TE0
- | SR_FECR_TE1;
-
- srattach(hc);
-
- return hc;
-}
-
-/*
- * Register the ports on the adapter.
- * Fill in the info for each port.
-#ifndef NETGRAPH
- * Attach each port to sppp and bpf.
-#endif
- */
-static int
-srattach(struct sr_hardc *hc)
-{
- struct sr_softc *sc = hc->sc;
-#ifndef NETGRAPH
- struct ifnet *ifp;
-#endif /* NETGRAPH */
- int unit; /* index: channel w/in card */
-
- /*
- * Report Card configuration information before we start configuring
- * each channel on the card...
- */
- printf("src%d: %uK RAM (%d mempages) @ %08x-%08x, %u ports.\n",
- hc->cunit, hc->memsize / 1024, hc->mempages,
- (u_int)hc->mem_start, (u_int)hc->mem_end, hc->numports);
-
- src_init(hc);
- sr_init_sca(hc);
-
- /*
- * Now configure each port on the card.
- */
- for (unit = 0; unit < hc->numports; sc++, unit++) {
- sc->hc = hc;
- sc->subunit = unit;
- sc->unit = next_sc_unit;
- next_sc_unit++;
- sc->scachan = unit % NCHAN;
-
- sr_init_rx_dmac(sc);
- sr_init_tx_dmac(sc);
- sr_init_msci(sc);
-
- printf("sr%d: Adapter %d, port %d.\n",
- sc->unit, hc->cunit, sc->subunit);
-
-#ifndef NETGRAPH
- ifp = &sc->ifsppp.pp_if;
- ifp->if_softc = sc;
- ifp->if_unit = sc->unit;
- ifp->if_name = "sr";
- ifp->if_mtu = PP_MTU;
- ifp->if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
- ifp->if_ioctl = srioctl;
- ifp->if_start = srstart;
- ifp->if_watchdog = srwatchdog;
-
- /*
- * Despite the fact that we want to allow both PPP *and*
- * Frame Relay access to a channel, due to the architecture
- * of the system, we'll have to do the attach here.
- *
- * At some point I'll defer the attach to the "up" call and
- * have the attach/detach performed when the interface is
- * up/downed...
- */
- sc->attached = 0;
- sc->protocol = N2_USE_PPP; /* default protocol */
-
-#if 0
- sc->ifsppp.pp_flags = PP_KEEPALIVE;
- sppp_attach((struct ifnet *)&sc->ifsppp);
-#endif
-
- if_attach(ifp);
-
- bpfattach(ifp, DLT_PPP, PPP_HEADER_LEN);
-#else /* NETGRAPH */
- /*
- * we have found a node, make sure our 'type' is availabe.
- */
- if (ngsr_done_init == 0) ngsr_init(NULL);
- if (ng_make_node_common(&typestruct, &sc->node) != 0)
- return (0);
- sc->node->private = sc;
- callout_handle_init(&sc->handle);
- sc->xmitq.ifq_maxlen = IFQ_MAXLEN;
- sc->xmitq_hipri.ifq_maxlen = IFQ_MAXLEN;
- sprintf(sc->nodename, "%s%d", NG_SR_NODE_TYPE, sc->unit);
- if (ng_name_node(sc->node, sc->nodename)) {
- ng_rmnode(sc->node);
- ng_unref(sc->node);
- return (0);
- }
- sc->running = 0;
-#endif /* NETGRAPH */
- }
-
- if (hc->mempages)
- SRC_SET_OFF(hc->iobase);
-
- return 1;
-}
-
-/*
- * N2 Interrupt Service Routine
- *
- * First figure out which SCA gave the interrupt.
- * Process it.
- * See if there is other interrupts pending.
- * Repeat until there no interrupts remain.
- */
-static void
-srintr(int unit)
-{
- struct sr_hardc *hc;
-
- hc = &sr_hardc[unit];
- srintr_hc(hc);
-
- return;
-}
-
-void
-srintr_hc(struct sr_hardc *hc)
-{
- sca_regs *sca = hc->sca; /* MSCI register tree */
- u_char isr0, isr1, isr2; /* interrupt statii captured */
-
-#if BUGGY > 1
- printf("sr: srintr_hc(hc=%08x)\n", hc);
-#endif
-
- /*
- * Since multiple interfaces may share this interrupt, we must loop
- * until no interrupts are still pending service.
- */
- while (1) {
- /*
- * Read all three interrupt status registers from the N2
- * card...
- */
- isr0 = SRC_GET8(hc->sca_base, sca->isr0);
- isr1 = SRC_GET8(hc->sca_base, sca->isr1);
- isr2 = SRC_GET8(hc->sca_base, sca->isr2);
-
- /*
- * If all three registers returned 0, we've finished
- * processing interrupts from this device, so we can quit
- * this loop...
- */
- if ((isr0 | isr1 | isr2) == 0)
- break;
-
-#if BUGGY > 2
- printf("src%d: srintr_hc isr0 %x, isr1 %x, isr2 %x\n",
-#ifndef NETGRAPH
- unit, isr0, isr1, isr2);
-#else
- hc->cunit, isr0, isr1, isr2);
-#endif /* NETGRAPH */
-#endif
-
- /*
- * Now we can dispatch the interrupts. Since we don't expect
- * either MSCI or timer interrupts, we'll test for DMA
- * interrupts first...
- */
- if (isr1) /* DMA-initiated interrupt */
- sr_dmac_intr(hc, isr1);
-
- if (isr0) /* serial part IRQ? */
- sr_msci_intr(hc, isr0);
-
- if (isr2) /* timer-initiated interrupt */
- sr_timer_intr(hc, isr2);
- }
-}
-
-/*
- * This will only start the transmitter. It is assumed that the data
- * is already there.
- * It is normally called from srstart() or sr_dmac_intr().
- */
-static void
-sr_xmit(struct sr_softc *sc)
-{
- u_short cda_value; /* starting descriptor */
- u_short eda_value; /* ending descriptor */
- struct sr_hardc *hc;
-#ifndef NETGRAPH
- struct ifnet *ifp; /* O/S Network Services */
-#endif /* NETGRAPH */
- dmac_channel *dmac; /* DMA channel registers */
-
-#if BUGGY > 0
- printf("sr: sr_xmit( sc=%08x)\n", sc);
-#endif
-
- hc = sc->hc;
-#ifndef NETGRAPH
- ifp = &sc->ifsppp.pp_if;
-#endif /* NETGRAPH */
- dmac = &hc->sca->dmac[DMAC_TXCH(sc->scachan)];
-
- /*
- * Get the starting and ending addresses of the chain to be
- * transmitted and pass these on to the DMA engine on-chip.
- */
- cda_value = sc->block[sc->txb_next_tx].txdesc + hc->mem_pstart;
- cda_value &= 0x00ffff;
- eda_value = sc->block[sc->txb_next_tx].txeda + hc->mem_pstart;
- eda_value &= 0x00ffff;
-
- SRC_PUT16(hc->sca_base, dmac->cda, cda_value);
- SRC_PUT16(hc->sca_base, dmac->eda, eda_value);
-
- /*
- * Now we'll let the DMA status register know about this change
- */
- SRC_PUT8(hc->sca_base, dmac->dsr, SCA_DSR_DE);
-
- sc->xmit_busy = 1; /* mark transmitter busy */
-
-#if BUGGY > 2
- printf("sr%d: XMIT cda=%04x, eda=%4x, rcda=%08lx\n",
- sc->unit, cda_value, eda_value,
- sc->block[sc->txb_next_tx].txdesc + hc->mem_pstart);
-#endif
-
- sc->txb_next_tx++; /* update next transmit seq# */
-
- if (sc->txb_next_tx == SR_TX_BLOCKS) /* handle wrap... */
- sc->txb_next_tx = 0;
-
-#ifndef NETGRAPH
- /*
- * Finally, we'll set a timout (which will start srwatchdog())
- * within the O/S network services layer...
- */
- ifp->if_timer = 2; /* Value in seconds. */
-#else
- /*
- * Don't time out for a while.
- */
- sc->out_dog = DOG_HOLDOFF; /* give ourself some breathing space*/
-#endif /* NETGRAPH */
-}
-
-/*
- * This function will be called from the upper level when a user add a
- * packet to be send, and from the interrupt handler after a finished
- * transmit.
- *
- * NOTE: it should run at spl_imp().
- *
- * This function only place the data in the oncard buffers. It does not
- * start the transmition. sr_xmit() does that.
- *
- * Transmitter idle state is indicated by the IFF_OACTIVE flag.
- * The function that clears that should ensure that the transmitter
- * and its DMA is in a "good" idle state.
- */
-#ifndef NETGRAPH
-static void
-srstart(struct ifnet *ifp)
-{
- struct sr_softc *sc; /* channel control structure */
-#else
-static void
-srstart(struct sr_softc *sc)
-{
-#endif /* NETGRAPH */
- struct sr_hardc *hc; /* card control/config block */
- int len; /* total length of a packet */
- int pkts; /* packets placed in DPRAM */
- int tlen; /* working length of pkt */
- u_int i;
- struct mbuf *mtx; /* message buffer from O/S */
- u_char *txdata; /* buffer address in DPRAM */
- sca_descriptor *txdesc; /* working descriptor pointr */
- struct buf_block *blkp;
-
-#ifndef NETGRAPH
-#if BUGGY > 0
- printf("sr: srstart( ifp=%08x)\n", ifp);
-#endif
- sc = ifp->if_softc;
- if ((ifp->if_flags & IFF_RUNNING) == 0)
- return;
-#endif /* NETGRAPH */
- hc = sc->hc;
- /*
- * It is OK to set the memory window outside the loop because all tx
- * buffers and descriptors are assumed to be in the same 16K window.
- */
- if (hc->mempages) {
- SRC_SET_ON(hc->iobase);
- SRC_SET_MEM(hc->iobase, sc->block[0].txdesc);
- }
-
- /*
- * Loop to place packets into DPRAM.
- *
- * We stay in this loop until there is nothing in
- * the TX queue left or the tx buffers are full.
- */
-top_srstart:
-
- /*
- * See if we have space for more packets.
- */
- if (sc->txb_inuse == SR_TX_BLOCKS) { /* out of space? */
-#ifndef NETGRAPH
- ifp->if_flags |= IFF_OACTIVE; /* yes, mark active */
-#else
- /*ifp->if_flags |= IFF_OACTIVE;*/ /* yes, mark active */
-#endif /* NETGRAPH */
-
- if (hc->mempages)
- SRC_SET_OFF(hc->iobase);
-
-#if BUGGY > 9
- printf("sr%d.srstart: sc->txb_inuse=%d; DPRAM full...\n",
- sc->unit, sc->txb_inuse);
-#endif
- return;
- }
- /*
- * OK, the card can take more traffic. Let's see if there's any
- * pending from the system...
- *
- * NOTE:
- * The architecture of the networking interface doesn't
- * actually call us like 'write()', providing an address. We get
- * started, a lot like a disk strategy routine, and we actually call
- * back out to the system to get traffic to send...
- *
- * NOTE:
- * If we were gonna run through another layer, we would use a
- * dispatch table to select the service we're getting a packet
- * from...
- */
-#ifndef NETGRAPH
- switch (sc->protocol) {
-#if NFR > 0
- case N2_USE_FRP:
- mtx = fr_dequeue(ifp);
- break;
-#endif
- case N2_USE_PPP:
- default:
- mtx = sppp_dequeue(ifp);
- }
-#else /* NETGRAPH */
- IF_DEQUEUE(&sc->xmitq_hipri, mtx);
- if (mtx == NULL) {
- IF_DEQUEUE(&sc->xmitq, mtx);
- }
-#endif /* NETGRAPH */
- if (!mtx) {
- if (hc->mempages)
- SRC_SET_OFF(hc->iobase);
- return;
- }
- /*
- * OK, we got a packet from the network services of the O/S. Now we
- * can move it into the DPRAM (under control of the descriptors) and
- * fire it off...
- */
- pkts = 0;
- i = 0; /* counts # of granules used */
-
- blkp = &sc->block[sc->txb_new]; /* address of free granule */
- txdesc = (sca_descriptor *)
- (hc->mem_start + (blkp->txdesc & hc->winmsk));
-
- txdata = (u_char *)(hc->mem_start
- + (blkp->txstart & hc->winmsk));
-
- /*
- * Now we'll try to install as many packets as possible into the
- * card's DP RAM buffers.
- */
- for (;;) { /* perform actual copy of packet */
- len = mtx->m_pkthdr.len; /* length of message */
-
-#if BUGGY > 1
- printf("sr%d.srstart: mbuf @ %08lx, %d bytes\n",
- sc->unit, mtx, len);
-#endif
-
-#ifndef NETGRAPH
- if (ifp->if_bpf)
- bpf_mtap(ifp, mtx);
-#else /* NETGRAPH */
- sc->outbytes += len;
-#endif /* NETGRAPH */
-
- /*
- * We can perform a straight copy because the tranmit
- * buffers won't wrap.
- */
- m_copydata(mtx, 0, len, txdata);
-
- /*
- * Now we know how big the message is gonna be. We must now
- * construct the descriptors to drive this message out...
- */
- tlen = len;
- while (tlen > SR_BUF_SIZ) { /* loop for full granules */
- txdesc->stat = 0; /* reset bits */
- txdesc->len = SR_BUF_SIZ; /* size of granule */
- tlen -= SR_BUF_SIZ;
-
- txdesc++; /* move to next dscr */
- txdata += SR_BUF_SIZ; /* adjust data addr */
- i++;
- }
-
- /*
- * This section handles the setting of the final piece of a
- * message.
- */
- txdesc->stat = SCA_DESC_EOM;
- txdesc->len = tlen;
- pkts++;
-
- /*
- * prepare for subsequent packets (if any)
- */
- txdesc++;
- txdata += SR_BUF_SIZ; /* next mem granule */
- i++; /* count of granules */
-
- /*
- * OK, we've now placed the message into the DPRAM where it
- * can be transmitted. We'll now release the message memory
- * and update the statistics...
- */
- m_freem(mtx);
-#ifndef NETGRAPH
- ++sc->ifsppp.pp_if.if_opackets;
-#else /* NETGRAPH */
- sc->opackets++;
-#endif /* NETGRAPH */
-
- /*
- * Check if we have space for another packet. XXX This is
- * hardcoded. A packet can't be larger than 3 buffers (3 x
- * 512).
- */
- if ((i + 3) >= blkp->txmax) { /* enough remains? */
-#if BUGGY > 9
- printf("sr%d.srstart: i=%d (%d pkts); card full.\n",
- sc->unit, i, pkts);
-#endif
- break;
- }
- /*
- * We'll pull the next message to be sent (if any)
- */
-#ifndef NETGRAPH
- switch (sc->protocol) {
-#if NFR > 0
- case N2_USE_FRP:
- mtx = fr_dequeue(ifp);
- break;
-#endif
- case N2_USE_PPP:
- default:
- mtx = sppp_dequeue(ifp);
- }
-#else /* NETGRAPH */
- IF_DEQUEUE(&sc->xmitq_hipri, mtx);
- if (mtx == NULL) {
- IF_DEQUEUE(&sc->xmitq, mtx);
- }
-#endif /* NETGRAPH */
- if (!mtx) { /* no message? We're done! */
-#if BUGGY > 9
- printf("sr%d.srstart: pending=0, pkts=%d\n",
- sc->unit, pkts);
-#endif
- break;
- }
- }
-
- blkp->txtail = i; /* record next free granule */
-
- /*
- * Mark the last descriptor, so that the SCA know where to stop.
- */
- txdesc--; /* back up to last descriptor in list */
- txdesc->stat |= SCA_DESC_EOT; /* mark as end of list */
-
- /*
- * Now we'll reset the transmit granule's descriptor address so we
- * can record this in the structure and fire it off w/ the DMA
- * processor of the serial chip...
- */
- txdesc = (sca_descriptor *)blkp->txdesc;
- blkp->txeda = (u_short)((u_int)&txdesc[i]);
-
- sc->txb_inuse++; /* update inuse status */
- sc->txb_new++; /* new traffic wuz added */
-
- if (sc->txb_new == SR_TX_BLOCKS)
- sc->txb_new = 0;
-
- /*
- * If the tranmitter wasn't marked as "busy" we will force it to be
- * started...
- */
- if (sc->xmit_busy == 0) {
- sr_xmit(sc);
-#if BUGGY > 9
- printf("sr%d.srstart: called sr_xmit()\n", sc->unit);
-#endif
- }
- goto top_srstart;
-}
-
-#ifndef NETGRAPH
-/*
- * Handle ioctl's at the device level, though we *will* call up
- * a layer...
- */
-#if BUGGY > 2
-static int bug_splats[] = {0, 0, 0, 0, 0, 0, 0, 0};
-#endif
-
-static int
-srioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
-{
- int s, error, was_up, should_be_up;
- struct sr_softc *sc = ifp->if_softc;
-
-#if BUGGY > 0
- printf("sr%d: srioctl(ifp=%08x, cmd=%08x, data=%08x)\n",
- ifp->if_unit, ifp, cmd, data);
-#endif
-
- was_up = ifp->if_flags & IFF_RUNNING;
-
- if (cmd == SIOCSIFFLAGS) {
- /*
- * First, handle an apparent protocol switch
- */
-#if NFR > 0
- if (was_up == 0)/* can only happen if DOWN */
- if (ifp->if_flags & IFF_LINK1)
- sc->protocol = N2_USE_FRP;
- else
- sc->protocol = N2_USE_PPP;
-#else
- sc->protocol = N2_USE_PPP;
- ifp->if_flags &= ~IFF_LINK1;
-#endif
-
- }
- /*
- * Next, we'll allow the network service layer we've called process
- * the ioctl...
- */
- if ((sc->attached != 0)
- && (sc->attached != sc->protocol)) {
- switch (sc->attached) {
-#if NFR > 0
- case N2_USE_FRP:
- fr_detach(ifp);
- break;
-#endif
- case N2_USE_PPP:
- default:
- sppp_detach(ifp);
- sc->ifsppp.pp_flags &= ~PP_KEEPALIVE;
- }
-
- sc->attached = 0;
- }
- if (sc->attached == 0) {
- switch (sc->protocol) {
-#if NFR > 0
- case N2_USE_FRP:
- fr_attach(&sc->ifsppp.pp_if);
- break;
-#endif
- case N2_USE_PPP:
- default:
- sc->ifsppp.pp_flags |= PP_KEEPALIVE;
- sppp_attach(&sc->ifsppp.pp_if);
-
- }
-
- sc->attached = sc->protocol;
- }
- switch (sc->protocol) {
-#if NFR > 0
- case N2_USE_FRP:
- error = fr_ioctl(ifp, cmd, data);
- break;
-#endif
- case N2_USE_PPP:
- default:
- error = sppp_ioctl(ifp, cmd, data);
- }
-
-#if BUGGY > 1
- printf("sr%d: ioctl: ifsppp.pp_flags = %08x, if_flags %08x.\n",
- ifp->if_unit, ((struct sppp *)ifp)->pp_flags, ifp->if_flags);
-#endif
-
- if (error)
- return error;
-
- if ((cmd != SIOCSIFFLAGS) && (cmd != SIOCSIFADDR)) {
-#if BUGGY > 2
- if (bug_splats[sc->unit]++ < 2) {
- printf("sr(%d).if_addrlist = %08x\n",
- sc->unit, ifp->if_addrlist);
- printf("sr(%d).if_bpf = %08x\n",
- sc->unit, ifp->if_bpf);
- printf("sr(%d).if_init = %08x\n",
- sc->unit, ifp->if_init);
- printf("sr(%d).if_output = %08x\n",
- sc->unit, ifp->if_output);
- printf("sr(%d).if_start = %08x\n",
- sc->unit, ifp->if_start);
- printf("sr(%d).if_done = %08x\n",
- sc->unit, ifp->if_done);
- printf("sr(%d).if_ioctl = %08x\n",
- sc->unit, ifp->if_ioctl);
- printf("sr(%d).if_reset = %08x\n",
- sc->unit, ifp->if_reset);
- printf("sr(%d).if_watchdog = %08x\n",
- sc->unit, ifp->if_watchdog);
- }
-#endif
- return 0;
- }
-
- s = splimp();
- should_be_up = ifp->if_flags & IFF_RUNNING;
-
- if (!was_up && should_be_up) {
- /*
- * Interface should be up -- start it.
- */
- sr_up(sc);
- srstart(ifp);
-
- /*
- * XXX Clear the IFF_UP flag so that the link will only go
- * up after sppp lcp and ipcp negotiation.
- */
- ifp->if_flags &= ~IFF_UP;
- } else if (was_up && !should_be_up) {
- /*
- * Interface should be down -- stop it.
- */
- sr_down(sc);
- switch (sc->protocol) {
-#if NFR > 0
- case N2_USE_FRP:
- fr_flush(ifp);
- break;
-#endif
- case N2_USE_PPP:
- default:
- sppp_flush(ifp);
- }
- }
- splx(s);
-
-#if BUGGY > 2
- if (bug_splats[sc->unit]++ < 2) {
- printf("sr(%d).if_addrlist = %08x\n",
- sc->unit, ifp->if_addrlist);
- printf("sr(%d).if_bpf = %08x\n",
- sc->unit, ifp->if_bpf);
- printf("sr(%d).if_init = %08x\n",
- sc->unit, ifp->if_init);
- printf("sr(%d).if_output = %08x\n",
- sc->unit, ifp->if_output);
- printf("sr(%d).if_start = %08x\n",
- sc->unit, ifp->if_start);
- printf("sr(%d).if_done = %08x\n",
- sc->unit, ifp->if_done);
- printf("sr(%d).if_ioctl = %08x\n",
- sc->unit, ifp->if_ioctl);
- printf("sr(%d).if_reset = %08x\n",
- sc->unit, ifp->if_reset);
- printf("sr(%d).if_watchdog = %08x\n",
- sc->unit, ifp->if_watchdog);
- }
-#endif
-
- return 0;
-}
-#endif /* NETGRAPH */
-
-/*
- * This is to catch lost tx interrupts.
- */
-static void
-#ifndef NETGRAPH
-srwatchdog(struct ifnet *ifp)
-#else
-srwatchdog(struct sr_softc *sc)
-#endif /* NETGRAPH */
-{
- int got_st0, got_st1, got_st3, got_dsr;
-#ifndef NETGRAPH
- struct sr_softc *sc = ifp->if_softc;
-#endif /* NETGRAPH */
- struct sr_hardc *hc = sc->hc;
- msci_channel *msci = &hc->sca->msci[sc->scachan];
- dmac_channel *dmac = &sc->hc->sca->dmac[sc->scachan];
-
-#if BUGGY > 0
-#ifndef NETGRAPH
- printf("srwatchdog(unit=%d)\n", unit);
-#else
- printf("srwatchdog(unit=%d)\n", sc->unit);
-#endif /* NETGRAPH */
-#endif
-
-#ifndef NETGRAPH
- if (!(ifp->if_flags & IFF_RUNNING))
- return;
-
- ifp->if_oerrors++; /* update output error count */
-#else /* NETGRAPH */
- sc->oerrors++; /* update output error count */
-#endif /* NETGRAPH */
-
- got_st0 = SRC_GET8(hc->sca_base, msci->st0);
- got_st1 = SRC_GET8(hc->sca_base, msci->st1);
- got_st3 = SRC_GET8(hc->sca_base, msci->st3);
- got_dsr = SRC_GET8(hc->sca_base, dmac->dsr);
-
-#ifndef NETGRAPH
-#if 0
- if (ifp->if_flags & IFF_DEBUG)
-#endif
- printf("sr%d: transmit failed, "
-#else /* NETGRAPH */
- printf("sr%d: transmit failed, "
-#endif /* NETGRAPH */
- "ST0 %02x, ST1 %02x, ST3 %02x, DSR %02x.\n",
- sc->unit,
- got_st0, got_st1, got_st3, got_dsr);
-
- if (SRC_GET8(hc->sca_base, msci->st1) & SCA_ST1_UDRN) {
- SRC_PUT8(hc->sca_base, msci->cmd, SCA_CMD_TXABORT);
- SRC_PUT8(hc->sca_base, msci->cmd, SCA_CMD_TXENABLE);
- SRC_PUT8(hc->sca_base, msci->st1, SCA_ST1_UDRN);
- }
- sc->xmit_busy = 0;
-#ifndef NETGRAPH
- ifp->if_flags &= ~IFF_OACTIVE;
-#else
- /*ifp->if_flags &= ~IFF_OACTIVE; */
-#endif /* NETGRAPH */
-
- if (sc->txb_inuse && --sc->txb_inuse)
- sr_xmit(sc);
-
-#ifndef NETGRAPH
- srstart(ifp); /* restart transmitter */
-#else
- srstart(sc); /* restart transmitter */
-#endif /* NETGRAPH */
-}
-
-static void
-sr_up(struct sr_softc *sc)
-{
- u_int *fecrp;
- struct sr_hardc *hc = sc->hc;
- sca_regs *sca = hc->sca;
- msci_channel *msci = &sca->msci[sc->scachan];
-
-#if BUGGY > 0
- printf("sr_up(sc=%08x)\n", sc);
-#endif
-
-#ifndef NETGRAPH
- /*
- * This section should really do the attach to the appropriate
- * system service, be it frame relay or PPP...
- */
- if (sc->attached == 0) {
- switch (sc->protocol) {
-#if NFR > 0
- case N2_USE_FRP:
- fr_attach(&sc->ifsppp.pp_if);
- break;
-#endif
- case N2_USE_PPP:
- default:
- sc->ifsppp.pp_flags |= PP_KEEPALIVE;
- sppp_attach(&sc->ifsppp.pp_if);
-
- }
-
- sc->attached = sc->protocol;
- }
-
-#endif /* NETGRAPH */
- /*
- * Enable transmitter and receiver. Raise DTR and RTS. Enable
- * interrupts.
- *
- * XXX What about using AUTO mode in msci->md0 ???
- */
- SRC_PUT8(hc->sca_base, msci->ctl,
- SRC_GET8(hc->sca_base, msci->ctl) & ~SCA_CTL_RTS);
-
- if (sc->scachan == 0)
- switch (hc->cardtype) {
- case SR_CRD_N2:
- outb(hc->iobase + SR_MCR,
- (inb(hc->iobase + SR_MCR) & ~SR_MCR_DTR0));
- break;
- case SR_CRD_N2PCI:
- fecrp = (u_int *)(hc->sca_base + SR_FECR);
- *fecrp &= ~SR_FECR_DTR0;
- break;
- }
- else
- switch (hc->cardtype) {
- case SR_CRD_N2:
- outb(hc->iobase + SR_MCR,
- (inb(hc->iobase + SR_MCR) & ~SR_MCR_DTR1));
- break;
- case SR_CRD_N2PCI:
- fecrp = (u_int *)(hc->sca_base + SR_FECR);
- *fecrp &= ~SR_FECR_DTR1;
- break;
- }
-
- if (sc->scachan == 0) {
- SRC_PUT8(hc->sca_base, sca->ier0,
- SRC_GET8(hc->sca_base, sca->ier0) | 0x000F);
- SRC_PUT8(hc->sca_base, sca->ier1,
- SRC_GET8(hc->sca_base, sca->ier1) | 0x000F);
- } else {
- SRC_PUT8(hc->sca_base, sca->ier0,
- SRC_GET8(hc->sca_base, sca->ier0) | 0x00F0);
- SRC_PUT8(hc->sca_base, sca->ier1,
- SRC_GET8(hc->sca_base, sca->ier1) | 0x00F0);
- }
-
- SRC_PUT8(hc->sca_base, msci->cmd, SCA_CMD_RXENABLE);
- inb(hc->iobase); /* XXX slow it down a bit. */
- SRC_PUT8(hc->sca_base, msci->cmd, SCA_CMD_TXENABLE);
-
-#ifndef NETGRAPH
-#ifdef USE_MODEMCK
- if (sr_watcher == 0)
- sr_modemck(NULL);
-#endif
-#else /* NETGRAPH */
- untimeout(ngsr_watchdog_frame, sc, sc->handle);
- sc->handle = timeout(ngsr_watchdog_frame, sc, hz);
- sc->running = 1;
-#endif /* NETGRAPH */
-}
-
-static void
-sr_down(struct sr_softc *sc)
-{
- u_int *fecrp;
- struct sr_hardc *hc = sc->hc;
- sca_regs *sca = hc->sca;
- msci_channel *msci = &sca->msci[sc->scachan];
-
-#if BUGGY > 0
- printf("sr_down(sc=%08x)\n", sc);
-#endif
-#ifdef NETGRAPH
- untimeout(ngsr_watchdog_frame, sc, sc->handle);
- sc->running = 0;
-#endif /* NETGRAPH */
-
- /*
- * Disable transmitter and receiver. Lower DTR and RTS. Disable
- * interrupts.
- */
- SRC_PUT8(hc->sca_base, msci->cmd, SCA_CMD_RXDISABLE);
- inb(hc->iobase); /* XXX slow it down a bit. */
- SRC_PUT8(hc->sca_base, msci->cmd, SCA_CMD_TXDISABLE);
-
- SRC_PUT8(hc->sca_base, msci->ctl,
- SRC_GET8(hc->sca_base, msci->ctl) | SCA_CTL_RTS);
-
- if (sc->scachan == 0)
- switch (hc->cardtype) {
- case SR_CRD_N2:
- outb(hc->iobase + SR_MCR,
- (inb(hc->iobase + SR_MCR) | SR_MCR_DTR0));
- break;
- case SR_CRD_N2PCI:
- fecrp = (u_int *)(hc->sca_base + SR_FECR);
- *fecrp |= SR_FECR_DTR0;
- break;
- }
- else
- switch (hc->cardtype) {
- case SR_CRD_N2:
- outb(hc->iobase + SR_MCR,
- (inb(hc->iobase + SR_MCR) | SR_MCR_DTR1));
- break;
- case SR_CRD_N2PCI:
- fecrp = (u_int *)(hc->sca_base + SR_FECR);
- *fecrp |= SR_FECR_DTR1;
- break;
- }
-
- if (sc->scachan == 0) {
- SRC_PUT8(hc->sca_base, sca->ier0,
- SRC_GET8(hc->sca_base, sca->ier0) & ~0x0F);
- SRC_PUT8(hc->sca_base, sca->ier1,
- SRC_GET8(hc->sca_base, sca->ier1) & ~0x0F);
- } else {
- SRC_PUT8(hc->sca_base, sca->ier0,
- SRC_GET8(hc->sca_base, sca->ier0) & ~0xF0);
- SRC_PUT8(hc->sca_base, sca->ier1,
- SRC_GET8(hc->sca_base, sca->ier1) & ~0xF0);
- }
-
-#ifndef NETGRAPH
- /*
- * This section does the detach from the currently configured net
- * service, be it frame relay or PPP...
- */
- switch (sc->protocol) {
-#if NFR > 0
- case N2_USE_FRP:
- fr_detach(&sc->ifsppp.pp_if);
- break;
-#endif
- case N2_USE_PPP:
- default:
- sppp_detach(&sc->ifsppp.pp_if);
- }
-
- sc->attached = 0;
-#endif /* NETGRAPH */
-}
-
-/*
- * Initialize the card, allocate memory for the sr_softc structures
- * and fill in the pointers.
- */
-static void
-src_init(struct sr_hardc *hc)
-{
- struct sr_softc *sc = hc->sc;
- int x;
- u_int chanmem;
- u_int bufmem;
- u_int next;
- u_int descneeded;
-
-#if BUGGY > 0
- printf("src_init(hc=%08x)\n", hc);
-#endif
-
- chanmem = hc->memsize / hc->numports;
- next = 0;
-
- for (x = 0; x < hc->numports; x++, sc++) {
- int blk;
-
- for (blk = 0; blk < SR_TX_BLOCKS; blk++) {
- sc->block[blk].txdesc = next;
- bufmem = (16 * 1024) / SR_TX_BLOCKS;
- descneeded = bufmem / SR_BUF_SIZ;
-
- sc->block[blk].txstart = sc->block[blk].txdesc
- + ((((descneeded * sizeof(sca_descriptor))
- / SR_BUF_SIZ) + 1)
- * SR_BUF_SIZ);
-
- sc->block[blk].txend = next + bufmem;
- sc->block[blk].txmax =
- (sc->block[blk].txend - sc->block[blk].txstart)
- / SR_BUF_SIZ;
- next += bufmem;
-
-#if BUGGY > 2
- printf("sr%d: blk %d: txdesc %08x, txstart %08x\n",
- sc->unit, blk,
- sc->block[blk].txdesc, sc->block[blk].txstart);
-#endif
- }
-
- sc->rxdesc = next;
- bufmem = chanmem - (bufmem * SR_TX_BLOCKS);
- descneeded = bufmem / SR_BUF_SIZ;
- sc->rxstart = sc->rxdesc +
- ((((descneeded * sizeof(sca_descriptor)) /
- SR_BUF_SIZ) + 1) * SR_BUF_SIZ);
- sc->rxend = next + bufmem;
- sc->rxmax = (sc->rxend - sc->rxstart) / SR_BUF_SIZ;
- next += bufmem;
- }
-}
-
-/*
- * The things done here are channel independent.
- *
- * Configure the sca waitstates.
- * Configure the global interrupt registers.
- * Enable master dma enable.
- */
-static void
-sr_init_sca(struct sr_hardc *hc)
-{
- sca_regs *sca = hc->sca;
-
-#if BUGGY > 0
- printf("sr_init_sca(hc=%08x)\n", hc);
-#endif
-
- /*
- * Do the wait registers. Set everything to 0 wait states.
- */
- SRC_PUT8(hc->sca_base, sca->pabr0, 0);
- SRC_PUT8(hc->sca_base, sca->pabr1, 0);
- SRC_PUT8(hc->sca_base, sca->wcrl, 0);
- SRC_PUT8(hc->sca_base, sca->wcrm, 0);
- SRC_PUT8(hc->sca_base, sca->wcrh, 0);
-
- /*
- * Configure the interrupt registers. Most are cleared until the
- * interface is configured.
- */
- SRC_PUT8(hc->sca_base, sca->ier0, 0x00); /* MSCI interrupts. */
- SRC_PUT8(hc->sca_base, sca->ier1, 0x00); /* DMAC interrupts */
- SRC_PUT8(hc->sca_base, sca->ier2, 0x00); /* TIMER interrupts. */
- SRC_PUT8(hc->sca_base, sca->itcr, 0x00); /* Use ivr and no intr
- * ack */
- SRC_PUT8(hc->sca_base, sca->ivr, 0x40); /* Interrupt vector. */
- SRC_PUT8(hc->sca_base, sca->imvr, 0x40);
-
- /*
- * Configure the timers. XXX Later
- */
-
- /*
- * Set the DMA channel priority to rotate between all four channels.
- *
- * Enable all dma channels.
- */
- SRC_PUT8(hc->sca_base, sca->pcr, SCA_PCR_PR2);
- SRC_PUT8(hc->sca_base, sca->dmer, SCA_DMER_EN);
-}
-
-/*
- * Configure the msci
- *
- * NOTE: The serial port configuration is hardcoded at the moment.
- */
-static void
-sr_init_msci(struct sr_softc *sc)
-{
- int portndx; /* on-board port number */
- u_int mcr_v; /* contents of modem control */
- u_int *fecrp; /* pointer for PCI's MCR i/o */
- struct sr_hardc *hc = sc->hc;
- msci_channel *msci = &hc->sca->msci[sc->scachan];
-#ifdef N2_TEST_SPEED
- int br_v; /* contents for BR divisor */
- int etcndx; /* index into ETC table */
- int fifo_v, gotspeed; /* final tabled speed found */
- int tmc_v; /* timer control register */
- int wanted; /* speed (bitrate) wanted... */
- struct rate_line *rtp;
-#endif
-
- portndx = sc->scachan;
-
-#if BUGGY > 0
- printf("sr: sr_init_msci( sc=%08x)\n", sc);
-#endif
-
- SRC_PUT8(hc->sca_base, msci->cmd, SCA_CMD_RESET);
- SRC_PUT8(hc->sca_base, msci->md0, SCA_MD0_CRC_1 |
- SCA_MD0_CRC_CCITT |
- SCA_MD0_CRC_ENABLE |
- SCA_MD0_MODE_HDLC);
- SRC_PUT8(hc->sca_base, msci->md1, SCA_MD1_NOADDRCHK);
- SRC_PUT8(hc->sca_base, msci->md2, SCA_MD2_DUPLEX | SCA_MD2_NRZ);
-
- /*
- * According to the manual I should give a reset after changing the
- * mode registers.
- */
- SRC_PUT8(hc->sca_base, msci->cmd, SCA_CMD_RXRESET);
- SRC_PUT8(hc->sca_base, msci->ctl, SCA_CTL_IDLPAT |
- SCA_CTL_UDRNC |
- SCA_CTL_RTS);
-
- /*
- * XXX Later we will have to support different clock settings.
- */
- switch (sc->clk_cfg) {
- default:
-#if BUGGY > 0
- printf("sr%: clk_cfg=%08x, selected default clock.\n",
- portndx, sc->clk_cfg);
-#endif
- /* FALLTHROUGH */
- case SR_FLAGS_EXT_CLK:
- /*
- * For now all interfaces are programmed to use the RX clock
- * for the TX clock.
- */
-
-#if BUGGY > 0
- printf("sr%d: External Clock Selected.\n", portndx);
-#endif
-
- SRC_PUT8(hc->sca_base, msci->rxs, 0);
- SRC_PUT8(hc->sca_base, msci->txs, 0);
- break;
-
- case SR_FLAGS_EXT_SEP_CLK:
-#if BUGGY > 0
- printf("sr%d: Split Clocking Selected.\n", portndx);
-#endif
-
-#if 1
- SRC_PUT8(hc->sca_base, msci->rxs, 0);
- SRC_PUT8(hc->sca_base, msci->txs, 0);
-#else
- SRC_PUT8(hc->sca_base, msci->rxs,
- SCA_RXS_CLK_RXC0 | SCA_RXS_DIV1);
-
- /*
- * We need to configure the internal bit clock for the
- * transmitter's channel...
- */
- SRC_PUT8(hc->sca_base, msci->txs,
- SCA_TXS_CLK_RX | SCA_TXS_DIV1);
-#endif
- break;
-
- case SR_FLAGS_INT_CLK:
-#if BUGGY > 0
- printf("sr%d: Internal Clocking selected.\n", portndx);
-#endif
-
- /*
- * XXX I do need some code to set the baud rate here!
- */
-#ifdef N2_TEST_SPEED
- switch (hc->cardtype) {
- case SR_CRD_N2PCI:
- fecrp = (u_int *)(hc->sca_base + SR_FECR);
- mcr_v = *fecrp;
- etcndx = 2;
- break;
- case SR_CRD_N2:
- default:
- mcr_v = inb(hc->iobase + SR_MCR);
- etcndx = 0;
- }
-
- fifo_v = 0x10; /* stolen from Linux version */
-
- /*
- * search for appropriate speed in table, don't calc it:
- */
- wanted = sr_test_speed[portndx];
- rtp = &n2_rates[0]; /* point to first table item */
-
- while ((rtp->target > 0) /* search table for speed */
- &&(rtp->target != wanted))
- rtp++;
-
- /*
- * We've searched the table for a matching speed. If we've
- * found the correct rate line, we'll get the pre-calc'd
- * values for the TMC and baud rate divisor for subsequent
- * use...
- */
- if (rtp->target > 0) { /* use table-provided values */
- gotspeed = wanted;
- tmc_v = rtp->tmc_reg;
- br_v = rtp->br_reg;
- } else { /* otherwise assume 1MBit comm rate */
- gotspeed = 10000;
- tmc_v = 5;
- br_v = 1;
- }
-
- /*
- * Now we mask in the enable clock output for the MCR:
- */
- mcr_v |= etc0vals[etcndx + portndx];
-
- /*
- * Now we'll program the registers with these speed- related
- * contents...
- */
- SRC_PUT8(hc->sca_base, msci->tmc, tmc_v);
- SRC_PUT8(hc->sca_base, msci->trc0, fifo_v);
- SRC_PUT8(hc->sca_base, msci->rxs, SCA_RXS_CLK_INT + br_v);
- SRC_PUT8(hc->sca_base, msci->txs, SCA_TXS_CLK_INT + br_v);
-
- switch (hc->cardtype) {
- case SR_CRD_N2PCI:
- *fecrp = mcr_v;
- break;
- case SR_CRD_N2:
- default:
- outb(hc->iobase + SR_MCR, mcr_v);
- }
-
-#if BUGGY > 0
- if (wanted != gotspeed)
- printf("sr%d: Speed wanted=%d, found=%d\n",
- wanted, gotspeed);
-
- printf("sr%d: Internal Clock %dx100 BPS, tmc=%d, div=%d\n",
- portndx, gotspeed, tmc_v, br_v);
-#endif
-#else
- SRC_PUT8(hc->sca_base, msci->rxs,
- SCA_RXS_CLK_INT | SCA_RXS_DIV1);
- SRC_PUT8(hc->sca_base, msci->txs,
- SCA_TXS_CLK_INT | SCA_TXS_DIV1);
-
- SRC_PUT8(hc->sca_base, msci->tmc, 5);
-
- if (portndx == 0)
- switch (hc->cardtype) {
- case SR_CRD_N2PCI:
- fecrp = (u_int *)(hc->sca_base + SR_FECR);
- *fecrp |= SR_FECR_ETC0;
- break;
- case SR_CRD_N2:
- default:
- mcr_v = inb(hc->iobase + SR_MCR);
- mcr_v |= SR_MCR_ETC0;
- outb(hc->iobase + SR_MCR, mcr_v);
- }
- else
- switch (hc->cardtype) {
- case SR_CRD_N2:
- mcr_v = inb(hc->iobase + SR_MCR);
- mcr_v |= SR_MCR_ETC1;
- outb(hc->iobase + SR_MCR, mcr_v);
- break;
- case SR_CRD_N2PCI:
- fecrp = (u_int *)(hc->sca_base + SR_FECR);
- *fecrp |= SR_FECR_ETC1;
- break;
- }
-#endif
- }
-
- /*
- * XXX Disable all interrupts for now. I think if you are using the
- * dmac you don't use these interrupts.
- */
- SRC_PUT8(hc->sca_base, msci->ie0, 0);
- SRC_PUT8(hc->sca_base, msci->ie1, 0x0C);
- SRC_PUT8(hc->sca_base, msci->ie2, 0);
- SRC_PUT8(hc->sca_base, msci->fie, 0);
-
- SRC_PUT8(hc->sca_base, msci->sa0, 0);
- SRC_PUT8(hc->sca_base, msci->sa1, 0);
-
- SRC_PUT8(hc->sca_base, msci->idl, 0x7E); /* set flags value */
-
- SRC_PUT8(hc->sca_base, msci->rrc, 0x0E);
- SRC_PUT8(hc->sca_base, msci->trc0, 0x10);
- SRC_PUT8(hc->sca_base, msci->trc1, 0x1F);
-}
-
-/*
- * Configure the rx dma controller.
- */
-static void
-sr_init_rx_dmac(struct sr_softc *sc)
-{
- struct sr_hardc *hc;
- dmac_channel *dmac;
- sca_descriptor *rxd;
- u_int cda_v, sarb_v, rxbuf, rxda, rxda_d;
-
-#if BUGGY > 0
- printf("sr_init_rx_dmac(sc=%08x)\n", sc);
-#endif
-
- hc = sc->hc;
- dmac = &hc->sca->dmac[DMAC_RXCH(sc->scachan)];
-
- if (hc->mempages)
- SRC_SET_MEM(hc->iobase, sc->rxdesc);
-
- /*
- * This phase initializes the contents of the descriptor table
- * needed to construct a circular buffer...
- */
- rxd = (sca_descriptor *)(hc->mem_start + (sc->rxdesc & hc->winmsk));
- rxda_d = (u_int) hc->mem_start - (sc->rxdesc & ~hc->winmsk);
-
- for (rxbuf = sc->rxstart;
- rxbuf < sc->rxend;
- rxbuf += SR_BUF_SIZ, rxd++) {
- /*
- * construct the circular chain...
- */
- rxda = (u_int) & rxd[1] - rxda_d + hc->mem_pstart;
- rxd->cp = (u_short)(rxda & 0xffff);
-
- /*
- * set the on-card buffer address...
- */
- rxd->bp = (u_short)((rxbuf + hc->mem_pstart) & 0xffff);
- rxd->bpb = (u_char)(((rxbuf + hc->mem_pstart) >> 16) & 0xff);
-
- rxd->len = 0; /* bytes resident w/in granule */
- rxd->stat = 0xff; /* The sca write here when finished */
- }
-
- /*
- * heal the chain so that the last entry points to the first...
- */
- rxd--;
- rxd->cp = (u_short)((sc->rxdesc + hc->mem_pstart) & 0xffff);
-
- /*
- * reset the reception handler's index...
- */
- sc->rxhind = 0;
-
- /*
- * We'll now configure the receiver's DMA logic...
- */
- SRC_PUT8(hc->sca_base, dmac->dsr, 0); /* Disable DMA transfer */
- SRC_PUT8(hc->sca_base, dmac->dcr, SCA_DCR_ABRT);
-
- /* XXX maybe also SCA_DMR_CNTE */
- SRC_PUT8(hc->sca_base, dmac->dmr, SCA_DMR_TMOD | SCA_DMR_NF);
- SRC_PUT16(hc->sca_base, dmac->bfl, SR_BUF_SIZ);
-
- cda_v = (u_short)((sc->rxdesc + hc->mem_pstart) & 0xffff);
- sarb_v = (u_char)(((sc->rxdesc + hc->mem_pstart) >> 16) & 0xff);
-
- SRC_PUT16(hc->sca_base, dmac->cda, cda_v);
- SRC_PUT8(hc->sca_base, dmac->sarb, sarb_v);
-
- rxd = (sca_descriptor *)sc->rxstart;
-
- SRC_PUT16(hc->sca_base, dmac->eda,
- (u_short)((u_int) & rxd[sc->rxmax - 1] & 0xffff));
-
- SRC_PUT8(hc->sca_base, dmac->dir, 0xF0);
-
-
- SRC_PUT8(hc->sca_base, dmac->dsr, SCA_DSR_DE); /* Enable DMA */
-}
-
-/*
- * Configure the TX DMA descriptors.
- * Initialize the needed values and chain the descriptors.
- */
-static void
-sr_init_tx_dmac(struct sr_softc *sc)
-{
- int blk;
- u_int txbuf, txda, txda_d;
- struct sr_hardc *hc;
- sca_descriptor *txd;
- dmac_channel *dmac;
- struct buf_block *blkp;
- u_int x;
- u_int sarb_v;
-
-#if BUGGY > 0
- printf("sr_init_tx_dmac(sc=%08x)\n", sc);
-#endif
-
- hc = sc->hc;
- dmac = &hc->sca->dmac[DMAC_TXCH(sc->scachan)];
-
- if (hc->mempages)
- SRC_SET_MEM(hc->iobase, sc->block[0].txdesc);
-
- /*
- * Initialize the array of descriptors for transmission
- */
- for (blk = 0; blk < SR_TX_BLOCKS; blk++) {
- blkp = &sc->block[blk];
- txd = (sca_descriptor *)(hc->mem_start
- + (blkp->txdesc & hc->winmsk));
- txda_d = (u_int) hc->mem_start
- - (blkp->txdesc & ~hc->winmsk);
-
- x = 0;
- txbuf = blkp->txstart;
- for (; txbuf < blkp->txend; txbuf += SR_BUF_SIZ, txd++) {
- txda = (u_int) & txd[1] - txda_d + hc->mem_pstart;
- txd->cp = (u_short)(txda & 0xffff);
-
- txd->bp = (u_short)((txbuf + hc->mem_pstart)
- & 0xffff);
- txd->bpb = (u_char)(((txbuf + hc->mem_pstart) >> 16)
- & 0xff);
- txd->len = 0;
- txd->stat = 0;
- x++;
- }
-
- txd--;
- txd->cp = (u_short)((blkp->txdesc + hc->mem_pstart)
- & 0xffff);
-
- blkp->txtail = (u_int)txd - (u_int)hc->mem_start;
- }
-
- SRC_PUT8(hc->sca_base, dmac->dsr, 0); /* Disable DMA */
- SRC_PUT8(hc->sca_base, dmac->dcr, SCA_DCR_ABRT);
- SRC_PUT8(hc->sca_base, dmac->dmr, SCA_DMR_TMOD | SCA_DMR_NF);
- SRC_PUT8(hc->sca_base, dmac->dir,
- SCA_DIR_EOT | SCA_DIR_BOF | SCA_DIR_COF);
-
- sarb_v = (sc->block[0].txdesc + hc->mem_pstart) >> 16;
- sarb_v &= 0x00ff;
-
- SRC_PUT8(hc->sca_base, dmac->sarb, (u_char) sarb_v);
-}
-
-/*
- * Look through the descriptors to see if there is a complete packet
- * available. Stop if we get to where the sca is busy.
- *
- * Return the length and status of the packet.
- * Return nonzero if there is a packet available.
- *
- * NOTE:
- * It seems that we get the interrupt a bit early. The updateing of
- * descriptor values is not always completed when this is called.
- */
-static int
-sr_packet_avail(struct sr_softc *sc, int *len, u_char *rxstat)
-{
- int granules; /* count of granules in pkt */
- int wki, wko;
- struct sr_hardc *hc;
- sca_descriptor *rxdesc; /* current descriptor */
- sca_descriptor *endp; /* ending descriptor */
- sca_descriptor *cda; /* starting descriptor */
-
- hc = sc->hc; /* get card's information */
-
- /*
- * set up starting descriptor by pulling that info from the DMA half
- * of the HD chip...
- */
- wki = DMAC_RXCH(sc->scachan);
- wko = SRC_GET16(hc->sca_base, hc->sca->dmac[wki].cda);
-
- cda = (sca_descriptor *)(hc->mem_start + (wko & hc->winmsk));
-
-#if BUGGY > 1
- printf("sr_packet_avail(): wki=%d, wko=%04x, cda=%08x\n",
- wki, wko, cda);
-#endif
-
- /*
- * open the appropriate memory window and set our expectations...
- */
- if (hc->mempages) {
- SRC_SET_MEM(hc->iobase, sc->rxdesc);
- SRC_SET_ON(hc->iobase);
- }
- rxdesc = (sca_descriptor *)
- (hc->mem_start + (sc->rxdesc & hc->winmsk));
- endp = rxdesc;
- rxdesc = &rxdesc[sc->rxhind];
- endp = &endp[sc->rxmax];
-
- *len = 0; /* reset result total length */
- granules = 0; /* reset count of granules */
-
- /*
- * This loop will scan descriptors, but it *will* puke up if we wrap
- * around to our starting point...
- */
- while (rxdesc != cda) {
- *len += rxdesc->len; /* increment result length */
- granules++;
-
- /*
- * If we hit a valid packet's completion we'll know we've
- * got a live one, and that we can deliver the packet.
- * Since we're only allowed to report a packet available,
- * somebody else does that...
- */
- if (rxdesc->stat & SCA_DESC_EOM) { /* End Of Message */
- *rxstat = rxdesc->stat; /* return closing */
-#if BUGGY > 0
- printf("sr%d: PKT AVAIL len %d, %x, bufs %u.\n",
- sc->unit, *len, *rxstat, granules);
-#endif
- return 1; /* indicate success */
- }
- /*
- * OK, this packet take up multiple granules. Move on to
- * the next descriptor so we can consider it...
- */
- rxdesc++;
-
- if (rxdesc == endp) /* recognize & act on wrap point */
- rxdesc = (sca_descriptor *)
- (hc->mem_start + (sc->rxdesc & hc->winmsk));
- }
-
- /*
- * Nothing found in the DPRAM. Let the caller know...
- */
- *len = 0;
- *rxstat = 0;
-
- return 0;
-}
-
-/*
- * Copy a packet from the on card memory into a provided mbuf.
- * Take into account that buffers wrap and that a packet may
- * be larger than a buffer.
- */
-static void
-sr_copy_rxbuf(struct mbuf *m, struct sr_softc *sc, int len)
-{
- struct sr_hardc *hc;
- sca_descriptor *rxdesc;
- u_int rxdata;
- u_int rxmax;
- u_int off = 0;
- u_int tlen;
-
-#if BUGGY > 0
- printf("sr_copy_rxbuf(m=%08x,sc=%08x,len=%d)\n",
- m, sc, len);
-#endif
-
- hc = sc->hc;
-
- rxdata = sc->rxstart + (sc->rxhind * SR_BUF_SIZ);
- rxmax = sc->rxstart + (sc->rxmax * SR_BUF_SIZ);
-
- rxdesc = (sca_descriptor *)
- (hc->mem_start + (sc->rxdesc & hc->winmsk));
- rxdesc = &rxdesc[sc->rxhind];
-
- /*
- * Using the count of bytes in the received packet, we decrement it
- * for each granule (controller by an SCA descriptor) to control the
- * looping...
- */
- while (len) {
- /*
- * tlen gets the length of *this* granule... ...which is
- * then copied to the target buffer.
- */
- tlen = (len < SR_BUF_SIZ) ? len : SR_BUF_SIZ;
-
- if (hc->mempages)
- SRC_SET_MEM(hc->iobase, rxdata);
-
- bcopy(hc->mem_start + (rxdata & hc->winmsk),
- mtod(m, caddr_t) +off,
- tlen);
-
- off += tlen;
- len -= tlen;
-
- /*
- * now, return to the descriptor's window in DPRAM and reset
- * the descriptor we've just suctioned...
- */
- if (hc->mempages)
- SRC_SET_MEM(hc->iobase, sc->rxdesc);
-
- rxdesc->len = 0;
- rxdesc->stat = 0xff;
-
- /*
- * Move on to the next granule. If we've any remaining
- * bytes to process we'll just continue in our loop...
- */
- rxdata += SR_BUF_SIZ;
- rxdesc++;
-
- if (rxdata == rxmax) { /* handle the wrap point */
- rxdata = sc->rxstart;
- rxdesc = (sca_descriptor *)
- (hc->mem_start + (sc->rxdesc & hc->winmsk));
- }
- }
-}
-
-/*
- * If single is set, just eat a packet. Otherwise eat everything up to
- * where cda points. Update pointers to point to the next packet.
- *
- * This handles "flushing" of a packet as received...
- *
- * If the "single" parameter is zero, all pending reeceive traffic will
- * be flushed out of existence. A non-zero value will only drop the
- * *next* (currently) pending packet...
- */
-static void
-sr_eat_packet(struct sr_softc *sc, int single)
-{
- struct sr_hardc *hc;
- sca_descriptor *rxdesc; /* current descriptor being eval'd */
- sca_descriptor *endp; /* last descriptor in chain */
- sca_descriptor *cda; /* current start point */
- u_int loopcnt = 0; /* count of packets flushed ??? */
- u_char stat; /* captured status byte from descr */
-
- hc = sc->hc;
- cda = (sca_descriptor *)(hc->mem_start +
- (SRC_GET16(hc->sca_base,
- hc->sca->dmac[DMAC_RXCH(sc->scachan)].cda) &
- hc->winmsk));
-
- /*
- * loop until desc->stat == (0xff || EOM) Clear the status and
- * length in the descriptor. Increment the descriptor.
- */
- if (hc->mempages)
- SRC_SET_MEM(hc->iobase, sc->rxdesc);
-
- rxdesc = (sca_descriptor *)
- (hc->mem_start + (sc->rxdesc & hc->winmsk));
- endp = rxdesc;
- rxdesc = &rxdesc[sc->rxhind];
- endp = &endp[sc->rxmax];
-
- /*
- * allow loop, but abort it if we wrap completely...
- */
- while (rxdesc != cda) {
- loopcnt++;
-
- if (loopcnt > sc->rxmax) {
- printf("sr%d: eat pkt %d loop, cda %x, "
- "rxdesc %x, stat %x.\n",
- sc->unit, loopcnt, (u_int) cda, (u_int) rxdesc,
- rxdesc->stat);
- break;
- }
- stat = rxdesc->stat;
-
- rxdesc->len = 0;
- rxdesc->stat = 0xff;
-
- rxdesc++;
- sc->rxhind++;
-
- if (rxdesc == endp) {
- rxdesc = (sca_descriptor *)
- (hc->mem_start + (sc->rxdesc & hc->winmsk));
- sc->rxhind = 0;
- }
- if (single && (stat == SCA_DESC_EOM))
- break;
- }
-
- /*
- * Update the eda to the previous descriptor.
- */
- rxdesc = (sca_descriptor *)sc->rxdesc;
- rxdesc = &rxdesc[(sc->rxhind + sc->rxmax - 2) % sc->rxmax];
-
- SRC_PUT16(hc->sca_base,
- hc->sca->dmac[DMAC_RXCH(sc->scachan)].eda,
- (u_short)((u_int)(rxdesc + hc->mem_pstart) & 0xffff));
-}
-
-/*
- * While there is packets available in the rx buffer, read them out
- * into mbufs and ship them off.
- */
-static void
-sr_get_packets(struct sr_softc *sc)
-{
- u_char rxstat; /* acquired status byte */
- int i;
- int pkts; /* count of packets found */
- int rxndx; /* rcv buffer index */
- int tries; /* settling time counter */
- u_int len; /* length of pending packet */
- struct sr_hardc *hc; /* card-level information */
- sca_descriptor *rxdesc; /* descriptor in memory */
-#ifndef NETGRAPH
- struct ifnet *ifp; /* network intf ctl table */
-#endif /* NETGRAPH */
- struct mbuf *m = NULL; /* message buffer */
-
-#if BUGGY > 0
- printf("sr_get_packets(sc=%08x)\n", sc);
-#endif
-
- hc = sc->hc;
-#ifndef NETGRAPH
- ifp = &sc->ifsppp.pp_if;
-#endif /* NETGRAPH */
-
- if (hc->mempages) {
- SRC_SET_MEM(hc->iobase, sc->rxdesc);
- SRC_SET_ON(hc->iobase); /* enable shared memory */
- }
- pkts = 0; /* reset count of found packets */
-
- /*
- * for each complete packet in the receiving pool, process each
- * packet...
- */
- while (sr_packet_avail(sc, &len, &rxstat)) { /* packet pending? */
- /*
- * I have seen situations where we got the interrupt but the
- * status value wasn't deposited. This code should allow
- * the status byte's value to settle...
- */
-
- tries = 5;
-
- while ((rxstat == 0x00ff)
- && --tries)
- sr_packet_avail(sc, &len, &rxstat);
-
-#if BUGGY > 1
- printf("sr_packet_avail() returned len=%d, rxstat=%02ux\n",
- len, rxstat);
-#endif
-
- pkts++;
-#ifdef NETGRAPH
- sc->inbytes += len;
- sc->inlast = 0;
-#endif /* NETGRAPH */
-
- /*
- * OK, we've settled the incoming message status. We can now
- * process it...
- */
- if (((rxstat & SCA_DESC_ERRORS) == 0) && (len < MCLBYTES)) {
-#if BUGGY > 1
- printf("sr%d: sr_get_packet() rxstat=%02x, len=%d\n",
- sc->unit, rxstat, len);
-#endif
-
- MGETHDR(m, M_DONTWAIT, MT_DATA);
- if (m == NULL) {
- /*
- * eat (flush) packet if get mbuf fail!!
- */
- sr_eat_packet(sc, 1);
- continue;
- }
- /*
- * construct control information for pass-off
- */
-#ifndef NETGRAPH
- m->m_pkthdr.rcvif = ifp;
-#else
- m->m_pkthdr.rcvif = NULL;
-#endif /* NETGRAPH */
- m->m_pkthdr.len = m->m_len = len;
- if (len > MHLEN) {
- MCLGET(m, M_DONTWAIT);
- if ((m->m_flags & M_EXT) == 0) {
- /*
- * We couldn't get a big enough
- * message packet, so we'll send the
- * packet to /dev/null...
- */
- m_freem(m);
- sr_eat_packet(sc, 1);
- continue;
- }
- }
- /*
- * OK, we've got a good message buffer. Now we can
- * copy the received message into it
- */
- sr_copy_rxbuf(m, sc, len); /* copy from DPRAM */
-
-#ifndef NETGRAPH
- if (ifp->if_bpf)
- bpf_mtap(ifp, m);
-
-#if BUGGY > 3
- {
- u_char *bp;
-
- bp = (u_char *)m;
- printf("sr%d: rcvd=%02x%02x%02x%02x%02x%02x\n",
- sc->unit,
- bp[0], bp[1], bp[2],
- bp[4], bp[5], bp[6]);
- }
-#endif
- /*
- * Pass off the message to PPP, connecting it it to
- * the system...
- */
- switch (sc->protocol) {
-#if NFR > 0
- case N2_USE_FRP:
- fr_input(ifp, m);
- break;
-#endif
- case N2_USE_PPP:
- default:
- sppp_input(ifp, m);
- }
-
- ifp->if_ipackets++;
-
-#else /* NETGRAPH */
-#if BUGGY > 3
- {
- u_char *bp;
-
- bp = mtod(m,u_char *);
- printf("sr%d: rd=%02x:%02x:%02x:%02x:%02x:%02x",
- sc->unit,
- bp[0], bp[1], bp[2],
- bp[4], bp[5], bp[6]);
- printf(":%02x:%02x:%02x:%02x:%02x:%02x\n",
- bp[6], bp[7], bp[8],
- bp[9], bp[10], bp[11]);
- }
-#endif
- ng_queue_data(sc->hook, m, NULL);
- sc->ipackets++;
-#endif /* NETGRAPH */
- /*
- * Update the eda to the previous descriptor.
- */
- i = (len + SR_BUF_SIZ - 1) / SR_BUF_SIZ;
- sc->rxhind = (sc->rxhind + i) % sc->rxmax;
-
- rxdesc = (sca_descriptor *)sc->rxdesc;
- rxndx = (sc->rxhind + sc->rxmax - 2) % sc->rxmax;
- rxdesc = &rxdesc[rxndx];
-
- SRC_PUT16(hc->sca_base,
- hc->sca->dmac[DMAC_RXCH(sc->scachan)].eda,
- (u_short)((u_int)(rxdesc + hc->mem_pstart)
- & 0xffff));
-
- } else {
- int got_st3, got_cda, got_eda;
- int tries = 5;
-
- while((rxstat == 0xff) && --tries)
- sr_packet_avail(sc, &len, &rxstat);
-
- /*
- * It look like we get an interrupt early
- * sometimes and then the status is not
- * filled in yet.
- */
- if(tries && (tries != 5))
- continue;
-
- /*
- * This chunk of code handles the error packets.
- * We'll log them for posterity...
- */
- sr_eat_packet(sc, 1);
-
-#ifndef NETGRAPH
- ifp->if_ierrors++;
-#else
- sc->ierrors[0]++;
-#endif /* NETGRAPH */
-
- got_st3 = SRC_GET8(hc->sca_base,
- hc->sca->msci[sc->scachan].st3);
- got_cda = SRC_GET16(hc->sca_base,
- hc->sca->dmac[DMAC_RXCH(sc->scachan)].cda);
- got_eda = SRC_GET16(hc->sca_base,
- hc->sca->dmac[DMAC_RXCH(sc->scachan)].eda);
-
-#if BUGGY > 0
- printf("sr%d: Receive error chan %d, "
- "stat %02x, msci st3 %02x,"
- "rxhind %d, cda %04x, eda %04x.\n",
- sc->unit, sc->scachan, rxstat,
- got_st3, sc->rxhind, got_cda, got_eda);
-#endif
- }
- }
-
-#if BUGGY > 0
- printf("sr%d: sr_get_packets() found %d packet(s)\n",
- sc->unit, pkts);
-#endif
-
- if (hc->mempages)
- SRC_SET_OFF(hc->iobase);
-}
-
-/*
- * All DMA interrupts come here.
- *
- * Each channel has two interrupts.
- * Interrupt A for errors and Interrupt B for normal stuff like end
- * of transmit or receive dmas.
- */
-static void
-sr_dmac_intr(struct sr_hardc *hc, u_char isr1)
-{
- u_char dsr; /* contents of DMA Stat Reg */
- u_char dotxstart; /* enables for tranmit part */
- int mch; /* channel being processed */
- struct sr_softc *sc; /* channel's softc structure */
- sca_regs *sca = hc->sca;
- dmac_channel *dmac; /* dma structure of chip */
-
-#if BUGGY > 0
- printf("sr_dmac_intr(hc=%08x,isr1=%04x)\n", hc, isr1);
-#endif
-
- mch = 0; /* assume chan0 on card */
- dotxstart = isr1; /* copy for xmitter starts */
-
- /*
- * Shortcut if there is no interrupts for dma channel 0 or 1.
- * Skip processing for channel 0 if no incoming hit
- */
- if ((isr1 & 0x0F) == 0) {
- mch = 1;
- isr1 >>= 4;
- }
- do {
- sc = &hc->sc[mch];
-
- /*
- * Transmit channel - DMA Status Register Evaluation
- */
- if (isr1 & 0x0C) {
- dmac = &sca->dmac[DMAC_TXCH(mch)];
-
- /*
- * get the DMA Status Register contents and write
- * back to reset interrupt...
- */
- dsr = SRC_GET8(hc->sca_base, dmac->dsr);
- SRC_PUT8(hc->sca_base, dmac->dsr, dsr);
-
- /*
- * Check for (& process) a Counter overflow
- */
- if (dsr & SCA_DSR_COF) {
- printf("sr%d: TX DMA Counter overflow, "
- "txpacket no %lu.\n",
-#ifndef NETGRAPH
- sc->unit, sc->ifsppp.pp_if.if_opackets);
- sc->ifsppp.pp_if.if_oerrors++;
-#else
- sc->unit, sc->opackets);
- sc->oerrors++;
-#endif /* NETGRAPH */
- }
- /*
- * Check for (& process) a Buffer overflow
- */
- if (dsr & SCA_DSR_BOF) {
- printf("sr%d: TX DMA Buffer overflow, "
- "txpacket no %lu, dsr %02x, "
- "cda %04x, eda %04x.\n",
-#ifndef NETGRAPH
- sc->unit, sc->ifsppp.pp_if.if_opackets,
-#else
- sc->unit, sc->opackets,
-#endif /* NETGRAPH */
- dsr,
- SRC_GET16(hc->sca_base, dmac->cda),
- SRC_GET16(hc->sca_base, dmac->eda));
-#ifndef NETGRAPH
- sc->ifsppp.pp_if.if_oerrors++;
-#else
- sc->oerrors++;
-#endif /* NETGRAPH */
- }
- /*
- * Check for (& process) an End of Transfer (OK)
- */
- if (dsr & SCA_DSR_EOT) {
- /*
- * This should be the most common case.
- *
- * Clear the IFF_OACTIVE flag.
- *
- * Call srstart to start a new transmit if
- * there is data to transmit.
- */
-#if BUGGY > 0
- printf("sr%d: TX Completed OK\n", sc->unit);
-#endif
- sc->xmit_busy = 0;
-#ifndef NETGRAPH
- sc->ifsppp.pp_if.if_flags &= ~IFF_OACTIVE;
- sc->ifsppp.pp_if.if_timer = 0;
-#else
- /* XXX may need to mark tx inactive? */
- sc->out_deficit++;
- sc->out_dog = DOG_HOLDOFF;
-#endif /* NETGRAPH */
-
- if (sc->txb_inuse && --sc->txb_inuse)
- sr_xmit(sc);
- }
- }
- /*
- * Receive channel processing of DMA Status Register
- */
- if (isr1 & 0x03) {
- dmac = &sca->dmac[DMAC_RXCH(mch)];
-
- dsr = SRC_GET8(hc->sca_base, dmac->dsr);
- SRC_PUT8(hc->sca_base, dmac->dsr, dsr);
-
- /*
- * End of frame processing (MSG OK?)
- */
- if (dsr & SCA_DSR_EOM) {
-#if BUGGY > 0
- int tt, ind;
-
-#ifndef NETGRAPH
- tt = sc->ifsppp.pp_if.if_ipackets;
-#else /* NETGRAPH */
- tt = sc->ipackets;
-#endif /* NETGRAPH */
- ind = sc->rxhind;
-#endif
-
- sr_get_packets(sc);
-#if BUGGY > 0
-#ifndef NETGRAPH
- if (tt == sc->ifsppp.pp_if.if_ipackets)
-#else /* NETGRAPH */
- if (tt == sc->ipackets)
-#endif /* NETGRAPH */
- {
- sca_descriptor *rxdesc;
- int i;
-
- printf("SR: RXINTR isr1 %x, dsr %x, "
- "no data %d pkts, orxind %d.\n",
- dotxstart, dsr, tt, ind);
- printf("SR: rxdesc %x, rxstart %x, "
- "rxend %x, rxhind %d, "
- "rxmax %d.\n",
- sc->rxdesc, sc->rxstart,
- sc->rxend, sc->rxhind,
- sc->rxmax);
- printf("SR: cda %x, eda %x.\n",
- SRC_GET16(hc->sca_base, dmac->cda),
- SRC_GET16(hc->sca_base, dmac->eda));
-
- if (hc->mempages) {
- SRC_SET_ON(hc->iobase);
- SRC_SET_MEM(hc->iobase, sc->rxdesc);
- }
- rxdesc = (sca_descriptor *)
- (hc->mem_start +
- (sc->rxdesc & hc->winmsk));
- rxdesc = &rxdesc[sc->rxhind];
-
- for (i = 0; i < 3; i++, rxdesc++)
- printf("SR: rxdesc->stat %x, "
- "len %d.\n",
- rxdesc->stat,
- rxdesc->len);
-
- if (hc->mempages)
- SRC_SET_OFF(hc->iobase);
- }
-#endif /* BUGGY */
- }
- /*
- * Check for Counter overflow
- */
- if (dsr & SCA_DSR_COF) {
- printf("sr%d: RX DMA Counter overflow, "
- "rxpkts %lu.\n",
-#ifndef NETGRAPH
- sc->unit, sc->ifsppp.pp_if.if_ipackets);
- sc->ifsppp.pp_if.if_ierrors++;
-#else /* NETGRAPH */
- sc->unit, sc->ipackets);
- sc->ierrors[1]++;
-#endif /* NETGRAPH */
- }
- /*
- * Check for Buffer overflow
- */
- if (dsr & SCA_DSR_BOF) {
- printf("sr%d: RX DMA Buffer overflow, "
- "rxpkts %lu, rxind %d, "
- "cda %x, eda %x, dsr %x.\n",
-#ifndef NETGRAPH
- sc->unit, sc->ifsppp.pp_if.if_ipackets,
-#else /* NETGRAPH */
- sc->unit, sc->ipackets,
-#endif /* NETGRAPH */
- sc->rxhind,
- SRC_GET16(hc->sca_base, dmac->cda),
- SRC_GET16(hc->sca_base, dmac->eda),
- dsr);
-
- /*
- * Make sure we eat as many as possible.
- * Then get the system running again.
- */
- if (hc->mempages)
- SRC_SET_ON(hc->iobase);
-
- sr_eat_packet(sc, 0);
-#ifndef NETGRAPH
- sc->ifsppp.pp_if.if_ierrors++;
-#else /* NETGRAPH */
- sc->ierrors[2]++;
-#endif /* NETGRAPH */
-
- SRC_PUT8(hc->sca_base,
- sca->msci[mch].cmd,
- SCA_CMD_RXMSGREJ);
-
- SRC_PUT8(hc->sca_base, dmac->dsr, SCA_DSR_DE);
-
-#if BUGGY > 0
- printf("sr%d: RX DMA Buffer overflow, "
- "rxpkts %lu, rxind %d, "
- "cda %x, eda %x, dsr %x. After\n",
- sc->unit,
-#ifndef NETGRAPH
- sc->ipackets,
-#else /* NETGRAPH */
- sc->ifsppp.pp_if.if_ipackets,
-#endif /* NETGRAPH */
- sc->rxhind,
- SRC_GET16(hc->sca_base, dmac->cda),
- SRC_GET16(hc->sca_base, dmac->eda),
- SRC_GET8(hc->sca_base, dmac->dsr));
-#endif
-
- if (hc->mempages)
- SRC_SET_OFF(hc->iobase);
- }
- /*
- * End of Transfer
- */
- if (dsr & SCA_DSR_EOT) {
- /*
- * If this happen, it means that we are
- * receiving faster than what the processor
- * can handle.
- *
- * XXX We should enable the dma again.
- */
- printf("sr%d: RX End of xfer, rxpkts %lu.\n",
- sc->unit,
-#ifndef NETGRAPH
- sc->ifsppp.pp_if.if_ipackets);
- sc->ifsppp.pp_if.if_ierrors++;
-#else
- sc->ipackets);
- sc->ierrors[3]++;
-#endif /* NETGRAPH */
- }
- }
- isr1 >>= 4; /* process next half of ISR */
- mch++; /* and move to next channel */
- } while ((mch < NCHAN) && isr1); /* loop for each chn */
-
- /*
- * Now that we have done all the urgent things, see if we can fill
- * the transmit buffers.
- */
- for (mch = 0; mch < NCHAN; mch++) {
- if (dotxstart & 0x0C) { /* TX initiation enabled? */
- sc = &hc->sc[mch];
-#ifndef NETGRAPH
- srstart(&sc->ifsppp.pp_if);
-#else
- srstart(sc);
-#endif /* NETGRAPH */
- }
- dotxstart >>= 4;/* shift for next channel */
- }
-}
-#ifndef NETGRAPH
-/*
- * Perform timeout on an FR channel
- *
- * Establish a periodic check of open N2 ports; If
- * a port is open/active, its DCD state is checked
- * and a loss of DCD is recognized (and eventually
- * processed).
- */
-static void
-sr_modemck(void *arg)
-{
- u_int s;
- int card; /* card index in table */
- int cards; /* card list index */
- int mch; /* channel on card */
- u_char dcd_v; /* Data Carrier Detect */
- u_char got_st0; /* contents of ST0 */
- u_char got_st1; /* contents of ST1 */
- u_char got_st2; /* contents of ST2 */
- u_char got_st3; /* contents of ST3 */
- struct sr_hardc *hc; /* card's configuration */
- struct sr_hardc *Card[16];/* up to 16 cards in system */
- struct sr_softc *sc; /* channel's softc structure */
- struct ifnet *ifp; /* interface control table */
- msci_channel *msci; /* regs specific to channel */
-
- s = splimp();
-
-#if 0
- if (sr_opens == 0) { /* count of "up" channels */
- sr_watcher = 0; /* indicate no watcher */
- splx(s);
- return;
- }
-#endif
-
- sr_watcher = 1; /* mark that we're online */
-
- /*
- * Now we'll need a list of cards to process. Since we can handle
- * both ISA and PCI cards (and I didn't think of making this logic
- * global YET) we'll generate a single table of card table
- * addresses.
- */
- cards = 0;
-
- for (card = 0; card < NSR; card++) {
- hc = &sr_hardc[card];
-
- if (hc->sc == (void *)0)
- continue;
-
- Card[cards++] = hc;
- }
-
- hc = sr_hardc_pci;
-
- while (hc) {
- Card[cards++] = hc;
- hc = hc->next;
- }
-
- /*
- * OK, we've got work we can do. Let's do it... (Please note that
- * this code _only_ deals w/ ISA cards)
- */
- for (card = 0; card < cards; card++) {
- hc = Card[card];/* get card table */
-
- for (mch = 0; mch < hc->numports; mch++) {
- sc = &hc->sc[mch];
-
- if (sc->attached == 0)
- continue;
-
- ifp = &sc->ifsppp.pp_if;
-
- /*
- * if this channel isn't "up", skip it
- */
- if ((ifp->if_flags & IFF_UP) == 0)
- continue;
-
- /*
- * OK, now we can go looking at this channel's
- * actual register contents...
- */
- msci = &hc->sca->msci[sc->scachan];
-
- /*
- * OK, now we'll look into the actual status of this
- * channel...
- *
- * I suck in more registers than strictly needed
- */
- got_st0 = SRC_GET8(hc->sca_base, msci->st0);
- got_st1 = SRC_GET8(hc->sca_base, msci->st1);
- got_st2 = SRC_GET8(hc->sca_base, msci->st2);
- got_st3 = SRC_GET8(hc->sca_base, msci->st3);
-
- /*
- * We want to see if the DCD signal is up (DCD is
- * true if zero)
- */
- dcd_v = (got_st3 & SCA_ST3_DCD) == 0;
-
- if (dcd_v == 0)
- printf("sr%d: DCD lost\n", sc->unit);
- }
- }
-
- /*
- * OK, now set up for the next modem signal checking pass...
- */
- timeout(sr_modemck, NULL, hz);
-
- splx(s);
-}
-
-#else /* NETGRAPH */
-/*
- * If a port is open/active, it's DCD state is checked
- * and a loss of DCD is recognized (and eventually processed?).
- */
-static void
-sr_modemck(struct sr_softc *sc )
-{
- u_int s;
- u_char got_st3; /* contents of ST3 */
- struct sr_hardc *hc = sc->hc; /* card's configuration */
- msci_channel *msci; /* regs specific to channel */
-
- s = splimp();
-
-
- if (sc->running == 0)
- return;
- /*
- * OK, now we can go looking at this channel's register contents...
- */
- msci = &hc->sca->msci[sc->scachan];
- got_st3 = SRC_GET8(hc->sca_base, msci->st3);
-
- /*
- * We want to see if the DCD signal is up (DCD is true if zero)
- */
- sc->dcd = (got_st3 & SCA_ST3_DCD) == 0;
- splx(s);
-}
-
-#endif /* NETGRAPH */
-static void
-sr_msci_intr(struct sr_hardc *hc, u_char isr0)
-{
- printf("src%d: SRINTR: MSCI\n", hc->cunit);
-}
-
-static void
-sr_timer_intr(struct sr_hardc *hc, u_char isr2)
-{
- printf("src%d: SRINTR: TIMER\n", hc->cunit);
-}
-
-#ifdef NETGRAPH
-/*****************************************
- * Device timeout/watchdog routine.
- * called once per second.
- * checks to see that if activity was expected, that it hapenned.
- * At present we only look to see if expected output was completed.
- */
-static void
-ngsr_watchdog_frame(void * arg)
-{
- struct sr_softc * sc = arg;
- int s;
- int speed;
-
- if(sc->running == 0)
- return; /* if we are not running let timeouts die */
- /*
- * calculate the apparent throughputs
- * XXX a real hack
- */
- s = splimp();
- speed = sc->inbytes - sc->lastinbytes;
- sc->lastinbytes = sc->inbytes;
- if ( sc->inrate < speed )
- sc->inrate = speed;
- speed = sc->outbytes - sc->lastoutbytes;
- sc->lastoutbytes = sc->outbytes;
- if ( sc->outrate < speed )
- sc->outrate = speed;
- sc->inlast++;
- splx(s);
-
- if ((sc->inlast > QUITE_A_WHILE)
- && (sc->out_deficit > LOTS_OF_PACKETS)) {
- log(LOG_ERR, "sr%d: No response from remote end\n", sc->unit);
- s = splimp();
- sr_down(sc);
- sr_up(sc);
- sc->inlast = sc->out_deficit = 0;
- splx(s);
- } else if ( sc->xmit_busy ) { /* no TX -> no TX timeouts */
- if (sc->out_dog == 0) {
- log(LOG_ERR, "sr%d: Transmit failure.. no clock?\n",
- sc->unit);
- s = splimp();
- srwatchdog(sc);
-#if 0
- sr_down(sc);
- sr_up(sc);
-#endif
- splx(s);
- sc->inlast = sc->out_deficit = 0;
- } else {
- sc->out_dog--;
- }
- }
- sr_modemck(sc); /* update the DCD status */
- sc->handle = timeout(ngsr_watchdog_frame, sc, hz);
-}
-
-/***********************************************************************
- * This section contains the methods for the Netgraph interface
- ***********************************************************************/
-/*
- * It is not possible or allowable to create a node of this type.
- * If the hardware exists, it will already have created it.
- */
-static int
-ngsr_constructor(node_p *nodep)
-{
- return (EINVAL);
-}
-
-/*
- * give our ok for a hook to be added...
- * If we are not running this should kick the device into life.
- * The hook's private info points to our stash of info about that
- * channel.
- */
-static int
-ngsr_newhook(node_p node, hook_p hook, const char *name)
-{
- struct sr_softc * sc = node->private;
-
- /*
- * check if it's our friend the debug hook
- */
- if (strcmp(name, NG_SR_HOOK_DEBUG) == 0) {
- hook->private = NULL; /* paranoid */
- sc->debug_hook = hook;
- return (0);
- }
-
- /*
- * Check for raw mode hook.
- */
- if (strcmp(name, NG_SR_HOOK_RAW) != 0) {
- return (EINVAL);
- }
- hook->private = sc;
- sc->hook = hook;
- sc->datahooks++;
- sr_up(sc);
- return (0);
-}
-
-/*
- * incoming messages.
- * Just respond to the generic TEXT_STATUS message
- */
-static int
-ngsr_rcvmsg(node_p node,
- struct ng_mesg *msg, const char *retaddr, struct ng_mesg **resp)
-{
- struct sr_softc * sc;
- int error = 0;
-
- sc = node->private;
- switch (msg->header.typecookie) {
- case NG_SR_COOKIE:
- error = EINVAL;
- break;
- case NGM_GENERIC_COOKIE:
- switch(msg->header.cmd) {
- case NGM_TEXT_STATUS: {
- char *arg;
- int pos = 0;
- int resplen = sizeof(struct ng_mesg) + 512;
- MALLOC(*resp, struct ng_mesg *, resplen,
- M_NETGRAPH, M_NOWAIT);
- if (*resp == NULL) {
- error = ENOMEM;
- break;
- }
- bzero(*resp, resplen);
- arg = (*resp)->data;
-
- /*
- * Put in the throughput information.
- */
- pos = sprintf(arg, "%ld bytes in, %ld bytes out\n"
- "highest rate seen: %ld B/S in, %ld B/S out\n",
- sc->inbytes, sc->outbytes,
- sc->inrate, sc->outrate);
- pos += sprintf(arg + pos,
- "%ld output errors\n",
- sc->oerrors);
- pos += sprintf(arg + pos,
- "ierrors = %ld, %ld, %ld, %ld, %ld, %ld\n",
- sc->ierrors[0],
- sc->ierrors[1],
- sc->ierrors[2],
- sc->ierrors[3],
- sc->ierrors[4],
- sc->ierrors[5]);
-
- (*resp)->header.version = NG_VERSION;
- (*resp)->header.arglen = strlen(arg) + 1;
- (*resp)->header.token = msg->header.token;
- (*resp)->header.typecookie = NG_SR_COOKIE;
- (*resp)->header.cmd = msg->header.cmd;
- strncpy((*resp)->header.cmdstr, "status",
- NG_CMDSTRLEN);
- }
- break;
- default:
- error = EINVAL;
- break;
- }
- break;
- default:
- error = EINVAL;
- break;
- }
- free(msg, M_NETGRAPH);
- return (error);
-}
-
-/*
- * get data from another node and transmit it to the correct channel
- */
-static int
-ngsr_rcvdata(hook_p hook, struct mbuf *m, meta_p meta)
-{
- int s;
- int error = 0;
- struct sr_softc * sc = hook->node->private;
- struct ifqueue *xmitq_p;
-
- /*
- * data doesn't come in from just anywhere (e.g control hook)
- */
- if ( hook->private == NULL) {
- error = ENETDOWN;
- goto bad;
- }
-
- /*
- * Now queue the data for when it can be sent
- */
- if (meta && meta->priority > 0) {
- xmitq_p = (&sc->xmitq_hipri);
- } else {
- xmitq_p = (&sc->xmitq);
- }
- s = splimp();
- if (IF_QFULL(xmitq_p)) {
- IF_DROP(xmitq_p);
- splx(s);
- error = ENOBUFS;
- goto bad;
- }
- IF_ENQUEUE(xmitq_p, m);
- srstart(sc);
- splx(s);
- return (0);
-
-bad:
- /*
- * It was an error case.
- * check if we need to free the mbuf, and then return the error
- */
- NG_FREE_DATA(m, meta);
- return (error);
-}
-
-/*
- * do local shutdown processing..
- * this node will refuse to go away, unless the hardware says to..
- * don't unref the node, or remove our name. just clear our links up.
- */
-static int
-ngsr_rmnode(node_p node)
-{
- struct sr_softc * sc = node->private;
-
- sr_down(sc);
- ng_cutlinks(node);
- node->flags &= ~NG_INVALID; /* bounce back to life */
- return (0);
-}
-
-/* already linked */
-static int
-ngsr_connect(hook_p hook)
-{
- /* be really amiable and just say "YUP that's OK by me! " */
- return (0);
-}
-
-/*
- * notify on hook disconnection (destruction)
- *
- * Invalidate the private data associated with this dlci.
- * For this type, removal of the last link resets tries to destroy the node.
- * As the device still exists, the shutdown method will not actually
- * destroy the node, but reset the device and leave it 'fresh' :)
- *
- * The node removal code will remove all references except that owned by the
- * driver.
- */
-static int
-ngsr_disconnect(hook_p hook)
-{
- struct sr_softc * sc = hook->node->private;
- int s;
- /*
- * If it's the data hook, then free resources etc.
- */
- if (hook->private) {
- s = splimp();
- sc->datahooks--;
- if (sc->datahooks == 0)
- sr_down(sc);
- splx(s);
- } else {
- sc->debug_hook = NULL;
- }
- return (0);
-}
-
-/*
- * called during bootup
- * or LKM loading to put this type into the list of known modules
- */
-static void
-ngsr_init(void *ignored)
-{
- if (ng_newtype(&typestruct))
- printf("ngsr install failed\n");
- ngsr_done_init = 1;
-}
-#endif /* NETGRAPH */
-
-/*
- ********************************* END ************************************
- */
diff --git a/sys/dev/sr/if_sr.h b/sys/dev/sr/if_sr.h
deleted file mode 100644
index 31e08abf2f56..000000000000
--- a/sys/dev/sr/if_sr.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * if_sr.h
- *
- * Copyright (C) 1997-1999 Whistle Communications Inc.
- * All rights reserved.
- *
- * $FreeBSD$
- */
-
-#ifndef _I386_ISA_IF_SR_H_
-#define _I386_ISA_IF_SR_H_
-
-/* Node type name and type cookie */
-#define NG_SR_NODE_TYPE "sync_sr"
-#define NG_SR_COOKIE 860552148
-
-/* Netgraph hooks */
-#define NG_SR_HOOK_DEBUG "debug"
-#define NG_SR_HOOK_RAW "rawdata"
-
-#endif /* _I386_ISA_IF_SR_H_ */
-
diff --git a/sys/dev/sr/if_sr_isa.c b/sys/dev/sr/if_sr_isa.c
deleted file mode 100644
index c1348e3a3a9e..000000000000
--- a/sys/dev/sr/if_sr_isa.c
+++ /dev/null
@@ -1,3552 +0,0 @@
-/*
- * Copyright (c) 1996 John Hay.
- * Copyright (c) 1996 SDL Communications, Inc.
- * 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 author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Programming assumptions and other issues.
- *
- * Only a 16K window will be used.
- *
- * The descriptors of a DMA channel will fit in a 16K memory window.
- *
- * The buffers of a transmit DMA channel will fit in a 16K memory window.
- *
- * When interface is going up, handshaking is set and it is only cleared
- * when the interface is down'ed.
- *
- * There should be a way to set/reset Raw HDLC/PPP, Loopback, DCE/DTE,
- * internal/external clock, etc.....
- *
- */
-
-#include "sr.h"
-#include "opt_netgraph.h"
-#ifdef NETGRAPH
-#include <i386/isa/if_sr.h>
-#else /* NETGRAPH */
-#ifdef notyet
-#include "fr.h"
-#else
-#define NFR 0
-#endif
-#endif /* NETGRAPH */
-
-#ifndef NETGRAPH
-#include "sppp.h"
-#if NSPPP <= 0
-#error Device 'sr' requires sppp.
-#endif
-#endif /* NETGRAPH */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/malloc.h>
-#include <sys/mbuf.h>
-#include <sys/sockio.h>
-#include <sys/socket.h>
-
-#include <net/if.h>
-#ifdef NETGRAPH
-#include <sys/syslog.h>
-#else /* NETGRAPH */
-#include <net/if_sppp.h>
-
-#include <net/bpf.h>
-#endif /* NETGRAPH */
-
-#include <machine/md_var.h>
-
-#include <i386/isa/if_srregs.h>
-#include <i386/isa/ic/hd64570.h>
-#include <i386/isa/isa_device.h>
-
-#ifdef NETGRAPH
-#include <netgraph/ng_message.h>
-#include <netgraph/netgraph.h>
-#endif /* NETGRAPH */
-/* #define USE_MODEMCK */
-
-#ifndef BUGGY
-#define BUGGY 0
-#endif
-
-#ifndef NETGRAPH
-#define PPP_HEADER_LEN 4
-#endif /* NETGRAPH */
-
-/*
- * These macros are used to hide the difference between the way the
- * ISA N2 cards and the PCI N2 cards access the Hitachi 64570 SCA.
- */
-#define SRC_GET8(base,off) (*hc->src_get8)(base,(u_int)&off)
-#define SRC_GET16(base,off) (*hc->src_get16)(base,(u_int)&off)
-#define SRC_PUT8(base,off,d) (*hc->src_put8)(base,(u_int)&off,d)
-#define SRC_PUT16(base,off,d) (*hc->src_put16)(base,(u_int)&off,d)
-
-/*
- * These macros enable/disable the DPRAM and select the correct
- * DPRAM page.
- */
-#define SRC_GET_WIN(addr) ((addr >> SRC_WIN_SHFT) & SR_PG_MSK)
-
-#define SRC_SET_ON(iobase) outb(iobase+SR_PCR, \
- SR_PCR_MEM_WIN | inb(iobase+SR_PCR))
-#define SRC_SET_MEM(iobase,win) outb(iobase+SR_PSR, SRC_GET_WIN(win) | \
- (inb(iobase+SR_PSR) & ~SR_PG_MSK))
-#define SRC_SET_OFF(iobase) outb(iobase+SR_PCR, \
- ~SR_PCR_MEM_WIN & inb(iobase+SR_PCR))
-
-/*
- * Define the hardware (card information) structure needed to keep
- * track of the device itself... There is only one per card.
- */
-struct sr_hardc {
- struct sr_hardc *next; /* PCI card linkage */
- struct sr_softc *sc; /* software channels */
- int cunit; /* card w/in system */
-
- u_short iobase; /* I/O Base Address */
- int cardtype;
- int numports; /* # of ports on cd */
- int mempages;
- u_int memsize; /* DPRAM size: bytes */
- u_int winmsk;
- vm_offset_t sca_base;
- vm_offset_t mem_pstart; /* start of buffer */
- caddr_t mem_start; /* start of DP RAM */
- caddr_t mem_end; /* end of DP RAM */
- caddr_t plx_base;
-
- sca_regs *sca; /* register array */
-
- /*
- * We vectorize the following functions to allow re-use between the
- * ISA card's needs and those of the PCI card.
- */
- void (*src_put8)(u_int base, u_int off, u_int val);
- void (*src_put16)(u_int base, u_int off, u_int val);
- u_int (*src_get8)(u_int base, u_int off);
- u_int (*src_get16)(u_int base, u_int off);
-};
-
-static int next_sc_unit = 0;
-#ifndef NETGRAPH
-static int sr_watcher = 0;
-#endif /* NETGRAPH */
-static struct sr_hardc sr_hardc[NSR];
-static struct sr_hardc *sr_hardc_pci;
-
-/*
- * Define the software interface for the card... There is one for
- * every channel (port).
- */
-struct sr_softc {
-#ifndef NETGRAPH
- struct sppp ifsppp; /* PPP service w/in system */
-#endif /* NETGRAPH */
- struct sr_hardc *hc; /* card-level information */
-
- int unit; /* With regard to all sr devices */
- int subunit; /* With regard to this card */
-
-#ifndef NETGRAPH
- int attached; /* attached to FR or PPP */
- int protocol; /* FR or PPP */
-#define N2_USE_FRP 2 /* Frame Relay Protocol */
-#define N2_USE_PPP 1 /* Point-to-Point Protocol */
-#endif /* NETGRAPH */
- struct buf_block {
- u_int txdesc; /* DPRAM offset */
- u_int txstart;/* DPRAM offset */
- u_int txend; /* DPRAM offset */
- u_int txtail; /* # of 1st free gran */
- u_int txmax; /* # of free grans */
- u_int txeda; /* err descr addr */
- } block[SR_TX_BLOCKS];
-
- char xmit_busy; /* Transmitter is busy */
- char txb_inuse; /* # of tx grans in use */
- u_int txb_new; /* ndx to new buffer */
- u_int txb_next_tx; /* ndx to next gran rdy tx */
-
- u_int rxdesc; /* DPRAM offset */
- u_int rxstart; /* DPRAM offset */
- u_int rxend; /* DPRAM offset */
- u_int rxhind; /* ndx to the hd of rx bufrs */
- u_int rxmax; /* # of avail grans */
-
- u_int clk_cfg; /* Clock configuration */
-
- int scachan; /* channel # on card */
-#ifdef NETGRAPH
- int running; /* something is attached so we are running */
- int dcd; /* do we have dcd? */
- /* ---netgraph bits --- */
- char nodename[NG_NODELEN + 1]; /* store our node name */
- int datahooks; /* number of data hooks attached */
- node_p node; /* netgraph node */
- hook_p hook; /* data hook */
- hook_p debug_hook;
- struct ifqueue xmitq_hipri; /* hi-priority transmit queue */
- struct ifqueue xmitq; /* transmit queue */
- int flags; /* state */
-#define SCF_RUNNING 0x01 /* board is active */
-#define SCF_OACTIVE 0x02 /* output is active */
- int out_dog; /* watchdog cycles output count-down */
-#if ( __FreeBSD__ >= 3 )
- struct callout_handle handle; /* timeout(9) handle */
-#endif
- u_long inbytes, outbytes; /* stats */
- u_long lastinbytes, lastoutbytes; /* a second ago */
- u_long inrate, outrate; /* highest rate seen */
- u_long inlast; /* last input N secs ago */
- u_long out_deficit; /* output since last input */
- u_long oerrors, ierrors[6];
- u_long opackets, ipackets;
-#endif /* NETGRAPH */
-};
-
-#ifdef NETGRAPH
-#define DOG_HOLDOFF 6 /* dog holds off for 6 secs */
-#define QUITE_A_WHILE 300 /* 5 MINUTES */
-#define LOTS_OF_PACKETS 100
-#endif /* NETGRAPH */
-
-/*
- * List of valid interrupt numbers for the N2 ISA card.
- */
-static int sr_irqtable[16] = {
- 0, /* 0 */
- 0, /* 1 */
- 0, /* 2 */
- 1, /* 3 */
- 1, /* 4 */
- 1, /* 5 */
- 0, /* 6 */
- 1, /* 7 */
- 0, /* 8 */
- 0, /* 9 */
- 1, /* 10 */
- 1, /* 11 */
- 1, /* 12 */
- 0, /* 13 */
- 0, /* 14 */
- 1 /* 15 */
-};
-
-static int srprobe(struct isa_device *id);
-static int srattach_isa(struct isa_device *id);
-
-struct isa_driver srdriver = {srprobe, srattach_isa, "src"};
-
-/*
- * Baud Rate table for Sync Mode.
- * Each entry consists of 3 elements:
- * Baud Rate (x100) , TMC, BR
- *
- * Baud Rate = FCLK / TMC / 2^BR
- * Baud table for Crystal freq. of 9.8304 Mhz
- */
-#ifdef N2_TEST_SPEED
-struct rate_line {
- int target; /* target rate/100 */
- int tmc_reg; /* TMC register value */
- int br_reg; /* BR (BaudRateClk) selector */
-} n2_rates[] = {
- /* Baudx100 TMC BR */
- { 3, 128, 8 },
- { 6, 128, 7 },
- { 12, 128, 6 },
- { 24, 128, 5 },
- { 48, 128, 4 },
- { 96, 128, 3 },
- { 192, 128, 2 },
- { 384, 128, 1 },
- { 560, 88, 1 },
- { 640, 77, 1 },
- { 1280, 38, 1 },
- { 2560, 19, 1 },
- { 5120, 10, 1 },
- { 10000, 5, 1 },
- { 15000, 3, 1 },
- { 25000, 2, 1 },
- { 50000, 1, 1 },
- { 0, 0, 0 }
-};
-
-int sr_test_speed[] = {
- N2_TEST_SPEED,
- N2_TEST_SPEED
-};
-
-int etc0vals[] = {
- SR_MCR_ETC0, /* ISA channel 0 */
- SR_MCR_ETC1, /* ISA channel 1 */
- SR_FECR_ETC0, /* PCI channel 0 */
- SR_FECR_ETC1 /* PCI channel 1 */
-};
-#endif
-
-struct sr_hardc *srattach_pci(int unit, vm_offset_t plx_vaddr,
- vm_offset_t sca_vaddr);
-void srintr_hc(struct sr_hardc *hc);
-
-static ointhand2_t srintr;
-
-static int srattach(struct sr_hardc *hc);
-static void sr_xmit(struct sr_softc *sc);
-#ifndef NETGRAPH
-static void srstart(struct ifnet *ifp);
-static int srioctl(struct ifnet *ifp, u_long cmd, caddr_t data);
-static void srwatchdog(struct ifnet *ifp);
-#else
-static void srstart(struct sr_softc *sc);
-static void srwatchdog(struct sr_softc *sc);
-#endif /* NETGRAPH */
-static int sr_packet_avail(struct sr_softc *sc, int *len, u_char *rxstat);
-static void sr_copy_rxbuf(struct mbuf *m, struct sr_softc *sc, int len);
-static void sr_eat_packet(struct sr_softc *sc, int single);
-static void sr_get_packets(struct sr_softc *sc);
-
-static void sr_up(struct sr_softc *sc);
-static void sr_down(struct sr_softc *sc);
-static void src_init(struct sr_hardc *hc);
-static void sr_init_sca(struct sr_hardc *hc);
-static void sr_init_msci(struct sr_softc *sc);
-static void sr_init_rx_dmac(struct sr_softc *sc);
-static void sr_init_tx_dmac(struct sr_softc *sc);
-static void sr_dmac_intr(struct sr_hardc *hc, u_char isr);
-static void sr_msci_intr(struct sr_hardc *hc, u_char isr);
-static void sr_timer_intr(struct sr_hardc *hc, u_char isr);
-#ifndef NETGRAPH
-static void sr_modemck(void *x);
-#else
-static void sr_modemck(struct sr_softc *x);
-#endif /* NETGRAPH */
-
-static u_int src_get8_io(u_int base, u_int off);
-static u_int src_get16_io(u_int base, u_int off);
-static void src_put8_io(u_int base, u_int off, u_int val);
-static void src_put16_io(u_int base, u_int off, u_int val);
-static u_int src_get8_mem(u_int base, u_int off);
-static u_int src_get16_mem(u_int base, u_int off);
-static void src_put8_mem(u_int base, u_int off, u_int val);
-static void src_put16_mem(u_int base, u_int off, u_int val);
-
-#ifndef NETGRAPH
-#if NFR > 0
-extern void fr_detach(struct ifnet *);
-extern int fr_attach(struct ifnet *);
-extern int fr_ioctl(struct ifnet *, int, caddr_t);
-extern void fr_flush(struct ifnet *);
-extern int fr_input(struct ifnet *, struct mbuf *);
-extern struct mbuf *fr_dequeue(struct ifnet *);
-#endif
-#else
-static void ngsr_watchdog_frame(void * arg);
-static void ngsr_init(void* ignored);
-
-static ng_constructor_t ngsr_constructor;
-static ng_rcvmsg_t ngsr_rcvmsg;
-static ng_shutdown_t ngsr_rmnode;
-static ng_newhook_t ngsr_newhook;
-/*static ng_findhook_t ngsr_findhook; */
-static ng_connect_t ngsr_connect;
-static ng_rcvdata_t ngsr_rcvdata;
-static ng_disconnect_t ngsr_disconnect;
-
-static struct ng_type typestruct = {
- NG_VERSION,
- NG_SR_NODE_TYPE,
- NULL,
- ngsr_constructor,
- ngsr_rcvmsg,
- ngsr_rmnode,
- ngsr_newhook,
- NULL,
- ngsr_connect,
- ngsr_rcvdata,
- ngsr_rcvdata,
- ngsr_disconnect,
- NULL
-};
-
-static int ngsr_done_init = 0;
-#endif /* NETGRAPH */
-
-/*
- * I/O for ISA N2 card(s)
- */
-#define SRC_REG(iobase,y) ((((y) & 0xf) + (((y) & 0xf0) << 6) + \
- (iobase)) | 0x8000)
-
-static u_int
-src_get8_io(u_int base, u_int off)
-{
- return inb(SRC_REG(base, off));
-}
-
-static u_int
-src_get16_io(u_int base, u_int off)
-{
- return inw(SRC_REG(base, off));
-}
-
-static void
-src_put8_io(u_int base, u_int off, u_int val)
-{
- outb(SRC_REG(base, off), val);
-}
-
-static void
-src_put16_io(u_int base, u_int off, u_int val)
-{
- outw(SRC_REG(base, off), val);
-}
-
-/*
- * I/O for PCI N2 card(s)
- */
-#define SRC_PCI_SCA_REG(y) ((y & 2) ? ((y & 0xfd) + 0x100) : y)
-
-static u_int
-src_get8_mem(u_int base, u_int off)
-{
- return *((u_char *)(base + SRC_PCI_SCA_REG(off)));
-}
-
-static u_int
-src_get16_mem(u_int base, u_int off)
-{
- return *((u_short *)(base + SRC_PCI_SCA_REG(off)));
-}
-
-static void
-src_put8_mem(u_int base, u_int off, u_int val)
-{
- *((u_char *)(base + SRC_PCI_SCA_REG(off))) = (u_char)val;
-}
-
-static void
-src_put16_mem(u_int base, u_int off, u_int val)
-{
- *((u_short *)(base + SRC_PCI_SCA_REG(off))) = (u_short)val;
-}
-
-/*
- * Probe for an ISA card. If it is there, size its memory. Then get the
- * rest of its information and fill it in.
- */
-static int
-srprobe(struct isa_device *id)
-{
- struct sr_hardc *hc = &sr_hardc[id->id_unit];
- u_int pgs, i, tmp;
- u_short port;
- u_short *smem;
- u_char mar;
- sca_regs *sca = 0;
-
- /*
- * Now see if the card is realy there.
- */
- hc->cardtype = SR_CRD_N2;
-
- /*
- * We have to fill these in early because the SRC_PUT* and SRC_GET*
- * macros use them.
- */
- hc->src_get8 = src_get8_io;
- hc->src_get16 = src_get16_io;
- hc->src_put8 = src_put8_io;
- hc->src_put16 = src_put16_io;
-
- hc->sca = 0;
- port = id->id_iobase;
- hc->numports = NCHAN; /* assumed # of channels on the card */
-
- if (id->id_flags & SR_FLAGS_NCHAN_MSK)
- hc->numports = id->id_flags & SR_FLAGS_NCHAN_MSK;
-
- outb(port + SR_PCR, 0); /* turn off the card */
-
- /*
- * Next, we'll test the Base Address Register to retension of
- * data... ... seeing if we're *really* talking to an N2.
- */
- for (i = 0; i < 0x100; i++) {
- outb(port + SR_BAR, i);
- inb(port + SR_PCR);
- tmp = inb(port + SR_BAR);
- if (tmp != i) {
- printf("sr%d: probe failed BAR %x, %x.\n",
- id->id_unit, i, tmp);
- return 0;
- }
- }
-
- /*
- * Now see if we can see the SCA.
- */
- outb(port + SR_PCR, SR_PCR_SCARUN | inb(port + SR_PCR));
- SRC_PUT8(port, sca->wcrl, 0);
- SRC_PUT8(port, sca->wcrm, 0);
- SRC_PUT8(port, sca->wcrh, 0);
- SRC_PUT8(port, sca->pcr, 0);
- SRC_PUT8(port, sca->msci[0].tmc, 0);
- inb(port);
-
- tmp = SRC_GET8(port, sca->msci[0].tmc);
- if (tmp != 0) {
- printf("sr%d: Error reading SCA 0, %x\n", id->id_unit, tmp);
- return 0;
- }
- SRC_PUT8(port, sca->msci[0].tmc, 0x5A);
- inb(port);
-
- tmp = SRC_GET8(port, sca->msci[0].tmc);
- if (tmp != 0x5A) {
- printf("sr%d: Error reading SCA 0x5A, %x\n", id->id_unit, tmp);
- return 0;
- }
- SRC_PUT16(port, sca->dmac[0].cda, 0);
- inb(port);
-
- tmp = SRC_GET16(port, sca->dmac[0].cda);
- if (tmp != 0) {
- printf("sr%d: Error reading SCA 0, %x\n", id->id_unit, tmp);
- return 0;
- }
- SRC_PUT16(port, sca->dmac[0].cda, 0x55AA);
- inb(port);
-
- tmp = SRC_GET16(port, sca->dmac[0].cda);
- if (tmp != 0x55AA) {
- printf("sr%d: Error reading SCA 0x55AA, %x\n",
- id->id_unit, tmp);
- return 0;
- }
- /*
- * OK, the board's interface registers seem to work. Now we'll see
- * if the Dual-Ported RAM is fully accessible...
- */
- outb(port + SR_PCR, SR_PCR_EN_VPM | SR_PCR_ISA16);
- outb(port + SR_PSR, SR_PSR_WIN_16K);
-
- /*
- * Take the kernel "virtual" address supplied to us and convert
- * it to a "real" address. Then program the card to use that.
- */
- mar = (kvtop(id->id_maddr) >> 16) & SR_PCR_16M_SEL;
- outb(port + SR_PCR, mar | inb(port + SR_PCR));
- mar = kvtop(id->id_maddr) >> 12;
- outb(port + SR_BAR, mar);
- outb(port + SR_PCR, inb(port + SR_PCR) | SR_PCR_MEM_WIN);
- smem = (u_short *)id->id_maddr; /* DP RAM Address */
-
- /*
- * Here we will perform the memory scan to size the device.
- *
- * This is done by marking each potential page with a magic number.
- * We then loop through the pages looking for that magic number. As
- * soon as we no longer see that magic number, we'll quit the scan,
- * knowing that no more memory is present. This provides the number
- * of pages present on the card.
- *
- * Note: We're sizing 16K memory granules.
- */
- for (i = 0; i <= SR_PSR_PG_SEL; i++) {
- outb(port + SR_PSR,
- (inb(port + SR_PSR) & ~SR_PSR_PG_SEL) | i);
-
- *smem = 0xAA55;
- }
-
- for (i = 0; i <= SR_PSR_PG_SEL; i++) {
- outb(port + SR_PSR,
- (inb(port + SR_PSR) & ~SR_PSR_PG_SEL) | i);
-
- if (*smem != 0xAA55) {
- /*
- * If we have less than 64k of memory, give up. That
- * is 4 x 16k pages.
- */
- if (i < 4) {
- printf("sr%d: Bad mem page %d, mem %x, %x.\n",
- id->id_unit, i, 0xAA55, *smem);
- return 0;
- }
- break;
- }
- *smem = i;
- }
-
- hc->mempages = i;
- hc->memsize = i * SRC_WIN_SIZ;
- hc->winmsk = SRC_WIN_MSK;
- pgs = i; /* final count of 16K pages */
-
- /*
- * This next loop erases the contents of that page in DPRAM
- */
- for (i = 0; i <= pgs; i++) {
- outb(port + SR_PSR,
- (inb(port + SR_PSR) & ~SR_PSR_PG_SEL) | i);
- bzero(smem, SRC_WIN_SIZ);
- }
-
- SRC_SET_OFF(port);
-
- /*
- * We have a card here, fill in what we can.
- */
- id->id_msize = SRC_WIN_SIZ;
- hc->iobase = id->id_iobase;
- hc->sca_base = id->id_iobase;
- hc->mem_start = id->id_maddr;
- hc->mem_end = (id->id_maddr + id->id_msize) - 1;
- hc->mem_pstart = 0;
- hc->cunit = id->id_unit;
-
- /*
- * Do a little sanity check.
- */
- if (sr_irqtable[ffs(id->id_irq) - 1] == 0)
- printf("sr%d: Warning: illegal interrupt %d chosen.\n",
- id->id_unit, ffs(id->id_irq) - 1);
-
- /*
- * Bogus card configuration
- */
- if ((hc->numports > NCHAN) /* only 2 ports/card */
- ||(hc->memsize > (512 * 1024))) /* no more than 256K */
- return 0;
-
- return SRC_IO_SIZ; /* return the amount of IO addresses used. */
-}
-
-/*
- * srattach_isa and srattach_pci allocate memory for hardc, softc and
- * data buffers. It also does any initialization that is bus specific.
- * At the end they call the common srattach() function.
- */
-static int
-srattach_isa(struct isa_device *id)
-{
- u_char mar;
- struct sr_hardc *hc = &sr_hardc[id->id_unit];
-
- /*
- * Allocate the software interface table(s)
- */
- MALLOC(hc->sc, struct sr_softc *,
- hc->numports * sizeof(struct sr_softc), M_DEVBUF, M_WAITOK);
- if (hc->sc == NULL)
- return(0);
- bzero(hc->sc, hc->numports * sizeof(struct sr_softc));
-
- id->id_ointr = srintr;
-
- outb(hc->iobase + SR_PCR, inb(hc->iobase + SR_PCR) | SR_PCR_SCARUN);
- outb(hc->iobase + SR_PSR, inb(hc->iobase + SR_PSR) | SR_PSR_EN_SCA_DMA);
- outb(hc->iobase + SR_MCR,
- SR_MCR_DTR0 | SR_MCR_DTR1 | SR_MCR_TE0 | SR_MCR_TE1);
-
- SRC_SET_ON(hc->iobase);
-
- /*
- * Configure the card. Mem address, irq,
- */
- mar = (kvtop(id->id_maddr) >> 16) & SR_PCR_16M_SEL;
- outb(hc->iobase + SR_PCR,
- mar | (inb(hc->iobase + SR_PCR) & ~SR_PCR_16M_SEL));
- mar = kvtop(id->id_maddr) >> 12;
- outb(hc->iobase + SR_BAR, mar);
-
- /*
- * Get the TX clock direction and configuration. The default is a
- * single external clock which is used by RX and TX.
- */
-#ifdef N2_TEST_SPEED
- if (sr_test_speed[0] > 0)
- hc->sc[0].clk_cfg = SR_FLAGS_INT_CLK;
- else if (id->id_flags & SR_FLAGS_0_CLK_MSK)
- hc->sc[0].clk_cfg =
- (id->id_flags & SR_FLAGS_0_CLK_MSK)
- >> SR_FLAGS_CLK_SHFT;
-#else
- if (id->id_flags & SR_FLAGS_0_CLK_MSK)
- hc->sc[0].clk_cfg =
- (id->id_flags & SR_FLAGS_0_CLK_MSK)
- >> SR_FLAGS_CLK_SHFT;
-#endif
-
- if (hc->numports == 2)
-#ifdef N2_TEST_SPEED
- if (sr_test_speed[1] > 0)
- hc->sc[0].clk_cfg = SR_FLAGS_INT_CLK;
- else
-#endif
- if (id->id_flags & SR_FLAGS_1_CLK_MSK)
- hc->sc[1].clk_cfg = (id->id_flags & SR_FLAGS_1_CLK_MSK)
- >> (SR_FLAGS_CLK_SHFT + SR_FLAGS_CLK_CHAN_SHFT);
-
- return srattach(hc);
-}
-
-struct sr_hardc *
-srattach_pci(int unit, vm_offset_t plx_vaddr, vm_offset_t sca_vaddr)
-{
- int numports, pndx;
- u_int fecr, *fecrp = (u_int *)(sca_vaddr + SR_FECR);
- struct sr_hardc *hc, **hcp;
-
- /*
- * Configure the PLX. This is magic. I'm doing it just like I'm told
- * to. :-)
- *
- * offset
- * 0x00 - Map Range - Mem-mapped to locate anywhere
- * 0x04 - Re-Map - PCI address decode enable
- * 0x18 - Bus Region - 32-bit bus, ready enable
- * 0x1c - Master Range - include all 16 MB
- * 0x20 - Master RAM - Map SCA Base at 0
- * 0x28 - Master Remap - direct master memory enable
- * 0x68 - Interrupt - Enable interrupt (0 to disable)
- *
- * Note: This is "cargo cult" stuff. - jrc
- */
- *((u_int *)(plx_vaddr + 0x00)) = 0xfffff000;
- *((u_int *)(plx_vaddr + 0x04)) = 1;
- *((u_int *)(plx_vaddr + 0x18)) = 0x40030043;
- *((u_int *)(plx_vaddr + 0x1c)) = 0xff000000;
- *((u_int *)(plx_vaddr + 0x20)) = 0;
- *((u_int *)(plx_vaddr + 0x28)) = 0xe9;
- *((u_int *)(plx_vaddr + 0x68)) = 0x10900;
-
- /*
- * Get info from card.
- *
- * Only look for the second port if the first exists. Too many things
- * will break if we have only a second port.
- */
- fecr = *fecrp;
- numports = 0;
-
- if (((fecr & SR_FECR_ID0) >> SR_FE_ID0_SHFT) != SR_FE_ID_NONE) {
- numports++;
- if (((fecr & SR_FECR_ID1) >> SR_FE_ID1_SHFT) != SR_FE_ID_NONE)
- numports++;
- }
- if (numports == 0)
- return NULL;
-
- hc = sr_hardc_pci;
- hcp = &sr_hardc_pci;
-
- while (hc) {
- hcp = &hc->next;
- hc = hc->next;
- }
-
- MALLOC(hc, struct sr_hardc *, sizeof(*hc), M_DEVBUF, M_WAITOK);
- if (hc == NULL)
- return NULL;
- bzero(hc, sizeof(*hc));
-
- MALLOC(hc->sc, struct sr_softc *,
- numports * sizeof(struct sr_softc), M_DEVBUF, M_WAITOK);
- if (hc->sc == NULL) {
- FREE(hc, M_DEVBUF);
- return NULL;
- }
- bzero(hc->sc, numports * sizeof(struct sr_softc));
- *hcp = hc;
-
- hc->numports = numports;
- hc->cunit = unit;
- hc->cardtype = SR_CRD_N2PCI;
- hc->plx_base = (caddr_t)plx_vaddr;
- hc->sca_base = sca_vaddr;
-
- hc->src_put8 = src_put8_mem;
- hc->src_put16 = src_put16_mem;
- hc->src_get8 = src_get8_mem;
- hc->src_get16 = src_get16_mem;
-
- /*
- * Malloc area for tx and rx buffers. For now allocate SRC_WIN_SIZ
- * (16k) for each buffer.
- *
- * Allocate the block below 16M because the N2pci card can only access
- * 16M memory at a time.
- *
- * (We could actually allocate a contiguous block above the 16MB limit,
- * but this would complicate card programming more than we want to
- * right now -jrc)
- */
- hc->memsize = 2 * hc->numports * SRC_WIN_SIZ;
- hc->mem_start = contigmalloc(hc->memsize,
- M_DEVBUF,
- M_NOWAIT,
- 0ul,
- 0xfffffful,
- 0x10000,
- 0x1000000);
-
- if (hc->mem_start == NULL) {
- printf("src%d: pci: failed to allocate buffer space.\n", unit);
- return NULL;
- }
- hc->winmsk = 0xffffffff;
- hc->mem_end = (caddr_t)((u_int)hc->mem_start + hc->memsize);
- hc->mem_pstart = kvtop(hc->mem_start);
- bzero(hc->mem_start, hc->memsize);
-
- for (pndx = 0; pndx < numports; pndx++) {
- int intf_sw;
- struct sr_softc *sc;
-
- sc = &hc->sc[pndx];
-
- switch (pndx) {
- case 1:
- intf_sw = fecr & SR_FECR_ID1 >> SR_FE_ID1_SHFT;
- break;
- case 0:
- default:
- intf_sw = fecr & SR_FECR_ID0 >> SR_FE_ID0_SHFT;
- }
-
-#ifdef N2_TEST_SPEED
- if (sr_test_speed[pndx] > 0)
- sc->clk_cfg = SR_FLAGS_INT_CLK;
- else
-#endif
- switch (intf_sw) {
- default:
- case SR_FE_ID_RS232:
- case SR_FE_ID_HSSI:
- case SR_FE_ID_RS422:
- case SR_FE_ID_TEST:
- break;
-
- case SR_FE_ID_V35:
- sc->clk_cfg = SR_FLAGS_EXT_SEP_CLK;
- break;
-
- case SR_FE_ID_X21:
- sc->clk_cfg = SR_FLAGS_EXT_CLK;
- break;
- }
- }
-
- *fecrp = SR_FECR_DTR0
- | SR_FECR_DTR1
- | SR_FECR_TE0
- | SR_FECR_TE1;
-
- srattach(hc);
-
- return hc;
-}
-
-/*
- * Register the ports on the adapter.
- * Fill in the info for each port.
-#ifndef NETGRAPH
- * Attach each port to sppp and bpf.
-#endif
- */
-static int
-srattach(struct sr_hardc *hc)
-{
- struct sr_softc *sc = hc->sc;
-#ifndef NETGRAPH
- struct ifnet *ifp;
-#endif /* NETGRAPH */
- int unit; /* index: channel w/in card */
-
- /*
- * Report Card configuration information before we start configuring
- * each channel on the card...
- */
- printf("src%d: %uK RAM (%d mempages) @ %08x-%08x, %u ports.\n",
- hc->cunit, hc->memsize / 1024, hc->mempages,
- (u_int)hc->mem_start, (u_int)hc->mem_end, hc->numports);
-
- src_init(hc);
- sr_init_sca(hc);
-
- /*
- * Now configure each port on the card.
- */
- for (unit = 0; unit < hc->numports; sc++, unit++) {
- sc->hc = hc;
- sc->subunit = unit;
- sc->unit = next_sc_unit;
- next_sc_unit++;
- sc->scachan = unit % NCHAN;
-
- sr_init_rx_dmac(sc);
- sr_init_tx_dmac(sc);
- sr_init_msci(sc);
-
- printf("sr%d: Adapter %d, port %d.\n",
- sc->unit, hc->cunit, sc->subunit);
-
-#ifndef NETGRAPH
- ifp = &sc->ifsppp.pp_if;
- ifp->if_softc = sc;
- ifp->if_unit = sc->unit;
- ifp->if_name = "sr";
- ifp->if_mtu = PP_MTU;
- ifp->if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
- ifp->if_ioctl = srioctl;
- ifp->if_start = srstart;
- ifp->if_watchdog = srwatchdog;
-
- /*
- * Despite the fact that we want to allow both PPP *and*
- * Frame Relay access to a channel, due to the architecture
- * of the system, we'll have to do the attach here.
- *
- * At some point I'll defer the attach to the "up" call and
- * have the attach/detach performed when the interface is
- * up/downed...
- */
- sc->attached = 0;
- sc->protocol = N2_USE_PPP; /* default protocol */
-
-#if 0
- sc->ifsppp.pp_flags = PP_KEEPALIVE;
- sppp_attach((struct ifnet *)&sc->ifsppp);
-#endif
-
- if_attach(ifp);
-
- bpfattach(ifp, DLT_PPP, PPP_HEADER_LEN);
-#else /* NETGRAPH */
- /*
- * we have found a node, make sure our 'type' is availabe.
- */
- if (ngsr_done_init == 0) ngsr_init(NULL);
- if (ng_make_node_common(&typestruct, &sc->node) != 0)
- return (0);
- sc->node->private = sc;
- callout_handle_init(&sc->handle);
- sc->xmitq.ifq_maxlen = IFQ_MAXLEN;
- sc->xmitq_hipri.ifq_maxlen = IFQ_MAXLEN;
- sprintf(sc->nodename, "%s%d", NG_SR_NODE_TYPE, sc->unit);
- if (ng_name_node(sc->node, sc->nodename)) {
- ng_rmnode(sc->node);
- ng_unref(sc->node);
- return (0);
- }
- sc->running = 0;
-#endif /* NETGRAPH */
- }
-
- if (hc->mempages)
- SRC_SET_OFF(hc->iobase);
-
- return 1;
-}
-
-/*
- * N2 Interrupt Service Routine
- *
- * First figure out which SCA gave the interrupt.
- * Process it.
- * See if there is other interrupts pending.
- * Repeat until there no interrupts remain.
- */
-static void
-srintr(int unit)
-{
- struct sr_hardc *hc;
-
- hc = &sr_hardc[unit];
- srintr_hc(hc);
-
- return;
-}
-
-void
-srintr_hc(struct sr_hardc *hc)
-{
- sca_regs *sca = hc->sca; /* MSCI register tree */
- u_char isr0, isr1, isr2; /* interrupt statii captured */
-
-#if BUGGY > 1
- printf("sr: srintr_hc(hc=%08x)\n", hc);
-#endif
-
- /*
- * Since multiple interfaces may share this interrupt, we must loop
- * until no interrupts are still pending service.
- */
- while (1) {
- /*
- * Read all three interrupt status registers from the N2
- * card...
- */
- isr0 = SRC_GET8(hc->sca_base, sca->isr0);
- isr1 = SRC_GET8(hc->sca_base, sca->isr1);
- isr2 = SRC_GET8(hc->sca_base, sca->isr2);
-
- /*
- * If all three registers returned 0, we've finished
- * processing interrupts from this device, so we can quit
- * this loop...
- */
- if ((isr0 | isr1 | isr2) == 0)
- break;
-
-#if BUGGY > 2
- printf("src%d: srintr_hc isr0 %x, isr1 %x, isr2 %x\n",
-#ifndef NETGRAPH
- unit, isr0, isr1, isr2);
-#else
- hc->cunit, isr0, isr1, isr2);
-#endif /* NETGRAPH */
-#endif
-
- /*
- * Now we can dispatch the interrupts. Since we don't expect
- * either MSCI or timer interrupts, we'll test for DMA
- * interrupts first...
- */
- if (isr1) /* DMA-initiated interrupt */
- sr_dmac_intr(hc, isr1);
-
- if (isr0) /* serial part IRQ? */
- sr_msci_intr(hc, isr0);
-
- if (isr2) /* timer-initiated interrupt */
- sr_timer_intr(hc, isr2);
- }
-}
-
-/*
- * This will only start the transmitter. It is assumed that the data
- * is already there.
- * It is normally called from srstart() or sr_dmac_intr().
- */
-static void
-sr_xmit(struct sr_softc *sc)
-{
- u_short cda_value; /* starting descriptor */
- u_short eda_value; /* ending descriptor */
- struct sr_hardc *hc;
-#ifndef NETGRAPH
- struct ifnet *ifp; /* O/S Network Services */
-#endif /* NETGRAPH */
- dmac_channel *dmac; /* DMA channel registers */
-
-#if BUGGY > 0
- printf("sr: sr_xmit( sc=%08x)\n", sc);
-#endif
-
- hc = sc->hc;
-#ifndef NETGRAPH
- ifp = &sc->ifsppp.pp_if;
-#endif /* NETGRAPH */
- dmac = &hc->sca->dmac[DMAC_TXCH(sc->scachan)];
-
- /*
- * Get the starting and ending addresses of the chain to be
- * transmitted and pass these on to the DMA engine on-chip.
- */
- cda_value = sc->block[sc->txb_next_tx].txdesc + hc->mem_pstart;
- cda_value &= 0x00ffff;
- eda_value = sc->block[sc->txb_next_tx].txeda + hc->mem_pstart;
- eda_value &= 0x00ffff;
-
- SRC_PUT16(hc->sca_base, dmac->cda, cda_value);
- SRC_PUT16(hc->sca_base, dmac->eda, eda_value);
-
- /*
- * Now we'll let the DMA status register know about this change
- */
- SRC_PUT8(hc->sca_base, dmac->dsr, SCA_DSR_DE);
-
- sc->xmit_busy = 1; /* mark transmitter busy */
-
-#if BUGGY > 2
- printf("sr%d: XMIT cda=%04x, eda=%4x, rcda=%08lx\n",
- sc->unit, cda_value, eda_value,
- sc->block[sc->txb_next_tx].txdesc + hc->mem_pstart);
-#endif
-
- sc->txb_next_tx++; /* update next transmit seq# */
-
- if (sc->txb_next_tx == SR_TX_BLOCKS) /* handle wrap... */
- sc->txb_next_tx = 0;
-
-#ifndef NETGRAPH
- /*
- * Finally, we'll set a timout (which will start srwatchdog())
- * within the O/S network services layer...
- */
- ifp->if_timer = 2; /* Value in seconds. */
-#else
- /*
- * Don't time out for a while.
- */
- sc->out_dog = DOG_HOLDOFF; /* give ourself some breathing space*/
-#endif /* NETGRAPH */
-}
-
-/*
- * This function will be called from the upper level when a user add a
- * packet to be send, and from the interrupt handler after a finished
- * transmit.
- *
- * NOTE: it should run at spl_imp().
- *
- * This function only place the data in the oncard buffers. It does not
- * start the transmition. sr_xmit() does that.
- *
- * Transmitter idle state is indicated by the IFF_OACTIVE flag.
- * The function that clears that should ensure that the transmitter
- * and its DMA is in a "good" idle state.
- */
-#ifndef NETGRAPH
-static void
-srstart(struct ifnet *ifp)
-{
- struct sr_softc *sc; /* channel control structure */
-#else
-static void
-srstart(struct sr_softc *sc)
-{
-#endif /* NETGRAPH */
- struct sr_hardc *hc; /* card control/config block */
- int len; /* total length of a packet */
- int pkts; /* packets placed in DPRAM */
- int tlen; /* working length of pkt */
- u_int i;
- struct mbuf *mtx; /* message buffer from O/S */
- u_char *txdata; /* buffer address in DPRAM */
- sca_descriptor *txdesc; /* working descriptor pointr */
- struct buf_block *blkp;
-
-#ifndef NETGRAPH
-#if BUGGY > 0
- printf("sr: srstart( ifp=%08x)\n", ifp);
-#endif
- sc = ifp->if_softc;
- if ((ifp->if_flags & IFF_RUNNING) == 0)
- return;
-#endif /* NETGRAPH */
- hc = sc->hc;
- /*
- * It is OK to set the memory window outside the loop because all tx
- * buffers and descriptors are assumed to be in the same 16K window.
- */
- if (hc->mempages) {
- SRC_SET_ON(hc->iobase);
- SRC_SET_MEM(hc->iobase, sc->block[0].txdesc);
- }
-
- /*
- * Loop to place packets into DPRAM.
- *
- * We stay in this loop until there is nothing in
- * the TX queue left or the tx buffers are full.
- */
-top_srstart:
-
- /*
- * See if we have space for more packets.
- */
- if (sc->txb_inuse == SR_TX_BLOCKS) { /* out of space? */
-#ifndef NETGRAPH
- ifp->if_flags |= IFF_OACTIVE; /* yes, mark active */
-#else
- /*ifp->if_flags |= IFF_OACTIVE;*/ /* yes, mark active */
-#endif /* NETGRAPH */
-
- if (hc->mempages)
- SRC_SET_OFF(hc->iobase);
-
-#if BUGGY > 9
- printf("sr%d.srstart: sc->txb_inuse=%d; DPRAM full...\n",
- sc->unit, sc->txb_inuse);
-#endif
- return;
- }
- /*
- * OK, the card can take more traffic. Let's see if there's any
- * pending from the system...
- *
- * NOTE:
- * The architecture of the networking interface doesn't
- * actually call us like 'write()', providing an address. We get
- * started, a lot like a disk strategy routine, and we actually call
- * back out to the system to get traffic to send...
- *
- * NOTE:
- * If we were gonna run through another layer, we would use a
- * dispatch table to select the service we're getting a packet
- * from...
- */
-#ifndef NETGRAPH
- switch (sc->protocol) {
-#if NFR > 0
- case N2_USE_FRP:
- mtx = fr_dequeue(ifp);
- break;
-#endif
- case N2_USE_PPP:
- default:
- mtx = sppp_dequeue(ifp);
- }
-#else /* NETGRAPH */
- IF_DEQUEUE(&sc->xmitq_hipri, mtx);
- if (mtx == NULL) {
- IF_DEQUEUE(&sc->xmitq, mtx);
- }
-#endif /* NETGRAPH */
- if (!mtx) {
- if (hc->mempages)
- SRC_SET_OFF(hc->iobase);
- return;
- }
- /*
- * OK, we got a packet from the network services of the O/S. Now we
- * can move it into the DPRAM (under control of the descriptors) and
- * fire it off...
- */
- pkts = 0;
- i = 0; /* counts # of granules used */
-
- blkp = &sc->block[sc->txb_new]; /* address of free granule */
- txdesc = (sca_descriptor *)
- (hc->mem_start + (blkp->txdesc & hc->winmsk));
-
- txdata = (u_char *)(hc->mem_start
- + (blkp->txstart & hc->winmsk));
-
- /*
- * Now we'll try to install as many packets as possible into the
- * card's DP RAM buffers.
- */
- for (;;) { /* perform actual copy of packet */
- len = mtx->m_pkthdr.len; /* length of message */
-
-#if BUGGY > 1
- printf("sr%d.srstart: mbuf @ %08lx, %d bytes\n",
- sc->unit, mtx, len);
-#endif
-
-#ifndef NETGRAPH
- if (ifp->if_bpf)
- bpf_mtap(ifp, mtx);
-#else /* NETGRAPH */
- sc->outbytes += len;
-#endif /* NETGRAPH */
-
- /*
- * We can perform a straight copy because the tranmit
- * buffers won't wrap.
- */
- m_copydata(mtx, 0, len, txdata);
-
- /*
- * Now we know how big the message is gonna be. We must now
- * construct the descriptors to drive this message out...
- */
- tlen = len;
- while (tlen > SR_BUF_SIZ) { /* loop for full granules */
- txdesc->stat = 0; /* reset bits */
- txdesc->len = SR_BUF_SIZ; /* size of granule */
- tlen -= SR_BUF_SIZ;
-
- txdesc++; /* move to next dscr */
- txdata += SR_BUF_SIZ; /* adjust data addr */
- i++;
- }
-
- /*
- * This section handles the setting of the final piece of a
- * message.
- */
- txdesc->stat = SCA_DESC_EOM;
- txdesc->len = tlen;
- pkts++;
-
- /*
- * prepare for subsequent packets (if any)
- */
- txdesc++;
- txdata += SR_BUF_SIZ; /* next mem granule */
- i++; /* count of granules */
-
- /*
- * OK, we've now placed the message into the DPRAM where it
- * can be transmitted. We'll now release the message memory
- * and update the statistics...
- */
- m_freem(mtx);
-#ifndef NETGRAPH
- ++sc->ifsppp.pp_if.if_opackets;
-#else /* NETGRAPH */
- sc->opackets++;
-#endif /* NETGRAPH */
-
- /*
- * Check if we have space for another packet. XXX This is
- * hardcoded. A packet can't be larger than 3 buffers (3 x
- * 512).
- */
- if ((i + 3) >= blkp->txmax) { /* enough remains? */
-#if BUGGY > 9
- printf("sr%d.srstart: i=%d (%d pkts); card full.\n",
- sc->unit, i, pkts);
-#endif
- break;
- }
- /*
- * We'll pull the next message to be sent (if any)
- */
-#ifndef NETGRAPH
- switch (sc->protocol) {
-#if NFR > 0
- case N2_USE_FRP:
- mtx = fr_dequeue(ifp);
- break;
-#endif
- case N2_USE_PPP:
- default:
- mtx = sppp_dequeue(ifp);
- }
-#else /* NETGRAPH */
- IF_DEQUEUE(&sc->xmitq_hipri, mtx);
- if (mtx == NULL) {
- IF_DEQUEUE(&sc->xmitq, mtx);
- }
-#endif /* NETGRAPH */
- if (!mtx) { /* no message? We're done! */
-#if BUGGY > 9
- printf("sr%d.srstart: pending=0, pkts=%d\n",
- sc->unit, pkts);
-#endif
- break;
- }
- }
-
- blkp->txtail = i; /* record next free granule */
-
- /*
- * Mark the last descriptor, so that the SCA know where to stop.
- */
- txdesc--; /* back up to last descriptor in list */
- txdesc->stat |= SCA_DESC_EOT; /* mark as end of list */
-
- /*
- * Now we'll reset the transmit granule's descriptor address so we
- * can record this in the structure and fire it off w/ the DMA
- * processor of the serial chip...
- */
- txdesc = (sca_descriptor *)blkp->txdesc;
- blkp->txeda = (u_short)((u_int)&txdesc[i]);
-
- sc->txb_inuse++; /* update inuse status */
- sc->txb_new++; /* new traffic wuz added */
-
- if (sc->txb_new == SR_TX_BLOCKS)
- sc->txb_new = 0;
-
- /*
- * If the tranmitter wasn't marked as "busy" we will force it to be
- * started...
- */
- if (sc->xmit_busy == 0) {
- sr_xmit(sc);
-#if BUGGY > 9
- printf("sr%d.srstart: called sr_xmit()\n", sc->unit);
-#endif
- }
- goto top_srstart;
-}
-
-#ifndef NETGRAPH
-/*
- * Handle ioctl's at the device level, though we *will* call up
- * a layer...
- */
-#if BUGGY > 2
-static int bug_splats[] = {0, 0, 0, 0, 0, 0, 0, 0};
-#endif
-
-static int
-srioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
-{
- int s, error, was_up, should_be_up;
- struct sr_softc *sc = ifp->if_softc;
-
-#if BUGGY > 0
- printf("sr%d: srioctl(ifp=%08x, cmd=%08x, data=%08x)\n",
- ifp->if_unit, ifp, cmd, data);
-#endif
-
- was_up = ifp->if_flags & IFF_RUNNING;
-
- if (cmd == SIOCSIFFLAGS) {
- /*
- * First, handle an apparent protocol switch
- */
-#if NFR > 0
- if (was_up == 0)/* can only happen if DOWN */
- if (ifp->if_flags & IFF_LINK1)
- sc->protocol = N2_USE_FRP;
- else
- sc->protocol = N2_USE_PPP;
-#else
- sc->protocol = N2_USE_PPP;
- ifp->if_flags &= ~IFF_LINK1;
-#endif
-
- }
- /*
- * Next, we'll allow the network service layer we've called process
- * the ioctl...
- */
- if ((sc->attached != 0)
- && (sc->attached != sc->protocol)) {
- switch (sc->attached) {
-#if NFR > 0
- case N2_USE_FRP:
- fr_detach(ifp);
- break;
-#endif
- case N2_USE_PPP:
- default:
- sppp_detach(ifp);
- sc->ifsppp.pp_flags &= ~PP_KEEPALIVE;
- }
-
- sc->attached = 0;
- }
- if (sc->attached == 0) {
- switch (sc->protocol) {
-#if NFR > 0
- case N2_USE_FRP:
- fr_attach(&sc->ifsppp.pp_if);
- break;
-#endif
- case N2_USE_PPP:
- default:
- sc->ifsppp.pp_flags |= PP_KEEPALIVE;
- sppp_attach(&sc->ifsppp.pp_if);
-
- }
-
- sc->attached = sc->protocol;
- }
- switch (sc->protocol) {
-#if NFR > 0
- case N2_USE_FRP:
- error = fr_ioctl(ifp, cmd, data);
- break;
-#endif
- case N2_USE_PPP:
- default:
- error = sppp_ioctl(ifp, cmd, data);
- }
-
-#if BUGGY > 1
- printf("sr%d: ioctl: ifsppp.pp_flags = %08x, if_flags %08x.\n",
- ifp->if_unit, ((struct sppp *)ifp)->pp_flags, ifp->if_flags);
-#endif
-
- if (error)
- return error;
-
- if ((cmd != SIOCSIFFLAGS) && (cmd != SIOCSIFADDR)) {
-#if BUGGY > 2
- if (bug_splats[sc->unit]++ < 2) {
- printf("sr(%d).if_addrlist = %08x\n",
- sc->unit, ifp->if_addrlist);
- printf("sr(%d).if_bpf = %08x\n",
- sc->unit, ifp->if_bpf);
- printf("sr(%d).if_init = %08x\n",
- sc->unit, ifp->if_init);
- printf("sr(%d).if_output = %08x\n",
- sc->unit, ifp->if_output);
- printf("sr(%d).if_start = %08x\n",
- sc->unit, ifp->if_start);
- printf("sr(%d).if_done = %08x\n",
- sc->unit, ifp->if_done);
- printf("sr(%d).if_ioctl = %08x\n",
- sc->unit, ifp->if_ioctl);
- printf("sr(%d).if_reset = %08x\n",
- sc->unit, ifp->if_reset);
- printf("sr(%d).if_watchdog = %08x\n",
- sc->unit, ifp->if_watchdog);
- }
-#endif
- return 0;
- }
-
- s = splimp();
- should_be_up = ifp->if_flags & IFF_RUNNING;
-
- if (!was_up && should_be_up) {
- /*
- * Interface should be up -- start it.
- */
- sr_up(sc);
- srstart(ifp);
-
- /*
- * XXX Clear the IFF_UP flag so that the link will only go
- * up after sppp lcp and ipcp negotiation.
- */
- ifp->if_flags &= ~IFF_UP;
- } else if (was_up && !should_be_up) {
- /*
- * Interface should be down -- stop it.
- */
- sr_down(sc);
- switch (sc->protocol) {
-#if NFR > 0
- case N2_USE_FRP:
- fr_flush(ifp);
- break;
-#endif
- case N2_USE_PPP:
- default:
- sppp_flush(ifp);
- }
- }
- splx(s);
-
-#if BUGGY > 2
- if (bug_splats[sc->unit]++ < 2) {
- printf("sr(%d).if_addrlist = %08x\n",
- sc->unit, ifp->if_addrlist);
- printf("sr(%d).if_bpf = %08x\n",
- sc->unit, ifp->if_bpf);
- printf("sr(%d).if_init = %08x\n",
- sc->unit, ifp->if_init);
- printf("sr(%d).if_output = %08x\n",
- sc->unit, ifp->if_output);
- printf("sr(%d).if_start = %08x\n",
- sc->unit, ifp->if_start);
- printf("sr(%d).if_done = %08x\n",
- sc->unit, ifp->if_done);
- printf("sr(%d).if_ioctl = %08x\n",
- sc->unit, ifp->if_ioctl);
- printf("sr(%d).if_reset = %08x\n",
- sc->unit, ifp->if_reset);
- printf("sr(%d).if_watchdog = %08x\n",
- sc->unit, ifp->if_watchdog);
- }
-#endif
-
- return 0;
-}
-#endif /* NETGRAPH */
-
-/*
- * This is to catch lost tx interrupts.
- */
-static void
-#ifndef NETGRAPH
-srwatchdog(struct ifnet *ifp)
-#else
-srwatchdog(struct sr_softc *sc)
-#endif /* NETGRAPH */
-{
- int got_st0, got_st1, got_st3, got_dsr;
-#ifndef NETGRAPH
- struct sr_softc *sc = ifp->if_softc;
-#endif /* NETGRAPH */
- struct sr_hardc *hc = sc->hc;
- msci_channel *msci = &hc->sca->msci[sc->scachan];
- dmac_channel *dmac = &sc->hc->sca->dmac[sc->scachan];
-
-#if BUGGY > 0
-#ifndef NETGRAPH
- printf("srwatchdog(unit=%d)\n", unit);
-#else
- printf("srwatchdog(unit=%d)\n", sc->unit);
-#endif /* NETGRAPH */
-#endif
-
-#ifndef NETGRAPH
- if (!(ifp->if_flags & IFF_RUNNING))
- return;
-
- ifp->if_oerrors++; /* update output error count */
-#else /* NETGRAPH */
- sc->oerrors++; /* update output error count */
-#endif /* NETGRAPH */
-
- got_st0 = SRC_GET8(hc->sca_base, msci->st0);
- got_st1 = SRC_GET8(hc->sca_base, msci->st1);
- got_st3 = SRC_GET8(hc->sca_base, msci->st3);
- got_dsr = SRC_GET8(hc->sca_base, dmac->dsr);
-
-#ifndef NETGRAPH
-#if 0
- if (ifp->if_flags & IFF_DEBUG)
-#endif
- printf("sr%d: transmit failed, "
-#else /* NETGRAPH */
- printf("sr%d: transmit failed, "
-#endif /* NETGRAPH */
- "ST0 %02x, ST1 %02x, ST3 %02x, DSR %02x.\n",
- sc->unit,
- got_st0, got_st1, got_st3, got_dsr);
-
- if (SRC_GET8(hc->sca_base, msci->st1) & SCA_ST1_UDRN) {
- SRC_PUT8(hc->sca_base, msci->cmd, SCA_CMD_TXABORT);
- SRC_PUT8(hc->sca_base, msci->cmd, SCA_CMD_TXENABLE);
- SRC_PUT8(hc->sca_base, msci->st1, SCA_ST1_UDRN);
- }
- sc->xmit_busy = 0;
-#ifndef NETGRAPH
- ifp->if_flags &= ~IFF_OACTIVE;
-#else
- /*ifp->if_flags &= ~IFF_OACTIVE; */
-#endif /* NETGRAPH */
-
- if (sc->txb_inuse && --sc->txb_inuse)
- sr_xmit(sc);
-
-#ifndef NETGRAPH
- srstart(ifp); /* restart transmitter */
-#else
- srstart(sc); /* restart transmitter */
-#endif /* NETGRAPH */
-}
-
-static void
-sr_up(struct sr_softc *sc)
-{
- u_int *fecrp;
- struct sr_hardc *hc = sc->hc;
- sca_regs *sca = hc->sca;
- msci_channel *msci = &sca->msci[sc->scachan];
-
-#if BUGGY > 0
- printf("sr_up(sc=%08x)\n", sc);
-#endif
-
-#ifndef NETGRAPH
- /*
- * This section should really do the attach to the appropriate
- * system service, be it frame relay or PPP...
- */
- if (sc->attached == 0) {
- switch (sc->protocol) {
-#if NFR > 0
- case N2_USE_FRP:
- fr_attach(&sc->ifsppp.pp_if);
- break;
-#endif
- case N2_USE_PPP:
- default:
- sc->ifsppp.pp_flags |= PP_KEEPALIVE;
- sppp_attach(&sc->ifsppp.pp_if);
-
- }
-
- sc->attached = sc->protocol;
- }
-
-#endif /* NETGRAPH */
- /*
- * Enable transmitter and receiver. Raise DTR and RTS. Enable
- * interrupts.
- *
- * XXX What about using AUTO mode in msci->md0 ???
- */
- SRC_PUT8(hc->sca_base, msci->ctl,
- SRC_GET8(hc->sca_base, msci->ctl) & ~SCA_CTL_RTS);
-
- if (sc->scachan == 0)
- switch (hc->cardtype) {
- case SR_CRD_N2:
- outb(hc->iobase + SR_MCR,
- (inb(hc->iobase + SR_MCR) & ~SR_MCR_DTR0));
- break;
- case SR_CRD_N2PCI:
- fecrp = (u_int *)(hc->sca_base + SR_FECR);
- *fecrp &= ~SR_FECR_DTR0;
- break;
- }
- else
- switch (hc->cardtype) {
- case SR_CRD_N2:
- outb(hc->iobase + SR_MCR,
- (inb(hc->iobase + SR_MCR) & ~SR_MCR_DTR1));
- break;
- case SR_CRD_N2PCI:
- fecrp = (u_int *)(hc->sca_base + SR_FECR);
- *fecrp &= ~SR_FECR_DTR1;
- break;
- }
-
- if (sc->scachan == 0) {
- SRC_PUT8(hc->sca_base, sca->ier0,
- SRC_GET8(hc->sca_base, sca->ier0) | 0x000F);
- SRC_PUT8(hc->sca_base, sca->ier1,
- SRC_GET8(hc->sca_base, sca->ier1) | 0x000F);
- } else {
- SRC_PUT8(hc->sca_base, sca->ier0,
- SRC_GET8(hc->sca_base, sca->ier0) | 0x00F0);
- SRC_PUT8(hc->sca_base, sca->ier1,
- SRC_GET8(hc->sca_base, sca->ier1) | 0x00F0);
- }
-
- SRC_PUT8(hc->sca_base, msci->cmd, SCA_CMD_RXENABLE);
- inb(hc->iobase); /* XXX slow it down a bit. */
- SRC_PUT8(hc->sca_base, msci->cmd, SCA_CMD_TXENABLE);
-
-#ifndef NETGRAPH
-#ifdef USE_MODEMCK
- if (sr_watcher == 0)
- sr_modemck(NULL);
-#endif
-#else /* NETGRAPH */
- untimeout(ngsr_watchdog_frame, sc, sc->handle);
- sc->handle = timeout(ngsr_watchdog_frame, sc, hz);
- sc->running = 1;
-#endif /* NETGRAPH */
-}
-
-static void
-sr_down(struct sr_softc *sc)
-{
- u_int *fecrp;
- struct sr_hardc *hc = sc->hc;
- sca_regs *sca = hc->sca;
- msci_channel *msci = &sca->msci[sc->scachan];
-
-#if BUGGY > 0
- printf("sr_down(sc=%08x)\n", sc);
-#endif
-#ifdef NETGRAPH
- untimeout(ngsr_watchdog_frame, sc, sc->handle);
- sc->running = 0;
-#endif /* NETGRAPH */
-
- /*
- * Disable transmitter and receiver. Lower DTR and RTS. Disable
- * interrupts.
- */
- SRC_PUT8(hc->sca_base, msci->cmd, SCA_CMD_RXDISABLE);
- inb(hc->iobase); /* XXX slow it down a bit. */
- SRC_PUT8(hc->sca_base, msci->cmd, SCA_CMD_TXDISABLE);
-
- SRC_PUT8(hc->sca_base, msci->ctl,
- SRC_GET8(hc->sca_base, msci->ctl) | SCA_CTL_RTS);
-
- if (sc->scachan == 0)
- switch (hc->cardtype) {
- case SR_CRD_N2:
- outb(hc->iobase + SR_MCR,
- (inb(hc->iobase + SR_MCR) | SR_MCR_DTR0));
- break;
- case SR_CRD_N2PCI:
- fecrp = (u_int *)(hc->sca_base + SR_FECR);
- *fecrp |= SR_FECR_DTR0;
- break;
- }
- else
- switch (hc->cardtype) {
- case SR_CRD_N2:
- outb(hc->iobase + SR_MCR,
- (inb(hc->iobase + SR_MCR) | SR_MCR_DTR1));
- break;
- case SR_CRD_N2PCI:
- fecrp = (u_int *)(hc->sca_base + SR_FECR);
- *fecrp |= SR_FECR_DTR1;
- break;
- }
-
- if (sc->scachan == 0) {
- SRC_PUT8(hc->sca_base, sca->ier0,
- SRC_GET8(hc->sca_base, sca->ier0) & ~0x0F);
- SRC_PUT8(hc->sca_base, sca->ier1,
- SRC_GET8(hc->sca_base, sca->ier1) & ~0x0F);
- } else {
- SRC_PUT8(hc->sca_base, sca->ier0,
- SRC_GET8(hc->sca_base, sca->ier0) & ~0xF0);
- SRC_PUT8(hc->sca_base, sca->ier1,
- SRC_GET8(hc->sca_base, sca->ier1) & ~0xF0);
- }
-
-#ifndef NETGRAPH
- /*
- * This section does the detach from the currently configured net
- * service, be it frame relay or PPP...
- */
- switch (sc->protocol) {
-#if NFR > 0
- case N2_USE_FRP:
- fr_detach(&sc->ifsppp.pp_if);
- break;
-#endif
- case N2_USE_PPP:
- default:
- sppp_detach(&sc->ifsppp.pp_if);
- }
-
- sc->attached = 0;
-#endif /* NETGRAPH */
-}
-
-/*
- * Initialize the card, allocate memory for the sr_softc structures
- * and fill in the pointers.
- */
-static void
-src_init(struct sr_hardc *hc)
-{
- struct sr_softc *sc = hc->sc;
- int x;
- u_int chanmem;
- u_int bufmem;
- u_int next;
- u_int descneeded;
-
-#if BUGGY > 0
- printf("src_init(hc=%08x)\n", hc);
-#endif
-
- chanmem = hc->memsize / hc->numports;
- next = 0;
-
- for (x = 0; x < hc->numports; x++, sc++) {
- int blk;
-
- for (blk = 0; blk < SR_TX_BLOCKS; blk++) {
- sc->block[blk].txdesc = next;
- bufmem = (16 * 1024) / SR_TX_BLOCKS;
- descneeded = bufmem / SR_BUF_SIZ;
-
- sc->block[blk].txstart = sc->block[blk].txdesc
- + ((((descneeded * sizeof(sca_descriptor))
- / SR_BUF_SIZ) + 1)
- * SR_BUF_SIZ);
-
- sc->block[blk].txend = next + bufmem;
- sc->block[blk].txmax =
- (sc->block[blk].txend - sc->block[blk].txstart)
- / SR_BUF_SIZ;
- next += bufmem;
-
-#if BUGGY > 2
- printf("sr%d: blk %d: txdesc %08x, txstart %08x\n",
- sc->unit, blk,
- sc->block[blk].txdesc, sc->block[blk].txstart);
-#endif
- }
-
- sc->rxdesc = next;
- bufmem = chanmem - (bufmem * SR_TX_BLOCKS);
- descneeded = bufmem / SR_BUF_SIZ;
- sc->rxstart = sc->rxdesc +
- ((((descneeded * sizeof(sca_descriptor)) /
- SR_BUF_SIZ) + 1) * SR_BUF_SIZ);
- sc->rxend = next + bufmem;
- sc->rxmax = (sc->rxend - sc->rxstart) / SR_BUF_SIZ;
- next += bufmem;
- }
-}
-
-/*
- * The things done here are channel independent.
- *
- * Configure the sca waitstates.
- * Configure the global interrupt registers.
- * Enable master dma enable.
- */
-static void
-sr_init_sca(struct sr_hardc *hc)
-{
- sca_regs *sca = hc->sca;
-
-#if BUGGY > 0
- printf("sr_init_sca(hc=%08x)\n", hc);
-#endif
-
- /*
- * Do the wait registers. Set everything to 0 wait states.
- */
- SRC_PUT8(hc->sca_base, sca->pabr0, 0);
- SRC_PUT8(hc->sca_base, sca->pabr1, 0);
- SRC_PUT8(hc->sca_base, sca->wcrl, 0);
- SRC_PUT8(hc->sca_base, sca->wcrm, 0);
- SRC_PUT8(hc->sca_base, sca->wcrh, 0);
-
- /*
- * Configure the interrupt registers. Most are cleared until the
- * interface is configured.
- */
- SRC_PUT8(hc->sca_base, sca->ier0, 0x00); /* MSCI interrupts. */
- SRC_PUT8(hc->sca_base, sca->ier1, 0x00); /* DMAC interrupts */
- SRC_PUT8(hc->sca_base, sca->ier2, 0x00); /* TIMER interrupts. */
- SRC_PUT8(hc->sca_base, sca->itcr, 0x00); /* Use ivr and no intr
- * ack */
- SRC_PUT8(hc->sca_base, sca->ivr, 0x40); /* Interrupt vector. */
- SRC_PUT8(hc->sca_base, sca->imvr, 0x40);
-
- /*
- * Configure the timers. XXX Later
- */
-
- /*
- * Set the DMA channel priority to rotate between all four channels.
- *
- * Enable all dma channels.
- */
- SRC_PUT8(hc->sca_base, sca->pcr, SCA_PCR_PR2);
- SRC_PUT8(hc->sca_base, sca->dmer, SCA_DMER_EN);
-}
-
-/*
- * Configure the msci
- *
- * NOTE: The serial port configuration is hardcoded at the moment.
- */
-static void
-sr_init_msci(struct sr_softc *sc)
-{
- int portndx; /* on-board port number */
- u_int mcr_v; /* contents of modem control */
- u_int *fecrp; /* pointer for PCI's MCR i/o */
- struct sr_hardc *hc = sc->hc;
- msci_channel *msci = &hc->sca->msci[sc->scachan];
-#ifdef N2_TEST_SPEED
- int br_v; /* contents for BR divisor */
- int etcndx; /* index into ETC table */
- int fifo_v, gotspeed; /* final tabled speed found */
- int tmc_v; /* timer control register */
- int wanted; /* speed (bitrate) wanted... */
- struct rate_line *rtp;
-#endif
-
- portndx = sc->scachan;
-
-#if BUGGY > 0
- printf("sr: sr_init_msci( sc=%08x)\n", sc);
-#endif
-
- SRC_PUT8(hc->sca_base, msci->cmd, SCA_CMD_RESET);
- SRC_PUT8(hc->sca_base, msci->md0, SCA_MD0_CRC_1 |
- SCA_MD0_CRC_CCITT |
- SCA_MD0_CRC_ENABLE |
- SCA_MD0_MODE_HDLC);
- SRC_PUT8(hc->sca_base, msci->md1, SCA_MD1_NOADDRCHK);
- SRC_PUT8(hc->sca_base, msci->md2, SCA_MD2_DUPLEX | SCA_MD2_NRZ);
-
- /*
- * According to the manual I should give a reset after changing the
- * mode registers.
- */
- SRC_PUT8(hc->sca_base, msci->cmd, SCA_CMD_RXRESET);
- SRC_PUT8(hc->sca_base, msci->ctl, SCA_CTL_IDLPAT |
- SCA_CTL_UDRNC |
- SCA_CTL_RTS);
-
- /*
- * XXX Later we will have to support different clock settings.
- */
- switch (sc->clk_cfg) {
- default:
-#if BUGGY > 0
- printf("sr%: clk_cfg=%08x, selected default clock.\n",
- portndx, sc->clk_cfg);
-#endif
- /* FALLTHROUGH */
- case SR_FLAGS_EXT_CLK:
- /*
- * For now all interfaces are programmed to use the RX clock
- * for the TX clock.
- */
-
-#if BUGGY > 0
- printf("sr%d: External Clock Selected.\n", portndx);
-#endif
-
- SRC_PUT8(hc->sca_base, msci->rxs, 0);
- SRC_PUT8(hc->sca_base, msci->txs, 0);
- break;
-
- case SR_FLAGS_EXT_SEP_CLK:
-#if BUGGY > 0
- printf("sr%d: Split Clocking Selected.\n", portndx);
-#endif
-
-#if 1
- SRC_PUT8(hc->sca_base, msci->rxs, 0);
- SRC_PUT8(hc->sca_base, msci->txs, 0);
-#else
- SRC_PUT8(hc->sca_base, msci->rxs,
- SCA_RXS_CLK_RXC0 | SCA_RXS_DIV1);
-
- /*
- * We need to configure the internal bit clock for the
- * transmitter's channel...
- */
- SRC_PUT8(hc->sca_base, msci->txs,
- SCA_TXS_CLK_RX | SCA_TXS_DIV1);
-#endif
- break;
-
- case SR_FLAGS_INT_CLK:
-#if BUGGY > 0
- printf("sr%d: Internal Clocking selected.\n", portndx);
-#endif
-
- /*
- * XXX I do need some code to set the baud rate here!
- */
-#ifdef N2_TEST_SPEED
- switch (hc->cardtype) {
- case SR_CRD_N2PCI:
- fecrp = (u_int *)(hc->sca_base + SR_FECR);
- mcr_v = *fecrp;
- etcndx = 2;
- break;
- case SR_CRD_N2:
- default:
- mcr_v = inb(hc->iobase + SR_MCR);
- etcndx = 0;
- }
-
- fifo_v = 0x10; /* stolen from Linux version */
-
- /*
- * search for appropriate speed in table, don't calc it:
- */
- wanted = sr_test_speed[portndx];
- rtp = &n2_rates[0]; /* point to first table item */
-
- while ((rtp->target > 0) /* search table for speed */
- &&(rtp->target != wanted))
- rtp++;
-
- /*
- * We've searched the table for a matching speed. If we've
- * found the correct rate line, we'll get the pre-calc'd
- * values for the TMC and baud rate divisor for subsequent
- * use...
- */
- if (rtp->target > 0) { /* use table-provided values */
- gotspeed = wanted;
- tmc_v = rtp->tmc_reg;
- br_v = rtp->br_reg;
- } else { /* otherwise assume 1MBit comm rate */
- gotspeed = 10000;
- tmc_v = 5;
- br_v = 1;
- }
-
- /*
- * Now we mask in the enable clock output for the MCR:
- */
- mcr_v |= etc0vals[etcndx + portndx];
-
- /*
- * Now we'll program the registers with these speed- related
- * contents...
- */
- SRC_PUT8(hc->sca_base, msci->tmc, tmc_v);
- SRC_PUT8(hc->sca_base, msci->trc0, fifo_v);
- SRC_PUT8(hc->sca_base, msci->rxs, SCA_RXS_CLK_INT + br_v);
- SRC_PUT8(hc->sca_base, msci->txs, SCA_TXS_CLK_INT + br_v);
-
- switch (hc->cardtype) {
- case SR_CRD_N2PCI:
- *fecrp = mcr_v;
- break;
- case SR_CRD_N2:
- default:
- outb(hc->iobase + SR_MCR, mcr_v);
- }
-
-#if BUGGY > 0
- if (wanted != gotspeed)
- printf("sr%d: Speed wanted=%d, found=%d\n",
- wanted, gotspeed);
-
- printf("sr%d: Internal Clock %dx100 BPS, tmc=%d, div=%d\n",
- portndx, gotspeed, tmc_v, br_v);
-#endif
-#else
- SRC_PUT8(hc->sca_base, msci->rxs,
- SCA_RXS_CLK_INT | SCA_RXS_DIV1);
- SRC_PUT8(hc->sca_base, msci->txs,
- SCA_TXS_CLK_INT | SCA_TXS_DIV1);
-
- SRC_PUT8(hc->sca_base, msci->tmc, 5);
-
- if (portndx == 0)
- switch (hc->cardtype) {
- case SR_CRD_N2PCI:
- fecrp = (u_int *)(hc->sca_base + SR_FECR);
- *fecrp |= SR_FECR_ETC0;
- break;
- case SR_CRD_N2:
- default:
- mcr_v = inb(hc->iobase + SR_MCR);
- mcr_v |= SR_MCR_ETC0;
- outb(hc->iobase + SR_MCR, mcr_v);
- }
- else
- switch (hc->cardtype) {
- case SR_CRD_N2:
- mcr_v = inb(hc->iobase + SR_MCR);
- mcr_v |= SR_MCR_ETC1;
- outb(hc->iobase + SR_MCR, mcr_v);
- break;
- case SR_CRD_N2PCI:
- fecrp = (u_int *)(hc->sca_base + SR_FECR);
- *fecrp |= SR_FECR_ETC1;
- break;
- }
-#endif
- }
-
- /*
- * XXX Disable all interrupts for now. I think if you are using the
- * dmac you don't use these interrupts.
- */
- SRC_PUT8(hc->sca_base, msci->ie0, 0);
- SRC_PUT8(hc->sca_base, msci->ie1, 0x0C);
- SRC_PUT8(hc->sca_base, msci->ie2, 0);
- SRC_PUT8(hc->sca_base, msci->fie, 0);
-
- SRC_PUT8(hc->sca_base, msci->sa0, 0);
- SRC_PUT8(hc->sca_base, msci->sa1, 0);
-
- SRC_PUT8(hc->sca_base, msci->idl, 0x7E); /* set flags value */
-
- SRC_PUT8(hc->sca_base, msci->rrc, 0x0E);
- SRC_PUT8(hc->sca_base, msci->trc0, 0x10);
- SRC_PUT8(hc->sca_base, msci->trc1, 0x1F);
-}
-
-/*
- * Configure the rx dma controller.
- */
-static void
-sr_init_rx_dmac(struct sr_softc *sc)
-{
- struct sr_hardc *hc;
- dmac_channel *dmac;
- sca_descriptor *rxd;
- u_int cda_v, sarb_v, rxbuf, rxda, rxda_d;
-
-#if BUGGY > 0
- printf("sr_init_rx_dmac(sc=%08x)\n", sc);
-#endif
-
- hc = sc->hc;
- dmac = &hc->sca->dmac[DMAC_RXCH(sc->scachan)];
-
- if (hc->mempages)
- SRC_SET_MEM(hc->iobase, sc->rxdesc);
-
- /*
- * This phase initializes the contents of the descriptor table
- * needed to construct a circular buffer...
- */
- rxd = (sca_descriptor *)(hc->mem_start + (sc->rxdesc & hc->winmsk));
- rxda_d = (u_int) hc->mem_start - (sc->rxdesc & ~hc->winmsk);
-
- for (rxbuf = sc->rxstart;
- rxbuf < sc->rxend;
- rxbuf += SR_BUF_SIZ, rxd++) {
- /*
- * construct the circular chain...
- */
- rxda = (u_int) & rxd[1] - rxda_d + hc->mem_pstart;
- rxd->cp = (u_short)(rxda & 0xffff);
-
- /*
- * set the on-card buffer address...
- */
- rxd->bp = (u_short)((rxbuf + hc->mem_pstart) & 0xffff);
- rxd->bpb = (u_char)(((rxbuf + hc->mem_pstart) >> 16) & 0xff);
-
- rxd->len = 0; /* bytes resident w/in granule */
- rxd->stat = 0xff; /* The sca write here when finished */
- }
-
- /*
- * heal the chain so that the last entry points to the first...
- */
- rxd--;
- rxd->cp = (u_short)((sc->rxdesc + hc->mem_pstart) & 0xffff);
-
- /*
- * reset the reception handler's index...
- */
- sc->rxhind = 0;
-
- /*
- * We'll now configure the receiver's DMA logic...
- */
- SRC_PUT8(hc->sca_base, dmac->dsr, 0); /* Disable DMA transfer */
- SRC_PUT8(hc->sca_base, dmac->dcr, SCA_DCR_ABRT);
-
- /* XXX maybe also SCA_DMR_CNTE */
- SRC_PUT8(hc->sca_base, dmac->dmr, SCA_DMR_TMOD | SCA_DMR_NF);
- SRC_PUT16(hc->sca_base, dmac->bfl, SR_BUF_SIZ);
-
- cda_v = (u_short)((sc->rxdesc + hc->mem_pstart) & 0xffff);
- sarb_v = (u_char)(((sc->rxdesc + hc->mem_pstart) >> 16) & 0xff);
-
- SRC_PUT16(hc->sca_base, dmac->cda, cda_v);
- SRC_PUT8(hc->sca_base, dmac->sarb, sarb_v);
-
- rxd = (sca_descriptor *)sc->rxstart;
-
- SRC_PUT16(hc->sca_base, dmac->eda,
- (u_short)((u_int) & rxd[sc->rxmax - 1] & 0xffff));
-
- SRC_PUT8(hc->sca_base, dmac->dir, 0xF0);
-
-
- SRC_PUT8(hc->sca_base, dmac->dsr, SCA_DSR_DE); /* Enable DMA */
-}
-
-/*
- * Configure the TX DMA descriptors.
- * Initialize the needed values and chain the descriptors.
- */
-static void
-sr_init_tx_dmac(struct sr_softc *sc)
-{
- int blk;
- u_int txbuf, txda, txda_d;
- struct sr_hardc *hc;
- sca_descriptor *txd;
- dmac_channel *dmac;
- struct buf_block *blkp;
- u_int x;
- u_int sarb_v;
-
-#if BUGGY > 0
- printf("sr_init_tx_dmac(sc=%08x)\n", sc);
-#endif
-
- hc = sc->hc;
- dmac = &hc->sca->dmac[DMAC_TXCH(sc->scachan)];
-
- if (hc->mempages)
- SRC_SET_MEM(hc->iobase, sc->block[0].txdesc);
-
- /*
- * Initialize the array of descriptors for transmission
- */
- for (blk = 0; blk < SR_TX_BLOCKS; blk++) {
- blkp = &sc->block[blk];
- txd = (sca_descriptor *)(hc->mem_start
- + (blkp->txdesc & hc->winmsk));
- txda_d = (u_int) hc->mem_start
- - (blkp->txdesc & ~hc->winmsk);
-
- x = 0;
- txbuf = blkp->txstart;
- for (; txbuf < blkp->txend; txbuf += SR_BUF_SIZ, txd++) {
- txda = (u_int) & txd[1] - txda_d + hc->mem_pstart;
- txd->cp = (u_short)(txda & 0xffff);
-
- txd->bp = (u_short)((txbuf + hc->mem_pstart)
- & 0xffff);
- txd->bpb = (u_char)(((txbuf + hc->mem_pstart) >> 16)
- & 0xff);
- txd->len = 0;
- txd->stat = 0;
- x++;
- }
-
- txd--;
- txd->cp = (u_short)((blkp->txdesc + hc->mem_pstart)
- & 0xffff);
-
- blkp->txtail = (u_int)txd - (u_int)hc->mem_start;
- }
-
- SRC_PUT8(hc->sca_base, dmac->dsr, 0); /* Disable DMA */
- SRC_PUT8(hc->sca_base, dmac->dcr, SCA_DCR_ABRT);
- SRC_PUT8(hc->sca_base, dmac->dmr, SCA_DMR_TMOD | SCA_DMR_NF);
- SRC_PUT8(hc->sca_base, dmac->dir,
- SCA_DIR_EOT | SCA_DIR_BOF | SCA_DIR_COF);
-
- sarb_v = (sc->block[0].txdesc + hc->mem_pstart) >> 16;
- sarb_v &= 0x00ff;
-
- SRC_PUT8(hc->sca_base, dmac->sarb, (u_char) sarb_v);
-}
-
-/*
- * Look through the descriptors to see if there is a complete packet
- * available. Stop if we get to where the sca is busy.
- *
- * Return the length and status of the packet.
- * Return nonzero if there is a packet available.
- *
- * NOTE:
- * It seems that we get the interrupt a bit early. The updateing of
- * descriptor values is not always completed when this is called.
- */
-static int
-sr_packet_avail(struct sr_softc *sc, int *len, u_char *rxstat)
-{
- int granules; /* count of granules in pkt */
- int wki, wko;
- struct sr_hardc *hc;
- sca_descriptor *rxdesc; /* current descriptor */
- sca_descriptor *endp; /* ending descriptor */
- sca_descriptor *cda; /* starting descriptor */
-
- hc = sc->hc; /* get card's information */
-
- /*
- * set up starting descriptor by pulling that info from the DMA half
- * of the HD chip...
- */
- wki = DMAC_RXCH(sc->scachan);
- wko = SRC_GET16(hc->sca_base, hc->sca->dmac[wki].cda);
-
- cda = (sca_descriptor *)(hc->mem_start + (wko & hc->winmsk));
-
-#if BUGGY > 1
- printf("sr_packet_avail(): wki=%d, wko=%04x, cda=%08x\n",
- wki, wko, cda);
-#endif
-
- /*
- * open the appropriate memory window and set our expectations...
- */
- if (hc->mempages) {
- SRC_SET_MEM(hc->iobase, sc->rxdesc);
- SRC_SET_ON(hc->iobase);
- }
- rxdesc = (sca_descriptor *)
- (hc->mem_start + (sc->rxdesc & hc->winmsk));
- endp = rxdesc;
- rxdesc = &rxdesc[sc->rxhind];
- endp = &endp[sc->rxmax];
-
- *len = 0; /* reset result total length */
- granules = 0; /* reset count of granules */
-
- /*
- * This loop will scan descriptors, but it *will* puke up if we wrap
- * around to our starting point...
- */
- while (rxdesc != cda) {
- *len += rxdesc->len; /* increment result length */
- granules++;
-
- /*
- * If we hit a valid packet's completion we'll know we've
- * got a live one, and that we can deliver the packet.
- * Since we're only allowed to report a packet available,
- * somebody else does that...
- */
- if (rxdesc->stat & SCA_DESC_EOM) { /* End Of Message */
- *rxstat = rxdesc->stat; /* return closing */
-#if BUGGY > 0
- printf("sr%d: PKT AVAIL len %d, %x, bufs %u.\n",
- sc->unit, *len, *rxstat, granules);
-#endif
- return 1; /* indicate success */
- }
- /*
- * OK, this packet take up multiple granules. Move on to
- * the next descriptor so we can consider it...
- */
- rxdesc++;
-
- if (rxdesc == endp) /* recognize & act on wrap point */
- rxdesc = (sca_descriptor *)
- (hc->mem_start + (sc->rxdesc & hc->winmsk));
- }
-
- /*
- * Nothing found in the DPRAM. Let the caller know...
- */
- *len = 0;
- *rxstat = 0;
-
- return 0;
-}
-
-/*
- * Copy a packet from the on card memory into a provided mbuf.
- * Take into account that buffers wrap and that a packet may
- * be larger than a buffer.
- */
-static void
-sr_copy_rxbuf(struct mbuf *m, struct sr_softc *sc, int len)
-{
- struct sr_hardc *hc;
- sca_descriptor *rxdesc;
- u_int rxdata;
- u_int rxmax;
- u_int off = 0;
- u_int tlen;
-
-#if BUGGY > 0
- printf("sr_copy_rxbuf(m=%08x,sc=%08x,len=%d)\n",
- m, sc, len);
-#endif
-
- hc = sc->hc;
-
- rxdata = sc->rxstart + (sc->rxhind * SR_BUF_SIZ);
- rxmax = sc->rxstart + (sc->rxmax * SR_BUF_SIZ);
-
- rxdesc = (sca_descriptor *)
- (hc->mem_start + (sc->rxdesc & hc->winmsk));
- rxdesc = &rxdesc[sc->rxhind];
-
- /*
- * Using the count of bytes in the received packet, we decrement it
- * for each granule (controller by an SCA descriptor) to control the
- * looping...
- */
- while (len) {
- /*
- * tlen gets the length of *this* granule... ...which is
- * then copied to the target buffer.
- */
- tlen = (len < SR_BUF_SIZ) ? len : SR_BUF_SIZ;
-
- if (hc->mempages)
- SRC_SET_MEM(hc->iobase, rxdata);
-
- bcopy(hc->mem_start + (rxdata & hc->winmsk),
- mtod(m, caddr_t) +off,
- tlen);
-
- off += tlen;
- len -= tlen;
-
- /*
- * now, return to the descriptor's window in DPRAM and reset
- * the descriptor we've just suctioned...
- */
- if (hc->mempages)
- SRC_SET_MEM(hc->iobase, sc->rxdesc);
-
- rxdesc->len = 0;
- rxdesc->stat = 0xff;
-
- /*
- * Move on to the next granule. If we've any remaining
- * bytes to process we'll just continue in our loop...
- */
- rxdata += SR_BUF_SIZ;
- rxdesc++;
-
- if (rxdata == rxmax) { /* handle the wrap point */
- rxdata = sc->rxstart;
- rxdesc = (sca_descriptor *)
- (hc->mem_start + (sc->rxdesc & hc->winmsk));
- }
- }
-}
-
-/*
- * If single is set, just eat a packet. Otherwise eat everything up to
- * where cda points. Update pointers to point to the next packet.
- *
- * This handles "flushing" of a packet as received...
- *
- * If the "single" parameter is zero, all pending reeceive traffic will
- * be flushed out of existence. A non-zero value will only drop the
- * *next* (currently) pending packet...
- */
-static void
-sr_eat_packet(struct sr_softc *sc, int single)
-{
- struct sr_hardc *hc;
- sca_descriptor *rxdesc; /* current descriptor being eval'd */
- sca_descriptor *endp; /* last descriptor in chain */
- sca_descriptor *cda; /* current start point */
- u_int loopcnt = 0; /* count of packets flushed ??? */
- u_char stat; /* captured status byte from descr */
-
- hc = sc->hc;
- cda = (sca_descriptor *)(hc->mem_start +
- (SRC_GET16(hc->sca_base,
- hc->sca->dmac[DMAC_RXCH(sc->scachan)].cda) &
- hc->winmsk));
-
- /*
- * loop until desc->stat == (0xff || EOM) Clear the status and
- * length in the descriptor. Increment the descriptor.
- */
- if (hc->mempages)
- SRC_SET_MEM(hc->iobase, sc->rxdesc);
-
- rxdesc = (sca_descriptor *)
- (hc->mem_start + (sc->rxdesc & hc->winmsk));
- endp = rxdesc;
- rxdesc = &rxdesc[sc->rxhind];
- endp = &endp[sc->rxmax];
-
- /*
- * allow loop, but abort it if we wrap completely...
- */
- while (rxdesc != cda) {
- loopcnt++;
-
- if (loopcnt > sc->rxmax) {
- printf("sr%d: eat pkt %d loop, cda %x, "
- "rxdesc %x, stat %x.\n",
- sc->unit, loopcnt, (u_int) cda, (u_int) rxdesc,
- rxdesc->stat);
- break;
- }
- stat = rxdesc->stat;
-
- rxdesc->len = 0;
- rxdesc->stat = 0xff;
-
- rxdesc++;
- sc->rxhind++;
-
- if (rxdesc == endp) {
- rxdesc = (sca_descriptor *)
- (hc->mem_start + (sc->rxdesc & hc->winmsk));
- sc->rxhind = 0;
- }
- if (single && (stat == SCA_DESC_EOM))
- break;
- }
-
- /*
- * Update the eda to the previous descriptor.
- */
- rxdesc = (sca_descriptor *)sc->rxdesc;
- rxdesc = &rxdesc[(sc->rxhind + sc->rxmax - 2) % sc->rxmax];
-
- SRC_PUT16(hc->sca_base,
- hc->sca->dmac[DMAC_RXCH(sc->scachan)].eda,
- (u_short)((u_int)(rxdesc + hc->mem_pstart) & 0xffff));
-}
-
-/*
- * While there is packets available in the rx buffer, read them out
- * into mbufs and ship them off.
- */
-static void
-sr_get_packets(struct sr_softc *sc)
-{
- u_char rxstat; /* acquired status byte */
- int i;
- int pkts; /* count of packets found */
- int rxndx; /* rcv buffer index */
- int tries; /* settling time counter */
- u_int len; /* length of pending packet */
- struct sr_hardc *hc; /* card-level information */
- sca_descriptor *rxdesc; /* descriptor in memory */
-#ifndef NETGRAPH
- struct ifnet *ifp; /* network intf ctl table */
-#endif /* NETGRAPH */
- struct mbuf *m = NULL; /* message buffer */
-
-#if BUGGY > 0
- printf("sr_get_packets(sc=%08x)\n", sc);
-#endif
-
- hc = sc->hc;
-#ifndef NETGRAPH
- ifp = &sc->ifsppp.pp_if;
-#endif /* NETGRAPH */
-
- if (hc->mempages) {
- SRC_SET_MEM(hc->iobase, sc->rxdesc);
- SRC_SET_ON(hc->iobase); /* enable shared memory */
- }
- pkts = 0; /* reset count of found packets */
-
- /*
- * for each complete packet in the receiving pool, process each
- * packet...
- */
- while (sr_packet_avail(sc, &len, &rxstat)) { /* packet pending? */
- /*
- * I have seen situations where we got the interrupt but the
- * status value wasn't deposited. This code should allow
- * the status byte's value to settle...
- */
-
- tries = 5;
-
- while ((rxstat == 0x00ff)
- && --tries)
- sr_packet_avail(sc, &len, &rxstat);
-
-#if BUGGY > 1
- printf("sr_packet_avail() returned len=%d, rxstat=%02ux\n",
- len, rxstat);
-#endif
-
- pkts++;
-#ifdef NETGRAPH
- sc->inbytes += len;
- sc->inlast = 0;
-#endif /* NETGRAPH */
-
- /*
- * OK, we've settled the incoming message status. We can now
- * process it...
- */
- if (((rxstat & SCA_DESC_ERRORS) == 0) && (len < MCLBYTES)) {
-#if BUGGY > 1
- printf("sr%d: sr_get_packet() rxstat=%02x, len=%d\n",
- sc->unit, rxstat, len);
-#endif
-
- MGETHDR(m, M_DONTWAIT, MT_DATA);
- if (m == NULL) {
- /*
- * eat (flush) packet if get mbuf fail!!
- */
- sr_eat_packet(sc, 1);
- continue;
- }
- /*
- * construct control information for pass-off
- */
-#ifndef NETGRAPH
- m->m_pkthdr.rcvif = ifp;
-#else
- m->m_pkthdr.rcvif = NULL;
-#endif /* NETGRAPH */
- m->m_pkthdr.len = m->m_len = len;
- if (len > MHLEN) {
- MCLGET(m, M_DONTWAIT);
- if ((m->m_flags & M_EXT) == 0) {
- /*
- * We couldn't get a big enough
- * message packet, so we'll send the
- * packet to /dev/null...
- */
- m_freem(m);
- sr_eat_packet(sc, 1);
- continue;
- }
- }
- /*
- * OK, we've got a good message buffer. Now we can
- * copy the received message into it
- */
- sr_copy_rxbuf(m, sc, len); /* copy from DPRAM */
-
-#ifndef NETGRAPH
- if (ifp->if_bpf)
- bpf_mtap(ifp, m);
-
-#if BUGGY > 3
- {
- u_char *bp;
-
- bp = (u_char *)m;
- printf("sr%d: rcvd=%02x%02x%02x%02x%02x%02x\n",
- sc->unit,
- bp[0], bp[1], bp[2],
- bp[4], bp[5], bp[6]);
- }
-#endif
- /*
- * Pass off the message to PPP, connecting it it to
- * the system...
- */
- switch (sc->protocol) {
-#if NFR > 0
- case N2_USE_FRP:
- fr_input(ifp, m);
- break;
-#endif
- case N2_USE_PPP:
- default:
- sppp_input(ifp, m);
- }
-
- ifp->if_ipackets++;
-
-#else /* NETGRAPH */
-#if BUGGY > 3
- {
- u_char *bp;
-
- bp = mtod(m,u_char *);
- printf("sr%d: rd=%02x:%02x:%02x:%02x:%02x:%02x",
- sc->unit,
- bp[0], bp[1], bp[2],
- bp[4], bp[5], bp[6]);
- printf(":%02x:%02x:%02x:%02x:%02x:%02x\n",
- bp[6], bp[7], bp[8],
- bp[9], bp[10], bp[11]);
- }
-#endif
- ng_queue_data(sc->hook, m, NULL);
- sc->ipackets++;
-#endif /* NETGRAPH */
- /*
- * Update the eda to the previous descriptor.
- */
- i = (len + SR_BUF_SIZ - 1) / SR_BUF_SIZ;
- sc->rxhind = (sc->rxhind + i) % sc->rxmax;
-
- rxdesc = (sca_descriptor *)sc->rxdesc;
- rxndx = (sc->rxhind + sc->rxmax - 2) % sc->rxmax;
- rxdesc = &rxdesc[rxndx];
-
- SRC_PUT16(hc->sca_base,
- hc->sca->dmac[DMAC_RXCH(sc->scachan)].eda,
- (u_short)((u_int)(rxdesc + hc->mem_pstart)
- & 0xffff));
-
- } else {
- int got_st3, got_cda, got_eda;
- int tries = 5;
-
- while((rxstat == 0xff) && --tries)
- sr_packet_avail(sc, &len, &rxstat);
-
- /*
- * It look like we get an interrupt early
- * sometimes and then the status is not
- * filled in yet.
- */
- if(tries && (tries != 5))
- continue;
-
- /*
- * This chunk of code handles the error packets.
- * We'll log them for posterity...
- */
- sr_eat_packet(sc, 1);
-
-#ifndef NETGRAPH
- ifp->if_ierrors++;
-#else
- sc->ierrors[0]++;
-#endif /* NETGRAPH */
-
- got_st3 = SRC_GET8(hc->sca_base,
- hc->sca->msci[sc->scachan].st3);
- got_cda = SRC_GET16(hc->sca_base,
- hc->sca->dmac[DMAC_RXCH(sc->scachan)].cda);
- got_eda = SRC_GET16(hc->sca_base,
- hc->sca->dmac[DMAC_RXCH(sc->scachan)].eda);
-
-#if BUGGY > 0
- printf("sr%d: Receive error chan %d, "
- "stat %02x, msci st3 %02x,"
- "rxhind %d, cda %04x, eda %04x.\n",
- sc->unit, sc->scachan, rxstat,
- got_st3, sc->rxhind, got_cda, got_eda);
-#endif
- }
- }
-
-#if BUGGY > 0
- printf("sr%d: sr_get_packets() found %d packet(s)\n",
- sc->unit, pkts);
-#endif
-
- if (hc->mempages)
- SRC_SET_OFF(hc->iobase);
-}
-
-/*
- * All DMA interrupts come here.
- *
- * Each channel has two interrupts.
- * Interrupt A for errors and Interrupt B for normal stuff like end
- * of transmit or receive dmas.
- */
-static void
-sr_dmac_intr(struct sr_hardc *hc, u_char isr1)
-{
- u_char dsr; /* contents of DMA Stat Reg */
- u_char dotxstart; /* enables for tranmit part */
- int mch; /* channel being processed */
- struct sr_softc *sc; /* channel's softc structure */
- sca_regs *sca = hc->sca;
- dmac_channel *dmac; /* dma structure of chip */
-
-#if BUGGY > 0
- printf("sr_dmac_intr(hc=%08x,isr1=%04x)\n", hc, isr1);
-#endif
-
- mch = 0; /* assume chan0 on card */
- dotxstart = isr1; /* copy for xmitter starts */
-
- /*
- * Shortcut if there is no interrupts for dma channel 0 or 1.
- * Skip processing for channel 0 if no incoming hit
- */
- if ((isr1 & 0x0F) == 0) {
- mch = 1;
- isr1 >>= 4;
- }
- do {
- sc = &hc->sc[mch];
-
- /*
- * Transmit channel - DMA Status Register Evaluation
- */
- if (isr1 & 0x0C) {
- dmac = &sca->dmac[DMAC_TXCH(mch)];
-
- /*
- * get the DMA Status Register contents and write
- * back to reset interrupt...
- */
- dsr = SRC_GET8(hc->sca_base, dmac->dsr);
- SRC_PUT8(hc->sca_base, dmac->dsr, dsr);
-
- /*
- * Check for (& process) a Counter overflow
- */
- if (dsr & SCA_DSR_COF) {
- printf("sr%d: TX DMA Counter overflow, "
- "txpacket no %lu.\n",
-#ifndef NETGRAPH
- sc->unit, sc->ifsppp.pp_if.if_opackets);
- sc->ifsppp.pp_if.if_oerrors++;
-#else
- sc->unit, sc->opackets);
- sc->oerrors++;
-#endif /* NETGRAPH */
- }
- /*
- * Check for (& process) a Buffer overflow
- */
- if (dsr & SCA_DSR_BOF) {
- printf("sr%d: TX DMA Buffer overflow, "
- "txpacket no %lu, dsr %02x, "
- "cda %04x, eda %04x.\n",
-#ifndef NETGRAPH
- sc->unit, sc->ifsppp.pp_if.if_opackets,
-#else
- sc->unit, sc->opackets,
-#endif /* NETGRAPH */
- dsr,
- SRC_GET16(hc->sca_base, dmac->cda),
- SRC_GET16(hc->sca_base, dmac->eda));
-#ifndef NETGRAPH
- sc->ifsppp.pp_if.if_oerrors++;
-#else
- sc->oerrors++;
-#endif /* NETGRAPH */
- }
- /*
- * Check for (& process) an End of Transfer (OK)
- */
- if (dsr & SCA_DSR_EOT) {
- /*
- * This should be the most common case.
- *
- * Clear the IFF_OACTIVE flag.
- *
- * Call srstart to start a new transmit if
- * there is data to transmit.
- */
-#if BUGGY > 0
- printf("sr%d: TX Completed OK\n", sc->unit);
-#endif
- sc->xmit_busy = 0;
-#ifndef NETGRAPH
- sc->ifsppp.pp_if.if_flags &= ~IFF_OACTIVE;
- sc->ifsppp.pp_if.if_timer = 0;
-#else
- /* XXX may need to mark tx inactive? */
- sc->out_deficit++;
- sc->out_dog = DOG_HOLDOFF;
-#endif /* NETGRAPH */
-
- if (sc->txb_inuse && --sc->txb_inuse)
- sr_xmit(sc);
- }
- }
- /*
- * Receive channel processing of DMA Status Register
- */
- if (isr1 & 0x03) {
- dmac = &sca->dmac[DMAC_RXCH(mch)];
-
- dsr = SRC_GET8(hc->sca_base, dmac->dsr);
- SRC_PUT8(hc->sca_base, dmac->dsr, dsr);
-
- /*
- * End of frame processing (MSG OK?)
- */
- if (dsr & SCA_DSR_EOM) {
-#if BUGGY > 0
- int tt, ind;
-
-#ifndef NETGRAPH
- tt = sc->ifsppp.pp_if.if_ipackets;
-#else /* NETGRAPH */
- tt = sc->ipackets;
-#endif /* NETGRAPH */
- ind = sc->rxhind;
-#endif
-
- sr_get_packets(sc);
-#if BUGGY > 0
-#ifndef NETGRAPH
- if (tt == sc->ifsppp.pp_if.if_ipackets)
-#else /* NETGRAPH */
- if (tt == sc->ipackets)
-#endif /* NETGRAPH */
- {
- sca_descriptor *rxdesc;
- int i;
-
- printf("SR: RXINTR isr1 %x, dsr %x, "
- "no data %d pkts, orxind %d.\n",
- dotxstart, dsr, tt, ind);
- printf("SR: rxdesc %x, rxstart %x, "
- "rxend %x, rxhind %d, "
- "rxmax %d.\n",
- sc->rxdesc, sc->rxstart,
- sc->rxend, sc->rxhind,
- sc->rxmax);
- printf("SR: cda %x, eda %x.\n",
- SRC_GET16(hc->sca_base, dmac->cda),
- SRC_GET16(hc->sca_base, dmac->eda));
-
- if (hc->mempages) {
- SRC_SET_ON(hc->iobase);
- SRC_SET_MEM(hc->iobase, sc->rxdesc);
- }
- rxdesc = (sca_descriptor *)
- (hc->mem_start +
- (sc->rxdesc & hc->winmsk));
- rxdesc = &rxdesc[sc->rxhind];
-
- for (i = 0; i < 3; i++, rxdesc++)
- printf("SR: rxdesc->stat %x, "
- "len %d.\n",
- rxdesc->stat,
- rxdesc->len);
-
- if (hc->mempages)
- SRC_SET_OFF(hc->iobase);
- }
-#endif /* BUGGY */
- }
- /*
- * Check for Counter overflow
- */
- if (dsr & SCA_DSR_COF) {
- printf("sr%d: RX DMA Counter overflow, "
- "rxpkts %lu.\n",
-#ifndef NETGRAPH
- sc->unit, sc->ifsppp.pp_if.if_ipackets);
- sc->ifsppp.pp_if.if_ierrors++;
-#else /* NETGRAPH */
- sc->unit, sc->ipackets);
- sc->ierrors[1]++;
-#endif /* NETGRAPH */
- }
- /*
- * Check for Buffer overflow
- */
- if (dsr & SCA_DSR_BOF) {
- printf("sr%d: RX DMA Buffer overflow, "
- "rxpkts %lu, rxind %d, "
- "cda %x, eda %x, dsr %x.\n",
-#ifndef NETGRAPH
- sc->unit, sc->ifsppp.pp_if.if_ipackets,
-#else /* NETGRAPH */
- sc->unit, sc->ipackets,
-#endif /* NETGRAPH */
- sc->rxhind,
- SRC_GET16(hc->sca_base, dmac->cda),
- SRC_GET16(hc->sca_base, dmac->eda),
- dsr);
-
- /*
- * Make sure we eat as many as possible.
- * Then get the system running again.
- */
- if (hc->mempages)
- SRC_SET_ON(hc->iobase);
-
- sr_eat_packet(sc, 0);
-#ifndef NETGRAPH
- sc->ifsppp.pp_if.if_ierrors++;
-#else /* NETGRAPH */
- sc->ierrors[2]++;
-#endif /* NETGRAPH */
-
- SRC_PUT8(hc->sca_base,
- sca->msci[mch].cmd,
- SCA_CMD_RXMSGREJ);
-
- SRC_PUT8(hc->sca_base, dmac->dsr, SCA_DSR_DE);
-
-#if BUGGY > 0
- printf("sr%d: RX DMA Buffer overflow, "
- "rxpkts %lu, rxind %d, "
- "cda %x, eda %x, dsr %x. After\n",
- sc->unit,
-#ifndef NETGRAPH
- sc->ipackets,
-#else /* NETGRAPH */
- sc->ifsppp.pp_if.if_ipackets,
-#endif /* NETGRAPH */
- sc->rxhind,
- SRC_GET16(hc->sca_base, dmac->cda),
- SRC_GET16(hc->sca_base, dmac->eda),
- SRC_GET8(hc->sca_base, dmac->dsr));
-#endif
-
- if (hc->mempages)
- SRC_SET_OFF(hc->iobase);
- }
- /*
- * End of Transfer
- */
- if (dsr & SCA_DSR_EOT) {
- /*
- * If this happen, it means that we are
- * receiving faster than what the processor
- * can handle.
- *
- * XXX We should enable the dma again.
- */
- printf("sr%d: RX End of xfer, rxpkts %lu.\n",
- sc->unit,
-#ifndef NETGRAPH
- sc->ifsppp.pp_if.if_ipackets);
- sc->ifsppp.pp_if.if_ierrors++;
-#else
- sc->ipackets);
- sc->ierrors[3]++;
-#endif /* NETGRAPH */
- }
- }
- isr1 >>= 4; /* process next half of ISR */
- mch++; /* and move to next channel */
- } while ((mch < NCHAN) && isr1); /* loop for each chn */
-
- /*
- * Now that we have done all the urgent things, see if we can fill
- * the transmit buffers.
- */
- for (mch = 0; mch < NCHAN; mch++) {
- if (dotxstart & 0x0C) { /* TX initiation enabled? */
- sc = &hc->sc[mch];
-#ifndef NETGRAPH
- srstart(&sc->ifsppp.pp_if);
-#else
- srstart(sc);
-#endif /* NETGRAPH */
- }
- dotxstart >>= 4;/* shift for next channel */
- }
-}
-#ifndef NETGRAPH
-/*
- * Perform timeout on an FR channel
- *
- * Establish a periodic check of open N2 ports; If
- * a port is open/active, its DCD state is checked
- * and a loss of DCD is recognized (and eventually
- * processed).
- */
-static void
-sr_modemck(void *arg)
-{
- u_int s;
- int card; /* card index in table */
- int cards; /* card list index */
- int mch; /* channel on card */
- u_char dcd_v; /* Data Carrier Detect */
- u_char got_st0; /* contents of ST0 */
- u_char got_st1; /* contents of ST1 */
- u_char got_st2; /* contents of ST2 */
- u_char got_st3; /* contents of ST3 */
- struct sr_hardc *hc; /* card's configuration */
- struct sr_hardc *Card[16];/* up to 16 cards in system */
- struct sr_softc *sc; /* channel's softc structure */
- struct ifnet *ifp; /* interface control table */
- msci_channel *msci; /* regs specific to channel */
-
- s = splimp();
-
-#if 0
- if (sr_opens == 0) { /* count of "up" channels */
- sr_watcher = 0; /* indicate no watcher */
- splx(s);
- return;
- }
-#endif
-
- sr_watcher = 1; /* mark that we're online */
-
- /*
- * Now we'll need a list of cards to process. Since we can handle
- * both ISA and PCI cards (and I didn't think of making this logic
- * global YET) we'll generate a single table of card table
- * addresses.
- */
- cards = 0;
-
- for (card = 0; card < NSR; card++) {
- hc = &sr_hardc[card];
-
- if (hc->sc == (void *)0)
- continue;
-
- Card[cards++] = hc;
- }
-
- hc = sr_hardc_pci;
-
- while (hc) {
- Card[cards++] = hc;
- hc = hc->next;
- }
-
- /*
- * OK, we've got work we can do. Let's do it... (Please note that
- * this code _only_ deals w/ ISA cards)
- */
- for (card = 0; card < cards; card++) {
- hc = Card[card];/* get card table */
-
- for (mch = 0; mch < hc->numports; mch++) {
- sc = &hc->sc[mch];
-
- if (sc->attached == 0)
- continue;
-
- ifp = &sc->ifsppp.pp_if;
-
- /*
- * if this channel isn't "up", skip it
- */
- if ((ifp->if_flags & IFF_UP) == 0)
- continue;
-
- /*
- * OK, now we can go looking at this channel's
- * actual register contents...
- */
- msci = &hc->sca->msci[sc->scachan];
-
- /*
- * OK, now we'll look into the actual status of this
- * channel...
- *
- * I suck in more registers than strictly needed
- */
- got_st0 = SRC_GET8(hc->sca_base, msci->st0);
- got_st1 = SRC_GET8(hc->sca_base, msci->st1);
- got_st2 = SRC_GET8(hc->sca_base, msci->st2);
- got_st3 = SRC_GET8(hc->sca_base, msci->st3);
-
- /*
- * We want to see if the DCD signal is up (DCD is
- * true if zero)
- */
- dcd_v = (got_st3 & SCA_ST3_DCD) == 0;
-
- if (dcd_v == 0)
- printf("sr%d: DCD lost\n", sc->unit);
- }
- }
-
- /*
- * OK, now set up for the next modem signal checking pass...
- */
- timeout(sr_modemck, NULL, hz);
-
- splx(s);
-}
-
-#else /* NETGRAPH */
-/*
- * If a port is open/active, it's DCD state is checked
- * and a loss of DCD is recognized (and eventually processed?).
- */
-static void
-sr_modemck(struct sr_softc *sc )
-{
- u_int s;
- u_char got_st3; /* contents of ST3 */
- struct sr_hardc *hc = sc->hc; /* card's configuration */
- msci_channel *msci; /* regs specific to channel */
-
- s = splimp();
-
-
- if (sc->running == 0)
- return;
- /*
- * OK, now we can go looking at this channel's register contents...
- */
- msci = &hc->sca->msci[sc->scachan];
- got_st3 = SRC_GET8(hc->sca_base, msci->st3);
-
- /*
- * We want to see if the DCD signal is up (DCD is true if zero)
- */
- sc->dcd = (got_st3 & SCA_ST3_DCD) == 0;
- splx(s);
-}
-
-#endif /* NETGRAPH */
-static void
-sr_msci_intr(struct sr_hardc *hc, u_char isr0)
-{
- printf("src%d: SRINTR: MSCI\n", hc->cunit);
-}
-
-static void
-sr_timer_intr(struct sr_hardc *hc, u_char isr2)
-{
- printf("src%d: SRINTR: TIMER\n", hc->cunit);
-}
-
-#ifdef NETGRAPH
-/*****************************************
- * Device timeout/watchdog routine.
- * called once per second.
- * checks to see that if activity was expected, that it hapenned.
- * At present we only look to see if expected output was completed.
- */
-static void
-ngsr_watchdog_frame(void * arg)
-{
- struct sr_softc * sc = arg;
- int s;
- int speed;
-
- if(sc->running == 0)
- return; /* if we are not running let timeouts die */
- /*
- * calculate the apparent throughputs
- * XXX a real hack
- */
- s = splimp();
- speed = sc->inbytes - sc->lastinbytes;
- sc->lastinbytes = sc->inbytes;
- if ( sc->inrate < speed )
- sc->inrate = speed;
- speed = sc->outbytes - sc->lastoutbytes;
- sc->lastoutbytes = sc->outbytes;
- if ( sc->outrate < speed )
- sc->outrate = speed;
- sc->inlast++;
- splx(s);
-
- if ((sc->inlast > QUITE_A_WHILE)
- && (sc->out_deficit > LOTS_OF_PACKETS)) {
- log(LOG_ERR, "sr%d: No response from remote end\n", sc->unit);
- s = splimp();
- sr_down(sc);
- sr_up(sc);
- sc->inlast = sc->out_deficit = 0;
- splx(s);
- } else if ( sc->xmit_busy ) { /* no TX -> no TX timeouts */
- if (sc->out_dog == 0) {
- log(LOG_ERR, "sr%d: Transmit failure.. no clock?\n",
- sc->unit);
- s = splimp();
- srwatchdog(sc);
-#if 0
- sr_down(sc);
- sr_up(sc);
-#endif
- splx(s);
- sc->inlast = sc->out_deficit = 0;
- } else {
- sc->out_dog--;
- }
- }
- sr_modemck(sc); /* update the DCD status */
- sc->handle = timeout(ngsr_watchdog_frame, sc, hz);
-}
-
-/***********************************************************************
- * This section contains the methods for the Netgraph interface
- ***********************************************************************/
-/*
- * It is not possible or allowable to create a node of this type.
- * If the hardware exists, it will already have created it.
- */
-static int
-ngsr_constructor(node_p *nodep)
-{
- return (EINVAL);
-}
-
-/*
- * give our ok for a hook to be added...
- * If we are not running this should kick the device into life.
- * The hook's private info points to our stash of info about that
- * channel.
- */
-static int
-ngsr_newhook(node_p node, hook_p hook, const char *name)
-{
- struct sr_softc * sc = node->private;
-
- /*
- * check if it's our friend the debug hook
- */
- if (strcmp(name, NG_SR_HOOK_DEBUG) == 0) {
- hook->private = NULL; /* paranoid */
- sc->debug_hook = hook;
- return (0);
- }
-
- /*
- * Check for raw mode hook.
- */
- if (strcmp(name, NG_SR_HOOK_RAW) != 0) {
- return (EINVAL);
- }
- hook->private = sc;
- sc->hook = hook;
- sc->datahooks++;
- sr_up(sc);
- return (0);
-}
-
-/*
- * incoming messages.
- * Just respond to the generic TEXT_STATUS message
- */
-static int
-ngsr_rcvmsg(node_p node,
- struct ng_mesg *msg, const char *retaddr, struct ng_mesg **resp)
-{
- struct sr_softc * sc;
- int error = 0;
-
- sc = node->private;
- switch (msg->header.typecookie) {
- case NG_SR_COOKIE:
- error = EINVAL;
- break;
- case NGM_GENERIC_COOKIE:
- switch(msg->header.cmd) {
- case NGM_TEXT_STATUS: {
- char *arg;
- int pos = 0;
- int resplen = sizeof(struct ng_mesg) + 512;
- MALLOC(*resp, struct ng_mesg *, resplen,
- M_NETGRAPH, M_NOWAIT);
- if (*resp == NULL) {
- error = ENOMEM;
- break;
- }
- bzero(*resp, resplen);
- arg = (*resp)->data;
-
- /*
- * Put in the throughput information.
- */
- pos = sprintf(arg, "%ld bytes in, %ld bytes out\n"
- "highest rate seen: %ld B/S in, %ld B/S out\n",
- sc->inbytes, sc->outbytes,
- sc->inrate, sc->outrate);
- pos += sprintf(arg + pos,
- "%ld output errors\n",
- sc->oerrors);
- pos += sprintf(arg + pos,
- "ierrors = %ld, %ld, %ld, %ld, %ld, %ld\n",
- sc->ierrors[0],
- sc->ierrors[1],
- sc->ierrors[2],
- sc->ierrors[3],
- sc->ierrors[4],
- sc->ierrors[5]);
-
- (*resp)->header.version = NG_VERSION;
- (*resp)->header.arglen = strlen(arg) + 1;
- (*resp)->header.token = msg->header.token;
- (*resp)->header.typecookie = NG_SR_COOKIE;
- (*resp)->header.cmd = msg->header.cmd;
- strncpy((*resp)->header.cmdstr, "status",
- NG_CMDSTRLEN);
- }
- break;
- default:
- error = EINVAL;
- break;
- }
- break;
- default:
- error = EINVAL;
- break;
- }
- free(msg, M_NETGRAPH);
- return (error);
-}
-
-/*
- * get data from another node and transmit it to the correct channel
- */
-static int
-ngsr_rcvdata(hook_p hook, struct mbuf *m, meta_p meta)
-{
- int s;
- int error = 0;
- struct sr_softc * sc = hook->node->private;
- struct ifqueue *xmitq_p;
-
- /*
- * data doesn't come in from just anywhere (e.g control hook)
- */
- if ( hook->private == NULL) {
- error = ENETDOWN;
- goto bad;
- }
-
- /*
- * Now queue the data for when it can be sent
- */
- if (meta && meta->priority > 0) {
- xmitq_p = (&sc->xmitq_hipri);
- } else {
- xmitq_p = (&sc->xmitq);
- }
- s = splimp();
- if (IF_QFULL(xmitq_p)) {
- IF_DROP(xmitq_p);
- splx(s);
- error = ENOBUFS;
- goto bad;
- }
- IF_ENQUEUE(xmitq_p, m);
- srstart(sc);
- splx(s);
- return (0);
-
-bad:
- /*
- * It was an error case.
- * check if we need to free the mbuf, and then return the error
- */
- NG_FREE_DATA(m, meta);
- return (error);
-}
-
-/*
- * do local shutdown processing..
- * this node will refuse to go away, unless the hardware says to..
- * don't unref the node, or remove our name. just clear our links up.
- */
-static int
-ngsr_rmnode(node_p node)
-{
- struct sr_softc * sc = node->private;
-
- sr_down(sc);
- ng_cutlinks(node);
- node->flags &= ~NG_INVALID; /* bounce back to life */
- return (0);
-}
-
-/* already linked */
-static int
-ngsr_connect(hook_p hook)
-{
- /* be really amiable and just say "YUP that's OK by me! " */
- return (0);
-}
-
-/*
- * notify on hook disconnection (destruction)
- *
- * Invalidate the private data associated with this dlci.
- * For this type, removal of the last link resets tries to destroy the node.
- * As the device still exists, the shutdown method will not actually
- * destroy the node, but reset the device and leave it 'fresh' :)
- *
- * The node removal code will remove all references except that owned by the
- * driver.
- */
-static int
-ngsr_disconnect(hook_p hook)
-{
- struct sr_softc * sc = hook->node->private;
- int s;
- /*
- * If it's the data hook, then free resources etc.
- */
- if (hook->private) {
- s = splimp();
- sc->datahooks--;
- if (sc->datahooks == 0)
- sr_down(sc);
- splx(s);
- } else {
- sc->debug_hook = NULL;
- }
- return (0);
-}
-
-/*
- * called during bootup
- * or LKM loading to put this type into the list of known modules
- */
-static void
-ngsr_init(void *ignored)
-{
- if (ng_newtype(&typestruct))
- printf("ngsr install failed\n");
- ngsr_done_init = 1;
-}
-#endif /* NETGRAPH */
-
-/*
- ********************************* END ************************************
- */
diff --git a/sys/dev/sr/if_sr_pci.c b/sys/dev/sr/if_sr_pci.c
deleted file mode 100644
index 04d0db82c418..000000000000
--- a/sys/dev/sr/if_sr_pci.c
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright (c) 1996 John Hay.
- * Copyright (c) 1996 SDL Communications, Inc.
- * 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 author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include "sr.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/malloc.h>
-
-#include <pci/pcivar.h>
-
-#ifndef BUGGY
-#define BUGGY 0
-#endif
-
-/*
- * The must match with the real functions in if_sr.c
- */
-extern void *srattach_pci(int unit,
- vm_offset_t plx_vaddr,
- vm_offset_t sca_vaddr);
-extern void srintr_hc(void *hc);
-
-static const char *sr_pci_probe(pcici_t tag, pcidi_t type);
-static void sr_pci_attach(pcici_t config_id, int unit);
-
-static u_long src_count = NSR;
-
-static struct pci_device sr_pci_driver =
-{
- "src",
- sr_pci_probe,
- sr_pci_attach,
- &src_count,
- NULL
-};
-
-COMPAT_PCI_DRIVER (sr_pci, sr_pci_driver);
-
-static const char *
-sr_pci_probe(pcici_t tag, pcidi_t type)
-{
- switch(type) {
- case 0x556812aa:
- return ("RISCom/N2pci");
- break;
- case 0x55684778:
- case 0x55684877:
- /*
- * XXX This can probably be removed sometime.
- */
- return ("RISCom/N2pci (old id)");
- break;
- default:
- break;
- }
- return (0);
-}
-
-static void
-sr_pci_attach(pcici_t config_id, int unit)
-{
- void *hc;
-#if BUGGY > 0
- u_int *fecr;
-#endif
- vm_offset_t plx_vaddr, plx_paddr, sca_vaddr, sca_paddr;
-
-#if BUGGY > 0
- printf("srp: ID %x\n", pci_conf_read(config_id, 0));
- printf("srp: BADR0 %x\n", pci_conf_read(config_id, 0x10));
- printf("srp: BADR1 %x\n", pci_conf_read(config_id, 0x18));
-#endif
- if(!pci_map_mem(config_id, 0x10, &plx_vaddr, &plx_paddr)) {
- printf("srp: map failed.\n");
- return;
- }
-#if BUGGY > 0
- printf("srp: vaddr %x, paddr %x\n", plx_vaddr, plx_paddr);
-#endif
- if(!pci_map_mem(config_id, 0x18, &sca_vaddr, &sca_paddr)) {
- printf("srp: map failed.\n");
- return;
- }
-#if BUGGY > 0
- printf("srp: vaddr %x, paddr %x\n", sca_vaddr, sca_paddr);
- fecr = (u_int *)(sca_vaddr + 0x200);
- printf("srp: FECR %x\n", *fecr);
-#endif
-
- hc = srattach_pci(unit, plx_vaddr, sca_vaddr);
- if(!hc)
- return;
-
- if(!pci_map_int(config_id, srintr_hc, (void *)hc, &net_imask)) {
- free(hc, M_DEVBUF);
- return;
- }
-}
diff --git a/sys/dev/sr/if_srregs.h b/sys/dev/sr/if_srregs.h
deleted file mode 100644
index 64d9ba11c50e..000000000000
--- a/sys/dev/sr/if_srregs.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (c) 1995 John Hay.
- * Copyright (c) 1996 SDL Communications, Inc.
- * 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 author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#ifndef _IF_SRREGS_H_
-#define _IF_SRREGS_H_
-
-#define NCHAN 2 /* A HD64570 chip have 2 channels */
-
-#define SR_BUF_SIZ 512
-#define SR_TX_BLOCKS 2 /* Sepperate sets of tx buffers */
-
-#define SR_CRD_N2 1
-#define SR_CRD_N2PCI 2
-
-/*
- * RISCom/N2 ISA card.
- */
-#define SRC_IO_SIZ 0x10 /* Actually a lie. It uses a lot more. */
-#define SRC_WIN_SIZ 0x00004000
-#define SRC_WIN_MSK (SRC_WIN_SIZ - 1)
-#define SRC_WIN_SHFT 14
-
-#define SR_FLAGS_NCHAN_MSK 0x0000000F
-#define SR_FLAGS_0_CLK_MSK 0x00000030
-#define SR_FLAGS_0_EXT_CLK 0x00000000 /* External RX clock shared by TX */
-#define SR_FLAGS_0_EXT_SEP_CLK 0x00000010 /* Sepperate external clocks */
-#define SR_FLAGS_0_INT_CLK 0x00000020 /* Internal clock */
-#define SR_FLAGS_1_CLK_MSK 0x000000C0
-#define SR_FLAGS_1_EXT_CLK 0x00000000 /* External RX clock shared by TX */
-#define SR_FLAGS_1_EXT_SEP_CLK 0x00000040 /* Sepperate external clocks */
-#define SR_FLAGS_1_INT_CLK 0x00000080 /* Internal clock */
-
-#define SR_FLAGS_CLK_SHFT 4
-#define SR_FLAGS_CLK_CHAN_SHFT 2
-#define SR_FLAGS_EXT_CLK 0x00000000 /* External RX clock shared by TX */
-#define SR_FLAGS_EXT_SEP_CLK 0x00000001 /* Sepperate external clocks */
-#define SR_FLAGS_INT_CLK 0x00000002 /* Internal clock */
-
-#define SR_PCR 0x00 /* RW, PC Control Register */
-#define SR_BAR 0x02 /* RW, Base Address Register */
-#define SR_PSR 0x04 /* RW, Page Scan Register */
-#define SR_MCR 0x06 /* RW, Modem Control Register */
-
-#define SR_PCR_SCARUN 0x01 /* !Reset */
-#define SR_PCR_EN_VPM 0x02 /* Running above 1M */
-#define SR_PCR_MEM_WIN 0x04 /* Open memory window */
-#define SR_PCR_ISA16 0x08 /* 16 bit ISA mode */
-#define SR_PCR_16M_SEL 0xF0 /* A20-A23 Addresses */
-
-#define SR_PSR_PG_SEL 0x1F /* Page 0 - 31 select */
-#define SR_PG_MSK 0x1F
-#define SR_PSR_WIN_SIZ 0x60 /* Window size select */
-#define SR_PSR_WIN_16K 0x00
-#define SR_PSR_WIN_32K 0x20
-#define SR_PSR_WIN_64K 0x40
-#define SR_PSR_WIN_128K 0x60
-#define SR_PSR_EN_SCA_DMA 0x80 /* Enable the SCA DMA */
-
-#define SR_MCR_DTR0 0x01 /* Deactivate DTR0 */
-#define SR_MCR_DTR1 0x02 /* Deactivate DTR1 */
-#define SR_MCR_DSR0 0x04 /* DSR0 Status */
-#define SR_MCR_DSR1 0x08 /* DSR1 Status */
-#define SR_MCR_TE0 0x10 /* Enable RS422 TXD */
-#define SR_MCR_TE1 0x20 /* Enable RS422 TXD */
-#define SR_MCR_ETC0 0x40 /* Enable Ext Clock out */
-#define SR_MCR_ETC1 0x80 /* Enable Ext Clock out */
-
-/*
- * RISCom/N2 PCI card.
- */
-#define SR_FECR 0x0200 /* Front End Control Register */
-#define SR_FECR_ETC0 0x0001 /* Enable Ext Clock out */
-#define SR_FECR_ETC1 0x0002 /* Enable Ext Clock out */
-#define SR_FECR_TE0 0x0004 /* Enable RS422 TXD */
-#define SR_FECR_TE1 0x0008 /* Enable RS422 TXD */
-#define SR_FECR_GPO0 0x0010 /* General Purpose Output */
-#define SR_FECR_GPO1 0x0020 /* General Purpose Output */
-#define SR_FECR_DTR0 0x0040 /* 0 for active, 1 for inactive */
-#define SR_FECR_DTR1 0x0080 /* 0 for active, 1 for inactive */
-#define SR_FECR_DSR0 0x0100 /* DSR0 Status */
-#define SR_FECR_ID0 0x0E00 /* ID of channel 0 */
-#define SR_FECR_DSR1 0x1000 /* DSR1 Status */
-#define SR_FECR_ID1 0xE000 /* ID of channel 1 */
-
-#define SR_FE_ID_V35 0x00 /* V.35 Interface */
-#define SR_FE_ID_RS232 0x01 /* RS232 Interface */
-#define SR_FE_ID_TEST 0x02 /* Test Board */
-#define SR_FE_ID_RS422 0x03 /* RS422 Interface */
-#define SR_FE_ID_HSSI 0x05 /* HSSI Interface */
-#define SR_FE_ID_X21 0x06 /* X.21 Interface */
-#define SR_FE_ID_NONE 0x07 /* No card present */
-#define SR_FE_ID0_SHFT 9
-#define SR_FE_ID1_SHFT 13
-
-#endif /* _IF_SRREGS_H_ */
diff --git a/sys/dev/syscons/apm/apm_saver.c b/sys/dev/syscons/apm/apm_saver.c
deleted file mode 100644
index d7863ba9a53e..000000000000
--- a/sys/dev/syscons/apm/apm_saver.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/*-
- * Copyright (c) 1999 Nick Sayer (who stole shamelessly from blank_saver)
- * 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,
- * without modification, immediately at the beginning of the file.
- * 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/consio.h>
-#include <sys/fbio.h>
-
-#include <dev/fb/fbreg.h>
-#include <dev/fb/splashreg.h>
-#include <dev/syscons/syscons.h>
-
-#include <sys/select.h>
-#include <machine/apm_bios.h>
-#include <machine/pc/bios.h>
-#include <i386/apm/apm.h>
-
-extern int apm_display __P((int newstate));
-
-extern struct apm_softc apm_softc;
-
-static int blanked=0;
-
-static int
-apm_saver(video_adapter_t *adp, int blank)
-{
- struct apm_softc *sc = &apm_softc;
-
- if (!sc->initialized || !sc->active)
- return 0;
-
- if (blank==blanked)
- return 0;
-
- blanked=blank;
-
- apm_display(!blanked);
-
- return 0;
-}
-
-static int
-apm_init(video_adapter_t *adp)
-{
- struct apm_softc *sc = &apm_softc;
-
- if (!sc->initialized || !sc->active)
- printf("WARNING: apm_saver module requires apm enabled\n");
- return 0;
-}
-
-static int
-apm_term(video_adapter_t *adp)
-{
- return 0;
-}
-
-static scrn_saver_t apm_module = {
- "apm_saver", apm_init, apm_term, apm_saver, NULL,
-};
-
-SAVER_MODULE(apm_saver, apm_module);
diff --git a/sys/dev/syscons/blank/blank_saver.c b/sys/dev/syscons/blank/blank_saver.c
deleted file mode 100644
index 960acca5a512..000000000000
--- a/sys/dev/syscons/blank/blank_saver.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/*-
- * Copyright (c) 1995-1998 Søren Schmidt
- * 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,
- * without modification, immediately at the beginning of the file.
- * 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/consio.h>
-#include <sys/fbio.h>
-
-#include <dev/fb/fbreg.h>
-#include <dev/fb/splashreg.h>
-#include <dev/syscons/syscons.h>
-
-static int
-blank_saver(video_adapter_t *adp, int blank)
-{
- (*vidsw[adp->va_index]->blank_display)(adp,
- (blank) ? V_DISPLAY_BLANK
- : V_DISPLAY_ON);
- return 0;
-}
-
-static int
-blank_init(video_adapter_t *adp)
-{
- if ((*vidsw[adp->va_index]->blank_display)(adp, V_DISPLAY_ON) == 0)
- return 0;
- return ENODEV;
-}
-
-static int
-blank_term(video_adapter_t *adp)
-{
- return 0;
-}
-
-static scrn_saver_t blank_module = {
- "blank_saver", blank_init, blank_term, blank_saver, NULL,
-};
-
-SAVER_MODULE(blank_saver, blank_module);
diff --git a/sys/dev/syscons/daemon/daemon_saver.c b/sys/dev/syscons/daemon/daemon_saver.c
deleted file mode 100644
index b056b486a039..000000000000
--- a/sys/dev/syscons/daemon/daemon_saver.c
+++ /dev/null
@@ -1,393 +0,0 @@
-/*-
- * Copyright (c) 1997 Sandro Sigala, Brescia, Italy.
- * Copyright (c) 1997 Chris Shenton
- * Copyright (c) 1995 S ren Schmidt
- * 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
- * in this position and unchanged.
- * 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/module.h>
-#include <sys/malloc.h>
-#include <sys/kernel.h>
-#include <sys/sysctl.h>
-#include <sys/consio.h>
-#include <sys/fbio.h>
-
-#include <machine/pc/display.h>
-
-#include <dev/fb/fbreg.h>
-#include <dev/fb/splashreg.h>
-#include <dev/syscons/syscons.h>
-
-#define DAEMON_MAX_WIDTH 32
-#define DAEMON_MAX_HEIGHT 19
-
-static char *message;
-static int messagelen;
-static int blanked;
-
-/* Who is the author of this ASCII pic? */
-
-static char *daemon_pic[] = {
- " , ,",
- " /( )`",
- " \\ \\___ / |",
- " /- _ `-/ '",
- " (/\\/ \\ \\ /\\",
- " / / | ` \\",
- " O O ) / |",
- " `-^--'`< '",
- " (_.) _ ) /",
- " `.___/` /",
- " `-----' /",
- "<----. __ / __ \\",
- "<----|====O)))==) \\) /====",
- "<----' `--' `.__,' \\",
- " | |",
- " \\ / /\\",
- " ______( (_ / \\______/",
- " ,' ,-----' |",
- " `--{__________)",
- NULL
-};
-
-static char *daemon_attr[] = {
- " R R",
- " RR RR",
- " R RRRR R R",
- " RR W RRR R",
- " RWWW W R RR",
- " W W W R R",
- " B B W R R",
- " WWWWWWRR R",
- " RRRR R R R",
- " RRRRRRR R",
- " RRRRRRR R",
- "YYYYYY RR R RR R",
- "YYYYYYYYYYRRRRYYR RR RYYYY",
- "YYYYYY RRRR RRRRRR R",
- " R R",
- " R R RR",
- " CCCCCCR RR R RRRRRRRR",
- " CC CCCCCCC C",
- " CCCCCCCCCCCCCCC",
- NULL
-};
-
-/*
- * Reverse a graphics character, or return unaltered if no mirror;
- * should do alphanumerics too, but I'm too lazy. <cshenton@it.hq.nasa.gov>
- */
-
-static char
-xflip_symbol(char symbol)
-{
- static const char lchars[] = "`'(){}[]\\/<>";
- static const char rchars[] = "'`)(}{][/\\><";
- int pos;
-
- for (pos = 0; lchars[pos] != '\0'; pos++)
- if (lchars[pos] == symbol)
- return rchars[pos];
-
- return symbol;
-}
-
-static void
-clear_daemon(sc_softc_t *sc, int xpos, int ypos, int dxdir, int xoff, int yoff,
- int xlen, int ylen)
-{
- int y;
-
- if (xlen <= 0)
- return;
- for (y = yoff; y < ylen; y++) {
- sc_vtb_erase(&sc->cur_scp->scr,
- (ypos + y)*sc->cur_scp->xsize + xpos + xoff,
- xlen - xoff,
- sc->scr_map[0x20], (FG_LIGHTGREY | BG_BLACK) << 8);
- }
-}
-
-static void
-draw_daemon(sc_softc_t *sc, int xpos, int ypos, int dxdir, int xoff, int yoff,
- int xlen, int ylen)
-{
- int x, y;
- int px;
- int attr;
-
- for (y = yoff; y < ylen; y++) {
- if (dxdir < 0)
- px = xoff;
- else
- px = DAEMON_MAX_WIDTH - xlen;
- if (px >= strlen(daemon_pic[y]))
- continue;
- for (x = xoff; (x < xlen) && (daemon_pic[y][px] != '\0'); x++, px++) {
- switch (daemon_attr[y][px]) {
-#ifndef PC98
- case 'R': attr = (FG_LIGHTRED|BG_BLACK)<<8; break;
- case 'Y': attr = (FG_YELLOW|BG_BLACK)<<8; break;
- case 'B': attr = (FG_LIGHTBLUE|BG_BLACK)<<8; break;
- case 'W': attr = (FG_LIGHTGREY|BG_BLACK)<<8; break;
- case 'C': attr = (FG_CYAN|BG_BLACK)<<8; break;
- default: attr = (FG_WHITE|BG_BLACK)<<8; break;
-#else /* PC98 */
- case 'R': attr = (FG_RED|BG_BLACK)<<8; break;
- case 'Y': attr = (FG_BROWN|BG_BLACK)<<8; break;
- case 'B': attr = (FG_BLUE|BG_BLACK)<<8; break;
- case 'W': attr = (FG_LIGHTGREY|BG_BLACK)<<8; break;
- case 'C': attr = (FG_CYAN|BG_BLACK)<<8; break;
- default: attr = (FG_LIGHTGREY|BG_BLACK)<<8; break;
-#endif /* PC98 */
- }
- if (dxdir < 0) { /* Moving left */
- sc_vtb_putc(&sc->cur_scp->scr,
- (ypos + y)*sc->cur_scp->xsize
- + xpos + x,
- sc->scr_map[daemon_pic[y][px]],
- attr);
- } else { /* Moving right */
- sc_vtb_putc(&sc->cur_scp->scr,
- (ypos + y)*sc->cur_scp->xsize
- + xpos + DAEMON_MAX_WIDTH
- - px - 1,
- sc->scr_map[xflip_symbol(daemon_pic[y][px])],
- attr);
- }
- }
- }
-}
-
-static void
-clear_string(sc_softc_t *sc, int xpos, int ypos, int xoff, char *s, int len)
-{
- if (len <= 0)
- return;
- sc_vtb_erase(&sc->cur_scp->scr,
- ypos*sc->cur_scp->xsize + xpos + xoff, len - xoff,
- sc->scr_map[0x20], (FG_LIGHTGREY | BG_BLACK) << 8);
-}
-
-static void
-draw_string(sc_softc_t *sc, int xpos, int ypos, int xoff, char *s, int len)
-{
- int x;
-
- for (x = xoff; x < len; x++) {
- sc_vtb_putc(&sc->cur_scp->scr,
- ypos*sc->cur_scp->xsize + xpos + x,
- sc->scr_map[s[x]], (FG_LIGHTGREEN | BG_BLACK) << 8);
- }
-}
-
-static int
-daemon_saver(video_adapter_t *adp, int blank)
-{
- static int txpos = 10, typos = 10;
- static int txdir = -1, tydir = -1;
- static int dxpos = 0, dypos = 0;
- static int dxdir = 1, dydir = 1;
- static int moved_daemon = 0;
- static int xoff, yoff, toff;
- static int xlen, ylen, tlen;
- sc_softc_t *sc;
- scr_stat *scp;
- int min, max;
-
- sc = sc_find_softc(adp, NULL);
- if (sc == NULL)
- return EAGAIN;
- scp = sc->cur_scp;
-
- if (blank) {
- if (adp->va_info.vi_flags & V_INFO_GRAPHICS)
- return EAGAIN;
- if (blanked == 0) {
-#ifdef PC98
- if (epson_machine_id == 0x20) {
- outb(0x43f, 0x42);
- outb(0x0c17, inb(0xc17) & ~0x08);
- outb(0x43f, 0x40);
- }
-#endif /* PC98 */
- /* clear the screen and set the border color */
- sc_vtb_clear(&scp->scr, sc->scr_map[0x20],
- (FG_LIGHTGREY | BG_BLACK) << 8);
- (*vidsw[adp->va_index]->set_hw_cursor)(adp, -1, -1);
- sc_set_border(scp, 0);
- xlen = ylen = tlen = 0;
- }
- if (blanked++ < 2)
- return 0;
- blanked = 1;
-
- clear_daemon(sc, dxpos, dypos, dxdir, xoff, yoff, xlen, ylen);
- clear_string(sc, txpos, typos, toff, (char *)message, tlen);
-
- if (++moved_daemon) {
- /*
- * The daemon picture may be off the screen, if
- * screen size is chagened while the screen
- * saver is inactive. Make sure the origin of
- * the picture is between min and max.
- */
- if (scp->xsize <= DAEMON_MAX_WIDTH) {
- /*
- * If the screen width is too narrow, we
- * allow part of the picture go off
- * the screen so that the daemon won't
- * flip too often.
- */
- min = scp->xsize - DAEMON_MAX_WIDTH - 10;
- max = 10;
- } else {
- min = 0;
- max = scp->xsize - DAEMON_MAX_WIDTH;
- }
- if (dxpos <= min) {
- dxpos = min;
- dxdir = 1;
- } else if (dxpos >= max) {
- dxpos = max;
- dxdir = -1;
- }
-
- if (scp->ysize <= DAEMON_MAX_HEIGHT) {
- min = scp->ysize - DAEMON_MAX_HEIGHT - 10;
- max = 10;
- } else {
- min = 0;
- max = scp->ysize - DAEMON_MAX_HEIGHT;
- }
- if (dypos <= min) {
- dypos = min;
- dydir = 1;
- } else if (dypos >= max) {
- dypos = max;
- dydir = -1;
- }
-
- moved_daemon = -1;
- dxpos += dxdir; dypos += dydir;
-
- /* clip the picture */
- xoff = 0;
- xlen = DAEMON_MAX_WIDTH;
- if (dxpos + xlen <= 0)
- xlen = 0;
- else if (dxpos < 0)
- xoff = -dxpos;
- if (dxpos >= scp->xsize)
- xlen = 0;
- else if (dxpos + xlen > scp->xsize)
- xlen = scp->xsize - dxpos;
- yoff = 0;
- ylen = DAEMON_MAX_HEIGHT;
- if (dypos + ylen <= 0)
- ylen = 0;
- else if (dypos < 0)
- yoff = -dypos;
- if (dypos >= scp->ysize)
- ylen = 0;
- else if (dypos + ylen > scp->ysize)
- ylen = scp->ysize - dypos;
- }
-
- if (scp->xsize <= messagelen) {
- min = scp->xsize - messagelen - 10;
- max = 10;
- } else {
- min = 0;
- max = scp->xsize - messagelen;
- }
- if (txpos <= min) {
- txpos = min;
- txdir = 1;
- } else if (txpos >= max) {
- txpos = max;
- txdir = -1;
- }
- if (typos <= 0) {
- typos = 0;
- tydir = 1;
- } else if (typos >= scp->ysize - 1) {
- typos = scp->ysize - 1;
- tydir = -1;
- }
- txpos += txdir; typos += tydir;
-
- toff = 0;
- tlen = messagelen;
- if (txpos + tlen <= 0)
- tlen = 0;
- else if (txpos < 0)
- toff = -txpos;
- if (txpos >= scp->xsize)
- tlen = 0;
- else if (txpos + tlen > scp->xsize)
- tlen = scp->xsize - txpos;
-
- draw_daemon(sc, dxpos, dypos, dxdir, xoff, yoff, xlen, ylen);
- draw_string(sc, txpos, typos, toff, (char *)message, tlen);
- } else {
-#ifdef PC98
- if (epson_machine_id == 0x20) {
- outb(0x43f, 0x42);
- outb(0x0c17, inb(0xc17) | 0x08);
- outb(0x43f, 0x40);
- }
-#endif /* PC98 */
- blanked = 0;
- }
- return 0;
-}
-
-static int
-daemon_init(video_adapter_t *adp)
-{
- messagelen = strlen(hostname) + 3 + strlen(ostype) + 1 +
- strlen(osrelease);
- message = malloc(messagelen + 1, M_DEVBUF, M_WAITOK);
- sprintf(message, "%s - %s %s", hostname, ostype, osrelease);
- blanked = 0;
- return 0;
-}
-
-static int
-daemon_term(video_adapter_t *adp)
-{
- free(message, M_DEVBUF);
- return 0;
-}
-
-static scrn_saver_t daemon_module = {
- "daemon_saver", daemon_init, daemon_term, daemon_saver, NULL,
-};
-
-SAVER_MODULE(daemon_saver, daemon_module);
diff --git a/sys/dev/syscons/fade/fade_saver.c b/sys/dev/syscons/fade/fade_saver.c
deleted file mode 100644
index 052fa9225908..000000000000
--- a/sys/dev/syscons/fade/fade_saver.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/*-
- * Copyright (c) 1995-1998 Søren Schmidt
- * 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,
- * without modification, immediately at the beginning of the file.
- * 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/consio.h>
-#include <sys/fbio.h>
-
-#include <dev/fb/fbreg.h>
-#include <dev/fb/splashreg.h>
-#include <dev/syscons/syscons.h>
-
-static u_char palette[256*3];
-static int blanked;
-
-static int
-fade_saver(video_adapter_t *adp, int blank)
-{
- static int count = 0;
- u_char pal[256*3];
- int i;
-
- if (blank) {
- blanked = TRUE;
- if (ISPALAVAIL(adp->va_flags)) {
- if (count <= 0)
- save_palette(adp, palette);
- if (count < 256) {
- pal[0] = pal[1] = pal[2] = 0;
- for (i = 3; i < 256*3; i++) {
- if (palette[i] - count > 60)
- pal[i] = palette[i] - count;
- else
- pal[i] = 60;
- }
- load_palette(adp, pal);
- count++;
- }
- } else {
- (*vidsw[adp->va_index]->blank_display)(adp,
- V_DISPLAY_BLANK);
- }
- } else {
- if (ISPALAVAIL(adp->va_flags)) {
- load_palette(adp, palette);
- count = 0;
- } else {
- (*vidsw[adp->va_index]->blank_display)(adp,
- V_DISPLAY_ON);
- }
- blanked = FALSE;
- }
- return 0;
-}
-
-static int
-fade_init(video_adapter_t *adp)
-{
- if (!ISPALAVAIL(adp->va_flags)
- && (*vidsw[adp->va_index]->blank_display)(adp, V_DISPLAY_ON) != 0)
- return ENODEV;
- blanked = FALSE;
- return 0;
-}
-
-static int
-fade_term(video_adapter_t *adp)
-{
- return 0;
-}
-
-static scrn_saver_t fade_module = {
- "fade_saver", fade_init, fade_term, fade_saver, NULL,
-};
-
-SAVER_MODULE(fade_saver, fade_module);
diff --git a/sys/dev/syscons/fire/fire_saver.c b/sys/dev/syscons/fire/fire_saver.c
deleted file mode 100644
index 59c707916160..000000000000
--- a/sys/dev/syscons/fire/fire_saver.c
+++ /dev/null
@@ -1,136 +0,0 @@
-/*-
- * Copyright (c) 1999 Brad Forschinger
- * 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,
- * without modification, immediately at the beginning of the file.
- * 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.
- *
- * $FreeBSD$
- */
-
-/*
- * brad forschinger, 19990504 <retch@flag.blackened.net>
- *
- * written with much help from warp_saver.c
- *
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/syslog.h>
-#include <sys/consio.h>
-#include <sys/fbio.h>
-
-#include <machine/random.h>
-
-#include <dev/fb/fbreg.h>
-#include <dev/fb/splashreg.h>
-#include <dev/syscons/syscons.h>
-
-#define X_SIZE 320
-#define Y_SIZE 200
-
-static int blanked;
-static u_char fire_pal[768];
-static u_char buf[X_SIZE * (Y_SIZE + 1)];
-static u_char *vid;
-
-static int
-fire_saver(video_adapter_t *adp, int blank)
-{
- int x, y;
-
- if (blank) {
- if (blanked <= 0) {
- int red, green, blue;
- int palette_index;
-
- set_video_mode(adp, M_VGA_CG320);
-
- /* build and load palette */
- red = green = blue = 0;
- for (palette_index = 0; palette_index < 256; palette_index++) {
- red++;
- if (red > 128)
- green += 2;
-
- fire_pal[(palette_index * 3) + 0] = red;
- fire_pal[(palette_index * 3) + 1] = green;
- fire_pal[(palette_index * 3) + 2] = blue;
- }
- load_palette(adp, fire_pal);
-
- blanked++;
- vid = (u_char *) adp->va_window;
- }
- /* make a new bottom line */
- for (x = 0, y = Y_SIZE; x < X_SIZE; x++)
- buf[x + (y * X_SIZE)] = random() % 160 + 96;
-
- /* fade the flames out */
- for (y = 0; y < Y_SIZE; y++) {
- for (x = 0; x < X_SIZE; x++) {
- buf[x + (y * X_SIZE)] = (buf[(x + 0) + ((y + 0) * X_SIZE)] +
- buf[(x - 1) + ((y + 1) * X_SIZE)] +
- buf[(x + 0) + ((y + 1) * X_SIZE)] +
- buf[(x + 1) + ((y + 1) * X_SIZE)]) / 4;
- if (buf[x + (y * X_SIZE)] > 0)
- buf[x + (y * X_SIZE)]--;
- }
- }
-
- /* blit our buffer into video ram */
- memcpy(vid, buf, X_SIZE * Y_SIZE);
- } else {
- blanked = 0;
- }
-
- return 0;
-}
-
-static int
-fire_initialise(video_adapter_t *adp)
-{
- video_info_t info;
-
- /* check that the console is capable of running in 320x200x256 */
- if (get_mode_info(adp, M_VGA_CG320, &info)) {
- log(LOG_NOTICE, "fire_saver: the console does not support M_VGA_CG320\n");
- return (ENODEV);
- }
- blanked = 0;
-
- return 0;
-}
-
-static int
-fire_terminate(video_adapter_t *adp)
-{
- return 0;
-}
-
-static scrn_saver_t fire_module = {
- "fire_saver", fire_initialise, fire_terminate, fire_saver, NULL
-};
-
-SAVER_MODULE(fire_saver, fire_module);
diff --git a/sys/dev/syscons/green/green_saver.c b/sys/dev/syscons/green/green_saver.c
deleted file mode 100644
index d6cfe80da689..000000000000
--- a/sys/dev/syscons/green/green_saver.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/*-
- * Copyright (c) 1995-1998 Søren Schmidt
- * 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,
- * without modification, immediately at the beginning of the file.
- * 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/consio.h>
-#include <sys/fbio.h>
-
-#include <dev/fb/fbreg.h>
-#include <dev/fb/splashreg.h>
-#include <dev/syscons/syscons.h>
-
-static int
-green_saver(video_adapter_t *adp, int blank)
-{
- (*vidsw[adp->va_index]->blank_display)(adp,
- (blank) ? V_DISPLAY_STAND_BY
- : V_DISPLAY_ON);
- return 0;
-}
-
-static int
-green_init(video_adapter_t *adp)
-{
- if ((*vidsw[adp->va_index]->blank_display)(adp, V_DISPLAY_ON) == 0)
- return 0;
- return ENODEV;
-}
-
-static int
-green_term(video_adapter_t *adp)
-{
- return 0;
-}
-
-static scrn_saver_t green_module = {
- "green_saver", green_init, green_term, green_saver, NULL,
-};
-
-SAVER_MODULE(green_saver, green_module);
diff --git a/sys/dev/syscons/logo/logo.c b/sys/dev/syscons/logo/logo.c
deleted file mode 100644
index be502fe502ff..000000000000
--- a/sys/dev/syscons/logo/logo.c
+++ /dev/null
@@ -1,352 +0,0 @@
-#define logo_w 88
-#define logo_h 88
-
-unsigned char logo_pal[768] = {
- 0x00, 0x00, 0x00,
- 0x33, 0x33, 0x33,
- 0x66, 0x66, 0x66,
- 0x99, 0x99, 0x99,
- 0xcc, 0xcc, 0xcc,
- 0xff, 0xff, 0xff,
- 0x90, 0x8f, 0x90,
- 0x56, 0x4b, 0x55,
- 0xa3, 0xa5, 0xab,
- 0xfd, 0xfd, 0xfd,
- 0x6d, 0x6e, 0x74,
- 0x41, 0x2b, 0x39,
- 0xcb, 0xc8, 0xcb,
- 0xcf, 0xbb, 0xba,
- 0x8e, 0x82, 0x87,
- 0x5c, 0x5d, 0x60,
- 0x52, 0x2a, 0x37,
- 0x7f, 0x76, 0x7d,
- 0x82, 0x82, 0x85,
- 0x7a, 0x3e, 0x45,
- 0x7f, 0x6e, 0x70,
- 0xef, 0xef, 0xed,
- 0x53, 0x41, 0x4b,
- 0x67, 0x2b, 0x35,
- 0x6a, 0x55, 0x62,
- 0xe7, 0xe2, 0xe3,
- 0x64, 0x35, 0x3f,
- 0xf7, 0xe0, 0xe7,
- 0xb1, 0xb2, 0xb2,
- 0x31, 0x2b, 0x35,
- 0x7a, 0x2d, 0x37,
- 0x69, 0x4c, 0x56,
- 0x95, 0x9d, 0xa4,
- 0x85, 0x61, 0x69,
- 0x40, 0x34, 0x41,
- 0x8f, 0x2e, 0x39,
- 0x7a, 0x50, 0x5a,
- 0xde, 0xe1, 0xe0,
- 0x32, 0x33, 0x3d,
- 0xa0, 0x9b, 0x9c,
- 0x68, 0x63, 0x67,
- 0x76, 0x60, 0x67,
- 0xba, 0xb6, 0xb8,
- 0x29, 0x24, 0x41,
- 0x38, 0x21, 0x29,
- 0x42, 0x21, 0x27,
- 0xa2, 0x2a, 0x32,
- 0x56, 0x55, 0x58,
- 0x55, 0x21, 0x2b,
- 0x7a, 0x20, 0x2a,
- 0x37, 0x16, 0x21,
- 0x4d, 0x18, 0x37,
- 0x8a, 0x3a, 0x3e,
- 0xc0, 0xc2, 0xc4,
- 0x64, 0x23, 0x2c,
- 0x37, 0x1a, 0x24,
- 0x42, 0x18, 0x20,
- 0x4c, 0x21, 0x2b,
- 0xa0, 0x23, 0x2e,
- 0x95, 0x6c, 0x76,
- 0x26, 0x16, 0x1c,
- 0xa5, 0x18, 0x23,
- 0x84, 0x20, 0x2b,
- 0x6d, 0x3f, 0x49,
- 0xae, 0xa7, 0xac,
- 0x2a, 0x1f, 0x24,
- 0x90, 0x21, 0x30,
- 0xa0, 0x39, 0x3e,
- 0x95, 0x0f, 0x1c,
- 0x84, 0x13, 0x1e,
- 0x4e, 0x17, 0x24,
- 0x8c, 0x56, 0x5f,
- 0xe0, 0xc4, 0xcb,
- 0xa5, 0x7f, 0x8e,
- 0xff, 0xff, 0xf1,
- 0x3d, 0x3d, 0x5d,
- 0x61, 0x19, 0x26,
- 0xd5, 0xd5, 0xd5,
- 0xff, 0xf1, 0xed,
- 0xb6, 0x9c, 0xa5,
- 0x87, 0x4c, 0x5a,
- 0xa0, 0x76, 0x76,
- 0xc8, 0xa0, 0xa0,
- 0xa2, 0xc1, 0xc8,
- 0x91, 0xae, 0xb6,
- 0x52, 0x8b, 0xae,
- 0xb3, 0xd2, 0xd4,
- 0x95, 0xb7, 0xc1,
- 0x54, 0x6e, 0x83,
- 0x67, 0x90, 0xa6,
- 0x44, 0x3e, 0x45,
- 0x23, 0x40, 0x6a,
- 0x41, 0x6e, 0x97,
- 0x7e, 0x8e, 0x91,
- 0x52, 0x33, 0x41,
- 0x39, 0x49, 0x68,
- 0x1d, 0x2a, 0x48,
- 0x17, 0x21, 0x45,
- 0x90, 0x17, 0x1f,
- 0x38, 0x54, 0x71,
- 0x1c, 0x33, 0x58,
- 0x1c, 0x1e, 0x23,
- 0x6c, 0x17, 0x21,
- 0xb0, 0xc5, 0xc1,
- 0x5d, 0x7f, 0x96,
- 0xe9, 0xbf, 0xc1,
- 0x96, 0x06, 0x0f,
- 0x78, 0x16, 0x1e,
- 0xab, 0x0e, 0x18,
- 0xa6, 0x06, 0x0e,
- 0x4c, 0x4c, 0x54,
- 0x61, 0x42, 0x4c,
- 0x48, 0x5f, 0x84,
- 0xa0, 0xb8, 0xbe,
- 0x5c, 0x66, 0x7f,
- 0x7b, 0x9e, 0xa9,
- 0x6f, 0x75, 0x7f,
- 0x45, 0x54, 0x74,
- 0x32, 0x3e, 0x63,
- 0xb1, 0xb4, 0xb3,
- 0x66, 0x9d, 0xb4,
- 0x7a, 0x9f, 0xbb,
- 0x82, 0xaa, 0xba,
- 0x13, 0x15, 0x17,
- 0x0b, 0x0b, 0x0a,
- 0x37, 0x66, 0x92,
- 0x4c, 0x7f, 0xa5,
- 0x24, 0x4c, 0x7b,
- 0x25, 0x5f, 0x91,
- 0x40, 0x7d, 0xa5,
- 0x1d, 0x56, 0x88,
- 0x2d, 0x6f, 0xa0,
- 0x70, 0x81, 0x8f,
- 0x58, 0x97, 0xbd,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00,
-};
-
-unsigned char logo_img[logo_w*logo_h] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x05, 0x05, 0x05, 0x05, 0x04, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x05, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x03, 0x04, 0x05, 0x05, 0x09, 0x0a, 0x0b, 0x07, 0x0c, 0x05, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x0d, 0x0e, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x03, 0x04, 0x05, 0x05, 0x05, 0x05, 0x09, 0x0f, 0x0b, 0x10, 0x11, 0x09, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x12, 0x13, 0x14, 0x05, 0x05, 0x04, 0x03, 0x02, 0x01, 0x02, 0x02, 0x02, 0x03, 0x03, 0x04, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x15, 0x16, 0x0b, 0x17, 0x18, 0x19, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x11, 0x13, 0x1a, 0x1b, 0x05, 0x05, 0x05, 0x04, 0x03, 0x02, 0x03, 0x03, 0x03, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x1c, 0x1d, 0x10, 0x1e, 0x1f, 0x19, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x20, 0x0b, 0x1e, 0x21, 0x05, 0x05, 0x05, 0x05, 0x05, 0x04, 0x03, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x19, 0x22, 0x0b, 0x17, 0x23, 0x24, 0x15, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x25, 0x26, 0x10, 0x23, 0x27, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x04, 0x05, 0x05, 0x05, 0x25, 0x27, 0x11, 0x28, 0x29, 0x11, 0x06, 0x0d, 0x09, 0x05, 0x2a, 0x2b, 0x2c, 0x2d, 0x1e, 0x2e, 0x21, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x2f, 0x0b, 0x30, 0x31, 0x0c, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x15, 0x06, 0x16, 0x22, 0x1d, 0x2c, 0x32, 0x33, 0x17, 0x17, 0x17, 0x22, 0x14, 0x16, 0x1d, 0x2c, 0x2d, 0x1e, 0x2e, 0x34, 0x0c, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x35, 0x2b, 0x2c, 0x36, 0x36, 0x35, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x27, 0x0b, 0x2c, 0x2c, 0x37, 0x32, 0x38, 0x2c, 0x2d, 0x39, 0x36, 0x17, 0x30, 0x2c, 0x2c, 0x2d, 0x2c, 0x2c, 0x1a, 0x3a, 0x3a, 0x3b, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x0a, 0x2d, 0x2b, 0x33, 0x31, 0x0e, 0x05, 0x05, 0x05, 0x05, 0x09, 0x28, 0x2c, 0x37, 0x3c, 0x32, 0x38, 0x38, 0x37, 0x2c, 0x30, 0x36, 0x36, 0x17, 0x31, 0x36, 0x23, 0x23, 0x17, 0x2c, 0x17, 0x3a, 0x3d, 0x13, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x22, 0x2c, 0x37, 0x33, 0x3e, 0x31, 0x3f, 0x40, 0x19, 0x05, 0x11, 0x2c, 0x2c, 0x32, 0x32, 0x32, 0x38, 0x37, 0x41, 0x30, 0x3a, 0x3a, 0x2e, 0x42, 0x43, 0x17, 0x1a, 0x13, 0x23, 0x31, 0x1a, 0x2e, 0x3d, 0x1a, 0x09, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x0b, 0x37, 0x32, 0x37, 0x33, 0x44, 0x44, 0x45, 0x17, 0x1a, 0x10, 0x2d, 0x37, 0x38, 0x46, 0x33, 0x46, 0x32, 0x2c, 0x23, 0x23, 0x47, 0x21, 0x13, 0x43, 0x34, 0x48, 0x19, 0x49, 0x34, 0x17, 0x1e, 0x3a, 0x13, 0x4a, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x4b, 0x32, 0x32, 0x32, 0x32, 0x4c, 0x45, 0x44, 0x44, 0x42, 0x36, 0x30, 0x33, 0x46, 0x38, 0x33, 0x46, 0x38, 0x31, 0x23, 0x27, 0x09, 0x4a, 0x4d, 0x47, 0x43, 0x0d, 0x4e, 0x4a, 0x4f, 0x34, 0x1a, 0x2e, 0x29, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x11, 0x33, 0x32, 0x32, 0x32, 0x33, 0x4c, 0x31, 0x45, 0x3e, 0x31, 0x36, 0x46, 0x46, 0x33, 0x33, 0x39, 0x30, 0x23, 0x50, 0x4a, 0x4a, 0x4a, 0x4a, 0x4d, 0x47, 0x51, 0x4e, 0x4a, 0x4a, 0x0e, 0x13, 0x1a, 0x27, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x35, 0x2b, 0x32, 0x32, 0x2b, 0x32, 0x33, 0x4c, 0x33, 0x4c, 0x4c, 0x36, 0x30, 0x30, 0x30, 0x30, 0x31, 0x23, 0x3a, 0x49, 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x4f, 0x50, 0x1b, 0x4e, 0x4a, 0x19, 0x50, 0x16, 0x0c, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x07, 0x32, 0x32, 0x32, 0x32, 0x2b, 0x33, 0x33, 0x30, 0x2d, 0x39, 0x30, 0x30, 0x30, 0x4c, 0x36, 0x42, 0x3a, 0x52, 0x05, 0x4a, 0x4a, 0x4a, 0x4a, 0x09, 0x3b, 0x52, 0x4e, 0x4a, 0x4a, 0x4f, 0x1a, 0x2a, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x4d, 0x2b, 0x2b, 0x32, 0x32, 0x32, 0x37, 0x2c, 0x2c, 0x2c, 0x2c, 0x2d, 0x10, 0x30, 0x30, 0x3e, 0x23, 0x3a, 0x0d, 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x40, 0x51, 0x4a, 0x4a, 0x25, 0x15, 0x1f, 0x27, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x40, 0x22, 0x2c, 0x32, 0x32, 0x32, 0x38, 0x2d, 0x2c, 0x41, 0x32, 0x39, 0x46, 0x4c, 0x31, 0x2e, 0x2e, 0x0c, 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x25, 0x53, 0x18, 0x4a, 0x54, 0x55, 0x56, 0x51, 0x11, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x2a, 0x22, 0x32, 0x32, 0x32, 0x38, 0x38, 0x32, 0x2c, 0x37, 0x38, 0x30, 0x30, 0x3e, 0x3a, 0x3a, 0x2a, 0x4a, 0x4a, 0x05, 0x4a, 0x57, 0x58, 0x59, 0x5a, 0x35, 0x58, 0x5b, 0x5c, 0x5d, 0x5e, 0x4a, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x4d, 0x07, 0x37, 0x32, 0x38, 0x38, 0x32, 0x32, 0x41, 0x38, 0x30, 0x30, 0x3e, 0x3a, 0x3d, 0x27, 0x05, 0x4a, 0x4a, 0x4a, 0x5c, 0x5f, 0x59, 0x1d, 0x29, 0x2f, 0x60, 0x61, 0x26, 0x0b, 0x1c, 0x05, 0x05, 0x04, 0x03, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x4e, 0x0a, 0x2d, 0x38, 0x38, 0x32, 0x37, 0x32, 0x2d, 0x39, 0x36, 0x31, 0x62, 0x3d, 0x0e, 0x4a, 0x4a, 0x4a, 0x09, 0x63, 0x64, 0x64, 0x61, 0x2d, 0x1d, 0x65, 0x61, 0x2b, 0x17, 0x16, 0x4a, 0x05, 0x05, 0x04, 0x03, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x05, 0x27, 0x2c, 0x38, 0x38, 0x37, 0x37, 0x38, 0x2d, 0x30, 0x31, 0x42, 0x3a, 0x18, 0x09, 0x05, 0x05, 0x4a, 0x63, 0x60, 0x60, 0x2b, 0x10, 0x2d, 0x41, 0x41, 0x30, 0x42, 0x3e, 0x29, 0x09, 0x05, 0x05, 0x04, 0x03, 0x03, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x2a, 0x37, 0x32, 0x38, 0x32, 0x41, 0x38, 0x38, 0x30, 0x66, 0x31, 0x3a, 0x1e, 0x67, 0x4a, 0x4a, 0x05, 0x68, 0x64, 0x61, 0x2b, 0x17, 0x36, 0x10, 0x33, 0x31, 0x42, 0x3d, 0x45, 0x06, 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x1c, 0x2c, 0x32, 0x32, 0x37, 0x41, 0x2c, 0x46, 0x30, 0x36, 0x36, 0x42, 0x42, 0x29, 0x1b, 0x4a, 0x4a, 0x4d, 0x26, 0x60, 0x0b, 0x17, 0x36, 0x44, 0x45, 0x66, 0x3e, 0x44, 0x44, 0x1a, 0x05, 0x05, 0x05, 0x05, 0x05, 0x15, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x0c, 0x2c, 0x32, 0x32, 0x38, 0x37, 0x32, 0x37, 0x30, 0x36, 0x4c, 0x31, 0x1e, 0x10, 0x1f, 0x52, 0x69, 0x52, 0x07, 0x2c, 0x10, 0x36, 0x62, 0x6a, 0x44, 0x6b, 0x3e, 0x44, 0x6c, 0x30, 0x09, 0x05, 0x05, 0x25, 0x54, 0x19, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x25, 0x2c, 0x37, 0x38, 0x37, 0x2c, 0x32, 0x32, 0x46, 0x30, 0x46, 0x4c, 0x31, 0x66, 0x4c, 0x36, 0x1a, 0x1a, 0x17, 0x37, 0x37, 0x10, 0x31, 0x62, 0x45, 0x4c, 0x3e, 0x44, 0x62, 0x30, 0x09, 0x05, 0x0a, 0x70, 0x71, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x22, 0x32, 0x32, 0x38, 0x41, 0x41, 0x38, 0x2d, 0x46, 0x66, 0x44, 0x6c, 0x6c, 0x6c, 0x3d, 0x3a, 0x42, 0x31, 0x32, 0x32, 0x32, 0x33, 0x33, 0x30, 0x36, 0x3e, 0x3e, 0x31, 0x07, 0x05, 0x12, 0x6e, 0x72, 0x09, 0x05, 0x05, 0x04, 0x03, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x2d, 0x2c, 0x38, 0x32, 0x41, 0x37, 0x2d, 0x46, 0x66, 0x6a, 0x6c, 0x6d, 0x6d, 0x6c, 0x3d, 0x3d, 0x31, 0x38, 0x38, 0x39, 0x33, 0x39, 0x36, 0x30, 0x30, 0x66, 0x30, 0x40, 0x4d, 0x5f, 0x4d, 0x4d, 0x05, 0x05, 0x05, 0x15, 0x04, 0x03, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x09, 0x5a, 0x2d, 0x32, 0x32, 0x37, 0x37, 0x32, 0x38, 0x46, 0x46, 0x66, 0x45, 0x44, 0x62, 0x44, 0x44, 0x3e, 0x31, 0x31, 0x31, 0x31, 0x31, 0x33, 0x37, 0x30, 0x10, 0x06, 0x05, 0x12, 0x0a, 0x05, 0x05, 0x05, 0x08, 0x68, 0x73, 0x05, 0x04, 0x03, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x35, 0x22, 0x32, 0x32, 0x32, 0x3c, 0x37, 0x37, 0x2d, 0x39, 0x39, 0x39, 0x36, 0x36, 0x6b, 0x3e, 0x3e, 0x3e, 0x3e, 0x31, 0x4c, 0x39, 0x2d, 0x10, 0x16, 0x2a, 0x05, 0x05, 0x74, 0x74, 0x05, 0x05, 0x0c, 0x75, 0x5f, 0x1c, 0x05, 0x05, 0x04, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x40, 0x2c, 0x32, 0x32, 0x32, 0x41, 0x37, 0x41, 0x2c, 0x2c, 0x41, 0x2c, 0x33, 0x36, 0x31, 0x36, 0x31, 0x31, 0x17, 0x46, 0x2c, 0x16, 0x40, 0x05, 0x05, 0x05, 0x05, 0x20, 0x5f, 0x4d, 0x72, 0x76, 0x06, 0x25, 0x4a, 0x05, 0x05, 0x05, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x40, 0x0b, 0x2d, 0x37, 0x2d, 0x2c, 0x2c, 0x37, 0x37, 0x38, 0x2c, 0x37, 0x2c, 0x10, 0x10, 0x39, 0x30, 0x0b, 0x2c, 0x11, 0x09, 0x05, 0x09, 0x4a, 0x05, 0x05, 0x19, 0x1d, 0x26, 0x76, 0x08, 0x05, 0x05, 0x05, 0x15, 0x25, 0x4d, 0x53, 0x77, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x4d, 0x5a, 0x2c, 0x37, 0x2d, 0x2c, 0x37, 0x37, 0x39, 0x39, 0x33, 0x38, 0x2c, 0x2d, 0x2d, 0x2c, 0x5e, 0x2a, 0x05, 0x15, 0x3b, 0x17, 0x1f, 0x19, 0x05, 0x06, 0x26, 0x60, 0x5f, 0x0c, 0x05, 0x05, 0x05, 0x35, 0x68, 0x78, 0x56, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x35, 0x2c, 0x2c, 0x2c, 0x37, 0x32, 0x37, 0x2c, 0x37, 0x32, 0x46, 0x33, 0x46, 0x39, 0x11, 0x15, 0x05, 0x05, 0x18, 0x31, 0x44, 0x6a, 0x30, 0x6e, 0x2b, 0x4b, 0x11, 0x5f, 0x63, 0x72, 0x54, 0x20, 0x74, 0x58, 0x25, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x15, 0x0b, 0x2c, 0x38, 0x2d, 0x39, 0x39, 0x2d, 0x37, 0x3c, 0x32, 0x37, 0x0b, 0x18, 0x05, 0x05, 0x05, 0x4e, 0x26, 0x32, 0x45, 0x6a, 0x46, 0x2b, 0x72, 0x4e, 0x05, 0x35, 0x0a, 0x75, 0x5f, 0x70, 0x08, 0x09, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x35, 0x22, 0x2d, 0x30, 0x6b, 0x6b, 0x66, 0x36, 0x30, 0x36, 0x4c, 0x36, 0x30, 0x18, 0x05, 0x05, 0x05, 0x09, 0x4b, 0x32, 0x46, 0x66, 0x38, 0x0b, 0x09, 0x05, 0x05, 0x05, 0x05, 0x09, 0x05, 0x05, 0x05, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x0a, 0x2c, 0x2c, 0x31, 0x62, 0x62, 0x6b, 0x31, 0x45, 0x44, 0x44, 0x45, 0x31, 0x10, 0x0c, 0x4d, 0x0c, 0x08, 0x0b, 0x3c, 0x32, 0x33, 0x66, 0x17, 0x06, 0x05, 0x05, 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x09, 0x22, 0x2c, 0x2d, 0x31, 0x45, 0x6b, 0x36, 0x31, 0x6b, 0x62, 0x45, 0x6a, 0x66, 0x30, 0x0b, 0x2c, 0x2c, 0x2c, 0x2c, 0x37, 0x46, 0x6b, 0x44, 0x62, 0x5e, 0x05, 0x05, 0x05, 0x05, 0x04, 0x03, 0x03, 0x03, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x0c, 0x1d, 0x2c, 0x39, 0x36, 0x4c, 0x30, 0x30, 0x30, 0x36, 0x4c, 0x66, 0x4c, 0x36, 0x30, 0x37, 0x41, 0x2c, 0x2d, 0x2c, 0x3c, 0x33, 0x6b, 0x44, 0x44, 0x39, 0x09, 0x05, 0x05, 0x04, 0x03, 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x2d, 0x2d, 0x2d, 0x36, 0x39, 0x2d, 0x32, 0x38, 0x38, 0x46, 0x6a, 0x6d, 0x3d, 0x62, 0x46, 0x3c, 0x37, 0x2d, 0x32, 0x32, 0x32, 0x38, 0x4c, 0x30, 0x16, 0x05, 0x05, 0x04, 0x03, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x0a, 0x37, 0x38, 0x38, 0x39, 0x37, 0x2c, 0x37, 0x37, 0x30, 0x45, 0x6d, 0x6d, 0x62, 0x62, 0x38, 0x3c, 0x3c, 0x32, 0x37, 0x32, 0x32, 0x32, 0x2c, 0x14, 0x15, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x6e, 0x37, 0x38, 0x38, 0x38, 0x37, 0x2c, 0x2d, 0x30, 0x31, 0x62, 0x6a, 0x6d, 0x6a, 0x6a, 0x46, 0x32, 0x32, 0x37, 0x37, 0x32, 0x30, 0x17, 0x29, 0x05, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x4a, 0x0b, 0x38, 0x38, 0x38, 0x2c, 0x2c, 0x0b, 0x2d, 0x39, 0x4c, 0x45, 0x6a, 0x6a, 0x6a, 0x6a, 0x6a, 0x38, 0x37, 0x2c, 0x41, 0x18, 0x1c, 0x0c, 0x05, 0x04, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x15, 0x0b, 0x2d, 0x38, 0x38, 0x37, 0x2c, 0x2c, 0x2c, 0x37, 0x32, 0x4c, 0x6b, 0x44, 0x44, 0x45, 0x6a, 0x45, 0x38, 0x37, 0x1c, 0x09, 0x05, 0x05, 0x04, 0x03, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x09, 0x1d, 0x38, 0x38, 0x38, 0x38, 0x2c, 0x3c, 0x37, 0x37, 0x32, 0x32, 0x46, 0x36, 0x1e, 0x6b, 0x4c, 0x46, 0x32, 0x22, 0x09, 0x05, 0x05, 0x04, 0x03, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x07, 0x37, 0x32, 0x37, 0x38, 0x38, 0x37, 0x32, 0x3c, 0x32, 0x32, 0x37, 0x38, 0x2d, 0x2d, 0x38, 0x2c, 0x2c, 0x4f, 0x05, 0x05, 0x04, 0x03, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x08, 0x3c, 0x37, 0x41, 0x38, 0x2d, 0x37, 0x37, 0x3c, 0x32, 0x3c, 0x32, 0x37, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x0c, 0x41, 0x3c, 0x3c, 0x38, 0x32, 0x3c, 0x3c, 0x3c, 0x41, 0x32, 0x41, 0x37, 0x2c, 0x2c, 0x41, 0x38, 0x45, 0x18, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x2a, 0x2c, 0x3c, 0x37, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x37, 0x2c, 0x2c, 0x2c, 0x2c, 0x4c, 0x45, 0x6a, 0x1a, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x11, 0x2c, 0x37, 0x41, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x41, 0x37, 0x37, 0x4c, 0x44, 0x6d, 0x6a, 0x1a, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x5a, 0x2c, 0x41, 0x3c, 0x3c, 0x3c, 0x32, 0x2c, 0x32, 0x2c, 0x2c, 0x38, 0x38, 0x36, 0x45, 0x62, 0x44, 0x45, 0x29, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x2a, 0x2c, 0x3c, 0x3c, 0x3c, 0x3c, 0x3c, 0x37, 0x37, 0x32, 0x37, 0x39, 0x4c, 0x4c, 0x45, 0x62, 0x44, 0x62, 0x30, 0x2a, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x4a, 0x5a, 0x41, 0x3c, 0x3c, 0x3c, 0x3c, 0x32, 0x3c, 0x37, 0x37, 0x2d, 0x46, 0x4c, 0x6b, 0x6b, 0x45, 0x3e, 0x36, 0x29, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x03, 0x04, 0x05, 0x05, 0x27, 0x3c, 0x37, 0x3c, 0x3c, 0x37, 0x37, 0x32, 0x38, 0x37, 0x37, 0x37, 0x38, 0x39, 0x36, 0x4c, 0x30, 0x10, 0x16, 0x09, 0x05, 0x05, 0x04, 0x03, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x03, 0x04, 0x05, 0x05, 0x25, 0x1d, 0x37, 0x37, 0x41, 0x32, 0x3c, 0x32, 0x41, 0x37, 0x32, 0x2c, 0x41, 0x37, 0x2c, 0x32, 0x37, 0x2c, 0x2c, 0x5a, 0x0c, 0x05, 0x05, 0x05, 0x04, 0x03, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x04, 0x05, 0x05, 0x15, 0x5a, 0x37, 0x2c, 0x41, 0x2c, 0x2c, 0x41, 0x37, 0x41, 0x41, 0x3c, 0x2c, 0x41, 0x41, 0x3c, 0x37, 0x2c, 0x39, 0x0b, 0x0b, 0x25, 0x05, 0x05, 0x05, 0x05, 0x04, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x05, 0x05, 0x2a, 0x22, 0x2d, 0x37, 0x2c, 0x3c, 0x1d, 0x2c, 0x38, 0x2c, 0x41, 0x2c, 0x2c, 0x2d, 0x39, 0x37, 0x3c, 0x37, 0x30, 0x1a, 0x5e, 0x6e, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x2a, 0x6e, 0x0b, 0x2d, 0x38, 0x41, 0x41, 0x6e, 0x5a, 0x2c, 0x41, 0x32, 0x38, 0x32, 0x39, 0x3f, 0x6f, 0x16, 0x37, 0x1a, 0x1f, 0x1f, 0x16, 0x1d, 0x0c, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x09, 0x40, 0x07, 0x2c, 0x37, 0x2c, 0x2d, 0x2c, 0x1d, 0x0e, 0x09, 0x0b, 0x4b, 0x07, 0x41, 0x38, 0x2d, 0x10, 0x2d, 0x10, 0x0b, 0x2b, 0x33, 0x3f, 0x21, 0x29, 0x07, 0x5e, 0x2f, 0x12, 0x08, 0x2a, 0x0c, 0x25, 0x09, 0x09, 0x09, 0x05, 0x05, 0x05, 0x05, 0x04, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x05, 0x19, 0x40, 0x28, 0x22, 0x2c, 0x38, 0x32, 0x32, 0x32, 0x1d, 0x0e, 0x19, 0x05, 0x35, 0x2c, 0x4b, 0x70, 0x0b, 0x32, 0x2c, 0x16, 0x16, 0x16, 0x0b, 0x22, 0x26, 0x0b, 0x10, 0x3f, 0x29, 0x1f, 0x47, 0x1f, 0x1f, 0x5e, 0x0b, 0x4b, 0x74, 0x84, 0x74, 0x84, 0x06, 0x35, 0x09, 0x05, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x03, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x09, 0x4d, 0x27, 0x0a, 0x22, 0x1d, 0x2c, 0x2c, 0x37, 0x32, 0x41, 0x41, 0x16, 0x27, 0x15, 0x09, 0x4a, 0x09, 0x28, 0x2d, 0x0b, 0x76, 0x2c, 0x37, 0x2d, 0x37, 0x32, 0x37, 0x0b, 0x0b, 0x5e, 0x5a, 0x4b, 0x0b, 0x0b, 0x07, 0x6e, 0x16, 0x5e, 0x10, 0x76, 0x5c, 0x68, 0x79, 0x7a, 0x53, 0x71, 0x54, 0x5d, 0x08, 0x4d, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x03, 0x04, 0x05, 0x05, 0x05, 0x25, 0x27, 0x28, 0x0b, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x41, 0x41, 0x41, 0x22, 0x11, 0x35, 0x4d, 0x4d, 0x35, 0x1c, 0x06, 0x0a, 0x22, 0x38, 0x38, 0x37, 0x38, 0x38, 0x38, 0x2d, 0x39, 0x39, 0x39, 0x10, 0x39, 0x10, 0x4b, 0x12, 0x08, 0x35, 0x67, 0x2a, 0x08, 0x74, 0x70, 0x81, 0x55, 0x78, 0x79, 0x57, 0x53, 0x71, 0x71, 0x73, 0x84, 0x25, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x04, 0x05, 0x09, 0x27, 0x16, 0x0b, 0x2c, 0x2d, 0x2c, 0x41, 0x41, 0x1d, 0x22, 0x5a, 0x0f, 0x14, 0x0a, 0x28, 0x0a, 0x28, 0x28, 0x28, 0x6e, 0x5a, 0x65, 0x1d, 0x0b, 0x2d, 0x38, 0x46, 0x38, 0x38, 0x38, 0x39, 0x2d, 0x46, 0x39, 0x30, 0x39, 0x4b, 0x68, 0x79, 0x7a, 0x57, 0x67, 0x67, 0x56, 0x53, 0x71, 0x68, 0x7e, 0x85, 0x59, 0x73, 0x79, 0x54, 0x7a, 0x54, 0x06, 0x1c, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x05, 0x4d, 0x16, 0x0b, 0x10, 0x39, 0x2d, 0x0b, 0x28, 0x06, 0x2a, 0x25, 0x35, 0x06, 0x11, 0x0a, 0x28, 0x07, 0x5a, 0x22, 0x26, 0x5a, 0x41, 0x7b, 0x7c, 0x60, 0x76, 0x22, 0x1d, 0x32, 0x38, 0x46, 0x46, 0x46, 0x38, 0x38, 0x38, 0x38, 0x2b, 0x75, 0x7d, 0x7e, 0x55, 0x78, 0x7a, 0x57, 0x57, 0x57, 0x71, 0x20, 0x68, 0x55, 0x85, 0x7a, 0x57, 0x53, 0x71, 0x57, 0x5d, 0x19, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x0c, 0x16, 0x0b, 0x30, 0x39, 0x18, 0x2a, 0x09, 0x05, 0x4e, 0x19, 0x25, 0x0c, 0x27, 0x11, 0x0a, 0x0a, 0x2f, 0x5a, 0x5a, 0x26, 0x5a, 0x7b, 0x7c, 0x7c, 0x61, 0x7f, 0x7f, 0x7f, 0x76, 0x22, 0x22, 0x0b, 0x2d, 0x0b, 0x2d, 0x2d, 0x33, 0x0b, 0x5f, 0x80, 0x7d, 0x5c, 0x81, 0x55, 0x59, 0x59, 0x73, 0x73, 0x54, 0x5c, 0x5c, 0x7e, 0x55, 0x59, 0x73, 0x7a, 0x71, 0x19, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x05, 0x05, 0x05, 0x09, 0x25, 0x08, 0x07, 0x5e, 0x10, 0x22, 0x1c, 0x4a, 0x05, 0x09, 0x05, 0x15, 0x4d, 0x19, 0x19, 0x4d, 0x08, 0x12, 0x74, 0x0f, 0x6e, 0x5a, 0x26, 0x1d, 0x7b, 0x7b, 0x7c, 0x7c, 0x7c, 0x61, 0x5b, 0x82, 0x82, 0x80, 0x80, 0x82, 0x7f, 0x7f, 0x7f, 0x7f, 0x5b, 0x7f, 0x82, 0x80, 0x7d, 0x5c, 0x7e, 0x79, 0x54, 0x54, 0x7a, 0x73, 0x0f, 0x2a, 0x25, 0x19, 0x09, 0x4a, 0x05, 0x05, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x09, 0x4d, 0x2a, 0x06, 0x74, 0x28, 0x22, 0x22, 0x2d, 0x2c, 0x0e, 0x05, 0x05, 0x05, 0x05, 0x05, 0x3b, 0x07, 0x19, 0x09, 0x25, 0x0c, 0x27, 0x12, 0x0f, 0x2f, 0x26, 0x26, 0x1d, 0x65, 0x65, 0x7c, 0x7c, 0x7b, 0x7c, 0x7b, 0x7b, 0x60, 0x5b, 0x7f, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x80, 0x80, 0x83, 0x83, 0x81, 0x7e, 0x59, 0x73, 0x73, 0x84, 0x5d, 0x25, 0x05, 0x05, 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x19, 0x08, 0x12, 0x0a, 0x0f, 0x6e, 0x5a, 0x26, 0x22, 0x2c, 0x2c, 0x0b, 0x27, 0x05, 0x05, 0x05, 0x15, 0x1e, 0x1e, 0x6f, 0x0c, 0x09, 0x15, 0x0c, 0x20, 0x12, 0x0f, 0x6e, 0x5a, 0x26, 0x26, 0x26, 0x65, 0x65, 0x65, 0x65, 0x7b, 0x7c, 0x7b, 0x65, 0x7b, 0x61, 0x61, 0x60, 0x64, 0x64, 0x64, 0x5b, 0x5b, 0x5f, 0x63, 0x70, 0x63, 0x58, 0x5d, 0x2a, 0x15, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x4a, 0x4d, 0x27, 0x11, 0x0a, 0x28, 0x6e, 0x5a, 0x26, 0x65, 0x41, 0x1d, 0x2c, 0x2c, 0x5e, 0x29, 0x0e, 0x14, 0x17, 0x31, 0x6b, 0x30, 0x14, 0x25, 0x09, 0x15, 0x4d, 0x08, 0x74, 0x0a, 0x0f, 0x2f, 0x5a, 0x26, 0x26, 0x1d, 0x1d, 0x1d, 0x2b, 0x65, 0x1d, 0x41, 0x65, 0x65, 0x7b, 0x65, 0x65, 0x1d, 0x6e, 0x74, 0x5d, 0x1c, 0x25, 0x15, 0x05, 0x05, 0x05, 0x05, 0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x09, 0x19, 0x4d, 0x08, 0x06, 0x0a, 0x2f, 0x6e, 0x2f, 0x6e, 0x26, 0x41, 0x7b, 0x65, 0x41, 0x37, 0x33, 0x30, 0x36, 0x36, 0x4c, 0x6b, 0x66, 0x30, 0x14, 0x35, 0x4a, 0x09, 0x15, 0x15, 0x25, 0x25, 0x0c, 0x1c, 0x08, 0x06, 0x5d, 0x5d, 0x5d, 0x0e, 0x06, 0x12, 0x06, 0x08, 0x1c, 0x2a, 0x0c, 0x19, 0x09, 0x05, 0x05, 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x09, 0x09, 0x19, 0x35, 0x08, 0x12, 0x28, 0x2f, 0x2f, 0x6e, 0x5a, 0x41, 0x7c, 0x3c, 0x3c, 0x2c, 0x41, 0x2d, 0x2d, 0x39, 0x30, 0x4c, 0x4c, 0x66, 0x66, 0x31, 0x24, 0x20, 0x4a, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x4a, 0x09, 0x4a, 0x09, 0x09, 0x05, 0x09, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x09, 0x15, 0x0c, 0x1c, 0x12, 0x28, 0x2f, 0x5a, 0x1d, 0x7c, 0x7b, 0x41, 0x7b, 0x3c, 0x7b, 0x3c, 0x41, 0x41, 0x5a, 0x16, 0x28, 0x14, 0x14, 0x14, 0x3b, 0x12, 0x05, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x05, 0x4a, 0x09, 0x15, 0x1c, 0x12, 0x12, 0x0a, 0x0f, 0x2f, 0x07, 0x2f, 0x0a, 0x12, 0x27, 0x0c, 0x4d, 0x15, 0x09, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x09, 0x15, 0x15, 0x15, 0x19, 0x4e, 0x4e, 0x05, 0x4a, 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-};
diff --git a/sys/dev/syscons/logo/logo_saver.c b/sys/dev/syscons/logo/logo_saver.c
deleted file mode 100644
index 2d2c660847ac..000000000000
--- a/sys/dev/syscons/logo/logo_saver.c
+++ /dev/null
@@ -1,157 +0,0 @@
-/*-
- * Copyright (c) 1998 Dag-Erling Coïdan Smørgrav
- * 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
- * in this position and unchanged.
- * 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/syslog.h>
-#include <sys/consio.h>
-#include <sys/fbio.h>
-
-#include <dev/fb/fbreg.h>
-#include <dev/fb/splashreg.h>
-#include <dev/syscons/syscons.h>
-
-static u_char *vid;
-static int banksize, scrmode, bpsl, scrw, scrh;
-static int blanked;
-
-#include "logo.c"
-
-static void
-logo_blit(video_adapter_t *adp, int x, int y)
-{
- int d, l, o, p;
-
- for (o = 0, p = y * bpsl + x; p > banksize; p -= banksize)
- o += banksize;
- set_origin(adp, o);
-
- for (d = 0; d < sizeof logo_img; d += logo_w) {
- if (p + logo_w < banksize) {
- bcopy(logo_img + d, vid + p, logo_w);
- p += bpsl;
- } else if (p < banksize) {
- l = banksize - p;
- bcopy(logo_img + d, vid + p, l);
- set_origin(adp, (o += banksize));
- bcopy(logo_img + d + l, vid, logo_w - l);
- p += bpsl - banksize;
- } else {
- p -= banksize;
- set_origin(adp, (o += banksize));
- bcopy(logo_img + d, vid + p, logo_w);
- p += bpsl;
- }
- }
-}
-
-static void
-logo_update(video_adapter_t *adp)
-{
- static int xpos = 0, ypos = 0;
- static int xinc = 1, yinc = 1;
-
- /* Turn when you hit the edge */
- if ((xpos + logo_w + xinc > scrw) || (xpos + xinc < 0))
- xinc = -xinc;
- if ((ypos + logo_h + yinc > scrh) || (ypos + yinc < 0))
- yinc = -yinc;
- xpos += xinc;
- ypos += yinc;
-
- /* XXX Relies on margin around logo to erase trail */
- logo_blit(adp, xpos, ypos);
-}
-
-static int
-logo_saver(video_adapter_t *adp, int blank)
-{
- int i, pl;
-
- if (blank) {
- /* switch to graphics mode */
- if (blanked <= 0) {
- pl = splhigh();
- set_video_mode(adp, scrmode);
- load_palette(adp, logo_pal);
-#if 0 /* XXX conflict */
- set_border(adp, 0);
-#endif
- blanked++;
- vid = (u_char *)adp->va_window;
- banksize = adp->va_window_size;
- bpsl = adp->va_line_width;
- splx(pl);
- for (i = 0; i < bpsl*scrh; i += banksize) {
- set_origin(adp, i);
- bzero(vid, banksize);
- }
- }
- logo_update(adp);
- } else {
- blanked = 0;
- }
- return 0;
-}
-
-static int
-logo_init(video_adapter_t *adp)
-{
- video_info_t info;
-
- if (!get_mode_info(adp, M_VESA_CG800x600, &info)) {
- scrmode = M_VESA_CG800x600;
- } else if (!get_mode_info(adp, M_VGA_CG320, &info)) {
- scrmode = M_VGA_CG320;
- } else {
- log(LOG_NOTICE, "logo_saver: no suitable graphics mode\n");
- return ENODEV;
- }
-
- scrw = info.vi_width;
- scrh = info.vi_height;
- blanked = 0;
-
- return 0;
-}
-
-static int
-logo_term(video_adapter_t *adp)
-{
- return 0;
-}
-
-static scrn_saver_t logo_module = {
- "logo_saver", logo_init, logo_term, logo_saver, NULL,
-};
-
-SAVER_MODULE(logo_saver, logo_module);
diff --git a/sys/dev/syscons/rain/rain_saver.c b/sys/dev/syscons/rain/rain_saver.c
deleted file mode 100644
index 6d2ed39e4654..000000000000
--- a/sys/dev/syscons/rain/rain_saver.c
+++ /dev/null
@@ -1,131 +0,0 @@
-/*-
- * Copyright (c) 1998 Dag-Erling Coïdan Smørgrav
- * 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
- * in this position and unchanged.
- * 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/syslog.h>
-#include <sys/consio.h>
-#include <sys/fbio.h>
-
-#include <machine/random.h>
-
-#include <dev/fb/fbreg.h>
-#include <dev/fb/splashreg.h>
-#include <dev/syscons/syscons.h>
-
-static u_char *vid;
-
-#define SCRW 320
-#define SCRH 200
-#define MAX 63
-
-static u_char rain_pal[768];
-static int blanked;
-
-static void
-rain_update(video_adapter_t *adp)
-{
- int i, t;
-
- t = rain_pal[(MAX*3+2)];
- for (i = (MAX*3+2); i > 5; i -= 3)
- rain_pal[i] = rain_pal[i-3];
- rain_pal[5] = t;
- load_palette(adp, rain_pal);
-}
-
-static int
-rain_saver(video_adapter_t *adp, int blank)
-{
- int i, j, k, pl;
-
- if (blank) {
- /* switch to graphics mode */
- if (blanked <= 0) {
- pl = splhigh();
- set_video_mode(adp, M_VGA_CG320);
- load_palette(adp, rain_pal);
-#if 0 /* XXX conflict */
- set_border(adp, 0);
-#endif
- blanked++;
- vid = (u_char *)adp->va_window;
- splx(pl);
- bzero(vid, SCRW*SCRH);
- for (i = 0; i < SCRW; i += 2)
- vid[i] = 1 + (random() % MAX);
- for (j = 1, k = SCRW; j < SCRH; j++)
- for (i = 0; i < SCRW; i += 2, k += 2)
- vid[k] = (vid[k-SCRW] < MAX) ? 1 + vid[k-SCRW] : 1;
- }
-
- /* update display */
- rain_update(adp);
-
- } else {
- blanked = 0;
- }
- return 0;
-}
-
-static int
-rain_init(video_adapter_t *adp)
-{
- video_info_t info;
- int i;
-
- /* check that the console is capable of running in 320x200x256 */
- if (get_mode_info(adp, M_VGA_CG320, &info)) {
- log(LOG_NOTICE, "rain_saver: the console does not support M_VGA_CG320\n");
- return ENODEV;
- }
-
- /* intialize the palette */
- for (i = 3; i < (MAX+1)*3; i += 3)
- rain_pal[i+2] = rain_pal[i-1] + 4;
-
- blanked = 0;
-
- return 0;
-}
-
-static int
-rain_term(video_adapter_t *adp)
-{
- return 0;
-}
-
-static scrn_saver_t rain_module = {
- "rain_saver", rain_init, rain_term, rain_saver, NULL,
-};
-
-SAVER_MODULE(rain_saver, rain_module);
diff --git a/sys/dev/syscons/scgfbrndr.c b/sys/dev/syscons/scgfbrndr.c
deleted file mode 100644
index 402a0946c54d..000000000000
--- a/sys/dev/syscons/scgfbrndr.c
+++ /dev/null
@@ -1,824 +0,0 @@
-/*-
- * Copyright (c) 1999 Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
- * 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 as
- * the first lines of this file unmodified.
- * 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 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.
- *
- * $FreeBSD$
- */
-
-#include "opt_syscons.h"
-#include "opt_vga.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-
-#include <machine/console.h>
-
-#include <dev/fb/fbreg.h>
-#include <dev/fb/vgareg.h>
-#include <dev/syscons/syscons.h>
-
-#include <isa/isareg.h>
-
-#ifndef SC_RENDER_DEBUG
-#define SC_RENDER_DEBUG 0
-#endif
-
-static vr_clear_t vga_txtclear;
-static vr_draw_border_t vga_txtborder;
-static vr_draw_t vga_txtdraw;
-static vr_set_cursor_t vga_txtcursor_shape;
-static vr_draw_cursor_t vga_txtcursor;
-static vr_blink_cursor_t vga_txtblink;
-#ifndef SC_NO_CUTPASTE
-static vr_draw_mouse_t vga_txtmouse;
-#else
-#define vga_txtmouse (vr_draw_mouse_t *)vga_nop
-#endif
-
-#ifdef SC_PIXEL_MODE
-static vr_clear_t vga_pxlclear;
-static vr_draw_border_t vga_pxlborder;
-static vr_draw_t vga_egadraw;
-static vr_draw_t vga_vgadraw;
-static vr_set_cursor_t vga_pxlcursor_shape;
-static vr_draw_cursor_t vga_pxlcursor;
-static vr_blink_cursor_t vga_pxlblink;
-#ifndef SC_NO_CUTPASTE
-static vr_draw_mouse_t vga_pxlmouse;
-#else
-#define vga_pxlmouse (vr_draw_mouse_t *)vga_nop
-#endif
-#endif /* SC_PIXEL_MODE */
-
-#ifndef SC_NO_MODE_CHANGE
-static vr_draw_border_t vga_grborder;
-#endif
-
-static void vga_nop(scr_stat *scp, ...);
-
-static struct linker_set vga_set;
-
-static sc_rndr_sw_t txtrndrsw = {
- vga_txtclear,
- vga_txtborder,
- vga_txtdraw,
- vga_txtcursor_shape,
- vga_txtcursor,
- vga_txtblink,
- (vr_set_mouse_t *)vga_nop,
- vga_txtmouse,
-};
-RENDERER(mda, 0, txtrndrsw, vga_set);
-RENDERER(cga, 0, txtrndrsw, vga_set);
-RENDERER(ega, 0, txtrndrsw, vga_set);
-RENDERER(vga, 0, txtrndrsw, vga_set);
-
-#ifdef SC_PIXEL_MODE
-static sc_rndr_sw_t egarndrsw = {
- vga_pxlclear,
- vga_pxlborder,
- vga_egadraw,
- vga_pxlcursor_shape,
- vga_pxlcursor,
- vga_pxlblink,
- (vr_set_mouse_t *)vga_nop,
- vga_pxlmouse,
-};
-RENDERER(ega, PIXEL_MODE, egarndrsw, vga_set);
-
-static sc_rndr_sw_t vgarndrsw = {
- vga_pxlclear,
- vga_pxlborder,
- vga_vgadraw,
- vga_pxlcursor_shape,
- vga_pxlcursor,
- vga_pxlblink,
- (vr_set_mouse_t *)vga_nop,
- vga_pxlmouse,
-};
-RENDERER(vga, PIXEL_MODE, vgarndrsw, vga_set);
-#endif /* SC_PIXEL_MODE */
-
-#ifndef SC_NO_MODE_CHANGE
-static sc_rndr_sw_t grrndrsw = {
- (vr_clear_t *)vga_nop,
- vga_grborder,
- (vr_draw_t *)vga_nop,
- (vr_set_cursor_t *)vga_nop,
- (vr_draw_cursor_t *)vga_nop,
- (vr_blink_cursor_t *)vga_nop,
- (vr_set_mouse_t *)vga_nop,
- (vr_draw_mouse_t *)vga_nop,
-};
-RENDERER(cga, GRAPHICS_MODE, grrndrsw, vga_set);
-RENDERER(ega, GRAPHICS_MODE, grrndrsw, vga_set);
-RENDERER(vga, GRAPHICS_MODE, grrndrsw, vga_set);
-#endif /* SC_NO_MODE_CHANGE */
-
-RENDERER_MODULE(vga, vga_set);
-
-#ifndef SC_NO_CUTPASTE
-static u_short mouse_and_mask[16] = {
- 0xc000, 0xe000, 0xf000, 0xf800, 0xfc00, 0xfe00, 0xff00, 0xff80,
- 0xfe00, 0x1e00, 0x1f00, 0x0f00, 0x0f00, 0x0000, 0x0000, 0x0000
-};
-static u_short mouse_or_mask[16] = {
- 0x0000, 0x4000, 0x6000, 0x7000, 0x7800, 0x7c00, 0x7e00, 0x6800,
- 0x0c00, 0x0c00, 0x0600, 0x0600, 0x0000, 0x0000, 0x0000, 0x0000
-};
-#endif
-
-static void
-vga_nop(scr_stat *scp, ...)
-{
-}
-
-/* text mode renderer */
-
-static void
-vga_txtclear(scr_stat *scp, int c, int attr)
-{
- sc_vtb_clear(&scp->scr, c, attr);
-}
-
-static void
-vga_txtborder(scr_stat *scp, int color)
-{
- (*vidsw[scp->sc->adapter]->set_border)(scp->sc->adp, color);
-}
-
-static void
-vga_txtdraw(scr_stat *scp, int from, int count, int flip)
-{
- vm_offset_t p;
- int c;
- int a;
-
- if (from + count > scp->xsize*scp->ysize)
- count = scp->xsize*scp->ysize - from;
-
- if (flip) {
- for (p = sc_vtb_pointer(&scp->scr, from); count-- > 0; ++from) {
- c = sc_vtb_getc(&scp->vtb, from);
- a = sc_vtb_geta(&scp->vtb, from);
- a = (a & 0x8800) | ((a & 0x7000) >> 4)
- | ((a & 0x0700) << 4);
- p = sc_vtb_putchar(&scp->scr, p, c, a);
- }
- } else {
- sc_vtb_copy(&scp->vtb, from, &scp->scr, from, count);
- }
-}
-
-static void
-vga_txtcursor_shape(scr_stat *scp, int base, int height, int blink)
-{
- if (base < 0 || base >= scp->font_size)
- return;
- /* the caller may set height <= 0 in order to disable the cursor */
-#if 0
- scp->cursor_base = base;
- scp->cursor_height = height;
-#endif
- (*vidsw[scp->sc->adapter]->set_hw_cursor_shape)(scp->sc->adp,
- base, height,
- scp->font_size, blink);
-}
-
-static void
-vga_txtcursor(scr_stat *scp, int at, int blink, int on, int flip)
-{
- video_adapter_t *adp;
- int cursor_attr;
-
- if (scp->cursor_height <= 0) /* the text cursor is disabled */
- return;
-
- adp = scp->sc->adp;
- if (blink) {
- scp->status |= VR_CURSOR_BLINK;
- if (on) {
- scp->status |= VR_CURSOR_ON;
- (*vidsw[adp->va_index]->set_hw_cursor)(adp,
- at%scp->xsize,
- at/scp->xsize);
- } else {
- if (scp->status & VR_CURSOR_ON)
- (*vidsw[adp->va_index]->set_hw_cursor)(adp,
- -1, -1);
- scp->status &= ~VR_CURSOR_ON;
- }
- } else {
- scp->status &= ~VR_CURSOR_BLINK;
- if (on) {
- scp->status |= VR_CURSOR_ON;
- cursor_attr = sc_vtb_geta(&scp->vtb, at);
- scp->cursor_saveunder_char = sc_vtb_getc(&scp->scr, at);
- scp->cursor_saveunder_attr = cursor_attr;
- if ((cursor_attr & 0x7000) == 0x7000) {
- cursor_attr &= 0x8f00;
- if ((cursor_attr & 0x0700) == 0)
- cursor_attr |= 0x0700;
- } else {
- cursor_attr |= 0x7000;
- if ((cursor_attr & 0x0700) == 0x0700)
- cursor_attr &= 0xf000;
- }
- if (flip)
- cursor_attr = (cursor_attr & 0x8800)
- | ((cursor_attr & 0x7000) >> 4)
- | ((cursor_attr & 0x0700) << 4);
- sc_vtb_putc(&scp->scr, at,
- sc_vtb_getc(&scp->scr, at),
- cursor_attr);
- } else {
- cursor_attr = scp->cursor_saveunder_attr;
- if (flip)
- cursor_attr = (cursor_attr & 0x8800)
- | ((cursor_attr & 0x7000) >> 4)
- | ((cursor_attr & 0x0700) << 4);
- if (scp->status & VR_CURSOR_ON)
- sc_vtb_putc(&scp->scr, at,
- scp->cursor_saveunder_char,
- cursor_attr);
- scp->status &= ~VR_CURSOR_ON;
- }
- }
-}
-
-static void
-vga_txtblink(scr_stat *scp, int at, int flip)
-{
-}
-
-#ifndef SC_NO_CUTPASTE
-
-static void
-draw_txtmouse(scr_stat *scp, int x, int y)
-{
-#ifndef SC_ALT_MOUSE_IMAGE
- u_char font_buf[128];
- u_short cursor[32];
- u_char c;
- int pos;
- int xoffset, yoffset;
- int crtc_addr;
- int i;
-
- /* prepare mousepointer char's bitmaps */
- pos = (y/scp->font_size - scp->yoff)*scp->xsize + x/8 - scp->xoff;
- bcopy(scp->font + sc_vtb_getc(&scp->vtb, pos)*scp->font_size,
- &font_buf[0], scp->font_size);
- bcopy(scp->font + sc_vtb_getc(&scp->vtb, pos + 1)*scp->font_size,
- &font_buf[32], scp->font_size);
- bcopy(scp->font
- + sc_vtb_getc(&scp->vtb, pos + scp->xsize)*scp->font_size,
- &font_buf[64], scp->font_size);
- bcopy(scp->font
- + sc_vtb_getc(&scp->vtb, pos + scp->xsize + 1)*scp->font_size,
- &font_buf[96], scp->font_size);
- for (i = 0; i < scp->font_size; ++i) {
- cursor[i] = font_buf[i]<<8 | font_buf[i+32];
- cursor[i + scp->font_size] = font_buf[i+64]<<8 | font_buf[i+96];
- }
-
- /* now and-or in the mousepointer image */
- xoffset = x%8;
- yoffset = y%scp->font_size;
- for (i = 0; i < 16; ++i) {
- cursor[i + yoffset] =
- (cursor[i + yoffset] & ~(mouse_and_mask[i] >> xoffset))
- | (mouse_or_mask[i] >> xoffset);
- }
- for (i = 0; i < scp->font_size; ++i) {
- font_buf[i] = (cursor[i] & 0xff00) >> 8;
- font_buf[i + 32] = cursor[i] & 0xff;
- font_buf[i + 64] = (cursor[i + scp->font_size] & 0xff00) >> 8;
- font_buf[i + 96] = cursor[i + scp->font_size] & 0xff;
- }
-
-#if 1
- /* wait for vertical retrace to avoid jitter on some videocards */
- crtc_addr = scp->sc->adp->va_crtc_addr;
- while (!(inb(crtc_addr + 6) & 0x08)) /* idle */ ;
-#endif
- c = scp->sc->mouse_char;
- (*vidsw[scp->sc->adapter]->load_font)(scp->sc->adp, 0, 32, font_buf,
- c, 4);
-
- sc_vtb_putc(&scp->scr, pos, c, sc_vtb_geta(&scp->scr, pos));
- /* FIXME: may be out of range! */
- sc_vtb_putc(&scp->scr, pos + scp->xsize, c + 2,
- sc_vtb_geta(&scp->scr, pos + scp->xsize));
- if (x < (scp->xsize - 1)*8) {
- sc_vtb_putc(&scp->scr, pos + 1, c + 1,
- sc_vtb_geta(&scp->scr, pos + 1));
- sc_vtb_putc(&scp->scr, pos + scp->xsize + 1, c + 3,
- sc_vtb_geta(&scp->scr, pos + scp->xsize + 1));
- }
-#else /* SC_ALT_MOUSE_IMAGE */
- /* Red, magenta and brown are mapped to green to to keep it readable */
- static const int col_conv[16] = {
- 6, 6, 6, 6, 2, 2, 2, 6, 14, 14, 14, 14, 10, 10, 10, 14
- };
- int pos;
- int color;
- int a;
-
- pos = (y/scp->font_size - scp->yoff)*scp->xsize + x/8 - scp->xoff;
- a = sc_vtb_geta(&scp->scr, pos);
- if (scp->sc->adp->va_flags & V_ADP_COLOR)
- color = (col_conv[(a & 0xf000) >> 12] << 12)
- | ((a & 0x0f00) | 0x0800);
- else
- color = ((a & 0xf000) >> 4) | ((a & 0x0f00) << 4);
- sc_vtb_putc(&scp->scr, pos, sc_vtb_getc(&scp->scr, pos), color);
-#endif /* SC_ALT_MOUSE_IMAGE */
-}
-
-static void
-remove_txtmouse(scr_stat *scp, int x, int y)
-{
-}
-
-static void
-vga_txtmouse(scr_stat *scp, int x, int y, int on)
-{
- if (on)
- draw_txtmouse(scp, x, y);
- else
- remove_txtmouse(scp, x, y);
-}
-
-#endif /* SC_NO_CUTPASTE */
-
-#ifdef SC_PIXEL_MODE
-
-/* pixel (raster text) mode renderer */
-
-static void
-vga_pxlclear(scr_stat *scp, int c, int attr)
-{
- vm_offset_t p;
- int line_width;
- int lines;
- int i;
-
- /* XXX: we are just filling the screen with the background color... */
- outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */
- outw(GDCIDX, 0x0003); /* data rotate/function select */
- outw(GDCIDX, 0x0f01); /* set/reset enable */
- outw(GDCIDX, 0xff08); /* bit mask */
- outw(GDCIDX, ((attr & 0xf000) >> 4) | 0x00); /* set/reset */
- line_width = scp->sc->adp->va_line_width;
- lines = scp->ysize*scp->font_size;
- p = scp->sc->adp->va_window + line_width*scp->yoff*scp->font_size
- + scp->xoff;
- for (i = 0; i < lines; ++i) {
- bzero_io((void *)p, scp->xsize);
- p += line_width;
- }
- outw(GDCIDX, 0x0000); /* set/reset */
- outw(GDCIDX, 0x0001); /* set/reset enable */
-}
-
-static void
-vga_pxlborder(scr_stat *scp, int color)
-{
- vm_offset_t p;
- int line_width;
- int i;
-
- (*vidsw[scp->sc->adapter]->set_border)(scp->sc->adp, color);
-
- outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */
- outw(GDCIDX, 0x0003); /* data rotate/function select */
- outw(GDCIDX, 0x0f01); /* set/reset enable */
- outw(GDCIDX, 0xff08); /* bit mask */
- outw(GDCIDX, (color << 8) | 0x00); /* set/reset */
- line_width = scp->sc->adp->va_line_width;
- p = scp->sc->adp->va_window;
- if (scp->yoff > 0) {
- bzero_io((void *)p, line_width*scp->yoff*scp->font_size);
- bzero_io((void *)(p + line_width*(scp->yoff + scp->ysize)
- *scp->font_size),
- line_width*(scp->ypixel
- - (scp->yoff + scp->ysize)*scp->font_size));
- }
- if (scp->xoff > 0) {
- for (i = 0; i < scp->ysize*scp->font_size; ++i) {
- bzero_io((void *)(p + line_width
- *(scp->yoff*scp->font_size + i)),
- scp->xoff);
- bzero_io((void *)(p + line_width
- *(scp->yoff*scp->font_size + i)
- + scp->xoff + scp->xsize),
- scp->xpixel/8 - scp->xoff - scp->xsize);
- }
- }
- outw(GDCIDX, 0x0000); /* set/reset */
- outw(GDCIDX, 0x0001); /* set/reset enable */
-}
-
-static void
-vga_egadraw(scr_stat *scp, int from, int count, int flip)
-{
- vm_offset_t d;
- vm_offset_t e;
- u_char *f;
- u_short bg;
- u_short col1, col2;
- int line_width;
- int i, j;
- int a;
- u_char c;
-
- line_width = scp->sc->adp->va_line_width;
- d = scp->sc->adp->va_window
- + scp->xoff
- + scp->yoff*scp->font_size*line_width
- + (from%scp->xsize)
- + scp->font_size*line_width*(from/scp->xsize);
-
- outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */
- outw(GDCIDX, 0x0003); /* data rotate/function select */
- outw(GDCIDX, 0x0f01); /* set/reset enable */
- bg = -1;
- if (from + count > scp->xsize*scp->ysize)
- count = scp->xsize*scp->ysize - from;
- for (i = from; count-- > 0; ++i) {
- a = sc_vtb_geta(&scp->vtb, i);
- if (flip) {
- col1 = ((a & 0x7000) >> 4) | (a & 0x0800);
- col2 = ((a & 0x8000) >> 4) | (a & 0x0700);
- } else {
- col1 = (a & 0x0f00);
- col2 = (a & 0xf000) >> 4;
- }
- /* set background color in EGA/VGA latch */
- if (bg != col2) {
- bg = col2;
- outw(GDCIDX, bg | 0x00); /* set/reset */
- outw(GDCIDX, 0xff08); /* bit mask */
- writeb(d, 0);
- c = readb(d); /* set bg color in the latch */
- }
- /* foreground color */
- outw(GDCIDX, col1 | 0x00); /* set/reset */
- e = d;
- f = &(scp->font[sc_vtb_getc(&scp->vtb, i)*scp->font_size]);
- for (j = 0; j < scp->font_size; ++j, ++f) {
- outw(GDCIDX, (*f << 8) | 0x08); /* bit mask */
- writeb(e, 0);
- e += line_width;
- }
- ++d;
- if ((i % scp->xsize) == scp->xsize - 1)
- d += scp->xoff*2
- + (scp->font_size - 1)*line_width;
- }
- outw(GDCIDX, 0x0000); /* set/reset */
- outw(GDCIDX, 0x0001); /* set/reset enable */
- outw(GDCIDX, 0xff08); /* bit mask */
-}
-
-static void
-vga_vgadraw(scr_stat *scp, int from, int count, int flip)
-{
- vm_offset_t d;
- vm_offset_t e;
- u_char *f;
- u_short bg;
- u_short col1, col2;
- int line_width;
- int i, j;
- int a;
- u_char c;
-
- line_width = scp->sc->adp->va_line_width;
- d = scp->sc->adp->va_window
- + scp->xoff
- + scp->yoff*scp->font_size*line_width
- + (from%scp->xsize)
- + scp->font_size*line_width*(from/scp->xsize);
-
- outw(GDCIDX, 0x0305); /* read mode 0, write mode 3 */
- outw(GDCIDX, 0x0003); /* data rotate/function select */
- outw(GDCIDX, 0x0f01); /* set/reset enable */
- outw(GDCIDX, 0xff08); /* bit mask */
- bg = -1;
- if (from + count > scp->xsize*scp->ysize)
- count = scp->xsize*scp->ysize - from;
- for (i = from; count-- > 0; ++i) {
- a = sc_vtb_geta(&scp->vtb, i);
- if (flip) {
- col1 = ((a & 0x7000) >> 4) | (a & 0x0800);
- col2 = ((a & 0x8000) >> 4) | (a & 0x0700);
- } else {
- col1 = (a & 0x0f00);
- col2 = (a & 0xf000) >> 4;
- }
- /* set background color in EGA/VGA latch */
- if (bg != col2) {
- bg = col2;
- outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */
- outw(GDCIDX, bg | 0x00); /* set/reset */
- writeb(d, 0);
- c = readb(d); /* set bg color in the latch */
- outw(GDCIDX, 0x0305); /* read mode 0, write mode 3 */
- }
- /* foreground color */
- outw(GDCIDX, col1 | 0x00); /* set/reset */
- e = d;
- f = &(scp->font[sc_vtb_getc(&scp->vtb, i)*scp->font_size]);
- for (j = 0; j < scp->font_size; ++j, ++f) {
- writeb(e, *f);
- e += line_width;
- }
- ++d;
- if ((i % scp->xsize) == scp->xsize - 1)
- d += scp->xoff*2
- + (scp->font_size - 1)*line_width;
- }
- outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */
- outw(GDCIDX, 0x0000); /* set/reset */
- outw(GDCIDX, 0x0001); /* set/reset enable */
-}
-
-static void
-vga_pxlcursor_shape(scr_stat *scp, int base, int height, int blink)
-{
- if (base < 0 || base >= scp->font_size)
- return;
- /* the caller may set height <= 0 in order to disable the cursor */
-#if 0
- scp->cursor_base = base;
- scp->cursor_height = height;
-#endif
-}
-
-static void
-draw_pxlcursor(scr_stat *scp, int at, int on, int flip)
-{
- vm_offset_t d;
- u_char *f;
- int line_width;
- int height;
- int col;
- int a;
- int i;
- u_char c;
-
- line_width = scp->sc->adp->va_line_width;
- d = scp->sc->adp->va_window
- + scp->xoff
- + scp->yoff*scp->font_size*line_width
- + (at%scp->xsize)
- + scp->font_size*line_width*(at/scp->xsize)
- + (scp->font_size - scp->cursor_base - 1)*line_width;
-
- outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */
- outw(GDCIDX, 0x0003); /* data rotate/function select */
- outw(GDCIDX, 0x0f01); /* set/reset enable */
- /* set background color in EGA/VGA latch */
- a = sc_vtb_geta(&scp->vtb, at);
- if (flip)
- col = (on) ? ((a & 0xf000) >> 4) : (a & 0x0f00);
- else
- col = (on) ? (a & 0x0f00) : ((a & 0xf000) >> 4);
- outw(GDCIDX, col | 0x00); /* set/reset */
- outw(GDCIDX, 0xff08); /* bit mask */
- writeb(d, 0);
- c = readb(d); /* set bg color in the latch */
- /* foreground color */
- if (flip)
- col = (on) ? (a & 0x0f00) : ((a & 0xf000) >> 4);
- else
- col = (on) ? ((a & 0xf000) >> 4) : (a & 0x0f00);
- outw(GDCIDX, col | 0x00); /* set/reset */
- f = &(scp->font[sc_vtb_getc(&scp->vtb, at)*scp->font_size
- + scp->font_size - scp->cursor_base - 1]);
- height = imin(scp->cursor_height, scp->font_size);
- for (i = 0; i < height; ++i, --f) {
- outw(GDCIDX, (*f << 8) | 0x08); /* bit mask */
- writeb(d, 0);
- d -= line_width;
- }
- outw(GDCIDX, 0x0000); /* set/reset */
- outw(GDCIDX, 0x0001); /* set/reset enable */
- outw(GDCIDX, 0xff08); /* bit mask */
-}
-
-static void
-vga_pxlcursor(scr_stat *scp, int at, int blink, int on, int flip)
-{
- if (scp->cursor_height <= 0) /* the text cursor is disabled */
- return;
-
- if (on) {
- scp->status |= VR_CURSOR_ON;
- draw_pxlcursor(scp, at, on, flip);
- } else {
- if (scp->status & VR_CURSOR_ON)
- draw_pxlcursor(scp, at, on, flip);
- scp->status &= ~VR_CURSOR_ON;
- }
- if (blink)
- scp->status |= VR_CURSOR_BLINK;
- else
- scp->status &= ~VR_CURSOR_BLINK;
-}
-
-static void
-vga_pxlblink(scr_stat *scp, int at, int flip)
-{
- static int blinkrate = 0;
-
- if (!(scp->status & VR_CURSOR_BLINK))
- return;
- if (!(++blinkrate & 4))
- return;
- blinkrate = 0;
- scp->status ^= VR_CURSOR_ON;
- draw_pxlcursor(scp, at, scp->status & VR_CURSOR_ON, flip);
-}
-
-#ifndef SC_NO_CUTPASTE
-
-static void
-draw_pxlmouse(scr_stat *scp, int x, int y)
-{
- vm_offset_t p;
- int line_width;
- int xoff, yoff;
- int ymax;
- u_short m;
- int i, j;
-
- line_width = scp->sc->adp->va_line_width;
- xoff = (x - scp->xoff*8)%8;
- yoff = y - (y/line_width)*line_width;
- ymax = imin(y + 16, scp->ypixel);
-
- outw(GDCIDX, 0x0805); /* read mode 1, write mode 0 */
- outw(GDCIDX, 0x0001); /* set/reset enable */
- outw(GDCIDX, 0x0002); /* color compare */
- outw(GDCIDX, 0x0007); /* color don't care */
- outw(GDCIDX, 0xff08); /* bit mask */
- outw(GDCIDX, 0x0803); /* data rotate/function select (and) */
- p = scp->sc->adp->va_window + line_width*y + x/8;
- if (x < scp->xpixel - 16) {
- for (i = y, j = 0; i < ymax; ++i, ++j) {
- m = ~(mouse_and_mask[j] >> xoff);
-#ifdef __i386__
- *(u_char *)p &= m >> 8;
- *(u_char *)(p + 1) &= m;
-#elif defined(__alpha__)
- writeb(p, readb(p) & (m >> 8));
- writeb(p + 1, readb(p + 1) & (m >> 8));
-#endif
- p += line_width;
- }
- } else {
- xoff += 8;
- for (i = y, j = 0; i < ymax; ++i, ++j) {
- m = ~(mouse_and_mask[j] >> xoff);
-#ifdef __i386__
- *(u_char *)p &= m;
-#elif defined(__alpha__)
- writeb(p, readb(p) & (m >> 8));
-#endif
- p += line_width;
- }
- }
- outw(GDCIDX, 0x1003); /* data rotate/function select (or) */
- p = scp->sc->adp->va_window + line_width*y + x/8;
- if (x < scp->xpixel - 16) {
- for (i = y, j = 0; i < ymax; ++i, ++j) {
- m = mouse_or_mask[j] >> xoff;
-#ifdef __i386__
- *(u_char *)p &= m >> 8;
- *(u_char *)(p + 1) &= m;
-#elif defined(__alpha__)
- writeb(p, readb(p) & (m >> 8));
- writeb(p + 1, readb(p + 1) & (m >> 8));
-#endif
- p += line_width;
- }
- } else {
- for (i = y, j = 0; i < ymax; ++i, ++j) {
- m = mouse_or_mask[j] >> xoff;
-#ifdef __i386__
- *(u_char *)p &= m;
-#elif defined(__alpha__)
- writeb(p, readb(p) & (m >> 8));
-#endif
- p += line_width;
- }
- }
- outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */
- outw(GDCIDX, 0x0003); /* data rotate/function select */
-}
-
-static void
-remove_pxlmouse(scr_stat *scp, int x, int y)
-{
- vm_offset_t p;
- int col, row;
- int pos;
- int line_width;
- int ymax;
- int i;
-
- /* erase the mouse cursor image */
- col = x/8 - scp->xoff;
- row = y/scp->font_size - scp->yoff;
- pos = row*scp->xsize + col;
- i = (col < scp->xsize - 1) ? 2 : 1;
- (*scp->rndr->draw)(scp, pos, i, FALSE);
- if (row < scp->ysize - 1)
- (*scp->rndr->draw)(scp, pos + scp->xsize, i, FALSE);
-
- /* paint border if necessary */
- line_width = scp->sc->adp->va_line_width;
- outw(GDCIDX, 0x0005); /* read mode 0, write mode 0 */
- outw(GDCIDX, 0x0003); /* data rotate/function select */
- outw(GDCIDX, 0x0f01); /* set/reset enable */
- outw(GDCIDX, 0xff08); /* bit mask */
- outw(GDCIDX, (scp->border << 8) | 0x00); /* set/reset */
- if (row == scp->ysize - 1) {
- i = (scp->ysize + scp->yoff)*scp->font_size;
- ymax = imin(i + scp->font_size, scp->ypixel);
- p = scp->sc->adp->va_window + i*line_width + scp->xoff + col;
- if (col < scp->xsize - 1) {
- for (; i < ymax; ++i) {
- writeb(p, 0);
- writeb(p + 1, 0);
- p += line_width;
- }
- } else {
- for (; i < ymax; ++i) {
- writeb(p, 0);
- p += line_width;
- }
- }
- }
- if ((col == scp->xsize - 1) && (scp->xoff > 0)) {
- i = (row + scp->yoff)*scp->font_size;
- ymax = imin(i + scp->font_size*2, scp->ypixel);
- p = scp->sc->adp->va_window + i*line_width
- + scp->xoff + scp->xsize;
- for (; i < ymax; ++i) {
- writeb(p, 0);
- p += line_width;
- }
- }
- outw(GDCIDX, 0x0000); /* set/reset */
- outw(GDCIDX, 0x0001); /* set/reset enable */
-}
-
-static void
-vga_pxlmouse(scr_stat *scp, int x, int y, int on)
-{
- if (on)
- draw_pxlmouse(scp, x, y);
- else
- remove_pxlmouse(scp, x, y);
-}
-
-#endif /* SC_NO_CUTPASTE */
-#endif /* SC_PIXEL_MODE */
-
-#ifndef SC_NO_MODE_CHANGE
-
-/* graphics mode renderer */
-
-static void
-vga_grborder(scr_stat *scp, int color)
-{
- (*vidsw[scp->sc->adapter]->set_border)(scp->sc->adp, color);
-}
-
-#endif
diff --git a/sys/dev/syscons/snake/snake_saver.c b/sys/dev/syscons/snake/snake_saver.c
deleted file mode 100644
index e4277e3beee2..000000000000
--- a/sys/dev/syscons/snake/snake_saver.c
+++ /dev/null
@@ -1,148 +0,0 @@
-/*-
- * Copyright (c) 1995-1998 Søren Schmidt
- * 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,
- * without modification, immediately at the beginning of the file.
- * 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/module.h>
-#include <sys/malloc.h>
-#include <sys/kernel.h>
-#include <sys/sysctl.h>
-#include <sys/consio.h>
-#include <sys/fbio.h>
-
-#include <machine/pc/display.h>
-
-#include <dev/fb/fbreg.h>
-#include <dev/fb/splashreg.h>
-#include <dev/syscons/syscons.h>
-
-static char *message;
-static int *messagep;
-static int messagelen;
-static int blanked;
-
-static int
-snake_saver(video_adapter_t *adp, int blank)
-{
- static int dirx, diry;
- int f;
- sc_softc_t *sc;
- scr_stat *scp;
-
-/* XXX hack for minimal changes. */
-#define save message
-#define savs messagep
-
- sc = sc_find_softc(adp, NULL);
- if (sc == NULL)
- return EAGAIN;
- scp = sc->cur_scp;
-
- if (blank) {
- if (adp->va_info.vi_flags & V_INFO_GRAPHICS)
- return EAGAIN;
- if (blanked <= 0) {
-#ifdef PC98
- if (epson_machine_id == 0x20) {
- outb(0x43f, 0x42);
- outb(0x0c17, inb(0xc17) & ~0x08);
- outb(0x43f, 0x40);
- }
-#endif /* PC98 */
- sc_vtb_clear(&scp->scr, sc->scr_map[0x20],
- (FG_LIGHTGREY | BG_BLACK) << 8);
- (*vidsw[adp->va_index]->set_hw_cursor)(adp, -1, -1);
- sc_set_border(scp, 0);
- dirx = (scp->xpos ? 1 : -1);
- diry = (scp->ypos ?
- scp->xsize : -scp->xsize);
- for (f=0; f< messagelen; f++)
- savs[f] = scp->xpos + scp->ypos*scp->xsize;
- sc_vtb_putc(&scp->scr, savs[0], sc->scr_map[*save],
- (FG_LIGHTGREY | BG_BLACK) << 8);
- blanked = 1;
- }
- if (blanked++ < 4)
- return 0;
- blanked = 1;
- sc_vtb_putc(&scp->scr, savs[messagelen - 1], sc->scr_map[0x20],
- (FG_LIGHTGREY | BG_BLACK) << 8);
- for (f=messagelen-1; f > 0; f--)
- savs[f] = savs[f-1];
- f = savs[0];
- if ((f % scp->xsize) == 0 ||
- (f % scp->xsize) == scp->xsize - 1 ||
- (random() % 50) == 0)
- dirx = -dirx;
- if ((f / scp->xsize) == 0 ||
- (f / scp->xsize) == scp->ysize - 1 ||
- (random() % 20) == 0)
- diry = -diry;
- savs[0] += dirx + diry;
- for (f=messagelen-1; f>=0; f--)
- sc_vtb_putc(&scp->scr, savs[f], sc->scr_map[save[f]],
- (FG_LIGHTGREY | BG_BLACK) << 8);
- }
- else {
-#ifdef PC98
- if (epson_machine_id == 0x20) {
- outb(0x43f, 0x42);
- outb(0x0c17, inb(0xc17) | 0x08);
- outb(0x43f, 0x40);
- }
-#endif /* PC98 */
- blanked = 0;
- }
- return 0;
-}
-
-static int
-snake_init(video_adapter_t *adp)
-{
- messagelen = strlen(ostype) + 1 + strlen(osrelease);
- message = malloc(messagelen + 1, M_DEVBUF, M_WAITOK);
- sprintf(message, "%s %s", ostype, osrelease);
- messagep = malloc(messagelen * sizeof *messagep, M_DEVBUF, M_WAITOK);
- return 0;
-}
-
-static int
-snake_term(video_adapter_t *adp)
-{
- free(message, M_DEVBUF);
- free(messagep, M_DEVBUF);
- return 0;
-}
-
-static scrn_saver_t snake_module = {
- "snake_saver", snake_init, snake_term, snake_saver, NULL,
-};
-
-SAVER_MODULE(snake_saver, snake_module);
diff --git a/sys/dev/syscons/star/star_saver.c b/sys/dev/syscons/star/star_saver.c
deleted file mode 100644
index 27e992133ee7..000000000000
--- a/sys/dev/syscons/star/star_saver.c
+++ /dev/null
@@ -1,135 +0,0 @@
-/*-
- * Copyright (c) 1995-1998 Søren Schmidt
- * 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,
- * without modification, immediately at the beginning of the file.
- * 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/consio.h>
-#include <sys/fbio.h>
-
-#include <machine/pc/display.h>
-
-#include <dev/fb/fbreg.h>
-#include <dev/fb/splashreg.h>
-#include <dev/syscons/syscons.h>
-
-#define NUM_STARS 50
-
-static int blanked;
-
-/*
- * Alternate saver that got its inspiration from a well known utility
- * package for an inferior^H^H^H^H^H^Hfamous OS.
- */
-static int
-star_saver(video_adapter_t *adp, int blank)
-{
- sc_softc_t *sc;
- scr_stat *scp;
- int cell, i;
- char pattern[] = {"...........++++*** "};
-#ifndef PC98
- char colors[] = {FG_DARKGREY, FG_LIGHTGREY,
- FG_WHITE, FG_LIGHTCYAN};
-#else
- char colors[] = {FG_BLUE, FG_LIGHTGREY,
- FG_LIGHTGREY, FG_CYAN};
-#endif /* PC98 */
- static u_short stars[NUM_STARS][2];
-
- sc = sc_find_softc(adp, NULL);
- if (sc == NULL)
- return EAGAIN;
- scp = sc->cur_scp;
-
- if (blank) {
- if (adp->va_info.vi_flags & V_INFO_GRAPHICS)
- return EAGAIN;
- if (!blanked) {
-#ifdef PC98
- if (epson_machine_id == 0x20) {
- outb(0x43f, 0x42);
- outb(0x0c17, inb(0xc17) & ~0x08);
- outb(0x43f, 0x40);
- }
-#endif /* PC98 */
- /* clear the screen and set the border color */
- sc_vtb_clear(&scp->scr, sc->scr_map[0x20],
- (FG_LIGHTGREY | BG_BLACK) << 8);
- (*vidsw[adp->va_index]->set_hw_cursor)(adp, -1, -1);
- sc_set_border(scp, 0);
- blanked = TRUE;
- for(i=0; i<NUM_STARS; i++) {
- stars[i][0] =
- random() % (scp->xsize*scp->ysize);
- stars[i][1] = 0;
- }
- }
- cell = random() % NUM_STARS;
- sc_vtb_putc(&scp->scr, stars[cell][0],
- sc->scr_map[pattern[stars[cell][1]]],
- colors[random()%sizeof(colors)] << 8);
- if ((stars[cell][1]+=(random()%4)) >= sizeof(pattern)-1) {
- stars[cell][0] = random() % (scp->xsize*scp->ysize);
- stars[cell][1] = 0;
- }
- }
- else {
-#ifdef PC98
- if (epson_machine_id == 0x20) {
- outb(0x43f, 0x42);
- outb(0x0c17, inb(0xc17) | 0x08);
- outb(0x43f, 0x40);
- }
-#endif /* PC98 */
- blanked = FALSE;
- }
- return 0;
-}
-
-static int
-star_init(video_adapter_t *adp)
-{
- blanked = FALSE;
- return 0;
-}
-
-static int
-star_term(video_adapter_t *adp)
-{
- return 0;
-}
-
-static scrn_saver_t star_module = {
- "star_saver", star_init, star_term, star_saver, NULL,
-};
-
-SAVER_MODULE(star_saver, star_module);
diff --git a/sys/dev/syscons/warp/warp_saver.c b/sys/dev/syscons/warp/warp_saver.c
deleted file mode 100644
index 7e5140720713..000000000000
--- a/sys/dev/syscons/warp/warp_saver.c
+++ /dev/null
@@ -1,139 +0,0 @@
-/*-
- * Copyright (c) 1998 Dag-Erling Coïdan Smørgrav
- * 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
- * in this position and unchanged.
- * 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/syslog.h>
-#include <sys/consio.h>
-#include <sys/fbio.h>
-
-#include <machine/random.h>
-
-#include <dev/fb/fbreg.h>
-#include <dev/fb/splashreg.h>
-#include <dev/syscons/syscons.h>
-
-static u_char *vid;
-static int blanked;
-
-#define SCRW 320
-#define SCRH 200
-#define SPP 15
-#define STARS (SPP*(1+2+4+8))
-
-static int star[STARS];
-static u_char warp_pal[768] = {
- 0x00, 0x00, 0x00,
- 0x66, 0x66, 0x66,
- 0x99, 0x99, 0x99,
- 0xcc, 0xcc, 0xcc,
- 0xff, 0xff, 0xff
- /* the rest is zero-filled by the compiler */
-};
-
-static void
-warp_update(void)
-{
- int i, j, k, n;
-
- for (i = 1, k = 0, n = SPP*8; i < 5; i++, n /= 2)
- for (j = 0; j < n; j++, k++) {
- vid[star[k]] = 0;
- star[k] += i;
- if (star[k] > SCRW*SCRH)
- star[k] -= SCRW*SCRH;
- vid[star[k]] = i;
- }
-}
-
-static int
-warp_saver(video_adapter_t *adp, int blank)
-{
- int pl;
-
- if (blank) {
- /* switch to graphics mode */
- if (blanked <= 0) {
- pl = splhigh();
- set_video_mode(adp, M_VGA_CG320);
- load_palette(adp, warp_pal);
-#if 0 /* XXX conflict */
- set_border(adp, 0);
-#endif
- blanked++;
- vid = (u_char *)adp->va_window;
- splx(pl);
- bzero(vid, SCRW*SCRH);
- }
-
- /* update display */
- warp_update();
-
- } else {
- blanked = 0;
- }
- return 0;
-}
-
-static int
-warp_init(video_adapter_t *adp)
-{
- video_info_t info;
- int i;
-
- /* check that the console is capable of running in 320x200x256 */
- if (get_mode_info(adp, M_VGA_CG320, &info)) {
- log(LOG_NOTICE, "warp_saver: the console does not support M_VGA_CG320\n");
- return ENODEV;
- }
-
- /* randomize the star field */
- for (i = 0; i < STARS; i++) {
- star[i] = random() % (SCRW*SCRH);
- }
-
- blanked = 0;
-
- return 0;
-}
-
-static int
-warp_term(video_adapter_t *adp)
-{
- return 0;
-}
-
-static scrn_saver_t warp_module = {
- "warp_saver", warp_init, warp_term, warp_saver, NULL,
-};
-
-SAVER_MODULE(warp_saver, warp_module);
diff --git a/sys/dev/ti/if_ti.c b/sys/dev/ti/if_ti.c
deleted file mode 100644
index 5b00f305d778..000000000000
--- a/sys/dev/ti/if_ti.c
+++ /dev/null
@@ -1,2510 +0,0 @@
-/*
- * Copyright (c) 1997, 1998, 1999
- * Bill Paul <wpaul@ctr.columbia.edu>. 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 Bill Paul.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY Bill Paul 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 Bill Paul OR THE VOICES IN HIS HEAD
- * 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Alteon Networks Tigon PCI gigabit ethernet driver for FreeBSD.
- * Manuals, sample driver and firmware source kits are available
- * from http://www.alteon.com/support/openkits.
- *
- * Written by Bill Paul <wpaul@ctr.columbia.edu>
- * Electrical Engineering Department
- * Columbia University, New York City
- */
-
-/*
- * The Alteon Networks Tigon chip contains an embedded R4000 CPU,
- * gigabit MAC, dual DMA channels and a PCI interface unit. NICs
- * using the Tigon may have anywhere from 512K to 2MB of SRAM. The
- * Tigon supports hardware IP, TCP and UCP checksumming, multicast
- * filtering and jumbo (9014 byte) frames. The hardware is largely
- * controlled by firmware, which must be loaded into the NIC during
- * initialization.
- *
- * The Tigon 2 contains 2 R4000 CPUs and requires a newer firmware
- * revision, which supports new features such as extended commands,
- * extended jumbo receive ring desciptors and a mini receive ring.
- *
- * Alteon Networks is to be commended for releasing such a vast amount
- * of development material for the Tigon NIC without requiring an NDA
- * (although they really should have done it a long time ago). With
- * any luck, the other vendors will finally wise up and follow Alteon's
- * stellar example.
- *
- * The firmware for the Tigon 1 and 2 NICs is compiled directly into
- * this driver by #including it as a C header file. This bloats the
- * driver somewhat, but it's the easiest method considering that the
- * driver code and firmware code need to be kept in sync. The source
- * for the firmware is not provided with the FreeBSD distribution since
- * compiling it requires a GNU toolchain targeted for mips-sgi-irix5.3.
- *
- * The following people deserve special thanks:
- * - Terry Murphy of 3Com, for providing a 3c985 Tigon 1 board
- * for testing
- * - Raymond Lee of Netgear, for providing a pair of Netgear
- * GA620 Tigon 2 boards for testing
- * - Ulf Zimmermann, for bringing the GA260 to my attention and
- * convincing me to write this driver.
- * - Andrew Gallatin for providing FreeBSD/Alpha support.
- */
-
-#include "vlan.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/sockio.h>
-#include <sys/mbuf.h>
-#include <sys/malloc.h>
-#include <sys/kernel.h>
-#include <sys/socket.h>
-#include <sys/queue.h>
-
-#include <net/if.h>
-#include <net/if_arp.h>
-#include <net/ethernet.h>
-#include <net/if_dl.h>
-#include <net/if_media.h>
-
-#include <net/bpf.h>
-
-#if NVLAN > 0
-#include <net/if_types.h>
-#include <net/if_vlan_var.h>
-#endif
-
-#include <netinet/in_systm.h>
-#include <netinet/in.h>
-#include <netinet/ip.h>
-
-#include <vm/vm.h> /* for vtophys */
-#include <vm/pmap.h> /* for vtophys */
-#include <machine/clock.h> /* for DELAY */
-#include <machine/bus_memio.h>
-#include <machine/bus.h>
-#include <machine/resource.h>
-#include <sys/bus.h>
-#include <sys/rman.h>
-
-#include <pci/pcireg.h>
-#include <pci/pcivar.h>
-
-#include <pci/if_tireg.h>
-#include <pci/ti_fw.h>
-#include <pci/ti_fw2.h>
-
-#ifdef M_HWCKSUM
-/*#define TI_CSUM_OFFLOAD*/
-#endif
-
-#if !defined(lint)
-static const char rcsid[] =
- "$FreeBSD$";
-#endif
-
-/*
- * Various supported device vendors/types and their names.
- */
-
-static struct ti_type ti_devs[] = {
- { ALT_VENDORID, ALT_DEVICEID_ACENIC,
- "Alteon AceNIC Gigabit Ethernet" },
- { TC_VENDORID, TC_DEVICEID_3C985,
- "3Com 3c985-SX Gigabit Ethernet" },
- { NG_VENDORID, NG_DEVICEID_GA620,
- "Netgear GA620 Gigabit Ethernet" },
- { SGI_VENDORID, SGI_DEVICEID_TIGON,
- "Silicon Graphics Gigabit Ethernet" },
- { DEC_VENDORID, DEC_DEVICEID_FARALLON_PN9000SX,
- "Farallon PN9000SX Gigabit Ethernet" },
- { 0, 0, NULL }
-};
-
-static int ti_probe __P((device_t));
-static int ti_attach __P((device_t));
-static int ti_detach __P((device_t));
-static void ti_txeof __P((struct ti_softc *));
-static void ti_rxeof __P((struct ti_softc *));
-
-static void ti_stats_update __P((struct ti_softc *));
-static int ti_encap __P((struct ti_softc *, struct mbuf *,
- u_int32_t *));
-
-static void ti_intr __P((void *));
-static void ti_start __P((struct ifnet *));
-static int ti_ioctl __P((struct ifnet *, u_long, caddr_t));
-static void ti_init __P((void *));
-static void ti_init2 __P((struct ti_softc *));
-static void ti_stop __P((struct ti_softc *));
-static void ti_watchdog __P((struct ifnet *));
-static void ti_shutdown __P((device_t));
-static int ti_ifmedia_upd __P((struct ifnet *));
-static void ti_ifmedia_sts __P((struct ifnet *, struct ifmediareq *));
-
-static u_int32_t ti_eeprom_putbyte __P((struct ti_softc *, int));
-static u_int8_t ti_eeprom_getbyte __P((struct ti_softc *,
- int, u_int8_t *));
-static int ti_read_eeprom __P((struct ti_softc *, caddr_t, int, int));
-
-static void ti_add_mcast __P((struct ti_softc *, struct ether_addr *));
-static void ti_del_mcast __P((struct ti_softc *, struct ether_addr *));
-static void ti_setmulti __P((struct ti_softc *));
-
-static void ti_mem __P((struct ti_softc *, u_int32_t,
- u_int32_t, caddr_t));
-static void ti_loadfw __P((struct ti_softc *));
-static void ti_cmd __P((struct ti_softc *, struct ti_cmd_desc *));
-static void ti_cmd_ext __P((struct ti_softc *, struct ti_cmd_desc *,
- caddr_t, int));
-static void ti_handle_events __P((struct ti_softc *));
-static int ti_alloc_jumbo_mem __P((struct ti_softc *));
-static void *ti_jalloc __P((struct ti_softc *));
-static void ti_jfree __P((caddr_t, u_int));
-static void ti_jref __P((caddr_t, u_int));
-static int ti_newbuf_std __P((struct ti_softc *, int, struct mbuf *));
-static int ti_newbuf_mini __P((struct ti_softc *, int, struct mbuf *));
-static int ti_newbuf_jumbo __P((struct ti_softc *, int, struct mbuf *));
-static int ti_init_rx_ring_std __P((struct ti_softc *));
-static void ti_free_rx_ring_std __P((struct ti_softc *));
-static int ti_init_rx_ring_jumbo __P((struct ti_softc *));
-static void ti_free_rx_ring_jumbo __P((struct ti_softc *));
-static int ti_init_rx_ring_mini __P((struct ti_softc *));
-static void ti_free_rx_ring_mini __P((struct ti_softc *));
-static void ti_free_tx_ring __P((struct ti_softc *));
-static int ti_init_tx_ring __P((struct ti_softc *));
-
-static int ti_64bitslot_war __P((struct ti_softc *));
-static int ti_chipinit __P((struct ti_softc *));
-static int ti_gibinit __P((struct ti_softc *));
-
-static device_method_t ti_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, ti_probe),
- DEVMETHOD(device_attach, ti_attach),
- DEVMETHOD(device_detach, ti_detach),
- DEVMETHOD(device_shutdown, ti_shutdown),
- { 0, 0 }
-};
-
-static driver_t ti_driver = {
- "ti",
- ti_methods,
- sizeof(struct ti_softc)
-};
-
-static devclass_t ti_devclass;
-
-DRIVER_MODULE(if_ti, pci, ti_driver, ti_devclass, 0, 0);
-
-/*
- * Send an instruction or address to the EEPROM, check for ACK.
- */
-static u_int32_t ti_eeprom_putbyte(sc, byte)
- struct ti_softc *sc;
- int byte;
-{
- register int i, ack = 0;
-
- /*
- * Make sure we're in TX mode.
- */
- TI_SETBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_TXEN);
-
- /*
- * Feed in each bit and stobe the clock.
- */
- for (i = 0x80; i; i >>= 1) {
- if (byte & i) {
- TI_SETBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_DOUT);
- } else {
- TI_CLRBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_DOUT);
- }
- DELAY(1);
- TI_SETBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_CLK);
- DELAY(1);
- TI_CLRBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_CLK);
- }
-
- /*
- * Turn off TX mode.
- */
- TI_CLRBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_TXEN);
-
- /*
- * Check for ack.
- */
- TI_SETBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_CLK);
- ack = CSR_READ_4(sc, TI_MISC_LOCAL_CTL) & TI_MLC_EE_DIN;
- TI_CLRBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_CLK);
-
- return(ack);
-}
-
-/*
- * Read a byte of data stored in the EEPROM at address 'addr.'
- * We have to send two address bytes since the EEPROM can hold
- * more than 256 bytes of data.
- */
-static u_int8_t ti_eeprom_getbyte(sc, addr, dest)
- struct ti_softc *sc;
- int addr;
- u_int8_t *dest;
-{
- register int i;
- u_int8_t byte = 0;
-
- EEPROM_START;
-
- /*
- * Send write control code to EEPROM.
- */
- if (ti_eeprom_putbyte(sc, EEPROM_CTL_WRITE)) {
- printf("ti%d: failed to send write command, status: %x\n",
- sc->ti_unit, CSR_READ_4(sc, TI_MISC_LOCAL_CTL));
- return(1);
- }
-
- /*
- * Send first byte of address of byte we want to read.
- */
- if (ti_eeprom_putbyte(sc, (addr >> 8) & 0xFF)) {
- printf("ti%d: failed to send address, status: %x\n",
- sc->ti_unit, CSR_READ_4(sc, TI_MISC_LOCAL_CTL));
- return(1);
- }
- /*
- * Send second byte address of byte we want to read.
- */
- if (ti_eeprom_putbyte(sc, addr & 0xFF)) {
- printf("ti%d: failed to send address, status: %x\n",
- sc->ti_unit, CSR_READ_4(sc, TI_MISC_LOCAL_CTL));
- return(1);
- }
-
- EEPROM_STOP;
- EEPROM_START;
- /*
- * Send read control code to EEPROM.
- */
- if (ti_eeprom_putbyte(sc, EEPROM_CTL_READ)) {
- printf("ti%d: failed to send read command, status: %x\n",
- sc->ti_unit, CSR_READ_4(sc, TI_MISC_LOCAL_CTL));
- return(1);
- }
-
- /*
- * Start reading bits from EEPROM.
- */
- TI_CLRBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_TXEN);
- for (i = 0x80; i; i >>= 1) {
- TI_SETBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_CLK);
- DELAY(1);
- if (CSR_READ_4(sc, TI_MISC_LOCAL_CTL) & TI_MLC_EE_DIN)
- byte |= i;
- TI_CLRBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_CLK);
- DELAY(1);
- }
-
- EEPROM_STOP;
-
- /*
- * No ACK generated for read, so just return byte.
- */
-
- *dest = byte;
-
- return(0);
-}
-
-/*
- * Read a sequence of bytes from the EEPROM.
- */
-static int ti_read_eeprom(sc, dest, off, cnt)
- struct ti_softc *sc;
- caddr_t dest;
- int off;
- int cnt;
-{
- int err = 0, i;
- u_int8_t byte = 0;
-
- for (i = 0; i < cnt; i++) {
- err = ti_eeprom_getbyte(sc, off + i, &byte);
- if (err)
- break;
- *(dest + i) = byte;
- }
-
- return(err ? 1 : 0);
-}
-
-/*
- * NIC memory access function. Can be used to either clear a section
- * of NIC local memory or (if buf is non-NULL) copy data into it.
- */
-static void ti_mem(sc, addr, len, buf)
- struct ti_softc *sc;
- u_int32_t addr, len;
- caddr_t buf;
-{
- int segptr, segsize, cnt;
- caddr_t ti_winbase, ptr;
-
- segptr = addr;
- cnt = len;
- ti_winbase = (caddr_t)(sc->ti_vhandle + TI_WINDOW);
- ptr = buf;
-
- while(cnt) {
- if (cnt < TI_WINLEN)
- segsize = cnt;
- else
- segsize = TI_WINLEN - (segptr % TI_WINLEN);
- CSR_WRITE_4(sc, TI_WINBASE, (segptr & ~(TI_WINLEN - 1)));
- if (buf == NULL)
- bzero((char *)ti_winbase + (segptr &
- (TI_WINLEN - 1)), segsize);
- else {
- bcopy((char *)ptr, (char *)ti_winbase +
- (segptr & (TI_WINLEN - 1)), segsize);
- ptr += segsize;
- }
- segptr += segsize;
- cnt -= segsize;
- }
-
- return;
-}
-
-/*
- * Load firmware image into the NIC. Check that the firmware revision
- * is acceptable and see if we want the firmware for the Tigon 1 or
- * Tigon 2.
- */
-static void ti_loadfw(sc)
- struct ti_softc *sc;
-{
- switch(sc->ti_hwrev) {
- case TI_HWREV_TIGON:
- if (tigonFwReleaseMajor != TI_FIRMWARE_MAJOR ||
- tigonFwReleaseMinor != TI_FIRMWARE_MINOR ||
- tigonFwReleaseFix != TI_FIRMWARE_FIX) {
- printf("ti%d: firmware revision mismatch; want "
- "%d.%d.%d, got %d.%d.%d\n", sc->ti_unit,
- TI_FIRMWARE_MAJOR, TI_FIRMWARE_MINOR,
- TI_FIRMWARE_FIX, tigonFwReleaseMajor,
- tigonFwReleaseMinor, tigonFwReleaseFix);
- return;
- }
- ti_mem(sc, tigonFwTextAddr, tigonFwTextLen,
- (caddr_t)tigonFwText);
- ti_mem(sc, tigonFwDataAddr, tigonFwDataLen,
- (caddr_t)tigonFwData);
- ti_mem(sc, tigonFwRodataAddr, tigonFwRodataLen,
- (caddr_t)tigonFwRodata);
- ti_mem(sc, tigonFwBssAddr, tigonFwBssLen, NULL);
- ti_mem(sc, tigonFwSbssAddr, tigonFwSbssLen, NULL);
- CSR_WRITE_4(sc, TI_CPU_PROGRAM_COUNTER, tigonFwStartAddr);
- break;
- case TI_HWREV_TIGON_II:
- if (tigon2FwReleaseMajor != TI_FIRMWARE_MAJOR ||
- tigon2FwReleaseMinor != TI_FIRMWARE_MINOR ||
- tigon2FwReleaseFix != TI_FIRMWARE_FIX) {
- printf("ti%d: firmware revision mismatch; want "
- "%d.%d.%d, got %d.%d.%d\n", sc->ti_unit,
- TI_FIRMWARE_MAJOR, TI_FIRMWARE_MINOR,
- TI_FIRMWARE_FIX, tigon2FwReleaseMajor,
- tigon2FwReleaseMinor, tigon2FwReleaseFix);
- return;
- }
- ti_mem(sc, tigon2FwTextAddr, tigon2FwTextLen,
- (caddr_t)tigon2FwText);
- ti_mem(sc, tigon2FwDataAddr, tigon2FwDataLen,
- (caddr_t)tigon2FwData);
- ti_mem(sc, tigon2FwRodataAddr, tigon2FwRodataLen,
- (caddr_t)tigon2FwRodata);
- ti_mem(sc, tigon2FwBssAddr, tigon2FwBssLen, NULL);
- ti_mem(sc, tigon2FwSbssAddr, tigon2FwSbssLen, NULL);
- CSR_WRITE_4(sc, TI_CPU_PROGRAM_COUNTER, tigon2FwStartAddr);
- break;
- default:
- printf("ti%d: can't load firmware: unknown hardware rev\n",
- sc->ti_unit);
- break;
- }
-
- return;
-}
-
-/*
- * Send the NIC a command via the command ring.
- */
-static void ti_cmd(sc, cmd)
- struct ti_softc *sc;
- struct ti_cmd_desc *cmd;
-{
- u_int32_t index;
-
- if (sc->ti_rdata->ti_cmd_ring == NULL)
- return;
-
- index = sc->ti_cmd_saved_prodidx;
- CSR_WRITE_4(sc, TI_GCR_CMDRING + (index * 4), *(u_int32_t *)(cmd));
- TI_INC(index, TI_CMD_RING_CNT);
- CSR_WRITE_4(sc, TI_MB_CMDPROD_IDX, index);
- sc->ti_cmd_saved_prodidx = index;
-
- return;
-}
-
-/*
- * Send the NIC an extended command. The 'len' parameter specifies the
- * number of command slots to include after the initial command.
- */
-static void ti_cmd_ext(sc, cmd, arg, len)
- struct ti_softc *sc;
- struct ti_cmd_desc *cmd;
- caddr_t arg;
- int len;
-{
- u_int32_t index;
- register int i;
-
- if (sc->ti_rdata->ti_cmd_ring == NULL)
- return;
-
- index = sc->ti_cmd_saved_prodidx;
- CSR_WRITE_4(sc, TI_GCR_CMDRING + (index * 4), *(u_int32_t *)(cmd));
- TI_INC(index, TI_CMD_RING_CNT);
- for (i = 0; i < len; i++) {
- CSR_WRITE_4(sc, TI_GCR_CMDRING + (index * 4),
- *(u_int32_t *)(&arg[i * 4]));
- TI_INC(index, TI_CMD_RING_CNT);
- }
- CSR_WRITE_4(sc, TI_MB_CMDPROD_IDX, index);
- sc->ti_cmd_saved_prodidx = index;
-
- return;
-}
-
-/*
- * Handle events that have triggered interrupts.
- */
-static void ti_handle_events(sc)
- struct ti_softc *sc;
-{
- struct ti_event_desc *e;
-
- if (sc->ti_rdata->ti_event_ring == NULL)
- return;
-
- while (sc->ti_ev_saved_considx != sc->ti_ev_prodidx.ti_idx) {
- e = &sc->ti_rdata->ti_event_ring[sc->ti_ev_saved_considx];
- switch(e->ti_event) {
- case TI_EV_LINKSTAT_CHANGED:
- sc->ti_linkstat = e->ti_code;
- if (e->ti_code == TI_EV_CODE_LINK_UP)
- printf("ti%d: 10/100 link up\n", sc->ti_unit);
- else if (e->ti_code == TI_EV_CODE_GIG_LINK_UP)
- printf("ti%d: gigabit link up\n", sc->ti_unit);
- else if (e->ti_code == TI_EV_CODE_LINK_DOWN)
- printf("ti%d: link down\n", sc->ti_unit);
- break;
- case TI_EV_ERROR:
- if (e->ti_code == TI_EV_CODE_ERR_INVAL_CMD)
- printf("ti%d: invalid command\n", sc->ti_unit);
- else if (e->ti_code == TI_EV_CODE_ERR_UNIMP_CMD)
- printf("ti%d: unknown command\n", sc->ti_unit);
- else if (e->ti_code == TI_EV_CODE_ERR_BADCFG)
- printf("ti%d: bad config data\n", sc->ti_unit);
- break;
- case TI_EV_FIRMWARE_UP:
- ti_init2(sc);
- break;
- case TI_EV_STATS_UPDATED:
- ti_stats_update(sc);
- break;
- case TI_EV_RESET_JUMBO_RING:
- case TI_EV_MCAST_UPDATED:
- /* Who cares. */
- break;
- default:
- printf("ti%d: unknown event: %d\n",
- sc->ti_unit, e->ti_event);
- break;
- }
- /* Advance the consumer index. */
- TI_INC(sc->ti_ev_saved_considx, TI_EVENT_RING_CNT);
- CSR_WRITE_4(sc, TI_GCR_EVENTCONS_IDX, sc->ti_ev_saved_considx);
- }
-
- return;
-}
-
-/*
- * Memory management for the jumbo receive ring is a pain in the
- * butt. We need to allocate at least 9018 bytes of space per frame,
- * _and_ it has to be contiguous (unless you use the extended
- * jumbo descriptor format). Using malloc() all the time won't
- * work: malloc() allocates memory in powers of two, which means we
- * would end up wasting a considerable amount of space by allocating
- * 9K chunks. We don't have a jumbo mbuf cluster pool. Thus, we have
- * to do our own memory management.
- *
- * The driver needs to allocate a contiguous chunk of memory at boot
- * time. We then chop this up ourselves into 9K pieces and use them
- * as external mbuf storage.
- *
- * One issue here is how much memory to allocate. The jumbo ring has
- * 256 slots in it, but at 9K per slot than can consume over 2MB of
- * RAM. This is a bit much, especially considering we also need
- * RAM for the standard ring and mini ring (on the Tigon 2). To
- * save space, we only actually allocate enough memory for 64 slots
- * by default, which works out to between 500 and 600K. This can
- * be tuned by changing a #define in if_tireg.h.
- */
-
-static int ti_alloc_jumbo_mem(sc)
- struct ti_softc *sc;
-{
- caddr_t ptr;
- register int i;
- struct ti_jpool_entry *entry;
-
- /* Grab a big chunk o' storage. */
- sc->ti_cdata.ti_jumbo_buf = contigmalloc(TI_JMEM, M_DEVBUF,
- M_NOWAIT, 0, 0xffffffff, PAGE_SIZE, 0);
-
- if (sc->ti_cdata.ti_jumbo_buf == NULL) {
- printf("ti%d: no memory for jumbo buffers!\n", sc->ti_unit);
- return(ENOBUFS);
- }
-
- SLIST_INIT(&sc->ti_jfree_listhead);
- SLIST_INIT(&sc->ti_jinuse_listhead);
-
- /*
- * Now divide it up into 9K pieces and save the addresses
- * in an array. Note that we play an evil trick here by using
- * the first few bytes in the buffer to hold the the address
- * of the softc structure for this interface. This is because
- * ti_jfree() needs it, but it is called by the mbuf management
- * code which will not pass it to us explicitly.
- */
- ptr = sc->ti_cdata.ti_jumbo_buf;
- for (i = 0; i < TI_JSLOTS; i++) {
- u_int64_t **aptr;
- aptr = (u_int64_t **)ptr;
- aptr[0] = (u_int64_t *)sc;
- ptr += sizeof(u_int64_t);
- sc->ti_cdata.ti_jslots[i].ti_buf = ptr;
- sc->ti_cdata.ti_jslots[i].ti_inuse = 0;
- ptr += (TI_JLEN - sizeof(u_int64_t));
- entry = malloc(sizeof(struct ti_jpool_entry),
- M_DEVBUF, M_NOWAIT);
- if (entry == NULL) {
- free(sc->ti_cdata.ti_jumbo_buf, M_DEVBUF);
- sc->ti_cdata.ti_jumbo_buf = NULL;
- printf("ti%d: no memory for jumbo "
- "buffer queue!\n", sc->ti_unit);
- return(ENOBUFS);
- }
- entry->slot = i;
- SLIST_INSERT_HEAD(&sc->ti_jfree_listhead, entry, jpool_entries);
- }
-
- return(0);
-}
-
-/*
- * Allocate a jumbo buffer.
- */
-static void *ti_jalloc(sc)
- struct ti_softc *sc;
-{
- struct ti_jpool_entry *entry;
-
- entry = SLIST_FIRST(&sc->ti_jfree_listhead);
-
- if (entry == NULL) {
- printf("ti%d: no free jumbo buffers\n", sc->ti_unit);
- return(NULL);
- }
-
- SLIST_REMOVE_HEAD(&sc->ti_jfree_listhead, jpool_entries);
- SLIST_INSERT_HEAD(&sc->ti_jinuse_listhead, entry, jpool_entries);
- sc->ti_cdata.ti_jslots[entry->slot].ti_inuse = 1;
- return(sc->ti_cdata.ti_jslots[entry->slot].ti_buf);
-}
-
-/*
- * Adjust usage count on a jumbo buffer. In general this doesn't
- * get used much because our jumbo buffers don't get passed around
- * too much, but it's implemented for correctness.
- */
-static void ti_jref(buf, size)
- caddr_t buf;
- u_int size;
-{
- struct ti_softc *sc;
- u_int64_t **aptr;
- register int i;
-
- /* Extract the softc struct pointer. */
- aptr = (u_int64_t **)(buf - sizeof(u_int64_t));
- sc = (struct ti_softc *)(aptr[0]);
-
- if (sc == NULL)
- panic("ti_jref: can't find softc pointer!");
-
- if (size != TI_JUMBO_FRAMELEN)
- panic("ti_jref: adjusting refcount of buf of wrong size!");
-
- /* calculate the slot this buffer belongs to */
-
- i = ((vm_offset_t)aptr
- - (vm_offset_t)sc->ti_cdata.ti_jumbo_buf) / TI_JLEN;
-
- if ((i < 0) || (i >= TI_JSLOTS))
- panic("ti_jref: asked to reference buffer "
- "that we don't manage!");
- else if (sc->ti_cdata.ti_jslots[i].ti_inuse == 0)
- panic("ti_jref: buffer already free!");
- else
- sc->ti_cdata.ti_jslots[i].ti_inuse++;
-
- return;
-}
-
-/*
- * Release a jumbo buffer.
- */
-static void ti_jfree(buf, size)
- caddr_t buf;
- u_int size;
-{
- struct ti_softc *sc;
- u_int64_t **aptr;
- int i;
- struct ti_jpool_entry *entry;
-
- /* Extract the softc struct pointer. */
- aptr = (u_int64_t **)(buf - sizeof(u_int64_t));
- sc = (struct ti_softc *)(aptr[0]);
-
- if (sc == NULL)
- panic("ti_jfree: can't find softc pointer!");
-
- if (size != TI_JUMBO_FRAMELEN)
- panic("ti_jfree: freeing buffer of wrong size!");
-
- /* calculate the slot this buffer belongs to */
-
- i = ((vm_offset_t)aptr
- - (vm_offset_t)sc->ti_cdata.ti_jumbo_buf) / TI_JLEN;
-
- if ((i < 0) || (i >= TI_JSLOTS))
- panic("ti_jfree: asked to free buffer that we don't manage!");
- else if (sc->ti_cdata.ti_jslots[i].ti_inuse == 0)
- panic("ti_jfree: buffer already free!");
- else {
- sc->ti_cdata.ti_jslots[i].ti_inuse--;
- if(sc->ti_cdata.ti_jslots[i].ti_inuse == 0) {
- entry = SLIST_FIRST(&sc->ti_jinuse_listhead);
- if (entry == NULL)
- panic("ti_jfree: buffer not in use!");
- entry->slot = i;
- SLIST_REMOVE_HEAD(&sc->ti_jinuse_listhead,
- jpool_entries);
- SLIST_INSERT_HEAD(&sc->ti_jfree_listhead,
- entry, jpool_entries);
- }
- }
-
- return;
-}
-
-
-/*
- * Intialize a standard receive ring descriptor.
- */
-static int ti_newbuf_std(sc, i, m)
- struct ti_softc *sc;
- int i;
- struct mbuf *m;
-{
- struct mbuf *m_new = NULL;
- struct ti_rx_desc *r;
-
- if (m == NULL) {
- MGETHDR(m_new, M_DONTWAIT, MT_DATA);
- if (m_new == NULL) {
- printf("ti%d: mbuf allocation failed "
- "-- packet dropped!\n", sc->ti_unit);
- return(ENOBUFS);
- }
-
- MCLGET(m_new, M_DONTWAIT);
- if (!(m_new->m_flags & M_EXT)) {
- printf("ti%d: cluster allocation failed "
- "-- packet dropped!\n", sc->ti_unit);
- m_freem(m_new);
- return(ENOBUFS);
- }
- m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
- } else {
- m_new = m;
- m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
- m_new->m_data = m_new->m_ext.ext_buf;
- }
-
- m_adj(m_new, ETHER_ALIGN);
- sc->ti_cdata.ti_rx_std_chain[i] = m_new;
- r = &sc->ti_rdata->ti_rx_std_ring[i];
- TI_HOSTADDR(r->ti_addr) = vtophys(mtod(m_new, caddr_t));
- r->ti_type = TI_BDTYPE_RECV_BD;
-#ifdef TI_CSUM_OFFLOAD
- r->ti_flags = TI_BDFLAG_TCP_UDP_CKSUM|TI_BDFLAG_IP_CKSUM;
-#else
- r->ti_flags = 0;
-#endif
- r->ti_len = m_new->m_len;
- r->ti_idx = i;
-
- return(0);
-}
-
-/*
- * Intialize a mini receive ring descriptor. This only applies to
- * the Tigon 2.
- */
-static int ti_newbuf_mini(sc, i, m)
- struct ti_softc *sc;
- int i;
- struct mbuf *m;
-{
- struct mbuf *m_new = NULL;
- struct ti_rx_desc *r;
-
- if (m == NULL) {
- MGETHDR(m_new, M_DONTWAIT, MT_DATA);
- if (m_new == NULL) {
- printf("ti%d: mbuf allocation failed "
- "-- packet dropped!\n", sc->ti_unit);
- return(ENOBUFS);
- }
- m_new->m_len = m_new->m_pkthdr.len = MHLEN;
- } else {
- m_new = m;
- m_new->m_data = m_new->m_pktdat;
- m_new->m_len = m_new->m_pkthdr.len = MHLEN;
- }
-
- m_adj(m_new, ETHER_ALIGN);
- r = &sc->ti_rdata->ti_rx_mini_ring[i];
- sc->ti_cdata.ti_rx_mini_chain[i] = m_new;
- TI_HOSTADDR(r->ti_addr) = vtophys(mtod(m_new, caddr_t));
- r->ti_type = TI_BDTYPE_RECV_BD;
- r->ti_flags = TI_BDFLAG_MINI_RING;
-#ifdef TI_CSUM_OFFLOAD
- r->ti_flags |= TI_BDFLAG_TCP_UDP_CKSUM|TI_BDFLAG_IP_CKSUM;
-#endif
- r->ti_len = m_new->m_len;
- r->ti_idx = i;
-
- return(0);
-}
-
-/*
- * Initialize a jumbo receive ring descriptor. This allocates
- * a jumbo buffer from the pool managed internally by the driver.
- */
-static int ti_newbuf_jumbo(sc, i, m)
- struct ti_softc *sc;
- int i;
- struct mbuf *m;
-{
- struct mbuf *m_new = NULL;
- struct ti_rx_desc *r;
-
- if (m == NULL) {
- caddr_t *buf = NULL;
-
- /* Allocate the mbuf. */
- MGETHDR(m_new, M_DONTWAIT, MT_DATA);
- if (m_new == NULL) {
- printf("ti%d: mbuf allocation failed "
- "-- packet dropped!\n", sc->ti_unit);
- return(ENOBUFS);
- }
-
- /* Allocate the jumbo buffer */
- buf = ti_jalloc(sc);
- if (buf == NULL) {
- m_freem(m_new);
- printf("ti%d: jumbo allocation failed "
- "-- packet dropped!\n", sc->ti_unit);
- return(ENOBUFS);
- }
-
- /* Attach the buffer to the mbuf. */
- m_new->m_data = m_new->m_ext.ext_buf = (void *)buf;
- m_new->m_flags |= M_EXT;
- m_new->m_len = m_new->m_pkthdr.len =
- m_new->m_ext.ext_size = TI_JUMBO_FRAMELEN;
- m_new->m_ext.ext_free = ti_jfree;
- m_new->m_ext.ext_ref = ti_jref;
- } else {
- m_new = m;
- m_new->m_data = m_new->m_ext.ext_buf;
- m_new->m_ext.ext_size = TI_JUMBO_FRAMELEN;
- }
-
- m_adj(m_new, ETHER_ALIGN);
- /* Set up the descriptor. */
- r = &sc->ti_rdata->ti_rx_jumbo_ring[i];
- sc->ti_cdata.ti_rx_jumbo_chain[i] = m_new;
- TI_HOSTADDR(r->ti_addr) = vtophys(mtod(m_new, caddr_t));
- r->ti_type = TI_BDTYPE_RECV_JUMBO_BD;
- r->ti_flags = TI_BDFLAG_JUMBO_RING;
-#ifdef TI_CSUM_OFFLOAD
- r->ti_flags |= TI_BDFLAG_TCP_UDP_CKSUM|TI_BDFLAG_IP_CKSUM;
-#endif
- r->ti_len = m_new->m_len;
- r->ti_idx = i;
-
- return(0);
-}
-
-/*
- * The standard receive ring has 512 entries in it. At 2K per mbuf cluster,
- * that's 1MB or memory, which is a lot. For now, we fill only the first
- * 256 ring entries and hope that our CPU is fast enough to keep up with
- * the NIC.
- */
-static int ti_init_rx_ring_std(sc)
- struct ti_softc *sc;
-{
- register int i;
- struct ti_cmd_desc cmd;
-
- for (i = 0; i < TI_SSLOTS; i++) {
- if (ti_newbuf_std(sc, i, NULL) == ENOBUFS)
- return(ENOBUFS);
- };
-
- TI_UPDATE_STDPROD(sc, i - 1);
- sc->ti_std = i - 1;
-
- return(0);
-}
-
-static void ti_free_rx_ring_std(sc)
- struct ti_softc *sc;
-{
- register int i;
-
- for (i = 0; i < TI_STD_RX_RING_CNT; i++) {
- if (sc->ti_cdata.ti_rx_std_chain[i] != NULL) {
- m_freem(sc->ti_cdata.ti_rx_std_chain[i]);
- sc->ti_cdata.ti_rx_std_chain[i] = NULL;
- }
- bzero((char *)&sc->ti_rdata->ti_rx_std_ring[i],
- sizeof(struct ti_rx_desc));
- }
-
- return;
-}
-
-static int ti_init_rx_ring_jumbo(sc)
- struct ti_softc *sc;
-{
- register int i;
- struct ti_cmd_desc cmd;
-
- for (i = 0; i < (TI_JSLOTS - 20); i++) {
- if (ti_newbuf_jumbo(sc, i, NULL) == ENOBUFS)
- return(ENOBUFS);
- };
-
- TI_UPDATE_JUMBOPROD(sc, i - 1);
- sc->ti_jumbo = i - 1;
-
- return(0);
-}
-
-static void ti_free_rx_ring_jumbo(sc)
- struct ti_softc *sc;
-{
- register int i;
-
- for (i = 0; i < TI_JUMBO_RX_RING_CNT; i++) {
- if (sc->ti_cdata.ti_rx_jumbo_chain[i] != NULL) {
- m_freem(sc->ti_cdata.ti_rx_jumbo_chain[i]);
- sc->ti_cdata.ti_rx_jumbo_chain[i] = NULL;
- }
- bzero((char *)&sc->ti_rdata->ti_rx_jumbo_ring[i],
- sizeof(struct ti_rx_desc));
- }
-
- return;
-}
-
-static int ti_init_rx_ring_mini(sc)
- struct ti_softc *sc;
-{
- register int i;
-
- for (i = 0; i < TI_MSLOTS; i++) {
- if (ti_newbuf_mini(sc, i, NULL) == ENOBUFS)
- return(ENOBUFS);
- };
-
- TI_UPDATE_MINIPROD(sc, i - 1);
- sc->ti_mini = i - 1;
-
- return(0);
-}
-
-static void ti_free_rx_ring_mini(sc)
- struct ti_softc *sc;
-{
- register int i;
-
- for (i = 0; i < TI_MINI_RX_RING_CNT; i++) {
- if (sc->ti_cdata.ti_rx_mini_chain[i] != NULL) {
- m_freem(sc->ti_cdata.ti_rx_mini_chain[i]);
- sc->ti_cdata.ti_rx_mini_chain[i] = NULL;
- }
- bzero((char *)&sc->ti_rdata->ti_rx_mini_ring[i],
- sizeof(struct ti_rx_desc));
- }
-
- return;
-}
-
-static void ti_free_tx_ring(sc)
- struct ti_softc *sc;
-{
- register int i;
-
- if (sc->ti_rdata->ti_tx_ring == NULL)
- return;
-
- for (i = 0; i < TI_TX_RING_CNT; i++) {
- if (sc->ti_cdata.ti_tx_chain[i] != NULL) {
- m_freem(sc->ti_cdata.ti_tx_chain[i]);
- sc->ti_cdata.ti_tx_chain[i] = NULL;
- }
- bzero((char *)&sc->ti_rdata->ti_tx_ring[i],
- sizeof(struct ti_tx_desc));
- }
-
- return;
-}
-
-static int ti_init_tx_ring(sc)
- struct ti_softc *sc;
-{
- sc->ti_txcnt = 0;
- sc->ti_tx_saved_considx = 0;
- CSR_WRITE_4(sc, TI_MB_SENDPROD_IDX, 0);
- return(0);
-}
-
-/*
- * The Tigon 2 firmware has a new way to add/delete multicast addresses,
- * but we have to support the old way too so that Tigon 1 cards will
- * work.
- */
-void ti_add_mcast(sc, addr)
- struct ti_softc *sc;
- struct ether_addr *addr;
-{
- struct ti_cmd_desc cmd;
- u_int16_t *m;
- u_int32_t ext[2] = {0, 0};
-
- m = (u_int16_t *)&addr->octet[0];
-
- switch(sc->ti_hwrev) {
- case TI_HWREV_TIGON:
- CSR_WRITE_4(sc, TI_GCR_MAR0, htons(m[0]));
- CSR_WRITE_4(sc, TI_GCR_MAR1, (htons(m[1]) << 16) | htons(m[2]));
- TI_DO_CMD(TI_CMD_ADD_MCAST_ADDR, 0, 0);
- break;
- case TI_HWREV_TIGON_II:
- ext[0] = htons(m[0]);
- ext[1] = (htons(m[1]) << 16) | htons(m[2]);
- TI_DO_CMD_EXT(TI_CMD_EXT_ADD_MCAST, 0, 0, (caddr_t)&ext, 2);
- break;
- default:
- printf("ti%d: unknown hwrev\n", sc->ti_unit);
- break;
- }
-
- return;
-}
-
-void ti_del_mcast(sc, addr)
- struct ti_softc *sc;
- struct ether_addr *addr;
-{
- struct ti_cmd_desc cmd;
- u_int16_t *m;
- u_int32_t ext[2] = {0, 0};
-
- m = (u_int16_t *)&addr->octet[0];
-
- switch(sc->ti_hwrev) {
- case TI_HWREV_TIGON:
- CSR_WRITE_4(sc, TI_GCR_MAR0, htons(m[0]));
- CSR_WRITE_4(sc, TI_GCR_MAR1, (htons(m[1]) << 16) | htons(m[2]));
- TI_DO_CMD(TI_CMD_DEL_MCAST_ADDR, 0, 0);
- break;
- case TI_HWREV_TIGON_II:
- ext[0] = htons(m[0]);
- ext[1] = (htons(m[1]) << 16) | htons(m[2]);
- TI_DO_CMD_EXT(TI_CMD_EXT_DEL_MCAST, 0, 0, (caddr_t)&ext, 2);
- break;
- default:
- printf("ti%d: unknown hwrev\n", sc->ti_unit);
- break;
- }
-
- return;
-}
-
-/*
- * Configure the Tigon's multicast address filter.
- *
- * The actual multicast table management is a bit of a pain, thanks to
- * slight brain damage on the part of both Alteon and us. With our
- * multicast code, we are only alerted when the multicast address table
- * changes and at that point we only have the current list of addresses:
- * we only know the current state, not the previous state, so we don't
- * actually know what addresses were removed or added. The firmware has
- * state, but we can't get our grubby mits on it, and there is no 'delete
- * all multicast addresses' command. Hence, we have to maintain our own
- * state so we know what addresses have been programmed into the NIC at
- * any given time.
- */
-static void ti_setmulti(sc)
- struct ti_softc *sc;
-{
- struct ifnet *ifp;
- struct ifmultiaddr *ifma;
- struct ti_cmd_desc cmd;
- struct ti_mc_entry *mc;
- u_int32_t intrs;
-
- ifp = &sc->arpcom.ac_if;
-
- if (ifp->if_flags & IFF_ALLMULTI) {
- TI_DO_CMD(TI_CMD_SET_ALLMULTI, TI_CMD_CODE_ALLMULTI_ENB, 0);
- return;
- } else {
- TI_DO_CMD(TI_CMD_SET_ALLMULTI, TI_CMD_CODE_ALLMULTI_DIS, 0);
- }
-
- /* Disable interrupts. */
- intrs = CSR_READ_4(sc, TI_MB_HOSTINTR);
- CSR_WRITE_4(sc, TI_MB_HOSTINTR, 1);
-
- /* First, zot all the existing filters. */
- while (sc->ti_mc_listhead.slh_first != NULL) {
- mc = sc->ti_mc_listhead.slh_first;
- ti_del_mcast(sc, &mc->mc_addr);
- SLIST_REMOVE_HEAD(&sc->ti_mc_listhead, mc_entries);
- free(mc, M_DEVBUF);
- }
-
- /* Now program new ones. */
- for (ifma = ifp->if_multiaddrs.lh_first;
- ifma != NULL; ifma = ifma->ifma_link.le_next) {
- if (ifma->ifma_addr->sa_family != AF_LINK)
- continue;
- mc = malloc(sizeof(struct ti_mc_entry), M_DEVBUF, M_NOWAIT);
- bcopy(LLADDR((struct sockaddr_dl *)ifma->ifma_addr),
- (char *)&mc->mc_addr, ETHER_ADDR_LEN);
- SLIST_INSERT_HEAD(&sc->ti_mc_listhead, mc, mc_entries);
- ti_add_mcast(sc, &mc->mc_addr);
- }
-
- /* Re-enable interrupts. */
- CSR_WRITE_4(sc, TI_MB_HOSTINTR, intrs);
-
- return;
-}
-
-/*
- * Check to see if the BIOS has configured us for a 64 bit slot when
- * we aren't actually in one. If we detect this condition, we can work
- * around it on the Tigon 2 by setting a bit in the PCI state register,
- * but for the Tigon 1 we must give up and abort the interface attach.
- */
-static int ti_64bitslot_war(sc)
- struct ti_softc *sc;
-{
- if (!(CSR_READ_4(sc, TI_PCI_STATE) & TI_PCISTATE_32BIT_BUS)) {
- CSR_WRITE_4(sc, 0x600, 0);
- CSR_WRITE_4(sc, 0x604, 0);
- CSR_WRITE_4(sc, 0x600, 0x5555AAAA);
- if (CSR_READ_4(sc, 0x604) == 0x5555AAAA) {
- if (sc->ti_hwrev == TI_HWREV_TIGON)
- return(EINVAL);
- else {
- TI_SETBIT(sc, TI_PCI_STATE,
- TI_PCISTATE_32BIT_BUS);
- return(0);
- }
- }
- }
-
- return(0);
-}
-
-/*
- * Do endian, PCI and DMA initialization. Also check the on-board ROM
- * self-test results.
- */
-static int ti_chipinit(sc)
- struct ti_softc *sc;
-{
- u_int32_t cacheline;
- u_int32_t pci_writemax = 0;
-
- /* Initialize link to down state. */
- sc->ti_linkstat = TI_EV_CODE_LINK_DOWN;
-
- /* Set endianness before we access any non-PCI registers. */
-#if BYTE_ORDER == BIG_ENDIAN
- CSR_WRITE_4(sc, TI_MISC_HOST_CTL,
- TI_MHC_BIGENDIAN_INIT | (TI_MHC_BIGENDIAN_INIT << 24));
-#else
- CSR_WRITE_4(sc, TI_MISC_HOST_CTL,
- TI_MHC_LITTLEENDIAN_INIT | (TI_MHC_LITTLEENDIAN_INIT << 24));
-#endif
-
- /* Check the ROM failed bit to see if self-tests passed. */
- if (CSR_READ_4(sc, TI_CPU_STATE) & TI_CPUSTATE_ROMFAIL) {
- printf("ti%d: board self-diagnostics failed!\n", sc->ti_unit);
- return(ENODEV);
- }
-
- /* Halt the CPU. */
- TI_SETBIT(sc, TI_CPU_STATE, TI_CPUSTATE_HALT);
-
- /* Figure out the hardware revision. */
- switch(CSR_READ_4(sc, TI_MISC_HOST_CTL) & TI_MHC_CHIP_REV_MASK) {
- case TI_REV_TIGON_I:
- sc->ti_hwrev = TI_HWREV_TIGON;
- break;
- case TI_REV_TIGON_II:
- sc->ti_hwrev = TI_HWREV_TIGON_II;
- break;
- default:
- printf("ti%d: unsupported chip revision\n", sc->ti_unit);
- return(ENODEV);
- }
-
- /* Do special setup for Tigon 2. */
- if (sc->ti_hwrev == TI_HWREV_TIGON_II) {
- TI_SETBIT(sc, TI_CPU_CTL_B, TI_CPUSTATE_HALT);
- TI_SETBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_SRAM_BANK_256K);
- TI_SETBIT(sc, TI_MISC_CONF, TI_MCR_SRAM_SYNCHRONOUS);
- }
-
- /* Set up the PCI state register. */
- CSR_WRITE_4(sc, TI_PCI_STATE, TI_PCI_READ_CMD|TI_PCI_WRITE_CMD);
- if (sc->ti_hwrev == TI_HWREV_TIGON_II) {
- TI_SETBIT(sc, TI_PCI_STATE, TI_PCISTATE_USE_MEM_RD_MULT);
- }
-
- /* Clear the read/write max DMA parameters. */
- TI_CLRBIT(sc, TI_PCI_STATE, (TI_PCISTATE_WRITE_MAXDMA|
- TI_PCISTATE_READ_MAXDMA));
-
- /* Get cache line size. */
- cacheline = CSR_READ_4(sc, TI_PCI_BIST) & 0xFF;
-
- /*
- * If the system has set enabled the PCI memory write
- * and invalidate command in the command register, set
- * the write max parameter accordingly. This is necessary
- * to use MWI with the Tigon 2.
- */
- if (CSR_READ_4(sc, TI_PCI_CMDSTAT) & PCIM_CMD_MWIEN) {
- switch(cacheline) {
- case 1:
- case 4:
- case 8:
- case 16:
- case 32:
- case 64:
- break;
- default:
- /* Disable PCI memory write and invalidate. */
- if (bootverbose)
- printf("ti%d: cache line size %d not "
- "supported; disabling PCI MWI\n",
- sc->ti_unit, cacheline);
- CSR_WRITE_4(sc, TI_PCI_CMDSTAT, CSR_READ_4(sc,
- TI_PCI_CMDSTAT) & ~PCIM_CMD_MWIEN);
- break;
- }
- }
-
-#ifdef __brokenalpha__
- /*
- * From the Alteon sample driver:
- * Must insure that we do not cross an 8K (bytes) boundary
- * for DMA reads. Our highest limit is 1K bytes. This is a
- * restriction on some ALPHA platforms with early revision
- * 21174 PCI chipsets, such as the AlphaPC 164lx
- */
- TI_SETBIT(sc, TI_PCI_STATE, pci_writemax|TI_PCI_READMAX_1024);
-#else
- TI_SETBIT(sc, TI_PCI_STATE, pci_writemax);
-#endif
-
- /* This sets the min dma param all the way up (0xff). */
- TI_SETBIT(sc, TI_PCI_STATE, TI_PCISTATE_MINDMA);
-
- /* Configure DMA variables. */
-#if BYTE_ORDER == BIG_ENDIAN
- CSR_WRITE_4(sc, TI_GCR_OPMODE, TI_OPMODE_BYTESWAP_BD |
- TI_OPMODE_BYTESWAP_DATA | TI_OPMODE_WORDSWAP_BD |
- TI_OPMODE_WARN_ENB | TI_OPMODE_FATAL_ENB |
- TI_OPMODE_DONT_FRAG_JUMBO);
-#else
- CSR_WRITE_4(sc, TI_GCR_OPMODE, TI_OPMODE_BYTESWAP_DATA|
- TI_OPMODE_WORDSWAP_BD|TI_OPMODE_DONT_FRAG_JUMBO|
- TI_OPMODE_WARN_ENB|TI_OPMODE_FATAL_ENB);
-#endif
-
- /*
- * Only allow 1 DMA channel to be active at a time.
- * I don't think this is a good idea, but without it
- * the firmware racks up lots of nicDmaReadRingFull
- * errors.
- */
-#ifndef TI_CSUM_OFFLOAD
- TI_SETBIT(sc, TI_GCR_OPMODE, TI_OPMODE_1_DMA_ACTIVE);
-#endif
-
- /* Recommended settings from Tigon manual. */
- CSR_WRITE_4(sc, TI_GCR_DMA_WRITECFG, TI_DMA_STATE_THRESH_8W);
- CSR_WRITE_4(sc, TI_GCR_DMA_READCFG, TI_DMA_STATE_THRESH_8W);
-
- if (ti_64bitslot_war(sc)) {
- printf("ti%d: bios thinks we're in a 64 bit slot, "
- "but we aren't", sc->ti_unit);
- return(EINVAL);
- }
-
- return(0);
-}
-
-/*
- * Initialize the general information block and firmware, and
- * start the CPU(s) running.
- */
-static int ti_gibinit(sc)
- struct ti_softc *sc;
-{
- struct ti_rcb *rcb;
- int i;
- struct ifnet *ifp;
-
- ifp = &sc->arpcom.ac_if;
-
- /* Disable interrupts for now. */
- CSR_WRITE_4(sc, TI_MB_HOSTINTR, 1);
-
- /* Tell the chip where to find the general information block. */
- CSR_WRITE_4(sc, TI_GCR_GENINFO_HI, 0);
- CSR_WRITE_4(sc, TI_GCR_GENINFO_LO, vtophys(&sc->ti_rdata->ti_info));
-
- /* Load the firmware into SRAM. */
- ti_loadfw(sc);
-
- /* Set up the contents of the general info and ring control blocks. */
-
- /* Set up the event ring and producer pointer. */
- rcb = &sc->ti_rdata->ti_info.ti_ev_rcb;
-
- TI_HOSTADDR(rcb->ti_hostaddr) = vtophys(&sc->ti_rdata->ti_event_ring);
- rcb->ti_flags = 0;
- TI_HOSTADDR(sc->ti_rdata->ti_info.ti_ev_prodidx_ptr) =
- vtophys(&sc->ti_ev_prodidx);
- sc->ti_ev_prodidx.ti_idx = 0;
- CSR_WRITE_4(sc, TI_GCR_EVENTCONS_IDX, 0);
- sc->ti_ev_saved_considx = 0;
-
- /* Set up the command ring and producer mailbox. */
- rcb = &sc->ti_rdata->ti_info.ti_cmd_rcb;
-
- sc->ti_rdata->ti_cmd_ring =
- (struct ti_cmd_desc *)(sc->ti_vhandle + TI_GCR_CMDRING);
- TI_HOSTADDR(rcb->ti_hostaddr) = TI_GCR_NIC_ADDR(TI_GCR_CMDRING);
- rcb->ti_flags = 0;
- rcb->ti_max_len = 0;
- for (i = 0; i < TI_CMD_RING_CNT; i++) {
- CSR_WRITE_4(sc, TI_GCR_CMDRING + (i * 4), 0);
- }
- CSR_WRITE_4(sc, TI_GCR_CMDCONS_IDX, 0);
- CSR_WRITE_4(sc, TI_MB_CMDPROD_IDX, 0);
- sc->ti_cmd_saved_prodidx = 0;
-
- /*
- * Assign the address of the stats refresh buffer.
- * We re-use the current stats buffer for this to
- * conserve memory.
- */
- TI_HOSTADDR(sc->ti_rdata->ti_info.ti_refresh_stats_ptr) =
- vtophys(&sc->ti_rdata->ti_info.ti_stats);
-
- /* Set up the standard receive ring. */
- rcb = &sc->ti_rdata->ti_info.ti_std_rx_rcb;
- TI_HOSTADDR(rcb->ti_hostaddr) = vtophys(&sc->ti_rdata->ti_rx_std_ring);
- rcb->ti_max_len = TI_FRAMELEN;
- rcb->ti_flags = 0;
-#ifdef TI_CSUM_OFFLOAD
- rcb->ti_flags |= TI_RCB_FLAG_TCP_UDP_CKSUM|TI_RCB_FLAG_IP_CKSUM;
-#endif
-#if NVLAN > 0
- rcb->ti_flags |= TI_RCB_FLAG_VLAN_ASSIST;
-#endif
-
- /* Set up the jumbo receive ring. */
- rcb = &sc->ti_rdata->ti_info.ti_jumbo_rx_rcb;
- TI_HOSTADDR(rcb->ti_hostaddr) =
- vtophys(&sc->ti_rdata->ti_rx_jumbo_ring);
- rcb->ti_max_len = TI_JUMBO_FRAMELEN;
- rcb->ti_flags = 0;
-#ifdef TI_CSUM_OFFLOAD
- rcb->ti_flags |= TI_RCB_FLAG_TCP_UDP_CKSUM|TI_RCB_FLAG_IP_CKSUM;
-#endif
-#if NVLAN > 0
- rcb->ti_flags |= TI_RCB_FLAG_VLAN_ASSIST;
-#endif
-
- /*
- * Set up the mini ring. Only activated on the
- * Tigon 2 but the slot in the config block is
- * still there on the Tigon 1.
- */
- rcb = &sc->ti_rdata->ti_info.ti_mini_rx_rcb;
- TI_HOSTADDR(rcb->ti_hostaddr) =
- vtophys(&sc->ti_rdata->ti_rx_mini_ring);
- rcb->ti_max_len = MHLEN - ETHER_ALIGN;
- if (sc->ti_hwrev == TI_HWREV_TIGON)
- rcb->ti_flags = TI_RCB_FLAG_RING_DISABLED;
- else
- rcb->ti_flags = 0;
-#ifdef TI_CSUM_OFFLOAD
- rcb->ti_flags |= TI_RCB_FLAG_TCP_UDP_CKSUM|TI_RCB_FLAG_IP_CKSUM;
-#endif
-#if NVLAN > 0
- rcb->ti_flags |= TI_RCB_FLAG_VLAN_ASSIST;
-#endif
-
- /*
- * Set up the receive return ring.
- */
- rcb = &sc->ti_rdata->ti_info.ti_return_rcb;
- TI_HOSTADDR(rcb->ti_hostaddr) =
- vtophys(&sc->ti_rdata->ti_rx_return_ring);
- rcb->ti_flags = 0;
- rcb->ti_max_len = TI_RETURN_RING_CNT;
- TI_HOSTADDR(sc->ti_rdata->ti_info.ti_return_prodidx_ptr) =
- vtophys(&sc->ti_return_prodidx);
-
- /*
- * Set up the tx ring. Note: for the Tigon 2, we have the option
- * of putting the transmit ring in the host's address space and
- * letting the chip DMA it instead of leaving the ring in the NIC's
- * memory and accessing it through the shared memory region. We
- * do this for the Tigon 2, but it doesn't work on the Tigon 1,
- * so we have to revert to the shared memory scheme if we detect
- * a Tigon 1 chip.
- */
- CSR_WRITE_4(sc, TI_WINBASE, TI_TX_RING_BASE);
- if (sc->ti_hwrev == TI_HWREV_TIGON) {
- sc->ti_rdata->ti_tx_ring_nic =
- (struct ti_tx_desc *)(sc->ti_vhandle + TI_WINDOW);
- }
- bzero((char *)sc->ti_rdata->ti_tx_ring,
- TI_TX_RING_CNT * sizeof(struct ti_tx_desc));
- rcb = &sc->ti_rdata->ti_info.ti_tx_rcb;
- if (sc->ti_hwrev == TI_HWREV_TIGON)
- rcb->ti_flags = 0;
- else
- rcb->ti_flags = TI_RCB_FLAG_HOST_RING;
-#if NVLAN > 0
- rcb->ti_flags |= TI_RCB_FLAG_VLAN_ASSIST;
-#endif
- rcb->ti_max_len = TI_TX_RING_CNT;
- if (sc->ti_hwrev == TI_HWREV_TIGON)
- TI_HOSTADDR(rcb->ti_hostaddr) = TI_TX_RING_BASE;
- else
- TI_HOSTADDR(rcb->ti_hostaddr) =
- vtophys(&sc->ti_rdata->ti_tx_ring);
- TI_HOSTADDR(sc->ti_rdata->ti_info.ti_tx_considx_ptr) =
- vtophys(&sc->ti_tx_considx);
-
- /* Set up tuneables */
- if (ifp->if_mtu > (ETHERMTU + ETHER_HDR_LEN + ETHER_CRC_LEN))
- CSR_WRITE_4(sc, TI_GCR_RX_COAL_TICKS,
- (sc->ti_rx_coal_ticks / 10));
- else
- CSR_WRITE_4(sc, TI_GCR_RX_COAL_TICKS, sc->ti_rx_coal_ticks);
- CSR_WRITE_4(sc, TI_GCR_TX_COAL_TICKS, sc->ti_tx_coal_ticks);
- CSR_WRITE_4(sc, TI_GCR_STAT_TICKS, sc->ti_stat_ticks);
- CSR_WRITE_4(sc, TI_GCR_RX_MAX_COAL_BD, sc->ti_rx_max_coal_bds);
- CSR_WRITE_4(sc, TI_GCR_TX_MAX_COAL_BD, sc->ti_tx_max_coal_bds);
- CSR_WRITE_4(sc, TI_GCR_TX_BUFFER_RATIO, sc->ti_tx_buf_ratio);
-
- /* Turn interrupts on. */
- CSR_WRITE_4(sc, TI_GCR_MASK_INTRS, 0);
- CSR_WRITE_4(sc, TI_MB_HOSTINTR, 0);
-
- /* Start CPU. */
- TI_CLRBIT(sc, TI_CPU_STATE, (TI_CPUSTATE_HALT|TI_CPUSTATE_STEP));
-
- return(0);
-}
-
-/*
- * Probe for a Tigon chip. Check the PCI vendor and device IDs
- * against our list and return its name if we find a match.
- */
-static int ti_probe(dev)
- device_t dev;
-{
- struct ti_type *t;
-
- t = ti_devs;
-
- while(t->ti_name != NULL) {
- if ((pci_get_vendor(dev) == t->ti_vid) &&
- (pci_get_device(dev) == t->ti_did)) {
- device_set_desc(dev, t->ti_name);
- return(0);
- }
- t++;
- }
-
- return(ENXIO);
-}
-
-static int ti_attach(dev)
- device_t dev;
-{
- int s;
- u_int32_t command;
- struct ifnet *ifp;
- struct ti_softc *sc;
- int unit, error = 0, rid;
-
- s = splimp();
-
- sc = device_get_softc(dev);
- unit = device_get_unit(dev);
- bzero(sc, sizeof(struct ti_softc));
-
- /*
- * Map control/status registers.
- */
- command = pci_read_config(dev, PCI_COMMAND_STATUS_REG, 4);
- command |= (PCIM_CMD_MEMEN|PCIM_CMD_BUSMASTEREN);
- pci_write_config(dev, PCI_COMMAND_STATUS_REG, command, 4);
- command = pci_read_config(dev, PCI_COMMAND_STATUS_REG, 4);
-
- if (!(command & PCIM_CMD_MEMEN)) {
- printf("ti%d: failed to enable memory mapping!\n", unit);
- error = ENXIO;
- goto fail;
- }
-
- rid = TI_PCI_LOMEM;
- sc->ti_res = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid,
- 0, ~0, 1, RF_ACTIVE);
-
- if (sc->ti_res == NULL) {
- printf ("ti%d: couldn't map memory\n", unit);
- error = ENXIO;
- goto fail;
- }
-
- sc->ti_btag = rman_get_bustag(sc->ti_res);
- sc->ti_bhandle = rman_get_bushandle(sc->ti_res);
- sc->ti_vhandle = (vm_offset_t)rman_get_virtual(sc->ti_res);
-
- /*
- * XXX FIXME: rman_get_virtual() on the alpha is currently
- * broken and returns a physical address instead of a kernel
- * virtual address. Consequently, we need to do a little
- * extra mangling of the vhandle on the alpha. This should
- * eventually be fixed! The whole idea here is to get rid
- * of platform dependencies.
- */
-#ifdef __alpha__
- if (pci_cvt_to_bwx(sc->ti_vhandle))
- sc->ti_vhandle = pci_cvt_to_bwx(sc->ti_vhandle);
- else
- sc->ti_vhandle = pci_cvt_to_dense(sc->ti_vhandle);
- sc->ti_vhandle = ALPHA_PHYS_TO_K0SEG(sc->ti_vhandle);
-#endif
-
- /* Allocate interrupt */
- rid = 0;
-
- sc->ti_irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1,
- RF_SHAREABLE | RF_ACTIVE);
-
- if (sc->ti_irq == NULL) {
- printf("ti%d: couldn't map interrupt\n", unit);
- error = ENXIO;
- goto fail;
- }
-
- error = bus_setup_intr(dev, sc->ti_irq, INTR_TYPE_NET,
- ti_intr, sc, &sc->ti_intrhand);
-
- if (error) {
- bus_release_resource(dev, SYS_RES_IRQ, 0, sc->ti_irq);
- bus_release_resource(dev, SYS_RES_MEMORY,
- TI_PCI_LOMEM, sc->ti_res);
- printf("ti%d: couldn't set up irq\n", unit);
- goto fail;
- }
-
- sc->ti_unit = unit;
-
- if (ti_chipinit(sc)) {
- printf("ti%d: chip initialization failed\n", sc->ti_unit);
- bus_teardown_intr(dev, sc->ti_irq, sc->ti_intrhand);
- bus_release_resource(dev, SYS_RES_IRQ, 0, sc->ti_irq);
- bus_release_resource(dev, SYS_RES_MEMORY,
- TI_PCI_LOMEM, sc->ti_res);
- error = ENXIO;
- goto fail;
- }
-
- /* Zero out the NIC's on-board SRAM. */
- ti_mem(sc, 0x2000, 0x100000 - 0x2000, NULL);
-
- /* Init again -- zeroing memory may have clobbered some registers. */
- if (ti_chipinit(sc)) {
- printf("ti%d: chip initialization failed\n", sc->ti_unit);
- bus_teardown_intr(dev, sc->ti_irq, sc->ti_intrhand);
- bus_release_resource(dev, SYS_RES_IRQ, 0, sc->ti_irq);
- bus_release_resource(dev, SYS_RES_MEMORY,
- TI_PCI_LOMEM, sc->ti_res);
- error = ENXIO;
- goto fail;
- }
-
- /*
- * Get station address from the EEPROM. Note: the manual states
- * that the MAC address is at offset 0x8c, however the data is
- * stored as two longwords (since that's how it's loaded into
- * the NIC). This means the MAC address is actually preceeded
- * by two zero bytes. We need to skip over those.
- */
- if (ti_read_eeprom(sc, (caddr_t)&sc->arpcom.ac_enaddr,
- TI_EE_MAC_OFFSET + 2, ETHER_ADDR_LEN)) {
- printf("ti%d: failed to read station address\n", unit);
- bus_teardown_intr(dev, sc->ti_irq, sc->ti_intrhand);
- bus_release_resource(dev, SYS_RES_IRQ, 0, sc->ti_irq);
- bus_release_resource(dev, SYS_RES_MEMORY,
- TI_PCI_LOMEM, sc->ti_res);
- error = ENXIO;
- goto fail;
- }
-
- /*
- * A Tigon chip was detected. Inform the world.
- */
- printf("ti%d: Ethernet address: %6D\n", unit,
- sc->arpcom.ac_enaddr, ":");
-
- /* Allocate the general information block and ring buffers. */
- sc->ti_rdata = contigmalloc(sizeof(struct ti_ring_data), M_DEVBUF,
- M_NOWAIT, 0, 0xffffffff, PAGE_SIZE, 0);
-
- if (sc->ti_rdata == NULL) {
- bus_teardown_intr(dev, sc->ti_irq, sc->ti_intrhand);
- bus_release_resource(dev, SYS_RES_IRQ, 0, sc->ti_irq);
- bus_release_resource(dev, SYS_RES_MEMORY,
- TI_PCI_LOMEM, sc->ti_res);
- error = ENXIO;
- printf("ti%d: no memory for list buffers!\n", sc->ti_unit);
- goto fail;
- }
-
- bzero(sc->ti_rdata, sizeof(struct ti_ring_data));
-
- /* Try to allocate memory for jumbo buffers. */
- if (ti_alloc_jumbo_mem(sc)) {
- printf("ti%d: jumbo buffer allocation failed\n", sc->ti_unit);
- bus_teardown_intr(dev, sc->ti_irq, sc->ti_intrhand);
- bus_release_resource(dev, SYS_RES_IRQ, 0, sc->ti_irq);
- bus_release_resource(dev, SYS_RES_MEMORY,
- TI_PCI_LOMEM, sc->ti_res);
- free(sc->ti_rdata, M_DEVBUF);
- error = ENXIO;
- goto fail;
- }
-
- /* Set default tuneable values. */
- sc->ti_stat_ticks = 2 * TI_TICKS_PER_SEC;
- sc->ti_rx_coal_ticks = TI_TICKS_PER_SEC / 5000;
- sc->ti_tx_coal_ticks = TI_TICKS_PER_SEC / 500;
- sc->ti_rx_max_coal_bds = 64;
- sc->ti_tx_max_coal_bds = 128;
- sc->ti_tx_buf_ratio = 21;
-
- /* Set up ifnet structure */
- ifp = &sc->arpcom.ac_if;
- ifp->if_softc = sc;
- ifp->if_unit = sc->ti_unit;
- ifp->if_name = "ti";
- ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
- ifp->if_ioctl = ti_ioctl;
- ifp->if_output = ether_output;
- ifp->if_start = ti_start;
- ifp->if_watchdog = ti_watchdog;
- ifp->if_init = ti_init;
- ifp->if_mtu = ETHERMTU;
- ifp->if_snd.ifq_maxlen = TI_TX_RING_CNT - 1;
-
- /* Set up ifmedia support. */
- ifmedia_init(&sc->ifmedia, IFM_IMASK, ti_ifmedia_upd, ti_ifmedia_sts);
- ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_10_FL, 0, NULL);
- ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_10_FL|IFM_FDX, 0, NULL);
- ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_100_FX, 0, NULL);
- ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_100_FX|IFM_FDX, 0, NULL);
- ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_1000_SX, 0, NULL);
- ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_1000_SX|IFM_FDX, 0, NULL);
- ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_AUTO, 0, NULL);
- ifmedia_set(&sc->ifmedia, IFM_ETHER|IFM_AUTO);
-
- /*
- * Call MI attach routines.
- */
- if_attach(ifp);
- ether_ifattach(ifp);
-
- bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
-
-fail:
- splx(s);
-
- return(error);
-}
-
-static int ti_detach(dev)
- device_t dev;
-{
- struct ti_softc *sc;
- struct ifnet *ifp;
- int s;
-
- s = splimp();
-
- sc = device_get_softc(dev);
- ifp = &sc->arpcom.ac_if;
-
- if_detach(ifp);
- ti_stop(sc);
-
- bus_teardown_intr(dev, sc->ti_irq, sc->ti_intrhand);
- bus_release_resource(dev, SYS_RES_IRQ, 0, sc->ti_irq);
- bus_release_resource(dev, SYS_RES_MEMORY, TI_PCI_LOMEM, sc->ti_res);
-
- free(sc->ti_cdata.ti_jumbo_buf, M_DEVBUF);
- free(sc->ti_rdata, M_DEVBUF);
- ifmedia_removeall(&sc->ifmedia);
-
- splx(s);
-
- return(0);
-}
-
-/*
- * Frame reception handling. This is called if there's a frame
- * on the receive return list.
- *
- * Note: we have to be able to handle three possibilities here:
- * 1) the frame is from the mini receive ring (can only happen)
- * on Tigon 2 boards)
- * 2) the frame is from the jumbo recieve ring
- * 3) the frame is from the standard receive ring
- */
-
-static void ti_rxeof(sc)
- struct ti_softc *sc;
-{
- struct ifnet *ifp;
- struct ti_cmd_desc cmd;
-
- ifp = &sc->arpcom.ac_if;
-
- while(sc->ti_rx_saved_considx != sc->ti_return_prodidx.ti_idx) {
- struct ti_rx_desc *cur_rx;
- u_int32_t rxidx;
- struct ether_header *eh;
- struct mbuf *m = NULL;
-#if NVLAN > 0
- u_int16_t vlan_tag = 0;
- int have_tag = 0;
-#endif
-#ifdef TI_CSUM_OFFLOAD
- struct ip *ip;
-#endif
-
- cur_rx =
- &sc->ti_rdata->ti_rx_return_ring[sc->ti_rx_saved_considx];
- rxidx = cur_rx->ti_idx;
- TI_INC(sc->ti_rx_saved_considx, TI_RETURN_RING_CNT);
-
-#if NVLAN > 0
- if (cur_rx->ti_flags & TI_BDFLAG_VLAN_TAG) {
- have_tag = 1;
- vlan_tag = cur_rx->ti_vlan_tag;
- }
-#endif
-
- if (cur_rx->ti_flags & TI_BDFLAG_JUMBO_RING) {
- TI_INC(sc->ti_jumbo, TI_JUMBO_RX_RING_CNT);
- m = sc->ti_cdata.ti_rx_jumbo_chain[rxidx];
- sc->ti_cdata.ti_rx_jumbo_chain[rxidx] = NULL;
- if (cur_rx->ti_flags & TI_BDFLAG_ERROR) {
- ifp->if_ierrors++;
- ti_newbuf_jumbo(sc, sc->ti_jumbo, m);
- continue;
- }
- if (ti_newbuf_jumbo(sc, sc->ti_jumbo, NULL) == ENOBUFS) {
- ifp->if_ierrors++;
- ti_newbuf_jumbo(sc, sc->ti_jumbo, m);
- continue;
- }
- } else if (cur_rx->ti_flags & TI_BDFLAG_MINI_RING) {
- TI_INC(sc->ti_mini, TI_MINI_RX_RING_CNT);
- m = sc->ti_cdata.ti_rx_mini_chain[rxidx];
- sc->ti_cdata.ti_rx_mini_chain[rxidx] = NULL;
- if (cur_rx->ti_flags & TI_BDFLAG_ERROR) {
- ifp->if_ierrors++;
- ti_newbuf_mini(sc, sc->ti_mini, m);
- continue;
- }
- if (ti_newbuf_mini(sc, sc->ti_mini, NULL) == ENOBUFS) {
- ifp->if_ierrors++;
- ti_newbuf_mini(sc, sc->ti_mini, m);
- continue;
- }
- } else {
- TI_INC(sc->ti_std, TI_STD_RX_RING_CNT);
- m = sc->ti_cdata.ti_rx_std_chain[rxidx];
- sc->ti_cdata.ti_rx_std_chain[rxidx] = NULL;
- if (cur_rx->ti_flags & TI_BDFLAG_ERROR) {
- ifp->if_ierrors++;
- ti_newbuf_std(sc, sc->ti_std, m);
- continue;
- }
- if (ti_newbuf_std(sc, sc->ti_std, NULL) == ENOBUFS) {
- ifp->if_ierrors++;
- ti_newbuf_std(sc, sc->ti_std, m);
- continue;
- }
- }
-
- m->m_pkthdr.len = m->m_len = cur_rx->ti_len;
- ifp->if_ipackets++;
- eh = mtod(m, struct ether_header *);
- m->m_pkthdr.rcvif = ifp;
-
- /*
- * Handle BPF listeners. Let the BPF user see the packet, but
- * don't pass it up to the ether_input() layer unless it's
- * a broadcast packet, multicast packet, matches our ethernet
- * address or the interface is in promiscuous mode.
- */
- if (ifp->if_bpf) {
- bpf_mtap(ifp, m);
- if (ifp->if_flags & IFF_PROMISC &&
- (bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr,
- ETHER_ADDR_LEN) &&
- (eh->ether_dhost[0] & 1) == 0)) {
- m_freem(m);
- continue;
- }
- }
-
- /* Remove header from mbuf and pass it on. */
- m_adj(m, sizeof(struct ether_header));
-
-#ifdef TI_CSUM_OFFLOAD
- ip = mtod(m, struct ip *);
- if (!(cur_rx->ti_tcp_udp_cksum ^ 0xFFFF) &&
- !(ip->ip_off & htons(IP_MF | IP_OFFMASK | IP_RF)))
- m->m_flags |= M_HWCKSUM;
-#endif
-
-#if NVLAN > 0
- /*
- * If we received a packet with a vlan tag, pass it
- * to vlan_input() instead of ether_input().
- */
- if (have_tag) {
- vlan_input_tag(eh, m, vlan_tag);
- have_tag = vlan_tag = 0;
- continue;
- }
-#endif
- ether_input(ifp, eh, m);
- }
-
- /* Only necessary on the Tigon 1. */
- if (sc->ti_hwrev == TI_HWREV_TIGON)
- CSR_WRITE_4(sc, TI_GCR_RXRETURNCONS_IDX,
- sc->ti_rx_saved_considx);
-
- TI_UPDATE_STDPROD(sc, sc->ti_std);
- TI_UPDATE_MINIPROD(sc, sc->ti_mini);
- TI_UPDATE_JUMBOPROD(sc, sc->ti_jumbo);
-
- return;
-}
-
-static void ti_txeof(sc)
- struct ti_softc *sc;
-{
- struct ti_tx_desc *cur_tx = NULL;
- struct ifnet *ifp;
-
- ifp = &sc->arpcom.ac_if;
-
- /*
- * Go through our tx ring and free mbufs for those
- * frames that have been sent.
- */
- while (sc->ti_tx_saved_considx != sc->ti_tx_considx.ti_idx) {
- u_int32_t idx = 0;
-
- idx = sc->ti_tx_saved_considx;
- if (sc->ti_hwrev == TI_HWREV_TIGON) {
- if (idx > 383)
- CSR_WRITE_4(sc, TI_WINBASE,
- TI_TX_RING_BASE + 6144);
- else if (idx > 255)
- CSR_WRITE_4(sc, TI_WINBASE,
- TI_TX_RING_BASE + 4096);
- else if (idx > 127)
- CSR_WRITE_4(sc, TI_WINBASE,
- TI_TX_RING_BASE + 2048);
- else
- CSR_WRITE_4(sc, TI_WINBASE,
- TI_TX_RING_BASE);
- cur_tx = &sc->ti_rdata->ti_tx_ring_nic[idx % 128];
- } else
- cur_tx = &sc->ti_rdata->ti_tx_ring[idx];
- if (cur_tx->ti_flags & TI_BDFLAG_END)
- ifp->if_opackets++;
- if (sc->ti_cdata.ti_tx_chain[idx] != NULL) {
- m_freem(sc->ti_cdata.ti_tx_chain[idx]);
- sc->ti_cdata.ti_tx_chain[idx] = NULL;
- }
- sc->ti_txcnt--;
- TI_INC(sc->ti_tx_saved_considx, TI_TX_RING_CNT);
- ifp->if_timer = 0;
- }
-
- if (cur_tx != NULL)
- ifp->if_flags &= ~IFF_OACTIVE;
-
- return;
-}
-
-static void ti_intr(xsc)
- void *xsc;
-{
- struct ti_softc *sc;
- struct ifnet *ifp;
-
- sc = xsc;
- ifp = &sc->arpcom.ac_if;
-
-#ifdef notdef
- /* Avoid this for now -- checking this register is expensive. */
- /* Make sure this is really our interrupt. */
- if (!(CSR_READ_4(sc, TI_MISC_HOST_CTL) & TI_MHC_INTSTATE))
- return;
-#endif
-
- /* Ack interrupt and stop others from occuring. */
- CSR_WRITE_4(sc, TI_MB_HOSTINTR, 1);
-
- if (ifp->if_flags & IFF_RUNNING) {
- /* Check RX return ring producer/consumer */
- ti_rxeof(sc);
-
- /* Check TX ring producer/consumer */
- ti_txeof(sc);
- }
-
- ti_handle_events(sc);
-
- /* Re-enable interrupts. */
- CSR_WRITE_4(sc, TI_MB_HOSTINTR, 0);
-
- if (ifp->if_flags & IFF_RUNNING && ifp->if_snd.ifq_head != NULL)
- ti_start(ifp);
-
- return;
-}
-
-static void ti_stats_update(sc)
- struct ti_softc *sc;
-{
- struct ifnet *ifp;
-
- ifp = &sc->arpcom.ac_if;
-
- ifp->if_collisions +=
- (sc->ti_rdata->ti_info.ti_stats.dot3StatsSingleCollisionFrames +
- sc->ti_rdata->ti_info.ti_stats.dot3StatsMultipleCollisionFrames +
- sc->ti_rdata->ti_info.ti_stats.dot3StatsExcessiveCollisions +
- sc->ti_rdata->ti_info.ti_stats.dot3StatsLateCollisions) -
- ifp->if_collisions;
-
- return;
-}
-
-/*
- * Encapsulate an mbuf chain in the tx ring by coupling the mbuf data
- * pointers to descriptors.
- */
-static int ti_encap(sc, m_head, txidx)
- struct ti_softc *sc;
- struct mbuf *m_head;
- u_int32_t *txidx;
-{
- struct ti_tx_desc *f = NULL;
- struct mbuf *m;
- u_int32_t frag, cur, cnt = 0;
-#if NVLAN > 0
- struct ifvlan *ifv = NULL;
-
- if ((m_head->m_flags & (M_PROTO1|M_PKTHDR)) == (M_PROTO1|M_PKTHDR) &&
- m_head->m_pkthdr.rcvif != NULL &&
- m_head->m_pkthdr.rcvif->if_type == IFT_8021_VLAN)
- ifv = m_head->m_pkthdr.rcvif->if_softc;
-#endif
-
- m = m_head;
- cur = frag = *txidx;
-
- /*
- * Start packing the mbufs in this chain into
- * the fragment pointers. Stop when we run out
- * of fragments or hit the end of the mbuf chain.
- */
- for (m = m_head; m != NULL; m = m->m_next) {
- if (m->m_len != 0) {
- if (sc->ti_hwrev == TI_HWREV_TIGON) {
- if (frag > 383)
- CSR_WRITE_4(sc, TI_WINBASE,
- TI_TX_RING_BASE + 6144);
- else if (frag > 255)
- CSR_WRITE_4(sc, TI_WINBASE,
- TI_TX_RING_BASE + 4096);
- else if (frag > 127)
- CSR_WRITE_4(sc, TI_WINBASE,
- TI_TX_RING_BASE + 2048);
- else
- CSR_WRITE_4(sc, TI_WINBASE,
- TI_TX_RING_BASE);
- f = &sc->ti_rdata->ti_tx_ring_nic[frag % 128];
- } else
- f = &sc->ti_rdata->ti_tx_ring[frag];
- if (sc->ti_cdata.ti_tx_chain[frag] != NULL)
- break;
- TI_HOSTADDR(f->ti_addr) = vtophys(mtod(m, vm_offset_t));
- f->ti_len = m->m_len;
- f->ti_flags = 0;
-#if NVLAN > 0
- if (ifv != NULL) {
- f->ti_flags |= TI_BDFLAG_VLAN_TAG;
- f->ti_vlan_tag = ifv->ifv_tag;
- } else {
- f->ti_vlan_tag = 0;
- }
-#endif
- /*
- * Sanity check: avoid coming within 16 descriptors
- * of the end of the ring.
- */
- if ((TI_TX_RING_CNT - (sc->ti_txcnt + cnt)) < 16)
- return(ENOBUFS);
- cur = frag;
- TI_INC(frag, TI_TX_RING_CNT);
- cnt++;
- }
- }
-
- if (m != NULL)
- return(ENOBUFS);
-
- if (frag == sc->ti_tx_saved_considx)
- return(ENOBUFS);
-
- if (sc->ti_hwrev == TI_HWREV_TIGON)
- sc->ti_rdata->ti_tx_ring_nic[cur % 128].ti_flags |=
- TI_BDFLAG_END;
- else
- sc->ti_rdata->ti_tx_ring[cur].ti_flags |= TI_BDFLAG_END;
- sc->ti_cdata.ti_tx_chain[cur] = m_head;
- sc->ti_txcnt += cnt;
-
- *txidx = frag;
-
- return(0);
-}
-
-/*
- * Main transmit routine. To avoid having to do mbuf copies, we put pointers
- * to the mbuf data regions directly in the transmit descriptors.
- */
-static void ti_start(ifp)
- struct ifnet *ifp;
-{
- struct ti_softc *sc;
- struct mbuf *m_head = NULL;
- u_int32_t prodidx = 0;
-
- sc = ifp->if_softc;
-
- prodidx = CSR_READ_4(sc, TI_MB_SENDPROD_IDX);
-
- while(sc->ti_cdata.ti_tx_chain[prodidx] == NULL) {
- IF_DEQUEUE(&ifp->if_snd, m_head);
- if (m_head == NULL)
- break;
-
- /*
- * Pack the data into the transmit ring. If we
- * don't have room, set the OACTIVE flag and wait
- * for the NIC to drain the ring.
- */
- if (ti_encap(sc, m_head, &prodidx)) {
- IF_PREPEND(&ifp->if_snd, m_head);
- ifp->if_flags |= IFF_OACTIVE;
- break;
- }
-
- /*
- * If there's a BPF listener, bounce a copy of this frame
- * to him.
- */
- if (ifp->if_bpf)
- bpf_mtap(ifp, m_head);
- }
-
- /* Transmit */
- CSR_WRITE_4(sc, TI_MB_SENDPROD_IDX, prodidx);
-
- /*
- * Set a timeout in case the chip goes out to lunch.
- */
- ifp->if_timer = 5;
-
- return;
-}
-
-static void ti_init(xsc)
- void *xsc;
-{
- struct ti_softc *sc = xsc;
- int s;
-
- s = splimp();
-
- /* Cancel pending I/O and flush buffers. */
- ti_stop(sc);
-
- /* Init the gen info block, ring control blocks and firmware. */
- if (ti_gibinit(sc)) {
- printf("ti%d: initialization failure\n", sc->ti_unit);
- splx(s);
- return;
- }
-
- splx(s);
-
- return;
-}
-
-static void ti_init2(sc)
- struct ti_softc *sc;
-{
- struct ti_cmd_desc cmd;
- struct ifnet *ifp;
- u_int16_t *m;
- struct ifmedia *ifm;
- int tmp;
-
- ifp = &sc->arpcom.ac_if;
-
- /* Specify MTU and interface index. */
- CSR_WRITE_4(sc, TI_GCR_IFINDEX, ifp->if_unit);
- CSR_WRITE_4(sc, TI_GCR_IFMTU, ifp->if_mtu +
- ETHER_HDR_LEN + ETHER_CRC_LEN);
- TI_DO_CMD(TI_CMD_UPDATE_GENCOM, 0, 0);
-
- /* Load our MAC address. */
- m = (u_int16_t *)&sc->arpcom.ac_enaddr[0];
- CSR_WRITE_4(sc, TI_GCR_PAR0, htons(m[0]));
- CSR_WRITE_4(sc, TI_GCR_PAR1, (htons(m[1]) << 16) | htons(m[2]));
- TI_DO_CMD(TI_CMD_SET_MAC_ADDR, 0, 0);
-
- /* Enable or disable promiscuous mode as needed. */
- if (ifp->if_flags & IFF_PROMISC) {
- TI_DO_CMD(TI_CMD_SET_PROMISC_MODE, TI_CMD_CODE_PROMISC_ENB, 0);
- } else {
- TI_DO_CMD(TI_CMD_SET_PROMISC_MODE, TI_CMD_CODE_PROMISC_DIS, 0);
- }
-
- /* Program multicast filter. */
- ti_setmulti(sc);
-
- /*
- * If this is a Tigon 1, we should tell the
- * firmware to use software packet filtering.
- */
- if (sc->ti_hwrev == TI_HWREV_TIGON) {
- TI_DO_CMD(TI_CMD_FDR_FILTERING, TI_CMD_CODE_FILT_ENB, 0);
- }
-
- /* Init RX ring. */
- ti_init_rx_ring_std(sc);
-
- /* Init jumbo RX ring. */
- if (ifp->if_mtu > (ETHERMTU + ETHER_HDR_LEN + ETHER_CRC_LEN))
- ti_init_rx_ring_jumbo(sc);
-
- /*
- * If this is a Tigon 2, we can also configure the
- * mini ring.
- */
- if (sc->ti_hwrev == TI_HWREV_TIGON_II)
- ti_init_rx_ring_mini(sc);
-
- CSR_WRITE_4(sc, TI_GCR_RXRETURNCONS_IDX, 0);
- sc->ti_rx_saved_considx = 0;
-
- /* Init TX ring. */
- ti_init_tx_ring(sc);
-
- /* Tell firmware we're alive. */
- TI_DO_CMD(TI_CMD_HOST_STATE, TI_CMD_CODE_STACK_UP, 0);
-
- /* Enable host interrupts. */
- CSR_WRITE_4(sc, TI_MB_HOSTINTR, 0);
-
- ifp->if_flags |= IFF_RUNNING;
- ifp->if_flags &= ~IFF_OACTIVE;
-
- /*
- * Make sure to set media properly. We have to do this
- * here since we have to issue commands in order to set
- * the link negotiation and we can't issue commands until
- * the firmware is running.
- */
- ifm = &sc->ifmedia;
- tmp = ifm->ifm_media;
- ifm->ifm_media = ifm->ifm_cur->ifm_media;
- ti_ifmedia_upd(ifp);
- ifm->ifm_media = tmp;
-
- return;
-}
-
-/*
- * Set media options.
- */
-static int ti_ifmedia_upd(ifp)
- struct ifnet *ifp;
-{
- struct ti_softc *sc;
- struct ifmedia *ifm;
- struct ti_cmd_desc cmd;
-
- sc = ifp->if_softc;
- ifm = &sc->ifmedia;
-
- if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER)
- return(EINVAL);
-
- switch(IFM_SUBTYPE(ifm->ifm_media)) {
- case IFM_AUTO:
- CSR_WRITE_4(sc, TI_GCR_GLINK, TI_GLNK_PREF|TI_GLNK_1000MB|
- TI_GLNK_FULL_DUPLEX|TI_GLNK_RX_FLOWCTL_Y|
- TI_GLNK_AUTONEGENB|TI_GLNK_ENB);
- CSR_WRITE_4(sc, TI_GCR_LINK, TI_LNK_100MB|TI_LNK_10MB|
- TI_LNK_FULL_DUPLEX|TI_LNK_HALF_DUPLEX|
- TI_LNK_AUTONEGENB|TI_LNK_ENB);
- TI_DO_CMD(TI_CMD_LINK_NEGOTIATION,
- TI_CMD_CODE_NEGOTIATE_BOTH, 0);
- break;
- case IFM_1000_SX:
- CSR_WRITE_4(sc, TI_GCR_GLINK, TI_GLNK_PREF|TI_GLNK_1000MB|
- TI_GLNK_FULL_DUPLEX|TI_GLNK_RX_FLOWCTL_Y|TI_GLNK_ENB);
- CSR_WRITE_4(sc, TI_GCR_LINK, 0);
- TI_DO_CMD(TI_CMD_LINK_NEGOTIATION,
- TI_CMD_CODE_NEGOTIATE_GIGABIT, 0);
- break;
- case IFM_100_FX:
- case IFM_10_FL:
- CSR_WRITE_4(sc, TI_GCR_GLINK, 0);
- CSR_WRITE_4(sc, TI_GCR_LINK, TI_LNK_ENB|TI_LNK_PREF);
- if (IFM_SUBTYPE(ifm->ifm_media) == IFM_100_FX) {
- TI_SETBIT(sc, TI_GCR_LINK, TI_LNK_100MB);
- } else {
- TI_SETBIT(sc, TI_GCR_LINK, TI_LNK_10MB);
- }
- if ((ifm->ifm_media & IFM_GMASK) == IFM_FDX) {
- TI_SETBIT(sc, TI_GCR_LINK, TI_LNK_FULL_DUPLEX);
- } else {
- TI_SETBIT(sc, TI_GCR_LINK, TI_LNK_HALF_DUPLEX);
- }
- TI_DO_CMD(TI_CMD_LINK_NEGOTIATION,
- TI_CMD_CODE_NEGOTIATE_10_100, 0);
- break;
- }
-
- return(0);
-}
-
-/*
- * Report current media status.
- */
-static void ti_ifmedia_sts(ifp, ifmr)
- struct ifnet *ifp;
- struct ifmediareq *ifmr;
-{
- struct ti_softc *sc;
-
- sc = ifp->if_softc;
-
- ifmr->ifm_status = IFM_AVALID;
- ifmr->ifm_active = IFM_ETHER;
-
- if (sc->ti_linkstat == TI_EV_CODE_LINK_DOWN)
- return;
-
- ifmr->ifm_status |= IFM_ACTIVE;
-
- if (sc->ti_linkstat == TI_EV_CODE_GIG_LINK_UP)
- ifmr->ifm_active |= IFM_1000_SX|IFM_FDX;
- else if (sc->ti_linkstat == TI_EV_CODE_LINK_UP) {
- u_int32_t media;
- media = CSR_READ_4(sc, TI_GCR_LINK_STAT);
- if (media & TI_LNK_100MB)
- ifmr->ifm_active |= IFM_100_FX;
- if (media & TI_LNK_10MB)
- ifmr->ifm_active |= IFM_10_FL;
- if (media & TI_LNK_FULL_DUPLEX)
- ifmr->ifm_active |= IFM_FDX;
- if (media & TI_LNK_HALF_DUPLEX)
- ifmr->ifm_active |= IFM_HDX;
- }
-
- return;
-}
-
-static int ti_ioctl(ifp, command, data)
- struct ifnet *ifp;
- u_long command;
- caddr_t data;
-{
- struct ti_softc *sc = ifp->if_softc;
- struct ifreq *ifr = (struct ifreq *) data;
- int s, error = 0;
- struct ti_cmd_desc cmd;
-
- s = splimp();
-
- switch(command) {
- case SIOCSIFADDR:
- case SIOCGIFADDR:
- error = ether_ioctl(ifp, command, data);
- break;
- case SIOCSIFMTU:
- if (ifr->ifr_mtu > TI_JUMBO_MTU)
- error = EINVAL;
- else {
- ifp->if_mtu = ifr->ifr_mtu;
- ti_init(sc);
- }
- break;
- case SIOCSIFFLAGS:
- if (ifp->if_flags & IFF_UP) {
- /*
- * If only the state of the PROMISC flag changed,
- * then just use the 'set promisc mode' command
- * instead of reinitializing the entire NIC. Doing
- * a full re-init means reloading the firmware and
- * waiting for it to start up, which may take a
- * second or two.
- */
- if (ifp->if_flags & IFF_RUNNING &&
- ifp->if_flags & IFF_PROMISC &&
- !(sc->ti_if_flags & IFF_PROMISC)) {
- TI_DO_CMD(TI_CMD_SET_PROMISC_MODE,
- TI_CMD_CODE_PROMISC_ENB, 0);
- } else if (ifp->if_flags & IFF_RUNNING &&
- !(ifp->if_flags & IFF_PROMISC) &&
- sc->ti_if_flags & IFF_PROMISC) {
- TI_DO_CMD(TI_CMD_SET_PROMISC_MODE,
- TI_CMD_CODE_PROMISC_DIS, 0);
- } else
- ti_init(sc);
- } else {
- if (ifp->if_flags & IFF_RUNNING) {
- ti_stop(sc);
- }
- }
- sc->ti_if_flags = ifp->if_flags;
- error = 0;
- break;
- case SIOCADDMULTI:
- case SIOCDELMULTI:
- if (ifp->if_flags & IFF_RUNNING) {
- ti_setmulti(sc);
- error = 0;
- }
- break;
- case SIOCSIFMEDIA:
- case SIOCGIFMEDIA:
- error = ifmedia_ioctl(ifp, ifr, &sc->ifmedia, command);
- break;
- default:
- error = EINVAL;
- break;
- }
-
- (void)splx(s);
-
- return(error);
-}
-
-static void ti_watchdog(ifp)
- struct ifnet *ifp;
-{
- struct ti_softc *sc;
-
- sc = ifp->if_softc;
-
- printf("ti%d: watchdog timeout -- resetting\n", sc->ti_unit);
- ti_stop(sc);
- ti_init(sc);
-
- ifp->if_oerrors++;
-
- return;
-}
-
-/*
- * Stop the adapter and free any mbufs allocated to the
- * RX and TX lists.
- */
-static void ti_stop(sc)
- struct ti_softc *sc;
-{
- struct ifnet *ifp;
- struct ti_cmd_desc cmd;
-
- ifp = &sc->arpcom.ac_if;
-
- /* Disable host interrupts. */
- CSR_WRITE_4(sc, TI_MB_HOSTINTR, 1);
- /*
- * Tell firmware we're shutting down.
- */
- TI_DO_CMD(TI_CMD_HOST_STATE, TI_CMD_CODE_STACK_DOWN, 0);
-
- /* Halt and reinitialize. */
- ti_chipinit(sc);
- ti_mem(sc, 0x2000, 0x100000 - 0x2000, NULL);
- ti_chipinit(sc);
-
- /* Free the RX lists. */
- ti_free_rx_ring_std(sc);
-
- /* Free jumbo RX list. */
- ti_free_rx_ring_jumbo(sc);
-
- /* Free mini RX list. */
- ti_free_rx_ring_mini(sc);
-
- /* Free TX buffers. */
- ti_free_tx_ring(sc);
-
- sc->ti_ev_prodidx.ti_idx = 0;
- sc->ti_return_prodidx.ti_idx = 0;
- sc->ti_tx_considx.ti_idx = 0;
- sc->ti_tx_saved_considx = TI_TXCONS_UNSET;
-
- ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
-
- return;
-}
-
-/*
- * Stop all chip I/O so that the kernel's probe routines don't
- * get confused by errant DMAs when rebooting.
- */
-static void ti_shutdown(dev)
- device_t dev;
-{
- struct ti_softc *sc;
-
- sc = device_get_softc(dev);
-
- ti_chipinit(sc);
-
- return;
-}
diff --git a/sys/dev/ti/if_tireg.h b/sys/dev/ti/if_tireg.h
deleted file mode 100644
index ec278030d0fd..000000000000
--- a/sys/dev/ti/if_tireg.h
+++ /dev/null
@@ -1,1184 +0,0 @@
-/*
- * Copyright (c) 1997, 1998, 1999
- * Bill Paul <wpaul@ctr.columbia.edu>. 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 Bill Paul.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY Bill Paul 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 Bill Paul OR THE VOICES IN HIS HEAD
- * 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Tigon register offsets. These are memory mapped registers
- * which can be accessed with the CSR_READ_4()/CSR_WRITE_4() macros.
- * Each register must be accessed using 32 bit operations.
- *
- * All reegisters are accessed through a 16K shared memory block.
- * The first group of registers are actually copies of the PCI
- * configuration space registers.
- */
-
-#define TI_PCI_ID 0x000 /* PCI device/vendor ID */
-#define TI_PCI_CMDSTAT 0x004
-#define TI_PCI_CLASSCODE 0x008
-#define TI_PCI_BIST 0x00C
-#define TI_PCI_LOMEM 0x010 /* Shared memory base address */
-#define TI_PCI_SUBSYS 0x02C
-#define TI_PCI_ROMBASE 0x030
-#define TI_PCI_INT 0x03C
-
-#ifndef PCIM_CMD_MWIEN
-#define PCIM_CMD_MWIEN 0x0010
-#endif
-
-/*
- * Alteon AceNIC PCI vendor/device ID.
- */
-#define ALT_VENDORID 0x12AE
-#define ALT_DEVICEID_ACENIC 0x0001
-
-/*
- * 3Com 3c985 PCI vendor/device ID.
- */
-#define TC_VENDORID 0x10B7
-#define TC_DEVICEID_3C985 0x0001
-
-/*
- * Netgear GA620 PCI vendor/device ID.
- */
-#define NG_VENDORID 0x1385
-#define NG_DEVICEID_GA620 0x620A
-
-/*
- * SGI device/vendor ID.
- */
-#define SGI_VENDORID 0x10A9
-#define SGI_DEVICEID_TIGON 0x0009
-
-/*
- * DEC vendor ID, Farallon device ID. Apparently, Farallon used
- * the DEC vendor ID in their cards by mistake.
- */
-#define DEC_VENDORID 0x1011
-#define DEC_DEVICEID_FARALLON_PN9000SX 0x001a
-
-/*
- * Tigon configuration and control registers.
- */
-#define TI_MISC_HOST_CTL 0x040
-#define TI_MISC_LOCAL_CTL 0x044
-#define TI_SEM_AB 0x048 /* Tigon 2 only */
-#define TI_MISC_CONF 0x050 /* Tigon 2 only */
-#define TI_TIMER_BITS 0x054
-#define TI_TIMERREF 0x058
-#define TI_PCI_STATE 0x05C
-#define TI_MAIN_EVENT_A 0x060
-#define TI_MAILBOX_EVENT_A 0x064
-#define TI_WINBASE 0x068
-#define TI_WINDATA 0x06C
-#define TI_MAIN_EVENT_B 0x070 /* Tigon 2 only */
-#define TI_MAILBOX_EVENT_B 0x074 /* Tigon 2 only */
-#define TI_TIMERREF_B 0x078 /* Tigon 2 only */
-#define TI_SERIAL 0x07C
-
-/*
- * Misc host control bits.
- */
-#define TI_MHC_INTSTATE 0x00000001
-#define TI_MHC_CLEARINT 0x00000002
-#define TI_MHC_RESET 0x00000008
-#define TI_MHC_BYTE_SWAP_ENB 0x00000010
-#define TI_MHC_WORD_SWAP_ENB 0x00000020
-#define TI_MHC_MASK_INTS 0x00000040
-#define TI_MHC_CHIP_REV_MASK 0xF0000000
-
-#define TI_MHC_BIGENDIAN_INIT \
- (TI_MHC_BYTE_SWAP_ENB|TI_MHC_WORD_SWAP_ENB|TI_MHC_CLEARINT)
-
-#define TI_MHC_LITTLEENDIAN_INIT \
- (TI_MHC_WORD_SWAP_ENB|TI_MHC_CLEARINT)
-
-/*
- * Tigon chip rev values. Rev 4 is the Tigon 1. Rev 6 is the Tigon 2.
- * Rev 5 is also the Tigon 2, but is a broken version which was never
- * used in any actual hardware, so we ignore it.
- */
-#define TI_REV_TIGON_I 0x40000000
-#define TI_REV_TIGON_II 0x60000000
-
-/*
- * Firmware revision that we want.
- */
-#define TI_FIRMWARE_MAJOR 0xc
-#define TI_FIRMWARE_MINOR 0x3
-#define TI_FIRMWARE_FIX 0x12
-
-/*
- * Miscelaneous Local Control register.
- */
-#define TI_MLC_EE_WRITE_ENB 0x00000010
-#define TI_MLC_SRAM_BANK_256K 0x00000200
-#define TI_MLC_SRAM_BANK_SIZE 0x00000300 /* Tigon 2 only */
-#define TI_MLC_LOCALADDR_21 0x00004000
-#define TI_MLC_LOCALADDR_22 0x00008000
-#define TI_MLC_SBUS_WRITEERR 0x00080000
-#define TI_MLC_EE_CLK 0x00100000
-#define TI_MLC_EE_TXEN 0x00200000
-#define TI_MLC_EE_DOUT 0x00400000
-#define TI_MLC_EE_DIN 0x00800000
-
-/*
- * Offset of MAC address inside EEPROM.
- */
-#define TI_EE_MAC_OFFSET 0x8c
-
-#define TI_DMA_ASSIST 0x11C
-#define TI_CPU_STATE 0x140
-#define TI_CPU_PROGRAM_COUNTER 0x144
-#define TI_SRAM_ADDR 0x154
-#define TI_SRAM_DATA 0x158
-#define TI_GEN_0 0x180
-#define TI_GEN_X 0x1FC
-#define TI_MAC_TX_STATE 0x200
-#define TI_MAC_RX_STATE 0x220
-#define TI_CPU_CTL_B 0x240 /* Tigon 2 only */
-#define TI_CPU_PROGRAM_COUNTER_B 0x244 /* Tigon 2 only */
-#define TI_SRAM_ADDR_B 0x254 /* Tigon 2 only */
-#define TI_SRAM_DATA_B 0x258 /* Tigon 2 only */
-#define TI_GEN_B_0 0x280 /* Tigon 2 only */
-#define TI_GEN_B_X 0x2FC /* Tigon 2 only */
-
-/*
- * Misc config register.
- */
-#define TI_MCR_SRAM_SYNCHRONOUS 0x00100000 /* Tigon 2 only */
-
-/*
- * PCI state register.
- */
-#define TI_PCISTATE_FORCE_RESET 0x00000001
-#define TI_PCISTATE_PROVIDE_LEN 0x00000002
-#define TI_PCISTATE_READ_MAXDMA 0x0000001C
-#define TI_PCISTATE_WRITE_MAXDMA 0x000000E0
-#define TI_PCISTATE_MINDMA 0x0000FF00
-#define TI_PCISTATE_FIFO_RETRY_ENB 0x00010000
-#define TI_PCISTATE_USE_MEM_RD_MULT 0x00020000
-#define TI_PCISTATE_NO_SWAP_READ_DMA 0x00040000
-#define TI_PCISTATE_NO_SWAP_WRITE_DMA 0x00080000
-#define TI_PCISTATE_66MHZ_BUS 0x00080000 /* Tigon 2 only */
-#define TI_PCISTATE_32BIT_BUS 0x00100000 /* Tigon 2 only */
-#define TI_PCISTATE_ENB_BYTE_ENABLES 0x00800000 /* Tigon 2 only */
-#define TI_PCISTATE_READ_CMD 0x0F000000
-#define TI_PCISTATE_WRITE_CMD 0xF0000000
-
-#define TI_PCI_READMAX_4 0x04
-#define TI_PCI_READMAX_16 0x08
-#define TI_PCI_READMAX_32 0x0C
-#define TI_PCI_READMAX_64 0x10
-#define TI_PCI_READMAX_128 0x14
-#define TI_PCI_READMAX_256 0x18
-#define TI_PCI_READMAX_1024 0x1C
-
-#define TI_PCI_WRITEMAX_4 0x20
-#define TI_PCI_WRITEMAX_16 0x40
-#define TI_PCI_WRITEMAX_32 0x60
-#define TI_PCI_WRITEMAX_64 0x80
-#define TI_PCI_WRITEMAX_128 0xA0
-#define TI_PCI_WRITEMAX_256 0xC0
-#define TI_PCI_WRITEMAX_1024 0xE0
-
-#define TI_PCI_READ_CMD 0x06000000
-#define TI_PCI_WRITE_CMD 0x70000000
-
-/*
- * DMA state register.
- */
-#define TI_DMASTATE_ENABLE 0x00000001
-#define TI_DMASTATE_PAUSE 0x00000002
-
-/*
- * CPU state register.
- */
-#define TI_CPUSTATE_RESET 0x00000001
-#define TI_CPUSTATE_STEP 0x00000002
-#define TI_CPUSTATE_ROMFAIL 0x00000010
-#define TI_CPUSTATE_HALT 0x00010000
-/*
- * MAC TX state register
- */
-#define TI_TXSTATE_RESET 0x00000001
-#define TI_TXSTATE_ENB 0x00000002
-#define TI_TXSTATE_STOP 0x00000004
-
-/*
- * MAC RX state register
- */
-#define TI_RXSTATE_RESET 0x00000001
-#define TI_RXSTATE_ENB 0x00000002
-#define TI_RXSTATE_STOP 0x00000004
-
-/*
- * Tigon 2 mailbox registers. The mailbox area consists of 256 bytes
- * split into 64 bit registers. Only the lower 32 bits of each mailbox
- * are used.
- */
-#define TI_MB_HOSTINTR_HI 0x500
-#define TI_MB_HOSTINTR_LO 0x504
-#define TI_MB_HOSTINTR TI_MB_HOSTINTR_LO
-#define TI_MB_CMDPROD_IDX_HI 0x508
-#define TI_MB_CMDPROD_IDX_LO 0x50C
-#define TI_MB_CMDPROD_IDX TI_MB_CMDPROD_IDX_LO
-#define TI_MB_SENDPROD_IDX_HI 0x510
-#define TI_MB_SENDPROD_IDX_LO 0x514
-#define TI_MB_SENDPROD_IDX TI_MB_SENDPROD_IDX_LO
-#define TI_MB_STDRXPROD_IDX_HI 0x518 /* Tigon 2 only */
-#define TI_MB_STDRXPROD_IDX_LO 0x51C /* Tigon 2 only */
-#define TI_MB_STDRXPROD_IDX TI_MB_STDRXPROD_IDX_LO
-#define TI_MB_JUMBORXPROD_IDX_HI 0x520 /* Tigon 2 only */
-#define TI_MB_JUMBORXPROD_IDX_LO 0x524 /* Tigon 2 only */
-#define TI_MB_JUMBORXPROD_IDX TI_MB_JUMBORXPROD_IDX_LO
-#define TI_MB_MINIRXPROD_IDX_HI 0x528 /* Tigon 2 only */
-#define TI_MB_MINIRXPROD_IDX_LO 0x52C /* Tigon 2 only */
-#define TI_MB_MINIRXPROD_IDX TI_MB_MINIRXPROD_IDX_LO
-#define TI_MB_RSVD 0x530
-
-/*
- * Tigon 2 general communication registers. These are 64 and 32 bit
- * registers which are only valid after the firmware has been
- * loaded and started. They actually exist in NIC memory but are
- * mapped into the host memory via the shared memory region.
- *
- * The NIC internally maps these registers starting at address 0,
- * so to determine the NIC address of any of these registers, we
- * subtract 0x600 (the address of the first register).
- */
-
-#define TI_GCR_BASE 0x600
-#define TI_GCR_MACADDR 0x600
-#define TI_GCR_PAR0 0x600
-#define TI_GCR_PAR1 0x604
-#define TI_GCR_GENINFO_HI 0x608
-#define TI_GCR_GENINFO_LO 0x60C
-#define TI_GCR_MCASTADDR 0x610 /* obsolete */
-#define TI_GCR_MAR0 0x610 /* obsolete */
-#define TI_GCR_MAR1 0x614 /* obsolete */
-#define TI_GCR_OPMODE 0x618
-#define TI_GCR_DMA_READCFG 0x61C
-#define TI_GCR_DMA_WRITECFG 0x620
-#define TI_GCR_TX_BUFFER_RATIO 0x624
-#define TI_GCR_EVENTCONS_IDX 0x628
-#define TI_GCR_CMDCONS_IDX 0x62C
-#define TI_GCR_TUNEPARMS 0x630
-#define TI_GCR_RX_COAL_TICKS 0x630
-#define TI_GCR_TX_COAL_TICKS 0x634
-#define TI_GCR_STAT_TICKS 0x638
-#define TI_GCR_TX_MAX_COAL_BD 0x63C
-#define TI_GCR_RX_MAX_COAL_BD 0x640
-#define TI_GCR_NIC_TRACING 0x644
-#define TI_GCR_GLINK 0x648
-#define TI_GCR_LINK 0x64C
-#define TI_GCR_NICTRACE_PTR 0x650
-#define TI_GCR_NICTRACE_START 0x654
-#define TI_GCR_NICTRACE_LEN 0x658
-#define TI_GCR_IFINDEX 0x65C
-#define TI_GCR_IFMTU 0x660
-#define TI_GCR_MASK_INTRS 0x664
-#define TI_GCR_GLINK_STAT 0x668
-#define TI_GCR_LINK_STAT 0x66C
-#define TI_GCR_RXRETURNCONS_IDX 0x680
-#define TI_GCR_CMDRING 0x700
-
-#define TI_GCR_NIC_ADDR(x) (x - TI_GCR_BASE);
-
-/*
- * Local memory window. The local memory window is a 2K shared
- * memory region which can be used to access the NIC's internal
- * SRAM. The window can be mapped to a given 2K region using
- * the TI_WINDOW_BASE register.
- */
-#define TI_WINDOW 0x800
-#define TI_WINLEN 0x800
-
-#define TI_TICKS_PER_SEC 1000000
-
-/*
- * Operation mode register.
- */
-#define TI_OPMODE_BYTESWAP_BD 0x00000002
-#define TI_OPMODE_WORDSWAP_BD 0x00000004
-#define TI_OPMODE_WARN_ENB 0x00000008 /* not yet implimented */
-#define TI_OPMODE_BYTESWAP_DATA 0x00000010
-#define TI_OPMODE_1_DMA_ACTIVE 0x00000040
-#define TI_OPMODE_SBUS 0x00000100
-#define TI_OPMODE_DONT_FRAG_JUMBO 0x00000200
-#define TI_OPMODE_INCLUDE_CRC 0x00000400
-#define TI_OPMODE_RX_BADFRAMES 0x00000800
-#define TI_OPMODE_NO_EVENT_INTRS 0x00001000
-#define TI_OPMODE_NO_TX_INTRS 0x00002000
-#define TI_OPMODE_NO_RX_INTRS 0x00004000
-#define TI_OPMODE_FATAL_ENB 0x40000000 /* not yet implimented */
-
-/*
- * DMA configuration thresholds.
- */
-#define TI_DMA_STATE_THRESH_16W 0x00000100
-#define TI_DMA_STATE_THRESH_8W 0x00000080
-#define TI_DMA_STATE_THRESH_4W 0x00000040
-#define TI_DMA_STATE_THRESH_2W 0x00000020
-#define TI_DMA_STATE_THRESH_1W 0x00000010
-
-#define TI_DMA_STATE_FORCE_32_BIT 0x00000008
-
-/*
- * Gigabit link status bits.
- */
-#define TI_GLNK_SENSE_NO_BEG 0x00002000
-#define TI_GLNK_LOOPBACK 0x00004000
-#define TI_GLNK_PREF 0x00008000
-#define TI_GLNK_1000MB 0x00040000
-#define TI_GLNK_FULL_DUPLEX 0x00080000
-#define TI_GLNK_TX_FLOWCTL_Y 0x00200000 /* Tigon 2 only */
-#define TI_GLNK_RX_FLOWCTL_Y 0x00800000
-#define TI_GLNK_AUTONEGENB 0x20000000
-#define TI_GLNK_ENB 0x40000000
-
-/*
- * Link status bits.
- */
-#define TI_LNK_LOOPBACK 0x00004000
-#define TI_LNK_PREF 0x00008000
-#define TI_LNK_10MB 0x00010000
-#define TI_LNK_100MB 0x00020000
-#define TI_LNK_1000MB 0x00040000
-#define TI_LNK_FULL_DUPLEX 0x00080000
-#define TI_LNK_HALF_DUPLEX 0x00100000
-#define TI_LNK_TX_FLOWCTL_Y 0x00200000 /* Tigon 2 only */
-#define TI_LNK_RX_FLOWCTL_Y 0x00800000
-#define TI_LNK_AUTONEGENB 0x20000000
-#define TI_LNK_ENB 0x40000000
-
-/*
- * Ring size constants.
- */
-#define TI_EVENT_RING_CNT 256
-#define TI_CMD_RING_CNT 64
-#define TI_STD_RX_RING_CNT 512
-#define TI_JUMBO_RX_RING_CNT 256
-#define TI_MINI_RX_RING_CNT 1024
-#define TI_RETURN_RING_CNT 2048
-
-/*
- * Possible TX ring sizes.
- */
-#define TI_TX_RING_CNT_128 128
-#define TI_TX_RING_BASE_128 0x3800
-
-#define TI_TX_RING_CNT_256 256
-#define TI_TX_RING_BASE_256 0x3000
-
-#define TI_TX_RING_CNT_512 512
-#define TI_TX_RING_BASE_512 0x2000
-
-#define TI_TX_RING_CNT TI_TX_RING_CNT_512
-#define TI_TX_RING_BASE TI_TX_RING_BASE_512
-
-/*
- * The Tigon can have up to 8MB of external SRAM, however the Tigon 1
- * is limited to 2MB total, and in general I think most adapters have
- * around 1MB. We use this value for zeroing the NIC's SRAM, so to
- * be safe we use the largest possible value (zeroing memory that
- * isn't there doesn't hurt anything).
- */
-#define TI_MEM_MAX 0x7FFFFF
-
-/*
- * Even on the alpha, pci addresses are 32-bit quantities
- */
-
-#ifdef __64_bit_pci_addressing__
-typedef struct {
- u_int64_t ti_addr;
-} ti_hostaddr;
-#define TI_HOSTADDR(x) x.ti_addr
-#else
-typedef struct {
- u_int32_t ti_addr_hi;
- u_int32_t ti_addr_lo;
-} ti_hostaddr;
-#define TI_HOSTADDR(x) x.ti_addr_lo
-#endif
-
-/*
- * Ring control block structure. The rules for the max_len field
- * are as follows:
- *
- * For the send ring, max_len indicates the number of entries in the
- * ring (128, 256 or 512).
- *
- * For the standard receive ring, max_len indicates the threshold
- * used to decide when a frame should be put in the jumbo receive ring
- * instead of the standard one.
- *
- * For the mini ring, max_len indicates the size of the buffers in the
- * ring. This is the value used to decide when a frame is small enough
- * to be placed in the mini ring.
- *
- * For the return receive ring, max_len indicates the number of entries
- * in the ring. It can be one of 2048, 1024 or 0 (which is the same as
- * 2048 for backwards compatibility). The value 1024 can only be used
- * if the mini ring is disabled.
- */
-struct ti_rcb {
- ti_hostaddr ti_hostaddr;
-#if BYTE_ORDER == BIG_ENDIAN
- u_int16_t ti_max_len;
- u_int16_t ti_flags;
-#else
- u_int16_t ti_flags;
- u_int16_t ti_max_len;
-#endif
- u_int32_t ti_unused;
-};
-
-#define TI_RCB_FLAG_TCP_UDP_CKSUM 0x00000001
-#define TI_RCB_FLAG_IP_CKSUM 0x00000002
-#define TI_RCB_FLAG_NO_PHDR_CKSUM 0x00000008
-#define TI_RCB_FLAG_VLAN_ASSIST 0x00000010
-#define TI_RCB_FLAG_COAL_UPD_ONLY 0x00000020
-#define TI_RCB_FLAG_HOST_RING 0x00000040
-#define TI_RCB_FLAG_IEEE_SNAP_CKSUM 0x00000080
-#define TI_RCB_FLAG_USE_EXT_RX_BD 0x00000100
-#define TI_RCB_FLAG_RING_DISABLED 0x00000200
-
-struct ti_producer {
- u_int32_t ti_idx;
- u_int32_t ti_unused;
-};
-
-/*
- * Tigon statistics counters.
- */
-struct ti_stats {
- /*
- * MAC stats, taken from RFC 1643, ethernet-like MIB
- */
- volatile u_int32_t dot3StatsAlignmentErrors; /* 0 */
- volatile u_int32_t dot3StatsFCSErrors; /* 1 */
- volatile u_int32_t dot3StatsSingleCollisionFrames; /* 2 */
- volatile u_int32_t dot3StatsMultipleCollisionFrames; /* 3 */
- volatile u_int32_t dot3StatsSQETestErrors; /* 4 */
- volatile u_int32_t dot3StatsDeferredTransmissions; /* 5 */
- volatile u_int32_t dot3StatsLateCollisions; /* 6 */
- volatile u_int32_t dot3StatsExcessiveCollisions; /* 7 */
- volatile u_int32_t dot3StatsInternalMacTransmitErrors; /* 8 */
- volatile u_int32_t dot3StatsCarrierSenseErrors; /* 9 */
- volatile u_int32_t dot3StatsFrameTooLongs; /* 10 */
- volatile u_int32_t dot3StatsInternalMacReceiveErrors; /* 11 */
- /*
- * interface stats, taken from RFC 1213, MIB-II, interfaces group
- */
- volatile u_int32_t ifIndex; /* 12 */
- volatile u_int32_t ifType; /* 13 */
- volatile u_int32_t ifMtu; /* 14 */
- volatile u_int32_t ifSpeed; /* 15 */
- volatile u_int32_t ifAdminStatus; /* 16 */
-#define IF_ADMIN_STATUS_UP 1
-#define IF_ADMIN_STATUS_DOWN 2
-#define IF_ADMIN_STATUS_TESTING 3
- volatile u_int32_t ifOperStatus; /* 17 */
-#define IF_OPER_STATUS_UP 1
-#define IF_OPER_STATUS_DOWN 2
-#define IF_OPER_STATUS_TESTING 3
-#define IF_OPER_STATUS_UNKNOWN 4
-#define IF_OPER_STATUS_DORMANT 5
- volatile u_int32_t ifLastChange; /* 18 */
- volatile u_int32_t ifInDiscards; /* 19 */
- volatile u_int32_t ifInErrors; /* 20 */
- volatile u_int32_t ifInUnknownProtos; /* 21 */
- volatile u_int32_t ifOutDiscards; /* 22 */
- volatile u_int32_t ifOutErrors; /* 23 */
- volatile u_int32_t ifOutQLen; /* deprecated */ /* 24 */
- volatile u_int8_t ifPhysAddress[8]; /* 8 bytes */ /* 25 - 26 */
- volatile u_int8_t ifDescr[32]; /* 27 - 34 */
- u_int32_t alignIt; /* align to 64 bit for u_int64_ts following */
- /*
- * more interface stats, taken from RFC 1573, MIB-IIupdate,
- * interfaces group
- */
- volatile u_int64_t ifHCInOctets; /* 36 - 37 */
- volatile u_int64_t ifHCInUcastPkts; /* 38 - 39 */
- volatile u_int64_t ifHCInMulticastPkts; /* 40 - 41 */
- volatile u_int64_t ifHCInBroadcastPkts; /* 42 - 43 */
- volatile u_int64_t ifHCOutOctets; /* 44 - 45 */
- volatile u_int64_t ifHCOutUcastPkts; /* 46 - 47 */
- volatile u_int64_t ifHCOutMulticastPkts; /* 48 - 49 */
- volatile u_int64_t ifHCOutBroadcastPkts; /* 50 - 51 */
- volatile u_int32_t ifLinkUpDownTrapEnable; /* 52 */
- volatile u_int32_t ifHighSpeed; /* 53 */
- volatile u_int32_t ifPromiscuousMode; /* 54 */
- volatile u_int32_t ifConnectorPresent; /* follow link state 55 */
- /*
- * Host Commands
- */
- volatile u_int32_t nicCmdsHostState; /* 56 */
- volatile u_int32_t nicCmdsFDRFiltering; /* 57 */
- volatile u_int32_t nicCmdsSetRecvProdIndex; /* 58 */
- volatile u_int32_t nicCmdsUpdateGencommStats; /* 59 */
- volatile u_int32_t nicCmdsResetJumboRing; /* 60 */
- volatile u_int32_t nicCmdsAddMCastAddr; /* 61 */
- volatile u_int32_t nicCmdsDelMCastAddr; /* 62 */
- volatile u_int32_t nicCmdsSetPromiscMode; /* 63 */
- volatile u_int32_t nicCmdsLinkNegotiate; /* 64 */
- volatile u_int32_t nicCmdsSetMACAddr; /* 65 */
- volatile u_int32_t nicCmdsClearProfile; /* 66 */
- volatile u_int32_t nicCmdsSetMulticastMode; /* 67 */
- volatile u_int32_t nicCmdsClearStats; /* 68 */
- volatile u_int32_t nicCmdsSetRecvJumboProdIndex; /* 69 */
- volatile u_int32_t nicCmdsSetRecvMiniProdIndex; /* 70 */
- volatile u_int32_t nicCmdsRefreshStats; /* 71 */
- volatile u_int32_t nicCmdsUnknown; /* 72 */
- /*
- * NIC Events
- */
- volatile u_int32_t nicEventsNICFirmwareOperational; /* 73 */
- volatile u_int32_t nicEventsStatsUpdated; /* 74 */
- volatile u_int32_t nicEventsLinkStateChanged; /* 75 */
- volatile u_int32_t nicEventsError; /* 76 */
- volatile u_int32_t nicEventsMCastListUpdated; /* 77 */
- volatile u_int32_t nicEventsResetJumboRing; /* 78 */
- /*
- * Ring manipulation
- */
- volatile u_int32_t nicRingSetSendProdIndex; /* 79 */
- volatile u_int32_t nicRingSetSendConsIndex; /* 80 */
- volatile u_int32_t nicRingSetRecvReturnProdIndex; /* 81 */
- /*
- * Interrupts
- */
- volatile u_int32_t nicInterrupts; /* 82 */
- volatile u_int32_t nicAvoidedInterrupts; /* 83 */
- /*
- * BD Coalessing Thresholds
- */
- volatile u_int32_t nicEventThresholdHit; /* 84 */
- volatile u_int32_t nicSendThresholdHit; /* 85 */
- volatile u_int32_t nicRecvThresholdHit; /* 86 */
- /*
- * DMA Attentions
- */
- volatile u_int32_t nicDmaRdOverrun; /* 87 */
- volatile u_int32_t nicDmaRdUnderrun; /* 88 */
- volatile u_int32_t nicDmaWrOverrun; /* 89 */
- volatile u_int32_t nicDmaWrUnderrun; /* 90 */
- volatile u_int32_t nicDmaWrMasterAborts; /* 91 */
- volatile u_int32_t nicDmaRdMasterAborts; /* 92 */
- /*
- * NIC Resources
- */
- volatile u_int32_t nicDmaWriteRingFull; /* 93 */
- volatile u_int32_t nicDmaReadRingFull; /* 94 */
- volatile u_int32_t nicEventRingFull; /* 95 */
- volatile u_int32_t nicEventProducerRingFull; /* 96 */
- volatile u_int32_t nicTxMacDescrRingFull; /* 97 */
- volatile u_int32_t nicOutOfTxBufSpaceFrameRetry; /* 98 */
- volatile u_int32_t nicNoMoreWrDMADescriptors; /* 99 */
- volatile u_int32_t nicNoMoreRxBDs; /* 100 */
- volatile u_int32_t nicNoSpaceInReturnRing; /* 101 */
- volatile u_int32_t nicSendBDs; /* current count 102 */
- volatile u_int32_t nicRecvBDs; /* current count 103 */
- volatile u_int32_t nicJumboRecvBDs; /* current count 104 */
- volatile u_int32_t nicMiniRecvBDs; /* current count 105 */
- volatile u_int32_t nicTotalRecvBDs; /* current count 106 */
- volatile u_int32_t nicTotalSendBDs; /* current count 107 */
- volatile u_int32_t nicJumboSpillOver; /* 108 */
- volatile u_int32_t nicSbusHangCleared; /* 109 */
- volatile u_int32_t nicEnqEventDelayed; /* 110 */
- /*
- * Stats from MAC rx completion
- */
- volatile u_int32_t nicMacRxLateColls; /* 111 */
- volatile u_int32_t nicMacRxLinkLostDuringPkt; /* 112 */
- volatile u_int32_t nicMacRxPhyDecodeErr; /* 113 */
- volatile u_int32_t nicMacRxMacAbort; /* 114 */
- volatile u_int32_t nicMacRxTruncNoResources; /* 115 */
- /*
- * Stats from the mac_stats area
- */
- volatile u_int32_t nicMacRxDropUla; /* 116 */
- volatile u_int32_t nicMacRxDropMcast; /* 117 */
- volatile u_int32_t nicMacRxFlowControl; /* 118 */
- volatile u_int32_t nicMacRxDropSpace; /* 119 */
- volatile u_int32_t nicMacRxColls; /* 120 */
- /*
- * MAC RX Attentions
- */
- volatile u_int32_t nicMacRxTotalAttns; /* 121 */
- volatile u_int32_t nicMacRxLinkAttns; /* 122 */
- volatile u_int32_t nicMacRxSyncAttns; /* 123 */
- volatile u_int32_t nicMacRxConfigAttns; /* 124 */
- volatile u_int32_t nicMacReset; /* 125 */
- volatile u_int32_t nicMacRxBufDescrAttns; /* 126 */
- volatile u_int32_t nicMacRxBufAttns; /* 127 */
- volatile u_int32_t nicMacRxZeroFrameCleanup; /* 128 */
- volatile u_int32_t nicMacRxOneFrameCleanup; /* 129 */
- volatile u_int32_t nicMacRxMultipleFrameCleanup; /* 130 */
- volatile u_int32_t nicMacRxTimerCleanup; /* 131 */
- volatile u_int32_t nicMacRxDmaCleanup; /* 132 */
- /*
- * Stats from the mac_stats area
- */
- volatile u_int32_t nicMacTxCollisionHistogram[15]; /* 133 */
- /*
- * MAC TX Attentions
- */
- volatile u_int32_t nicMacTxTotalAttns; /* 134 */
- /*
- * NIC Profile
- */
- volatile u_int32_t nicProfile[32]; /* 135 */
- /*
- * Pat to 1024 bytes.
- */
- u_int32_t pad[75];
-};
-/*
- * Tigon general information block. This resides in host memory
- * and contains the status counters, ring control blocks and
- * producer pointers.
- */
-
-struct ti_gib {
- struct ti_stats ti_stats;
- struct ti_rcb ti_ev_rcb;
- struct ti_rcb ti_cmd_rcb;
- struct ti_rcb ti_tx_rcb;
- struct ti_rcb ti_std_rx_rcb;
- struct ti_rcb ti_jumbo_rx_rcb;
- struct ti_rcb ti_mini_rx_rcb;
- struct ti_rcb ti_return_rcb;
- ti_hostaddr ti_ev_prodidx_ptr;
- ti_hostaddr ti_return_prodidx_ptr;
- ti_hostaddr ti_tx_considx_ptr;
- ti_hostaddr ti_refresh_stats_ptr;
-};
-
-/*
- * Buffer descriptor structures. There are basically three types
- * of structures: normal receive descriptors, extended receive
- * descriptors and transmit descriptors. The extended receive
- * descriptors are optionally used only for the jumbo receive ring.
- */
-
-struct ti_rx_desc {
- ti_hostaddr ti_addr;
-#if BYTE_ORDER == BIG_ENDIAN
- u_int16_t ti_idx;
- u_int16_t ti_len;
-#else
- u_int16_t ti_len;
- u_int16_t ti_idx;
-#endif
-#if BYTE_ORDER == BIG_ENDIAN
- u_int16_t ti_type;
- u_int16_t ti_flags;
-#else
- u_int16_t ti_flags;
- u_int16_t ti_type;
-#endif
-#if BYTE_ORDER == BIG_ENDIAN
- u_int16_t ti_ip_cksum;
- u_int16_t ti_tcp_udp_cksum;
-#else
- u_int16_t ti_tcp_udp_cksum;
- u_int16_t ti_ip_cksum;
-#endif
-#if BYTE_ORDER == BIG_ENDIAN
- u_int16_t ti_error_flags;
- u_int16_t ti_vlan_tag;
-#else
- u_int16_t ti_vlan_tag;
- u_int16_t ti_error_flags;
-#endif
- u_int32_t ti_rsvd;
- u_int32_t ti_opaque;
-};
-
-struct ti_rx_desc_ext {
- ti_hostaddr ti_addr1;
- ti_hostaddr ti_addr2;
- ti_hostaddr ti_addr3;
-#if BYTE_ORDER == BIG_ENDIAN
- u_int16_t ti_len1;
- u_int16_t ti_len2;
-#else
- u_int16_t ti_len2;
- u_int16_t ti_len1;
-#endif
-#if BYTE_ORDER == BIG_ENDIAN
- u_int16_t ti_len3;
- u_int16_t ti_rsvd0;
-#else
- u_int16_t ti_rsvd0;
- u_int16_t ti_len3;
-#endif
- ti_hostaddr ti_addr0;
-#if BYTE_ORDER == BIG_ENDIAN
- u_int16_t ti_idx;
- u_int16_t ti_len0;
-#else
- u_int16_t ti_len0;
- u_int16_t ti_idx;
-#endif
-#if BYTE_ORDER == BIG_ENDIAN
- u_int16_t ti_type;
- u_int16_t ti_flags;
-#else
- u_int16_t ti_flags;
- u_int16_t ti_type;
-#endif
-#if BYTE_ORDER == BIG_ENDIAN
- u_int16_t ti_ip_cksum;
- u_int16_t ti_tcp_udp_cksum;
-#else
- u_int16_t ti_tcp_udp_cksum;
- u_int16_t ti_ip_cksum;
-#endif
-#if BYTE_ORDER == BIG_ENDIAN
- u_int16_t ti_error_flags;
- u_int16_t ti_vlan_tag;
-#else
- u_int16_t ti_vlan_tag;
- u_int16_t ti_error_flags;
-#endif
- u_int32_t ti_rsvd1;
- u_int32_t ti_opaque;
-};
-
-/*
- * Transmit descriptors are, mercifully, very small.
- */
-struct ti_tx_desc {
- ti_hostaddr ti_addr;
-#if BYTE_ORDER == BIG_ENDIAN
- u_int16_t ti_len;
- u_int16_t ti_flags;
-#else
- u_int16_t ti_flags;
- u_int16_t ti_len;
-#endif
-#if BYTE_ORDER == BIG_ENDIAN
- u_int16_t ti_rsvd;
- u_int16_t ti_vlan_tag;
-#else
- u_int16_t ti_vlan_tag;
- u_int16_t ti_rsvd;
-#endif
-};
-
-/*
- * NOTE! On the Alpha, we have an alignment constraint.
- * The first thing in the packet is a 14-byte Ethernet header.
- * This means that the packet is misaligned. To compensate,
- * we actually offset the data 2 bytes into the cluster. This
- * alignes the packet after the Ethernet header at a 32-bit
- * boundary.
- */
-
-#define ETHER_ALIGN 2
-
-#define TI_FRAMELEN 1518
-#define TI_JUMBO_FRAMELEN 9018
-#define TI_JUMBO_MTU (TI_JUMBO_FRAMELEN-ETHER_HDR_LEN-ETHER_CRC_LEN)
-#define TI_PAGE_SIZE PAGE_SIZE
-#define TI_MIN_FRAMELEN 60
-
-/*
- * Buffer descriptor error flags.
- */
-#define TI_BDERR_CRC 0x0001
-#define TI_BDERR_COLLDETECT 0x0002
-#define TI_BDERR_LINKLOST 0x0004
-#define TI_BDERR_DECODE 0x0008
-#define TI_BDERR_ODD_NIBBLES 0x0010
-#define TI_BDERR_MAC_ABRT 0x0020
-#define TI_BDERR_RUNT 0x0040
-#define TI_BDERR_TRUNC 0x0080
-#define TI_BDERR_GIANT 0x0100
-
-/*
- * Buffer descriptor flags.
- */
-#define TI_BDFLAG_TCP_UDP_CKSUM 0x0001
-#define TI_BDFLAG_IP_CKSUM 0x0002
-#define TI_BDFLAG_END 0x0004
-#define TI_BDFLAG_MORE 0x0008
-#define TI_BDFLAG_JUMBO_RING 0x0010
-#define TI_BDFLAG_UCAST_PKT 0x0020
-#define TI_BDFLAG_MCAST_PKT 0x0040
-#define TI_BDFLAG_BCAST_PKT 0x0060
-#define TI_BDFLAG_IP_FRAG 0x0080
-#define TI_BDFLAG_IP_FRAG_END 0x0100
-#define TI_BDFLAG_VLAN_TAG 0x0200
-#define TI_BDFLAG_ERROR 0x0400
-#define TI_BDFLAG_COAL_NOW 0x0800
-#define TI_BDFLAG_MINI_RING 0x1000
-
-/*
- * Descriptor type flags. I think these only have meaning for
- * the Tigon 1. I had to extract them from the sample driver source
- * since they aren't in the manual.
- */
-#define TI_BDTYPE_TYPE_NULL 0x0000
-#define TI_BDTYPE_SEND_BD 0x0001
-#define TI_BDTYPE_RECV_BD 0x0002
-#define TI_BDTYPE_RECV_JUMBO_BD 0x0003
-#define TI_BDTYPE_RECV_BD_LAST 0x0004
-#define TI_BDTYPE_SEND_DATA 0x0005
-#define TI_BDTYPE_SEND_DATA_LAST 0x0006
-#define TI_BDTYPE_RECV_DATA 0x0007
-#define TI_BDTYPE_RECV_DATA_LAST 0x000b
-#define TI_BDTYPE_EVENT_RUPT 0x000c
-#define TI_BDTYPE_EVENT_NO_RUPT 0x000d
-#define TI_BDTYPE_ODD_START 0x000e
-#define TI_BDTYPE_UPDATE_STATS 0x000f
-#define TI_BDTYPE_SEND_DUMMY_DMA 0x0010
-#define TI_BDTYPE_EVENT_PROD 0x0011
-#define TI_BDTYPE_TX_CONS 0x0012
-#define TI_BDTYPE_RX_PROD 0x0013
-#define TI_BDTYPE_REFRESH_STATS 0x0014
-#define TI_BDTYPE_SEND_DATA_LAST_VLAN 0x0015
-#define TI_BDTYPE_SEND_DATA_COAL 0x0016
-#define TI_BDTYPE_SEND_DATA_LAST_COAL 0x0017
-#define TI_BDTYPE_SEND_DATA_LAST_VLAN_COAL 0x0018
-#define TI_BDTYPE_TX_CONS_NO_INTR 0x0019
-
-/*
- * Tigon command structure.
- */
-struct ti_cmd_desc {
-#if BYTE_ORDER == BIG_ENDIAN
- u_int32_t ti_cmd:8;
- u_int32_t ti_code:12;
- u_int32_t ti_idx:12;
-#else
- u_int32_t ti_idx:12;
- u_int32_t ti_code:12;
- u_int32_t ti_cmd:8;
-#endif
-};
-
-#define TI_CMD_HOST_STATE 0x01
-#define TI_CMD_CODE_STACK_UP 0x01
-#define TI_CMD_CODE_STACK_DOWN 0x02
-
-/*
- * This command enables software address filtering. It's a workaround
- * for a bug in the Tigon 1 and not implemented for the Tigon 2.
- */
-#define TI_CMD_FDR_FILTERING 0x02
-#define TI_CMD_CODE_FILT_ENB 0x01
-#define TI_CMD_CODE_FILT_DIS 0x02
-
-#define TI_CMD_SET_RX_PROD_IDX 0x03 /* obsolete */
-#define TI_CMD_UPDATE_GENCOM 0x04
-#define TI_CMD_RESET_JUMBO_RING 0x05
-#define TI_CMD_SET_PARTIAL_RX_CNT 0x06
-#define TI_CMD_ADD_MCAST_ADDR 0x08 /* obsolete */
-#define TI_CMD_DEL_MCAST_ADDR 0x09 /* obsolete */
-
-#define TI_CMD_SET_PROMISC_MODE 0x0A
-#define TI_CMD_CODE_PROMISC_ENB 0x01
-#define TI_CMD_CODE_PROMISC_DIS 0x02
-
-#define TI_CMD_LINK_NEGOTIATION 0x0B
-#define TI_CMD_CODE_NEGOTIATE_BOTH 0x00
-#define TI_CMD_CODE_NEGOTIATE_GIGABIT 0x01
-#define TI_CMD_CODE_NEGOTIATE_10_100 0x02
-
-#define TI_CMD_SET_MAC_ADDR 0x0C
-#define TI_CMD_CLR_PROFILE 0x0D
-
-#define TI_CMD_SET_ALLMULTI 0x0E
-#define TI_CMD_CODE_ALLMULTI_ENB 0x01
-#define TI_CMD_CODE_ALLMULTI_DIS 0x02
-
-#define TI_CMD_CLR_STATS 0x0F
-#define TI_CMD_SET_RX_JUMBO_PROD_IDX 0x10 /* obsolete */
-#define TI_CMD_RFRSH_STATS 0x11
-
-#define TI_CMD_EXT_ADD_MCAST 0x12
-#define TI_CMD_EXT_DEL_MCAST 0x13
-
-/*
- * Utility macros to make issuing commands a little simpler. Assumes
- * that 'sc' and 'cmd' are in local scope.
- */
-#define TI_DO_CMD(x, y, z) \
- cmd.ti_cmd = x; \
- cmd.ti_code = y; \
- cmd.ti_idx = z; \
- ti_cmd(sc, &cmd);
-
-#define TI_DO_CMD_EXT(x, y, z, v, w) \
- cmd.ti_cmd = x; \
- cmd.ti_code = y; \
- cmd.ti_idx = z; \
- ti_cmd_ext(sc, &cmd, v, w);
-
-/*
- * Other utility macros.
- */
-#define TI_INC(x, y) (x) = (x + 1) % y
-
-#define TI_UPDATE_JUMBOPROD(x, y) \
- if (x->ti_hwrev == TI_HWREV_TIGON) { \
- TI_DO_CMD(TI_CMD_SET_RX_JUMBO_PROD_IDX, 0, y); \
- } else { \
- CSR_WRITE_4(x, TI_MB_JUMBORXPROD_IDX, y); \
- }
-
-#define TI_UPDATE_MINIPROD(x, y) \
- CSR_WRITE_4(x, TI_MB_MINIRXPROD_IDX, y);
-
-#define TI_UPDATE_STDPROD(x, y) \
- if (x->ti_hwrev == TI_HWREV_TIGON) { \
- TI_DO_CMD(TI_CMD_SET_RX_PROD_IDX, 0, y); \
- } else { \
- CSR_WRITE_4(x, TI_MB_STDRXPROD_IDX, y); \
- }
-
-
-/*
- * Tigon event structure.
- */
-struct ti_event_desc {
-#if BYTE_ORDER == BIG_ENDIAN
- u_int32_t ti_event:8;
- u_int32_t ti_code:12;
- u_int32_t ti_idx:12;
-#else
- u_int32_t ti_idx:12;
- u_int32_t ti_code:12;
- u_int32_t ti_event:8;
-#endif
- u_int32_t ti_rsvd;
-};
-
-/*
- * Tigon events.
- */
-#define TI_EV_FIRMWARE_UP 0x01
-#define TI_EV_STATS_UPDATED 0x04
-
-#define TI_EV_LINKSTAT_CHANGED 0x06
-#define TI_EV_CODE_GIG_LINK_UP 0x01
-#define TI_EV_CODE_LINK_DOWN 0x02
-#define TI_EV_CODE_LINK_UP 0x03
-
-#define TI_EV_ERROR 0x07
-#define TI_EV_CODE_ERR_INVAL_CMD 0x01
-#define TI_EV_CODE_ERR_UNIMP_CMD 0x02
-#define TI_EV_CODE_ERR_BADCFG 0x03
-
-#define TI_EV_MCAST_UPDATED 0x08
-#define TI_EV_CODE_MCAST_ADD 0x01
-#define TI_EV_CODE_MCAST_DEL 0x02
-
-#define TI_EV_RESET_JUMBO_RING 0x09
-/*
- * Register access macros. The Tigon always uses memory mapped register
- * accesses and all registers must be accessed with 32 bit operations.
- */
-
-#define CSR_WRITE_4(sc, reg, val) \
- bus_space_write_4(sc->ti_btag, sc->ti_bhandle, reg, val)
-
-#define CSR_READ_4(sc, reg) \
- bus_space_read_4(sc->ti_btag, sc->ti_bhandle, reg)
-
-#define TI_SETBIT(sc, reg, x) \
- CSR_WRITE_4(sc, reg, (CSR_READ_4(sc, reg) | x))
-#define TI_CLRBIT(sc, reg, x) \
- CSR_WRITE_4(sc, reg, (CSR_READ_4(sc, reg) & ~x))
-
-/*
- * Memory management stuff. Note: the SSLOTS, MSLOTS and JSLOTS
- * values are tuneable. They control the actual amount of buffers
- * allocated for the standard, mini and jumbo receive rings.
- */
-
-#define TI_SSLOTS 256
-#define TI_MSLOTS 256
-#define TI_JSLOTS 256
-
-#define TI_JRAWLEN (TI_JUMBO_FRAMELEN + ETHER_ALIGN + sizeof(u_int64_t))
-#define TI_JLEN (TI_JRAWLEN + (sizeof(u_int64_t) - \
- (TI_JRAWLEN % sizeof(u_int64_t))))
-#define TI_JPAGESZ PAGE_SIZE
-#define TI_RESID (TI_JPAGESZ - (TI_JLEN * TI_JSLOTS) % TI_JPAGESZ)
-#define TI_JMEM ((TI_JLEN * TI_JSLOTS) + TI_RESID)
-
-struct ti_jslot {
- caddr_t ti_buf;
- int ti_inuse;
-};
-
-/*
- * Ring structures. Most of these reside in host memory and we tell
- * the NIC where they are via the ring control blocks. The exceptions
- * are the tx and command rings, which live in NIC memory and which
- * we access via the shared memory window.
- */
-struct ti_ring_data {
- struct ti_rx_desc ti_rx_std_ring[TI_STD_RX_RING_CNT];
- struct ti_rx_desc ti_rx_jumbo_ring[TI_JUMBO_RX_RING_CNT];
- struct ti_rx_desc ti_rx_mini_ring[TI_MINI_RX_RING_CNT];
- struct ti_rx_desc ti_rx_return_ring[TI_RETURN_RING_CNT];
- struct ti_event_desc ti_event_ring[TI_EVENT_RING_CNT];
- struct ti_tx_desc ti_tx_ring[TI_TX_RING_CNT];
- /*
- * Make sure producer structures are aligned on 32-byte cache
- * line boundaries.
- */
- struct ti_producer ti_ev_prodidx_r;
- u_int32_t ti_pad0[6];
- struct ti_producer ti_return_prodidx_r;
- u_int32_t ti_pad1[6];
- struct ti_producer ti_tx_considx_r;
- u_int32_t ti_pad2[6];
- struct ti_tx_desc *ti_tx_ring_nic;/* pointer to shared mem */
- struct ti_cmd_desc *ti_cmd_ring; /* pointer to shared mem */
- struct ti_gib ti_info;
-};
-
-/*
- * Mbuf pointers. We need these to keep track of the virtual addresses
- * of our mbuf chains since we can only convert from physical to virtual,
- * not the other way around.
- */
-struct ti_chain_data {
- struct mbuf *ti_tx_chain[TI_TX_RING_CNT];
- struct mbuf *ti_rx_std_chain[TI_STD_RX_RING_CNT];
- struct mbuf *ti_rx_jumbo_chain[TI_JUMBO_RX_RING_CNT];
- struct mbuf *ti_rx_mini_chain[TI_MINI_RX_RING_CNT];
- /* Stick the jumbo mem management stuff here too. */
- struct ti_jslot ti_jslots[TI_JSLOTS];
- void *ti_jumbo_buf;
-};
-
-struct ti_type {
- u_int16_t ti_vid;
- u_int16_t ti_did;
- char *ti_name;
-};
-
-#define TI_HWREV_TIGON 0x01
-#define TI_HWREV_TIGON_II 0x02
-#define TI_TIMEOUT 1000
-#define TI_TXCONS_UNSET 0xFFFF /* impossible value */
-
-struct ti_mc_entry {
- struct ether_addr mc_addr;
- SLIST_ENTRY(ti_mc_entry) mc_entries;
-};
-
-struct ti_jpool_entry {
- int slot;
- SLIST_ENTRY(ti_jpool_entry) jpool_entries;
-};
-
-struct ti_softc {
- struct arpcom arpcom; /* interface info */
- bus_space_handle_t ti_bhandle;
- vm_offset_t ti_vhandle;
- bus_space_tag_t ti_btag;
- void *ti_intrhand;
- struct resource *ti_irq;
- struct resource *ti_res;
- struct ifmedia ifmedia; /* media info */
- u_int8_t ti_unit; /* interface number */
- u_int8_t ti_hwrev; /* Tigon rev (1 or 2) */
- u_int8_t ti_linkstat; /* Link state */
- struct ti_ring_data *ti_rdata; /* rings */
- struct ti_chain_data ti_cdata; /* mbufs */
-#define ti_ev_prodidx ti_rdata->ti_ev_prodidx_r
-#define ti_return_prodidx ti_rdata->ti_return_prodidx_r
-#define ti_tx_considx ti_rdata->ti_tx_considx_r
- u_int16_t ti_tx_saved_considx;
- u_int16_t ti_rx_saved_considx;
- u_int16_t ti_ev_saved_considx;
- u_int16_t ti_cmd_saved_prodidx;
- u_int16_t ti_std; /* current std ring head */
- u_int16_t ti_mini; /* current mini ring head */
- u_int16_t ti_jumbo; /* current jumo ring head */
- SLIST_HEAD(__ti_mchead, ti_mc_entry) ti_mc_listhead;
- SLIST_HEAD(__ti_jfreehead, ti_jpool_entry) ti_jfree_listhead;
- SLIST_HEAD(__ti_jinusehead, ti_jpool_entry) ti_jinuse_listhead;
- u_int32_t ti_stat_ticks;
- u_int32_t ti_rx_coal_ticks;
- u_int32_t ti_tx_coal_ticks;
- u_int32_t ti_rx_max_coal_bds;
- u_int32_t ti_tx_max_coal_bds;
- u_int32_t ti_tx_buf_ratio;
- int ti_if_flags;
- int ti_txcnt;
-};
-
-/*
- * Microchip Technology 24Cxx EEPROM control bytes
- */
-#define EEPROM_CTL_READ 0xA1 /* 0101 0001 */
-#define EEPROM_CTL_WRITE 0xA0 /* 0101 0000 */
-
-/*
- * Note that EEPROM_START leaves transmission enabled.
- */
-#define EEPROM_START \
- TI_SETBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_CLK); /* Pull clock pin high */\
- TI_SETBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_DOUT); /* Set DATA bit to 1 */ \
- TI_SETBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_TXEN); /* Enable xmit to write bit */\
- TI_CLRBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_DOUT); /* Pull DATA bit to 0 again */\
- TI_CLRBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_CLK); /* Pull clock low again */
-
-/*
- * EEPROM_STOP ends access to the EEPROM and clears the ETXEN bit so
- * that no further data can be written to the EEPROM I/O pin.
- */
-#define EEPROM_STOP \
- TI_CLRBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_TXEN); /* Disable xmit */ \
- TI_CLRBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_DOUT); /* Pull DATA to 0 */ \
- TI_SETBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_CLK); /* Pull clock high */ \
- TI_SETBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_TXEN); /* Enable xmit */ \
- TI_SETBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_DOUT); /* Toggle DATA to 1 */ \
- TI_CLRBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_TXEN); /* Disable xmit. */ \
- TI_CLRBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_CLK); /* Pull clock low again */
-
-
-#ifdef __alpha__
-#undef vtophys
-#define vtophys(va) alpha_XXX_dmamap((vm_offset_t)va)
-#endif
diff --git a/sys/dev/ti/ti_fw.h b/sys/dev/ti/ti_fw.h
deleted file mode 100644
index f60becbb0336..000000000000
--- a/sys/dev/ti/ti_fw.h
+++ /dev/null
@@ -1,4487 +0,0 @@
-/*
- * Firmware for Alteon Tigon 1 chip.
- * Generated by genfw.c
- *
- * $FreeBSD$
- */
-static int tigonFwReleaseMajor = 0xc;
-static int tigonFwReleaseMinor = 0x3;
-static int tigonFwReleaseFix = 0x12;
-static u_int32_t tigonFwStartAddr = 0x00004000;
-static u_int32_t tigonFwTextAddr = 0x00004000;
-static int tigonFwTextLen = 0x10ad0;
-static u_int32_t tigonFwRodataAddr = 0x00014ad0;
-static int tigonFwRodataLen = 0xaa0;
-static u_int32_t tigonFwDataAddr = 0x000155a0;
-static int tigonFwDataLen = 0x160;
-static u_int32_t tigonFwSbssAddr = 0x00015700;
-static int tigonFwSbssLen = 0x2c;
-static u_int32_t tigonFwBssAddr = 0x00015730;
-static int tigonFwBssLen = 0x2080;
-static u_int32_t tigonFwText[] = {
-0x10000003,
-0x0, 0xd, 0xd, 0x3c1d0001,
-0x8fbd55d4, 0x3a0f021, 0x3c100000, 0x26104000,
-0xc00100c, 0x0, 0xd, 0x27bdffd8,
-0x3c1cc000, 0x3c1b0013, 0x377bd800, 0xd021,
-0x3c170013, 0x36f75418, 0x2e02021, 0x340583e8,
-0xafbf0024, 0xc002488, 0xafb00020, 0xc0023e8,
-0x0, 0x3c040001, 0x24844b34, 0x24050001,
-0x2e03021, 0x3821, 0x3c100001, 0x261077b0,
-0xafb00010, 0xc002403, 0xafbb0014, 0x3c02000f,
-0x3442ffff, 0x2021024, 0x362102b, 0x10400009,
-0x24050003, 0x3c040001, 0x24844b40, 0x2003021,
-0x3603821, 0x3c020010, 0xafa20010, 0xc002403,
-0xafa00014, 0x2021, 0x3405c000, 0x3c010001,
-0x370821, 0xa02083b0, 0x3c010001, 0x370821,
-0xa02083b2, 0x3c010001, 0x370821, 0xa02083b3,
-0x3c010001, 0x370821, 0xac2083b4, 0xa2e004d8,
-0x418c0, 0x24840001, 0x771021, 0xac40727c,
-0x771021, 0xac407280, 0x2e31021, 0xa445727c,
-0x2c820020, 0x1440fff7, 0x418c0, 0x2021,
-0x3405c000, 0x418c0, 0x24840001, 0x771021,
-0xac40737c, 0x771021, 0xac407380, 0x2e31021,
-0xa445737c, 0x2c820080, 0x5440fff7, 0x418c0,
-0xaf800054, 0xaf80011c, 0x8f820044, 0x34420040,
-0xaf820044, 0x8f820044, 0x34420020, 0xaf820044,
-0x8f420218, 0x30420002, 0x10400009, 0x0,
-0x8f420220, 0x3c030002, 0x34630004, 0x431025,
-0xaee204c4, 0x8f42021c, 0x8001074, 0x34420004,
-0x8f420220, 0x3c030002, 0x34630006, 0x431025,
-0xaee204c4, 0x8f42021c, 0x34420006, 0xaee204cc,
-0x8f420218, 0x30420010, 0x1040000a, 0x0,
-0x8f42021c, 0x34420004, 0xaee204c8, 0x8f420220,
-0x3c03000a, 0x34630004, 0x431025, 0x800108a,
-0xaee204c0, 0x8f420220, 0x3c03000a, 0x34630006,
-0x431025, 0xaee204c0, 0x8f42021c, 0x34420006,
-0xaee204c8, 0x8f420218, 0x30420200, 0x10400003,
-0x24020001, 0x8001091, 0xa2e27248, 0xa2e07248,
-0x24020001, 0xaf8200a0, 0xaf8200b0, 0x8f830054,
-0x8f820054, 0x8001099, 0x24630064, 0x8f820054,
-0x621023, 0x2c420065, 0x1440fffc, 0x0,
-0xaf800044, 0x8f420208, 0x8f43020c, 0xaee20010,
-0xaee30014, 0x8ee40010, 0x8ee50014, 0x26e20030,
-0xaee20028, 0x24020490, 0xaee20018, 0xaf840090,
-0xaf850094, 0x8ee20028, 0xaf8200b4, 0x96e2001a,
-0xaf82009c, 0x8f8200b0, 0x8ee304cc, 0x431025,
-0xaf8200b0, 0x8f8200b0, 0x30420004, 0x1440fffd,
-0x0, 0x8ee20450, 0x8ee30454, 0xaee304fc,
-0x8ee204fc, 0x2442e000, 0x2c422001, 0x1440000d,
-0x26e40030, 0x8ee20450, 0x8ee30454, 0x3c040001,
-0x24844b4c, 0x3c050001, 0xafa00010, 0xafa00014,
-0x8ee704fc, 0x34a5f000, 0xc002403, 0x603021,
-0x26e40030, 0xc002488, 0x24050400, 0x27440080,
-0xc002488, 0x24050080, 0x26e4777c, 0xc002488,
-0x24050400, 0x8f42025c, 0x26e40094, 0xaee20060,
-0x8f420260, 0x27450200, 0x24060008, 0xaee20068,
-0x24020006, 0xc00249a, 0xaee20064, 0x3c023b9a,
-0x3442ca00, 0x2021, 0x24030002, 0xaee30074,
-0xaee30070, 0xaee2006c, 0x240203e8, 0xaee20104,
-0x24020001, 0xaee30100, 0xaee2010c, 0x3c030001,
-0x641821, 0x906355a0, 0x2e41021, 0x24840001,
-0xa043009c, 0x2c82000f, 0x1440fff8, 0x0,
-0x8f820040, 0x2e41821, 0x24840001, 0x21702,
-0x24420030, 0xa062009c, 0x2e41021, 0xa040009c,
-0x96e2046a, 0x30420003, 0x14400009, 0x0,
-0x96e2047a, 0x30420003, 0x50400131, 0x3c030800,
-0x96e2046a, 0x30420003, 0x1040002a, 0x3c020700,
-0x96e2047a, 0x30420003, 0x10400026, 0x3c020700,
-0x96e3047a, 0x96e2046a, 0x14620022, 0x3c020700,
-0x8ee204c0, 0x24030001, 0xa2e34e20, 0x34420e00,
-0xaee204c0, 0x8f420218, 0x30420100, 0x10400005,
-0x0, 0x3c020001, 0x2442e168, 0x800111d,
-0x21100, 0x3c020001, 0x2442d35c, 0x21100,
-0x21182, 0x3c030800, 0x431025, 0x3c010001,
-0xac221238, 0x3c020001, 0x2442f680, 0x21100,
-0x21182, 0x3c030800, 0x431025, 0x3c010001,
-0xac221278, 0x8ee20000, 0x34424000, 0x8001238,
-0xaee20000, 0x34423000, 0xafa20018, 0x8ee20608,
-0x8f430228, 0x24420001, 0x304900ff, 0x512300e2,
-0xafa00010, 0x8ee20608, 0x210c0, 0x571021,
-0x8fa30018, 0x8fa4001c, 0xac43060c, 0xac440610,
-0x8f870120, 0x27623800, 0x24e80020, 0x102102b,
-0x50400001, 0x27683000, 0x8f820128, 0x11020004,
-0x0, 0x8f820124, 0x15020007, 0x1021,
-0x8ee201a4, 0x3021, 0x24420001, 0xaee201a4,
-0x80011a0, 0x8ee201a4, 0x8ee40608, 0x420c0,
-0x801821, 0x8ee40430, 0x8ee50434, 0xa32821,
-0xa3302b, 0x822021, 0x862021, 0xace40000,
-0xace50004, 0x8ee30608, 0x24020008, 0xa4e2000e,
-0x2402000d, 0xace20018, 0xace9001c, 0x318c0,
-0x2463060c, 0x2e31021, 0xace20008, 0x8ee204c4,
-0xace20010, 0xaf880120, 0x92e24e20, 0x14400037,
-0x24060001, 0x8ee24e30, 0x210c0, 0x24425038,
-0x2e22021, 0x8c830000, 0x24020007, 0x1462001f,
-0x0, 0x8ee34e30, 0x8ee24e34, 0x1062001b,
-0x24030040, 0x8c820004, 0x24420001, 0xac820004,
-0x8ee24e34, 0x8ee54e30, 0x24420001, 0x10430007,
-0x0, 0x8ee24e34, 0x24420001, 0x10a20005,
-0x0, 0x800118a, 0x0, 0x14a00005,
-0x0, 0x8f820128, 0x24420020, 0xaf820128,
-0x8f820128, 0x8c820004, 0x2c420011, 0x50400013,
-0xac800000, 0x80011a0, 0x0, 0x8ee24e30,
-0x24030040, 0x24420001, 0x50430003, 0x1021,
-0x8ee24e30, 0x24420001, 0xaee24e30, 0x8ee24e30,
-0x210c0, 0x24425038, 0x2e22021, 0x24020007,
-0xac820000, 0x24020001, 0xac820004, 0x54c0000c,
-0xaee90608, 0x3c040001, 0x24844b58, 0xafa00010,
-0xafa00014, 0x8ee60608, 0x8f470228, 0x3c050009,
-0xc002403, 0x34a5f000, 0x8001223, 0x0,
-0x8f830120, 0x27623800, 0x24660020, 0xc2102b,
-0x50400001, 0x27663000, 0x8f820128, 0x10c20004,
-0x0, 0x8f820124, 0x14c20007, 0x0,
-0x8ee201a4, 0x3021, 0x24420001, 0xaee201a4,
-0x8001207, 0x8ee201a4, 0x8ee20608, 0xac62001c,
-0x8ee404a0, 0x8ee504a4, 0x2462001c, 0xac620008,
-0x24020008, 0xa462000e, 0x24020011, 0xac620018,
-0xac640000, 0xac650004, 0x8ee204c4, 0xac620010,
-0xaf860120, 0x92e24e20, 0x14400037, 0x24060001,
-0x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
-0x8c830000, 0x24020012, 0x1462001f, 0x0,
-0x8ee34e30, 0x8ee24e34, 0x1062001b, 0x24030040,
-0x8c820004, 0x24420001, 0xac820004, 0x8ee24e34,
-0x8ee54e30, 0x24420001, 0x10430007, 0x0,
-0x8ee24e34, 0x24420001, 0x10a20005, 0x0,
-0x80011f1, 0x0, 0x14a00005, 0x0,
-0x8f820128, 0x24420020, 0xaf820128, 0x8f820128,
-0x8c820004, 0x2c420011, 0x50400013, 0xac800000,
-0x8001207, 0x0, 0x8ee24e30, 0x24030040,
-0x24420001, 0x50430003, 0x1021, 0x8ee24e30,
-0x24420001, 0xaee24e30, 0x8ee24e30, 0x210c0,
-0x24425038, 0x2e22021, 0x24020012, 0xac820000,
-0x24020001, 0xac820004, 0x14c0001b, 0x0,
-0x3c040001, 0x24844b60, 0xafa00010, 0xafa00014,
-0x8ee60608, 0x8f470228, 0x3c050009, 0xc002403,
-0x34a5f001, 0x8ee201b0, 0x24420001, 0xaee201b0,
-0x8001223, 0x8ee201b0, 0x3c040001, 0x24844b6c,
-0xafa00014, 0x8ee60608, 0x8f470228, 0x3c050009,
-0xc002403, 0x34a5f005, 0x8ee201ac, 0x24420001,
-0xaee201ac, 0x8ee201ac, 0x8ee20160, 0x3c040001,
-0x24844b78, 0x3405f001, 0x24420001, 0xaee20160,
-0x8ee20160, 0x3021, 0x3821, 0xafa00010,
-0xc002403, 0xafa00014, 0x8001238, 0x0,
-0x3c020001, 0x2442f5a8, 0x21100, 0x21182,
-0x431025, 0x3c010001, 0xac221278, 0x96e2045a,
-0x30420003, 0x10400025, 0x3c050fff, 0x8ee204c8,
-0x34a5ffff, 0x34420a00, 0xaee204c8, 0x8ee304c8,
-0x3c040001, 0x24844b84, 0x24020001, 0xa2e204ec,
-0xa2e204ed, 0x3c020002, 0x621825, 0x3c020001,
-0x2442a390, 0x451024, 0x21082, 0xaee304c8,
-0x3c030800, 0x431025, 0x3c010001, 0xac221220,
-0x3c020001, 0x2442add4, 0x451024, 0x21082,
-0x431025, 0x3c010001, 0xac221280, 0x96e6045a,
-0x3821, 0x24050011, 0xafa00010, 0xc002403,
-0xafa00014, 0x8001268, 0x0, 0x3c020001,
-0x2442a9d4, 0x21100, 0x21182, 0x3c030800,
-0x431025, 0x3c010001, 0xac221280, 0x96e2046a,
-0x30420010, 0x14400009, 0x0, 0x96e2047a,
-0x30420010, 0x10400112, 0x0, 0x96e2046a,
-0x30420010, 0x10400005, 0x3c020700, 0x96e2047a,
-0x30420010, 0x14400102, 0x3c020700, 0x34423000,
-0xafa20018, 0x8ee20608, 0x8f430228, 0x24420001,
-0x304900ff, 0x512300e2, 0xafa00010, 0x8ee20608,
-0x210c0, 0x571021, 0x8fa30018, 0x8fa4001c,
-0xac43060c, 0xac440610, 0x8f870120, 0x27623800,
-0x24e80020, 0x102102b, 0x50400001, 0x27683000,
-0x8f820128, 0x11020004, 0x0, 0x8f820124,
-0x15020007, 0x1021, 0x8ee201a4, 0x3021,
-0x24420001, 0xaee201a4, 0x80012ea, 0x8ee201a4,
-0x8ee40608, 0x420c0, 0x801821, 0x8ee40430,
-0x8ee50434, 0xa32821, 0xa3302b, 0x822021,
-0x862021, 0xace40000, 0xace50004, 0x8ee30608,
-0x24020008, 0xa4e2000e, 0x2402000d, 0xace20018,
-0xace9001c, 0x318c0, 0x2463060c, 0x2e31021,
-0xace20008, 0x8ee204c4, 0xace20010, 0xaf880120,
-0x92e24e20, 0x14400037, 0x24060001, 0x8ee24e30,
-0x210c0, 0x24425038, 0x2e22021, 0x8c830000,
-0x24020007, 0x1462001f, 0x0, 0x8ee34e30,
-0x8ee24e34, 0x1062001b, 0x24030040, 0x8c820004,
-0x24420001, 0xac820004, 0x8ee24e34, 0x8ee54e30,
-0x24420001, 0x10430007, 0x0, 0x8ee24e34,
-0x24420001, 0x10a20005, 0x0, 0x80012d4,
-0x0, 0x14a00005, 0x0, 0x8f820128,
-0x24420020, 0xaf820128, 0x8f820128, 0x8c820004,
-0x2c420011, 0x50400013, 0xac800000, 0x80012ea,
-0x0, 0x8ee24e30, 0x24030040, 0x24420001,
-0x50430003, 0x1021, 0x8ee24e30, 0x24420001,
-0xaee24e30, 0x8ee24e30, 0x210c0, 0x24425038,
-0x2e22021, 0x24020007, 0xac820000, 0x24020001,
-0xac820004, 0x54c0000c, 0xaee90608, 0x3c040001,
-0x24844b58, 0xafa00010, 0xafa00014, 0x8ee60608,
-0x8f470228, 0x3c050009, 0xc002403, 0x34a5f000,
-0x800136d, 0x0, 0x8f830120, 0x27623800,
-0x24660020, 0xc2102b, 0x50400001, 0x27663000,
-0x8f820128, 0x10c20004, 0x0, 0x8f820124,
-0x14c20007, 0x0, 0x8ee201a4, 0x3021,
-0x24420001, 0xaee201a4, 0x8001351, 0x8ee201a4,
-0x8ee20608, 0xac62001c, 0x8ee404a0, 0x8ee504a4,
-0x2462001c, 0xac620008, 0x24020008, 0xa462000e,
-0x24020011, 0xac620018, 0xac640000, 0xac650004,
-0x8ee204c4, 0xac620010, 0xaf860120, 0x92e24e20,
-0x14400037, 0x24060001, 0x8ee24e30, 0x210c0,
-0x24425038, 0x2e22021, 0x8c830000, 0x24020012,
-0x1462001f, 0x0, 0x8ee34e30, 0x8ee24e34,
-0x1062001b, 0x24030040, 0x8c820004, 0x24420001,
-0xac820004, 0x8ee24e34, 0x8ee54e30, 0x24420001,
-0x10430007, 0x0, 0x8ee24e34, 0x24420001,
-0x10a20005, 0x0, 0x800133b, 0x0,
-0x14a00005, 0x0, 0x8f820128, 0x24420020,
-0xaf820128, 0x8f820128, 0x8c820004, 0x2c420011,
-0x50400013, 0xac800000, 0x8001351, 0x0,
-0x8ee24e30, 0x24030040, 0x24420001, 0x50430003,
-0x1021, 0x8ee24e30, 0x24420001, 0xaee24e30,
-0x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
-0x24020012, 0xac820000, 0x24020001, 0xac820004,
-0x14c0001b, 0x0, 0x3c040001, 0x24844b60,
-0xafa00010, 0xafa00014, 0x8ee60608, 0x8f470228,
-0x3c050009, 0xc002403, 0x34a5f001, 0x8ee201b0,
-0x24420001, 0xaee201b0, 0x800136d, 0x8ee201b0,
-0x3c040001, 0x24844b6c, 0xafa00014, 0x8ee60608,
-0x8f470228, 0x3c050009, 0xc002403, 0x34a5f005,
-0x8ee201ac, 0x24420001, 0xaee201ac, 0x8ee201ac,
-0x8ee20160, 0x3c040001, 0x24844b78, 0x3405f002,
-0x24420001, 0xaee20160, 0x8ee20160, 0x3021,
-0x3821, 0xafa00010, 0xc002403, 0xafa00014,
-0x96e6047a, 0x96e7046a, 0x3c040001, 0x24844b90,
-0x24050012, 0xafa00010, 0xc002403, 0xafa00014,
-0xc004500, 0x0, 0xc002318, 0x0,
-0x3c060001, 0x34c63800, 0xaee00608, 0xaf400228,
-0xaf40022c, 0x96e30458, 0x8ee40000, 0x3c0512d8,
-0x34a5c358, 0x27623800, 0xaee27258, 0x27623800,
-0xaee27260, 0x27623800, 0xaee27264, 0x3661021,
-0xaee27270, 0x2402ffff, 0xaee004d4, 0xaee004e0,
-0xaee004e4, 0xaee004f0, 0xa2e004f4, 0xaee00e0c,
-0xaee00e18, 0xaee00e10, 0xaee00e14, 0xaee00e1c,
-0xaee0724c, 0xaee05244, 0xaee05240, 0xaee0523c,
-0xaee07250, 0xaee07254, 0xaee0725c, 0xaee07268,
-0xaee004d0, 0x2463ffff, 0x852025, 0xaee304f8,
-0xaee40000, 0xaf800060, 0xaf820064, 0x3c020100,
-0xafa20018, 0x8ee20608, 0x8f430228, 0x24420001,
-0x304900ff, 0x512300e2, 0xafa00010, 0x8ee20608,
-0x210c0, 0x571021, 0x8fa30018, 0x8fa4001c,
-0xac43060c, 0xac440610, 0x8f870120, 0x27623800,
-0x24e80020, 0x102102b, 0x50400001, 0x27683000,
-0x8f820128, 0x11020004, 0x0, 0x8f820124,
-0x15020007, 0x1021, 0x8ee201a4, 0x3021,
-0x24420001, 0xaee201a4, 0x8001422, 0x8ee201a4,
-0x8ee40608, 0x420c0, 0x801821, 0x8ee40430,
-0x8ee50434, 0xa32821, 0xa3302b, 0x822021,
-0x862021, 0xace40000, 0xace50004, 0x8ee30608,
-0x24020008, 0xa4e2000e, 0x2402000d, 0xace20018,
-0xace9001c, 0x318c0, 0x2463060c, 0x2e31021,
-0xace20008, 0x8ee204c4, 0xace20010, 0xaf880120,
-0x92e24e20, 0x14400037, 0x24060001, 0x8ee24e30,
-0x210c0, 0x24425038, 0x2e22021, 0x8c830000,
-0x24020007, 0x1462001f, 0x0, 0x8ee34e30,
-0x8ee24e34, 0x1062001b, 0x24030040, 0x8c820004,
-0x24420001, 0xac820004, 0x8ee24e34, 0x8ee54e30,
-0x24420001, 0x10430007, 0x0, 0x8ee24e34,
-0x24420001, 0x10a20005, 0x0, 0x800140c,
-0x0, 0x14a00005, 0x0, 0x8f820128,
-0x24420020, 0xaf820128, 0x8f820128, 0x8c820004,
-0x2c420011, 0x50400013, 0xac800000, 0x8001422,
-0x0, 0x8ee24e30, 0x24030040, 0x24420001,
-0x50430003, 0x1021, 0x8ee24e30, 0x24420001,
-0xaee24e30, 0x8ee24e30, 0x210c0, 0x24425038,
-0x2e22021, 0x24020007, 0xac820000, 0x24020001,
-0xac820004, 0x54c0000c, 0xaee90608, 0x3c040001,
-0x24844b58, 0xafa00010, 0xafa00014, 0x8ee60608,
-0x8f470228, 0x3c050009, 0xc002403, 0x34a5f000,
-0x80014a5, 0x0, 0x8f830120, 0x27623800,
-0x24660020, 0xc2102b, 0x50400001, 0x27663000,
-0x8f820128, 0x10c20004, 0x0, 0x8f820124,
-0x14c20007, 0x0, 0x8ee201a4, 0x3021,
-0x24420001, 0xaee201a4, 0x8001489, 0x8ee201a4,
-0x8ee20608, 0xac62001c, 0x8ee404a0, 0x8ee504a4,
-0x2462001c, 0xac620008, 0x24020008, 0xa462000e,
-0x24020011, 0xac620018, 0xac640000, 0xac650004,
-0x8ee204c4, 0xac620010, 0xaf860120, 0x92e24e20,
-0x14400037, 0x24060001, 0x8ee24e30, 0x210c0,
-0x24425038, 0x2e22021, 0x8c830000, 0x24020012,
-0x1462001f, 0x0, 0x8ee34e30, 0x8ee24e34,
-0x1062001b, 0x24030040, 0x8c820004, 0x24420001,
-0xac820004, 0x8ee24e34, 0x8ee54e30, 0x24420001,
-0x10430007, 0x0, 0x8ee24e34, 0x24420001,
-0x10a20005, 0x0, 0x8001473, 0x0,
-0x14a00005, 0x0, 0x8f820128, 0x24420020,
-0xaf820128, 0x8f820128, 0x8c820004, 0x2c420011,
-0x50400013, 0xac800000, 0x8001489, 0x0,
-0x8ee24e30, 0x24030040, 0x24420001, 0x50430003,
-0x1021, 0x8ee24e30, 0x24420001, 0xaee24e30,
-0x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
-0x24020012, 0xac820000, 0x24020001, 0xac820004,
-0x14c0001b, 0x0, 0x3c040001, 0x24844b60,
-0xafa00010, 0xafa00014, 0x8ee60608, 0x8f470228,
-0x3c050009, 0xc002403, 0x34a5f001, 0x8ee201b0,
-0x24420001, 0xaee201b0, 0x80014a5, 0x8ee201b0,
-0x3c040001, 0x24844b6c, 0xafa00014, 0x8ee60608,
-0x8f470228, 0x3c050009, 0xc002403, 0x34a5f005,
-0x8ee201ac, 0x24420001, 0xaee201ac, 0x8ee201ac,
-0x8ee20154, 0x24420001, 0xaee20154, 0xc0014dc,
-0x8ee20154, 0x8f8200a0, 0x30420004, 0x1440fffd,
-0x0, 0x8f820040, 0x30420001, 0x14400008,
-0x0, 0x8f430104, 0x24020001, 0x10620004,
-0x0, 0x8f420264, 0x10400006, 0x0,
-0x8ee2017c, 0x24420001, 0xaee2017c, 0x80014c5,
-0x8ee2017c, 0x8f820044, 0x34420004, 0xaf820044,
-0x8ee20178, 0x24420001, 0xaee20178, 0x8ee20178,
-0x8f8200d8, 0x8f8300d4, 0x431023, 0xaee2726c,
-0x8ee2726c, 0x1c400003, 0x3c030001, 0x431021,
-0xaee2726c, 0xc004064, 0x0, 0xc004440,
-0xaf800228, 0x8fbf0024, 0x8fb00020, 0x3e00008,
-0x27bd0028, 0x3e00008, 0x0, 0x3e00008,
-0x0, 0x0, 0x0, 0x2402002c,
-0xaf820050, 0xaee07274, 0x8f420238, 0xaee27278,
-0x8f820054, 0x24420067, 0xaf820058, 0xaee07b88,
-0xaee07b8c, 0xaee07b84, 0x3c010001, 0x370821,
-0xac2083bc, 0x3c010001, 0x370821, 0x3e00008,
-0xa02083b9, 0x27bdffd8, 0xafbf0024, 0xafb00020,
-0x8f820054, 0x3c030001, 0x8c635658, 0x24420067,
-0x1060000d, 0xaf820058, 0x3c020001, 0x571021,
-0x904283b8, 0x10400005, 0x3c030200, 0x3c010001,
-0x370821, 0x8001503, 0xa02083b8, 0x8ee20000,
-0x431025, 0xaee20000, 0x8f420218, 0x30420100,
-0x104000c6, 0x0, 0x8f8200b0, 0x30420004,
-0x104000c2, 0x0, 0x3c030001, 0x771821,
-0x8c6383d0, 0x8f820104, 0x146200b4, 0x0,
-0x3c030001, 0x771821, 0x8c6383d4, 0x8f8200b4,
-0x146200ae, 0x0, 0x8f8200b0, 0x3c030080,
-0x431024, 0x1040000d, 0x0, 0x8f82011c,
-0x34420002, 0xaf82011c, 0x8f8200b0, 0x2403fffb,
-0x431024, 0xaf8200b0, 0x8f82011c, 0x2403fffd,
-0x431024, 0x80015cc, 0xaf82011c, 0x3c030001,
-0x771821, 0x8c6383d0, 0x8f820104, 0x14620082,
-0x0, 0x3c030001, 0x771821, 0x8c6383d4,
-0x8f8200b4, 0x1462007c, 0x0, 0x3c070001,
-0xf73821, 0x8ce783d0, 0x8f8200b0, 0x3c040001,
-0x24844c00, 0xafa00014, 0xafa20010, 0x8f8600b0,
-0x3c050005, 0xc002403, 0x34a50900, 0x8f82011c,
-0x34420002, 0xaf82011c, 0x8f830104, 0x8f8200b0,
-0x34420001, 0xaf8200b0, 0xaf830104, 0x8f830120,
-0x27623800, 0x24660020, 0xc2102b, 0x50400001,
-0x27663000, 0x8f820128, 0x10c20004, 0x0,
-0x8f820124, 0x14c20006, 0x0, 0x8ee201a4,
-0x24420001, 0xaee201a4, 0x80015a0, 0x8ee201a4,
-0x8f440208, 0x8f45020c, 0x26e20030, 0xac620008,
-0x24020400, 0xa462000e, 0x2402000f, 0xac620018,
-0xac60001c, 0xac640000, 0xac650004, 0x8ee204c4,
-0xac620010, 0xaf860120, 0x92e24e20, 0x14400037,
-0x0, 0x8ee24e30, 0x210c0, 0x24425038,
-0x2e22021, 0x8c830000, 0x24020007, 0x1462001f,
-0x0, 0x8ee34e30, 0x8ee24e34, 0x1062001b,
-0x24030040, 0x8c820004, 0x24420001, 0xac820004,
-0x8ee24e34, 0x8ee54e30, 0x24420001, 0x10430007,
-0x0, 0x8ee24e34, 0x24420001, 0x10a20005,
-0x0, 0x800158a, 0x0, 0x14a00005,
-0x0, 0x8f820128, 0x24420020, 0xaf820128,
-0x8f820128, 0x8c820004, 0x2c420011, 0x50400013,
-0xac800000, 0x80015a0, 0x0, 0x8ee24e30,
-0x24030040, 0x24420001, 0x50430003, 0x1021,
-0x8ee24e30, 0x24420001, 0xaee24e30, 0x8ee24e30,
-0x210c0, 0x24425038, 0x2e22021, 0x24020007,
-0xac820000, 0x24020001, 0xac820004, 0x8f82011c,
-0x2403fffd, 0x431024, 0xaf82011c, 0x8ee201e4,
-0x3c070001, 0xf73821, 0x8ce783d0, 0x24420001,
-0xaee201e4, 0x8ee201e4, 0x3c040001, 0x24844c0c,
-0x80015bd, 0xafa00010, 0x8f820104, 0x3c010001,
-0x370821, 0xac2283d0, 0x8f8200b4, 0x3c070001,
-0xf73821, 0x8ce783d0, 0x3c040001, 0x24844c14,
-0x3c010001, 0x370821, 0xac2283d4, 0xafa00010,
-0xafa00014, 0x8f8600b0, 0x3c050005, 0xc002403,
-0x34a50900, 0x80015cc, 0x0, 0x8f820104,
-0x3c010001, 0x370821, 0xac2283d0, 0x8f8200b4,
-0x3c010001, 0x370821, 0xac2283d4, 0x8ee27274,
-0x92e304f4, 0x24420067, 0x14600006, 0xaee27274,
-0x8ee27274, 0x8f430234, 0x43102b, 0x1440007b,
-0x0, 0x8ee304e4, 0x8ee204f8, 0x14620004,
-0x0, 0x92e204f4, 0x50400074, 0xa2e004f4,
-0x8f830120, 0x27623800, 0x24660020, 0xc2102b,
-0x50400001, 0x27663000, 0x8f820128, 0x10c20004,
-0x0, 0x8f820124, 0x14c20007, 0x0,
-0x8ee201a4, 0x8021, 0x24420001, 0xaee201a4,
-0x8001637, 0x8ee201a4, 0x8ee204e4, 0xac62001c,
-0x8ee404b0, 0x8ee504b4, 0x2462001c, 0xac620008,
-0x24020008, 0xa462000e, 0x24020011, 0xac620018,
-0xac640000, 0xac650004, 0x8ee204c4, 0xac620010,
-0xaf860120, 0x92e24e20, 0x14400037, 0x24100001,
-0x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
-0x8c830000, 0x24020012, 0x1462001f, 0x0,
-0x8ee34e30, 0x8ee24e34, 0x1062001b, 0x24030040,
-0x8c820004, 0x24420001, 0xac820004, 0x8ee24e34,
-0x8ee54e30, 0x24420001, 0x10430007, 0x0,
-0x8ee24e34, 0x24420001, 0x10a20005, 0x0,
-0x8001621, 0x0, 0x14a00005, 0x0,
-0x8f820128, 0x24420020, 0xaf820128, 0x8f820128,
-0x8c820004, 0x2c420011, 0x50400013, 0xac800000,
-0x8001637, 0x0, 0x8ee24e30, 0x24030040,
-0x24420001, 0x50430003, 0x1021, 0x8ee24e30,
-0x24420001, 0xaee24e30, 0x8ee24e30, 0x210c0,
-0x24425038, 0x2e22021, 0x24020012, 0xac820000,
-0x24020001, 0xac820004, 0x5600000b, 0x24100001,
-0x8ee204e4, 0x3c040001, 0x24844c1c, 0xafa00014,
-0xafa20010, 0x8ee60608, 0x8f470228, 0x3c050009,
-0xc002403, 0x34a5f006, 0x16000003, 0x24020001,
-0x8001650, 0xa2e204f4, 0x8ee20170, 0x24420001,
-0xaee20170, 0x8ee20170, 0x8ee204e4, 0xa2e004f4,
-0xaee004f0, 0xaee07274, 0xaee204f8, 0x8ee20e1c,
-0x1040006d, 0x0, 0x8f830120, 0x27623800,
-0x24660020, 0xc2102b, 0x50400001, 0x27663000,
-0x8f820128, 0x10c20004, 0x0, 0x8f820124,
-0x14c20007, 0x0, 0x8ee201a4, 0x8021,
-0x24420001, 0xaee201a4, 0x80016ad, 0x8ee201a4,
-0x8ee2724c, 0xac62001c, 0x8ee404a8, 0x8ee504ac,
-0x2462001c, 0xac620008, 0x24020008, 0xa462000e,
-0x24020011, 0xac620018, 0xac640000, 0xac650004,
-0x8ee204c4, 0xac620010, 0xaf860120, 0x92e24e20,
-0x14400037, 0x24100001, 0x8ee24e30, 0x210c0,
-0x24425038, 0x2e22021, 0x8c830000, 0x24020012,
-0x1462001f, 0x0, 0x8ee34e30, 0x8ee24e34,
-0x1062001b, 0x24030040, 0x8c820004, 0x24420001,
-0xac820004, 0x8ee24e34, 0x8ee54e30, 0x24420001,
-0x10430007, 0x0, 0x8ee24e34, 0x24420001,
-0x10a20005, 0x0, 0x8001697, 0x0,
-0x14a00005, 0x0, 0x8f820128, 0x24420020,
-0xaf820128, 0x8f820128, 0x8c820004, 0x2c420011,
-0x50400013, 0xac800000, 0x80016ad, 0x0,
-0x8ee24e30, 0x24030040, 0x24420001, 0x50430003,
-0x1021, 0x8ee24e30, 0x24420001, 0xaee24e30,
-0x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
-0x24020012, 0xac820000, 0x24020001, 0xac820004,
-0x5600000b, 0x24100001, 0x8ee2724c, 0x3c040001,
-0x24844c28, 0xafa00014, 0xafa20010, 0x8ee6724c,
-0x8f470280, 0x3c050009, 0xc002403, 0x34a5f008,
-0x56000001, 0xaee00e1c, 0x8ee20174, 0x24420001,
-0xaee20174, 0x8ee20174, 0x8ee24e24, 0x10400019,
-0x0, 0xaee04e24, 0x8f820040, 0x30420001,
-0x14400008, 0x0, 0x8f430104, 0x24020001,
-0x10620004, 0x0, 0x8f420264, 0x10400006,
-0x0, 0x8ee2017c, 0x24420001, 0xaee2017c,
-0x80016da, 0x8ee2017c, 0x8f820044, 0x34420004,
-0xaf820044, 0x8ee20178, 0x24420001, 0xaee20178,
-0x8ee20178, 0x8ee27278, 0x2442ff99, 0xaee27278,
-0x8ee27278, 0x1c4002ad, 0x0, 0x8f420238,
-0x104002aa, 0x0, 0x3c020001, 0x571021,
-0x904283e0, 0x144002a5, 0x0, 0x8f420080,
-0xaee2004c, 0x8f4200c0, 0xaee20048, 0x8f420084,
-0xaee20038, 0x8f420084, 0xaee20244, 0x8f420088,
-0xaee20248, 0x8f42008c, 0xaee2024c, 0x8f420090,
-0xaee20250, 0x8f420094, 0xaee20254, 0x8f420098,
-0xaee20258, 0x8f42009c, 0xaee2025c, 0x8f4200a0,
-0xaee20260, 0x8f4200a4, 0xaee20264, 0x8f4200a8,
-0xaee20268, 0x8f4200ac, 0xaee2026c, 0x8f4200b0,
-0xaee20270, 0x8f4200b4, 0xaee20274, 0x8f4200b8,
-0xaee20278, 0x8f4200bc, 0x24040001, 0xaee2027c,
-0xaee0003c, 0x41080, 0x571021, 0x8ee3003c,
-0x8c420244, 0x24840001, 0x621821, 0x2c82000f,
-0xaee3003c, 0x1440fff8, 0x41080, 0x8f4200cc,
-0xaee20050, 0x8f4200d0, 0xaee20054, 0x8f830120,
-0x27623800, 0x24660020, 0xc2102b, 0x50400001,
-0x27663000, 0x8f820128, 0x10c20004, 0x0,
-0x8f820124, 0x14c20007, 0x0, 0x8ee201a4,
-0x8021, 0x24420001, 0xaee201a4, 0x8001775,
-0x8ee201a4, 0x8f440208, 0x8f45020c, 0x26e20030,
-0xac620008, 0x24020400, 0xa462000e, 0x2402000f,
-0xac620018, 0xac60001c, 0xac640000, 0xac650004,
-0x8ee204c4, 0xac620010, 0xaf860120, 0x92e24e20,
-0x14400037, 0x24100001, 0x8ee24e30, 0x210c0,
-0x24425038, 0x2e22021, 0x8c830000, 0x24020007,
-0x1462001f, 0x0, 0x8ee34e30, 0x8ee24e34,
-0x1062001b, 0x24030040, 0x8c820004, 0x24420001,
-0xac820004, 0x8ee24e34, 0x8ee54e30, 0x24420001,
-0x10430007, 0x0, 0x8ee24e34, 0x24420001,
-0x10a20005, 0x0, 0x800175f, 0x0,
-0x14a00005, 0x0, 0x8f820128, 0x24420020,
-0xaf820128, 0x8f820128, 0x8c820004, 0x2c420011,
-0x50400013, 0xac800000, 0x8001775, 0x0,
-0x8ee24e30, 0x24030040, 0x24420001, 0x50430003,
-0x1021, 0x8ee24e30, 0x24420001, 0xaee24e30,
-0x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
-0x24020007, 0xac820000, 0x24020001, 0xac820004,
-0x12000212, 0x3c020400, 0xafa20018, 0x3c020001,
-0x571021, 0x904283b0, 0x1040010b, 0x0,
-0x8ee20608, 0x8f430228, 0x24420001, 0x304a00ff,
-0x514300fd, 0xafa00010, 0x8ee20608, 0x210c0,
-0x571021, 0x8fa30018, 0x8fa4001c, 0xac43060c,
-0xac440610, 0x8f830054, 0x8f820054, 0x24690032,
-0x1221023, 0x2c420033, 0x1040006a, 0x5821,
-0x24180008, 0x240f000d, 0x240d0007, 0x240c0040,
-0x240e0001, 0x8f870120, 0x27623800, 0x24e80020,
-0x102102b, 0x50400001, 0x27683000, 0x8f820128,
-0x11020004, 0x0, 0x8f820124, 0x15020007,
-0x1021, 0x8ee201a4, 0x8021, 0x24420001,
-0xaee201a4, 0x80017f3, 0x8ee201a4, 0x8ee40608,
-0x420c0, 0x801821, 0x8ee40430, 0x8ee50434,
-0xa32821, 0xa3302b, 0x822021, 0x862021,
-0xace40000, 0xace50004, 0x8ee20608, 0xa4f8000e,
-0xacef0018, 0xacea001c, 0x210c0, 0x2442060c,
-0x2e21021, 0xace20008, 0x8ee204c4, 0xace20010,
-0xaf880120, 0x92e24e20, 0x14400033, 0x24100001,
-0x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
-0x8c820000, 0x144d001f, 0x0, 0x8ee34e30,
-0x8ee24e34, 0x1062001b, 0x0, 0x8c820004,
-0x24420001, 0xac820004, 0x8ee24e34, 0x8ee34e30,
-0x24420001, 0x104c0007, 0x0, 0x8ee24e34,
-0x24420001, 0x10620005, 0x0, 0x80017e0,
-0x0, 0x14600005, 0x0, 0x8f820128,
-0x24420020, 0xaf820128, 0x8f820128, 0x8c820004,
-0x2c420011, 0x50400010, 0xac800000, 0x80017f3,
-0x0, 0x8ee24e30, 0x24420001, 0x504c0003,
-0x1021, 0x8ee24e30, 0x24420001, 0xaee24e30,
-0x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
-0xac8d0000, 0xac8e0004, 0x56000006, 0x240b0001,
-0x8f820054, 0x1221023, 0x2c420033, 0x1440ff9d,
-0x0, 0x316300ff, 0x24020001, 0x14620077,
-0x3c050009, 0xaeea0608, 0x8f830054, 0x8f820054,
-0x24690032, 0x1221023, 0x2c420033, 0x10400061,
-0x5821, 0x240d0008, 0x240c0011, 0x24080012,
-0x24070040, 0x240a0001, 0x8f830120, 0x27623800,
-0x24660020, 0xc2102b, 0x50400001, 0x27663000,
-0x8f820128, 0x10c20004, 0x0, 0x8f820124,
-0x14c20007, 0x0, 0x8ee201a4, 0x8021,
-0x24420001, 0xaee201a4, 0x800185f, 0x8ee201a4,
-0x8ee20608, 0xac62001c, 0x8ee404a0, 0x8ee504a4,
-0x2462001c, 0xac620008, 0xa46d000e, 0xac6c0018,
-0xac640000, 0xac650004, 0x8ee204c4, 0xac620010,
-0xaf860120, 0x92e24e20, 0x14400033, 0x24100001,
-0x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
-0x8c820000, 0x1448001f, 0x0, 0x8ee34e30,
-0x8ee24e34, 0x1062001b, 0x0, 0x8c820004,
-0x24420001, 0xac820004, 0x8ee24e34, 0x8ee34e30,
-0x24420001, 0x10470007, 0x0, 0x8ee24e34,
-0x24420001, 0x10620005, 0x0, 0x800184c,
-0x0, 0x14600005, 0x0, 0x8f820128,
-0x24420020, 0xaf820128, 0x8f820128, 0x8c820004,
-0x2c420011, 0x50400010, 0xac800000, 0x800185f,
-0x0, 0x8ee24e30, 0x24420001, 0x50470003,
-0x1021, 0x8ee24e30, 0x24420001, 0xaee24e30,
-0x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
-0xac880000, 0xac8a0004, 0x56000006, 0x240b0001,
-0x8f820054, 0x1221023, 0x2c420033, 0x1440ffa6,
-0x0, 0x316300ff, 0x24020001, 0x14620003,
-0x3c050009, 0x800197c, 0x24100001, 0x3c040001,
-0x24844c34, 0xafa00010, 0xafa00014, 0x8f860120,
-0x8f870124, 0x800187b, 0x34a5f011, 0x3c040001,
-0x24844c40, 0xafa00010, 0xafa00014, 0x8f860120,
-0x8f870124, 0x34a5f010, 0xc002403, 0x8021,
-0x800197c, 0x0, 0x3c040001, 0x24844c4c,
-0xafa00014, 0x8ee60608, 0x8f470228, 0x3c050009,
-0x8001975, 0x34a5f00f, 0x8ee20608, 0x8f430228,
-0x24420001, 0x304900ff, 0x512300e2, 0xafa00010,
-0x8ee20608, 0x210c0, 0x571021, 0x8fa30018,
-0x8fa4001c, 0xac43060c, 0xac440610, 0x8f870120,
-0x27623800, 0x24e80020, 0x102102b, 0x50400001,
-0x27683000, 0x8f820128, 0x11020004, 0x0,
-0x8f820124, 0x15020007, 0x1021, 0x8ee201a4,
-0x8021, 0x24420001, 0xaee201a4, 0x80018f7,
-0x8ee201a4, 0x8ee40608, 0x420c0, 0x801821,
-0x8ee40430, 0x8ee50434, 0xa32821, 0xa3302b,
-0x822021, 0x862021, 0xace40000, 0xace50004,
-0x8ee30608, 0x24020008, 0xa4e2000e, 0x2402000d,
-0xace20018, 0xace9001c, 0x318c0, 0x2463060c,
-0x2e31021, 0xace20008, 0x8ee204c4, 0xace20010,
-0xaf880120, 0x92e24e20, 0x14400037, 0x24100001,
-0x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
-0x8c830000, 0x24020007, 0x1462001f, 0x0,
-0x8ee34e30, 0x8ee24e34, 0x1062001b, 0x24030040,
-0x8c820004, 0x24420001, 0xac820004, 0x8ee24e34,
-0x8ee54e30, 0x24420001, 0x10430007, 0x0,
-0x8ee24e34, 0x24420001, 0x10a20005, 0x0,
-0x80018e1, 0x0, 0x14a00005, 0x0,
-0x8f820128, 0x24420020, 0xaf820128, 0x8f820128,
-0x8c820004, 0x2c420011, 0x50400013, 0xac800000,
-0x80018f7, 0x0, 0x8ee24e30, 0x24030040,
-0x24420001, 0x50430003, 0x1021, 0x8ee24e30,
-0x24420001, 0xaee24e30, 0x8ee24e30, 0x210c0,
-0x24425038, 0x2e22021, 0x24020007, 0xac820000,
-0x24020001, 0xac820004, 0x5600000c, 0xaee90608,
-0x3c040001, 0x24844c58, 0xafa00010, 0xafa00014,
-0x8ee60608, 0x8f470228, 0x3c050009, 0xc002403,
-0x34a5f000, 0x800197c, 0x0, 0x8f830120,
-0x27623800, 0x24660020, 0xc2102b, 0x50400001,
-0x27663000, 0x8f820128, 0x10c20004, 0x0,
-0x8f820124, 0x14c20007, 0x0, 0x8ee201a4,
-0x8021, 0x24420001, 0xaee201a4, 0x800195e,
-0x8ee201a4, 0x8ee20608, 0xac62001c, 0x8ee404a0,
-0x8ee504a4, 0x2462001c, 0xac620008, 0x24020008,
-0xa462000e, 0x24020011, 0xac620018, 0xac640000,
-0xac650004, 0x8ee204c4, 0xac620010, 0xaf860120,
-0x92e24e20, 0x14400037, 0x24100001, 0x8ee24e30,
-0x210c0, 0x24425038, 0x2e22021, 0x8c830000,
-0x24020012, 0x1462001f, 0x0, 0x8ee34e30,
-0x8ee24e34, 0x1062001b, 0x24030040, 0x8c820004,
-0x24420001, 0xac820004, 0x8ee24e34, 0x8ee54e30,
-0x24420001, 0x10430007, 0x0, 0x8ee24e34,
-0x24420001, 0x10a20005, 0x0, 0x8001948,
-0x0, 0x14a00005, 0x0, 0x8f820128,
-0x24420020, 0xaf820128, 0x8f820128, 0x8c820004,
-0x2c420011, 0x50400013, 0xac800000, 0x800195e,
-0x0, 0x8ee24e30, 0x24030040, 0x24420001,
-0x50430003, 0x1021, 0x8ee24e30, 0x24420001,
-0xaee24e30, 0x8ee24e30, 0x210c0, 0x24425038,
-0x2e22021, 0x24020012, 0xac820000, 0x24020001,
-0xac820004, 0x5600001d, 0x24100001, 0x3c040001,
-0x24844c60, 0xafa00010, 0xafa00014, 0x8ee60608,
-0x8f470228, 0x3c050009, 0xc002403, 0x34a5f001,
-0x8ee201b0, 0x24420001, 0xaee201b0, 0x800197c,
-0x8ee201b0, 0x3c040001, 0x24844c6c, 0xafa00014,
-0x8ee60608, 0x8f470228, 0x3c050009, 0x34a5f005,
-0xc002403, 0x0, 0x8ee201ac, 0x8021,
-0x24420001, 0xaee201ac, 0x8ee201ac, 0x1200000c,
-0x24020001, 0x3c010001, 0x370821, 0xa02083b0,
-0x8f420238, 0x8ee30158, 0x24630001, 0xaee30158,
-0x8ee30158, 0x800198c, 0xaee27278, 0x24020001,
-0x3c010001, 0x370821, 0xa02283b0, 0x3c020001,
-0x8c425658, 0x10400187, 0x0, 0x8ee27b84,
-0x24430001, 0x284200c9, 0x144001a4, 0xaee37b84,
-0x8ee204d4, 0x30420002, 0x14400119, 0xaee07b84,
-0x8ee204d4, 0x3c030600, 0x34631000, 0x34420002,
-0xaee204d4, 0xafa30018, 0x8ee20608, 0x8f430228,
-0x24420001, 0x304a00ff, 0x514300fd, 0xafa00010,
-0x8ee20608, 0x210c0, 0x571021, 0x8fa30018,
-0x8fa4001c, 0xac43060c, 0xac440610, 0x8f830054,
-0x8f820054, 0x24690032, 0x1221023, 0x2c420033,
-0x1040006a, 0x5821, 0x24180008, 0x240f000d,
-0x240d0007, 0x240c0040, 0x240e0001, 0x8f870120,
-0x27623800, 0x24e80020, 0x102102b, 0x50400001,
-0x27683000, 0x8f820128, 0x11020004, 0x0,
-0x8f820124, 0x15020007, 0x1021, 0x8ee201a4,
-0x8021, 0x24420001, 0xaee201a4, 0x8001a15,
-0x8ee201a4, 0x8ee40608, 0x420c0, 0x801821,
-0x8ee40430, 0x8ee50434, 0xa32821, 0xa3302b,
-0x822021, 0x862021, 0xace40000, 0xace50004,
-0x8ee20608, 0xa4f8000e, 0xacef0018, 0xacea001c,
-0x210c0, 0x2442060c, 0x2e21021, 0xace20008,
-0x8ee204c4, 0xace20010, 0xaf880120, 0x92e24e20,
-0x14400033, 0x24100001, 0x8ee24e30, 0x210c0,
-0x24425038, 0x2e22021, 0x8c820000, 0x144d001f,
-0x0, 0x8ee34e30, 0x8ee24e34, 0x1062001b,
-0x0, 0x8c820004, 0x24420001, 0xac820004,
-0x8ee24e34, 0x8ee34e30, 0x24420001, 0x104c0007,
-0x0, 0x8ee24e34, 0x24420001, 0x10620005,
-0x0, 0x8001a02, 0x0, 0x14600005,
-0x0, 0x8f820128, 0x24420020, 0xaf820128,
-0x8f820128, 0x8c820004, 0x2c420011, 0x50400010,
-0xac800000, 0x8001a15, 0x0, 0x8ee24e30,
-0x24420001, 0x504c0003, 0x1021, 0x8ee24e30,
-0x24420001, 0xaee24e30, 0x8ee24e30, 0x210c0,
-0x24425038, 0x2e22021, 0xac8d0000, 0xac8e0004,
-0x56000006, 0x240b0001, 0x8f820054, 0x1221023,
-0x2c420033, 0x1440ff9d, 0x0, 0x316300ff,
-0x24020001, 0x54620078, 0xafa00010, 0xaeea0608,
-0x8f830054, 0x8f820054, 0x24690032, 0x1221023,
-0x2c420033, 0x10400061, 0x5821, 0x240d0008,
-0x240c0011, 0x24080012, 0x24070040, 0x240a0001,
-0x8f830120, 0x27623800, 0x24660020, 0xc2102b,
-0x50400001, 0x27663000, 0x8f820128, 0x10c20004,
-0x0, 0x8f820124, 0x14c20007, 0x0,
-0x8ee201a4, 0x8021, 0x24420001, 0xaee201a4,
-0x8001a81, 0x8ee201a4, 0x8ee20608, 0xac62001c,
-0x8ee404a0, 0x8ee504a4, 0x2462001c, 0xac620008,
-0xa46d000e, 0xac6c0018, 0xac640000, 0xac650004,
-0x8ee204c4, 0xac620010, 0xaf860120, 0x92e24e20,
-0x14400033, 0x24100001, 0x8ee24e30, 0x210c0,
-0x24425038, 0x2e22021, 0x8c820000, 0x1448001f,
-0x0, 0x8ee34e30, 0x8ee24e34, 0x1062001b,
-0x0, 0x8c820004, 0x24420001, 0xac820004,
-0x8ee24e34, 0x8ee34e30, 0x24420001, 0x10470007,
-0x0, 0x8ee24e34, 0x24420001, 0x10620005,
-0x0, 0x8001a6e, 0x0, 0x14600005,
-0x0, 0x8f820128, 0x24420020, 0xaf820128,
-0x8f820128, 0x8c820004, 0x2c420011, 0x50400010,
-0xac800000, 0x8001a81, 0x0, 0x8ee24e30,
-0x24420001, 0x50470003, 0x1021, 0x8ee24e30,
-0x24420001, 0xaee24e30, 0x8ee24e30, 0x210c0,
-0x24425038, 0x2e22021, 0xac880000, 0xac8a0004,
-0x56000006, 0x240b0001, 0x8f820054, 0x1221023,
-0x2c420033, 0x1440ffa6, 0x0, 0x316300ff,
-0x24020001, 0x10620022, 0x0, 0x3c040001,
-0x24844c34, 0xafa00010, 0xafa00014, 0x8f860120,
-0x8f870124, 0x3c050009, 0xc002403, 0x34a5f011,
-0x8001aad, 0x0, 0x3c040001, 0x24844c40,
-0xafa00014, 0x8f860120, 0x8f870124, 0x3c050009,
-0xc002403, 0x34a5f010, 0x8001aad, 0x0,
-0x3c040001, 0x24844c4c, 0xafa00014, 0x8ee60608,
-0x8f470228, 0x3c050009, 0xc002403, 0x34a5f00f,
-0x8ee201ac, 0x24420001, 0xaee201ac, 0x8ee201ac,
-0x8ee2015c, 0x24420001, 0xaee2015c, 0x8ee2015c,
-0x8ee204d4, 0x30420001, 0x10400055, 0x0,
-0x8f420218, 0x30420080, 0x10400029, 0x0,
-0x8f820044, 0x34420040, 0xaf820044, 0x8ee27b7c,
-0x402821, 0x8ee200c0, 0x8ee300c4, 0x24060000,
-0x2407ffff, 0x2021, 0x461024, 0x1444000d,
-0x671824, 0x1465000b, 0x0, 0x8ee27b80,
-0x402821, 0x8ee200e0, 0x8ee300e4, 0x2021,
-0x461024, 0x14440003, 0x671824, 0x1065000b,
-0x0, 0x8ee200c0, 0x8ee300c4, 0x8ee400e0,
-0x8ee500e4, 0xaee37b7c, 0xaee57b80, 0x8f820044,
-0x38420020, 0x8001b38, 0xaf820044, 0x8f820044,
-0x2403ffdf, 0x431024, 0x8001b38, 0xaf820044,
-0x8f820044, 0x2403ffdf, 0x431024, 0xaf820044,
-0x8ee27b7c, 0x402821, 0x8ee200c0, 0x8ee300c4,
-0x24060000, 0x2407ffff, 0x2021, 0x461024,
-0x1444000d, 0x671824, 0x1465000b, 0x0,
-0x8ee27b80, 0x402821, 0x8ee200e0, 0x8ee300e4,
-0x2021, 0x461024, 0x14440003, 0x671824,
-0x1065000b, 0x0, 0x8ee200c0, 0x8ee300c4,
-0x8ee400e0, 0x8ee500e4, 0xaee37b7c, 0xaee57b80,
-0x8f820044, 0x38420040, 0x8001b38, 0xaf820044,
-0x8f820044, 0x34420040, 0x8001b38, 0xaf820044,
-0x8f820044, 0x34420040, 0xaf820044, 0x8ee27b8c,
-0x24430001, 0x28420015, 0x14400028, 0xaee37b8c,
-0x8f820044, 0x38420020, 0xaf820044, 0x8001b38,
-0xaee07b8c, 0x8ee204d4, 0x30420001, 0x10400011,
-0x0, 0x8f420218, 0x30420080, 0x10400009,
-0x0, 0x8f820044, 0x34420020, 0xaf820044,
-0x8f820044, 0x2403ffbf, 0x431024, 0x8001b36,
-0xaf820044, 0x8f820044, 0x34420060, 0x8001b36,
-0xaf820044, 0x8f820044, 0x34420040, 0xaf820044,
-0x8ee27b88, 0x24430001, 0x28421389, 0x14400005,
-0xaee37b88, 0x8f820044, 0x38420020, 0xaf820044,
-0xaee07b88, 0xc0045c2, 0x0, 0x8fbf0024,
-0x8fb00020, 0x3e00008, 0x27bd0028, 0x27bdffb8,
-0xafbf0044, 0xafb60040, 0xafb5003c, 0xafb40038,
-0xafb30034, 0xafb20030, 0xafb1002c, 0xafb00028,
-0x8f960064, 0x32c20004, 0x1040000c, 0x24020004,
-0xaf820064, 0x8f420114, 0xaee204e0, 0x8f820060,
-0x34420008, 0xaf820060, 0x8ee2016c, 0x24420001,
-0xaee2016c, 0x80022f4, 0x8ee2016c, 0x32c20001,
-0x10400004, 0x24020001, 0xaf820064, 0x80022f4,
-0x0, 0x32c20002, 0x1440000c, 0x3c050003,
-0x3c040001, 0x24844ce4, 0x34a50001, 0x2c03021,
-0x3821, 0xafa00010, 0xc002403, 0xafa00014,
-0x2402fff8, 0x80022f4, 0xaf820064, 0x8f43022c,
-0x8f42010c, 0x5062000c, 0xafa00010, 0x8f42022c,
-0x21080, 0x5a1021, 0x8c420300, 0xafa20020,
-0x8f42022c, 0x24070001, 0x24420001, 0x3042003f,
-0x8001b80, 0xaf42022c, 0x3c040001, 0x24844cf0,
-0xafa00014, 0x8f46022c, 0x8f47010c, 0x3c050003,
-0xc002403, 0x34a5f01f, 0x3821, 0x14e00003,
-0x0, 0x80022ed, 0xaf960064, 0x93a20020,
-0x2443ffff, 0x2c620011, 0x10400658, 0x31080,
-0x3c010001, 0x220821, 0x8c224da8, 0x400008,
-0x0, 0x8fa20020, 0x30420fff, 0xaee20e0c,
-0x8f820060, 0x34420200, 0xaf820060, 0x8ee20118,
-0x24420001, 0xaee20118, 0x80022e8, 0x8ee20118,
-0x8fa20020, 0x24030001, 0x3c010001, 0x370821,
-0xa02383b1, 0x30420fff, 0xaee25238, 0x8f820060,
-0x34420100, 0xaf820060, 0x8ee20144, 0x24420001,
-0xaee20144, 0x80022e8, 0x8ee20144, 0x8fa20020,
-0x21200, 0x22502, 0x24020001, 0x10820005,
-0x24020002, 0x10820009, 0x2402fffe, 0x8001bc9,
-0xafa00010, 0x8ee204d4, 0xaee40070, 0xaee40074,
-0x34420001, 0x8001bbd, 0xaee204d4, 0x8ee304d4,
-0xaee40070, 0xaee40074, 0x621824, 0xaee304d4,
-0x8f840054, 0x41442, 0x41c82, 0x431021,
-0x41cc2, 0x431023, 0x41d02, 0x431021,
-0x41d42, 0x431023, 0x8001bd0, 0xaee20078,
-0x3c040001, 0x24844cfc, 0xafa00014, 0x8fa60020,
-0x3c050003, 0xc002403, 0x34a50004, 0x8ee20110,
-0x24420001, 0xaee20110, 0x80022e8, 0x8ee20110,
-0x27440212, 0xc0022fe, 0x24050006, 0x3049001f,
-0x920c0, 0x2e41021, 0x9442727c, 0x30424000,
-0x1040000a, 0x971021, 0x97430212, 0xa443727e,
-0x8f430214, 0x971021, 0xac437280, 0x2e41821,
-0x34028000, 0x8001c79, 0xa462727c, 0x9443727e,
-0x97420212, 0x14620006, 0x2e41021, 0x971021,
-0x8c437280, 0x8f420214, 0x1062009f, 0x2e41021,
-0x9442727c, 0x30428000, 0x1040002a, 0x2406ffff,
-0x2021, 0x410c0, 0x2e21021, 0x9442737c,
-0x30424000, 0x54400005, 0x803021, 0x24840001,
-0x2c820080, 0x1440fff8, 0x410c0, 0x4c10010,
-0x618c0, 0x610c0, 0x571821, 0x8c63737c,
-0x571021, 0xafa30010, 0x8c427380, 0x3c040001,
-0x24844d08, 0xafa20014, 0x8f470214, 0x3c050003,
-0xc002403, 0x34a50013, 0x8001c90, 0x3c020800,
-0x97440212, 0x771021, 0xa444737e, 0x8f440214,
-0x771021, 0x2e31821, 0xac447380, 0x34028000,
-0xa462737c, 0x910c0, 0x2e21021, 0x8001c79,
-0xa446727c, 0x2e41021, 0x9445727c, 0x8001c2e,
-0x510c0, 0x9443737e, 0x97420212, 0x14620006,
-0x510c0, 0x971021, 0x8c437380, 0x8f420214,
-0x10620065, 0x510c0, 0x2e21021, 0x9445737c,
-0x510c0, 0x2e21021, 0x9442737c, 0x30428000,
-0x1040fff0, 0x971021, 0x520c0, 0x971021,
-0x9443737e, 0x97420212, 0x14620006, 0x2406ffff,
-0x971021, 0x8c437380, 0x8f420214, 0x10620053,
-0x3c020800, 0x2021, 0x410c0, 0x2e21021,
-0x9442737c, 0x30424000, 0x54400005, 0x803021,
-0x24840001, 0x2c820080, 0x1440fff8, 0x410c0,
-0x4c10023, 0x618c0, 0x910c0, 0x571821,
-0x8c63727c, 0x571021, 0xafa30010, 0x8c427280,
-0x3c040001, 0x24844d14, 0xafa20014, 0x8f470214,
-0x3c050003, 0xc002403, 0x34a5f017, 0x8001c90,
-0x3c020800, 0x8f430210, 0xb71021, 0xac43777c,
-0x8f430214, 0xb71021, 0xac437780, 0x3c020001,
-0x571021, 0x8c4283b4, 0x24420001, 0x3c010001,
-0x370821, 0xac2283b4, 0x3c030001, 0x771821,
-0x8c6383b4, 0x2e51021, 0x8001c82, 0xa443777c,
-0x97440212, 0x771021, 0xa444737e, 0x8f440214,
-0x771021, 0x2e31821, 0xac447380, 0x34028000,
-0xa462737c, 0x510c0, 0x2e21021, 0xa446737c,
-0x2021, 0x428c0, 0x2e51021, 0x9442777c,
-0x1040ffdc, 0x24840001, 0x2c820080, 0x5440fffa,
-0x428c0, 0x92e204d8, 0x10400006, 0x24020001,
-0x8ee304dc, 0x1221004, 0x621825, 0x8001c8f,
-0xaee304dc, 0x8f830228, 0x24020001, 0x1221004,
-0x621825, 0xaf830228, 0x3c020800, 0x34421000,
-0xafa20018, 0x8ee20608, 0x8f430228, 0x24420001,
-0x304a00ff, 0x514300fd, 0xafa00010, 0x8ee20608,
-0x210c0, 0x571021, 0x8fa30018, 0x8fa4001c,
-0xac43060c, 0xac440610, 0x8f830054, 0x8f820054,
-0x24690032, 0x1221023, 0x2c420033, 0x1040006a,
-0x5821, 0x24100008, 0x240f000d, 0x240d0007,
-0x240c0040, 0x240e0001, 0x8f870120, 0x27623800,
-0x24e80020, 0x102102b, 0x50400001, 0x27683000,
-0x8f820128, 0x11020004, 0x0, 0x8f820124,
-0x15020007, 0x1021, 0x8ee201a4, 0x3821,
-0x24420001, 0xaee201a4, 0x8001d08, 0x8ee201a4,
-0x8ee40608, 0x420c0, 0x801821, 0x8ee40430,
-0x8ee50434, 0xa32821, 0xa3302b, 0x822021,
-0x862021, 0xace40000, 0xace50004, 0x8ee20608,
-0xa4f0000e, 0xacef0018, 0xacea001c, 0x210c0,
-0x2442060c, 0x2e21021, 0xace20008, 0x8ee204c4,
-0xace20010, 0xaf880120, 0x92e24e20, 0x14400033,
-0x24070001, 0x8ee24e30, 0x210c0, 0x24425038,
-0x2e22021, 0x8c820000, 0x144d001f, 0x0,
-0x8ee34e30, 0x8ee24e34, 0x1062001b, 0x0,
-0x8c820004, 0x24420001, 0xac820004, 0x8ee24e34,
-0x8ee34e30, 0x24420001, 0x104c0007, 0x0,
-0x8ee24e34, 0x24420001, 0x10620005, 0x0,
-0x8001cf5, 0x0, 0x14600005, 0x0,
-0x8f820128, 0x24420020, 0xaf820128, 0x8f820128,
-0x8c820004, 0x2c420011, 0x50400010, 0xac800000,
-0x8001d08, 0x0, 0x8ee24e30, 0x24420001,
-0x504c0003, 0x1021, 0x8ee24e30, 0x24420001,
-0xaee24e30, 0x8ee24e30, 0x210c0, 0x24425038,
-0x2e22021, 0xac8d0000, 0xac8e0004, 0x54e00006,
-0x240b0001, 0x8f820054, 0x1221023, 0x2c420033,
-0x1440ff9d, 0x0, 0x316300ff, 0x24020001,
-0x54620078, 0xafa00010, 0xaeea0608, 0x8f830054,
-0x8f820054, 0x24690032, 0x1221023, 0x2c420033,
-0x10400061, 0x5821, 0x240e0008, 0x240d0011,
-0x240a0012, 0x24080040, 0x240c0001, 0x8f830120,
-0x27623800, 0x24660020, 0xc2102b, 0x50400001,
-0x27663000, 0x8f820128, 0x10c20004, 0x0,
-0x8f820124, 0x14c20007, 0x0, 0x8ee201a4,
-0x3821, 0x24420001, 0xaee201a4, 0x8001d74,
-0x8ee201a4, 0x8ee20608, 0xac62001c, 0x8ee404a0,
-0x8ee504a4, 0x2462001c, 0xac620008, 0xa46e000e,
-0xac6d0018, 0xac640000, 0xac650004, 0x8ee204c4,
-0xac620010, 0xaf860120, 0x92e24e20, 0x14400033,
-0x24070001, 0x8ee24e30, 0x210c0, 0x24425038,
-0x2e22021, 0x8c820000, 0x144a001f, 0x0,
-0x8ee34e30, 0x8ee24e34, 0x1062001b, 0x0,
-0x8c820004, 0x24420001, 0xac820004, 0x8ee24e34,
-0x8ee34e30, 0x24420001, 0x10480007, 0x0,
-0x8ee24e34, 0x24420001, 0x10620005, 0x0,
-0x8001d61, 0x0, 0x14600005, 0x0,
-0x8f820128, 0x24420020, 0xaf820128, 0x8f820128,
-0x8c820004, 0x2c420011, 0x50400010, 0xac800000,
-0x8001d74, 0x0, 0x8ee24e30, 0x24420001,
-0x50480003, 0x1021, 0x8ee24e30, 0x24420001,
-0xaee24e30, 0x8ee24e30, 0x210c0, 0x24425038,
-0x2e22021, 0xac8a0000, 0xac8c0004, 0x54e00006,
-0x240b0001, 0x8f820054, 0x1221023, 0x2c420033,
-0x1440ffa6, 0x0, 0x316300ff, 0x24020001,
-0x10620022, 0x0, 0x3c040001, 0x24844d20,
-0xafa00010, 0xafa00014, 0x8f860120, 0x8f870124,
-0x3c050009, 0xc002403, 0x34a5f011, 0x8001da0,
-0x0, 0x3c040001, 0x24844d2c, 0xafa00014,
-0x8f860120, 0x8f870124, 0x3c050009, 0xc002403,
-0x34a5f010, 0x8001da0, 0x0, 0x3c040001,
-0x24844d38, 0xafa00014, 0x8ee60608, 0x8f470228,
-0x3c050009, 0xc002403, 0x34a5f00f, 0x8ee201ac,
-0x24420001, 0xaee201ac, 0x8ee201ac, 0x8ee20124,
-0x24420001, 0xaee20124, 0x8001f97, 0x8ee20124,
-0x27440212, 0xc0022fe, 0x24050006, 0x3049001f,
-0x928c0, 0x2e51021, 0x9442727c, 0x30428000,
-0x1040002f, 0x2e51021, 0x9442727c, 0x30424000,
-0x1440001c, 0xb71021, 0x9443727e, 0x97420212,
-0x14620018, 0xb71021, 0x8c437280, 0x8f420214,
-0x54620016, 0xafa20010, 0x92e204d8, 0x10400007,
-0x24020001, 0x8ee304dc, 0x1221004, 0x21027,
-0x621824, 0x8001dc9, 0xaee304dc, 0x8f830228,
-0x1221004, 0x21027, 0x621824, 0xaf830228,
-0x910c0, 0x2e21821, 0x3402c000, 0x8001e4e,
-0xa462727c, 0x8f420214, 0xafa20010, 0x910c0,
-0x571021, 0x8c42727c, 0x3c040001, 0x24844d44,
-0x3c050003, 0xafa20014, 0x8f470210, 0x34a5f01c,
-0xc002403, 0x1203021, 0x8001e83, 0x3c020800,
-0xb71021, 0x9443727e, 0x97420212, 0x14620019,
-0x918c0, 0xb71021, 0x8c437280, 0x8f420214,
-0x14620014, 0x918c0, 0x2e51021, 0x9447727c,
-0x720c0, 0x971021, 0x9443737e, 0xb71021,
-0xa443727e, 0x971021, 0x8c437380, 0xb71021,
-0xac437280, 0x2e41021, 0x9443737c, 0x2e51021,
-0xa443727c, 0x2e41821, 0x3402c000, 0x8001e4e,
-0xa462737c, 0x2e31021, 0x9447727c, 0x3021,
-0x720c0, 0x2e41021, 0x9442737c, 0x4021,
-0x30428000, 0x14400025, 0xe02821, 0x605021,
-0x340bc000, 0x971021, 0x9443737e, 0x97420212,
-0x54620015, 0xe02821, 0x971021, 0x8c437380,
-0x8f420214, 0x54620010, 0xe02821, 0x11000006,
-0x2e41021, 0x9443737c, 0x510c0, 0x2e21021,
-0x8001e1a, 0xa443737c, 0x9443737c, 0x2ea1021,
-0xa443727c, 0x710c0, 0x2e21021, 0xa44b737c,
-0x8001e28, 0x24060001, 0x510c0, 0x2e21021,
-0x9447737c, 0x720c0, 0x2e41021, 0x9442737c,
-0x30428000, 0x1040ffdf, 0x25080001, 0x30c200ff,
-0x14400025, 0x2021, 0x720c0, 0x971021,
-0x9443737e, 0x97420212, 0x1462000f, 0x910c0,
-0x971021, 0x8c437380, 0x8f420214, 0x1462000a,
-0x910c0, 0x2e41821, 0x3402c000, 0x15000015,
-0xa462737c, 0x910c0, 0x2e21821, 0x34028000,
-0x8001e4e, 0xa462727c, 0x571021, 0x8c42727c,
-0x3c040001, 0x24844d50, 0x3c050003, 0xafa20010,
-0x710c0, 0x571021, 0x8c42737c, 0x34a5001e,
-0x1203021, 0xc002403, 0xafa20014, 0x8001e83,
-0x3c020800, 0x2021, 0x428c0, 0xb71021,
-0x9443777e, 0x97420212, 0x5462002b, 0x24840001,
-0xb71021, 0x8c437780, 0x8f420214, 0x54620026,
-0x24840001, 0x3c020001, 0x571021, 0x8c4283b4,
-0x2442ffff, 0x3c010001, 0x370821, 0xac2283b4,
-0x3c020001, 0x571021, 0x8c4283b4, 0x809021,
-0x242102b, 0x1040000e, 0x24b1777c, 0x24b07784,
-0x2f02021, 0x2f12821, 0xc002490, 0x24060008,
-0x26310008, 0x3c020001, 0x571021, 0x8c4283b4,
-0x26520001, 0x242102b, 0x1440fff5, 0x26100008,
-0x3c040001, 0x972021, 0x8c8483b4, 0x24050008,
-0x420c0, 0x2484777c, 0xc002488, 0x2e42021,
-0x8001e83, 0x3c020800, 0x2c820080, 0x1440ffcf,
-0x428c0, 0x3c020800, 0x34422000, 0xafa20018,
-0x8ee20608, 0x8f430228, 0x24420001, 0x304a00ff,
-0x514300fd, 0xafa00010, 0x8ee20608, 0x210c0,
-0x571021, 0x8fa30018, 0x8fa4001c, 0xac43060c,
-0xac440610, 0x8f830054, 0x8f820054, 0x24690032,
-0x1221023, 0x2c420033, 0x1040006a, 0x5821,
-0x24100008, 0x240f000d, 0x240d0007, 0x240c0040,
-0x240e0001, 0x8f870120, 0x27623800, 0x24e80020,
-0x102102b, 0x50400001, 0x27683000, 0x8f820128,
-0x11020004, 0x0, 0x8f820124, 0x15020007,
-0x1021, 0x8ee201a4, 0x3821, 0x24420001,
-0xaee201a4, 0x8001efb, 0x8ee201a4, 0x8ee40608,
-0x420c0, 0x801821, 0x8ee40430, 0x8ee50434,
-0xa32821, 0xa3302b, 0x822021, 0x862021,
-0xace40000, 0xace50004, 0x8ee20608, 0xa4f0000e,
-0xacef0018, 0xacea001c, 0x210c0, 0x2442060c,
-0x2e21021, 0xace20008, 0x8ee204c4, 0xace20010,
-0xaf880120, 0x92e24e20, 0x14400033, 0x24070001,
-0x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
-0x8c820000, 0x144d001f, 0x0, 0x8ee34e30,
-0x8ee24e34, 0x1062001b, 0x0, 0x8c820004,
-0x24420001, 0xac820004, 0x8ee24e34, 0x8ee34e30,
-0x24420001, 0x104c0007, 0x0, 0x8ee24e34,
-0x24420001, 0x10620005, 0x0, 0x8001ee8,
-0x0, 0x14600005, 0x0, 0x8f820128,
-0x24420020, 0xaf820128, 0x8f820128, 0x8c820004,
-0x2c420011, 0x50400010, 0xac800000, 0x8001efb,
-0x0, 0x8ee24e30, 0x24420001, 0x504c0003,
-0x1021, 0x8ee24e30, 0x24420001, 0xaee24e30,
-0x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
-0xac8d0000, 0xac8e0004, 0x54e00006, 0x240b0001,
-0x8f820054, 0x1221023, 0x2c420033, 0x1440ff9d,
-0x0, 0x316300ff, 0x24020001, 0x54620078,
-0xafa00010, 0xaeea0608, 0x8f830054, 0x8f820054,
-0x24690032, 0x1221023, 0x2c420033, 0x10400061,
-0x5821, 0x240e0008, 0x240d0011, 0x240a0012,
-0x24080040, 0x240c0001, 0x8f830120, 0x27623800,
-0x24660020, 0xc2102b, 0x50400001, 0x27663000,
-0x8f820128, 0x10c20004, 0x0, 0x8f820124,
-0x14c20007, 0x0, 0x8ee201a4, 0x3821,
-0x24420001, 0xaee201a4, 0x8001f67, 0x8ee201a4,
-0x8ee20608, 0xac62001c, 0x8ee404a0, 0x8ee504a4,
-0x2462001c, 0xac620008, 0xa46e000e, 0xac6d0018,
-0xac640000, 0xac650004, 0x8ee204c4, 0xac620010,
-0xaf860120, 0x92e24e20, 0x14400033, 0x24070001,
-0x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
-0x8c820000, 0x144a001f, 0x0, 0x8ee34e30,
-0x8ee24e34, 0x1062001b, 0x0, 0x8c820004,
-0x24420001, 0xac820004, 0x8ee24e34, 0x8ee34e30,
-0x24420001, 0x10480007, 0x0, 0x8ee24e34,
-0x24420001, 0x10620005, 0x0, 0x8001f54,
-0x0, 0x14600005, 0x0, 0x8f820128,
-0x24420020, 0xaf820128, 0x8f820128, 0x8c820004,
-0x2c420011, 0x50400010, 0xac800000, 0x8001f67,
-0x0, 0x8ee24e30, 0x24420001, 0x50480003,
-0x1021, 0x8ee24e30, 0x24420001, 0xaee24e30,
-0x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
-0xac8a0000, 0xac8c0004, 0x54e00006, 0x240b0001,
-0x8f820054, 0x1221023, 0x2c420033, 0x1440ffa6,
-0x0, 0x316300ff, 0x24020001, 0x10620022,
-0x0, 0x3c040001, 0x24844d20, 0xafa00010,
-0xafa00014, 0x8f860120, 0x8f870124, 0x3c050009,
-0xc002403, 0x34a5f011, 0x8001f93, 0x0,
-0x3c040001, 0x24844d2c, 0xafa00014, 0x8f860120,
-0x8f870124, 0x3c050009, 0xc002403, 0x34a5f010,
-0x8001f93, 0x0, 0x3c040001, 0x24844d38,
-0xafa00014, 0x8ee60608, 0x8f470228, 0x3c050009,
-0xc002403, 0x34a5f00f, 0x8ee201ac, 0x24420001,
-0xaee201ac, 0x8ee201ac, 0x8ee20128, 0x24420001,
-0xaee20128, 0x8ee20128, 0x8ee20164, 0x24420001,
-0xaee20164, 0x80022e8, 0x8ee20164, 0x8fa20020,
-0x21200, 0x21d02, 0x24020001, 0x10620005,
-0x24020002, 0x1062000d, 0x0, 0x8001fb7,
-0xafa00010, 0x92e204d8, 0x14400006, 0x24020001,
-0x8f820228, 0xaee204dc, 0x2402ffff, 0xaf820228,
-0x24020001, 0x8001fbe, 0xa2e204d8, 0x92e204d8,
-0x5040000c, 0xa2e004d8, 0x8ee204dc, 0xaf820228,
-0x8001fbe, 0xa2e004d8, 0x3c040001, 0x24844d58,
-0xafa00014, 0x8fa60020, 0x3c050003, 0xc002403,
-0x34a5f009, 0x8ee2013c, 0x24420001, 0xaee2013c,
-0x80022e8, 0x8ee2013c, 0x8fa20020, 0x21200,
-0x22502, 0x24020001, 0x10820005, 0x24020002,
-0x1082000f, 0x0, 0x8001fe3, 0xafa00010,
-0x8f820220, 0x3c0308ff, 0x3463ffff, 0x431024,
-0x34420008, 0xaf820220, 0x24020001, 0x3c010001,
-0x370821, 0xa02283b2, 0x8001fea, 0xaee40108,
-0x8f820220, 0x3c0308ff, 0x3463fff7, 0x431024,
-0xaf820220, 0x3c010001, 0x370821, 0xa02083b2,
-0x8001fea, 0xaee40108, 0x3c040001, 0x24844d64,
-0xafa00014, 0x8fa60020, 0x3c050003, 0xc002403,
-0x34a5f00a, 0x8ee2012c, 0x24420001, 0xaee2012c,
-0x80022e8, 0x8ee2012c, 0x8fa20020, 0x21200,
-0x21d02, 0x24020001, 0x10620005, 0x24020002,
-0x1062000e, 0x0, 0x8002011, 0xafa00010,
-0x8f820220, 0x3c0308ff, 0x3463ffff, 0x431024,
-0x34420008, 0xaf820220, 0x24020001, 0x3c010001,
-0x370821, 0x8002018, 0xa02283b3, 0x3c020001,
-0x571021, 0x904283b2, 0x3c010001, 0x370821,
-0x1440000e, 0xa02083b3, 0x8f820220, 0x3c0308ff,
-0x3463fff7, 0x431024, 0x8002018, 0xaf820220,
-0x3c040001, 0x24844d70, 0xafa00014, 0x8fa60020,
-0x3c050003, 0xc002403, 0x34a5f00b, 0x8ee20114,
-0x24420001, 0xaee20114, 0x80022e8, 0x8ee20114,
-0x27840208, 0x27450200, 0xc00249a, 0x24060008,
-0x26e40094, 0x27450200, 0xc00249a, 0x24060008,
-0x8ee20134, 0x24420001, 0xaee20134, 0x80022e8,
-0x8ee20134, 0x8f460248, 0x2021, 0xc005010,
-0x24050004, 0x8ee20130, 0x24420001, 0xaee20130,
-0x80022e8, 0x8ee20130, 0x8ef301cc, 0x8ef401d0,
-0x8ef501d8, 0x8ee20140, 0x26e40030, 0x24420001,
-0xaee20140, 0x8ef00140, 0x8ef10074, 0x8ef20070,
-0xc002488, 0x24050400, 0xaef301cc, 0xaef401d0,
-0xaef501d8, 0xaef00140, 0xaef10074, 0xaef20070,
-0x8f42025c, 0x26e40094, 0xaee20060, 0x8f420260,
-0x27450200, 0x24060008, 0xaee20068, 0x24020006,
-0xc00249a, 0xaee20064, 0x3c023b9a, 0x3442ca00,
-0xaee2006c, 0x240203e8, 0x24040002, 0x24030001,
-0xaee20104, 0xaee40100, 0xaee3010c, 0x8f820220,
-0x30420008, 0x10400004, 0x0, 0xaee30108,
-0x8002061, 0x2021, 0xaee40108, 0x2021,
-0x3c030001, 0x641821, 0x906355b0, 0x2e41021,
-0x24840001, 0xa043009c, 0x2c82000f, 0x1440fff8,
-0x0, 0x8f820040, 0x2e41821, 0x24840001,
-0x21702, 0x24420030, 0xa062009c, 0x2e41021,
-0x80022e8, 0xa040009c, 0x24020001, 0x3c010001,
-0x370821, 0xa02283e0, 0x240b0400, 0x24080014,
-0x240a0040, 0x24090001, 0x8f830100, 0x27623000,
-0x24660020, 0xc2102b, 0x50400001, 0x27662800,
-0x8f820108, 0x10c20004, 0x0, 0x8f820104,
-0x14c20007, 0x26e20030, 0x8ee201a8, 0x3821,
-0x24420001, 0xaee201a8, 0x80020a8, 0x8ee201a8,
-0x8ee404b8, 0x8ee504bc, 0xac620008, 0xa46b000e,
-0xac680018, 0xac60001c, 0xac640000, 0xac650004,
-0x8ee204cc, 0xac620010, 0xaf860100, 0x92e204ec,
-0x1440000e, 0x24070001, 0x8ee24e28, 0x24420001,
-0x504a0003, 0x1021, 0x8ee24e28, 0x24420001,
-0xaee24e28, 0x8ee24e28, 0x210c0, 0x24424e38,
-0x2e21021, 0xac480000, 0xac490004, 0x10e0ffd2,
-0x0, 0x80022e8, 0x0, 0x3c020900,
-0xaee05238, 0xaee0523c, 0xaee05240, 0xaee05244,
-0xaee001d0, 0x3c010001, 0x370821, 0xa02083b1,
-0xafa20018, 0x8ee20608, 0x8f430228, 0x24420001,
-0x304a00ff, 0x514300fd, 0xafa00010, 0x8ee20608,
-0x210c0, 0x571021, 0x8fa30018, 0x8fa4001c,
-0xac43060c, 0xac440610, 0x8f830054, 0x8f820054,
-0x24690032, 0x1221023, 0x2c420033, 0x1040006a,
-0x5821, 0x24100008, 0x240f000d, 0x240d0007,
-0x240c0040, 0x240e0001, 0x8f870120, 0x27623800,
-0x24e80020, 0x102102b, 0x50400001, 0x27683000,
-0x8f820128, 0x11020004, 0x0, 0x8f820124,
-0x15020007, 0x1021, 0x8ee201a4, 0x3821,
-0x24420001, 0xaee201a4, 0x800212c, 0x8ee201a4,
-0x8ee40608, 0x420c0, 0x801821, 0x8ee40430,
-0x8ee50434, 0xa32821, 0xa3302b, 0x822021,
-0x862021, 0xace40000, 0xace50004, 0x8ee20608,
-0xa4f0000e, 0xacef0018, 0xacea001c, 0x210c0,
-0x2442060c, 0x2e21021, 0xace20008, 0x8ee204c4,
-0xace20010, 0xaf880120, 0x92e24e20, 0x14400033,
-0x24070001, 0x8ee24e30, 0x210c0, 0x24425038,
-0x2e22021, 0x8c820000, 0x144d001f, 0x0,
-0x8ee34e30, 0x8ee24e34, 0x1062001b, 0x0,
-0x8c820004, 0x24420001, 0xac820004, 0x8ee24e34,
-0x8ee34e30, 0x24420001, 0x104c0007, 0x0,
-0x8ee24e34, 0x24420001, 0x10620005, 0x0,
-0x8002119, 0x0, 0x14600005, 0x0,
-0x8f820128, 0x24420020, 0xaf820128, 0x8f820128,
-0x8c820004, 0x2c420011, 0x50400010, 0xac800000,
-0x800212c, 0x0, 0x8ee24e30, 0x24420001,
-0x504c0003, 0x1021, 0x8ee24e30, 0x24420001,
-0xaee24e30, 0x8ee24e30, 0x210c0, 0x24425038,
-0x2e22021, 0xac8d0000, 0xac8e0004, 0x54e00006,
-0x240b0001, 0x8f820054, 0x1221023, 0x2c420033,
-0x1440ff9d, 0x0, 0x316300ff, 0x24020001,
-0x54620078, 0xafa00010, 0xaeea0608, 0x8f830054,
-0x8f820054, 0x24690032, 0x1221023, 0x2c420033,
-0x10400061, 0x5821, 0x240e0008, 0x240d0011,
-0x240a0012, 0x24080040, 0x240c0001, 0x8f830120,
-0x27623800, 0x24660020, 0xc2102b, 0x50400001,
-0x27663000, 0x8f820128, 0x10c20004, 0x0,
-0x8f820124, 0x14c20007, 0x0, 0x8ee201a4,
-0x3821, 0x24420001, 0xaee201a4, 0x8002198,
-0x8ee201a4, 0x8ee20608, 0xac62001c, 0x8ee404a0,
-0x8ee504a4, 0x2462001c, 0xac620008, 0xa46e000e,
-0xac6d0018, 0xac640000, 0xac650004, 0x8ee204c4,
-0xac620010, 0xaf860120, 0x92e24e20, 0x14400033,
-0x24070001, 0x8ee24e30, 0x210c0, 0x24425038,
-0x2e22021, 0x8c820000, 0x144a001f, 0x0,
-0x8ee34e30, 0x8ee24e34, 0x1062001b, 0x0,
-0x8c820004, 0x24420001, 0xac820004, 0x8ee24e34,
-0x8ee34e30, 0x24420001, 0x10480007, 0x0,
-0x8ee24e34, 0x24420001, 0x10620005, 0x0,
-0x8002185, 0x0, 0x14600005, 0x0,
-0x8f820128, 0x24420020, 0xaf820128, 0x8f820128,
-0x8c820004, 0x2c420011, 0x50400010, 0xac800000,
-0x8002198, 0x0, 0x8ee24e30, 0x24420001,
-0x50480003, 0x1021, 0x8ee24e30, 0x24420001,
-0xaee24e30, 0x8ee24e30, 0x210c0, 0x24425038,
-0x2e22021, 0xac8a0000, 0xac8c0004, 0x54e00006,
-0x240b0001, 0x8f820054, 0x1221023, 0x2c420033,
-0x1440ffa6, 0x0, 0x316300ff, 0x24020001,
-0x10620022, 0x0, 0x3c040001, 0x24844d20,
-0xafa00010, 0xafa00014, 0x8f860120, 0x8f870124,
-0x3c050009, 0xc002403, 0x34a5f011, 0x80021c4,
-0x0, 0x3c040001, 0x24844d2c, 0xafa00014,
-0x8f860120, 0x8f870124, 0x3c050009, 0xc002403,
-0x34a5f010, 0x80021c4, 0x0, 0x3c040001,
-0x24844d38, 0xafa00014, 0x8ee60608, 0x8f470228,
-0x3c050009, 0xc002403, 0x34a5f00f, 0x8ee201ac,
-0x24420001, 0xaee201ac, 0x8ee201ac, 0x8ee20120,
-0x24420001, 0xaee20120, 0x8ee20120, 0x8ee20168,
-0x24420001, 0xaee20168, 0x80022e8, 0x8ee20168,
-0x8f42025c, 0x26e40094, 0xaee20060, 0x8f420260,
-0x27450200, 0x24060008, 0xc00249a, 0xaee20068,
-0x8f820220, 0x30420008, 0x14400002, 0x24020001,
-0x24020002, 0xaee20108, 0x8ee2011c, 0x24420001,
-0xaee2011c, 0x80022e8, 0x8ee2011c, 0x3c040001,
-0x24844d7c, 0xafa00010, 0xafa00014, 0x8fa60020,
-0x3c050003, 0xc002403, 0x34a5f00f, 0x93a20020,
-0x3c030700, 0x34631000, 0x431025, 0xafa20018,
-0x8ee20608, 0x8f430228, 0x24420001, 0x304900ff,
-0x512300e2, 0xafa00010, 0x8ee20608, 0x210c0,
-0x571021, 0x8fa30018, 0x8fa4001c, 0xac43060c,
-0xac440610, 0x8f870120, 0x27623800, 0x24e80020,
-0x102102b, 0x50400001, 0x27683000, 0x8f820128,
-0x11020004, 0x0, 0x8f820124, 0x15020007,
-0x1021, 0x8ee201a4, 0x3821, 0x24420001,
-0xaee201a4, 0x800225d, 0x8ee201a4, 0x8ee40608,
-0x420c0, 0x801821, 0x8ee40430, 0x8ee50434,
-0xa32821, 0xa3302b, 0x822021, 0x862021,
-0xace40000, 0xace50004, 0x8ee30608, 0x24020008,
-0xa4e2000e, 0x2402000d, 0xace20018, 0xace9001c,
-0x318c0, 0x2463060c, 0x2e31021, 0xace20008,
-0x8ee204c4, 0xace20010, 0xaf880120, 0x92e24e20,
-0x14400037, 0x24070001, 0x8ee24e30, 0x210c0,
-0x24425038, 0x2e22021, 0x8c830000, 0x24020007,
-0x1462001f, 0x0, 0x8ee34e30, 0x8ee24e34,
-0x1062001b, 0x24030040, 0x8c820004, 0x24420001,
-0xac820004, 0x8ee24e34, 0x8ee54e30, 0x24420001,
-0x10430007, 0x0, 0x8ee24e34, 0x24420001,
-0x10a20005, 0x0, 0x8002247, 0x0,
-0x14a00005, 0x0, 0x8f820128, 0x24420020,
-0xaf820128, 0x8f820128, 0x8c820004, 0x2c420011,
-0x50400013, 0xac800000, 0x800225d, 0x0,
-0x8ee24e30, 0x24030040, 0x24420001, 0x50430003,
-0x1021, 0x8ee24e30, 0x24420001, 0xaee24e30,
-0x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
-0x24020007, 0xac820000, 0x24020001, 0xac820004,
-0x54e0000c, 0xaee90608, 0x3c040001, 0x24844d84,
-0xafa00010, 0xafa00014, 0x8ee60608, 0x8f470228,
-0x3c050009, 0xc002403, 0x34a5f000, 0x80022e0,
-0x0, 0x8f830120, 0x27623800, 0x24660020,
-0xc2102b, 0x50400001, 0x27663000, 0x8f820128,
-0x10c20004, 0x0, 0x8f820124, 0x14c20007,
-0x0, 0x8ee201a4, 0x3821, 0x24420001,
-0xaee201a4, 0x80022c4, 0x8ee201a4, 0x8ee20608,
-0xac62001c, 0x8ee404a0, 0x8ee504a4, 0x2462001c,
-0xac620008, 0x24020008, 0xa462000e, 0x24020011,
-0xac620018, 0xac640000, 0xac650004, 0x8ee204c4,
-0xac620010, 0xaf860120, 0x92e24e20, 0x14400037,
-0x24070001, 0x8ee24e30, 0x210c0, 0x24425038,
-0x2e22021, 0x8c830000, 0x24020012, 0x1462001f,
-0x0, 0x8ee34e30, 0x8ee24e34, 0x1062001b,
-0x24030040, 0x8c820004, 0x24420001, 0xac820004,
-0x8ee24e34, 0x8ee54e30, 0x24420001, 0x10430007,
-0x0, 0x8ee24e34, 0x24420001, 0x10a20005,
-0x0, 0x80022ae, 0x0, 0x14a00005,
-0x0, 0x8f820128, 0x24420020, 0xaf820128,
-0x8f820128, 0x8c820004, 0x2c420011, 0x50400013,
-0xac800000, 0x80022c4, 0x0, 0x8ee24e30,
-0x24030040, 0x24420001, 0x50430003, 0x1021,
-0x8ee24e30, 0x24420001, 0xaee24e30, 0x8ee24e30,
-0x210c0, 0x24425038, 0x2e22021, 0x24020012,
-0xac820000, 0x24020001, 0xac820004, 0x14e0001b,
-0x0, 0x3c040001, 0x24844d8c, 0xafa00010,
-0xafa00014, 0x8ee60608, 0x8f470228, 0x3c050009,
-0xc002403, 0x34a5f001, 0x8ee201b0, 0x24420001,
-0xaee201b0, 0x80022e0, 0x8ee201b0, 0x3c040001,
-0x24844d98, 0xafa00014, 0x8ee60608, 0x8f470228,
-0x3c050009, 0xc002403, 0x34a5f005, 0x8ee201ac,
-0x24420001, 0xaee201ac, 0x8ee201ac, 0x8ee20150,
-0x24420001, 0xaee20150, 0x8ee20150, 0x8ee20160,
-0x24420001, 0xaee20160, 0x8ee20160, 0x8f43022c,
-0x8f42010c, 0x14620009, 0x24020002, 0xaf820064,
-0x8f820064, 0x14400005, 0x0, 0x8f43022c,
-0x8f42010c, 0x1462f875, 0x0, 0x8fbf0044,
-0x8fb60040, 0x8fb5003c, 0x8fb40038, 0x8fb30034,
-0x8fb20030, 0x8fb1002c, 0x8fb00028, 0x3e00008,
-0x27bd0048, 0x27bdfff8, 0x2408ffff, 0x10a00014,
-0x4821, 0x3c0aedb8, 0x354a8320, 0x90870000,
-0x24840001, 0x3021, 0x1071026, 0x30420001,
-0x10400002, 0x81842, 0x6a1826, 0x604021,
-0x24c60001, 0x2cc20008, 0x1440fff7, 0x73842,
-0x25290001, 0x125102b, 0x1440fff0, 0x0,
-0x1001021, 0x3e00008, 0x27bd0008, 0x27bdffe8,
-0x27642800, 0xafbf0010, 0xc002488, 0x24051000,
-0x24020021, 0xaf800100, 0xaf800104, 0xaf800108,
-0xaf800110, 0xaf800114, 0xaf800118, 0xaf800120,
-0xaf800124, 0xaf800128, 0xaf800130, 0xaf800134,
-0xaf800138, 0xaee04e28, 0xaee04e2c, 0xaee04e30,
-0xaee04e34, 0xaf82011c, 0x8f420218, 0x30420040,
-0x10400004, 0x0, 0x8f82011c, 0x34420004,
-0xaf82011c, 0x8fbf0010, 0x3e00008, 0x27bd0018,
-0x27bdffe0, 0xafbf0018, 0x8f820104, 0xafa20010,
-0x8f820100, 0x3c050002, 0xafa20014, 0x8f8600b0,
-0x8f87011c, 0x3c040001, 0x24844e50, 0xc002403,
-0x34a5f000, 0x8f8300b0, 0x3c027f00, 0x621824,
-0x3c020400, 0x10620029, 0x43102b, 0x14400008,
-0x3c022000, 0x3c020100, 0x10620024, 0x3c020200,
-0x10620011, 0x0, 0x8002374, 0x0,
-0x10620008, 0x3c024000, 0x1462001c, 0x0,
-0x8ee20190, 0x24420001, 0xaee20190, 0x8002374,
-0x8ee20190, 0x8ee2018c, 0x24420001, 0xaee2018c,
-0x8002374, 0x8ee2018c, 0x8f82011c, 0x34420002,
-0xaf82011c, 0x8f830104, 0x8f8200b0, 0x34420001,
-0xaf8200b0, 0xaf830104, 0x8f82011c, 0x2403fffd,
-0x431024, 0xaf82011c, 0x8ee201a0, 0x24420001,
-0xaee201a0, 0x8002377, 0x8ee201a0, 0x8f8200b0,
-0x34420001, 0xaf8200b0, 0x8fbf0018, 0x3e00008,
-0x27bd0020, 0x27bdffe0, 0xafbf001c, 0xafb00018,
-0x8f820120, 0xafa20010, 0x8f820124, 0x3c050001,
-0xafa20014, 0x8f8600a0, 0x8f87011c, 0x3c040001,
-0x24844e5c, 0xc002403, 0x34a5f000, 0x8f8300a0,
-0x3c027f00, 0x621824, 0x3c020400, 0x10620053,
-0x8021, 0x43102b, 0x14400008, 0x3c042000,
-0x3c020100, 0x1062004d, 0x3c020200, 0x1062003a,
-0x0, 0x80023e0, 0x0, 0x10640003,
-0x3c024000, 0x14620045, 0x0, 0x8f8200a0,
-0x441024, 0x10400006, 0x0, 0x8ee20194,
-0x24420001, 0xaee20194, 0x80023a9, 0x8ee20194,
-0x8ee20198, 0x24420001, 0xaee20198, 0x8ee20198,
-0x8f82011c, 0x34420002, 0xaf82011c, 0x8f82011c,
-0x30420200, 0x1040001b, 0x0, 0x8f8300a0,
-0x8f840124, 0x8f8200ac, 0x14400007, 0x24020001,
-0x3c020001, 0x3442f000, 0x621024, 0x50400001,
-0x24100001, 0x24020001, 0x1200000d, 0xaf8200a0,
-0x8f820124, 0x2442ffe0, 0xaf820124, 0x8f820124,
-0x8f820124, 0x27633000, 0x43102b, 0x10400005,
-0x276237e0, 0xaf820124, 0x80023ca, 0x0,
-0xaf840124, 0x8f82011c, 0x2403fffd, 0x431024,
-0x80023e3, 0xaf82011c, 0x8f82011c, 0x34420002,
-0xaf82011c, 0x8f830124, 0x8f8200a0, 0x34420001,
-0xaf8200a0, 0xaf830124, 0x8f82011c, 0x2403fffd,
-0x431024, 0xaf82011c, 0x8ee2019c, 0x24420001,
-0xaee2019c, 0x80023e3, 0x8ee2019c, 0x8f8200a0,
-0x34420001, 0xaf8200a0, 0x8fbf001c, 0x8fb00018,
-0x3e00008, 0x27bd0020, 0x0, 0x3c020001,
-0x8c4255d8, 0x27bdffe8, 0xafbf0014, 0x14400012,
-0xafb00010, 0x3c100001, 0x26105730, 0x2002021,
-0xc002488, 0x24052000, 0x26021fe0, 0x3c010001,
-0xac225704, 0x3c010001, 0xac225700, 0xaf420250,
-0x24022000, 0xaf500254, 0xaf420258, 0x24020001,
-0x3c010001, 0xac2255d8, 0x8fbf0014, 0x8fb00010,
-0x3e00008, 0x27bd0018, 0x3c030001, 0x8c635704,
-0x8c820000, 0x8fa80010, 0x8fa90014, 0xac620000,
-0x3c020001, 0x8c425704, 0x8c830004, 0xac430004,
-0xac450008, 0x8f840054, 0x2443ffe0, 0xac460010,
-0xac470014, 0xac480018, 0xac49001c, 0x3c010001,
-0xac235704, 0xac44000c, 0x3c020001, 0x24425730,
-0x62182b, 0x10600005, 0x0, 0x3c020001,
-0x8c425700, 0x3c010001, 0xac225704, 0x3c030001,
-0x8c635704, 0x3c020001, 0x8c4255c0, 0xac620000,
-0x3c030001, 0x8c635704, 0x3c020001, 0x8c4255c0,
-0xac620004, 0x3e00008, 0xaf430250, 0x3c030001,
-0x8c635704, 0x3c020001, 0x8c4255c0, 0x27bdffd0,
-0xafb40020, 0x8fb40040, 0xafb00010, 0x808021,
-0xafb50024, 0x8fb50044, 0x8fa40048, 0xafb10014,
-0xa08821, 0xafbf0028, 0xafb3001c, 0xafb20018,
-0xac620000, 0x3c050001, 0x8ca55704, 0x3c020001,
-0x8c4255c0, 0xc09021, 0xe09821, 0x10800006,
-0xaca20004, 0x24a50008, 0xc002490, 0x24060018,
-0x800244e, 0x0, 0x24a40008, 0xc002488,
-0x24050018, 0x3c020001, 0x8c425704, 0x3c050001,
-0x24a55730, 0x2442ffe0, 0x3c010001, 0xac225704,
-0x45102b, 0x10400005, 0x0, 0x3c020001,
-0x8c425700, 0x3c010001, 0xac225704, 0x3c030001,
-0x8c635704, 0x8e020000, 0xac620000, 0x3c030001,
-0x8c635704, 0x8e020004, 0xac620004, 0xac710008,
-0x8f840054, 0x2462ffe0, 0x3c010001, 0xac225704,
-0x45102b, 0xac720010, 0xac730014, 0xac740018,
-0xac75001c, 0x10400005, 0xac64000c, 0x3c020001,
-0x8c425700, 0x3c010001, 0xac225704, 0x3c030001,
-0x8c635704, 0x3c020001, 0x8c4255c0, 0xac620000,
-0x3c030001, 0x8c635704, 0x3c020001, 0x8c4255c0,
-0xac620004, 0xaf430250, 0x8fbf0028, 0x8fb50024,
-0x8fb40020, 0x8fb3001c, 0x8fb20018, 0x8fb10014,
-0x8fb00010, 0x3e00008, 0x27bd0030, 0x10a00005,
-0x0, 0xac800000, 0x24a5fffc, 0x14a0fffd,
-0x24840004, 0x3e00008, 0x0, 0x10c00007,
-0x0, 0x8c820000, 0x24840004, 0x24c6fffc,
-0xaca20000, 0x14c0fffb, 0x24a50004, 0x3e00008,
-0x0, 0x10c00007, 0x0, 0x8ca20000,
-0x24a50004, 0x24c6fffc, 0xac820000, 0x14c0fffb,
-0x24840004, 0x3e00008, 0x0, 0x3e00008,
-0x0, 0x27bdffd8, 0xafbf0020, 0x8ee304e4,
-0x8ee204e0, 0x10620436, 0x0, 0x8ee204e4,
-0x8ee304fc, 0x21100, 0x626021, 0x95870008,
-0x8d8a0000, 0x8d8b0004, 0x958d000a, 0x8ee2725c,
-0x8ee3726c, 0x30e4ffff, 0x441021, 0x62182b,
-0x10600015, 0x31a20004, 0x8f8200d8, 0x8ee37258,
-0x431023, 0xaee2726c, 0x8ee2726c, 0x1c400003,
-0x3c030001, 0x431021, 0xaee2726c, 0x8ee2725c,
-0x8ee3726c, 0x441021, 0x62182b, 0x10600006,
-0x31a20004, 0x8ee201b8, 0x24420001, 0xaee201b8,
-0x80028e1, 0x8ee201b8, 0x10400240, 0x31a20200,
-0x1040014d, 0x4821, 0x96e2045a, 0x30420010,
-0x10400149, 0x0, 0x8f840100, 0x27623000,
-0x24850020, 0xa2102b, 0x50400001, 0x27652800,
-0x8f820108, 0x10a20004, 0x0, 0x8f820104,
-0x14a20006, 0x2402000c, 0x8ee201a8, 0x24420001,
-0xaee201a8, 0x800252c, 0x8ee201a8, 0xac8a0000,
-0xac8b0004, 0x8ee37264, 0x24060005, 0xa482000e,
-0xac860018, 0xac830008, 0x8ee204e4, 0xac82001c,
-0x8ee204c8, 0xac820010, 0xaf850100, 0x92e204ec,
-0x14400036, 0x24090001, 0x8ee24e28, 0x210c0,
-0x24424e38, 0x2e22021, 0x8c820000, 0x1446001f,
-0x0, 0x8ee34e28, 0x8ee24e2c, 0x1062001b,
-0x24030040, 0x8c820004, 0x24420001, 0xac820004,
-0x8ee24e2c, 0x8ee54e28, 0x24420001, 0x10430007,
-0x0, 0x8ee24e2c, 0x24420001, 0x10a20005,
-0x0, 0x8002516, 0x0, 0x14a00005,
-0x0, 0x8f820108, 0x24420020, 0xaf820108,
-0x8f820108, 0x8c820004, 0x2c420011, 0x50400013,
-0xac800000, 0x800252c, 0x0, 0x8ee24e28,
-0x24030040, 0x24420001, 0x50430003, 0x1021,
-0x8ee24e28, 0x24420001, 0xaee24e28, 0x8ee24e28,
-0x210c0, 0x24424e38, 0x2e22021, 0x24020005,
-0xac820000, 0x24020001, 0xac820004, 0x1520000a,
-0x3c040001, 0xafab0010, 0x8ee27264, 0x3c040001,
-0x248450c0, 0x3c050004, 0xafa20014, 0x8ee604e4,
-0x80028be, 0x34a5f114, 0x8ee27264, 0x34843800,
-0x3641821, 0x24420010, 0x43102b, 0x14400073,
-0x0, 0x8ee27264, 0x24480010, 0x3641021,
-0x102102b, 0x14400002, 0x3c02ffff, 0x1024021,
-0x8f850100, 0x27623000, 0x24a60020, 0xc2102b,
-0x50400001, 0x27662800, 0x8f820108, 0x10c20004,
-0x0, 0x8f820104, 0x14c20007, 0x2563000c,
-0x8ee201a8, 0x4821, 0x24420001, 0xaee201a8,
-0x80025a0, 0x8ee201a8, 0x2c64000c, 0x1441021,
-0xaca20000, 0xaca30004, 0x24e2fff4, 0xa4a2000e,
-0x24020006, 0xaca80008, 0xaca20018, 0x8ee204e4,
-0xaca2001c, 0x8ee204c8, 0x3c030002, 0x431025,
-0xaca20010, 0xaf860100, 0x92e204ec, 0x14400037,
-0x24090001, 0x8ee24e28, 0x210c0, 0x24424e38,
-0x2e22021, 0x8c830000, 0x24020005, 0x1462001f,
-0x0, 0x8ee34e28, 0x8ee24e2c, 0x1062001b,
-0x24030040, 0x8c820004, 0x24420001, 0xac820004,
-0x8ee24e2c, 0x8ee54e28, 0x24420001, 0x10430007,
-0x0, 0x8ee24e2c, 0x24420001, 0x10a20005,
-0x0, 0x800258a, 0x0, 0x14a00005,
-0x0, 0x8f820108, 0x24420020, 0xaf820108,
-0x8f820108, 0x8c820004, 0x2c420011, 0x50400013,
-0xac800000, 0x80025a0, 0x0, 0x8ee24e28,
-0x24030040, 0x24420001, 0x50430003, 0x1021,
-0x8ee24e28, 0x24420001, 0xaee24e28, 0x8ee24e28,
-0x210c0, 0x24424e38, 0x2e22021, 0x24020005,
-0xac820000, 0x24020001, 0xac820004, 0x1520000a,
-0x2508fffc, 0xafab0010, 0x8ee27264, 0x3c040001,
-0x248450c0, 0x3c050004, 0xafa20014, 0x8ee604e4,
-0x80028be, 0x34a5f125, 0x34028100, 0xa5020000,
-0x9582000e, 0x800261d, 0xa5020002, 0x8f850100,
-0x27623000, 0x24a60020, 0xc2102b, 0x50400001,
-0x27662800, 0x8f820108, 0x10c20004, 0x0,
-0x8f820104, 0x14c20007, 0x2563000c, 0x8ee201a8,
-0x4821, 0x24420001, 0xaee201a8, 0x800260d,
-0x8ee201a8, 0x2c64000c, 0x1441021, 0xaca20000,
-0xaca30004, 0x8ee37264, 0x24e2fff4, 0xa4a2000e,
-0x24020006, 0xaca20018, 0x24630010, 0xaca30008,
-0x8ee204e4, 0xaca2001c, 0x8ee204c8, 0x3c030002,
-0x431025, 0xaca20010, 0xaf860100, 0x92e204ec,
-0x14400037, 0x24090001, 0x8ee24e28, 0x210c0,
-0x24424e38, 0x2e22021, 0x8c830000, 0x24020005,
-0x1462001f, 0x0, 0x8ee34e28, 0x8ee24e2c,
-0x1062001b, 0x24030040, 0x8c820004, 0x24420001,
-0xac820004, 0x8ee24e2c, 0x8ee54e28, 0x24420001,
-0x10430007, 0x0, 0x8ee24e2c, 0x24420001,
-0x10a20005, 0x0, 0x80025f7, 0x0,
-0x14a00005, 0x0, 0x8f820108, 0x24420020,
-0xaf820108, 0x8f820108, 0x8c820004, 0x2c420011,
-0x50400013, 0xac800000, 0x800260d, 0x0,
-0x8ee24e28, 0x24030040, 0x24420001, 0x50430003,
-0x1021, 0x8ee24e28, 0x24420001, 0xaee24e28,
-0x8ee24e28, 0x210c0, 0x24424e38, 0x2e22021,
-0x24020005, 0xac820000, 0x24020001, 0xac820004,
-0x1520000a, 0x34028100, 0xafab0010, 0x8ee27264,
-0x3c040001, 0x248450c0, 0x3c050004, 0xafa20014,
-0x8ee604e4, 0x80028be, 0x34a5f015, 0x8ee37264,
-0xa462000c, 0x8ee37264, 0x9582000e, 0xa462000e,
-0x8002681, 0x24e70004, 0x8f840100, 0x27623000,
-0x24850020, 0xa2102b, 0x50400001, 0x27652800,
-0x8f820108, 0x10a20004, 0x0, 0x8f820104,
-0x14a20007, 0x24020006, 0x8ee201a8, 0x4821,
-0x24420001, 0xaee201a8, 0x8002677, 0x8ee201a8,
-0xac8a0000, 0xac8b0004, 0x8ee37264, 0xa487000e,
-0xac820018, 0xac830008, 0x8ee204e4, 0xac82001c,
-0x8ee204c8, 0x3c030002, 0x431025, 0xac820010,
-0xaf850100, 0x92e204ec, 0x14400037, 0x24090001,
-0x8ee24e28, 0x210c0, 0x24424e38, 0x2e22021,
-0x8c830000, 0x24020005, 0x1462001f, 0x0,
-0x8ee34e28, 0x8ee24e2c, 0x1062001b, 0x24030040,
-0x8c820004, 0x24420001, 0xac820004, 0x8ee24e2c,
-0x8ee54e28, 0x24420001, 0x10430007, 0x0,
-0x8ee24e2c, 0x24420001, 0x10a20005, 0x0,
-0x8002661, 0x0, 0x14a00005, 0x0,
-0x8f820108, 0x24420020, 0xaf820108, 0x8f820108,
-0x8c820004, 0x2c420011, 0x50400013, 0xac800000,
-0x8002677, 0x0, 0x8ee24e28, 0x24030040,
-0x24420001, 0x50430003, 0x1021, 0x8ee24e28,
-0x24420001, 0xaee24e28, 0x8ee24e28, 0x210c0,
-0x24424e38, 0x2e22021, 0x24020005, 0xac820000,
-0x24020001, 0xac820004, 0x15200009, 0x3c050004,
-0xafab0010, 0x8ee27264, 0x3c040001, 0x248450c0,
-0xafa20014, 0x8ee604e4, 0x80028be, 0x34a5f004,
-0x8ee2725c, 0x30e7ffff, 0x471021, 0xaee2725c,
-0x8ee204e4, 0x8ee304fc, 0x8ee47258, 0x21100,
-0x431021, 0xac44000c, 0x8ee27258, 0xafa20018,
-0x8ee3725c, 0xafa3001c, 0x8ee2725c, 0x2c42003c,
-0x10400004, 0x24620001, 0x2403fffe, 0x431024,
-0xafa2001c, 0x8ee27264, 0x3c060001, 0x34c63800,
-0x8ee3725c, 0x2405fff8, 0x471021, 0x24420007,
-0x451024, 0x24630007, 0xaee27258, 0x8ee2726c,
-0x8ee47258, 0x651824, 0x431023, 0xaee2726c,
-0x3661021, 0x82202b, 0x14800004, 0x3c03ffff,
-0x8ee27258, 0x431021, 0xaee27258, 0x8ee27258,
-0xaee27264, 0x8f8200f0, 0x24470008, 0x27621800,
-0xe2102b, 0x50400001, 0x27671000, 0x8f8200f4,
-0x14e20007, 0x0, 0x8ee201b4, 0x4821,
-0x24420001, 0xaee201b4, 0x80026c4, 0x8ee201b4,
-0x8f8200f0, 0x24090001, 0x8fa30018, 0x8fa4001c,
-0xac430000, 0xac440004, 0xaf8700f0, 0x15200012,
-0xd1142, 0x8f8200f0, 0xafa20010, 0x8f8200f4,
-0x3c040001, 0x248450cc, 0xafa20014, 0x8fa60018,
-0x8fa7001c, 0x3c050004, 0xc002403, 0x34a5f005,
-0x8ee20088, 0x24420001, 0xaee20088, 0x8ee20088,
-0x80028d3, 0xaee0725c, 0x30430003, 0x24020002,
-0x10620016, 0x28620003, 0x10400005, 0x24020001,
-0x10620008, 0x0, 0x8002703, 0x0,
-0x24020003, 0x10620017, 0x0, 0x8002703,
-0x0, 0x8ee200e8, 0x8ee300ec, 0x24630001,
-0x2c640001, 0x441021, 0xaee200e8, 0xaee300ec,
-0x8ee200e8, 0x8002703, 0x8ee300ec, 0x8ee200f0,
-0x8ee300f4, 0x24630001, 0x2c640001, 0x441021,
-0xaee200f0, 0xaee300f4, 0x8ee200f0, 0x8002703,
-0x8ee300f4, 0x8ee200f8, 0x8ee300fc, 0x24630001,
-0x2c640001, 0x441021, 0xaee200f8, 0xaee300fc,
-0x8ee200f8, 0x8ee300fc, 0x8ee2725c, 0x8ee400e0,
-0x8ee500e4, 0x401821, 0x1021, 0xa32821,
-0xa3302b, 0x822021, 0x862021, 0xaee400e0,
-0xaee500e4, 0x80028d3, 0xaee0725c, 0x30e2ffff,
-0x104001c1, 0x31a20200, 0x1040014d, 0x4821,
-0x96e2045a, 0x30420010, 0x10400149, 0x0,
-0x8f840100, 0x27623000, 0x24850020, 0xa2102b,
-0x50400001, 0x27652800, 0x8f820108, 0x10a20004,
-0x0, 0x8f820104, 0x14a20006, 0x2402000c,
-0x8ee201a8, 0x24420001, 0xaee201a8, 0x800276e,
-0x8ee201a8, 0xac8a0000, 0xac8b0004, 0x8ee37264,
-0x24060005, 0xa482000e, 0xac860018, 0xac830008,
-0x8ee204e4, 0xac82001c, 0x8ee204c8, 0xac820010,
-0xaf850100, 0x92e204ec, 0x14400036, 0x24090001,
-0x8ee24e28, 0x210c0, 0x24424e38, 0x2e22021,
-0x8c820000, 0x1446001f, 0x0, 0x8ee34e28,
-0x8ee24e2c, 0x1062001b, 0x24030040, 0x8c820004,
-0x24420001, 0xac820004, 0x8ee24e2c, 0x8ee54e28,
-0x24420001, 0x10430007, 0x0, 0x8ee24e2c,
-0x24420001, 0x10a20005, 0x0, 0x8002758,
-0x0, 0x14a00005, 0x0, 0x8f820108,
-0x24420020, 0xaf820108, 0x8f820108, 0x8c820004,
-0x2c420011, 0x50400013, 0xac800000, 0x800276e,
-0x0, 0x8ee24e28, 0x24030040, 0x24420001,
-0x50430003, 0x1021, 0x8ee24e28, 0x24420001,
-0xaee24e28, 0x8ee24e28, 0x210c0, 0x24424e38,
-0x2e22021, 0x24020005, 0xac820000, 0x24020001,
-0xac820004, 0x1520000a, 0x3c040001, 0xafab0010,
-0x8ee27264, 0x3c040001, 0x248450c0, 0x3c050004,
-0xafa20014, 0x8ee604e4, 0x80028be, 0x34a5f014,
-0x8ee27264, 0x34843800, 0x3641821, 0x24420010,
-0x43102b, 0x14400073, 0x0, 0x8ee27264,
-0x24480010, 0x3641021, 0x102102b, 0x14400002,
-0x3c02ffff, 0x1024021, 0x8f850100, 0x27623000,
-0x24a60020, 0xc2102b, 0x50400001, 0x27662800,
-0x8f820108, 0x10c20004, 0x0, 0x8f820104,
-0x14c20007, 0x2563000c, 0x8ee201a8, 0x4821,
-0x24420001, 0xaee201a8, 0x80027e2, 0x8ee201a8,
-0x2c64000c, 0x1441021, 0xaca20000, 0xaca30004,
-0x24e2fff4, 0xa4a2000e, 0x24020006, 0xaca80008,
-0xaca20018, 0x8ee204e4, 0xaca2001c, 0x8ee204c8,
-0x3c030002, 0x431025, 0xaca20010, 0xaf860100,
-0x92e204ec, 0x14400037, 0x24090001, 0x8ee24e28,
-0x210c0, 0x24424e38, 0x2e22021, 0x8c830000,
-0x24020005, 0x1462001f, 0x0, 0x8ee34e28,
-0x8ee24e2c, 0x1062001b, 0x24030040, 0x8c820004,
-0x24420001, 0xac820004, 0x8ee24e2c, 0x8ee54e28,
-0x24420001, 0x10430007, 0x0, 0x8ee24e2c,
-0x24420001, 0x10a20005, 0x0, 0x80027cc,
-0x0, 0x14a00005, 0x0, 0x8f820108,
-0x24420020, 0xaf820108, 0x8f820108, 0x8c820004,
-0x2c420011, 0x50400013, 0xac800000, 0x80027e2,
-0x0, 0x8ee24e28, 0x24030040, 0x24420001,
-0x50430003, 0x1021, 0x8ee24e28, 0x24420001,
-0xaee24e28, 0x8ee24e28, 0x210c0, 0x24424e38,
-0x2e22021, 0x24020005, 0xac820000, 0x24020001,
-0xac820004, 0x1520000a, 0x2508fffc, 0xafab0010,
-0x8ee27264, 0x3c040001, 0x248450c0, 0x3c050004,
-0xafa20014, 0x8ee604e4, 0x80028be, 0x34a5f015,
-0x34028100, 0xa5020000, 0x9582000e, 0x800285f,
-0xa5020002, 0x8f850100, 0x27623000, 0x24a60020,
-0xc2102b, 0x50400001, 0x27662800, 0x8f820108,
-0x10c20004, 0x0, 0x8f820104, 0x14c20007,
-0x2563000c, 0x8ee201a8, 0x4821, 0x24420001,
-0xaee201a8, 0x800284f, 0x8ee201a8, 0x2c64000c,
-0x1441021, 0xaca20000, 0xaca30004, 0x8ee37264,
-0x24e2fff4, 0xa4a2000e, 0x24020006, 0xaca20018,
-0x24630010, 0xaca30008, 0x8ee204e4, 0xaca2001c,
-0x8ee204c8, 0x3c030002, 0x431025, 0xaca20010,
-0xaf860100, 0x92e204ec, 0x14400037, 0x24090001,
-0x8ee24e28, 0x210c0, 0x24424e38, 0x2e22021,
-0x8c830000, 0x24020005, 0x1462001f, 0x0,
-0x8ee34e28, 0x8ee24e2c, 0x1062001b, 0x24030040,
-0x8c820004, 0x24420001, 0xac820004, 0x8ee24e2c,
-0x8ee54e28, 0x24420001, 0x10430007, 0x0,
-0x8ee24e2c, 0x24420001, 0x10a20005, 0x0,
-0x8002839, 0x0, 0x14a00005, 0x0,
-0x8f820108, 0x24420020, 0xaf820108, 0x8f820108,
-0x8c820004, 0x2c420011, 0x50400013, 0xac800000,
-0x800284f, 0x0, 0x8ee24e28, 0x24030040,
-0x24420001, 0x50430003, 0x1021, 0x8ee24e28,
-0x24420001, 0xaee24e28, 0x8ee24e28, 0x210c0,
-0x24424e38, 0x2e22021, 0x24020005, 0xac820000,
-0x24020001, 0xac820004, 0x1520000a, 0x34028100,
-0xafab0010, 0x8ee27264, 0x3c040001, 0x248450c0,
-0x3c050004, 0xafa20014, 0x8ee604e4, 0x80028be,
-0x34a5f016, 0x8ee37264, 0xa462000c, 0x8ee37264,
-0x9582000e, 0xa462000e, 0x80028c2, 0x24e70004,
-0x8f830100, 0x27623000, 0x24640020, 0x82102b,
-0x50400001, 0x27642800, 0x8f820108, 0x10820004,
-0x0, 0x8f820104, 0x14820007, 0x24050005,
-0x8ee201a8, 0x4821, 0x24420001, 0xaee201a8,
-0x80028b6, 0x8ee201a8, 0xac6a0000, 0xac6b0004,
-0x8ee27264, 0xa467000e, 0xac650018, 0xac620008,
-0x8ee204e4, 0xac62001c, 0x8ee204c8, 0xac620010,
-0xaf840100, 0x92e204ec, 0x14400036, 0x24090001,
-0x8ee24e28, 0x210c0, 0x24424e38, 0x2e22021,
-0x8c820000, 0x1445001f, 0x0, 0x8ee34e28,
-0x8ee24e2c, 0x1062001b, 0x24030040, 0x8c820004,
-0x24420001, 0xac820004, 0x8ee24e2c, 0x8ee54e28,
-0x24420001, 0x10430007, 0x0, 0x8ee24e2c,
-0x24420001, 0x10a20005, 0x0, 0x80028a0,
-0x0, 0x14a00005, 0x0, 0x8f820108,
-0x24420020, 0xaf820108, 0x8f820108, 0x8c820004,
-0x2c420011, 0x50400013, 0xac800000, 0x80028b6,
-0x0, 0x8ee24e28, 0x24030040, 0x24420001,
-0x50430003, 0x1021, 0x8ee24e28, 0x24420001,
-0xaee24e28, 0x8ee24e28, 0x210c0, 0x24424e38,
-0x2e22021, 0x24020005, 0xac820000, 0x24020001,
-0xac820004, 0x1520000b, 0x3c050004, 0x3c040001,
-0x248450d8, 0xafab0010, 0xafa00014, 0x8ee604e4,
-0x34a5f017, 0xc002403, 0x30e7ffff, 0x80028e1,
-0x0, 0x8ee27264, 0x3c050001, 0x30e4ffff,
-0x441021, 0xaee27264, 0x8ee2725c, 0x8ee37264,
-0x34a53800, 0x441021, 0xaee2725c, 0x3651021,
-0x62182b, 0x14600004, 0x3c03ffff, 0x8ee27264,
-0x431021, 0xaee27264, 0x8ee304e4, 0x96e20458,
-0x24630001, 0x2442ffff, 0x621824, 0xaee304e4,
-0x8ee304e4, 0x8ee204e0, 0x14620005, 0x0,
-0x8f820060, 0x2403fff7, 0x431024, 0xaf820060,
-0x8fbf0020, 0x3e00008, 0x27bd0028, 0x27bdffe0,
-0xafbf0018, 0x8ee304e8, 0x8ee204e0, 0x10620189,
-0x0, 0x8ee204e8, 0x8ee304fc, 0x21100,
-0x621821, 0x94670008, 0x92e204ed, 0x8c680000,
-0x8c690004, 0x10400023, 0x946a000a, 0x8ee204c8,
-0x34460400, 0x31420200, 0x1040001f, 0x0,
-0x96e2045a, 0x30420010, 0x1040001b, 0x3c028000,
-0x3c010001, 0x370821, 0xac2283d8, 0x8ee27264,
-0x9464000e, 0x3c050001, 0x34a53800, 0x24420004,
-0xaee27264, 0x8ee37264, 0x42400, 0x3651021,
-0x3c010001, 0x370821, 0xac2483dc, 0x62182b,
-0x14600005, 0x24e70004, 0x8ee27264, 0x3c03ffff,
-0x431021, 0xaee27264, 0x8ee27264, 0x8002917,
-0xaee27258, 0x8ee604c8, 0x8ee2726c, 0x30e4ffff,
-0x44102a, 0x10400015, 0x0, 0x8f8200d8,
-0x8ee37258, 0x431023, 0xaee2726c, 0x8ee2726c,
-0x1c400007, 0x44102a, 0x8ee2726c, 0x3c030001,
-0x431021, 0xaee2726c, 0x8ee2726c, 0x44102a,
-0x10400006, 0x0, 0x8ee201b8, 0x24420001,
-0xaee201b8, 0x8002a72, 0x8ee201b8, 0x3c020001,
-0x571021, 0x8c4283d8, 0x54400001, 0x24e7fffc,
-0x31420004, 0x104000b9, 0x30e2ffff, 0x3c020001,
-0x571021, 0x8c4283d8, 0x1040002f, 0x5021,
-0x8f840100, 0x27623000, 0x24850020, 0xa2102b,
-0x50400001, 0x27652800, 0x8f820108, 0x10a20032,
-0x0, 0x8f820104, 0x10a2002f, 0x24020015,
-0xac880000, 0xac890004, 0x8ee37264, 0xa487000e,
-0xac820018, 0xac830008, 0x8ee204e8, 0x3c030001,
-0x771821, 0x8c6383dc, 0xac860010, 0x431025,
-0xac82001c, 0xaf850100, 0x92e204ec, 0x14400066,
-0x240a0001, 0x8ee24e28, 0x24030040, 0x24420001,
-0x50430003, 0x1021, 0x8ee24e28, 0x24420001,
-0xaee24e28, 0x8ee24e28, 0x210c0, 0x24424e38,
-0x2e21821, 0x24020015, 0xac620000, 0x24020001,
-0x80029bf, 0xac620004, 0x8f840100, 0x27623000,
-0x24850020, 0xa2102b, 0x50400001, 0x27652800,
-0x8f820108, 0x10a20004, 0x0, 0x8f820104,
-0x14a20006, 0x24020006, 0x8ee201a8, 0x24420001,
-0xaee201a8, 0x80029bf, 0x8ee201a8, 0xac880000,
-0xac890004, 0x8ee37264, 0xa487000e, 0xac820018,
-0xac830008, 0x8ee204e8, 0xac860010, 0xac82001c,
-0xaf850100, 0x92e204ec, 0x14400037, 0x240a0001,
-0x8ee24e28, 0x210c0, 0x24424e38, 0x2e22021,
-0x8c830000, 0x24020005, 0x1462001f, 0x0,
-0x8ee34e28, 0x8ee24e2c, 0x1062001b, 0x24030040,
-0x8c820004, 0x24420001, 0xac820004, 0x8ee24e2c,
-0x8ee54e28, 0x24420001, 0x10430007, 0x0,
-0x8ee24e2c, 0x24420001, 0x10a20005, 0x0,
-0x80029a9, 0x0, 0x14a00005, 0x0,
-0x8f820108, 0x24420020, 0xaf820108, 0x8f820108,
-0x8c820004, 0x2c420011, 0x50400013, 0xac800000,
-0x80029bf, 0x0, 0x8ee24e28, 0x24030040,
-0x24420001, 0x50430003, 0x1021, 0x8ee24e28,
-0x24420001, 0xaee24e28, 0x8ee24e28, 0x210c0,
-0x24424e38, 0x2e22021, 0x24020005, 0xac820000,
-0x24020001, 0xac820004, 0x1540000a, 0x24020001,
-0xafa90010, 0x8ee27264, 0x3c040001, 0x248450c0,
-0x3c050004, 0xafa20014, 0x8ee604e4, 0x8002a4f,
-0x34a5f204, 0xa2e204ed, 0x8ee204e8, 0x8ee304fc,
-0x8ee47258, 0x3c060001, 0x34c63800, 0x3c010001,
-0x370821, 0xac2083d8, 0x3c010001, 0x370821,
-0xac2083dc, 0x21100, 0x431021, 0xac44000c,
-0x8ee27264, 0x2405fff8, 0x30e3ffff, 0x431021,
-0x24420007, 0x451024, 0x24630007, 0xaee27258,
-0x8ee2726c, 0x8ee47258, 0x651824, 0x431023,
-0xaee2726c, 0x3661021, 0x82202b, 0x14800004,
-0x3c03ffff, 0x8ee27258, 0x431021, 0xaee27258,
-0x8ee27258, 0x8002a64, 0xaee27264, 0x10400073,
-0x0, 0x8f830100, 0x27623000, 0x24640020,
-0x82102b, 0x14400002, 0x5021, 0x27642800,
-0x8f820108, 0x10820004, 0x0, 0x8f820104,
-0x14820006, 0x24050005, 0x8ee201a8, 0x24420001,
-0xaee201a8, 0x8002a46, 0x8ee201a8, 0xac680000,
-0xac690004, 0x8ee27264, 0xa467000e, 0xac650018,
-0xac620008, 0x8ee204e8, 0xac660010, 0xac62001c,
-0xaf840100, 0x92e204ec, 0x14400036, 0x240a0001,
-0x8ee24e28, 0x210c0, 0x24424e38, 0x2e22021,
-0x8c820000, 0x1445001f, 0x0, 0x8ee34e28,
-0x8ee24e2c, 0x1062001b, 0x24030040, 0x8c820004,
-0x24420001, 0xac820004, 0x8ee24e2c, 0x8ee54e28,
-0x24420001, 0x10430007, 0x0, 0x8ee24e2c,
-0x24420001, 0x10a20005, 0x0, 0x8002a30,
-0x0, 0x14a00005, 0x0, 0x8f820108,
-0x24420020, 0xaf820108, 0x8f820108, 0x8c820004,
-0x2c420011, 0x50400013, 0xac800000, 0x8002a46,
-0x0, 0x8ee24e28, 0x24030040, 0x24420001,
-0x50430003, 0x1021, 0x8ee24e28, 0x24420001,
-0xaee24e28, 0x8ee24e28, 0x210c0, 0x24424e38,
-0x2e22021, 0x24020005, 0xac820000, 0x24020001,
-0xac820004, 0x1540000c, 0x30e5ffff, 0x3c040001,
-0x248450d8, 0x3c050004, 0xafa90010, 0xafa00014,
-0x8ee604e4, 0x34a5f237, 0xc002403, 0x30e7ffff,
-0x8002a72, 0x0, 0x8ee27264, 0x451021,
-0xaee27264, 0x8ee2726c, 0x8ee37264, 0x3c040001,
-0x34843800, 0xa2e004ed, 0x451023, 0xaee2726c,
-0x3641021, 0x62182b, 0x14600004, 0x3c03ffff,
-0x8ee27264, 0x431021, 0xaee27264, 0x8ee304e8,
-0x96e20458, 0x24630001, 0x2442ffff, 0x621824,
-0xaee304e8, 0x8ee304e8, 0x8ee204e0, 0x14620005,
-0x0, 0x8f820060, 0x2403fff7, 0x431024,
-0xaf820060, 0x8fbf0018, 0x3e00008, 0x27bd0020,
-0x27bdffe0, 0xafbf001c, 0xafb00018, 0x8f820100,
-0x8ee34e2c, 0x8f820104, 0x8f850108, 0x24020040,
-0x24630001, 0x50620003, 0x1021, 0x8ee24e2c,
-0x24420001, 0xaee24e2c, 0x8ee24e2c, 0x8ee34e2c,
-0x210c0, 0x24424e38, 0x2e22021, 0x8ee24e28,
-0x8c870004, 0x14620007, 0xa03021, 0x8f820108,
-0x24420020, 0xaf820108, 0x8f820108, 0x8002aa2,
-0xac800000, 0x8ee24e2c, 0x24030040, 0x24420001,
-0x50430003, 0x1021, 0x8ee24e2c, 0x24420001,
-0x210c0, 0x24424e38, 0x2e22021, 0x8c820004,
-0x8f830108, 0x21140, 0x621821, 0xaf830108,
-0xac800000, 0x8cc20018, 0x2443fffe, 0x2c620013,
-0x104000c1, 0x31080, 0x3c010001, 0x220821,
-0x8c225100, 0x400008, 0x0, 0x8ee204f0,
-0x471021, 0xaee204f0, 0x8ee204f0, 0x8f43023c,
-0x43102b, 0x144000be, 0x0, 0x8ee304e4,
-0x8ee204f8, 0x506200ba, 0xa2e004f4, 0x8f830120,
-0x27623800, 0x24660020, 0xc2102b, 0x50400001,
-0x27663000, 0x8f820128, 0x10c20004, 0x0,
-0x8f820124, 0x14c20007, 0x0, 0x8ee201a4,
-0x8021, 0x24420001, 0xaee201a4, 0x8002b12,
-0x8ee201a4, 0x8ee204e4, 0xac62001c, 0x8ee404b0,
-0x8ee504b4, 0x2462001c, 0xac620008, 0x24020008,
-0xa462000e, 0x24020011, 0xac620018, 0xac640000,
-0xac650004, 0x8ee204c4, 0xac620010, 0xaf860120,
-0x92e24e20, 0x14400037, 0x24100001, 0x8ee24e30,
-0x210c0, 0x24425038, 0x2e22021, 0x8c830000,
-0x24020012, 0x1462001f, 0x0, 0x8ee34e30,
-0x8ee24e34, 0x1062001b, 0x24030040, 0x8c820004,
-0x24420001, 0xac820004, 0x8ee24e34, 0x8ee54e30,
-0x24420001, 0x10430007, 0x0, 0x8ee24e34,
-0x24420001, 0x10a20005, 0x0, 0x8002afc,
-0x0, 0x14a00005, 0x0, 0x8f820128,
-0x24420020, 0xaf820128, 0x8f820128, 0x8c820004,
-0x2c420011, 0x50400013, 0xac800000, 0x8002b12,
-0x0, 0x8ee24e30, 0x24030040, 0x24420001,
-0x50430003, 0x1021, 0x8ee24e30, 0x24420001,
-0xaee24e30, 0x8ee24e30, 0x210c0, 0x24425038,
-0x2e22021, 0x24020012, 0xac820000, 0x24020001,
-0xac820004, 0x5600000b, 0x24100001, 0x8ee204e4,
-0x3c040001, 0x248450e4, 0xafa00014, 0xafa20010,
-0x8ee60608, 0x8f470228, 0x3c050009, 0xc002403,
-0x34a5f006, 0x16000003, 0x24020001, 0x8002b71,
-0xa2e204f4, 0x8ee20170, 0x24420001, 0xaee20170,
-0x8ee20170, 0x8ee204e4, 0xa2e004f4, 0xaee004f0,
-0xaee204f8, 0x8f42023c, 0x50400045, 0xaee07274,
-0x8ee20184, 0x24420001, 0xaee20184, 0x8ee20184,
-0x8002b71, 0xaee07274, 0x8ee20504, 0x24030040,
-0x24420001, 0x50430003, 0x1021, 0x8ee20504,
-0x24420001, 0xaee20504, 0x8ee20504, 0x8cc30018,
-0x21080, 0x571021, 0x8c440508, 0x24020003,
-0x1462000f, 0x0, 0x3c020001, 0x571021,
-0x904283b1, 0x10400014, 0x0, 0x8ee201d0,
-0x8ee35240, 0x441021, 0xaee201d0, 0x8ee201d8,
-0x641821, 0x306300ff, 0x8002b59, 0xaee35240,
-0x8ee201cc, 0x8ee30e10, 0x441021, 0xaee201cc,
-0x8ee201d8, 0x641821, 0x306301ff, 0xaee30e10,
-0x441021, 0xaee201d8, 0x8ee20000, 0x34420040,
-0x8002b71, 0xaee20000, 0x8ee2014c, 0x3c010001,
-0x370821, 0xa02083e0, 0x24420001, 0xaee2014c,
-0x8002b71, 0x8ee2014c, 0x94c7000e, 0x8cc2001c,
-0x3c040001, 0x248450f0, 0xafa60014, 0xafa20010,
-0x8cc60018, 0x3c050008, 0xc002403, 0x34a50910,
-0x8fbf001c, 0x8fb00018, 0x3e00008, 0x27bd0020,
-0x27bdff98, 0xafbf0060, 0xafbe005c, 0xafb60058,
-0xafb50054, 0xafb40050, 0xafb3004c, 0xafb20048,
-0xafb10044, 0xafb00040, 0x8f830108, 0x8f820104,
-0xafa00024, 0x106203e7, 0xafa0002c, 0x3c1e0001,
-0x37de3800, 0x3c0bffff, 0x8f930108, 0x8e620018,
-0x8f830104, 0x2443fffe, 0x2c620014, 0x104003cf,
-0x31080, 0x3c010001, 0x220821, 0x8c225150,
-0x400008, 0x0, 0x9663000e, 0x8ee2725c,
-0x8ee404f0, 0x431021, 0xaee2725c, 0x8e63001c,
-0x96e20458, 0x24840001, 0xaee404f0, 0x24630001,
-0x2442ffff, 0x621824, 0xaee304e4, 0x8f42023c,
-0x82202b, 0x148003b9, 0x0, 0x8f830120,
-0x27623800, 0x24660020, 0xc2102b, 0x50400001,
-0x27663000, 0x8f820128, 0x10c20004, 0x0,
-0x8f820124, 0x14c20007, 0x0, 0x8ee201a4,
-0x8021, 0x24420001, 0xaee201a4, 0x8002bfe,
-0x8ee201a4, 0x8ee204e4, 0xac62001c, 0x8ee404b0,
-0x8ee504b4, 0x2462001c, 0xac620008, 0x24020008,
-0xa462000e, 0x24020011, 0xac620018, 0xac640000,
-0xac650004, 0x8ee204c4, 0xac620010, 0xaf860120,
-0x92e24e20, 0x14400037, 0x24100001, 0x8ee24e30,
-0x210c0, 0x24425038, 0x2e22021, 0x8c830000,
-0x24020012, 0x1462001f, 0x0, 0x8ee34e30,
-0x8ee24e34, 0x1062001b, 0x240c0040, 0x8c820004,
-0x24420001, 0xac820004, 0x8ee24e34, 0x8ee34e30,
-0x24420001, 0x104c0007, 0x0, 0x8ee24e34,
-0x24420001, 0x10620005, 0x0, 0x8002be8,
-0x0, 0x14600005, 0x0, 0x8f820128,
-0x24420020, 0xaf820128, 0x8f820128, 0x8c820004,
-0x2c420011, 0x50400013, 0xac800000, 0x8002bfe,
-0x0, 0x8ee24e30, 0x240c0040, 0x24420001,
-0x504c0003, 0x1021, 0x8ee24e30, 0x24420001,
-0xaee24e30, 0x8ee24e30, 0x210c0, 0x24425038,
-0x2e22021, 0x24020012, 0x240c0001, 0xac820000,
-0xac8c0004, 0x5600000d, 0x24100001, 0x8ee204e4,
-0x3c040001, 0x248450e4, 0xafa00014, 0xafa20010,
-0x8ee60608, 0x8f470228, 0x3c050009, 0x34a5f006,
-0xc002403, 0xafab0038, 0x8fab0038, 0x1200030a,
-0x240c0001, 0x8002f19, 0x0, 0x966c001c,
-0xafac002c, 0x9662001e, 0x3c0c8000, 0xafac0024,
-0xae62001c, 0x8e75001c, 0x8ee204fc, 0x8ee404fc,
-0x151900, 0x621021, 0x8c52000c, 0x92e27b98,
-0x641821, 0x9476000a, 0x14400003, 0x32c20002,
-0xaef27ba4, 0xaef57b9c, 0x1040004b, 0x8021,
-0x96e2045a, 0x30420002, 0x10400047, 0x0,
-0x8e63001c, 0x8ee204fc, 0x32100, 0x821021,
-0x8c42000c, 0x37e1821, 0x24420022, 0x43102b,
-0x1440000a, 0x24050014, 0x8ee204fc, 0x821021,
-0x8c44000c, 0xafab0038, 0xc002f75, 0x2484000e,
-0x8fab0038, 0x8002c52, 0x3050ffff, 0x8ee204fc,
-0x821021, 0x8c42000c, 0x9450000e, 0x94430010,
-0x94440012, 0x94450014, 0x2038021, 0x2048021,
-0x2058021, 0x94430016, 0x94440018, 0x9445001a,
-0x2038021, 0x2048021, 0x2058021, 0x9443001c,
-0x9444001e, 0x94420020, 0x2038021, 0x2048021,
-0x2028021, 0x101c02, 0x3202ffff, 0x628021,
-0x8e63001c, 0x8ee204fc, 0x102402, 0x32900,
-0xa21021, 0x8c43000c, 0x3202ffff, 0x828021,
-0x37e1021, 0x24630018, 0x62182b, 0x14600009,
-0x0, 0x8ee204fc, 0xa21021, 0x8c43000c,
-0x101027, 0x3c01ffff, 0x230821, 0x8002c6f,
-0xa4220018, 0x8ee204fc, 0xa21021, 0x8c43000c,
-0x101027, 0xa4620018, 0x96e2045a, 0x8821,
-0x30420008, 0x14400063, 0xa021, 0x8e63001c,
-0x8ee204fc, 0x33100, 0xc21021, 0x8c42000c,
-0x37e1821, 0x24420022, 0x43102b, 0x14400035,
-0x0, 0x8ee204fc, 0xc21021, 0x8c42000c,
-0x24470010, 0x37e1021, 0xe2102b, 0x50400001,
-0xeb3821, 0x8ee204fc, 0x94f10000, 0xc21021,
-0x8c42000c, 0x24470016, 0x37e1021, 0xe2102b,
-0x14400002, 0x2634ffec, 0xeb3821, 0x8ee204fc,
-0x90e30001, 0xc21021, 0x8c42000c, 0x2447001a,
-0x37e1021, 0xe2102b, 0x14400002, 0x2838821,
-0xeb3821, 0x94e20000, 0x24e70002, 0x2228821,
-0x37e1021, 0xe2102b, 0x50400001, 0xeb3821,
-0x94e20000, 0x24e70002, 0x2228821, 0x37e1021,
-0xe2102b, 0x50400001, 0xeb3821, 0x94e20000,
-0x24e70002, 0x2228821, 0x37e1021, 0xe2102b,
-0x50400001, 0xeb3821, 0x94e20000, 0x8002cd0,
-0x2228821, 0x8ee204fc, 0xc21021, 0x8c43000c,
-0x8ee204fc, 0x94710010, 0x8ee304fc, 0xc21021,
-0x8c44000c, 0xc31821, 0x8c62000c, 0x2634ffec,
-0x90840017, 0x8ee304fc, 0x9442001a, 0x2848821,
-0xc31821, 0x8c65000c, 0x8ee304fc, 0x2228821,
-0x8ee204fc, 0xc31821, 0xc21021, 0x8c44000c,
-0x8c62000c, 0x94a3001c, 0x9484001e, 0x94420020,
-0x2238821, 0x2248821, 0x2228821, 0x111c02,
-0x3222ffff, 0x628821, 0x111c02, 0x3222ffff,
-0x628821, 0x32c20001, 0x104000b2, 0x0,
-0x96e2045a, 0x30420001, 0x104000ae, 0x32c20080,
-0x10400008, 0x0, 0x92e27b98, 0x14400005,
-0x0, 0x240c0001, 0xa2ec7b98, 0xaef57b9c,
-0xaef27ba4, 0x8ee304fc, 0x151100, 0x431021,
-0x8c47000c, 0x37e1821, 0x24e2000e, 0x43102b,
-0x14400008, 0xe02021, 0x2405000e, 0xc002f75,
-0xafab0038, 0x3042ffff, 0x8fab0038, 0x8002d09,
-0x2028021, 0x94e60000, 0x24e70002, 0x94e50000,
-0x24e70002, 0x94e30000, 0x24e70002, 0x94e20000,
-0x24e70002, 0x94e40000, 0x24e70002, 0x2068021,
-0x2058021, 0x2038021, 0x2028021, 0x94e20000,
-0x94e30002, 0x2048021, 0x2028021, 0x2038021,
-0x101c02, 0x3202ffff, 0x628021, 0x101c02,
-0x3202ffff, 0x8ee47b9c, 0x628021, 0x14950004,
-0x3205ffff, 0x96620016, 0x8002d17, 0x512021,
-0x96620016, 0x542021, 0x41402, 0x3083ffff,
-0x432021, 0x852023, 0x41402, 0x822021,
-0x3084ffff, 0x50800001, 0x3404ffff, 0x8ee27ba4,
-0x24430017, 0x37e1021, 0x62102b, 0x50400001,
-0x6b1821, 0x90630000, 0x24020011, 0x14620031,
-0x24020006, 0x8ee27ba4, 0x37e1821, 0x24420028,
-0x43102b, 0x14400018, 0x0, 0x8ee27b9c,
-0x12a2000a, 0x32c20100, 0x8ee27ba4, 0x3c01ffff,
-0x220821, 0x94220028, 0x822021, 0x41c02,
-0x3082ffff, 0x622021, 0x32c20100, 0x14400004,
-0x41027, 0x92e27b98, 0x14400002, 0x41027,
-0x3044ffff, 0x8ee27ba4, 0x3c01ffff, 0x220821,
-0x8002d8a, 0xa4240028, 0x8ee27b9c, 0x12a20008,
-0x32c20100, 0x8ee27ba4, 0x94420028, 0x822021,
-0x41c02, 0x3082ffff, 0x622021, 0x32c20100,
-0x14400004, 0x41027, 0x92e27b98, 0x14400002,
-0x41027, 0x3044ffff, 0x8ee27ba4, 0x8002d8a,
-0xa4440028, 0x1462002f, 0x37e1821, 0x8ee27ba4,
-0x24420032, 0x43102b, 0x14400018, 0x0,
-0x8ee27b9c, 0x12a2000a, 0x32c20100, 0x8ee27ba4,
-0x3c01ffff, 0x220821, 0x94220032, 0x822021,
-0x41c02, 0x3082ffff, 0x622021, 0x32c20100,
-0x14400004, 0x41027, 0x92e27b98, 0x14400002,
-0x41027, 0x3044ffff, 0x8ee27ba4, 0x3c01ffff,
-0x220821, 0x8002d8a, 0xa4240032, 0x8ee27b9c,
-0x12a20008, 0x32c20100, 0x8ee27ba4, 0x94420032,
-0x822021, 0x41c02, 0x3082ffff, 0x622021,
-0x32c20100, 0x14400004, 0x41027, 0x92e27b98,
-0x14400002, 0x41027, 0x3044ffff, 0x8ee27ba4,
-0xa4440032, 0x8fac0024, 0x1180002c, 0x37e1821,
-0x8e420000, 0xae42fffc, 0x2642000a, 0x43102b,
-0x1440001b, 0x34038100, 0x26430004, 0x37e1021,
-0x62102b, 0x14400003, 0x602021, 0x6b1821,
-0x602021, 0x8c620000, 0x24630004, 0xae420000,
-0x37e1021, 0x62102b, 0x50400001, 0x6b1821,
-0x8c620000, 0xac820000, 0x34028100, 0xa4620000,
-0x24630002, 0x37e1021, 0x62102b, 0x50400001,
-0x6b1821, 0x97ac002e, 0x8002db4, 0xa46c0000,
-0x8e420004, 0x8e440008, 0xa6430008, 0x97ac002e,
-0xa64c000a, 0xae420000, 0xae440004, 0x9662000e,
-0x2652fffc, 0x24420004, 0xa662000e, 0x9662000e,
-0x8ee3725c, 0x621821, 0xaee3725c, 0xafb20018,
-0x8ee3725c, 0xafa3001c, 0x8ee2725c, 0x2c42003c,
-0x10400004, 0x24620001, 0x2403fffe, 0x431024,
-0xafa2001c, 0x32c20080, 0x1040000c, 0x32c20100,
-0x8ee27ba8, 0x24430001, 0x210c0, 0x571021,
-0xaee37ba8, 0x8fa30018, 0x8fa4001c, 0xac437bac,
-0xac447bb0, 0x8002ea0, 0xaee0725c, 0x10400072,
-0x0, 0x8ee27ba8, 0x24430001, 0x210c0,
-0x571021, 0xaee37ba8, 0x8fa30018, 0x8fa4001c,
-0xac437bac, 0xac447bb0, 0x8ee27ba8, 0x10400063,
-0x4821, 0x5021, 0x8f8200f0, 0x24480008,
-0x27621800, 0x102102b, 0x50400001, 0x27681000,
-0x8f8200f4, 0x15020007, 0x0, 0x8ee201b4,
-0x8021, 0x24420001, 0xaee201b4, 0x8002dfa,
-0x8ee201b4, 0x8f8300f0, 0x24100001, 0x1571021,
-0x8c447bac, 0x8c457bb0, 0xac640000, 0xac650004,
-0xaf8800f0, 0x16000006, 0x2ea1021, 0x8ee20088,
-0x24420001, 0xaee20088, 0x8002e3f, 0x8ee20088,
-0x8c427bb0, 0x8ee400e0, 0x8ee500e4, 0x8ee67b9c,
-0x401821, 0x1021, 0xa32821, 0xa3382b,
-0x822021, 0x872021, 0x8ee204fc, 0xc93021,
-0x63100, 0xaee400e0, 0xaee500e4, 0xc23021,
-0x94c2000a, 0x240c0002, 0x21142, 0x30430003,
-0x106c0016, 0x28620003, 0x10400005, 0x240c0001,
-0x106c0008, 0x0, 0x8002e3f, 0x0,
-0x240c0003, 0x106c0017, 0x0, 0x8002e3f,
-0x0, 0x8ee200e8, 0x8ee300ec, 0x24630001,
-0x2c640001, 0x441021, 0xaee200e8, 0xaee300ec,
-0x8ee200e8, 0x8002e3f, 0x8ee300ec, 0x8ee200f0,
-0x8ee300f4, 0x24630001, 0x2c640001, 0x441021,
-0xaee200f0, 0xaee300f4, 0x8ee200f0, 0x8002e3f,
-0x8ee300f4, 0x8ee200f8, 0x8ee300fc, 0x24630001,
-0x2c640001, 0x441021, 0xaee200f8, 0xaee300fc,
-0x8ee200f8, 0x8ee300fc, 0x8ee27ba8, 0x25290001,
-0x122102b, 0x1440ffa0, 0x254a0008, 0xa2e07b98,
-0x8002e9f, 0xaee07ba8, 0x8f8200f0, 0x24470008,
-0x27621800, 0xe2102b, 0x50400001, 0x27671000,
-0x8f8200f4, 0x14e20007, 0x0, 0x8ee201b4,
-0x8021, 0x24420001, 0xaee201b4, 0x8002e5d,
-0x8ee201b4, 0x8f8200f0, 0x24100001, 0x8fa30018,
-0x8fa4001c, 0xac430000, 0xac440004, 0xaf8700f0,
-0x16000007, 0x0, 0x8ee20088, 0x24420001,
-0xaee20088, 0x8ee20088, 0x8002ea0, 0xaee0725c,
-0x8ee2725c, 0x8ee400e0, 0x8ee500e4, 0x240c0002,
-0x401821, 0x1021, 0xa32821, 0xa3302b,
-0x822021, 0x862021, 0x161142, 0x30430003,
-0xaee400e0, 0xaee500e4, 0x106c0017, 0x2c620003,
-0x10400005, 0x240c0001, 0x106c0008, 0x0,
-0x8002ea0, 0xaee0725c, 0x240c0003, 0x106c0019,
-0x0, 0x8002ea0, 0xaee0725c, 0x8ee200e8,
-0x8ee300ec, 0x24630001, 0x2c640001, 0x441021,
-0xaee200e8, 0xaee300ec, 0x8ee200e8, 0x8ee300ec,
-0x8002ea0, 0xaee0725c, 0x8ee200f0, 0x8ee300f4,
-0x24630001, 0x2c640001, 0x441021, 0xaee200f0,
-0xaee300f4, 0x8ee200f0, 0x8ee300f4, 0x8002ea0,
-0xaee0725c, 0x8ee200f8, 0x8ee300fc, 0x24630001,
-0x2c640001, 0x441021, 0xaee200f8, 0xaee300fc,
-0x8ee200f8, 0x8ee300fc, 0xaee0725c, 0x8e62001c,
-0x96e30458, 0x8ee404f0, 0x24420001, 0x2463ffff,
-0x431024, 0x24840001, 0xaee204e4, 0xaee404f0,
-0x8f42023c, 0x82202b, 0x148000b0, 0x0,
-0x8f830120, 0x27623800, 0x24660020, 0xc2102b,
-0x50400001, 0x27663000, 0x8f820128, 0x10c20004,
-0x0, 0x8f820124, 0x14c20007, 0x0,
-0x8ee201a4, 0x8021, 0x24420001, 0xaee201a4,
-0x8002f07, 0x8ee201a4, 0x8ee204e4, 0xac62001c,
-0x8ee404b0, 0x8ee504b4, 0x2462001c, 0xac620008,
-0x24020008, 0xa462000e, 0x24020011, 0xac620018,
-0xac640000, 0xac650004, 0x8ee204c4, 0xac620010,
-0xaf860120, 0x92e24e20, 0x14400037, 0x24100001,
-0x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
-0x8c830000, 0x24020012, 0x1462001f, 0x0,
-0x8ee34e30, 0x8ee24e34, 0x1062001b, 0x240c0040,
-0x8c820004, 0x24420001, 0xac820004, 0x8ee24e34,
-0x8ee34e30, 0x24420001, 0x104c0007, 0x0,
-0x8ee24e34, 0x24420001, 0x10620005, 0x0,
-0x8002ef1, 0x0, 0x14600005, 0x0,
-0x8f820128, 0x24420020, 0xaf820128, 0x8f820128,
-0x8c820004, 0x2c420011, 0x50400013, 0xac800000,
-0x8002f07, 0x0, 0x8ee24e30, 0x240c0040,
-0x24420001, 0x504c0003, 0x1021, 0x8ee24e30,
-0x24420001, 0xaee24e30, 0x8ee24e30, 0x210c0,
-0x24425038, 0x2e22021, 0x24020012, 0x240c0001,
-0xac820000, 0xac8c0004, 0x5600000d, 0x24100001,
-0x8ee204e4, 0x3c040001, 0x248450e4, 0xafa00014,
-0xafa20010, 0x8ee60608, 0x8f470228, 0x3c050009,
-0x34a5f006, 0xc002403, 0xafab0038, 0x8fab0038,
-0x16000003, 0x240c0001, 0x8002f5c, 0xa2ec04f4,
-0x8ee20170, 0x24420001, 0xaee20170, 0x8ee20170,
-0x8ee204e4, 0xa2e004f4, 0xaee004f0, 0xaee07274,
-0xaee204f8, 0x8f42023c, 0x10400038, 0x0,
-0x8ee20184, 0x24420001, 0xaee20184, 0x8002f5c,
-0x8ee20184, 0x8ee20504, 0x240c0040, 0x24420001,
-0x504c0003, 0x1021, 0x8ee20504, 0x24420001,
-0xaee20504, 0x8ee20504, 0x8e630018, 0x240c0003,
-0x21080, 0x571021, 0x146c000f, 0x8c440508,
-0x3c020001, 0x571021, 0x904283b1, 0x10400014,
-0x0, 0x8ee201d0, 0x8ee35240, 0x441021,
-0xaee201d0, 0x8ee201d8, 0x641821, 0x306300ff,
-0x8002f4f, 0xaee35240, 0x8ee201cc, 0x8ee30e10,
-0x441021, 0xaee201cc, 0x8ee201d8, 0x641821,
-0x306301ff, 0xaee30e10, 0x441021, 0xaee201d8,
-0x8ee20000, 0x34420040, 0x8002f5c, 0xaee20000,
-0x8ee2014c, 0x3c010001, 0x370821, 0xa02083e0,
-0x24420001, 0xaee2014c, 0x8ee2014c, 0x8f820108,
-0x24420020, 0xaf820108, 0x8f820108, 0x8f820108,
-0x27633000, 0x43102b, 0x14400002, 0x27622800,
-0xaf820108, 0x8f830108, 0x8f820104, 0x1462fc1e,
-0x0, 0x8fbf0060, 0x8fbe005c, 0x8fb60058,
-0x8fb50054, 0x8fb40050, 0x8fb3004c, 0x8fb20048,
-0x8fb10044, 0x8fb00040, 0x3e00008, 0x27bd0068,
-0x52843, 0x10a0000d, 0x3021, 0x3c030001,
-0x34633800, 0x3c07ffff, 0x3631021, 0x82102b,
-0x50400001, 0x872021, 0x94820000, 0x24840002,
-0x24a5ffff, 0x14a0fff8, 0xc23021, 0x61c02,
-0x30c2ffff, 0x623021, 0x61c02, 0x30c2ffff,
-0x623021, 0x3e00008, 0x30c2ffff, 0x27bdff88,
-0x240f0001, 0xafbf0070, 0xafbe006c, 0xafb60068,
-0xafb50064, 0xafb40060, 0xafb3005c, 0xafb20058,
-0xafb10054, 0xafb00050, 0xa3a00027, 0xafaf002c,
-0x8ee204d4, 0x8021, 0x30420001, 0x1440002a,
-0xa3a00037, 0x8f8700e0, 0x8f8800c4, 0x8f8200e8,
-0xe22023, 0x2c821000, 0x50400001, 0x24841000,
-0x420c2, 0x801821, 0x8ee400c8, 0x8ee500cc,
-0x1021, 0xa32821, 0xa3302b, 0x822021,
-0x862021, 0xaee400c8, 0xaee500cc, 0x8f8300c8,
-0x3c02000a, 0x3442efff, 0x1032023, 0x44102b,
-0x10400003, 0x3c02000a, 0x3442f000, 0x822021,
-0x801821, 0x8ee400c0, 0x8ee500c4, 0x1021,
-0xa32821, 0xa3302b, 0x822021, 0x862021,
-0xaee400c0, 0xaee500c4, 0xaf8800c8, 0xaf8700e4,
-0x80034cc, 0xaf8700e8, 0x3c020001, 0x571021,
-0x904283c0, 0x1040000b, 0x0, 0x3c140001,
-0x297a021, 0x8e9483c4, 0x3c130001, 0x2779821,
-0x8e7383c8, 0x3c120001, 0x2579021, 0x8003193,
-0x8e5283cc, 0x8f8300e0, 0x8f8200e4, 0x10430007,
-0x8821, 0x8f8200e4, 0x24110001, 0x8c430000,
-0x8c440004, 0xafa30018, 0xafa4001c, 0x1620000e,
-0x3c02ffff, 0x8f8200c4, 0xafa20010, 0x8f8200c8,
-0x3c040001, 0x24845200, 0xafa20014, 0x8f8600e0,
-0x8f8700e4, 0x3c050006, 0xc002403, 0x34a5f000,
-0x80034cc, 0x0, 0x8fa3001c, 0x8fb20018,
-0x3074ffff, 0x2694fffc, 0x621024, 0x10400058,
-0x2409821, 0x3c020080, 0x621024, 0x1040000a,
-0x3c040040, 0x8ee2007c, 0x24420001, 0xaee2007c,
-0x8ee2007c, 0x8ee201fc, 0x24420001, 0xaee201fc,
-0x80034c6, 0x8ee201fc, 0x3c060004, 0x3c0b0001,
-0x3c0a0002, 0x3c050010, 0x3c090008, 0x8ee20080,
-0x3c080020, 0x34078000, 0x24420001, 0xaee20080,
-0x8ee20080, 0x8fa2001c, 0x441824, 0x10660021,
-0xc3102b, 0x14400007, 0x0, 0x106b0011,
-0x0, 0x106a0015, 0x0, 0x8003049,
-0x42042, 0x10650023, 0xa3102b, 0x14400005,
-0x0, 0x10690019, 0x0, 0x8003049,
-0x42042, 0x10680021, 0x0, 0x8003049,
-0x42042, 0x8ee20034, 0x24420001, 0xaee20034,
-0x8ee20034, 0x8003049, 0x42042, 0x8ee201ec,
-0x24420001, 0xaee201ec, 0x8ee201ec, 0x8003049,
-0x42042, 0x8ee201f0, 0x24420001, 0xaee201f0,
-0x8ee201f0, 0x8003049, 0x42042, 0x8ee201f4,
-0x24420001, 0xaee201f4, 0x8ee201f4, 0x8003049,
-0x42042, 0x8ee20030, 0x24420001, 0xaee20030,
-0x8ee20030, 0x8003049, 0x42042, 0x8ee201f8,
-0x24420001, 0xaee201f8, 0x8ee201f8, 0x42042,
-0x1087047c, 0x0, 0x800300e, 0x0,
-0x3c020001, 0x571021, 0x904283b2, 0x14400084,
-0x24020001, 0x3c030001, 0x771821, 0x906383b3,
-0x1462007f, 0x3c020100, 0x8e430000, 0x621024,
-0x1040006f, 0x2402ffff, 0x14620005, 0x24100001,
-0x96430004, 0x3402ffff, 0x10620075, 0x0,
-0x92e204d8, 0x14400072, 0x0, 0x3c020001,
-0x571021, 0x8c4283b4, 0x28420005, 0x10400020,
-0x3821, 0x3c020001, 0x571021, 0x8c4283b4,
-0x18400016, 0x2821, 0x96660000, 0x520c0,
-0x971021, 0x9442777e, 0x14460009, 0x971021,
-0x94437780, 0x96620002, 0x14620005, 0x971021,
-0x94437782, 0x96620004, 0x50620008, 0x24070001,
-0x3c020001, 0x571021, 0x8c4283b4, 0x24a50001,
-0xa2102a, 0x5440ffee, 0x520c0, 0x30e200ff,
-0x10400440, 0x0, 0x80030d5, 0x0,
-0x2402021, 0xc0022fe, 0x24050006, 0x3044001f,
-0x428c0, 0x2e51021, 0x9442727c, 0x30424000,
-0x14400434, 0xb71021, 0x9443727e, 0x96620000,
-0x1462000b, 0x418c0, 0xb71021, 0x94437280,
-0x96620002, 0x14620006, 0x418c0, 0xb71021,
-0x94437282, 0x96620004, 0x10620035, 0x418c0,
-0x2e31021, 0x9442727c, 0x30428000, 0x14400421,
-0x2e31021, 0x944b727c, 0x96670000, 0xb28c0,
-0xb71021, 0x9442737e, 0x80030b7, 0x3021,
-0x420c0, 0x2e41021, 0x9443737c, 0x2e41021,
-0x944b737c, 0x30638000, 0x14600010, 0xb28c0,
-0xb71021, 0x9442737e, 0x1447fff5, 0x1602021,
-0xb71021, 0x94437380, 0x96620002, 0x5462fff1,
-0x420c0, 0xb71021, 0x94437382, 0x96620004,
-0x5462ffec, 0x420c0, 0x24060001, 0x30c200ff,
-0x10400400, 0x0, 0x80030d5, 0x0,
-0x97430202, 0x96420000, 0x146203fa, 0x0,
-0x97430204, 0x96420002, 0x146203f6, 0x0,
-0x97430206, 0x96420004, 0x146203f2, 0x0,
-0x92420000, 0x3a030001, 0x30420001, 0x431024,
-0x10400074, 0x2402ffff, 0x8e630000, 0x14620004,
-0x3402ffff, 0x96630004, 0x1062006f, 0x240f0002,
-0x3c020001, 0x571021, 0x904283b2, 0x1440006a,
-0x240f0003, 0x92e204d8, 0x54400068, 0xafaf002c,
-0x3c020001, 0x571021, 0x8c4283b4, 0x28420005,
-0x10400020, 0x3821, 0x3c020001, 0x571021,
-0x8c4283b4, 0x18400016, 0x2821, 0x96660000,
-0x520c0, 0x971021, 0x9442777e, 0x14460009,
-0x971021, 0x94437780, 0x96620002, 0x14620005,
-0x971021, 0x94437782, 0x96620004, 0x50620008,
-0x24070001, 0x3c020001, 0x571021, 0x8c4283b4,
-0x24a50001, 0xa2102a, 0x5440ffee, 0x520c0,
-0x30e200ff, 0x14400044, 0x240f0003, 0x80034c6,
-0x0, 0x2402021, 0xc0022fe, 0x24050006,
-0x3044001f, 0x428c0, 0x2e51021, 0x9442727c,
-0x30424000, 0x144003af, 0xb71021, 0x9443727e,
-0x96620000, 0x1462000b, 0x418c0, 0xb71021,
-0x94437280, 0x96620002, 0x14620006, 0x418c0,
-0xb71021, 0x94437282, 0x96620004, 0x10620027,
-0x418c0, 0x2e31021, 0x9442727c, 0x30428000,
-0x1440039c, 0x2e31021, 0x944b727c, 0x96670000,
-0xb28c0, 0xb71021, 0x9442737e, 0x800313c,
-0x3021, 0x420c0, 0x2e41021, 0x9443737c,
-0x2e41021, 0x944b737c, 0x30638000, 0x14600010,
-0xb28c0, 0xb71021, 0x9442737e, 0x1447fff5,
-0x1602021, 0xb71021, 0x94437380, 0x96620002,
-0x5462fff1, 0x420c0, 0xb71021, 0x94437382,
-0x96620004, 0x5462ffec, 0x420c0, 0x24060001,
-0x30c200ff, 0x1040037b, 0x0, 0x800314f,
-0x240f0003, 0x240f0001, 0xafaf002c, 0x8f420260,
-0x54102b, 0x1040003a, 0x0, 0x8f8300e4,
-0x8f8200e0, 0x10620003, 0x24630008, 0xaf8300e4,
-0xaf8300e8, 0x8ee400c0, 0x8ee500c4, 0x2801821,
-0x1021, 0xa32821, 0xa3302b, 0x822021,
-0x862021, 0xaee400c0, 0xaee500c4, 0x8ee20058,
-0x24420001, 0xaee20058, 0x8ee20058, 0x8ee2007c,
-0x24420001, 0xaee2007c, 0x8ee2007c, 0x8f8200e0,
-0xafa20010, 0x8f8200e4, 0x3c040001, 0x24845208,
-0xafa20014, 0x8fa60018, 0x8fa7001c, 0x3c050006,
-0xc002403, 0x34a5f003, 0x80034cc, 0x0,
-0x8ee25240, 0xafa20010, 0x8ee25244, 0x3c040001,
-0x24845214, 0xafa20014, 0x8ee60e10, 0x8ee70e18,
-0x3c050006, 0xc002403, 0x34a5f002, 0x8ee201c0,
-0x24420001, 0xaee201c0, 0x8ee20000, 0x8ee301c0,
-0x2403ffbf, 0x431024, 0x8003470, 0xaee20000,
-0x96e20468, 0x54102b, 0x10400003, 0x0,
-0x240f0001, 0xa3af0027, 0x12800301, 0x24160007,
-0x24150040, 0x241e0001, 0x240e0012, 0x8ee2724c,
-0x8f430280, 0x24420001, 0x304207ff, 0x106202d3,
-0x0, 0x93a20027, 0x10400014, 0x0,
-0x8ee35240, 0x8ee25244, 0x10620009, 0x26ed5244,
-0x8ee65244, 0x8ee35244, 0x21140, 0x24425248,
-0x2e28021, 0x24630001, 0x80031bf, 0x306b00ff,
-0x92e27248, 0x1440ffca, 0x0, 0x8ee201e0,
-0x24420001, 0xaee201e0, 0x8ee201e0, 0x8ee30e10,
-0x8ee20e18, 0x1062ffc2, 0x26ed0e18, 0x8ee60e18,
-0x8ee30e18, 0x21140, 0x24420e20, 0x2e28021,
-0x24630001, 0x306b01ff, 0x96e2046a, 0x30420010,
-0x10400019, 0x0, 0x9642000c, 0x340f8100,
-0x144f0015, 0x0, 0x3c020001, 0x571021,
-0x904283c0, 0x14400010, 0x0, 0x9642000e,
-0xa6020016, 0x8e420008, 0x8e430004, 0x8e440000,
-0x2694fffc, 0xae42000c, 0xae430008, 0xae440004,
-0x9602000e, 0x26730004, 0x240f0001, 0xa3af0037,
-0x34420200, 0xa602000e, 0x8e020000, 0x8e030004,
-0x3c040001, 0x34843800, 0x306a0007, 0x26a9823,
-0x3641021, 0x262102b, 0x10400005, 0x28aa021,
-0x2641023, 0x3621823, 0x3c020020, 0x439823,
-0x26820007, 0x2404fff8, 0x9603000a, 0x446024,
-0x6a1821, 0x6c102b, 0x10400002, 0x1803821,
-0x603821, 0xae130018, 0x8f880120, 0x24e20007,
-0x443824, 0x27623800, 0x25090020, 0x122102b,
-0x50400001, 0x27693000, 0x8f820128, 0x11220004,
-0x0, 0x8f820124, 0x15220007, 0x1401821,
-0x8ee201a4, 0x8821, 0x24420001, 0xaee201a4,
-0x800324c, 0x8ee201a4, 0x8e040000, 0x8e050004,
-0x1021, 0xad130008, 0xa507000e, 0xad160018,
-0xad06001c, 0xa3302b, 0xa32823, 0x822023,
-0x862023, 0xad040000, 0xad050004, 0x8ee204c0,
-0xad020010, 0xaf890120, 0x92e24e20, 0x14400033,
-0x24110001, 0x8ee24e30, 0x210c0, 0x24425038,
-0x2e22021, 0x8c820000, 0x1456001f, 0x0,
-0x8ee34e30, 0x8ee24e34, 0x1062001b, 0x0,
-0x8c820004, 0x24420001, 0xac820004, 0x8ee24e34,
-0x8ee34e30, 0x24420001, 0x10550007, 0x0,
-0x8ee24e34, 0x24420001, 0x10620005, 0x0,
-0x8003239, 0x0, 0x14600005, 0x0,
-0x8f820128, 0x24420020, 0xaf820128, 0x8f820128,
-0x8c820004, 0x2c420011, 0x50400010, 0xac800000,
-0x800324c, 0x0, 0x8ee24e30, 0x24420001,
-0x50550003, 0x1021, 0x8ee24e30, 0x24420001,
-0xaee24e30, 0x8ee24e30, 0x210c0, 0x24425038,
-0x2e22021, 0xac960000, 0xac9e0004, 0x16200018,
-0x3c050006, 0x8e020018, 0x3c040001, 0x24845220,
-0xafa20010, 0x8e020000, 0x8e030004, 0x34a5f009,
-0x2003021, 0xc002403, 0xafa30014, 0x93a20037,
-0x10400216, 0x340f8100, 0x8e420004, 0x8e430008,
-0x8e44000c, 0xa64f000c, 0xae420000, 0xae430004,
-0xae440008, 0x96020016, 0x8003470, 0xa642000e,
-0x14ec0168, 0x28a1823, 0x960c000a, 0x9603000e,
-0x28a1023, 0xa602000a, 0x34620004, 0xa602000e,
-0x8f880120, 0x27623800, 0x25090020, 0x122102b,
-0x14400002, 0x306affff, 0x27693000, 0x8f820128,
-0x11220004, 0x0, 0x8f820124, 0x15220007,
-0x24040020, 0x8ee201a4, 0x8821, 0x24420001,
-0xaee201a4, 0x80032ca, 0x8ee201a4, 0x8ee5724c,
-0x8ee60490, 0x8ee70494, 0xa504000e, 0x24040004,
-0xad100008, 0xad040018, 0x52940, 0xa01821,
-0x1021, 0xe33821, 0xe3202b, 0xc23021,
-0xc43021, 0xad060000, 0xad070004, 0x8ee2724c,
-0xad02001c, 0x8ee204c4, 0xad020010, 0xaf890120,
-0x92e24e20, 0x14400033, 0x24110001, 0x8ee24e30,
-0x210c0, 0x24425038, 0x2e22021, 0x8c820000,
-0x1456001f, 0x0, 0x8ee34e30, 0x8ee24e34,
-0x1062001b, 0x0, 0x8c820004, 0x24420001,
-0xac820004, 0x8ee24e34, 0x8ee34e30, 0x24420001,
-0x10550007, 0x0, 0x8ee24e34, 0x24420001,
-0x10620005, 0x0, 0x80032b7, 0x0,
-0x14600005, 0x0, 0x8f820128, 0x24420020,
-0xaf820128, 0x8f820128, 0x8c820004, 0x2c420011,
-0x50400010, 0xac800000, 0x80032ca, 0x0,
-0x8ee24e30, 0x24420001, 0x50550003, 0x1021,
-0x8ee24e30, 0x24420001, 0xaee24e30, 0x8ee24e30,
-0x210c0, 0x24425038, 0x2e22021, 0xac960000,
-0xac9e0004, 0x1620000d, 0x0, 0xa60c000a,
-0xa60a000e, 0x8f820100, 0xafa20010, 0x8f820104,
-0x3c040001, 0x2484522c, 0x3c050006, 0xafa20014,
-0x8ee6724c, 0x800343b, 0x34a5f00b, 0x3c010001,
-0x370821, 0xa02083c0, 0xadab0000, 0x8ee201d8,
-0x8ee3724c, 0x2442ffff, 0xaee201d8, 0x8ee201d8,
-0x24630001, 0x306307ff, 0x26e25244, 0x15a20006,
-0xaee3724c, 0x8ee201d0, 0x2442ffff, 0xaee201d0,
-0x80032ef, 0x8ee201d0, 0x8ee201cc, 0x2442ffff,
-0xaee201cc, 0x8ee201cc, 0x8f420240, 0x10400073,
-0x0, 0x8ee20e1c, 0x24420001, 0xaee20e1c,
-0x8f430240, 0x43102b, 0x14400176, 0xa021,
-0x8f830120, 0x27623800, 0x24660020, 0xc2102b,
-0x50400001, 0x27663000, 0x8f820128, 0x10c20004,
-0x0, 0x8f820124, 0x14c20007, 0x0,
-0x8ee201a4, 0x8821, 0x24420001, 0xaee201a4,
-0x800334f, 0x8ee201a4, 0x8ee2724c, 0xac62001c,
-0x8ee404a8, 0x8ee504ac, 0x2462001c, 0xac620008,
-0x24020008, 0xa462000e, 0x24020011, 0xac620018,
-0xac640000, 0xac650004, 0x8ee204c4, 0xac620010,
-0xaf860120, 0x92e24e20, 0x14400033, 0x24110001,
-0x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
-0x8c820000, 0x144e001f, 0x0, 0x8ee34e30,
-0x8ee24e34, 0x1062001b, 0x0, 0x8c820004,
-0x24420001, 0xac820004, 0x8ee24e34, 0x8ee34e30,
-0x24420001, 0x10550007, 0x0, 0x8ee24e34,
-0x24420001, 0x10620005, 0x0, 0x800333c,
-0x0, 0x14600005, 0x0, 0x8f820128,
-0x24420020, 0xaf820128, 0x8f820128, 0x8c820004,
-0x2c420011, 0x50400010, 0xac800000, 0x800334f,
-0x0, 0x8ee24e30, 0x24420001, 0x50550003,
-0x1021, 0x8ee24e30, 0x24420001, 0xaee24e30,
-0x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
-0xac8e0000, 0xac9e0004, 0x5620000d, 0x24110001,
-0x8ee2724c, 0x3c040001, 0x24845238, 0xafa00014,
-0xafa20010, 0x8ee6724c, 0x8f470280, 0x3c050009,
-0x34a5f008, 0xc002403, 0xafae0048, 0x8fae0048,
-0x56200001, 0xaee00e1c, 0x8ee20188, 0x24420001,
-0xaee20188, 0x80033c8, 0x8ee20188, 0x8f830120,
-0x27623800, 0x24660020, 0xc2102b, 0x50400001,
-0x27663000, 0x8f820128, 0x10c20004, 0x0,
-0x8f820124, 0x14c20007, 0x0, 0x8ee201a4,
-0x8821, 0x24420001, 0xaee201a4, 0x80033ba,
-0x8ee201a4, 0x8ee2724c, 0xac62001c, 0x8ee404a8,
-0x8ee504ac, 0x2462001c, 0xac620008, 0x24020008,
-0xa462000e, 0x24020011, 0xac620018, 0xac640000,
-0xac650004, 0x8ee204c4, 0xac620010, 0xaf860120,
-0x92e24e20, 0x14400033, 0x24110001, 0x8ee24e30,
-0x210c0, 0x24425038, 0x2e22021, 0x8c820000,
-0x144e001f, 0x0, 0x8ee34e30, 0x8ee24e34,
-0x1062001b, 0x0, 0x8c820004, 0x24420001,
-0xac820004, 0x8ee24e34, 0x8ee34e30, 0x24420001,
-0x10550007, 0x0, 0x8ee24e34, 0x24420001,
-0x10620005, 0x0, 0x80033a7, 0x0,
-0x14600005, 0x0, 0x8f820128, 0x24420020,
-0xaf820128, 0x8f820128, 0x8c820004, 0x2c420011,
-0x50400010, 0xac800000, 0x80033ba, 0x0,
-0x8ee24e30, 0x24420001, 0x50550003, 0x1021,
-0x8ee24e30, 0x24420001, 0xaee24e30, 0x8ee24e30,
-0x210c0, 0x24425038, 0x2e22021, 0xac8e0000,
-0xac9e0004, 0x1620000d, 0x0, 0x8ee2724c,
-0x3c040001, 0x24845238, 0xafa00014, 0xafa20010,
-0x8ee6724c, 0x8f470280, 0x3c050009, 0x34a5f008,
-0xc002403, 0xafae0048, 0x8fae0048, 0x8ee20174,
-0x24420001, 0xaee20174, 0x8ee20174, 0x800346e,
-0xa021, 0x960c000a, 0x183102b, 0x54400001,
-0x1801821, 0xa603000a, 0x8f880120, 0x27623800,
-0x25090020, 0x122102b, 0x50400001, 0x27693000,
-0x8f820128, 0x11220004, 0x0, 0x8f820124,
-0x15220007, 0x24040020, 0x8ee201a4, 0x8821,
-0x24420001, 0xaee201a4, 0x800342f, 0x8ee201a4,
-0x8ee5724c, 0x8ee60490, 0x8ee70494, 0xa504000e,
-0x24040004, 0xad100008, 0xad040018, 0x52940,
-0xa01821, 0x1021, 0xe33821, 0xe3202b,
-0xc23021, 0xc43021, 0xad060000, 0xad070004,
-0x8ee2724c, 0xad02001c, 0x8ee204c4, 0xad020010,
-0xaf890120, 0x92e24e20, 0x14400033, 0x24110001,
-0x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
-0x8c820000, 0x1456001f, 0x0, 0x8ee34e30,
-0x8ee24e34, 0x1062001b, 0x0, 0x8c820004,
-0x24420001, 0xac820004, 0x8ee24e34, 0x8ee34e30,
-0x24420001, 0x10550007, 0x0, 0x8ee24e34,
-0x24420001, 0x10620005, 0x0, 0x800341c,
-0x0, 0x14600005, 0x0, 0x8f820128,
-0x24420020, 0xaf820128, 0x8f820128, 0x8c820004,
-0x2c420011, 0x50400010, 0xac800000, 0x800342f,
-0x0, 0x8ee24e30, 0x24420001, 0x50550003,
-0x1021, 0x8ee24e30, 0x24420001, 0xaee24e30,
-0x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
-0xac960000, 0xac9e0004, 0x1620001d, 0x0,
-0xa60c000a, 0x8f820100, 0xafa20010, 0x8f820104,
-0x3c040001, 0x2484522c, 0x3c050006, 0xafa20014,
-0x8ee6724c, 0x34a5f00d, 0xc002403, 0x2003821,
-0x93a20037, 0x10400031, 0x340f8100, 0x8e420004,
-0x8e430008, 0x8e44000c, 0xa64f000c, 0xae420000,
-0xae430004, 0xae440008, 0x96020016, 0xa642000e,
-0x9602000e, 0x3042fdff, 0x8003470, 0xa602000e,
-0x8ee201d8, 0x2442ffff, 0xaee201d8, 0x8ee201d8,
-0x8ee201cc, 0x3c04001f, 0x3c010001, 0x370821,
-0xa03e83c0, 0x2442ffff, 0xaee201cc, 0x9603000a,
-0x3484ffff, 0x8ee201cc, 0x6a1821, 0x2639821,
-0x93202b, 0x10800003, 0x3c02fff5, 0x34421000,
-0x2629821, 0xadab0000, 0x8ee2724c, 0x24420001,
-0x304207ff, 0xaee2724c, 0x8f420240, 0x10400004,
-0x283a023, 0x8ee20e1c, 0x24420001, 0xaee20e1c,
-0xa3a00027, 0x1680fd29, 0x0, 0x12800024,
-0x0, 0x3c010001, 0x370821, 0xac3483c4,
-0x3c010001, 0x370821, 0xac3383c8, 0x3c010001,
-0x370821, 0xac3283cc, 0x93a20037, 0x10400008,
-0x0, 0x3c020001, 0x571021, 0x8c4283cc,
-0x24420004, 0x3c010001, 0x370821, 0xac2283cc,
-0x8ee2724c, 0x8f430280, 0x24420001, 0x304207ff,
-0x14620006, 0x0, 0x8ee201c4, 0x24420001,
-0xaee201c4, 0x80034cc, 0x8ee201c4, 0x8ee201bc,
-0x24420001, 0xaee201bc, 0x80034cc, 0x8ee201bc,
-0x97a4001e, 0x2484fffc, 0x801821, 0x8ee400c0,
-0x8ee500c4, 0x1021, 0xa32821, 0xa3302b,
-0x822021, 0x862021, 0xaee400c0, 0xaee500c4,
-0x8faf002c, 0x24020002, 0x11e2000f, 0x29e20003,
-0x14400017, 0x24020003, 0x15e20015, 0x0,
-0x8ee200d0, 0x8ee300d4, 0x24630001, 0x2c640001,
-0x441021, 0xaee200d0, 0xaee300d4, 0x8ee200d0,
-0x80034c6, 0x8ee300d4, 0x8ee200d8, 0x8ee300dc,
-0x24630001, 0x2c640001, 0x441021, 0xaee200d8,
-0xaee300dc, 0x8ee200d8, 0x80034c6, 0x8ee300dc,
-0x8ee200c8, 0x8ee300cc, 0x24630001, 0x2c640001,
-0x441021, 0xaee200c8, 0xaee300cc, 0x8ee200c8,
-0x8ee300cc, 0x8f8300e4, 0x8f8200e0, 0x10620003,
-0x24630008, 0xaf8300e4, 0xaf8300e8, 0x8fbf0070,
-0x8fbe006c, 0x8fb60068, 0x8fb50064, 0x8fb40060,
-0x8fb3005c, 0x8fb20058, 0x8fb10054, 0x8fb00050,
-0x3e00008, 0x27bd0078, 0x27bdffb0, 0xafb50044,
-0xa821, 0xafb00030, 0x8021, 0xafbf004c,
-0xafb60048, 0xafb40040, 0xafb3003c, 0xafb20038,
-0xafb10034, 0x8ee204d4, 0x24140001, 0x30420001,
-0x1440002a, 0xb021, 0x8f8700e0, 0x8f8800c4,
-0x8f8200e8, 0xe22023, 0x2c821000, 0x50400001,
-0x24841000, 0x420c2, 0x801821, 0x8ee400c8,
-0x8ee500cc, 0x1021, 0xa32821, 0xa3302b,
-0x822021, 0x862021, 0xaee400c8, 0xaee500cc,
-0x8f8300c8, 0x3c02000a, 0x3442efff, 0x1032023,
-0x44102b, 0x10400003, 0x3c02000a, 0x3442f000,
-0x822021, 0x801821, 0x8ee400c0, 0x8ee500c4,
-0x1021, 0xa32821, 0xa3302b, 0x822021,
-0x862021, 0xaee400c0, 0xaee500c4, 0xaf8800c8,
-0xaf8700e4, 0x8003850, 0xaf8700e8, 0x3c020001,
-0x571021, 0x904283c0, 0x1040000b, 0x0,
-0x3c130001, 0x2779821, 0x8e7383c4, 0x3c110001,
-0x2378821, 0x8e3183c8, 0x3c120001, 0x2579021,
-0x80036e8, 0x8e5283cc, 0x8f8300e0, 0x8f8200e4,
-0x10430007, 0x4821, 0x8f8200e4, 0x24090001,
-0x8c430000, 0x8c440004, 0xafa30018, 0xafa4001c,
-0x1520000e, 0x3c02ffff, 0x8f8200c4, 0xafa20010,
-0x8f8200c8, 0x3c040001, 0x24845200, 0xafa20014,
-0x8f8600e0, 0x8f8700e4, 0x3c050006, 0xc002403,
-0x34a5f000, 0x8003850, 0x0, 0x8fa3001c,
-0x8fb20018, 0x3073ffff, 0x2673fffc, 0x621024,
-0x10400058, 0x2408821, 0x3c020080, 0x621024,
-0x1040000a, 0x3c040040, 0x8ee2007c, 0x24420001,
-0xaee2007c, 0x8ee2007c, 0x8ee201fc, 0x24420001,
-0xaee201fc, 0x800384a, 0x8ee201fc, 0x3c060004,
-0x3c0b0001, 0x3c0a0002, 0x3c050010, 0x3c090008,
-0x8ee20080, 0x3c080020, 0x34078000, 0x24420001,
-0xaee20080, 0x8ee20080, 0x8fa2001c, 0x441824,
-0x10660021, 0xc3102b, 0x14400007, 0x0,
-0x106b0011, 0x0, 0x106a0015, 0x0,
-0x8003592, 0x42042, 0x10650023, 0xa3102b,
-0x14400005, 0x0, 0x10690019, 0x0,
-0x8003592, 0x42042, 0x10680021, 0x0,
-0x8003592, 0x42042, 0x8ee20034, 0x24420001,
-0xaee20034, 0x8ee20034, 0x8003592, 0x42042,
-0x8ee201ec, 0x24420001, 0xaee201ec, 0x8ee201ec,
-0x8003592, 0x42042, 0x8ee201f0, 0x24420001,
-0xaee201f0, 0x8ee201f0, 0x8003592, 0x42042,
-0x8ee201f4, 0x24420001, 0xaee201f4, 0x8ee201f4,
-0x8003592, 0x42042, 0x8ee20030, 0x24420001,
-0xaee20030, 0x8ee20030, 0x8003592, 0x42042,
-0x8ee201f8, 0x24420001, 0xaee201f8, 0x8ee201f8,
-0x42042, 0x108702b7, 0x0, 0x8003557,
-0x0, 0x3c020001, 0x571021, 0x904283b2,
-0x14400084, 0x24020001, 0x3c030001, 0x771821,
-0x906383b3, 0x1462007f, 0x3c020100, 0x8e430000,
-0x621024, 0x1040006f, 0x2402ffff, 0x14620005,
-0x24100001, 0x96430004, 0x3402ffff, 0x10620075,
-0x0, 0x92e204d8, 0x14400072, 0x0,
-0x3c020001, 0x571021, 0x8c4283b4, 0x28420005,
-0x10400020, 0x3821, 0x3c020001, 0x571021,
-0x8c4283b4, 0x18400016, 0x2821, 0x96260000,
-0x520c0, 0x971021, 0x9442777e, 0x14460009,
-0x971021, 0x94437780, 0x96220002, 0x14620005,
-0x971021, 0x94437782, 0x96220004, 0x50620008,
-0x24070001, 0x3c020001, 0x571021, 0x8c4283b4,
-0x24a50001, 0xa2102a, 0x5440ffee, 0x520c0,
-0x30e200ff, 0x1040027b, 0x0, 0x800361e,
-0x0, 0x2402021, 0xc0022fe, 0x24050006,
-0x3044001f, 0x428c0, 0x2e51021, 0x9442727c,
-0x30424000, 0x1440026f, 0xb71021, 0x9443727e,
-0x96220000, 0x1462000b, 0x418c0, 0xb71021,
-0x94437280, 0x96220002, 0x14620006, 0x418c0,
-0xb71021, 0x94437282, 0x96220004, 0x10620035,
-0x418c0, 0x2e31021, 0x9442727c, 0x30428000,
-0x1440025c, 0x2e31021, 0x9448727c, 0x96270000,
-0x828c0, 0xb71021, 0x9442737e, 0x8003600,
-0x3021, 0x420c0, 0x2e41021, 0x9443737c,
-0x2e41021, 0x9448737c, 0x30638000, 0x14600010,
-0x828c0, 0xb71021, 0x9442737e, 0x1447fff5,
-0x1002021, 0xb71021, 0x94437380, 0x96220002,
-0x5462fff1, 0x420c0, 0xb71021, 0x94437382,
-0x96220004, 0x5462ffec, 0x420c0, 0x24060001,
-0x30c200ff, 0x1040023b, 0x0, 0x800361e,
-0x0, 0x97430202, 0x96420000, 0x14620235,
-0x0, 0x97430204, 0x96420002, 0x14620231,
-0x0, 0x97430206, 0x96420004, 0x1462022d,
-0x0, 0x92420000, 0x3a030001, 0x30420001,
-0x431024, 0x10400074, 0x2402ffff, 0x8e230000,
-0x14620004, 0x3402ffff, 0x96230004, 0x1062006f,
-0x24140002, 0x3c020001, 0x571021, 0x904283b2,
-0x1440006a, 0x24140003, 0x92e204d8, 0x14400067,
-0x0, 0x3c020001, 0x571021, 0x8c4283b4,
-0x28420005, 0x10400020, 0x3821, 0x3c020001,
-0x571021, 0x8c4283b4, 0x18400016, 0x2821,
-0x96260000, 0x520c0, 0x971021, 0x9442777e,
-0x14460009, 0x971021, 0x94437780, 0x96220002,
-0x14620005, 0x971021, 0x94437782, 0x96220004,
-0x50620008, 0x24070001, 0x3c020001, 0x571021,
-0x8c4283b4, 0x24a50001, 0xa2102a, 0x5440ffee,
-0x520c0, 0x30e200ff, 0x14400044, 0x24140003,
-0x800384a, 0x0, 0x2402021, 0xc0022fe,
-0x24050006, 0x3044001f, 0x428c0, 0x2e51021,
-0x9442727c, 0x30424000, 0x144001ea, 0xb71021,
-0x9443727e, 0x96220000, 0x1462000b, 0x418c0,
-0xb71021, 0x94437280, 0x96220002, 0x14620006,
-0x418c0, 0xb71021, 0x94437282, 0x96220004,
-0x10620027, 0x418c0, 0x2e31021, 0x9442727c,
-0x30428000, 0x144001d7, 0x2e31021, 0x9448727c,
-0x96270000, 0x828c0, 0xb71021, 0x9442737e,
-0x8003685, 0x3021, 0x420c0, 0x2e41021,
-0x9443737c, 0x2e41021, 0x9448737c, 0x30638000,
-0x14600010, 0x828c0, 0xb71021, 0x9442737e,
-0x1447fff5, 0x1002021, 0xb71021, 0x94437380,
-0x96220002, 0x5462fff1, 0x420c0, 0xb71021,
-0x94437382, 0x96220004, 0x5462ffec, 0x420c0,
-0x24060001, 0x30c200ff, 0x104001b6, 0x0,
-0x8003698, 0x24140003, 0x24140001, 0x8f420260,
-0x53102b, 0x10400049, 0x0, 0x8f8300e4,
-0x8f8200e0, 0x10620003, 0x24630008, 0xaf8300e4,
-0xaf8300e8, 0x8ee400c0, 0x8ee500c4, 0x2601821,
-0x1021, 0xa32821, 0xa3302b, 0x822021,
-0x862021, 0xaee400c0, 0xaee500c4, 0x8ee20058,
-0x24420001, 0xaee20058, 0x8ee20058, 0x8ee2007c,
-0x24420001, 0xaee2007c, 0x8ee2007c, 0x8f8200e0,
-0xafa20010, 0x8f8200e4, 0x3c040001, 0x24845208,
-0xafa20014, 0x8fa60018, 0x8fa7001c, 0x3c050006,
-0xc002403, 0x34a5f003, 0x8003850, 0x0,
-0x8ee25240, 0xafa20010, 0x8ee25244, 0x3c040001,
-0x24845214, 0xafa20014, 0x8ee60e10, 0x8ee70e18,
-0xc002403, 0x34a5f002, 0x8ee201c0, 0x24420001,
-0xaee201c0, 0x8ee20000, 0x8ee301c0, 0x2403ffbf,
-0x431024, 0x80037f8, 0xaee20000, 0x8ee25240,
-0xafa20010, 0x8ee25244, 0x3c040001, 0x24845214,
-0xafa20014, 0x8ee60e10, 0x8ee70e18, 0x3c050006,
-0xc002403, 0x34a5f002, 0x8ee201c0, 0x24420001,
-0xaee201c0, 0x80037f8, 0x8ee201c0, 0x96e20468,
-0x53102b, 0x54400001, 0x3c158000, 0x12600131,
-0x3c0c001f, 0x358cffff, 0x8ee2724c, 0x8f430280,
-0x24420001, 0x304207ff, 0x10620108, 0x0,
-0x12a00014, 0x0, 0x8ee35240, 0x8ee25244,
-0x10620009, 0x26ee5244, 0x8eeb5244, 0x8ee35244,
-0x21140, 0x24425248, 0x2e28021, 0x24630001,
-0x8003712, 0x306800ff, 0x92e27248, 0x1440ffc0,
-0x3c050006, 0x8ee201e0, 0x24420001, 0xaee201e0,
-0x8ee201e0, 0x8ee30e10, 0x8ee20e18, 0x1062ffcb,
-0x26ee0e18, 0x8eeb0e18, 0xa821, 0x8ee30e18,
-0x21140, 0x24420e20, 0x2e28021, 0x24630001,
-0x306801ff, 0x96e2046a, 0x30420010, 0x10400017,
-0x34028100, 0x9643000c, 0x14620014, 0x0,
-0x3c020001, 0x571021, 0x904283c0, 0x1440000f,
-0x0, 0x9642000e, 0xa6020016, 0x8e420008,
-0x8e430004, 0x8e440000, 0x2673fffc, 0xae42000c,
-0xae430008, 0xae440004, 0x9602000e, 0x26310004,
-0x24160001, 0x34420200, 0xa602000e, 0x9603000a,
-0x2605021, 0x73102b, 0x10400002, 0x2606821,
-0x605021, 0x2d42003d, 0x1040002a, 0x3821,
-0x9623000c, 0x24020800, 0x54620027, 0xae110018,
-0x3c020001, 0x571021, 0x904283c0, 0x54400022,
-0xae110018, 0x26220017, 0x182102b, 0x10400013,
-0x0, 0x3c02fff5, 0x511021, 0x90421017,
-0x38430006, 0x2c630001, 0x38420011, 0x2c420001,
-0x621825, 0x10600013, 0x26220010, 0x182102b,
-0x1040000e, 0x0, 0x3c07fff5, 0xf13821,
-0x94e71010, 0x800375e, 0x24e7000e, 0x92220017,
-0x38430006, 0x2c630001, 0x38420011, 0x2c420001,
-0x621825, 0x50600004, 0xae110018, 0x96270010,
-0x24e7000e, 0xae110018, 0x3c020001, 0x571021,
-0x904283c0, 0x2102b, 0x14e00002, 0x24ec0,
-0x1403821, 0x8f830120, 0x27623800, 0x24660020,
-0xc2102b, 0x50400001, 0x27663000, 0x8f820128,
-0x10c20004, 0x0, 0x8f820124, 0x14c20007,
-0x2402000b, 0x8ee201a4, 0x4821, 0x24420001,
-0xaee201a4, 0x80037bf, 0x8ee201a4, 0x8e040000,
-0x8e050004, 0xac620018, 0x1751025, 0x491025,
-0xac710008, 0xa467000e, 0xac62001c, 0xac640000,
-0xac650004, 0x8ee204c0, 0xac620010, 0xaf860120,
-0x92e24e20, 0x14400038, 0x24090001, 0x8ee24e30,
-0x210c0, 0x24425038, 0x2e22021, 0x8c830000,
-0x24020007, 0x14620020, 0x0, 0x8ee34e30,
-0x8ee24e34, 0x1062001c, 0x0, 0x8c820004,
-0x24420001, 0xac820004, 0x8ee34e34, 0x8ee54e30,
-0x24020040, 0x24630001, 0x10620007, 0x0,
-0x8ee24e34, 0x24420001, 0x10a20005, 0x0,
-0x80037a9, 0x0, 0x14a00005, 0x0,
-0x8f820128, 0x24420020, 0xaf820128, 0x8f820128,
-0x8c820004, 0x2c420011, 0x50400013, 0xac800000,
-0x80037bf, 0x0, 0x8ee24e30, 0x24030040,
-0x24420001, 0x50430003, 0x1021, 0x8ee24e30,
-0x24420001, 0xaee24e30, 0x8ee24e30, 0x210c0,
-0x24425038, 0x2e22021, 0x24020007, 0xac820000,
-0x24020001, 0xac820004, 0x15200018, 0x3c050006,
-0x8e020018, 0x3c040001, 0x24845220, 0xafa20010,
-0x8e020000, 0x8e030004, 0x34a5f009, 0x2003021,
-0xc002403, 0xafa30014, 0x32c200ff, 0x1040002b,
-0x34028100, 0x8e430004, 0x8e440008, 0x8e45000c,
-0xa642000c, 0xae430000, 0xae440004, 0xae450008,
-0x96020016, 0x80037f8, 0xa642000e, 0x154d000a,
-0x0, 0x9602000e, 0xa613000a, 0x34420004,
-0xa602000e, 0x3c010001, 0x370821, 0xa02083c0,
-0x80037f6, 0x9821, 0x9604000a, 0x93102b,
-0x10400002, 0x2601821, 0x801821, 0x24020001,
-0xa603000a, 0x3c010001, 0x370821, 0xa02283c0,
-0x9604000a, 0x2248821, 0x191102b, 0x10400003,
-0x3c02fff5, 0x34421000, 0x2228821, 0x2649823,
-0xa821, 0x1660fef4, 0xadc80000, 0x12600021,
-0x32c200ff, 0x3c010001, 0x370821, 0xac3383c4,
-0x3c010001, 0x370821, 0xac3183c8, 0x3c010001,
-0x370821, 0x10400008, 0xac3283cc, 0x3c020001,
-0x571021, 0x8c4283cc, 0x24420004, 0x3c010001,
-0x370821, 0xac2283cc, 0x8ee2724c, 0x8f430280,
-0x24420001, 0x14620006, 0x0, 0x8ee201c4,
-0x24420001, 0xaee201c4, 0x8003850, 0x8ee201c4,
-0x8ee201bc, 0x24420001, 0xaee201bc, 0x8003850,
-0x8ee201bc, 0x97a4001e, 0x2484fffc, 0x801821,
-0x8ee400c0, 0x8ee500c4, 0x1021, 0xa32821,
-0xa3302b, 0x822021, 0x862021, 0x24020002,
-0xaee400c0, 0xaee500c4, 0x1282000f, 0x2a820003,
-0x14400017, 0x24020003, 0x16820015, 0x0,
-0x8ee200d0, 0x8ee300d4, 0x24630001, 0x2c640001,
-0x441021, 0xaee200d0, 0xaee300d4, 0x8ee200d0,
-0x800384a, 0x8ee300d4, 0x8ee200d8, 0x8ee300dc,
-0x24630001, 0x2c640001, 0x441021, 0xaee200d8,
-0xaee300dc, 0x8ee200d8, 0x800384a, 0x8ee300dc,
-0x8ee200c8, 0x8ee300cc, 0x24630001, 0x2c640001,
-0x441021, 0xaee200c8, 0xaee300cc, 0x8ee200c8,
-0x8ee300cc, 0x8f8300e4, 0x8f8200e0, 0x10620003,
-0x24630008, 0xaf8300e4, 0xaf8300e8, 0x8fbf004c,
-0x8fb60048, 0x8fb50044, 0x8fb40040, 0x8fb3003c,
-0x8fb20038, 0x8fb10034, 0x8fb00030, 0x3e00008,
-0x27bd0050, 0x27bdff90, 0xafb60060, 0xb021,
-0xafbf0068, 0xafbe0064, 0xafb5005c, 0xafb40058,
-0xafb30054, 0xafb20050, 0xafb1004c, 0xafb00048,
-0x8ee204d4, 0x8821, 0x24150001, 0x30420001,
-0x1440002a, 0xa3a0002f, 0x8f8700e0, 0x8f8800c4,
-0x8f8200e8, 0xe22023, 0x2c821000, 0x50400001,
-0x24841000, 0x420c2, 0x801821, 0x8ee400c8,
-0x8ee500cc, 0x1021, 0xa32821, 0xa3302b,
-0x822021, 0x862021, 0xaee400c8, 0xaee500cc,
-0x8f8300c8, 0x3c02000a, 0x3442efff, 0x1032023,
-0x44102b, 0x10400003, 0x3c02000a, 0x3442f000,
-0x822021, 0x801821, 0x8ee400c0, 0x8ee500c4,
-0x1021, 0xa32821, 0xa3302b, 0x822021,
-0x862021, 0xaee400c0, 0xaee500c4, 0xaf8800c8,
-0xaf8700e4, 0x8003c5b, 0xaf8700e8, 0x3c020001,
-0x571021, 0x904283c0, 0x1040000b, 0x0,
-0x3c130001, 0x2779821, 0x8e7383c4, 0x3c100001,
-0x2178021, 0x8e1083c8, 0x3c120001, 0x2579021,
-0x8003a59, 0x8e5283cc, 0x8f8300e0, 0x8f8200e4,
-0x10430007, 0x3821, 0x8f8200e4, 0x24070001,
-0x8c430000, 0x8c440004, 0xafa30018, 0xafa4001c,
-0x14e0000e, 0x3c02ffff, 0x8f8200c4, 0xafa20010,
-0x8f8200c8, 0x3c040001, 0x24845244, 0xafa20014,
-0x8f8600e0, 0x8f8700e4, 0x3c050006, 0xc002403,
-0x34a5f200, 0x8003c5b, 0x0, 0x8fa3001c,
-0x8fb20018, 0x3073ffff, 0x2673fffc, 0x621024,
-0x10400058, 0x2408021, 0x3c020080, 0x621024,
-0x1040000a, 0x3c040040, 0x8ee2007c, 0x24420001,
-0xaee2007c, 0x8ee2007c, 0x8ee201fc, 0x24420001,
-0xaee201fc, 0x8003c55, 0x8ee201fc, 0x3c060004,
-0x3c0b0001, 0x3c0a0002, 0x3c050010, 0x3c090008,
-0x8ee20080, 0x3c080020, 0x34078000, 0x24420001,
-0xaee20080, 0x8ee20080, 0x8fa2001c, 0x441824,
-0x10660021, 0xc3102b, 0x14400007, 0x0,
-0x106b0011, 0x0, 0x106a0015, 0x0,
-0x8003916, 0x42042, 0x10650023, 0xa3102b,
-0x14400005, 0x0, 0x10690019, 0x0,
-0x8003916, 0x42042, 0x10680021, 0x0,
-0x8003916, 0x42042, 0x8ee20034, 0x24420001,
-0xaee20034, 0x8ee20034, 0x8003916, 0x42042,
-0x8ee201ec, 0x24420001, 0xaee201ec, 0x8ee201ec,
-0x8003916, 0x42042, 0x8ee201f0, 0x24420001,
-0xaee201f0, 0x8ee201f0, 0x8003916, 0x42042,
-0x8ee201f4, 0x24420001, 0xaee201f4, 0x8ee201f4,
-0x8003916, 0x42042, 0x8ee20030, 0x24420001,
-0xaee20030, 0x8ee20030, 0x8003916, 0x42042,
-0x8ee201f8, 0x24420001, 0xaee201f8, 0x8ee201f8,
-0x42042, 0x1087033e, 0x0, 0x80038db,
-0x0, 0x3c020001, 0x571021, 0x904283b2,
-0x14400084, 0x24020001, 0x3c030001, 0x771821,
-0x906383b3, 0x1462007f, 0x3c020100, 0x8e430000,
-0x621024, 0x1040006f, 0x2402ffff, 0x14620005,
-0x24110001, 0x96430004, 0x3402ffff, 0x10620075,
-0x0, 0x92e204d8, 0x14400072, 0x0,
-0x3c020001, 0x571021, 0x8c4283b4, 0x28420005,
-0x10400020, 0x3821, 0x3c020001, 0x571021,
-0x8c4283b4, 0x18400016, 0x2821, 0x96060000,
-0x520c0, 0x971021, 0x9442777e, 0x14460009,
-0x971021, 0x94437780, 0x96020002, 0x14620005,
-0x971021, 0x94437782, 0x96020004, 0x50620008,
-0x24070001, 0x3c020001, 0x571021, 0x8c4283b4,
-0x24a50001, 0xa2102a, 0x5440ffee, 0x520c0,
-0x30e200ff, 0x10400302, 0x0, 0x80039a2,
-0x0, 0x2402021, 0xc0022fe, 0x24050006,
-0x3044001f, 0x428c0, 0x2e51021, 0x9442727c,
-0x30424000, 0x144002f6, 0xb71021, 0x9443727e,
-0x96020000, 0x1462000b, 0x418c0, 0xb71021,
-0x94437280, 0x96020002, 0x14620006, 0x418c0,
-0xb71021, 0x94437282, 0x96020004, 0x10620035,
-0x418c0, 0x2e31021, 0x9442727c, 0x30428000,
-0x144002e3, 0x2e31021, 0x944d727c, 0x96070000,
-0xd28c0, 0xb71021, 0x9442737e, 0x8003984,
-0x3021, 0x420c0, 0x2e41021, 0x9443737c,
-0x2e41021, 0x944d737c, 0x30638000, 0x14600010,
-0xd28c0, 0xb71021, 0x9442737e, 0x1447fff5,
-0x1a02021, 0xb71021, 0x94437380, 0x96020002,
-0x5462fff1, 0x420c0, 0xb71021, 0x94437382,
-0x96020004, 0x5462ffec, 0x420c0, 0x24060001,
-0x30c200ff, 0x104002c2, 0x0, 0x80039a2,
-0x0, 0x97430202, 0x96420000, 0x146202bc,
-0x0, 0x97430204, 0x96420002, 0x146202b8,
-0x0, 0x97430206, 0x96420004, 0x146202b4,
-0x0, 0x92420000, 0x3a230001, 0x30420001,
-0x431024, 0x10400074, 0x2402ffff, 0x8e030000,
-0x14620004, 0x3402ffff, 0x96030004, 0x1062006f,
-0x24150002, 0x3c020001, 0x571021, 0x904283b2,
-0x1440006a, 0x24150003, 0x92e204d8, 0x14400067,
-0x0, 0x3c020001, 0x571021, 0x8c4283b4,
-0x28420005, 0x10400020, 0x3821, 0x3c020001,
-0x571021, 0x8c4283b4, 0x18400016, 0x2821,
-0x96060000, 0x520c0, 0x971021, 0x9442777e,
-0x14460009, 0x971021, 0x94437780, 0x96020002,
-0x14620005, 0x971021, 0x94437782, 0x96020004,
-0x50620008, 0x24070001, 0x3c020001, 0x571021,
-0x8c4283b4, 0x24a50001, 0xa2102a, 0x5440ffee,
-0x520c0, 0x30e200ff, 0x14400044, 0x24150003,
-0x8003c55, 0x0, 0x2402021, 0xc0022fe,
-0x24050006, 0x3044001f, 0x428c0, 0x2e51021,
-0x9442727c, 0x30424000, 0x14400271, 0xb71021,
-0x9443727e, 0x96020000, 0x1462000b, 0x418c0,
-0xb71021, 0x94437280, 0x96020002, 0x14620006,
-0x418c0, 0xb71021, 0x94437282, 0x96020004,
-0x10620027, 0x418c0, 0x2e31021, 0x9442727c,
-0x30428000, 0x1440025e, 0x2e31021, 0x944d727c,
-0x96070000, 0xd28c0, 0xb71021, 0x9442737e,
-0x8003a09, 0x3021, 0x420c0, 0x2e41021,
-0x9443737c, 0x2e41021, 0x944d737c, 0x30638000,
-0x14600010, 0xd28c0, 0xb71021, 0x9442737e,
-0x1447fff5, 0x1a02021, 0xb71021, 0x94437380,
-0x96020002, 0x5462fff1, 0x420c0, 0xb71021,
-0x94437382, 0x96020004, 0x5462ffec, 0x420c0,
-0x24060001, 0x30c200ff, 0x1040023d, 0x0,
-0x8003a1c, 0x24150003, 0x24150001, 0x8f420260,
-0x53102b, 0x10400036, 0x0, 0x8f8300e4,
-0x8f8200e0, 0x10620003, 0x24630008, 0xaf8300e4,
-0xaf8300e8, 0x8ee400c0, 0x8ee500c4, 0x2601821,
-0x1021, 0xa32821, 0xa3302b, 0x822021,
-0x862021, 0xaee400c0, 0xaee500c4, 0x8ee20058,
-0x24420001, 0xaee20058, 0x8ee20058, 0x8ee2007c,
-0x24420001, 0xaee2007c, 0x8ee2007c, 0x8f8200e0,
-0xafa20010, 0x8f8200e4, 0x3c040001, 0x24845250,
-0xafa20014, 0x8fa60018, 0x8fa7001c, 0x3c050006,
-0xc002403, 0x34a5f203, 0x8003c5b, 0x0,
-0x8ee25240, 0xafa20010, 0x8ee25244, 0x3c040001,
-0x2484525c, 0xafa20014, 0x8ee60e10, 0x8ee70e18,
-0x3c050006, 0xc002403, 0x34a5f202, 0x8ee201c0,
-0x24420001, 0xaee201c0, 0x8003c02, 0x8ee201c0,
-0x96e20468, 0x53102b, 0x54400001, 0x3c168000,
-0x126001cb, 0x3c0e001f, 0x35ceffff, 0x3c0ffff5,
-0x35ef1000, 0x241e0040, 0x8ee2724c, 0x8f430280,
-0x24420001, 0x304207ff, 0x1062019e, 0x0,
-0x12c00012, 0x0, 0x8ee35240, 0x8ee25244,
-0x1062000a, 0x26f85244, 0x8ef45244, 0xafb80024,
-0x8ee35244, 0x21140, 0x24425248, 0x2e28821,
-0x24630001, 0x8003a85, 0x306d00ff, 0x8ee201e0,
-0x24420001, 0xaee201e0, 0x8ee201e0, 0x8ee30e10,
-0x8ee20e18, 0x1062ffca, 0x26f80e18, 0x8ef40e18,
-0xb021, 0xafb80024, 0x8ee30e18, 0x21140,
-0x24420e20, 0x2e28821, 0x24630001, 0x306d01ff,
-0x96e2046a, 0x30420010, 0x10400018, 0x34028100,
-0x9643000c, 0x14620015, 0x0, 0x3c020001,
-0x571021, 0x904283c0, 0x14400010, 0x0,
-0x9642000e, 0xa6220016, 0x8e420008, 0x8e430004,
-0x8e440000, 0x2673fffc, 0xae42000c, 0xae430008,
-0xae440004, 0x9622000e, 0x26100004, 0x24180001,
-0xa3b8002f, 0x34420200, 0xa622000e, 0x8e220000,
-0x8e230004, 0x3c040001, 0x34843800, 0x2003021,
-0x306a0007, 0x20a8023, 0x3641021, 0x202102b,
-0x10400005, 0x26a9821, 0x2041023, 0x3621823,
-0x3c020020, 0x438023, 0x26620007, 0x9623000a,
-0x2418fff8, 0x58c824, 0x6a1821, 0x79102b,
-0x10400002, 0x3206021, 0x606021, 0x1801821,
-0x24620007, 0x2418fff8, 0x586024, 0x26c102b,
-0x14400004, 0x1932823, 0x1832823, 0x8003ac3,
-0xc31021, 0xd31021, 0x4a2023, 0x1c4102b,
-0x54400001, 0x8f2021, 0x25420040, 0x4c102b,
-0x14400035, 0x5821, 0x94c3000c, 0x24020800,
-0x54620032, 0xae260018, 0x3c020001, 0x571021,
-0x904283c0, 0x5440002d, 0xae260018, 0x24c20017,
-0x1c2102b, 0x10400013, 0x0, 0x3c02fff5,
-0x461021, 0x90421017, 0x38430006, 0x2c630001,
-0x38420011, 0x2c420001, 0x621825, 0x10600014,
-0x24c20010, 0x1c2102b, 0x1040000e, 0x0,
-0x3c0bfff5, 0x1665821, 0x956b1010, 0x8003af4,
-0x2562000e, 0x90c20017, 0x38430006, 0x2c630001,
-0x38420011, 0x2c420001, 0x621825, 0x10600005,
-0x1601821, 0x94cb0010, 0x2562000e, 0x4a5821,
-0x1601821, 0x24620007, 0x2418fff8, 0x585824,
-0xc31021, 0x4a2023, 0x1c4102b, 0x10400002,
-0x1632823, 0x8f2021, 0xae260018, 0x3c020001,
-0x571021, 0x904283c0, 0x2102b, 0x216c0,
-0x15600002, 0xafa20044, 0x1805821, 0x30820001,
-0x10400007, 0x4021, 0x90880000, 0x24840001,
-0x1c4102b, 0x10400002, 0x24a5ffff, 0x8f2021,
-0x50a00012, 0x81c02, 0x2ca20002, 0x54400009,
-0x24a5ffff, 0x94820000, 0x24840002, 0x1024021,
-0x1c4102b, 0x10400006, 0x24a5fffe, 0x8003b21,
-0x8f2021, 0x90820000, 0x21200, 0x1024021,
-0x14a0fff2, 0x2ca20002, 0x81c02, 0x3102ffff,
-0x624021, 0x3108ffff, 0x1402821, 0x11400011,
-0x2002021, 0x2ca20002, 0x54400009, 0x24a5ffff,
-0x94820000, 0x24840002, 0x1024021, 0x1c4102b,
-0x10400006, 0x24a5fffe, 0x8003b38, 0x8f2021,
-0x90820000, 0x21200, 0x1024021, 0x14a0fff2,
-0x2ca20002, 0x81c02, 0x3102ffff, 0x624021,
-0x81c02, 0x3102ffff, 0x8f890120, 0x624021,
-0x27623800, 0x25230020, 0x62102b, 0x14400002,
-0x3108ffff, 0x27633000, 0x8f820128, 0x10620004,
-0x0, 0x8f820124, 0x14620007, 0x1402821,
-0x8ee201a4, 0x3821, 0x24420001, 0xaee201a4,
-0x8003bc9, 0x8ee201a4, 0x8e260000, 0x8e270004,
-0x81400, 0x3448000b, 0xad300008, 0xa52b000e,
-0xad280018, 0x8fb80044, 0x2021, 0x2961025,
-0x581025, 0xad22001c, 0xe5102b, 0xe53823,
-0xc43023, 0xc23023, 0xad260000, 0xad270004,
-0x8ee204c0, 0xad220010, 0xaf830120, 0x92e24e20,
-0x1440005f, 0x24070001, 0x2502ffee, 0x2c420002,
-0x14400003, 0x24020011, 0x15020024, 0x0,
-0x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
-0x8c830000, 0x24020012, 0x1462000f, 0x0,
-0x8ee34e30, 0x8ee24e34, 0x1062000b, 0x0,
-0x8c820004, 0x24420001, 0xac820004, 0x8ee24e34,
-0x8ee34e30, 0x24420001, 0x105e002a, 0x0,
-0x8003ba8, 0x0, 0x8ee24e30, 0x24420001,
-0x505e0003, 0x1021, 0x8ee24e30, 0x24420001,
-0xaee24e30, 0x8ee24e30, 0x210c0, 0x24425038,
-0x2e22021, 0x8003bc6, 0x24020012, 0x8ee24e30,
-0x210c0, 0x24425038, 0x2e22021, 0x8c830000,
-0x24020007, 0x1462001f, 0x0, 0x8ee34e30,
-0x8ee24e34, 0x1062001b, 0x0, 0x8c820004,
-0x24420001, 0xac820004, 0x8ee24e34, 0x8ee34e30,
-0x24420001, 0x105e0007, 0x0, 0x8ee24e34,
-0x24420001, 0x10620005, 0x0, 0x8003bb4,
-0x0, 0x14600005, 0x0, 0x8f820128,
-0x24420020, 0xaf820128, 0x8f820128, 0x8c820004,
-0x2c420011, 0x50400012, 0xac800000, 0x8003bc9,
-0x0, 0x8ee24e30, 0x24420001, 0x505e0003,
-0x1021, 0x8ee24e30, 0x24420001, 0xaee24e30,
-0x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
-0x24020007, 0xac820000, 0x24020001, 0xac820004,
-0x14e00019, 0x3c050006, 0x3c040001, 0x24845220,
-0x8e220018, 0x34a5f209, 0xafa20010, 0x8e220000,
-0x8e230004, 0x2203021, 0x1603821, 0xc002403,
-0xafa30014, 0x93a2002f, 0x1040002a, 0x34028100,
-0x8e430004, 0x8e440008, 0x8e45000c, 0xa642000c,
-0xae430000, 0xae440004, 0xae450008, 0x96220016,
-0x8003c02, 0xa642000e, 0x1599000a, 0x26a1823,
-0x9622000e, 0xa623000a, 0x34420004, 0xa622000e,
-0x3c010001, 0x370821, 0xa02083c0, 0x8003bff,
-0x9821, 0x9624000a, 0x83102b, 0x54400001,
-0x801821, 0x24020001, 0xa623000a, 0x3c010001,
-0x370821, 0xa02283c0, 0x9622000a, 0x4a1821,
-0x2038021, 0x1d0102b, 0x54400001, 0x20f8021,
-0x2639823, 0xb021, 0x8fb80024, 0x1660fe5e,
-0xaf0d0000, 0x12600022, 0x0, 0x3c010001,
-0x370821, 0xac3383c4, 0x3c010001, 0x370821,
-0xac3083c8, 0x3c010001, 0x370821, 0xac3283cc,
-0x93a2002f, 0x10400008, 0x0, 0x3c020001,
-0x571021, 0x8c4283cc, 0x24420004, 0x3c010001,
-0x370821, 0xac2283cc, 0x8f430280, 0x8ee2724c,
-0x14620006, 0x0, 0x8ee201c4, 0x24420001,
-0xaee201c4, 0x8003c5b, 0x8ee201c4, 0x8ee201bc,
-0x24420001, 0xaee201bc, 0x8003c5b, 0x8ee201bc,
-0x97a4001e, 0x2484fffc, 0x801821, 0x8ee400c0,
-0x8ee500c4, 0x1021, 0xa32821, 0xa3302b,
-0x822021, 0x862021, 0x24020002, 0xaee400c0,
-0xaee500c4, 0x12a2000f, 0x2aa20003, 0x14400017,
-0x24020003, 0x16a20015, 0x0, 0x8ee200d0,
-0x8ee300d4, 0x24630001, 0x2c640001, 0x441021,
-0xaee200d0, 0xaee300d4, 0x8ee200d0, 0x8003c55,
-0x8ee300d4, 0x8ee200d8, 0x8ee300dc, 0x24630001,
-0x2c640001, 0x441021, 0xaee200d8, 0xaee300dc,
-0x8ee200d8, 0x8003c55, 0x8ee300dc, 0x8ee200c8,
-0x8ee300cc, 0x24630001, 0x2c640001, 0x441021,
-0xaee200c8, 0xaee300cc, 0x8ee200c8, 0x8ee300cc,
-0x8f8300e4, 0x8f8200e0, 0x10620003, 0x24630008,
-0xaf8300e4, 0xaf8300e8, 0x8fbf0068, 0x8fbe0064,
-0x8fb60060, 0x8fb5005c, 0x8fb40058, 0x8fb30054,
-0x8fb20050, 0x8fb1004c, 0x8fb00048, 0x3e00008,
-0x27bd0070, 0x27bdffe0, 0xafbf0018, 0x8ee30e14,
-0x8ee20e0c, 0x10620074, 0x0, 0x8ee30e0c,
-0x8ee20e14, 0x622023, 0x4820001, 0x24840200,
-0x8ee30e18, 0x8ee20e14, 0x43102b, 0x14400004,
-0x24020200, 0x8ee30e14, 0x8003c7d, 0x431823,
-0x8ee20e18, 0x8ee30e14, 0x431023, 0x2443ffff,
-0x804821, 0x69102a, 0x54400001, 0x604821,
-0x8f870100, 0x27623000, 0x24e80020, 0x102102b,
-0x50400001, 0x27682800, 0x8f820108, 0x11020004,
-0x0, 0x8f820104, 0x15020007, 0x1021,
-0x8ee201a8, 0x2021, 0x24420001, 0xaee201a8,
-0x8003cbf, 0x8ee201a8, 0x8ee40e14, 0x42140,
-0x801821, 0x8ee40460, 0x8ee50464, 0xa32821,
-0xa3302b, 0x822021, 0x862021, 0xace40000,
-0xace50004, 0x8ee30e14, 0x91140, 0xa4e2000e,
-0x24020002, 0xace20018, 0x31940, 0x24630e20,
-0x2e31021, 0xace20008, 0x8ee20e14, 0xace2001c,
-0x8ee204cc, 0xace20010, 0xaf880100, 0x92e204ec,
-0x14400011, 0x24040001, 0x8ee24e28, 0x24030040,
-0x24420001, 0x50430003, 0x1021, 0x8ee24e28,
-0x24420001, 0xaee24e28, 0x8ee24e28, 0x210c0,
-0x24424e38, 0x2e21821, 0x24020002, 0xac620000,
-0x24020001, 0xac620004, 0x1480000e, 0x24030040,
-0x8ee20e14, 0xafa20010, 0x8ee20e18, 0x3c050007,
-0xafa20014, 0x8ee60e0c, 0x8ee70e10, 0x3c040001,
-0x24845264, 0xc002403, 0x34a5f001, 0x8003cdd,
-0x0, 0x8ee20500, 0x24420001, 0x50430003,
-0x1021, 0x8ee20500, 0x24420001, 0xaee20500,
-0x8ee20500, 0x21080, 0x571021, 0xac490508,
-0x8ee20e14, 0x491021, 0x304201ff, 0xaee20e14,
-0x8ee30e14, 0x8ee20e0c, 0x14620005, 0x0,
-0x8f820060, 0x2403fdff, 0x431024, 0xaf820060,
-0x8fbf0018, 0x3e00008, 0x27bd0020, 0x27bdffe0,
-0xafbf0018, 0x8ee3523c, 0x8ee25238, 0x10620074,
-0x0, 0x8ee35238, 0x8ee2523c, 0x622023,
-0x4820001, 0x24840100, 0x8ee35244, 0x8ee2523c,
-0x43102b, 0x14400004, 0x24020100, 0x8ee3523c,
-0x8003cff, 0x431823, 0x8ee25244, 0x8ee3523c,
-0x431023, 0x2443ffff, 0x804821, 0x69102a,
-0x54400001, 0x604821, 0x8f870100, 0x27623000,
-0x24e80020, 0x102102b, 0x50400001, 0x27682800,
-0x8f820108, 0x11020004, 0x0, 0x8f820104,
-0x15020007, 0x1021, 0x8ee201a8, 0x2021,
-0x24420001, 0xaee201a8, 0x8003d41, 0x8ee201a8,
-0x8ee4523c, 0x42140, 0x801821, 0x8ee40470,
-0x8ee50474, 0xa32821, 0xa3302b, 0x822021,
-0x862021, 0xace40000, 0xace50004, 0x8ee3523c,
-0x91140, 0xa4e2000e, 0x24020003, 0xace20018,
-0x31940, 0x24635248, 0x2e31021, 0xace20008,
-0x8ee2523c, 0xace2001c, 0x8ee204cc, 0xace20010,
-0xaf880100, 0x92e204ec, 0x14400011, 0x24040001,
-0x8ee24e28, 0x24030040, 0x24420001, 0x50430003,
-0x1021, 0x8ee24e28, 0x24420001, 0xaee24e28,
-0x8ee24e28, 0x210c0, 0x24424e38, 0x2e21821,
-0x24020003, 0xac620000, 0x24020001, 0xac620004,
-0x1480000e, 0x24030040, 0x8ee2523c, 0xafa20010,
-0x8ee25244, 0x3c050007, 0xafa20014, 0x8ee65238,
-0x8ee75240, 0x3c040001, 0x24845270, 0xc002403,
-0x34a5f010, 0x8003d5f, 0x0, 0x8ee20500,
-0x24420001, 0x50430003, 0x1021, 0x8ee20500,
-0x24420001, 0xaee20500, 0x8ee20500, 0x21080,
-0x571021, 0xac490508, 0x8ee2523c, 0x491021,
-0x304200ff, 0xaee2523c, 0x8ee3523c, 0x8ee25238,
-0x14620005, 0x0, 0x8f820060, 0x2403feff,
-0x431024, 0xaf820060, 0x8fbf0018, 0x3e00008,
-0x27bd0020, 0x8f820120, 0x8ee34e34, 0x8f820124,
-0x8f860128, 0x24020040, 0x24630001, 0x50620003,
-0x1021, 0x8ee24e34, 0x24420001, 0xaee24e34,
-0x8ee24e34, 0x8ee44e34, 0x8ee34e30, 0x210c0,
-0x24425038, 0x14830007, 0x2e22821, 0x8f820128,
-0x24420020, 0xaf820128, 0x8f820128, 0x8003d92,
-0xaca00000, 0x8ee24e34, 0x24030040, 0x24420001,
-0x50430003, 0x1021, 0x8ee24e34, 0x24420001,
-0x210c0, 0x24425038, 0x2e22821, 0x8ca20004,
-0x8f830128, 0x21140, 0x621821, 0xaf830128,
-0xaca00000, 0x8cc20018, 0x2443fffe, 0x2c620012,
-0x10400008, 0x31080, 0x3c010001, 0x220821,
-0x8c225280, 0x400008, 0x0, 0x24020001,
-0xaee24e24, 0x3e00008, 0x0, 0x27bdffc8,
-0xafbf0030, 0xafb5002c, 0xafb40028, 0xafb30024,
-0xafb20020, 0xafb1001c, 0xafb00018, 0x8f830128,
-0x8f820124, 0x106202b0, 0x9821, 0x3c11001f,
-0x3631ffff, 0x3c12fff5, 0x36521000, 0x24150012,
-0x24140040, 0x8f8c0128, 0x8f820128, 0x24420020,
-0xaf820128, 0x9182001b, 0x8f830128, 0x2443fffe,
-0x2c620012, 0x1040029c, 0x31080, 0x3c010001,
-0x220821, 0x8c2252d8, 0x400008, 0x0,
-0x8f420218, 0x30420100, 0x10400007, 0x0,
-0x95830016, 0x95820018, 0x621823, 0x31402,
-0x431021, 0xa5820016, 0x8d82001c, 0x3c038000,
-0x3044ffff, 0x436824, 0x3c030800, 0x431824,
-0x11a00004, 0xad84001c, 0x41140, 0x8003dd8,
-0x24425248, 0x41140, 0x24420e20, 0x2e25821,
-0x9562000e, 0x3042fffc, 0x10600004, 0xa562000e,
-0x95840016, 0x8003ec0, 0x0, 0x8d690018,
-0x4021, 0x952a0000, 0x25290002, 0x95270000,
-0x25290002, 0x95260000, 0x25290002, 0x95250000,
-0x25290002, 0x95240000, 0x25290002, 0x95230000,
-0x25290002, 0x95220000, 0x25290002, 0x1475021,
-0x1465021, 0x1455021, 0x1445021, 0x1435021,
-0x1425021, 0xa1c02, 0x3142ffff, 0x625021,
-0xa1c02, 0x3142ffff, 0x625021, 0x96e2046a,
-0x314effff, 0x30420002, 0x10400044, 0x5021,
-0x25220014, 0x222102b, 0x10400014, 0x1201821,
-0x2405000a, 0x2021, 0x223102b, 0x54400001,
-0x721821, 0x94620000, 0x24630002, 0x24a5ffff,
-0x14a0fff9, 0x822021, 0x41c02, 0x3082ffff,
-0x622021, 0x41402, 0x3083ffff, 0x431021,
-0x3042ffff, 0x8003e33, 0x1425021, 0x952a0000,
-0x25290002, 0x95280000, 0x25290002, 0x95270000,
-0x25290002, 0x95260000, 0x25290002, 0x95250000,
-0x25290002, 0x95230000, 0x25290002, 0x95220000,
-0x25290002, 0x95240000, 0x25290002, 0x1485021,
-0x1475021, 0x1465021, 0x1455021, 0x1435021,
-0x1425021, 0x95220000, 0x95230002, 0x1445021,
-0x1425021, 0x1435021, 0xa1c02, 0x3142ffff,
-0x625021, 0xa1c02, 0x3142ffff, 0x625021,
-0x3148ffff, 0x51000001, 0x3408ffff, 0x8d620018,
-0x9443000c, 0x24020800, 0x54620005, 0xa5680010,
-0x9562000e, 0x34420002, 0xa562000e, 0xa5680010,
-0x96e2046a, 0x2821, 0x30420008, 0x14400056,
-0x3021, 0x8d630018, 0x24620024, 0x222102b,
-0x10400034, 0x24690010, 0x229102b, 0x54400001,
-0x1324821, 0x95250000, 0x24690014, 0x229102b,
-0x10400002, 0x24a5ffec, 0x1324821, 0x95220000,
-0x30420fff, 0x14400003, 0x25290002, 0x8003e60,
-0x24130001, 0x9821, 0xa03021, 0x229102b,
-0x54400001, 0x1324821, 0x91220001, 0x25290002,
-0xa22821, 0x229102b, 0x54400001, 0x1324821,
-0x25290002, 0x229102b, 0x54400001, 0x1324821,
-0x95220000, 0x25290002, 0xa22821, 0x229102b,
-0x54400001, 0x1324821, 0x95220000, 0x25290002,
-0xa22821, 0x229102b, 0x54400001, 0x1324821,
-0x95220000, 0x25290002, 0xa22821, 0x229102b,
-0x54400001, 0x1324821, 0x95220000, 0x8003e99,
-0xa22821, 0x94650010, 0x94620014, 0x24690016,
-0x30420fff, 0x14400003, 0x24a5ffec, 0x8003e8c,
-0x24130001, 0x9821, 0xa03021, 0x91230001,
-0x25290004, 0x95220000, 0x25290002, 0x95240000,
-0x25290002, 0xa32821, 0xa22821, 0x95220000,
-0x95230002, 0xa42821, 0xa22821, 0xa32821,
-0x51c02, 0x30a2ffff, 0x622821, 0x51c02,
-0x30a2ffff, 0x622821, 0x96e2046a, 0x30420001,
-0x1040001e, 0x2021, 0x95820016, 0x4e2023,
-0x41402, 0x822021, 0x326200ff, 0x50400002,
-0x862021, 0x852021, 0x41402, 0x822021,
-0x3084ffff, 0x50800001, 0x3404ffff, 0x8d620018,
-0x24430017, 0x223102b, 0x54400001, 0x721821,
-0x90620000, 0x38430011, 0x2c630001, 0x38420006,
-0x2c420001, 0x621825, 0x10600004, 0x0,
-0x9562000e, 0x34420001, 0xa562000e, 0x9562000e,
-0x240a0002, 0x30420004, 0x10400002, 0xa5640012,
-0x240a0004, 0x8f880120, 0x27623800, 0x25090020,
-0x122102b, 0x50400001, 0x27693000, 0x8f820128,
-0x11220004, 0x0, 0x8f820124, 0x15220007,
-0x24040020, 0x8ee201a4, 0x8021, 0x24420001,
-0xaee201a4, 0x8003f4f, 0x8ee201a4, 0x8ee5724c,
-0x8ee60490, 0x8ee70494, 0xad0b0008, 0xa504000e,
-0xad0a0018, 0x52940, 0xa01821, 0x1021,
-0xe33821, 0xe3202b, 0xc23021, 0xc43021,
-0xad060000, 0xad070004, 0x8ee2724c, 0x4d1025,
-0xad02001c, 0x8ee204c4, 0xad020010, 0xaf890120,
-0x92e24e20, 0x14400060, 0x24100001, 0x2543ffee,
-0x2c630002, 0x39420011, 0x2c420001, 0x621825,
-0x10600024, 0x0, 0x8ee24e30, 0x210c0,
-0x24425038, 0x2e22021, 0x8c820000, 0x1455000f,
-0x0, 0x8ee34e30, 0x8ee24e34, 0x1062000b,
-0x0, 0x8c820004, 0x24420001, 0xac820004,
-0x8ee24e34, 0x8ee34e30, 0x24420001, 0x1054002b,
-0x0, 0x8003f2e, 0x0, 0x8ee24e30,
-0x24420001, 0x50540003, 0x1021, 0x8ee24e30,
-0x24420001, 0xaee24e30, 0x8ee24e30, 0x210c0,
-0x24425038, 0x2e22021, 0x24020001, 0x8003f4e,
-0xac950000, 0x8ee24e30, 0x210c0, 0x24425038,
-0x2e22021, 0x8c830000, 0x24020007, 0x1462001f,
-0x0, 0x8ee34e30, 0x8ee24e34, 0x1062001b,
-0x0, 0x8c820004, 0x24420001, 0xac820004,
-0x8ee24e34, 0x8ee34e30, 0x24420001, 0x10540007,
-0x0, 0x8ee24e34, 0x24420001, 0x10620005,
-0x0, 0x8003f3a, 0x0, 0x14600005,
-0x0, 0x8f820128, 0x24420020, 0xaf820128,
-0x8f820128, 0x8c820004, 0x2c420011, 0x50400012,
-0xac800000, 0x8003f4f, 0x0, 0x8ee24e30,
-0x24420001, 0x50540003, 0x1021, 0x8ee24e30,
-0x24420001, 0xaee24e30, 0x8ee24e30, 0x210c0,
-0x24425038, 0x2e22021, 0x24020007, 0xac820000,
-0x24020001, 0xac820004, 0x1600000d, 0x0,
-0x8f820120, 0x3c040001, 0x248452c8, 0xafa00014,
-0xafa20010, 0x8d86001c, 0x8f870124, 0x3c050008,
-0xc002403, 0x34a50001, 0x8004057, 0x0,
-0x8ee2724c, 0x24420001, 0x304207ff, 0x11a00006,
-0xaee2724c, 0x8ee201d0, 0x2442ffff, 0xaee201d0,
-0x8003f6b, 0x8ee201d0, 0x8ee201cc, 0x2442ffff,
-0xaee201cc, 0x8ee201cc, 0x8ee201d8, 0x2442ffff,
-0xaee201d8, 0x8004057, 0x8ee201d8, 0x8f420240,
-0x104000e5, 0x0, 0x8ee20e1c, 0x24420001,
-0x8004057, 0xaee20e1c, 0x9582001e, 0xad82001c,
-0x8f420240, 0x10400072, 0x0, 0x8ee20e1c,
-0x24420001, 0xaee20e1c, 0x8f430240, 0x43102b,
-0x144000d5, 0x0, 0x8f830120, 0x27623800,
-0x24660020, 0xc2102b, 0x50400001, 0x27663000,
-0x8f820128, 0x10c20004, 0x0, 0x8f820124,
-0x14c20007, 0x0, 0x8ee201a4, 0x8021,
-0x24420001, 0xaee201a4, 0x8003fda, 0x8ee201a4,
-0x8ee2724c, 0xac62001c, 0x8ee404a8, 0x8ee504ac,
-0x2462001c, 0xac620008, 0x24020008, 0xa462000e,
-0x24020011, 0xac620018, 0xac640000, 0xac650004,
-0x8ee204c4, 0xac620010, 0xaf860120, 0x92e24e20,
-0x14400034, 0x24100001, 0x8ee24e30, 0x210c0,
-0x24425038, 0x2e22021, 0x8c820000, 0x1455001f,
-0x0, 0x8ee34e30, 0x8ee24e34, 0x1062001b,
-0x0, 0x8c820004, 0x24420001, 0xac820004,
-0x8ee24e34, 0x8ee34e30, 0x24420001, 0x10540007,
-0x0, 0x8ee24e34, 0x24420001, 0x10620005,
-0x0, 0x8003fc6, 0x0, 0x14600005,
-0x0, 0x8f820128, 0x24420020, 0xaf820128,
-0x8f820128, 0x8c820004, 0x2c420011, 0x50400011,
-0xac800000, 0x8003fda, 0x0, 0x8ee24e30,
-0x24420001, 0x50540003, 0x1021, 0x8ee24e30,
-0x24420001, 0xaee24e30, 0x8ee24e30, 0x210c0,
-0x24425038, 0x2e22021, 0x24020001, 0xac950000,
-0xac820004, 0x5600000b, 0x24100001, 0x8ee2724c,
-0x3c040001, 0x24845238, 0xafa00014, 0xafa20010,
-0x8ee6724c, 0x8f470280, 0x3c050009, 0xc002403,
-0x34a5f008, 0x56000001, 0xaee00e1c, 0x8ee20188,
-0x24420001, 0xaee20188, 0x8004050, 0x8ee20188,
-0x8f830120, 0x27623800, 0x24660020, 0xc2102b,
-0x50400001, 0x27663000, 0x8f820128, 0x10c20004,
-0x0, 0x8f820124, 0x14c20007, 0x0,
-0x8ee201a4, 0x8021, 0x24420001, 0xaee201a4,
-0x8004044, 0x8ee201a4, 0x8ee2724c, 0xac62001c,
-0x8ee404a8, 0x8ee504ac, 0x2462001c, 0xac620008,
-0x24020008, 0xa462000e, 0x24020011, 0xac620018,
-0xac640000, 0xac650004, 0x8ee204c4, 0xac620010,
-0xaf860120, 0x92e24e20, 0x14400034, 0x24100001,
-0x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
-0x8c820000, 0x1455001f, 0x0, 0x8ee34e30,
-0x8ee24e34, 0x1062001b, 0x0, 0x8c820004,
-0x24420001, 0xac820004, 0x8ee24e34, 0x8ee34e30,
-0x24420001, 0x10540007, 0x0, 0x8ee24e34,
-0x24420001, 0x10620005, 0x0, 0x8004030,
-0x0, 0x14600005, 0x0, 0x8f820128,
-0x24420020, 0xaf820128, 0x8f820128, 0x8c820004,
-0x2c420011, 0x50400011, 0xac800000, 0x8004044,
-0x0, 0x8ee24e30, 0x24420001, 0x50540003,
-0x1021, 0x8ee24e30, 0x24420001, 0xaee24e30,
-0x8ee24e30, 0x210c0, 0x24425038, 0x2e22021,
-0x24020001, 0xac950000, 0xac820004, 0x1600000b,
-0x0, 0x8ee2724c, 0x3c040001, 0x24845238,
-0xafa00014, 0xafa20010, 0x8ee6724c, 0x8f470280,
-0x3c050009, 0xc002403, 0x34a5f008, 0x8ee20174,
-0x24420001, 0xaee20174, 0x8004057, 0x8ee20174,
-0x24020001, 0xaee24e24, 0x8f830128, 0x8f820124,
-0x1462fd58, 0x0, 0x8fbf0030, 0x8fb5002c,
-0x8fb40028, 0x8fb30024, 0x8fb20020, 0x8fb1001c,
-0x8fb00018, 0x3e00008, 0x27bd0038, 0x27bdffe8,
-0x27840208, 0x27450200, 0x24060008, 0xafbf0014,
-0xc00249a, 0xafb00010, 0x2021, 0x24100001,
-0x2402241f, 0xaf900210, 0xaf900200, 0xaf800204,
-0xaf820214, 0x8f460248, 0x24030004, 0x3c020040,
-0x3c010001, 0xac235644, 0x3c010001, 0xac235648,
-0x3c010001, 0xac20570c, 0x3c010001, 0xac225640,
-0x3c010001, 0xac235648, 0xc005010, 0x24050004,
-0xc004791, 0x0, 0x8ee20000, 0x3c03feff,
-0x3463fffd, 0x431024, 0xaee20000, 0x3c023c00,
-0xaf82021c, 0x3c010001, 0x370821, 0xac3083ac,
-0x8fbf0014, 0x8fb00010, 0x3e00008, 0x27bd0018,
-0x27bdffe0, 0x3c050008, 0x34a50400, 0xafbf0018,
-0xafa00010, 0xafa00014, 0x8f860200, 0x3c040001,
-0x24845380, 0xc002403, 0x3821, 0x8ee20280,
-0x24420001, 0xaee20280, 0x8ee20280, 0x8f830200,
-0x3c023f00, 0x621824, 0x8fbf0018, 0x3c020400,
-0x3e00008, 0x27bd0020, 0x27bdffd8, 0xafbf0020,
-0xafb1001c, 0xafb00018, 0x8f900220, 0x8ee20214,
-0x3821, 0x24420001, 0xaee20214, 0x8ee20214,
-0x3c020300, 0x2021024, 0x10400027, 0x3c110400,
-0xc00429b, 0x0, 0x3c020100, 0x2021024,
-0x10400007, 0x0, 0x8ee20218, 0x24420001,
-0xaee20218, 0x8ee20218, 0x80040c6, 0x3c03fdff,
-0x8ee2021c, 0x24420001, 0xaee2021c, 0x8ee2021c,
-0x3c03fdff, 0x3463ffff, 0x3c0808ff, 0x3508ffff,
-0x8ee20000, 0x3c040001, 0x2484538c, 0x3c050008,
-0x2003021, 0x431024, 0xaee20000, 0x8f820220,
-0x3821, 0x3c030300, 0x481024, 0x431025,
-0xaf820220, 0xafa00010, 0xc002403, 0xafa00014,
-0x8004296, 0x0, 0x2111024, 0x1040001f,
-0x3c024000, 0x8f830224, 0x24021402, 0x1462000b,
-0x3c03fdff, 0x3c040001, 0x24845398, 0x3c050008,
-0xafa00010, 0xafa00014, 0x8f860224, 0x34a5ffff,
-0xc002403, 0x3821, 0x3c03fdff, 0x8ee20000,
-0x3463ffff, 0x2002021, 0x431024, 0xc004d5c,
-0xaee20000, 0x8ee20220, 0x24420001, 0xaee20220,
-0x8ee20220, 0x8f820220, 0x3c0308ff, 0x3463ffff,
-0x431024, 0x8004295, 0x511025, 0x2021024,
-0x10400142, 0x0, 0x8ee2022c, 0x24420001,
-0xaee2022c, 0x8ee2022c, 0x8f820220, 0x3c0308ff,
-0x3463ffff, 0x431024, 0x34420004, 0xaf820220,
-0x8f830054, 0x8f820054, 0x800410e, 0x24630002,
-0x8f820054, 0x621023, 0x2c420003, 0x1440fffc,
-0x0, 0x8f8600e0, 0x8f8400e4, 0x30c20007,
-0x10400012, 0x0, 0x8f8300e4, 0x2402fff8,
-0xc21024, 0x1043000d, 0x0, 0x8f820054,
-0x8f8300e0, 0x14c30009, 0x24440050, 0x8f820054,
-0x821023, 0x2c420051, 0x10400004, 0x0,
-0x8f8200e0, 0x10c2fff9, 0x0, 0x8f820220,
-0x3c0308ff, 0x3463fffd, 0x431024, 0xaf820220,
-0x8f8600e0, 0x30c20007, 0x10400003, 0x2402fff8,
-0xc23024, 0xaf8600e0, 0x8f8300c4, 0x3c02001f,
-0x3442ffff, 0x24680008, 0x48102b, 0x10400003,
-0x3c02fff5, 0x34421000, 0x1024021, 0x8f8b00c8,
-0x8f850120, 0x8f840124, 0x8004145, 0x6021,
-0x27623800, 0x82102b, 0x50400001, 0x27643000,
-0x10a40010, 0x318200ff, 0x8c820018, 0x38430007,
-0x2c630001, 0x3842000b, 0x2c420001, 0x621825,
-0x5060fff3, 0x24840020, 0x8ee20240, 0x240c0001,
-0x24420001, 0xaee20240, 0x8ee20240, 0x8c8b0008,
-0x318200ff, 0x14400065, 0x0, 0x3c020001,
-0x571021, 0x904283c0, 0x14400060, 0x0,
-0x8f8400e4, 0xc41023, 0x218c3, 0x4620001,
-0x24630200, 0x8f8900c4, 0x10600005, 0x24020001,
-0x10620009, 0x0, 0x8004187, 0x0,
-0x8ee20230, 0x1205821, 0x24420001, 0xaee20230,
-0x80041bc, 0x8ee20230, 0x8ee20234, 0x3c05000a,
-0x24420001, 0xaee20234, 0x8c8b0000, 0x34a5f000,
-0x8ee20234, 0x12b1823, 0xa3102b, 0x54400001,
-0x651821, 0x2c62233f, 0x14400040, 0x0,
-0x8f8200e8, 0x24420008, 0xaf8200e8, 0x8f8200e8,
-0x8f8200e4, 0x1205821, 0x24420008, 0xaf8200e4,
-0x80041bc, 0x8f8200e4, 0x8ee20238, 0x3c03000a,
-0x24420001, 0xaee20238, 0x8c840000, 0x3463f000,
-0x8ee20238, 0x883823, 0x67102b, 0x54400001,
-0xe33821, 0x3c020003, 0x34420d40, 0x47102b,
-0x10400003, 0x0, 0x80041bc, 0x805821,
-0x8f8200e4, 0x24440008, 0xaf8400e4, 0x8f8400e4,
-0x10860018, 0x3c05000a, 0x34a5f000, 0x3c0a0003,
-0x354a0d40, 0x8ee2007c, 0x24420001, 0xaee2007c,
-0x8c830000, 0x8ee2007c, 0x683823, 0xa7102b,
-0x54400001, 0xe53821, 0x147102b, 0x54400007,
-0x605821, 0x8f8200e4, 0x24440008, 0xaf8400e4,
-0x8f8400e4, 0x1486ffef, 0x0, 0x14860005,
-0x0, 0x1205821, 0xaf8600e4, 0x80041bc,
-0xaf8600e8, 0xaf8400e4, 0xaf8400e8, 0x8f8200c8,
-0x3c03000a, 0x3463f000, 0x483823, 0x67102b,
-0x54400001, 0xe33821, 0x3c020003, 0x34420d3f,
-0x47102b, 0x54400007, 0x6021, 0x1683823,
-0x67102b, 0x54400003, 0xe33821, 0x80041cf,
-0x3c020003, 0x3c020003, 0x34420d3f, 0x47102b,
-0x14400016, 0x318200ff, 0x14400006, 0x0,
-0x3c020001, 0x571021, 0x904283c0, 0x1040000f,
-0x0, 0x8ee2023c, 0x3c04fdff, 0x8ee30000,
-0x3484ffff, 0x24420001, 0xaee2023c, 0x8ee2023c,
-0x24020001, 0x641824, 0x3c010001, 0x370821,
-0xa02283b8, 0x800422c, 0xaee30000, 0xaf8b00c8,
-0x8f8300c8, 0x8f8200c4, 0x3c04000a, 0x3484f000,
-0x623823, 0x87102b, 0x54400001, 0xe43821,
-0x3c020003, 0x34420d40, 0x47102b, 0x2ce30001,
-0x431025, 0x10400008, 0x0, 0x8f820220,
-0x3c0308ff, 0x3463ffff, 0x431024, 0x3c034000,
-0x431025, 0xaf820220, 0x8f8600e0, 0x8f8400e4,
-0x10c4002a, 0x0, 0x8ee2007c, 0x24420001,
-0xaee2007c, 0x8ee2007c, 0x24c2fff8, 0xaf8200e0,
-0x3c020001, 0x8c427790, 0x3c030008, 0x8f8600e0,
-0x431024, 0x1040001d, 0x0, 0x10c4001b,
-0x240dfff8, 0x3c0a000a, 0x354af000, 0x3c0c0080,
-0x24850008, 0x27622800, 0x50a20001, 0x27651800,
-0x8c880004, 0x8c820000, 0x8ca90000, 0x3103ffff,
-0x431021, 0x4d1024, 0x24430010, 0x6b102b,
-0x54400001, 0x6a1821, 0x12b102b, 0x54400001,
-0x12a4821, 0x10690002, 0x10c1025, 0xac820004,
-0xa02021, 0x14c4ffeb, 0x24850008, 0x8f820220,
-0x3c0308ff, 0x3463ffff, 0x431024, 0x34420002,
-0xaf820220, 0x8f830054, 0x8f820054, 0x8004237,
-0x24630001, 0x8f820054, 0x621023, 0x2c420002,
-0x1440fffc, 0x0, 0x8f820220, 0x3c0308ff,
-0x3463fffb, 0x431024, 0xaf820220, 0x6010055,
-0x0, 0x8ee20228, 0x24420001, 0xaee20228,
-0x8ee20228, 0x8f820220, 0x3c0308ff, 0x3463ffff,
-0x431024, 0x34420004, 0xaf820220, 0x8f830054,
-0x8f820054, 0x8004251, 0x24630002, 0x8f820054,
-0x621023, 0x2c420003, 0x1440fffc, 0x0,
-0x8f8600e0, 0x30c20007, 0x10400012, 0x0,
-0x8f8300e4, 0x2402fff8, 0xc21024, 0x1043000d,
-0x0, 0x8f820054, 0x8f8300e0, 0x14c30009,
-0x24440032, 0x8f820054, 0x821023, 0x2c420033,
-0x10400004, 0x0, 0x8f8200e0, 0x10c2fff9,
-0x0, 0x8f820220, 0x3c0308ff, 0x3463fffd,
-0x431024, 0xaf820220, 0x8f8600e0, 0x30c20007,
-0x10400003, 0x2402fff8, 0xc23024, 0xaf8600e0,
-0x240301f5, 0x8f8200e8, 0x673823, 0x718c0,
-0x431021, 0xaf8200e8, 0x8f8200e8, 0xaf8200e4,
-0x8ee2007c, 0x3c0408ff, 0x3484ffff, 0x471021,
-0xaee2007c, 0x8f820220, 0x3c038000, 0x34630002,
-0x441024, 0x431025, 0xaf820220, 0x8f830054,
-0x8f820054, 0x800428d, 0x24630001, 0x8f820054,
-0x621023, 0x2c420002, 0x1440fffc, 0x0,
-0x8f820220, 0x3c0308ff, 0x3463fffb, 0x431024,
-0xaf820220, 0x8fbf0020, 0x8fb1001c, 0x8fb00018,
-0x3e00008, 0x27bd0028, 0x3c020001, 0x8c425658,
-0x27bdffd8, 0x10400012, 0xafbf0020, 0x3c040001,
-0x248453a4, 0x3c050008, 0x24020001, 0x3c010001,
-0x370821, 0xac2283ac, 0xafa00010, 0xafa00014,
-0x8f860220, 0x34a50498, 0x3c010001, 0xac205658,
-0x3c010001, 0xac22564c, 0xc002403, 0x3821,
-0x8f420268, 0x3c037fff, 0x3463ffff, 0x431024,
-0xaf420268, 0x8ee204d0, 0x8ee404d4, 0x2403fffe,
-0x431024, 0x30840002, 0x1080011e, 0xaee204d0,
-0x8ee204d4, 0x2403fffd, 0x431024, 0xaee204d4,
-0x8f820044, 0x3c030600, 0x34632000, 0x34420020,
-0xaf820044, 0xafa30018, 0x8ee20608, 0x8f430228,
-0x24420001, 0x304a00ff, 0x514300fe, 0xafa00010,
-0x8ee20608, 0x210c0, 0x571021, 0x8fa30018,
-0x8fa4001c, 0xac43060c, 0xac440610, 0x8f830054,
-0x8f820054, 0x24690032, 0x1221023, 0x2c420033,
-0x1040006a, 0x5821, 0x24180008, 0x240f000d,
-0x240d0007, 0x240c0040, 0x240e0001, 0x8f870120,
-0x27623800, 0x24e80020, 0x102102b, 0x50400001,
-0x27683000, 0x8f820128, 0x11020004, 0x0,
-0x8f820124, 0x15020007, 0x1021, 0x8ee201a4,
-0x2821, 0x24420001, 0xaee201a4, 0x800433d,
-0x8ee201a4, 0x8ee40608, 0x420c0, 0x801821,
-0x8ee40430, 0x8ee50434, 0xa32821, 0xa3302b,
-0x822021, 0x862021, 0xace40000, 0xace50004,
-0x8ee20608, 0xa4f8000e, 0xacef0018, 0xacea001c,
-0x210c0, 0x2442060c, 0x2e21021, 0xace20008,
-0x8ee204c4, 0xace20010, 0xaf880120, 0x92e24e20,
-0x14400033, 0x24050001, 0x8ee24e30, 0x210c0,
-0x24425038, 0x2e22021, 0x8c820000, 0x144d001f,
-0x0, 0x8ee34e30, 0x8ee24e34, 0x1062001b,
-0x0, 0x8c820004, 0x24420001, 0xac820004,
-0x8ee24e34, 0x8ee34e30, 0x24420001, 0x104c0007,
-0x0, 0x8ee24e34, 0x24420001, 0x10620005,
-0x0, 0x800432a, 0x0, 0x14600005,
-0x0, 0x8f820128, 0x24420020, 0xaf820128,
-0x8f820128, 0x8c820004, 0x2c420011, 0x50400010,
-0xac800000, 0x800433d, 0x0, 0x8ee24e30,
-0x24420001, 0x504c0003, 0x1021, 0x8ee24e30,
-0x24420001, 0xaee24e30, 0x8ee24e30, 0x210c0,
-0x24425038, 0x2e22021, 0xac8d0000, 0xac8e0004,
-0x54a00006, 0x240b0001, 0x8f820054, 0x1221023,
-0x2c420033, 0x1440ff9d, 0x0, 0x316300ff,
-0x24020001, 0x54620079, 0xafa00010, 0xaeea0608,
-0x8f830054, 0x8f820054, 0x24690032, 0x1221023,
-0x2c420033, 0x10400061, 0x5821, 0x240d0008,
-0x240c0011, 0x24080012, 0x24070040, 0x240a0001,
-0x8f830120, 0x27623800, 0x24660020, 0xc2102b,
-0x50400001, 0x27663000, 0x8f820128, 0x10c20004,
-0x0, 0x8f820124, 0x14c20007, 0x0,
-0x8ee201a4, 0x2821, 0x24420001, 0xaee201a4,
-0x80043a9, 0x8ee201a4, 0x8ee20608, 0xac62001c,
-0x8ee404a0, 0x8ee504a4, 0x2462001c, 0xac620008,
-0xa46d000e, 0xac6c0018, 0xac640000, 0xac650004,
-0x8ee204c4, 0xac620010, 0xaf860120, 0x92e24e20,
-0x14400033, 0x24050001, 0x8ee24e30, 0x210c0,
-0x24425038, 0x2e22021, 0x8c820000, 0x1448001f,
-0x0, 0x8ee34e30, 0x8ee24e34, 0x1062001b,
-0x0, 0x8c820004, 0x24420001, 0xac820004,
-0x8ee24e34, 0x8ee34e30, 0x24420001, 0x10470007,
-0x0, 0x8ee24e34, 0x24420001, 0x10620005,
-0x0, 0x8004396, 0x0, 0x14600005,
-0x0, 0x8f820128, 0x24420020, 0xaf820128,
-0x8f820128, 0x8c820004, 0x2c420011, 0x50400010,
-0xac800000, 0x80043a9, 0x0, 0x8ee24e30,
-0x24420001, 0x50470003, 0x1021, 0x8ee24e30,
-0x24420001, 0xaee24e30, 0x8ee24e30, 0x210c0,
-0x24425038, 0x2e22021, 0xac880000, 0xac8a0004,
-0x54a00006, 0x240b0001, 0x8f820054, 0x1221023,
-0x2c420033, 0x1440ffa6, 0x0, 0x316300ff,
-0x24020001, 0x54620003, 0xafa00010, 0x80043d6,
-0x0, 0x3c040001, 0x248453b0, 0xafa00014,
-0x8f860120, 0x8f870124, 0x3c050009, 0xc002403,
-0x34a5f011, 0x80043d6, 0x0, 0x3c040001,
-0x248453bc, 0xafa00014, 0x8f860120, 0x8f870124,
-0x3c050009, 0xc002403, 0x34a5f010, 0x80043d6,
-0x0, 0x3c040001, 0x248453c8, 0xafa00014,
-0x8ee60608, 0x8f470228, 0x3c050009, 0xc002403,
-0x34a5f00f, 0x8ee201ac, 0x24420001, 0xaee201ac,
-0x8ee201ac, 0x8ee2015c, 0x24420001, 0xaee2015c,
-0x8ee2015c, 0x8fbf0020, 0x3e00008, 0x27bd0028,
-0x3c020001, 0x8c425658, 0x27bdffe0, 0x1440000d,
-0xafbf0018, 0x3c040001, 0x248453d4, 0x3c050008,
-0xafa00010, 0xafa00014, 0x8f860220, 0x34a50499,
-0x24020001, 0x3c010001, 0xac225658, 0xc002403,
-0x3821, 0x8ee204d0, 0x3c030001, 0x771821,
-0x946383b2, 0x34420001, 0x10600007, 0xaee204d0,
-0x8f820220, 0x3c0308ff, 0x3463ffff, 0x431024,
-0x34420008, 0xaf820220, 0x2021, 0xc00511d,
-0x24050004, 0xaf420268, 0x8fbf0018, 0x3e00008,
-0x27bd0020, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x3c120001,
-0x26521200, 0x3c140001, 0x8e9455d0, 0x3c100001,
-0x26101120, 0x3c15c000, 0x36b50060, 0x8e8a0000,
-0x8eb30000, 0x26a400b, 0x248000a, 0x200f821,
-0x0, 0xd, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x80014d6,
-0x0, 0x80014d8, 0x3c0a0001, 0x80014d8,
-0x3c0a0002, 0x80014d8, 0x0, 0x80024a6,
-0x0, 0x80014d8, 0x3c0a0003, 0x80014d8,
-0x3c0a0004, 0x8002f8c, 0x0, 0x80014d8,
-0x3c0a0005, 0x8003ce8, 0x0, 0x8003c66,
-0x0, 0x80014d8, 0x3c0a0006, 0x80014d8,
-0x3c0a0007, 0x80014d8, 0x0, 0x80014d8,
-0x0, 0x80014d8, 0x0, 0x8002a75,
-0x0, 0x80014d8, 0x3c0a000b, 0x80014d8,
-0x3c0a000c, 0x80014d8, 0x3c0a000d, 0x800237a,
-0x0, 0x8002339, 0x0, 0x80014d8,
-0x3c0a000e, 0x8001b3c, 0x0, 0x80024a4,
-0x0, 0x80014d8, 0x3c0a000f, 0x80040a7,
-0x0, 0x8004091, 0x0, 0x80014d8,
-0x3c0a0010, 0x80014ee, 0x0, 0x80014d8,
-0x3c0a0011, 0x80014d8, 0x3c0a0012, 0x80014d8,
-0x3c0a0013, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x3c030001,
-0x34633800, 0x24050080, 0x2404001f, 0x2406ffff,
-0x24020001, 0xaf80021c, 0xaf820200, 0xaf820220,
-0x3631021, 0xaf8200c0, 0x3631021, 0xaf8200c4,
-0x3631021, 0xaf8200c8, 0x27623800, 0xaf8200d0,
-0x27623800, 0xaf8200d4, 0x27623800, 0xaf8200d8,
-0x27621800, 0xaf8200e0, 0x27621800, 0xaf8200e4,
-0x27621800, 0xaf8200e8, 0x27621000, 0xaf8200f0,
-0x27621000, 0xaf8200f4, 0x27621000, 0xaf8200f8,
-0xaca00000, 0x2484ffff, 0x1486fffd, 0x24a50004,
-0x8f830040, 0x3c02f000, 0x621824, 0x3c025000,
-0x1062000c, 0x43102b, 0x14400006, 0x3c026000,
-0x3c024000, 0x10620008, 0x24020800, 0x8004539,
-0x0, 0x10620004, 0x24020800, 0x8004539,
-0x0, 0x24020700, 0x3c010001, 0xac22565c,
-0x3e00008, 0x0, 0x27bdffd0, 0xafbf0028,
-0x3c010001, 0xc004d37, 0xac205644, 0x24040001,
-0x2821, 0x27a60020, 0x34028000, 0xc0048fa,
-0xa7a20020, 0x8f830054, 0x8f820054, 0x800454b,
-0x24630064, 0x8f820054, 0x621023, 0x2c420065,
-0x1440fffc, 0x24040001, 0x24050001, 0xc0048b8,
-0x27a60020, 0x8f830054, 0x8f820054, 0x8004557,
-0x24630064, 0x8f820054, 0x621023, 0x2c420065,
-0x1440fffc, 0x24040001, 0x24050001, 0xc0048b8,
-0x27a60020, 0x8f830054, 0x8f820054, 0x8004563,
-0x24630064, 0x8f820054, 0x621023, 0x2c420065,
-0x1440fffc, 0x24040001, 0x24050002, 0xc0048b8,
-0x27a60018, 0x8f830054, 0x8f820054, 0x800456f,
-0x24630064, 0x8f820054, 0x621023, 0x2c420065,
-0x1440fffc, 0x24040001, 0x24050003, 0xc0048b8,
-0x27a6001a, 0x97a20020, 0x10400028, 0x24030001,
-0x3c020001, 0x8c425644, 0x97a30018, 0x34420001,
-0x3c010001, 0xac225644, 0x24020015, 0x1462000e,
-0x0, 0x97a2001a, 0x3042fff0, 0x3843f420,
-0x2c630001, 0x3842f430, 0x2c420001, 0x621825,
-0x10600005, 0x24020003, 0x3c010001, 0xac225720,
-0x80045a8, 0x3c08fff0, 0x97a30018, 0x24027810,
-0x1462000a, 0x24020002, 0x97a2001a, 0x3042fff0,
-0x14400006, 0x24020002, 0x24020004, 0x3c010001,
-0xac225720, 0x80045a8, 0x3c08fff0, 0x3c010001,
-0xac225720, 0x80045a8, 0x3c08fff0, 0x3c020001,
-0x8c425644, 0x3c010001, 0xac235720, 0x34420004,
-0x3c010001, 0xac225644, 0x3c08fff0, 0x3508bdc0,
-0x8f830054, 0x97a60018, 0x3c070001, 0x8ce75720,
-0x3c040001, 0x24845440, 0x24020001, 0x3c010001,
-0xac22564c, 0xafa60010, 0x3c060001, 0x8cc65644,
-0x97a2001a, 0x3c05000d, 0x34a50100, 0x3c010001,
-0xac205648, 0x681821, 0x3c010001, 0xac235718,
-0xc002403, 0xafa20014, 0x8fbf0028, 0x3e00008,
-0x27bd0030, 0x27bdffe8, 0x3c040001, 0x8c845648,
-0x24060004, 0x24020001, 0x1482000a, 0xafbf0010,
-0x3c020001, 0x8c42779c, 0x3c050004, 0x30428000,
-0x1040000c, 0x34a593e0, 0x3c05000f, 0x80045da,
-0x34a54240, 0x3c020001, 0x8c42779c, 0x3c05000f,
-0x30428000, 0x10400003, 0x34a54240, 0x3c05001e,
-0x34a58480, 0x3c020001, 0x8c425718, 0x8f830054,
-0x451021, 0x431023, 0x45102b, 0x14400037,
-0x0, 0x3c020001, 0x8c425650, 0x14400033,
-0x0, 0x3c010001, 0x10c00025, 0xac205660,
-0x3c090001, 0x8d295644, 0x24070001, 0x3c054000,
-0x3c080001, 0x2508779c, 0x250afffc, 0x42042,
-0x14800002, 0x24c6ffff, 0x24040008, 0x891024,
-0x10400010, 0x0, 0x14870008, 0x0,
-0x8d020000, 0x451024, 0x1040000a, 0x0,
-0x3c010001, 0x8004606, 0xac245660, 0x8d420000,
-0x451024, 0x10400003, 0x0, 0x3c010001,
-0xac275660, 0x3c020001, 0x8c425660, 0x6182b,
-0x2c420001, 0x431024, 0x5440ffe5, 0x42042,
-0x3c020001, 0x8c425660, 0x3c010001, 0x10400028,
-0xac245648, 0x8f830054, 0x24020001, 0x3c010001,
-0xac22564c, 0x3c010001, 0xac235718, 0x3c020001,
-0x8c425660, 0x1040001e, 0x0, 0x3c020001,
-0x8c42564c, 0x10400006, 0x24020001, 0x3c010001,
-0xac20564c, 0x3c010001, 0x370821, 0xac2283ac,
-0x3c030001, 0x771821, 0x8c6383ac, 0x24020008,
-0x10620005, 0x24020001, 0xc00463c, 0x0,
-0x8004639, 0x0, 0x3c030001, 0x8c635648,
-0x10620007, 0x2402000e, 0x3c030001, 0x8c637730,
-0x10620003, 0x0, 0xc004d5c, 0x8f840220,
-0x8fbf0010, 0x3e00008, 0x27bd0018, 0x27bdffe0,
-0x3c02fdff, 0xafbf0018, 0x8ee30000, 0x3c050001,
-0x8ca55648, 0x3c040001, 0x8c84566c, 0x3442ffff,
-0x621824, 0x14a40008, 0xaee30000, 0x3c030001,
-0x771821, 0x8c6383ac, 0x3c020001, 0x8c425670,
-0x10620008, 0x0, 0x3c020001, 0x571021,
-0x8c4283ac, 0x3c010001, 0xac25566c, 0x3c010001,
-0xac225670, 0x3c030001, 0x8c635648, 0x24020002,
-0x10620131, 0x2c620003, 0x10400005, 0x24020001,
-0x10620008, 0x0, 0x800478b, 0x0,
-0x24020004, 0x10620079, 0x24020001, 0x800478c,
-0x0, 0x3c020001, 0x571021, 0x8c4283ac,
-0x2443ffff, 0x2c620008, 0x10400122, 0x31080,
-0x3c010001, 0x220821, 0x8c225458, 0x400008,
-0x0, 0xc004791, 0x0, 0x3c020001,
-0x8c425654, 0x3c010001, 0xac2055e0, 0x104000bd,
-0x24020002, 0x3c010001, 0x370821, 0xac2283ac,
-0x3c010001, 0x800478e, 0xac205654, 0xc00493b,
-0x0, 0x3c030001, 0x8c635680, 0x80046fd,
-0x24020011, 0x3c050001, 0x8ca55648, 0x3c060001,
-0x8cc6779c, 0xc005010, 0x2021, 0x24020005,
-0x3c010001, 0xac205654, 0x3c010001, 0x370821,
-0x800478e, 0xac2283ac, 0x3c040001, 0x2484544c,
-0x3c05000f, 0x34a50100, 0x3021, 0x3821,
-0xafa00010, 0xc002403, 0xafa00014, 0x800478e,
-0x0, 0x8f820220, 0x3c03f700, 0x431025,
-0x8004726, 0xaf820220, 0x8f820220, 0x3c030004,
-0x431024, 0x14400090, 0x24020007, 0x8f830054,
-0x3c020001, 0x8c425710, 0x2463d8f0, 0x431023,
-0x2c422710, 0x144000df, 0x24020001, 0x800478c,
-0x0, 0x3c050001, 0x8ca55648, 0xc00511d,
-0x2021, 0xc0051e8, 0x2021, 0x3c030001,
-0x8c637794, 0x46100d1, 0x24020001, 0x3c020008,
-0x621024, 0x10400006, 0x0, 0x8f820214,
-0x3c03ffff, 0x431024, 0x80046c9, 0x3442251f,
-0x8f820214, 0x3c03ffff, 0x431024, 0x3442241f,
-0xaf820214, 0x8ee20000, 0x3c030200, 0x431025,
-0xaee20000, 0x8f820220, 0x2403fffb, 0x431024,
-0xaf820220, 0x8f820220, 0x34420002, 0xaf820220,
-0x24020008, 0x3c010001, 0x370821, 0xc0043dd,
-0xac2283ac, 0x800478e, 0x0, 0x3c020001,
-0x571021, 0x8c4283ac, 0x2443ffff, 0x2c620008,
-0x104000ac, 0x31080, 0x3c010001, 0x220821,
-0x8c225478, 0x400008, 0x0, 0xc00429b,
-0x0, 0x3c010001, 0xac20564c, 0xaf800204,
-0x3c010001, 0xc004791, 0xac207780, 0x24020001,
-0x3c010001, 0xac225664, 0x24020002, 0x3c010001,
-0x370821, 0x800478e, 0xac2283ac, 0xc00480e,
-0x0, 0x3c030001, 0x8c635664, 0x24020009,
-0x14620090, 0x24020003, 0x3c010001, 0x370821,
-0x800478e, 0xac2283ac, 0x3c020001, 0x8c427798,
-0x30424000, 0x10400005, 0x0, 0x8f820044,
-0x3c03ffff, 0x800470e, 0x34637fff, 0x8f820044,
-0x2403ff7f, 0x431024, 0xaf820044, 0x8f830054,
-0x8004728, 0x24020004, 0x8f830054, 0x3c020001,
-0x8c425710, 0x2463d8f0, 0x431023, 0x2c422710,
-0x14400074, 0x24020005, 0x3c010001, 0x370821,
-0x800478e, 0xac2283ac, 0x8f820220, 0x3c03f700,
-0x431025, 0xaf820220, 0xaf800204, 0x3c010001,
-0xac207780, 0x8f830054, 0x24020006, 0x3c010001,
-0x370821, 0xac2283ac, 0x3c010001, 0x800478e,
-0xac235710, 0x8f830054, 0x3c020001, 0x8c425710,
-0x2463fff6, 0x431023, 0x2c42000a, 0x14400059,
-0x0, 0x24020007, 0x3c010001, 0x370821,
-0x800478e, 0xac2283ac, 0x8f820220, 0x3c04f700,
-0x441025, 0xaf820220, 0x8f820220, 0x3c030300,
-0x431024, 0x14400005, 0x1821, 0x8f820220,
-0x24030001, 0x441025, 0xaf820220, 0x10600043,
-0x24020001, 0x8f820214, 0x3c03ffff, 0x3c040001,
-0x8c845708, 0x431024, 0x3442251f, 0xaf820214,
-0x24020008, 0x3c010001, 0x370821, 0x1080000b,
-0xac2283ac, 0x3c020001, 0x8c4256e4, 0x14400007,
-0x24020001, 0x3c010001, 0xac227730, 0xc004d5c,
-0x8f840220, 0x800477b, 0x0, 0x8f820220,
-0x3c030008, 0x431024, 0x14400017, 0x2402000e,
-0x3c010001, 0xac227730, 0x8ee20000, 0x2021,
-0x3c030200, 0x431025, 0xc0051e8, 0xaee20000,
-0x8f820220, 0x2403fffb, 0x431024, 0xaf820220,
-0x8f820220, 0x34420002, 0xc0043dd, 0xaf820220,
-0x3c050001, 0x8ca55648, 0xc00511d, 0x2021,
-0x800478e, 0x0, 0x3c020001, 0x8c4256e4,
-0x10400010, 0x0, 0x3c020001, 0x8c4256e0,
-0x2442ffff, 0x3c010001, 0xac2256e0, 0x14400009,
-0x24020002, 0x3c010001, 0xac2056e4, 0x3c010001,
-0x800478e, 0xac2256e0, 0x24020001, 0x3c010001,
-0xac22564c, 0x8fbf0018, 0x3e00008, 0x27bd0020,
-0x8f820200, 0x8f820220, 0x8f820220, 0x34420004,
-0xaf820220, 0x8f820200, 0x3c060001, 0x8cc65648,
-0x34420004, 0xaf820200, 0x24020002, 0x10c2003a,
-0x2cc20003, 0x10400005, 0x24020001, 0x10c20008,
-0x0, 0x80047d7, 0x0, 0x24020004,
-0x10c20013, 0x24020001, 0x80047d7, 0x0,
-0x3c030001, 0x8c635638, 0x3c020001, 0x8c425640,
-0x3c040001, 0x8c84565c, 0x3c050001, 0x8ca5563c,
-0xaf860200, 0xaf860220, 0x34630022, 0x441025,
-0x451025, 0x34420002, 0x80047d6, 0xaf830200,
-0x3c030001, 0x8c635708, 0xaf820200, 0x10600009,
-0xaf820220, 0x3c020001, 0x8c4256e4, 0x14400005,
-0x3c033f00, 0x3c020001, 0x8c425630, 0x80047ca,
-0x346300e0, 0x3c020001, 0x8c425630, 0x3c033f00,
-0x346300e2, 0x431025, 0xaf820200, 0x3c030001,
-0x8c635634, 0x3c04f700, 0x3c020001, 0x8c425640,
-0x3c050001, 0x8ca5565c, 0x641825, 0x431025,
-0x451025, 0xaf820220, 0x3e00008, 0x0,
-0x8f820220, 0x3c030001, 0x8c635648, 0x34420004,
-0xaf820220, 0x24020001, 0x1062000f, 0x0,
-0x8f830054, 0x8f820054, 0x24630002, 0x621023,
-0x2c420003, 0x10400011, 0x0, 0x8f820054,
-0x621023, 0x2c420003, 0x1040000c, 0x0,
-0x80047e8, 0x0, 0x8f830054, 0x8f820054,
-0x80047f4, 0x24630007, 0x8f820054, 0x621023,
-0x2c420008, 0x1440fffc, 0x0, 0x8f8400e0,
-0x30820007, 0x1040000d, 0x0, 0x8f820054,
-0x8f8300e0, 0x14830009, 0x24450032, 0x8f820054,
-0xa21023, 0x2c420033, 0x10400004, 0x0,
-0x8f8200e0, 0x1082fff9, 0x0, 0x8f820220,
-0x2403fffd, 0x431024, 0xaf820220, 0x3e00008,
-0x0, 0x3c030001, 0x8c635664, 0x3c020001,
-0x8c425668, 0x50620004, 0x2463ffff, 0x3c010001,
-0xac235668, 0x2463ffff, 0x2c620009, 0x1040009d,
-0x31080, 0x3c010001, 0x220821, 0x8c225498,
-0x400008, 0x0, 0x8f820044, 0x34428080,
-0xaf820044, 0x8f830054, 0x80048a7, 0x24020002,
-0x8f830054, 0x3c020001, 0x8c425714, 0x2463d8f0,
-0x431023, 0x2c422710, 0x1440008a, 0x24020003,
-0x80048b4, 0x0, 0x8f820044, 0x3c03ffff,
-0x34637fff, 0x431024, 0xaf820044, 0x8f830054,
-0x80048a7, 0x24020004, 0x8f830054, 0x3c020001,
-0x8c425714, 0x2463fff6, 0x431023, 0x2c42000a,
-0x14400078, 0x24020005, 0x80048b4, 0x0,
-0x8f820220, 0x3c03f700, 0x431025, 0xaf820220,
-0x8f820220, 0x2403fffb, 0x431024, 0xaf820220,
-0x8f820220, 0x34420002, 0xaf820220, 0x3c023f00,
-0x344200e0, 0xaf820200, 0x8f820200, 0x2403fffd,
-0x431024, 0xaf820200, 0x24040001, 0x3405ffff,
-0xaf840204, 0x8f830054, 0x8f820054, 0x800485b,
-0x24630001, 0x8f820054, 0x621023, 0x2c420002,
-0x1440fffc, 0x0, 0x8f820224, 0x42040,
-0xa4102b, 0x1040fff2, 0x0, 0x8f820220,
-0x3c03f700, 0x431025, 0xaf820220, 0x8f820214,
-0x3c03ffff, 0x431024, 0x3442251f, 0xaf820214,
-0x8f820220, 0x2403fffb, 0x431024, 0xaf820220,
-0x8f820220, 0x3c04f700, 0x34840008, 0x34420002,
-0xaf820220, 0x8f820220, 0x3c033f00, 0x346300e2,
-0x441025, 0xaf820220, 0xaf830200, 0x8f8400f0,
-0x276217f8, 0x14820002, 0x24850008, 0x27651000,
-0x8f8200f4, 0x10a20007, 0x3c038000, 0x34630040,
-0x3c020001, 0x244255f0, 0xac820000, 0xac830004,
-0xaf8500f0, 0x8f830054, 0x80048a7, 0x24020006,
-0x8f830054, 0x3c020001, 0x8c425714, 0x2463fff6,
-0x431023, 0x2c42000a, 0x14400022, 0x24020007,
-0x80048b4, 0x0, 0x8f8200e0, 0xaf8200e4,
-0x8f8200e0, 0xaf8200e8, 0x8f820220, 0x34420004,
-0xaf820220, 0x8f820220, 0x2403fff7, 0x431024,
-0xaf820220, 0x8f820044, 0x34428080, 0xaf820044,
-0x8f830054, 0x24020008, 0x3c010001, 0xac225664,
-0x3c010001, 0x80048b6, 0xac235714, 0x8f830054,
-0x3c020001, 0x8c425714, 0x2463d8f0, 0x431023,
-0x2c422710, 0x14400003, 0x24020009, 0x3c010001,
-0xac225664, 0x3e00008, 0x0, 0x27bdffd8,
-0xafb20018, 0x809021, 0xafb3001c, 0xa09821,
-0xafb10014, 0xc08821, 0xafb00010, 0x8021,
-0xafbf0020, 0xa6200000, 0xc004d11, 0x24040001,
-0x26100001, 0x2e020020, 0x1440fffb, 0x0,
-0xc004d11, 0x2021, 0xc004d11, 0x24040001,
-0xc004d11, 0x24040001, 0xc004d11, 0x2021,
-0x24100010, 0x2501024, 0x10400002, 0x2021,
-0x24040001, 0xc004d11, 0x108042, 0x1600fffa,
-0x2501024, 0x24100010, 0x2701024, 0x10400002,
-0x2021, 0x24040001, 0xc004d11, 0x108042,
-0x1600fffa, 0x2701024, 0xc004d37, 0x34108000,
-0xc004d37, 0x0, 0xc004cf1, 0x0,
-0x50400005, 0x108042, 0x96220000, 0x501025,
-0xa6220000, 0x108042, 0x1600fff7, 0x0,
-0xc004d37, 0x0, 0x8fbf0020, 0x8fb3001c,
-0x8fb20018, 0x8fb10014, 0x8fb00010, 0x3e00008,
-0x27bd0028, 0x27bdffd8, 0xafb10014, 0x808821,
-0xafb20018, 0xa09021, 0xafb3001c, 0xc09821,
-0xafb00010, 0x8021, 0xafbf0020, 0xc004d11,
-0x24040001, 0x26100001, 0x2e020020, 0x1440fffb,
-0x0, 0xc004d11, 0x2021, 0xc004d11,
-0x24040001, 0xc004d11, 0x2021, 0xc004d11,
-0x24040001, 0x24100010, 0x2301024, 0x10400002,
-0x2021, 0x24040001, 0xc004d11, 0x108042,
-0x1600fffa, 0x2301024, 0x24100010, 0x2501024,
-0x10400002, 0x2021, 0x24040001, 0xc004d11,
-0x108042, 0x1600fffa, 0x2501024, 0xc004d11,
-0x24040001, 0xc004d11, 0x2021, 0x34108000,
-0x96620000, 0x501024, 0x10400002, 0x2021,
-0x24040001, 0xc004d11, 0x108042, 0x1600fff8,
-0x0, 0xc004d37, 0x0, 0x8fbf0020,
-0x8fb3001c, 0x8fb20018, 0x8fb10014, 0x8fb00010,
-0x3e00008, 0x27bd0028, 0x3c030001, 0x8c635680,
-0x3c020001, 0x8c4256c4, 0x27bdffd8, 0xafbf0020,
-0xafb1001c, 0x10620003, 0xafb00018, 0x3c010001,
-0xac2356c4, 0x2463ffff, 0x2c620013, 0x104003a3,
-0x31080, 0x3c010001, 0x220821, 0x8c2254c0,
-0x400008, 0x0, 0xc004d37, 0x8021,
-0x34028000, 0xa7a20010, 0x27b10010, 0xc004d11,
-0x24040001, 0x26100001, 0x2e020020, 0x1440fffb,
-0x0, 0xc004d11, 0x2021, 0xc004d11,
-0x24040001, 0xc004d11, 0x2021, 0xc004d11,
-0x24040001, 0x24100010, 0x32020001, 0x10400002,
-0x2021, 0x24040001, 0xc004d11, 0x108042,
-0x1600fffa, 0x32020001, 0x24100010, 0xc004d11,
-0x2021, 0x108042, 0x1600fffc, 0x0,
-0xc004d11, 0x24040001, 0xc004d11, 0x2021,
-0x34108000, 0x96220000, 0x501024, 0x10400002,
-0x2021, 0x24040001, 0xc004d11, 0x108042,
-0x1600fff8, 0x0, 0xc004d37, 0x0,
-0x8004cea, 0x24020002, 0x27b10010, 0xa7a00010,
-0x8021, 0xc004d11, 0x24040001, 0x26100001,
-0x2e020020, 0x1440fffb, 0x0, 0xc004d11,
-0x2021, 0xc004d11, 0x24040001, 0xc004d11,
-0x24040001, 0xc004d11, 0x2021, 0x24100010,
-0x32020001, 0x10400002, 0x2021, 0x24040001,
-0xc004d11, 0x108042, 0x1600fffa, 0x32020001,
-0x24100010, 0xc004d11, 0x2021, 0x108042,
-0x1600fffc, 0x0, 0xc004d37, 0x34108000,
-0xc004d37, 0x0, 0xc004cf1, 0x0,
-0x50400005, 0x108042, 0x96220000, 0x501025,
-0xa6220000, 0x108042, 0x1600fff7, 0x0,
-0xc004d37, 0x0, 0x97a20010, 0x30428000,
-0x14400336, 0x24020003, 0x8004cea, 0x0,
-0x3c020001, 0x8c425720, 0x30420004, 0x10400056,
-0x24020001, 0x3c030001, 0x8c63779c, 0xa7a20010,
-0x3c020008, 0x621024, 0x1040000c, 0x3c020002,
-0x621024, 0x10400002, 0x24020101, 0xa7a20010,
-0x3c020001, 0x621024, 0x10400005, 0x3c020010,
-0x97a20010, 0x34420040, 0xa7a20010, 0x3c020010,
-0x621024, 0x1040000e, 0x3c020002, 0x621024,
-0x10400005, 0x3c020001, 0x97a20010, 0x34420080,
-0xa7a20010, 0x3c020001, 0x621024, 0x10400005,
-0x27b10010, 0x97a20010, 0x34420020, 0xa7a20010,
-0x27b10010, 0x8021, 0xc004d11, 0x24040001,
-0x26100001, 0x2e020020, 0x1440fffb, 0x0,
-0xc004d11, 0x2021, 0xc004d11, 0x24040001,
-0xc004d11, 0x2021, 0xc004d11, 0x24040001,
-0x24100010, 0x32020001, 0x10400002, 0x2021,
-0x24040001, 0xc004d11, 0x108042, 0x1600fffa,
-0x32020001, 0x24100010, 0x32020004, 0x10400002,
-0x2021, 0x24040001, 0xc004d11, 0x108042,
-0x1600fffa, 0x32020004, 0xc004d11, 0x24040001,
-0xc004d11, 0x2021, 0x34108000, 0x96220000,
-0x501024, 0x10400002, 0x2021, 0x24040001,
-0xc004d11, 0x108042, 0x1600fff8, 0x0,
-0xc004d37, 0x0, 0x24021200, 0xa7a20010,
-0x27b10010, 0x8021, 0xc004d11, 0x24040001,
-0x26100001, 0x2e020020, 0x1440fffb, 0x0,
-0xc004d11, 0x2021, 0xc004d11, 0x24040001,
-0xc004d11, 0x2021, 0xc004d11, 0x24040001,
-0x24100010, 0x32020001, 0x10400002, 0x2021,
-0x24040001, 0xc004d11, 0x108042, 0x1600fffa,
-0x32020001, 0x24100010, 0xc004d11, 0x2021,
-0x108042, 0x1600fffc, 0x0, 0xc004d11,
-0x24040001, 0xc004d11, 0x2021, 0x34108000,
-0x96220000, 0x501024, 0x10400002, 0x2021,
-0x24040001, 0xc004d11, 0x108042, 0x1600fff8,
-0x0, 0xc004d37, 0x0, 0x8f830054,
-0x8004cdc, 0x24020004, 0x8f830054, 0x3c020001,
-0x8c42571c, 0x2463ff9c, 0x431023, 0x2c420064,
-0x1440029e, 0x24020002, 0x3c030001, 0x8c635720,
-0x10620297, 0x2c620003, 0x14400296, 0x24020011,
-0x24020003, 0x10620005, 0x24020004, 0x10620291,
-0x2402000f, 0x8004cea, 0x24020011, 0x8004cea,
-0x24020005, 0x24020014, 0xa7a20010, 0x27b10010,
-0x8021, 0xc004d11, 0x24040001, 0x26100001,
-0x2e020020, 0x1440fffb, 0x0, 0xc004d11,
-0x2021, 0xc004d11, 0x24040001, 0xc004d11,
-0x2021, 0xc004d11, 0x24040001, 0x24100010,
-0x32020001, 0x10400002, 0x2021, 0x24040001,
-0xc004d11, 0x108042, 0x1600fffa, 0x32020001,
-0x24100010, 0x32020012, 0x10400002, 0x2021,
-0x24040001, 0xc004d11, 0x108042, 0x1600fffa,
-0x32020012, 0xc004d11, 0x24040001, 0xc004d11,
-0x2021, 0x34108000, 0x96220000, 0x501024,
-0x10400002, 0x2021, 0x24040001, 0xc004d11,
-0x108042, 0x1600fff8, 0x0, 0xc004d37,
-0x0, 0x8f830054, 0x8004cdc, 0x24020006,
-0x8f830054, 0x3c020001, 0x8c42571c, 0x2463ff9c,
-0x431023, 0x2c420064, 0x14400250, 0x24020007,
-0x8004cea, 0x0, 0x24020006, 0xa7a20010,
-0x27b10010, 0x8021, 0xc004d11, 0x24040001,
-0x26100001, 0x2e020020, 0x1440fffb, 0x0,
-0xc004d11, 0x2021, 0xc004d11, 0x24040001,
-0xc004d11, 0x2021, 0xc004d11, 0x24040001,
-0x24100010, 0x32020001, 0x10400002, 0x2021,
-0x24040001, 0xc004d11, 0x108042, 0x1600fffa,
-0x32020001, 0x24100010, 0x32020013, 0x10400002,
-0x2021, 0x24040001, 0xc004d11, 0x108042,
-0x1600fffa, 0x32020013, 0xc004d11, 0x24040001,
-0xc004d11, 0x2021, 0x34108000, 0x96220000,
-0x501024, 0x10400002, 0x2021, 0x24040001,
-0xc004d11, 0x108042, 0x1600fff8, 0x0,
-0xc004d37, 0x0, 0x8f830054, 0x8004cdc,
-0x24020008, 0x8f830054, 0x3c020001, 0x8c42571c,
-0x2463ff9c, 0x431023, 0x2c420064, 0x1440020f,
-0x24020009, 0x8004cea, 0x0, 0x27b10010,
-0xa7a00010, 0x8021, 0xc004d11, 0x24040001,
-0x26100001, 0x2e020020, 0x1440fffb, 0x0,
-0xc004d11, 0x2021, 0xc004d11, 0x24040001,
-0xc004d11, 0x24040001, 0xc004d11, 0x2021,
-0x24100010, 0x32020001, 0x10400002, 0x2021,
-0x24040001, 0xc004d11, 0x108042, 0x1600fffa,
-0x32020001, 0x24100010, 0x32020018, 0x10400002,
-0x2021, 0x24040001, 0xc004d11, 0x108042,
-0x1600fffa, 0x32020018, 0xc004d37, 0x34108000,
-0xc004d37, 0x0, 0xc004cf1, 0x0,
-0x50400005, 0x108042, 0x96220000, 0x501025,
-0xa6220000, 0x108042, 0x1600fff7, 0x0,
-0xc004d37, 0x8021, 0x97a20010, 0x27b10010,
-0x34420001, 0xa7a20010, 0xc004d11, 0x24040001,
-0x26100001, 0x2e020020, 0x1440fffb, 0x0,
-0xc004d11, 0x2021, 0xc004d11, 0x24040001,
-0xc004d11, 0x2021, 0xc004d11, 0x24040001,
-0x24100010, 0x32020001, 0x10400002, 0x2021,
-0x24040001, 0xc004d11, 0x108042, 0x1600fffa,
-0x32020001, 0x24100010, 0x32020018, 0x10400002,
-0x2021, 0x24040001, 0xc004d11, 0x108042,
-0x1600fffa, 0x32020018, 0xc004d11, 0x24040001,
-0xc004d11, 0x2021, 0x34108000, 0x96220000,
-0x501024, 0x10400002, 0x2021, 0x24040001,
-0xc004d11, 0x108042, 0x1600fff8, 0x0,
-0xc004d37, 0x0, 0x8f830054, 0x8004cdc,
-0x2402000a, 0x8f830054, 0x3c020001, 0x8c42571c,
-0x2463ff9c, 0x431023, 0x2c420064, 0x1440019b,
-0x2402000b, 0x8004cea, 0x0, 0x27b10010,
-0xa7a00010, 0x8021, 0xc004d11, 0x24040001,
-0x26100001, 0x2e020020, 0x1440fffb, 0x0,
-0xc004d11, 0x2021, 0xc004d11, 0x24040001,
-0xc004d11, 0x24040001, 0xc004d11, 0x2021,
-0x24100010, 0x32020001, 0x10400002, 0x2021,
-0x24040001, 0xc004d11, 0x108042, 0x1600fffa,
-0x32020001, 0x24100010, 0x32020017, 0x10400002,
-0x2021, 0x24040001, 0xc004d11, 0x108042,
-0x1600fffa, 0x32020017, 0xc004d37, 0x34108000,
-0xc004d37, 0x0, 0xc004cf1, 0x0,
-0x50400005, 0x108042, 0x96220000, 0x501025,
-0xa6220000, 0x108042, 0x1600fff7, 0x0,
-0xc004d37, 0x8021, 0x97a20010, 0x27b10010,
-0x34420700, 0xa7a20010, 0xc004d11, 0x24040001,
-0x26100001, 0x2e020020, 0x1440fffb, 0x0,
-0xc004d11, 0x2021, 0xc004d11, 0x24040001,
-0xc004d11, 0x2021, 0xc004d11, 0x24040001,
-0x24100010, 0x32020001, 0x10400002, 0x2021,
-0x24040001, 0xc004d11, 0x108042, 0x1600fffa,
-0x32020001, 0x24100010, 0x32020017, 0x10400002,
-0x2021, 0x24040001, 0xc004d11, 0x108042,
-0x1600fffa, 0x32020017, 0xc004d11, 0x24040001,
-0xc004d11, 0x2021, 0x34108000, 0x96220000,
-0x501024, 0x10400002, 0x2021, 0x24040001,
-0xc004d11, 0x108042, 0x1600fff8, 0x0,
-0xc004d37, 0x0, 0x8f830054, 0x8004cdc,
-0x2402000c, 0x8f830054, 0x3c020001, 0x8c42571c,
-0x2463ff9c, 0x431023, 0x2c420064, 0x14400127,
-0x24020012, 0x8004cea, 0x0, 0x27b10010,
-0xa7a00010, 0x8021, 0xc004d11, 0x24040001,
-0x26100001, 0x2e020020, 0x1440fffb, 0x0,
-0xc004d11, 0x2021, 0xc004d11, 0x24040001,
-0xc004d11, 0x24040001, 0xc004d11, 0x2021,
-0x24100010, 0x32020001, 0x10400002, 0x2021,
-0x24040001, 0xc004d11, 0x108042, 0x1600fffa,
-0x32020001, 0x24100010, 0x32020014, 0x10400002,
-0x2021, 0x24040001, 0xc004d11, 0x108042,
-0x1600fffa, 0x32020014, 0xc004d37, 0x34108000,
-0xc004d37, 0x0, 0xc004cf1, 0x0,
-0x50400005, 0x108042, 0x96220000, 0x501025,
-0xa6220000, 0x108042, 0x1600fff7, 0x0,
-0xc004d37, 0x8021, 0x97a20010, 0x27b10010,
-0x34420010, 0xa7a20010, 0xc004d11, 0x24040001,
-0x26100001, 0x2e020020, 0x1440fffb, 0x0,
-0xc004d11, 0x2021, 0xc004d11, 0x24040001,
-0xc004d11, 0x2021, 0xc004d11, 0x24040001,
-0x24100010, 0x32020001, 0x10400002, 0x2021,
-0x24040001, 0xc004d11, 0x108042, 0x1600fffa,
-0x32020001, 0x24100010, 0x32020014, 0x10400002,
-0x2021, 0x24040001, 0xc004d11, 0x108042,
-0x1600fffa, 0x32020014, 0xc004d11, 0x24040001,
-0xc004d11, 0x2021, 0x34108000, 0x96220000,
-0x501024, 0x10400002, 0x2021, 0x24040001,
-0xc004d11, 0x108042, 0x1600fff8, 0x0,
-0xc004d37, 0x0, 0x8f830054, 0x8004cdc,
-0x24020013, 0x8f830054, 0x3c020001, 0x8c42571c,
-0x2463ff9c, 0x431023, 0x2c420064, 0x144000b3,
-0x2402000d, 0x8004cea, 0x0, 0x27b10010,
-0xa7a00010, 0x8021, 0xc004d11, 0x24040001,
-0x26100001, 0x2e020020, 0x1440fffb, 0x0,
-0xc004d11, 0x2021, 0xc004d11, 0x24040001,
-0xc004d11, 0x24040001, 0xc004d11, 0x2021,
-0x24100010, 0x32020001, 0x10400002, 0x2021,
-0x24040001, 0xc004d11, 0x108042, 0x1600fffa,
-0x32020001, 0x24100010, 0x32020018, 0x10400002,
-0x2021, 0x24040001, 0xc004d11, 0x108042,
-0x1600fffa, 0x32020018, 0xc004d37, 0x34108000,
-0xc004d37, 0x0, 0xc004cf1, 0x0,
-0x50400005, 0x108042, 0x96220000, 0x501025,
-0xa6220000, 0x108042, 0x1600fff7, 0x0,
-0xc004d37, 0x8021, 0x97a20010, 0x27b10010,
-0x3042fffe, 0xa7a20010, 0xc004d11, 0x24040001,
-0x26100001, 0x2e020020, 0x1440fffb, 0x0,
-0xc004d11, 0x2021, 0xc004d11, 0x24040001,
-0xc004d11, 0x2021, 0xc004d11, 0x24040001,
-0x24100010, 0x32020001, 0x10400002, 0x2021,
-0x24040001, 0xc004d11, 0x108042, 0x1600fffa,
-0x32020001, 0x24100010, 0x32020018, 0x10400002,
-0x2021, 0x24040001, 0xc004d11, 0x108042,
-0x1600fffa, 0x32020018, 0xc004d11, 0x24040001,
-0xc004d11, 0x2021, 0x34108000, 0x96220000,
-0x501024, 0x10400002, 0x2021, 0x24040001,
-0xc004d11, 0x108042, 0x1600fff8, 0x0,
-0xc004d37, 0x0, 0x8f830054, 0x8004cdc,
-0x2402000e, 0x24020840, 0xa7a20010, 0x27b10010,
-0x8021, 0xc004d11, 0x24040001, 0x26100001,
-0x2e020020, 0x1440fffb, 0x0, 0xc004d11,
-0x2021, 0xc004d11, 0x24040001, 0xc004d11,
-0x2021, 0xc004d11, 0x24040001, 0x24100010,
-0x32020001, 0x10400002, 0x2021, 0x24040001,
-0xc004d11, 0x108042, 0x1600fffa, 0x32020001,
-0x24100010, 0x32020013, 0x10400002, 0x2021,
-0x24040001, 0xc004d11, 0x108042, 0x1600fffa,
-0x32020013, 0xc004d11, 0x24040001, 0xc004d11,
-0x2021, 0x34108000, 0x96220000, 0x501024,
-0x10400002, 0x2021, 0x24040001, 0xc004d11,
-0x108042, 0x1600fff8, 0x0, 0xc004d37,
-0x0, 0x8f830054, 0x24020010, 0x3c010001,
-0xac225680, 0x3c010001, 0x8004cec, 0xac23571c,
-0x8f830054, 0x3c020001, 0x8c42571c, 0x2463ff9c,
-0x431023, 0x2c420064, 0x14400004, 0x0,
-0x24020011, 0x3c010001, 0xac225680, 0x8fbf0020,
-0x8fb1001c, 0x8fb00018, 0x3e00008, 0x27bd0028,
-0x8f850044, 0x8f820044, 0x3c030001, 0x431025,
-0x3c030008, 0xaf820044, 0x8f840054, 0x8f820054,
-0xa32824, 0x8004cfd, 0x24840001, 0x8f820054,
-0x821023, 0x2c420002, 0x1440fffc, 0x0,
-0x8f820044, 0x3c03fffe, 0x3463ffff, 0x431024,
-0xaf820044, 0x8f830054, 0x8f820054, 0x8004d0b,
-0x24630001, 0x8f820054, 0x621023, 0x2c420002,
-0x1440fffc, 0x0, 0x3e00008, 0xa01021,
-0x8f830044, 0x3c02fff0, 0x3442ffff, 0x42480,
-0x621824, 0x3c020002, 0x822025, 0x641825,
-0xaf830044, 0x8f820044, 0x3c030001, 0x431025,
-0xaf820044, 0x8f830054, 0x8f820054, 0x8004d23,
-0x24630001, 0x8f820054, 0x621023, 0x2c420002,
-0x1440fffc, 0x0, 0x8f820044, 0x3c03fffe,
-0x3463ffff, 0x431024, 0xaf820044, 0x8f830054,
-0x8f820054, 0x8004d31, 0x24630001, 0x8f820054,
-0x621023, 0x2c420002, 0x1440fffc, 0x0,
-0x3e00008, 0x0, 0x8f820044, 0x3c03fff0,
-0x3463ffff, 0x431024, 0xaf820044, 0x8f820044,
-0x3c030001, 0x431025, 0xaf820044, 0x8f830054,
-0x8f820054, 0x8004d45, 0x24630001, 0x8f820054,
-0x621023, 0x2c420002, 0x1440fffc, 0x0,
-0x8f820044, 0x3c03fffe, 0x3463ffff, 0x431024,
-0xaf820044, 0x8f830054, 0x8f820054, 0x8004d53,
-0x24630001, 0x8f820054, 0x621023, 0x2c420002,
-0x1440fffc, 0x0, 0x3e00008, 0x0,
-0x0, 0x0, 0x0, 0x27bdffe8,
-0xafbf0010, 0x3c030001, 0x771821, 0x8c6383ac,
-0x24020008, 0x1462022c, 0x803021, 0x3c020001,
-0x8c425708, 0x14400033, 0x0, 0x8f850224,
-0x38a30020, 0x2c630001, 0x38a20010, 0x2c420001,
-0x621825, 0x1460000d, 0x38a30030, 0x2c630001,
-0x38a20400, 0x2c420001, 0x621825, 0x14600007,
-0x38a30402, 0x2c630001, 0x38a20404, 0x2c420001,
-0x621825, 0x10600005, 0x0, 0xc00429b,
-0x0, 0x8004d95, 0x2402000e, 0xc0043dd,
-0x0, 0x3c050001, 0x8ca55648, 0xc00511d,
-0x2021, 0x3c030001, 0x8c635648, 0x24020004,
-0x14620005, 0x2403fffb, 0x3c020001, 0x8c425644,
-0x8004d91, 0x2403fff7, 0x3c020001, 0x8c425644,
-0x431024, 0x3c010001, 0xac225644, 0x2402000e,
-0x3c010001, 0xc00429b, 0xac227730, 0x8004f8f,
-0x0, 0x8f820220, 0x3c030400, 0x431024,
-0x10400027, 0x2403ffbf, 0x8f850224, 0x3c020001,
-0x8c42773c, 0xa32024, 0x431024, 0x1482000c,
-0x0, 0x3c020001, 0x8c427740, 0x24420001,
-0x3c010001, 0xac227740, 0x2c420002, 0x14400008,
-0x24020001, 0x3c010001, 0x8004db5, 0xac227760,
-0x3c010001, 0xac207740, 0x3c010001, 0xac207760,
-0x3c020001, 0x8c427760, 0x10400006, 0x30a20040,
-0x10400004, 0x24020001, 0x3c010001, 0x8004dc0,
-0xac227764, 0x3c010001, 0xac207764, 0x3c010001,
-0xac25773c, 0x3c010001, 0x8004dd0, 0xac207770,
-0x24020001, 0x3c010001, 0xac227770, 0x3c010001,
-0xac207760, 0x3c010001, 0xac207740, 0x3c010001,
-0xac207764, 0x3c010001, 0xac20773c, 0x3c030001,
-0x8c637730, 0x3c020001, 0x8c427734, 0x10620003,
-0x3c020200, 0x3c010001, 0xac237734, 0xc21024,
-0x10400007, 0x2463ffff, 0x8f820220, 0x24030001,
-0x3c010001, 0xac23564c, 0x8004f8d, 0x3c03f700,
-0x2c62000e, 0x104001a8, 0x31080, 0x3c010001,
-0x220821, 0x8c225510, 0x400008, 0x0,
-0x3c010001, 0xac207760, 0x3c010001, 0xac207740,
-0x3c010001, 0xac20773c, 0x3c010001, 0xac207764,
-0x3c010001, 0xac207758, 0x3c010001, 0xac207750,
-0xc0047d9, 0xaf800224, 0x24020002, 0x3c010001,
-0xac227730, 0x3c020001, 0x8c427770, 0x14400056,
-0x3c03fdff, 0x8ee20000, 0x3463ffff, 0x431024,
-0xc00429b, 0xaee20000, 0xaf800204, 0x8f820200,
-0x2403fffd, 0x431024, 0xaf820200, 0x3c010001,
-0xac207780, 0x8f830054, 0x3c020001, 0x8c427758,
-0x24040001, 0x3c010001, 0xac24776c, 0x24420001,
-0x3c010001, 0xac227758, 0x2c420004, 0x3c010001,
-0xac237754, 0x14400006, 0x24020003, 0x3c010001,
-0xac24564c, 0x3c010001, 0x8004f8b, 0xac207758,
-0x3c010001, 0x8004f8b, 0xac227730, 0x8f830054,
-0x3c020001, 0x8c427754, 0x2463d8f0, 0x431023,
-0x2c422710, 0x14400003, 0x24020004, 0x3c010001,
-0xac227730, 0x3c020001, 0x8c427770, 0x14400026,
-0x3c03fdff, 0x8ee20000, 0x3463ffff, 0x431024,
-0x8004f8b, 0xaee20000, 0x3c040001, 0x8c84570c,
-0x3c010001, 0xc004f92, 0xac207748, 0x3c020001,
-0x8c42777c, 0xaf820204, 0x3c020001, 0x8c427770,
-0x14400015, 0x3c03fdff, 0x8ee20000, 0x3463ffff,
-0x431024, 0xaee20000, 0x8f820204, 0x30420030,
-0x1440013c, 0x24020002, 0x3c030001, 0x8c63777c,
-0x24020005, 0x3c010001, 0xac227730, 0x3c010001,
-0x8004f8b, 0xac237780, 0x3c020001, 0x8c427770,
-0x10400010, 0x3c03fdff, 0x3c020001, 0x8c4256dc,
-0x24420001, 0x3c010001, 0xac2256dc, 0x2c420002,
-0x14400131, 0x24020001, 0x3c010001, 0xac2256e4,
-0x3c010001, 0xac2056dc, 0x3c010001, 0x8004f8b,
-0xac22564c, 0x8ee20000, 0x3463ffff, 0x431024,
-0xaee20000, 0x3c020001, 0x8c427760, 0x10400122,
-0x0, 0x3c020001, 0x8c42773c, 0x1040011e,
-0x0, 0x3c010001, 0xac227768, 0x24020003,
-0x3c010001, 0xac227740, 0x8004f2c, 0x24020006,
-0x3c010001, 0xac207748, 0x8f820204, 0x34420040,
-0xaf820204, 0x3c020001, 0x8c427780, 0x24030007,
-0x3c010001, 0xac237730, 0x34420040, 0x3c010001,
-0xac227780, 0x3c020001, 0x8c427760, 0x10400005,
-0x0, 0x3c020001, 0x8c42773c, 0x104000f9,
-0x24020002, 0x3c050001, 0x24a57740, 0x8ca20000,
-0x2c424e21, 0x104000f3, 0x24020002, 0x3c020001,
-0x8c427764, 0x104000f8, 0x2404ffbf, 0x3c020001,
-0x8c42773c, 0x3c030001, 0x8c637768, 0x441024,
-0x641824, 0x10430004, 0x24020001, 0x3c010001,
-0x8004f8b, 0xac227730, 0x24020003, 0xaca20000,
-0x24020008, 0x3c010001, 0xac227730, 0x3c020001,
-0x8c42776c, 0x1040000c, 0x24020001, 0x3c040001,
-0xc004f9f, 0x8c84773c, 0x3c020001, 0x8c427788,
-0x14400005, 0x24020001, 0x3c020001, 0x8c427784,
-0x10400006, 0x24020001, 0x3c010001, 0xac22564c,
-0x3c010001, 0x8004f8b, 0xac207758, 0x3c020001,
-0x8c427750, 0x3c030001, 0x8c63773c, 0x2c420001,
-0x210c0, 0x30630008, 0x3c010001, 0xac227750,
-0x3c010001, 0xac23774c, 0x8f830054, 0x24020009,
-0x3c010001, 0xac227730, 0x3c010001, 0x8004f8b,
-0xac237754, 0x8f830054, 0x3c020001, 0x8c427754,
-0x2463d8f0, 0x431023, 0x2c422710, 0x144000a8,
-0x0, 0x3c020001, 0x8c427760, 0x10400005,
-0x0, 0x3c020001, 0x8c42773c, 0x104000a9,
-0x24020002, 0x3c030001, 0x24637740, 0x8c620000,
-0x2c424e21, 0x104000a3, 0x24020002, 0x3c020001,
-0x8c42776c, 0x1040000e, 0x0, 0x3c020001,
-0x8c42773c, 0x3c010001, 0xac20776c, 0x30420080,
-0x1040002f, 0x2402000c, 0x8f820204, 0x30420080,
-0x1440000c, 0x24020003, 0x8004f19, 0x2402000c,
-0x3c020001, 0x8c42773c, 0x30420080, 0x14400005,
-0x24020003, 0x8f820204, 0x30420080, 0x1040001f,
-0x24020003, 0xac620000, 0x2402000a, 0x3c010001,
-0xac227730, 0x3c040001, 0x24847778, 0x8c820000,
-0x3c030001, 0x8c637750, 0x431025, 0xaf820204,
-0x8c830000, 0x3c040001, 0x8c847750, 0x2402000b,
-0x3c010001, 0xac227730, 0x641825, 0x3c010001,
-0xac237780, 0x3c050001, 0x24a57740, 0x8ca20000,
-0x2c424e21, 0x1040006f, 0x24020002, 0x3c020001,
-0x8c427770, 0x10400005, 0x0, 0x2402000c,
-0x3c010001, 0x8004f8b, 0xac227730, 0x3c020001,
-0x8c427760, 0x1040006c, 0x0, 0x3c040001,
-0x8c84773c, 0x1080005e, 0x30820008, 0x3c030001,
-0x8c63774c, 0x10620064, 0x24020003, 0x3c010001,
-0xac247768, 0xaca20000, 0x24020006, 0x3c010001,
-0x8004f8b, 0xac227730, 0x8f820200, 0x34420002,
-0xaf820200, 0x8f830054, 0x2402000d, 0x3c010001,
-0xac227730, 0x3c010001, 0xac237754, 0x8f830054,
-0x3c020001, 0x8c427754, 0x2463d8f0, 0x431023,
-0x2c422710, 0x1440003a, 0x0, 0x3c020001,
-0x8c427770, 0x10400029, 0x2402000e, 0x3c030001,
-0x8c637784, 0x3c010001, 0x14600015, 0xac227730,
-0xc0043dd, 0x0, 0x3c050001, 0x8ca55648,
-0xc00511d, 0x2021, 0x3c030001, 0x8c635648,
-0x24020004, 0x14620005, 0x2403fffb, 0x3c020001,
-0x8c425644, 0x8004f5a, 0x2403fff7, 0x3c020001,
-0x8c425644, 0x431024, 0x3c010001, 0xac225644,
-0x8ee20000, 0x3c030200, 0x431025, 0xaee20000,
-0x8f820224, 0x3c010001, 0xac22778c, 0x8f820220,
-0x2403fffb, 0x431024, 0xaf820220, 0x8f820220,
-0x34420002, 0x8004f8b, 0xaf820220, 0x3c020001,
-0x8c427760, 0x10400005, 0x0, 0x3c020001,
-0x8c42773c, 0x1040000f, 0x24020002, 0x3c020001,
-0x8c427740, 0x2c424e21, 0x1040000a, 0x24020002,
-0x3c020001, 0x8c427760, 0x1040000f, 0x0,
-0x3c020001, 0x8c42773c, 0x1440000b, 0x0,
-0x24020002, 0x3c010001, 0x8004f8b, 0xac227730,
-0x3c020001, 0x8c427760, 0x10400003, 0x0,
-0xc00429b, 0x0, 0x8f820220, 0x3c03f700,
-0x431025, 0xaf820220, 0x8fbf0010, 0x3e00008,
-0x27bd0018, 0x3c030001, 0x24637788, 0x8c620000,
-0x10400005, 0x34422000, 0x3c010001, 0xac22777c,
-0x8004f9d, 0xac600000, 0x3c010001, 0xac24777c,
-0x3e00008, 0x0, 0x27bdffe0, 0x30820030,
-0xafbf0018, 0x3c010001, 0xac227784, 0x14400067,
-0x3c02ffff, 0x34421f0e, 0x821024, 0x14400061,
-0x24020030, 0x30822000, 0x1040005d, 0x30838000,
-0x31a02, 0x30820001, 0x21200, 0x3c040001,
-0x8c84570c, 0x621825, 0x331c2, 0x3c030001,
-0x246356e8, 0x30828000, 0x21202, 0x30840001,
-0x42200, 0x441025, 0x239c2, 0x61080,
-0x431021, 0x471021, 0x90430000, 0x24020001,
-0x10620025, 0x0, 0x10600007, 0x24020002,
-0x10620013, 0x24020003, 0x1062002c, 0x3c05000f,
-0x8005001, 0x0, 0x8f820200, 0x2403feff,
-0x431024, 0xaf820200, 0x8f820220, 0x3c03fffe,
-0x3463ffff, 0x431024, 0xaf820220, 0x3c010001,
-0xac2077a4, 0x3c010001, 0x800500c, 0xac2077ac,
-0x8f820200, 0x34420100, 0xaf820200, 0x8f820220,
-0x3c03fffe, 0x3463ffff, 0x431024, 0xaf820220,
-0x24020100, 0x3c010001, 0xac2277a4, 0x3c010001,
-0x800500c, 0xac2077ac, 0x8f820200, 0x2403feff,
-0x431024, 0xaf820200, 0x8f820220, 0x3c030001,
-0x431025, 0xaf820220, 0x3c010001, 0xac2077a4,
-0x3c010001, 0x800500c, 0xac2377ac, 0x8f820200,
-0x34420100, 0xaf820200, 0x8f820220, 0x3c030001,
-0x431025, 0xaf820220, 0x24020100, 0x3c010001,
-0xac2277a4, 0x3c010001, 0x800500c, 0xac2377ac,
-0x34a5ffff, 0x3c040001, 0x24845548, 0xafa30010,
-0xc002403, 0xafa00014, 0x800500c, 0x0,
-0x24020030, 0x3c010001, 0xac227788, 0x8fbf0018,
-0x3e00008, 0x27bd0020, 0x0, 0x27bdffc8,
-0xafb10024, 0x808821, 0xafb3002c, 0xa09821,
-0xafb00020, 0xc08021, 0x3c040001, 0x24845560,
-0x3c050009, 0x3c020001, 0x8c425648, 0x34a59001,
-0x2203021, 0x2603821, 0xafbf0030, 0xafb20028,
-0xa7a0001a, 0xafb00014, 0xc002403, 0xafa20010,
-0x24020002, 0x126200ef, 0x2e620003, 0x10400005,
-0x24020001, 0x1262000a, 0x3c02fffb, 0x8005116,
-0x0, 0x24020004, 0x1262006d, 0x24020008,
-0x1262006c, 0x3c02ffec, 0x8005116, 0x0,
-0x3442ffff, 0x2028024, 0x119140, 0x3c010001,
-0x320821, 0xac30779c, 0x3c024000, 0x2021024,
-0x10400046, 0x1023c2, 0x30840030, 0x101382,
-0x3042000c, 0x3c030001, 0x24635684, 0x431021,
-0x823821, 0x3c020020, 0x2021024, 0x10400006,
-0x24020100, 0x3c010001, 0x320821, 0xac2277a0,
-0x8005053, 0x3c020080, 0x3c010001, 0x320821,
-0xac2077a0, 0x3c020080, 0x2021024, 0x10400006,
-0x111940, 0x3c020001, 0x3c010001, 0x230821,
-0x800505f, 0xac2277a8, 0x111140, 0x3c010001,
-0x220821, 0xac2077a8, 0x94e30000, 0x32024000,
-0x10400003, 0xa7a30018, 0x34624000, 0xa7a20018,
-0x24040001, 0x94e20002, 0x24050004, 0x24e60002,
-0x34420001, 0xc0048fa, 0xa4e20002, 0x24040001,
-0x2821, 0xc0048fa, 0x27a60018, 0x3c020001,
-0x8c425648, 0x24110001, 0x3c010001, 0xac315654,
-0x14530004, 0x32028000, 0xc00429b, 0x0,
-0x32028000, 0x1040009b, 0x0, 0xc00429b,
-0x0, 0x24020002, 0x3c010001, 0xac31564c,
-0x3c010001, 0x8005116, 0xac225648, 0x24040001,
-0x24050004, 0x27b0001a, 0xc0048fa, 0x2003021,
-0x24040001, 0x2821, 0xc0048fa, 0x2003021,
-0x3c020001, 0x521021, 0x8c427794, 0x3c040001,
-0x8c845648, 0x3c03bfff, 0x3463ffff, 0x3c010001,
-0xac335654, 0x431024, 0x3c010001, 0x320821,
-0x1093007a, 0xac227794, 0x8005116, 0x0,
-0x3c02ffec, 0x3442ffff, 0x2028024, 0x3c020008,
-0x2028025, 0x111140, 0x3c010001, 0x220821,
-0xac307798, 0x3c022000, 0x2021024, 0x10400009,
-0x0, 0x3c020001, 0x8c4256e4, 0x14400005,
-0x24020001, 0x3c010001, 0xac225708, 0x80050b5,
-0x3c024000, 0x3c010001, 0xac205708, 0x3c024000,
-0x2021024, 0x1440001e, 0x0, 0x3c020001,
-0x8c425708, 0x3c010001, 0xac205660, 0x10400007,
-0x24022020, 0x3c010001, 0xac22570c, 0x24020001,
-0x3c010001, 0x370821, 0xac2283ac, 0x3c04bfff,
-0x111940, 0x3c020001, 0x431021, 0x8c427790,
-0x3c050001, 0x8ca55648, 0x3484ffff, 0x441024,
-0x3c010001, 0x230821, 0xac227790, 0x24020001,
-0x10a20044, 0x0, 0x8005114, 0x0,
-0x3c020001, 0x8c425708, 0x1040001c, 0x24022000,
-0x3c010001, 0xac22570c, 0x3c0300a0, 0x2031024,
-0x14430005, 0x111140, 0x3402a000, 0x3c010001,
-0x800510f, 0xac22570c, 0x3c030001, 0x621821,
-0x8c637798, 0x3c020020, 0x621024, 0x10400004,
-0x24022001, 0x3c010001, 0x800510f, 0xac22570c,
-0x3c020080, 0x621024, 0x1040001f, 0x3402a001,
-0x3c010001, 0x800510f, 0xac22570c, 0x3c020020,
-0x2021024, 0x10400007, 0x111940, 0x24020100,
-0x3c010001, 0x230821, 0xac2277a4, 0x8005103,
-0x3c020080, 0x111140, 0x3c010001, 0x220821,
-0xac2077a4, 0x3c020080, 0x2021024, 0x10400006,
-0x111940, 0x3c020001, 0x3c010001, 0x230821,
-0x800510f, 0xac2277ac, 0x111140, 0x3c010001,
-0x220821, 0xac2077ac, 0x3c030001, 0x8c635648,
-0x24020001, 0x10620003, 0x0, 0xc00429b,
-0x0, 0x8fbf0030, 0x8fb3002c, 0x8fb20028,
-0x8fb10024, 0x8fb00020, 0x3e00008, 0x27bd0038,
-0x27bdffd0, 0xafb40028, 0x80a021, 0xafb20020,
-0x9021, 0xafb30024, 0x9821, 0xafb1001c,
-0x8821, 0x24020002, 0xafbf002c, 0xafb00018,
-0xa7a00012, 0x10a20068, 0xa7a00010, 0x2ca20003,
-0x10400005, 0x24020001, 0x10a2000a, 0x148140,
-0x80051e0, 0x2201021, 0x24020004, 0x10a2005e,
-0x24020008, 0x10a2005d, 0x142940, 0x80051e0,
-0x2201021, 0x3c030001, 0x701821, 0x8c63779c,
-0x3c024000, 0x621024, 0x14400009, 0x24040001,
-0x3c027fff, 0x3442ffff, 0x628824, 0x3c010001,
-0x300821, 0xac317794, 0x80051e0, 0x2201021,
-0x24050001, 0xc0048b8, 0x27a60010, 0x24040001,
-0x24050001, 0xc0048b8, 0x27a60010, 0x97a20010,
-0x30420004, 0x10400034, 0x3c114000, 0x3c030001,
-0x8c635720, 0x24020003, 0x10620008, 0x2c620004,
-0x14400029, 0x3c028000, 0x24020004, 0x10620014,
-0x24040001, 0x8005183, 0x3c028000, 0x24040001,
-0x24050011, 0x27b00012, 0xc0048b8, 0x2003021,
-0x24040001, 0x24050011, 0xc0048b8, 0x2003021,
-0x97a30012, 0x30624000, 0x10400002, 0x3c130010,
-0x3c130008, 0x3c120001, 0x8005180, 0x30628000,
-0x24050014, 0x27b00012, 0xc0048b8, 0x2003021,
-0x24040001, 0x24050014, 0xc0048b8, 0x2003021,
-0x97a30012, 0x30621000, 0x10400002, 0x3c130010,
-0x3c130008, 0x3c120001, 0x30620800, 0x54400001,
-0x3c120002, 0x3c028000, 0x2221025, 0x2531825,
-0x800518d, 0x438825, 0x3c110001, 0x2308821,
-0x8e31779c, 0x3c027fff, 0x3442ffff, 0x2228824,
-0x141140, 0x3c010001, 0x220821, 0xac317794,
-0x80051e0, 0x2201021, 0x142940, 0x3c030001,
-0x651821, 0x8c637798, 0x3c024000, 0x621024,
-0x14400008, 0x3c027fff, 0x3442ffff, 0x628824,
-0x3c010001, 0x250821, 0xac317790, 0x80051e0,
-0x2201021, 0x3c020001, 0x8c425658, 0x10400033,
-0x3c11c00c, 0x3c020001, 0x8c4256e4, 0x3c04c00c,
-0x34842000, 0x3c030001, 0x8c635708, 0x2102b,
-0x21023, 0x441024, 0x10600003, 0x518825,
-0x3c022000, 0x2228825, 0x3c020001, 0x451021,
-0x8c4277a4, 0x10400003, 0x3c020020, 0x80051bd,
-0x2228825, 0x3c02ffdf, 0x3442ffff, 0x2228824,
-0x141140, 0x3c010001, 0x220821, 0x8c2277ac,
-0x10400003, 0x3c020080, 0x80051c8, 0x2228825,
-0x3c02ff7f, 0x3442ffff, 0x2228824, 0x3c020001,
-0x8c4256d0, 0x10400002, 0x3c020800, 0x2228825,
-0x3c020001, 0x8c4256d4, 0x10400002, 0x3c020400,
-0x2228825, 0x3c020001, 0x8c4256d8, 0x10400006,
-0x3c020100, 0x80051db, 0x2228825, 0x3c027fff,
-0x3442ffff, 0x628824, 0x141140, 0x3c010001,
-0x220821, 0xac317790, 0x2201021, 0x8fbf002c,
-0x8fb40028, 0x8fb30024, 0x8fb20020, 0x8fb1001c,
-0x8fb00018, 0x3e00008, 0x27bd0030, 0x27bdffd8,
-0xafb40020, 0x80a021, 0xafbf0024, 0xafb3001c,
-0xafb20018, 0xafb10014, 0xafb00010, 0x8f900200,
-0x3c030001, 0x8c635648, 0x8f930220, 0x24020002,
-0x106200b4, 0x2c620003, 0x10400005, 0x24020001,
-0x1062000a, 0x141940, 0x80052aa, 0x0,
-0x24020004, 0x1062005a, 0x24020008, 0x10620059,
-0x149140, 0x80052aa, 0x0, 0x3c040001,
-0x832021, 0x8c84779c, 0x3c110001, 0x2238821,
-0x8e317794, 0x3c024000, 0x821024, 0x1040003e,
-0x3c020008, 0x2221024, 0x10400020, 0x36100002,
-0x3c020001, 0x431021, 0x8c4277a0, 0x10400005,
-0x36100020, 0x36100100, 0x3c020020, 0x800521f,
-0x2228825, 0x2402feff, 0x2028024, 0x3c02ffdf,
-0x3442ffff, 0x2228824, 0x141140, 0x3c010001,
-0x220821, 0x8c2277a8, 0x10400005, 0x3c020001,
-0x2629825, 0x3c020080, 0x800523e, 0x2228825,
-0x3c02fffe, 0x3442ffff, 0x2629824, 0x3c02ff7f,
-0x3442ffff, 0x800523e, 0x2228824, 0x2402fedf,
-0x2028024, 0x3c02fffe, 0x3442ffff, 0x2629824,
-0x3c02ff5f, 0x3442ffff, 0x2228824, 0x3c010001,
-0x230821, 0xac2077a0, 0x3c010001, 0x230821,
-0xac2077a8, 0xc0047d9, 0x0, 0xaf900200,
-0xaf930220, 0x8f820220, 0x2403fffb, 0x431024,
-0xaf820220, 0x8f820220, 0x34420002, 0xaf820220,
-0x8005255, 0x141140, 0x8f820200, 0x2403fffd,
-0x431024, 0xc0047d9, 0xaf820200, 0x3c02bfff,
-0x3442ffff, 0xc00429b, 0x2228824, 0x141140,
-0x3c010001, 0x220821, 0x80052aa, 0xac317794,
-0x149140, 0x3c040001, 0x922021, 0x8c847798,
-0x3c110001, 0x2328821, 0x8e317790, 0x3c024000,
-0x821024, 0x14400011, 0x0, 0x3c020001,
-0x8c425708, 0x14400006, 0x3c02bfff, 0x8f820200,
-0x34420002, 0xc0047d9, 0xaf820200, 0x3c02bfff,
-0x3442ffff, 0xc00429b, 0x2228824, 0x3c010001,
-0x320821, 0x80052aa, 0xac317790, 0x3c020001,
-0x8c425708, 0x10400005, 0x3c020020, 0x3c020001,
-0x8c4256e4, 0x1040002b, 0x3c020020, 0x821024,
-0x10400007, 0x36100020, 0x24020100, 0x3c010001,
-0x320821, 0xac2277a4, 0x800528a, 0x36100100,
-0x3c010001, 0x320821, 0xac2077a4, 0x2402feff,
-0x2028024, 0x3c020080, 0x821024, 0x10400007,
-0x141940, 0x3c020001, 0x3c010001, 0x230821,
-0xac2277ac, 0x800529b, 0x2629825, 0x141140,
-0x3c010001, 0x220821, 0xac2077ac, 0x3c02fffe,
-0x3442ffff, 0x2629824, 0xc0047d9, 0x0,
-0xaf900200, 0xaf930220, 0x8f820220, 0x2403fffb,
-0x431024, 0xaf820220, 0x8f820220, 0x34420002,
-0xaf820220, 0x141140, 0x3c010001, 0x220821,
-0xac317790, 0x8fbf0024, 0x8fb40020, 0x8fb3001c,
-0x8fb20018, 0x8fb10014, 0x8fb00010, 0x3e00008,
-0x27bd0028, 0x0, 0x0, 0x0 };
-static u_int32_t tigonFwRodata[] = {
-0x24486561, 0x6465723a, 0x202f7072,
-0x6f6a6563, 0x74732f72, 0x63732f73, 0x772f6765,
-0x2f2e2f6e, 0x69632f66, 0x772f636f, 0x6d6d6f6e,
-0x2f66776d, 0x61696e2e, 0x632c7620, 0x312e312e,
-0x322e3131, 0x20313939, 0x382f3034, 0x2f323720,
-0x32323a31, 0x333a3432, 0x20736875, 0x616e6720,
-0x45787020, 0x24000000, 0x7468655f, 0x4441574e,
-0x0, 0x53544143, 0x4b5f3120, 0x0,
-0x42616453, 0x6e64526e, 0x67000000, 0x3f456e71,
-0x45767400, 0x3f6e6f51, 0x64457650, 0x0,
-0x6576526e, 0x6746756c, 0x6c000000, 0x496c6c43,
-0x6f6e6652, 0x78000000, 0x53656e64, 0x436b5375,
-0x6d000000, 0x52656376, 0x566c616e, 0x0,
-0x0, 0x24486561, 0x6465723a, 0x202f7072,
-0x6f6a6563, 0x74732f72, 0x63732f73, 0x772f6765,
-0x2f2e2f6e, 0x69632f66, 0x772f636f, 0x6d6d6f6e,
-0x2f74696d, 0x65722e63, 0x2c762031, 0x2e312e32,
-0x2e382031, 0x3939382f, 0x30372f33, 0x31203137,
-0x3a35383a, 0x34352073, 0x6875616e, 0x67204578,
-0x70202400, 0x542d446d, 0x61526431, 0x0,
-0x542d446d, 0x61424200, 0x542d446d, 0x61320000,
-0x3f6e6f51, 0x64547845, 0x0, 0x3f6e6f51,
-0x64527845, 0x0, 0x656e714d, 0x45765046,
-0x61696c00, 0x656e714d, 0x45764661, 0x696c0000,
-0x6661696c, 0x456e454d, 0x0, 0x3f456e71,
-0x45767400, 0x3f6e6f51, 0x64457650, 0x0,
-0x6576526e, 0x6746756c, 0x6c000000, 0x0,
-0x0, 0x24486561, 0x6465723a, 0x202f7072,
-0x6f6a6563, 0x74732f72, 0x63732f73, 0x772f6765,
-0x2f2e2f6e, 0x69632f66, 0x772f636f, 0x6d6d6f6e,
-0x2f636f6d, 0x6d616e64, 0x2e632c76, 0x20312e31,
-0x2e322e31, 0x30203139, 0x39382f31, 0x312f3138,
-0x2031373a, 0x31313a31, 0x38207368, 0x75616e67,
-0x20457870, 0x20240000, 0x3f4d626f, 0x78457674,
-0x0, 0x4e4f636f, 0x6d616e64, 0x0,
-0x68737465, 0x5f455252, 0x0, 0x412d4572,
-0x72427563, 0x0, 0x4552524f, 0x522d4164,
-0x64000000, 0x656e714d, 0x45765046, 0x61696c00,
-0x656e714d, 0x45764661, 0x696c0000, 0x6661696c,
-0x456e454d, 0x0, 0x442d4572, 0x724c6173,
-0x74000000, 0x442d4572, 0x72320000, 0x6d437374,
-0x4d644552, 0x52000000, 0x70726f6d, 0x4d644552,
-0x52000000, 0x46696c74, 0x4d644552, 0x52000000,
-0x636d645f, 0x45525200, 0x3f456e71, 0x45767400,
-0x3f6e6f51, 0x64457650, 0x0, 0x6576526e,
-0x6746756c, 0x6c000000, 0x0, 0x6ea0,
-0x7fbc, 0x6e38, 0x8734, 0x82b0,
-0x8780, 0x8780, 0x6f54, 0x7694,
-0x7f0c, 0x80a8, 0x8074, 0x8780,
-0x7e70, 0x80cc, 0x6e64, 0x81cc,
-0x0, 0x24486561, 0x6465723a, 0x202f7072,
-0x6f6a6563, 0x74732f72, 0x63732f73, 0x772f6765,
-0x2f2e2f6e, 0x69632f66, 0x772f636f, 0x6d6d6f6e,
-0x2f646d61, 0x2e632c76, 0x20312e31, 0x2e322e33,
-0x20313939, 0x382f3034, 0x2f323720, 0x32323a31,
-0x333a3431, 0x20736875, 0x616e6720, 0x45787020,
-0x24000000, 0x646d6172, 0x6441544e, 0x0,
-0x646d6177, 0x7241544e, 0x0, 0x0,
-0x0, 0x24486561, 0x6465723a, 0x202f7072,
-0x6f6a6563, 0x74732f72, 0x63732f73, 0x772f6765,
-0x2f2e2f6e, 0x69632f66, 0x772f636f, 0x6d6d6f6e,
-0x2f747261, 0x63652e63, 0x2c762031, 0x2e312e32,
-0x2e322031, 0x3939382f, 0x30342f32, 0x37203232,
-0x3a31333a, 0x35302073, 0x6875616e, 0x67204578,
-0x70202400, 0x24486561, 0x6465723a, 0x202f7072,
-0x6f6a6563, 0x74732f72, 0x63732f73, 0x772f6765,
-0x2f2e2f6e, 0x69632f66, 0x772f636f, 0x6d6d6f6e,
-0x2f646174, 0x612e632c, 0x7620312e, 0x312e322e,
-0x32203139, 0x39382f30, 0x342f3237, 0x2032323a,
-0x31333a34, 0x30207368, 0x75616e67, 0x20457870,
-0x20240000, 0x46575f56, 0x45525349, 0x4f4e3a20,
-0x23312054, 0x6875204a, 0x616e2032, 0x37203131,
-0x3a32373a, 0x35352050, 0x53542032, 0x30303000,
-0x46575f43, 0x4f4d5049, 0x4c455f54, 0x494d453a,
-0x2031313a, 0x32373a35, 0x35000000, 0x46575f43,
-0x4f4d5049, 0x4c455f42, 0x593a2064, 0x65767263,
-0x73000000, 0x46575f43, 0x4f4d5049, 0x4c455f48,
-0x4f53543a, 0x20636f6d, 0x70757465, 0x0,
-0x46575f43, 0x4f4d5049, 0x4c455f44, 0x4f4d4149,
-0x4e3a2065, 0x6e672e61, 0x6374656f, 0x6e2e636f,
-0x6d000000, 0x46575f43, 0x4f4d5049, 0x4c45523a,
-0x20676363, 0x20766572, 0x73696f6e, 0x20322e37,
-0x2e320000, 0x0, 0x0, 0x0,
-0x0, 0x24486561, 0x6465723a, 0x202f7072,
-0x6f6a6563, 0x74732f72, 0x63732f73, 0x772f6765,
-0x2f2e2f6e, 0x69632f66, 0x772f636f, 0x6d6d6f6e,
-0x2f6d656d, 0x2e632c76, 0x20312e31, 0x2e322e32,
-0x20313939, 0x382f3034, 0x2f323720, 0x32323a31,
-0x333a3434, 0x20736875, 0x616e6720, 0x45787020,
-0x24000000, 0x24486561, 0x6465723a, 0x202f7072,
-0x6f6a6563, 0x74732f72, 0x63732f73, 0x772f6765,
-0x2f2e2f6e, 0x69632f66, 0x772f636f, 0x6d6d6f6e,
-0x2f73656e, 0x642e632c, 0x7620312e, 0x312e322e,
-0x31312031, 0x3939382f, 0x31322f32, 0x32203137,
-0x3a31373a, 0x35352073, 0x6875616e, 0x67204578,
-0x70202400, 0x736e6464, 0x654e6f51, 0x20000000,
-0x6e6f454e, 0x515f5458, 0x0, 0x736e6464,
-0x744e6f51, 0x20000000, 0x3f6e6f51, 0x64547845,
-0x0, 0x756e6b72, 0x64747970, 0x65000000,
-0x0, 0xaccc, 0xaccc, 0xad9c,
-0xaab0, 0xaab0, 0xad9c, 0xad9c,
-0xad9c, 0xad9c, 0xad9c, 0xad9c,
-0xad9c, 0xad9c, 0xad9c, 0xad9c,
-0xad9c, 0xad9c, 0xad9c, 0xad7c,
-0x0, 0xbca8, 0xbca8, 0xbd70,
-0xae4c, 0xb058, 0xbd70, 0xbd70,
-0xbd70, 0xbd70, 0xbd70, 0xbd70,
-0xbd70, 0xbd70, 0xbd70, 0xbd70,
-0xbd70, 0xbd70, 0xbd70, 0xbd54,
-0xb040, 0x24486561, 0x6465723a, 0x202f7072,
-0x6f6a6563, 0x74732f72, 0x63732f73, 0x772f6765,
-0x2f2e2f6e, 0x69632f66, 0x772f636f, 0x6d6d6f6e,
-0x2f726563, 0x762e632c, 0x7620312e, 0x312e322e,
-0x31392031, 0x3939382f, 0x30372f32, 0x34203231,
-0x3a33303a, 0x30352073, 0x6875616e, 0x67204578,
-0x70202400, 0x706b5278, 0x45525200, 0x66726d32,
-0x4c617267, 0x65000000, 0x72784e6f, 0x52784264,
-0x0, 0x72785144, 0x6d614446, 0x0,
-0x72785144, 0x6d614246, 0x0, 0x3f6e6f51,
-0x64527845, 0x0, 0x706b5278, 0x45525273,
-0x0, 0x66726d32, 0x4c726753, 0x0,
-0x72784e6f, 0x42645300, 0x3f724264, 0x446d6146,
-0x0, 0x3f724a42, 0x64446d46, 0x0,
-0x0, 0xf678, 0xf678, 0xf678,
-0xf678, 0xf678, 0xf678, 0xf678,
-0xf678, 0xf678, 0xf678, 0xf678,
-0xf678, 0xf678, 0xf678, 0xf678,
-0xf670, 0xf670, 0xf670, 0x572d444d,
-0x41456e46, 0x0, 0x0, 0xfdc0,
-0x1015c, 0xfddc, 0x1015c, 0x1015c,
-0x1015c, 0x1015c, 0x1015c, 0x1015c,
-0xf704, 0x1015c, 0x1015c, 0x1015c,
-0x1015c, 0x1015c, 0x10154, 0x10154,
-0x10154, 0x24486561, 0x6465723a, 0x202f7072,
-0x6f6a6563, 0x74732f72, 0x63732f73, 0x772f6765,
-0x2f2e2f6e, 0x69632f66, 0x772f636f, 0x6d6d6f6e,
-0x2f6d6163, 0x2e632c76, 0x20312e31, 0x2e322e31,
-0x32203139, 0x39382f30, 0x342f3237, 0x2032323a,
-0x31333a34, 0x32207368, 0x75616e67, 0x20457870,
-0x20240000, 0x6d616374, 0x7841544e, 0x0,
-0x4e745379, 0x6e264c6b, 0x0, 0x72656d61,
-0x73737274, 0x0, 0x6c696e6b, 0x444f574e,
-0x0, 0x656e714d, 0x45765046, 0x61696c00,
-0x656e714d, 0x45764661, 0x696c0000, 0x6661696c,
-0x456e454d, 0x0, 0x6c696e6b, 0x55500000,
-0x0, 0x24486561, 0x6465723a, 0x202f7072,
-0x6f6a6563, 0x74732f72, 0x63732f73, 0x772f6765,
-0x2f2e2f6e, 0x69632f66, 0x772f636f, 0x6d6d6f6e,
-0x2f636b73, 0x756d2e63, 0x2c762031, 0x2e312e32,
-0x2e322031, 0x3939382f, 0x30342f32, 0x37203232,
-0x3a31333a, 0x33392073, 0x6875616e, 0x67204578,
-0x70202400, 0x50726f62, 0x65506879, 0x0,
-0x6c6e6b41, 0x53535254, 0x0, 0x119c8,
-0x11a00, 0x11a18, 0x11a4c, 0x11a78,
-0x11a8c, 0x11ac8, 0x11e38, 0x11ba0,
-0x11be0, 0x11c0c, 0x11c4c, 0x11c7c,
-0x11cb8, 0x11cec, 0x11e38, 0x1207c,
-0x12094, 0x120bc, 0x120dc, 0x12104,
-0x12234, 0x1225c, 0x122b0, 0x122d8,
-0x0, 0x1253c, 0x1260c, 0x126e4,
-0x1291c, 0x12978, 0x12a54, 0x12a7c,
-0x12b58, 0x12b80, 0x12d28, 0x12d50,
-0x12ef8, 0x130f0, 0x13384, 0x13298,
-0x13384, 0x133b0, 0x12f20, 0x130c8,
-0x0, 0x137a4, 0x137e8, 0x13880,
-0x138cc, 0x1393c, 0x139d4, 0x13a08,
-0x13a90, 0x13b28, 0x13bf8, 0x13c38,
-0x13cbc, 0x13ce0, 0x13e14, 0x646f4261,
-0x73655067, 0x0, 0x0, 0x0,
-0x0, 0x73746d61, 0x634c4e4b, 0x0,
-0x0, 0x0 };
-static u_int32_t tigonFwData[] = {
-0x416c7465,
-0x6f6e2041, 0x63654e49, 0x43205600, 0x416c7465,
-0x6f6e2041, 0x63654e49, 0x43205600, 0x42424242,
-0x0, 0x0, 0x0, 0x135418,
-0x13e7fc, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x60cf00,
-0x60, 0xcf000000, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x3, 0x0,
-0x1, 0x0, 0x0, 0x0,
-0x1, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x1,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x1000000, 0x21000000, 0x12000140,
-0x0, 0x0, 0x20000000, 0x120000a0,
-0x0, 0x12000060, 0x12000180, 0x120001e0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x2,
-0x0, 0x0, 0x30001, 0x1,
-0x30201, 0x0, 0x0, 0x0 };
diff --git a/sys/dev/ti/ti_fw2.h b/sys/dev/ti/ti_fw2.h
deleted file mode 100644
index 4a6d9ee385c8..000000000000
--- a/sys/dev/ti/ti_fw2.h
+++ /dev/null
@@ -1,4189 +0,0 @@
-/*
- * Generated by genfw.c
- * Built on Fri Jan 28 20:29:13 2000 by wpaul@eedept
- * OS: FreeBSD 3.2-RELEASE
- *
- * $FreeBSD$
- */
-static int tigon2FwReleaseMajor = 0xc;
-static int tigon2FwReleaseMinor = 0x3;
-static int tigon2FwReleaseFix = 0x12;
-static u_int32_t tigon2FwStartAddr = 0x00004000;
-static u_int32_t tigon2FwTextAddr = 0x00004000;
-static int tigon2FwTextLen = 0xf2e0;
-static u_int32_t tigon2FwRodataAddr = 0x000132e0;
-static int tigon2FwRodataLen = 0xfc0;
-static u_int32_t tigon2FwDataAddr = 0x000142c0;
-static int tigon2FwDataLen = 0x180;
-static u_int32_t tigon2FwSbssAddr = 0x00014440;
-static int tigon2FwSbssLen = 0xbc;
-static u_int32_t tigon2FwBssAddr = 0x00014500;
-static int tigon2FwBssLen = 0x20c0;
-static u_int32_t tigon2FwText[] = {
-0x0,
-0x10000003, 0x0, 0xd, 0xd,
-0x3c1d0001, 0x8fbd4310, 0x3a0f021, 0x3c100000,
-0x26104000, 0xc0010c0, 0x0, 0xd,
-0x3c1d0001, 0x8fbd4314, 0x3a0f021, 0x3c100000,
-0x26104000, 0xc0017be, 0x0, 0xd,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x2000008,
-0x0, 0x800170d, 0x3c0a0001, 0x800170d,
-0x3c0a0002, 0x800170d, 0x0, 0x8002b38,
-0x0, 0x8002adb, 0x0, 0x800170d,
-0x3c0a0004, 0x8003142, 0x0, 0x8001a2e,
-0x0, 0x80037f4, 0x0, 0x800379b,
-0x0, 0x800170d, 0x3c0a0006, 0x8003862,
-0x3c0a0007, 0x800170d, 0x3c0a0008, 0x800170d,
-0x3c0a0009, 0x80038ba, 0x0, 0x8002d32,
-0x0, 0x800170d, 0x3c0a000b, 0x800170d,
-0x3c0a000c, 0x800170d, 0x3c0a000d, 0x80027a7,
-0x0, 0x800273c, 0x0, 0x800170d,
-0x3c0a000e, 0x8001f48, 0x0, 0x8001940,
-0x0, 0x80019e0, 0x0, 0x8003b3c,
-0x0, 0x8003b2a, 0x0, 0x800170d,
-0x0, 0x80018f6, 0x0, 0x800170d,
-0x0, 0x800170d, 0x3c0a0013, 0x800170d,
-0x3c0a0014, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x27bdffe0,
-0x3c1cc000, 0xafbf001c, 0xafb00018, 0x8f820140,
-0x24030003, 0xaf8300ec, 0x34420004, 0xc0029cc,
-0xaf820140, 0x3c0100c0, 0xc001741, 0xac203ffc,
-0x403021, 0x3c020008, 0x3c010001, 0xac264458,
-0x50c2000d, 0x24020008, 0x3c100010, 0x10d00009,
-0x24050100, 0x3c040001, 0x24843394, 0x3821,
-0xafa00010, 0xc0029e7, 0xafa00014, 0x3c010001,
-0xac304458, 0x24020008, 0x3c010001, 0xac224470,
-0x2402001f, 0x3c010001, 0xac224480, 0x24020016,
-0x3c010001, 0xac224454, 0x3c05fffe, 0x34a56f08,
-0x3c020001, 0x8c424458, 0x3c030001, 0x246365c0,
-0x3c040001, 0x8c8442c4, 0x431023, 0x14800002,
-0x458021, 0x2610fa38, 0x2402f000, 0x2028024,
-0xc001763, 0x2002021, 0x2022823, 0x3c040020,
-0x821823, 0x651823, 0x247bb000, 0x3c03fffe,
-0x3463bf08, 0x363b821, 0x3c0600bf, 0x34c6f000,
-0x3c070001, 0x8ce742c0, 0x3c0300bf, 0x3463e000,
-0x852023, 0x3c010001, 0xac244464, 0x822023,
-0x3c010001, 0xac25444c, 0x52842, 0x3c010001,
-0xac224440, 0x27620ffc, 0x3c010001, 0xac224310,
-0x27621ffc, 0xdb3023, 0x7b1823, 0x3c010001,
-0xac244444, 0x3c010001, 0xac254468, 0x3c010001,
-0xac224314, 0xaf860150, 0x10e00011, 0xaf830250,
-0x3c1d0001, 0x8fbd42cc, 0x3a0f021, 0xc001727,
-0x0, 0x3c020001, 0x8c4242d0, 0x3c030001,
-0x8c6342d4, 0x2442fe00, 0x24630200, 0x3c010001,
-0xac2242d0, 0x3c010001, 0x10000004, 0xac2342d4,
-0x3c1d0001, 0x8fbd4310, 0x3a0f021, 0x3c020001,
-0x8c4242c4, 0x1040000d, 0x26fafa38, 0x3c020001,
-0x8c4242d0, 0x3c030001, 0x8c6342d4, 0x3c1a0001,
-0x8f5a42d4, 0x2442fa38, 0x246305c8, 0x3c010001,
-0xac2242d0, 0x3c010001, 0xac2342d4, 0x3c020001,
-0x8c4242c8, 0x14400003, 0x0, 0x3c010001,
-0xac2042d0, 0xc00114c, 0x0, 0x8fbf001c,
-0x8fb00018, 0x3e00008, 0x27bd0020, 0x3c020001,
-0x8c4242d0, 0x3c030001, 0x8c6342d4, 0x27bdffa0,
-0xafb00040, 0x3c100001, 0x8e103d48, 0x3c040001,
-0x248433a0, 0xafbf0058, 0xafbe0054, 0xafb50050,
-0xafb3004c, 0xafb20048, 0xafb10044, 0xafa20034,
-0xafa30030, 0xafa00010, 0xafa00014, 0x8f860040,
-0x24050200, 0xc0029e7, 0x2003821, 0x8f830040,
-0x3c02f000, 0x621824, 0x3c026000, 0x1062000b,
-0xa3a0003f, 0x240e0001, 0x3c040001, 0x248433a8,
-0xa3ae003f, 0xafa00010, 0xafa00014, 0x8f860040,
-0x24050300, 0xc0029e7, 0x2003821, 0x8f820240,
-0x3c030001, 0x431025, 0xaf820240, 0xaf800048,
-0x8f820048, 0x14400005, 0x0, 0xaf800048,
-0x8f820048, 0x10400004, 0x0, 0xaf800048,
-0x10000003, 0x2e02021, 0xaf80004c, 0x2e02021,
-0x3c050001, 0xc002a54, 0x34a540f8, 0x3402021,
-0xc002a54, 0x240505c8, 0x3c020001, 0x8c424464,
-0x3c0d0001, 0x8dad4444, 0x3c030001, 0x8c634440,
-0x3c080001, 0x8d08444c, 0x3c090001, 0x8d294468,
-0x3c0a0001, 0x8d4a4470, 0x3c0b0001, 0x8d6b4480,
-0x3c0c0001, 0x8d8c4454, 0x3c040001, 0x248433b4,
-0x24050400, 0xaf42013c, 0x8f42013c, 0x24060001,
-0x24070001, 0xaf400000, 0xaf4d0138, 0xaf430144,
-0xaf480148, 0xaf49014c, 0xaf4a0150, 0xaf4b0154,
-0xaf4c0158, 0x2442ff80, 0xaf420140, 0x24020001,
-0xafa20010, 0xc0029e7, 0xafa00014, 0x8f420138,
-0xafa20010, 0x8f42013c, 0xafa20014, 0x8f460144,
-0x8f470148, 0x3c040001, 0x248433c0, 0xc0029e7,
-0x24050500, 0xafb70010, 0xafba0014, 0x8f46014c,
-0x8f470150, 0x3c040001, 0x248433cc, 0xc0029e7,
-0x24050600, 0x3c020001, 0x8c424458, 0x3603821,
-0x3c060001, 0x24c665c0, 0x2448ffff, 0x1061824,
-0xe81024, 0x43102b, 0x10400006, 0x24050900,
-0x3c040001, 0x248433d8, 0xafa80010, 0xc0029e7,
-0xafa00014, 0x8f82000c, 0xafa20010, 0x8f82003c,
-0xafa20014, 0x8f860000, 0x8f870004, 0x3c040001,
-0x248433e4, 0xc0029e7, 0x24051000, 0x8c020220,
-0x8c030224, 0x8c060218, 0x8c07021c, 0x3c040001,
-0x248433ec, 0x24051100, 0xafa20010, 0xc0029e7,
-0xafa30014, 0xaf800054, 0xaf80011c, 0x8c020218,
-0x30420002, 0x10400009, 0x0, 0x8c020220,
-0x3c030002, 0x34630004, 0x431025, 0xaf42000c,
-0x8c02021c, 0x10000008, 0x34420004, 0x8c020220,
-0x3c030002, 0x34630006, 0x431025, 0xaf42000c,
-0x8c02021c, 0x34420006, 0xaf420014, 0x8c020218,
-0x30420010, 0x1040000a, 0x0, 0x8c02021c,
-0x34420004, 0xaf420010, 0x8c020220, 0x3c03000a,
-0x34630004, 0x431025, 0x10000009, 0xaf420008,
-0x8c020220, 0x3c03000a, 0x34630006, 0x431025,
-0xaf420008, 0x8c02021c, 0x34420006, 0xaf420010,
-0x24020001, 0xaf8200a0, 0xaf8200b0, 0x8f830054,
-0x8f820054, 0x10000002, 0x24630064, 0x8f820054,
-0x621023, 0x2c420065, 0x1440fffc, 0x0,
-0x8c040208, 0x8c05020c, 0x26e20028, 0xaee20020,
-0x24020490, 0xaee20010, 0xaee40008, 0xaee5000c,
-0x26e40008, 0x8c820000, 0x8c830004, 0xaf820090,
-0xaf830094, 0x8c820018, 0xaf8200b4, 0x9482000a,
-0xaf82009c, 0x8f420014, 0xaf8200b0, 0x8f8200b0,
-0x30420004, 0x1440fffd, 0x0, 0x8f8200b0,
-0x3c03ef00, 0x431024, 0x10400021, 0x0,
-0x8f8200b4, 0xafa20010, 0x8f820090, 0x8f830094,
-0x3c040001, 0x248433f4, 0xafa30014, 0x8f8600b0,
-0x8f87009c, 0x3c050001, 0xc0029e7, 0x34a5200d,
-0x3c040001, 0x24843400, 0x240203a6, 0xafa20010,
-0xafa00014, 0x8f860144, 0x3c070001, 0x24e73408,
-0xc0029e7, 0x3405dead, 0x8f82011c, 0x34420002,
-0xaf82011c, 0x8f820220, 0x34420004, 0xaf820220,
-0x8f820140, 0x3c030001, 0x431025, 0xaf820140,
-0x96e20472, 0x96e60452, 0x96e70462, 0xafa20010,
-0x96e20482, 0x3c040001, 0x24843414, 0x24051200,
-0xc0029e7, 0xafa20014, 0x96f00452, 0x32020001,
-0x10400002, 0xb021, 0x24160001, 0x32020002,
-0x54400001, 0x36d60002, 0x32020008, 0x54400001,
-0x36d60004, 0x32020010, 0x54400001, 0x36d60008,
-0x32020020, 0x54400001, 0x36d60010, 0x32020040,
-0x54400001, 0x36d60020, 0x32020080, 0x54400001,
-0x36d60040, 0x96e60482, 0x30c20200, 0x54400001,
-0x36d64000, 0x96e30472, 0x30620200, 0x10400003,
-0x30620100, 0x10000003, 0x36d62000, 0x54400001,
-0x36d61000, 0x96f00462, 0x32c24000, 0x14400004,
-0x3207009b, 0x30c2009b, 0x14e20007, 0x240e0001,
-0x32c22000, 0x1440000d, 0x32020001, 0x3062009b,
-0x10e20009, 0x240e0001, 0x3c040001, 0x24843420,
-0x24051300, 0x2003821, 0xa3ae003f, 0xafa30010,
-0xc0029e7, 0xafa00014, 0x32020001, 0x54400001,
-0x36d60080, 0x32020002, 0x54400001, 0x36d60100,
-0x32020008, 0x54400001, 0x36d60200, 0x32020010,
-0x54400001, 0x36d60400, 0x32020080, 0x54400001,
-0x36d60800, 0x8c020218, 0x30420200, 0x10400002,
-0x3c020008, 0x2c2b025, 0x8c020218, 0x30420800,
-0x10400002, 0x3c020080, 0x2c2b025, 0x8c020218,
-0x30420400, 0x10400002, 0x3c020100, 0x2c2b025,
-0x8c020218, 0x30420100, 0x10400002, 0x3c020200,
-0x2c2b025, 0x8c020218, 0x30420080, 0x10400002,
-0x3c020400, 0x2c2b025, 0x8c020218, 0x30422000,
-0x10400002, 0x3c020010, 0x2c2b025, 0x8c020218,
-0x30424000, 0x10400002, 0x3c020020, 0x2c2b025,
-0x8c020218, 0x30421000, 0x10400002, 0x3c020040,
-0x2c2b025, 0x8ee20498, 0x8ee3049c, 0xaf420160,
-0xaf430164, 0x8ee204a0, 0x8ee304a4, 0xaf420168,
-0xaf43016c, 0x8ee204a8, 0x8ee304ac, 0xaf420170,
-0xaf430174, 0x8ee20428, 0x8ee3042c, 0xaf420178,
-0xaf43017c, 0x8ee20448, 0x8ee3044c, 0xaf420180,
-0xaf430184, 0x8ee20458, 0x8ee3045c, 0xaf420188,
-0xaf43018c, 0x8ee20468, 0x8ee3046c, 0xaf420190,
-0xaf430194, 0x8ee20478, 0x8ee3047c, 0xaf420198,
-0xaf43019c, 0x8ee20488, 0x8ee3048c, 0xaf4201a0,
-0xaf4301a4, 0x8ee204b0, 0x8ee304b4, 0x24040080,
-0xaf4201a8, 0xaf4301ac, 0xc002a54, 0x24050080,
-0x8c02025c, 0x27440224, 0xaf4201f0, 0x8c020260,
-0x24050200, 0x24060008, 0xc002a6b, 0xaf4201f8,
-0x3c043b9a, 0x3484ca00, 0x3821, 0x24020006,
-0x24030002, 0xaf4201f4, 0x240203e8, 0xaf430204,
-0xaf430200, 0xaf4401fc, 0xaf420294, 0x24020001,
-0xaf430290, 0xaf42029c, 0x3c030001, 0x671821,
-0x906342d8, 0x3471021, 0x24e70001, 0xa043022c,
-0x2ce2000f, 0x1440fff8, 0x3471821, 0x24e70001,
-0x3c080001, 0x350840f8, 0x8f820040, 0x3c040001,
-0x2484342c, 0x24051400, 0x21702, 0x24420030,
-0xa062022c, 0x3471021, 0xa040022c, 0x8c070218,
-0x2c03021, 0x240205c8, 0xafa20010, 0xc0029e7,
-0xafa80014, 0x3c040001, 0x24843438, 0x3c050000,
-0x24a55bf8, 0x24060010, 0x27b10030, 0x2203821,
-0x27b30034, 0xc001781, 0xafb30010, 0x3c030001,
-0x8c6342c8, 0x1060000a, 0x408021, 0x8fa30030,
-0x2405ff00, 0x8fa20034, 0x246400ff, 0x852024,
-0x831823, 0x431023, 0xafa20034, 0xafa40030,
-0xafb30010, 0x3c040001, 0x24843444, 0x3c050000,
-0x24a54100, 0x24060108, 0xc001781, 0x2203821,
-0x409021, 0x32c20003, 0x50400045, 0x2203821,
-0x8f820050, 0x3c030010, 0x431024, 0x10400016,
-0x0, 0x8c020218, 0x30420040, 0x1040000f,
-0x24020001, 0x8f820050, 0x8c030218, 0x240e0001,
-0x3c040001, 0x24843450, 0xa3ae003f, 0xafa20010,
-0xafa30014, 0x8f870040, 0x24051500, 0xc0029e7,
-0x2c03021, 0x10000004, 0x0, 0x3c010001,
-0x370821, 0xa02240f4, 0x3c040001, 0x2484345c,
-0x3c050001, 0x24a53260, 0x3c060001, 0x24c632cc,
-0xc53023, 0x8f420010, 0x27b30030, 0x2603821,
-0x27b10034, 0x34420a00, 0xaf420010, 0xc001781,
-0xafb10010, 0x3c040001, 0x24843470, 0x3c050001,
-0x24a5b144, 0x3c060001, 0x24c6b4c0, 0xc53023,
-0x2603821, 0xaf420108, 0xc001781, 0xafb10010,
-0x3c040001, 0x2484348c, 0x3c050001, 0x24a5b8e0,
-0x3c060001, 0x24c6c3e0, 0xc53023, 0x2603821,
-0x3c010001, 0xac2244b0, 0xc001781, 0xafb10010,
-0x3c040001, 0x248434a4, 0x10000024, 0x24051600,
-0x3c040001, 0x248434ac, 0x3c050001, 0x24a59bbc,
-0x3c060001, 0x24c69ce8, 0xc53023, 0xc001781,
-0xafb30010, 0x3c040001, 0x248434bc, 0x3c050001,
-0x24a5ace0, 0x3c060001, 0x24c6b13c, 0xc53023,
-0x2203821, 0xaf420108, 0xc001781, 0xafb30010,
-0x3c040001, 0x248434d0, 0x3c050001, 0x24a5b4c8,
-0x3c060001, 0x24c6b8d8, 0xc53023, 0x2203821,
-0x3c010001, 0xac2244b0, 0xc001781, 0xafb30010,
-0x3c040001, 0x248434e4, 0x24051650, 0x2c03021,
-0x3821, 0x3c010001, 0xac2244b4, 0xafa00010,
-0xc0029e7, 0xafa00014, 0x32c20020, 0x10400021,
-0x27a70030, 0x3c040001, 0x248434f0, 0x3c050001,
-0x24a5ab6c, 0x3c060001, 0x24c6acd8, 0xc53023,
-0x24022000, 0xaf42001c, 0x27a20034, 0xc001781,
-0xafa20010, 0x21900, 0x31982, 0x3c040800,
-0x641825, 0xae430028, 0x24030010, 0xaf43003c,
-0x96e30450, 0xaf430040, 0x8f430040, 0x3c040001,
-0x24843504, 0xafa00014, 0xafa30010, 0x8f47001c,
-0x24051660, 0x3c010001, 0xac2244ac, 0x10000025,
-0x32c60020, 0x8ee20448, 0x8ee3044c, 0xaf43001c,
-0x8f42001c, 0x2442e000, 0x2c422001, 0x1440000a,
-0x240e0001, 0x3c040001, 0x24843510, 0xa3ae003f,
-0xafa00010, 0xafa00014, 0x8f46001c, 0x24051700,
-0xc0029e7, 0x3821, 0x3c020000, 0x24425c34,
-0x21100, 0x21182, 0x3c030800, 0x431025,
-0xae420028, 0x24020008, 0xaf42003c, 0x96e20450,
-0xaf420040, 0x8f420040, 0x3c040001, 0x2484351c,
-0xafa00014, 0xafa20010, 0x8f47001c, 0x24051800,
-0x32c60020, 0xc0029e7, 0x0, 0x3c030001,
-0x8c6344b0, 0x3c050fff, 0x34a5ffff, 0x3c020001,
-0x8c4244b4, 0x3c040800, 0x651824, 0x31882,
-0x641825, 0x451024, 0x21082, 0x441025,
-0xae420080, 0x32c20180, 0x10400056, 0xae430020,
-0x8f82005c, 0x3c030080, 0x431024, 0x1040000d,
-0x0, 0x8f820050, 0xafa20010, 0x8f82005c,
-0x240e0001, 0x3c040001, 0x24843528, 0xa3ae003f,
-0xafa20014, 0x8f870040, 0x24051900, 0xc0029e7,
-0x2c03021, 0x8f820050, 0x3c030010, 0x431024,
-0x10400016, 0x0, 0x8c020218, 0x30420040,
-0x1040000f, 0x24020001, 0x8f820050, 0x8c030218,
-0x240e0001, 0x3c040001, 0x24843450, 0xa3ae003f,
-0xafa20010, 0xafa30014, 0x8f870040, 0x24052000,
-0xc0029e7, 0x2c03021, 0x10000004, 0x0,
-0x3c010001, 0x370821, 0xa02240f4, 0x3c040001,
-0x24843534, 0x3c050001, 0x24a531e0, 0x3c060001,
-0x24c63258, 0xc53023, 0x8f420008, 0x27b30030,
-0x2603821, 0x27b10034, 0x34420e00, 0xaf420008,
-0xc001781, 0xafb10010, 0x3c040001, 0x2484354c,
-0x3c050001, 0x24a5d350, 0x3c060001, 0x24c6de64,
-0xc53023, 0x2603821, 0xaf42010c, 0xc001781,
-0xafb10010, 0x3c040001, 0x24843564, 0x3c050001,
-0x24a5e448, 0x3c060001, 0x24c6eb8c, 0xc53023,
-0x2603821, 0x3c010001, 0xac2244c0, 0xc001781,
-0xafb10010, 0x3c040001, 0x2484357c, 0x10000027,
-0x24052100, 0x3c040001, 0x24843584, 0x3c050001,
-0x24a59a78, 0x3c060001, 0x24c69bb4, 0xc53023,
-0x27b10030, 0x2203821, 0x27b30034, 0xc001781,
-0xafb30010, 0x3c040001, 0x24843594, 0x3c050001,
-0x24a5c5b0, 0x3c060001, 0x24c6d348, 0xc53023,
-0x2203821, 0xaf42010c, 0xc001781, 0xafb30010,
-0x3c040001, 0x248435a4, 0x3c050001, 0x24a5e2e8,
-0x3c060001, 0x24c6e440, 0xc53023, 0x2203821,
-0x3c010001, 0xac2244c0, 0xc001781, 0xafb30010,
-0x3c040001, 0x248435b8, 0x24052150, 0x2c03021,
-0x3821, 0x3c010001, 0xac2244cc, 0xafa00010,
-0xc0029e7, 0xafa00014, 0x3c030001, 0x8c6344c0,
-0x3c110fff, 0x3631ffff, 0x3c020001, 0x8c4244cc,
-0x3c1e0800, 0x711824, 0x31882, 0x7e1825,
-0x511024, 0x21082, 0x5e1025, 0xae430038,
-0xae420078, 0x8c020218, 0x30420040, 0x14400004,
-0x24020001, 0x3c010001, 0x370821, 0xa02240f4,
-0x3c040001, 0x248435c4, 0x3c050001, 0x24a5de6c,
-0x3c060001, 0x24c6dfc8, 0xc53023, 0x27b50030,
-0x2a03821, 0x27b30034, 0xc001781, 0xafb30010,
-0x3c010001, 0xac2244b8, 0x511024, 0x21082,
-0x5e1025, 0xae420050, 0x32c22000, 0x10400005,
-0x2a03821, 0x3c020000, 0x24425c34, 0x1000000d,
-0x511024, 0x3c040001, 0x248435d8, 0x3c050001,
-0x24a5dfd0, 0x3c060001, 0x24c6e180, 0xc53023,
-0xc001781, 0xafb30010, 0x3c010001, 0xac2244d0,
-0x511024, 0x21082, 0x5e1025, 0xae420048,
-0x32c24000, 0x10400005, 0x27a70030, 0x3c020000,
-0x24425c34, 0x1000000e, 0x21100, 0x3c040001,
-0x248435f0, 0x3c050001, 0x24a5e188, 0x3c060001,
-0x24c6e2e0, 0xc53023, 0x27a20034, 0xc001781,
-0xafa20010, 0x3c010001, 0xac2244c4, 0x21100,
-0x21182, 0x3c030800, 0x431025, 0xae420060,
-0x3c040001, 0x24843608, 0x3c050000, 0x24a57d20,
-0x3c060001, 0x24c68140, 0xc53023, 0x27b10030,
-0x2203821, 0x27b30034, 0xc001781, 0xafb30010,
-0x3c1e0fff, 0x37deffff, 0x3c040001, 0x24843614,
-0x3c050000, 0x24a563d8, 0x3c060000, 0x24c664f8,
-0xc53023, 0x2203821, 0x3c010001, 0xac224498,
-0x5e1024, 0x21082, 0x3c150800, 0x551025,
-0xae4200b8, 0xc001781, 0xafb30010, 0x3c040001,
-0x24843620, 0x3c050000, 0x24a56500, 0x3c060000,
-0x24c66778, 0xc53023, 0x2203821, 0x3c010001,
-0xac22448c, 0x5e1024, 0x21082, 0x551025,
-0xae4200e8, 0xc001781, 0xafb30010, 0x3c040001,
-0x24843638, 0x3c050000, 0x24a56780, 0x3c060000,
-0x24c668b0, 0xc53023, 0x2203821, 0x3c010001,
-0xac224484, 0x5e1024, 0x21082, 0x551025,
-0xae4200c0, 0xc001781, 0xafb30010, 0x3c040001,
-0x24843650, 0x3c050001, 0x24a5f520, 0x3c060001,
-0x24c6f5f8, 0xc53023, 0x2203821, 0x3c010001,
-0xac224490, 0x5e1024, 0x21082, 0x551025,
-0xae4200c8, 0xc001781, 0xafb30010, 0x3c040001,
-0x2484365c, 0x3c050001, 0x24a5c41c, 0x3c060001,
-0x24c6c500, 0xc53023, 0x2203821, 0xaf420110,
-0xc001781, 0xafb30010, 0x3c040001, 0x2484366c,
-0x3c050001, 0x24a5c3f0, 0x3c060001, 0x24c6c414,
-0xc53023, 0x2203821, 0xaf420124, 0xc001781,
-0xafb30010, 0x3c040001, 0x2484367c, 0x3c050001,
-0x24a531a0, 0x3c060001, 0x24c631cc, 0xc53023,
-0x2203821, 0xaf420120, 0xaf420114, 0xc001781,
-0xafb30010, 0x3c040001, 0x24843688, 0x3c050001,
-0x24a5ecf0, 0x3c060001, 0x24c6f10c, 0xc53023,
-0x2203821, 0xaf420118, 0xc001781, 0xafb30010,
-0x3c010001, 0xac2244d4, 0x5e1024, 0x21082,
-0x551025, 0xc003e57, 0xae4200d0, 0xc003ae8,
-0x0, 0xc002654, 0x0, 0xac000228,
-0xac00022c, 0x96e20450, 0x2442ffff, 0xaf420038,
-0x96e20460, 0xaf420080, 0x32c24000, 0x14400003,
-0x0, 0x96e20480, 0xaf420084, 0x96e70490,
-0x50e00001, 0x24070800, 0x24e2ffff, 0xaf420088,
-0xaf42007c, 0x24020800, 0x10e2000f, 0x32c24000,
-0x10400003, 0x24020400, 0x10e2000b, 0x0,
-0x240e0001, 0x3c040001, 0x24843698, 0xa3ae003f,
-0x96e60490, 0x24052170, 0x2c03821, 0xafa00010,
-0xc0029e7, 0xafa00014, 0x8f430138, 0x8f440138,
-0x24020001, 0xa34205c2, 0xaf430094, 0xaf440098,
-0xafa00010, 0xafa00014, 0x8f460080, 0x8f470084,
-0x3c040001, 0x248436a4, 0xc0029e7, 0x24052200,
-0xc002354, 0x3c110800, 0x3c1433d8, 0x3694cb58,
-0x3c020800, 0x34420080, 0x3c040001, 0x248436b0,
-0x3c050000, 0x24a55c78, 0x3c060000, 0x24c65c94,
-0xc53023, 0x27a70030, 0xaf820060, 0x2402ffff,
-0xaf820064, 0x27a20034, 0xc001781, 0xafa20010,
-0x3c010001, 0xac224474, 0x21100, 0x21182,
-0x511025, 0xc0018d8, 0xae420000, 0x8f820240,
-0x3c030001, 0x431025, 0xaf820240, 0x3c020000,
-0x24424034, 0xaf820244, 0xaf800240, 0x8f820060,
-0x511024, 0x14400005, 0x3c030800, 0x8f820060,
-0x431024, 0x1040fffd, 0x0, 0xc003af5,
-0x8821, 0x3c020100, 0xafa20020, 0x8f530018,
-0x240200ff, 0x56620001, 0x26710001, 0x8c020228,
-0x1622000e, 0x1330c0, 0x8f42033c, 0x24420001,
-0xaf42033c, 0x8f42033c, 0x8c020228, 0x3c040001,
-0x24843344, 0x3c050009, 0xafa00014, 0xafa20010,
-0x8fa60020, 0x1000003f, 0x34a50100, 0xd71021,
-0x8fa30020, 0x8fa40024, 0xac4304c0, 0xac4404c4,
-0xc01821, 0x8f440178, 0x8f45017c, 0x1021,
-0x24070004, 0xafa70010, 0xafb10014, 0x8f48000c,
-0x24c604c0, 0x2e63021, 0xafa80018, 0x8f48010c,
-0x24070008, 0xa32821, 0xa3482b, 0x822021,
-0x100f809, 0x892021, 0x1440000b, 0x24070008,
-0x8f820120, 0xafa20010, 0x8f820124, 0x3c040001,
-0x2484334c, 0x3c050009, 0xafa20014, 0x8fa60020,
-0x1000001c, 0x34a50200, 0x8f440160, 0x8f450164,
-0x8f43000c, 0xaf510018, 0x8f860120, 0x24020010,
-0xafa20010, 0xafb10014, 0xafa30018, 0x8f42010c,
-0x40f809, 0x24c6001c, 0x14400010, 0x0,
-0x8f420340, 0x24420001, 0xaf420340, 0x8f420340,
-0x8f820120, 0xafa20010, 0x8f820124, 0x3c040001,
-0x24843354, 0x3c050009, 0xafa20014, 0x8fa60020,
-0x34a50300, 0xc0029e7, 0x2603821, 0x8f4202e4,
-0x24420001, 0xaf4202e4, 0x8f4202e4, 0x93a2003f,
-0x10400069, 0x3c020700, 0x34423000, 0xafa20028,
-0x8f530018, 0x240200ff, 0x12620002, 0x8821,
-0x26710001, 0x8c020228, 0x1622000e, 0x1330c0,
-0x8f42033c, 0x24420001, 0xaf42033c, 0x8f42033c,
-0x8c020228, 0x3c040001, 0x24843344, 0x3c050009,
-0xafa00014, 0xafa20010, 0x8fa60028, 0x1000003f,
-0x34a50100, 0xd71021, 0x8fa30028, 0x8fa4002c,
-0xac4304c0, 0xac4404c4, 0xc01821, 0x8f440178,
-0x8f45017c, 0x1021, 0x24070004, 0xafa70010,
-0xafb10014, 0x8f48000c, 0x24c604c0, 0x2e63021,
-0xafa80018, 0x8f48010c, 0x24070008, 0xa32821,
-0xa3482b, 0x822021, 0x100f809, 0x892021,
-0x1440000b, 0x24070008, 0x8f820120, 0xafa20010,
-0x8f820124, 0x3c040001, 0x2484334c, 0x3c050009,
-0xafa20014, 0x8fa60028, 0x1000001c, 0x34a50200,
-0x8f440160, 0x8f450164, 0x8f43000c, 0xaf510018,
-0x8f860120, 0x24020010, 0xafa20010, 0xafb10014,
-0xafa30018, 0x8f42010c, 0x40f809, 0x24c6001c,
-0x14400010, 0x0, 0x8f420340, 0x24420001,
-0xaf420340, 0x8f420340, 0x8f820120, 0xafa20010,
-0x8f820124, 0x3c040001, 0x24843354, 0x3c050009,
-0xafa20014, 0x8fa60028, 0x34a50300, 0xc0029e7,
-0x2603821, 0x8f4202f0, 0x24420001, 0xaf4202f0,
-0x8f4202f0, 0x3c040001, 0x248436c0, 0xafa00010,
-0xafa00014, 0x8fa60028, 0x24052300, 0xc0029e7,
-0x3821, 0x10000004, 0x0, 0x8c020264,
-0x10400005, 0x0, 0x8f8200a0, 0x30420004,
-0x1440fffa, 0x0, 0x8f820044, 0x34420004,
-0xaf820044, 0x8f420308, 0x24420001, 0xaf420308,
-0x8f420308, 0x8f8200d8, 0x8f8300d4, 0x431023,
-0x2442ff80, 0xaf420090, 0x8f420090, 0x2842ff81,
-0x10400006, 0x24020001, 0x8f420090, 0x8f430144,
-0x431021, 0xaf420090, 0x24020001, 0xaf42008c,
-0x32c20008, 0x10400006, 0x0, 0x8f820214,
-0x3c038100, 0x3042ffff, 0x431025, 0xaf820214,
-0x3c020001, 0x8c424384, 0x30420001, 0x10400009,
-0x0, 0x3c040001, 0x248436cc, 0x3c050000,
-0x24a56cc0, 0x3c060000, 0x24c67168, 0x10000008,
-0xc53023, 0x3c040001, 0x248436dc, 0x3c050000,
-0x24a568b8, 0x3c060000, 0x24c66cb8, 0xc53023,
-0x27a70030, 0x27a20034, 0xc001781, 0xafa20010,
-0x3c010001, 0xac224488, 0x3c020001, 0x8c424488,
-0x3c030800, 0x21100, 0x21182, 0x431025,
-0xae420040, 0x8f8200a0, 0xafa20010, 0x8f8200b0,
-0xafa20014, 0x8f86005c, 0x8f87011c, 0x3c040001,
-0x248436ec, 0x3c010001, 0xac364460, 0x3c010001,
-0xac204450, 0x3c010001, 0xac3c4448, 0x3c010001,
-0xac3b4478, 0x3c010001, 0xac37447c, 0x3c010001,
-0xac3a445c, 0xc0029e7, 0x24052400, 0x8f820200,
-0xafa20010, 0x8f820220, 0xafa20014, 0x8f860044,
-0x8f870050, 0x3c040001, 0x248436f8, 0xc0029e7,
-0x24052500, 0x8f830060, 0x74100b, 0x242000a,
-0x200f821, 0x0, 0xd, 0x8fbf0058,
-0x8fbe0054, 0x8fb50050, 0x8fb3004c, 0x8fb20048,
-0x8fb10044, 0x8fb00040, 0x3e00008, 0x27bd0060,
-0x27bdffe0, 0x3c040001, 0x24843704, 0x24052600,
-0x3021, 0x3821, 0xafbf0018, 0xafa00010,
-0xc0029e7, 0xafa00014, 0x8fbf0018, 0x3e00008,
-0x27bd0020, 0x3e00008, 0x0, 0x3e00008,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x3e00008, 0x0,
-0x3e00008, 0x0, 0x27bdfde0, 0x27a50018,
-0x3c04dead, 0x3484beef, 0xafbf0218, 0x8f820150,
-0x3c03001f, 0x3463ffff, 0xafa40018, 0xa22823,
-0xa32824, 0x8ca20000, 0x1044000a, 0x0,
-0xafa50010, 0x8ca20000, 0xafa20014, 0x8f860150,
-0x8f870250, 0x3c040001, 0x2484370c, 0xc0029e7,
-0x24052700, 0x8fbf0218, 0x3e00008, 0x27bd0220,
-0x27bdffe0, 0x3c06abba, 0x34c6babe, 0xafb00018,
-0x3c100004, 0x3c07007f, 0x34e7ffff, 0xafbf001c,
-0x102840, 0x8e040000, 0x8ca30000, 0xaca00000,
-0xae060000, 0x8ca20000, 0xaca30000, 0x10460005,
-0xae040000, 0xa08021, 0xf0102b, 0x1040fff5,
-0x102840, 0x3c040001, 0x24843718, 0x24052800,
-0x2003021, 0x3821, 0xafa00010, 0xc0029e7,
-0xafa00014, 0x2001021, 0x8fbf001c, 0x8fb00018,
-0x3e00008, 0x27bd0020, 0x8c020224, 0x3047003f,
-0x10e00010, 0x803021, 0x2821, 0x24030020,
-0xe31024, 0x10400002, 0x63042, 0xa62821,
-0x31842, 0x1460fffb, 0xe31024, 0x2402f000,
-0xa22824, 0x3402ffff, 0x45102b, 0x14400003,
-0x3c020001, 0x10000008, 0x3c020001, 0x3442ffff,
-0x851823, 0x43102b, 0x14400003, 0xa01021,
-0x3c02fffe, 0x821021, 0x3e00008, 0x0,
-0x27bdffd0, 0xafb50028, 0x8fb50040, 0xafb20020,
-0xa09021, 0xafb1001c, 0x24c60003, 0xafbf002c,
-0xafb30024, 0xafb00018, 0x8ea20000, 0x2403fffc,
-0xc38024, 0x50102b, 0x1440001b, 0xe08821,
-0x8e330000, 0xafb00010, 0x8ea20000, 0xafa20014,
-0x8e270000, 0x24053000, 0xc0029e7, 0x2403021,
-0x8e230000, 0x702021, 0x64102b, 0x10400007,
-0x2402821, 0x8ca20000, 0xac620000, 0x24630004,
-0x64102b, 0x1440fffb, 0x24a50004, 0x8ea20000,
-0x501023, 0xaea20000, 0x8e220000, 0x501021,
-0x1000000b, 0xae220000, 0x2402002d, 0xa0820000,
-0xafb00010, 0x8ea20000, 0x2409821, 0xafa20014,
-0x8e270000, 0x24053100, 0xc0029e7, 0x2603021,
-0x2601021, 0x8fbf002c, 0x8fb50028, 0x8fb30024,
-0x8fb20020, 0x8fb1001c, 0x8fb00018, 0x3e00008,
-0x27bd0030, 0x27bdffe8, 0x3c1cc000, 0x3c05fffe,
-0x3c030001, 0x8c634440, 0x3c040001, 0x8c84444c,
-0x34a5bf08, 0x24021ffc, 0x3c010001, 0xac2242d0,
-0x3c0200c0, 0x3c010001, 0xac2242d4, 0x3c020020,
-0xafbf0010, 0x3c0100c0, 0xac201ffc, 0x431023,
-0x441023, 0x245bb000, 0x365b821, 0x3c1d0001,
-0x8fbd42cc, 0x3a0f021, 0x3c0400c0, 0x34840200,
-0x3c1a00c0, 0x3c0300c0, 0x346307c8, 0x24021dfc,
-0x3c010001, 0xac2242d0, 0x24021834, 0x3c010001,
-0xac2442d4, 0x3c010001, 0xac2242d0, 0x3c010001,
-0xac2342d4, 0xc0017eb, 0x375a0200, 0x8fbf0010,
-0x3e00008, 0x27bd0018, 0x27bdffc8, 0x3c040001,
-0x24843724, 0x24053200, 0x3c020001, 0x8c4242d0,
-0x3c030001, 0x8c6342d4, 0x3021, 0x3603821,
-0xafbf0030, 0xafb3002c, 0xafb20028, 0xafb10024,
-0xafb00020, 0xafa2001c, 0xafa30018, 0xafb70010,
-0xc0029e7, 0xafba0014, 0xc0018f2, 0x0,
-0x8f820240, 0x34420004, 0xaf820240, 0x24020001,
-0xaf420000, 0x3c020001, 0x571021, 0x904240f4,
-0x10400092, 0x2403fffc, 0x3c100001, 0x2610a723,
-0x3c120001, 0x2652a2fc, 0x2121023, 0x438024,
-0x8fa3001c, 0x3c040001, 0x24843730, 0x70102b,
-0x1440001a, 0x27b30018, 0x8fb10018, 0x24053000,
-0x2403021, 0xafb00010, 0xafa30014, 0xc0029e7,
-0x2203821, 0x8fa30018, 0x702021, 0x64102b,
-0x10400007, 0x2403021, 0x8cc20000, 0xac620000,
-0x24630004, 0x64102b, 0x1440fffb, 0x24c60004,
-0x8fa2001c, 0x501023, 0xafa2001c, 0x8e620000,
-0x501021, 0x1000000a, 0xae620000, 0x2408821,
-0x24053100, 0xafb00010, 0xafa30014, 0x8fa70018,
-0x2203021, 0x2402002d, 0xc0029e7, 0xa0820000,
-0x24070020, 0x8fa3001c, 0x3c040001, 0x2484374c,
-0x24120020, 0x3c010001, 0xac31446c, 0x2c620020,
-0x1440001d, 0x27b10018, 0x8fb00018, 0x24053000,
-0x3c060001, 0x24c64500, 0xafa70010, 0xafa30014,
-0xc0029e7, 0x2003821, 0x8fa30018, 0x3c040001,
-0x24844500, 0x24650020, 0x65102b, 0x10400007,
-0x0, 0x8c820000, 0xac620000, 0x24630004,
-0x65102b, 0x1440fffb, 0x24840004, 0x8fa2001c,
-0x521023, 0xafa2001c, 0x8e220000, 0x521021,
-0x1000000b, 0xae220000, 0x3c100001, 0x26104500,
-0x24053100, 0xafa70010, 0xafa30014, 0x8fa70018,
-0x2003021, 0x2402002d, 0xc0029e7, 0xa0820000,
-0x24070020, 0x3c040001, 0x24843760, 0x8fa3001c,
-0x24120020, 0x3c010001, 0xac3044a0, 0x2c620020,
-0x1440001d, 0x27b10018, 0x8fb00018, 0x24053000,
-0x3c060001, 0x24c64520, 0xafa70010, 0xafa30014,
-0xc0029e7, 0x2003821, 0x8fa30018, 0x3c040001,
-0x24844520, 0x24650020, 0x65102b, 0x10400007,
-0x0, 0x8c820000, 0xac620000, 0x24630004,
-0x65102b, 0x1440fffb, 0x24840004, 0x8fa2001c,
-0x521023, 0xafa2001c, 0x8e220000, 0x521021,
-0x1000000b, 0xae220000, 0x3c100001, 0x26104520,
-0x24053100, 0xafa70010, 0xafa30014, 0x8fa70018,
-0x2003021, 0x2402002d, 0xc0029e7, 0xa0820000,
-0x3c010001, 0x10000031, 0xac30449c, 0x3c100000,
-0x26107d0f, 0x3c120000, 0x26527b8c, 0x2121023,
-0x438024, 0x8fa3001c, 0x3c040001, 0x24843774,
-0x70102b, 0x1440001a, 0x27b30018, 0x8fb10018,
-0x24053000, 0x2403021, 0xafb00010, 0xafa30014,
-0xc0029e7, 0x2203821, 0x8fa30018, 0x702021,
-0x64102b, 0x10400007, 0x2403021, 0x8cc20000,
-0xac620000, 0x24630004, 0x64102b, 0x1440fffb,
-0x24c60004, 0x8fa2001c, 0x501023, 0xafa2001c,
-0x8e620000, 0x501021, 0x1000000a, 0xae620000,
-0x2408821, 0x24053100, 0xafb00010, 0xafa30014,
-0x8fa70018, 0x2203021, 0x2402002d, 0xc0029e7,
-0xa0820000, 0x3c010001, 0xac31446c, 0x3c030001,
-0x8c63446c, 0x24020400, 0x60f809, 0xaf820070,
-0x8fbf0030, 0x8fb3002c, 0x8fb20028, 0x8fb10024,
-0x8fb00020, 0x3e00008, 0x27bd0038, 0x8f820040,
-0x3c03f000, 0x431024, 0x3c036000, 0x14430006,
-0x0, 0x8f820050, 0x2403ff80, 0x431024,
-0x34420055, 0xaf820050, 0x8f820054, 0x244203e8,
-0xaf820058, 0x240201f4, 0xaf4200e0, 0x24020004,
-0xaf4200e8, 0x24020002, 0xaf4001b0, 0xaf4000e4,
-0xaf4200dc, 0xaf4000d8, 0xaf4000d4, 0x3e00008,
-0xaf4000d0, 0x8f820054, 0x24420005, 0x3e00008,
-0xaf820078, 0x27bdffe8, 0xafbf0010, 0x8f820054,
-0x244203e8, 0xaf820058, 0x3c020800, 0x2c21024,
-0x10400004, 0x3c02f7ff, 0x3442ffff, 0x2c2b024,
-0x36940040, 0x3c020001, 0x8c424398, 0x10400017,
-0x3c020200, 0x3c030001, 0x8c6344d8, 0x10600016,
-0x282a025, 0x3c020001, 0x8c424424, 0x14400012,
-0x3c020200, 0x3c020001, 0x8c424384, 0x30420001,
-0x1440000d, 0x3c020200, 0x8f830224, 0x3c020001,
-0x8c42659c, 0x10620008, 0x3c020200, 0xc003c45,
-0x0, 0x10000004, 0x3c020200, 0xc003fe0,
-0x0, 0x3c020200, 0x2c21024, 0x10400003,
-0x0, 0xc001e07, 0x0, 0x8f4200d8,
-0x8f4300dc, 0x24420001, 0xaf4200d8, 0x43102b,
-0x14400003, 0x0, 0xaf4000d8, 0x36940080,
-0x8c030238, 0x1060000c, 0x0, 0x8f4201b0,
-0x244203e8, 0xaf4201b0, 0x43102b, 0x14400006,
-0x0, 0x934205c5, 0x14400003, 0x0,
-0xc001c5c, 0x0, 0x8fbf0010, 0x3e00008,
-0x27bd0018, 0x3e00008, 0x0, 0x27bdffd8,
-0xafbf0020, 0x8f43002c, 0x8f420038, 0x10620059,
-0x0, 0x3c020001, 0x571021, 0x904240f0,
-0x10400026, 0x24070008, 0x8f440170, 0x8f450174,
-0x8f48000c, 0x8f860120, 0x24020020, 0xafa20010,
-0xafa30014, 0xafa80018, 0x8f42010c, 0x40f809,
-0x24c6001c, 0x14400011, 0x24020001, 0x3c010001,
-0x370821, 0xa02240f0, 0x8f820124, 0xafa20010,
-0x8f820128, 0x3c040001, 0x24843818, 0xafa20014,
-0x8f46002c, 0x8f870120, 0x3c050009, 0xc0029e7,
-0x34a50900, 0x1000005c, 0x0, 0x8f420300,
-0x24420001, 0xaf420300, 0x8f420300, 0x8f42002c,
-0xa34005c1, 0x10000027, 0xaf420038, 0x8f440170,
-0x8f450174, 0x8f43002c, 0x8f48000c, 0x8f860120,
-0x24020080, 0xafa20010, 0xafa30014, 0xafa80018,
-0x8f42010c, 0x40f809, 0x24c6001c, 0x14400011,
-0x24020001, 0x3c010001, 0x370821, 0xa02240f1,
-0x8f820124, 0xafa20010, 0x8f820128, 0x3c040001,
-0x24843824, 0xafa20014, 0x8f46002c, 0x8f870120,
-0x3c050009, 0xc0029e7, 0x34a51100, 0x10000036,
-0x0, 0x8f420300, 0x8f43002c, 0x24420001,
-0xaf420300, 0x8f420300, 0x24020001, 0xa34205c1,
-0xaf430038, 0x3c010001, 0x370821, 0xa02040f1,
-0x3c010001, 0x370821, 0xa02040f0, 0x10000026,
-0xaf400034, 0x934205c1, 0x1040001d, 0x0,
-0xa34005c1, 0x8f820040, 0x30420001, 0x14400008,
-0x2021, 0x8c030104, 0x24020001, 0x50620005,
-0x24040001, 0x8c020264, 0x10400003, 0x801021,
-0x24040001, 0x801021, 0x10400006, 0x0,
-0x8f42030c, 0x24420001, 0xaf42030c, 0x10000008,
-0x8f42030c, 0x8f820044, 0x34420004, 0xaf820044,
-0x8f420308, 0x24420001, 0xaf420308, 0x8f420308,
-0x3c010001, 0x370821, 0xa02040f0, 0x3c010001,
-0x370821, 0xa02040f1, 0x8f420000, 0x10400007,
-0x0, 0xaf80004c, 0x8f82004c, 0x1040fffd,
-0x0, 0x10000005, 0x0, 0xaf800048,
-0x8f820048, 0x1040fffd, 0x0, 0x8f820060,
-0x3c03ff7f, 0x3463ffff, 0x431024, 0xaf820060,
-0x8f420000, 0x10400003, 0x0, 0x10000002,
-0xaf80004c, 0xaf800048, 0x8fbf0020, 0x3e00008,
-0x27bd0028, 0x3e00008, 0x0, 0x27bdffd8,
-0xafbf0020, 0x8f430044, 0x8f42007c, 0x10620029,
-0x24070008, 0x8f440168, 0x8f45016c, 0x8f48000c,
-0x8f860120, 0x24020040, 0xafa20010, 0xafa30014,
-0xafa80018, 0x8f42010c, 0x40f809, 0x24c6001c,
-0x14400011, 0x24020001, 0x3c010001, 0x370821,
-0xa02240f2, 0x8f820124, 0xafa20010, 0x8f820128,
-0x3c040001, 0x2484382c, 0xafa20014, 0x8f460044,
-0x8f870120, 0x3c050009, 0xc0029e7, 0x34a51300,
-0x1000000f, 0x0, 0x8f420304, 0x24420001,
-0xaf420304, 0x8f420304, 0x8f420044, 0xaf42007c,
-0x3c010001, 0x370821, 0xa02040f2, 0x10000004,
-0xaf400078, 0x3c010001, 0x370821, 0xa02040f2,
-0x8f420000, 0x10400007, 0x0, 0xaf80004c,
-0x8f82004c, 0x1040fffd, 0x0, 0x10000005,
-0x0, 0xaf800048, 0x8f820048, 0x1040fffd,
-0x0, 0x8f820060, 0x3c03feff, 0x3463ffff,
-0x431024, 0xaf820060, 0x8f420000, 0x10400003,
-0x0, 0x10000002, 0xaf80004c, 0xaf800048,
-0x8fbf0020, 0x3e00008, 0x27bd0028, 0x3e00008,
-0x0, 0x3c020001, 0x8c424398, 0x27bdffa8,
-0xafbf0050, 0xafbe004c, 0xafb50048, 0xafb30044,
-0xafb20040, 0xafb1003c, 0xafb00038, 0x104000d5,
-0x8f900044, 0x8f4200d0, 0x24430001, 0x2842000b,
-0x144000e4, 0xaf4300d0, 0x8f420004, 0x30420002,
-0x1440009c, 0xaf4000d0, 0x8f420004, 0x3c030001,
-0x8c634388, 0x34420002, 0xaf420004, 0x24020001,
-0x14620003, 0x3c020600, 0x10000002, 0x34423000,
-0x34421000, 0xafa20020, 0x8f4a0018, 0xafaa0034,
-0x27aa0020, 0xafaa002c, 0x8faa0034, 0x240200ff,
-0x11420002, 0x1821, 0x25430001, 0x8c020228,
-0x609821, 0x1662000e, 0x3c050009, 0x8f42033c,
-0x24420001, 0xaf42033c, 0x8f42033c, 0x8c020228,
-0x8fa70034, 0x3c040001, 0x248437fc, 0xafa00014,
-0xafa20010, 0x8fa60020, 0x10000070, 0x34a50500,
-0x8faa0034, 0xa38c0, 0xf71021, 0x8fa30020,
-0x8fa40024, 0xac4304c0, 0xac4404c4, 0x8f830054,
-0x8f820054, 0x247103e8, 0x2221023, 0x2c4203e9,
-0x1040001b, 0xa821, 0xe09021, 0x265e04c0,
-0x8f440178, 0x8f45017c, 0x2401821, 0x240a0004,
-0xafaa0010, 0xafb30014, 0x8f48000c, 0x1021,
-0x2fe3021, 0xafa80018, 0x8f48010c, 0x24070008,
-0xa32821, 0xa3482b, 0x822021, 0x100f809,
-0x892021, 0x54400006, 0x24150001, 0x8f820054,
-0x2221023, 0x2c4203e9, 0x1440ffe9, 0x0,
-0x32a200ff, 0x54400018, 0xaf530018, 0x8f420378,
-0x24420001, 0xaf420378, 0x8f420378, 0x8f820120,
-0x8faa002c, 0x8fa70034, 0xafa20010, 0x8f820124,
-0x3c040001, 0x24843808, 0xafa20014, 0x8d460000,
-0x3c050009, 0x10000035, 0x34a50600, 0x8f420308,
-0x24150001, 0x24420001, 0xaf420308, 0x8f420308,
-0x1000001e, 0x32a200ff, 0x8f830054, 0x8f820054,
-0x247103e8, 0x2221023, 0x2c4203e9, 0x10400016,
-0xa821, 0x3c1e0020, 0x24120010, 0x8f42000c,
-0x8f440160, 0x8f450164, 0x8f860120, 0xafb20010,
-0xafb30014, 0x5e1025, 0xafa20018, 0x8f42010c,
-0x24070008, 0x40f809, 0x24c6001c, 0x1440ffe3,
-0x0, 0x8f820054, 0x2221023, 0x2c4203e9,
-0x1440ffee, 0x0, 0x32a200ff, 0x14400011,
-0x3c050009, 0x8f420378, 0x24420001, 0xaf420378,
-0x8f420378, 0x8f820120, 0x8faa002c, 0x8fa70034,
-0xafa20010, 0x8f820124, 0x3c040001, 0x24843810,
-0xafa20014, 0x8d460000, 0x34a50700, 0xc0029e7,
-0x0, 0x8f4202ec, 0x24420001, 0xaf4202ec,
-0x8f4202ec, 0x8f420004, 0x30420001, 0x50400029,
-0x36100040, 0x3c020400, 0x2c21024, 0x10400013,
-0x2404ffdf, 0x8f420250, 0x8f430254, 0x8f4401b4,
-0x14640006, 0x36100040, 0x8f420270, 0x8f430274,
-0x8f4401b8, 0x10640007, 0x2402ffdf, 0x8f420250,
-0x8f430254, 0x8f440270, 0x8f450274, 0x10000012,
-0x3a100020, 0x1000002b, 0x2028024, 0x8f420250,
-0x8f430254, 0x8f4501b4, 0x14650006, 0x2048024,
-0x8f420270, 0x8f430274, 0x8f4401b8, 0x50640021,
-0x36100040, 0x8f420250, 0x8f430254, 0x8f440270,
-0x8f450274, 0x3a100040, 0xaf4301b4, 0x10000019,
-0xaf4501b8, 0x8f4200d4, 0x24430001, 0x10000011,
-0x28420033, 0x8f420004, 0x30420001, 0x10400009,
-0x3c020400, 0x2c21024, 0x10400004, 0x2402ffdf,
-0x2028024, 0x1000000b, 0x36100040, 0x10000009,
-0x36100060, 0x8f4200d4, 0x36100040, 0x24430001,
-0x284201f5, 0x14400003, 0xaf4300d4, 0xaf4000d4,
-0x3a100020, 0xaf900044, 0x2402ff7f, 0x282a024,
-0x8fbf0050, 0x8fbe004c, 0x8fb50048, 0x8fb30044,
-0x8fb20040, 0x8fb1003c, 0x8fb00038, 0x3e00008,
-0x27bd0058, 0x3e00008, 0x0, 0x3c020001,
-0x8c424398, 0x27bdffb0, 0xafbf0048, 0xafbe0044,
-0xafb50040, 0xafb3003c, 0xafb20038, 0xafb10034,
-0x104000de, 0xafb00030, 0x8f4200d0, 0x3c040001,
-0x8c844388, 0x24430001, 0x2842000b, 0xaf4400e8,
-0x144000fe, 0xaf4300d0, 0x8f420004, 0x30420002,
-0x14400095, 0xaf4000d0, 0x8f420004, 0x34420002,
-0xaf420004, 0x24020001, 0x14820003, 0x3c020600,
-0x10000002, 0x34423000, 0x34421000, 0xafa20020,
-0x1821, 0x8f5e0018, 0x27aa0020, 0x240200ff,
-0x13c20002, 0xafaa002c, 0x27c30001, 0x8c020228,
-0x609021, 0x1642000e, 0x1e38c0, 0x8f42033c,
-0x24420001, 0xaf42033c, 0x8f42033c, 0x8c020228,
-0x3c040001, 0x248437fc, 0x3c050009, 0xafa00014,
-0xafa20010, 0x8fa60020, 0x1000006d, 0x34a50500,
-0xf71021, 0x8fa30020, 0x8fa40024, 0xac4304c0,
-0xac4404c4, 0x8f830054, 0x8f820054, 0x247003e8,
-0x2021023, 0x2c4203e9, 0x1040001b, 0x9821,
-0xe08821, 0x263504c0, 0x8f440178, 0x8f45017c,
-0x2201821, 0x240a0004, 0xafaa0010, 0xafb20014,
-0x8f48000c, 0x1021, 0x2f53021, 0xafa80018,
-0x8f48010c, 0x24070008, 0xa32821, 0xa3482b,
-0x822021, 0x100f809, 0x892021, 0x54400006,
-0x24130001, 0x8f820054, 0x2021023, 0x2c4203e9,
-0x1440ffe9, 0x0, 0x326200ff, 0x54400017,
-0xaf520018, 0x8f420378, 0x24420001, 0xaf420378,
-0x8f420378, 0x8f820120, 0x8faa002c, 0xafa20010,
-0x8f820124, 0x3c040001, 0x24843808, 0x3c050009,
-0xafa20014, 0x8d460000, 0x10000035, 0x34a50600,
-0x8f420308, 0x24130001, 0x24420001, 0xaf420308,
-0x8f420308, 0x1000001e, 0x326200ff, 0x8f830054,
-0x8f820054, 0x247003e8, 0x2021023, 0x2c4203e9,
-0x10400016, 0x9821, 0x3c150020, 0x24110010,
-0x8f42000c, 0x8f440160, 0x8f450164, 0x8f860120,
-0xafb10010, 0xafb20014, 0x551025, 0xafa20018,
-0x8f42010c, 0x24070008, 0x40f809, 0x24c6001c,
-0x1440ffe3, 0x0, 0x8f820054, 0x2021023,
-0x2c4203e9, 0x1440ffee, 0x0, 0x326200ff,
-0x14400011, 0x0, 0x8f420378, 0x24420001,
-0xaf420378, 0x8f420378, 0x8f820120, 0x8faa002c,
-0xafa20010, 0x8f820124, 0x3c040001, 0x24843810,
-0x3c050009, 0xafa20014, 0x8d460000, 0x34a50700,
-0xc0029e7, 0x3c03821, 0x8f4202ec, 0x24420001,
-0xaf4202ec, 0x8f4202ec, 0x8f420004, 0x30420001,
-0x10400033, 0x3c020400, 0x2c21024, 0x10400017,
-0x0, 0x934205c0, 0x8f440250, 0x8f450254,
-0x8f4301b4, 0x34420020, 0x14a30006, 0xa34205c0,
-0x8f420270, 0x8f430274, 0x8f4401b8, 0x10640008,
-0x0, 0x8f420250, 0x8f430254, 0x934405c0,
-0x8f460270, 0x8f470274, 0x10000016, 0x38840040,
-0x934205c0, 0x10000048, 0x304200bf, 0x934205c0,
-0x8f440250, 0x8f450254, 0x8f4301b4, 0x304200bf,
-0x14a30006, 0xa34205c0, 0x8f420270, 0x8f430274,
-0x8f4401b8, 0x1064000b, 0x0, 0x8f420250,
-0x8f430254, 0x934405c0, 0x8f460270, 0x8f470274,
-0x38840020, 0xaf4301b4, 0xaf4701b8, 0x10000033,
-0xa34405c0, 0x934205c0, 0x1000002f, 0x34420020,
-0x934205c0, 0x8f4300d4, 0x34420020, 0xa34205c0,
-0x24620001, 0x10000023, 0x28630033, 0x8f4200e4,
-0x8f4300e0, 0x24420001, 0xaf4200e4, 0x43102a,
-0x14400006, 0x24030001, 0x8f4200e8, 0x14430002,
-0xaf4000e4, 0x24030004, 0xaf4300e8, 0x8f420004,
-0x30420001, 0x1040000d, 0x3c020400, 0x2c21024,
-0x10400007, 0x0, 0x934205c0, 0x34420040,
-0xa34205c0, 0x934205c0, 0x1000000f, 0x304200df,
-0x934205c0, 0x1000000c, 0x34420060, 0x934205c0,
-0x8f4300d4, 0x34420020, 0xa34205c0, 0x24620001,
-0x286300fb, 0x14600005, 0xaf4200d4, 0x934205c0,
-0xaf4000d4, 0x38420040, 0xa34205c0, 0x934205c0,
-0x8f4300e8, 0x3042007f, 0xa34205c0, 0x24020001,
-0x14620005, 0x0, 0x934405c0, 0x42102,
-0x10000003, 0x348400f0, 0x934405c0, 0x3484000f,
-0xc004c28, 0x0, 0x2402ff7f, 0x282a024,
-0x8fbf0048, 0x8fbe0044, 0x8fb50040, 0x8fb3003c,
-0x8fb20038, 0x8fb10034, 0x8fb00030, 0x3e00008,
-0x27bd0050, 0x3e00008, 0x0, 0x27bdffb0,
-0x274401c0, 0x26e30028, 0x24650400, 0x65102b,
-0xafbf0048, 0xafbe0044, 0xafb50040, 0xafb3003c,
-0xafb20038, 0xafb10034, 0x10400007, 0xafb00030,
-0x8c820000, 0xac620000, 0x24630004, 0x65102b,
-0x1440fffb, 0x24840004, 0x8c020080, 0xaee20044,
-0x8c0200c0, 0xaee20040, 0x8c020084, 0xaee20030,
-0x8c020084, 0xaee2023c, 0x8c020088, 0xaee20240,
-0x8c02008c, 0xaee20244, 0x8c020090, 0xaee20248,
-0x8c020094, 0xaee2024c, 0x8c020098, 0xaee20250,
-0x8c02009c, 0xaee20254, 0x8c0200a0, 0xaee20258,
-0x8c0200a4, 0xaee2025c, 0x8c0200a8, 0xaee20260,
-0x8c0200ac, 0xaee20264, 0x8c0200b0, 0xaee20268,
-0x8c0200b4, 0xaee2026c, 0x8c0200b8, 0xaee20270,
-0x8c0200bc, 0x24040001, 0xaee20274, 0xaee00034,
-0x41080, 0x571021, 0x8ee30034, 0x8c42023c,
-0x24840001, 0x621821, 0x2c82000f, 0xaee30034,
-0x1440fff8, 0x41080, 0x8c0200cc, 0xaee20048,
-0x8c0200d0, 0xaee2004c, 0x8c0200e0, 0xaee201f8,
-0x8c0200e4, 0xaee201fc, 0x8c0200e8, 0xaee20200,
-0x8c0200ec, 0xaee20204, 0x8c0200f0, 0xaee20208,
-0x8ee400c0, 0x8ee500c4, 0x8c0200fc, 0x45102b,
-0x1040000b, 0x0, 0x8ee200c0, 0x8ee300c4,
-0x24040001, 0x24050000, 0x651821, 0x65302b,
-0x441021, 0x461021, 0xaee200c0, 0xaee300c4,
-0x8c0200fc, 0x8ee400c0, 0x8ee500c4, 0x2408ffff,
-0x24090000, 0x401821, 0x1021, 0x882024,
-0xa92824, 0x822025, 0xa32825, 0xaee400c0,
-0xaee500c4, 0x8ee400d0, 0x8ee500d4, 0x8c0200f4,
-0x45102b, 0x1040000b, 0x0, 0x8ee200d0,
-0x8ee300d4, 0x24040001, 0x24050000, 0x651821,
-0x65302b, 0x441021, 0x461021, 0xaee200d0,
-0xaee300d4, 0x8c0200f4, 0x8ee400d0, 0x8ee500d4,
-0x401821, 0x1021, 0x882024, 0xa92824,
-0x822025, 0xa32825, 0xaee400d0, 0xaee500d4,
-0x8ee400c8, 0x8ee500cc, 0x8c0200f8, 0x45102b,
-0x1040000b, 0x0, 0x8ee200c8, 0x8ee300cc,
-0x24040001, 0x24050000, 0x651821, 0x65302b,
-0x441021, 0x461021, 0xaee200c8, 0xaee300cc,
-0x8c0200f8, 0x8ee400c8, 0x8ee500cc, 0x401821,
-0x1021, 0x882024, 0xa92824, 0x822025,
-0xa32825, 0x24020008, 0xaee400c8, 0xaee500cc,
-0xafa20010, 0xafa00014, 0x8f42000c, 0x8c040208,
-0x8c05020c, 0xafa20018, 0x8f42010c, 0x26e60028,
-0x40f809, 0x24070400, 0x104000f0, 0x3c020400,
-0xafa20020, 0x934205c6, 0x10400089, 0x1821,
-0x8f5e0018, 0x27aa0020, 0x240200ff, 0x13c20002,
-0xafaa002c, 0x27c30001, 0x8c020228, 0x609021,
-0x1642000e, 0x1e38c0, 0x8f42033c, 0x24420001,
-0xaf42033c, 0x8f42033c, 0x8c020228, 0x3c040001,
-0x248437fc, 0x3c050009, 0xafa00014, 0xafa20010,
-0x8fa60020, 0x1000006b, 0x34a50500, 0xf71021,
-0x8fa30020, 0x8fa40024, 0xac4304c0, 0xac4404c4,
-0x8f830054, 0x8f820054, 0x247003e8, 0x2021023,
-0x2c4203e9, 0x1040001b, 0x9821, 0xe08821,
-0x263504c0, 0x8f440178, 0x8f45017c, 0x2201821,
-0x240a0004, 0xafaa0010, 0xafb20014, 0x8f48000c,
-0x1021, 0x2f53021, 0xafa80018, 0x8f48010c,
-0x24070008, 0xa32821, 0xa3482b, 0x822021,
-0x100f809, 0x892021, 0x54400006, 0x24130001,
-0x8f820054, 0x2021023, 0x2c4203e9, 0x1440ffe9,
-0x0, 0x326200ff, 0x54400017, 0xaf520018,
-0x8f420378, 0x24420001, 0xaf420378, 0x8f420378,
-0x8f820120, 0x8faa002c, 0xafa20010, 0x8f820124,
-0x3c040001, 0x24843808, 0x3c050009, 0xafa20014,
-0x8d460000, 0x10000033, 0x34a50600, 0x8f420308,
-0x24130001, 0x24420001, 0xaf420308, 0x8f420308,
-0x1000001c, 0x326200ff, 0x8f830054, 0x8f820054,
-0x247003e8, 0x2021023, 0x2c4203e9, 0x10400014,
-0x9821, 0x24110010, 0x8f42000c, 0x8f440160,
-0x8f450164, 0x8f860120, 0xafb10010, 0xafb20014,
-0xafa20018, 0x8f42010c, 0x24070008, 0x40f809,
-0x24c6001c, 0x1440ffe5, 0x0, 0x8f820054,
-0x2021023, 0x2c4203e9, 0x1440ffef, 0x0,
-0x326200ff, 0x54400012, 0x24020001, 0x8f420378,
-0x24420001, 0xaf420378, 0x8f420378, 0x8f820120,
-0x8faa002c, 0xafa20010, 0x8f820124, 0x3c040001,
-0x24843810, 0x3c050009, 0xafa20014, 0x8d460000,
-0x34a50700, 0xc0029e7, 0x3c03821, 0x1021,
-0x1440005b, 0x24020001, 0x10000065, 0x0,
-0x8f510018, 0x240200ff, 0x12220002, 0x8021,
-0x26300001, 0x8c020228, 0x1602000e, 0x1130c0,
-0x8f42033c, 0x24420001, 0xaf42033c, 0x8f42033c,
-0x8c020228, 0x3c040001, 0x248437e4, 0x3c050009,
-0xafa00014, 0xafa20010, 0x8fa60020, 0x1000003f,
-0x34a50100, 0xd71021, 0x8fa30020, 0x8fa40024,
-0xac4304c0, 0xac4404c4, 0xc01821, 0x8f440178,
-0x8f45017c, 0x1021, 0x24070004, 0xafa70010,
-0xafb00014, 0x8f48000c, 0x24c604c0, 0x2e63021,
-0xafa80018, 0x8f48010c, 0x24070008, 0xa32821,
-0xa3482b, 0x822021, 0x100f809, 0x892021,
-0x1440000b, 0x24070008, 0x8f820120, 0xafa20010,
-0x8f820124, 0x3c040001, 0x248437ec, 0x3c050009,
-0xafa20014, 0x8fa60020, 0x1000001c, 0x34a50200,
-0x8f440160, 0x8f450164, 0x8f43000c, 0xaf500018,
-0x8f860120, 0x24020010, 0xafa20010, 0xafb00014,
-0xafa30018, 0x8f42010c, 0x40f809, 0x24c6001c,
-0x54400011, 0x24020001, 0x8f420340, 0x24420001,
-0xaf420340, 0x8f420340, 0x8f820120, 0xafa20010,
-0x8f820124, 0x3c040001, 0x248437f4, 0x3c050009,
-0xafa20014, 0x8fa60020, 0x34a50300, 0xc0029e7,
-0x2203821, 0x1021, 0x1040000d, 0x24020001,
-0x8f4202e8, 0xa34005c6, 0xaf4001b0, 0x24420001,
-0xaf4202e8, 0x8f4202e8, 0x8ee20150, 0x24420001,
-0xaee20150, 0x10000003, 0x8ee20150, 0x24020001,
-0xa34205c6, 0x8fbf0048, 0x8fbe0044, 0x8fb50040,
-0x8fb3003c, 0x8fb20038, 0x8fb10034, 0x8fb00030,
-0x3e00008, 0x27bd0050, 0x27bdffd8, 0xafbf0020,
-0x8f8200b0, 0x30420004, 0x10400068, 0x0,
-0x8f430128, 0x8f820104, 0x14620005, 0x0,
-0x8f430130, 0x8f8200b4, 0x10620006, 0x0,
-0x8f820104, 0xaf420128, 0x8f8200b4, 0x1000005b,
-0xaf420130, 0x8f8200b0, 0x3c030080, 0x431024,
-0x1040000d, 0x0, 0x8f82011c, 0x34420002,
-0xaf82011c, 0x8f8200b0, 0x2403fffb, 0x431024,
-0xaf8200b0, 0x8f82011c, 0x2403fffd, 0x431024,
-0x1000004a, 0xaf82011c, 0x8f430128, 0x8f820104,
-0x14620005, 0x0, 0x8f430130, 0x8f8200b4,
-0x10620010, 0x0, 0x8f820104, 0xaf420128,
-0x8f8200b4, 0x8f430128, 0xaf420130, 0xafa30010,
-0x8f420130, 0x3c040001, 0x24843834, 0xafa20014,
-0x8f86011c, 0x8f8700b0, 0x3c050005, 0x10000031,
-0x34a50900, 0x8f420128, 0xafa20010, 0x8f420130,
-0x3c040001, 0x24843840, 0xafa20014, 0x8f86011c,
-0x8f8700b0, 0x3c050005, 0xc0029e7, 0x34a51000,
-0x8f82011c, 0x34420002, 0xaf82011c, 0x8f830104,
-0x8f8200b0, 0x34420001, 0xaf8200b0, 0x24020008,
-0xaf830104, 0xafa20010, 0xafa00014, 0x8f42000c,
-0x8c040208, 0x8c05020c, 0xafa20018, 0x8f42010c,
-0x26e60028, 0x40f809, 0x24070400, 0x8f82011c,
-0x2403fffd, 0x431024, 0xaf82011c, 0x8ee201dc,
-0x24420001, 0xaee201dc, 0x8ee201dc, 0x8f420128,
-0xafa20010, 0x8f420130, 0x3c040001, 0x2484384c,
-0xafa20014, 0x8f86011c, 0x8f8700b0, 0x3c050005,
-0x34a51100, 0xc0029e7, 0x0, 0x8f8200a0,
-0x30420004, 0x10400069, 0x0, 0x8f43012c,
-0x8f820124, 0x14620005, 0x0, 0x8f430134,
-0x8f8200a4, 0x10620006, 0x0, 0x8f820124,
-0xaf42012c, 0x8f8200a4, 0x1000005c, 0xaf420134,
-0x8f8200a0, 0x3c030080, 0x431024, 0x1040000d,
-0x0, 0x8f82011c, 0x34420002, 0xaf82011c,
-0x8f8200a0, 0x2403fffb, 0x431024, 0xaf8200a0,
-0x8f82011c, 0x2403fffd, 0x431024, 0x1000004b,
-0xaf82011c, 0x8f43012c, 0x8f820124, 0x14620005,
-0x0, 0x8f430134, 0x8f8200a4, 0x10620010,
-0x0, 0x8f820124, 0xaf42012c, 0x8f8200a4,
-0x8f43012c, 0xaf420134, 0xafa30010, 0x8f420134,
-0x3c040001, 0x24843858, 0xafa20014, 0x8f86011c,
-0x8f8700a0, 0x3c050005, 0x10000032, 0x34a51200,
-0x8f42012c, 0xafa20010, 0x8f420134, 0x3c040001,
-0x24843864, 0xafa20014, 0x8f86011c, 0x8f8700a0,
-0x3c050005, 0xc0029e7, 0x34a51300, 0x8f82011c,
-0x34420002, 0xaf82011c, 0x8f830124, 0x8f8200a0,
-0x34420001, 0xaf8200a0, 0x24020080, 0xaf830124,
-0xafa20010, 0xafa00014, 0x8f420014, 0x8c040208,
-0x8c05020c, 0xafa20018, 0x8f420108, 0x3c060001,
-0x24c64494, 0x40f809, 0x24070004, 0x8f82011c,
-0x2403fffd, 0x431024, 0xaf82011c, 0x8ee201dc,
-0x24420001, 0xaee201dc, 0x8ee201dc, 0x8f42012c,
-0xafa20010, 0x8f420134, 0x3c040001, 0x24843870,
-0xafa20014, 0x8f86011c, 0x8f8700a0, 0x3c050005,
-0x34a51400, 0xc0029e7, 0x0, 0x8fbf0020,
-0x3e00008, 0x27bd0028, 0x3c081000, 0x24070001,
-0x3c060080, 0x3c050100, 0x8f820070, 0x481024,
-0x1040fffd, 0x0, 0x8f820054, 0x24420005,
-0xaf820078, 0x8c040234, 0x10800016, 0x1821,
-0x3c020001, 0x571021, 0x8c4240e8, 0x24420005,
-0x3c010001, 0x370821, 0xac2240e8, 0x3c020001,
-0x571021, 0x8c4240e8, 0x44102b, 0x14400009,
-0x0, 0x3c030080, 0x3c010001, 0x370821,
-0xac2040e8, 0x3c010001, 0x370821, 0x1000000b,
-0xa02740f0, 0x3c020001, 0x571021, 0x904240f0,
-0x54400006, 0x661825, 0x3c020001, 0x571021,
-0x904240f1, 0x54400001, 0x661825, 0x8c040230,
-0x10800013, 0x0, 0x3c020001, 0x571021,
-0x8c4240ec, 0x24420005, 0x3c010001, 0x370821,
-0xac2240ec, 0x3c020001, 0x571021, 0x8c4240ec,
-0x44102b, 0x14400006, 0x0, 0x3c010001,
-0x370821, 0xac2040ec, 0x10000006, 0x651825,
-0x3c020001, 0x571021, 0x904240f2, 0x54400001,
-0x651825, 0x1060ffbc, 0x0, 0x8f420000,
-0x10400007, 0x0, 0xaf80004c, 0x8f82004c,
-0x1040fffd, 0x0, 0x10000005, 0x0,
-0xaf800048, 0x8f820048, 0x1040fffd, 0x0,
-0x8f820060, 0x431025, 0xaf820060, 0x8f420000,
-0x10400003, 0x0, 0x1000ffa7, 0xaf80004c,
-0x1000ffa5, 0xaf800048, 0x3e00008, 0x0,
-0x0, 0x0, 0x0, 0x27bdffe0,
-0xafbf0018, 0x8f860064, 0x30c20004, 0x10400025,
-0x24040004, 0x8c020114, 0xaf420020, 0xaf840064,
-0x8f4202fc, 0x24420001, 0xaf4202fc, 0x8f4202fc,
-0x8f820064, 0x30420004, 0x14400005, 0x0,
-0x8c030114, 0x8f420020, 0x1462fff2, 0x0,
-0x8f420000, 0x10400007, 0x8f43003c, 0xaf80004c,
-0x8f82004c, 0x1040fffd, 0x0, 0x10000005,
-0x0, 0xaf800048, 0x8f820048, 0x1040fffd,
-0x0, 0x8f820060, 0x431025, 0xaf820060,
-0x8f420000, 0x10400073, 0x0, 0x1000006f,
-0x0, 0x30c20008, 0x10400020, 0x24040008,
-0x8c02011c, 0xaf420048, 0xaf840064, 0x8f4202a8,
-0x24420001, 0xaf4202a8, 0x8f4202a8, 0x8f820064,
-0x30420008, 0x14400005, 0x0, 0x8c03011c,
-0x8f420048, 0x1462fff2, 0x0, 0x8f420000,
-0x10400007, 0x0, 0xaf80004c, 0x8f82004c,
-0x1040fffd, 0x0, 0x10000005, 0x0,
-0xaf800048, 0x8f820048, 0x1040fffd, 0x0,
-0x8f820060, 0x1000ffd9, 0x34420200, 0x30c20020,
-0x10400023, 0x24040020, 0x8c02012c, 0xaf420068,
-0xaf840064, 0x8f4202d8, 0x24420001, 0xaf4202d8,
-0x8f4202d8, 0x8f820064, 0x30420020, 0x14400005,
-0x32c24000, 0x8c03012c, 0x8f420068, 0x1462fff2,
-0x32c24000, 0x14400002, 0x3c020001, 0x2c2b025,
-0x8f420000, 0x10400007, 0x0, 0xaf80004c,
-0x8f82004c, 0x1040fffd, 0x0, 0x10000005,
-0x0, 0xaf800048, 0x8f820048, 0x1040fffd,
-0x0, 0x8f820060, 0x1000ffb4, 0x34420800,
-0x30c20010, 0x10400029, 0x24040010, 0x8c020124,
-0xaf420058, 0xaf840064, 0x8f4202d4, 0x24420001,
-0xaf4202d4, 0x8f4202d4, 0x8f820064, 0x30420010,
-0x14400005, 0x32c22000, 0x8c030124, 0x8f420058,
-0x1462fff2, 0x32c22000, 0x50400001, 0x36d68000,
-0x8f420000, 0x10400007, 0x0, 0xaf80004c,
-0x8f82004c, 0x1040fffd, 0x0, 0x10000005,
-0x0, 0xaf800048, 0x8f820048, 0x1040fffd,
-0x0, 0x8f820060, 0x34420100, 0xaf820060,
-0x8f420000, 0x10400003, 0x0, 0x1000006c,
-0xaf80004c, 0x1000006a, 0xaf800048, 0x30c20001,
-0x10400004, 0x24020001, 0xaf820064, 0x10000064,
-0x0, 0x30c20002, 0x1440000b, 0x3c050003,
-0x3c040001, 0x24843934, 0x34a50500, 0x3821,
-0xafa00010, 0xc0029e7, 0xafa00014, 0x2402ffc0,
-0x10000057, 0xaf820064, 0x8c05022c, 0x8c02010c,
-0x10a20048, 0x51080, 0x8c460300, 0x24a20001,
-0x3045003f, 0x24020003, 0xac05022c, 0x61e02,
-0x10620005, 0x24020010, 0x1062001d, 0x30c20fff,
-0x10000039, 0x0, 0x8f4302a8, 0x8f440000,
-0x30c20fff, 0xaf420048, 0x24630001, 0xaf4302a8,
-0x10800007, 0x8f4202a8, 0xaf80004c, 0x8f82004c,
-0x1040fffd, 0x0, 0x10000005, 0x0,
-0xaf800048, 0x8f820048, 0x1040fffd, 0x0,
-0x8f820060, 0x34420200, 0xaf820060, 0x8f420000,
-0x1040001f, 0x0, 0x1000001b, 0x0,
-0xaf420058, 0x32c22000, 0x50400001, 0x36d68000,
-0x8f4202d4, 0x8f430000, 0x24420001, 0xaf4202d4,
-0x10600007, 0x8f4202d4, 0xaf80004c, 0x8f82004c,
-0x1040fffd, 0x0, 0x10000005, 0x0,
-0xaf800048, 0x8f820048, 0x1040fffd, 0x0,
-0x8f820060, 0x34420100, 0xaf820060, 0x8f420000,
-0x10400003, 0x0, 0x10000006, 0xaf80004c,
-0x10000004, 0xaf800048, 0xc002052, 0xc02021,
-0x402821, 0x8c02010c, 0x14a20002, 0x24020002,
-0xaf820064, 0x8f820064, 0x30420002, 0x14400004,
-0x0, 0x8c02010c, 0x14a2ffac, 0x0,
-0x8fbf0018, 0x3e00008, 0x27bd0020, 0x3e00008,
-0x0, 0x27bdffa0, 0xafb00040, 0x808021,
-0x101602, 0x2442ffff, 0x304300ff, 0x2c620013,
-0xafbf0058, 0xafbe0054, 0xafb50050, 0xafb3004c,
-0xafb20048, 0xafb10044, 0x104001ec, 0xafa50034,
-0x31080, 0x3c010001, 0x220821, 0x8c223978,
-0x400008, 0x0, 0x101302, 0x30440fff,
-0x24020001, 0x10820005, 0x24020002, 0x1082000a,
-0x2402fffe, 0x10000021, 0x3c050003, 0x8f430004,
-0x3c020001, 0x8c4244c0, 0xaf440200, 0xaf440204,
-0x10000007, 0x34630001, 0x8f430004, 0xaf440200,
-0xaf440204, 0x621824, 0x3c020001, 0x2442c508,
-0x21100, 0x21182, 0xaf430004, 0x3c030800,
-0x431025, 0x3c010000, 0xac224138, 0x8f840054,
-0x41442, 0x41c82, 0x431021, 0x41cc2,
-0x431023, 0x41d02, 0x431021, 0x41d42,
-0x431023, 0x10000009, 0xaf420208, 0x3c040001,
-0x24843940, 0x34a51000, 0x2003021, 0x3821,
-0xafa00010, 0xc0029e7, 0xafa00014, 0x8f4202a0,
-0x24420001, 0xaf4202a0, 0x1000021b, 0x8f4202a0,
-0x27b00028, 0x2002021, 0x24050210, 0xc002a6b,
-0x24060008, 0xc0023c7, 0x2002021, 0x10000212,
-0x0, 0x8faa0034, 0x27a40028, 0xa1880,
-0x25420001, 0x3042003f, 0xafa20034, 0x8c650300,
-0x8faa0034, 0x21080, 0x8c430300, 0x25420001,
-0x3042003f, 0xafa20034, 0xac02022c, 0xafa50028,
-0xc0023c7, 0xafa3002c, 0x100001ff, 0x0,
-0x27b00028, 0x2002021, 0x24050210, 0xc002a6b,
-0x24060008, 0xc002506, 0x2002021, 0x100001f6,
-0x0, 0x8faa0034, 0x27a40028, 0xa1880,
-0x25420001, 0x3042003f, 0xafa20034, 0x8c650300,
-0x8faa0034, 0x21080, 0x8c430300, 0x25420001,
-0x3042003f, 0xafa20034, 0xac02022c, 0xafa50028,
-0xc002506, 0xafa3002c, 0x100001e3, 0x0,
-0x101302, 0x30430fff, 0x24020001, 0x10620005,
-0x24020002, 0x1062001e, 0x3c020002, 0x10000033,
-0x3c050003, 0x3c030002, 0x2c31024, 0x54400037,
-0x2c3b025, 0x8f820228, 0x3c010001, 0x370821,
-0xac2238d8, 0x8f82022c, 0x3c010001, 0x370821,
-0xac2238dc, 0x8f820230, 0x3c010001, 0x370821,
-0xac2238e0, 0x8f820234, 0x3c010001, 0x370821,
-0xac2238e4, 0x2402ffff, 0xaf820228, 0xaf82022c,
-0xaf820230, 0xaf820234, 0x10000020, 0x2c3b025,
-0x2c21024, 0x10400012, 0x3c02fffd, 0x3c020001,
-0x571021, 0x8c4238d8, 0xaf820228, 0x3c020001,
-0x571021, 0x8c4238dc, 0xaf82022c, 0x3c020001,
-0x571021, 0x8c4238e0, 0xaf820230, 0x3c020001,
-0x571021, 0x8c4238e4, 0xaf820234, 0x3c02fffd,
-0x3442ffff, 0x10000009, 0x2c2b024, 0x3c040001,
-0x2484394c, 0x34a51100, 0x2003021, 0x3821,
-0xafa00010, 0xc0029e7, 0xafa00014, 0x8f4202cc,
-0x24420001, 0xaf4202cc, 0x1000019b, 0x8f4202cc,
-0x101302, 0x30450fff, 0x24020001, 0x10a20005,
-0x24020002, 0x10a2000d, 0x3c0408ff, 0x10000014,
-0x3c050003, 0x3c0208ff, 0x3442ffff, 0x8f830220,
-0x3c040004, 0x2c4b025, 0x621824, 0x34630008,
-0xaf830220, 0x10000012, 0xaf450298, 0x3484fff7,
-0x3c03fffb, 0x8f820220, 0x3463ffff, 0x2c3b024,
-0x441024, 0xaf820220, 0x10000009, 0xaf450298,
-0x3c040001, 0x24843958, 0x34a51200, 0x2003021,
-0x3821, 0xafa00010, 0xc0029e7, 0xafa00014,
-0x8f4202bc, 0x24420001, 0xaf4202bc, 0x10000172,
-0x8f4202bc, 0x27840208, 0x24050200, 0xc002a6b,
-0x24060008, 0x27440224, 0x24050200, 0xc002a6b,
-0x24060008, 0x8f4202c4, 0x24420001, 0xaf4202c4,
-0x10000165, 0x8f4202c4, 0x101302, 0x30430fff,
-0x24020001, 0x10620011, 0x28620002, 0x50400005,
-0x24020002, 0x10600007, 0x0, 0x10000017,
-0x0, 0x1062000f, 0x0, 0x10000013,
-0x0, 0x8c060248, 0x2021, 0xc004998,
-0x24050004, 0x10000007, 0x0, 0x8c060248,
-0x2021, 0xc004998, 0x24050004, 0x10000010,
-0x0, 0x8c06024c, 0x2021, 0xc004998,
-0x24050001, 0x1000000a, 0x0, 0x3c040001,
-0x24843964, 0x3c050003, 0x34a51300, 0x2003021,
-0x3821, 0xafa00010, 0xc0029e7, 0xafa00014,
-0x8f4202c0, 0x24420001, 0xaf4202c0, 0x10000136,
-0x8f4202c0, 0xc0022db, 0x0, 0x10000132,
-0x0, 0x24020001, 0xa34205c5, 0x24100100,
-0x8f4401a8, 0x8f4501ac, 0xafb00010, 0xafa00014,
-0x8f420014, 0xafa20018, 0x8f420108, 0x26e60028,
-0x40f809, 0x24070400, 0x1040fff5, 0x0,
-0x10000121, 0x0, 0x3c02ffff, 0x34427fff,
-0x2c2b024, 0x1821, 0x3c020900, 0xaf400058,
-0xaf40005c, 0xaf400060, 0xaf400064, 0xaf400360,
-0xafa20020, 0x8f5e0018, 0x27aa0020, 0x240200ff,
-0x13c20002, 0xafaa003c, 0x27c30001, 0x8c020228,
-0x609021, 0x1642000e, 0x1e38c0, 0x8f42033c,
-0x24420001, 0xaf42033c, 0x8f42033c, 0x8c020228,
-0x3c040001, 0x248438fc, 0x3c050009, 0xafa00014,
-0xafa20010, 0x8fa60020, 0x1000006b, 0x34a50500,
-0xf71021, 0x8fa30020, 0x8fa40024, 0xac4304c0,
-0xac4404c4, 0x8f830054, 0x8f820054, 0x247003e8,
-0x2021023, 0x2c4203e9, 0x1040001b, 0x9821,
-0xe08821, 0x263504c0, 0x8f440178, 0x8f45017c,
-0x2201821, 0x240a0004, 0xafaa0010, 0xafb20014,
-0x8f48000c, 0x1021, 0x2f53021, 0xafa80018,
-0x8f48010c, 0x24070008, 0xa32821, 0xa3482b,
-0x822021, 0x100f809, 0x892021, 0x54400006,
-0x24130001, 0x8f820054, 0x2021023, 0x2c4203e9,
-0x1440ffe9, 0x0, 0x326200ff, 0x54400017,
-0xaf520018, 0x8f420378, 0x24420001, 0xaf420378,
-0x8f420378, 0x8f820120, 0x8faa003c, 0xafa20010,
-0x8f820124, 0x3c040001, 0x24843908, 0x3c050009,
-0xafa20014, 0x8d460000, 0x10000033, 0x34a50600,
-0x8f420308, 0x24130001, 0x24420001, 0xaf420308,
-0x8f420308, 0x1000001c, 0x326200ff, 0x8f830054,
-0x8f820054, 0x247003e8, 0x2021023, 0x2c4203e9,
-0x10400014, 0x9821, 0x24110010, 0x8f42000c,
-0x8f440160, 0x8f450164, 0x8f860120, 0xafb10010,
-0xafb20014, 0xafa20018, 0x8f42010c, 0x24070008,
-0x40f809, 0x24c6001c, 0x1440ffe5, 0x0,
-0x8f820054, 0x2021023, 0x2c4203e9, 0x1440ffef,
-0x0, 0x326200ff, 0x14400011, 0x0,
-0x8f420378, 0x24420001, 0xaf420378, 0x8f420378,
-0x8f820120, 0x8faa003c, 0xafa20010, 0x8f820124,
-0x3c040001, 0x24843910, 0x3c050009, 0xafa20014,
-0x8d460000, 0x34a50700, 0xc0029e7, 0x3c03821,
-0x8f4202b0, 0x24420001, 0xaf4202b0, 0x8f4202b0,
-0x8f4202f8, 0x24420001, 0xaf4202f8, 0x1000008a,
-0x8f4202f8, 0x8c02025c, 0x27440224, 0xaf4201f0,
-0x8c020260, 0x24050200, 0x24060008, 0xc002a6b,
-0xaf4201f8, 0x8f820220, 0x30420008, 0x14400002,
-0x24020001, 0x24020002, 0xaf420298, 0x8f4202ac,
-0x24420001, 0xaf4202ac, 0x10000077, 0x8f4202ac,
-0x3c0200ff, 0x3442ffff, 0x2021824, 0x32c20180,
-0x14400006, 0x3402fffb, 0x43102b, 0x14400003,
-0x0, 0x1000006c, 0xaf4300bc, 0x3c040001,
-0x24843970, 0x3c050003, 0x34a51500, 0x2003021,
-0x3821, 0xafa00010, 0xc0029e7, 0xafa00014,
-0x3c020700, 0x34421000, 0x101e02, 0x621825,
-0xafa30020, 0x8f510018, 0x240200ff, 0x12220002,
-0x8021, 0x26300001, 0x8c020228, 0x1602000e,
-0x1130c0, 0x8f42033c, 0x24420001, 0xaf42033c,
-0x8f42033c, 0x8c020228, 0x3c040001, 0x248438e4,
-0x3c050009, 0xafa00014, 0xafa20010, 0x8fa60020,
-0x1000003f, 0x34a50100, 0xd71021, 0x8fa30020,
-0x8fa40024, 0xac4304c0, 0xac4404c4, 0xc01821,
-0x8f440178, 0x8f45017c, 0x1021, 0x24070004,
-0xafa70010, 0xafb00014, 0x8f48000c, 0x24c604c0,
-0x2e63021, 0xafa80018, 0x8f48010c, 0x24070008,
-0xa32821, 0xa3482b, 0x822021, 0x100f809,
-0x892021, 0x1440000b, 0x24070008, 0x8f820120,
-0xafa20010, 0x8f820124, 0x3c040001, 0x248438ec,
-0x3c050009, 0xafa20014, 0x8fa60020, 0x1000001c,
-0x34a50200, 0x8f440160, 0x8f450164, 0x8f43000c,
-0xaf500018, 0x8f860120, 0x24020010, 0xafa20010,
-0xafb00014, 0xafa30018, 0x8f42010c, 0x40f809,
-0x24c6001c, 0x14400010, 0x0, 0x8f420340,
-0x24420001, 0xaf420340, 0x8f420340, 0x8f820120,
-0xafa20010, 0x8f820124, 0x3c040001, 0x248438f4,
-0x3c050009, 0xafa20014, 0x8fa60020, 0x34a50300,
-0xc0029e7, 0x2203821, 0x8f4202e0, 0x24420001,
-0xaf4202e0, 0x8f4202e0, 0x8f4202f0, 0x24420001,
-0xaf4202f0, 0x8f4202f0, 0x8fa20034, 0x8fbf0058,
-0x8fbe0054, 0x8fb50050, 0x8fb3004c, 0x8fb20048,
-0x8fb10044, 0x8fb00040, 0x3e00008, 0x27bd0060,
-0x27bdfff8, 0x2408ffff, 0x10a00014, 0x4821,
-0x3c0aedb8, 0x354a8320, 0x90870000, 0x24840001,
-0x3021, 0x1071026, 0x30420001, 0x10400002,
-0x81842, 0x6a1826, 0x604021, 0x24c60001,
-0x2cc20008, 0x1440fff7, 0x73842, 0x25290001,
-0x125102b, 0x1440fff0, 0x0, 0x1001021,
-0x3e00008, 0x27bd0008, 0x27bdffb8, 0xafbf0040,
-0xafbe003c, 0xafb50038, 0xafb30034, 0xafb20030,
-0xafb1002c, 0xafb00028, 0x8f870220, 0xafa7001c,
-0x8f870200, 0xafa70024, 0x8f820220, 0x3c0308ff,
-0x3463ffff, 0x431024, 0x34420004, 0xaf820220,
-0x8f820200, 0x3c03c0ff, 0x3463ffff, 0x431024,
-0x34420004, 0xaf820200, 0x8f53035c, 0x8f550360,
-0x8f5e0364, 0x8f470368, 0xafa70014, 0x8f4202d0,
-0x274401c0, 0x24420001, 0xaf4202d0, 0x8f5002d0,
-0x8f510204, 0x8f520200, 0xc002a54, 0x24050400,
-0xaf53035c, 0xaf550360, 0xaf5e0364, 0x8fa70014,
-0xaf470368, 0xaf5002d0, 0xaf510204, 0xaf520200,
-0x8c02025c, 0x27440224, 0xaf4201f0, 0x8c020260,
-0x24050200, 0x24060008, 0xaf4201f8, 0x24020006,
-0xc002a6b, 0xaf4201f4, 0x3c023b9a, 0x3442ca00,
-0xaf4201fc, 0x240203e8, 0x24040002, 0x24030001,
-0xaf420294, 0xaf440290, 0xaf43029c, 0x8f820220,
-0x30420008, 0x10400004, 0x0, 0xaf430298,
-0x10000003, 0x3021, 0xaf440298, 0x3021,
-0x3c030001, 0x661821, 0x906342f0, 0x3461021,
-0x24c60001, 0xa043022c, 0x2cc2000f, 0x1440fff8,
-0x3461821, 0x24c60001, 0x8f820040, 0x24040080,
-0x24050080, 0x21702, 0x24420030, 0xa062022c,
-0x3461021, 0xc002a54, 0xa040022c, 0x8fa7001c,
-0x30e20004, 0x14400006, 0x0, 0x8f820220,
-0x3c0308ff, 0x3463fffb, 0x431024, 0xaf820220,
-0x8fa70024, 0x30e20004, 0x14400006, 0x0,
-0x8f820200, 0x3c03c0ff, 0x3463fffb, 0x431024,
-0xaf820200, 0x8fbf0040, 0x8fbe003c, 0x8fb50038,
-0x8fb30034, 0x8fb20030, 0x8fb1002c, 0x8fb00028,
-0x3e00008, 0x27bd0048, 0x0, 0xaf400104,
-0x24040001, 0x410c0, 0x2e21821, 0x24820001,
-0x3c010001, 0x230821, 0xa42234d0, 0x402021,
-0x2c820080, 0x1440fff8, 0x410c0, 0x24020001,
-0x3c010001, 0x370821, 0xa42038d0, 0xaf420100,
-0xaf800228, 0xaf80022c, 0xaf800230, 0x3e00008,
-0xaf800234, 0x27bdffe8, 0xafbf0014, 0xafb00010,
-0x8f420104, 0x28420005, 0x10400026, 0x808021,
-0x3c020001, 0x8f430104, 0x344230d0, 0x2e23021,
-0x318c0, 0x621821, 0x2e33821, 0xc7102b,
-0x10400015, 0x1021, 0x96080000, 0x24c40006,
-0x9482fffc, 0x14480009, 0x2821, 0x9483fffe,
-0x96020002, 0x14620006, 0xa01021, 0x94820000,
-0x96030004, 0x431026, 0x2c450001, 0xa01021,
-0x1440000a, 0x24c60008, 0xc7102b, 0x1440fff0,
-0x24840008, 0x1021, 0x304200ff, 0x14400030,
-0x24020001, 0x1000002e, 0x1021, 0x1000fffa,
-0x24020001, 0x2002021, 0xc0022c1, 0x24050006,
-0x3042007f, 0x218c0, 0x2e31021, 0x3c010001,
-0x220821, 0x942230d0, 0x1040fff2, 0x2e31021,
-0x3c060001, 0xc23021, 0x94c630d0, 0x10c0ffed,
-0x3c080001, 0x350834d2, 0x96070000, 0x610c0,
-0x572021, 0x882021, 0x94820000, 0x14470009,
-0x2821, 0x94830002, 0x96020002, 0x14620006,
-0xa01021, 0x94820004, 0x96030004, 0x431026,
-0x2c450001, 0xa01021, 0x14400007, 0x610c0,
-0x2e21021, 0x3c060001, 0xc23021, 0x94c634d0,
-0x14c0ffeb, 0x610c0, 0x10c0ffd2, 0x24020001,
-0x8fbf0014, 0x8fb00010, 0x3e00008, 0x27bd0018,
-0x3e00008, 0x0, 0x27bdffb0, 0x801021,
-0xafb00030, 0x24500002, 0x2002021, 0x24050006,
-0xafb10034, 0x408821, 0xafbf0048, 0xafbe0044,
-0xafb50040, 0xafb3003c, 0xc0022c1, 0xafb20038,
-0x3047007f, 0x710c0, 0x2e21021, 0x3c050001,
-0xa22821, 0x94a530d0, 0x50a0001c, 0xa03021,
-0x3c090001, 0x352934d2, 0x96280002, 0x510c0,
-0x572021, 0x892021, 0x94820000, 0x14480009,
-0x3021, 0x94830002, 0x96020002, 0x14620006,
-0xc01021, 0x94820004, 0x96030004, 0x431026,
-0x2c460001, 0xc01021, 0x14400007, 0x510c0,
-0x2e21021, 0x3c050001, 0xa22821, 0x94a534d0,
-0x14a0ffeb, 0x510c0, 0xa03021, 0x10c00014,
-0x610c0, 0x571821, 0x3c010001, 0x230821,
-0x8c2334d0, 0x571021, 0xafa30010, 0x3c010001,
-0x220821, 0x8c2234d4, 0x3c040001, 0x24843a84,
-0xafa20014, 0x8e260000, 0x8e270004, 0x3c050004,
-0xc0029e7, 0x34a50400, 0x10000063, 0x3c020800,
-0x8f450100, 0x10a00006, 0x510c0, 0x2e21021,
-0x3c010001, 0x220821, 0x942234d0, 0xaf420100,
-0xa03021, 0x14c00011, 0x628c0, 0x710c0,
-0x2e21021, 0xafa70010, 0x3c010001, 0x220821,
-0x942230d0, 0x3c040001, 0x24843a90, 0xafa20014,
-0x8e260000, 0x8e270004, 0x3c050004, 0xc0029e7,
-0x34a50500, 0x10000048, 0x3c020800, 0xb71821,
-0x3c020001, 0x96040000, 0x344234d2, 0x621821,
-0xa4640000, 0x8e020002, 0x720c0, 0xac620002,
-0x2e41021, 0x3c030001, 0x621821, 0x946330d0,
-0x2e51021, 0x3c010001, 0x220821, 0xa42334d0,
-0x2e41021, 0x3c010001, 0x220821, 0xa42630d0,
-0x8f420104, 0x24420001, 0x28420080, 0x1040000f,
-0x3c020002, 0x8f420104, 0x3c040001, 0x348430d2,
-0x96030000, 0x210c0, 0x571021, 0x441021,
-0xa4430000, 0x8e030002, 0xac430002, 0x8f420104,
-0x24420001, 0xaf420104, 0x3c020002, 0x2c21024,
-0x10400011, 0x72142, 0x3c030001, 0x346338d8,
-0x24020003, 0x441023, 0x21080, 0x572021,
-0x832021, 0x571021, 0x431021, 0x30e5001f,
-0x8c430000, 0x24020001, 0xa21004, 0x621825,
-0x1000000c, 0xac830000, 0x24020003, 0x441023,
-0x21080, 0x5c2821, 0x5c1021, 0x30e4001f,
-0x8c430228, 0x24020001, 0x821004, 0x621825,
-0xaca30228, 0x3c020800, 0x34421000, 0x1821,
-0xafa20020, 0x8f5e0018, 0x27aa0020, 0x240200ff,
-0x13c20002, 0xafaa002c, 0x27c30001, 0x8c020228,
-0x609021, 0x1642000e, 0x1e38c0, 0x8f42033c,
-0x24420001, 0xaf42033c, 0x8f42033c, 0x8c020228,
-0x3c040001, 0x24843a4c, 0x3c050009, 0xafa00014,
-0xafa20010, 0x8fa60020, 0x1000006b, 0x34a50500,
-0xf71021, 0x8fa30020, 0x8fa40024, 0xac4304c0,
-0xac4404c4, 0x8f830054, 0x8f820054, 0x247003e8,
-0x2021023, 0x2c4203e9, 0x1040001b, 0x9821,
-0xe08821, 0x263504c0, 0x8f440178, 0x8f45017c,
-0x2201821, 0x240a0004, 0xafaa0010, 0xafb20014,
-0x8f48000c, 0x1021, 0x2f53021, 0xafa80018,
-0x8f48010c, 0x24070008, 0xa32821, 0xa3482b,
-0x822021, 0x100f809, 0x892021, 0x54400006,
-0x24130001, 0x8f820054, 0x2021023, 0x2c4203e9,
-0x1440ffe9, 0x0, 0x326200ff, 0x54400017,
-0xaf520018, 0x8f420378, 0x24420001, 0xaf420378,
-0x8f420378, 0x8f820120, 0x8faa002c, 0xafa20010,
-0x8f820124, 0x3c040001, 0x24843a58, 0x3c050009,
-0xafa20014, 0x8d460000, 0x10000033, 0x34a50600,
-0x8f420308, 0x24130001, 0x24420001, 0xaf420308,
-0x8f420308, 0x1000001c, 0x326200ff, 0x8f830054,
-0x8f820054, 0x247003e8, 0x2021023, 0x2c4203e9,
-0x10400014, 0x9821, 0x24110010, 0x8f42000c,
-0x8f440160, 0x8f450164, 0x8f860120, 0xafb10010,
-0xafb20014, 0xafa20018, 0x8f42010c, 0x24070008,
-0x40f809, 0x24c6001c, 0x1440ffe5, 0x0,
-0x8f820054, 0x2021023, 0x2c4203e9, 0x1440ffef,
-0x0, 0x326200ff, 0x14400011, 0x0,
-0x8f420378, 0x24420001, 0xaf420378, 0x8f420378,
-0x8f820120, 0x8faa002c, 0xafa20010, 0x8f820124,
-0x3c040001, 0x24843a60, 0x3c050009, 0xafa20014,
-0x8d460000, 0x34a50700, 0xc0029e7, 0x3c03821,
-0x8f4202b4, 0x24420001, 0xaf4202b4, 0x8f4202b4,
-0x8f4202f4, 0x24420001, 0xaf4202f4, 0x8f4202f4,
-0x8fbf0048, 0x8fbe0044, 0x8fb50040, 0x8fb3003c,
-0x8fb20038, 0x8fb10034, 0x8fb00030, 0x3e00008,
-0x27bd0050, 0x27bdffa0, 0x801021, 0xafb00040,
-0x24500002, 0x2002021, 0x24050006, 0xafb10044,
-0x408821, 0xafbf0058, 0xafbe0054, 0xafb50050,
-0xafb3004c, 0xc0022c1, 0xafb20048, 0x3048007f,
-0x810c0, 0x2e21021, 0x3c060001, 0xc23021,
-0x94c630d0, 0x10c0001c, 0x3821, 0x3c0a0001,
-0x354a34d2, 0x96290002, 0x610c0, 0x572021,
-0x8a2021, 0x94820000, 0x14490009, 0x2821,
-0x94830002, 0x96020002, 0x14620006, 0xa01021,
-0x94820004, 0x96030004, 0x431026, 0x2c450001,
-0xa01021, 0x14400008, 0x610c0, 0xc03821,
-0x2e21021, 0x3c060001, 0xc23021, 0x94c634d0,
-0x14c0ffea, 0x610c0, 0x14c00011, 0xafa70028,
-0x810c0, 0x2e21021, 0xafa80010, 0x3c010001,
-0x220821, 0x942230d0, 0x3c040001, 0x24843a9c,
-0xafa20014, 0x8e260000, 0x8e270004, 0x3c050004,
-0xc0029e7, 0x34a50900, 0x10000075, 0x3c020800,
-0x10e0000c, 0x610c0, 0x2e21021, 0x3c030001,
-0x621821, 0x946334d0, 0x710c0, 0x2e21021,
-0x3c010001, 0x220821, 0xa42334d0, 0x1000000b,
-0x3c040001, 0x2e21021, 0x3c030001, 0x621821,
-0x946334d0, 0x810c0, 0x2e21021, 0x3c010001,
-0x220821, 0xa42330d0, 0x3c040001, 0x348430d0,
-0x8f430100, 0x610c0, 0x2e21021, 0x3c010001,
-0x220821, 0xa42334d0, 0x8f420104, 0x2e43821,
-0x2821, 0x18400029, 0xaf460100, 0x24e60006,
-0x94c3fffc, 0x96020000, 0x14620009, 0x2021,
-0x94c3fffe, 0x96020002, 0x14620006, 0x801021,
-0x94c20000, 0x96030004, 0x431026, 0x2c440001,
-0x801021, 0x50400014, 0x24a50001, 0x8f420104,
-0x2442ffff, 0xa2102a, 0x1040000b, 0x24e40004,
-0x94820006, 0x8c830008, 0xa482fffe, 0xac830000,
-0x8f420104, 0x24a50001, 0x2442ffff, 0xa2102a,
-0x1440fff7, 0x24840008, 0x8f420104, 0x2442ffff,
-0x10000006, 0xaf420104, 0x8f420104, 0x24c60008,
-0xa2102a, 0x1440ffda, 0x24e70008, 0x810c0,
-0x2e21021, 0x3c010001, 0x220821, 0x942230d0,
-0x14400023, 0x3c020800, 0x3c020002, 0x2c21024,
-0x10400012, 0x82142, 0x3c030001, 0x346338d8,
-0x24020003, 0x441023, 0x21080, 0x572021,
-0x832021, 0x571021, 0x431021, 0x3105001f,
-0x24030001, 0x8c420000, 0xa31804, 0x31827,
-0x431024, 0x1000000d, 0xac820000, 0x24020003,
-0x441023, 0x21080, 0x5c2821, 0x5c1021,
-0x3104001f, 0x24030001, 0x8c420228, 0x831804,
-0x31827, 0x431024, 0xaca20228, 0x3c020800,
-0x34422000, 0x1821, 0xafa20020, 0x8f5e0018,
-0x27ab0020, 0x240200ff, 0x13c20002, 0xafab0034,
-0x27c30001, 0x8c020228, 0x609021, 0x1642000e,
-0x1e38c0, 0x8f42033c, 0x24420001, 0xaf42033c,
-0x8f42033c, 0x8c020228, 0x3c040001, 0x24843a4c,
-0x3c050009, 0xafa00014, 0xafa20010, 0x8fa60020,
-0x1000006b, 0x34a50500, 0xf71021, 0x8fa30020,
-0x8fa40024, 0xac4304c0, 0xac4404c4, 0x8f830054,
-0x8f820054, 0x247003e8, 0x2021023, 0x2c4203e9,
-0x1040001b, 0x9821, 0xe08821, 0x263504c0,
-0x8f440178, 0x8f45017c, 0x2201821, 0x240b0004,
-0xafab0010, 0xafb20014, 0x8f48000c, 0x1021,
-0x2f53021, 0xafa80018, 0x8f48010c, 0x24070008,
-0xa32821, 0xa3482b, 0x822021, 0x100f809,
-0x892021, 0x54400006, 0x24130001, 0x8f820054,
-0x2021023, 0x2c4203e9, 0x1440ffe9, 0x0,
-0x326200ff, 0x54400017, 0xaf520018, 0x8f420378,
-0x24420001, 0xaf420378, 0x8f420378, 0x8f820120,
-0x8fab0034, 0xafa20010, 0x8f820124, 0x3c040001,
-0x24843a58, 0x3c050009, 0xafa20014, 0x8d660000,
-0x10000033, 0x34a50600, 0x8f420308, 0x24130001,
-0x24420001, 0xaf420308, 0x8f420308, 0x1000001c,
-0x326200ff, 0x8f830054, 0x8f820054, 0x247003e8,
-0x2021023, 0x2c4203e9, 0x10400014, 0x9821,
-0x24110010, 0x8f42000c, 0x8f440160, 0x8f450164,
-0x8f860120, 0xafb10010, 0xafb20014, 0xafa20018,
-0x8f42010c, 0x24070008, 0x40f809, 0x24c6001c,
-0x1440ffe5, 0x0, 0x8f820054, 0x2021023,
-0x2c4203e9, 0x1440ffef, 0x0, 0x326200ff,
-0x14400011, 0x0, 0x8f420378, 0x24420001,
-0xaf420378, 0x8f420378, 0x8f820120, 0x8fab0034,
-0xafa20010, 0x8f820124, 0x3c040001, 0x24843a60,
-0x3c050009, 0xafa20014, 0x8d660000, 0x34a50700,
-0xc0029e7, 0x3c03821, 0x8f4202b8, 0x24420001,
-0xaf4202b8, 0x8f4202b8, 0x8f4202f4, 0x24420001,
-0xaf4202f4, 0x8f4202f4, 0x8fbf0058, 0x8fbe0054,
-0x8fb50050, 0x8fb3004c, 0x8fb20048, 0x8fb10044,
-0x8fb00040, 0x3e00008, 0x27bd0060, 0x27bdffe0,
-0x27644000, 0xafbf0018, 0xc002a54, 0x24051000,
-0x3c030001, 0x34632cc0, 0x3c040001, 0x34842ec8,
-0x24020020, 0xaf82011c, 0x2e31021, 0xaf800100,
-0xaf800104, 0xaf800108, 0xaf800110, 0xaf800114,
-0xaf800118, 0xaf800120, 0xaf800124, 0xaf800128,
-0xaf800130, 0xaf800134, 0xaf800138, 0xaf4200ec,
-0x2e31021, 0xaf4200f0, 0x2e41021, 0xaf4200f4,
-0x2e41021, 0xaf4200f8, 0x3c020001, 0x571021,
-0x904240f4, 0x1440001c, 0x3c050001, 0x8f82011c,
-0x3c040001, 0x24843b60, 0x3c050001, 0x34420001,
-0xaf82011c, 0xafa00010, 0xafa00014, 0x8f86011c,
-0x34a50100, 0xc0029e7, 0x3821, 0x8c020218,
-0x30420040, 0x10400014, 0x0, 0x8f82011c,
-0x3c040001, 0x24843b6c, 0x3c050001, 0x34420004,
-0xaf82011c, 0xafa00010, 0xafa00014, 0x8f86011c,
-0x10000007, 0x34a50200, 0x3c040001, 0x24843b74,
-0xafa00010, 0xafa00014, 0x8f86011c, 0x34a50300,
-0xc0029e7, 0x3821, 0x8fbf0018, 0x3e00008,
-0x27bd0020, 0x8fa90010, 0x8f83012c, 0x8faa0014,
-0x8fab0018, 0x1060000a, 0x27624fe0, 0x14620002,
-0x24680020, 0x27684800, 0x8f820128, 0x11020004,
-0x0, 0x8f820124, 0x15020007, 0x0,
-0x8f430334, 0x1021, 0x24630001, 0xaf430334,
-0x10000039, 0x8f430334, 0xac640000, 0xac650004,
-0xac660008, 0xa467000e, 0xac690018, 0xac6a001c,
-0xac6b0010, 0xac620014, 0xaf880120, 0x8f4200fc,
-0x8f4400f4, 0x2442ffff, 0xaf4200fc, 0x8c820000,
-0x10490005, 0x3042ff8f, 0x10400019, 0x3122ff8f,
-0x10400018, 0x3c020001, 0x8c830004, 0x2c620010,
-0x10400013, 0x3c020001, 0x24630001, 0xac830004,
-0x8f4300f8, 0x344230c8, 0x2e21021, 0x54620004,
-0x24620008, 0x3c020001, 0x34422ec8, 0x2e21021,
-0x14440015, 0x24020001, 0x8f820128, 0x24420020,
-0xaf820128, 0x8f820128, 0x1000000f, 0x24020001,
-0x3c020001, 0x344230c8, 0x2e21021, 0x54820004,
-0x24820008, 0x3c020001, 0x34422ec8, 0x2e21021,
-0x402021, 0x24020001, 0xaf4400f4, 0xac890000,
-0xac820004, 0x24020001, 0x3e00008, 0x0,
-0x3e00008, 0x0, 0x8fa90010, 0x8f83010c,
-0x8faa0014, 0x8fab0018, 0x1060000a, 0x276247e0,
-0x14620002, 0x24680020, 0x27684000, 0x8f820108,
-0x11020004, 0x0, 0x8f820104, 0x15020007,
-0x0, 0x8f430338, 0x1021, 0x24630001,
-0xaf430338, 0x10000035, 0x8f430338, 0xac640000,
-0xac650004, 0xac660008, 0xa467000e, 0xac690018,
-0xac6a001c, 0xac6b0010, 0xac620014, 0xaf880100,
-0x8f4400ec, 0x8c820000, 0x30420006, 0x10400019,
-0x31220006, 0x10400018, 0x3c020001, 0x8c830004,
-0x2c620010, 0x10400013, 0x3c020001, 0x24630001,
-0xac830004, 0x8f4300f0, 0x34422ec0, 0x2e21021,
-0x54620004, 0x24620008, 0x3c020001, 0x34422cc0,
-0x2e21021, 0x14440015, 0x24020001, 0x8f820108,
-0x24420020, 0xaf820108, 0x8f820108, 0x1000000f,
-0x24020001, 0x3c020001, 0x34422ec0, 0x2e21021,
-0x54820004, 0x24820008, 0x3c020001, 0x34422cc0,
-0x2e21021, 0x402021, 0x24020001, 0xaf4400ec,
-0xac890000, 0xac820004, 0x24020001, 0x3e00008,
-0x0, 0x3e00008, 0x0, 0x27bdffd8,
-0x3c040001, 0x24843b7c, 0x3c050001, 0xafbf0024,
-0xafb20020, 0xafb1001c, 0xafb00018, 0x8f900104,
-0x8f9100b0, 0x8f92011c, 0x34a52500, 0x8f820100,
-0x2403021, 0x2203821, 0xafa20010, 0xc0029e7,
-0xafb00014, 0x8e020008, 0xafa20010, 0x8e02000c,
-0x3c040001, 0x24843b88, 0xafa20014, 0x8e060000,
-0x8e070004, 0x3c050001, 0xc0029e7, 0x34a52510,
-0x8e020018, 0xafa20010, 0x8e02001c, 0x3c040001,
-0x24843b94, 0xafa20014, 0x8e060010, 0x8e070014,
-0x3c050001, 0xc0029e7, 0x34a52520, 0x3c027f00,
-0x2221024, 0x3c030800, 0x54430016, 0x3c030200,
-0x8f82009c, 0x3042ffff, 0x14400012, 0x3c030200,
-0x3c040001, 0x24843ba0, 0x3c050002, 0x34a5f030,
-0x3021, 0x3821, 0x36420002, 0xaf82011c,
-0x36220001, 0xaf8200b0, 0xaf900104, 0xaf92011c,
-0xafa00010, 0xc0029e7, 0xafa00014, 0x10000024,
-0x0, 0x2c31024, 0x1040000d, 0x2231024,
-0x1040000b, 0x36420002, 0xaf82011c, 0x36220001,
-0xaf8200b0, 0xaf900104, 0xaf92011c, 0x8f420330,
-0x24420001, 0xaf420330, 0x10000015, 0x8f420330,
-0x3c040001, 0x24843ba8, 0x240202a9, 0xafa20010,
-0xafa00014, 0x8f860144, 0x3c070001, 0x24e73bb0,
-0xc0029e7, 0x3405dead, 0x8f82011c, 0x34420002,
-0xaf82011c, 0x8f820220, 0x34420004, 0xaf820220,
-0x8f820140, 0x3c030001, 0x431025, 0xaf820140,
-0x8fbf0024, 0x8fb20020, 0x8fb1001c, 0x8fb00018,
-0x3e00008, 0x27bd0028, 0x27bdffd8, 0x3c040001,
-0x24843bb8, 0x3c050001, 0xafbf0024, 0xafb20020,
-0xafb1001c, 0xafb00018, 0x8f900124, 0x8f9100a0,
-0x8f92011c, 0x34a52600, 0x8f820120, 0x2403021,
-0x2203821, 0xafa20010, 0xc0029e7, 0xafb00014,
-0x8e020008, 0xafa20010, 0x8e02000c, 0x3c040001,
-0x24843bc4, 0xafa20014, 0x8e060000, 0x8e070004,
-0x3c050001, 0xc0029e7, 0x34a52610, 0x8e020018,
-0xafa20010, 0x8e02001c, 0x3c040001, 0x24843bd0,
-0xafa20014, 0x8e060010, 0x8e070014, 0x3c050001,
-0xc0029e7, 0x34a52620, 0x3c027f00, 0x2221024,
-0x3c030800, 0x54430016, 0x3c030200, 0x8f8200ac,
-0x3042ffff, 0x14400012, 0x3c030200, 0x3c040001,
-0x24843bdc, 0x3c050001, 0x34a5f030, 0x3021,
-0x3821, 0x36420002, 0xaf82011c, 0x36220001,
-0xaf8200a0, 0xaf900124, 0xaf92011c, 0xafa00010,
-0xc0029e7, 0xafa00014, 0x10000024, 0x0,
-0x2c31024, 0x1040000d, 0x2231024, 0x1040000b,
-0x36420002, 0xaf82011c, 0x36220001, 0xaf8200a0,
-0xaf900124, 0xaf92011c, 0x8f42032c, 0x24420001,
-0xaf42032c, 0x10000015, 0x8f42032c, 0x3c040001,
-0x24843ba8, 0x240202e2, 0xafa20010, 0xafa00014,
-0x8f860144, 0x3c070001, 0x24e73bb0, 0xc0029e7,
-0x3405dead, 0x8f82011c, 0x34420002, 0xaf82011c,
-0x8f820220, 0x34420004, 0xaf820220, 0x8f820140,
-0x3c030001, 0x431025, 0xaf820140, 0x8fbf0024,
-0x8fb20020, 0x8fb1001c, 0x8fb00018, 0x3e00008,
-0x27bd0028, 0x6021, 0x5021, 0x3021,
-0x2821, 0x6821, 0x4821, 0x7821,
-0x7021, 0x8f880124, 0x8f870104, 0x1580002e,
-0x8f8b011c, 0x11a00014, 0x31620800, 0x8f820120,
-0x10460029, 0x0, 0x3c040001, 0x8c8444a0,
-0x8cc20000, 0x8cc30004, 0xac820000, 0xac830004,
-0x8cc20008, 0xac820008, 0x94c2000e, 0xa482000e,
-0x8cc20010, 0x240c0001, 0xac820010, 0x8cc20014,
-0x10000012, 0x24c60020, 0x10400017, 0x0,
-0x3c040001, 0x8c8444a0, 0x8d020000, 0x8d030004,
-0xac820000, 0xac830004, 0x8d020008, 0xac820008,
-0x9502000e, 0xa482000e, 0x8d020010, 0x25060020,
-0xac820010, 0x8d020014, 0x240c0001, 0xc01821,
-0xac820014, 0x27624fe0, 0x43102b, 0x54400001,
-0x27634800, 0x603021, 0x1540002f, 0x31620100,
-0x11200014, 0x31628000, 0x8f820100, 0x1045002a,
-0x31620100, 0x3c040001, 0x8c84449c, 0x8ca20000,
-0x8ca30004, 0xac820000, 0xac830004, 0x8ca20008,
-0xac820008, 0x94a2000e, 0xa482000e, 0x8ca20010,
-0x240a0001, 0xac820010, 0x8ca20014, 0x10000012,
-0x24a50020, 0x10400018, 0x31620100, 0x3c040001,
-0x8c84449c, 0x8ce20000, 0x8ce30004, 0xac820000,
-0xac830004, 0x8ce20008, 0xac820008, 0x94e2000e,
-0xa482000e, 0x8ce20010, 0x24e50020, 0xac820010,
-0x8ce20014, 0x240a0001, 0xa01821, 0xac820014,
-0x276247e0, 0x43102b, 0x54400001, 0x27634000,
-0x602821, 0x31620100, 0x5440001d, 0x31621000,
-0x11a00009, 0x31a20800, 0x10400004, 0x25020020,
-0x8f8200a8, 0xa5e20000, 0x25020020, 0xaf820124,
-0x8f880124, 0x6821, 0x11800011, 0x31621000,
-0x3c040001, 0x8c8444a0, 0x8c820000, 0x8c830004,
-0xaf820080, 0xaf830084, 0x8c820008, 0xaf8200a4,
-0x9482000e, 0xaf8200ac, 0x8c820010, 0x6021,
-0xaf8200a0, 0x8c8d0010, 0x8c8f0014, 0x31621000,
-0x1440ff82, 0x0, 0x1120000f, 0x31220800,
-0x10400004, 0x3c020002, 0x8f8200b8, 0xa5c20000,
-0x3c020002, 0x1221024, 0x10400004, 0x24e20020,
-0x8f8200b4, 0xaf8200d4, 0x24e20020, 0xaf820104,
-0x8f870104, 0x4821, 0x1140ff70, 0x0,
-0x3c040001, 0x8c84449c, 0x8c820000, 0x8c830004,
-0xaf820090, 0xaf830094, 0x8c820008, 0xaf8200b4,
-0x9482000e, 0xaf82009c, 0x8c820010, 0x5021,
-0xaf8200b0, 0x8c890010, 0x1000ff60, 0x8c8e0014,
-0x3e00008, 0x0, 0x6021, 0x5821,
-0x3021, 0x2821, 0x6821, 0x5021,
-0x7821, 0x7021, 0x8f880124, 0x8f870104,
-0x3c180100, 0x1580002e, 0x8f89011c, 0x11a00014,
-0x31220800, 0x8f820120, 0x10460029, 0x0,
-0x3c040001, 0x8c8444a0, 0x8cc20000, 0x8cc30004,
-0xac820000, 0xac830004, 0x8cc20008, 0xac820008,
-0x94c2000e, 0xa482000e, 0x8cc20010, 0x240c0001,
-0xac820010, 0x8cc20014, 0x10000012, 0x24c60020,
-0x10400017, 0x0, 0x3c040001, 0x8c8444a0,
-0x8d020000, 0x8d030004, 0xac820000, 0xac830004,
-0x8d020008, 0xac820008, 0x9502000e, 0xa482000e,
-0x8d020010, 0x25060020, 0xac820010, 0x8d020014,
-0x240c0001, 0xc01821, 0xac820014, 0x27624fe0,
-0x43102b, 0x54400001, 0x27634800, 0x603021,
-0x1560002f, 0x31220100, 0x11400014, 0x31228000,
-0x8f820100, 0x1045002a, 0x31220100, 0x3c040001,
-0x8c84449c, 0x8ca20000, 0x8ca30004, 0xac820000,
-0xac830004, 0x8ca20008, 0xac820008, 0x94a2000e,
-0xa482000e, 0x8ca20010, 0x240b0001, 0xac820010,
-0x8ca20014, 0x10000012, 0x24a50020, 0x10400018,
-0x31220100, 0x3c040001, 0x8c84449c, 0x8ce20000,
-0x8ce30004, 0xac820000, 0xac830004, 0x8ce20008,
-0xac820008, 0x94e2000e, 0xa482000e, 0x8ce20010,
-0x24e50020, 0xac820010, 0x8ce20014, 0x240b0001,
-0xa01821, 0xac820014, 0x276247e0, 0x43102b,
-0x54400001, 0x27634000, 0x602821, 0x31220100,
-0x5440001d, 0x31221000, 0x11a00009, 0x31a20800,
-0x10400004, 0x25020020, 0x8f8200a8, 0xa5e20000,
-0x25020020, 0xaf820124, 0x8f880124, 0x6821,
-0x11800011, 0x31221000, 0x3c040001, 0x8c8444a0,
-0x8c820000, 0x8c830004, 0xaf820080, 0xaf830084,
-0x8c820008, 0xaf8200a4, 0x9482000e, 0xaf8200ac,
-0x8c820010, 0x6021, 0xaf8200a0, 0x8c8d0010,
-0x8c8f0014, 0x31221000, 0x14400022, 0x0,
-0x1140000f, 0x31420800, 0x10400004, 0x3c020002,
-0x8f8200b8, 0xa5c20000, 0x3c020002, 0x1421024,
-0x10400004, 0x24e20020, 0x8f8200b4, 0xaf8200d4,
-0x24e20020, 0xaf820104, 0x8f870104, 0x5021,
-0x11600010, 0x0, 0x3c040001, 0x8c84449c,
-0x8c820000, 0x8c830004, 0xaf820090, 0xaf830094,
-0x8c820008, 0xaf8200b4, 0x9482000e, 0xaf82009c,
-0x8c820010, 0x5821, 0xaf8200b0, 0x8c8a0010,
-0x8c8e0014, 0x8f820070, 0x3c031000, 0x431024,
-0x1040ff5c, 0x0, 0x8f820054, 0x24420005,
-0xaf820078, 0x8c040234, 0x10800016, 0x1821,
-0x3c020001, 0x571021, 0x8c4240e8, 0x24420005,
-0x3c010001, 0x370821, 0xac2240e8, 0x3c020001,
-0x571021, 0x8c4240e8, 0x44102b, 0x14400009,
-0x24020001, 0x3c030080, 0x3c010001, 0x370821,
-0xac2040e8, 0x3c010001, 0x370821, 0x1000000c,
-0xa02240f0, 0x3c020001, 0x571021, 0x904240f0,
-0x14400006, 0x3c020080, 0x3c020001, 0x571021,
-0x904240f1, 0x10400002, 0x3c020080, 0x621825,
-0x8c040230, 0x10800013, 0x0, 0x3c020001,
-0x571021, 0x8c4240ec, 0x24420005, 0x3c010001,
-0x370821, 0xac2240ec, 0x3c020001, 0x571021,
-0x8c4240ec, 0x44102b, 0x14400006, 0x0,
-0x3c010001, 0x370821, 0xac2040ec, 0x10000006,
-0x781825, 0x3c020001, 0x571021, 0x904240f2,
-0x54400001, 0x781825, 0x1060ff1a, 0x0,
-0x8f420000, 0x10400007, 0x0, 0xaf80004c,
-0x8f82004c, 0x1040fffd, 0x0, 0x10000005,
-0x0, 0xaf800048, 0x8f820048, 0x1040fffd,
-0x0, 0x8f820060, 0x431025, 0xaf820060,
-0x8f420000, 0x10400003, 0x0, 0x1000ff05,
-0xaf80004c, 0x1000ff03, 0xaf800048, 0x3e00008,
-0x0, 0x0, 0x0, 0x3c020001,
-0x8c424318, 0x27bdffe8, 0xafbf0014, 0x14400012,
-0xafb00010, 0x3c100001, 0x26104540, 0x2002021,
-0xc002a54, 0x24052000, 0x26021fe0, 0x3c010001,
-0xac2244a8, 0x3c010001, 0xac2244a4, 0xac020250,
-0x24022000, 0xac100254, 0xac020258, 0x24020001,
-0x3c010001, 0xac224318, 0x8fbf0014, 0x8fb00010,
-0x3e00008, 0x27bd0018, 0x3c090001, 0x8d2944a8,
-0x8c820000, 0x8fa30010, 0x8fa80014, 0xad220000,
-0x8c820004, 0xad250008, 0xad220004, 0x8f820054,
-0xad260010, 0xad270014, 0xad230018, 0xad28001c,
-0xad22000c, 0x2529ffe0, 0x3c020001, 0x24424540,
-0x122102b, 0x10400003, 0x0, 0x3c090001,
-0x8d2944a4, 0x3c020001, 0x8c424300, 0xad220000,
-0x3c020001, 0x8c424300, 0x3c010001, 0xac2944a8,
-0xad220004, 0x3e00008, 0xac090250, 0x27bdffd0,
-0xafb00010, 0x3c100001, 0x8e1044a8, 0x3c020001,
-0x8c424300, 0xafb10014, 0x808821, 0xafbe0024,
-0x8fbe0040, 0x8fa40048, 0xafb20018, 0xa09021,
-0xafbf0028, 0xafb50020, 0xafb3001c, 0xae020000,
-0x3c020001, 0x8c424300, 0xc09821, 0xe0a821,
-0x10800006, 0xae020004, 0x26050008, 0xc002a5f,
-0x24060018, 0x10000005, 0x2610ffe0, 0x26040008,
-0xc002a54, 0x24050018, 0x2610ffe0, 0x3c030001,
-0x24634540, 0x203102b, 0x10400003, 0x0,
-0x3c100001, 0x8e1044a4, 0x8e220000, 0xae020000,
-0x8e220004, 0xae120008, 0xae020004, 0x8f820054,
-0xae130010, 0xae150014, 0xae1e0018, 0x8fa80044,
-0xae08001c, 0xae02000c, 0x2610ffe0, 0x203102b,
-0x10400003, 0x0, 0x3c100001, 0x8e1044a4,
-0x3c020001, 0x8c424300, 0xae020000, 0x3c020001,
-0x8c424300, 0x3c010001, 0xac3044a8, 0xae020004,
-0xac100250, 0x8fbf0028, 0x8fbe0024, 0x8fb50020,
-0x8fb3001c, 0x8fb20018, 0x8fb10014, 0x8fb00010,
-0x3e00008, 0x27bd0030, 0x0, 0x851821,
-0x83102b, 0x10400006, 0x0, 0xac800000,
-0x24840004, 0x83102b, 0x5440fffd, 0xac800000,
-0x3e00008, 0x0, 0xa61821, 0xa3102b,
-0x10400007, 0x0, 0x8c820000, 0xaca20000,
-0x24a50004, 0xa3102b, 0x1440fffb, 0x24840004,
-0x3e00008, 0x0, 0x861821, 0x83102b,
-0x10400007, 0x0, 0x8ca20000, 0xac820000,
-0x24840004, 0x83102b, 0x1440fffb, 0x24a50004,
-0x3e00008, 0x0, 0x63080, 0x861821,
-0x83102b, 0x10400006, 0x0, 0xac850000,
-0x24840004, 0x83102b, 0x5440fffd, 0xac850000,
-0x3e00008, 0x0, 0x0, 0x3c0208ff,
-0x3442ffff, 0x3c03c0ff, 0x8f850220, 0x3463ffff,
-0x8f860200, 0xa21024, 0x34420004, 0xc31824,
-0x34630004, 0xaf820220, 0xaf830200, 0x8c820214,
-0xac020084, 0x8c820218, 0xac020088, 0x8c82021c,
-0xac02008c, 0x8c820220, 0xac020090, 0x8c820224,
-0xac020094, 0x8c820228, 0xac020098, 0x8c82022c,
-0xac02009c, 0x8c820230, 0xac0200a0, 0x8c820234,
-0xac0200a4, 0x8c820238, 0xac0200a8, 0x8c82023c,
-0xac0200ac, 0x8c820240, 0xac0200b0, 0x8c820244,
-0xac0200b4, 0x8c820248, 0xac0200b8, 0x8c82024c,
-0xac0200bc, 0x8c82001c, 0xac020080, 0x8c820018,
-0xac0200c0, 0x8c820020, 0xac0200cc, 0x8c820024,
-0xac0200d0, 0x8c8201d0, 0xac0200e0, 0x8c8201d4,
-0xac0200e4, 0x8c8201d8, 0xac0200e8, 0x8c8201dc,
-0xac0200ec, 0x8c8201e0, 0xac0200f0, 0x8c820098,
-0x8c83009c, 0xac0300fc, 0x8c8200a8, 0x8c8300ac,
-0xac0300f4, 0x8c8200a0, 0x8c8300a4, 0x30a50004,
-0xac0300f8, 0x14a00007, 0x30c20004, 0x8f820220,
-0x3c0308ff, 0x3463fffb, 0x431024, 0xaf820220,
-0x30c20004, 0x14400006, 0x0, 0x8f820200,
-0x3c03c0ff, 0x3463fffb, 0x431024, 0xaf820200,
-0x3e00008, 0x0, 0x27bdffd8, 0xafbf0024,
-0xafb00020, 0x8f430024, 0x8f420020, 0x10620038,
-0x0, 0x8f430020, 0x8f420024, 0x622023,
-0x4810003, 0x0, 0x8f420040, 0x822021,
-0x8f430030, 0x8f420024, 0x43102b, 0x14400005,
-0x0, 0x8f430040, 0x8f420024, 0x10000005,
-0x621023, 0x8f420030, 0x8f430024, 0x431023,
-0x2442ffff, 0x406021, 0x8c102a, 0x54400001,
-0x806021, 0x8f4a0024, 0x8f490040, 0x8f480024,
-0x8f440180, 0x8f450184, 0x8f460024, 0x8f4b001c,
-0x24070001, 0xafa70010, 0x84100, 0x1001821,
-0x14c5021, 0x2529ffff, 0x1498024, 0xafb00014,
-0x8f470014, 0x1021, 0x63100, 0xafa70018,
-0xa32821, 0xa3382b, 0x822021, 0x872021,
-0x8f420108, 0x1663021, 0x40f809, 0xc3900,
-0x54400001, 0xaf500024, 0x8f430024, 0x8f420020,
-0x14620018, 0x0, 0x8f420000, 0x10400007,
-0x0, 0xaf80004c, 0x8f82004c, 0x1040fffd,
-0x0, 0x10000005, 0x0, 0xaf800048,
-0x8f820048, 0x1040fffd, 0x0, 0x8f820060,
-0x2403ffef, 0x431024, 0xaf820060, 0x8f420000,
-0x10400003, 0x0, 0x10000002, 0xaf80004c,
-0xaf800048, 0x8fbf0024, 0x8fb00020, 0x3e00008,
-0x27bd0028, 0x3e00008, 0x0, 0x27bdffc0,
-0x32c20020, 0xafbf0038, 0xafb30034, 0xafb20030,
-0xafb1002c, 0x10400004, 0xafb00028, 0x8f530028,
-0x10000002, 0x0, 0x8f530020, 0x8f420030,
-0x105300eb, 0x21100, 0x8f43001c, 0x628021,
-0x8e040000, 0x8e050004, 0x96120008, 0x8f420090,
-0x9611000a, 0x3246ffff, 0x46102a, 0x10400017,
-0x0, 0x8f8200d8, 0x8f430098, 0x431023,
-0x2442fff8, 0xaf420090, 0x8f420090, 0x2842fff9,
-0x10400005, 0x0, 0x8f420090, 0x8f430144,
-0x431021, 0xaf420090, 0x8f420090, 0x46102a,
-0x10400006, 0x0, 0x8f420348, 0x24420001,
-0xaf420348, 0x100000e1, 0x8f420348, 0x8f8200fc,
-0x14400006, 0x0, 0x8f420344, 0x24420001,
-0xaf420344, 0x100000d9, 0x8f420344, 0x934205c2,
-0x1040000b, 0x32c20008, 0x10400008, 0x32220200,
-0x10400006, 0x3c034000, 0x9602000e, 0xaf4300ac,
-0x21400, 0x10000002, 0xaf4200b0, 0xaf4000ac,
-0x32220004, 0x1040007f, 0x32220800, 0x10400003,
-0x3247ffff, 0x10000002, 0x24020020, 0x24020004,
-0xafa20010, 0x8f420030, 0xafa20014, 0x8f420010,
-0x3c030002, 0x431025, 0xafa20018, 0x8f460098,
-0x8f420108, 0x40f809, 0x0, 0x104000b7,
-0x0, 0x8f42009c, 0x8f430094, 0x2421021,
-0xaf42009c, 0xae03000c, 0x8f4200ac, 0x10400008,
-0x3c034000, 0x8f420094, 0x431025, 0xafa20020,
-0x8f42009c, 0x8f4300b0, 0x10000004, 0x431025,
-0x8f420094, 0xafa20020, 0x8f42009c, 0xafa20024,
-0x8f8200fc, 0x8fa30020, 0x8fa40024, 0xac430000,
-0xac440004, 0x24420008, 0xaf8200f0, 0x8f42009c,
-0x8f440270, 0x8f450274, 0x401821, 0x1021,
-0xa32821, 0xa3302b, 0x822021, 0x862021,
-0x32230060, 0x24020040, 0xaf440270, 0xaf450274,
-0x10620017, 0x2c620041, 0x10400005, 0x24020020,
-0x10620008, 0x24020001, 0x10000026, 0x0,
-0x24020060, 0x10620019, 0x24020001, 0x10000021,
-0x0, 0x8f420278, 0x8f43027c, 0x24630001,
-0x2c640001, 0x441021, 0xaf420278, 0xaf43027c,
-0x8f420278, 0x8f43027c, 0x10000016, 0x24020001,
-0x8f420280, 0x8f430284, 0x24630001, 0x2c640001,
-0x441021, 0xaf420280, 0xaf430284, 0x8f420280,
-0x8f430284, 0x1000000b, 0x24020001, 0x8f420288,
-0x8f43028c, 0x24630001, 0x2c640001, 0x441021,
-0xaf420288, 0xaf43028c, 0x8f420288, 0x8f43028c,
-0x24020001, 0xa34205c2, 0x8f420098, 0x3244ffff,
-0x2406fff8, 0x8f45013c, 0x441021, 0x24420007,
-0x461024, 0x24840007, 0xaf420094, 0x8f420090,
-0x8f430094, 0x862024, 0x441023, 0x65182b,
-0x14600005, 0xaf420090, 0x8f420094, 0x8f430144,
-0x431023, 0xaf420094, 0x8f420094, 0x10000023,
-0xaf40009c, 0x3247ffff, 0x50e00022, 0x32c20020,
-0x14400002, 0x24020010, 0x24020002, 0xafa20010,
-0x8f420030, 0xafa20014, 0x8f420010, 0xafa20018,
-0x8f460098, 0x8f420108, 0x40f809, 0x0,
-0x1040003a, 0x3245ffff, 0x8f420098, 0x8f430090,
-0x8f46013c, 0x451021, 0xaf420098, 0x8f42009c,
-0x8f440098, 0xa34005c2, 0x651823, 0xaf430090,
-0x451021, 0x86202b, 0x14800005, 0xaf42009c,
-0x8f420098, 0x8f430144, 0x431023, 0xaf420098,
-0x32c20020, 0x10400005, 0x0, 0x8f420358,
-0x2442ffff, 0xaf420358, 0x8f420358, 0x8f420030,
-0x8f430040, 0x24420001, 0x2463ffff, 0x431024,
-0xaf420030, 0x8f420030, 0x14530018, 0x0,
-0x8f420000, 0x10400007, 0x0, 0xaf80004c,
-0x8f82004c, 0x1040fffd, 0x0, 0x10000005,
-0x0, 0xaf800048, 0x8f820048, 0x1040fffd,
-0x0, 0x8f820060, 0x2403fff7, 0x431024,
-0xaf820060, 0x8f420000, 0x10400003, 0x0,
-0x10000002, 0xaf80004c, 0xaf800048, 0x8fbf0038,
-0x8fb30034, 0x8fb20030, 0x8fb1002c, 0x8fb00028,
-0x3e00008, 0x27bd0040, 0x3e00008, 0x0,
-0x27bdffd0, 0x32c20020, 0xafbf002c, 0xafb20028,
-0xafb10024, 0x10400004, 0xafb00020, 0x8f520028,
-0x10000002, 0x0, 0x8f520020, 0x8f420030,
-0x105200b5, 0x21100, 0x8f43001c, 0x628021,
-0x8e040000, 0x8e050004, 0x96110008, 0x8f420090,
-0x9607000a, 0x3226ffff, 0x46102a, 0x10400017,
-0x0, 0x8f8200d8, 0x8f430098, 0x431023,
-0x2442ff80, 0xaf420090, 0x8f420090, 0x2842ff81,
-0x10400005, 0x0, 0x8f420090, 0x8f430144,
-0x431021, 0xaf420090, 0x8f420090, 0x46102a,
-0x10400006, 0x0, 0x8f420348, 0x24420001,
-0xaf420348, 0x100000ab, 0x8f420348, 0x8f8600fc,
-0x10c0000c, 0x0, 0x8f8200f4, 0x2403fff8,
-0x431024, 0x461023, 0x218c3, 0x58600001,
-0x24630100, 0x8f42008c, 0x43102b, 0x14400006,
-0x712c2, 0x8f420344, 0x24420001, 0xaf420344,
-0x10000098, 0x8f420344, 0x934305c2, 0x1060000f,
-0x30460001, 0x8f420010, 0x34480400, 0x32c20008,
-0x10400008, 0x30e20200, 0x10400006, 0x3c034000,
-0x9602000e, 0xaf4300ac, 0x21400, 0x10000004,
-0xaf4200b0, 0x10000002, 0xaf4000ac, 0x8f480010,
-0x30e20004, 0x10400045, 0x3227ffff, 0x8f4900ac,
-0x11200005, 0x30c200ff, 0x14400006, 0x24020040,
-0x10000004, 0x24020008, 0x14400002, 0x24020020,
-0x24020004, 0xafa20010, 0x8f430030, 0x11200004,
-0xafa30014, 0x8f4200b0, 0x621025, 0xafa20014,
-0x3c020002, 0x1021025, 0xafa20018, 0x8f460098,
-0x8f420108, 0x40f809, 0x0, 0x10400069,
-0x3224ffff, 0x8f42008c, 0x8f430094, 0x24420001,
-0xaf42008c, 0x24020001, 0xae03000c, 0xa34205c2,
-0x8f420098, 0x2406fff8, 0x8f45013c, 0x441021,
-0x24420007, 0x461024, 0x24840007, 0xaf420094,
-0x8f420090, 0x8f430094, 0x862024, 0x441023,
-0x65182b, 0x14600005, 0xaf420090, 0x8f420094,
-0x8f430144, 0x431023, 0xaf420094, 0x8f430094,
-0x8f420140, 0x43102b, 0x10400009, 0x0,
-0x8f43013c, 0x8f440094, 0x8f420090, 0x8f450138,
-0x641823, 0x431023, 0xaf420090, 0xaf450094,
-0x8f420094, 0x1000001f, 0xaf420098, 0x10e0001d,
-0x30c200ff, 0x14400002, 0x24020010, 0x24020002,
-0xafa20010, 0x8f420030, 0xafa80018, 0xafa20014,
-0x8f460098, 0x8f420108, 0x40f809, 0x0,
-0x10400030, 0x3225ffff, 0x8f420098, 0x8f44013c,
-0x451021, 0xaf420098, 0x8f420090, 0x8f430098,
-0xa34005c2, 0x451023, 0x64182b, 0x14600005,
-0xaf420090, 0x8f420098, 0x8f430144, 0x431023,
-0xaf420098, 0x8f420030, 0x8f430040, 0x24420001,
-0x2463ffff, 0x431024, 0xaf420030, 0x8f420030,
-0x14520018, 0x0, 0x8f420000, 0x10400007,
-0x0, 0xaf80004c, 0x8f82004c, 0x1040fffd,
-0x0, 0x10000005, 0x0, 0xaf800048,
-0x8f820048, 0x1040fffd, 0x0, 0x8f820060,
-0x2403fff7, 0x431024, 0xaf820060, 0x8f420000,
-0x10400003, 0x0, 0x10000002, 0xaf80004c,
-0xaf800048, 0x8fbf002c, 0x8fb20028, 0x8fb10024,
-0x8fb00020, 0x3e00008, 0x27bd0030, 0x3e00008,
-0x0, 0x27bdffd8, 0x3c020001, 0x34422ec0,
-0xafbf0020, 0x8f4300f0, 0x8f840108, 0x2e21021,
-0x54620004, 0x24620008, 0x3c020001, 0x34422cc0,
-0x2e21021, 0x401821, 0xaf4300f0, 0xac600000,
-0x8f4200ec, 0x8c660004, 0x14620004, 0x3c020001,
-0x24820020, 0x1000000f, 0xaf820108, 0x8f4300f0,
-0x34422ec0, 0x2e21021, 0x54620004, 0x24620008,
-0x3c020001, 0x34422cc0, 0x2e21021, 0x401821,
-0x8c620004, 0x21140, 0x821021, 0xaf820108,
-0xac600000, 0x8c850018, 0x30a20036, 0x1040006c,
-0x30a20001, 0x8c82001c, 0x8f430040, 0x8f440034,
-0x24420001, 0x2463ffff, 0x431024, 0x862021,
-0xaf42002c, 0x30a20030, 0x14400006, 0xaf440034,
-0x8f420034, 0x8c03023c, 0x43102b, 0x144000ca,
-0x0, 0x32c20010, 0x10400028, 0x24070008,
-0x8f440170, 0x8f450174, 0x8f43002c, 0x8f48000c,
-0x8f860120, 0x24020080, 0xafa20010, 0xafa30014,
-0xafa80018, 0x8f42010c, 0x40f809, 0x24c6001c,
-0x14400011, 0x24020001, 0x3c010001, 0x370821,
-0xa02240f1, 0x8f820124, 0xafa20010, 0x8f820128,
-0x3c040001, 0x24843e54, 0xafa20014, 0x8f46002c,
-0x8f870120, 0x3c050009, 0xc0029e7, 0x34a51100,
-0x10000036, 0x0, 0x8f420300, 0x8f43002c,
-0x24420001, 0xaf420300, 0x8f420300, 0x24020001,
-0xa34205c1, 0x10000026, 0xaf430038, 0x8f440170,
-0x8f450174, 0x8f43002c, 0x8f48000c, 0x8f860120,
-0x24020020, 0xafa20010, 0xafa30014, 0xafa80018,
-0x8f42010c, 0x40f809, 0x24c6001c, 0x14400011,
-0x24020001, 0x3c010001, 0x370821, 0xa02240f0,
-0x8f820124, 0xafa20010, 0x8f820128, 0x3c040001,
-0x24843e48, 0xafa20014, 0x8f46002c, 0x8f870120,
-0x3c050009, 0xc0029e7, 0x34a50900, 0x1000000f,
-0x0, 0x8f420300, 0x24420001, 0xaf420300,
-0x8f420300, 0x8f42002c, 0xa34005c1, 0xaf420038,
-0x3c010001, 0x370821, 0xa02040f1, 0x3c010001,
-0x370821, 0xa02040f0, 0xaf400034, 0x8f420314,
-0x24420001, 0xaf420314, 0x1000006f, 0x8f420314,
-0x10400022, 0x30a27000, 0x8c85001c, 0x8f420028,
-0xa22023, 0x4810003, 0x0, 0x8f420040,
-0x822021, 0x8f420358, 0x8f430000, 0xaf450028,
-0x441021, 0x10600007, 0xaf420358, 0xaf80004c,
-0x8f82004c, 0x1040fffd, 0x0, 0x10000005,
-0x0, 0xaf800048, 0x8f820048, 0x1040fffd,
-0x0, 0x8f820060, 0x34420008, 0xaf820060,
-0x8f420000, 0x10400003, 0x0, 0x1000004e,
-0xaf80004c, 0x1000004c, 0xaf800048, 0x1040002f,
-0x30a21000, 0x1040000c, 0x30a24000, 0x8c83001c,
-0x8f420050, 0x622023, 0x4820001, 0x24840200,
-0x8f42035c, 0x441021, 0xaf42035c, 0x8f420368,
-0x1000001a, 0xaf430050, 0x1040000c, 0x32c28000,
-0x8c83001c, 0x8f420070, 0x622023, 0x4820001,
-0x24840400, 0x8f420364, 0x441021, 0xaf420364,
-0x8f420368, 0x1000000d, 0xaf430070, 0x1040000e,
-0x3c020800, 0x8c83001c, 0x8f420060, 0x622023,
-0x4820001, 0x24840100, 0x8f420360, 0x441021,
-0xaf420360, 0x8f420368, 0xaf430060, 0x441021,
-0xaf420368, 0x3c020800, 0x2c21024, 0x5040001e,
-0x36940040, 0x1000001c, 0x0, 0x30a20100,
-0x10400019, 0x0, 0x3c020001, 0x8c4242c4,
-0x1040000d, 0x274301c0, 0x24650400, 0x65102b,
-0x10400007, 0x26e40028, 0x8c820000, 0xac620000,
-0x24630004, 0x65102b, 0x1440fffb, 0x24840004,
-0x10000002, 0x274401c0, 0x26e40028, 0xc002a84,
-0x0, 0x8f4202dc, 0xa34005c5, 0x24420001,
-0xaf4202dc, 0x8f4202dc, 0x8fbf0020, 0x3e00008,
-0x27bd0028, 0x3e00008, 0x0, 0x27bdffa8,
-0xafbf0050, 0xafbe004c, 0xafb50048, 0xafb30044,
-0xafb20040, 0xafb1003c, 0xafb00038, 0x8f910108,
-0x26220020, 0xaf820108, 0x8e320018, 0xa821,
-0x32420024, 0x104001ba, 0xf021, 0x8e26001c,
-0x8f43001c, 0x61100, 0x621821, 0x8c70000c,
-0x9604000c, 0x962d0016, 0x9473000a, 0x2c8305dd,
-0x38828870, 0x2c420001, 0x621825, 0x10600015,
-0x2821, 0x32c20040, 0x10400015, 0x24020800,
-0x96030014, 0x14620012, 0x3402aaaa, 0x9603000e,
-0x14620007, 0x2021, 0x96030010, 0x24020300,
-0x14620004, 0x801021, 0x96020012, 0x2c440001,
-0x801021, 0x54400006, 0x24050016, 0x10000004,
-0x0, 0x24020800, 0x50820001, 0x2405000e,
-0x934205c3, 0x14400008, 0x5821, 0x240b0001,
-0x32620180, 0xaf4500a8, 0xaf5000a0, 0x10400002,
-0xaf4600a4, 0xa34b05c3, 0x10a00085, 0x2054021,
-0x91020000, 0x3821, 0x3042000f, 0x25080,
-0x32c20002, 0x10400012, 0x10a1821, 0x32620002,
-0x10400010, 0x32c20001, 0x1002021, 0x94820000,
-0x24840002, 0xe23821, 0x83102b, 0x1440fffb,
-0x30e2ffff, 0x71c02, 0x623821, 0x71c02,
-0x30e2ffff, 0x623821, 0x71027, 0xa502000a,
-0x32c20001, 0x1040006a, 0x32620001, 0x10400068,
-0x0, 0x8f4200a8, 0x10400065, 0x0,
-0x8f4200a0, 0x8f4300a8, 0x431021, 0x904c0009,
-0x318900ff, 0x39230006, 0x3182b, 0x39220011,
-0x2102b, 0x621824, 0x1060000c, 0x3c050006,
-0x8f4200a4, 0x3c040001, 0x24843e64, 0xafa20010,
-0x8f4200a0, 0x34a54600, 0x1203821, 0xc0029e7,
-0xafa20014, 0x1000004e, 0x0, 0x32c20004,
-0x14400013, 0x2821, 0x316200ff, 0x14400004,
-0x0, 0x95020002, 0x1000000d, 0x4a2823,
-0x9505000c, 0x9502000e, 0x95030010, 0xa22821,
-0xa32821, 0x95030012, 0x91040009, 0x95020002,
-0xa32821, 0xa42821, 0x4a1023, 0xa22821,
-0x2002021, 0x94820000, 0x24840002, 0xe23821,
-0x88102b, 0x1440fffb, 0x71c02, 0x30e2ffff,
-0x623821, 0x71c02, 0x30e2ffff, 0x623821,
-0x1a52821, 0x51c02, 0x30a2ffff, 0x622821,
-0x51c02, 0x30a2ffff, 0x622821, 0xa72823,
-0x51402, 0xa22821, 0x30a5ffff, 0x50a00001,
-0x3405ffff, 0x316200ff, 0x14400008, 0x318300ff,
-0x8f4300a0, 0x8f4200a8, 0x624021, 0x91020000,
-0x3042000f, 0x25080, 0x318300ff, 0x24020006,
-0x14620003, 0x10a1021, 0x10000002, 0x24440010,
-0x24440006, 0x316200ff, 0x14400006, 0x0,
-0x94820000, 0xa22821, 0x51c02, 0x30a2ffff,
-0x622821, 0x934205c3, 0x10400003, 0x32620100,
-0x50400003, 0xa4850000, 0x52827, 0xa4850000,
-0x9622000e, 0x8f43009c, 0x621821, 0x32a200ff,
-0x10400007, 0xaf43009c, 0x3c024000, 0x2021025,
-0xafa20020, 0x8f42009c, 0x10000003, 0x5e1025,
-0xafb00020, 0x8f42009c, 0xafa20024, 0x32620080,
-0x10400010, 0x32620100, 0x8f4200b4, 0x24430001,
-0x210c0, 0x571021, 0xaf4300b4, 0x8fa30020,
-0x8fa40024, 0x3c010001, 0x220821, 0xac2338e8,
-0x3c010001, 0x220821, 0xac2438ec, 0x100000a5,
-0x32c20020, 0x10400064, 0x0, 0x8f4200b4,
-0x24430001, 0x210c0, 0x571021, 0xaf4300b4,
-0x8fa30020, 0x8fa40024, 0x3c010001, 0x220821,
-0xac2338e8, 0x3c010001, 0x220821, 0xac2438ec,
-0x8f4200b4, 0x10400051, 0x3821, 0x3c090001,
-0x352938e8, 0x3c08001f, 0x3508ffff, 0x240bffff,
-0x340affff, 0x710c0, 0x571021, 0x491021,
-0x8c430000, 0x8c440004, 0xafa30028, 0xafa4002c,
-0x8f8200fc, 0x8fa30028, 0x8fa4002c, 0xac430000,
-0xac440004, 0x24420008, 0xaf8200f0, 0x8f42008c,
-0x2442ffff, 0xaf42008c, 0x97a2002e, 0x8f440270,
-0x8f450274, 0x401821, 0x1021, 0xa32821,
-0xa3302b, 0x822021, 0x862021, 0xaf440270,
-0xaf450274, 0x8fa20028, 0x481024, 0x90430000,
-0x30630001, 0x1460000b, 0x402021, 0x8f420278,
-0x8f43027c, 0x24630001, 0x2c640001, 0x441021,
-0xaf420278, 0xaf43027c, 0x8f420278, 0x1000001a,
-0x8f43027c, 0x8c820000, 0x144b000e, 0x0,
-0x94820004, 0x144a000b, 0x0, 0x8f420288,
-0x8f43028c, 0x24630001, 0x2c640001, 0x441021,
-0xaf420288, 0xaf43028c, 0x8f420288, 0x1000000a,
-0x8f43028c, 0x8f420280, 0x8f430284, 0x24630001,
-0x2c640001, 0x441021, 0xaf420280, 0xaf430284,
-0x8f420280, 0x8f430284, 0x8f4200b4, 0x24e70001,
-0xe2102b, 0x1440ffb8, 0x710c0, 0xa34005c3,
-0x1000003f, 0xaf4000b4, 0x8f8200fc, 0x8fa30020,
-0x8fa40024, 0xac430000, 0xac440004, 0x24420008,
-0xaf8200f0, 0x8f42009c, 0x8f46008c, 0x8f440270,
-0x8f450274, 0x401821, 0x1021, 0x24c6ffff,
-0xaf46008c, 0xa32821, 0xa3302b, 0x822021,
-0x862021, 0xaf440270, 0xaf450274, 0x92020000,
-0x30420001, 0x1440000c, 0x2402ffff, 0x8f420278,
-0x8f43027c, 0x24630001, 0x2c640001, 0x441021,
-0xaf420278, 0xaf43027c, 0x8f420278, 0x8f43027c,
-0x1000001c, 0x32c20020, 0x8e030000, 0x1462000f,
-0x3402ffff, 0x96030004, 0x1462000c, 0x0,
-0x8f420288, 0x8f43028c, 0x24630001, 0x2c640001,
-0x441021, 0xaf420288, 0xaf43028c, 0x8f420288,
-0x8f43028c, 0x1000000b, 0x32c20020, 0x8f420280,
-0x8f430284, 0x24630001, 0x2c640001, 0x441021,
-0xaf420280, 0xaf430284, 0x8f420280, 0x8f430284,
-0x32c20020, 0x10400005, 0xaf40009c, 0x8f420358,
-0x2442ffff, 0xaf420358, 0x8f420358, 0x8e22001c,
-0x8f430040, 0x24420001, 0x2463ffff, 0x431024,
-0xaf42002c, 0x32420060, 0x14400008, 0x32c20010,
-0x8f420034, 0x24420001, 0xaf420034, 0x8c03023c,
-0x43102b, 0x14400118, 0x32c20010, 0x10400018,
-0x24070008, 0x8f440170, 0x8f450174, 0x8f43002c,
-0x8f48000c, 0x8f860120, 0x24020080, 0xafa20010,
-0xafa30014, 0xafa80018, 0x8f42010c, 0x40f809,
-0x24c6001c, 0x10400047, 0x24020001, 0x8f420300,
-0x8f43002c, 0x24420001, 0xaf420300, 0x8f420300,
-0x24020001, 0xa34205c1, 0x1000007c, 0xaf430038,
-0x8f440170, 0x8f450174, 0x8f43002c, 0x8f48000c,
-0x8f860120, 0x24020020, 0xafa20010, 0xafa30014,
-0xafa80018, 0x8f42010c, 0x40f809, 0x24c6001c,
-0x10400057, 0x24020001, 0x10000065, 0x0,
-0x32420012, 0x10400075, 0x32420001, 0x9622000e,
-0x8f43009c, 0x621821, 0x32c20020, 0x10400005,
-0xaf43009c, 0x8f420358, 0x2442ffff, 0xaf420358,
-0x8f420358, 0x8e22001c, 0x8f430040, 0x24420001,
-0x2463ffff, 0x431024, 0xaf42002c, 0x32420010,
-0x14400008, 0x32c20010, 0x8f420034, 0x24420001,
-0xaf420034, 0x8c03023c, 0x43102b, 0x144000d2,
-0x32c20010, 0x10400028, 0x24070008, 0x8f440170,
-0x8f450174, 0x8f43002c, 0x8f48000c, 0x8f860120,
-0x24020080, 0xafa20010, 0xafa30014, 0xafa80018,
-0x8f42010c, 0x40f809, 0x24c6001c, 0x14400011,
-0x24020001, 0x3c010001, 0x370821, 0xa02240f1,
-0x8f820124, 0xafa20010, 0x8f820128, 0x3c040001,
-0x24843e54, 0xafa20014, 0x8f46002c, 0x8f870120,
-0x3c050009, 0xc0029e7, 0x34a51100, 0x10000036,
-0x0, 0x8f420300, 0x8f43002c, 0x24420001,
-0xaf420300, 0x8f420300, 0x24020001, 0xa34205c1,
-0x10000026, 0xaf430038, 0x8f440170, 0x8f450174,
-0x8f43002c, 0x8f48000c, 0x8f860120, 0x24020020,
-0xafa20010, 0xafa30014, 0xafa80018, 0x8f42010c,
-0x40f809, 0x24c6001c, 0x14400011, 0x24020001,
-0x3c010001, 0x370821, 0xa02240f0, 0x8f820124,
-0xafa20010, 0x8f820128, 0x3c040001, 0x24843e48,
-0xafa20014, 0x8f46002c, 0x8f870120, 0x3c050009,
-0xc0029e7, 0x34a50900, 0x1000000f, 0x0,
-0x8f420300, 0x24420001, 0xaf420300, 0x8f420300,
-0x8f42002c, 0xa34005c1, 0xaf420038, 0x3c010001,
-0x370821, 0xa02040f1, 0x3c010001, 0x370821,
-0xa02040f0, 0xaf400034, 0x8f420314, 0x24420001,
-0xaf420314, 0x10000078, 0x8f420314, 0x10400022,
-0x32427000, 0x8e25001c, 0x8f420028, 0xa22023,
-0x4810003, 0x0, 0x8f420040, 0x822021,
-0x8f420358, 0x8f430000, 0xaf450028, 0x441021,
-0x10600007, 0xaf420358, 0xaf80004c, 0x8f82004c,
-0x1040fffd, 0x0, 0x10000005, 0x0,
-0xaf800048, 0x8f820048, 0x1040fffd, 0x0,
-0x8f820060, 0x34420008, 0xaf820060, 0x8f420000,
-0x10400003, 0x0, 0x10000057, 0xaf80004c,
-0x10000055, 0xaf800048, 0x1040002f, 0x32421000,
-0x1040000c, 0x32424000, 0x8e23001c, 0x8f420050,
-0x622023, 0x4820001, 0x24840200, 0x8f42035c,
-0x441021, 0xaf42035c, 0x8f420368, 0x1000001a,
-0xaf430050, 0x1040000c, 0x32c28000, 0x8e23001c,
-0x8f420070, 0x622023, 0x4820001, 0x24840400,
-0x8f420364, 0x441021, 0xaf420364, 0x8f420368,
-0x1000000d, 0xaf430070, 0x1040000e, 0x3c020800,
-0x8e23001c, 0x8f420060, 0x622023, 0x4820001,
-0x24840100, 0x8f420360, 0x441021, 0xaf420360,
-0x8f420368, 0xaf430060, 0x441021, 0xaf420368,
-0x3c020800, 0x2c21024, 0x50400027, 0x36940040,
-0x10000025, 0x0, 0x32420048, 0x10400007,
-0x24150001, 0x8e22001c, 0x3c03ffff, 0x43f024,
-0x3042ffff, 0x1000fd75, 0xae22001c, 0x32420100,
-0x10400019, 0x0, 0x3c020001, 0x8c4242c4,
-0x1040000d, 0x274301c0, 0x24650400, 0x65102b,
-0x10400007, 0x26e40028, 0x8c820000, 0xac620000,
-0x24630004, 0x65102b, 0x1440fffb, 0x24840004,
-0x10000002, 0x274401c0, 0x26e40028, 0xc002a84,
-0x0, 0x8f4202dc, 0xa34005c5, 0x24420001,
-0xaf4202dc, 0x8f4202dc, 0x8fbf0050, 0x8fbe004c,
-0x8fb50048, 0x8fb30044, 0x8fb20040, 0x8fb1003c,
-0x8fb00038, 0x3e00008, 0x27bd0058, 0x3e00008,
-0x0, 0x0, 0x0, 0x8f8300e4,
-0x8f8200e0, 0x2404fff8, 0x441024, 0x621026,
-0x2102b, 0x21023, 0x3e00008, 0x621024,
-0x3e00008, 0x0, 0x27bdffe0, 0xafbf001c,
-0xafb00018, 0x8f8600c4, 0x8f8400e0, 0x8f8500e4,
-0x2402fff8, 0x821824, 0x10a30009, 0x27623ff8,
-0x14a20002, 0x24a20008, 0x27623000, 0x408021,
-0x16030005, 0x30820004, 0x10400004, 0xc02021,
-0x10000022, 0x1021, 0x8e040000, 0x8f42011c,
-0x14a20003, 0x0, 0x8f420120, 0xaf420114,
-0x8ca30000, 0x8f420148, 0x831823, 0x43102b,
-0x10400003, 0x0, 0x8f420148, 0x621821,
-0x94a20006, 0x24420050, 0x62102b, 0x1440000f,
-0xa01021, 0xafa40010, 0xafa30014, 0x8ca60000,
-0x8ca70004, 0x3c040001, 0xc0029e7, 0x24843f24,
-0x8f42020c, 0x24420001, 0xaf42020c, 0x8f42020c,
-0x1021, 0xaf9000e8, 0xaf9000e4, 0x8fbf001c,
-0x8fb00018, 0x3e00008, 0x27bd0020, 0x3e00008,
-0x0, 0x8f8400e0, 0x8f8800c4, 0x8f8300e8,
-0x2402fff8, 0x823824, 0xe32023, 0x2c821000,
-0x50400001, 0x24841000, 0x420c2, 0x801821,
-0x8f440258, 0x8f45025c, 0x1021, 0xa32821,
-0xa3302b, 0x822021, 0x862021, 0xaf440258,
-0xaf45025c, 0x8f8300c8, 0x8f420148, 0x1032023,
-0x82102b, 0x14400004, 0x801821, 0x8f420148,
-0x822021, 0x801821, 0x8f440250, 0x8f450254,
-0x1021, 0xa32821, 0xa3302b, 0x822021,
-0x862021, 0xaf440250, 0xaf450254, 0xaf8800c8,
-0xaf8700e4, 0x3e00008, 0xaf8700e8, 0x27bdff30,
-0x240a0001, 0xafbf00c8, 0xafbe00c4, 0xafb500c0,
-0xafb300bc, 0xafb200b8, 0xafb100b4, 0xafb000b0,
-0xa3a00097, 0xafa00044, 0xafaa005c, 0x934205c4,
-0xa7a0008e, 0x1040000a, 0xa7a00086, 0x8f4b00c4,
-0xafab0064, 0x8f4a00c0, 0xafaa006c, 0x8f4b00cc,
-0xafab0074, 0x8f4a00c8, 0x10000129, 0xafaa007c,
-0x8f420114, 0x40f809, 0x0, 0x403021,
-0x10c0033f, 0x0, 0x8cc20000, 0x8cc30004,
-0xafa20020, 0xafa30024, 0x8fab0024, 0x8faa0020,
-0x3162ffff, 0x2442fffc, 0xafa2006c, 0x3c020006,
-0x2c21024, 0xafab007c, 0x14400015, 0xafaa0064,
-0x91420000, 0x30420001, 0x10400011, 0x2402ffff,
-0x8d430000, 0x14620004, 0x3402ffff, 0x95430004,
-0x1062000b, 0x0, 0xc00236a, 0x8fa40064,
-0x304200ff, 0x14400006, 0x0, 0x8f420118,
-0x40f809, 0x0, 0x1000031d, 0x0,
-0x8fa20024, 0x3c03ffbf, 0x3463ffff, 0x431024,
-0x3c03ffff, 0x431824, 0x14600003, 0xafa20024,
-0x10000040, 0x1821, 0x3c020080, 0x621024,
-0x10400007, 0x0, 0x8f42038c, 0x24420001,
-0xaf42038c, 0x8f42038c, 0x10000036, 0x24030001,
-0x8f420210, 0x24420001, 0xaf420210, 0x8f420210,
-0x3c020001, 0x621024, 0x10400006, 0x3c020002,
-0x8f4201c4, 0x24420001, 0xaf4201c4, 0x8f4201c4,
-0x3c020002, 0x621024, 0x10400006, 0x3c020004,
-0x8f42037c, 0x24420001, 0xaf42037c, 0x8f42037c,
-0x3c020004, 0x621024, 0x10400006, 0x3c020008,
-0x8f420380, 0x24420001, 0xaf420380, 0x8f420380,
-0x3c020008, 0x621024, 0x10400006, 0x3c020010,
-0x8f420384, 0x24420001, 0xaf420384, 0x8f420384,
-0x3c020010, 0x621024, 0x10400006, 0x3c020020,
-0x8f4201c0, 0x24420001, 0xaf4201c0, 0x8f4201c0,
-0x3c020020, 0x621024, 0x10400006, 0x24030001,
-0x8f420388, 0x24420001, 0xaf420388, 0x8f420388,
-0x24030001, 0x8c020260, 0x8fab006c, 0x4b102b,
-0x10400014, 0x307000ff, 0x8f4201e8, 0x24420001,
-0xaf4201e8, 0x8f4201e8, 0x8faa007c, 0x8f8200e0,
-0x354a0100, 0xafaa007c, 0xafa20010, 0x8f8200e4,
-0x24100001, 0x3c040001, 0x24843f30, 0xafa20014,
-0x8fa60020, 0x8fa70024, 0x3c050007, 0xc0029e7,
-0x34a50800, 0x12000010, 0x3c020080, 0x2c21024,
-0x1440000e, 0x32c20400, 0x8fab007c, 0x3c020080,
-0x34420100, 0x1621024, 0x10400005, 0x0,
-0x8f42020c, 0x24420001, 0xaf42020c, 0x8f42020c,
-0x100002a0, 0x8fa3006c, 0x32c20400, 0x10400015,
-0x34028100, 0x8faa0064, 0x9543000c, 0x14620012,
-0x3c020100, 0x240b0200, 0xa7ab008e, 0x9542000e,
-0x8d430008, 0x8d440004, 0x8d450000, 0x8faa006c,
-0x8fab0064, 0x254afffc, 0xafaa006c, 0xa7a20086,
-0xad63000c, 0xad640008, 0xad650004, 0x256b0004,
-0xafab0064, 0x3c020100, 0x2c21024, 0x10400004,
-0x0, 0x8faa006c, 0x254a0004, 0xafaa006c,
-0x8f4200bc, 0x5040000a, 0xafa00074, 0x8fab006c,
-0x4b102b, 0x50400006, 0xafa00074, 0x8f4200bc,
-0x1621023, 0xafa20074, 0x8f4a00bc, 0xafaa006c,
-0x8f420080, 0x8fab006c, 0x4b102b, 0x10400056,
-0x32c28000, 0x1040005e, 0x240a0003, 0x32c21000,
-0x1040005b, 0xafaa005c, 0x10000058, 0x240b0004,
-0x8f420350, 0x2403ffbf, 0x283a024, 0x24420001,
-0xaf420350, 0x1000023f, 0x8f420350, 0x2c2b025,
-0x2402ffbf, 0x282a024, 0x8f830128, 0x3c040001,
-0x24843f60, 0x26620001, 0xafa20014, 0xafa30010,
-0x8f860120, 0x8f870124, 0x3c050007, 0xc0029e7,
-0x34a52250, 0x1000022f, 0x0, 0x2c2b025,
-0x2402ffbf, 0x282a024, 0x8f830128, 0x3c040001,
-0x24843f60, 0x24020002, 0xafa20014, 0xafa30010,
-0x8f860120, 0x8f870124, 0x3c050007, 0xc0029e7,
-0x34a52450, 0x1000021f, 0x0, 0x8ea20000,
-0x8ea30004, 0x3c040001, 0x24843f78, 0xafb00010,
-0xafbe0014, 0x8ea70018, 0x34a52800, 0xc0029e7,
-0x603021, 0x10000213, 0x0, 0xa6b1000a,
-0x8f820124, 0x3c040001, 0x24843f80, 0xafbe0014,
-0xafa20010, 0x8f460044, 0x8f870120, 0x3c050007,
-0xc0029e7, 0x34a53000, 0x10000206, 0x0,
-0xa6b1000a, 0xa6b2000e, 0x8f820124, 0x3c040001,
-0x24843f8c, 0xafbe0014, 0xafa20010, 0x8f460044,
-0x8f870120, 0x3c050007, 0xc0029e7, 0x34a53200,
-0x100001f8, 0x0, 0x8f420084, 0x8faa006c,
-0x4a102b, 0x14400007, 0x3c020001, 0x2c21024,
-0x10400004, 0x0, 0x240b0002, 0xafab005c,
-0x8faa006c, 0x1140020b, 0x27ab0020, 0xafab00a4,
-0x3c0a001f, 0x354affff, 0xafaa009c, 0x8fab005c,
-0x240a0001, 0x156a0021, 0x24020002, 0x8f430054,
-0x8f420050, 0x1062000b, 0x274b0054, 0x8f5e0054,
-0x3403ecc0, 0xafab004c, 0x27c20001, 0x304201ff,
-0xafa20054, 0x1e1140, 0x431021, 0x1000006b,
-0x2e2a821, 0x8f420044, 0x8faa006c, 0x3c040001,
-0x24843f3c, 0xafaa0014, 0xafa20010, 0x8f460054,
-0x8f470050, 0x3c050007, 0xc0029e7, 0x34a51300,
-0x8f430350, 0x2402ffbf, 0x282a024, 0x24630001,
-0xaf430350, 0x100001c3, 0x8f420350, 0x1562001d,
-0x0, 0x8f430074, 0x8f420070, 0x1062000a,
-0x274a0074, 0x8f5e0074, 0xafaa004c, 0x27c20001,
-0x304203ff, 0xafa20054, 0x1e1140, 0x24426cc0,
-0x1000004a, 0x2e2a821, 0x8f420044, 0x8fab006c,
-0x3c040001, 0x24843f48, 0x3c050007, 0xafab0014,
-0xafa20010, 0x8f460074, 0x8f470070, 0x34a51500,
-0x240a0001, 0xc0029e7, 0xafaa005c, 0x1000ffc3,
-0x0, 0x8f430064, 0x8f420060, 0x1062001a,
-0x274b0064, 0x8f5e0064, 0x8faa005c, 0xafab004c,
-0x27c20001, 0x304200ff, 0xafa20054, 0x24020004,
-0x1542000e, 0x1e1140, 0x1e1180, 0x24420cc0,
-0x2e21021, 0xafa20044, 0x9442002a, 0x8fab0044,
-0x8faa006c, 0x4a102b, 0x10400024, 0x25750020,
-0x240b0001, 0x10000021, 0xa3ab0097, 0x24424cc0,
-0x1000001e, 0x2e2a821, 0x8f420044, 0x8faa006c,
-0x3c040001, 0x24843f54, 0xafaa0014, 0xafa20010,
-0x8f460064, 0x8f470060, 0x3c050007, 0xc0029e7,
-0x34a51800, 0x3c020008, 0x2c21024, 0x1440ff34,
-0x0, 0x8f420370, 0x240b0001, 0xafab005c,
-0x24420001, 0xaf420370, 0x1000ff90, 0x8f420370,
-0x27a30036, 0x131040, 0x621821, 0x94620000,
-0x441021, 0x10000020, 0xa4620000, 0x8faa0064,
-0xaeaa0018, 0x93a20097, 0x10400072, 0x9821,
-0x8fab0044, 0x8fa4006c, 0x8fa300a4, 0x25620020,
-0xafa20028, 0x25620008, 0xafa20030, 0x25620010,
-0xafab002c, 0xafa20034, 0x9562002a, 0xa7a20038,
-0x95620018, 0xa7a2003a, 0x9562001a, 0xa7a2003c,
-0x9562001c, 0xa7a2003e, 0x94620018, 0x24630002,
-0x822023, 0x1880ffde, 0x26730001, 0x2e620004,
-0x1440fff9, 0x0, 0x8f4200fc, 0x26650001,
-0xa2102a, 0x1440002b, 0x24030001, 0x8f83012c,
-0x10600023, 0x0, 0x8f820124, 0x431023,
-0x22143, 0x58800001, 0x24840040, 0x8f820128,
-0x431023, 0x21943, 0x58600001, 0x24630040,
-0x64102a, 0x54400001, 0x602021, 0xaf4400fc,
-0x8f4200fc, 0xa2102a, 0x10400011, 0x24030001,
-0x10000015, 0x306200ff, 0x8faa0064, 0x96070018,
-0xafaa0010, 0x8e220008, 0x3c040001, 0x24843f6c,
-0x8c430004, 0x8c420000, 0x34a52400, 0x2403021,
-0xc0029e7, 0xafa30014, 0x1000002b, 0x0,
-0x8f420334, 0x1821, 0x24420001, 0xaf420334,
-0x8f420334, 0x306200ff, 0x5040fedc, 0x3c020800,
-0x12600021, 0x9021, 0x8fb100a4, 0x2208021,
-0x8e220008, 0x96070018, 0x8fa60064, 0x8c440000,
-0x8c450004, 0x240b0001, 0xafab0010, 0xafbe0014,
-0x8f420008, 0xafa20018, 0x8f42010c, 0x40f809,
-0x0, 0x1040ffd8, 0x3c050007, 0x96020018,
-0x8faa0064, 0x8fab009c, 0x1425021, 0x16a102b,
-0x10400004, 0xafaa0064, 0x8f420148, 0x1425023,
-0xafaa0064, 0x26100002, 0x26520001, 0x253102b,
-0x1440ffe3, 0x26310004, 0x8fb0006c, 0x10000036,
-0x97b10038, 0x8f4200fc, 0x24050002, 0xa2102a,
-0x1440001b, 0x24030001, 0x8f83012c, 0x10600013,
-0x0, 0x8f820124, 0x431023, 0x22143,
-0x58800001, 0x24840040, 0x8f820128, 0x431023,
-0x21943, 0x58600001, 0x24630040, 0x64102a,
-0x54400001, 0x602021, 0xaf4400fc, 0x8f4200fc,
-0xa2102a, 0x14400006, 0x24030001, 0x8f420334,
-0x1821, 0x24420001, 0xaf420334, 0x8f420334,
-0x306200ff, 0x1040fea5, 0x3c020800, 0x96b1000a,
-0x8fb0006c, 0x3223ffff, 0x70102b, 0x54400001,
-0x608021, 0x8ea40000, 0x8ea50004, 0x240a0001,
-0xafaa0010, 0xafbe0014, 0x8f420008, 0x8fa60064,
-0xafa20018, 0x8f42010c, 0x40f809, 0x2003821,
-0x1040fea2, 0x3c050007, 0x96a3000e, 0x97ab008e,
-0x11600007, 0x609021, 0x934205c4, 0x14400004,
-0x0, 0x97aa0086, 0x6b1825, 0xa6aa0016,
-0x8fab007c, 0x3c02ffff, 0x1621024, 0x10400003,
-0xb1402, 0x34630400, 0xa6a20014, 0x8faa006c,
-0x560a0072, 0xa6a3000e, 0x34620004, 0xa6a2000e,
-0x8fab0074, 0x14b1021, 0xa6a2000a, 0x8f430044,
-0x8f4401a0, 0x8f4501a4, 0x34028000, 0xafa20010,
-0x8f420044, 0x2a03021, 0x24070020, 0xafa20014,
-0x8f42000c, 0x31940, 0x604821, 0xafa20018,
-0x8f42010c, 0x4021, 0xa92821, 0xa9182b,
-0x882021, 0x40f809, 0x832021, 0x5040fe7f,
-0xa6b2000e, 0x8f420368, 0xafa0006c, 0xa34005c4,
-0x2442ffff, 0xaf420368, 0x8faa005c, 0x240b0001,
-0x8f420368, 0x154b0006, 0x24020002, 0x8f42035c,
-0x2442ffff, 0xaf42035c, 0x1000000c, 0x8f42035c,
-0x15420006, 0x0, 0x8f420364, 0x2442ffff,
-0xaf420364, 0x10000005, 0x8f420364, 0x8f420360,
-0x2442ffff, 0xaf420360, 0x8f420360, 0x8faa0054,
-0x8fab004c, 0xad6a0000, 0x8f420044, 0x8f440088,
-0x8f430078, 0x24420001, 0x441024, 0x24630001,
-0xaf420044, 0xaf430078, 0x8c020240, 0x62182b,
-0x14600065, 0x24070008, 0x8f440168, 0x8f45016c,
-0x8f430044, 0x8f48000c, 0x8f860120, 0x24020040,
-0xafa20010, 0xafa30014, 0xafa80018, 0x8f42010c,
-0x40f809, 0x24c6001c, 0x14400011, 0x240b0001,
-0x3c010001, 0x370821, 0xa02b40f2, 0x8f820124,
-0xafa20010, 0x8f820128, 0x3c040001, 0x24843f1c,
-0xafa20014, 0x8f460044, 0x8f870120, 0x3c050009,
-0xc0029e7, 0x34a51300, 0x1000000b, 0x0,
-0x8f420304, 0x24420001, 0xaf420304, 0x8f420304,
-0x8f420044, 0xaf42007c, 0x3c010001, 0x370821,
-0xa02040f2, 0xaf400078, 0x8f420318, 0x24420001,
-0xaf420318, 0x10000038, 0x8f420318, 0xa6b0000a,
-0x8f430044, 0x8f4401a0, 0x8f4501a4, 0x34028000,
-0xafa20010, 0x8f420044, 0x2a03021, 0x24070020,
-0xafa20014, 0x8f42000c, 0x31940, 0x604821,
-0xafa20018, 0x8f42010c, 0x4021, 0xa92821,
-0xa9182b, 0x882021, 0x40f809, 0x832021,
-0x1040fe1f, 0x240a0001, 0xa34a05c4, 0x8fab006c,
-0x8faa0064, 0x1705823, 0xafab006c, 0x8fab009c,
-0x1505021, 0x16a102b, 0x10400004, 0xafaa0064,
-0x8f420148, 0x1425023, 0xafaa0064, 0x8f420368,
-0x2442ffff, 0xaf420368, 0x8f420368, 0x8f42035c,
-0x2442ffff, 0xaf42035c, 0x8fab0054, 0x8faa004c,
-0x8f42035c, 0xad4b0000, 0x8f420044, 0x8f440088,
-0x8f430078, 0x24420001, 0x441024, 0x24630001,
-0xaf420044, 0xaf430078, 0x8faa006c, 0x1540fe1b,
-0x0, 0x8fab006c, 0x1160001e, 0x0,
-0x934205c4, 0x10400009, 0x0, 0x8faa0064,
-0xaf4a00c4, 0xaf4b00c0, 0x8fab007c, 0xaf4b00c8,
-0x8faa0074, 0x1000000e, 0xaf4a00cc, 0x97ab008e,
-0x1160000b, 0x34038100, 0x8fa20020, 0x8c46000c,
-0xa443000c, 0x97aa0086, 0x8c440004, 0x8c450008,
-0xa44a000e, 0xac440000, 0xac450004, 0xac460008,
-0x8f42034c, 0x24420001, 0xaf42034c, 0x10000010,
-0x8f42034c, 0x8fab007c, 0x3164ffff, 0x2484fffc,
-0x801821, 0x8f440250, 0x8f450254, 0x8f460118,
-0x1021, 0xa32821, 0xa3382b, 0x822021,
-0x872021, 0xaf440250, 0xc0f809, 0xaf450254,
-0x8fbf00c8, 0x8fbe00c4, 0x8fb500c0, 0x8fb300bc,
-0x8fb200b8, 0x8fb100b4, 0x8fb000b0, 0x3e00008,
-0x27bd00d0, 0x3e00008, 0x0, 0x27bdff38,
-0x240b0001, 0xafbf00c0, 0xafbe00bc, 0xafb500b8,
-0xafb300b4, 0xafb200b0, 0xafb100ac, 0xafb000a8,
-0xa3a00087, 0xafa00044, 0xafab005c, 0x934205c4,
-0xa7a00076, 0x10400007, 0xa7a0007e, 0x8f4c00c0,
-0xafac0064, 0x8f4b00c8, 0x8f5e00c4, 0x10000130,
-0xafab006c, 0x8f420114, 0x40f809, 0x0,
-0x403021, 0x10c002a1, 0x0, 0x8cc20000,
-0x8cc30004, 0xafa20020, 0xafa30024, 0x8fac0024,
-0x8fbe0020, 0x3182ffff, 0x2442fffc, 0xafa20064,
-0x3c020006, 0x2c21024, 0x14400015, 0xafac006c,
-0x93c20000, 0x30420001, 0x10400011, 0x2402ffff,
-0x8fc30000, 0x14620004, 0x3402ffff, 0x97c30004,
-0x1062000b, 0x0, 0xc00236a, 0x3c02021,
-0x304200ff, 0x14400006, 0x0, 0x8f420118,
-0x40f809, 0x0, 0x10000280, 0x0,
-0x8fa20024, 0x3c03ffbf, 0x3463ffff, 0x431024,
-0x3c03ffff, 0x431824, 0x14600003, 0xafa20024,
-0x10000040, 0x8021, 0x3c020080, 0x621024,
-0x10400007, 0x0, 0x8f42038c, 0x24420001,
-0xaf42038c, 0x8f42038c, 0x10000036, 0x24100001,
-0x8f420210, 0x24420001, 0xaf420210, 0x8f420210,
-0x3c020001, 0x621024, 0x10400006, 0x3c020002,
-0x8f4201c4, 0x24420001, 0xaf4201c4, 0x8f4201c4,
-0x3c020002, 0x621024, 0x10400006, 0x3c020004,
-0x8f42037c, 0x24420001, 0xaf42037c, 0x8f42037c,
-0x3c020004, 0x621024, 0x10400006, 0x3c020008,
-0x8f420380, 0x24420001, 0xaf420380, 0x8f420380,
-0x3c020008, 0x621024, 0x10400006, 0x3c020010,
-0x8f420384, 0x24420001, 0xaf420384, 0x8f420384,
-0x3c020010, 0x621024, 0x10400006, 0x3c020020,
-0x8f4201c0, 0x24420001, 0xaf4201c0, 0x8f4201c0,
-0x3c020020, 0x621024, 0x10400006, 0x24100001,
-0x8f420388, 0x24420001, 0xaf420388, 0x8f420388,
-0x24100001, 0x8c020260, 0x8fab0064, 0x4b102b,
-0x10400015, 0x320200ff, 0x8f4201e8, 0x24420001,
-0xaf4201e8, 0x8f4201e8, 0x8fac006c, 0x8f8200e0,
-0x358c0100, 0xafac006c, 0xafa20010, 0x8f8200e4,
-0x24100001, 0x3c040001, 0x24843f30, 0xafa20014,
-0x8fa60020, 0x8fa70024, 0x3c050007, 0xc0029e7,
-0x34a53600, 0x320200ff, 0x10400010, 0x3c020080,
-0x2c21024, 0x1440000e, 0x32c20400, 0x8fab006c,
-0x3c020080, 0x34420100, 0x1621024, 0x10400005,
-0x0, 0x8f42020c, 0x24420001, 0xaf42020c,
-0x8f42020c, 0x10000202, 0x8fa30064, 0x32c20400,
-0x10400012, 0x34028100, 0x97c3000c, 0x1462000f,
-0x0, 0x240c0200, 0xa7ac0076, 0x97c2000e,
-0x8fc30008, 0x8fc40004, 0x8fab0064, 0x8fc50000,
-0x256bfffc, 0xafab0064, 0xa7a2007e, 0xafc3000c,
-0xafc40008, 0xafc50004, 0x27de0004, 0x8fa70064,
-0x320200ff, 0x14400034, 0x3c020100, 0x97c4000c,
-0x2c8305dd, 0x38828870, 0x2c420001, 0x621825,
-0x10600015, 0x2821, 0x32c20800, 0x10400015,
-0x24020800, 0x97c30014, 0x14620012, 0x3402aaaa,
-0x97c3000e, 0x14620007, 0x2021, 0x97c30010,
-0x24020300, 0x14620004, 0x801021, 0x97c20012,
-0x2c440001, 0x801021, 0x54400006, 0x24050016,
-0x10000004, 0x0, 0x24020800, 0x50820001,
-0x2405000e, 0x10a00013, 0x3c52021, 0x24830009,
-0x3c02001f, 0x3442ffff, 0x43102b, 0x10400003,
-0x0, 0x8f420148, 0x621823, 0x90620000,
-0x38430006, 0x2c630001, 0x38420011, 0x2c420001,
-0x621825, 0x10600004, 0x3c020100, 0x94820002,
-0x453821, 0x3c020100, 0x2c21024, 0x5040000e,
-0xafa70064, 0x8fac0064, 0x10ec0008, 0x3c050007,
-0x3c040001, 0x24843f98, 0x8fa60064, 0x34a54000,
-0xafa00010, 0xc0029e7, 0xafa00014, 0x8fab0064,
-0x256b0004, 0xafab0064, 0x8f420080, 0x8fac0064,
-0x4c102b, 0x1040002c, 0x32c28000, 0x10400034,
-0x240b0003, 0x32c21000, 0x10400031, 0xafab005c,
-0x1000002e, 0x240c0004, 0x8f420350, 0x2403ffbf,
-0x283a024, 0x24420001, 0xaf420350, 0x10000173,
-0x8f420350, 0x3c020800, 0x2c2b025, 0x2402ffbf,
-0x282a024, 0x8f830128, 0x3c040001, 0x24843f60,
-0x26620001, 0xafa20014, 0xafa30010, 0x8f860120,
-0x8f870124, 0x3c050007, 0xc0029e7, 0x34a55300,
-0x10000162, 0x0, 0x8ea20000, 0x8ea30004,
-0x3c040001, 0x24843f78, 0xafb00010, 0xafb10014,
-0x8ea70018, 0x34a55900, 0xc0029e7, 0x603021,
-0x10000156, 0x0, 0x8f420084, 0x8fab0064,
-0x4b102b, 0x14400007, 0x3c020001, 0x2c21024,
-0x10400004, 0x0, 0x240c0002, 0xafac005c,
-0x8fab0064, 0x11600166, 0x27ac0020, 0xafac008c,
-0x8fab005c, 0x240c0001, 0x556c0021, 0x240c0002,
-0x8f430054, 0x8f420050, 0x1062000b, 0x274b0054,
-0x8f510054, 0x3403ecc0, 0xafab004c, 0x26220001,
-0x304201ff, 0xafa20054, 0x111140, 0x431021,
-0x1000006b, 0x2e2a821, 0x8f420044, 0x8fac0064,
-0x3c040001, 0x24843f3c, 0xafac0014, 0xafa20010,
-0x8f460054, 0x8f470050, 0x3c050007, 0xc0029e7,
-0x34a54300, 0x8f430350, 0x2402ffbf, 0x282a024,
-0x24630001, 0xaf430350, 0x10000124, 0x8f420350,
-0x156c001d, 0x0, 0x8f430074, 0x8f420070,
-0x1062000a, 0x274b0074, 0x8f510074, 0xafab004c,
-0x26220001, 0x304203ff, 0xafa20054, 0x111140,
-0x24426cc0, 0x1000004a, 0x2e2a821, 0x8f420044,
-0x8fac0064, 0x3c040001, 0x24843f48, 0x3c050007,
-0xafac0014, 0xafa20010, 0x8f460074, 0x8f470070,
-0x34a54500, 0x240b0001, 0xc0029e7, 0xafab005c,
-0x1000ffc3, 0x0, 0x8f430064, 0x8f420060,
-0x1062001a, 0x274c0064, 0x8f510064, 0x8fab005c,
-0xafac004c, 0x26220001, 0x304200ff, 0xafa20054,
-0x24020004, 0x1562000e, 0x111140, 0x111180,
-0x24420cc0, 0x2e21021, 0xafa20044, 0x9442002a,
-0x8fac0044, 0x8fab0064, 0x4b102b, 0x10400024,
-0x25950020, 0x240c0001, 0x10000021, 0xa3ac0087,
-0x24424cc0, 0x1000001e, 0x2e2a821, 0x8f420044,
-0x8fab0064, 0x3c040001, 0x24843f54, 0xafab0014,
-0xafa20010, 0x8f460064, 0x8f470060, 0x3c050007,
-0xc0029e7, 0x34a54800, 0x3c020008, 0x2c21024,
-0x1440ff61, 0x0, 0x8f420370, 0x240c0001,
-0xafac005c, 0x24420001, 0xaf420370, 0x1000ff90,
-0x8f420370, 0x27a30036, 0x131040, 0x621821,
-0x94620000, 0x441021, 0x1000001f, 0xa4620000,
-0xaebe0018, 0x93a20087, 0x10400084, 0x9821,
-0x8fab0044, 0x8fa40064, 0x8fa3008c, 0x25620020,
-0xafa20028, 0x25620008, 0xafa20030, 0x25620010,
-0xafab002c, 0xafa20034, 0x9562002a, 0xa7a20038,
-0x95620018, 0xa7a2003a, 0x9562001a, 0xa7a2003c,
-0x9562001c, 0xa7a2003e, 0x94620018, 0x24630002,
-0x822023, 0x1880ffdf, 0x26730001, 0x2e620004,
-0x1440fff9, 0x0, 0x8f4200fc, 0x262102a,
-0x14400030, 0x24030001, 0x8f83012c, 0x10600028,
-0x0, 0x8f820124, 0x431023, 0x22143,
-0x58800001, 0x24840040, 0x8f820128, 0x431023,
-0x21943, 0x58600001, 0x24630040, 0x64102a,
-0x54400001, 0x602021, 0xaf4400fc, 0x8f4200fc,
-0x262102a, 0x10400016, 0x24030001, 0x1000001a,
-0x306200ff, 0x8fac008c, 0x101040, 0x4c1021,
-0x94470018, 0x101080, 0x4c1021, 0xafbe0010,
-0x8c420008, 0x3c040001, 0x24843f6c, 0x3c050007,
-0x8c430004, 0x8c420000, 0x34a55500, 0x2003021,
-0xc0029e7, 0xafa30014, 0x10000039, 0x0,
-0x8f420334, 0x1821, 0x24420001, 0xaf420334,
-0x8f420334, 0x306200ff, 0x1040ff06, 0x8021,
-0x8f430008, 0x2402fbff, 0x1260002d, 0x625024,
-0x3c0b4000, 0x22b4025, 0x8fb1008c, 0x2669ffff,
-0x2209021, 0x8e420008, 0x96270018, 0x8c440000,
-0x8c450004, 0x56090004, 0x240b0001, 0x240c0002,
-0x10000002, 0xafac0010, 0xafab0010, 0x16000004,
-0xafa80014, 0x8f420008, 0x10000002, 0xafa20018,
-0xafaa0018, 0x8f42010c, 0x3c03021, 0xafa80098,
-0xafa9009c, 0x40f809, 0xafaa00a0, 0x8fa80098,
-0x8fa9009c, 0x8faa00a0, 0x1040ffc2, 0x3c02001f,
-0x96230018, 0x3442ffff, 0x3c3f021, 0x5e102b,
-0x10400003, 0x26310002, 0x8f420148, 0x3c2f023,
-0x26100001, 0x213102b, 0x1440ffda, 0x26520004,
-0x8fb00064, 0x1000001a, 0x0, 0x96a3000a,
-0x8fb00064, 0x70102b, 0x54400001, 0x608021,
-0x8ea40000, 0x8ea50004, 0x8fab005c, 0x240c0002,
-0xafac0010, 0x934305c4, 0xb1700, 0x10600003,
-0x2223025, 0x3c020800, 0xc23025, 0xafa60014,
-0x8f420008, 0xafa20018, 0x8f42010c, 0x3c03021,
-0x40f809, 0x2003821, 0x1040fecb, 0x3c050007,
-0x97ac0076, 0x11800007, 0x96a3000e, 0x934205c4,
-0x14400004, 0x0, 0x97ab007e, 0x6c1825,
-0xa6ab0016, 0x8fac006c, 0x3c02ffff, 0x1821024,
-0x10400003, 0xc1402, 0x34630400, 0xa6a20014,
-0xa6b0000a, 0x8fab0064, 0x560b0006, 0x3d0f021,
-0x34620004, 0xafa00064, 0xa6a2000e, 0x1000000d,
-0xa34005c4, 0x8fac0064, 0x3c02001f, 0x3442ffff,
-0x5e102b, 0x1906023, 0xafac0064, 0xa6a3000e,
-0x240b0001, 0x10400003, 0xa34b05c4, 0x8f420148,
-0x3c2f023, 0x8fab0054, 0x8fac004c, 0xad8b0000,
-0x8fac0064, 0x1580feba, 0x0, 0x8fab0064,
-0x1160001b, 0x0, 0x934205c4, 0x10400006,
-0x0, 0xaf5e00c4, 0xaf4b00c0, 0x8fac006c,
-0x1000000e, 0xaf4c00c8, 0x97ab0076, 0x1160000b,
-0x34038100, 0x8fa20020, 0x8c46000c, 0xa443000c,
-0x97ac007e, 0x8c440004, 0x8c450008, 0xa44c000e,
-0xac440000, 0xac450004, 0xac460008, 0x8f42034c,
-0x24420001, 0xaf42034c, 0x10000010, 0x8f42034c,
-0x8fab006c, 0x3164ffff, 0x2484fffc, 0x801821,
-0x8f440250, 0x8f450254, 0x8f460118, 0x1021,
-0xa32821, 0xa3382b, 0x822021, 0x872021,
-0xaf440250, 0xc0f809, 0xaf450254, 0x8fbf00c0,
-0x8fbe00bc, 0x8fb500b8, 0x8fb300b4, 0x8fb200b0,
-0x8fb100ac, 0x8fb000a8, 0x3e00008, 0x27bd00c8,
-0x3e00008, 0x0, 0x27bdffd8, 0xafbf0024,
-0xafb00020, 0x8f43004c, 0x8f420048, 0x10620034,
-0x0, 0x8f430048, 0x8f42004c, 0x622023,
-0x4820001, 0x24840200, 0x8f430054, 0x8f42004c,
-0x43102b, 0x14400004, 0x24020200, 0x8f43004c,
-0x10000005, 0x431023, 0x8f420054, 0x8f43004c,
-0x431023, 0x2442ffff, 0x405021, 0x8a102a,
-0x54400001, 0x805021, 0x8f49004c, 0x8f48004c,
-0x8f440188, 0x8f45018c, 0x8f46004c, 0x24071000,
-0xafa70010, 0x84140, 0x1001821, 0x12a4821,
-0x313001ff, 0xafb00014, 0x8f470014, 0x1021,
-0x63140, 0xafa70018, 0xa32821, 0xa3382b,
-0x822021, 0x872021, 0x3402ecc0, 0xc23021,
-0x8f420108, 0x2e63021, 0x40f809, 0xa3940,
-0x54400001, 0xaf50004c, 0x8f43004c, 0x8f420048,
-0x14620018, 0x0, 0x8f420000, 0x10400007,
-0x0, 0xaf80004c, 0x8f82004c, 0x1040fffd,
-0x0, 0x10000005, 0x0, 0xaf800048,
-0x8f820048, 0x1040fffd, 0x0, 0x8f820060,
-0x2403fdff, 0x431024, 0xaf820060, 0x8f420000,
-0x10400003, 0x0, 0x10000002, 0xaf80004c,
-0xaf800048, 0x8fbf0024, 0x8fb00020, 0x3e00008,
-0x27bd0028, 0x3e00008, 0x0, 0x27bdffd8,
-0xafbf0024, 0xafb00020, 0x8f43005c, 0x8f420058,
-0x10620049, 0x0, 0x8f430058, 0x8f42005c,
-0x622023, 0x4820001, 0x24840100, 0x8f430064,
-0x8f42005c, 0x43102b, 0x14400004, 0x24020100,
-0x8f43005c, 0x10000005, 0x431023, 0x8f420064,
-0x8f43005c, 0x431023, 0x2442ffff, 0x403821,
-0x87102a, 0x54400001, 0x803821, 0x8f42005c,
-0x471021, 0x305000ff, 0x32c21000, 0x10400015,
-0x24082000, 0x8f49005c, 0x8f440190, 0x8f450194,
-0x8f46005c, 0x73980, 0xafa80010, 0xafb00014,
-0x8f480014, 0x94980, 0x1201821, 0x1021,
-0xa32821, 0xa3482b, 0x822021, 0x892021,
-0x63180, 0xafa80018, 0x8f420108, 0x10000014,
-0x24c60cc0, 0x8f49005c, 0x8f440190, 0x8f450194,
-0x8f46005c, 0x73940, 0xafa80010, 0xafb00014,
-0x8f480014, 0x94940, 0x1201821, 0x1021,
-0xa32821, 0xa3482b, 0x822021, 0x892021,
-0x63140, 0xafa80018, 0x8f420108, 0x24c64cc0,
-0x40f809, 0x2e63021, 0x54400001, 0xaf50005c,
-0x8f43005c, 0x8f420058, 0x14620018, 0x0,
-0x8f420000, 0x10400007, 0x0, 0xaf80004c,
-0x8f82004c, 0x1040fffd, 0x0, 0x10000005,
-0x0, 0xaf800048, 0x8f820048, 0x1040fffd,
-0x0, 0x8f820060, 0x2403feff, 0x431024,
-0xaf820060, 0x8f420000, 0x10400003, 0x0,
-0x10000002, 0xaf80004c, 0xaf800048, 0x8fbf0024,
-0x8fb00020, 0x3e00008, 0x27bd0028, 0x3e00008,
-0x0, 0x27bdffd8, 0xafbf0024, 0xafb00020,
-0x8f43006c, 0x8f420068, 0x10620033, 0x0,
-0x8f430068, 0x8f42006c, 0x622023, 0x4820001,
-0x24840400, 0x8f430074, 0x8f42006c, 0x43102b,
-0x14400004, 0x24020400, 0x8f43006c, 0x10000005,
-0x431023, 0x8f420074, 0x8f43006c, 0x431023,
-0x2442ffff, 0x405021, 0x8a102a, 0x54400001,
-0x805021, 0x8f49006c, 0x8f48006c, 0x8f440198,
-0x8f45019c, 0x8f46006c, 0x24074000, 0xafa70010,
-0x84140, 0x1001821, 0x12a4821, 0x313003ff,
-0xafb00014, 0x8f470014, 0x1021, 0x63140,
-0x24c66cc0, 0xafa70018, 0xa32821, 0xa3382b,
-0x822021, 0x872021, 0x8f420108, 0x2e63021,
-0x40f809, 0xa3940, 0x54400001, 0xaf50006c,
-0x8f43006c, 0x8f420068, 0x14620018, 0x0,
-0x8f420000, 0x10400007, 0x0, 0xaf80004c,
-0x8f82004c, 0x1040fffd, 0x0, 0x10000005,
-0x0, 0xaf800048, 0x8f820048, 0x1040fffd,
-0x0, 0x8f820060, 0x2403f7ff, 0x431024,
-0xaf820060, 0x8f420000, 0x10400003, 0x0,
-0x10000002, 0xaf80004c, 0xaf800048, 0x8fbf0024,
-0x8fb00020, 0x3e00008, 0x27bd0028, 0x3e00008,
-0x0, 0x8f4200fc, 0x3c030001, 0x8f4400f8,
-0x346330c8, 0x24420001, 0xaf4200fc, 0x8f850128,
-0x2e31021, 0x54820004, 0x24820008, 0x3c020001,
-0x34422ec8, 0x2e21021, 0x401821, 0xaf4300f8,
-0xac600000, 0x8f4200f4, 0x14620004, 0x3c020001,
-0x24a20020, 0x1000000f, 0xaf820128, 0x8f4300f8,
-0x344230c8, 0x2e21021, 0x54620004, 0x24620008,
-0x3c020001, 0x34422ec8, 0x2e21021, 0x401821,
-0x8c620004, 0x21140, 0xa21021, 0xaf820128,
-0xac600000, 0x8ca30018, 0x30620070, 0x1040002d,
-0x30620020, 0x10400004, 0x3c020010, 0x2c21024,
-0x1040000d, 0x0, 0x30620040, 0x10400004,
-0x3c020020, 0x2c21024, 0x10400007, 0x0,
-0x30620010, 0x1040001f, 0x3c020040, 0x2c21024,
-0x1440001c, 0x0, 0x8f820040, 0x30420001,
-0x14400008, 0x2021, 0x8c030104, 0x24020001,
-0x50620005, 0x24040001, 0x8c020264, 0x10400003,
-0x801021, 0x24040001, 0x801021, 0x10400006,
-0x0, 0x8f42030c, 0x24420001, 0xaf42030c,
-0x10000008, 0x8f42030c, 0x8f820044, 0x34420004,
-0xaf820044, 0x8f420308, 0x24420001, 0xaf420308,
-0x8f420308, 0x3e00008, 0x0, 0x3e00008,
-0x0, 0x27bdff98, 0xafbf0060, 0xafbe005c,
-0xafb50058, 0xafb30054, 0xafb20050, 0xafb1004c,
-0xafb00048, 0x8f4200fc, 0x24420001, 0xaf4200fc,
-0x8f880128, 0x25020020, 0xaf820128, 0x8d030018,
-0x30620070, 0x1040002e, 0x30620020, 0x10400004,
-0x3c020010, 0x2c21024, 0x1040000d, 0x0,
-0x30620040, 0x10400004, 0x3c020020, 0x2c21024,
-0x10400007, 0x0, 0x30620010, 0x104001a9,
-0x3c020040, 0x2c21024, 0x144001a6, 0x0,
-0x8f820040, 0x30420001, 0x14400008, 0x2021,
-0x8c030104, 0x24020001, 0x50620005, 0x24040001,
-0x8c020264, 0x10400003, 0x801021, 0x24040001,
-0x801021, 0x10400006, 0x0, 0x8f42030c,
-0x24420001, 0xaf42030c, 0x10000192, 0x8f42030c,
-0x8f820044, 0x34420004, 0xaf820044, 0x8f420308,
-0x24420001, 0xaf420308, 0x1000018a, 0x8f420308,
-0x30620002, 0x1040014b, 0x3c020800, 0x8d1e001c,
-0x1e5702, 0xafaa0034, 0x950a0016, 0x3c22024,
-0xafaa0024, 0x8faa0034, 0x24020001, 0x15420006,
-0x33deffff, 0x1e1140, 0x3403ecc0, 0x431021,
-0x10000010, 0x2e2a821, 0x24020002, 0x15420005,
-0x24020003, 0x1e1140, 0x24426cc0, 0x10000009,
-0x2e2a821, 0x15420005, 0x1e1180, 0x1e1140,
-0x24424cc0, 0x10000003, 0x2e2a821, 0x571021,
-0x24550ce0, 0x96a2000e, 0x304afffc, 0x30420400,
-0x10400003, 0xafaa002c, 0x100000e1, 0x8821,
-0x10800004, 0x8821, 0x97b10026, 0x100000dd,
-0xa6b10012, 0x8eb30018, 0x966a000c, 0xa7aa003e,
-0x97a5003e, 0x2ca305dd, 0x38a28870, 0x2c420001,
-0x621825, 0x10600015, 0x2021, 0x32c20800,
-0x10400015, 0x24020800, 0x96630014, 0x14620012,
-0x3402aaaa, 0x9663000e, 0x14620007, 0x2821,
-0x96630010, 0x24020300, 0x14620004, 0xa01021,
-0x96620012, 0x2c450001, 0xa01021, 0x54400006,
-0x24040016, 0x10000004, 0x0, 0x24020800,
-0x50a20001, 0x2404000e, 0x108000b9, 0x2649021,
-0x92420000, 0x3042000f, 0x28080, 0x32c20100,
-0x10400020, 0x2501821, 0x3c020020, 0x43102b,
-0x1440000e, 0x2402021, 0x2821, 0x94820000,
-0x24840002, 0xa22821, 0x83102b, 0x1440fffb,
-0x30a2ffff, 0x51c02, 0x622821, 0x51c02,
-0x30a2ffff, 0x10000009, 0x622821, 0x8f470148,
-0x8f420110, 0x102842, 0x3c060020, 0x40f809,
-0xafa80040, 0x3045ffff, 0x8fa80040, 0x50a00001,
-0x3405ffff, 0x8faa002c, 0x354a0002, 0x10000002,
-0xafaa002c, 0x2821, 0x32c20080, 0x10400090,
-0xa6a50010, 0x26430009, 0x3c02001f, 0x3442ffff,
-0x43102b, 0x10400003, 0x0, 0x8f420148,
-0x621823, 0x90660000, 0x30c200ff, 0x38430006,
-0x2c630001, 0x38420011, 0x2c420001, 0x621825,
-0x1060007f, 0x24020800, 0x8821, 0x97a3003e,
-0x1462000f, 0x2602021, 0x96710000, 0x96620002,
-0x96630004, 0x96640006, 0x2228821, 0x2238821,
-0x2248821, 0x96620008, 0x9663000a, 0x9664000c,
-0x2228821, 0x2238821, 0x10000007, 0x2248821,
-0x94820000, 0x24840002, 0x2228821, 0x92102b,
-0x1440fffb, 0x0, 0x111c02, 0x3222ffff,
-0x628821, 0x111c02, 0x3222ffff, 0x628821,
-0x32c20200, 0x10400003, 0x26440006, 0x1000003e,
-0x8021, 0x3c05001f, 0x34a5ffff, 0xa4102b,
-0x10400003, 0x0, 0x8f420148, 0x822023,
-0x94820000, 0x30421fff, 0x10400004, 0x2644000c,
-0x96420002, 0x10000030, 0x508023, 0x96420002,
-0x26430014, 0x508023, 0x3c020020, 0x43102b,
-0x1440000a, 0xd08021, 0x9642000c, 0x2028021,
-0x9642000e, 0x96430010, 0x96440012, 0x2028021,
-0x2038021, 0x10000020, 0x2048021, 0xa4102b,
-0x10400003, 0x0, 0x8f420148, 0x822023,
-0x94820000, 0x24840002, 0x2028021, 0xa4102b,
-0x10400003, 0x0, 0x8f420148, 0x822023,
-0x94820000, 0x24840002, 0x2028021, 0xa4102b,
-0x10400003, 0x0, 0x8f420148, 0x822023,
-0x94820000, 0x24840002, 0x2028021, 0xa4102b,
-0x10400003, 0x0, 0x8f420148, 0x822023,
-0x94820000, 0x2028021, 0x3c020100, 0x2c21024,
-0x1040000e, 0x0, 0x8faa002c, 0x31420004,
-0x1040000a, 0x0, 0x9504000e, 0x2642021,
-0xc003d80, 0x2484fffc, 0x3042ffff, 0x2228821,
-0x111c02, 0x3222ffff, 0x628821, 0x8faa0024,
-0x1518823, 0x111402, 0x2228821, 0x2308821,
-0x111402, 0x2228821, 0x3231ffff, 0x52200001,
-0x3411ffff, 0x8faa002c, 0x354a0001, 0xafaa002c,
-0xa6b10012, 0x97aa002e, 0xa6aa000e, 0x8faa002c,
-0x31420004, 0x10400002, 0x24091000, 0x34098000,
-0x8f480044, 0x8f4401a0, 0x8f4501a4, 0xafa90010,
-0x8f490044, 0x84140, 0x1001821, 0xafa90014,
-0x8f48000c, 0x2a03021, 0x24070020, 0xafa80018,
-0x8f48010c, 0x1021, 0xa32821, 0xa3482b,
-0x822021, 0x100f809, 0x892021, 0x1440000b,
-0x0, 0x8f820128, 0x3c040001, 0x24843fa4,
-0xafbe0014, 0xafa20010, 0x8f860124, 0x8f870120,
-0x3c050007, 0xc0029e7, 0x34a59920, 0x8f420368,
-0x2442ffff, 0xaf420368, 0x8f420044, 0x8f430088,
-0x24420001, 0x431024, 0xaf420044, 0x8faa0034,
-0x8f440368, 0x24020001, 0x15420006, 0x24020002,
-0x8f42035c, 0x2442ffff, 0xaf42035c, 0x10000049,
-0x8f42035c, 0x15420006, 0x0, 0x8f420364,
-0x2442ffff, 0xaf420364, 0x10000042, 0x8f420364,
-0x8f420360, 0x2442ffff, 0xaf420360, 0x1000003d,
-0x8f420360, 0x30621000, 0x10400005, 0x30628000,
-0x8f420078, 0x24420001, 0x10000036, 0xaf420078,
-0x10400034, 0x0, 0x8f420078, 0x24420001,
-0xaf420078, 0x8c030240, 0x43102b, 0x1440002d,
-0x24070008, 0x8f440168, 0x8f45016c, 0x8f430044,
-0x8f48000c, 0x8f860120, 0x24020040, 0xafa20010,
-0xafa30014, 0xafa80018, 0x8f42010c, 0x40f809,
-0x24c6001c, 0x14400011, 0x24020001, 0x3c010001,
-0x370821, 0xa02240f2, 0x8f820124, 0xafa20010,
-0x8f820128, 0x3c040001, 0x24843f1c, 0xafa20014,
-0x8f460044, 0x8f870120, 0x3c050009, 0xc0029e7,
-0x34a51300, 0x1000000b, 0x0, 0x8f420304,
-0x24420001, 0xaf420304, 0x8f420304, 0x8f420044,
-0xaf42007c, 0x3c010001, 0x370821, 0xa02040f2,
-0xaf400078, 0x8f420318, 0x24420001, 0xaf420318,
-0x8f420318, 0x8fbf0060, 0x8fbe005c, 0x8fb50058,
-0x8fb30054, 0x8fb20050, 0x8fb1004c, 0x8fb00048,
-0x3e00008, 0x27bd0068, 0x3e00008, 0x0,
-0x0, 0x0, 0x0, 0x8f42013c,
-0xaf8200c0, 0x8f42013c, 0xaf8200c4, 0x8f42013c,
-0xaf8200c8, 0x8f420138, 0xaf8200d0, 0x8f420138,
-0xaf8200d4, 0x8f420138, 0x3e00008, 0xaf8200d8,
-0x27bdffe0, 0x27840208, 0x24050200, 0xafbf0018,
-0xc002a6b, 0x24060008, 0x8c020204, 0xc003ea6,
-0xaf820210, 0x2021, 0x8c060248, 0x24020004,
-0x3c010001, 0xac224388, 0xc004998, 0x24050004,
-0x3c020001, 0x8c424384, 0x30420001, 0x10400007,
-0x24020001, 0x3c010001, 0xac224388, 0x2021,
-0x24050001, 0xc004998, 0x3c06601b, 0x3c040001,
-0x24844060, 0x8f420150, 0x8f430154, 0x3c050008,
-0x8f460158, 0x21640, 0x31940, 0x34630403,
-0x431025, 0x633c0, 0x461025, 0xaf82021c,
-0xafa00010, 0xafa00014, 0x8f86021c, 0x34a50200,
-0xc0029e7, 0x3821, 0x3c010001, 0xac204380,
-0x3c010001, 0xac204398, 0x8fbf0018, 0x3e00008,
-0x27bd0020, 0x27bdffe0, 0x3c050008, 0x34a50300,
-0xafbf0018, 0xafa00010, 0xafa00014, 0x8f860200,
-0x3c040001, 0x2484406c, 0xc0029e7, 0x3821,
-0x8f420410, 0x24420001, 0xaf420410, 0x8f420410,
-0x8fbf0018, 0x3e00008, 0x27bd0020, 0x27bdffd8,
-0xafbf0020, 0xafb1001c, 0xafb00018, 0x8f4203a4,
-0x24420001, 0xaf4203a4, 0x8f4203a4, 0x8f900220,
-0x8f8200e0, 0xafa20010, 0x8f8200e4, 0xafa20014,
-0x8f8600c4, 0x8f8700c8, 0x3c040001, 0x24844078,
-0xc0029e7, 0x2002821, 0x3c044000, 0x2041024,
-0x504000b4, 0x3c040100, 0x8f4203bc, 0x24420001,
-0xaf4203bc, 0x8f4203bc, 0x8f8700c4, 0x8f8300c8,
-0x8f420148, 0x671823, 0x43102b, 0x10400003,
-0x0, 0x8f420148, 0x621821, 0x10600005,
-0x0, 0x8f42014c, 0x43102b, 0x1040000b,
-0x0, 0x8f8200e0, 0x8f430124, 0xaf42011c,
-0xaf430114, 0x8f820220, 0x3c0308ff, 0x3463fffb,
-0x431024, 0x100000ce, 0x441025, 0x8f820220,
-0x3c0308ff, 0x3463ffff, 0x431024, 0x34420004,
-0xaf820220, 0x8f8200e0, 0x8f430124, 0xaf42011c,
-0xaf430114, 0x8f8600c8, 0x8f840120, 0x8f830124,
-0x10000005, 0x2821, 0x14620002, 0x24620020,
-0x27624800, 0x401821, 0x1064000c, 0x30a200ff,
-0x8c620018, 0x30420003, 0x1040fff7, 0x27624fe0,
-0x8f4203d0, 0x24050001, 0x24420001, 0xaf4203d0,
-0x8f4203d0, 0x8c660008, 0x30a200ff, 0x14400058,
-0x0, 0x934205c4, 0x14400055, 0x0,
-0x8f8700c4, 0x8f8800e0, 0x8f8400e4, 0x2402fff8,
-0x1024024, 0x1041023, 0x218c3, 0x4620001,
-0x24630200, 0x10600005, 0x24020001, 0x10620009,
-0x0, 0x1000001f, 0x0, 0x8f4203c0,
-0xe03021, 0x24420001, 0xaf4203c0, 0x10000040,
-0x8f4203c0, 0x8f4203c4, 0x24420001, 0xaf4203c4,
-0x8c860000, 0x8f420148, 0x8f4303c4, 0xe61823,
-0x43102b, 0x10400004, 0x2c62233f, 0x8f420148,
-0x621821, 0x2c62233f, 0x14400031, 0x0,
-0x8f42020c, 0x24420001, 0xaf42020c, 0x8f42020c,
-0xe03021, 0x24820008, 0xaf8200e4, 0x10000028,
-0xaf8200e8, 0x8f4203c8, 0x24420001, 0xaf4203c8,
-0x8f4203c8, 0x8c850000, 0x8f420148, 0xa71823,
-0x43102b, 0x10400003, 0x0, 0x8f420148,
-0x621821, 0x8f42014c, 0x43102b, 0x5440000a,
-0xa03021, 0x8f42020c, 0x24420001, 0xaf42020c,
-0x8f42020c, 0x24820008, 0xaf8200e4, 0x8f8400e4,
-0x1488ffec, 0xaf8400e8, 0x1488000d, 0x27623000,
-0x14820002, 0x2482fff8, 0x27623ff8, 0x94430006,
-0x3c02001f, 0x3442ffff, 0xc33021, 0x46102b,
-0x10400003, 0x0, 0x8f420148, 0xc23023,
-0xaf8600c8, 0x8f8300c4, 0x8f420148, 0xc31823,
-0x43102b, 0x10400003, 0x0, 0x8f420148,
-0x621821, 0x10600005, 0x0, 0x8f42014c,
-0x43102b, 0x50400008, 0x3c02fdff, 0x8f820220,
-0x3c0308ff, 0x3463fffb, 0x431024, 0x3c034000,
-0x1000003f, 0x431025, 0x8f4303cc, 0x3442ffff,
-0x282a024, 0x24630001, 0xaf4303cc, 0x10000039,
-0x8f4203cc, 0x2041024, 0x1040000e, 0x3c110200,
-0x8f4203a8, 0x24420001, 0xaf4203a8, 0x8f4203a8,
-0x8f820220, 0x3c0308ff, 0x3463ffff, 0x431024,
-0x441025, 0xc003c45, 0xaf820220, 0x10000029,
-0x0, 0x2111024, 0x50400008, 0x3c110400,
-0x8f4203ac, 0x24420001, 0xaf4203ac, 0xc003c45,
-0x8f4203ac, 0x10000019, 0x0, 0x2111024,
-0x1040001c, 0x0, 0x8f830224, 0x24021402,
-0x14620009, 0x3c050008, 0x3c040001, 0x24844084,
-0xafa00010, 0xafa00014, 0x8f860224, 0x34a50500,
-0xc0029e7, 0x3821, 0x8f4203b0, 0x24420001,
-0xaf4203b0, 0x8f4203b0, 0x8f820220, 0x2002021,
-0x34420002, 0xc004730, 0xaf820220, 0x8f820220,
-0x3c0308ff, 0x3463ffff, 0x431024, 0x511025,
-0xaf820220, 0x8fbf0020, 0x8fb1001c, 0x8fb00018,
-0x3e00008, 0x27bd0028, 0x3e00008, 0x0,
-0x3c020001, 0x8c424398, 0x27bdffb0, 0xafbf0048,
-0xafbe0044, 0xafb50040, 0xafb3003c, 0xafb20038,
-0xafb10034, 0x1040000f, 0xafb00030, 0x3c040001,
-0x24844090, 0x3c050008, 0xafa00010, 0xafa00014,
-0x8f860220, 0x34a50600, 0x24020001, 0x3c010001,
-0xac204398, 0x3c010001, 0xac22438c, 0xc0029e7,
-0x3821, 0x3c037fff, 0x8c020268, 0x3463ffff,
-0x3c04fdff, 0x431024, 0xac020268, 0x8f420004,
-0x3484ffff, 0x30420002, 0x10400092, 0x284a024,
-0x3c040600, 0x34842000, 0x8f420004, 0x2821,
-0x2403fffd, 0x431024, 0xaf420004, 0xafa40020,
-0x8f5e0018, 0x27aa0020, 0x240200ff, 0x13c20002,
-0xafaa002c, 0x27c50001, 0x8c020228, 0xa09021,
-0x1642000e, 0x1e38c0, 0x8f42033c, 0x24420001,
-0xaf42033c, 0x8f42033c, 0x8c020228, 0x3c040001,
-0x24844028, 0x3c050009, 0xafa00014, 0xafa20010,
-0x8fa60020, 0x1000006d, 0x34a50500, 0xf71021,
-0x8fa30020, 0x8fa40024, 0xac4304c0, 0xac4404c4,
-0x8f830054, 0x8f820054, 0x247003e8, 0x2021023,
-0x2c4203e9, 0x1040001b, 0x9821, 0xe08821,
-0x263504c0, 0x8f440178, 0x8f45017c, 0x2201821,
-0x240a0004, 0xafaa0010, 0xafb20014, 0x8f48000c,
-0x1021, 0x2f53021, 0xafa80018, 0x8f48010c,
-0x24070008, 0xa32821, 0xa3482b, 0x822021,
-0x100f809, 0x892021, 0x54400006, 0x24130001,
-0x8f820054, 0x2021023, 0x2c4203e9, 0x1440ffe9,
-0x0, 0x326200ff, 0x54400017, 0xaf520018,
-0x8f420378, 0x24420001, 0xaf420378, 0x8f420378,
-0x8f820120, 0x8faa002c, 0xafa20010, 0x8f820124,
-0x3c040001, 0x24844034, 0x3c050009, 0xafa20014,
-0x8d460000, 0x10000035, 0x34a50600, 0x8f420308,
-0x24130001, 0x24420001, 0xaf420308, 0x8f420308,
-0x1000001e, 0x326200ff, 0x8f830054, 0x8f820054,
-0x247003e8, 0x2021023, 0x2c4203e9, 0x10400016,
-0x9821, 0x3c150020, 0x24110010, 0x8f42000c,
-0x8f440160, 0x8f450164, 0x8f860120, 0xafb10010,
-0xafb20014, 0x551025, 0xafa20018, 0x8f42010c,
-0x24070008, 0x40f809, 0x24c6001c, 0x1440ffe3,
-0x0, 0x8f820054, 0x2021023, 0x2c4203e9,
-0x1440ffee, 0x0, 0x326200ff, 0x14400011,
-0x0, 0x8f420378, 0x24420001, 0xaf420378,
-0x8f420378, 0x8f820120, 0x8faa002c, 0xafa20010,
-0x8f820124, 0x3c040001, 0x2484403c, 0x3c050009,
-0xafa20014, 0x8d460000, 0x34a50700, 0xc0029e7,
-0x3c03821, 0x8f4202ec, 0x24420001, 0xaf4202ec,
-0x8f4202ec, 0x8fbf0048, 0x8fbe0044, 0x8fb50040,
-0x8fb3003c, 0x8fb20038, 0x8fb10034, 0x8fb00030,
-0x3e00008, 0x27bd0050, 0x3c020001, 0x8c424398,
-0x27bdffe0, 0x1440000d, 0xafbf0018, 0x3c040001,
-0x2484409c, 0x3c050008, 0xafa00010, 0xafa00014,
-0x8f860220, 0x34a50700, 0x24020001, 0x3c010001,
-0xac224398, 0xc0029e7, 0x3821, 0x3c020004,
-0x2c21024, 0x10400007, 0x0, 0x8f820220,
-0x3c0308ff, 0x3463ffff, 0x431024, 0x34420008,
-0xaf820220, 0x3c050001, 0x8ca54388, 0x24020001,
-0x14a20007, 0x2021, 0xc004aa4, 0x24050001,
-0xac02026c, 0x8c03026c, 0x10000006, 0x3c020007,
-0xc004aa4, 0x2021, 0xac020268, 0x8c030268,
-0x3c020007, 0x621824, 0x3c020002, 0x5062000d,
-0x3c0205f5, 0x43102b, 0x14400006, 0x3c020004,
-0x3c020001, 0x10620009, 0x3c020098, 0x1000000b,
-0x0, 0x14620009, 0x3c023b9a, 0x10000004,
-0x3442ca00, 0x10000002, 0x3442e100, 0x34429680,
-0xaf4201fc, 0x8f4201fc, 0xaee20064, 0x8fbf0018,
-0x3e00008, 0x27bd0020, 0x0, 0x86102b,
-0x50400001, 0x872023, 0xc41023, 0x24843,
-0x125102b, 0x1040001b, 0x91040, 0x824021,
-0x88102b, 0x10400007, 0x1821, 0x94820000,
-0x24840002, 0x621821, 0x88102b, 0x1440fffb,
-0x0, 0x602021, 0xc73023, 0xa91023,
-0x21040, 0xc22821, 0xc5102b, 0x10400007,
-0x1821, 0x94c20000, 0x24c60002, 0x621821,
-0xc5102b, 0x1440fffb, 0x0, 0x1000000d,
-0x832021, 0x51040, 0x822821, 0x85102b,
-0x10400007, 0x1821, 0x94820000, 0x24840002,
-0x621821, 0x85102b, 0x1440fffb, 0x0,
-0x602021, 0x41c02, 0x3082ffff, 0x622021,
-0x41c02, 0x3082ffff, 0x622021, 0x3e00008,
-0x3082ffff, 0x3e00008, 0x0, 0x802821,
-0x30a20001, 0x1040002b, 0x3c03001f, 0x3463ffff,
-0x24a20004, 0x62102b, 0x54400007, 0x65102b,
-0x90a20001, 0x90a40003, 0x90a30000, 0x90a50002,
-0x1000002a, 0x441021, 0x10400003, 0x0,
-0x8f420148, 0xa22823, 0x90a40000, 0x24a50001,
-0x65102b, 0x10400003, 0x0, 0x8f420148,
-0xa22823, 0x90a20000, 0x24a50001, 0x21200,
-0x822021, 0x65102b, 0x10400003, 0x0,
-0x8f420148, 0xa22823, 0x90a20000, 0x24a50001,
-0x822021, 0x65102b, 0x10400003, 0x0,
-0x8f420148, 0xa22823, 0x90a20000, 0x1000002d,
-0x21200, 0x3463ffff, 0x24a20004, 0x62102b,
-0x5440000a, 0x65102b, 0x90a20000, 0x90a40002,
-0x90a30001, 0x90a50003, 0x441021, 0x21200,
-0x651821, 0x10000020, 0x432021, 0x10400003,
-0x0, 0x8f420148, 0xa22823, 0x90a20000,
-0x24a50001, 0x22200, 0x65102b, 0x10400003,
-0x0, 0x8f420148, 0xa22823, 0x90a20000,
-0x24a50001, 0x822021, 0x65102b, 0x10400003,
-0x0, 0x8f420148, 0xa22823, 0x90a20000,
-0x24a50001, 0x21200, 0x822021, 0x65102b,
-0x10400003, 0x0, 0x8f420148, 0xa22823,
-0x90a20000, 0x822021, 0x41c02, 0x3082ffff,
-0x622021, 0x41c02, 0x3082ffff, 0x622021,
-0x3e00008, 0x3082ffff, 0x0, 0x8f820220,
-0x34420002, 0xaf820220, 0x3c020001, 0x8c4265a8,
-0x30424000, 0x10400054, 0x24040001, 0x8f820200,
-0x24067fff, 0x8f830200, 0x30450002, 0x2402fffd,
-0x621824, 0xaf830200, 0xaf840204, 0x8f830054,
-0x8f820054, 0x10000002, 0x24630001, 0x8f820054,
-0x621023, 0x2c420002, 0x1440fffc, 0x0,
-0x8f820224, 0x1444004d, 0x42040, 0xc4102b,
-0x1040fff1, 0x0, 0x8f820200, 0x451025,
-0xaf820200, 0x8f820220, 0x34428000, 0xaf820220,
-0x8f830054, 0x8f820054, 0x10000002, 0x24630001,
-0x8f820054, 0x621023, 0x2c420002, 0x1440fffc,
-0x0, 0x8f820220, 0x3c030004, 0x431024,
-0x1440000f, 0x0, 0x8f820220, 0x3c03ffff,
-0x34637fff, 0x431024, 0xaf820220, 0x8f830054,
-0x8f820054, 0x10000002, 0x24630001, 0x8f820054,
-0x621023, 0x2c420002, 0x1440fffc, 0x0,
-0x8f820220, 0x3c030004, 0x431024, 0x1440000d,
-0x0, 0x8f820220, 0x34428000, 0xaf820220,
-0x8f830054, 0x8f820054, 0x10000002, 0x24630001,
-0x8f820054, 0x621023, 0x2c420002, 0x1440fffc,
-0x0, 0x8f820220, 0x3c030004, 0x431024,
-0x1040001b, 0x1021, 0x8f830220, 0x24020001,
-0x10000015, 0x3c04f700, 0x8f820220, 0x3c04f700,
-0x441025, 0xaf820220, 0x8f820220, 0x2403fffd,
-0x431024, 0xaf820220, 0x8f820220, 0x3c030300,
-0x431024, 0x14400003, 0x0, 0x10000008,
-0x1021, 0x8f820220, 0x34420002, 0xaf820220,
-0x8f830220, 0x24020001, 0x641825, 0xaf830220,
-0x3e00008, 0x0, 0x2021, 0x3c050100,
-0x24020001, 0xaf80021c, 0xaf820200, 0xaf820220,
-0x27625000, 0xaf8200c0, 0x27625000, 0xaf8200c4,
-0x27625000, 0xaf8200c8, 0x27625000, 0xaf8200d0,
-0x27625000, 0xaf8200d4, 0x27625000, 0xaf8200d8,
-0x27623000, 0xaf8200e0, 0x27623000, 0xaf8200e4,
-0x27623000, 0xaf8200e8, 0x27622800, 0xaf8200f0,
-0x27622800, 0xaf8200f4, 0x27622800, 0xaf8200f8,
-0x418c0, 0x24840001, 0x3631021, 0xac453004,
-0x3631021, 0xac403000, 0x28820200, 0x1440fff9,
-0x418c0, 0x2021, 0x418c0, 0x24840001,
-0x3631021, 0xac402804, 0x3631021, 0xac402800,
-0x28820100, 0x1440fff9, 0x418c0, 0xaf80023c,
-0x24030080, 0x24040100, 0xac600000, 0x24630004,
-0x64102b, 0x5440fffd, 0xac600000, 0x8f830040,
-0x3c02f000, 0x621824, 0x3c025000, 0x1062000c,
-0x43102b, 0x14400006, 0x3c026000, 0x3c024000,
-0x10620008, 0x24020800, 0x10000008, 0x0,
-0x10620004, 0x24020800, 0x10000004, 0x0,
-0x24020700, 0x3c010001, 0xac22439c, 0x3e00008,
-0x0, 0x27bdffc8, 0xafbf0034, 0xafb20030,
-0xafb1002c, 0xafb00028, 0x3c010001, 0xc00470b,
-0xac204384, 0x24040001, 0x2821, 0x27a60020,
-0x34028000, 0xc0042ce, 0xa7a20020, 0x8f830054,
-0x8f820054, 0x10000002, 0x24630064, 0x8f820054,
-0x621023, 0x2c420065, 0x1440fffc, 0x24040001,
-0x24050001, 0xc00428c, 0x27a60020, 0x8f830054,
-0x8f820054, 0x10000002, 0x24630064, 0x8f820054,
-0x621023, 0x2c420065, 0x1440fffc, 0x24040001,
-0x24050001, 0xc00428c, 0x27a60020, 0x8f830054,
-0x8f820054, 0x10000002, 0x24630064, 0x8f820054,
-0x621023, 0x2c420065, 0x1440fffc, 0x24040001,
-0x24050002, 0xc00428c, 0x27a60018, 0x8f830054,
-0x8f820054, 0x10000002, 0x24630064, 0x8f820054,
-0x621023, 0x2c420065, 0x1440fffc, 0x24040001,
-0x24050003, 0xc00428c, 0x27a6001a, 0x97a20020,
-0x1040002a, 0x24020001, 0x3c020001, 0x8c424384,
-0x97a30018, 0x34420001, 0x3c010001, 0xac224384,
-0x24020015, 0x1462000a, 0x0, 0x97a2001a,
-0x3042fff0, 0x3843f420, 0x2c630001, 0x3842f430,
-0x2c420001, 0x621825, 0x14600018, 0x24020003,
-0x97a30018, 0x24027810, 0x14620014, 0x24020002,
-0x97a2001a, 0x3042fff0, 0x14400010, 0x24020002,
-0x1000000e, 0x24020004, 0x3c020001, 0x8c424384,
-0x34420008, 0x3c010001, 0xac224384, 0x10000058,
-0x24020004, 0x3c020001, 0x8c424384, 0x34420004,
-0x3c010001, 0x100000a9, 0xac224384, 0x3c010001,
-0xac2244f0, 0x24020e00, 0xaf820238, 0x8f840054,
-0x8f820054, 0x24030008, 0x3c010001, 0xac234388,
-0x10000002, 0x248401f4, 0x8f820054, 0x821023,
-0x2c4201f5, 0x1440fffc, 0x3c0200c8, 0x344201fb,
-0xaf820238, 0x8f830054, 0x8f820054, 0x10000002,
-0x246301f4, 0x8f820054, 0x621023, 0x2c4201f5,
-0x1440fffc, 0x8021, 0x24120001, 0x24110009,
-0xc0041ad, 0x0, 0x3c010001, 0xac3243a4,
-0xc00425a, 0x0, 0x3c020001, 0x8c4243a4,
-0x1451fffb, 0x3c0200c8, 0x344201f6, 0xaf820238,
-0x8f830054, 0x8f820054, 0x10000002, 0x2463000a,
-0x8f820054, 0x621023, 0x2c42000b, 0x1440fffc,
-0x0, 0x8f820220, 0x24040001, 0x34420002,
-0xaf820220, 0x8f830200, 0x24057fff, 0x2402fffd,
-0x621824, 0xaf830200, 0xaf840204, 0x8f830054,
-0x8f820054, 0x10000002, 0x24630001, 0x8f820054,
-0x621023, 0x2c420002, 0x1440fffc, 0x0,
-0x8f820224, 0x14440005, 0x34028000, 0x42040,
-0xa4102b, 0x1040fff0, 0x34028000, 0x1082ffa6,
-0x26100001, 0x2e020014, 0x1440ffcd, 0x24020004,
-0x3c010001, 0xac224388, 0x8021, 0x24120009,
-0x3c11ffff, 0x36313f7f, 0xc0041ad, 0x0,
-0x24020001, 0x3c010001, 0xac2243a4, 0xc00425a,
-0x0, 0x3c020001, 0x8c4243a4, 0x1452fffb,
-0x0, 0x8f820044, 0x511024, 0x34425080,
-0xaf820044, 0x8f830054, 0x8f820054, 0x10000002,
-0x2463000a, 0x8f820054, 0x621023, 0x2c42000b,
-0x1440fffc, 0x0, 0x8f820044, 0x511024,
-0x3442f080, 0xaf820044, 0x8f830054, 0x8f820054,
-0x10000002, 0x2463000a, 0x8f820054, 0x621023,
-0x2c42000b, 0x1440fffc, 0x0, 0x8f820220,
-0x3c03f700, 0x431025, 0xaf820220, 0x8f830054,
-0x8f820054, 0x10000002, 0x24630064, 0x8f820054,
-0x621023, 0x2c420065, 0x1440fffc, 0x0,
-0x8f820220, 0x24040001, 0x34420002, 0xaf820220,
-0x8f830200, 0x24057fff, 0x2402fffd, 0x621824,
-0xaf830200, 0xaf840204, 0x8f830054, 0x8f820054,
-0x10000002, 0x24630001, 0x8f820054, 0x621023,
-0x2c420002, 0x1440fffc, 0x0, 0x8f820224,
-0x14440005, 0x34028000, 0x42040, 0xa4102b,
-0x1040fff0, 0x34028000, 0x1082ff56, 0x26100001,
-0x2e020064, 0x1440ffb0, 0x0, 0x3c020001,
-0x8c424384, 0x30420004, 0x14400007, 0x3c08fff0,
-0x8f820044, 0x3c03ffff, 0x34633f7f, 0x431024,
-0xaf820044, 0x3c08fff0, 0x3508bdc0, 0x8f830054,
-0x97a60018, 0x3c070001, 0x8ce744f0, 0x3c040001,
-0x24844170, 0x24020001, 0x3c010001, 0xac22438c,
-0xafa60010, 0x3c060001, 0x8cc64384, 0x97a2001a,
-0x3c05000d, 0x34a50100, 0x3c010001, 0xac204388,
-0x681821, 0x3c010001, 0xac2344e8, 0xc0029e7,
-0xafa20014, 0x8fbf0034, 0x8fb20030, 0x8fb1002c,
-0x8fb00028, 0x3e00008, 0x27bd0038, 0x27bdffe8,
-0x3c040001, 0x8c844388, 0x24060004, 0x24020001,
-0x1482000a, 0xafbf0010, 0x3c020001, 0x8c4265ac,
-0x3c050004, 0x30428000, 0x1040000c, 0x34a593e0,
-0x3c05000f, 0x10000009, 0x34a54240, 0x3c020001,
-0x8c4265ac, 0x3c05000f, 0x30428000, 0x10400003,
-0x34a54240, 0x3c05001e, 0x34a58480, 0x3c020001,
-0x8c4244e8, 0x8f830054, 0x451021, 0x431023,
-0x45102b, 0x14400037, 0x0, 0x3c020001,
-0x8c424390, 0x14400033, 0x0, 0x3c010001,
-0x10c00025, 0xac2043a0, 0x3c090001, 0x8d294384,
-0x24070001, 0x3c054000, 0x3c080001, 0x250865ac,
-0x250afffc, 0x42042, 0x14800002, 0x24c6ffff,
-0x24040008, 0x891024, 0x10400010, 0x0,
-0x14870008, 0x0, 0x8d020000, 0x451024,
-0x1040000a, 0x0, 0x3c010001, 0x10000007,
-0xac2443a0, 0x8d420000, 0x451024, 0x10400003,
-0x0, 0x3c010001, 0xac2743a0, 0x3c020001,
-0x8c4243a0, 0x6182b, 0x2c420001, 0x431024,
-0x5440ffe5, 0x42042, 0x3c020001, 0x8c4243a0,
-0x3c010001, 0x10400024, 0xac244388, 0x8f830054,
-0x24020001, 0x3c010001, 0xac22438c, 0x3c010001,
-0xac2344e8, 0x3c020001, 0x8c4243a0, 0x1040001a,
-0x0, 0x3c020001, 0x8c42438c, 0x10400004,
-0x24020001, 0x3c010001, 0xac20438c, 0xaee204b8,
-0x8ee304b8, 0x24020008, 0x10620005, 0x24020001,
-0xc004056, 0x0, 0x1000000b, 0x0,
-0x3c030001, 0x8c634388, 0x10620007, 0x2402000e,
-0x3c030001, 0x8c636540, 0x10620003, 0x0,
-0xc004730, 0x8f840220, 0x8fbf0010, 0x3e00008,
-0x27bd0018, 0x27bdffe0, 0x3c03fdff, 0x3c040001,
-0x8c844388, 0x3c020001, 0x8c4243ac, 0x3463ffff,
-0x283a024, 0x14820006, 0xafbf0018, 0x8ee304b8,
-0x3c020001, 0x8c4243b0, 0x10620006, 0x0,
-0x8ee204b8, 0x3c010001, 0xac2443ac, 0x3c010001,
-0xac2243b0, 0x3c030001, 0x8c634388, 0x24020002,
-0x1062013c, 0x2c620003, 0x10400005, 0x24020001,
-0x1062000a, 0x0, 0x10000134, 0x0,
-0x24020004, 0x1062006d, 0x24020008, 0x1062009f,
-0x24020001, 0x1000012d, 0x0, 0x8ee204b8,
-0x2443ffff, 0x2c620008, 0x1040012a, 0x31080,
-0x3c010001, 0x220821, 0x8c224188, 0x400008,
-0x0, 0xc0041ad, 0x0, 0x3c020001,
-0x8c424394, 0x3c010001, 0xac204320, 0x104000d7,
-0x24020002, 0xaee204b8, 0x3c010001, 0x10000119,
-0xac204394, 0xc00430f, 0x0, 0x3c030001,
-0x8c6343c0, 0x1000009e, 0x24020011, 0x3c050001,
-0x8ca54388, 0x3c060001, 0x8cc665ac, 0xc004998,
-0x2021, 0x24020005, 0x3c010001, 0xac204394,
-0x10000108, 0xaee204b8, 0x3c040001, 0x2484417c,
-0x3c05000f, 0x34a50100, 0x3021, 0x3821,
-0xafa00010, 0xc0029e7, 0xafa00014, 0x100000fd,
-0x0, 0x8f820220, 0x3c03f700, 0x431025,
-0x100000a4, 0xaf820220, 0x8f820220, 0x3c030004,
-0x431024, 0x144000ae, 0x24020007, 0x8f830054,
-0x3c020001, 0x8c4244e0, 0x2463d8f0, 0x431023,
-0x2c422710, 0x144000eb, 0x24020001, 0x100000e7,
-0x0, 0x3c050001, 0x8ca54388, 0xc004aa4,
-0x2021, 0xc004b6f, 0x2021, 0x3c030001,
-0x8c6365a4, 0x46100dd, 0x24020001, 0x3c020008,
-0x621024, 0x10400006, 0x0, 0x8f820214,
-0x3c03ffff, 0x431024, 0x10000005, 0x3442251f,
-0x8f820214, 0x3c03ffff, 0x431024, 0x3442241f,
-0xaf820214, 0x8f820220, 0x3c030200, 0x283a025,
-0x34420002, 0xaf820220, 0x24020008, 0xc003d03,
-0xaee204b8, 0x100000c7, 0x0, 0x8ee204b8,
-0x2443ffff, 0x2c620008, 0x104000c2, 0x31080,
-0x3c010001, 0x220821, 0x8c2241a8, 0x400008,
-0x0, 0x3c020001, 0x8c4265a8, 0x30424000,
-0x10400004, 0x0, 0x8f820044, 0x10000006,
-0x3442f080, 0x8f820044, 0x3c03ffff, 0x34633f7f,
-0x431024, 0x3442a080, 0xaf820044, 0x8f830054,
-0x1000005a, 0x24020004, 0xc003de4, 0x0,
-0x104000a6, 0x24020001, 0x8f820214, 0x3c03ffff,
-0x3c040001, 0x8c8444d8, 0x431024, 0x3442251f,
-0xaf820214, 0x24020008, 0x10800005, 0xaee204b8,
-0x3c020001, 0x8c424424, 0x1040006d, 0x24020001,
-0x8f820220, 0x3c030008, 0x431024, 0x10400073,
-0x3c020200, 0x10000081, 0x0, 0x8ee204b8,
-0x2443ffff, 0x2c620007, 0x1040008e, 0x31080,
-0x3c010001, 0x220821, 0x8c2241c8, 0x400008,
-0x0, 0xc003c45, 0x0, 0x3c010001,
-0xac20438c, 0xaf800204, 0x3c010001, 0xc0041ad,
-0xac206590, 0x24020001, 0x3c010001, 0xac2243a4,
-0x24020002, 0x1000007b, 0xaee204b8, 0xc00425a,
-0x0, 0x3c030001, 0x8c6343a4, 0x24020009,
-0x14620074, 0x24020003, 0x10000072, 0xaee204b8,
-0x3c020001, 0x8c4265a8, 0x30424000, 0x10400003,
-0x3c0200c8, 0x10000002, 0x344201f6, 0x344201fe,
-0xaf820238, 0x8f830054, 0x10000014, 0x24020004,
-0x8f830054, 0x3c020001, 0x8c4244e0, 0x2463d8f0,
-0x431023, 0x2c422710, 0x1440005e, 0x24020005,
-0x1000005c, 0xaee204b8, 0x8f820220, 0x3c03f700,
-0x431025, 0xaf820220, 0xaf800204, 0x3c010001,
-0xac206590, 0x8f830054, 0x24020006, 0xaee204b8,
-0x3c010001, 0x1000004f, 0xac2344e0, 0x8f830054,
-0x3c020001, 0x8c4244e0, 0x2463fff6, 0x431023,
-0x2c42000a, 0x14400047, 0x0, 0x24020007,
-0x10000044, 0xaee204b8, 0xc003de4, 0x0,
-0x1040003e, 0x24020001, 0x8f820214, 0x3c03ffff,
-0x3c040001, 0x8c8444d8, 0x431024, 0x3442251f,
-0xaf820214, 0x24020008, 0x1080000f, 0xaee204b8,
-0x3c020001, 0x8c424424, 0x1440000b, 0x0,
-0x8f820220, 0x34420002, 0xaf820220, 0x24020001,
-0x3c010001, 0xac226540, 0xc004730, 0x8f840220,
-0x10000016, 0x0, 0x8f820220, 0x3c030008,
-0x431024, 0x14400011, 0x3c020200, 0x282a025,
-0x2402000e, 0x3c010001, 0xac226540, 0xc004b6f,
-0x2021, 0x8f820220, 0x34420002, 0xc003d03,
-0xaf820220, 0x3c050001, 0x8ca54388, 0xc004aa4,
-0x2021, 0x10000013, 0x0, 0x3c020001,
-0x8c424424, 0x1040000f, 0x0, 0x3c020001,
-0x8c424420, 0x2442ffff, 0x3c010001, 0xac224420,
-0x14400008, 0x24020002, 0x3c010001, 0xac204424,
-0x3c010001, 0x10000003, 0xac224420, 0x3c010001,
-0xac22438c, 0x8fbf0018, 0x3e00008, 0x27bd0020,
-0x8f820200, 0x8f820220, 0x8f820220, 0x34420004,
-0xaf820220, 0x8f820200, 0x3c060001, 0x8cc64388,
-0x34420004, 0xaf820200, 0x24020002, 0x10c2003b,
-0x2cc20003, 0x10400005, 0x24020001, 0x10c2000a,
-0x3c03f0ff, 0x10000099, 0x0, 0x24020004,
-0x10c2005a, 0x24020008, 0x10c2006d, 0x3c02f0ff,
-0x10000092, 0x0, 0x8f820050, 0x3463ffff,
-0x3c05ffff, 0x3c040001, 0x8c8444f0, 0x431024,
-0x3c030700, 0x431025, 0xaf820050, 0x24020e00,
-0xaf860200, 0xaf860220, 0xaf820238, 0x8f820044,
-0x3c030001, 0x8c634378, 0x34a53f7f, 0x451024,
-0x34630022, 0xaf820044, 0x24020004, 0xaf860238,
-0x1082000c, 0xaf830200, 0x3c020001, 0x8c42439c,
-0x3c030001, 0x8c634380, 0x3c040001, 0x8c84437c,
-0x34428000, 0x621825, 0x641825, 0x1000006e,
-0x34620002, 0x3c020001, 0x8c424380, 0x3c030001,
-0x8c63439c, 0x3c040001, 0x8c84437c, 0x431025,
-0x441025, 0x10000064, 0x34420002, 0x8f830050,
-0x3c02f0ff, 0x3442ffff, 0x3c040001, 0x8c8444d8,
-0x621824, 0x3c020d00, 0x621825, 0x24020001,
-0xaf830050, 0xaf820200, 0xaf820220, 0x24020e00,
-0x10800009, 0xaf820238, 0x3c020001, 0x8c424424,
-0x14400005, 0x3c033f00, 0x3c020001, 0x8c424370,
-0x10000005, 0x34630070, 0x3c020001, 0x8c424370,
-0x3c033f00, 0x34630072, 0x431025, 0xaf820200,
-0x3c030001, 0x8c634374, 0x3c04f700, 0x3c020001,
-0x8c424380, 0x3c050001, 0x8ca5439c, 0x641825,
-0x431025, 0x1000003c, 0x451025, 0x8f830050,
-0x3c02f0ff, 0x3442ffff, 0x3c040001, 0x8c8444d8,
-0x621824, 0x3c020a00, 0x621825, 0x24020001,
-0xaf830050, 0xaf820200, 0x1080001e, 0xaf820220,
-0x3c020001, 0x8c424424, 0x1440001a, 0x3c033f00,
-0x3c020001, 0x8c424370, 0x1000001a, 0x346300e0,
-0x8f830050, 0x3c040001, 0x8c8444d8, 0x3442ffff,
-0x621824, 0x1080000f, 0xaf830050, 0x3c020001,
-0x8c424424, 0x1440000b, 0x3c043f00, 0x3c030001,
-0x8c634370, 0x348400e0, 0x24020001, 0xaf820200,
-0xaf820220, 0x641825, 0xaf830200, 0x10000008,
-0x3c05f700, 0x3c020001, 0x8c424370, 0x3c033f00,
-0x346300e2, 0x431025, 0xaf820200, 0x3c05f700,
-0x34a58000, 0x3c030001, 0x8c634374, 0x3c020001,
-0x8c424380, 0x3c040001, 0x8c84439c, 0x651825,
-0x431025, 0x441025, 0xaf820220, 0x3e00008,
-0x0, 0x3c030001, 0x8c6343a4, 0x3c020001,
-0x8c4243a8, 0x10620003, 0x24020002, 0x3c010001,
-0xac2343a8, 0x1062001d, 0x2c620003, 0x10400025,
-0x24020001, 0x14620023, 0x24020004, 0x3c030001,
-0x8c634388, 0x10620006, 0x24020008, 0x1462000c,
-0x3c0200c8, 0x344201fb, 0x10000009, 0xaf820238,
-0x24020e01, 0xaf820238, 0x8f820044, 0x3c03ffff,
-0x34633f7f, 0x431024, 0x34420080, 0xaf820044,
-0x8f830054, 0x24020002, 0x3c010001, 0xac2243a4,
-0x3c010001, 0x1000000b, 0xac2344e4, 0x8f830054,
-0x3c020001, 0x8c4244e4, 0x2463d8f0, 0x431023,
-0x2c422710, 0x14400003, 0x24020009, 0x3c010001,
-0xac2243a4, 0x3e00008, 0x0, 0x27bdffd8,
-0xafb20018, 0x809021, 0xafb3001c, 0xa09821,
-0xafb10014, 0xc08821, 0xafb00010, 0x8021,
-0xafbf0020, 0xa6200000, 0xc0046e5, 0x24040001,
-0x26100001, 0x2e020020, 0x1440fffb, 0x0,
-0xc0046e5, 0x2021, 0xc0046e5, 0x24040001,
-0xc0046e5, 0x24040001, 0xc0046e5, 0x2021,
-0x24100010, 0x2501024, 0x10400002, 0x2021,
-0x24040001, 0xc0046e5, 0x108042, 0x1600fffa,
-0x2501024, 0x24100010, 0x2701024, 0x10400002,
-0x2021, 0x24040001, 0xc0046e5, 0x108042,
-0x1600fffa, 0x2701024, 0xc00470b, 0x34108000,
-0xc00470b, 0x0, 0xc0046c5, 0x0,
-0x50400005, 0x108042, 0x96220000, 0x501025,
-0xa6220000, 0x108042, 0x1600fff7, 0x0,
-0xc00470b, 0x0, 0x8fbf0020, 0x8fb3001c,
-0x8fb20018, 0x8fb10014, 0x8fb00010, 0x3e00008,
-0x27bd0028, 0x27bdffd8, 0xafb10014, 0x808821,
-0xafb20018, 0xa09021, 0xafb3001c, 0xc09821,
-0xafb00010, 0x8021, 0xafbf0020, 0xc0046e5,
-0x24040001, 0x26100001, 0x2e020020, 0x1440fffb,
-0x0, 0xc0046e5, 0x2021, 0xc0046e5,
-0x24040001, 0xc0046e5, 0x2021, 0xc0046e5,
-0x24040001, 0x24100010, 0x2301024, 0x10400002,
-0x2021, 0x24040001, 0xc0046e5, 0x108042,
-0x1600fffa, 0x2301024, 0x24100010, 0x2501024,
-0x10400002, 0x2021, 0x24040001, 0xc0046e5,
-0x108042, 0x1600fffa, 0x2501024, 0xc0046e5,
-0x24040001, 0xc0046e5, 0x2021, 0x34108000,
-0x96620000, 0x501024, 0x10400002, 0x2021,
-0x24040001, 0xc0046e5, 0x108042, 0x1600fff8,
-0x0, 0xc00470b, 0x0, 0x8fbf0020,
-0x8fb3001c, 0x8fb20018, 0x8fb10014, 0x8fb00010,
-0x3e00008, 0x27bd0028, 0x3c030001, 0x8c6343c0,
-0x3c020001, 0x8c424404, 0x27bdffd8, 0xafbf0020,
-0xafb1001c, 0x10620003, 0xafb00018, 0x3c010001,
-0xac234404, 0x2463ffff, 0x2c620013, 0x104003a3,
-0x31080, 0x3c010001, 0x220821, 0x8c2241f0,
-0x400008, 0x0, 0xc00470b, 0x8021,
-0x34028000, 0xa7a20010, 0x27b10010, 0xc0046e5,
-0x24040001, 0x26100001, 0x2e020020, 0x1440fffb,
-0x0, 0xc0046e5, 0x2021, 0xc0046e5,
-0x24040001, 0xc0046e5, 0x2021, 0xc0046e5,
-0x24040001, 0x24100010, 0x32020001, 0x10400002,
-0x2021, 0x24040001, 0xc0046e5, 0x108042,
-0x1600fffa, 0x32020001, 0x24100010, 0xc0046e5,
-0x2021, 0x108042, 0x1600fffc, 0x0,
-0xc0046e5, 0x24040001, 0xc0046e5, 0x2021,
-0x34108000, 0x96220000, 0x501024, 0x10400002,
-0x2021, 0x24040001, 0xc0046e5, 0x108042,
-0x1600fff8, 0x0, 0xc00470b, 0x0,
-0x10000368, 0x24020002, 0x27b10010, 0xa7a00010,
-0x8021, 0xc0046e5, 0x24040001, 0x26100001,
-0x2e020020, 0x1440fffb, 0x0, 0xc0046e5,
-0x2021, 0xc0046e5, 0x24040001, 0xc0046e5,
-0x24040001, 0xc0046e5, 0x2021, 0x24100010,
-0x32020001, 0x10400002, 0x2021, 0x24040001,
-0xc0046e5, 0x108042, 0x1600fffa, 0x32020001,
-0x24100010, 0xc0046e5, 0x2021, 0x108042,
-0x1600fffc, 0x0, 0xc00470b, 0x34108000,
-0xc00470b, 0x0, 0xc0046c5, 0x0,
-0x50400005, 0x108042, 0x96220000, 0x501025,
-0xa6220000, 0x108042, 0x1600fff7, 0x0,
-0xc00470b, 0x0, 0x97a20010, 0x30428000,
-0x14400336, 0x24020003, 0x10000332, 0x0,
-0x3c020001, 0x8c4244f0, 0x30420004, 0x10400056,
-0x24020001, 0x3c030001, 0x8c6365ac, 0xa7a20010,
-0x3c020008, 0x621024, 0x1040000c, 0x3c020002,
-0x621024, 0x10400002, 0x24020101, 0xa7a20010,
-0x3c020001, 0x621024, 0x10400005, 0x3c020010,
-0x97a20010, 0x34420040, 0xa7a20010, 0x3c020010,
-0x621024, 0x1040000e, 0x3c020002, 0x621024,
-0x10400005, 0x3c020001, 0x97a20010, 0x34420080,
-0xa7a20010, 0x3c020001, 0x621024, 0x10400005,
-0x27b10010, 0x97a20010, 0x34420020, 0xa7a20010,
-0x27b10010, 0x8021, 0xc0046e5, 0x24040001,
-0x26100001, 0x2e020020, 0x1440fffb, 0x0,
-0xc0046e5, 0x2021, 0xc0046e5, 0x24040001,
-0xc0046e5, 0x2021, 0xc0046e5, 0x24040001,
-0x24100010, 0x32020001, 0x10400002, 0x2021,
-0x24040001, 0xc0046e5, 0x108042, 0x1600fffa,
-0x32020001, 0x24100010, 0x32020004, 0x10400002,
-0x2021, 0x24040001, 0xc0046e5, 0x108042,
-0x1600fffa, 0x32020004, 0xc0046e5, 0x24040001,
-0xc0046e5, 0x2021, 0x34108000, 0x96220000,
-0x501024, 0x10400002, 0x2021, 0x24040001,
-0xc0046e5, 0x108042, 0x1600fff8, 0x0,
-0xc00470b, 0x0, 0x24021200, 0xa7a20010,
-0x27b10010, 0x8021, 0xc0046e5, 0x24040001,
-0x26100001, 0x2e020020, 0x1440fffb, 0x0,
-0xc0046e5, 0x2021, 0xc0046e5, 0x24040001,
-0xc0046e5, 0x2021, 0xc0046e5, 0x24040001,
-0x24100010, 0x32020001, 0x10400002, 0x2021,
-0x24040001, 0xc0046e5, 0x108042, 0x1600fffa,
-0x32020001, 0x24100010, 0xc0046e5, 0x2021,
-0x108042, 0x1600fffc, 0x0, 0xc0046e5,
-0x24040001, 0xc0046e5, 0x2021, 0x34108000,
-0x96220000, 0x501024, 0x10400002, 0x2021,
-0x24040001, 0xc0046e5, 0x108042, 0x1600fff8,
-0x0, 0xc00470b, 0x0, 0x8f830054,
-0x10000296, 0x24020004, 0x8f830054, 0x3c020001,
-0x8c4244ec, 0x2463ff9c, 0x431023, 0x2c420064,
-0x1440029e, 0x24020002, 0x3c030001, 0x8c6344f0,
-0x10620297, 0x2c620003, 0x14400296, 0x24020011,
-0x24020003, 0x10620005, 0x24020004, 0x10620291,
-0x2402000f, 0x1000028f, 0x24020011, 0x1000028d,
-0x24020005, 0x24020014, 0xa7a20010, 0x27b10010,
-0x8021, 0xc0046e5, 0x24040001, 0x26100001,
-0x2e020020, 0x1440fffb, 0x0, 0xc0046e5,
-0x2021, 0xc0046e5, 0x24040001, 0xc0046e5,
-0x2021, 0xc0046e5, 0x24040001, 0x24100010,
-0x32020001, 0x10400002, 0x2021, 0x24040001,
-0xc0046e5, 0x108042, 0x1600fffa, 0x32020001,
-0x24100010, 0x32020012, 0x10400002, 0x2021,
-0x24040001, 0xc0046e5, 0x108042, 0x1600fffa,
-0x32020012, 0xc0046e5, 0x24040001, 0xc0046e5,
-0x2021, 0x34108000, 0x96220000, 0x501024,
-0x10400002, 0x2021, 0x24040001, 0xc0046e5,
-0x108042, 0x1600fff8, 0x0, 0xc00470b,
-0x0, 0x8f830054, 0x10000248, 0x24020006,
-0x8f830054, 0x3c020001, 0x8c4244ec, 0x2463ff9c,
-0x431023, 0x2c420064, 0x14400250, 0x24020007,
-0x1000024c, 0x0, 0x24020006, 0xa7a20010,
-0x27b10010, 0x8021, 0xc0046e5, 0x24040001,
-0x26100001, 0x2e020020, 0x1440fffb, 0x0,
-0xc0046e5, 0x2021, 0xc0046e5, 0x24040001,
-0xc0046e5, 0x2021, 0xc0046e5, 0x24040001,
-0x24100010, 0x32020001, 0x10400002, 0x2021,
-0x24040001, 0xc0046e5, 0x108042, 0x1600fffa,
-0x32020001, 0x24100010, 0x32020013, 0x10400002,
-0x2021, 0x24040001, 0xc0046e5, 0x108042,
-0x1600fffa, 0x32020013, 0xc0046e5, 0x24040001,
-0xc0046e5, 0x2021, 0x34108000, 0x96220000,
-0x501024, 0x10400002, 0x2021, 0x24040001,
-0xc0046e5, 0x108042, 0x1600fff8, 0x0,
-0xc00470b, 0x0, 0x8f830054, 0x10000207,
-0x24020008, 0x8f830054, 0x3c020001, 0x8c4244ec,
-0x2463ff9c, 0x431023, 0x2c420064, 0x1440020f,
-0x24020009, 0x1000020b, 0x0, 0x27b10010,
-0xa7a00010, 0x8021, 0xc0046e5, 0x24040001,
-0x26100001, 0x2e020020, 0x1440fffb, 0x0,
-0xc0046e5, 0x2021, 0xc0046e5, 0x24040001,
-0xc0046e5, 0x24040001, 0xc0046e5, 0x2021,
-0x24100010, 0x32020001, 0x10400002, 0x2021,
-0x24040001, 0xc0046e5, 0x108042, 0x1600fffa,
-0x32020001, 0x24100010, 0x32020018, 0x10400002,
-0x2021, 0x24040001, 0xc0046e5, 0x108042,
-0x1600fffa, 0x32020018, 0xc00470b, 0x34108000,
-0xc00470b, 0x0, 0xc0046c5, 0x0,
-0x50400005, 0x108042, 0x96220000, 0x501025,
-0xa6220000, 0x108042, 0x1600fff7, 0x0,
-0xc00470b, 0x8021, 0x97a20010, 0x27b10010,
-0x34420001, 0xa7a20010, 0xc0046e5, 0x24040001,
-0x26100001, 0x2e020020, 0x1440fffb, 0x0,
-0xc0046e5, 0x2021, 0xc0046e5, 0x24040001,
-0xc0046e5, 0x2021, 0xc0046e5, 0x24040001,
-0x24100010, 0x32020001, 0x10400002, 0x2021,
-0x24040001, 0xc0046e5, 0x108042, 0x1600fffa,
-0x32020001, 0x24100010, 0x32020018, 0x10400002,
-0x2021, 0x24040001, 0xc0046e5, 0x108042,
-0x1600fffa, 0x32020018, 0xc0046e5, 0x24040001,
-0xc0046e5, 0x2021, 0x34108000, 0x96220000,
-0x501024, 0x10400002, 0x2021, 0x24040001,
-0xc0046e5, 0x108042, 0x1600fff8, 0x0,
-0xc00470b, 0x0, 0x8f830054, 0x10000193,
-0x2402000a, 0x8f830054, 0x3c020001, 0x8c4244ec,
-0x2463ff9c, 0x431023, 0x2c420064, 0x1440019b,
-0x2402000b, 0x10000197, 0x0, 0x27b10010,
-0xa7a00010, 0x8021, 0xc0046e5, 0x24040001,
-0x26100001, 0x2e020020, 0x1440fffb, 0x0,
-0xc0046e5, 0x2021, 0xc0046e5, 0x24040001,
-0xc0046e5, 0x24040001, 0xc0046e5, 0x2021,
-0x24100010, 0x32020001, 0x10400002, 0x2021,
-0x24040001, 0xc0046e5, 0x108042, 0x1600fffa,
-0x32020001, 0x24100010, 0x32020017, 0x10400002,
-0x2021, 0x24040001, 0xc0046e5, 0x108042,
-0x1600fffa, 0x32020017, 0xc00470b, 0x34108000,
-0xc00470b, 0x0, 0xc0046c5, 0x0,
-0x50400005, 0x108042, 0x96220000, 0x501025,
-0xa6220000, 0x108042, 0x1600fff7, 0x0,
-0xc00470b, 0x8021, 0x97a20010, 0x27b10010,
-0x34420700, 0xa7a20010, 0xc0046e5, 0x24040001,
-0x26100001, 0x2e020020, 0x1440fffb, 0x0,
-0xc0046e5, 0x2021, 0xc0046e5, 0x24040001,
-0xc0046e5, 0x2021, 0xc0046e5, 0x24040001,
-0x24100010, 0x32020001, 0x10400002, 0x2021,
-0x24040001, 0xc0046e5, 0x108042, 0x1600fffa,
-0x32020001, 0x24100010, 0x32020017, 0x10400002,
-0x2021, 0x24040001, 0xc0046e5, 0x108042,
-0x1600fffa, 0x32020017, 0xc0046e5, 0x24040001,
-0xc0046e5, 0x2021, 0x34108000, 0x96220000,
-0x501024, 0x10400002, 0x2021, 0x24040001,
-0xc0046e5, 0x108042, 0x1600fff8, 0x0,
-0xc00470b, 0x0, 0x8f830054, 0x1000011f,
-0x2402000c, 0x8f830054, 0x3c020001, 0x8c4244ec,
-0x2463ff9c, 0x431023, 0x2c420064, 0x14400127,
-0x24020012, 0x10000123, 0x0, 0x27b10010,
-0xa7a00010, 0x8021, 0xc0046e5, 0x24040001,
-0x26100001, 0x2e020020, 0x1440fffb, 0x0,
-0xc0046e5, 0x2021, 0xc0046e5, 0x24040001,
-0xc0046e5, 0x24040001, 0xc0046e5, 0x2021,
-0x24100010, 0x32020001, 0x10400002, 0x2021,
-0x24040001, 0xc0046e5, 0x108042, 0x1600fffa,
-0x32020001, 0x24100010, 0x32020014, 0x10400002,
-0x2021, 0x24040001, 0xc0046e5, 0x108042,
-0x1600fffa, 0x32020014, 0xc00470b, 0x34108000,
-0xc00470b, 0x0, 0xc0046c5, 0x0,
-0x50400005, 0x108042, 0x96220000, 0x501025,
-0xa6220000, 0x108042, 0x1600fff7, 0x0,
-0xc00470b, 0x8021, 0x97a20010, 0x27b10010,
-0x34420010, 0xa7a20010, 0xc0046e5, 0x24040001,
-0x26100001, 0x2e020020, 0x1440fffb, 0x0,
-0xc0046e5, 0x2021, 0xc0046e5, 0x24040001,
-0xc0046e5, 0x2021, 0xc0046e5, 0x24040001,
-0x24100010, 0x32020001, 0x10400002, 0x2021,
-0x24040001, 0xc0046e5, 0x108042, 0x1600fffa,
-0x32020001, 0x24100010, 0x32020014, 0x10400002,
-0x2021, 0x24040001, 0xc0046e5, 0x108042,
-0x1600fffa, 0x32020014, 0xc0046e5, 0x24040001,
-0xc0046e5, 0x2021, 0x34108000, 0x96220000,
-0x501024, 0x10400002, 0x2021, 0x24040001,
-0xc0046e5, 0x108042, 0x1600fff8, 0x0,
-0xc00470b, 0x0, 0x8f830054, 0x100000ab,
-0x24020013, 0x8f830054, 0x3c020001, 0x8c4244ec,
-0x2463ff9c, 0x431023, 0x2c420064, 0x144000b3,
-0x2402000d, 0x100000af, 0x0, 0x27b10010,
-0xa7a00010, 0x8021, 0xc0046e5, 0x24040001,
-0x26100001, 0x2e020020, 0x1440fffb, 0x0,
-0xc0046e5, 0x2021, 0xc0046e5, 0x24040001,
-0xc0046e5, 0x24040001, 0xc0046e5, 0x2021,
-0x24100010, 0x32020001, 0x10400002, 0x2021,
-0x24040001, 0xc0046e5, 0x108042, 0x1600fffa,
-0x32020001, 0x24100010, 0x32020018, 0x10400002,
-0x2021, 0x24040001, 0xc0046e5, 0x108042,
-0x1600fffa, 0x32020018, 0xc00470b, 0x34108000,
-0xc00470b, 0x0, 0xc0046c5, 0x0,
-0x50400005, 0x108042, 0x96220000, 0x501025,
-0xa6220000, 0x108042, 0x1600fff7, 0x0,
-0xc00470b, 0x8021, 0x97a20010, 0x27b10010,
-0x3042fffe, 0xa7a20010, 0xc0046e5, 0x24040001,
-0x26100001, 0x2e020020, 0x1440fffb, 0x0,
-0xc0046e5, 0x2021, 0xc0046e5, 0x24040001,
-0xc0046e5, 0x2021, 0xc0046e5, 0x24040001,
-0x24100010, 0x32020001, 0x10400002, 0x2021,
-0x24040001, 0xc0046e5, 0x108042, 0x1600fffa,
-0x32020001, 0x24100010, 0x32020018, 0x10400002,
-0x2021, 0x24040001, 0xc0046e5, 0x108042,
-0x1600fffa, 0x32020018, 0xc0046e5, 0x24040001,
-0xc0046e5, 0x2021, 0x34108000, 0x96220000,
-0x501024, 0x10400002, 0x2021, 0x24040001,
-0xc0046e5, 0x108042, 0x1600fff8, 0x0,
-0xc00470b, 0x0, 0x8f830054, 0x10000037,
-0x2402000e, 0x24020840, 0xa7a20010, 0x27b10010,
-0x8021, 0xc0046e5, 0x24040001, 0x26100001,
-0x2e020020, 0x1440fffb, 0x0, 0xc0046e5,
-0x2021, 0xc0046e5, 0x24040001, 0xc0046e5,
-0x2021, 0xc0046e5, 0x24040001, 0x24100010,
-0x32020001, 0x10400002, 0x2021, 0x24040001,
-0xc0046e5, 0x108042, 0x1600fffa, 0x32020001,
-0x24100010, 0x32020013, 0x10400002, 0x2021,
-0x24040001, 0xc0046e5, 0x108042, 0x1600fffa,
-0x32020013, 0xc0046e5, 0x24040001, 0xc0046e5,
-0x2021, 0x34108000, 0x96220000, 0x501024,
-0x10400002, 0x2021, 0x24040001, 0xc0046e5,
-0x108042, 0x1600fff8, 0x0, 0xc00470b,
-0x0, 0x8f830054, 0x24020010, 0x3c010001,
-0xac2243c0, 0x3c010001, 0x1000000c, 0xac2344ec,
-0x8f830054, 0x3c020001, 0x8c4244ec, 0x2463ff9c,
-0x431023, 0x2c420064, 0x14400004, 0x0,
-0x24020011, 0x3c010001, 0xac2243c0, 0x8fbf0020,
-0x8fb1001c, 0x8fb00018, 0x3e00008, 0x27bd0028,
-0x8f850044, 0x8f820044, 0x3c030001, 0x431025,
-0x3c030008, 0xaf820044, 0x8f840054, 0x8f820054,
-0xa32824, 0x10000002, 0x24840001, 0x8f820054,
-0x821023, 0x2c420002, 0x1440fffc, 0x0,
-0x8f820044, 0x3c03fffe, 0x3463ffff, 0x431024,
-0xaf820044, 0x8f830054, 0x8f820054, 0x10000002,
-0x24630001, 0x8f820054, 0x621023, 0x2c420002,
-0x1440fffc, 0x0, 0x3e00008, 0xa01021,
-0x8f830044, 0x3c02fff0, 0x3442ffff, 0x42480,
-0x621824, 0x3c020002, 0x822025, 0x641825,
-0xaf830044, 0x8f820044, 0x3c030001, 0x431025,
-0xaf820044, 0x8f830054, 0x8f820054, 0x10000002,
-0x24630001, 0x8f820054, 0x621023, 0x2c420002,
-0x1440fffc, 0x0, 0x8f820044, 0x3c03fffe,
-0x3463ffff, 0x431024, 0xaf820044, 0x8f830054,
-0x8f820054, 0x10000002, 0x24630001, 0x8f820054,
-0x621023, 0x2c420002, 0x1440fffc, 0x0,
-0x3e00008, 0x0, 0x8f820044, 0x3c03fff0,
-0x3463ffff, 0x431024, 0xaf820044, 0x8f820044,
-0x3c030001, 0x431025, 0xaf820044, 0x8f830054,
-0x8f820054, 0x10000002, 0x24630001, 0x8f820054,
-0x621023, 0x2c420002, 0x1440fffc, 0x0,
-0x8f820044, 0x3c03fffe, 0x3463ffff, 0x431024,
-0xaf820044, 0x8f830054, 0x8f820054, 0x10000002,
-0x24630001, 0x8f820054, 0x621023, 0x2c420002,
-0x1440fffc, 0x0, 0x3e00008, 0x0,
-0x0, 0x0, 0x0, 0x27bdffe8,
-0xafbf0010, 0x8ee304b8, 0x24020008, 0x146201e0,
-0x0, 0x3c020001, 0x8c4244d8, 0x14400005,
-0x0, 0xc003c45, 0x8f840224, 0x100001d8,
-0x0, 0x8f820220, 0x3c030008, 0x431024,
-0x10400026, 0x24020001, 0x8f840224, 0x8f820220,
-0x3c030400, 0x431024, 0x10400006, 0x0,
-0x3c010001, 0xac206550, 0x3c010001, 0x1000000b,
-0xac206570, 0x3c030001, 0x24636550, 0x8c620000,
-0x24420001, 0xac620000, 0x2c420002, 0x14400003,
-0x24020001, 0x3c010001, 0xac226570, 0x3c020001,
-0x8c426570, 0x10400006, 0x30820040, 0x10400004,
-0x24020001, 0x3c010001, 0x10000003, 0xac226574,
-0x3c010001, 0xac206574, 0x3c010001, 0xac24654c,
-0x3c010001, 0x1000000b, 0xac206580, 0x3c010001,
-0xac226580, 0x3c010001, 0xac206570, 0x3c010001,
-0xac206550, 0x3c010001, 0xac206574, 0x3c010001,
-0xac20654c, 0x3c030001, 0x8c636540, 0x3c020001,
-0x8c426544, 0x50620004, 0x2463ffff, 0x3c010001,
-0xac236544, 0x2463ffff, 0x2c62000e, 0x10400194,
-0x31080, 0x3c010001, 0x220821, 0x8c224240,
-0x400008, 0x0, 0x24020002, 0x3c010001,
-0xac206570, 0x3c010001, 0xac206550, 0x3c010001,
-0xac20654c, 0x3c010001, 0xac206574, 0x3c010001,
-0xac206568, 0x3c010001, 0xac206560, 0xaf800224,
-0x3c010001, 0xac226540, 0x3c020001, 0x8c426580,
-0x1440004f, 0x3c02fdff, 0x3442ffff, 0xc003c45,
-0x282a024, 0xaf800204, 0x8f820200, 0x2403fffd,
-0x431024, 0xaf820200, 0x3c010001, 0xac206590,
-0x8f830054, 0x3c020001, 0x8c426568, 0x24040001,
-0x3c010001, 0xac24657c, 0x24420001, 0x3c010001,
-0xac226568, 0x2c420004, 0x3c010001, 0xac236564,
-0x14400006, 0x24020003, 0x3c010001, 0xac24438c,
-0x3c010001, 0x1000015e, 0xac206568, 0x3c010001,
-0x1000015b, 0xac226540, 0x8f830054, 0x3c020001,
-0x8c426564, 0x2463d8f0, 0x431023, 0x2c422710,
-0x14400003, 0x24020004, 0x3c010001, 0xac226540,
-0x3c020001, 0x8c426580, 0x14400021, 0x3c02fdff,
-0x3442ffff, 0x1000014a, 0x282a024, 0x3c040001,
-0x8c8444dc, 0x3c010001, 0xc004918, 0xac206558,
-0x3c020001, 0x8c42658c, 0xaf820204, 0x3c020001,
-0x8c426580, 0x14400012, 0x3c03fdff, 0x8f820204,
-0x3463ffff, 0x30420030, 0x1440012f, 0x283a024,
-0x3c030001, 0x8c63658c, 0x24020005, 0x3c010001,
-0xac226540, 0x3c010001, 0x10000131, 0xac236590,
-0x3c020001, 0x8c426580, 0x10400010, 0x3c02fdff,
-0x3c020001, 0x8c42441c, 0x24420001, 0x3c010001,
-0xac22441c, 0x2c420002, 0x14400125, 0x24020001,
-0x3c010001, 0xac224424, 0x3c010001, 0xac20441c,
-0x3c010001, 0x1000011e, 0xac22438c, 0x3c030001,
-0x8c636570, 0x3442ffff, 0x10600119, 0x282a024,
-0x3c020001, 0x8c42654c, 0x10400115, 0x0,
-0x3c010001, 0xac226578, 0x24020003, 0x3c010001,
-0xac226550, 0x100000b8, 0x24020006, 0x3c010001,
-0xac206558, 0x8f820204, 0x34420040, 0xaf820204,
-0x3c020001, 0x8c426590, 0x24030007, 0x3c010001,
-0xac236540, 0x34420040, 0x3c010001, 0xac226590,
-0x3c020001, 0x8c426570, 0x10400005, 0x0,
-0x3c020001, 0x8c42654c, 0x104000f0, 0x24020002,
-0x3c050001, 0x24a56550, 0x8ca20000, 0x2c424e21,
-0x104000ea, 0x24020002, 0x3c020001, 0x8c426574,
-0x104000ef, 0x2404ffbf, 0x3c020001, 0x8c42654c,
-0x3c030001, 0x8c636578, 0x441024, 0x641824,
-0x10430004, 0x24020001, 0x3c010001, 0x100000e4,
-0xac226540, 0x24020003, 0xaca20000, 0x24020008,
-0x3c010001, 0xac226540, 0x3c020001, 0x8c42657c,
-0x1040000c, 0x24020001, 0x3c040001, 0xc004925,
-0x8c84654c, 0x3c020001, 0x8c426598, 0x14400005,
-0x24020001, 0x3c020001, 0x8c426594, 0x10400006,
-0x24020001, 0x3c010001, 0xac22438c, 0x3c010001,
-0x100000cb, 0xac206568, 0x3c020001, 0x8c426560,
-0x3c030001, 0x8c63654c, 0x2c420001, 0x210c0,
-0x30630008, 0x3c010001, 0xac226560, 0x3c010001,
-0xac23655c, 0x8f830054, 0x24020009, 0x3c010001,
-0xac226540, 0x3c010001, 0x100000b9, 0xac236564,
-0x8f830054, 0x3c020001, 0x8c426564, 0x2463d8f0,
-0x431023, 0x2c422710, 0x1440009f, 0x0,
-0x3c020001, 0x8c426570, 0x10400005, 0x0,
-0x3c020001, 0x8c42654c, 0x104000a0, 0x24020002,
-0x3c030001, 0x24636550, 0x8c620000, 0x2c424e21,
-0x1040009a, 0x24020002, 0x3c020001, 0x8c42657c,
-0x1040000e, 0x0, 0x3c020001, 0x8c42654c,
-0x3c010001, 0xac20657c, 0x30420080, 0x1040002f,
-0x2402000c, 0x8f820204, 0x30420080, 0x1440000c,
-0x24020003, 0x10000029, 0x2402000c, 0x3c020001,
-0x8c42654c, 0x30420080, 0x14400005, 0x24020003,
-0x8f820204, 0x30420080, 0x1040001f, 0x24020003,
-0xac620000, 0x2402000a, 0x3c010001, 0xac226540,
-0x3c040001, 0x24846588, 0x8c820000, 0x3c030001,
-0x8c636560, 0x431025, 0xaf820204, 0x8c830000,
-0x3c040001, 0x8c846560, 0x2402000b, 0x3c010001,
-0xac226540, 0x641825, 0x3c010001, 0xac236590,
-0x3c050001, 0x24a56550, 0x8ca20000, 0x2c424e21,
-0x10400066, 0x24020002, 0x3c020001, 0x8c426580,
-0x10400005, 0x0, 0x2402000c, 0x3c010001,
-0x10000067, 0xac226540, 0x3c020001, 0x8c426570,
-0x10400063, 0x0, 0x3c040001, 0x8c84654c,
-0x10800055, 0x30820008, 0x3c030001, 0x8c63655c,
-0x1062005b, 0x24020003, 0x3c010001, 0xac246578,
-0xaca20000, 0x24020006, 0x3c010001, 0x10000054,
-0xac226540, 0x8f820200, 0x34420002, 0xaf820200,
-0x8f830054, 0x2402000d, 0x3c010001, 0xac226540,
-0x3c010001, 0xac236564, 0x8f830054, 0x3c020001,
-0x8c426564, 0x2463d8f0, 0x431023, 0x2c422710,
-0x14400031, 0x0, 0x3c020001, 0x8c426580,
-0x10400020, 0x2402000e, 0x3c030001, 0x8c636594,
-0x3c010001, 0x14600015, 0xac226540, 0xc003d03,
-0x0, 0x3c050001, 0x8ca54388, 0xc004aa4,
-0x2021, 0x3c030001, 0x8c634388, 0x24020004,
-0x14620005, 0x2403fffb, 0x3c020001, 0x8c424384,
-0x10000003, 0x2403fff7, 0x3c020001, 0x8c424384,
-0x431024, 0x3c010001, 0xac224384, 0x8f830224,
-0x3c020200, 0x3c010001, 0xac23659c, 0x10000020,
-0x282a025, 0x3c020001, 0x8c426570, 0x10400005,
-0x0, 0x3c020001, 0x8c42654c, 0x1040000f,
-0x24020002, 0x3c020001, 0x8c426550, 0x2c424e21,
-0x1040000a, 0x24020002, 0x3c020001, 0x8c426570,
-0x1040000f, 0x0, 0x3c020001, 0x8c42654c,
-0x1440000b, 0x0, 0x24020002, 0x3c010001,
-0x10000007, 0xac226540, 0x3c020001, 0x8c426570,
-0x10400003, 0x0, 0xc003c45, 0x0,
-0x8f820220, 0x3c03f700, 0x431025, 0xaf820220,
-0x8fbf0010, 0x3e00008, 0x27bd0018, 0x3c030001,
-0x24636598, 0x8c620000, 0x10400005, 0x34422000,
-0x3c010001, 0xac22658c, 0x10000003, 0xac600000,
-0x3c010001, 0xac24658c, 0x3e00008, 0x0,
-0x27bdffe0, 0x30820030, 0xafbf0018, 0x3c010001,
-0xac226594, 0x14400067, 0x3c02ffff, 0x34421f0e,
-0x821024, 0x14400061, 0x24020030, 0x30822000,
-0x1040005d, 0x30838000, 0x31a02, 0x30820001,
-0x21200, 0x3c040001, 0x8c8444dc, 0x621825,
-0x331c2, 0x3c030001, 0x24634428, 0x30828000,
-0x21202, 0x30840001, 0x42200, 0x441025,
-0x239c2, 0x61080, 0x431021, 0x471021,
-0x90430000, 0x24020001, 0x10620025, 0x0,
-0x10600007, 0x24020002, 0x10620013, 0x24020003,
-0x1062002c, 0x3c05000f, 0x10000037, 0x0,
-0x8f820200, 0x2403feff, 0x431024, 0xaf820200,
-0x8f820220, 0x3c03fffe, 0x3463ffff, 0x431024,
-0xaf820220, 0x3c010001, 0xac2065b4, 0x3c010001,
-0x10000034, 0xac2065bc, 0x8f820200, 0x34420100,
-0xaf820200, 0x8f820220, 0x3c03fffe, 0x3463ffff,
-0x431024, 0xaf820220, 0x24020100, 0x3c010001,
-0xac2265b4, 0x3c010001, 0x10000026, 0xac2065bc,
-0x8f820200, 0x2403feff, 0x431024, 0xaf820200,
-0x8f820220, 0x3c030001, 0x431025, 0xaf820220,
-0x3c010001, 0xac2065b4, 0x3c010001, 0x10000019,
-0xac2365bc, 0x8f820200, 0x34420100, 0xaf820200,
-0x8f820220, 0x3c030001, 0x431025, 0xaf820220,
-0x24020100, 0x3c010001, 0xac2265b4, 0x3c010001,
-0x1000000c, 0xac2365bc, 0x34a5ffff, 0x3c040001,
-0x24844278, 0xafa30010, 0xc0029e7, 0xafa00014,
-0x10000004, 0x0, 0x24020030, 0x3c010001,
-0xac226598, 0x8fbf0018, 0x3e00008, 0x27bd0020,
-0x0, 0x0, 0x0, 0x27bdffc8,
-0xafb10024, 0x808821, 0xafb3002c, 0xa09821,
-0xafb00020, 0xc08021, 0x3c040001, 0x24844290,
-0x3c050009, 0x3c020001, 0x8c424388, 0x34a59001,
-0x2203021, 0x2603821, 0xafbf0030, 0xafb20028,
-0xa7a0001a, 0xafb00014, 0xc0029e7, 0xafa20010,
-0x24020002, 0x126200ee, 0x2e620003, 0x10400005,
-0x24020001, 0x1262000a, 0x3c02fffb, 0x100000e8,
-0x0, 0x24020004, 0x1262006d, 0x24020008,
-0x1262006c, 0x3c02ffec, 0x100000e1, 0x0,
-0x3442ffff, 0x2028024, 0x119140, 0x3c010001,
-0x320821, 0xac3065ac, 0x3c024000, 0x2021024,
-0x10400046, 0x1023c2, 0x30840030, 0x101382,
-0x3042000c, 0x3c030001, 0x246343c4, 0x431021,
-0x823821, 0x3c020020, 0x2021024, 0x10400006,
-0x24020100, 0x3c010001, 0x320821, 0xac2265b0,
-0x10000005, 0x3c020080, 0x3c010001, 0x320821,
-0xac2065b0, 0x3c020080, 0x2021024, 0x10400006,
-0x111940, 0x3c020001, 0x3c010001, 0x230821,
-0x10000005, 0xac2265b8, 0x111140, 0x3c010001,
-0x220821, 0xac2065b8, 0x94e30000, 0x32024000,
-0x10400003, 0xa7a30018, 0x34624000, 0xa7a20018,
-0x24040001, 0x94e20002, 0x24050004, 0x24e60002,
-0x34420001, 0xc0042ce, 0xa4e20002, 0x24040001,
-0x2821, 0xc0042ce, 0x27a60018, 0x3c020001,
-0x8c424388, 0x24110001, 0x3c010001, 0xac314394,
-0x14530004, 0x32028000, 0xc003c45, 0x0,
-0x32028000, 0x1040009a, 0x0, 0xc003c45,
-0x0, 0x24020002, 0x3c010001, 0xac31438c,
-0x3c010001, 0x10000092, 0xac224388, 0x24040001,
-0x24050004, 0x27b0001a, 0xc0042ce, 0x2003021,
-0x24040001, 0x2821, 0xc0042ce, 0x2003021,
-0x3c020001, 0x521021, 0x8c4265a4, 0x3c040001,
-0x8c844388, 0x3c03bfff, 0x3463ffff, 0x3c010001,
-0xac334394, 0x431024, 0x3c010001, 0x320821,
-0x10930079, 0xac2265a4, 0x10000079, 0x0,
-0x3c02ffec, 0x3442ffff, 0x2028024, 0x3c020008,
-0x2028025, 0x111140, 0x3c010001, 0x220821,
-0xac3065a8, 0x3c022000, 0x2021024, 0x10400009,
-0x0, 0x3c020001, 0x8c424424, 0x14400005,
-0x24020001, 0x3c010001, 0xac2244d8, 0x10000004,
-0x3c024000, 0x3c010001, 0xac2044d8, 0x3c024000,
-0x2021024, 0x1440001d, 0x24020e01, 0x3c030001,
-0x8c6344d8, 0xaf820238, 0x3c010001, 0xac2043a0,
-0x10600005, 0x24022020, 0x3c010001, 0xac2244dc,
-0x24020001, 0xaee204b8, 0x3c04bfff, 0x111940,
-0x3c020001, 0x431021, 0x8c4265a0, 0x3c050001,
-0x8ca54388, 0x3484ffff, 0x441024, 0x3c010001,
-0x230821, 0xac2265a0, 0x24020001, 0x10a20044,
-0x0, 0x10000040, 0x0, 0x3c020001,
-0x8c4244d8, 0x1040001c, 0x24022000, 0x3c010001,
-0xac2244dc, 0x3c0300a0, 0x2031024, 0x14430005,
-0x111140, 0x3402a000, 0x3c010001, 0x1000002d,
-0xac2244dc, 0x3c030001, 0x621821, 0x8c6365a8,
-0x3c020020, 0x621024, 0x10400004, 0x24022001,
-0x3c010001, 0x10000023, 0xac2244dc, 0x3c020080,
-0x621024, 0x1040001f, 0x3402a001, 0x3c010001,
-0x1000001c, 0xac2244dc, 0x3c020020, 0x2021024,
-0x10400007, 0x111940, 0x24020100, 0x3c010001,
-0x230821, 0xac2265b4, 0x10000006, 0x3c020080,
-0x111140, 0x3c010001, 0x220821, 0xac2065b4,
-0x3c020080, 0x2021024, 0x10400006, 0x111940,
-0x3c020001, 0x3c010001, 0x230821, 0x10000005,
-0xac2265bc, 0x111140, 0x3c010001, 0x220821,
-0xac2065bc, 0x3c030001, 0x8c634388, 0x24020001,
-0x10620003, 0x0, 0xc003c45, 0x0,
-0x8fbf0030, 0x8fb3002c, 0x8fb20028, 0x8fb10024,
-0x8fb00020, 0x3e00008, 0x27bd0038, 0x27bdffd0,
-0xafb50028, 0x80a821, 0xafb20020, 0x9021,
-0xafb30024, 0x9821, 0xafb1001c, 0x8821,
-0x24020002, 0xafbf002c, 0xafb00018, 0xa7a00012,
-0x10a20068, 0xa7a00010, 0x2ca20003, 0x10400005,
-0x24020001, 0x10a2000a, 0x158140, 0x100000ae,
-0x2201021, 0x24020004, 0x10a2005e, 0x24020008,
-0x10a2005d, 0x152940, 0x100000a7, 0x2201021,
-0x3c030001, 0x701821, 0x8c6365ac, 0x3c024000,
-0x621024, 0x14400009, 0x24040001, 0x3c027fff,
-0x3442ffff, 0x628824, 0x3c010001, 0x300821,
-0xac3165a4, 0x10000098, 0x2201021, 0x24050001,
-0xc00428c, 0x27a60010, 0x24040001, 0x24050001,
-0xc00428c, 0x27a60010, 0x97a20010, 0x30420004,
-0x10400034, 0x3c114000, 0x3c030001, 0x8c6344f0,
-0x24020003, 0x10620008, 0x2c620004, 0x14400029,
-0x3c028000, 0x24020004, 0x10620014, 0x24040001,
-0x10000024, 0x3c028000, 0x24040001, 0x24050011,
-0x27b00012, 0xc00428c, 0x2003021, 0x24040001,
-0x24050011, 0xc00428c, 0x2003021, 0x97a30012,
-0x30624000, 0x10400002, 0x3c130010, 0x3c130008,
-0x3c120001, 0x10000010, 0x30628000, 0x24050014,
-0x27b00012, 0xc00428c, 0x2003021, 0x24040001,
-0x24050014, 0xc00428c, 0x2003021, 0x97a30012,
-0x30621000, 0x10400002, 0x3c130010, 0x3c130008,
-0x3c120001, 0x30620800, 0x54400001, 0x3c120002,
-0x3c028000, 0x2221025, 0x2531825, 0x10000007,
-0x438825, 0x3c110001, 0x2308821, 0x8e3165ac,
-0x3c027fff, 0x3442ffff, 0x2228824, 0x151140,
-0x3c010001, 0x220821, 0xac3165a4, 0x1000004e,
-0x2201021, 0x152940, 0x3c030001, 0x651821,
-0x8c6365a8, 0x3c024000, 0x621024, 0x14400008,
-0x3c027fff, 0x3442ffff, 0x628824, 0x3c010001,
-0x250821, 0xac3165a0, 0x1000003f, 0x2201021,
-0x3c020001, 0x8c424398, 0x10400033, 0x3c11c00c,
-0x3c020001, 0x8c424424, 0x3c04c00c, 0x34842000,
-0x3c030001, 0x8c6344d8, 0x2102b, 0x21023,
-0x441024, 0x10600003, 0x518825, 0x3c022000,
-0x2228825, 0x3c020001, 0x451021, 0x8c4265b4,
-0x10400003, 0x3c020020, 0x10000004, 0x2228825,
-0x3c02ffdf, 0x3442ffff, 0x2228824, 0x151140,
-0x3c010001, 0x220821, 0x8c2265bc, 0x10400003,
-0x3c020080, 0x10000004, 0x2228825, 0x3c02ff7f,
-0x3442ffff, 0x2228824, 0x3c020001, 0x8c424410,
-0x10400002, 0x3c020800, 0x2228825, 0x3c020001,
-0x8c424414, 0x10400002, 0x3c020400, 0x2228825,
-0x3c020001, 0x8c424418, 0x10400006, 0x3c020100,
-0x10000004, 0x2228825, 0x3c027fff, 0x3442ffff,
-0x628824, 0x151140, 0x3c010001, 0x220821,
-0xac3165a0, 0x2201021, 0x8fbf002c, 0x8fb50028,
-0x8fb30024, 0x8fb20020, 0x8fb1001c, 0x8fb00018,
-0x3e00008, 0x27bd0030, 0x27bdffe0, 0xafb20018,
-0x809021, 0xafbf001c, 0xafb10014, 0xafb00010,
-0x8f840200, 0x3c030001, 0x8c634388, 0x8f860220,
-0x24020002, 0x106200a6, 0x2c620003, 0x10400005,
-0x24020001, 0x1062000a, 0x121940, 0x100000a0,
-0x0, 0x24020004, 0x10620053, 0x24020008,
-0x10620052, 0x128940, 0x10000099, 0x0,
-0x3c050001, 0xa32821, 0x8ca565ac, 0x3c100001,
-0x2038021, 0x8e1065a4, 0x3c024000, 0xa21024,
-0x10400038, 0x3c020008, 0x2021024, 0x10400020,
-0x34840002, 0x3c020001, 0x431021, 0x8c4265b0,
-0x10400005, 0x34840020, 0x34840100, 0x3c020020,
-0x10000006, 0x2028025, 0x2402feff, 0x822024,
-0x3c02ffdf, 0x3442ffff, 0x2028024, 0x121140,
-0x3c010001, 0x220821, 0x8c2265b8, 0x10400005,
-0x3c020001, 0xc23025, 0x3c020080, 0x10000016,
-0x2028025, 0x3c02fffe, 0x3442ffff, 0xc23024,
-0x3c02ff7f, 0x3442ffff, 0x1000000f, 0x2028024,
-0x2402fedf, 0x822024, 0x3c02fffe, 0x3442ffff,
-0xc23024, 0x3c02ff5f, 0x3442ffff, 0x2028024,
-0x3c010001, 0x230821, 0xac2065b0, 0x3c010001,
-0x230821, 0xac2065b8, 0xaf840200, 0xaf860220,
-0x8f820220, 0x34420002, 0xaf820220, 0x1000000a,
-0x121140, 0x3c02bfff, 0x3442ffff, 0x8f830200,
-0x2028024, 0x2402fffd, 0x621824, 0xc003c45,
-0xaf830200, 0x121140, 0x3c010001, 0x220821,
-0x1000004b, 0xac3065a4, 0x128940, 0x3c050001,
-0xb12821, 0x8ca565a8, 0x3c100001, 0x2118021,
-0x8e1065a0, 0x3c024000, 0xa21024, 0x14400010,
-0x0, 0x3c020001, 0x8c4244d8, 0x14400005,
-0x3c02bfff, 0x8f820200, 0x34420002, 0xaf820200,
-0x3c02bfff, 0x3442ffff, 0xc003c45, 0x2028024,
-0x3c010001, 0x310821, 0x10000031, 0xac3065a0,
-0x3c020001, 0x8c4244d8, 0x10400005, 0x3c020020,
-0x3c020001, 0x8c424424, 0x10400025, 0x3c020020,
-0xa21024, 0x10400007, 0x34840020, 0x24020100,
-0x3c010001, 0x310821, 0xac2265b4, 0x10000006,
-0x34840100, 0x3c010001, 0x310821, 0xac2065b4,
-0x2402feff, 0x822024, 0x3c020080, 0xa21024,
-0x10400007, 0x121940, 0x3c020001, 0x3c010001,
-0x230821, 0xac2265bc, 0x10000008, 0xc23025,
-0x121140, 0x3c010001, 0x220821, 0xac2065bc,
-0x3c02fffe, 0x3442ffff, 0xc23024, 0xaf840200,
-0xaf860220, 0x8f820220, 0x34420002, 0xaf820220,
-0x121140, 0x3c010001, 0x220821, 0xac3065a0,
-0x8fbf001c, 0x8fb20018, 0x8fb10014, 0x8fb00010,
-0x3e00008, 0x27bd0020, 0x0, 0x1821,
-0x308400ff, 0x2405ffdf, 0x2406ffbf, 0x641007,
-0x30420001, 0x10400004, 0x0, 0x8f820044,
-0x10000003, 0x34420040, 0x8f820044, 0x461024,
-0xaf820044, 0x8f820044, 0x34420020, 0xaf820044,
-0x8f820044, 0x451024, 0xaf820044, 0x24630001,
-0x28620008, 0x5440ffee, 0x641007, 0x3e00008,
-0x0, 0x0, 0x0, 0x8f8400c4,
-0x8f8600e0, 0x8f8700e4, 0x2402fff8, 0xc22824,
-0x10e5001a, 0x27623ff8, 0x14e20002, 0x24e80008,
-0x27683000, 0x55050004, 0x8d0a0000, 0x30c20004,
-0x14400012, 0x805021, 0x8ce90000, 0x8f42013c,
-0x1494823, 0x49182b, 0x94eb0006, 0x10600002,
-0x25630050, 0x494821, 0x123182b, 0x50400003,
-0x8f4201fc, 0x3e00008, 0xe01021, 0xaf8800e8,
-0x24420001, 0xaf4201fc, 0xaf8800e4, 0x3e00008,
-0x1021, 0x3e00008, 0x0, 0x8f8300e4,
-0x27623ff8, 0x10620004, 0x24620008, 0xaf8200e8,
-0x3e00008, 0xaf8200e4, 0x27623000, 0xaf8200e8,
-0x3e00008, 0xaf8200e4, 0x3e00008, 0x0,
-0x0, 0x0, 0x0, 0x8f880120,
-0x27624fe0, 0x8f830128, 0x15020002, 0x25090020,
-0x27694800, 0x11230012, 0x8fa20010, 0xad040000,
-0xad050004, 0xad060008, 0xa507000e, 0x8fa30014,
-0xad020018, 0x8fa20018, 0xad03001c, 0x25030016,
-0xad020010, 0xad030014, 0xaf890120, 0x8f4300fc,
-0x24020001, 0x2463ffff, 0x3e00008, 0xaf4300fc,
-0x8f430324, 0x1021, 0x24630001, 0x3e00008,
-0xaf430324, 0x3e00008, 0x0, 0x8f880100,
-0x276247e0, 0x8f830108, 0x15020002, 0x25090020,
-0x27694000, 0x1123000f, 0x8fa20010, 0xad040000,
-0xad050004, 0xad060008, 0xa507000e, 0x8fa30014,
-0xad020018, 0x8fa20018, 0xad03001c, 0x25030016,
-0xad020010, 0xad030014, 0xaf890100, 0x3e00008,
-0x24020001, 0x8f430328, 0x1021, 0x24630001,
-0x3e00008, 0xaf430328, 0x3e00008, 0x0,
-0x0, 0x0, 0x0, 0x0 };
-static u_int32_t tigon2FwRodata[] = {
-0x24486561,
-0x6465723a, 0x202f7072, 0x6f6a6563, 0x74732f72,
-0x63732f73, 0x772f6765, 0x2f2e2f6e, 0x69632f66,
-0x77322f63, 0x6f6d6d6f, 0x6e2f6677, 0x6d61696e,
-0x2e632c76, 0x20312e31, 0x2e322e34, 0x35203139,
-0x39392f30, 0x312f3234, 0x2030303a, 0x31303a35,
-0x35207368, 0x75616e67, 0x20457870, 0x20240000,
-0x65767452, 0x6e674600, 0x51657674, 0x46000000,
-0x51657674, 0x505f4600, 0x4d657674, 0x526e6746,
-0x0, 0x4d516576, 0x74460000, 0x4d516576,
-0x505f4600, 0x5173436f, 0x6e495f46, 0x0,
-0x5173436f, 0x6e734600, 0x51725072, 0x6f644600,
-0x6261644d, 0x656d537a, 0x0, 0x68774677,
-0x56657200, 0x62616448, 0x77566572, 0x0,
-0x2a2a4441, 0x574e5f41, 0x0, 0x74785278,
-0x4266537a, 0x0, 0x62664174, 0x6e4d726b,
-0x0, 0x7265645a, 0x6f6e6531, 0x0,
-0x70636943, 0x6f6e6600, 0x67656e43, 0x6f6e6600,
-0x2a646d61, 0x5244666c, 0x0, 0x2a50414e,
-0x49432a00, 0x66776d61, 0x696e2e63, 0x0,
-0x72636246, 0x6c616773, 0x0, 0x62616452,
-0x78526362, 0x0, 0x676c6f62, 0x466c6773,
-0x0, 0x2b5f6469, 0x73705f6c, 0x6f6f7000,
-0x2b65765f, 0x68616e64, 0x6c657200, 0x63616e74,
-0x31446d61, 0x0, 0x2b715f64, 0x6d615f74,
-0x6f5f6e69, 0x635f636b, 0x73756d00, 0x2b685f73,
-0x656e645f, 0x64617461, 0x5f726561, 0x64795f63,
-0x6b73756d, 0x0, 0x2b685f64, 0x6d615f72,
-0x645f6173, 0x73697374, 0x5f636b73, 0x756d0000,
-0x74436b73, 0x6d4f6e00, 0x2b715f64, 0x6d615f74,
-0x6f5f6e69, 0x63000000, 0x2b685f73, 0x656e645f,
-0x64617461, 0x5f726561, 0x64790000, 0x2b685f64,
-0x6d615f72, 0x645f6173, 0x73697374, 0x0,
-0x74436b73, 0x6d4f6666, 0x0, 0x2b685f73,
-0x656e645f, 0x62645f72, 0x65616479, 0x0,
-0x68737453, 0x52696e67, 0x0, 0x62616453,
-0x52696e67, 0x0, 0x6e696353, 0x52696e67,
-0x0, 0x77446d61, 0x416c6c41, 0x0,
-0x2b715f64, 0x6d615f74, 0x6f5f686f, 0x73745f63,
-0x6b73756d, 0x0, 0x2b685f6d, 0x61635f72,
-0x785f636f, 0x6d705f63, 0x6b73756d, 0x0,
-0x2b685f64, 0x6d615f77, 0x725f6173, 0x73697374,
-0x5f636b73, 0x756d0000, 0x72436b73, 0x6d4f6e00,
-0x2b715f64, 0x6d615f74, 0x6f5f686f, 0x73740000,
-0x2b685f6d, 0x61635f72, 0x785f636f, 0x6d700000,
-0x2b685f64, 0x6d615f77, 0x725f6173, 0x73697374,
-0x0, 0x72436b73, 0x6d4f6666, 0x0,
-0x2b685f72, 0x6563765f, 0x62645f72, 0x65616479,
-0x0, 0x2b685f72, 0x6563765f, 0x6a756d62,
-0x6f5f6264, 0x5f726561, 0x64790000, 0x2b685f72,
-0x6563765f, 0x6d696e69, 0x5f62645f, 0x72656164,
-0x79000000, 0x2b6d685f, 0x636f6d6d, 0x616e6400,
-0x2b685f74, 0x696d6572, 0x0, 0x2b685f64,
-0x6f5f7570, 0x64617465, 0x5f74785f, 0x636f6e73,
-0x0, 0x2b685f64, 0x6f5f7570, 0x64617465,
-0x5f72785f, 0x70726f64, 0x0, 0x2b636b73,
-0x756d3136, 0x0, 0x2b706565, 0x6b5f6d61,
-0x635f7278, 0x5f776100, 0x2b706565, 0x6b5f6d61,
-0x635f7278, 0x0, 0x2b646571, 0x5f6d6163,
-0x5f727800, 0x2b685f6d, 0x61635f72, 0x785f6174,
-0x746e0000, 0x62616452, 0x6574537a, 0x0,
-0x72784264, 0x4266537a, 0x0, 0x2b6e756c,
-0x6c5f6861, 0x6e646c65, 0x72000000, 0x66774f70,
-0x4661696c, 0x0, 0x2b685f75, 0x70646174,
-0x655f6c65, 0x64360000, 0x2b685f75, 0x70646174,
-0x655f6c65, 0x64320000, 0x696e7453, 0x74617465,
-0x0, 0x2a2a696e, 0x69744370, 0x0,
-0x23736372, 0x65616d00, 0x69537461, 0x636b4572,
-0x0, 0x70726f62, 0x654d656d, 0x0,
-0x2a2a4441, 0x574e5f42, 0x0, 0x2b73775f,
-0x646d615f, 0x61737369, 0x73745f70, 0x6c75735f,
-0x74696d65, 0x72000000, 0x2b267072, 0x656c6f61,
-0x645f7772, 0x5f646573, 0x63720000, 0x2b267072,
-0x656c6f61, 0x645f7264, 0x5f646573, 0x63720000,
-0x2b685f68, 0x665f7469, 0x6d657200, 0x24486561,
-0x6465723a, 0x202f7072, 0x6f6a6563, 0x74732f72,
-0x63732f73, 0x772f6765, 0x2f2e2f6e, 0x69632f66,
-0x77322f63, 0x6f6d6d6f, 0x6e2f7469, 0x6d65722e,
-0x632c7620, 0x312e312e, 0x322e3335, 0x20313939,
-0x392f3031, 0x2f323720, 0x31393a30, 0x393a3530,
-0x20686179, 0x65732045, 0x78702024, 0x0,
-0x65767452, 0x6e674600, 0x51657674, 0x46000000,
-0x51657674, 0x505f4600, 0x4d657674, 0x526e6746,
-0x0, 0x4d516576, 0x74460000, 0x4d516576,
-0x505f4600, 0x5173436f, 0x6e495f46, 0x0,
-0x5173436f, 0x6e734600, 0x51725072, 0x6f644600,
-0x542d446d, 0x61526432, 0x0, 0x542d446d,
-0x61526431, 0x0, 0x542d446d, 0x61526442,
-0x0, 0x542d446d, 0x61577232, 0x0,
-0x542d446d, 0x61577231, 0x0, 0x542d446d,
-0x61577242, 0x0, 0x0, 0x24486561,
-0x6465723a, 0x202f7072, 0x6f6a6563, 0x74732f72,
-0x63732f73, 0x772f6765, 0x2f2e2f6e, 0x69632f66,
-0x77322f63, 0x6f6d6d6f, 0x6e2f636f, 0x6d6d616e,
-0x642e632c, 0x7620312e, 0x312e322e, 0x32382031,
-0x3939392f, 0x30312f32, 0x30203139, 0x3a34393a,
-0x34392073, 0x6875616e, 0x67204578, 0x70202400,
-0x65767452, 0x6e674600, 0x51657674, 0x46000000,
-0x51657674, 0x505f4600, 0x4d657674, 0x526e6746,
-0x0, 0x4d516576, 0x74460000, 0x4d516576,
-0x505f4600, 0x5173436f, 0x6e495f46, 0x0,
-0x5173436f, 0x6e734600, 0x51725072, 0x6f644600,
-0x3f48636d, 0x644d6278, 0x0, 0x3f636d64,
-0x48737453, 0x0, 0x3f636d64, 0x4d634d64,
-0x0, 0x3f636d64, 0x50726f6d, 0x0,
-0x3f636d64, 0x4c696e6b, 0x0, 0x3f636d64,
-0x45727200, 0x819c, 0x8930, 0x8930,
-0x88b8, 0x865c, 0x8904, 0x8930,
-0x8274, 0x82e4, 0x8474, 0x854c,
-0x8518, 0x8930, 0x8354, 0x8608,
-0x8930, 0x8618, 0x8298, 0x8308,
-0x0, 0x0, 0x0, 0x24486561,
-0x6465723a, 0x202f7072, 0x6f6a6563, 0x74732f72,
-0x63732f73, 0x772f6765, 0x2f2e2f6e, 0x69632f66,
-0x77322f63, 0x6f6d6d6f, 0x6e2f6d63, 0x6173742e,
-0x632c7620, 0x312e312e, 0x322e3820, 0x31393938,
-0x2f31322f, 0x30382030, 0x323a3336, 0x3a333620,
-0x73687561, 0x6e672045, 0x78702024, 0x0,
-0x65767452, 0x6e674600, 0x51657674, 0x46000000,
-0x51657674, 0x505f4600, 0x4d657674, 0x526e6746,
-0x0, 0x4d516576, 0x74460000, 0x4d516576,
-0x505f4600, 0x5173436f, 0x6e495f46, 0x0,
-0x5173436f, 0x6e734600, 0x51725072, 0x6f644600,
-0x6164644d, 0x63447570, 0x0, 0x6164644d,
-0x6346756c, 0x0, 0x64656c4d, 0x634e6f45,
-0x0, 0x0, 0x0, 0x24486561,
-0x6465723a, 0x202f7072, 0x6f6a6563, 0x74732f72,
-0x63732f73, 0x772f6765, 0x2f2e2f6e, 0x69632f66,
-0x77322f63, 0x6f6d6d6f, 0x6e2f646d, 0x612e632c,
-0x7620312e, 0x312e322e, 0x32342031, 0x3939382f,
-0x31322f32, 0x31203030, 0x3a33333a, 0x30392073,
-0x6875616e, 0x67204578, 0x70202400, 0x65767452,
-0x6e674600, 0x51657674, 0x46000000, 0x51657674,
-0x505f4600, 0x4d657674, 0x526e6746, 0x0,
-0x4d516576, 0x74460000, 0x4d516576, 0x505f4600,
-0x5173436f, 0x6e495f46, 0x0, 0x5173436f,
-0x6e734600, 0x51725072, 0x6f644600, 0x7377446d,
-0x614f6666, 0x0, 0x31446d61, 0x4f6e0000,
-0x7377446d, 0x614f6e00, 0x2372446d, 0x6141544e,
-0x0, 0x72446d61, 0x41544e30, 0x0,
-0x72446d61, 0x41544e31, 0x0, 0x72446d61,
-0x34476200, 0x2a50414e, 0x49432a00, 0x646d612e,
-0x63000000, 0x2377446d, 0x6141544e, 0x0,
-0x77446d61, 0x41544e30, 0x0, 0x77446d61,
-0x41544e31, 0x0, 0x77446d61, 0x34476200,
-0x0, 0x0, 0x0, 0x24486561,
-0x6465723a, 0x202f7072, 0x6f6a6563, 0x74732f72,
-0x63732f73, 0x772f6765, 0x2f2e2f6e, 0x69632f66,
-0x77322f63, 0x6f6d6d6f, 0x6e2f7472, 0x6163652e,
-0x632c7620, 0x312e312e, 0x322e3520, 0x31393938,
-0x2f30392f, 0x33302031, 0x383a3530, 0x3a323820,
-0x73687561, 0x6e672045, 0x78702024, 0x0,
-0x0, 0x0, 0x0, 0x24486561,
-0x6465723a, 0x202f7072, 0x6f6a6563, 0x74732f72,
-0x63732f73, 0x772f6765, 0x2f2e2f6e, 0x69632f66,
-0x77322f63, 0x6f6d6d6f, 0x6e2f6461, 0x74612e63,
-0x2c762031, 0x2e312e32, 0x2e313220, 0x31393939,
-0x2f30312f, 0x32302031, 0x393a3439, 0x3a353120,
-0x73687561, 0x6e672045, 0x78702024, 0x0,
-0x46575f56, 0x45525349, 0x4f4e3a20, 0x58585800,
-0x46575f43, 0x4f4d5049, 0x4c455f54, 0x494d453a,
-0x20585858, 0x0, 0x46575f43, 0x4f4d5049,
-0x4c455f42, 0x593a2058, 0x58580000, 0x46575f43,
-0x4f4d5049, 0x4c455f48, 0x4f53543a, 0x20585858,
-0x0, 0x46575f43, 0x4f4d5049, 0x4c455f44,
-0x4f4d4149, 0x4e3a2058, 0x58580000, 0x46575f43,
-0x4f4d5049, 0x4c45523a, 0x20585858, 0x0,
-0x0, 0x12031600, 0x0, 0x24486561,
-0x6465723a, 0x202f7072, 0x6f6a6563, 0x74732f72,
-0x63732f73, 0x772f6765, 0x2f2e2f6e, 0x69632f66,
-0x77322f63, 0x6f6d6d6f, 0x6e2f6d65, 0x6d2e632c,
-0x7620312e, 0x312e322e, 0x35203139, 0x39382f30,
-0x392f3330, 0x2031383a, 0x35303a30, 0x38207368,
-0x75616e67, 0x20457870, 0x20240000, 0x24486561,
-0x6465723a, 0x202f7072, 0x6f6a6563, 0x74732f72,
-0x63732f73, 0x772f6765, 0x2f2e2f6e, 0x69632f66,
-0x77322f63, 0x6f6d6d6f, 0x6e2f7365, 0x6e642e63,
-0x2c762031, 0x2e312e32, 0x2e343420, 0x31393938,
-0x2f31322f, 0x32312030, 0x303a3333, 0x3a313820,
-0x73687561, 0x6e672045, 0x78702024, 0x0,
-0x65767452, 0x6e674600, 0x51657674, 0x46000000,
-0x51657674, 0x505f4600, 0x4d657674, 0x526e6746,
-0x0, 0x4d516576, 0x74460000, 0x4d516576,
-0x505f4600, 0x5173436f, 0x6e495f46, 0x0,
-0x5173436f, 0x6e734600, 0x51725072, 0x6f644600,
-0x69736e74, 0x54637055, 0x0, 0x24486561,
-0x6465723a, 0x202f7072, 0x6f6a6563, 0x74732f72,
-0x63732f73, 0x772f6765, 0x2f2e2f6e, 0x69632f66,
-0x77322f63, 0x6f6d6d6f, 0x6e2f7265, 0x63762e63,
-0x2c762031, 0x2e312e32, 0x2e353320, 0x31393939,
-0x2f30312f, 0x31362030, 0x323a3535, 0x3a343320,
-0x73687561, 0x6e672045, 0x78702024, 0x0,
-0x65767452, 0x6e674600, 0x51657674, 0x46000000,
-0x51657674, 0x505f4600, 0x4d657674, 0x526e6746,
-0x0, 0x4d516576, 0x74460000, 0x4d516576,
-0x505f4600, 0x5173436f, 0x6e495f46, 0x0,
-0x5173436f, 0x6e734600, 0x51725072, 0x6f644600,
-0x724d6163, 0x43686b30, 0x0, 0x72784672,
-0x6d324c67, 0x0, 0x72784e6f, 0x53744264,
-0x0, 0x72784e6f, 0x4d694264, 0x0,
-0x72784e6f, 0x4a6d4264, 0x0, 0x7278436b,
-0x446d6146, 0x0, 0x72785144, 0x6d457846,
-0x0, 0x72785144, 0x6d614600, 0x72785144,
-0x4c426446, 0x0, 0x72785144, 0x6d426446,
-0x0, 0x72784372, 0x63506164, 0x0,
-0x72536d51, 0x446d6146, 0x0, 0x24486561,
-0x6465723a, 0x202f7072, 0x6f6a6563, 0x74732f72,
-0x63732f73, 0x772f6765, 0x2f2e2f6e, 0x69632f66,
-0x77322f63, 0x6f6d6d6f, 0x6e2f6d61, 0x632e632c,
-0x7620312e, 0x312e322e, 0x32322031, 0x3939382f,
-0x31322f30, 0x38203032, 0x3a33363a, 0x33302073,
-0x6875616e, 0x67204578, 0x70202400, 0x65767452,
-0x6e674600, 0x51657674, 0x46000000, 0x51657674,
-0x505f4600, 0x4d657674, 0x526e6746, 0x0,
-0x4d516576, 0x74460000, 0x4d516576, 0x505f4600,
-0x5173436f, 0x6e495f46, 0x0, 0x5173436f,
-0x6e734600, 0x51725072, 0x6f644600, 0x6d616354,
-0x68726573, 0x0, 0x23744d61, 0x6341544e,
-0x0, 0x23724d61, 0x6341544e, 0x0,
-0x72656d41, 0x73737274, 0x0, 0x6c696e6b,
-0x444f574e, 0x0, 0x6c696e6b, 0x55500000,
-0x0, 0x0, 0x0, 0x24486561,
-0x6465723a, 0x202f7072, 0x6f6a6563, 0x74732f72,
-0x63732f73, 0x772f6765, 0x2f2e2f6e, 0x69632f66,
-0x77322f63, 0x6f6d6d6f, 0x6e2f636b, 0x73756d2e,
-0x632c7620, 0x312e312e, 0x322e3920, 0x31393939,
-0x2f30312f, 0x31342030, 0x303a3033, 0x3a343820,
-0x73687561, 0x6e672045, 0x78702024, 0x0,
-0x65767452, 0x6e674600, 0x51657674, 0x46000000,
-0x51657674, 0x505f4600, 0x4d657674, 0x526e6746,
-0x0, 0x4d516576, 0x74460000, 0x4d516576,
-0x505f4600, 0x5173436f, 0x6e495f46, 0x0,
-0x5173436f, 0x6e734600, 0x51725072, 0x6f644600,
-0x0, 0x0, 0x0, 0x50726f62,
-0x65506879, 0x0, 0x6c6e6b41, 0x53535254,
-0x0, 0x10218, 0x10248, 0x10260,
-0x1028c, 0x102b8, 0x102cc, 0x10308,
-0x106a8, 0x10488, 0x104c0, 0x103b8,
-0x10514, 0x1053c, 0x10570, 0x103fc,
-0x106a8, 0x10488, 0x104c0, 0x104e4,
-0x10514, 0x1053c, 0x10570, 0x1059c,
-0x0, 0x0, 0x0, 0x10c8c,
-0x10d5c, 0x10e34, 0x1106c, 0x110c8,
-0x111a4, 0x111cc, 0x112a8, 0x112d0,
-0x11478, 0x114a0, 0x11648, 0x11840,
-0x11ad4, 0x119e8, 0x11ad4, 0x11b00,
-0x11670, 0x11818, 0x0, 0x11e0c,
-0x11e4c, 0x11edc, 0x11f20, 0x11f84,
-0x12010, 0x12044, 0x120cc, 0x12164,
-0x12234, 0x12274, 0x122f8, 0x1231c,
-0x1242c, 0x646f4261, 0x73655067, 0x0,
-0x0, 0x0, 0x0, 0x73746d61,
-0x634c4e4b, 0x0, 0x0, 0x0 };
-static u_int32_t tigon2FwData[] = {
-0x1,
-0x1, 0x1, 0xc001fc, 0x3ffc,
-0xc00000, 0x416c7465, 0x6f6e2041, 0x63654e49,
-0x43205600, 0x0, 0x0, 0x416c7465,
-0x6f6e2041, 0x63654e49, 0x43205600, 0x42424242,
-0x0, 0x0, 0x0, 0x1ffffc,
-0x1fff7c, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x60cf00,
-0x60, 0xcf000000, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x3, 0x0,
-0x1, 0x0, 0x0, 0x0,
-0x1, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x1,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x1000000, 0x21000000, 0x12000140,
-0x0, 0x0, 0x20000000, 0x120000a0,
-0x0, 0x12000060, 0x12000180, 0x120001e0,
-0x0, 0x0, 0x0, 0x0,
-0x0, 0x0, 0x0, 0x2,
-0x0, 0x0, 0x30001, 0x1,
-0x30201, 0x0, 0x0, 0x0 };
diff --git a/sys/dev/tx/if_tx.c b/sys/dev/tx/if_tx.c
deleted file mode 100644
index 288edbd9b874..000000000000
--- a/sys/dev/tx/if_tx.c
+++ /dev/null
@@ -1,2069 +0,0 @@
-/* $OpenBSD: if_tx.c,v 1.3 1998/10/10 04:30:09 jason Exp $ */
-/* $FreeBSD$ */
-
-/*-
- * Copyright (c) 1997 Semen Ustimenko (semen@iclub.nsu.ru)
- * 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 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 AUTHOR 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.
- *
- *
- */
-
-/*
- * EtherPower II 10/100 Fast Ethernet (tx0)
- * (aka SMC9432TX based on SMC83c170 EPIC chip)
- *
- * Thanks are going to Steve Bauer and Jason Wright.
- *
- * todo:
- * Implement FULL IFF_MULTICAST support.
- * Test, test and test again:-(
- *
- */
-
-/* We should define compile time options before if_txvar.h included */
-/*#define EPIC_NOIFMEDIA 1*/
-/*#define EPIC_USEIOSPACE 1*/
-#define EARLY_RX 1
-/*#define EPIC_DEBUG 1*/
-
-#if defined(EPIC_DEBUG)
-#define dprintf(a) printf a
-#else
-#define dprintf(a)
-#endif
-
-/* Macro to get either mbuf cluster or nothing */
-#define EPIC_MGETCLUSTER(m) \
- { MGETHDR((m),M_DONTWAIT,MT_DATA); \
- if (m) { \
- MCLGET((m),M_DONTWAIT); \
- if( 0 == ((m)->m_flags & M_EXT) ){ \
- m_freem(m); \
- (m) = NULL; \
- } \
- } \
- }
-
-#include "bpf.h"
-#include "opt_bdg.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <sys/malloc.h>
-#include <sys/kernel.h>
-#include <sys/socket.h>
-#include <sys/sockio.h>
-
-#include <net/if.h>
-#include <net/if_dl.h>
-#include <net/if_types.h>
-
-#if !defined(SIOCSIFMEDIA) || defined(EPIC_NOIFMEDIA)
-#define EPIC_NOIFMEDIA 1
-#else
-#include <net/if_media.h>
-#endif
-
-#ifdef INET
-#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/in_var.h>
-#include <netinet/ip.h>
-#endif
-
-#ifdef IPX
-#include <netipx/ipx.h>
-#include <netipx/ipx_if.h>
-#endif
-
-#ifdef NS
-#include <netns/ns.h>
-#include <netns/ns_if.h>
-#endif
-
-#if NBPF > 0
-#include <net/bpf.h>
-#include <net/bpfdesc.h>
-#endif
-
-#if defined(__OpenBSD__)
-#include <sys/ioctl.h>
-#include <sys/errno.h>
-#include <sys/device.h>
-
-#include <netinet/if_ether.h>
-
-#include <vm/vm.h>
-
-#include <dev/pci/pcivar.h>
-#include <dev/pci/pcireg.h>
-#include <dev/pci/pcidevs.h>
-
-#include <dev/pci/if_txvar.h>
-#else /* __FreeBSD__ */
-#include <sys/eventhandler.h>
-#include <net/if_mib.h>
-#include <netinet/in.h>
-#include <netinet/if_ether.h>
-#include <vm/vm.h>
-#include <vm/pmap.h>
-#include <machine/clock.h>
-
-#include <pci/pcivar.h>
-#include <pci/if_txvar.h>
-
-#ifdef BRIDGE
-#include <net/bridge.h>
-#endif
-
-#endif
-
-#if defined(__FreeBSD__)
-#if __FreeBSD_version >= 300000
-#define EPIC_IFIOCTL_CMD_TYPE u_long
-#else
-#define EPIC_IFIOCTL_CMD_TYPE int
-#endif
-#define EPIC_INTR_RET_TYPE void
-#else /* __OpenBSD__ */
-#define EPIC_IFIOCTL_CMD_TYPE u_long
-#define EPIC_INTR_RET_TYPE int
-#endif
-
-static int epic_ifioctl __P((register struct ifnet *, EPIC_IFIOCTL_CMD_TYPE, caddr_t));
-static EPIC_INTR_RET_TYPE epic_intr __P((void *));
-static int epic_common_attach __P((epic_softc_t *));
-static void epic_ifstart __P((struct ifnet * const));
-static void epic_ifwatchdog __P((struct ifnet *));
-static int epic_init __P((epic_softc_t *));
-static void epic_stop __P((epic_softc_t *));
-static __inline void epic_rx_done __P((epic_softc_t *));
-static __inline void epic_tx_done __P((epic_softc_t *));
-static int epic_init_rings __P((epic_softc_t *));
-static void epic_free_rings __P((epic_softc_t *));
-static void epic_stop_activity __P((epic_softc_t *));
-static void epic_start_activity __P((epic_softc_t *));
-static void epic_set_rx_mode __P((epic_softc_t *));
-static void epic_set_tx_mode __P((epic_softc_t *));
-static void epic_set_mc_table __P((epic_softc_t *));
-static void epic_set_media_speed __P((epic_softc_t *));
-static void epic_init_phy __P((epic_softc_t *));
-static void epic_dump_state __P((epic_softc_t *));
-static int epic_autoneg __P((epic_softc_t *));
-static int epic_read_eeprom __P((epic_softc_t *,u_int16_t));
-static void epic_output_eepromw __P((epic_softc_t *, u_int16_t));
-static u_int16_t epic_input_eepromw __P((epic_softc_t *));
-static u_int8_t epic_eeprom_clock __P((epic_softc_t *,u_int8_t));
-static void epic_write_eepromreg __P((epic_softc_t *,u_int8_t));
-static u_int8_t epic_read_eepromreg __P((epic_softc_t *));
-static u_int16_t epic_read_phy_register __P((epic_softc_t *, u_int16_t));
-static void epic_write_phy_register __P((epic_softc_t *, u_int16_t, u_int16_t));
-
-#if !defined(EPIC_NOIFMEDIA)
-static int epic_ifmedia_change __P((struct ifnet *));
-static void epic_ifmedia_status __P((struct ifnet *, struct ifmediareq *));
-#endif
-
-int epic_mtypes [] = {
- IFM_ETHER | IFM_10_T,
- IFM_ETHER | IFM_10_T | IFM_FDX,
- IFM_ETHER | IFM_100_TX,
- IFM_ETHER | IFM_100_TX | IFM_FDX,
- IFM_ETHER | IFM_10_T | IFM_LOOP,
- IFM_ETHER | IFM_10_T | IFM_FDX | IFM_LOOP,
- IFM_ETHER | IFM_10_T | IFM_LOOP | IFM_FLAG1,
- IFM_ETHER | IFM_100_TX | IFM_LOOP,
- IFM_ETHER | IFM_100_TX | IFM_LOOP | IFM_FLAG1,
- IFM_ETHER | IFM_100_TX | IFM_FDX | IFM_LOOP,
- IFM_ETHER | IFM_AUTO
-};
-#define EPIC_MTYPESNUM (sizeof(epic_mtypes) / sizeof(epic_mtypes[0]))
-
-
-/* -------------------------------------------------------------------------
- OS-specific part
- ------------------------------------------------------------------------- */
-
-#if defined(__OpenBSD__)
-/* -----------------------------OpenBSD------------------------------------- */
-
-static int epic_openbsd_probe __P((struct device *,void *,void *));
-static void epic_openbsd_attach __P((struct device *, struct device *, void *));
-static void epic_shutdown __P((void *));
-
-struct cfattach tx_ca = {
- sizeof(epic_softc_t), epic_openbsd_probe, epic_openbsd_attach
-};
-struct cfdriver tx_cd = {
- NULL,"tx",DV_IFNET
-};
-
-/* Synopsis: Check if device id corresponds with SMC83C170 id. */
-static int
-epic_openbsd_probe(
- struct device *parent,
- void *match,
- void *aux )
-{
- struct pci_attach_args *pa = aux;
- if( PCI_VENDOR(pa->pa_id) != SMC_VENDORID )
- return 0;
-
- if( PCI_PRODUCT(pa->pa_id) == CHIPID_83C170 )
- return 1;
-
- return 0;
-}
-
-static void
-epic_openbsd_attach(
- struct device *parent,
- struct device *self,
- void *aux )
-{
- epic_softc_t *sc = (epic_softc_t*)self;
- struct pci_attach_args *pa = aux;
- pci_chipset_tag_t pc = pa->pa_pc;
- pci_intr_handle_t ih;
- const char *intrstr = NULL;
- struct ifnet *ifp;
- bus_space_tag_t iot = pa->pa_iot;
- bus_addr_t iobase;
- bus_size_t iosize;
- int i;
-#if !defined(EPIC_NOIFMEDIA)
- int tmp;
-#endif
-
- if( pci_io_find(pc, pa->pa_tag, PCI_CBIO, &iobase, &iosize)) {
- printf(": can't find i/o space\n");
- return;
- }
- if( bus_space_map(iot, iobase, iosize, 0, &sc->sc_sh)) {
- printf(": can't map i/o space\n");
- return;
- }
- sc->sc_st = iot;
-
- ifp = &sc->sc_if;
- bcopy(sc->sc_dev.dv_xname, ifp->if_xname,IFNAMSIZ);
- ifp->if_softc = sc;
- ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
- ifp->if_ioctl = epic_ifioctl;
- ifp->if_start = epic_ifstart;
- ifp->if_watchdog = epic_ifwatchdog;
-
- /* Do common attach procedure */
- if( epic_common_attach(sc) ) return;
-
- /* Map interrupt */
- if( pci_intr_map(pc, pa->pa_intrtag, pa->pa_intrpin,
- pa->pa_intrline, &ih)) {
- printf(": can't map interrupt\n");
- return;
- }
- intrstr = pci_intr_string(pc, ih);
- sc->sc_ih = pci_intr_establish(pc, ih, IPL_NET, epic_intr, sc,
- self->dv_xname);
-
- if( NULL == sc->sc_ih ) {
- printf(": can't establish interrupt");
- if( intrstr )printf(" at %s",intrstr);
- printf("\n");
- return;
- }
- printf(": %s",intrstr);
-
- /* Display some info */
- printf(" address %s",ether_sprintf(sc->sc_macaddr));
- /* Read current media config and display it too */
- i = PHY_READ_2( sc, DP83840_BMCR );
-#if !defined(EPIC_NOIFMEDIA)
- tmp = IFM_ETHER;
-#endif
- if( i & BMCR_AUTONEGOTIATION ){
- printf(", Auto-Neg ");
-
- /* To avoid bug in QS6612 read LPAR enstead of BMSR */
- i = PHY_READ_2( sc, DP83840_LPAR );
- if( i & (ANAR_100_TX|ANAR_100_TX_FD) ) printf("100Mbps");
- else printf("10Mbps");
- if( i & (ANAR_10_FD|ANAR_100_TX_FD) ) printf(" FD");
-#if !defined(EPIC_NOIFMEDIA)
- tmp |= IFM_AUTO;
-#endif
- } else {
-#if defined(EPIC_NOIFMEDIA)
- ifp->if_flags |= IFF_LINK0;
-#endif
- if( i & BMCR_100MBPS ) {
- printf(", 100Mbps");
-#if !defined(EPIC_NOIFMEDIA)
- tmp |= IFM_100_TX;
-#else
- ifp->if_flags |= IFF_LINK2;
-#endif
- } else {
- printf(", 10Mbps");
-#if !defined(EPIC_NOIFMEDIA)
- tmp |= IFM_10_T;
-#endif
- }
- if( i & BMCR_FULL_DUPLEX ) {
- printf(" FD");
-#if !defined(EPIC_NOIFMEDIA)
- tmp |= IFM_FDX;
-#else
- ifp->if_flags |= IFF_LINK1;
-#endif
- }
- }
-
- /* Init ifmedia interface */
-#if !defined(EPIC_NOIFMEDIA)
- ifmedia_init(&sc->ifmedia,0,epic_ifmedia_change,epic_ifmedia_status);
-
- for (i=0; i<EPIC_MTYPESNUM; i++)
- ifmedia_add(&sc->ifmedia,epic_mtypes[i],0,NULL);
-
- ifmedia_set(&sc->ifmedia, tmp);
-#endif
-
- /* Attach os interface and bpf */
- if_attach(ifp);
- ether_ifattach(ifp);
-#if NBPF > 0
- bpfattach(&sc->sc_if.if_bpf, ifp, DLT_EN10MB,
- sizeof(struct ether_header));
-#endif
-
- /* Set shutdown routine to stop DMA process */
- shutdownhook_establish(epic_shutdown, sc);
- printf("\n");
-}
-
-/* Simple call epic_stop() */
-static void
-epic_shutdown(
- void *sc)
-{
- epic_stop(sc);
-}
-
-#else /* __FreeBSD__ */
-/* -----------------------------FreeBSD------------------------------------- */
-
-static const char* epic_freebsd_probe __P((pcici_t, pcidi_t));
-static void epic_freebsd_attach __P((pcici_t, int));
-static void epic_shutdown __P((void *, int));
-
-/* Global variables */
-static u_long epic_pci_count;
-static struct pci_device txdevice = {
- "tx",
- epic_freebsd_probe,
- epic_freebsd_attach,
- &epic_pci_count,
- NULL
-};
-
-/* Append this driver to pci drivers list */
-COMPAT_PCI_DRIVER (tx, txdevice);
-
-/* Synopsis: Check if device id corresponds with SMC83C170 id. */
-static const char*
-epic_freebsd_probe(
- pcici_t config_id,
- pcidi_t device_id)
-{
- if( PCI_VENDORID(device_id) != SMC_VENDORID )
- return NULL;
-
- if( PCI_CHIPID(device_id) == CHIPID_83C170 )
- return "SMC 83c170";
-
- return NULL;
-}
-
-/*
- * Do FreeBSD-specific attach routine, like map registers, alloc softc
- * structure and etc.
- */
-static void
-epic_freebsd_attach(
- pcici_t config_id,
- int unit)
-{
- struct ifnet *ifp;
- epic_softc_t *sc;
-#if defined(EPIC_USEIOSPACE)
- u_int32_t iobase;
-#else
- caddr_t pmembase;
-#endif
- u_int32_t command;
- int i,s,tmp;
-
- printf("tx%d",unit);
-
- /* Allocate memory for softc, hardware descriptors and frag lists */
- sc = (epic_softc_t *) malloc( sizeof(epic_softc_t), M_DEVBUF, M_NOWAIT);
- if (sc == NULL) return;
-
- /* Preinitialize softc structure */
- bzero(sc, sizeof(epic_softc_t));
- sc->unit = unit;
-
- /* Fill ifnet structure */
- ifp = &sc->sc_if;
- ifp->if_unit = unit;
- ifp->if_name = "tx";
- ifp->if_softc = sc;
- ifp->if_flags = IFF_BROADCAST|IFF_SIMPLEX|IFF_MULTICAST;
- ifp->if_ioctl = epic_ifioctl;
- ifp->if_start = epic_ifstart;
- ifp->if_watchdog = epic_ifwatchdog;
- ifp->if_init = (if_init_f_t*)epic_init;
- ifp->if_timer = 0;
- ifp->if_output = ether_output;
- ifp->if_snd.ifq_maxlen = TX_RING_SIZE;
-
- /* Get iobase or membase */
-#if defined(EPIC_USEIOSPACE)
- command = PCI_CONF_READ(PCI_CFCS);
- command |= PCI_CFCS_IOEN;
- PCI_CONF_WRITE(PCI_CFCS, command);
- command = PCI_CONF_READ(PCI_CFCS);
-
- if (!(command & PCI_CFCS_IOEN)) {
- printf(": failed to enable memory mapping!\n");
- free(sc, M_DEVBUF);
- return;
- }
-
- if (!pci_map_port(config_id, PCI_CBIO,(u_short *) &(sc->iobase))) {
- printf(": cannot map port\n");
- free(sc, M_DEVBUF);
- return;
- }
-#else
- command = PCI_CONF_READ(PCI_CFCS);
- command |= PCI_CFCS_MAEN;
- PCI_CONF_WRITE(PCI_CFCS, command);
- command = PCI_CONF_READ(PCI_CFCS);
-
- if (!(command & PCI_CFCS_MAEN)) {
- printf(": failed to enable memory mapping!\n");
- free(sc, M_DEVBUF);
- return;
- }
-
- if (!pci_map_mem(config_id, PCI_CBMA,(vm_offset_t *) &(sc->csr),(vm_offset_t *) &pmembase)) {
- printf(": cannot map memory\n");
- free(sc, M_DEVBUF);
- return;
- }
-#endif
-
- /* Do OS independent part, including chip wakeup and reset */
- if( epic_common_attach(sc) ) return;
-
- /* Enable BusMaster'ing */
- command = PCI_CONF_READ(PCI_CFCS);
- command |= PCI_CFCS_BMEN;
- PCI_CONF_WRITE(PCI_CFCS, command);
-
- /* Display ethernet address ,... */
- printf(": address %02x:%02x:%02x:%02x:%02x:%02x,",
- sc->sc_macaddr[0],sc->sc_macaddr[1],sc->sc_macaddr[2],
- sc->sc_macaddr[3],sc->sc_macaddr[4],sc->sc_macaddr[5]);
-
- /* board type and ... */
- printf(" type ");
- for(i=0x2c;i<0x32;i++) {
- tmp = epic_read_eeprom( sc, i );
- if( ' ' == (u_int8_t)tmp ) break;
- printf("%c",(u_int8_t)tmp);
- tmp >>= 8;
- if( ' ' == (u_int8_t)tmp ) break;
- printf("%c",(u_int8_t)tmp);
- }
-
- /* Read current media config and display it too */
- i = PHY_READ_2( sc, DP83840_BMCR );
-#if !defined(EPIC_NOIFMEDIA)
- tmp = IFM_ETHER;
-#endif
- if( i & BMCR_AUTONEGOTIATION ){
- printf(", Auto-Neg ");
-
- /* To avoid bug in QS6612 read LPAR enstead of BMSR */
- i = PHY_READ_2( sc, DP83840_LPAR );
- if( i & (ANAR_100_TX|ANAR_100_TX_FD) ) printf("100Mbps ");
- else printf("10Mbps ");
- if( i & (ANAR_10_FD|ANAR_100_TX_FD) ) printf("FD");
-#if !defined(EPIC_NOIFMEDIA)
- tmp |= IFM_AUTO;
-#endif
- } else {
-#if defined(EPIC_NOIFMEDIA)
- ifp->if_flags |= IFF_LINK0;
-#endif
- if( i & BMCR_100MBPS ) {
- printf(", 100Mbps ");
-#if !defined(EPIC_NOIFMEDIA)
- tmp |= IFM_100_TX;
-#else
- ifp->if_flags |= IFF_LINK2;
-#endif
- } else {
- printf(", 10Mbps ");
-#if !defined(EPIC_NOIFMEDIA)
- tmp |= IFM_10_T;
-#endif
- }
- if( i & BMCR_FULL_DUPLEX ) {
- printf("FD");
-#if !defined(EPIC_NOIFMEDIA)
- tmp |= IFM_FDX;
-#else
- ifp->if_flags |= IFF_LINK1;
-#endif
- }
- }
-
- /* Init ifmedia interface */
-#if !defined(EPIC_NOIFMEDIA)
- ifmedia_init(&sc->ifmedia,0,epic_ifmedia_change,epic_ifmedia_status);
-
- for (i=0; i<EPIC_MTYPESNUM; i++)
- ifmedia_add(&sc->ifmedia,epic_mtypes[i],0,NULL);
-
- ifmedia_set(&sc->ifmedia, tmp);
-#endif
-
- s = splimp();
-
- /* Map interrupt */
- if( !pci_map_int(config_id, epic_intr, (void*)sc, &net_imask) ) {
- printf(": couldn't map interrupt\n");
- free(sc, M_DEVBUF);
- return;
- }
-
- /* Set shut down routine to stop DMA processes on reboot */
- EVENTHANDLER_REGISTER(shutdown_post_sync, epic_shutdown, sc,
- SHUTDOWN_PRI_DEFAULT);
-
- /* Attach to if manager */
- if_attach(ifp);
- ether_ifattach(ifp);
-
-#if NBPF > 0
- bpfattach(ifp,DLT_EN10MB, sizeof(struct ether_header));
-#endif
-
- splx(s);
-
- printf("\n");
-
- return;
-}
-
-static void
-epic_shutdown(
- void *sc,
- int howto)
-{
- epic_stop(sc);
-}
-
-#endif /* __OpenBSD__ */
-
-/* ------------------------------------------------------------------------
- OS-independing part
- ------------------------------------------------------------------------ */
-
-/*
- * This is if_ioctl handler.
- */
-static int
-epic_ifioctl __P((
- register struct ifnet * ifp,
- EPIC_IFIOCTL_CMD_TYPE command,
- caddr_t data))
-{
- epic_softc_t *sc = ifp->if_softc;
- int x, error = 0;
-
- x = splimp();
-
- switch (command) {
-#if defined(__FreeBSD__)
- case SIOCSIFADDR:
- case SIOCGIFADDR:
- case SIOCSIFMTU:
- error = ether_ioctl(ifp, command, data);
- break;
-#else /* __OpenBSD__ */
- case SIOCSIFADDR: {
- struct ifaddr *ifa = (struct ifaddr *)data;
-
- ifp->if_flags |= IFF_UP;
- switch(ifa->ifa_addr->sa_family) {
-#if INET
- case AF_INET:
- epic_stop(sc);
- epic_init(sc);
- arp_ifinit(&sc->arpcom,ifa);
- break;
-#endif /* __FreeBSD__ */
-#if NS
- case AF_NS: {
- register struct ns_addr * ina = &IA_SNS(ifa)->sns_addr;
-
- if( ns_nullhost(*ina) )
- ina->x_host =
- *(union ns_host *) LLADDR(ifp->if_sadl);
- else
- bcopy(ina->x_host.c_host, LLADDR(ifp->if_sadl),
- ifp->if_addrlen);
-
- epic_stop(sc);
- epic_init(sc);
- break;
- }
-#endif
- default:
- epic_stop(sc);
- epic_init(sc);
- break;
- }
- }
-#endif
-
- case SIOCSIFFLAGS:
- /*
- * If the interface is marked up and stopped, then start it.
- * If it is marked down and running, then stop it.
- */
- if (ifp->if_flags & IFF_UP) {
- if ((ifp->if_flags & IFF_RUNNING) == 0) {
- epic_init(sc);
- break;
- }
- } else {
- if (ifp->if_flags & IFF_RUNNING) {
- epic_stop(sc);
- break;
- }
- }
-
- epic_stop_activity(sc);
-
- /* Handle IFF_PROMISC flag */
- epic_set_rx_mode(sc);
-
-#if defined(EPIC_NOIFMEDIA)
- /* Handle IFF_LINKx flags */
- epic_set_media_speed(sc);
-#endif
- epic_start_activity(sc);
- break;
-
- case SIOCADDMULTI:
- case SIOCDELMULTI:
- /* Update out multicast list */
-#if defined(__FreeBSD__) && __FreeBSD_version >= 300000
- epic_set_mc_table(sc);
- error = 0;
-#else
- error = (command == SIOCADDMULTI) ?
- ether_addmulti((struct ifreq *)data, &sc->arpcom) :
- ether_delmulti((struct ifreq *)data, &sc->arpcom);
-
- if (error == ENETRESET) {
- epic_set_mc_table(sc);
- error = 0;
- }
-#endif
- break;
-
-#if !defined(EPIC_NOIFMEDIA)
- case SIOCSIFMEDIA:
- case SIOCGIFMEDIA:
- error = ifmedia_ioctl(ifp, (struct ifreq *)data,
- &sc->ifmedia, command);
- break;
-#endif
-
- default:
- error = EINVAL;
- }
- splx(x);
-
- return error;
-}
-
-/*
- * OS-independed part of attach process. allocate memory for descriptors
- * and frag lists, wake up chip, read MAC address and PHY identyfier.
- * Return -1 on failure.
- */
-static int
-epic_common_attach(
- epic_softc_t *sc)
-{
- int i;
- caddr_t pool;
-
- i = sizeof(struct epic_frag_list)*TX_RING_SIZE +
- sizeof(struct epic_rx_desc)*RX_RING_SIZE +
- sizeof(struct epic_tx_desc)*TX_RING_SIZE + PAGE_SIZE,
- sc->pool = (epic_softc_t *) malloc( i, M_DEVBUF, M_NOWAIT);
-
- if (sc->pool == NULL) {
- printf(": can't allocate memory for buffers\n");
- return -1;
- }
- bzero(sc->pool, i);
-
- /* Align pool on PAGE_SIZE */
- pool = (caddr_t)sc->pool;
- pool = (caddr_t)((u_int32_t)(pool + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1));
-
- /* Distribute memory */
- sc->tx_flist = (void *)pool;
- pool += sizeof(struct epic_frag_list)*TX_RING_SIZE;
- sc->rx_desc = (void *)pool;
- pool += sizeof(struct epic_rx_desc)*RX_RING_SIZE;
- sc->tx_desc = (void *)pool;
-
- /* Bring the chip out of low-power mode and reset it. */
- CSR_WRITE_4( sc, GENCTL, GENCTL_SOFT_RESET );
-
- /* Workaround for Application Note 7-15 */
- for (i=0; i<16; i++) CSR_WRITE_4(sc, TEST1, TEST1_CLOCK_TEST);
-
- /* Read mac address from EEPROM */
- for (i = 0; i < ETHER_ADDR_LEN / sizeof(u_int16_t); i++)
- ((u_int16_t *)sc->sc_macaddr)[i] = epic_read_eeprom(sc,i);
-
- /* Identify PHY */
- sc->phyid = PHY_READ_2(sc, DP83840_PHYIDR1 )<<6;
- sc->phyid|= (PHY_READ_2( sc, DP83840_PHYIDR2 )>>10)&0x3F;
- if( QS6612_OUI != sc->phyid )
- printf(": WARNING! PHY unknown (0x%x)",sc->phyid);
-
- sc->tx_threshold = TRANSMIT_THRESHOLD;
- sc->txcon = TXCON_DEFAULT;
-
- return 0;
-}
-
-/*
- * This is if_start handler. It takes mbufs from if_snd queue
- * and quque them for transmit, one by one, until TX ring become full
- * or quque become empty.
- */
-static void
-epic_ifstart(struct ifnet * const ifp){
- epic_softc_t *sc = ifp->if_softc;
- struct epic_tx_buffer *buf;
- struct epic_tx_desc *desc;
- struct epic_frag_list *flist;
- struct mbuf *m0;
- register struct mbuf *m;
- register int i;
-
-#if 0
- /* If no link is established, simply free all mbufs in queue */
- PHY_READ_2( sc, DP83840_BMSR );
- if( !(BMSR_LINK_STATUS & PHY_READ_2( sc, DP83840_BMSR )) ){
- IF_DEQUEUE( &ifp->if_snd, m0 );
- while( m0 ) {
- m_freem(m0);
- IF_DEQUEUE( &ifp->if_snd, m0 );
- }
- return;
- }
-#endif
-
- /* Link is OK, queue packets to NIC */
- while( sc->pending_txs < TX_RING_SIZE ){
- buf = sc->tx_buffer + sc->cur_tx;
- desc = sc->tx_desc + sc->cur_tx;
- flist = sc->tx_flist + sc->cur_tx;
-
- /* Get next packet to send */
- IF_DEQUEUE( &ifp->if_snd, m0 );
-
- /* If nothing to send, return */
- if( NULL == m0 ) return;
-
- /* If descriptor is busy, set IFF_OACTIVE and exit */
- if( desc->status & 0x8000 ) {
- dprintf((EPIC_FORMAT ": desc is busy in ifstart, up and down interface please\n",EPIC_ARGS(sc)));
- break;
- }
-
- if( buf->mbuf ) {
- dprintf((EPIC_FORMAT ": mbuf not freed in ifstart, up and down interface please\n",EPIC_ARGS(sc)));
- break;
- }
-
- /* Fill fragments list */
- for( m=m0, i=0;
- (NULL != m) && (i < EPIC_MAX_FRAGS);
- m = m->m_next, i++ ) {
- flist->frag[i].fraglen = m->m_len;
- flist->frag[i].fragaddr = vtophys( mtod(m, caddr_t) );
- }
- flist->numfrags = i;
-
- /* If packet was more than EPIC_MAX_FRAGS parts, */
- /* recopy packet to new allocated mbuf cluster */
- if( NULL != m ){
- EPIC_MGETCLUSTER(m);
- if( NULL == m ){
- printf(EPIC_FORMAT ": cannot allocate mbuf cluster\n",EPIC_ARGS(sc));
- m_freem(m0);
- ifp->if_oerrors++;
- continue;
- }
-
- m_copydata( m0, 0, m0->m_pkthdr.len, mtod(m,caddr_t) );
- flist->frag[0].fraglen =
- m->m_pkthdr.len = m->m_len = m0->m_pkthdr.len;
- m->m_pkthdr.rcvif = ifp;
-
- flist->numfrags = 1;
- flist->frag[0].fragaddr = vtophys( mtod(m, caddr_t) );
- m_freem(m0);
- m0 = m;
- }
-
- buf->mbuf = m0;
- sc->pending_txs++;
- sc->cur_tx = ( sc->cur_tx + 1 ) & TX_RING_MASK;
- desc->control = 0x01;
- desc->txlength =
- max(m0->m_pkthdr.len,ETHER_MIN_LEN-ETHER_CRC_LEN);
- desc->status = 0x8000;
- CSR_WRITE_4( sc, COMMAND, COMMAND_TXQUEUED );
-
- /* Set watchdog timer */
- ifp->if_timer = 8;
-
-#if NBPF > 0
- if( ifp->if_bpf )
-#if defined(__FreeBSD__)
- bpf_mtap( ifp, m0 );
-#else /* __OpenBSD__ */
- bpf_mtap( ifp->if_bpf, m0 );
-#endif /* __FreeBSD__ */
-#endif
- }
-
- ifp->if_flags |= IFF_OACTIVE;
-
- return;
-
-}
-
-/*
- *
- * splimp() invoked before epic_intr_normal()
- */
-static __inline void
-epic_rx_done __P((
- epic_softc_t *sc ))
-{
- u_int16_t len;
- struct epic_rx_buffer *buf;
- struct epic_rx_desc *desc;
- struct mbuf *m;
- struct ether_header *eh;
-
- while( !(sc->rx_desc[sc->cur_rx].status & 0x8000) ) {
- buf = sc->rx_buffer + sc->cur_rx;
- desc = sc->rx_desc + sc->cur_rx;
-
- /* Switch to next descriptor */
- sc->cur_rx = (sc->cur_rx+1) & RX_RING_MASK;
-
- /* Check for errors, this should happend */
- /* only if SAVE_ERRORED_PACKETS is set, */
- /* normaly rx errors generate RXE interrupt */
- if( !(desc->status & 1) ) {
- dprintf((EPIC_FORMAT ": Rx error status: 0x%x\n",EPIC_ARGS(sc),desc->status));
- sc->sc_if.if_ierrors++;
- desc->status = 0x8000;
- continue;
- }
-
- /* Save packet length and mbuf contained packet */
- len = desc->rxlength - ETHER_CRC_LEN;
- m = buf->mbuf;
-
- /* Try to get mbuf cluster */
- EPIC_MGETCLUSTER( buf->mbuf );
- if( NULL == buf->mbuf ) {
- printf(EPIC_FORMAT ": cannot allocate mbuf cluster\n",EPIC_ARGS(sc));
- buf->mbuf = m;
- desc->status = 0x8000;
- sc->sc_if.if_ierrors++;
- continue;
- }
-
- /* Point to new mbuf, and give descriptor to chip */
- desc->bufaddr = vtophys( mtod( buf->mbuf, caddr_t ) );
- desc->status = 0x8000;
-
- /* First mbuf in packet holds the ethernet and packet headers */
- eh = mtod( m, struct ether_header * );
- m->m_pkthdr.rcvif = &(sc->sc_if);
- m->m_pkthdr.len = m->m_len = len;
-
-#if NBPF > 0
- /* Give mbuf to BPF */
- if( sc->sc_if.if_bpf )
-#if defined(__FreeBSD__)
- bpf_mtap( &sc->sc_if, m );
-#else /* __OpenBSD__ */
- bpf_mtap( sc->sc_if.if_bpf, m );
-#endif /* __FreeBSD__ */
-#endif /* NBPF */
-
-#ifdef BRIDGE
- if (do_bridge) {
- struct ifnet *bdg_ifp ;
- bdg_ifp = bridge_in(m);
- if (bdg_ifp == BDG_DROP) {
- if (m)
- m_free(m);
- continue; /* and drop */
- }
- if (bdg_ifp != BDG_LOCAL)
- bdg_forward(&m, bdg_ifp);
- if (bdg_ifp != BDG_LOCAL && bdg_ifp != BDG_BCAST &&
- bdg_ifp != BDG_MCAST) {
- if (m)
- m_free(m);
- continue; /* and drop */
- }
- /* all others accepted locally */
- }
-#endif
-
-#if NBPF > 0
-#ifdef BRIDGE
- /*
- * This deserves explanation
- * If the bridge is _on_, then the following check
- * must not be done because occasionally the bridge
- * gets packets that are local but have the ethernet
- * address of one of the other interfaces.
- *
- * But if the bridge is off, then we have to drop
- * stuff that came in just via bpf.
- */
- if (!do_bridge)
-#endif
- /* Accept only our packets, broadcasts and multicasts */
- if( (eh->ether_dhost[0] & 1) == 0 &&
- bcmp(eh->ether_dhost,sc->sc_macaddr,ETHER_ADDR_LEN)){
- m_freem(m);
- continue;
- }
-#endif
-
- /* Second mbuf holds packet ifself */
- m->m_pkthdr.len = m->m_len = len - sizeof(struct ether_header);
- m->m_data += sizeof( struct ether_header );
-
- /* Give mbuf to OS */
- ether_input(&sc->sc_if, eh, m);
-
- /* Successfuly received frame */
- sc->sc_if.if_ipackets++;
- }
-
- return;
-}
-
-/*
- * Synopsis: Do last phase of transmission. I.e. if desc is
- * transmitted, decrease pending_txs counter, free mbuf contained
- * packet, switch to next descriptor and repeat until no packets
- * are pending or descriptor is not transmitted yet.
- */
-static __inline void
-epic_tx_done __P((
- register epic_softc_t *sc ))
-{
- struct epic_tx_buffer *buf;
- struct epic_tx_desc *desc;
- u_int16_t status;
-
- while( sc->pending_txs > 0 ){
- buf = sc->tx_buffer + sc->dirty_tx;
- desc = sc->tx_desc + sc->dirty_tx;
- status = desc->status;
-
- /* If packet is not transmitted, thou followed */
- /* packets are not transmitted too */
- if( status & 0x8000 ) break;
-
- /* Packet is transmitted. Switch to next and */
- /* free mbuf */
- sc->pending_txs--;
- sc->dirty_tx = (sc->dirty_tx + 1) & TX_RING_MASK;
- m_freem( buf->mbuf );
- buf->mbuf = NULL;
-
- /* Check for errors and collisions */
- if( status & 0x0001 ) sc->sc_if.if_opackets++;
- else sc->sc_if.if_oerrors++;
- sc->sc_if.if_collisions += (status >> 8) & 0x1F;
-#if defined(EPIC_DEBUG)
- if( (status & 0x1001) == 0x1001 )
- dprintf((EPIC_FORMAT ": frame not transmitted due collisions\n",EPIC_ARGS(sc)));
-#endif
- }
-
- if( sc->pending_txs < TX_RING_SIZE )
- sc->sc_if.if_flags &= ~IFF_OACTIVE;
-}
-
-/*
- * Interrupt function
- *
- * splimp() assumed to be done
- */
-static EPIC_INTR_RET_TYPE
-epic_intr (
- void *arg)
-{
- epic_softc_t * sc = (epic_softc_t *) arg;
- int status,i=4;
-#if defined(__OpenBSD__)
- int claimed = 0;
-#endif
-
-
- while( i-- && ((status = CSR_READ_4(sc, INTSTAT)) & INTSTAT_INT_ACTV) ){
-#if defined(__OpenBSD__)
- claimed = 1;
-#endif
- CSR_WRITE_4( sc, INTSTAT, status );
-
- if( status & (INTSTAT_RQE|INTSTAT_RCC|INTSTAT_OVW) ) {
- epic_rx_done( sc );
- if( status & (INTSTAT_RQE|INTSTAT_OVW) ){
-#if defined(EPIC_DEBUG)
- if( status & INTSTAT_OVW )
- printf(EPIC_FORMAT ": RX buffer overflow\n",EPIC_ARGS(sc));
- if( status & INTSTAT_RQE )
- printf(EPIC_FORMAT ": RX FIFO overflow\n",EPIC_ARGS(sc));
- if( sc->sc_if.if_flags & IFF_DEBUG )
- epic_dump_state(sc);
-#endif
- if( !(CSR_READ_4( sc, COMMAND ) & COMMAND_RXQUEUED) )
- CSR_WRITE_4( sc, COMMAND, COMMAND_RXQUEUED );
- sc->sc_if.if_ierrors++;
- }
- }
-
- if( status & (INTSTAT_TXC|INTSTAT_TCC|INTSTAT_TQE) ) {
- epic_tx_done( sc );
- if(!(sc->sc_if.if_flags & IFF_OACTIVE) &&
- sc->sc_if.if_snd.ifq_head )
- epic_ifstart( &sc->sc_if );
- }
-
- if( (status & INTSTAT_GP2) && (QS6612_OUI == sc->phyid) ) {
- u_int32_t phystatus = PHY_READ_2( sc, QS6612_INTSTAT );
-
- if( phystatus & INTSTAT_AN_COMPLETE ) {
- u_int32_t bmcr;
- if( epic_autoneg(sc) == EPIC_FULL_DUPLEX ) {
- dprintf((EPIC_FORMAT ": going fullduplex\n",EPIC_ARGS(sc)));
- bmcr = BMCR_FULL_DUPLEX | PHY_READ_2( sc, DP83840_BMCR );
- sc->txcon |= TXCON_FULL_DUPLEX;
- } else {
- /* Default to half-duplex */
- dprintf((EPIC_FORMAT ": going halfduplex\n",EPIC_ARGS(sc)));
- bmcr = ~BMCR_FULL_DUPLEX & PHY_READ_2( sc, DP83840_BMCR );
- sc->txcon &= ~TXCON_FULL_DUPLEX;
- }
-
- /* There is apparently QS6612 chip bug: */
- /* BMCR_FULL_DUPLEX flag is not updated by */
- /* autonegotiation process, so update it by hands */
- /* so we can rely on it in epic_ifmedia_status() */
- PHY_WRITE_2( sc, DP83840_BMCR, bmcr );
-
- epic_stop_activity(sc);
- epic_set_tx_mode(sc);
- epic_start_activity(sc);
- }
-
- PHY_READ_2(sc, DP83840_BMSR);
- if( !(PHY_READ_2(sc, DP83840_BMSR) & BMSR_LINK_STATUS) ) {
- dprintf((EPIC_FORMAT ": WARNING! link down\n",EPIC_ARGS(sc)));
- sc->flags |= EPIC_LINK_DOWN;
- } else {
- dprintf((EPIC_FORMAT ": link up\n",EPIC_ARGS(sc)));
- sc->flags &= ~EPIC_LINK_DOWN;
- }
-
- /* We should clear GP2 int again after we clear it on PHY */
- CSR_WRITE_4( sc, INTSTAT, INTSTAT_GP2 );
- }
-
- /* Check for errors */
- if( status & (INTSTAT_FATAL|INTSTAT_PMA|INTSTAT_PTA|
- INTSTAT_APE|INTSTAT_DPE|INTSTAT_TXU|INTSTAT_RXE) ){
- if( status & (INTSTAT_FATAL|INTSTAT_PMA|INTSTAT_PTA|
- INTSTAT_APE|INTSTAT_DPE) ){
- printf(EPIC_FORMAT ": PCI fatal error occured (%s%s%s%s)\n",
- EPIC_ARGS(sc),
- (status&INTSTAT_PMA)?"PMA":"",
- (status&INTSTAT_PTA)?" PTA":"",
- (status&INTSTAT_APE)?" APE":"",
- (status&INTSTAT_DPE)?" DPE":""
- );
-
- epic_dump_state(sc);
-
- epic_stop(sc);
- epic_init(sc);
-
- break;
- }
-
- if (status & INTSTAT_RXE) {
- dprintf((EPIC_FORMAT ": CRC/Alignment error\n",EPIC_ARGS(sc)));
- sc->sc_if.if_ierrors++;
- }
-
- /* Tx FIFO underflow. Increase tx threshold, */
- /* if it grown above 2048, disable EARLY_TX */
- if (status & INTSTAT_TXU) {
- if( sc->tx_threshold > 0x800 ) {
- sc->txcon &= ~TXCON_EARLY_TRANSMIT_ENABLE;
- dprintf((EPIC_FORMAT ": TX underrun error, early tx disabled\n",EPIC_ARGS(sc)));
- } else {
- sc->tx_threshold += 0x40;
- dprintf((EPIC_FORMAT ": TX underrun error, tx threshold increased to %d\n",EPIC_ARGS(sc),sc->tx_threshold));
- }
-
- CSR_WRITE_4(sc, COMMAND, COMMAND_TXUGO | COMMAND_TXQUEUED);
- epic_stop_activity(sc);
- epic_set_tx_mode(sc);
- epic_start_activity(sc);
- sc->sc_if.if_oerrors++;
- }
- }
- }
-
- /* If no packets are pending, thus no timeouts */
- if( sc->pending_txs == 0 ) sc->sc_if.if_timer = 0;
-
-#if defined(__OpenBSD__)
- return claimed;
-#endif
-}
-
-/*
- * Synopsis: This one is called if packets wasn't transmitted
- * during timeout. Try to deallocate transmitted packets, and
- * if success continue to work.
- *
- * splimp() invoked here
- */
-static void
-epic_ifwatchdog __P((
- struct ifnet *ifp))
-{
- epic_softc_t *sc = ifp->if_softc;
- int x;
-
- x = splimp();
-
- printf(EPIC_FORMAT ": device timeout %d packets, ",
- EPIC_ARGS(sc),sc->pending_txs);
-
- /* Try to finish queued packets */
- epic_tx_done( sc );
-
- /* If not successful */
- if( sc->pending_txs > 0 ){
-#if defined(EPIC_DEBUG)
- if( ifp->if_flags & IFF_DEBUG ) epic_dump_state(sc);
-#endif
- ifp->if_oerrors+=sc->pending_txs;
-
- /* Reinitialize board */
- printf("reinitialization\n");
- epic_stop(sc);
- epic_init(sc);
-
- } else
- printf("seems we can continue normaly\n");
-
- /* Start output */
- if( ifp->if_snd.ifq_head ) epic_ifstart( ifp );
-
- splx(x);
-}
-
-#if defined(SIOCSIFMEDIA) && !defined(EPIC_NOIFMEDIA)
-static int
-epic_ifmedia_change __P((
- struct ifnet * ifp))
-{
- epic_softc_t *sc = (epic_softc_t *)(ifp->if_softc);
-
- if (IFM_TYPE(sc->ifmedia.ifm_media) != IFM_ETHER)
- return (EINVAL);
-
- if (!(ifp->if_flags & IFF_UP))
- return (0);
-
- epic_stop_activity(sc);
- epic_set_media_speed(sc);
- epic_start_activity(sc);
-
- return 0;
-}
-
-static void
-epic_ifmedia_status __P((
- struct ifnet * ifp,
- struct ifmediareq *ifmr))
-{
- epic_softc_t *sc = ifp->if_softc;
- u_int32_t bmcr;
- u_int32_t bmsr;
-
- if (!(ifp->if_flags & IFF_UP))
- return;
-
- bmcr = PHY_READ_2( sc, DP83840_BMCR );
-
- PHY_READ_2( sc, DP83840_BMSR );
- bmsr = PHY_READ_2( sc, DP83840_BMSR );
-
- ifmr->ifm_active = IFM_ETHER;
- ifmr->ifm_status = IFM_AVALID;
-
- if( !(bmsr & BMSR_LINK_STATUS) ) {
- ifmr->ifm_active |=
- (bmcr&BMCR_AUTONEGOTIATION)?IFM_AUTO:IFM_NONE;
- return;
- }
-
- ifmr->ifm_status |= IFM_ACTIVE;
- ifmr->ifm_active |= (bmcr & BMCR_100MBPS) ? IFM_100_TX : IFM_10_T;
- ifmr->ifm_active |= (bmcr & BMCR_FULL_DUPLEX) ? IFM_FDX : 0;
- if ((sc->txcon & TXCON_LOOPBACK_MODE) == TXCON_LOOPBACK_MODE_INT)
- ifmr->ifm_active |= (IFM_LOOP | IFM_FLAG1);
- else if ((sc->txcon & TXCON_LOOPBACK_MODE) == TXCON_LOOPBACK_MODE_PHY)
- ifmr->ifm_active |= IFM_LOOP;
-
-}
-#endif
-
-/*
- * Reset chip, PHY, allocate rings
- *
- * splimp() invoked here
- */
-static int
-epic_init __P((
- epic_softc_t * sc))
-{
- struct ifnet *ifp = &sc->sc_if;
- int s,i;
-
- s = splimp();
-
- /* Soft reset the chip (we have to power up card before) */
- CSR_WRITE_4( sc, GENCTL, 0 );
- CSR_WRITE_4( sc, GENCTL, GENCTL_SOFT_RESET );
-
- /*
- * Reset takes 15 pci ticks which depends on PCI bus speed.
- * Assuming it >= 33000000 hz, we have wait at least 495e-6 sec.
- */
- DELAY(500);
-
- /* Wake up */
- CSR_WRITE_4( sc, GENCTL, 0 );
-
- /* Workaround for Application Note 7-15 */
- for (i=0; i<16; i++) CSR_WRITE_4(sc, TEST1, TEST1_CLOCK_TEST);
-
- /* Initialize rings */
- if( epic_init_rings( sc ) ) {
- printf(EPIC_FORMAT ": failed to init rings\n",EPIC_ARGS(sc));
- splx(s);
- return -1;
- }
-
- /* Give rings to EPIC */
- CSR_WRITE_4( sc, PRCDAR, vtophys( sc->rx_desc ) );
- CSR_WRITE_4( sc, PTCDAR, vtophys( sc->tx_desc ) );
-
- /* Put node address to EPIC */
- CSR_WRITE_4( sc, LAN0, ((u_int16_t *)sc->sc_macaddr)[0] );
- CSR_WRITE_4( sc, LAN1, ((u_int16_t *)sc->sc_macaddr)[1] );
- CSR_WRITE_4( sc, LAN2, ((u_int16_t *)sc->sc_macaddr)[2] );
-
- /* Set tx mode, includeing transmit threshold */
- epic_set_tx_mode(sc);
-
- /* Compute and set RXCON. */
- epic_set_rx_mode( sc );
-
- /* Set multicast table */
- epic_set_mc_table( sc );
-
- /* Enable interrupts by setting the interrupt mask. */
- CSR_WRITE_4( sc, INTMASK,
- INTSTAT_RCC | INTSTAT_RQE | INTSTAT_OVW | INTSTAT_RXE |
- INTSTAT_TXC | INTSTAT_TCC | INTSTAT_TQE | INTSTAT_TXU |
- INTSTAT_FATAL |
- ((QS6612_OUI == sc->phyid)?INTSTAT_GP2:0) );
-
- /* Enable interrupts, set for PCI read multiple and etc */
- CSR_WRITE_4( sc, GENCTL,
- GENCTL_ENABLE_INTERRUPT | GENCTL_MEMORY_READ_MULTIPLE |
- GENCTL_ONECOPY | GENCTL_RECEIVE_FIFO_THRESHOLD64 );
-
- /* Set media speed mode */
- epic_set_media_speed( sc );
-
- /* Mark interface running ... */
- if( ifp->if_flags & IFF_UP ) ifp->if_flags |= IFF_RUNNING;
- else ifp->if_flags &= ~IFF_RUNNING;
-
- /* ... and free */
- ifp->if_flags &= ~IFF_OACTIVE;
-
- /* Start Rx process */
- epic_start_activity(sc);
-
- splx(s);
- return 0;
-}
-
-/*
- * Synopsis: calculate and set Rx mode. Chip must be in idle state to
- * access RXCON.
- */
-static void
-epic_set_rx_mode(
- epic_softc_t * sc)
-{
- u_int32_t flags = sc->sc_if.if_flags;
- u_int32_t rxcon = RXCON_DEFAULT | RXCON_RECEIVE_MULTICAST_FRAMES | RXCON_RECEIVE_BROADCAST_FRAMES;
-
- rxcon |= (flags & IFF_PROMISC)?RXCON_PROMISCUOUS_MODE:0;
-
- CSR_WRITE_4( sc, RXCON, rxcon );
-
- return;
-}
-
-#if 0
-void
-dump_phy_regs(epic_softc_t *sc)
-{
-
- printf("BMCR: 0x%04x\n", PHY_READ_2(sc, DP83840_BMCR));
- printf("BMSR: 0x%04x\n", PHY_READ_2(sc, DP83840_BMSR));
- printf("ANAR: 0x%04x\n", PHY_READ_2(sc, DP83840_ANAR));
- printf("LPAR: 0x%04x\n", PHY_READ_2(sc, DP83840_LPAR));
- printf("ANER: 0x%04x\n", PHY_READ_2(sc, DP83840_ANER));
- printf("MCTL: 0x%04x\n", PHY_READ_2(sc, QS6612_MCTL));
- printf("INTSTAT: 0x%04x\n", PHY_READ_2(sc, QS6612_INTSTAT));
- printf("INTMASK: 0x%04x\n", PHY_READ_2(sc, QS6612_INTMASK));
- printf("BPCR: 0x%04x\n", PHY_READ_2(sc, QS6612_BPCR));
-}
-#endif
-
-/*
- * Synopsis: Reset PHY and do PHY-special initialization:
- */
-static void
-epic_init_phy __P((
- epic_softc_t * sc))
-{
- u_int32_t i;
-
- /* Reset PHY (We have to take the delay from manual XXX) */
- PHY_WRITE_2(sc, DP83840_BMCR, BMCR_RESET);
- DELAY(10);
- for(i=0;i<0x1000;i++) {
- if( !(PHY_READ_2(sc, DP83840_BMCR) & BMCR_RESET) )
- break;
- DELAY(1);
- }
-
- if( PHY_READ_2(sc, DP83840_BMCR) & BMCR_RESET )
- printf(EPIC_FORMAT ": WARNING! cant reset PHY\n",EPIC_ARGS(sc));
-
- PHY_WRITE_2(sc, DP83840_BMCR, 0 );
- PHY_WRITE_2(sc, DP83840_BMCR, BMCR_LOOPBACK | BMCR_ISOLATE );
-
- switch( sc->phyid ){
- case QS6612_OUI: {
- /* Init QS6612 and EPIC to generate interrupt */
- CSR_WRITE_4(sc, NVCTL, NVCTL_GP1_OUTPUT_ENABLE | NVCTL_GP1);
-
- /* Mask interrupts sources */
- PHY_WRITE_2(sc, QS6612_INTMASK,
- PHY_READ_2(sc, QS6612_INTSTAT) |
- INTMASK_THUNDERLAN | INTSTAT_AN_COMPLETE |
- INTSTAT_LINK_STATUS );
-
- /* Enable QS6612 extended cable length capabilites */
- /* PHY_WRITE_2(sc, QS6612_MCTL, */
- /* PHY_READ_2(sc, QS6612_MCTL) | MCTL_BTEXT); */
-
- break;
- }
- default:
- break;
- }
-}
-
-/*
- * Synopsis: Set PHY to media type specified by IFF_LINK* flags or
- * ifmedia structure. Chip must be in idle state to access TXCON.
- */
-static void
-epic_set_media_speed __P((
- epic_softc_t * sc))
-{
- u_int16_t media;
-#if !defined(EPIC_NOIFMEDIA)
- u_int32_t tgtmedia = sc->ifmedia.ifm_cur->ifm_media;
-#endif
-
- epic_init_phy(sc);
-
-#if !defined(EPIC_NOIFMEDIA)
- if( IFM_SUBTYPE(tgtmedia) != IFM_AUTO ){
- /* Clean previous values */
- sc->txcon &= ~(TXCON_LOOPBACK_MODE | TXCON_FULL_DUPLEX);
- media = 0;
-
- /* Set mode */
- media |= (IFM_SUBTYPE(tgtmedia)==IFM_100_TX) ? BMCR_100MBPS : 0;
- if (tgtmedia & IFM_FDX) {
- media |= BMCR_FULL_DUPLEX;
- sc->txcon |= TXCON_FULL_DUPLEX;
- }
- if (tgtmedia & IFM_LOOP) {
- if (tgtmedia & IFM_FLAG1)
- sc->txcon |= TXCON_LOOPBACK_MODE_INT;
- else {
- media |= BMCR_LOOPBACK | BMCR_ISOLATE;
- sc->txcon |= TXCON_LOOPBACK_MODE_PHY;
- }
- }
-
- sc->sc_if.if_baudrate =
- (IFM_SUBTYPE(tgtmedia)==IFM_100_TX)?100000000:10000000;
-
- PHY_WRITE_2( sc, DP83840_BMCR, media );
- }
-#else /* EPIC_NOIFMEDIA */
- struct ifnet *ifp = &sc->sc_if;
-
- if( ifp->if_flags & IFF_LINK0 ) {
- /* Set mode */
- media = 0;
- media|= (ifp->if_flags & IFF_LINK2) ? BMCR_100MBPS : 0;
- media|= (ifp->if_flags & IFF_LINK1) ? BMCR_FULL_DUPLEX : 0;
-
- sc->sc_if.if_baudrate =
- (ifp->if_flags & IFF_LINK2)?100000000:10000000;
-
- PHY_WRITE_2( sc, DP83840_BMCR, media );
-
- if( ifp->if_flags & IFF_LINK2 ) sc->txcon |= TXCON_FULL_DUPLEX;
- else sc->txcon &= ~TXCON_FULL_DUPLEX;
-
- CSR_WRITE_4( sc, TXCON, sc->txcon );
- }
-#endif /* !EPIC_NOIFMEDIA */
- else {
- sc->sc_if.if_baudrate = 100000000;
-
- sc->txcon &= ~TXCON_FULL_DUPLEX;
- CSR_WRITE_4(sc, TXCON, sc->txcon);
-
- /* Set and restart autoneg */
- PHY_WRITE_2(sc, DP83840_BMCR, BMCR_AUTONEGOTIATION );
- PHY_WRITE_2(sc, DP83840_BMCR,
- BMCR_AUTONEGOTIATION | BMCR_RESTART_AUTONEG);
-
- /* If it is not QS6612 PHY, try to get result of autoneg. */
- if( QS6612_OUI != sc->phyid ) {
- /* Wait 3 seconds for the autoneg to finish
- * This is the recommended time from the DP83840A data
- * sheet Section 7.1
- */
- DELAY(3000000);
-
- if( epic_autoneg(sc) == EPIC_FULL_DUPLEX ) {
- sc->txcon |= TXCON_FULL_DUPLEX;
- CSR_WRITE_4(sc, TXCON, sc->txcon);
- }
- }
- /* Else it will be done when GP2 int occured */
- }
-
- epic_set_tx_mode(sc);
-
- return;
-}
-
-/*
- * This functions get results of the autoneg processes of the phy
- * It implements the workaround that is described in section 7.2 & 7.3 of the
- * DP83840A data sheet
- * http://www.national.com/ds/DP/DP83840A.pdf
- */
-static int
-epic_autoneg(
- epic_softc_t * sc)
-{
- u_int16_t media;
- u_int16_t i;
-
- /* BMSR must be read twice to update the link status bit
- * since that bit is a latch bit
- */
- PHY_READ_2( sc, DP83840_BMSR);
- i = PHY_READ_2( sc, DP83840_BMSR);
-
- if ((i & BMSR_LINK_STATUS) && (i & BMSR_AUTONEG_COMPLETE)){
- i = PHY_READ_2( sc, DP83840_LPAR );
-
- if ( i & (ANAR_100_TX_FD|ANAR_10_FD) )
- return EPIC_FULL_DUPLEX;
- else
- return EPIC_HALF_DUPLEX;
- } else {
- /*Auto-negotiation or link status is not 1
- Thus the auto-negotiation failed and one
- must take other means to fix it.
- */
-
- /* ANER must be read twice to get the correct reading for the
- * Multiple link fault bit -- it is a latched bit
- */
- PHY_READ_2( sc, DP83840_ANER );
- i = PHY_READ_2( sc, DP83840_ANER );
-
- if ( i & ANER_MULTIPLE_LINK_FAULT ) {
- /* it can be forced to 100Mb/s Half-Duplex */
- media = PHY_READ_2( sc, DP83840_BMCR );
- media &= ~(BMCR_AUTONEGOTIATION | BMCR_FULL_DUPLEX);
- media |= BMCR_100MBPS;
- PHY_WRITE_2( sc, DP83840_BMCR, media );
-
- /* read BMSR again to determine link status */
- PHY_READ_2( sc, DP83840_BMSR );
- i=PHY_READ_2( sc, DP83840_BMSR );
-
- if (i & BMSR_LINK_STATUS){
- /* port is linked to the non Auto-Negotiation
- * 100Mbs partner.
- */
- return EPIC_HALF_DUPLEX;
- }
- else {
- media = PHY_READ_2( sc, DP83840_BMCR);
- media &= ~(BMCR_AUTONEGOTIATION | BMCR_FULL_DUPLEX | BMCR_100MBPS);
- PHY_WRITE_2( sc, DP83840_BMCR, media);
- PHY_READ_2( sc, DP83840_BMSR );
- i = PHY_READ_2( sc, DP83840_BMSR );
-
- if (i & BMSR_LINK_STATUS) {
- /*port is linked to the non
- * Auto-Negotiation10Mbs partner
- */
- return EPIC_HALF_DUPLEX;
- }
- }
- }
- /* If we get here we are most likely not connected
- * so lets default it to half duplex
- */
- return EPIC_HALF_DUPLEX;
- }
-
-}
-
-/*
- */
-static void
-epic_set_tx_mode (
- epic_softc_t *sc )
-{
-
- if( sc->txcon & TXCON_EARLY_TRANSMIT_ENABLE )
- CSR_WRITE_4( sc, ETXTHR, sc->tx_threshold );
-
- CSR_WRITE_4( sc, TXCON, sc->txcon );
-}
-
-/*
- * Synopsis: This function should update multicast hash table.
- * I suppose there is a bug in chips MC filter so this function
- * only set it to receive all MC packets. The second problem is
- * that we should wait for TX and RX processes to stop before
- * reprogramming MC filter. The epic_stop_activity() and
- * epic_start_activity() should help to do this.
- */
-static void
-epic_set_mc_table (
- epic_softc_t * sc)
-{
- struct ifnet *ifp = &sc->sc_if;
-
- if( ifp->if_flags & IFF_MULTICAST ){
- CSR_WRITE_4( sc, MC0, 0xFFFF );
- CSR_WRITE_4( sc, MC1, 0xFFFF );
- CSR_WRITE_4( sc, MC2, 0xFFFF );
- CSR_WRITE_4( sc, MC3, 0xFFFF );
- }
-
- return;
-}
-
-
-/*
- * Synopsis: Start receive process and transmit one, if they need.
- */
-static void
-epic_start_activity __P((
- epic_softc_t * sc))
-{
- /* Start rx process */
- CSR_WRITE_4(sc, COMMAND,
- COMMAND_RXQUEUED | COMMAND_START_RX |
- (sc->pending_txs?COMMAND_TXQUEUED:0));
- dprintf((EPIC_FORMAT ": activity started\n",EPIC_ARGS(sc)));
-}
-
-/*
- * Synopsis: Completely stop Rx and Tx processes. If TQE is set additional
- * packet needs to be queued to stop Tx DMA.
- */
-static void
-epic_stop_activity __P((
- epic_softc_t * sc))
-{
- int i;
-
- /* Stop Tx and Rx DMA */
- CSR_WRITE_4(sc,COMMAND,COMMAND_STOP_RX|COMMAND_STOP_RDMA|COMMAND_STOP_TDMA);
-
- /* Wait Rx and Tx DMA to stop (why 1 ms ??? XXX) */
- dprintf((EPIC_FORMAT ": waiting Rx and Tx DMA to stop\n",EPIC_ARGS(sc)));
- for(i=0;i<0x1000;i++) {
- if((CSR_READ_4(sc,INTSTAT) & (INTSTAT_TXIDLE | INTSTAT_RXIDLE)) ==
- (INTSTAT_TXIDLE | INTSTAT_RXIDLE) )
- break;
- DELAY(1);
- }
-
- if( !(CSR_READ_4(sc,INTSTAT)&INTSTAT_RXIDLE) )
- printf(EPIC_FORMAT ": can't stop Rx DMA\n",EPIC_ARGS(sc));
-
- if( !(CSR_READ_4(sc,INTSTAT)&INTSTAT_TXIDLE) )
- printf(EPIC_FORMAT ": can't stop Tx DMA\n",EPIC_ARGS(sc));
-
- /* Catch all finished packets */
- epic_rx_done(sc);
- epic_tx_done(sc);
-
- /*
- * May need to queue one more packet if TQE, this is rare but existing
- * case.
- */
- if( (CSR_READ_4( sc, INTSTAT ) & INTSTAT_TQE) &&
- !(CSR_READ_4( sc, INTSTAT ) & INTSTAT_TXIDLE) ) {
- struct epic_tx_desc *desc;
- struct epic_frag_list *flist;
- struct epic_tx_buffer *buf;
- struct mbuf *m0;
-
- dprintf((EPIC_FORMAT ": queue last packet\n",EPIC_ARGS(sc)));
-
- desc = sc->tx_desc + sc->cur_tx;
- flist = sc->tx_flist + sc->cur_tx;
- buf = sc->tx_buffer + sc->cur_tx;
-
- if ((desc->status & 0x8000) || (buf->mbuf != NULL))
- return;
-
- MGETHDR(m0,M_DONTWAIT,MT_DATA);
- if (NULL == m0)
- return;
-
- /* Prepare mbuf */
- m0->m_len = min(MHLEN,ETHER_MIN_LEN-ETHER_CRC_LEN);
- flist->frag[0].fraglen = m0->m_len;
- m0->m_pkthdr.len = m0->m_len;
- m0->m_pkthdr.rcvif = &sc->sc_if;
- bzero(mtod(m0,caddr_t),m0->m_len);
-
- /* Fill fragments list */
- flist->frag[0].fraglen = m0->m_len;
- flist->frag[0].fragaddr = vtophys( mtod(m0, caddr_t) );
- flist->numfrags = 1;
-
- /* Fill in descriptor */
- buf->mbuf = m0;
- sc->pending_txs++;
- sc->cur_tx = (sc->cur_tx + 1) & TX_RING_MASK;
- desc->control = 0x01;
- desc->txlength = max(m0->m_pkthdr.len,ETHER_MIN_LEN-ETHER_CRC_LEN);
- desc->status = 0x8000;
-
- /* Launch transmition */
- CSR_WRITE_4(sc, COMMAND, COMMAND_STOP_TDMA | COMMAND_TXQUEUED);
-
- /* Wait Tx DMA to stop (for how long??? XXX) */
- dprintf((EPIC_FORMAT ": waiting Tx DMA to stop\n",EPIC_ARGS(sc)));
- for(i=0;i<1000;i++) {
- if( (CSR_READ_4(sc,INTSTAT)&INTSTAT_TXIDLE) == INTSTAT_TXIDLE )
- break;
- DELAY(1);
- }
-
- if( !(CSR_READ_4(sc,INTSTAT)&INTSTAT_TXIDLE) )
- printf(EPIC_FORMAT ": can't stop TX DMA\n",EPIC_ARGS(sc));
- else
- epic_tx_done(sc);
- }
-
- dprintf((EPIC_FORMAT ": activity stoped\n",EPIC_ARGS(sc)));
-}
-
-/*
- * Synopsis: Shut down board and deallocates rings.
- *
- * splimp() invoked here
- */
-static void
-epic_stop __P((
- epic_softc_t * sc))
-{
- int s;
-
- s = splimp();
-
- sc->sc_if.if_timer = 0;
-
- /* Disable interrupts */
- CSR_WRITE_4( sc, INTMASK, 0 );
- CSR_WRITE_4( sc, GENCTL, 0 );
-
- /* Try to stop Rx and TX processes */
- epic_stop_activity(sc);
-
- /* Reset chip */
- CSR_WRITE_4( sc, GENCTL, GENCTL_SOFT_RESET );
- DELAY(1000);
-
- /* Make chip go to bed */
- CSR_WRITE_4(sc, GENCTL, GENCTL_POWER_DOWN);
-
- /* Free memory allocated for rings */
- epic_free_rings(sc);
-
- /* Mark as stoped */
- sc->sc_if.if_flags &= ~IFF_RUNNING;
-
- splx(s);
- return;
-}
-
-/*
- * Synopsis: This function should free all memory allocated for rings.
- */
-static void
-epic_free_rings __P((
- epic_softc_t * sc))
-{
- int i;
-
- for(i=0;i<RX_RING_SIZE;i++){
- struct epic_rx_buffer *buf = sc->rx_buffer + i;
- struct epic_rx_desc *desc = sc->rx_desc + i;
-
- desc->status = 0;
- desc->buflength = 0;
- desc->bufaddr = 0;
-
- if( buf->mbuf ) m_freem( buf->mbuf );
- buf->mbuf = NULL;
- }
-
- for(i=0;i<TX_RING_SIZE;i++){
- struct epic_tx_buffer *buf = sc->tx_buffer + i;
- struct epic_tx_desc *desc = sc->tx_desc + i;
-
- desc->status = 0;
- desc->buflength = 0;
- desc->bufaddr = 0;
-
- if( buf->mbuf ) m_freem( buf->mbuf );
- buf->mbuf = NULL;
- }
-}
-
-/*
- * Synopsis: Allocates mbufs for Rx ring and point Rx descs to them.
- * Point Tx descs to fragment lists. Check that all descs and fraglists
- * are bounded and aligned properly.
- */
-static int
-epic_init_rings(epic_softc_t * sc){
- int i;
-
- sc->cur_rx = sc->cur_tx = sc->dirty_tx = sc->pending_txs = 0;
-
- for (i = 0; i < RX_RING_SIZE; i++) {
- struct epic_rx_buffer *buf = sc->rx_buffer + i;
- struct epic_rx_desc *desc = sc->rx_desc + i;
-
- desc->status = 0; /* Owned by driver */
- desc->next = vtophys( sc->rx_desc + ((i+1) & RX_RING_MASK) );
-
- if( (desc->next & 3) || ((desc->next & 0xFFF) + sizeof(struct epic_rx_desc) > 0x1000 ) )
- printf(EPIC_FORMAT ": WARNING! rx_desc is misbound or misaligned\n",EPIC_ARGS(sc));
-
- EPIC_MGETCLUSTER( buf->mbuf );
- if( NULL == buf->mbuf ) {
- epic_free_rings(sc);
- return -1;
- }
- desc->bufaddr = vtophys( mtod(buf->mbuf,caddr_t) );
-
- desc->buflength = ETHER_MAX_FRAME_LEN;
- desc->status = 0x8000; /* Give to EPIC */
-
- }
-
- for (i = 0; i < TX_RING_SIZE; i++) {
- struct epic_tx_buffer *buf = sc->tx_buffer + i;
- struct epic_tx_desc *desc = sc->tx_desc + i;
-
- desc->status = 0;
- desc->next = vtophys( sc->tx_desc + ( (i+1) & TX_RING_MASK ) );
-
- if( (desc->next & 3) || ((desc->next & 0xFFF) + sizeof(struct epic_tx_desc) > 0x1000 ) )
- printf(EPIC_FORMAT ": WARNING! tx_desc is misbound or misaligned\n",EPIC_ARGS(sc));
-
- buf->mbuf = NULL;
- desc->bufaddr = vtophys( sc->tx_flist + i );
- if( (desc->bufaddr & 3) || ((desc->bufaddr & 0xFFF) + sizeof(struct epic_frag_list) > 0x1000 ) )
- printf(EPIC_FORMAT ": WARNING! frag_list is misbound or misaligned\n",EPIC_ARGS(sc));
- }
-
- return 0;
-}
-
-/*
- * EEPROM operation functions
- */
-static void epic_write_eepromreg __P((
- epic_softc_t *sc,
- u_int8_t val))
-{
- u_int16_t i;
-
- CSR_WRITE_1( sc, EECTL, val );
-
- for (i=0; i<0xFF; i++)
- if( !(CSR_READ_1( sc, EECTL ) & 0x20) ) break;
-
- return;
-}
-
-static u_int8_t
-epic_read_eepromreg __P((
- epic_softc_t *sc))
-{
- return CSR_READ_1( sc,EECTL );
-}
-
-static u_int8_t
-epic_eeprom_clock __P((
- epic_softc_t *sc,
- u_int8_t val))
-{
- epic_write_eepromreg( sc, val );
- epic_write_eepromreg( sc, (val | 0x4) );
- epic_write_eepromreg( sc, val );
-
- return epic_read_eepromreg( sc );
-}
-
-static void
-epic_output_eepromw __P((
- epic_softc_t * sc,
- u_int16_t val))
-{
- int i;
- for( i = 0xF; i >= 0; i--){
- if( (val & (1 << i)) ) epic_eeprom_clock( sc, 0x0B );
- else epic_eeprom_clock( sc, 3);
- }
-}
-
-static u_int16_t
-epic_input_eepromw __P((
- epic_softc_t *sc))
-{
- int i;
- int tmp;
- u_int16_t retval = 0;
-
- for( i = 0xF; i >= 0; i--) {
- tmp = epic_eeprom_clock( sc, 0x3 );
- if( tmp & 0x10 ){
- retval |= (1 << i);
- }
- }
- return retval;
-}
-
-static int
-epic_read_eeprom __P((
- epic_softc_t *sc,
- u_int16_t loc))
-{
- u_int16_t dataval;
- u_int16_t read_cmd;
-
- epic_write_eepromreg( sc , 3);
-
- if( epic_read_eepromreg( sc ) & 0x40 )
- read_cmd = ( loc & 0x3F ) | 0x180;
- else
- read_cmd = ( loc & 0xFF ) | 0x600;
-
- epic_output_eepromw( sc, read_cmd );
-
- dataval = epic_input_eepromw( sc );
-
- epic_write_eepromreg( sc, 1 );
-
- return dataval;
-}
-
-static u_int16_t
-epic_read_phy_register __P((
- epic_softc_t *sc,
- u_int16_t loc))
-{
- int i;
-
- CSR_WRITE_4( sc, MIICTL, ((loc << 4) | 0x0601) );
-
- for (i=0;i<0x100;i++) {
- if( !(CSR_READ_4( sc, MIICTL )&1) ) break;
- DELAY(1);
- }
-
- return CSR_READ_4( sc, MIIDATA );
-}
-
-static void
-epic_write_phy_register __P((
- epic_softc_t * sc,
- u_int16_t loc,
- u_int16_t val))
-{
- int i;
-
- CSR_WRITE_4( sc, MIIDATA, val );
- CSR_WRITE_4( sc, MIICTL, ((loc << 4) | 0x0602) );
-
- for( i=0;i<0x100;i++) {
- if( !(CSR_READ_4( sc, MIICTL )&2) ) break;
- DELAY(1);
- }
-
- return;
-}
-
-static void
-epic_dump_state __P((
- epic_softc_t * sc))
-{
- int j;
- struct epic_tx_desc *tdesc;
- struct epic_rx_desc *rdesc;
- printf(EPIC_FORMAT ": cur_rx: %d, pending_txs: %d, dirty_tx: %d, cur_tx: %d\n", EPIC_ARGS(sc),sc->cur_rx,sc->pending_txs,sc->dirty_tx,sc->cur_tx);
- printf(EPIC_FORMAT ": COMMAND: 0x%08x, INTSTAT: 0x%08x\n",EPIC_ARGS(sc),CSR_READ_4(sc,COMMAND),CSR_READ_4(sc,INTSTAT));
- printf(EPIC_FORMAT ": PRCDAR: 0x%08x, PTCDAR: 0x%08x\n",EPIC_ARGS(sc),CSR_READ_4(sc,PRCDAR),CSR_READ_4(sc,PTCDAR));
- printf(EPIC_FORMAT ": dumping rx descriptors\n",EPIC_ARGS(sc));
- for(j=0;j<RX_RING_SIZE;j++){
- rdesc = sc->rx_desc + j;
- printf("desc%d: %4d 0x%04x, 0x%08x, %4d, 0x%08x\n",
- j,
- rdesc->rxlength,rdesc->status,
- rdesc->bufaddr,
- rdesc->buflength,
- rdesc->next
- );
- }
- printf(EPIC_FORMAT ": dumping tx descriptors\n",EPIC_ARGS(sc));
- for(j=0;j<TX_RING_SIZE;j++){
- tdesc = sc->tx_desc + j;
- printf(
- "desc%d: %4d 0x%04x, 0x%08lx, 0x%04x %4u, 0x%08lx, mbuf: %p\n",
- j,
- tdesc->txlength,tdesc->status,
- (u_long)tdesc->bufaddr,
- tdesc->control,tdesc->buflength,
- (u_long)tdesc->next,
- (void *)sc->tx_buffer[j].mbuf
- );
- }
-}
diff --git a/sys/dev/tx/if_txreg.h b/sys/dev/tx/if_txreg.h
deleted file mode 100644
index 49a394132533..000000000000
--- a/sys/dev/tx/if_txreg.h
+++ /dev/null
@@ -1,419 +0,0 @@
-/* $OpenBSD: if_txvar.h,v 1.3 1998/10/10 04:30:09 jason Exp $ */
-/* $FreeBSD$ */
-
-/*-
- * Copyright (c) 1997 Semen Ustimenko
- * 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 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 AUTHOR 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.
- *
- *
- */
-
-/*
- * Configuration
- */
-#ifndef ETHER_MAX_LEN
-#define ETHER_MAX_LEN 1518
-#endif
-#ifndef ETHER_MIN_LEN
-#define ETHER_MIN_LEN 64
-#endif
-#ifndef ETHER_CRC_LEN
-#define ETHER_CRC_LEN 4
-#endif
-#define TX_RING_SIZE 16 /* Leave this a power of 2 */
-#define RX_RING_SIZE 16 /* And this too, to do not */
- /* confuse RX(TX)_RING_MASK */
-#define TX_RING_MASK (TX_RING_SIZE - 1)
-#define RX_RING_MASK (RX_RING_SIZE - 1)
-#define EPIC_FULL_DUPLEX 1
-#define EPIC_HALF_DUPLEX 0
-#define ETHER_MAX_FRAME_LEN (ETHER_MAX_LEN + ETHER_CRC_LEN)
-#define EPIC_LINK_DOWN 0x00000001
-
-/* PCI identification */
-#define SMC_VENDORID 0x10B8
-#define CHIPID_83C170 0x0005
-#define PCI_VENDORID(x) ((x) & 0xFFFF)
-#define PCI_CHIPID(x) (((x) >> 16) & 0xFFFF)
-
-/* PCI configuration */
-#define PCI_CFID 0x00 /* Configuration ID */
-#define PCI_CFCS 0x04 /* Configurtion Command/Status */
-#define PCI_CFRV 0x08 /* Configuration Revision */
-#define PCI_CFLT 0x0c /* Configuration Latency Timer */
-#define PCI_CBIO 0x10 /* Configuration Base IO Address */
-#define PCI_CBMA 0x14 /* Configuration Base Memory Address */
-#define PCI_CFIT 0x3c /* Configuration Interrupt */
-#define PCI_CFDA 0x40 /* Configuration Driver Area */
-
-#define PCI_CFCS_IOEN 0x0001 /* IO Sapce Enable */
-#define PCI_CFCS_MAEN 0x0002 /* Memory Space Enable */
-#define PCI_CFCS_BMEN 0x0004 /* Bus Master Enable */
-
-#define PCI_CONF_WRITE(r, v) pci_conf_write(config_id, (r), (v))
-#define PCI_CONF_READ(r) pci_conf_read(config_id, (r))
-
-/* EPIC's registers */
-#define COMMAND 0x0000
-#define INTSTAT 0x0004 /* Interrupt status. See below */
-#define INTMASK 0x0008 /* Interrupt mask. See below */
-#define GENCTL 0x000C
-#define NVCTL 0x0010
-#define EECTL 0x0014 /* EEPROM control **/
-#define TEST1 0x001C /* XXXXX */
-#define CRCCNT 0x0020 /* CRC error counter */
-#define ALICNT 0x0024 /* FrameTooLang error counter */
-#define MPCNT 0x0028 /* MissedFrames error counters */
-#define MIICTL 0x0030
-#define MIIDATA 0x0034
-#define MIICFG 0x0038
-#define IPG 0x003C
-#define LAN0 0x0040 /* MAC address */
-#define LAN1 0x0044 /* MAC address */
-#define LAN2 0x0048 /* MAC address */
-#define ID_CHK 0x004C
-#define MC0 0x0050 /* Multicast filter table */
-#define MC1 0x0054 /* Multicast filter table */
-#define MC2 0x0058 /* Multicast filter table */
-#define MC3 0x005C /* Multicast filter table */
-#define RXCON 0x0060 /* Rx control register */
-#define TXCON 0x0070 /* Tx control register */
-#define TXSTAT 0x0074
-#define PRCDAR 0x0084 /* RxRing bus address */
-#define PRSTAT 0x00A4
-#define PRCPTHR 0x00B0
-#define PTCDAR 0x00C4 /* TxRing bus address */
-#define ETXTHR 0x00DC
-
-#define COMMAND_STOP_RX 0x01
-#define COMMAND_START_RX 0x02
-#define COMMAND_TXQUEUED 0x04
-#define COMMAND_RXQUEUED 0x08
-#define COMMAND_NEXTFRAME 0x10
-#define COMMAND_STOP_TDMA 0x20
-#define COMMAND_STOP_RDMA 0x40
-#define COMMAND_TXUGO 0x80
-
-/* Tx threshold */
-#define TX_FIFO_THRESH 0x80 /* 0x40 or 0x10 */
-
-/* Interrupt register bits */
-#define INTSTAT_RCC 0x00000001
-#define INTSTAT_HCC 0x00000002
-#define INTSTAT_RQE 0x00000004
-#define INTSTAT_OVW 0x00000008
-#define INTSTAT_RXE 0x00000010
-#define INTSTAT_TXC 0x00000020
-#define INTSTAT_TCC 0x00000040
-#define INTSTAT_TQE 0x00000080
-#define INTSTAT_TXU 0x00000100
-#define INTSTAT_CNT 0x00000200
-#define INTSTAT_PREI 0x00000400
-#define INTSTAT_RCT 0x00000800
-#define INTSTAT_FATAL 0x00001000 /* One of DPE,APE,PMA,PTA happend */
-#define INTSTAT_UNUSED1 0x00002000
-#define INTSTAT_UNUSED2 0x00004000
-#define INTSTAT_GP2 0x00008000 /* PHY Event */
-#define INTSTAT_INT_ACTV 0x00010000
-#define INTSTAT_RXIDLE 0x00020000
-#define INTSTAT_TXIDLE 0x00040000
-#define INTSTAT_RCIP 0x00080000
-#define INTSTAT_TCIP 0x00100000
-#define INTSTAT_RBE 0x00200000
-#define INTSTAT_RCTS 0x00400000
-#define INTSTAT_RSV 0x00800000
-#define INTSTAT_DPE 0x01000000 /* PCI Fatal error */
-#define INTSTAT_APE 0x02000000 /* PCI Fatal error */
-#define INTSTAT_PMA 0x04000000 /* PCI Fatal error */
-#define INTSTAT_PTA 0x08000000 /* PCI Fatal error */
-
-#define GENCTL_SOFT_RESET 0x00000001
-#define GENCTL_ENABLE_INTERRUPT 0x00000002
-#define GENCTL_SOFTWARE_INTERRUPT 0x00000004
-#define GENCTL_POWER_DOWN 0x00000008
-#define GENCTL_ONECOPY 0x00000010
-#define GENCTL_BIG_ENDIAN 0x00000020
-#define GENCTL_RECEIVE_DMA_PRIORITY 0x00000040
-#define GENCTL_TRANSMIT_DMA_PRIORITY 0x00000080
-#define GENCTL_RECEIVE_FIFO_THRESHOLD128 0x00000300
-#define GENCTL_RECEIVE_FIFO_THRESHOLD96 0x00000200
-#define GENCTL_RECEIVE_FIFO_THRESHOLD64 0x00000100
-#define GENCTL_RECEIVE_FIFO_THRESHOLD32 0x00000000
-#define GENCTL_MEMORY_READ_LINE 0x00000400
-#define GENCTL_MEMORY_READ_MULTIPLE 0x00000800
-#define GENCTL_SOFTWARE1 0x00001000
-#define GENCTL_SOFTWARE2 0x00002000
-#define GENCTL_RESET_PHY 0x00004000
-
-#define NVCTL_ENABLE_MEMORY_MAP 0x00000001
-#define NVCTL_CLOCK_RUN_SUPPORTED 0x00000002
-#define NVCTL_GP1_OUTPUT_ENABLE 0x00000004
-#define NVCTL_GP2_OUTPUT_ENABLE 0x00000008
-#define NVCTL_GP1 0x00000010
-#define NVCTL_GP2 0x00000020
-#define NVCTL_CARDBUS_MODE 0x00000040
-#define NVCTL_IPG_DELAY_MASK(x) ((x&0xF)<<7)
-
-#define RXCON_SAVE_ERRORED_PACKETS 0x00000001
-#define RXCON_RECEIVE_RUNT_FRAMES 0x00000002
-#define RXCON_RECEIVE_BROADCAST_FRAMES 0x00000004
-#define RXCON_RECEIVE_MULTICAST_FRAMES 0x00000008
-#define RXCON_RECEIVE_INVERSE_INDIVIDUAL_ADDRESS_FRAMES 0x00000010
-#define RXCON_PROMISCUOUS_MODE 0x00000020
-#define RXCON_MONITOR_MODE 0x00000040
-#define RXCON_EARLY_RECEIVE_ENABLE 0x00000080
-#define RXCON_EXTERNAL_BUFFER_DISABLE 0x00000000
-#define RXCON_EXTERNAL_BUFFER_16K 0x00000100
-#define RXCON_EXTERNAL_BUFFER_32K 0x00000200
-#define RXCON_EXTERNAL_BUFFER_128K 0x00000300
-
-#define TXCON_EARLY_TRANSMIT_ENABLE 0x00000001
-#define TXCON_LOOPBACK_DISABLE 0x00000000
-#define TXCON_LOOPBACK_MODE_INT 0x00000002
-#define TXCON_LOOPBACK_MODE_PHY 0x00000004
-#define TXCON_LOOPBACK_MODE 0x00000006
-#define TXCON_FULL_DUPLEX 0x00000006
-#define TXCON_SLOT_TIME 0x00000078
-
-#define MIICFG_SMI_ENABLE 0x00000010
-
-#define TEST1_CLOCK_TEST 0x00000008
-
-#define TXCON_DEFAULT (TXCON_SLOT_TIME | TXCON_EARLY_TRANSMIT_ENABLE)
-#define TRANSMIT_THRESHOLD 0x80
-
-#if defined(EARLY_RX)
- #define RXCON_DEFAULT (RXCON_EARLY_RECEIVE_ENABLE | RXCON_SAVE_ERRORED_PACKETS)
-#else
- #define RXCON_DEFAULT (0)
-#endif
-/*
- * National Semiconductor's DP83840A Registers and bits
- */
-#define DP83840_OUI 0x080017
-#define DP83840_BMCR 0x00 /* Control register */
-#define DP83840_BMSR 0x01 /* Status rgister */
-#define DP83840_ANAR 0x04 /* Autonegotiation advertising register */
-#define DP83840_LPAR 0x05 /* Link Partner Ability register */
-#define DP83840_ANER 0x06 /* Auto-Negotiation Expansion Register */
-#define DP83840_PAR 0x19 /* PHY Address Register */
-#define DP83840_PHYIDR1 0x02
-#define DP83840_PHYIDR2 0x03
-
-#define BMCR_RESET 0x8000
-#define BMCR_LOOPBACK 0x4000
-#define BMCR_100MBPS 0x2000 /* 10/100 Mbps */
-#define BMCR_AUTONEGOTIATION 0x1000 /* ON/OFF */
-#define BMCR_POWERDOWN 0x0800
-#define BMCR_ISOLATE 0x0400
-#define BMCR_RESTART_AUTONEG 0x0200
-#define BMCR_FULL_DUPLEX 0x0100
-#define BMCR_COL_TEST 0x0080
-
-#define BMSR_100BASE_T4 0x8000
-#define BMSR_100BASE_TX_FD 0x4000
-#define BMSR_100BASE_TX 0x2000
-#define BMSR_10BASE_T_FD 0x1000
-#define BMSR_10BASE_T 0x0800
-#define BMSR_AUTONEG_COMPLETE 0x0020
-#define BMSR_AUTONEG_ABLE 0x0008
-#define BMSR_LINK_STATUS 0x0004
-
-#define PAR_FULL_DUPLEX 0x0400
-
-#define ANER_MULTIPLE_LINK_FAULT 0x10
-
-/* ANAR and LPAR have the same bits, define them only once */
-#define ANAR_10 0x0020
-#define ANAR_10_FD 0x0040
-#define ANAR_100_TX 0x0080
-#define ANAR_100_TX_FD 0x0100
-#define ANAR_100_T4 0x0200
-
-/*
- * Quality Semiconductor's QS6612 registers and bits
- */
-#define QS6612_OUI 0x006051
-#define QS6612_MCTL 17
-#define QS6612_INTSTAT 29
-#define QS6612_INTMASK 30
-#define QS6612_BPCR 31
-
-#define MCTL_T4_PRESENT 0x1000 /* External T4 Enabled, ignored */
- /* if AutoNeg is enabled */
-#define MCTL_BTEXT 0x0800 /* Reduces 10baset squelch level */
- /* for extended cable length */
-
-#define INTSTAT_AN_COMPLETE 0x40 /* Autonegotiation complete */
-#define INTSTAT_RF_DETECTED 0x20 /* Remote Fault detected */
-#define INTSTAT_LINK_STATUS 0x10 /* Link status changed */
-#define INTSTAT_AN_LP_ACK 0x08 /* Autoneg. LP Acknoledge */
-#define INTSTAT_PD_FAULT 0x04 /* Parallel Detection Fault */
-#define INTSTAT_AN_PAGE 0x04 /* Autoneg. Page Received */
-#define INTSTAT_RE_CNT_FULL 0x01 /* Receive Error Counter Full */
-
-#define INTMASK_THUNDERLAN 0x8000 /* Enable interrupts */
-
-/*
- * Structures definition and Functions prototypes
- */
-
-/* EPIC's hardware descriptors, must be aligned on dword in memory */
-/* NB: to make driver happy, this two structures MUST have thier sizes */
-/* be divisor of PAGE_SIZE */
-struct epic_tx_desc {
- volatile u_int16_t status;
- volatile u_int16_t txlength;
- volatile u_int32_t bufaddr;
- volatile u_int16_t buflength;
- volatile u_int16_t control;
- volatile u_int32_t next;
-};
-struct epic_rx_desc {
- volatile u_int16_t status;
- volatile u_int16_t rxlength;
- volatile u_int32_t bufaddr;
- volatile u_int32_t buflength;
- volatile u_int32_t next;
-};
-
-/* This structure defines EPIC's fragment list, maximum number of frags */
-/* is 63. Let use maximum, becouse size of struct MUST be divisor of */
-/* PAGE_SIZE, and sometimes come mbufs with more then 30 frags */
-#define EPIC_MAX_FRAGS 63
-struct epic_frag_list {
- volatile u_int32_t numfrags;
- struct {
- volatile u_int32_t fragaddr;
- volatile u_int32_t fraglen;
- } frag[EPIC_MAX_FRAGS];
- volatile u_int32_t pad; /* align on 256 bytes */
-};
-
-/* This is driver's structure to define EPIC descriptors */
-struct epic_rx_buffer {
- struct mbuf * mbuf; /* mbuf receiving packet */
-};
-
-struct epic_tx_buffer {
- struct mbuf * mbuf; /* mbuf contained packet */
-};
-
-/*
- * NB: ALIGN OF ABOVE STRUCTURES
- * epic_rx_desc, epic_tx_desc, epic_frag_list - must be aligned on dword
- */
-
-/* Driver status structure */
-typedef struct {
- struct arpcom arpcom;
-#if defined(__OpenBSD__)
- struct device sc_dev;
- void *sc_ih;
- bus_space_tag_t sc_st;
- bus_space_handle_t sc_sh;
-#else /* __FreeBSD__ */
-#if defined(EPIC_USEIOSPACE)
- u_int32_t iobase;
-#else
- caddr_t csr;
-#endif
-#endif
-#if !defined(EPIC_NOIFMEDIA)
- struct ifmedia ifmedia;
-#endif
- u_int32_t unit;
- struct epic_rx_buffer rx_buffer[RX_RING_SIZE];
- struct epic_tx_buffer tx_buffer[TX_RING_SIZE];
-
- /* Each element of array MUST be aligned on dword */
- /* and bounded on PAGE_SIZE */
- struct epic_rx_desc *rx_desc;
- struct epic_tx_desc *tx_desc;
- struct epic_frag_list *tx_flist;
- u_int32_t flags;
- u_int32_t tx_threshold;
- u_int32_t txcon;
- u_int32_t phyid;
- u_int32_t cur_tx;
- u_int32_t cur_rx;
- u_int32_t dirty_tx;
- u_int32_t pending_txs;
- void *pool;
-} epic_softc_t;
-
-#if defined(__FreeBSD__)
-#define EPIC_FORMAT "tx%d"
-#define EPIC_ARGS(sc) (sc->unit)
-#define sc_if arpcom.ac_if
-#define sc_macaddr arpcom.ac_enaddr
-#if defined(EPIC_USEIOSPACE)
-#define CSR_WRITE_4(sc,reg,val) \
- outl( (sc)->iobase + (u_int32_t)(reg), (val) )
-#define CSR_WRITE_2(sc,reg,val) \
- outw( (sc)->iobase + (u_int32_t)(reg), (val) )
-#define CSR_WRITE_1(sc,reg,val) \
- outb( (sc)->iobase + (u_int32_t)(reg), (val) )
-#define CSR_READ_4(sc,reg) \
- inl( (sc)->iobase + (u_int32_t)(reg) )
-#define CSR_READ_2(sc,reg) \
- inw( (sc)->iobase + (u_int32_t)(reg) )
-#define CSR_READ_1(sc,reg) \
- inb( (sc)->iobase + (u_int32_t)(reg) )
-#else
-#define CSR_WRITE_1(sc,reg,val) \
- ((*(volatile u_int8_t*)((sc)->csr + (u_int32_t)(reg))) = (u_int8_t)(val))
-#define CSR_WRITE_2(sc,reg,val) \
- ((*(volatile u_int16_t*)((sc)->csr + (u_int32_t)(reg))) = (u_int16_t)(val))
-#define CSR_WRITE_4(sc,reg,val) \
- ((*(volatile u_int32_t*)((sc)->csr + (u_int32_t)(reg))) = (u_int32_t)(val))
-#define CSR_READ_1(sc,reg) \
- (*(volatile u_int8_t*)((sc)->csr + (u_int32_t)(reg)))
-#define CSR_READ_2(sc,reg) \
- (*(volatile u_int16_t*)((sc)->csr + (u_int32_t)(reg)))
-#define CSR_READ_4(sc,reg) \
- (*(volatile u_int32_t*)((sc)->csr + (u_int32_t)(reg)))
-#endif
-#else /* __OpenBSD__ */
-#define EPIC_FORMAT "%s"
-#define EPIC_ARGS(sc) (sc->sc_dev.dv_xname)
-#define sc_if arpcom.ac_if
-#define sc_macaddr arpcom.ac_enaddr
-#define CSR_WRITE_4(sc,reg,val) \
- bus_space_write_4( (sc)->sc_st, (sc)->sc_sh, (reg), (val) )
-#define CSR_WRITE_2(sc,reg,val) \
- bus_space_write_2( (sc)->sc_st, (sc)->sc_sh, (reg), (val) )
-#define CSR_WRITE_1(sc,reg,val) \
- bus_space_write_1( (sc)->sc_st, (sc)->sc_sh, (reg), (val) )
-#define CSR_READ_4(sc,reg) \
- bus_space_read_4( (sc)->sc_st, (sc)->sc_sh, (reg) )
-#define CSR_READ_2(sc,reg) \
- bus_space_read_2( (sc)->sc_st, (sc)->sc_sh, (reg) )
-#define CSR_READ_1(sc,reg) \
- bus_space_read_1( (sc)->sc_st, (sc)->sc_sh, (reg) )
-#endif
-
-#define PHY_READ_2(sc,reg) epic_read_phy_register(sc,reg)
-#define PHY_WRITE_2(sc,reg,val) epic_write_phy_register(sc,reg,val)
-
diff --git a/sys/dev/tx/if_txvar.h b/sys/dev/tx/if_txvar.h
deleted file mode 100644
index 49a394132533..000000000000
--- a/sys/dev/tx/if_txvar.h
+++ /dev/null
@@ -1,419 +0,0 @@
-/* $OpenBSD: if_txvar.h,v 1.3 1998/10/10 04:30:09 jason Exp $ */
-/* $FreeBSD$ */
-
-/*-
- * Copyright (c) 1997 Semen Ustimenko
- * 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 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 AUTHOR 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.
- *
- *
- */
-
-/*
- * Configuration
- */
-#ifndef ETHER_MAX_LEN
-#define ETHER_MAX_LEN 1518
-#endif
-#ifndef ETHER_MIN_LEN
-#define ETHER_MIN_LEN 64
-#endif
-#ifndef ETHER_CRC_LEN
-#define ETHER_CRC_LEN 4
-#endif
-#define TX_RING_SIZE 16 /* Leave this a power of 2 */
-#define RX_RING_SIZE 16 /* And this too, to do not */
- /* confuse RX(TX)_RING_MASK */
-#define TX_RING_MASK (TX_RING_SIZE - 1)
-#define RX_RING_MASK (RX_RING_SIZE - 1)
-#define EPIC_FULL_DUPLEX 1
-#define EPIC_HALF_DUPLEX 0
-#define ETHER_MAX_FRAME_LEN (ETHER_MAX_LEN + ETHER_CRC_LEN)
-#define EPIC_LINK_DOWN 0x00000001
-
-/* PCI identification */
-#define SMC_VENDORID 0x10B8
-#define CHIPID_83C170 0x0005
-#define PCI_VENDORID(x) ((x) & 0xFFFF)
-#define PCI_CHIPID(x) (((x) >> 16) & 0xFFFF)
-
-/* PCI configuration */
-#define PCI_CFID 0x00 /* Configuration ID */
-#define PCI_CFCS 0x04 /* Configurtion Command/Status */
-#define PCI_CFRV 0x08 /* Configuration Revision */
-#define PCI_CFLT 0x0c /* Configuration Latency Timer */
-#define PCI_CBIO 0x10 /* Configuration Base IO Address */
-#define PCI_CBMA 0x14 /* Configuration Base Memory Address */
-#define PCI_CFIT 0x3c /* Configuration Interrupt */
-#define PCI_CFDA 0x40 /* Configuration Driver Area */
-
-#define PCI_CFCS_IOEN 0x0001 /* IO Sapce Enable */
-#define PCI_CFCS_MAEN 0x0002 /* Memory Space Enable */
-#define PCI_CFCS_BMEN 0x0004 /* Bus Master Enable */
-
-#define PCI_CONF_WRITE(r, v) pci_conf_write(config_id, (r), (v))
-#define PCI_CONF_READ(r) pci_conf_read(config_id, (r))
-
-/* EPIC's registers */
-#define COMMAND 0x0000
-#define INTSTAT 0x0004 /* Interrupt status. See below */
-#define INTMASK 0x0008 /* Interrupt mask. See below */
-#define GENCTL 0x000C
-#define NVCTL 0x0010
-#define EECTL 0x0014 /* EEPROM control **/
-#define TEST1 0x001C /* XXXXX */
-#define CRCCNT 0x0020 /* CRC error counter */
-#define ALICNT 0x0024 /* FrameTooLang error counter */
-#define MPCNT 0x0028 /* MissedFrames error counters */
-#define MIICTL 0x0030
-#define MIIDATA 0x0034
-#define MIICFG 0x0038
-#define IPG 0x003C
-#define LAN0 0x0040 /* MAC address */
-#define LAN1 0x0044 /* MAC address */
-#define LAN2 0x0048 /* MAC address */
-#define ID_CHK 0x004C
-#define MC0 0x0050 /* Multicast filter table */
-#define MC1 0x0054 /* Multicast filter table */
-#define MC2 0x0058 /* Multicast filter table */
-#define MC3 0x005C /* Multicast filter table */
-#define RXCON 0x0060 /* Rx control register */
-#define TXCON 0x0070 /* Tx control register */
-#define TXSTAT 0x0074
-#define PRCDAR 0x0084 /* RxRing bus address */
-#define PRSTAT 0x00A4
-#define PRCPTHR 0x00B0
-#define PTCDAR 0x00C4 /* TxRing bus address */
-#define ETXTHR 0x00DC
-
-#define COMMAND_STOP_RX 0x01
-#define COMMAND_START_RX 0x02
-#define COMMAND_TXQUEUED 0x04
-#define COMMAND_RXQUEUED 0x08
-#define COMMAND_NEXTFRAME 0x10
-#define COMMAND_STOP_TDMA 0x20
-#define COMMAND_STOP_RDMA 0x40
-#define COMMAND_TXUGO 0x80
-
-/* Tx threshold */
-#define TX_FIFO_THRESH 0x80 /* 0x40 or 0x10 */
-
-/* Interrupt register bits */
-#define INTSTAT_RCC 0x00000001
-#define INTSTAT_HCC 0x00000002
-#define INTSTAT_RQE 0x00000004
-#define INTSTAT_OVW 0x00000008
-#define INTSTAT_RXE 0x00000010
-#define INTSTAT_TXC 0x00000020
-#define INTSTAT_TCC 0x00000040
-#define INTSTAT_TQE 0x00000080
-#define INTSTAT_TXU 0x00000100
-#define INTSTAT_CNT 0x00000200
-#define INTSTAT_PREI 0x00000400
-#define INTSTAT_RCT 0x00000800
-#define INTSTAT_FATAL 0x00001000 /* One of DPE,APE,PMA,PTA happend */
-#define INTSTAT_UNUSED1 0x00002000
-#define INTSTAT_UNUSED2 0x00004000
-#define INTSTAT_GP2 0x00008000 /* PHY Event */
-#define INTSTAT_INT_ACTV 0x00010000
-#define INTSTAT_RXIDLE 0x00020000
-#define INTSTAT_TXIDLE 0x00040000
-#define INTSTAT_RCIP 0x00080000
-#define INTSTAT_TCIP 0x00100000
-#define INTSTAT_RBE 0x00200000
-#define INTSTAT_RCTS 0x00400000
-#define INTSTAT_RSV 0x00800000
-#define INTSTAT_DPE 0x01000000 /* PCI Fatal error */
-#define INTSTAT_APE 0x02000000 /* PCI Fatal error */
-#define INTSTAT_PMA 0x04000000 /* PCI Fatal error */
-#define INTSTAT_PTA 0x08000000 /* PCI Fatal error */
-
-#define GENCTL_SOFT_RESET 0x00000001
-#define GENCTL_ENABLE_INTERRUPT 0x00000002
-#define GENCTL_SOFTWARE_INTERRUPT 0x00000004
-#define GENCTL_POWER_DOWN 0x00000008
-#define GENCTL_ONECOPY 0x00000010
-#define GENCTL_BIG_ENDIAN 0x00000020
-#define GENCTL_RECEIVE_DMA_PRIORITY 0x00000040
-#define GENCTL_TRANSMIT_DMA_PRIORITY 0x00000080
-#define GENCTL_RECEIVE_FIFO_THRESHOLD128 0x00000300
-#define GENCTL_RECEIVE_FIFO_THRESHOLD96 0x00000200
-#define GENCTL_RECEIVE_FIFO_THRESHOLD64 0x00000100
-#define GENCTL_RECEIVE_FIFO_THRESHOLD32 0x00000000
-#define GENCTL_MEMORY_READ_LINE 0x00000400
-#define GENCTL_MEMORY_READ_MULTIPLE 0x00000800
-#define GENCTL_SOFTWARE1 0x00001000
-#define GENCTL_SOFTWARE2 0x00002000
-#define GENCTL_RESET_PHY 0x00004000
-
-#define NVCTL_ENABLE_MEMORY_MAP 0x00000001
-#define NVCTL_CLOCK_RUN_SUPPORTED 0x00000002
-#define NVCTL_GP1_OUTPUT_ENABLE 0x00000004
-#define NVCTL_GP2_OUTPUT_ENABLE 0x00000008
-#define NVCTL_GP1 0x00000010
-#define NVCTL_GP2 0x00000020
-#define NVCTL_CARDBUS_MODE 0x00000040
-#define NVCTL_IPG_DELAY_MASK(x) ((x&0xF)<<7)
-
-#define RXCON_SAVE_ERRORED_PACKETS 0x00000001
-#define RXCON_RECEIVE_RUNT_FRAMES 0x00000002
-#define RXCON_RECEIVE_BROADCAST_FRAMES 0x00000004
-#define RXCON_RECEIVE_MULTICAST_FRAMES 0x00000008
-#define RXCON_RECEIVE_INVERSE_INDIVIDUAL_ADDRESS_FRAMES 0x00000010
-#define RXCON_PROMISCUOUS_MODE 0x00000020
-#define RXCON_MONITOR_MODE 0x00000040
-#define RXCON_EARLY_RECEIVE_ENABLE 0x00000080
-#define RXCON_EXTERNAL_BUFFER_DISABLE 0x00000000
-#define RXCON_EXTERNAL_BUFFER_16K 0x00000100
-#define RXCON_EXTERNAL_BUFFER_32K 0x00000200
-#define RXCON_EXTERNAL_BUFFER_128K 0x00000300
-
-#define TXCON_EARLY_TRANSMIT_ENABLE 0x00000001
-#define TXCON_LOOPBACK_DISABLE 0x00000000
-#define TXCON_LOOPBACK_MODE_INT 0x00000002
-#define TXCON_LOOPBACK_MODE_PHY 0x00000004
-#define TXCON_LOOPBACK_MODE 0x00000006
-#define TXCON_FULL_DUPLEX 0x00000006
-#define TXCON_SLOT_TIME 0x00000078
-
-#define MIICFG_SMI_ENABLE 0x00000010
-
-#define TEST1_CLOCK_TEST 0x00000008
-
-#define TXCON_DEFAULT (TXCON_SLOT_TIME | TXCON_EARLY_TRANSMIT_ENABLE)
-#define TRANSMIT_THRESHOLD 0x80
-
-#if defined(EARLY_RX)
- #define RXCON_DEFAULT (RXCON_EARLY_RECEIVE_ENABLE | RXCON_SAVE_ERRORED_PACKETS)
-#else
- #define RXCON_DEFAULT (0)
-#endif
-/*
- * National Semiconductor's DP83840A Registers and bits
- */
-#define DP83840_OUI 0x080017
-#define DP83840_BMCR 0x00 /* Control register */
-#define DP83840_BMSR 0x01 /* Status rgister */
-#define DP83840_ANAR 0x04 /* Autonegotiation advertising register */
-#define DP83840_LPAR 0x05 /* Link Partner Ability register */
-#define DP83840_ANER 0x06 /* Auto-Negotiation Expansion Register */
-#define DP83840_PAR 0x19 /* PHY Address Register */
-#define DP83840_PHYIDR1 0x02
-#define DP83840_PHYIDR2 0x03
-
-#define BMCR_RESET 0x8000
-#define BMCR_LOOPBACK 0x4000
-#define BMCR_100MBPS 0x2000 /* 10/100 Mbps */
-#define BMCR_AUTONEGOTIATION 0x1000 /* ON/OFF */
-#define BMCR_POWERDOWN 0x0800
-#define BMCR_ISOLATE 0x0400
-#define BMCR_RESTART_AUTONEG 0x0200
-#define BMCR_FULL_DUPLEX 0x0100
-#define BMCR_COL_TEST 0x0080
-
-#define BMSR_100BASE_T4 0x8000
-#define BMSR_100BASE_TX_FD 0x4000
-#define BMSR_100BASE_TX 0x2000
-#define BMSR_10BASE_T_FD 0x1000
-#define BMSR_10BASE_T 0x0800
-#define BMSR_AUTONEG_COMPLETE 0x0020
-#define BMSR_AUTONEG_ABLE 0x0008
-#define BMSR_LINK_STATUS 0x0004
-
-#define PAR_FULL_DUPLEX 0x0400
-
-#define ANER_MULTIPLE_LINK_FAULT 0x10
-
-/* ANAR and LPAR have the same bits, define them only once */
-#define ANAR_10 0x0020
-#define ANAR_10_FD 0x0040
-#define ANAR_100_TX 0x0080
-#define ANAR_100_TX_FD 0x0100
-#define ANAR_100_T4 0x0200
-
-/*
- * Quality Semiconductor's QS6612 registers and bits
- */
-#define QS6612_OUI 0x006051
-#define QS6612_MCTL 17
-#define QS6612_INTSTAT 29
-#define QS6612_INTMASK 30
-#define QS6612_BPCR 31
-
-#define MCTL_T4_PRESENT 0x1000 /* External T4 Enabled, ignored */
- /* if AutoNeg is enabled */
-#define MCTL_BTEXT 0x0800 /* Reduces 10baset squelch level */
- /* for extended cable length */
-
-#define INTSTAT_AN_COMPLETE 0x40 /* Autonegotiation complete */
-#define INTSTAT_RF_DETECTED 0x20 /* Remote Fault detected */
-#define INTSTAT_LINK_STATUS 0x10 /* Link status changed */
-#define INTSTAT_AN_LP_ACK 0x08 /* Autoneg. LP Acknoledge */
-#define INTSTAT_PD_FAULT 0x04 /* Parallel Detection Fault */
-#define INTSTAT_AN_PAGE 0x04 /* Autoneg. Page Received */
-#define INTSTAT_RE_CNT_FULL 0x01 /* Receive Error Counter Full */
-
-#define INTMASK_THUNDERLAN 0x8000 /* Enable interrupts */
-
-/*
- * Structures definition and Functions prototypes
- */
-
-/* EPIC's hardware descriptors, must be aligned on dword in memory */
-/* NB: to make driver happy, this two structures MUST have thier sizes */
-/* be divisor of PAGE_SIZE */
-struct epic_tx_desc {
- volatile u_int16_t status;
- volatile u_int16_t txlength;
- volatile u_int32_t bufaddr;
- volatile u_int16_t buflength;
- volatile u_int16_t control;
- volatile u_int32_t next;
-};
-struct epic_rx_desc {
- volatile u_int16_t status;
- volatile u_int16_t rxlength;
- volatile u_int32_t bufaddr;
- volatile u_int32_t buflength;
- volatile u_int32_t next;
-};
-
-/* This structure defines EPIC's fragment list, maximum number of frags */
-/* is 63. Let use maximum, becouse size of struct MUST be divisor of */
-/* PAGE_SIZE, and sometimes come mbufs with more then 30 frags */
-#define EPIC_MAX_FRAGS 63
-struct epic_frag_list {
- volatile u_int32_t numfrags;
- struct {
- volatile u_int32_t fragaddr;
- volatile u_int32_t fraglen;
- } frag[EPIC_MAX_FRAGS];
- volatile u_int32_t pad; /* align on 256 bytes */
-};
-
-/* This is driver's structure to define EPIC descriptors */
-struct epic_rx_buffer {
- struct mbuf * mbuf; /* mbuf receiving packet */
-};
-
-struct epic_tx_buffer {
- struct mbuf * mbuf; /* mbuf contained packet */
-};
-
-/*
- * NB: ALIGN OF ABOVE STRUCTURES
- * epic_rx_desc, epic_tx_desc, epic_frag_list - must be aligned on dword
- */
-
-/* Driver status structure */
-typedef struct {
- struct arpcom arpcom;
-#if defined(__OpenBSD__)
- struct device sc_dev;
- void *sc_ih;
- bus_space_tag_t sc_st;
- bus_space_handle_t sc_sh;
-#else /* __FreeBSD__ */
-#if defined(EPIC_USEIOSPACE)
- u_int32_t iobase;
-#else
- caddr_t csr;
-#endif
-#endif
-#if !defined(EPIC_NOIFMEDIA)
- struct ifmedia ifmedia;
-#endif
- u_int32_t unit;
- struct epic_rx_buffer rx_buffer[RX_RING_SIZE];
- struct epic_tx_buffer tx_buffer[TX_RING_SIZE];
-
- /* Each element of array MUST be aligned on dword */
- /* and bounded on PAGE_SIZE */
- struct epic_rx_desc *rx_desc;
- struct epic_tx_desc *tx_desc;
- struct epic_frag_list *tx_flist;
- u_int32_t flags;
- u_int32_t tx_threshold;
- u_int32_t txcon;
- u_int32_t phyid;
- u_int32_t cur_tx;
- u_int32_t cur_rx;
- u_int32_t dirty_tx;
- u_int32_t pending_txs;
- void *pool;
-} epic_softc_t;
-
-#if defined(__FreeBSD__)
-#define EPIC_FORMAT "tx%d"
-#define EPIC_ARGS(sc) (sc->unit)
-#define sc_if arpcom.ac_if
-#define sc_macaddr arpcom.ac_enaddr
-#if defined(EPIC_USEIOSPACE)
-#define CSR_WRITE_4(sc,reg,val) \
- outl( (sc)->iobase + (u_int32_t)(reg), (val) )
-#define CSR_WRITE_2(sc,reg,val) \
- outw( (sc)->iobase + (u_int32_t)(reg), (val) )
-#define CSR_WRITE_1(sc,reg,val) \
- outb( (sc)->iobase + (u_int32_t)(reg), (val) )
-#define CSR_READ_4(sc,reg) \
- inl( (sc)->iobase + (u_int32_t)(reg) )
-#define CSR_READ_2(sc,reg) \
- inw( (sc)->iobase + (u_int32_t)(reg) )
-#define CSR_READ_1(sc,reg) \
- inb( (sc)->iobase + (u_int32_t)(reg) )
-#else
-#define CSR_WRITE_1(sc,reg,val) \
- ((*(volatile u_int8_t*)((sc)->csr + (u_int32_t)(reg))) = (u_int8_t)(val))
-#define CSR_WRITE_2(sc,reg,val) \
- ((*(volatile u_int16_t*)((sc)->csr + (u_int32_t)(reg))) = (u_int16_t)(val))
-#define CSR_WRITE_4(sc,reg,val) \
- ((*(volatile u_int32_t*)((sc)->csr + (u_int32_t)(reg))) = (u_int32_t)(val))
-#define CSR_READ_1(sc,reg) \
- (*(volatile u_int8_t*)((sc)->csr + (u_int32_t)(reg)))
-#define CSR_READ_2(sc,reg) \
- (*(volatile u_int16_t*)((sc)->csr + (u_int32_t)(reg)))
-#define CSR_READ_4(sc,reg) \
- (*(volatile u_int32_t*)((sc)->csr + (u_int32_t)(reg)))
-#endif
-#else /* __OpenBSD__ */
-#define EPIC_FORMAT "%s"
-#define EPIC_ARGS(sc) (sc->sc_dev.dv_xname)
-#define sc_if arpcom.ac_if
-#define sc_macaddr arpcom.ac_enaddr
-#define CSR_WRITE_4(sc,reg,val) \
- bus_space_write_4( (sc)->sc_st, (sc)->sc_sh, (reg), (val) )
-#define CSR_WRITE_2(sc,reg,val) \
- bus_space_write_2( (sc)->sc_st, (sc)->sc_sh, (reg), (val) )
-#define CSR_WRITE_1(sc,reg,val) \
- bus_space_write_1( (sc)->sc_st, (sc)->sc_sh, (reg), (val) )
-#define CSR_READ_4(sc,reg) \
- bus_space_read_4( (sc)->sc_st, (sc)->sc_sh, (reg) )
-#define CSR_READ_2(sc,reg) \
- bus_space_read_2( (sc)->sc_st, (sc)->sc_sh, (reg) )
-#define CSR_READ_1(sc,reg) \
- bus_space_read_1( (sc)->sc_st, (sc)->sc_sh, (reg) )
-#endif
-
-#define PHY_READ_2(sc,reg) epic_read_phy_register(sc,reg)
-#define PHY_WRITE_2(sc,reg,val) epic_write_phy_register(sc,reg,val)
-
diff --git a/sys/dev/usb/ohci_pci.c b/sys/dev/usb/ohci_pci.c
deleted file mode 100644
index 7bce5f2b18f7..000000000000
--- a/sys/dev/usb/ohci_pci.c
+++ /dev/null
@@ -1,283 +0,0 @@
-/* $FreeBSD$ */
-
-/*
- * Copyright (c) 1998 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Lennart Augustsson (augustss@carlstedt.se) at
- * Carlstedt Research & Technology.
- *
- * 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 the NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation 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 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.
- */
-
-/*
- * USB Open Host Controller driver.
- *
- * OHCI spec: http://www.intel.com/design/usb/ohci11d.pdf
- */
-
-/* The low level controller code for OHCI has been split into
- * PCI probes and OHCI specific code. This was done to facilitate the
- * sharing of code between *BSD's
- */
-
-
-#include "opt_bus.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/bus.h>
-#include <sys/proc.h>
-#include <sys/queue.h>
-#include <machine/bus.h>
-#include <sys/rman.h>
-#include <machine/resource.h>
-
-#include <pci/pcivar.h>
-#include <pci/pcireg.h>
-
-#include <dev/usb/usb.h>
-#include <dev/usb/usbdi.h>
-#include <dev/usb/usbdivar.h>
-#include <dev/usb/usb_mem.h>
-
-#include <dev/usb/ohcireg.h>
-#include <dev/usb/ohcivar.h>
-
-#define PCI_OHCI_VENDORID_ALI 0x10b9
-#define PCI_OHCI_VENDORID_AMD756 0x1022
-#define PCI_OHCI_VENDORID_CMDTECH 0x1095
-#define PCI_OHCI_VENDORID_COMPAQ 0x0e11
-#define PCI_OHCI_VENDORID_NEC 0x1033
-#define PCI_OHCI_VENDORID_OPTI 0x1045
-#define PCI_OHCI_VENDORID_SIS 0x1039
-
-#define PCI_OHCI_DEVICEID_ALADDIN_V 0x523710b9
-static const char *ohci_device_aladdin_v = "AcerLabs M5237 (Aladdin-V) USB controller";
-#define PCI_OHCI_DEVICEID_AMD756 0x740c1022
-static const char *ohci_device_amd756 = "AMD-756 USB Controller";
-#define PCI_OHCI_DEVICEID_FIRELINK 0xc8611045
-static const char *ohci_device_firelink = "OPTi 82C861 (FireLink) USB controller";
-#define PCI_OHCI_DEVICEID_NEC 0x00351033
-static const char *ohci_device_nec = "NEC uPD 9210 USB controller";
-#define PCI_OHCI_DEVICEID_USB0670 0x06701095
-static const char *ohci_device_usb0670 = "CMD Tech 670 (USB0670) USB controller";
-#define PCI_OHCI_DEVICEID_USB0673 0x06731095
-static const char *ohci_device_usb0673 = "CMD Tech 673 (USB0673) USB controller";
-
-static const char *ohci_device_generic = "OHCI (generic) USB controller";
-
-#define PCI_OHCI_BASE_REG 0x10
-
-static const char *
-ohci_pci_match(device_t self)
-{
- u_int32_t device_id = pci_get_devid(self);
-
- switch(device_id) {
- case PCI_OHCI_DEVICEID_ALADDIN_V:
- return (ohci_device_aladdin_v);
- case PCI_OHCI_DEVICEID_AMD756:
- return (ohci_device_amd756);
- case PCI_OHCI_DEVICEID_USB0670:
- return (ohci_device_usb0670);
- case PCI_OHCI_DEVICEID_USB0673:
- return (ohci_device_usb0673);
- case PCI_OHCI_DEVICEID_FIRELINK:
- return (ohci_device_firelink);
- case PCI_OHCI_DEVICEID_NEC:
- return (ohci_device_nec);
- default:
- if ( pci_get_class(self) == PCIC_SERIALBUS
- && pci_get_subclass(self) == PCIS_SERIALBUS_USB
- && pci_get_progif(self) == PCI_INTERFACE_OHCI) {
- return (ohci_device_generic);
- }
- }
-
- return NULL; /* dunno */
-}
-
-static int
-ohci_pci_probe(device_t self)
-{
- const char *desc = ohci_pci_match(self);
- if (desc) {
- device_set_desc(self, desc);
- return 0;
- } else {
- return ENXIO;
- }
-}
-
-static int
-ohci_pci_attach(device_t self)
-{
- device_t parent = device_get_parent(self);
- ohci_softc_t *sc = device_get_softc(self);
- int err;
- int rid;
- struct resource *io_res, *irq_res;
- void *ih;
- int intr;
-
- /* For the moment, put in a message stating what is wrong */
- intr = pci_read_config(self, PCIR_INTLINE, 1);
- if (intr == 0 || intr == 255) {
- device_printf(self, "Invalid irq %d\n", intr);
- device_printf(self, "Please switch on USB support and switch PNP-OS to 'No' in BIOS\n");
- return ENXIO;
- }
-
- /* XXX where does it say so in the spec? */
- sc->sc_bus.usbrev = USBREV_1_0;
-
- rid = PCI_CBMEM;
- io_res = bus_alloc_resource(self, SYS_RES_MEMORY, &rid,
- 0, ~0, 1, RF_ACTIVE);
- if (!io_res) {
- device_printf(self, "could not map memory\n");
- return ENXIO;
- }
-
- sc->iot = rman_get_bustag(io_res);
- sc->ioh = rman_get_bushandle(io_res);
-
- rid = 0;
- irq_res = bus_alloc_resource(self, SYS_RES_IRQ, &rid, 0, ~0, 1,
- RF_SHAREABLE | RF_ACTIVE);
- if (irq_res == NULL) {
- device_printf(self, "could not allocate irq\n");
- err = ENOMEM;
- goto bad1;
- }
-
- sc->sc_bus.bdev = device_add_child(self, "usb", -1);
- if (!sc->sc_bus.bdev) {
- device_printf(self, "could not add USB device\n");
- err = ENOMEM;
- goto bad2;
- }
- device_set_ivars(sc->sc_bus.bdev, sc);
-
- switch (pci_get_devid(self)) {
- case PCI_OHCI_DEVICEID_ALADDIN_V:
- device_set_desc(sc->sc_bus.bdev, ohci_device_aladdin_v);
- sprintf(sc->sc_vendor, "AcerLabs");
- break;
- case PCI_OHCI_DEVICEID_AMD756:
- device_set_desc(sc->sc_bus.bdev, ohci_device_amd756);
- sprintf(sc->sc_vendor, "AMD");
- break;
- case PCI_OHCI_DEVICEID_FIRELINK:
- device_set_desc(sc->sc_bus.bdev, ohci_device_firelink);
- sprintf(sc->sc_vendor, "OPTi");
- break;
- case PCI_OHCI_DEVICEID_NEC:
- device_set_desc(sc->sc_bus.bdev, ohci_device_nec);
- sprintf(sc->sc_vendor, "NEC");
- break;
- case PCI_OHCI_DEVICEID_USB0670:
- device_set_desc(sc->sc_bus.bdev, ohci_device_usb0670);
- sprintf(sc->sc_vendor, "CMDTECH");
- break;
- case PCI_OHCI_DEVICEID_USB0673:
- device_set_desc(sc->sc_bus.bdev, ohci_device_usb0673);
- sprintf(sc->sc_vendor, "CMDTECH");
- break;
- default:
- if (bootverbose)
- device_printf(self, "(New OHCI DeviceId=0x%08x)\n",
- pci_get_devid(self));
- device_set_desc(sc->sc_bus.bdev, ohci_device_generic);
- sprintf(sc->sc_vendor, "(unknown)");
- }
-
- err = BUS_SETUP_INTR(parent, self, irq_res, INTR_TYPE_BIO,
- (driver_intr_t *) ohci_intr, sc, &ih);
- if (err) {
- device_printf(self, "could not setup irq, %d\n", err);
- goto bad3;
- }
-
- err = ohci_init(sc);
- if (!err)
- err = device_probe_and_attach(sc->sc_bus.bdev);
-
- if (err) {
- device_printf(self, "USB init failed\n");
- err = EIO;
- goto bad4;
- }
-
- return 0;
-bad4:
- /* disable interrupts that might have been switched on
- * in ohci_init
- */
- bus_space_write_4(sc->iot, sc->ioh,
- OHCI_INTERRUPT_DISABLE, OHCI_ALL_INTRS);
-
- err = BUS_TEARDOWN_INTR(parent, self, irq_res, ih);
- if (err)
- /* XXX or should we panic? */
- device_printf(self, "could not tear down irq, %d\n", err);
-bad3:
- device_delete_child(self, sc->sc_bus.bdev);
-bad2:
- bus_release_resource(self, SYS_RES_IOPORT, 0, irq_res);
-bad1:
- bus_release_resource(self, SYS_RES_MEMORY, PCI_CBMEM, io_res);
- return err;
-}
-
-static device_method_t ohci_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, ohci_pci_probe),
- DEVMETHOD(device_attach, ohci_pci_attach),
- DEVMETHOD(device_shutdown, bus_generic_shutdown),
-
- /* Bus interface */
- DEVMETHOD(bus_print_child, bus_generic_print_child),
-
- { 0, 0 }
-};
-
-static driver_t ohci_driver = {
- "ohci",
- ohci_methods,
- sizeof(ohci_softc_t),
-};
-
-static devclass_t ohci_devclass;
-
-DRIVER_MODULE(ohci, pci, ohci_driver, ohci_devclass, 0, 0);
diff --git a/sys/dev/usb/uhci_pci.c b/sys/dev/usb/uhci_pci.c
deleted file mode 100644
index 8859e5027f3f..000000000000
--- a/sys/dev/usb/uhci_pci.c
+++ /dev/null
@@ -1,324 +0,0 @@
-/*
- * Copyright (c) 1998 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Lennart Augustsson (augustss@carlstedt.se) at
- * Carlstedt Research & Technology.
- *
- * 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 the NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation 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 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.
- *
- * $FreeBSD$
- */
-
-/* Universal Host Controller Interface
- *
- * UHCI spec: http://www.intel.com/
- */
-
-/* The low level controller code for UHCI has been split into
- * PCI probes and UHCI specific code. This was done to facilitate the
- * sharing of code between *BSD's
- */
-
-#include "opt_bus.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/bus.h>
-#include <sys/proc.h>
-#include <sys/queue.h>
-#if defined(__FreeBSD__)
-#include <sys/bus.h>
-
-#include <machine/bus.h>
-#include <machine/resource.h>
-#include <sys/rman.h>
-#endif
-
-#include <pci/pcivar.h>
-#include <pci/pcireg.h>
-
-#include <dev/usb/usb.h>
-#include <dev/usb/usbdi.h>
-#include <dev/usb/usbdivar.h>
-#include <dev/usb/usb_mem.h>
-
-#include <dev/usb/uhcireg.h>
-#include <dev/usb/uhcivar.h>
-
-#define PCI_UHCI_VENDORID_INTEL 0x8086
-#define PCI_UHCI_VENDORID_VIA 0x1106
-
-#define PCI_UHCI_DEVICEID_PIIX3 0x70208086
-static const char *uhci_device_piix3 = "Intel 82371SB (PIIX3) USB controller";
-#define PCI_UHCI_DEVICEID_PIIX4 0x71128086
-#define PCI_UHCI_DEVICEID_PIIX4E 0x71128086 /* no separate stepping */
-static const char *uhci_device_piix4 = "Intel 82371AB/EB (PIIX4) USB controller";
-#define PCI_UHCI_DEVICEID_ICH 0x24128086
-static const char *uhci_device_ich = "Intel 82801AA (ICH) USB controller";
-#define PCI_UHCI_DEVICEID_ICH0 0x24228086
-static const char *uhci_device_ich0 = "Intel 82801AB (ICH0) USB controller";
-#define PCI_UHCI_DEVICEID_VT83C572 0x30381106
-static const char *uhci_device_vt83c572 = "VIA 83C572 USB controller";
-
-static const char *uhci_device_generic = "UHCI (generic) USB controller";
-
-#define PCI_UHCI_BASE_REG 0x20
-
-static int
-uhci_pci_suspend(device_t self)
-{
- uhci_softc_t *sc = device_get_softc(self);
- int err;
-
- err = bus_generic_suspend(self);
- if (err)
- return err;
- uhci_power(PWR_SUSPEND, sc);
-
- return 0;
-}
-
-static int
-uhci_pci_resume(device_t self)
-{
- uhci_softc_t *sc = device_get_softc(self);
-
- uhci_power(PWR_RESUME, sc);
- bus_generic_resume(self);
-
- return 0;
-}
-
-static const char *
-uhci_pci_match(device_t self)
-{
- u_int32_t device_id = pci_get_devid(self);
-
- if (device_id == PCI_UHCI_DEVICEID_PIIX3) {
- return (uhci_device_piix3);
- } else if (device_id == PCI_UHCI_DEVICEID_PIIX4) {
- return (uhci_device_piix4);
- } else if (device_id == PCI_UHCI_DEVICEID_ICH) {
- return (uhci_device_ich);
- } else if (device_id == PCI_UHCI_DEVICEID_ICH0) {
- return (uhci_device_ich0);
- } else if (device_id == PCI_UHCI_DEVICEID_VT83C572) {
- return (uhci_device_vt83c572);
- } else {
- if ( pci_get_class(self) == PCIC_SERIALBUS
- && pci_get_subclass(self) == PCIS_SERIALBUS_USB
- && pci_get_progif(self) == PCI_INTERFACE_UHCI) {
- return (uhci_device_generic);
- }
- }
-
- return NULL; /* dunno... */
-}
-
-static int
-uhci_pci_probe(device_t self)
-{
- const char *desc = uhci_pci_match(self);
- if (desc) {
- device_set_desc(self, desc);
- return 0;
- } else {
- return ENXIO;
- }
-}
-
-static int
-uhci_pci_attach(device_t self)
-{
- uhci_softc_t *sc = device_get_softc(self);
- device_t parent = device_get_parent(self);
- int rid;
- void *ih;
- struct resource *io_res, *irq_res;
- int intr;
- int err;
-
- /* For the moment, put in a message stating what is wrong */
- intr = pci_read_config(self, PCIR_INTLINE, 1);
- if (intr == 0 || intr == 255) {
- device_printf(self, "Invalid irq %d\n", intr);
- device_printf(self, "Please switch on USB support and switch PNP-OS to 'No' in BIOS\n");
- return ENXIO;
- }
-
- rid = PCI_UHCI_BASE_REG;
- io_res = bus_alloc_resource(self, SYS_RES_IOPORT, &rid,
- 0, ~0, 1, RF_ACTIVE);
- if (!io_res) {
- device_printf(self, "could not map ports\n");
- return ENXIO;
- }
-
- sc->iot = rman_get_bustag(io_res);
- sc->ioh = rman_get_bushandle(io_res);
-
- /* disable interrupts */
- bus_space_write_2(sc->iot, sc->ioh, UHCI_INTR, 0);
-
- rid = 0;
- irq_res = bus_alloc_resource(self, SYS_RES_IRQ, &rid, 0, ~0, 1,
- RF_SHAREABLE | RF_ACTIVE);
- if (irq_res == NULL) {
- device_printf(self, "could not allocate irq\n");
- err = ENOMEM;
- goto bad1;
- }
-
- sc->sc_bus.bdev = device_add_child(self, "usb", -1);
- if (!sc->sc_bus.bdev) {
- device_printf(self, "could not add USB device\n");
- err = ENOMEM;
- goto bad2;
- }
- device_set_ivars(sc->sc_bus.bdev, sc);
-
- switch (pci_get_devid(self)) {
- case PCI_UHCI_DEVICEID_PIIX3:
- device_set_desc(sc->sc_bus.bdev, uhci_device_piix3);
- sprintf(sc->sc_vendor, "Intel");
- break;
- case PCI_UHCI_DEVICEID_PIIX4:
- device_set_desc(sc->sc_bus.bdev, uhci_device_piix4);
- sprintf(sc->sc_vendor, "Intel");
- break;
- case PCI_UHCI_DEVICEID_ICH:
- device_set_desc(sc->sc_bus.bdev, uhci_device_ich);
- sprintf(sc->sc_vendor, "Intel");
- break;
- case PCI_UHCI_DEVICEID_ICH0:
- device_set_desc(sc->sc_bus.bdev, uhci_device_ich0);
- sprintf(sc->sc_vendor, "Intel");
- break;
- case PCI_UHCI_DEVICEID_VT83C572:
- device_set_desc(sc->sc_bus.bdev, uhci_device_vt83c572);
- sprintf(sc->sc_vendor, "VIA");
- break;
- default:
- device_printf(self, "(New UHCI DeviceId=0x%08x)\n",
- pci_get_devid(self));
- device_set_desc(sc->sc_bus.bdev, uhci_device_generic);
- sprintf(sc->sc_vendor, "(0x%08x)", pci_get_devid(self));
- }
-
- switch(pci_read_config(self, PCI_USBREV, 4) & PCI_USBREV_MASK) {
- case PCI_USBREV_PRE_1_0:
- sc->sc_bus.usbrev = USBREV_PRE_1_0;
- break;
- case PCI_USBREV_1_0:
- sc->sc_bus.usbrev = USBREV_1_0;
- break;
- default:
- sc->sc_bus.usbrev = USBREV_UNKNOWN;
- break;
- }
-
- err = BUS_SETUP_INTR(parent, self, irq_res, INTR_TYPE_BIO,
- (driver_intr_t *) uhci_intr, sc, &ih);
- if (err) {
- device_printf(self, "could not setup irq, %d\n", err);
- goto bad3;
- }
-
- /* Set the PIRQD enable bit and switch off all the others. We don't
- * want legacy support to interfere with us
- * XXX Does this also mean that the BIOS won't touch the keyboard
- * anymore if it is connected to the ports of the root hub?
- */
-#ifdef UHCI_DEBUG
- if (pci_read_config(self, PCI_LEGSUP, 4) != PCI_LEGSUP_USBPIRQDEN)
- device_printf(self, "LegSup = 0x%08x\n",
- pci_read_config(self, PCI_LEGSUP, 4));
-#endif
- pci_write_config(self, PCI_LEGSUP, PCI_LEGSUP_USBPIRQDEN, 4);
-
- err = uhci_init(sc);
- if (!err)
- err = device_probe_and_attach(sc->sc_bus.bdev);
-
- if (err) {
- device_printf(self, "USB init failed\n");
- err = EIO;
- goto bad4;
- }
-
- return 0;
-
-bad4:
- /* disable interrupts that might have been switched on
- * in uhci_init.
- */
- bus_space_write_2(sc->iot, sc->ioh, UHCI_INTR, 0);
-
- err = BUS_TEARDOWN_INTR(parent, self, irq_res, ih);
- if (err)
- /* XXX or should we panic? */
- device_printf(self, "could not tear down irq, %d\n",
- err);
-
-bad3:
- device_delete_child(self, sc->sc_bus.bdev);
-bad2:
- bus_release_resource(self, SYS_RES_IRQ, 0, irq_res);
-bad1:
- bus_release_resource(self, SYS_RES_IOPORT, PCI_UHCI_BASE_REG, io_res);
- return err;
-}
-
-static device_method_t uhci_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, uhci_pci_probe),
- DEVMETHOD(device_attach, uhci_pci_attach),
- DEVMETHOD(device_suspend, uhci_pci_suspend),
- DEVMETHOD(device_resume, uhci_pci_resume),
- DEVMETHOD(device_shutdown, bus_generic_shutdown),
-
- /* Bus interface */
- DEVMETHOD(bus_print_child, bus_generic_print_child),
-
- { 0, 0 }
-};
-
-static driver_t uhci_driver = {
- "uhci",
- uhci_methods,
- sizeof(uhci_softc_t),
-};
-
-static devclass_t uhci_devclass;
-
-DRIVER_MODULE(uhci, pci, uhci_driver, uhci_devclass, 0, 0);
diff --git a/sys/dev/vr/if_vr.c b/sys/dev/vr/if_vr.c
deleted file mode 100644
index 59c354fd06c6..000000000000
--- a/sys/dev/vr/if_vr.c
+++ /dev/null
@@ -1,1663 +0,0 @@
-/*
- * Copyright (c) 1997, 1998
- * Bill Paul <wpaul@ctr.columbia.edu>. 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 Bill Paul.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY Bill Paul 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 Bill Paul OR THE VOICES IN HIS HEAD
- * 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.
- *
- * $FreeBSD$
- */
-
-/*
- * VIA Rhine fast ethernet PCI NIC driver
- *
- * Supports various network adapters based on the VIA Rhine
- * and Rhine II PCI controllers, including the D-Link DFE530TX.
- * Datasheets are available at http://www.via.com.tw.
- *
- * Written by Bill Paul <wpaul@ctr.columbia.edu>
- * Electrical Engineering Department
- * Columbia University, New York City
- */
-
-/*
- * The VIA Rhine controllers are similar in some respects to the
- * the DEC tulip chips, except less complicated. The controller
- * uses an MII bus and an external physical layer interface. The
- * receiver has a one entry perfect filter and a 64-bit hash table
- * multicast filter. Transmit and receive descriptors are similar
- * to the tulip.
- *
- * The Rhine has a serious flaw in its transmit DMA mechanism:
- * transmit buffers must be longword aligned. Unfortunately,
- * FreeBSD doesn't guarantee that mbufs will be filled in starting
- * at longword boundaries, so we have to do a buffer copy before
- * transmission.
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/sockio.h>
-#include <sys/mbuf.h>
-#include <sys/malloc.h>
-#include <sys/kernel.h>
-#include <sys/socket.h>
-
-#include <net/if.h>
-#include <net/if_arp.h>
-#include <net/ethernet.h>
-#include <net/if_dl.h>
-#include <net/if_media.h>
-
-#include <net/bpf.h>
-
-#include "opt_bdg.h"
-#ifdef BRIDGE
-#include <net/bridge.h>
-#endif /* BRIDGE */
-
-#include <vm/vm.h> /* for vtophys */
-#include <vm/pmap.h> /* for vtophys */
-#include <machine/clock.h> /* for DELAY */
-#include <machine/bus_pio.h>
-#include <machine/bus_memio.h>
-#include <machine/bus.h>
-#include <machine/resource.h>
-#include <sys/bus.h>
-#include <sys/rman.h>
-
-#include <dev/mii/mii.h>
-#include <dev/mii/miivar.h>
-
-#include <pci/pcireg.h>
-#include <pci/pcivar.h>
-
-#define VR_USEIOSPACE
-
-#include <pci/if_vrreg.h>
-
-/* "controller miibus0" required. See GENERIC if you get errors here. */
-#include "miibus_if.h"
-
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif
-
-/*
- * Various supported device vendors/types and their names.
- */
-static struct vr_type vr_devs[] = {
- { VIA_VENDORID, VIA_DEVICEID_RHINE,
- "VIA VT3043 Rhine I 10/100BaseTX" },
- { VIA_VENDORID, VIA_DEVICEID_RHINE_II,
- "VIA VT86C100A Rhine II 10/100BaseTX" },
- { DELTA_VENDORID, DELTA_DEVICEID_RHINE_II,
- "Delta Electronics Rhine II 10/100BaseTX" },
- { ADDTRON_VENDORID, ADDTRON_DEVICEID_RHINE_II,
- "Addtron Technology Rhine II 10/100BaseTX" },
- { 0, 0, NULL }
-};
-
-static int vr_probe __P((device_t));
-static int vr_attach __P((device_t));
-static int vr_detach __P((device_t));
-
-static int vr_newbuf __P((struct vr_softc *,
- struct vr_chain_onefrag *,
- struct mbuf *));
-static int vr_encap __P((struct vr_softc *, struct vr_chain *,
- struct mbuf * ));
-
-static void vr_rxeof __P((struct vr_softc *));
-static void vr_rxeoc __P((struct vr_softc *));
-static void vr_txeof __P((struct vr_softc *));
-static void vr_txeoc __P((struct vr_softc *));
-static void vr_tick __P((void *));
-static void vr_intr __P((void *));
-static void vr_start __P((struct ifnet *));
-static int vr_ioctl __P((struct ifnet *, u_long, caddr_t));
-static void vr_init __P((void *));
-static void vr_stop __P((struct vr_softc *));
-static void vr_watchdog __P((struct ifnet *));
-static void vr_shutdown __P((device_t));
-static int vr_ifmedia_upd __P((struct ifnet *));
-static void vr_ifmedia_sts __P((struct ifnet *, struct ifmediareq *));
-
-static void vr_mii_sync __P((struct vr_softc *));
-static void vr_mii_send __P((struct vr_softc *, u_int32_t, int));
-static int vr_mii_readreg __P((struct vr_softc *, struct vr_mii_frame *));
-static int vr_mii_writereg __P((struct vr_softc *, struct vr_mii_frame *));
-static int vr_miibus_readreg __P((device_t, int, int));
-static int vr_miibus_writereg __P((device_t, int, int, int));
-static void vr_miibus_statchg __P((device_t));
-
-static void vr_setcfg __P((struct vr_softc *, int));
-static u_int8_t vr_calchash __P((u_int8_t *));
-static void vr_setmulti __P((struct vr_softc *));
-static void vr_reset __P((struct vr_softc *));
-static int vr_list_rx_init __P((struct vr_softc *));
-static int vr_list_tx_init __P((struct vr_softc *));
-
-#ifdef VR_USEIOSPACE
-#define VR_RES SYS_RES_IOPORT
-#define VR_RID VR_PCI_LOIO
-#else
-#define VR_RES SYS_RES_MEMORY
-#define VR_RID VR_PCI_LOMEM
-#endif
-
-static device_method_t vr_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, vr_probe),
- DEVMETHOD(device_attach, vr_attach),
- DEVMETHOD(device_detach, vr_detach),
- DEVMETHOD(device_shutdown, vr_shutdown),
-
- /* bus interface */
- DEVMETHOD(bus_print_child, bus_generic_print_child),
- DEVMETHOD(bus_driver_added, bus_generic_driver_added),
-
- /* MII interface */
- DEVMETHOD(miibus_readreg, vr_miibus_readreg),
- DEVMETHOD(miibus_writereg, vr_miibus_writereg),
- DEVMETHOD(miibus_statchg, vr_miibus_statchg),
-
- { 0, 0 }
-};
-
-static driver_t vr_driver = {
- "vr",
- vr_methods,
- sizeof(struct vr_softc)
-};
-
-static devclass_t vr_devclass;
-
-DRIVER_MODULE(if_vr, pci, vr_driver, vr_devclass, 0, 0);
-DRIVER_MODULE(miibus, vr, miibus_driver, miibus_devclass, 0, 0);
-
-#define VR_SETBIT(sc, reg, x) \
- CSR_WRITE_1(sc, reg, \
- CSR_READ_1(sc, reg) | x)
-
-#define VR_CLRBIT(sc, reg, x) \
- CSR_WRITE_1(sc, reg, \
- CSR_READ_1(sc, reg) & ~x)
-
-#define VR_SETBIT16(sc, reg, x) \
- CSR_WRITE_2(sc, reg, \
- CSR_READ_2(sc, reg) | x)
-
-#define VR_CLRBIT16(sc, reg, x) \
- CSR_WRITE_2(sc, reg, \
- CSR_READ_2(sc, reg) & ~x)
-
-#define VR_SETBIT32(sc, reg, x) \
- CSR_WRITE_4(sc, reg, \
- CSR_READ_4(sc, reg) | x)
-
-#define VR_CLRBIT32(sc, reg, x) \
- CSR_WRITE_4(sc, reg, \
- CSR_READ_4(sc, reg) & ~x)
-
-#define SIO_SET(x) \
- CSR_WRITE_1(sc, VR_MIICMD, \
- CSR_READ_1(sc, VR_MIICMD) | x)
-
-#define SIO_CLR(x) \
- CSR_WRITE_1(sc, VR_MIICMD, \
- CSR_READ_1(sc, VR_MIICMD) & ~x)
-
-/*
- * Sync the PHYs by setting data bit and strobing the clock 32 times.
- */
-static void vr_mii_sync(sc)
- struct vr_softc *sc;
-{
- register int i;
-
- SIO_SET(VR_MIICMD_DIR|VR_MIICMD_DATAIN);
-
- for (i = 0; i < 32; i++) {
- SIO_SET(VR_MIICMD_CLK);
- DELAY(1);
- SIO_CLR(VR_MIICMD_CLK);
- DELAY(1);
- }
-
- return;
-}
-
-/*
- * Clock a series of bits through the MII.
- */
-static void vr_mii_send(sc, bits, cnt)
- struct vr_softc *sc;
- u_int32_t bits;
- int cnt;
-{
- int i;
-
- SIO_CLR(VR_MIICMD_CLK);
-
- for (i = (0x1 << (cnt - 1)); i; i >>= 1) {
- if (bits & i) {
- SIO_SET(VR_MIICMD_DATAIN);
- } else {
- SIO_CLR(VR_MIICMD_DATAIN);
- }
- DELAY(1);
- SIO_CLR(VR_MIICMD_CLK);
- DELAY(1);
- SIO_SET(VR_MIICMD_CLK);
- }
-}
-
-/*
- * Read an PHY register through the MII.
- */
-static int vr_mii_readreg(sc, frame)
- struct vr_softc *sc;
- struct vr_mii_frame *frame;
-
-{
- int i, ack, s;
-
- s = splimp();
-
- /*
- * Set up frame for RX.
- */
- frame->mii_stdelim = VR_MII_STARTDELIM;
- frame->mii_opcode = VR_MII_READOP;
- frame->mii_turnaround = 0;
- frame->mii_data = 0;
-
- CSR_WRITE_1(sc, VR_MIICMD, 0);
- VR_SETBIT(sc, VR_MIICMD, VR_MIICMD_DIRECTPGM);
-
- /*
- * Turn on data xmit.
- */
- SIO_SET(VR_MIICMD_DIR);
-
- vr_mii_sync(sc);
-
- /*
- * Send command/address info.
- */
- vr_mii_send(sc, frame->mii_stdelim, 2);
- vr_mii_send(sc, frame->mii_opcode, 2);
- vr_mii_send(sc, frame->mii_phyaddr, 5);
- vr_mii_send(sc, frame->mii_regaddr, 5);
-
- /* Idle bit */
- SIO_CLR((VR_MIICMD_CLK|VR_MIICMD_DATAIN));
- DELAY(1);
- SIO_SET(VR_MIICMD_CLK);
- DELAY(1);
-
- /* Turn off xmit. */
- SIO_CLR(VR_MIICMD_DIR);
-
- /* Check for ack */
- SIO_CLR(VR_MIICMD_CLK);
- DELAY(1);
- SIO_SET(VR_MIICMD_CLK);
- DELAY(1);
- ack = CSR_READ_4(sc, VR_MIICMD) & VR_MIICMD_DATAOUT;
-
- /*
- * Now try reading data bits. If the ack failed, we still
- * need to clock through 16 cycles to keep the PHY(s) in sync.
- */
- if (ack) {
- for(i = 0; i < 16; i++) {
- SIO_CLR(VR_MIICMD_CLK);
- DELAY(1);
- SIO_SET(VR_MIICMD_CLK);
- DELAY(1);
- }
- goto fail;
- }
-
- for (i = 0x8000; i; i >>= 1) {
- SIO_CLR(VR_MIICMD_CLK);
- DELAY(1);
- if (!ack) {
- if (CSR_READ_4(sc, VR_MIICMD) & VR_MIICMD_DATAOUT)
- frame->mii_data |= i;
- DELAY(1);
- }
- SIO_SET(VR_MIICMD_CLK);
- DELAY(1);
- }
-
-fail:
-
- SIO_CLR(VR_MIICMD_CLK);
- DELAY(1);
- SIO_SET(VR_MIICMD_CLK);
- DELAY(1);
-
- splx(s);
-
- if (ack)
- return(1);
- return(0);
-}
-
-/*
- * Write to a PHY register through the MII.
- */
-static int vr_mii_writereg(sc, frame)
- struct vr_softc *sc;
- struct vr_mii_frame *frame;
-
-{
- int s;
-
- s = splimp();
-
- CSR_WRITE_1(sc, VR_MIICMD, 0);
- VR_SETBIT(sc, VR_MIICMD, VR_MIICMD_DIRECTPGM);
-
- /*
- * Set up frame for TX.
- */
-
- frame->mii_stdelim = VR_MII_STARTDELIM;
- frame->mii_opcode = VR_MII_WRITEOP;
- frame->mii_turnaround = VR_MII_TURNAROUND;
-
- /*
- * Turn on data output.
- */
- SIO_SET(VR_MIICMD_DIR);
-
- vr_mii_sync(sc);
-
- vr_mii_send(sc, frame->mii_stdelim, 2);
- vr_mii_send(sc, frame->mii_opcode, 2);
- vr_mii_send(sc, frame->mii_phyaddr, 5);
- vr_mii_send(sc, frame->mii_regaddr, 5);
- vr_mii_send(sc, frame->mii_turnaround, 2);
- vr_mii_send(sc, frame->mii_data, 16);
-
- /* Idle bit. */
- SIO_SET(VR_MIICMD_CLK);
- DELAY(1);
- SIO_CLR(VR_MIICMD_CLK);
- DELAY(1);
-
- /*
- * Turn off xmit.
- */
- SIO_CLR(VR_MIICMD_DIR);
-
- splx(s);
-
- return(0);
-}
-
-static int vr_miibus_readreg(dev, phy, reg)
- device_t dev;
- int phy, reg;
-{
- struct vr_softc *sc;
- struct vr_mii_frame frame;
-
- sc = device_get_softc(dev);
- bzero((char *)&frame, sizeof(frame));
-
- frame.mii_phyaddr = phy;
- frame.mii_regaddr = reg;
- vr_mii_readreg(sc, &frame);
-
- return(frame.mii_data);
-}
-
-static int vr_miibus_writereg(dev, phy, reg, data)
- device_t dev;
- u_int16_t phy, reg, data;
-{
- struct vr_softc *sc;
- struct vr_mii_frame frame;
-
- sc = device_get_softc(dev);
- bzero((char *)&frame, sizeof(frame));
-
- frame.mii_phyaddr = phy;
- frame.mii_regaddr = reg;
- frame.mii_data = data;
-
- vr_mii_writereg(sc, &frame);
-
- return(0);
-}
-
-static void vr_miibus_statchg(dev)
- device_t dev;
-{
- struct vr_softc *sc;
- struct mii_data *mii;
-
- sc = device_get_softc(dev);
- mii = device_get_softc(sc->vr_miibus);
- vr_setcfg(sc, mii->mii_media_active);
-
- return;
-}
-
-/*
- * Calculate CRC of a multicast group address, return the lower 6 bits.
- */
-static u_int8_t vr_calchash(addr)
- u_int8_t *addr;
-{
- u_int32_t crc, carry;
- int i, j;
- u_int8_t c;
-
- /* Compute CRC for the address value. */
- crc = 0xFFFFFFFF; /* initial value */
-
- for (i = 0; i < 6; i++) {
- c = *(addr + i);
- for (j = 0; j < 8; j++) {
- carry = ((crc & 0x80000000) ? 1 : 0) ^ (c & 0x01);
- crc <<= 1;
- c >>= 1;
- if (carry)
- crc = (crc ^ 0x04c11db6) | carry;
- }
- }
-
- /* return the filter bit position */
- return((crc >> 26) & 0x0000003F);
-}
-
-/*
- * Program the 64-bit multicast hash filter.
- */
-static void vr_setmulti(sc)
- struct vr_softc *sc;
-{
- struct ifnet *ifp;
- int h = 0;
- u_int32_t hashes[2] = { 0, 0 };
- struct ifmultiaddr *ifma;
- u_int8_t rxfilt;
- int mcnt = 0;
-
- ifp = &sc->arpcom.ac_if;
-
- rxfilt = CSR_READ_1(sc, VR_RXCFG);
-
- if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) {
- rxfilt |= VR_RXCFG_RX_MULTI;
- CSR_WRITE_1(sc, VR_RXCFG, rxfilt);
- CSR_WRITE_4(sc, VR_MAR0, 0xFFFFFFFF);
- CSR_WRITE_4(sc, VR_MAR1, 0xFFFFFFFF);
- return;
- }
-
- /* first, zot all the existing hash bits */
- CSR_WRITE_4(sc, VR_MAR0, 0);
- CSR_WRITE_4(sc, VR_MAR1, 0);
-
- /* now program new ones */
- for (ifma = ifp->if_multiaddrs.lh_first; ifma != NULL;
- ifma = ifma->ifma_link.le_next) {
- if (ifma->ifma_addr->sa_family != AF_LINK)
- continue;
- h = vr_calchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
- if (h < 32)
- hashes[0] |= (1 << h);
- else
- hashes[1] |= (1 << (h - 32));
- mcnt++;
- }
-
- if (mcnt)
- rxfilt |= VR_RXCFG_RX_MULTI;
- else
- rxfilt &= ~VR_RXCFG_RX_MULTI;
-
- CSR_WRITE_4(sc, VR_MAR0, hashes[0]);
- CSR_WRITE_4(sc, VR_MAR1, hashes[1]);
- CSR_WRITE_1(sc, VR_RXCFG, rxfilt);
-
- return;
-}
-
-/*
- * In order to fiddle with the
- * 'full-duplex' and '100Mbps' bits in the netconfig register, we
- * first have to put the transmit and/or receive logic in the idle state.
- */
-static void vr_setcfg(sc, media)
- struct vr_softc *sc;
- int media;
-{
- int restart = 0;
-
- if (CSR_READ_2(sc, VR_COMMAND) & (VR_CMD_TX_ON|VR_CMD_RX_ON)) {
- restart = 1;
- VR_CLRBIT16(sc, VR_COMMAND, (VR_CMD_TX_ON|VR_CMD_RX_ON));
- }
-
- if ((media & IFM_GMASK) == IFM_FDX)
- VR_SETBIT16(sc, VR_COMMAND, VR_CMD_FULLDUPLEX);
- else
- VR_CLRBIT16(sc, VR_COMMAND, VR_CMD_FULLDUPLEX);
-
- if (restart)
- VR_SETBIT16(sc, VR_COMMAND, VR_CMD_TX_ON|VR_CMD_RX_ON);
-
- return;
-}
-
-static void vr_reset(sc)
- struct vr_softc *sc;
-{
- register int i;
-
- VR_SETBIT16(sc, VR_COMMAND, VR_CMD_RESET);
-
- for (i = 0; i < VR_TIMEOUT; i++) {
- DELAY(10);
- if (!(CSR_READ_2(sc, VR_COMMAND) & VR_CMD_RESET))
- break;
- }
- if (i == VR_TIMEOUT)
- printf("vr%d: reset never completed!\n", sc->vr_unit);
-
- /* Wait a little while for the chip to get its brains in order. */
- DELAY(1000);
-
- return;
-}
-
-/*
- * Probe for a VIA Rhine chip. Check the PCI vendor and device
- * IDs against our list and return a device name if we find a match.
- */
-static int vr_probe(dev)
- device_t dev;
-{
- struct vr_type *t;
-
- t = vr_devs;
-
- while(t->vr_name != NULL) {
- if ((pci_get_vendor(dev) == t->vr_vid) &&
- (pci_get_device(dev) == t->vr_did)) {
- device_set_desc(dev, t->vr_name);
- return(0);
- }
- t++;
- }
-
- return(ENXIO);
-}
-
-/*
- * Attach the interface. Allocate softc structures, do ifmedia
- * setup and ethernet/BPF attach.
- */
-static int vr_attach(dev)
- device_t dev;
-{
- int i, s;
- u_char eaddr[ETHER_ADDR_LEN];
- u_int32_t command;
- struct vr_softc *sc;
- struct ifnet *ifp;
- int unit, error = 0, rid;
-
- s = splimp();
-
- sc = device_get_softc(dev);
- unit = device_get_unit(dev);
- bzero(sc, sizeof(struct vr_softc *));
-
- /*
- * Handle power management nonsense.
- */
-
- command = pci_read_config(dev, VR_PCI_CAPID, 4) & 0x000000FF;
- if (command == 0x01) {
-
- command = pci_read_config(dev, VR_PCI_PWRMGMTCTRL, 4);
- if (command & VR_PSTATE_MASK) {
- u_int32_t iobase, membase, irq;
-
- /* Save important PCI config data. */
- iobase = pci_read_config(dev, VR_PCI_LOIO, 4);
- membase = pci_read_config(dev, VR_PCI_LOMEM, 4);
- irq = pci_read_config(dev, VR_PCI_INTLINE, 4);
-
- /* Reset the power state. */
- printf("vr%d: chip is in D%d power mode "
- "-- setting to D0\n", unit, command & VR_PSTATE_MASK);
- command &= 0xFFFFFFFC;
- pci_write_config(dev, VR_PCI_PWRMGMTCTRL, command, 4);
-
- /* Restore PCI config data. */
- pci_write_config(dev, VR_PCI_LOIO, iobase, 4);
- pci_write_config(dev, VR_PCI_LOMEM, membase, 4);
- pci_write_config(dev, VR_PCI_INTLINE, irq, 4);
- }
- }
-
- /*
- * Map control/status registers.
- */
- command = pci_read_config(dev, PCI_COMMAND_STATUS_REG, 4);
- command |= (PCIM_CMD_PORTEN|PCIM_CMD_MEMEN|PCIM_CMD_BUSMASTEREN);
- pci_write_config(dev, PCI_COMMAND_STATUS_REG, command, 4);
- command = pci_read_config(dev, PCI_COMMAND_STATUS_REG, 4);
-
-#ifdef VR_USEIOSPACE
- if (!(command & PCIM_CMD_PORTEN)) {
- printf("vr%d: failed to enable I/O ports!\n", unit);
- free(sc, M_DEVBUF);
- goto fail;
- }
-#else
- if (!(command & PCIM_CMD_MEMEN)) {
- printf("vr%d: failed to enable memory mapping!\n", unit);
- goto fail;
- }
-#endif
-
- rid = VR_RID;
- sc->vr_res = bus_alloc_resource(dev, VR_RES, &rid,
- 0, ~0, 1, RF_ACTIVE);
-
- if (sc->vr_res == NULL) {
- printf("vr%d: couldn't map ports/memory\n", unit);
- error = ENXIO;
- goto fail;
- }
-
- sc->vr_btag = rman_get_bustag(sc->vr_res);
- sc->vr_bhandle = rman_get_bushandle(sc->vr_res);
-
- /* Allocate interrupt */
- rid = 0;
- sc->vr_irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1,
- RF_SHAREABLE | RF_ACTIVE);
-
- if (sc->vr_irq == NULL) {
- printf("vr%d: couldn't map interrupt\n", unit);
- bus_release_resource(dev, VR_RES, VR_RID, sc->vr_res);
- error = ENXIO;
- goto fail;
- }
-
- error = bus_setup_intr(dev, sc->vr_irq, INTR_TYPE_NET,
- vr_intr, sc, &sc->vr_intrhand);
-
- if (error) {
- bus_release_resource(dev, SYS_RES_IRQ, 0, sc->vr_irq);
- bus_release_resource(dev, VR_RES, VR_RID, sc->vr_res);
- printf("vr%d: couldn't set up irq\n", unit);
- goto fail;
- }
-
- /* Reset the adapter. */
- vr_reset(sc);
-
- /*
- * Get station address. The way the Rhine chips work,
- * you're not allowed to directly access the EEPROM once
- * they've been programmed a special way. Consequently,
- * we need to read the node address from the PAR0 and PAR1
- * registers.
- */
- VR_SETBIT(sc, VR_EECSR, VR_EECSR_LOAD);
- DELAY(200);
- for (i = 0; i < ETHER_ADDR_LEN; i++)
- eaddr[i] = CSR_READ_1(sc, VR_PAR0 + i);
-
- /*
- * A Rhine chip was detected. Inform the world.
- */
- printf("vr%d: Ethernet address: %6D\n", unit, eaddr, ":");
-
- sc->vr_unit = unit;
- bcopy(eaddr, (char *)&sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
-
- sc->vr_ldata = contigmalloc(sizeof(struct vr_list_data), M_DEVBUF,
- M_NOWAIT, 0, 0xffffffff, PAGE_SIZE, 0);
-
- if (sc->vr_ldata == NULL) {
- printf("vr%d: no memory for list buffers!\n", unit);
- bus_teardown_intr(dev, sc->vr_irq, sc->vr_intrhand);
- bus_release_resource(dev, SYS_RES_IRQ, 0, sc->vr_irq);
- bus_release_resource(dev, VR_RES, VR_RID, sc->vr_res);
- error = ENXIO;
- goto fail;
- }
-
- bzero(sc->vr_ldata, sizeof(struct vr_list_data));
-
- ifp = &sc->arpcom.ac_if;
- ifp->if_softc = sc;
- ifp->if_unit = unit;
- ifp->if_name = "vr";
- ifp->if_mtu = ETHERMTU;
- ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
- ifp->if_ioctl = vr_ioctl;
- ifp->if_output = ether_output;
- ifp->if_start = vr_start;
- ifp->if_watchdog = vr_watchdog;
- ifp->if_init = vr_init;
- ifp->if_baudrate = 10000000;
- ifp->if_snd.ifq_maxlen = VR_TX_LIST_CNT - 1;
-
- /*
- * Do MII setup.
- */
- if (mii_phy_probe(dev, &sc->vr_miibus,
- vr_ifmedia_upd, vr_ifmedia_sts)) {
- printf("vr%d: MII without any phy!\n", sc->vr_unit);
- bus_teardown_intr(dev, sc->vr_irq, sc->vr_intrhand);
- bus_release_resource(dev, SYS_RES_IRQ, 0, sc->vr_irq);
- bus_release_resource(dev, VR_RES, VR_RID, sc->vr_res);
- contigfree(sc->vr_ldata,
- sizeof(struct vr_list_data), M_DEVBUF);
- error = ENXIO;
- goto fail;
- }
-
- callout_handle_init(&sc->vr_stat_ch);
-
- /*
- * Call MI attach routines.
- */
- if_attach(ifp);
- ether_ifattach(ifp);
-
- bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
-
-fail:
- splx(s);
- return(error);
-}
-
-static int vr_detach(dev)
- device_t dev;
-{
- struct vr_softc *sc;
- struct ifnet *ifp;
- int s;
-
- s = splimp();
-
- sc = device_get_softc(dev);
- ifp = &sc->arpcom.ac_if;
-
- vr_stop(sc);
- if_detach(ifp);
-
- bus_generic_detach(dev);
- device_delete_child(dev, sc->vr_miibus);
-
- bus_teardown_intr(dev, sc->vr_irq, sc->vr_intrhand);
- bus_release_resource(dev, SYS_RES_IRQ, 0, sc->vr_irq);
- bus_release_resource(dev, VR_RES, VR_RID, sc->vr_res);
-
- contigfree(sc->vr_ldata, sizeof(struct vr_list_data), M_DEVBUF);
-
- splx(s);
-
- return(0);
-}
-
-/*
- * Initialize the transmit descriptors.
- */
-static int vr_list_tx_init(sc)
- struct vr_softc *sc;
-{
- struct vr_chain_data *cd;
- struct vr_list_data *ld;
- int i;
-
- cd = &sc->vr_cdata;
- ld = sc->vr_ldata;
- for (i = 0; i < VR_TX_LIST_CNT; i++) {
- cd->vr_tx_chain[i].vr_ptr = &ld->vr_tx_list[i];
- if (i == (VR_TX_LIST_CNT - 1))
- cd->vr_tx_chain[i].vr_nextdesc =
- &cd->vr_tx_chain[0];
- else
- cd->vr_tx_chain[i].vr_nextdesc =
- &cd->vr_tx_chain[i + 1];
- }
-
- cd->vr_tx_free = &cd->vr_tx_chain[0];
- cd->vr_tx_tail = cd->vr_tx_head = NULL;
-
- return(0);
-}
-
-
-/*
- * Initialize the RX descriptors and allocate mbufs for them. Note that
- * we arrange the descriptors in a closed ring, so that the last descriptor
- * points back to the first.
- */
-static int vr_list_rx_init(sc)
- struct vr_softc *sc;
-{
- struct vr_chain_data *cd;
- struct vr_list_data *ld;
- int i;
-
- cd = &sc->vr_cdata;
- ld = sc->vr_ldata;
-
- for (i = 0; i < VR_RX_LIST_CNT; i++) {
- cd->vr_rx_chain[i].vr_ptr =
- (struct vr_desc *)&ld->vr_rx_list[i];
- if (vr_newbuf(sc, &cd->vr_rx_chain[i], NULL) == ENOBUFS)
- return(ENOBUFS);
- if (i == (VR_RX_LIST_CNT - 1)) {
- cd->vr_rx_chain[i].vr_nextdesc =
- &cd->vr_rx_chain[0];
- ld->vr_rx_list[i].vr_next =
- vtophys(&ld->vr_rx_list[0]);
- } else {
- cd->vr_rx_chain[i].vr_nextdesc =
- &cd->vr_rx_chain[i + 1];
- ld->vr_rx_list[i].vr_next =
- vtophys(&ld->vr_rx_list[i + 1]);
- }
- }
-
- cd->vr_rx_head = &cd->vr_rx_chain[0];
-
- return(0);
-}
-
-/*
- * Initialize an RX descriptor and attach an MBUF cluster.
- * Note: the length fields are only 11 bits wide, which means the
- * largest size we can specify is 2047. This is important because
- * MCLBYTES is 2048, so we have to subtract one otherwise we'll
- * overflow the field and make a mess.
- */
-static int vr_newbuf(sc, c, m)
- struct vr_softc *sc;
- struct vr_chain_onefrag *c;
- struct mbuf *m;
-{
- struct mbuf *m_new = NULL;
-
- if (m == NULL) {
- MGETHDR(m_new, M_DONTWAIT, MT_DATA);
- if (m_new == NULL) {
- printf("vr%d: no memory for rx list "
- "-- packet dropped!\n", sc->vr_unit);
- return(ENOBUFS);
- }
-
- MCLGET(m_new, M_DONTWAIT);
- if (!(m_new->m_flags & M_EXT)) {
- printf("vr%d: no memory for rx list "
- "-- packet dropped!\n", sc->vr_unit);
- m_freem(m_new);
- return(ENOBUFS);
- }
- m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
- } else {
- m_new = m;
- m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
- m_new->m_data = m_new->m_ext.ext_buf;
- }
-
- m_adj(m_new, sizeof(u_int64_t));
-
- c->vr_mbuf = m_new;
- c->vr_ptr->vr_status = VR_RXSTAT;
- c->vr_ptr->vr_data = vtophys(mtod(m_new, caddr_t));
- c->vr_ptr->vr_ctl = VR_RXCTL | VR_RXLEN;
-
- return(0);
-}
-
-/*
- * A frame has been uploaded: pass the resulting mbuf chain up to
- * the higher level protocols.
- */
-static void vr_rxeof(sc)
- struct vr_softc *sc;
-{
- struct ether_header *eh;
- struct mbuf *m;
- struct ifnet *ifp;
- struct vr_chain_onefrag *cur_rx;
- int total_len = 0;
- u_int32_t rxstat;
-
- ifp = &sc->arpcom.ac_if;
-
- while(!((rxstat = sc->vr_cdata.vr_rx_head->vr_ptr->vr_status) &
- VR_RXSTAT_OWN)) {
- struct mbuf *m0 = NULL;
-
- cur_rx = sc->vr_cdata.vr_rx_head;
- sc->vr_cdata.vr_rx_head = cur_rx->vr_nextdesc;
- m = cur_rx->vr_mbuf;
-
- /*
- * If an error occurs, update stats, clear the
- * status word and leave the mbuf cluster in place:
- * it should simply get re-used next time this descriptor
- * comes up in the ring.
- */
- if (rxstat & VR_RXSTAT_RXERR) {
- ifp->if_ierrors++;
- printf("vr%d: rx error: ", sc->vr_unit);
- switch(rxstat & 0x000000FF) {
- case VR_RXSTAT_CRCERR:
- printf("crc error\n");
- break;
- case VR_RXSTAT_FRAMEALIGNERR:
- printf("frame alignment error\n");
- break;
- case VR_RXSTAT_FIFOOFLOW:
- printf("FIFO overflow\n");
- break;
- case VR_RXSTAT_GIANT:
- printf("received giant packet\n");
- break;
- case VR_RXSTAT_RUNT:
- printf("received runt packet\n");
- break;
- case VR_RXSTAT_BUSERR:
- printf("system bus error\n");
- break;
- case VR_RXSTAT_BUFFERR:
- printf("rx buffer error\n");
- break;
- default:
- printf("unknown rx error\n");
- break;
- }
- vr_newbuf(sc, cur_rx, m);
- continue;
- }
-
- /* No errors; receive the packet. */
- total_len = VR_RXBYTES(cur_rx->vr_ptr->vr_status);
-
- /*
- * XXX The VIA Rhine chip includes the CRC with every
- * received frame, and there's no way to turn this
- * behavior off (at least, I can't find anything in
- * the manual that explains how to do it) so we have
- * to trim off the CRC manually.
- */
- total_len -= ETHER_CRC_LEN;
-
- m0 = m_devget(mtod(m, char *) - ETHER_ALIGN,
- total_len + ETHER_ALIGN, 0, ifp, NULL);
- vr_newbuf(sc, cur_rx, m);
- if (m0 == NULL) {
- ifp->if_ierrors++;
- continue;
- }
- m_adj(m0, ETHER_ALIGN);
- m = m0;
-
- ifp->if_ipackets++;
- eh = mtod(m, struct ether_header *);
-
- /*
- * Handle BPF listeners. Let the BPF user see the packet, but
- * don't pass it up to the ether_input() layer unless it's
- * a broadcast packet, multicast packet, matches our ethernet
- * address or the interface is in promiscuous mode.
- */
- if (ifp->if_bpf) {
- bpf_mtap(ifp, m);
- if (ifp->if_flags & IFF_PROMISC &&
- (bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr,
- ETHER_ADDR_LEN) &&
- (eh->ether_dhost[0] & 1) == 0)) {
- m_freem(m);
- continue;
- }
- }
-
-#ifdef BRIDGE
- if (do_bridge) {
- struct ifnet *bdg_ifp;
- bdg_ifp = bridge_in(m);
- if (bdg_ifp != BDG_LOCAL && bdg_ifp != BDG_DROP)
- bdg_forward(&m, bdg_ifp);
- if (((bdg_ifp != BDG_LOCAL) && (bdg_ifp != BDG_BCAST) &&
- (bdg_ifp != BDG_MCAST)) || bdg_ifp == BDG_DROP) {
- m_freem(m);
- continue;
- }
- }
-#endif /* BRIDGE */
-
- /* Remove header from mbuf and pass it on. */
- m_adj(m, sizeof(struct ether_header));
- ether_input(ifp, eh, m);
- }
-
- return;
-}
-
-void vr_rxeoc(sc)
- struct vr_softc *sc;
-{
-
- vr_rxeof(sc);
- VR_CLRBIT16(sc, VR_COMMAND, VR_CMD_RX_ON);
- CSR_WRITE_4(sc, VR_RXADDR, vtophys(sc->vr_cdata.vr_rx_head->vr_ptr));
- VR_SETBIT16(sc, VR_COMMAND, VR_CMD_RX_ON);
- VR_SETBIT16(sc, VR_COMMAND, VR_CMD_RX_GO);
-
- return;
-}
-
-/*
- * A frame was downloaded to the chip. It's safe for us to clean up
- * the list buffers.
- */
-
-static void vr_txeof(sc)
- struct vr_softc *sc;
-{
- struct vr_chain *cur_tx;
- struct ifnet *ifp;
-
- ifp = &sc->arpcom.ac_if;
-
- /* Clear the timeout timer. */
- ifp->if_timer = 0;
-
- /* Sanity check. */
- if (sc->vr_cdata.vr_tx_head == NULL)
- return;
-
- /*
- * Go through our tx list and free mbufs for those
- * frames that have been transmitted.
- */
- while(sc->vr_cdata.vr_tx_head->vr_mbuf != NULL) {
- u_int32_t txstat;
-
- cur_tx = sc->vr_cdata.vr_tx_head;
- txstat = cur_tx->vr_ptr->vr_status;
-
- if (txstat & VR_TXSTAT_OWN)
- break;
-
- if (txstat & VR_TXSTAT_ERRSUM) {
- ifp->if_oerrors++;
- if (txstat & VR_TXSTAT_DEFER)
- ifp->if_collisions++;
- if (txstat & VR_TXSTAT_LATECOLL)
- ifp->if_collisions++;
- }
-
- ifp->if_collisions +=(txstat & VR_TXSTAT_COLLCNT) >> 3;
-
- ifp->if_opackets++;
- if (cur_tx->vr_mbuf != NULL) {
- m_freem(cur_tx->vr_mbuf);
- cur_tx->vr_mbuf = NULL;
- }
-
- if (sc->vr_cdata.vr_tx_head == sc->vr_cdata.vr_tx_tail) {
- sc->vr_cdata.vr_tx_head = NULL;
- sc->vr_cdata.vr_tx_tail = NULL;
- break;
- }
-
- sc->vr_cdata.vr_tx_head = cur_tx->vr_nextdesc;
- }
-
- return;
-}
-
-/*
- * TX 'end of channel' interrupt handler.
- */
-static void vr_txeoc(sc)
- struct vr_softc *sc;
-{
- struct ifnet *ifp;
-
- ifp = &sc->arpcom.ac_if;
-
- ifp->if_timer = 0;
-
- if (sc->vr_cdata.vr_tx_head == NULL) {
- ifp->if_flags &= ~IFF_OACTIVE;
- sc->vr_cdata.vr_tx_tail = NULL;
- }
-
- return;
-}
-
-static void vr_tick(xsc)
- void *xsc;
-{
- struct vr_softc *sc;
- struct mii_data *mii;
- int s;
-
- s = splimp();
-
- sc = xsc;
- mii = device_get_softc(sc->vr_miibus);
- mii_tick(mii);
-
- sc->vr_stat_ch = timeout(vr_tick, sc, hz);
-
- splx(s);
-
- return;
-}
-
-static void vr_intr(arg)
- void *arg;
-{
- struct vr_softc *sc;
- struct ifnet *ifp;
- u_int16_t status;
-
- sc = arg;
- ifp = &sc->arpcom.ac_if;
-
- /* Supress unwanted interrupts. */
- if (!(ifp->if_flags & IFF_UP)) {
- vr_stop(sc);
- return;
- }
-
- /* Disable interrupts. */
- CSR_WRITE_2(sc, VR_IMR, 0x0000);
-
- for (;;) {
-
- status = CSR_READ_2(sc, VR_ISR);
- if (status)
- CSR_WRITE_2(sc, VR_ISR, status);
-
- if ((status & VR_INTRS) == 0)
- break;
-
- if (status & VR_ISR_RX_OK)
- vr_rxeof(sc);
-
- if ((status & VR_ISR_RX_ERR) || (status & VR_ISR_RX_NOBUF) ||
- (status & VR_ISR_RX_NOBUF) || (status & VR_ISR_RX_OFLOW) ||
- (status & VR_ISR_RX_DROPPED)) {
- vr_rxeof(sc);
- vr_rxeoc(sc);
- }
-
- if (status & VR_ISR_TX_OK) {
- vr_txeof(sc);
- vr_txeoc(sc);
- }
-
- if ((status & VR_ISR_TX_UNDERRUN)||(status & VR_ISR_TX_ABRT)){
- ifp->if_oerrors++;
- vr_txeof(sc);
- if (sc->vr_cdata.vr_tx_head != NULL) {
- VR_SETBIT16(sc, VR_COMMAND, VR_CMD_TX_ON);
- VR_SETBIT16(sc, VR_COMMAND, VR_CMD_TX_GO);
- }
- }
-
- if (status & VR_ISR_BUSERR) {
- vr_reset(sc);
- vr_init(sc);
- }
- }
-
- /* Re-enable interrupts. */
- CSR_WRITE_2(sc, VR_IMR, VR_INTRS);
-
- if (ifp->if_snd.ifq_head != NULL) {
- vr_start(ifp);
- }
-
- return;
-}
-
-/*
- * Encapsulate an mbuf chain in a descriptor by coupling the mbuf data
- * pointers to the fragment pointers.
- */
-static int vr_encap(sc, c, m_head)
- struct vr_softc *sc;
- struct vr_chain *c;
- struct mbuf *m_head;
-{
- int frag = 0;
- struct vr_desc *f = NULL;
- int total_len;
- struct mbuf *m;
-
- m = m_head;
- total_len = 0;
-
- /*
- * The VIA Rhine wants packet buffers to be longword
- * aligned, but very often our mbufs aren't. Rather than
- * waste time trying to decide when to copy and when not
- * to copy, just do it all the time.
- */
- if (m != NULL) {
- struct mbuf *m_new = NULL;
-
- MGETHDR(m_new, M_DONTWAIT, MT_DATA);
- if (m_new == NULL) {
- printf("vr%d: no memory for tx list", sc->vr_unit);
- return(1);
- }
- if (m_head->m_pkthdr.len > MHLEN) {
- MCLGET(m_new, M_DONTWAIT);
- if (!(m_new->m_flags & M_EXT)) {
- m_freem(m_new);
- printf("vr%d: no memory for tx list",
- sc->vr_unit);
- return(1);
- }
- }
- m_copydata(m_head, 0, m_head->m_pkthdr.len,
- mtod(m_new, caddr_t));
- m_new->m_pkthdr.len = m_new->m_len = m_head->m_pkthdr.len;
- m_freem(m_head);
- m_head = m_new;
- /*
- * The Rhine chip doesn't auto-pad, so we have to make
- * sure to pad short frames out to the minimum frame length
- * ourselves.
- */
- if (m_head->m_len < VR_MIN_FRAMELEN) {
- m_new->m_pkthdr.len += VR_MIN_FRAMELEN - m_new->m_len;
- m_new->m_len = m_new->m_pkthdr.len;
- }
- f = c->vr_ptr;
- f->vr_data = vtophys(mtod(m_new, caddr_t));
- f->vr_ctl = total_len = m_new->m_len;
- f->vr_ctl |= VR_TXCTL_TLINK|VR_TXCTL_FIRSTFRAG;
- f->vr_status = 0;
- frag = 1;
- }
-
- c->vr_mbuf = m_head;
- c->vr_ptr->vr_ctl |= VR_TXCTL_LASTFRAG|VR_TXCTL_FINT;
- c->vr_ptr->vr_next = vtophys(c->vr_nextdesc->vr_ptr);
-
- return(0);
-}
-
-/*
- * Main transmit routine. To avoid having to do mbuf copies, we put pointers
- * to the mbuf data regions directly in the transmit lists. We also save a
- * copy of the pointers since the transmit list fragment pointers are
- * physical addresses.
- */
-
-static void vr_start(ifp)
- struct ifnet *ifp;
-{
- struct vr_softc *sc;
- struct mbuf *m_head = NULL;
- struct vr_chain *cur_tx = NULL, *start_tx;
-
- sc = ifp->if_softc;
-
- if (ifp->if_flags & IFF_OACTIVE)
- return;
-
- /*
- * Check for an available queue slot. If there are none,
- * punt.
- */
- if (sc->vr_cdata.vr_tx_free->vr_mbuf != NULL) {
- ifp->if_flags |= IFF_OACTIVE;
- return;
- }
-
- start_tx = sc->vr_cdata.vr_tx_free;
-
- while(sc->vr_cdata.vr_tx_free->vr_mbuf == NULL) {
- IF_DEQUEUE(&ifp->if_snd, m_head);
- if (m_head == NULL)
- break;
-
- /* Pick a descriptor off the free list. */
- cur_tx = sc->vr_cdata.vr_tx_free;
- sc->vr_cdata.vr_tx_free = cur_tx->vr_nextdesc;
-
- /* Pack the data into the descriptor. */
- vr_encap(sc, cur_tx, m_head);
-
- if (cur_tx != start_tx)
- VR_TXOWN(cur_tx) = VR_TXSTAT_OWN;
-
- /*
- * If there's a BPF listener, bounce a copy of this frame
- * to him.
- */
- if (ifp->if_bpf)
- bpf_mtap(ifp, cur_tx->vr_mbuf);
-
- VR_TXOWN(cur_tx) = VR_TXSTAT_OWN;
- VR_SETBIT16(sc, VR_COMMAND, /*VR_CMD_TX_ON|*/VR_CMD_TX_GO);
- }
-
- /*
- * If there are no frames queued, bail.
- */
- if (cur_tx == NULL)
- return;
-
- sc->vr_cdata.vr_tx_tail = cur_tx;
-
- if (sc->vr_cdata.vr_tx_head == NULL)
- sc->vr_cdata.vr_tx_head = start_tx;
-
- /*
- * Set a timeout in case the chip goes out to lunch.
- */
- ifp->if_timer = 5;
-
- return;
-}
-
-static void vr_init(xsc)
- void *xsc;
-{
- struct vr_softc *sc = xsc;
- struct ifnet *ifp = &sc->arpcom.ac_if;
- struct mii_data *mii;
- int s;
-
- s = splimp();
-
- mii = device_get_softc(sc->vr_miibus);
-
- /*
- * Cancel pending I/O and free all RX/TX buffers.
- */
- vr_stop(sc);
- vr_reset(sc);
-
- VR_CLRBIT(sc, VR_RXCFG, VR_RXCFG_RX_THRESH);
- VR_SETBIT(sc, VR_RXCFG, VR_RXTHRESH_STORENFWD);
-
- VR_CLRBIT(sc, VR_TXCFG, VR_TXCFG_TX_THRESH);
- VR_SETBIT(sc, VR_TXCFG, VR_TXTHRESH_STORENFWD);
-
- /* Init circular RX list. */
- if (vr_list_rx_init(sc) == ENOBUFS) {
- printf("vr%d: initialization failed: no "
- "memory for rx buffers\n", sc->vr_unit);
- vr_stop(sc);
- (void)splx(s);
- return;
- }
-
- /*
- * Init tx descriptors.
- */
- vr_list_tx_init(sc);
-
- /* If we want promiscuous mode, set the allframes bit. */
- if (ifp->if_flags & IFF_PROMISC)
- VR_SETBIT(sc, VR_RXCFG, VR_RXCFG_RX_PROMISC);
- else
- VR_CLRBIT(sc, VR_RXCFG, VR_RXCFG_RX_PROMISC);
-
- /* Set capture broadcast bit to capture broadcast frames. */
- if (ifp->if_flags & IFF_BROADCAST)
- VR_SETBIT(sc, VR_RXCFG, VR_RXCFG_RX_BROAD);
- else
- VR_CLRBIT(sc, VR_RXCFG, VR_RXCFG_RX_BROAD);
-
- /*
- * Program the multicast filter, if necessary.
- */
- vr_setmulti(sc);
-
- /*
- * Load the address of the RX list.
- */
- CSR_WRITE_4(sc, VR_RXADDR, vtophys(sc->vr_cdata.vr_rx_head->vr_ptr));
-
- /* Enable receiver and transmitter. */
- CSR_WRITE_2(sc, VR_COMMAND, VR_CMD_TX_NOPOLL|VR_CMD_START|
- VR_CMD_TX_ON|VR_CMD_RX_ON|
- VR_CMD_RX_GO);
-
- CSR_WRITE_4(sc, VR_TXADDR, vtophys(&sc->vr_ldata->vr_tx_list[0]));
-
- /*
- * Enable interrupts.
- */
- CSR_WRITE_2(sc, VR_ISR, 0xFFFF);
- CSR_WRITE_2(sc, VR_IMR, VR_INTRS);
-
- mii_mediachg(mii);
-
- ifp->if_flags |= IFF_RUNNING;
- ifp->if_flags &= ~IFF_OACTIVE;
-
- (void)splx(s);
-
- sc->vr_stat_ch = timeout(vr_tick, sc, hz);
-
- return;
-}
-
-/*
- * Set media options.
- */
-static int vr_ifmedia_upd(ifp)
- struct ifnet *ifp;
-{
- struct vr_softc *sc;
-
- sc = ifp->if_softc;
-
- if (ifp->if_flags & IFF_UP)
- vr_init(sc);
-
- return(0);
-}
-
-/*
- * Report current media status.
- */
-static void vr_ifmedia_sts(ifp, ifmr)
- struct ifnet *ifp;
- struct ifmediareq *ifmr;
-{
- struct vr_softc *sc;
- struct mii_data *mii;
-
- sc = ifp->if_softc;
- mii = device_get_softc(sc->vr_miibus);
- mii_pollstat(mii);
- ifmr->ifm_active = mii->mii_media_active;
- ifmr->ifm_status = mii->mii_media_status;
-
- return;
-}
-
-static int vr_ioctl(ifp, command, data)
- struct ifnet *ifp;
- u_long command;
- caddr_t data;
-{
- struct vr_softc *sc = ifp->if_softc;
- struct ifreq *ifr = (struct ifreq *) data;
- struct mii_data *mii;
- int s, error = 0;
-
- s = splimp();
-
- switch(command) {
- case SIOCSIFADDR:
- case SIOCGIFADDR:
- case SIOCSIFMTU:
- error = ether_ioctl(ifp, command, data);
- break;
- case SIOCSIFFLAGS:
- if (ifp->if_flags & IFF_UP) {
- vr_init(sc);
- } else {
- if (ifp->if_flags & IFF_RUNNING)
- vr_stop(sc);
- }
- error = 0;
- break;
- case SIOCADDMULTI:
- case SIOCDELMULTI:
- vr_setmulti(sc);
- error = 0;
- break;
- case SIOCGIFMEDIA:
- case SIOCSIFMEDIA:
- mii = device_get_softc(sc->vr_miibus);
- error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, command);
- break;
- default:
- error = EINVAL;
- break;
- }
-
- (void)splx(s);
-
- return(error);
-}
-
-static void vr_watchdog(ifp)
- struct ifnet *ifp;
-{
- struct vr_softc *sc;
-
- sc = ifp->if_softc;
-
- ifp->if_oerrors++;
- printf("vr%d: watchdog timeout\n", sc->vr_unit);
-
- vr_stop(sc);
- vr_reset(sc);
- vr_init(sc);
-
- if (ifp->if_snd.ifq_head != NULL)
- vr_start(ifp);
-
- return;
-}
-
-/*
- * Stop the adapter and free any mbufs allocated to the
- * RX and TX lists.
- */
-static void vr_stop(sc)
- struct vr_softc *sc;
-{
- register int i;
- struct ifnet *ifp;
-
- ifp = &sc->arpcom.ac_if;
- ifp->if_timer = 0;
-
- untimeout(vr_tick, sc, sc->vr_stat_ch);
-
- VR_SETBIT16(sc, VR_COMMAND, VR_CMD_STOP);
- VR_CLRBIT16(sc, VR_COMMAND, (VR_CMD_RX_ON|VR_CMD_TX_ON));
- CSR_WRITE_2(sc, VR_IMR, 0x0000);
- CSR_WRITE_4(sc, VR_TXADDR, 0x00000000);
- CSR_WRITE_4(sc, VR_RXADDR, 0x00000000);
-
- /*
- * Free data in the RX lists.
- */
- for (i = 0; i < VR_RX_LIST_CNT; i++) {
- if (sc->vr_cdata.vr_rx_chain[i].vr_mbuf != NULL) {
- m_freem(sc->vr_cdata.vr_rx_chain[i].vr_mbuf);
- sc->vr_cdata.vr_rx_chain[i].vr_mbuf = NULL;
- }
- }
- bzero((char *)&sc->vr_ldata->vr_rx_list,
- sizeof(sc->vr_ldata->vr_rx_list));
-
- /*
- * Free the TX list buffers.
- */
- for (i = 0; i < VR_TX_LIST_CNT; i++) {
- if (sc->vr_cdata.vr_tx_chain[i].vr_mbuf != NULL) {
- m_freem(sc->vr_cdata.vr_tx_chain[i].vr_mbuf);
- sc->vr_cdata.vr_tx_chain[i].vr_mbuf = NULL;
- }
- }
-
- bzero((char *)&sc->vr_ldata->vr_tx_list,
- sizeof(sc->vr_ldata->vr_tx_list));
-
- ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
-
- return;
-}
-
-/*
- * Stop all chip I/O so that the kernel's probe routines don't
- * get confused by errant DMAs when rebooting.
- */
-static void vr_shutdown(dev)
- device_t dev;
-{
- struct vr_softc *sc;
-
- sc = device_get_softc(dev);
-
- vr_stop(sc);
-
- return;
-}
diff --git a/sys/dev/vr/if_vrreg.h b/sys/dev/vr/if_vrreg.h
deleted file mode 100644
index f5524c3f43b3..000000000000
--- a/sys/dev/vr/if_vrreg.h
+++ /dev/null
@@ -1,510 +0,0 @@
-/*
- * Copyright (c) 1997, 1998
- * Bill Paul <wpaul@ctr.columbia.edu>. 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 Bill Paul.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY Bill Paul 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 Bill Paul OR THE VOICES IN HIS HEAD
- * 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Rhine register definitions.
- */
-
-#define VR_PAR0 0x00 /* node address 0 to 4 */
-#define VR_PAR1 0x04 /* node address 2 to 6 */
-#define VR_RXCFG 0x06 /* receiver config register */
-#define VR_TXCFG 0x07 /* transmit config register */
-#define VR_COMMAND 0x08 /* command register */
-#define VR_ISR 0x0C /* interrupt/status register */
-#define VR_IMR 0x0E /* interrupt mask register */
-#define VR_MAR0 0x10 /* multicast hash 0 */
-#define VR_MAR1 0x14 /* multicast hash 1 */
-#define VR_RXADDR 0x18 /* rx descriptor list start addr */
-#define VR_TXADDR 0x1C /* tx descriptor list start addr */
-#define VR_CURRXDESC0 0x20
-#define VR_CURRXDESC1 0x24
-#define VR_CURRXDESC2 0x28
-#define VR_CURRXDESC3 0x2C
-#define VR_NEXTRXDESC0 0x30
-#define VR_NEXTRXDESC1 0x34
-#define VR_NEXTRXDESC2 0x38
-#define VR_NEXTRXDESC3 0x3C
-#define VR_CURTXDESC0 0x40
-#define VR_CURTXDESC1 0x44
-#define VR_CURTXDESC2 0x48
-#define VR_CURTXDESC3 0x4C
-#define VR_NEXTTXDESC0 0x50
-#define VR_NEXTTXDESC1 0x54
-#define VR_NEXTTXDESC2 0x58
-#define VR_NEXTTXDESC3 0x5C
-#define VR_CURRXDMA 0x60 /* current RX DMA address */
-#define VR_CURTXDMA 0x64 /* current TX DMA address */
-#define VR_TALLYCNT 0x68 /* tally counter test register */
-#define VR_PHYADDR 0x6C
-#define VR_MIISTAT 0x6D
-#define VR_BCR0 0x6E
-#define VR_BCR1 0x6F
-#define VR_MIICMD 0x70
-#define VR_MIIADDR 0x71
-#define VR_MIIDATA 0x72
-#define VR_EECSR 0x74
-#define VR_TEST 0x75
-#define VR_GPIO 0x76
-#define VR_CONFIG 0x78
-#define VR_MPA_CNT 0x7C
-#define VR_CRC_CNT 0x7E
-
-/*
- * RX config bits.
- */
-#define VR_RXCFG_RX_ERRPKTS 0x01
-#define VR_RXCFG_RX_RUNT 0x02
-#define VR_RXCFG_RX_MULTI 0x04
-#define VR_RXCFG_RX_BROAD 0x08
-#define VR_RXCFG_RX_PROMISC 0x10
-#define VR_RXCFG_RX_THRESH 0xE0
-
-#define VR_RXTHRESH_32BYTES 0x00
-#define VR_RXTHRESH_64BYTES 0x20
-#define VR_RXTHRESH_128BYTES 0x40
-#define VR_RXTHRESH_256BYTES 0x60
-#define VR_RXTHRESH_512BYTES 0x80
-#define VR_RXTHRESH_768BYTES 0xA0
-#define VR_RXTHRESH_1024BYTES 0xC0
-#define VR_RXTHRESH_STORENFWD 0xE0
-
-/*
- * TX config bits.
- */
-#define VR_TXCFG_RSVD0 0x01
-#define VR_TXCFG_LOOPBKMODE 0x06
-#define VR_TXCFG_BACKOFF 0x08
-#define VR_TXCFG_RSVD1 0x10
-#define VR_TXCFG_TX_THRESH 0xE0
-
-#define VR_TXTHRESH_32BYTES 0x00
-#define VR_TXTHRESH_64BYTES 0x20
-#define VR_TXTHRESH_128BYTES 0x40
-#define VR_TXTHRESH_256BYTES 0x60
-#define VR_TXTHRESH_512BYTES 0x80
-#define VR_TXTHRESH_768BYTES 0xA0
-#define VR_TXTHRESH_1024BYTES 0xC0
-#define VR_TXTHRESH_STORENFWD 0xE0
-
-/*
- * Command register bits.
- */
-#define VR_CMD_INIT 0x0001
-#define VR_CMD_START 0x0002
-#define VR_CMD_STOP 0x0004
-#define VR_CMD_RX_ON 0x0008
-#define VR_CMD_TX_ON 0x0010
-#define VR_CMD_TX_GO 0x0020
-#define VR_CMD_RX_GO 0x0040
-#define VR_CMD_RSVD 0x0080
-#define VR_CMD_RX_EARLY 0x0100
-#define VR_CMD_TX_EARLY 0x0200
-#define VR_CMD_FULLDUPLEX 0x0400
-#define VR_CMD_TX_NOPOLL 0x0800
-
-#define VR_CMD_RESET 0x8000
-
-/*
- * Interrupt status bits.
- */
-#define VR_ISR_RX_OK 0x0001 /* packet rx ok */
-#define VR_ISR_TX_OK 0x0002 /* packet tx ok */
-#define VR_ISR_RX_ERR 0x0004 /* packet rx with err */
-#define VR_ISR_TX_ABRT 0x0008 /* tx aborted due to excess colls */
-#define VR_ISR_TX_UNDERRUN 0x0010 /* tx buffer underflow */
-#define VR_ISR_RX_NOBUF 0x0020 /* no rx buffer available */
-#define VR_ISR_BUSERR 0x0040 /* PCI bus error */
-#define VR_ISR_STATSOFLOW 0x0080 /* stats counter oflow */
-#define VR_ISR_RX_EARLY 0x0100 /* rx early */
-#define VR_ISR_LINKSTAT 0x0200 /* MII status change */
-#define VR_ISR_RX_OFLOW 0x0400 /* rx FIFO overflow */
-#define VR_ISR_RX_DROPPED 0x0800
-#define VR_ISR_RX_NOBUF2 0x1000
-#define VR_ISR_TX_ABRT2 0x2000
-#define VR_ISR_LINKSTAT2 0x4000
-#define VR_ISR_MAGICPACKET 0x8000
-
-/*
- * Interrupt mask bits.
- */
-#define VR_IMR_RX_OK 0x0001 /* packet rx ok */
-#define VR_IMR_TX_OK 0x0002 /* packet tx ok */
-#define VR_IMR_RX_ERR 0x0004 /* packet rx with err */
-#define VR_IMR_TX_ABRT 0x0008 /* tx aborted due to excess colls */
-#define VR_IMR_TX_UNDERRUN 0x0010 /* tx buffer underflow */
-#define VR_IMR_RX_NOBUF 0x0020 /* no rx buffer available */
-#define VR_IMR_BUSERR 0x0040 /* PCI bus error */
-#define VR_IMR_STATSOFLOW 0x0080 /* stats counter oflow */
-#define VR_IMR_RX_EARLY 0x0100 /* rx early */
-#define VR_IMR_LINKSTAT 0x0200 /* MII status change */
-#define VR_IMR_RX_OFLOW 0x0400 /* rx FIFO overflow */
-#define VR_IMR_RX_DROPPED 0x0800
-#define VR_IMR_RX_NOBUF2 0x1000
-#define VR_IMR_TX_ABRT2 0x2000
-#define VR_IMR_LINKSTAT2 0x4000
-#define VR_IMR_MAGICPACKET 0x8000
-
-#define VR_INTRS \
- (VR_IMR_RX_OK|VR_IMR_TX_OK|VR_IMR_RX_NOBUF| \
- VR_IMR_TX_ABRT|VR_IMR_TX_UNDERRUN|VR_IMR_BUSERR| \
- VR_IMR_RX_ERR|VR_ISR_RX_DROPPED)
-
-/*
- * MII status register.
- */
-
-#define VR_MIISTAT_SPEED 0x01
-#define VR_MIISTAT_LINKFAULT 0x02
-#define VR_MIISTAT_MGTREADERR 0x04
-#define VR_MIISTAT_MIIERR 0x08
-#define VR_MIISTAT_PHYOPT 0x10
-#define VR_MIISTAT_MDC_SPEED 0x20
-#define VR_MIISTAT_RSVD 0x40
-#define VR_MIISTAT_GPIO1POLL 0x80
-
-/*
- * MII command register bits.
- */
-#define VR_MIICMD_CLK 0x01
-#define VR_MIICMD_DATAOUT 0x02
-#define VR_MIICMD_DATAIN 0x04
-#define VR_MIICMD_DIR 0x08
-#define VR_MIICMD_DIRECTPGM 0x10
-#define VR_MIICMD_WRITE_ENB 0x20
-#define VR_MIICMD_READ_ENB 0x40
-#define VR_MIICMD_AUTOPOLL 0x80
-
-/*
- * EEPROM control bits.
- */
-#define VR_EECSR_DATAIN 0x01 /* data out */
-#define VR_EECSR_DATAOUT 0x02 /* data in */
-#define VR_EECSR_CLK 0x04 /* clock */
-#define VR_EECSR_CS 0x08 /* chip select */
-#define VR_EECSR_DPM 0x10
-#define VR_EECSR_LOAD 0x20
-#define VR_EECSR_EMBP 0x40
-#define VR_EECSR_EEPR 0x80
-
-#define VR_EECMD_WRITE 0x140
-#define VR_EECMD_READ 0x180
-#define VR_EECMD_ERASE 0x1c0
-
-/*
- * Test register bits.
- */
-#define VR_TEST_TEST0 0x01
-#define VR_TEST_TEST1 0x02
-#define VR_TEST_TEST2 0x04
-#define VR_TEST_TSTUD 0x08
-#define VR_TEST_TSTOV 0x10
-#define VR_TEST_BKOFF 0x20
-#define VR_TEST_FCOL 0x40
-#define VR_TEST_HBDES 0x80
-
-/*
- * Config register bits.
- */
-#define VR_CFG_GPIO2OUTENB 0x00000001
-#define VR_CFG_GPIO2OUT 0x00000002 /* gen. purp. pin */
-#define VR_CFG_GPIO2IN 0x00000004 /* gen. purp. pin */
-#define VR_CFG_AUTOOPT 0x00000008 /* enable rx/tx autopoll */
-#define VR_CFG_MIIOPT 0x00000010
-#define VR_CFG_MMIENB 0x00000020 /* memory mapped mode enb */
-#define VR_CFG_JUMPER 0x00000040 /* PHY and oper. mode select */
-#define VR_CFG_EELOAD 0x00000080 /* enable EEPROM programming */
-#define VR_CFG_LATMENB 0x00000100 /* larency timer effect enb. */
-#define VR_CFG_MRREADWAIT 0x00000200
-#define VR_CFG_MRWRITEWAIT 0x00000400
-#define VR_CFG_RX_ARB 0x00000800
-#define VR_CFG_TX_ARB 0x00001000
-#define VR_CFG_READMULTI 0x00002000
-#define VR_CFG_TX_PACE 0x00004000
-#define VR_CFG_TX_QDIS 0x00008000
-#define VR_CFG_ROMSEL0 0x00010000
-#define VR_CFG_ROMSEL1 0x00020000
-#define VR_CFG_ROMSEL2 0x00040000
-#define VR_CFG_ROMTIMESEL 0x00080000
-#define VR_CFG_RSVD0 0x00100000
-#define VR_CFG_ROMDLY 0x00200000
-#define VR_CFG_ROMOPT 0x00400000
-#define VR_CFG_RSVD1 0x00800000
-#define VR_CFG_BACKOFFOPT 0x01000000
-#define VR_CFG_BACKOFFMOD 0x02000000
-#define VR_CFG_CAPEFFECT 0x04000000
-#define VR_CFG_BACKOFFRAND 0x08000000
-#define VR_CFG_MAGICKPACKET 0x10000000
-#define VR_CFG_PCIREADLINE 0x20000000
-#define VR_CFG_DIAG 0x40000000
-#define VR_CFG_GPIOEN 0x80000000
-
-/*
- * Rhine TX/RX list structure.
- */
-
-struct vr_desc {
- u_int32_t vr_status;
- u_int32_t vr_ctl;
- u_int32_t vr_ptr1;
- u_int32_t vr_ptr2;
-};
-
-#define vr_data vr_ptr1
-#define vr_next vr_ptr2
-
-
-#define VR_RXSTAT_RXERR 0x00000001
-#define VR_RXSTAT_CRCERR 0x00000002
-#define VR_RXSTAT_FRAMEALIGNERR 0x00000004
-#define VR_RXSTAT_FIFOOFLOW 0x00000008
-#define VR_RXSTAT_GIANT 0x00000010
-#define VR_RXSTAT_RUNT 0x00000020
-#define VR_RXSTAT_BUSERR 0x00000040
-#define VR_RXSTAT_BUFFERR 0x00000080
-#define VR_RXSTAT_LASTFRAG 0x00000100
-#define VR_RXSTAT_FIRSTFRAG 0x00000200
-#define VR_RXSTAT_RLINK 0x00000400
-#define VR_RXSTAT_RX_PHYS 0x00000800
-#define VR_RXSTAT_RX_BROAD 0x00001000
-#define VR_RXSTAT_RX_MULTI 0x00002000
-#define VR_RXSTAT_RX_OK 0x00004000
-#define VR_RXSTAT_RXLEN 0x07FF0000
-#define VR_RXSTAT_RXLEN_EXT 0x78000000
-#define VR_RXSTAT_OWN 0x80000000
-
-#define VR_RXBYTES(x) ((x & VR_RXSTAT_RXLEN) >> 16)
-#define VR_RXSTAT (VR_RXSTAT_FIRSTFRAG|VR_RXSTAT_LASTFRAG|VR_RXSTAT_OWN)
-
-#define VR_RXCTL_BUFLEN 0x000007FF
-#define VR_RXCTL_BUFLEN_EXT 0x00007800
-#define VR_RXCTL_CHAIN 0x00008000
-#define VR_RXCTL_RX_INTR 0x00800000
-
-#define VR_RXCTL (VR_RXCTL_CHAIN|VR_RXCTL_RX_INTR)
-
-#define VR_TXSTAT_DEFER 0x00000001
-#define VR_TXSTAT_UNDERRUN 0x00000002
-#define VR_TXSTAT_COLLCNT 0x00000078
-#define VR_TXSTAT_SQE 0x00000080
-#define VR_TXSTAT_ABRT 0x00000100
-#define VR_TXSTAT_LATECOLL 0x00000200
-#define VR_TXSTAT_CARRLOST 0x00000400
-#define VR_TXSTAT_BUSERR 0x00002000
-#define VR_TXSTAT_JABTIMEO 0x00004000
-#define VR_TXSTAT_ERRSUM 0x00008000
-#define VR_TXSTAT_OWN 0x80000000
-
-#define VR_TXCTL_BUFLEN 0x000007FF
-#define VR_TXCTL_BUFLEN_EXT 0x00007800
-#define VR_TXCTL_TLINK 0x00008000
-#define VR_TXCTL_FIRSTFRAG 0x00200000
-#define VR_TXCTL_LASTFRAG 0x00400000
-#define VR_TXCTL_FINT 0x00800000
-
-
-#define VR_MAXFRAGS 16
-#define VR_RX_LIST_CNT 64
-#define VR_TX_LIST_CNT 128
-#define VR_MIN_FRAMELEN 60
-#define VR_FRAMELEN 1536
-#define VR_RXLEN 1520
-
-#define VR_TXOWN(x) x->vr_ptr->vr_status
-
-struct vr_list_data {
- struct vr_desc vr_rx_list[VR_RX_LIST_CNT];
- struct vr_desc vr_tx_list[VR_TX_LIST_CNT];
-};
-
-struct vr_chain {
- struct vr_desc *vr_ptr;
- struct mbuf *vr_mbuf;
- struct vr_chain *vr_nextdesc;
-};
-
-struct vr_chain_onefrag {
- struct vr_desc *vr_ptr;
- struct mbuf *vr_mbuf;
- struct vr_chain_onefrag *vr_nextdesc;
-};
-
-struct vr_chain_data {
- struct vr_chain_onefrag vr_rx_chain[VR_RX_LIST_CNT];
- struct vr_chain vr_tx_chain[VR_TX_LIST_CNT];
-
- struct vr_chain_onefrag *vr_rx_head;
-
- struct vr_chain *vr_tx_head;
- struct vr_chain *vr_tx_tail;
- struct vr_chain *vr_tx_free;
-};
-
-struct vr_type {
- u_int16_t vr_vid;
- u_int16_t vr_did;
- char *vr_name;
-};
-
-struct vr_mii_frame {
- u_int8_t mii_stdelim;
- u_int8_t mii_opcode;
- u_int8_t mii_phyaddr;
- u_int8_t mii_regaddr;
- u_int8_t mii_turnaround;
- u_int16_t mii_data;
-};
-
-/*
- * MII constants
- */
-#define VR_MII_STARTDELIM 0x01
-#define VR_MII_READOP 0x02
-#define VR_MII_WRITEOP 0x01
-#define VR_MII_TURNAROUND 0x02
-
-#define VR_FLAG_FORCEDELAY 1
-#define VR_FLAG_SCHEDDELAY 2
-#define VR_FLAG_DELAYTIMEO 3
-
-struct vr_softc {
- struct arpcom arpcom; /* interface info */
- bus_space_handle_t vr_bhandle; /* bus space handle */
- bus_space_tag_t vr_btag; /* bus space tag */
- struct resource *vr_res;
- struct resource *vr_irq;
- void *vr_intrhand;
- device_t vr_miibus;
- struct vr_type *vr_info; /* Rhine adapter info */
- u_int8_t vr_unit; /* interface number */
- u_int8_t vr_type;
- struct vr_list_data *vr_ldata;
- struct vr_chain_data vr_cdata;
- struct callout_handle vr_stat_ch;
-};
-
-/*
- * register space access macros
- */
-#define CSR_WRITE_4(sc, reg, val) \
- bus_space_write_4(sc->vr_btag, sc->vr_bhandle, reg, val)
-#define CSR_WRITE_2(sc, reg, val) \
- bus_space_write_2(sc->vr_btag, sc->vr_bhandle, reg, val)
-#define CSR_WRITE_1(sc, reg, val) \
- bus_space_write_1(sc->vr_btag, sc->vr_bhandle, reg, val)
-
-#define CSR_READ_4(sc, reg) \
- bus_space_read_4(sc->vr_btag, sc->vr_bhandle, reg)
-#define CSR_READ_2(sc, reg) \
- bus_space_read_2(sc->vr_btag, sc->vr_bhandle, reg)
-#define CSR_READ_1(sc, reg) \
- bus_space_read_1(sc->vr_btag, sc->vr_bhandle, reg)
-
-#define VR_TIMEOUT 1000
-#define ETHER_ALIGN 2
-
-/*
- * General constants that are fun to know.
- *
- * VIA vendor ID
- */
-#define VIA_VENDORID 0x1106
-
-/*
- * VIA Rhine device IDs.
- */
-#define VIA_DEVICEID_RHINE 0x3043
-#define VIA_DEVICEID_RHINE_II 0x6100
-
-/*
- * Delta Electronics device ID.
- */
-#define DELTA_VENDORID 0x1500
-
-/*
- * Delta device IDs.
- */
-#define DELTA_DEVICEID_RHINE_II 0x1320
-
-/*
- * Addtron vendor ID.
- */
-#define ADDTRON_VENDORID 0x4033
-
-/*
- * Addtron device IDs.
- */
-#define ADDTRON_DEVICEID_RHINE_II 0x1320
-
-
-/*
- * PCI low memory base and low I/O base register, and
- * other PCI registers.
- */
-
-#define VR_PCI_VENDOR_ID 0x00
-#define VR_PCI_DEVICE_ID 0x02
-#define VR_PCI_COMMAND 0x04
-#define VR_PCI_STATUS 0x06
-#define VR_PCI_CLASSCODE 0x09
-#define VR_PCI_LATENCY_TIMER 0x0D
-#define VR_PCI_HEADER_TYPE 0x0E
-#define VR_PCI_LOIO 0x10
-#define VR_PCI_LOMEM 0x14
-#define VR_PCI_BIOSROM 0x30
-#define VR_PCI_INTLINE 0x3C
-#define VR_PCI_INTPIN 0x3D
-#define VR_PCI_MINGNT 0x3E
-#define VR_PCI_MINLAT 0x0F
-#define VR_PCI_RESETOPT 0x48
-#define VR_PCI_EEPROM_DATA 0x4C
-
-/* power management registers */
-#define VR_PCI_CAPID 0xDC /* 8 bits */
-#define VR_PCI_NEXTPTR 0xDD /* 8 bits */
-#define VR_PCI_PWRMGMTCAP 0xDE /* 16 bits */
-#define VR_PCI_PWRMGMTCTRL 0xE0 /* 16 bits */
-
-#define VR_PSTATE_MASK 0x0003
-#define VR_PSTATE_D0 0x0000
-#define VR_PSTATE_D1 0x0002
-#define VR_PSTATE_D2 0x0002
-#define VR_PSTATE_D3 0x0003
-#define VR_PME_EN 0x0010
-#define VR_PME_STATUS 0x8000
-
-
-#ifdef __alpha__
-#undef vtophys
-#define vtophys(va) alpha_XXX_dmamap((vm_offset_t)va)
-#endif
diff --git a/sys/dev/wi/if_wavelan_ieee.h b/sys/dev/wi/if_wavelan_ieee.h
deleted file mode 100644
index 5e1046a6c06f..000000000000
--- a/sys/dev/wi/if_wavelan_ieee.h
+++ /dev/null
@@ -1,321 +0,0 @@
-/*
- * Copyright (c) 1997, 1998, 1999
- * Bill Paul <wpaul@ctr.columbia.edu>. 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 Bill Paul.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY Bill Paul 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 Bill Paul OR THE VOICES IN HIS HEAD
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _IF_WAVELAN_IEEE_H
-#define _IF_WAVELAN_IEEE_H
-
-/*
- * This header defines a simple command interface to the FreeBSD
- * WaveLAN/IEEE driver (wi) driver, which is used to set certain
- * device-specific parameters which can't be easily managed through
- * ifconfig(8). No, sysctl(2) is not the answer. I said a _simple_
- * interface, didn't I.
- */
-
-#ifndef SIOCSWAVELAN
-#define SIOCSWAVELAN SIOCSIFGENERIC
-#endif
-
-#ifndef SIOCGWAVELAN
-#define SIOCGWAVELAN SIOCGIFGENERIC
-#endif
-
-/*
- * Technically I don't think there's a limit to a record
- * length. The largest record is the one that contains the CIS
- * data, which is 240 words long, so 256 should be a safe
- * value.
- */
-#define WI_MAX_DATALEN 512
-
-struct wi_req {
- u_int16_t wi_len;
- u_int16_t wi_type;
- u_int16_t wi_val[WI_MAX_DATALEN];
-};
-
-/*
- * Private LTV records (interpreted only by the driver). This is
- * a minor kludge to allow reading the interface statistics from
- * the driver.
- */
-#define WI_RID_IFACE_STATS 0x0100
-#define WI_RID_MGMT_XMIT 0x0200
-#ifdef WICACHE
-#define WI_RID_ZERO_CACHE 0x0300
-#define WI_RID_READ_CACHE 0x0400
-#endif
-
-struct wi_80211_hdr {
- u_int16_t frame_ctl;
- u_int16_t dur_id;
- u_int8_t addr1[6];
- u_int8_t addr2[6];
- u_int8_t addr3[6];
- u_int16_t seq_ctl;
- u_int8_t addr4[6];
-};
-
-#define WI_FCTL_VERS 0x0002
-#define WI_FCTL_FTYPE 0x000C
-#define WI_FCTL_STYPE 0x00F0
-#define WI_FCTL_TODS 0x0100
-#define WI_FCTL_FROMDS 0x0200
-#define WI_FCTL_MOREFRAGS 0x0400
-#define WI_FCTL_RETRY 0x0800
-#define WI_FCTL_PM 0x1000
-#define WI_FCTL_MOREDATA 0x2000
-#define WI_FCTL_WEP 0x4000
-#define WI_FCTL_ORDER 0x8000
-
-#define WI_FTYPE_MGMT 0x0000
-#define WI_FTYPE_CTL 0x0004
-#define WI_FTYPE_DATA 0x0008
-
-#define WI_STYPE_MGMT_ASREQ 0x0000 /* association request */
-#define WI_STYPE_MGMT_ASRESP 0x0010 /* association response */
-#define WI_STYPE_MGMT_REASREQ 0x0020 /* reassociation request */
-#define WI_STYPE_MGMT_REASRESP 0x0030 /* reassociation response */
-#define WI_STYPE_MGMT_PROBEREQ 0x0040 /* probe request */
-#define WI_STYPE_MGMT_PROBERESP 0x0050 /* probe response */
-#define WI_STYPE_MGMT_BEACON 0x0080 /* beacon */
-#define WI_STYPE_MGMT_ATIM 0x0090 /* announcement traffic ind msg */
-#define WI_STYPE_MGMT_DISAS 0x00A0 /* disassociation */
-#define WI_STYPE_MGMT_AUTH 0x00B0 /* authentication */
-#define WI_STYPE_MGMT_DEAUTH 0x00C0 /* deauthentication */
-
-struct wi_mgmt_hdr {
- u_int16_t frame_ctl;
- u_int16_t duration;
- u_int8_t dst_addr[6];
- u_int8_t src_addr[6];
- u_int8_t bssid[6];
- u_int16_t seq_ctl;
-};
-
-/*
- * Lucent/wavelan IEEE signal strength cache
- *
- * driver keeps cache of last
- * MAXWICACHE packets to arrive including signal strength info.
- * daemons may read this via ioctl
- *
- * Each entry in the wi_sigcache has a unique macsrc.
- */
-#ifdef WICACHE
-#define MAXWICACHE 10
-
-struct wi_sigcache {
- char macsrc[6]; /* unique MAC address for entry */
- int ipsrc; /* ip address associated with packet */
- int signal; /* signal strength of the packet */
- int noise; /* noise value */
- int quality; /* quality of the packet */
-};
-#endif
-
-#ifndef _KERNEL
-struct wi_counters {
- u_int32_t wi_tx_unicast_frames;
- u_int32_t wi_tx_multicast_frames;
- u_int32_t wi_tx_fragments;
- u_int32_t wi_tx_unicast_octets;
- u_int32_t wi_tx_multicast_octets;
- u_int32_t wi_tx_deferred_xmits;
- u_int32_t wi_tx_single_retries;
- u_int32_t wi_tx_multi_retries;
- u_int32_t wi_tx_retry_limit;
- u_int32_t wi_tx_discards;
- u_int32_t wi_rx_unicast_frames;
- u_int32_t wi_rx_multicast_frames;
- u_int32_t wi_rx_fragments;
- u_int32_t wi_rx_unicast_octets;
- u_int32_t wi_rx_multicast_octets;
- u_int32_t wi_rx_fcs_errors;
- u_int32_t wi_rx_discards_nobuf;
- u_int32_t wi_tx_discards_wrong_sa;
- u_int32_t wi_rx_WEP_cant_decrypt;
- u_int32_t wi_rx_msg_in_msg_frags;
- u_int32_t wi_rx_msg_in_bad_msg_frags;
-};
-
-/*
- * These are all the LTV record types that we can read or write
- * from the WaveLAN. Not all of them are temendously useful, but I
- * list as many as I know about here for completeness.
- */
-
-#define WI_RID_DNLD_BUF 0xFD01
-#define WI_RID_MEMSZ 0xFD02
-#define WI_RID_DOMAINS 0xFD11
-#define WI_RID_CIS 0xFD13
-#define WI_RID_COMMQUAL 0xFD43
-#define WI_RID_SCALETHRESH 0xFD46
-#define WI_RID_PCF 0xFD87
-
-/*
- * Network parameters, static configuration entities.
- */
-#define WI_RID_PORTTYPE 0xFC00 /* Connection control characteristics */
-#define WI_RID_MAC_NODE 0xFC01 /* MAC address of this station */
-#define WI_RID_DESIRED_SSID 0xFC02 /* Service Set ID for connection */
-#define WI_RID_OWN_CHNL 0xFC03 /* Comm channel for BSS creation */
-#define WI_RID_OWN_SSID 0xFC04 /* IBSS creation ID */
-#define WI_RID_OWN_ATIM_WIN 0xFC05 /* ATIM window time for IBSS creation */
-#define WI_RID_SYSTEM_SCALE 0xFC06 /* scale that specifies AP density */
-#define WI_RID_MAX_DATALEN 0xFC07 /* Max len of MAC frame body data */
-#define WI_RID_MAC_WDS 0xFC08 /* MAC addr of corresponding WDS node */
-#define WI_RID_PM_ENABLED 0xFC09 /* ESS power management enable */
-#define WI_RID_PM_EPS 0xFC0A /* PM EPS/PS mode */
-#define WI_RID_MCAST_RX 0xFC0B /* ESS PM mcast reception */
-#define WI_RID_MAX_SLEEP 0xFC0C /* max sleep time for ESS PM */
-#define WI_RID_HOLDOVER 0xFC0D /* holdover time for ESS PM */
-#define WI_RID_NODENAME 0xFC0E /* ID name of this node for diag */
-#define WI_RID_DTIM_PERIOD 0xFC10 /* beacon interval between DTIMs */
-#define WI_RID_WDS_ADDR1 0xFC11 /* port 1 MAC of WDS link node */
-#define WI_RID_WDS_ADDR2 0xFC12 /* port 1 MAC of WDS link node */
-#define WI_RID_WDS_ADDR3 0xFC13 /* port 1 MAC of WDS link node */
-#define WI_RID_WDS_ADDR4 0xFC14 /* port 1 MAC of WDS link node */
-#define WI_RID_WDS_ADDR5 0xFC15 /* port 1 MAC of WDS link node */
-#define WI_RID_WDS_ADDR6 0xFC16 /* port 1 MAC of WDS link node */
-#define WI_RID_MCAST_PM_BUF 0xFC17 /* PM buffering of mcast */
-#define WI_RID_ENCRYPTION 0xFC20 /* enable/disable WEP */
-#define WI_RID_AUTHTYPE 0xFC21 /* specify authentication type */
-
-/*
- * Network parameters, dynamic configuration entities
- */
-#define WI_RID_MCAST_LIST 0xFC80 /* list of multicast addrs */
-#define WI_RID_CREATE_IBSS 0xFC81 /* create IBSS */
-#define WI_RID_FRAG_THRESH 0xFC82 /* frag len, unicast msg xmit */
-#define WI_RID_RTS_THRESH 0xFC83 /* frame len for RTS/CTS handshake */
-#define WI_RID_TX_RATE 0xFC84 /* data rate for message xmit */
-#define WI_RID_PROMISC 0xFC85 /* enable promisc mode */
-#define WI_RID_FRAG_THRESH0 0xFC90
-#define WI_RID_FRAG_THRESH1 0xFC91
-#define WI_RID_FRAG_THRESH2 0xFC92
-#define WI_RID_FRAG_THRESH3 0xFC93
-#define WI_RID_FRAG_THRESH4 0xFC94
-#define WI_RID_FRAG_THRESH5 0xFC95
-#define WI_RID_FRAG_THRESH6 0xFC96
-#define WI_RID_RTS_THRESH0 0xFC97
-#define WI_RID_RTS_THRESH1 0xFC98
-#define WI_RID_RTS_THRESH2 0xFC99
-#define WI_RID_RTS_THRESH3 0xFC9A
-#define WI_RID_RTS_THRESH4 0xFC9B
-#define WI_RID_RTS_THRESH5 0xFC9C
-#define WI_RID_RTS_THRESH6 0xFC9D
-#define WI_RID_TX_RATE0 0xFC9E
-#define WI_RID_TX_RATE1 0xFC9F
-#define WI_RID_TX_RATE2 0xFCA0
-#define WI_RID_TX_RATE3 0xFCA1
-#define WI_RID_TX_RATE4 0xFCA2
-#define WI_RID_TX_RATE5 0xFCA3
-#define WI_RID_TX_RATE6 0xFCA4
-#define WI_RID_DEFLT_CRYPT_KEYS 0xFCB0
-#define WI_RID_TX_CRYPT_KEY 0xFCB1
-#define WI_RID_TICK_TIME 0xFCE0
-
-struct wi_key {
- u_int16_t wi_keylen;
- u_int8_t wi_keydat[14];
-};
-
-struct wi_ltv_keys {
- u_int16_t wi_len;
- u_int16_t wi_type;
- struct wi_key wi_keys[4];
-};
-
-/*
- * NIC information
- */
-#define WI_RID_FIRM_ID 0xFD02 /* Primary func firmware ID. */
-#define WI_RID_PRI_SUP_RANGE 0xFD03 /* primary supplier compatibility */
-#define WI_RID_CIF_ACT_RANGE 0xFD04 /* controller sup. compatibility */
-#define WI_RID_SERIALNO 0xFD0A /* card serial number */
-#define WI_RID_CARD_ID 0xFD0B /* card identification */
-#define WI_RID_MFI_SUP_RANGE 0xFD0C /* modem supplier compatibility */
-#define WI_RID_CFI_SUP_RANGE 0xFD0D /* controller sup. compatibility */
-#define WI_RID_CHANNEL_LIST 0xFD10 /* allowd comm. frequencies. */
-#define WI_RID_REG_DOMAINS 0xFD11 /* list of intendted regulatory doms */
-#define WI_RID_TEMP_TYPE 0xFD12 /* hw temp range code */
-#define WI_RID_CIS 0xFD13 /* PC card info struct */
-#define WI_RID_STA_IDENEITY 0xFD20 /* station funcs firmware ident */
-#define WI_RID_STA_SUP_RANGE 0xFD21 /* station supplier compat */
-#define WI_RID_MFI_ACT_RANGE 0xFD22
-#define WI_RID_CFI_ACT_RANGE 0xFD33
-
-/*
- * MAC information
- */
-#define WI_RID_PORT_STAT 0xFD40 /* actual MAC port con control stat */
-#define WI_RID_CURRENT_SSID 0xFD41 /* ID of actually connected SS */
-#define WI_RID_CURRENT_BSSID 0xFD42 /* ID of actually connected BSS */
-#define WI_RID_COMMS_QUALITY 0xFD43 /* quality of BSS connection */
-#define WI_RID_CUR_TX_RATE 0xFD44 /* current TX rate */
-#define WI_RID_OWN_BEACON_INT 0xFD45 /* beacon xmit time for BSS creation */
-#define WI_RID_CUR_SCALE_THRESH 0xFD46 /* actual system scane thresh setting */
-#define WI_RID_PROT_RESP_TIME 0xFD47 /* time to wait for resp to req msg */
-#define WI_RID_SHORT_RTR_LIM 0xFD48 /* max tx attempts for short frames */
-#define WI_RID_LONG_RTS_LIM 0xFD49 /* max tx attempts for long frames */
-#define WI_RID_MAX_TX_LIFE 0xFD4A /* max tx frame handling duration */
-#define WI_RID_MAX_RX_LIFE 0xFD4B /* max rx frame handling duration */
-#define WI_RID_CF_POLL 0xFD4C /* contention free pollable ind */
-#define WI_RID_AUTH_ALGS 0xFD4D /* auth algorithms available */
-#define WI_RID_AUTH_TYPE 0xFD4E /* availanle auth types */
-#define WI_RID_WEP_AVAIL 0xFD4F /* WEP privacy option available */
-#define WI_RID_CUR_TX_RATE1 0xFD80
-#define WI_RID_CUR_TX_RATE2 0xFD81
-#define WI_RID_CUR_TX_RATE3 0xFD82
-#define WI_RID_CUR_TX_RATE4 0xFD83
-#define WI_RID_CUR_TX_RATE5 0xFD84
-#define WI_RID_CUR_TX_RATE6 0xFD85
-#define WI_RID_OWN_MAC 0xFD86 /* unique local MAC addr */
-#define WI_RID_PCI_INFO 0xFD87 /* point coordination func cap */
-
-/*
- * Modem information
- */
-#define WI_RID_PHY_TYPE 0xFDC0 /* phys layer type indication */
-#define WI_RID_CURRENT_CHAN 0xFDC1 /* current frequency */
-#define WI_RID_PWR_STATE 0xFDC2 /* pwr consumption status */
-#define WI_RID_CCA_MODE 0xFDC3 /* clear chan assess mode indication */
-#define WI_RID_CCA_TIME 0xFDC4 /* clear chan assess time */
-#define WI_RID_MAC_PROC_DELAY 0xFDC5 /* MAC processing delay time */
-#define WI_RID_DATA_RATES 0xFDC6 /* supported data rates */
-#endif
-
-
-#endif
diff --git a/sys/dev/wi/if_wi.c b/sys/dev/wi/if_wi.c
deleted file mode 100644
index e678b021d7e0..000000000000
--- a/sys/dev/wi/if_wi.c
+++ /dev/null
@@ -1,1599 +0,0 @@
-/*
- * Copyright (c) 1997, 1998, 1999
- * Bill Paul <wpaul@ctr.columbia.edu>. 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 Bill Paul.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY Bill Paul 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 Bill Paul OR THE VOICES IN HIS HEAD
- * 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Lucent WaveLAN/IEEE 802.11 PCMCIA driver for FreeBSD.
- *
- * Written by Bill Paul <wpaul@ctr.columbia.edu>
- * Electrical Engineering Department
- * Columbia University, New York City
- */
-
-/*
- * The WaveLAN/IEEE adapter is the second generation of the WaveLAN
- * from Lucent. Unlike the older cards, the new ones are programmed
- * entirely via a firmware-driven controller called the Hermes.
- * Unfortunately, Lucent will not release the Hermes programming manual
- * without an NDA (if at all). What they do release is an API library
- * called the HCF (Hardware Control Functions) which is supposed to
- * do the device-specific operations of a device driver for you. The
- * publically available version of the HCF library (the 'HCF Light') is
- * a) extremely gross, b) lacks certain features, particularly support
- * for 802.11 frames, and c) is contaminated by the GNU Public License.
- *
- * This driver does not use the HCF or HCF Light at all. Instead, it
- * programs the Hermes controller directly, using information gleaned
- * from the HCF Light code and corresponding documentation.
- *
- * This driver supports both the PCMCIA and ISA versions of the
- * WaveLAN/IEEE cards. Note however that the ISA card isn't really
- * anything of the sort: it's actually a PCMCIA bridge adapter
- * that fits into an ISA slot, into which a PCMCIA WaveLAN card is
- * inserted. Consequently, you need to use the pccard support for
- * both the ISA and PCMCIA adapters.
- */
-
-#define WI_HERMES_AUTOINC_WAR /* Work around data write autoinc bug. */
-#define WI_HERMES_STATS_WAR /* Work around stats counter bug. */
-#define WICACHE /* turn on signal strength cache code */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/sockio.h>
-#include <sys/mbuf.h>
-#include <sys/malloc.h>
-#include <sys/kernel.h>
-#include <sys/socket.h>
-#include <sys/module.h>
-#include <sys/bus.h>
-#include <sys/syslog.h>
-#include <sys/sysctl.h>
-
-#include <machine/bus.h>
-#include <machine/resource.h>
-#include <machine/clock.h>
-#include <machine/md_var.h>
-#include <machine/bus_pio.h>
-#include <sys/rman.h>
-
-#include <net/if.h>
-#include <net/if_arp.h>
-#include <net/ethernet.h>
-#include <net/if_dl.h>
-#include <net/if_media.h>
-#include <net/if_types.h>
-
-#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/in_var.h>
-#include <netinet/ip.h>
-#include <netinet/if_ether.h>
-
-#include <net/bpf.h>
-
-#include <machine/if_wavelan_ieee.h>
-#include <i386/isa/if_wireg.h>
-
-#if !defined(lint)
-static const char rcsid[] =
- "$FreeBSD$";
-#endif
-
-#ifdef foo
-static u_int8_t wi_mcast_addr[6] = { 0x01, 0x60, 0x1D, 0x00, 0x01, 0x00 };
-#endif
-
-static void wi_intr __P((void *));
-static void wi_reset __P((struct wi_softc *));
-static int wi_ioctl __P((struct ifnet *, u_long, caddr_t));
-static void wi_init __P((void *));
-static void wi_start __P((struct ifnet *));
-static void wi_stop __P((struct wi_softc *));
-static void wi_watchdog __P((struct ifnet *));
-static void wi_rxeof __P((struct wi_softc *));
-static void wi_txeof __P((struct wi_softc *, int));
-static void wi_update_stats __P((struct wi_softc *));
-static void wi_setmulti __P((struct wi_softc *));
-
-static int wi_cmd __P((struct wi_softc *, int, int));
-static int wi_read_record __P((struct wi_softc *, struct wi_ltv_gen *));
-static int wi_write_record __P((struct wi_softc *, struct wi_ltv_gen *));
-static int wi_read_data __P((struct wi_softc *, int,
- int, caddr_t, int));
-static int wi_write_data __P((struct wi_softc *, int,
- int, caddr_t, int));
-static int wi_seek __P((struct wi_softc *, int, int, int));
-static int wi_alloc_nicmem __P((struct wi_softc *, int, int *));
-static void wi_inquire __P((void *));
-static void wi_setdef __P((struct wi_softc *, struct wi_req *));
-static int wi_mgmt_xmit __P((struct wi_softc *, caddr_t, int));
-
-#ifdef WICACHE
-static
-void wi_cache_store __P((struct wi_softc *, struct ether_header *,
- struct mbuf *, unsigned short));
-#endif
-
-static int wi_pccard_probe __P((device_t));
-static int wi_pccard_attach __P((device_t));
-static int wi_pccard_detach __P((device_t));
-static void wi_shutdown __P((device_t));
-
-static int wi_alloc __P((device_t));
-static void wi_free __P((device_t));
-
-static device_method_t wi_pccard_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, wi_pccard_probe),
- DEVMETHOD(device_attach, wi_pccard_attach),
- DEVMETHOD(device_detach, wi_pccard_detach),
- DEVMETHOD(device_shutdown, wi_shutdown),
-
- { 0, 0 }
-};
-
-static driver_t wi_pccard_driver = {
- "wi",
- wi_pccard_methods,
- sizeof(struct wi_softc)
-};
-
-static devclass_t wi_pccard_devclass;
-
-DRIVER_MODULE(if_wi, pccard, wi_pccard_driver, wi_pccard_devclass, 0, 0);
-
-static int wi_pccard_probe(dev)
- device_t dev;
-{
- struct wi_softc *sc;
- int error;
-
- sc = device_get_softc(dev);
- sc->wi_gone = 0;
-
- error = wi_alloc(dev);
- if (error)
- return (error);
-
- device_set_desc(dev, "WaveLAN/IEEE 802.11");
- wi_free(dev);
-
- /* Make sure interrupts are disabled. */
- CSR_WRITE_2(sc, WI_INT_EN, 0);
- CSR_WRITE_2(sc, WI_EVENT_ACK, 0xFFFF);
-
- return (0);
-}
-
-static int wi_pccard_detach(dev)
- device_t dev;
-{
- struct wi_softc *sc;
- struct ifnet *ifp;
- int s;
-
- s = splimp();
-
- sc = device_get_softc(dev);
- ifp = &sc->arpcom.ac_if;
-
- if (sc->wi_gone) {
- device_printf(dev, "already unloaded\n");
- return(ENODEV);
- }
-
- wi_stop(sc);
- if_detach(ifp);
- bus_teardown_intr(dev, sc->irq, sc->wi_intrhand);
- wi_free(dev);
- sc->wi_gone = 1;
-
- splx(s);
- device_printf(dev, "unload\n");
-
- return(0);
-}
-
-static int wi_pccard_attach(device_t dev)
-{
- struct wi_softc *sc;
- struct wi_ltv_macaddr mac;
- struct wi_ltv_gen gen;
- struct ifnet *ifp;
- int error;
-
- sc = device_get_softc(dev);
- ifp = &sc->arpcom.ac_if;
-
- error = wi_alloc(dev);
- if (error) {
- device_printf(dev, "wi_alloc() failed! (%d)\n", error);
- return (error);
- }
-
- error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET,
- wi_intr, sc, &sc->wi_intrhand);
-
- if (error) {
- device_printf(dev, "bus_setup_intr() failed! (%d)\n", error);
- wi_free(dev);
- return (error);
- }
-
- /* Reset the NIC. */
- wi_reset(sc);
-
- /* Read the station address. */
- mac.wi_type = WI_RID_MAC_NODE;
- mac.wi_len = 4;
- wi_read_record(sc, (struct wi_ltv_gen *)&mac);
- bcopy((char *)&mac.wi_mac_addr,
- (char *)&sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
-
- device_printf(dev, "Ethernet address: %6D\n",
- sc->arpcom.ac_enaddr, ":");
-
- ifp->if_softc = sc;
- ifp->if_unit = sc->wi_unit;
- ifp->if_name = "wi";
- ifp->if_mtu = ETHERMTU;
- ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
- ifp->if_ioctl = wi_ioctl;
- ifp->if_output = ether_output;
- ifp->if_start = wi_start;
- ifp->if_watchdog = wi_watchdog;
- ifp->if_init = wi_init;
- ifp->if_baudrate = 10000000;
- ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
-
- bzero(sc->wi_node_name, sizeof(sc->wi_node_name));
- bcopy(WI_DEFAULT_NODENAME, sc->wi_node_name,
- sizeof(WI_DEFAULT_NODENAME) - 1);
-
- bzero(sc->wi_net_name, sizeof(sc->wi_net_name));
- bcopy(WI_DEFAULT_NETNAME, sc->wi_net_name,
- sizeof(WI_DEFAULT_NETNAME) - 1);
-
- bzero(sc->wi_ibss_name, sizeof(sc->wi_ibss_name));
- bcopy(WI_DEFAULT_IBSS, sc->wi_ibss_name,
- sizeof(WI_DEFAULT_IBSS) - 1);
-
- sc->wi_portnum = WI_DEFAULT_PORT;
- sc->wi_ptype = WI_PORTTYPE_ADHOC;
- sc->wi_ap_density = WI_DEFAULT_AP_DENSITY;
- sc->wi_rts_thresh = WI_DEFAULT_RTS_THRESH;
- sc->wi_tx_rate = WI_DEFAULT_TX_RATE;
- sc->wi_max_data_len = WI_DEFAULT_DATALEN;
- sc->wi_create_ibss = WI_DEFAULT_CREATE_IBSS;
- sc->wi_pm_enabled = WI_DEFAULT_PM_ENABLED;
- sc->wi_max_sleep = WI_DEFAULT_MAX_SLEEP;
-
- /*
- * Read the default channel from the NIC. This may vary
- * depending on the country where the NIC was purchased, so
- * we can't hard-code a default and expect it to work for
- * everyone.
- */
- gen.wi_type = WI_RID_OWN_CHNL;
- gen.wi_len = 2;
- wi_read_record(sc, &gen);
- sc->wi_channel = gen.wi_val;
-
- /*
- * Find out if we support WEP on this card.
- */
- gen.wi_type = WI_RID_WEP_AVAIL;
- gen.wi_len = 2;
- wi_read_record(sc, &gen);
- sc->wi_has_wep = gen.wi_val;
-
- bzero((char *)&sc->wi_stats, sizeof(sc->wi_stats));
-
- wi_init(sc);
- wi_stop(sc);
-
- /*
- * Call MI attach routines.
- */
- if_attach(ifp);
- ether_ifattach(ifp);
- callout_handle_init(&sc->wi_stat_ch);
- bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
-
- return(0);
-}
-
-static void wi_rxeof(sc)
- struct wi_softc *sc;
-{
- struct ifnet *ifp;
- struct ether_header *eh;
- struct wi_frame rx_frame;
- struct mbuf *m;
- int id;
-
- ifp = &sc->arpcom.ac_if;
-
- id = CSR_READ_2(sc, WI_RX_FID);
-
- /* First read in the frame header */
- if (wi_read_data(sc, id, 0, (caddr_t)&rx_frame, sizeof(rx_frame))) {
- ifp->if_ierrors++;
- return;
- }
-
- if (rx_frame.wi_status & WI_STAT_ERRSTAT) {
- ifp->if_ierrors++;
- return;
- }
-
- MGETHDR(m, M_DONTWAIT, MT_DATA);
- if (m == NULL) {
- ifp->if_ierrors++;
- return;
- }
- MCLGET(m, M_DONTWAIT);
- if (!(m->m_flags & M_EXT)) {
- m_freem(m);
- ifp->if_ierrors++;
- return;
- }
-
- eh = mtod(m, struct ether_header *);
- m->m_pkthdr.rcvif = ifp;
-
- if (rx_frame.wi_status == WI_STAT_1042 ||
- rx_frame.wi_status == WI_STAT_TUNNEL ||
- rx_frame.wi_status == WI_STAT_WMP_MSG) {
- if((rx_frame.wi_dat_len + WI_SNAPHDR_LEN) > MCLBYTES) {
- device_printf(sc->dev, "oversized packet received "
- "(wi_dat_len=%d, wi_status=0x%x)\n",
- rx_frame.wi_dat_len, rx_frame.wi_status);
- m_freem(m);
- ifp->if_ierrors++;
- return;
- }
- m->m_pkthdr.len = m->m_len =
- rx_frame.wi_dat_len + WI_SNAPHDR_LEN;
-
- bcopy((char *)&rx_frame.wi_addr1,
- (char *)&eh->ether_dhost, ETHER_ADDR_LEN);
- bcopy((char *)&rx_frame.wi_addr2,
- (char *)&eh->ether_shost, ETHER_ADDR_LEN);
- bcopy((char *)&rx_frame.wi_type,
- (char *)&eh->ether_type, sizeof(u_int16_t));
-
- if (wi_read_data(sc, id, WI_802_11_OFFSET,
- mtod(m, caddr_t) + sizeof(struct ether_header),
- m->m_len + 2)) {
- m_freem(m);
- ifp->if_ierrors++;
- return;
- }
- } else {
- if((rx_frame.wi_dat_len +
- sizeof(struct ether_header)) > MCLBYTES) {
- device_printf(sc->dev, "oversized packet received "
- "(wi_dat_len=%d, wi_status=0x%x)\n",
- rx_frame.wi_dat_len, rx_frame.wi_status);
- m_freem(m);
- ifp->if_ierrors++;
- return;
- }
- m->m_pkthdr.len = m->m_len =
- rx_frame.wi_dat_len + sizeof(struct ether_header);
-
- if (wi_read_data(sc, id, WI_802_3_OFFSET,
- mtod(m, caddr_t), m->m_len + 2)) {
- m_freem(m);
- ifp->if_ierrors++;
- return;
- }
- }
-
- ifp->if_ipackets++;
-
- /* Handle BPF listeners. */
- if (ifp->if_bpf) {
- bpf_mtap(ifp, m);
- if (ifp->if_flags & IFF_PROMISC &&
- (bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr,
- ETHER_ADDR_LEN) && (eh->ether_dhost[0] & 1) == 0)) {
- m_freem(m);
- return;
- }
- }
-
- /* Receive packet. */
- m_adj(m, sizeof(struct ether_header));
-#ifdef WICACHE
- wi_cache_store(sc, eh, m, rx_frame.wi_q_info);
-#endif
- ether_input(ifp, eh, m);
-
- return;
-}
-
-static void wi_txeof(sc, status)
- struct wi_softc *sc;
- int status;
-{
- struct ifnet *ifp;
-
- ifp = &sc->arpcom.ac_if;
-
- ifp->if_timer = 0;
- ifp->if_flags &= ~IFF_OACTIVE;
-
- if (status & WI_EV_TX_EXC)
- ifp->if_oerrors++;
- else
- ifp->if_opackets++;
-
- return;
-}
-
-void wi_inquire(xsc)
- void *xsc;
-{
- struct wi_softc *sc;
- struct ifnet *ifp;
-
- sc = xsc;
- ifp = &sc->arpcom.ac_if;
-
- sc->wi_stat_ch = timeout(wi_inquire, sc, hz * 60);
-
- /* Don't do this while we're transmitting */
- if (ifp->if_flags & IFF_OACTIVE)
- return;
-
- wi_cmd(sc, WI_CMD_INQUIRE, WI_INFO_COUNTERS);
-
- return;
-}
-
-void wi_update_stats(sc)
- struct wi_softc *sc;
-{
- struct wi_ltv_gen gen;
- u_int16_t id;
- struct ifnet *ifp;
- u_int32_t *ptr;
- int i;
- u_int16_t t;
-
- ifp = &sc->arpcom.ac_if;
-
- id = CSR_READ_2(sc, WI_INFO_FID);
-
- wi_read_data(sc, id, 0, (char *)&gen, 4);
-
- if (gen.wi_type != WI_INFO_COUNTERS ||
- gen.wi_len > (sizeof(sc->wi_stats) / 4) + 1)
- return;
-
- ptr = (u_int32_t *)&sc->wi_stats;
-
- for (i = 0; i < gen.wi_len - 1; i++) {
- t = CSR_READ_2(sc, WI_DATA1);
-#ifdef WI_HERMES_STATS_WAR
- if (t > 0xF000)
- t = ~t & 0xFFFF;
-#endif
- ptr[i] += t;
- }
-
- ifp->if_collisions = sc->wi_stats.wi_tx_single_retries +
- sc->wi_stats.wi_tx_multi_retries +
- sc->wi_stats.wi_tx_retry_limit;
-
- return;
-}
-
-static void wi_intr(xsc)
- void *xsc;
-{
- struct wi_softc *sc = xsc;
- struct ifnet *ifp;
- u_int16_t status;
-
- ifp = &sc->arpcom.ac_if;
-
- if (!(ifp->if_flags & IFF_UP)) {
- CSR_WRITE_2(sc, WI_EVENT_ACK, 0xFFFF);
- CSR_WRITE_2(sc, WI_INT_EN, 0);
- return;
- }
-
- /* Disable interrupts. */
- CSR_WRITE_2(sc, WI_INT_EN, 0);
-
- status = CSR_READ_2(sc, WI_EVENT_STAT);
- CSR_WRITE_2(sc, WI_EVENT_ACK, ~WI_INTRS);
-
- if (status & WI_EV_RX) {
- wi_rxeof(sc);
- CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_RX);
- }
-
- if (status & WI_EV_TX) {
- wi_txeof(sc, status);
- CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_TX);
- }
-
- if (status & WI_EV_ALLOC) {
- int id;
- id = CSR_READ_2(sc, WI_ALLOC_FID);
- CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_ALLOC);
- if (id == sc->wi_tx_data_id)
- wi_txeof(sc, status);
- }
-
- if (status & WI_EV_INFO) {
- wi_update_stats(sc);
- CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_INFO);
- }
-
- if (status & WI_EV_TX_EXC) {
- wi_txeof(sc, status);
- CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_TX_EXC);
- }
-
- if (status & WI_EV_INFO_DROP) {
- CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_INFO_DROP);
- }
-
- /* Re-enable interrupts. */
- CSR_WRITE_2(sc, WI_INT_EN, WI_INTRS);
-
- if (ifp->if_snd.ifq_head != NULL)
- wi_start(ifp);
-
- return;
-}
-
-static int wi_cmd(sc, cmd, val)
- struct wi_softc *sc;
- int cmd;
- int val;
-{
- int i, s = 0;
-
- CSR_WRITE_2(sc, WI_PARAM0, val);
- CSR_WRITE_2(sc, WI_COMMAND, cmd);
-
- for (i = 0; i < WI_TIMEOUT; i++) {
- /*
- * Wait for 'command complete' bit to be
- * set in the event status register.
- */
- s = CSR_READ_2(sc, WI_EVENT_STAT) & WI_EV_CMD;
- if (s) {
- /* Ack the event and read result code. */
- s = CSR_READ_2(sc, WI_STATUS);
- CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_CMD);
-#ifdef foo
- if ((s & WI_CMD_CODE_MASK) != (cmd & WI_CMD_CODE_MASK))
- return(EIO);
-#endif
- if (s & WI_STAT_CMD_RESULT)
- return(EIO);
- break;
- }
- }
-
- if (i == WI_TIMEOUT)
- return(ETIMEDOUT);
-
- return(0);
-}
-
-static void wi_reset(sc)
- struct wi_softc *sc;
-{
- wi_cmd(sc, WI_CMD_INI, 0);
- DELAY(100000);
- wi_cmd(sc, WI_CMD_INI, 0);
- DELAY(100000);
-#ifdef foo
- if (wi_cmd(sc, WI_CMD_INI, 0))
- device_printf(sc->dev, "init failed\n");
- CSR_WRITE_2(sc, WI_INT_EN, 0);
- CSR_WRITE_2(sc, WI_EVENT_ACK, 0xFFFF);
-
- /* Calibrate timer. */
- WI_SETVAL(WI_RID_TICK_TIME, 8);
-#endif
- return;
-}
-
-/*
- * Read an LTV record from the NIC.
- */
-static int wi_read_record(sc, ltv)
- struct wi_softc *sc;
- struct wi_ltv_gen *ltv;
-{
- u_int16_t *ptr;
- int i, len, code;
-
- /* Tell the NIC to enter record read mode. */
- if (wi_cmd(sc, WI_CMD_ACCESS|WI_ACCESS_READ, ltv->wi_type))
- return(EIO);
-
- /* Seek to the record. */
- if (wi_seek(sc, ltv->wi_type, 0, WI_BAP1))
- return(EIO);
-
- /*
- * Read the length and record type and make sure they
- * match what we expect (this verifies that we have enough
- * room to hold all of the returned data).
- */
- len = CSR_READ_2(sc, WI_DATA1);
- if (len > ltv->wi_len)
- return(ENOSPC);
- code = CSR_READ_2(sc, WI_DATA1);
- if (code != ltv->wi_type)
- return(EIO);
-
- ltv->wi_len = len;
- ltv->wi_type = code;
-
- /* Now read the data. */
- ptr = &ltv->wi_val;
- for (i = 0; i < ltv->wi_len - 1; i++)
- ptr[i] = CSR_READ_2(sc, WI_DATA1);
-
- return(0);
-}
-
-/*
- * Same as read, except we inject data instead of reading it.
- */
-static int wi_write_record(sc, ltv)
- struct wi_softc *sc;
- struct wi_ltv_gen *ltv;
-{
- u_int16_t *ptr;
- int i;
-
- if (wi_seek(sc, ltv->wi_type, 0, WI_BAP1))
- return(EIO);
-
- CSR_WRITE_2(sc, WI_DATA1, ltv->wi_len);
- CSR_WRITE_2(sc, WI_DATA1, ltv->wi_type);
-
- ptr = &ltv->wi_val;
- for (i = 0; i < ltv->wi_len - 1; i++)
- CSR_WRITE_2(sc, WI_DATA1, ptr[i]);
-
- if (wi_cmd(sc, WI_CMD_ACCESS|WI_ACCESS_WRITE, ltv->wi_type))
- return(EIO);
-
- return(0);
-}
-
-static int wi_seek(sc, id, off, chan)
- struct wi_softc *sc;
- int id, off, chan;
-{
- int i;
- int selreg, offreg;
-
- switch (chan) {
- case WI_BAP0:
- selreg = WI_SEL0;
- offreg = WI_OFF0;
- break;
- case WI_BAP1:
- selreg = WI_SEL1;
- offreg = WI_OFF1;
- break;
- default:
- device_printf(sc->dev, "invalid data path: %x\n", chan);
- return(EIO);
- }
-
- CSR_WRITE_2(sc, selreg, id);
- CSR_WRITE_2(sc, offreg, off);
-
- for (i = 0; i < WI_TIMEOUT; i++) {
- if (!(CSR_READ_2(sc, offreg) & (WI_OFF_BUSY|WI_OFF_ERR)))
- break;
- }
-
- if (i == WI_TIMEOUT)
- return(ETIMEDOUT);
-
- return(0);
-}
-
-static int wi_read_data(sc, id, off, buf, len)
- struct wi_softc *sc;
- int id, off;
- caddr_t buf;
- int len;
-{
- int i;
- u_int16_t *ptr;
-
- if (wi_seek(sc, id, off, WI_BAP1))
- return(EIO);
-
- ptr = (u_int16_t *)buf;
- for (i = 0; i < len / 2; i++)
- ptr[i] = CSR_READ_2(sc, WI_DATA1);
-
- return(0);
-}
-
-/*
- * According to the comments in the HCF Light code, there is a bug in
- * the Hermes (or possibly in certain Hermes firmware revisions) where
- * the chip's internal autoincrement counter gets thrown off during
- * data writes: the autoincrement is missed, causing one data word to
- * be overwritten and subsequent words to be written to the wrong memory
- * locations. The end result is that we could end up transmitting bogus
- * frames without realizing it. The workaround for this is to write a
- * couple of extra guard words after the end of the transfer, then
- * attempt to read then back. If we fail to locate the guard words where
- * we expect them, we preform the transfer over again.
- */
-static int wi_write_data(sc, id, off, buf, len)
- struct wi_softc *sc;
- int id, off;
- caddr_t buf;
- int len;
-{
- int i;
- u_int16_t *ptr;
-
-#ifdef WI_HERMES_AUTOINC_WAR
-again:
-#endif
-
- if (wi_seek(sc, id, off, WI_BAP0))
- return(EIO);
-
- ptr = (u_int16_t *)buf;
- for (i = 0; i < (len / 2); i++)
- CSR_WRITE_2(sc, WI_DATA0, ptr[i]);
-
-#ifdef WI_HERMES_AUTOINC_WAR
- CSR_WRITE_2(sc, WI_DATA0, 0x1234);
- CSR_WRITE_2(sc, WI_DATA0, 0x5678);
-
- if (wi_seek(sc, id, off + len, WI_BAP0))
- return(EIO);
-
- if (CSR_READ_2(sc, WI_DATA0) != 0x1234 ||
- CSR_READ_2(sc, WI_DATA0) != 0x5678)
- goto again;
-#endif
-
- return(0);
-}
-
-/*
- * Allocate a region of memory inside the NIC and zero
- * it out.
- */
-static int wi_alloc_nicmem(sc, len, id)
- struct wi_softc *sc;
- int len;
- int *id;
-{
- int i;
-
- if (wi_cmd(sc, WI_CMD_ALLOC_MEM, len)) {
- device_printf(sc->dev, "failed to allocate %d bytes on NIC\n", len);
- return(ENOMEM);
- }
-
- for (i = 0; i < WI_TIMEOUT; i++) {
- if (CSR_READ_2(sc, WI_EVENT_STAT) & WI_EV_ALLOC)
- break;
- }
-
- if (i == WI_TIMEOUT)
- return(ETIMEDOUT);
-
- CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_ALLOC);
- *id = CSR_READ_2(sc, WI_ALLOC_FID);
-
- if (wi_seek(sc, *id, 0, WI_BAP0))
- return(EIO);
-
- for (i = 0; i < len / 2; i++)
- CSR_WRITE_2(sc, WI_DATA0, 0);
-
- return(0);
-}
-
-static void wi_setmulti(sc)
- struct wi_softc *sc;
-{
- struct ifnet *ifp;
- int i = 0;
- struct ifmultiaddr *ifma;
- struct wi_ltv_mcast mcast;
-
- ifp = &sc->arpcom.ac_if;
-
- bzero((char *)&mcast, sizeof(mcast));
-
- mcast.wi_type = WI_RID_MCAST;
- mcast.wi_len = (3 * 16) + 1;
-
- if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) {
- wi_write_record(sc, (struct wi_ltv_gen *)&mcast);
- return;
- }
-
- for (ifma = ifp->if_multiaddrs.lh_first; ifma != NULL;
- ifma = ifma->ifma_link.le_next) {
- if (ifma->ifma_addr->sa_family != AF_LINK)
- continue;
- if (i < 16) {
- bcopy(LLADDR((struct sockaddr_dl *)ifma->ifma_addr),
- (char *)&mcast.wi_mcast[i], ETHER_ADDR_LEN);
- i++;
- } else {
- bzero((char *)&mcast, sizeof(mcast));
- break;
- }
- }
-
- mcast.wi_len = (i * 3) + 1;
- wi_write_record(sc, (struct wi_ltv_gen *)&mcast);
-
- return;
-}
-
-static void wi_setdef(sc, wreq)
- struct wi_softc *sc;
- struct wi_req *wreq;
-{
- struct sockaddr_dl *sdl;
- struct ifaddr *ifa;
- struct ifnet *ifp;
-
- ifp = &sc->arpcom.ac_if;
-
- switch(wreq->wi_type) {
- case WI_RID_MAC_NODE:
- ifa = ifnet_addrs[ifp->if_index - 1];
- sdl = (struct sockaddr_dl *)ifa->ifa_addr;
- bcopy((char *)&wreq->wi_val, (char *)&sc->arpcom.ac_enaddr,
- ETHER_ADDR_LEN);
- bcopy((char *)&wreq->wi_val, LLADDR(sdl), ETHER_ADDR_LEN);
- break;
- case WI_RID_PORTTYPE:
- sc->wi_ptype = wreq->wi_val[0];
- break;
- case WI_RID_TX_RATE:
- sc->wi_tx_rate = wreq->wi_val[0];
- break;
- case WI_RID_MAX_DATALEN:
- sc->wi_max_data_len = wreq->wi_val[0];
- break;
- case WI_RID_RTS_THRESH:
- sc->wi_rts_thresh = wreq->wi_val[0];
- break;
- case WI_RID_SYSTEM_SCALE:
- sc->wi_ap_density = wreq->wi_val[0];
- break;
- case WI_RID_CREATE_IBSS:
- sc->wi_create_ibss = wreq->wi_val[0];
- break;
- case WI_RID_OWN_CHNL:
- sc->wi_channel = wreq->wi_val[0];
- break;
- case WI_RID_NODENAME:
- bzero(sc->wi_node_name, sizeof(sc->wi_node_name));
- bcopy((char *)&wreq->wi_val[1], sc->wi_node_name, 30);
- break;
- case WI_RID_DESIRED_SSID:
- bzero(sc->wi_net_name, sizeof(sc->wi_net_name));
- bcopy((char *)&wreq->wi_val[1], sc->wi_net_name, 30);
- break;
- case WI_RID_OWN_SSID:
- bzero(sc->wi_ibss_name, sizeof(sc->wi_ibss_name));
- bcopy((char *)&wreq->wi_val[1], sc->wi_ibss_name, 30);
- break;
- case WI_RID_PM_ENABLED:
- sc->wi_pm_enabled = wreq->wi_val[0];
- break;
- case WI_RID_MAX_SLEEP:
- sc->wi_max_sleep = wreq->wi_val[0];
- break;
- case WI_RID_ENCRYPTION:
- sc->wi_use_wep = wreq->wi_val[0];
- break;
- case WI_RID_TX_CRYPT_KEY:
- sc->wi_tx_key = wreq->wi_val[0];
- break;
- case WI_RID_DEFLT_CRYPT_KEYS:
- bcopy((char *)wreq, (char *)&sc->wi_keys,
- sizeof(struct wi_ltv_keys));
- break;
- default:
- break;
- }
-
- /* Reinitialize WaveLAN. */
- wi_init(sc);
-
- return;
-}
-
-static int wi_ioctl(ifp, command, data)
- struct ifnet *ifp;
- u_long command;
- caddr_t data;
-{
- int s, error = 0;
- struct wi_softc *sc;
- struct wi_req wreq;
- struct ifreq *ifr;
-
- s = splimp();
-
- sc = ifp->if_softc;
- ifr = (struct ifreq *)data;
-
- if (sc->wi_gone)
- return(ENODEV);
-
- switch(command) {
- case SIOCSIFADDR:
- case SIOCGIFADDR:
- case SIOCSIFMTU:
- error = ether_ioctl(ifp, command, data);
- break;
- case SIOCSIFFLAGS:
- if (ifp->if_flags & IFF_UP) {
- if (ifp->if_flags & IFF_RUNNING &&
- ifp->if_flags & IFF_PROMISC &&
- !(sc->wi_if_flags & IFF_PROMISC)) {
- WI_SETVAL(WI_RID_PROMISC, 1);
- } else if (ifp->if_flags & IFF_RUNNING &&
- !(ifp->if_flags & IFF_PROMISC) &&
- sc->wi_if_flags & IFF_PROMISC) {
- WI_SETVAL(WI_RID_PROMISC, 0);
- } else
- wi_init(sc);
- } else {
- if (ifp->if_flags & IFF_RUNNING) {
- wi_stop(sc);
- }
- }
- sc->wi_if_flags = ifp->if_flags;
- error = 0;
- break;
- case SIOCADDMULTI:
- case SIOCDELMULTI:
- wi_setmulti(sc);
- error = 0;
- break;
- case SIOCGWAVELAN:
- error = copyin(ifr->ifr_data, &wreq, sizeof(wreq));
- if (error)
- break;
- if (wreq.wi_type == WI_RID_IFACE_STATS) {
- bcopy((char *)&sc->wi_stats, (char *)&wreq.wi_val,
- sizeof(sc->wi_stats));
- wreq.wi_len = (sizeof(sc->wi_stats) / 2) + 1;
- } else if (wreq.wi_type == WI_RID_DEFLT_CRYPT_KEYS) {
- bcopy((char *)&sc->wi_keys, (char *)&wreq,
- sizeof(struct wi_ltv_keys));
- }
-#ifdef WICACHE
- else if (wreq.wi_type == WI_RID_ZERO_CACHE) {
- sc->wi_sigitems = sc->wi_nextitem = 0;
- } else if (wreq.wi_type == WI_RID_READ_CACHE) {
- char *pt = (char *)&wreq.wi_val;
- bcopy((char *)&sc->wi_sigitems,
- (char *)pt, sizeof(int));
- pt += (sizeof (int));
- wreq.wi_len = sizeof(int) / 2;
- bcopy((char *)&sc->wi_sigcache, (char *)pt,
- sizeof(struct wi_sigcache) * sc->wi_sigitems);
- wreq.wi_len += ((sizeof(struct wi_sigcache) *
- sc->wi_sigitems) / 2) + 1;
- }
-#endif
- else {
- if (wi_read_record(sc, (struct wi_ltv_gen *)&wreq)) {
- error = EINVAL;
- break;
- }
- }
- error = copyout(&wreq, ifr->ifr_data, sizeof(wreq));
- break;
- case SIOCSWAVELAN:
- error = copyin(ifr->ifr_data, &wreq, sizeof(wreq));
- if (error)
- break;
- if (wreq.wi_type == WI_RID_IFACE_STATS) {
- error = EINVAL;
- break;
- } else if (wreq.wi_type == WI_RID_MGMT_XMIT) {
- error = wi_mgmt_xmit(sc, (caddr_t)&wreq.wi_val,
- wreq.wi_len);
- } else {
- error = wi_write_record(sc, (struct wi_ltv_gen *)&wreq);
- if (!error)
- wi_setdef(sc, &wreq);
- }
- break;
- default:
- error = EINVAL;
- break;
- }
-
- splx(s);
-
- return(error);
-}
-
-static void wi_init(xsc)
- void *xsc;
-{
- struct wi_softc *sc = xsc;
- struct ifnet *ifp = &sc->arpcom.ac_if;
- int s;
- struct wi_ltv_macaddr mac;
- int id = 0;
-
- if (sc->wi_gone)
- return;
-
- s = splimp();
-
- if (ifp->if_flags & IFF_RUNNING)
- wi_stop(sc);
-
- wi_reset(sc);
-
- /* Program max data length. */
- WI_SETVAL(WI_RID_MAX_DATALEN, sc->wi_max_data_len);
-
- /* Enable/disable IBSS creation. */
- WI_SETVAL(WI_RID_CREATE_IBSS, sc->wi_create_ibss);
-
- /* Set the port type. */
- WI_SETVAL(WI_RID_PORTTYPE, sc->wi_ptype);
-
- /* Program the RTS/CTS threshold. */
- WI_SETVAL(WI_RID_RTS_THRESH, sc->wi_rts_thresh);
-
- /* Program the TX rate */
- WI_SETVAL(WI_RID_TX_RATE, sc->wi_tx_rate);
-
- /* Access point density */
- WI_SETVAL(WI_RID_SYSTEM_SCALE, sc->wi_ap_density);
-
- /* Power Management Enabled */
- WI_SETVAL(WI_RID_PM_ENABLED, sc->wi_pm_enabled);
-
- /* Power Managment Max Sleep */
- WI_SETVAL(WI_RID_MAX_SLEEP, sc->wi_max_sleep);
-
- /* Specify the IBSS name */
- WI_SETSTR(WI_RID_OWN_SSID, sc->wi_ibss_name);
-
- /* Specify the network name */
- WI_SETSTR(WI_RID_DESIRED_SSID, sc->wi_net_name);
-
- /* Specify the frequency to use */
- WI_SETVAL(WI_RID_OWN_CHNL, sc->wi_channel);
-
- /* Program the nodename. */
- WI_SETSTR(WI_RID_NODENAME, sc->wi_node_name);
-
- /* Set our MAC address. */
- mac.wi_len = 4;
- mac.wi_type = WI_RID_MAC_NODE;
- bcopy((char *)&sc->arpcom.ac_enaddr,
- (char *)&mac.wi_mac_addr, ETHER_ADDR_LEN);
- wi_write_record(sc, (struct wi_ltv_gen *)&mac);
-
- /* Configure WEP. */
- if (sc->wi_has_wep) {
- WI_SETVAL(WI_RID_ENCRYPTION, sc->wi_use_wep);
- WI_SETVAL(WI_RID_TX_CRYPT_KEY, sc->wi_tx_key);
- sc->wi_keys.wi_len = (sizeof(struct wi_ltv_keys) / 2) + 1;
- sc->wi_keys.wi_type = WI_RID_DEFLT_CRYPT_KEYS;
- wi_write_record(sc, (struct wi_ltv_gen *)&sc->wi_keys);
- }
-
- /* Initialize promisc mode. */
- if (ifp->if_flags & IFF_PROMISC) {
- WI_SETVAL(WI_RID_PROMISC, 1);
- } else {
- WI_SETVAL(WI_RID_PROMISC, 0);
- }
-
- /* Set multicast filter. */
- wi_setmulti(sc);
-
- /* Enable desired port */
- wi_cmd(sc, WI_CMD_ENABLE|sc->wi_portnum, 0);
-
- if (wi_alloc_nicmem(sc, 1518 + sizeof(struct wi_frame) + 8, &id))
- device_printf(sc->dev, "tx buffer allocation failed\n");
- sc->wi_tx_data_id = id;
-
- if (wi_alloc_nicmem(sc, 1518 + sizeof(struct wi_frame) + 8, &id))
- device_printf(sc->dev, "mgmt. buffer allocation failed\n");
- sc->wi_tx_mgmt_id = id;
-
- /* enable interrupts */
- CSR_WRITE_2(sc, WI_INT_EN, WI_INTRS);
-
- splx(s);
-
- ifp->if_flags |= IFF_RUNNING;
- ifp->if_flags &= ~IFF_OACTIVE;
-
- sc->wi_stat_ch = timeout(wi_inquire, sc, hz * 60);
-
- return;
-}
-
-static void wi_start(ifp)
- struct ifnet *ifp;
-{
- struct wi_softc *sc;
- struct mbuf *m0;
- struct wi_frame tx_frame;
- struct ether_header *eh;
- int id;
-
- sc = ifp->if_softc;
-
- if (sc->wi_gone)
- return;
-
- if (ifp->if_flags & IFF_OACTIVE)
- return;
-
- IF_DEQUEUE(&ifp->if_snd, m0);
- if (m0 == NULL)
- return;
-
- bzero((char *)&tx_frame, sizeof(tx_frame));
- id = sc->wi_tx_data_id;
- eh = mtod(m0, struct ether_header *);
-
- /*
- * Use RFC1042 encoding for IP and ARP datagrams,
- * 802.3 for anything else.
- */
- if (ntohs(eh->ether_type) > 1518) {
- bcopy((char *)&eh->ether_dhost,
- (char *)&tx_frame.wi_addr1, ETHER_ADDR_LEN);
- bcopy((char *)&eh->ether_shost,
- (char *)&tx_frame.wi_addr2, ETHER_ADDR_LEN);
- bcopy((char *)&eh->ether_dhost,
- (char *)&tx_frame.wi_dst_addr, ETHER_ADDR_LEN);
- bcopy((char *)&eh->ether_shost,
- (char *)&tx_frame.wi_src_addr, ETHER_ADDR_LEN);
-
- tx_frame.wi_dat_len = m0->m_pkthdr.len - WI_SNAPHDR_LEN;
- tx_frame.wi_frame_ctl = WI_FTYPE_DATA;
- tx_frame.wi_dat[0] = htons(WI_SNAP_WORD0);
- tx_frame.wi_dat[1] = htons(WI_SNAP_WORD1);
- tx_frame.wi_len = htons(m0->m_pkthdr.len - WI_SNAPHDR_LEN);
- tx_frame.wi_type = eh->ether_type;
-
- m_copydata(m0, sizeof(struct ether_header),
- m0->m_pkthdr.len - sizeof(struct ether_header),
- (caddr_t)&sc->wi_txbuf);
-
- wi_write_data(sc, id, 0, (caddr_t)&tx_frame,
- sizeof(struct wi_frame));
- wi_write_data(sc, id, WI_802_11_OFFSET, (caddr_t)&sc->wi_txbuf,
- (m0->m_pkthdr.len - sizeof(struct ether_header)) + 2);
- } else {
- tx_frame.wi_dat_len = m0->m_pkthdr.len;
-
- eh->ether_type = htons(m0->m_pkthdr.len - WI_SNAPHDR_LEN);
- m_copydata(m0, 0, m0->m_pkthdr.len, (caddr_t)&sc->wi_txbuf);
-
- wi_write_data(sc, id, 0, (caddr_t)&tx_frame,
- sizeof(struct wi_frame));
- wi_write_data(sc, id, WI_802_3_OFFSET, (caddr_t)&sc->wi_txbuf,
- m0->m_pkthdr.len + 2);
- }
-
- /*
- * If there's a BPF listner, bounce a copy of
- * this frame to him.
- */
- if (ifp->if_bpf)
- bpf_mtap(ifp, m0);
-
- m_freem(m0);
-
- if (wi_cmd(sc, WI_CMD_TX|WI_RECLAIM, id))
- device_printf(sc->dev, "xmit failed\n");
-
- ifp->if_flags |= IFF_OACTIVE;
-
- /*
- * Set a timeout in case the chip goes out to lunch.
- */
- ifp->if_timer = 5;
-
- return;
-}
-
-static int wi_mgmt_xmit(sc, data, len)
- struct wi_softc *sc;
- caddr_t data;
- int len;
-{
- struct wi_frame tx_frame;
- int id;
- struct wi_80211_hdr *hdr;
- caddr_t dptr;
-
- if (sc->wi_gone)
- return(ENODEV);
-
- hdr = (struct wi_80211_hdr *)data;
- dptr = data + sizeof(struct wi_80211_hdr);
-
- bzero((char *)&tx_frame, sizeof(tx_frame));
- id = sc->wi_tx_mgmt_id;
-
- bcopy((char *)hdr, (char *)&tx_frame.wi_frame_ctl,
- sizeof(struct wi_80211_hdr));
-
- tx_frame.wi_dat_len = len - WI_SNAPHDR_LEN;
- tx_frame.wi_len = htons(len - WI_SNAPHDR_LEN);
-
- wi_write_data(sc, id, 0, (caddr_t)&tx_frame, sizeof(struct wi_frame));
- wi_write_data(sc, id, WI_802_11_OFFSET_RAW, dptr,
- (len - sizeof(struct wi_80211_hdr)) + 2);
-
- if (wi_cmd(sc, WI_CMD_TX|WI_RECLAIM, id)) {
- device_printf(sc->dev, "xmit failed\n");
- return(EIO);
- }
-
- return(0);
-}
-
-static void wi_stop(sc)
- struct wi_softc *sc;
-{
- struct ifnet *ifp;
-
- if (sc->wi_gone)
- return;
-
- ifp = &sc->arpcom.ac_if;
-
- CSR_WRITE_2(sc, WI_INT_EN, 0);
- wi_cmd(sc, WI_CMD_DISABLE|sc->wi_portnum, 0);
-
- untimeout(wi_inquire, sc, sc->wi_stat_ch);
-
- ifp->if_flags &= ~(IFF_RUNNING|IFF_OACTIVE);
-
- return;
-}
-
-static void wi_watchdog(ifp)
- struct ifnet *ifp;
-{
- struct wi_softc *sc;
-
- sc = ifp->if_softc;
-
- device_printf(sc->dev,"device timeout\n");
-
- wi_init(sc);
-
- ifp->if_oerrors++;
-
- return;
-}
-
-static int wi_alloc(dev)
- device_t dev;
-{
- struct wi_softc *sc = device_get_softc(dev);
- int rid;
-
- rid = 0;
- sc->iobase = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
- 0, ~0, 1, RF_ACTIVE);
- if (!sc->iobase) {
- device_printf(dev, "No I/O space?!\n");
- return (ENXIO);
- }
-
- rid = 0;
- sc->irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid,
- 0, ~0, 1, RF_ACTIVE);
- if (!sc->irq) {
- device_printf(dev, "No irq?!\n");
- return (ENXIO);
- }
-
- sc->dev = dev;
- sc->wi_unit = device_get_unit(dev);
- sc->wi_io_addr = rman_get_start(sc->iobase);
- sc->wi_btag = rman_get_bustag(sc->iobase);
- sc->wi_bhandle = rman_get_bushandle(sc->iobase);
-
- return (0);
-}
-
-static void wi_free(dev)
- device_t dev;
-{
- struct wi_softc *sc = device_get_softc(dev);
-
- if (sc->iobase != NULL)
- bus_release_resource(dev, SYS_RES_IOPORT, 0, sc->iobase);
- if (sc->irq != NULL)
- bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq);
-
- return;
-}
-
-static void wi_shutdown(dev)
- device_t dev;
-{
- struct wi_softc *sc;
-
- sc = device_get_softc(dev);
- wi_stop(sc);
-
- return;
-}
-
-#ifdef WICACHE
-/* wavelan signal strength cache code.
- * store signal/noise/quality on per MAC src basis in
- * a small fixed cache. The cache wraps if > MAX slots
- * used. The cache may be zeroed out to start over.
- * Two simple filters exist to reduce computation:
- * 1. ip only (literally 0x800) which may be used
- * to ignore some packets. It defaults to ip only.
- * it could be used to focus on broadcast, non-IP 802.11 beacons.
- * 2. multicast/broadcast only. This may be used to
- * ignore unicast packets and only cache signal strength
- * for multicast/broadcast packets (beacons); e.g., Mobile-IP
- * beacons and not unicast traffic.
- *
- * The cache stores (MAC src(index), IP src (major clue), signal,
- * quality, noise)
- *
- * No apologies for storing IP src here. It's easy and saves much
- * trouble elsewhere. The cache is assumed to be INET dependent,
- * although it need not be.
- */
-
-#ifdef documentation
-
-int wi_sigitems; /* number of cached entries */
-struct wi_sigcache wi_sigcache[MAXWICACHE]; /* array of cache entries */
-int wi_nextitem; /* index/# of entries */
-
-
-#endif
-
-/* control variables for cache filtering. Basic idea is
- * to reduce cost (e.g., to only Mobile-IP agent beacons
- * which are broadcast or multicast). Still you might
- * want to measure signal strength with unicast ping packets
- * on a pt. to pt. ant. setup.
- */
-/* set true if you want to limit cache items to broadcast/mcast
- * only packets (not unicast). Useful for mobile-ip beacons which
- * are broadcast/multicast at network layer. Default is all packets
- * so ping/unicast will work say with pt. to pt. antennae setup.
- */
-static int wi_cache_mcastonly = 0;
-SYSCTL_INT(_machdep, OID_AUTO, wi_cache_mcastonly, CTLFLAG_RW,
- &wi_cache_mcastonly, 0, "");
-
-/* set true if you want to limit cache items to IP packets only
-*/
-static int wi_cache_iponly = 1;
-SYSCTL_INT(_machdep, OID_AUTO, wi_cache_iponly, CTLFLAG_RW,
- &wi_cache_iponly, 0, "");
-
-/*
- * Original comments:
- * -----------------
- * wi_cache_store, per rx packet store signal
- * strength in MAC (src) indexed cache.
- *
- * follows linux driver in how signal strength is computed.
- * In ad hoc mode, we use the rx_quality field.
- * signal and noise are trimmed to fit in the range from 47..138.
- * rx_quality field MSB is signal strength.
- * rx_quality field LSB is noise.
- * "quality" is (signal - noise) as is log value.
- * note: quality CAN be negative.
- *
- * In BSS mode, we use the RID for communication quality.
- * TBD: BSS mode is currently untested.
- *
- * Bill's comments:
- * ---------------
- * Actually, we use the rx_quality field all the time for both "ad-hoc"
- * and BSS modes. Why? Because reading an RID is really, really expensive:
- * there's a bunch of PIO operations that have to be done to read a record
- * from the NIC, and reading the comms quality RID each time a packet is
- * received can really hurt performance. We don't have to do this anyway:
- * the comms quality field only reflects the values in the rx_quality field
- * anyway. The comms quality RID is only meaningful in infrastructure mode,
- * but the values it contains are updated based on the rx_quality from
- * frames received from the access point.
- *
- * Also, according to Lucent, the signal strength and noise level values
- * can be converted to dBms by subtracting 149, so I've modified the code
- * to do that instead of the scaling it did originally.
- */
-static
-void wi_cache_store (struct wi_softc *sc, struct ether_header *eh,
- struct mbuf *m, unsigned short rx_quality)
-{
- struct ip *ip = 0;
- int i;
- static int cache_slot = 0; /* use this cache entry */
- static int wrapindex = 0; /* next "free" cache entry */
- int sig, noise;
- int sawip=0;
-
- /* filters:
- * 1. ip only
- * 2. configurable filter to throw out unicast packets,
- * keep multicast only.
- */
-
- if ((ntohs(eh->ether_type) == 0x800)) {
- sawip = 1;
- }
-
- /* filter for ip packets only
- */
- if (wi_cache_iponly && !sawip) {
- return;
- }
-
- /* filter for broadcast/multicast only
- */
- if (wi_cache_mcastonly && ((eh->ether_dhost[0] & 1) == 0)) {
- return;
- }
-
-#ifdef SIGDEBUG
- printf("wi%d: q value %x (MSB=0x%x, LSB=0x%x) \n", sc->wi_unit,
- rx_quality & 0xffff, rx_quality >> 8, rx_quality & 0xff);
-#endif
-
- /* find the ip header. we want to store the ip_src
- * address.
- */
- if (sawip) {
- ip = mtod(m, struct ip *);
- }
-
- /* do a linear search for a matching MAC address
- * in the cache table
- * . MAC address is 6 bytes,
- * . var w_nextitem holds total number of entries already cached
- */
- for(i = 0; i < sc->wi_nextitem; i++) {
- if (! bcmp(eh->ether_shost , sc->wi_sigcache[i].macsrc, 6 )) {
- /* Match!,
- * so we already have this entry,
- * update the data
- */
- break;
- }
- }
-
- /* did we find a matching mac address?
- * if yes, then overwrite a previously existing cache entry
- */
- if (i < sc->wi_nextitem ) {
- cache_slot = i;
- }
- /* else, have a new address entry,so
- * add this new entry,
- * if table full, then we need to replace LRU entry
- */
- else {
-
- /* check for space in cache table
- * note: wi_nextitem also holds number of entries
- * added in the cache table
- */
- if ( sc->wi_nextitem < MAXWICACHE ) {
- cache_slot = sc->wi_nextitem;
- sc->wi_nextitem++;
- sc->wi_sigitems = sc->wi_nextitem;
- }
- /* no space found, so simply wrap with wrap index
- * and "zap" the next entry
- */
- else {
- if (wrapindex == MAXWICACHE) {
- wrapindex = 0;
- }
- cache_slot = wrapindex++;
- }
- }
-
- /* invariant: cache_slot now points at some slot
- * in cache.
- */
- if (cache_slot < 0 || cache_slot >= MAXWICACHE) {
- log(LOG_ERR, "wi_cache_store, bad index: %d of "
- "[0..%d], gross cache error\n",
- cache_slot, MAXWICACHE);
- return;
- }
-
- /* store items in cache
- * .ip source address
- * .mac src
- * .signal, etc.
- */
- if (sawip) {
- sc->wi_sigcache[cache_slot].ipsrc = ip->ip_src.s_addr;
- }
- bcopy( eh->ether_shost, sc->wi_sigcache[cache_slot].macsrc, 6);
-
- sig = (rx_quality >> 8) & 0xFF;
- noise = rx_quality & 0xFF;
- sc->wi_sigcache[cache_slot].signal = sig - 149;
- sc->wi_sigcache[cache_slot].noise = noise - 149;
- sc->wi_sigcache[cache_slot].quality = sig - noise;
-
- return;
-}
-#endif
diff --git a/sys/dev/wi/if_wireg.h b/sys/dev/wi/if_wireg.h
deleted file mode 100644
index 42e46376c85d..000000000000
--- a/sys/dev/wi/if_wireg.h
+++ /dev/null
@@ -1,636 +0,0 @@
-/*
- * Copyright (c) 1997, 1998, 1999
- * Bill Paul <wpaul@ctr.columbia.edu>. 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 Bill Paul.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY Bill Paul 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 Bill Paul OR THE VOICES IN HIS HEAD
- * 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.
- *
- * $FreeBSD$
- */
-
-struct wi_counters {
- u_int32_t wi_tx_unicast_frames;
- u_int32_t wi_tx_multicast_frames;
- u_int32_t wi_tx_fragments;
- u_int32_t wi_tx_unicast_octets;
- u_int32_t wi_tx_multicast_octets;
- u_int32_t wi_tx_deferred_xmits;
- u_int32_t wi_tx_single_retries;
- u_int32_t wi_tx_multi_retries;
- u_int32_t wi_tx_retry_limit;
- u_int32_t wi_tx_discards;
- u_int32_t wi_rx_unicast_frames;
- u_int32_t wi_rx_multicast_frames;
- u_int32_t wi_rx_fragments;
- u_int32_t wi_rx_unicast_octets;
- u_int32_t wi_rx_multicast_octets;
- u_int32_t wi_rx_fcs_errors;
- u_int32_t wi_rx_discards_nobuf;
- u_int32_t wi_tx_discards_wrong_sa;
- u_int32_t wi_rx_WEP_cant_decrypt;
- u_int32_t wi_rx_msg_in_msg_frags;
- u_int32_t wi_rx_msg_in_bad_msg_frags;
-};
-
-/*
- * Encryption controls. We can enable or disable encryption as
- * well as specify up to 4 encryption keys. We can also specify
- * which of the four keys will be used for transmit encryption.
- */
-#define WI_RID_ENCRYPTION 0xFC20
-#define WI_RID_AUTHTYPE 0xFC21
-#define WI_RID_DEFLT_CRYPT_KEYS 0xFCB0
-#define WI_RID_TX_CRYPT_KEY 0xFCB1
-#define WI_RID_WEP_AVAIL 0xFD4F
-struct wi_key {
- u_int16_t wi_keylen;
- u_int8_t wi_keydat[14];
-};
-
-struct wi_ltv_keys {
- u_int16_t wi_len;
- u_int16_t wi_type;
- struct wi_key wi_keys[4];
-};
-
-struct wi_softc {
- struct arpcom arpcom;
- struct ifmedia ifmedia;
- device_t dev;
- int wi_unit;
- struct resource * iobase;
- struct resource * irq;
- bus_space_handle_t wi_bhandle;
- bus_space_tag_t wi_btag;
- void * wi_intrhand;
- int wi_io_addr;
- int wi_tx_data_id;
- int wi_tx_mgmt_id;
- int wi_gone;
- int wi_if_flags;
- u_int16_t wi_ptype;
- u_int16_t wi_portnum;
- u_int16_t wi_max_data_len;
- u_int16_t wi_rts_thresh;
- u_int16_t wi_ap_density;
- u_int16_t wi_tx_rate;
- u_int16_t wi_create_ibss;
- u_int16_t wi_channel;
- u_int16_t wi_pm_enabled;
- u_int16_t wi_max_sleep;
- char wi_node_name[32];
- char wi_net_name[32];
- char wi_ibss_name[32];
- u_int8_t wi_txbuf[1596];
- struct wi_counters wi_stats;
- int wi_has_wep;
- int wi_use_wep;
- int wi_tx_key;
- struct wi_ltv_keys wi_keys;
-#ifdef WICACHE
- int wi_sigitems;
- struct wi_sigcache wi_sigcache[MAXWICACHE];
- int wi_nextitem;
-#endif
- struct callout_handle wi_stat_ch;
-};
-
-#define WI_TIMEOUT 65536
-
-#define WI_PORT0 0
-#define WI_PORT1 1
-#define WI_PORT2 2
-#define WI_PORT3 3
-#define WI_PORT4 4
-#define WI_PORT5 5
-
-/* Default port: 0 (only 0 exists on stations) */
-#define WI_DEFAULT_PORT (WI_PORT0 << 8)
-
-/* Default TX rate: 2Mbps, auto fallback */
-#define WI_DEFAULT_TX_RATE 3
-
-/* Default network name: empty string implies any */
-#define WI_DEFAULT_NETNAME ""
-
-#define WI_DEFAULT_AP_DENSITY 1
-
-#define WI_DEFAULT_RTS_THRESH 2347
-
-#define WI_DEFAULT_DATALEN 2304
-
-#define WI_DEFAULT_CREATE_IBSS 0
-
-#define WI_DEFAULT_PM_ENABLED 0
-
-#define WI_DEFAULT_MAX_SLEEP 100
-
-#define WI_DEFAULT_NODENAME "FreeBSD WaveLAN/IEEE node"
-
-#define WI_DEFAULT_IBSS "FreeBSD IBSS"
-
-#define WI_DEFAULT_CHAN 3
-
-/*
- * register space access macros
- */
-#define CSR_WRITE_4(sc, reg, val) \
- bus_space_write_4(sc->wi_btag, sc->wi_bhandle, reg, val)
-#define CSR_WRITE_2(sc, reg, val) \
- bus_space_write_2(sc->wi_btag, sc->wi_bhandle, reg, val)
-#define CSR_WRITE_1(sc, reg, val) \
- bus_space_write_1(sc->wi_btag, sc->wi_bhandle, reg, val)
-
-#define CSR_READ_4(sc, reg) \
- bus_space_read_4(sc->wi_btag, sc->wi_bhandle, reg)
-#define CSR_READ_2(sc, reg) \
- bus_space_read_2(sc->wi_btag, sc->wi_bhandle, reg)
-#define CSR_READ_1(sc, reg) \
- bus_space_read_1(sc->wi_btag, sc->wi_bhandle, reg)
-
-/*
- * The WaveLAN/IEEE cards contain an 802.11 MAC controller which Lucent
- * calls 'Hermes.' In typical fashion, getting documentation about this
- * controller is about as easy as squeezing blood from a stone. Here
- * is more or less what I know:
- *
- * - The Hermes controller is firmware driven, and the host interacts
- * with the Hermes via a firmware interface, which can change.
- *
- * - The Hermes is described in a document called: "Hermes Firmware
- * WaveLAN/IEEE Station Functions," document #010245, which of course
- * Lucent will not release without an NDA.
- *
- * - Lucent has created a library called HCF (Hardware Control Functions)
- * though which it wants developers to interact with the card. The HCF
- * is needlessly complex, ill conceived and badly documented. Actually,
- * the comments in the HCP code itself aren't bad, but the publically
- * available manual that comes with it is awful, probably due largely to
- * the fact that it has been emasculated in order to hide information
- * that Lucent wants to keep proprietary. The purpose of the HCF seems
- * to be to insulate the driver programmer from the Hermes itself so that
- * Lucent has an excuse not to release programming in for it.
- *
- * - Lucent only makes available documentation and code for 'HCF Light'
- * which is a stripped down version of HCF with certain features not
- * implemented, most notably support for 802.11 frames.
- *
- * - The HCF code which I have seen blows goats. Whoever decided to
- * use a 132 column format should be shot.
- *
- * Rather than actually use the Lucent HCF library, I have stripped all
- * the useful information from it and used it to create a driver in the
- * usual BSD form. Note: I don't want to hear anybody whining about the
- * fact that the Lucent code is GPLed and mine isn't. I did not actually
- * put any of Lucent's code in this driver: I only used it as a reference
- * to obtain information about the underlying hardware. The Hermes
- * programming interface is not GPLed, so bite me.
- */
-
-/*
- * Size of Hermes I/O space.
- */
-#define WI_IOSIZ 0x40
-
-/*
- * Hermes register definitions and what little I know about them.
- */
-
-/* Hermes command/status registers. */
-#define WI_COMMAND 0x00
-#define WI_PARAM0 0x02
-#define WI_PARAM1 0x04
-#define WI_PARAM2 0x06
-#define WI_STATUS 0x08
-#define WI_RESP0 0x0A
-#define WI_RESP1 0x0C
-#define WI_RESP2 0x0E
-
-/* Command register values. */
-#define WI_CMD_BUSY 0x8000 /* busy bit */
-#define WI_CMD_INI 0x0000 /* initialize */
-#define WI_CMD_ENABLE 0x0001 /* enable */
-#define WI_CMD_DISABLE 0x0002 /* disable */
-#define WI_CMD_DIAG 0x0003
-#define WI_CMD_ALLOC_MEM 0x000A /* allocate NIC memory */
-#define WI_CMD_TX 0x000B /* transmit */
-#define WI_CMD_NOTIFY 0x0010
-#define WI_CMD_INQUIRE 0x0011
-#define WI_CMD_ACCESS 0x0021
-#define WI_CMD_PROGRAM 0x0022
-
-#define WI_CMD_CODE_MASK 0x003F
-
-/*
- * Reclaim qualifier bit, applicable to the
- * TX and INQUIRE commands.
- */
-#define WI_RECLAIM 0x0100 /* reclaim NIC memory */
-
-/*
- * ACCESS command qualifier bits.
- */
-#define WI_ACCESS_READ 0x0000
-#define WI_ACCESS_WRITE 0x0100
-
-/*
- * PROGRAM command qualifier bits.
- */
-#define WI_PROGRAM_DISABLE 0x0000
-#define WI_PROGRAM_ENABLE_RAM 0x0100
-#define WI_PROGRAM_ENABLE_NVRAM 0x0200
-#define WI_PROGRAM_NVRAM 0x0300
-
-/* Status register values */
-#define WI_STAT_CMD_CODE 0x003F
-#define WI_STAT_DIAG_ERR 0x0100
-#define WI_STAT_INQ_ERR 0x0500
-#define WI_STAT_CMD_RESULT 0x7F00
-
-/* memory handle management registers */
-#define WI_INFO_FID 0x10
-#define WI_RX_FID 0x20
-#define WI_ALLOC_FID 0x22
-#define WI_TX_CMP_FID 0x24
-
-/*
- * Buffer Access Path (BAP) registers.
- * These are I/O channels. I believe you can use each one for
- * any desired purpose independently of the other. In general
- * though, we use BAP1 for reading and writing LTV records and
- * reading received data frames, and BAP0 for writing transmit
- * frames. This is a convention though, not a rule.
- */
-#define WI_SEL0 0x18
-#define WI_SEL1 0x1A
-#define WI_OFF0 0x1C
-#define WI_OFF1 0x1E
-#define WI_DATA0 0x36
-#define WI_DATA1 0x38
-#define WI_BAP0 WI_DATA0
-#define WI_BAP1 WI_DATA1
-
-#define WI_OFF_BUSY 0x8000
-#define WI_OFF_ERR 0x4000
-#define WI_OFF_DATAOFF 0x0FFF
-
-/* Event registers */
-#define WI_EVENT_STAT 0x30 /* Event status */
-#define WI_INT_EN 0x32 /* Interrupt enable/disable */
-#define WI_EVENT_ACK 0x34 /* Ack event */
-
-/* Events */
-#define WI_EV_TICK 0x8000 /* aux timer tick */
-#define WI_EV_RES 0x4000 /* controller h/w error (time out) */
-#define WI_EV_INFO_DROP 0x2000 /* no RAM to build unsolicited frame */
-#define WI_EV_NO_CARD 0x0800 /* card removed (hunh?) */
-#define WI_EV_DUIF_RX 0x0400 /* wavelan management packet received */
-#define WI_EV_INFO 0x0080 /* async info frame */
-#define WI_EV_CMD 0x0010 /* command completed */
-#define WI_EV_ALLOC 0x0008 /* async alloc/reclaim completed */
-#define WI_EV_TX_EXC 0x0004 /* async xmit completed with failure */
-#define WI_EV_TX 0x0002 /* async xmit completed succesfully */
-#define WI_EV_RX 0x0001 /* async rx completed */
-
-#define WI_INTRS \
- (WI_EV_RX|WI_EV_TX|WI_EV_TX_EXC|WI_EV_ALLOC|WI_EV_INFO|WI_EV_INFO_DROP)
-
-/* Host software registers */
-#define WI_SW0 0x28
-#define WI_SW1 0x2A
-#define WI_SW2 0x2C
-#define WI_SW3 0x2E
-
-#define WI_CNTL 0x14
-
-#define WI_CNTL_AUX_ENA 0xC000
-#define WI_CNTL_AUX_ENA_STAT 0xC000
-#define WI_CNTL_AUX_DIS_STAT 0x0000
-#define WI_CNTL_AUX_ENA_CNTL 0x8000
-#define WI_CNTL_AUX_DIS_CNTL 0x4000
-
-#define WI_AUX_PAGE 0x3A
-#define WI_AUX_OFFSET 0x3C
-#define WI_AUX_DATA 0x3E
-
-/*
- * One form of communication with the Hermes is with what Lucent calls
- * LTV records, where LTV stands for Length, Type and Value. The length
- * and type are 16 bits and are in native byte order. The value is in
- * multiples of 16 bits and is in little endian byte order.
- */
-struct wi_ltv_gen {
- u_int16_t wi_len;
- u_int16_t wi_type;
- u_int16_t wi_val;
-};
-
-struct wi_ltv_str {
- u_int16_t wi_len;
- u_int16_t wi_type;
- u_int16_t wi_str[17];
-};
-
-#define WI_SETVAL(recno, val) \
- do { \
- struct wi_ltv_gen g; \
- \
- g.wi_len = 2; \
- g.wi_type = recno; \
- g.wi_val = val; \
- wi_write_record(sc, &g); \
- } while (0)
-
-#define WI_SETSTR(recno, str) \
- do { \
- struct wi_ltv_str s; \
- int l; \
- \
- l = (strlen(str) + 1) & ~0x1; \
- bzero((char *)&s, sizeof(s)); \
- s.wi_len = (l / 2) + 2; \
- s.wi_type = recno; \
- s.wi_str[0] = strlen(str); \
- bcopy(str, (char *)&s.wi_str[1], strlen(str)); \
- wi_write_record(sc, (struct wi_ltv_gen *)&s); \
- } while (0)
-
-/*
- * Download buffer location and length (0xFD01).
- */
-#define WI_RID_DNLD_BUF 0xFD01
-struct wi_ltv_dnld_buf {
- u_int16_t wi_len;
- u_int16_t wi_type;
- u_int16_t wi_buf_pg; /* page addr of intermediate dl buf*/
- u_int16_t wi_buf_off; /* offset of idb */
- u_int16_t wi_buf_len; /* len of idb */
-};
-
-/*
- * Mem sizes (0xFD02).
- */
-#define WI_RID_MEMSZ 0xFD02
-struct wi_ltv_memsz {
- u_int16_t wi_len;
- u_int16_t wi_type;
- u_int16_t wi_mem_ram;
- u_int16_t wi_mem_nvram;
-};
-
-/*
- * List of intended regulatory domains (0xFD11).
- */
-#define WI_RID_DOMAINS 0xFD11
-struct wi_ltv_domains {
- u_int16_t wi_len;
- u_int16_t wi_type;
- u_int16_t wi_domains[6];
-};
-
-/*
- * CIS struct (0xFD13).
- */
-#define WI_RID_CIS 0xFD13
-struct wi_ltv_cis {
- u_int16_t wi_len;
- u_int16_t wi_type;
- u_int16_t wi_cis[240];
-};
-
-/*
- * Communications quality (0xFD43).
- */
-#define WI_RID_COMMQUAL 0xFD43
-struct wi_ltv_commqual {
- u_int16_t wi_len;
- u_int16_t wi_type;
- u_int16_t wi_coms_qual;
- u_int16_t wi_sig_lvl;
- u_int16_t wi_noise_lvl;
-};
-
-/*
- * Actual system scale thresholds (0xFD46).
- */
-#define WI_RID_SYSTEM_SCALE 0xFC06
-#define WI_RID_SCALETHRESH 0xFD46
-struct wi_ltv_scalethresh {
- u_int16_t wi_len;
- u_int16_t wi_type;
- u_int16_t wi_energy_detect;
- u_int16_t wi_carrier_detect;
- u_int16_t wi_defer;
- u_int16_t wi_cell_search;
- u_int16_t wi_out_of_range;
- u_int16_t wi_delta_snr;
-};
-
-/*
- * PCF info struct (0xFD87).
- */
-#define WI_RID_PCF 0xFD87
-struct wi_ltv_pcf {
- u_int16_t wi_len;
- u_int16_t wi_type;
- u_int16_t wi_energy_detect;
- u_int16_t wi_carrier_detect;
- u_int16_t wi_defer;
- u_int16_t wi_cell_search;
- u_int16_t wi_range;
-};
-
-/*
- * Connection control characteristics.
- * 1 == Basic Service Set (BSS)
- * 2 == Wireless Distribudion System (WDS)
- * 3 == Pseudo IBSS
- */
-#define WI_RID_PORTTYPE 0xFC00
-#define WI_PORTTYPE_BSS 0x1
-#define WI_PORTTYPE_WDS 0x2
-#define WI_PORTTYPE_ADHOC 0x3
-
-/*
- * Mac addresses.
- */
-#define WI_RID_MAC_NODE 0xFC01
-#define WI_RID_MAC_WDS 0xFC08
-struct wi_ltv_macaddr {
- u_int16_t wi_len;
- u_int16_t wi_type;
- u_int16_t wi_mac_addr[3];
-};
-
-/*
- * Station set identification (SSID).
- */
-#define WI_RID_DESIRED_SSID 0xFC02
-#define WI_RID_OWN_SSID 0xFC04
-struct wi_ltv_ssid {
- u_int16_t wi_len;
- u_int16_t wi_type;
- u_int16_t wi_id[17];
-};
-
-/*
- * Set communications channel (radio frequency).
- */
-#define WI_RID_OWN_CHNL 0xFC03
-
-/*
- * Frame data size.
- */
-#define WI_RID_MAX_DATALEN 0xFC07
-
-/*
- * ESS power management enable
- */
-#define WI_RID_PM_ENABLED 0xFC09
-
-/*
- * ESS max PM sleep internal
- */
-#define WI_RID_MAX_SLEEP 0xFC0C
-
-/*
- * Set our station name.
- */
-#define WI_RID_NODENAME 0xFC0E
-struct wi_ltv_nodename {
- u_int16_t wi_len;
- u_int16_t wi_type;
- u_int16_t wi_nodename[17];
-};
-
-/*
- * Multicast addresses to be put in filter. We're
- * allowed up to 16 addresses in the filter.
- */
-#define WI_RID_MCAST 0xFC80
-struct wi_ltv_mcast {
- u_int16_t wi_len;
- u_int16_t wi_type;
- struct ether_addr wi_mcast[16];
-};
-
-/*
- * Create IBSS.
- */
-#define WI_RID_CREATE_IBSS 0xFC81
-
-#define WI_RID_FRAG_THRESH 0xFC82
-#define WI_RID_RTS_THRESH 0xFC83
-
-/*
- * TX rate control
- * 0 == Fixed 1mbps
- * 1 == Fixed 2mbps
- * 2 == auto fallback
- */
-#define WI_RID_TX_RATE 0xFC84
-
-/*
- * promiscuous mode.
- */
-#define WI_RID_PROMISC 0xFC85
-
-/*
- * Auxiliary Timer tick interval
- */
-#define WI_RID_TICK_TIME 0xFCE0
-
-/*
- * Information frame types.
- */
-#define WI_INFO_NOTIFY 0xF000 /* Handover address */
-#define WI_INFO_COUNTERS 0xF100 /* Statistics counters */
-#define WI_INFO_SCAN_RESULTS 0xF101 /* Scan results */
-#define WI_INFO_LINK_STAT 0xF200 /* Link status */
-#define WI_INFO_ASSOC_STAT 0xF201 /* Association status */
-
-/*
- * Hermes transmit/receive frame structure
- */
-struct wi_frame {
- u_int16_t wi_status; /* 0x00 */
- u_int16_t wi_rsvd0; /* 0x02 */
- u_int16_t wi_rsvd1; /* 0x04 */
- u_int16_t wi_q_info; /* 0x06 */
- u_int16_t wi_rsvd2; /* 0x08 */
- u_int16_t wi_rsvd3; /* 0x0A */
- u_int16_t wi_tx_ctl; /* 0x0C */
- u_int16_t wi_frame_ctl; /* 0x0E */
- u_int16_t wi_id; /* 0x10 */
- u_int8_t wi_addr1[6]; /* 0x12 */
- u_int8_t wi_addr2[6]; /* 0x18 */
- u_int8_t wi_addr3[6]; /* 0x1E */
- u_int16_t wi_seq_ctl; /* 0x24 */
- u_int8_t wi_addr4[6]; /* 0x26 */
- u_int16_t wi_dat_len; /* 0x2C */
- u_int8_t wi_dst_addr[6]; /* 0x2E */
- u_int8_t wi_src_addr[6]; /* 0x34 */
- u_int16_t wi_len; /* 0x3A */
- u_int16_t wi_dat[3]; /* 0x3C */ /* SNAP header */
- u_int16_t wi_type; /* 0x42 */
-};
-
-#define WI_802_3_OFFSET 0x2E
-#define WI_802_11_OFFSET 0x44
-#define WI_802_11_OFFSET_RAW 0x3C
-
-#define WI_STAT_BADCRC 0x0001
-#define WI_STAT_UNDECRYPTABLE 0x0002
-#define WI_STAT_ERRSTAT 0x0003
-#define WI_STAT_MAC_PORT 0x0700
-#define WI_STAT_1042 0x2000 /* RFC1042 encoded */
-#define WI_STAT_TUNNEL 0x4000 /* Bridge-tunnel encoded */
-#define WI_STAT_WMP_MSG 0x6000 /* WaveLAN-II management protocol */
-#define WI_RXSTAT_MSG_TYPE 0xE000
-
-#define WI_ENC_TX_802_3 0x00
-#define WI_ENC_TX_802_11 0x11
-#define WI_ENC_TX_E_II 0x0E
-
-#define WI_ENC_TX_1042 0x00
-#define WI_ENC_TX_TUNNEL 0xF8
-
-#define WI_TXCNTL_MACPORT 0x00FF
-#define WI_TXCNTL_STRUCTTYPE 0xFF00
-
-/*
- * SNAP (sub-network access protocol) constants for transmission
- * of IP datagrams over IEEE 802 networks, taken from RFC1042.
- * We need these for the LLC/SNAP header fields in the TX/RX frame
- * structure.
- */
-#define WI_SNAP_K1 0xaa /* assigned global SAP for SNAP */
-#define WI_SNAP_K2 0x00
-#define WI_SNAP_CONTROL 0x03 /* unnumbered information format */
-#define WI_SNAP_WORD0 (WI_SNAP_K1 | (WI_SNAP_K1 << 8))
-#define WI_SNAP_WORD1 (WI_SNAP_K2 | (WI_SNAP_CONTROL << 8))
-#define WI_SNAPHDR_LEN 0x6
diff --git a/sys/dev/wl/if_wl.c b/sys/dev/wl/if_wl.c
deleted file mode 100644
index 6111b8dfd437..000000000000
--- a/sys/dev/wl/if_wl.c
+++ /dev/null
@@ -1,2673 +0,0 @@
-/* $FreeBSD$ */
-/*
- * 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 all copyright
- * notices, this list of conditions and the following disclaimer.
- * 2. The names of the authors may not be used to endorse or promote products
- * derived from this software withough 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.
- *
- */
-/*
- * if_wl.c - original MACH, then BSDI ISA wavelan driver
- * ported to mach by Anders Klemets
- * to BSDI by Robert Morris
- * to FreeBSD by Jim Binkley
- * to FreeBSD 2.2+ by Michael Smith
- *
- * 2.2 update:
- * Changed interface to match 2.1-2.2 differences.
- * Implement IRQ selection logic in wlprobe()
- * Implement PSA updating.
- * Pruned heading comments for relevance.
- * Ripped out all the 'interface counters' cruft.
- * Cut the missing-interrupt timer back to 100ms.
- * 2.2.1 update:
- * now supports all multicast mode (mrouted will work),
- * but unfortunately must do that by going into promiscuous mode
- * NWID sysctl added so that normally promiscuous mode is NWID-specific
- * but can be made NWID-inspecific
- * 7/14/97 jrb
- *
- * Work done:
- * Ported to FreeBSD, got promiscuous mode working with bpfs,
- * and rewired timer routine. The i82586 will hang occasionally on output
- * and the watchdog timer will kick it if so and log an entry.
- * 2 second timeout there. Apparently the chip loses an interrupt.
- * Code borrowed from if_ie.c for watchdog timer.
- *
- * The wavelan card is a 2mbit radio modem that emulates ethernet;
- * i.e., it uses MAC addresses. This should not be a surprise since
- * it uses an ethernet controller as a major hw item.
- * It can broadcast, unicast or apparently multicast in a base cell
- * using a omni-directional antennae that is
- * about 800 feet around the base cell barring walls and metal.
- * With directional antennae, it can be used point to point over a mile
- * or so apparently (haven't tried that).
- *
- * There are ISA and pcmcia versions (not supported by this code).
- * The ISA card has an Intel 82586 lan controller on it. It consists
- * of 2 pieces of hw, the lan controller (intel) and a radio-modem.
- * The latter has an extra set of controller registers that has nothing
- * to do with the i82586 and allows setting and monitoring of radio
- * signal strength, etc. There is a nvram area called the PSA that
- * contains a number of setup variables including the IRQ and so-called
- * NWID or Network ID. The NWID must be set the same for all radio
- * cards to communicate (unless you are using the ATT/NCR roaming feature
- * with their access points. There is no support for that here. Roaming
- * involves a link-layer beacon sent out from the access points. End
- * stations monitor the signal strength and only use the strongest
- * access point). This driver assumes that the base ISA port, IRQ,
- * and NWID are first set in nvram via the dos-side "instconf.exe" utility
- * supplied with the card. This driver takes the ISA port from
- * the kernel configuration setup, and then determines the IRQ either
- * from the kernel config (if an explicit IRQ is set) or from the
- * PSA on the card if not.
- * The hw also magically just uses the IRQ set in the nvram.
- * The NWID is used magically as well by the radio-modem
- * to determine which packets to keep or throw out.
- *
- * sample config:
- *
- * device wl0 at isa? port 0x300 net irq ?
- *
- * Ifdefs:
- * 1. WLDEBUG. (off) - if turned on enables IFF_DEBUG set via ifconfig debug
- * 2. MULTICAST (on) - turned on and works up to and including mrouted
- * 3. WLCACHE (off) - define to turn on a signal strength
- * (and other metric) cache that is indexed by sender MAC address.
- * Apps can read this out to learn the remote signal strength of a
- * sender. Note that it has a switch so that it only stores
- * broadcast/multicast senders but it could be set to store unicast
- * too only. Size is hardwired in if_wl_wavelan.h
- *
- * one further note: promiscuous mode is a curious thing. In this driver,
- * promiscuous mode apparently CAN catch ALL packets and ignore the NWID
- * setting. This is probably more useful in a sense (for snoopers) if
- * you are interested in all traffic as opposed to if you are interested
- * in just your own. There is a driver specific sysctl to turn promiscuous
- * from just promiscuous to wildly promiscuous...
- *
- * This driver also knows how to load the synthesizers in the 2.4 Gz
- * ISA Half-card, Product number 847647476 (USA/FCC IEEE Channel set).
- * This product consists of a "mothercard" that contains the 82586,
- * NVRAM that holds the PSA, and the ISA-buss interface custom ASIC.
- * The radio transceiver is a "daughtercard" called the WaveMODEM which
- * connects to the mothercard through two single-inline connectors: a
- * 20-pin connector provides DC-power and modem signals, and a 3-pin
- * connector which exports the antenna connection. The code herein
- * loads the receive and transmit synthesizers and the corresponding
- * transmitter output power value from an EEPROM controlled through
- * additional registers via the MMC. The EEPROM address selected
- * are those whose values are preset by the DOS utility programs
- * provided with the product, and this provides compatible operation
- * with the DOS Packet Driver software. A future modification will
- * add the necessary functionality to this driver and to the wlconfig
- * utility to completely replace the DOS Configuration Utilities.
- * The 2.4 Gz WaveMODEM is described in document number 407-024692/E,
- * and is available through Lucent Technologies OEM supply channels.
- * --RAB 1997/06/08.
- */
-
-#define MULTICAST 1
-
-/*
- * Olivetti PC586 Mach Ethernet driver v1.0
- * Copyright Ing. C. Olivetti & C. S.p.A. 1988, 1989
- * All rights reserved.
- *
- */
-
-/*
- Copyright 1988, 1989 by Olivetti Advanced Technology Center, Inc.,
-Cupertino, California.
-
- 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, and that the name of Olivetti
-not be used in advertising or publicity pertaining to distribution
-of the software without specific, written prior permission.
-
- OLIVETTI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
-INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
-IN NO EVENT SHALL OLIVETTI 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 OUR OF OR IN CONNECTION
-WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-*/
-
-/*
- Copyright 1988, 1989 by Intel Corporation, Santa Clara, California.
-
- 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, and that the name of Intel
-not be used in advertising or publicity pertaining to distribution
-of the software without specific, written prior permission.
-
-INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
-INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
-IN NO EVENT SHALL INTEL 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.
-*/
-
-/*
- * NOTE:
- * by rvb:
- * 1. The best book on the 82586 is:
- * LAN Components User's Manual by Intel
- * The copy I found was dated 1984. This really tells you
- * what the state machines are doing
- * 2. In the current design, we only do one write at a time,
- * though the hardware is capable of chaining and possibly
- * even batching. The problem is that we only make one
- * transmit buffer available in sram space.
- */
-
-#include "wl.h"
-#include "opt_wavelan.h"
-#include "opt_inet.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/sockio.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <sys/syslog.h>
-#include <sys/proc.h>
-
-#include <sys/kernel.h>
-#include <sys/sysctl.h>
-
-#include <net/ethernet.h>
-#include <net/if.h>
-#include <net/if_dl.h>
-
-#ifdef INET
-#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <netinet/if_ether.h>
-#endif
-
-#include <net/bpf.h>
-
-#include <machine/clock.h>
-
-#include <i386/isa/isa_device.h>
-
-#include <i386/isa/ic/if_wl_i82586.h> /* Definitions for the Intel chip */
-
-/* was 1000 in original, fed to DELAY(x) */
-#define DELAYCONST 1000
-#include <i386/isa/if_wl.h>
-#include <machine/if_wl_wavelan.h>
-
-static char t_packet[ETHERMTU + sizeof(struct ether_header) + sizeof(long)];
-
-struct wl_softc{
- struct arpcom wl_ac; /* Ethernet common part */
-#define wl_if wl_ac.ac_if /* network visible interface */
-#define wl_addr wl_ac.ac_enaddr /* hardware address */
- u_char psa[0x40];
- u_char nwid[2]; /* current radio modem nwid */
- short base;
- short unit;
- int flags;
- int tbusy; /* flag to determine if xmit is busy */
- u_short begin_fd;
- u_short end_fd;
- u_short end_rbd;
- u_short hacr; /* latest host adapter CR command */
- short mode;
- u_char chan24; /* 2.4 Gz: channel number/EEPROM Area # */
- u_short freq24; /* 2.4 Gz: resulting frequency */
- struct callout_handle watchdog_ch;
-#ifdef WLCACHE
- int w_sigitems; /* number of cached entries */
- /* array of cache entries */
- struct w_sigcache w_sigcache[ MAXCACHEITEMS ];
- int w_nextcache; /* next free cache entry */
- int w_wrapindex; /* next "free" cache entry */
-#endif
-};
-static struct wl_softc wl_softc[NWL];
-
-#define WLSOFTC(unit) ((struct wl_softc *)(&wl_softc[unit]))
-
-static int wlprobe(struct isa_device *);
-static int wlattach(struct isa_device *);
-
-struct isa_driver wldriver = {
- wlprobe, wlattach, "wl", 0
-};
-
-/*
- * XXX The Wavelan appears to be prone to dropping stuff if you talk to
- * it too fast. This disgusting hack inserts a delay after each packet
- * is queued which helps avoid this behaviour on fast systems.
- */
-static int wl_xmit_delay = 250;
-SYSCTL_INT(_machdep, OID_AUTO, wl_xmit_delay, CTLFLAG_RW, &wl_xmit_delay, 0, "");
-
-/*
- * not XXX, but ZZZ (bizarre).
- * promiscuous mode can be toggled to ignore NWIDs. By default,
- * it does not. Caution should be exercised about combining
- * this mode with IFF_ALLMULTI which puts this driver in
- * promiscuous mode.
- */
-static int wl_ignore_nwid = 0;
-SYSCTL_INT(_machdep, OID_AUTO, wl_ignore_nwid, CTLFLAG_RW, &wl_ignore_nwid, 0, "");
-
-/*
- * Emit diagnostics about transmission problems
- */
-static int xmt_watch = 0;
-SYSCTL_INT(_machdep, OID_AUTO, wl_xmit_watch, CTLFLAG_RW, &xmt_watch, 0, "");
-
-/*
- * Collect SNR statistics
- */
-static int gathersnr = 0;
-SYSCTL_INT(_machdep, OID_AUTO, wl_gather_snr, CTLFLAG_RW, &gathersnr, 0, "");
-
-static void wlstart(struct ifnet *ifp);
-static void wlinit(void *xsc);
-static int wlioctl(struct ifnet *ifp, u_long cmd, caddr_t data);
-static timeout_t wlwatchdog;
-static ointhand2_t wlintr;
-static void wlxmt(int unt, struct mbuf *m);
-static int wldiag(int unt);
-static int wlconfig(int unit);
-static int wlcmd(int unit, char *str);
-static void wlmmcstat(int unit);
-static u_short wlbldru(int unit);
-static u_short wlmmcread(u_int base, u_short reg);
-static void wlinitmmc(int unit);
-static int wlhwrst(int unit);
-static void wlrustrt(int unit);
-static void wlbldcu(int unit);
-static int wlack(int unit);
-static int wlread(int unit, u_short fd_p);
-static void getsnr(int unit);
-static void wlrcv(int unit);
-static int wlrequeue(int unit, u_short fd_p);
-static void wlsftwsleaze(u_short *countp, u_char **mb_pp, struct mbuf **tm_pp, int unit);
-static void wlhdwsleaze(u_short *countp, u_char **mb_pp, struct mbuf **tm_pp, int unit);
-static void wltbd(int unit);
-static void wlgetpsa(int base, u_char *buf);
-static void wlsetpsa(int unit);
-static u_short wlpsacrc(u_char *buf);
-static void wldump(int unit);
-#ifdef WLCACHE
-static void wl_cache_store(int, int, struct ether_header *, struct mbuf *);
-static void wl_cache_zero(int unit);
-#endif
-#ifdef MULTICAST
-# if defined(__FreeBSD__) && __FreeBSD_version < 300000
-static int check_allmulti(int unit);
-# endif
-#endif
-
-/* array for maping irq numbers to values for the irq parameter register */
-static int irqvals[16] = {
- 0, 0, 0, 0x01, 0x02, 0x04, 0, 0x08, 0, 0, 0x10, 0x20, 0x40, 0, 0, 0x80
-};
-/* mask of valid IRQs */
-#define WL_IRQS (IRQ3|IRQ4|IRQ5|IRQ7|IRQ10|IRQ11|IRQ12|IRQ15)
-
-/*
- * wlprobe:
- *
- * This function "probes" or checks for the WaveLAN board on the bus to
- * see if it is there. As far as I can tell, the best break between this
- * routine and the attach code is to simply determine whether the board
- * is configured in properly. Currently my approach to this is to write
- * and read a word from the SRAM on the board being probed. If the word
- * comes back properly then we assume the board is there. The config
- * code expects to see a successful return from the probe routine before
- * attach will be called.
- *
- * input : address device is mapped to, and unit # being checked
- * output : a '1' is returned if the board exists, and a 0 otherwise
- *
- */
-static int
-wlprobe(struct isa_device *id)
-{
- struct wl_softc *sc = &wl_softc[id->id_unit];
- register short base = id->id_iobase;
- char *str = "wl%d: board out of range [0..%d]\n";
- u_char inbuf[100];
- unsigned long oldpri;
- int irq;
-
- /* TBD. not true.
- * regular CMD() will not work, since no softc yet
- */
-#define PCMD(base, hacr) outw((base), (hacr))
-
- oldpri = splimp();
- PCMD(base, HACR_RESET); /* reset the board */
- DELAY(DELAYCONST); /* >> 4 clocks at 6MHz */
- PCMD(base, HACR_RESET); /* reset the board */
- DELAY(DELAYCONST); /* >> 4 clocks at 6MHz */
- splx(oldpri);
-
- /* clear reset command and set PIO#1 in autoincrement mode */
- PCMD(base, HACR_DEFAULT);
- PCMD(base, HACR_DEFAULT);
- outw(PIOR1(base), 0); /* go to beginning of RAM */
- outsw(PIOP1(base), str, strlen(str)/2+1); /* write string */
-
- outw(PIOR1(base), 0); /* rewind */
- insw(PIOP1(base), inbuf, strlen(str)/2+1); /* read result */
-
- if (bcmp(str, inbuf, strlen(str)))
- return(0);
-
- sc->chan24 = 0; /* 2.4 Gz: config channel */
- sc->freq24 = 0; /* 2.4 Gz: frequency */
-
- /* read the PSA from the board into temporary storage */
- wlgetpsa(base, inbuf);
-
- /* We read the IRQ value from the PSA on the board. */
- for (irq = 15; irq >= 0; irq--)
- if (irqvals[irq] == inbuf[WLPSA_IRQNO])
- break;
- if ((irq == 0) || (irqvals[irq] == 0)){
- printf("wl%d: PSA corrupt (invalid IRQ value)\n", id->id_unit);
- id->id_irq = 0; /* no interrupt */
- } else {
- /*
- * If the IRQ requested by the PSA is already claimed by another
- * device, the board won't work, but the user can still access the
- * driver to change the IRQ.
- */
- id->id_irq = (1<<irq); /* use IRQ from PSA */
- }
- return(16);
-}
-
-
-/*
- * wlattach:
- *
- * This function attaches a WaveLAN board to the "system". The rest of
- * runtime structures are initialized here (this routine is called after
- * a successful probe of the board). Once the ethernet address is read
- * and stored, the board's ifnet structure is attached and readied.
- *
- * input : isa_dev structure setup in autoconfig
- * output : board structs and ifnet is setup
- *
- */
-static int
-wlattach(struct isa_device *id)
-{
- struct wl_softc *sc = (struct wl_softc *) &wl_softc[id->id_unit];
- register short base = id->id_iobase;
- int i,j;
- u_char unit = id->id_unit;
- register struct ifnet *ifp = &sc->wl_if;
-
-#ifdef WLDEBUG
- printf("wlattach: base %x, unit %d\n", base, unit);
-#endif
- id->id_ointr = wlintr;
- sc->base = base;
- sc->unit = unit;
- sc->flags = 0;
- sc->mode = 0;
- sc->hacr = HACR_RESET;
- callout_handle_init(&sc->watchdog_ch);
- CMD(unit); /* reset the board */
- DELAY(DELAYCONST); /* >> 4 clocks at 6MHz */
-
- /* clear reset command and set PIO#2 in parameter access mode */
- sc->hacr = (HACR_DEFAULT & ~HACR_16BITS);
- CMD(unit);
-
- /* Read the PSA from the board for our later reference */
- wlgetpsa(base, sc->psa);
-
- /* fetch NWID */
- sc->nwid[0] = sc->psa[WLPSA_NWID];
- sc->nwid[1] = sc->psa[WLPSA_NWID+1];
-
- /* fetch MAC address - decide which one first */
- if (sc->psa[WLPSA_MACSEL] & 1) {
- j = WLPSA_LOCALMAC;
- } else {
- j = WLPSA_UNIMAC;
- }
- for(i=0; i < WAVELAN_ADDR_SIZE; ++i) {
- sc->wl_addr[i] = sc->psa[j + i];
- }
-
- /* enter normal 16 bit mode operation */
- sc->hacr = HACR_DEFAULT;
- CMD(unit);
-
- wlinitmmc(unit);
- outw(PIOR1(base), OFFSET_SCB + 8); /* address of scb_crcerrs */
- outw(PIOP1(base), 0); /* clear scb_crcerrs */
- outw(PIOP1(base), 0); /* clear scb_alnerrs */
- outw(PIOP1(base), 0); /* clear scb_rscerrs */
- outw(PIOP1(base), 0); /* clear scb_ovrnerrs */
-
- bzero(ifp, sizeof(ifp));
- ifp->if_softc = sc;
- ifp->if_unit = id->id_unit;
- ifp->if_mtu = WAVELAN_MTU;
- ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX;
-#ifdef WLDEBUG
- ifp->if_flags |= IFF_DEBUG;
-#endif
-#if MULTICAST
- ifp->if_flags |= IFF_MULTICAST;
-#endif /* MULTICAST */
- ifp->if_name = "wl";
- ifp->if_unit = unit;
- ifp->if_init = wlinit;
- ifp->if_output = ether_output;
- ifp->if_start = wlstart;
- ifp->if_ioctl = wlioctl;
- ifp->if_timer = 0; /* paranoia */
- /* no entries
- ifp->if_watchdog
- ifp->if_done
- ifp->if_reset
- */
- if_attach(ifp);
- ether_ifattach(ifp);
-
- bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
-
- bcopy(&sc->wl_addr[0], sc->wl_ac.ac_enaddr, WAVELAN_ADDR_SIZE);
- printf("%s%d: address %6D, NWID 0x%02x%02x", ifp->if_name, ifp->if_unit,
- sc->wl_ac.ac_enaddr, ":", sc->nwid[0], sc->nwid[1]);
- if (sc->freq24)
- printf(", Freq %d MHz",sc->freq24); /* 2.4 Gz */
- printf("\n"); /* 2.4 Gz */
-
-
- if (bootverbose)
- wldump(unit);
- return(1);
-}
-
-/*
- * Print out interesting information about the 82596.
- */
-static void
-wldump(int unit)
-{
- register struct wl_softc *sp = WLSOFTC(unit);
- int base = sp->base;
- int i;
-
- printf("hasr %04x\n", inw(HASR(base)));
-
- printf("scb at %04x:\n ", OFFSET_SCB);
- outw(PIOR1(base), OFFSET_SCB);
- for(i = 0; i < 8; i++)
- printf("%04x ", inw(PIOP1(base)));
- printf("\n");
-
- printf("cu at %04x:\n ", OFFSET_CU);
- outw(PIOR1(base), OFFSET_CU);
- for(i = 0; i < 8; i++)
- printf("%04x ", inw(PIOP1(base)));
- printf("\n");
-
- printf("tbd at %04x:\n ", OFFSET_TBD);
- outw(PIOR1(base), OFFSET_TBD);
- for(i = 0; i < 4; i++)
- printf("%04x ", inw(PIOP1(base)));
- printf("\n");
-}
-
-/* Initialize the Modem Management Controller */
-static void
-wlinitmmc(int unit)
-{
- register struct wl_softc *sp = WLSOFTC(unit);
- int base = sp->base;
- int configured;
- int mode = sp->mode;
- int i; /* 2.4 Gz */
-
- /* enter 8 bit operation */
- sp->hacr = (HACR_DEFAULT & ~HACR_16BITS);
- CMD(unit);
-
- configured = sp->psa[WLPSA_CONFIGURED] & 1;
-
- /*
- * Set default modem control parameters. Taken from NCR document
- * 407-0024326 Rev. A
- */
- MMC_WRITE(MMC_JABBER_ENABLE, 0x01);
- MMC_WRITE(MMC_ANTEN_SEL, 0x02);
- MMC_WRITE(MMC_IFS, 0x20);
- MMC_WRITE(MMC_MOD_DELAY, 0x04);
- MMC_WRITE(MMC_JAM_TIME, 0x38);
- MMC_WRITE(MMC_DECAY_PRM, 0x00); /* obsolete ? */
- MMC_WRITE(MMC_DECAY_UPDAT_PRM, 0x00);
- if (!configured) {
- MMC_WRITE(MMC_LOOPT_SEL, 0x00);
- if (sp->psa[WLPSA_COMPATNO] & 1) {
- MMC_WRITE(MMC_THR_PRE_SET, 0x01); /* 0x04 for AT and 0x01 for MCA */
- } else {
- MMC_WRITE(MMC_THR_PRE_SET, 0x04); /* 0x04 for AT and 0x01 for MCA */
- }
- MMC_WRITE(MMC_QUALITY_THR, 0x03);
- } else {
- /* use configuration defaults from parameter storage area */
- if (sp->psa[WLPSA_NWIDENABLE] & 1) {
- if ((mode & (MOD_PROM | MOD_ENAL)) && wl_ignore_nwid) {
- MMC_WRITE(MMC_LOOPT_SEL, 0x40);
- } else {
- MMC_WRITE(MMC_LOOPT_SEL, 0x00);
- }
- } else {
- MMC_WRITE(MMC_LOOPT_SEL, 0x40); /* disable network id check */
- }
- MMC_WRITE(MMC_THR_PRE_SET, sp->psa[WLPSA_THRESH]);
- MMC_WRITE(MMC_QUALITY_THR, sp->psa[WLPSA_QUALTHRESH]);
- }
- MMC_WRITE(MMC_FREEZE, 0x00);
- MMC_WRITE(MMC_ENCR_ENABLE, 0x00);
-
- MMC_WRITE(MMC_NETW_ID_L,sp->nwid[1]); /* set NWID */
- MMC_WRITE(MMC_NETW_ID_H,sp->nwid[0]);
-
- /* enter normal 16 bit mode operation */
- sp->hacr = HACR_DEFAULT;
- CMD(unit);
- CMD(unit); /* virtualpc1 needs this! */
-
- if (sp->psa[WLPSA_COMPATNO]== /* 2.4 Gz: half-card ver */
- WLPSA_COMPATNO_WL24B) { /* 2.4 Gz */
- i=sp->chan24<<4; /* 2.4 Gz: position ch # */
- MMC_WRITE(MMC_EEADDR,i+0x0f); /* 2.4 Gz: named ch, wc=16 */
- MMC_WRITE(MMC_EECTRL,MMC_EECTRL_DWLD+ /* 2.4 Gz: Download Synths */
- MMC_EECTRL_EEOP_READ); /* 2.4 Gz: Read EEPROM */
- for (i=0; i<1000; ++i) { /* 2.4 Gz: wait for download */
- DELAY(40); /* 2.4 Gz */
- if ((wlmmcread(base,MMC_EECTRLstat) /* 2.4 Gz: check DWLD and */
- &(MMC_EECTRLstat_DWLD /* 2.4 Gz: EEBUSY */
- +MMC_EECTRLstat_EEBUSY))==0) /* 2.4 Gz: */
- break; /* 2.4 Gz: download finished */
- } /* 2.4 Gz */
- if (i==1000) printf("wl: synth load failed\n"); /* 2.4 Gz */
- MMC_WRITE(MMC_EEADDR,0x61); /* 2.4 Gz: default pwr, wc=2 */
- MMC_WRITE(MMC_EECTRL,MMC_EECTRL_DWLD+ /* 2.4 Gz: Download Xmit Pwr */
- MMC_EECTRL_EEOP_READ); /* 2.4 Gz: Read EEPROM */
- for (i=0; i<1000; ++i) { /* 2.4 Gz: wait for download */
- DELAY(40); /* 2.4 Gz */
- if ((wlmmcread(base,MMC_EECTRLstat) /* 2.4 Gz: check DWLD and */
- &(MMC_EECTRLstat_DWLD /* 2.4 Gz: EEBUSY */
- +MMC_EECTRLstat_EEBUSY))==0) /* 2.4 Gz: */
- break; /* 2.4 Gz: download finished */
- } /* 2.4 Gz */
- if (i==1000) printf("wl: xmit pwr load failed\n"); /* 2.4 Gz */
- MMC_WRITE(MMC_ANALCTRL, /* 2.4 Gz: EXT ant+polarity */
- MMC_ANALCTRL_ANTPOL + /* 2.4 Gz: */
- MMC_ANALCTRL_EXTANT); /* 2.4 Gz: */
- i=sp->chan24<<4; /* 2.4 Gz: position ch # */
- MMC_WRITE(MMC_EEADDR,i); /* 2.4 Gz: get frequency */
- MMC_WRITE(MMC_EECTRL, /* 2.4 Gz: EEPROM read */
- MMC_EECTRL_EEOP_READ); /* 2.4 Gz: */
- DELAY(40); /* 2.4 Gz */
- i = wlmmcread(base,MMC_EEDATALrv) /* 2.4 Gz: freq val */
- + (wlmmcread(base,MMC_EEDATAHrv)<<8); /* 2.4 Gz */
- sp->freq24 = (i>>6)+2400; /* 2.4 Gz: save real freq */
- }
-}
-
-/*
- * wlinit:
- *
- * Another routine that interfaces the "if" layer to this driver.
- * Simply resets the structures that are used by "upper layers".
- * As well as calling wlhwrst that does reset the WaveLAN board.
- *
- * input : softc pointer for this interface
- * output : structures (if structs) and board are reset
- *
- */
-static void
-wlinit(void *xsc)
-{
- register struct wl_softc *sc = xsc;
- struct ifnet *ifp = &sc->wl_if;
- int stat;
- u_long oldpri;
-
-#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG)
- printf("wl%d: entered wlinit()\n",sc->unit);
-#endif
-#if defined(__FreeBSD__) && __FreeBSD_version >= 300000
- if (ifp->if_addrhead.tqh_first == (struct ifaddr *)0) {
-#else
- if (ifp->if_addrlist == (struct ifaddr *)0) {
-#endif
- return;
- }
- oldpri = splimp();
- if ((stat = wlhwrst(sc->unit)) == TRUE) {
- sc->wl_if.if_flags |= IFF_RUNNING; /* same as DSF_RUNNING */
- /*
- * OACTIVE is used by upper-level routines
- * and must be set
- */
- sc->wl_if.if_flags &= ~IFF_OACTIVE; /* same as tbusy below */
-
- sc->flags |= DSF_RUNNING;
- sc->tbusy = 0;
- untimeout(wlwatchdog, sc, sc->watchdog_ch);
-
- wlstart(ifp);
- } else {
- printf("wl%d init(): trouble resetting board.\n", sc->unit);
- }
- splx(oldpri);
-}
-
-/*
- * wlhwrst:
- *
- * This routine resets the WaveLAN board that corresponds to the
- * board number passed in.
- *
- * input : board number to do a hardware reset
- * output : board is reset
- *
- */
-static int
-wlhwrst(int unit)
-{
- register struct wl_softc *sc = WLSOFTC(unit);
-
-#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG)
- printf("wl%d: entered wlhwrst()\n",unit);
-#endif
- sc->hacr = HACR_RESET;
- CMD(unit); /* reset the board */
-
- /* clear reset command and set PIO#1 in autoincrement mode */
- sc->hacr = HACR_DEFAULT;
- CMD(unit);
-
-#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG)
- wlmmcstat(unit); /* Display MMC registers */
-#endif /* WLDEBUG */
- wlbldcu(unit); /* set up command unit structures */
-
- if (wldiag(unit) == 0)
- return(0);
-
- if (wlconfig(unit) == 0)
- return(0);
- /*
- * insert code for loopback test here
- */
- wlrustrt(unit); /* start receive unit */
-
- /* enable interrupts */
- sc->hacr = (HACR_DEFAULT | HACR_INTRON);
- CMD(unit);
-
- return(1);
-}
-
-/*
- * wlbldcu:
- *
- * This function builds up the command unit structures. It inits
- * the scp, iscp, scb, cb, tbd, and tbuf.
- *
- */
-static void
-wlbldcu(int unit)
-{
- register struct wl_softc *sc = WLSOFTC(unit);
- short base = sc->base;
- scp_t scp;
- iscp_t iscp;
- scb_t scb;
- ac_t cb;
- tbd_t tbd;
- int i;
-
- bzero(&scp, sizeof(scp));
- scp.scp_sysbus = 0;
- scp.scp_iscp = OFFSET_ISCP;
- scp.scp_iscp_base = 0;
- outw(PIOR1(base), OFFSET_SCP);
- outsw(PIOP1(base), &scp, sizeof(scp_t)/2);
-
- bzero(&iscp, sizeof(iscp));
- iscp.iscp_busy = 1;
- iscp.iscp_scb_offset = OFFSET_SCB;
- iscp.iscp_scb = 0;
- iscp.iscp_scb_base = 0;
- outw(PIOR1(base), OFFSET_ISCP);
- outsw(PIOP1(base), &iscp, sizeof(iscp_t)/2);
-
- scb.scb_status = 0;
- scb.scb_command = SCB_RESET;
- scb.scb_cbl_offset = OFFSET_CU;
- scb.scb_rfa_offset = OFFSET_RU;
- scb.scb_crcerrs = 0;
- scb.scb_alnerrs = 0;
- scb.scb_rscerrs = 0;
- scb.scb_ovrnerrs = 0;
- outw(PIOR1(base), OFFSET_SCB);
- outsw(PIOP1(base), &scb, sizeof(scb_t)/2);
-
- SET_CHAN_ATTN(unit);
-
- outw(PIOR0(base), OFFSET_ISCP + 0); /* address of iscp_busy */
- for (i = 1000000; inw(PIOP0(base)) && (i-- > 0); );
- if (i <= 0) printf("wl%d bldcu(): iscp_busy timeout.\n", unit);
- outw(PIOR0(base), OFFSET_SCB + 0); /* address of scb_status */
- for (i = STATUS_TRIES; i-- > 0; ) {
- if (inw(PIOP0(base)) == (SCB_SW_CX|SCB_SW_CNA))
- break;
- }
- if (i <= 0)
- printf("wl%d bldcu(): not ready after reset.\n", unit);
- wlack(unit);
-
- cb.ac_status = 0;
- cb.ac_command = AC_CW_EL; /* NOP */
- cb.ac_link_offset = OFFSET_CU;
- outw(PIOR1(base), OFFSET_CU);
- outsw(PIOP1(base), &cb, 6/2);
-
- tbd.act_count = 0;
- tbd.next_tbd_offset = I82586NULL;
- tbd.buffer_addr = 0;
- tbd.buffer_base = 0;
- outw(PIOR1(base), OFFSET_TBD);
- outsw(PIOP1(base), &tbd, sizeof(tbd_t)/2);
-}
-
-/*
- * wlstart:
- *
- * send a packet
- *
- * input : board number
- * output : stuff sent to board if any there
- *
- */
-static void
-wlstart(struct ifnet *ifp)
-{
- int unit = ifp->if_unit;
- struct mbuf *m;
- register struct wl_softc *sc = WLSOFTC(unit);
- short base = sc->base;
- int scb_status, cu_status, scb_command;
-
-#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG)
- printf("wl%d: entered wlstart()\n",unit);
-#endif
-
- outw(PIOR1(base), OFFSET_CU);
- cu_status = inw(PIOP1(base));
- outw(PIOR0(base),OFFSET_SCB + 0); /* scb_status */
- scb_status = inw(PIOP0(base));
- outw(PIOR0(base), OFFSET_SCB + 2);
- scb_command = inw(PIOP0(base));
-
- /*
- * don't need OACTIVE check as tbusy here checks to see
- * if we are already busy
- */
- if (sc->tbusy) {
- if((scb_status & 0x0700) == SCB_CUS_IDLE &&
- (cu_status & AC_SW_B) == 0){
- sc->tbusy = 0;
- untimeout(wlwatchdog, sc, sc->watchdog_ch);
- sc->wl_ac.ac_if.if_flags &= ~IFF_OACTIVE;
- /*
- * This is probably just a race. The xmt'r is just
- * became idle but WE have masked interrupts so ...
- */
-#ifdef WLDEBUG
- printf("wl%d: CU idle, scb %04x %04x cu %04x\n",
- unit, scb_status, scb_command, cu_status);
-#endif
- if (xmt_watch) printf("!!");
- } else {
- return; /* genuinely still busy */
- }
- } else if((scb_status & 0x0700) == SCB_CUS_ACTV ||
- (cu_status & AC_SW_B)){
-#ifdef WLDEBUG
- printf("wl%d: CU unexpectedly busy; scb %04x cu %04x\n",
- unit, scb_status, cu_status);
-#endif
- if (xmt_watch) printf("wl%d: busy?!",unit);
- return; /* hey, why are we busy? */
- }
-
- /* get ourselves some data */
- ifp = &(sc->wl_if);
- IF_DEQUEUE(&ifp->if_snd, m);
- if (m != (struct mbuf *)0) {
- /* let BPF see it before we commit it */
- if (ifp->if_bpf) {
- bpf_mtap(ifp, m);
- }
- sc->tbusy++;
- /* set the watchdog timer so that if the board
- * fails to interrupt we will restart
- */
- /* try 10 ticks, not very long */
- sc->watchdog_ch = timeout(wlwatchdog, sc, 10);
- sc->wl_ac.ac_if.if_flags |= IFF_OACTIVE;
- sc->wl_if.if_opackets++;
- wlxmt(unit, m);
- } else {
- sc->wl_ac.ac_if.if_flags &= ~IFF_OACTIVE;
- }
- return;
-}
-
-/*
- * wlread:
- *
- * This routine does the actual copy of data (including ethernet header
- * structure) from the WaveLAN to an mbuf chain that will be passed up
- * to the "if" (network interface) layer. NOTE: we currently
- * don't handle trailer protocols, so if that is needed, it will
- * (at least in part) be added here. For simplicities sake, this
- * routine copies the receive buffers from the board into a local (stack)
- * buffer until the frame has been copied from the board. Once in
- * the local buffer, the contents are copied to an mbuf chain that
- * is then enqueued onto the appropriate "if" queue.
- *
- * input : board number, and an frame descriptor address
- * output : the packet is put into an mbuf chain, and passed up
- * assumes : if any errors occur, packet is "dropped on the floor"
- *
- */
-static int
-wlread(int unit, u_short fd_p)
-{
- register struct wl_softc *sc = WLSOFTC(unit);
- register struct ifnet *ifp = &sc->wl_if;
- short base = sc->base;
- fd_t fd;
- struct ether_header eh;
- struct mbuf *m, *tm;
- rbd_t rbd;
- u_char *mb_p;
- u_short mlen, len, clen;
- u_short bytes_in_msg, bytes_in_mbuf, bytes;
-
-
-#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG)
- printf("wl%d: entered wlread()\n",unit);
-#endif
- if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) {
- printf("wl%d read(): board is not running.\n", ifp->if_unit);
- sc->hacr &= ~HACR_INTRON;
- CMD(unit); /* turn off interrupts */
- }
- /* read ether_header info out of device memory. doesn't
- * go into mbuf. goes directly into eh structure
- */
- len = sizeof(struct ether_header); /* 14 bytes */
- outw(PIOR1(base), fd_p);
- insw(PIOP1(base), &fd, (sizeof(fd_t) - len)/2);
- insw(PIOP1(base), &eh, (len-2)/2);
- eh.ether_type = ntohs(inw(PIOP1(base)));
-#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG) {
- printf("wlread: rcv packet, type is %x\n", eh.ether_type);
- }
-#endif
- /*
- * WARNING. above is done now in ether_input, above may be
- * useful for debug. jrb
- */
- eh.ether_type = htons(eh.ether_type);
-
- if (fd.rbd_offset == I82586NULL) {
- printf("wl%d read(): Invalid buffer\n", unit);
- if (wlhwrst(unit) != TRUE) {
- printf("wl%d read(): hwrst trouble.\n", unit);
- }
- return 0;
- }
-
- outw(PIOR1(base), fd.rbd_offset);
- insw(PIOP1(base), &rbd, sizeof(rbd_t)/2);
- bytes_in_msg = rbd.status & RBD_SW_COUNT;
- MGETHDR(m, M_DONTWAIT, MT_DATA);
- tm = m;
- if (m == (struct mbuf *)0) {
- /*
- * not only do we want to return, we need to drop the packet on
- * the floor to clear the interrupt.
- *
- */
- if (wlhwrst(unit) != TRUE) {
- sc->hacr &= ~HACR_INTRON;
- CMD(unit); /* turn off interrupts */
- printf("wl%d read(): hwrst trouble.\n", unit);
- }
- return 0;
- }
- m->m_next = (struct mbuf *) 0;
- m->m_pkthdr.rcvif = ifp;
- m->m_pkthdr.len = 0; /* don't know this yet */
- m->m_len = MHLEN;
-
- /* always use a cluster. jrb
- */
- MCLGET(m, M_DONTWAIT);
- if (m->m_flags & M_EXT) {
- m->m_len = MCLBYTES;
- }
- else {
- m_freem(m);
- if (wlhwrst(unit) != TRUE) {
- sc->hacr &= ~HACR_INTRON;
- CMD(unit); /* turn off interrupts */
- printf("wl%d read(): hwrst trouble.\n", unit);
- }
- return 0;
- }
-
- mlen = 0;
- clen = mlen;
- bytes_in_mbuf = m->m_len;
- mb_p = mtod(tm, u_char *);
- bytes = min(bytes_in_mbuf, bytes_in_msg);
- for (;;) {
- if (bytes & 1) {
- len = bytes + 1;
- } else {
- len = bytes;
- }
- outw(PIOR1(base), rbd.buffer_addr);
- insw(PIOP1(base), mb_p, len/2);
- clen += bytes;
- mlen += bytes;
-
- if (!(bytes_in_mbuf -= bytes)) {
- MGET(tm->m_next, M_DONTWAIT, MT_DATA);
- tm = tm->m_next;
- if (tm == (struct mbuf *)0) {
- m_freem(m);
- printf("wl%d read(): No mbuf nth\n", unit);
- if (wlhwrst(unit) != TRUE) {
- sc->hacr &= ~HACR_INTRON;
- CMD(unit); /* turn off interrupts */
- printf("wl%d read(): hwrst trouble.\n", unit);
- }
- return 0;
- }
- mlen = 0;
- tm->m_len = MLEN;
- bytes_in_mbuf = MLEN;
- mb_p = mtod(tm, u_char *);
- } else {
- mb_p += bytes;
- }
-
- if (!(bytes_in_msg -= bytes)) {
- if (rbd.status & RBD_SW_EOF ||
- rbd.next_rbd_offset == I82586NULL) {
- tm->m_len = mlen;
- break;
- } else {
- outw(PIOR1(base), rbd.next_rbd_offset);
- insw(PIOP1(base), &rbd, sizeof(rbd_t)/2);
- bytes_in_msg = rbd.status & RBD_SW_COUNT;
- }
- } else {
- rbd.buffer_addr += bytes;
- }
-
- bytes = min(bytes_in_mbuf, bytes_in_msg);
- }
-
- m->m_pkthdr.len = clen;
-
- /*
- * Check if there's a BPF listener on this interface. If so, hand off
- * the raw packet to bpf.
- */
- if (ifp->if_bpf) {
- /* bpf assumes header is in mbufs. It isn't. We can
- * fool it without allocating memory as follows.
- * Trick borrowed from if_ie.c
- */
- struct mbuf m0;
- m0.m_len = sizeof eh;
- m0.m_data = (caddr_t) &eh;
- m0.m_next = m;
-
- bpf_mtap(ifp, &m0);
-
- }
- /*
- * If hw is in promiscuous mode (note that I said hardware, not if
- * IFF_PROMISC is set in ifnet flags), then if this is a unicast
- * packet and the MAC dst is not us, drop it. This check was formerly
- * inside the bpf if, above, but IFF_MULTI causes hw promisc without
- * a bpf listener, so this is wrong.
- * Greg Troxel <gdt@ir.bbn.com>, 1998-08-07
- */
- /*
- * TBD: also discard packets where NWID does not match.
- * However, there does not appear to be a way to read the nwid
- * for a received packet. -gdt 1998-08-07
- */
- if (
-#ifdef WL_USE_IFNET_PROMISC_CHECK /* not defined */
- (sc->wl_ac.ac_if.if_flags & (IFF_PROMISC|IFF_ALLMULTI))
-#else
- /* hw is in promisc mode if this is true */
- (sc->mode & (MOD_PROM | MOD_ENAL))
-#endif
- &&
- (eh.ether_dhost[0] & 1) == 0 && /* !mcast and !bcast */
- bcmp(eh.ether_dhost, sc->wl_ac.ac_enaddr,
- sizeof(eh.ether_dhost)) != 0 ) {
- m_freem(m);
- return 1;
- }
-
-#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG)
- printf("wl%d: wlrecv %d bytes\n", unit, clen);
-#endif
-
-#ifdef WLCACHE
- wl_cache_store(unit, base, &eh, m);
-#endif
-
- /*
- * received packet is now in a chain of mbuf's. next step is
- * to pass the packet upwards.
- *
- */
- ether_input(&sc->wl_if, &eh, m);
- return 1;
-}
-
-/*
- * wlioctl:
- *
- * This routine processes an ioctl request from the "if" layer
- * above.
- *
- * input : pointer the appropriate "if" struct, command, and data
- * output : based on command appropriate action is taken on the
- * WaveLAN board(s) or related structures
- * return : error is returned containing exit conditions
- *
- */
-static int
-wlioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
-{
- register struct ifreq *ifr = (struct ifreq *)data;
- int unit = ifp->if_unit;
- register struct wl_softc *sc = WLSOFTC(unit);
- short base = sc->base;
- short mode = 0;
- int opri, error = 0;
- struct proc *p = curproc; /* XXX */
- int irq, irqval, i, isroot, size;
- caddr_t up;
- char * cpt;
-
-
-#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG)
- printf("wl%d: entered wlioctl()\n",unit);
-#endif
- opri = splimp();
- switch (cmd) {
- case SIOCSIFADDR:
- case SIOCGIFADDR:
- case SIOCSIFMTU:
- error = ether_ioctl(ifp, cmd, data);
- break;
-
- case SIOCSIFFLAGS:
- if (ifp->if_flags & IFF_ALLMULTI) {
- mode |= MOD_ENAL;
- }
- if (ifp->if_flags & IFF_PROMISC) {
- mode |= MOD_PROM;
- }
- if(ifp->if_flags & IFF_LINK0) {
- mode |= MOD_PROM;
- }
- /*
- * force a complete reset if the recieve multicast/
- * promiscuous mode changes so that these take
- * effect immediately.
- *
- */
- if (sc->mode != mode) {
- sc->mode = mode;
- if (sc->flags & DSF_RUNNING) {
- sc->flags &= ~DSF_RUNNING;
- wlinit(sc);
- }
- }
- /* if interface is marked DOWN and still running then
- * stop it.
- */
- if ((ifp->if_flags & IFF_UP) == 0 && sc->flags & DSF_RUNNING) {
- printf("wl%d ioctl(): board is not running\n", unit);
- sc->flags &= ~DSF_RUNNING;
- sc->hacr &= ~HACR_INTRON;
- CMD(unit); /* turn off interrupts */
- }
- /* else if interface is UP and RUNNING, start it
- */
- else if (ifp->if_flags & IFF_UP && (sc->flags & DSF_RUNNING) == 0) {
- wlinit(sc);
- }
-
- /* if WLDEBUG set on interface, then printf rf-modem regs
- */
- if(ifp->if_flags & IFF_DEBUG)
- wlmmcstat(unit);
- break;
-#if MULTICAST
- case SIOCADDMULTI:
- case SIOCDELMULTI:
-
-#if defined(__FreeBSD__) && __FreeBSD_version < 300000
- if (cmd == SIOCADDMULTI) {
- error = ether_addmulti(ifr, &sc->wl_ac);
- }
- else {
- error = ether_delmulti(ifr, &sc->wl_ac);
- }
-
- /* see if we should be in all multicast mode
- * note that 82586 cannot do that, must simulate with
- * promiscuous mode
- */
- if ( check_allmulti(unit)) {
- ifp->if_flags |= IFF_ALLMULTI;
- sc->mode |= MOD_ENAL;
- sc->flags &= ~DSF_RUNNING;
- wlinit(sc);
- error = 0;
- break;
- }
-
- if (error == ENETRESET) {
- if(sc->flags & DSF_RUNNING) {
- sc->flags &= ~DSF_RUNNING;
- wlinit(sc);
- }
- error = 0;
- }
-#else
- wlinit(sc);
-#endif
- break;
-#endif /* MULTICAST */
-
- /* DEVICE SPECIFIC */
-
-
- /* copy the PSA out to the caller */
- case SIOCGWLPSA:
- /* pointer to buffer in user space */
- up = (void *)ifr->ifr_data;
- /* work out if they're root */
- isroot = (suser(p) == 0);
-
- for (i = 0; i < 0x40; i++) {
- /* don't hand the DES key out to non-root users */
- if ((i > WLPSA_DESKEY) && (i < (WLPSA_DESKEY + 8)) && !isroot)
- continue;
- if (subyte((up + i), sc->psa[i]))
- return(EFAULT);
- }
- break;
-
-
- /* copy the PSA in from the caller; we only copy _some_ values */
- case SIOCSWLPSA:
- /* root only */
- if ((error = suser(p)))
- break;
- error = EINVAL; /* assume the worst */
- /* pointer to buffer in user space containing data */
- up = (void *)ifr->ifr_data;
-
- /* check validity of input range */
- for (i = 0; i < 0x40; i++)
- if (fubyte(up + i) < 0)
- return(EFAULT);
-
- /* check IRQ value */
- irqval = fubyte(up+WLPSA_IRQNO);
- for (irq = 15; irq >= 0; irq--)
- if(irqvals[irq] == irqval)
- break;
- if (irq == 0) /* oops */
- break;
- /* new IRQ */
- sc->psa[WLPSA_IRQNO] = irqval;
-
- /* local MAC */
- for (i = 0; i < 6; i++)
- sc->psa[WLPSA_LOCALMAC+i] = fubyte(up+WLPSA_LOCALMAC+i);
-
- /* MAC select */
- sc->psa[WLPSA_MACSEL] = fubyte(up+WLPSA_MACSEL);
-
- /* default nwid */
- sc->psa[WLPSA_NWID] = fubyte(up+WLPSA_NWID);
- sc->psa[WLPSA_NWID+1] = fubyte(up+WLPSA_NWID+1);
-
- error = 0;
- wlsetpsa(unit); /* update the PSA */
- break;
-
-
- /* get the current NWID out of the sc since we stored it there */
- case SIOCGWLCNWID:
- ifr->ifr_data = (caddr_t) (sc->nwid[0] << 8 | sc->nwid[1]);
- break;
-
-
- /*
- * change the nwid dynamically. This
- * ONLY changes the radio modem and does not
- * change the PSA.
- *
- * 2 steps:
- * 1. save in softc "soft registers"
- * 2. save in radio modem (MMC)
- */
- case SIOCSWLCNWID:
- /* root only */
- if ((error = suser(p)))
- break;
- if (!(ifp->if_flags & IFF_UP)) {
- error = EIO; /* only allowed while up */
- } else {
- /*
- * soft c nwid shadows radio modem setting
- */
- sc->nwid[0] = (int)ifr->ifr_data >> 8;
- sc->nwid[1] = (int)ifr->ifr_data & 0xff;
- MMC_WRITE(MMC_NETW_ID_L,sc->nwid[1]);
- MMC_WRITE(MMC_NETW_ID_H,sc->nwid[0]);
- }
- break;
-
- /* copy the EEPROM in 2.4 Gz WaveMODEM out to the caller */
- case SIOCGWLEEPROM:
- /* root only */
- if ((error = suser(p)))
- break;
- /* pointer to buffer in user space */
- up = (void *)ifr->ifr_data;
-
- for (i=0x00; i<0x80; ++i) { /* 2.4 Gz: size of EEPROM */
- MMC_WRITE(MMC_EEADDR,i); /* 2.4 Gz: get frequency */
- MMC_WRITE(MMC_EECTRL, /* 2.4 Gz: EEPROM read */
- MMC_EECTRL_EEOP_READ); /* 2.4 Gz: */
- DELAY(40); /* 2.4 Gz */
- if (subyte(up + 2*i , /* 2.4 Gz: pass low byte of */
- wlmmcread(base,MMC_EEDATALrv)) /* 2.4 Gz: EEPROM word */
- ) return(EFAULT); /* 2.4 Gz: */
- if (subyte(up + 2*i+1, /* 2.4 Gz: pass hi byte of */
- wlmmcread(base,MMC_EEDATALrv)) /* 2.4 Gz: EEPROM word */
- ) return(EFAULT); /* 2.4 Gz: */
- }
- break;
-
-#ifdef WLCACHE
- /* zero (Delete) the wl cache */
- case SIOCDWLCACHE:
- /* root only */
- if ((error = suser(p)))
- break;
- wl_cache_zero(unit);
- break;
-
- /* read out the number of used cache elements */
- case SIOCGWLCITEM:
- ifr->ifr_data = (caddr_t) sc->w_sigitems;
- break;
-
- /* read out the wl cache */
- case SIOCGWLCACHE:
- /* pointer to buffer in user space */
- up = (void *)ifr->ifr_data;
- cpt = (char *) &sc->w_sigcache[0];
- size = sc->w_sigitems * sizeof(struct w_sigcache);
-
- for (i = 0; i < size; i++) {
- if (subyte((up + i), *cpt++))
- return(EFAULT);
- }
- break;
-#endif
-
- default:
- error = EINVAL;
- }
- splx(opri);
- return (error);
-}
-
-/*
- * wlwatchdog():
- *
- * Called if the timer set in wlstart expires before an interrupt is received
- * from the wavelan. It seems to lose interrupts sometimes.
- * The watchdog routine gets called if the transmitter failed to interrupt
- *
- * input : which board is timing out
- * output : board reset
- *
- */
-static void
-wlwatchdog(void *vsc)
-{
- struct wl_softc *sc = vsc;
- int unit = sc->unit;
-
- log(LOG_ERR, "wl%d: wavelan device timeout on xmit\n", unit);
- sc->wl_ac.ac_if.if_oerrors++;
- wlinit(sc);
-}
-
-/*
- * wlintr:
- *
- * This function is the interrupt handler for the WaveLAN
- * board. This routine will be called whenever either a packet
- * is received, or a packet has successfully been transfered and
- * the unit is ready to transmit another packet.
- *
- * input : board number that interrupted
- * output : either a packet is received, or a packet is transfered
- *
- */
-static void
-wlintr(unit)
-int unit;
-{
- register struct wl_softc *sc = &wl_softc[unit];
- short base = sc->base;
- int ac_status;
- u_short int_type, int_type1;
-
-#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG)
- printf("wl%d: wlintr() called\n",unit);
-#endif
-
- if((int_type = inw(HASR(base))) & HASR_MMC_INTR) {
- /* handle interrupt from the modem management controler */
- /* This will clear the interrupt condition */
- (void) wlmmcread(base,MMC_DCE_STATUS); /* ignored for now */
- }
-
- if(!(int_type & HASR_INTR)){ /* return if no interrupt from 82586 */
- /* commented out. jrb. it happens when reinit occurs
- printf("wlintr: int_type %x, dump follows\n", int_type);
- wldump(unit);
- */
- return;
- }
-
- if (gathersnr)
- getsnr(unit);
- for(;;) {
- outw(PIOR0(base), OFFSET_SCB + 0); /* get scb status */
- int_type = (inw(PIOP0(base)) & SCB_SW_INT);
- if (int_type == 0) /* no interrupts left */
- break;
-
- int_type1 = wlack(unit); /* acknowledge interrupt(s) */
- /* make sure no bits disappeared (others may appear) */
- if ((int_type & int_type1) != int_type)
- printf("wlack() int bits disappeared : %04x != int_type %04x\n",
- int_type1, int_type);
- int_type = int_type1; /* go with the new status */
- /*
- * incoming packet
- */
- if (int_type & SCB_SW_FR) {
- sc->wl_if.if_ipackets++;
- wlrcv(unit);
- }
- /*
- * receiver not ready
- */
- if (int_type & SCB_SW_RNR) {
- sc->wl_if.if_ierrors++;
-#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG)
- printf("wl%d intr(): receiver overrun! begin_fd = %x\n",
- unit, sc->begin_fd);
-#endif
- wlrustrt(unit);
- }
- /*
- * CU not ready
- */
- if (int_type & SCB_SW_CNA) {
- /*
- * At present, we don't care about CNA's. We
- * believe they are a side effect of XMT.
- */
- }
- if (int_type & SCB_SW_CX) {
- /*
- * At present, we only request Interrupt for
- * XMT.
- */
- outw(PIOR1(base), OFFSET_CU); /* get command status */
- ac_status = inw(PIOP1(base));
-
- if (xmt_watch) { /* report some anomalies */
-
- if (sc->tbusy == 0) {
- printf("wl%d: xmt intr but not busy, CU %04x\n",
- unit, ac_status);
- }
- if (ac_status == 0) {
- printf("wl%d: xmt intr but ac_status == 0\n", unit);
- }
- if (ac_status & AC_SW_A) {
- printf("wl%d: xmt aborted\n",unit);
- }
-#ifdef notdef
- if (ac_status & TC_CARRIER) {
- printf("wl%d: no carrier\n", unit);
- }
-#endif /* notdef */
- if (ac_status & TC_CLS) {
- printf("wl%d: no CTS\n", unit);
- }
- if (ac_status & TC_DMA) {
- printf("wl%d: DMA underrun\n", unit);
- }
- if (ac_status & TC_DEFER) {
- printf("wl%d: xmt deferred\n",unit);
- }
- if (ac_status & TC_SQE) {
- printf("wl%d: heart beat\n", unit);
- }
- if (ac_status & TC_COLLISION) {
- printf("wl%d: too many collisions\n", unit);
- }
- }
- /* if the transmit actually failed, or returned some status */
- if ((!(ac_status & AC_SW_OK)) || (ac_status & 0xfff)) {
- if (ac_status & (TC_COLLISION | TC_CLS | TC_DMA)) {
- sc->wl_if.if_oerrors++;
- }
- /* count collisions */
- sc->wl_if.if_collisions += (ac_status & 0xf);
- /* if TC_COLLISION set and collision count zero, 16 collisions */
- if ((ac_status & 0x20) == 0x20) {
- sc->wl_if.if_collisions += 0x10;
- }
- }
- sc->tbusy = 0;
- untimeout(wlwatchdog, sc, sc->watchdog_ch);
- sc->wl_ac.ac_if.if_flags &= ~IFF_OACTIVE;
- wlstart(&(sc->wl_if));
- }
- }
- return;
-}
-
-/*
- * wlrcv:
- *
- * This routine is called by the interrupt handler to initiate a
- * packet transfer from the board to the "if" layer above this
- * driver. This routine checks if a buffer has been successfully
- * received by the WaveLAN. If so, the routine wlread is called
- * to do the actual transfer of the board data (including the
- * ethernet header) into a packet (consisting of an mbuf chain).
- *
- * input : number of the board to check
- * output : if a packet is available, it is "sent up"
- *
- */
-static void
-wlrcv(int unit)
-{
- register struct wl_softc *sc = WLSOFTC(unit);
- short base = sc->base;
- u_short fd_p, status, offset, link_offset;
-
-#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG)
- printf("wl%d: entered wlrcv()\n",unit);
-#endif
- for (fd_p = sc->begin_fd; fd_p != I82586NULL; fd_p = sc->begin_fd) {
-
- outw(PIOR0(base), fd_p + 0); /* address of status */
- status = inw(PIOP0(base));
- outw(PIOR1(base), fd_p + 4); /* address of link_offset */
- link_offset = inw(PIOP1(base));
- offset = inw(PIOP1(base)); /* rbd_offset */
- if (status == 0xffff || offset == 0xffff /*I82586NULL*/) {
- if (wlhwrst(unit) != TRUE)
- printf("wl%d rcv(): hwrst ffff trouble.\n", unit);
- return;
- } else if (status & AC_SW_C) {
- if (status == (RFD_DONE|RFD_RSC)) {
- /* lost one */
-#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG)
- printf("wl%d RCV: RSC %x\n", unit, status);
-#endif
- sc->wl_if.if_ierrors++;
- } else if (!(status & RFD_OK)) {
- printf("wl%d RCV: !OK %x\n", unit, status);
- sc->wl_if.if_ierrors++;
- } else if (status & 0xfff) { /* can't happen */
- printf("wl%d RCV: ERRs %x\n", unit, status);
- sc->wl_if.if_ierrors++;
- } else if (!wlread(unit, fd_p))
- return;
-
- if (!wlrequeue(unit, fd_p)) {
- /* abort on chain error */
- if (wlhwrst(unit) != TRUE)
- printf("wl%d rcv(): hwrst trouble.\n", unit);
- return;
- }
- sc->begin_fd = link_offset;
- } else {
- break;
- }
- }
- return;
-}
-
-/*
- * wlrequeue:
- *
- * This routine puts rbd's used in the last receive back onto the
- * free list for the next receive.
- *
- */
-static int
-wlrequeue(int unit, u_short fd_p)
-{
- register struct wl_softc *sc = WLSOFTC(unit);
- short base = sc->base;
- fd_t fd;
- u_short l_rbdp, f_rbdp, rbd_offset;
-
- outw(PIOR0(base), fd_p + 6);
- rbd_offset = inw(PIOP0(base));
- if ((f_rbdp = rbd_offset) != I82586NULL) {
- l_rbdp = f_rbdp;
- for(;;) {
- outw(PIOR0(base), l_rbdp + 0); /* address of status */
- if(inw(PIOP0(base)) & RBD_SW_EOF)
- break;
- outw(PIOP0(base), 0);
- outw(PIOR0(base), l_rbdp + 2); /* next_rbd_offset */
- if((l_rbdp = inw(PIOP0(base))) == I82586NULL)
- break;
- }
- outw(PIOP0(base), 0);
- outw(PIOR0(base), l_rbdp + 2); /* next_rbd_offset */
- outw(PIOP0(base), I82586NULL);
- outw(PIOR0(base), l_rbdp + 8); /* address of size */
- outw(PIOP0(base), inw(PIOP0(base)) | AC_CW_EL);
- outw(PIOR0(base), sc->end_rbd + 2);
- outw(PIOP0(base), f_rbdp); /* end_rbd->next_rbd_offset */
- outw(PIOR0(base), sc->end_rbd + 8); /* size */
- outw(PIOP0(base), inw(PIOP0(base)) & ~AC_CW_EL);
- sc->end_rbd = l_rbdp;
- }
-
- fd.status = 0;
- fd.command = AC_CW_EL;
- fd.link_offset = I82586NULL;
- fd.rbd_offset = I82586NULL;
- outw(PIOR1(base), fd_p);
- outsw(PIOP1(base), &fd, 8/2);
-
- outw(PIOR1(base), sc->end_fd + 2); /* addr of command */
- outw(PIOP1(base), 0); /* command = 0 */
- outw(PIOP1(base), fd_p); /* end_fd->link_offset = fd_p */
- sc->end_fd = fd_p;
-
- return 1;
-}
-
-#ifdef WLDEBUG
-static int xmt_debug = 0;
-#endif /* WLDEBUG */
-
-/*
- * wlxmt:
- *
- * This routine fills in the appropriate registers and memory
- * locations on the WaveLAN board and starts the board off on
- * the transmit.
- *
- * input : board number of interest, and a pointer to the mbuf
- * output : board memory and registers are set for xfer and attention
- *
- */
-static void
-wlxmt(int unit, struct mbuf *m)
-{
- register struct wl_softc *sc = WLSOFTC(unit);
- register u_short xmtdata_p = OFFSET_TBUF;
- register u_short xmtshort_p;
- struct mbuf *tm_p = m;
- register struct ether_header *eh_p = mtod(m, struct ether_header *);
- u_char *mb_p = mtod(m, u_char *) + sizeof(struct ether_header);
- u_short count = m->m_len - sizeof(struct ether_header);
- ac_t cb;
- u_short tbd_p = OFFSET_TBD;
- u_short len, clen = 0;
- short base = sc->base;
- int spin;
-
-#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG)
- printf("wl%d: entered wlxmt()\n",unit);
-#endif
-
- cb.ac_status = 0;
- cb.ac_command = (AC_CW_EL|AC_TRANSMIT|AC_CW_I);
- cb.ac_link_offset = I82586NULL;
- outw(PIOR1(base), OFFSET_CU);
- outsw(PIOP1(base), &cb, 6/2);
- outw(PIOP1(base), OFFSET_TBD); /* cb.cmd.transmit.tbd_offset */
- outsw(PIOP1(base), eh_p->ether_dhost, WAVELAN_ADDR_SIZE/2);
- outw(PIOP1(base), eh_p->ether_type);
-
-#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG) {
- if (xmt_debug) {
- printf("XMT mbuf: L%d @%p ", count, (void *)mb_p);
- printf("ether type %x\n", eh_p->ether_type);
- }
- }
-#endif /* WLDEBUG */
- outw(PIOR0(base), OFFSET_TBD);
- outw(PIOP0(base), 0); /* act_count */
- outw(PIOR1(base), OFFSET_TBD + 4);
- outw(PIOP1(base), xmtdata_p); /* buffer_addr */
- outw(PIOP1(base), 0); /* buffer_base */
- for (;;) {
- if (count) {
- if (clen + count > WAVELAN_MTU)
- break;
- if (count & 1)
- len = count + 1;
- else
- len = count;
- outw(PIOR1(base), xmtdata_p);
- outsw(PIOP1(base), mb_p, len/2);
- clen += count;
- outw(PIOR0(base), tbd_p); /* address of act_count */
- outw(PIOP0(base), inw(PIOP0(base)) + count);
- xmtdata_p += len;
- if ((tm_p = tm_p->m_next) == (struct mbuf *)0)
- break;
- if (count & 1) {
- /* go to the next descriptor */
- outw(PIOR0(base), tbd_p + 2);
- tbd_p += sizeof (tbd_t);
- outw(PIOP0(base), tbd_p); /* next_tbd_offset */
- outw(PIOR0(base), tbd_p);
- outw(PIOP0(base), 0); /* act_count */
- outw(PIOR1(base), tbd_p + 4);
- outw(PIOP1(base), xmtdata_p); /* buffer_addr */
- outw(PIOP1(base), 0); /* buffer_base */
- /* at the end -> coallesce remaining mbufs */
- if (tbd_p == OFFSET_TBD + (N_TBD-1) * sizeof (tbd_t)) {
- wlsftwsleaze(&count, &mb_p, &tm_p, unit);
- continue;
- }
- /* next mbuf short -> coallesce as needed */
- if ( (tm_p->m_next == (struct mbuf *) 0) ||
-#define HDW_THRESHOLD 55
- tm_p->m_len > HDW_THRESHOLD)
- /* ok */;
- else {
- wlhdwsleaze(&count, &mb_p, &tm_p, unit);
- continue;
- }
- }
- } else if ((tm_p = tm_p->m_next) == (struct mbuf *)0)
- break;
- count = tm_p->m_len;
- mb_p = mtod(tm_p, u_char *);
-#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG)
- if (xmt_debug)
- printf("mbuf+ L%d @%p ", count, (void *)mb_p);
-#endif /* WLDEBUG */
- }
-#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG)
- if (xmt_debug)
- printf("CLEN = %d\n", clen);
-#endif /* WLDEBUG */
- outw(PIOR0(base), tbd_p);
- if (clen < ETHERMIN) {
- outw(PIOP0(base), inw(PIOP0(base)) + ETHERMIN - clen);
- outw(PIOR1(base), xmtdata_p);
- for (xmtshort_p = xmtdata_p; clen < ETHERMIN; clen += 2)
- outw(PIOP1(base), 0);
- }
- outw(PIOP0(base), inw(PIOP0(base)) | TBD_SW_EOF);
- outw(PIOR0(base), tbd_p + 2);
- outw(PIOP0(base), I82586NULL);
-#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG) {
- if (xmt_debug) {
- wltbd(unit);
- printf("\n");
- }
- }
-#endif /* WLDEBUG */
-
- outw(PIOR0(base), OFFSET_SCB + 2); /* address of scb_command */
- /*
- * wait for 586 to clear previous command, complain if it takes
- * too long
- */
- for (spin = 1;;spin = (spin + 1) % 10000) {
- if (inw(PIOP0(base)) == 0) { /* it's done, we can go */
- break;
- }
- if ((spin == 0) && xmt_watch) { /* not waking up, and we care */
- printf("wl%d: slow accepting xmit\n",unit);
- }
- }
- outw(PIOP0(base), SCB_CU_STRT); /* new command */
- SET_CHAN_ATTN(unit);
-
- m_freem(m);
-
- /* XXX
- * Pause to avoid transmit overrun problems.
- * The required delay tends to vary with platform type, and may be
- * related to interrupt loss.
- */
- if (wl_xmit_delay) {
- DELAY(wl_xmit_delay);
- }
- return;
-}
-
-/*
- * wlbldru:
- *
- * This function builds the linear linked lists of fd's and
- * rbd's. Based on page 4-32 of 1986 Intel microcom handbook.
- *
- */
-static u_short
-wlbldru(int unit)
-{
- register struct wl_softc *sc = WLSOFTC(unit);
- short base = sc->base;
- fd_t fd;
- rbd_t rbd;
- u_short fd_p = OFFSET_RU;
- u_short rbd_p = OFFSET_RBD;
- int i;
-
- sc->begin_fd = fd_p;
- for(i = 0; i < N_FD; i++) {
- fd.status = 0;
- fd.command = 0;
- fd.link_offset = fd_p + sizeof(fd_t);
- fd.rbd_offset = I82586NULL;
- outw(PIOR1(base), fd_p);
- outsw(PIOP1(base), &fd, 8/2);
- fd_p = fd.link_offset;
- }
- fd_p -= sizeof(fd_t);
- sc->end_fd = fd_p;
- outw(PIOR1(base), fd_p + 2);
- outw(PIOP1(base), AC_CW_EL); /* command */
- outw(PIOP1(base), I82586NULL); /* link_offset */
- fd_p = OFFSET_RU;
-
- outw(PIOR0(base), fd_p + 6); /* address of rbd_offset */
- outw(PIOP0(base), rbd_p);
- outw(PIOR1(base), rbd_p);
- for(i = 0; i < N_RBD; i++) {
- rbd.status = 0;
- rbd.buffer_addr = rbd_p + sizeof(rbd_t) + 2;
- rbd.buffer_base = 0;
- rbd.size = RCVBUFSIZE;
- if (i != N_RBD-1) {
- rbd_p += sizeof(ru_t);
- rbd.next_rbd_offset = rbd_p;
- } else {
- rbd.next_rbd_offset = I82586NULL;
- rbd.size |= AC_CW_EL;
- sc->end_rbd = rbd_p;
- }
- outsw(PIOP1(base), &rbd, sizeof(rbd_t)/2);
- outw(PIOR1(base), rbd_p);
- }
- return sc->begin_fd;
-}
-
-/*
- * wlrustrt:
- *
- * This routine starts the receive unit running. First checks if the
- * board is actually ready, then the board is instructed to receive
- * packets again.
- *
- */
-static void
-wlrustrt(int unit)
-{
- register struct wl_softc *sc = WLSOFTC(unit);
- short base = sc->base;
- u_short rfa;
-
-#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG)
- printf("wl%d: entered wlrustrt()\n",unit);
-#endif
- outw(PIOR0(base), OFFSET_SCB);
- if (inw(PIOP0(base)) & SCB_RUS_READY){
- printf("wlrustrt: RUS_READY\n");
- return;
- }
-
- outw(PIOR0(base), OFFSET_SCB + 2);
- outw(PIOP0(base), SCB_RU_STRT); /* command */
- rfa = wlbldru(unit);
- outw(PIOR0(base), OFFSET_SCB + 6); /* address of scb_rfa_offset */
- outw(PIOP0(base), rfa);
-
- SET_CHAN_ATTN(unit);
- return;
-}
-
-/*
- * wldiag:
- *
- * This routine does a 586 op-code number 7, and obtains the
- * diagnose status for the WaveLAN.
- *
- */
-static int
-wldiag(int unit)
-{
- register struct wl_softc *sc = WLSOFTC(unit);
- short base = sc->base;
- short status;
-
-#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG)
- printf("wl%d: entered wldiag()\n",unit);
-#endif
- outw(PIOR0(base), OFFSET_SCB);
- status = inw(PIOP0(base));
- if (status & SCB_SW_INT) {
- /* state is 2000 which seems ok
- printf("wl%d diag(): unexpected initial state %\n",
- unit, inw(PIOP0(base)));
- */
- wlack(unit);
- }
- outw(PIOR1(base), OFFSET_CU);
- outw(PIOP1(base), 0); /* ac_status */
- outw(PIOP1(base), AC_DIAGNOSE|AC_CW_EL);/* ac_command */
- if(wlcmd(unit, "diag()") == 0)
- return 0;
- outw(PIOR0(base), OFFSET_CU);
- if (inw(PIOP0(base)) & 0x0800) {
- printf("wl%d: i82586 Self Test failed!\n", unit);
- return 0;
- }
- return TRUE;
-}
-
-/*
- * wlconfig:
- *
- * This routine does a standard config of the WaveLAN board.
- *
- */
-static int
-wlconfig(int unit)
-{
- configure_t configure;
- register struct wl_softc *sc = WLSOFTC(unit);
- short base = sc->base;
-
-#if MULTICAST
-#if defined(__FreeBSD__) && __FreeBSD_version >= 300000
- struct ifmultiaddr *ifma;
- u_char *addrp;
-#else
- struct ether_multi *enm;
- struct ether_multistep step;
-#endif
- int cnt = 0;
-#endif /* MULTICAST */
-
-#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG)
- printf("wl%d: entered wlconfig()\n",unit);
-#endif
- outw(PIOR0(base), OFFSET_SCB);
- if (inw(PIOP0(base)) & SCB_SW_INT) {
- /*
- printf("wl%d config(): unexpected initial state %x\n",
- unit, inw(PIOP0(base)));
- */
- }
- wlack(unit);
-
- outw(PIOR1(base), OFFSET_CU);
- outw(PIOP1(base), 0); /* ac_status */
- outw(PIOP1(base), AC_CONFIGURE|AC_CW_EL); /* ac_command */
-
-/* jrb hack */
- configure.fifolim_bytecnt = 0x080c;
- configure.addrlen_mode = 0x0600;
- configure.linprio_interframe = 0x2060;
- configure.slot_time = 0xf200;
- configure.hardware = 0x0008; /* tx even w/o CD */
- configure.min_frame_len = 0x0040;
-#if 0
- /* This is the configuration block suggested by Marc Meertens
- * <mmeerten@obelix.utrecht.NCR.COM> in an e-mail message to John
- * Ioannidis on 10 Nov 92.
- */
- configure.fifolim_bytecnt = 0x040c;
- configure.addrlen_mode = 0x0600;
- configure.linprio_interframe = 0x2060;
- configure.slot_time = 0xf000;
- configure.hardware = 0x0008; /* tx even w/o CD */
- configure.min_frame_len = 0x0040;
-#else
- /*
- * below is the default board configuration from p2-28 from 586 book
- */
- configure.fifolim_bytecnt = 0x080c;
- configure.addrlen_mode = 0x2600;
- configure.linprio_interframe = 0x7820; /* IFS=120, ACS=2 */
- configure.slot_time = 0xf00c; /* slottime=12 */
- configure.hardware = 0x0008; /* tx even w/o CD */
- configure.min_frame_len = 0x0040;
-#endif
- if(sc->mode & (MOD_PROM | MOD_ENAL)) {
- configure.hardware |= 1;
- }
- outw(PIOR1(base), OFFSET_CU + 6);
- outsw(PIOP1(base), &configure, sizeof(configure_t)/2);
-
- if(wlcmd(unit, "config()-configure") == 0)
- return 0;
-#if MULTICAST
- outw(PIOR1(base), OFFSET_CU);
- outw(PIOP1(base), 0); /* ac_status */
- outw(PIOP1(base), AC_MCSETUP|AC_CW_EL); /* ac_command */
- outw(PIOR1(base), OFFSET_CU + 8);
-#if defined(__FreeBSD__) && __FreeBSD_version >= 300000
- for (ifma = sc->wl_if.if_multiaddrs.lh_first; ifma;
- ifma = ifma->ifma_link.le_next) {
- if (ifma->ifma_addr->sa_family != AF_LINK)
- continue;
-
- addrp = LLADDR((struct sockaddr_dl *)ifma->ifma_addr);
- outw(PIOP1(base), addrp[0] + (addrp[1] << 8));
- outw(PIOP1(base), addrp[2] + (addrp[3] << 8));
- outw(PIOP1(base), addrp[4] + (addrp[5] << 8));
- ++cnt;
- }
-#else
- ETHER_FIRST_MULTI(step, &sc->wl_ac, enm);
- while (enm != NULL) {
- unsigned int lo, hi;
- /* break if setting a multicast range, else we would crash */
- if (bcmp(enm->enm_addrlo, enm->enm_addrhi, 6) != 0) {
- break;
- }
- lo = (enm->enm_addrlo[3] << 16) + (enm->enm_addrlo[4] << 8)
- + enm->enm_addrlo[5];
- hi = (enm->enm_addrhi[3] << 16) + (enm->enm_addrhi[4] << 8)
- + enm->enm_addrhi[5];
- while(lo <= hi) {
- outw(PIOP1(base),enm->enm_addrlo[0] +
- (enm->enm_addrlo[1] << 8));
- outw(PIOP1(base),enm->enm_addrlo[2] +
- ((lo >> 8) & 0xff00));
- outw(PIOP1(base), ((lo >> 8) & 0xff) +
- ((lo << 8) & 0xff00));
-/* #define MCASTDEBUG */
-#ifdef MCASTDEBUG
-printf("mcast_addr[%d,%d,%d] %x %x %x %x %x %x\n", lo, hi, cnt,
- enm->enm_addrlo[0],
- enm->enm_addrlo[1],
- enm->enm_addrlo[2],
- enm->enm_addrlo[3],
- enm->enm_addrlo[4],
- enm->enm_addrlo[5]);
-#endif
- ++cnt;
- ++lo;
- }
- ETHER_NEXT_MULTI(step, enm);
- }
-#endif
- outw(PIOR1(base), OFFSET_CU + 6); /* mc-cnt */
- outw(PIOP1(base), cnt * WAVELAN_ADDR_SIZE);
- if(wlcmd(unit, "config()-mcaddress") == 0)
- return 0;
-#endif /* MULTICAST */
-
- outw(PIOR1(base), OFFSET_CU);
- outw(PIOP1(base), 0); /* ac_status */
- outw(PIOP1(base), AC_IASETUP|AC_CW_EL); /* ac_command */
- outw(PIOR1(base), OFFSET_CU + 6);
- outsw(PIOP1(base), sc->wl_addr, WAVELAN_ADDR_SIZE/2);
-
- if(wlcmd(unit, "config()-address") == 0)
- return(0);
-
- wlinitmmc(unit);
-
- return(1);
-}
-
-/*
- * wlcmd:
- *
- * Set channel attention bit and busy wait until command has
- * completed. Then acknowledge the command completion.
- */
-static int
-wlcmd(int unit, char *str)
-{
- register struct wl_softc *sc = WLSOFTC(unit);
- short base = sc->base;
- int i;
-
- outw(PIOR0(base), OFFSET_SCB + 2); /* address of scb_command */
- outw(PIOP0(base), SCB_CU_STRT);
-
- SET_CHAN_ATTN(unit);
-
- outw(PIOR0(base), OFFSET_CU);
- for(i = 0; i < 0xffff; i++)
- if (inw(PIOP0(base)) & AC_SW_C)
- break;
- if (i == 0xffff || !(inw(PIOP0(base)) & AC_SW_OK)) {
- printf("wl%d: %s failed; status = %d, inw = %x, outw = %x\n",
- unit, str, inw(PIOP0(base)) & AC_SW_OK, inw(PIOP0(base)), inw(PIOR0(base)));
- outw(PIOR0(base), OFFSET_SCB);
- printf("scb_status %x\n", inw(PIOP0(base)));
- outw(PIOR0(base), OFFSET_SCB+2);
- printf("scb_command %x\n", inw(PIOP0(base)));
- outw(PIOR0(base), OFFSET_SCB+4);
- printf("scb_cbl %x\n", inw(PIOP0(base)));
- outw(PIOR0(base), OFFSET_CU+2);
- printf("cu_cmd %x\n", inw(PIOP0(base)));
- return(0);
- }
-
- outw(PIOR0(base), OFFSET_SCB);
- if ((inw(PIOP0(base)) & SCB_SW_INT) && (inw(PIOP0(base)) != SCB_SW_CNA)) {
- /*
- printf("wl%d %s: unexpected final state %x\n",
- unit, str, inw(PIOP0(base)));
- */
- }
- wlack(unit);
- return(TRUE);
-}
-
-/*
- * wlack: if the 82596 wants attention because it has finished
- * sending or receiving a packet, acknowledge its desire and
- * return bits indicating the kind of attention. wlack() returns
- * these bits so that the caller can service exactly the
- * conditions that wlack() acknowledged.
- */
-static int
-wlack(int unit)
-{
- int i;
- register u_short cmd;
- register struct wl_softc *sc = WLSOFTC(unit);
- short base = sc->base;
-
- outw(PIOR1(base), OFFSET_SCB);
- if(!(cmd = (inw(PIOP1(base)) & SCB_SW_INT)))
- return(0);
-#ifdef WLDEBUG
- if (sc->wl_if.if_flags & IFF_DEBUG)
- printf("wl%d: doing a wlack()\n",unit);
-#endif
- outw(PIOP1(base), cmd);
- SET_CHAN_ATTN(unit);
- outw(PIOR0(base), OFFSET_SCB + 2); /* address of scb_command */
- for (i = 1000000; inw(PIOP0(base)) && (i-- > 0); );
- if (i < 1)
- printf("wl%d wlack(): board not accepting command.\n", unit);
- return(cmd);
-}
-
-static void
-wltbd(int unit)
-{
- register struct wl_softc *sc = WLSOFTC(unit);
- short base = sc->base;
- u_short tbd_p = OFFSET_TBD;
- tbd_t tbd;
- int i = 0;
- int sum = 0;
-
- for (;;) {
- outw(PIOR1(base), tbd_p);
- insw(PIOP1(base), &tbd, sizeof(tbd_t)/2);
- sum += (tbd.act_count & ~TBD_SW_EOF);
- printf("%d: addr %x, count %d (%d), next %x, base %x\n",
- i++, tbd.buffer_addr,
- (tbd.act_count & ~TBD_SW_EOF), sum,
- tbd.next_tbd_offset, tbd.buffer_base);
- if (tbd.act_count & TBD_SW_EOF)
- break;
- tbd_p = tbd.next_tbd_offset;
- }
-}
-
-static void
-wlhdwsleaze(u_short *countp, u_char **mb_pp, struct mbuf **tm_pp, int unit)
-{
- struct mbuf *tm_p = *tm_pp;
- u_char *mb_p = *mb_pp;
- u_short count = 0;
- u_char *cp;
- int len;
-
- /*
- * can we get a run that will be coallesced or
- * that terminates before breaking
- */
- do {
- count += tm_p->m_len;
- if (tm_p->m_len & 1)
- break;
- } while ((tm_p = tm_p->m_next) != (struct mbuf *)0);
- if ( (tm_p == (struct mbuf *)0) ||
- count > HDW_THRESHOLD) {
- *countp = (*tm_pp)->m_len;
- *mb_pp = mtod((*tm_pp), u_char *);
- return;
- }
-
- /* we need to copy */
- tm_p = *tm_pp;
- mb_p = *mb_pp;
- count = 0;
- cp = (u_char *) t_packet;
- for (;;) {
- bcopy(mtod(tm_p, u_char *), cp, len = tm_p->m_len);
- count += len;
- if (count > HDW_THRESHOLD)
- break;
- cp += len;
- if (tm_p->m_next == (struct mbuf *)0)
- break;
- tm_p = tm_p->m_next;
- }
- *countp = count;
- *mb_pp = (u_char *) t_packet;
- *tm_pp = tm_p;
- return;
-}
-
-
-static void
-wlsftwsleaze(u_short *countp, u_char **mb_pp, struct mbuf **tm_pp, int unit)
-{
- struct mbuf *tm_p = *tm_pp;
- u_short count = 0;
- u_char *cp = (u_char *) t_packet;
- int len;
-
- /* we need to copy */
- for (;;) {
- bcopy(mtod(tm_p, u_char *), cp, len = tm_p->m_len);
- count += len;
- cp += len;
- if (tm_p->m_next == (struct mbuf *)0)
- break;
- tm_p = tm_p->m_next;
- }
-
- *countp = count;
- *mb_pp = (u_char *) t_packet;
- *tm_pp = tm_p;
- return;
-}
-
-static void
-wlmmcstat(int unit)
-{
- register struct wl_softc *sc = WLSOFTC(unit);
- short base = sc->base;
- u_short tmp;
-
- printf("wl%d: DCE_STATUS: 0x%x, ", unit,
- wlmmcread(base,MMC_DCE_STATUS) & 0x0f);
- tmp = wlmmcread(base,MMC_CORRECT_NWID_H) << 8;
- tmp |= wlmmcread(base,MMC_CORRECT_NWID_L);
- printf("Correct NWID's: %d, ", tmp);
- tmp = wlmmcread(base,MMC_WRONG_NWID_H) << 8;
- tmp |= wlmmcread(base,MMC_WRONG_NWID_L);
- printf("Wrong NWID's: %d\n", tmp);
- printf("THR_PRE_SET: 0x%x, ", wlmmcread(base,MMC_THR_PRE_SET));
- printf("SIGNAL_LVL: %d, SILENCE_LVL: %d\n",
- wlmmcread(base,MMC_SIGNAL_LVL),
- wlmmcread(base,MMC_SILENCE_LVL));
- printf("SIGN_QUAL: 0x%x, NETW_ID: %x:%x, DES: %d\n",
- wlmmcread(base,MMC_SIGN_QUAL),
- wlmmcread(base,MMC_NETW_ID_H),
- wlmmcread(base,MMC_NETW_ID_L),
- wlmmcread(base,MMC_DES_AVAIL));
-}
-
-static u_short
-wlmmcread(u_int base, u_short reg)
-{
- while(inw(HASR(base)) & HASR_MMC_BUSY) ;
- outw(MMCR(base),reg << 1);
- while(inw(HASR(base)) & HASR_MMC_BUSY) ;
- return (u_short)inw(MMCR(base)) >> 8;
-}
-
-static void
-getsnr(int unit)
-{
- MMC_WRITE(MMC_FREEZE,1);
- /*
- * SNR retrieval procedure :
- *
- * read signal level : wlmmcread(base, MMC_SIGNAL_LVL);
- * read silence level : wlmmcread(base, MMC_SILENCE_LVL);
- */
- MMC_WRITE(MMC_FREEZE,0);
- /*
- * SNR is signal:silence ratio.
- */
-}
-
-/*
-** wlgetpsa
-**
-** Reads the psa for the wavelan at (base) into (buf)
-*/
-static void
-wlgetpsa(int base, u_char *buf)
-{
- int i;
-
- PCMD(base, HACR_DEFAULT & ~HACR_16BITS);
- PCMD(base, HACR_DEFAULT & ~HACR_16BITS);
-
- for (i = 0; i < 0x40; i++) {
- outw(PIOR2(base), i);
- buf[i] = inb(PIOP2(base));
- }
- PCMD(base, HACR_DEFAULT);
- PCMD(base, HACR_DEFAULT);
-}
-
-/*
-** wlsetpsa
-**
-** Writes the psa for wavelan (unit) from the softc back to the
-** board. Updates the CRC and sets the CRC OK flag.
-**
-** Do not call this when the board is operating, as it doesn't
-** preserve the hacr.
-*/
-static void
-wlsetpsa(int unit)
-{
- register struct wl_softc *sc = WLSOFTC(unit);
- short base = sc->base;
- int i, oldpri;
- u_short crc;
-
- crc = wlpsacrc(sc->psa); /* calculate CRC of PSA */
- sc->psa[WLPSA_CRCLOW] = crc & 0xff;
- sc->psa[WLPSA_CRCHIGH] = (crc >> 8) & 0xff;
- sc->psa[WLPSA_CRCOK] = 0x55; /* default to 'bad' until programming complete */
-
- oldpri = splimp(); /* ick, long pause */
-
- PCMD(base, HACR_DEFAULT & ~HACR_16BITS);
- PCMD(base, HACR_DEFAULT & ~HACR_16BITS);
-
- for (i = 0; i < 0x40; i++) {
- DELAY(DELAYCONST);
- outw(PIOR2(base),i); /* write param memory */
- DELAY(DELAYCONST);
- outb(PIOP2(base), sc->psa[i]);
- }
- DELAY(DELAYCONST);
- outw(PIOR2(base),WLPSA_CRCOK); /* update CRC flag*/
- DELAY(DELAYCONST);
- sc->psa[WLPSA_CRCOK] = 0xaa; /* OK now */
- outb(PIOP2(base), 0xaa); /* all OK */
- DELAY(DELAYCONST);
-
- PCMD(base, HACR_DEFAULT);
- PCMD(base, HACR_DEFAULT);
-
- splx(oldpri);
-}
-
-/*
-** CRC routine provided by Christopher Giordano <cgiordan@gdeb.com>,
-** from original code by Tomi Mikkonen (tomitm@remedy.fi)
-*/
-
-static u_int crc16_table[16] = {
- 0x0000, 0xCC01, 0xD801, 0x1400,
- 0xF001, 0x3C00, 0x2800, 0xE401,
- 0xA001, 0x6C00, 0x7800, 0xB401,
- 0x5000, 0x9C01, 0x8801, 0x4400
-};
-
-static u_short
-wlpsacrc(u_char *buf)
-{
- u_short crc = 0;
- int i, r1;
-
- for (i = 0; i < 0x3d; i++, buf++) {
- /* lower 4 bits */
- r1 = crc16_table[crc & 0xF];
- crc = (crc >> 4) & 0x0FFF;
- crc = crc ^ r1 ^ crc16_table[*buf & 0xF];
-
- /* upper 4 bits */
- r1 = crc16_table[crc & 0xF];
- crc = (crc >> 4) & 0x0FFF;
- crc = crc ^ r1 ^ crc16_table[(*buf >> 4) & 0xF];
- }
- return(crc);
-}
-#ifdef WLCACHE
-
-/*
- * wl_cache_store
- *
- * take input packet and cache various radio hw characteristics
- * indexed by MAC address.
- *
- * Some things to think about:
- * note that no space is malloced.
- * We might hash the mac address if the cache were bigger.
- * It is not clear that the cache is big enough.
- * It is also not clear how big it should be.
- * The cache is IP-specific. We don't care about that as
- * we want it to be IP-specific.
- * The last N recv. packets are saved. This will tend
- * to reward agents and mobile hosts that beacon.
- * That is probably fine for mobile ip.
- */
-
-/* globals for wavelan signal strength cache */
-/* this should go into softc structure above.
-*/
-
-/* set true if you want to limit cache items to broadcast/mcast
- * only packets (not unicast)
- */
-static int wl_cache_mcastonly = 1;
-SYSCTL_INT(_machdep, OID_AUTO, wl_cache_mcastonly, CTLFLAG_RW,
- &wl_cache_mcastonly, 0, "");
-
-/* set true if you want to limit cache items to IP packets only
-*/
-static int wl_cache_iponly = 1;
-SYSCTL_INT(_machdep, OID_AUTO, wl_cache_iponly, CTLFLAG_RW,
- &wl_cache_iponly, 0, "");
-
-/* zero out the cache
-*/
-static void
-wl_cache_zero(int unit)
-{
- register struct wl_softc *sc = WLSOFTC(unit);
-
- bzero(&sc->w_sigcache[0], sizeof(struct w_sigcache) * MAXCACHEITEMS);
- sc->w_sigitems = 0;
- sc->w_nextcache = 0;
- sc->w_wrapindex = 0;
-}
-
-/* store hw signal info in cache.
- * index is MAC address, but an ip src gets stored too
- * There are two filters here controllable via sysctl:
- * throw out unicast (on by default, but can be turned off)
- * throw out non-ip (on by default, but can be turned off)
- */
-static
-void wl_cache_store (int unit, int base, struct ether_header *eh,
- struct mbuf *m)
-{
- struct ip *ip = NULL; /* Avoid GCC warning */
- int i;
- int signal, silence;
- int w_insertcache; /* computed index for cache entry storage */
- register struct wl_softc *sc = WLSOFTC(unit);
- int ipflag = wl_cache_iponly;
-
- /* filters:
- * 1. ip only
- * 2. configurable filter to throw out unicast packets,
- * keep multicast only.
- */
-
-#ifdef INET
- /* reject if not IP packet
- */
- if ( wl_cache_iponly && (ntohs(eh->ether_type) != 0x800)) {
- return;
- }
-
- /* check if broadcast or multicast packet. we toss
- * unicast packets
- */
- if (wl_cache_mcastonly && ((eh->ether_dhost[0] & 1) == 0)) {
- return;
- }
-
- /* find the ip header. we want to store the ip_src
- * address. use the mtod macro(in mbuf.h)
- * to typecast m to struct ip *
- */
- if (ipflag) {
- ip = mtod(m, struct ip *);
- }
-
- /* do a linear search for a matching MAC address
- * in the cache table
- * . MAC address is 6 bytes,
- * . var w_nextcache holds total number of entries already cached
- */
- for(i = 0; i < sc->w_nextcache; i++) {
- if (! bcmp(eh->ether_shost, sc->w_sigcache[i].macsrc, 6 )) {
- /* Match!,
- * so we already have this entry,
- * update the data, and LRU age
- */
- break;
- }
- }
-
- /* did we find a matching mac address?
- * if yes, then overwrite a previously existing cache entry
- */
- if (i < sc->w_nextcache ) {
- w_insertcache = i;
- }
- /* else, have a new address entry,so
- * add this new entry,
- * if table full, then we need to replace entry
- */
- else {
-
- /* check for space in cache table
- * note: w_nextcache also holds number of entries
- * added in the cache table
- */
- if ( sc->w_nextcache < MAXCACHEITEMS ) {
- w_insertcache = sc->w_nextcache;
- sc->w_nextcache++;
- sc->w_sigitems = sc->w_nextcache;
- }
- /* no space found, so simply wrap with wrap index
- * and "zap" the next entry
- */
- else {
- if (sc->w_wrapindex == MAXCACHEITEMS) {
- sc->w_wrapindex = 0;
- }
- w_insertcache = sc->w_wrapindex++;
- }
- }
-
- /* invariant: w_insertcache now points at some slot
- * in cache.
- */
- if (w_insertcache < 0 || w_insertcache >= MAXCACHEITEMS) {
- log(LOG_ERR,
- "wl_cache_store, bad index: %d of [0..%d], gross cache error\n",
- w_insertcache, MAXCACHEITEMS);
- return;
- }
-
- /* store items in cache
- * .ipsrc
- * .macsrc
- * .signal (0..63) ,silence (0..63) ,quality (0..15)
- */
- if (ipflag) {
- sc->w_sigcache[w_insertcache].ipsrc = ip->ip_src.s_addr;
- }
- bcopy( eh->ether_shost, sc->w_sigcache[w_insertcache].macsrc, 6);
- signal = sc->w_sigcache[w_insertcache].signal = wlmmcread(base, MMC_SIGNAL_LVL) & 0x3f;
- silence = sc->w_sigcache[w_insertcache].silence = wlmmcread(base, MMC_SILENCE_LVL) & 0x3f;
- sc->w_sigcache[w_insertcache].quality = wlmmcread(base, MMC_SIGN_QUAL) & 0x0f;
- if (signal > 0)
- sc->w_sigcache[w_insertcache].snr =
- signal - silence;
- else
- sc->w_sigcache[w_insertcache].snr = 0;
-#endif /* INET */
-
-}
-#endif /* WLCACHE */
-
-/*
- * determine if in all multicast mode or not
- *
- * returns: 1 if IFF_ALLMULTI should be set
- * else 0
- */
-#ifdef MULTICAST
-
-#if defined(__FreeBSD__) && __FreeBSD_version < 300000 /* not required */
-static int
-check_allmulti(int unit)
-{
- register struct wl_softc *sc = WLSOFTC(unit);
- short base = sc->base;
- struct ether_multi *enm;
- struct ether_multistep step;
-
- ETHER_FIRST_MULTI(step, &sc->wl_ac, enm);
- while (enm != NULL) {
- unsigned int lo, hi;
-#ifdef MDEBUG
- printf("enm_addrlo %x:%x:%x:%x:%x:%x\n", enm->enm_addrlo[0], enm->enm_addrlo[1],
- enm->enm_addrlo[2], enm->enm_addrlo[3], enm->enm_addrlo[4],
- enm->enm_addrlo[5]);
- printf("enm_addrhi %x:%x:%x:%x:%x:%x\n", enm->enm_addrhi[0], enm->enm_addrhi[1],
- enm->enm_addrhi[2], enm->enm_addrhi[3], enm->enm_addrhi[4],
- enm->enm_addrhi[5]);
-#endif
- if (bcmp(enm->enm_addrlo, enm->enm_addrhi, 6) != 0) {
- return(1);
- }
- ETHER_NEXT_MULTI(step, enm);
- }
- return(0);
-}
-#endif
-#endif
diff --git a/sys/dev/wl/if_wl.h b/sys/dev/wl/if_wl.h
deleted file mode 100644
index 70d5d30cdb66..000000000000
--- a/sys/dev/wl/if_wl.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * 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 all copyright
- * notices, this list of conditions and the following disclaimer.
- * 2. The names of the authors may not be used to endorse or promote products
- * derived from this software withough 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.
- *
- */
-/* Definitions for WaveLAN driver */
-
-#ifndef _IF_WL_H
-#define _IF_WL_H
-
-#define STATUS_TRIES 15000
-
-#define N_FD 100
-#define N_RBD 100
-#define N_TBD 72
-#define RCVBUFSIZE 540
-#define I82586NULL 0xffff
-
-#define DSF_RUNNING 1
-
-#define MOD_ENAL 1
-#define MOD_PROM 2
-
-typedef struct {
- rbd_t r;
- char rbd_pad[2];
- char rbuffer[RCVBUFSIZE];
-} ru_t;
-
-/* Board 64k RAM layout. Offsets from 0x0000 */
-
-#define OFFSET_RU 0x0000 /* 0x64 * fd_t = 0x898 */
-#define OFFSET_RBD 0x0900 /* 0x64 * ru_t = 0xd7a0 */
-#define OFFSET_CU 0xe0a0 /* 0x100 */
-#define OFFSET_TBD 0xe1a0 /* 0x48 * tbd_t = 0x240 */
-#define OFFSET_TBUF 0xe3e0 /* 0x1bfe */
-#define OFFSET_SCB 0xffde /* 0x1 * scb_t = 0x10 */
-#define OFFSET_ISCP 0xffee /* 0x1 * iscp_t = 0x8 */
-#define OFFSET_SCP 0xfff6 /* 0x1 * scp_t = 0xa */
-
-/* WaveLAN host interface definitions */
-
-#define HACR(base) (base) /* Host Adapter Command Register */
-#define HASR(base) (base) /* Host Adapter Status Register */
-#define MMCR(base) (base+0x2) /* Modem Management Ctrl Register */
-#define PIOR0(base) (base+0x4) /* Program I/O Address Register 0 */
-#define PIOP0(base) (base+0x6) /* Program I/O Port 0 */
-#define PIOR1(base) (base+0x8) /* Program I/O Address Register 1 */
-#define PIOP1(base) (base+0xa) /* Program I/O Port 1 */
-#define PIOR2(base) (base+0xc) /* Program I/O Address Register 2 */
-#define PIOP2(base) (base+0xe) /* Program I/O Port 2 */
-
-/* Program I/O Mode Register values */
-
-#define STATIC_PIO 0 /* Mode 1: static mode */
-#define AUTOINCR_PIO 1 /* Mode 2: auto increment mode */
-#define AUTODECR_PIO 2 /* Mode 3: auto decrement mode */
-#define PARAM_ACCESS_PIO 3 /* Mode 4: LAN parameter access mode */
-#define PIO_MASK 3 /* register mask */
-#define PIOM(cmd,piono) ((u_short)cmd << 10 << (piono * 2))
-
-/* Host Adapter status register definitions */
-
-#define HASR_INTR 0x0001 /* Interrupt request from 82586 */
-#define HASR_MMC_INTR 0x0002 /* Interrupt request from MMC */
-#define HASR_MMC_BUSY 0x0004 /* MMC busy indication */
-#define HASR_PARA_BUSY 0x0008 /* LAN parameter storage area busy */
-
-/* Host Adapter command register definitions */
-
-#define HACR_RESET 0x0001 /* Reset board */
-#define HACR_CA 0x0002 /* Set Channel Attention for 82586 */
-#define HACR_16BITS 0x0004 /* 1==16 bits operation, 0==8 bits */
-#define HACR_OUT1 0x0008 /* General purpose output pin */
-#define HACR_OUT2 0x0010 /* General purpose output pin */
-#define HACR_MASK_82586 0x0020 /* Mask 82586 interrupts, 1==unmask */
-#define HACR_MASK_MMC 0x0040 /* Mask MMC interrupts, 1==unmask */
-#define HACR_INTR_CLEN 0x0080 /* interrupt status clear enable */
-
-#define HACR_DEFAULT (HACR_OUT1 | HACR_OUT2 | HACR_16BITS | PIOM(STATIC_PIO, 0) | PIOM(AUTOINCR_PIO, 1) | PIOM(PARAM_ACCESS_PIO, 2))
-#define HACR_INTRON (HACR_MASK_82586 | HACR_MASK_MMC | HACR_INTR_CLEN)
-#define CMD(unit) \
- { \
- outw(HACR(WLSOFTC(unit)->base),WLSOFTC(unit)->hacr); \
- /* delay for 50 us, might only be needed sometimes */ \
- DELAY(DELAYCONST); \
- }
-
-/* macro for setting the channel attention bit. No delays here since
- * it is used in critical sections
- */
-#define SET_CHAN_ATTN(unit) \
- { \
- outw(HACR(WLSOFTC(unit)->base),WLSOFTC(unit)->hacr | HACR_CA); \
- }
-
-
-#define MMC_WRITE(cmd,val) \
- while(inw(HASR(WLSOFTC(unit)->base)) & HASR_MMC_BUSY) ; \
- outw(MMCR(WLSOFTC(unit)->base), \
- (u_short)(((u_short)(val) << 8) | ((cmd) << 1) | 1))
-
-#endif /* _IF_WL_H */
-
diff --git a/sys/fs/cd9660/TODO b/sys/fs/cd9660/TODO
deleted file mode 100644
index b8d7f3efebb9..000000000000
--- a/sys/fs/cd9660/TODO
+++ /dev/null
@@ -1,43 +0,0 @@
-# $FreeBSD$
-
- 2) should understand Rock Ridge
-
- Yes, we have follows function.
-
- o Symbolic Link
- o Real Name(long name)
- o File Attribute
- o Time stamp
- o uid, gid
- o Devices
- o Relocated directories
-
- Except follows:
-
- o POSIX device number mapping
-
- There is some preliminary stuff in there that (ab-)uses the mknod
- system call, but this needs a writable filesystem
-
- 5) should have name translation enabled by mount flag
-
- Yes. we can disable the Rock Ridge Extension by follows option;
-
- "mount -t isofs -o -norrip /dev/cd0d /cdrom"
-
- 6) should run as a user process, and not take up kernel space (cdroms
- are slow)
-
- Not yet.
-
- 7) ECMA support.
-
- Not yet. we need not only a technical spec but also ECMA format
- cd-rom itself!
-
- 8) Character set change by SVD ( multi SVD support )
-
- Not yet. We should also hack the other part of system as 8 bit
- clean. As far as I know, if you export the cdrom by NFS, the client
- can access the 8 bit clean (ie. Solaris Japanese with EUC code )
-
diff --git a/sys/fs/cd9660/TODO.hibler b/sys/fs/cd9660/TODO.hibler
deleted file mode 100644
index 660b268cb643..000000000000
--- a/sys/fs/cd9660/TODO.hibler
+++ /dev/null
@@ -1,14 +0,0 @@
-1. Investiate making ISOFS another UFS shared filesystem (ala FFS/MFS/LFS).
- Since it was modelled after the inode code, we might be able to merge
- them back. It looks like a seperate (but very similar) lookup routine
- will be needed due to the associated file stuff.
-
-2. It would be nice to be able to use the vfs_cluster code.
- Unfortunately, if the logical block size is smaller than the page size,
- it won't work. Also, if throughtput is relatively constant for any
- block size (as it is for the HP drive--150kbs) then clustering may not
- buy much (or may even hurt when vfs_cluster comes up with a large sync
- cluster).
-
-3. Seems like there should be a "notrans" or some such mount option to show
- filenames as they really are without lower-casing. Does this make sense?
diff --git a/sys/fs/cd9660/cd9660_bmap.c b/sys/fs/cd9660/cd9660_bmap.c
deleted file mode 100644
index e5fcd9ab32b3..000000000000
--- a/sys/fs/cd9660/cd9660_bmap.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/*-
- * Copyright (c) 1994
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley
- * by Pace Willisson (pace@blitz.com). The Rock Ridge Extension
- * Support code is derived from software contributed to Berkeley
- * by Atsushi Murai (amurai@spec.co.jp).
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)cd9660_bmap.c 8.3 (Berkeley) 1/23/94
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/vnode.h>
-#include <sys/mount.h>
-
-#include <isofs/cd9660/iso.h>
-#include <isofs/cd9660/cd9660_node.h>
-
-/*
- * Bmap converts a the logical block number of a file to its physical block
- * number on the disk. The conversion is done by using the logical block
- * number to index into the data block (extent) for the file.
- */
-int
-cd9660_bmap(ap)
- struct vop_bmap_args /* {
- struct vnode *a_vp;
- daddr_t a_bn;
- struct vnode **a_vpp;
- daddr_t *a_bnp;
- int *a_runp;
- int *a_runb;
- } */ *ap;
-{
- struct iso_node *ip = VTOI(ap->a_vp);
- daddr_t lblkno = ap->a_bn;
- int bshift;
-
- /*
- * Check for underlying vnode requests and ensure that logical
- * to physical mapping is requested.
- */
- if (ap->a_vpp != NULL)
- *ap->a_vpp = ip->i_devvp;
- if (ap->a_bnp == NULL)
- return (0);
-
- /*
- * Compute the requested block number
- */
- bshift = ip->i_mnt->im_bshift;
- *ap->a_bnp = (ip->iso_start + lblkno) << (bshift - DEV_BSHIFT);
-
- /*
- * Determine maximum number of readahead blocks following the
- * requested block.
- */
- if (ap->a_runp) {
- int nblk;
-
- nblk = (ip->i_size >> bshift) - (lblkno + 1);
- if (nblk <= 0)
- *ap->a_runp = 0;
- else if (nblk >= (MAXBSIZE >> bshift))
- *ap->a_runp = (MAXBSIZE >> bshift) - 1;
- else
- *ap->a_runp = nblk;
- }
-
- if (ap->a_runb) {
- *ap->a_runb = 0;
- }
-
- return 0;
-}
diff --git a/sys/fs/cd9660/cd9660_lookup.c b/sys/fs/cd9660/cd9660_lookup.c
deleted file mode 100644
index b9aabbc7e2b8..000000000000
--- a/sys/fs/cd9660/cd9660_lookup.c
+++ /dev/null
@@ -1,421 +0,0 @@
-/*-
- * Copyright (c) 1989, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley
- * by Pace Willisson (pace@blitz.com). The Rock Ridge Extension
- * Support code is derived from software contributed to Berkeley
- * by Atsushi Murai (amurai@spec.co.jp).
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)ufs_lookup.c 7.33 (Berkeley) 5/19/91
- *
- * @(#)cd9660_lookup.c 8.2 (Berkeley) 1/23/94
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/namei.h>
-#include <sys/buf.h>
-#include <sys/vnode.h>
-#include <sys/mount.h>
-
-#include <isofs/cd9660/iso.h>
-#include <isofs/cd9660/cd9660_node.h>
-#include <isofs/cd9660/iso_rrip.h>
-
-/*
- * Convert a component of a pathname into a pointer to a locked inode.
- * This is a very central and rather complicated routine.
- * If the file system is not maintained in a strict tree hierarchy,
- * this can result in a deadlock situation (see comments in code below).
- *
- * The flag argument is LOOKUP, CREATE, RENAME, or DELETE depending on
- * whether the name is to be looked up, created, renamed, or deleted.
- * When CREATE, RENAME, or DELETE is specified, information usable in
- * creating, renaming, or deleting a directory entry may be calculated.
- * If flag has LOCKPARENT or'ed into it and the target of the pathname
- * exists, lookup returns both the target and its parent directory locked.
- * When creating or renaming and LOCKPARENT is specified, the target may
- * not be ".". When deleting and LOCKPARENT is specified, the target may
- * be "."., but the caller must check to ensure it does an vrele and iput
- * instead of two iputs.
- *
- * Overall outline of ufs_lookup:
- *
- * search for name in directory, to found or notfound
- * notfound:
- * if creating, return locked directory, leaving info on available slots
- * else return error
- * found:
- * if at end of path and deleting, return information to allow delete
- * if at end of path and rewriting (RENAME and LOCKPARENT), lock target
- * inode and return info to allow rewrite
- * if not at end, add name to cache; if at end and neither creating
- * nor deleting, add name to cache
- *
- * NOTE: (LOOKUP | LOCKPARENT) currently returns the parent inode unlocked.
- */
-int
-cd9660_lookup(ap)
- struct vop_cachedlookup_args /* {
- struct vnode *a_dvp;
- struct vnode **a_vpp;
- struct componentname *a_cnp;
- } */ *ap;
-{
- register struct vnode *vdp; /* vnode for directory being searched */
- register struct iso_node *dp; /* inode for directory being searched */
- register struct iso_mnt *imp; /* file system that directory is in */
- struct buf *bp; /* a buffer of directory entries */
- struct iso_directory_record *ep = 0;/* the current directory entry */
- int entryoffsetinblock; /* offset of ep in bp's buffer */
- int saveoffset = 0; /* offset of last directory entry in dir */
- int numdirpasses; /* strategy for directory search */
- doff_t endsearch; /* offset to end directory search */
- struct vnode *pdp; /* saved dp during symlink work */
- struct vnode *tdp; /* returned by cd9660_vget_internal */
- u_long bmask; /* block offset mask */
- int lockparent; /* 1 => lockparent flag is set */
- int wantparent; /* 1 => wantparent or lockparent flag */
- int error;
- ino_t ino = 0;
- int reclen;
- u_short namelen;
- int isoflags;
- char altname[NAME_MAX];
- int res;
- int assoc, len;
- char *name;
- struct vnode **vpp = ap->a_vpp;
- struct componentname *cnp = ap->a_cnp;
- int flags = cnp->cn_flags;
- int nameiop = cnp->cn_nameiop;
- struct proc *p = cnp->cn_proc;
-
- bp = NULL;
- *vpp = NULL;
- vdp = ap->a_dvp;
- dp = VTOI(vdp);
- imp = dp->i_mnt;
- lockparent = flags & LOCKPARENT;
- wantparent = flags & (LOCKPARENT|WANTPARENT);
-
- /*
- * We now have a segment name to search for, and a directory to search.
- */
-
- len = cnp->cn_namelen;
- name = cnp->cn_nameptr;
- /*
- * A leading `=' means, we are looking for an associated file
- */
- if ((assoc = (imp->iso_ftype != ISO_FTYPE_RRIP && *name == ASSOCCHAR)))
- {
- len--;
- name++;
- }
-
- /*
- * If there is cached information on a previous search of
- * this directory, pick up where we last left off.
- * We cache only lookups as these are the most common
- * and have the greatest payoff. Caching CREATE has little
- * benefit as it usually must search the entire directory
- * to determine that the entry does not exist. Caching the
- * location of the last DELETE or RENAME has not reduced
- * profiling time and hence has been removed in the interest
- * of simplicity.
- */
- bmask = imp->im_bmask;
- if (nameiop != LOOKUP || dp->i_diroff == 0 ||
- dp->i_diroff > dp->i_size) {
- entryoffsetinblock = 0;
- dp->i_offset = 0;
- numdirpasses = 1;
- } else {
- dp->i_offset = dp->i_diroff;
- if ((entryoffsetinblock = dp->i_offset & bmask) &&
- (error = cd9660_blkatoff(vdp, (off_t)dp->i_offset, NULL, &bp)))
- return (error);
- numdirpasses = 2;
- nchstats.ncs_2passes++;
- }
- endsearch = dp->i_size;
-
-searchloop:
- while (dp->i_offset < endsearch) {
- /*
- * If offset is on a block boundary,
- * read the next directory block.
- * Release previous if it exists.
- */
- if ((dp->i_offset & bmask) == 0) {
- if (bp != NULL)
- brelse(bp);
- if ((error =
- cd9660_blkatoff(vdp, (off_t)dp->i_offset, NULL, &bp)) != 0)
- return (error);
- entryoffsetinblock = 0;
- }
- /*
- * Get pointer to next entry.
- */
- ep = (struct iso_directory_record *)
- ((char *)bp->b_data + entryoffsetinblock);
-
- reclen = isonum_711(ep->length);
- if (reclen == 0) {
- /* skip to next block, if any */
- dp->i_offset =
- (dp->i_offset & ~bmask) + imp->logical_block_size;
- continue;
- }
-
- if (reclen < ISO_DIRECTORY_RECORD_SIZE)
- /* illegal entry, stop */
- break;
-
- if (entryoffsetinblock + reclen > imp->logical_block_size)
- /* entries are not allowed to cross boundaries */
- break;
-
- namelen = isonum_711(ep->name_len);
- isoflags = isonum_711(imp->iso_ftype == ISO_FTYPE_HIGH_SIERRA?
- &ep->date[6]: ep->flags);
-
- if (reclen < ISO_DIRECTORY_RECORD_SIZE + namelen)
- /* illegal entry, stop */
- break;
-
- /*
- * Check for a name match.
- */
- switch (imp->iso_ftype) {
- default:
- if (!(isoflags & 4) == !assoc) {
- if ((len == 1
- && *name == '.')
- || (flags & ISDOTDOT)) {
- if (namelen == 1
- && ep->name[0] == ((flags & ISDOTDOT) ? 1 : 0)) {
- /*
- * Save directory entry's inode number and
- * release directory buffer.
- */
- dp->i_ino = isodirino(ep, imp);
- goto found;
- }
- if (namelen != 1
- || ep->name[0] != 0)
- goto notfound;
- } else if (!(res = isofncmp(name, len, ep->name, namelen, imp->joliet_level))) {
- if (isoflags & 2)
- ino = isodirino(ep, imp);
- else
- ino = dbtob(bp->b_blkno)
- + entryoffsetinblock;
- saveoffset = dp->i_offset;
- } else if (ino)
- goto foundino;
-#ifdef NOSORTBUG /* On some CDs directory entries are not sorted correctly */
- else if (res < 0)
- goto notfound;
- else if (res > 0 && numdirpasses == 2)
- numdirpasses++;
-#endif
- }
- break;
- case ISO_FTYPE_RRIP:
- if (isonum_711(ep->flags)&2)
- ino = isodirino(ep, imp);
- else
- ino = dbtob(bp->b_blkno) + entryoffsetinblock;
- dp->i_ino = ino;
- cd9660_rrip_getname(ep,altname,&namelen,&dp->i_ino,imp);
- if (namelen == cnp->cn_namelen
- && !bcmp(name,altname,namelen))
- goto found;
- ino = 0;
- break;
- }
- dp->i_offset += reclen;
- entryoffsetinblock += reclen;
- }
- if (ino) {
-foundino:
- dp->i_ino = ino;
- if (saveoffset != dp->i_offset) {
- if (lblkno(imp, dp->i_offset) !=
- lblkno(imp, saveoffset)) {
- if (bp != NULL)
- brelse(bp);
- if ((error = cd9660_blkatoff(vdp,
- (off_t)saveoffset, NULL, &bp)) != 0)
- return (error);
- }
- entryoffsetinblock = saveoffset & bmask;
- ep = (struct iso_directory_record *)
- ((char *)bp->b_data + entryoffsetinblock);
- dp->i_offset = saveoffset;
- }
- goto found;
- }
-notfound:
- /*
- * If we started in the middle of the directory and failed
- * to find our target, we must check the beginning as well.
- */
- if (numdirpasses == 2) {
- numdirpasses--;
- dp->i_offset = 0;
- endsearch = dp->i_diroff;
- goto searchloop;
- }
- if (bp != NULL)
- brelse(bp);
-
- /*
- * Insert name into cache (as non-existent) if appropriate.
- */
- if (cnp->cn_flags & MAKEENTRY)
- cache_enter(vdp, *vpp, cnp);
- if (nameiop == CREATE || nameiop == RENAME)
- return (EROFS);
- return (ENOENT);
-
-found:
- if (numdirpasses == 2)
- nchstats.ncs_pass2++;
-
- /*
- * Found component in pathname.
- * If the final component of path name, save information
- * in the cache as to where the entry was found.
- */
- if ((flags & ISLASTCN) && nameiop == LOOKUP)
- dp->i_diroff = dp->i_offset;
-
- /*
- * Step through the translation in the name. We do not `iput' the
- * directory because we may need it again if a symbolic link
- * is relative to the current directory. Instead we save it
- * unlocked as "pdp". We must get the target inode before unlocking
- * the directory to insure that the inode will not be removed
- * before we get it. We prevent deadlock by always fetching
- * inodes from the root, moving down the directory tree. Thus
- * when following backward pointers ".." we must unlock the
- * parent directory before getting the requested directory.
- * There is a potential race condition here if both the current
- * and parent directories are removed before the `iget' for the
- * inode associated with ".." returns. We hope that this occurs
- * infrequently since we cannot avoid this race condition without
- * implementing a sophisticated deadlock detection algorithm.
- * Note also that this simple deadlock detection scheme will not
- * work if the file system has any hard links other than ".."
- * that point backwards in the directory structure.
- */
- pdp = vdp;
- /*
- * If ino is different from dp->i_ino,
- * it's a relocated directory.
- */
- if (flags & ISDOTDOT) {
- VOP_UNLOCK(pdp, 0, p); /* race to get the inode */
- error = cd9660_vget_internal(vdp->v_mount, dp->i_ino, &tdp,
- dp->i_ino != ino, ep);
- brelse(bp);
- if (error) {
- vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY, p);
- return (error);
- }
- if (lockparent && (flags & ISLASTCN) &&
- (error = vn_lock(pdp, LK_EXCLUSIVE, p))) {
- vput(tdp);
- return (error);
- }
- *vpp = tdp;
- } else if (dp->i_number == dp->i_ino) {
- brelse(bp);
- VREF(vdp); /* we want ourself, ie "." */
- *vpp = vdp;
- } else {
- error = cd9660_vget_internal(vdp->v_mount, dp->i_ino, &tdp,
- dp->i_ino != ino, ep);
- brelse(bp);
- if (error)
- return (error);
- if (!lockparent || !(flags & ISLASTCN))
- VOP_UNLOCK(pdp, 0, p);
- *vpp = tdp;
- }
-
- /*
- * Insert name into cache if appropriate.
- */
- if (cnp->cn_flags & MAKEENTRY)
- cache_enter(vdp, *vpp, cnp);
- return (0);
-}
-
-/*
- * Return buffer with the contents of block "offset" from the beginning of
- * directory "ip". If "res" is non-zero, fill it in with a pointer to the
- * remaining space in the directory.
- */
-int
-cd9660_blkatoff(vp, offset, res, bpp)
- struct vnode *vp;
- off_t offset;
- char **res;
- struct buf **bpp;
-{
- struct iso_node *ip;
- register struct iso_mnt *imp;
- struct buf *bp;
- daddr_t lbn;
- int bsize, error;
-
- ip = VTOI(vp);
- imp = ip->i_mnt;
- lbn = lblkno(imp, offset);
- bsize = blksize(imp, ip, lbn);
-
- if ((error = bread(vp, lbn, bsize, NOCRED, &bp)) != 0) {
- brelse(bp);
- *bpp = NULL;
- return (error);
- }
- if (res)
- *res = (char *)bp->b_data + blkoff(imp, offset);
- *bpp = bp;
- return (0);
-}
diff --git a/sys/fs/cd9660/cd9660_mount.h b/sys/fs/cd9660/cd9660_mount.h
deleted file mode 100644
index d42adcd22b91..000000000000
--- a/sys/fs/cd9660/cd9660_mount.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 1995
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley
- * by Pace Willisson (pace@blitz.com). The Rock Ridge Extension
- * Support code is derived from software contributed to Berkeley
- * by Atsushi Murai (amurai@spec.co.jp).
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)cd9660_mount.h 8.1 (Berkeley) 5/24/95
- */
-
-/*
- * Arguments to mount ISO 9660 filesystems.
- */
-struct iso_args {
- char *fspec; /* block special device to mount */
- struct export_args export; /* network export info */
- int flags; /* mounting flags, see below */
- int ssector; /* starting sector, 0 for 1st session */
-};
-#define ISOFSMNT_NORRIP 0x00000001 /* disable Rock Ridge Ext.*/
-#define ISOFSMNT_GENS 0x00000002 /* enable generation numbers */
-#define ISOFSMNT_EXTATT 0x00000004 /* enable extended attributes */
-#define ISOFSMNT_NOJOLIET 0x00000008 /* disable Joliet Ext.*/
diff --git a/sys/fs/cd9660/cd9660_node.c b/sys/fs/cd9660/cd9660_node.c
deleted file mode 100644
index d7093fe3fd7f..000000000000
--- a/sys/fs/cd9660/cd9660_node.c
+++ /dev/null
@@ -1,428 +0,0 @@
-/*-
- * Copyright (c) 1982, 1986, 1989, 1994, 1995
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley
- * by Pace Willisson (pace@blitz.com). The Rock Ridge Extension
- * Support code is derived from software contributed to Berkeley
- * by Atsushi Murai (amurai@spec.co.jp).
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)cd9660_node.c 8.2 (Berkeley) 1/23/94
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/mount.h>
-#include <sys/proc.h>
-#include <sys/buf.h>
-#include <sys/vnode.h>
-#include <sys/malloc.h>
-#include <sys/stat.h>
-
-#include <isofs/cd9660/iso.h>
-#include <isofs/cd9660/cd9660_node.h>
-#include <isofs/cd9660/cd9660_mount.h>
-
-/*
- * Structures associated with iso_node caching.
- */
-static struct iso_node **isohashtbl;
-static u_long isohash;
-#define INOHASH(device, inum) ((minor(device) + ((inum)>>12)) & isohash)
-#ifndef NULL_SIMPLELOCKS
-static struct simplelock cd9660_ihash_slock;
-#endif
-
-static void cd9660_ihashrem __P((struct iso_node *));
-static unsigned cd9660_chars2ui __P((unsigned char *begin, int len));
-
-/*
- * Initialize hash links for inodes and dnodes.
- */
-int
-cd9660_init(vfsp)
- struct vfsconf *vfsp;
-{
-
- isohashtbl = hashinit(desiredvnodes, M_ISOFSMNT, &isohash);
- simple_lock_init(&cd9660_ihash_slock);
- return (0);
-}
-
-
-/*
- * Use the device/inum pair to find the incore inode, and return a pointer
- * to it. If it is in core, but locked, wait for it.
- */
-struct vnode *
-cd9660_ihashget(dev, inum)
- dev_t dev;
- ino_t inum;
-{
- struct proc *p = curproc; /* XXX */
- struct iso_node *ip;
- struct vnode *vp;
-
-loop:
- simple_lock(&cd9660_ihash_slock);
- for (ip = isohashtbl[INOHASH(dev, inum)]; ip; ip = ip->i_next) {
- if (inum == ip->i_number && dev == ip->i_dev) {
- vp = ITOV(ip);
- simple_lock(&vp->v_interlock);
- simple_unlock(&cd9660_ihash_slock);
- if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, p))
- goto loop;
- return (vp);
- }
- }
- simple_unlock(&cd9660_ihash_slock);
- return (NULL);
-}
-
-/*
- * Insert the inode into the hash table, and return it locked.
- */
-void
-cd9660_ihashins(ip)
- struct iso_node *ip;
-{
- struct proc *p = curproc; /* XXX */
- struct iso_node **ipp, *iq;
-
- simple_lock(&cd9660_ihash_slock);
- ipp = &isohashtbl[INOHASH(ip->i_dev, ip->i_number)];
- if ((iq = *ipp) != NULL)
- iq->i_prev = &ip->i_next;
- ip->i_next = iq;
- ip->i_prev = ipp;
- *ipp = ip;
- simple_unlock(&cd9660_ihash_slock);
-
- lockmgr(&ip->i_lock, LK_EXCLUSIVE, (struct simplelock *)0, p);
-}
-
-/*
- * Remove the inode from the hash table.
- */
-static void
-cd9660_ihashrem(ip)
- register struct iso_node *ip;
-{
- register struct iso_node *iq;
-
- simple_lock(&cd9660_ihash_slock);
- if ((iq = ip->i_next) != NULL)
- iq->i_prev = ip->i_prev;
- *ip->i_prev = iq;
-#ifdef DIAGNOSTIC
- ip->i_next = NULL;
- ip->i_prev = NULL;
-#endif
- simple_unlock(&cd9660_ihash_slock);
-}
-
-/*
- * Last reference to an inode, write the inode out and if necessary,
- * truncate and deallocate the file.
- */
-int
-cd9660_inactive(ap)
- struct vop_inactive_args /* {
- struct vnode *a_vp;
- struct proc *a_p;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
- struct proc *p = ap->a_p;
- register struct iso_node *ip = VTOI(vp);
- int error = 0;
-
- if (prtactive && vp->v_usecount != 0)
- vprint("cd9660_inactive: pushing active", vp);
-
- ip->i_flag = 0;
- VOP_UNLOCK(vp, 0, p);
- /*
- * If we are done with the inode, reclaim it
- * so that it can be reused immediately.
- */
- if (ip->inode.iso_mode == 0)
- vrecycle(vp, (struct simplelock *)0, p);
- return error;
-}
-
-/*
- * Reclaim an inode so that it can be used for other purposes.
- */
-int
-cd9660_reclaim(ap)
- struct vop_reclaim_args /* {
- struct vnode *a_vp;
- struct proc *a_p;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
- register struct iso_node *ip = VTOI(vp);
-
- if (prtactive && vp->v_usecount != 0)
- vprint("cd9660_reclaim: pushing active", vp);
- /*
- * Remove the inode from its hash chain.
- */
- cd9660_ihashrem(ip);
- /*
- * Purge old data structures associated with the inode.
- */
- cache_purge(vp);
- if (ip->i_devvp) {
- vrele(ip->i_devvp);
- ip->i_devvp = 0;
- }
- FREE(vp->v_data, M_ISOFSNODE);
- vp->v_data = NULL;
- return (0);
-}
-
-/*
- * File attributes
- */
-void
-cd9660_defattr(isodir, inop, bp, ftype)
- struct iso_directory_record *isodir;
- struct iso_node *inop;
- struct buf *bp;
- enum ISO_FTYPE ftype;
-{
- struct buf *bp2 = NULL;
- struct iso_mnt *imp;
- struct iso_extended_attributes *ap = NULL;
- int off;
-
- /* high sierra does not have timezone data, flag is one byte ahead */
- if (isonum_711(ftype == ISO_FTYPE_HIGH_SIERRA?
- &isodir->date[6]: isodir->flags)&2) {
- inop->inode.iso_mode = S_IFDIR;
- /*
- * If we return 2, fts() will assume there are no subdirectories
- * (just links for the path and .), so instead we return 1.
- */
- inop->inode.iso_links = 1;
- } else {
- inop->inode.iso_mode = S_IFREG;
- inop->inode.iso_links = 1;
- }
- if (!bp
- && ((imp = inop->i_mnt)->im_flags & ISOFSMNT_EXTATT)
- && (off = isonum_711(isodir->ext_attr_length))) {
- cd9660_blkatoff(ITOV(inop), (off_t)-(off << imp->im_bshift), NULL,
- &bp2);
- bp = bp2;
- }
- if (bp) {
- ap = (struct iso_extended_attributes *)bp->b_data;
-
- if (isonum_711(ap->version) == 1) {
- if (!(ap->perm[0]&0x40))
- inop->inode.iso_mode |= VEXEC >> 6;
- if (!(ap->perm[0]&0x10))
- inop->inode.iso_mode |= VREAD >> 6;
- if (!(ap->perm[0]&4))
- inop->inode.iso_mode |= VEXEC >> 3;
- if (!(ap->perm[0]&1))
- inop->inode.iso_mode |= VREAD >> 3;
- if (!(ap->perm[1]&0x40))
- inop->inode.iso_mode |= VEXEC;
- if (!(ap->perm[1]&0x10))
- inop->inode.iso_mode |= VREAD;
- inop->inode.iso_uid = isonum_723(ap->owner); /* what about 0? */
- inop->inode.iso_gid = isonum_723(ap->group); /* what about 0? */
- } else
- ap = NULL;
- }
- if (!ap) {
- inop->inode.iso_mode |= VREAD|VEXEC|(VREAD|VEXEC)>>3|(VREAD|VEXEC)>>6;
- inop->inode.iso_uid = (uid_t)0;
- inop->inode.iso_gid = (gid_t)0;
- }
- if (bp2)
- brelse(bp2);
-}
-
-/*
- * Time stamps
- */
-void
-cd9660_deftstamp(isodir,inop,bp,ftype)
- struct iso_directory_record *isodir;
- struct iso_node *inop;
- struct buf *bp;
- enum ISO_FTYPE ftype;
-{
- struct buf *bp2 = NULL;
- struct iso_mnt *imp;
- struct iso_extended_attributes *ap = NULL;
- int off;
-
- if (!bp
- && ((imp = inop->i_mnt)->im_flags & ISOFSMNT_EXTATT)
- && (off = isonum_711(isodir->ext_attr_length))) {
- cd9660_blkatoff(ITOV(inop), (off_t)-(off << imp->im_bshift), NULL,
- &bp2);
- bp = bp2;
- }
- if (bp) {
- ap = (struct iso_extended_attributes *)bp->b_data;
-
- if (ftype != ISO_FTYPE_HIGH_SIERRA
- && isonum_711(ap->version) == 1) {
- if (!cd9660_tstamp_conv17(ap->ftime,&inop->inode.iso_atime))
- cd9660_tstamp_conv17(ap->ctime,&inop->inode.iso_atime);
- if (!cd9660_tstamp_conv17(ap->ctime,&inop->inode.iso_ctime))
- inop->inode.iso_ctime = inop->inode.iso_atime;
- if (!cd9660_tstamp_conv17(ap->mtime,&inop->inode.iso_mtime))
- inop->inode.iso_mtime = inop->inode.iso_ctime;
- } else
- ap = NULL;
- }
- if (!ap) {
- cd9660_tstamp_conv7(isodir->date,&inop->inode.iso_ctime,ftype);
- inop->inode.iso_atime = inop->inode.iso_ctime;
- inop->inode.iso_mtime = inop->inode.iso_ctime;
- }
- if (bp2)
- brelse(bp2);
-}
-
-int
-cd9660_tstamp_conv7(pi,pu,ftype)
- u_char *pi;
- struct timespec *pu;
- enum ISO_FTYPE ftype;
-{
- int crtime, days;
- int y, m, d, hour, minute, second, tz;
-
- y = pi[0] + 1900;
- m = pi[1];
- d = pi[2];
- hour = pi[3];
- minute = pi[4];
- second = pi[5];
- if(ftype != ISO_FTYPE_HIGH_SIERRA)
- tz = pi[6];
- else
- /* original high sierra misses timezone data */
- tz = 0;
-
- if (y < 1970) {
- pu->tv_sec = 0;
- pu->tv_nsec = 0;
- return 0;
- } else {
-#ifdef ORIGINAL
- /* computes day number relative to Sept. 19th,1989 */
- /* don't even *THINK* about changing formula. It works! */
- days = 367*(y-1980)-7*(y+(m+9)/12)/4-3*((y+(m-9)/7)/100+1)/4+275*m/9+d-100;
-#else
- /*
- * Changed :-) to make it relative to Jan. 1st, 1970
- * and to disambiguate negative division
- */
- days = 367*(y-1960)-7*(y+(m+9)/12)/4-3*((y+(m+9)/12-1)/100+1)/4+275*m/9+d-239;
-#endif
- crtime = ((((days * 24) + hour) * 60 + minute) * 60) + second;
-
- /* timezone offset is unreliable on some disks */
- if (-48 <= tz && tz <= 52)
- crtime -= tz * 15 * 60;
- }
- pu->tv_sec = crtime;
- pu->tv_nsec = 0;
- return 1;
-}
-
-static u_int
-cd9660_chars2ui(begin,len)
- u_char *begin;
- int len;
-{
- u_int rc;
-
- for (rc = 0; --len >= 0;) {
- rc *= 10;
- rc += *begin++ - '0';
- }
- return rc;
-}
-
-int
-cd9660_tstamp_conv17(pi,pu)
- u_char *pi;
- struct timespec *pu;
-{
- u_char buf[7];
-
- /* year:"0001"-"9999" -> -1900 */
- buf[0] = cd9660_chars2ui(pi,4) - 1900;
-
- /* month: " 1"-"12" -> 1 - 12 */
- buf[1] = cd9660_chars2ui(pi + 4,2);
-
- /* day: " 1"-"31" -> 1 - 31 */
- buf[2] = cd9660_chars2ui(pi + 6,2);
-
- /* hour: " 0"-"23" -> 0 - 23 */
- buf[3] = cd9660_chars2ui(pi + 8,2);
-
- /* minute:" 0"-"59" -> 0 - 59 */
- buf[4] = cd9660_chars2ui(pi + 10,2);
-
- /* second:" 0"-"59" -> 0 - 59 */
- buf[5] = cd9660_chars2ui(pi + 12,2);
-
- /* difference of GMT */
- buf[6] = pi[16];
-
- return cd9660_tstamp_conv7(buf, pu, ISO_FTYPE_DEFAULT);
-}
-
-ino_t
-isodirino(isodir, imp)
- struct iso_directory_record *isodir;
- struct iso_mnt *imp;
-{
- ino_t ino;
-
- ino = (isonum_733(isodir->extent) + isonum_711(isodir->ext_attr_length))
- << imp->im_bshift;
- return (ino);
-}
diff --git a/sys/fs/cd9660/cd9660_node.h b/sys/fs/cd9660/cd9660_node.h
deleted file mode 100644
index 9f56150c183f..000000000000
--- a/sys/fs/cd9660/cd9660_node.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/*-
- * Copyright (c) 1994
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley
- * by Pace Willisson (pace@blitz.com). The Rock Ridge Extension
- * Support code is derived from software contributed to Berkeley
- * by Atsushi Murai (amurai@spec.co.jp).
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)cd9660_node.h 8.6 (Berkeley) 5/14/95
- * $FreeBSD$
- */
-
-/*
- * Theoretically, directories can be more than 2Gb in length,
- * however, in practice this seems unlikely. So, we define
- * the type doff_t as a long to keep down the cost of doing
- * lookup on a 32-bit machine. If you are porting to a 64-bit
- * architecture, you should make doff_t the same as off_t.
- */
-#define doff_t long
-
-typedef struct {
- struct timespec iso_atime; /* time of last access */
- struct timespec iso_mtime; /* time of last modification */
- struct timespec iso_ctime; /* time file changed */
- u_short iso_mode; /* files access mode and type */
- uid_t iso_uid; /* owner user id */
- gid_t iso_gid; /* owner group id */
- short iso_links; /* links of file */
- udev_t iso_rdev; /* Major/Minor number for special */
-} ISO_RRIP_INODE;
-
-
-struct iso_node {
- struct lock i_lock; /* node lock > Keep this first< */
- struct iso_node *i_next, **i_prev; /* hash chain */
- struct vnode *i_vnode; /* vnode associated with this inode */
- struct vnode *i_devvp; /* vnode for block I/O */
- u_long i_flag; /* see below */
- dev_t i_dev; /* device where inode resides */
- ino_t i_number; /* the identity of the inode */
- /* we use the actual starting block of the file */
- struct iso_mnt *i_mnt; /* filesystem associated with this inode */
- struct lockf *i_lockf; /* head of byte-level lock list */
- doff_t i_endoff; /* end of useful stuff in directory */
- doff_t i_diroff; /* offset in dir, where we found last entry */
- doff_t i_offset; /* offset of free space in directory */
- ino_t i_ino; /* inode number of found directory */
-
- long iso_extent; /* extent of file */
- long i_size;
- long iso_start; /* actual start of data of file (may be different */
- /* from iso_extent, if file has extended attributes) */
- ISO_RRIP_INODE inode;
-};
-
-#define i_forw i_chain[0]
-#define i_back i_chain[1]
-
-/* flags */
-#define IN_ACCESS 0x0020 /* inode access time to be updated */
-
-#define VTOI(vp) ((struct iso_node *)(vp)->v_data)
-#define ITOV(ip) ((ip)->i_vnode)
-
-#ifdef _KERNEL
-
-#ifdef MALLOC_DECLARE
-MALLOC_DECLARE(M_ISOFSMNT);
-MALLOC_DECLARE(M_ISOFSNODE);
-#endif
-
-struct buf;
-struct vop_bmap_args;
-struct vop_cachedlookup_args;
-struct vop_inactive_args;
-struct vop_reclaim_args;
-
-/*
- * Prototypes for ISOFS vnode operations
- */
-int cd9660_lookup __P((struct vop_cachedlookup_args *));
-int cd9660_inactive __P((struct vop_inactive_args *));
-int cd9660_reclaim __P((struct vop_reclaim_args *));
-int cd9660_bmap __P((struct vop_bmap_args *));
-int cd9660_blkatoff __P((struct vnode *vp, off_t offset, char **res, struct buf **bpp));
-
-void cd9660_defattr __P((struct iso_directory_record *,
- struct iso_node *, struct buf *, enum ISO_FTYPE));
-void cd9660_deftstamp __P((struct iso_directory_record *,
- struct iso_node *, struct buf *, enum ISO_FTYPE));
-struct vnode *cd9660_ihashget __P((dev_t, ino_t));
-void cd9660_ihashins __P((struct iso_node *));
-int cd9660_tstamp_conv7 __P((u_char *, struct timespec *, enum ISO_FTYPE));
-int cd9660_tstamp_conv17 __P((u_char *, struct timespec *));
-
-#endif /* _KERNEL */
diff --git a/sys/fs/cd9660/cd9660_rrip.c b/sys/fs/cd9660/cd9660_rrip.c
deleted file mode 100644
index b4f97a98e112..000000000000
--- a/sys/fs/cd9660/cd9660_rrip.c
+++ /dev/null
@@ -1,726 +0,0 @@
-/*-
- * Copyright (c) 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley
- * by Pace Willisson (pace@blitz.com). The Rock Ridge Extension
- * Support code is derived from software contributed to Berkeley
- * by Atsushi Murai (amurai@spec.co.jp).
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)cd9660_rrip.c 8.6 (Berkeley) 12/5/94
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/buf.h>
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <sys/kernel.h>
-
-#include <isofs/cd9660/iso.h>
-#include <isofs/cd9660/cd9660_node.h>
-#include <isofs/cd9660/cd9660_rrip.h>
-#include <isofs/cd9660/iso_rrip.h>
-
-typedef int rrt_func_t __P((void *, ISO_RRIP_ANALYZE *ana));
-
-typedef struct {
- char type[2];
- rrt_func_t *func;
- void (*func2) __P((struct iso_directory_record *isodir, ISO_RRIP_ANALYZE *ana));
- int result;
-} RRIP_TABLE;
-
-static int cd9660_rrip_altname __P((ISO_RRIP_ALTNAME *p,
- ISO_RRIP_ANALYZE *ana));
-static int cd9660_rrip_attr __P((ISO_RRIP_ATTR *p, ISO_RRIP_ANALYZE *ana));
-static int cd9660_rrip_cont __P((ISO_RRIP_CONT *p, ISO_RRIP_ANALYZE *ana));
-static void cd9660_rrip_defattr __P((struct iso_directory_record *isodir,
- ISO_RRIP_ANALYZE *ana));
-static void cd9660_rrip_defname __P((struct iso_directory_record *isodir,
- ISO_RRIP_ANALYZE *ana));
-static void cd9660_rrip_deftstamp __P((struct iso_directory_record *isodir,
- ISO_RRIP_ANALYZE *ana));
-static int cd9660_rrip_device __P((ISO_RRIP_DEVICE *p,
- ISO_RRIP_ANALYZE *ana));
-static int cd9660_rrip_extref __P((ISO_RRIP_EXTREF *p,
- ISO_RRIP_ANALYZE *ana));
-static int cd9660_rrip_idflag __P((ISO_RRIP_IDFLAG *p,
- ISO_RRIP_ANALYZE *ana));
-static int cd9660_rrip_loop __P((struct iso_directory_record *isodir,
- ISO_RRIP_ANALYZE *ana,
- RRIP_TABLE *table));
-static int cd9660_rrip_pclink __P((ISO_RRIP_CLINK *p,
- ISO_RRIP_ANALYZE *ana));
-static int cd9660_rrip_reldir __P((ISO_RRIP_RELDIR *p,
- ISO_RRIP_ANALYZE *ana));
-static int cd9660_rrip_slink __P((ISO_RRIP_SLINK *p,
- ISO_RRIP_ANALYZE *ana));
-static int cd9660_rrip_stop __P((ISO_SUSP_HEADER *p,
- ISO_RRIP_ANALYZE *ana));
-static int cd9660_rrip_tstamp __P((ISO_RRIP_TSTAMP *p,
- ISO_RRIP_ANALYZE *ana));
-
-/*
- * POSIX file attribute
- */
-static int
-cd9660_rrip_attr(p,ana)
- ISO_RRIP_ATTR *p;
- ISO_RRIP_ANALYZE *ana;
-{
- ana->inop->inode.iso_mode = isonum_733(p->mode);
- ana->inop->inode.iso_uid = isonum_733(p->uid);
- ana->inop->inode.iso_gid = isonum_733(p->gid);
- ana->inop->inode.iso_links = isonum_733(p->links);
- ana->fields &= ~ISO_SUSP_ATTR;
- return ISO_SUSP_ATTR;
-}
-
-static void
-cd9660_rrip_defattr(isodir,ana)
- struct iso_directory_record *isodir;
- ISO_RRIP_ANALYZE *ana;
-{
- /* But this is a required field! */
- printf("RRIP without PX field?\n");
- cd9660_defattr(isodir,ana->inop,NULL,ISO_FTYPE_RRIP);
-}
-
-/*
- * Symbolic Links
- */
-static int
-cd9660_rrip_slink(p,ana)
- ISO_RRIP_SLINK *p;
- ISO_RRIP_ANALYZE *ana;
-{
- register ISO_RRIP_SLINK_COMPONENT *pcomp;
- register ISO_RRIP_SLINK_COMPONENT *pcompe;
- int len, wlen, cont;
- char *outbuf, *inbuf;
-
- pcomp = (ISO_RRIP_SLINK_COMPONENT *)p->component;
- pcompe = (ISO_RRIP_SLINK_COMPONENT *)((char *)p + isonum_711(p->h.length));
- len = *ana->outlen;
- outbuf = ana->outbuf;
- cont = ana->cont;
-
- /*
- * Gathering a Symbolic name from each component with path
- */
- for (;
- pcomp < pcompe;
- pcomp = (ISO_RRIP_SLINK_COMPONENT *)((char *)pcomp + ISO_RRIP_SLSIZ
- + isonum_711(pcomp->clen))) {
-
- if (!cont) {
- if (len < ana->maxlen) {
- len++;
- *outbuf++ = '/';
- }
- }
- cont = 0;
-
- inbuf = "..";
- wlen = 0;
-
- switch (*pcomp->cflag) {
-
- case ISO_SUSP_CFLAG_CURRENT:
- /* Inserting Current */
- wlen = 1;
- break;
-
- case ISO_SUSP_CFLAG_PARENT:
- /* Inserting Parent */
- wlen = 2;
- break;
-
- case ISO_SUSP_CFLAG_ROOT:
- /* Inserting slash for ROOT */
- /* start over from beginning(?) */
- outbuf -= len;
- len = 0;
- break;
-
- case ISO_SUSP_CFLAG_VOLROOT:
- /* Inserting a mount point i.e. "/cdrom" */
- /* same as above */
- outbuf -= len;
- len = 0;
- inbuf = ana->imp->im_mountp->mnt_stat.f_mntonname;
- wlen = strlen(inbuf);
- break;
-
- case ISO_SUSP_CFLAG_HOST:
- /* Inserting hostname i.e. "kurt.tools.de" */
- inbuf = hostname;
- wlen = strlen(hostname);
- break;
-
- case ISO_SUSP_CFLAG_CONTINUE:
- cont = 1;
- /* fall thru */
- case 0:
- /* Inserting component */
- wlen = isonum_711(pcomp->clen);
- inbuf = pcomp->name;
- break;
- default:
- printf("RRIP with incorrect flags?");
- wlen = ana->maxlen + 1;
- break;
- }
-
- if (len + wlen > ana->maxlen) {
- /* indicate error to caller */
- ana->cont = 1;
- ana->fields = 0;
- ana->outbuf -= *ana->outlen;
- *ana->outlen = 0;
- return 0;
- }
-
- bcopy(inbuf,outbuf,wlen);
- outbuf += wlen;
- len += wlen;
-
- }
- ana->outbuf = outbuf;
- *ana->outlen = len;
- ana->cont = cont;
-
- if (!isonum_711(p->flags)) {
- ana->fields &= ~ISO_SUSP_SLINK;
- return ISO_SUSP_SLINK;
- }
- return 0;
-}
-
-/*
- * Alternate name
- */
-static int
-cd9660_rrip_altname(p,ana)
- ISO_RRIP_ALTNAME *p;
- ISO_RRIP_ANALYZE *ana;
-{
- char *inbuf;
- int wlen;
- int cont;
-
- inbuf = "..";
- wlen = 0;
- cont = 0;
-
- switch (*p->flags) {
- case ISO_SUSP_CFLAG_CURRENT:
- /* Inserting Current */
- wlen = 1;
- break;
-
- case ISO_SUSP_CFLAG_PARENT:
- /* Inserting Parent */
- wlen = 2;
- break;
-
- case ISO_SUSP_CFLAG_HOST:
- /* Inserting hostname i.e. "kurt.tools.de" */
- inbuf = hostname;
- wlen = strlen(hostname);
- break;
-
- case ISO_SUSP_CFLAG_CONTINUE:
- cont = 1;
- /* fall thru */
- case 0:
- /* Inserting component */
- wlen = isonum_711(p->h.length) - 5;
- inbuf = (char *)p + 5;
- break;
-
- default:
- printf("RRIP with incorrect NM flags?\n");
- wlen = ana->maxlen + 1;
- break;
- }
-
- if ((*ana->outlen += wlen) > ana->maxlen) {
- /* treat as no name field */
- ana->fields &= ~ISO_SUSP_ALTNAME;
- ana->outbuf -= *ana->outlen - wlen;
- *ana->outlen = 0;
- return 0;
- }
-
- bcopy(inbuf,ana->outbuf,wlen);
- ana->outbuf += wlen;
-
- if (!cont) {
- ana->fields &= ~ISO_SUSP_ALTNAME;
- return ISO_SUSP_ALTNAME;
- }
- return 0;
-}
-
-static void
-cd9660_rrip_defname(isodir,ana)
- struct iso_directory_record *isodir;
- ISO_RRIP_ANALYZE *ana;
-{
- isofntrans(isodir->name,isonum_711(isodir->name_len),
- ana->outbuf,ana->outlen,
- 1,isonum_711(isodir->flags)&4, ana->imp->joliet_level);
- switch (*ana->outbuf) {
- default:
- break;
- case 1:
- *ana->outlen = 2;
- /* FALL THROUGH */
- case 0:
- /* outlen is 1 already */
- strcpy(ana->outbuf,"..");
- break;
- }
-}
-
-/*
- * Parent or Child Link
- */
-static int
-cd9660_rrip_pclink(p,ana)
- ISO_RRIP_CLINK *p;
- ISO_RRIP_ANALYZE *ana;
-{
- *ana->inump = isonum_733(p->dir_loc) << ana->imp->im_bshift;
- ana->fields &= ~(ISO_SUSP_CLINK|ISO_SUSP_PLINK);
- return *p->h.type == 'C' ? ISO_SUSP_CLINK : ISO_SUSP_PLINK;
-}
-
-/*
- * Relocated directory
- */
-static int
-cd9660_rrip_reldir(p,ana)
- ISO_RRIP_RELDIR *p;
- ISO_RRIP_ANALYZE *ana;
-{
- /* special hack to make caller aware of RE field */
- *ana->outlen = 0;
- ana->fields = 0;
- return ISO_SUSP_RELDIR|ISO_SUSP_ALTNAME|ISO_SUSP_CLINK|ISO_SUSP_PLINK;
-}
-
-static int
-cd9660_rrip_tstamp(p,ana)
- ISO_RRIP_TSTAMP *p;
- ISO_RRIP_ANALYZE *ana;
-{
- u_char *ptime;
-
- ptime = p->time;
-
- /* Check a format of time stamp (7bytes/17bytes) */
- if (!(*p->flags&ISO_SUSP_TSTAMP_FORM17)) {
- if (*p->flags&ISO_SUSP_TSTAMP_CREAT)
- ptime += 7;
-
- if (*p->flags&ISO_SUSP_TSTAMP_MODIFY) {
- cd9660_tstamp_conv7(ptime,&ana->inop->inode.iso_mtime,
- ISO_FTYPE_RRIP);
- ptime += 7;
- } else
- bzero(&ana->inop->inode.iso_mtime,sizeof(struct timespec));
-
- if (*p->flags&ISO_SUSP_TSTAMP_ACCESS) {
- cd9660_tstamp_conv7(ptime,&ana->inop->inode.iso_atime,
- ISO_FTYPE_RRIP);
- ptime += 7;
- } else
- ana->inop->inode.iso_atime = ana->inop->inode.iso_mtime;
-
- if (*p->flags&ISO_SUSP_TSTAMP_ATTR)
- cd9660_tstamp_conv7(ptime,&ana->inop->inode.iso_ctime,
- ISO_FTYPE_RRIP);
- else
- ana->inop->inode.iso_ctime = ana->inop->inode.iso_mtime;
-
- } else {
- if (*p->flags&ISO_SUSP_TSTAMP_CREAT)
- ptime += 17;
-
- if (*p->flags&ISO_SUSP_TSTAMP_MODIFY) {
- cd9660_tstamp_conv17(ptime,&ana->inop->inode.iso_mtime);
- ptime += 17;
- } else
- bzero(&ana->inop->inode.iso_mtime,sizeof(struct timespec));
-
- if (*p->flags&ISO_SUSP_TSTAMP_ACCESS) {
- cd9660_tstamp_conv17(ptime,&ana->inop->inode.iso_atime);
- ptime += 17;
- } else
- ana->inop->inode.iso_atime = ana->inop->inode.iso_mtime;
-
- if (*p->flags&ISO_SUSP_TSTAMP_ATTR)
- cd9660_tstamp_conv17(ptime,&ana->inop->inode.iso_ctime);
- else
- ana->inop->inode.iso_ctime = ana->inop->inode.iso_mtime;
-
- }
- ana->fields &= ~ISO_SUSP_TSTAMP;
- return ISO_SUSP_TSTAMP;
-}
-
-static void
-cd9660_rrip_deftstamp(isodir,ana)
- struct iso_directory_record *isodir;
- ISO_RRIP_ANALYZE *ana;
-{
- cd9660_deftstamp(isodir,ana->inop,NULL,ISO_FTYPE_RRIP);
-}
-
-/*
- * POSIX device modes
- */
-static int
-cd9660_rrip_device(p,ana)
- ISO_RRIP_DEVICE *p;
- ISO_RRIP_ANALYZE *ana;
-{
- u_int high, low;
-
- high = isonum_733(p->dev_t_high);
- low = isonum_733(p->dev_t_low);
-
- if (high == 0)
- ana->inop->inode.iso_rdev = makeudev(umajor(low), uminor(low));
- else
- ana->inop->inode.iso_rdev = makeudev(high, uminor(low));
- ana->fields &= ~ISO_SUSP_DEVICE;
- return ISO_SUSP_DEVICE;
-}
-
-/*
- * Flag indicating
- */
-static int
-cd9660_rrip_idflag(p,ana)
- ISO_RRIP_IDFLAG *p;
- ISO_RRIP_ANALYZE *ana;
-{
- ana->fields &= isonum_711(p->flags)|~0xff; /* don't touch high bits */
- /* special handling of RE field */
- if (ana->fields&ISO_SUSP_RELDIR)
- return cd9660_rrip_reldir(/* XXX */ (ISO_RRIP_RELDIR *)p,ana);
-
- return ISO_SUSP_IDFLAG;
-}
-
-/*
- * Continuation pointer
- */
-static int
-cd9660_rrip_cont(p,ana)
- ISO_RRIP_CONT *p;
- ISO_RRIP_ANALYZE *ana;
-{
- ana->iso_ce_blk = isonum_733(p->location);
- ana->iso_ce_off = isonum_733(p->offset);
- ana->iso_ce_len = isonum_733(p->length);
- return ISO_SUSP_CONT;
-}
-
-/*
- * System Use end
- */
-static int
-cd9660_rrip_stop(p,ana)
- ISO_SUSP_HEADER *p;
- ISO_RRIP_ANALYZE *ana;
-{
- return ISO_SUSP_STOP;
-}
-
-/*
- * Extension reference
- */
-static int
-cd9660_rrip_extref(p,ana)
- ISO_RRIP_EXTREF *p;
- ISO_RRIP_ANALYZE *ana;
-{
- if (isonum_711(p->len_id) != 10
- || bcmp((char *)p + 8,"RRIP_1991A",10)
- || isonum_711(p->version) != 1)
- return 0;
- ana->fields &= ~ISO_SUSP_EXTREF;
- return ISO_SUSP_EXTREF;
-}
-
-static int
-cd9660_rrip_loop(isodir,ana,table)
- struct iso_directory_record *isodir;
- ISO_RRIP_ANALYZE *ana;
- RRIP_TABLE *table;
-{
- register RRIP_TABLE *ptable;
- register ISO_SUSP_HEADER *phead;
- register ISO_SUSP_HEADER *pend;
- struct buf *bp = NULL;
- char *pwhead;
- u_char c;
- int result;
-
- /*
- * Note: If name length is odd,
- * it will be padding 1 byte after the name
- */
- pwhead = isodir->name + isonum_711(isodir->name_len);
- if (!(isonum_711(isodir->name_len)&1))
- pwhead++;
- isochar(isodir->name, pwhead, ana->imp->joliet_level, &c);
-
- /* If it's not the '.' entry of the root dir obey SP field */
- if (c != 0 || isonum_733(isodir->extent) != ana->imp->root_extent)
- pwhead += ana->imp->rr_skip;
- else
- pwhead += ana->imp->rr_skip0;
-
- phead = (ISO_SUSP_HEADER *)pwhead;
- pend = (ISO_SUSP_HEADER *)((char *)isodir + isonum_711(isodir->length));
-
- result = 0;
- while (1) {
- ana->iso_ce_len = 0;
- /*
- * Note: "pend" should be more than one SUSP header
- */
- while (pend >= phead + 1) {
- if (isonum_711(phead->version) == 1) {
- for (ptable = table; ptable->func; ptable++) {
- if (*phead->type == *ptable->type
- && phead->type[1] == ptable->type[1]) {
- result |= ptable->func(phead,ana);
- break;
- }
- }
- if (!ana->fields)
- break;
- }
- if (result&ISO_SUSP_STOP) {
- result &= ~ISO_SUSP_STOP;
- break;
- }
- /* plausibility check */
- if (isonum_711(phead->length) < sizeof(*phead))
- break;
- /*
- * move to next SUSP
- * Hopefully this works with newer versions, too
- */
- phead = (ISO_SUSP_HEADER *)((char *)phead + isonum_711(phead->length));
- }
-
- if (ana->fields && ana->iso_ce_len) {
- if (ana->iso_ce_blk >= ana->imp->volume_space_size
- || ana->iso_ce_off + ana->iso_ce_len > ana->imp->logical_block_size
- || bread(ana->imp->im_devvp,
- ana->iso_ce_blk <<
- (ana->imp->im_bshift - DEV_BSHIFT),
- ana->imp->logical_block_size, NOCRED, &bp))
- /* what to do now? */
- break;
- phead = (ISO_SUSP_HEADER *)(bp->b_data + ana->iso_ce_off);
- pend = (ISO_SUSP_HEADER *) ((char *)phead + ana->iso_ce_len);
- } else
- break;
- }
- if (bp)
- brelse(bp);
- /*
- * If we don't find the Basic SUSP stuffs, just set default value
- * (attribute/time stamp)
- */
- for (ptable = table; ptable->func2; ptable++)
- if (!(ptable->result&result))
- ptable->func2(isodir,ana);
-
- return result;
-}
-
-/*
- * Get Attributes.
- */
-/*
- * XXX the casts are bogus but will do for now.
- */
-#define BC (rrt_func_t *)
-static RRIP_TABLE rrip_table_analyze[] = {
- { "PX", BC cd9660_rrip_attr, cd9660_rrip_defattr, ISO_SUSP_ATTR },
- { "TF", BC cd9660_rrip_tstamp, cd9660_rrip_deftstamp, ISO_SUSP_TSTAMP },
- { "PN", BC cd9660_rrip_device, 0, ISO_SUSP_DEVICE },
- { "RR", BC cd9660_rrip_idflag, 0, ISO_SUSP_IDFLAG },
- { "CE", BC cd9660_rrip_cont, 0, ISO_SUSP_CONT },
- { "ST", BC cd9660_rrip_stop, 0, ISO_SUSP_STOP },
- { "", 0, 0, 0 }
-};
-
-int
-cd9660_rrip_analyze(isodir,inop,imp)
- struct iso_directory_record *isodir;
- struct iso_node *inop;
- struct iso_mnt *imp;
-{
- ISO_RRIP_ANALYZE analyze;
-
- analyze.inop = inop;
- analyze.imp = imp;
- analyze.fields = ISO_SUSP_ATTR|ISO_SUSP_TSTAMP|ISO_SUSP_DEVICE;
-
- return cd9660_rrip_loop(isodir,&analyze,rrip_table_analyze);
-}
-
-/*
- * Get Alternate Name.
- */
-static RRIP_TABLE rrip_table_getname[] = {
- { "NM", BC cd9660_rrip_altname, cd9660_rrip_defname, ISO_SUSP_ALTNAME },
- { "CL", BC cd9660_rrip_pclink, 0, ISO_SUSP_CLINK|ISO_SUSP_PLINK },
- { "PL", BC cd9660_rrip_pclink, 0, ISO_SUSP_CLINK|ISO_SUSP_PLINK },
- { "RE", BC cd9660_rrip_reldir, 0, ISO_SUSP_RELDIR },
- { "RR", BC cd9660_rrip_idflag, 0, ISO_SUSP_IDFLAG },
- { "CE", BC cd9660_rrip_cont, 0, ISO_SUSP_CONT },
- { "ST", BC cd9660_rrip_stop, 0, ISO_SUSP_STOP },
- { "", 0, 0, 0 }
-};
-
-int
-cd9660_rrip_getname(isodir,outbuf,outlen,inump,imp)
- struct iso_directory_record *isodir;
- char *outbuf;
- u_short *outlen;
- ino_t *inump;
- struct iso_mnt *imp;
-{
- ISO_RRIP_ANALYZE analyze;
- RRIP_TABLE *tab;
- u_char c;
-
- analyze.outbuf = outbuf;
- analyze.outlen = outlen;
- analyze.maxlen = NAME_MAX;
- analyze.inump = inump;
- analyze.imp = imp;
- analyze.fields = ISO_SUSP_ALTNAME|ISO_SUSP_RELDIR|ISO_SUSP_CLINK|ISO_SUSP_PLINK;
- *outlen = 0;
-
- isochar(isodir->name, isodir->name + isonum_711(isodir->name_len),
- imp->joliet_level, &c);
- tab = rrip_table_getname;
- if (c == 0 || c == 1) {
- cd9660_rrip_defname(isodir,&analyze);
-
- analyze.fields &= ~ISO_SUSP_ALTNAME;
- tab++;
- }
-
- return cd9660_rrip_loop(isodir,&analyze,tab);
-}
-
-/*
- * Get Symbolic Link.
- */
-static RRIP_TABLE rrip_table_getsymname[] = {
- { "SL", BC cd9660_rrip_slink, 0, ISO_SUSP_SLINK },
- { "RR", BC cd9660_rrip_idflag, 0, ISO_SUSP_IDFLAG },
- { "CE", BC cd9660_rrip_cont, 0, ISO_SUSP_CONT },
- { "ST", BC cd9660_rrip_stop, 0, ISO_SUSP_STOP },
- { "", 0, 0, 0 }
-};
-
-int
-cd9660_rrip_getsymname(isodir,outbuf,outlen,imp)
- struct iso_directory_record *isodir;
- char *outbuf;
- u_short *outlen;
- struct iso_mnt *imp;
-{
- ISO_RRIP_ANALYZE analyze;
-
- analyze.outbuf = outbuf;
- analyze.outlen = outlen;
- *outlen = 0;
- analyze.maxlen = MAXPATHLEN;
- analyze.cont = 1; /* don't start with a slash */
- analyze.imp = imp;
- analyze.fields = ISO_SUSP_SLINK;
-
- return (cd9660_rrip_loop(isodir,&analyze,rrip_table_getsymname)&ISO_SUSP_SLINK);
-}
-
-static RRIP_TABLE rrip_table_extref[] = {
- { "ER", BC cd9660_rrip_extref, 0, ISO_SUSP_EXTREF },
- { "CE", BC cd9660_rrip_cont, 0, ISO_SUSP_CONT },
- { "ST", BC cd9660_rrip_stop, 0, ISO_SUSP_STOP },
- { "", 0, 0, 0 }
-};
-
-/*
- * Check for Rock Ridge Extension and return offset of its fields.
- * Note: We insist on the ER field.
- */
-int
-cd9660_rrip_offset(isodir,imp)
- struct iso_directory_record *isodir;
- struct iso_mnt *imp;
-{
- ISO_RRIP_OFFSET *p;
- ISO_RRIP_ANALYZE analyze;
-
- imp->rr_skip0 = 0;
- p = (ISO_RRIP_OFFSET *)(isodir->name + 1);
- if (bcmp(p,"SP\7\1\276\357",6)) {
- /* Maybe, it's a CDROM XA disc? */
- imp->rr_skip0 = 15;
- p = (ISO_RRIP_OFFSET *)((char *)p + 15);
- if (bcmp(p,"SP\7\1\276\357",6))
- return -1;
- }
-
- analyze.imp = imp;
- analyze.fields = ISO_SUSP_EXTREF;
- if (!(cd9660_rrip_loop(isodir,&analyze,rrip_table_extref)&ISO_SUSP_EXTREF))
- return -1;
-
- return isonum_711(p->skip);
-}
diff --git a/sys/fs/cd9660/cd9660_rrip.h b/sys/fs/cd9660/cd9660_rrip.h
deleted file mode 100644
index 5008abf2a0ac..000000000000
--- a/sys/fs/cd9660/cd9660_rrip.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/*-
- * Copyright (c) 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley
- * by Pace Willisson (pace@blitz.com). The Rock Ridge Extension
- * Support code is derived from software contributed to Berkeley
- * by Atsushi Murai (amurai@spec.co.jp).
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)cd9660_rrip.h 8.2 (Berkeley) 12/5/94
- * $FreeBSD$
- */
-
-typedef struct {
- char type [ISODCL ( 0, 1)];
- u_char length [ISODCL ( 2, 2)]; /* 711 */
- u_char version [ISODCL ( 3, 3)];
-} ISO_SUSP_HEADER;
-
-typedef struct {
- ISO_SUSP_HEADER h;
- char mode [ISODCL ( 4, 11)]; /* 733 */
- char links [ISODCL ( 12, 19)]; /* 733 */
- char uid [ISODCL ( 20, 27)]; /* 733 */
- char gid [ISODCL ( 28, 35)]; /* 733 */
-} ISO_RRIP_ATTR;
-
-typedef struct {
- ISO_SUSP_HEADER h;
- char dev_t_high [ISODCL ( 4, 11)]; /* 733 */
- char dev_t_low [ISODCL ( 12, 19)]; /* 733 */
-} ISO_RRIP_DEVICE;
-
-#define ISO_SUSP_CFLAG_CONTINUE 0x01
-#define ISO_SUSP_CFLAG_CURRENT 0x02
-#define ISO_SUSP_CFLAG_PARENT 0x04
-#define ISO_SUSP_CFLAG_ROOT 0x08
-#define ISO_SUSP_CFLAG_VOLROOT 0x10
-#define ISO_SUSP_CFLAG_HOST 0x20
-
-typedef struct {
- u_char cflag [ISODCL ( 1, 1)];
- u_char clen [ISODCL ( 2, 2)];
- u_char name [1]; /* XXX */
-} ISO_RRIP_SLINK_COMPONENT;
-#define ISO_RRIP_SLSIZ 2
-
-typedef struct {
- ISO_SUSP_HEADER h;
- u_char flags [ISODCL ( 4, 4)];
- u_char component [ISODCL ( 5, 5)];
-} ISO_RRIP_SLINK;
-
-typedef struct {
- ISO_SUSP_HEADER h;
- char flags [ISODCL ( 4, 4)];
-} ISO_RRIP_ALTNAME;
-
-typedef struct {
- ISO_SUSP_HEADER h;
- char dir_loc [ISODCL ( 4, 11)]; /* 733 */
-} ISO_RRIP_CLINK;
-
-typedef struct {
- ISO_SUSP_HEADER h;
- char dir_loc [ISODCL ( 4, 11)]; /* 733 */
-} ISO_RRIP_PLINK;
-
-typedef struct {
- ISO_SUSP_HEADER h;
-} ISO_RRIP_RELDIR;
-
-#define ISO_SUSP_TSTAMP_FORM17 0x80
-#define ISO_SUSP_TSTAMP_FORM7 0x00
-#define ISO_SUSP_TSTAMP_CREAT 0x01
-#define ISO_SUSP_TSTAMP_MODIFY 0x02
-#define ISO_SUSP_TSTAMP_ACCESS 0x04
-#define ISO_SUSP_TSTAMP_ATTR 0x08
-#define ISO_SUSP_TSTAMP_BACKUP 0x10
-#define ISO_SUSP_TSTAMP_EXPIRE 0x20
-#define ISO_SUSP_TSTAMP_EFFECT 0x40
-
-typedef struct {
- ISO_SUSP_HEADER h;
- u_char flags [ISODCL ( 4, 4)];
- u_char time [ISODCL ( 5, 5)];
-} ISO_RRIP_TSTAMP;
-
-typedef struct {
- ISO_SUSP_HEADER h;
- u_char flags [ISODCL ( 4, 4)];
-} ISO_RRIP_IDFLAG;
-
-typedef struct {
- ISO_SUSP_HEADER h;
- char len_id [ISODCL ( 4, 4)];
- char len_des [ISODCL ( 5, 5)];
- char len_src [ISODCL ( 6, 6)];
- char version [ISODCL ( 7, 7)];
-} ISO_RRIP_EXTREF;
-
-typedef struct {
- ISO_SUSP_HEADER h;
- char check [ISODCL ( 4, 5)];
- char skip [ISODCL ( 6, 6)];
-} ISO_RRIP_OFFSET;
-
-typedef struct {
- ISO_SUSP_HEADER h;
- char location [ISODCL ( 4, 11)];
- char offset [ISODCL ( 12, 19)];
- char length [ISODCL ( 20, 27)];
-} ISO_RRIP_CONT;
diff --git a/sys/fs/cd9660/cd9660_util.c b/sys/fs/cd9660/cd9660_util.c
deleted file mode 100644
index 2a11dc2f6361..000000000000
--- a/sys/fs/cd9660/cd9660_util.c
+++ /dev/null
@@ -1,175 +0,0 @@
-/*-
- * Copyright (c) 1994
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley
- * by Pace Willisson (pace@blitz.com). The Rock Ridge Extension
- * Support code is derived from software contributed to Berkeley
- * by Atsushi Murai (amurai@spec.co.jp). Joliet support was added by
- * Joachim Kuebart (joki@kuebart.stuttgart.netsurf.de).
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)cd9660_util.c 8.3 (Berkeley) 12/5/94
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/mount.h>
-#include <sys/vnode.h>
-
-#include <isofs/cd9660/iso.h>
-
-/*
- * Get one character out of an iso filename
- * Obey joliet_level
- * Return number of bytes consumed
- */
-int
-isochar(isofn, isoend, joliet_level, c)
- u_char *isofn;
- u_char *isoend;
- int joliet_level;
- u_char *c;
-{
- *c = *isofn++;
- if (joliet_level == 0 || isofn == isoend)
- /* (00) and (01) are one byte in Joliet, too */
- return 1;
-
- /* No Unicode support yet :-( */
- switch (*c) {
- default:
- *c = '?';
- break;
- case '\0':
- *c = *isofn;
- break;
- }
- return 2;
-}
-
-/*
- * translate and compare a filename
- * returns (fn - isofn)
- * Note: Version number plus ';' may be omitted.
- */
-int
-isofncmp(fn, fnlen, isofn, isolen, joliet_level)
- u_char *fn;
- int fnlen;
- u_char *isofn;
- int isolen;
- int joliet_level;
-{
- int i, j;
- u_char c, *fnend = fn + fnlen, *isoend = isofn + isolen;
-
- for (; fn != fnend; fn++) {
- if (isofn == isoend)
- return *fn;
- isofn += isochar(isofn, isoend, joliet_level, &c);
- if (c == ';') {
- if (*fn++ != ';')
- return fn[-1];
- for (i = 0; fn != fnend; i = i * 10 + *fn++ - '0') {
- if (*fn < '0' || *fn > '9') {
- return -1;
- }
- }
- for (j = 0; isofn != isoend; j = j * 10 + c - '0')
- isofn += isochar(isofn, isoend,
- joliet_level, &c);
- return i - j;
- }
- if (c != *fn) {
- if (c >= 'A' && c <= 'Z') {
- if (c + ('a' - 'A') != *fn) {
- if (*fn >= 'a' && *fn <= 'z')
- return *fn - ('a' - 'A') - c;
- else
- return *fn - c;
- }
- } else
- return *fn - c;
- }
- }
- if (isofn != isoend) {
- isofn += isochar(isofn, isoend, joliet_level, &c);
- switch (c) {
- default:
- return -c;
- case '.':
- if (isofn != isoend) {
- isochar(isofn, isoend, joliet_level, &c);
- if (c == ';')
- return 0;
- }
- return -1;
- case ';':
- return 0;
- }
- }
- return 0;
-}
-
-/*
- * translate a filename of length > 0
- */
-void
-isofntrans(infn, infnlen, outfn, outfnlen, original, assoc, joliet_level)
- u_char *infn;
- int infnlen;
- u_char *outfn;
- u_short *outfnlen;
- int original;
- int assoc;
- int joliet_level;
-{
- int fnidx = 0;
- u_char c, d = '\0', *infnend = infn + infnlen;
-
- if (assoc) {
- *outfn++ = ASSOCCHAR;
- fnidx++;
- }
- for (; infn != infnend; fnidx++) {
- infn += isochar(infn, infnend, joliet_level, &c);
-
- if (!original && !joliet_level && c >= 'A' && c <= 'Z')
- *outfn++ = c + ('a' - 'A');
- else if (!original && c == ';') {
- fnidx -= (d == '.');
- break;
- } else
- *outfn++ = c;
- d = c;
- }
- *outfnlen = fnidx;
-}
diff --git a/sys/fs/cd9660/cd9660_vfsops.c b/sys/fs/cd9660/cd9660_vfsops.c
deleted file mode 100644
index 955cc2f4019d..000000000000
--- a/sys/fs/cd9660/cd9660_vfsops.c
+++ /dev/null
@@ -1,898 +0,0 @@
-/*-
- * Copyright (c) 1994
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley
- * by Pace Willisson (pace@blitz.com). The Rock Ridge Extension
- * Support code is derived from software contributed to Berkeley
- * by Atsushi Murai (amurai@spec.co.jp).
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)cd9660_vfsops.c 8.18 (Berkeley) 5/22/95
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/namei.h>
-#include <sys/proc.h>
-#include <sys/kernel.h>
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <sys/buf.h>
-#include <sys/cdio.h>
-#include <sys/conf.h>
-#include <sys/fcntl.h>
-#include <sys/malloc.h>
-#include <sys/stat.h>
-#include <sys/syslog.h>
-
-#include <vm/vm_zone.h>
-
-#include <isofs/cd9660/iso.h>
-#include <isofs/cd9660/iso_rrip.h>
-#include <isofs/cd9660/cd9660_node.h>
-#include <isofs/cd9660/cd9660_mount.h>
-
-MALLOC_DEFINE(M_ISOFSMNT, "ISOFS mount", "ISOFS mount structure");
-MALLOC_DEFINE(M_ISOFSNODE, "ISOFS node", "ISOFS vnode private part");
-
-static int cd9660_mount __P((struct mount *,
- char *, caddr_t, struct nameidata *, struct proc *));
-static int cd9660_unmount __P((struct mount *, int, struct proc *));
-static int cd9660_root __P((struct mount *, struct vnode **));
-static int cd9660_statfs __P((struct mount *, struct statfs *, struct proc *));
-static int cd9660_vget __P((struct mount *, ino_t, struct vnode **));
-static int cd9660_fhtovp __P((struct mount *, struct fid *, struct vnode **));
-static int cd9660_checkexp __P((struct mount *, struct sockaddr *,
- int *, struct ucred **));
-static int cd9660_vptofh __P((struct vnode *, struct fid *));
-
-static struct vfsops cd9660_vfsops = {
- cd9660_mount,
- vfs_stdstart,
- cd9660_unmount,
- cd9660_root,
- vfs_stdquotactl,
- cd9660_statfs,
- vfs_stdsync,
- cd9660_vget,
- cd9660_fhtovp,
- cd9660_checkexp,
- cd9660_vptofh,
- cd9660_init,
- vfs_stduninit,
- vfs_stdextattrctl,
-};
-VFS_SET(cd9660_vfsops, cd9660, VFCF_READONLY);
-
-
-/*
- * Called by vfs_mountroot when iso is going to be mounted as root.
- */
-
-static int iso_get_ssector __P((dev_t dev, struct proc *p));
-static int iso_mountfs __P((struct vnode *devvp, struct mount *mp,
- struct proc *p, struct iso_args *argp));
-
-/*
- * Try to find the start of the last data track on this CD-ROM. This
- * is used to mount the last session of a multi-session CD. Bail out
- * and return 0 if we fail, this is always a safe bet.
- */
-static int
-iso_get_ssector(dev, p)
- dev_t dev;
- struct proc *p;
-{
- struct ioc_toc_header h;
- struct ioc_read_toc_single_entry t;
- int i;
- struct cdevsw *bd;
- d_ioctl_t *ioctlp;
-
- bd = devsw(dev);
- ioctlp = bd->d_ioctl;
- if (ioctlp == NULL)
- return 0;
-
- if (ioctlp(dev, CDIOREADTOCHEADER, (caddr_t)&h, FREAD, p) != 0)
- return 0;
-
- for (i = h.ending_track; i >= 0; i--) {
- t.address_format = CD_LBA_FORMAT;
- t.track = i;
- if (ioctlp(dev, CDIOREADTOCENTRY, (caddr_t)&t, FREAD, p) != 0)
- return 0;
- if ((t.entry.control & 4) != 0)
- /* found a data track */
- break;
- }
-
- if (i < 0)
- return 0;
-
- return ntohl(t.entry.addr.lba);
-}
-
-static int iso_mountroot __P((struct mount *mp, struct proc *p));
-
-static int
-iso_mountroot(mp, p)
- struct mount *mp;
- struct proc *p;
-{
- struct iso_args args;
- int error;
-
- if ((error = bdevvp(rootdev, &rootvp))) {
- printf("iso_mountroot: can't find rootvp\n");
- return (error);
- }
- args.flags = ISOFSMNT_ROOT;
- args.ssector = iso_get_ssector(rootdev, p);
- if (bootverbose)
- printf("iso_mountroot(): using session at block %d\n",
- args.ssector);
- if ((error = iso_mountfs(rootvp, mp, p, &args)) != 0)
- return (error);
-
- (void)cd9660_statfs(mp, &mp->mnt_stat, p);
- return (0);
-}
-
-/*
- * VFS Operations.
- *
- * mount system call
- */
-static int
-cd9660_mount(mp, path, data, ndp, p)
- register struct mount *mp;
- char *path;
- caddr_t data;
- struct nameidata *ndp;
- struct proc *p;
-{
- struct vnode *devvp;
- struct iso_args args;
- size_t size;
- int error;
- mode_t accessmode;
- struct iso_mnt *imp = 0;
-
- if ((mp->mnt_flag & MNT_ROOTFS) != 0) {
- return (iso_mountroot(mp, p));
- }
- if ((error = copyin(data, (caddr_t)&args, sizeof (struct iso_args))))
- return (error);
-
- if ((mp->mnt_flag & MNT_RDONLY) == 0)
- return (EROFS);
-
- /*
- * If updating, check whether changing from read-only to
- * read/write; if there is no device name, that's all we do.
- */
- if (mp->mnt_flag & MNT_UPDATE) {
- imp = VFSTOISOFS(mp);
- if (args.fspec == 0)
- return (vfs_export(mp, &imp->im_export, &args.export));
- }
- /*
- * Not an update, or updating the name: look up the name
- * and verify that it refers to a sensible block device.
- */
- NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, p);
- if ((error = namei(ndp)))
- return (error);
- NDFREE(ndp, NDF_ONLY_PNBUF);
- devvp = ndp->ni_vp;
-
- if (!vn_isdisk(devvp, &error)) {
- vrele(devvp);
- return (error);
- }
-
- /*
- * Verify that user has necessary permissions on the device,
- * or has superuser abilities
- */
- accessmode = VREAD;
- vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p);
- error = VOP_ACCESS(devvp, accessmode, p->p_ucred, p);
- if (error)
- error = suser(p);
- if (error) {
- vput(devvp);
- return (error);
- }
- VOP_UNLOCK(devvp, 0, p);
-
- if ((mp->mnt_flag & MNT_UPDATE) == 0) {
- error = iso_mountfs(devvp, mp, p, &args);
- } else {
- if (devvp != imp->im_devvp)
- error = EINVAL; /* needs translation */
- else
- vrele(devvp);
- }
- if (error) {
- vrele(devvp);
- return error;
- }
- imp = VFSTOISOFS(mp);
- (void) copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size);
- bzero(mp->mnt_stat.f_mntonname + size, MNAMELEN - size);
- (void) copyinstr(args.fspec, mp->mnt_stat.f_mntfromname, MNAMELEN - 1,
- &size);
- bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
- (void) cd9660_statfs(mp, &mp->mnt_stat, p);
- return 0;
-}
-
-/*
- * Common code for mount and mountroot
- */
-static int
-iso_mountfs(devvp, mp, p, argp)
- register struct vnode *devvp;
- struct mount *mp;
- struct proc *p;
- struct iso_args *argp;
-{
- register struct iso_mnt *isomp = (struct iso_mnt *)0;
- struct buf *bp = NULL;
- struct buf *pribp = NULL, *supbp = NULL;
- dev_t dev = devvp->v_rdev;
- int error = EINVAL;
- int needclose = 0;
- int high_sierra = 0;
- int iso_bsize;
- int iso_blknum;
- int joliet_level;
- struct iso_volume_descriptor *vdp = 0;
- struct iso_primary_descriptor *pri = NULL;
- struct iso_sierra_primary_descriptor *pri_sierra = NULL;
- struct iso_supplementary_descriptor *sup = NULL;
- struct iso_directory_record *rootp;
- int logical_block_size;
-
- if (!(mp->mnt_flag & MNT_RDONLY))
- return EROFS;
-
- /*
- * Disallow multiple mounts of the same device.
- * Disallow mounting of a device that is currently in use
- * (except for root, which might share swap device for miniroot).
- * Flush out any old buffers remaining from a previous use.
- */
- if ((error = vfs_mountedon(devvp)))
- return error;
- if (vcount(devvp) > 1 && devvp != rootvp)
- return EBUSY;
- if ((error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0)))
- return (error);
-
- vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p);
- error = VOP_OPEN(devvp, FREAD, FSCRED, p);
- VOP_UNLOCK(devvp, 0, p);
- if (error)
- return error;
-
- needclose = 1;
-
- /* This is the "logical sector size". The standard says this
- * should be 2048 or the physical sector size on the device,
- * whichever is greater. For now, we'll just use a constant.
- */
- iso_bsize = ISO_DEFAULT_BLOCK_SIZE;
-
- joliet_level = 0;
- for (iso_blknum = 16 + argp->ssector;
- iso_blknum < 100 + argp->ssector;
- iso_blknum++) {
- if ((error = bread(devvp, iso_blknum * btodb(iso_bsize),
- iso_bsize, NOCRED, &bp)) != 0)
- goto out;
-
- vdp = (struct iso_volume_descriptor *)bp->b_data;
- if (bcmp (vdp->id, ISO_STANDARD_ID, sizeof vdp->id) != 0) {
- if (bcmp (vdp->id_sierra, ISO_SIERRA_ID,
- sizeof vdp->id) != 0) {
- error = EINVAL;
- goto out;
- } else
- high_sierra = 1;
- }
- switch (isonum_711 (high_sierra? vdp->type_sierra: vdp->type)){
- case ISO_VD_PRIMARY:
- if (pribp == NULL) {
- pribp = bp;
- bp = NULL;
- pri = (struct iso_primary_descriptor *)vdp;
- pri_sierra =
- (struct iso_sierra_primary_descriptor *)vdp;
- }
- break;
-
- case ISO_VD_SUPPLEMENTARY:
- if (supbp == NULL) {
- supbp = bp;
- bp = NULL;
- sup = (struct iso_supplementary_descriptor *)vdp;
-
- if (!(argp->flags & ISOFSMNT_NOJOLIET)) {
- if (bcmp(sup->escape, "%/@", 3) == 0)
- joliet_level = 1;
- if (bcmp(sup->escape, "%/C", 3) == 0)
- joliet_level = 2;
- if (bcmp(sup->escape, "%/E", 3) == 0)
- joliet_level = 3;
-
- if (isonum_711 (sup->flags) & 1)
- joliet_level = 0;
- }
- }
- break;
-
- case ISO_VD_END:
- goto vd_end;
-
- default:
- break;
- }
- if (bp) {
- brelse(bp);
- bp = NULL;
- }
- }
- vd_end:
- if (bp) {
- brelse(bp);
- bp = NULL;
- }
-
- if (pri == NULL) {
- error = EINVAL;
- goto out;
- }
-
- logical_block_size =
- isonum_723 (high_sierra?
- pri_sierra->logical_block_size:
- pri->logical_block_size);
-
- if (logical_block_size < DEV_BSIZE || logical_block_size > MAXBSIZE
- || (logical_block_size & (logical_block_size - 1)) != 0) {
- error = EINVAL;
- goto out;
- }
-
- rootp = (struct iso_directory_record *)
- (high_sierra?
- pri_sierra->root_directory_record:
- pri->root_directory_record);
-
- isomp = malloc(sizeof *isomp, M_ISOFSMNT, M_WAITOK);
- bzero((caddr_t)isomp, sizeof *isomp);
- isomp->logical_block_size = logical_block_size;
- isomp->volume_space_size =
- isonum_733 (high_sierra?
- pri_sierra->volume_space_size:
- pri->volume_space_size);
- isomp->joliet_level = 0;
- /*
- * Since an ISO9660 multi-session CD can also access previous
- * sessions, we have to include them into the space consider-
- * ations. This doesn't yield a very accurate number since
- * parts of the old sessions might be inaccessible now, but we
- * can't do much better. This is also important for the NFS
- * filehandle validation.
- */
- isomp->volume_space_size += argp->ssector;
- bcopy (rootp, isomp->root, sizeof isomp->root);
- isomp->root_extent = isonum_733 (rootp->extent);
- isomp->root_size = isonum_733 (rootp->size);
-
- isomp->im_bmask = logical_block_size - 1;
- isomp->im_bshift = ffs(logical_block_size) - 1;
-
- pribp->b_flags |= B_AGE;
- brelse(pribp);
- pribp = NULL;
-
- mp->mnt_data = (qaddr_t)isomp;
- mp->mnt_stat.f_fsid.val[0] = dev2udev(dev);
- mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum;
- mp->mnt_maxsymlinklen = 0;
- mp->mnt_flag |= MNT_LOCAL;
- isomp->im_mountp = mp;
- isomp->im_dev = dev;
- isomp->im_devvp = devvp;
-
- devvp->v_specmountpoint = mp;
-
- /* Check the Rock Ridge Extention support */
- if (!(argp->flags & ISOFSMNT_NORRIP)) {
- if ((error = bread(isomp->im_devvp,
- (isomp->root_extent + isonum_711(rootp->ext_attr_length)) <<
- (isomp->im_bshift - DEV_BSHIFT),
- isomp->logical_block_size, NOCRED, &bp)) != 0)
- goto out;
-
- rootp = (struct iso_directory_record *)bp->b_data;
-
- if ((isomp->rr_skip = cd9660_rrip_offset(rootp,isomp)) < 0) {
- argp->flags |= ISOFSMNT_NORRIP;
- } else {
- argp->flags &= ~ISOFSMNT_GENS;
- }
-
- /*
- * The contents are valid,
- * but they will get reread as part of another vnode, so...
- */
- bp->b_flags |= B_AGE;
- brelse(bp);
- bp = NULL;
- }
- isomp->im_flags = argp->flags & (ISOFSMNT_NORRIP | ISOFSMNT_GENS |
- ISOFSMNT_EXTATT | ISOFSMNT_NOJOLIET);
-
- if (high_sierra) {
- /* this effectively ignores all the mount flags */
- log(LOG_INFO, "cd9660: High Sierra Format\n");
- isomp->iso_ftype = ISO_FTYPE_HIGH_SIERRA;
- } else
- switch (isomp->im_flags&(ISOFSMNT_NORRIP|ISOFSMNT_GENS)) {
- default:
- isomp->iso_ftype = ISO_FTYPE_DEFAULT;
- break;
- case ISOFSMNT_GENS|ISOFSMNT_NORRIP:
- isomp->iso_ftype = ISO_FTYPE_9660;
- break;
- case 0:
- log(LOG_INFO, "cd9660: RockRidge Extension\n");
- isomp->iso_ftype = ISO_FTYPE_RRIP;
- break;
- }
-
- /* Decide whether to use the Joliet descriptor */
-
- if (isomp->iso_ftype != ISO_FTYPE_RRIP && joliet_level) {
- log(LOG_INFO, "cd9660: Joliet Extension\n");
- rootp = (struct iso_directory_record *)
- sup->root_directory_record;
- bcopy (rootp, isomp->root, sizeof isomp->root);
- isomp->root_extent = isonum_733 (rootp->extent);
- isomp->root_size = isonum_733 (rootp->size);
- isomp->joliet_level = joliet_level;
- supbp->b_flags |= B_AGE;
- }
-
- if (supbp) {
- brelse(supbp);
- supbp = NULL;
- }
-
- return 0;
-out:
- devvp->v_specmountpoint = NULL;
- if (bp)
- brelse(bp);
- if (pribp)
- brelse(pribp);
- if (supbp)
- brelse(supbp);
- if (needclose)
- (void)VOP_CLOSE(devvp, FREAD, NOCRED, p);
- if (isomp) {
- free((caddr_t)isomp, M_ISOFSMNT);
- mp->mnt_data = (qaddr_t)0;
- }
- return error;
-}
-
-/*
- * unmount system call
- */
-static int
-cd9660_unmount(mp, mntflags, p)
- struct mount *mp;
- int mntflags;
- struct proc *p;
-{
- register struct iso_mnt *isomp;
- int error, flags = 0;
-
- if (mntflags & MNT_FORCE)
- flags |= FORCECLOSE;
-#if 0
- mntflushbuf(mp, 0);
- if (mntinvalbuf(mp))
- return EBUSY;
-#endif
- if ((error = vflush(mp, NULLVP, flags)))
- return (error);
-
- isomp = VFSTOISOFS(mp);
-
- isomp->im_devvp->v_specmountpoint = NULL;
- error = VOP_CLOSE(isomp->im_devvp, FREAD, NOCRED, p);
- vrele(isomp->im_devvp);
- free((caddr_t)isomp, M_ISOFSMNT);
- mp->mnt_data = (qaddr_t)0;
- mp->mnt_flag &= ~MNT_LOCAL;
- return (error);
-}
-
-/*
- * Return root of a filesystem
- */
-static int
-cd9660_root(mp, vpp)
- struct mount *mp;
- struct vnode **vpp;
-{
- struct iso_mnt *imp = VFSTOISOFS(mp);
- struct iso_directory_record *dp =
- (struct iso_directory_record *)imp->root;
- ino_t ino = isodirino(dp, imp);
-
- /*
- * With RRIP we must use the `.' entry of the root directory.
- * Simply tell vget, that it's a relocated directory.
- */
- return (cd9660_vget_internal(mp, ino, vpp,
- imp->iso_ftype == ISO_FTYPE_RRIP, dp));
-}
-
-/*
- * Get file system statistics.
- */
-int
-cd9660_statfs(mp, sbp, p)
- struct mount *mp;
- register struct statfs *sbp;
- struct proc *p;
-{
- register struct iso_mnt *isomp;
-
- isomp = VFSTOISOFS(mp);
-
- sbp->f_bsize = isomp->logical_block_size;
- sbp->f_iosize = sbp->f_bsize; /* XXX */
- sbp->f_blocks = isomp->volume_space_size;
- sbp->f_bfree = 0; /* total free blocks */
- sbp->f_bavail = 0; /* blocks free for non superuser */
- sbp->f_files = 0; /* total files */
- sbp->f_ffree = 0; /* free file nodes */
- if (sbp != &mp->mnt_stat) {
- sbp->f_type = mp->mnt_vfc->vfc_typenum;
- bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN);
- bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN);
- }
- return 0;
-}
-
-/*
- * File handle to vnode
- *
- * Have to be really careful about stale file handles:
- * - check that the inode number is in range
- * - call iget() to get the locked inode
- * - check for an unallocated inode (i_mode == 0)
- * - check that the generation number matches
- */
-
-struct ifid {
- ushort ifid_len;
- ushort ifid_pad;
- int ifid_ino;
- long ifid_start;
-};
-
-/* ARGSUSED */
-int
-cd9660_fhtovp(mp, fhp, vpp)
- register struct mount *mp;
- struct fid *fhp;
- struct vnode **vpp;
-{
- struct ifid *ifhp = (struct ifid *)fhp;
- register struct iso_node *ip;
- struct vnode *nvp;
- int error;
-
-#ifdef ISOFS_DBG
- printf("fhtovp: ino %d, start %ld\n",
- ifhp->ifid_ino, ifhp->ifid_start);
-#endif
-
- if ((error = VFS_VGET(mp, ifhp->ifid_ino, &nvp)) != 0) {
- *vpp = NULLVP;
- return (error);
- }
- ip = VTOI(nvp);
- if (ip->inode.iso_mode == 0) {
- vput(nvp);
- *vpp = NULLVP;
- return (ESTALE);
- }
- *vpp = nvp;
- return (0);
-}
-
-int
-cd9660_checkexp(mp, nam, exflagsp, credanonp)
- struct mount *mp;
- struct sockaddr *nam;
- int *exflagsp;
- struct ucred **credanonp;
-{
- register struct netcred *np;
- register struct iso_mnt *imp;
-
- imp = VFSTOISOFS(mp);
-
- /*
- * Get the export permission structure for this <mp, client> tuple.
- */
- np = vfs_export_lookup(mp, &imp->im_export, nam);
- if (np == NULL)
- return (EACCES);
-
- *exflagsp = np->netc_exflags;
- *credanonp = &np->netc_anon;
- return (0);
-}
-
-int
-cd9660_vget(mp, ino, vpp)
- struct mount *mp;
- ino_t ino;
- struct vnode **vpp;
-{
-
- /*
- * XXXX
- * It would be nice if we didn't always set the `relocated' flag
- * and force the extra read, but I don't want to think about fixing
- * that right now.
- */
- return (cd9660_vget_internal(mp, ino, vpp,
-#if 0
- VFSTOISOFS(mp)->iso_ftype == ISO_FTYPE_RRIP,
-#else
- 0,
-#endif
- (struct iso_directory_record *)0));
-}
-
-int
-cd9660_vget_internal(mp, ino, vpp, relocated, isodir)
- struct mount *mp;
- ino_t ino;
- struct vnode **vpp;
- int relocated;
- struct iso_directory_record *isodir;
-{
- struct iso_mnt *imp;
- struct iso_node *ip;
- struct buf *bp;
- struct vnode *vp;
- dev_t dev;
- int error;
-
- imp = VFSTOISOFS(mp);
- dev = imp->im_dev;
- if ((*vpp = cd9660_ihashget(dev, ino)) != NULLVP)
- return (0);
-
- /* Allocate a new vnode/iso_node. */
- if ((error = getnewvnode(VT_ISOFS, mp, cd9660_vnodeop_p, &vp)) != 0) {
- *vpp = NULLVP;
- return (error);
- }
- MALLOC(ip, struct iso_node *, sizeof(struct iso_node), M_ISOFSNODE,
- M_WAITOK);
- bzero((caddr_t)ip, sizeof(struct iso_node));
- lockinit(&ip->i_lock, PINOD, "isonode", 0, 0);
- vp->v_data = ip;
- ip->i_vnode = vp;
- ip->i_dev = dev;
- ip->i_number = ino;
-
- /*
- * Put it onto its hash chain and lock it so that other requests for
- * this inode will block if they arrive while we are sleeping waiting
- * for old data structures to be purged or for the contents of the
- * disk portion of this inode to be read.
- */
- cd9660_ihashins(ip);
-
- if (isodir == 0) {
- int lbn, off;
-
- lbn = lblkno(imp, ino);
- if (lbn >= imp->volume_space_size) {
- vput(vp);
- printf("fhtovp: lbn exceed volume space %d\n", lbn);
- return (ESTALE);
- }
-
- off = blkoff(imp, ino);
- if (off + ISO_DIRECTORY_RECORD_SIZE > imp->logical_block_size) {
- vput(vp);
- printf("fhtovp: crosses block boundary %d\n",
- off + ISO_DIRECTORY_RECORD_SIZE);
- return (ESTALE);
- }
-
- error = bread(imp->im_devvp,
- lbn << (imp->im_bshift - DEV_BSHIFT),
- imp->logical_block_size, NOCRED, &bp);
- if (error) {
- vput(vp);
- brelse(bp);
- printf("fhtovp: bread error %d\n",error);
- return (error);
- }
- isodir = (struct iso_directory_record *)(bp->b_data + off);
-
- if (off + isonum_711(isodir->length) >
- imp->logical_block_size) {
- vput(vp);
- if (bp != 0)
- brelse(bp);
- printf("fhtovp: directory crosses block boundary %d[off=%d/len=%d]\n",
- off +isonum_711(isodir->length), off,
- isonum_711(isodir->length));
- return (ESTALE);
- }
-
-#if 0
- if (isonum_733(isodir->extent) +
- isonum_711(isodir->ext_attr_length) != ifhp->ifid_start) {
- if (bp != 0)
- brelse(bp);
- printf("fhtovp: file start miss %d vs %d\n",
- isonum_733(isodir->extent) + isonum_711(isodir->ext_attr_length),
- ifhp->ifid_start);
- return (ESTALE);
- }
-#endif
- } else
- bp = 0;
-
- ip->i_mnt = imp;
- ip->i_devvp = imp->im_devvp;
- VREF(ip->i_devvp);
-
- if (relocated) {
- /*
- * On relocated directories we must
- * read the `.' entry out of a dir.
- */
- ip->iso_start = ino >> imp->im_bshift;
- if (bp != 0)
- brelse(bp);
- if ((error = cd9660_blkatoff(vp, (off_t)0, NULL, &bp)) != 0) {
- vput(vp);
- return (error);
- }
- isodir = (struct iso_directory_record *)bp->b_data;
- }
-
- ip->iso_extent = isonum_733(isodir->extent);
- ip->i_size = isonum_733(isodir->size);
- ip->iso_start = isonum_711(isodir->ext_attr_length) + ip->iso_extent;
-
- /*
- * Setup time stamp, attribute
- */
- vp->v_type = VNON;
- switch (imp->iso_ftype) {
- default: /* ISO_FTYPE_9660 */
- {
- struct buf *bp2;
- int off;
- if ((imp->im_flags & ISOFSMNT_EXTATT)
- && (off = isonum_711(isodir->ext_attr_length)))
- cd9660_blkatoff(vp, (off_t)-(off << imp->im_bshift), NULL,
- &bp2);
- else
- bp2 = NULL;
- cd9660_defattr(isodir, ip, bp2, ISO_FTYPE_9660);
- cd9660_deftstamp(isodir, ip, bp2, ISO_FTYPE_9660);
- if (bp2)
- brelse(bp2);
- break;
- }
- case ISO_FTYPE_RRIP:
- cd9660_rrip_analyze(isodir, ip, imp);
- break;
- }
-
- if (bp != 0)
- brelse(bp);
-
- /*
- * Initialize the associated vnode
- */
- switch (vp->v_type = IFTOVT(ip->inode.iso_mode)) {
- case VFIFO:
- vp->v_op = cd9660_fifoop_p;
- break;
- case VCHR:
- case VBLK:
- vp->v_op = cd9660_specop_p;
- addaliasu(vp, ip->inode.iso_rdev);
- break;
- default:
- break;
- }
-
- if (ip->iso_extent == imp->root_extent)
- vp->v_flag |= VROOT;
-
- /*
- * XXX need generation number?
- */
-
- *vpp = vp;
- return (0);
-}
-
-/*
- * Vnode pointer to File handle
- */
-/* ARGSUSED */
-int
-cd9660_vptofh(vp, fhp)
- struct vnode *vp;
- struct fid *fhp;
-{
- register struct iso_node *ip = VTOI(vp);
- register struct ifid *ifhp;
-
- ifhp = (struct ifid *)fhp;
- ifhp->ifid_len = sizeof(struct ifid);
-
- ifhp->ifid_ino = ip->i_number;
- ifhp->ifid_start = ip->iso_start;
-
-#ifdef ISOFS_DBG
- printf("vptofh: ino %d, start %ld\n",
- ifhp->ifid_ino,ifhp->ifid_start);
-#endif
- return 0;
-}
diff --git a/sys/fs/cd9660/cd9660_vnops.c b/sys/fs/cd9660/cd9660_vnops.c
deleted file mode 100644
index 65ad9385e36c..000000000000
--- a/sys/fs/cd9660/cd9660_vnops.c
+++ /dev/null
@@ -1,930 +0,0 @@
-/*-
- * Copyright (c) 1994
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley
- * by Pace Willisson (pace@blitz.com). The Rock Ridge Extension
- * Support code is derived from software contributed to Berkeley
- * by Atsushi Murai (amurai@spec.co.jp).
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)cd9660_vnops.c 8.19 (Berkeley) 5/27/95
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/namei.h>
-#include <sys/kernel.h>
-#include <sys/stat.h>
-#include <sys/buf.h>
-#include <sys/mount.h>
-#include <sys/vnode.h>
-#include <miscfs/fifofs/fifo.h>
-#include <sys/malloc.h>
-#include <sys/dirent.h>
-#include <sys/unistd.h>
-#include <sys/filio.h>
-
-#include <vm/vm.h>
-#include <vm/vm_zone.h>
-#include <vm/vnode_pager.h>
-
-#include <isofs/cd9660/iso.h>
-#include <isofs/cd9660/cd9660_node.h>
-#include <isofs/cd9660/iso_rrip.h>
-
-static int cd9660_setattr __P((struct vop_setattr_args *));
-static int cd9660_access __P((struct vop_access_args *));
-static int cd9660_getattr __P((struct vop_getattr_args *));
-static int cd9660_ioctl __P((struct vop_ioctl_args *));
-static int cd9660_pathconf __P((struct vop_pathconf_args *));
-static int cd9660_read __P((struct vop_read_args *));
-struct isoreaddir;
-static int iso_uiodir __P((struct isoreaddir *idp, struct dirent *dp,
- off_t off));
-static int iso_shipdir __P((struct isoreaddir *idp));
-static int cd9660_readdir __P((struct vop_readdir_args *));
-static int cd9660_readlink __P((struct vop_readlink_args *ap));
-static int cd9660_strategy __P((struct vop_strategy_args *));
-static int cd9660_print __P((struct vop_print_args *));
-static int cd9660_getpages __P((struct vop_getpages_args *));
-static int cd9660_putpages __P((struct vop_putpages_args *));
-
-/*
- * Setattr call. Only allowed for block and character special devices.
- */
-int
-cd9660_setattr(ap)
- struct vop_setattr_args /* {
- struct vnodeop_desc *a_desc;
- struct vnode *a_vp;
- struct vattr *a_vap;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
- struct vattr *vap = ap->a_vap;
-
- if (vap->va_flags != (u_long)VNOVAL || vap->va_uid != (uid_t)VNOVAL ||
- vap->va_gid != (gid_t)VNOVAL || vap->va_atime.tv_sec != VNOVAL ||
- vap->va_mtime.tv_sec != VNOVAL || vap->va_mode != (mode_t)VNOVAL)
- return (EROFS);
- if (vap->va_size != (u_quad_t)VNOVAL) {
- switch (vp->v_type) {
- case VDIR:
- return (EISDIR);
- case VLNK:
- case VREG:
- return (EROFS);
- case VCHR:
- case VBLK:
- case VSOCK:
- case VFIFO:
- case VNON:
- case VBAD:
- return (0);
- }
- }
- return (0);
-}
-
-/*
- * Check mode permission on inode pointer. Mode is READ, WRITE or EXEC.
- * The mode is shifted to select the owner/group/other fields. The
- * super user is granted all permissions.
- */
-/* ARGSUSED */
-static int
-cd9660_access(ap)
- struct vop_access_args /* {
- struct vnode *a_vp;
- int a_mode;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
- struct iso_node *ip = VTOI(vp);
- struct ucred *cred = ap->a_cred;
- mode_t mask, mode = ap->a_mode;
- gid_t *gp;
- int i;
-
- /*
- * Disallow write attempts unless the file is a socket,
- * fifo, or a block or character device resident on the
- * file system.
- */
- if (mode & VWRITE) {
- switch (vp->v_type) {
- case VDIR:
- case VLNK:
- case VREG:
- return (EROFS);
- /* NOT REACHED */
- default:
- break;
- }
- }
-
- /* User id 0 always gets access. */
- if (cred->cr_uid == 0)
- return (0);
-
- mask = 0;
-
- /* Otherwise, check the owner. */
- if (cred->cr_uid == ip->inode.iso_uid) {
- if (mode & VEXEC)
- mask |= S_IXUSR;
- if (mode & VREAD)
- mask |= S_IRUSR;
- if (mode & VWRITE)
- mask |= S_IWUSR;
- return ((ip->inode.iso_mode & mask) == mask ? 0 : EACCES);
- }
-
- /* Otherwise, check the groups. */
- for (i = 0, gp = cred->cr_groups; i < cred->cr_ngroups; i++, gp++)
- if (ip->inode.iso_gid == *gp) {
- if (mode & VEXEC)
- mask |= S_IXGRP;
- if (mode & VREAD)
- mask |= S_IRGRP;
- if (mode & VWRITE)
- mask |= S_IWGRP;
- return ((ip->inode.iso_mode & mask) == mask ?
- 0 : EACCES);
- }
-
- /* Otherwise, check everyone else. */
- if (mode & VEXEC)
- mask |= S_IXOTH;
- if (mode & VREAD)
- mask |= S_IROTH;
- if (mode & VWRITE)
- mask |= S_IWOTH;
- return ((ip->inode.iso_mode & mask) == mask ? 0 : EACCES);
-}
-
-static int
-cd9660_getattr(ap)
- struct vop_getattr_args /* {
- struct vnode *a_vp;
- struct vattr *a_vap;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-
-{
- struct vnode *vp = ap->a_vp;
- register struct vattr *vap = ap->a_vap;
- register struct iso_node *ip = VTOI(vp);
-
- vap->va_fsid = dev2udev(ip->i_dev);
- vap->va_fileid = ip->i_number;
-
- vap->va_mode = ip->inode.iso_mode;
- vap->va_nlink = ip->inode.iso_links;
- vap->va_uid = ip->inode.iso_uid;
- vap->va_gid = ip->inode.iso_gid;
- vap->va_atime = ip->inode.iso_atime;
- vap->va_mtime = ip->inode.iso_mtime;
- vap->va_ctime = ip->inode.iso_ctime;
- vap->va_rdev = ip->inode.iso_rdev;
-
- vap->va_size = (u_quad_t) ip->i_size;
- if (ip->i_size == 0 && (vap->va_mode & S_IFMT) == S_IFLNK) {
- struct vop_readlink_args rdlnk;
- struct iovec aiov;
- struct uio auio;
- char *cp;
-
- MALLOC(cp, char *, MAXPATHLEN, M_TEMP, M_WAITOK);
- aiov.iov_base = cp;
- aiov.iov_len = MAXPATHLEN;
- auio.uio_iov = &aiov;
- auio.uio_iovcnt = 1;
- auio.uio_offset = 0;
- auio.uio_rw = UIO_READ;
- auio.uio_segflg = UIO_SYSSPACE;
- auio.uio_procp = ap->a_p;
- auio.uio_resid = MAXPATHLEN;
- rdlnk.a_uio = &auio;
- rdlnk.a_vp = ap->a_vp;
- rdlnk.a_cred = ap->a_cred;
- if (cd9660_readlink(&rdlnk) == 0)
- vap->va_size = MAXPATHLEN - auio.uio_resid;
- FREE(cp, M_TEMP);
- }
- vap->va_flags = 0;
- vap->va_gen = 1;
- vap->va_blocksize = ip->i_mnt->logical_block_size;
- vap->va_bytes = (u_quad_t) ip->i_size;
- vap->va_type = vp->v_type;
- vap->va_filerev = 0;
- return (0);
-}
-
-/*
- * Vnode op for ioctl.
- */
-static int
-cd9660_ioctl(ap)
- struct vop_ioctl_args /* {
- struct vnode *a_vp;
- int a_command;
- caddr_t a_data;
- int a_fflag;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
- struct iso_node *ip = VTOI(vp);
-
- switch (ap->a_command) {
-
- case FIOGETLBA:
- *(int *)(ap->a_data) = ip->iso_start;
- return 0;
- default:
- return (ENOTTY);
- }
-}
-
-/*
- * Vnode op for reading.
- */
-static int
-cd9660_read(ap)
- struct vop_read_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- int a_ioflag;
- struct ucred *a_cred;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
- register struct uio *uio = ap->a_uio;
- register struct iso_node *ip = VTOI(vp);
- register struct iso_mnt *imp;
- struct buf *bp;
- daddr_t lbn, rablock;
- off_t diff;
- int rasize, error = 0;
- int seqcount;
- long size, n, on;
-
- seqcount = ap->a_ioflag >> 16;
-
- if (uio->uio_resid == 0)
- return (0);
- if (uio->uio_offset < 0)
- return (EINVAL);
- ip->i_flag |= IN_ACCESS;
- imp = ip->i_mnt;
- do {
- lbn = lblkno(imp, uio->uio_offset);
- on = blkoff(imp, uio->uio_offset);
- n = min((u_int)(imp->logical_block_size - on),
- uio->uio_resid);
- diff = (off_t)ip->i_size - uio->uio_offset;
- if (diff <= 0)
- return (0);
- if (diff < n)
- n = diff;
- size = blksize(imp, ip, lbn);
- rablock = lbn + 1;
- if ((vp->v_mount->mnt_flag & MNT_NOCLUSTERR) == 0) {
- if (lblktosize(imp, rablock) < ip->i_size)
- error = cluster_read(vp, (off_t)ip->i_size,
- lbn, size, NOCRED, uio->uio_resid,
- (ap->a_ioflag >> 16), &bp);
- else
- error = bread(vp, lbn, size, NOCRED, &bp);
- } else {
- if (seqcount > 1 &&
- lblktosize(imp, rablock) < ip->i_size) {
- rasize = blksize(imp, ip, rablock);
- error = breadn(vp, lbn, size, &rablock,
- &rasize, 1, NOCRED, &bp);
- } else
- error = bread(vp, lbn, size, NOCRED, &bp);
- }
- n = min(n, size - bp->b_resid);
- if (error) {
- brelse(bp);
- return (error);
- }
-
- error = uiomove(bp->b_data + on, (int)n, uio);
- brelse(bp);
- } while (error == 0 && uio->uio_resid > 0 && n != 0);
- return (error);
-}
-
-/*
- * Structure for reading directories
- */
-struct isoreaddir {
- struct dirent saveent;
- struct dirent assocent;
- struct dirent current;
- off_t saveoff;
- off_t assocoff;
- off_t curroff;
- struct uio *uio;
- off_t uio_off;
- int eofflag;
- u_long *cookies;
- int ncookies;
-};
-
-int
-iso_uiodir(idp,dp,off)
- struct isoreaddir *idp;
- struct dirent *dp;
- off_t off;
-{
- int error;
-
- dp->d_name[dp->d_namlen] = 0;
- dp->d_reclen = GENERIC_DIRSIZ(dp);
-
- if (idp->uio->uio_resid < dp->d_reclen) {
- idp->eofflag = 0;
- return (-1);
- }
-
- if (idp->cookies) {
- if (idp->ncookies <= 0) {
- idp->eofflag = 0;
- return (-1);
- }
-
- *idp->cookies++ = off;
- --idp->ncookies;
- }
-
- if ((error = uiomove((caddr_t) dp,dp->d_reclen,idp->uio)) != 0)
- return (error);
- idp->uio_off = off;
- return (0);
-}
-
-int
-iso_shipdir(idp)
- struct isoreaddir *idp;
-{
- struct dirent *dp;
- int cl, sl, assoc;
- int error;
- char *cname, *sname;
-
- cl = idp->current.d_namlen;
- cname = idp->current.d_name;
-assoc = (cl > 1) && (*cname == ASSOCCHAR);
- if (assoc) {
- cl--;
- cname++;
- }
-
- dp = &idp->saveent;
- sname = dp->d_name;
- if (!(sl = dp->d_namlen)) {
- dp = &idp->assocent;
- sname = dp->d_name + 1;
- sl = dp->d_namlen - 1;
- }
- if (sl > 0) {
- if (sl != cl
- || bcmp(sname,cname,sl)) {
- if (idp->assocent.d_namlen) {
- if ((error = iso_uiodir(idp,&idp->assocent,idp->assocoff)) != 0)
- return (error);
- idp->assocent.d_namlen = 0;
- }
- if (idp->saveent.d_namlen) {
- if ((error = iso_uiodir(idp,&idp->saveent,idp->saveoff)) != 0)
- return (error);
- idp->saveent.d_namlen = 0;
- }
- }
- }
- idp->current.d_reclen = GENERIC_DIRSIZ(&idp->current);
- if (assoc) {
- idp->assocoff = idp->curroff;
- bcopy(&idp->current,&idp->assocent,idp->current.d_reclen);
- } else {
- idp->saveoff = idp->curroff;
- bcopy(&idp->current,&idp->saveent,idp->current.d_reclen);
- }
- return (0);
-}
-
-/*
- * Vnode op for readdir
- */
-static int
-cd9660_readdir(ap)
- struct vop_readdir_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- struct ucred *a_cred;
- int *a_eofflag;
- int *a_ncookies;
- u_long *a_cookies;
- } */ *ap;
-{
- register struct uio *uio = ap->a_uio;
- struct isoreaddir *idp;
- struct vnode *vdp = ap->a_vp;
- struct iso_node *dp;
- struct iso_mnt *imp;
- struct buf *bp = NULL;
- struct iso_directory_record *ep;
- int entryoffsetinblock;
- doff_t endsearch;
- u_long bmask;
- int error = 0;
- int reclen;
- u_short namelen;
- int ncookies = 0;
- u_long *cookies = NULL;
-
- dp = VTOI(vdp);
- imp = dp->i_mnt;
- bmask = imp->im_bmask;
-
- MALLOC(idp, struct isoreaddir *, sizeof(*idp), M_TEMP, M_WAITOK);
- idp->saveent.d_namlen = idp->assocent.d_namlen = 0;
- /*
- * XXX
- * Is it worth trying to figure out the type?
- */
- idp->saveent.d_type = idp->assocent.d_type = idp->current.d_type =
- DT_UNKNOWN;
- idp->uio = uio;
- if (ap->a_ncookies == NULL) {
- idp->cookies = NULL;
- } else {
- /*
- * Guess the number of cookies needed.
- */
- ncookies = uio->uio_resid / 16;
- MALLOC(cookies, u_long *, ncookies * sizeof(u_int), M_TEMP,
- M_WAITOK);
- idp->cookies = cookies;
- idp->ncookies = ncookies;
- }
- idp->eofflag = 1;
- idp->curroff = uio->uio_offset;
-
- if ((entryoffsetinblock = idp->curroff & bmask) &&
- (error = cd9660_blkatoff(vdp, (off_t)idp->curroff, NULL, &bp))) {
- FREE(idp, M_TEMP);
- return (error);
- }
- endsearch = dp->i_size;
-
- while (idp->curroff < endsearch) {
- /*
- * If offset is on a block boundary,
- * read the next directory block.
- * Release previous if it exists.
- */
- if ((idp->curroff & bmask) == 0) {
- if (bp != NULL)
- brelse(bp);
- if ((error =
- cd9660_blkatoff(vdp, (off_t)idp->curroff, NULL, &bp)) != 0)
- break;
- entryoffsetinblock = 0;
- }
- /*
- * Get pointer to next entry.
- */
- ep = (struct iso_directory_record *)
- ((char *)bp->b_data + entryoffsetinblock);
-
- reclen = isonum_711(ep->length);
- if (reclen == 0) {
- /* skip to next block, if any */
- idp->curroff =
- (idp->curroff & ~bmask) + imp->logical_block_size;
- continue;
- }
-
- if (reclen < ISO_DIRECTORY_RECORD_SIZE) {
- error = EINVAL;
- /* illegal entry, stop */
- break;
- }
-
- if (entryoffsetinblock + reclen > imp->logical_block_size) {
- error = EINVAL;
- /* illegal directory, so stop looking */
- break;
- }
-
- idp->current.d_namlen = isonum_711(ep->name_len);
-
- if (reclen < ISO_DIRECTORY_RECORD_SIZE + idp->current.d_namlen) {
- error = EINVAL;
- /* illegal entry, stop */
- break;
- }
-
- if (isonum_711(ep->flags)&2)
- idp->current.d_fileno = isodirino(ep, imp);
- else
- idp->current.d_fileno = dbtob(bp->b_blkno) +
- entryoffsetinblock;
-
- idp->curroff += reclen;
-
- switch (imp->iso_ftype) {
- case ISO_FTYPE_RRIP:
- cd9660_rrip_getname(ep,idp->current.d_name, &namelen,
- &idp->current.d_fileno,imp);
- idp->current.d_namlen = (u_char)namelen;
- if (idp->current.d_namlen)
- error = iso_uiodir(idp,&idp->current,idp->curroff);
- break;
- default: /* ISO_FTYPE_DEFAULT || ISO_FTYPE_9660 || ISO_FTYPE_HIGH_SIERRA*/
- strcpy(idp->current.d_name,"..");
- if (idp->current.d_namlen == 1 && ep->name[0] == 0) {
- idp->current.d_namlen = 1;
- error = iso_uiodir(idp,&idp->current,idp->curroff);
- } else if (idp->current.d_namlen == 1 && ep->name[0] == 1) {
- idp->current.d_namlen = 2;
- error = iso_uiodir(idp,&idp->current,idp->curroff);
- } else {
- isofntrans(ep->name,idp->current.d_namlen,
- idp->current.d_name, &namelen,
- imp->iso_ftype == ISO_FTYPE_9660,
- isonum_711(ep->flags)&4,
- imp->joliet_level);
- idp->current.d_namlen = (u_char)namelen;
- if (imp->iso_ftype == ISO_FTYPE_DEFAULT)
- error = iso_shipdir(idp);
- else
- error = iso_uiodir(idp,&idp->current,idp->curroff);
- }
- }
- if (error)
- break;
-
- entryoffsetinblock += reclen;
- }
-
- if (!error && imp->iso_ftype == ISO_FTYPE_DEFAULT) {
- idp->current.d_namlen = 0;
- error = iso_shipdir(idp);
- }
- if (error < 0)
- error = 0;
-
- if (ap->a_ncookies != NULL) {
- if (error)
- free(cookies, M_TEMP);
- else {
- /*
- * Work out the number of cookies actually used.
- */
- *ap->a_ncookies = ncookies - idp->ncookies;
- *ap->a_cookies = cookies;
- }
- }
-
- if (bp)
- brelse (bp);
-
- uio->uio_offset = idp->uio_off;
- *ap->a_eofflag = idp->eofflag;
-
- FREE(idp, M_TEMP);
-
- return (error);
-}
-
-/*
- * Return target name of a symbolic link
- * Shouldn't we get the parent vnode and read the data from there?
- * This could eventually result in deadlocks in cd9660_lookup.
- * But otherwise the block read here is in the block buffer two times.
- */
-typedef struct iso_directory_record ISODIR;
-typedef struct iso_node ISONODE;
-typedef struct iso_mnt ISOMNT;
-static int
-cd9660_readlink(ap)
- struct vop_readlink_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- struct ucred *a_cred;
- } */ *ap;
-{
- ISONODE *ip;
- ISODIR *dirp;
- ISOMNT *imp;
- struct buf *bp;
- struct uio *uio;
- u_short symlen;
- int error;
- char *symname;
-
- ip = VTOI(ap->a_vp);
- imp = ip->i_mnt;
- uio = ap->a_uio;
-
- if (imp->iso_ftype != ISO_FTYPE_RRIP)
- return (EINVAL);
-
- /*
- * Get parents directory record block that this inode included.
- */
- error = bread(imp->im_devvp,
- (ip->i_number >> imp->im_bshift) <<
- (imp->im_bshift - DEV_BSHIFT),
- imp->logical_block_size, NOCRED, &bp);
- if (error) {
- brelse(bp);
- return (EINVAL);
- }
-
- /*
- * Setup the directory pointer for this inode
- */
- dirp = (ISODIR *)(bp->b_data + (ip->i_number & imp->im_bmask));
-
- /*
- * Just make sure, we have a right one....
- * 1: Check not cross boundary on block
- */
- if ((ip->i_number & imp->im_bmask) + isonum_711(dirp->length)
- > (unsigned)imp->logical_block_size) {
- brelse(bp);
- return (EINVAL);
- }
-
- /*
- * Now get a buffer
- * Abuse a namei buffer for now.
- */
- if (uio->uio_segflg == UIO_SYSSPACE)
- symname = uio->uio_iov->iov_base;
- else
- symname = zalloc(namei_zone);
-
- /*
- * Ok, we just gathering a symbolic name in SL record.
- */
- if (cd9660_rrip_getsymname(dirp, symname, &symlen, imp) == 0) {
- if (uio->uio_segflg != UIO_SYSSPACE)
- zfree(namei_zone, symname);
- brelse(bp);
- return (EINVAL);
- }
- /*
- * Don't forget before you leave from home ;-)
- */
- brelse(bp);
-
- /*
- * return with the symbolic name to caller's.
- */
- if (uio->uio_segflg != UIO_SYSSPACE) {
- error = uiomove(symname, symlen, uio);
- zfree(namei_zone, symname);
- return (error);
- }
- uio->uio_resid -= symlen;
- uio->uio_iov->iov_base += symlen;
- uio->uio_iov->iov_len -= symlen;
- return (0);
-}
-
-/*
- * Calculate the logical to physical mapping if not done already,
- * then call the device strategy routine.
- */
-static int
-cd9660_strategy(ap)
- struct vop_strategy_args /* {
- struct buf *a_vp;
- struct buf *a_bp;
- } */ *ap;
-{
- register struct buf *bp = ap->a_bp;
- register struct vnode *vp = bp->b_vp;
- register struct iso_node *ip;
- int error;
-
- ip = VTOI(vp);
- if (vp->v_type == VBLK || vp->v_type == VCHR)
- panic("cd9660_strategy: spec");
- if (bp->b_blkno == bp->b_lblkno) {
- if ((error =
- VOP_BMAP(vp, bp->b_lblkno, NULL, &bp->b_blkno, NULL, NULL))) {
- bp->b_error = error;
- bp->b_flags |= B_ERROR;
- biodone(bp);
- return (error);
- }
- if ((long)bp->b_blkno == -1)
- clrbuf(bp);
- }
- if ((long)bp->b_blkno == -1) {
- biodone(bp);
- return (0);
- }
- vp = ip->i_devvp;
- bp->b_dev = vp->v_rdev;
- VOP_STRATEGY(vp, bp);
- return (0);
-}
-
-/*
- * Print out the contents of an inode.
- */
-static int
-cd9660_print(ap)
- struct vop_print_args /* {
- struct vnode *a_vp;
- } */ *ap;
-{
-
- printf("tag VT_ISOFS, isofs vnode\n");
- return (0);
-}
-
-/*
- * Return POSIX pathconf information applicable to cd9660 filesystems.
- */
-static int
-cd9660_pathconf(ap)
- struct vop_pathconf_args /* {
- struct vnode *a_vp;
- int a_name;
- register_t *a_retval;
- } */ *ap;
-{
-
- switch (ap->a_name) {
- case _PC_LINK_MAX:
- *ap->a_retval = 1;
- return (0);
- case _PC_NAME_MAX:
- if (VTOI(ap->a_vp)->i_mnt->iso_ftype == ISO_FTYPE_RRIP)
- *ap->a_retval = NAME_MAX;
- else
- *ap->a_retval = 37;
- return (0);
- case _PC_PATH_MAX:
- *ap->a_retval = PATH_MAX;
- return (0);
- case _PC_PIPE_BUF:
- *ap->a_retval = PIPE_BUF;
- return (0);
- case _PC_CHOWN_RESTRICTED:
- *ap->a_retval = 1;
- return (0);
- case _PC_NO_TRUNC:
- *ap->a_retval = 1;
- return (0);
- default:
- return (EINVAL);
- }
- /* NOTREACHED */
-}
-
-/*
- * get page routine
- *
- * XXX By default, wimp out... note that a_offset is ignored (and always
- * XXX has been).
- */
-int
-cd9660_getpages(ap)
- struct vop_getpages_args *ap;
-{
- return vnode_pager_generic_getpages(ap->a_vp, ap->a_m, ap->a_count,
- ap->a_reqpage);
-}
-
-/*
- * put page routine
- *
- * XXX By default, wimp out... note that a_offset is ignored (and always
- * XXX has been).
- */
-int
-cd9660_putpages(ap)
- struct vop_putpages_args *ap;
-{
- return vnode_pager_generic_putpages(ap->a_vp, ap->a_m, ap->a_count,
- ap->a_sync, ap->a_rtvals);
-}
-
-/*
- * Global vfs data structures for cd9660
- */
-vop_t **cd9660_vnodeop_p;
-static struct vnodeopv_entry_desc cd9660_vnodeop_entries[] = {
- { &vop_default_desc, (vop_t *) vop_defaultop },
- { &vop_access_desc, (vop_t *) cd9660_access },
- { &vop_bmap_desc, (vop_t *) cd9660_bmap },
- { &vop_cachedlookup_desc, (vop_t *) cd9660_lookup },
- { &vop_getattr_desc, (vop_t *) cd9660_getattr },
- { &vop_inactive_desc, (vop_t *) cd9660_inactive },
- { &vop_ioctl_desc, (vop_t *) cd9660_ioctl },
- { &vop_islocked_desc, (vop_t *) vop_stdislocked },
- { &vop_lock_desc, (vop_t *) vop_stdlock },
- { &vop_lookup_desc, (vop_t *) vfs_cache_lookup },
- { &vop_pathconf_desc, (vop_t *) cd9660_pathconf },
- { &vop_print_desc, (vop_t *) cd9660_print },
- { &vop_read_desc, (vop_t *) cd9660_read },
- { &vop_readdir_desc, (vop_t *) cd9660_readdir },
- { &vop_readlink_desc, (vop_t *) cd9660_readlink },
- { &vop_reclaim_desc, (vop_t *) cd9660_reclaim },
- { &vop_setattr_desc, (vop_t *) cd9660_setattr },
- { &vop_strategy_desc, (vop_t *) cd9660_strategy },
- { &vop_unlock_desc, (vop_t *) vop_stdunlock },
- { &vop_getpages_desc, (vop_t *) cd9660_getpages },
- { &vop_putpages_desc, (vop_t *) cd9660_putpages },
- { NULL, NULL }
-};
-static struct vnodeopv_desc cd9660_vnodeop_opv_desc =
- { &cd9660_vnodeop_p, cd9660_vnodeop_entries };
-VNODEOP_SET(cd9660_vnodeop_opv_desc);
-
-/*
- * Special device vnode ops
- */
-vop_t **cd9660_specop_p;
-static struct vnodeopv_entry_desc cd9660_specop_entries[] = {
- { &vop_default_desc, (vop_t *) spec_vnoperate },
- { &vop_access_desc, (vop_t *) cd9660_access },
- { &vop_getattr_desc, (vop_t *) cd9660_getattr },
- { &vop_inactive_desc, (vop_t *) cd9660_inactive },
- { &vop_islocked_desc, (vop_t *) vop_stdislocked },
- { &vop_lock_desc, (vop_t *) vop_stdlock },
- { &vop_print_desc, (vop_t *) cd9660_print },
- { &vop_reclaim_desc, (vop_t *) cd9660_reclaim },
- { &vop_setattr_desc, (vop_t *) cd9660_setattr },
- { &vop_unlock_desc, (vop_t *) vop_stdunlock },
- { NULL, NULL }
-};
-static struct vnodeopv_desc cd9660_specop_opv_desc =
- { &cd9660_specop_p, cd9660_specop_entries };
-VNODEOP_SET(cd9660_specop_opv_desc);
-
-vop_t **cd9660_fifoop_p;
-static struct vnodeopv_entry_desc cd9660_fifoop_entries[] = {
- { &vop_default_desc, (vop_t *) fifo_vnoperate },
- { &vop_access_desc, (vop_t *) cd9660_access },
- { &vop_getattr_desc, (vop_t *) cd9660_getattr },
- { &vop_inactive_desc, (vop_t *) cd9660_inactive },
- { &vop_islocked_desc, (vop_t *) vop_stdislocked },
- { &vop_lock_desc, (vop_t *) vop_stdlock },
- { &vop_print_desc, (vop_t *) cd9660_print },
- { &vop_reclaim_desc, (vop_t *) cd9660_reclaim },
- { &vop_setattr_desc, (vop_t *) cd9660_setattr },
- { &vop_unlock_desc, (vop_t *) vop_stdunlock },
- { NULL, NULL }
-};
-static struct vnodeopv_desc cd9660_fifoop_opv_desc =
- { &cd9660_fifoop_p, cd9660_fifoop_entries };
-
-VNODEOP_SET(cd9660_fifoop_opv_desc);
diff --git a/sys/fs/cd9660/iso.h b/sys/fs/cd9660/iso.h
deleted file mode 100644
index f9a4abbc6008..000000000000
--- a/sys/fs/cd9660/iso.h
+++ /dev/null
@@ -1,357 +0,0 @@
-/*-
- * Copyright (c) 1994
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley
- * by Pace Willisson (pace@blitz.com). The Rock Ridge Extension
- * Support code is derived from software contributed to Berkeley
- * by Atsushi Murai (amurai@spec.co.jp).
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)iso.h 8.6 (Berkeley) 5/10/95
- * $FreeBSD$
- */
-
-#define ISODCL(from, to) (to - from + 1)
-
-struct iso_volume_descriptor {
- char type[ISODCL(1,1)]; /* 711 */
- char id[ISODCL(2,6)];
- char version[ISODCL(7,7)];
- char unused[ISODCL(8,8)];
- char type_sierra[ISODCL(9,9)]; /* 711 */
- char id_sierra[ISODCL(10,14)];
- char version_sierra[ISODCL(15,15)];
- char data[ISODCL(16,2048)];
-};
-
-/* volume descriptor types */
-#define ISO_VD_PRIMARY 1
-#define ISO_VD_SUPPLEMENTARY 2
-#define ISO_VD_END 255
-
-#define ISO_STANDARD_ID "CD001"
-#define ISO_ECMA_ID "CDW01"
-
-#define ISO_SIERRA_ID "CDROM"
-
-struct iso_primary_descriptor {
- char type [ISODCL ( 1, 1)]; /* 711 */
- char id [ISODCL ( 2, 6)];
- char version [ISODCL ( 7, 7)]; /* 711 */
- char unused1 [ISODCL ( 8, 8)];
- char system_id [ISODCL ( 9, 40)]; /* achars */
- char volume_id [ISODCL ( 41, 72)]; /* dchars */
- char unused2 [ISODCL ( 73, 80)];
- char volume_space_size [ISODCL ( 81, 88)]; /* 733 */
- char unused3 [ISODCL ( 89, 120)];
- char volume_set_size [ISODCL (121, 124)]; /* 723 */
- char volume_sequence_number [ISODCL (125, 128)]; /* 723 */
- char logical_block_size [ISODCL (129, 132)]; /* 723 */
- char path_table_size [ISODCL (133, 140)]; /* 733 */
- char type_l_path_table [ISODCL (141, 144)]; /* 731 */
- char opt_type_l_path_table [ISODCL (145, 148)]; /* 731 */
- char type_m_path_table [ISODCL (149, 152)]; /* 732 */
- char opt_type_m_path_table [ISODCL (153, 156)]; /* 732 */
- char root_directory_record [ISODCL (157, 190)]; /* 9.1 */
- char volume_set_id [ISODCL (191, 318)]; /* dchars */
- char publisher_id [ISODCL (319, 446)]; /* achars */
- char preparer_id [ISODCL (447, 574)]; /* achars */
- char application_id [ISODCL (575, 702)]; /* achars */
- char copyright_file_id [ISODCL (703, 739)]; /* 7.5 dchars */
- char abstract_file_id [ISODCL (740, 776)]; /* 7.5 dchars */
- char bibliographic_file_id [ISODCL (777, 813)]; /* 7.5 dchars */
- char creation_date [ISODCL (814, 830)]; /* 8.4.26.1 */
- char modification_date [ISODCL (831, 847)]; /* 8.4.26.1 */
- char expiration_date [ISODCL (848, 864)]; /* 8.4.26.1 */
- char effective_date [ISODCL (865, 881)]; /* 8.4.26.1 */
- char file_structure_version [ISODCL (882, 882)]; /* 711 */
- char unused4 [ISODCL (883, 883)];
- char application_data [ISODCL (884, 1395)];
- char unused5 [ISODCL (1396, 2048)];
-};
-#define ISO_DEFAULT_BLOCK_SIZE 2048
-
-/*
- * Used by Microsoft Joliet extension to ISO9660. Almost the same
- * as PVD, but byte position 8 is a flag, and 89-120 is for escape.
- */
-
-struct iso_supplementary_descriptor {
- char type [ISODCL ( 1, 1)]; /* 711 */
- char id [ISODCL ( 2, 6)];
- char version [ISODCL ( 7, 7)]; /* 711 */
- char flags [ISODCL ( 8, 8)]; /* 711? */
- char system_id [ISODCL ( 9, 40)]; /* achars */
- char volume_id [ISODCL ( 41, 72)]; /* dchars */
- char unused2 [ISODCL ( 73, 80)];
- char volume_space_size [ISODCL ( 81, 88)]; /* 733 */
- char escape [ISODCL ( 89, 120)];
- char volume_set_size [ISODCL (121, 124)]; /* 723 */
- char volume_sequence_number [ISODCL (125, 128)]; /* 723 */
- char logical_block_size [ISODCL (129, 132)]; /* 723 */
- char path_table_size [ISODCL (133, 140)]; /* 733 */
- char type_l_path_table [ISODCL (141, 144)]; /* 731 */
- char opt_type_l_path_table [ISODCL (145, 148)]; /* 731 */
- char type_m_path_table [ISODCL (149, 152)]; /* 732 */
- char opt_type_m_path_table [ISODCL (153, 156)]; /* 732 */
- char root_directory_record [ISODCL (157, 190)]; /* 9.1 */
- char volume_set_id [ISODCL (191, 318)]; /* dchars */
- char publisher_id [ISODCL (319, 446)]; /* achars */
- char preparer_id [ISODCL (447, 574)]; /* achars */
- char application_id [ISODCL (575, 702)]; /* achars */
- char copyright_file_id [ISODCL (703, 739)]; /* 7.5 dchars */
- char abstract_file_id [ISODCL (740, 776)]; /* 7.5 dchars */
- char bibliographic_file_id [ISODCL (777, 813)]; /* 7.5 dchars */
- char creation_date [ISODCL (814, 830)]; /* 8.4.26.1 */
- char modification_date [ISODCL (831, 847)]; /* 8.4.26.1 */
- char expiration_date [ISODCL (848, 864)]; /* 8.4.26.1 */
- char effective_date [ISODCL (865, 881)]; /* 8.4.26.1 */
- char file_structure_version [ISODCL (882, 882)]; /* 711 */
- char unused4 [ISODCL (883, 883)];
- char application_data [ISODCL (884, 1395)];
- char unused5 [ISODCL (1396, 2048)];
-};
-
-struct iso_sierra_primary_descriptor {
- char unknown1 [ISODCL ( 1, 8)]; /* 733 */
- char type [ISODCL ( 9, 9)]; /* 711 */
- char id [ISODCL ( 10, 14)];
- char version [ISODCL ( 15, 15)]; /* 711 */
- char unused1 [ISODCL ( 16, 16)];
- char system_id [ISODCL ( 17, 48)]; /* achars */
- char volume_id [ISODCL ( 49, 80)]; /* dchars */
- char unused2 [ISODCL ( 81, 88)];
- char volume_space_size [ISODCL ( 89, 96)]; /* 733 */
- char unused3 [ISODCL ( 97, 128)];
- char volume_set_size [ISODCL (129, 132)]; /* 723 */
- char volume_sequence_number [ISODCL (133, 136)]; /* 723 */
- char logical_block_size [ISODCL (137, 140)]; /* 723 */
- char path_table_size [ISODCL (141, 148)]; /* 733 */
- char type_l_path_table [ISODCL (149, 152)]; /* 731 */
- char opt_type_l_path_table [ISODCL (153, 156)]; /* 731 */
- char unknown2 [ISODCL (157, 160)]; /* 731 */
- char unknown3 [ISODCL (161, 164)]; /* 731 */
- char type_m_path_table [ISODCL (165, 168)]; /* 732 */
- char opt_type_m_path_table [ISODCL (169, 172)]; /* 732 */
- char unknown4 [ISODCL (173, 176)]; /* 732 */
- char unknown5 [ISODCL (177, 180)]; /* 732 */
- char root_directory_record [ISODCL (181, 214)]; /* 9.1 */
- char volume_set_id [ISODCL (215, 342)]; /* dchars */
- char publisher_id [ISODCL (343, 470)]; /* achars */
- char preparer_id [ISODCL (471, 598)]; /* achars */
- char application_id [ISODCL (599, 726)]; /* achars */
- char copyright_id [ISODCL (727, 790)]; /* achars */
- char creation_date [ISODCL (791, 806)]; /* ? */
- char modification_date [ISODCL (807, 822)]; /* ? */
- char expiration_date [ISODCL (823, 838)]; /* ? */
- char effective_date [ISODCL (839, 854)]; /* ? */
- char file_structure_version [ISODCL (855, 855)]; /* 711 */
- char unused4 [ISODCL (856, 2048)];
-};
-
-struct iso_directory_record {
- char length [ISODCL (1, 1)]; /* 711 */
- char ext_attr_length [ISODCL (2, 2)]; /* 711 */
- u_char extent [ISODCL (3, 10)]; /* 733 */
- u_char size [ISODCL (11, 18)]; /* 733 */
- char date [ISODCL (19, 25)]; /* 7 by 711 */
- char flags [ISODCL (26, 26)];
- char file_unit_size [ISODCL (27, 27)]; /* 711 */
- char interleave [ISODCL (28, 28)]; /* 711 */
- char volume_sequence_number [ISODCL (29, 32)]; /* 723 */
- char name_len [ISODCL (33, 33)]; /* 711 */
- char name [1]; /* XXX */
-};
-/* can't take sizeof(iso_directory_record), because of possible alignment
- of the last entry (34 instead of 33) */
-#define ISO_DIRECTORY_RECORD_SIZE 33
-
-struct iso_extended_attributes {
- u_char owner [ISODCL (1, 4)]; /* 723 */
- u_char group [ISODCL (5, 8)]; /* 723 */
- u_char perm [ISODCL (9, 10)]; /* 9.5.3 */
- char ctime [ISODCL (11, 27)]; /* 8.4.26.1 */
- char mtime [ISODCL (28, 44)]; /* 8.4.26.1 */
- char xtime [ISODCL (45, 61)]; /* 8.4.26.1 */
- char ftime [ISODCL (62, 78)]; /* 8.4.26.1 */
- char recfmt [ISODCL (79, 79)]; /* 711 */
- char recattr [ISODCL (80, 80)]; /* 711 */
- u_char reclen [ISODCL (81, 84)]; /* 723 */
- char system_id [ISODCL (85, 116)]; /* achars */
- char system_use [ISODCL (117, 180)];
- char version [ISODCL (181, 181)]; /* 711 */
- char len_esc [ISODCL (182, 182)]; /* 711 */
- char reserved [ISODCL (183, 246)];
- u_char len_au [ISODCL (247, 250)]; /* 723 */
-};
-
-#ifdef _KERNEL
-
-/* CD-ROM Format type */
-enum ISO_FTYPE { ISO_FTYPE_DEFAULT, ISO_FTYPE_9660, ISO_FTYPE_RRIP,
- ISO_FTYPE_JOLIET, ISO_FTYPE_ECMA, ISO_FTYPE_HIGH_SIERRA };
-
-#ifndef ISOFSMNT_ROOT
-#define ISOFSMNT_ROOT 0
-#endif
-
-struct iso_mnt {
- int im_flags;
-
- struct mount *im_mountp;
- dev_t im_dev;
- struct vnode *im_devvp;
-
- int logical_block_size;
- int im_bshift;
- int im_bmask;
-
- int volume_space_size;
- struct netexport im_export;
-
- char root[ISODCL (157, 190)];
- int root_extent;
- int root_size;
- enum ISO_FTYPE iso_ftype;
-
- int rr_skip;
- int rr_skip0;
-
- int joliet_level;
-};
-
-#define VFSTOISOFS(mp) ((struct iso_mnt *)((mp)->mnt_data))
-
-#define blkoff(imp, loc) ((loc) & (imp)->im_bmask)
-#define lblktosize(imp, blk) ((blk) << (imp)->im_bshift)
-#define lblkno(imp, loc) ((loc) >> (imp)->im_bshift)
-#define blksize(imp, ip, lbn) ((imp)->logical_block_size)
-
-int cd9660_vget_internal __P((struct mount *, ino_t, struct vnode **, int,
- struct iso_directory_record *));
-int cd9660_init __P((struct vfsconf *));
-#define cd9660_sysctl ((int (*) __P((int *, u_int, void *, size_t *, void *, \
- size_t, struct proc *)))eopnotsupp)
-
-extern vop_t **cd9660_vnodeop_p;
-extern vop_t **cd9660_specop_p;
-extern vop_t **cd9660_fifoop_p;
-
-int isochar __P((u_char *, u_char *, int, u_char *));
-int isofncmp __P((u_char *, int, u_char *, int, int));
-void isofntrans __P((u_char *, int, u_char *, u_short *, int, int, int));
-ino_t isodirino __P((struct iso_directory_record *, struct iso_mnt *));
-
-#endif /* _KERNEL */
-
-/*
- * The isonum_xxx functions are inlined anyway, and could come handy even
- * outside the kernel. Thus we don't hide them here.
- */
-
-static __inline int isonum_711 __P((u_char *));
-static __inline int
-isonum_711(p)
- u_char *p;
-{
- return *p;
-}
-
-static __inline int isonum_712 __P((char *));
-static __inline int
-isonum_712(p)
- char *p;
-{
- return *p;
-}
-
-#ifndef UNALIGNED_ACCESS
-
-static __inline int isonum_723 __P((u_char *));
-static __inline int
-isonum_723(p)
- u_char *p;
-{
- return *p|(p[1] << 8);
-}
-
-static __inline int isonum_733 __P((u_char *));
-static __inline int
-isonum_733(p)
- u_char *p;
-{
- return *p|(p[1] << 8)|(p[2] << 16)|(p[3] << 24);
-}
-
-#else /* UNALIGNED_ACCESS */
-
-#if BYTE_ORDER == LITTLE_ENDIAN
-
-static __inline int
-isonum_723(p)
- u_char *p
-{
- return *(u_int16t *)p;
-}
-
-static __inline int
-isonum_733(p)
- u_char *p;
-{
- return *(u_int32t *)p;
-}
-
-#endif
-
-#if BYTE_ORDER == BIG_ENDIAN
-
-static __inline int
-isonum_723(p)
- u_char *p
-{
- return *(u_int16t *)(p + 2);
-}
-
-static __inline int
-isonum_733(p)
- u_char *p;
-{
- return *(u_int32t *)(p + 4);
-}
-
-#endif
-
-#endif /* UNALIGNED_ACCESS */
-
-/*
- * Associated files have a leading '='.
- */
-#define ASSOCCHAR '='
diff --git a/sys/fs/cd9660/iso_rrip.h b/sys/fs/cd9660/iso_rrip.h
deleted file mode 100644
index 0c06e98825ce..000000000000
--- a/sys/fs/cd9660/iso_rrip.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*-
- * Copyright (c) 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley
- * by Pace Willisson (pace@blitz.com). The Rock Ridge Extension
- * Support code is derived from software contributed to Berkeley
- * by Atsushi Murai (amurai@spec.co.jp).
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)iso_rrip.h 8.2 (Berkeley) 1/23/94
- * $FreeBSD$
- */
-
-
-/*
- * Analyze function flag (similar to RR field bits)
- */
-#define ISO_SUSP_ATTR 0x0001
-#define ISO_SUSP_DEVICE 0x0002
-#define ISO_SUSP_SLINK 0x0004
-#define ISO_SUSP_ALTNAME 0x0008
-#define ISO_SUSP_CLINK 0x0010
-#define ISO_SUSP_PLINK 0x0020
-#define ISO_SUSP_RELDIR 0x0040
-#define ISO_SUSP_TSTAMP 0x0080
-#define ISO_SUSP_IDFLAG 0x0100
-#define ISO_SUSP_EXTREF 0x0200
-#define ISO_SUSP_CONT 0x0400
-#define ISO_SUSP_OFFSET 0x0800
-#define ISO_SUSP_STOP 0x1000
-#define ISO_SUSP_UNKNOWN 0x8000
-
-typedef struct {
- struct iso_node *inop;
- int fields; /* interesting fields in this analysis */
- daddr_t iso_ce_blk; /* block of continuation area */
- off_t iso_ce_off; /* offset of continuation area */
- int iso_ce_len; /* length of continuation area */
- struct iso_mnt *imp; /* mount structure */
- ino_t *inump; /* inode number pointer */
- char *outbuf; /* name/symbolic link output area */
- u_short *outlen; /* length of above */
- u_short maxlen; /* maximum length of above */
- int cont; /* continuation of above */
-} ISO_RRIP_ANALYZE;
-
-struct iso_directory_record;
-
-int cd9660_rrip_analyze __P((struct iso_directory_record *isodir,
- struct iso_node *inop, struct iso_mnt *imp));
-int cd9660_rrip_getname __P((struct iso_directory_record *isodir,
- char *outbuf, u_short *outlen,
- ino_t *inump, struct iso_mnt *imp));
-int cd9660_rrip_getsymname __P((struct iso_directory_record *isodir,
- char *outbuf, u_short *outlen,
- struct iso_mnt *imp));
-int cd9660_rrip_offset __P((struct iso_directory_record *isodir,
- struct iso_mnt *imp));
diff --git a/sys/fs/coda/README b/sys/fs/coda/README
deleted file mode 100644
index f9bf3c35cdc6..000000000000
--- a/sys/fs/coda/README
+++ /dev/null
@@ -1,60 +0,0 @@
- Announcing the Availability of the
- Coda Distributed
- Filesystem
- for
- BSD Unix Systems
-
- Coda is a distributed file system like NFS and AFS. It is
-freely available, like NFS. But it functions much like AFS in being a
-"stateful" file system. Coda and AFS cache files on your local
-machine to improve performance. But Coda goes a step further than AFS
-by letting you access the cached files when there is no available
-network, viz. disconnected laptops and network outages. In Coda, both
-the client and server are outside the kernel which makes them easier
-to experiment with.
-
-To get more information on Coda, I would like to refer people to
- http://www.coda.cs.cmu.edu
-There is a wealth of documents, papers, and theses there. There is
-also a good introduction to the Coda File System in
- http://www.coda.cs.cmu.edu/ljpaper/lj.html
-
-Coda was originally developed as an academic prototype/testbed. It is
-being polished and rewritten where necessary. Coda is a work in
-progress and does have bugs. It is, though, very usable. Our
-interest is in making Coda available to as many people as possible and
-to have Coda evolve and flourish.
-
-The bulk of the Coda file system code supports the Coda client
-program, the Coda server program and the utilities needed by both.
-All these programs are unix programs and can run equally well on any
-Unix platform. Our main development thrust is improving these
-programs. There is a small part of Coda that deals with the kernel to
-file system interface. This code is OS specific (but should not be
-platform specific).
-
-Coda is currently available for several OS's and platforms:
- Freebsd-2.2.5: i386
- Freebsd-2.2.6: i386
- Freebsd -current: i386
- linux 2.0: i386 & sparc
- linux 2.1: i386 & sparc
- NetBSD 1.3: i386
- NetBSD -current: i386
-The relevant sources, binaries, and docs can be found in
- ftp://ftp.coda.cs.cmu.edu/pub/coda/
-
-We intend to come out with new Coda releases often, not daily. We
-don't want to slight any OS/platform not mentioned above. We are just
-limited in our resources as to what we can support internally. We
-will be happy to integrate OpenBSD support as well as other OS
-support. Also, adding platform support should be relatively easy and
-we can discuss this. The only difficulty is that Coda has a light weight
-process package. It does some manipulations in assembler which would
-have to be redone for a different platform.
-
-There are several mailing lists @coda.cs.cmu.edu that discuss coda:
-coda-announce and linux-coda. We are going to revise linux-coda to be
-OS neutral, since it is mainly Coda we want to discuss. We appreciate
-comments, feedback, bug reports, bug fixes, enhancements, etc.
-
diff --git a/sys/fs/coda/TODO b/sys/fs/coda/TODO
deleted file mode 100644
index eac514394b38..000000000000
--- a/sys/fs/coda/TODO
+++ /dev/null
@@ -1,17 +0,0 @@
-OOPS:
- FreeBSD does not fsync!!!
-
-Near term:
- Fix bug in executing/mapping new files.
- cfs_mount bug: interaction with cfs_inactive no cfs_unsave.
- vref/vn_lock == vget except no VXWANT which may be on.
- Review locks: vn_lock/VOP_UNLOCK/lockmgr ...
-
-Medium term:
- Add missing VFS methods.
- Do performance profile.
- Tune hash algorithm used in cfs_namecache.
- Tune hash algorithm used in cfs_subr.
-
-Eventually:
- Use standard queue macros.
diff --git a/sys/fs/coda/cnode.h b/sys/fs/coda/cnode.h
deleted file mode 100644
index 75d29acc22ed..000000000000
--- a/sys/fs/coda/cnode.h
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- *
- * Coda: an Experimental Distributed File System
- * Release 3.1
- *
- * Copyright (c) 1987-1998 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, and
- * that credit is given to Carnegie Mellon University in all documents
- * and publicity pertaining to direct or indirect use of this code or its
- * derivatives.
- *
- * CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS KNOWN TO HAVE BUGS,
- * SOME OF WHICH MAY HAVE SERIOUS CONSEQUENCES. 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 DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE OR OF
- * ANY DERIVATIVE WORK.
- *
- * Carnegie Mellon encourages users of this software to return any
- * improvements or extensions that they make, and to grant Carnegie
- * Mellon the rights to redistribute these changes without encumbrance.
- *
- * @(#) src/sys/coda/cnode.h,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $
- * $FreeBSD$
- *
- */
-
-/*
- * Mach Operating System
- * Copyright (c) 1990 Carnegie-Mellon University
- * Copyright (c) 1989 Carnegie-Mellon University
- * All rights reserved. The CMU software License Agreement specifies
- * the terms and conditions for use and redistribution.
- */
-
-/*
- * This code was written for the Coda file system at Carnegie Mellon University.
- * Contributers include David Steere, James Kistler, and M. Satyanarayanan.
- */
-
-#ifndef _CNODE_H_
-#define _CNODE_H_
-
-#include <sys/vnode.h>
-#include <sys/lock.h>
-#include <machine/clock.h>
-
-MALLOC_DECLARE(M_CODA);
-
-/*
- * tmp below since we need struct queue
- */
-#include <coda/coda_kernel.h>
-
-/*
- * Cnode lookup stuff.
- * NOTE: CODA_CACHESIZE must be a power of 2 for cfshash to work!
- */
-#define CODA_CACHESIZE 512
-
-#define CODA_ALLOC(ptr, cast, size) \
-do { \
- ptr = (cast)malloc((unsigned long) size, M_CODA, M_WAITOK); \
- if (ptr == 0) { \
- panic("kernel malloc returns 0 at %s:%d\n", __FILE__, __LINE__); \
- } \
-} while (0)
-
-#define CODA_FREE(ptr, size) free((ptr), M_CODA)
-
-/*
- * global cache state control
- */
-extern int coda_nc_use;
-
-/*
- * Used to select debugging statements throughout the cfs code.
- */
-extern int codadebug;
-extern int coda_nc_debug;
-extern int coda_printf_delay;
-extern int coda_vnop_print_entry;
-extern int coda_psdev_print_entry;
-extern int coda_vfsop_print_entry;
-
-#define CODADBGMSK(N) (1 << N)
-#define CODADEBUG(N, STMT) { if (codadebug & CODADBGMSK(N)) { STMT } }
-#define myprintf(args) \
-do { \
- if (coda_printf_delay) \
- DELAY(coda_printf_delay);\
- printf args ; \
-} while (0)
-
-struct cnode {
- struct vnode *c_vnode;
- u_short c_flags; /* flags (see below) */
- ViceFid c_fid; /* file handle */
- struct lock c_lock; /* new lock protocol */
- struct vnode *c_ovp; /* open vnode pointer */
- u_short c_ocount; /* count of openers */
- u_short c_owrite; /* count of open for write */
- struct vattr c_vattr; /* attributes */
- char *c_symlink; /* pointer to symbolic link */
- u_short c_symlen; /* length of symbolic link */
- dev_t c_device; /* associated vnode device */
- ino_t c_inode; /* associated vnode inode */
- struct cnode *c_next; /* links if on NetBSD machine */
-};
-#define VTOC(vp) ((struct cnode *)(vp)->v_data)
-#define CTOV(cp) ((struct vnode *)((cp)->c_vnode))
-
-/* flags */
-#define C_VATTR 0x01 /* Validity of vattr in the cnode */
-#define C_SYMLINK 0x02 /* Validity of symlink pointer in the Code */
-#define C_WANTED 0x08 /* Set if lock wanted */
-#define C_LOCKED 0x10 /* Set if lock held */
-#define C_UNMOUNTING 0X20 /* Set if unmounting */
-#define C_PURGING 0x40 /* Set if purging a fid */
-
-#define VALID_VATTR(cp) ((cp->c_flags) & C_VATTR)
-#define VALID_SYMLINK(cp) ((cp->c_flags) & C_SYMLINK)
-#define IS_UNMOUNTING(cp) ((cp)->c_flags & C_UNMOUNTING)
-
-struct vcomm {
- u_long vc_seq;
- struct selinfo vc_selproc;
- struct queue vc_requests;
- struct queue vc_replys;
-};
-
-#define VC_OPEN(vcp) ((vcp)->vc_requests.forw != NULL)
-#define MARK_VC_CLOSED(vcp) (vcp)->vc_requests.forw = NULL;
-#define MARK_VC_OPEN(vcp) /* MT */
-
-struct coda_clstat {
- int ncalls; /* client requests */
- int nbadcalls; /* upcall failures */
- int reqs[CODA_NCALLS]; /* count of each request */
-};
-extern struct coda_clstat coda_clstat;
-
-/*
- * CODA structure to hold mount/file system information
- */
-struct coda_mntinfo {
- struct vnode *mi_rootvp;
- struct mount *mi_vfsp;
- struct vcomm mi_vcomm;
-};
-extern struct coda_mntinfo coda_mnttbl[]; /* indexed by minor device number */
-
-/*
- * vfs pointer to mount info
- */
-#define vftomi(vfsp) ((struct coda_mntinfo *)(vfsp->mnt_data))
-#define CODA_MOUNTED(vfsp) (vftomi((vfsp)) != (struct coda_mntinfo *)0)
-
-/*
- * vnode pointer to mount info
- */
-#define vtomi(vp) ((struct coda_mntinfo *)(vp->v_mount->mnt_data))
-
-/*
- * Used for identifying usage of "Control" object
- */
-extern struct vnode *coda_ctlvp;
-#define IS_CTL_VP(vp) ((vp) == coda_ctlvp)
-#define IS_CTL_NAME(vp, name, l)((l == CODA_CONTROLLEN) \
- && ((vp) == vtomi((vp))->mi_rootvp) \
- && strncmp(name, CODA_CONTROL, l) == 0)
-
-/*
- * An enum to tell us whether something that will remove a reference
- * to a cnode was a downcall or not
- */
-enum dc_status {
- IS_DOWNCALL = 6,
- NOT_DOWNCALL = 7
-};
-
-/* cfs_psdev.h */
-extern int coda_call(struct coda_mntinfo *mntinfo, int inSize, int *outSize, caddr_t buffer);
-extern int coda_kernel_version;
-
-/* cfs_subr.h */
-extern int handleDownCall(int opcode, union outputArgs *out);
-extern void coda_unmounting(struct mount *whoIam);
-extern int coda_vmflush(struct cnode *cp);
-
-/* cfs_vnodeops.h */
-extern struct cnode *make_coda_node(ViceFid *fid, struct mount *vfsp, short type);
-extern int coda_vnodeopstats_init(void);
-
-/* coda_vfsops.h */
-extern struct mount *devtomp(dev_t dev);
-
-/* sigh */
-#define CODA_RDWR ((u_long) 31)
-
-#endif /* _CNODE_H_ */
-
diff --git a/sys/fs/coda/coda.h b/sys/fs/coda/coda.h
deleted file mode 100644
index 2e59cfcf7d21..000000000000
--- a/sys/fs/coda/coda.h
+++ /dev/null
@@ -1,761 +0,0 @@
-/*
- *
- * Coda: an Experimental Distributed File System
- * Release 3.1
- *
- * Copyright (c) 1987-1998 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, and
- * that credit is given to Carnegie Mellon University in all documents
- * and publicity pertaining to direct or indirect use of this code or its
- * derivatives.
- *
- * CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS KNOWN TO HAVE BUGS,
- * SOME OF WHICH MAY HAVE SERIOUS CONSEQUENCES. 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 DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE OR OF
- * ANY DERIVATIVE WORK.
- *
- * Carnegie Mellon encourages users of this software to return any
- * improvements or extensions that they make, and to grant Carnegie
- * Mellon the rights to redistribute these changes without encumbrance.
- *
- * @(#) src/sys/coda/coda.h,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $
- * $FreeBSD$
- *
- */
-
-
-/*
- *
- * Based on cfs.h from Mach, but revamped for increased simplicity.
- * Linux modifications by Peter Braam, Aug 1996
- */
-
-#ifndef _CODA_HEADER_
-#define _CODA_HEADER_
-
-
-
-/* Catch new _KERNEL defn for NetBSD */
-#ifdef __NetBSD__
-#include <sys/types.h>
-#endif
-
-#ifndef CODA_MAXSYMLINKS
-#define CODA_MAXSYMLINKS 10
-#endif
-
-#if defined(DJGPP) || defined(__CYGWIN32__)
-#ifdef _KERNEL
-typedef unsigned long u_long;
-typedef unsigned int u_int;
-typedef unsigned short u_short;
-typedef u_long ino_t;
-typedef u_long dev_t;
-typedef void * caddr_t;
-#ifdef DOS
-typedef unsigned __int64 u_quad_t;
-#else
-typedef unsigned long long u_quad_t;
-#endif
-
-#define inline
-
-struct timespec {
- long ts_sec;
- long ts_nsec;
-};
-#else /* DJGPP but not _KERNEL */
-#include <sys/types.h>
-#include <sys/time.h>
-typedef unsigned long long u_quad_t;
-#endif /* !_KERNEL */
-#endif /* !DJGPP */
-
-
-#if defined(__linux__)
-#define cdev_t u_quad_t
-#if !defined(_UQUAD_T_) && (!defined(__GLIBC__) || __GLIBC__ < 2)
-#define _UQUAD_T_ 1
-typedef unsigned long long u_quad_t;
-#endif
-#else
-#define cdev_t udev_t
-#endif
-
-#ifdef __CYGWIN32__
-typedef unsigned char u_int8_t;
-struct timespec {
- time_t tv_sec; /* seconds */
- long tv_nsec; /* nanoseconds */
-};
-#endif
-
-
-/*
- * Cfs constants
- */
-#define CODA_MAXNAMLEN 255
-#define CODA_MAXPATHLEN 1024
-#define CODA_MAXSYMLINK 10
-
-/* these are Coda's version of O_RDONLY etc combinations
- * to deal with VFS open modes
- */
-#define C_O_READ 0x001
-#define C_O_WRITE 0x002
-#define C_O_TRUNC 0x010
-#define C_O_EXCL 0x100
-#define C_O_CREAT 0x200
-
-/* these are to find mode bits in Venus */
-#define C_M_READ 00400
-#define C_M_WRITE 00200
-
-/* for access Venus will use */
-#define C_A_C_OK 8 /* Test for writing upon create. */
-#define C_A_R_OK 4 /* Test for read permission. */
-#define C_A_W_OK 2 /* Test for write permission. */
-#define C_A_X_OK 1 /* Test for execute permission. */
-#define C_A_F_OK 0 /* Test for existence. */
-
-
-
-#ifndef _VENUS_DIRENT_T_
-#define _VENUS_DIRENT_T_ 1
-struct venus_dirent {
- unsigned long d_fileno; /* file number of entry */
- unsigned short d_reclen; /* length of this record */
- char d_type; /* file type, see below */
- char d_namlen; /* length of string in d_name */
- char d_name[CODA_MAXNAMLEN + 1];/* name must be no longer than this */
-};
-#undef DIRSIZ
-#define DIRSIZ(dp) ((sizeof (struct venus_dirent) - (CODA_MAXNAMLEN+1)) + \
- (((dp)->d_namlen+1 + 3) &~ 3))
-
-/*
- * File types
- */
-#define CDT_UNKNOWN 0
-#define CDT_FIFO 1
-#define CDT_CHR 2
-#define CDT_DIR 4
-#define CDT_BLK 6
-#define CDT_REG 8
-#define CDT_LNK 10
-#define CDT_SOCK 12
-#define CDT_WHT 14
-
-/*
- * Convert between stat structure types and directory types.
- */
-#define IFTOCDT(mode) (((mode) & 0170000) >> 12)
-#define CDTTOIF(dirtype) ((dirtype) << 12)
-
-#endif
-
-#ifndef _FID_T_
-#define _FID_T_ 1
-typedef u_long VolumeId;
-typedef u_long VnodeId;
-typedef u_long Unique_t;
-typedef u_long FileVersion;
-#endif
-
-#ifndef _VICEFID_T_
-#define _VICEFID_T_ 1
-typedef struct ViceFid {
- VolumeId Volume;
- VnodeId Vnode;
- Unique_t Unique;
-} ViceFid;
-#endif /* VICEFID */
-
-
-#ifdef __linux__
-static __inline__ ino_t coda_f2i(struct ViceFid *fid)
-{
- if ( ! fid )
- return 0;
- if (fid->Vnode == 0xfffffffe || fid->Vnode == 0xffffffff)
- return ((fid->Volume << 20) | (fid->Unique & 0xfffff));
- else
- return (fid->Unique + (fid->Vnode<<10) + (fid->Volume<<20));
-}
-
-#else
-#define coda_f2i(fid)\
- ((fid) ? ((fid)->Unique + ((fid)->Vnode<<10) + ((fid)->Volume<<20)) : 0)
-#endif
-
-
-#ifndef __BIT_TYPES_DEFINED__
-#define u_int32_t unsigned int
-#endif
-
-
-#ifndef _VUID_T_
-#define _VUID_T_
-typedef u_int32_t vuid_t;
-typedef u_int32_t vgid_t;
-#endif /*_VUID_T_ */
-
-#ifndef _CODACRED_T_
-#define _CODACRED_T_
-struct coda_cred {
- vuid_t cr_uid, cr_euid, cr_suid, cr_fsuid; /* Real, efftve, set, fs uid*/
- vgid_t cr_groupid, cr_egid, cr_sgid, cr_fsgid; /* same for groups */
-};
-#endif
-
-#ifndef _VENUS_VATTR_T_
-#define _VENUS_VATTR_T_
-/*
- * Vnode types. VNON means no type.
- */
-enum coda_vtype { C_VNON, C_VREG, C_VDIR, C_VBLK, C_VCHR, C_VLNK, C_VSOCK, C_VFIFO, C_VBAD };
-
-struct coda_vattr {
- int va_type; /* vnode type (for create) */
- u_short va_mode; /* files access mode and type */
- short va_nlink; /* number of references to file */
- vuid_t va_uid; /* owner user id */
- vgid_t va_gid; /* owner group id */
- long va_fileid; /* file id */
- u_quad_t va_size; /* file size in bytes */
- long va_blocksize; /* blocksize preferred for i/o */
- struct timespec va_atime; /* time of last access */
- struct timespec va_mtime; /* time of last modification */
- struct timespec va_ctime; /* time file changed */
- u_long va_gen; /* generation number of file */
- u_long va_flags; /* flags defined for file */
- cdev_t va_rdev; /* device special file represents */
- u_quad_t va_bytes; /* bytes of disk space held by file */
- u_quad_t va_filerev; /* file modification number */
-};
-
-#endif
-
-/*
- * Kernel <--> Venus communications.
- */
-
-#define CODA_ROOT 2
-#define CODA_SYNC 3
-#define CODA_OPEN 4
-#define CODA_CLOSE 5
-#define CODA_IOCTL 6
-#define CODA_GETATTR 7
-#define CODA_SETATTR 8
-#define CODA_ACCESS 9
-#define CODA_LOOKUP 10
-#define CODA_CREATE 11
-#define CODA_REMOVE 12
-#define CODA_LINK 13
-#define CODA_RENAME 14
-#define CODA_MKDIR 15
-#define CODA_RMDIR 16
-#define CODA_READDIR 17
-#define CODA_SYMLINK 18
-#define CODA_READLINK 19
-#define CODA_FSYNC 20
-#define CODA_INACTIVE 21
-#define CODA_VGET 22
-#define CODA_SIGNAL 23
-#define CODA_REPLACE 24
-#define CODA_FLUSH 25
-#define CODA_PURGEUSER 26
-#define CODA_ZAPFILE 27
-#define CODA_ZAPDIR 28
-#define CODA_PURGEFID 30
-#define CODA_OPEN_BY_PATH 31
-#define CODA_RESOLVE 32
-#define CODA_REINTEGRATE 33
-#define CODA_NCALLS 34
-
-#define DOWNCALL(opcode) (opcode >= CODA_REPLACE && opcode <= CODA_PURGEFID)
-
-#define VC_MAXDATASIZE 8192
-#define VC_MAXMSGSIZE sizeof(union inputArgs)+sizeof(union outputArgs) +\
- VC_MAXDATASIZE
-
-#define CIOC_KERNEL_VERSION _IOWR('c', 10, sizeof (int))
-#if 0
- /* don't care about kernel version number */
-#define CODA_KERNEL_VERSION 0
- /* The old venus 4.6 compatible interface */
-#define CODA_KERNEL_VERSION 1
-#endif
- /* venus_lookup gets an extra parameter to aid windows.*/
-#define CODA_KERNEL_VERSION 2
-
-/*
- * Venus <-> Coda RPC arguments
- */
-struct coda_in_hdr {
- unsigned long opcode;
- unsigned long unique; /* Keep multiple outstanding msgs distinct */
- u_short pid; /* Common to all */
- u_short pgid; /* Common to all */
- u_short sid; /* Common to all */
- struct coda_cred cred; /* Common to all */
-};
-
-/* Really important that opcode and unique are 1st two fields! */
-struct coda_out_hdr {
- unsigned long opcode;
- unsigned long unique;
- unsigned long result;
-};
-
-/* coda_root: NO_IN */
-struct coda_root_out {
- struct coda_out_hdr oh;
- ViceFid VFid;
-};
-
-struct coda_root_in {
- struct coda_in_hdr in;
-};
-
-/* coda_sync: */
-/* Nothing needed for coda_sync */
-
-/* coda_open: */
-struct coda_open_in {
- struct coda_in_hdr ih;
- ViceFid VFid;
- int flags;
-};
-
-struct coda_open_out {
- struct coda_out_hdr oh;
- cdev_t dev;
- ino_t inode;
-};
-
-
-/* coda_close: */
-struct coda_close_in {
- struct coda_in_hdr ih;
- ViceFid VFid;
- int flags;
-};
-
-struct coda_close_out {
- struct coda_out_hdr out;
-};
-
-/* coda_ioctl: */
-struct coda_ioctl_in {
- struct coda_in_hdr ih;
- ViceFid VFid;
- int cmd;
- int len;
- int rwflag;
- char *data; /* Place holder for data. */
-};
-
-struct coda_ioctl_out {
- struct coda_out_hdr oh;
- int len;
- caddr_t data; /* Place holder for data. */
-};
-
-
-/* coda_getattr: */
-struct coda_getattr_in {
- struct coda_in_hdr ih;
- ViceFid VFid;
-};
-
-struct coda_getattr_out {
- struct coda_out_hdr oh;
- struct coda_vattr attr;
-};
-
-
-/* coda_setattr: NO_OUT */
-struct coda_setattr_in {
- struct coda_in_hdr ih;
- ViceFid VFid;
- struct coda_vattr attr;
-};
-
-struct coda_setattr_out {
- struct coda_out_hdr out;
-};
-
-/* coda_access: NO_OUT */
-struct coda_access_in {
- struct coda_in_hdr ih;
- ViceFid VFid;
- int flags;
-};
-
-struct coda_access_out {
- struct coda_out_hdr out;
-};
-
-
-/* lookup flags */
-#define CLU_CASE_SENSITIVE 0x01
-#define CLU_CASE_INSENSITIVE 0x02
-
-/* coda_lookup: */
-struct coda_lookup_in {
- struct coda_in_hdr ih;
- ViceFid VFid;
- int name; /* Place holder for data. */
- int flags;
-};
-
-struct coda_lookup_out {
- struct coda_out_hdr oh;
- ViceFid VFid;
- int vtype;
-};
-
-
-/* coda_create: */
-struct coda_create_in {
- struct coda_in_hdr ih;
- ViceFid VFid;
- struct coda_vattr attr;
- int excl;
- int mode;
- int name; /* Place holder for data. */
-};
-
-struct coda_create_out {
- struct coda_out_hdr oh;
- ViceFid VFid;
- struct coda_vattr attr;
-};
-
-
-/* coda_remove: NO_OUT */
-struct coda_remove_in {
- struct coda_in_hdr ih;
- ViceFid VFid;
- int name; /* Place holder for data. */
-};
-
-struct coda_remove_out {
- struct coda_out_hdr out;
-};
-
-/* coda_link: NO_OUT */
-struct coda_link_in {
- struct coda_in_hdr ih;
- ViceFid sourceFid; /* cnode to link *to* */
- ViceFid destFid; /* Directory in which to place link */
- int tname; /* Place holder for data. */
-};
-
-struct coda_link_out {
- struct coda_out_hdr out;
-};
-
-
-/* coda_rename: NO_OUT */
-struct coda_rename_in {
- struct coda_in_hdr ih;
- ViceFid sourceFid;
- int srcname;
- ViceFid destFid;
- int destname;
-};
-
-struct coda_rename_out {
- struct coda_out_hdr out;
-};
-
-/* coda_mkdir: */
-struct coda_mkdir_in {
- struct coda_in_hdr ih;
- ViceFid VFid;
- struct coda_vattr attr;
- int name; /* Place holder for data. */
-};
-
-struct coda_mkdir_out {
- struct coda_out_hdr oh;
- ViceFid VFid;
- struct coda_vattr attr;
-};
-
-
-/* coda_rmdir: NO_OUT */
-struct coda_rmdir_in {
- struct coda_in_hdr ih;
- ViceFid VFid;
- int name; /* Place holder for data. */
-};
-
-struct coda_rmdir_out {
- struct coda_out_hdr out;
-};
-
-/* coda_readdir: */
-struct coda_readdir_in {
- struct coda_in_hdr ih;
- ViceFid VFid;
- int count;
- int offset;
-};
-
-struct coda_readdir_out {
- struct coda_out_hdr oh;
- int size;
- caddr_t data; /* Place holder for data. */
-};
-
-/* coda_symlink: NO_OUT */
-struct coda_symlink_in {
- struct coda_in_hdr ih;
- ViceFid VFid; /* Directory to put symlink in */
- int srcname;
- struct coda_vattr attr;
- int tname;
-};
-
-struct coda_symlink_out {
- struct coda_out_hdr out;
-};
-
-/* coda_readlink: */
-struct coda_readlink_in {
- struct coda_in_hdr ih;
- ViceFid VFid;
-};
-
-struct coda_readlink_out {
- struct coda_out_hdr oh;
- int count;
- caddr_t data; /* Place holder for data. */
-};
-
-
-/* coda_fsync: NO_OUT */
-struct coda_fsync_in {
- struct coda_in_hdr ih;
- ViceFid VFid;
-};
-
-struct coda_fsync_out {
- struct coda_out_hdr out;
-};
-
-/* coda_inactive: NO_OUT */
-struct coda_inactive_in {
- struct coda_in_hdr ih;
- ViceFid VFid;
-};
-
-/* coda_vget: */
-struct coda_vget_in {
- struct coda_in_hdr ih;
- ViceFid VFid;
-};
-
-struct coda_vget_out {
- struct coda_out_hdr oh;
- ViceFid VFid;
- int vtype;
-};
-
-
-/* CODA_SIGNAL is out-of-band, doesn't need data. */
-/* CODA_INVALIDATE is a venus->kernel call */
-/* CODA_FLUSH is a venus->kernel call */
-
-/* coda_purgeuser: */
-/* CODA_PURGEUSER is a venus->kernel call */
-struct coda_purgeuser_out {
- struct coda_out_hdr oh;
- struct coda_cred cred;
-};
-
-/* coda_zapfile: */
-/* CODA_ZAPFILE is a venus->kernel call */
-struct coda_zapfile_out {
- struct coda_out_hdr oh;
- ViceFid CodaFid;
-};
-
-/* coda_zapdir: */
-/* CODA_ZAPDIR is a venus->kernel call */
-struct coda_zapdir_out {
- struct coda_out_hdr oh;
- ViceFid CodaFid;
-};
-
-/* coda_zapnode: */
-/* CODA_ZAPVNODE is a venus->kernel call */
-struct coda_zapvnode_out {
- struct coda_out_hdr oh;
- struct coda_cred cred;
- ViceFid VFid;
-};
-
-/* coda_purgefid: */
-/* CODA_PURGEFID is a venus->kernel call */
-struct coda_purgefid_out {
- struct coda_out_hdr oh;
- ViceFid CodaFid;
-};
-
-/* coda_rdwr: */
-struct coda_rdwr_in {
- struct coda_in_hdr ih;
- ViceFid VFid;
- int rwflag;
- int count;
- int offset;
- int ioflag;
- caddr_t data; /* Place holder for data. */
-};
-
-struct coda_rdwr_out {
- struct coda_out_hdr oh;
- int rwflag;
- int count;
- caddr_t data; /* Place holder for data. */
-};
-
-
-/* coda_replace: */
-/* CODA_REPLACE is a venus->kernel call */
-struct coda_replace_out { /* coda_replace is a venus->kernel call */
- struct coda_out_hdr oh;
- ViceFid NewFid;
- ViceFid OldFid;
-};
-
-/* coda_open_by_path: */
-struct coda_open_by_path_in {
- struct coda_in_hdr ih;
- ViceFid VFid;
- int flags;
-};
-
-struct coda_open_by_path_out {
- struct coda_out_hdr oh;
- int path;
-};
-
-/*
- * Occasionally, we don't cache the fid returned by CODA_LOOKUP.
- * For instance, if the fid is inconsistent.
- * This case is handled by setting the top bit of the type result parameter.
- */
-#define CODA_NOCACHE 0x80000000
-
-union inputArgs {
- struct coda_in_hdr ih; /* NB: every struct below begins with an ih */
- struct coda_open_in coda_open;
- struct coda_close_in coda_close;
- struct coda_ioctl_in coda_ioctl;
- struct coda_getattr_in coda_getattr;
- struct coda_setattr_in coda_setattr;
- struct coda_access_in coda_access;
- struct coda_lookup_in coda_lookup;
- struct coda_create_in coda_create;
- struct coda_remove_in coda_remove;
- struct coda_link_in coda_link;
- struct coda_rename_in coda_rename;
- struct coda_mkdir_in coda_mkdir;
- struct coda_rmdir_in coda_rmdir;
- struct coda_readdir_in coda_readdir;
- struct coda_symlink_in coda_symlink;
- struct coda_readlink_in coda_readlink;
- struct coda_fsync_in coda_fsync;
- struct coda_inactive_in coda_inactive;
- struct coda_vget_in coda_vget;
- struct coda_rdwr_in coda_rdwr;
- struct coda_open_by_path_in coda_open_by_path;
-};
-
-union outputArgs {
- struct coda_out_hdr oh; /* NB: every struct below begins with an oh */
- struct coda_root_out coda_root;
- struct coda_open_out coda_open;
- struct coda_ioctl_out coda_ioctl;
- struct coda_getattr_out coda_getattr;
- struct coda_lookup_out coda_lookup;
- struct coda_create_out coda_create;
- struct coda_mkdir_out coda_mkdir;
- struct coda_readdir_out coda_readdir;
- struct coda_readlink_out coda_readlink;
- struct coda_vget_out coda_vget;
- struct coda_purgeuser_out coda_purgeuser;
- struct coda_zapfile_out coda_zapfile;
- struct coda_zapdir_out coda_zapdir;
- struct coda_zapvnode_out coda_zapvnode;
- struct coda_purgefid_out coda_purgefid;
- struct coda_rdwr_out coda_rdwr;
- struct coda_replace_out coda_replace;
- struct coda_open_by_path_out coda_open_by_path;
-};
-
-union coda_downcalls {
- /* CODA_INVALIDATE is a venus->kernel call */
- /* CODA_FLUSH is a venus->kernel call */
- struct coda_purgeuser_out purgeuser;
- struct coda_zapfile_out zapfile;
- struct coda_zapdir_out zapdir;
- struct coda_zapvnode_out zapvnode;
- struct coda_purgefid_out purgefid;
- struct coda_replace_out replace;
-};
-
-
-/*
- * Used for identifying usage of "Control" and pioctls
- */
-
-#define PIOCPARM_MASK 0x0000ffff
-struct ViceIoctl {
- caddr_t in, out; /* Data to be transferred in, or out */
- short in_size; /* Size of input buffer <= 2K */
- short out_size; /* Maximum size of output buffer, <= 2K */
-};
-
-#if defined(__CYGWIN32__) || defined(DJGPP)
-struct PioctlData {
- unsigned long cmd;
- const char *path;
- int follow;
- struct ViceIoctl vi;
-};
-#else
-struct PioctlData {
- const char *path;
- int follow;
- struct ViceIoctl vi;
-};
-#endif
-
-#define CODA_CONTROL ".CONTROL"
-#define CODA_CONTROLLEN 8
-#define CTL_VOL -1
-#define CTL_VNO -1
-#define CTL_UNI -1
-#define CTL_INO -1
-#define CTL_FILE "/coda/.CONTROL"
-
-
-#define IS_CTL_FID(fidp) ((fidp)->Volume == CTL_VOL &&\
- (fidp)->Vnode == CTL_VNO &&\
- (fidp)->Unique == CTL_UNI)
-#endif
-
diff --git a/sys/fs/coda/coda_fbsd.c b/sys/fs/coda/coda_fbsd.c
deleted file mode 100644
index f7143bdfe298..000000000000
--- a/sys/fs/coda/coda_fbsd.c
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- *
- * Coda: an Experimental Distributed File System
- * Release 3.1
- *
- * Copyright (c) 1987-1998 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, and
- * that credit is given to Carnegie Mellon University in all documents
- * and publicity pertaining to direct or indirect use of this code or its
- * derivatives.
- *
- * CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS KNOWN TO HAVE BUGS,
- * SOME OF WHICH MAY HAVE SERIOUS CONSEQUENCES. 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 DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE OR OF
- * ANY DERIVATIVE WORK.
- *
- * Carnegie Mellon encourages users of this software to return any
- * improvements or extensions that they make, and to grant Carnegie
- * Mellon the rights to redistribute these changes without encumbrance.
- *
- * @(#) src/sys/coda/coda_fbsd.cr,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $
- * $FreeBSD$
- *
- */
-
-#include "vcoda.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/proc.h>
-#include <sys/malloc.h>
-#include <sys/fcntl.h>
-#include <sys/ucred.h>
-#include <sys/vnode.h>
-#include <sys/conf.h>
-
-#include <vm/vm.h>
-#include <vm/vnode_pager.h>
-
-#include <coda/coda.h>
-#include <coda/cnode.h>
-#include <coda/coda_vnops.h>
-#include <coda/coda_psdev.h>
-
-/*
- From: "Jordan K. Hubbard" <jkh@time.cdrom.com>
- Subject: Re: New 3.0 SNAPshot CDROM about ready for production..
- To: "Robert.V.Baron" <rvb@GLUCK.CODA.CS.CMU.EDU>
- Date: Fri, 20 Feb 1998 15:57:01 -0800
-
- > Also I need a character device major number. (and might want to reserve
- > a block of 10 syscalls.)
-
- Just one char device number? No block devices? Very well, cdev 93 is yours!
-*/
-
-#define VC_DEV_NO 93
-
-static struct cdevsw codadevsw = {
- /* open */ vc_nb_open,
- /* close */ vc_nb_close,
- /* read */ vc_nb_read,
- /* write */ vc_nb_write,
- /* ioctl */ vc_nb_ioctl,
- /* poll */ vc_nb_poll,
- /* mmap */ nommap,
- /* strategy */ nostrategy,
- /* name */ "Coda",
- /* maj */ VC_DEV_NO,
- /* dump */ nodump,
- /* psize */ nopsize,
- /* flags */ 0,
- /* bmaj */ -1
-};
-
-int vcdebug = 1;
-#define VCDEBUG if (vcdebug) printf
-
-static int
-codadev_modevent(module_t mod, int type, void *data)
-{
-
- switch (type) {
- case MOD_LOAD:
- cdevsw_add(&codadevsw);
- break;
- case MOD_UNLOAD:
- break;
- default:
- break;
- }
- return 0;
-}
-static moduledata_t codadev_mod = {
- "codadev",
- codadev_modevent,
- NULL
-};
-DECLARE_MODULE(codadev, codadev_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE+VC_DEV_NO);
-
-int
-coda_fbsd_getpages(v)
- void *v;
-{
- struct vop_getpages_args *ap = v;
- int ret = 0;
-
-#if 1
- /* ??? a_offset */
- ret = vnode_pager_generic_getpages(ap->a_vp, ap->a_m, ap->a_count,
- ap->a_reqpage);
- return ret;
-#else
- {
- struct vnode *vp = ap->a_vp;
- struct cnode *cp = VTOC(vp);
- struct vnode *cfvp = cp->c_ovp;
- int opened_internally = 0;
- struct ucred *cred = (struct ucred *) 0;
- struct proc *p = curproc;
- int error = 0;
-
- if (IS_CTL_VP(vp)) {
- return(EINVAL);
- }
-
- /* Redirect the request to UFS. */
-
- if (cfvp == NULL) {
- opened_internally = 1;
-
- error = VOP_OPEN(vp, FREAD, cred, p);
-printf("coda_getp: Internally Opening %p\n", vp);
-
- if (error) {
- printf("coda_getpage: VOP_OPEN on container failed %d\n", error);
- return (error);
- }
- if (vp->v_type == VREG) {
- error = vfs_object_create(vp, p, cred);
- if (error != 0) {
- printf("coda_getpage: vfs_object_create() returns %d\n", error);
- vput(vp);
- return(error);
- }
- }
-
- cfvp = cp->c_ovp;
- } else {
-printf("coda_getp: has container %p\n", cfvp);
- }
-
-printf("coda_fbsd_getpages: using container ");
-/*
- error = vnode_pager_generic_getpages(cfvp, ap->a_m, ap->a_count,
- ap->a_reqpage);
-*/
- error = VOP_GETPAGES(cfvp, ap->a_m, ap->a_count,
- ap->a_reqpage, ap->a_offset);
-printf("error = %d\n", error);
-
- /* Do an internal close if necessary. */
- if (opened_internally) {
- (void)VOP_CLOSE(vp, FREAD, cred, p);
- }
-
- return(error);
- }
-#endif
-}
-
-int
-coda_fbsd_putpages(v)
- void *v;
-{
- struct vop_putpages_args *ap = v;
-
- /*??? a_offset */
- return vnode_pager_generic_putpages(ap->a_vp, ap->a_m, ap->a_count,
- ap->a_sync, ap->a_rtvals);
-}
diff --git a/sys/fs/coda/coda_io.h b/sys/fs/coda/coda_io.h
deleted file mode 100644
index 6620f4f0c32e..000000000000
--- a/sys/fs/coda/coda_io.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- *
- * Coda: an Experimental Distributed File System
- * Release 3.1
- *
- * Copyright (c) 1987-1998 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, and
- * that credit is given to Carnegie Mellon University in all documents
- * and publicity pertaining to direct or indirect use of this code or its
- * derivatives.
- *
- * CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS KNOWN TO HAVE BUGS,
- * SOME OF WHICH MAY HAVE SERIOUS CONSEQUENCES. 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 DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE OR OF
- * ANY DERIVATIVE WORK.
- *
- * Carnegie Mellon encourages users of this software to return any
- * improvements or extensions that they make, and to grant Carnegie
- * Mellon the rights to redistribute these changes without encumbrance.
- *
- * @(#) src/sys/coda/coda_io.h,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $
- * $FreeBSD$
- *
- */
-
-/*
- * Mach Operating System
- * Copyright (c) 1990 Carnegie-Mellon University
- * Copyright (c) 1989 Carnegie-Mellon University
- * All rights reserved. The CMU software License Agreement specifies
- * the terms and conditions for use and redistribution.
- */
-
-/*
- * This code was written for the Coda file system at Carnegie Mellon University.
- * Contributers include David Steere, James Kistler, and M. Satyanarayanan.
- */
-
-#ifndef _CODAIO_H_
-#define _CODAIO_H_
-
-/* Define ioctl commands for vcioctl, /dev/cfs */
-
-#define CODARESIZE _IOW('c', 1, struct coda_resize ) /* Resize CODA NameCache */
-#define CODASTATS _IO('c', 2) /* Collect stats */
-#define CODAPRINT _IO('c', 3) /* Print Cache */
-#define CODATEST _IO('c', 4) /* Print Cache */
-
-struct coda_resize { int hashsize, heapsize; };
-
-#endif
diff --git a/sys/fs/coda/coda_kernel.h b/sys/fs/coda/coda_kernel.h
deleted file mode 100644
index cc0fd957f81c..000000000000
--- a/sys/fs/coda/coda_kernel.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- *
- * Coda: an Experimental Distributed File System
- * Release 3.1
- *
- * Copyright (c) 1987-1998 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, and
- * that credit is given to Carnegie Mellon University in all documents
- * and publicity pertaining to direct or indirect use of this code or its
- * derivatives.
- *
- * CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS KNOWN TO HAVE BUGS,
- * SOME OF WHICH MAY HAVE SERIOUS CONSEQUENCES. 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 DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE OR OF
- * ANY DERIVATIVE WORK.
- *
- * Carnegie Mellon encourages users of this software to return any
- * improvements or extensions that they make, and to grant Carnegie
- * Mellon the rights to redistribute these changes without encumbrance.
- *
- * @(#) src/sys/coda/coda_kernel.h,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $
- * $FreeBSD$
- *
- */
-
-/* Macros to manipulate the queue */
-#ifndef INIT_QUEUE
-struct queue {
- struct queue *forw, *back;
-};
-
-#define INIT_QUEUE(head) \
-do { \
- (head).forw = (struct queue *)&(head); \
- (head).back = (struct queue *)&(head); \
-} while (0)
-
-#define GETNEXT(head) (head).forw
-
-#define EMPTY(head) ((head).forw == &(head))
-
-#define EOQ(el, head) ((struct queue *)(el) == (struct queue *)&(head))
-
-#define INSQUE(el, head) \
-do { \
- (el).forw = ((head).back)->forw; \
- (el).back = (head).back; \
- ((head).back)->forw = (struct queue *)&(el); \
- (head).back = (struct queue *)&(el); \
-} while (0)
-
-#define REMQUE(el) \
-do { \
- ((el).forw)->back = (el).back; \
- (el).back->forw = (el).forw; \
-} while (0)
-
-#endif
diff --git a/sys/fs/coda/coda_namecache.c b/sys/fs/coda/coda_namecache.c
deleted file mode 100644
index 23425b5a13dd..000000000000
--- a/sys/fs/coda/coda_namecache.c
+++ /dev/null
@@ -1,765 +0,0 @@
-/*
- *
- * Coda: an Experimental Distributed File System
- * Release 3.1
- *
- * Copyright (c) 1987-1998 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, and
- * that credit is given to Carnegie Mellon University in all documents
- * and publicity pertaining to direct or indirect use of this code or its
- * derivatives.
- *
- * CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS KNOWN TO HAVE BUGS,
- * SOME OF WHICH MAY HAVE SERIOUS CONSEQUENCES. 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 DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE OR OF
- * ANY DERIVATIVE WORK.
- *
- * Carnegie Mellon encourages users of this software to return any
- * improvements or extensions that they make, and to grant Carnegie
- * Mellon the rights to redistribute these changes without encumbrance.
- *
- * @(#) src/sys/coda/coda_namecache.c,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $
- * $FreeBSD$
- *
- */
-
-/*
- * Mach Operating System
- * Copyright (c) 1990 Carnegie-Mellon University
- * Copyright (c) 1989 Carnegie-Mellon University
- * All rights reserved. The CMU software License Agreement specifies
- * the terms and conditions for use and redistribution.
- */
-
-/*
- * This code was written for the Coda file system at Carnegie Mellon University.
- * Contributers include David Steere, James Kistler, and M. Satyanarayanan.
- */
-
-/*
- * This module contains the routines to implement the CODA name cache. The
- * purpose of this cache is to reduce the cost of translating pathnames
- * into Vice FIDs. Each entry in the cache contains the name of the file,
- * the vnode (FID) of the parent directory, and the cred structure of the
- * user accessing the file.
- *
- * The first time a file is accessed, it is looked up by the local Venus
- * which first insures that the user has access to the file. In addition
- * we are guaranteed that Venus will invalidate any name cache entries in
- * case the user no longer should be able to access the file. For these
- * reasons we do not need to keep access list information as well as a
- * cred structure for each entry.
- *
- * The table can be accessed through the routines cnc_init(), cnc_enter(),
- * cnc_lookup(), cnc_rmfidcred(), cnc_rmfid(), cnc_rmcred(), and cnc_purge().
- * There are several other routines which aid in the implementation of the
- * hash table.
- */
-
-/*
- * NOTES: rvb@cs
- * 1. The name cache holds a reference to every vnode in it. Hence files can not be
- * closed or made inactive until they are released.
- * 2. coda_nc_name(cp) was added to get a name for a cnode pointer for debugging.
- * 3. coda_nc_find() has debug code to detect when entries are stored with different
- * credentials. We don't understand yet, if/how entries are NOT EQ but still
- * EQUAL
- * 4. I wonder if this name cache could be replace by the vnode name cache.
- * The latter has no zapping functions, so probably not.
- */
-
-#include <sys/param.h>
-#include <sys/errno.h>
-#include <sys/malloc.h>
-#include <sys/ucred.h>
-#include <sys/select.h>
-
-#ifndef insque
-#include <sys/systm.h>
-#endif /* insque */
-
-#include <vm/vm.h>
-#include <vm/vm_object.h>
-
-#include <coda/coda.h>
-#include <coda/cnode.h>
-#include <coda/coda_namecache.h>
-
-#ifdef DEBUG
-#include <coda/coda_vnops.h>
-#endif
-
-/*
- * Declaration of the name cache data structure.
- */
-
-int coda_nc_use = 1; /* Indicate use of CODA Name Cache */
-int coda_nc_size = CODA_NC_CACHESIZE; /* size of the cache */
-int coda_nc_hashsize = CODA_NC_HASHSIZE; /* size of the primary hash */
-
-struct coda_cache *coda_nc_heap; /* pointer to the cache entries */
-struct coda_hash *coda_nc_hash; /* hash table of coda_cache pointers */
-struct coda_lru coda_nc_lru; /* head of lru chain */
-
-struct coda_nc_statistics coda_nc_stat; /* Keep various stats */
-
-/*
- * for testing purposes
- */
-int coda_nc_debug = 0;
-
-/*
- * Entry points for the CODA Name Cache
- */
-static struct coda_cache *coda_nc_find(struct cnode *dcp, const char *name, int namelen,
- struct ucred *cred, int hash);
-static void coda_nc_remove(struct coda_cache *cncp, enum dc_status dcstat);
-
-/*
- * Initialize the cache, the LRU structure and the Hash structure(s)
- */
-
-#define TOTAL_CACHE_SIZE (sizeof(struct coda_cache) * coda_nc_size)
-#define TOTAL_HASH_SIZE (sizeof(struct coda_hash) * coda_nc_hashsize)
-
-int coda_nc_initialized = 0; /* Initially the cache has not been initialized */
-
-void
-coda_nc_init(void)
-{
- int i;
-
- /* zero the statistics structure */
-
- bzero(&coda_nc_stat, (sizeof(struct coda_nc_statistics)));
-
-#ifdef CODA_VERBOSE
- printf("CODA NAME CACHE: CACHE %d, HASH TBL %d\n", CODA_NC_CACHESIZE, CODA_NC_HASHSIZE);
-#endif
- CODA_ALLOC(coda_nc_heap, struct coda_cache *, TOTAL_CACHE_SIZE);
- CODA_ALLOC(coda_nc_hash, struct coda_hash *, TOTAL_HASH_SIZE);
-
- coda_nc_lru.lru_next =
- coda_nc_lru.lru_prev = (struct coda_cache *)LRU_PART(&coda_nc_lru);
-
-
- for (i=0; i < coda_nc_size; i++) { /* initialize the heap */
- CODA_NC_LRUINS(&coda_nc_heap[i], &coda_nc_lru);
- CODA_NC_HSHNUL(&coda_nc_heap[i]);
- coda_nc_heap[i].cp = coda_nc_heap[i].dcp = (struct cnode *)0;
- }
-
- for (i=0; i < coda_nc_hashsize; i++) { /* initialize the hashtable */
- CODA_NC_HSHNUL((struct coda_cache *)&coda_nc_hash[i]);
- }
-
- coda_nc_initialized++;
-}
-
-/*
- * Auxillary routines -- shouldn't be entry points
- */
-
-static struct coda_cache *
-coda_nc_find(dcp, name, namelen, cred, hash)
- struct cnode *dcp;
- const char *name;
- int namelen;
- struct ucred *cred;
- int hash;
-{
- /*
- * hash to find the appropriate bucket, look through the chain
- * for the right entry (especially right cred, unless cred == 0)
- */
- struct coda_cache *cncp;
- int count = 1;
-
- CODA_NC_DEBUG(CODA_NC_FIND,
- myprintf(("coda_nc_find(dcp %p, name %s, len %d, cred %p, hash %d\n",
- dcp, name, namelen, cred, hash));)
-
- for (cncp = coda_nc_hash[hash].hash_next;
- cncp != (struct coda_cache *)&coda_nc_hash[hash];
- cncp = cncp->hash_next, count++)
- {
-
- if ((CODA_NAMEMATCH(cncp, name, namelen, dcp)) &&
- ((cred == 0) || (cncp->cred == cred)))
- {
- /* compare cr_uid instead */
- coda_nc_stat.Search_len += count;
- return(cncp);
- }
-#ifdef DEBUG
- else if (CODA_NAMEMATCH(cncp, name, namelen, dcp)) {
- printf("coda_nc_find: name %s, new cred = %p, cred = %p\n",
- name, cred, cncp->cred);
- printf("nref %d, nuid %d, ngid %d // oref %d, ocred %d, ogid %d\n",
- cred->cr_ref, cred->cr_uid, cred->cr_gid,
- cncp->cred->cr_ref, cncp->cred->cr_uid, cncp->cred->cr_gid);
- print_cred(cred);
- print_cred(cncp->cred);
- }
-#endif
- }
-
- return((struct coda_cache *)0);
-}
-
-/*
- * Enter a new (dir cnode, name) pair into the cache, updating the
- * LRU and Hash as needed.
- */
-void
-coda_nc_enter(dcp, name, namelen, cred, cp)
- struct cnode *dcp;
- const char *name;
- int namelen;
- struct ucred *cred;
- struct cnode *cp;
-{
- struct coda_cache *cncp;
- int hash;
-
- if (coda_nc_use == 0) /* Cache is off */
- return;
-
- CODA_NC_DEBUG(CODA_NC_ENTER,
- myprintf(("Enter: dcp %p cp %p name %s cred %p \n",
- dcp, cp, name, cred)); )
-
- if (namelen > CODA_NC_NAMELEN) {
- CODA_NC_DEBUG(CODA_NC_ENTER,
- myprintf(("long name enter %s\n",name));)
- coda_nc_stat.long_name_enters++; /* record stats */
- return;
- }
-
- hash = CODA_NC_HASH(name, namelen, dcp);
- cncp = coda_nc_find(dcp, name, namelen, cred, hash);
- if (cncp != (struct coda_cache *) 0) {
- coda_nc_stat.dbl_enters++; /* duplicate entry */
- return;
- }
-
- coda_nc_stat.enters++; /* record the enters statistic */
-
- /* Grab the next element in the lru chain */
- cncp = CODA_NC_LRUGET(coda_nc_lru);
-
- CODA_NC_LRUREM(cncp); /* remove it from the lists */
-
- if (CODA_NC_VALID(cncp)) {
- /* Seems really ugly, but we have to decrement the appropriate
- hash bucket length here, so we have to find the hash bucket
- */
- coda_nc_hash[CODA_NC_HASH(cncp->name, cncp->namelen, cncp->dcp)].length--;
-
- coda_nc_stat.lru_rm++; /* zapped a valid entry */
- CODA_NC_HSHREM(cncp);
- vrele(CTOV(cncp->dcp));
- vrele(CTOV(cncp->cp));
- crfree(cncp->cred);
- }
-
- /*
- * Put a hold on the current vnodes and fill in the cache entry.
- */
- vref(CTOV(cp));
- vref(CTOV(dcp));
- crhold(cred);
- cncp->dcp = dcp;
- cncp->cp = cp;
- cncp->namelen = namelen;
- cncp->cred = cred;
-
- bcopy(name, cncp->name, (unsigned)namelen);
-
- /* Insert into the lru and hash chains. */
-
- CODA_NC_LRUINS(cncp, &coda_nc_lru);
- CODA_NC_HSHINS(cncp, &coda_nc_hash[hash]);
- coda_nc_hash[hash].length++; /* Used for tuning */
-
- CODA_NC_DEBUG(CODA_NC_PRINTCODA_NC, print_coda_nc(); )
-}
-
-/*
- * Find the (dir cnode, name) pair in the cache, if it's cred
- * matches the input, return it, otherwise return 0
- */
-struct cnode *
-coda_nc_lookup(dcp, name, namelen, cred)
- struct cnode *dcp;
- const char *name;
- int namelen;
- struct ucred *cred;
-{
- int hash;
- struct coda_cache *cncp;
-
- if (coda_nc_use == 0) /* Cache is off */
- return((struct cnode *) 0);
-
- if (namelen > CODA_NC_NAMELEN) {
- CODA_NC_DEBUG(CODA_NC_LOOKUP,
- myprintf(("long name lookup %s\n",name));)
- coda_nc_stat.long_name_lookups++; /* record stats */
- return((struct cnode *) 0);
- }
-
- /* Use the hash function to locate the starting point,
- then the search routine to go down the list looking for
- the correct cred.
- */
-
- hash = CODA_NC_HASH(name, namelen, dcp);
- cncp = coda_nc_find(dcp, name, namelen, cred, hash);
- if (cncp == (struct coda_cache *) 0) {
- coda_nc_stat.misses++; /* record miss */
- return((struct cnode *) 0);
- }
-
- coda_nc_stat.hits++;
-
- /* put this entry at the end of the LRU */
- CODA_NC_LRUREM(cncp);
- CODA_NC_LRUINS(cncp, &coda_nc_lru);
-
- /* move it to the front of the hash chain */
- /* don't need to change the hash bucket length */
- CODA_NC_HSHREM(cncp);
- CODA_NC_HSHINS(cncp, &coda_nc_hash[hash]);
-
- CODA_NC_DEBUG(CODA_NC_LOOKUP,
- printf("lookup: dcp %p, name %s, cred %p = cp %p\n",
- dcp, name, cred, cncp->cp); )
-
- return(cncp->cp);
-}
-
-static void
-coda_nc_remove(cncp, dcstat)
- struct coda_cache *cncp;
- enum dc_status dcstat;
-{
- /*
- * remove an entry -- vrele(cncp->dcp, cp), crfree(cred),
- * remove it from it's hash chain, and
- * place it at the head of the lru list.
- */
- CODA_NC_DEBUG(CODA_NC_REMOVE,
- myprintf(("coda_nc_remove %s from parent %lx.%lx.%lx\n",
- cncp->name, (cncp->dcp)->c_fid.Volume,
- (cncp->dcp)->c_fid.Vnode, (cncp->dcp)->c_fid.Unique));)
-
- CODA_NC_HSHREM(cncp);
-
- CODA_NC_HSHNUL(cncp); /* have it be a null chain */
- if ((dcstat == IS_DOWNCALL) && (CTOV(cncp->dcp)->v_usecount == 1)) {
- cncp->dcp->c_flags |= C_PURGING;
- }
- vrele(CTOV(cncp->dcp));
-
- if ((dcstat == IS_DOWNCALL) && (CTOV(cncp->cp)->v_usecount == 1)) {
- cncp->cp->c_flags |= C_PURGING;
- }
- vrele(CTOV(cncp->cp));
-
- crfree(cncp->cred);
- bzero(DATA_PART(cncp),DATA_SIZE);
-
- /* Put the null entry just after the least-recently-used entry */
- /* LRU_TOP adjusts the pointer to point to the top of the structure. */
- CODA_NC_LRUREM(cncp);
- CODA_NC_LRUINS(cncp, LRU_TOP(coda_nc_lru.lru_prev));
-}
-
-/*
- * Remove all entries with a parent which has the input fid.
- */
-void
-coda_nc_zapParentfid(fid, dcstat)
- ViceFid *fid;
- enum dc_status dcstat;
-{
- /* To get to a specific fid, we might either have another hashing
- function or do a sequential search through the cache for the
- appropriate entries. The later may be acceptable since I don't
- think callbacks or whatever Case 1 covers are frequent occurences.
- */
- struct coda_cache *cncp, *ncncp;
- int i;
-
- if (coda_nc_use == 0) /* Cache is off */
- return;
-
- CODA_NC_DEBUG(CODA_NC_ZAPPFID,
- myprintf(("ZapParent: fid 0x%lx, 0x%lx, 0x%lx \n",
- fid->Volume, fid->Vnode, fid->Unique)); )
-
- coda_nc_stat.zapPfids++;
-
- for (i = 0; i < coda_nc_hashsize; i++) {
-
- /*
- * Need to save the hash_next pointer in case we remove the
- * entry. remove causes hash_next to point to itself.
- */
-
- for (cncp = coda_nc_hash[i].hash_next;
- cncp != (struct coda_cache *)&coda_nc_hash[i];
- cncp = ncncp) {
- ncncp = cncp->hash_next;
- if ((cncp->dcp->c_fid.Volume == fid->Volume) &&
- (cncp->dcp->c_fid.Vnode == fid->Vnode) &&
- (cncp->dcp->c_fid.Unique == fid->Unique)) {
- coda_nc_hash[i].length--; /* Used for tuning */
- coda_nc_remove(cncp, dcstat);
- }
- }
- }
-}
-
-
-/*
- * Remove all entries which have the same fid as the input
- */
-void
-coda_nc_zapfid(fid, dcstat)
- ViceFid *fid;
- enum dc_status dcstat;
-{
- /* See comment for zapParentfid. This routine will be used
- if attributes are being cached.
- */
- struct coda_cache *cncp, *ncncp;
- int i;
-
- if (coda_nc_use == 0) /* Cache is off */
- return;
-
- CODA_NC_DEBUG(CODA_NC_ZAPFID,
- myprintf(("Zapfid: fid 0x%lx, 0x%lx, 0x%lx \n",
- fid->Volume, fid->Vnode, fid->Unique)); )
-
- coda_nc_stat.zapFids++;
-
- for (i = 0; i < coda_nc_hashsize; i++) {
- for (cncp = coda_nc_hash[i].hash_next;
- cncp != (struct coda_cache *)&coda_nc_hash[i];
- cncp = ncncp) {
- ncncp = cncp->hash_next;
- if ((cncp->cp->c_fid.Volume == fid->Volume) &&
- (cncp->cp->c_fid.Vnode == fid->Vnode) &&
- (cncp->cp->c_fid.Unique == fid->Unique)) {
- coda_nc_hash[i].length--; /* Used for tuning */
- coda_nc_remove(cncp, dcstat);
- }
- }
- }
-}
-
-/*
- * Remove all entries which match the fid and the cred
- */
-void
-coda_nc_zapvnode(fid, cred, dcstat)
- ViceFid *fid;
- struct ucred *cred;
- enum dc_status dcstat;
-{
- /* See comment for zapfid. I don't think that one would ever
- want to zap a file with a specific cred from the kernel.
- We'll leave this one unimplemented.
- */
- if (coda_nc_use == 0) /* Cache is off */
- return;
-
- CODA_NC_DEBUG(CODA_NC_ZAPVNODE,
- myprintf(("Zapvnode: fid 0x%lx, 0x%lx, 0x%lx cred %p\n",
- fid->Volume, fid->Vnode, fid->Unique, cred)); )
-
-}
-
-/*
- * Remove all entries which have the (dir vnode, name) pair
- */
-void
-coda_nc_zapfile(dcp, name, namelen)
- struct cnode *dcp;
- const char *name;
- int namelen;
-{
- /* use the hash function to locate the file, then zap all
- entries of it regardless of the cred.
- */
- struct coda_cache *cncp;
- int hash;
-
- if (coda_nc_use == 0) /* Cache is off */
- return;
-
- CODA_NC_DEBUG(CODA_NC_ZAPFILE,
- myprintf(("Zapfile: dcp %p name %s \n",
- dcp, name)); )
-
- if (namelen > CODA_NC_NAMELEN) {
- coda_nc_stat.long_remove++; /* record stats */
- return;
- }
-
- coda_nc_stat.zapFile++;
-
- hash = CODA_NC_HASH(name, namelen, dcp);
- cncp = coda_nc_find(dcp, name, namelen, 0, hash);
-
- while (cncp) {
- coda_nc_hash[hash].length--; /* Used for tuning */
-
- coda_nc_remove(cncp, NOT_DOWNCALL);
- cncp = coda_nc_find(dcp, name, namelen, 0, hash);
- }
-}
-
-/*
- * Remove all the entries for a particular user. Used when tokens expire.
- * A user is determined by his/her effective user id (id_uid).
- */
-void
-coda_nc_purge_user(uid, dcstat)
- vuid_t uid;
- enum dc_status dcstat;
-{
- /*
- * I think the best approach is to go through the entire cache
- * via HASH or whatever and zap all entries which match the
- * input cred. Or just flush the whole cache. It might be
- * best to go through on basis of LRU since cache will almost
- * always be full and LRU is more straightforward.
- */
-
- struct coda_cache *cncp, *ncncp;
- int hash;
-
- if (coda_nc_use == 0) /* Cache is off */
- return;
-
- CODA_NC_DEBUG(CODA_NC_PURGEUSER,
- myprintf(("ZapDude: uid %x\n", uid)); )
- coda_nc_stat.zapUsers++;
-
- for (cncp = CODA_NC_LRUGET(coda_nc_lru);
- cncp != (struct coda_cache *)(&coda_nc_lru);
- cncp = ncncp) {
- ncncp = CODA_NC_LRUGET(*cncp);
-
- if ((CODA_NC_VALID(cncp)) &&
- ((cncp->cred)->cr_uid == uid)) {
- /* Seems really ugly, but we have to decrement the appropriate
- hash bucket length here, so we have to find the hash bucket
- */
- hash = CODA_NC_HASH(cncp->name, cncp->namelen, cncp->dcp);
- coda_nc_hash[hash].length--; /* For performance tuning */
-
- coda_nc_remove(cncp, dcstat);
- }
- }
-}
-
-/*
- * Flush the entire name cache. In response to a flush of the Venus cache.
- */
-void
-coda_nc_flush(dcstat)
- enum dc_status dcstat;
-{
- /* One option is to deallocate the current name cache and
- call init to start again. Or just deallocate, then rebuild.
- Or again, we could just go through the array and zero the
- appropriate fields.
- */
-
- /*
- * Go through the whole lru chain and kill everything as we go.
- * I don't use remove since that would rebuild the lru chain
- * as it went and that seemed unneccesary.
- */
- struct coda_cache *cncp;
- int i;
-
- if (coda_nc_use == 0) /* Cache is off */
- return;
-
- coda_nc_stat.Flushes++;
-
- for (cncp = CODA_NC_LRUGET(coda_nc_lru);
- cncp != (struct coda_cache *)&coda_nc_lru;
- cncp = CODA_NC_LRUGET(*cncp)) {
- if (CODA_NC_VALID(cncp)) {
-
- CODA_NC_HSHREM(cncp); /* only zero valid nodes */
- CODA_NC_HSHNUL(cncp);
- if ((dcstat == IS_DOWNCALL)
- && (CTOV(cncp->dcp)->v_usecount == 1))
- {
- cncp->dcp->c_flags |= C_PURGING;
- }
- vrele(CTOV(cncp->dcp));
-
- if (CTOV(cncp->cp)->v_flag & VTEXT) {
- if (coda_vmflush(cncp->cp))
- CODADEBUG(CODA_FLUSH,
- myprintf(("coda_nc_flush: (%lx.%lx.%lx) busy\n", cncp->cp->c_fid.Volume, cncp->cp->c_fid.Vnode, cncp->cp->c_fid.Unique)); )
- }
-
- if ((dcstat == IS_DOWNCALL)
- && (CTOV(cncp->cp)->v_usecount == 1))
- {
- cncp->cp->c_flags |= C_PURGING;
- }
- vrele(CTOV(cncp->cp));
-
- crfree(cncp->cred);
- bzero(DATA_PART(cncp),DATA_SIZE);
- }
- }
-
- for (i = 0; i < coda_nc_hashsize; i++)
- coda_nc_hash[i].length = 0;
-}
-
-/*
- * Debugging routines
- */
-
-/*
- * This routine should print out all the hash chains to the console.
- */
-void
-print_coda_nc(void)
-{
- int hash;
- struct coda_cache *cncp;
-
- for (hash = 0; hash < coda_nc_hashsize; hash++) {
- myprintf(("\nhash %d\n",hash));
-
- for (cncp = coda_nc_hash[hash].hash_next;
- cncp != (struct coda_cache *)&coda_nc_hash[hash];
- cncp = cncp->hash_next) {
- myprintf(("cp %p dcp %p cred %p name %s\n",
- cncp->cp, cncp->dcp,
- cncp->cred, cncp->name));
- }
- }
-}
-
-void
-coda_nc_gather_stats(void)
-{
- int i, max = 0, sum = 0, temp, zeros = 0, ave, n;
-
- for (i = 0; i < coda_nc_hashsize; i++) {
- if (coda_nc_hash[i].length) {
- sum += coda_nc_hash[i].length;
- } else {
- zeros++;
- }
-
- if (coda_nc_hash[i].length > max)
- max = coda_nc_hash[i].length;
- }
-
- /*
- * When computing the Arithmetic mean, only count slots which
- * are not empty in the distribution.
- */
- coda_nc_stat.Sum_bucket_len = sum;
- coda_nc_stat.Num_zero_len = zeros;
- coda_nc_stat.Max_bucket_len = max;
-
- if ((n = coda_nc_hashsize - zeros) > 0)
- ave = sum / n;
- else
- ave = 0;
-
- sum = 0;
- for (i = 0; i < coda_nc_hashsize; i++) {
- if (coda_nc_hash[i].length) {
- temp = coda_nc_hash[i].length - ave;
- sum += temp * temp;
- }
- }
- coda_nc_stat.Sum2_bucket_len = sum;
-}
-
-/*
- * The purpose of this routine is to allow the hash and cache sizes to be
- * changed dynamically. This should only be used in controlled environments,
- * it makes no effort to lock other users from accessing the cache while it
- * is in an improper state (except by turning the cache off).
- */
-int
-coda_nc_resize(hashsize, heapsize, dcstat)
- int hashsize, heapsize;
- enum dc_status dcstat;
-{
- if ((hashsize % 2) || (heapsize % 2)) { /* Illegal hash or cache sizes */
- return(EINVAL);
- }
-
- coda_nc_use = 0; /* Turn the cache off */
-
- coda_nc_flush(dcstat); /* free any cnodes in the cache */
-
- /* WARNING: free must happen *before* size is reset */
- CODA_FREE(coda_nc_heap,TOTAL_CACHE_SIZE);
- CODA_FREE(coda_nc_hash,TOTAL_HASH_SIZE);
-
- coda_nc_hashsize = hashsize;
- coda_nc_size = heapsize;
-
- coda_nc_init(); /* Set up a cache with the new size */
-
- coda_nc_use = 1; /* Turn the cache back on */
- return(0);
-}
-
-#ifdef DEBUG
-char coda_nc_name_buf[CODA_MAXNAMLEN+1];
-
-void
-coda_nc_name(struct cnode *cp)
-{
- struct coda_cache *cncp, *ncncp;
- int i;
-
- if (coda_nc_use == 0) /* Cache is off */
- return;
-
- for (i = 0; i < coda_nc_hashsize; i++) {
- for (cncp = coda_nc_hash[i].hash_next;
- cncp != (struct coda_cache *)&coda_nc_hash[i];
- cncp = ncncp) {
- ncncp = cncp->hash_next;
- if (cncp->cp == cp) {
- bcopy(cncp->name, coda_nc_name_buf, cncp->namelen);
- coda_nc_name_buf[cncp->namelen] = 0;
- printf(" is %s (%p,%p)@%p",
- coda_nc_name_buf, cncp->cp, cncp->dcp, cncp);
- }
-
- }
- }
-}
-#endif
diff --git a/sys/fs/coda/coda_namecache.h b/sys/fs/coda/coda_namecache.h
deleted file mode 100644
index 11f2e80b12b2..000000000000
--- a/sys/fs/coda/coda_namecache.h
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- *
- * Coda: an Experimental Distributed File System
- * Release 3.1
- *
- * Copyright (c) 1987-1998 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, and
- * that credit is given to Carnegie Mellon University in all documents
- * and publicity pertaining to direct or indirect use of this code or its
- * derivatives.
- *
- * CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS KNOWN TO HAVE BUGS,
- * SOME OF WHICH MAY HAVE SERIOUS CONSEQUENCES. 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 DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE OR OF
- * ANY DERIVATIVE WORK.
- *
- * Carnegie Mellon encourages users of this software to return any
- * improvements or extensions that they make, and to grant Carnegie
- * Mellon the rights to redistribute these changes without encumbrance.
- *
- * @(#) src/sys/coda/coda_namecache.h,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $
- * $FreeBSD$
- *
- */
-
-/*
- * Mach Operating System
- * Copyright (c) 1990 Carnegie-Mellon University
- * Copyright (c) 1989 Carnegie-Mellon University
- * All rights reserved. The CMU software License Agreement specifies
- * the terms and conditions for use and redistribution.
- */
-
-/*
- * This code was written for the Coda file system at Carnegie Mellon University.
- * Contributers include David Steere, James Kistler, and M. Satyanarayanan.
- */
-
-#ifndef _CODA_NC_HEADER_
-#define _CODA_NC_HEADER_
-
-/*
- * Coda constants
- */
-#define CODA_NC_NAMELEN 15 /* longest name stored in cache */
-#define CODA_NC_CACHESIZE 256 /* Default cache size */
-#define CODA_NC_HASHSIZE 64 /* Must be multiple of 2 */
-
-/*
- * Hash function for the primary hash.
- */
-
-/*
- * First try -- (first + last letters + length + (int)cp) mod size
- * 2nd try -- same, except dir fid.vnode instead of cp
- */
-
-#ifdef oldhash
-#define CODA_NC_HASH(name, namelen, cp) \
- ((name[0] + name[namelen-1] + namelen + (int)(cp)) & (coda_nc_hashsize-1))
-#else
-#define CODA_NC_HASH(name, namelen, cp) \
- ((name[0] + (name[namelen-1]<<4) + namelen + (((int)cp)>>8)) & (coda_nc_hashsize-1))
-#endif
-
-#define CODA_NAMEMATCH(cp, name, namelen, dcp) \
- ((namelen == cp->namelen) && (dcp == cp->dcp) && \
- (bcmp(cp->name,name,namelen) == 0))
-
-/*
- * Functions to modify the hash and lru chains.
- * insque and remque assume that the pointers are the first thing
- * in the list node, thus the trickery for lru.
- */
-
-#define CODA_NC_HSHINS(elem, pred) insque(elem,pred)
-#define CODA_NC_HSHREM(elem) remque(elem)
-#define CODA_NC_HSHNUL(elem) (elem)->hash_next = \
- (elem)->hash_prev = (elem)
-
-#define CODA_NC_LRUINS(elem, pred) insque(LRU_PART(elem), LRU_PART(pred))
-#define CODA_NC_LRUREM(elem) remque(LRU_PART(elem));
-#define CODA_NC_LRUGET(lruhead) LRU_TOP((lruhead).lru_prev)
-
-#define CODA_NC_VALID(cncp) (cncp->dcp != (struct cnode *)0)
-
-#define LRU_PART(cncp) (struct coda_cache *) \
- ((char *)cncp + (2*sizeof(struct coda_cache *)))
-#define LRU_TOP(cncp) (struct coda_cache *) \
- ((char *)cncp - (2*sizeof(struct coda_cache *)))
-#define DATA_PART(cncp) (struct coda_cache *) \
- ((char *)cncp + (4*sizeof(struct coda_cache *)))
-#define DATA_SIZE (sizeof(struct coda_cache)-(4*sizeof(struct coda_cache *)))
-
-/*
- * Structure for an element in the CODA Name Cache.
- * NOTE: I use the position of arguments and their size in the
- * implementation of the functions CODA_NC_LRUINS, CODA_NC_LRUREM, and
- * DATA_PART.
- */
-
-struct coda_cache {
- struct coda_cache *hash_next,*hash_prev; /* Hash list */
- struct coda_cache *lru_next, *lru_prev; /* LRU list */
- struct cnode *cp; /* vnode of the file */
- struct cnode *dcp; /* parent's cnode */
- struct ucred *cred; /* user credentials */
- char name[CODA_NC_NAMELEN]; /* segment name */
- int namelen; /* length of name */
-};
-
-struct coda_lru { /* Start of LRU chain */
- char *dummy1, *dummy2; /* place holders */
- struct coda_cache *lru_next, *lru_prev; /* position of pointers is important */
-};
-
-
-struct coda_hash { /* Start of Hash chain */
- struct coda_cache *hash_next, *hash_prev; /* NOTE: chain pointers must be first */
- int length; /* used for tuning purposes */
-};
-
-
-/*
- * Symbols to aid in debugging the namecache code. Assumes the existence
- * of the variable coda_nc_debug, which is defined in cfs_namecache.c
- */
-#define CODA_NC_DEBUG(N, STMT) { if (coda_nc_debug & (1 <<N)) { STMT } }
-
-/* Prototypes of functions exported within cfs */
-extern void coda_nc_init(void);
-extern void coda_nc_enter(struct cnode *, const char *, int, struct ucred *, struct cnode *);
-extern struct cnode *coda_nc_lookup(struct cnode *, const char *, int, struct ucred *);
-
-extern void coda_nc_zapParentfid(ViceFid *, enum dc_status);
-extern void coda_nc_zapfid(ViceFid *, enum dc_status);
-extern void coda_nc_zapvnode(ViceFid *, struct ucred *, enum dc_status);
-extern void coda_nc_zapfile(struct cnode *, const char *, int);
-extern void coda_nc_purge_user(vuid_t, enum dc_status);
-extern void coda_nc_flush(enum dc_status);
-
-extern void print_coda_nc(void);
-extern void coda_nc_gather_stats(void);
-extern int coda_nc_resize(int, int, enum dc_status);
-extern void coda_nc_name(struct cnode *cp);
-
-/*
- * Structure to contain statistics on the cache usage
- */
-
-struct coda_nc_statistics {
- unsigned hits;
- unsigned misses;
- unsigned enters;
- unsigned dbl_enters;
- unsigned long_name_enters;
- unsigned long_name_lookups;
- unsigned long_remove;
- unsigned lru_rm;
- unsigned zapPfids;
- unsigned zapFids;
- unsigned zapFile;
- unsigned zapUsers;
- unsigned Flushes;
- unsigned Sum_bucket_len;
- unsigned Sum2_bucket_len;
- unsigned Max_bucket_len;
- unsigned Num_zero_len;
- unsigned Search_len;
-};
-
-#define CODA_NC_FIND ((u_long) 1)
-#define CODA_NC_REMOVE ((u_long) 2)
-#define CODA_NC_INIT ((u_long) 3)
-#define CODA_NC_ENTER ((u_long) 4)
-#define CODA_NC_LOOKUP ((u_long) 5)
-#define CODA_NC_ZAPPFID ((u_long) 6)
-#define CODA_NC_ZAPFID ((u_long) 7)
-#define CODA_NC_ZAPVNODE ((u_long) 8)
-#define CODA_NC_ZAPFILE ((u_long) 9)
-#define CODA_NC_PURGEUSER ((u_long) 10)
-#define CODA_NC_FLUSH ((u_long) 11)
-#define CODA_NC_PRINTCODA_NC ((u_long) 12)
-#define CODA_NC_PRINTSTATS ((u_long) 13)
-
-#endif
diff --git a/sys/fs/coda/coda_opstats.h b/sys/fs/coda/coda_opstats.h
deleted file mode 100644
index 8661a07ebfa0..000000000000
--- a/sys/fs/coda/coda_opstats.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- *
- * Coda: an Experimental Distributed File System
- * Release 3.1
- *
- * Copyright (c) 1987-1998 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, and
- * that credit is given to Carnegie Mellon University in all documents
- * and publicity pertaining to direct or indirect use of this code or its
- * derivatives.
- *
- * CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS KNOWN TO HAVE BUGS,
- * SOME OF WHICH MAY HAVE SERIOUS CONSEQUENCES. 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 DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE OR OF
- * ANY DERIVATIVE WORK.
- *
- * Carnegie Mellon encourages users of this software to return any
- * improvements or extensions that they make, and to grant Carnegie
- * Mellon the rights to redistribute these changes without encumbrance.
- *
- * @(#) src/sys/coda/coda_opstats.h,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $
- * $FreeBSD$
- *
- */
-
-/*
- * operation stats: what the minicache can intercept that
- * *isn't* seen by venus. These stats are kept to augment
- * the stats maintained by the Volume-Session mechanism.
- */
-
-/* vfsops:
- * mount: not currently bounced to Venus
- * umount: nope
- * root: only first call, rest is cached.
- * statfs: none (bogus)
- * sync: none (bogus)
- * vget: all
- */
-
-#define CODA_MOUNT_STATS 0
-#define CODA_UMOUNT_STATS 1
-#define CODA_ROOT_STATS 2
-#define CODA_STATFS_STATS 3
-#define CODA_SYNC_STATS 4
-#define CODA_VGET_STATS 5
-#define CODA_VFSOPS_SIZE 6
-
-/* vnodeops:
- * open: all to venus
- * close: all to venus
- * rdrw: bogus. Maybe redirected to UFS.
- * May call open/close for internal opens/closes
- * (Does exec not call open?)
- * ioctl: causes a lookupname
- * passes through
- * select: can't get there from here.
- * getattr: can be satsified by cache
- * setattr: all go through
- * access: can be satisfied by cache
- * readlink: can be satisfied by cache
- * fsync: passes through
- * inactive: passes through
- * lookup: can be satisfied by cache
- * create: passes through
- * remove: passes through
- * link: passes through
- * rename: passes through
- * mkdir: passes through
- * rmdir: passes through
- * symlink: passes through
- * readdir: may be redirected to UFS
- * may cause an "internal" open/close
- */
-
-#define CODA_OPEN_STATS 0
-#define CODA_CLOSE_STATS 1
-#define CODA_RDWR_STATS 2
-#define CODA_IOCTL_STATS 3
-#define CODA_SELECT_STATS 4
-#define CODA_GETATTR_STATS 5
-#define CODA_SETATTR_STATS 6
-#define CODA_ACCESS_STATS 7
-#define CODA_READLINK_STATS 8
-#define CODA_FSYNC_STATS 9
-#define CODA_INACTIVE_STATS 10
-#define CODA_LOOKUP_STATS 11
-#define CODA_CREATE_STATS 12
-#define CODA_REMOVE_STATS 13
-#define CODA_LINK_STATS 14
-#define CODA_RENAME_STATS 15
-#define CODA_MKDIR_STATS 16
-#define CODA_RMDIR_STATS 17
-#define CODA_SYMLINK_STATS 18
-#define CODA_READDIR_STATS 19
-#define CODA_VNODEOPS_SIZE 20
-
-/*
- * I propose the following structres:
- */
-
-struct coda_op_stats {
- int opcode; /* vfs opcode */
- long entries; /* number of times call attempted */
- long sat_intrn; /* number of times call satisfied by cache */
- long unsat_intrn; /* number of times call failed in cache, but
- was not bounced to venus proper. */
- long gen_intrn; /* number of times call generated internally */
- /* (do we need that?) */
-};
-
-/*
- * With each call to the minicache, we'll bump the counters whenver
- * a call is satisfied internally (through the cache or through a
- * redirect), and whenever an operation is caused internally.
- * Then, we can add the total operations caught by the minicache
- * to the world-wide totals, and leave a caveat for the specific
- * graphs later.
- */
diff --git a/sys/fs/coda/coda_pioctl.h b/sys/fs/coda/coda_pioctl.h
deleted file mode 100644
index 2c2577ce57ee..000000000000
--- a/sys/fs/coda/coda_pioctl.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- *
- * Coda: an Experimental Distributed File System
- * Release 3.1
- *
- * Copyright (c) 1987-1998 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, and
- * that credit is given to Carnegie Mellon University in all documents
- * and publicity pertaining to direct or indirect use of this code or its
- * derivatives.
- *
- * CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS KNOWN TO HAVE BUGS,
- * SOME OF WHICH MAY HAVE SERIOUS CONSEQUENCES. 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 DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE OR OF
- * ANY DERIVATIVE WORK.
- *
- * Carnegie Mellon encourages users of this software to return any
- * improvements or extensions that they make, and to grant Carnegie
- * Mellon the rights to redistribute these changes without encumbrance.
- *
- * @(#) src/sys/coda/coda_pioctl.h,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $
- * $FreeBSD$
- *
- */
-
-/*
- * Mach Operating System
- * Copyright (c) 1989 Carnegie-Mellon University
- * Copyright (c) 1988 Carnegie-Mellon University
- * Copyright (c) 1987 Carnegie-Mellon University
- * All rights reserved. The CMU software License Agreement specifies
- * the terms and conditions for use and redistribution.
- */
-
-/*
- * ITC Remote file system - vice ioctl interface module
- */
-
-/*
- * TODO: Find /usr/local/include/viceioctl.h.
- */
-
-#ifndef _SYS_PIOCTL_H_
-#define _SYS_PIOCTL_H_
-
-/* The 2K limits above are a consequence of the size of the kernel buffer
- used to buffer requests from the user to venus--2*MAXPATHLEN.
- The buffer pointers may be null, or the counts may be 0 if there
- are no input or output parameters
- */
-
-#define _VICEIOCTL(id) ((unsigned int ) _IOW('V', id, struct ViceIoctl))
-
-/* Use this macro to define up to 256 vice ioctl's. These ioctl's
- all potentially have in/out parameters--this depends upon the
- values in the ViceIoctl structure. This structure is itself passed
- into the kernel by the normal ioctl parameter passing mechanism.
- */
-
-#define _VALIDVICEIOCTL(com) (com >= _VICEIOCTL(0) && com <= _VICEIOCTL(255))
-
-#endif
diff --git a/sys/fs/coda/coda_psdev.c b/sys/fs/coda/coda_psdev.c
deleted file mode 100644
index 4cd559da1558..000000000000
--- a/sys/fs/coda/coda_psdev.c
+++ /dev/null
@@ -1,679 +0,0 @@
-/*
- *
- * Coda: an Experimental Distributed File System
- * Release 3.1
- *
- * Copyright (c) 1987-1998 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, and
- * that credit is given to Carnegie Mellon University in all documents
- * and publicity pertaining to direct or indirect use of this code or its
- * derivatives.
- *
- * CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS KNOWN TO HAVE BUGS,
- * SOME OF WHICH MAY HAVE SERIOUS CONSEQUENCES. 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 DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE OR OF
- * ANY DERIVATIVE WORK.
- *
- * Carnegie Mellon encourages users of this software to return any
- * improvements or extensions that they make, and to grant Carnegie
- * Mellon the rights to redistribute these changes without encumbrance.
- *
- * @(#) src/sys/coda/coda_psdev.c,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $
- * $FreeBSD$
- *
- */
-
-/*
- * Mach Operating System
- * Copyright (c) 1989 Carnegie-Mellon University
- * All rights reserved. The CMU software License Agreement specifies
- * the terms and conditions for use and redistribution.
- */
-
-/*
- * This code was written for the Coda file system at Carnegie Mellon
- * University. Contributers include David Steere, James Kistler, and
- * M. Satyanarayanan. */
-
-/*
- * These routines define the psuedo device for communication between
- * Coda's Venus and Minicache in Mach 2.6. They used to be in cfs_subr.c,
- * but I moved them to make it easier to port the Minicache without
- * porting coda. -- DCS 10/12/94
- */
-
-/* These routines are the device entry points for Venus. */
-
-extern int coda_nc_initialized; /* Set if cache has been initialized */
-
-#include <vcoda.h>
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/proc.h>
-#include <sys/malloc.h>
-#include <sys/mount.h>
-#include <sys/file.h>
-#include <sys/ioccom.h>
-#include <sys/poll.h>
-#include <sys/conf.h>
-
-#include <coda/coda.h>
-#include <coda/cnode.h>
-#include <coda/coda_namecache.h>
-#include <coda/coda_io.h>
-#include <coda/coda_psdev.h>
-
-#define CTL_C
-
-#ifdef CTL_C
-#include <sys/signalvar.h>
-#endif
-
-int coda_psdev_print_entry = 0;
-static
-int outstanding_upcalls = 0;
-int coda_call_sleep = PZERO - 1;
-#ifdef CTL_C
-int coda_pcatch = PCATCH;
-#else
-#endif
-
-#define ENTRY if(coda_psdev_print_entry) myprintf(("Entered %s\n",__FUNCTION__))
-
-void vcodaattach(int n);
-
-struct vmsg {
- struct queue vm_chain;
- caddr_t vm_data;
- u_short vm_flags;
- u_short vm_inSize; /* Size is at most 5000 bytes */
- u_short vm_outSize;
- u_short vm_opcode; /* copied from data to save ptr lookup */
- int vm_unique;
- caddr_t vm_sleep; /* Not used by Mach. */
-};
-
-#define VM_READ 1
-#define VM_WRITE 2
-#define VM_INTR 4
-
-/* vcodaattach: do nothing */
-void
-vcodaattach(n)
- int n;
-{
-}
-
-int
-vc_nb_open(dev, flag, mode, p)
- dev_t dev;
- int flag;
- int mode;
- struct proc *p; /* NetBSD only */
-{
- register struct vcomm *vcp;
-
- ENTRY;
-
- if (minor(dev) >= NVCODA || minor(dev) < 0)
- return(ENXIO);
-
- if (!coda_nc_initialized)
- coda_nc_init();
-
- vcp = &coda_mnttbl[minor(dev)].mi_vcomm;
- if (VC_OPEN(vcp))
- return(EBUSY);
-
- bzero(&(vcp->vc_selproc), sizeof (struct selinfo));
- INIT_QUEUE(vcp->vc_requests);
- INIT_QUEUE(vcp->vc_replys);
- MARK_VC_OPEN(vcp);
-
- coda_mnttbl[minor(dev)].mi_vfsp = NULL;
- coda_mnttbl[minor(dev)].mi_rootvp = NULL;
-
- return(0);
-}
-
-int
-vc_nb_close (dev, flag, mode, p)
- dev_t dev;
- int flag;
- int mode;
- struct proc *p;
-{
- register struct vcomm *vcp;
- register struct vmsg *vmp, *nvmp = NULL;
- struct coda_mntinfo *mi;
- int err;
-
- ENTRY;
-
- if (minor(dev) >= NVCODA || minor(dev) < 0)
- return(ENXIO);
-
- mi = &coda_mnttbl[minor(dev)];
- vcp = &(mi->mi_vcomm);
-
- if (!VC_OPEN(vcp))
- panic("vcclose: not open");
-
- /* prevent future operations on this vfs from succeeding by auto-
- * unmounting any vfs mounted via this device. This frees user or
- * sysadm from having to remember where all mount points are located.
- * Put this before WAKEUPs to avoid queuing new messages between
- * the WAKEUP and the unmount (which can happen if we're unlucky)
- */
- if (!mi->mi_rootvp) {
- /* just a simple open/close w no mount */
- MARK_VC_CLOSED(vcp);
- return 0;
- }
-
- /* Let unmount know this is for real */
- VTOC(mi->mi_rootvp)->c_flags |= C_UNMOUNTING;
- coda_unmounting(mi->mi_vfsp);
-
- outstanding_upcalls = 0;
- /* Wakeup clients so they can return. */
- for (vmp = (struct vmsg *)GETNEXT(vcp->vc_requests);
- !EOQ(vmp, vcp->vc_requests);
- vmp = nvmp)
- {
- nvmp = (struct vmsg *)GETNEXT(vmp->vm_chain);
- /* Free signal request messages and don't wakeup cause
- no one is waiting. */
- if (vmp->vm_opcode == CODA_SIGNAL) {
- CODA_FREE((caddr_t)vmp->vm_data, (u_int)VC_IN_NO_DATA);
- CODA_FREE((caddr_t)vmp, (u_int)sizeof(struct vmsg));
- continue;
- }
- outstanding_upcalls++;
- wakeup(&vmp->vm_sleep);
- }
-
- for (vmp = (struct vmsg *)GETNEXT(vcp->vc_replys);
- !EOQ(vmp, vcp->vc_replys);
- vmp = (struct vmsg *)GETNEXT(vmp->vm_chain))
- {
- outstanding_upcalls++;
- wakeup(&vmp->vm_sleep);
- }
-
- MARK_VC_CLOSED(vcp);
-
- if (outstanding_upcalls) {
-#ifdef CODA_VERBOSE
- printf("presleep: outstanding_upcalls = %d\n", outstanding_upcalls);
- (void) tsleep(&outstanding_upcalls, coda_call_sleep, "coda_umount", 0);
- printf("postsleep: outstanding_upcalls = %d\n", outstanding_upcalls);
-#else
- (void) tsleep(&outstanding_upcalls, coda_call_sleep, "coda_umount", 0);
-#endif
- }
-
- err = dounmount(mi->mi_vfsp, flag, p);
- if (err)
- myprintf(("Error %d unmounting vfs in vcclose(%d)\n",
- err, minor(dev)));
- return 0;
-}
-
-int
-vc_nb_read(dev, uiop, flag)
- dev_t dev;
- struct uio *uiop;
- int flag;
-{
- register struct vcomm * vcp;
- register struct vmsg *vmp;
- int error = 0;
-
- ENTRY;
-
- if (minor(dev) >= NVCODA || minor(dev) < 0)
- return(ENXIO);
-
- vcp = &coda_mnttbl[minor(dev)].mi_vcomm;
- /* Get message at head of request queue. */
- if (EMPTY(vcp->vc_requests))
- return(0); /* Nothing to read */
-
- vmp = (struct vmsg *)GETNEXT(vcp->vc_requests);
-
- /* Move the input args into userspace */
- uiop->uio_rw = UIO_READ;
- error = uiomove(vmp->vm_data, vmp->vm_inSize, uiop);
- if (error) {
- myprintf(("vcread: error (%d) on uiomove\n", error));
- error = EINVAL;
- }
-
-#ifdef OLD_DIAGNOSTIC
- if (vmp->vm_chain.forw == 0 || vmp->vm_chain.back == 0)
- panic("vc_nb_read: bad chain");
-#endif
-
- REMQUE(vmp->vm_chain);
-
- /* If request was a signal, free up the message and don't
- enqueue it in the reply queue. */
- if (vmp->vm_opcode == CODA_SIGNAL) {
- if (codadebug)
- myprintf(("vcread: signal msg (%d, %d)\n",
- vmp->vm_opcode, vmp->vm_unique));
- CODA_FREE((caddr_t)vmp->vm_data, (u_int)VC_IN_NO_DATA);
- CODA_FREE((caddr_t)vmp, (u_int)sizeof(struct vmsg));
- return(error);
- }
-
- vmp->vm_flags |= VM_READ;
- INSQUE(vmp->vm_chain, vcp->vc_replys);
-
- return(error);
-}
-
-int
-vc_nb_write(dev, uiop, flag)
- dev_t dev;
- struct uio *uiop;
- int flag;
-{
- register struct vcomm * vcp;
- register struct vmsg *vmp;
- struct coda_out_hdr *out;
- u_long seq;
- u_long opcode;
- int buf[2];
- int error = 0;
-
- ENTRY;
-
- if (minor(dev) >= NVCODA || minor(dev) < 0)
- return(ENXIO);
-
- vcp = &coda_mnttbl[minor(dev)].mi_vcomm;
-
- /* Peek at the opcode, unique without transfering the data. */
- uiop->uio_rw = UIO_WRITE;
- error = uiomove((caddr_t)buf, sizeof(int) * 2, uiop);
- if (error) {
- myprintf(("vcwrite: error (%d) on uiomove\n", error));
- return(EINVAL);
- }
-
- opcode = buf[0];
- seq = buf[1];
-
- if (codadebug)
- myprintf(("vcwrite got a call for %ld.%ld\n", opcode, seq));
-
- if (DOWNCALL(opcode)) {
- union outputArgs pbuf;
-
- /* get the rest of the data. */
- uiop->uio_rw = UIO_WRITE;
- error = uiomove((caddr_t)&pbuf.coda_purgeuser.oh.result, sizeof(pbuf) - (sizeof(int)*2), uiop);
- if (error) {
- myprintf(("vcwrite: error (%d) on uiomove (Op %ld seq %ld)\n",
- error, opcode, seq));
- return(EINVAL);
- }
-
- return handleDownCall(opcode, &pbuf);
- }
-
- /* Look for the message on the (waiting for) reply queue. */
- for (vmp = (struct vmsg *)GETNEXT(vcp->vc_replys);
- !EOQ(vmp, vcp->vc_replys);
- vmp = (struct vmsg *)GETNEXT(vmp->vm_chain))
- {
- if (vmp->vm_unique == seq) break;
- }
-
- if (EOQ(vmp, vcp->vc_replys)) {
- if (codadebug)
- myprintf(("vcwrite: msg (%ld, %ld) not found\n", opcode, seq));
-
- return(ESRCH);
- }
-
- /* Remove the message from the reply queue */
- REMQUE(vmp->vm_chain);
-
- /* move data into response buffer. */
- out = (struct coda_out_hdr *)vmp->vm_data;
- /* Don't need to copy opcode and uniquifier. */
-
- /* get the rest of the data. */
- if (vmp->vm_outSize < uiop->uio_resid) {
- myprintf(("vcwrite: more data than asked for (%d < %d)\n",
- vmp->vm_outSize, uiop->uio_resid));
- wakeup(&vmp->vm_sleep); /* Notify caller of the error. */
- return(EINVAL);
- }
-
- buf[0] = uiop->uio_resid; /* Save this value. */
- uiop->uio_rw = UIO_WRITE;
- error = uiomove((caddr_t) &out->result, vmp->vm_outSize - (sizeof(int) * 2), uiop);
- if (error) {
- myprintf(("vcwrite: error (%d) on uiomove (op %ld seq %ld)\n",
- error, opcode, seq));
- return(EINVAL);
- }
-
- /* I don't think these are used, but just in case. */
- /* XXX - aren't these two already correct? -bnoble */
- out->opcode = opcode;
- out->unique = seq;
- vmp->vm_outSize = buf[0]; /* Amount of data transferred? */
- vmp->vm_flags |= VM_WRITE;
- wakeup(&vmp->vm_sleep);
-
- return(0);
-}
-
-int
-vc_nb_ioctl(dev, cmd, addr, flag, p)
- dev_t dev;
- u_long cmd;
- caddr_t addr;
- int flag;
- struct proc *p;
-{
- ENTRY;
-
- switch(cmd) {
- case CODARESIZE: {
- struct coda_resize *data = (struct coda_resize *)addr;
- return(coda_nc_resize(data->hashsize, data->heapsize, IS_DOWNCALL));
- break;
- }
- case CODASTATS:
- if (coda_nc_use) {
- coda_nc_gather_stats();
- return(0);
- } else {
- return(ENODEV);
- }
- break;
- case CODAPRINT:
- if (coda_nc_use) {
- print_coda_nc();
- return(0);
- } else {
- return(ENODEV);
- }
- break;
- case CIOC_KERNEL_VERSION:
- switch (*(u_int *)addr) {
- case 0:
- *(u_int *)addr = coda_kernel_version;
- return 0;
- break;
- case 1:
- case 2:
- if (coda_kernel_version != *(u_int *)addr)
- return ENOENT;
- else
- return 0;
- default:
- return ENOENT;
- }
- break;
- default :
- return(EINVAL);
- break;
- }
-}
-
-int
-vc_nb_poll(dev, events, p)
- dev_t dev;
- int events;
- struct proc *p;
-{
- register struct vcomm *vcp;
- int event_msk = 0;
-
- ENTRY;
-
- if (minor(dev) >= NVCODA || minor(dev) < 0)
- return(ENXIO);
-
- vcp = &coda_mnttbl[minor(dev)].mi_vcomm;
-
- event_msk = events & (POLLIN|POLLRDNORM);
- if (!event_msk)
- return(0);
-
- if (!EMPTY(vcp->vc_requests))
- return(events & (POLLIN|POLLRDNORM));
-
- selrecord(p, &(vcp->vc_selproc));
-
- return(0);
-}
-
-/*
- * Statistics
- */
-struct coda_clstat coda_clstat;
-
-/*
- * Key question: whether to sleep interuptably or uninteruptably when
- * waiting for Venus. The former seems better (cause you can ^C a
- * job), but then GNU-EMACS completion breaks. Use tsleep with no
- * timeout, and no longjmp happens. But, when sleeping
- * "uninterruptibly", we don't get told if it returns abnormally
- * (e.g. kill -9).
- */
-
-int
-coda_call(mntinfo, inSize, outSize, buffer)
- struct coda_mntinfo *mntinfo; int inSize; int *outSize; caddr_t buffer;
-{
- struct vcomm *vcp;
- struct vmsg *vmp;
- int error;
-#ifdef CTL_C
- struct proc *p = curproc;
- sigset_t psig_omask = p->p_sigmask;
- sigset_t tempset;
- int i;
-#endif
- if (mntinfo == NULL) {
- /* Unlikely, but could be a race condition with a dying warden */
- return ENODEV;
- }
-
- vcp = &(mntinfo->mi_vcomm);
-
- coda_clstat.ncalls++;
- coda_clstat.reqs[((struct coda_in_hdr *)buffer)->opcode]++;
-
- if (!VC_OPEN(vcp))
- return(ENODEV);
-
- CODA_ALLOC(vmp,struct vmsg *,sizeof(struct vmsg));
- /* Format the request message. */
- vmp->vm_data = buffer;
- vmp->vm_flags = 0;
- vmp->vm_inSize = inSize;
- vmp->vm_outSize
- = *outSize ? *outSize : inSize; /* |buffer| >= inSize */
- vmp->vm_opcode = ((struct coda_in_hdr *)buffer)->opcode;
- vmp->vm_unique = ++vcp->vc_seq;
- if (codadebug)
- myprintf(("Doing a call for %d.%d\n",
- vmp->vm_opcode, vmp->vm_unique));
-
- /* Fill in the common input args. */
- ((struct coda_in_hdr *)buffer)->unique = vmp->vm_unique;
-
- /* Append msg to request queue and poke Venus. */
- INSQUE(vmp->vm_chain, vcp->vc_requests);
- selwakeup(&(vcp->vc_selproc));
-
- /* We can be interrupted while we wait for Venus to process
- * our request. If the interrupt occurs before Venus has read
- * the request, we dequeue and return. If it occurs after the
- * read but before the reply, we dequeue, send a signal
- * message, and return. If it occurs after the reply we ignore
- * it. In no case do we want to restart the syscall. If it
- * was interrupted by a venus shutdown (vcclose), return
- * ENODEV. */
-
- /* Ignore return, We have to check anyway */
-#ifdef CTL_C
- /* This is work in progress. Setting coda_pcatch lets tsleep reawaken
- on a ^c or ^z. The problem is that emacs sets certain interrupts
- as SA_RESTART. This means that we should exit sleep handle the
- "signal" and then go to sleep again. Mostly this is done by letting
- the syscall complete and be restarted. We are not idempotent and
- can not do this. A better solution is necessary.
- */
- i = 0;
- do {
- error = tsleep(&vmp->vm_sleep,
- (coda_call_sleep|coda_pcatch), "coda_call",
- hz*2);
- if (error == 0)
- break;
- else if (error == EWOULDBLOCK) {
-#ifdef CODA_VERBOSE
- printf("coda_call: tsleep TIMEOUT %d sec\n", 2+2*i);
-#endif
- }
- else {
- SIGEMPTYSET(tempset);
- SIGADDSET(tempset, SIGIO);
- if (SIGSETEQ(p->p_siglist, tempset)) {
- SIGADDSET(p->p_sigmask, SIGIO);
-#ifdef CODA_VERBOSE
- printf("coda_call: tsleep returns %d SIGIO, cnt %d\n",
- error, i);
-#endif
- } else {
- SIGDELSET(tempset, SIGIO);
- SIGADDSET(tempset, SIGALRM);
- if (SIGSETEQ(p->p_siglist, tempset)) {
- SIGADDSET(p->p_sigmask, SIGALRM);
-#ifdef CODA_VERBOSE
- printf("coda_call: tsleep returns %d SIGALRM, cnt %d\n",
- error, i);
-#endif
- }
- else {
- printf("coda_call: tsleep returns %d, cnt %d\n",
- error, i);
-
-#if notyet
- tempset = p->p_siglist;
- SIGSETNAND(tempset, p->p_sigmask);
- printf("coda_call: siglist = %p, sigmask = %p, mask %p\n",
- p->p_siglist, p->p_sigmask,
- tempset);
- break;
- SIGSETOR(p->p_sigmask, p->p_siglist);
- tempset = p->p_siglist;
- SIGSETNAND(tempset, p->p_sigmask);
- printf("coda_call: new mask, siglist = %p, sigmask = %p, mask %p\n",
- p->p_siglist, p->p_sigmask,
- tempset);
-#endif
- }
- }
- }
- } while (error && i++ < 128 && VC_OPEN(vcp));
- p->p_sigmask = psig_omask;
-#else
- (void) tsleep(&vmp->vm_sleep, coda_call_sleep, "coda_call", 0);
-#endif
- if (VC_OPEN(vcp)) { /* Venus is still alive */
- /* Op went through, interrupt or not... */
- if (vmp->vm_flags & VM_WRITE) {
- error = 0;
- *outSize = vmp->vm_outSize;
- }
-
- else if (!(vmp->vm_flags & VM_READ)) {
- /* Interrupted before venus read it. */
-#ifdef CODA_VERBOSE
- if (1)
-#else
- if (codadebug)
-#endif
- myprintf(("interrupted before read: op = %d.%d, flags = %x\n",
- vmp->vm_opcode, vmp->vm_unique, vmp->vm_flags));
- REMQUE(vmp->vm_chain);
- error = EINTR;
- }
-
- else {
- /* (!(vmp->vm_flags & VM_WRITE)) means interrupted after
- upcall started */
- /* Interrupted after start of upcall, send venus a signal */
- struct coda_in_hdr *dog;
- struct vmsg *svmp;
-
-#ifdef CODA_VERBOSE
- if (1)
-#else
- if (codadebug)
-#endif
- myprintf(("Sending Venus a signal: op = %d.%d, flags = %x\n",
- vmp->vm_opcode, vmp->vm_unique, vmp->vm_flags));
-
- REMQUE(vmp->vm_chain);
- error = EINTR;
-
- CODA_ALLOC(svmp, struct vmsg *, sizeof (struct vmsg));
-
- CODA_ALLOC((svmp->vm_data), char *, sizeof (struct coda_in_hdr));
- dog = (struct coda_in_hdr *)svmp->vm_data;
-
- svmp->vm_flags = 0;
- dog->opcode = svmp->vm_opcode = CODA_SIGNAL;
- dog->unique = svmp->vm_unique = vmp->vm_unique;
- svmp->vm_inSize = sizeof (struct coda_in_hdr);
-/*??? rvb */ svmp->vm_outSize = sizeof (struct coda_in_hdr);
-
- if (codadebug)
- myprintf(("coda_call: enqueing signal msg (%d, %d)\n",
- svmp->vm_opcode, svmp->vm_unique));
-
- /* insert at head of queue! */
- INSQUE(svmp->vm_chain, vcp->vc_requests);
- selwakeup(&(vcp->vc_selproc));
- }
- }
-
- else { /* If venus died (!VC_OPEN(vcp)) */
- if (codadebug)
- myprintf(("vcclose woke op %d.%d flags %d\n",
- vmp->vm_opcode, vmp->vm_unique, vmp->vm_flags));
-
- error = ENODEV;
- }
-
- CODA_FREE(vmp, sizeof(struct vmsg));
-
- if (outstanding_upcalls > 0 && (--outstanding_upcalls == 0))
- wakeup(&outstanding_upcalls);
-
- if (!error)
- error = ((struct coda_out_hdr *)buffer)->result;
- return(error);
-}
diff --git a/sys/fs/coda/coda_psdev.h b/sys/fs/coda/coda_psdev.h
deleted file mode 100644
index c6276f3e710c..000000000000
--- a/sys/fs/coda/coda_psdev.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- *
- * Coda: an Experimental Distributed File System
- * Release 3.1
- *
- * Copyright (c) 1998 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, and
- * that credit is given to Carnegie Mellon University in all documents
- * and publicity pertaining to direct or indirect use of this code or its
- * derivatives.
- *
- * CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS KNOWN TO HAVE BUGS,
- * SOME OF WHICH MAY HAVE SERIOUS CONSEQUENCES. 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 DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE OR OF
- * ANY DERIVATIVE WORK.
- *
- * Carnegie Mellon encourages users of this software to return any
- * improvements or extensions that they make, and to grant Carnegie
- * Mellon the rights to redistribute these changes without encumbrance.
- *
- * @(#) src/sys/coda/coda_psdev.c,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $
- * $FreeBSD$
- *
- */
-
-int vc_nb_open(dev_t dev, int flag, int mode, struct proc *p);
-int vc_nb_close (dev_t dev, int flag, int mode, struct proc *p);
-int vc_nb_read(dev_t dev, struct uio *uiop, int flag);
-int vc_nb_write(dev_t dev, struct uio *uiop, int flag);
-int vc_nb_ioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p);
-int vc_nb_poll(dev_t dev, int events, struct proc *p);
diff --git a/sys/fs/coda/coda_subr.c b/sys/fs/coda/coda_subr.c
deleted file mode 100644
index aaf805c54ad6..000000000000
--- a/sys/fs/coda/coda_subr.c
+++ /dev/null
@@ -1,573 +0,0 @@
-/*
- *
- * Coda: an Experimental Distributed File System
- * Release 3.1
- *
- * Copyright (c) 1987-1998 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, and
- * that credit is given to Carnegie Mellon University in all documents
- * and publicity pertaining to direct or indirect use of this code or its
- * derivatives.
- *
- * CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS KNOWN TO HAVE BUGS,
- * SOME OF WHICH MAY HAVE SERIOUS CONSEQUENCES. 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 DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE OR OF
- * ANY DERIVATIVE WORK.
- *
- * Carnegie Mellon encourages users of this software to return any
- * improvements or extensions that they make, and to grant Carnegie
- * Mellon the rights to redistribute these changes without encumbrance.
- *
- * @(#) src/sys/coda/coda_subr.c,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $
- * $FreeBSD$
- *
- */
-
-/*
- * Mach Operating System
- * Copyright (c) 1989 Carnegie-Mellon University
- * All rights reserved. The CMU software License Agreement specifies
- * the terms and conditions for use and redistribution.
- */
-
-/*
- * This code was written for the Coda file system at Carnegie Mellon
- * University. Contributers include David Steere, James Kistler, and
- * M. Satyanarayanan.
- */
-
-/* NOTES: rvb
- * 1. Added coda_unmounting to mark all cnodes as being UNMOUNTING. This has to
- * be done before dounmount is called. Because some of the routines that
- * dounmount calls before coda_unmounted might try to force flushes to venus.
- * The vnode pager does this.
- * 2. coda_unmounting marks all cnodes scanning coda_cache.
- * 3. cfs_checkunmounting (under DEBUG) checks all cnodes by chasing the vnodes
- * under the /coda mount point.
- * 4. coda_cacheprint (under DEBUG) prints names with vnode/cnode address
- */
-
-#include <vcoda.h>
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/proc.h>
-#include <sys/malloc.h>
-#include <sys/select.h>
-#include <sys/mount.h>
-
-#include <coda/coda.h>
-#include <coda/cnode.h>
-#include <coda/coda_subr.h>
-#include <coda/coda_namecache.h>
-
-int coda_active = 0;
-int coda_reuse = 0;
-int coda_new = 0;
-
-struct cnode *coda_freelist = NULL;
-struct cnode *coda_cache[CODA_CACHESIZE];
-
-#define coda_hash(fid) (((fid)->Volume + (fid)->Vnode) & (CODA_CACHESIZE-1))
-#define CNODE_NEXT(cp) ((cp)->c_next)
-#define ODD(vnode) ((vnode) & 0x1)
-
-/*
- * Allocate a cnode.
- */
-struct cnode *
-coda_alloc(void)
-{
- struct cnode *cp;
-
- if (coda_freelist) {
- cp = coda_freelist;
- coda_freelist = CNODE_NEXT(cp);
- coda_reuse++;
- }
- else {
- CODA_ALLOC(cp, struct cnode *, sizeof(struct cnode));
- /* NetBSD vnodes don't have any Pager info in them ('cause there are
- no external pagers, duh!) */
-#define VNODE_VM_INFO_INIT(vp) /* MT */
- VNODE_VM_INFO_INIT(CTOV(cp));
- coda_new++;
- }
- bzero(cp, sizeof (struct cnode));
-
- return(cp);
-}
-
-/*
- * Deallocate a cnode.
- */
-void
-coda_free(cp)
- register struct cnode *cp;
-{
-
- CNODE_NEXT(cp) = coda_freelist;
- coda_freelist = cp;
-}
-
-/*
- * Put a cnode in the hash table
- */
-void
-coda_save(cp)
- struct cnode *cp;
-{
- CNODE_NEXT(cp) = coda_cache[coda_hash(&cp->c_fid)];
- coda_cache[coda_hash(&cp->c_fid)] = cp;
-}
-
-/*
- * Remove a cnode from the hash table
- */
-void
-coda_unsave(cp)
- struct cnode *cp;
-{
- struct cnode *ptr;
- struct cnode *ptrprev = NULL;
-
- ptr = coda_cache[coda_hash(&cp->c_fid)];
- while (ptr != NULL) {
- if (ptr == cp) {
- if (ptrprev == NULL) {
- coda_cache[coda_hash(&cp->c_fid)]
- = CNODE_NEXT(ptr);
- } else {
- CNODE_NEXT(ptrprev) = CNODE_NEXT(ptr);
- }
- CNODE_NEXT(cp) = (struct cnode *)NULL;
-
- return;
- }
- ptrprev = ptr;
- ptr = CNODE_NEXT(ptr);
- }
-}
-
-/*
- * Lookup a cnode by fid. If the cnode is dying, it is bogus so skip it.
- * NOTE: this allows multiple cnodes with same fid -- dcs 1/25/95
- */
-struct cnode *
-coda_find(fid)
- ViceFid *fid;
-{
- struct cnode *cp;
-
- cp = coda_cache[coda_hash(fid)];
- while (cp) {
- if ((cp->c_fid.Vnode == fid->Vnode) &&
- (cp->c_fid.Volume == fid->Volume) &&
- (cp->c_fid.Unique == fid->Unique) &&
- (!IS_UNMOUNTING(cp)))
- {
- coda_active++;
- return(cp);
- }
- cp = CNODE_NEXT(cp);
- }
- return(NULL);
-}
-
-/*
- * coda_kill is called as a side effect to vcopen. To prevent any
- * cnodes left around from an earlier run of a venus or warden from
- * causing problems with the new instance, mark any outstanding cnodes
- * as dying. Future operations on these cnodes should fail (excepting
- * coda_inactive of course!). Since multiple venii/wardens can be
- * running, only kill the cnodes for a particular entry in the
- * coda_mnttbl. -- DCS 12/1/94 */
-
-int
-coda_kill(whoIam, dcstat)
- struct mount *whoIam;
- enum dc_status dcstat;
-{
- int hash, count = 0;
- struct cnode *cp;
-
- /*
- * Algorithm is as follows:
- * Second, flush whatever vnodes we can from the name cache.
- *
- * Finally, step through whatever is left and mark them dying.
- * This prevents any operation at all.
- */
-
- /* This is slightly overkill, but should work. Eventually it'd be
- * nice to only flush those entries from the namecache that
- * reference a vnode in this vfs. */
- coda_nc_flush(dcstat);
-
- for (hash = 0; hash < CODA_CACHESIZE; hash++) {
- for (cp = coda_cache[hash]; cp != NULL; cp = CNODE_NEXT(cp)) {
- if (CTOV(cp)->v_mount == whoIam) {
-#ifdef DEBUG
- printf("coda_kill: vp %p, cp %p\n", CTOV(cp), cp);
-#endif
- count++;
- CODADEBUG(CODA_FLUSH,
- myprintf(("Live cnode fid %lx.%lx.%lx flags %d count %d\n",
- (cp->c_fid).Volume,
- (cp->c_fid).Vnode,
- (cp->c_fid).Unique,
- cp->c_flags,
- CTOV(cp)->v_usecount)); );
- }
- }
- }
- return count;
-}
-
-/*
- * There are two reasons why a cnode may be in use, it may be in the
- * name cache or it may be executing.
- */
-void
-coda_flush(dcstat)
- enum dc_status dcstat;
-{
- int hash;
- struct cnode *cp;
-
- coda_clstat.ncalls++;
- coda_clstat.reqs[CODA_FLUSH]++;
-
- coda_nc_flush(dcstat); /* flush files from the name cache */
-
- for (hash = 0; hash < CODA_CACHESIZE; hash++) {
- for (cp = coda_cache[hash]; cp != NULL; cp = CNODE_NEXT(cp)) {
- if (!ODD(cp->c_fid.Vnode)) /* only files can be executed */
- coda_vmflush(cp);
- }
- }
-}
-
-/*
- * As a debugging measure, print out any cnodes that lived through a
- * name cache flush.
- */
-void
-coda_testflush(void)
-{
- int hash;
- struct cnode *cp;
-
- for (hash = 0; hash < CODA_CACHESIZE; hash++) {
- for (cp = coda_cache[hash];
- cp != NULL;
- cp = CNODE_NEXT(cp)) {
- myprintf(("Live cnode fid %lx.%lx.%lx count %d\n",
- (cp->c_fid).Volume,(cp->c_fid).Vnode,
- (cp->c_fid).Unique, CTOV(cp)->v_usecount));
- }
- }
-}
-
-/*
- * First, step through all cnodes and mark them unmounting.
- * NetBSD kernels may try to fsync them now that venus
- * is dead, which would be a bad thing.
- *
- */
-void
-coda_unmounting(whoIam)
- struct mount *whoIam;
-{
- int hash;
- struct cnode *cp;
-
- for (hash = 0; hash < CODA_CACHESIZE; hash++) {
- for (cp = coda_cache[hash]; cp != NULL; cp = CNODE_NEXT(cp)) {
- if (CTOV(cp)->v_mount == whoIam) {
- if (cp->c_flags & (C_LOCKED|C_WANTED)) {
- printf("coda_unmounting: Unlocking %p\n", cp);
- cp->c_flags &= ~(C_LOCKED|C_WANTED);
- wakeup((caddr_t) cp);
- }
- cp->c_flags |= C_UNMOUNTING;
- }
- }
- }
-}
-
-#ifdef DEBUG
-void
-coda_checkunmounting(mp)
- struct mount *mp;
-{
- register struct vnode *vp, *nvp;
- struct cnode *cp;
- int count = 0, bad = 0;
-loop:
- for (vp = mp->mnt_vnodelist.lh_first; vp; vp = nvp) {
- if (vp->v_mount != mp)
- goto loop;
- nvp = vp->v_mntvnodes.le_next;
- cp = VTOC(vp);
- count++;
- if (!(cp->c_flags & C_UNMOUNTING)) {
- bad++;
- printf("vp %p, cp %p missed\n", vp, cp);
- cp->c_flags |= C_UNMOUNTING;
- }
- }
-}
-
-void
-coda_cacheprint(whoIam)
- struct mount *whoIam;
-{
- int hash;
- struct cnode *cp;
- int count = 0;
-
- printf("coda_cacheprint: coda_ctlvp %p, cp %p", coda_ctlvp, VTOC(coda_ctlvp));
- coda_nc_name(VTOC(coda_ctlvp));
- printf("\n");
-
- for (hash = 0; hash < CODA_CACHESIZE; hash++) {
- for (cp = coda_cache[hash]; cp != NULL; cp = CNODE_NEXT(cp)) {
- if (CTOV(cp)->v_mount == whoIam) {
- printf("coda_cacheprint: vp %p, cp %p", CTOV(cp), cp);
- coda_nc_name(cp);
- printf("\n");
- count++;
- }
- }
- }
- printf("coda_cacheprint: count %d\n", count);
-}
-#endif
-
-/*
- * There are 6 cases where invalidations occur. The semantics of each
- * is listed here.
- *
- * CODA_FLUSH -- flush all entries from the name cache and the cnode cache.
- * CODA_PURGEUSER -- flush all entries from the name cache for a specific user
- * This call is a result of token expiration.
- *
- * The next two are the result of callbacks on a file or directory.
- * CODA_ZAPDIR -- flush the attributes for the dir from its cnode.
- * Zap all children of this directory from the namecache.
- * CODA_ZAPFILE -- flush the attributes for a file.
- *
- * The fifth is a result of Venus detecting an inconsistent file.
- * CODA_PURGEFID -- flush the attribute for the file
- * If it is a dir (odd vnode), purge its
- * children from the namecache
- * remove the file from the namecache.
- *
- * The sixth allows Venus to replace local fids with global ones
- * during reintegration.
- *
- * CODA_REPLACE -- replace one ViceFid with another throughout the name cache
- */
-
-int handleDownCall(opcode, out)
- int opcode; union outputArgs *out;
-{
- int error;
-
- /* Handle invalidate requests. */
- switch (opcode) {
- case CODA_FLUSH : {
-
- coda_flush(IS_DOWNCALL);
-
- CODADEBUG(CODA_FLUSH,coda_testflush();) /* print remaining cnodes */
- return(0);
- }
-
- case CODA_PURGEUSER : {
- coda_clstat.ncalls++;
- coda_clstat.reqs[CODA_PURGEUSER]++;
-
- /* XXX - need to prevent fsync's */
- coda_nc_purge_user(out->coda_purgeuser.cred.cr_uid, IS_DOWNCALL);
- return(0);
- }
-
- case CODA_ZAPFILE : {
- struct cnode *cp;
-
- error = 0;
- coda_clstat.ncalls++;
- coda_clstat.reqs[CODA_ZAPFILE]++;
-
- cp = coda_find(&out->coda_zapfile.CodaFid);
- if (cp != NULL) {
- vref(CTOV(cp));
-
- cp->c_flags &= ~C_VATTR;
- if (CTOV(cp)->v_flag & VTEXT)
- error = coda_vmflush(cp);
- CODADEBUG(CODA_ZAPFILE, myprintf(("zapfile: fid = (%lx.%lx.%lx),
- refcnt = %d, error = %d\n",
- cp->c_fid.Volume,
- cp->c_fid.Vnode,
- cp->c_fid.Unique,
- CTOV(cp)->v_usecount - 1, error)););
- if (CTOV(cp)->v_usecount == 1) {
- cp->c_flags |= C_PURGING;
- }
- vrele(CTOV(cp));
- }
-
- return(error);
- }
-
- case CODA_ZAPDIR : {
- struct cnode *cp;
-
- coda_clstat.ncalls++;
- coda_clstat.reqs[CODA_ZAPDIR]++;
-
- cp = coda_find(&out->coda_zapdir.CodaFid);
- if (cp != NULL) {
- vref(CTOV(cp));
-
- cp->c_flags &= ~C_VATTR;
- coda_nc_zapParentfid(&out->coda_zapdir.CodaFid, IS_DOWNCALL);
-
- CODADEBUG(CODA_ZAPDIR, myprintf(("zapdir: fid = (%lx.%lx.%lx),
- refcnt = %d\n",cp->c_fid.Volume,
- cp->c_fid.Vnode,
- cp->c_fid.Unique,
- CTOV(cp)->v_usecount - 1)););
- if (CTOV(cp)->v_usecount == 1) {
- cp->c_flags |= C_PURGING;
- }
- vrele(CTOV(cp));
- }
-
- return(0);
- }
-
- case CODA_PURGEFID : {
- struct cnode *cp;
-
- error = 0;
- coda_clstat.ncalls++;
- coda_clstat.reqs[CODA_PURGEFID]++;
-
- cp = coda_find(&out->coda_purgefid.CodaFid);
- if (cp != NULL) {
- vref(CTOV(cp));
- if (ODD(out->coda_purgefid.CodaFid.Vnode)) { /* Vnode is a directory */
- coda_nc_zapParentfid(&out->coda_purgefid.CodaFid,
- IS_DOWNCALL);
- }
- cp->c_flags &= ~C_VATTR;
- coda_nc_zapfid(&out->coda_purgefid.CodaFid, IS_DOWNCALL);
- if (!(ODD(out->coda_purgefid.CodaFid.Vnode))
- && (CTOV(cp)->v_flag & VTEXT)) {
-
- error = coda_vmflush(cp);
- }
- CODADEBUG(CODA_PURGEFID, myprintf(("purgefid: fid = (%lx.%lx.%lx), refcnt = %d, error = %d\n",
- cp->c_fid.Volume, cp->c_fid.Vnode,
- cp->c_fid.Unique,
- CTOV(cp)->v_usecount - 1, error)););
- if (CTOV(cp)->v_usecount == 1) {
- cp->c_flags |= C_PURGING;
- }
- vrele(CTOV(cp));
- }
- return(error);
- }
-
- case CODA_REPLACE : {
- struct cnode *cp = NULL;
-
- coda_clstat.ncalls++;
- coda_clstat.reqs[CODA_REPLACE]++;
-
- cp = coda_find(&out->coda_replace.OldFid);
- if (cp != NULL) {
- /* remove the cnode from the hash table, replace the fid, and reinsert */
- vref(CTOV(cp));
- coda_unsave(cp);
- cp->c_fid = out->coda_replace.NewFid;
- coda_save(cp);
-
- CODADEBUG(CODA_REPLACE, myprintf(("replace: oldfid = (%lx.%lx.%lx), newfid = (%lx.%lx.%lx), cp = %p\n",
- out->coda_replace.OldFid.Volume,
- out->coda_replace.OldFid.Vnode,
- out->coda_replace.OldFid.Unique,
- cp->c_fid.Volume, cp->c_fid.Vnode,
- cp->c_fid.Unique, cp));)
- vrele(CTOV(cp));
- }
- return (0);
- }
- default:
- myprintf(("handleDownCall: unknown opcode %d\n", opcode));
- return (EINVAL);
- }
-}
-
-/* coda_grab_vnode: lives in either cfs_mach.c or cfs_nbsd.c */
-
-int
-coda_vmflush(cp)
- struct cnode *cp;
-{
- return 0;
-}
-
-
-/*
- * kernel-internal debugging switches
- */
-void coda_debugon(void)
-{
- codadebug = -1;
- coda_nc_debug = -1;
- coda_vnop_print_entry = 1;
- coda_psdev_print_entry = 1;
- coda_vfsop_print_entry = 1;
-}
-
-void coda_debugoff(void)
-{
- codadebug = 0;
- coda_nc_debug = 0;
- coda_vnop_print_entry = 0;
- coda_psdev_print_entry = 0;
- coda_vfsop_print_entry = 0;
-}
-
-/*
- * Utilities used by both client and server
- * Standard levels:
- * 0) no debugging
- * 1) hard failures
- * 2) soft failures
- * 3) current test software
- * 4) main procedure entry points
- * 5) main procedure exit points
- * 6) utility procedure entry points
- * 7) utility procedure exit points
- * 8) obscure procedure entry points
- * 9) obscure procedure exit points
- * 10) random stuff
- * 11) all <= 1
- * 12) all <= 2
- * 13) all <= 3
- * ...
- */
diff --git a/sys/fs/coda/coda_subr.h b/sys/fs/coda/coda_subr.h
deleted file mode 100644
index 71c8a3de3812..000000000000
--- a/sys/fs/coda/coda_subr.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- *
- * Coda: an Experimental Distributed File System
- * Release 3.1
- *
- * Copyright (c) 1987-1998 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, and
- * that credit is given to Carnegie Mellon University in all documents
- * and publicity pertaining to direct or indirect use of this code or its
- * derivatives.
- *
- * CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS KNOWN TO HAVE BUGS,
- * SOME OF WHICH MAY HAVE SERIOUS CONSEQUENCES. 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 DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE OR OF
- * ANY DERIVATIVE WORK.
- *
- * Carnegie Mellon encourages users of this software to return any
- * improvements or extensions that they make, and to grant Carnegie
- * Mellon the rights to redistribute these changes without encumbrance.
- *
- * @(#) src/sys/coda/coda_subr.h,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $
- * $FreeBSD$
- *
- */
-
-struct cnode *coda_alloc(void);
-void coda_free(struct cnode *cp);
-struct cnode *coda_find(ViceFid *fid);
-void coda_flush(enum dc_status dcstat);
-void coda_testflush(void);
-void coda_checkunmounting(struct mount *mp);
-void coda_cacheprint(struct mount *whoIam);
-void coda_debugon(void);
-void coda_debugoff(void);
-int coda_kill(struct mount *whoIam, enum dc_status dcstat);
-void coda_save(struct cnode *cp);
-void coda_unsave(struct cnode *cp);
diff --git a/sys/fs/coda/coda_venus.c b/sys/fs/coda/coda_venus.c
deleted file mode 100644
index f27357498d45..000000000000
--- a/sys/fs/coda/coda_venus.c
+++ /dev/null
@@ -1,661 +0,0 @@
-/*
- *
- * Coda: an Experimental Distributed File System
- * Release 3.1
- *
- * Copyright (c) 1987-1998 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, and
- * that credit is given to Carnegie Mellon University in all documents
- * and publicity pertaining to direct or indirect use of this code or its
- * derivatives.
- *
- * CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS KNOWN TO HAVE BUGS,
- * SOME OF WHICH MAY HAVE SERIOUS CONSEQUENCES. 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 DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE OR OF
- * ANY DERIVATIVE WORK.
- *
- * Carnegie Mellon encourages users of this software to return any
- * improvements or extensions that they make, and to grant Carnegie
- * Mellon the rights to redistribute these changes without encumbrance.
- *
- * @(#) src/sys/cfs/coda_venus.c,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $
- * $FreeBSD$
- *
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/malloc.h>
-#include <sys/proc.h>
-#include <sys/select.h>
-#include <sys/ioccom.h>
-#include <sys/fcntl.h>
-
-#include <coda/coda.h>
-#include <coda/cnode.h>
-#include <coda/coda_venus.h>
-#include <coda/coda_pioctl.h>
-
-#define DECL_NO_IN(name) \
- struct coda_in_hdr *inp; \
- struct name ## _out *outp; \
- int name ## _size = sizeof (struct coda_in_hdr); \
- int Isize = sizeof (struct coda_in_hdr); \
- int Osize = sizeof (struct name ## _out); \
- int error
-
-#define DECL(name) \
- struct name ## _in *inp; \
- struct name ## _out *outp; \
- int name ## _size = sizeof (struct name ## _in); \
- int Isize = sizeof (struct name ## _in); \
- int Osize = sizeof (struct name ## _out); \
- int error
-
-#define DECL_NO_OUT(name) \
- struct name ## _in *inp; \
- struct coda_out_hdr *outp; \
- int name ## _size = sizeof (struct name ## _in); \
- int Isize = sizeof (struct name ## _in); \
- int Osize = sizeof (struct coda_out_hdr); \
- int error
-
-#define ALLOC_NO_IN(name) \
- if (Osize > name ## _size) \
- name ## _size = Osize; \
- CODA_ALLOC(inp, struct coda_in_hdr *, name ## _size);\
- outp = (struct name ## _out *) inp
-
-#define ALLOC(name) \
- if (Osize > name ## _size) \
- name ## _size = Osize; \
- CODA_ALLOC(inp, struct name ## _in *, name ## _size);\
- outp = (struct name ## _out *) inp
-
-#define ALLOC_NO_OUT(name) \
- if (Osize > name ## _size) \
- name ## _size = Osize; \
- CODA_ALLOC(inp, struct name ## _in *, name ## _size);\
- outp = (struct coda_out_hdr *) inp
-
-#define STRCPY(struc, name, len) \
- bcopy(name, (char *)inp + (int)inp->struc, len); \
- ((char*)inp + (int)inp->struc)[len++] = 0; \
- Isize += len
-
-#define INIT_IN(in, op, ident, p) \
- (in)->opcode = (op); \
- (in)->pid = p ? p->p_pid : -1; \
- (in)->pgid = p ? p->p_pgid : -1; \
- (in)->sid = (p && p->p_session && p->p_session->s_leader) ? (p->p_session->s_leader->p_pid) : -1; \
- if (ident != NOCRED) { \
- (in)->cred.cr_uid = ident->cr_uid; \
- (in)->cred.cr_groupid = ident->cr_gid; \
- } else { \
- bzero(&((in)->cred),sizeof(struct coda_cred)); \
- (in)->cred.cr_uid = -1; \
- (in)->cred.cr_groupid = -1; \
- } \
-
-#define CNV_OFLAG(to, from) \
- do { \
- to = 0; \
- if (from & FREAD) to |= C_O_READ; \
- if (from & FWRITE) to |= C_O_WRITE; \
- if (from & O_TRUNC) to |= C_O_TRUNC; \
- if (from & O_EXCL) to |= C_O_EXCL; \
- if (from & O_CREAT) to |= C_O_CREAT; \
- } while (0)
-
-#define CNV_VV2V_ATTR(top, fromp) \
- do { \
- (top)->va_type = (fromp)->va_type; \
- (top)->va_mode = (fromp)->va_mode; \
- (top)->va_nlink = (fromp)->va_nlink; \
- (top)->va_uid = (fromp)->va_uid; \
- (top)->va_gid = (fromp)->va_gid; \
- (top)->va_fsid = VNOVAL; \
- (top)->va_fileid = (fromp)->va_fileid; \
- (top)->va_size = (fromp)->va_size; \
- (top)->va_blocksize = (fromp)->va_blocksize; \
- (top)->va_atime = (fromp)->va_atime; \
- (top)->va_mtime = (fromp)->va_mtime; \
- (top)->va_ctime = (fromp)->va_ctime; \
- (top)->va_gen = (fromp)->va_gen; \
- (top)->va_flags = (fromp)->va_flags; \
- (top)->va_rdev = (fromp)->va_rdev; \
- (top)->va_bytes = (fromp)->va_bytes; \
- (top)->va_filerev = (fromp)->va_filerev; \
- (top)->va_vaflags = VNOVAL; \
- (top)->va_spare = VNOVAL; \
- } while (0)
-
-#define CNV_V2VV_ATTR(top, fromp) \
- do { \
- (top)->va_type = (fromp)->va_type; \
- (top)->va_mode = (fromp)->va_mode; \
- (top)->va_nlink = (fromp)->va_nlink; \
- (top)->va_uid = (fromp)->va_uid; \
- (top)->va_gid = (fromp)->va_gid; \
- (top)->va_fileid = (fromp)->va_fileid; \
- (top)->va_size = (fromp)->va_size; \
- (top)->va_blocksize = (fromp)->va_blocksize; \
- (top)->va_atime = (fromp)->va_atime; \
- (top)->va_mtime = (fromp)->va_mtime; \
- (top)->va_ctime = (fromp)->va_ctime; \
- (top)->va_gen = (fromp)->va_gen; \
- (top)->va_flags = (fromp)->va_flags; \
- (top)->va_rdev = (fromp)->va_rdev; \
- (top)->va_bytes = (fromp)->va_bytes; \
- (top)->va_filerev = (fromp)->va_filerev; \
- } while (0)
-
-
-int coda_kernel_version = CODA_KERNEL_VERSION;
-
-int
-venus_root(void *mdp,
- struct ucred *cred, struct proc *p,
-/*out*/ ViceFid *VFid)
-{
- DECL_NO_IN(coda_root); /* sets Isize & Osize */
- ALLOC_NO_IN(coda_root); /* sets inp & outp */
-
- /* send the open to venus. */
- INIT_IN(inp, CODA_ROOT, cred, p);
-
- error = coda_call(mdp, Isize, &Osize, (char *)inp);
- if (!error)
- *VFid = outp->VFid;
-
- CODA_FREE(inp, coda_root_size);
- return error;
-}
-
-int
-venus_open(void *mdp, ViceFid *fid, int flag,
- struct ucred *cred, struct proc *p,
-/*out*/ dev_t *dev, ino_t *inode)
-{
- int cflag;
- DECL(coda_open); /* sets Isize & Osize */
- ALLOC(coda_open); /* sets inp & outp */
-
- /* send the open to venus. */
- INIT_IN(&inp->ih, CODA_OPEN, cred, p);
- inp->VFid = *fid;
- CNV_OFLAG(cflag, flag);
- inp->flags = cflag;
-
- error = coda_call(mdp, Isize, &Osize, (char *)inp);
- if (!error) {
-/* 5/11 *dev = udev2dev(outp->dev, 2); */
- *dev = udev2dev(outp->dev, 0);
- *inode = outp->inode;
- }
-
- CODA_FREE(inp, coda_open_size);
- return error;
-}
-
-int
-venus_close(void *mdp, ViceFid *fid, int flag,
- struct ucred *cred, struct proc *p)
-{
- int cflag;
- DECL_NO_OUT(coda_close); /* sets Isize & Osize */
- ALLOC_NO_OUT(coda_close); /* sets inp & outp */
-
- INIT_IN(&inp->ih, CODA_CLOSE, cred, p);
- inp->VFid = *fid;
- CNV_OFLAG(cflag, flag);
- inp->flags = cflag;
-
- error = coda_call(mdp, Isize, &Osize, (char *)inp);
-
- CODA_FREE(inp, coda_close_size);
- return error;
-}
-
-/*
- * these two calls will not exist!!! the container file is read/written
- * directly.
- */
-void
-venus_read(void)
-{
-}
-
-void
-venus_write(void)
-{
-}
-
-/*
- * this is a bit sad too. the ioctl's are for the control file, not for
- * normal files.
- */
-int
-venus_ioctl(void *mdp, ViceFid *fid,
- int com, int flag, caddr_t data,
- struct ucred *cred, struct proc *p)
-{
- DECL(coda_ioctl); /* sets Isize & Osize */
- struct PioctlData *iap = (struct PioctlData *)data;
- int tmp;
-
- coda_ioctl_size = VC_MAXMSGSIZE;
- ALLOC(coda_ioctl); /* sets inp & outp */
-
- INIT_IN(&inp->ih, CODA_IOCTL, cred, p);
- inp->VFid = *fid;
-
- /* command was mutated by increasing its size field to reflect the
- * path and follow args. we need to subtract that out before sending
- * the command to venus.
- */
- inp->cmd = (com & ~(IOCPARM_MASK << 16));
- tmp = ((com >> 16) & IOCPARM_MASK) - sizeof (char *) - sizeof (int);
- inp->cmd |= (tmp & IOCPARM_MASK) << 16;
-
- inp->rwflag = flag;
- inp->len = iap->vi.in_size;
- inp->data = (char *)(sizeof (struct coda_ioctl_in));
-
- error = copyin(iap->vi.in, (char*)inp + (int)inp->data,
- iap->vi.in_size);
- if (error) {
- CODA_FREE(inp, coda_ioctl_size);
- return(error);
- }
-
- Osize = VC_MAXMSGSIZE;
- error = coda_call(mdp, Isize + iap->vi.in_size, &Osize, (char *)inp);
-
- /* copy out the out buffer. */
- if (!error) {
- if (outp->len > iap->vi.out_size) {
- error = EINVAL;
- } else {
- error = copyout((char *)outp + (int)outp->data,
- iap->vi.out, iap->vi.out_size);
- }
- }
-
- CODA_FREE(inp, coda_ioctl_size);
- return error;
-}
-
-int
-venus_getattr(void *mdp, ViceFid *fid,
- struct ucred *cred, struct proc *p,
-/*out*/ struct vattr *vap)
-{
- DECL(coda_getattr); /* sets Isize & Osize */
- ALLOC(coda_getattr); /* sets inp & outp */
-
- /* send the open to venus. */
- INIT_IN(&inp->ih, CODA_GETATTR, cred, p);
- inp->VFid = *fid;
-
- error = coda_call(mdp, Isize, &Osize, (char *)inp);
- if (!error) {
- CNV_VV2V_ATTR(vap, &outp->attr);
- }
-
- CODA_FREE(inp, coda_getattr_size);
- return error;
-}
-
-int
-venus_setattr(void *mdp, ViceFid *fid, struct vattr *vap,
- struct ucred *cred, struct proc *p)
-{
- DECL_NO_OUT(coda_setattr); /* sets Isize & Osize */
- ALLOC_NO_OUT(coda_setattr); /* sets inp & outp */
-
- /* send the open to venus. */
- INIT_IN(&inp->ih, CODA_SETATTR, cred, p);
- inp->VFid = *fid;
- CNV_V2VV_ATTR(&inp->attr, vap);
-
- error = coda_call(mdp, Isize, &Osize, (char *)inp);
-
- CODA_FREE(inp, coda_setattr_size);
- return error;
-}
-
-int
-venus_access(void *mdp, ViceFid *fid, int mode,
- struct ucred *cred, struct proc *p)
-{
- DECL_NO_OUT(coda_access); /* sets Isize & Osize */
- ALLOC_NO_OUT(coda_access); /* sets inp & outp */
-
- /* send the open to venus. */
- INIT_IN(&inp->ih, CODA_ACCESS, cred, p);
- inp->VFid = *fid;
- /* NOTE:
- * NetBSD and Venus internals use the "data" in the low 3 bits.
- * Hence, the conversion.
- */
- inp->flags = mode>>6;
-
- error = coda_call(mdp, Isize, &Osize, (char *)inp);
-
- CODA_FREE(inp, coda_access_size);
- return error;
-}
-
-int
-venus_readlink(void *mdp, ViceFid *fid,
- struct ucred *cred, struct proc *p,
-/*out*/ char **str, int *len)
-{
- DECL(coda_readlink); /* sets Isize & Osize */
- coda_readlink_size += CODA_MAXPATHLEN;
- ALLOC(coda_readlink); /* sets inp & outp */
-
- /* send the open to venus. */
- INIT_IN(&inp->ih, CODA_READLINK, cred, p);
- inp->VFid = *fid;
-
- Osize += CODA_MAXPATHLEN;
- error = coda_call(mdp, Isize, &Osize, (char *)inp);
- if (!error) {
- CODA_ALLOC(*str, char *, outp->count);
- *len = outp->count;
- bcopy((char *)outp + (int)outp->data, *str, *len);
- }
-
- CODA_FREE(inp, coda_readlink_size);
- return error;
-}
-
-int
-venus_fsync(void *mdp, ViceFid *fid,
- struct ucred *cred, struct proc *p)
-{
- DECL_NO_OUT(coda_fsync); /* sets Isize & Osize */
- ALLOC_NO_OUT(coda_fsync); /* sets inp & outp */
-
- /* send the open to venus. */
- INIT_IN(&inp->ih, CODA_FSYNC, cred, p);
- inp->VFid = *fid;
-
- error = coda_call(mdp, Isize, &Osize, (char *)inp);
-
- CODA_FREE(inp, coda_fsync_size);
- return error;
-}
-
-int
-venus_lookup(void *mdp, ViceFid *fid,
- const char *nm, int len,
- struct ucred *cred, struct proc *p,
-/*out*/ ViceFid *VFid, int *vtype)
-{
- DECL(coda_lookup); /* sets Isize & Osize */
- coda_lookup_size += len + 1;
- ALLOC(coda_lookup); /* sets inp & outp */
-
- /* send the open to venus. */
- INIT_IN(&inp->ih, CODA_LOOKUP, cred, p);
- inp->VFid = *fid;
-
- /* NOTE:
- * Between version 1 and version 2 we have added an extra flag field
- * to this structure. But because the string was at the end and because
- * of the wierd way we represent strings by having the slot point to
- * where the string characters are in the "heap", we can just slip the
- * flag parameter in after the string slot pointer and veni that don't
- * know better won't see this new flag field ...
- * Otherwise we'd need two different venus_lookup functions.
- */
- inp->name = Isize;
- inp->flags = CLU_CASE_SENSITIVE; /* doesn't really matter for BSD */
- STRCPY(name, nm, len); /* increments Isize */
-
- error = coda_call(mdp, Isize, &Osize, (char *)inp);
- if (!error) {
- *VFid = outp->VFid;
- *vtype = outp->vtype;
- }
-
- CODA_FREE(inp, coda_lookup_size);
- return error;
-}
-
-int
-venus_create(void *mdp, ViceFid *fid,
- const char *nm, int len, int exclusive, int mode, struct vattr *va,
- struct ucred *cred, struct proc *p,
-/*out*/ ViceFid *VFid, struct vattr *attr)
-{
- DECL(coda_create); /* sets Isize & Osize */
- coda_create_size += len + 1;
- ALLOC(coda_create); /* sets inp & outp */
-
- /* send the open to venus. */
- INIT_IN(&inp->ih, CODA_CREATE, cred, p);
- inp->VFid = *fid;
- inp->excl = exclusive ? C_O_EXCL : 0;
- inp->mode = mode;
- CNV_V2VV_ATTR(&inp->attr, va);
-
- inp->name = Isize;
- STRCPY(name, nm, len); /* increments Isize */
-
- error = coda_call(mdp, Isize, &Osize, (char *)inp);
- if (!error) {
- *VFid = outp->VFid;
- CNV_VV2V_ATTR(attr, &outp->attr);
- }
-
- CODA_FREE(inp, coda_create_size);
- return error;
-}
-
-int
-venus_remove(void *mdp, ViceFid *fid,
- const char *nm, int len,
- struct ucred *cred, struct proc *p)
-{
- DECL_NO_OUT(coda_remove); /* sets Isize & Osize */
- coda_remove_size += len + 1;
- ALLOC_NO_OUT(coda_remove); /* sets inp & outp */
-
- /* send the open to venus. */
- INIT_IN(&inp->ih, CODA_REMOVE, cred, p);
- inp->VFid = *fid;
-
- inp->name = Isize;
- STRCPY(name, nm, len); /* increments Isize */
-
- error = coda_call(mdp, Isize, &Osize, (char *)inp);
-
- CODA_FREE(inp, coda_remove_size);
- return error;
-}
-
-int
-venus_link(void *mdp, ViceFid *fid, ViceFid *tfid,
- const char *nm, int len,
- struct ucred *cred, struct proc *p)
-{
- DECL_NO_OUT(coda_link); /* sets Isize & Osize */
- coda_link_size += len + 1;
- ALLOC_NO_OUT(coda_link); /* sets inp & outp */
-
- /* send the open to venus. */
- INIT_IN(&inp->ih, CODA_LINK, cred, p);
- inp->sourceFid = *fid;
- inp->destFid = *tfid;
-
- inp->tname = Isize;
- STRCPY(tname, nm, len); /* increments Isize */
-
- error = coda_call(mdp, Isize, &Osize, (char *)inp);
-
- CODA_FREE(inp, coda_link_size);
- return error;
-}
-
-int
-venus_rename(void *mdp, ViceFid *fid, ViceFid *tfid,
- const char *nm, int len, const char *tnm, int tlen,
- struct ucred *cred, struct proc *p)
-{
- DECL_NO_OUT(coda_rename); /* sets Isize & Osize */
- coda_rename_size += len + 1 + tlen + 1;
- ALLOC_NO_OUT(coda_rename); /* sets inp & outp */
-
- /* send the open to venus. */
- INIT_IN(&inp->ih, CODA_RENAME, cred, p);
- inp->sourceFid = *fid;
- inp->destFid = *tfid;
-
- inp->srcname = Isize;
- STRCPY(srcname, nm, len); /* increments Isize */
-
- inp->destname = Isize;
- STRCPY(destname, tnm, tlen); /* increments Isize */
-
- error = coda_call(mdp, Isize, &Osize, (char *)inp);
-
- CODA_FREE(inp, coda_rename_size);
- return error;
-}
-
-int
-venus_mkdir(void *mdp, ViceFid *fid,
- const char *nm, int len, struct vattr *va,
- struct ucred *cred, struct proc *p,
-/*out*/ ViceFid *VFid, struct vattr *ova)
-{
- DECL(coda_mkdir); /* sets Isize & Osize */
- coda_mkdir_size += len + 1;
- ALLOC(coda_mkdir); /* sets inp & outp */
-
- /* send the open to venus. */
- INIT_IN(&inp->ih, CODA_MKDIR, cred, p);
- inp->VFid = *fid;
- CNV_V2VV_ATTR(&inp->attr, va);
-
- inp->name = Isize;
- STRCPY(name, nm, len); /* increments Isize */
-
- error = coda_call(mdp, Isize, &Osize, (char *)inp);
- if (!error) {
- *VFid = outp->VFid;
- CNV_VV2V_ATTR(ova, &outp->attr);
- }
-
- CODA_FREE(inp, coda_mkdir_size);
- return error;
-}
-
-int
-venus_rmdir(void *mdp, ViceFid *fid,
- const char *nm, int len,
- struct ucred *cred, struct proc *p)
-{
- DECL_NO_OUT(coda_rmdir); /* sets Isize & Osize */
- coda_rmdir_size += len + 1;
- ALLOC_NO_OUT(coda_rmdir); /* sets inp & outp */
-
- /* send the open to venus. */
- INIT_IN(&inp->ih, CODA_RMDIR, cred, p);
- inp->VFid = *fid;
-
- inp->name = Isize;
- STRCPY(name, nm, len); /* increments Isize */
-
- error = coda_call(mdp, Isize, &Osize, (char *)inp);
-
- CODA_FREE(inp, coda_rmdir_size);
- return error;
-}
-
-int
-venus_symlink(void *mdp, ViceFid *fid,
- const char *lnm, int llen, const char *nm, int len, struct vattr *va,
- struct ucred *cred, struct proc *p)
-{
- DECL_NO_OUT(coda_symlink); /* sets Isize & Osize */
- coda_symlink_size += llen + 1 + len + 1;
- ALLOC_NO_OUT(coda_symlink); /* sets inp & outp */
-
- /* send the open to venus. */
- INIT_IN(&inp->ih, CODA_SYMLINK, cred, p);
- inp->VFid = *fid;
- CNV_V2VV_ATTR(&inp->attr, va);
-
- inp->srcname = Isize;
- STRCPY(srcname, lnm, llen); /* increments Isize */
-
- inp->tname = Isize;
- STRCPY(tname, nm, len); /* increments Isize */
-
- error = coda_call(mdp, Isize, &Osize, (char *)inp);
-
- CODA_FREE(inp, coda_symlink_size);
- return error;
-}
-
-int
-venus_readdir(void *mdp, ViceFid *fid,
- int count, int offset,
- struct ucred *cred, struct proc *p,
-/*out*/ char *buffer, int *len)
-{
- DECL(coda_readdir); /* sets Isize & Osize */
- coda_readdir_size = VC_MAXMSGSIZE;
- ALLOC(coda_readdir); /* sets inp & outp */
-
- /* send the open to venus. */
- INIT_IN(&inp->ih, CODA_READDIR, cred, p);
- inp->VFid = *fid;
- inp->count = count;
- inp->offset = offset;
-
- Osize = VC_MAXMSGSIZE;
- error = coda_call(mdp, Isize, &Osize, (char *)inp);
- if (!error) {
- bcopy((char *)outp + (int)outp->data, buffer, outp->size);
- *len = outp->size;
- }
-
- CODA_FREE(inp, coda_readdir_size);
- return error;
-}
-
-int
-venus_fhtovp(void *mdp, ViceFid *fid,
- struct ucred *cred, struct proc *p,
-/*out*/ ViceFid *VFid, int *vtype)
-{
- DECL(coda_vget); /* sets Isize & Osize */
- ALLOC(coda_vget); /* sets inp & outp */
-
- /* Send the open to Venus. */
- INIT_IN(&inp->ih, CODA_VGET, cred, p);
- inp->VFid = *fid;
-
- error = coda_call(mdp, Isize, &Osize, (char *)inp);
- if (!error) {
- *VFid = outp->VFid;
- *vtype = outp->vtype;
- }
-
- CODA_FREE(inp, coda_vget_size);
- return error;
-}
diff --git a/sys/fs/coda/coda_venus.h b/sys/fs/coda/coda_venus.h
deleted file mode 100644
index 392a73f07114..000000000000
--- a/sys/fs/coda/coda_venus.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- *
- * Coda: an Experimental Distributed File System
- * Release 3.1
- *
- * Copyright (c) 1987-1998 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, and
- * that credit is given to Carnegie Mellon University in all documents
- * and publicity pertaining to direct or indirect use of this code or its
- * derivatives.
- *
- * CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS KNOWN TO HAVE BUGS,
- * SOME OF WHICH MAY HAVE SERIOUS CONSEQUENCES. 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 DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE OR OF
- * ANY DERIVATIVE WORK.
- *
- * Carnegie Mellon encourages users of this software to return any
- * improvements or extensions that they make, and to grant Carnegie
- * Mellon the rights to redistribute these changes without encumbrance.
- *
- * @(#) src/sys/coda/coda_venus.h,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $
- * $FreeBSD$
- *
- */
-
-int
-venus_root(void *mdp,
- struct ucred *cred, struct proc *p,
-/*out*/ ViceFid *VFid);
-
-int
-venus_open(void *mdp, ViceFid *fid, int flag,
- struct ucred *cred, struct proc *p,
-/*out*/ dev_t *dev, ino_t *inode);
-
-int
-venus_close(void *mdp, ViceFid *fid, int flag,
- struct ucred *cred, struct proc *p);
-
-void
-venus_read(void);
-
-void
-venus_write(void);
-
-int
-venus_ioctl(void *mdp, ViceFid *fid,
- int com, int flag, caddr_t data,
- struct ucred *cred, struct proc *p);
-
-int
-venus_getattr(void *mdp, ViceFid *fid,
- struct ucred *cred, struct proc *p,
-/*out*/ struct vattr *vap);
-
-int
-venus_setattr(void *mdp, ViceFid *fid, struct vattr *vap,
- struct ucred *cred, struct proc *p);
-
-int
-venus_access(void *mdp, ViceFid *fid, int mode,
- struct ucred *cred, struct proc *p);
-
-int
-venus_readlink(void *mdp, ViceFid *fid,
- struct ucred *cred, struct proc *p,
-/*out*/ char **str, int *len);
-
-int
-venus_fsync(void *mdp, ViceFid *fid,
- struct ucred *cred, struct proc *p);
-
-int
-venus_lookup(void *mdp, ViceFid *fid,
- const char *nm, int len,
- struct ucred *cred, struct proc *p,
-/*out*/ ViceFid *VFid, int *vtype);
-
-int
-venus_create(void *mdp, ViceFid *fid,
- const char *nm, int len, int exclusive, int mode, struct vattr *va,
- struct ucred *cred, struct proc *p,
-/*out*/ ViceFid *VFid, struct vattr *attr);
-
-int
-venus_remove(void *mdp, ViceFid *fid,
- const char *nm, int len,
- struct ucred *cred, struct proc *p);
-
-int
-venus_link(void *mdp, ViceFid *fid, ViceFid *tfid,
- const char *nm, int len,
- struct ucred *cred, struct proc *p);
-
-int
-venus_rename(void *mdp, ViceFid *fid, ViceFid *tfid,
- const char *nm, int len, const char *tnm, int tlen,
- struct ucred *cred, struct proc *p);
-
-int
-venus_mkdir(void *mdp, ViceFid *fid,
- const char *nm, int len, struct vattr *va,
- struct ucred *cred, struct proc *p,
-/*out*/ ViceFid *VFid, struct vattr *ova);
-
-int
-venus_rmdir(void *mdp, ViceFid *fid,
- const char *nm, int len,
- struct ucred *cred, struct proc *p);
-
-int
-venus_symlink(void *mdp, ViceFid *fid,
- const char *lnm, int llen, const char *nm, int len, struct vattr *va,
- struct ucred *cred, struct proc *p);
-
-int
-venus_readdir(void *mdp, ViceFid *fid,
- int count, int offset,
- struct ucred *cred, struct proc *p,
-/*out*/ char *buffer, int *len);
-
-int
-venus_fhtovp(void *mdp, ViceFid *fid,
- struct ucred *cred, struct proc *p,
-/*out*/ ViceFid *VFid, int *vtype);
diff --git a/sys/fs/coda/coda_vfsops.c b/sys/fs/coda/coda_vfsops.c
deleted file mode 100644
index 7450c979b678..000000000000
--- a/sys/fs/coda/coda_vfsops.c
+++ /dev/null
@@ -1,542 +0,0 @@
-/*
- *
- * Coda: an Experimental Distributed File System
- * Release 3.1
- *
- * Copyright (c) 1987-1998 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, and
- * that credit is given to Carnegie Mellon University in all documents
- * and publicity pertaining to direct or indirect use of this code or its
- * derivatives.
- *
- * CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS KNOWN TO HAVE BUGS,
- * SOME OF WHICH MAY HAVE SERIOUS CONSEQUENCES. 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 DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE OR OF
- * ANY DERIVATIVE WORK.
- *
- * Carnegie Mellon encourages users of this software to return any
- * improvements or extensions that they make, and to grant Carnegie
- * Mellon the rights to redistribute these changes without encumbrance.
- *
- * @(#) src/sys/cfs/coda_vfsops.c,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $
- * $FreeBSD$
- *
- */
-
-/*
- * Mach Operating System
- * Copyright (c) 1989 Carnegie-Mellon University
- * All rights reserved. The CMU software License Agreement specifies
- * the terms and conditions for use and redistribution.
- */
-
-/*
- * This code was written for the Coda file system at Carnegie Mellon
- * University. Contributers include David Steere, James Kistler, and
- * M. Satyanarayanan.
- */
-
-#include <vcoda.h>
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/proc.h>
-#include <sys/malloc.h>
-#include <sys/conf.h>
-#include <sys/namei.h>
-#include <sys/mount.h>
-#include <sys/select.h>
-
-#include <vm/vm_zone.h>
-
-#include <coda/coda.h>
-#include <coda/cnode.h>
-#include <coda/coda_vfsops.h>
-#include <coda/coda_venus.h>
-#include <coda/coda_subr.h>
-#include <coda/coda_opstats.h>
-
-MALLOC_DEFINE(M_CODA, "CODA storage", "Various Coda Structures");
-
-int codadebug = 0;
-int coda_vfsop_print_entry = 0;
-#define ENTRY if(coda_vfsop_print_entry) myprintf(("Entered %s\n",__FUNCTION__))
-
-struct vnode *coda_ctlvp;
-struct coda_mntinfo coda_mnttbl[NVCODA]; /* indexed by minor device number */
-
-/* structure to keep statistics of internally generated/satisfied calls */
-
-struct coda_op_stats coda_vfsopstats[CODA_VFSOPS_SIZE];
-
-#define MARK_ENTRY(op) (coda_vfsopstats[op].entries++)
-#define MARK_INT_SAT(op) (coda_vfsopstats[op].sat_intrn++)
-#define MARK_INT_FAIL(op) (coda_vfsopstats[op].unsat_intrn++)
-#define MRAK_INT_GEN(op) (coda_vfsopstats[op].gen_intrn++)
-
-extern int coda_nc_initialized; /* Set if cache has been initialized */
-extern int vc_nb_open __P((dev_t, int, int, struct proc *));
-
-int
-coda_vfsopstats_init(void)
-{
- register int i;
-
- for (i=0;i<CODA_VFSOPS_SIZE;i++) {
- coda_vfsopstats[i].opcode = i;
- coda_vfsopstats[i].entries = 0;
- coda_vfsopstats[i].sat_intrn = 0;
- coda_vfsopstats[i].unsat_intrn = 0;
- coda_vfsopstats[i].gen_intrn = 0;
- }
-
- return 0;
-}
-
-/*
- * cfs mount vfsop
- * Set up mount info record and attach it to vfs struct.
- */
-/*ARGSUSED*/
-int
-coda_mount(vfsp, path, data, ndp, p)
- struct mount *vfsp; /* Allocated and initialized by mount(2) */
- char *path; /* path covered: ignored by the fs-layer */
- caddr_t data; /* Need to define a data type for this in netbsd? */
- struct nameidata *ndp; /* Clobber this to lookup the device name */
- struct proc *p; /* The ever-famous proc pointer */
-{
- struct vnode *dvp;
- struct cnode *cp;
- dev_t dev;
- struct coda_mntinfo *mi;
- struct vnode *rootvp;
- ViceFid rootfid;
- ViceFid ctlfid;
- int error;
-
- ENTRY;
-
- coda_vfsopstats_init();
- coda_vnodeopstats_init();
-
- MARK_ENTRY(CODA_MOUNT_STATS);
- if (CODA_MOUNTED(vfsp)) {
- MARK_INT_FAIL(CODA_MOUNT_STATS);
- return(EBUSY);
- }
-
- /* Validate mount device. Similar to getmdev(). */
- NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, data, p);
- error = namei(ndp);
- dvp = ndp->ni_vp;
-
- if (error) {
- MARK_INT_FAIL(CODA_MOUNT_STATS);
- return (error);
- }
- if (dvp->v_type != VCHR) {
- MARK_INT_FAIL(CODA_MOUNT_STATS);
- vrele(dvp);
- NDFREE(ndp, NDF_ONLY_PNBUF);
- return(ENXIO);
- }
- dev = dvp->v_rdev;
- vrele(dvp);
- NDFREE(ndp, NDF_ONLY_PNBUF);
-
- /*
- * See if the device table matches our expectations.
- */
- if (devsw(dev)->d_open != vc_nb_open)
- {
- MARK_INT_FAIL(CODA_MOUNT_STATS);
- return(ENXIO);
- }
-
- if (minor(dev) >= NVCODA || minor(dev) < 0) {
- MARK_INT_FAIL(CODA_MOUNT_STATS);
- return(ENXIO);
- }
-
- /*
- * Initialize the mount record and link it to the vfs struct
- */
- mi = &coda_mnttbl[minor(dev)];
-
- if (!VC_OPEN(&mi->mi_vcomm)) {
- MARK_INT_FAIL(CODA_MOUNT_STATS);
- return(ENODEV);
- }
-
- /* No initialization (here) of mi_vcomm! */
- vfsp->mnt_data = (qaddr_t)mi;
- vfs_getnewfsid (vfsp);
-
- mi->mi_vfsp = vfsp;
-
- /*
- * Make a root vnode to placate the Vnode interface, but don't
- * actually make the CODA_ROOT call to venus until the first call
- * to coda_root in case a server is down while venus is starting.
- */
- rootfid.Volume = 0;
- rootfid.Vnode = 0;
- rootfid.Unique = 0;
- cp = make_coda_node(&rootfid, vfsp, VDIR);
- rootvp = CTOV(cp);
- rootvp->v_flag |= VROOT;
-
- ctlfid.Volume = CTL_VOL;
- ctlfid.Vnode = CTL_VNO;
- ctlfid.Unique = CTL_UNI;
-/* cp = make_coda_node(&ctlfid, vfsp, VCHR);
- The above code seems to cause a loop in the cnode links.
- I don't totally understand when it happens, it is caught
- when closing down the system.
- */
- cp = make_coda_node(&ctlfid, 0, VCHR);
-
- coda_ctlvp = CTOV(cp);
-
- /* Add vfs and rootvp to chain of vfs hanging off mntinfo */
- mi->mi_vfsp = vfsp;
- mi->mi_rootvp = rootvp;
-
- /* set filesystem block size */
- vfsp->mnt_stat.f_bsize = 8192; /* XXX -JJK */
-
- /* Set f_iosize. XXX -- inamura@isl.ntt.co.jp.
- For vnode_pager_haspage() references. The value should be obtained
- from underlying UFS. */
- /* Checked UFS. iosize is set as 8192 */
- vfsp->mnt_stat.f_iosize = 8192;
-
- /* error is currently guaranteed to be zero, but in case some
- code changes... */
- CODADEBUG(1,
- myprintf(("coda_mount returned %d\n",error)););
- if (error)
- MARK_INT_FAIL(CODA_MOUNT_STATS);
- else
- MARK_INT_SAT(CODA_MOUNT_STATS);
-
- return(error);
-}
-
-int
-coda_unmount(vfsp, mntflags, p)
- struct mount *vfsp;
- int mntflags;
- struct proc *p;
-{
- struct coda_mntinfo *mi = vftomi(vfsp);
- int active, error = 0;
-
- ENTRY;
- MARK_ENTRY(CODA_UMOUNT_STATS);
- if (!CODA_MOUNTED(vfsp)) {
- MARK_INT_FAIL(CODA_UMOUNT_STATS);
- return(EINVAL);
- }
-
- if (mi->mi_vfsp == vfsp) { /* We found the victim */
- if (!IS_UNMOUNTING(VTOC(mi->mi_rootvp)))
- return (EBUSY); /* Venus is still running */
-
-#ifdef DEBUG
- printf("coda_unmount: ROOT: vp %p, cp %p\n", mi->mi_rootvp, VTOC(mi->mi_rootvp));
-#endif
- vrele(mi->mi_rootvp);
-
- active = coda_kill(vfsp, NOT_DOWNCALL);
- mi->mi_rootvp->v_flag &= ~VROOT;
- error = vflush(mi->mi_vfsp, NULLVP, FORCECLOSE);
- printf("coda_unmount: active = %d, vflush active %d\n", active, error);
- error = 0;
- /* I'm going to take this out to allow lookups to go through. I'm
- * not sure it's important anyway. -- DCS 2/2/94
- */
- /* vfsp->VFS_DATA = NULL; */
-
- /* No more vfsp's to hold onto */
- mi->mi_vfsp = NULL;
- mi->mi_rootvp = NULL;
-
- if (error)
- MARK_INT_FAIL(CODA_UMOUNT_STATS);
- else
- MARK_INT_SAT(CODA_UMOUNT_STATS);
-
- return(error);
- }
- return (EINVAL);
-}
-
-/*
- * find root of cfs
- */
-int
-coda_root(vfsp, vpp)
- struct mount *vfsp;
- struct vnode **vpp;
-{
- struct coda_mntinfo *mi = vftomi(vfsp);
- struct vnode **result;
- int error;
- struct proc *p = curproc; /* XXX - bnoble */
- ViceFid VFid;
-
- ENTRY;
- MARK_ENTRY(CODA_ROOT_STATS);
- result = NULL;
-
- if (vfsp == mi->mi_vfsp) {
- if ((VTOC(mi->mi_rootvp)->c_fid.Volume != 0) ||
- (VTOC(mi->mi_rootvp)->c_fid.Vnode != 0) ||
- (VTOC(mi->mi_rootvp)->c_fid.Unique != 0))
- { /* Found valid root. */
- *vpp = mi->mi_rootvp;
- /* On Mach, this is vref. On NetBSD, VOP_LOCK */
-#if 1
- vref(*vpp);
- vn_lock(*vpp, LK_EXCLUSIVE, p);
-#else
- vget(*vpp, LK_EXCLUSIVE, p);
-#endif
- MARK_INT_SAT(CODA_ROOT_STATS);
- return(0);
- }
- }
-
- error = venus_root(vftomi(vfsp), p->p_ucred, p, &VFid);
-
- if (!error) {
- /*
- * Save the new rootfid in the cnode, and rehash the cnode into the
- * cnode hash with the new fid key.
- */
- coda_unsave(VTOC(mi->mi_rootvp));
- VTOC(mi->mi_rootvp)->c_fid = VFid;
- coda_save(VTOC(mi->mi_rootvp));
-
- *vpp = mi->mi_rootvp;
-#if 1
- vref(*vpp);
- vn_lock(*vpp, LK_EXCLUSIVE, p);
-#else
- vget(*vpp, LK_EXCLUSIVE, p);
-#endif
-
- MARK_INT_SAT(CODA_ROOT_STATS);
- goto exit;
- } else if (error == ENODEV || error == EINTR) {
- /* Gross hack here! */
- /*
- * If Venus fails to respond to the CODA_ROOT call, coda_call returns
- * ENODEV. Return the uninitialized root vnode to allow vfs
- * operations such as unmount to continue. Without this hack,
- * there is no way to do an unmount if Venus dies before a
- * successful CODA_ROOT call is done. All vnode operations
- * will fail.
- */
- *vpp = mi->mi_rootvp;
-#if 1
- vref(*vpp);
- vn_lock(*vpp, LK_EXCLUSIVE, p);
-#else
- vget(*vpp, LK_EXCLUSIVE, p);
-#endif
-
- MARK_INT_FAIL(CODA_ROOT_STATS);
- error = 0;
- goto exit;
- } else {
- CODADEBUG( CODA_ROOT, myprintf(("error %d in CODA_ROOT\n", error)); );
- MARK_INT_FAIL(CODA_ROOT_STATS);
-
- goto exit;
- }
-
- exit:
- return(error);
-}
-
-/*
- * Get file system statistics.
- */
-int
-coda_nb_statfs(vfsp, sbp, p)
- register struct mount *vfsp;
- struct statfs *sbp;
- struct proc *p;
-{
- ENTRY;
-/* MARK_ENTRY(CODA_STATFS_STATS); */
- if (!CODA_MOUNTED(vfsp)) {
-/* MARK_INT_FAIL(CODA_STATFS_STATS);*/
- return(EINVAL);
- }
-
- bzero(sbp, sizeof(struct statfs));
- /* XXX - what to do about f_flags, others? --bnoble */
- /* Below This is what AFS does
- #define NB_SFS_SIZ 0x895440
- */
- /* Note: Normal fs's have a bsize of 0x400 == 1024 */
- sbp->f_type = vfsp->mnt_vfc->vfc_typenum;
- sbp->f_bsize = 8192; /* XXX */
- sbp->f_iosize = 8192; /* XXX */
-#define NB_SFS_SIZ 0x8AB75D
- sbp->f_blocks = NB_SFS_SIZ;
- sbp->f_bfree = NB_SFS_SIZ;
- sbp->f_bavail = NB_SFS_SIZ;
- sbp->f_files = NB_SFS_SIZ;
- sbp->f_ffree = NB_SFS_SIZ;
- bcopy((caddr_t)&(vfsp->mnt_stat.f_fsid), (caddr_t)&(sbp->f_fsid), sizeof (fsid_t));
- snprintf(sbp->f_mntonname, sizeof(sbp->f_mntonname), "/coda");
- snprintf(sbp->f_mntfromname, sizeof(sbp->f_mntfromname), "CODA");
-/* MARK_INT_SAT(CODA_STATFS_STATS); */
- return(0);
-}
-
-/*
- * Flush any pending I/O.
- */
-int
-coda_sync(vfsp, waitfor, cred, p)
- struct mount *vfsp;
- int waitfor;
- struct ucred *cred;
- struct proc *p;
-{
- ENTRY;
- MARK_ENTRY(CODA_SYNC_STATS);
- MARK_INT_SAT(CODA_SYNC_STATS);
- return(0);
-}
-
-/*
- * fhtovp is now what vget used to be in 4.3-derived systems. For
- * some silly reason, vget is now keyed by a 32 bit ino_t, rather than
- * a type-specific fid.
- */
-int
-coda_fhtovp(vfsp, fhp, nam, vpp, exflagsp, creadanonp)
- register struct mount *vfsp;
- struct fid *fhp;
- struct mbuf *nam;
- struct vnode **vpp;
- int *exflagsp;
- struct ucred **creadanonp;
-{
- struct cfid *cfid = (struct cfid *)fhp;
- struct cnode *cp = 0;
- int error;
- struct proc *p = curproc; /* XXX -mach */
- ViceFid VFid;
- int vtype;
-
- ENTRY;
-
- MARK_ENTRY(CODA_VGET_STATS);
- /* Check for vget of control object. */
- if (IS_CTL_FID(&cfid->cfid_fid)) {
- *vpp = coda_ctlvp;
- vref(coda_ctlvp);
- MARK_INT_SAT(CODA_VGET_STATS);
- return(0);
- }
-
- error = venus_fhtovp(vftomi(vfsp), &cfid->cfid_fid, p->p_ucred, p, &VFid, &vtype);
-
- if (error) {
- CODADEBUG(CODA_VGET, myprintf(("vget error %d\n",error));)
- *vpp = (struct vnode *)0;
- } else {
- CODADEBUG(CODA_VGET,
- myprintf(("vget: vol %lx vno %lx uni %lx type %d result %d\n",
- VFid.Volume, VFid.Vnode, VFid.Unique, vtype, error)); )
-
- cp = make_coda_node(&VFid, vfsp, vtype);
- *vpp = CTOV(cp);
- }
- return(error);
-}
-
-/*
- * To allow for greater ease of use, some vnodes may be orphaned when
- * Venus dies. Certain operations should still be allowed to go
- * through, but without propagating ophan-ness. So this function will
- * get a new vnode for the file from the current run of Venus. */
-
-int
-getNewVnode(vpp)
- struct vnode **vpp;
-{
- struct cfid cfid;
- struct coda_mntinfo *mi = vftomi((*vpp)->v_mount);
-
- ENTRY;
-
- cfid.cfid_len = (short)sizeof(ViceFid);
- cfid.cfid_fid = VTOC(*vpp)->c_fid; /* Structure assignment. */
- /* XXX ? */
-
- /* We're guessing that if set, the 1st element on the list is a
- * valid vnode to use. If not, return ENODEV as venus is dead.
- */
- if (mi->mi_vfsp == NULL)
- return ENODEV;
-
- return coda_fhtovp(mi->mi_vfsp, (struct fid*)&cfid, NULL, vpp,
- NULL, NULL);
-}
-
-#include <ufs/ufs/quota.h>
-#include <ufs/ufs/ufsmount.h>
-/* get the mount structure corresponding to a given device. Assume
- * device corresponds to a UFS. Return NULL if no device is found.
- */
-struct mount *devtomp(dev)
- dev_t dev;
-{
- struct mount *mp;
-
- TAILQ_FOREACH(mp, &mountlist, mnt_list) {
- if (((VFSTOUFS(mp))->um_dev == dev)) {
- /* mount corresponds to UFS and the device matches one we want */
- return(mp);
- }
- }
- /* mount structure wasn't found */
- return(NULL);
-}
-
-struct vfsops coda_vfsops = {
- coda_mount,
- vfs_stdstart,
- coda_unmount,
- coda_root,
- vfs_stdquotactl,
- coda_nb_statfs,
- coda_sync,
- vfs_stdvget,
- vfs_stdfhtovp,
- vfs_stdcheckexp,
- vfs_stdvptofh,
- vfs_stdinit,
- vfs_stduninit,
- vfs_stdextattrctl,
-};
-
-VFS_SET(coda_vfsops, coda, VFCF_NETWORK);
diff --git a/sys/fs/coda/coda_vfsops.h b/sys/fs/coda/coda_vfsops.h
deleted file mode 100644
index 13a006d1b1c7..000000000000
--- a/sys/fs/coda/coda_vfsops.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- *
- * Coda: an Experimental Distributed File System
- * Release 3.1
- *
- * Copyright (c) 1987-1998 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, and
- * that credit is given to Carnegie Mellon University in all documents
- * and publicity pertaining to direct or indirect use of this code or its
- * derivatives.
- *
- * CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS KNOWN TO HAVE BUGS,
- * SOME OF WHICH MAY HAVE SERIOUS CONSEQUENCES. 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 DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE OR OF
- * ANY DERIVATIVE WORK.
- *
- * Carnegie Mellon encourages users of this software to return any
- * improvements or extensions that they make, and to grant Carnegie
- * Mellon the rights to redistribute these changes without encumbrance.
- *
- * @(#) src/sys/cfs/coda_vfsops.h,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $
- * $FreeBSD$
- *
- */
-
-/*
- * cfid structure:
- * This overlays the fid structure (see vfs.h)
- * Only used below and will probably go away.
- */
-
-struct cfid {
- u_short cfid_len;
- u_short padding;
- ViceFid cfid_fid;
-};
-
-struct mount;
-
-int coda_vfsopstats_init(void);
-int coda_mount(struct mount *, char *, caddr_t, struct nameidata *,
- struct proc *);
-int coda_start(struct mount *, int, struct proc *);
-int coda_unmount(struct mount *, int, struct proc *);
-int coda_root(struct mount *, struct vnode **);
-int coda_quotactl(struct mount *, int, uid_t, caddr_t, struct proc *);
-int coda_nb_statfs(struct mount *, struct statfs *, struct proc *);
-int coda_sync(struct mount *, int, struct ucred *, struct proc *);
-int coda_vget(struct mount *, ino_t, struct vnode **);
-int coda_fhtovp(struct mount *, struct fid *, struct mbuf *, struct vnode **,
- int *, struct ucred **);
-int coda_vptofh(struct vnode *, struct fid *);
-int coda_init(struct vfsconf *vfsp);
-
-int getNewVnode(struct vnode **vpp);
diff --git a/sys/fs/coda/coda_vnops.c b/sys/fs/coda/coda_vnops.c
deleted file mode 100644
index 761ebcc6a971..000000000000
--- a/sys/fs/coda/coda_vnops.c
+++ /dev/null
@@ -1,1957 +0,0 @@
-/*
- *
- * Coda: an Experimental Distributed File System
- * Release 3.1
- *
- * Copyright (c) 1987-1998 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, and
- * that credit is given to Carnegie Mellon University in all documents
- * and publicity pertaining to direct or indirect use of this code or its
- * derivatives.
- *
- * CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS KNOWN TO HAVE BUGS,
- * SOME OF WHICH MAY HAVE SERIOUS CONSEQUENCES. 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 DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE OR OF
- * ANY DERIVATIVE WORK.
- *
- * Carnegie Mellon encourages users of this software to return any
- * improvements or extensions that they make, and to grant Carnegie
- * Mellon the rights to redistribute these changes without encumbrance.
- *
- * @(#) src/sys/coda/coda_vnops.c,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $
- * $FreeBSD$
- *
- */
-
-/*
- * Mach Operating System
- * Copyright (c) 1990 Carnegie-Mellon University
- * Copyright (c) 1989 Carnegie-Mellon University
- * All rights reserved. The CMU software License Agreement specifies
- * the terms and conditions for use and redistribution.
- */
-
-/*
- * This code was written for the Coda file system at Carnegie Mellon
- * University. Contributers include David Steere, James Kistler, and
- * M. Satyanarayanan.
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/proc.h>
-#include <sys/malloc.h>
-#include <sys/mount.h>
-#include <sys/errno.h>
-#include <sys/acct.h>
-#include <sys/file.h>
-#include <sys/fcntl.h>
-#include <sys/uio.h>
-#include <sys/namei.h>
-#include <sys/ioccom.h>
-#include <sys/select.h>
-
-#include <vm/vm.h>
-#include <vm/vm_object.h>
-#include <vm/vm_extern.h>
-#include <vm/vm_zone.h>
-
-#include <coda/coda.h>
-#include <coda/cnode.h>
-#include <coda/coda_vnops.h>
-#include <coda/coda_venus.h>
-#include <coda/coda_opstats.h>
-#include <coda/coda_subr.h>
-#include <coda/coda_namecache.h>
-#include <coda/coda_pioctl.h>
-
-/*
- * These flags select various performance enhancements.
- */
-int coda_attr_cache = 1; /* Set to cache attributes in the kernel */
-int coda_symlink_cache = 1; /* Set to cache symbolic link information */
-int coda_access_cache = 1; /* Set to handle some access checks directly */
-
-/* structure to keep track of vfs calls */
-
-struct coda_op_stats coda_vnodeopstats[CODA_VNODEOPS_SIZE];
-
-#define MARK_ENTRY(op) (coda_vnodeopstats[op].entries++)
-#define MARK_INT_SAT(op) (coda_vnodeopstats[op].sat_intrn++)
-#define MARK_INT_FAIL(op) (coda_vnodeopstats[op].unsat_intrn++)
-#define MARK_INT_GEN(op) (coda_vnodeopstats[op].gen_intrn++)
-
-/* What we are delaying for in printf */
-int coda_printf_delay = 0; /* in microseconds */
-int coda_vnop_print_entry = 0;
-static int coda_lockdebug = 0;
-
-/* Definition of the vfs operation vector */
-
-/*
- * Some NetBSD details:
- *
- * coda_start is called at the end of the mount syscall.
- * coda_init is called at boot time.
- */
-
-#define ENTRY if(coda_vnop_print_entry) myprintf(("Entered %s\n",__FUNCTION__))
-
-/* Definition of the vnode operation vector */
-
-struct vnodeopv_entry_desc coda_vnodeop_entries[] = {
- { &vop_default_desc, coda_vop_error },
- { &vop_lookup_desc, coda_lookup }, /* lookup */
- { &vop_create_desc, coda_create }, /* create */
- { &vop_mknod_desc, coda_vop_error }, /* mknod */
- { &vop_open_desc, coda_open }, /* open */
- { &vop_close_desc, coda_close }, /* close */
- { &vop_access_desc, coda_access }, /* access */
- { &vop_getattr_desc, coda_getattr }, /* getattr */
- { &vop_setattr_desc, coda_setattr }, /* setattr */
- { &vop_read_desc, coda_read }, /* read */
- { &vop_write_desc, coda_write }, /* write */
- { &vop_ioctl_desc, coda_ioctl }, /* ioctl */
- { &vop_mmap_desc, coda_vop_error }, /* mmap */
- { &vop_fsync_desc, coda_fsync }, /* fsync */
- { &vop_remove_desc, coda_remove }, /* remove */
- { &vop_link_desc, coda_link }, /* link */
- { &vop_rename_desc, coda_rename }, /* rename */
- { &vop_mkdir_desc, coda_mkdir }, /* mkdir */
- { &vop_rmdir_desc, coda_rmdir }, /* rmdir */
- { &vop_symlink_desc, coda_symlink }, /* symlink */
- { &vop_readdir_desc, coda_readdir }, /* readdir */
- { &vop_readlink_desc, coda_readlink }, /* readlink */
- { &vop_inactive_desc, coda_inactive }, /* inactive */
- { &vop_reclaim_desc, coda_reclaim }, /* reclaim */
- { &vop_lock_desc, coda_lock }, /* lock */
- { &vop_unlock_desc, coda_unlock }, /* unlock */
- { &vop_bmap_desc, coda_bmap }, /* bmap */
- { &vop_strategy_desc, coda_strategy }, /* strategy */
- { &vop_print_desc, coda_vop_error }, /* print */
- { &vop_islocked_desc, coda_islocked }, /* islocked */
- { &vop_pathconf_desc, coda_vop_error }, /* pathconf */
- { &vop_advlock_desc, coda_vop_nop }, /* advlock */
- { &vop_bwrite_desc, coda_vop_error }, /* bwrite */
- { &vop_lease_desc, coda_vop_nop }, /* lease */
- { &vop_poll_desc, (vop_t *) vop_stdpoll },
- { &vop_getpages_desc, coda_fbsd_getpages }, /* pager intf.*/
- { &vop_putpages_desc, coda_fbsd_putpages }, /* pager intf.*/
-
-#if 0
-
- we need to define these someday
-#define UFS_BLKATOFF(aa, bb, cc, dd) VFSTOUFS((aa)->v_mount)->um_blkatoff(aa, bb, cc, dd)
-#define UFS_VALLOC(aa, bb, cc, dd) VFSTOUFS((aa)->v_mount)->um_valloc(aa, bb, cc, dd)
-#define UFS_VFREE(aa, bb, cc) VFSTOUFS((aa)->v_mount)->um_vfree(aa, bb, cc)
-#define UFS_TRUNCATE(aa, bb, cc, dd, ee) VFSTOUFS((aa)->v_mount)->um_truncate(aa, bb, cc, dd, ee)
-#define UFS_UPDATE(aa, bb) VFSTOUFS((aa)->v_mount)->um_update(aa, bb)
-
- missing
- { &vop_reallocblks_desc, (vop_t *) ufs_missingop },
- { &vop_cachedlookup_desc, (vop_t *) ufs_lookup },
- { &vop_whiteout_desc, (vop_t *) ufs_whiteout },
-#endif
- { (struct vnodeop_desc*)NULL, (int(*)(void *))NULL }
-};
-
-static struct vnodeopv_desc coda_vnodeop_opv_desc =
- { &coda_vnodeop_p, coda_vnodeop_entries };
-
-VNODEOP_SET(coda_vnodeop_opv_desc);
-
-/* A generic panic: we were called with something we didn't define yet */
-int
-coda_vop_error(void *anon) {
- struct vnodeop_desc **desc = (struct vnodeop_desc **)anon;
-
- myprintf(("coda_vop_error: Vnode operation %s called, but not defined.\n",
- (*desc)->vdesc_name));
- /*
- panic("coda_vop_error");
- */
- return EIO;
-}
-
-/* A generic do-nothing. For lease_check, advlock */
-int
-coda_vop_nop(void *anon) {
- struct vnodeop_desc **desc = (struct vnodeop_desc **)anon;
-
- if (codadebug) {
- myprintf(("Vnode operation %s called, but unsupported\n",
- (*desc)->vdesc_name));
- }
- return (0);
-}
-
-int
-coda_vnodeopstats_init(void)
-{
- register int i;
-
- for(i=0;i<CODA_VNODEOPS_SIZE;i++) {
- coda_vnodeopstats[i].opcode = i;
- coda_vnodeopstats[i].entries = 0;
- coda_vnodeopstats[i].sat_intrn = 0;
- coda_vnodeopstats[i].unsat_intrn = 0;
- coda_vnodeopstats[i].gen_intrn = 0;
- }
- return 0;
-}
-
-/*
- * coda_open calls Venus to return the device, inode pair of the cache
- * file holding the data. Using iget, coda_open finds the vnode of the
- * cache file, and then opens it.
- */
-int
-coda_open(v)
- void *v;
-{
- /*
- * NetBSD can pass the O_EXCL flag in mode, even though the check
- * has already happened. Venus defensively assumes that if open
- * is passed the EXCL, it must be a bug. We strip the flag here.
- */
-/* true args */
- struct vop_open_args *ap = v;
- register struct vnode **vpp = &(ap->a_vp);
- struct cnode *cp = VTOC(*vpp);
- int flag = ap->a_mode & (~O_EXCL);
- struct ucred *cred = ap->a_cred;
- struct proc *p = ap->a_p;
-/* locals */
- int error;
- struct vnode *vp;
- dev_t dev;
- ino_t inode;
-
- MARK_ENTRY(CODA_OPEN_STATS);
-
- /* Check for open of control file. */
- if (IS_CTL_VP(*vpp)) {
- /* XXX */
- /* if (WRITEABLE(flag)) */
- if (flag & (FWRITE | O_TRUNC | O_CREAT | O_EXCL)) {
- MARK_INT_FAIL(CODA_OPEN_STATS);
- return(EACCES);
- }
- MARK_INT_SAT(CODA_OPEN_STATS);
- return(0);
- }
-
- error = venus_open(vtomi((*vpp)), &cp->c_fid, flag, cred, p, &dev, &inode);
- if (error)
- return (error);
- if (!error) {
- CODADEBUG( CODA_OPEN,myprintf(("open: dev %#lx inode %lu result %d\n",
- (u_long)dev2udev(dev), (u_long)inode,
- error)); )
- }
-
- /* Translate the <device, inode> pair for the cache file into
- an inode pointer. */
- error = coda_grab_vnode(dev, inode, &vp);
- if (error)
- return (error);
-
- /* We get the vnode back locked. Needs unlocked */
- VOP_UNLOCK(vp, 0, p);
- /* Keep a reference until the close comes in. */
- vref(*vpp);
-
- /* Save the vnode pointer for the cache file. */
- if (cp->c_ovp == NULL) {
- cp->c_ovp = vp;
- } else {
- if (cp->c_ovp != vp)
- panic("coda_open: cp->c_ovp != ITOV(ip)");
- }
- cp->c_ocount++;
-
- /* Flush the attribute cached if writing the file. */
- if (flag & FWRITE) {
- cp->c_owrite++;
- cp->c_flags &= ~C_VATTR;
- }
-
- /* Save the <device, inode> pair for the cache file to speed
- up subsequent page_read's. */
- cp->c_device = dev;
- cp->c_inode = inode;
-
- /* Open the cache file. */
- error = VOP_OPEN(vp, flag, cred, p);
- if (error) {
- printf("coda_open: VOP_OPEN on container failed %d\n", error);
- return (error);
- }
-/* grab (above) does this when it calls newvnode unless it's in the cache*/
- if (vp->v_type == VREG) {
- error = vfs_object_create(vp, p, cred);
- if (error != 0) {
- printf("coda_open: vfs_object_create() returns %d\n", error);
- vput(vp);
- }
- }
-
- return(error);
-}
-
-/*
- * Close the cache file used for I/O and notify Venus.
- */
-int
-coda_close(v)
- void *v;
-{
-/* true args */
- struct vop_close_args *ap = v;
- struct vnode *vp = ap->a_vp;
- struct cnode *cp = VTOC(vp);
- int flag = ap->a_fflag;
- struct ucred *cred = ap->a_cred;
- struct proc *p = ap->a_p;
-/* locals */
- int error;
-
- MARK_ENTRY(CODA_CLOSE_STATS);
-
- /* Check for close of control file. */
- if (IS_CTL_VP(vp)) {
- MARK_INT_SAT(CODA_CLOSE_STATS);
- return(0);
- }
-
- if (IS_UNMOUNTING(cp)) {
- if (cp->c_ovp) {
-#ifdef CODA_VERBOSE
- printf("coda_close: destroying container ref %d, ufs vp %p of vp %p/cp %p\n",
- vp->v_usecount, cp->c_ovp, vp, cp);
-#endif
-#ifdef hmm
- vgone(cp->c_ovp);
-#else
- VOP_CLOSE(cp->c_ovp, flag, cred, p); /* Do errors matter here? */
- vrele(cp->c_ovp);
-#endif
- } else {
-#ifdef CODA_VERBOSE
- printf("coda_close: NO container vp %p/cp %p\n", vp, cp);
-#endif
- }
- return ENODEV;
- } else {
- VOP_CLOSE(cp->c_ovp, flag, cred, p); /* Do errors matter here? */
- vrele(cp->c_ovp);
- }
-
- if (--cp->c_ocount == 0)
- cp->c_ovp = NULL;
-
- if (flag & FWRITE) /* file was opened for write */
- --cp->c_owrite;
-
- error = venus_close(vtomi(vp), &cp->c_fid, flag, cred, p);
- vrele(CTOV(cp));
-
- CODADEBUG(CODA_CLOSE, myprintf(("close: result %d\n",error)); )
- return(error);
-}
-
-int
-coda_read(v)
- void *v;
-{
- struct vop_read_args *ap = v;
-
- ENTRY;
- return(coda_rdwr(ap->a_vp, ap->a_uio, UIO_READ,
- ap->a_ioflag, ap->a_cred, ap->a_uio->uio_procp));
-}
-
-int
-coda_write(v)
- void *v;
-{
- struct vop_write_args *ap = v;
-
- ENTRY;
- return(coda_rdwr(ap->a_vp, ap->a_uio, UIO_WRITE,
- ap->a_ioflag, ap->a_cred, ap->a_uio->uio_procp));
-}
-
-int
-coda_rdwr(vp, uiop, rw, ioflag, cred, p)
- struct vnode *vp;
- struct uio *uiop;
- enum uio_rw rw;
- int ioflag;
- struct ucred *cred;
- struct proc *p;
-{
-/* upcall decl */
- /* NOTE: container file operation!!! */
-/* locals */
- struct cnode *cp = VTOC(vp);
- struct vnode *cfvp = cp->c_ovp;
- int igot_internally = 0;
- int opened_internally = 0;
- int error = 0;
-
- MARK_ENTRY(CODA_RDWR_STATS);
-
- CODADEBUG(CODA_RDWR, myprintf(("coda_rdwr(%d, %p, %d, %lld, %d)\n", rw,
- (void *)uiop->uio_iov->iov_base, uiop->uio_resid,
- (long long)uiop->uio_offset, uiop->uio_segflg)); )
-
- /* Check for rdwr of control object. */
- if (IS_CTL_VP(vp)) {
- MARK_INT_FAIL(CODA_RDWR_STATS);
- return(EINVAL);
- }
-
- /*
- * If file is not already open this must be a page
- * {read,write} request. Iget the cache file's inode
- * pointer if we still have its <device, inode> pair.
- * Otherwise, we must do an internal open to derive the
- * pair.
- */
- if (cfvp == NULL) {
- /*
- * If we're dumping core, do the internal open. Otherwise
- * venus won't have the correct size of the core when
- * it's completely written.
- */
- if (cp->c_inode != 0 && !(p && (p->p_acflag & ACORE))) {
- igot_internally = 1;
- error = coda_grab_vnode(cp->c_device, cp->c_inode, &cfvp);
- if (error) {
- MARK_INT_FAIL(CODA_RDWR_STATS);
- return(error);
- }
- /*
- * We get the vnode back locked in both Mach and
- * NetBSD. Needs unlocked
- */
- VOP_UNLOCK(cfvp, 0, p);
- }
- else {
- opened_internally = 1;
- MARK_INT_GEN(CODA_OPEN_STATS);
- error = VOP_OPEN(vp, (rw == UIO_READ ? FREAD : FWRITE),
- cred, p);
-printf("coda_rdwr: Internally Opening %p\n", vp);
- if (error) {
- printf("coda_rdwr: VOP_OPEN on container failed %d\n", error);
- return (error);
- }
- if (vp->v_type == VREG) {
- error = vfs_object_create(vp, p, cred);
- if (error != 0) {
- printf("coda_rdwr: vfs_object_create() returns %d\n", error);
- vput(vp);
- }
- }
- if (error) {
- MARK_INT_FAIL(CODA_RDWR_STATS);
- return(error);
- }
- cfvp = cp->c_ovp;
- }
- }
-
- /* Have UFS handle the call. */
- CODADEBUG(CODA_RDWR, myprintf(("indirect rdwr: fid = (%lx.%lx.%lx), refcnt = %d\n",
- cp->c_fid.Volume, cp->c_fid.Vnode,
- cp->c_fid.Unique, CTOV(cp)->v_usecount)); )
-
-
- if (rw == UIO_READ) {
- error = VOP_READ(cfvp, uiop, ioflag, cred);
- } else {
- error = VOP_WRITE(cfvp, uiop, ioflag, cred);
- /* ufs_write updates the vnode_pager_setsize for the vnode/object */
-
- { struct vattr attr;
-
- if (VOP_GETATTR(cfvp, &attr, cred, p) == 0) {
- vnode_pager_setsize(vp, attr.va_size);
- }
- }
- }
-
- if (error)
- MARK_INT_FAIL(CODA_RDWR_STATS);
- else
- MARK_INT_SAT(CODA_RDWR_STATS);
-
- /* Do an internal close if necessary. */
- if (opened_internally) {
- MARK_INT_GEN(CODA_CLOSE_STATS);
- (void)VOP_CLOSE(vp, (rw == UIO_READ ? FREAD : FWRITE), cred, p);
- }
-
- /* Invalidate cached attributes if writing. */
- if (rw == UIO_WRITE)
- cp->c_flags &= ~C_VATTR;
- return(error);
-}
-
-int
-coda_ioctl(v)
- void *v;
-{
-/* true args */
- struct vop_ioctl_args *ap = v;
- struct vnode *vp = ap->a_vp;
- int com = ap->a_command;
- caddr_t data = ap->a_data;
- int flag = ap->a_fflag;
- struct ucred *cred = ap->a_cred;
- struct proc *p = ap->a_p;
-/* locals */
- int error;
- struct vnode *tvp;
- struct nameidata ndp;
- struct PioctlData *iap = (struct PioctlData *)data;
-
- MARK_ENTRY(CODA_IOCTL_STATS);
-
- CODADEBUG(CODA_IOCTL, myprintf(("in coda_ioctl on %s\n", iap->path));)
-
- /* Don't check for operation on a dying object, for ctlvp it
- shouldn't matter */
-
- /* Must be control object to succeed. */
- if (!IS_CTL_VP(vp)) {
- MARK_INT_FAIL(CODA_IOCTL_STATS);
- CODADEBUG(CODA_IOCTL, myprintf(("coda_ioctl error: vp != ctlvp"));)
- return (EOPNOTSUPP);
- }
- /* Look up the pathname. */
-
- /* Should we use the name cache here? It would get it from
- lookupname sooner or later anyway, right? */
-
- NDINIT(&ndp, LOOKUP, (iap->follow ? FOLLOW : NOFOLLOW), UIO_USERSPACE, iap->path, p);
- error = namei(&ndp);
- tvp = ndp.ni_vp;
-
- if (error) {
- MARK_INT_FAIL(CODA_IOCTL_STATS);
- CODADEBUG(CODA_IOCTL, myprintf(("coda_ioctl error: lookup returns %d\n",
- error));)
- return(error);
- }
-
- /*
- * Make sure this is a coda style cnode, but it may be a
- * different vfsp
- */
- if (tvp->v_op != coda_vnodeop_p) {
- vrele(tvp);
- NDFREE(&ndp, NDF_ONLY_PNBUF);
- MARK_INT_FAIL(CODA_IOCTL_STATS);
- CODADEBUG(CODA_IOCTL,
- myprintf(("coda_ioctl error: %s not a coda object\n",
- iap->path));)
- return(EINVAL);
- }
-
- if (iap->vi.in_size > VC_MAXDATASIZE) {
- NDFREE(&ndp, 0);
- return(EINVAL);
- }
- error = venus_ioctl(vtomi(tvp), &((VTOC(tvp))->c_fid), com, flag, data, cred, p);
-
- if (error)
- MARK_INT_FAIL(CODA_IOCTL_STATS);
- else
- CODADEBUG(CODA_IOCTL, myprintf(("Ioctl returns %d \n", error)); )
-
- vrele(tvp);
- NDFREE(&ndp, NDF_ONLY_PNBUF);
- return(error);
-}
-
-/*
- * To reduce the cost of a user-level venus;we cache attributes in
- * the kernel. Each cnode has storage allocated for an attribute. If
- * c_vattr is valid, return a reference to it. Otherwise, get the
- * attributes from venus and store them in the cnode. There is some
- * question if this method is a security leak. But I think that in
- * order to make this call, the user must have done a lookup and
- * opened the file, and therefore should already have access.
- */
-int
-coda_getattr(v)
- void *v;
-{
-/* true args */
- struct vop_getattr_args *ap = v;
- struct vnode *vp = ap->a_vp;
- struct cnode *cp = VTOC(vp);
- struct vattr *vap = ap->a_vap;
- struct ucred *cred = ap->a_cred;
- struct proc *p = ap->a_p;
-/* locals */
- int error;
-
- MARK_ENTRY(CODA_GETATTR_STATS);
-
- if (IS_UNMOUNTING(cp))
- return ENODEV;
-
- /* Check for getattr of control object. */
- if (IS_CTL_VP(vp)) {
- MARK_INT_FAIL(CODA_GETATTR_STATS);
- return(ENOENT);
- }
-
- /* Check to see if the attributes have already been cached */
- if (VALID_VATTR(cp)) {
- CODADEBUG(CODA_GETATTR, { myprintf(("attr cache hit: (%lx.%lx.%lx)\n",
- cp->c_fid.Volume,
- cp->c_fid.Vnode,
- cp->c_fid.Unique));});
- CODADEBUG(CODA_GETATTR, if (!(codadebug & ~CODA_GETATTR))
- print_vattr(&cp->c_vattr); );
-
- *vap = cp->c_vattr;
- MARK_INT_SAT(CODA_GETATTR_STATS);
- return(0);
- }
-
- error = venus_getattr(vtomi(vp), &cp->c_fid, cred, p, vap);
-
- if (!error) {
- CODADEBUG(CODA_GETATTR, myprintf(("getattr miss (%lx.%lx.%lx): result %d\n",
- cp->c_fid.Volume,
- cp->c_fid.Vnode,
- cp->c_fid.Unique,
- error)); )
-
- CODADEBUG(CODA_GETATTR, if (!(codadebug & ~CODA_GETATTR))
- print_vattr(vap); );
-
- { int size = vap->va_size;
- struct vnode *convp = cp->c_ovp;
- if (convp != (struct vnode *)0) {
- vnode_pager_setsize(convp, size);
- }
- }
- /* If not open for write, store attributes in cnode */
- if ((cp->c_owrite == 0) && (coda_attr_cache)) {
- cp->c_vattr = *vap;
- cp->c_flags |= C_VATTR;
- }
-
- }
- return(error);
-}
-
-int
-coda_setattr(v)
- void *v;
-{
-/* true args */
- struct vop_setattr_args *ap = v;
- register struct vnode *vp = ap->a_vp;
- struct cnode *cp = VTOC(vp);
- register struct vattr *vap = ap->a_vap;
- struct ucred *cred = ap->a_cred;
- struct proc *p = ap->a_p;
-/* locals */
- int error;
-
- MARK_ENTRY(CODA_SETATTR_STATS);
-
- /* Check for setattr of control object. */
- if (IS_CTL_VP(vp)) {
- MARK_INT_FAIL(CODA_SETATTR_STATS);
- return(ENOENT);
- }
-
- if (codadebug & CODADBGMSK(CODA_SETATTR)) {
- print_vattr(vap);
- }
- error = venus_setattr(vtomi(vp), &cp->c_fid, vap, cred, p);
-
- if (!error)
- cp->c_flags &= ~C_VATTR;
-
- { int size = vap->va_size;
- struct vnode *convp = cp->c_ovp;
- if (size != VNOVAL && convp != (struct vnode *)0) {
- vnode_pager_setsize(convp, size);
- }
- }
- CODADEBUG(CODA_SETATTR, myprintf(("setattr %d\n", error)); )
- return(error);
-}
-
-int
-coda_access(v)
- void *v;
-{
-/* true args */
- struct vop_access_args *ap = v;
- struct vnode *vp = ap->a_vp;
- struct cnode *cp = VTOC(vp);
- int mode = ap->a_mode;
- struct ucred *cred = ap->a_cred;
- struct proc *p = ap->a_p;
-/* locals */
- int error;
-
- MARK_ENTRY(CODA_ACCESS_STATS);
-
- /* Check for access of control object. Only read access is
- allowed on it. */
- if (IS_CTL_VP(vp)) {
- /* bogus hack - all will be marked as successes */
- MARK_INT_SAT(CODA_ACCESS_STATS);
- return(((mode & VREAD) && !(mode & (VWRITE | VEXEC)))
- ? 0 : EACCES);
- }
-
- /*
- * if the file is a directory, and we are checking exec (eg lookup)
- * access, and the file is in the namecache, then the user must have
- * lookup access to it.
- */
- if (coda_access_cache) {
- if ((vp->v_type == VDIR) && (mode & VEXEC)) {
- if (coda_nc_lookup(cp, ".", 1, cred)) {
- MARK_INT_SAT(CODA_ACCESS_STATS);
- return(0); /* it was in the cache */
- }
- }
- }
-
- error = venus_access(vtomi(vp), &cp->c_fid, mode, cred, p);
-
- return(error);
-}
-
-int
-coda_readlink(v)
- void *v;
-{
-/* true args */
- struct vop_readlink_args *ap = v;
- struct vnode *vp = ap->a_vp;
- struct cnode *cp = VTOC(vp);
- struct uio *uiop = ap->a_uio;
- struct ucred *cred = ap->a_cred;
- struct proc *p = ap->a_uio->uio_procp;
-/* locals */
- int error;
- char *str;
- int len;
-
- MARK_ENTRY(CODA_READLINK_STATS);
-
- /* Check for readlink of control object. */
- if (IS_CTL_VP(vp)) {
- MARK_INT_FAIL(CODA_READLINK_STATS);
- return(ENOENT);
- }
-
- if ((coda_symlink_cache) && (VALID_SYMLINK(cp))) { /* symlink was cached */
- uiop->uio_rw = UIO_READ;
- error = uiomove(cp->c_symlink, (int)cp->c_symlen, uiop);
- if (error)
- MARK_INT_FAIL(CODA_READLINK_STATS);
- else
- MARK_INT_SAT(CODA_READLINK_STATS);
- return(error);
- }
-
- error = venus_readlink(vtomi(vp), &cp->c_fid, cred, p, &str, &len);
-
- if (!error) {
- uiop->uio_rw = UIO_READ;
- error = uiomove(str, len, uiop);
-
- if (coda_symlink_cache) {
- cp->c_symlink = str;
- cp->c_symlen = len;
- cp->c_flags |= C_SYMLINK;
- } else
- CODA_FREE(str, len);
- }
-
- CODADEBUG(CODA_READLINK, myprintf(("in readlink result %d\n",error));)
- return(error);
-}
-
-int
-coda_fsync(v)
- void *v;
-{
-/* true args */
- struct vop_fsync_args *ap = v;
- struct vnode *vp = ap->a_vp;
- struct cnode *cp = VTOC(vp);
- struct ucred *cred = ap->a_cred;
- struct proc *p = ap->a_p;
-/* locals */
- struct vnode *convp = cp->c_ovp;
- int error;
-
- MARK_ENTRY(CODA_FSYNC_STATS);
-
- /* Check for fsync on an unmounting object */
- /* The NetBSD kernel, in it's infinite wisdom, can try to fsync
- * after an unmount has been initiated. This is a Bad Thing,
- * which we have to avoid. Not a legitimate failure for stats.
- */
- if (IS_UNMOUNTING(cp)) {
- return(ENODEV);
- }
-
- /* Check for fsync of control object. */
- if (IS_CTL_VP(vp)) {
- MARK_INT_SAT(CODA_FSYNC_STATS);
- return(0);
- }
-
- if (convp)
- VOP_FSYNC(convp, cred, MNT_WAIT, p);
-
- /*
- * We see fsyncs with usecount == 1 then usecount == 0.
- * For now we ignore them.
- */
- /*
- if (!vp->v_usecount) {
- printf("coda_fsync on vnode %p with %d usecount. c_flags = %x (%x)\n",
- vp, vp->v_usecount, cp->c_flags, cp->c_flags&C_PURGING);
- }
- */
-
- /*
- * We can expect fsync on any vnode at all if venus is pruging it.
- * Venus can't very well answer the fsync request, now can it?
- * Hopefully, it won't have to, because hopefully, venus preserves
- * the (possibly untrue) invariant that it never purges an open
- * vnode. Hopefully.
- */
- if (cp->c_flags & C_PURGING) {
- return(0);
- }
-
- /* needs research */
- return 0;
- error = venus_fsync(vtomi(vp), &cp->c_fid, cred, p);
-
- CODADEBUG(CODA_FSYNC, myprintf(("in fsync result %d\n",error)); );
- return(error);
-}
-
-int
-coda_inactive(v)
- void *v;
-{
- /* XXX - at the moment, inactive doesn't look at cred, and doesn't
- have a proc pointer. Oops. */
-/* true args */
- struct vop_inactive_args *ap = v;
- struct vnode *vp = ap->a_vp;
- struct cnode *cp = VTOC(vp);
- struct ucred *cred __attribute__((unused)) = NULL;
- struct proc *p __attribute__((unused)) = curproc;
-/* upcall decl */
-/* locals */
-
- /* We don't need to send inactive to venus - DCS */
- MARK_ENTRY(CODA_INACTIVE_STATS);
-
- if (IS_CTL_VP(vp)) {
- MARK_INT_SAT(CODA_INACTIVE_STATS);
- return 0;
- }
-
- CODADEBUG(CODA_INACTIVE, myprintf(("in inactive, %lx.%lx.%lx. vfsp %p\n",
- cp->c_fid.Volume, cp->c_fid.Vnode,
- cp->c_fid.Unique, vp->v_mount));)
-
- /* If an array has been allocated to hold the symlink, deallocate it */
- if ((coda_symlink_cache) && (VALID_SYMLINK(cp))) {
- if (cp->c_symlink == NULL)
- panic("coda_inactive: null symlink pointer in cnode");
-
- CODA_FREE(cp->c_symlink, cp->c_symlen);
- cp->c_flags &= ~C_SYMLINK;
- cp->c_symlen = 0;
- }
-
- /* Remove it from the table so it can't be found. */
- coda_unsave(cp);
- if ((struct coda_mntinfo *)(vp->v_mount->mnt_data) == NULL) {
- myprintf(("Help! vfsp->vfs_data was NULL, but vnode %p wasn't dying\n", vp));
- panic("badness in coda_inactive\n");
- }
-
- if (IS_UNMOUNTING(cp)) {
-#ifdef DEBUG
- printf("coda_inactive: IS_UNMOUNTING use %d: vp %p, cp %p\n", vp->v_usecount, vp, cp);
- if (cp->c_ovp != NULL)
- printf("coda_inactive: cp->ovp != NULL use %d: vp %p, cp %p\n",
- vp->v_usecount, vp, cp);
-#endif
- lockmgr(&cp->c_lock, LK_RELEASE, &vp->v_interlock, p);
- } else {
-#ifdef OLD_DIAGNOSTIC
- if (CTOV(cp)->v_usecount) {
- panic("coda_inactive: nonzero reference count");
- }
- if (cp->c_ovp != NULL) {
- panic("coda_inactive: cp->ovp != NULL");
- }
-#endif
- VOP_UNLOCK(vp, 0, p);
- vgone(vp);
- }
-
- MARK_INT_SAT(CODA_INACTIVE_STATS);
- return(0);
-}
-
-/*
- * Remote file system operations having to do with directory manipulation.
- */
-
-/*
- * It appears that in NetBSD, lookup is supposed to return the vnode locked
- */
-int
-coda_lookup(v)
- void *v;
-{
-/* true args */
- struct vop_lookup_args *ap = v;
- struct vnode *dvp = ap->a_dvp;
- struct cnode *dcp = VTOC(dvp);
- struct vnode **vpp = ap->a_vpp;
- /*
- * It looks as though ap->a_cnp->ni_cnd->cn_nameptr holds the rest
- * of the string to xlate, and that we must try to get at least
- * ap->a_cnp->ni_cnd->cn_namelen of those characters to macth. I
- * could be wrong.
- */
- struct componentname *cnp = ap->a_cnp;
- struct ucred *cred = cnp->cn_cred;
- struct proc *p = cnp->cn_proc;
-/* locals */
- struct cnode *cp;
- const char *nm = cnp->cn_nameptr;
- int len = cnp->cn_namelen;
- ViceFid VFid;
- int vtype;
- int error = 0;
-
- MARK_ENTRY(CODA_LOOKUP_STATS);
-
- CODADEBUG(CODA_LOOKUP, myprintf(("lookup: %s in %lx.%lx.%lx\n",
- nm, dcp->c_fid.Volume,
- dcp->c_fid.Vnode, dcp->c_fid.Unique)););
-
- /* Check for lookup of control object. */
- if (IS_CTL_NAME(dvp, nm, len)) {
- *vpp = coda_ctlvp;
- vref(*vpp);
- MARK_INT_SAT(CODA_LOOKUP_STATS);
- goto exit;
- }
-
- if (len+1 > CODA_MAXNAMLEN) {
- MARK_INT_FAIL(CODA_LOOKUP_STATS);
- CODADEBUG(CODA_LOOKUP, myprintf(("name too long: lookup, %lx.%lx.%lx(%s)\n",
- dcp->c_fid.Volume, dcp->c_fid.Vnode,
- dcp->c_fid.Unique, nm)););
- *vpp = (struct vnode *)0;
- error = EINVAL;
- goto exit;
- }
- /* First try to look the file up in the cfs name cache */
- /* lock the parent vnode? */
- cp = coda_nc_lookup(dcp, nm, len, cred);
- if (cp) {
- *vpp = CTOV(cp);
- vref(*vpp);
- CODADEBUG(CODA_LOOKUP,
- myprintf(("lookup result %d vpp %p\n",error,*vpp));)
- } else {
-
- /* The name wasn't cached, so we need to contact Venus */
- error = venus_lookup(vtomi(dvp), &dcp->c_fid, nm, len, cred, p, &VFid, &vtype);
-
- if (error) {
- MARK_INT_FAIL(CODA_LOOKUP_STATS);
- CODADEBUG(CODA_LOOKUP, myprintf(("lookup error on %lx.%lx.%lx(%s)%d\n",
- dcp->c_fid.Volume, dcp->c_fid.Vnode, dcp->c_fid.Unique, nm, error));)
- *vpp = (struct vnode *)0;
- } else {
- MARK_INT_SAT(CODA_LOOKUP_STATS);
- CODADEBUG(CODA_LOOKUP,
- myprintf(("lookup: vol %lx vno %lx uni %lx type %o result %d\n",
- VFid.Volume, VFid.Vnode, VFid.Unique, vtype,
- error)); )
-
- cp = make_coda_node(&VFid, dvp->v_mount, vtype);
- *vpp = CTOV(cp);
-
- /* enter the new vnode in the Name Cache only if the top bit isn't set */
- /* And don't enter a new vnode for an invalid one! */
- if (!(vtype & CODA_NOCACHE))
- coda_nc_enter(VTOC(dvp), nm, len, cred, VTOC(*vpp));
- }
- }
-
- exit:
- /*
- * If we are creating, and this was the last name to be looked up,
- * and the error was ENOENT, then there really shouldn't be an
- * error and we can make the leaf NULL and return success. Since
- * this is supposed to work under Mach as well as NetBSD, we're
- * leaving this fn wrapped. We also must tell lookup/namei that
- * we need to save the last component of the name. (Create will
- * have to free the name buffer later...lucky us...)
- */
- if (((cnp->cn_nameiop == CREATE) || (cnp->cn_nameiop == RENAME))
- && (cnp->cn_flags & ISLASTCN)
- && (error == ENOENT))
- {
- error = EJUSTRETURN;
- cnp->cn_flags |= SAVENAME;
- *ap->a_vpp = NULL;
- }
-
- /*
- * If we are removing, and we are at the last element, and we
- * found it, then we need to keep the name around so that the
- * removal will go ahead as planned. Unfortunately, this will
- * probably also lock the to-be-removed vnode, which may or may
- * not be a good idea. I'll have to look at the bits of
- * coda_remove to make sure. We'll only save the name if we did in
- * fact find the name, otherwise coda_remove won't have a chance
- * to free the pathname.
- */
- if ((cnp->cn_nameiop == DELETE)
- && (cnp->cn_flags & ISLASTCN)
- && !error)
- {
- cnp->cn_flags |= SAVENAME;
- }
-
- /*
- * If the lookup went well, we need to (potentially?) unlock the
- * parent, and lock the child. We are only responsible for
- * checking to see if the parent is supposed to be unlocked before
- * we return. We must always lock the child (provided there is
- * one, and (the parent isn't locked or it isn't the same as the
- * parent.) Simple, huh? We can never leave the parent locked unless
- * we are ISLASTCN
- */
- if (!error || (error == EJUSTRETURN)) {
- if (!(cnp->cn_flags & LOCKPARENT) || !(cnp->cn_flags & ISLASTCN)) {
- if ((error = VOP_UNLOCK(dvp, 0, p))) {
- return error;
- }
- /*
- * The parent is unlocked. As long as there is a child,
- * lock it without bothering to check anything else.
- */
- if (*ap->a_vpp) {
- if ((error = VOP_LOCK(*ap->a_vpp, LK_EXCLUSIVE, p))) {
- printf("coda_lookup: ");
- panic("unlocked parent but couldn't lock child");
- }
- }
- } else {
- /* The parent is locked, and may be the same as the child */
- if (*ap->a_vpp && (*ap->a_vpp != dvp)) {
- /* Different, go ahead and lock it. */
- if ((error = VOP_LOCK(*ap->a_vpp, LK_EXCLUSIVE, p))) {
- printf("coda_lookup: ");
- panic("unlocked parent but couldn't lock child");
- }
- }
- }
- } else {
- /* If the lookup failed, we need to ensure that the leaf is NULL */
- /* Don't change any locking? */
- *ap->a_vpp = NULL;
- }
- return(error);
-}
-
-/*ARGSUSED*/
-int
-coda_create(v)
- void *v;
-{
-/* true args */
- struct vop_create_args *ap = v;
- struct vnode *dvp = ap->a_dvp;
- struct cnode *dcp = VTOC(dvp);
- struct vattr *va = ap->a_vap;
- int exclusive = 1;
- int mode = ap->a_vap->va_mode;
- struct vnode **vpp = ap->a_vpp;
- struct componentname *cnp = ap->a_cnp;
- struct ucred *cred = cnp->cn_cred;
- struct proc *p = cnp->cn_proc;
-/* locals */
- int error;
- struct cnode *cp;
- const char *nm = cnp->cn_nameptr;
- int len = cnp->cn_namelen;
- ViceFid VFid;
- struct vattr attr;
-
- MARK_ENTRY(CODA_CREATE_STATS);
-
- /* All creates are exclusive XXX */
- /* I'm assuming the 'mode' argument is the file mode bits XXX */
-
- /* Check for create of control object. */
- if (IS_CTL_NAME(dvp, nm, len)) {
- *vpp = (struct vnode *)0;
- MARK_INT_FAIL(CODA_CREATE_STATS);
- return(EACCES);
- }
-
- error = venus_create(vtomi(dvp), &dcp->c_fid, nm, len, exclusive, mode, va, cred, p, &VFid, &attr);
-
- if (!error) {
-
- /* If this is an exclusive create, panic if the file already exists. */
- /* Venus should have detected the file and reported EEXIST. */
-
- if ((exclusive == 1) &&
- (coda_find(&VFid) != NULL))
- panic("cnode existed for newly created file!");
-
- cp = make_coda_node(&VFid, dvp->v_mount, attr.va_type);
- *vpp = CTOV(cp);
-
- /* Update va to reflect the new attributes. */
- (*va) = attr;
-
- /* Update the attribute cache and mark it as valid */
- if (coda_attr_cache) {
- VTOC(*vpp)->c_vattr = attr;
- VTOC(*vpp)->c_flags |= C_VATTR;
- }
-
- /* Invalidate the parent's attr cache, the modification time has changed */
- VTOC(dvp)->c_flags &= ~C_VATTR;
-
- /* enter the new vnode in the Name Cache */
- coda_nc_enter(VTOC(dvp), nm, len, cred, VTOC(*vpp));
-
- CODADEBUG(CODA_CREATE,
- myprintf(("create: (%lx.%lx.%lx), result %d\n",
- VFid.Volume, VFid.Vnode, VFid.Unique, error)); )
- } else {
- *vpp = (struct vnode *)0;
- CODADEBUG(CODA_CREATE, myprintf(("create error %d\n", error));)
- }
-
- if (!error) {
- if (cnp->cn_flags & LOCKLEAF) {
- if ((error = VOP_LOCK(*ap->a_vpp, LK_EXCLUSIVE, p))) {
- printf("coda_create: ");
- panic("unlocked parent but couldn't lock child");
- }
- }
-#ifdef OLD_DIAGNOSTIC
- else {
- printf("coda_create: LOCKLEAF not set!\n");
- }
-#endif
- }
- return(error);
-}
-
-int
-coda_remove(v)
- void *v;
-{
-/* true args */
- struct vop_remove_args *ap = v;
- struct vnode *dvp = ap->a_dvp;
- struct cnode *cp = VTOC(dvp);
- struct componentname *cnp = ap->a_cnp;
- struct ucred *cred = cnp->cn_cred;
- struct proc *p = cnp->cn_proc;
-/* locals */
- int error;
- const char *nm = cnp->cn_nameptr;
- int len = cnp->cn_namelen;
- struct cnode *tp;
-
- MARK_ENTRY(CODA_REMOVE_STATS);
-
- CODADEBUG(CODA_REMOVE, myprintf(("remove: %s in %lx.%lx.%lx\n",
- nm, cp->c_fid.Volume, cp->c_fid.Vnode,
- cp->c_fid.Unique)););
-
- /* Remove the file's entry from the CODA Name Cache */
- /* We're being conservative here, it might be that this person
- * doesn't really have sufficient access to delete the file
- * but we feel zapping the entry won't really hurt anyone -- dcs
- */
- /* I'm gonna go out on a limb here. If a file and a hardlink to it
- * exist, and one is removed, the link count on the other will be
- * off by 1. We could either invalidate the attrs if cached, or
- * fix them. I'll try to fix them. DCS 11/8/94
- */
- tp = coda_nc_lookup(VTOC(dvp), nm, len, cred);
- if (tp) {
- if (VALID_VATTR(tp)) { /* If attrs are cached */
- if (tp->c_vattr.va_nlink > 1) { /* If it's a hard link */
- tp->c_vattr.va_nlink--;
- }
- }
-
- coda_nc_zapfile(VTOC(dvp), nm, len);
- /* No need to flush it if it doesn't exist! */
- }
- /* Invalidate the parent's attr cache, the modification time has changed */
- VTOC(dvp)->c_flags &= ~C_VATTR;
-
- /* Check for remove of control object. */
- if (IS_CTL_NAME(dvp, nm, len)) {
- MARK_INT_FAIL(CODA_REMOVE_STATS);
- return(ENOENT);
- }
-
- error = venus_remove(vtomi(dvp), &cp->c_fid, nm, len, cred, p);
-
- CODADEBUG(CODA_REMOVE, myprintf(("in remove result %d\n",error)); )
-
- return(error);
-}
-
-int
-coda_link(v)
- void *v;
-{
-/* true args */
- struct vop_link_args *ap = v;
- struct vnode *vp = ap->a_vp;
- struct cnode *cp = VTOC(vp);
- struct vnode *tdvp = ap->a_tdvp;
- struct cnode *tdcp = VTOC(tdvp);
- struct componentname *cnp = ap->a_cnp;
- struct ucred *cred = cnp->cn_cred;
- struct proc *p = cnp->cn_proc;
-/* locals */
- int error;
- const char *nm = cnp->cn_nameptr;
- int len = cnp->cn_namelen;
-
- MARK_ENTRY(CODA_LINK_STATS);
-
- if (codadebug & CODADBGMSK(CODA_LINK)) {
-
- myprintf(("nb_link: vp fid: (%lx.%lx.%lx)\n",
- cp->c_fid.Volume, cp->c_fid.Vnode, cp->c_fid.Unique));
- myprintf(("nb_link: tdvp fid: (%lx.%lx.%lx)\n",
- tdcp->c_fid.Volume, tdcp->c_fid.Vnode, tdcp->c_fid.Unique));
-
- }
- if (codadebug & CODADBGMSK(CODA_LINK)) {
- myprintf(("link: vp fid: (%lx.%lx.%lx)\n",
- cp->c_fid.Volume, cp->c_fid.Vnode, cp->c_fid.Unique));
- myprintf(("link: tdvp fid: (%lx.%lx.%lx)\n",
- tdcp->c_fid.Volume, tdcp->c_fid.Vnode, tdcp->c_fid.Unique));
-
- }
-
- /* Check for link to/from control object. */
- if (IS_CTL_NAME(tdvp, nm, len) || IS_CTL_VP(vp)) {
- MARK_INT_FAIL(CODA_LINK_STATS);
- return(EACCES);
- }
-
- error = venus_link(vtomi(vp), &cp->c_fid, &tdcp->c_fid, nm, len, cred, p);
-
- /* Invalidate the parent's attr cache, the modification time has changed */
- VTOC(tdvp)->c_flags &= ~C_VATTR;
- VTOC(vp)->c_flags &= ~C_VATTR;
-
- CODADEBUG(CODA_LINK, myprintf(("in link result %d\n",error)); )
-
- return(error);
-}
-
-int
-coda_rename(v)
- void *v;
-{
-/* true args */
- struct vop_rename_args *ap = v;
- struct vnode *odvp = ap->a_fdvp;
- struct cnode *odcp = VTOC(odvp);
- struct componentname *fcnp = ap->a_fcnp;
- struct vnode *ndvp = ap->a_tdvp;
- struct cnode *ndcp = VTOC(ndvp);
- struct componentname *tcnp = ap->a_tcnp;
- struct ucred *cred = fcnp->cn_cred;
- struct proc *p = fcnp->cn_proc;
-/* true args */
- int error;
- const char *fnm = fcnp->cn_nameptr;
- int flen = fcnp->cn_namelen;
- const char *tnm = tcnp->cn_nameptr;
- int tlen = tcnp->cn_namelen;
-
- MARK_ENTRY(CODA_RENAME_STATS);
-
- /* Hmmm. The vnodes are already looked up. Perhaps they are locked?
- This could be Bad. XXX */
-#ifdef OLD_DIAGNOSTIC
- if ((fcnp->cn_cred != tcnp->cn_cred)
- || (fcnp->cn_proc != tcnp->cn_proc))
- {
- panic("coda_rename: component names don't agree");
- }
-#endif
-
- /* Check for rename involving control object. */
- if (IS_CTL_NAME(odvp, fnm, flen) || IS_CTL_NAME(ndvp, tnm, tlen)) {
- MARK_INT_FAIL(CODA_RENAME_STATS);
- return(EACCES);
- }
-
- /* Problem with moving directories -- need to flush entry for .. */
- if (odvp != ndvp) {
- struct cnode *ovcp = coda_nc_lookup(VTOC(odvp), fnm, flen, cred);
- if (ovcp) {
- struct vnode *ovp = CTOV(ovcp);
- if ((ovp) &&
- (ovp->v_type == VDIR)) /* If it's a directory */
- coda_nc_zapfile(VTOC(ovp),"..", 2);
- }
- }
-
- /* Remove the entries for both source and target files */
- coda_nc_zapfile(VTOC(odvp), fnm, flen);
- coda_nc_zapfile(VTOC(ndvp), tnm, tlen);
-
- /* Invalidate the parent's attr cache, the modification time has changed */
- VTOC(odvp)->c_flags &= ~C_VATTR;
- VTOC(ndvp)->c_flags &= ~C_VATTR;
-
- if (flen+1 > CODA_MAXNAMLEN) {
- MARK_INT_FAIL(CODA_RENAME_STATS);
- error = EINVAL;
- goto exit;
- }
-
- if (tlen+1 > CODA_MAXNAMLEN) {
- MARK_INT_FAIL(CODA_RENAME_STATS);
- error = EINVAL;
- goto exit;
- }
-
- error = venus_rename(vtomi(odvp), &odcp->c_fid, &ndcp->c_fid, fnm, flen, tnm, tlen, cred, p);
-
- exit:
- CODADEBUG(CODA_RENAME, myprintf(("in rename result %d\n",error));)
- /* XXX - do we need to call cache pureg on the moved vnode? */
- cache_purge(ap->a_fvp);
-
- /* It seems to be incumbent on us to drop locks on all four vnodes */
- /* From-vnodes are not locked, only ref'd. To-vnodes are locked. */
-
- vrele(ap->a_fvp);
- vrele(odvp);
-
- if (ap->a_tvp) {
- if (ap->a_tvp == ndvp) {
- vrele(ap->a_tvp);
- } else {
- vput(ap->a_tvp);
- }
- }
-
- vput(ndvp);
- return(error);
-}
-
-int
-coda_mkdir(v)
- void *v;
-{
-/* true args */
- struct vop_mkdir_args *ap = v;
- struct vnode *dvp = ap->a_dvp;
- struct cnode *dcp = VTOC(dvp);
- struct componentname *cnp = ap->a_cnp;
- register struct vattr *va = ap->a_vap;
- struct vnode **vpp = ap->a_vpp;
- struct ucred *cred = cnp->cn_cred;
- struct proc *p = cnp->cn_proc;
-/* locals */
- int error;
- const char *nm = cnp->cn_nameptr;
- int len = cnp->cn_namelen;
- struct cnode *cp;
- ViceFid VFid;
- struct vattr ova;
-
- MARK_ENTRY(CODA_MKDIR_STATS);
-
- /* Check for mkdir of target object. */
- if (IS_CTL_NAME(dvp, nm, len)) {
- *vpp = (struct vnode *)0;
- MARK_INT_FAIL(CODA_MKDIR_STATS);
- return(EACCES);
- }
-
- if (len+1 > CODA_MAXNAMLEN) {
- *vpp = (struct vnode *)0;
- MARK_INT_FAIL(CODA_MKDIR_STATS);
- return(EACCES);
- }
-
- error = venus_mkdir(vtomi(dvp), &dcp->c_fid, nm, len, va, cred, p, &VFid, &ova);
-
- if (!error) {
- if (coda_find(&VFid) != NULL)
- panic("cnode existed for newly created directory!");
-
-
- cp = make_coda_node(&VFid, dvp->v_mount, va->va_type);
- *vpp = CTOV(cp);
-
- /* enter the new vnode in the Name Cache */
- coda_nc_enter(VTOC(dvp), nm, len, cred, VTOC(*vpp));
-
- /* as a side effect, enter "." and ".." for the directory */
- coda_nc_enter(VTOC(*vpp), ".", 1, cred, VTOC(*vpp));
- coda_nc_enter(VTOC(*vpp), "..", 2, cred, VTOC(dvp));
-
- if (coda_attr_cache) {
- VTOC(*vpp)->c_vattr = ova; /* update the attr cache */
- VTOC(*vpp)->c_flags |= C_VATTR; /* Valid attributes in cnode */
- }
-
- /* Invalidate the parent's attr cache, the modification time has changed */
- VTOC(dvp)->c_flags &= ~C_VATTR;
-
- CODADEBUG( CODA_MKDIR, myprintf(("mkdir: (%lx.%lx.%lx) result %d\n",
- VFid.Volume, VFid.Vnode, VFid.Unique, error)); )
- } else {
- *vpp = (struct vnode *)0;
- CODADEBUG(CODA_MKDIR, myprintf(("mkdir error %d\n",error));)
- }
-
- return(error);
-}
-
-int
-coda_rmdir(v)
- void *v;
-{
-/* true args */
- struct vop_rmdir_args *ap = v;
- struct vnode *dvp = ap->a_dvp;
- struct cnode *dcp = VTOC(dvp);
- struct componentname *cnp = ap->a_cnp;
- struct ucred *cred = cnp->cn_cred;
- struct proc *p = cnp->cn_proc;
-/* true args */
- int error;
- const char *nm = cnp->cn_nameptr;
- int len = cnp->cn_namelen;
- struct cnode *cp;
-
- MARK_ENTRY(CODA_RMDIR_STATS);
-
- /* Check for rmdir of control object. */
- if (IS_CTL_NAME(dvp, nm, len)) {
- MARK_INT_FAIL(CODA_RMDIR_STATS);
- return(ENOENT);
- }
-
- /* We're being conservative here, it might be that this person
- * doesn't really have sufficient access to delete the file
- * but we feel zapping the entry won't really hurt anyone -- dcs
- */
- /*
- * As a side effect of the rmdir, remove any entries for children of
- * the directory, especially "." and "..".
- */
- cp = coda_nc_lookup(dcp, nm, len, cred);
- if (cp) coda_nc_zapParentfid(&(cp->c_fid), NOT_DOWNCALL);
-
- /* Remove the file's entry from the CODA Name Cache */
- coda_nc_zapfile(dcp, nm, len);
-
- /* Invalidate the parent's attr cache, the modification time has changed */
- dcp->c_flags &= ~C_VATTR;
-
- error = venus_rmdir(vtomi(dvp), &dcp->c_fid, nm, len, cred, p);
-
- CODADEBUG(CODA_RMDIR, myprintf(("in rmdir result %d\n", error)); )
-
- return(error);
-}
-
-int
-coda_symlink(v)
- void *v;
-{
-/* true args */
- struct vop_symlink_args *ap = v;
- struct vnode *tdvp = ap->a_dvp;
- struct cnode *tdcp = VTOC(tdvp);
- struct componentname *cnp = ap->a_cnp;
- struct vattr *tva = ap->a_vap;
- char *path = ap->a_target;
- struct ucred *cred = cnp->cn_cred;
- struct proc *p = cnp->cn_proc;
- struct vnode **vpp = ap->a_vpp;
-/* locals */
- int error;
- /*
- * XXX I'm assuming the following things about coda_symlink's
- * arguments:
- * t(foo) is the new name/parent/etc being created.
- * lname is the contents of the new symlink.
- */
- char *nm = cnp->cn_nameptr;
- int len = cnp->cn_namelen;
- int plen = strlen(path);
-
- /*
- * Here's the strategy for the moment: perform the symlink, then
- * do a lookup to grab the resulting vnode. I know this requires
- * two communications with Venus for a new sybolic link, but
- * that's the way the ball bounces. I don't yet want to change
- * the way the Mach symlink works. When Mach support is
- * deprecated, we should change symlink so that the common case
- * returns the resultant vnode in a vpp argument.
- */
-
- MARK_ENTRY(CODA_SYMLINK_STATS);
-
- /* Check for symlink of control object. */
- if (IS_CTL_NAME(tdvp, nm, len)) {
- MARK_INT_FAIL(CODA_SYMLINK_STATS);
- return(EACCES);
- }
-
- if (plen+1 > CODA_MAXPATHLEN) {
- MARK_INT_FAIL(CODA_SYMLINK_STATS);
- return(EINVAL);
- }
-
- if (len+1 > CODA_MAXNAMLEN) {
- MARK_INT_FAIL(CODA_SYMLINK_STATS);
- error = EINVAL;
- goto exit;
- }
-
- error = venus_symlink(vtomi(tdvp), &tdcp->c_fid, path, plen, nm, len, tva, cred, p);
-
- /* Invalidate the parent's attr cache, the modification time has changed */
- tdcp->c_flags &= ~C_VATTR;
-
- if (error == 0)
- error = VOP_LOOKUP(tdvp, vpp, cnp);
-
- exit:
- CODADEBUG(CODA_SYMLINK, myprintf(("in symlink result %d\n",error)); )
- return(error);
-}
-
-/*
- * Read directory entries.
- */
-int
-coda_readdir(v)
- void *v;
-{
-/* true args */
- struct vop_readdir_args *ap = v;
- struct vnode *vp = ap->a_vp;
- struct cnode *cp = VTOC(vp);
- register struct uio *uiop = ap->a_uio;
- struct ucred *cred = ap->a_cred;
- int *eofflag = ap->a_eofflag;
- u_long **cookies = ap->a_cookies;
- int *ncookies = ap->a_ncookies;
- struct proc *p = ap->a_uio->uio_procp;
-/* upcall decl */
-/* locals */
- int error = 0;
-
- MARK_ENTRY(CODA_READDIR_STATS);
-
- CODADEBUG(CODA_READDIR, myprintf(("coda_readdir(%p, %d, %lld, %d)\n",
- (void *)uiop->uio_iov->iov_base,
- uiop->uio_resid,
- (long long)uiop->uio_offset,
- uiop->uio_segflg)); )
-
- /* Check for readdir of control object. */
- if (IS_CTL_VP(vp)) {
- MARK_INT_FAIL(CODA_READDIR_STATS);
- return(ENOENT);
- }
-
- {
- /* If directory is not already open do an "internal open" on it. */
- int opened_internally = 0;
- if (cp->c_ovp == NULL) {
- opened_internally = 1;
- MARK_INT_GEN(CODA_OPEN_STATS);
- error = VOP_OPEN(vp, FREAD, cred, p);
-printf("coda_readdir: Internally Opening %p\n", vp);
- if (error) {
- printf("coda_readdir: VOP_OPEN on container failed %d\n", error);
- return (error);
- }
- if (vp->v_type == VREG) {
- error = vfs_object_create(vp, p, cred);
- if (error != 0) {
- printf("coda_readdir: vfs_object_create() returns %d\n", error);
- vput(vp);
- }
- }
- if (error) return(error);
- }
-
- /* Have UFS handle the call. */
- CODADEBUG(CODA_READDIR, myprintf(("indirect readdir: fid = (%lx.%lx.%lx), refcnt = %d\n",cp->c_fid.Volume, cp->c_fid.Vnode, cp->c_fid.Unique, vp->v_usecount)); )
- error = VOP_READDIR(cp->c_ovp, uiop, cred, eofflag, ncookies,
- cookies);
-
- if (error)
- MARK_INT_FAIL(CODA_READDIR_STATS);
- else
- MARK_INT_SAT(CODA_READDIR_STATS);
-
- /* Do an "internal close" if necessary. */
- if (opened_internally) {
- MARK_INT_GEN(CODA_CLOSE_STATS);
- (void)VOP_CLOSE(vp, FREAD, cred, p);
- }
- }
-
- return(error);
-}
-
-/*
- * Convert from file system blocks to device blocks
- */
-int
-coda_bmap(v)
- void *v;
-{
- /* XXX on the global proc */
-/* true args */
- struct vop_bmap_args *ap = v;
- struct vnode *vp __attribute__((unused)) = ap->a_vp; /* file's vnode */
- daddr_t bn __attribute__((unused)) = ap->a_bn; /* fs block number */
- struct vnode **vpp = ap->a_vpp; /* RETURN vp of device */
- daddr_t *bnp __attribute__((unused)) = ap->a_bnp; /* RETURN device block number */
- struct proc *p __attribute__((unused)) = curproc;
-/* upcall decl */
-/* locals */
-
- int ret = 0;
- struct cnode *cp;
-
- cp = VTOC(vp);
- if (cp->c_ovp) {
- return EINVAL;
- ret = VOP_BMAP(cp->c_ovp, bn, vpp, bnp, ap->a_runp, ap->a_runb);
-#if 0
- printf("VOP_BMAP(cp->c_ovp %p, bn %p, vpp %p, bnp %p, ap->a_runp %p, ap->a_runb %p) = %d\n",
- cp->c_ovp, bn, vpp, bnp, ap->a_runp, ap->a_runb, ret);
-#endif
- return ret;
- } else {
-#if 0
- printf("coda_bmap: no container\n");
-#endif
- return(EOPNOTSUPP);
- }
-}
-
-/*
- * I don't think the following two things are used anywhere, so I've
- * commented them out
- *
- * struct buf *async_bufhead;
- * int async_daemon_count;
- */
-int
-coda_strategy(v)
- void *v;
-{
-/* true args */
- struct vop_strategy_args *ap = v;
- register struct buf *bp __attribute__((unused)) = ap->a_bp;
- struct proc *p __attribute__((unused)) = curproc;
-/* upcall decl */
-/* locals */
-
- printf("coda_strategy: called ???\n");
- return(EOPNOTSUPP);
-}
-
-int
-coda_reclaim(v)
- void *v;
-{
-/* true args */
- struct vop_reclaim_args *ap = v;
- struct vnode *vp = ap->a_vp;
- struct cnode *cp = VTOC(vp);
-/* upcall decl */
-/* locals */
-
-/*
- * Forced unmount/flush will let vnodes with non zero use be destroyed!
- */
- ENTRY;
-
- if (IS_UNMOUNTING(cp)) {
-#ifdef DEBUG
- if (VTOC(vp)->c_ovp) {
- if (IS_UNMOUNTING(cp))
- printf("coda_reclaim: c_ovp not void: vp %p, cp %p\n", vp, cp);
- }
-#endif
- } else {
-#ifdef OLD_DIAGNOSTIC
- if (vp->v_usecount != 0)
- print("coda_reclaim: pushing active %p\n", vp);
- if (VTOC(vp)->c_ovp) {
- panic("coda_reclaim: c_ovp not void");
- }
-#endif
- }
- cache_purge(vp);
- coda_free(VTOC(vp));
- VTOC(vp) = NULL;
- return (0);
-}
-
-int
-coda_lock(v)
- void *v;
-{
-/* true args */
- struct vop_lock_args *ap = v;
- struct vnode *vp = ap->a_vp;
- struct cnode *cp = VTOC(vp);
- struct proc *p = ap->a_p;
-/* upcall decl */
-/* locals */
-
- ENTRY;
-
- if (coda_lockdebug) {
- myprintf(("Attempting lock on %lx.%lx.%lx\n",
- cp->c_fid.Volume, cp->c_fid.Vnode, cp->c_fid.Unique));
- }
-
-#ifndef DEBUG_LOCKS
- return (lockmgr(&cp->c_lock, ap->a_flags, &vp->v_interlock, p));
-#else
- return (debuglockmgr(&cp->c_lock, ap->a_flags, &vp->v_interlock, p,
- "coda_lock", vp->filename, vp->line));
-#endif
-}
-
-int
-coda_unlock(v)
- void *v;
-{
-/* true args */
- struct vop_unlock_args *ap = v;
- struct vnode *vp = ap->a_vp;
- struct cnode *cp = VTOC(vp);
- struct proc *p = ap->a_p;
-/* upcall decl */
-/* locals */
-
- ENTRY;
- if (coda_lockdebug) {
- myprintf(("Attempting unlock on %lx.%lx.%lx\n",
- cp->c_fid.Volume, cp->c_fid.Vnode, cp->c_fid.Unique));
- }
-
- return (lockmgr(&cp->c_lock, ap->a_flags | LK_RELEASE, &vp->v_interlock, p));
-}
-
-int
-coda_islocked(v)
- void *v;
-{
-/* true args */
- struct vop_islocked_args *ap = v;
- struct cnode *cp = VTOC(ap->a_vp);
- ENTRY;
-
- return (lockstatus(&cp->c_lock, ap->a_p));
-}
-
-/* How one looks up a vnode given a device/inode pair: */
-int
-coda_grab_vnode(dev_t dev, ino_t ino, struct vnode **vpp)
-{
- /* This is like VFS_VGET() or igetinode()! */
- int error;
- struct mount *mp;
-
- if (!(mp = devtomp(dev))) {
- myprintf(("coda_grab_vnode: devtomp(%#lx) returns NULL\n",
- (u_long)dev2udev(dev)));
- return(ENXIO);
- }
-
- /* XXX - ensure that nonzero-return means failure */
- error = VFS_VGET(mp,ino,vpp);
- if (error) {
- myprintf(("coda_grab_vnode: iget/vget(%lx, %lu) returns %p, err %d\n",
- (u_long)dev2udev(dev), (u_long)ino, (void *)*vpp, error));
- return(ENOENT);
- }
- return(0);
-}
-
-void
-print_vattr( attr )
- struct vattr *attr;
-{
- char *typestr;
-
- switch (attr->va_type) {
- case VNON:
- typestr = "VNON";
- break;
- case VREG:
- typestr = "VREG";
- break;
- case VDIR:
- typestr = "VDIR";
- break;
- case VBLK:
- typestr = "VBLK";
- break;
- case VCHR:
- typestr = "VCHR";
- break;
- case VLNK:
- typestr = "VLNK";
- break;
- case VSOCK:
- typestr = "VSCK";
- break;
- case VFIFO:
- typestr = "VFFO";
- break;
- case VBAD:
- typestr = "VBAD";
- break;
- default:
- typestr = "????";
- break;
- }
-
-
- myprintf(("attr: type %s mode %d uid %d gid %d fsid %d rdev %d\n",
- typestr, (int)attr->va_mode, (int)attr->va_uid,
- (int)attr->va_gid, (int)attr->va_fsid, (int)attr->va_rdev));
-
- myprintf((" fileid %d nlink %d size %d blocksize %d bytes %d\n",
- (int)attr->va_fileid, (int)attr->va_nlink,
- (int)attr->va_size,
- (int)attr->va_blocksize,(int)attr->va_bytes));
- myprintf((" gen %ld flags %ld vaflags %d\n",
- attr->va_gen, attr->va_flags, attr->va_vaflags));
- myprintf((" atime sec %d nsec %d\n",
- (int)attr->va_atime.tv_sec, (int)attr->va_atime.tv_nsec));
- myprintf((" mtime sec %d nsec %d\n",
- (int)attr->va_mtime.tv_sec, (int)attr->va_mtime.tv_nsec));
- myprintf((" ctime sec %d nsec %d\n",
- (int)attr->va_ctime.tv_sec, (int)attr->va_ctime.tv_nsec));
-}
-
-/* How to print a ucred */
-void
-print_cred(cred)
- struct ucred *cred;
-{
-
- int i;
-
- myprintf(("ref %d\tuid %d\n",cred->cr_ref,cred->cr_uid));
-
- for (i=0; i < cred->cr_ngroups; i++)
- myprintf(("\tgroup %d: (%d)\n",i,cred->cr_groups[i]));
- myprintf(("\n"));
-
-}
-
-/*
- * Return a vnode for the given fid.
- * If no cnode exists for this fid create one and put it
- * in a table hashed by fid.Volume and fid.Vnode. If the cnode for
- * this fid is already in the table return it (ref count is
- * incremented by coda_find. The cnode will be flushed from the
- * table when coda_inactive calls coda_unsave.
- */
-struct cnode *
-make_coda_node(fid, vfsp, type)
- ViceFid *fid; struct mount *vfsp; short type;
-{
- struct cnode *cp;
- int err;
-
- if ((cp = coda_find(fid)) == NULL) {
- struct vnode *vp;
-
- cp = coda_alloc();
- lockinit(&cp->c_lock, PINOD, "cnode", 0, 0);
- cp->c_fid = *fid;
-
- err = getnewvnode(VT_CODA, vfsp, coda_vnodeop_p, &vp);
- if (err) {
- panic("coda: getnewvnode returned error %d\n", err);
- }
- vp->v_data = cp;
- vp->v_type = type;
- cp->c_vnode = vp;
- coda_save(cp);
-
- } else {
- vref(CTOV(cp));
- }
-
- return cp;
-}
diff --git a/sys/fs/coda/coda_vnops.h b/sys/fs/coda/coda_vnops.h
deleted file mode 100644
index 0fb598582d75..000000000000
--- a/sys/fs/coda/coda_vnops.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- *
- * Coda: an Experimental Distributed File System
- * Release 3.1
- *
- * Copyright (c) 1987-1998 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, and
- * that credit is given to Carnegie Mellon University in all documents
- * and publicity pertaining to direct or indirect use of this code or its
- * derivatives.
- *
- * CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS KNOWN TO HAVE BUGS,
- * SOME OF WHICH MAY HAVE SERIOUS CONSEQUENCES. 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 DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE OR OF
- * ANY DERIVATIVE WORK.
- *
- * Carnegie Mellon encourages users of this software to return any
- * improvements or extensions that they make, and to grant Carnegie
- * Mellon the rights to redistribute these changes without encumbrance.
- *
- * @(#) src/sys/coda/coda_vnops.h,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $
- * $FreeBSD$
- *
- */
-
-/*
- * Mach Operating System
- * Copyright (c) 1990 Carnegie-Mellon University
- * Copyright (c) 1989 Carnegie-Mellon University
- * All rights reserved. The CMU software License Agreement specifies
- * the terms and conditions for use and redistribution.
- */
-
-/*
- * This code was written for the Coda file system at Carnegie Mellon
- * University. Contributers include David Steere, James Kistler, and
- * M. Satyanarayanan.
- */
-
-
-/* NetBSD interfaces to the vnodeops */
-int coda_open __P((void *));
-int coda_close __P((void *));
-int coda_read __P((void *));
-int coda_write __P((void *));
-int coda_ioctl __P((void *));
-/* 1.3 int cfs_select __P((void *));*/
-int coda_getattr __P((void *));
-int coda_setattr __P((void *));
-int coda_access __P((void *));
-int coda_abortop __P((void *));
-int coda_readlink __P((void *));
-int coda_fsync __P((void *));
-int coda_inactive __P((void *));
-int coda_lookup __P((void *));
-int coda_create __P((void *));
-int coda_remove __P((void *));
-int coda_link __P((void *));
-int coda_rename __P((void *));
-int coda_mkdir __P((void *));
-int coda_rmdir __P((void *));
-int coda_symlink __P((void *));
-int coda_readdir __P((void *));
-int coda_bmap __P((void *));
-int coda_strategy __P((void *));
-int coda_reclaim __P((void *));
-int coda_lock __P((void *));
-int coda_unlock __P((void *));
-int coda_islocked __P((void *));
-int coda_vop_error __P((void *));
-int coda_vop_nop __P((void *));
-int coda_fbsd_getpages __P((void *));
-int coda_fbsd_putpages __P((void *));
-
-int (**coda_vnodeop_p)(void *);
-
-int coda_rdwr(struct vnode *vp, struct uio *uiop, enum uio_rw rw,
- int ioflag, struct ucred *cred, struct proc *p);
-int coda_grab_vnode(dev_t dev, ino_t ino, struct vnode **vpp);
-void print_vattr(struct vattr *attr);
-void print_cred(struct ucred *cred);
diff --git a/sys/fs/deadfs/dead_vnops.c b/sys/fs/deadfs/dead_vnops.c
deleted file mode 100644
index f9acbd043587..000000000000
--- a/sys/fs/deadfs/dead_vnops.c
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
- * Copyright (c) 1989, 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)dead_vnops.c 8.1 (Berkeley) 6/10/93
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/lock.h>
-#include <sys/vnode.h>
-#include <sys/buf.h>
-#include <sys/poll.h>
-
-static int chkvnlock __P((struct vnode *));
-/*
- * Prototypes for dead operations on vnodes.
- */
-static int dead_badop __P((void));
-static int dead_bmap __P((struct vop_bmap_args *));
-static int dead_ioctl __P((struct vop_ioctl_args *));
-static int dead_lock __P((struct vop_lock_args *));
-static int dead_lookup __P((struct vop_lookup_args *));
-static int dead_open __P((struct vop_open_args *));
-static int dead_poll __P((struct vop_poll_args *));
-static int dead_print __P((struct vop_print_args *));
-static int dead_read __P((struct vop_read_args *));
-static int dead_write __P((struct vop_write_args *));
-
-vop_t **dead_vnodeop_p;
-static struct vnodeopv_entry_desc dead_vnodeop_entries[] = {
- { &vop_default_desc, (vop_t *) vop_defaultop },
- { &vop_access_desc, (vop_t *) vop_ebadf },
- { &vop_advlock_desc, (vop_t *) vop_ebadf },
- { &vop_bmap_desc, (vop_t *) dead_bmap },
- { &vop_create_desc, (vop_t *) dead_badop },
- { &vop_getattr_desc, (vop_t *) vop_ebadf },
- { &vop_inactive_desc, (vop_t *) vop_null },
- { &vop_ioctl_desc, (vop_t *) dead_ioctl },
- { &vop_link_desc, (vop_t *) dead_badop },
- { &vop_lock_desc, (vop_t *) dead_lock },
- { &vop_lookup_desc, (vop_t *) dead_lookup },
- { &vop_mkdir_desc, (vop_t *) dead_badop },
- { &vop_mknod_desc, (vop_t *) dead_badop },
- { &vop_mmap_desc, (vop_t *) dead_badop },
- { &vop_open_desc, (vop_t *) dead_open },
- { &vop_pathconf_desc, (vop_t *) vop_ebadf }, /* per pathconf(2) */
- { &vop_poll_desc, (vop_t *) dead_poll },
- { &vop_print_desc, (vop_t *) dead_print },
- { &vop_read_desc, (vop_t *) dead_read },
- { &vop_readdir_desc, (vop_t *) vop_ebadf },
- { &vop_readlink_desc, (vop_t *) vop_ebadf },
- { &vop_reclaim_desc, (vop_t *) vop_null },
- { &vop_remove_desc, (vop_t *) dead_badop },
- { &vop_rename_desc, (vop_t *) dead_badop },
- { &vop_rmdir_desc, (vop_t *) dead_badop },
- { &vop_setattr_desc, (vop_t *) vop_ebadf },
- { &vop_symlink_desc, (vop_t *) dead_badop },
- { &vop_write_desc, (vop_t *) dead_write },
- { NULL, NULL }
-};
-static struct vnodeopv_desc dead_vnodeop_opv_desc =
- { &dead_vnodeop_p, dead_vnodeop_entries };
-
-VNODEOP_SET(dead_vnodeop_opv_desc);
-
-/*
- * Trivial lookup routine that always fails.
- */
-/* ARGSUSED */
-static int
-dead_lookup(ap)
- struct vop_lookup_args /* {
- struct vnode * a_dvp;
- struct vnode ** a_vpp;
- struct componentname * a_cnp;
- } */ *ap;
-{
-
- *ap->a_vpp = NULL;
- return (ENOTDIR);
-}
-
-/*
- * Open always fails as if device did not exist.
- */
-/* ARGSUSED */
-static int
-dead_open(ap)
- struct vop_open_args /* {
- struct vnode *a_vp;
- int a_mode;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
-
- return (ENXIO);
-}
-
-/*
- * Vnode op for read
- */
-/* ARGSUSED */
-static int
-dead_read(ap)
- struct vop_read_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- int a_ioflag;
- struct ucred *a_cred;
- } */ *ap;
-{
-
- if (chkvnlock(ap->a_vp))
- panic("dead_read: lock");
- /*
- * Return EOF for tty devices, EIO for others
- */
- if ((ap->a_vp->v_flag & VISTTY) == 0)
- return (EIO);
- return (0);
-}
-
-/*
- * Vnode op for write
- */
-/* ARGSUSED */
-static int
-dead_write(ap)
- struct vop_write_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- int a_ioflag;
- struct ucred *a_cred;
- } */ *ap;
-{
-
- if (chkvnlock(ap->a_vp))
- panic("dead_write: lock");
- return (EIO);
-}
-
-/*
- * Device ioctl operation.
- */
-/* ARGSUSED */
-static int
-dead_ioctl(ap)
- struct vop_ioctl_args /* {
- struct vnode *a_vp;
- int a_command;
- caddr_t a_data;
- int a_fflag;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
-
- if (!chkvnlock(ap->a_vp))
- return (ENOTTY);
- return (VCALL(ap->a_vp, VOFFSET(vop_ioctl), ap));
-}
-
-
-/*
- * Wait until the vnode has finished changing state.
- */
-static int
-dead_lock(ap)
- struct vop_lock_args /* {
- struct vnode *a_vp;
- int a_flags;
- struct proc *a_p;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
-
- /*
- * Since we are not using the lock manager, we must clear
- * the interlock here.
- */
- if (ap->a_flags & LK_INTERLOCK) {
- simple_unlock(&vp->v_interlock);
- ap->a_flags &= ~LK_INTERLOCK;
- }
- if (!chkvnlock(vp))
- return (0);
- return (VCALL(vp, VOFFSET(vop_lock), ap));
-}
-
-/*
- * Wait until the vnode has finished changing state.
- */
-static int
-dead_bmap(ap)
- struct vop_bmap_args /* {
- struct vnode *a_vp;
- daddr_t a_bn;
- struct vnode **a_vpp;
- daddr_t *a_bnp;
- int *a_runp;
- int *a_runb;
- } */ *ap;
-{
-
- if (!chkvnlock(ap->a_vp))
- return (EIO);
- return (VOP_BMAP(ap->a_vp, ap->a_bn, ap->a_vpp, ap->a_bnp, ap->a_runp, ap->a_runb));
-}
-
-/*
- * Print out the contents of a dead vnode.
- */
-/* ARGSUSED */
-static int
-dead_print(ap)
- struct vop_print_args /* {
- struct vnode *a_vp;
- } */ *ap;
-{
-
- printf("tag VT_NON, dead vnode\n");
- return (0);
-}
-
-/*
- * Empty vnode bad operation
- */
-static int
-dead_badop()
-{
-
- panic("dead_badop called");
- /* NOTREACHED */
-}
-
-/*
- * We have to wait during times when the vnode is
- * in a state of change.
- */
-int
-chkvnlock(vp)
- register struct vnode *vp;
-{
- int locked = 0;
-
- while (vp->v_flag & VXLOCK) {
- vp->v_flag |= VXWANT;
- (void) tsleep((caddr_t)vp, PINOD, "ckvnlk", 0);
- locked = 1;
- }
- return (locked);
-}
-
-/*
- * Trivial poll routine that always returns POLLHUP.
- * This is necessary so that a process which is polling a file
- * gets notified when that file is revoke()d.
- */
-static int
-dead_poll(ap)
- struct vop_poll_args *ap;
-{
- return (POLLHUP);
-}
diff --git a/sys/fs/fdescfs/fdesc.h b/sys/fs/fdescfs/fdesc.h
deleted file mode 100644
index 755149d2a46c..000000000000
--- a/sys/fs/fdescfs/fdesc.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)fdesc.h 8.5 (Berkeley) 1/21/94
- *
- * $FreeBSD$
- */
-
-#ifdef _KERNEL
-struct fdescmount {
- struct vnode *f_root; /* Root node */
-};
-
-#define FD_ROOT 2
-#define FD_DEVFD 3
-#define FD_STDIN 4
-#define FD_STDOUT 5
-#define FD_STDERR 6
-#define FD_CTTY 7
-#define FD_DESC 8
-#define FD_MAX 12
-
-typedef enum {
- Froot,
- Fdevfd,
- Fdesc,
- Flink,
- Fctty
-} fdntype;
-
-struct fdescnode {
- LIST_ENTRY(fdescnode) fd_hash; /* Hash list */
- struct vnode *fd_vnode; /* Back ptr to vnode */
- fdntype fd_type; /* Type of this node */
- unsigned fd_fd; /* Fd to be dup'ed */
- char *fd_link; /* Link to fd/n */
- int fd_ix; /* filesystem index */
-};
-
-#define VFSTOFDESC(mp) ((struct fdescmount *)((mp)->mnt_data))
-#define VTOFDESC(vp) ((struct fdescnode *)(vp)->v_data)
-
-extern dev_t devctty;
-extern int fdesc_init __P((struct vfsconf *));
-extern int fdesc_root __P((struct mount *, struct vnode **));
-extern int fdesc_allocvp __P((fdntype, int, struct mount *, struct vnode **));
-#endif /* _KERNEL */
diff --git a/sys/fs/fdescfs/fdesc_vfsops.c b/sys/fs/fdescfs/fdesc_vfsops.c
deleted file mode 100644
index 0105ff7f8c75..000000000000
--- a/sys/fs/fdescfs/fdesc_vfsops.c
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- * Copyright (c) 1992, 1993, 1995
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)fdesc_vfsops.c 8.4 (Berkeley) 1/21/94
- *
- * $FreeBSD$
- */
-
-/*
- * /dev/fd Filesystem
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/proc.h>
-#include <sys/resourcevar.h>
-#include <sys/filedesc.h>
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <sys/malloc.h>
-#include <miscfs/fdesc/fdesc.h>
-
-static MALLOC_DEFINE(M_FDESCMNT, "FDESC mount", "FDESC mount structure");
-
-static int fdesc_mount __P((struct mount *mp, char *path, caddr_t data,
- struct nameidata *ndp, struct proc *p));
-static int fdesc_unmount __P((struct mount *mp, int mntflags,
- struct proc *p));
-static int fdesc_statfs __P((struct mount *mp, struct statfs *sbp,
- struct proc *p));
-
-/*
- * Mount the per-process file descriptors (/dev/fd)
- */
-static int
-fdesc_mount(mp, path, data, ndp, p)
- struct mount *mp;
- char *path;
- caddr_t data;
- struct nameidata *ndp;
- struct proc *p;
-{
- int error = 0;
- u_int size;
- struct fdescmount *fmp;
- struct vnode *rvp;
-
- /*
- * Update is a no-op
- */
- if (mp->mnt_flag & MNT_UPDATE)
- return (EOPNOTSUPP);
-
- error = fdesc_allocvp(Froot, FD_ROOT, mp, &rvp);
- if (error)
- return (error);
-
- MALLOC(fmp, struct fdescmount *, sizeof(struct fdescmount),
- M_FDESCMNT, M_WAITOK); /* XXX */
- rvp->v_type = VDIR;
- rvp->v_flag |= VROOT;
- fmp->f_root = rvp;
- /* XXX -- don't mark as local to work around fts() problems */
- /*mp->mnt_flag |= MNT_LOCAL;*/
- mp->mnt_data = (qaddr_t) fmp;
- vfs_getnewfsid(mp);
-
- (void) copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size);
- bzero(mp->mnt_stat.f_mntonname + size, MNAMELEN - size);
- bzero(mp->mnt_stat.f_mntfromname, MNAMELEN);
- bcopy("fdesc", mp->mnt_stat.f_mntfromname, sizeof("fdesc"));
- (void)fdesc_statfs(mp, &mp->mnt_stat, p);
- return (0);
-}
-
-static int
-fdesc_unmount(mp, mntflags, p)
- struct mount *mp;
- int mntflags;
- struct proc *p;
-{
- int error;
- int flags = 0;
- struct vnode *rootvp = VFSTOFDESC(mp)->f_root;
-
- if (mntflags & MNT_FORCE)
- flags |= FORCECLOSE;
-
- /*
- * Clear out buffer cache. I don't think we
- * ever get anything cached at this level at the
- * moment, but who knows...
- */
- if (rootvp->v_usecount > 1)
- return (EBUSY);
- if ((error = vflush(mp, rootvp, flags)) != 0)
- return (error);
-
- /*
- * Release reference on underlying root vnode
- */
- vrele(rootvp);
- /*
- * And blow it away for future re-use
- */
- vgone(rootvp);
- /*
- * Finally, throw away the fdescmount structure
- */
- free(mp->mnt_data, M_FDESCMNT); /* XXX */
- mp->mnt_data = 0;
-
- return (0);
-}
-
-int
-fdesc_root(mp, vpp)
- struct mount *mp;
- struct vnode **vpp;
-{
- struct proc *p = curproc; /* XXX */
- struct vnode *vp;
-
- /*
- * Return locked reference to root.
- */
- vp = VFSTOFDESC(mp)->f_root;
- VREF(vp);
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
- *vpp = vp;
- return (0);
-}
-
-static int
-fdesc_statfs(mp, sbp, p)
- struct mount *mp;
- struct statfs *sbp;
- struct proc *p;
-{
- struct filedesc *fdp;
- int lim;
- int i;
- int last;
- int freefd;
-
- /*
- * Compute number of free file descriptors.
- * [ Strange results will ensue if the open file
- * limit is ever reduced below the current number
- * of open files... ]
- */
- lim = p->p_rlimit[RLIMIT_NOFILE].rlim_cur;
- fdp = p->p_fd;
- last = min(fdp->fd_nfiles, lim);
- freefd = 0;
- for (i = fdp->fd_freefile; i < last; i++)
- if (fdp->fd_ofiles[i] == NULL)
- freefd++;
-
- /*
- * Adjust for the fact that the fdesc array may not
- * have been fully allocated yet.
- */
- if (fdp->fd_nfiles < lim)
- freefd += (lim - fdp->fd_nfiles);
-
- sbp->f_flags = 0;
- sbp->f_bsize = DEV_BSIZE;
- sbp->f_iosize = DEV_BSIZE;
- sbp->f_blocks = 2; /* 1K to keep df happy */
- sbp->f_bfree = 0;
- sbp->f_bavail = 0;
- sbp->f_files = lim + 1; /* Allow for "." */
- sbp->f_ffree = freefd; /* See comments above */
- if (sbp != &mp->mnt_stat) {
- sbp->f_type = mp->mnt_vfc->vfc_typenum;
- bcopy(&mp->mnt_stat.f_fsid, &sbp->f_fsid, sizeof(sbp->f_fsid));
- bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN);
- bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN);
- }
- return (0);
-}
-
-static struct vfsops fdesc_vfsops = {
- fdesc_mount,
- vfs_stdstart,
- fdesc_unmount,
- fdesc_root,
- vfs_stdquotactl,
- fdesc_statfs,
- vfs_stdsync,
- vfs_stdvget,
- vfs_stdfhtovp,
- vfs_stdcheckexp,
- vfs_stdvptofh,
- fdesc_init,
- vfs_stduninit,
- vfs_stdextattrctl,
-};
-
-VFS_SET(fdesc_vfsops, fdesc, VFCF_SYNTHETIC);
diff --git a/sys/fs/fdescfs/fdesc_vnops.c b/sys/fs/fdescfs/fdesc_vnops.c
deleted file mode 100644
index 32563491d0da..000000000000
--- a/sys/fs/fdescfs/fdesc_vnops.c
+++ /dev/null
@@ -1,874 +0,0 @@
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)fdesc_vnops.c 8.9 (Berkeley) 1/21/94
- *
- * $FreeBSD$
- */
-
-/*
- * /dev/fd Filesystem
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/proc.h>
-#include <sys/kernel.h> /* boottime */
-#include <sys/filedesc.h>
-#include <sys/vnode.h>
-#include <sys/malloc.h>
-#include <sys/file.h>
-#include <sys/stat.h>
-#include <sys/mount.h>
-#include <sys/namei.h>
-#include <sys/dirent.h>
-#include <sys/conf.h>
-#include <miscfs/fdesc/fdesc.h>
-
-extern struct cdevsw ctty_cdevsw;
-
-#define cttyvp(p) ((p)->p_flag & P_CONTROLT ? (p)->p_session->s_ttyvp : NULL)
-
-#define FDL_WANT 0x01
-#define FDL_LOCKED 0x02
-static int fdcache_lock;
-
-static vop_t **fdesc_vnodeop_p;
-
-dev_t devctty;
-
-#if (FD_STDIN != FD_STDOUT-1) || (FD_STDOUT != FD_STDERR-1)
-FD_STDIN, FD_STDOUT, FD_STDERR must be a sequence n, n+1, n+2
-#endif
-
-#define NFDCACHE 4
-#define FD_NHASH(ix) \
- (&fdhashtbl[(ix) & fdhash])
-static LIST_HEAD(fdhashhead, fdescnode) *fdhashtbl;
-static u_long fdhash;
-
-static int fdesc_attr __P((int fd, struct vattr *vap, struct ucred *cred,
- struct proc *p));
-static int fdesc_badop __P((void));
-static int fdesc_getattr __P((struct vop_getattr_args *ap));
-static int fdesc_inactive __P((struct vop_inactive_args *ap));
-static int fdesc_ioctl __P((struct vop_ioctl_args *ap));
-static int fdesc_lookup __P((struct vop_lookup_args *ap));
-static int fdesc_open __P((struct vop_open_args *ap));
-static int fdesc_print __P((struct vop_print_args *ap));
-static int fdesc_read __P((struct vop_read_args *ap));
-static int fdesc_readdir __P((struct vop_readdir_args *ap));
-static int fdesc_readlink __P((struct vop_readlink_args *ap));
-static int fdesc_reclaim __P((struct vop_reclaim_args *ap));
-static int fdesc_poll __P((struct vop_poll_args *ap));
-static int fdesc_setattr __P((struct vop_setattr_args *ap));
-static int fdesc_write __P((struct vop_write_args *ap));
-
-/*
- * Initialise cache headers
- */
-int
-fdesc_init(vfsp)
- struct vfsconf *vfsp;
-{
-
- devctty = NODEV;
- fdhashtbl = hashinit(NFDCACHE, M_CACHE, &fdhash);
- return (0);
-}
-
-int
-fdesc_allocvp(ftype, ix, mp, vpp)
- fdntype ftype;
- int ix;
- struct mount *mp;
- struct vnode **vpp;
-{
- struct proc *p = curproc; /* XXX */
- struct fdhashhead *fc;
- struct fdescnode *fd;
- int error = 0;
-
- fc = FD_NHASH(ix);
-loop:
- for (fd = fc->lh_first; fd != 0; fd = fd->fd_hash.le_next) {
- if (fd->fd_ix == ix && fd->fd_vnode->v_mount == mp) {
- if (vget(fd->fd_vnode, 0, p))
- goto loop;
- *vpp = fd->fd_vnode;
- return (error);
- }
- }
-
- /*
- * otherwise lock the array while we call getnewvnode
- * since that can block.
- */
- if (fdcache_lock & FDL_LOCKED) {
- fdcache_lock |= FDL_WANT;
- (void) tsleep((caddr_t) &fdcache_lock, PINOD, "fdalvp", 0);
- goto loop;
- }
- fdcache_lock |= FDL_LOCKED;
-
- /*
- * Do the MALLOC before the getnewvnode since doing so afterward
- * might cause a bogus v_data pointer to get dereferenced
- * elsewhere if MALLOC should block.
- */
- MALLOC(fd, struct fdescnode *, sizeof(struct fdescnode), M_TEMP, M_WAITOK);
-
- error = getnewvnode(VT_FDESC, mp, fdesc_vnodeop_p, vpp);
- if (error) {
- FREE(fd, M_TEMP);
- goto out;
- }
- (*vpp)->v_data = fd;
- fd->fd_vnode = *vpp;
- fd->fd_type = ftype;
- fd->fd_fd = -1;
- fd->fd_link = 0;
- fd->fd_ix = ix;
- LIST_INSERT_HEAD(fc, fd, fd_hash);
-
-out:;
- fdcache_lock &= ~FDL_LOCKED;
-
- if (fdcache_lock & FDL_WANT) {
- fdcache_lock &= ~FDL_WANT;
- wakeup((caddr_t) &fdcache_lock);
- }
-
- return (error);
-}
-
-/*
- * vp is the current namei directory
- * ndp is the name to locate in that directory...
- */
-static int
-fdesc_lookup(ap)
- struct vop_lookup_args /* {
- struct vnode * a_dvp;
- struct vnode ** a_vpp;
- struct componentname * a_cnp;
- } */ *ap;
-{
- struct vnode **vpp = ap->a_vpp;
- struct vnode *dvp = ap->a_dvp;
- struct componentname *cnp = ap->a_cnp;
- char *pname = cnp->cn_nameptr;
- struct proc *p = cnp->cn_proc;
- int nfiles = p->p_fd->fd_nfiles;
- unsigned fd = -1;
- int error;
- struct vnode *fvp;
- char *ln;
-
- if (cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME) {
- error = EROFS;
- goto bad;
- }
-
- VOP_UNLOCK(dvp, 0, p);
- if (cnp->cn_namelen == 1 && *pname == '.') {
- *vpp = dvp;
- VREF(dvp);
- vn_lock(dvp, LK_SHARED | LK_RETRY, p);
- return (0);
- }
-
- switch (VTOFDESC(dvp)->fd_type) {
- default:
- case Flink:
- case Fdesc:
- case Fctty:
- error = ENOTDIR;
- goto bad;
-
- case Froot:
- if (cnp->cn_namelen == 2 && bcmp(pname, "fd", 2) == 0) {
- error = fdesc_allocvp(Fdevfd, FD_DEVFD, dvp->v_mount, &fvp);
- if (error)
- goto bad;
- *vpp = fvp;
- fvp->v_type = VDIR;
- vn_lock(fvp, LK_SHARED | LK_RETRY, p);
- return (0);
- }
-
- if (cnp->cn_namelen == 3 && bcmp(pname, "tty", 3) == 0) {
- struct vnode *ttyvp = cttyvp(p);
- if (ttyvp == NULL) {
- error = ENXIO;
- goto bad;
- }
- error = fdesc_allocvp(Fctty, FD_CTTY, dvp->v_mount, &fvp);
- if (error)
- goto bad;
- *vpp = fvp;
- fvp->v_type = VFIFO;
- vn_lock(fvp, LK_SHARED | LK_RETRY, p);
- return (0);
- }
-
- ln = 0;
- switch (cnp->cn_namelen) {
- case 5:
- if (bcmp(pname, "stdin", 5) == 0) {
- ln = "fd/0";
- fd = FD_STDIN;
- }
- break;
- case 6:
- if (bcmp(pname, "stdout", 6) == 0) {
- ln = "fd/1";
- fd = FD_STDOUT;
- } else
- if (bcmp(pname, "stderr", 6) == 0) {
- ln = "fd/2";
- fd = FD_STDERR;
- }
- break;
- }
-
- if (ln) {
- error = fdesc_allocvp(Flink, fd, dvp->v_mount, &fvp);
- if (error)
- goto bad;
- VTOFDESC(fvp)->fd_link = ln;
- *vpp = fvp;
- fvp->v_type = VLNK;
- vn_lock(fvp, LK_SHARED | LK_RETRY, p);
- return (0);
- } else {
- error = ENOENT;
- goto bad;
- }
-
- /* FALL THROUGH */
-
- case Fdevfd:
- if (cnp->cn_namelen == 2 && bcmp(pname, "..", 2) == 0) {
- if ((error = fdesc_root(dvp->v_mount, vpp)) != 0)
- goto bad;
- return (0);
- }
-
- fd = 0;
- while (*pname >= '0' && *pname <= '9') {
- fd = 10 * fd + *pname++ - '0';
- if (fd >= nfiles)
- break;
- }
-
- if (*pname != '\0') {
- error = ENOENT;
- goto bad;
- }
-
- if (fd >= nfiles || p->p_fd->fd_ofiles[fd] == NULL) {
- error = EBADF;
- goto bad;
- }
-
- error = fdesc_allocvp(Fdesc, FD_DESC+fd, dvp->v_mount, &fvp);
- if (error)
- goto bad;
- VTOFDESC(fvp)->fd_fd = fd;
- vn_lock(fvp, LK_SHARED | LK_RETRY, p);
- *vpp = fvp;
- return (0);
- }
-
-bad:;
- vn_lock(dvp, LK_SHARED | LK_RETRY, p);
- *vpp = NULL;
- return (error);
-}
-
-static int
-fdesc_open(ap)
- struct vop_open_args /* {
- struct vnode *a_vp;
- int a_mode;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
- int error = 0;
-
- switch (VTOFDESC(vp)->fd_type) {
- case Fdesc:
- /*
- * XXX Kludge: set p->p_dupfd to contain the value of the
- * the file descriptor being sought for duplication. The error
- * return ensures that the vnode for this device will be
- * released by vn_open. Open will detect this special error and
- * take the actions in dupfdopen. Other callers of vn_open or
- * VOP_OPEN will simply report the error.
- */
- ap->a_p->p_dupfd = VTOFDESC(vp)->fd_fd; /* XXX */
- error = ENODEV;
- break;
-
- case Fctty:
- error = (*ctty_cdevsw.d_open)(devctty, ap->a_mode, 0, ap->a_p);
- break;
-
- default: /* nothing special */
- break;
- }
-
- return (error);
-}
-
-static int
-fdesc_attr(fd, vap, cred, p)
- int fd;
- struct vattr *vap;
- struct ucred *cred;
- struct proc *p;
-{
- struct filedesc *fdp = p->p_fd;
- struct file *fp;
- struct stat stb;
- int error;
-
- if (fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[fd]) == NULL)
- return (EBADF);
-
- switch (fp->f_type) {
- case DTYPE_FIFO:
- case DTYPE_VNODE:
- error = VOP_GETATTR((struct vnode *) fp->f_data, vap, cred, p);
- if (error == 0 && vap->va_type == VDIR) {
- /*
- * directories can cause loops in the namespace,
- * so turn off the 'x' bits to avoid trouble.
- */
- vap->va_mode &= ~((VEXEC)|(VEXEC>>3)|(VEXEC>>6));
- }
- break;
-
- case DTYPE_PIPE:
- case DTYPE_SOCKET:
- error = fo_stat(fp, &stb, p);
- if (error == 0) {
- vattr_null(vap);
- vap->va_type = VSOCK; /* XXX pipe? */
- vap->va_mode = stb.st_mode;
- vap->va_nlink = stb.st_nlink;
- vap->va_uid = stb.st_uid;
- vap->va_gid = stb.st_gid;
- vap->va_fsid = stb.st_dev;
- vap->va_fileid = stb.st_ino;
- vap->va_size = stb.st_size;
- vap->va_blocksize = stb.st_blksize;
- vap->va_atime = stb.st_atimespec;
- vap->va_mtime = stb.st_mtimespec;
- vap->va_ctime = stb.st_ctimespec;
- vap->va_gen = stb.st_gen;
- vap->va_flags = stb.st_flags;
- vap->va_rdev = stb.st_rdev;
- vap->va_bytes = stb.st_blocks * stb.st_blksize;
- }
- break;
-
- default:
- panic("fdesc attr");
- break;
- }
-
- return (error);
-}
-
-static int
-fdesc_getattr(ap)
- struct vop_getattr_args /* {
- struct vnode *a_vp;
- struct vattr *a_vap;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
- struct vattr *vap = ap->a_vap;
- unsigned fd;
- int error = 0;
-
- switch (VTOFDESC(vp)->fd_type) {
- case Froot:
- case Fdevfd:
- case Flink:
- case Fctty:
- bzero((caddr_t) vap, sizeof(*vap));
- vattr_null(vap);
- vap->va_fileid = VTOFDESC(vp)->fd_ix;
-
- switch (VTOFDESC(vp)->fd_type) {
- case Flink:
- vap->va_mode = S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;
- vap->va_type = VLNK;
- vap->va_nlink = 1;
- vap->va_size = strlen(VTOFDESC(vp)->fd_link);
- break;
-
- case Fctty:
- vap->va_mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH;
- vap->va_type = VFIFO;
- vap->va_nlink = 1;
- vap->va_size = 0;
- break;
-
- default:
- vap->va_mode = S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;
- vap->va_type = VDIR;
- vap->va_nlink = 2;
- vap->va_size = DEV_BSIZE;
- break;
- }
- vap->va_uid = 0;
- vap->va_gid = 0;
- vap->va_blocksize = DEV_BSIZE;
- vap->va_atime.tv_sec = boottime.tv_sec;
- vap->va_atime.tv_nsec = 0;
- vap->va_mtime = vap->va_atime;
- vap->va_ctime = vap->va_mtime;
- vap->va_gen = 0;
- vap->va_flags = 0;
- vap->va_rdev = 0;
- vap->va_bytes = 0;
- break;
-
- case Fdesc:
- fd = VTOFDESC(vp)->fd_fd;
- error = fdesc_attr(fd, vap, ap->a_cred, ap->a_p);
- break;
-
- default:
- panic("fdesc_getattr");
- break;
- }
-
- if (error == 0)
- vp->v_type = vap->va_type;
-
- return (error);
-}
-
-static int
-fdesc_setattr(ap)
- struct vop_setattr_args /* {
- struct vnode *a_vp;
- struct vattr *a_vap;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- struct filedesc *fdp = ap->a_p->p_fd;
- struct vattr *vap = ap->a_vap;
- struct file *fp;
- unsigned fd;
- int error;
-
- /*
- * Can't mess with the root vnode
- */
- switch (VTOFDESC(ap->a_vp)->fd_type) {
- case Fdesc:
- break;
-
- case Fctty:
- if (vap->va_flags != VNOVAL)
- return (EOPNOTSUPP);
- return (0);
-
- default:
- return (EACCES);
- }
-
- fd = VTOFDESC(ap->a_vp)->fd_fd;
- if (fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[fd]) == NULL) {
- return (EBADF);
- }
-
- /*
- * Can setattr the underlying vnode, but not sockets!
- */
- switch (fp->f_type) {
- case DTYPE_FIFO:
- case DTYPE_PIPE:
- case DTYPE_VNODE:
- error = VOP_SETATTR((struct vnode *) fp->f_data, ap->a_vap, ap->a_cred, ap->a_p);
- break;
-
- case DTYPE_SOCKET:
- if (vap->va_flags != VNOVAL)
- error = EOPNOTSUPP;
- else
- error = 0;
- break;
-
- default:
- error = EBADF;
- break;
- }
-
- return (error);
-}
-
-#define UIO_MX 16
-
-static struct dirtmp {
- u_long d_fileno;
- u_short d_reclen;
- u_short d_namlen;
- char d_name[8];
-} rootent[] = {
- { FD_DEVFD, UIO_MX, 2, "fd" },
- { FD_STDIN, UIO_MX, 5, "stdin" },
- { FD_STDOUT, UIO_MX, 6, "stdout" },
- { FD_STDERR, UIO_MX, 6, "stderr" },
- { FD_CTTY, UIO_MX, 3, "tty" },
-};
-
-static int
-fdesc_readdir(ap)
- struct vop_readdir_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- struct ucred *a_cred;
- int *a_eofflag;
- u_long *a_cookies;
- int a_ncookies;
- } */ *ap;
-{
- struct uio *uio = ap->a_uio;
- struct filedesc *fdp;
- int error, i, off;
-
- /*
- * We don't allow exporting fdesc mounts, and currently local
- * requests do not need cookies.
- */
- if (ap->a_ncookies)
- panic("fdesc_readdir: not hungry");
-
- if (VTOFDESC(ap->a_vp)->fd_type != Froot &&
- VTOFDESC(ap->a_vp)->fd_type != Fdevfd)
- panic("fdesc_readdir: not dir");
-
- off = (int)uio->uio_offset;
- if (off != uio->uio_offset || off < 0 || (u_int)off % UIO_MX != 0 ||
- uio->uio_resid < UIO_MX)
- return (EINVAL);
- i = (u_int)off / UIO_MX;
- fdp = uio->uio_procp->p_fd;
-
- if (VTOFDESC(ap->a_vp)->fd_type == Froot) {
- struct dirent d;
- struct dirent *dp = &d;
- struct dirtmp *dt;
-
- error = 0;
-
- while (i < sizeof(rootent) / sizeof(rootent[0]) &&
- uio->uio_resid >= UIO_MX) {
- dt = &rootent[i];
- switch (dt->d_fileno) {
- case FD_CTTY:
- if (cttyvp(uio->uio_procp) == NULL)
- continue;
- break;
-
- case FD_STDIN:
- case FD_STDOUT:
- case FD_STDERR:
- if ((dt->d_fileno-FD_STDIN) >= fdp->fd_nfiles)
- continue;
- if (fdp->fd_ofiles[dt->d_fileno-FD_STDIN] == NULL)
- continue;
- break;
- }
- bzero((caddr_t) dp, UIO_MX);
- dp->d_fileno = dt->d_fileno;
- dp->d_namlen = dt->d_namlen;
- dp->d_type = DT_UNKNOWN;
- dp->d_reclen = dt->d_reclen;
- bcopy(dt->d_name, dp->d_name, dp->d_namlen+1);
- error = uiomove((caddr_t) dp, UIO_MX, uio);
- if (error)
- break;
- i++;
- }
- uio->uio_offset = i * UIO_MX;
- return (error);
- }
-
- error = 0;
- while (i < fdp->fd_nfiles && uio->uio_resid >= UIO_MX) {
- if (fdp->fd_ofiles[i] != NULL) {
- struct dirent d;
- struct dirent *dp = &d;
-
- bzero((caddr_t) dp, UIO_MX);
-
- dp->d_namlen = sprintf(dp->d_name, "%d", i);
- dp->d_reclen = UIO_MX;
- dp->d_type = DT_UNKNOWN;
- dp->d_fileno = i + FD_STDIN;
- /*
- * And ship to userland
- */
- error = uiomove((caddr_t) dp, UIO_MX, uio);
- if (error)
- break;
- }
- i++;
- }
-
- uio->uio_offset = i * UIO_MX;
- return (error);
-}
-
-static int
-fdesc_readlink(ap)
- struct vop_readlink_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- struct ucred *a_cred;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
- int error;
-
- if (vp->v_type != VLNK)
- return (EPERM);
-
- if (VTOFDESC(vp)->fd_type == Flink) {
- char *ln = VTOFDESC(vp)->fd_link;
- error = uiomove(ln, strlen(ln), ap->a_uio);
- } else {
- error = EOPNOTSUPP;
- }
-
- return (error);
-}
-
-static int
-fdesc_read(ap)
- struct vop_read_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- int a_ioflag;
- struct ucred *a_cred;
- } */ *ap;
-{
- int error = EOPNOTSUPP;
-
- switch (VTOFDESC(ap->a_vp)->fd_type) {
- case Fctty:
- error = (*ctty_cdevsw.d_read)(devctty, ap->a_uio, ap->a_ioflag);
- break;
-
- default:
- error = EOPNOTSUPP;
- break;
- }
-
- return (error);
-}
-
-static int
-fdesc_write(ap)
- struct vop_write_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- int a_ioflag;
- struct ucred *a_cred;
- } */ *ap;
-{
- int error = EOPNOTSUPP;
-
- switch (VTOFDESC(ap->a_vp)->fd_type) {
- case Fctty:
- error = (*ctty_cdevsw.d_write)(devctty, ap->a_uio, ap->a_ioflag);
- break;
-
- default:
- error = EOPNOTSUPP;
- break;
- }
-
- return (error);
-}
-
-static int
-fdesc_ioctl(ap)
- struct vop_ioctl_args /* {
- struct vnode *a_vp;
- int a_command;
- caddr_t a_data;
- int a_fflag;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- int error = EOPNOTSUPP;
-
- switch (VTOFDESC(ap->a_vp)->fd_type) {
- case Fctty:
- error = (*ctty_cdevsw.d_ioctl)(devctty, ap->a_command,
- ap->a_data, ap->a_fflag, ap->a_p);
- break;
-
- default:
- error = EOPNOTSUPP;
- break;
- }
-
- return (error);
-}
-
-static int
-fdesc_poll(ap)
- struct vop_poll_args /* {
- struct vnode *a_vp;
- int a_events;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- int revents;
-
- switch (VTOFDESC(ap->a_vp)->fd_type) {
- case Fctty:
- revents = (*ctty_cdevsw.d_poll)(devctty, ap->a_events, ap->a_p);
- break;
-
- default:
- revents = seltrue(0, ap->a_events, ap->a_p);
- break;
- }
-
- return (revents);
-}
-
-static int
-fdesc_inactive(ap)
- struct vop_inactive_args /* {
- struct vnode *a_vp;
- struct proc *a_p;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
-
- /*
- * Clear out the v_type field to avoid
- * nasty things happening in vgone().
- */
- VOP_UNLOCK(vp, 0, ap->a_p);
- vp->v_type = VNON;
- return (0);
-}
-
-static int
-fdesc_reclaim(ap)
- struct vop_reclaim_args /* {
- struct vnode *a_vp;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
- struct fdescnode *fd = VTOFDESC(vp);
-
- LIST_REMOVE(fd, fd_hash);
- FREE(vp->v_data, M_TEMP);
- vp->v_data = 0;
-
- return (0);
-}
-
-/*
- * Print out the contents of a /dev/fd vnode.
- */
-/* ARGSUSED */
-static int
-fdesc_print(ap)
- struct vop_print_args /* {
- struct vnode *a_vp;
- } */ *ap;
-{
-
- printf("tag VT_NON, fdesc vnode\n");
- return (0);
-}
-
-/*
- * /dev/fd "should never get here" operation
- */
-static int
-fdesc_badop()
-{
-
- panic("fdesc: bad op");
- /* NOTREACHED */
-}
-
-static struct vnodeopv_entry_desc fdesc_vnodeop_entries[] = {
- { &vop_default_desc, (vop_t *) vop_defaultop },
- { &vop_access_desc, (vop_t *) vop_null },
- { &vop_bmap_desc, (vop_t *) fdesc_badop },
- { &vop_getattr_desc, (vop_t *) fdesc_getattr },
- { &vop_inactive_desc, (vop_t *) fdesc_inactive },
- { &vop_ioctl_desc, (vop_t *) fdesc_ioctl },
- { &vop_lookup_desc, (vop_t *) fdesc_lookup },
- { &vop_open_desc, (vop_t *) fdesc_open },
- { &vop_pathconf_desc, (vop_t *) vop_stdpathconf },
- { &vop_poll_desc, (vop_t *) fdesc_poll },
- { &vop_print_desc, (vop_t *) fdesc_print },
- { &vop_read_desc, (vop_t *) fdesc_read },
- { &vop_readdir_desc, (vop_t *) fdesc_readdir },
- { &vop_readlink_desc, (vop_t *) fdesc_readlink },
- { &vop_reclaim_desc, (vop_t *) fdesc_reclaim },
- { &vop_setattr_desc, (vop_t *) fdesc_setattr },
- { &vop_write_desc, (vop_t *) fdesc_write },
- { NULL, NULL }
-};
-static struct vnodeopv_desc fdesc_vnodeop_opv_desc =
- { &fdesc_vnodeop_p, fdesc_vnodeop_entries };
-
-VNODEOP_SET(fdesc_vnodeop_opv_desc);
diff --git a/sys/fs/fifofs/fifo.h b/sys/fs/fifofs/fifo.h
deleted file mode 100644
index e63020752863..000000000000
--- a/sys/fs/fifofs/fifo.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 1991, 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)fifo.h 8.6 (Berkeley) 5/21/95
- * $FreeBSD$
- */
-
-extern vop_t **fifo_vnodeop_p;
-
-/*
- * Prototypes for fifo operations on vnodes.
- */
-int fifo_vnoperate __P((struct vop_generic_args *));
-int fifo_printinfo __P((struct vnode *));
-
diff --git a/sys/fs/fifofs/fifo_vnops.c b/sys/fs/fifofs/fifo_vnops.c
deleted file mode 100644
index b64f957b4960..000000000000
--- a/sys/fs/fifofs/fifo_vnops.c
+++ /dev/null
@@ -1,536 +0,0 @@
-/*
- * Copyright (c) 1990, 1993, 1995
- * 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)fifo_vnops.c 8.10 (Berkeley) 5/27/95
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/unistd.h>
-#include <sys/kernel.h>
-#include <sys/lock.h>
-#include <sys/malloc.h>
-#include <sys/vnode.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-#include <sys/filio.h>
-#include <sys/fcntl.h>
-#include <sys/file.h>
-#include <sys/poll.h>
-#include <sys/un.h>
-#include <miscfs/fifofs/fifo.h>
-
-/*
- * This structure is associated with the FIFO vnode and stores
- * the state associated with the FIFO.
- */
-struct fifoinfo {
- struct socket *fi_readsock;
- struct socket *fi_writesock;
- long fi_readers;
- long fi_writers;
-};
-
-static int fifo_badop __P((void));
-static int fifo_print __P((struct vop_print_args *));
-static int fifo_lookup __P((struct vop_lookup_args *));
-static int fifo_open __P((struct vop_open_args *));
-static int fifo_close __P((struct vop_close_args *));
-static int fifo_read __P((struct vop_read_args *));
-static int fifo_write __P((struct vop_write_args *));
-static int fifo_ioctl __P((struct vop_ioctl_args *));
-static int fifo_poll __P((struct vop_poll_args *));
-static int fifo_inactive __P((struct vop_inactive_args *));
-static int fifo_bmap __P((struct vop_bmap_args *));
-static int fifo_pathconf __P((struct vop_pathconf_args *));
-static int fifo_advlock __P((struct vop_advlock_args *));
-
-
-vop_t **fifo_vnodeop_p;
-static struct vnodeopv_entry_desc fifo_vnodeop_entries[] = {
- { &vop_default_desc, (vop_t *) vop_defaultop },
- { &vop_access_desc, (vop_t *) vop_ebadf },
- { &vop_advlock_desc, (vop_t *) fifo_advlock },
- { &vop_bmap_desc, (vop_t *) fifo_bmap },
- { &vop_close_desc, (vop_t *) fifo_close },
- { &vop_create_desc, (vop_t *) fifo_badop },
- { &vop_getattr_desc, (vop_t *) vop_ebadf },
- { &vop_inactive_desc, (vop_t *) fifo_inactive },
- { &vop_ioctl_desc, (vop_t *) fifo_ioctl },
- { &vop_lease_desc, (vop_t *) vop_null },
- { &vop_link_desc, (vop_t *) fifo_badop },
- { &vop_lookup_desc, (vop_t *) fifo_lookup },
- { &vop_mkdir_desc, (vop_t *) fifo_badop },
- { &vop_mknod_desc, (vop_t *) fifo_badop },
- { &vop_open_desc, (vop_t *) fifo_open },
- { &vop_pathconf_desc, (vop_t *) fifo_pathconf },
- { &vop_poll_desc, (vop_t *) fifo_poll },
- { &vop_print_desc, (vop_t *) fifo_print },
- { &vop_read_desc, (vop_t *) fifo_read },
- { &vop_readdir_desc, (vop_t *) fifo_badop },
- { &vop_readlink_desc, (vop_t *) fifo_badop },
- { &vop_reallocblks_desc, (vop_t *) fifo_badop },
- { &vop_reclaim_desc, (vop_t *) vop_null },
- { &vop_remove_desc, (vop_t *) fifo_badop },
- { &vop_rename_desc, (vop_t *) fifo_badop },
- { &vop_rmdir_desc, (vop_t *) fifo_badop },
- { &vop_setattr_desc, (vop_t *) vop_ebadf },
- { &vop_symlink_desc, (vop_t *) fifo_badop },
- { &vop_write_desc, (vop_t *) fifo_write },
- { NULL, NULL }
-};
-static struct vnodeopv_desc fifo_vnodeop_opv_desc =
- { &fifo_vnodeop_p, fifo_vnodeop_entries };
-
-VNODEOP_SET(fifo_vnodeop_opv_desc);
-
-int
-fifo_vnoperate(ap)
- struct vop_generic_args /* {
- struct vnodeop_desc *a_desc;
- <other random data follows, presumably>
- } */ *ap;
-{
- return (VOCALL(fifo_vnodeop_p, ap->a_desc->vdesc_offset, ap));
-}
-
-/*
- * Trivial lookup routine that always fails.
- */
-/* ARGSUSED */
-static int
-fifo_lookup(ap)
- struct vop_lookup_args /* {
- struct vnode * a_dvp;
- struct vnode ** a_vpp;
- struct componentname * a_cnp;
- } */ *ap;
-{
-
- *ap->a_vpp = NULL;
- return (ENOTDIR);
-}
-
-/*
- * Open called to set up a new instance of a fifo or
- * to find an active instance of a fifo.
- */
-/* ARGSUSED */
-static int
-fifo_open(ap)
- struct vop_open_args /* {
- struct vnode *a_vp;
- int a_mode;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
- struct fifoinfo *fip;
- struct proc *p = ap->a_p;
- struct socket *rso, *wso;
- int error;
-
- if ((fip = vp->v_fifoinfo) == NULL) {
- MALLOC(fip, struct fifoinfo *, sizeof(*fip), M_VNODE, M_WAITOK);
- vp->v_fifoinfo = fip;
- error = socreate(AF_LOCAL, &rso, SOCK_STREAM, 0, ap->a_p);
- if (error) {
- free(fip, M_VNODE);
- vp->v_fifoinfo = NULL;
- return (error);
- }
- fip->fi_readsock = rso;
- error = socreate(AF_LOCAL, &wso, SOCK_STREAM, 0, ap->a_p);
- if (error) {
- (void)soclose(rso);
- free(fip, M_VNODE);
- vp->v_fifoinfo = NULL;
- return (error);
- }
- fip->fi_writesock = wso;
- error = unp_connect2(wso, rso);
- if (error) {
- (void)soclose(wso);
- (void)soclose(rso);
- free(fip, M_VNODE);
- vp->v_fifoinfo = NULL;
- return (error);
- }
- fip->fi_readers = fip->fi_writers = 0;
- wso->so_snd.sb_lowat = PIPE_BUF;
- rso->so_state |= SS_CANTRCVMORE;
- }
- if (ap->a_mode & FREAD) {
- fip->fi_readers++;
- if (fip->fi_readers == 1) {
- fip->fi_writesock->so_state &= ~SS_CANTSENDMORE;
- if (fip->fi_writers > 0)
- wakeup((caddr_t)&fip->fi_writers);
- }
- }
- if (ap->a_mode & FWRITE) {
- fip->fi_writers++;
- if (fip->fi_writers == 1) {
- fip->fi_readsock->so_state &= ~SS_CANTRCVMORE;
- if (fip->fi_readers > 0)
- wakeup((caddr_t)&fip->fi_readers);
- }
- }
- if ((ap->a_mode & FREAD) && (ap->a_mode & O_NONBLOCK) == 0) {
- while (fip->fi_writers == 0) {
- VOP_UNLOCK(vp, 0, p);
- error = tsleep((caddr_t)&fip->fi_readers,
- PCATCH | PSOCK, "fifoor", 0);
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
- if (error)
- goto bad;
- }
- }
- if (ap->a_mode & FWRITE) {
- if (ap->a_mode & O_NONBLOCK) {
- if (fip->fi_readers == 0) {
- error = ENXIO;
- goto bad;
- }
- } else {
- while (fip->fi_readers == 0) {
- VOP_UNLOCK(vp, 0, p);
- error = tsleep((caddr_t)&fip->fi_writers,
- PCATCH | PSOCK, "fifoow", 0);
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
- if (error)
- goto bad;
- }
- }
- }
- return (0);
-bad:
- VOP_CLOSE(vp, ap->a_mode, ap->a_cred, p);
- return (error);
-}
-
-/*
- * Vnode op for read
- */
-/* ARGSUSED */
-static int
-fifo_read(ap)
- struct vop_read_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- int a_ioflag;
- struct ucred *a_cred;
- } */ *ap;
-{
- struct uio *uio = ap->a_uio;
- struct socket *rso = ap->a_vp->v_fifoinfo->fi_readsock;
- struct proc *p = uio->uio_procp;
- int error, startresid;
-
-#ifdef DIAGNOSTIC
- if (uio->uio_rw != UIO_READ)
- panic("fifo_read mode");
-#endif
- if (uio->uio_resid == 0)
- return (0);
- if (ap->a_ioflag & IO_NDELAY)
- rso->so_state |= SS_NBIO;
- startresid = uio->uio_resid;
- VOP_UNLOCK(ap->a_vp, 0, p);
- error = soreceive(rso, (struct sockaddr **)0, uio, (struct mbuf **)0,
- (struct mbuf **)0, (int *)0);
- vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY, p);
- if (ap->a_ioflag & IO_NDELAY)
- rso->so_state &= ~SS_NBIO;
- return (error);
-}
-
-/*
- * Vnode op for write
- */
-/* ARGSUSED */
-static int
-fifo_write(ap)
- struct vop_write_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- int a_ioflag;
- struct ucred *a_cred;
- } */ *ap;
-{
- struct socket *wso = ap->a_vp->v_fifoinfo->fi_writesock;
- struct proc *p = ap->a_uio->uio_procp;
- int error;
-
-#ifdef DIAGNOSTIC
- if (ap->a_uio->uio_rw != UIO_WRITE)
- panic("fifo_write mode");
-#endif
- if (ap->a_ioflag & IO_NDELAY)
- wso->so_state |= SS_NBIO;
- VOP_UNLOCK(ap->a_vp, 0, p);
- error = sosend(wso, (struct sockaddr *)0, ap->a_uio, 0,
- (struct mbuf *)0, 0, p);
- vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY, p);
- if (ap->a_ioflag & IO_NDELAY)
- wso->so_state &= ~SS_NBIO;
- return (error);
-}
-
-/*
- * Device ioctl operation.
- */
-/* ARGSUSED */
-static int
-fifo_ioctl(ap)
- struct vop_ioctl_args /* {
- struct vnode *a_vp;
- int a_command;
- caddr_t a_data;
- int a_fflag;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- struct file filetmp;
- int error;
-
- if (ap->a_command == FIONBIO)
- return (0);
- if (ap->a_fflag & FREAD) {
- filetmp.f_data = (caddr_t)ap->a_vp->v_fifoinfo->fi_readsock;
- error = soo_ioctl(&filetmp, ap->a_command, ap->a_data, ap->a_p);
- if (error)
- return (error);
- }
- if (ap->a_fflag & FWRITE) {
- filetmp.f_data = (caddr_t)ap->a_vp->v_fifoinfo->fi_writesock;
- error = soo_ioctl(&filetmp, ap->a_command, ap->a_data, ap->a_p);
- if (error)
- return (error);
- }
- return (0);
-}
-
-/* ARGSUSED */
-static int
-fifo_poll(ap)
- struct vop_poll_args /* {
- struct vnode *a_vp;
- int a_events;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- struct file filetmp;
- int revents = 0;
-
- if (ap->a_events & (POLLIN | POLLPRI | POLLRDNORM | POLLRDBAND)) {
- filetmp.f_data = (caddr_t)ap->a_vp->v_fifoinfo->fi_readsock;
- if (filetmp.f_data)
- revents |= soo_poll(&filetmp, ap->a_events, ap->a_cred,
- ap->a_p);
- }
- if (ap->a_events & (POLLOUT | POLLWRNORM | POLLWRBAND)) {
- filetmp.f_data = (caddr_t)ap->a_vp->v_fifoinfo->fi_writesock;
- if (filetmp.f_data)
- revents |= soo_poll(&filetmp, ap->a_events, ap->a_cred,
- ap->a_p);
- }
- return (revents);
-}
-
-static int
-fifo_inactive(ap)
- struct vop_inactive_args /* {
- struct vnode *a_vp;
- struct proc *a_p;
- } */ *ap;
-{
-
- VOP_UNLOCK(ap->a_vp, 0, ap->a_p);
- return (0);
-}
-
-/*
- * This is a noop, simply returning what one has been given.
- */
-static int
-fifo_bmap(ap)
- struct vop_bmap_args /* {
- struct vnode *a_vp;
- daddr_t a_bn;
- struct vnode **a_vpp;
- daddr_t *a_bnp;
- int *a_runp;
- int *a_runb;
- } */ *ap;
-{
-
- if (ap->a_vpp != NULL)
- *ap->a_vpp = ap->a_vp;
- if (ap->a_bnp != NULL)
- *ap->a_bnp = ap->a_bn;
- if (ap->a_runp != NULL)
- *ap->a_runp = 0;
- if (ap->a_runb != NULL)
- *ap->a_runb = 0;
- return (0);
-}
-
-/*
- * Device close routine
- */
-/* ARGSUSED */
-static int
-fifo_close(ap)
- struct vop_close_args /* {
- struct vnode *a_vp;
- int a_fflag;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
- register struct fifoinfo *fip = vp->v_fifoinfo;
- int error1, error2;
-
- if (ap->a_fflag & FREAD) {
- fip->fi_readers--;
- if (fip->fi_readers == 0)
- socantsendmore(fip->fi_writesock);
- }
- if (ap->a_fflag & FWRITE) {
- fip->fi_writers--;
- if (fip->fi_writers == 0)
- socantrcvmore(fip->fi_readsock);
- }
- if (vp->v_usecount > 1)
- return (0);
- error1 = soclose(fip->fi_readsock);
- error2 = soclose(fip->fi_writesock);
- FREE(fip, M_VNODE);
- vp->v_fifoinfo = NULL;
- if (error1)
- return (error1);
- return (error2);
-}
-
-
-/*
- * Print out internal contents of a fifo vnode.
- */
-int
-fifo_printinfo(vp)
- struct vnode *vp;
-{
- register struct fifoinfo *fip = vp->v_fifoinfo;
-
- printf(", fifo with %ld readers and %ld writers",
- fip->fi_readers, fip->fi_writers);
- return (0);
-}
-
-/*
- * Print out the contents of a fifo vnode.
- */
-static int
-fifo_print(ap)
- struct vop_print_args /* {
- struct vnode *a_vp;
- } */ *ap;
-{
-
- printf("tag VT_NON");
- fifo_printinfo(ap->a_vp);
- printf("\n");
- return (0);
-}
-
-/*
- * Return POSIX pathconf information applicable to fifo's.
- */
-int
-fifo_pathconf(ap)
- struct vop_pathconf_args /* {
- struct vnode *a_vp;
- int a_name;
- int *a_retval;
- } */ *ap;
-{
-
- switch (ap->a_name) {
- case _PC_LINK_MAX:
- *ap->a_retval = LINK_MAX;
- return (0);
- case _PC_PIPE_BUF:
- *ap->a_retval = PIPE_BUF;
- return (0);
- case _PC_CHOWN_RESTRICTED:
- *ap->a_retval = 1;
- return (0);
- default:
- return (EINVAL);
- }
- /* NOTREACHED */
-}
-
-/*
- * Fifo advisory byte-level locks.
- */
-/* ARGSUSED */
-static int
-fifo_advlock(ap)
- struct vop_advlock_args /* {
- struct vnode *a_vp;
- caddr_t a_id;
- int a_op;
- struct flock *a_fl;
- int a_flags;
- } */ *ap;
-{
-
- return (ap->a_flags & F_FLOCK ? EOPNOTSUPP : EINVAL);
-}
-
-/*
- * Fifo bad operation
- */
-static int
-fifo_badop()
-{
-
- panic("fifo_badop called");
- /* NOTREACHED */
-}
diff --git a/sys/fs/msdosfs/bootsect.h b/sys/fs/msdosfs/bootsect.h
deleted file mode 100644
index 666c0f8f41b1..000000000000
--- a/sys/fs/msdosfs/bootsect.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/* $FreeBSD$ */
-/* $NetBSD: bootsect.h,v 1.9 1997/11/17 15:36:17 ws Exp $ */
-
-/*
- * Written by Paul Popelka (paulp@uts.amdahl.com)
- *
- * You can do anything you want with this software, just don't say you wrote
- * it, and don't remove this notice.
- *
- * This software is provided "as is".
- *
- * The author supplies this software to be publicly redistributed on the
- * understanding that the author is not responsible for the correct
- * functioning of this software in any circumstances and is not liable for
- * any damages caused by this software.
- *
- * October 1992
- */
-
-/*
- * Format of a boot sector. This is the first sector on a DOS floppy disk
- * or the fist sector of a partition on a hard disk. But, it is not the
- * first sector of a partitioned hard disk.
- */
-struct bootsector33 {
- u_int8_t bsJump[3]; /* jump inst E9xxxx or EBxx90 */
- int8_t bsOemName[8]; /* OEM name and version */
- int8_t bsBPB[19]; /* BIOS parameter block */
- int8_t bsDriveNumber; /* drive number (0x80) */
- int8_t bsBootCode[479]; /* pad so struct is 512b */
- u_int8_t bsBootSectSig0;
- u_int8_t bsBootSectSig1;
-#define BOOTSIG0 0x55
-#define BOOTSIG1 0xaa
-};
-
-struct extboot {
- int8_t exDriveNumber; /* drive number (0x80) */
- int8_t exReserved1; /* reserved */
- int8_t exBootSignature; /* ext. boot signature (0x29) */
-#define EXBOOTSIG 0x29
- int8_t exVolumeID[4]; /* volume ID number */
- int8_t exVolumeLabel[11]; /* volume label */
- int8_t exFileSysType[8]; /* fs type (FAT12 or FAT16) */
-};
-
-struct bootsector50 {
- u_int8_t bsJump[3]; /* jump inst E9xxxx or EBxx90 */
- int8_t bsOemName[8]; /* OEM name and version */
- int8_t bsBPB[25]; /* BIOS parameter block */
- int8_t bsExt[26]; /* Bootsector Extension */
- int8_t bsBootCode[448]; /* pad so structure is 512b */
- u_int8_t bsBootSectSig0;
- u_int8_t bsBootSectSig1;
-#define BOOTSIG0 0x55
-#define BOOTSIG1 0xaa
-};
-
-struct bootsector710 {
- u_int8_t bsJump[3]; /* jump inst E9xxxx or EBxx90 */
- int8_t bsOEMName[8]; /* OEM name and version */
- int8_t bsPBP[53]; /* BIOS parameter block */
- int8_t bsExt[26]; /* Bootsector Extension */
- int8_t bsBootCode[418]; /* pad so structure is 512b */
- u_int8_t bsBootSectSig2; /* 2 & 3 are only defined for FAT32? */
- u_int8_t bsBootSectSig3;
- u_int8_t bsBootSectSig0;
- u_int8_t bsBootSectSig1;
-#define BOOTSIG0 0x55
-#define BOOTSIG1 0xaa
-#define BOOTSIG2 0
-#define BOOTSIG3 0
-};
-#ifdef atari
-/*
- * The boot sector on a gemdos fs is a little bit different from the msdos fs
- * format. Currently there is no need to declare a seperate structure, the
- * bootsector33 struct will do.
- */
-#if 0
-struct bootsec_atari {
- u_int8_t bsBranch[2]; /* branch inst if auto-boot */
- int8_t bsFiller[6]; /* anything or nothing */
- int8_t bsSerial[3]; /* serial no. for mediachange */
- int8_t bsBPB[19]; /* BIOS parameter block */
- int8_t bsBootCode[482]; /* pad so struct is 512b */
-};
-#endif
-#endif /* atari */
-
-union bootsector {
- struct bootsector33 bs33;
- struct bootsector50 bs50;
- struct bootsector710 bs710;
-};
-
-#if 0
-/*
- * Shorthand for fields in the bpb.
- */
-#define bsBytesPerSec bsBPB.bpbBytesPerSec
-#define bsSectPerClust bsBPB.bpbSectPerClust
-#define bsResSectors bsBPB.bpbResSectors
-#define bsFATS bsBPB.bpbFATS
-#define bsRootDirEnts bsBPB.bpbRootDirEnts
-#define bsSectors bsBPB.bpbSectors
-#define bsMedia bsBPB.bpbMedia
-#define bsFATsecs bsBPB.bpbFATsecs
-#define bsSectPerTrack bsBPB.bpbSectPerTrack
-#define bsHeads bsBPB.bpbHeads
-#define bsHiddenSecs bsBPB.bpbHiddenSecs
-#define bsHugeSectors bsBPB.bpbHugeSectors
-#endif
diff --git a/sys/fs/msdosfs/bpb.h b/sys/fs/msdosfs/bpb.h
deleted file mode 100644
index 88b9eefb859a..000000000000
--- a/sys/fs/msdosfs/bpb.h
+++ /dev/null
@@ -1,209 +0,0 @@
-/* $FreeBSD$ */
-/* $NetBSD: bpb.h,v 1.7 1997/11/17 15:36:24 ws Exp $ */
-
-/*
- * Written by Paul Popelka (paulp@uts.amdahl.com)
- *
- * You can do anything you want with this software, just don't say you wrote
- * it, and don't remove this notice.
- *
- * This software is provided "as is".
- *
- * The author supplies this software to be publicly redistributed on the
- * understanding that the author is not responsible for the correct
- * functioning of this software in any circumstances and is not liable for
- * any damages caused by this software.
- *
- * October 1992
- */
-
-/*
- * BIOS Parameter Block (BPB) for DOS 3.3
- */
-struct bpb33 {
- u_int16_t bpbBytesPerSec; /* bytes per sector */
- u_int8_t bpbSecPerClust; /* sectors per cluster */
- u_int16_t bpbResSectors; /* number of reserved sectors */
- u_int8_t bpbFATs; /* number of FATs */
- u_int16_t bpbRootDirEnts; /* number of root directory entries */
- u_int16_t bpbSectors; /* total number of sectors */
- u_int8_t bpbMedia; /* media descriptor */
- u_int16_t bpbFATsecs; /* number of sectors per FAT */
- u_int16_t bpbSecPerTrack; /* sectors per track */
- u_int16_t bpbHeads; /* number of heads */
- u_int16_t bpbHiddenSecs; /* number of hidden sectors */
-};
-
-/*
- * BPB for DOS 5.0 The difference is bpbHiddenSecs is a short for DOS 3.3,
- * and bpbHugeSectors is not in the 3.3 bpb.
- */
-struct bpb50 {
- u_int16_t bpbBytesPerSec; /* bytes per sector */
- u_int8_t bpbSecPerClust; /* sectors per cluster */
- u_int16_t bpbResSectors; /* number of reserved sectors */
- u_int8_t bpbFATs; /* number of FATs */
- u_int16_t bpbRootDirEnts; /* number of root directory entries */
- u_int16_t bpbSectors; /* total number of sectors */
- u_int8_t bpbMedia; /* media descriptor */
- u_int16_t bpbFATsecs; /* number of sectors per FAT */
- u_int16_t bpbSecPerTrack; /* sectors per track */
- u_int16_t bpbHeads; /* number of heads */
- u_int32_t bpbHiddenSecs; /* # of hidden sectors */
- u_int32_t bpbHugeSectors; /* # of sectors if bpbSectors == 0 */
-};
-
-/*
- * BPB for DOS 7.10 (FAT32). This one has a few extensions to bpb50.
- */
-struct bpb710 {
- u_int16_t bpbBytesPerSec; /* bytes per sector */
- u_int8_t bpbSecPerClust; /* sectors per cluster */
- u_int16_t bpbResSectors; /* number of reserved sectors */
- u_int8_t bpbFATs; /* number of FATs */
- u_int16_t bpbRootDirEnts; /* number of root directory entries */
- u_int16_t bpbSectors; /* total number of sectors */
- u_int8_t bpbMedia; /* media descriptor */
- u_int16_t bpbFATsecs; /* number of sectors per FAT */
- u_int16_t bpbSecPerTrack; /* sectors per track */
- u_int16_t bpbHeads; /* number of heads */
- u_int32_t bpbHiddenSecs; /* # of hidden sectors */
- u_int32_t bpbHugeSectors; /* # of sectors if bpbSectors == 0 */
- u_int32_t bpbBigFATsecs; /* like bpbFATsecs for FAT32 */
- u_int16_t bpbExtFlags; /* extended flags: */
-#define FATNUM 0xf /* mask for numbering active FAT */
-#define FATMIRROR 0x80 /* FAT is mirrored (like it always was) */
- u_int16_t bpbFSVers; /* filesystem version */
-#define FSVERS 0 /* currently only 0 is understood */
- u_int32_t bpbRootClust; /* start cluster for root directory */
- u_int16_t bpbFSInfo; /* filesystem info structure sector */
- u_int16_t bpbBackup; /* backup boot sector */
- /* There is a 12 byte filler here, but we ignore it */
-};
-
-#ifdef atari
-/*
- * BPB for gemdos filesystems. Atari leaves the obsolete stuff undefined.
- * Currently there is no need for a separate BPB structure.
- */
-#if 0
-struct bpb_a {
- u_int16_t bpbBytesPerSec; /* bytes per sector */
- u_int8_t bpbSecPerClust; /* sectors per cluster */
- u_int16_t bpbResSectors; /* number of reserved sectors */
- u_int8_t bpbFATs; /* number of FATs */
- u_int16_t bpbRootDirEnts; /* number of root directory entries */
- u_int16_t bpbSectors; /* total number of sectors */
- u_int8_t bpbUseless1; /* meaningless on gemdos fs */
- u_int16_t bpbFATsecs; /* number of sectors per FAT */
- u_int16_t bpbUseless2; /* meaningless for harddisk fs */
- u_int16_t bpbUseless3; /* meaningless for harddisk fs */
- u_int16_t bpbHiddenSecs; /* the TOS-BIOS ignores this */
-};
-#endif
-#endif /* atari */
-
-/*
- * The following structures represent how the bpb's look on disk. shorts
- * and longs are just character arrays of the appropriate length. This is
- * because the compiler forces shorts and longs to align on word or
- * halfword boundaries.
- *
- * XXX The little-endian code here assumes that the processor can access
- * 16-bit and 32-bit quantities on byte boundaries. If this is not true,
- * use the macros for the big-endian case.
- */
-#include <machine/endian.h>
-#if (BYTE_ORDER == LITTLE_ENDIAN) /* && defined(UNALIGNED_ACCESS) */
-#define getushort(x) *((u_int16_t *)(x))
-#define getulong(x) *((u_int32_t *)(x))
-#define putushort(p, v) (*((u_int16_t *)(p)) = (v))
-#define putulong(p, v) (*((u_int32_t *)(p)) = (v))
-#else
-#define getushort(x) (((u_int8_t *)(x))[0] + (((u_int8_t *)(x))[1] << 8))
-#define getulong(x) (((u_int8_t *)(x))[0] + (((u_int8_t *)(x))[1] << 8) \
- + (((u_int8_t *)(x))[2] << 16) \
- + (((u_int8_t *)(x))[3] << 24))
-#define putushort(p, v) (((u_int8_t *)(p))[0] = (v), \
- ((u_int8_t *)(p))[1] = (v) >> 8)
-#define putulong(p, v) (((u_int8_t *)(p))[0] = (v), \
- ((u_int8_t *)(p))[1] = (v) >> 8, \
- ((u_int8_t *)(p))[2] = (v) >> 16,\
- ((u_int8_t *)(p))[3] = (v) >> 24)
-#endif
-
-/*
- * BIOS Parameter Block (BPB) for DOS 3.3
- */
-struct byte_bpb33 {
- int8_t bpbBytesPerSec[2]; /* bytes per sector */
- int8_t bpbSecPerClust; /* sectors per cluster */
- int8_t bpbResSectors[2]; /* number of reserved sectors */
- int8_t bpbFATs; /* number of FATs */
- int8_t bpbRootDirEnts[2]; /* number of root directory entries */
- int8_t bpbSectors[2]; /* total number of sectors */
- int8_t bpbMedia; /* media descriptor */
- int8_t bpbFATsecs[2]; /* number of sectors per FAT */
- int8_t bpbSecPerTrack[2]; /* sectors per track */
- int8_t bpbHeads[2]; /* number of heads */
- int8_t bpbHiddenSecs[2]; /* number of hidden sectors */
-};
-
-/*
- * BPB for DOS 5.0 The difference is bpbHiddenSecs is a short for DOS 3.3,
- * and bpbHugeSectors is not in the 3.3 bpb.
- */
-struct byte_bpb50 {
- int8_t bpbBytesPerSec[2]; /* bytes per sector */
- int8_t bpbSecPerClust; /* sectors per cluster */
- int8_t bpbResSectors[2]; /* number of reserved sectors */
- int8_t bpbFATs; /* number of FATs */
- int8_t bpbRootDirEnts[2]; /* number of root directory entries */
- int8_t bpbSectors[2]; /* total number of sectors */
- int8_t bpbMedia; /* media descriptor */
- int8_t bpbFATsecs[2]; /* number of sectors per FAT */
- int8_t bpbSecPerTrack[2]; /* sectors per track */
- int8_t bpbHeads[2]; /* number of heads */
- int8_t bpbHiddenSecs[4]; /* number of hidden sectors */
- int8_t bpbHugeSectors[4]; /* # of sectors if bpbSectors == 0 */
-};
-
-/*
- * BPB for DOS 7.10 (FAT32). This one has a few extensions to bpb50.
- */
-struct byte_bpb710 {
- u_int8_t bpbBytesPerSec[2]; /* bytes per sector */
- u_int8_t bpbSecPerClust; /* sectors per cluster */
- u_int8_t bpbResSectors[2]; /* number of reserved sectors */
- u_int8_t bpbFATs; /* number of FATs */
- u_int8_t bpbRootDirEnts[2]; /* number of root directory entries */
- u_int8_t bpbSectors[2]; /* total number of sectors */
- u_int8_t bpbMedia; /* media descriptor */
- u_int8_t bpbFATsecs[2]; /* number of sectors per FAT */
- u_int8_t bpbSecPerTrack[2]; /* sectors per track */
- u_int8_t bpbHeads[2]; /* number of heads */
- u_int8_t bpbHiddenSecs[4]; /* # of hidden sectors */
- u_int8_t bpbHugeSectors[4]; /* # of sectors if bpbSectors == 0 */
- u_int8_t bpbBigFATsecs[4]; /* like bpbFATsecs for FAT32 */
- u_int8_t bpbExtFlags[2]; /* extended flags: */
- u_int8_t bpbFSVers[2]; /* filesystem version */
- u_int8_t bpbRootClust[4]; /* start cluster for root directory */
- u_int8_t bpbFSInfo[2]; /* filesystem info structure sector */
- u_int8_t bpbBackup[2]; /* backup boot sector */
- /* There is a 12 byte filler here, but we ignore it */
-};
-
-/*
- * FAT32 FSInfo block.
- */
-struct fsinfo {
- u_int8_t fsisig1[4];
- u_int8_t fsifill1[480];
- u_int8_t fsisig2[4];
- u_int8_t fsinfree[4];
- u_int8_t fsinxtfree[4];
- u_int8_t fsifill2[12];
- u_int8_t fsisig3[4];
- u_int8_t fsifill3[508];
- u_int8_t fsisig4[4];
-};
diff --git a/sys/fs/msdosfs/denode.h b/sys/fs/msdosfs/denode.h
deleted file mode 100644
index f57e014ef1df..000000000000
--- a/sys/fs/msdosfs/denode.h
+++ /dev/null
@@ -1,286 +0,0 @@
-/* $FreeBSD$ */
-/* $NetBSD: denode.h,v 1.25 1997/11/17 15:36:28 ws Exp $ */
-
-/*-
- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
- * Copyright (C) 1994, 1995, 1997 TooLs GmbH.
- * All rights reserved.
- * Original code by Paul Popelka (paulp@uts.amdahl.com) (see below).
- *
- * 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 TooLs GmbH.
- * 4. The name of TooLs GmbH may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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.
- */
-/*
- * Written by Paul Popelka (paulp@uts.amdahl.com)
- *
- * You can do anything you want with this software, just don't say you wrote
- * it, and don't remove this notice.
- *
- * This software is provided "as is".
- *
- * The author supplies this software to be publicly redistributed on the
- * understanding that the author is not responsible for the correct
- * functioning of this software in any circumstances and is not liable for
- * any damages caused by this software.
- *
- * October 1992
- */
-
-/*
- * This is the pc filesystem specific portion of the vnode structure.
- *
- * To describe a file uniquely the de_dirclust, de_diroffset, and
- * de_StartCluster fields are used.
- *
- * de_dirclust contains the cluster number of the directory cluster
- * containing the entry for a file or directory.
- * de_diroffset is the index into the cluster for the entry describing
- * a file or directory.
- * de_StartCluster is the number of the first cluster of the file or directory.
- *
- * Now to describe the quirks of the pc filesystem.
- * - Clusters 0 and 1 are reserved.
- * - The first allocatable cluster is 2.
- * - The root directory is of fixed size and all blocks that make it up
- * are contiguous.
- * - Cluster 0 refers to the root directory when it is found in the
- * startcluster field of a directory entry that points to another directory.
- * - Cluster 0 implies a 0 length file when found in the start cluster field
- * of a directory entry that points to a file.
- * - You can't use the cluster number 0 to derive the address of the root
- * directory.
- * - Multiple directory entries can point to a directory. The entry in the
- * parent directory points to a child directory. Any directories in the
- * child directory contain a ".." entry that points back to the parent.
- * The child directory itself contains a "." entry that points to itself.
- * - The root directory does not contain a "." or ".." entry.
- * - Directory entries for directories are never changed once they are created
- * (except when removed). The size stays 0, and the last modification time
- * is never changed. This is because so many directory entries can point to
- * the physical clusters that make up a directory. It would lead to an
- * update nightmare.
- * - The length field in a directory entry pointing to a directory contains 0
- * (always). The only way to find the end of a directory is to follow the
- * cluster chain until the "last cluster" marker is found.
- *
- * My extensions to make this house of cards work. These apply only to the in
- * memory copy of the directory entry.
- * - A reference count for each denode will be kept since dos doesn't keep such
- * things.
- */
-
-/*
- * Internal pseudo-offset for (nonexistent) directory entry for the root
- * dir in the root dir
- */
-#define MSDOSFSROOT_OFS 0x1fffffff
-
-/*
- * The fat cache structure. fc_fsrcn is the filesystem relative cluster
- * number that corresponds to the file relative cluster number in this
- * structure (fc_frcn).
- */
-struct fatcache {
- u_long fc_frcn; /* file relative cluster number */
- u_long fc_fsrcn; /* filesystem relative cluster number */
-};
-
-/*
- * The fat entry cache as it stands helps make extending files a "quick"
- * operation by avoiding having to scan the fat to discover the last
- * cluster of the file. The cache also helps sequential reads by
- * remembering the last cluster read from the file. This also prevents us
- * from having to rescan the fat to find the next cluster to read. This
- * cache is probably pretty worthless if a file is opened by multiple
- * processes.
- */
-#define FC_SIZE 2 /* number of entries in the cache */
-#define FC_LASTMAP 0 /* entry the last call to pcbmap() resolved
- * to */
-#define FC_LASTFC 1 /* entry for the last cluster in the file */
-
-#define FCE_EMPTY 0xffffffff /* doesn't represent an actual cluster # */
-
-/*
- * Set a slot in the fat cache.
- */
-#define fc_setcache(dep, slot, frcn, fsrcn) \
- (dep)->de_fc[slot].fc_frcn = frcn; \
- (dep)->de_fc[slot].fc_fsrcn = fsrcn;
-
-/*
- * This is the in memory variant of a dos directory entry. It is usually
- * contained within a vnode.
- */
-struct denode {
- struct lock de_lock; /* denode lock >Keep this first< */
- struct denode *de_next; /* Hash chain forward */
- struct denode **de_prev; /* Hash chain back */
- struct vnode *de_vnode; /* addr of vnode we are part of */
- struct vnode *de_devvp; /* vnode of blk dev we live on */
- u_long de_flag; /* flag bits */
- dev_t de_dev; /* device where direntry lives */
- u_long de_dirclust; /* cluster of the directory file containing this entry */
- u_long de_diroffset; /* offset of this entry in the directory cluster */
- u_long de_fndoffset; /* offset of found dir entry */
- int de_fndcnt; /* number of slots before de_fndoffset */
- long de_refcnt; /* reference count */
- struct msdosfsmount *de_pmp; /* addr of our mount struct */
- u_char de_Name[12]; /* name, from DOS directory entry */
- u_char de_Attributes; /* attributes, from directory entry */
- u_char de_LowerCase; /* NT VFAT lower case flags */
- u_char de_CHun; /* Hundredth of second of CTime*/
- u_short de_CTime; /* creation time */
- u_short de_CDate; /* creation date */
- u_short de_ADate; /* access date */
- u_short de_MTime; /* modification time */
- u_short de_MDate; /* modification date */
- u_long de_StartCluster; /* starting cluster of file */
- u_long de_FileSize; /* size of file in bytes */
- struct fatcache de_fc[FC_SIZE]; /* fat cache */
- u_quad_t de_modrev; /* Revision level for lease. */
-};
-
-/*
- * Values for the de_flag field of the denode.
- */
-#define DE_UPDATE 0x0004 /* Modification time update request */
-#define DE_CREATE 0x0008 /* Creation time update */
-#define DE_ACCESS 0x0010 /* Access time update */
-#define DE_MODIFIED 0x0020 /* Denode has been modified */
-#define DE_RENAME 0x0040 /* Denode is in the process of being renamed */
-
-
-/*
- * Transfer directory entries between internal and external form.
- * dep is a struct denode * (internal form),
- * dp is a struct direntry * (external form).
- */
-#define DE_INTERNALIZE32(dep, dp) \
- ((dep)->de_StartCluster |= getushort((dp)->deHighClust) << 16)
-#define DE_INTERNALIZE(dep, dp) \
- (bcopy((dp)->deName, (dep)->de_Name, 11), \
- (dep)->de_Attributes = (dp)->deAttributes, \
- (dep)->de_LowerCase = (dp)->deLowerCase, \
- (dep)->de_CHun = (dp)->deCHundredth, \
- (dep)->de_CTime = getushort((dp)->deCTime), \
- (dep)->de_CDate = getushort((dp)->deCDate), \
- (dep)->de_ADate = getushort((dp)->deADate), \
- (dep)->de_MTime = getushort((dp)->deMTime), \
- (dep)->de_MDate = getushort((dp)->deMDate), \
- (dep)->de_StartCluster = getushort((dp)->deStartCluster), \
- (dep)->de_FileSize = getulong((dp)->deFileSize), \
- (FAT32((dep)->de_pmp) ? DE_INTERNALIZE32((dep), (dp)) : 0))
-
-#define DE_EXTERNALIZE(dp, dep) \
- (bcopy((dep)->de_Name, (dp)->deName, 11), \
- (dp)->deAttributes = (dep)->de_Attributes, \
- (dp)->deLowerCase = (dep)->de_LowerCase, \
- (dp)->deCHundredth = (dep)->de_CHun, \
- putushort((dp)->deCTime, (dep)->de_CTime), \
- putushort((dp)->deCDate, (dep)->de_CDate), \
- putushort((dp)->deADate, (dep)->de_ADate), \
- putushort((dp)->deMTime, (dep)->de_MTime), \
- putushort((dp)->deMDate, (dep)->de_MDate), \
- putushort((dp)->deStartCluster, (dep)->de_StartCluster), \
- putulong((dp)->deFileSize, \
- ((dep)->de_Attributes & ATTR_DIRECTORY) ? 0 : (dep)->de_FileSize), \
- putushort((dp)->deHighClust, (dep)->de_StartCluster >> 16))
-
-#define de_forw de_chain[0]
-#define de_back de_chain[1]
-
-#ifdef _KERNEL
-
-#define VTODE(vp) ((struct denode *)(vp)->v_data)
-#define DETOV(de) ((de)->de_vnode)
-
-#define DETIMES(dep, acc, mod, cre) do { \
- if ((dep)->de_flag & DE_UPDATE) { \
- (dep)->de_flag |= DE_MODIFIED; \
- unix2dostime((mod), &(dep)->de_MDate, &(dep)->de_MTime, \
- NULL); \
- (dep)->de_Attributes |= ATTR_ARCHIVE; \
- } \
- if ((dep)->de_pmp->pm_flags & MSDOSFSMNT_NOWIN95) { \
- (dep)->de_flag &= ~(DE_UPDATE | DE_CREATE | DE_ACCESS); \
- break; \
- } \
- if ((dep)->de_flag & DE_ACCESS) { \
- u_int16_t adate; \
- \
- unix2dostime((acc), &adate, NULL, NULL); \
- if (adate != (dep)->de_ADate) { \
- (dep)->de_flag |= DE_MODIFIED; \
- (dep)->de_ADate = adate; \
- } \
- } \
- if ((dep)->de_flag & DE_CREATE) { \
- unix2dostime((cre), &(dep)->de_CDate, &(dep)->de_CTime, \
- &(dep)->de_CHun); \
- (dep)->de_flag |= DE_MODIFIED; \
- } \
- (dep)->de_flag &= ~(DE_UPDATE | DE_CREATE | DE_ACCESS); \
-} while (0);
-
-/*
- * This overlays the fid structure (see mount.h)
- */
-struct defid {
- u_short defid_len; /* length of structure */
- u_short defid_pad; /* force long alignment */
-
- u_long defid_dirclust; /* cluster this dir entry came from */
- u_long defid_dirofs; /* offset of entry within the cluster */
-#if 0
- u_long defid_gen; /* generation number */
-#endif
-};
-
-extern vop_t **msdosfs_vnodeop_p;
-
-int msdosfs_lookup __P((struct vop_cachedlookup_args *));
-int msdosfs_inactive __P((struct vop_inactive_args *));
-int msdosfs_reclaim __P((struct vop_reclaim_args *));
-
-/*
- * Internal service routine prototypes.
- */
-int deget __P((struct msdosfsmount *, u_long, u_long, struct denode **));
-int uniqdosname __P((struct denode *, struct componentname *, u_char *));
-int findwin95 __P((struct denode *));
-
-int readep __P((struct msdosfsmount *pmp, u_long dirclu, u_long dirofs, struct buf **bpp, struct direntry **epp));
-int readde __P((struct denode *dep, struct buf **bpp, struct direntry **epp));
-int deextend __P((struct denode *dep, u_long length, struct ucred *cred));
-int fillinusemap __P((struct msdosfsmount *pmp));
-void reinsert __P((struct denode *dep));
-int dosdirempty __P((struct denode *dep));
-int createde __P((struct denode *dep, struct denode *ddep, struct denode **depp, struct componentname *cnp));
-int deupdat __P((struct denode *dep, int waitfor));
-int removede __P((struct denode *pdep, struct denode *dep));
-int detrunc __P((struct denode *dep, u_long length, int flags, struct ucred *cred, struct proc *p));
-int doscheckpath __P(( struct denode *source, struct denode *target));
-#endif /* _KERNEL */
diff --git a/sys/fs/msdosfs/direntry.h b/sys/fs/msdosfs/direntry.h
deleted file mode 100644
index fccf58b53ff3..000000000000
--- a/sys/fs/msdosfs/direntry.h
+++ /dev/null
@@ -1,143 +0,0 @@
-/* $FreeBSD$ */
-/* $NetBSD: direntry.h,v 1.14 1997/11/17 15:36:32 ws Exp $ */
-
-/*-
- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
- * Copyright (C) 1994, 1995, 1997 TooLs GmbH.
- * All rights reserved.
- * Original code by Paul Popelka (paulp@uts.amdahl.com) (see below).
- *
- * 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 TooLs GmbH.
- * 4. The name of TooLs GmbH may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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.
- */
-/*
- * Written by Paul Popelka (paulp@uts.amdahl.com)
- *
- * You can do anything you want with this software, just don't say you wrote
- * it, and don't remove this notice.
- *
- * This software is provided "as is".
- *
- * The author supplies this software to be publicly redistributed on the
- * understanding that the author is not responsible for the correct
- * functioning of this software in any circumstances and is not liable for
- * any damages caused by this software.
- *
- * October 1992
- */
-
-/*
- * Structure of a dos directory entry.
- */
-struct direntry {
- u_int8_t deName[8]; /* filename, blank filled */
-#define SLOT_EMPTY 0x00 /* slot has never been used */
-#define SLOT_E5 0x05 /* the real value is 0xe5 */
-#define SLOT_DELETED 0xe5 /* file in this slot deleted */
- u_int8_t deExtension[3]; /* extension, blank filled */
- u_int8_t deAttributes; /* file attributes */
-#define ATTR_NORMAL 0x00 /* normal file */
-#define ATTR_READONLY 0x01 /* file is readonly */
-#define ATTR_HIDDEN 0x02 /* file is hidden */
-#define ATTR_SYSTEM 0x04 /* file is a system file */
-#define ATTR_VOLUME 0x08 /* entry is a volume label */
-#define ATTR_DIRECTORY 0x10 /* entry is a directory name */
-#define ATTR_ARCHIVE 0x20 /* file is new or modified */
- u_int8_t deLowerCase; /* NT VFAT lower case flags */
-#define LCASE_BASE 0x08 /* filename base in lower case */
-#define LCASE_EXT 0x10 /* filename extension in lower case */
- u_int8_t deCHundredth; /* hundredth of seconds in CTime */
- u_int8_t deCTime[2]; /* create time */
- u_int8_t deCDate[2]; /* create date */
- u_int8_t deADate[2]; /* access date */
- u_int8_t deHighClust[2]; /* high bytes of cluster number */
- u_int8_t deMTime[2]; /* last update time */
- u_int8_t deMDate[2]; /* last update date */
- u_int8_t deStartCluster[2]; /* starting cluster of file */
- u_int8_t deFileSize[4]; /* size of file in bytes */
-};
-
-/*
- * Structure of a Win95 long name directory entry
- */
-struct winentry {
- u_int8_t weCnt;
-#define WIN_LAST 0x40
-#define WIN_CNT 0x3f
- u_int8_t wePart1[10];
- u_int8_t weAttributes;
-#define ATTR_WIN95 0x0f
- u_int8_t weReserved1;
- u_int8_t weChksum;
- u_int8_t wePart2[12];
- u_int16_t weReserved2;
- u_int8_t wePart3[4];
-};
-#define WIN_CHARS 13 /* Number of chars per winentry */
-
-/*
- * Maximum filename length in Win95
- * Note: Must be < sizeof(dirent.d_name)
- */
-#define WIN_MAXLEN 255
-
-/*
- * This is the format of the contents of the deTime field in the direntry
- * structure.
- * We don't use bitfields because we don't know how compilers for
- * arbitrary machines will lay them out.
- */
-#define DT_2SECONDS_MASK 0x1F /* seconds divided by 2 */
-#define DT_2SECONDS_SHIFT 0
-#define DT_MINUTES_MASK 0x7E0 /* minutes */
-#define DT_MINUTES_SHIFT 5
-#define DT_HOURS_MASK 0xF800 /* hours */
-#define DT_HOURS_SHIFT 11
-
-/*
- * This is the format of the contents of the deDate field in the direntry
- * structure.
- */
-#define DD_DAY_MASK 0x1F /* day of month */
-#define DD_DAY_SHIFT 0
-#define DD_MONTH_MASK 0x1E0 /* month */
-#define DD_MONTH_SHIFT 5
-#define DD_YEAR_MASK 0xFE00 /* year - 1980 */
-#define DD_YEAR_SHIFT 9
-
-#ifdef _KERNEL
-struct dirent;
-void unix2dostime __P((struct timespec *tsp, u_int16_t *ddp,
- u_int16_t *dtp, u_int8_t *dhp));
-void dos2unixtime __P((u_int dd, u_int dt, u_int dh, struct timespec *tsp));
-int dos2unixfn __P((u_char dn[11], u_char *un, int lower, int d2u_loaded, u_int8_t *d2u, int ul_loaded, u_int8_t *ul));
-int unix2dosfn __P((const u_char *un, u_char dn[12], int unlen, u_int gen, int u2d_loaded, u_int8_t *u2d, int lu_loaded, u_int8_t *lu));
-int unix2winfn __P((const u_char *un, int unlen, struct winentry *wep, int cnt, int chksum, int table_loaded, u_int16_t *u2w));
-int winChkName __P((const u_char *un, int unlen, struct winentry *wep, int chksum, int u2w_loaded, u_int16_t *u2w, int ul_loaded, u_int8_t *ul));
-int win2unixfn __P((struct winentry *wep, struct dirent *dp, int chksum, int table_loaded, u_int16_t *u2w));
-u_int8_t winChksum __P((u_int8_t *name));
-int winSlotCnt __P((const u_char *un, int unlen));
-int winLenFixup __P((const u_char *un, int unlen));
-#endif /* _KERNEL */
diff --git a/sys/fs/msdosfs/fat.h b/sys/fs/msdosfs/fat.h
deleted file mode 100644
index 7dd5bbfffd74..000000000000
--- a/sys/fs/msdosfs/fat.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/* $FreeBSD$ */
-/* $NetBSD: fat.h,v 1.12 1997/11/17 15:36:36 ws Exp $ */
-
-/*-
- * Copyright (C) 1994, 1997 Wolfgang Solfrank.
- * Copyright (C) 1994, 1997 TooLs GmbH.
- * All rights reserved.
- * Original code by Paul Popelka (paulp@uts.amdahl.com) (see below).
- *
- * 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 TooLs GmbH.
- * 4. The name of TooLs GmbH may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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.
- */
-/*
- * Written by Paul Popelka (paulp@uts.amdahl.com)
- *
- * You can do anything you want with this software, just don't say you wrote
- * it, and don't remove this notice.
- *
- * This software is provided "as is".
- *
- * The author supplies this software to be publicly redistributed on the
- * understanding that the author is not responsible for the correct
- * functioning of this software in any circumstances and is not liable for
- * any damages caused by this software.
- *
- * October 1992
- */
-
-/*
- * Some useful cluster numbers.
- */
-#define MSDOSFSROOT 0 /* cluster 0 means the root dir */
-#define CLUST_FREE 0 /* cluster 0 also means a free cluster */
-#define MSDOSFSFREE CLUST_FREE
-#define CLUST_FIRST 2 /* first legal cluster number */
-#define CLUST_RSRVD 0xfffffff6 /* reserved cluster range */
-#define CLUST_BAD 0xfffffff7 /* a cluster with a defect */
-#define CLUST_EOFS 0xfffffff8 /* start of eof cluster range */
-#define CLUST_EOFE 0xffffffff /* end of eof cluster range */
-
-#define FAT12_MASK 0x00000fff /* mask for 12 bit cluster numbers */
-#define FAT16_MASK 0x0000ffff /* mask for 16 bit cluster numbers */
-#define FAT32_MASK 0x0fffffff /* mask for FAT32 cluster numbers */
-
-/*
- * MSDOSFS:
- * Return true if filesystem uses 12 bit fats. Microsoft Programmer's
- * Reference says if the maximum cluster number in a filesystem is greater
- * than 4078 ((CLUST_RSRVS - CLUST_FIRST) & FAT12_MASK) then we've got a
- * 16 bit fat filesystem. While mounting, the result of this test is stored
- * in pm_fatentrysize.
- * GEMDOS-flavour (atari):
- * If the filesystem is on floppy we've got a 12 bit fat filesystem, otherwise
- * 16 bit. We check the d_type field in the disklabel struct while mounting
- * and store the result in the pm_fatentrysize. Note that this kind of
- * detection gets flakey when mounting a vnd-device.
- */
-#define FAT12(pmp) (pmp->pm_fatmask == FAT12_MASK)
-#define FAT16(pmp) (pmp->pm_fatmask == FAT16_MASK)
-#define FAT32(pmp) (pmp->pm_fatmask == FAT32_MASK)
-
-#define MSDOSFSEOF(pmp, cn) ((((cn) | ~(pmp)->pm_fatmask) & CLUST_EOFS) == CLUST_EOFS)
-
-#ifdef _KERNEL
-/*
- * These are the values for the function argument to the function
- * fatentry().
- */
-#define FAT_GET 0x0001 /* get a fat entry */
-#define FAT_SET 0x0002 /* set a fat entry */
-#define FAT_GET_AND_SET (FAT_GET | FAT_SET)
-
-/*
- * Flags to extendfile:
- */
-#define DE_CLEAR 1 /* Zero out the blocks allocated */
-
-int pcbmap __P((struct denode *dep, u_long findcn, daddr_t *bnp, u_long *cnp, int* sp));
-int clusterfree __P((struct msdosfsmount *pmp, u_long cn, u_long *oldcnp));
-int clusteralloc __P((struct msdosfsmount *pmp, u_long start, u_long count, u_long fillwith, u_long *retcluster, u_long *got));
-int fatentry __P((int function, struct msdosfsmount *pmp, u_long cluster, u_long *oldcontents, u_long newcontents));
-int freeclusterchain __P((struct msdosfsmount *pmp, u_long startchain));
-int extendfile __P((struct denode *dep, u_long count, struct buf **bpp, u_long *ncp, int flags));
-void fc_purge __P((struct denode *dep, u_int frcn));
-
-#endif /* _KERNEL */
diff --git a/sys/fs/msdosfs/msdosfs_conv.c b/sys/fs/msdosfs/msdosfs_conv.c
deleted file mode 100644
index 8c43f93c0adc..000000000000
--- a/sys/fs/msdosfs/msdosfs_conv.c
+++ /dev/null
@@ -1,1041 +0,0 @@
-/* $FreeBSD$ */
-/* $NetBSD: msdosfs_conv.c,v 1.25 1997/11/17 15:36:40 ws Exp $ */
-
-/*-
- * Copyright (C) 1995, 1997 Wolfgang Solfrank.
- * Copyright (C) 1995, 1997 TooLs GmbH.
- * All rights reserved.
- * Original code by Paul Popelka (paulp@uts.amdahl.com) (see below).
- *
- * 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 TooLs GmbH.
- * 4. The name of TooLs GmbH may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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.
- */
-/*
- * Written by Paul Popelka (paulp@uts.amdahl.com)
- *
- * You can do anything you want with this software, just don't say you wrote
- * it, and don't remove this notice.
- *
- * This software is provided "as is".
- *
- * The author supplies this software to be publicly redistributed on the
- * understanding that the author is not responsible for the correct
- * functioning of this software in any circumstances and is not liable for
- * any damages caused by this software.
- *
- * October 1992
- */
-
-/*
- * System include files.
- */
-#include <sys/param.h>
-#include <sys/time.h>
-#include <sys/kernel.h> /* defines tz */
-#include <sys/systm.h>
-#include <machine/clock.h>
-#include <sys/dirent.h>
-
-/*
- * MSDOSFS include files.
- */
-#include <msdosfs/direntry.h>
-
-/*
- * Total number of days that have passed for each month in a regular year.
- */
-static u_short regyear[] = {
- 31, 59, 90, 120, 151, 181,
- 212, 243, 273, 304, 334, 365
-};
-
-/*
- * Total number of days that have passed for each month in a leap year.
- */
-static u_short leapyear[] = {
- 31, 60, 91, 121, 152, 182,
- 213, 244, 274, 305, 335, 366
-};
-
-/*
- * Variables used to remember parts of the last time conversion. Maybe we
- * can avoid a full conversion.
- */
-static u_long lasttime;
-static u_long lastday;
-static u_short lastddate;
-static u_short lastdtime;
-
-static __inline u_int8_t find_lcode __P((u_int16_t code, u_int16_t *u2w));
-
-/*
- * Convert the unix version of time to dos's idea of time to be used in
- * file timestamps. The passed in unix time is assumed to be in GMT.
- */
-void
-unix2dostime(tsp, ddp, dtp, dhp)
- struct timespec *tsp;
- u_int16_t *ddp;
- u_int16_t *dtp;
- u_int8_t *dhp;
-{
- u_long t;
- u_long days;
- u_long inc;
- u_long year;
- u_long month;
- u_short *months;
-
- /*
- * If the time from the last conversion is the same as now, then
- * skip the computations and use the saved result.
- */
- t = tsp->tv_sec - (tz.tz_minuteswest * 60)
- - (wall_cmos_clock ? adjkerntz : 0);
- /* - daylight savings time correction */
- t &= ~1;
- if (lasttime != t) {
- lasttime = t;
- lastdtime = (((t / 2) % 30) << DT_2SECONDS_SHIFT)
- + (((t / 60) % 60) << DT_MINUTES_SHIFT)
- + (((t / 3600) % 24) << DT_HOURS_SHIFT);
-
- /*
- * If the number of days since 1970 is the same as the last
- * time we did the computation then skip all this leap year
- * and month stuff.
- */
- days = t / (24 * 60 * 60);
- if (days != lastday) {
- lastday = days;
- for (year = 1970;; year++) {
- inc = year & 0x03 ? 365 : 366;
- if (days < inc)
- break;
- days -= inc;
- }
- months = year & 0x03 ? regyear : leapyear;
- for (month = 0; days >= months[month]; month++)
- ;
- if (month > 0)
- days -= months[month - 1];
- lastddate = ((days + 1) << DD_DAY_SHIFT)
- + ((month + 1) << DD_MONTH_SHIFT);
- /*
- * Remember dos's idea of time is relative to 1980.
- * unix's is relative to 1970. If somehow we get a
- * time before 1980 then don't give totally crazy
- * results.
- */
- if (year > 1980)
- lastddate += (year - 1980) << DD_YEAR_SHIFT;
- }
- }
- if (dtp)
- *dtp = lastdtime;
- if (dhp)
- *dhp = (tsp->tv_sec & 1) * 100 + tsp->tv_nsec / 10000000;
-
- *ddp = lastddate;
-}
-
-/*
- * The number of seconds between Jan 1, 1970 and Jan 1, 1980. In that
- * interval there were 8 regular years and 2 leap years.
- */
-#define SECONDSTO1980 (((8 * 365) + (2 * 366)) * (24 * 60 * 60))
-
-static u_short lastdosdate;
-static u_long lastseconds;
-
-/*
- * Convert from dos' idea of time to unix'. This will probably only be
- * called from the stat(), and fstat() system calls and so probably need
- * not be too efficient.
- */
-void
-dos2unixtime(dd, dt, dh, tsp)
- u_int dd;
- u_int dt;
- u_int dh;
- struct timespec *tsp;
-{
- u_long seconds;
- u_long month;
- u_long year;
- u_long days;
- u_short *months;
-
- if (dd == 0) {
- /*
- * Uninitialized field, return the epoch.
- */
- tsp->tv_sec = 0;
- tsp->tv_nsec = 0;
- return;
- }
- seconds = (((dt & DT_2SECONDS_MASK) >> DT_2SECONDS_SHIFT) << 1)
- + ((dt & DT_MINUTES_MASK) >> DT_MINUTES_SHIFT) * 60
- + ((dt & DT_HOURS_MASK) >> DT_HOURS_SHIFT) * 3600
- + dh / 100;
- /*
- * If the year, month, and day from the last conversion are the
- * same then use the saved value.
- */
- if (lastdosdate != dd) {
- lastdosdate = dd;
- days = 0;
- year = (dd & DD_YEAR_MASK) >> DD_YEAR_SHIFT;
- days = year * 365;
- days += year / 4 + 1; /* add in leap days */
- if ((year & 0x03) == 0)
- days--; /* if year is a leap year */
- months = year & 0x03 ? regyear : leapyear;
- month = (dd & DD_MONTH_MASK) >> DD_MONTH_SHIFT;
- if (month < 1 || month > 12) {
- printf("dos2unixtime(): month value out of range (%ld)\n",
- month);
- month = 1;
- }
- if (month > 1)
- days += months[month - 2];
- days += ((dd & DD_DAY_MASK) >> DD_DAY_SHIFT) - 1;
- lastseconds = (days * 24 * 60 * 60) + SECONDSTO1980;
- }
- tsp->tv_sec = seconds + lastseconds + (tz.tz_minuteswest * 60)
- + adjkerntz;
- /* + daylight savings time correction */
- tsp->tv_nsec = (dh % 100) * 10000000;
-}
-
-/*
- * 0 - character disallowed in long file name.
- * 1 - character should be replaced by '_' in DOS file name,
- * and generation number inserted.
- * 2 - character ('.' and ' ') should be skipped in DOS file name,
- * and generation number inserted.
- */
-static u_char
-unix2dos[256] = {
- 0, 0, 0, 0, 0, 0, 0, 0, /* 00-07 */
- 0, 0, 0, 0, 0, 0, 0, 0, /* 08-0f */
- 0, 0, 0, 0, 0, 0, 0, 0, /* 10-17 */
- 0, 0, 0, 0, 0, 0, 0, 0, /* 18-1f */
- 2, 0x21, 0, 0x23, 0x24, 0x25, 0x26, 0x27, /* 20-27 */
- 0x28, 0x29, 0, 1, 1, 0x2d, 2, 0, /* 28-2f */
- 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 30-37 */
- 0x38, 0x39, 0, 1, 0, 1, 0, 0, /* 38-3f */
- 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* 40-47 */
- 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, /* 48-4f */
- 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, /* 50-57 */
- 0x58, 0x59, 0x5a, 1, 0, 1, 0x5e, 0x5f, /* 58-5f */
- 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* 60-67 */
- 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, /* 68-6f */
- 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, /* 70-77 */
- 0x58, 0x59, 0x5a, 0x7b, 0, 0x7d, 0x7e, 0, /* 78-7f */
- 0, 0, 0, 0, 0, 0, 0, 0, /* 80-87 */
- 0, 0, 0, 0, 0, 0, 0, 0, /* 88-8f */
- 0, 0, 0, 0, 0, 0, 0, 0, /* 90-97 */
- 0, 0, 0, 0, 0, 0, 0, 0, /* 98-9f */
- 0, 0xad, 0xbd, 0x9c, 0xcf, 0xbe, 0xdd, 0xf5, /* a0-a7 */
- 0xf9, 0xb8, 0xa6, 0xae, 0xaa, 0xf0, 0xa9, 0xee, /* a8-af */
- 0xf8, 0xf1, 0xfd, 0xfc, 0xef, 0xe6, 0xf4, 0xfa, /* b0-b7 */
- 0xf7, 0xfb, 0xa7, 0xaf, 0xac, 0xab, 0xf3, 0xa8, /* b8-bf */
- 0xb7, 0xb5, 0xb6, 0xc7, 0x8e, 0x8f, 0x92, 0x80, /* c0-c7 */
- 0xd4, 0x90, 0xd2, 0xd3, 0xde, 0xd6, 0xd7, 0xd8, /* c8-cf */
- 0xd1, 0xa5, 0xe3, 0xe0, 0xe2, 0xe5, 0x99, 0x9e, /* d0-d7 */
- 0x9d, 0xeb, 0xe9, 0xea, 0x9a, 0xed, 0xe8, 0xe1, /* d8-df */
- 0xb7, 0xb5, 0xb6, 0xc7, 0x8e, 0x8f, 0x92, 0x80, /* e0-e7 */
- 0xd4, 0x90, 0xd2, 0xd3, 0xde, 0xd6, 0xd7, 0xd8, /* e8-ef */
- 0xd1, 0xa5, 0xe3, 0xe0, 0xe2, 0xe5, 0x99, 0xf6, /* f0-f7 */
- 0x9d, 0xeb, 0xe9, 0xea, 0x9a, 0xed, 0xe8, 0x98, /* f8-ff */
-};
-
-static u_char
-dos2unix[256] = {
- 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, /* 00-07 */
- 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, /* 08-0f */
- 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, /* 10-17 */
- 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, /* 18-1f */
- 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, /* 20-27 */
- 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, /* 28-2f */
- 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 30-37 */
- 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, /* 38-3f */
- 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* 40-47 */
- 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, /* 48-4f */
- 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, /* 50-57 */
- 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, /* 58-5f */
- 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 60-67 */
- 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, /* 68-6f */
- 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /* 70-77 */
- 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, /* 78-7f */
- 0xc7, 0xfc, 0xe9, 0xe2, 0xe4, 0xe0, 0xe5, 0xe7, /* 80-87 */
- 0xea, 0xeb, 0xe8, 0xef, 0xee, 0xec, 0xc4, 0xc5, /* 88-8f */
- 0xc9, 0xe6, 0xc6, 0xf4, 0xf6, 0xf2, 0xfb, 0xf9, /* 90-97 */
- 0xff, 0xd6, 0xdc, 0xf8, 0xa3, 0xd8, 0xd7, 0x3f, /* 98-9f */
- 0xe1, 0xed, 0xf3, 0xfa, 0xf1, 0xd1, 0xaa, 0xba, /* a0-a7 */
- 0xbf, 0xae, 0xac, 0xbd, 0xbc, 0xa1, 0xab, 0xbb, /* a8-af */
- 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0xc1, 0xc2, 0xc0, /* b0-b7 */
- 0xa9, 0x3f, 0x3f, 0x3f, 0x3f, 0xa2, 0xa5, 0x3f, /* b8-bf */
- 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0xe3, 0xc3, /* c0-c7 */
- 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0xa4, /* c8-cf */
- 0xf0, 0xd0, 0xca, 0xcb, 0xc8, 0x3f, 0xcd, 0xce, /* d0-d7 */
- 0xcf, 0x3f, 0x3f, 0x3f, 0x3f, 0xa6, 0xcc, 0x3f, /* d8-df */
- 0xd3, 0xdf, 0xd4, 0xd2, 0xf5, 0xd5, 0xb5, 0xfe, /* e0-e7 */
- 0xde, 0xda, 0xdb, 0xd9, 0xfd, 0xdd, 0xaf, 0x3f, /* e8-ef */
- 0xad, 0xb1, 0x3f, 0xbe, 0xb6, 0xa7, 0xf7, 0xb8, /* f0-f7 */
- 0xb0, 0xa8, 0xb7, 0xb9, 0xb3, 0xb2, 0x3f, 0x3f, /* f8-ff */
-};
-
-static u_char
-u2l[256] = {
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 00-07 */
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 08-0f */
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 10-17 */
- 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* 18-1f */
- 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, /* 20-27 */
- 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, /* 28-2f */
- 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 30-37 */
- 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, /* 38-3f */
- 0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 40-47 */
- 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, /* 48-4f */
- 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /* 50-57 */
- 0x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, /* 58-5f */
- 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 60-67 */
- 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, /* 68-6f */
- 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /* 70-77 */
- 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, /* 78-7f */
- 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 80-87 */
- 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, /* 88-8f */
- 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, /* 90-97 */
- 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, /* 98-9f */
- 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, /* a0-a7 */
- 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, /* a8-af */
- 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, /* b0-b7 */
- 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, /* b8-bf */
- 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* c0-c7 */
- 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* c8-cf */
- 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xd7, /* d0-d7 */
- 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xdf, /* d8-df */
- 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* e0-e7 */
- 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* e8-ef */
- 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* f0-f7 */
- 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, /* f8-ff */
-};
-
-static u_char
-l2u[256] = {
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 00-07 */
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 08-0f */
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 10-17 */
- 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* 18-1f */
- 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, /* 20-27 */
- 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, /* 28-2f */
- 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 30-37 */
- 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, /* 38-3f */
- 0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 40-47 */
- 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, /* 48-4f */
- 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /* 50-57 */
- 0x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, /* 58-5f */
- 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 60-67 */
- 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, /* 68-6f */
- 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /* 70-77 */
- 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, /* 78-7f */
- 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 80-87 */
- 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, /* 88-8f */
- 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, /* 90-97 */
- 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, /* 98-9f */
- 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, /* a0-a7 */
- 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, /* a8-af */
- 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, /* b0-b7 */
- 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, /* b8-bf */
- 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* c0-c7 */
- 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* c8-cf */
- 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xd7, /* d0-d7 */
- 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xdf, /* d8-df */
- 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* e0-e7 */
- 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, /* e8-ef */
- 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* f0-f7 */
- 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, /* f8-ff */
-};
-
-/*
- * DOS filenames are made of 2 parts, the name part and the extension part.
- * The name part is 8 characters long and the extension part is 3
- * characters long. They may contain trailing blanks if the name or
- * extension are not long enough to fill their respective fields.
- */
-
-/*
- * Convert a DOS filename to a unix filename. And, return the number of
- * characters in the resulting unix filename excluding the terminating
- * null.
- */
-int
-dos2unixfn(dn, un, lower, d2u_loaded, d2u, ul_loaded, ul)
- u_char dn[11];
- u_char *un;
- int lower;
- int d2u_loaded;
- u_int8_t *d2u;
- int ul_loaded;
- u_int8_t *ul;
-{
- int i;
- int thislong = 1;
- u_char c;
-
- /*
- * If first char of the filename is SLOT_E5 (0x05), then the real
- * first char of the filename should be 0xe5. But, they couldn't
- * just have a 0xe5 mean 0xe5 because that is used to mean a freed
- * directory slot. Another dos quirk.
- */
- if (*dn == SLOT_E5)
- c = d2u_loaded ? d2u[0xe5 & 0x7f] : dos2unix[0xe5];
- else
- c = d2u_loaded && (*dn & 0x80) ? d2u[*dn & 0x7f] :
- dos2unix[*dn];
- *un++ = (lower & LCASE_BASE) ? (ul_loaded && (c & 0x80) ?
- ul[c & 0x7f] : u2l[c]) : c;
- dn++;
-
- /*
- * Copy the name portion into the unix filename string.
- */
- for (i = 1; i < 8 && *dn != ' '; i++) {
- c = d2u_loaded && (*dn & 0x80) ? d2u[*dn & 0x7f] :
- dos2unix[*dn];
- dn++;
- *un++ = (lower & LCASE_BASE) ? (ul_loaded && (c & 0x80) ?
- ul[c & 0x7f] : u2l[c]) : c;
- thislong++;
- }
- dn += 8 - i;
-
- /*
- * Now, if there is an extension then put in a period and copy in
- * the extension.
- */
- if (*dn != ' ') {
- *un++ = '.';
- thislong++;
- for (i = 0; i < 3 && *dn != ' '; i++) {
- c = d2u_loaded && (*dn & 0x80) ? d2u[*dn & 0x7f] :
- dos2unix[*dn];
- dn++;
- *un++ = (lower & LCASE_EXT) ? (ul_loaded && (c & 0x80) ?
- ul[c & 0x7f] : u2l[c]) : c;
- thislong++;
- }
- }
- *un++ = 0;
-
- return (thislong);
-}
-
-/*
- * Convert a unix filename to a DOS filename according to Win95 rules.
- * If applicable and gen is not 0, it is inserted into the converted
- * filename as a generation number.
- * Returns
- * 0 if name couldn't be converted
- * 1 if the converted name is the same as the original
- * (no long filename entry necessary for Win95)
- * 2 if conversion was successful
- * 3 if conversion was successful and generation number was inserted
- */
-int
-unix2dosfn(un, dn, unlen, gen, u2d_loaded, u2d, lu_loaded, lu)
- const u_char *un;
- u_char dn[12];
- int unlen;
- u_int gen;
- int u2d_loaded;
- u_int8_t *u2d;
- int lu_loaded;
- u_int8_t *lu;
-{
- int i, j, l;
- int conv = 1;
- const u_char *cp, *dp, *dp1;
- u_char gentext[6], *wcp;
- u_int8_t c;
-#define U2D(c) (u2d_loaded && ((c) & 0x80) ? u2d[(c) & 0x7f] : unix2dos[c])
-
- /*
- * Fill the dos filename string with blanks. These are DOS's pad
- * characters.
- */
- for (i = 0; i < 11; i++)
- dn[i] = ' ';
- dn[11] = 0;
-
- /*
- * The filenames "." and ".." are handled specially, since they
- * don't follow dos filename rules.
- */
- if (un[0] == '.' && unlen == 1) {
- dn[0] = '.';
- return gen <= 1;
- }
- if (un[0] == '.' && un[1] == '.' && unlen == 2) {
- dn[0] = '.';
- dn[1] = '.';
- return gen <= 1;
- }
-
- /*
- * Filenames with only blanks and dots are not allowed!
- */
- for (cp = un, i = unlen; --i >= 0; cp++)
- if (*cp != ' ' && *cp != '.')
- break;
- if (i < 0)
- return 0;
-
-
- /*
- * Filenames with some characters are not allowed!
- */
- for (cp = un, i = unlen; --i >= 0; cp++)
- if (U2D(*cp) == 0)
- return 0;
-
- /*
- * Now find the extension
- * Note: dot as first char doesn't start extension
- * and trailing dots and blanks are ignored
- */
- dp = dp1 = 0;
- for (cp = un + 1, i = unlen - 1; --i >= 0;) {
- switch (*cp++) {
- case '.':
- if (!dp1)
- dp1 = cp;
- break;
- case ' ':
- break;
- default:
- if (dp1)
- dp = dp1;
- dp1 = 0;
- break;
- }
- }
-
- /*
- * Now convert it
- */
- if (dp) {
- if (dp1)
- l = dp1 - dp;
- else
- l = unlen - (dp - un);
- for (i = 0, j = 8; i < l && j < 11; i++, j++) {
- c = dp[i];
- c = lu_loaded && (c & 0x80) ?
- lu[c & 0x7f] : l2u[c];
- c = U2D(c);
- if (dp[i] != (dn[j] = c)
- && conv != 3)
- conv = 2;
- if (dn[j] == 1) {
- conv = 3;
- dn[j] = '_';
- }
- if (dn[j] == 2) {
- conv = 3;
- dn[j--] = ' ';
- }
- }
- if (i < l)
- conv = 3;
- dp--;
- } else {
- for (dp = cp; *--dp == ' ' || *dp == '.';);
- dp++;
- }
-
- /*
- * Now convert the rest of the name
- */
- for (i = j = 0; un < dp && j < 8; i++, j++, un++) {
- c = lu_loaded && (*un & 0x80) ?
- lu[*un & 0x7f] : l2u[*un];
- c = U2D(c);
- if (*un != (dn[j] = c)
- && conv != 3)
- conv = 2;
- if (dn[j] == 1) {
- conv = 3;
- dn[j] = '_';
- }
- if (dn[j] == 2) {
- conv = 3;
- dn[j--] = ' ';
- }
- }
- if (un < dp)
- conv = 3;
- /*
- * If we didn't have any chars in filename,
- * generate a default
- */
- if (!j)
- dn[0] = '_';
-
- /*
- * The first character cannot be E5,
- * because that means a deleted entry
- */
- if (dn[0] == 0xe5)
- dn[0] = SLOT_E5;
-
- /*
- * If there wasn't any char dropped,
- * there is no place for generation numbers
- */
- if (conv != 3) {
- if (gen > 1)
- return 0;
- return conv;
- }
-
- /*
- * Now insert the generation number into the filename part
- */
- if (gen == 0)
- return conv;
- for (wcp = gentext + sizeof(gentext); wcp > gentext && gen; gen /= 10)
- *--wcp = gen % 10 + '0';
- if (gen)
- return 0;
- for (i = 8; dn[--i] == ' ';);
- i++;
- if (gentext + sizeof(gentext) - wcp + 1 > 8 - i)
- i = 8 - (gentext + sizeof(gentext) - wcp + 1);
- dn[i++] = '~';
- while (wcp < gentext + sizeof(gentext))
- dn[i++] = *wcp++;
- return 3;
-#undef U2D
-}
-
-/*
- * Create a Win95 long name directory entry
- * Note: assumes that the filename is valid,
- * i.e. doesn't consist solely of blanks and dots
- */
-int
-unix2winfn(un, unlen, wep, cnt, chksum, table_loaded, u2w)
- const u_char *un;
- int unlen;
- struct winentry *wep;
- int cnt;
- int chksum;
- int table_loaded;
- u_int16_t *u2w;
-{
- const u_int8_t *cp;
- u_int8_t *wcp;
- int i;
- u_int16_t code;
-
- /*
- * Drop trailing blanks and dots
- */
- for (cp = un + unlen; *--cp == ' ' || *cp == '.'; unlen--);
-
- un += (cnt - 1) * WIN_CHARS;
- unlen -= (cnt - 1) * WIN_CHARS;
-
- /*
- * Initialize winentry to some useful default
- */
- for (wcp = (u_int8_t *)wep, i = sizeof(*wep); --i >= 0; *wcp++ = 0xff);
- wep->weCnt = cnt;
- wep->weAttributes = ATTR_WIN95;
- wep->weReserved1 = 0;
- wep->weChksum = chksum;
- wep->weReserved2 = 0;
-
- /*
- * Now convert the filename parts
- */
- for (wcp = wep->wePart1, i = sizeof(wep->wePart1)/2; --i >= 0;) {
- if (--unlen < 0)
- goto done;
- if (table_loaded && (*un & 0x80)) {
- code = u2w[*un++ & 0x7f];
- *wcp++ = code;
- *wcp++ = code >> 8;
- } else {
- *wcp++ = *un++;
- *wcp++ = 0;
- }
- }
- for (wcp = wep->wePart2, i = sizeof(wep->wePart2)/2; --i >= 0;) {
- if (--unlen < 0)
- goto done;
- if (table_loaded && (*un & 0x80)) {
- code = u2w[*un++ & 0x7f];
- *wcp++ = code;
- *wcp++ = code >> 8;
- } else {
- *wcp++ = *un++;
- *wcp++ = 0;
- }
- }
- for (wcp = wep->wePart3, i = sizeof(wep->wePart3)/2; --i >= 0;) {
- if (--unlen < 0)
- goto done;
- if (table_loaded && (*un & 0x80)) {
- code = u2w[*un++ & 0x7f];
- *wcp++ = code;
- *wcp++ = code >> 8;
- } else {
- *wcp++ = *un++;
- *wcp++ = 0;
- }
- }
- if (!unlen)
- wep->weCnt |= WIN_LAST;
- return unlen;
-
-done:
- *wcp++ = 0;
- *wcp++ = 0;
- wep->weCnt |= WIN_LAST;
- return 0;
-}
-
-static __inline u_int8_t
-find_lcode(code, u2w)
- u_int16_t code;
- u_int16_t *u2w;
-{
- int i;
-
- for (i = 0; i < 128; i++)
- if (u2w[i] == code)
- return (i | 0x80);
- return '?';
-}
-
-/*
- * Compare our filename to the one in the Win95 entry
- * Returns the checksum or -1 if no match
- */
-int
-winChkName(un, unlen, wep, chksum, u2w_loaded, u2w, ul_loaded, ul)
- const u_char *un;
- int unlen;
- struct winentry *wep;
- int chksum;
- int u2w_loaded;
- u_int16_t *u2w;
- int ul_loaded;
- u_int8_t *ul;
-{
- u_int8_t *cp;
- int i;
- u_int16_t code;
- u_int8_t c1, c2;
-
- /*
- * First compare checksums
- */
- if (wep->weCnt&WIN_LAST)
- chksum = wep->weChksum;
- else if (chksum != wep->weChksum)
- chksum = -1;
- if (chksum == -1)
- return -1;
-
- /*
- * Offset of this entry
- */
- i = ((wep->weCnt&WIN_CNT) - 1) * WIN_CHARS;
- un += i;
- if ((unlen -= i) <= 0)
- return -1;
- if ((wep->weCnt&WIN_LAST) && unlen > WIN_CHARS)
- return -1;
-
- /*
- * Compare the name parts
- */
- for (cp = wep->wePart1, i = sizeof(wep->wePart1)/2; --i >= 0;) {
- if (--unlen < 0) {
- if (!*cp++ && !*cp)
- return chksum;
- return -1;
- }
- code = (cp[1] << 8) | cp[0];
- if (code & 0xff80) {
- if (u2w_loaded)
- code = find_lcode(code, u2w);
- else if (code & 0xff00)
- code = '?';
- }
- c1 = ul_loaded && (code & 0x80) ?
- ul[code & 0x7f] : u2l[code];
- c2 = ul_loaded && (*un & 0x80) ?
- ul[*un & 0x7f] : u2l[*un];
- if (c1 != c2)
- return -1;
- cp += 2;
- un++;
- }
- for (cp = wep->wePart2, i = sizeof(wep->wePart2)/2; --i >= 0;) {
- if (--unlen < 0) {
- if (!*cp++ && !*cp)
- return chksum;
- return -1;
- }
- code = (cp[1] << 8) | cp[0];
- if (code & 0xff80) {
- if (u2w_loaded)
- code = find_lcode(code, u2w);
- else if (code & 0xff00)
- code = '?';
- }
- c1 = ul_loaded && (code & 0x80) ?
- ul[code & 0x7f] : u2l[code];
- c2 = ul_loaded && (*un & 0x80) ?
- ul[*un & 0x7f] : u2l[*un];
- if (c1 != c2)
- return -1;
- cp += 2;
- un++;
- }
- for (cp = wep->wePart3, i = sizeof(wep->wePart3)/2; --i >= 0;) {
- if (--unlen < 0) {
- if (!*cp++ && !*cp)
- return chksum;
- return -1;
- }
- code = (cp[1] << 8) | cp[0];
- if (code & 0xff80) {
- if (u2w_loaded)
- code = find_lcode(code, u2w);
- else if (code & 0xff00)
- code = '?';
- }
- c1 = ul_loaded && (code & 0x80) ?
- ul[code & 0x7f] : u2l[code];
- c2 = ul_loaded && (*un & 0x80) ?
- ul[*un & 0x7f] : u2l[*un];
- if (c1 != c2)
- return -1;
- cp += 2;
- un++;
- }
- return chksum;
-}
-
-/*
- * Convert Win95 filename to dirbuf.
- * Returns the checksum or -1 if impossible
- */
-int
-win2unixfn(wep, dp, chksum, table_loaded, u2w)
- struct winentry *wep;
- struct dirent *dp;
- int chksum;
- int table_loaded;
- u_int16_t *u2w;
-{
- u_int8_t *cp;
- u_int8_t *np, *ep = dp->d_name + WIN_MAXLEN;
- u_int16_t code;
- int i;
-
- if ((wep->weCnt&WIN_CNT) > howmany(WIN_MAXLEN, WIN_CHARS)
- || !(wep->weCnt&WIN_CNT))
- return -1;
-
- /*
- * First compare checksums
- */
- if (wep->weCnt&WIN_LAST) {
- chksum = wep->weChksum;
- /*
- * This works even though d_namlen is one byte!
- */
- dp->d_namlen = (wep->weCnt&WIN_CNT) * WIN_CHARS;
- } else if (chksum != wep->weChksum)
- chksum = -1;
- if (chksum == -1)
- return -1;
-
- /*
- * Offset of this entry
- */
- i = ((wep->weCnt&WIN_CNT) - 1) * WIN_CHARS;
- np = (u_int8_t *)dp->d_name + i;
-
- /*
- * Convert the name parts
- */
- for (cp = wep->wePart1, i = sizeof(wep->wePart1)/2; --i >= 0;) {
- code = (cp[1] << 8) | cp[0];
- switch (code) {
- case 0:
- *np = '\0';
- dp->d_namlen -= sizeof(wep->wePart2)/2
- + sizeof(wep->wePart3)/2 + i + 1;
- return chksum;
- case '/':
- *np = '\0';
- return -1;
- default:
- if (code & 0xff80) {
- if (table_loaded)
- code = find_lcode(code, u2w);
- else if (code & 0xff00)
- code = '?';
- }
- *np++ = code;
- break;
- }
- /*
- * The size comparison should result in the compiler
- * optimizing the whole if away
- */
- if (WIN_MAXLEN % WIN_CHARS < sizeof(wep->wePart1) / 2
- && np > ep) {
- np[-1] = 0;
- return -1;
- }
- cp += 2;
- }
- for (cp = wep->wePart2, i = sizeof(wep->wePart2)/2; --i >= 0;) {
- code = (cp[1] << 8) | cp[0];
- switch (code) {
- case 0:
- *np = '\0';
- dp->d_namlen -= sizeof(wep->wePart3)/2 + i + 1;
- return chksum;
- case '/':
- *np = '\0';
- return -1;
- default:
- if (code & 0xff80) {
- if (table_loaded)
- code = find_lcode(code, u2w);
- else if (code & 0xff00)
- code = '?';
- }
- *np++ = code;
- break;
- }
- /*
- * The size comparisons should be optimized away
- */
- if (WIN_MAXLEN % WIN_CHARS >= sizeof(wep->wePart1) / 2
- && WIN_MAXLEN % WIN_CHARS < (sizeof(wep->wePart1) + sizeof(wep->wePart2)) / 2
- && np > ep) {
- np[-1] = 0;
- return -1;
- }
- cp += 2;
- }
- for (cp = wep->wePart3, i = sizeof(wep->wePart3)/2; --i >= 0;) {
- code = (cp[1] << 8) | cp[0];
- switch (code) {
- case 0:
- *np = '\0';
- dp->d_namlen -= i + 1;
- return chksum;
- case '/':
- *np = '\0';
- return -1;
- default:
- if (code & 0xff80) {
- if (table_loaded)
- code = find_lcode(code, u2w);
- else if (code & 0xff00)
- code = '?';
- }
- *np++ = code;
- break;
- }
- /*
- * See above
- */
- if (WIN_MAXLEN % WIN_CHARS >= (sizeof(wep->wePart1) + sizeof(wep->wePart2)) / 2
- && np > ep) {
- np[-1] = 0;
- return -1;
- }
- cp += 2;
- }
- return chksum;
-}
-
-/*
- * Compute the checksum of a DOS filename for Win95 use
- */
-u_int8_t
-winChksum(name)
- u_int8_t *name;
-{
- int i;
- u_int8_t s;
-
- for (s = 0, i = 11; --i >= 0; s += *name++)
- s = (s << 7)|(s >> 1);
- return s;
-}
-
-/*
- * Determine the number of slots necessary for Win95 names
- */
-int
-winSlotCnt(un, unlen)
- const u_char *un;
- int unlen;
-{
- unlen = winLenFixup(un, unlen);
- if (unlen > WIN_MAXLEN)
- return 0;
- return howmany(unlen, WIN_CHARS);
-}
-
-/*
- * Determine the number of bytes neccesary for Win95 names
- */
-int
-winLenFixup(un, unlen)
- const u_char* un;
- int unlen;
-{
- for (un += unlen; unlen > 0; unlen--)
- if (*--un != ' ' && *un != '.')
- break;
- return unlen;
-}
diff --git a/sys/fs/msdosfs/msdosfs_denode.c b/sys/fs/msdosfs/msdosfs_denode.c
deleted file mode 100644
index ea825397a4c7..000000000000
--- a/sys/fs/msdosfs/msdosfs_denode.c
+++ /dev/null
@@ -1,712 +0,0 @@
-/* $FreeBSD$ */
-/* $NetBSD: msdosfs_denode.c,v 1.28 1998/02/10 14:10:00 mrg Exp $ */
-
-/*-
- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
- * Copyright (C) 1994, 1995, 1997 TooLs GmbH.
- * All rights reserved.
- * Original code by Paul Popelka (paulp@uts.amdahl.com) (see below).
- *
- * 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 TooLs GmbH.
- * 4. The name of TooLs GmbH may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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.
- */
-/*
- * Written by Paul Popelka (paulp@uts.amdahl.com)
- *
- * You can do anything you want with this software, just don't say you wrote
- * it, and don't remove this notice.
- *
- * This software is provided "as is".
- *
- * The author supplies this software to be publicly redistributed on the
- * understanding that the author is not responsible for the correct
- * functioning of this software in any circumstances and is not liable for
- * any damages caused by this software.
- *
- * October 1992
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/mount.h>
-#include <sys/malloc.h>
-#include <sys/proc.h>
-#include <sys/buf.h>
-#include <sys/vnode.h>
-
-#include <vm/vm.h>
-#include <vm/vm_extern.h>
-
-#include <msdosfs/bpb.h>
-#include <msdosfs/msdosfsmount.h>
-#include <msdosfs/direntry.h>
-#include <msdosfs/denode.h>
-#include <msdosfs/fat.h>
-
-static MALLOC_DEFINE(M_MSDOSFSNODE, "MSDOSFS node", "MSDOSFS vnode private part");
-
-static struct denode **dehashtbl;
-static u_long dehash; /* size of hash table - 1 */
-#define DEHASH(dev, dcl, doff) (dehashtbl[(minor(dev) + (dcl) + (doff) / \
- sizeof(struct direntry)) & dehash])
-#ifndef NULL_SIMPLELOCKS
-static struct simplelock dehash_slock;
-#endif
-
-union _qcvt {
- quad_t qcvt;
- long val[2];
-};
-#define SETHIGH(q, h) { \
- union _qcvt tmp; \
- tmp.qcvt = (q); \
- tmp.val[_QUAD_HIGHWORD] = (h); \
- (q) = tmp.qcvt; \
-}
-#define SETLOW(q, l) { \
- union _qcvt tmp; \
- tmp.qcvt = (q); \
- tmp.val[_QUAD_LOWWORD] = (l); \
- (q) = tmp.qcvt; \
-}
-
-static struct denode *
- msdosfs_hashget __P((dev_t dev, u_long dirclust,
- u_long diroff));
-static void msdosfs_hashins __P((struct denode *dep));
-static void msdosfs_hashrem __P((struct denode *dep));
-
-/*ARGSUSED*/
-int
-msdosfs_init(vfsp)
- struct vfsconf *vfsp;
-{
- dehashtbl = hashinit(desiredvnodes/2, M_MSDOSFSMNT, &dehash);
- simple_lock_init(&dehash_slock);
- return (0);
-}
-
-static struct denode *
-msdosfs_hashget(dev, dirclust, diroff)
- dev_t dev;
- u_long dirclust;
- u_long diroff;
-{
- struct proc *p = curproc; /* XXX */
- struct denode *dep;
- struct vnode *vp;
-
-loop:
- simple_lock(&dehash_slock);
- for (dep = DEHASH(dev, dirclust, diroff); dep; dep = dep->de_next) {
- if (dirclust == dep->de_dirclust
- && diroff == dep->de_diroffset
- && dev == dep->de_dev
- && dep->de_refcnt != 0) {
- vp = DETOV(dep);
- simple_lock(&vp->v_interlock);
- simple_unlock(&dehash_slock);
- if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, p))
- goto loop;
- return (dep);
- }
- }
- simple_unlock(&dehash_slock);
- return (NULL);
-}
-
-static void
-msdosfs_hashins(dep)
- struct denode *dep;
-{
- struct denode **depp, *deq;
-
- simple_lock(&dehash_slock);
- depp = &DEHASH(dep->de_dev, dep->de_dirclust, dep->de_diroffset);
- deq = *depp;
- if (deq)
- deq->de_prev = &dep->de_next;
- dep->de_next = deq;
- dep->de_prev = depp;
- *depp = dep;
- simple_unlock(&dehash_slock);
-}
-
-static void
-msdosfs_hashrem(dep)
- struct denode *dep;
-{
- struct denode *deq;
-
- simple_lock(&dehash_slock);
- deq = dep->de_next;
- if (deq)
- deq->de_prev = dep->de_prev;
- *dep->de_prev = deq;
-#ifdef DIAGNOSTIC
- dep->de_next = NULL;
- dep->de_prev = NULL;
-#endif
- simple_unlock(&dehash_slock);
-}
-
-/*
- * If deget() succeeds it returns with the gotten denode locked().
- *
- * pmp - address of msdosfsmount structure of the filesystem containing
- * the denode of interest. The pm_dev field and the address of
- * the msdosfsmount structure are used.
- * dirclust - which cluster bp contains, if dirclust is 0 (root directory)
- * diroffset is relative to the beginning of the root directory,
- * otherwise it is cluster relative.
- * diroffset - offset past begin of cluster of denode we want
- * depp - returns the address of the gotten denode.
- */
-int
-deget(pmp, dirclust, diroffset, depp)
- struct msdosfsmount *pmp; /* so we know the maj/min number */
- u_long dirclust; /* cluster this dir entry came from */
- u_long diroffset; /* index of entry within the cluster */
- struct denode **depp; /* returns the addr of the gotten denode */
-{
- int error;
- dev_t dev = pmp->pm_dev;
- struct mount *mntp = pmp->pm_mountp;
- struct direntry *direntptr;
- struct denode *ldep;
- struct vnode *nvp;
- struct buf *bp;
- struct proc *p = curproc; /* XXX */
- struct timeval tv;
-
-#ifdef MSDOSFS_DEBUG
- printf("deget(pmp %p, dirclust %lu, diroffset %lx, depp %p)\n",
- pmp, dirclust, diroffset, depp);
-#endif
-
- /*
- * On FAT32 filesystems, root is a (more or less) normal
- * directory
- */
- if (FAT32(pmp) && dirclust == MSDOSFSROOT)
- dirclust = pmp->pm_rootdirblk;
-
- /*
- * See if the denode is in the denode cache. Use the location of
- * the directory entry to compute the hash value. For subdir use
- * address of "." entry. For root dir (if not FAT32) use cluster
- * MSDOSFSROOT, offset MSDOSFSROOT_OFS
- *
- * NOTE: The check for de_refcnt > 0 below insures the denode being
- * examined does not represent an unlinked but still open file.
- * These files are not to be accessible even when the directory
- * entry that represented the file happens to be reused while the
- * deleted file is still open.
- */
- ldep = msdosfs_hashget(dev, dirclust, diroffset);
- if (ldep) {
- *depp = ldep;
- return (0);
- }
-
- /*
- * Do the MALLOC before the getnewvnode since doing so afterward
- * might cause a bogus v_data pointer to get dereferenced
- * elsewhere if MALLOC should block.
- */
- MALLOC(ldep, struct denode *, sizeof(struct denode), M_MSDOSFSNODE, M_WAITOK);
-
- /*
- * Directory entry was not in cache, have to create a vnode and
- * copy it from the passed disk buffer.
- */
- /* getnewvnode() does a VREF() on the vnode */
- error = getnewvnode(VT_MSDOSFS, mntp, msdosfs_vnodeop_p, &nvp);
- if (error) {
- *depp = NULL;
- FREE(ldep, M_MSDOSFSNODE);
- return error;
- }
- bzero((caddr_t)ldep, sizeof *ldep);
- lockinit(&ldep->de_lock, PINOD, "denode", 0, 0);
- nvp->v_data = ldep;
- ldep->de_vnode = nvp;
- ldep->de_flag = 0;
- ldep->de_devvp = 0;
- ldep->de_dev = dev;
- ldep->de_dirclust = dirclust;
- ldep->de_diroffset = diroffset;
- fc_purge(ldep, 0); /* init the fat cache for this denode */
-
- /*
- * Lock the denode so that it can't be accessed until we've read
- * it in and have done what we need to it. Do this here instead
- * of at the start of msdosfs_hashins() so that reinsert() can
- * call msdosfs_hashins() with a locked denode.
- */
- if (lockmgr(&ldep->de_lock, LK_EXCLUSIVE, (struct simplelock *)0, p))
- panic("deget: unexpected lock failure");
-
- /*
- * Insert the denode into the hash queue.
- */
- msdosfs_hashins(ldep);
-
- ldep->de_pmp = pmp;
- ldep->de_refcnt = 1;
- /*
- * Copy the directory entry into the denode area of the vnode.
- */
- if ((dirclust == MSDOSFSROOT
- || (FAT32(pmp) && dirclust == pmp->pm_rootdirblk))
- && diroffset == MSDOSFSROOT_OFS) {
- /*
- * Directory entry for the root directory. There isn't one,
- * so we manufacture one. We should probably rummage
- * through the root directory and find a label entry (if it
- * exists), and then use the time and date from that entry
- * as the time and date for the root denode.
- */
- nvp->v_flag |= VROOT; /* should be further down XXX */
-
- ldep->de_Attributes = ATTR_DIRECTORY;
- ldep->de_LowerCase = 0;
- if (FAT32(pmp))
- ldep->de_StartCluster = pmp->pm_rootdirblk;
- /* de_FileSize will be filled in further down */
- else {
- ldep->de_StartCluster = MSDOSFSROOT;
- ldep->de_FileSize = pmp->pm_rootdirsize * DEV_BSIZE;
- }
- /*
- * fill in time and date so that dos2unixtime() doesn't
- * spit up when called from msdosfs_getattr() with root
- * denode
- */
- ldep->de_CHun = 0;
- ldep->de_CTime = 0x0000; /* 00:00:00 */
- ldep->de_CDate = (0 << DD_YEAR_SHIFT) | (1 << DD_MONTH_SHIFT)
- | (1 << DD_DAY_SHIFT);
- /* Jan 1, 1980 */
- ldep->de_ADate = ldep->de_CDate;
- ldep->de_MTime = ldep->de_CTime;
- ldep->de_MDate = ldep->de_CDate;
- /* leave the other fields as garbage */
- } else {
- error = readep(pmp, dirclust, diroffset, &bp, &direntptr);
- if (error) {
- /*
- * The denode does not contain anything useful, so
- * it would be wrong to leave it on its hash chain.
- * Arrange for vput() to just forget about it.
- */
- ldep->de_Name[0] = SLOT_DELETED;
-
- vput(nvp);
- *depp = NULL;
- return (error);
- }
- DE_INTERNALIZE(ldep, direntptr);
- brelse(bp);
- }
-
- /*
- * Fill in a few fields of the vnode and finish filling in the
- * denode. Then return the address of the found denode.
- */
- if (ldep->de_Attributes & ATTR_DIRECTORY) {
- /*
- * Since DOS directory entries that describe directories
- * have 0 in the filesize field, we take this opportunity
- * to find out the length of the directory and plug it into
- * the denode structure.
- */
- u_long size;
-
- nvp->v_type = VDIR;
- if (ldep->de_StartCluster != MSDOSFSROOT) {
- error = pcbmap(ldep, 0xffff, 0, &size, 0);
- if (error == E2BIG) {
- ldep->de_FileSize = de_cn2off(pmp, size);
- error = 0;
- } else
- printf("deget(): pcbmap returned %d\n", error);
- }
- } else
- nvp->v_type = VREG;
- getmicrouptime(&tv);
- SETHIGH(ldep->de_modrev, tv.tv_sec);
- SETLOW(ldep->de_modrev, tv.tv_usec * 4294);
- ldep->de_devvp = pmp->pm_devvp;
- VREF(ldep->de_devvp);
- *depp = ldep;
- return (0);
-}
-
-int
-deupdat(dep, waitfor)
- struct denode *dep;
- int waitfor;
-{
- int error;
- struct buf *bp;
- struct direntry *dirp;
- struct timespec ts;
-
- if (DETOV(dep)->v_mount->mnt_flag & MNT_RDONLY)
- return (0);
- getnanotime(&ts);
- DETIMES(dep, &ts, &ts, &ts);
- if ((dep->de_flag & DE_MODIFIED) == 0)
- return (0);
- dep->de_flag &= ~DE_MODIFIED;
- if (dep->de_Attributes & ATTR_DIRECTORY)
- return (0);
- if (dep->de_refcnt <= 0)
- return (0);
- error = readde(dep, &bp, &dirp);
- if (error)
- return (error);
- DE_EXTERNALIZE(dirp, dep);
- if (waitfor)
- return (bwrite(bp));
- else {
- bdwrite(bp);
- return (0);
- }
-}
-
-/*
- * Truncate the file described by dep to the length specified by length.
- */
-int
-detrunc(dep, length, flags, cred, p)
- struct denode *dep;
- u_long length;
- int flags;
- struct ucred *cred;
- struct proc *p;
-{
- int error;
- int allerror;
- u_long eofentry;
- u_long chaintofree;
- daddr_t bn;
- int boff;
- int isadir = dep->de_Attributes & ATTR_DIRECTORY;
- struct buf *bp;
- struct msdosfsmount *pmp = dep->de_pmp;
-
-#ifdef MSDOSFS_DEBUG
- printf("detrunc(): file %s, length %lu, flags %x\n", dep->de_Name, length, flags);
-#endif
-
- /*
- * Disallow attempts to truncate the root directory since it is of
- * fixed size. That's just the way dos filesystems are. We use
- * the VROOT bit in the vnode because checking for the directory
- * bit and a startcluster of 0 in the denode is not adequate to
- * recognize the root directory at this point in a file or
- * directory's life.
- */
- if ((DETOV(dep)->v_flag & VROOT) && !FAT32(pmp)) {
- printf("detrunc(): can't truncate root directory, clust %ld, offset %ld\n",
- dep->de_dirclust, dep->de_diroffset);
- return (EINVAL);
- }
-
-
- if (dep->de_FileSize < length) {
- vnode_pager_setsize(DETOV(dep), length);
- return deextend(dep, length, cred);
- }
-
- /*
- * If the desired length is 0 then remember the starting cluster of
- * the file and set the StartCluster field in the directory entry
- * to 0. If the desired length is not zero, then get the number of
- * the last cluster in the shortened file. Then get the number of
- * the first cluster in the part of the file that is to be freed.
- * Then set the next cluster pointer in the last cluster of the
- * file to CLUST_EOFE.
- */
- if (length == 0) {
- chaintofree = dep->de_StartCluster;
- dep->de_StartCluster = 0;
- eofentry = ~0;
- } else {
- error = pcbmap(dep, de_clcount(pmp, length) - 1, 0,
- &eofentry, 0);
- if (error) {
-#ifdef MSDOSFS_DEBUG
- printf("detrunc(): pcbmap fails %d\n", error);
-#endif
- return (error);
- }
- }
-
- fc_purge(dep, de_clcount(pmp, length));
-
- /*
- * If the new length is not a multiple of the cluster size then we
- * must zero the tail end of the new last cluster in case it
- * becomes part of the file again because of a seek.
- */
- if ((boff = length & pmp->pm_crbomask) != 0) {
- if (isadir) {
- bn = cntobn(pmp, eofentry);
- error = bread(pmp->pm_devvp, bn, pmp->pm_bpcluster,
- NOCRED, &bp);
- } else {
- bn = de_blk(pmp, length);
- error = bread(DETOV(dep), bn, pmp->pm_bpcluster,
- NOCRED, &bp);
- }
- if (error) {
- brelse(bp);
-#ifdef MSDOSFS_DEBUG
- printf("detrunc(): bread fails %d\n", error);
-#endif
- return (error);
- }
- /*
- * is this the right place for it?
- */
- bzero(bp->b_data + boff, pmp->pm_bpcluster - boff);
- if (flags & IO_SYNC)
- bwrite(bp);
- else
- bdwrite(bp);
- }
-
- /*
- * Write out the updated directory entry. Even if the update fails
- * we free the trailing clusters.
- */
- dep->de_FileSize = length;
- if (!isadir)
- dep->de_flag |= DE_UPDATE|DE_MODIFIED;
- allerror = vtruncbuf(DETOV(dep), cred, p, length, pmp->pm_bpcluster);
-#ifdef MSDOSFS_DEBUG
- if (allerror)
- printf("detrunc(): vtruncbuf error %d\n", allerror);
-#endif
- error = deupdat(dep, 1);
- if (error && (allerror == 0))
- allerror = error;
-#ifdef MSDOSFS_DEBUG
- printf("detrunc(): allerror %d, eofentry %lu\n",
- allerror, eofentry);
-#endif
-
- /*
- * If we need to break the cluster chain for the file then do it
- * now.
- */
- if (eofentry != ~0) {
- error = fatentry(FAT_GET_AND_SET, pmp, eofentry,
- &chaintofree, CLUST_EOFE);
- if (error) {
-#ifdef MSDOSFS_DEBUG
- printf("detrunc(): fatentry errors %d\n", error);
-#endif
- return (error);
- }
- fc_setcache(dep, FC_LASTFC, de_cluster(pmp, length - 1),
- eofentry);
- }
-
- /*
- * Now free the clusters removed from the file because of the
- * truncation.
- */
- if (chaintofree != 0 && !MSDOSFSEOF(pmp, chaintofree))
- freeclusterchain(pmp, chaintofree);
-
- return (allerror);
-}
-
-/*
- * Extend the file described by dep to length specified by length.
- */
-int
-deextend(dep, length, cred)
- struct denode *dep;
- u_long length;
- struct ucred *cred;
-{
- struct msdosfsmount *pmp = dep->de_pmp;
- u_long count;
- int error;
-
- /*
- * The root of a DOS filesystem cannot be extended.
- */
- if ((DETOV(dep)->v_flag & VROOT) && !FAT32(pmp))
- return (EINVAL);
-
- /*
- * Directories cannot be extended.
- */
- if (dep->de_Attributes & ATTR_DIRECTORY)
- return (EISDIR);
-
- if (length <= dep->de_FileSize)
- panic("deextend: file too large");
-
- /*
- * Compute the number of clusters to allocate.
- */
- count = de_clcount(pmp, length) - de_clcount(pmp, dep->de_FileSize);
- if (count > 0) {
- if (count > pmp->pm_freeclustercount)
- return (ENOSPC);
- error = extendfile(dep, count, NULL, NULL, DE_CLEAR);
- if (error) {
- /* truncate the added clusters away again */
- (void) detrunc(dep, dep->de_FileSize, 0, cred, NULL);
- return (error);
- }
- }
- dep->de_FileSize = length;
- dep->de_flag |= DE_UPDATE|DE_MODIFIED;
- return (deupdat(dep, 1));
-}
-
-/*
- * Move a denode to its correct hash queue after the file it represents has
- * been moved to a new directory.
- */
-void
-reinsert(dep)
- struct denode *dep;
-{
- /*
- * Fix up the denode cache. If the denode is for a directory,
- * there is nothing to do since the hash is based on the starting
- * cluster of the directory file and that hasn't changed. If for a
- * file the hash is based on the location of the directory entry,
- * so we must remove it from the cache and re-enter it with the
- * hash based on the new location of the directory entry.
- */
- if (dep->de_Attributes & ATTR_DIRECTORY)
- return;
- msdosfs_hashrem(dep);
- msdosfs_hashins(dep);
-}
-
-int
-msdosfs_reclaim(ap)
- struct vop_reclaim_args /* {
- struct vnode *a_vp;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
- struct denode *dep = VTODE(vp);
-
-#ifdef MSDOSFS_DEBUG
- printf("msdosfs_reclaim(): dep %p, file %s, refcnt %ld\n",
- dep, dep->de_Name, dep->de_refcnt);
-#endif
-
- if (prtactive && vp->v_usecount != 0)
- vprint("msdosfs_reclaim(): pushing active", vp);
- /*
- * Remove the denode from its hash chain.
- */
- msdosfs_hashrem(dep);
- /*
- * Purge old data structures associated with the denode.
- */
- cache_purge(vp);
- if (dep->de_devvp) {
- vrele(dep->de_devvp);
- dep->de_devvp = 0;
- }
-#if 0 /* XXX */
- dep->de_flag = 0;
-#endif
- FREE(dep, M_MSDOSFSNODE);
- vp->v_data = NULL;
-
- return (0);
-}
-
-int
-msdosfs_inactive(ap)
- struct vop_inactive_args /* {
- struct vnode *a_vp;
- struct proc *a_p;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
- struct denode *dep = VTODE(vp);
- struct proc *p = ap->a_p;
- int error = 0;
-
-#ifdef MSDOSFS_DEBUG
- printf("msdosfs_inactive(): dep %p, de_Name[0] %x\n", dep, dep->de_Name[0]);
-#endif
-
- if (prtactive && vp->v_usecount != 0)
- vprint("msdosfs_inactive(): pushing active", vp);
-
- /*
- * Ignore denodes related to stale file handles.
- */
- if (dep->de_Name[0] == SLOT_DELETED)
- goto out;
-
- /*
- * If the file has been deleted and it is on a read/write
- * filesystem, then truncate the file, and mark the directory slot
- * as empty. (This may not be necessary for the dos filesystem.)
- */
-#ifdef MSDOSFS_DEBUG
- printf("msdosfs_inactive(): dep %p, refcnt %ld, mntflag %x, MNT_RDONLY %x\n",
- dep, dep->de_refcnt, vp->v_mount->mnt_flag, MNT_RDONLY);
-#endif
- if (dep->de_refcnt <= 0 && (vp->v_mount->mnt_flag & MNT_RDONLY) == 0) {
- error = detrunc(dep, (u_long) 0, 0, NOCRED, p);
- dep->de_flag |= DE_UPDATE;
- dep->de_Name[0] = SLOT_DELETED;
- }
- deupdat(dep, 0);
-
-out:
- VOP_UNLOCK(vp, 0, p);
- /*
- * If we are done with the denode, reclaim it
- * so that it can be reused immediately.
- */
-#ifdef MSDOSFS_DEBUG
- printf("msdosfs_inactive(): v_usecount %d, de_Name[0] %x\n", vp->v_usecount,
- dep->de_Name[0]);
-#endif
- if (dep->de_Name[0] == SLOT_DELETED)
- vrecycle(vp, (struct simplelock *)0, p);
- return (error);
-}
diff --git a/sys/fs/msdosfs/msdosfs_fat.c b/sys/fs/msdosfs/msdosfs_fat.c
deleted file mode 100644
index 1caad93b2a0c..000000000000
--- a/sys/fs/msdosfs/msdosfs_fat.c
+++ /dev/null
@@ -1,1101 +0,0 @@
-/* $FreeBSD$ */
-/* $NetBSD: msdosfs_fat.c,v 1.28 1997/11/17 15:36:49 ws Exp $ */
-
-/*-
- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
- * Copyright (C) 1994, 1995, 1997 TooLs GmbH.
- * All rights reserved.
- * Original code by Paul Popelka (paulp@uts.amdahl.com) (see below).
- *
- * 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 TooLs GmbH.
- * 4. The name of TooLs GmbH may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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.
- */
-/*
- * Written by Paul Popelka (paulp@uts.amdahl.com)
- *
- * You can do anything you want with this software, just don't say you wrote
- * it, and don't remove this notice.
- *
- * This software is provided "as is".
- *
- * The author supplies this software to be publicly redistributed on the
- * understanding that the author is not responsible for the correct
- * functioning of this software in any circumstances and is not liable for
- * any damages caused by this software.
- *
- * October 1992
- */
-
-/*
- * kernel include files.
- */
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/buf.h>
-#include <sys/mount.h> /* to define statfs structure */
-#include <sys/vnode.h> /* to define vattr structure */
-
-/*
- * msdosfs include files.
- */
-#include <msdosfs/bpb.h>
-#include <msdosfs/msdosfsmount.h>
-#include <msdosfs/direntry.h>
-#include <msdosfs/denode.h>
-#include <msdosfs/fat.h>
-
-/*
- * Fat cache stats.
- */
-static int fc_fileextends; /* # of file extends */
-static int fc_lfcempty; /* # of time last file cluster cache entry
- * was empty */
-static int fc_bmapcalls; /* # of times pcbmap was called */
-
-#define LMMAX 20
-static int fc_lmdistance[LMMAX];/* counters for how far off the last
- * cluster mapped entry was. */
-static int fc_largedistance; /* off by more than LMMAX */
-
-static int chainalloc __P((struct msdosfsmount *pmp, u_long start,
- u_long count, u_long fillwith,
- u_long *retcluster, u_long *got));
-static int chainlength __P((struct msdosfsmount *pmp, u_long start,
- u_long count));
-static void fatblock __P((struct msdosfsmount *pmp, u_long ofs,
- u_long *bnp, u_long *sizep, u_long *bop));
-static int fatchain __P((struct msdosfsmount *pmp, u_long start,
- u_long count, u_long fillwith));
-static void fc_lookup __P((struct denode *dep, u_long findcn,
- u_long *frcnp, u_long *fsrcnp));
-static void updatefats __P((struct msdosfsmount *pmp, struct buf *bp,
- u_long fatbn));
-static __inline void
- usemap_alloc __P((struct msdosfsmount *pmp, u_long cn));
-static __inline void
- usemap_free __P((struct msdosfsmount *pmp, u_long cn));
-
-static void
-fatblock(pmp, ofs, bnp, sizep, bop)
- struct msdosfsmount *pmp;
- u_long ofs;
- u_long *bnp;
- u_long *sizep;
- u_long *bop;
-{
- u_long bn, size;
-
- bn = ofs / pmp->pm_fatblocksize * pmp->pm_fatblocksec;
- size = min(pmp->pm_fatblocksec, pmp->pm_FATsecs - bn)
- * DEV_BSIZE;
- bn += pmp->pm_fatblk + pmp->pm_curfat * pmp->pm_FATsecs;
-
- if (bnp)
- *bnp = bn;
- if (sizep)
- *sizep = size;
- if (bop)
- *bop = ofs % pmp->pm_fatblocksize;
-}
-
-/*
- * Map the logical cluster number of a file into a physical disk sector
- * that is filesystem relative.
- *
- * dep - address of denode representing the file of interest
- * findcn - file relative cluster whose filesystem relative cluster number
- * and/or block number are/is to be found
- * bnp - address of where to place the file system relative block number.
- * If this pointer is null then don't return this quantity.
- * cnp - address of where to place the file system relative cluster number.
- * If this pointer is null then don't return this quantity.
- *
- * NOTE: Either bnp or cnp must be non-null.
- * This function has one side effect. If the requested file relative cluster
- * is beyond the end of file, then the actual number of clusters in the file
- * is returned in *cnp. This is useful for determining how long a directory is.
- * If cnp is null, nothing is returned.
- */
-int
-pcbmap(dep, findcn, bnp, cnp, sp)
- struct denode *dep;
- u_long findcn; /* file relative cluster to get */
- daddr_t *bnp; /* returned filesys relative blk number */
- u_long *cnp; /* returned cluster number */
- int *sp; /* returned block size */
-{
- int error;
- u_long i;
- u_long cn;
- u_long prevcn = 0; /* XXX: prevcn could be used unititialized */
- u_long byteoffset;
- u_long bn;
- u_long bo;
- struct buf *bp = NULL;
- u_long bp_bn = -1;
- struct msdosfsmount *pmp = dep->de_pmp;
- u_long bsize;
-
- fc_bmapcalls++;
-
- /*
- * If they don't give us someplace to return a value then don't
- * bother doing anything.
- */
- if (bnp == NULL && cnp == NULL && sp == NULL)
- return (0);
-
- cn = dep->de_StartCluster;
- /*
- * The "file" that makes up the root directory is contiguous,
- * permanently allocated, of fixed size, and is not made up of
- * clusters. If the cluster number is beyond the end of the root
- * directory, then return the number of clusters in the file.
- */
- if (cn == MSDOSFSROOT) {
- if (dep->de_Attributes & ATTR_DIRECTORY) {
- if (de_cn2off(pmp, findcn) >= dep->de_FileSize) {
- if (cnp)
- *cnp = de_bn2cn(pmp, pmp->pm_rootdirsize);
- return (E2BIG);
- }
- if (bnp)
- *bnp = pmp->pm_rootdirblk + de_cn2bn(pmp, findcn);
- if (cnp)
- *cnp = MSDOSFSROOT;
- if (sp)
- *sp = min(pmp->pm_bpcluster,
- dep->de_FileSize - de_cn2off(pmp, findcn));
- return (0);
- } else { /* just an empty file */
- if (cnp)
- *cnp = 0;
- return (E2BIG);
- }
- }
-
- /*
- * All other files do I/O in cluster sized blocks
- */
- if (sp)
- *sp = pmp->pm_bpcluster;
-
- /*
- * Rummage around in the fat cache, maybe we can avoid tromping
- * thru every fat entry for the file. And, keep track of how far
- * off the cache was from where we wanted to be.
- */
- i = 0;
- fc_lookup(dep, findcn, &i, &cn);
- if ((bn = findcn - i) >= LMMAX)
- fc_largedistance++;
- else
- fc_lmdistance[bn]++;
-
- /*
- * Handle all other files or directories the normal way.
- */
- for (; i < findcn; i++) {
- /*
- * Stop with all reserved clusters, not just with EOF.
- */
- if ((cn | ~pmp->pm_fatmask) >= CLUST_RSRVD)
- goto hiteof;
- byteoffset = FATOFS(pmp, cn);
- fatblock(pmp, byteoffset, &bn, &bsize, &bo);
- if (bn != bp_bn) {
- if (bp)
- brelse(bp);
- error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp);
- if (error) {
- brelse(bp);
- return (error);
- }
- bp_bn = bn;
- }
- prevcn = cn;
- if (FAT32(pmp))
- cn = getulong(&bp->b_data[bo]);
- else
- cn = getushort(&bp->b_data[bo]);
- if (FAT12(pmp) && (prevcn & 1))
- cn >>= 4;
- cn &= pmp->pm_fatmask;
-
- /*
- * Force the special cluster numbers
- * to be the same for all cluster sizes
- * to let the rest of msdosfs handle
- * all cases the same.
- */
- if ((cn | ~pmp->pm_fatmask) >= CLUST_RSRVD)
- cn |= ~pmp->pm_fatmask;
- }
-
- if (!MSDOSFSEOF(pmp, cn)) {
- if (bp)
- brelse(bp);
- if (bnp)
- *bnp = cntobn(pmp, cn);
- if (cnp)
- *cnp = cn;
- fc_setcache(dep, FC_LASTMAP, i, cn);
- return (0);
- }
-
-hiteof:;
- if (cnp)
- *cnp = i;
- if (bp)
- brelse(bp);
- /* update last file cluster entry in the fat cache */
- fc_setcache(dep, FC_LASTFC, i - 1, prevcn);
- return (E2BIG);
-}
-
-/*
- * Find the closest entry in the fat cache to the cluster we are looking
- * for.
- */
-static void
-fc_lookup(dep, findcn, frcnp, fsrcnp)
- struct denode *dep;
- u_long findcn;
- u_long *frcnp;
- u_long *fsrcnp;
-{
- int i;
- u_long cn;
- struct fatcache *closest = 0;
-
- for (i = 0; i < FC_SIZE; i++) {
- cn = dep->de_fc[i].fc_frcn;
- if (cn != FCE_EMPTY && cn <= findcn) {
- if (closest == 0 || cn > closest->fc_frcn)
- closest = &dep->de_fc[i];
- }
- }
- if (closest) {
- *frcnp = closest->fc_frcn;
- *fsrcnp = closest->fc_fsrcn;
- }
-}
-
-/*
- * Purge the fat cache in denode dep of all entries relating to file
- * relative cluster frcn and beyond.
- */
-void
-fc_purge(dep, frcn)
- struct denode *dep;
- u_int frcn;
-{
- int i;
- struct fatcache *fcp;
-
- fcp = dep->de_fc;
- for (i = 0; i < FC_SIZE; i++, fcp++) {
- if (fcp->fc_frcn >= frcn)
- fcp->fc_frcn = FCE_EMPTY;
- }
-}
-
-/*
- * Update the fat.
- * If mirroring the fat, update all copies, with the first copy as last.
- * Else update only the current fat (ignoring the others).
- *
- * pmp - msdosfsmount structure for filesystem to update
- * bp - addr of modified fat block
- * fatbn - block number relative to begin of filesystem of the modified fat block.
- */
-static void
-updatefats(pmp, bp, fatbn)
- struct msdosfsmount *pmp;
- struct buf *bp;
- u_long fatbn;
-{
- int i;
- struct buf *bpn;
-
-#ifdef MSDOSFS_DEBUG
- printf("updatefats(pmp %p, bp %p, fatbn %lu)\n", pmp, bp, fatbn);
-#endif
-
- /*
- * If we have an FSInfo block, update it.
- */
- if (pmp->pm_fsinfo) {
- u_long cn = pmp->pm_nxtfree;
-
- if (pmp->pm_freeclustercount
- && (pmp->pm_inusemap[cn / N_INUSEBITS]
- & (1 << (cn % N_INUSEBITS)))) {
- /*
- * The cluster indicated in FSInfo isn't free
- * any longer. Got get a new free one.
- */
- for (cn = 0; cn < pmp->pm_maxcluster; cn += N_INUSEBITS)
- if (pmp->pm_inusemap[cn / N_INUSEBITS] != (u_int)-1)
- break;
- pmp->pm_nxtfree = cn
- + ffs(pmp->pm_inusemap[cn / N_INUSEBITS]
- ^ (u_int)-1) - 1;
- }
- if (bread(pmp->pm_devvp, pmp->pm_fsinfo, fsi_size(pmp),
- NOCRED, &bpn) != 0) {
- /*
- * Ignore the error, but turn off FSInfo update for the future.
- */
- pmp->pm_fsinfo = 0;
- brelse(bpn);
- } else {
- struct fsinfo *fp = (struct fsinfo *)bpn->b_data;
-
- putulong(fp->fsinfree, pmp->pm_freeclustercount);
- putulong(fp->fsinxtfree, pmp->pm_nxtfree);
- if (pmp->pm_flags & MSDOSFSMNT_WAITONFAT)
- bwrite(bpn);
- else
- bdwrite(bpn);
- }
- }
-
- if (pmp->pm_flags & MSDOSFS_FATMIRROR) {
- /*
- * Now copy the block(s) of the modified fat to the other copies of
- * the fat and write them out. This is faster than reading in the
- * other fats and then writing them back out. This could tie up
- * the fat for quite a while. Preventing others from accessing it.
- * To prevent us from going after the fat quite so much we use
- * delayed writes, unless they specfied "synchronous" when the
- * filesystem was mounted. If synch is asked for then use
- * bwrite()'s and really slow things down.
- */
- for (i = 1; i < pmp->pm_FATs; i++) {
- fatbn += pmp->pm_FATsecs;
- /* getblk() never fails */
- bpn = getblk(pmp->pm_devvp, fatbn, bp->b_bcount, 0, 0);
- bcopy(bp->b_data, bpn->b_data, bp->b_bcount);
- if (pmp->pm_flags & MSDOSFSMNT_WAITONFAT)
- bwrite(bpn);
- else
- bdwrite(bpn);
- }
- }
-
- /*
- * Write out the first (or current) fat last.
- */
- if (pmp->pm_flags & MSDOSFSMNT_WAITONFAT)
- bwrite(bp);
- else
- bdwrite(bp);
- /*
- * Maybe update fsinfo sector here?
- */
-}
-
-/*
- * Updating entries in 12 bit fats is a pain in the butt.
- *
- * The following picture shows where nibbles go when moving from a 12 bit
- * cluster number into the appropriate bytes in the FAT.
- *
- * byte m byte m+1 byte m+2
- * +----+----+ +----+----+ +----+----+
- * | 0 1 | | 2 3 | | 4 5 | FAT bytes
- * +----+----+ +----+----+ +----+----+
- *
- * +----+----+----+ +----+----+----+
- * | 3 0 1 | | 4 5 2 |
- * +----+----+----+ +----+----+----+
- * cluster n cluster n+1
- *
- * Where n is even. m = n + (n >> 2)
- *
- */
-static __inline void
-usemap_alloc(pmp, cn)
- struct msdosfsmount *pmp;
- u_long cn;
-{
-
- pmp->pm_inusemap[cn / N_INUSEBITS] |= 1 << (cn % N_INUSEBITS);
- pmp->pm_freeclustercount--;
-}
-
-static __inline void
-usemap_free(pmp, cn)
- struct msdosfsmount *pmp;
- u_long cn;
-{
-
- pmp->pm_freeclustercount++;
- pmp->pm_inusemap[cn / N_INUSEBITS] &= ~(1 << (cn % N_INUSEBITS));
-}
-
-int
-clusterfree(pmp, cluster, oldcnp)
- struct msdosfsmount *pmp;
- u_long cluster;
- u_long *oldcnp;
-{
- int error;
- u_long oldcn;
-
- usemap_free(pmp, cluster);
- error = fatentry(FAT_GET_AND_SET, pmp, cluster, &oldcn, MSDOSFSFREE);
- if (error) {
- usemap_alloc(pmp, cluster);
- return (error);
- }
- /*
- * If the cluster was successfully marked free, then update
- * the count of free clusters, and turn off the "allocated"
- * bit in the "in use" cluster bit map.
- */
- if (oldcnp)
- *oldcnp = oldcn;
- return (0);
-}
-
-/*
- * Get or Set or 'Get and Set' the cluster'th entry in the fat.
- *
- * function - whether to get or set a fat entry
- * pmp - address of the msdosfsmount structure for the filesystem
- * whose fat is to be manipulated.
- * cn - which cluster is of interest
- * oldcontents - address of a word that is to receive the contents of the
- * cluster'th entry if this is a get function
- * newcontents - the new value to be written into the cluster'th element of
- * the fat if this is a set function.
- *
- * This function can also be used to free a cluster by setting the fat entry
- * for a cluster to 0.
- *
- * All copies of the fat are updated if this is a set function. NOTE: If
- * fatentry() marks a cluster as free it does not update the inusemap in
- * the msdosfsmount structure. This is left to the caller.
- */
-int
-fatentry(function, pmp, cn, oldcontents, newcontents)
- int function;
- struct msdosfsmount *pmp;
- u_long cn;
- u_long *oldcontents;
- u_long newcontents;
-{
- int error;
- u_long readcn;
- u_long bn, bo, bsize, byteoffset;
- struct buf *bp;
-
-#ifdef MSDOSFS_DEBUG
- printf("fatentry(func %d, pmp %p, clust %lu, oldcon %p, newcon %lx)\n",
- function, pmp, cn, oldcontents, newcontents);
-#endif
-
-#ifdef DIAGNOSTIC
- /*
- * Be sure they asked us to do something.
- */
- if ((function & (FAT_SET | FAT_GET)) == 0) {
- printf("fatentry(): function code doesn't specify get or set\n");
- return (EINVAL);
- }
-
- /*
- * If they asked us to return a cluster number but didn't tell us
- * where to put it, give them an error.
- */
- if ((function & FAT_GET) && oldcontents == NULL) {
- printf("fatentry(): get function with no place to put result\n");
- return (EINVAL);
- }
-#endif
-
- /*
- * Be sure the requested cluster is in the filesystem.
- */
- if (cn < CLUST_FIRST || cn > pmp->pm_maxcluster)
- return (EINVAL);
-
- byteoffset = FATOFS(pmp, cn);
- fatblock(pmp, byteoffset, &bn, &bsize, &bo);
- error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp);
- if (error) {
- brelse(bp);
- return (error);
- }
-
- if (function & FAT_GET) {
- if (FAT32(pmp))
- readcn = getulong(&bp->b_data[bo]);
- else
- readcn = getushort(&bp->b_data[bo]);
- if (FAT12(pmp) & (cn & 1))
- readcn >>= 4;
- readcn &= pmp->pm_fatmask;
- /* map reserved fat entries to same values for all fats */
- if ((readcn | ~pmp->pm_fatmask) >= CLUST_RSRVD)
- readcn |= ~pmp->pm_fatmask;
- *oldcontents = readcn;
- }
- if (function & FAT_SET) {
- switch (pmp->pm_fatmask) {
- case FAT12_MASK:
- readcn = getushort(&bp->b_data[bo]);
- if (cn & 1) {
- readcn &= 0x000f;
- readcn |= newcontents << 4;
- } else {
- readcn &= 0xf000;
- readcn |= newcontents & 0xfff;
- }
- putushort(&bp->b_data[bo], readcn);
- break;
- case FAT16_MASK:
- putushort(&bp->b_data[bo], newcontents);
- break;
- case FAT32_MASK:
- /*
- * According to spec we have to retain the
- * high order bits of the fat entry.
- */
- readcn = getulong(&bp->b_data[bo]);
- readcn &= ~FAT32_MASK;
- readcn |= newcontents & FAT32_MASK;
- putulong(&bp->b_data[bo], readcn);
- break;
- }
- updatefats(pmp, bp, bn);
- bp = NULL;
- pmp->pm_fmod = 1;
- }
- if (bp)
- brelse(bp);
- return (0);
-}
-
-/*
- * Update a contiguous cluster chain
- *
- * pmp - mount point
- * start - first cluster of chain
- * count - number of clusters in chain
- * fillwith - what to write into fat entry of last cluster
- */
-static int
-fatchain(pmp, start, count, fillwith)
- struct msdosfsmount *pmp;
- u_long start;
- u_long count;
- u_long fillwith;
-{
- int error;
- u_long bn, bo, bsize, byteoffset, readcn, newc;
- struct buf *bp;
-
-#ifdef MSDOSFS_DEBUG
- printf("fatchain(pmp %p, start %lu, count %lu, fillwith %lx)\n",
- pmp, start, count, fillwith);
-#endif
- /*
- * Be sure the clusters are in the filesystem.
- */
- if (start < CLUST_FIRST || start + count - 1 > pmp->pm_maxcluster)
- return (EINVAL);
-
- while (count > 0) {
- byteoffset = FATOFS(pmp, start);
- fatblock(pmp, byteoffset, &bn, &bsize, &bo);
- error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp);
- if (error) {
- brelse(bp);
- return (error);
- }
- while (count > 0) {
- start++;
- newc = --count > 0 ? start : fillwith;
- switch (pmp->pm_fatmask) {
- case FAT12_MASK:
- readcn = getushort(&bp->b_data[bo]);
- if (start & 1) {
- readcn &= 0xf000;
- readcn |= newc & 0xfff;
- } else {
- readcn &= 0x000f;
- readcn |= newc << 4;
- }
- putushort(&bp->b_data[bo], readcn);
- bo++;
- if (!(start & 1))
- bo++;
- break;
- case FAT16_MASK:
- putushort(&bp->b_data[bo], newc);
- bo += 2;
- break;
- case FAT32_MASK:
- readcn = getulong(&bp->b_data[bo]);
- readcn &= ~pmp->pm_fatmask;
- readcn |= newc & pmp->pm_fatmask;
- putulong(&bp->b_data[bo], readcn);
- bo += 4;
- break;
- }
- if (bo >= bsize)
- break;
- }
- updatefats(pmp, bp, bn);
- }
- pmp->pm_fmod = 1;
- return (0);
-}
-
-/*
- * Check the length of a free cluster chain starting at start.
- *
- * pmp - mount point
- * start - start of chain
- * count - maximum interesting length
- */
-static int
-chainlength(pmp, start, count)
- struct msdosfsmount *pmp;
- u_long start;
- u_long count;
-{
- u_long idx, max_idx;
- u_int map;
- u_long len;
-
- max_idx = pmp->pm_maxcluster / N_INUSEBITS;
- idx = start / N_INUSEBITS;
- start %= N_INUSEBITS;
- map = pmp->pm_inusemap[idx];
- map &= ~((1 << start) - 1);
- if (map) {
- len = ffs(map) - 1 - start;
- return (len > count ? count : len);
- }
- len = N_INUSEBITS - start;
- if (len >= count)
- return (count);
- while (++idx <= max_idx) {
- if (len >= count)
- break;
- map = pmp->pm_inusemap[idx];
- if (map) {
- len += ffs(map) - 1;
- break;
- }
- len += N_INUSEBITS;
- }
- return (len > count ? count : len);
-}
-
-/*
- * Allocate contigous free clusters.
- *
- * pmp - mount point.
- * start - start of cluster chain.
- * count - number of clusters to allocate.
- * fillwith - put this value into the fat entry for the
- * last allocated cluster.
- * retcluster - put the first allocated cluster's number here.
- * got - how many clusters were actually allocated.
- */
-static int
-chainalloc(pmp, start, count, fillwith, retcluster, got)
- struct msdosfsmount *pmp;
- u_long start;
- u_long count;
- u_long fillwith;
- u_long *retcluster;
- u_long *got;
-{
- int error;
- u_long cl, n;
-
- for (cl = start, n = count; n-- > 0;)
- usemap_alloc(pmp, cl++);
-
- error = fatchain(pmp, start, count, fillwith);
- if (error != 0)
- return (error);
-#ifdef MSDOSFS_DEBUG
- printf("clusteralloc(): allocated cluster chain at %lu (%lu clusters)\n",
- start, count);
-#endif
- if (retcluster)
- *retcluster = start;
- if (got)
- *got = count;
- return (0);
-}
-
-/*
- * Allocate contiguous free clusters.
- *
- * pmp - mount point.
- * start - preferred start of cluster chain.
- * count - number of clusters requested.
- * fillwith - put this value into the fat entry for the
- * last allocated cluster.
- * retcluster - put the first allocated cluster's number here.
- * got - how many clusters were actually allocated.
- */
-int
-clusteralloc(pmp, start, count, fillwith, retcluster, got)
- struct msdosfsmount *pmp;
- u_long start;
- u_long count;
- u_long fillwith;
- u_long *retcluster;
- u_long *got;
-{
- u_long idx;
- u_long len, newst, foundl, cn, l;
- u_long foundcn = 0; /* XXX: foundcn could be used unititialized */
- u_int map;
-
-#ifdef MSDOSFS_DEBUG
- printf("clusteralloc(): find %lu clusters\n",count);
-#endif
- if (start) {
- if ((len = chainlength(pmp, start, count)) >= count)
- return (chainalloc(pmp, start, count, fillwith, retcluster, got));
- } else
- len = 0;
-
- /*
- * Start at a (pseudo) random place to maximize cluster runs
- * under multiple writers.
- */
- newst = random() % (pmp->pm_maxcluster + 1);
- foundl = 0;
-
- for (cn = newst; cn <= pmp->pm_maxcluster;) {
- idx = cn / N_INUSEBITS;
- map = pmp->pm_inusemap[idx];
- map |= (1 << (cn % N_INUSEBITS)) - 1;
- if (map != (u_int)-1) {
- cn = idx * N_INUSEBITS + ffs(map^(u_int)-1) - 1;
- if ((l = chainlength(pmp, cn, count)) >= count)
- return (chainalloc(pmp, cn, count, fillwith, retcluster, got));
- if (l > foundl) {
- foundcn = cn;
- foundl = l;
- }
- cn += l + 1;
- continue;
- }
- cn += N_INUSEBITS - cn % N_INUSEBITS;
- }
- for (cn = 0; cn < newst;) {
- idx = cn / N_INUSEBITS;
- map = pmp->pm_inusemap[idx];
- map |= (1 << (cn % N_INUSEBITS)) - 1;
- if (map != (u_int)-1) {
- cn = idx * N_INUSEBITS + ffs(map^(u_int)-1) - 1;
- if ((l = chainlength(pmp, cn, count)) >= count)
- return (chainalloc(pmp, cn, count, fillwith, retcluster, got));
- if (l > foundl) {
- foundcn = cn;
- foundl = l;
- }
- cn += l + 1;
- continue;
- }
- cn += N_INUSEBITS - cn % N_INUSEBITS;
- }
-
- if (!foundl)
- return (ENOSPC);
-
- if (len)
- return (chainalloc(pmp, start, len, fillwith, retcluster, got));
- else
- return (chainalloc(pmp, foundcn, foundl, fillwith, retcluster, got));
-}
-
-
-/*
- * Free a chain of clusters.
- *
- * pmp - address of the msdosfs mount structure for the filesystem
- * containing the cluster chain to be freed.
- * startcluster - number of the 1st cluster in the chain of clusters to be
- * freed.
- */
-int
-freeclusterchain(pmp, cluster)
- struct msdosfsmount *pmp;
- u_long cluster;
-{
- int error;
- struct buf *bp = NULL;
- u_long bn, bo, bsize, byteoffset;
- u_long readcn, lbn = -1;
-
- while (cluster >= CLUST_FIRST && cluster <= pmp->pm_maxcluster) {
- byteoffset = FATOFS(pmp, cluster);
- fatblock(pmp, byteoffset, &bn, &bsize, &bo);
- if (lbn != bn) {
- if (bp)
- updatefats(pmp, bp, lbn);
- error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp);
- if (error) {
- brelse(bp);
- return (error);
- }
- lbn = bn;
- }
- usemap_free(pmp, cluster);
- switch (pmp->pm_fatmask) {
- case FAT12_MASK:
- readcn = getushort(&bp->b_data[bo]);
- if (cluster & 1) {
- cluster = readcn >> 4;
- readcn &= 0x000f;
- readcn |= MSDOSFSFREE << 4;
- } else {
- cluster = readcn;
- readcn &= 0xf000;
- readcn |= MSDOSFSFREE & 0xfff;
- }
- putushort(&bp->b_data[bo], readcn);
- break;
- case FAT16_MASK:
- cluster = getushort(&bp->b_data[bo]);
- putushort(&bp->b_data[bo], MSDOSFSFREE);
- break;
- case FAT32_MASK:
- cluster = getulong(&bp->b_data[bo]);
- putulong(&bp->b_data[bo],
- (MSDOSFSFREE & FAT32_MASK) | (cluster & ~FAT32_MASK));
- break;
- }
- cluster &= pmp->pm_fatmask;
- if ((cluster | ~pmp->pm_fatmask) >= CLUST_RSRVD)
- cluster |= pmp->pm_fatmask;
- }
- if (bp)
- updatefats(pmp, bp, bn);
- return (0);
-}
-
-/*
- * Read in fat blocks looking for free clusters. For every free cluster
- * found turn off its corresponding bit in the pm_inusemap.
- */
-int
-fillinusemap(pmp)
- struct msdosfsmount *pmp;
-{
- struct buf *bp = NULL;
- u_long cn, readcn;
- int error;
- u_long bn, bo, bsize, byteoffset;
-
- /*
- * Mark all clusters in use, we mark the free ones in the fat scan
- * loop further down.
- */
- for (cn = 0; cn < (pmp->pm_maxcluster + N_INUSEBITS) / N_INUSEBITS; cn++)
- pmp->pm_inusemap[cn] = (u_int)-1;
-
- /*
- * Figure how many free clusters are in the filesystem by ripping
- * through the fat counting the number of entries whose content is
- * zero. These represent free clusters.
- */
- pmp->pm_freeclustercount = 0;
- for (cn = CLUST_FIRST; cn <= pmp->pm_maxcluster; cn++) {
- byteoffset = FATOFS(pmp, cn);
- bo = byteoffset % pmp->pm_fatblocksize;
- if (!bo || !bp) {
- /* Read new FAT block */
- if (bp)
- brelse(bp);
- fatblock(pmp, byteoffset, &bn, &bsize, NULL);
- error = bread(pmp->pm_devvp, bn, bsize, NOCRED, &bp);
- if (error) {
- brelse(bp);
- return (error);
- }
- }
- if (FAT32(pmp))
- readcn = getulong(&bp->b_data[bo]);
- else
- readcn = getushort(&bp->b_data[bo]);
- if (FAT12(pmp) && (cn & 1))
- readcn >>= 4;
- readcn &= pmp->pm_fatmask;
-
- if (readcn == 0)
- usemap_free(pmp, cn);
- }
- brelse(bp);
- return (0);
-}
-
-/*
- * Allocate a new cluster and chain it onto the end of the file.
- *
- * dep - the file to extend
- * count - number of clusters to allocate
- * bpp - where to return the address of the buf header for the first new
- * file block
- * ncp - where to put cluster number of the first newly allocated cluster
- * If this pointer is 0, do not return the cluster number.
- * flags - see fat.h
- *
- * NOTE: This function is not responsible for turning on the DE_UPDATE bit of
- * the de_flag field of the denode and it does not change the de_FileSize
- * field. This is left for the caller to do.
- */
-int
-extendfile(dep, count, bpp, ncp, flags)
- struct denode *dep;
- u_long count;
- struct buf **bpp;
- u_long *ncp;
- int flags;
-{
- int error;
- u_long frcn;
- u_long cn, got;
- struct msdosfsmount *pmp = dep->de_pmp;
- struct buf *bp;
-
- /*
- * Don't try to extend the root directory
- */
- if (dep->de_StartCluster == MSDOSFSROOT
- && (dep->de_Attributes & ATTR_DIRECTORY)) {
- printf("extendfile(): attempt to extend root directory\n");
- return (ENOSPC);
- }
-
- /*
- * If the "file's last cluster" cache entry is empty, and the file
- * is not empty, then fill the cache entry by calling pcbmap().
- */
- fc_fileextends++;
- if (dep->de_fc[FC_LASTFC].fc_frcn == FCE_EMPTY &&
- dep->de_StartCluster != 0) {
- fc_lfcempty++;
- error = pcbmap(dep, 0xffff, 0, &cn, 0);
- /* we expect it to return E2BIG */
- if (error != E2BIG)
- return (error);
- }
-
- while (count > 0) {
- /*
- * Allocate a new cluster chain and cat onto the end of the
- * file. * If the file is empty we make de_StartCluster point
- * to the new block. Note that de_StartCluster being 0 is
- * sufficient to be sure the file is empty since we exclude
- * attempts to extend the root directory above, and the root
- * dir is the only file with a startcluster of 0 that has
- * blocks allocated (sort of).
- */
- if (dep->de_StartCluster == 0)
- cn = 0;
- else
- cn = dep->de_fc[FC_LASTFC].fc_fsrcn + 1;
- error = clusteralloc(pmp, cn, count, CLUST_EOFE, &cn, &got);
- if (error)
- return (error);
-
- count -= got;
-
- /*
- * Give them the filesystem relative cluster number if they want
- * it.
- */
- if (ncp) {
- *ncp = cn;
- ncp = NULL;
- }
-
- if (dep->de_StartCluster == 0) {
- dep->de_StartCluster = cn;
- frcn = 0;
- } else {
- error = fatentry(FAT_SET, pmp,
- dep->de_fc[FC_LASTFC].fc_fsrcn,
- 0, cn);
- if (error) {
- clusterfree(pmp, cn, NULL);
- return (error);
- }
- frcn = dep->de_fc[FC_LASTFC].fc_frcn + 1;
- }
-
- /*
- * Update the "last cluster of the file" entry in the denode's fat
- * cache.
- */
- fc_setcache(dep, FC_LASTFC, frcn + got - 1, cn + got - 1);
-
- if (flags & DE_CLEAR) {
- while (got-- > 0) {
- /*
- * Get the buf header for the new block of the file.
- */
- if (dep->de_Attributes & ATTR_DIRECTORY)
- bp = getblk(pmp->pm_devvp, cntobn(pmp, cn++),
- pmp->pm_bpcluster, 0, 0);
- else {
- bp = getblk(DETOV(dep), de_cn2bn(pmp, frcn++),
- pmp->pm_bpcluster, 0, 0);
- /*
- * Do the bmap now, as in msdosfs_write
- */
- if (pcbmap(dep,
- de_bn2cn(pmp, bp->b_lblkno),
- &bp->b_blkno, 0, 0))
- bp->b_blkno = -1;
- if (bp->b_blkno == -1)
- panic("extendfile: pcbmap");
- }
- clrbuf(bp);
- if (bpp) {
- *bpp = bp;
- bpp = NULL;
- } else
- bdwrite(bp);
- }
- }
- }
-
- return (0);
-}
diff --git a/sys/fs/msdosfs/msdosfs_lookup.c b/sys/fs/msdosfs/msdosfs_lookup.c
deleted file mode 100644
index 95e8e898ad30..000000000000
--- a/sys/fs/msdosfs/msdosfs_lookup.c
+++ /dev/null
@@ -1,1085 +0,0 @@
-/* $FreeBSD$ */
-/* $NetBSD: msdosfs_lookup.c,v 1.37 1997/11/17 15:36:54 ws Exp $ */
-
-/*-
- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
- * Copyright (C) 1994, 1995, 1997 TooLs GmbH.
- * All rights reserved.
- * Original code by Paul Popelka (paulp@uts.amdahl.com) (see below).
- *
- * 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 TooLs GmbH.
- * 4. The name of TooLs GmbH may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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.
- */
-/*
- * Written by Paul Popelka (paulp@uts.amdahl.com)
- *
- * You can do anything you want with this software, just don't say you wrote
- * it, and don't remove this notice.
- *
- * This software is provided "as is".
- *
- * The author supplies this software to be publicly redistributed on the
- * understanding that the author is not responsible for the correct
- * functioning of this software in any circumstances and is not liable for
- * any damages caused by this software.
- *
- * October 1992
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/namei.h>
-#include <sys/buf.h>
-#include <sys/vnode.h>
-#include <sys/mount.h>
-
-#include <msdosfs/bpb.h>
-#include <msdosfs/direntry.h>
-#include <msdosfs/denode.h>
-#include <msdosfs/msdosfsmount.h>
-#include <msdosfs/fat.h>
-
-/*
- * When we search a directory the blocks containing directory entries are
- * read and examined. The directory entries contain information that would
- * normally be in the inode of a unix filesystem. This means that some of
- * a directory's contents may also be in memory resident denodes (sort of
- * an inode). This can cause problems if we are searching while some other
- * process is modifying a directory. To prevent one process from accessing
- * incompletely modified directory information we depend upon being the
- * sole owner of a directory block. bread/brelse provide this service.
- * This being the case, when a process modifies a directory it must first
- * acquire the disk block that contains the directory entry to be modified.
- * Then update the disk block and the denode, and then write the disk block
- * out to disk. This way disk blocks containing directory entries and in
- * memory denode's will be in synch.
- */
-int
-msdosfs_lookup(ap)
- struct vop_cachedlookup_args /* {
- struct vnode *a_dvp;
- struct vnode **a_vpp;
- struct componentname *a_cnp;
- } */ *ap;
-{
- struct vnode *vdp = ap->a_dvp;
- struct vnode **vpp = ap->a_vpp;
- struct componentname *cnp = ap->a_cnp;
- daddr_t bn;
- int error;
- int lockparent;
- int wantparent;
- int slotcount;
- int slotoffset = 0;
- int frcn;
- u_long cluster;
- int blkoff;
- int diroff;
- int blsize;
- int isadir; /* ~0 if found direntry is a directory */
- u_long scn; /* starting cluster number */
- struct vnode *pdp;
- struct denode *dp;
- struct denode *tdp;
- struct msdosfsmount *pmp;
- struct buf *bp = 0;
- struct direntry *dep = NULL;
- u_char dosfilename[12];
- int flags = cnp->cn_flags;
- int nameiop = cnp->cn_nameiop;
- struct proc *p = cnp->cn_proc;
- int unlen;
-
- int wincnt = 1;
- int chksum = -1;
- int olddos = 1;
-
-#ifdef MSDOSFS_DEBUG
- printf("msdosfs_lookup(): looking for %s\n", cnp->cn_nameptr);
-#endif
- dp = VTODE(vdp);
- pmp = dp->de_pmp;
- *vpp = NULL;
- lockparent = flags & LOCKPARENT;
- wantparent = flags & (LOCKPARENT | WANTPARENT);
-#ifdef MSDOSFS_DEBUG
- printf("msdosfs_lookup(): vdp %p, dp %p, Attr %02x\n",
- vdp, dp, dp->de_Attributes);
-#endif
-
- /*
- * If they are going after the . or .. entry in the root directory,
- * they won't find it. DOS filesystems don't have them in the root
- * directory. So, we fake it. deget() is in on this scam too.
- */
- if ((vdp->v_flag & VROOT) && cnp->cn_nameptr[0] == '.' &&
- (cnp->cn_namelen == 1 ||
- (cnp->cn_namelen == 2 && cnp->cn_nameptr[1] == '.'))) {
- isadir = ATTR_DIRECTORY;
- scn = MSDOSFSROOT;
-#ifdef MSDOSFS_DEBUG
- printf("msdosfs_lookup(): looking for . or .. in root directory\n");
-#endif
- cluster = MSDOSFSROOT;
- blkoff = MSDOSFSROOT_OFS;
- goto foundroot;
- }
-
- switch (unix2dosfn((const u_char *)cnp->cn_nameptr, dosfilename,
- cnp->cn_namelen, 0,
- pmp->pm_flags & MSDOSFSMNT_U2WTABLE, pmp->pm_u2d,
- pmp->pm_flags & MSDOSFSMNT_ULTABLE, pmp->pm_lu)) {
- case 0:
- return (EINVAL);
- case 1:
- break;
- case 2:
- wincnt = winSlotCnt((const u_char *)cnp->cn_nameptr,
- cnp->cn_namelen) + 1;
- break;
- case 3:
- olddos = 0;
- wincnt = winSlotCnt((const u_char *)cnp->cn_nameptr,
- cnp->cn_namelen) + 1;
- break;
- }
- if (pmp->pm_flags & MSDOSFSMNT_SHORTNAME) {
- wincnt = 1;
- olddos = 1;
- }
- unlen = winLenFixup(cnp->cn_nameptr, cnp->cn_namelen);
-
- /*
- * Suppress search for slots unless creating
- * file and at end of pathname, in which case
- * we watch for a place to put the new file in
- * case it doesn't already exist.
- */
- slotcount = wincnt;
- if ((nameiop == CREATE || nameiop == RENAME) &&
- (flags & ISLASTCN))
- slotcount = 0;
-
-#ifdef MSDOSFS_DEBUG
- printf("msdosfs_lookup(): dos version of filename %s, length %ld\n",
- dosfilename, cnp->cn_namelen);
-#endif
- /*
- * Search the directory pointed at by vdp for the name pointed at
- * by cnp->cn_nameptr.
- */
- tdp = NULL;
- /*
- * The outer loop ranges over the clusters that make up the
- * directory. Note that the root directory is different from all
- * other directories. It has a fixed number of blocks that are not
- * part of the pool of allocatable clusters. So, we treat it a
- * little differently. The root directory starts at "cluster" 0.
- */
- diroff = 0;
- for (frcn = 0;; frcn++) {
- error = pcbmap(dp, frcn, &bn, &cluster, &blsize);
- if (error) {
- if (error == E2BIG)
- break;
- return (error);
- }
- error = bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp);
- if (error) {
- brelse(bp);
- return (error);
- }
- for (blkoff = 0; blkoff < blsize;
- blkoff += sizeof(struct direntry),
- diroff += sizeof(struct direntry)) {
- dep = (struct direntry *)(bp->b_data + blkoff);
- /*
- * If the slot is empty and we are still looking
- * for an empty then remember this one. If the
- * slot is not empty then check to see if it
- * matches what we are looking for. If the slot
- * has never been filled with anything, then the
- * remainder of the directory has never been used,
- * so there is no point in searching it.
- */
- if (dep->deName[0] == SLOT_EMPTY ||
- dep->deName[0] == SLOT_DELETED) {
- /*
- * Drop memory of previous long matches
- */
- chksum = -1;
-
- if (slotcount < wincnt) {
- slotcount++;
- slotoffset = diroff;
- }
- if (dep->deName[0] == SLOT_EMPTY) {
- brelse(bp);
- goto notfound;
- }
- } else {
- /*
- * If there wasn't enough space for our winentries,
- * forget about the empty space
- */
- if (slotcount < wincnt)
- slotcount = 0;
-
- /*
- * Check for Win95 long filename entry
- */
- if (dep->deAttributes == ATTR_WIN95) {
- if (pmp->pm_flags & MSDOSFSMNT_SHORTNAME)
- continue;
-
- chksum = winChkName((const u_char *)cnp->cn_nameptr,
- unlen,
- (struct winentry *)dep,
- chksum,
- pmp->pm_flags & MSDOSFSMNT_U2WTABLE,
- pmp->pm_u2w,
- pmp->pm_flags & MSDOSFSMNT_ULTABLE,
- pmp->pm_ul);
- continue;
- }
-
- /*
- * Ignore volume labels (anywhere, not just
- * the root directory).
- */
- if (dep->deAttributes & ATTR_VOLUME) {
- chksum = -1;
- continue;
- }
-
- /*
- * Check for a checksum or name match
- */
- if (chksum != winChksum(dep->deName)
- && (!olddos || bcmp(dosfilename, dep->deName, 11))) {
- chksum = -1;
- continue;
- }
-#ifdef MSDOSFS_DEBUG
- printf("msdosfs_lookup(): match blkoff %d, diroff %d\n",
- blkoff, diroff);
-#endif
- /*
- * Remember where this directory
- * entry came from for whoever did
- * this lookup.
- */
- dp->de_fndoffset = diroff;
- dp->de_fndcnt = wincnt - 1;
-
- goto found;
- }
- } /* for (blkoff = 0; .... */
- /*
- * Release the buffer holding the directory cluster just
- * searched.
- */
- brelse(bp);
- } /* for (frcn = 0; ; frcn++) */
-
-notfound:
- /*
- * We hold no disk buffers at this point.
- */
-
- /*
- * Fixup the slot description to point to the place where
- * we might put the new DOS direntry (putting the Win95
- * long name entries before that)
- */
- if (!slotcount) {
- slotcount = 1;
- slotoffset = diroff;
- }
- if (wincnt > slotcount)
- slotoffset += sizeof(struct direntry) * (wincnt - slotcount);
-
- /*
- * If we get here we didn't find the entry we were looking for. But
- * that's ok if we are creating or renaming and are at the end of
- * the pathname and the directory hasn't been removed.
- */
-#ifdef MSDOSFS_DEBUG
- printf("msdosfs_lookup(): op %d, refcnt %ld\n",
- nameiop, dp->de_refcnt);
- printf(" slotcount %d, slotoffset %d\n",
- slotcount, slotoffset);
-#endif
- if ((nameiop == CREATE || nameiop == RENAME) &&
- (flags & ISLASTCN) && dp->de_refcnt != 0) {
- /*
- * Access for write is interpreted as allowing
- * creation of files in the directory.
- */
- error = VOP_ACCESS(vdp, VWRITE, cnp->cn_cred, cnp->cn_proc);
- if (error)
- return (error);
- /*
- * Return an indication of where the new directory
- * entry should be put.
- */
- dp->de_fndoffset = slotoffset;
- dp->de_fndcnt = wincnt - 1;
-
- /*
- * We return with the directory locked, so that
- * the parameters we set up above will still be
- * valid if we actually decide to do a direnter().
- * We return ni_vp == NULL to indicate that the entry
- * does not currently exist; we leave a pointer to
- * the (locked) directory inode in ndp->ni_dvp.
- * The pathname buffer is saved so that the name
- * can be obtained later.
- *
- * NB - if the directory is unlocked, then this
- * information cannot be used.
- */
- cnp->cn_flags |= SAVENAME;
- if (!lockparent)
- VOP_UNLOCK(vdp, 0, p);
- return (EJUSTRETURN);
- }
- /*
- * Insert name into cache (as non-existent) if appropriate.
- */
- if ((cnp->cn_flags & MAKEENTRY) && nameiop != CREATE)
- cache_enter(vdp, *vpp, cnp);
- return (ENOENT);
-
-found:
- /*
- * NOTE: We still have the buffer with matched directory entry at
- * this point.
- */
- isadir = dep->deAttributes & ATTR_DIRECTORY;
- scn = getushort(dep->deStartCluster);
- if (FAT32(pmp)) {
- scn |= getushort(dep->deHighClust) << 16;
- if (scn == pmp->pm_rootdirblk) {
- /*
- * There should actually be 0 here.
- * Just ignore the error.
- */
- scn = MSDOSFSROOT;
- }
- }
-
- if (isadir) {
- cluster = scn;
- if (cluster == MSDOSFSROOT)
- blkoff = MSDOSFSROOT_OFS;
- else
- blkoff = 0;
- } else if (cluster == MSDOSFSROOT)
- blkoff = diroff;
-
- /*
- * Now release buf to allow deget to read the entry again.
- * Reserving it here and giving it to deget could result
- * in a deadlock.
- */
- brelse(bp);
- bp = 0;
-
-foundroot:
- /*
- * If we entered at foundroot, then we are looking for the . or ..
- * entry of the filesystems root directory. isadir and scn were
- * setup before jumping here. And, bp is already null.
- */
- if (FAT32(pmp) && scn == MSDOSFSROOT)
- scn = pmp->pm_rootdirblk;
-
- /*
- * If deleting, and at end of pathname, return
- * parameters which can be used to remove file.
- * If the wantparent flag isn't set, we return only
- * the directory (in ndp->ni_dvp), otherwise we go
- * on and lock the inode, being careful with ".".
- */
- if (nameiop == DELETE && (flags & ISLASTCN)) {
- /*
- * Don't allow deleting the root.
- */
- if (blkoff == MSDOSFSROOT_OFS)
- return EROFS; /* really? XXX */
-
- /*
- * Write access to directory required to delete files.
- */
- error = VOP_ACCESS(vdp, VWRITE, cnp->cn_cred, cnp->cn_proc);
- if (error)
- return (error);
-
- /*
- * Return pointer to current entry in dp->i_offset.
- * Save directory inode pointer in ndp->ni_dvp for dirremove().
- */
- if (dp->de_StartCluster == scn && isadir) { /* "." */
- VREF(vdp);
- *vpp = vdp;
- return (0);
- }
- error = deget(pmp, cluster, blkoff, &tdp);
- if (error)
- return (error);
- *vpp = DETOV(tdp);
- if (!lockparent)
- VOP_UNLOCK(vdp, 0, p);
- return (0);
- }
-
- /*
- * If rewriting (RENAME), return the inode and the
- * information required to rewrite the present directory
- * Must get inode of directory entry to verify it's a
- * regular file, or empty directory.
- */
- if (nameiop == RENAME && wantparent &&
- (flags & ISLASTCN)) {
- if (blkoff == MSDOSFSROOT_OFS)
- return EROFS; /* really? XXX */
-
- error = VOP_ACCESS(vdp, VWRITE, cnp->cn_cred, cnp->cn_proc);
- if (error)
- return (error);
-
- /*
- * Careful about locking second inode.
- * This can only occur if the target is ".".
- */
- if (dp->de_StartCluster == scn && isadir)
- return (EISDIR);
-
- if ((error = deget(pmp, cluster, blkoff, &tdp)) != 0)
- return (error);
- *vpp = DETOV(tdp);
- cnp->cn_flags |= SAVENAME;
- if (!lockparent)
- VOP_UNLOCK(vdp, 0, p);
- return (0);
- }
-
- /*
- * Step through the translation in the name. We do not `vput' the
- * directory because we may need it again if a symbolic link
- * is relative to the current directory. Instead we save it
- * unlocked as "pdp". We must get the target inode before unlocking
- * the directory to insure that the inode will not be removed
- * before we get it. We prevent deadlock by always fetching
- * inodes from the root, moving down the directory tree. Thus
- * when following backward pointers ".." we must unlock the
- * parent directory before getting the requested directory.
- * There is a potential race condition here if both the current
- * and parent directories are removed before the VFS_VGET for the
- * inode associated with ".." returns. We hope that this occurs
- * infrequently since we cannot avoid this race condition without
- * implementing a sophisticated deadlock detection algorithm.
- * Note also that this simple deadlock detection scheme will not
- * work if the file system has any hard links other than ".."
- * that point backwards in the directory structure.
- */
- pdp = vdp;
- if (flags & ISDOTDOT) {
- VOP_UNLOCK(pdp, 0, p);
- error = deget(pmp, cluster, blkoff, &tdp);
- if (error) {
- vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY, p);
- return (error);
- }
- if (lockparent && (flags & ISLASTCN) &&
- (error = vn_lock(pdp, LK_EXCLUSIVE, p))) {
- vput(DETOV(tdp));
- return (error);
- }
- *vpp = DETOV(tdp);
- } else if (dp->de_StartCluster == scn && isadir) {
- VREF(vdp); /* we want ourself, ie "." */
- *vpp = vdp;
- } else {
- if ((error = deget(pmp, cluster, blkoff, &tdp)) != 0)
- return (error);
- if (!lockparent || !(flags & ISLASTCN))
- VOP_UNLOCK(pdp, 0, p);
- *vpp = DETOV(tdp);
- }
-
- /*
- * Insert name into cache if appropriate.
- */
- if (cnp->cn_flags & MAKEENTRY)
- cache_enter(vdp, *vpp, cnp);
- return (0);
-}
-
-/*
- * dep - directory entry to copy into the directory
- * ddep - directory to add to
- * depp - return the address of the denode for the created directory entry
- * if depp != 0
- * cnp - componentname needed for Win95 long filenames
- */
-int
-createde(dep, ddep, depp, cnp)
- struct denode *dep;
- struct denode *ddep;
- struct denode **depp;
- struct componentname *cnp;
-{
- int error;
- u_long dirclust, diroffset;
- struct direntry *ndep;
- struct msdosfsmount *pmp = ddep->de_pmp;
- struct buf *bp;
- daddr_t bn;
- int blsize;
-
-#ifdef MSDOSFS_DEBUG
- printf("createde(dep %p, ddep %p, depp %p, cnp %p)\n",
- dep, ddep, depp, cnp);
-#endif
-
- /*
- * If no space left in the directory then allocate another cluster
- * and chain it onto the end of the file. There is one exception
- * to this. That is, if the root directory has no more space it
- * can NOT be expanded. extendfile() checks for and fails attempts
- * to extend the root directory. We just return an error in that
- * case.
- */
- if (ddep->de_fndoffset >= ddep->de_FileSize) {
- diroffset = ddep->de_fndoffset + sizeof(struct direntry)
- - ddep->de_FileSize;
- dirclust = de_clcount(pmp, diroffset);
- error = extendfile(ddep, dirclust, 0, 0, DE_CLEAR);
- if (error) {
- (void)detrunc(ddep, ddep->de_FileSize, 0, NOCRED, NULL);
- return error;
- }
-
- /*
- * Update the size of the directory
- */
- ddep->de_FileSize += de_cn2off(pmp, dirclust);
- }
-
- /*
- * We just read in the cluster with space. Copy the new directory
- * entry in. Then write it to disk. NOTE: DOS directories
- * do not get smaller as clusters are emptied.
- */
- error = pcbmap(ddep, de_cluster(pmp, ddep->de_fndoffset),
- &bn, &dirclust, &blsize);
- if (error)
- return error;
- diroffset = ddep->de_fndoffset;
- if (dirclust != MSDOSFSROOT)
- diroffset &= pmp->pm_crbomask;
- if ((error = bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp)) != 0) {
- brelse(bp);
- return error;
- }
- ndep = bptoep(pmp, bp, ddep->de_fndoffset);
-
- DE_EXTERNALIZE(ndep, dep);
-
- /*
- * Now write the Win95 long name
- */
- if (ddep->de_fndcnt > 0) {
- u_int8_t chksum = winChksum(ndep->deName);
- const u_char *un = (const u_char *)cnp->cn_nameptr;
- int unlen = cnp->cn_namelen;
- int cnt = 1;
-
- while (--ddep->de_fndcnt >= 0) {
- if (!(ddep->de_fndoffset & pmp->pm_crbomask)) {
- if ((error = bwrite(bp)) != 0)
- return error;
-
- ddep->de_fndoffset -= sizeof(struct direntry);
- error = pcbmap(ddep,
- de_cluster(pmp,
- ddep->de_fndoffset),
- &bn, 0, &blsize);
- if (error)
- return error;
-
- error = bread(pmp->pm_devvp, bn, blsize,
- NOCRED, &bp);
- if (error) {
- brelse(bp);
- return error;
- }
- ndep = bptoep(pmp, bp, ddep->de_fndoffset);
- } else {
- ndep--;
- ddep->de_fndoffset -= sizeof(struct direntry);
- }
- if (!unix2winfn(un, unlen, (struct winentry *)ndep,
- cnt++, chksum,
- pmp->pm_flags & MSDOSFSMNT_U2WTABLE,
- pmp->pm_u2w))
- break;
- }
- }
-
- if ((error = bwrite(bp)) != 0)
- return error;
-
- /*
- * If they want us to return with the denode gotten.
- */
- if (depp) {
- if (dep->de_Attributes & ATTR_DIRECTORY) {
- dirclust = dep->de_StartCluster;
- if (FAT32(pmp) && dirclust == pmp->pm_rootdirblk)
- dirclust = MSDOSFSROOT;
- if (dirclust == MSDOSFSROOT)
- diroffset = MSDOSFSROOT_OFS;
- else
- diroffset = 0;
- }
- return deget(pmp, dirclust, diroffset, depp);
- }
-
- return 0;
-}
-
-/*
- * Be sure a directory is empty except for "." and "..". Return 1 if empty,
- * return 0 if not empty or error.
- */
-int
-dosdirempty(dep)
- struct denode *dep;
-{
- int blsize;
- int error;
- u_long cn;
- daddr_t bn;
- struct buf *bp;
- struct msdosfsmount *pmp = dep->de_pmp;
- struct direntry *dentp;
-
- /*
- * Since the filesize field in directory entries for a directory is
- * zero, we just have to feel our way through the directory until
- * we hit end of file.
- */
- for (cn = 0;; cn++) {
- if ((error = pcbmap(dep, cn, &bn, 0, &blsize)) != 0) {
- if (error == E2BIG)
- return (1); /* it's empty */
- return (0);
- }
- error = bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp);
- if (error) {
- brelse(bp);
- return (0);
- }
- for (dentp = (struct direntry *)bp->b_data;
- (char *)dentp < bp->b_data + blsize;
- dentp++) {
- if (dentp->deName[0] != SLOT_DELETED &&
- (dentp->deAttributes & ATTR_VOLUME) == 0) {
- /*
- * In dos directories an entry whose name
- * starts with SLOT_EMPTY (0) starts the
- * beginning of the unused part of the
- * directory, so we can just return that it
- * is empty.
- */
- if (dentp->deName[0] == SLOT_EMPTY) {
- brelse(bp);
- return (1);
- }
- /*
- * Any names other than "." and ".." in a
- * directory mean it is not empty.
- */
- if (bcmp(dentp->deName, ". ", 11) &&
- bcmp(dentp->deName, ".. ", 11)) {
- brelse(bp);
-#ifdef MSDOSFS_DEBUG
- printf("dosdirempty(): entry found %02x, %02x\n",
- dentp->deName[0], dentp->deName[1]);
-#endif
- return (0); /* not empty */
- }
- }
- }
- brelse(bp);
- }
- /* NOTREACHED */
-}
-
-/*
- * Check to see if the directory described by target is in some
- * subdirectory of source. This prevents something like the following from
- * succeeding and leaving a bunch or files and directories orphaned. mv
- * /a/b/c /a/b/c/d/e/f Where c and f are directories.
- *
- * source - the inode for /a/b/c
- * target - the inode for /a/b/c/d/e/f
- *
- * Returns 0 if target is NOT a subdirectory of source.
- * Otherwise returns a non-zero error number.
- * The target inode is always unlocked on return.
- */
-int
-doscheckpath(source, target)
- struct denode *source;
- struct denode *target;
-{
- daddr_t scn;
- struct msdosfsmount *pmp;
- struct direntry *ep;
- struct denode *dep;
- struct buf *bp = NULL;
- int error = 0;
-
- dep = target;
- if ((target->de_Attributes & ATTR_DIRECTORY) == 0 ||
- (source->de_Attributes & ATTR_DIRECTORY) == 0) {
- error = ENOTDIR;
- goto out;
- }
- if (dep->de_StartCluster == source->de_StartCluster) {
- error = EEXIST;
- goto out;
- }
- if (dep->de_StartCluster == MSDOSFSROOT)
- goto out;
- pmp = dep->de_pmp;
-#ifdef DIAGNOSTIC
- if (pmp != source->de_pmp)
- panic("doscheckpath: source and target on different filesystems");
-#endif
- if (FAT32(pmp) && dep->de_StartCluster == pmp->pm_rootdirblk)
- goto out;
-
- for (;;) {
- if ((dep->de_Attributes & ATTR_DIRECTORY) == 0) {
- error = ENOTDIR;
- break;
- }
- scn = dep->de_StartCluster;
- error = bread(pmp->pm_devvp, cntobn(pmp, scn),
- pmp->pm_bpcluster, NOCRED, &bp);
- if (error)
- break;
-
- ep = (struct direntry *) bp->b_data + 1;
- if ((ep->deAttributes & ATTR_DIRECTORY) == 0 ||
- bcmp(ep->deName, ".. ", 11) != 0) {
- error = ENOTDIR;
- break;
- }
- scn = getushort(ep->deStartCluster);
- if (FAT32(pmp))
- scn |= getushort(ep->deHighClust) << 16;
-
- if (scn == source->de_StartCluster) {
- error = EINVAL;
- break;
- }
- if (scn == MSDOSFSROOT)
- break;
- if (FAT32(pmp) && scn == pmp->pm_rootdirblk) {
- /*
- * scn should be 0 in this case,
- * but we silently ignore the error.
- */
- break;
- }
-
- vput(DETOV(dep));
- brelse(bp);
- bp = NULL;
- /* NOTE: deget() clears dep on error */
- if ((error = deget(pmp, scn, 0, &dep)) != 0)
- break;
- }
-out:;
- if (bp)
- brelse(bp);
- if (error == ENOTDIR)
- printf("doscheckpath(): .. not a directory?\n");
- if (dep != NULL)
- vput(DETOV(dep));
- return (error);
-}
-
-/*
- * Read in the disk block containing the directory entry (dirclu, dirofs)
- * and return the address of the buf header, and the address of the
- * directory entry within the block.
- */
-int
-readep(pmp, dirclust, diroffset, bpp, epp)
- struct msdosfsmount *pmp;
- u_long dirclust, diroffset;
- struct buf **bpp;
- struct direntry **epp;
-{
- int error;
- daddr_t bn;
- int blsize;
-
- blsize = pmp->pm_bpcluster;
- if (dirclust == MSDOSFSROOT
- && de_blk(pmp, diroffset + blsize) > pmp->pm_rootdirsize)
- blsize = de_bn2off(pmp, pmp->pm_rootdirsize) & pmp->pm_crbomask;
- bn = detobn(pmp, dirclust, diroffset);
- if ((error = bread(pmp->pm_devvp, bn, blsize, NOCRED, bpp)) != 0) {
- brelse(*bpp);
- *bpp = NULL;
- return (error);
- }
- if (epp)
- *epp = bptoep(pmp, *bpp, diroffset);
- return (0);
-}
-
-/*
- * Read in the disk block containing the directory entry dep came from and
- * return the address of the buf header, and the address of the directory
- * entry within the block.
- */
-int
-readde(dep, bpp, epp)
- struct denode *dep;
- struct buf **bpp;
- struct direntry **epp;
-{
-
- return (readep(dep->de_pmp, dep->de_dirclust, dep->de_diroffset,
- bpp, epp));
-}
-
-/*
- * Remove a directory entry. At this point the file represented by the
- * directory entry to be removed is still full length until noone has it
- * open. When the file no longer being used msdosfs_inactive() is called
- * and will truncate the file to 0 length. When the vnode containing the
- * denode is needed for some other purpose by VFS it will call
- * msdosfs_reclaim() which will remove the denode from the denode cache.
- */
-int
-removede(pdep, dep)
- struct denode *pdep; /* directory where the entry is removed */
- struct denode *dep; /* file to be removed */
-{
- int error;
- struct direntry *ep;
- struct buf *bp;
- daddr_t bn;
- int blsize;
- struct msdosfsmount *pmp = pdep->de_pmp;
- u_long offset = pdep->de_fndoffset;
-
-#ifdef MSDOSFS_DEBUG
- printf("removede(): filename %s, dep %p, offset %08lx\n",
- dep->de_Name, dep, offset);
-#endif
-
- dep->de_refcnt--;
- offset += sizeof(struct direntry);
- do {
- offset -= sizeof(struct direntry);
- error = pcbmap(pdep, de_cluster(pmp, offset), &bn, 0, &blsize);
- if (error)
- return error;
- error = bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp);
- if (error) {
- brelse(bp);
- return error;
- }
- ep = bptoep(pmp, bp, offset);
- /*
- * Check whether, if we came here the second time, i.e.
- * when underflowing into the previous block, the last
- * entry in this block is a longfilename entry, too.
- */
- if (ep->deAttributes != ATTR_WIN95
- && offset != pdep->de_fndoffset) {
- brelse(bp);
- break;
- }
- offset += sizeof(struct direntry);
- while (1) {
- /*
- * We are a bit agressive here in that we delete any Win95
- * entries preceding this entry, not just the ones we "own".
- * Since these presumably aren't valid anyway,
- * there should be no harm.
- */
- offset -= sizeof(struct direntry);
- ep--->deName[0] = SLOT_DELETED;
- if ((pmp->pm_flags & MSDOSFSMNT_NOWIN95)
- || !(offset & pmp->pm_crbomask)
- || ep->deAttributes != ATTR_WIN95)
- break;
- }
- if ((error = bwrite(bp)) != 0)
- return error;
- } while (!(pmp->pm_flags & MSDOSFSMNT_NOWIN95)
- && !(offset & pmp->pm_crbomask)
- && offset);
- return 0;
-}
-
-/*
- * Create a unique DOS name in dvp
- */
-int
-uniqdosname(dep, cnp, cp)
- struct denode *dep;
- struct componentname *cnp;
- u_char *cp;
-{
- struct msdosfsmount *pmp = dep->de_pmp;
- struct direntry *dentp;
- int gen;
- int blsize;
- u_long cn;
- daddr_t bn;
- struct buf *bp;
- int error;
-
- if (pmp->pm_flags & MSDOSFSMNT_SHORTNAME)
- return (unix2dosfn((const u_char *)cnp->cn_nameptr, cp,
- cnp->cn_namelen, 0,
- pmp->pm_flags & MSDOSFSMNT_U2WTABLE, pmp->pm_u2d,
- pmp->pm_flags & MSDOSFSMNT_ULTABLE, pmp->pm_lu) ?
- 0 : EINVAL);
-
- for (gen = 1;; gen++) {
- /*
- * Generate DOS name with generation number
- */
- if (!unix2dosfn((const u_char *)cnp->cn_nameptr, cp,
- cnp->cn_namelen, gen,
- pmp->pm_flags & MSDOSFSMNT_U2WTABLE, pmp->pm_u2d,
- pmp->pm_flags & MSDOSFSMNT_ULTABLE, pmp->pm_lu))
- return gen == 1 ? EINVAL : EEXIST;
-
- /*
- * Now look for a dir entry with this exact name
- */
- for (cn = error = 0; !error; cn++) {
- if ((error = pcbmap(dep, cn, &bn, 0, &blsize)) != 0) {
- if (error == E2BIG) /* EOF reached and not found */
- return 0;
- return error;
- }
- error = bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp);
- if (error) {
- brelse(bp);
- return error;
- }
- for (dentp = (struct direntry *)bp->b_data;
- (char *)dentp < bp->b_data + blsize;
- dentp++) {
- if (dentp->deName[0] == SLOT_EMPTY) {
- /*
- * Last used entry and not found
- */
- brelse(bp);
- return 0;
- }
- /*
- * Ignore volume labels and Win95 entries
- */
- if (dentp->deAttributes & ATTR_VOLUME)
- continue;
- if (!bcmp(dentp->deName, cp, 11)) {
- error = EEXIST;
- break;
- }
- }
- brelse(bp);
- }
- }
-}
-
-/*
- * Find any Win'95 long filename entry in directory dep
- */
-int
-findwin95(dep)
- struct denode *dep;
-{
- struct msdosfsmount *pmp = dep->de_pmp;
- struct direntry *dentp;
- int blsize, win95;
- u_long cn;
- daddr_t bn;
- struct buf *bp;
-
- win95 = 1;
- /*
- * Read through the directory looking for Win'95 entries
- * Note: Error currently handled just as EOF XXX
- */
- for (cn = 0;; cn++) {
- if (pcbmap(dep, cn, &bn, 0, &blsize))
- return (win95);
- if (bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp)) {
- brelse(bp);
- return (win95);
- }
- for (dentp = (struct direntry *)bp->b_data;
- (char *)dentp < bp->b_data + blsize;
- dentp++) {
- if (dentp->deName[0] == SLOT_EMPTY) {
- /*
- * Last used entry and not found
- */
- brelse(bp);
- return (win95);
- }
- if (dentp->deName[0] == SLOT_DELETED) {
- /*
- * Ignore deleted files
- * Note: might be an indication of Win'95 anyway XXX
- */
- continue;
- }
- if (dentp->deAttributes == ATTR_WIN95) {
- brelse(bp);
- return 1;
- }
- win95 = 0;
- }
- brelse(bp);
- }
-}
diff --git a/sys/fs/msdosfs/msdosfs_vfsops.c b/sys/fs/msdosfs/msdosfs_vfsops.c
deleted file mode 100644
index 3c7b6b3c9f64..000000000000
--- a/sys/fs/msdosfs/msdosfs_vfsops.c
+++ /dev/null
@@ -1,986 +0,0 @@
-/* $FreeBSD$ */
-/* $NetBSD: msdosfs_vfsops.c,v 1.51 1997/11/17 15:36:58 ws Exp $ */
-
-/*-
- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
- * Copyright (C) 1994, 1995, 1997 TooLs GmbH.
- * All rights reserved.
- * Original code by Paul Popelka (paulp@uts.amdahl.com) (see below).
- *
- * 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 TooLs GmbH.
- * 4. The name of TooLs GmbH may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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.
- */
-/*
- * Written by Paul Popelka (paulp@uts.amdahl.com)
- *
- * You can do anything you want with this software, just don't say you wrote
- * it, and don't remove this notice.
- *
- * This software is provided "as is".
- *
- * The author supplies this software to be publicly redistributed on the
- * understanding that the author is not responsible for the correct
- * functioning of this software in any circumstances and is not liable for
- * any damages caused by this software.
- *
- * October 1992
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/conf.h>
-#include <sys/namei.h>
-#include <sys/proc.h>
-#include <sys/kernel.h>
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <sys/buf.h>
-#include <sys/fcntl.h>
-#include <sys/malloc.h>
-#include <sys/stat.h> /* defines ALLPERMS */
-#include <vm/vm_zone.h>
-
-#include <msdosfs/bpb.h>
-#include <msdosfs/bootsect.h>
-#include <msdosfs/direntry.h>
-#include <msdosfs/denode.h>
-#include <msdosfs/msdosfsmount.h>
-#include <msdosfs/fat.h>
-
-#if 1 /*def PC98*/
-/*
- * XXX - The boot signature formatted by NEC PC-98 DOS looks like a
- * garbage or a random value :-{
- * If you want to use that broken-signatured media, define the
- * following symbol even though PC/AT.
- * (ex. mount PC-98 DOS formatted FD on PC/AT)
- */
-#define MSDOSFS_NOCHECKSIG
-#endif
-
-MALLOC_DEFINE(M_MSDOSFSMNT, "MSDOSFS mount", "MSDOSFS mount structure");
-static MALLOC_DEFINE(M_MSDOSFSFAT, "MSDOSFS FAT", "MSDOSFS file allocation table");
-
-static int update_mp __P((struct mount *mp, struct msdosfs_args *argp));
-static int mountmsdosfs __P((struct vnode *devvp, struct mount *mp,
- struct proc *p, struct msdosfs_args *argp));
-static int msdosfs_fhtovp __P((struct mount *, struct fid *,
- struct vnode **));
-static int msdosfs_checkexp __P((struct mount *, struct sockaddr *,
- int *, struct ucred **));
-static int msdosfs_mount __P((struct mount *, char *, caddr_t,
- struct nameidata *, struct proc *));
-static int msdosfs_root __P((struct mount *, struct vnode **));
-static int msdosfs_statfs __P((struct mount *, struct statfs *,
- struct proc *));
-static int msdosfs_sync __P((struct mount *, int, struct ucred *,
- struct proc *));
-static int msdosfs_unmount __P((struct mount *, int, struct proc *));
-static int msdosfs_vptofh __P((struct vnode *, struct fid *));
-
-static int
-update_mp(mp, argp)
- struct mount *mp;
- struct msdosfs_args *argp;
-{
- struct msdosfsmount *pmp = VFSTOMSDOSFS(mp);
- int error;
-
- pmp->pm_gid = argp->gid;
- pmp->pm_uid = argp->uid;
- pmp->pm_mask = argp->mask & ALLPERMS;
- pmp->pm_flags |= argp->flags & MSDOSFSMNT_MNTOPT;
- if (pmp->pm_flags & MSDOSFSMNT_U2WTABLE) {
- bcopy(argp->u2w, pmp->pm_u2w, sizeof(pmp->pm_u2w));
- bcopy(argp->d2u, pmp->pm_d2u, sizeof(pmp->pm_d2u));
- bcopy(argp->u2d, pmp->pm_u2d, sizeof(pmp->pm_u2d));
- }
- if (pmp->pm_flags & MSDOSFSMNT_ULTABLE) {
- bcopy(argp->ul, pmp->pm_ul, sizeof(pmp->pm_ul));
- bcopy(argp->lu, pmp->pm_lu, sizeof(pmp->pm_lu));
- }
-
-#ifndef __FreeBSD__
- /*
- * GEMDOS knows nothing (yet) about win95
- */
- if (pmp->pm_flags & MSDOSFSMNT_GEMDOSFS)
- pmp->pm_flags |= MSDOSFSMNT_NOWIN95;
-#endif
-
- if (pmp->pm_flags & MSDOSFSMNT_NOWIN95)
- pmp->pm_flags |= MSDOSFSMNT_SHORTNAME;
- else if (!(pmp->pm_flags &
- (MSDOSFSMNT_SHORTNAME | MSDOSFSMNT_LONGNAME))) {
- struct vnode *rootvp;
-
- /*
- * Try to divine whether to support Win'95 long filenames
- */
- if (FAT32(pmp))
- pmp->pm_flags |= MSDOSFSMNT_LONGNAME;
- else {
- if ((error = msdosfs_root(mp, &rootvp)) != 0)
- return error;
- pmp->pm_flags |= findwin95(VTODE(rootvp))
- ? MSDOSFSMNT_LONGNAME
- : MSDOSFSMNT_SHORTNAME;
- vput(rootvp);
- }
- }
- return 0;
-}
-
-#ifndef __FreeBSD__
-int
-msdosfs_mountroot()
-{
- register struct mount *mp;
- struct proc *p = curproc; /* XXX */
- size_t size;
- int error;
- struct msdosfs_args args;
-
- if (root_device->dv_class != DV_DISK)
- return (ENODEV);
-
- /*
- * Get vnodes for swapdev and rootdev.
- */
- if (bdevvp(rootdev, &rootvp))
- panic("msdosfs_mountroot: can't setup rootvp");
-
- mp = malloc((u_long)sizeof(struct mount), M_MOUNT, M_WAITOK);
- bzero((char *)mp, (u_long)sizeof(struct mount));
- mp->mnt_op = &msdosfs_vfsops;
- mp->mnt_flag = 0;
- LIST_INIT(&mp->mnt_vnodelist);
-
- args.flags = 0;
- args.uid = 0;
- args.gid = 0;
- args.mask = 0777;
-
- if ((error = mountmsdosfs(rootvp, mp, p, &args)) != 0) {
- free(mp, M_MOUNT);
- return (error);
- }
-
- if ((error = update_mp(mp, &args)) != 0) {
- (void)msdosfs_unmount(mp, 0, p);
- free(mp, M_MOUNT);
- return (error);
- }
-
- if ((error = vfs_lock(mp)) != 0) {
- (void)msdosfs_unmount(mp, 0, p);
- free(mp, M_MOUNT);
- return (error);
- }
-
- TAILQ_INSERT_TAIL(&mountlist, mp, mnt_list);
- mp->mnt_vnodecovered = NULLVP;
- (void) copystr("/", mp->mnt_stat.f_mntonname, MNAMELEN - 1,
- &size);
- bzero(mp->mnt_stat.f_mntonname + size, MNAMELEN - size);
- (void) copystr(ROOTNAME, mp->mnt_stat.f_mntfromname, MNAMELEN - 1,
- &size);
- bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
- (void)msdosfs_statfs(mp, &mp->mnt_stat, p);
- vfs_unlock(mp);
- return (0);
-}
-#endif
-
-/*
- * mp - path - addr in user space of mount point (ie /usr or whatever)
- * data - addr in user space of mount params including the name of the block
- * special file to treat as a filesystem.
- */
-static int
-msdosfs_mount(mp, path, data, ndp, p)
- struct mount *mp;
- char *path;
- caddr_t data;
- struct nameidata *ndp;
- struct proc *p;
-{
- struct vnode *devvp; /* vnode for blk device to mount */
- struct msdosfs_args args; /* will hold data from mount request */
- /* msdosfs specific mount control block */
- struct msdosfsmount *pmp = NULL;
- size_t size;
- int error, flags;
- mode_t accessmode;
-
- error = copyin(data, (caddr_t)&args, sizeof(struct msdosfs_args));
- if (error)
- return (error);
- if (args.magic != MSDOSFS_ARGSMAGIC)
- args.flags = 0;
- /*
- * If updating, check whether changing from read-only to
- * read/write; if there is no device name, that's all we do.
- */
- if (mp->mnt_flag & MNT_UPDATE) {
- pmp = VFSTOMSDOSFS(mp);
- error = 0;
- if (!(pmp->pm_flags & MSDOSFSMNT_RONLY) && (mp->mnt_flag & MNT_RDONLY)) {
- flags = WRITECLOSE;
- if (mp->mnt_flag & MNT_FORCE)
- flags |= FORCECLOSE;
- error = vflush(mp, NULLVP, flags);
- }
- if (!error && (mp->mnt_flag & MNT_RELOAD))
- /* not yet implemented */
- error = EOPNOTSUPP;
- if (error)
- return (error);
- if ((pmp->pm_flags & MSDOSFSMNT_RONLY) && (mp->mnt_kern_flag & MNTK_WANTRDWR)) {
- /*
- * If upgrade to read-write by non-root, then verify
- * that user has necessary permissions on the device.
- */
- if (p->p_ucred->cr_uid != 0) {
- devvp = pmp->pm_devvp;
- vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p);
- error = VOP_ACCESS(devvp, VREAD | VWRITE,
- p->p_ucred, p);
- if (error) {
- VOP_UNLOCK(devvp, 0, p);
- return (error);
- }
- VOP_UNLOCK(devvp, 0, p);
- }
- pmp->pm_flags &= ~MSDOSFSMNT_RONLY;
- }
- if (args.fspec == 0) {
-#ifdef __notyet__ /* doesn't work correctly with current mountd XXX */
- if (args.flags & MSDOSFSMNT_MNTOPT) {
- pmp->pm_flags &= ~MSDOSFSMNT_MNTOPT;
- pmp->pm_flags |= args.flags & MSDOSFSMNT_MNTOPT;
- if (pmp->pm_flags & MSDOSFSMNT_NOWIN95)
- pmp->pm_flags |= MSDOSFSMNT_SHORTNAME;
- }
-#endif
- /*
- * Process export requests.
- */
- return (vfs_export(mp, &pmp->pm_export, &args.export));
- }
- }
- /*
- * Not an update, or updating the name: look up the name
- * and verify that it refers to a sensible block device.
- */
- NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, p);
- error = namei(ndp);
- if (error)
- return (error);
- devvp = ndp->ni_vp;
- NDFREE(ndp, NDF_ONLY_PNBUF);
-
- if (!vn_isdisk(devvp, &error)) {
- vrele(devvp);
- return (error);
- }
- /*
- * If mount by non-root, then verify that user has necessary
- * permissions on the device.
- */
- if (p->p_ucred->cr_uid != 0) {
- accessmode = VREAD;
- if ((mp->mnt_flag & MNT_RDONLY) == 0)
- accessmode |= VWRITE;
- vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p);
- error = VOP_ACCESS(devvp, accessmode, p->p_ucred, p);
- if (error) {
- vput(devvp);
- return (error);
- }
- VOP_UNLOCK(devvp, 0, p);
- }
- if ((mp->mnt_flag & MNT_UPDATE) == 0) {
- error = mountmsdosfs(devvp, mp, p, &args);
-#ifdef MSDOSFS_DEBUG /* only needed for the printf below */
- pmp = VFSTOMSDOSFS(mp);
-#endif
- } else {
- if (devvp != pmp->pm_devvp)
- error = EINVAL; /* XXX needs translation */
- else
- vrele(devvp);
- }
- if (error) {
- vrele(devvp);
- return (error);
- }
-
- error = update_mp(mp, &args);
- if (error) {
- msdosfs_unmount(mp, MNT_FORCE, p);
- return error;
- }
-
- (void) copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size);
- bzero(mp->mnt_stat.f_mntonname + size, MNAMELEN - size);
- (void) copyinstr(args.fspec, mp->mnt_stat.f_mntfromname, MNAMELEN - 1,
- &size);
- bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
- (void) msdosfs_statfs(mp, &mp->mnt_stat, p);
-#ifdef MSDOSFS_DEBUG
- printf("msdosfs_mount(): mp %p, pmp %p, inusemap %p\n", mp, pmp, pmp->pm_inusemap);
-#endif
- return (0);
-}
-
-static int
-mountmsdosfs(devvp, mp, p, argp)
- struct vnode *devvp;
- struct mount *mp;
- struct proc *p;
- struct msdosfs_args *argp;
-{
- struct msdosfsmount *pmp;
- struct buf *bp;
- dev_t dev = devvp->v_rdev;
-#ifndef __FreeBSD__
- struct partinfo dpart;
- int bsize = 0, dtype = 0, tmp;
-#endif
- union bootsector *bsp;
- struct byte_bpb33 *b33;
- struct byte_bpb50 *b50;
- struct byte_bpb710 *b710;
- u_int8_t SecPerClust;
- u_long clusters;
- int ronly, error;
-
- /*
- * Disallow multiple mounts of the same device.
- * Disallow mounting of a device that is currently in use
- * (except for root, which might share swap device for miniroot).
- * Flush out any old buffers remaining from a previous use.
- */
- error = vfs_mountedon(devvp);
- if (error)
- return (error);
- if (vcount(devvp) > 1 && devvp != rootvp)
- return (EBUSY);
- vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p);
- error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0);
- VOP_UNLOCK(devvp, 0, p);
- if (error)
- return (error);
-
- ronly = (mp->mnt_flag & MNT_RDONLY) != 0;
- vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p);
- error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, p);
- VOP_UNLOCK(devvp, 0, p);
- if (error)
- return (error);
-
- bp = NULL; /* both used in error_exit */
- pmp = NULL;
-
-#ifndef __FreeBSD__
- if (argp->flags & MSDOSFSMNT_GEMDOSFS) {
- /*
- * We need the disklabel to calculate the size of a FAT entry
- * later on. Also make sure the partition contains a filesystem
- * of type FS_MSDOS. This doesn't work for floppies, so we have
- * to check for them too.
- *
- * At least some parts of the msdos fs driver seem to assume
- * that the size of a disk block will always be 512 bytes.
- * Let's check it...
- */
- error = VOP_IOCTL(devvp, DIOCGPART, (caddr_t)&dpart,
- FREAD, NOCRED, p);
- if (error)
- goto error_exit;
- tmp = dpart.part->p_fstype;
- dtype = dpart.disklab->d_type;
- bsize = dpart.disklab->d_secsize;
- if (bsize != 512 || (dtype!=DTYPE_FLOPPY && tmp!=FS_MSDOS)) {
- error = EINVAL;
- goto error_exit;
- }
- }
-#endif
-
- /*
- * Read the boot sector of the filesystem, and then check the
- * boot signature. If not a dos boot sector then error out.
- *
- * NOTE: 2048 is a maximum sector size in current...
- */
- error = bread(devvp, 0, 2048, NOCRED, &bp);
- if (error)
- goto error_exit;
- bp->b_flags |= B_AGE;
- bsp = (union bootsector *)bp->b_data;
- b33 = (struct byte_bpb33 *)bsp->bs33.bsBPB;
- b50 = (struct byte_bpb50 *)bsp->bs50.bsBPB;
- b710 = (struct byte_bpb710 *)bsp->bs710.bsPBP;
-
-#ifndef __FreeBSD__
- if (!(argp->flags & MSDOSFSMNT_GEMDOSFS)) {
-#endif
-#ifndef MSDOSFS_NOCHECKSIG
- if (bsp->bs50.bsBootSectSig0 != BOOTSIG0
- || bsp->bs50.bsBootSectSig1 != BOOTSIG1) {
- error = EINVAL;
- goto error_exit;
- }
-#endif
-#ifndef __FreeBSD__
- }
-#endif
-
- pmp = malloc(sizeof *pmp, M_MSDOSFSMNT, M_WAITOK);
- bzero((caddr_t)pmp, sizeof *pmp);
- pmp->pm_mountp = mp;
-
- /*
- * Compute several useful quantities from the bpb in the
- * bootsector. Copy in the dos 5 variant of the bpb then fix up
- * the fields that are different between dos 5 and dos 3.3.
- */
- SecPerClust = b50->bpbSecPerClust;
- pmp->pm_BytesPerSec = getushort(b50->bpbBytesPerSec);
- pmp->pm_ResSectors = getushort(b50->bpbResSectors);
- pmp->pm_FATs = b50->bpbFATs;
- pmp->pm_RootDirEnts = getushort(b50->bpbRootDirEnts);
- pmp->pm_Sectors = getushort(b50->bpbSectors);
- pmp->pm_FATsecs = getushort(b50->bpbFATsecs);
- pmp->pm_SecPerTrack = getushort(b50->bpbSecPerTrack);
- pmp->pm_Heads = getushort(b50->bpbHeads);
- pmp->pm_Media = b50->bpbMedia;
-
- /* calculate the ratio of sector size to DEV_BSIZE */
- pmp->pm_BlkPerSec = pmp->pm_BytesPerSec / DEV_BSIZE;
-
-#ifndef __FreeBSD__
- if (!(argp->flags & MSDOSFSMNT_GEMDOSFS)) {
-#endif
- /* XXX - We should probably check more values here */
- if (!pmp->pm_BytesPerSec || !SecPerClust
- || !pmp->pm_Heads || pmp->pm_Heads > 255
-#ifdef PC98
- || !pmp->pm_SecPerTrack || pmp->pm_SecPerTrack > 255) {
-#else
- || !pmp->pm_SecPerTrack || pmp->pm_SecPerTrack > 63) {
-#endif
- error = EINVAL;
- goto error_exit;
- }
-#ifndef __FreeBSD__
- }
-#endif
-
- if (pmp->pm_Sectors == 0) {
- pmp->pm_HiddenSects = getulong(b50->bpbHiddenSecs);
- pmp->pm_HugeSectors = getulong(b50->bpbHugeSectors);
- } else {
- pmp->pm_HiddenSects = getushort(b33->bpbHiddenSecs);
- pmp->pm_HugeSectors = pmp->pm_Sectors;
- }
- if (pmp->pm_HugeSectors > 0xffffffff /
- (pmp->pm_BytesPerSec / sizeof(struct direntry)) + 1) {
- /*
- * We cannot deal currently with this size of disk
- * due to fileid limitations (see msdosfs_getattr and
- * msdosfs_readdir)
- */
- error = EINVAL;
- printf("mountmsdosfs(): disk too big, sorry\n");
- goto error_exit;
- }
-
- if (pmp->pm_RootDirEnts == 0) {
- if (bsp->bs710.bsBootSectSig2 != BOOTSIG2
- || bsp->bs710.bsBootSectSig3 != BOOTSIG3
- || pmp->pm_Sectors
- || pmp->pm_FATsecs
- || getushort(b710->bpbFSVers)) {
- error = EINVAL;
- printf("mountmsdosfs(): bad FAT32 filesystem\n");
- goto error_exit;
- }
- pmp->pm_fatmask = FAT32_MASK;
- pmp->pm_fatmult = 4;
- pmp->pm_fatdiv = 1;
- pmp->pm_FATsecs = getulong(b710->bpbBigFATsecs);
- if (getushort(b710->bpbExtFlags) & FATMIRROR)
- pmp->pm_curfat = getushort(b710->bpbExtFlags) & FATNUM;
- else
- pmp->pm_flags |= MSDOSFS_FATMIRROR;
- } else
- pmp->pm_flags |= MSDOSFS_FATMIRROR;
-
- /*
- * Check a few values (could do some more):
- * - logical sector size: power of 2, >= block size
- * - sectors per cluster: power of 2, >= 1
- * - number of sectors: >= 1, <= size of partition
- */
- if ( (SecPerClust == 0)
- || (SecPerClust & (SecPerClust - 1))
- || (pmp->pm_BytesPerSec < DEV_BSIZE)
- || (pmp->pm_BytesPerSec & (pmp->pm_BytesPerSec - 1))
- || (pmp->pm_HugeSectors == 0)
- ) {
- error = EINVAL;
- goto error_exit;
- }
-
- pmp->pm_HugeSectors *= pmp->pm_BlkPerSec;
- pmp->pm_HiddenSects *= pmp->pm_BlkPerSec; /* XXX not used? */
- pmp->pm_FATsecs *= pmp->pm_BlkPerSec;
- SecPerClust *= pmp->pm_BlkPerSec;
-
- pmp->pm_fatblk = pmp->pm_ResSectors * pmp->pm_BlkPerSec;
-
- if (FAT32(pmp)) {
- pmp->pm_rootdirblk = getulong(b710->bpbRootClust);
- pmp->pm_firstcluster = pmp->pm_fatblk
- + (pmp->pm_FATs * pmp->pm_FATsecs);
- pmp->pm_fsinfo = getushort(b710->bpbFSInfo) * pmp->pm_BlkPerSec;
- } else {
- pmp->pm_rootdirblk = pmp->pm_fatblk +
- (pmp->pm_FATs * pmp->pm_FATsecs);
- pmp->pm_rootdirsize = (pmp->pm_RootDirEnts * sizeof(struct direntry)
- + DEV_BSIZE - 1)
- / DEV_BSIZE; /* in blocks */
- pmp->pm_firstcluster = pmp->pm_rootdirblk + pmp->pm_rootdirsize;
- }
-
- pmp->pm_maxcluster = (pmp->pm_HugeSectors - pmp->pm_firstcluster) /
- SecPerClust + 1;
- pmp->pm_fatsize = pmp->pm_FATsecs * DEV_BSIZE; /* XXX not used? */
-
-#ifndef __FreeBSD__
- if (argp->flags & MSDOSFSMNT_GEMDOSFS) {
- if ((pmp->pm_maxcluster <= (0xff0 - 2))
- && ((dtype == DTYPE_FLOPPY) || ((dtype == DTYPE_VNODE)
- && ((pmp->pm_Heads == 1) || (pmp->pm_Heads == 2))))
- ) {
- pmp->pm_fatmask = FAT12_MASK;
- pmp->pm_fatmult = 3;
- pmp->pm_fatdiv = 2;
- } else {
- pmp->pm_fatmask = FAT16_MASK;
- pmp->pm_fatmult = 2;
- pmp->pm_fatdiv = 1;
- }
- } else
-#endif
- if (pmp->pm_fatmask == 0) {
- if (pmp->pm_maxcluster
- <= ((CLUST_RSRVD - CLUST_FIRST) & FAT12_MASK)) {
- /*
- * This will usually be a floppy disk. This size makes
- * sure that one fat entry will not be split across
- * multiple blocks.
- */
- pmp->pm_fatmask = FAT12_MASK;
- pmp->pm_fatmult = 3;
- pmp->pm_fatdiv = 2;
- } else {
- pmp->pm_fatmask = FAT16_MASK;
- pmp->pm_fatmult = 2;
- pmp->pm_fatdiv = 1;
- }
- }
-
- clusters = (pmp->pm_fatsize / pmp->pm_fatmult) * pmp->pm_fatdiv;
- if (pmp->pm_maxcluster >= clusters) {
- printf("Warning: number of clusters (%ld) exceeds FAT "
- "capacity (%ld)\n", pmp->pm_maxcluster + 1, clusters);
- pmp->pm_maxcluster = clusters - 1;
- }
-
-
- if (FAT12(pmp))
- pmp->pm_fatblocksize = 3 * pmp->pm_BytesPerSec;
- else
- pmp->pm_fatblocksize = DFLTBSIZE;
-
- pmp->pm_fatblocksec = pmp->pm_fatblocksize / DEV_BSIZE;
- pmp->pm_bnshift = ffs(DEV_BSIZE) - 1;
-
- /*
- * Compute mask and shift value for isolating cluster relative byte
- * offsets and cluster numbers from a file offset.
- */
- pmp->pm_bpcluster = SecPerClust * DEV_BSIZE;
- pmp->pm_crbomask = pmp->pm_bpcluster - 1;
- pmp->pm_cnshift = ffs(pmp->pm_bpcluster) - 1;
-
- /*
- * Check for valid cluster size
- * must be a power of 2
- */
- if (pmp->pm_bpcluster ^ (1 << pmp->pm_cnshift)) {
- error = EINVAL;
- goto error_exit;
- }
-
- /*
- * Release the bootsector buffer.
- */
- brelse(bp);
- bp = NULL;
-
- /*
- * Check FSInfo.
- */
- if (pmp->pm_fsinfo) {
- struct fsinfo *fp;
-
- if ((error = bread(devvp, pmp->pm_fsinfo, fsi_size(pmp),
- NOCRED, &bp)) != 0)
- goto error_exit;
- fp = (struct fsinfo *)bp->b_data;
- if (!bcmp(fp->fsisig1, "RRaA", 4)
- && !bcmp(fp->fsisig2, "rrAa", 4)
- && !bcmp(fp->fsisig3, "\0\0\125\252", 4)
- && !bcmp(fp->fsisig4, "\0\0\125\252", 4))
- pmp->pm_nxtfree = getulong(fp->fsinxtfree);
- else
- pmp->pm_fsinfo = 0;
- brelse(bp);
- bp = NULL;
- }
-
- /*
- * Check and validate (or perhaps invalidate?) the fsinfo structure? XXX
- */
-
- /*
- * Allocate memory for the bitmap of allocated clusters, and then
- * fill it in.
- */
- pmp->pm_inusemap = malloc(((pmp->pm_maxcluster + N_INUSEBITS - 1)
- / N_INUSEBITS)
- * sizeof(*pmp->pm_inusemap),
- M_MSDOSFSFAT, M_WAITOK);
-
- /*
- * fillinusemap() needs pm_devvp.
- */
- pmp->pm_dev = dev;
- pmp->pm_devvp = devvp;
-
- /*
- * Have the inuse map filled in.
- */
- if ((error = fillinusemap(pmp)) != 0)
- goto error_exit;
-
- /*
- * If they want fat updates to be synchronous then let them suffer
- * the performance degradation in exchange for the on disk copy of
- * the fat being correct just about all the time. I suppose this
- * would be a good thing to turn on if the kernel is still flakey.
- */
- if (mp->mnt_flag & MNT_SYNCHRONOUS)
- pmp->pm_flags |= MSDOSFSMNT_WAITONFAT;
-
- /*
- * Finish up.
- */
- if (ronly)
- pmp->pm_flags |= MSDOSFSMNT_RONLY;
- else
- pmp->pm_fmod = 1;
- mp->mnt_data = (qaddr_t) pmp;
- mp->mnt_stat.f_fsid.val[0] = dev2udev(dev);
- mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum;
- mp->mnt_flag |= MNT_LOCAL;
- devvp->v_specmountpoint = mp;
-
- return 0;
-
-error_exit:
- if (bp)
- brelse(bp);
- (void) VOP_CLOSE(devvp, ronly ? FREAD : FREAD | FWRITE, NOCRED, p);
- if (pmp) {
- if (pmp->pm_inusemap)
- free(pmp->pm_inusemap, M_MSDOSFSFAT);
- free(pmp, M_MSDOSFSMNT);
- mp->mnt_data = (qaddr_t)0;
- }
- return (error);
-}
-
-/*
- * Unmount the filesystem described by mp.
- */
-static int
-msdosfs_unmount(mp, mntflags, p)
- struct mount *mp;
- int mntflags;
- struct proc *p;
-{
- struct msdosfsmount *pmp;
- int error, flags;
-
- flags = 0;
- if (mntflags & MNT_FORCE)
- flags |= FORCECLOSE;
- error = vflush(mp, NULLVP, flags);
- if (error)
- return error;
- pmp = VFSTOMSDOSFS(mp);
- pmp->pm_devvp->v_specmountpoint = NULL;
-#ifdef MSDOSFS_DEBUG
- {
- struct vnode *vp = pmp->pm_devvp;
-
- printf("msdosfs_umount(): just before calling VOP_CLOSE()\n");
- printf("flag %08lx, usecount %d, writecount %d, holdcnt %ld\n",
- vp->v_flag, vp->v_usecount, vp->v_writecount, vp->v_holdcnt);
- printf("id %lu, mount %p, op %p\n",
- vp->v_id, vp->v_mount, vp->v_op);
- printf("freef %p, freeb %p, mount %p\n",
- vp->v_freelist.tqe_next, vp->v_freelist.tqe_prev,
- vp->v_mount);
- printf("cleanblkhd %p, dirtyblkhd %p, numoutput %ld, type %d\n",
- TAILQ_FIRST(&vp->v_cleanblkhd),
- TAILQ_FIRST(&vp->v_dirtyblkhd),
- vp->v_numoutput, vp->v_type);
- printf("union %p, tag %d, data[0] %08x, data[1] %08x\n",
- vp->v_socket, vp->v_tag,
- ((u_int *)vp->v_data)[0],
- ((u_int *)vp->v_data)[1]);
- }
-#endif
- error = VOP_CLOSE(pmp->pm_devvp,
- (pmp->pm_flags&MSDOSFSMNT_RONLY) ? FREAD : FREAD | FWRITE,
- NOCRED, p);
- vrele(pmp->pm_devvp);
- free(pmp->pm_inusemap, M_MSDOSFSFAT);
- free(pmp, M_MSDOSFSMNT);
- mp->mnt_data = (qaddr_t)0;
- mp->mnt_flag &= ~MNT_LOCAL;
- return (error);
-}
-
-static int
-msdosfs_root(mp, vpp)
- struct mount *mp;
- struct vnode **vpp;
-{
- struct msdosfsmount *pmp = VFSTOMSDOSFS(mp);
- struct denode *ndep;
- int error;
-
-#ifdef MSDOSFS_DEBUG
- printf("msdosfs_root(); mp %p, pmp %p\n", mp, pmp);
-#endif
- error = deget(pmp, MSDOSFSROOT, MSDOSFSROOT_OFS, &ndep);
- if (error)
- return (error);
- *vpp = DETOV(ndep);
- return (0);
-}
-
-static int
-msdosfs_statfs(mp, sbp, p)
- struct mount *mp;
- struct statfs *sbp;
- struct proc *p;
-{
- struct msdosfsmount *pmp;
-
- pmp = VFSTOMSDOSFS(mp);
- sbp->f_bsize = pmp->pm_bpcluster;
- sbp->f_iosize = pmp->pm_bpcluster;
- sbp->f_blocks = pmp->pm_maxcluster + 1;
- sbp->f_bfree = pmp->pm_freeclustercount;
- sbp->f_bavail = pmp->pm_freeclustercount;
- sbp->f_files = pmp->pm_RootDirEnts; /* XXX */
- sbp->f_ffree = 0; /* what to put in here? */
- if (sbp != &mp->mnt_stat) {
- sbp->f_type = mp->mnt_vfc->vfc_typenum;
- bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN);
- bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN);
- }
- strncpy(sbp->f_fstypename, mp->mnt_vfc->vfc_name, MFSNAMELEN);
- return (0);
-}
-
-static int
-msdosfs_sync(mp, waitfor, cred, p)
- struct mount *mp;
- int waitfor;
- struct ucred *cred;
- struct proc *p;
-{
- struct vnode *vp, *nvp;
- struct denode *dep;
- struct msdosfsmount *pmp = VFSTOMSDOSFS(mp);
- int error, allerror = 0;
-
- /*
- * If we ever switch to not updating all of the fats all the time,
- * this would be the place to update them from the first one.
- */
- if (pmp->pm_fmod != 0) {
- if (pmp->pm_flags & MSDOSFSMNT_RONLY)
- panic("msdosfs_sync: rofs mod");
- else {
- /* update fats here */
- }
- }
- /*
- * Write back each (modified) denode.
- */
- simple_lock(&mntvnode_slock);
-loop:
- for (vp = mp->mnt_vnodelist.lh_first; vp != NULL; vp = nvp) {
- /*
- * If the vnode that we are about to sync is no longer
- * associated with this mount point, start over.
- */
- if (vp->v_mount != mp)
- goto loop;
-
- simple_lock(&vp->v_interlock);
- nvp = vp->v_mntvnodes.le_next;
- dep = VTODE(vp);
- if (vp->v_type == VNON ||
- ((dep->de_flag &
- (DE_ACCESS | DE_CREATE | DE_UPDATE | DE_MODIFIED)) == 0 &&
- (TAILQ_EMPTY(&vp->v_dirtyblkhd) || waitfor == MNT_LAZY))) {
- simple_unlock(&vp->v_interlock);
- continue;
- }
- simple_unlock(&mntvnode_slock);
- error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT | LK_INTERLOCK, p);
- if (error) {
- simple_lock(&mntvnode_slock);
- if (error == ENOENT)
- goto loop;
- continue;
- }
- error = VOP_FSYNC(vp, cred, waitfor, p);
- if (error)
- allerror = error;
- VOP_UNLOCK(vp, 0, p);
- vrele(vp);
- simple_lock(&mntvnode_slock);
- }
- simple_unlock(&mntvnode_slock);
-
- /*
- * Flush filesystem control info.
- */
- if (waitfor != MNT_LAZY) {
- vn_lock(pmp->pm_devvp, LK_EXCLUSIVE | LK_RETRY, p);
- error = VOP_FSYNC(pmp->pm_devvp, cred, waitfor, p);
- if (error)
- allerror = error;
- VOP_UNLOCK(pmp->pm_devvp, 0, p);
- }
- return (allerror);
-}
-
-static int
-msdosfs_fhtovp(mp, fhp, vpp)
- struct mount *mp;
- struct fid *fhp;
- struct vnode **vpp;
-{
- struct msdosfsmount *pmp = VFSTOMSDOSFS(mp);
- struct defid *defhp = (struct defid *) fhp;
- struct denode *dep;
- int error;
-
- error = deget(pmp, defhp->defid_dirclust, defhp->defid_dirofs, &dep);
- if (error) {
- *vpp = NULLVP;
- return (error);
- }
- *vpp = DETOV(dep);
- return (0);
-}
-
-static int
-msdosfs_checkexp(mp, nam, exflagsp, credanonp)
- struct mount *mp;
- struct sockaddr *nam;
- int *exflagsp;
- struct ucred **credanonp;
-{
- struct msdosfsmount *pmp = VFSTOMSDOSFS(mp);
- struct netcred *np;
-
- np = vfs_export_lookup(mp, &pmp->pm_export, nam);
- if (np == NULL)
- return (EACCES);
- *exflagsp = np->netc_exflags;
- *credanonp = &np->netc_anon;
- return (0);
-}
-
-static int
-msdosfs_vptofh(vp, fhp)
- struct vnode *vp;
- struct fid *fhp;
-{
- struct denode *dep;
- struct defid *defhp;
-
- dep = VTODE(vp);
- defhp = (struct defid *)fhp;
- defhp->defid_len = sizeof(struct defid);
- defhp->defid_dirclust = dep->de_dirclust;
- defhp->defid_dirofs = dep->de_diroffset;
- /* defhp->defid_gen = dep->de_gen; */
- return (0);
-}
-
-static struct vfsops msdosfs_vfsops = {
- msdosfs_mount,
- vfs_stdstart,
- msdosfs_unmount,
- msdosfs_root,
- vfs_stdquotactl,
- msdosfs_statfs,
- msdosfs_sync,
- vfs_stdvget,
- msdosfs_fhtovp,
- msdosfs_checkexp,
- msdosfs_vptofh,
- msdosfs_init,
- vfs_stduninit,
- vfs_stdextattrctl,
-};
-
-VFS_SET(msdosfs_vfsops, msdos, 0);
diff --git a/sys/fs/msdosfs/msdosfs_vnops.c b/sys/fs/msdosfs/msdosfs_vnops.c
deleted file mode 100644
index 5ce499011b68..000000000000
--- a/sys/fs/msdosfs/msdosfs_vnops.c
+++ /dev/null
@@ -1,1977 +0,0 @@
-/* $FreeBSD$ */
-/* $NetBSD: msdosfs_vnops.c,v 1.68 1998/02/10 14:10:04 mrg Exp $ */
-
-/*-
- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
- * Copyright (C) 1994, 1995, 1997 TooLs GmbH.
- * All rights reserved.
- * Original code by Paul Popelka (paulp@uts.amdahl.com) (see below).
- *
- * 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 TooLs GmbH.
- * 4. The name of TooLs GmbH may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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.
- */
-/*
- * Written by Paul Popelka (paulp@uts.amdahl.com)
- *
- * You can do anything you want with this software, just don't say you wrote
- * it, and don't remove this notice.
- *
- * This software is provided "as is".
- *
- * The author supplies this software to be publicly redistributed on the
- * understanding that the author is not responsible for the correct
- * functioning of this software in any circumstances and is not liable for
- * any damages caused by this software.
- *
- * October 1992
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/namei.h>
-#include <sys/resourcevar.h> /* defines plimit structure in proc struct */
-#include <sys/kernel.h>
-#include <sys/stat.h>
-#include <sys/buf.h>
-#include <sys/proc.h>
-#include <sys/mount.h>
-#include <sys/unistd.h>
-#include <sys/vnode.h>
-#include <sys/malloc.h>
-#include <sys/dirent.h>
-#include <sys/signalvar.h>
-
-#include <vm/vm.h>
-#include <vm/vm_extern.h>
-#include <vm/vm_zone.h>
-#include <vm/vnode_pager.h>
-
-#include <msdosfs/bpb.h>
-#include <msdosfs/direntry.h>
-#include <msdosfs/denode.h>
-#include <msdosfs/msdosfsmount.h>
-#include <msdosfs/fat.h>
-
-#define DOS_FILESIZE_MAX 0xffffffff
-
-/*
- * Prototypes for MSDOSFS vnode operations
- */
-static int msdosfs_create __P((struct vop_create_args *));
-static int msdosfs_mknod __P((struct vop_mknod_args *));
-static int msdosfs_close __P((struct vop_close_args *));
-static int msdosfs_access __P((struct vop_access_args *));
-static int msdosfs_getattr __P((struct vop_getattr_args *));
-static int msdosfs_setattr __P((struct vop_setattr_args *));
-static int msdosfs_read __P((struct vop_read_args *));
-static int msdosfs_write __P((struct vop_write_args *));
-static int msdosfs_fsync __P((struct vop_fsync_args *));
-static int msdosfs_remove __P((struct vop_remove_args *));
-static int msdosfs_link __P((struct vop_link_args *));
-static int msdosfs_rename __P((struct vop_rename_args *));
-static int msdosfs_mkdir __P((struct vop_mkdir_args *));
-static int msdosfs_rmdir __P((struct vop_rmdir_args *));
-static int msdosfs_symlink __P((struct vop_symlink_args *));
-static int msdosfs_readdir __P((struct vop_readdir_args *));
-static int msdosfs_bmap __P((struct vop_bmap_args *));
-static int msdosfs_strategy __P((struct vop_strategy_args *));
-static int msdosfs_print __P((struct vop_print_args *));
-static int msdosfs_pathconf __P((struct vop_pathconf_args *ap));
-static int msdosfs_getpages __P((struct vop_getpages_args *));
-static int msdosfs_putpages __P((struct vop_putpages_args *));
-
-/*
- * Some general notes:
- *
- * In the ufs filesystem the inodes, superblocks, and indirect blocks are
- * read/written using the vnode for the filesystem. Blocks that represent
- * the contents of a file are read/written using the vnode for the file
- * (including directories when they are read/written as files). This
- * presents problems for the dos filesystem because data that should be in
- * an inode (if dos had them) resides in the directory itself. Since we
- * must update directory entries without the benefit of having the vnode
- * for the directory we must use the vnode for the filesystem. This means
- * that when a directory is actually read/written (via read, write, or
- * readdir, or seek) we must use the vnode for the filesystem instead of
- * the vnode for the directory as would happen in ufs. This is to insure we
- * retreive the correct block from the buffer cache since the hash value is
- * based upon the vnode address and the desired block number.
- */
-
-/*
- * Create a regular file. On entry the directory to contain the file being
- * created is locked. We must release before we return. We must also free
- * the pathname buffer pointed at by cnp->cn_pnbuf, always on error, or
- * only if the SAVESTART bit in cn_flags is clear on success.
- */
-static int
-msdosfs_create(ap)
- struct vop_create_args /* {
- struct vnode *a_dvp;
- struct vnode **a_vpp;
- struct componentname *a_cnp;
- struct vattr *a_vap;
- } */ *ap;
-{
- struct componentname *cnp = ap->a_cnp;
- struct denode ndirent;
- struct denode *dep;
- struct denode *pdep = VTODE(ap->a_dvp);
- struct timespec ts;
- int error;
-
-#ifdef MSDOSFS_DEBUG
- printf("msdosfs_create(cnp %p, vap %p\n", cnp, ap->a_vap);
-#endif
-
- /*
- * If this is the root directory and there is no space left we
- * can't do anything. This is because the root directory can not
- * change size.
- */
- if (pdep->de_StartCluster == MSDOSFSROOT
- && pdep->de_fndoffset >= pdep->de_FileSize) {
- error = ENOSPC;
- goto bad;
- }
-
- /*
- * Create a directory entry for the file, then call createde() to
- * have it installed. NOTE: DOS files are always executable. We
- * use the absence of the owner write bit to make the file
- * readonly.
- */
-#ifdef DIAGNOSTIC
- if ((cnp->cn_flags & HASBUF) == 0)
- panic("msdosfs_create: no name");
-#endif
- bzero(&ndirent, sizeof(ndirent));
- error = uniqdosname(pdep, cnp, ndirent.de_Name);
- if (error)
- goto bad;
-
- ndirent.de_Attributes = (ap->a_vap->va_mode & VWRITE) ?
- ATTR_ARCHIVE : ATTR_ARCHIVE | ATTR_READONLY;
- ndirent.de_LowerCase = 0;
- ndirent.de_StartCluster = 0;
- ndirent.de_FileSize = 0;
- ndirent.de_dev = pdep->de_dev;
- ndirent.de_devvp = pdep->de_devvp;
- ndirent.de_pmp = pdep->de_pmp;
- ndirent.de_flag = DE_ACCESS | DE_CREATE | DE_UPDATE;
- getnanotime(&ts);
- DETIMES(&ndirent, &ts, &ts, &ts);
- error = createde(&ndirent, pdep, &dep, cnp);
- if (error)
- goto bad;
- *ap->a_vpp = DETOV(dep);
- return (0);
-
-bad:
- return (error);
-}
-
-static int
-msdosfs_mknod(ap)
- struct vop_mknod_args /* {
- struct vnode *a_dvp;
- struct vnode **a_vpp;
- struct componentname *a_cnp;
- struct vattr *a_vap;
- } */ *ap;
-{
-
- switch (ap->a_vap->va_type) {
- case VDIR:
- return (msdosfs_mkdir((struct vop_mkdir_args *)ap));
- break;
-
- case VREG:
- return (msdosfs_create((struct vop_create_args *)ap));
- break;
-
- default:
- return (EINVAL);
- }
- /* NOTREACHED */
-}
-
-static int
-msdosfs_close(ap)
- struct vop_close_args /* {
- struct vnode *a_vp;
- int a_fflag;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
- struct denode *dep = VTODE(vp);
- struct timespec ts;
-
- simple_lock(&vp->v_interlock);
- if (vp->v_usecount > 1) {
- getnanotime(&ts);
- DETIMES(dep, &ts, &ts, &ts);
- }
- simple_unlock(&vp->v_interlock);
- return 0;
-}
-
-static int
-msdosfs_access(ap)
- struct vop_access_args /* {
- struct vnode *a_vp;
- int a_mode;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
- struct denode *dep = VTODE(ap->a_vp);
- struct msdosfsmount *pmp = dep->de_pmp;
- struct ucred *cred = ap->a_cred;
- mode_t mask, file_mode, mode = ap->a_mode;
- register gid_t *gp;
- int i;
-
- file_mode = (S_IXUSR|S_IXGRP|S_IXOTH) | (S_IRUSR|S_IRGRP|S_IROTH) |
- ((dep->de_Attributes & ATTR_READONLY) ? 0 : (S_IWUSR|S_IWGRP|S_IWOTH));
- file_mode &= pmp->pm_mask;
-
- /*
- * Disallow write attempts on read-only file systems;
- * unless the file is a socket, fifo, or a block or
- * character device resident on the file system.
- */
- if (mode & VWRITE) {
- switch (vp->v_type) {
- case VDIR:
- case VLNK:
- case VREG:
- if (vp->v_mount->mnt_flag & MNT_RDONLY)
- return (EROFS);
- break;
- default:
- break;
- }
- }
-
- /* User id 0 always gets access. */
- if (cred->cr_uid == 0)
- return 0;
-
- mask = 0;
-
- /* Otherwise, check the owner. */
- if (cred->cr_uid == pmp->pm_uid) {
- if (mode & VEXEC)
- mask |= S_IXUSR;
- if (mode & VREAD)
- mask |= S_IRUSR;
- if (mode & VWRITE)
- mask |= S_IWUSR;
- return (file_mode & mask) == mask ? 0 : EACCES;
- }
-
- /* Otherwise, check the groups. */
- for (i = 0, gp = cred->cr_groups; i < cred->cr_ngroups; i++, gp++)
- if (pmp->pm_gid == *gp) {
- if (mode & VEXEC)
- mask |= S_IXGRP;
- if (mode & VREAD)
- mask |= S_IRGRP;
- if (mode & VWRITE)
- mask |= S_IWGRP;
- return (file_mode & mask) == mask ? 0 : EACCES;
- }
-
- /* Otherwise, check everyone else. */
- if (mode & VEXEC)
- mask |= S_IXOTH;
- if (mode & VREAD)
- mask |= S_IROTH;
- if (mode & VWRITE)
- mask |= S_IWOTH;
- return (file_mode & mask) == mask ? 0 : EACCES;
-}
-
-static int
-msdosfs_getattr(ap)
- struct vop_getattr_args /* {
- struct vnode *a_vp;
- struct vattr *a_vap;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- struct denode *dep = VTODE(ap->a_vp);
- struct msdosfsmount *pmp = dep->de_pmp;
- struct vattr *vap = ap->a_vap;
- mode_t mode;
- struct timespec ts;
- u_long dirsperblk = pmp->pm_BytesPerSec / sizeof(struct direntry);
- u_long fileid;
-
- getnanotime(&ts);
- DETIMES(dep, &ts, &ts, &ts);
- vap->va_fsid = dev2udev(dep->de_dev);
- /*
- * The following computation of the fileid must be the same as that
- * used in msdosfs_readdir() to compute d_fileno. If not, pwd
- * doesn't work.
- */
- if (dep->de_Attributes & ATTR_DIRECTORY) {
- fileid = cntobn(pmp, dep->de_StartCluster) * dirsperblk;
- if (dep->de_StartCluster == MSDOSFSROOT)
- fileid = 1;
- } else {
- fileid = cntobn(pmp, dep->de_dirclust) * dirsperblk;
- if (dep->de_dirclust == MSDOSFSROOT)
- fileid = roottobn(pmp, 0) * dirsperblk;
- fileid += dep->de_diroffset / sizeof(struct direntry);
- }
- vap->va_fileid = fileid;
- if ((dep->de_Attributes & ATTR_READONLY) == 0)
- mode = S_IRWXU|S_IRWXG|S_IRWXO;
- else
- mode = S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;
- vap->va_mode = mode & pmp->pm_mask;
- vap->va_uid = pmp->pm_uid;
- vap->va_gid = pmp->pm_gid;
- vap->va_nlink = 1;
- vap->va_rdev = 0;
- vap->va_size = dep->de_FileSize;
- dos2unixtime(dep->de_MDate, dep->de_MTime, 0, &vap->va_mtime);
- if (pmp->pm_flags & MSDOSFSMNT_LONGNAME) {
- dos2unixtime(dep->de_ADate, 0, 0, &vap->va_atime);
- dos2unixtime(dep->de_CDate, dep->de_CTime, dep->de_CHun, &vap->va_ctime);
- } else {
- vap->va_atime = vap->va_mtime;
- vap->va_ctime = vap->va_mtime;
- }
- vap->va_flags = 0;
- if ((dep->de_Attributes & ATTR_ARCHIVE) == 0)
- vap->va_flags |= SF_ARCHIVED;
- vap->va_gen = 0;
- vap->va_blocksize = pmp->pm_bpcluster;
- vap->va_bytes =
- (dep->de_FileSize + pmp->pm_crbomask) & ~pmp->pm_crbomask;
- vap->va_type = ap->a_vp->v_type;
- vap->va_filerev = dep->de_modrev;
- return (0);
-}
-
-static int
-msdosfs_setattr(ap)
- struct vop_setattr_args /* {
- struct vnode *a_vp;
- struct vattr *a_vap;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
- struct denode *dep = VTODE(ap->a_vp);
- struct msdosfsmount *pmp = dep->de_pmp;
- struct vattr *vap = ap->a_vap;
- struct ucred *cred = ap->a_cred;
- int error = 0;
-
-#ifdef MSDOSFS_DEBUG
- printf("msdosfs_setattr(): vp %p, vap %p, cred %p, p %p\n",
- ap->a_vp, vap, cred, ap->a_p);
-#endif
-
- /*
- * Check for unsettable attributes.
- */
- if ((vap->va_type != VNON) || (vap->va_nlink != VNOVAL) ||
- (vap->va_fsid != VNOVAL) || (vap->va_fileid != VNOVAL) ||
- (vap->va_blocksize != VNOVAL) || (vap->va_rdev != VNOVAL) ||
- (vap->va_bytes != VNOVAL) || (vap->va_gen != VNOVAL)) {
-#ifdef MSDOSFS_DEBUG
- printf("msdosfs_setattr(): returning EINVAL\n");
- printf(" va_type %d, va_nlink %x, va_fsid %lx, va_fileid %lx\n",
- vap->va_type, vap->va_nlink, vap->va_fsid, vap->va_fileid);
- printf(" va_blocksize %lx, va_rdev %x, va_bytes %qx, va_gen %lx\n",
- vap->va_blocksize, vap->va_rdev, vap->va_bytes, vap->va_gen);
- printf(" va_uid %x, va_gid %x\n",
- vap->va_uid, vap->va_gid);
-#endif
- return (EINVAL);
- }
- if (vap->va_flags != VNOVAL) {
- if (vp->v_mount->mnt_flag & MNT_RDONLY)
- return (EROFS);
- if (cred->cr_uid != pmp->pm_uid &&
- (error = suser_xxx(cred, ap->a_p, PRISON_ROOT)))
- return (error);
- /*
- * We are very inconsistent about handling unsupported
- * attributes. We ignored the access time and the
- * read and execute bits. We were strict for the other
- * attributes.
- *
- * Here we are strict, stricter than ufs in not allowing
- * users to attempt to set SF_SETTABLE bits or anyone to
- * set unsupported bits. However, we ignore attempts to
- * set ATTR_ARCHIVE for directories `cp -pr' from a more
- * sensible file system attempts it a lot.
- */
- if (cred->cr_uid != 0) {
- if (vap->va_flags & SF_SETTABLE)
- return EPERM;
- }
- if (vap->va_flags & ~SF_ARCHIVED)
- return EOPNOTSUPP;
- if (vap->va_flags & SF_ARCHIVED)
- dep->de_Attributes &= ~ATTR_ARCHIVE;
- else if (!(dep->de_Attributes & ATTR_DIRECTORY))
- dep->de_Attributes |= ATTR_ARCHIVE;
- dep->de_flag |= DE_MODIFIED;
- }
-
- if (vap->va_uid != (uid_t)VNOVAL || vap->va_gid != (gid_t)VNOVAL) {
- uid_t uid;
- gid_t gid;
-
- if (vp->v_mount->mnt_flag & MNT_RDONLY)
- return (EROFS);
- uid = vap->va_uid;
- if (uid == (uid_t)VNOVAL)
- uid = pmp->pm_uid;
- gid = vap->va_gid;
- if (gid == (gid_t)VNOVAL)
- gid = pmp->pm_gid;
- if ((cred->cr_uid != pmp->pm_uid || uid != pmp->pm_uid ||
- (gid != pmp->pm_gid && !groupmember(gid, cred))) &&
- (error = suser_xxx(cred, ap->a_p, PRISON_ROOT)))
- return error;
- if (uid != pmp->pm_uid || gid != pmp->pm_gid)
- return EINVAL;
- }
-
- if (vap->va_size != VNOVAL) {
- /*
- * Disallow write attempts on read-only file systems;
- * unless the file is a socket, fifo, or a block or
- * character device resident on the file system.
- */
- switch (vp->v_type) {
- case VDIR:
- return (EISDIR);
- /* NOT REACHED */
- case VLNK:
- case VREG:
- if (vp->v_mount->mnt_flag & MNT_RDONLY)
- return (EROFS);
- break;
- default:
- break;
- }
- error = detrunc(dep, vap->va_size, 0, cred, ap->a_p);
- if (error)
- return error;
- }
- if (vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL) {
- if (vp->v_mount->mnt_flag & MNT_RDONLY)
- return (EROFS);
- if (cred->cr_uid != pmp->pm_uid &&
- (error = suser_xxx(cred, ap->a_p, PRISON_ROOT)) &&
- ((vap->va_vaflags & VA_UTIMES_NULL) == 0 ||
- (error = VOP_ACCESS(ap->a_vp, VWRITE, cred, ap->a_p))))
- return (error);
- if (vp->v_type != VDIR) {
- if ((pmp->pm_flags & MSDOSFSMNT_NOWIN95) == 0 &&
- vap->va_atime.tv_sec != VNOVAL)
- unix2dostime(&vap->va_atime, &dep->de_ADate, NULL, NULL);
- if (vap->va_mtime.tv_sec != VNOVAL)
- unix2dostime(&vap->va_mtime, &dep->de_MDate, &dep->de_MTime, NULL);
- dep->de_Attributes |= ATTR_ARCHIVE;
- dep->de_flag |= DE_MODIFIED;
- }
- }
- /*
- * DOS files only have the ability to have their writability
- * attribute set, so we use the owner write bit to set the readonly
- * attribute.
- */
- if (vap->va_mode != (mode_t)VNOVAL) {
- if (vp->v_mount->mnt_flag & MNT_RDONLY)
- return (EROFS);
- if (cred->cr_uid != pmp->pm_uid &&
- (error = suser_xxx(cred, ap->a_p, PRISON_ROOT)))
- return (error);
- if (vp->v_type != VDIR) {
- /* We ignore the read and execute bits. */
- if (vap->va_mode & VWRITE)
- dep->de_Attributes &= ~ATTR_READONLY;
- else
- dep->de_Attributes |= ATTR_READONLY;
- dep->de_flag |= DE_MODIFIED;
- }
- }
- return (deupdat(dep, 1));
-}
-
-static int
-msdosfs_read(ap)
- struct vop_read_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- int a_ioflag;
- struct ucred *a_cred;
- } */ *ap;
-{
- int error = 0;
- int blsize;
- int isadir;
- int orig_resid;
- u_int n;
- u_long diff;
- u_long on;
- daddr_t lbn;
- daddr_t rablock;
- int rasize;
- int seqcount;
- struct buf *bp;
- struct vnode *vp = ap->a_vp;
- struct denode *dep = VTODE(vp);
- struct msdosfsmount *pmp = dep->de_pmp;
- struct uio *uio = ap->a_uio;
-
- if (uio->uio_offset < 0)
- return (EINVAL);
-
- if ((uoff_t)uio->uio_offset > DOS_FILESIZE_MAX)
- return (0);
- /*
- * If they didn't ask for any data, then we are done.
- */
- orig_resid = uio->uio_resid;
- if (orig_resid <= 0)
- return (0);
-
- seqcount = ap->a_ioflag >> 16;
-
- isadir = dep->de_Attributes & ATTR_DIRECTORY;
- do {
- if (uio->uio_offset >= dep->de_FileSize)
- break;
- lbn = de_cluster(pmp, uio->uio_offset);
- /*
- * If we are operating on a directory file then be sure to
- * do i/o with the vnode for the filesystem instead of the
- * vnode for the directory.
- */
- if (isadir) {
- /* convert cluster # to block # */
- error = pcbmap(dep, lbn, &lbn, 0, &blsize);
- if (error == E2BIG) {
- error = EINVAL;
- break;
- } else if (error)
- break;
- error = bread(pmp->pm_devvp, lbn, blsize, NOCRED, &bp);
- } else {
- blsize = pmp->pm_bpcluster;
- rablock = lbn + 1;
- if (seqcount > 1 &&
- de_cn2off(pmp, rablock) < dep->de_FileSize) {
- rasize = pmp->pm_bpcluster;
- error = breadn(vp, lbn, blsize,
- &rablock, &rasize, 1, NOCRED, &bp);
- } else {
- error = bread(vp, lbn, blsize, NOCRED, &bp);
- }
- }
- if (error) {
- brelse(bp);
- break;
- }
- on = uio->uio_offset & pmp->pm_crbomask;
- diff = pmp->pm_bpcluster - on;
- n = diff > uio->uio_resid ? uio->uio_resid : diff;
- diff = dep->de_FileSize - uio->uio_offset;
- if (diff < n)
- n = diff;
- diff = blsize - bp->b_resid;
- if (diff < n)
- n = diff;
- error = uiomove(bp->b_data + on, (int) n, uio);
- brelse(bp);
- } while (error == 0 && uio->uio_resid > 0 && n != 0);
- if (!isadir && (error == 0 || uio->uio_resid != orig_resid) &&
- (vp->v_mount->mnt_flag & MNT_NOATIME) == 0)
- dep->de_flag |= DE_ACCESS;
- return (error);
-}
-
-/*
- * Write data to a file or directory.
- */
-static int
-msdosfs_write(ap)
- struct vop_write_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- int a_ioflag;
- struct ucred *a_cred;
- } */ *ap;
-{
- int n;
- int croffset;
- int resid;
- u_long osize;
- int error = 0;
- u_long count;
- daddr_t bn, lastcn;
- struct buf *bp;
- int ioflag = ap->a_ioflag;
- struct uio *uio = ap->a_uio;
- struct proc *p = uio->uio_procp;
- struct vnode *vp = ap->a_vp;
- struct vnode *thisvp;
- struct denode *dep = VTODE(vp);
- struct msdosfsmount *pmp = dep->de_pmp;
- struct ucred *cred = ap->a_cred;
-
-#ifdef MSDOSFS_DEBUG
- printf("msdosfs_write(vp %p, uio %p, ioflag %x, cred %p\n",
- vp, uio, ioflag, cred);
- printf("msdosfs_write(): diroff %lu, dirclust %lu, startcluster %lu\n",
- dep->de_diroffset, dep->de_dirclust, dep->de_StartCluster);
-#endif
-
- switch (vp->v_type) {
- case VREG:
- if (ioflag & IO_APPEND)
- uio->uio_offset = dep->de_FileSize;
- thisvp = vp;
- break;
- case VDIR:
- return EISDIR;
- default:
- panic("msdosfs_write(): bad file type");
- }
-
- if (uio->uio_offset < 0)
- return (EFBIG);
-
- if (uio->uio_resid == 0)
- return (0);
-
- /*
- * If they've exceeded their filesize limit, tell them about it.
- */
- if (p &&
- ((uoff_t)uio->uio_offset + uio->uio_resid >
- p->p_rlimit[RLIMIT_FSIZE].rlim_cur)) {
- psignal(p, SIGXFSZ);
- return (EFBIG);
- }
-
- if ((uoff_t)uio->uio_offset + uio->uio_resid > DOS_FILESIZE_MAX)
- return (EFBIG);
-
- /*
- * If the offset we are starting the write at is beyond the end of
- * the file, then they've done a seek. Unix filesystems allow
- * files with holes in them, DOS doesn't so we must fill the hole
- * with zeroed blocks.
- */
- if (uio->uio_offset > dep->de_FileSize) {
- error = deextend(dep, uio->uio_offset, cred);
- if (error)
- return (error);
- }
-
- /*
- * Remember some values in case the write fails.
- */
- resid = uio->uio_resid;
- osize = dep->de_FileSize;
-
- /*
- * If we write beyond the end of the file, extend it to its ultimate
- * size ahead of the time to hopefully get a contiguous area.
- */
- if (uio->uio_offset + resid > osize) {
- count = de_clcount(pmp, uio->uio_offset + resid) -
- de_clcount(pmp, osize);
- error = extendfile(dep, count, NULL, NULL, 0);
- if (error && (error != ENOSPC || (ioflag & IO_UNIT)))
- goto errexit;
- lastcn = dep->de_fc[FC_LASTFC].fc_frcn;
- } else
- lastcn = de_clcount(pmp, osize) - 1;
-
- do {
- if (de_cluster(pmp, uio->uio_offset) > lastcn) {
- error = ENOSPC;
- break;
- }
-
- croffset = uio->uio_offset & pmp->pm_crbomask;
- n = min(uio->uio_resid, pmp->pm_bpcluster - croffset);
- if (uio->uio_offset + n > dep->de_FileSize) {
- dep->de_FileSize = uio->uio_offset + n;
- /* The object size needs to be set before buffer is allocated */
- vnode_pager_setsize(vp, dep->de_FileSize);
- }
-
- bn = de_cluster(pmp, uio->uio_offset);
- if ((uio->uio_offset & pmp->pm_crbomask) == 0
- && (de_cluster(pmp, uio->uio_offset + uio->uio_resid)
- > de_cluster(pmp, uio->uio_offset)
- || uio->uio_offset + uio->uio_resid >= dep->de_FileSize)) {
- /*
- * If either the whole cluster gets written,
- * or we write the cluster from its start beyond EOF,
- * then no need to read data from disk.
- */
- bp = getblk(thisvp, bn, pmp->pm_bpcluster, 0, 0);
- clrbuf(bp);
- /*
- * Do the bmap now, since pcbmap needs buffers
- * for the fat table. (see msdosfs_strategy)
- */
- if (bp->b_blkno == bp->b_lblkno) {
- error = pcbmap(dep, bp->b_lblkno, &bp->b_blkno,
- 0, 0);
- if (error)
- bp->b_blkno = -1;
- }
- if (bp->b_blkno == -1) {
- brelse(bp);
- if (!error)
- error = EIO; /* XXX */
- break;
- }
- } else {
- /*
- * The block we need to write into exists, so read it in.
- */
- error = bread(thisvp, bn, pmp->pm_bpcluster, cred, &bp);
- if (error) {
- brelse(bp);
- break;
- }
- }
-
- /*
- * Should these vnode_pager_* functions be done on dir
- * files?
- */
-
- /*
- * Copy the data from user space into the buf header.
- */
- error = uiomove(bp->b_data + croffset, n, uio);
- if (error) {
- brelse(bp);
- break;
- }
-
- /*
- * If they want this synchronous then write it and wait for
- * it. Otherwise, if on a cluster boundary write it
- * asynchronously so we can move on to the next block
- * without delay. Otherwise do a delayed write because we
- * may want to write somemore into the block later.
- */
- if (ioflag & IO_SYNC)
- (void) bwrite(bp);
- else if (n + croffset == pmp->pm_bpcluster)
- bawrite(bp);
- else
- bdwrite(bp);
- dep->de_flag |= DE_UPDATE;
- } while (error == 0 && uio->uio_resid > 0);
-
- /*
- * If the write failed and they want us to, truncate the file back
- * to the size it was before the write was attempted.
- */
-errexit:
- if (error) {
- if (ioflag & IO_UNIT) {
- detrunc(dep, osize, ioflag & IO_SYNC, NOCRED, NULL);
- uio->uio_offset -= resid - uio->uio_resid;
- uio->uio_resid = resid;
- } else {
- detrunc(dep, dep->de_FileSize, ioflag & IO_SYNC, NOCRED, NULL);
- if (uio->uio_resid != resid)
- error = 0;
- }
- } else if (ioflag & IO_SYNC)
- error = deupdat(dep, 1);
- return (error);
-}
-
-/*
- * Flush the blocks of a file to disk.
- *
- * This function is worthless for vnodes that represent directories. Maybe we
- * could just do a sync if they try an fsync on a directory file.
- */
-static int
-msdosfs_fsync(ap)
- struct vop_fsync_args /* {
- struct vnode *a_vp;
- struct ucred *a_cred;
- int a_waitfor;
- struct proc *a_p;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
- int s;
- struct buf *bp, *nbp;
-
- /*
- * Flush all dirty buffers associated with a vnode.
- */
-loop:
- s = splbio();
- for (bp = TAILQ_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) {
- nbp = TAILQ_NEXT(bp, b_vnbufs);
- if (BUF_LOCK(bp, LK_EXCLUSIVE | LK_NOWAIT))
- continue;
- if ((bp->b_flags & B_DELWRI) == 0)
- panic("msdosfs_fsync: not dirty");
- bremfree(bp);
- splx(s);
- (void) bwrite(bp);
- goto loop;
- }
- while (vp->v_numoutput) {
- vp->v_flag |= VBWAIT;
- (void) tsleep((caddr_t)&vp->v_numoutput, PRIBIO + 1, "msdosfsn", 0);
- }
-#ifdef DIAGNOSTIC
- if (!TAILQ_EMPTY(&vp->v_dirtyblkhd)) {
- vprint("msdosfs_fsync: dirty", vp);
- goto loop;
- }
-#endif
- splx(s);
- return (deupdat(VTODE(vp), ap->a_waitfor == MNT_WAIT));
-}
-
-static int
-msdosfs_remove(ap)
- struct vop_remove_args /* {
- struct vnode *a_dvp;
- struct vnode *a_vp;
- struct componentname *a_cnp;
- } */ *ap;
-{
- struct denode *dep = VTODE(ap->a_vp);
- struct denode *ddep = VTODE(ap->a_dvp);
- int error;
-
- if (ap->a_vp->v_type == VDIR)
- error = EPERM;
- else
- error = removede(ddep, dep);
-#ifdef MSDOSFS_DEBUG
- printf("msdosfs_remove(), dep %p, v_usecount %d\n", dep, ap->a_vp->v_usecount);
-#endif
- return (error);
-}
-
-/*
- * DOS filesystems don't know what links are. But since we already called
- * msdosfs_lookup() with create and lockparent, the parent is locked so we
- * have to free it before we return the error.
- */
-static int
-msdosfs_link(ap)
- struct vop_link_args /* {
- struct vnode *a_tdvp;
- struct vnode *a_vp;
- struct componentname *a_cnp;
- } */ *ap;
-{
- return (EOPNOTSUPP);
-}
-
-/*
- * Renames on files require moving the denode to a new hash queue since the
- * denode's location is used to compute which hash queue to put the file
- * in. Unless it is a rename in place. For example "mv a b".
- *
- * What follows is the basic algorithm:
- *
- * if (file move) {
- * if (dest file exists) {
- * remove dest file
- * }
- * if (dest and src in same directory) {
- * rewrite name in existing directory slot
- * } else {
- * write new entry in dest directory
- * update offset and dirclust in denode
- * move denode to new hash chain
- * clear old directory entry
- * }
- * } else {
- * directory move
- * if (dest directory exists) {
- * if (dest is not empty) {
- * return ENOTEMPTY
- * }
- * remove dest directory
- * }
- * if (dest and src in same directory) {
- * rewrite name in existing entry
- * } else {
- * be sure dest is not a child of src directory
- * write entry in dest directory
- * update "." and ".." in moved directory
- * clear old directory entry for moved directory
- * }
- * }
- *
- * On entry:
- * source's parent directory is unlocked
- * source file or directory is unlocked
- * destination's parent directory is locked
- * destination file or directory is locked if it exists
- *
- * On exit:
- * all denodes should be released
- *
- * Notes:
- * I'm not sure how the memory containing the pathnames pointed at by the
- * componentname structures is freed, there may be some memory bleeding
- * for each rename done.
- */
-static int
-msdosfs_rename(ap)
- struct vop_rename_args /* {
- struct vnode *a_fdvp;
- struct vnode *a_fvp;
- struct componentname *a_fcnp;
- struct vnode *a_tdvp;
- struct vnode *a_tvp;
- struct componentname *a_tcnp;
- } */ *ap;
-{
- struct vnode *tdvp = ap->a_tdvp;
- struct vnode *fvp = ap->a_fvp;
- struct vnode *fdvp = ap->a_fdvp;
- struct vnode *tvp = ap->a_tvp;
- struct componentname *tcnp = ap->a_tcnp;
- struct componentname *fcnp = ap->a_fcnp;
- struct proc *p = fcnp->cn_proc;
- struct denode *ip, *xp, *dp, *zp;
- u_char toname[11], oldname[11];
- u_long from_diroffset, to_diroffset;
- u_char to_count;
- int doingdirectory = 0, newparent = 0;
- int error;
- u_long cn;
- daddr_t bn;
- struct denode *fddep; /* from file's parent directory */
- struct denode *fdep; /* from file or directory */
- struct denode *tddep; /* to file's parent directory */
- struct denode *tdep; /* to file or directory */
- struct msdosfsmount *pmp;
- struct direntry *dotdotp;
- struct buf *bp;
-
- fddep = VTODE(ap->a_fdvp);
- fdep = VTODE(ap->a_fvp);
- tddep = VTODE(ap->a_tdvp);
- tdep = tvp ? VTODE(tvp) : NULL;
- pmp = fddep->de_pmp;
-
- pmp = VFSTOMSDOSFS(fdvp->v_mount);
-
-#ifdef DIAGNOSTIC
- if ((tcnp->cn_flags & HASBUF) == 0 ||
- (fcnp->cn_flags & HASBUF) == 0)
- panic("msdosfs_rename: no name");
-#endif
- /*
- * Check for cross-device rename.
- */
- if ((fvp->v_mount != tdvp->v_mount) ||
- (tvp && (fvp->v_mount != tvp->v_mount))) {
- error = EXDEV;
-abortit:
- if (tdvp == tvp)
- vrele(tdvp);
- else
- vput(tdvp);
- if (tvp)
- vput(tvp);
- vrele(fdvp);
- vrele(fvp);
- return (error);
- }
-
- /*
- * If source and dest are the same, do nothing.
- */
- if (tvp == fvp) {
- error = 0;
- goto abortit;
- }
-
- error = vn_lock(fvp, LK_EXCLUSIVE, p);
- if (error)
- goto abortit;
- dp = VTODE(fdvp);
- ip = VTODE(fvp);
-
- /*
- * Be sure we are not renaming ".", "..", or an alias of ".". This
- * leads to a crippled directory tree. It's pretty tough to do a
- * "ls" or "pwd" with the "." directory entry missing, and "cd .."
- * doesn't work if the ".." entry is missing.
- */
- if (ip->de_Attributes & ATTR_DIRECTORY) {
- /*
- * Avoid ".", "..", and aliases of "." for obvious reasons.
- */
- if ((fcnp->cn_namelen == 1 && fcnp->cn_nameptr[0] == '.') ||
- dp == ip ||
- (fcnp->cn_flags & ISDOTDOT) ||
- (tcnp->cn_flags & ISDOTDOT) ||
- (ip->de_flag & DE_RENAME)) {
- VOP_UNLOCK(fvp, 0, p);
- error = EINVAL;
- goto abortit;
- }
- ip->de_flag |= DE_RENAME;
- doingdirectory++;
- }
-
- /*
- * When the target exists, both the directory
- * and target vnodes are returned locked.
- */
- dp = VTODE(tdvp);
- xp = tvp ? VTODE(tvp) : NULL;
- /*
- * Remember direntry place to use for destination
- */
- to_diroffset = dp->de_fndoffset;
- to_count = dp->de_fndcnt;
-
- /*
- * If ".." must be changed (ie the directory gets a new
- * parent) then the source directory must not be in the
- * directory heirarchy above the target, as this would
- * orphan everything below the source directory. Also
- * the user must have write permission in the source so
- * as to be able to change "..". We must repeat the call
- * to namei, as the parent directory is unlocked by the
- * call to doscheckpath().
- */
- error = VOP_ACCESS(fvp, VWRITE, tcnp->cn_cred, tcnp->cn_proc);
- VOP_UNLOCK(fvp, 0, p);
- if (VTODE(fdvp)->de_StartCluster != VTODE(tdvp)->de_StartCluster)
- newparent = 1;
- vrele(fdvp);
- if (doingdirectory && newparent) {
- if (error) /* write access check above */
- goto bad;
- if (xp != NULL)
- vput(tvp);
- /*
- * doscheckpath() vput()'s dp,
- * so we have to do a relookup afterwards
- */
- error = doscheckpath(ip, dp);
- if (error)
- goto out;
- if ((tcnp->cn_flags & SAVESTART) == 0)
- panic("msdosfs_rename: lost to startdir");
- error = relookup(tdvp, &tvp, tcnp);
- if (error)
- goto out;
- dp = VTODE(tdvp);
- xp = tvp ? VTODE(tvp) : NULL;
- }
-
- if (xp != NULL) {
- /*
- * Target must be empty if a directory and have no links
- * to it. Also, ensure source and target are compatible
- * (both directories, or both not directories).
- */
- if (xp->de_Attributes & ATTR_DIRECTORY) {
- if (!dosdirempty(xp)) {
- error = ENOTEMPTY;
- goto bad;
- }
- if (!doingdirectory) {
- error = ENOTDIR;
- goto bad;
- }
- cache_purge(tdvp);
- } else if (doingdirectory) {
- error = EISDIR;
- goto bad;
- }
- error = removede(dp, xp);
- if (error)
- goto bad;
- vput(tvp);
- xp = NULL;
- }
-
- /*
- * Convert the filename in tcnp into a dos filename. We copy this
- * into the denode and directory entry for the destination
- * file/directory.
- */
- error = uniqdosname(VTODE(tdvp), tcnp, toname);
- if (error)
- goto abortit;
-
- /*
- * Since from wasn't locked at various places above,
- * have to do a relookup here.
- */
- fcnp->cn_flags &= ~MODMASK;
- fcnp->cn_flags |= LOCKPARENT | LOCKLEAF;
- if ((fcnp->cn_flags & SAVESTART) == 0)
- panic("msdosfs_rename: lost from startdir");
- if (!newparent)
- VOP_UNLOCK(tdvp, 0, p);
- (void) relookup(fdvp, &fvp, fcnp);
- if (fvp == NULL) {
- /*
- * From name has disappeared.
- */
- if (doingdirectory)
- panic("rename: lost dir entry");
- vrele(ap->a_fvp);
- if (newparent)
- VOP_UNLOCK(tdvp, 0, p);
- vrele(tdvp);
- return 0;
- }
- xp = VTODE(fvp);
- zp = VTODE(fdvp);
- from_diroffset = zp->de_fndoffset;
-
- /*
- * Ensure that the directory entry still exists and has not
- * changed till now. If the source is a file the entry may
- * have been unlinked or renamed. In either case there is
- * no further work to be done. If the source is a directory
- * then it cannot have been rmdir'ed or renamed; this is
- * prohibited by the DE_RENAME flag.
- */
- if (xp != ip) {
- if (doingdirectory)
- panic("rename: lost dir entry");
- vrele(ap->a_fvp);
- VOP_UNLOCK(fvp, 0, p);
- if (newparent)
- VOP_UNLOCK(fdvp, 0, p);
- xp = NULL;
- } else {
- vrele(fvp);
- xp = NULL;
-
- /*
- * First write a new entry in the destination
- * directory and mark the entry in the source directory
- * as deleted. Then move the denode to the correct hash
- * chain for its new location in the filesystem. And, if
- * we moved a directory, then update its .. entry to point
- * to the new parent directory.
- */
- bcopy(ip->de_Name, oldname, 11);
- bcopy(toname, ip->de_Name, 11); /* update denode */
- dp->de_fndoffset = to_diroffset;
- dp->de_fndcnt = to_count;
- error = createde(ip, dp, (struct denode **)0, tcnp);
- if (error) {
- bcopy(oldname, ip->de_Name, 11);
- if (newparent)
- VOP_UNLOCK(fdvp, 0, p);
- VOP_UNLOCK(fvp, 0, p);
- goto bad;
- }
- ip->de_refcnt++;
- zp->de_fndoffset = from_diroffset;
- error = removede(zp, ip);
- if (error) {
- /* XXX should really panic here, fs is corrupt */
- if (newparent)
- VOP_UNLOCK(fdvp, 0, p);
- VOP_UNLOCK(fvp, 0, p);
- goto bad;
- }
- if (!doingdirectory) {
- error = pcbmap(dp, de_cluster(pmp, to_diroffset), 0,
- &ip->de_dirclust, 0);
- if (error) {
- /* XXX should really panic here, fs is corrupt */
- if (newparent)
- VOP_UNLOCK(fdvp, 0, p);
- VOP_UNLOCK(fvp, 0, p);
- goto bad;
- }
- if (ip->de_dirclust == MSDOSFSROOT)
- ip->de_diroffset = to_diroffset;
- else
- ip->de_diroffset = to_diroffset & pmp->pm_crbomask;
- }
- reinsert(ip);
- if (newparent)
- VOP_UNLOCK(fdvp, 0, p);
- }
-
- /*
- * If we moved a directory to a new parent directory, then we must
- * fixup the ".." entry in the moved directory.
- */
- if (doingdirectory && newparent) {
- cn = ip->de_StartCluster;
- if (cn == MSDOSFSROOT) {
- /* this should never happen */
- panic("msdosfs_rename(): updating .. in root directory?");
- } else
- bn = cntobn(pmp, cn);
- error = bread(pmp->pm_devvp, bn, pmp->pm_bpcluster,
- NOCRED, &bp);
- if (error) {
- /* XXX should really panic here, fs is corrupt */
- brelse(bp);
- VOP_UNLOCK(fvp, 0, p);
- goto bad;
- }
- dotdotp = (struct direntry *)bp->b_data + 1;
- putushort(dotdotp->deStartCluster, dp->de_StartCluster);
- if (FAT32(pmp))
- putushort(dotdotp->deHighClust, dp->de_StartCluster >> 16);
- error = bwrite(bp);
- if (error) {
- /* XXX should really panic here, fs is corrupt */
- VOP_UNLOCK(fvp, 0, p);
- goto bad;
- }
- }
-
- VOP_UNLOCK(fvp, 0, p);
-bad:
- if (xp)
- vput(tvp);
- vput(tdvp);
-out:
- ip->de_flag &= ~DE_RENAME;
- vrele(fdvp);
- vrele(fvp);
- return (error);
-
-}
-
-static struct {
- struct direntry dot;
- struct direntry dotdot;
-} dosdirtemplate = {
- { ". ", " ", /* the . entry */
- ATTR_DIRECTORY, /* file attribute */
- 0, /* reserved */
- 0, { 0, 0 }, { 0, 0 }, /* create time & date */
- { 0, 0 }, /* access date */
- { 0, 0 }, /* high bits of start cluster */
- { 210, 4 }, { 210, 4 }, /* modify time & date */
- { 0, 0 }, /* startcluster */
- { 0, 0, 0, 0 } /* filesize */
- },
- { ".. ", " ", /* the .. entry */
- ATTR_DIRECTORY, /* file attribute */
- 0, /* reserved */
- 0, { 0, 0 }, { 0, 0 }, /* create time & date */
- { 0, 0 }, /* access date */
- { 0, 0 }, /* high bits of start cluster */
- { 210, 4 }, { 210, 4 }, /* modify time & date */
- { 0, 0 }, /* startcluster */
- { 0, 0, 0, 0 } /* filesize */
- }
-};
-
-static int
-msdosfs_mkdir(ap)
- struct vop_mkdir_args /* {
- struct vnode *a_dvp;
- struvt vnode **a_vpp;
- struvt componentname *a_cnp;
- struct vattr *a_vap;
- } */ *ap;
-{
- struct componentname *cnp = ap->a_cnp;
- struct denode *dep;
- struct denode *pdep = VTODE(ap->a_dvp);
- struct direntry *denp;
- struct msdosfsmount *pmp = pdep->de_pmp;
- struct buf *bp;
- u_long newcluster, pcl;
- int bn;
- int error;
- struct denode ndirent;
- struct timespec ts;
-
- /*
- * If this is the root directory and there is no space left we
- * can't do anything. This is because the root directory can not
- * change size.
- */
- if (pdep->de_StartCluster == MSDOSFSROOT
- && pdep->de_fndoffset >= pdep->de_FileSize) {
- error = ENOSPC;
- goto bad2;
- }
-
- /*
- * Allocate a cluster to hold the about to be created directory.
- */
- error = clusteralloc(pmp, 0, 1, CLUST_EOFE, &newcluster, NULL);
- if (error)
- goto bad2;
-
- bzero(&ndirent, sizeof(ndirent));
- ndirent.de_pmp = pmp;
- ndirent.de_flag = DE_ACCESS | DE_CREATE | DE_UPDATE;
- getnanotime(&ts);
- DETIMES(&ndirent, &ts, &ts, &ts);
-
- /*
- * Now fill the cluster with the "." and ".." entries. And write
- * the cluster to disk. This way it is there for the parent
- * directory to be pointing at if there were a crash.
- */
- bn = cntobn(pmp, newcluster);
- /* always succeeds */
- bp = getblk(pmp->pm_devvp, bn, pmp->pm_bpcluster, 0, 0);
- bzero(bp->b_data, pmp->pm_bpcluster);
- bcopy(&dosdirtemplate, bp->b_data, sizeof dosdirtemplate);
- denp = (struct direntry *)bp->b_data;
- putushort(denp[0].deStartCluster, newcluster);
- putushort(denp[0].deCDate, ndirent.de_CDate);
- putushort(denp[0].deCTime, ndirent.de_CTime);
- denp[0].deCHundredth = ndirent.de_CHun;
- putushort(denp[0].deADate, ndirent.de_ADate);
- putushort(denp[0].deMDate, ndirent.de_MDate);
- putushort(denp[0].deMTime, ndirent.de_MTime);
- pcl = pdep->de_StartCluster;
- if (FAT32(pmp) && pcl == pmp->pm_rootdirblk)
- pcl = 0;
- putushort(denp[1].deStartCluster, pcl);
- putushort(denp[1].deCDate, ndirent.de_CDate);
- putushort(denp[1].deCTime, ndirent.de_CTime);
- denp[1].deCHundredth = ndirent.de_CHun;
- putushort(denp[1].deADate, ndirent.de_ADate);
- putushort(denp[1].deMDate, ndirent.de_MDate);
- putushort(denp[1].deMTime, ndirent.de_MTime);
- if (FAT32(pmp)) {
- putushort(denp[0].deHighClust, newcluster >> 16);
- putushort(denp[1].deHighClust, pdep->de_StartCluster >> 16);
- }
-
- error = bwrite(bp);
- if (error)
- goto bad;
-
- /*
- * Now build up a directory entry pointing to the newly allocated
- * cluster. This will be written to an empty slot in the parent
- * directory.
- */
-#ifdef DIAGNOSTIC
- if ((cnp->cn_flags & HASBUF) == 0)
- panic("msdosfs_mkdir: no name");
-#endif
- error = uniqdosname(pdep, cnp, ndirent.de_Name);
- if (error)
- goto bad;
-
- ndirent.de_Attributes = ATTR_DIRECTORY;
- ndirent.de_LowerCase = 0;
- ndirent.de_StartCluster = newcluster;
- ndirent.de_FileSize = 0;
- ndirent.de_dev = pdep->de_dev;
- ndirent.de_devvp = pdep->de_devvp;
- error = createde(&ndirent, pdep, &dep, cnp);
- if (error)
- goto bad;
- *ap->a_vpp = DETOV(dep);
- return (0);
-
-bad:
- clusterfree(pmp, newcluster, NULL);
-bad2:
- return (error);
-}
-
-static int
-msdosfs_rmdir(ap)
- struct vop_rmdir_args /* {
- struct vnode *a_dvp;
- struct vnode *a_vp;
- struct componentname *a_cnp;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
- register struct vnode *dvp = ap->a_dvp;
- register struct componentname *cnp = ap->a_cnp;
- register struct denode *ip, *dp;
- struct proc *p = cnp->cn_proc;
- int error;
-
- ip = VTODE(vp);
- dp = VTODE(dvp);
-
- /*
- * Verify the directory is empty (and valid).
- * (Rmdir ".." won't be valid since
- * ".." will contain a reference to
- * the current directory and thus be
- * non-empty.)
- */
- error = 0;
- if (!dosdirempty(ip) || ip->de_flag & DE_RENAME) {
- error = ENOTEMPTY;
- goto out;
- }
- /*
- * Delete the entry from the directory. For dos filesystems this
- * gets rid of the directory entry on disk, the in memory copy
- * still exists but the de_refcnt is <= 0. This prevents it from
- * being found by deget(). When the vput() on dep is done we give
- * up access and eventually msdosfs_reclaim() will be called which
- * will remove it from the denode cache.
- */
- error = removede(dp, ip);
- if (error)
- goto out;
- /*
- * This is where we decrement the link count in the parent
- * directory. Since dos filesystems don't do this we just purge
- * the name cache.
- */
- cache_purge(dvp);
- VOP_UNLOCK(dvp, 0, p);
- /*
- * Truncate the directory that is being deleted.
- */
- error = detrunc(ip, (u_long)0, IO_SYNC, cnp->cn_cred, p);
- cache_purge(vp);
-
- vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, p);
-out:
- return (error);
-}
-
-/*
- * DOS filesystems don't know what symlinks are.
- */
-static int
-msdosfs_symlink(ap)
- struct vop_symlink_args /* {
- struct vnode *a_dvp;
- struct vnode **a_vpp;
- struct componentname *a_cnp;
- struct vattr *a_vap;
- char *a_target;
- } */ *ap;
-{
- return (EOPNOTSUPP);
-}
-
-static int
-msdosfs_readdir(ap)
- struct vop_readdir_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- struct ucred *a_cred;
- int *a_eofflag;
- int *a_ncookies;
- u_long **a_cookies;
- } */ *ap;
-{
- int error = 0;
- int diff;
- long n;
- int blsize;
- long on;
- u_long cn;
- u_long fileno;
- u_long dirsperblk;
- long bias = 0;
- daddr_t bn, lbn;
- struct buf *bp;
- struct denode *dep = VTODE(ap->a_vp);
- struct msdosfsmount *pmp = dep->de_pmp;
- struct direntry *dentp;
- struct dirent dirbuf;
- struct uio *uio = ap->a_uio;
- u_long *cookies = NULL;
- int ncookies = 0;
- off_t offset, off;
- int chksum = -1;
-
-#ifdef MSDOSFS_DEBUG
- printf("msdosfs_readdir(): vp %p, uio %p, cred %p, eofflagp %p\n",
- ap->a_vp, uio, ap->a_cred, ap->a_eofflag);
-#endif
-
- /*
- * msdosfs_readdir() won't operate properly on regular files since
- * it does i/o only with the the filesystem vnode, and hence can
- * retrieve the wrong block from the buffer cache for a plain file.
- * So, fail attempts to readdir() on a plain file.
- */
- if ((dep->de_Attributes & ATTR_DIRECTORY) == 0)
- return (ENOTDIR);
-
- /*
- * To be safe, initialize dirbuf
- */
- bzero(dirbuf.d_name, sizeof(dirbuf.d_name));
-
- /*
- * If the user buffer is smaller than the size of one dos directory
- * entry or the file offset is not a multiple of the size of a
- * directory entry, then we fail the read.
- */
- off = offset = uio->uio_offset;
- if (uio->uio_resid < sizeof(struct direntry) ||
- (offset & (sizeof(struct direntry) - 1)))
- return (EINVAL);
-
- if (ap->a_ncookies) {
- ncookies = uio->uio_resid / 16;
- MALLOC(cookies, u_long *, ncookies * sizeof(u_long), M_TEMP,
- M_WAITOK);
- *ap->a_cookies = cookies;
- *ap->a_ncookies = ncookies;
- }
-
- dirsperblk = pmp->pm_BytesPerSec / sizeof(struct direntry);
-
- /*
- * If they are reading from the root directory then, we simulate
- * the . and .. entries since these don't exist in the root
- * directory. We also set the offset bias to make up for having to
- * simulate these entries. By this I mean that at file offset 64 we
- * read the first entry in the root directory that lives on disk.
- */
- if (dep->de_StartCluster == MSDOSFSROOT
- || (FAT32(pmp) && dep->de_StartCluster == pmp->pm_rootdirblk)) {
-#if 0
- printf("msdosfs_readdir(): going after . or .. in root dir, offset %d\n",
- offset);
-#endif
- bias = 2 * sizeof(struct direntry);
- if (offset < bias) {
- for (n = (int)offset / sizeof(struct direntry);
- n < 2; n++) {
- if (FAT32(pmp))
- dirbuf.d_fileno = cntobn(pmp,
- pmp->pm_rootdirblk)
- * dirsperblk;
- else
- dirbuf.d_fileno = 1;
- dirbuf.d_type = DT_DIR;
- switch (n) {
- case 0:
- dirbuf.d_namlen = 1;
- strcpy(dirbuf.d_name, ".");
- break;
- case 1:
- dirbuf.d_namlen = 2;
- strcpy(dirbuf.d_name, "..");
- break;
- }
- dirbuf.d_reclen = GENERIC_DIRSIZ(&dirbuf);
- if (uio->uio_resid < dirbuf.d_reclen)
- goto out;
- error = uiomove((caddr_t) &dirbuf,
- dirbuf.d_reclen, uio);
- if (error)
- goto out;
- offset += sizeof(struct direntry);
- off = offset;
- if (cookies) {
- *cookies++ = offset;
- if (--ncookies <= 0)
- goto out;
- }
- }
- }
- }
-
- off = offset;
- while (uio->uio_resid > 0) {
- lbn = de_cluster(pmp, offset - bias);
- on = (offset - bias) & pmp->pm_crbomask;
- n = min(pmp->pm_bpcluster - on, uio->uio_resid);
- diff = dep->de_FileSize - (offset - bias);
- if (diff <= 0)
- break;
- n = min(n, diff);
- error = pcbmap(dep, lbn, &bn, &cn, &blsize);
- if (error)
- break;
- error = bread(pmp->pm_devvp, bn, blsize, NOCRED, &bp);
- if (error) {
- brelse(bp);
- return (error);
- }
- n = min(n, blsize - bp->b_resid);
-
- /*
- * Convert from dos directory entries to fs-independent
- * directory entries.
- */
- for (dentp = (struct direntry *)(bp->b_data + on);
- (char *)dentp < bp->b_data + on + n;
- dentp++, offset += sizeof(struct direntry)) {
-#if 0
- printf("rd: dentp %08x prev %08x crnt %08x deName %02x attr %02x\n",
- dentp, prev, crnt, dentp->deName[0], dentp->deAttributes);
-#endif
- /*
- * If this is an unused entry, we can stop.
- */
- if (dentp->deName[0] == SLOT_EMPTY) {
- brelse(bp);
- goto out;
- }
- /*
- * Skip deleted entries.
- */
- if (dentp->deName[0] == SLOT_DELETED) {
- chksum = -1;
- continue;
- }
-
- /*
- * Handle Win95 long directory entries
- */
- if (dentp->deAttributes == ATTR_WIN95) {
- if (pmp->pm_flags & MSDOSFSMNT_SHORTNAME)
- continue;
- chksum = win2unixfn((struct winentry *)dentp,
- &dirbuf, chksum,
- pmp->pm_flags & MSDOSFSMNT_U2WTABLE,
- pmp->pm_u2w);
- continue;
- }
-
- /*
- * Skip volume labels
- */
- if (dentp->deAttributes & ATTR_VOLUME) {
- chksum = -1;
- continue;
- }
- /*
- * This computation of d_fileno must match
- * the computation of va_fileid in
- * msdosfs_getattr.
- */
- if (dentp->deAttributes & ATTR_DIRECTORY) {
- fileno = getushort(dentp->deStartCluster);
- if (FAT32(pmp))
- fileno |= getushort(dentp->deHighClust) << 16;
- /* if this is the root directory */
- if (fileno == MSDOSFSROOT)
- if (FAT32(pmp))
- fileno = cntobn(pmp,
- pmp->pm_rootdirblk)
- * dirsperblk;
- else
- fileno = 1;
- else
- fileno = cntobn(pmp, fileno) * dirsperblk;
- dirbuf.d_fileno = fileno;
- dirbuf.d_type = DT_DIR;
- } else {
- dirbuf.d_fileno = offset / sizeof(struct direntry);
- dirbuf.d_type = DT_REG;
- }
- if (chksum != winChksum(dentp->deName))
- dirbuf.d_namlen = dos2unixfn(dentp->deName,
- (u_char *)dirbuf.d_name,
- dentp->deLowerCase |
- ((pmp->pm_flags & MSDOSFSMNT_SHORTNAME) ?
- (LCASE_BASE | LCASE_EXT) : 0),
- pmp->pm_flags & MSDOSFSMNT_U2WTABLE,
- pmp->pm_d2u,
- pmp->pm_flags & MSDOSFSMNT_ULTABLE,
- pmp->pm_ul);
- else
- dirbuf.d_name[dirbuf.d_namlen] = 0;
- chksum = -1;
- dirbuf.d_reclen = GENERIC_DIRSIZ(&dirbuf);
- if (uio->uio_resid < dirbuf.d_reclen) {
- brelse(bp);
- goto out;
- }
- error = uiomove((caddr_t) &dirbuf,
- dirbuf.d_reclen, uio);
- if (error) {
- brelse(bp);
- goto out;
- }
- if (cookies) {
- *cookies++ = offset + sizeof(struct direntry);
- if (--ncookies <= 0) {
- brelse(bp);
- goto out;
- }
- }
- off = offset + sizeof(struct direntry);
- }
- brelse(bp);
- }
-out:
- /* Subtract unused cookies */
- if (ap->a_ncookies)
- *ap->a_ncookies -= ncookies;
-
- uio->uio_offset = off;
-
- /*
- * Set the eofflag (NFS uses it)
- */
- if (ap->a_eofflag) {
- if (dep->de_FileSize - (offset - bias) <= 0)
- *ap->a_eofflag = 1;
- else
- *ap->a_eofflag = 0;
- }
- return (error);
-}
-
-/*
- * vp - address of vnode file the file
- * bn - which cluster we are interested in mapping to a filesystem block number.
- * vpp - returns the vnode for the block special file holding the filesystem
- * containing the file of interest
- * bnp - address of where to return the filesystem relative block number
- */
-static int
-msdosfs_bmap(ap)
- struct vop_bmap_args /* {
- struct vnode *a_vp;
- daddr_t a_bn;
- struct vnode **a_vpp;
- daddr_t *a_bnp;
- int *a_runp;
- int *a_runb;
- } */ *ap;
-{
- struct denode *dep = VTODE(ap->a_vp);
-
- if (ap->a_vpp != NULL)
- *ap->a_vpp = dep->de_devvp;
- if (ap->a_bnp == NULL)
- return (0);
- if (ap->a_runp) {
- /*
- * Sequential clusters should be counted here.
- */
- *ap->a_runp = 0;
- }
- if (ap->a_runb) {
- *ap->a_runb = 0;
- }
- return (pcbmap(dep, ap->a_bn, ap->a_bnp, 0, 0));
-}
-
-static int
-msdosfs_strategy(ap)
- struct vop_strategy_args /* {
- struct vnode *a_vp;
- struct buf *a_bp;
- } */ *ap;
-{
- struct buf *bp = ap->a_bp;
- struct denode *dep = VTODE(bp->b_vp);
- struct vnode *vp;
- int error = 0;
-
- if (bp->b_vp->v_type == VBLK || bp->b_vp->v_type == VCHR)
- panic("msdosfs_strategy: spec");
- /*
- * If we don't already know the filesystem relative block number
- * then get it using pcbmap(). If pcbmap() returns the block
- * number as -1 then we've got a hole in the file. DOS filesystems
- * don't allow files with holes, so we shouldn't ever see this.
- */
- if (bp->b_blkno == bp->b_lblkno) {
- error = pcbmap(dep, bp->b_lblkno, &bp->b_blkno, 0, 0);
- if (error) {
- bp->b_error = error;
- bp->b_flags |= B_ERROR;
- biodone(bp);
- return (error);
- }
- if ((long)bp->b_blkno == -1)
- vfs_bio_clrbuf(bp);
- }
- if (bp->b_blkno == -1) {
- biodone(bp);
- return (0);
- }
- /*
- * Read/write the block from/to the disk that contains the desired
- * file block.
- */
- vp = dep->de_devvp;
- bp->b_dev = vp->v_rdev;
- VOP_STRATEGY(vp, bp);
- return (0);
-}
-
-static int
-msdosfs_print(ap)
- struct vop_print_args /* {
- struct vnode *vp;
- } */ *ap;
-{
- struct denode *dep = VTODE(ap->a_vp);
-
- printf(
- "tag VT_MSDOSFS, startcluster %lu, dircluster %lu, diroffset %lu ",
- dep->de_StartCluster, dep->de_dirclust, dep->de_diroffset);
- printf(" dev %d, %d", major(dep->de_dev), minor(dep->de_dev));
- lockmgr_printinfo(&dep->de_lock);
- printf("\n");
- return (0);
-}
-
-static int
-msdosfs_pathconf(ap)
- struct vop_pathconf_args /* {
- struct vnode *a_vp;
- int a_name;
- int *a_retval;
- } */ *ap;
-{
- struct msdosfsmount *pmp = VTODE(ap->a_vp)->de_pmp;
-
- switch (ap->a_name) {
- case _PC_LINK_MAX:
- *ap->a_retval = 1;
- return (0);
- case _PC_NAME_MAX:
- *ap->a_retval = pmp->pm_flags & MSDOSFSMNT_LONGNAME ? WIN_MAXLEN : 12;
- return (0);
- case _PC_PATH_MAX:
- *ap->a_retval = PATH_MAX;
- return (0);
- case _PC_CHOWN_RESTRICTED:
- *ap->a_retval = 1;
- return (0);
- case _PC_NO_TRUNC:
- *ap->a_retval = 0;
- return (0);
- default:
- return (EINVAL);
- }
- /* NOTREACHED */
-}
-
-/*
- * get page routine
- *
- * XXX By default, wimp out... note that a_offset is ignored (and always
- * XXX has been).
- */
-int
-msdosfs_getpages(ap)
- struct vop_getpages_args *ap;
-{
- return vnode_pager_generic_getpages(ap->a_vp, ap->a_m, ap->a_count,
- ap->a_reqpage);
-}
-
-/*
- * put page routine
- *
- * XXX By default, wimp out... note that a_offset is ignored (and always
- * XXX has been).
- */
-int
-msdosfs_putpages(ap)
- struct vop_putpages_args *ap;
-{
- return vnode_pager_generic_putpages(ap->a_vp, ap->a_m, ap->a_count,
- ap->a_sync, ap->a_rtvals);
-}
-
-/* Global vfs data structures for msdosfs */
-vop_t **msdosfs_vnodeop_p;
-static struct vnodeopv_entry_desc msdosfs_vnodeop_entries[] = {
- { &vop_default_desc, (vop_t *) vop_defaultop },
- { &vop_access_desc, (vop_t *) msdosfs_access },
- { &vop_bmap_desc, (vop_t *) msdosfs_bmap },
- { &vop_cachedlookup_desc, (vop_t *) msdosfs_lookup },
- { &vop_close_desc, (vop_t *) msdosfs_close },
- { &vop_create_desc, (vop_t *) msdosfs_create },
- { &vop_fsync_desc, (vop_t *) msdosfs_fsync },
- { &vop_getattr_desc, (vop_t *) msdosfs_getattr },
- { &vop_inactive_desc, (vop_t *) msdosfs_inactive },
- { &vop_islocked_desc, (vop_t *) vop_stdislocked },
- { &vop_link_desc, (vop_t *) msdosfs_link },
- { &vop_lock_desc, (vop_t *) vop_stdlock },
- { &vop_lookup_desc, (vop_t *) vfs_cache_lookup },
- { &vop_mkdir_desc, (vop_t *) msdosfs_mkdir },
- { &vop_mknod_desc, (vop_t *) msdosfs_mknod },
- { &vop_pathconf_desc, (vop_t *) msdosfs_pathconf },
- { &vop_print_desc, (vop_t *) msdosfs_print },
- { &vop_read_desc, (vop_t *) msdosfs_read },
- { &vop_readdir_desc, (vop_t *) msdosfs_readdir },
- { &vop_reclaim_desc, (vop_t *) msdosfs_reclaim },
- { &vop_remove_desc, (vop_t *) msdosfs_remove },
- { &vop_rename_desc, (vop_t *) msdosfs_rename },
- { &vop_rmdir_desc, (vop_t *) msdosfs_rmdir },
- { &vop_setattr_desc, (vop_t *) msdosfs_setattr },
- { &vop_strategy_desc, (vop_t *) msdosfs_strategy },
- { &vop_symlink_desc, (vop_t *) msdosfs_symlink },
- { &vop_unlock_desc, (vop_t *) vop_stdunlock },
- { &vop_write_desc, (vop_t *) msdosfs_write },
- { &vop_getpages_desc, (vop_t *) msdosfs_getpages },
- { &vop_putpages_desc, (vop_t *) msdosfs_putpages },
- { NULL, NULL }
-};
-static struct vnodeopv_desc msdosfs_vnodeop_opv_desc =
- { &msdosfs_vnodeop_p, msdosfs_vnodeop_entries };
-
-VNODEOP_SET(msdosfs_vnodeop_opv_desc);
diff --git a/sys/fs/msdosfs/msdosfsmount.h b/sys/fs/msdosfs/msdosfsmount.h
deleted file mode 100644
index 59cc7c9eae48..000000000000
--- a/sys/fs/msdosfs/msdosfsmount.h
+++ /dev/null
@@ -1,245 +0,0 @@
-/* $FreeBSD$ */
-/* $NetBSD: msdosfsmount.h,v 1.17 1997/11/17 15:37:07 ws Exp $ */
-
-/*-
- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
- * Copyright (C) 1994, 1995, 1997 TooLs GmbH.
- * All rights reserved.
- * Original code by Paul Popelka (paulp@uts.amdahl.com) (see below).
- *
- * 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 TooLs GmbH.
- * 4. The name of TooLs GmbH may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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.
- */
-/*
- * Written by Paul Popelka (paulp@uts.amdahl.com)
- *
- * You can do anything you want with this software, just don't say you wrote
- * it, and don't remove this notice.
- *
- * This software is provided "as is".
- *
- * The author supplies this software to be publicly redistributed on the
- * understanding that the author is not responsible for the correct
- * functioning of this software in any circumstances and is not liable for
- * any damages caused by this software.
- *
- * October 1992
- */
-
-#ifndef _MSDOSFS_MSDOSFSMOUNT_H_
-#define _MSDOSFS_MSDOSFSMOUNT_H_
-
-#ifdef _KERNEL
-
-#ifdef MALLOC_DECLARE
-MALLOC_DECLARE(M_MSDOSFSMNT);
-#endif
-
-/*
- * Layout of the mount control block for a msdos file system.
- */
-struct msdosfsmount {
- struct mount *pm_mountp;/* vfs mount struct for this fs */
- dev_t pm_dev; /* block special device mounted */
- uid_t pm_uid; /* uid to set as owner of the files */
- gid_t pm_gid; /* gid to set as owner of the files */
- mode_t pm_mask; /* mask to and with file protection bits */
- struct vnode *pm_devvp; /* vnode for block device mntd */
- struct bpb50 pm_bpb; /* BIOS parameter blk for this fs */
- u_long pm_BlkPerSec; /* How many DEV_BSIZE blocks fit inside a physical sector */
- u_long pm_FATsecs; /* actual number of fat sectors */
- u_long pm_fatblk; /* block # of first FAT */
- u_long pm_rootdirblk; /* block # (cluster # for FAT32) of root directory number */
- u_long pm_rootdirsize; /* size in blocks (not clusters) */
- u_long pm_firstcluster; /* block number of first cluster */
- u_long pm_maxcluster; /* maximum cluster number */
- u_long pm_freeclustercount; /* number of free clusters */
- u_long pm_cnshift; /* shift file offset right this amount to get a cluster number */
- u_long pm_crbomask; /* and a file offset with this mask to get cluster rel offset */
- u_long pm_bnshift; /* shift file offset right this amount to get a block number */
- u_long pm_bpcluster; /* bytes per cluster */
- u_long pm_fmod; /* ~0 if fs is modified, this can rollover to 0 */
- u_long pm_fatblocksize; /* size of fat blocks in bytes */
- u_long pm_fatblocksec; /* size of fat blocks in sectors */
- u_long pm_fatsize; /* size of fat in bytes */
- u_long pm_fatmask; /* mask to use for fat numbers */
- u_long pm_fsinfo; /* fsinfo block number */
- u_long pm_nxtfree; /* next free cluster in fsinfo block */
- u_int pm_fatmult; /* these 2 values are used in fat */
- u_int pm_fatdiv; /* offset computation */
- u_int pm_curfat; /* current fat for FAT32 (0 otherwise) */
- u_int *pm_inusemap; /* ptr to bitmap of in-use clusters */
- u_int pm_flags; /* see below */
- struct netexport pm_export; /* export information */
- u_int16_t pm_u2w[128]; /* Local->Unicode table */
- u_int8_t pm_ul[128]; /* Local upper->lower table */
- u_int8_t pm_lu[128]; /* Local lower->upper table */
- u_int8_t pm_d2u[128]; /* DOS->local table */
- u_int8_t pm_u2d[128]; /* Local->DOS table */
-};
-/* Byte offset in FAT on filesystem pmp, cluster cn */
-#define FATOFS(pmp, cn) ((cn) * (pmp)->pm_fatmult / (pmp)->pm_fatdiv)
-
-
-#define VFSTOMSDOSFS(mp) ((struct msdosfsmount *)mp->mnt_data)
-
-/* Number of bits in one pm_inusemap item: */
-#define N_INUSEBITS (8 * sizeof(u_int))
-
-/*
- * Shorthand for fields in the bpb contained in the msdosfsmount structure.
- */
-#define pm_BytesPerSec pm_bpb.bpbBytesPerSec
-#define pm_ResSectors pm_bpb.bpbResSectors
-#define pm_FATs pm_bpb.bpbFATs
-#define pm_RootDirEnts pm_bpb.bpbRootDirEnts
-#define pm_Sectors pm_bpb.bpbSectors
-#define pm_Media pm_bpb.bpbMedia
-#define pm_SecPerTrack pm_bpb.bpbSecPerTrack
-#define pm_Heads pm_bpb.bpbHeads
-#define pm_HiddenSects pm_bpb.bpbHiddenSecs
-#define pm_HugeSectors pm_bpb.bpbHugeSectors
-
-/*
- * Convert pointer to buffer -> pointer to direntry
- */
-#define bptoep(pmp, bp, dirofs) \
- ((struct direntry *)(((bp)->b_data) \
- + ((dirofs) & (pmp)->pm_crbomask)))
-
-/*
- * Convert block number to cluster number
- */
-#define de_bn2cn(pmp, bn) \
- ((bn) >> ((pmp)->pm_cnshift - (pmp)->pm_bnshift))
-
-/*
- * Convert cluster number to block number
- */
-#define de_cn2bn(pmp, cn) \
- ((cn) << ((pmp)->pm_cnshift - (pmp)->pm_bnshift))
-
-/*
- * Convert file offset to cluster number
- */
-#define de_cluster(pmp, off) \
- ((off) >> (pmp)->pm_cnshift)
-
-/*
- * Clusters required to hold size bytes
- */
-#define de_clcount(pmp, size) \
- (((size) + (pmp)->pm_bpcluster - 1) >> (pmp)->pm_cnshift)
-
-/*
- * Convert file offset to block number
- */
-#define de_blk(pmp, off) \
- (de_cn2bn(pmp, de_cluster((pmp), (off))))
-
-/*
- * Convert cluster number to file offset
- */
-#define de_cn2off(pmp, cn) \
- ((cn) << (pmp)->pm_cnshift)
-
-/*
- * Convert block number to file offset
- */
-#define de_bn2off(pmp, bn) \
- ((bn) << (pmp)->pm_bnshift)
-/*
- * Map a cluster number into a filesystem relative block number.
- */
-#define cntobn(pmp, cn) \
- (de_cn2bn((pmp), (cn)-CLUST_FIRST) + (pmp)->pm_firstcluster)
-
-/*
- * Calculate block number for directory entry in root dir, offset dirofs
- */
-#define roottobn(pmp, dirofs) \
- (de_blk((pmp), (dirofs)) + (pmp)->pm_rootdirblk)
-
-/*
- * Calculate block number for directory entry at cluster dirclu, offset
- * dirofs
- */
-#define detobn(pmp, dirclu, dirofs) \
- ((dirclu) == MSDOSFSROOT \
- ? roottobn((pmp), (dirofs)) \
- : cntobn((pmp), (dirclu)))
-
-/*
- * Calculate fsinfo block size
- */
-#define fsi_size(pmp) \
- (1024 << ((pmp)->pm_BlkPerSec >> 2))
-
-int msdosfs_init __P((struct vfsconf *vfsp));
-int msdosfs_mountroot __P((void));
-
-#endif /* _KERNEL */
-
-/*
- * Arguments to mount MSDOS filesystems.
- */
-struct msdosfs_args {
- char *fspec; /* blocks special holding the fs to mount */
- struct export_args export; /* network export information */
- uid_t uid; /* uid that owns msdosfs files */
- gid_t gid; /* gid that owns msdosfs files */
- mode_t mask; /* mask to be applied for msdosfs perms */
- int flags; /* see below */
- int magic; /* version number */
- u_int16_t u2w[128]; /* Local->Unicode table */
- u_int8_t ul[128]; /* Local upper->lower table */
- u_int8_t lu[128]; /* Local lower->upper table */
- u_int8_t d2u[128]; /* DOS->local table */
- u_int8_t u2d[128]; /* Local->DOS table */
-};
-
-/*
- * Msdosfs mount options:
- */
-#define MSDOSFSMNT_SHORTNAME 1 /* Force old DOS short names only */
-#define MSDOSFSMNT_LONGNAME 2 /* Force Win'95 long names */
-#define MSDOSFSMNT_NOWIN95 4 /* Completely ignore Win95 entries */
-#ifndef __FreeBSD__
-#define MSDOSFSMNT_GEMDOSFS 8 /* This is a gemdos-flavour */
-#endif
-#define MSDOSFSMNT_U2WTABLE 0x10 /* Local->Unicode and local<->DOS */
- /* tables loaded */
-#define MSDOSFSMNT_ULTABLE 0x20 /* Local upper<->lower table loaded */
-/* All flags above: */
-#define MSDOSFSMNT_MNTOPT \
- (MSDOSFSMNT_SHORTNAME|MSDOSFSMNT_LONGNAME|MSDOSFSMNT_NOWIN95 \
- /*|MSDOSFSMNT_GEMDOSFS*/|MSDOSFSMNT_U2WTABLE|MSDOSFSMNT_ULTABLE)
-#define MSDOSFSMNT_RONLY 0x80000000 /* mounted read-only */
-#define MSDOSFSMNT_WAITONFAT 0x40000000 /* mounted synchronous */
-#define MSDOSFS_FATMIRROR 0x20000000 /* FAT is mirrored */
-
-#define MSDOSFS_ARGSMAGIC 0xe4eff300
-
-#endif /* !_MSDOSFS_MSDOSFSMOUNT_H_ */
diff --git a/sys/fs/ntfs/ntfs.h b/sys/fs/ntfs/ntfs.h
deleted file mode 100644
index c4568612708d..000000000000
--- a/sys/fs/ntfs/ntfs.h
+++ /dev/null
@@ -1,336 +0,0 @@
-/* $NetBSD: ntfs.h,v 1.9 1999/10/31 19:45:26 jdolecek Exp $ */
-
-/*-
- * Copyright (c) 1998, 1999 Semen Ustimenko
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-/*#define NTFS_DEBUG 1*/
-#if defined(__NetBSD__) && defined(_KERNEL) && !defined(_LKM)
-#include "opt_ntfs.h"
-#endif
-
-typedef u_int64_t cn_t;
-typedef u_int16_t wchar;
-
-#pragma pack(1)
-#define BBSIZE 1024
-#define BBOFF ((off_t)(0))
-#define BBLOCK ((daddr_t)(0))
-#define NTFS_MFTINO 0
-#define NTFS_VOLUMEINO 3
-#define NTFS_ATTRDEFINO 4
-#define NTFS_ROOTINO 5
-#define NTFS_BITMAPINO 6
-#define NTFS_BOOTINO 7
-#define NTFS_BADCLUSINO 8
-#define NTFS_UPCASEINO 10
-#define NTFS_MAXFILENAME 255
-
-struct fixuphdr {
- u_int32_t fh_magic;
- u_int16_t fh_foff;
- u_int16_t fh_fnum;
-};
-
-#define NTFS_AF_INRUN 0x00000001
-struct attrhdr {
- u_int32_t a_type;
- u_int32_t reclen;
- u_int8_t a_flag;
- u_int8_t a_namelen;
- u_int8_t a_nameoff;
- u_int8_t reserved1;
- u_int8_t a_compression;
- u_int8_t reserved2;
- u_int16_t a_index;
-};
-#define NTFS_A_STD 0x10
-#define NTFS_A_ATTRLIST 0x20
-#define NTFS_A_NAME 0x30
-#define NTFS_A_VOLUMENAME 0x60
-#define NTFS_A_DATA 0x80
-#define NTFS_A_INDXROOT 0x90
-#define NTFS_A_INDX 0xA0
-#define NTFS_A_INDXBITMAP 0xB0
-
-#define NTFS_MAXATTRNAME 255
-struct attr {
- struct attrhdr a_hdr;
- union {
- struct {
- u_int16_t a_datalen;
- u_int16_t reserved1;
- u_int16_t a_dataoff;
- u_int16_t a_indexed;
- } a_S_r;
- struct {
- cn_t a_vcnstart;
- cn_t a_vcnend;
- u_int16_t a_dataoff;
- u_int16_t a_compressalg;
- u_int32_t reserved1;
- u_int64_t a_allocated;
- u_int64_t a_datalen;
- u_int64_t a_initialized;
- } a_S_nr;
- } a_S;
-};
-#define a_r a_S.a_S_r
-#define a_nr a_S.a_S_nr
-
-typedef struct {
- u_int64_t t_create;
- u_int64_t t_write;
- u_int64_t t_mftwrite;
- u_int64_t t_access;
-} ntfs_times_t;
-
-#define NTFS_FFLAG_RDONLY 0x01LL
-#define NTFS_FFLAG_HIDDEN 0x02LL
-#define NTFS_FFLAG_SYSTEM 0x04LL
-#define NTFS_FFLAG_ARCHIVE 0x20LL
-#define NTFS_FFLAG_COMPRESSED 0x0800LL
-#define NTFS_FFLAG_DIR 0x10000000LL
-
-struct attr_name {
- u_int32_t n_pnumber; /* Parent ntnode */
- u_int32_t reserved;
- ntfs_times_t n_times;
- u_int64_t n_size;
- u_int64_t n_attrsz;
- u_int64_t n_flag;
- u_int8_t n_namelen;
- u_int8_t n_nametype;
- u_int16_t n_name[1];
-};
-
-#define NTFS_IRFLAG_INDXALLOC 0x00000001
-struct attr_indexroot {
- u_int32_t ir_unkn1; /* always 0x30 */
- u_int32_t ir_unkn2; /* always 0x1 */
- u_int32_t ir_size;/* ??? */
- u_int32_t ir_unkn3; /* number of cluster */
- u_int32_t ir_unkn4; /* always 0x10 */
- u_int32_t ir_datalen; /* sizeof simething */
- u_int32_t ir_allocated; /* same as above */
- u_int16_t ir_flag;/* ?? always 1 */
- u_int16_t ir_unkn7;
-};
-
-struct attr_attrlist {
- u_int32_t al_type; /* Attribute type */
- u_int16_t reclen; /* length of this entry */
- u_int8_t al_namelen; /* Attribute name len */
- u_int8_t al_nameoff; /* Name offset from entry start */
- u_int64_t al_vcnstart; /* VCN number */
- u_int32_t al_inumber; /* Parent ntnode */
- u_int32_t reserved;
- u_int16_t al_index; /* Attribute index in MFT record */
- u_int16_t al_name[1]; /* Name */
-};
-
-#define NTFS_INDXMAGIC (u_int32_t)(0x58444E49)
-struct attr_indexalloc {
- struct fixuphdr ia_fixup;
- u_int64_t unknown1;
- cn_t ia_bufcn;
- u_int16_t ia_hdrsize;
- u_int16_t unknown2;
- u_int32_t ia_inuse;
- u_int32_t ia_allocated;
-};
-
-#define NTFS_IEFLAG_SUBNODE 0x00000001
-#define NTFS_IEFLAG_LAST 0x00000002
-
-struct attr_indexentry {
- u_int32_t ie_number;
- u_int32_t unknown1;
- u_int16_t reclen;
- u_int16_t ie_size;
- u_int32_t ie_flag;/* 1 - has subnodes, 2 - last */
- u_int32_t ie_fpnumber;
- u_int32_t unknown2;
- ntfs_times_t ie_ftimes;
- u_int64_t ie_fallocated;
- u_int64_t ie_fsize;
- u_int64_t ie_fflag;
- u_int8_t ie_fnamelen;
- u_int8_t ie_fnametype;
- wchar ie_fname[NTFS_MAXFILENAME];
- /* cn_t ie_bufcn; buffer with subnodes */
-};
-
-#define NTFS_FILEMAGIC (u_int32_t)(0x454C4946)
-#define NTFS_FRFLAG_DIR 0x0002
-struct filerec {
- struct fixuphdr fr_fixup;
- u_int8_t reserved[8];
- u_int16_t fr_seqnum; /* Sequence number */
- u_int16_t fr_nlink;
- u_int16_t fr_attroff; /* offset to attributes */
- u_int16_t fr_flags; /* 1-nonresident attr, 2-directory */
- u_int32_t fr_size;/* hdr + attributes */
- u_int32_t fr_allocated; /* allocated length of record */
- u_int64_t fr_mainrec; /* main record */
- u_int16_t fr_attrnum; /* maximum attr number + 1 ??? */
-};
-
-#define NTFS_ATTRNAME_MAXLEN 0x40
-#define NTFS_ADFLAG_NONRES 0x0080 /* Attrib can be non resident */
-#define NTFS_ADFLAG_INDEX 0x0002 /* Attrib can be indexed */
-struct attrdef {
- wchar ad_name[NTFS_ATTRNAME_MAXLEN];
- u_int32_t ad_type;
- u_int32_t reserved1[2];
- u_int32_t ad_flag;
- u_int64_t ad_minlen;
- u_int64_t ad_maxlen; /* -1 for nonlimited */
-};
-
-struct ntvattrdef {
- char ad_name[0x40];
- int ad_namelen;
- u_int32_t ad_type;
-};
-
-#define NTFS_BBID "NTFS "
-#define NTFS_BBIDLEN 8
-struct bootfile {
- u_int8_t reserved1[3]; /* asm jmp near ... */
- u_int8_t bf_sysid[8]; /* 'NTFS ' */
- u_int16_t bf_bps; /* bytes per sector */
- u_int8_t bf_spc; /* sectors per cluster */
- u_int8_t reserved2[7]; /* unused (zeroed) */
- u_int8_t bf_media; /* media desc. (0xF8) */
- u_int8_t reserved3[2];
- u_int16_t bf_spt; /* sectors per track */
- u_int16_t bf_heads; /* number of heads */
- u_int8_t reserver4[12];
- u_int64_t bf_spv; /* sectors per volume */
- cn_t bf_mftcn; /* $MFT cluster number */
- cn_t bf_mftmirrcn; /* $MFTMirr cn */
- u_int8_t bf_mftrecsz; /* MFT record size (clust) */
- /* 0xF6 inducates 1/4 */
- u_int32_t bf_ibsz; /* index buffer size */
- u_int32_t bf_volsn; /* volume ser. num. */
-};
-
-#define NTFS_SYSNODESNUM 0x0B
-struct ntfsmount {
- struct mount *ntm_mountp; /* filesystem vfs structure */
- struct bootfile ntm_bootfile;
- dev_t ntm_dev; /* device mounted */
- struct vnode *ntm_devvp; /* block device mounted vnode */
- struct vnode *ntm_sysvn[NTFS_SYSNODESNUM];
- u_int32_t ntm_bpmftrec;
- uid_t ntm_uid;
- gid_t ntm_gid;
- mode_t ntm_mode;
- u_long ntm_flag;
- cn_t ntm_cfree;
- struct ntvattrdef *ntm_ad;
- int ntm_adnum;
- struct netexport ntm_export; /* export information */
-};
-
-#define ntm_mftcn ntm_bootfile.bf_mftcn
-#define ntm_mftmirrcn ntm_bootfile.bf_mftmirrcn
-#define ntm_mftrecsz ntm_bootfile.bf_mftrecsz
-#define ntm_spc ntm_bootfile.bf_spc
-#define ntm_bps ntm_bootfile.bf_bps
-
-#pragma pack()
-
-#define NTFS_NEXTREC(s, type) ((type)(((caddr_t) s) + (s)->reclen))
-
-/* Convert mount ptr to ntfsmount ptr. */
-#define VFSTONTFS(mp) ((struct ntfsmount *)((mp)->mnt_data))
-#define VTONT(v) FTONT(VTOF(v))
-#define VTOF(v) ((struct fnode *)((v)->v_data))
-#define FTOV(f) ((f)->f_vp)
-#define FTONT(f) ((f)->f_ip)
-#define ntfs_cntobn(cn) (daddr_t)((cn) * (ntmp->ntm_spc))
-#define ntfs_cntob(cn) (off_t)((cn) * (ntmp)->ntm_spc * (ntmp)->ntm_bps)
-#define ntfs_btocn(off) (cn_t)((off) / ((ntmp)->ntm_spc * (ntmp)->ntm_bps))
-#define ntfs_btocl(off) (cn_t)((off + ntfs_cntob(1) - 1) / ((ntmp)->ntm_spc * (ntmp)->ntm_bps))
-#define ntfs_btocnoff(off) (off_t)((off) % ((ntmp)->ntm_spc * (ntmp)->ntm_bps))
-#define ntfs_bntob(bn) (daddr_t)((bn) * (ntmp)->ntm_bps)
-
-#define ntfs_bpbl (daddr_t)((ntmp)->ntm_bps)
-
-#ifdef MALLOC_DECLARE
-MALLOC_DECLARE(M_NTFSMNT);
-MALLOC_DECLARE(M_NTFSNTNODE);
-MALLOC_DECLARE(M_NTFSFNODE);
-MALLOC_DECLARE(M_NTFSDIR);
-MALLOC_DECLARE(M_NTFSNTHASH);
-#endif
-
-#ifdef __NetBSD__
-#define MALLOC_DEFINE(a, b, c)
-#define M_NTFSNTHASH M_NTFS
-#define M_NTFSNTVATTR M_NTFS
-#define M_NTFSRDATA M_NTFS
-#define M_NTFSRUN M_NTFS
-#define M_NTFSDECOMP M_NTFS
-#define M_NTFSMNT M_NTFS
-#define M_NTFSNTNODE M_NTFS
-#define M_NTFSFNODE M_NTFS
-#define M_NTFSDIR M_NTFS
-typedef int (vop_t) __P((void *));
-#define HASHINIT(a, b, c, d) hashinit((a), (b), (c), (d))
-#define bqrelse(bp) brelse(bp)
-#define VOP__UNLOCK(a, b, c) VOP_UNLOCK((a), (b))
-#define VGET(a, b, c) vget((a), (b))
-#define VN_LOCK(a, b, c) vn_lock((a), (b))
-#define LOCKMGR(a, b, c) lockmgr((a), (b), (c))
-#else /* !NetBSD */
-#define HASHINIT(a, b, c, d) hashinit((a), (b), (d))
-#define VOP__UNLOCK(a, b, c) VOP_UNLOCK((a), (b), (c))
-#define VGET(a, b, c) vget((a), (b), (c))
-#define VN_LOCK(a, b, c) vn_lock((a), (b), (c))
-#define LOCKMGR(a, b, c) lockmgr((a), (b), (c), NULL)
-
-/* PDIRUNLOCK is used by NetBSD to mark if vfs_lookup() unlocked parent dir;
- * on FreeBSD, it's not defined and nothing similar exists */
-#define PDIRUNLOCK 0
-#endif /* NetBSD */
-
-#if defined(NTFS_DEBUG)
-#define dprintf(a) printf a
-#if NTFS_DEBUG > 1
-#define ddprintf(a) printf a
-#else
-#define ddprintf(a)
-#endif
-#else
-#define dprintf(a)
-#define ddprintf(a)
-#endif
-
-extern vop_t **ntfs_vnodeop_p;
diff --git a/sys/fs/ntfs/ntfs_compr.c b/sys/fs/ntfs/ntfs_compr.c
deleted file mode 100644
index 114a6afeb137..000000000000
--- a/sys/fs/ntfs/ntfs_compr.c
+++ /dev/null
@@ -1,119 +0,0 @@
-/* $NetBSD: ntfs_compr.c,v 1.3 1999/07/26 14:02:31 jdolecek Exp $ */
-
-/*-
- * Copyright (c) 1998, 1999 Semen Ustimenko
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/namei.h>
-#include <sys/proc.h>
-#include <sys/kernel.h>
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <sys/buf.h>
-#include <sys/file.h>
-#include <sys/malloc.h>
-
-#if defined(__NetBSD__)
-#include <miscfs/specfs/specdev.h>
-#endif
-
-#include <ntfs/ntfs.h>
-#include <ntfs/ntfs_compr.h>
-
-#define GET_UINT16(addr) (*((u_int16_t *)(addr)))
-
-int
-ntfs_uncompblock(
- u_int8_t * buf,
- u_int8_t * cbuf)
-{
- u_int32_t ctag;
- int len, dshift, lmask;
- int blen, boff;
- int i, j;
- int pos, cpos;
-
- len = GET_UINT16(cbuf) & 0xFFF;
- dprintf(("ntfs_uncompblock: block length: %d + 3, 0x%x,0x%04x\n",
- len, len, GET_UINT16(cbuf)));
-
- if (!(GET_UINT16(cbuf) & 0x8000)) {
- if ((len + 1) != NTFS_COMPBLOCK_SIZE) {
- dprintf(("ntfs_uncompblock: len: %x instead of %d\n",
- len, 0xfff));
- }
- memcpy(buf, cbuf + 2, len + 1);
- bzero(buf + len + 1, NTFS_COMPBLOCK_SIZE - 1 - len);
- return len + 3;
- }
- cpos = 2;
- pos = 0;
- while ((cpos < len + 3) && (pos < NTFS_COMPBLOCK_SIZE)) {
- ctag = cbuf[cpos++];
- for (i = 0; (i < 8) && (pos < NTFS_COMPBLOCK_SIZE); i++) {
- if (ctag & 1) {
- for (j = pos - 1, lmask = 0xFFF, dshift = 12;
- j >= 0x10; j >>= 1) {
- dshift--;
- lmask >>= 1;
- }
- boff = -1 - (GET_UINT16(cbuf + cpos) >> dshift);
- blen = 3 + (GET_UINT16(cbuf + cpos) & lmask);
- for (j = 0; (j < blen) && (pos < NTFS_COMPBLOCK_SIZE); j++) {
- buf[pos] = buf[pos + boff];
- pos++;
- }
- cpos += 2;
- } else {
- buf[pos++] = cbuf[cpos++];
- }
- ctag >>= 1;
- }
- }
- return len + 3;
-}
-
-int
-ntfs_uncompunit(
- struct ntfsmount * ntmp,
- u_int8_t * uup,
- u_int8_t * cup)
-{
- int i;
- int off = 0;
- int new;
-
- for (i = 0; i * NTFS_COMPBLOCK_SIZE < ntfs_cntob(NTFS_COMPUNIT_CL); i++) {
- new = ntfs_uncompblock(uup + i * NTFS_COMPBLOCK_SIZE, cup + off);
- if (new == 0)
- return (EINVAL);
- off += new;
- }
- return (0);
-}
diff --git a/sys/fs/ntfs/ntfs_compr.h b/sys/fs/ntfs/ntfs_compr.h
deleted file mode 100644
index e51bc09f2fda..000000000000
--- a/sys/fs/ntfs/ntfs_compr.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* $NetBSD: ntfs_compr.h,v 1.3 1999/07/26 14:02:31 jdolecek Exp $ */
-
-/*-
- * Copyright (c) 1998, 1999 Semen Ustimenko
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#define NTFS_COMPBLOCK_SIZE 0x1000
-#define NTFS_COMPUNIT_CL 16
-
-int ntfs_uncompblock(u_int8_t *, u_int8_t *);
-int ntfs_uncompunit(struct ntfsmount *, u_int8_t *, u_int8_t *);
diff --git a/sys/fs/ntfs/ntfs_ihash.c b/sys/fs/ntfs/ntfs_ihash.c
deleted file mode 100644
index 0deecff73851..000000000000
--- a/sys/fs/ntfs/ntfs_ihash.c
+++ /dev/null
@@ -1,130 +0,0 @@
-/* $NetBSD: ntfs_ihash.c,v 1.5 1999/09/30 16:56:40 jdolecek Exp $ */
-
-/*
- * Copyright (c) 1982, 1986, 1989, 1991, 1993, 1995
- * 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)ufs_ihash.c 8.7 (Berkeley) 5/17/95
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/lock.h>
-#include <sys/vnode.h>
-#include <sys/malloc.h>
-#include <sys/proc.h>
-#include <sys/mount.h>
-
-#include <ntfs/ntfs.h>
-#include <ntfs/ntfs_inode.h>
-#include <ntfs/ntfs_ihash.h>
-
-MALLOC_DEFINE(M_NTFSNTHASH, "NTFS nthash", "NTFS ntnode hash tables");
-
-/*
- * Structures associated with inode cacheing.
- */
-static LIST_HEAD(nthashhead, ntnode) *ntfs_nthashtbl;
-static u_long ntfs_nthash; /* size of hash table - 1 */
-#define NTNOHASH(device, inum) (&ntfs_nthashtbl[(minor(device) + (inum)) & ntfs_nthash])
-#ifndef NULL_SIMPLELOCKS
-static struct simplelock ntfs_nthash_slock;
-#endif
-struct lock ntfs_hashlock;
-
-/*
- * Initialize inode hash table.
- */
-void
-ntfs_nthashinit()
-{
- lockinit(&ntfs_hashlock, PINOD, "ntfs_nthashlock", 0, 0);
- ntfs_nthashtbl = HASHINIT(desiredvnodes, M_NTFSNTHASH, M_WAITOK,
- &ntfs_nthash);
- simple_lock_init(&ntfs_nthash_slock);
-}
-
-/*
- * Use the device/inum pair to find the incore inode, and return a pointer
- * to it. If it is in core, return it, even if it is locked.
- */
-struct ntnode *
-ntfs_nthashlookup(dev, inum)
- dev_t dev;
- ino_t inum;
-{
- struct ntnode *ip;
-
- simple_lock(&ntfs_nthash_slock);
- for (ip = NTNOHASH(dev, inum)->lh_first; ip; ip = ip->i_hash.le_next)
- if (inum == ip->i_number && dev == ip->i_dev)
- break;
- simple_unlock(&ntfs_nthash_slock);
-
- return (ip);
-}
-
-/*
- * Insert the ntnode into the hash table.
- */
-void
-ntfs_nthashins(ip)
- struct ntnode *ip;
-{
- struct nthashhead *ipp;
-
- simple_lock(&ntfs_nthash_slock);
- ipp = NTNOHASH(ip->i_dev, ip->i_number);
- LIST_INSERT_HEAD(ipp, ip, i_hash);
- ip->i_flag |= IN_HASHED;
- simple_unlock(&ntfs_nthash_slock);
-}
-
-/*
- * Remove the inode from the hash table.
- */
-void
-ntfs_nthashrem(ip)
- struct ntnode *ip;
-{
- simple_lock(&ntfs_nthash_slock);
- if (ip->i_flag & IN_HASHED) {
- ip->i_flag &= ~IN_HASHED;
- LIST_REMOVE(ip, i_hash);
-#ifdef DIAGNOSTIC
- ip->i_hash.le_next = NULL;
- ip->i_hash.le_prev = NULL;
-#endif
- }
- simple_unlock(&ntfs_nthash_slock);
-}
diff --git a/sys/fs/ntfs/ntfs_ihash.h b/sys/fs/ntfs/ntfs_ihash.h
deleted file mode 100644
index 7b7143f2f0a7..000000000000
--- a/sys/fs/ntfs/ntfs_ihash.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/* $NetBSD: ntfs_ihash.h,v 1.4 1999/09/30 16:56:40 jdolecek Exp $ */
-
-/*-
- * Copyright (c) 1998, 1999 Semen Ustimenko
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-extern struct lock ntfs_hashlock;
-void ntfs_nthashinit __P((void));
-struct ntnode *ntfs_nthashlookup __P((dev_t, ino_t));
-struct ntnode *ntfs_nthashget __P((dev_t, ino_t));
-void ntfs_nthashins __P((struct ntnode *));
-void ntfs_nthashrem __P((register struct ntnode *));
diff --git a/sys/fs/ntfs/ntfs_inode.h b/sys/fs/ntfs/ntfs_inode.h
deleted file mode 100644
index a86d5f7daa01..000000000000
--- a/sys/fs/ntfs/ntfs_inode.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/* $NetBSD: ntfs_inode.h,v 1.8 1999/10/31 19:45:26 jdolecek Exp $ */
-
-/*-
- * Copyright (c) 1998, 1999 Semen Ustimenko
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-/* These flags are kept in i_flag. */
-#if defined(__FreeBSD__)
-#define IN_ACCESS 0x0001 /* Access time update request. */
-#define IN_CHANGE 0x0002 /* Inode change time update request. */
-#define IN_UPDATE 0x0004 /* Modification time update request. */
-#define IN_MODIFIED 0x0008 /* Inode has been modified. */
-#define IN_RENAME 0x0010 /* Inode is being renamed. */
-#define IN_SHLOCK 0x0020 /* File has shared lock. */
-#define IN_EXLOCK 0x0040 /* File has exclusive lock. */
-#define IN_LAZYMOD 0x0080 /* Modified, but don't write yet. */
-#else /* defined(__NetBSD__) */
-#define IN_ACCESS 0x0001 /* Access time update request. */
-#define IN_CHANGE 0x0002 /* Inode change time update request. */
-#define IN_EXLOCK 0x0004 /* File has exclusive lock. */
-#define IN_LOCKED 0x0008 /* Inode lock. */
-#define IN_LWAIT 0x0010 /* Process waiting on file lock. */
-#define IN_MODIFIED 0x0020 /* Inode has been modified. */
-#define IN_RENAME 0x0040 /* Inode is being renamed. */
-#define IN_SHLOCK 0x0080 /* File has shared lock. */
-#define IN_UPDATE 0x0100 /* Modification time update request. */
-#define IN_WANTED 0x0200 /* Inode is wanted by a process. */
-#define IN_RECURSE 0x0400 /* Recursion expected */
-#endif
-
-#define IN_HASHED 0x0800 /* Inode is on hash list */
-#define IN_LOADED 0x8000 /* ntvattrs loaded */
-#define IN_PRELOADED 0x4000 /* loaded from directory entry */
-
-struct ntnode {
- struct vnode *i_devvp; /* vnode of blk dev we live on */
- dev_t i_dev; /* Device associated with the inode. */
-
- LIST_ENTRY(ntnode) i_hash;
- struct ntnode *i_next;
- struct ntnode **i_prev;
- struct ntfsmount *i_mp;
- ino_t i_number;
- u_int32_t i_flag;
-
- /* locking */
- struct lock i_lock;
- struct simplelock i_interlock;
- int i_usecount;
-
- LIST_HEAD(,fnode) i_fnlist;
- LIST_HEAD(,ntvattr) i_valist;
-
- long i_nlink; /* MFR */
- ino_t i_mainrec; /* MFR */
- u_int32_t i_frflag; /* MFR */
-};
-
-#define FN_PRELOADED 0x0001
-#define FN_VALID 0x0002
-#define FN_AATTRNAME 0x0004 /* space allocated for f_attrname */
-struct fnode {
-#ifdef __FreeBSD__
- struct lock f_lock; /* fnode lock >Keep this first< */
-#endif
-
- LIST_ENTRY(fnode) f_fnlist;
- struct vnode *f_vp; /* Associatied vnode */
- struct ntnode *f_ip; /* Associated ntnode */
- u_long f_flag;
-
- ntfs_times_t f_times; /* $NAME/dirinfo */
- ino_t f_pnumber; /* $NAME/dirinfo */
- u_int32_t f_fflag; /* $NAME/dirinfo */
- u_int64_t f_size; /* defattr/dirinfo: */
- u_int64_t f_allocated; /* defattr/dirinfo */
-
- u_int32_t f_attrtype;
- char *f_attrname;
-
- /* for ntreaddir */
- u_int32_t f_lastdattr;
- u_int32_t f_lastdblnum;
- u_int32_t f_lastdoff;
- u_int32_t f_lastdnum;
- caddr_t f_dirblbuf;
- u_int32_t f_dirblsz;
-};
-
-/* This overlays the fid structure (see <sys/mount.h>) */
-struct ntfid {
- u_int16_t ntfid_len; /* Length of structure. */
- u_int16_t ntfid_pad; /* Force 32-bit alignment. */
- ino_t ntfid_ino; /* File number (ino). */
- int32_t ntfid_gen; /* Generation number. */
-};
diff --git a/sys/fs/ntfs/ntfs_subr.c b/sys/fs/ntfs/ntfs_subr.c
deleted file mode 100644
index 7a75972a3758..000000000000
--- a/sys/fs/ntfs/ntfs_subr.c
+++ /dev/null
@@ -1,1995 +0,0 @@
-/* $NetBSD: ntfs_subr.c,v 1.23 1999/10/31 19:45:26 jdolecek Exp $ */
-
-/*-
- * Copyright (c) 1998, 1999 Semen Ustimenko (semenu@FreeBSD.org)
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/systm.h>
-#include <sys/namei.h>
-#include <sys/proc.h>
-#include <sys/kernel.h>
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <sys/buf.h>
-#include <sys/file.h>
-#include <sys/malloc.h>
-#include <sys/lock.h>
-
-#if defined(__NetBSD__)
-#include <miscfs/specfs/specdev.h>
-#endif
-
-/* #define NTFS_DEBUG 1 */
-#include <ntfs/ntfs.h>
-#include <ntfs/ntfsmount.h>
-#include <ntfs/ntfs_inode.h>
-#include <ntfs/ntfs_vfsops.h>
-#include <ntfs/ntfs_subr.h>
-#include <ntfs/ntfs_compr.h>
-#include <ntfs/ntfs_ihash.h>
-
-#if defined(__FreeBSD__)
-MALLOC_DEFINE(M_NTFSNTVATTR, "NTFS vattr", "NTFS file attribute information");
-MALLOC_DEFINE(M_NTFSRDATA, "NTFS res data", "NTFS resident data");
-MALLOC_DEFINE(M_NTFSRUN, "NTFS vrun", "NTFS vrun storage");
-MALLOC_DEFINE(M_NTFSDECOMP, "NTFS decomp", "NTFS decompression temporary");
-#endif
-
-static int ntfs_ntlookupattr __P((struct ntfsmount *, const char *, int, int *, char **));
-static int ntfs_findvattr __P((struct ntfsmount *, struct ntnode *, struct ntvattr **, struct ntvattr **, u_int32_t, const char *, size_t, cn_t));
-static int ntfs_uastricmp __P((const wchar *, size_t, const char *, size_t));
-static int ntfs_uastrcmp __P((const wchar *, size_t, const char *, size_t));
-
-/* table for mapping Unicode chars into uppercase; it's filled upon first
- * ntfs mount, freed upon last ntfs umount */
-static wchar *ntfs_toupper_tab;
-#define NTFS_U28(ch) ((((ch) & 0xFF) == 0) ? '_' : (ch) & 0xFF)
-#define NTFS_TOUPPER(ch) (ntfs_toupper_tab[(unsigned char)(ch)])
-static struct lock ntfs_toupper_lock;
-static signed int ntfs_toupper_usecount;
-
-/* support macro for ntfs_ntvattrget() */
-#define NTFS_AALPCMP(aalp,type,name,namelen) ( \
- (aalp->al_type == type) && (aalp->al_namelen == namelen) && \
- !ntfs_uastrcmp(aalp->al_name,aalp->al_namelen,name,namelen) )
-
-/*
- *
- */
-int
-ntfs_ntvattrrele(vap)
- struct ntvattr * vap;
-{
- dprintf(("ntfs_ntvattrrele: ino: %d, type: 0x%x\n",
- vap->va_ip->i_number, vap->va_type));
-
- ntfs_ntrele(vap->va_ip);
-
- return (0);
-}
-
-/*
- * find the attribute in the ntnode
- */
-static int
-ntfs_findvattr(ntmp, ip, lvapp, vapp, type, name, namelen, vcn)
- struct ntfsmount *ntmp;
- struct ntnode *ip;
- struct ntvattr **lvapp, **vapp;
- u_int32_t type;
- const char *name;
- size_t namelen;
- cn_t vcn;
-{
- int error;
- struct ntvattr *vap;
-
- if((ip->i_flag & IN_LOADED) == 0) {
- dprintf(("ntfs_findvattr: node not loaded, ino: %d\n",
- ip->i_number));
- error = ntfs_loadntnode(ntmp,ip);
- if (error) {
- printf("ntfs_findvattr: FAILED TO LOAD INO: %d\n",
- ip->i_number);
- return (error);
- }
- }
-
- *lvapp = NULL;
- *vapp = NULL;
- for (vap = ip->i_valist.lh_first; vap; vap = vap->va_list.le_next) {
- ddprintf(("ntfs_findvattr: type: 0x%x, vcn: %d - %d\n", \
- vap->va_type, (u_int32_t) vap->va_vcnstart, \
- (u_int32_t) vap->va_vcnend));
- if ((vap->va_type == type) &&
- (vap->va_vcnstart <= vcn) && (vap->va_vcnend >= vcn) &&
- (vap->va_namelen == namelen) &&
- (strncmp(name, vap->va_name, namelen) == 0)) {
- *vapp = vap;
- ntfs_ntref(vap->va_ip);
- return (0);
- }
- if (vap->va_type == NTFS_A_ATTRLIST)
- *lvapp = vap;
- }
-
- return (-1);
-}
-
-/*
- * Search attribute specifed in ntnode (load ntnode if nessecary).
- * If not found but ATTR_A_ATTRLIST present, read it in and search throught.
- * VOP_VGET node needed, and lookup througth it's ntnode (load if nessesary).
- *
- * ntnode should be locked
- */
-int
-ntfs_ntvattrget(
- struct ntfsmount * ntmp,
- struct ntnode * ip,
- u_int32_t type,
- const char *name,
- cn_t vcn,
- struct ntvattr ** vapp)
-{
- struct ntvattr *lvap = NULL;
- struct attr_attrlist *aalp;
- struct attr_attrlist *nextaalp;
- struct vnode *newvp;
- struct ntnode *newip;
- caddr_t alpool;
- size_t namelen, len;
- int error;
-
- *vapp = NULL;
-
- if (name) {
- dprintf(("ntfs_ntvattrget: " \
- "ino: %d, type: 0x%x, name: %s, vcn: %d\n", \
- ip->i_number, type, name, (u_int32_t) vcn));
- namelen = strlen(name);
- } else {
- dprintf(("ntfs_ntvattrget: " \
- "ino: %d, type: 0x%x, vcn: %d\n", \
- ip->i_number, type, (u_int32_t) vcn));
- name = "";
- namelen = 0;
- }
-
- error = ntfs_findvattr(ntmp, ip, &lvap, vapp, type, name, namelen, vcn);
- if (error >= 0)
- return (error);
-
- if (!lvap) {
- dprintf(("ntfs_ntvattrget: UNEXISTED ATTRIBUTE: " \
- "ino: %d, type: 0x%x, name: %s, vcn: %d\n", \
- ip->i_number, type, name, (u_int32_t) vcn));
- return (ENOENT);
- }
- /* Scan $ATTRIBUTE_LIST for requested attribute */
- len = lvap->va_datalen;
- MALLOC(alpool, caddr_t, len, M_TEMP, M_WAITOK);
- error = ntfs_readntvattr_plain(ntmp, ip, lvap, 0, len, alpool, &len,
- NULL);
- if (error)
- goto out;
-
- aalp = (struct attr_attrlist *) alpool;
- nextaalp = NULL;
-
- for(; len > 0; aalp = nextaalp) {
- dprintf(("ntfs_ntvattrget: " \
- "attrlist: ino: %d, attr: 0x%x, vcn: %d\n", \
- aalp->al_inumber, aalp->al_type, \
- (u_int32_t) aalp->al_vcnstart));
-
- if (len > aalp->reclen) {
- nextaalp = NTFS_NEXTREC(aalp, struct attr_attrlist *);
- } else {
- nextaalp = NULL;
- }
- len -= aalp->reclen;
-
- if (!NTFS_AALPCMP(aalp, type, name, namelen) ||
- (nextaalp && (nextaalp->al_vcnstart <= vcn) &&
- NTFS_AALPCMP(nextaalp, type, name, namelen)))
- continue;
-
- dprintf(("ntfs_ntvattrget: attribute in ino: %d\n",
- aalp->al_inumber));
-
- /* this is not a main record, so we can't use just plain
- vget() */
- error = ntfs_vgetex(ntmp->ntm_mountp, aalp->al_inumber,
- NTFS_A_DATA, NULL, LK_EXCLUSIVE,
- VG_EXT, curproc, &newvp);
- if (error) {
- printf("ntfs_ntvattrget: CAN'T VGET INO: %d\n",
- aalp->al_inumber);
- goto out;
- }
- newip = VTONT(newvp);
- /* XXX have to lock ntnode */
- error = ntfs_findvattr(ntmp, newip, &lvap, vapp,
- type, name, namelen, vcn);
- vput(newvp);
- if (error == 0)
- goto out;
- printf("ntfs_ntvattrget: ATTRLIST ERROR.\n");
- break;
- }
- error = ENOENT;
-
- dprintf(("ntfs_ntvattrget: UNEXISTED ATTRIBUTE: " \
- "ino: %d, type: 0x%x, name: %.*s, vcn: %d\n", \
- ip->i_number, type, (int) namelen, name, (u_int32_t) vcn));
-out:
- FREE(alpool, M_TEMP);
- return (error);
-}
-
-/*
- * Read ntnode from disk, make ntvattr list.
- *
- * ntnode should be locked
- */
-int
-ntfs_loadntnode(
- struct ntfsmount * ntmp,
- struct ntnode * ip)
-{
- struct filerec *mfrp;
- daddr_t bn;
- int error,off;
- struct attr *ap;
- struct ntvattr *nvap;
-
- dprintf(("ntfs_loadntnode: loading ino: %d\n",ip->i_number));
-
- MALLOC(mfrp, struct filerec *, ntfs_bntob(ntmp->ntm_bpmftrec),
- M_TEMP, M_WAITOK);
-
- if (ip->i_number < NTFS_SYSNODESNUM) {
- struct buf *bp;
-
- dprintf(("ntfs_loadntnode: read system node\n"));
-
- bn = ntfs_cntobn(ntmp->ntm_mftcn) +
- ntmp->ntm_bpmftrec * ip->i_number;
-
- error = bread(ntmp->ntm_devvp,
- bn, ntfs_bntob(ntmp->ntm_bpmftrec),
- NOCRED, &bp);
- if (error) {
- printf("ntfs_loadntnode: BREAD FAILED\n");
- brelse(bp);
- goto out;
- }
- memcpy(mfrp, bp->b_data, ntfs_bntob(ntmp->ntm_bpmftrec));
- bqrelse(bp);
- } else {
- struct vnode *vp;
-
- vp = ntmp->ntm_sysvn[NTFS_MFTINO];
- error = ntfs_readattr(ntmp, VTONT(vp), NTFS_A_DATA, NULL,
- ip->i_number * ntfs_bntob(ntmp->ntm_bpmftrec),
- ntfs_bntob(ntmp->ntm_bpmftrec), mfrp, NULL);
- if (error) {
- printf("ntfs_loadntnode: ntfs_readattr failed\n");
- goto out;
- }
- }
-
- /* Check if magic and fixups are correct */
- error = ntfs_procfixups(ntmp, NTFS_FILEMAGIC, (caddr_t)mfrp,
- ntfs_bntob(ntmp->ntm_bpmftrec));
- if (error) {
- printf("ntfs_loadntnode: BAD MFT RECORD %d\n",
- (u_int32_t) ip->i_number);
- goto out;
- }
-
- dprintf(("ntfs_loadntnode: load attrs for ino: %d\n",ip->i_number));
- off = mfrp->fr_attroff;
- ap = (struct attr *) ((caddr_t)mfrp + off);
-
- LIST_INIT(&ip->i_valist);
-
- while (ap->a_hdr.a_type != -1) {
- error = ntfs_attrtontvattr(ntmp, &nvap, ap);
- if (error)
- break;
- nvap->va_ip = ip;
-
- LIST_INSERT_HEAD(&ip->i_valist, nvap, va_list);
-
- off += ap->a_hdr.reclen;
- ap = (struct attr *) ((caddr_t)mfrp + off);
- }
- if (error) {
- printf("ntfs_loadntnode: failed to load attr ino: %d\n",
- ip->i_number);
- goto out;
- }
-
- ip->i_mainrec = mfrp->fr_mainrec;
- ip->i_nlink = mfrp->fr_nlink;
- ip->i_frflag = mfrp->fr_flags;
-
- ip->i_flag |= IN_LOADED;
-
-out:
- FREE(mfrp, M_TEMP);
- return (error);
-}
-
-/*
- * Routine locks ntnode and increase usecount, just opposite of
- * ntfs_ntput().
- */
-int
-ntfs_ntget(ip)
- struct ntnode *ip;
-{
- dprintf(("ntfs_ntget: get ntnode %d: %p, usecount: %d\n",
- ip->i_number, ip, ip->i_usecount));
-
- simple_lock(&ip->i_interlock);
- ip->i_usecount++;
- LOCKMGR(&ip->i_lock, LK_EXCLUSIVE | LK_INTERLOCK, &ip->i_interlock);
-
- return 0;
-}
-
-/*
- * Routine search ntnode in hash, if found: lock, inc usecount and return.
- * If not in hash allocate structure for ntnode, prefill it, lock,
- * inc count and return.
- *
- * ntnode returned locked
- */
-int
-ntfs_ntlookup(
- struct ntfsmount * ntmp,
- ino_t ino,
- struct ntnode ** ipp)
-{
- struct ntnode *ip;
-
- dprintf(("ntfs_ntlookup: looking for ntnode %d\n", ino));
-
- do {
- if ((ip = ntfs_nthashlookup(ntmp->ntm_dev, ino)) != NULL) {
- ntfs_ntget(ip);
- dprintf(("ntfs_ntlookup: ntnode %d: %p, usecount: %d\n",
- ino, ip, ip->i_usecount));
- *ipp = ip;
- return (0);
- }
- } while (LOCKMGR(&ntfs_hashlock, LK_EXCLUSIVE | LK_SLEEPFAIL, NULL));
-
- MALLOC(ip, struct ntnode *, sizeof(struct ntnode),
- M_NTFSNTNODE, M_WAITOK);
- ddprintf(("ntfs_ntlookup: allocating ntnode: %d: %p\n", ino, ip));
- bzero((caddr_t) ip, sizeof(struct ntnode));
-
- /* Generic initialization */
- ip->i_devvp = ntmp->ntm_devvp;
- ip->i_dev = ntmp->ntm_dev;
- ip->i_number = ino;
- ip->i_mp = ntmp;
-
- LIST_INIT(&ip->i_fnlist);
-
- /* init lock and lock the newborn ntnode */
- lockinit(&ip->i_lock, PINOD, "ntnode", 0, LK_EXCLUSIVE);
- simple_lock_init(&ip->i_interlock);
- ntfs_ntget(ip);
-
- ntfs_nthashins(ip);
-
- LOCKMGR(&ntfs_hashlock, LK_RELEASE, NULL);
-
- *ipp = ip;
-
- dprintf(("ntfs_ntlookup: ntnode %d: %p, usecount: %d\n",
- ino, ip, ip->i_usecount));
-
- return (0);
-}
-
-/*
- * Decrement usecount of ntnode and unlock it, if usecount reach zero,
- * deallocate ntnode.
- *
- * ntnode should be locked on entry, and unlocked on return.
- */
-void
-ntfs_ntput(ip)
- struct ntnode *ip;
-{
- struct ntvattr *vap;
-
- dprintf(("ntfs_ntput: rele ntnode %d: %p, usecount: %d\n",
- ip->i_number, ip, ip->i_usecount));
-
- simple_lock(&ip->i_interlock);
- ip->i_usecount--;
-
-#ifdef DIAGNOSTIC
- if (ip->i_usecount < 0) {
- panic("ntfs_ntput: ino: %d usecount: %d \n",
- ip->i_number,ip->i_usecount);
- }
-#endif
-
- if (ip->i_usecount == 0) {
- dprintf(("ntfs_ntput: deallocating ntnode: %d\n",
- ip->i_number));
-
- if (ip->i_fnlist.lh_first)
- panic("ntfs_ntput: ntnode has fnodes\n");
-
- ntfs_nthashrem(ip);
-
- while (ip->i_valist.lh_first != NULL) {
- vap = ip->i_valist.lh_first;
- LIST_REMOVE(vap,va_list);
- ntfs_freentvattr(vap);
- }
- FREE(ip, M_NTFSNTNODE);
- } else {
- LOCKMGR(&ip->i_lock, LK_RELEASE|LK_INTERLOCK, &ip->i_interlock);
- }
-}
-
-/*
- * increment usecount of ntnode
- */
-void
-ntfs_ntref(ip)
- struct ntnode *ip;
-{
- simple_lock(&ip->i_interlock);
- ip->i_usecount++;
- simple_unlock(&ip->i_interlock);
-
- dprintf(("ntfs_ntref: ino %d, usecount: %d\n",
- ip->i_number, ip->i_usecount));
-
-}
-
-/*
- * Decrement usecount of ntnode.
- */
-void
-ntfs_ntrele(ip)
- struct ntnode *ip;
-{
- dprintf(("ntfs_ntrele: rele ntnode %d: %p, usecount: %d\n",
- ip->i_number, ip, ip->i_usecount));
-
- simple_lock(&ip->i_interlock);
- ip->i_usecount--;
-
- if (ip->i_usecount < 0)
- panic("ntfs_ntrele: ino: %d usecount: %d \n",
- ip->i_number,ip->i_usecount);
- simple_unlock(&ip->i_interlock);
-}
-
-/*
- * Deallocate all memory allocated for ntvattr
- */
-void
-ntfs_freentvattr(vap)
- struct ntvattr * vap;
-{
- if (vap->va_flag & NTFS_AF_INRUN) {
- if (vap->va_vruncn)
- FREE(vap->va_vruncn, M_NTFSRUN);
- if (vap->va_vruncl)
- FREE(vap->va_vruncl, M_NTFSRUN);
- } else {
- if (vap->va_datap)
- FREE(vap->va_datap, M_NTFSRDATA);
- }
- FREE(vap, M_NTFSNTVATTR);
-}
-
-/*
- * Convert disk image of attribute into ntvattr structure,
- * runs are expanded also.
- */
-int
-ntfs_attrtontvattr(
- struct ntfsmount * ntmp,
- struct ntvattr ** rvapp,
- struct attr * rap)
-{
- int error, i;
- struct ntvattr *vap;
-
- error = 0;
- *rvapp = NULL;
-
- MALLOC(vap, struct ntvattr *, sizeof(struct ntvattr),
- M_NTFSNTVATTR, M_WAITOK);
- bzero(vap, sizeof(struct ntvattr));
- vap->va_ip = NULL;
- vap->va_flag = rap->a_hdr.a_flag;
- vap->va_type = rap->a_hdr.a_type;
- vap->va_compression = rap->a_hdr.a_compression;
- vap->va_index = rap->a_hdr.a_index;
-
- ddprintf(("type: 0x%x, index: %d", vap->va_type, vap->va_index));
-
- vap->va_namelen = rap->a_hdr.a_namelen;
- if (rap->a_hdr.a_namelen) {
- wchar *unp = (wchar *) ((caddr_t) rap + rap->a_hdr.a_nameoff);
- ddprintf((", name:["));
- for (i = 0; i < vap->va_namelen; i++) {
- vap->va_name[i] = unp[i];
- ddprintf(("%c", vap->va_name[i]));
- }
- ddprintf(("]"));
- }
- if (vap->va_flag & NTFS_AF_INRUN) {
- ddprintf((", nonres."));
- vap->va_datalen = rap->a_nr.a_datalen;
- vap->va_allocated = rap->a_nr.a_allocated;
- vap->va_vcnstart = rap->a_nr.a_vcnstart;
- vap->va_vcnend = rap->a_nr.a_vcnend;
- vap->va_compressalg = rap->a_nr.a_compressalg;
- error = ntfs_runtovrun(&(vap->va_vruncn), &(vap->va_vruncl),
- &(vap->va_vruncnt),
- (caddr_t) rap + rap->a_nr.a_dataoff);
- } else {
- vap->va_compressalg = 0;
- ddprintf((", res."));
- vap->va_datalen = rap->a_r.a_datalen;
- vap->va_allocated = rap->a_r.a_datalen;
- vap->va_vcnstart = 0;
- vap->va_vcnend = ntfs_btocn(vap->va_allocated);
- MALLOC(vap->va_datap, caddr_t, vap->va_datalen,
- M_NTFSRDATA, M_WAITOK);
- memcpy(vap->va_datap, (caddr_t) rap + rap->a_r.a_dataoff,
- rap->a_r.a_datalen);
- }
- ddprintf((", len: %d", vap->va_datalen));
-
- if (error)
- FREE(vap, M_NTFSNTVATTR);
- else
- *rvapp = vap;
-
- ddprintf(("\n"));
-
- return (error);
-}
-
-/*
- * Expand run into more utilizable and more memory eating format.
- */
-int
-ntfs_runtovrun(
- cn_t ** rcnp,
- cn_t ** rclp,
- u_long * rcntp,
- u_int8_t * run)
-{
- u_int32_t off;
- u_int32_t sz, i;
- cn_t *cn;
- cn_t *cl;
- u_long cnt;
- cn_t prev;
- cn_t tmp;
-
- off = 0;
- cnt = 0;
- i = 0;
- while (run[off]) {
- off += (run[off] & 0xF) + ((run[off] >> 4) & 0xF) + 1;
- cnt++;
- }
- MALLOC(cn, cn_t *, cnt * sizeof(cn_t), M_NTFSRUN, M_WAITOK);
- MALLOC(cl, cn_t *, cnt * sizeof(cn_t), M_NTFSRUN, M_WAITOK);
-
- off = 0;
- cnt = 0;
- prev = 0;
- while (run[off]) {
-
- sz = run[off++];
- cl[cnt] = 0;
-
- for (i = 0; i < (sz & 0xF); i++)
- cl[cnt] += (u_int32_t) run[off++] << (i << 3);
-
- sz >>= 4;
- if (run[off + sz - 1] & 0x80) {
- tmp = ((u_int64_t) - 1) << (sz << 3);
- for (i = 0; i < sz; i++)
- tmp |= (u_int64_t) run[off++] << (i << 3);
- } else {
- tmp = 0;
- for (i = 0; i < sz; i++)
- tmp |= (u_int64_t) run[off++] << (i << 3);
- }
- if (tmp)
- prev = cn[cnt] = prev + tmp;
- else
- cn[cnt] = tmp;
-
- cnt++;
- }
- *rcnp = cn;
- *rclp = cl;
- *rcntp = cnt;
- return (0);
-}
-
-/*
- * Compare unicode and ascii string case insens.
- */
-static int
-ntfs_uastricmp(ustr, ustrlen, astr, astrlen)
- const wchar *ustr;
- size_t ustrlen;
- const char *astr;
- size_t astrlen;
-{
- size_t i;
- int res;
-
- for (i = 0; i < ustrlen && i < astrlen; i++) {
- res = ((int) NTFS_TOUPPER(NTFS_U28(ustr[i]))) -
- ((int)NTFS_TOUPPER(astr[i]));
- if (res)
- return res;
- }
- return (ustrlen - astrlen);
-}
-
-/*
- * Compare unicode and ascii string case sens.
- */
-static int
-ntfs_uastrcmp(ustr, ustrlen, astr, astrlen)
- const wchar *ustr;
- size_t ustrlen;
- const char *astr;
- size_t astrlen;
-{
- size_t i;
- int res;
-
- for (i = 0; (i < ustrlen) && (i < astrlen); i++) {
- res = (int) (((char)NTFS_U28(ustr[i])) - astr[i]);
- if (res)
- return res;
- }
- return (ustrlen - astrlen);
-}
-
-/*
- * Search fnode in ntnode, if not found allocate and preinitialize.
- *
- * ntnode should be locked on entry.
- */
-int
-ntfs_fget(
- struct ntfsmount *ntmp,
- struct ntnode *ip,
- int attrtype,
- char *attrname,
- struct fnode **fpp)
-{
- struct fnode *fp;
-
- dprintf(("ntfs_fget: ino: %d, attrtype: 0x%x, attrname: %s\n",
- ip->i_number,attrtype, attrname?attrname:""));
- *fpp = NULL;
- for (fp = ip->i_fnlist.lh_first; fp != NULL; fp = fp->f_fnlist.le_next){
- dprintf(("ntfs_fget: fnode: attrtype: %d, attrname: %s\n",
- fp->f_attrtype, fp->f_attrname?fp->f_attrname:""));
-
- if ((attrtype == fp->f_attrtype) &&
- ((!attrname && !fp->f_attrname) ||
- (attrname && fp->f_attrname &&
- !strcmp(attrname,fp->f_attrname)))){
- dprintf(("ntfs_fget: found existed: %p\n",fp));
- *fpp = fp;
- }
- }
-
- if (*fpp)
- return (0);
-
- MALLOC(fp, struct fnode *, sizeof(struct fnode), M_NTFSFNODE, M_WAITOK);
- bzero(fp, sizeof(struct fnode));
- dprintf(("ntfs_fget: allocating fnode: %p\n",fp));
-
- fp->f_ip = ip;
- fp->f_attrname = attrname;
- if (fp->f_attrname) fp->f_flag |= FN_AATTRNAME;
- fp->f_attrtype = attrtype;
-
- ntfs_ntref(ip);
-
- LIST_INSERT_HEAD(&ip->i_fnlist, fp, f_fnlist);
-
- *fpp = fp;
-
- return (0);
-}
-
-/*
- * Deallocate fnode, remove it from ntnode's fnode list.
- *
- * ntnode should be locked.
- */
-void
-ntfs_frele(
- struct fnode *fp)
-{
- struct ntnode *ip = FTONT(fp);
-
- dprintf(("ntfs_frele: fnode: %p for %d: %p\n", fp, ip->i_number, ip));
-
- dprintf(("ntfs_frele: deallocating fnode\n"));
- LIST_REMOVE(fp,f_fnlist);
- if (fp->f_flag & FN_AATTRNAME)
- FREE(fp->f_attrname, M_TEMP);
- if (fp->f_dirblbuf)
- FREE(fp->f_dirblbuf, M_NTFSDIR);
- FREE(fp, M_NTFSFNODE);
- ntfs_ntrele(ip);
-}
-
-/*
- * Lookup attribute name in format: [[:$ATTR_TYPE]:$ATTR_NAME],
- * $ATTR_TYPE is searched in attrdefs read from $AttrDefs.
- * If $ATTR_TYPE nott specifed, ATTR_A_DATA assumed.
- */
-static int
-ntfs_ntlookupattr(
- struct ntfsmount * ntmp,
- const char * name,
- int namelen,
- int *attrtype,
- char **attrname)
-{
- const char *sys;
- size_t syslen, i;
- struct ntvattrdef *adp;
-
- if (namelen == 0)
- return (0);
-
- if (name[0] == '$') {
- sys = name;
- for (syslen = 0; syslen < namelen; syslen++) {
- if(sys[syslen] == ':') {
- name++;
- namelen--;
- break;
- }
- }
- name += syslen;
- namelen -= syslen;
-
- adp = ntmp->ntm_ad;
- for (i = 0; i < ntmp->ntm_adnum; i++, adp++){
- if (syslen != adp->ad_namelen ||
- strncmp(sys, adp->ad_name, syslen) != 0)
- continue;
-
- *attrtype = adp->ad_type;
- goto out;
- }
- return (ENOENT);
- }
-
- out:
- if (namelen) {
- MALLOC((*attrname), char *, namelen, M_TEMP, M_WAITOK);
- memcpy((*attrname), name, namelen);
- (*attrname)[namelen] = '\0';
- *attrtype = NTFS_A_DATA;
- }
-
- return (0);
-}
-
-/*
- * Lookup specifed node for filename, matching cnp,
- * return fnode filled.
- */
-int
-ntfs_ntlookupfile(
- struct ntfsmount * ntmp,
- struct vnode * vp,
- struct componentname * cnp,
- struct vnode ** vpp)
-{
- struct fnode *fp = VTOF(vp);
- struct ntnode *ip = FTONT(fp);
- struct ntvattr *vap; /* Root attribute */
- cn_t cn; /* VCN in current attribute */
- caddr_t rdbuf; /* Buffer to read directory's blocks */
- u_int32_t blsize;
- u_int32_t rdsize; /* Length of data to read from current block */
- struct attr_indexentry *iep;
- int error, res, anamelen, fnamelen;
- const char *fname,*aname;
- u_int32_t aoff;
- int attrtype = NTFS_A_DATA;
- char *attrname = NULL;
- struct fnode *nfp;
- struct vnode *nvp;
- enum vtype f_type;
-
- error = ntfs_ntget(ip);
- if (error)
- return (error);
-
- error = ntfs_ntvattrget(ntmp, ip, NTFS_A_INDXROOT, "$I30", 0, &vap);
- if (error || (vap->va_flag & NTFS_AF_INRUN))
- return (ENOTDIR);
-
- blsize = vap->va_a_iroot->ir_size;
- rdsize = vap->va_datalen;
-
- /*
- * Divide file name into: foofilefoofilefoofile[:attrspec]
- * Store like this: fname:fnamelen [aname:anamelen]
- */
- fname = cnp->cn_nameptr;
- aname = NULL;
- anamelen = 0;
- for (fnamelen = 0; fnamelen < cnp->cn_namelen; fnamelen++)
- if(fname[fnamelen] == ':') {
- aname = fname + fnamelen + 1;
- anamelen = cnp->cn_namelen - fnamelen - 1;
- dprintf(("ntfs_ntlookupfile: %s (%d), attr: %s (%d)\n",
- fname, fnamelen, aname, anamelen));
- break;
- }
-
- dprintf(("ntfs_ntlookupfile: blksz: %d, rdsz: %d\n", blsize, rdsize));
-
- MALLOC(rdbuf, caddr_t, blsize, M_TEMP, M_WAITOK);
-
- error = ntfs_readattr(ntmp, ip, NTFS_A_INDXROOT, "$I30",
- 0, rdsize, rdbuf, NULL);
- if (error)
- goto fail;
-
- aoff = sizeof(struct attr_indexroot);
-
- do {
- iep = (struct attr_indexentry *) (rdbuf + aoff);
-
- for (; !(iep->ie_flag & NTFS_IEFLAG_LAST) && (rdsize > aoff);
- aoff += iep->reclen,
- iep = (struct attr_indexentry *) (rdbuf + aoff))
- {
- ddprintf(("scan: %d, %d\n",
- (u_int32_t) iep->ie_number,
- (u_int32_t) iep->ie_fnametype));
-
- /* check the name - the case-insensitible check
- * has to come first, to break from this for loop
- * if needed, so we can dive correctly */
- res = ntfs_uastricmp(iep->ie_fname, iep->ie_fnamelen,
- fname, fnamelen);
- if (res > 0) break;
- if (res < 0) continue;
-
- if (iep->ie_fnametype == 0 ||
- !(ntmp->ntm_flag & NTFS_MFLAG_CASEINS))
- {
- res = ntfs_uastrcmp(iep->ie_fname,
- iep->ie_fnamelen, fname, fnamelen);
- if (res != 0) continue;
- }
-
- if (aname) {
- error = ntfs_ntlookupattr(ntmp,
- aname, anamelen,
- &attrtype, &attrname);
- if (error)
- goto fail;
- }
-
- /* Check if we've found ourself */
- if ((iep->ie_number == ip->i_number) &&
- (attrtype == fp->f_attrtype) &&
- ((!attrname && !fp->f_attrname) ||
- (attrname && fp->f_attrname &&
- !strcmp(attrname, fp->f_attrname))))
- {
- VREF(vp);
- *vpp = vp;
- error = 0;
- goto fail;
- }
-
- /* free the buffer returned by ntfs_ntlookupattr() */
- if (attrname) {
- FREE(attrname, M_TEMP);
- attrname = NULL;
- }
-
- /* vget node, but don't load it */
- error = ntfs_vgetex(ntmp->ntm_mountp,
- iep->ie_number, attrtype, attrname,
- LK_EXCLUSIVE, VG_DONTLOADIN | VG_DONTVALIDFN,
- curproc, &nvp);
- if (error)
- goto fail;
-
- nfp = VTOF(nvp);
-
- if (nfp->f_flag & FN_VALID) {
- *vpp = nvp;
- goto fail;
- }
-
- nfp->f_fflag = iep->ie_fflag;
- nfp->f_pnumber = iep->ie_fpnumber;
- nfp->f_times = iep->ie_ftimes;
-
- if((nfp->f_fflag & NTFS_FFLAG_DIR) &&
- (nfp->f_attrtype == NTFS_A_DATA) &&
- (nfp->f_attrname == NULL))
- f_type = VDIR;
- else
- f_type = VREG;
-
- nvp->v_type = f_type;
-
- if ((nfp->f_attrtype == NTFS_A_DATA) &&
- (nfp->f_attrname == NULL))
- {
- /* Opening default attribute */
- nfp->f_size = iep->ie_fsize;
- nfp->f_allocated = iep->ie_fallocated;
- nfp->f_flag |= FN_PRELOADED;
- } else {
- error = ntfs_filesize(ntmp, nfp,
- &nfp->f_size, &nfp->f_allocated);
- if (error) {
- vput(nvp);
- goto fail;
- }
- }
-
- nfp->f_flag &= ~FN_VALID;
- *vpp = nvp;
- goto fail;
- }
-
- /* Dive if possible */
- if (iep->ie_flag & NTFS_IEFLAG_SUBNODE) {
- dprintf(("ntfs_ntlookupfile: diving\n"));
-
- cn = *(cn_t *) (rdbuf + aoff +
- iep->reclen - sizeof(cn_t));
- rdsize = blsize;
-
- error = ntfs_readattr(ntmp, ip, NTFS_A_INDX, "$I30",
- ntfs_cntob(cn), rdsize, rdbuf, NULL);
- if (error)
- goto fail;
-
- error = ntfs_procfixups(ntmp, NTFS_INDXMAGIC,
- rdbuf, rdsize);
- if (error)
- goto fail;
-
- aoff = (((struct attr_indexalloc *) rdbuf)->ia_hdrsize +
- 0x18);
- } else {
- dprintf(("ntfs_ntlookupfile: nowhere to dive :-(\n"));
- error = ENOENT;
- break;
- }
- } while (1);
-
- dprintf(("finish\n"));
-
-fail:
- if (attrname) FREE(attrname, M_TEMP);
- ntfs_ntvattrrele(vap);
- ntfs_ntput(ip);
- FREE(rdbuf, M_TEMP);
- return (error);
-}
-
-/*
- * Check if name type is permitted to show.
- */
-int
-ntfs_isnamepermitted(
- struct ntfsmount * ntmp,
- struct attr_indexentry * iep)
-{
- if (ntmp->ntm_flag & NTFS_MFLAG_ALLNAMES)
- return 1;
-
- switch (iep->ie_fnametype) {
- case 2:
- ddprintf(("ntfs_isnamepermitted: skiped DOS name\n"));
- return 0;
- case 0: case 1: case 3:
- return 1;
- default:
- printf("ntfs_isnamepermitted: " \
- "WARNING! Unknown file name type: %d\n",
- iep->ie_fnametype);
- break;
- }
- return 0;
-}
-
-/*
- * Read ntfs dir like stream of attr_indexentry, not like btree of them.
- * This is done by scaning $BITMAP:$I30 for busy clusters and reading them.
- * Ofcouse $INDEX_ROOT:$I30 is read before. Last read values are stored in
- * fnode, so we can skip toward record number num almost immediatly.
- * Anyway this is rather slow routine. The problem is that we don't know
- * how many records are there in $INDEX_ALLOCATION:$I30 block.
- */
-int
-ntfs_ntreaddir(
- struct ntfsmount * ntmp,
- struct fnode * fp,
- u_int32_t num,
- struct attr_indexentry ** riepp)
-{
- struct ntnode *ip = FTONT(fp);
- struct ntvattr *vap = NULL; /* IndexRoot attribute */
- struct ntvattr *bmvap = NULL; /* BitMap attribute */
- struct ntvattr *iavap = NULL; /* IndexAllocation attribute */
- caddr_t rdbuf; /* Buffer to read directory's blocks */
- u_char *bmp = NULL; /* Bitmap */
- u_int32_t blsize; /* Index allocation size (2048) */
- u_int32_t rdsize; /* Length of data to read */
- u_int32_t attrnum; /* Current attribute type */
- u_int32_t cpbl = 1; /* Clusters per directory block */
- u_int32_t blnum;
- struct attr_indexentry *iep;
- int error = ENOENT;
- u_int32_t aoff, cnum;
-
- dprintf(("ntfs_ntreaddir: read ino: %d, num: %d\n", ip->i_number, num));
- error = ntfs_ntget(ip);
- if (error)
- return (error);
-
- error = ntfs_ntvattrget(ntmp, ip, NTFS_A_INDXROOT, "$I30", 0, &vap);
- if (error)
- return (ENOTDIR);
-
- if (fp->f_dirblbuf == NULL) {
- fp->f_dirblsz = vap->va_a_iroot->ir_size;
- MALLOC(fp->f_dirblbuf, caddr_t,
- max(vap->va_datalen,fp->f_dirblsz), M_NTFSDIR, M_WAITOK);
- }
-
- blsize = fp->f_dirblsz;
- rdbuf = fp->f_dirblbuf;
-
- dprintf(("ntfs_ntreaddir: rdbuf: 0x%p, blsize: %d\n", rdbuf, blsize));
-
- if (vap->va_a_iroot->ir_flag & NTFS_IRFLAG_INDXALLOC) {
- error = ntfs_ntvattrget(ntmp, ip, NTFS_A_INDXBITMAP, "$I30",
- 0, &bmvap);
- if (error) {
- error = ENOTDIR;
- goto fail;
- }
- MALLOC(bmp, u_char *, bmvap->va_datalen, M_TEMP, M_WAITOK);
- error = ntfs_readattr(ntmp, ip, NTFS_A_INDXBITMAP, "$I30", 0,
- bmvap->va_datalen, bmp, NULL);
- if (error)
- goto fail;
-
- error = ntfs_ntvattrget(ntmp, ip, NTFS_A_INDX, "$I30",
- 0, &iavap);
- if (error) {
- error = ENOTDIR;
- goto fail;
- }
- cpbl = ntfs_btocn(blsize + ntfs_cntob(1) - 1);
- dprintf(("ntfs_ntreaddir: indexalloc: %d, cpbl: %d\n",
- iavap->va_datalen, cpbl));
- } else {
- dprintf(("ntfs_ntreadidir: w/o BitMap and IndexAllocation\n"));
- iavap = bmvap = NULL;
- bmp = NULL;
- }
-
- /* Try use previous values */
- if ((fp->f_lastdnum < num) && (fp->f_lastdnum != 0)) {
- attrnum = fp->f_lastdattr;
- aoff = fp->f_lastdoff;
- blnum = fp->f_lastdblnum;
- cnum = fp->f_lastdnum;
- } else {
- attrnum = NTFS_A_INDXROOT;
- aoff = sizeof(struct attr_indexroot);
- blnum = 0;
- cnum = 0;
- }
-
- do {
- dprintf(("ntfs_ntreaddir: scan: 0x%x, %d, %d, %d, %d\n",
- attrnum, (u_int32_t) blnum, cnum, num, aoff));
- rdsize = (attrnum == NTFS_A_INDXROOT) ? vap->va_datalen : blsize;
- error = ntfs_readattr(ntmp, ip, attrnum, "$I30",
- ntfs_cntob(blnum * cpbl), rdsize, rdbuf, NULL);
- if (error)
- goto fail;
-
- if (attrnum == NTFS_A_INDX) {
- error = ntfs_procfixups(ntmp, NTFS_INDXMAGIC,
- rdbuf, rdsize);
- if (error)
- goto fail;
- }
- if (aoff == 0)
- aoff = (attrnum == NTFS_A_INDX) ?
- (0x18 + ((struct attr_indexalloc *) rdbuf)->ia_hdrsize) :
- sizeof(struct attr_indexroot);
-
- iep = (struct attr_indexentry *) (rdbuf + aoff);
- for (; !(iep->ie_flag & NTFS_IEFLAG_LAST) && (rdsize > aoff);
- aoff += iep->reclen,
- iep = (struct attr_indexentry *) (rdbuf + aoff))
- {
- if (!ntfs_isnamepermitted(ntmp, iep)) continue;
-
- if (cnum >= num) {
- fp->f_lastdnum = cnum;
- fp->f_lastdoff = aoff;
- fp->f_lastdblnum = blnum;
- fp->f_lastdattr = attrnum;
-
- *riepp = iep;
-
- error = 0;
- goto fail;
- }
- cnum++;
- }
-
- if (iavap) {
- if (attrnum == NTFS_A_INDXROOT)
- blnum = 0;
- else
- blnum++;
-
- while (ntfs_cntob(blnum * cpbl) < iavap->va_datalen) {
- if (bmp[blnum >> 3] & (1 << (blnum & 3)))
- break;
- blnum++;
- }
-
- attrnum = NTFS_A_INDX;
- aoff = 0;
- if (ntfs_cntob(blnum * cpbl) >= iavap->va_datalen)
- break;
- dprintf(("ntfs_ntreaddir: blnum: %d\n", (u_int32_t) blnum));
- }
- } while (iavap);
-
- *riepp = NULL;
- fp->f_lastdnum = 0;
-
-fail:
- if (vap)
- ntfs_ntvattrrele(vap);
- if (bmvap)
- ntfs_ntvattrrele(bmvap);
- if (iavap)
- ntfs_ntvattrrele(iavap);
- if (bmp)
- FREE(bmp, M_TEMP);
- ntfs_ntput(ip);
- return (error);
-}
-
-/*
- * Convert NTFS times that are in 100 ns units and begins from
- * 1601 Jan 1 into unix times.
- */
-struct timespec
-ntfs_nttimetounix(
- u_int64_t nt)
-{
- struct timespec t;
-
- /* WindowNT times are in 100 ns and from 1601 Jan 1 */
- t.tv_nsec = (nt % (1000 * 1000 * 10)) * 100;
- t.tv_sec = nt / (1000 * 1000 * 10) -
- 369LL * 365LL * 24LL * 60LL * 60LL -
- 89LL * 1LL * 24LL * 60LL * 60LL;
- return (t);
-}
-
-/*
- * Get file times from NTFS_A_NAME attribute.
- */
-int
-ntfs_times(
- struct ntfsmount * ntmp,
- struct ntnode * ip,
- ntfs_times_t * tm)
-{
- struct ntvattr *vap;
- int error;
-
- dprintf(("ntfs_times: ino: %d...\n", ip->i_number));
-
- error = ntfs_ntget(ip);
- if (error)
- return (error);
-
- error = ntfs_ntvattrget(ntmp, ip, NTFS_A_NAME, NULL, 0, &vap);
- if (error) {
- ntfs_ntput(ip);
- return (error);
- }
- *tm = vap->va_a_name->n_times;
- ntfs_ntvattrrele(vap);
- ntfs_ntput(ip);
-
- return (0);
-}
-
-/*
- * Get file sizes from corresponding attribute.
- *
- * ntnode under fnode should be locked.
- */
-int
-ntfs_filesize(
- struct ntfsmount * ntmp,
- struct fnode * fp,
- u_int64_t * size,
- u_int64_t * bytes)
-{
- struct ntvattr *vap;
- struct ntnode *ip = FTONT(fp);
- u_int64_t sz, bn;
- int error;
-
- dprintf(("ntfs_filesize: ino: %d\n", ip->i_number));
-
- error = ntfs_ntvattrget(ntmp, ip,
- fp->f_attrtype, fp->f_attrname, 0, &vap);
- if (error)
- return (error);
-
- bn = vap->va_allocated;
- sz = vap->va_datalen;
-
- dprintf(("ntfs_filesize: %d bytes (%d bytes allocated)\n",
- (u_int32_t) sz, (u_int32_t) bn));
-
- if (size)
- *size = sz;
- if (bytes)
- *bytes = bn;
-
- ntfs_ntvattrrele(vap);
-
- return (0);
-}
-
-/*
- * This is one of write routine.
- */
-int
-ntfs_writeattr_plain(
- struct ntfsmount * ntmp,
- struct ntnode * ip,
- u_int32_t attrnum,
- char *attrname,
- off_t roff,
- size_t rsize,
- void *rdata,
- size_t * initp,
- struct uio *uio)
-{
- size_t init;
- int error = 0;
- off_t off = roff, left = rsize, towrite;
- caddr_t data = rdata;
- struct ntvattr *vap;
- *initp = 0;
-
- while (left) {
- error = ntfs_ntvattrget(ntmp, ip, attrnum, attrname,
- ntfs_btocn(off), &vap);
- if (error)
- return (error);
- towrite = min(left, ntfs_cntob(vap->va_vcnend + 1) - off);
- ddprintf(("ntfs_writeattr_plain: o: %d, s: %d (%d - %d)\n",
- (u_int32_t) off, (u_int32_t) towrite,
- (u_int32_t) vap->va_vcnstart,
- (u_int32_t) vap->va_vcnend));
- error = ntfs_writentvattr_plain(ntmp, ip, vap,
- off - ntfs_cntob(vap->va_vcnstart),
- towrite, data, &init, uio);
- if (error) {
- printf("ntfs_writeattr_plain: " \
- "ntfs_writentvattr_plain failed: o: %d, s: %d\n",
- (u_int32_t) off, (u_int32_t) towrite);
- printf("ntfs_writeattr_plain: attrib: %d - %d\n",
- (u_int32_t) vap->va_vcnstart,
- (u_int32_t) vap->va_vcnend);
- ntfs_ntvattrrele(vap);
- break;
- }
- ntfs_ntvattrrele(vap);
- left -= towrite;
- off += towrite;
- data = data + towrite;
- *initp += init;
- }
-
- return (error);
-}
-
-/*
- * This is one of write routine.
- *
- * ntnode should be locked.
- */
-int
-ntfs_writentvattr_plain(
- struct ntfsmount * ntmp,
- struct ntnode * ip,
- struct ntvattr * vap,
- off_t roff,
- size_t rsize,
- void *rdata,
- size_t * initp,
- struct uio *uio)
-{
- int error = 0;
- int off;
- int cnt;
- cn_t ccn, ccl, cn, left, cl;
- caddr_t data = rdata;
- struct buf *bp;
- size_t tocopy;
-
- *initp = 0;
-
- if ((vap->va_flag & NTFS_AF_INRUN) == 0) {
- printf("ntfs_writevattr_plain: CAN'T WRITE RES. ATTRIBUTE\n");
- return ENOTTY;
- }
-
- ddprintf(("ntfs_writentvattr_plain: data in run: %d chains\n",
- vap->va_vruncnt));
-
- off = roff;
- left = rsize;
- ccl = 0;
- ccn = 0;
- cnt = 0;
- for (; left && (cnt < vap->va_vruncnt); cnt++) {
- ccn = vap->va_vruncn[cnt];
- ccl = vap->va_vruncl[cnt];
-
- ddprintf(("ntfs_writentvattr_plain: " \
- "left %d, cn: 0x%x, cl: %d, off: %d\n", \
- (u_int32_t) left, (u_int32_t) ccn, \
- (u_int32_t) ccl, (u_int32_t) off));
-
- if (ntfs_cntob(ccl) < off) {
- off -= ntfs_cntob(ccl);
- cnt++;
- continue;
- }
- if (!ccn && ip->i_number != NTFS_BOOTINO)
- continue; /* XXX */
-
- ccl -= ntfs_btocn(off);
- cn = ccn + ntfs_btocn(off);
- off = ntfs_btocnoff(off);
-
- while (left && ccl) {
-#if defined(__FreeBSD__)
- tocopy = min(left,
- min(ntfs_cntob(ccl) - off, MAXBSIZE - off));
-#else
- /* under NetBSD, bread() can read
- * maximum one block worth of data */
- tocopy = min(left, ntmp->ntm_bps - off);
-#endif
- cl = ntfs_btocl(tocopy + off);
- ddprintf(("ntfs_writentvattr_plain: write: " \
- "cn: 0x%x cl: %d, off: %d len: %d, left: %d\n",
- (u_int32_t) cn, (u_int32_t) cl,
- (u_int32_t) off, (u_int32_t) tocopy,
- (u_int32_t) left));
- if ((off == 0) && (tocopy == ntfs_cntob(cl)))
- {
- bp = getblk(ntmp->ntm_devvp, ntfs_cntobn(cn),
- ntfs_cntob(cl), 0, 0);
- clrbuf(bp);
- } else {
- error = bread(ntmp->ntm_devvp, ntfs_cntobn(cn),
- ntfs_cntob(cl), NOCRED, &bp);
- if (error) {
- brelse(bp);
- return (error);
- }
- }
- if (uio)
- uiomove(bp->b_data + off, tocopy, uio);
- else
- memcpy(bp->b_data + off, data, tocopy);
- bawrite(bp);
- data = data + tocopy;
- *initp += tocopy;
- off = 0;
- left -= tocopy;
- cn += cl;
- ccl -= cl;
- }
- }
-
- if (left) {
- printf("ntfs_writentvattr_plain: POSSIBLE RUN ERROR\n");
- error = EINVAL;
- }
-
- return (error);
-}
-
-/*
- * This is one of read routines.
- *
- * ntnode should be locked.
- */
-int
-ntfs_readntvattr_plain(
- struct ntfsmount * ntmp,
- struct ntnode * ip,
- struct ntvattr * vap,
- off_t roff,
- size_t rsize,
- void *rdata,
- size_t * initp,
- struct uio *uio)
-{
- int error = 0;
- int off;
-
- *initp = 0;
- if (vap->va_flag & NTFS_AF_INRUN) {
- int cnt;
- cn_t ccn, ccl, cn, left, cl;
- caddr_t data = rdata;
- struct buf *bp;
- size_t tocopy;
-
- ddprintf(("ntfs_readntvattr_plain: data in run: %d chains\n",
- vap->va_vruncnt));
-
- off = roff;
- left = rsize;
- ccl = 0;
- ccn = 0;
- cnt = 0;
- while (left && (cnt < vap->va_vruncnt)) {
- ccn = vap->va_vruncn[cnt];
- ccl = vap->va_vruncl[cnt];
-
- ddprintf(("ntfs_readntvattr_plain: " \
- "left %d, cn: 0x%x, cl: %d, off: %d\n", \
- (u_int32_t) left, (u_int32_t) ccn, \
- (u_int32_t) ccl, (u_int32_t) off));
-
- if (ntfs_cntob(ccl) < off) {
- off -= ntfs_cntob(ccl);
- cnt++;
- continue;
- }
- if (ccn || ip->i_number == NTFS_BOOTINO) {
- ccl -= ntfs_btocn(off);
- cn = ccn + ntfs_btocn(off);
- off = ntfs_btocnoff(off);
-
- while (left && ccl) {
-#if defined(__FreeBSD__)
- tocopy = min(left,
- min(ntfs_cntob(ccl) - off,
- MAXBSIZE - off));
-#else
- /* under NetBSD, bread() can read
- * maximum one block worth of data */
- tocopy = min(left,
- ntmp->ntm_bps - off);
-#endif
- cl = ntfs_btocl(tocopy + off);
- ddprintf(("ntfs_readntvattr_plain: " \
- "read: cn: 0x%x cl: %d, " \
- "off: %d len: %d, left: %d\n",
- (u_int32_t) cn,
- (u_int32_t) cl,
- (u_int32_t) off,
- (u_int32_t) tocopy,
- (u_int32_t) left));
- error = bread(ntmp->ntm_devvp,
- ntfs_cntobn(cn),
- ntfs_cntob(cl),
- NOCRED, &bp);
- if (error) {
- brelse(bp);
- return (error);
- }
- if (uio) {
- uiomove(bp->b_data + off,
- tocopy, uio);
- } else {
- memcpy(data, bp->b_data + off,
- tocopy);
- }
- brelse(bp);
- data = data + tocopy;
- *initp += tocopy;
- off = 0;
- left -= tocopy;
- cn += cl;
- ccl -= cl;
- }
- } else {
- tocopy = min(left, ntfs_cntob(ccl) - off);
- ddprintf(("ntfs_readntvattr_plain: "
- "hole: ccn: 0x%x ccl: %d, off: %d, " \
- " len: %d, left: %d\n",
- (u_int32_t) ccn, (u_int32_t) ccl,
- (u_int32_t) off, (u_int32_t) tocopy,
- (u_int32_t) left));
- left -= tocopy;
- off = 0;
- if (uio) {
- size_t remains = tocopy;
- for(; remains; remains++)
- uiomove("", 1, uio);
- } else
- bzero(data, tocopy);
- data = data + tocopy;
- }
- cnt++;
- }
- if (left) {
- printf("ntfs_readntvattr_plain: POSSIBLE RUN ERROR\n");
- error = E2BIG;
- }
- } else {
- ddprintf(("ntfs_readnvattr_plain: data is in mft record\n"));
- if (uio)
- uiomove(vap->va_datap + roff, rsize, uio);
- else
- memcpy(rdata, vap->va_datap + roff, rsize);
- *initp += rsize;
- }
-
- return (error);
-}
-
-/*
- * This is one of read routines.
- */
-int
-ntfs_readattr_plain(
- struct ntfsmount * ntmp,
- struct ntnode * ip,
- u_int32_t attrnum,
- char *attrname,
- off_t roff,
- size_t rsize,
- void *rdata,
- size_t * initp,
- struct uio *uio)
-{
- size_t init;
- int error = 0;
- off_t off = roff, left = rsize, toread;
- caddr_t data = rdata;
- struct ntvattr *vap;
- *initp = 0;
-
- while (left) {
- error = ntfs_ntvattrget(ntmp, ip, attrnum, attrname,
- ntfs_btocn(off), &vap);
- if (error)
- return (error);
- toread = min(left, ntfs_cntob(vap->va_vcnend + 1) - off);
- ddprintf(("ntfs_readattr_plain: o: %d, s: %d (%d - %d)\n",
- (u_int32_t) off, (u_int32_t) toread,
- (u_int32_t) vap->va_vcnstart,
- (u_int32_t) vap->va_vcnend));
- error = ntfs_readntvattr_plain(ntmp, ip, vap,
- off - ntfs_cntob(vap->va_vcnstart),
- toread, data, &init, uio);
- if (error) {
- printf("ntfs_readattr_plain: " \
- "ntfs_readntvattr_plain failed: o: %d, s: %d\n",
- (u_int32_t) off, (u_int32_t) toread);
- printf("ntfs_readattr_plain: attrib: %d - %d\n",
- (u_int32_t) vap->va_vcnstart,
- (u_int32_t) vap->va_vcnend);
- ntfs_ntvattrrele(vap);
- break;
- }
- ntfs_ntvattrrele(vap);
- left -= toread;
- off += toread;
- data = data + toread;
- *initp += init;
- }
-
- return (error);
-}
-
-/*
- * This is one of read routines.
- */
-int
-ntfs_readattr(
- struct ntfsmount * ntmp,
- struct ntnode * ip,
- u_int32_t attrnum,
- char *attrname,
- off_t roff,
- size_t rsize,
- void *rdata,
- struct uio *uio)
-{
- int error = 0;
- struct ntvattr *vap;
- size_t init;
-
- ddprintf(("ntfs_readattr: reading %d: 0x%x, from %d size %d bytes\n",
- ip->i_number, attrnum, (u_int32_t) roff, (u_int32_t) rsize));
-
- error = ntfs_ntvattrget(ntmp, ip, attrnum, attrname, 0, &vap);
- if (error)
- return (error);
-
- if ((roff > vap->va_datalen) ||
- (roff + rsize > vap->va_datalen)) {
- ddprintf(("ntfs_readattr: offset too big\n"));
- ntfs_ntvattrrele(vap);
- return (E2BIG);
- }
- if (vap->va_compression && vap->va_compressalg) {
- u_int8_t *cup;
- u_int8_t *uup;
- off_t off = roff, left = rsize, tocopy;
- caddr_t data = rdata;
- cn_t cn;
-
- ddprintf(("ntfs_ntreadattr: compression: %d\n",
- vap->va_compressalg));
-
- MALLOC(cup, u_int8_t *, ntfs_cntob(NTFS_COMPUNIT_CL),
- M_NTFSDECOMP, M_WAITOK);
- MALLOC(uup, u_int8_t *, ntfs_cntob(NTFS_COMPUNIT_CL),
- M_NTFSDECOMP, M_WAITOK);
-
- cn = (ntfs_btocn(roff)) & (~(NTFS_COMPUNIT_CL - 1));
- off = roff - ntfs_cntob(cn);
-
- while (left) {
- error = ntfs_readattr_plain(ntmp, ip, attrnum,
- attrname, ntfs_cntob(cn),
- ntfs_cntob(NTFS_COMPUNIT_CL),
- cup, &init, NULL);
- if (error)
- break;
-
- tocopy = min(left, ntfs_cntob(NTFS_COMPUNIT_CL) - off);
-
- if (init == ntfs_cntob(NTFS_COMPUNIT_CL)) {
- if (uio)
- uiomove(cup + off, tocopy, uio);
- else
- memcpy(data, cup + off, tocopy);
- } else if (init == 0) {
- if (uio) {
- size_t remains = tocopy;
- for(; remains; remains--)
- uiomove("", 1, uio);
- }
- else
- bzero(data, tocopy);
- } else {
- error = ntfs_uncompunit(ntmp, uup, cup);
- if (error)
- break;
- if (uio)
- uiomove(uup + off, tocopy, uio);
- else
- memcpy(data, uup + off, tocopy);
- }
-
- left -= tocopy;
- data = data + tocopy;
- off += tocopy - ntfs_cntob(NTFS_COMPUNIT_CL);
- cn += NTFS_COMPUNIT_CL;
- }
-
- FREE(uup, M_NTFSDECOMP);
- FREE(cup, M_NTFSDECOMP);
- } else
- error = ntfs_readattr_plain(ntmp, ip, attrnum, attrname,
- roff, rsize, rdata, &init, uio);
- ntfs_ntvattrrele(vap);
- return (error);
-}
-
-#if UNUSED_CODE
-int
-ntfs_parserun(
- cn_t * cn,
- cn_t * cl,
- u_int8_t * run,
- u_long len,
- u_long *off)
-{
- u_int8_t sz;
- int i;
-
- if (NULL == run) {
- printf("ntfs_parsetun: run == NULL\n");
- return (EINVAL);
- }
- sz = run[(*off)++];
- if (0 == sz) {
- printf("ntfs_parserun: trying to go out of run\n");
- return (E2BIG);
- }
- *cl = 0;
- if ((sz & 0xF) > 8 || (*off) + (sz & 0xF) > len) {
- printf("ntfs_parserun: " \
- "bad run: length too big: sz: 0x%02x (%ld < %ld + sz)\n",
- sz, len, *off);
- return (EINVAL);
- }
- for (i = 0; i < (sz & 0xF); i++)
- *cl += (u_int32_t) run[(*off)++] << (i << 3);
-
- sz >>= 4;
- if ((sz & 0xF) > 8 || (*off) + (sz & 0xF) > len) {
- printf("ntfs_parserun: " \
- "bad run: length too big: sz: 0x%02x (%ld < %ld + sz)\n",
- sz, len, *off);
- return (EINVAL);
- }
- for (i = 0; i < (sz & 0xF); i++)
- *cn += (u_int32_t) run[(*off)++] << (i << 3);
-
- return (0);
-}
-#endif
-
-/*
- * Process fixup routine on given buffer.
- */
-int
-ntfs_procfixups(
- struct ntfsmount * ntmp,
- u_int32_t magic,
- caddr_t buf,
- size_t len)
-{
- struct fixuphdr *fhp = (struct fixuphdr *) buf;
- int i;
- u_int16_t fixup;
- u_int16_t *fxp;
- u_int16_t *cfxp;
-
- if (fhp->fh_magic != magic) {
- printf("ntfs_procfixups: magic doesn't match: %08x != %08x\n",
- fhp->fh_magic, magic);
- return (EINVAL);
- }
- if ((fhp->fh_fnum - 1) * ntmp->ntm_bps != len) {
- printf("ntfs_procfixups: " \
- "bad fixups number: %d for %ld bytes block\n",
- fhp->fh_fnum, (long)len); /* XXX printf kludge */
- return (EINVAL);
- }
- if (fhp->fh_foff >= ntmp->ntm_spc * ntmp->ntm_mftrecsz * ntmp->ntm_bps) {
- printf("ntfs_procfixups: invalid offset: %x", fhp->fh_foff);
- return (EINVAL);
- }
- fxp = (u_int16_t *) (buf + fhp->fh_foff);
- cfxp = (u_int16_t *) (buf + ntmp->ntm_bps - 2);
- fixup = *fxp++;
- for (i = 1; i < fhp->fh_fnum; i++, fxp++) {
- if (*cfxp != fixup) {
- printf("ntfs_procfixups: fixup %d doesn't match\n", i);
- return (EINVAL);
- }
- *cfxp = *fxp;
- ((caddr_t) cfxp) += ntmp->ntm_bps;
- }
- return (0);
-}
-
-#if UNUSED_CODE
-int
-ntfs_runtocn(
- cn_t * cn,
- struct ntfsmount * ntmp,
- u_int8_t * run,
- u_long len,
- cn_t vcn)
-{
- cn_t ccn = 0;
- cn_t ccl = 0;
- u_long off = 0;
- int error = 0;
-
-#if NTFS_DEBUG
- int i;
- printf("ntfs_runtocn: run: 0x%p, %ld bytes, vcn:%ld\n",
- run, len, (u_long) vcn);
- printf("ntfs_runtocn: run: ");
- for (i = 0; i < len; i++)
- printf("0x%02x ", run[i]);
- printf("\n");
-#endif
-
- if (NULL == run) {
- printf("ntfs_runtocn: run == NULL\n");
- return (EINVAL);
- }
- do {
- if (run[off] == 0) {
- printf("ntfs_runtocn: vcn too big\n");
- return (E2BIG);
- }
- vcn -= ccl;
- error = ntfs_parserun(&ccn, &ccl, run, len, &off);
- if (error) {
- printf("ntfs_runtocn: ntfs_parserun failed\n");
- return (error);
- }
- } while (ccl <= vcn);
- *cn = ccn + vcn;
- return (0);
-}
-#endif
-
-/*
- * this initializes toupper table & dependant variables to be ready for
- * later work
- */
-void
-ntfs_toupper_init()
-{
- ntfs_toupper_tab = (wchar *) NULL;
- lockinit(&ntfs_toupper_lock, PVFS, "ntfs_toupper", 0, 0);
- ntfs_toupper_usecount = 0;
-}
-
-/*
- * if the ntfs_toupper_tab[] is filled already, just raise use count;
- * otherwise read the data from the filesystem we are currently mounting
- */
-int
-ntfs_toupper_use(mp, ntmp)
- struct mount *mp;
- struct ntfsmount *ntmp;
-{
- int error = 0;
- struct vnode *vp;
-
- /* get exclusive access */
- LOCKMGR(&ntfs_toupper_lock, LK_EXCLUSIVE, NULL);
-
- /* only read the translation data from a file if it hasn't been
- * read already */
- if (ntfs_toupper_tab)
- goto out;
-
- /*
- * Read in Unicode lowercase -> uppercase translation file.
- * XXX for now, just the first 256 entries are used anyway,
- * so don't bother reading more
- */
- MALLOC(ntfs_toupper_tab, wchar *, 256 * sizeof(wchar),
- M_NTFSRDATA, M_WAITOK);
-
- if ((error = VFS_VGET(mp, NTFS_UPCASEINO, &vp)))
- goto out;
- error = ntfs_readattr(ntmp, VTONT(vp), NTFS_A_DATA, NULL,
- 0, 256*sizeof(wchar), (char *) ntfs_toupper_tab, NULL);
- vput(vp);
-
- out:
- ntfs_toupper_usecount++;
- LOCKMGR(&ntfs_toupper_lock, LK_RELEASE, NULL);
- return (error);
-}
-
-/*
- * lower the use count and if it reaches zero, free the memory
- * tied by toupper table
- */
-void
-ntfs_toupper_unuse()
-{
- /* get exclusive access */
- LOCKMGR(&ntfs_toupper_lock, LK_EXCLUSIVE, NULL);
-
- ntfs_toupper_usecount--;
- if (ntfs_toupper_usecount == 0) {
- FREE(ntfs_toupper_tab, M_NTFSRDATA);
- ntfs_toupper_tab = NULL;
- }
-#ifdef DIAGNOSTIC
- else if (ntfs_toupper_usecount < 0) {
- panic("ntfs_toupper_unuse(): use count negative: %d\n",
- ntfs_toupper_usecount);
- }
-#endif
-
- /* release the lock */
- LOCKMGR(&ntfs_toupper_lock, LK_RELEASE, NULL);
-}
-
-/*
- * maps the Unicode char to 8bit equivalent
- * XXX currently only gets lower 8bit from the Unicode char
- * and substitutes a '_' for it if the result would be '\0';
- * something better has to be definitely though out
- */
-char
-ntfs_u28(unichar)
- wchar unichar;
-{
- return (char) NTFS_U28(unichar);
-}
-
diff --git a/sys/fs/ntfs/ntfs_subr.h b/sys/fs/ntfs/ntfs_subr.h
deleted file mode 100644
index a0cda505c421..000000000000
--- a/sys/fs/ntfs/ntfs_subr.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/* $NetBSD: ntfs_subr.h,v 1.8 1999/10/10 14:48:37 jdolecek Exp $ */
-
-/*-
- * Copyright (c) 1998, 1999 Semen Ustimenko
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#define VA_LOADED 0x0001
-#define VA_PRELOADED 0x0002
-
-struct ntvattr {
- LIST_ENTRY(ntvattr) va_list;
-
- u_int32_t va_vflag;
- struct vnode *va_vp;
- struct ntnode *va_ip;
-
- u_int32_t va_flag;
- u_int32_t va_type;
- u_int8_t va_namelen;
- char va_name[NTFS_MAXATTRNAME];
-
- u_int32_t va_compression;
- u_int32_t va_compressalg;
- u_int32_t va_datalen;
- u_int32_t va_allocated;
- cn_t va_vcnstart;
- cn_t va_vcnend;
- u_int16_t va_index;
- union {
- struct {
- cn_t * cn;
- cn_t * cl;
- u_long cnt;
- } vrun;
- caddr_t datap;
- struct attr_name *name;
- struct attr_indexroot *iroot;
- struct attr_indexalloc *ialloc;
- } va_d;
-};
-#define va_vruncn va_d.vrun.cn
-#define va_vruncl va_d.vrun.cl
-#define va_vruncnt va_d.vrun.cnt
-#define va_datap va_d.datap
-#define va_a_name va_d.name
-#define va_a_iroot va_d.iroot
-#define va_a_ialloc va_d.ialloc
-
-struct componentname;
-struct fnode;
-struct uio;
-
-int ntfs_procfixups __P(( struct ntfsmount *, u_int32_t, caddr_t, size_t ));
-int ntfs_parserun __P(( cn_t *, cn_t *, u_int8_t *, u_long, u_long *));
-int ntfs_runtocn __P(( cn_t *, struct ntfsmount *, u_int8_t *, u_long, cn_t));
-int ntfs_readntvattr_plain __P(( struct ntfsmount *, struct ntnode *, struct ntvattr *, off_t, size_t, void *,size_t *, struct uio *));
-int ntfs_readattr_plain __P(( struct ntfsmount *, struct ntnode *, u_int32_t, char *, off_t, size_t, void *,size_t *, struct uio *));
-int ntfs_readattr __P(( struct ntfsmount *, struct ntnode *, u_int32_t, char *, off_t, size_t, void *, struct uio *));
-int ntfs_filesize __P(( struct ntfsmount *, struct fnode *, u_int64_t *, u_int64_t *));
-int ntfs_times __P(( struct ntfsmount *, struct ntnode *, ntfs_times_t *));
-struct timespec ntfs_nttimetounix __P(( u_int64_t ));
-int ntfs_ntreaddir __P(( struct ntfsmount *, struct fnode *, u_int32_t, struct attr_indexentry **));
-char ntfs_u28 __P((wchar));
-int ntfs_runtovrun __P(( cn_t **, cn_t **, u_long *, u_int8_t *));
-int ntfs_attrtontvattr __P(( struct ntfsmount *, struct ntvattr **, struct attr * ));
-void ntfs_freentvattr __P(( struct ntvattr * ));
-int ntfs_loadntvattrs __P(( struct ntfsmount *, struct vnode *, caddr_t, struct ntvattr **));
-struct ntvattr * ntfs_findntvattr __P(( struct ntfsmount *, struct ntnode *, u_int32_t, cn_t ));
-int ntfs_ntlookupfile __P((struct ntfsmount *, struct vnode *, struct componentname *, struct vnode **));
-int ntfs_isnamepermitted __P((struct ntfsmount *, struct attr_indexentry * ));
-int ntfs_ntvattrrele __P((struct ntvattr * ));
-int ntfs_ntvattrget __P((struct ntfsmount *, struct ntnode *, u_int32_t, const char *, cn_t , struct ntvattr **));
-int ntfs_ntlookup __P((struct ntfsmount *, ino_t, struct ntnode **));
-int ntfs_ntget __P((struct ntnode *));
-void ntfs_ntref __P((struct ntnode *));
-void ntfs_ntrele __P((struct ntnode *));
-void ntfs_ntput __P((struct ntnode *));
-int ntfs_loadntnode __P(( struct ntfsmount *, struct ntnode * ));
-int ntfs_writentvattr_plain __P((struct ntfsmount *, struct ntnode *, struct ntvattr *, off_t, size_t, void *, size_t *, struct uio *));
-int ntfs_writeattr_plain __P((struct ntfsmount *, struct ntnode *, u_int32_t, char *, off_t, size_t, void *, size_t *, struct uio *));
-void ntfs_toupper_init __P((void));
-int ntfs_toupper_use __P((struct mount *, struct ntfsmount *));
-void ntfs_toupper_unuse __P((void));
-int ntfs_fget __P((struct ntfsmount *, struct ntnode *, int, char *, struct fnode **));
-void ntfs_frele __P((struct fnode *));
diff --git a/sys/fs/ntfs/ntfs_vfsops.c b/sys/fs/ntfs/ntfs_vfsops.c
deleted file mode 100644
index 089c6ebf23a6..000000000000
--- a/sys/fs/ntfs/ntfs_vfsops.c
+++ /dev/null
@@ -1,1056 +0,0 @@
-/* $NetBSD: ntfs_vfsops.c,v 1.23 1999/11/15 19:38:14 jdolecek Exp $ */
-
-/*-
- * Copyright (c) 1998, 1999 Semen Ustimenko
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/namei.h>
-#include <sys/conf.h>
-#include <sys/proc.h>
-#include <sys/kernel.h>
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <sys/buf.h>
-#include <sys/fcntl.h>
-#include <sys/malloc.h>
-#include <sys/systm.h>
-#if defined(__NetBSD__)
-#include <sys/device.h>
-#endif
-
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#if defined(__NetBSD__)
-#include <vm/vm_prot.h>
-#endif
-#include <vm/vm_page.h>
-#include <vm/vm_object.h>
-#include <vm/vm_extern.h>
-#include <vm/vm_zone.h>
-
-#if defined(__NetBSD__)
-#include <miscfs/specfs/specdev.h>
-#endif
-
-/*#define NTFS_DEBUG 1*/
-#include <ntfs/ntfs.h>
-#include <ntfs/ntfs_inode.h>
-#include <ntfs/ntfs_subr.h>
-#include <ntfs/ntfs_vfsops.h>
-#include <ntfs/ntfs_ihash.h>
-#include <ntfs/ntfsmount.h>
-
-#if defined(__FreeBSD__)
-MALLOC_DEFINE(M_NTFSMNT, "NTFS mount", "NTFS mount structure");
-MALLOC_DEFINE(M_NTFSNTNODE,"NTFS ntnode", "NTFS ntnode information");
-MALLOC_DEFINE(M_NTFSFNODE,"NTFS fnode", "NTFS fnode information");
-MALLOC_DEFINE(M_NTFSDIR,"NTFS dir", "NTFS dir buffer");
-#endif
-
-static int ntfs_root __P((struct mount *, struct vnode **));
-static int ntfs_statfs __P((struct mount *, struct statfs *,
- struct proc *));
-static int ntfs_unmount __P((struct mount *, int, struct proc *));
-static int ntfs_vget __P((struct mount *mp, ino_t ino,
- struct vnode **vpp));
-static int ntfs_mountfs __P((register struct vnode *, struct mount *,
- struct ntfs_args *, struct proc *));
-static int ntfs_vptofh __P((struct vnode *, struct fid *));
-static int ntfs_fhtovp __P((struct mount *, struct fid *,
- struct vnode **));
-
-#if !defined (__FreeBSD__)
-static int ntfs_quotactl __P((struct mount *, int, uid_t, caddr_t,
- struct proc *));
-static int ntfs_start __P((struct mount *, int, struct proc *));
-static int ntfs_sync __P((struct mount *, int, struct ucred *,
- struct proc *));
-#endif
-
-#if defined(__FreeBSD__)
-struct sockaddr;
-static int ntfs_mount __P((struct mount *, char *, caddr_t,
- struct nameidata *, struct proc *));
-static int ntfs_init __P((struct vfsconf *));
-static int ntfs_checkexp __P((struct mount *, struct sockaddr *,
- int *, struct ucred **));
-#elif defined(__NetBSD__)
-static int ntfs_mount __P((struct mount *, const char *, void *,
- struct nameidata *, struct proc *));
-static void ntfs_init __P((void));
-static int ntfs_mountroot __P((void));
-static int ntfs_sysctl __P((int *, u_int, void *, size_t *, void *,
- size_t, struct proc *));
-static int ntfs_checkexp __P((struct mount *, struct mbuf *,
- int *, struct ucred **));
-#endif
-
-/*
- * Verify a remote client has export rights and return these rights via.
- * exflagsp and credanonp.
- */
-static int
-ntfs_checkexp(mp, nam, exflagsp, credanonp)
-#if defined(__FreeBSD__)
- register struct mount *mp;
- struct sockaddr *nam;
- int *exflagsp;
- struct ucred **credanonp;
-#else /* defined(__NetBSD__) */
- register struct mount *mp;
- struct mbuf *nam;
- int *exflagsp;
- struct ucred **credanonp;
-#endif
-{
- register struct netcred *np;
- register struct ntfsmount *ntm = VFSTONTFS(mp);
-
- /*
- * Get the export permission structure for this <mp, client> tuple.
- */
- np = vfs_export_lookup(mp, &ntm->ntm_export, nam);
- if (np == NULL)
- return (EACCES);
-
- *exflagsp = np->netc_exflags;
- *credanonp = &np->netc_anon;
- return (0);
-}
-
-#if defined(__NetBSD__)
-/*ARGSUSED*/
-static int
-ntfs_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
- int *name;
- u_int namelen;
- void *oldp;
- size_t *oldlenp;
- void *newp;
- size_t newlen;
- struct proc *p;
-{
- return (EINVAL);
-}
-
-static int
-ntfs_mountroot()
-{
- struct mount *mp;
- extern struct vnode *rootvp;
- struct proc *p = curproc; /* XXX */
- int error;
- struct ntfs_args args;
-
- if (root_device->dv_class != DV_DISK)
- return (ENODEV);
-
- /*
- * Get vnodes for rootdev.
- */
- if (bdevvp(rootdev, &rootvp))
- panic("ntfs_mountroot: can't setup rootvp");
-
- if ((error = vfs_rootmountalloc(MOUNT_NTFS, "root_device", &mp))) {
- vrele(rootvp);
- return (error);
- }
-
- args.flag = 0;
- args.uid = 0;
- args.gid = 0;
- args.mode = 0777;
-
- if ((error = ntfs_mountfs(rootvp, mp, &args, p)) != 0) {
- mp->mnt_op->vfs_refcount--;
- vfs_unbusy(mp);
- free(mp, M_MOUNT);
- vrele(rootvp);
- return (error);
- }
-
- simple_lock(&mountlist_slock);
- CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list);
- simple_unlock(&mountlist_slock);
- (void)ntfs_statfs(mp, &mp->mnt_stat, p);
- vfs_unbusy(mp);
- return (0);
-}
-
-static void
-ntfs_init ()
-{
- ntfs_nthashinit();
- ntfs_toupper_init();
-}
-
-#elif defined(__FreeBSD__)
-
-static int
-ntfs_init (
- struct vfsconf *vcp )
-{
- ntfs_nthashinit();
- ntfs_toupper_init();
- return 0;
-}
-
-#endif /* NetBSD */
-
-static int
-ntfs_mount (
- struct mount *mp,
-#if defined(__FreeBSD__)
- char *path,
- caddr_t data,
-#else
- const char *path,
- void *data,
-#endif
- struct nameidata *ndp,
- struct proc *p )
-{
- size_t size;
- int err = 0;
- struct vnode *devvp;
- struct ntfs_args args;
-
-#ifdef __FreeBSD__
- /*
- * Use NULL path to flag a root mount
- */
- if( path == NULL) {
- /*
- ***
- * Mounting root file system
- ***
- */
-
- /* Get vnode for root device*/
- if( bdevvp( rootdev, &rootvp))
- panic("ffs_mountroot: can't setup bdevvp for root");
-
- /*
- * FS specific handling
- */
- mp->mnt_flag |= MNT_RDONLY; /* XXX globally applicable?*/
-
- /*
- * Attempt mount
- */
- if( ( err = ntfs_mountfs(rootvp, mp, &args, p)) != 0) {
- /* fs specific cleanup (if any)*/
- goto error_1;
- }
-
- goto dostatfs; /* success*/
-
- }
-#endif /* FreeBSD */
-
- /*
- ***
- * Mounting non-root file system or updating a file system
- ***
- */
-
- /* copy in user arguments*/
- err = copyin(data, (caddr_t)&args, sizeof (struct ntfs_args));
- if (err)
- goto error_1; /* can't get arguments*/
-
- /*
- * If updating, check whether changing from read-only to
- * read/write; if there is no device name, that's all we do.
- */
- if (mp->mnt_flag & MNT_UPDATE) {
- /* if not updating name...*/
- if (args.fspec == 0) {
- /*
- * Process export requests. Jumping to "success"
- * will return the vfs_export() error code.
- */
- struct ntfsmount *ntm = VFSTONTFS(mp);
- err = vfs_export(mp, &ntm->ntm_export, &args.export);
- goto success;
- }
-
- printf("ntfs_mount(): MNT_UPDATE not supported\n");
- err = EINVAL;
- goto error_1;
- }
-
- /*
- * Not an update, or updating the name: look up the name
- * and verify that it refers to a sensible block device.
- */
- NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, p);
- err = namei(ndp);
- if (err) {
- /* can't get devvp!*/
- goto error_1;
- }
- NDFREE(ndp, NDF_ONLY_PNBUF);
- devvp = ndp->ni_vp;
-
-#if defined(__FreeBSD__)
- if (!vn_isdisk(devvp, &err))
- goto error_2;
-#else
- if (devvp->v_type != VBLK) {
- err = ENOTBLK;
- goto error_2;
- }
- if (major(devvp->v_rdev) >= nblkdev) {
- err = ENXIO;
- goto error_2;
- }
-#endif
- if (mp->mnt_flag & MNT_UPDATE) {
-#if 0
- /*
- ********************
- * UPDATE
- ********************
- */
-
- if (devvp != ntmp->um_devvp)
- err = EINVAL; /* needs translation */
- else
- vrele(devvp);
- /*
- * Update device name only on success
- */
- if( !err) {
- /* Save "mounted from" info for mount point (NULL pad)*/
- copyinstr( args.fspec,
- mp->mnt_stat.f_mntfromname,
- MNAMELEN - 1,
- &size);
- bzero( mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
- }
-#endif
- } else {
- /*
- ********************
- * NEW MOUNT
- ********************
- */
-
- /*
- * Since this is a new mount, we want the names for
- * the device and the mount point copied in. If an
- * error occurs, the mountpoint is discarded by the
- * upper level code.
- */
- /* Save "last mounted on" info for mount point (NULL pad)*/
- copyinstr( path, /* mount point*/
- mp->mnt_stat.f_mntonname, /* save area*/
- MNAMELEN - 1, /* max size*/
- &size); /* real size*/
- bzero( mp->mnt_stat.f_mntonname + size, MNAMELEN - size);
-
- /* Save "mounted from" info for mount point (NULL pad)*/
- copyinstr( args.fspec, /* device name*/
- mp->mnt_stat.f_mntfromname, /* save area*/
- MNAMELEN - 1, /* max size*/
- &size); /* real size*/
- bzero( mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
-
- err = ntfs_mountfs(devvp, mp, &args, p);
- }
- if (err) {
- goto error_2;
- }
-
-#ifdef __FreeBSD__
-dostatfs:
-#endif
- /*
- * Initialize FS stat information in mount struct; uses both
- * mp->mnt_stat.f_mntonname and mp->mnt_stat.f_mntfromname
- *
- * This code is common to root and non-root mounts
- */
- (void)VFS_STATFS(mp, &mp->mnt_stat, p);
-
- goto success;
-
-
-error_2: /* error with devvp held*/
-
- /* release devvp before failing*/
- vrele(devvp);
-
-error_1: /* no state to back out*/
-
-success:
- return(err);
-}
-
-/*
- * Common code for mount and mountroot
- */
-int
-ntfs_mountfs(devvp, mp, argsp, p)
- register struct vnode *devvp;
- struct mount *mp;
- struct ntfs_args *argsp;
- struct proc *p;
-{
- struct buf *bp;
- struct ntfsmount *ntmp;
- dev_t dev = devvp->v_rdev;
- int error, ronly, ncount, i;
- struct vnode *vp;
-
- /*
- * Disallow multiple mounts of the same device.
- * Disallow mounting of a device that is currently in use
- * (except for root, which might share swap device for miniroot).
- * Flush out any old buffers remaining from a previous use.
- */
- error = vfs_mountedon(devvp);
- if (error)
- return (error);
- ncount = vcount(devvp);
-#if defined(__FreeBSD__)
- if (devvp->v_object)
- ncount -= 1;
-#endif
- if (ncount > 1 && devvp != rootvp)
- return (EBUSY);
-#if defined(__FreeBSD__)
- VN_LOCK(devvp, LK_EXCLUSIVE | LK_RETRY, p);
- error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0);
- VOP__UNLOCK(devvp, 0, p);
-#else
- error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0);
-#endif
- if (error)
- return (error);
-
- ronly = (mp->mnt_flag & MNT_RDONLY) != 0;
- VN_LOCK(devvp, LK_EXCLUSIVE | LK_RETRY, p);
- error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, p);
- VOP__UNLOCK(devvp, 0, p);
- if (error)
- return (error);
-
- bp = NULL;
-
- error = bread(devvp, BBLOCK, BBSIZE, NOCRED, &bp);
- if (error)
- goto out;
- ntmp = malloc( sizeof *ntmp, M_NTFSMNT, M_WAITOK );
- bzero( ntmp, sizeof *ntmp );
- bcopy( bp->b_data, &ntmp->ntm_bootfile, sizeof(struct bootfile) );
- brelse( bp );
- bp = NULL;
-
- if (strncmp(ntmp->ntm_bootfile.bf_sysid, NTFS_BBID, NTFS_BBIDLEN)) {
- error = EINVAL;
- dprintf(("ntfs_mountfs: invalid boot block\n"));
- goto out;
- }
-
- {
- int8_t cpr = ntmp->ntm_mftrecsz;
- if( cpr > 0 )
- ntmp->ntm_bpmftrec = ntmp->ntm_spc * cpr;
- else
- ntmp->ntm_bpmftrec = (1 << (-cpr)) / ntmp->ntm_bps;
- }
- dprintf(("ntfs_mountfs(): bps: %d, spc: %d, media: %x, mftrecsz: %d (%d sects)\n",
- ntmp->ntm_bps,ntmp->ntm_spc,ntmp->ntm_bootfile.bf_media,
- ntmp->ntm_mftrecsz,ntmp->ntm_bpmftrec));
- dprintf(("ntfs_mountfs(): mftcn: 0x%x|0x%x\n",
- (u_int32_t)ntmp->ntm_mftcn,(u_int32_t)ntmp->ntm_mftmirrcn));
-
- ntmp->ntm_mountp = mp;
- ntmp->ntm_dev = dev;
- ntmp->ntm_devvp = devvp;
- ntmp->ntm_uid = argsp->uid;
- ntmp->ntm_gid = argsp->gid;
- ntmp->ntm_mode = argsp->mode;
- ntmp->ntm_flag = argsp->flag;
- mp->mnt_data = (qaddr_t)ntmp;
-
- dprintf(("ntfs_mountfs(): case-%s,%s uid: %d, gid: %d, mode: %o\n",
- (ntmp->ntm_flag & NTFS_MFLAG_CASEINS)?"insens.":"sens.",
- (ntmp->ntm_flag & NTFS_MFLAG_ALLNAMES)?" allnames,":"",
- ntmp->ntm_uid, ntmp->ntm_gid, ntmp->ntm_mode));
-
- /*
- * We read in some system nodes to do not allow
- * reclaim them and to have everytime access to them.
- */
- {
- int pi[3] = { NTFS_MFTINO, NTFS_ROOTINO, NTFS_BITMAPINO };
- for (i=0; i<3; i++) {
- error = VFS_VGET(mp, pi[i], &(ntmp->ntm_sysvn[pi[i]]));
- if(error)
- goto out1;
- ntmp->ntm_sysvn[pi[i]]->v_flag |= VSYSTEM;
- VREF(ntmp->ntm_sysvn[pi[i]]);
- vput(ntmp->ntm_sysvn[pi[i]]);
- }
- }
-
- /* read the Unicode lowercase --> uppercase translation table,
- * if necessary */
- if ((error = ntfs_toupper_use(mp, ntmp)))
- goto out1;
-
- /*
- * Scan $BitMap and count free clusters
- */
- error = ntfs_calccfree(ntmp, &ntmp->ntm_cfree);
- if(error)
- goto out1;
-
- /*
- * Read and translate to internal format attribute
- * definition file.
- */
- {
- int num,j;
- struct attrdef ad;
-
- /* Open $AttrDef */
- error = VFS_VGET(mp, NTFS_ATTRDEFINO, &vp );
- if(error)
- goto out1;
-
- /* Count valid entries */
- for(num=0;;num++) {
- error = ntfs_readattr(ntmp, VTONT(vp),
- NTFS_A_DATA, NULL,
- num * sizeof(ad), sizeof(ad),
- &ad, NULL);
- if (error)
- goto out1;
- if (ad.ad_name[0] == 0)
- break;
- }
-
- /* Alloc memory for attribute definitions */
- MALLOC(ntmp->ntm_ad, struct ntvattrdef *,
- num * sizeof(struct ntvattrdef),
- M_NTFSMNT, M_WAITOK);
-
- ntmp->ntm_adnum = num;
-
- /* Read them and translate */
- for(i=0;i<num;i++){
- error = ntfs_readattr(ntmp, VTONT(vp),
- NTFS_A_DATA, NULL,
- i * sizeof(ad), sizeof(ad),
- &ad, NULL);
- if (error)
- goto out1;
- j = 0;
- do {
- ntmp->ntm_ad[i].ad_name[j] = ad.ad_name[j];
- } while(ad.ad_name[j++]);
- ntmp->ntm_ad[i].ad_namelen = j - 1;
- ntmp->ntm_ad[i].ad_type = ad.ad_type;
- }
-
- vput(vp);
- }
-
-#if defined(__FreeBSD__)
- mp->mnt_stat.f_fsid.val[0] = dev2udev(dev);
- mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum;
-#else
- mp->mnt_stat.f_fsid.val[0] = dev;
- mp->mnt_stat.f_fsid.val[1] = makefstype(MOUNT_NTFS);
-#endif
- mp->mnt_maxsymlinklen = 0;
- mp->mnt_flag |= MNT_LOCAL;
- devvp->v_specmountpoint = mp;
- return (0);
-
-out1:
- for(i=0;i<NTFS_SYSNODESNUM;i++)
- if(ntmp->ntm_sysvn[i]) vrele(ntmp->ntm_sysvn[i]);
-
- if (vflush(mp,NULLVP,0))
- dprintf(("ntfs_mountfs: vflush failed\n"));
-
-out:
- devvp->v_specmountpoint = NULL;
- if (bp)
- brelse(bp);
-
-#if defined __NetBSD__
- /* lock the device vnode before calling VOP_CLOSE() */
- VN_LOCK(devvp, LK_EXCLUSIVE | LK_RETRY, p);
- (void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, NOCRED, p);
- VOP__UNLOCK(devvp, 0, p);
-#else
- (void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, NOCRED, p);
-#endif
-
- return (error);
-}
-
-#if !defined(__FreeBSD__)
-static int
-ntfs_start (
- struct mount *mp,
- int flags,
- struct proc *p )
-{
- return (0);
-}
-#endif
-
-static int
-ntfs_unmount(
- struct mount *mp,
- int mntflags,
- struct proc *p)
-{
- register struct ntfsmount *ntmp;
- int error, ronly = 0, flags, i;
-
- dprintf(("ntfs_unmount: unmounting...\n"));
- ntmp = VFSTONTFS(mp);
-
- flags = 0;
- if(mntflags & MNT_FORCE)
- flags |= FORCECLOSE;
-
- dprintf(("ntfs_unmount: vflushing...\n"));
- error = vflush(mp,NULLVP,flags | SKIPSYSTEM);
- if (error) {
- printf("ntfs_unmount: vflush failed: %d\n",error);
- return (error);
- }
-
- /* Check if only system vnodes are rest */
- for(i=0;i<NTFS_SYSNODESNUM;i++)
- if((ntmp->ntm_sysvn[i]) &&
- (ntmp->ntm_sysvn[i]->v_usecount > 1)) return (EBUSY);
-
- /* Dereference all system vnodes */
- for(i=0;i<NTFS_SYSNODESNUM;i++)
- if(ntmp->ntm_sysvn[i]) vrele(ntmp->ntm_sysvn[i]);
-
- /* vflush system vnodes */
- error = vflush(mp,NULLVP,flags);
- if (error)
- printf("ntfs_unmount: vflush failed(sysnodes): %d\n",error);
-
- /* Check if the type of device node isn't VBAD before
- * touching v_specinfo. If the device vnode is revoked, the
- * field is NULL and touching it causes null pointer derefercence.
- */
- if (ntmp->ntm_devvp->v_type != VBAD)
- ntmp->ntm_devvp->v_specmountpoint = NULL;
-
- vinvalbuf(ntmp->ntm_devvp, V_SAVE, NOCRED, p, 0, 0);
-
-#if defined(__NetBSD__)
- /* lock the device vnode before calling VOP_CLOSE() */
- VOP_LOCK(ntmp->ntm_devvp, LK_EXCLUSIVE | LK_RETRY);
- error = VOP_CLOSE(ntmp->ntm_devvp, ronly ? FREAD : FREAD|FWRITE,
- NOCRED, p);
- VOP__UNLOCK(ntmp->ntm_devvp, 0, p);
-#else
- error = VOP_CLOSE(ntmp->ntm_devvp, ronly ? FREAD : FREAD|FWRITE,
- NOCRED, p);
-#endif
-
- vrele(ntmp->ntm_devvp);
-
- /* free the toupper table, if this has been last mounted ntfs volume */
- ntfs_toupper_unuse();
-
- dprintf(("ntfs_umount: freeing memory...\n"));
- mp->mnt_data = (qaddr_t)0;
- mp->mnt_flag &= ~MNT_LOCAL;
- FREE(ntmp->ntm_ad, M_NTFSMNT);
- FREE(ntmp, M_NTFSMNT);
- return (error);
-}
-
-static int
-ntfs_root(
- struct mount *mp,
- struct vnode **vpp )
-{
- struct vnode *nvp;
- int error = 0;
-
- dprintf(("ntfs_root(): sysvn: %p\n",
- VFSTONTFS(mp)->ntm_sysvn[NTFS_ROOTINO]));
- error = VFS_VGET(mp, (ino_t)NTFS_ROOTINO, &nvp);
- if(error) {
- printf("ntfs_root: VFS_VGET failed: %d\n",error);
- return (error);
- }
-
- *vpp = nvp;
- return (0);
-}
-
-#if !defined(__FreeBSD__)
-static int
-ntfs_quotactl (
- struct mount *mp,
- int cmds,
- uid_t uid,
- caddr_t arg,
- struct proc *p)
-{
- printf("\nntfs_quotactl():\n");
- return EOPNOTSUPP;
-}
-#endif
-
-int
-ntfs_calccfree(
- struct ntfsmount *ntmp,
- cn_t *cfreep)
-{
- struct vnode *vp;
- u_int8_t *tmp;
- int j, error;
- long cfree = 0;
- size_t bmsize, i;
-
- vp = ntmp->ntm_sysvn[NTFS_BITMAPINO];
-
- bmsize = VTOF(vp)->f_size;
-
- MALLOC(tmp, u_int8_t *, bmsize, M_TEMP, M_WAITOK);
-
- error = ntfs_readattr(ntmp, VTONT(vp), NTFS_A_DATA, NULL,
- 0, bmsize, tmp, NULL);
- if (error)
- goto out;
-
- for(i=0;i<bmsize;i++)
- for(j=0;j<8;j++)
- if(~tmp[i] & (1 << j)) cfree++;
- *cfreep = cfree;
-
- out:
- FREE(tmp, M_TEMP);
- return(error);
-}
-
-static int
-ntfs_statfs(
- struct mount *mp,
- struct statfs *sbp,
- struct proc *p)
-{
- struct ntfsmount *ntmp = VFSTONTFS(mp);
- u_int64_t mftsize,mftallocated;
-
- dprintf(("ntfs_statfs():\n"));
-
- mftsize = VTOF(ntmp->ntm_sysvn[NTFS_MFTINO])->f_size;
- mftallocated = VTOF(ntmp->ntm_sysvn[NTFS_MFTINO])->f_allocated;
-
-#if defined(__FreeBSD__)
- sbp->f_type = mp->mnt_vfc->vfc_typenum;
-#elif defined(__NetBSD__)
- sbp->f_type = 0;
-#else
- sbp->f_type = MOUNT_NTFS;
-#endif
- sbp->f_bsize = ntmp->ntm_bps;
- sbp->f_iosize = ntmp->ntm_bps * ntmp->ntm_spc;
- sbp->f_blocks = ntmp->ntm_bootfile.bf_spv;
- sbp->f_bfree = sbp->f_bavail = ntfs_cntobn(ntmp->ntm_cfree);
- sbp->f_ffree = sbp->f_bfree / ntmp->ntm_bpmftrec;
- sbp->f_files = mftallocated / ntfs_bntob(ntmp->ntm_bpmftrec) +
- sbp->f_ffree;
- if (sbp != &mp->mnt_stat) {
- bcopy((caddr_t)mp->mnt_stat.f_mntonname,
- (caddr_t)&sbp->f_mntonname[0], MNAMELEN);
- bcopy((caddr_t)mp->mnt_stat.f_mntfromname,
- (caddr_t)&sbp->f_mntfromname[0], MNAMELEN);
- }
- sbp->f_flags = mp->mnt_flag;
-#ifdef __NetBSD__
- strncpy(sbp->f_fstypename, mp->mnt_op->vfs_name, MFSNAMELEN);
-#endif
-
- return (0);
-}
-
-#if !defined(__FreeBSD__)
-static int
-ntfs_sync (
- struct mount *mp,
- int waitfor,
- struct ucred *cred,
- struct proc *p)
-{
- /*dprintf(("ntfs_sync():\n"));*/
- return (0);
-}
-#endif
-
-/*ARGSUSED*/
-static int
-ntfs_fhtovp(
- struct mount *mp,
- struct fid *fhp,
- struct vnode **vpp)
-{
- struct vnode *nvp;
- struct ntfid *ntfhp = (struct ntfid *)fhp;
- int error;
-
- ddprintf(("ntfs_fhtovp(): %s: %d\n", mp->mnt_stat->f_mntonname,
- ntfhp->ntfid_ino));
-
- if ((error = VFS_VGET(mp, ntfhp->ntfid_ino, &nvp)) != 0) {
- *vpp = NULLVP;
- return (error);
- }
- /* XXX as unlink/rmdir/mkdir/creat are not currently possible
- * with NTFS, we don't need to check anything else for now */
- *vpp = nvp;
-
- return (0);
-}
-
-static int
-ntfs_vptofh(
- struct vnode *vp,
- struct fid *fhp)
-{
- register struct ntnode *ntp;
- register struct ntfid *ntfhp;
-
- ddprintf(("ntfs_fhtovp(): %s: %p\n", vp->v_mount->mnt_stat->f_mntonname,
- vp));
-
- ntp = VTONT(vp);
- ntfhp = (struct ntfid *)fhp;
- ntfhp->ntfid_len = sizeof(struct ntfid);
- ntfhp->ntfid_ino = ntp->i_number;
- /* ntfhp->ntfid_gen = ntp->i_gen; */
- return (0);
-}
-
-int
-ntfs_vgetex(
- struct mount *mp,
- ino_t ino,
- u_int32_t attrtype,
- char *attrname,
- u_long lkflags,
- u_long flags,
- struct proc *p,
- struct vnode **vpp)
-{
- int error;
- register struct ntfsmount *ntmp;
- struct ntnode *ip;
- struct fnode *fp;
- struct vnode *vp;
- enum vtype f_type;
-
- dprintf(("ntfs_vgetex: ino: %d, attr: 0x%x:%s, lkf: 0x%lx, f: 0x%lx\n",
- ino, attrtype, attrname?attrname:"", (u_long)lkflags,
- (u_long)flags ));
-
- ntmp = VFSTONTFS(mp);
- *vpp = NULL;
-
- /* Get ntnode */
- error = ntfs_ntlookup(ntmp, ino, &ip);
- if (error) {
- printf("ntfs_vget: ntfs_ntget failed\n");
- return (error);
- }
-
- /* It may be not initialized fully, so force load it */
- if (!(flags & VG_DONTLOADIN) && !(ip->i_flag & IN_LOADED)) {
- error = ntfs_loadntnode(ntmp, ip);
- if(error) {
- printf("ntfs_vget: CAN'T LOAD ATTRIBUTES FOR INO: %d\n",
- ip->i_number);
- ntfs_ntput(ip);
- return (error);
- }
- }
-
- error = ntfs_fget(ntmp, ip, attrtype, attrname, &fp);
- if (error) {
- printf("ntfs_vget: ntfs_fget failed\n");
- ntfs_ntput(ip);
- return (error);
- }
-
- f_type = VNON;
- if (!(flags & VG_DONTVALIDFN) && !(fp->f_flag & FN_VALID)) {
- if ((ip->i_frflag & NTFS_FRFLAG_DIR) &&
- (fp->f_attrtype == NTFS_A_DATA && fp->f_attrname == NULL)) {
- f_type = VDIR;
- } else if (flags & VG_EXT) {
- f_type = VNON;
- fp->f_size = fp->f_allocated = 0;
- } else {
- f_type = VREG;
-
- error = ntfs_filesize(ntmp, fp,
- &fp->f_size, &fp->f_allocated);
- if (error) {
- ntfs_ntput(ip);
- return (error);
- }
- }
-
- fp->f_flag |= FN_VALID;
- }
-
- if (FTOV(fp)) {
- VGET(FTOV(fp), lkflags, p);
- *vpp = FTOV(fp);
- ntfs_ntput(ip);
- return (0);
- }
-
- error = getnewvnode(VT_NTFS, ntmp->ntm_mountp, ntfs_vnodeop_p, &vp);
- if(error) {
- ntfs_frele(fp);
- ntfs_ntput(ip);
- return (error);
- }
- dprintf(("ntfs_vget: vnode: %p for ntnode: %d\n", vp,ino));
-
-#ifdef __FreeBSD__
- lockinit(&fp->f_lock, PINOD, "fnode", 0, 0);
-#endif
- fp->f_vp = vp;
- vp->v_data = fp;
- vp->v_type = f_type;
-
- if (ino == NTFS_ROOTINO)
- vp->v_flag |= VROOT;
-
- ntfs_ntput(ip);
-
- if (lkflags & LK_TYPE_MASK) {
- error = VN_LOCK(vp, lkflags, p);
- if (error) {
- vput(vp);
- return (error);
- }
- }
-
- VREF(ip->i_devvp);
- *vpp = vp;
- return (0);
-
-}
-
-static int
-ntfs_vget(
- struct mount *mp,
- ino_t ino,
- struct vnode **vpp)
-{
- return ntfs_vgetex(mp, ino, NTFS_A_DATA, NULL,
- LK_EXCLUSIVE | LK_RETRY, 0, curproc, vpp);
-}
-
-#if defined(__FreeBSD__)
-static struct vfsops ntfs_vfsops = {
- ntfs_mount,
- vfs_stdstart,
- ntfs_unmount,
- ntfs_root,
- vfs_stdquotactl,
- ntfs_statfs,
- vfs_stdsync,
- ntfs_vget,
- ntfs_fhtovp,
- ntfs_checkexp,
- ntfs_vptofh,
- ntfs_init,
- vfs_stduninit,
- vfs_stdextattrctl,
-};
-VFS_SET(ntfs_vfsops, ntfs, 0);
-#elif defined(__NetBSD__)
-extern struct vnodeopv_desc ntfs_vnodeop_opv_desc;
-
-struct vnodeopv_desc *ntfs_vnodeopv_descs[] = {
- &ntfs_vnodeop_opv_desc,
- NULL,
-};
-
-struct vfsops ntfs_vfsops = {
- MOUNT_NTFS,
- ntfs_mount,
- ntfs_start,
- ntfs_unmount,
- ntfs_root,
- ntfs_quotactl,
- ntfs_statfs,
- ntfs_sync,
- ntfs_vget,
- ntfs_fhtovp,
- ntfs_vptofh,
- ntfs_init,
- ntfs_sysctl,
- ntfs_mountroot,
- ntfs_checkexp,
- ntfs_vnodeopv_descs,
-};
-#else /* !NetBSD && !FreeBSD */
-static struct vfsops ntfs_vfsops = {
- ntfs_mount,
- ntfs_start,
- ntfs_unmount,
- ntfs_root,
- ntfs_quotactl,
- ntfs_statfs,
- ntfs_sync,
- ntfs_vget,
- ntfs_fhtovp,
- ntfs_vptofh,
- ntfs_init,
-};
-VFS_SET(ntfs_vfsops, ntfs, MOUNT_NTFS, 0);
-#endif
-
-
diff --git a/sys/fs/ntfs/ntfs_vfsops.h b/sys/fs/ntfs/ntfs_vfsops.h
deleted file mode 100644
index c05686f156bd..000000000000
--- a/sys/fs/ntfs/ntfs_vfsops.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* $NetBSD: ntfs_vfsops.h,v 1.4 1999/10/10 14:20:33 jdolecek Exp $ */
-
-/*-
- * Copyright (c) 1998, 1999 Semen Ustimenko (semenu@FreeBSD.org)
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#define VG_DONTLOADIN 0x0001 /* Tells ntfs_vgetex to do not call */
- /* ntfs_loadntnode() on ntnode, even if */
- /* ntnode not loaded */
-#define VG_DONTVALIDFN 0x0002 /* Tells ntfs_vgetex to do not validate */
- /* fnode */
-#define VG_EXT 0x0004 /* This is not main record */
-
-struct mount;
-struct ntfsmount;
-struct proc;
-struct vnode;
-
-int ntfs_vgetex(struct mount *, ino_t, u_int32_t, char *, u_long, u_long,
- struct proc *, struct vnode **);
-int ntfs_calccfree(struct ntfsmount *, cn_t *);
diff --git a/sys/fs/ntfs/ntfs_vnops.c b/sys/fs/ntfs/ntfs_vnops.c
deleted file mode 100644
index 381cb8fd8018..000000000000
--- a/sys/fs/ntfs/ntfs_vnops.c
+++ /dev/null
@@ -1,977 +0,0 @@
-/* $NetBSD: ntfs_vnops.c,v 1.23 1999/10/31 19:45:27 jdolecek Exp $ */
-
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * John Heidemann of the UCLA Ficus project.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- *
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <sys/namei.h>
-#include <sys/malloc.h>
-#include <sys/buf.h>
-#include <sys/dirent.h>
-
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#if defined(__NetBSD__)
-#include <vm/vm_prot.h>
-#endif
-#include <vm/vm_page.h>
-#include <vm/vm_object.h>
-#include <vm/vm_pager.h>
-#if defined(__FreeBSD__)
-#include <vm/vnode_pager.h>
-#endif
-#include <vm/vm_extern.h>
-
-#include <sys/sysctl.h>
-
-/*#define NTFS_DEBUG 1*/
-#include <ntfs/ntfs.h>
-#include <ntfs/ntfs_inode.h>
-#include <ntfs/ntfs_subr.h>
-#if defined(__NetBSD__)
-#include <miscfs/specfs/specdev.h>
-#include <miscfs/genfs/genfs.h>
-#endif
-
-#include <sys/unistd.h> /* for pathconf(2) constants */
-
-static int ntfs_bypass __P((struct vop_generic_args *ap));
-static int ntfs_read __P((struct vop_read_args *));
-static int ntfs_write __P((struct vop_write_args *ap));
-static int ntfs_getattr __P((struct vop_getattr_args *ap));
-static int ntfs_inactive __P((struct vop_inactive_args *ap));
-static int ntfs_print __P((struct vop_print_args *ap));
-static int ntfs_reclaim __P((struct vop_reclaim_args *ap));
-static int ntfs_strategy __P((struct vop_strategy_args *ap));
-static int ntfs_access __P((struct vop_access_args *ap));
-static int ntfs_open __P((struct vop_open_args *ap));
-static int ntfs_close __P((struct vop_close_args *ap));
-static int ntfs_readdir __P((struct vop_readdir_args *ap));
-static int ntfs_lookup __P((struct vop_lookup_args *ap));
-static int ntfs_bmap __P((struct vop_bmap_args *ap));
-#if defined(__FreeBSD__)
-static int ntfs_getpages __P((struct vop_getpages_args *ap));
-static int ntfs_putpages __P((struct vop_putpages_args *));
-static int ntfs_fsync __P((struct vop_fsync_args *ap));
-#endif
-static int ntfs_pathconf __P((void *));
-
-int ntfs_prtactive = 1; /* 1 => print out reclaim of active vnodes */
-
-#if defined(__FreeBSD__)
-int
-ntfs_getpages(ap)
- struct vop_getpages_args *ap;
-{
- return vnode_pager_generic_getpages(ap->a_vp, ap->a_m, ap->a_count,
- ap->a_reqpage);
-}
-
-int
-ntfs_putpages(ap)
- struct vop_putpages_args *ap;
-{
- return vnode_pager_generic_putpages(ap->a_vp, ap->a_m, ap->a_count,
- ap->a_sync, ap->a_rtvals);
-}
-#endif
-
-/*
- * This is a noop, simply returning what one has been given.
- */
-int
-ntfs_bmap(ap)
- struct vop_bmap_args /* {
- struct vnode *a_vp;
- daddr_t a_bn;
- struct vnode **a_vpp;
- daddr_t *a_bnp;
- int *a_runp;
- int *a_runb;
- } */ *ap;
-{
- dprintf(("ntfs_bmap: vn: %p, blk: %d\n", ap->a_vp,(u_int32_t)ap->a_bn));
- if (ap->a_vpp != NULL)
- *ap->a_vpp = ap->a_vp;
- if (ap->a_bnp != NULL)
- *ap->a_bnp = ap->a_bn;
- if (ap->a_runp != NULL)
- *ap->a_runp = 0;
-#if !defined(__NetBSD__)
- if (ap->a_runb != NULL)
- *ap->a_runb = 0;
-#endif
- return (0);
-}
-
-static int
-ntfs_read(ap)
- struct vop_read_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- int a_ioflag;
- struct ucred *a_cred;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
- register struct fnode *fp = VTOF(vp);
- register struct ntnode *ip = FTONT(fp);
- struct uio *uio = ap->a_uio;
- struct ntfsmount *ntmp = ip->i_mp;
- u_int64_t toread;
- int error;
-
- dprintf(("ntfs_read: ino: %d, off: %d resid: %d, segflg: %d\n",ip->i_number,(u_int32_t)uio->uio_offset,uio->uio_resid,uio->uio_segflg));
-
- dprintf(("ntfs_read: filesize: %d",(u_int32_t)fp->f_size));
-
- /* don't allow reading after end of file */
- if (uio->uio_offset > fp->f_size)
- toread = 0;
- else
- toread = min( uio->uio_resid, fp->f_size - uio->uio_offset );
-
- dprintf((", toread: %d\n",(u_int32_t)toread));
-
- if (toread == 0)
- return (0);
-
- error = ntfs_readattr(ntmp, ip, fp->f_attrtype,
- fp->f_attrname, uio->uio_offset, toread, NULL, uio);
- if (error) {
- printf("ntfs_read: ntfs_readattr failed: %d\n",error);
- return (error);
- }
-
- return (0);
-}
-
-static int
-ntfs_bypass(ap)
- struct vop_generic_args /* {
- struct vnodeop_desc *a_desc;
- <other random data follows, presumably>
- } */ *ap;
-{
- int error = ENOTTY;
- dprintf(("ntfs_bypass: %s\n", ap->a_desc->vdesc_name));
- return (error);
-}
-
-
-static int
-ntfs_getattr(ap)
- struct vop_getattr_args /* {
- struct vnode *a_vp;
- struct vattr *a_vap;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
- register struct fnode *fp = VTOF(vp);
- register struct ntnode *ip = FTONT(fp);
- register struct vattr *vap = ap->a_vap;
-
- dprintf(("ntfs_getattr: %d, flags: %d\n",ip->i_number,ip->i_flag));
-
-#if defined(__FreeBSD__)
- vap->va_fsid = dev2udev(ip->i_dev);
-#else /* NetBSD */
- vap->va_fsid = ip->i_dev;
-#endif
- vap->va_fileid = ip->i_number;
- vap->va_mode = ip->i_mp->ntm_mode;
- vap->va_nlink = ip->i_nlink;
- vap->va_uid = ip->i_mp->ntm_uid;
- vap->va_gid = ip->i_mp->ntm_gid;
- vap->va_rdev = 0; /* XXX UNODEV ? */
- vap->va_size = fp->f_size;
- vap->va_bytes = fp->f_allocated;
- vap->va_atime = ntfs_nttimetounix(fp->f_times.t_access);
- vap->va_mtime = ntfs_nttimetounix(fp->f_times.t_write);
- vap->va_ctime = ntfs_nttimetounix(fp->f_times.t_create);
- vap->va_flags = ip->i_flag;
- vap->va_gen = 0;
- vap->va_blocksize = ip->i_mp->ntm_spc * ip->i_mp->ntm_bps;
- vap->va_type = vp->v_type;
- vap->va_filerev = 0;
- return (0);
-}
-
-
-/*
- * Last reference to an ntnode. If necessary, write or delete it.
- */
-int
-ntfs_inactive(ap)
- struct vop_inactive_args /* {
- struct vnode *a_vp;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
-#ifdef NTFS_DEBUG
- register struct ntnode *ip = VTONT(vp);
-#endif
-
- dprintf(("ntfs_inactive: vnode: %p, ntnode: %d\n", vp, ip->i_number));
-
- if (ntfs_prtactive && vp->v_usecount != 0)
- vprint("ntfs_inactive: pushing active", vp);
-
- VOP__UNLOCK(vp, 0, ap->a_p);
-
- /* XXX since we don't support any filesystem changes
- * right now, nothing more needs to be done
- */
- return (0);
-}
-
-/*
- * Reclaim an fnode/ntnode so that it can be used for other purposes.
- */
-int
-ntfs_reclaim(ap)
- struct vop_reclaim_args /* {
- struct vnode *a_vp;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
- register struct fnode *fp = VTOF(vp);
- register struct ntnode *ip = FTONT(fp);
- int error;
-
- dprintf(("ntfs_reclaim: vnode: %p, ntnode: %d\n", vp, ip->i_number));
-
- if (ntfs_prtactive && vp->v_usecount != 0)
- vprint("ntfs_reclaim: pushing active", vp);
-
- if ((error = ntfs_ntget(ip)) != 0)
- return (error);
-
- /* Purge old data structures associated with the inode. */
- cache_purge(vp);
- if (ip->i_devvp) {
- vrele(ip->i_devvp);
- ip->i_devvp = NULL;
- }
-
- ntfs_frele(fp);
- ntfs_ntput(ip);
- vp->v_data = NULL;
-
- return (0);
-}
-
-static int
-ntfs_print(ap)
- struct vop_print_args /* {
- struct vnode *a_vp;
- } */ *ap;
-{
- return (0);
-}
-
-/*
- * Calculate the logical to physical mapping if not done already,
- * then call the device strategy routine.
- */
-int
-ntfs_strategy(ap)
- struct vop_strategy_args /* {
- struct buf *a_bp;
- } */ *ap;
-{
- register struct buf *bp = ap->a_bp;
- register struct vnode *vp = bp->b_vp;
- register struct fnode *fp = VTOF(vp);
- register struct ntnode *ip = FTONT(fp);
- struct ntfsmount *ntmp = ip->i_mp;
- int error;
-
-#ifdef __FreeBSD__
- dprintf(("ntfs_strategy: offset: %d, blkno: %d, lblkno: %d\n",
- (u_int32_t)bp->b_offset,(u_int32_t)bp->b_blkno,
- (u_int32_t)bp->b_lblkno));
-#else
- dprintf(("ntfs_strategy: blkno: %d, lblkno: %d\n",
- (u_int32_t)bp->b_blkno,
- (u_int32_t)bp->b_lblkno));
-#endif
-
- dprintf(("strategy: bcount: %d flags: 0x%lx\n",
- (u_int32_t)bp->b_bcount,bp->b_flags));
-
- if (bp->b_flags & B_READ) {
- u_int32_t toread;
-
- if (ntfs_cntob(bp->b_blkno) >= fp->f_size) {
- clrbuf(bp);
- error = 0;
- } else {
- toread = min(bp->b_bcount,
- fp->f_size-ntfs_cntob(bp->b_blkno));
- dprintf(("ntfs_strategy: toread: %d, fsize: %d\n",
- toread,(u_int32_t)fp->f_size));
-
- error = ntfs_readattr(ntmp, ip, fp->f_attrtype,
- fp->f_attrname, ntfs_cntob(bp->b_blkno),
- toread, bp->b_data, NULL);
-
- if (error) {
- printf("ntfs_strategy: ntfs_readattr failed\n");
- bp->b_error = error;
- bp->b_flags |= B_ERROR;
- }
-
- bzero(bp->b_data + toread, bp->b_bcount - toread);
- }
- } else {
- size_t tmp;
- u_int32_t towrite;
-
- if (ntfs_cntob(bp->b_blkno) + bp->b_bcount >= fp->f_size) {
- printf("ntfs_strategy: CAN'T EXTEND FILE\n");
- bp->b_error = error = EFBIG;
- bp->b_flags |= B_ERROR;
- } else {
- towrite = min(bp->b_bcount,
- fp->f_size-ntfs_cntob(bp->b_blkno));
- dprintf(("ntfs_strategy: towrite: %d, fsize: %d\n",
- towrite,(u_int32_t)fp->f_size));
-
- error = ntfs_writeattr_plain(ntmp, ip, fp->f_attrtype,
- fp->f_attrname, ntfs_cntob(bp->b_blkno),towrite,
- bp->b_data, &tmp, NULL);
-
- if (error) {
- printf("ntfs_strategy: ntfs_writeattr fail\n");
- bp->b_error = error;
- bp->b_flags |= B_ERROR;
- }
- }
- }
- biodone(bp);
- return (error);
-}
-
-static int
-ntfs_write(ap)
- struct vop_write_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- int a_ioflag;
- struct ucred *a_cred;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
- register struct fnode *fp = VTOF(vp);
- register struct ntnode *ip = FTONT(fp);
- struct uio *uio = ap->a_uio;
- struct ntfsmount *ntmp = ip->i_mp;
- u_int64_t towrite;
- size_t written;
- int error;
-
- dprintf(("ntfs_write: ino: %d, off: %d resid: %d, segflg: %d\n",ip->i_number,(u_int32_t)uio->uio_offset,uio->uio_resid,uio->uio_segflg));
- dprintf(("ntfs_write: filesize: %d",(u_int32_t)fp->f_size));
-
- if (uio->uio_resid + uio->uio_offset > fp->f_size) {
- printf("ntfs_write: CAN'T WRITE BEYOND END OF FILE\n");
- return (EFBIG);
- }
-
- towrite = min(uio->uio_resid, fp->f_size - uio->uio_offset);
-
- dprintf((", towrite: %d\n",(u_int32_t)towrite));
-
- error = ntfs_writeattr_plain(ntmp, ip, fp->f_attrtype,
- fp->f_attrname, uio->uio_offset, towrite, NULL, &written, uio);
-#ifdef NTFS_DEBUG
- if (error)
- printf("ntfs_write: ntfs_writeattr failed: %d\n", error);
-#endif
-
- return (error);
-}
-
-int
-ntfs_access(ap)
- struct vop_access_args /* {
- struct vnode *a_vp;
- int a_mode;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
- struct ntnode *ip = VTONT(vp);
- struct ucred *cred = ap->a_cred;
- mode_t mask, mode = ap->a_mode;
- register gid_t *gp;
- int i;
-#ifdef QUOTA
- int error;
-#endif
-
- dprintf(("ntfs_access: %d\n",ip->i_number));
-
- /*
- * Disallow write attempts on read-only file systems;
- * unless the file is a socket, fifo, or a block or
- * character device resident on the file system.
- */
- if (mode & VWRITE) {
- switch ((int)vp->v_type) {
- case VDIR:
- case VLNK:
- case VREG:
- if (vp->v_mount->mnt_flag & MNT_RDONLY)
- return (EROFS);
-#ifdef QUOTA
- if (error = getinoquota(ip))
- return (error);
-#endif
- break;
- }
- }
-
- /* Otherwise, user id 0 always gets access. */
- if (cred->cr_uid == 0)
- return (0);
-
- mask = 0;
-
- /* Otherwise, check the owner. */
- if (cred->cr_uid == ip->i_mp->ntm_uid) {
- if (mode & VEXEC)
- mask |= S_IXUSR;
- if (mode & VREAD)
- mask |= S_IRUSR;
- if (mode & VWRITE)
- mask |= S_IWUSR;
- return ((ip->i_mp->ntm_mode & mask) == mask ? 0 : EACCES);
- }
-
- /* Otherwise, check the groups. */
- for (i = 0, gp = cred->cr_groups; i < cred->cr_ngroups; i++, gp++)
- if (ip->i_mp->ntm_gid == *gp) {
- if (mode & VEXEC)
- mask |= S_IXGRP;
- if (mode & VREAD)
- mask |= S_IRGRP;
- if (mode & VWRITE)
- mask |= S_IWGRP;
- return ((ip->i_mp->ntm_mode&mask) == mask ? 0 : EACCES);
- }
-
- /* Otherwise, check everyone else. */
- if (mode & VEXEC)
- mask |= S_IXOTH;
- if (mode & VREAD)
- mask |= S_IROTH;
- if (mode & VWRITE)
- mask |= S_IWOTH;
- return ((ip->i_mp->ntm_mode & mask) == mask ? 0 : EACCES);
-}
-
-/*
- * Open called.
- *
- * Nothing to do.
- */
-/* ARGSUSED */
-static int
-ntfs_open(ap)
- struct vop_open_args /* {
- struct vnode *a_vp;
- int a_mode;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
-#if NTFS_DEBUG
- register struct vnode *vp = ap->a_vp;
- register struct ntnode *ip = VTONT(vp);
-
- printf("ntfs_open: %d\n",ip->i_number);
-#endif
-
- /*
- * Files marked append-only must be opened for appending.
- */
-
- return (0);
-}
-
-/*
- * Close called.
- *
- * Update the times on the inode.
- */
-/* ARGSUSED */
-static int
-ntfs_close(ap)
- struct vop_close_args /* {
- struct vnode *a_vp;
- int a_fflag;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
-#if NTFS_DEBUG
- register struct vnode *vp = ap->a_vp;
- register struct ntnode *ip = VTONT(vp);
-
- printf("ntfs_close: %d\n",ip->i_number);
-#endif
-
- return (0);
-}
-
-int
-ntfs_readdir(ap)
- struct vop_readdir_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- struct ucred *a_cred;
- int *a_ncookies;
- u_int **cookies;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
- register struct fnode *fp = VTOF(vp);
- register struct ntnode *ip = FTONT(fp);
- struct uio *uio = ap->a_uio;
- struct ntfsmount *ntmp = ip->i_mp;
- int i, error = 0;
- u_int32_t faked = 0, num;
- int ncookies = 0;
- struct dirent cde;
- off_t off;
-
- dprintf(("ntfs_readdir %d off: %d resid: %d\n",ip->i_number,(u_int32_t)uio->uio_offset,uio->uio_resid));
-
- off = uio->uio_offset;
-
- /* Simulate . in every dir except ROOT */
- if( ip->i_number != NTFS_ROOTINO ) {
- struct dirent dot = { NTFS_ROOTINO,
- sizeof(struct dirent), DT_DIR, 1, "." };
-
- if( uio->uio_offset < sizeof(struct dirent) ) {
- dot.d_fileno = ip->i_number;
- error = uiomove((char *)&dot,sizeof(struct dirent),uio);
- if(error)
- return (error);
-
- ncookies ++;
- }
- }
-
- /* Simulate .. in every dir including ROOT */
- if( uio->uio_offset < 2 * sizeof(struct dirent) ) {
- struct dirent dotdot = { NTFS_ROOTINO,
- sizeof(struct dirent), DT_DIR, 2, ".." };
-
- error = uiomove((char *)&dotdot,sizeof(struct dirent),uio);
- if(error)
- return (error);
-
- ncookies ++;
- }
-
- faked = (ip->i_number == NTFS_ROOTINO) ? 1 : 2;
- num = uio->uio_offset / sizeof(struct dirent) - faked;
-
- while( uio->uio_resid >= sizeof(struct dirent) ) {
- struct attr_indexentry *iep;
-
- error = ntfs_ntreaddir(ntmp, fp, num, &iep);
-
- if(error)
- return (error);
-
- if( NULL == iep )
- break;
-
- for(; !(iep->ie_flag & NTFS_IEFLAG_LAST) && (uio->uio_resid >= sizeof(struct dirent));
- iep = NTFS_NEXTREC(iep, struct attr_indexentry *))
- {
- if(!ntfs_isnamepermitted(ntmp,iep))
- continue;
-
- for(i=0; i<iep->ie_fnamelen; i++) {
- cde.d_name[i] = ntfs_u28(iep->ie_fname[i]);
- }
- cde.d_name[i] = '\0';
- dprintf(("ntfs_readdir: elem: %d, fname:[%s] type: %d, flag: %d, ",
- num, cde.d_name, iep->ie_fnametype,
- iep->ie_flag));
- cde.d_namlen = iep->ie_fnamelen;
- cde.d_fileno = iep->ie_number;
- cde.d_type = (iep->ie_fflag & NTFS_FFLAG_DIR) ? DT_DIR : DT_REG;
- cde.d_reclen = sizeof(struct dirent);
- dprintf(("%s\n", (cde.d_type == DT_DIR) ? "dir":"reg"));
-
- error = uiomove((char *)&cde, sizeof(struct dirent), uio);
- if(error)
- return (error);
-
- ncookies++;
- num++;
- }
- }
-
- dprintf(("ntfs_readdir: %d entries (%d bytes) read\n",
- ncookies,(u_int)(uio->uio_offset - off)));
- dprintf(("ntfs_readdir: off: %d resid: %d\n",
- (u_int32_t)uio->uio_offset,uio->uio_resid));
-
- if (!error && ap->a_ncookies != NULL) {
- struct dirent* dpStart;
- struct dirent* dp;
-#if defined(__FreeBSD__)
- u_long *cookies;
- u_long *cookiep;
-#else /* defined(__NetBSD__) */
- off_t *cookies;
- off_t *cookiep;
-#endif
-
- ddprintf(("ntfs_readdir: %d cookies\n",ncookies));
- if (uio->uio_segflg != UIO_SYSSPACE || uio->uio_iovcnt != 1)
- panic("ntfs_readdir: unexpected uio from NFS server");
- dpStart = (struct dirent *)
- ((caddr_t)uio->uio_iov->iov_base -
- (uio->uio_offset - off));
-#if defined(__FreeBSD__)
- MALLOC(cookies, u_long *, ncookies * sizeof(u_long),
- M_TEMP, M_WAITOK);
-#else /* defined(__NetBSD__) */
- MALLOC(cookies, off_t *, ncookies * sizeof(off_t),
- M_TEMP, M_WAITOK);
-#endif
- for (dp = dpStart, cookiep = cookies, i=0;
- i < ncookies;
- dp = (struct dirent *)((caddr_t) dp + dp->d_reclen), i++) {
- off += dp->d_reclen;
- *cookiep++ = (u_int) off;
- }
- *ap->a_ncookies = ncookies;
- *ap->a_cookies = cookies;
- }
-/*
- if (ap->a_eofflag)
- *ap->a_eofflag = VTONT(ap->a_vp)->i_size <= uio->uio_offset;
-*/
- return (error);
-}
-
-int
-ntfs_lookup(ap)
- struct vop_lookup_args /* {
- struct vnode *a_dvp;
- struct vnode **a_vpp;
- struct componentname *a_cnp;
- } */ *ap;
-{
- register struct vnode *dvp = ap->a_dvp;
- register struct ntnode *dip = VTONT(dvp);
- struct ntfsmount *ntmp = dip->i_mp;
- struct componentname *cnp = ap->a_cnp;
- struct ucred *cred = cnp->cn_cred;
- int error;
- int lockparent = cnp->cn_flags & LOCKPARENT;
-#if NTFS_DEBUG
- int wantparent = cnp->cn_flags & (LOCKPARENT|WANTPARENT);
-#endif
- dprintf(("ntfs_lookup: \"%.*s\" (%ld bytes) in %d, lp: %d, wp: %d \n",
- (int)cnp->cn_namelen, cnp->cn_nameptr, cnp->cn_namelen,
- dip->i_number, lockparent, wantparent));
-
- error = VOP_ACCESS(dvp, VEXEC, cred, cnp->cn_proc);
- if(error)
- return (error);
-
- if ((cnp->cn_flags & ISLASTCN) &&
- (dvp->v_mount->mnt_flag & MNT_RDONLY) &&
- (cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME))
- return (EROFS);
-
-#ifdef __NetBSD__
- /*
- * We now have a segment name to search for, and a directory
- * to search.
- *
- * Before tediously performing a linear scan of the directory,
- * check the name cache to see if the directory/name pair
- * we are looking for is known already.
- */
- if ((error = cache_lookup(ap->a_dvp, ap->a_vpp, cnp)) >= 0)
- return (error);
-#endif
-
- if(cnp->cn_namelen == 1 && cnp->cn_nameptr[0] == '.') {
- dprintf(("ntfs_lookup: faking . directory in %d\n",
- dip->i_number));
-
- VREF(dvp);
- *ap->a_vpp = dvp;
- error = 0;
- } else if (cnp->cn_flags & ISDOTDOT) {
- struct ntvattr *vap;
-
- dprintf(("ntfs_lookup: faking .. directory in %d\n",
- dip->i_number));
-
- error = ntfs_ntvattrget(ntmp, dip, NTFS_A_NAME, NULL, 0, &vap);
- if(error)
- return (error);
-
- VOP__UNLOCK(dvp,0,cnp->cn_proc);
- cnp->cn_flags |= PDIRUNLOCK;
-
- dprintf(("ntfs_lookup: parentdir: %d\n",
- vap->va_a_name->n_pnumber));
- error = VFS_VGET(ntmp->ntm_mountp,
- vap->va_a_name->n_pnumber,ap->a_vpp);
- ntfs_ntvattrrele(vap);
- if (error) {
- if (VN_LOCK(dvp,LK_EXCLUSIVE|LK_RETRY,cnp->cn_proc)==0)
- cnp->cn_flags &= ~PDIRUNLOCK;
- return (error);
- }
-
- if (lockparent && (cnp->cn_flags & ISLASTCN)) {
- error = VN_LOCK(dvp, LK_EXCLUSIVE, cnp->cn_proc);
- if (error) {
- vput( *(ap->a_vpp) );
- return (error);
- }
- cnp->cn_flags &= ~PDIRUNLOCK;
- }
- } else {
- error = ntfs_ntlookupfile(ntmp, dvp, cnp, ap->a_vpp);
- if (error) {
- dprintf(("ntfs_ntlookupfile: returned %d\n", error));
- return (error);
- }
-
- dprintf(("ntfs_lookup: found ino: %d\n",
- VTONT(*ap->a_vpp)->i_number));
-
- if(!lockparent || !(cnp->cn_flags & ISLASTCN))
- VOP__UNLOCK(dvp, 0, cnp->cn_proc);
- }
-
- if (cnp->cn_flags & MAKEENTRY)
- cache_enter(dvp, *ap->a_vpp, cnp);
-
- return (error);
-}
-
-#if defined(__FreeBSD__)
-/*
- * Flush the blocks of a file to disk.
- *
- * This function is worthless for vnodes that represent directories. Maybe we
- * could just do a sync if they try an fsync on a directory file.
- */
-static int
-ntfs_fsync(ap)
- struct vop_fsync_args /* {
- struct vnode *a_vp;
- struct ucred *a_cred;
- int a_waitfor;
- struct proc *a_p;
- } */ *ap;
-{
- return (0);
-}
-#endif
-
-/*
- * Return POSIX pathconf information applicable to NTFS filesystem
- */
-int
-ntfs_pathconf(v)
- void *v;
-{
- struct vop_pathconf_args /* {
- struct vnode *a_vp;
- int a_name;
- register_t *a_retval;
- } */ *ap = v;
-
- switch (ap->a_name) {
- case _PC_LINK_MAX:
- *ap->a_retval = 1;
- return (0);
- case _PC_NAME_MAX:
- *ap->a_retval = NTFS_MAXFILENAME;
- return (0);
- case _PC_PATH_MAX:
- *ap->a_retval = PATH_MAX;
- return (0);
- case _PC_CHOWN_RESTRICTED:
- *ap->a_retval = 1;
- return (0);
- case _PC_NO_TRUNC:
- *ap->a_retval = 0;
- return (0);
-#if defined(__NetBSD__)
- case _PC_SYNC_IO:
- *ap->a_retval = 1;
- return (0);
- case _PC_FILESIZEBITS:
- *ap->a_retval = 64;
- return (0);
-#endif
- default:
- return (EINVAL);
- }
- /* NOTREACHED */
-}
-
-/*
- * Global vfs data structures
- */
-vop_t **ntfs_vnodeop_p;
-#if defined(__FreeBSD__)
-static
-struct vnodeopv_entry_desc ntfs_vnodeop_entries[] = {
- { &vop_default_desc, (vop_t *)ntfs_bypass },
-
- { &vop_getattr_desc, (vop_t *)ntfs_getattr },
- { &vop_inactive_desc, (vop_t *)ntfs_inactive },
- { &vop_reclaim_desc, (vop_t *)ntfs_reclaim },
- { &vop_print_desc, (vop_t *)ntfs_print },
- { &vop_pathconf_desc, ntfs_pathconf },
-
- { &vop_islocked_desc, (vop_t *)vop_stdislocked },
- { &vop_unlock_desc, (vop_t *)vop_stdunlock },
- { &vop_lock_desc, (vop_t *)vop_stdlock },
- { &vop_cachedlookup_desc, (vop_t *)ntfs_lookup },
- { &vop_lookup_desc, (vop_t *)vfs_cache_lookup },
-
- { &vop_access_desc, (vop_t *)ntfs_access },
- { &vop_close_desc, (vop_t *)ntfs_close },
- { &vop_open_desc, (vop_t *)ntfs_open },
- { &vop_readdir_desc, (vop_t *)ntfs_readdir },
- { &vop_fsync_desc, (vop_t *)ntfs_fsync },
-
- { &vop_bmap_desc, (vop_t *)ntfs_bmap },
- { &vop_getpages_desc, (vop_t *) ntfs_getpages },
- { &vop_putpages_desc, (vop_t *) ntfs_putpages },
- { &vop_strategy_desc, (vop_t *)ntfs_strategy },
- { &vop_bwrite_desc, (vop_t *)vop_stdbwrite },
- { &vop_read_desc, (vop_t *)ntfs_read },
- { &vop_write_desc, (vop_t *)ntfs_write },
-
- { NULL, NULL }
-};
-
-static
-struct vnodeopv_desc ntfs_vnodeop_opv_desc =
- { &ntfs_vnodeop_p, ntfs_vnodeop_entries };
-
-VNODEOP_SET(ntfs_vnodeop_opv_desc);
-
-#else /* !FreeBSD */
-
-struct vnodeopv_entry_desc ntfs_vnodeop_entries[] = {
- { &vop_default_desc, (vop_t *) ntfs_bypass },
- { &vop_lookup_desc, (vop_t *) ntfs_lookup }, /* lookup */
- { &vop_create_desc, genfs_eopnotsupp }, /* create */
- { &vop_mknod_desc, genfs_eopnotsupp }, /* mknod */
- { &vop_open_desc, (vop_t *) ntfs_open }, /* open */
- { &vop_close_desc,(vop_t *) ntfs_close }, /* close */
- { &vop_access_desc, (vop_t *) ntfs_access }, /* access */
- { &vop_getattr_desc, (vop_t *) ntfs_getattr }, /* getattr */
- { &vop_setattr_desc, genfs_eopnotsupp }, /* setattr */
- { &vop_read_desc, (vop_t *) ntfs_read }, /* read */
- { &vop_write_desc, (vop_t *) ntfs_write }, /* write */
- { &vop_lease_desc, genfs_lease_check }, /* lease */
- { &vop_fcntl_desc, genfs_fcntl }, /* fcntl */
- { &vop_ioctl_desc, genfs_enoioctl }, /* ioctl */
- { &vop_poll_desc, genfs_poll }, /* poll */
- { &vop_revoke_desc, genfs_revoke }, /* revoke */
- { &vop_mmap_desc, genfs_eopnotsupp }, /* mmap */
- { &vop_fsync_desc, genfs_fsync }, /* fsync */
- { &vop_seek_desc, genfs_seek }, /* seek */
- { &vop_remove_desc, genfs_eopnotsupp }, /* remove */
- { &vop_link_desc, genfs_eopnotsupp }, /* link */
- { &vop_rename_desc, genfs_eopnotsupp }, /* rename */
- { &vop_mkdir_desc, genfs_eopnotsupp }, /* mkdir */
- { &vop_rmdir_desc, genfs_eopnotsupp }, /* rmdir */
- { &vop_symlink_desc, genfs_eopnotsupp }, /* symlink */
- { &vop_readdir_desc, (vop_t *) ntfs_readdir }, /* readdir */
- { &vop_readlink_desc, genfs_eopnotsupp }, /* readlink */
- { &vop_abortop_desc, genfs_abortop }, /* abortop */
- { &vop_inactive_desc, (vop_t *) ntfs_inactive }, /* inactive */
- { &vop_reclaim_desc, (vop_t *) ntfs_reclaim }, /* reclaim */
- { &vop_lock_desc, genfs_lock }, /* lock */
- { &vop_unlock_desc, genfs_unlock }, /* unlock */
- { &vop_bmap_desc, (vop_t *) ntfs_bmap }, /* bmap */
- { &vop_strategy_desc, (vop_t *) ntfs_strategy }, /* strategy */
- { &vop_print_desc, (vop_t *) ntfs_print }, /* print */
- { &vop_islocked_desc, genfs_islocked }, /* islocked */
- { &vop_pathconf_desc, ntfs_pathconf }, /* pathconf */
- { &vop_advlock_desc, genfs_nullop }, /* advlock */
- { &vop_blkatoff_desc, genfs_eopnotsupp }, /* blkatoff */
- { &vop_valloc_desc, genfs_eopnotsupp }, /* valloc */
- { &vop_reallocblks_desc, genfs_eopnotsupp }, /* reallocblks */
- { &vop_vfree_desc, genfs_eopnotsupp }, /* vfree */
- { &vop_truncate_desc, genfs_eopnotsupp }, /* truncate */
- { &vop_update_desc, genfs_eopnotsupp }, /* update */
- { &vop_bwrite_desc, vn_bwrite }, /* bwrite */
- { (struct vnodeop_desc *)NULL, (int (*) __P((void *)))NULL }
-};
-struct vnodeopv_desc ntfs_vnodeop_opv_desc =
- { &ntfs_vnodeop_p, ntfs_vnodeop_entries };
-
-#endif
diff --git a/sys/fs/ntfs/ntfsmount.h b/sys/fs/ntfs/ntfsmount.h
deleted file mode 100644
index f3a6d25a0421..000000000000
--- a/sys/fs/ntfs/ntfsmount.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* $NetBSD: ntfsmount.h,v 1.3 1999/07/26 14:02:32 jdolecek Exp $ */
-
-/*-
- * Copyright (c) 1998, 1999 Semen Ustimenko
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#define NTFS_MFLAG_CASEINS 0x00000001
-#define NTFS_MFLAG_ALLNAMES 0x00000002
-
-struct ntfs_args {
- char *fspec; /* block special device to mount */
- struct export_args export; /* network export information */
- uid_t uid; /* uid that owns ntfs files */
- gid_t gid; /* gid that owns ntfs files */
- mode_t mode; /* mask to be applied for ntfs perms */
- u_long flag; /* additional flags */
-};
diff --git a/sys/fs/nullfs/null.h b/sys/fs/nullfs/null.h
deleted file mode 100644
index 2b7ed51d2427..000000000000
--- a/sys/fs/nullfs/null.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)null.h 8.3 (Berkeley) 8/20/94
- *
- * $FreeBSD$
- */
-
-struct null_args {
- char *target; /* Target of loopback */
-};
-
-struct null_mount {
- struct mount *nullm_vfs;
- struct vnode *nullm_rootvp; /* Reference to root null_node */
-};
-
-#ifdef _KERNEL
-/*
- * A cache of vnode references
- */
-struct null_node {
- LIST_ENTRY(null_node) null_hash; /* Hash list */
- struct vnode *null_lowervp; /* VREFed once */
- struct vnode *null_vnode; /* Back pointer */
-};
-
-extern int nullfs_init __P((struct vfsconf *vfsp));
-extern int null_node_create __P((struct mount *mp, struct vnode *target, struct vnode **vpp));
-
-#define MOUNTTONULLMOUNT(mp) ((struct null_mount *)((mp)->mnt_data))
-#define VTONULL(vp) ((struct null_node *)(vp)->v_data)
-#define NULLTOV(xp) ((xp)->null_vnode)
-#ifdef DIAGNOSTIC
-extern struct vnode *null_checkvp __P((struct vnode *vp, char *fil, int lno));
-#define NULLVPTOLOWERVP(vp) null_checkvp((vp), __FILE__, __LINE__)
-#else
-#define NULLVPTOLOWERVP(vp) (VTONULL(vp)->null_lowervp)
-#endif
-
-extern int null_bypass __P((struct vop_generic_args *ap));
-
-extern vop_t **null_vnodeop_p;
-#endif /* _KERNEL */
diff --git a/sys/fs/nullfs/null_subr.c b/sys/fs/nullfs/null_subr.c
deleted file mode 100644
index ad37a1ef4788..000000000000
--- a/sys/fs/nullfs/null_subr.c
+++ /dev/null
@@ -1,301 +0,0 @@
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)null_subr.c 8.7 (Berkeley) 5/14/95
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/proc.h>
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <sys/malloc.h>
-#include <miscfs/nullfs/null.h>
-
-#define LOG2_SIZEVNODE 7 /* log2(sizeof struct vnode) */
-#define NNULLNODECACHE 16
-
-/*
- * Null layer cache:
- * Each cache entry holds a reference to the lower vnode
- * along with a pointer to the alias vnode. When an
- * entry is added the lower vnode is VREF'd. When the
- * alias is removed the lower vnode is vrele'd.
- */
-
-#define NULL_NHASH(vp) \
- (&null_node_hashtbl[(((uintptr_t)vp)>>LOG2_SIZEVNODE) & null_node_hash])
-static LIST_HEAD(null_node_hashhead, null_node) *null_node_hashtbl;
-static u_long null_node_hash;
-
-static int null_node_alloc __P((struct mount *mp, struct vnode *lowervp,
- struct vnode **vpp));
-static struct vnode *
- null_node_find __P((struct mount *mp, struct vnode *lowervp));
-
-/*
- * Initialise cache headers
- */
-int
-nullfs_init(vfsp)
- struct vfsconf *vfsp;
-{
-
-#ifdef DEBUG
- printf("nullfs_init\n"); /* printed during system boot */
-#endif
- null_node_hashtbl = hashinit(NNULLNODECACHE, M_CACHE, &null_node_hash);
- return (0);
-}
-
-/*
- * Return a VREF'ed alias for lower vnode if already exists, else 0.
- */
-static struct vnode *
-null_node_find(mp, lowervp)
- struct mount *mp;
- struct vnode *lowervp;
-{
- struct proc *p = curproc; /* XXX */
- struct null_node_hashhead *hd;
- struct null_node *a;
- struct vnode *vp;
-
- /*
- * Find hash base, and then search the (two-way) linked
- * list looking for a null_node structure which is referencing
- * the lower vnode. If found, the increment the null_node
- * reference count (but NOT the lower vnode's VREF counter).
- */
- hd = NULL_NHASH(lowervp);
-loop:
- for (a = hd->lh_first; a != 0; a = a->null_hash.le_next) {
- if (a->null_lowervp == lowervp && NULLTOV(a)->v_mount == mp) {
- vp = NULLTOV(a);
- /*
- * We need vget for the VXLOCK
- * stuff, but we don't want to lock
- * the lower node.
- */
- if (vget(vp, 0, p)) {
- printf ("null_node_find: vget failed.\n");
- goto loop;
- };
- return (vp);
- }
- }
-
- return NULLVP;
-}
-
-
-/*
- * Make a new null_node node.
- * Vp is the alias vnode, lofsvp is the lower vnode.
- * Maintain a reference to (lowervp).
- */
-static int
-null_node_alloc(mp, lowervp, vpp)
- struct mount *mp;
- struct vnode *lowervp;
- struct vnode **vpp;
-{
- struct null_node_hashhead *hd;
- struct null_node *xp;
- struct vnode *othervp, *vp;
- int error;
-
- /*
- * Do the MALLOC before the getnewvnode since doing so afterward
- * might cause a bogus v_data pointer to get dereferenced
- * elsewhere if MALLOC should block.
- */
- MALLOC(xp, struct null_node *, sizeof(struct null_node), M_TEMP, M_WAITOK);
-
- error = getnewvnode(VT_NULL, mp, null_vnodeop_p, vpp);
- if (error) {
- FREE(xp, M_TEMP);
- return (error);
- }
- vp = *vpp;
-
- vp->v_type = lowervp->v_type;
- xp->null_vnode = vp;
- vp->v_data = xp;
- xp->null_lowervp = lowervp;
- /*
- * Before we insert our new node onto the hash chains,
- * check to see if someone else has beaten us to it.
- * (We could have slept in MALLOC.)
- */
- othervp = null_node_find(mp, lowervp);
- if (othervp) {
- FREE(xp, M_TEMP);
- vp->v_type = VBAD; /* node is discarded */
- vp->v_usecount = 0; /* XXX */
- *vpp = othervp;
- return 0;
- };
- VREF(lowervp); /* Extra VREF will be vrele'd in null_node_create */
- hd = NULL_NHASH(lowervp);
- LIST_INSERT_HEAD(hd, xp, null_hash);
- return 0;
-}
-
-
-/*
- * Try to find an existing null_node vnode refering
- * to it, otherwise make a new null_node vnode which
- * contains a reference to the lower vnode.
- */
-int
-null_node_create(mp, lowervp, newvpp)
- struct mount *mp;
- struct vnode *lowervp;
- struct vnode **newvpp;
-{
- struct vnode *aliasvp;
-
- aliasvp = null_node_find(mp, lowervp);
- if (aliasvp) {
- /*
- * null_node_find has taken another reference
- * to the alias vnode.
- */
-#ifdef DEBUG
- vprint("null_node_create: exists", aliasvp);
-#endif
- /* VREF(aliasvp); --- done in null_node_find */
- } else {
- int error;
-
- /*
- * Get new vnode.
- */
-#ifdef DEBUG
- printf("null_node_create: create new alias vnode\n");
-#endif
-
- /*
- * Make new vnode reference the null_node.
- */
- error = null_node_alloc(mp, lowervp, &aliasvp);
- if (error)
- return error;
-
- /*
- * aliasvp is already VREF'd by getnewvnode()
- */
- }
-
- vrele(lowervp);
-
-#ifdef DIAGNOSTIC
- if (lowervp->v_usecount < 1) {
- /* Should never happen... */
- vprint ("null_node_create: alias ", aliasvp);
- vprint ("null_node_create: lower ", lowervp);
- panic ("null_node_create: lower has 0 usecount.");
- };
-#endif
-
-#ifdef DEBUG
- vprint("null_node_create: alias", aliasvp);
- vprint("null_node_create: lower", lowervp);
-#endif
-
- *newvpp = aliasvp;
- return (0);
-}
-
-#ifdef DIAGNOSTIC
-#include "opt_ddb.h"
-
-#ifdef DDB
-#define null_checkvp_barrier 1
-#else
-#define null_checkvp_barrier 0
-#endif
-
-struct vnode *
-null_checkvp(vp, fil, lno)
- struct vnode *vp;
- char *fil;
- int lno;
-{
- struct null_node *a = VTONULL(vp);
-#ifdef notyet
- /*
- * Can't do this check because vop_reclaim runs
- * with a funny vop vector.
- */
- if (vp->v_op != null_vnodeop_p) {
- printf ("null_checkvp: on non-null-node\n");
- while (null_checkvp_barrier) /*WAIT*/ ;
- panic("null_checkvp");
- };
-#endif
- if (a->null_lowervp == NULLVP) {
- /* Should never happen */
- int i; u_long *p;
- printf("vp = %p, ZERO ptr\n", (void *)vp);
- for (p = (u_long *) a, i = 0; i < 8; i++)
- printf(" %lx", p[i]);
- printf("\n");
- /* wait for debugger */
- while (null_checkvp_barrier) /*WAIT*/ ;
- panic("null_checkvp");
- }
- if (a->null_lowervp->v_usecount < 1) {
- int i; u_long *p;
- printf("vp = %p, unref'ed lowervp\n", (void *)vp);
- for (p = (u_long *) a, i = 0; i < 8; i++)
- printf(" %lx", p[i]);
- printf("\n");
- /* wait for debugger */
- while (null_checkvp_barrier) /*WAIT*/ ;
- panic ("null with unref'ed lowervp");
- };
-#ifdef notyet
- printf("null %x/%d -> %x/%d [%s, %d]\n",
- NULLTOV(a), NULLTOV(a)->v_usecount,
- a->null_lowervp, a->null_lowervp->v_usecount,
- fil, lno);
-#endif
- return a->null_lowervp;
-}
-#endif
diff --git a/sys/fs/nullfs/null_vfsops.c b/sys/fs/nullfs/null_vfsops.c
deleted file mode 100644
index a865cce05300..000000000000
--- a/sys/fs/nullfs/null_vfsops.c
+++ /dev/null
@@ -1,450 +0,0 @@
-/*
- * Copyright (c) 1992, 1993, 1995
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)null_vfsops.c 8.2 (Berkeley) 1/21/94
- *
- * @(#)lofs_vfsops.c 1.2 (Berkeley) 6/18/92
- * $FreeBSD$
- */
-
-/*
- * Null Layer
- * (See null_vnops.c for a description of what this does.)
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/proc.h>
-#include <sys/malloc.h>
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <sys/namei.h>
-#include <miscfs/nullfs/null.h>
-#include <vm/vm_zone.h>
-
-static MALLOC_DEFINE(M_NULLFSMNT, "NULLFS mount", "NULLFS mount structure");
-
-static int nullfs_fhtovp __P((struct mount *mp, struct fid *fidp,
- struct vnode **vpp));
-static int nullfs_checkexp __P((struct mount *mp, struct sockaddr *nam,
- int *extflagsp, struct ucred **credanonp));
-static int nullfs_mount __P((struct mount *mp, char *path, caddr_t data,
- struct nameidata *ndp, struct proc *p));
-static int nullfs_quotactl __P((struct mount *mp, int cmd, uid_t uid,
- caddr_t arg, struct proc *p));
-static int nullfs_root __P((struct mount *mp, struct vnode **vpp));
-static int nullfs_start __P((struct mount *mp, int flags, struct proc *p));
-static int nullfs_statfs __P((struct mount *mp, struct statfs *sbp,
- struct proc *p));
-static int nullfs_sync __P((struct mount *mp, int waitfor,
- struct ucred *cred, struct proc *p));
-static int nullfs_unmount __P((struct mount *mp, int mntflags,
- struct proc *p));
-static int nullfs_vget __P((struct mount *mp, ino_t ino,
- struct vnode **vpp));
-static int nullfs_vptofh __P((struct vnode *vp, struct fid *fhp));
-
-/*
- * Mount null layer
- */
-static int
-nullfs_mount(mp, path, data, ndp, p)
- struct mount *mp;
- char *path;
- caddr_t data;
- struct nameidata *ndp;
- struct proc *p;
-{
- int error = 0;
- struct null_args args;
- struct vnode *lowerrootvp, *vp;
- struct vnode *nullm_rootvp;
- struct null_mount *xmp;
- u_int size;
- int isvnunlocked = 0;
-
-#ifdef DEBUG
- printf("nullfs_mount(mp = %p)\n", (void *)mp);
-#endif
-
- /*
- * Update is a no-op
- */
- if (mp->mnt_flag & MNT_UPDATE) {
- return (EOPNOTSUPP);
- /* return VFS_MOUNT(MOUNTTONULLMOUNT(mp)->nullm_vfs, path, data, ndp, p);*/
- }
-
- /*
- * Get argument
- */
- error = copyin(data, (caddr_t)&args, sizeof(struct null_args));
- if (error)
- return (error);
-
- /*
- * Unlock lower node to avoid deadlock.
- * (XXX) VOP_ISLOCKED is needed?
- */
- if ((mp->mnt_vnodecovered->v_op == null_vnodeop_p) &&
- VOP_ISLOCKED(mp->mnt_vnodecovered, NULL)) {
- VOP_UNLOCK(mp->mnt_vnodecovered, 0, p);
- isvnunlocked = 1;
- }
- /*
- * Find lower node
- */
- NDINIT(ndp, LOOKUP, FOLLOW|WANTPARENT|LOCKLEAF,
- UIO_USERSPACE, args.target, p);
- error = namei(ndp);
- /*
- * Re-lock vnode.
- */
- if (isvnunlocked && !VOP_ISLOCKED(mp->mnt_vnodecovered, NULL))
- vn_lock(mp->mnt_vnodecovered, LK_EXCLUSIVE | LK_RETRY, p);
-
- if (error)
- return (error);
- NDFREE(ndp, NDF_ONLY_PNBUF);
-
- /*
- * Sanity check on lower vnode
- */
- lowerrootvp = ndp->ni_vp;
-
- vrele(ndp->ni_dvp);
- ndp->ni_dvp = NULLVP;
-
- /*
- * Check multi null mount to avoid `lock against myself' panic.
- */
- if (lowerrootvp == VTONULL(mp->mnt_vnodecovered)->null_lowervp) {
-#ifdef DEBUG
- printf("nullfs_mount: multi null mount?\n");
-#endif
- return (EDEADLK);
- }
-
- xmp = (struct null_mount *) malloc(sizeof(struct null_mount),
- M_NULLFSMNT, M_WAITOK); /* XXX */
-
- /*
- * Save reference to underlying FS
- */
- xmp->nullm_vfs = lowerrootvp->v_mount;
-
- /*
- * Save reference. Each mount also holds
- * a reference on the root vnode.
- */
- error = null_node_create(mp, lowerrootvp, &vp);
- /*
- * Unlock the node (either the lower or the alias)
- */
- VOP_UNLOCK(vp, 0, p);
- /*
- * Make sure the node alias worked
- */
- if (error) {
- vrele(lowerrootvp);
- free(xmp, M_NULLFSMNT); /* XXX */
- return (error);
- }
-
- /*
- * Keep a held reference to the root vnode.
- * It is vrele'd in nullfs_unmount.
- */
- nullm_rootvp = vp;
- nullm_rootvp->v_flag |= VROOT;
- xmp->nullm_rootvp = nullm_rootvp;
- if (NULLVPTOLOWERVP(nullm_rootvp)->v_mount->mnt_flag & MNT_LOCAL)
- mp->mnt_flag |= MNT_LOCAL;
- mp->mnt_data = (qaddr_t) xmp;
- vfs_getnewfsid(mp);
-
- (void) copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size);
- bzero(mp->mnt_stat.f_mntonname + size, MNAMELEN - size);
- (void) copyinstr(args.target, mp->mnt_stat.f_mntfromname, MNAMELEN - 1,
- &size);
- bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
- (void)nullfs_statfs(mp, &mp->mnt_stat, p);
-#ifdef DEBUG
- printf("nullfs_mount: lower %s, alias at %s\n",
- mp->mnt_stat.f_mntfromname, mp->mnt_stat.f_mntonname);
-#endif
- return (0);
-}
-
-/*
- * VFS start. Nothing needed here - the start routine
- * on the underlying filesystem will have been called
- * when that filesystem was mounted.
- */
-static int
-nullfs_start(mp, flags, p)
- struct mount *mp;
- int flags;
- struct proc *p;
-{
- return (0);
- /* return VFS_START(MOUNTTONULLMOUNT(mp)->nullm_vfs, flags, p); */
-}
-
-/*
- * Free reference to null layer
- */
-static int
-nullfs_unmount(mp, mntflags, p)
- struct mount *mp;
- int mntflags;
- struct proc *p;
-{
- struct vnode *nullm_rootvp = MOUNTTONULLMOUNT(mp)->nullm_rootvp;
- int error;
- int flags = 0;
-
-#ifdef DEBUG
- printf("nullfs_unmount(mp = %p)\n", (void *)mp);
-#endif
-
- if (mntflags & MNT_FORCE)
- flags |= FORCECLOSE;
-
- /*
- * Clear out buffer cache. I don't think we
- * ever get anything cached at this level at the
- * moment, but who knows...
- */
-#if 0
- mntflushbuf(mp, 0);
- if (mntinvalbuf(mp, 1))
- return (EBUSY);
-#endif
- if (nullm_rootvp->v_usecount > 1)
- return (EBUSY);
- error = vflush(mp, nullm_rootvp, flags);
- if (error)
- return (error);
-
-#ifdef DEBUG
- vprint("alias root of lower", nullm_rootvp);
-#endif
- /*
- * Release reference on underlying root vnode
- */
- vrele(nullm_rootvp);
- /*
- * And blow it away for future re-use
- */
- vgone(nullm_rootvp);
- /*
- * Finally, throw away the null_mount structure
- */
- free(mp->mnt_data, M_NULLFSMNT); /* XXX */
- mp->mnt_data = 0;
- return 0;
-}
-
-static int
-nullfs_root(mp, vpp)
- struct mount *mp;
- struct vnode **vpp;
-{
- struct proc *p = curproc; /* XXX */
- struct vnode *vp;
-
-#ifdef DEBUG
- printf("nullfs_root(mp = %p, vp = %p->%p)\n", (void *)mp,
- (void *)MOUNTTONULLMOUNT(mp)->nullm_rootvp,
- (void *)NULLVPTOLOWERVP(MOUNTTONULLMOUNT(mp)->nullm_rootvp));
-#endif
-
- /*
- * Return locked reference to root.
- */
- vp = MOUNTTONULLMOUNT(mp)->nullm_rootvp;
- VREF(vp);
- if (VOP_ISLOCKED(vp, NULL)) {
- /*
- * XXX
- * Should we check type of node?
- */
-#ifdef DEBUG
- printf("nullfs_root: multi null mount?\n");
-#endif
- vrele(vp);
- return (EDEADLK);
- } else
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
- *vpp = vp;
- return 0;
-}
-
-static int
-nullfs_quotactl(mp, cmd, uid, arg, p)
- struct mount *mp;
- int cmd;
- uid_t uid;
- caddr_t arg;
- struct proc *p;
-{
- return VFS_QUOTACTL(MOUNTTONULLMOUNT(mp)->nullm_vfs, cmd, uid, arg, p);
-}
-
-static int
-nullfs_statfs(mp, sbp, p)
- struct mount *mp;
- struct statfs *sbp;
- struct proc *p;
-{
- int error;
- struct statfs mstat;
-
-#ifdef DEBUG
- printf("nullfs_statfs(mp = %p, vp = %p->%p)\n", (void *)mp,
- (void *)MOUNTTONULLMOUNT(mp)->nullm_rootvp,
- (void *)NULLVPTOLOWERVP(MOUNTTONULLMOUNT(mp)->nullm_rootvp));
-#endif
-
- bzero(&mstat, sizeof(mstat));
-
- error = VFS_STATFS(MOUNTTONULLMOUNT(mp)->nullm_vfs, &mstat, p);
- if (error)
- return (error);
-
- /* now copy across the "interesting" information and fake the rest */
- sbp->f_type = mstat.f_type;
- sbp->f_flags = mstat.f_flags;
- sbp->f_bsize = mstat.f_bsize;
- sbp->f_iosize = mstat.f_iosize;
- sbp->f_blocks = mstat.f_blocks;
- sbp->f_bfree = mstat.f_bfree;
- sbp->f_bavail = mstat.f_bavail;
- sbp->f_files = mstat.f_files;
- sbp->f_ffree = mstat.f_ffree;
- if (sbp != &mp->mnt_stat) {
- bcopy(&mp->mnt_stat.f_fsid, &sbp->f_fsid, sizeof(sbp->f_fsid));
- bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN);
- bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN);
- }
- return (0);
-}
-
-static int
-nullfs_sync(mp, waitfor, cred, p)
- struct mount *mp;
- int waitfor;
- struct ucred *cred;
- struct proc *p;
-{
- /*
- * XXX - Assumes no data cached at null layer.
- */
- return (0);
-}
-
-static int
-nullfs_vget(mp, ino, vpp)
- struct mount *mp;
- ino_t ino;
- struct vnode **vpp;
-{
-
- return VFS_VGET(MOUNTTONULLMOUNT(mp)->nullm_vfs, ino, vpp);
-}
-
-static int
-nullfs_fhtovp(mp, fidp, vpp)
- struct mount *mp;
- struct fid *fidp;
- struct vnode **vpp;
-{
-
- return VFS_FHTOVP(MOUNTTONULLMOUNT(mp)->nullm_vfs, fidp, vpp);
-}
-
-static int
-nullfs_checkexp(mp, nam, extflagsp, credanonp)
- struct mount *mp;
- struct sockaddr *nam;
- int *extflagsp;
- struct ucred **credanonp;
-{
-
- return VFS_CHECKEXP(MOUNTTONULLMOUNT(mp)->nullm_vfs, nam,
- extflagsp, credanonp);
-}
-
-static int
-nullfs_vptofh(vp, fhp)
- struct vnode *vp;
- struct fid *fhp;
-{
- return VFS_VPTOFH(NULLVPTOLOWERVP(vp), fhp);
-}
-
-static int
-nullfs_extattrctl(mp, cmd, attrname, arg, p)
- struct mount *mp;
- int cmd;
- const char *attrname;
- caddr_t arg;
- struct proc *p;
-{
- return VFS_EXTATTRCTL(MOUNTTONULLMOUNT(mp)->nullm_vfs, cmd, attrname,
- arg, p);
-}
-
-
-static struct vfsops null_vfsops = {
- nullfs_mount,
- nullfs_start,
- nullfs_unmount,
- nullfs_root,
- nullfs_quotactl,
- nullfs_statfs,
- nullfs_sync,
- nullfs_vget,
- nullfs_fhtovp,
- nullfs_checkexp,
- nullfs_vptofh,
- nullfs_init,
- vfs_stduninit,
- nullfs_extattrctl,
-};
-
-VFS_SET(null_vfsops, null, VFCF_LOOPBACK);
diff --git a/sys/fs/nullfs/null_vnops.c b/sys/fs/nullfs/null_vnops.c
deleted file mode 100644
index 9600f3c11ea6..000000000000
--- a/sys/fs/nullfs/null_vnops.c
+++ /dev/null
@@ -1,610 +0,0 @@
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * John Heidemann of the UCLA Ficus project.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)null_vnops.c 8.6 (Berkeley) 5/27/95
- *
- * Ancestors:
- * @(#)lofs_vnops.c 1.2 (Berkeley) 6/18/92
- * $FreeBSD$
- * ...and...
- * @(#)null_vnodeops.c 1.20 92/07/07 UCLA Ficus project
- *
- * $FreeBSD$
- */
-
-/*
- * Null Layer
- *
- * (See mount_null(8) for more information.)
- *
- * The null layer duplicates a portion of the file system
- * name space under a new name. In this respect, it is
- * similar to the loopback file system. It differs from
- * the loopback fs in two respects: it is implemented using
- * a stackable layers techniques, and its "null-node"s stack above
- * all lower-layer vnodes, not just over directory vnodes.
- *
- * The null layer has two purposes. First, it serves as a demonstration
- * of layering by proving a layer which does nothing. (It actually
- * does everything the loopback file system does, which is slightly
- * more than nothing.) Second, the null layer can serve as a prototype
- * layer. Since it provides all necessary layer framework,
- * new file system layers can be created very easily be starting
- * with a null layer.
- *
- * The remainder of this man page examines the null layer as a basis
- * for constructing new layers.
- *
- *
- * INSTANTIATING NEW NULL LAYERS
- *
- * New null layers are created with mount_null(8).
- * Mount_null(8) takes two arguments, the pathname
- * of the lower vfs (target-pn) and the pathname where the null
- * layer will appear in the namespace (alias-pn). After
- * the null layer is put into place, the contents
- * of target-pn subtree will be aliased under alias-pn.
- *
- *
- * OPERATION OF A NULL LAYER
- *
- * The null layer is the minimum file system layer,
- * simply bypassing all possible operations to the lower layer
- * for processing there. The majority of its activity centers
- * on the bypass routine, through which nearly all vnode operations
- * pass.
- *
- * The bypass routine accepts arbitrary vnode operations for
- * handling by the lower layer. It begins by examing vnode
- * operation arguments and replacing any null-nodes by their
- * lower-layer equivlants. It then invokes the operation
- * on the lower layer. Finally, it replaces the null-nodes
- * in the arguments and, if a vnode is return by the operation,
- * stacks a null-node on top of the returned vnode.
- *
- * Although bypass handles most operations, vop_getattr, vop_lock,
- * vop_unlock, vop_inactive, vop_reclaim, and vop_print are not
- * bypassed. Vop_getattr must change the fsid being returned.
- * Vop_lock and vop_unlock must handle any locking for the
- * current vnode as well as pass the lock request down.
- * Vop_inactive and vop_reclaim are not bypassed so that
- * they can handle freeing null-layer specific data. Vop_print
- * is not bypassed to avoid excessive debugging information.
- * Also, certain vnode operations change the locking state within
- * the operation (create, mknod, remove, link, rename, mkdir, rmdir,
- * and symlink). Ideally these operations should not change the
- * lock state, but should be changed to let the caller of the
- * function unlock them. Otherwise all intermediate vnode layers
- * (such as union, umapfs, etc) must catch these functions to do
- * the necessary locking at their layer.
- *
- *
- * INSTANTIATING VNODE STACKS
- *
- * Mounting associates the null layer with a lower layer,
- * effect stacking two VFSes. Vnode stacks are instead
- * created on demand as files are accessed.
- *
- * The initial mount creates a single vnode stack for the
- * root of the new null layer. All other vnode stacks
- * are created as a result of vnode operations on
- * this or other null vnode stacks.
- *
- * New vnode stacks come into existance as a result of
- * an operation which returns a vnode.
- * The bypass routine stacks a null-node above the new
- * vnode before returning it to the caller.
- *
- * For example, imagine mounting a null layer with
- * "mount_null /usr/include /dev/layer/null".
- * Changing directory to /dev/layer/null will assign
- * the root null-node (which was created when the null layer was mounted).
- * Now consider opening "sys". A vop_lookup would be
- * done on the root null-node. This operation would bypass through
- * to the lower layer which would return a vnode representing
- * the UFS "sys". Null_bypass then builds a null-node
- * aliasing the UFS "sys" and returns this to the caller.
- * Later operations on the null-node "sys" will repeat this
- * process when constructing other vnode stacks.
- *
- *
- * CREATING OTHER FILE SYSTEM LAYERS
- *
- * One of the easiest ways to construct new file system layers is to make
- * a copy of the null layer, rename all files and variables, and
- * then begin modifing the copy. Sed can be used to easily rename
- * all variables.
- *
- * The umap layer is an example of a layer descended from the
- * null layer.
- *
- *
- * INVOKING OPERATIONS ON LOWER LAYERS
- *
- * There are two techniques to invoke operations on a lower layer
- * when the operation cannot be completely bypassed. Each method
- * is appropriate in different situations. In both cases,
- * it is the responsibility of the aliasing layer to make
- * the operation arguments "correct" for the lower layer
- * by mapping an vnode arguments to the lower layer.
- *
- * The first approach is to call the aliasing layer's bypass routine.
- * This method is most suitable when you wish to invoke the operation
- * currently being handled on the lower layer. It has the advantage
- * that the bypass routine already must do argument mapping.
- * An example of this is null_getattrs in the null layer.
- *
- * A second approach is to directly invoke vnode operations on
- * the lower layer with the VOP_OPERATIONNAME interface.
- * The advantage of this method is that it is easy to invoke
- * arbitrary operations on the lower layer. The disadvantage
- * is that vnode arguments must be manualy mapped.
- *
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/sysctl.h>
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <sys/namei.h>
-#include <sys/malloc.h>
-#include <sys/buf.h>
-#include <miscfs/nullfs/null.h>
-
-static int null_bug_bypass = 0; /* for debugging: enables bypass printf'ing */
-SYSCTL_INT(_debug, OID_AUTO, nullfs_bug_bypass, CTLFLAG_RW,
- &null_bug_bypass, 0, "");
-
-static int null_access __P((struct vop_access_args *ap));
-static int null_getattr __P((struct vop_getattr_args *ap));
-static int null_inactive __P((struct vop_inactive_args *ap));
-static int null_lock __P((struct vop_lock_args *ap));
-static int null_lookup __P((struct vop_lookup_args *ap));
-static int null_print __P((struct vop_print_args *ap));
-static int null_reclaim __P((struct vop_reclaim_args *ap));
-static int null_setattr __P((struct vop_setattr_args *ap));
-static int null_unlock __P((struct vop_unlock_args *ap));
-
-/*
- * This is the 10-Apr-92 bypass routine.
- * This version has been optimized for speed, throwing away some
- * safety checks. It should still always work, but it's not as
- * robust to programmer errors.
- *
- * In general, we map all vnodes going down and unmap them on the way back.
- * As an exception to this, vnodes can be marked "unmapped" by setting
- * the Nth bit in operation's vdesc_flags.
- *
- * Also, some BSD vnode operations have the side effect of vrele'ing
- * their arguments. With stacking, the reference counts are held
- * by the upper node, not the lower one, so we must handle these
- * side-effects here. This is not of concern in Sun-derived systems
- * since there are no such side-effects.
- *
- * This makes the following assumptions:
- * - only one returned vpp
- * - no INOUT vpp's (Sun's vop_open has one of these)
- * - the vnode operation vector of the first vnode should be used
- * to determine what implementation of the op should be invoked
- * - all mapped vnodes are of our vnode-type (NEEDSWORK:
- * problems on rmdir'ing mount points and renaming?)
- */
-int
-null_bypass(ap)
- struct vop_generic_args /* {
- struct vnodeop_desc *a_desc;
- <other random data follows, presumably>
- } */ *ap;
-{
- register struct vnode **this_vp_p;
- int error;
- struct vnode *old_vps[VDESC_MAX_VPS];
- struct vnode **vps_p[VDESC_MAX_VPS];
- struct vnode ***vppp;
- struct vnodeop_desc *descp = ap->a_desc;
- int reles, i;
-
- if (null_bug_bypass)
- printf ("null_bypass: %s\n", descp->vdesc_name);
-
-#ifdef DIAGNOSTIC
- /*
- * We require at least one vp.
- */
- if (descp->vdesc_vp_offsets == NULL ||
- descp->vdesc_vp_offsets[0] == VDESC_NO_OFFSET)
- panic ("null_bypass: no vp's in map");
-#endif
-
- /*
- * Map the vnodes going in.
- * Later, we'll invoke the operation based on
- * the first mapped vnode's operation vector.
- */
- reles = descp->vdesc_flags;
- for (i = 0; i < VDESC_MAX_VPS; reles >>= 1, i++) {
- if (descp->vdesc_vp_offsets[i] == VDESC_NO_OFFSET)
- break; /* bail out at end of list */
- vps_p[i] = this_vp_p =
- VOPARG_OFFSETTO(struct vnode**,descp->vdesc_vp_offsets[i],ap);
- /*
- * We're not guaranteed that any but the first vnode
- * are of our type. Check for and don't map any
- * that aren't. (We must always map first vp or vclean fails.)
- */
- if (i && (*this_vp_p == NULLVP ||
- (*this_vp_p)->v_op != null_vnodeop_p)) {
- old_vps[i] = NULLVP;
- } else {
- old_vps[i] = *this_vp_p;
- *(vps_p[i]) = NULLVPTOLOWERVP(*this_vp_p);
- /*
- * XXX - Several operations have the side effect
- * of vrele'ing their vp's. We must account for
- * that. (This should go away in the future.)
- */
- if (reles & 1)
- VREF(*this_vp_p);
- }
-
- }
-
- /*
- * Call the operation on the lower layer
- * with the modified argument structure.
- */
- error = VCALL(*(vps_p[0]), descp->vdesc_offset, ap);
-
- /*
- * Maintain the illusion of call-by-value
- * by restoring vnodes in the argument structure
- * to their original value.
- */
- reles = descp->vdesc_flags;
- for (i = 0; i < VDESC_MAX_VPS; reles >>= 1, i++) {
- if (descp->vdesc_vp_offsets[i] == VDESC_NO_OFFSET)
- break; /* bail out at end of list */
- if (old_vps[i]) {
- *(vps_p[i]) = old_vps[i];
- if (reles & 1)
- vrele(*(vps_p[i]));
- }
- }
-
- /*
- * Map the possible out-going vpp
- * (Assumes that the lower layer always returns
- * a VREF'ed vpp unless it gets an error.)
- */
- if (descp->vdesc_vpp_offset != VDESC_NO_OFFSET &&
- !(descp->vdesc_flags & VDESC_NOMAP_VPP) &&
- !error) {
- /*
- * XXX - even though some ops have vpp returned vp's,
- * several ops actually vrele this before returning.
- * We must avoid these ops.
- * (This should go away when these ops are regularized.)
- */
- if (descp->vdesc_flags & VDESC_VPP_WILLRELE)
- goto out;
- vppp = VOPARG_OFFSETTO(struct vnode***,
- descp->vdesc_vpp_offset,ap);
- if (*vppp)
- error = null_node_create(old_vps[0]->v_mount, **vppp, *vppp);
- }
-
- out:
- return (error);
-}
-
-/*
- * We have to carry on the locking protocol on the null layer vnodes
- * as we progress through the tree. We also have to enforce read-only
- * if this layer is mounted read-only.
- */
-static int
-null_lookup(ap)
- struct vop_lookup_args /* {
- struct vnode * a_dvp;
- struct vnode ** a_vpp;
- struct componentname * a_cnp;
- } */ *ap;
-{
- struct componentname *cnp = ap->a_cnp;
- struct proc *p = cnp->cn_proc;
- int flags = cnp->cn_flags;
- struct vop_lock_args lockargs;
- struct vop_unlock_args unlockargs;
- struct vnode *dvp, *vp;
- int error;
-
- if ((flags & ISLASTCN) && (ap->a_dvp->v_mount->mnt_flag & MNT_RDONLY) &&
- (cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME))
- return (EROFS);
- error = null_bypass((struct vop_generic_args *)ap);
- if (error == EJUSTRETURN && (flags & ISLASTCN) &&
- (ap->a_dvp->v_mount->mnt_flag & MNT_RDONLY) &&
- (cnp->cn_nameiop == CREATE || cnp->cn_nameiop == RENAME))
- error = EROFS;
- /*
- * We must do the same locking and unlocking at this layer as
- * is done in the layers below us. We could figure this out
- * based on the error return and the LASTCN, LOCKPARENT, and
- * LOCKLEAF flags. However, it is more expidient to just find
- * out the state of the lower level vnodes and set ours to the
- * same state.
- */
- dvp = ap->a_dvp;
- vp = *ap->a_vpp;
- if (dvp == vp)
- return (error);
- if (!VOP_ISLOCKED(dvp, NULL)) {
- unlockargs.a_vp = dvp;
- unlockargs.a_flags = 0;
- unlockargs.a_p = p;
- vop_nounlock(&unlockargs);
- }
- if (vp != NULLVP && VOP_ISLOCKED(vp, NULL)) {
- lockargs.a_vp = vp;
- lockargs.a_flags = LK_SHARED;
- lockargs.a_p = p;
- vop_nolock(&lockargs);
- }
- return (error);
-}
-
-/*
- * Setattr call. Disallow write attempts if the layer is mounted read-only.
- */
-int
-null_setattr(ap)
- struct vop_setattr_args /* {
- struct vnodeop_desc *a_desc;
- struct vnode *a_vp;
- struct vattr *a_vap;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
- struct vattr *vap = ap->a_vap;
-
- if ((vap->va_flags != VNOVAL || vap->va_uid != (uid_t)VNOVAL ||
- vap->va_gid != (gid_t)VNOVAL || vap->va_atime.tv_sec != VNOVAL ||
- vap->va_mtime.tv_sec != VNOVAL || vap->va_mode != (mode_t)VNOVAL) &&
- (vp->v_mount->mnt_flag & MNT_RDONLY))
- return (EROFS);
- if (vap->va_size != VNOVAL) {
- switch (vp->v_type) {
- case VDIR:
- return (EISDIR);
- case VCHR:
- case VBLK:
- case VSOCK:
- case VFIFO:
- if (vap->va_flags != VNOVAL)
- return (EOPNOTSUPP);
- return (0);
- case VREG:
- case VLNK:
- default:
- /*
- * Disallow write attempts if the filesystem is
- * mounted read-only.
- */
- if (vp->v_mount->mnt_flag & MNT_RDONLY)
- return (EROFS);
- }
- }
- return (null_bypass((struct vop_generic_args *)ap));
-}
-
-/*
- * We handle getattr only to change the fsid.
- */
-static int
-null_getattr(ap)
- struct vop_getattr_args /* {
- struct vnode *a_vp;
- struct vattr *a_vap;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- int error;
-
- if ((error = null_bypass((struct vop_generic_args *)ap)) != 0)
- return (error);
- return (0);
-}
-
-static int
-null_access(ap)
- struct vop_access_args /* {
- struct vnode *a_vp;
- int a_mode;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
- mode_t mode = ap->a_mode;
-
- /*
- * Disallow write attempts on read-only layers;
- * unless the file is a socket, fifo, or a block or
- * character device resident on the file system.
- */
- if (mode & VWRITE) {
- switch (vp->v_type) {
- case VDIR:
- case VLNK:
- case VREG:
- if (vp->v_mount->mnt_flag & MNT_RDONLY)
- return (EROFS);
- break;
- default:
- break;
- }
- }
- return (null_bypass((struct vop_generic_args *)ap));
-}
-
-/*
- * We need to process our own vnode lock and then clear the
- * interlock flag as it applies only to our vnode, not the
- * vnodes below us on the stack.
- */
-static int
-null_lock(ap)
- struct vop_lock_args /* {
- struct vnode *a_vp;
- int a_flags;
- struct proc *a_p;
- } */ *ap;
-{
-
- vop_nolock(ap);
- if ((ap->a_flags & LK_TYPE_MASK) == LK_DRAIN)
- return (0);
- ap->a_flags &= ~LK_INTERLOCK;
- return (null_bypass((struct vop_generic_args *)ap));
-}
-
-/*
- * We need to process our own vnode unlock and then clear the
- * interlock flag as it applies only to our vnode, not the
- * vnodes below us on the stack.
- */
-static int
-null_unlock(ap)
- struct vop_unlock_args /* {
- struct vnode *a_vp;
- int a_flags;
- struct proc *a_p;
- } */ *ap;
-{
- vop_nounlock(ap);
- ap->a_flags &= ~LK_INTERLOCK;
- return (null_bypass((struct vop_generic_args *)ap));
-}
-
-static int
-null_inactive(ap)
- struct vop_inactive_args /* {
- struct vnode *a_vp;
- struct proc *a_p;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
- struct null_node *xp = VTONULL(vp);
- struct vnode *lowervp = xp->null_lowervp;
- /*
- * Do nothing (and _don't_ bypass).
- * Wait to vrele lowervp until reclaim,
- * so that until then our null_node is in the
- * cache and reusable.
- * We still have to tell the lower layer the vnode
- * is now inactive though.
- *
- * NEEDSWORK: Someday, consider inactive'ing
- * the lowervp and then trying to reactivate it
- * with capabilities (v_id)
- * like they do in the name lookup cache code.
- * That's too much work for now.
- */
- VOP_INACTIVE(lowervp, ap->a_p);
- VOP_UNLOCK(ap->a_vp, 0, ap->a_p);
- return (0);
-}
-
-static int
-null_reclaim(ap)
- struct vop_reclaim_args /* {
- struct vnode *a_vp;
- struct proc *a_p;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
- struct null_node *xp = VTONULL(vp);
- struct vnode *lowervp = xp->null_lowervp;
-
- /*
- * Note: in vop_reclaim, vp->v_op == dead_vnodeop_p,
- * so we can't call VOPs on ourself.
- */
- /* After this assignment, this node will not be re-used. */
- xp->null_lowervp = NULLVP;
- LIST_REMOVE(xp, null_hash);
- FREE(vp->v_data, M_TEMP);
- vp->v_data = NULL;
- vrele (lowervp);
- return (0);
-}
-
-static int
-null_print(ap)
- struct vop_print_args /* {
- struct vnode *a_vp;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
- printf ("\ttag VT_NULLFS, vp=%p, lowervp=%p\n", vp, NULLVPTOLOWERVP(vp));
- return (0);
-}
-
-/*
- * Global vfs data structures
- */
-vop_t **null_vnodeop_p;
-static struct vnodeopv_entry_desc null_vnodeop_entries[] = {
- { &vop_default_desc, (vop_t *) null_bypass },
- { &vop_access_desc, (vop_t *) null_access },
- { &vop_getattr_desc, (vop_t *) null_getattr },
- { &vop_inactive_desc, (vop_t *) null_inactive },
- { &vop_lock_desc, (vop_t *) null_lock },
- { &vop_lookup_desc, (vop_t *) null_lookup },
- { &vop_print_desc, (vop_t *) null_print },
- { &vop_reclaim_desc, (vop_t *) null_reclaim },
- { &vop_setattr_desc, (vop_t *) null_setattr },
- { &vop_unlock_desc, (vop_t *) null_unlock },
- { NULL, NULL }
-};
-static struct vnodeopv_desc null_vnodeop_opv_desc =
- { &null_vnodeop_p, null_vnodeop_entries };
-
-VNODEOP_SET(null_vnodeop_opv_desc);
diff --git a/sys/fs/nwfs/nwfs.h b/sys/fs/nwfs/nwfs.h
deleted file mode 100644
index e5478692b13e..000000000000
--- a/sys/fs/nwfs/nwfs.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 1999, Boris Popov
- * 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 Boris Popov.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _NWFS_H_
-#define _NWFS_H_
-
-#include <netncp/ncp.h>
-#include <nwfs/nwfs_mount.h>
-
-#define NR_OPEN 0
-#define NW_NSB_DOS (1 << NW_NS_DOS)
-#define NW_NSB_MAC (1 << NW_NS_MAC)
-#define NW_NSB_NFS (1 << NW_NS_NFS)
-#define NW_NSB_FTAM (1 << NW_NS_FTAM)
-#define NW_NSB_OS2 (1 << NW_NS_OS2)
-
-#define NWFSIOC_GETCONN _IOR('n',1,int)
-#define NWFSIOC_GETEINFO _IOR('n',2,struct nw_entry_info)
-#define NWFSIOC_GETNS _IOR('n',3,int)
-
-#ifdef _KERNEL
-
-#include <sys/vnode.h>
-#include <sys/mount.h>
-
-struct nwfsnode;
-
-struct nwmount {
- struct nwfs_args m;
- struct mount *mp;
- struct ncp_handle *connh;
- int name_space;
- struct nwnode *n_root;
- u_int32_t n_volume;
- ncpfid n_rootent;
- int n_id;
-};
-
-#define VFSTONWFS(mntp) ((struct nwmount *)((mntp)->mnt_data))
-#define NWFSTOVFS(mnp) ((struct mount *)((mnp)->mount))
-#define VTOVFS(vp) ((vp)->v_mount)
-#define VTONWFS(vp) (VFSTONWFS(VTOVFS(vp)))
-#define NWFSTOCONN(nmp) ((nmp)->connh->nh_conn)
-
-int ncp_conn_logged_in(struct nwmount *);
-int nwfs_ioctl(struct vop_ioctl_args *ap);
-int nwfs_doio(struct buf *bp, struct ucred *cr, struct proc *p);
-int nwfs_vinvalbuf(struct vnode *vp, int flags, struct ucred *cred,
- struct proc *p, int intrflg);
-#endif /* _KERNEL */
-
-#endif /* _NWFS_H_ */
diff --git a/sys/fs/nwfs/nwfs_io.c b/sys/fs/nwfs/nwfs_io.c
deleted file mode 100644
index d634cbc1dc26..000000000000
--- a/sys/fs/nwfs/nwfs_io.c
+++ /dev/null
@@ -1,633 +0,0 @@
-/*
- * Copyright (c) 1999, Boris Popov
- * 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 Boris Popov.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- *
- */
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/resourcevar.h> /* defines plimit structure in proc struct */
-#include <sys/kernel.h>
-#include <sys/buf.h>
-#include <sys/proc.h>
-#include <sys/mount.h>
-#include <sys/namei.h>
-#include <sys/vnode.h>
-#include <sys/dirent.h>
-#include <sys/signalvar.h>
-#include <sys/sysctl.h>
-
-#include <vm/vm.h>
-#include <vm/vm_page.h>
-#include <vm/vm_extern.h>
-#include <vm/vm_object.h>
-#include <vm/vm_pager.h>
-#include <vm/vnode_pager.h>
-
-#include <netncp/ncp.h>
-#include <netncp/ncp_conn.h>
-#include <netncp/ncp_subr.h>
-
-#include <nwfs/nwfs.h>
-#include <nwfs/nwfs_node.h>
-#include <nwfs/nwfs_subr.h>
-
-static int nwfs_fastlookup = 1;
-
-extern struct linker_set sysctl_vfs_nwfs;
-
-SYSCTL_DECL(_vfs_nwfs);
-SYSCTL_INT(_vfs_nwfs, OID_AUTO, fastlookup, CTLFLAG_RW, &nwfs_fastlookup, 0, "");
-
-
-extern int nwfs_pbuf_freecnt;
-
-#define DE_SIZE (sizeof(struct dirent))
-#define NWFS_RWCACHE
-
-static int
-nwfs_readvdir(struct vnode *vp, struct uio *uio, struct ucred *cred) {
- struct nwmount *nmp = VTONWFS(vp);
- int error, count, i;
- struct dirent dp;
- struct nwnode *np = VTONW(vp);
- struct nw_entry_info fattr;
- struct vnode *newvp;
- struct componentname cn;
- ncpfid fid;
-
- np = VTONW(vp);
- NCPVNDEBUG("dirname='%s'\n",np->n_name);
- if (uio->uio_resid < DE_SIZE || (uio->uio_offset < 0))
- return (EINVAL);
- error = 0;
- count = 0;
- i = uio->uio_offset / DE_SIZE; /* offset in directory */
- if (i == 0) {
- error = ncp_initsearch(vp, uio->uio_procp, cred);
- if (error) {
- NCPVNDEBUG("cannot initialize search, error=%d",error);
- return( error );
- }
- }
-
- for (; uio->uio_resid >= DE_SIZE; i++) {
- bzero((char *) &dp, DE_SIZE);
- dp.d_reclen = DE_SIZE;
- switch (i) {
- case 0: /* `.' */
- case 1: /* `..' */
- dp.d_fileno = (i == 0) ? np->n_fid.f_id : np->n_parent.f_id;
- if (!dp.d_fileno) dp.d_fileno = NWFS_ROOT_INO;
- dp.d_namlen = i + 1;
- dp.d_name[0] = '.';
- dp.d_name[1] = '.';
- dp.d_name[i + 1] = '\0';
- dp.d_type = DT_DIR;
- break;
- default:
- error = ncp_search_for_file_or_subdir(nmp, &np->n_seq, &fattr, uio->uio_procp, cred);
- if (error && error < 0x80) break;
- dp.d_fileno = fattr.dirEntNum;
- dp.d_type = (fattr.attributes & aDIR) ? DT_DIR : DT_REG;
- dp.d_namlen = fattr.nameLen;
- bcopy(fattr.entryName, dp.d_name, dp.d_namlen);
- dp.d_name[dp.d_namlen] = '\0';
-#if 0
- if (error && eofflag) {
- /* *eofflag = 1;*/
- break;
- }
-#endif
- break;
- }
- if (nwfs_fastlookup && !error && i > 1) {
- fid.f_id = fattr.dirEntNum;
- fid.f_parent = np->n_fid.f_id;
- error = nwfs_nget(vp->v_mount, fid, &fattr, vp, &newvp);
- if (!error) {
- VTONW(newvp)->n_ctime = VTONW(newvp)->n_vattr.va_ctime.tv_sec;
- cn.cn_nameptr = dp.d_name;
- cn.cn_namelen = dp.d_namlen;
- cache_enter(vp, newvp, &cn);
- vput(newvp);
- } else
- error = 0;
- }
- if (error >= 0x80) {
- error = 0;
- break;
- }
- if ((error = uiomove((caddr_t)&dp, DE_SIZE, uio)))
- break;
- }
-
- uio->uio_offset = i * DE_SIZE;
- return (error);
-}
-
-int
-nwfs_readvnode(struct vnode *vp, struct uio *uiop, struct ucred *cred) {
- struct nwmount *nmp = VFSTONWFS(vp->v_mount);
- struct nwnode *np = VTONW(vp);
- struct proc *p;
- struct vattr vattr;
- int error, biosize;
-
- if (vp->v_type != VREG && vp->v_type != VDIR) {
- printf("%s: vn types other than VREG or VDIR are unsupported !\n",__FUNCTION__);
- return EIO;
- }
- if (uiop->uio_resid == 0) return 0;
- if (uiop->uio_offset < 0) return EINVAL;
-/* if (uiop->uio_offset + uiop->uio_resid > nmp->nm_maxfilesize)
- return (EFBIG);*/
- p = uiop->uio_procp;
- if (vp->v_type == VDIR) {
- error = nwfs_readvdir(vp, uiop, cred);
- return error;
- }
- biosize = NWFSTOCONN(nmp)->buffer_size;
- if (np->n_flag & NMODIFIED) {
- nwfs_attr_cacheremove(vp);
- error = VOP_GETATTR(vp, &vattr, cred, p);
- if (error) return (error);
- np->n_mtime = vattr.va_mtime.tv_sec;
- } else {
- error = VOP_GETATTR(vp, &vattr, cred, p);
- if (error) return (error);
- if (np->n_mtime != vattr.va_mtime.tv_sec) {
- error = nwfs_vinvalbuf(vp, V_SAVE, cred, p, 1);
- if (error) return (error);
- np->n_mtime = vattr.va_mtime.tv_sec;
- }
- }
- error = ncp_read(NWFSTOCONN(nmp), &np->n_fh, uiop,cred);
- return (error);
-}
-
-int
-nwfs_writevnode(vp, uiop, cred, ioflag)
- register struct vnode *vp;
- register struct uio *uiop;
- struct ucred *cred;
- int ioflag;
-{
- struct nwmount *nmp = VTONWFS(vp);
- struct nwnode *np = VTONW(vp);
- struct proc *p;
-/* struct vattr vattr;*/
- int error = 0;
-
- if (vp->v_type != VREG) {
- printf("%s: vn types other than VREG unsupported !\n",__FUNCTION__);
- return EIO;
- }
- NCPVNDEBUG("ofs=%d,resid=%d\n",(int)uiop->uio_offset, uiop->uio_resid);
- if (uiop->uio_offset < 0) return EINVAL;
-/* if (uiop->uio_offset + uiop->uio_resid > nmp->nm_maxfilesize)
- return (EFBIG);*/
- p = uiop->uio_procp;
- if (ioflag & (IO_APPEND | IO_SYNC)) {
- if (np->n_flag & NMODIFIED) {
- nwfs_attr_cacheremove(vp);
- error = nwfs_vinvalbuf(vp, V_SAVE, cred, p, 1);
- if (error) return (error);
- }
- if (ioflag & IO_APPEND) {
- /* We can relay only on local information about file size,
- * because until file is closed NetWare will not return
- * the correct size. */
-#if notyet
- nwfs_attr_cacheremove(vp);
- error = VOP_GETATTR(vp, &vattr, cred, p);
- if (error) return (error);
-#endif
- uiop->uio_offset = np->n_size;
- }
- }
- if (uiop->uio_resid == 0) return 0;
- if (p && uiop->uio_offset + uiop->uio_resid > p->p_rlimit[RLIMIT_FSIZE].rlim_cur) {
- psignal(p, SIGXFSZ);
- return (EFBIG);
- }
- error = ncp_write(NWFSTOCONN(nmp), &np->n_fh, uiop, cred);
- NCPVNDEBUG("after: ofs=%d,resid=%d\n",(int)uiop->uio_offset, uiop->uio_resid);
- if (!error) {
- if (uiop->uio_offset > np->n_size) {
- np->n_vattr.va_size = np->n_size = uiop->uio_offset;
- vnode_pager_setsize(vp, np->n_size);
- }
- }
- return (error);
-}
-
-/*
- * Do an I/O operation to/from a cache block.
- */
-int
-nwfs_doio(bp, cr, p)
- register struct buf *bp;
- struct ucred *cr;
- struct proc *p;
-{
- register struct uio *uiop;
- register struct vnode *vp;
- struct nwnode *np;
- struct nwmount *nmp;
- int error = 0;
- struct uio uio;
- struct iovec io;
-
- vp = bp->b_vp;
- np = VTONW(vp);
- nmp = VFSTONWFS(vp->v_mount);
- uiop = &uio;
- uiop->uio_iov = &io;
- uiop->uio_iovcnt = 1;
- uiop->uio_segflg = UIO_SYSSPACE;
- uiop->uio_procp = p;
- if (bp->b_flags & B_READ) {
- io.iov_len = uiop->uio_resid = bp->b_bcount;
- io.iov_base = bp->b_data;
- uiop->uio_rw = UIO_READ;
- switch (vp->v_type) {
- case VREG:
- uiop->uio_offset = ((off_t)bp->b_blkno) * DEV_BSIZE;
- error = ncp_read(NWFSTOCONN(nmp), &np->n_fh, uiop, cr);
- if (error)
- break;
- if (uiop->uio_resid) {
- int left = uiop->uio_resid;
- int nread = bp->b_bcount - left;
- if (left > 0)
- bzero((char *)bp->b_data + nread, left);
- }
- break;
-/* case VDIR:
- nfsstats.readdir_bios++;
- uiop->uio_offset = ((u_quad_t)bp->b_lblkno) * NFS_DIRBLKSIZ;
- if (nmp->nm_flag & NFSMNT_RDIRPLUS) {
- error = nfs_readdirplusrpc(vp, uiop, cr);
- if (error == NFSERR_NOTSUPP)
- nmp->nm_flag &= ~NFSMNT_RDIRPLUS;
- }
- if ((nmp->nm_flag & NFSMNT_RDIRPLUS) == 0)
- error = nfs_readdirrpc(vp, uiop, cr);
- if (error == 0 && uiop->uio_resid == bp->b_bcount)
- bp->b_flags |= B_INVAL;
- break;
-*/
- default:
- printf("nwfs_doio: type %x unexpected\n",vp->v_type);
- break;
- };
- if (error) {
- bp->b_flags |= B_ERROR;
- bp->b_error = error;
- }
- } else { /* write */
- if (((bp->b_blkno * DEV_BSIZE) + bp->b_dirtyend) > np->n_size)
- bp->b_dirtyend = np->n_size - (bp->b_blkno * DEV_BSIZE);
-
- if (bp->b_dirtyend > bp->b_dirtyoff) {
- io.iov_len = uiop->uio_resid = bp->b_dirtyend - bp->b_dirtyoff;
- uiop->uio_offset = ((off_t)bp->b_blkno) * DEV_BSIZE + bp->b_dirtyoff;
- io.iov_base = (char *)bp->b_data + bp->b_dirtyoff;
- uiop->uio_rw = UIO_WRITE;
- bp->b_flags |= B_WRITEINPROG;
- error = ncp_write(NWFSTOCONN(nmp), &np->n_fh, uiop, cr);
- bp->b_flags &= ~B_WRITEINPROG;
-
- /*
- * For an interrupted write, the buffer is still valid
- * and the write hasn't been pushed to the server yet,
- * so we can't set B_ERROR and report the interruption
- * by setting B_EINTR. For the B_ASYNC case, B_EINTR
- * is not relevant, so the rpc attempt is essentially
- * a noop. For the case of a V3 write rpc not being
- * committed to stable storage, the block is still
- * dirty and requires either a commit rpc or another
- * write rpc with iomode == NFSV3WRITE_FILESYNC before
- * the block is reused. This is indicated by setting
- * the B_DELWRI and B_NEEDCOMMIT flags.
- */
- if (error == EINTR
- || (!error && (bp->b_flags & B_NEEDCOMMIT))) {
- int s;
-
- s = splbio();
- bp->b_flags &= ~(B_INVAL|B_NOCACHE);
- if ((bp->b_flags & B_ASYNC) == 0)
- bp->b_flags |= B_EINTR;
- if ((bp->b_flags & B_PAGING) == 0) {
- bdirty(bp);
- bp->b_flags &= ~B_DONE;
- }
- if ((bp->b_flags & B_ASYNC) == 0)
- bp->b_flags |= B_EINTR;
- splx(s);
- } else {
- if (error) {
- bp->b_flags |= B_ERROR;
- bp->b_error /*= np->n_error */= error;
-/* np->n_flag |= NWRITEERR;*/
- }
- bp->b_dirtyoff = bp->b_dirtyend = 0;
- }
- } else {
- bp->b_resid = 0;
- biodone(bp);
- return (0);
- }
- }
- bp->b_resid = uiop->uio_resid;
- biodone(bp);
- return (error);
-}
-
-/*
- * Vnode op for VM getpages.
- * Wish wish .... get rid from multiple IO routines
- */
-int
-nwfs_getpages(ap)
- struct vop_getpages_args /* {
- struct vnode *a_vp;
- vm_page_t *a_m;
- int a_count;
- int a_reqpage;
- vm_ooffset_t a_offset;
- } */ *ap;
-{
-#ifndef NWFS_RWCACHE
- return vnode_pager_generic_getpages(ap->a_vp, ap->a_m, ap->a_count,
- ap->a_reqpage);
-#else
- int i, error, nextoff, size, toff, npages, count;
- struct uio uio;
- struct iovec iov;
- vm_offset_t kva;
- struct buf *bp;
- struct vnode *vp;
- struct proc *p;
- struct ucred *cred;
- struct nwmount *nmp;
- struct nwnode *np;
- vm_page_t *pages;
-
- vp = ap->a_vp;
- p = curproc; /* XXX */
- cred = curproc->p_ucred; /* XXX */
- np = VTONW(vp);
- nmp = VFSTONWFS(vp->v_mount);
- pages = ap->a_m;
- count = ap->a_count;
-
- if (vp->v_object == NULL) {
- printf("nwfs_getpages: called with non-merged cache vnode??\n");
- return VM_PAGER_ERROR;
- }
-
- bp = getpbuf(&nwfs_pbuf_freecnt);
- npages = btoc(count);
- kva = (vm_offset_t) bp->b_data;
- pmap_qenter(kva, pages, npages);
-
- iov.iov_base = (caddr_t) kva;
- iov.iov_len = count;
- uio.uio_iov = &iov;
- uio.uio_iovcnt = 1;
- uio.uio_offset = IDX_TO_OFF(pages[0]->pindex);
- uio.uio_resid = count;
- uio.uio_segflg = UIO_SYSSPACE;
- uio.uio_rw = UIO_READ;
- uio.uio_procp = p;
-
- error = ncp_read(NWFSTOCONN(nmp), &np->n_fh, &uio,cred);
- pmap_qremove(kva, npages);
-
- relpbuf(bp, &nwfs_pbuf_freecnt);
-
- if (error && (uio.uio_resid == count)) {
- printf("nwfs_getpages: error %d\n",error);
- for (i = 0; i < npages; i++) {
- if (ap->a_reqpage != i)
- vnode_pager_freepage(pages[i]);
- }
- return VM_PAGER_ERROR;
- }
-
- size = count - uio.uio_resid;
-
- for (i = 0, toff = 0; i < npages; i++, toff = nextoff) {
- vm_page_t m;
- nextoff = toff + PAGE_SIZE;
- m = pages[i];
-
- m->flags &= ~PG_ZERO;
-
- if (nextoff <= size) {
- m->valid = VM_PAGE_BITS_ALL;
- m->dirty = 0;
- } else {
- int nvalid = ((size + DEV_BSIZE - 1) - toff) & ~(DEV_BSIZE - 1);
- vm_page_set_validclean(m, 0, nvalid);
- }
-
- if (i != ap->a_reqpage) {
- /*
- * Whether or not to leave the page activated is up in
- * the air, but we should put the page on a page queue
- * somewhere (it already is in the object). Result:
- * It appears that emperical results show that
- * deactivating pages is best.
- */
-
- /*
- * Just in case someone was asking for this page we
- * now tell them that it is ok to use.
- */
- if (!error) {
- if (m->flags & PG_WANTED)
- vm_page_activate(m);
- else
- vm_page_deactivate(m);
- vm_page_wakeup(m);
- } else {
- vnode_pager_freepage(m);
- }
- }
- }
- return 0;
-#endif /* NWFS_RWCACHE */
-}
-
-/*
- * Vnode op for VM putpages.
- * possible bug: all IO done in sync mode
- * Note that vop_close always invalidate pages before close, so it's
- * not necessary to open vnode.
- */
-int
-nwfs_putpages(ap)
- struct vop_putpages_args /* {
- struct vnode *a_vp;
- vm_page_t *a_m;
- int a_count;
- int a_sync;
- int *a_rtvals;
- vm_ooffset_t a_offset;
- } */ *ap;
-{
- int error;
- struct vnode *vp = ap->a_vp;
- struct proc *p;
- struct ucred *cred;
-
-#ifndef NWFS_RWCACHE
- p = curproc; /* XXX */
- cred = p->p_ucred; /* XXX */
- VOP_OPEN(vp, FWRITE, cred, p);
- error = vnode_pager_generic_putpages(ap->a_vp, ap->a_m, ap->a_count,
- ap->a_sync, ap->a_rtvals);
- VOP_CLOSE(vp, FWRITE, cred, p);
- return error;
-#else
- struct uio uio;
- struct iovec iov;
- vm_offset_t kva;
- struct buf *bp;
- int i, npages, count;
- int *rtvals;
- struct nwmount *nmp;
- struct nwnode *np;
- vm_page_t *pages;
-
- p = curproc; /* XXX */
- cred = p->p_ucred; /* XXX */
-/* VOP_OPEN(vp, FWRITE, cred, p);*/
- np = VTONW(vp);
- nmp = VFSTONWFS(vp->v_mount);
- pages = ap->a_m;
- count = ap->a_count;
- rtvals = ap->a_rtvals;
- npages = btoc(count);
-
- for (i = 0; i < npages; i++) {
- rtvals[i] = VM_PAGER_AGAIN;
- }
-
- bp = getpbuf(&nwfs_pbuf_freecnt);
- kva = (vm_offset_t) bp->b_data;
- pmap_qenter(kva, pages, npages);
-
- iov.iov_base = (caddr_t) kva;
- iov.iov_len = count;
- uio.uio_iov = &iov;
- uio.uio_iovcnt = 1;
- uio.uio_offset = IDX_TO_OFF(pages[0]->pindex);
- uio.uio_resid = count;
- uio.uio_segflg = UIO_SYSSPACE;
- uio.uio_rw = UIO_WRITE;
- uio.uio_procp = p;
- NCPVNDEBUG("ofs=%d,resid=%d\n",(int)uio.uio_offset, uio.uio_resid);
-
- error = ncp_write(NWFSTOCONN(nmp), &np->n_fh, &uio, cred);
-/* VOP_CLOSE(vp, FWRITE, cred, p);*/
- NCPVNDEBUG("paged write done: %d\n", error);
-
- pmap_qremove(kva, npages);
- relpbuf(bp, &nwfs_pbuf_freecnt);
-
- if (!error) {
- int nwritten = round_page(count - uio.uio_resid) / PAGE_SIZE;
- for (i = 0; i < nwritten; i++) {
- rtvals[i] = VM_PAGER_OK;
- pages[i]->dirty = 0;
- }
- }
- return rtvals[0];
-#endif /* NWFS_RWCACHE */
-}
-/*
- * Flush and invalidate all dirty buffers. If another process is already
- * doing the flush, just wait for completion.
- */
-int
-nwfs_vinvalbuf(vp, flags, cred, p, intrflg)
- struct vnode *vp;
- int flags;
- struct ucred *cred;
- struct proc *p;
- int intrflg;
-{
- register struct nwnode *np = VTONW(vp);
-/* struct nwmount *nmp = VTONWFS(vp);*/
- int error = 0, slpflag, slptimeo;
-
- if (vp->v_flag & VXLOCK) {
- return (0);
- }
- if (intrflg) {
- slpflag = PCATCH;
- slptimeo = 2 * hz;
- } else {
- slpflag = 0;
- slptimeo = 0;
- }
- while (np->n_flag & NFLUSHINPROG) {
- np->n_flag |= NFLUSHWANT;
- error = tsleep((caddr_t)&np->n_flag, PRIBIO + 2, "nwfsvinv", slptimeo);
- error = ncp_chkintr(NWFSTOCONN(VTONWFS(vp)), p);
- if (error == EINTR && intrflg)
- return EINTR;
- }
- np->n_flag |= NFLUSHINPROG;
- error = vinvalbuf(vp, flags, cred, p, slpflag, 0);
- while (error) {
- if (intrflg && (error == ERESTART || error == EINTR)) {
- np->n_flag &= ~NFLUSHINPROG;
- if (np->n_flag & NFLUSHWANT) {
- np->n_flag &= ~NFLUSHWANT;
- wakeup((caddr_t)&np->n_flag);
- }
- return EINTR;
- }
- error = vinvalbuf(vp, flags, cred, p, slpflag, 0);
- }
- np->n_flag &= ~(NMODIFIED | NFLUSHINPROG);
- if (np->n_flag & NFLUSHWANT) {
- np->n_flag &= ~NFLUSHWANT;
- wakeup((caddr_t)&np->n_flag);
- }
- return (error);
-}
diff --git a/sys/fs/nwfs/nwfs_ioctl.c b/sys/fs/nwfs/nwfs_ioctl.c
deleted file mode 100644
index 1892cef8d872..000000000000
--- a/sys/fs/nwfs/nwfs_ioctl.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (c) 1999, Boris Popov
- * 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 Boris Popov.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/buf.h>
-#include <sys/proc.h>
-#include <sys/mount.h>
-#include <sys/vnode.h>
-#include <sys/ioccom.h>
-
-#include <netncp/ncp.h>
-#include <netncp/ncp_conn.h>
-#include <netncp/ncp_subr.h>
-
-#include <nwfs/nwfs.h>
-#include <nwfs/nwfs_node.h>
-#include <nwfs/nwfs_subr.h>
-
-int
-nwfs_ioctl(ap)
- struct vop_ioctl_args /* {
- struct vnode *a_vp;
- u_long a_command;
- caddr_t a_data;
- int fflag;
- struct ucred *cred;
- struct proc *p;
- } */ *ap;
-{
- int error;
- struct proc *p = ap->a_p;
- struct ucred *cred = ap->a_cred;
- struct vnode *vp = ap->a_vp;
- struct nwnode *np = VTONW(vp);
- struct nwmount *nmp = VTONWFS(vp);
- struct ncp_conn *conn = NWFSTOCONN(nmp);
- struct ncp_handle *hp;
- struct nw_entry_info *fap;
- void *data = ap->a_data;
-
- switch (ap->a_command) {
- case NWFSIOC_GETCONN:
- error = ncp_conn_lock(conn, p, cred, NCPM_READ);
- if (error) break;
- error = ncp_conn_gethandle(conn, p, &hp);
- ncp_conn_unlock(conn, p);
- if (error) break;
- *(int*)data = hp->nh_id;
- break;
- case NWFSIOC_GETEINFO:
- if ((error = VOP_ACCESS(vp, VEXEC, cred, p))) break;
- fap = data;
- error = ncp_obtain_info(nmp, np->n_fid.f_id, 0, NULL, fap,
- ap->a_p,ap->a_cred);
- strcpy(fap->entryName, np->n_name);
- fap->nameLen = np->n_nmlen;
- break;
- case NWFSIOC_GETNS:
- if ((error = VOP_ACCESS(vp, VEXEC, cred, p))) break;
- *(int*)data = nmp->name_space;
- break;
- default:
- error = EINVAL;
- }
- return (error);
-}
diff --git a/sys/fs/nwfs/nwfs_mount.h b/sys/fs/nwfs/nwfs_mount.h
deleted file mode 100644
index 613e6856fe35..000000000000
--- a/sys/fs/nwfs/nwfs_mount.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 1999, Boris Popov
- * 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 Boris Popov.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#ifndef _NWFS_MOUNT_H_
-#define _NWFS_MOUNT_H_
-
-#ifndef _NCP_NCP_NLS_H_
-#include <netncp/ncp_nls.h>
-#endif
-
-#define NWFS_VERMAJ 1
-#define NWFS_VERMIN 3400
-#define NWFS_VERSION (NWFS_VERMAJ*100000 + NWFS_VERMIN)
-
-/* Values for flags */
-#define NWFS_MOUNT_SOFT 0x0001
-#define WNFS_MOUNT_INTR 0x0002
-#define NWFS_MOUNT_STRONG 0x0004
-#define NWFS_MOUNT_NO_OS2 0x0008
-#define NWFS_MOUNT_NO_NFS 0x0010
-#define NWFS_MOUNT_NO_LONG 0x0020
-#define NWFS_MOUNT_GET_SYSENT 0x0040 /* special case, look to vfsops :) */
-#define NWFS_MOUNT_HAVE_NLS 0x0080
-
-#define NWFS_VOLNAME_LEN 48
-
-
-/* Layout of the mount control block for a netware file system. */
-struct nwfs_args {
- int connRef; /* connection reference */
- char mount_point[MAXPATHLEN];
- u_int flags;
- u_char mounted_vol[NWFS_VOLNAME_LEN + 1];
- u_char root_path[512+1];
- int version;
- uid_t uid;
- gid_t gid;
- mode_t file_mode;
- mode_t dir_mode;
- struct ncp_nlstables nls;
-};
-
-#ifdef _KERNEL
-
-#ifdef MALLOC_DECLARE
-MALLOC_DECLARE(M_NWFSMNT);
-#endif
-
-#endif
-#endif /* !_NWFS_MOUNT_H_ */
diff --git a/sys/fs/nwfs/nwfs_node.c b/sys/fs/nwfs/nwfs_node.c
deleted file mode 100644
index 223143ec84a5..000000000000
--- a/sys/fs/nwfs/nwfs_node.c
+++ /dev/null
@@ -1,316 +0,0 @@
-/*
- * Copyright (c) 1999, Boris Popov
- * 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 Boris Popov.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/time.h>
-#include <sys/proc.h>
-#include <sys/mount.h>
-#include <sys/vnode.h>
-#include <sys/malloc.h>
-#include <sys/sysctl.h>
-#include <vm/vm.h>
-#include <vm/vm_extern.h>
-#include <vm/vm_page.h>
-#include <vm/vm_object.h>
-#include <sys/queue.h>
-
-#include <netncp/ncp.h>
-#include <netncp/ncp_conn.h>
-#include <netncp/ncp_subr.h>
-
-#include <nwfs/nwfs.h>
-#include <nwfs/nwfs_mount.h>
-#include <nwfs/nwfs_node.h>
-#include <nwfs/nwfs_subr.h>
-
-#define NWNOHASH(fhsum) (&nwhashtbl[(fhsum.f_id) & nwnodehash])
-
-extern vop_t **nwfs_vnodeop_p;
-
-static LIST_HEAD(nwnode_hash_head,nwnode) *nwhashtbl;
-static u_long nwnodehash;
-static int nwhashlock = 0;
-
-MALLOC_DEFINE(M_NWNODE, "NWFS node", "NWFS vnode private part");
-MALLOC_DEFINE(M_NWFSHASH, "NWFS hash", "NWFS has table");
-
-static int nwfs_sysctl_vnprint SYSCTL_HANDLER_ARGS;
-
-extern struct linker_set sysctl_vfs_nwfs;
-
-SYSCTL_DECL(_vfs_nwfs);
-
-SYSCTL_PROC(_vfs_nwfs, OID_AUTO, vnprint, CTLFLAG_WR|CTLTYPE_OPAQUE,
- NULL, 0, nwfs_sysctl_vnprint, "S,vnlist", "vnode hash");
-
-void
-nwfs_hash_init(void) {
- nwhashtbl = hashinit(desiredvnodes, M_NWFSHASH, &nwnodehash);
-}
-
-void
-nwfs_hash_free(void) {
- free(nwhashtbl, M_NWFSHASH);
-}
-
-int
-nwfs_sysctl_vnprint SYSCTL_HANDLER_ARGS {
- struct nwnode *np;
- struct nwnode_hash_head *nhpp;
- struct vnode *vp;
- int i;
-
- if (nwfs_debuglevel == 0)
- return 0;
- printf("Name:uc:hc:fid:pfid\n");
- for(i = 0; i <= nwnodehash; i++) {
- nhpp = &nwhashtbl[i];
- for (np = nhpp->lh_first; np != 0; np = np->n_hash.le_next) {
- vp = NWTOV(np);
- printf("%s:%d:%d:%d:%d\n",np->n_name,vp->v_usecount,vp->v_holdcnt,
- np->n_fid.f_id, np->n_fid.f_parent);
- }
- }
- return 0;
-}
-
-/*
- * Allocate new nwfsnode/vnode from given nwnode.
- * Vnode referenced and not locked.
- */
-int
-nwfs_allocvp(struct mount *mp, ncpfid fid, struct vnode **vpp) {
- struct proc *p = curproc; /* XXX */
- struct nwnode *np, *np2;
- struct nwnode_hash_head *nhpp;
- struct vnode *vp;
- int error;
-
-retry:
- nhpp = NWNOHASH(fid);
-loop:
- for (np = nhpp->lh_first; np != 0; np = np->n_hash.le_next) {
- vp = NWTOV(np);
- if (mp != vp->v_mount || !NWCMPF(&fid, &np->n_fid))
- continue;
- if (vget(vp, LK_EXCLUSIVE, p))
- goto loop;
- *vpp = vp;
- return(0);
- }
-
- /* lock list, or waiting in malloc can cause problems */
- if (nwhashlock) {
- while(nwhashlock) {
- nwhashlock = -1;
- tsleep((caddr_t) &nwhashlock, PVM, "nwfsvp", 0);
- }
- goto loop;
- }
- nwhashlock = 1;
- /*
- * Do the MALLOC before the getnewvnode since doing so afterward
- * might cause a bogus v_data pointer to get dereferenced
- * elsewhere if MALLOC should block.
- */
- MALLOC(np, struct nwnode *, sizeof *np, M_NWNODE, M_WAITOK);
- error = getnewvnode(VT_NWFS, mp, nwfs_vnodeop_p, &vp);
- if (error) {
- if (nwhashlock < 0)
- wakeup(&nwhashlock);
- nwhashlock = 0;
- *vpp = 0;
- FREE(np, M_NWNODE);
- return (error);
- }
- *vpp = vp;
- bzero(np,sizeof(*np));
- vp->v_data = np;
- np->n_vnode = vp;
- np->n_mount = VFSTONWFS(mp);
- np->n_fid = fid;
- for (np2 = nhpp->lh_first; np2 != 0; np2 = np->n_hash.le_next) {
- if (mp != NWTOV(np2)->v_mount || !NWCMPF(&fid, &np2->n_fid))
- continue;
- vrele(vp);
- FREE(np, M_NWNODE);
- if (nwhashlock < 0)
- wakeup(&nwhashlock);
- nwhashlock = 0;
- goto retry;
- }
- LIST_INSERT_HEAD(nhpp, np, n_hash);
- if (nwhashlock < 0)
- wakeup(&nwhashlock);
- nwhashlock = 0;
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
- np->n_flag |= NNEW;
- return (error);
-}
-
-int
-nwfs_lookupnp(struct nwmount *nmp, ncpfid fid, struct nwnode **npp) {
- struct nwnode *np;
- struct nwnode_hash_head *nhpp;
-
- nhpp = NWNOHASH(fid);
- for (np = nhpp->lh_first; np != 0; np = np->n_hash.le_next) {
- if (nmp != np->n_mount || !NWCMPF(&fid, &np->n_fid))
- continue;
- *npp = np;
- return(0);
- }
- return ENOENT;
-}
-
-/*
- * Free nwnode, and give vnode back to system
- */
-int
-nwfs_reclaim(ap)
- struct vop_reclaim_args /* {
- struct vnode *a_vp;
- } */ *ap;
-{
- struct vnode *dvp = NULL, *vp = ap->a_vp;
- struct nwnode *dnp, *np = VTONW(vp);
- struct nwmount *nmp=VTONWFS(vp);
-
- NCPVNDEBUG("%s,%d\n", np->n_name, vp->v_usecount);
- if (np->n_refparent) {
- np->n_refparent = 0;
- if (nwfs_lookupnp(nmp, np->n_parent, &dnp) == 0) {
- dvp = dnp->n_vnode;
- } else {
- NCPVNDEBUG("%s: has no parent ?\n",np->n_name);
- }
- }
- LIST_REMOVE(np, n_hash);
- cache_purge(vp);
- if (nmp->n_root == np) {
- nmp->n_root = NULL;
- }
- vp->v_data = NULL;
- FREE(np, M_NWNODE);
- if (dvp) {
- vrele(dvp);
- }
- return (0);
-}
-
-int
-nwfs_inactive(ap)
- struct vop_inactive_args /* {
- struct vnode *a_vp;
- struct proc *a_p;
- } */ *ap;
-{
- struct proc *p = ap->a_p;
- struct ucred *cred = p->p_ucred;
- struct vnode *vp = ap->a_vp;
- struct nwnode *np = VTONW(vp);
- int error;
-
- NCPVNDEBUG("%s: %d\n", VTONW(vp)->n_name, vp->v_usecount);
- if (np->opened) {
- error = nwfs_vinvalbuf(vp, V_SAVE, cred, p, 1);
- error = ncp_close_file(NWFSTOCONN(VTONWFS(vp)), &np->n_fh, p, cred);
- np->opened = 0;
- }
- VOP_UNLOCK(vp, 0, p);
- return (0);
-}
-/*
- * routines to maintain vnode attributes cache
- * nwfs_attr_cacheenter: unpack np.i to va structure
- */
-void
-nwfs_attr_cacheenter(struct vnode *vp, struct nw_entry_info *fi) {
- struct nwnode *np = VTONW(vp);
- struct nwmount *nmp = VTONWFS(vp);
- register struct vattr *va = &np->n_vattr;
-
- va->va_type = vp->v_type; /* vnode type (for create) */
- if (vp->v_type == VREG) {
- if (va->va_size != fi->dataStreamSize) {
- va->va_size = fi->dataStreamSize;
- vnode_pager_setsize(vp, va->va_size);
- }
- va->va_mode = nmp->m.file_mode; /* files access mode and type */
- } else if (vp->v_type == VDIR) {
- va->va_size = 16384; /* should be a better way ... */
- va->va_mode = nmp->m.dir_mode; /* files access mode and type */
- } else
- return;
- np->n_size = va->va_size;
- va->va_nlink = 1; /* number of references to file */
- va->va_uid = nmp->m.uid; /* owner user id */
- va->va_gid = nmp->m.gid; /* owner group id */
- va->va_fsid = vp->v_mount->mnt_stat.f_fsid.val[0];
- va->va_fileid = np->n_fid.f_id; /* file id */
- if (va->va_fileid == 0)
- va->va_fileid = NWFS_ROOT_INO;
- va->va_blocksize=nmp->connh->nh_conn->buffer_size;/* blocksize preferred for i/o */
- /* time of last modification */
- ncp_dos2unixtime(fi->modifyDate, fi->modifyTime, 0, &va->va_mtime);
- /* time of last access */
- ncp_dos2unixtime(fi->lastAccessDate, 0, 0, &va->va_atime);
- va->va_ctime = va->va_mtime; /* time file changed */
- va->va_gen = VNOVAL; /* generation number of file */
- va->va_flags = 0; /* flags defined for file */
- va->va_rdev = VNOVAL; /* device the special file represents */
- va->va_bytes = va->va_size; /* bytes of disk space held by file */
- va->va_filerev = 0; /* file modification number */
- va->va_vaflags = 0; /* operations flags */
- np->n_vattr = *va;
- if (np->n_mtime == 0) {
- np->n_mtime = va->va_mtime.tv_sec;
- }
- np->n_atime = time_second;
- return;
-}
-
-int
-nwfs_attr_cachelookup(struct vnode *vp, struct vattr *va) {
- struct nwnode *np = VTONW(vp);
- int diff;
-
- diff = time_second - np->n_atime;
- if (diff > 2) { /* XXX should be configurable */
- return ENOENT;
- }
- *va = np->n_vattr;
- return 0;
-}
diff --git a/sys/fs/nwfs/nwfs_node.h b/sys/fs/nwfs/nwfs_node.h
deleted file mode 100644
index 3777679c7c64..000000000000
--- a/sys/fs/nwfs/nwfs_node.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (c) 1999, Boris Popov
- * 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 Boris Popov.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#ifndef _NWFS_NODE_H_
-#define _NWFS_NODE_H_
-
-#define NWFS_ROOT_INO 0x7ffffffd
-#define NWFS_ROOTVOL "#.ROOT"
-
-/* Bits for nwnode.n_flag */
-#define NFLUSHINPROG 0x0001
-#define NFLUSHWANT 0x0002 /* they should gone ... */
-#define NMODIFIED 0x0004 /* bogus, until async IO implemented */
-#define NNEW 0x0008 /* vnode has been allocated */
-#define NVOLUME 0x0010 /* vnode references a volume */
-
-struct nwnode {
- LIST_ENTRY(nwnode) n_hash;
- struct vnode *n_vnode;
- struct vattr n_vattr;
- struct nwmount *n_mount;
- time_t n_atime; /* attributes cache time*/
- time_t n_ctime;
- time_t n_mtime;
- int n_flag;
- ncpfid n_parent;
- ncpfid n_fid;
- int n_refparent;
- u_long n_attr; /* LH */
- u_long n_size;
- u_long n_dosfid;
- int opened;
-/* int access;*/
- u_long n_origfh;
- ncp_fh n_fh;
- struct nw_search_seq n_seq;
- u_char n_nmlen;
- u_char n_name[256];
-};
-
-#define VTONW(vp) ((struct nwnode *)(vp)->v_data)
-#define NWTOV(np) ((struct vnode *)(np)->n_vnode)
-#define NWCMPF(f1,f2) ((f1)->f_parent == (f2)->f_parent && \
- (f1)->f_id == (f2)->f_id)
-#define NWCMPN(np1,np2) NWCMPF(&(np1)->n_fid, &(np2)->n_fid)
-#define NWCMPV(vp1,vp2) NWCMPN(VTONW(vp1),VTONW(vp2))
-
-struct vop_getpages_args;
-struct vop_inactive_args;
-struct vop_putpages_args;
-struct vop_reclaim_args;
-struct ucred;
-struct uio;
-
-void nwfs_hash_init(void);
-void nwfs_hash_free(void);
-int nwfs_allocvp(struct mount *mp, ncpfid fid, struct vnode **vpp);
-int nwfs_lookupnp(struct nwmount *nmp, ncpfid fid, struct nwnode **npp);
-int nwfs_inactive __P((struct vop_inactive_args *));
-int nwfs_reclaim __P((struct vop_reclaim_args *));
-int nwfs_nget(struct mount *mp, ncpfid fid, struct nw_entry_info *fap,
- struct vnode *dvp, struct vnode **vpp);
-
-int nwfs_getpages __P((struct vop_getpages_args *));
-int nwfs_putpages __P((struct vop_putpages_args *));
-int nwfs_readvnode(struct vnode *vp, struct uio *uiop, struct ucred *cred);
-int nwfs_writevnode(struct vnode *vp, struct uio *uiop, struct ucred *cred, int ioflag);
-void nwfs_attr_cacheenter(struct vnode *vp, struct nw_entry_info *fi);
-int nwfs_attr_cachelookup(struct vnode *vp,struct vattr *va);
-
-#define nwfs_attr_cacheremove(vp) VTONW(vp)->n_atime = 0
-
-#endif /* _NWFS_NODE_H_ */
diff --git a/sys/fs/nwfs/nwfs_subr.c b/sys/fs/nwfs/nwfs_subr.c
deleted file mode 100644
index 9ba8b312b1bc..000000000000
--- a/sys/fs/nwfs/nwfs_subr.c
+++ /dev/null
@@ -1,666 +0,0 @@
-/*
- * Copyright (c) 1999, Boris Popov
- * 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 Boris Popov.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/malloc.h>
-#include <machine/clock.h>
-#include <sys/time.h>
-
-#include <netncp/ncp.h>
-#include <netncp/ncp_conn.h>
-#include <netncp/ncp_ncp.h>
-#include <netncp/ncp_subr.h>
-#include <netncp/ncp_rq.h>
-#include <netncp/nwerror.h>
-
-#include <nwfs/nwfs.h>
-#include <nwfs/nwfs_node.h>
-#include <nwfs/nwfs_subr.h>
-
-MALLOC_DEFINE(M_NWFSDATA, "NWFS data", "NWFS private data");
-
-static void
-ncp_extract_file_info(struct nwmount *nmp, struct ncp_rq *rqp, struct nw_entry_info *target) {
- u_char name_len;
- const int info_struct_size = sizeof(struct nw_entry_info) - 257;
-
- ncp_rp_mem(rqp,(caddr_t)target,info_struct_size);
- name_len = ncp_rp_byte(rqp);
- target->nameLen = name_len;
- ncp_rp_mem(rqp,(caddr_t)target->entryName, name_len);
- target->entryName[name_len] = '\0';
- ncp_path2unix(target->entryName, target->entryName, name_len, &nmp->m.nls);
- return;
-}
-
-static void
-ncp_update_file_info(struct nwmount *nmp, struct ncp_rq *rqp,
- struct nw_entry_info *target)
-{
- int info_struct_size = sizeof(struct nw_entry_info) - 257;
-
- ncp_rp_mem(rqp,(caddr_t)target,info_struct_size);
- return;
-}
-
-int
-ncp_initsearch(struct vnode *dvp,struct proc *p,struct ucred *cred)
-{
- struct nwmount *nmp = VTONWFS(dvp);
- struct ncp_conn *conn = NWFSTOCONN(nmp);
- struct nwnode *np = VTONW(dvp);
- u_int8_t volnum = nmp->n_volume;
- u_int32_t dirent = np->n_fid.f_id;
- int error;
- DECLARE_RQ;
-
- NCPNDEBUG("vol=%d,dir=%d\n", volnum, dirent);
- NCP_RQ_HEAD(87,p,cred);
- ncp_rq_byte(rqp, 2); /* subfunction */
- ncp_rq_byte(rqp, nmp->name_space);
- ncp_rq_byte(rqp, 0); /* reserved */
- ncp_rq_dbase_path(rqp, volnum, dirent, 0, NULL, NULL);
- checkbad(ncp_request(conn,rqp));
- ncp_rp_mem(rqp,(caddr_t)&np->n_seq, sizeof(np->n_seq));
- NCP_RQ_EXIT;
- return error;
-}
-
-int
-ncp_search_for_file_or_subdir(struct nwmount *nmp,
- struct nw_search_seq *seq,
- struct nw_entry_info *target,
- struct proc *p,struct ucred *cred)
-{
- struct ncp_conn *conn = NWFSTOCONN(nmp);
- int error;
- DECLARE_RQ;
-
- NCP_RQ_HEAD(87,p,cred);
- ncp_rq_byte(rqp, 3); /* subfunction */
- ncp_rq_byte(rqp, nmp->name_space);
- ncp_rq_byte(rqp, 0); /* data stream */
- ncp_rq_word_lh(rqp, 0xffff); /* Search attribs */
- ncp_rq_dword(rqp, IM_ALL); /* return info mask */
- ncp_rq_mem(rqp, (caddr_t)seq, 9);
- ncp_rq_byte(rqp, 2); /* 2 byte pattern */
- ncp_rq_byte(rqp, 0xff); /* following is a wildcard */
- ncp_rq_byte(rqp, '*');
- checkbad(ncp_request(conn,rqp));
- ncp_rp_mem(rqp,(caddr_t)seq, sizeof(*seq));
- ncp_rp_byte(rqp); /* skip */
- ncp_extract_file_info(nmp, rqp, target);
- NCP_RQ_EXIT;
- return error;
-}
-
-/*
- * Returns information for a (one-component) name relative to the specified
- * directory.
- */
-int
-ncp_obtain_info(struct nwmount *nmp, u_int32_t dirent,
- int namelen, char *path, struct nw_entry_info *target,
- struct proc *p,struct ucred *cred)
-{
- struct ncp_conn *conn=NWFSTOCONN(nmp);
- int error;
- u_char volnum = nmp->n_volume, ns;
- DECLARE_RQ;
-
- if (target == NULL) {
- NCPFATAL("target == NULL\n");
- return EINVAL;
- }
- ns = (path == NULL || path[0] == 0) ? NW_NS_DOS : nmp->name_space;
- NCP_RQ_HEAD(87, p, cred);
- ncp_rq_byte(rqp, 6); /* subfunction */
- ncp_rq_byte(rqp, ns);
- ncp_rq_byte(rqp, ns); /* DestNameSpace */
- ncp_rq_word(rqp, htons(0xff00)); /* get all */
- ncp_rq_dword(rqp, IM_ALL);
- ncp_rq_dbase_path(rqp, volnum, dirent, namelen, path, &nmp->m.nls);
- checkbad(ncp_request(conn,rqp));
- if (path)
- ncp_extract_file_info(nmp, rqp, target);
- else
- ncp_update_file_info(nmp, rqp, target);
- NCP_RQ_EXIT;
- return error;
-}
-/*
- * lookup name pointed by cnp in directory dvp and return file info in np.
- * May be I should create a little cache, but another way is to minimize
- * number of calls, on other hand, in multiprocess environment ...
- */
-int
-ncp_lookup(struct vnode *dvp, int len, char *name, struct nw_entry_info *fap,
- struct proc *p,struct ucred *cred)
-{
- struct nwmount *nmp;
- struct nwnode *dnp = VTONW(dvp);
- struct ncp_conn *conn;
- int error;
-
- if (!dvp || dvp->v_type != VDIR) {
- nwfs_printf("dvp is NULL or not a directory.\n");
- return (ENOENT);
- }
- nmp = VTONWFS(dvp);
- conn = NWFSTOCONN(nmp);
-
- if (len == 1 && name[0] == '.') {
- if (strcmp(dnp->n_name, NWFS_ROOTVOL) == 0) {
- error = ncp_obtain_info(nmp, dnp->n_fid.f_id, 0, NULL,
- fap, p, cred);
- } else {
- error = ncp_obtain_info(nmp, dnp->n_fid.f_parent,
- dnp->n_nmlen, dnp->n_name, fap, p, cred);
- }
- return error;
- } else if (len == 2 && name[0] == '.' && name[1] == '.') {
- printf("%s: knows NOTHING about '..'\n", __FUNCTION__);
- return EIO;
- } else {
- error = ncp_obtain_info(nmp, dnp->n_fid.f_id,
- len, name, fap, p, cred);
- }
- return error;
-}
-
-static void ConvertToNWfromDWORD(u_int32_t sfd, ncp_fh *fh);
-static void
-ConvertToNWfromDWORD(u_int32_t sfd, ncp_fh *fh) {
- fh->val1 = (fh->val.val32 = sfd);
- return;
-}
-
-/*
- * If both dir and name are NULL, then in target there's already a looked-up
- * entry that wants to be opened.
- */
-int
-ncp_open_create_file_or_subdir(struct nwmount *nmp,struct vnode *dvp,int namelen,
- char *name, int open_create_mode, u_int32_t create_attributes,
- int desired_acc_rights, struct ncp_open_info *nop,
- struct proc *p,struct ucred *cred)
-{
-
- struct ncp_conn *conn=NWFSTOCONN(nmp);
- u_int16_t search_attribs = SA_ALL & (~SA_SUBDIR_FILES);
- u_int8_t volnum;
- u_int32_t dirent;
- int error;
- DECLARE_RQ;
-
- volnum = nmp->n_volume;
- dirent = VTONW(dvp)->n_fid.f_id;
- if ((create_attributes & aDIR) != 0) {
- search_attribs |= SA_SUBDIR_FILES;
- }
- NCP_RQ_HEAD(87,p,cred);
- ncp_rq_byte(rqp, 1);/* subfunction */
- ncp_rq_byte(rqp, nmp->name_space);
- ncp_rq_byte(rqp, open_create_mode);
- ncp_rq_word(rqp, search_attribs);
- ncp_rq_dword(rqp, IM_ALL);
- ncp_rq_dword(rqp, create_attributes);
- /*
- * The desired acc rights seem to be the inherited rights mask for
- * directories
- */
- ncp_rq_word(rqp, desired_acc_rights);
- ncp_rq_dbase_path(rqp, volnum, dirent, namelen, name, &nmp->m.nls);
- checkbad(ncp_request(conn,rqp));
-
- nop->origfh = ncp_rp_dword_lh(rqp);
- nop->action = ncp_rp_byte(rqp);
- ncp_rp_byte(rqp); /* skip */
- ncp_extract_file_info(nmp, rqp, &nop->fattr);
- ConvertToNWfromDWORD(nop->origfh, &nop->fh);
- NCP_RQ_EXIT;
- switch(error) {
- case NWE_FILE_NO_CREATE_PRIV:
- error = EACCES;
- break;
- }
- return error;
-}
-
-int
-ncp_close_file(struct ncp_conn *conn, ncp_fh *fh,struct proc *p,struct ucred *cred) {
- int error;
- DECLARE_RQ;
-
- NCP_RQ_HEAD(66,p,cred);
- ncp_rq_byte(rqp, 0);
- ncp_rq_mem(rqp, (caddr_t)fh, 6);
- error = ncp_request(conn,rqp);
- NCP_RQ_EXIT_NB;
- return error;
-}
-
-int
-ncp_DeleteNSEntry(struct nwmount *nmp, u_int32_t dirent,
- int namelen,char *name,struct proc *p,struct ucred *cred)
-{
- int error;
- struct ncp_conn *conn=NWFSTOCONN(nmp);
- DECLARE_RQ;
-
- NCP_RQ_HEAD(87,p,cred);
- ncp_rq_byte(rqp, 8); /* subfunction */
- ncp_rq_byte(rqp, nmp->name_space);
- ncp_rq_byte(rqp, 0); /* reserved */
- ncp_rq_word(rqp, SA_ALL); /* search attribs: all */
- ncp_rq_dbase_path(rqp, nmp->n_volume, dirent, namelen, name, &nmp->m.nls);
- error = ncp_request(conn,rqp);
- NCP_RQ_EXIT_NB;
- return error;
-}
-
-int
-ncp_nsrename(struct ncp_conn *conn, int volume, int ns, int oldtype,
- struct ncp_nlstables *nt,
- nwdirent fdir, char *old_name, int oldlen,
- nwdirent tdir, char *new_name, int newlen,
- struct proc *p, struct ucred *cred)
-{
- DECLARE_RQ;
- int error;
-
- NCP_RQ_HEAD(87,p,cred);
- ncp_rq_byte(rqp, 4);
- ncp_rq_byte(rqp, ns);
- ncp_rq_byte(rqp, 1);
- ncp_rq_word(rqp, oldtype);
- /* source Handle Path */
- ncp_rq_byte(rqp, volume);
- ncp_rq_dword(rqp, fdir);
- ncp_rq_byte(rqp, 1);
- ncp_rq_byte(rqp, 1); /* 1 source component */
- /* dest Handle Path */
- ncp_rq_byte(rqp, volume);
- ncp_rq_dword(rqp, tdir);
- ncp_rq_byte(rqp, 1);
- ncp_rq_byte(rqp, 1); /* 1 destination component */
- ncp_rq_pathstring(rqp, oldlen, old_name, nt);
- ncp_rq_pathstring(rqp, newlen, new_name, nt);
- error = ncp_request(conn,rqp);
- NCP_RQ_EXIT_NB;
- return error;
-}
-
-int
-ncp_modify_file_or_subdir_dos_info(struct nwmount *nmp, struct vnode *vp,
- u_int32_t info_mask,
- struct nw_modify_dos_info *info,
- struct proc *p,struct ucred *cred)
-{
- struct nwnode *np=VTONW(vp);
- u_int8_t volnum = nmp->n_volume;
- u_int32_t dirent = np->n_fid.f_id;
- struct ncp_conn *conn=NWFSTOCONN(nmp);
- int error;
- DECLARE_RQ;
-
- NCP_RQ_HEAD(87,p,cred);
- ncp_rq_byte(rqp, 7); /* subfunction */
- ncp_rq_byte(rqp, nmp->name_space);
- ncp_rq_byte(rqp, 0); /* reserved */
- ncp_rq_word(rqp, htons(0x0680)); /* search attribs: all */
- ncp_rq_dword(rqp, info_mask);
- ncp_rq_mem(rqp, (caddr_t)info, sizeof(*info));
- ncp_rq_dbase_path(rqp, volnum, dirent, 0, NULL, NULL);
- error = ncp_request(conn,rqp);
- NCP_RQ_EXIT_NB;
- return error;
-}
-
-int
-ncp_setattr(vp, vap, cred, procp)
- register struct vnode *vp;
- register struct vattr *vap;
- struct ucred *cred;
- struct proc *procp;
-{
- struct nwmount *nmp=VTONWFS(vp);
- struct nwnode *np=VTONW(vp);
- struct ncp_open_info nwn;
- struct ncp_conn *conn=NWFSTOCONN(nmp);
- struct nw_modify_dos_info info;
- int error = 0, info_mask;
- DECLARE_RQ;
-
- if (vap->va_size != VNOVAL) {
- error = ncp_open_create_file_or_subdir(nmp, vp, 0, NULL, OC_MODE_OPEN, 0,
- AR_WRITE | AR_READ, &nwn,procp,cred);
- if (error) return error;
- NCP_RQ_HEAD(73,procp,cred);
- ncp_rq_byte(rqp, 0);
- ncp_rq_mem(rqp, (caddr_t)&nwn.fh, 6);
- ncp_rq_dword(rqp, htonl(vap->va_size));
- ncp_rq_word_hl(rqp, 0);
- checkbad(ncp_request(conn,rqp));
- np->n_vattr.va_size = np->n_size = vap->va_size;
- NCP_RQ_EXIT;
- ncp_close_file(conn, &nwn.fh, procp, cred);
- if (error) return error;
- }
- info_mask = 0;
- bzero(&info, sizeof(info));
-
- if (vap->va_mtime.tv_sec != VNOVAL) {
- info_mask |= (DM_MODIFY_TIME | DM_MODIFY_DATE);
- ncp_unix2dostime(&vap->va_mtime, &info.modifyDate, &info.modifyTime, NULL);
- }
- if (vap->va_atime.tv_sec != VNOVAL) {
- info_mask |= (DM_LAST_ACCESS_DATE);
- ncp_unix2dostime(&vap->va_atime, &info.lastAccessDate,NULL,NULL);
- }
- if (info_mask) {
- error = ncp_modify_file_or_subdir_dos_info(nmp, vp, info_mask, &info,procp,cred);
- }
- return (error);
-}
-
-int
-ncp_get_volume_info_with_number(struct ncp_conn *conn,
- int n, struct ncp_volume_info *target,
- struct proc *p,struct ucred *cred) {
- int error,len;
- DECLARE_RQ;
-
- NCP_RQ_HEAD_S(22,44,p,cred);
- ncp_rq_byte(rqp,n);
- checkbad(ncp_request(conn,rqp));
- target->total_blocks = ncp_rp_dword_lh(rqp);
- target->free_blocks = ncp_rp_dword_lh(rqp);
- target->purgeable_blocks = ncp_rp_dword_lh(rqp);
- target->not_yet_purgeable_blocks = ncp_rp_dword_lh(rqp);
- target->total_dir_entries = ncp_rp_dword_lh(rqp);
- target->available_dir_entries = ncp_rp_dword_lh(rqp);
- ncp_rp_dword_lh(rqp);
- target->sectors_per_block = ncp_rp_byte(rqp);
- bzero(&target->volume_name, sizeof(target->volume_name));
- len = ncp_rp_byte(rqp);
- if (len > NCP_VOLNAME_LEN) {
- error = ENAMETOOLONG;
- } else {
- ncp_rp_mem(rqp,(caddr_t)&target->volume_name, len);
- }
- NCP_RQ_EXIT;
- return error;
-}
-
-int
-ncp_get_namespaces(struct ncp_conn *conn, u_int32_t volume, int *nsf,
- struct proc *p,struct ucred *cred) {
- int error;
- u_int8_t ns;
- u_int16_t nscnt;
- DECLARE_RQ;
-
- NCP_RQ_HEAD(87,p,cred);
- ncp_rq_byte(rqp, 24); /* Subfunction: Get Loaded Name Spaces */
- ncp_rq_word(rqp, 0);
- ncp_rq_byte(rqp, volume);
- checkbad(ncp_request(conn,rqp));
- nscnt = ncp_rp_word_lh(rqp);
- *nsf = 0;
- while (nscnt-- > 0) {
- ns = ncp_rp_byte(rqp);
- *nsf |= 1 << ns;
- }
- NCP_RQ_EXIT;
- return error;
-}
-
-int
-ncp_lookup_volume(struct ncp_conn *conn, char *volname,
- u_char *volNum, u_int32_t *dirEnt,
- struct proc *p,struct ucred *cred)
-{
- int error;
- DECLARE_RQ;
-
- NCPNDEBUG("looking up vol %s\n", volname);
- NCP_RQ_HEAD(87,p,cred);
- ncp_rq_byte(rqp, 22); /* Subfunction: Generate dir handle */
- ncp_rq_byte(rqp, 0); /* src name space */
- ncp_rq_byte(rqp, 0); /* dst name space, always zero */
- ncp_rq_word(rqp, 0); /* dstNSIndicator */
-
- ncp_rq_byte(rqp, 0); /* faked volume number */
- ncp_rq_dword(rqp, 0); /* faked dir_base */
- ncp_rq_byte(rqp, 0xff); /* Don't have a dir_base */
- ncp_rq_byte(rqp, 1); /* 1 path component */
- ncp_rq_pstring(rqp, volname);
- checkbad(ncp_request(conn,rqp));
- ncp_rp_dword_lh(rqp); /* NSDirectoryBase*/
- *dirEnt = ncp_rp_dword_lh(rqp);
- *volNum = ncp_rp_byte(rqp);
- NCP_RQ_EXIT;
- return error;
-}
-
-/*
- * Time & date conversion routines taken from msdosfs. Although leap
- * year calculation is bogus, it's sufficient before 2100 :)
- */
-/*
- * This is the format of the contents of the deTime field in the direntry
- * structure.
- * We don't use bitfields because we don't know how compilers for
- * arbitrary machines will lay them out.
- */
-#define DT_2SECONDS_MASK 0x1F /* seconds divided by 2 */
-#define DT_2SECONDS_SHIFT 0
-#define DT_MINUTES_MASK 0x7E0 /* minutes */
-#define DT_MINUTES_SHIFT 5
-#define DT_HOURS_MASK 0xF800 /* hours */
-#define DT_HOURS_SHIFT 11
-
-/*
- * This is the format of the contents of the deDate field in the direntry
- * structure.
- */
-#define DD_DAY_MASK 0x1F /* day of month */
-#define DD_DAY_SHIFT 0
-#define DD_MONTH_MASK 0x1E0 /* month */
-#define DD_MONTH_SHIFT 5
-#define DD_YEAR_MASK 0xFE00 /* year - 1980 */
-#define DD_YEAR_SHIFT 9
-/*
- * Total number of days that have passed for each month in a regular year.
- */
-static u_short regyear[] = {
- 31, 59, 90, 120, 151, 181,
- 212, 243, 273, 304, 334, 365
-};
-
-/*
- * Total number of days that have passed for each month in a leap year.
- */
-static u_short leapyear[] = {
- 31, 60, 91, 121, 152, 182,
- 213, 244, 274, 305, 335, 366
-};
-
-/*
- * Variables used to remember parts of the last time conversion. Maybe we
- * can avoid a full conversion.
- */
-static u_long lasttime;
-static u_long lastday;
-static u_short lastddate;
-static u_short lastdtime;
-/*
- * Convert the unix version of time to dos's idea of time to be used in
- * file timestamps. The passed in unix time is assumed to be in GMT.
- */
-void
-ncp_unix2dostime(tsp, ddp, dtp, dhp)
- struct timespec *tsp;
- u_int16_t *ddp;
- u_int16_t *dtp;
- u_int8_t *dhp;
-{
- u_long t;
- u_long days;
- u_long inc;
- u_long year;
- u_long month;
- u_short *months;
-
- /*
- * If the time from the last conversion is the same as now, then
- * skip the computations and use the saved result.
- */
- t = tsp->tv_sec - (tz.tz_minuteswest * 60)
- - (wall_cmos_clock ? adjkerntz : 0);
- /* - daylight savings time correction */
- t &= ~1;
- if (lasttime != t) {
- lasttime = t;
- lastdtime = (((t / 2) % 30) << DT_2SECONDS_SHIFT)
- + (((t / 60) % 60) << DT_MINUTES_SHIFT)
- + (((t / 3600) % 24) << DT_HOURS_SHIFT);
-
- /*
- * If the number of days since 1970 is the same as the last
- * time we did the computation then skip all this leap year
- * and month stuff.
- */
- days = t / (24 * 60 * 60);
- if (days != lastday) {
- lastday = days;
- for (year = 1970;; year++) {
- inc = year & 0x03 ? 365 : 366;
- if (days < inc)
- break;
- days -= inc;
- }
- months = year & 0x03 ? regyear : leapyear;
- for (month = 0; days >= months[month]; month++)
- ;
- if (month > 0)
- days -= months[month - 1];
- lastddate = ((days + 1) << DD_DAY_SHIFT)
- + ((month + 1) << DD_MONTH_SHIFT);
- /*
- * Remember dos's idea of time is relative to 1980.
- * unix's is relative to 1970. If somehow we get a
- * time before 1980 then don't give totally crazy
- * results.
- */
- if (year > 1980)
- lastddate += (year - 1980) << DD_YEAR_SHIFT;
- }
- }
- if (dtp)
- *dtp = lastdtime;
- if (dhp)
- *dhp = (tsp->tv_sec & 1) * 100 + tsp->tv_nsec / 10000000;
-
- *ddp = lastddate;
-}
-
-/*
- * The number of seconds between Jan 1, 1970 and Jan 1, 1980. In that
- * interval there were 8 regular years and 2 leap years.
- */
-#define SECONDSTO1980 (((8 * 365) + (2 * 366)) * (24 * 60 * 60))
-
-static u_short lastdosdate;
-static u_long lastseconds;
-
-/*
- * Convert from dos' idea of time to unix'. This will probably only be
- * called from the stat(), and fstat() system calls and so probably need
- * not be too efficient.
- */
-void
-ncp_dos2unixtime(dd, dt, dh, tsp)
- u_int dd;
- u_int dt;
- u_int dh;
- struct timespec *tsp;
-{
- u_long seconds;
- u_long month;
- u_long year;
- u_long days;
- u_short *months;
-
- if (dd == 0) {
- /*
- * Uninitialized field, return the epoch.
- */
- tsp->tv_sec = 0;
- tsp->tv_nsec = 0;
- return;
- }
- seconds = (((dt & DT_2SECONDS_MASK) >> DT_2SECONDS_SHIFT) << 1)
- + ((dt & DT_MINUTES_MASK) >> DT_MINUTES_SHIFT) * 60
- + ((dt & DT_HOURS_MASK) >> DT_HOURS_SHIFT) * 3600
- + dh / 100;
- /*
- * If the year, month, and day from the last conversion are the
- * same then use the saved value.
- */
- if (lastdosdate != dd) {
- lastdosdate = dd;
- days = 0;
- year = (dd & DD_YEAR_MASK) >> DD_YEAR_SHIFT;
- days = year * 365;
- days += year / 4 + 1; /* add in leap days */
- if ((year & 0x03) == 0)
- days--; /* if year is a leap year */
- months = year & 0x03 ? regyear : leapyear;
- month = (dd & DD_MONTH_MASK) >> DD_MONTH_SHIFT;
- if (month < 1 || month > 12) {
- month = 1;
- }
- if (month > 1)
- days += months[month - 2];
- days += ((dd & DD_DAY_MASK) >> DD_DAY_SHIFT) - 1;
- lastseconds = (days * 24 * 60 * 60) + SECONDSTO1980;
- }
- tsp->tv_sec = seconds + lastseconds + (tz.tz_minuteswest * 60)
- + adjkerntz;
- /* + daylight savings time correction */
- tsp->tv_nsec = (dh % 100) * 10000000;
-}
diff --git a/sys/fs/nwfs/nwfs_subr.h b/sys/fs/nwfs/nwfs_subr.h
deleted file mode 100644
index acec92c48d0f..000000000000
--- a/sys/fs/nwfs/nwfs_subr.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (c) 1999, Boris Popov
- * 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 Boris Popov.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#ifndef _NWFS_SUBR_H_
-#define _NWFS_SUBR_H_
-
-extern int nwfs_debuglevel;
-
-#ifdef MALLOC_DECLARE
-MALLOC_DECLARE(M_NWFSDATA);
-#endif
-
-struct ncp_conn;
-struct ncp_nlstables;
-struct ncp_open_info;
-struct nw_entry_info;
-struct nw_search_info;
-struct nwmount;
-struct proc;
-struct timespec;
-struct ucred;
-struct vattr;
-struct vnode;
-
-int ncp_initsearch(struct vnode *dvp,struct proc *p,struct ucred *cred);
-int ncp_search_for_file_or_subdir(struct nwmount *nmp,struct nw_search_seq *seq,
- struct nw_entry_info *target,
- struct proc *p,struct ucred *cred);
-int ncp_lookup(struct vnode *dvp, int len, char *name, struct nw_entry_info *fap,
- struct proc *p,struct ucred *cred);
-int ncp_lookup_volume(struct ncp_conn *conn, char *volname,
- u_char *volNum, u_int32_t *dirEnt,
- struct proc *p,struct ucred *cred);
-int ncp_close_file(struct ncp_conn *conn, ncp_fh *fh,
- struct proc *p,struct ucred *cred);
-int ncp_open_create_file_or_subdir(struct nwmount *nmp,struct vnode *dvp, int namelen,char *name,
- int open_create_mode, u_int32_t create_attributes,
- int desired_acc_rights, struct ncp_open_info *nop,
- struct proc *p,struct ucred *cred);
-int ncp_DeleteNSEntry(struct nwmount *nmp,
- u_int32_t dirent, int namelen, char *name,
- struct proc *p,struct ucred *cred);
-int ncp_nsrename(struct ncp_conn *conn, int volume, int ns, int oldtype,
- struct ncp_nlstables *nt,
- nwdirent fdir, char *old_name, int oldlen,
- nwdirent tdir, char *new_name, int newlen,
- struct proc *p, struct ucred *cred);
-int ncp_obtain_info(struct nwmount *nmp, u_int32_t dirent,
- int namelen, char *path, struct nw_entry_info *target,
- struct proc *p,struct ucred *cred);
-int ncp_modify_file_or_subdir_dos_info(struct nwmount *nmp, struct vnode *vp,
- u_int32_t info_mask,
- struct nw_modify_dos_info *info,
- struct proc *p,struct ucred *cred);
-int ncp_setattr(struct vnode *,struct vattr *,struct ucred *,struct proc *);
-int ncp_get_namespaces(struct ncp_conn *conn, u_int32_t volume, int *nsf,
- struct proc *p,struct ucred *cred);
-int ncp_get_volume_info_with_number(struct ncp_conn *conn,
- int n, struct ncp_volume_info *target,
- struct proc *p,struct ucred *cred);
-
-void ncp_unix2dostime __P((struct timespec *tsp, u_int16_t *ddp,
- u_int16_t *dtp, u_int8_t *dhp));
-void ncp_dos2unixtime __P((u_int dd, u_int dt, u_int dh, struct timespec *tsp));
-
-#endif /* !_NWFS_SUBR_H_ */
diff --git a/sys/fs/nwfs/nwfs_vfsops.c b/sys/fs/nwfs/nwfs_vfsops.c
deleted file mode 100644
index ac89567ad6fd..000000000000
--- a/sys/fs/nwfs/nwfs_vfsops.c
+++ /dev/null
@@ -1,522 +0,0 @@
-/*
- * Copyright (c) 1999, Boris Popov
- * 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 Boris Popov.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include "opt_ncp.h"
-#ifndef NCP
-#error "NWFS requires NCP protocol"
-#endif
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/proc.h>
-#include <sys/kernel.h>
-#include <sys/sysctl.h>
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <sys/stat.h>
-#include <sys/malloc.h>
-#include <sys/buf.h>
-
-#include <netncp/ncp.h>
-#include <netncp/ncp_conn.h>
-#include <netncp/ncp_subr.h>
-#include <netncp/ncp_ncp.h>
-#include <netncp/ncp_nls.h>
-
-#include <nwfs/nwfs.h>
-#include <nwfs/nwfs_node.h>
-#include <nwfs/nwfs_subr.h>
-
-int nwfs_debuglevel = 0;
-
-static int nwfs_version = NWFS_VERSION;
-
-SYSCTL_DECL(_vfs_nwfs);
-SYSCTL_NODE(_vfs, OID_AUTO, nwfs, CTLFLAG_RW, 0, "Netware file system");
-SYSCTL_INT(_vfs_nwfs, OID_AUTO, version, CTLFLAG_RD, &nwfs_version, 0, "");
-SYSCTL_INT(_vfs_nwfs, OID_AUTO, debuglevel, CTLFLAG_RW, &nwfs_debuglevel, 0, "");
-
-static int nwfs_mount __P((struct mount *, char *, caddr_t,
- struct nameidata *, struct proc *));
-static int nwfs_quotactl __P((struct mount *, int, uid_t, caddr_t,
- struct proc *));
-static int nwfs_root __P((struct mount *, struct vnode **));
-static int nwfs_start __P((struct mount *, int, struct proc *));
-static int nwfs_statfs __P((struct mount *, struct statfs *,
- struct proc *));
-static int nwfs_sync __P((struct mount *, int, struct ucred *,
- struct proc *));
-static int nwfs_unmount __P((struct mount *, int, struct proc *));
-static int nwfs_init __P((struct vfsconf *vfsp));
-static int nwfs_uninit __P((struct vfsconf *vfsp));
-
-static struct vfsops nwfs_vfsops = {
- nwfs_mount,
- nwfs_start,
- nwfs_unmount,
- nwfs_root,
- nwfs_quotactl,
- nwfs_statfs,
- nwfs_sync,
- vfs_stdvget,
- vfs_stdfhtovp, /* shouldn't happen */
- vfs_stdcheckexp,
- vfs_stdvptofh, /* shouldn't happen */
- nwfs_init,
- nwfs_uninit,
- vfs_stdextattrctl,
-};
-
-
-VFS_SET(nwfs_vfsops, nwfs, VFCF_NETWORK);
-
-int nwfs_pbuf_freecnt = -1; /* start out unlimited */
-static int nwfsid = 1;
-
-static int
-nwfs_initnls(struct nwmount *nmp) {
- char *pc, *pe;
- int error = 0;
-#define COPY_TABLE(t,d) { \
- if (t) { \
- error = copyin((t), pc, 256); \
- if (error) break; \
- } else \
- bcopy(d, pc, 256); \
- (t) = pc; pc += 256; \
- }
-
- nmp->m.nls.opt |= NWHP_NLS | NWHP_DOS;
- if ((nmp->m.flags & NWFS_MOUNT_HAVE_NLS) == 0) {
- nmp->m.nls.to_lower = ncp_defnls.to_lower;
- nmp->m.nls.to_upper = ncp_defnls.to_upper;
- nmp->m.nls.n2u = ncp_defnls.n2u;
- nmp->m.nls.u2n = ncp_defnls.u2n;
- return 0;
- }
- MALLOC(pe, char *, 256 * 4, M_NWFSDATA, M_WAITOK);
- if (pe == NULL) return ENOMEM;
- pc = pe;
- do {
- COPY_TABLE(nmp->m.nls.to_lower, ncp_defnls.to_lower);
- COPY_TABLE(nmp->m.nls.to_upper, ncp_defnls.to_upper);
- COPY_TABLE(nmp->m.nls.n2u, ncp_defnls.n2u);
- COPY_TABLE(nmp->m.nls.u2n, ncp_defnls.u2n);
- } while(0);
- if (error) {
- free(pe, M_NWFSDATA);
- return error;
- }
- return 0;
-}
-/*
- * mp - path - addr in user space of mount point (ie /usr or whatever)
- * data - addr in user space of mount params
- */
-static int nwfs_mount(struct mount *mp, char *path, caddr_t data,
- struct nameidata *ndp, struct proc *p)
-{
- struct nwfs_args args; /* will hold data from mount request */
- size_t size;
- int error;
- struct nwmount *nmp = NULL;
- struct ncp_conn *conn = NULL;
- struct ncp_handle *handle = NULL;
- struct vnode *vp;
- char *pc,*pe;
-
- if (data == NULL) {
- nwfs_printf("missing data argument\n");
- return 1;
- }
- if (mp->mnt_flag & MNT_UPDATE) {
- nwfs_printf("MNT_UPDATE not implemented");
- return (EOPNOTSUPP);
- }
- error = copyin(data, (caddr_t)&args, sizeof(struct nwfs_args));
- if (error)
- return (error);
- if (args.version != NWFS_VERSION) {
- nwfs_printf("mount version mismatch: kernel=%d, mount=%d\n",NWFS_VERSION,args.version);
- return (1);
- }
- error = ncp_conn_getbyref(args.connRef,p,p->p_ucred,NCPM_EXECUTE,&conn);
- if (error) {
- nwfs_printf("invalid connection refernce %d\n",args.connRef);
- return (error);
- }
- error = ncp_conn_gethandle(conn, NULL, &handle);
- if (error) {
- nwfs_printf("can't get connection handle\n");
- return (error);
- }
- ncp_conn_unlock(conn,p); /* we keep the ref */
- mp->mnt_stat.f_iosize = conn->buffer_size;
- /* We must malloc our own mount info */
- MALLOC(nmp,struct nwmount *,sizeof(struct nwmount),M_NWFSDATA,M_USE_RESERVE);
- if (nmp == NULL) {
- nwfs_printf("could not alloc nwmount\n");
- error = ENOMEM;
- goto bad;
- }
- bzero(nmp,sizeof(*nmp));
- mp->mnt_data = (qaddr_t)nmp;
- nmp->connh = handle;
- nmp->n_root = NULL;
- nmp->n_id = nwfsid++;
- nmp->m = args;
- nmp->m.file_mode = (nmp->m.file_mode &
- (S_IRWXU|S_IRWXG|S_IRWXO)) | S_IFREG;
- nmp->m.dir_mode = (nmp->m.dir_mode &
- (S_IRWXU|S_IRWXG|S_IRWXO)) | S_IFDIR;
- if ((error = nwfs_initnls(nmp)) != 0) goto bad;
- (void) copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size);
- bzero(mp->mnt_stat.f_mntonname + size, MNAMELEN - size);
- pc = mp->mnt_stat.f_mntfromname;
- pe = pc+sizeof(mp->mnt_stat.f_mntfromname);
- bzero(pc, MNAMELEN);
- *(pc++) = '/';
- pc = index(strncpy(pc, conn->li.server, pe-pc-2),0);
- if (pc < pe-1) {
- *(pc++) = ':';
- pc=index(strncpy(pc, conn->li.user, pe-pc-2),0);
- if (pc < pe-1) {
- *(pc++) = '/';
- strncpy(pc, nmp->m.mounted_vol, pe-pc-2);
- }
- }
- /* protect against invalid mount points */
- nmp->m.mount_point[sizeof(nmp->m.mount_point)-1] = '\0';
- vfs_getnewfsid(mp);
- error = nwfs_root(mp, &vp);
- if (error)
- goto bad;
- /*
- * Lose the lock but keep the ref.
- */
- VOP_UNLOCK(vp, 0, curproc);
- NCPVODEBUG("rootvp.vrefcnt=%d\n",vp->v_usecount);
- return error;
-bad:
- if (nmp)
- free(nmp, M_NWFSDATA);
- if (handle)
- ncp_conn_puthandle(handle, NULL, 0);
- return error;
-}
-
-/* Unmount the filesystem described by mp. */
-static int
-nwfs_unmount(struct mount *mp, int mntflags, struct proc *p)
-{
- struct nwmount *nmp = VFSTONWFS(mp);
- struct ncp_conn *conn;
- struct vnode *vp;
- int error, flags;
-
- NCPVODEBUG("nwfs_unmount: flags=%04x\n",mntflags);
- flags = 0;
- if (mntflags & MNT_FORCE)
- flags |= FORCECLOSE;
- error = VFS_ROOT(mp,&vp);
- if (error) return (error);
- if (vp->v_usecount > 2) {
- printf("nwfs_unmount: usecnt=%d\n",vp->v_usecount);
- vput(vp);
- return (EBUSY);
- }
- error = vflush(mp, vp, flags);
- if (error) {
- vput(vp);
- return (error);
- }
- /*
- * There are two reference counts and one lock to get rid of here.
- */
- NCPVODEBUG("v_use: %d\n",vp->v_usecount);
- vput(vp);
- NCPVODEBUG("v_use after vput: %d\n",vp->v_usecount);
- vrele(vp);
- NCPVODEBUG("v_use after vrele: %d\n",vp->v_usecount);
- vgone(vp);
- NCPVODEBUG("v_gone finished !!!!\n");
- conn = NWFSTOCONN(nmp);
- ncp_conn_puthandle(nmp->connh,NULL,0);
- if (ncp_conn_lock(conn,p,p->p_ucred,NCPM_WRITE | NCPM_EXECUTE) == 0) {
- if(ncp_disconnect(conn))
- ncp_conn_unlock(conn,p);
- }
- mp->mnt_data = (qaddr_t)0;
- if (nmp->m.flags & NWFS_MOUNT_HAVE_NLS)
- free(nmp->m.nls.to_lower, M_NWFSDATA);
- free(nmp, M_NWFSDATA);
- mp->mnt_flag &= ~MNT_LOCAL;
- return (error);
-}
-
-/* Return locked vnode to root of a filesystem */
-static int
-nwfs_root(struct mount *mp, struct vnode **vpp) {
- struct vnode *vp;
- struct nwmount *nmp;
- struct nwnode *np;
- struct ncp_conn *conn;
- struct nw_entry_info fattr;
- struct proc *p = curproc;
- struct ucred *cred = p->p_ucred;
- int error, nsf, opt;
- u_char vol;
-
- nmp = VFSTONWFS(mp);
- conn = NWFSTOCONN(nmp);
- if (nmp->n_root) {
- *vpp = NWTOV(nmp->n_root);
- vget(*vpp, LK_EXCLUSIVE, curproc);
- return 0;
- }
- error = ncp_lookup_volume(conn, nmp->m.mounted_vol, &vol,
- &nmp->n_rootent.f_id, p, cred);
- if (error)
- return ENOENT;
- nmp->n_volume = vol;
- error = ncp_get_namespaces(conn, vol, &nsf, p, cred);
- if (error)
- return ENOENT;
- if (nsf & NW_NSB_OS2) {
- NCPVODEBUG("volume %s has os2 namespace\n",nmp->m.mounted_vol);
- if ((nmp->m.flags & NWFS_MOUNT_NO_OS2) == 0) {
- nmp->name_space = NW_NS_OS2;
- nmp->m.nls.opt &= ~NWHP_DOS;
- }
- }
- opt = nmp->m.nls.opt;
- nsf = opt & (NWHP_UPPER | NWHP_LOWER);
- if (opt & NWHP_DOS) {
- if (nsf == (NWHP_UPPER | NWHP_LOWER)) {
- nmp->m.nls.opt &= ~(NWHP_LOWER | NWHP_UPPER);
- } else if (nsf == 0) {
- nmp->m.nls.opt |= NWHP_LOWER;
- }
- } else {
- if (nsf == (NWHP_UPPER | NWHP_LOWER)) {
- nmp->m.nls.opt &= ~(NWHP_LOWER | NWHP_UPPER);
- }
- }
- if (nmp->m.root_path[0]) {
- nmp->m.root_path[0]--;
- error = ncp_obtain_info(nmp, nmp->n_rootent.f_id,
- -nmp->m.root_path[0], nmp->m.root_path, &fattr, p, cred);
- if (error) {
- NCPFATAL("Invalid root path specified\n");
- return ENOENT;
- }
- nmp->n_rootent.f_parent = fattr.dirEntNum;
- nmp->m.root_path[0]++;
- error = ncp_obtain_info(nmp, nmp->n_rootent.f_id,
- -nmp->m.root_path[0], nmp->m.root_path, &fattr, p, cred);
- if (error) {
- NCPFATAL("Invalid root path specified\n");
- return ENOENT;
- }
- nmp->n_rootent.f_id = fattr.dirEntNum;
- } else {
- error = ncp_obtain_info(nmp, nmp->n_rootent.f_id,
- 0, NULL, &fattr, p, cred);
- if (error) {
- NCPFATAL("Can't obtain volume info\n");
- return ENOENT;
- }
- fattr.nameLen = strlen(strcpy(fattr.entryName, NWFS_ROOTVOL));
- nmp->n_rootent.f_parent = nmp->n_rootent.f_id;
- }
- error = nwfs_nget(mp, nmp->n_rootent, &fattr, NULL, &vp);
- if (error)
- return (error);
- vp->v_flag |= VROOT;
- np = VTONW(vp);
- if (nmp->m.root_path[0] == 0)
- np->n_flag |= NVOLUME;
- nmp->n_root = np;
-/* error = VOP_GETATTR(vp, &vattr, cred, p);
- if (error) {
- vput(vp);
- NCPFATAL("Can't get root directory entry\n");
- return error;
- }*/
- *vpp = vp;
- return (0);
-}
-
-/*
- * Vfs start routine, a no-op.
- */
-/* ARGSUSED */
-static int
-nwfs_start(mp, flags, p)
- struct mount *mp;
- int flags;
- struct proc *p;
-{
- NCPVODEBUG("flags=%04x\n",flags);
- return (0);
-}
-
-/*
- * Do operations associated with quotas, not supported
- */
-/* ARGSUSED */
-static int
-nwfs_quotactl(mp, cmd, uid, arg, p)
- struct mount *mp;
- int cmd;
- uid_t uid;
- caddr_t arg;
- struct proc *p;
-{
- NCPVODEBUG("return EOPNOTSUPP\n");
- return (EOPNOTSUPP);
-}
-
-/*ARGSUSED*/
-int
-nwfs_init(struct vfsconf *vfsp)
-{
-#ifndef SMP
- int name[2];
- int olen, ncpu, plen, error;
-
- name[0] = CTL_HW;
- name[1] = HW_NCPU;
- error = kernel_sysctl(curproc, name, 2, &ncpu, &olen, NULL, 0, &plen);
- if (error == 0 && ncpu > 1)
- printf("warning: nwfs module compiled without SMP support.");
-#endif
- nwfs_hash_init();
- nwfs_pbuf_freecnt = nswbuf / 2 + 1;
- NCPVODEBUG("always happy to load!\n");
- return (0);
-}
-
-/*ARGSUSED*/
-int
-nwfs_uninit(struct vfsconf *vfsp)
-{
-
- nwfs_hash_free();
- NCPVODEBUG("unloaded\n");
- return (0);
-}
-
-/*
- * nwfs_statfs call
- */
-int
-nwfs_statfs(mp, sbp, p)
- struct mount *mp;
- register struct statfs *sbp;
- struct proc *p;
-{
- struct nwmount *nmp = VFSTONWFS(mp);
- int error = 0, secsize;
- struct nwnode *np = nmp->n_root;
- struct ncp_volume_info vi;
-
- if (np == NULL) return EINVAL;
- error = ncp_get_volume_info_with_number(NWFSTOCONN(nmp), nmp->n_volume, &vi,p,p->p_ucred);
- if (error) return error;
- secsize = 512; /* XXX how to get real value ??? */
- sbp->f_spare2=0; /* placeholder */
- /* fundamental file system block size */
- sbp->f_bsize = vi.sectors_per_block*secsize;
- /* optimal transfer block size */
- sbp->f_iosize = NWFSTOCONN(nmp)->buffer_size;
- /* total data blocks in file system */
- sbp->f_blocks= vi.total_blocks;
- /* free blocks in fs */
- sbp->f_bfree = vi.free_blocks + vi.purgeable_blocks;
- /* free blocks avail to non-superuser */
- sbp->f_bavail= vi.free_blocks+vi.purgeable_blocks;
- /* total file nodes in file system */
- sbp->f_files = vi.total_dir_entries;
- /* free file nodes in fs */
- sbp->f_ffree = vi.available_dir_entries;
- sbp->f_flags = 0; /* copy of mount exported flags */
- if (sbp != &mp->mnt_stat) {
- sbp->f_fsid = mp->mnt_stat.f_fsid; /* file system id */
- sbp->f_owner = mp->mnt_stat.f_owner; /* user that mounted the filesystem */
- sbp->f_type = mp->mnt_vfc->vfc_typenum; /* type of filesystem */
- bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN);
- bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN);
- }
- strncpy(sbp->f_fstypename, mp->mnt_vfc->vfc_name, MFSNAMELEN);
- return 0;
-}
-
-/*
- * Flush out the buffer cache
- */
-/* ARGSUSED */
-static int
-nwfs_sync(mp, waitfor, cred, p)
- struct mount *mp;
- int waitfor;
- struct ucred *cred;
- struct proc *p;
-{
- register struct vnode *vp;
- int error, allerror = 0;
- /*
- * Force stale buffer cache information to be flushed.
- */
-loop:
- for (vp = mp->mnt_vnodelist.lh_first;
- vp != NULL;
- vp = vp->v_mntvnodes.le_next) {
- /*
- * If the vnode that we are about to sync is no longer
- * associated with this mount point, start over.
- */
- if (vp->v_mount != mp)
- goto loop;
- if (VOP_ISLOCKED(vp, NULL) || TAILQ_EMPTY(&vp->v_dirtyblkhd) ||
- waitfor == MNT_LAZY)
- continue;
- if (vget(vp, LK_EXCLUSIVE, p))
- goto loop;
- error = VOP_FSYNC(vp, cred, waitfor, p);
- if (error)
- allerror = error;
- vput(vp);
- }
- return (allerror);
-}
diff --git a/sys/fs/nwfs/nwfs_vnops.c b/sys/fs/nwfs/nwfs_vnops.c
deleted file mode 100644
index 22df1b30016a..000000000000
--- a/sys/fs/nwfs/nwfs_vnops.c
+++ /dev/null
@@ -1,1098 +0,0 @@
-/*
- * Copyright (c) 1999, Boris Popov
- * 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 Boris Popov.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/namei.h>
-#include <sys/kernel.h>
-#include <sys/buf.h>
-#include <sys/proc.h>
-#include <sys/fcntl.h>
-#include <sys/mount.h>
-#include <sys/unistd.h>
-#include <sys/vnode.h>
-
-#include <vm/vm.h>
-#include <vm/vm_extern.h>
-#include <vm/vm_zone.h>
-
-#include <netncp/ncp.h>
-#include <netncp/ncp_conn.h>
-#include <netncp/ncp_subr.h>
-#include <netncp/nwerror.h>
-#include <netncp/ncp_nls.h>
-
-#include <nwfs/nwfs.h>
-#include <nwfs/nwfs_node.h>
-#include <nwfs/nwfs_subr.h>
-
-/*
- * Prototypes for NWFS vnode operations
- */
-static int nwfs_create __P((struct vop_create_args *));
-static int nwfs_mknod __P((struct vop_mknod_args *));
-static int nwfs_open __P((struct vop_open_args *));
-static int nwfs_close __P((struct vop_close_args *));
-static int nwfs_access __P((struct vop_access_args *));
-static int nwfs_getattr __P((struct vop_getattr_args *));
-static int nwfs_setattr __P((struct vop_setattr_args *));
-static int nwfs_read __P((struct vop_read_args *));
-static int nwfs_write __P((struct vop_write_args *));
-static int nwfs_fsync __P((struct vop_fsync_args *));
-static int nwfs_remove __P((struct vop_remove_args *));
-static int nwfs_link __P((struct vop_link_args *));
-static int nwfs_lookup __P((struct vop_lookup_args *));
-static int nwfs_rename __P((struct vop_rename_args *));
-static int nwfs_mkdir __P((struct vop_mkdir_args *));
-static int nwfs_rmdir __P((struct vop_rmdir_args *));
-static int nwfs_symlink __P((struct vop_symlink_args *));
-static int nwfs_readdir __P((struct vop_readdir_args *));
-static int nwfs_bmap __P((struct vop_bmap_args *));
-static int nwfs_strategy __P((struct vop_strategy_args *));
-static int nwfs_print __P((struct vop_print_args *));
-static int nwfs_pathconf __P((struct vop_pathconf_args *ap));
-
-/* Global vfs data structures for nwfs */
-vop_t **nwfs_vnodeop_p;
-static struct vnodeopv_entry_desc nwfs_vnodeop_entries[] = {
- { &vop_default_desc, (vop_t *) vop_defaultop },
- { &vop_access_desc, (vop_t *) nwfs_access },
- { &vop_bmap_desc, (vop_t *) nwfs_bmap },
- { &vop_open_desc, (vop_t *) nwfs_open },
- { &vop_close_desc, (vop_t *) nwfs_close },
- { &vop_create_desc, (vop_t *) nwfs_create },
- { &vop_fsync_desc, (vop_t *) nwfs_fsync },
- { &vop_getattr_desc, (vop_t *) nwfs_getattr },
- { &vop_getpages_desc, (vop_t *) nwfs_getpages },
- { &vop_putpages_desc, (vop_t *) nwfs_putpages },
- { &vop_ioctl_desc, (vop_t *) nwfs_ioctl },
- { &vop_inactive_desc, (vop_t *) nwfs_inactive },
- { &vop_islocked_desc, (vop_t *) vop_noislocked },
- { &vop_link_desc, (vop_t *) nwfs_link },
- { &vop_lock_desc, (vop_t *) vop_sharedlock },
- { &vop_lookup_desc, (vop_t *) nwfs_lookup },
- { &vop_mkdir_desc, (vop_t *) nwfs_mkdir },
- { &vop_mknod_desc, (vop_t *) nwfs_mknod },
- { &vop_pathconf_desc, (vop_t *) nwfs_pathconf },
- { &vop_print_desc, (vop_t *) nwfs_print },
- { &vop_read_desc, (vop_t *) nwfs_read },
- { &vop_readdir_desc, (vop_t *) nwfs_readdir },
- { &vop_reclaim_desc, (vop_t *) nwfs_reclaim },
- { &vop_remove_desc, (vop_t *) nwfs_remove },
- { &vop_rename_desc, (vop_t *) nwfs_rename },
- { &vop_rmdir_desc, (vop_t *) nwfs_rmdir },
- { &vop_setattr_desc, (vop_t *) nwfs_setattr },
- { &vop_strategy_desc, (vop_t *) nwfs_strategy },
- { &vop_symlink_desc, (vop_t *) nwfs_symlink },
- { &vop_unlock_desc, (vop_t *) vop_nounlock },
- { &vop_write_desc, (vop_t *) nwfs_write },
- { NULL, NULL }
-};
-static struct vnodeopv_desc nwfs_vnodeop_opv_desc =
- { &nwfs_vnodeop_p, nwfs_vnodeop_entries };
-
-VNODEOP_SET(nwfs_vnodeop_opv_desc);
-
-void nwfs_createname(char *_name,struct vnode *vp,struct componentname *cnp);
-
-
-void nwfs_createname(char *_name,struct vnode *vp,struct componentname *cnp){
- strncpy(_name, cnp->cn_nameptr, cnp->cn_namelen);
- _name[cnp->cn_namelen] = '\0';
- ncp_str_upper(_name);
-}
-/*
- * nwfs_access vnode op
- * for now just return ok
- */
-static int
-nwfs_access(ap)
- struct vop_access_args /* {
- struct vnode *a_vp;
- int a_mode;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
- struct ucred *cred = ap->a_cred;
- u_int mode = ap->a_mode;
- struct nwmount *nmp = VTONWFS(vp);
- int error = 0;
-
- NCPVNDEBUG("\n");
- if ((ap->a_mode & VWRITE) && (vp->v_mount->mnt_flag & MNT_RDONLY)) {
- switch (vp->v_type) {
- case VREG: case VDIR: case VLNK:
- return (EROFS);
- default:
- break;
- }
- }
- if (cred->cr_uid == 0)
- return 0;
- if (cred->cr_uid != nmp->m.uid) {
- mode >>= 3;
- if (!groupmember(nmp->m.gid, cred))
- mode >>= 3;
- }
- error = (((vp->v_type == VREG) ? nmp->m.file_mode : nmp->m.dir_mode) & mode) == mode ? 0 : EACCES;
- return error;
-}
-/*
- * nwfs_open vnode op
- */
-/* ARGSUSED */
-static int
-nwfs_open(ap)
- struct vop_open_args /* {
- struct vnode *a_vp;
- int a_mode;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
- int mode = ap->a_mode;
- struct nwnode *np = VTONW(vp);
- struct ncp_open_info no;
- struct nwmount *nmp = VTONWFS(vp);
- struct vattr vattr;
- int error, nwm;
-
- NCPVNDEBUG("%s,%d\n",np->n_name, np->opened);
- if (vp->v_type != VREG && vp->v_type != VDIR) {
- NCPFATAL("open eacces vtype=%d\n", vp->v_type);
- return (EACCES);
- }
- if (vp->v_type == VDIR) return 0; /* nothing to do now */
- if (np->n_flag & NMODIFIED) {
- if ((error = nwfs_vinvalbuf(vp, V_SAVE, ap->a_cred, ap->a_p, 1)) == EINTR)
- return (error);
- np->n_atime = 0;
- error = VOP_GETATTR(vp, &vattr, ap->a_cred, ap->a_p);
- if (error) return (error);
- np->n_mtime = vattr.va_mtime.tv_sec;
- } else {
- error = VOP_GETATTR(vp, &vattr, ap->a_cred, ap->a_p);
- if (error) return (error);
- if (np->n_mtime != vattr.va_mtime.tv_sec) {
- if ((error = nwfs_vinvalbuf(vp, V_SAVE, ap->a_cred, ap->a_p, 1)) == EINTR)
- return (error);
- np->n_mtime = vattr.va_mtime.tv_sec;
- }
- }
- if (np->opened) {
- np->opened++;
- return 0;
- }
- nwm = AR_READ;
- if ((vp->v_mount->mnt_flag & MNT_RDONLY) == 0)
- nwm |= AR_WRITE;
- error = ncp_open_create_file_or_subdir(nmp, vp, 0, NULL, OC_MODE_OPEN,
- 0, nwm, &no, ap->a_p, ap->a_cred);
- if (error) {
- if (mode & FWRITE)
- return EACCES;
- nwm = AR_READ;
- error = ncp_open_create_file_or_subdir(nmp, vp, 0, NULL, OC_MODE_OPEN, 0,
- nwm, &no, ap->a_p,ap->a_cred);
- }
- if (!error) {
- np->opened++;
- np->n_fh = no.fh;
- np->n_origfh = no.origfh;
- }
- np->n_atime = 0;
- return (error);
-}
-
-static int
-nwfs_close(ap)
- struct vop_close_args /* {
- struct vnodeop_desc *a_desc;
- struct vnode *a_vp;
- int a_fflag;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
- register struct nwnode *np = VTONW(vp);
- int error;
-
- NCPVNDEBUG("name=%s,pid=%d,c=%d\n",np->n_name,ap->a_p->p_pid,np->opened);
-
- if (vp->v_type == VDIR) return 0; /* nothing to do now */
- error = 0;
- simple_lock(&vp->v_interlock);
- if (np->opened == 0) {
- simple_unlock(&vp->v_interlock);
- return 0;
- }
- simple_unlock(&vp->v_interlock);
- error = nwfs_vinvalbuf(vp, V_SAVE, ap->a_cred, ap->a_p, 1);
- simple_lock(&vp->v_interlock);
- if (np->opened == 0) {
- simple_unlock(&vp->v_interlock);
- return 0;
- }
- if (--np->opened == 0)
- error = ncp_close_file(NWFSTOCONN(VTONWFS(vp)), &np->n_fh,
- ap->a_p, ap->a_cred);
- simple_unlock(&vp->v_interlock);
- np->n_atime = 0;
- return (error);
-}
-
-/*
- * nwfs_getattr call from vfs.
- */
-static int
-nwfs_getattr(ap)
- struct vop_getattr_args /* {
- struct vnode *a_vp;
- struct vattr *a_vap;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
- register struct nwnode *np = VTONW(vp);
- struct vattr *va=ap->a_vap;
- struct nwmount *nmp = VTONWFS(vp);
- struct nw_entry_info fattr;
- int error;
- u_int32_t oldsize;
-
- NCPVNDEBUG("%lx:%d: '%s' %d\n", (long)vp, nmp->n_volume, np->n_name, (vp->v_flag & VROOT) != 0);
- error = nwfs_attr_cachelookup(vp,va);
- if (!error) return 0;
- NCPVNDEBUG("not in cache\n");
- oldsize = np->n_size;
- if (np->n_flag & NVOLUME) {
- error = ncp_obtain_info(nmp, np->n_fid.f_id, 0, NULL, &fattr,
- ap->a_p,ap->a_cred);
- } else {
- error = ncp_obtain_info(nmp, np->n_fid.f_parent, np->n_nmlen,
- np->n_name, &fattr, ap->a_p, ap->a_cred);
- }
- if (error) {
- NCPVNDEBUG("error %d\n", error);
- return error;
- }
- nwfs_attr_cacheenter(vp, &fattr);
- *va = np->n_vattr;
- if (np->opened)
- np->n_size = oldsize;
- return (0);
-}
-/*
- * nwfs_setattr call from vfs.
- */
-static int
-nwfs_setattr(ap)
- struct vop_setattr_args /* {
- struct vnode *a_vp;
- struct vattr *a_vap;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
- register struct nwnode *np = VTONW(vp);
- register struct vattr *vap = ap->a_vap;
- u_quad_t tsize=0;
- int error = 0;
-
- NCPVNDEBUG("\n");
- if (vap->va_flags != VNOVAL)
- return (EOPNOTSUPP);
- /*
- * Disallow write attempts if the filesystem is mounted read-only.
- */
- if ((vap->va_uid != (uid_t)VNOVAL || vap->va_gid != (gid_t)VNOVAL ||
- vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL ||
- vap->va_mode != (mode_t)VNOVAL) &&(vp->v_mount->mnt_flag & MNT_RDONLY))
- return (EROFS);
- if (vap->va_size != VNOVAL) {
- switch (vp->v_type) {
- case VDIR:
- return (EISDIR);
- case VREG:
- /*
- * Disallow write attempts if the filesystem is
- * mounted read-only.
- */
- if (vp->v_mount->mnt_flag & MNT_RDONLY)
- return (EROFS);
- vnode_pager_setsize(vp, (u_long)vap->va_size);
- tsize = np->n_size;
- np->n_size = vap->va_size;
- break;
- default:
- return EINVAL;
- };
- }
- error = ncp_setattr(vp, vap, ap->a_cred, ap->a_p);
- if (error && vap->va_size != VNOVAL) {
- np->n_size = tsize;
- vnode_pager_setsize(vp, (u_long)tsize);
- }
- np->n_atime = 0; /* invalidate cache */
- VOP_GETATTR(vp, vap, ap->a_cred, ap->a_p);
- np->n_mtime = vap->va_mtime.tv_sec;
- return (0);
-}
-/*
- * nwfs_read call.
- */
-static int
-nwfs_read(ap)
- struct vop_read_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- int a_ioflag;
- struct ucred *a_cred;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
- struct uio *uio=ap->a_uio;
- int error;
- NCPVNDEBUG("nwfs_read:\n");
-
- if (vp->v_type != VREG && vp->v_type != VDIR)
- return (EPERM);
- error = nwfs_readvnode(vp, uio, ap->a_cred);
- return error;
-}
-
-static int
-nwfs_write(ap)
- struct vop_write_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- int a_ioflag;
- struct ucred *a_cred;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
- struct uio *uio = ap->a_uio;
- int error;
-
- NCPVNDEBUG("%d,ofs=%d,sz=%d\n",vp->v_type, (int)uio->uio_offset, uio->uio_resid);
-
- if (vp->v_type != VREG)
- return (EPERM);
- error = nwfs_writevnode(vp, uio, ap->a_cred,ap->a_ioflag);
- return(error);
-}
-/*
- * nwfs_create call
- * Create a regular file. On entry the directory to contain the file being
- * created is locked. We must release before we return. We must also free
- * the pathname buffer pointed at by cnp->cn_pnbuf, always on error, or
- * only if the SAVESTART bit in cn_flags is clear on success.
- */
-static int
-nwfs_create(ap)
- struct vop_create_args /* {
- struct vnode *a_dvp;
- struct vnode **a_vpp;
- struct componentname *a_cnp;
- struct vattr *a_vap;
- } */ *ap;
-{
- register struct vnode *dvp = ap->a_dvp;
- register struct vattr *vap = ap->a_vap;
- struct vnode **vpp=ap->a_vpp;
- register struct componentname *cnp = ap->a_cnp;
- struct vnode *vp = (struct vnode *)0;
- int error = 0, fmode;
- struct vattr vattr;
- struct nwnode *np;
- struct ncp_open_info no;
- struct nwmount *nmp=VTONWFS(dvp);
- ncpfid fid;
-
-
- NCPVNDEBUG("\n");
- *vpp = NULL;
- if (vap->va_type == VSOCK)
- return (EOPNOTSUPP);
- if ((error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred, cnp->cn_proc))) {
- return (error);
- }
- fmode = AR_READ | AR_WRITE;
-/* if (vap->va_vaflags & VA_EXCLUSIVE)
- fmode |= AR_DENY_READ | AR_DENY_WRITE;*/
-
- error = ncp_open_create_file_or_subdir(nmp,dvp,cnp->cn_namelen,cnp->cn_nameptr,
- OC_MODE_CREATE | OC_MODE_OPEN | OC_MODE_REPLACE,
- 0, fmode, &no, cnp->cn_proc, cnp->cn_cred);
- if (!error) {
- error = ncp_close_file(NWFSTOCONN(nmp), &no.fh, cnp->cn_proc,cnp->cn_cred);
- fid.f_parent = VTONW(dvp)->n_fid.f_id;
- fid.f_id = no.fattr.dirEntNum;
- error = nwfs_nget(VTOVFS(dvp), fid, &no.fattr, dvp, &vp);
- if (!error) {
- np = VTONW(vp);
- np->opened = 0;
- *vpp = vp;
- }
- if (cnp->cn_flags & MAKEENTRY)
- cache_enter(dvp, vp, cnp);
- }
- return (error);
-}
-
-/*
- * nwfs_remove call. It isn't possible to emulate UFS behaivour because
- * NetWare doesn't allow delete/rename operations on an opened file.
- */
-static int
-nwfs_remove(ap)
- struct vop_remove_args /* {
- struct vnodeop_desc *a_desc;
- struct vnode * a_dvp;
- struct vnode * a_vp;
- struct componentname * a_cnp;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
- register struct vnode *dvp = ap->a_dvp;
- register struct componentname *cnp = ap->a_cnp;
- register struct nwnode *np = VTONW(vp);
- struct nwmount *nmp = VTONWFS(vp);
- int error;
-
- if (vp->v_type == VDIR || np->opened || vp->v_usecount != 1) {
- error = EPERM;
- } else if (!ncp_conn_valid(NWFSTOCONN(nmp))) {
- error = EIO;
- } else {
- cache_purge(vp);
- error = ncp_DeleteNSEntry(nmp, VTONW(dvp)->n_fid.f_id,
- cnp->cn_namelen,cnp->cn_nameptr,cnp->cn_proc,cnp->cn_cred);
- if (error == 0x899c) error = EACCES;
- }
- return (error);
-}
-
-/*
- * nwfs_file rename call
- */
-static int
-nwfs_rename(ap)
- struct vop_rename_args /* {
- struct vnode *a_fdvp;
- struct vnode *a_fvp;
- struct componentname *a_fcnp;
- struct vnode *a_tdvp;
- struct vnode *a_tvp;
- struct componentname *a_tcnp;
- } */ *ap;
-{
- register struct vnode *fvp = ap->a_fvp;
- register struct vnode *tvp = ap->a_tvp;
- register struct vnode *fdvp = ap->a_fdvp;
- register struct vnode *tdvp = ap->a_tdvp;
- register struct componentname *tcnp = ap->a_tcnp;
- register struct componentname *fcnp = ap->a_fcnp;
- struct nwmount *nmp=VTONWFS(fvp);
- u_int16_t oldtype = 6;
- int error=0;
-
- /* Check for cross-device rename */
- if ((fvp->v_mount != tdvp->v_mount) ||
- (tvp && (fvp->v_mount != tvp->v_mount))) {
- error = EXDEV;
- goto out;
- }
-
- if (tvp && tvp->v_usecount > 1) {
- error = EBUSY;
- goto out;
- }
- if (tvp && tvp != fvp) {
- error = ncp_DeleteNSEntry(nmp, VTONW(tdvp)->n_fid.f_id,
- tcnp->cn_namelen, tcnp->cn_nameptr,
- tcnp->cn_proc, tcnp->cn_cred);
- if (error == 0x899c) error = EACCES;
- if (error)
- goto out;
- }
- if (fvp->v_type == VDIR) {
- oldtype |= NW_TYPE_SUBDIR;
- } else if (fvp->v_type == VREG) {
- oldtype |= NW_TYPE_FILE;
- } else
- return EINVAL;
- error = ncp_nsrename(NWFSTOCONN(nmp), nmp->n_volume, nmp->name_space,
- oldtype, &nmp->m.nls,
- VTONW(fdvp)->n_fid.f_id, fcnp->cn_nameptr, fcnp->cn_namelen,
- VTONW(tdvp)->n_fid.f_id, tcnp->cn_nameptr, tcnp->cn_namelen,
- tcnp->cn_proc,tcnp->cn_cred);
-
- if (error == 0x8992)
- error = EEXIST;
- if (fvp->v_type == VDIR) {
- if (tvp != NULL && tvp->v_type == VDIR)
- cache_purge(tdvp);
- cache_purge(fdvp);
- }
-out:
- if (tdvp == tvp)
- vrele(tdvp);
- else
- vput(tdvp);
- if (tvp)
- vput(tvp);
- vrele(fdvp);
- vrele(fvp);
- nwfs_attr_cacheremove(fdvp);
- nwfs_attr_cacheremove(tdvp);
- /*
- * Need to get rid of old vnodes, because netware will change
- * file id on rename
- */
- vgone(fvp);
- if (tvp)
- vgone(tvp);
- /*
- * Kludge: Map ENOENT => 0 assuming that it is a reply to a retry.
- */
- if (error == ENOENT)
- error = 0;
- return (error);
-}
-
-/*
- * nwfs hard link create call
- * Netware filesystems don't know what links are.
- */
-static int
-nwfs_link(ap)
- struct vop_link_args /* {
- struct vnode *a_tdvp;
- struct vnode *a_vp;
- struct componentname *a_cnp;
- } */ *ap;
-{
- return EOPNOTSUPP;
-}
-
-/*
- * nwfs_symlink link create call
- * Netware filesystems don't know what symlinks are.
- */
-static int
-nwfs_symlink(ap)
- struct vop_symlink_args /* {
- struct vnode *a_dvp;
- struct vnode **a_vpp;
- struct componentname *a_cnp;
- struct vattr *a_vap;
- char *a_target;
- } */ *ap;
-{
- return (EOPNOTSUPP);
-}
-
-static int nwfs_mknod(ap)
- struct vop_mknod_args /* {
- } */ *ap;
-{
- return (EOPNOTSUPP);
-}
-
-/*
- * nwfs_mkdir call
- */
-static int
-nwfs_mkdir(ap)
- struct vop_mkdir_args /* {
- struct vnode *a_dvp;
- struct vnode **a_vpp;
- struct componentname *a_cnp;
- struct vattr *a_vap;
- } */ *ap;
-{
- register struct vnode *dvp = ap->a_dvp;
-/* register struct vattr *vap = ap->a_vap;*/
- register struct componentname *cnp = ap->a_cnp;
- register int len=cnp->cn_namelen;
- struct ncp_open_info no;
- struct nwnode *np;
- struct vnode *newvp = (struct vnode *)0;
- ncpfid fid;
- int error = 0;
- struct vattr vattr;
- char *name=cnp->cn_nameptr;
-
- if ((error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred, cnp->cn_proc))) {
- return (error);
- }
- if ((name[0] == '.') && ((len == 1) || ((len == 2) && (name[1] == '.')))) {
- return EEXIST;
- }
- if (ncp_open_create_file_or_subdir(VTONWFS(dvp),dvp, cnp->cn_namelen,
- cnp->cn_nameptr,OC_MODE_CREATE, aDIR, 0xffff,
- &no, cnp->cn_proc, cnp->cn_cred) != 0) {
- error = EACCES;
- } else {
- error = 0;
- }
- if (!error) {
- fid.f_parent = VTONW(dvp)->n_fid.f_id;
- fid.f_id = no.fattr.dirEntNum;
- error = nwfs_nget(VTOVFS(dvp), fid, &no.fattr, dvp, &newvp);
- if (!error) {
- np = VTONW(newvp);
- newvp->v_type = VDIR;
- *ap->a_vpp = newvp;
- }
- }
- return (error);
-}
-
-/*
- * nwfs_remove directory call
- */
-static int
-nwfs_rmdir(ap)
- struct vop_rmdir_args /* {
- struct vnode *a_dvp;
- struct vnode *a_vp;
- struct componentname *a_cnp;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
- register struct vnode *dvp = ap->a_dvp;
- register struct componentname *cnp = ap->a_cnp;
- struct nwmount *nmp = VTONWFS(vp);
- struct nwnode *dnp = VTONW(dvp);
- int error = EIO;
-
- if (dvp == vp) return EINVAL;
- if (!ncp_conn_valid(NWFSTOCONN(nmp))) return(error);
-
- error = ncp_DeleteNSEntry(nmp, dnp->n_fid.f_id,
- cnp->cn_namelen, cnp->cn_nameptr,cnp->cn_proc,cnp->cn_cred);
- if (error == NWE_DIR_NOT_EMPTY) error = ENOTEMPTY;
- dnp->n_flag |= NMODIFIED;
- nwfs_attr_cacheremove(dvp);
- cache_purge(dvp);
- cache_purge(vp);
- return (error);
-}
-
-/*
- * nwfs_readdir call
- */
-static int
-nwfs_readdir(ap)
- struct vop_readdir_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- struct ucred *a_cred;
- int *a_eofflag;
- u_long *a_cookies;
- int a_ncookies;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
- register struct uio *uio = ap->a_uio;
- int error;
-
- if (vp->v_type != VDIR)
- return (EPERM);
- if (ap->a_ncookies) {
- printf("nwfs_readdir: no support for cookies now...");
- return (EOPNOTSUPP);
- }
-
- error = nwfs_readvnode(vp, uio, ap->a_cred);
- return error;
-}
-/* ARGSUSED */
-static int
-nwfs_fsync(ap)
- struct vop_fsync_args /* {
- struct vnodeop_desc *a_desc;
- struct vnode * a_vp;
- struct ucred * a_cred;
- int a_waitfor;
- struct proc * a_p;
- } */ *ap;
-{
-/* return (nfs_flush(ap->a_vp, ap->a_cred, ap->a_waitfor, ap->a_p, 1));*/
- return (0);
-}
-/* ARGSUSED */
-static
-int nwfs_print (ap)
- struct vop_print_args /* {
- struct vnode *a_vp;
- } */ *ap;
-{
- return (0);
-}
-
-static int nwfs_pathconf (ap)
- struct vop_pathconf_args /* {
- struct vnode *vp;
- int name;
- register_t *retval;
- } */ *ap;
-{
- int name=ap->a_name, error=0;
- register_t *retval=ap->a_retval;
-
- switch(name){
- case _PC_LINK_MAX:
- *retval=0;
- break;
- case _PC_NAME_MAX:
- *retval=NCP_MAX_FILENAME; /* XXX from nwfsnode */
- break;
- case _PC_PATH_MAX:
- *retval=NCP_MAXPATHLEN; /* XXX from nwfsnode */
- break;
- default:
- error=EINVAL;
- }
- return(error);
-}
-
-static int nwfs_strategy (ap)
- struct vop_strategy_args /* {
- struct buf *a_bp
- } */ *ap;
-{
- struct buf *bp=ap->a_bp;
- struct ucred *cr;
- struct proc *p;
- int error = 0;
-
- NCPVNDEBUG("\n");
- if (bp->b_flags & B_PHYS)
- panic("nwfs physio");
- if (bp->b_flags & B_ASYNC)
- p = (struct proc *)0;
- else
- p = curproc; /* XXX */
- if (bp->b_flags & B_READ)
- cr = bp->b_rcred;
- else
- cr = bp->b_wcred;
- /*
- * If the op is asynchronous and an i/o daemon is waiting
- * queue the request, wake it up and wait for completion
- * otherwise just do it ourselves.
- */
- if ((bp->b_flags & B_ASYNC) == 0 )
- error = nwfs_doio(bp, cr, p);
- return (error);
-}
-
-static int
-nwfs_bmap(ap)
- struct vop_bmap_args /* {
- struct vnode *a_vp;
- daddr_t a_bn;
- struct vnode **a_vpp;
- daddr_t *a_bnp;
- int *a_runp;
- int *a_runb;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
-
- if (ap->a_vpp != NULL)
- *ap->a_vpp = vp;
- if (ap->a_bnp != NULL)
- *ap->a_bnp = ap->a_bn * btodb(vp->v_mount->mnt_stat.f_iosize);
- if (ap->a_runp != NULL)
- *ap->a_runp = 0;
- if (ap->a_runb != NULL)
- *ap->a_runb = 0;
- return (0);
-}
-
-int
-nwfs_nget(struct mount *mp, ncpfid fid, struct nw_entry_info *fap,
- struct vnode *dvp, struct vnode **vpp)
-{
- int error;
- struct nwnode *newnp;
- struct vnode *vp;
-
- *vpp = NULL;
- error = nwfs_allocvp(mp, fid, &vp);
- if (error)
- return error;
- newnp = VTONW(vp);
- if (fap) {
- if (newnp->n_flag & NNEW) {
- newnp->n_nmlen = fap->nameLen;
- bcopy(fap->entryName, newnp->n_name, newnp->n_nmlen);
- newnp->n_name[fap->nameLen] = 0;
- }
- newnp->n_attr = fap->attributes;
- newnp->n_dosfid = fap->DosDirNum;
- vp->v_type = newnp->n_attr & aDIR ? VDIR : VREG;
- nwfs_attr_cacheenter(vp, fap);
- }
- if (dvp) {
- newnp->n_parent = VTONW(dvp)->n_fid;
- if ((newnp->n_flag & NNEW) && vp->v_type == VDIR) {
- if ((dvp->v_flag & VROOT) == 0) {
- newnp->n_refparent = 1;
- vref(dvp); /* vhold */
- }
- }
- } else {
- if ((newnp->n_flag & NNEW) && vp->v_type == VREG)
- printf("new vnode '%s' borned without parent ?\n",newnp->n_name);
- }
- newnp->n_flag &= ~NNEW;
- *vpp = vp;
- return 0;
-}
-
-/*
- * How to keep the brain busy ...
- * Currently lookup routine can make two lookup for vnode. This can be
- * avoided by reorg the code.
- */
-int
-nwfs_lookup(ap)
- struct vop_lookup_args /* {
- struct vnodeop_desc *a_desc;
- struct vnode *a_dvp;
- struct vnode **a_vpp;
- struct componentname *a_cnp;
- } */ *ap;
-{
- struct componentname *cnp = ap->a_cnp;
- struct vnode *dvp = ap->a_dvp;
- struct vnode **vpp = ap->a_vpp;
- int flags = cnp->cn_flags;
- struct vnode *vp;
- struct nwmount *nmp;
- struct mount *mp = dvp->v_mount;
- struct nwnode *dnp, *npp;
- struct nw_entry_info fattr, *fap;
- ncpfid fid;
- int nameiop=cnp->cn_nameiop, islastcn;
- int lockparent, wantparent, error = 0, notfound;
- struct proc *p = cnp->cn_proc;
- char _name[cnp->cn_namelen+1];
- bcopy(cnp->cn_nameptr,_name,cnp->cn_namelen);
- _name[cnp->cn_namelen]=0;
-
- if (dvp->v_type != VDIR)
- return (ENOTDIR);
- if ((flags & ISDOTDOT) && (dvp->v_flag & VROOT)) {
- printf("nwfs_lookup: invalid '..'\n");
- return EIO;
- }
-
- NCPVNDEBUG("%d '%s' in '%s' id=d\n", nameiop, _name,
- VTONW(dvp)->n_name/*, VTONW(dvp)->n_name*/);
-
- islastcn = flags & ISLASTCN;
- if (islastcn && (mp->mnt_flag & MNT_RDONLY) && (nameiop != LOOKUP))
- return (EROFS);
- if ((error = VOP_ACCESS(dvp, VEXEC, cnp->cn_cred, p)))
- return (error);
- lockparent = flags & LOCKPARENT;
- wantparent = flags & (LOCKPARENT|WANTPARENT);
- nmp = VFSTONWFS(mp);
- dnp = VTONW(dvp);
-/*
-printf("dvp %d:%d:%d\n", (int)mp, (int)dvp->v_flag & VROOT, (int)flags & ISDOTDOT);
-*/
- error = ncp_pathcheck(cnp->cn_nameptr, cnp->cn_namelen, &nmp->m.nls,
- (nameiop == CREATE || nameiop == RENAME) && (nmp->m.nls.opt & NWHP_NOSTRICT) == 0);
- if (error)
- return ENOENT;
-
- error = cache_lookup(dvp, vpp, cnp);
- NCPVNDEBUG("cache_lookup returned %d\n",error);
- if (error > 0)
- return error;
- if (error) { /* name was found */
- struct vattr vattr;
- int vpid;
-
- vp = *vpp;
- vpid = vp->v_id;
- if (dvp == vp) { /* lookup on current */
- vref(vp);
- error = 0;
- NCPVNDEBUG("cached '.'");
- } else if (flags & ISDOTDOT) {
- VOP_UNLOCK(dvp, 0, p); /* unlock parent */
- error = vget(vp, LK_EXCLUSIVE, p);
- if (!error && lockparent && islastcn)
- error = vn_lock(dvp, LK_EXCLUSIVE, p);
- } else {
- error = vget(vp, LK_EXCLUSIVE, p);
- if (!lockparent || error || !islastcn)
- VOP_UNLOCK(dvp, 0, p);
- }
- if (!error) {
- if (vpid == vp->v_id) {
- if (!VOP_GETATTR(vp, &vattr, cnp->cn_cred, p)
- && vattr.va_ctime.tv_sec == VTONW(vp)->n_ctime) {
- if (nameiop != LOOKUP && islastcn)
- cnp->cn_flags |= SAVENAME;
- NCPVNDEBUG("use cached vnode");
- return (0);
- }
- cache_purge(vp);
- }
- vput(vp);
- if (lockparent && dvp != vp && islastcn)
- VOP_UNLOCK(dvp, 0, p);
- }
- error = vn_lock(dvp, LK_EXCLUSIVE, p);
- *vpp = NULLVP;
- if (error)
- return (error);
- }
- /* not in cache, so ... */
- error = 0;
- *vpp = NULLVP;
- fap = NULL;
- if (flags & ISDOTDOT) {
- if (NWCMPF(&dnp->n_parent, &nmp->n_rootent)) {
- fid = nmp->n_rootent;
- fap = NULL;
- notfound = 0;
- } else {
- error = nwfs_lookupnp(nmp, dnp->n_parent, &npp);
- if (error) {
- return error;
- }
- fid = dnp->n_parent;
- fap = &fattr;
- /*np = *npp;*/
- notfound = ncp_obtain_info(nmp, npp->n_dosfid,
- 0, NULL, fap, p, cnp->cn_cred);
- }
- } else {
- fap = &fattr;
- notfound = ncp_lookup(dvp, cnp->cn_namelen, cnp->cn_nameptr,
- fap, p, cnp->cn_cred);
- fid.f_id = fap->dirEntNum;
- if (cnp->cn_namelen == 1 && cnp->cn_nameptr[0] == '.') {
- fid.f_parent = dnp->n_fid.f_parent;
- } else
- fid.f_parent = dnp->n_fid.f_id;
- NCPVNDEBUG("call to ncp_lookup returned=%d\n",notfound);
- }
- if (notfound && notfound < 0x80 )
- return (notfound); /* hard error */
- if (notfound) { /* entry not found */
- /* Handle RENAME or CREATE case... */
- if ((nameiop == CREATE || nameiop == RENAME) && wantparent && islastcn) {
- cnp->cn_flags |= SAVENAME;
- if (!lockparent)
- VOP_UNLOCK(dvp, 0, p);
- return (EJUSTRETURN);
- }
- return ENOENT;
- }/* else {
- NCPVNDEBUG("Found entry %s with id=%d\n", fap->entryName, fap->dirEntNum);
- }*/
- /* handle DELETE case ... */
- if (nameiop == DELETE && islastcn) { /* delete last component */
- error = VOP_ACCESS(dvp, VWRITE, cnp->cn_cred, cnp->cn_proc);
- if (error) return (error);
- if (NWCMPF(&dnp->n_fid, &fid)) { /* we found ourselfs */
- VREF(dvp);
- *vpp = dvp;
- return 0;
- }
- error = nwfs_nget(mp, fid, fap, dvp, &vp);
- if (error) return (error);
- *vpp = vp;
- cnp->cn_flags |= SAVENAME; /* I free it later */
- if (!lockparent) VOP_UNLOCK(dvp,0,p);
- return (0);
- }
- if (nameiop == RENAME && islastcn && wantparent) {
- error = VOP_ACCESS(dvp, VWRITE, cnp->cn_cred, cnp->cn_proc);
- if (error) return (error);
- if (NWCMPF(&dnp->n_fid, &fid)) return EISDIR;
- error = nwfs_nget(mp, fid, fap, dvp, &vp);
- if (error) return (error);
- *vpp = vp;
- cnp->cn_flags |= SAVENAME;
- if (!lockparent)
- VOP_UNLOCK(dvp,0,p);
- return (0);
- }
- if (flags & ISDOTDOT) {
- VOP_UNLOCK(dvp, 0, p); /* race to get the inode */
- error = nwfs_nget(mp, fid, NULL, NULL, &vp);
- if (error) {
- vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, p);
- return (error);
- }
- if (lockparent && islastcn &&
- (error = vn_lock(dvp, LK_EXCLUSIVE, p))) {
- vput(vp);
- return (error);
- }
- *vpp = vp;
- } else if (NWCMPF(&dnp->n_fid, &fid)) {
- vref(dvp);
- *vpp = dvp;
- } else {
- error = nwfs_nget(mp, fid, fap, dvp, &vp);
- if (error) return (error);
- *vpp = vp;
- NCPVNDEBUG("lookup: getnewvp!\n");
- if (!lockparent || !islastcn)
- VOP_UNLOCK(dvp, 0, p);
- }
- if ((cnp->cn_flags & MAKEENTRY)/* && !islastcn*/) {
- VTONW(*vpp)->n_ctime = VTONW(*vpp)->n_vattr.va_ctime.tv_sec;
- cache_enter(dvp, *vpp, cnp);
- }
- return (0);
-}
diff --git a/sys/fs/portalfs/portal.h b/sys/fs/portalfs/portal.h
deleted file mode 100644
index ec46662afd76..000000000000
--- a/sys/fs/portalfs/portal.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)portal.h 8.4 (Berkeley) 1/21/94
- *
- * $FreeBSD$
- */
-
-struct portal_args {
- char *pa_config; /* Config file */
- int pa_socket; /* Socket to server */
-};
-
-struct portal_cred {
- int pcr_flag; /* File open mode */
- uid_t pcr_uid; /* From ucred */
- short pcr_ngroups; /* From ucred */
- gid_t pcr_groups[NGROUPS]; /* From ucred */
-};
-
-#ifdef _KERNEL
-struct portalmount {
- struct vnode *pm_root; /* Root node */
- struct file *pm_server; /* Held reference to server socket */
-};
-
-struct portalnode {
- int pt_size; /* Length of Arg */
- char *pt_arg; /* Arg to send to server */
- int pt_fileid; /* cookie */
-};
-
-#define VFSTOPORTAL(mp) ((struct portalmount *)((mp)->mnt_data))
-#define VTOPORTAL(vp) ((struct portalnode *)(vp)->v_data)
-
-#define PORTAL_ROOTFILEID 2
-
-extern vop_t **portal_vnodeop_p;
-#endif /* _KERNEL */
diff --git a/sys/fs/portalfs/portal_vfsops.c b/sys/fs/portalfs/portal_vfsops.c
deleted file mode 100644
index 950d3838aef3..000000000000
--- a/sys/fs/portalfs/portal_vfsops.c
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * Copyright (c) 1992, 1993, 1995
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)portal_vfsops.c 8.11 (Berkeley) 5/14/95
- *
- * $FreeBSD$
- */
-
-/*
- * Portal Filesystem
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/proc.h>
-#include <sys/filedesc.h>
-#include <sys/file.h>
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <sys/malloc.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-#include <sys/protosw.h>
-#include <sys/domain.h>
-#include <miscfs/portal/portal.h>
-
-static MALLOC_DEFINE(M_PORTALFSMNT, "PORTAL mount", "PORTAL mount structure");
-
-static int portal_mount __P((struct mount *mp, char *path, caddr_t data,
- struct nameidata *ndp, struct proc *p));
-static int portal_unmount __P((struct mount *mp, int mntflags,
- struct proc *p));
-static int portal_root __P((struct mount *mp, struct vnode **vpp));
-static int portal_statfs __P((struct mount *mp, struct statfs *sbp,
- struct proc *p));
-
-/*
- * Mount the per-process file descriptors (/dev/fd)
- */
-static int
-portal_mount(mp, path, data, ndp, p)
- struct mount *mp;
- char *path;
- caddr_t data;
- struct nameidata *ndp;
- struct proc *p;
-{
- struct file *fp;
- struct portal_args args;
- struct portalmount *fmp;
- struct socket *so;
- struct vnode *rvp;
- struct portalnode *pn;
- u_int size;
- int error;
-
- /*
- * Update is a no-op
- */
- if (mp->mnt_flag & MNT_UPDATE)
- return (EOPNOTSUPP);
-
- error = copyin(data, (caddr_t) &args, sizeof(struct portal_args));
- if (error)
- return (error);
-
- error = getsock(p->p_fd, args.pa_socket, &fp);
- if (error)
- return (error);
- so = (struct socket *) fp->f_data;
- if (so->so_proto->pr_domain->dom_family != AF_UNIX)
- return (ESOCKTNOSUPPORT);
-
- MALLOC(pn, struct portalnode *, sizeof(struct portalnode),
- M_TEMP, M_WAITOK);
-
- MALLOC(fmp, struct portalmount *, sizeof(struct portalmount),
- M_PORTALFSMNT, M_WAITOK); /* XXX */
-
- error = getnewvnode(VT_PORTAL, mp, portal_vnodeop_p, &rvp); /* XXX */
- if (error) {
- FREE(fmp, M_PORTALFSMNT);
- FREE(pn, M_TEMP);
- return (error);
- }
-
- rvp->v_data = pn;
- rvp->v_type = VDIR;
- rvp->v_flag |= VROOT;
- VTOPORTAL(rvp)->pt_arg = 0;
- VTOPORTAL(rvp)->pt_size = 0;
- VTOPORTAL(rvp)->pt_fileid = PORTAL_ROOTFILEID;
- fmp->pm_root = rvp;
- fmp->pm_server = fp; fp->f_count++;
-
- mp->mnt_flag |= MNT_LOCAL;
- mp->mnt_data = (qaddr_t) fmp;
- vfs_getnewfsid(mp);
-
- (void)copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size);
- bzero(mp->mnt_stat.f_mntonname + size, MNAMELEN - size);
- (void)copyinstr(args.pa_config,
- mp->mnt_stat.f_mntfromname, MNAMELEN - 1, &size);
- bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
-
-#ifdef notdef
- bzero(mp->mnt_stat.f_mntfromname, MNAMELEN);
- bcopy("portal", mp->mnt_stat.f_mntfromname, sizeof("portal"));
-#endif
-
- (void)portal_statfs(mp, &mp->mnt_stat, p);
- return (0);
-}
-
-static int
-portal_unmount(mp, mntflags, p)
- struct mount *mp;
- int mntflags;
- struct proc *p;
-{
- struct vnode *rootvp = VFSTOPORTAL(mp)->pm_root;
- int error, flags = 0;
-
-
- if (mntflags & MNT_FORCE)
- flags |= FORCECLOSE;
-
- /*
- * Clear out buffer cache. I don't think we
- * ever get anything cached at this level at the
- * moment, but who knows...
- */
-#ifdef notyet
- mntflushbuf(mp, 0);
- if (mntinvalbuf(mp, 1))
- return (EBUSY);
-#endif
- if (rootvp->v_usecount > 1)
- return (EBUSY);
- error = vflush(mp, rootvp, flags);
- if (error)
- return (error);
-
- /*
- * Release reference on underlying root vnode
- */
- vrele(rootvp);
- /*
- * And blow it away for future re-use
- */
- vgone(rootvp);
- /*
- * Shutdown the socket. This will cause the select in the
- * daemon to wake up, and then the accept will get ECONNABORTED
- * which it interprets as a request to go and bury itself.
- */
- soshutdown((struct socket *) VFSTOPORTAL(mp)->pm_server->f_data, 2);
- /*
- * Discard reference to underlying file. Must call closef because
- * this may be the last reference.
- */
- closef(VFSTOPORTAL(mp)->pm_server, (struct proc *) 0);
- /*
- * Finally, throw away the portalmount structure
- */
- free(mp->mnt_data, M_PORTALFSMNT); /* XXX */
- mp->mnt_data = 0;
- return (0);
-}
-
-static int
-portal_root(mp, vpp)
- struct mount *mp;
- struct vnode **vpp;
-{
- struct proc *p = curproc; /* XXX */
- struct vnode *vp;
-
- /*
- * Return locked reference to root.
- */
- vp = VFSTOPORTAL(mp)->pm_root;
- VREF(vp);
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
- *vpp = vp;
- return (0);
-}
-
-static int
-portal_statfs(mp, sbp, p)
- struct mount *mp;
- struct statfs *sbp;
- struct proc *p;
-{
-
- sbp->f_flags = 0;
- sbp->f_bsize = DEV_BSIZE;
- sbp->f_iosize = DEV_BSIZE;
- sbp->f_blocks = 2; /* 1K to keep df happy */
- sbp->f_bfree = 0;
- sbp->f_bavail = 0;
- sbp->f_files = 1; /* Allow for "." */
- sbp->f_ffree = 0; /* See comments above */
- if (sbp != &mp->mnt_stat) {
- sbp->f_type = mp->mnt_vfc->vfc_typenum;
- bcopy(&mp->mnt_stat.f_fsid, &sbp->f_fsid, sizeof(sbp->f_fsid));
- bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN);
- bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN);
- }
- return (0);
-}
-
-static struct vfsops portal_vfsops = {
- portal_mount,
- vfs_stdstart,
- portal_unmount,
- portal_root,
- vfs_stdquotactl,
- portal_statfs,
- vfs_stdsync,
- vfs_stdvget,
- vfs_stdfhtovp,
- vfs_stdcheckexp,
- vfs_stdvptofh,
- vfs_stdinit,
- vfs_stduninit,
- vfs_stdextattrctl,
-};
-
-VFS_SET(portal_vfsops, portal, VFCF_SYNTHETIC);
diff --git a/sys/fs/portalfs/portal_vnops.c b/sys/fs/portalfs/portal_vnops.c
deleted file mode 100644
index d4146da6a833..000000000000
--- a/sys/fs/portalfs/portal_vnops.c
+++ /dev/null
@@ -1,606 +0,0 @@
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)portal_vnops.c 8.14 (Berkeley) 5/21/95
- *
- * $FreeBSD$
- */
-
-/*
- * Portal Filesystem
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/sysproto.h>
-#include <sys/kernel.h>
-#include <sys/time.h>
-#include <sys/proc.h>
-#include <sys/filedesc.h>
-#include <sys/vnode.h>
-#include <sys/fcntl.h>
-#include <sys/file.h>
-#include <sys/stat.h>
-#include <sys/mount.h>
-#include <sys/malloc.h>
-#include <sys/namei.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-#include <sys/un.h>
-#include <sys/unpcb.h>
-#include <miscfs/portal/portal.h>
-
-static int portal_fileid = PORTAL_ROOTFILEID+1;
-
-static int portal_badop __P((void));
-static void portal_closefd __P((struct proc *p, int fd));
-static int portal_connect __P((struct socket *so, struct socket *so2));
-static int portal_getattr __P((struct vop_getattr_args *ap));
-static int portal_inactive __P((struct vop_inactive_args *ap));
-static int portal_lookup __P((struct vop_lookup_args *ap));
-static int portal_open __P((struct vop_open_args *ap));
-static int portal_print __P((struct vop_print_args *ap));
-static int portal_readdir __P((struct vop_readdir_args *ap));
-static int portal_reclaim __P((struct vop_reclaim_args *ap));
-static int portal_setattr __P((struct vop_setattr_args *ap));
-
-static void
-portal_closefd(p, fd)
- struct proc *p;
- int fd;
-{
- int error;
- struct close_args ua;
-
- ua.fd = fd;
- error = close(p, &ua);
- /*
- * We should never get an error, and there isn't anything
- * we could do if we got one, so just print a message.
- */
- if (error)
- printf("portal_closefd: error = %d\n", error);
-}
-
-/*
- * vp is the current namei directory
- * cnp is the name to locate in that directory...
- */
-static int
-portal_lookup(ap)
- struct vop_lookup_args /* {
- struct vnode * a_dvp;
- struct vnode ** a_vpp;
- struct componentname * a_cnp;
- } */ *ap;
-{
- struct componentname *cnp = ap->a_cnp;
- struct vnode **vpp = ap->a_vpp;
- struct vnode *dvp = ap->a_dvp;
- char *pname = cnp->cn_nameptr;
- struct portalnode *pt;
- int error;
- struct vnode *fvp = 0;
- char *path;
- int size;
-
- *vpp = NULLVP;
-
- if (cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME)
- return (EROFS);
-
- if (cnp->cn_namelen == 1 && *pname == '.') {
- *vpp = dvp;
- VREF(dvp);
- /*VOP_LOCK(dvp);*/
- return (0);
- }
-
- /*
- * Do the MALLOC before the getnewvnode since doing so afterward
- * might cause a bogus v_data pointer to get dereferenced
- * elsewhere if MALLOC should block.
- */
- MALLOC(pt, struct portalnode *, sizeof(struct portalnode),
- M_TEMP, M_WAITOK);
-
- error = getnewvnode(VT_PORTAL, dvp->v_mount, portal_vnodeop_p, &fvp);
- if (error) {
- FREE(pt, M_TEMP);
- goto bad;
- }
- fvp->v_type = VREG;
- fvp->v_data = pt;
- /*
- * Save all of the remaining pathname and
- * advance the namei next pointer to the end
- * of the string.
- */
- for (size = 0, path = pname; *path; path++)
- size++;
- cnp->cn_consume = size - cnp->cn_namelen;
-
- pt->pt_arg = malloc(size+1, M_TEMP, M_WAITOK);
- pt->pt_size = size+1;
- bcopy(pname, pt->pt_arg, pt->pt_size);
- pt->pt_fileid = portal_fileid++;
-
- *vpp = fvp;
- /*VOP_LOCK(fvp);*/
- return (0);
-
-bad:;
- if (fvp)
- vrele(fvp);
- return (error);
-}
-
-static int
-portal_connect(so, so2)
- struct socket *so;
- struct socket *so2;
-{
- /* from unp_connect, bypassing the namei stuff... */
- struct socket *so3;
- struct unpcb *unp2;
- struct unpcb *unp3;
-
- if (so2 == 0)
- return (ECONNREFUSED);
-
- if (so->so_type != so2->so_type)
- return (EPROTOTYPE);
-
- if ((so2->so_options & SO_ACCEPTCONN) == 0)
- return (ECONNREFUSED);
-
- if ((so3 = sonewconn(so2, 0)) == 0)
- return (ECONNREFUSED);
-
- unp2 = sotounpcb(so2);
- unp3 = sotounpcb(so3);
- if (unp2->unp_addr)
- unp3->unp_addr = (struct sockaddr_un *)
- dup_sockaddr((struct sockaddr *)unp2->unp_addr, 0);
- so2 = so3;
-
- return (unp_connect2(so, so2));
-}
-
-static int
-portal_open(ap)
- struct vop_open_args /* {
- struct vnode *a_vp;
- int a_mode;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- struct socket *so = 0;
- struct portalnode *pt;
- struct proc *p = ap->a_p;
- struct vnode *vp = ap->a_vp;
- int s;
- struct uio auio;
- struct iovec aiov[2];
- int res;
- struct mbuf *cm = 0;
- struct cmsghdr *cmsg;
- int newfds;
- int *ip;
- int fd;
- int error;
- int len;
- struct portalmount *fmp;
- struct file *fp;
- struct portal_cred pcred;
-
- /*
- * Nothing to do when opening the root node.
- */
- if (vp->v_flag & VROOT)
- return (0);
-
- /*
- * Can't be opened unless the caller is set up
- * to deal with the side effects. Check for this
- * by testing whether the p_dupfd has been set.
- */
- if (p->p_dupfd >= 0)
- return (ENODEV);
-
- pt = VTOPORTAL(vp);
- fmp = VFSTOPORTAL(vp->v_mount);
-
- /*
- * Create a new socket.
- */
- error = socreate(AF_UNIX, &so, SOCK_STREAM, 0, ap->a_p);
- if (error)
- goto bad;
-
- /*
- * Reserve some buffer space
- */
- res = pt->pt_size + sizeof(pcred) + 512; /* XXX */
- error = soreserve(so, res, res);
- if (error)
- goto bad;
-
- /*
- * Kick off connection
- */
- error = portal_connect(so, (struct socket *)fmp->pm_server->f_data);
- if (error)
- goto bad;
-
- /*
- * Wait for connection to complete
- */
- /*
- * XXX: Since the mount point is holding a reference on the
- * underlying server socket, it is not easy to find out whether
- * the server process is still running. To handle this problem
- * we loop waiting for the new socket to be connected (something
- * which will only happen if the server is still running) or for
- * the reference count on the server socket to drop to 1, which
- * will happen if the server dies. Sleep for 5 second intervals
- * and keep polling the reference count. XXX.
- */
- s = splnet();
- while ((so->so_state & SS_ISCONNECTING) && so->so_error == 0) {
- if (fmp->pm_server->f_count == 1) {
- error = ECONNREFUSED;
- splx(s);
- goto bad;
- }
- (void) tsleep((caddr_t) &so->so_timeo, PSOCK, "portalcon", 5 * hz);
- }
- splx(s);
-
- if (so->so_error) {
- error = so->so_error;
- goto bad;
- }
-
- /*
- * Set miscellaneous flags
- */
- so->so_rcv.sb_timeo = 0;
- so->so_snd.sb_timeo = 0;
- so->so_rcv.sb_flags |= SB_NOINTR;
- so->so_snd.sb_flags |= SB_NOINTR;
-
-
- pcred.pcr_flag = ap->a_mode;
- pcred.pcr_uid = ap->a_cred->cr_uid;
- pcred.pcr_ngroups = ap->a_cred->cr_ngroups;
- bcopy(ap->a_cred->cr_groups, pcred.pcr_groups, NGROUPS * sizeof(gid_t));
- aiov[0].iov_base = (caddr_t) &pcred;
- aiov[0].iov_len = sizeof(pcred);
- aiov[1].iov_base = pt->pt_arg;
- aiov[1].iov_len = pt->pt_size;
- auio.uio_iov = aiov;
- auio.uio_iovcnt = 2;
- auio.uio_rw = UIO_WRITE;
- auio.uio_segflg = UIO_SYSSPACE;
- auio.uio_procp = p;
- auio.uio_offset = 0;
- auio.uio_resid = aiov[0].iov_len + aiov[1].iov_len;
-
- error = sosend(so, (struct sockaddr *) 0, &auio,
- (struct mbuf *) 0, (struct mbuf *) 0, 0, p);
- if (error)
- goto bad;
-
- len = auio.uio_resid = sizeof(int);
- do {
- struct mbuf *m = 0;
- int flags = MSG_WAITALL;
- error = soreceive(so, (struct sockaddr **) 0, &auio,
- &m, &cm, &flags);
- if (error)
- goto bad;
-
- /*
- * Grab an error code from the mbuf.
- */
- if (m) {
- m = m_pullup(m, sizeof(int)); /* Needed? */
- if (m) {
- error = *(mtod(m, int *));
- m_freem(m);
- } else {
- error = EINVAL;
- }
- } else {
- if (cm == 0) {
- error = ECONNRESET; /* XXX */
-#ifdef notdef
- break;
-#endif
- }
- }
- } while (cm == 0 && auio.uio_resid == len && !error);
-
- if (cm == 0)
- goto bad;
-
- if (auio.uio_resid) {
- error = 0;
-#ifdef notdef
- error = EMSGSIZE;
- goto bad;
-#endif
- }
-
- /*
- * XXX: Break apart the control message, and retrieve the
- * received file descriptor. Note that more than one descriptor
- * may have been received, or that the rights chain may have more
- * than a single mbuf in it. What to do?
- */
- cmsg = mtod(cm, struct cmsghdr *);
- newfds = (cmsg->cmsg_len - sizeof(*cmsg)) / sizeof (int);
- if (newfds == 0) {
- error = ECONNREFUSED;
- goto bad;
- }
- /*
- * At this point the rights message consists of a control message
- * header, followed by a data region containing a vector of
- * integer file descriptors. The fds were allocated by the action
- * of receiving the control message.
- */
- ip = (int *) (cmsg + 1);
- fd = *ip++;
- if (newfds > 1) {
- /*
- * Close extra fds.
- */
- int i;
- printf("portal_open: %d extra fds\n", newfds - 1);
- for (i = 1; i < newfds; i++) {
- portal_closefd(p, *ip);
- ip++;
- }
- }
-
- /*
- * Check that the mode the file is being opened for is a subset
- * of the mode of the existing descriptor.
- */
- fp = p->p_fd->fd_ofiles[fd];
- if (((ap->a_mode & (FREAD|FWRITE)) | fp->f_flag) != fp->f_flag) {
- portal_closefd(p, fd);
- error = EACCES;
- goto bad;
- }
-
- /*
- * Save the dup fd in the proc structure then return the
- * special error code (ENXIO) which causes magic things to
- * happen in vn_open. The whole concept is, well, hmmm.
- */
- p->p_dupfd = fd;
- error = ENXIO;
-
-bad:;
- /*
- * And discard the control message.
- */
- if (cm) {
- m_freem(cm);
- }
-
- if (so) {
- soshutdown(so, 2);
- soclose(so);
- }
- return (error);
-}
-
-static int
-portal_getattr(ap)
- struct vop_getattr_args /* {
- struct vnode *a_vp;
- struct vattr *a_vap;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
- struct vattr *vap = ap->a_vap;
-
- bzero(vap, sizeof(*vap));
- vattr_null(vap);
- vap->va_uid = 0;
- vap->va_gid = 0;
- vap->va_size = DEV_BSIZE;
- vap->va_blocksize = DEV_BSIZE;
- nanotime(&vap->va_atime);
- vap->va_mtime = vap->va_atime;
- vap->va_ctime = vap->va_mtime;
- vap->va_gen = 0;
- vap->va_flags = 0;
- vap->va_rdev = 0;
- /* vap->va_qbytes = 0; */
- vap->va_bytes = 0;
- /* vap->va_qsize = 0; */
- if (vp->v_flag & VROOT) {
- vap->va_type = VDIR;
- vap->va_mode = S_IRUSR|S_IWUSR|S_IXUSR|
- S_IRGRP|S_IWGRP|S_IXGRP|
- S_IROTH|S_IWOTH|S_IXOTH;
- vap->va_nlink = 2;
- vap->va_fileid = 2;
- } else {
- vap->va_type = VREG;
- vap->va_mode = S_IRUSR|S_IWUSR|
- S_IRGRP|S_IWGRP|
- S_IROTH|S_IWOTH;
- vap->va_nlink = 1;
- vap->va_fileid = VTOPORTAL(vp)->pt_fileid;
- }
- return (0);
-}
-
-static int
-portal_setattr(ap)
- struct vop_setattr_args /* {
- struct vnode *a_vp;
- struct vattr *a_vap;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
-
- /*
- * Can't mess with the root vnode
- */
- if (ap->a_vp->v_flag & VROOT)
- return (EACCES);
-
- if (ap->a_vap->va_flags != VNOVAL)
- return (EOPNOTSUPP);
-
- return (0);
-}
-
-/*
- * Fake readdir, just return empty directory.
- * It is hard to deal with '.' and '..' so don't bother.
- */
-static int
-portal_readdir(ap)
- struct vop_readdir_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- struct ucred *a_cred;
- int *a_eofflag;
- u_long *a_cookies;
- int a_ncookies;
- } */ *ap;
-{
-
- /*
- * We don't allow exporting portal mounts, and currently local
- * requests do not need cookies.
- */
- if (ap->a_ncookies)
- panic("portal_readdir: not hungry");
-
- return (0);
-}
-
-static int
-portal_inactive(ap)
- struct vop_inactive_args /* {
- struct vnode *a_vp;
- struct proc *a_p;
- } */ *ap;
-{
-
- VOP_UNLOCK(ap->a_vp, 0, ap->a_p);
- return (0);
-}
-
-static int
-portal_reclaim(ap)
- struct vop_reclaim_args /* {
- struct vnode *a_vp;
- } */ *ap;
-{
- struct portalnode *pt = VTOPORTAL(ap->a_vp);
-
- if (pt->pt_arg) {
- free((caddr_t) pt->pt_arg, M_TEMP);
- pt->pt_arg = 0;
- }
- FREE(ap->a_vp->v_data, M_TEMP);
- ap->a_vp->v_data = 0;
-
- return (0);
-}
-
-
-/*
- * Print out the contents of a Portal vnode.
- */
-/* ARGSUSED */
-static int
-portal_print(ap)
- struct vop_print_args /* {
- struct vnode *a_vp;
- } */ *ap;
-{
-
- printf("tag VT_PORTAL, portal vnode\n");
- return (0);
-}
-
-
-/*
- * Portal "should never get here" operation
- */
-static int
-portal_badop()
-{
-
- panic("portal: bad op");
- /* NOTREACHED */
-}
-
-vop_t **portal_vnodeop_p;
-static struct vnodeopv_entry_desc portal_vnodeop_entries[] = {
- { &vop_default_desc, (vop_t *) vop_defaultop },
- { &vop_access_desc, (vop_t *) vop_null },
- { &vop_bmap_desc, (vop_t *) portal_badop },
- { &vop_getattr_desc, (vop_t *) portal_getattr },
- { &vop_inactive_desc, (vop_t *) portal_inactive },
- { &vop_lookup_desc, (vop_t *) portal_lookup },
- { &vop_open_desc, (vop_t *) portal_open },
- { &vop_pathconf_desc, (vop_t *) vop_stdpathconf },
- { &vop_print_desc, (vop_t *) portal_print },
- { &vop_readdir_desc, (vop_t *) portal_readdir },
- { &vop_reclaim_desc, (vop_t *) portal_reclaim },
- { &vop_setattr_desc, (vop_t *) portal_setattr },
- { NULL, NULL }
-};
-static struct vnodeopv_desc portal_vnodeop_opv_desc =
- { &portal_vnodeop_p, portal_vnodeop_entries };
-
-VNODEOP_SET(portal_vnodeop_opv_desc);
diff --git a/sys/fs/procfs/README b/sys/fs/procfs/README
deleted file mode 100644
index f816b321b432..000000000000
--- a/sys/fs/procfs/README
+++ /dev/null
@@ -1,113 +0,0 @@
-saute procfs lyonnais
-
-procfs supports two levels of directory. the filesystem root
-directory contains a representation of the system process table.
-this consists of an entry for each active and zombie process, and
-an additional entry "curproc" which always represents the process
-making the lookup request.
-
-each of the sub-directories contains several files. these files
-are used to control and interrogate processes. the files implemented
-are:
-
- file - xxx. the exec'ed file.
-
- status - r/o. returns process status.
-
- ctl - w/o. sends a control message to the process.
- for example:
- echo hup > /proc/curproc/note
- will send a SIGHUP to the shell.
- whereas
- echo attach > /proc/1293/ctl
- would set up process 1293 for debugging.
- see below for more details.
-
- mem - r/w. virtual memory image of the process.
- parts of the address space are readable
- only if they exist in the target process.
- a more reasonable alternative might be
- to return zero pages instead of an error.
- comments?
-
- note - w/o. writing a string here sends the
- equivalent note to the process.
- [ not implemented. ]
-
- notepg - w/o. the same as note, but sends to all
- members of the process group.
- [ not implemented. ]
-
- regs - r/w. process register set. this can be read
- or written any time even if the process
- is not stopped. since the bsd kernel
- is single-processor, this implementation
- will get the "right" register values.
- a multi-proc kernel would need to do some
- synchronisation.
-
-this then looks like:
-
-% ls -li /proc
-total 0
- 9 dr-xr-xr-x 2 root wheel 0 Sep 21 15:06 0
- 17 dr-xr-xr-x 2 root wheel 0 Sep 21 15:06 1
- 89 dr-xr-xr-x 2 root wheel 0 Sep 21 15:06 10
- 25 dr-xr-xr-x 2 root wheel 0 Sep 21 15:06 2
-2065 dr-xr-xr-x 2 root wheel 0 Sep 21 15:06 257
-2481 dr-xr-xr-x 2 jsp staff 0 Sep 21 15:06 309
- 265 dr-xr-xr-x 2 root wheel 0 Sep 21 15:06 32
-3129 dr-xr-xr-x 2 jsp staff 0 Sep 21 15:06 390
-3209 dr-xr-xr-x 2 jsp staff 0 Sep 21 15:06 400
-3217 dr-xr-xr-x 2 jsp staff 0 Sep 21 15:06 401
-3273 dr-xr-xr-x 2 jsp staff 0 Sep 21 15:06 408
- 393 dr-xr-xr-x 2 root wheel 0 Sep 21 15:06 48
- 409 dr-xr-xr-x 2 root wheel 0 Sep 21 15:06 50
- 465 dr-xr-xr-x 2 root wheel 0 Sep 21 15:06 57
- 481 dr-xr-xr-x 2 root wheel 0 Sep 21 15:06 59
- 537 dr-xr-xr-x 2 root kmem 0 Sep 21 15:06 66
- 545 dr-xr-xr-x 2 root wheel 0 Sep 21 15:06 67
- 657 dr-xr-xr-x 2 jsp staff 0 Sep 21 15:06 81
- 665 dr-xr-xr-x 2 jsp staff 0 Sep 21 15:06 82
- 673 dr-xr-xr-x 2 jsp staff 0 Sep 21 15:06 83
- 681 dr-xr-xr-x 2 root wheel 0 Sep 21 15:06 84
-3273 dr-xr-xr-x 2 jsp staff 0 Sep 21 15:06 curproc
-% ls -li /proc/curproc
-total 408
-3341 --w------- 1 jsp staff 0 Sep 21 15:06 ctl
-1554 -r-xr-xr-x 1 bin bin 90112 Mar 29 04:52 file
-3339 -rw------- 1 jsp staff 118784 Sep 21 15:06 mem
-3343 --w------- 1 jsp staff 0 Sep 21 15:06 note
-3344 --w------- 1 jsp staff 0 Sep 21 15:06 notepg
-3340 -rw------- 1 jsp staff 0 Sep 21 15:06 regs
-3342 -r--r--r-- 1 jsp staff 0 Sep 21 15:06 status
-% df /proc/curproc /proc/curproc/file
-Filesystem 512-blocks Used Avail Capacity Mounted on
-proc 2 2 0 100% /proc
-/dev/wd0a 16186 13548 1018 93% /
-% cat /proc/curproc/status
-cat 446 439 400 81 12,0 ctty 748620684 270000 0 0 0 20000 nochan 11 20 20 20 0 21 117
-
-
-
-the basic sequence of commands written to "ctl" would be
-
- attach - this stops the target process and
- arranges for the sending process
- to become the debug control process
- wait - wait for the target process to come to
- a steady state ready for debugging.
- step - single step, with no signal delivery.
- run - continue running, with no signal delivery,
- until next trap or breakpoint.
- <signame> - deliver signal <signame> and continue running.
- detach - continue execution of the target process
- and remove it from control by the debug process
-
-in a normal debugging environment, where the target is fork/exec'd by
-the debugger, the debugger should fork and the child should stop itself
-(with a self-inflicted SIGSTOP). the parent should do a "wait" then an
-"attach". as before, the child will hit a breakpoint on the first
-instruction in any newly exec'd image.
-
-$FreeBSD$
diff --git a/sys/fs/procfs/procfs.h b/sys/fs/procfs/procfs.h
deleted file mode 100644
index f0000267b5d7..000000000000
--- a/sys/fs/procfs/procfs.h
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Copyright (c) 1993 Jan-Simon Pendry
- * Copyright (c) 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)procfs.h 8.9 (Berkeley) 5/14/95
- *
- * From:
- * $FreeBSD$
- */
-
-/*
- * The different types of node in a procfs filesystem
- */
-typedef enum {
- Proot, /* the filesystem root */
- Pcurproc, /* symbolic link for curproc */
- Pproc, /* a process-specific sub-directory */
- Pfile, /* the executable file */
- Pmem, /* the process's memory image */
- Pregs, /* the process's register set */
- Pfpregs, /* the process's FP register set */
- Pdbregs, /* the process's debug register set */
- Pctl, /* process control */
- Pstatus, /* process status */
- Pnote, /* process notifier */
- Pnotepg, /* process group notifier */
- Pmap, /* memory map */
- Ptype, /* executable type */
- Pcmdline, /* command line */
- Prlimit /* resource limits */
-} pfstype;
-
-/*
- * control data for the proc file system.
- */
-struct pfsnode {
- struct pfsnode *pfs_next; /* next on list */
- struct vnode *pfs_vnode; /* vnode associated with this pfsnode */
- pfstype pfs_type; /* type of procfs node */
- pid_t pfs_pid; /* associated process */
- u_short pfs_mode; /* mode bits for stat() */
- u_long pfs_flags; /* open flags */
- u_long pfs_fileno; /* unique file id */
- pid_t pfs_lockowner; /* pfs lock owner */
-};
-
-#define PROCFS_NOTELEN 64 /* max length of a note (/proc/$pid/note) */
-#define PROCFS_CTLLEN 8 /* max length of a ctl msg (/proc/$pid/ctl */
-#define PROCFS_NAMELEN 8 /* max length of a filename component */
-
-/*
- * Kernel stuff follows
- */
-#ifdef _KERNEL
-#define CNEQ(cnp, s, len) \
- ((cnp)->cn_namelen == (len) && \
- (bcmp((s), (cnp)->cn_nameptr, (len)) == 0))
-
-#define KMEM_GROUP 2
-
-#define PROCFS_FILENO(pid, type) \
- (((type) < Pproc) ? \
- ((type) + 2) : \
- ((((pid)+1) << 4) + ((int) (type))))
-
-/*
- * Convert between pfsnode vnode
- */
-#define VTOPFS(vp) ((struct pfsnode *)(vp)->v_data)
-#define PFSTOV(pfs) ((pfs)->pfs_vnode)
-
-typedef struct vfs_namemap vfs_namemap_t;
-struct vfs_namemap {
- const char *nm_name;
- int nm_val;
-};
-
-int vfs_getuserstr __P((struct uio *, char *, int *));
-vfs_namemap_t *vfs_findname __P((vfs_namemap_t *, char *, int));
-
-/* <machine/reg.h> */
-struct reg;
-struct fpreg;
-struct dbreg;
-
-#define PFIND(pid) ((pid) ? pfind(pid) : &proc0)
-
-void procfs_exit __P((struct proc *));
-int procfs_freevp __P((struct vnode *));
-int procfs_allocvp __P((struct mount *, struct vnode **, long, pfstype));
-struct vnode *procfs_findtextvp __P((struct proc *));
-int procfs_sstep __P((struct proc *));
-void procfs_fix_sstep __P((struct proc *));
-int procfs_read_regs __P((struct proc *, struct reg *));
-int procfs_write_regs __P((struct proc *, struct reg *));
-int procfs_read_fpregs __P((struct proc *, struct fpreg *));
-int procfs_write_fpregs __P((struct proc *, struct fpreg *));
-int procfs_read_dbregs __P((struct proc *, struct dbreg *));
-int procfs_write_dbregs __P((struct proc *, struct dbreg *));
-int procfs_donote __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio));
-int procfs_doregs __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio));
-int procfs_dofpregs __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio));
-int procfs_dodbregs __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio));
-int procfs_domem __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio));
-int procfs_doctl __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio));
-int procfs_dostatus __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio));
-int procfs_domap __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio));
-int procfs_dotype __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio));
-int procfs_docmdline __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio));
-int procfs_dorlimit __P((struct proc *, struct proc *, struct pfsnode *pfsp, struct uio *uio));
-
-/* Return 1 if process has special kernel digging privileges */
-int procfs_kmemaccess __P((struct proc *));
-
-/* functions to check whether or not files should be displayed */
-int procfs_validfile __P((struct proc *));
-int procfs_validfpregs __P((struct proc *));
-int procfs_validregs __P((struct proc *));
-int procfs_validdbregs __P((struct proc *));
-int procfs_validmap __P((struct proc *));
-int procfs_validtype __P((struct proc *));
-
-#define PROCFS_LOCKED 0x01
-#define PROCFS_WANT 0x02
-
-extern vop_t **procfs_vnodeop_p;
-
-int procfs_root __P((struct mount *, struct vnode **));
-int procfs_rw __P((struct vop_read_args *));
-#endif /* _KERNEL */
diff --git a/sys/fs/procfs/procfs_ctl.c b/sys/fs/procfs/procfs_ctl.c
deleted file mode 100644
index d96bcb34d1d4..000000000000
--- a/sys/fs/procfs/procfs_ctl.c
+++ /dev/null
@@ -1,314 +0,0 @@
-/*
- * Copyright (c) 1993 Jan-Simon Pendry
- * Copyright (c) 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)procfs_ctl.c 8.4 (Berkeley) 6/15/94
- *
- * From:
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/proc.h>
-#include <sys/vnode.h>
-#include <sys/ptrace.h>
-#include <sys/signalvar.h>
-#include <miscfs/procfs/procfs.h>
-
-#include <vm/vm.h>
-
-#ifndef FIX_SSTEP
-#define FIX_SSTEP(p)
-#endif
-
-/*
- * True iff process (p) is in trace wait state
- * relative to process (curp)
- */
-#define TRACE_WAIT_P(curp, p) \
- ((p)->p_stat == SSTOP && \
- (p)->p_pptr == (curp) && \
- ((p)->p_flag & P_TRACED))
-
-#define PROCFS_CTL_ATTACH 1
-#define PROCFS_CTL_DETACH 2
-#define PROCFS_CTL_STEP 3
-#define PROCFS_CTL_RUN 4
-#define PROCFS_CTL_WAIT 5
-
-static vfs_namemap_t ctlnames[] = {
- /* special /proc commands */
- { "attach", PROCFS_CTL_ATTACH },
- { "detach", PROCFS_CTL_DETACH },
- { "step", PROCFS_CTL_STEP },
- { "run", PROCFS_CTL_RUN },
- { "wait", PROCFS_CTL_WAIT },
- { 0 },
-};
-
-static vfs_namemap_t signames[] = {
- /* regular signal names */
- { "hup", SIGHUP }, { "int", SIGINT },
- { "quit", SIGQUIT }, { "ill", SIGILL },
- { "trap", SIGTRAP }, { "abrt", SIGABRT },
- { "iot", SIGIOT }, { "emt", SIGEMT },
- { "fpe", SIGFPE }, { "kill", SIGKILL },
- { "bus", SIGBUS }, { "segv", SIGSEGV },
- { "sys", SIGSYS }, { "pipe", SIGPIPE },
- { "alrm", SIGALRM }, { "term", SIGTERM },
- { "urg", SIGURG }, { "stop", SIGSTOP },
- { "tstp", SIGTSTP }, { "cont", SIGCONT },
- { "chld", SIGCHLD }, { "ttin", SIGTTIN },
- { "ttou", SIGTTOU }, { "io", SIGIO },
- { "xcpu", SIGXCPU }, { "xfsz", SIGXFSZ },
- { "vtalrm", SIGVTALRM }, { "prof", SIGPROF },
- { "winch", SIGWINCH }, { "info", SIGINFO },
- { "usr1", SIGUSR1 }, { "usr2", SIGUSR2 },
- { 0 },
-};
-
-static int procfs_control __P((struct proc *curp, struct proc *p, int op));
-
-static int
-procfs_control(curp, p, op)
- struct proc *curp;
- struct proc *p;
- int op;
-{
- int error;
-
- /*
- * Attach - attaches the target process for debugging
- * by the calling process.
- */
- if (op == PROCFS_CTL_ATTACH) {
- /* check whether already being traced */
- if (p->p_flag & P_TRACED)
- return (EBUSY);
-
- /* can't trace yourself! */
- if (p->p_pid == curp->p_pid)
- return (EINVAL);
-
- /* can't trace init when securelevel > 0 */
- if (securelevel > 0 && p->p_pid == 1)
- return (EPERM);
-
- /*
- * Go ahead and set the trace flag.
- * Save the old parent (it's reset in
- * _DETACH, and also in kern_exit.c:wait4()
- * Reparent the process so that the tracing
- * proc gets to see all the action.
- * Stop the target.
- */
- p->p_flag |= P_TRACED;
- faultin(p);
- p->p_xstat = 0; /* XXX ? */
- if (p->p_pptr != curp) {
- p->p_oppid = p->p_pptr->p_pid;
- proc_reparent(p, curp);
- }
- psignal(p, SIGSTOP);
- return (0);
- }
-
- /*
- * Target process must be stopped, owned by (curp) and
- * be set up for tracing (P_TRACED flag set).
- * Allow DETACH to take place at any time for sanity.
- * Allow WAIT any time, of course.
- */
- switch (op) {
- case PROCFS_CTL_DETACH:
- case PROCFS_CTL_WAIT:
- break;
-
- default:
- if (!TRACE_WAIT_P(curp, p))
- return (EBUSY);
- }
-
-
-#ifdef FIX_SSTEP
- /*
- * do single-step fixup if needed
- */
- FIX_SSTEP(p);
-#endif
-
- /*
- * Don't deliver any signal by default.
- * To continue with a signal, just send
- * the signal name to the ctl file
- */
- p->p_xstat = 0;
-
- switch (op) {
- /*
- * Detach. Cleans up the target process, reparent it if possible
- * and set it running once more.
- */
- case PROCFS_CTL_DETACH:
- /* if not being traced, then this is a painless no-op */
- if ((p->p_flag & P_TRACED) == 0)
- return (0);
-
- /* not being traced any more */
- p->p_flag &= ~P_TRACED;
-
- /* remove pending SIGTRAP, else the process will die */
- SIGDELSET(p->p_siglist, SIGTRAP);
-
- /* give process back to original parent */
- if (p->p_oppid != p->p_pptr->p_pid) {
- struct proc *pp;
-
- pp = pfind(p->p_oppid);
- if (pp)
- proc_reparent(p, pp);
- }
-
- p->p_oppid = 0;
- p->p_flag &= ~P_WAITED; /* XXX ? */
- wakeup((caddr_t) curp); /* XXX for CTL_WAIT below ? */
-
- break;
-
- /*
- * Step. Let the target process execute a single instruction.
- */
- case PROCFS_CTL_STEP:
- PHOLD(p);
- error = procfs_sstep(p);
- PRELE(p);
- if (error)
- return (error);
- break;
-
- /*
- * Run. Let the target process continue running until a breakpoint
- * or some other trap.
- */
- case PROCFS_CTL_RUN:
- break;
-
- /*
- * Wait for the target process to stop.
- * If the target is not being traced then just wait
- * to enter
- */
- case PROCFS_CTL_WAIT:
- error = 0;
- if (p->p_flag & P_TRACED) {
- while (error == 0 &&
- (p->p_stat != SSTOP) &&
- (p->p_flag & P_TRACED) &&
- (p->p_pptr == curp)) {
- error = tsleep((caddr_t) p,
- PWAIT|PCATCH, "procfsx", 0);
- }
- if (error == 0 && !TRACE_WAIT_P(curp, p))
- error = EBUSY;
- } else {
- while (error == 0 && p->p_stat != SSTOP) {
- error = tsleep((caddr_t) p,
- PWAIT|PCATCH, "procfs", 0);
- }
- }
- return (error);
-
- default:
- panic("procfs_control");
- }
-
- if (p->p_stat == SSTOP)
- setrunnable(p);
- return (0);
-}
-
-int
-procfs_doctl(curp, p, pfs, uio)
- struct proc *curp;
- struct pfsnode *pfs;
- struct uio *uio;
- struct proc *p;
-{
- int xlen;
- int error;
- char msg[PROCFS_CTLLEN+1];
- vfs_namemap_t *nm;
-
- if (uio->uio_rw != UIO_WRITE)
- return (EOPNOTSUPP);
-
- xlen = PROCFS_CTLLEN;
- error = vfs_getuserstr(uio, msg, &xlen);
- if (error)
- return (error);
-
- /*
- * Map signal names into signal generation
- * or debug control. Unknown commands and/or signals
- * return EOPNOTSUPP.
- *
- * Sending a signal while the process is being debugged
- * also has the side effect of letting the target continue
- * to run. There is no way to single-step a signal delivery.
- */
- error = EOPNOTSUPP;
-
- nm = vfs_findname(ctlnames, msg, xlen);
- if (nm) {
- error = procfs_control(curp, p, nm->nm_val);
- } else {
- nm = vfs_findname(signames, msg, xlen);
- if (nm) {
- if (TRACE_WAIT_P(curp, p)) {
- p->p_xstat = nm->nm_val;
-#ifdef FIX_SSTEP
- FIX_SSTEP(p);
-#endif
- setrunnable(p);
- } else {
- psignal(p, nm->nm_val);
- }
- error = 0;
- }
- }
-
- return (error);
-}
diff --git a/sys/fs/procfs/procfs_dbregs.c b/sys/fs/procfs/procfs_dbregs.c
deleted file mode 100644
index 158c3f4ab269..000000000000
--- a/sys/fs/procfs/procfs_dbregs.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/*-
- * Copyright (c) 1999 Brian Scott Dean, brdean@unx.sas.com.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Jan-Simon Pendry under the following copyrights and conditions:
- *
- * Copyright (c) 1993 Jan-Simon Pendry
- * Copyright (c) 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/proc.h>
-#include <sys/vnode.h>
-#include <machine/reg.h>
-#include <miscfs/procfs/procfs.h>
-#include <vm/vm.h>
-
-int
-procfs_dodbregs(curp, p, pfs, uio)
- struct proc *curp;
- struct proc *p;
- struct pfsnode *pfs;
- struct uio *uio;
-{
- int error;
- struct dbreg r;
- char *kv;
- int kl;
-
- if (p_trespass(curp, p))
- return (EPERM);
- kl = sizeof(r);
- kv = (char *) &r;
-
- kv += uio->uio_offset;
- kl -= uio->uio_offset;
- if (kl > uio->uio_resid)
- kl = uio->uio_resid;
-
- PHOLD(p);
-
- if (kl < 0)
- error = EINVAL;
- else
- error = procfs_read_dbregs(p, &r);
- if (error == 0)
- error = uiomove(kv, kl, uio);
- if (error == 0 && uio->uio_rw == UIO_WRITE) {
- if (p->p_stat != SSTOP)
- error = EBUSY;
- else
- error = procfs_write_dbregs(p, &r);
- }
- PRELE(p);
-
- uio->uio_offset = 0;
- return (error);
-}
-
-int
-procfs_validdbregs(p)
- struct proc *p;
-{
- return ((p->p_flag & P_SYSTEM) == 0);
-}
diff --git a/sys/fs/procfs/procfs_fpregs.c b/sys/fs/procfs/procfs_fpregs.c
deleted file mode 100644
index 353b52bcac82..000000000000
--- a/sys/fs/procfs/procfs_fpregs.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (c) 1993 Jan-Simon Pendry
- * Copyright (c) 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)procfs_fpregs.c 8.2 (Berkeley) 6/15/94
- *
- * From:
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/proc.h>
-#include <sys/vnode.h>
-#include <machine/reg.h>
-#include <miscfs/procfs/procfs.h>
-#include <vm/vm.h>
-
-int
-procfs_dofpregs(curp, p, pfs, uio)
- struct proc *curp;
- struct proc *p;
- struct pfsnode *pfs;
- struct uio *uio;
-{
- int error;
- struct fpreg r;
- char *kv;
- int kl;
-
- if (p_trespass(curp, p))
- return EPERM;
- kl = sizeof(r);
- kv = (char *) &r;
-
- kv += uio->uio_offset;
- kl -= uio->uio_offset;
- if (kl > uio->uio_resid)
- kl = uio->uio_resid;
-
- PHOLD(p);
-
- if (kl < 0)
- error = EINVAL;
- else
- error = procfs_read_fpregs(p, &r);
- if (error == 0)
- error = uiomove(kv, kl, uio);
- if (error == 0 && uio->uio_rw == UIO_WRITE) {
- if (p->p_stat != SSTOP)
- error = EBUSY;
- else
- error = procfs_write_fpregs(p, &r);
- }
- PRELE(p);
-
- uio->uio_offset = 0;
- return (error);
-}
-
-int
-procfs_validfpregs(p)
- struct proc *p;
-{
- return ((p->p_flag & P_SYSTEM) == 0);
-}
diff --git a/sys/fs/procfs/procfs_map.c b/sys/fs/procfs/procfs_map.c
deleted file mode 100644
index 1caa6305a730..000000000000
--- a/sys/fs/procfs/procfs_map.c
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Copyright (c) 1993 Jan-Simon Pendry
- * Copyright (c) 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)procfs_status.c 8.3 (Berkeley) 2/17/94
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/proc.h>
-#include <sys/vnode.h>
-#include <miscfs/procfs/procfs.h>
-
-#include <vm/vm.h>
-#include <sys/lock.h>
-#include <vm/pmap.h>
-#include <vm/vm_map.h>
-#include <vm/vm_page.h>
-#include <vm/vm_object.h>
-
-
-#define MEBUFFERSIZE 256
-
-/*
- * The map entries can *almost* be read with programs like cat. However,
- * large maps need special programs to read. It is not easy to implement
- * a program that can sense the required size of the buffer, and then
- * subsequently do a read with the appropriate size. This operation cannot
- * be atomic. The best that we can do is to allow the program to do a read
- * with an arbitrarily large buffer, and return as much as we can. We can
- * return an error code if the buffer is too small (EFBIG), then the program
- * can try a bigger buffer.
- */
-int
-procfs_domap(curp, p, pfs, uio)
- struct proc *curp;
- struct proc *p;
- struct pfsnode *pfs;
- struct uio *uio;
-{
- int len;
- int error;
- vm_map_t map = &p->p_vmspace->vm_map;
- pmap_t pmap = vmspace_pmap(p->p_vmspace);
- vm_map_entry_t entry;
- char mebuffer[MEBUFFERSIZE];
-
- if (uio->uio_rw != UIO_READ)
- return (EOPNOTSUPP);
-
- if (uio->uio_offset != 0)
- return (0);
-
- error = 0;
- if (map != &curproc->p_vmspace->vm_map)
- vm_map_lock_read(map);
- for (entry = map->header.next;
- ((uio->uio_resid > 0) && (entry != &map->header));
- entry = entry->next) {
- vm_object_t obj, tobj, lobj;
- int ref_count, shadow_count, flags;
- vm_offset_t addr;
- int resident, privateresident;
- char *type;
-
- if (entry->eflags & MAP_ENTRY_IS_SUB_MAP)
- continue;
-
- obj = entry->object.vm_object;
- if (obj && (obj->shadow_count == 1))
- privateresident = obj->resident_page_count;
- else
- privateresident = 0;
-
- resident = 0;
- addr = entry->start;
- while (addr < entry->end) {
- if (pmap_extract( pmap, addr))
- resident++;
- addr += PAGE_SIZE;
- }
-
- for( lobj = tobj = obj; tobj; tobj = tobj->backing_object)
- lobj = tobj;
-
- if (lobj) {
- switch(lobj->type) {
-
-default:
-case OBJT_DEFAULT:
- type = "default";
- break;
-case OBJT_VNODE:
- type = "vnode";
- break;
-case OBJT_SWAP:
- type = "swap";
- break;
-case OBJT_DEVICE:
- type = "device";
- break;
- }
-
- flags = obj->flags;
- ref_count = obj->ref_count;
- shadow_count = obj->shadow_count;
- } else {
- type = "none";
- flags = 0;
- ref_count = 0;
- shadow_count = 0;
- }
-
-
- /*
- * format:
- * start, end, resident, private resident, cow, access, type.
- */
- snprintf(mebuffer, sizeof(mebuffer),
- "0x%lx 0x%lx %d %d %p %s%s%s %d %d 0x%x %s %s %s\n",
- (u_long)entry->start, (u_long)entry->end,
- resident, privateresident, obj,
- (entry->protection & VM_PROT_READ)?"r":"-",
- (entry->protection & VM_PROT_WRITE)?"w":"-",
- (entry->protection & VM_PROT_EXECUTE)?"x":"-",
- ref_count, shadow_count, flags,
- (entry->eflags & MAP_ENTRY_COW)?"COW":"NCOW",
- (entry->eflags & MAP_ENTRY_NEEDS_COPY)?"NC":"NNC",
- type);
-
- len = strlen(mebuffer);
- if (len > uio->uio_resid) {
- error = EFBIG;
- break;
- }
- error = uiomove(mebuffer, len, uio);
- if (error)
- break;
- }
- if (map != &curproc->p_vmspace->vm_map)
- vm_map_unlock_read(map);
- return error;
-}
-
-int
-procfs_validmap(p)
- struct proc *p;
-{
- return ((p->p_flag & P_SYSTEM) == 0);
-}
diff --git a/sys/fs/procfs/procfs_mem.c b/sys/fs/procfs/procfs_mem.c
deleted file mode 100644
index b7eed8503ea1..000000000000
--- a/sys/fs/procfs/procfs_mem.c
+++ /dev/null
@@ -1,316 +0,0 @@
-/*
- * Copyright (c) 1993 Jan-Simon Pendry
- * Copyright (c) 1993 Sean Eric Fagan
- * Copyright (c) 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Jan-Simon Pendry and Sean Eric Fagan.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)procfs_mem.c 8.5 (Berkeley) 6/15/94
- *
- * $FreeBSD$
- */
-
-/*
- * This is a lightly hacked and merged version
- * of sef's pread/pwrite functions
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/proc.h>
-#include <sys/vnode.h>
-#include <miscfs/procfs/procfs.h>
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <sys/lock.h>
-#include <vm/pmap.h>
-#include <vm/vm_extern.h>
-#include <vm/vm_map.h>
-#include <vm/vm_kern.h>
-#include <vm/vm_object.h>
-#include <vm/vm_page.h>
-#include <sys/user.h>
-#include <sys/ptrace.h>
-
-static int procfs_rwmem __P((struct proc *curp,
- struct proc *p, struct uio *uio));
-
-static int
-procfs_rwmem(curp, p, uio)
- struct proc *curp;
- struct proc *p;
- struct uio *uio;
-{
- int error;
- int writing;
- struct vmspace *vm;
- vm_map_t map;
- vm_object_t object = NULL;
- vm_offset_t pageno = 0; /* page number */
- vm_prot_t reqprot;
- vm_offset_t kva;
-
- /*
- * if the vmspace is in the midst of being deallocated or the
- * process is exiting, don't try to grab anything. The page table
- * usage in that process can be messed up.
- */
- vm = p->p_vmspace;
- if ((p->p_flag & P_WEXIT) || (vm->vm_refcnt < 1))
- return EFAULT;
- ++vm->vm_refcnt;
- /*
- * The map we want...
- */
- map = &vm->vm_map;
-
- writing = uio->uio_rw == UIO_WRITE;
- reqprot = writing ? (VM_PROT_WRITE | VM_PROT_OVERRIDE_WRITE) : VM_PROT_READ;
-
- kva = kmem_alloc_pageable(kernel_map, PAGE_SIZE);
-
- /*
- * Only map in one page at a time. We don't have to, but it
- * makes things easier. This way is trivial - right?
- */
- do {
- vm_map_t tmap;
- vm_offset_t uva;
- int page_offset; /* offset into page */
- vm_map_entry_t out_entry;
- vm_prot_t out_prot;
- boolean_t wired;
- vm_pindex_t pindex;
- u_int len;
- vm_page_t m;
-
- object = NULL;
-
- uva = (vm_offset_t) uio->uio_offset;
-
- /*
- * Get the page number of this segment.
- */
- pageno = trunc_page(uva);
- page_offset = uva - pageno;
-
- /*
- * How many bytes to copy
- */
- len = min(PAGE_SIZE - page_offset, uio->uio_resid);
-
- /*
- * Fault the page on behalf of the process
- */
- error = vm_fault(map, pageno, reqprot, VM_FAULT_NORMAL);
- if (error) {
- error = EFAULT;
- break;
- }
-
- /*
- * Now we need to get the page. out_entry, out_prot, wired,
- * and single_use aren't used. One would think the vm code
- * would be a *bit* nicer... We use tmap because
- * vm_map_lookup() can change the map argument.
- */
- tmap = map;
- error = vm_map_lookup(&tmap, pageno, reqprot,
- &out_entry, &object, &pindex, &out_prot,
- &wired);
-
- if (error) {
- error = EFAULT;
-
- /*
- * Make sure that there is no residue in 'object' from
- * an error return on vm_map_lookup.
- */
- object = NULL;
-
- break;
- }
-
- m = vm_page_lookup(object, pindex);
-
- /* Allow fallback to backing objects if we are reading */
-
- while (m == NULL && !writing && object->backing_object) {
-
- pindex += OFF_TO_IDX(object->backing_object_offset);
- object = object->backing_object;
-
- m = vm_page_lookup(object, pindex);
- }
-
- if (m == NULL) {
- error = EFAULT;
-
- /*
- * Make sure that there is no residue in 'object' from
- * an error return on vm_map_lookup.
- */
- object = NULL;
-
- vm_map_lookup_done(tmap, out_entry);
-
- break;
- }
-
- /*
- * Wire the page into memory
- */
- vm_page_wire(m);
-
- /*
- * We're done with tmap now.
- * But reference the object first, so that we won't loose
- * it.
- */
- vm_object_reference(object);
- vm_map_lookup_done(tmap, out_entry);
-
- pmap_kenter(kva, VM_PAGE_TO_PHYS(m));
-
- /*
- * Now do the i/o move.
- */
- error = uiomove((caddr_t)(kva + page_offset), len, uio);
-
- pmap_kremove(kva);
-
- /*
- * release the page and the object
- */
- vm_page_unwire(m, 1);
- vm_object_deallocate(object);
-
- object = NULL;
-
- } while (error == 0 && uio->uio_resid > 0);
-
- if (object)
- vm_object_deallocate(object);
-
- kmem_free(kernel_map, kva, PAGE_SIZE);
- vmspace_free(vm);
- return (error);
-}
-
-/*
- * Copy data in and out of the target process.
- * We do this by mapping the process's page into
- * the kernel and then doing a uiomove direct
- * from the kernel address space.
- */
-int
-procfs_domem(curp, p, pfs, uio)
- struct proc *curp;
- struct proc *p;
- struct pfsnode *pfs;
- struct uio *uio;
-{
-
- if (uio->uio_resid == 0)
- return (0);
-
- /*
- * XXX
- * We need to check for KMEM_GROUP because ps is sgid kmem;
- * not allowing it here causes ps to not work properly. Arguably,
- * this is a bug with what ps does. We only need to do this
- * for Pmem nodes, and only if it's reading. This is still not
- * good, as it may still be possible to grab illicit data if
- * a process somehow gets to be KMEM_GROUP. Note that this also
- * means that KMEM_GROUP can't change without editing procfs.h!
- * All in all, quite yucky.
- */
-
- if (p_trespass(curp, p) &&
- !(uio->uio_rw == UIO_READ &&
- procfs_kmemaccess(curp)))
- return EPERM;
-
- return (procfs_rwmem(curp, p, uio));
-}
-
-/*
- * Given process (p), find the vnode from which
- * its text segment is being executed.
- *
- * It would be nice to grab this information from
- * the VM system, however, there is no sure-fire
- * way of doing that. Instead, fork(), exec() and
- * wait() all maintain the p_textvp field in the
- * process proc structure which contains a held
- * reference to the exec'ed vnode.
- *
- * XXX - Currently, this is not not used, as the
- * /proc/pid/file object exposes an information leak
- * that shouldn't happen. Using a mount option would
- * make it configurable on a per-system (or, at least,
- * per-mount) basis; however, that's not really best.
- * The best way to do it, I think, would be as an
- * ioctl; this would restrict it to the uid running
- * program, or root, which seems a reasonable compromise.
- * However, the number of applications for this is
- * minimal, if it can't be seen in the filesytem space,
- * and doint it as an ioctl makes it somewhat less
- * useful due to the, well, inelegance.
- *
- */
-struct vnode *
-procfs_findtextvp(p)
- struct proc *p;
-{
-
- return (p->p_textvp);
-}
-
-int procfs_kmemaccess(curp)
- struct proc *curp;
-{
- int i;
- struct ucred *cred;
-
- cred = curp->p_ucred;
- if (suser(curp))
- return 1;
-
- /* XXX: Why isn't this done with file-perms ??? */
- for (i = 0; i < cred->cr_ngroups; i++)
- if (cred->cr_groups[i] == KMEM_GROUP)
- return 1;
-
- return 0;
-}
diff --git a/sys/fs/procfs/procfs_note.c b/sys/fs/procfs/procfs_note.c
deleted file mode 100644
index 273010b32956..000000000000
--- a/sys/fs/procfs/procfs_note.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 1993 Jan-Simon Pendry
- * Copyright (c) 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)procfs_note.c 8.2 (Berkeley) 1/21/94
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/vnode.h>
-#include <miscfs/procfs/procfs.h>
-
-int
-procfs_donote(curp, p, pfs, uio)
- struct proc *curp;
- struct proc *p;
- struct pfsnode *pfs;
- struct uio *uio;
-{
- int xlen;
- int error;
- char note[PROCFS_NOTELEN+1];
-
- if (uio->uio_rw != UIO_WRITE)
- return (EINVAL);
-
- xlen = PROCFS_NOTELEN;
- error = vfs_getuserstr(uio, note, &xlen);
- if (error)
- return (error);
-
- /* send to process's notify function */
- return (EOPNOTSUPP);
-}
diff --git a/sys/fs/procfs/procfs_regs.c b/sys/fs/procfs/procfs_regs.c
deleted file mode 100644
index 88f85d3d1857..000000000000
--- a/sys/fs/procfs/procfs_regs.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (c) 1993 Jan-Simon Pendry
- * Copyright (c) 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)procfs_regs.c 8.4 (Berkeley) 6/15/94
- *
- * From:
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/proc.h>
-#include <sys/vnode.h>
-#include <machine/reg.h>
-#include <miscfs/procfs/procfs.h>
-#include <vm/vm.h>
-#include <vm/vm_extern.h>
-
-int
-procfs_doregs(curp, p, pfs, uio)
- struct proc *curp;
- struct proc *p;
- struct pfsnode *pfs;
- struct uio *uio;
-{
- int error;
- struct reg r;
- char *kv;
- int kl;
-
- if (p_trespass(curp, p))
- return EPERM;
- kl = sizeof(r);
- kv = (char *) &r;
-
- kv += uio->uio_offset;
- kl -= uio->uio_offset;
- if (kl > uio->uio_resid)
- kl = uio->uio_resid;
-
- PHOLD(p);
-
- if (kl < 0)
- error = EINVAL;
- else
- error = procfs_read_regs(p, &r);
- if (error == 0)
- error = uiomove(kv, kl, uio);
- if (error == 0 && uio->uio_rw == UIO_WRITE) {
- if (p->p_stat != SSTOP)
- error = EBUSY;
- else
- error = procfs_write_regs(p, &r);
- }
- PRELE(p);
-
- uio->uio_offset = 0;
- return (error);
-}
-
-int
-procfs_validregs(p)
- struct proc *p;
-{
- return ((p->p_flag & P_SYSTEM) == 0);
-}
diff --git a/sys/fs/procfs/procfs_rlimit.c b/sys/fs/procfs/procfs_rlimit.c
deleted file mode 100644
index 361f6f6e9d7d..000000000000
--- a/sys/fs/procfs/procfs_rlimit.c
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (c) 1999 Adrian Chadd
- * Copyright (c) 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)procfs_status.c 8.4 (Berkeley) 6/15/94
- *
- * $FreeBSD$
- */
-
-/*
- * To get resource.h to include our rlimit_ident[] array of rlimit identifiers
- */
-
-#define _RLIMIT_IDENT
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/proc.h>
-#include <sys/vnode.h>
-#include <sys/resourcevar.h>
-#include <sys/resource.h>
-#include <sys/types.h>
-#include <miscfs/procfs/procfs.h>
-
-
-int
-procfs_dorlimit(curp, p, pfs, uio)
- struct proc *curp;
- struct proc *p;
- struct pfsnode *pfs;
- struct uio *uio;
-{
- char *ps;
- int i;
- int xlen;
- int error;
- char psbuf[512]; /* XXX - conservative */
-
- if (uio->uio_rw != UIO_READ)
- return (EOPNOTSUPP);
-
-
- ps = psbuf;
-
- for (i = 0; i < RLIM_NLIMITS; i++) {
-
- /*
- * Add the rlimit ident
- */
-
- ps += sprintf(ps, "%s ", rlimit_ident[i]);
-
- /*
- * Replace RLIM_INFINITY with -1 in the string
- */
-
- /*
- * current limit
- */
-
- if (p->p_rlimit[i].rlim_cur == RLIM_INFINITY) {
- ps += sprintf(ps, "-1 ");
- } else {
- ps += sprintf(ps, "%llu ",
- (unsigned long long)p->p_rlimit[i].rlim_cur);
- }
-
- /*
- * maximum limit
- */
-
- if (p->p_rlimit[i].rlim_max == RLIM_INFINITY) {
- ps += sprintf(ps, "-1\n");
- } else {
- ps += sprintf(ps, "%llu\n",
- (unsigned long long)p->p_rlimit[i].rlim_max);
- }
- }
-
- /*
- * This logic is rather tasty - but its from procfs_status.c, so
- * I guess I'll use it here.
- */
-
- xlen = ps - psbuf;
- xlen -= uio->uio_offset;
- ps = psbuf + uio->uio_offset;
- xlen = imin(xlen, uio->uio_resid);
- if (xlen <= 0)
- error = 0;
- else
- error = uiomove(ps, xlen, uio);
-
- return (error);
-}
-
diff --git a/sys/fs/procfs/procfs_status.c b/sys/fs/procfs/procfs_status.c
deleted file mode 100644
index 03149e9776ce..000000000000
--- a/sys/fs/procfs/procfs_status.c
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * Copyright (c) 1993 Jan-Simon Pendry
- * Copyright (c) 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)procfs_status.c 8.4 (Berkeley) 6/15/94
- *
- * From:
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/malloc.h>
-#include <sys/proc.h>
-#include <sys/jail.h>
-#include <sys/vnode.h>
-#include <sys/tty.h>
-#include <sys/resourcevar.h>
-#include <miscfs/procfs/procfs.h>
-
-#include <vm/vm.h>
-#include <vm/pmap.h>
-#include <vm/vm_param.h>
-#include <sys/exec.h>
-
-int
-procfs_dostatus(curp, p, pfs, uio)
- struct proc *curp;
- struct proc *p;
- struct pfsnode *pfs;
- struct uio *uio;
-{
- struct session *sess;
- struct tty *tp;
- struct ucred *cr;
- char *ps;
- char *sep;
- int pid, ppid, pgid, sid;
- int i;
- int xlen;
- int error;
- char psbuf[256]; /* XXX - conservative */
-
- if (uio->uio_rw != UIO_READ)
- return (EOPNOTSUPP);
-
- pid = p->p_pid;
- ppid = p->p_pptr ? p->p_pptr->p_pid : 0;
- pgid = p->p_pgrp->pg_id;
- sess = p->p_pgrp->pg_session;
- sid = sess->s_leader ? sess->s_leader->p_pid : 0;
-
-/* comm pid ppid pgid sid maj,min ctty,sldr start ut st wmsg
- euid ruid rgid,egid,groups[1 .. NGROUPS]
-*/
- ps = psbuf;
- bcopy(p->p_comm, ps, MAXCOMLEN);
- ps[MAXCOMLEN] = '\0';
- ps += strlen(ps);
- ps += sprintf(ps, " %d %d %d %d ", pid, ppid, pgid, sid);
-
- if ((p->p_flag&P_CONTROLT) && (tp = sess->s_ttyp))
- ps += sprintf(ps, "%d,%d ", major(tp->t_dev), minor(tp->t_dev));
- else
- ps += sprintf(ps, "%d,%d ", -1, -1);
-
- sep = "";
- if (sess->s_ttyvp) {
- ps += sprintf(ps, "%sctty", sep);
- sep = ",";
- }
- if (SESS_LEADER(p)) {
- ps += sprintf(ps, "%ssldr", sep);
- sep = ",";
- }
- if (*sep != ',')
- ps += sprintf(ps, "noflags");
-
- if (p->p_flag & P_INMEM) {
- struct timeval ut, st;
-
- calcru(p, &ut, &st, (struct timeval *) NULL);
- ps += sprintf(ps, " %ld,%ld %ld,%ld %ld,%ld",
- p->p_stats->p_start.tv_sec,
- p->p_stats->p_start.tv_usec,
- ut.tv_sec, ut.tv_usec,
- st.tv_sec, st.tv_usec);
- } else
- ps += sprintf(ps, " -1,-1 -1,-1 -1,-1");
-
- ps += sprintf(ps, " %s",
- (p->p_wchan && p->p_wmesg) ? p->p_wmesg : "nochan");
-
- cr = p->p_ucred;
-
- ps += sprintf(ps, " %lu %lu %lu",
- (u_long)cr->cr_uid,
- (u_long)p->p_cred->p_ruid,
- (u_long)p->p_cred->p_rgid);
-
- /* egid (p->p_cred->p_svgid) is equal to cr_ngroups[0]
- see also getegid(2) in /sys/kern/kern_prot.c */
-
- for (i = 0; i < cr->cr_ngroups; i++)
- ps += sprintf(ps, ",%lu", (u_long)cr->cr_groups[i]);
-
- if (p->p_prison)
- ps += sprintf(ps, " %s", p->p_prison->pr_host);
- else
- ps += sprintf(ps, " -");
- ps += sprintf(ps, "\n");
-
- xlen = ps - psbuf;
- xlen -= uio->uio_offset;
- ps = psbuf + uio->uio_offset;
- xlen = imin(xlen, uio->uio_resid);
- if (xlen <= 0)
- error = 0;
- else
- error = uiomove(ps, xlen, uio);
-
- return (error);
-}
-
-int
-procfs_docmdline(curp, p, pfs, uio)
- struct proc *curp;
- struct proc *p;
- struct pfsnode *pfs;
- struct uio *uio;
-{
- char *ps;
- int xlen;
- int error;
- char *buf, *bp;
- int buflen;
- struct ps_strings pstr;
- int i;
- size_t bytes_left, done;
-
- if (uio->uio_rw != UIO_READ)
- return (EOPNOTSUPP);
-
- /*
- * If we are using the ps/cmdline caching, use that. Otherwise
- * revert back to the old way which only implements full cmdline
- * for the currept process and just p->p_comm for all other
- * processes.
- * Note that if the argv is no longer available, we deliberately
- * don't fall back on p->p_comm or return an error: the authentic
- * Linux behaviour is to return zero-length in this case.
- */
-
- if (p->p_args && (ps_argsopen ||!p_trespass(curp, p))) {
- bp = p->p_args->ar_args;
- buflen = p->p_args->ar_length;
- buf = 0;
- } else if (p != curp) {
- bp = p->p_comm;
- buflen = MAXCOMLEN;
- buf = 0;
- } else {
- buflen = 256;
- MALLOC(buf, char *, buflen + 1, M_TEMP, M_WAITOK);
- bp = buf;
- ps = buf;
- error = copyin((void*)PS_STRINGS, &pstr, sizeof(pstr));
- if (error) {
- FREE(buf, M_TEMP);
- return (error);
- }
- bytes_left = buflen;
- for (i = 0; bytes_left && (i < pstr.ps_nargvstr); i++) {
- error = copyinstr(pstr.ps_argvstr[i], ps,
- bytes_left, &done);
- /* If too long or malformed, just truncate */
- if (error) {
- error = 0;
- break;
- }
- ps += done;
- bytes_left -= done;
- }
- buflen = ps - buf;
- }
-
- buflen -= uio->uio_offset;
- ps = bp + uio->uio_offset;
- xlen = min(buflen, uio->uio_resid);
- if (xlen <= 0)
- error = 0;
- else
- error = uiomove(ps, xlen, uio);
- if (buf)
- FREE(buf, M_TEMP);
- return (error);
-}
diff --git a/sys/fs/procfs/procfs_subr.c b/sys/fs/procfs/procfs_subr.c
deleted file mode 100644
index 01e8ae9e014a..000000000000
--- a/sys/fs/procfs/procfs_subr.c
+++ /dev/null
@@ -1,402 +0,0 @@
-/*
- * Copyright (c) 1993 Jan-Simon Pendry
- * Copyright (c) 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)procfs_subr.c 8.6 (Berkeley) 5/14/95
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/proc.h>
-#include <sys/vnode.h>
-#include <sys/malloc.h>
-#include <miscfs/procfs/procfs.h>
-
-static struct pfsnode *pfshead;
-static int pfsvplock;
-
-/*
- * allocate a pfsnode/vnode pair. the vnode is
- * referenced, but not locked.
- *
- * the pid, pfs_type, and mount point uniquely
- * identify a pfsnode. the mount point is needed
- * because someone might mount this filesystem
- * twice.
- *
- * all pfsnodes are maintained on a singly-linked
- * list. new nodes are only allocated when they cannot
- * be found on this list. entries on the list are
- * removed when the vfs reclaim entry is called.
- *
- * a single lock is kept for the entire list. this is
- * needed because the getnewvnode() function can block
- * waiting for a vnode to become free, in which case there
- * may be more than one process trying to get the same
- * vnode. this lock is only taken if we are going to
- * call getnewvnode, since the kernel itself is single-threaded.
- *
- * if an entry is found on the list, then call vget() to
- * take a reference. this is done because there may be
- * zero references to it and so it needs to removed from
- * the vnode free list.
- */
-int
-procfs_allocvp(mp, vpp, pid, pfs_type)
- struct mount *mp;
- struct vnode **vpp;
- long pid;
- pfstype pfs_type;
-{
- struct proc *p = curproc; /* XXX */
- struct pfsnode *pfs;
- struct vnode *vp;
- struct pfsnode **pp;
- int error;
-
-loop:
- for (pfs = pfshead; pfs != 0; pfs = pfs->pfs_next) {
- vp = PFSTOV(pfs);
- if (pfs->pfs_pid == pid &&
- pfs->pfs_type == pfs_type &&
- vp->v_mount == mp) {
- if (vget(vp, 0, p))
- goto loop;
- *vpp = vp;
- return (0);
- }
- }
-
- /*
- * otherwise lock the vp list while we call getnewvnode
- * since that can block.
- */
- if (pfsvplock & PROCFS_LOCKED) {
- pfsvplock |= PROCFS_WANT;
- (void) tsleep((caddr_t) &pfsvplock, PINOD, "pfsavp", 0);
- goto loop;
- }
- pfsvplock |= PROCFS_LOCKED;
-
- /*
- * Do the MALLOC before the getnewvnode since doing so afterward
- * might cause a bogus v_data pointer to get dereferenced
- * elsewhere if MALLOC should block.
- */
- MALLOC(pfs, struct pfsnode *, sizeof(struct pfsnode), M_TEMP, M_WAITOK);
-
- if ((error = getnewvnode(VT_PROCFS, mp, procfs_vnodeop_p, vpp)) != 0) {
- FREE(pfs, M_TEMP);
- goto out;
- }
- vp = *vpp;
-
- vp->v_data = pfs;
-
- pfs->pfs_next = 0;
- pfs->pfs_pid = (pid_t) pid;
- pfs->pfs_type = pfs_type;
- pfs->pfs_vnode = vp;
- pfs->pfs_flags = 0;
- pfs->pfs_lockowner = 0;
- pfs->pfs_fileno = PROCFS_FILENO(pid, pfs_type);
-
- switch (pfs_type) {
- case Proot: /* /proc = dr-xr-xr-x */
- pfs->pfs_mode = (VREAD|VEXEC) |
- (VREAD|VEXEC) >> 3 |
- (VREAD|VEXEC) >> 6;
- vp->v_type = VDIR;
- vp->v_flag = VROOT;
- break;
-
- case Pcurproc: /* /proc/curproc = lr--r--r-- */
- pfs->pfs_mode = (VREAD) |
- (VREAD >> 3) |
- (VREAD >> 6);
- vp->v_type = VLNK;
- break;
-
- case Pproc:
- pfs->pfs_mode = (VREAD|VEXEC) |
- (VREAD|VEXEC) >> 3 |
- (VREAD|VEXEC) >> 6;
- vp->v_type = VDIR;
- break;
-
- case Pfile:
- case Pmem:
- pfs->pfs_mode = (VREAD|VWRITE) |
- (VREAD) >> 3;;
- vp->v_type = VREG;
- break;
-
- case Pregs:
- case Pfpregs:
- case Pdbregs:
- pfs->pfs_mode = (VREAD|VWRITE);
- vp->v_type = VREG;
- break;
-
- case Pctl:
- case Pnote:
- case Pnotepg:
- pfs->pfs_mode = (VWRITE);
- vp->v_type = VREG;
- break;
-
- case Ptype:
- case Pmap:
- case Pstatus:
- case Pcmdline:
- case Prlimit:
- pfs->pfs_mode = (VREAD) |
- (VREAD >> 3) |
- (VREAD >> 6);
- vp->v_type = VREG;
- break;
-
- default:
- panic("procfs_allocvp");
- }
-
- /* add to procfs vnode list */
- for (pp = &pfshead; *pp; pp = &(*pp)->pfs_next)
- continue;
- *pp = pfs;
-
-out:
- pfsvplock &= ~PROCFS_LOCKED;
-
- if (pfsvplock & PROCFS_WANT) {
- pfsvplock &= ~PROCFS_WANT;
- wakeup((caddr_t) &pfsvplock);
- }
-
- return (error);
-}
-
-int
-procfs_freevp(vp)
- struct vnode *vp;
-{
- struct pfsnode **pfspp;
- struct pfsnode *pfs = VTOPFS(vp);
-
- for (pfspp = &pfshead; *pfspp != 0; pfspp = &(*pfspp)->pfs_next) {
- if (*pfspp == pfs) {
- *pfspp = pfs->pfs_next;
- break;
- }
- }
-
- FREE(vp->v_data, M_TEMP);
- vp->v_data = 0;
- return (0);
-}
-
-int
-procfs_rw(ap)
- struct vop_read_args *ap;
-{
- struct vnode *vp = ap->a_vp;
- struct uio *uio = ap->a_uio;
- struct proc *curp = uio->uio_procp;
- struct pfsnode *pfs = VTOPFS(vp);
- struct proc *p;
- int rtval;
-
- p = PFIND(pfs->pfs_pid);
- if (p == 0)
- return (EINVAL);
- if (p->p_pid == 1 && securelevel > 0 && uio->uio_rw == UIO_WRITE)
- return (EACCES);
-
- while (pfs->pfs_lockowner) {
- tsleep(&pfs->pfs_lockowner, PRIBIO, "pfslck", 0);
- }
- pfs->pfs_lockowner = curproc->p_pid;
-
- switch (pfs->pfs_type) {
- case Pnote:
- case Pnotepg:
- rtval = procfs_donote(curp, p, pfs, uio);
- break;
-
- case Pregs:
- rtval = procfs_doregs(curp, p, pfs, uio);
- break;
-
- case Pfpregs:
- rtval = procfs_dofpregs(curp, p, pfs, uio);
- break;
-
- case Pdbregs:
- rtval = procfs_dodbregs(curp, p, pfs, uio);
- break;
-
- case Pctl:
- rtval = procfs_doctl(curp, p, pfs, uio);
- break;
-
- case Pstatus:
- rtval = procfs_dostatus(curp, p, pfs, uio);
- break;
-
- case Pmap:
- rtval = procfs_domap(curp, p, pfs, uio);
- break;
-
- case Pmem:
- rtval = procfs_domem(curp, p, pfs, uio);
- break;
-
- case Ptype:
- rtval = procfs_dotype(curp, p, pfs, uio);
- break;
-
- case Pcmdline:
- rtval = procfs_docmdline(curp, p, pfs, uio);
- break;
-
- case Prlimit:
- rtval = procfs_dorlimit(curp, p, pfs, uio);
- break;
-
- default:
- rtval = EOPNOTSUPP;
- break;
- }
- pfs->pfs_lockowner = 0;
- wakeup(&pfs->pfs_lockowner);
- return rtval;
-}
-
-/*
- * Get a string from userland into (buf). Strip a trailing
- * nl character (to allow easy access from the shell).
- * The buffer should be *buflenp + 1 chars long. vfs_getuserstr
- * will automatically add a nul char at the end.
- *
- * Returns 0 on success or the following errors
- *
- * EINVAL: file offset is non-zero.
- * EMSGSIZE: message is longer than kernel buffer
- * EFAULT: user i/o buffer is not addressable
- */
-int
-vfs_getuserstr(uio, buf, buflenp)
- struct uio *uio;
- char *buf;
- int *buflenp;
-{
- int xlen;
- int error;
-
- if (uio->uio_offset != 0)
- return (EINVAL);
-
- xlen = *buflenp;
-
- /* must be able to read the whole string in one go */
- if (xlen < uio->uio_resid)
- return (EMSGSIZE);
- xlen = uio->uio_resid;
-
- if ((error = uiomove(buf, xlen, uio)) != 0)
- return (error);
-
- /* allow multiple writes without seeks */
- uio->uio_offset = 0;
-
- /* cleanup string and remove trailing newline */
- buf[xlen] = '\0';
- xlen = strlen(buf);
- if (xlen > 0 && buf[xlen-1] == '\n')
- buf[--xlen] = '\0';
- *buflenp = xlen;
-
- return (0);
-}
-
-vfs_namemap_t *
-vfs_findname(nm, buf, buflen)
- vfs_namemap_t *nm;
- char *buf;
- int buflen;
-{
-
- for (; nm->nm_name; nm++)
- if (bcmp(buf, nm->nm_name, buflen+1) == 0)
- return (nm);
-
- return (0);
-}
-
-void
-procfs_exit(struct proc *p)
-{
- struct pfsnode *pfs;
- pid_t pid = p->p_pid;
-
- /*
- * The reason for this loop is not obvious -- basicly,
- * procfs_freevp(), which is called via vgone() (eventually),
- * removes the specified procfs node from the pfshead list.
- * It does this by *pfsp = pfs->pfs_next, meaning that it
- * overwrites the node. So when we do pfs = pfs->next, we
- * end up skipping the node that replaces the one that was
- * vgone'd. Since it may have been the last one on the list,
- * it may also have been set to null -- but *our* pfs pointer,
- * here, doesn't see this. So the loop starts from the beginning
- * again.
- *
- * This is not a for() loop because the final event
- * would be "pfs = pfs->pfs_next"; in the case where
- * pfs is set to pfshead again, that would mean that
- * pfshead is skipped over.
- *
- */
- pfs = pfshead;
- while (pfs) {
- if (pfs->pfs_pid == pid) {
- vgone(PFSTOV(pfs));
- pfs = pfshead;
- } else
- pfs = pfs->pfs_next;
- }
-}
diff --git a/sys/fs/procfs/procfs_type.c b/sys/fs/procfs/procfs_type.c
deleted file mode 100644
index cb2a45f6a3d6..000000000000
--- a/sys/fs/procfs/procfs_type.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 1993 Jan-Simon Pendry
- * Copyright (c) 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/proc.h>
-#include <sys/sysent.h>
-#include <sys/vnode.h>
-#include <miscfs/procfs/procfs.h>
-
-int
-procfs_dotype(curp, p, pfs, uio)
- struct proc *curp;
- struct proc *p;
- struct pfsnode *pfs;
- struct uio *uio;
-{
- int len;
- int error;
- /*
- * buffer for emulation type
- */
- char mebuffer[256];
- char *none = "Not Available";
-
- if (uio->uio_rw != UIO_READ)
- return (EOPNOTSUPP);
-
- if (uio->uio_offset != 0)
- return (0);
-
- if (p && p->p_sysent && p->p_sysent->sv_name) {
- len = strlen(p->p_sysent->sv_name);
- bcopy(p->p_sysent->sv_name, mebuffer, len);
- } else {
- len = strlen(none);
- bcopy(none, mebuffer, len);
- }
- mebuffer[len++] = '\n';
- error = uiomove(mebuffer, len, uio);
- return error;
-}
-
-int
-procfs_validtype(p)
- struct proc *p;
-{
- return ((p->p_flag & P_SYSTEM) == 0);
-}
diff --git a/sys/fs/procfs/procfs_vfsops.c b/sys/fs/procfs/procfs_vfsops.c
deleted file mode 100644
index b1d4d4332540..000000000000
--- a/sys/fs/procfs/procfs_vfsops.c
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Copyright (c) 1993 Jan-Simon Pendry
- * Copyright (c) 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)procfs_vfsops.c 8.7 (Berkeley) 5/10/95
- *
- * $FreeBSD$
- */
-
-/*
- * procfs VFS interface
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/proc.h>
-#include <sys/mount.h>
-#include <sys/vnode.h>
-#include <miscfs/procfs/procfs.h>
-
-static int procfs_mount __P((struct mount *mp, char *path, caddr_t data,
- struct nameidata *ndp, struct proc *p));
-static int procfs_statfs __P((struct mount *mp, struct statfs *sbp,
- struct proc *p));
-static int procfs_unmount __P((struct mount *mp, int mntflags,
- struct proc *p));
-
-/*
- * VFS Operations.
- *
- * mount system call
- */
-/* ARGSUSED */
-static int
-procfs_mount(mp, path, data, ndp, p)
- struct mount *mp;
- char *path;
- caddr_t data;
- struct nameidata *ndp;
- struct proc *p;
-{
- size_t size;
- int error;
-
- if (mp->mnt_flag & MNT_UPDATE)
- return (EOPNOTSUPP);
-
- if (mp->mnt_vfc->vfc_refcount == 1 && (error = at_exit(procfs_exit))) {
- printf("procfs: cannot register procfs_exit with at_exit\n");
- return(error);
- }
-
- mp->mnt_flag |= MNT_LOCAL;
- mp->mnt_data = 0;
- vfs_getnewfsid(mp);
-
- (void) copyinstr(path, (caddr_t)mp->mnt_stat.f_mntonname, MNAMELEN, &size);
- bzero(mp->mnt_stat.f_mntonname + size, MNAMELEN - size);
-
- size = sizeof("procfs") - 1;
- bcopy("procfs", mp->mnt_stat.f_mntfromname, size);
- bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
- (void)procfs_statfs(mp, &mp->mnt_stat, p);
-
- return (0);
-}
-
-/*
- * unmount system call
- */
-static int
-procfs_unmount(mp, mntflags, p)
- struct mount *mp;
- int mntflags;
- struct proc *p;
-{
- int error;
- int flags = 0;
-
- if (mntflags & MNT_FORCE)
- flags |= FORCECLOSE;
-
- error = vflush(mp, 0, flags);
- if (error)
- return (error);
-
- if (mp->mnt_vfc->vfc_refcount == 1)
- rm_at_exit(procfs_exit);
-
- return (0);
-}
-
-int
-procfs_root(mp, vpp)
- struct mount *mp;
- struct vnode **vpp;
-{
-
- return (procfs_allocvp(mp, vpp, 0, Proot));
-}
-
-/*
- * Get file system statistics.
- */
-static int
-procfs_statfs(mp, sbp, p)
- struct mount *mp;
- struct statfs *sbp;
- struct proc *p;
-{
- sbp->f_bsize = PAGE_SIZE;
- sbp->f_iosize = PAGE_SIZE;
- sbp->f_blocks = 1; /* avoid divide by zero in some df's */
- sbp->f_bfree = 0;
- sbp->f_bavail = 0;
- sbp->f_files = maxproc; /* approx */
- sbp->f_ffree = maxproc - nprocs; /* approx */
-
- if (sbp != &mp->mnt_stat) {
- sbp->f_type = mp->mnt_vfc->vfc_typenum;
- bcopy(&mp->mnt_stat.f_fsid, &sbp->f_fsid, sizeof(sbp->f_fsid));
- bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN);
- bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN);
- }
-
- return (0);
-}
-
-static struct vfsops procfs_vfsops = {
- procfs_mount,
- vfs_stdstart,
- procfs_unmount,
- procfs_root,
- vfs_stdquotactl,
- procfs_statfs,
- vfs_stdsync,
- vfs_stdvget,
- vfs_stdfhtovp,
- vfs_stdcheckexp,
- vfs_stdvptofh,
- vfs_stdinit,
- vfs_stduninit,
- vfs_stdextattrctl,
-};
-
-VFS_SET(procfs_vfsops, procfs, VFCF_SYNTHETIC);
diff --git a/sys/fs/procfs/procfs_vnops.c b/sys/fs/procfs/procfs_vnops.c
deleted file mode 100644
index d7de7ce230f8..000000000000
--- a/sys/fs/procfs/procfs_vnops.c
+++ /dev/null
@@ -1,1010 +0,0 @@
-/*
- * Copyright (c) 1993, 1995 Jan-Simon Pendry
- * Copyright (c) 1993, 1995
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)procfs_vnops.c 8.18 (Berkeley) 5/21/95
- *
- * $FreeBSD$
- */
-
-/*
- * procfs vnode interface
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/time.h>
-#include <sys/kernel.h>
-#include <sys/lock.h>
-#include <sys/fcntl.h>
-#include <sys/proc.h>
-#include <sys/signalvar.h>
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <sys/namei.h>
-#include <sys/dirent.h>
-#include <machine/reg.h>
-#include <vm/vm_zone.h>
-#include <miscfs/procfs/procfs.h>
-#include <sys/pioctl.h>
-
-static int procfs_access __P((struct vop_access_args *));
-static int procfs_badop __P((void));
-static int procfs_bmap __P((struct vop_bmap_args *));
-static int procfs_close __P((struct vop_close_args *));
-static int procfs_getattr __P((struct vop_getattr_args *));
-static int procfs_inactive __P((struct vop_inactive_args *));
-static int procfs_ioctl __P((struct vop_ioctl_args *));
-static int procfs_lookup __P((struct vop_lookup_args *));
-static int procfs_open __P((struct vop_open_args *));
-static int procfs_print __P((struct vop_print_args *));
-static int procfs_readdir __P((struct vop_readdir_args *));
-static int procfs_readlink __P((struct vop_readlink_args *));
-static int procfs_reclaim __P((struct vop_reclaim_args *));
-static int procfs_setattr __P((struct vop_setattr_args *));
-
-/*
- * This is a list of the valid names in the
- * process-specific sub-directories. It is
- * used in procfs_lookup and procfs_readdir
- */
-static struct proc_target {
- u_char pt_type;
- u_char pt_namlen;
- char *pt_name;
- pfstype pt_pfstype;
- int (*pt_valid) __P((struct proc *p));
-} proc_targets[] = {
-#define N(s) sizeof(s)-1, s
- /* name type validp */
- { DT_DIR, N("."), Pproc, NULL },
- { DT_DIR, N(".."), Proot, NULL },
- { DT_REG, N("mem"), Pmem, NULL },
- { DT_REG, N("regs"), Pregs, procfs_validregs },
- { DT_REG, N("fpregs"), Pfpregs, procfs_validfpregs },
- { DT_REG, N("dbregs"), Pdbregs, procfs_validdbregs },
- { DT_REG, N("ctl"), Pctl, NULL },
- { DT_REG, N("status"), Pstatus, NULL },
- { DT_REG, N("note"), Pnote, NULL },
- { DT_REG, N("notepg"), Pnotepg, NULL },
- { DT_REG, N("map"), Pmap, procfs_validmap },
- { DT_REG, N("etype"), Ptype, procfs_validtype },
- { DT_REG, N("cmdline"), Pcmdline, NULL },
- { DT_REG, N("rlimit"), Prlimit, NULL },
-#undef N
-};
-static const int nproc_targets = sizeof(proc_targets) / sizeof(proc_targets[0]);
-
-static pid_t atopid __P((const char *, u_int));
-
-/*
- * set things up for doing i/o on
- * the pfsnode (vp). (vp) is locked
- * on entry, and should be left locked
- * on exit.
- *
- * for procfs we don't need to do anything
- * in particular for i/o. all that is done
- * is to support exclusive open on process
- * memory images.
- */
-static int
-procfs_open(ap)
- struct vop_open_args /* {
- struct vnode *a_vp;
- int a_mode;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- struct pfsnode *pfs = VTOPFS(ap->a_vp);
- struct proc *p1, *p2;
-
- p2 = PFIND(pfs->pfs_pid);
- if (p2 == NULL)
- return (ENOENT);
- if (pfs->pfs_pid && !PRISON_CHECK(ap->a_p, p2))
- return (ENOENT);
-
- switch (pfs->pfs_type) {
- case Pmem:
- if (((pfs->pfs_flags & FWRITE) && (ap->a_mode & O_EXCL)) ||
- ((pfs->pfs_flags & O_EXCL) && (ap->a_mode & FWRITE)))
- return (EBUSY);
-
- p1 = ap->a_p;
- if (p_trespass(p1, p2) &&
- !procfs_kmemaccess(p1))
- return (EPERM);
-
- if (ap->a_mode & FWRITE)
- pfs->pfs_flags = ap->a_mode & (FWRITE|O_EXCL);
-
- return (0);
-
- default:
- break;
- }
-
- return (0);
-}
-
-/*
- * close the pfsnode (vp) after doing i/o.
- * (vp) is not locked on entry or exit.
- *
- * nothing to do for procfs other than undo
- * any exclusive open flag (see _open above).
- */
-static int
-procfs_close(ap)
- struct vop_close_args /* {
- struct vnode *a_vp;
- int a_fflag;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- struct pfsnode *pfs = VTOPFS(ap->a_vp);
- struct proc *p;
-
- switch (pfs->pfs_type) {
- case Pmem:
- if ((ap->a_fflag & FWRITE) && (pfs->pfs_flags & O_EXCL))
- pfs->pfs_flags &= ~(FWRITE|O_EXCL);
- /*
- * This rather complicated-looking code is trying to
- * determine if this was the last close on this particular
- * vnode. While one would expect v_usecount to be 1 at
- * that point, it seems that (according to John Dyson)
- * the VM system will bump up the usecount. So: if the
- * usecount is 2, and VOBJBUF is set, then this is really
- * the last close. Otherwise, if the usecount is < 2
- * then it is definitely the last close.
- * If this is the last close, then it checks to see if
- * the target process has PF_LINGER set in p_pfsflags,
- * if this is *not* the case, then the process' stop flags
- * are cleared, and the process is woken up. This is
- * to help prevent the case where a process has been
- * told to stop on an event, but then the requesting process
- * has gone away or forgotten about it.
- */
- if ((ap->a_vp->v_usecount < 2)
- && (p = pfind(pfs->pfs_pid))
- && !(p->p_pfsflags & PF_LINGER)) {
- p->p_stops = 0;
- p->p_step = 0;
- wakeup(&p->p_step);
- }
- break;
- default:
- break;
- }
-
- return (0);
-}
-
-/*
- * do an ioctl operation on a pfsnode (vp).
- * (vp) is not locked on entry or exit.
- */
-static int
-procfs_ioctl(ap)
- struct vop_ioctl_args *ap;
-{
- struct pfsnode *pfs = VTOPFS(ap->a_vp);
- struct proc *procp, *p;
- int error;
- int signo;
- struct procfs_status *psp;
- unsigned char flags;
-
- p = ap->a_p;
- procp = pfind(pfs->pfs_pid);
- if (procp == NULL) {
- return ENOTTY;
- }
-
- if (p_trespass(p, procp))
- return EPERM;
-
- switch (ap->a_command) {
- case PIOCBIS:
- procp->p_stops |= *(unsigned int*)ap->a_data;
- break;
- case PIOCBIC:
- procp->p_stops &= ~*(unsigned int*)ap->a_data;
- break;
- case PIOCSFL:
- /*
- * NFLAGS is "non-suser_xxx flags" -- currently, only
- * PFS_ISUGID ("ignore set u/g id");
- */
-#define NFLAGS (PF_ISUGID)
- flags = (unsigned char)*(unsigned int*)ap->a_data;
- if (flags & NFLAGS && (error = suser(p)))
- return error;
- procp->p_pfsflags = flags;
- break;
- case PIOCGFL:
- *(unsigned int*)ap->a_data = (unsigned int)procp->p_pfsflags;
- case PIOCSTATUS:
- psp = (struct procfs_status *)ap->a_data;
- psp->state = (procp->p_step == 0);
- psp->flags = procp->p_pfsflags;
- psp->events = procp->p_stops;
- if (procp->p_step) {
- psp->why = procp->p_stype;
- psp->val = procp->p_xstat;
- } else {
- psp->why = psp->val = 0; /* Not defined values */
- }
- break;
- case PIOCWAIT:
- psp = (struct procfs_status *)ap->a_data;
- if (procp->p_step == 0) {
- error = tsleep(&procp->p_stype, PWAIT | PCATCH, "piocwait", 0);
- if (error)
- return error;
- }
- psp->state = 1; /* It stopped */
- psp->flags = procp->p_pfsflags;
- psp->events = procp->p_stops;
- psp->why = procp->p_stype; /* why it stopped */
- psp->val = procp->p_xstat; /* any extra info */
- break;
- case PIOCCONT: /* Restart a proc */
- if (procp->p_step == 0)
- return EINVAL; /* Can only start a stopped process */
- if ((signo = *(int*)ap->a_data) != 0) {
- if (signo >= NSIG || signo <= 0)
- return EINVAL;
- psignal(procp, signo);
- }
- procp->p_step = 0;
- wakeup(&procp->p_step);
- break;
- default:
- return (ENOTTY);
- }
- return 0;
-}
-
-/*
- * do block mapping for pfsnode (vp).
- * since we don't use the buffer cache
- * for procfs this function should never
- * be called. in any case, it's not clear
- * what part of the kernel ever makes use
- * of this function. for sanity, this is the
- * usual no-op bmap, although returning
- * (EIO) would be a reasonable alternative.
- */
-static int
-procfs_bmap(ap)
- struct vop_bmap_args /* {
- struct vnode *a_vp;
- daddr_t a_bn;
- struct vnode **a_vpp;
- daddr_t *a_bnp;
- int *a_runp;
- } */ *ap;
-{
-
- if (ap->a_vpp != NULL)
- *ap->a_vpp = ap->a_vp;
- if (ap->a_bnp != NULL)
- *ap->a_bnp = ap->a_bn;
- if (ap->a_runp != NULL)
- *ap->a_runp = 0;
- return (0);
-}
-
-/*
- * procfs_inactive is called when the pfsnode
- * is vrele'd and the reference count goes
- * to zero. (vp) will be on the vnode free
- * list, so to get it back vget() must be
- * used.
- *
- * (vp) is locked on entry, but must be unlocked on exit.
- */
-static int
-procfs_inactive(ap)
- struct vop_inactive_args /* {
- struct vnode *a_vp;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
-
- VOP_UNLOCK(vp, 0, ap->a_p);
-
- return (0);
-}
-
-/*
- * _reclaim is called when getnewvnode()
- * wants to make use of an entry on the vnode
- * free list. at this time the filesystem needs
- * to free any private data and remove the node
- * from any private lists.
- */
-static int
-procfs_reclaim(ap)
- struct vop_reclaim_args /* {
- struct vnode *a_vp;
- } */ *ap;
-{
-
- return (procfs_freevp(ap->a_vp));
-}
-
-/*
- * _print is used for debugging.
- * just print a readable description
- * of (vp).
- */
-static int
-procfs_print(ap)
- struct vop_print_args /* {
- struct vnode *a_vp;
- } */ *ap;
-{
- struct pfsnode *pfs = VTOPFS(ap->a_vp);
-
- printf("tag VT_PROCFS, type %d, pid %ld, mode %x, flags %lx\n",
- pfs->pfs_type, (long)pfs->pfs_pid, pfs->pfs_mode, pfs->pfs_flags);
- return (0);
-}
-
-/*
- * generic entry point for unsupported operations
- */
-static int
-procfs_badop()
-{
-
- return (EIO);
-}
-
-/*
- * Invent attributes for pfsnode (vp) and store
- * them in (vap).
- * Directories lengths are returned as zero since
- * any real length would require the genuine size
- * to be computed, and nothing cares anyway.
- *
- * this is relatively minimal for procfs.
- */
-static int
-procfs_getattr(ap)
- struct vop_getattr_args /* {
- struct vnode *a_vp;
- struct vattr *a_vap;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- struct pfsnode *pfs = VTOPFS(ap->a_vp);
- struct vattr *vap = ap->a_vap;
- struct proc *procp;
- int error;
-
- /*
- * First make sure that the process and its credentials
- * still exist.
- */
- switch (pfs->pfs_type) {
- case Proot:
- case Pcurproc:
- procp = 0;
- break;
-
- default:
- procp = PFIND(pfs->pfs_pid);
- if (procp == 0 || procp->p_cred == NULL ||
- procp->p_ucred == NULL)
- return (ENOENT);
- }
-
- error = 0;
-
- /* start by zeroing out the attributes */
- VATTR_NULL(vap);
-
- /* next do all the common fields */
- vap->va_type = ap->a_vp->v_type;
- vap->va_mode = pfs->pfs_mode;
- vap->va_fileid = pfs->pfs_fileno;
- vap->va_flags = 0;
- vap->va_blocksize = PAGE_SIZE;
- vap->va_bytes = vap->va_size = 0;
- vap->va_fsid = ap->a_vp->v_mount->mnt_stat.f_fsid.val[0];
-
- /*
- * Make all times be current TOD.
- * It would be possible to get the process start
- * time from the p_stat structure, but there's
- * no "file creation" time stamp anyway, and the
- * p_stat structure is not addressible if u. gets
- * swapped out for that process.
- */
- nanotime(&vap->va_ctime);
- vap->va_atime = vap->va_mtime = vap->va_ctime;
-
- /*
- * If the process has exercised some setuid or setgid
- * privilege, then rip away read/write permission so
- * that only root can gain access.
- */
- switch (pfs->pfs_type) {
- case Pctl:
- case Pregs:
- case Pfpregs:
- case Pdbregs:
- if (procp->p_flag & P_SUGID)
- vap->va_mode &= ~((VREAD|VWRITE)|
- ((VREAD|VWRITE)>>3)|
- ((VREAD|VWRITE)>>6));
- break;
- case Pmem:
- /* Retain group kmem readablity. */
- if (procp->p_flag & P_SUGID)
- vap->va_mode &= ~(VREAD|VWRITE);
- break;
- default:
- break;
- }
-
- /*
- * now do the object specific fields
- *
- * The size could be set from struct reg, but it's hardly
- * worth the trouble, and it puts some (potentially) machine
- * dependent data into this machine-independent code. If it
- * becomes important then this function should break out into
- * a per-file stat function in the corresponding .c file.
- */
-
- vap->va_nlink = 1;
- if (procp) {
- vap->va_uid = procp->p_ucred->cr_uid;
- vap->va_gid = procp->p_ucred->cr_gid;
- }
-
- switch (pfs->pfs_type) {
- case Proot:
- /*
- * Set nlink to 1 to tell fts(3) we don't actually know.
- */
- vap->va_nlink = 1;
- vap->va_uid = 0;
- vap->va_gid = 0;
- vap->va_size = vap->va_bytes = DEV_BSIZE;
- break;
-
- case Pcurproc: {
- char buf[16]; /* should be enough */
- vap->va_uid = 0;
- vap->va_gid = 0;
- vap->va_size = vap->va_bytes =
- snprintf(buf, sizeof(buf), "%ld", (long)curproc->p_pid);
- break;
- }
-
- case Pproc:
- vap->va_nlink = nproc_targets;
- vap->va_size = vap->va_bytes = DEV_BSIZE;
- break;
-
- case Pfile:
- error = EOPNOTSUPP;
- break;
-
- case Pmem:
- /*
- * If we denied owner access earlier, then we have to
- * change the owner to root - otherwise 'ps' and friends
- * will break even though they are setgid kmem. *SIGH*
- */
- if (procp->p_flag & P_SUGID)
- vap->va_uid = 0;
- else
- vap->va_uid = procp->p_ucred->cr_uid;
- vap->va_gid = KMEM_GROUP;
- break;
-
- case Pregs:
- vap->va_bytes = vap->va_size = sizeof(struct reg);
- break;
-
- case Pfpregs:
- vap->va_bytes = vap->va_size = sizeof(struct fpreg);
- break;
-
- case Pdbregs:
- vap->va_bytes = vap->va_size = sizeof(struct dbreg);
- break;
-
- case Ptype:
- case Pmap:
- case Pctl:
- case Pstatus:
- case Pnote:
- case Pnotepg:
- case Pcmdline:
- case Prlimit:
- break;
-
- default:
- panic("procfs_getattr");
- }
-
- return (error);
-}
-
-static int
-procfs_setattr(ap)
- struct vop_setattr_args /* {
- struct vnode *a_vp;
- struct vattr *a_vap;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
-
- if (ap->a_vap->va_flags != VNOVAL)
- return (EOPNOTSUPP);
-
- /*
- * just fake out attribute setting
- * it's not good to generate an error
- * return, otherwise things like creat()
- * will fail when they try to set the
- * file length to 0. worse, this means
- * that echo $note > /proc/$pid/note will fail.
- */
-
- return (0);
-}
-
-/*
- * implement access checking.
- *
- * something very similar to this code is duplicated
- * throughout the 4bsd kernel and should be moved
- * into kern/vfs_subr.c sometime.
- *
- * actually, the check for super-user is slightly
- * broken since it will allow read access to write-only
- * objects. this doesn't cause any particular trouble
- * but does mean that the i/o entry points need to check
- * that the operation really does make sense.
- */
-static int
-procfs_access(ap)
- struct vop_access_args /* {
- struct vnode *a_vp;
- int a_mode;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- struct vattr *vap;
- struct vattr vattr;
- int error;
-
- /*
- * If you're the super-user,
- * you always get access.
- */
- if (ap->a_cred->cr_uid == 0)
- return (0);
-
- vap = &vattr;
- error = VOP_GETATTR(ap->a_vp, vap, ap->a_cred, ap->a_p);
- if (error)
- return (error);
-
- /*
- * Access check is based on only one of owner, group, public.
- * If not owner, then check group. If not a member of the
- * group, then check public access.
- */
- if (ap->a_cred->cr_uid != vap->va_uid) {
- gid_t *gp;
- int i;
-
- ap->a_mode >>= 3;
- gp = ap->a_cred->cr_groups;
- for (i = 0; i < ap->a_cred->cr_ngroups; i++, gp++)
- if (vap->va_gid == *gp)
- goto found;
- ap->a_mode >>= 3;
-found:
- ;
- }
-
- if ((vap->va_mode & ap->a_mode) == ap->a_mode)
- return (0);
-
- return (EACCES);
-}
-
-/*
- * lookup. this is incredibly complicated in the
- * general case, however for most pseudo-filesystems
- * very little needs to be done.
- *
- * unless you want to get a migraine, just make sure your
- * filesystem doesn't do any locking of its own. otherwise
- * read and inwardly digest ufs_lookup().
- */
-static int
-procfs_lookup(ap)
- struct vop_lookup_args /* {
- struct vnode * a_dvp;
- struct vnode ** a_vpp;
- struct componentname * a_cnp;
- } */ *ap;
-{
- struct componentname *cnp = ap->a_cnp;
- struct vnode **vpp = ap->a_vpp;
- struct vnode *dvp = ap->a_dvp;
- char *pname = cnp->cn_nameptr;
- struct proc *curp = cnp->cn_proc;
- struct proc_target *pt;
- struct vnode *fvp;
- pid_t pid;
- struct pfsnode *pfs;
- struct proc *p;
- int i;
-
- *vpp = NULL;
-
- if (cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME)
- return (EROFS);
-
- if (cnp->cn_namelen == 1 && *pname == '.') {
- *vpp = dvp;
- VREF(dvp);
- /* vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, curp); */
- return (0);
- }
-
- pfs = VTOPFS(dvp);
- switch (pfs->pfs_type) {
- case Proot:
- if (cnp->cn_flags & ISDOTDOT)
- return (EIO);
-
- if (CNEQ(cnp, "curproc", 7))
- return (procfs_allocvp(dvp->v_mount, vpp, 0, Pcurproc));
-
- pid = atopid(pname, cnp->cn_namelen);
- if (pid == NO_PID)
- break;
-
- p = PFIND(pid);
- if (p == 0)
- break;
-
- return (procfs_allocvp(dvp->v_mount, vpp, pid, Pproc));
-
- case Pproc:
- if (cnp->cn_flags & ISDOTDOT)
- return (procfs_root(dvp->v_mount, vpp));
-
- p = PFIND(pfs->pfs_pid);
- if (p == 0)
- break;
-
- for (pt = proc_targets, i = 0; i < nproc_targets; pt++, i++) {
- if (cnp->cn_namelen == pt->pt_namlen &&
- bcmp(pt->pt_name, pname, cnp->cn_namelen) == 0 &&
- (pt->pt_valid == NULL || (*pt->pt_valid)(p)))
- goto found;
- }
- break;
-
- found:
- if (pt->pt_pfstype == Pfile) {
- fvp = procfs_findtextvp(p);
- /* We already checked that it exists. */
- VREF(fvp);
- vn_lock(fvp, LK_EXCLUSIVE | LK_RETRY, curp);
- *vpp = fvp;
- return (0);
- }
-
- return (procfs_allocvp(dvp->v_mount, vpp, pfs->pfs_pid,
- pt->pt_pfstype));
-
- default:
- return (ENOTDIR);
- }
-
- return (cnp->cn_nameiop == LOOKUP ? ENOENT : EROFS);
-}
-
-/*
- * Does this process have a text file?
- */
-int
-procfs_validfile(p)
- struct proc *p;
-{
-
- return (procfs_findtextvp(p) != NULLVP);
-}
-
-/*
- * readdir() returns directory entries from pfsnode (vp).
- *
- * We generate just one directory entry at a time, as it would probably
- * not pay off to buffer several entries locally to save uiomove calls.
- */
-static int
-procfs_readdir(ap)
- struct vop_readdir_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- struct ucred *a_cred;
- int *a_eofflag;
- int *a_ncookies;
- u_long **a_cookies;
- } */ *ap;
-{
- struct uio *uio = ap->a_uio;
- struct dirent d;
- struct dirent *dp = &d;
- struct pfsnode *pfs;
- int count, error, i, off;
- static u_int delen;
-
- if (!delen) {
-
- d.d_namlen = PROCFS_NAMELEN;
- delen = GENERIC_DIRSIZ(&d);
- }
-
- pfs = VTOPFS(ap->a_vp);
-
- off = (int)uio->uio_offset;
- if (off != uio->uio_offset || off < 0 ||
- off % delen != 0 || uio->uio_resid < delen)
- return (EINVAL);
-
- error = 0;
- count = 0;
- i = off / delen;
-
- switch (pfs->pfs_type) {
- /*
- * this is for the process-specific sub-directories.
- * all that is needed to is copy out all the entries
- * from the procent[] table (top of this file).
- */
- case Pproc: {
- struct proc *p;
- struct proc_target *pt;
-
- p = PFIND(pfs->pfs_pid);
- if (p == NULL)
- break;
- if (!PRISON_CHECK(curproc, p))
- break;
-
- for (pt = &proc_targets[i];
- uio->uio_resid >= delen && i < nproc_targets; pt++, i++) {
- if (pt->pt_valid && (*pt->pt_valid)(p) == 0)
- continue;
-
- dp->d_reclen = delen;
- dp->d_fileno = PROCFS_FILENO(pfs->pfs_pid, pt->pt_pfstype);
- dp->d_namlen = pt->pt_namlen;
- bcopy(pt->pt_name, dp->d_name, pt->pt_namlen + 1);
- dp->d_type = pt->pt_type;
-
- if ((error = uiomove((caddr_t)dp, delen, uio)) != 0)
- break;
- }
-
- break;
- }
-
- /*
- * this is for the root of the procfs filesystem
- * what is needed is a special entry for "curproc"
- * followed by an entry for each process on allproc
-#ifdef PROCFS_ZOMBIE
- * and zombproc.
-#endif
- */
-
- case Proot: {
-#ifdef PROCFS_ZOMBIE
- int doingzomb = 0;
-#endif
- int pcnt = 0;
- volatile struct proc *p = allproc.lh_first;
-
- for (; p && uio->uio_resid >= delen; i++, pcnt++) {
- bzero((char *) dp, delen);
- dp->d_reclen = delen;
-
- switch (i) {
- case 0: /* `.' */
- case 1: /* `..' */
- dp->d_fileno = PROCFS_FILENO(0, Proot);
- dp->d_namlen = i + 1;
- bcopy("..", dp->d_name, dp->d_namlen);
- dp->d_name[i + 1] = '\0';
- dp->d_type = DT_DIR;
- break;
-
- case 2:
- dp->d_fileno = PROCFS_FILENO(0, Pcurproc);
- dp->d_namlen = 7;
- bcopy("curproc", dp->d_name, 8);
- dp->d_type = DT_LNK;
- break;
-
- default:
- while (pcnt < i) {
- p = p->p_list.le_next;
- if (!p)
- goto done;
- if (!PRISON_CHECK(curproc, p))
- continue;
- pcnt++;
- }
- while (!PRISON_CHECK(curproc, p)) {
- p = p->p_list.le_next;
- if (!p)
- goto done;
- }
- dp->d_fileno = PROCFS_FILENO(p->p_pid, Pproc);
- dp->d_namlen = sprintf(dp->d_name, "%ld",
- (long)p->p_pid);
- dp->d_type = DT_REG;
- p = p->p_list.le_next;
- break;
- }
-
- if ((error = uiomove((caddr_t)dp, delen, uio)) != 0)
- break;
- }
- done:
-
-#ifdef PROCFS_ZOMBIE
- if (p == 0 && doingzomb == 0) {
- doingzomb = 1;
- p = zombproc.lh_first;
- goto again;
- }
-#endif
-
- break;
-
- }
-
- default:
- error = ENOTDIR;
- break;
- }
-
- uio->uio_offset = i * delen;
-
- return (error);
-}
-
-/*
- * readlink reads the link of `curproc'
- */
-static int
-procfs_readlink(ap)
- struct vop_readlink_args *ap;
-{
- char buf[16]; /* should be enough */
- int len;
-
- if (VTOPFS(ap->a_vp)->pfs_fileno != PROCFS_FILENO(0, Pcurproc))
- return (EINVAL);
-
- len = snprintf(buf, sizeof(buf), "%ld", (long)curproc->p_pid);
-
- return (uiomove((caddr_t)buf, len, ap->a_uio));
-}
-
-/*
- * convert decimal ascii to pid_t
- */
-static pid_t
-atopid(b, len)
- const char *b;
- u_int len;
-{
- pid_t p = 0;
-
- while (len--) {
- char c = *b++;
- if (c < '0' || c > '9')
- return (NO_PID);
- p = 10 * p + (c - '0');
- if (p > PID_MAX)
- return (NO_PID);
- }
-
- return (p);
-}
-
-/*
- * procfs vnode operations.
- */
-vop_t **procfs_vnodeop_p;
-static struct vnodeopv_entry_desc procfs_vnodeop_entries[] = {
- { &vop_default_desc, (vop_t *) vop_defaultop },
- { &vop_access_desc, (vop_t *) procfs_access },
- { &vop_advlock_desc, (vop_t *) procfs_badop },
- { &vop_bmap_desc, (vop_t *) procfs_bmap },
- { &vop_close_desc, (vop_t *) procfs_close },
- { &vop_create_desc, (vop_t *) procfs_badop },
- { &vop_getattr_desc, (vop_t *) procfs_getattr },
- { &vop_inactive_desc, (vop_t *) procfs_inactive },
- { &vop_link_desc, (vop_t *) procfs_badop },
- { &vop_lookup_desc, (vop_t *) procfs_lookup },
- { &vop_mkdir_desc, (vop_t *) procfs_badop },
- { &vop_mknod_desc, (vop_t *) procfs_badop },
- { &vop_open_desc, (vop_t *) procfs_open },
- { &vop_pathconf_desc, (vop_t *) vop_stdpathconf },
- { &vop_print_desc, (vop_t *) procfs_print },
- { &vop_read_desc, (vop_t *) procfs_rw },
- { &vop_readdir_desc, (vop_t *) procfs_readdir },
- { &vop_readlink_desc, (vop_t *) procfs_readlink },
- { &vop_reclaim_desc, (vop_t *) procfs_reclaim },
- { &vop_remove_desc, (vop_t *) procfs_badop },
- { &vop_rename_desc, (vop_t *) procfs_badop },
- { &vop_rmdir_desc, (vop_t *) procfs_badop },
- { &vop_setattr_desc, (vop_t *) procfs_setattr },
- { &vop_symlink_desc, (vop_t *) procfs_badop },
- { &vop_write_desc, (vop_t *) procfs_rw },
- { &vop_ioctl_desc, (vop_t *) procfs_ioctl },
- { NULL, NULL }
-};
-static struct vnodeopv_desc procfs_vnodeop_opv_desc =
- { &procfs_vnodeop_p, procfs_vnodeop_entries };
-
-VNODEOP_SET(procfs_vnodeop_opv_desc);
diff --git a/sys/fs/specfs/spec_vnops.c b/sys/fs/specfs/spec_vnops.c
deleted file mode 100644
index 9641897a75bb..000000000000
--- a/sys/fs/specfs/spec_vnops.c
+++ /dev/null
@@ -1,781 +0,0 @@
-/*
- * Copyright (c) 1989, 1993, 1995
- * 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)spec_vnops.c 8.14 (Berkeley) 5/21/95
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/proc.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/conf.h>
-#include <sys/buf.h>
-#include <sys/mount.h>
-#include <sys/vnode.h>
-#include <sys/stat.h>
-#include <sys/fcntl.h>
-#include <sys/vmmeter.h>
-#include <sys/tty.h>
-
-#include <vm/vm.h>
-#include <vm/vm_object.h>
-#include <vm/vm_page.h>
-#include <vm/vm_pager.h>
-
-static int spec_advlock __P((struct vop_advlock_args *));
-static int spec_bmap __P((struct vop_bmap_args *));
-static int spec_close __P((struct vop_close_args *));
-static int spec_freeblks __P((struct vop_freeblks_args *));
-static int spec_fsync __P((struct vop_fsync_args *));
-static int spec_getpages __P((struct vop_getpages_args *));
-static int spec_inactive __P((struct vop_inactive_args *));
-static int spec_ioctl __P((struct vop_ioctl_args *));
-static int spec_open __P((struct vop_open_args *));
-static int spec_poll __P((struct vop_poll_args *));
-static int spec_print __P((struct vop_print_args *));
-static int spec_read __P((struct vop_read_args *));
-static int spec_strategy __P((struct vop_strategy_args *));
-static int spec_write __P((struct vop_write_args *));
-
-vop_t **spec_vnodeop_p;
-static struct vnodeopv_entry_desc spec_vnodeop_entries[] = {
- { &vop_default_desc, (vop_t *) vop_defaultop },
- { &vop_access_desc, (vop_t *) vop_ebadf },
- { &vop_advlock_desc, (vop_t *) spec_advlock },
- { &vop_bmap_desc, (vop_t *) spec_bmap },
- { &vop_close_desc, (vop_t *) spec_close },
- { &vop_create_desc, (vop_t *) vop_panic },
- { &vop_freeblks_desc, (vop_t *) spec_freeblks },
- { &vop_fsync_desc, (vop_t *) spec_fsync },
- { &vop_getpages_desc, (vop_t *) spec_getpages },
- { &vop_inactive_desc, (vop_t *) spec_inactive },
- { &vop_ioctl_desc, (vop_t *) spec_ioctl },
- { &vop_lease_desc, (vop_t *) vop_null },
- { &vop_link_desc, (vop_t *) vop_panic },
- { &vop_mkdir_desc, (vop_t *) vop_panic },
- { &vop_mknod_desc, (vop_t *) vop_panic },
- { &vop_open_desc, (vop_t *) spec_open },
- { &vop_pathconf_desc, (vop_t *) vop_stdpathconf },
- { &vop_poll_desc, (vop_t *) spec_poll },
- { &vop_print_desc, (vop_t *) spec_print },
- { &vop_read_desc, (vop_t *) spec_read },
- { &vop_readdir_desc, (vop_t *) vop_panic },
- { &vop_readlink_desc, (vop_t *) vop_panic },
- { &vop_reallocblks_desc, (vop_t *) vop_panic },
- { &vop_reclaim_desc, (vop_t *) vop_null },
- { &vop_remove_desc, (vop_t *) vop_panic },
- { &vop_rename_desc, (vop_t *) vop_panic },
- { &vop_rmdir_desc, (vop_t *) vop_panic },
- { &vop_setattr_desc, (vop_t *) vop_ebadf },
- { &vop_strategy_desc, (vop_t *) spec_strategy },
- { &vop_symlink_desc, (vop_t *) vop_panic },
- { &vop_write_desc, (vop_t *) spec_write },
- { NULL, NULL }
-};
-static struct vnodeopv_desc spec_vnodeop_opv_desc =
- { &spec_vnodeop_p, spec_vnodeop_entries };
-
-VNODEOP_SET(spec_vnodeop_opv_desc);
-
-int
-spec_vnoperate(ap)
- struct vop_generic_args /* {
- struct vnodeop_desc *a_desc;
- <other random data follows, presumably>
- } */ *ap;
-{
- return (VOCALL(spec_vnodeop_p, ap->a_desc->vdesc_offset, ap));
-}
-
-static void spec_getpages_iodone __P((struct buf *bp));
-
-/*
- * Open a special file.
- */
-/* ARGSUSED */
-static int
-spec_open(ap)
- struct vop_open_args /* {
- struct vnode *a_vp;
- int a_mode;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- struct proc *p = ap->a_p;
- struct vnode *vp = ap->a_vp;
- dev_t dev = vp->v_rdev;
- int error;
- struct cdevsw *dsw;
- const char *cp;
-
- /*
- * Don't allow open if fs is mounted -nodev.
- */
- if (vp->v_mount && (vp->v_mount->mnt_flag & MNT_NODEV))
- return (ENXIO);
-
- dsw = devsw(dev);
- if ( (dsw == NULL) || (dsw->d_open == NULL))
- return ENXIO;
-
- /* Make this field valid before any I/O in ->d_open */
- if (!dev->si_iosize_max)
- dev->si_iosize_max = DFLTPHYS;
-
- /*
- * XXX: Disks get special billing here, but it is mostly wrong.
- * XXX: diskpartitions can overlap and the real checks should
- * XXX: take this into account, and consequently they need to
- * XXX: live in the diskslicing code. Some checks do.
- */
- if (vn_isdisk(vp, NULL) && ap->a_cred != FSCRED &&
- (ap->a_mode & FWRITE)) {
- /*
- * Never allow opens for write if the device is mounted R/W
- */
- if (vp->v_specmountpoint != NULL &&
- !(vp->v_specmountpoint->mnt_flag & MNT_RDONLY))
- return (EBUSY);
-
- /*
- * When running in secure mode, do not allow opens
- * for writing if the device is mounted
- */
- if (securelevel >= 1 && vp->v_specmountpoint != NULL)
- return (EPERM);
-
- /*
- * When running in very secure mode, do not allow
- * opens for writing of any devices.
- */
- if (securelevel >= 2)
- return (EPERM);
- }
-
- /* XXX: Special casing of ttys for deadfs. Probably redundant */
- if (dsw->d_flags & D_TTY)
- vp->v_flag |= VISTTY;
-
- VOP_UNLOCK(vp, 0, p);
- error = (*dsw->d_open)(dev, ap->a_mode, S_IFCHR, p);
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
-
- if (error)
- return (error);
-
- if (dsw->d_flags & D_TTY) {
- if (dev->si_tty) {
- struct tty *tp;
- tp = dev->si_tty;
- if (!tp->t_stop) {
- printf("Warning:%s: no t_stop, using nottystop\n", devtoname(dev));
- tp->t_stop = nottystop;
- }
- }
- }
-
- if (vn_isdisk(vp, NULL)) {
- if (!dev->si_bsize_phys)
- dev->si_bsize_phys = DEV_BSIZE;
- }
- if ((dsw->d_flags & D_DISK) == 0) {
- cp = devtoname(dev);
- if (*cp == '#' && (dsw->d_flags & D_NAGGED) == 0) {
- printf("WARNING: driver %s should register devices with make_dev() (dev_t = \"%s\")\n",
- dsw->d_name, cp);
- dsw->d_flags |= D_NAGGED;
- }
- }
- return (error);
-}
-
-/*
- * Vnode op for read
- */
-/* ARGSUSED */
-static int
-spec_read(ap)
- struct vop_read_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- int a_ioflag;
- struct ucred *a_cred;
- } */ *ap;
-{
- struct vnode *vp;
- struct proc *p;
- struct uio *uio;
- dev_t dev;
- int error;
-
- vp = ap->a_vp;
- dev = vp->v_rdev;
- uio = ap->a_uio;
- p = uio->uio_procp;
-
- if (uio->uio_resid == 0)
- return (0);
-
- VOP_UNLOCK(vp, 0, p);
- error = (*devsw(dev)->d_read) (dev, uio, ap->a_ioflag);
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
- return (error);
-}
-
-/*
- * Vnode op for write
- */
-/* ARGSUSED */
-static int
-spec_write(ap)
- struct vop_write_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- int a_ioflag;
- struct ucred *a_cred;
- } */ *ap;
-{
- struct vnode *vp;
- struct proc *p;
- struct uio *uio;
- dev_t dev;
- int error;
-
- vp = ap->a_vp;
- dev = vp->v_rdev;
- uio = ap->a_uio;
- p = uio->uio_procp;
-
- VOP_UNLOCK(vp, 0, p);
- error = (*devsw(dev)->d_write) (dev, uio, ap->a_ioflag);
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
- return (error);
-}
-
-/*
- * Device ioctl operation.
- */
-/* ARGSUSED */
-static int
-spec_ioctl(ap)
- struct vop_ioctl_args /* {
- struct vnode *a_vp;
- int a_command;
- caddr_t a_data;
- int a_fflag;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- dev_t dev;
-
- dev = ap->a_vp->v_rdev;
- return ((*devsw(dev)->d_ioctl)(dev, ap->a_command,
- ap->a_data, ap->a_fflag, ap->a_p));
-}
-
-/* ARGSUSED */
-static int
-spec_poll(ap)
- struct vop_poll_args /* {
- struct vnode *a_vp;
- int a_events;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- dev_t dev;
-
- dev = ap->a_vp->v_rdev;
- return (*devsw(dev)->d_poll)(dev, ap->a_events, ap->a_p);
-}
-/*
- * Synch buffers associated with a block device
- */
-/* ARGSUSED */
-static int
-spec_fsync(ap)
- struct vop_fsync_args /* {
- struct vnode *a_vp;
- struct ucred *a_cred;
- int a_waitfor;
- struct proc *a_p;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
- struct buf *bp;
- struct buf *nbp;
- int s;
-
- if (!vn_isdisk(vp, NULL))
- return (0);
-
- /*
- * Flush all dirty buffers associated with a block device.
- */
-loop:
- s = splbio();
- for (bp = TAILQ_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) {
- nbp = TAILQ_NEXT(bp, b_vnbufs);
- if (BUF_LOCK(bp, LK_EXCLUSIVE | LK_NOWAIT))
- continue;
- if ((bp->b_flags & B_DELWRI) == 0)
- panic("spec_fsync: not dirty");
- if ((vp->v_flag & VOBJBUF) && (bp->b_flags & B_CLUSTEROK)) {
- BUF_UNLOCK(bp);
- vfs_bio_awrite(bp);
- splx(s);
- } else {
- bremfree(bp);
- splx(s);
- bawrite(bp);
- }
- goto loop;
- }
- if (ap->a_waitfor == MNT_WAIT) {
- while (vp->v_numoutput) {
- vp->v_flag |= VBWAIT;
- (void) tsleep((caddr_t)&vp->v_numoutput, PRIBIO + 1, "spfsyn", 0);
- }
-#ifdef DIAGNOSTIC
- if (!TAILQ_EMPTY(&vp->v_dirtyblkhd)) {
- vprint("spec_fsync: dirty", vp);
- splx(s);
- goto loop;
- }
-#endif
- }
- splx(s);
- return (0);
-}
-
-static int
-spec_inactive(ap)
- struct vop_inactive_args /* {
- struct vnode *a_vp;
- struct proc *a_p;
- } */ *ap;
-{
-
- VOP_UNLOCK(ap->a_vp, 0, ap->a_p);
- return (0);
-}
-
-/*
- * Just call the device strategy routine
- */
-static int
-spec_strategy(ap)
- struct vop_strategy_args /* {
- struct vnode *a_vp;
- struct buf *a_bp;
- } */ *ap;
-{
- struct buf *bp;
- struct vnode *vp;
- struct mount *mp;
-
- bp = ap->a_bp;
- if (((bp->b_flags & B_READ) == 0) &&
- (LIST_FIRST(&bp->b_dep)) != NULL && bioops.io_start)
- (*bioops.io_start)(bp);
-
- /*
- * Collect statistics on synchronous and asynchronous read
- * and write counts for disks that have associated filesystems.
- */
- vp = ap->a_vp;
- if (vn_isdisk(vp, NULL) && (mp = vp->v_specmountpoint) != NULL) {
- if ((bp->b_flags & B_READ) == 0) {
- if (bp->b_lock.lk_lockholder == LK_KERNPROC)
- mp->mnt_stat.f_asyncwrites++;
- else
- mp->mnt_stat.f_syncwrites++;
- } else {
- if (bp->b_lock.lk_lockholder == LK_KERNPROC)
- mp->mnt_stat.f_asyncreads++;
- else
- mp->mnt_stat.f_syncreads++;
- }
- }
- KASSERT(devsw(bp->b_dev) != NULL,
- ("No devsw on dev %s responsible for buffer %p\n",
- devtoname(bp->b_dev), bp));
- KASSERT(devsw(bp->b_dev)->d_strategy != NULL,
- ("No strategy on dev %s responsible for buffer %p\n",
- devtoname(bp->b_dev), bp));
- BUF_STRATEGY(bp, 0);
- return (0);
-}
-
-static int
-spec_freeblks(ap)
- struct vop_freeblks_args /* {
- struct vnode *a_vp;
- daddr_t a_addr;
- daddr_t a_length;
- } */ *ap;
-{
- struct cdevsw *bsw;
- struct buf *bp;
-
- /*
- * XXX: This assumes that strategy does the deed right away.
- * XXX: this may not be TRTTD.
- */
- bsw = devsw(ap->a_vp->v_rdev);
- if ((bsw->d_flags & D_CANFREE) == 0)
- return (0);
- bp = geteblk(ap->a_length);
- bp->b_flags |= B_FREEBUF;
- bp->b_dev = ap->a_vp->v_rdev;
- bp->b_blkno = ap->a_addr;
- bp->b_offset = dbtob(ap->a_addr);
- bp->b_bcount = ap->a_length;
- BUF_STRATEGY(bp, 0);
- return (0);
-}
-
-/*
- * Implement degenerate case where the block requested is the block
- * returned, and assume that the entire device is contiguous in regards
- * to the contiguous block range (runp and runb).
- */
-static int
-spec_bmap(ap)
- struct vop_bmap_args /* {
- struct vnode *a_vp;
- daddr_t a_bn;
- struct vnode **a_vpp;
- daddr_t *a_bnp;
- int *a_runp;
- int *a_runb;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
- int runp = 0;
- int runb = 0;
-
- if (ap->a_vpp != NULL)
- *ap->a_vpp = vp;
- if (ap->a_bnp != NULL)
- *ap->a_bnp = ap->a_bn;
- if (vp->v_mount != NULL)
- runp = runb = MAXBSIZE / vp->v_mount->mnt_stat.f_iosize;
- if (ap->a_runp != NULL)
- *ap->a_runp = runp;
- if (ap->a_runb != NULL)
- *ap->a_runb = runb;
- return (0);
-}
-
-/*
- * Device close routine
- */
-/* ARGSUSED */
-static int
-spec_close(ap)
- struct vop_close_args /* {
- struct vnode *a_vp;
- int a_fflag;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
- struct proc *p = ap->a_p;
- dev_t dev = vp->v_rdev;
-
- /*
- * Hack: a tty device that is a controlling terminal
- * has a reference from the session structure.
- * We cannot easily tell that a character device is
- * a controlling terminal, unless it is the closing
- * process' controlling terminal. In that case,
- * if the reference count is 2 (this last descriptor
- * plus the session), release the reference from the session.
- */
- if (vcount(vp) == 2 && p && (vp->v_flag & VXLOCK) == 0 &&
- vp == p->p_session->s_ttyvp) {
- vrele(vp);
- p->p_session->s_ttyvp = NULL;
- }
- /*
- * We do not want to really close the device if it
- * is still in use unless we are trying to close it
- * forcibly. Since every use (buffer, vnode, swap, cmap)
- * holds a reference to the vnode, and because we mark
- * any other vnodes that alias this device, when the
- * sum of the reference counts on all the aliased
- * vnodes descends to one, we are on last close.
- */
- if (vp->v_flag & VXLOCK) {
- /* Forced close */
- } else if (devsw(dev)->d_flags & D_TRACKCLOSE) {
- /* Keep device updated on status */
- } else if (vcount(vp) > 1) {
- return (0);
- }
- return (devsw(dev)->d_close(dev, ap->a_fflag, S_IFCHR, p));
-}
-
-/*
- * Print out the contents of a special device vnode.
- */
-static int
-spec_print(ap)
- struct vop_print_args /* {
- struct vnode *a_vp;
- } */ *ap;
-{
-
- printf("tag VT_NON, dev %s\n", devtoname(ap->a_vp->v_rdev));
- return (0);
-}
-
-/*
- * Special device advisory byte-level locks.
- */
-/* ARGSUSED */
-static int
-spec_advlock(ap)
- struct vop_advlock_args /* {
- struct vnode *a_vp;
- caddr_t a_id;
- int a_op;
- struct flock *a_fl;
- int a_flags;
- } */ *ap;
-{
-
- return (ap->a_flags & F_FLOCK ? EOPNOTSUPP : EINVAL);
-}
-
-static void
-spec_getpages_iodone(bp)
- struct buf *bp;
-{
-
- bp->b_flags |= B_DONE;
- wakeup(bp);
-}
-
-static int
-spec_getpages(ap)
- struct vop_getpages_args *ap;
-{
- vm_offset_t kva;
- int error;
- int i, pcount, size, s;
- daddr_t blkno;
- struct buf *bp;
- vm_page_t m;
- vm_ooffset_t offset;
- int toff, nextoff, nread;
- struct vnode *vp = ap->a_vp;
- int blksiz;
- int gotreqpage;
-
- error = 0;
- pcount = round_page(ap->a_count) / PAGE_SIZE;
-
- /*
- * Calculate the offset of the transfer and do sanity check.
- * FreeBSD currently only supports an 8 TB range due to b_blkno
- * being in DEV_BSIZE ( usually 512 ) byte chunks on call to
- * VOP_STRATEGY. XXX
- */
- offset = IDX_TO_OFF(ap->a_m[0]->pindex) + ap->a_offset;
-
-#define DADDR_T_BIT (sizeof(daddr_t)*8)
-#define OFFSET_MAX ((1LL << (DADDR_T_BIT + DEV_BSHIFT)) - 1)
-
- if (offset < 0 || offset > OFFSET_MAX) {
- /* XXX still no %q in kernel. */
- printf("spec_getpages: preposterous offset 0x%x%08x\n",
- (u_int)((u_quad_t)offset >> 32),
- (u_int)(offset & 0xffffffff));
- return (VM_PAGER_ERROR);
- }
-
- blkno = btodb(offset);
-
- /*
- * Round up physical size for real devices. We cannot round using
- * v_mount's block size data because v_mount has nothing to do with
- * the device. i.e. it's usually '/dev'. We need the physical block
- * size for the device itself.
- *
- * We can't use v_specmountpoint because it only exists when the
- * block device is mounted. However, we can use v_rdev.
- */
-
- if (vn_isdisk(vp, NULL))
- blksiz = vp->v_rdev->si_bsize_phys;
- else
- blksiz = DEV_BSIZE;
-
- size = (ap->a_count + blksiz - 1) & ~(blksiz - 1);
-
- bp = getpbuf(NULL);
- kva = (vm_offset_t)bp->b_data;
-
- /*
- * Map the pages to be read into the kva.
- */
- pmap_qenter(kva, ap->a_m, pcount);
-
- /* Build a minimal buffer header. */
- bp->b_flags = B_READ | B_CALL;
- bp->b_iodone = spec_getpages_iodone;
-
- /* B_PHYS is not set, but it is nice to fill this in. */
- bp->b_rcred = bp->b_wcred = curproc->p_ucred;
- if (bp->b_rcred != NOCRED)
- crhold(bp->b_rcred);
- if (bp->b_wcred != NOCRED)
- crhold(bp->b_wcred);
- bp->b_blkno = blkno;
- bp->b_lblkno = blkno;
- pbgetvp(ap->a_vp, bp);
- bp->b_bcount = size;
- bp->b_bufsize = size;
- bp->b_resid = 0;
-
- cnt.v_vnodein++;
- cnt.v_vnodepgsin += pcount;
-
- /* Do the input. */
- VOP_STRATEGY(bp->b_vp, bp);
-
- s = splbio();
-
- /* We definitely need to be at splbio here. */
- while ((bp->b_flags & B_DONE) == 0)
- tsleep(bp, PVM, "spread", 0);
-
- splx(s);
-
- if ((bp->b_flags & B_ERROR) != 0) {
- if (bp->b_error)
- error = bp->b_error;
- else
- error = EIO;
- }
-
- nread = size - bp->b_resid;
-
- if (nread < ap->a_count) {
- bzero((caddr_t)kva + nread,
- ap->a_count - nread);
- }
- pmap_qremove(kva, pcount);
-
-
- gotreqpage = 0;
- for (i = 0, toff = 0; i < pcount; i++, toff = nextoff) {
- nextoff = toff + PAGE_SIZE;
- m = ap->a_m[i];
-
- m->flags &= ~PG_ZERO;
-
- if (nextoff <= nread) {
- m->valid = VM_PAGE_BITS_ALL;
- vm_page_undirty(m);
- } else if (toff < nread) {
- /*
- * Since this is a VM request, we have to supply the
- * unaligned offset to allow vm_page_set_validclean()
- * to zero sub-DEV_BSIZE'd portions of the page.
- */
- vm_page_set_validclean(m, 0, nread - toff);
- } else {
- m->valid = 0;
- vm_page_undirty(m);
- }
-
- if (i != ap->a_reqpage) {
- /*
- * Just in case someone was asking for this page we
- * now tell them that it is ok to use.
- */
- if (!error || (m->valid == VM_PAGE_BITS_ALL)) {
- if (m->valid) {
- if (m->flags & PG_WANTED) {
- vm_page_activate(m);
- } else {
- vm_page_deactivate(m);
- }
- vm_page_wakeup(m);
- } else {
- vm_page_free(m);
- }
- } else {
- vm_page_free(m);
- }
- } else if (m->valid) {
- gotreqpage = 1;
- /*
- * Since this is a VM request, we need to make the
- * entire page presentable by zeroing invalid sections.
- */
- if (m->valid != VM_PAGE_BITS_ALL)
- vm_page_zero_invalid(m, FALSE);
- }
- }
- if (!gotreqpage) {
- m = ap->a_m[ap->a_reqpage];
-#ifndef MAX_PERF
- printf(
- "spec_getpages:(%s) I/O read failure: (error=%d) bp %p vp %p\n",
- devtoname(bp->b_dev), error, bp, bp->b_vp);
- printf(
- " size: %d, resid: %ld, a_count: %d, valid: 0x%x\n",
- size, bp->b_resid, ap->a_count, m->valid);
- printf(
- " nread: %d, reqpage: %d, pindex: %lu, pcount: %d\n",
- nread, ap->a_reqpage, (u_long)m->pindex, pcount);
-#endif
- /*
- * Free the buffer header back to the swap buffer pool.
- */
- relpbuf(bp, NULL);
- return VM_PAGER_ERROR;
- }
- /*
- * Free the buffer header back to the swap buffer pool.
- */
- relpbuf(bp, NULL);
- return VM_PAGER_OK;
-}
diff --git a/sys/fs/umapfs/umap.h b/sys/fs/umapfs/umap.h
deleted file mode 100644
index eb562eda6722..000000000000
--- a/sys/fs/umapfs/umap.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * the UCLA Ficus project.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)umap.h 8.4 (Berkeley) 8/20/94
- *
- * $FreeBSD$
- */
-
-#define MAPFILEENTRIES 64
-#define GMAPFILEENTRIES 16
-#define NOBODY 32767
-#define NULLGROUP 65534
-
-struct umap_args {
- char *target; /* Target of loopback */
- int nentries; /* # of entries in user map array */
- int gnentries; /* # of entries in group map array */
- u_long (*mapdata)[2]; /* pointer to array of user mappings */
- u_long (*gmapdata)[2]; /* pointer to array of group mappings */
-};
-
-struct umap_mount {
- struct mount *umapm_vfs;
- struct vnode *umapm_rootvp; /* Reference to root umap_node */
- int info_nentries; /* number of uid mappings */
- int info_gnentries; /* number of gid mappings */
- u_long info_mapdata[MAPFILEENTRIES][2]; /* mapping data for
- user mapping in ficus */
- u_long info_gmapdata[GMAPFILEENTRIES][2]; /*mapping data for
- group mapping in ficus */
-};
-
-#ifdef _KERNEL
-/*
- * A cache of vnode references
- */
-struct umap_node {
- LIST_ENTRY(umap_node) umap_hash; /* Hash list */
- struct vnode *umap_lowervp; /* Aliased vnode - VREFed once */
- struct vnode *umap_vnode; /* Back pointer to vnode/umap_node */
-};
-
-extern int umapfs_init __P((struct vfsconf *vfsp));
-extern int umap_node_create __P((struct mount *mp, struct vnode *target, struct vnode **vpp));
-extern u_long umap_reverse_findid __P((u_long id, u_long map[][2], int nentries));
-extern void umap_mapids __P((struct mount *v_mount, struct ucred *credp));
-
-#define MOUNTTOUMAPMOUNT(mp) ((struct umap_mount *)((mp)->mnt_data))
-#define VTOUMAP(vp) ((struct umap_node *)(vp)->v_data)
-#define UMAPTOV(xp) ((xp)->umap_vnode)
-#ifdef DIAGNOSTIC
-extern struct vnode *umap_checkvp __P((struct vnode *vp, char *fil, int lno));
-#define UMAPVPTOLOWERVP(vp) umap_checkvp((vp), __FILE__, __LINE__)
-#else
-#define UMAPVPTOLOWERVP(vp) (VTOUMAP(vp)->umap_lowervp)
-#endif
-
-extern vop_t **umap_vnodeop_p;
-#endif /* _KERNEL */
diff --git a/sys/fs/umapfs/umap_subr.c b/sys/fs/umapfs/umap_subr.c
deleted file mode 100644
index 6f08513cf552..000000000000
--- a/sys/fs/umapfs/umap_subr.c
+++ /dev/null
@@ -1,404 +0,0 @@
-/*
- * Copyright (c) 1992, 1993, 1995
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)umap_subr.c 8.9 (Berkeley) 5/14/95
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/proc.h>
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <sys/malloc.h>
-#include <miscfs/umapfs/umap.h>
-
-#define LOG2_SIZEVNODE 7 /* log2(sizeof struct vnode) */
-#define NUMAPNODECACHE 16
-
-/*
- * Null layer cache:
- * Each cache entry holds a reference to the target vnode
- * along with a pointer to the alias vnode. When an
- * entry is added the target vnode is VREF'd. When the
- * alias is removed the target vnode is vrele'd.
- */
-
-#define UMAP_NHASH(vp) \
- (&umap_node_hashtbl \
- [((uintptr_t)(void *)(vp) >> LOG2_SIZEVNODE) & umap_node_hash])
-static LIST_HEAD(umap_node_hashhead, umap_node) *umap_node_hashtbl;
-static u_long umap_node_hash;
-
-static u_long umap_findid __P((u_long id, u_long map[][2], int nentries));
-static int umap_node_alloc __P((struct mount *mp, struct vnode *lowervp,
- struct vnode **vpp));
-static struct vnode *
- umap_node_find __P((struct mount *mp, struct vnode *targetvp));
-
-/*
- * Initialise cache headers
- */
-int
-umapfs_init(vfsp)
- struct vfsconf *vfsp;
-{
-
-#ifdef DEBUG
- printf("umapfs_init\n"); /* printed during system boot */
-#endif
- umap_node_hashtbl = hashinit(NUMAPNODECACHE, M_CACHE, &umap_node_hash);
- return (0);
-}
-
-/*
- * umap_findid is called by various routines in umap_vnodeops.c to
- * find a user or group id in a map.
- */
-static u_long
-umap_findid(id, map, nentries)
- u_long id;
- u_long map[][2];
- int nentries;
-{
- int i;
-
- /* Find uid entry in map */
- i = 0;
- while ((i<nentries) && ((map[i][0]) != id))
- i++;
-
- if (i < nentries)
- return (map[i][1]);
- else
- return (-1);
-
-}
-
-/*
- * umap_reverse_findid is called by umap_getattr() in umap_vnodeops.c to
- * find a user or group id in a map, in reverse.
- */
-u_long
-umap_reverse_findid(id, map, nentries)
- u_long id;
- u_long map[][2];
- int nentries;
-{
- int i;
-
- /* Find uid entry in map */
- i = 0;
- while ((i<nentries) && ((map[i][1]) != id))
- i++;
-
- if (i < nentries)
- return (map[i][0]);
- else
- return (-1);
-
-}
-
-/*
- * Return alias for target vnode if already exists, else 0.
- */
-static struct vnode *
-umap_node_find(mp, targetvp)
- struct mount *mp;
- struct vnode *targetvp;
-{
- struct proc *p = curproc; /* XXX */
- struct umap_node_hashhead *hd;
- struct umap_node *a;
- struct vnode *vp;
-
-#ifdef DEBUG
- printf("umap_node_find(mp = %p, target = %p)\n",
- (void *)mp, (void *)targetvp);
-#endif
-
- /*
- * Find hash base, and then search the (two-way) linked
- * list looking for a umap_node structure which is referencing
- * the target vnode. If found, the increment the umap_node
- * reference count (but NOT the target vnode's VREF counter).
- */
- hd = UMAP_NHASH(targetvp);
-loop:
- for (a = hd->lh_first; a != 0; a = a->umap_hash.le_next) {
- if (a->umap_lowervp == targetvp &&
- a->umap_vnode->v_mount == mp) {
- vp = UMAPTOV(a);
- /*
- * We need vget for the VXLOCK
- * stuff, but we don't want to lock
- * the lower node.
- */
- if (vget(vp, 0, p)) {
-#ifdef DEBUG
- printf ("umap_node_find: vget failed.\n");
-#endif
- goto loop;
- }
- return (vp);
- }
- }
-
-#ifdef DEBUG
- printf("umap_node_find(%p, %p): NOT found\n",
- (void *)mp, (void *)targetvp);
-#endif
-
- return (0);
-}
-
-/*
- * Make a new umap_node node.
- * Vp is the alias vnode, lofsvp is the target vnode.
- * Maintain a reference to (targetvp).
- */
-static int
-umap_node_alloc(mp, lowervp, vpp)
- struct mount *mp;
- struct vnode *lowervp;
- struct vnode **vpp;
-{
- struct umap_node_hashhead *hd;
- struct umap_node *xp;
- struct vnode *othervp, *vp;
- int error;
-
- /* XXX This routine probably needs a node_alloc lock */
-
- /*
- * Do the MALLOC before the getnewvnode since doing so afterward
- * might cause a bogus v_data pointer to get dereferenced
- * elsewhere if MALLOC should block.
- */
- MALLOC(xp, struct umap_node *, sizeof(struct umap_node),
- M_TEMP, M_WAITOK);
-
- error = getnewvnode(VT_UMAP, mp, umap_vnodeop_p, vpp);
- if (error) {
- FREE(xp, M_TEMP);
- return (error);
- }
- vp = *vpp;
-
- vp->v_type = lowervp->v_type;
- xp->umap_vnode = vp;
- vp->v_data = xp;
- xp->umap_lowervp = lowervp;
- /*
- * Before we insert our new node onto the hash chains,
- * check to see if someone else has beaten us to it.
- * (We could have slept in MALLOC.)
- */
- othervp = umap_node_find(mp, lowervp);
- if (othervp) {
- FREE(xp, M_TEMP);
- vp->v_type = VBAD; /* node is discarded */
- vp->v_usecount = 0; /* XXX */
- *vpp = othervp;
- return (0);
- }
- VREF(lowervp); /* Extra VREF will be vrele'd in umap_node_create */
- hd = UMAP_NHASH(lowervp);
- LIST_INSERT_HEAD(hd, xp, umap_hash);
- return (0);
-}
-
-
-/*
- * Try to find an existing umap_node vnode refering
- * to it, otherwise make a new umap_node vnode which
- * contains a reference to the target vnode.
- */
-int
-umap_node_create(mp, targetvp, newvpp)
- struct mount *mp;
- struct vnode *targetvp;
- struct vnode **newvpp;
-{
- struct vnode *aliasvp;
-
- aliasvp = umap_node_find(mp, targetvp);
- if (aliasvp) {
- /*
- * Take another reference to the alias vnode
- */
-#ifdef DEBUG
- vprint("umap_node_create: exists", aliasvp);
-#endif
- /* VREF(aliasvp); */
- } else {
- int error;
-
- /*
- * Get new vnode.
- */
-#ifdef DEBUG
- printf("umap_node_create: create new alias vnode\n");
-#endif
- /*
- * Make new vnode reference the umap_node.
- */
- error = umap_node_alloc(mp, targetvp, &aliasvp);
- if (error)
- return (error);
-
- /*
- * aliasvp is already VREF'd by getnewvnode()
- */
- }
-
- vrele(targetvp);
-
-#ifdef DEBUG
- vprint("umap_node_create: alias", aliasvp);
- vprint("umap_node_create: target", targetvp);
-#endif
-
- *newvpp = aliasvp;
- return (0);
-}
-
-#ifdef DIAGNOSTIC
-int umap_checkvp_barrier = 1;
-struct vnode *
-umap_checkvp(vp, fil, lno)
- struct vnode *vp;
- char *fil;
- int lno;
-{
- struct umap_node *a = VTOUMAP(vp);
-#if 0
- /*
- * Can't do this check because vop_reclaim runs
- * with funny vop vector.
- */
- if (vp->v_op != umap_vnodeop_p) {
- printf ("umap_checkvp: on non-umap-node\n");
- while (umap_checkvp_barrier) /*WAIT*/ ;
- panic("umap_checkvp");
- }
-#endif
- if (a->umap_lowervp == NULL) {
- /* Should never happen */
- int i; u_long *p;
- printf("vp = %p, ZERO ptr\n", (void *)vp);
- for (p = (u_long *) a, i = 0; i < 8; i++)
- printf(" %p", (void *)p[i]);
- printf("\n");
- /* wait for debugger */
- while (umap_checkvp_barrier) /*WAIT*/ ;
- panic("umap_checkvp");
- }
- if (a->umap_lowervp->v_usecount < 1) {
- int i; u_long *p;
- printf("vp = %p, unref'ed lowervp\n", (void *)vp);
- for (p = (u_long *) a, i = 0; i < 8; i++)
- printf(" %p", (void *)p[i]);
- printf("\n");
- /* wait for debugger */
- while (umap_checkvp_barrier) /*WAIT*/ ;
- panic ("umap with unref'ed lowervp");
- }
-#if 0
- printf("umap %x/%d -> %x/%d [%s, %d]\n",
- a->umap_vnode, a->umap_vnode->v_usecount,
- a->umap_lowervp, a->umap_lowervp->v_usecount,
- fil, lno);
-#endif
- return (a->umap_lowervp);
-}
-#endif /* DIAGNOSTIC */
-
-/* umap_mapids maps all of the ids in a credential, both user and group. */
-
-void
-umap_mapids(v_mount, credp)
- struct mount *v_mount;
- struct ucred *credp;
-{
- int i;
- uid_t uid;
- gid_t gid;
-
- if (credp == NOCRED)
- return;
-
- /* Find uid entry in map */
-
- uid = (uid_t) umap_findid(credp->cr_uid,
- MOUNTTOUMAPMOUNT(v_mount)->info_mapdata,
- MOUNTTOUMAPMOUNT(v_mount)->info_nentries);
-
- if (uid != -1)
- credp->cr_uid = uid;
- else
- credp->cr_uid = (uid_t) NOBODY;
-
-#ifdef notdef
- /* cr_gid is the same as cr_groups[0] in 4BSD */
-
- /* Find gid entry in map */
-
- gid = (gid_t) umap_findid(credp->cr_gid,
- MOUNTTOUMAPMOUNT(v_mount)->info_gmapdata,
- MOUNTTOUMAPMOUNT(v_mount)->info_gnentries);
-
- if (gid != -1)
- credp->cr_gid = gid;
- else
- credp->cr_gid = NULLGROUP;
-#endif
-
- /* Now we must map each of the set of groups in the cr_groups
- structure. */
-
- i = 0;
- while (credp->cr_groups[i] != 0) {
- gid = (gid_t) umap_findid(credp->cr_groups[i],
- MOUNTTOUMAPMOUNT(v_mount)->info_gmapdata,
- MOUNTTOUMAPMOUNT(v_mount)->info_gnentries);
-
- if (gid != -1)
- credp->cr_groups[i++] = gid;
- else
- credp->cr_groups[i++] = NULLGROUP;
- }
-}
diff --git a/sys/fs/umapfs/umap_vfsops.c b/sys/fs/umapfs/umap_vfsops.c
deleted file mode 100644
index 207bb9cb3e41..000000000000
--- a/sys/fs/umapfs/umap_vfsops.c
+++ /dev/null
@@ -1,466 +0,0 @@
-/*
- * Copyright (c) 1992, 1993, 1995
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * the UCLA Ficus project.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)umap_vfsops.c 8.8 (Berkeley) 5/14/95
- *
- * $FreeBSD$
- */
-
-/*
- * Umap Layer
- * (See mount_umap(8) for a description of this layer.)
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/proc.h>
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <sys/namei.h>
-#include <sys/malloc.h>
-#include <miscfs/umapfs/umap.h>
-#include <vm/vm_zone.h>
-
-static MALLOC_DEFINE(M_UMAPFSMNT, "UMAP mount", "UMAP mount structure");
-
-static int umapfs_fhtovp __P((struct mount *mp, struct fid *fidp,
- struct vnode **vpp));
-static int umapfs_checkexp __P((struct mount *mp, struct sockaddr *nam,
- int *extflagsp, struct ucred **credanonp));
-static int umapfs_mount __P((struct mount *mp, char *path, caddr_t data,
- struct nameidata *ndp, struct proc *p));
-static int umapfs_quotactl __P((struct mount *mp, int cmd, uid_t uid,
- caddr_t arg, struct proc *p));
-static int umapfs_root __P((struct mount *mp, struct vnode **vpp));
-static int umapfs_start __P((struct mount *mp, int flags, struct proc *p));
-static int umapfs_statfs __P((struct mount *mp, struct statfs *sbp,
- struct proc *p));
-static int umapfs_sync __P((struct mount *mp, int waitfor,
- struct ucred *cred, struct proc *p));
-static int umapfs_unmount __P((struct mount *mp, int mntflags,
- struct proc *p));
-static int umapfs_vget __P((struct mount *mp, ino_t ino,
- struct vnode **vpp));
-static int umapfs_vptofh __P((struct vnode *vp, struct fid *fhp));
-static int umapfs_extattrctl __P((struct mount *mp, int cmd,
- const char *attrname, caddr_t arg,
- struct proc *p));
-
-/*
- * Mount umap layer
- */
-static int
-umapfs_mount(mp, path, data, ndp, p)
- struct mount *mp;
- char *path;
- caddr_t data;
- struct nameidata *ndp;
- struct proc *p;
-{
- struct umap_args args;
- struct vnode *lowerrootvp, *vp;
- struct vnode *umapm_rootvp;
- struct umap_mount *amp;
- u_int size;
- int error;
-#ifdef DEBUG
- int i;
-#endif
-
- /*
- * Only for root
- */
- if ((error = suser(p)) != 0)
- return (error);
-
-#ifdef DEBUG
- printf("umapfs_mount(mp = %p)\n", (void *)mp);
-#endif
-
- /*
- * Update is a no-op
- */
- if (mp->mnt_flag & MNT_UPDATE) {
- return (EOPNOTSUPP);
- /* return (VFS_MOUNT(MOUNTTOUMAPMOUNT(mp)->umapm_vfs, path, data, ndp, p));*/
- }
-
- /*
- * Get argument
- */
- error = copyin(data, (caddr_t)&args, sizeof(struct umap_args));
- if (error)
- return (error);
-
- /*
- * Find lower node
- */
- NDINIT(ndp, LOOKUP, FOLLOW|WANTPARENT|LOCKLEAF,
- UIO_USERSPACE, args.target, p);
- error = namei(ndp);
- if (error)
- return (error);
- NDFREE(ndp, NDF_ONLY_PNBUF);
-
- /*
- * Sanity check on lower vnode
- */
- lowerrootvp = ndp->ni_vp;
-#ifdef DEBUG
- printf("vp = %p, check for VDIR...\n", (void *)lowerrootvp);
-#endif
- vrele(ndp->ni_dvp);
- ndp->ni_dvp = 0;
-
- if (lowerrootvp->v_type != VDIR) {
- vput(lowerrootvp);
- return (EINVAL);
- }
-
-#ifdef DEBUG
- printf("mp = %p\n", (void *)mp);
-#endif
-
- amp = (struct umap_mount *) malloc(sizeof(struct umap_mount),
- M_UMAPFSMNT, M_WAITOK); /* XXX */
-
- /*
- * Save reference to underlying FS
- */
- amp->umapm_vfs = lowerrootvp->v_mount;
-
- /*
- * Now copy in the number of entries and maps for umap mapping.
- */
- amp->info_nentries = args.nentries;
- amp->info_gnentries = args.gnentries;
- error = copyin(args.mapdata, (caddr_t)amp->info_mapdata,
- 2*sizeof(u_long)*args.nentries);
- if (error)
- return (error);
-
-#ifdef DEBUG
- printf("umap_mount:nentries %d\n",args.nentries);
- for (i = 0; i < args.nentries; i++)
- printf(" %lu maps to %lu\n", amp->info_mapdata[i][0],
- amp->info_mapdata[i][1]);
-#endif
-
- error = copyin(args.gmapdata, (caddr_t)amp->info_gmapdata,
- 2*sizeof(u_long)*args.gnentries);
- if (error)
- return (error);
-
-#ifdef DEBUG
- printf("umap_mount:gnentries %d\n",args.gnentries);
- for (i = 0; i < args.gnentries; i++)
- printf(" group %lu maps to %lu\n",
- amp->info_gmapdata[i][0],
- amp->info_gmapdata[i][1]);
-#endif
-
-
- /*
- * Save reference. Each mount also holds
- * a reference on the root vnode.
- */
- error = umap_node_create(mp, lowerrootvp, &vp);
- /*
- * Unlock the node (either the lower or the alias)
- */
- VOP_UNLOCK(vp, 0, p);
- /*
- * Make sure the node alias worked
- */
- if (error) {
- vrele(lowerrootvp);
- free(amp, M_UMAPFSMNT); /* XXX */
- return (error);
- }
-
- /*
- * Keep a held reference to the root vnode.
- * It is vrele'd in umapfs_unmount.
- */
- umapm_rootvp = vp;
- umapm_rootvp->v_flag |= VROOT;
- amp->umapm_rootvp = umapm_rootvp;
- if (UMAPVPTOLOWERVP(umapm_rootvp)->v_mount->mnt_flag & MNT_LOCAL)
- mp->mnt_flag |= MNT_LOCAL;
- mp->mnt_data = (qaddr_t) amp;
- vfs_getnewfsid(mp);
-
- (void) copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size);
- bzero(mp->mnt_stat.f_mntonname + size, MNAMELEN - size);
- (void) copyinstr(args.target, mp->mnt_stat.f_mntfromname, MNAMELEN - 1,
- &size);
- bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
- (void)umapfs_statfs(mp, &mp->mnt_stat, p);
-#ifdef DEBUG
- printf("umapfs_mount: lower %s, alias at %s\n",
- mp->mnt_stat.f_mntfromname, mp->mnt_stat.f_mntonname);
-#endif
- return (0);
-}
-
-/*
- * VFS start. Nothing needed here - the start routine
- * on the underlying filesystem will have been called
- * when that filesystem was mounted.
- */
-static int
-umapfs_start(mp, flags, p)
- struct mount *mp;
- int flags;
- struct proc *p;
-{
- return (0);
- /* return (VFS_START(MOUNTTOUMAPMOUNT(mp)->umapm_vfs, flags, p)); */
-}
-
-/*
- * Free reference to umap layer
- */
-static int
-umapfs_unmount(mp, mntflags, p)
- struct mount *mp;
- int mntflags;
- struct proc *p;
-{
- struct vnode *umapm_rootvp = MOUNTTOUMAPMOUNT(mp)->umapm_rootvp;
- int error;
- int flags = 0;
-
-#ifdef DEBUG
- printf("umapfs_unmount(mp = %p)\n", (void *)mp);
-#endif
-
- if (mntflags & MNT_FORCE)
- flags |= FORCECLOSE;
-
- /*
- * Clear out buffer cache. I don't think we
- * ever get anything cached at this level at the
- * moment, but who knows...
- */
-#ifdef notyet
- mntflushbuf(mp, 0);
- if (mntinvalbuf(mp, 1))
- return (EBUSY);
-#endif
- if (umapm_rootvp->v_usecount > 1)
- return (EBUSY);
- error = vflush(mp, umapm_rootvp, flags);
- if (error)
- return (error);
-
-#ifdef DEBUG
- vprint("alias root of lower", umapm_rootvp);
-#endif
- /*
- * Release reference on underlying root vnode
- */
- vrele(umapm_rootvp);
- /*
- * And blow it away for future re-use
- */
- vgone(umapm_rootvp);
- /*
- * Finally, throw away the umap_mount structure
- */
- free(mp->mnt_data, M_UMAPFSMNT); /* XXX */
- mp->mnt_data = 0;
- return (0);
-}
-
-static int
-umapfs_root(mp, vpp)
- struct mount *mp;
- struct vnode **vpp;
-{
- struct proc *p = curproc; /* XXX */
- struct vnode *vp;
-
-#ifdef DEBUG
- printf("umapfs_root(mp = %p, vp = %p->%p)\n",
- (void *)mp, (void *)MOUNTTOUMAPMOUNT(mp)->umapm_rootvp,
- (void *)UMAPVPTOLOWERVP(MOUNTTOUMAPMOUNT(mp)->umapm_rootvp));
-#endif
-
- /*
- * Return locked reference to root.
- */
- vp = MOUNTTOUMAPMOUNT(mp)->umapm_rootvp;
- VREF(vp);
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
- *vpp = vp;
- return (0);
-}
-
-static int
-umapfs_quotactl(mp, cmd, uid, arg, p)
- struct mount *mp;
- int cmd;
- uid_t uid;
- caddr_t arg;
- struct proc *p;
-{
- return (VFS_QUOTACTL(MOUNTTOUMAPMOUNT(mp)->umapm_vfs, cmd, uid, arg, p));
-}
-
-static int
-umapfs_statfs(mp, sbp, p)
- struct mount *mp;
- struct statfs *sbp;
- struct proc *p;
-{
- int error;
- struct statfs mstat;
-
-#ifdef DEBUG
- printf("umapfs_statfs(mp = %p, vp = %p->%p)\n",
- (void *)mp, (void *)MOUNTTOUMAPMOUNT(mp)->umapm_rootvp,
- (void *)UMAPVPTOLOWERVP(MOUNTTOUMAPMOUNT(mp)->umapm_rootvp));
-#endif
-
- bzero(&mstat, sizeof(mstat));
-
- error = VFS_STATFS(MOUNTTOUMAPMOUNT(mp)->umapm_vfs, &mstat, p);
- if (error)
- return (error);
-
- /* now copy across the "interesting" information and fake the rest */
- sbp->f_type = mstat.f_type;
- sbp->f_flags = mstat.f_flags;
- sbp->f_bsize = mstat.f_bsize;
- sbp->f_iosize = mstat.f_iosize;
- sbp->f_blocks = mstat.f_blocks;
- sbp->f_bfree = mstat.f_bfree;
- sbp->f_bavail = mstat.f_bavail;
- sbp->f_files = mstat.f_files;
- sbp->f_ffree = mstat.f_ffree;
- if (sbp != &mp->mnt_stat) {
- bcopy(&mp->mnt_stat.f_fsid, &sbp->f_fsid, sizeof(sbp->f_fsid));
- bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN);
- bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN);
- }
- return (0);
-}
-
-static int
-umapfs_sync(mp, waitfor, cred, p)
- struct mount *mp;
- int waitfor;
- struct ucred *cred;
- struct proc *p;
-{
- /*
- * XXX - Assumes no data cached at umap layer.
- */
- return (0);
-}
-
-static int
-umapfs_vget(mp, ino, vpp)
- struct mount *mp;
- ino_t ino;
- struct vnode **vpp;
-{
-
- return (VFS_VGET(MOUNTTOUMAPMOUNT(mp)->umapm_vfs, ino, vpp));
-}
-
-static int
-umapfs_fhtovp(mp, fidp, vpp)
- struct mount *mp;
- struct fid *fidp;
- struct vnode **vpp;
-{
-
- return (VFS_FHTOVP(MOUNTTOUMAPMOUNT(mp)->umapm_vfs, fidp, vpp));
-}
-
-static int
-umapfs_checkexp(mp, nam, exflagsp, credanonp)
- struct mount *mp;
- struct sockaddr *nam;
- int *exflagsp;
- struct ucred **credanonp;
-{
-
- return (VFS_CHECKEXP(MOUNTTOUMAPMOUNT(mp)->umapm_vfs, nam,
- exflagsp, credanonp));
-}
-
-static int
-umapfs_vptofh(vp, fhp)
- struct vnode *vp;
- struct fid *fhp;
-{
- return (VFS_VPTOFH(UMAPVPTOLOWERVP(vp), fhp));
-}
-
-static int
-umapfs_extattrctl(mp, cmd, attrname, arg, p)
- struct mount *mp;
- int cmd;
- const char *attrname;
- caddr_t arg;
- struct proc *p;
-{
- return (VFS_EXTATTRCTL(MOUNTTOUMAPMOUNT(mp)->umapm_vfs, cmd, attrname,
- arg, p));
-}
-
-
-static struct vfsops umap_vfsops = {
- umapfs_mount,
- umapfs_start,
- umapfs_unmount,
- umapfs_root,
- umapfs_quotactl,
- umapfs_statfs,
- umapfs_sync,
- umapfs_vget,
- umapfs_fhtovp,
- umapfs_checkexp,
- umapfs_vptofh,
- umapfs_init,
- vfs_stduninit,
- umapfs_extattrctl,
-};
-
-VFS_SET(umap_vfsops, umap, VFCF_LOOPBACK);
diff --git a/sys/fs/umapfs/umap_vnops.c b/sys/fs/umapfs/umap_vnops.c
deleted file mode 100644
index 02135b2409f1..000000000000
--- a/sys/fs/umapfs/umap_vnops.c
+++ /dev/null
@@ -1,518 +0,0 @@
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * the UCLA Ficus project.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)umap_vnops.c 8.6 (Berkeley) 5/22/95
- * $FreeBSD$
- */
-
-/*
- * Umap Layer
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/sysctl.h>
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <sys/namei.h>
-#include <sys/malloc.h>
-#include <sys/buf.h>
-#include <miscfs/umapfs/umap.h>
-#include <miscfs/nullfs/null.h>
-
-static int umap_bug_bypass = 0; /* for debugging: enables bypass printf'ing */
-SYSCTL_INT(_debug, OID_AUTO, umapfs_bug_bypass, CTLFLAG_RW,
- &umap_bug_bypass, 0, "");
-
-static int umap_bypass __P((struct vop_generic_args *ap));
-static int umap_getattr __P((struct vop_getattr_args *ap));
-static int umap_inactive __P((struct vop_inactive_args *ap));
-static int umap_lock __P((struct vop_lock_args *ap));
-static int umap_print __P((struct vop_print_args *ap));
-static int umap_reclaim __P((struct vop_reclaim_args *ap));
-static int umap_rename __P((struct vop_rename_args *ap));
-static int umap_unlock __P((struct vop_unlock_args *ap));
-
-/*
- * This is the 10-Apr-92 bypass routine.
- * See null_vnops.c:null_bypass for more details.
- */
-static int
-umap_bypass(ap)
- struct vop_generic_args /* {
- struct vnodeop_desc *a_desc;
- <other random data follows, presumably>
- } */ *ap;
-{
- struct ucred **credpp = 0, *credp = 0;
- struct ucred *savecredp = 0, *savecompcredp = 0;
- struct ucred *compcredp = 0;
- struct vnode **this_vp_p;
- int error;
- struct vnode *old_vps[VDESC_MAX_VPS];
- struct vnode *vp1 = 0;
- struct vnode **vps_p[VDESC_MAX_VPS];
- struct vnode ***vppp;
- struct vnodeop_desc *descp = ap->a_desc;
- int reles, i;
- struct componentname **compnamepp = 0;
-
- if (umap_bug_bypass)
- printf ("umap_bypass: %s\n", descp->vdesc_name);
-
-#ifdef DIAGNOSTIC
- /*
- * We require at least one vp.
- */
- if (descp->vdesc_vp_offsets == NULL ||
- descp->vdesc_vp_offsets[0] == VDESC_NO_OFFSET)
- panic ("umap_bypass: no vp's in map");
-#endif
-
- /*
- * Map the vnodes going in.
- * Later, we'll invoke the operation based on
- * the first mapped vnode's operation vector.
- */
- reles = descp->vdesc_flags;
- for (i = 0; i < VDESC_MAX_VPS; reles >>= 1, i++) {
- if (descp->vdesc_vp_offsets[i] == VDESC_NO_OFFSET)
- break; /* bail out at end of list */
- vps_p[i] = this_vp_p =
- VOPARG_OFFSETTO(struct vnode**, descp->vdesc_vp_offsets[i], ap);
-
- if (i == 0) {
- vp1 = *vps_p[0];
- }
-
- /*
- * We're not guaranteed that any but the first vnode
- * are of our type. Check for and don't map any
- * that aren't. (Must map first vp or vclean fails.)
- */
-
- if (i && (*this_vp_p)->v_op != umap_vnodeop_p) {
- old_vps[i] = NULL;
- } else {
- old_vps[i] = *this_vp_p;
- *(vps_p[i]) = UMAPVPTOLOWERVP(*this_vp_p);
- if (reles & 1)
- VREF(*this_vp_p);
- }
-
- }
-
- /*
- * Fix the credentials. (That's the purpose of this layer.)
- */
-
- if (descp->vdesc_cred_offset != VDESC_NO_OFFSET) {
-
- credpp = VOPARG_OFFSETTO(struct ucred**,
- descp->vdesc_cred_offset, ap);
-
- /* Save old values */
-
- savecredp = (*credpp);
- if (savecredp != NOCRED)
- (*credpp) = crdup(savecredp);
- credp = *credpp;
-
- if (umap_bug_bypass && credp->cr_uid != 0)
- printf("umap_bypass: user was %lu, group %lu\n",
- (u_long)credp->cr_uid, (u_long)credp->cr_gid);
-
- /* Map all ids in the credential structure. */
-
- umap_mapids(vp1->v_mount, credp);
-
- if (umap_bug_bypass && credp->cr_uid != 0)
- printf("umap_bypass: user now %lu, group %lu\n",
- (u_long)credp->cr_uid, (u_long)credp->cr_gid);
- }
-
- /* BSD often keeps a credential in the componentname structure
- * for speed. If there is one, it better get mapped, too.
- */
-
- if (descp->vdesc_componentname_offset != VDESC_NO_OFFSET) {
-
- compnamepp = VOPARG_OFFSETTO(struct componentname**,
- descp->vdesc_componentname_offset, ap);
-
- compcredp = (*compnamepp)->cn_cred;
- savecompcredp = compcredp;
- if (savecompcredp != NOCRED)
- (*compnamepp)->cn_cred = crdup(savecompcredp);
- compcredp = (*compnamepp)->cn_cred;
-
- if (umap_bug_bypass && compcredp->cr_uid != 0)
- printf(
- "umap_bypass: component credit user was %lu, group %lu\n",
- (u_long)compcredp->cr_uid,
- (u_long)compcredp->cr_gid);
-
- /* Map all ids in the credential structure. */
-
- umap_mapids(vp1->v_mount, compcredp);
-
- if (umap_bug_bypass && compcredp->cr_uid != 0)
- printf(
- "umap_bypass: component credit user now %lu, group %lu\n",
- (u_long)compcredp->cr_uid,
- (u_long)compcredp->cr_gid);
- }
-
- /*
- * Call the operation on the lower layer
- * with the modified argument structure.
- */
- error = VCALL(*(vps_p[0]), descp->vdesc_offset, ap);
-
- /*
- * Maintain the illusion of call-by-value
- * by restoring vnodes in the argument structure
- * to their original value.
- */
- reles = descp->vdesc_flags;
- for (i = 0; i < VDESC_MAX_VPS; reles >>= 1, i++) {
- if (descp->vdesc_vp_offsets[i] == VDESC_NO_OFFSET)
- break; /* bail out at end of list */
- if (old_vps[i]) {
- *(vps_p[i]) = old_vps[i];
- if (reles & 1)
- vrele(*(vps_p[i]));
- };
- };
-
- /*
- * Map the possible out-going vpp
- * (Assumes that the lower layer always returns
- * a VREF'ed vpp unless it gets an error.)
- */
- if (descp->vdesc_vpp_offset != VDESC_NO_OFFSET &&
- !(descp->vdesc_flags & VDESC_NOMAP_VPP) &&
- !error) {
- if (descp->vdesc_flags & VDESC_VPP_WILLRELE)
- goto out;
- vppp = VOPARG_OFFSETTO(struct vnode***,
- descp->vdesc_vpp_offset, ap);
- if (*vppp)
- error = umap_node_create(old_vps[0]->v_mount, **vppp, *vppp);
- };
-
- out:
- /*
- * Free duplicate cred structure and restore old one.
- */
- if (descp->vdesc_cred_offset != VDESC_NO_OFFSET) {
- if (umap_bug_bypass && credp && credp->cr_uid != 0)
- printf("umap_bypass: returning-user was %lu\n",
- (u_long)credp->cr_uid);
-
- if (savecredp != NOCRED) {
- crfree(credp);
- (*credpp) = savecredp;
- if (umap_bug_bypass && credpp && (*credpp)->cr_uid != 0)
- printf(
- "umap_bypass: returning-user now %lu\n\n",
- (u_long)(*credpp)->cr_uid);
- }
- }
-
- if (descp->vdesc_componentname_offset != VDESC_NO_OFFSET) {
- if (umap_bug_bypass && compcredp && compcredp->cr_uid != 0)
- printf(
- "umap_bypass: returning-component-user was %lu\n",
- (u_long)compcredp->cr_uid);
-
- if (savecompcredp != NOCRED) {
- crfree(compcredp);
- (*compnamepp)->cn_cred = savecompcredp;
- if (umap_bug_bypass && credpp && (*credpp)->cr_uid != 0)
- printf(
- "umap_bypass: returning-component-user now %lu\n",
- (u_long)compcredp->cr_uid);
- }
- }
-
- return (error);
-}
-
-
-/*
- * We handle getattr to change the fsid.
- */
-static int
-umap_getattr(ap)
- struct vop_getattr_args /* {
- struct vnode *a_vp;
- struct vattr *a_vap;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- short uid, gid;
- int error, tmpid, nentries, gnentries;
- u_long (*mapdata)[2], (*gmapdata)[2];
- struct vnode **vp1p;
- struct vnodeop_desc *descp = ap->a_desc;
-
- error = umap_bypass((struct vop_generic_args *)ap);
- if (error)
- return (error);
-
- /*
- * Umap needs to map the uid and gid returned by a stat
- * into the proper values for this site. This involves
- * finding the returned uid in the mapping information,
- * translating it into the uid on the other end,
- * and filling in the proper field in the vattr
- * structure pointed to by ap->a_vap. The group
- * is easier, since currently all groups will be
- * translate to the NULLGROUP.
- */
-
- /* Find entry in map */
-
- uid = ap->a_vap->va_uid;
- gid = ap->a_vap->va_gid;
- if (umap_bug_bypass)
- printf("umap_getattr: mapped uid = %d, mapped gid = %d\n", uid,
- gid);
-
- vp1p = VOPARG_OFFSETTO(struct vnode**, descp->vdesc_vp_offsets[0], ap);
- nentries = MOUNTTOUMAPMOUNT((*vp1p)->v_mount)->info_nentries;
- mapdata = (MOUNTTOUMAPMOUNT((*vp1p)->v_mount)->info_mapdata);
- gnentries = MOUNTTOUMAPMOUNT((*vp1p)->v_mount)->info_gnentries;
- gmapdata = (MOUNTTOUMAPMOUNT((*vp1p)->v_mount)->info_gmapdata);
-
- /* Reverse map the uid for the vnode. Since it's a reverse
- map, we can't use umap_mapids() to do it. */
-
- tmpid = umap_reverse_findid(uid, mapdata, nentries);
-
- if (tmpid != -1) {
-
- ap->a_vap->va_uid = (uid_t) tmpid;
- if (umap_bug_bypass)
- printf("umap_getattr: original uid = %d\n", uid);
- } else
- ap->a_vap->va_uid = (uid_t) NOBODY;
-
- /* Reverse map the gid for the vnode. */
-
- tmpid = umap_reverse_findid(gid, gmapdata, gnentries);
-
- if (tmpid != -1) {
-
- ap->a_vap->va_gid = (gid_t) tmpid;
- if (umap_bug_bypass)
- printf("umap_getattr: original gid = %d\n", gid);
- } else
- ap->a_vap->va_gid = (gid_t) NULLGROUP;
-
- return (0);
-}
-
-/*
- * We need to process our own vnode lock and then clear the
- * interlock flag as it applies only to our vnode, not the
- * vnodes below us on the stack.
- */
-static int
-umap_lock(ap)
- struct vop_lock_args /* {
- struct vnode *a_vp;
- int a_flags;
- struct proc *a_p;
- } */ *ap;
-{
-
- vop_nolock(ap);
- if ((ap->a_flags & LK_TYPE_MASK) == LK_DRAIN)
- return (0);
- ap->a_flags &= ~LK_INTERLOCK;
- return (null_bypass((struct vop_generic_args *)ap));
-}
-
-/*
- * We need to process our own vnode unlock and then clear the
- * interlock flag as it applies only to our vnode, not the
- * vnodes below us on the stack.
- */
-int
-umap_unlock(ap)
- struct vop_unlock_args /* {
- struct vnode *a_vp;
- int a_flags;
- struct proc *a_p;
- } */ *ap;
-{
- vop_nounlock(ap);
- ap->a_flags &= ~LK_INTERLOCK;
- return (null_bypass((struct vop_generic_args *)ap));
-}
-
-static int
-umap_inactive(ap)
- struct vop_inactive_args /* {
- struct vnode *a_vp;
- struct proc *a_p;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
- struct umap_node *xp = VTOUMAP(vp);
- struct vnode *lowervp = xp->umap_lowervp;
- /*
- * Do nothing (and _don't_ bypass).
- * Wait to vrele lowervp until reclaim,
- * so that until then our umap_node is in the
- * cache and reusable.
- *
- */
- VOP_INACTIVE(lowervp, ap->a_p);
- VOP_UNLOCK(ap->a_vp, 0, ap->a_p);
- return (0);
-}
-
-static int
-umap_reclaim(ap)
- struct vop_reclaim_args /* {
- struct vnode *a_vp;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
- struct umap_node *xp = VTOUMAP(vp);
- struct vnode *lowervp = xp->umap_lowervp;
-
- /* After this assignment, this node will not be re-used. */
- xp->umap_lowervp = NULL;
- LIST_REMOVE(xp, umap_hash);
- FREE(vp->v_data, M_TEMP);
- vp->v_data = NULL;
- vrele(lowervp);
- return (0);
-}
-
-static int
-umap_print(ap)
- struct vop_print_args /* {
- struct vnode *a_vp;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
- printf("\ttag VT_UMAPFS, vp=%p, lowervp=%p\n", vp, UMAPVPTOLOWERVP(vp));
- return (0);
-}
-
-static int
-umap_rename(ap)
- struct vop_rename_args /* {
- struct vnode *a_fdvp;
- struct vnode *a_fvp;
- struct componentname *a_fcnp;
- struct vnode *a_tdvp;
- struct vnode *a_tvp;
- struct componentname *a_tcnp;
- } */ *ap;
-{
- int error;
- struct componentname *compnamep;
- struct ucred *compcredp, *savecompcredp;
- struct vnode *vp;
-
- /*
- * Rename is irregular, having two componentname structures.
- * We need to map the cre in the second structure,
- * and then bypass takes care of the rest.
- */
-
- vp = ap->a_fdvp;
- compnamep = ap->a_tcnp;
- compcredp = compnamep->cn_cred;
-
- savecompcredp = compcredp;
- compcredp = compnamep->cn_cred = crdup(savecompcredp);
-
- if (umap_bug_bypass && compcredp->cr_uid != 0)
- printf(
- "umap_rename: rename component credit user was %lu, group %lu\n",
- (u_long)compcredp->cr_uid, (u_long)compcredp->cr_gid);
-
- /* Map all ids in the credential structure. */
-
- umap_mapids(vp->v_mount, compcredp);
-
- if (umap_bug_bypass && compcredp->cr_uid != 0)
- printf(
- "umap_rename: rename component credit user now %lu, group %lu\n",
- (u_long)compcredp->cr_uid, (u_long)compcredp->cr_gid);
-
- error = umap_bypass((struct vop_generic_args *)ap);
-
- /* Restore the additional mapped componentname cred structure. */
-
- crfree(compcredp);
- compnamep->cn_cred = savecompcredp;
-
- return error;
-}
-
-/*
- * Global vfs data structures
- */
-/*
- * XXX - strategy, bwrite are hand coded currently. They should
- * go away with a merged buffer/block cache.
- *
- */
-vop_t **umap_vnodeop_p;
-static struct vnodeopv_entry_desc umap_vnodeop_entries[] = {
- { &vop_default_desc, (vop_t *) umap_bypass },
- { &vop_getattr_desc, (vop_t *) umap_getattr },
- { &vop_inactive_desc, (vop_t *) umap_inactive },
- { &vop_lock_desc, (vop_t *) umap_lock },
- { &vop_print_desc, (vop_t *) umap_print },
- { &vop_reclaim_desc, (vop_t *) umap_reclaim },
- { &vop_rename_desc, (vop_t *) umap_rename },
- { &vop_unlock_desc, (vop_t *) umap_unlock },
- { NULL, NULL }
-};
-static struct vnodeopv_desc umap_vnodeop_opv_desc =
- { &umap_vnodeop_p, umap_vnodeop_entries };
-
-VNODEOP_SET(umap_vnodeop_opv_desc);
diff --git a/sys/fs/unionfs/union.h b/sys/fs/unionfs/union.h
deleted file mode 100644
index a720d411df87..000000000000
--- a/sys/fs/unionfs/union.h
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright (c) 1994 The Regents of the University of California.
- * Copyright (c) 1994 Jan-Simon Pendry.
- * All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)union.h 8.9 (Berkeley) 12/10/94
- * $FreeBSD$
- */
-
-struct union_args {
- char *target; /* Target of loopback */
- int mntflags; /* Options on the mount */
-};
-
-#define UNMNT_ABOVE 0x0001 /* Target appears below mount point */
-#define UNMNT_BELOW 0x0002 /* Target appears below mount point */
-#define UNMNT_REPLACE 0x0003 /* Target replaces mount point */
-#define UNMNT_OPMASK 0x0003
-
-struct union_mount {
- struct vnode *um_uppervp; /* UN_ULOCK holds locking state */
- struct vnode *um_lowervp; /* Left unlocked */
- struct ucred *um_cred; /* Credentials of user calling mount */
- int um_cmode; /* cmask from mount process */
- int um_op; /* Operation mode */
-};
-
-#ifdef _KERNEL
-
-#ifndef DIAGNOSTIC
-#define DIAGNOSTIC
-#endif
-
-/*
- * DEFDIRMODE is the mode bits used to create a shadow directory.
- */
-#define VRWXMODE (VREAD|VWRITE|VEXEC)
-#define VRWMODE (VREAD|VWRITE)
-#define UN_DIRMODE ((VRWXMODE)|(VRWXMODE>>3)|(VRWXMODE>>6))
-#define UN_FILEMODE ((VRWMODE)|(VRWMODE>>3)|(VRWMODE>>6))
-
-/*
- * A cache of vnode references (hangs off v_data)
- *
- * Placing un_lock as the first elements theoretically allows us to
- * use the vop_stdlock functions. However, we need to make sure of
- * certain side effects so we will still punch in our own code.
- */
-struct union_node {
- struct lock un_lock;
- LIST_ENTRY(union_node) un_cache; /* Hash chain */
- struct vnode *un_vnode; /* Back pointer */
- struct vnode *un_uppervp; /* overlaying object */
- struct vnode *un_lowervp; /* underlying object */
- struct vnode *un_dirvp; /* Parent dir of uppervp */
- struct vnode *un_pvp; /* Parent vnode */
- char *un_path; /* saved component name */
- int un_openl; /* # of opens on lowervp */
- int un_exclcnt; /* exclusive count */
- unsigned int un_flags;
- struct vnode **un_dircache; /* cached union stack */
- off_t un_uppersz; /* size of upper object */
- off_t un_lowersz; /* size of lower object */
-#ifdef DIAGNOSTIC
- pid_t un_pid;
-#endif
-};
-
-/*
- * XXX UN_ULOCK - indicates that the uppervp is locked
- *
- * UN_CACHED - node is in the union cache
- */
-
-/*#define UN_ULOCK 0x04*/ /* Upper node is locked */
-#define UN_CACHED 0x10 /* In union cache */
-
-/*
- * Hash table locking flags
- */
-
-#define UNVP_WANT 0x01
-#define UNVP_LOCKED 0x02
-
-extern int union_allocvp __P((struct vnode **, struct mount *,
- struct vnode *,
- struct vnode *,
- struct componentname *, struct vnode *,
- struct vnode *, int));
-extern int union_freevp __P((struct vnode *));
-extern struct vnode *union_dircache __P((struct vnode *, struct proc *));
-extern int union_copyup __P((struct union_node *, int, struct ucred *,
- struct proc *));
-extern int union_dowhiteout __P((struct union_node *, struct ucred *,
- struct proc *));
-extern int union_mkshadow __P((struct union_mount *, struct vnode *,
- struct componentname *, struct vnode **));
-extern int union_mkwhiteout __P((struct union_mount *, struct vnode *,
- struct componentname *, char *));
-extern int union_cn_close __P((struct vnode *, int, struct ucred *,
- struct proc *));
-extern void union_removed_upper __P((struct union_node *un));
-extern struct vnode *union_lowervp __P((struct vnode *));
-extern void union_newsize __P((struct vnode *, off_t, off_t));
-extern void union_vm_coherency __P((struct vnode *, struct uio *, int));
-
-extern int (*union_dircheckp) __P((struct proc *, struct vnode **,
- struct file *));
-
-#define MOUNTTOUNIONMOUNT(mp) ((struct union_mount *)((mp)->mnt_data))
-#define VTOUNION(vp) ((struct union_node *)(vp)->v_data)
-#define UNIONTOV(un) ((un)->un_vnode)
-#define LOWERVP(vp) (VTOUNION(vp)->un_lowervp)
-#define UPPERVP(vp) (VTOUNION(vp)->un_uppervp)
-#define OTHERVP(vp) (UPPERVP(vp) ? UPPERVP(vp) : LOWERVP(vp))
-
-#define UDEBUG(x) if (uniondebug) printf x
-#define UDEBUG_ENABLED 1
-
-extern vop_t **union_vnodeop_p;
-extern struct vfsops union_vfsops;
-extern int uniondebug;
-
-#endif /* _KERNEL */
diff --git a/sys/fs/unionfs/union_subr.c b/sys/fs/unionfs/union_subr.c
deleted file mode 100644
index 6b88befc18ed..000000000000
--- a/sys/fs/unionfs/union_subr.c
+++ /dev/null
@@ -1,1373 +0,0 @@
-/*
- * Copyright (c) 1994 Jan-Simon Pendry
- * Copyright (c) 1994
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)union_subr.c 8.20 (Berkeley) 5/20/95
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/vnode.h>
-#include <sys/namei.h>
-#include <sys/malloc.h>
-#include <sys/fcntl.h>
-#include <sys/file.h>
-#include <sys/filedesc.h>
-#include <sys/module.h>
-#include <sys/mount.h>
-#include <sys/stat.h>
-#include <vm/vm.h>
-#include <vm/vm_extern.h> /* for vnode_pager_setsize */
-#include <vm/vm_zone.h>
-#include <vm/vm_object.h> /* for vm cache coherency */
-#include <miscfs/union/union.h>
-
-#include <sys/proc.h>
-
-extern int union_init __P((void));
-
-/* must be power of two, otherwise change UNION_HASH() */
-#define NHASH 32
-
-/* unsigned int ... */
-#define UNION_HASH(u, l) \
- (((((uintptr_t) (u)) + ((uintptr_t) l)) >> 8) & (NHASH-1))
-
-static LIST_HEAD(unhead, union_node) unhead[NHASH];
-static int unvplock[NHASH];
-
-static void union_dircache_r __P((struct vnode *vp, struct vnode ***vppp,
- int *cntp));
-static int union_list_lock __P((int ix));
-static void union_list_unlock __P((int ix));
-static int union_relookup __P((struct union_mount *um, struct vnode *dvp,
- struct vnode **vpp,
- struct componentname *cnp,
- struct componentname *cn, char *path,
- int pathlen));
-static void union_updatevp __P((struct union_node *un,
- struct vnode *uppervp,
- struct vnode *lowervp));
-static void union_newlower __P((struct union_node *, struct vnode *));
-static void union_newupper __P((struct union_node *, struct vnode *));
-static int union_copyfile __P((struct vnode *, struct vnode *,
- struct ucred *, struct proc *));
-static int union_vn_create __P((struct vnode **, struct union_node *,
- struct proc *));
-static int union_vn_close __P((struct vnode *, int, struct ucred *,
- struct proc *));
-
-int
-union_init()
-{
- int i;
-
- for (i = 0; i < NHASH; i++)
- LIST_INIT(&unhead[i]);
- bzero((caddr_t)unvplock, sizeof(unvplock));
- return (0);
-}
-
-static int
-union_list_lock(ix)
- int ix;
-{
- if (unvplock[ix] & UNVP_LOCKED) {
- unvplock[ix] |= UNVP_WANT;
- (void) tsleep((caddr_t) &unvplock[ix], PINOD, "unllck", 0);
- return (1);
- }
- unvplock[ix] |= UNVP_LOCKED;
- return (0);
-}
-
-static void
-union_list_unlock(ix)
- int ix;
-{
- unvplock[ix] &= ~UNVP_LOCKED;
-
- if (unvplock[ix] & UNVP_WANT) {
- unvplock[ix] &= ~UNVP_WANT;
- wakeup((caddr_t) &unvplock[ix]);
- }
-}
-
-/*
- * union_updatevp:
- *
- * The uppervp, if not NULL, must be referenced and not locked by us
- * The lowervp, if not NULL, must be referenced.
- *
- * if uppervp and lowervp match pointers already installed, nothing
- * happens. The passed vp's (when matching) are not adjusted. This
- * routine may only be called by union_newupper() and union_newlower().
- */
-
-static void
-union_updatevp(un, uppervp, lowervp)
- struct union_node *un;
- struct vnode *uppervp;
- struct vnode *lowervp;
-{
- int ohash = UNION_HASH(un->un_uppervp, un->un_lowervp);
- int nhash = UNION_HASH(uppervp, lowervp);
- int docache = (lowervp != NULLVP || uppervp != NULLVP);
- int lhash, uhash;
-
- /*
- * Ensure locking is ordered from lower to higher
- * to avoid deadlocks.
- */
- if (nhash < ohash) {
- lhash = nhash;
- uhash = ohash;
- } else {
- lhash = ohash;
- uhash = nhash;
- }
-
- if (lhash != uhash) {
- while (union_list_lock(lhash))
- continue;
- }
-
- while (union_list_lock(uhash))
- continue;
-
- if (ohash != nhash || !docache) {
- if (un->un_flags & UN_CACHED) {
- un->un_flags &= ~UN_CACHED;
- LIST_REMOVE(un, un_cache);
- }
- }
-
- if (ohash != nhash)
- union_list_unlock(ohash);
-
- if (un->un_lowervp != lowervp) {
- if (un->un_lowervp) {
- vrele(un->un_lowervp);
- if (un->un_path) {
- free(un->un_path, M_TEMP);
- un->un_path = 0;
- }
- }
- un->un_lowervp = lowervp;
- un->un_lowersz = VNOVAL;
- }
-
- if (un->un_uppervp != uppervp) {
- if (un->un_uppervp)
- vrele(un->un_uppervp);
- un->un_uppervp = uppervp;
- un->un_uppersz = VNOVAL;
- }
-
- if (docache && (ohash != nhash)) {
- LIST_INSERT_HEAD(&unhead[nhash], un, un_cache);
- un->un_flags |= UN_CACHED;
- }
-
- union_list_unlock(nhash);
-}
-
-/*
- * Set a new lowervp. The passed lowervp must be referenced and will be
- * stored in the vp in a referenced state.
- */
-
-static void
-union_newlower(un, lowervp)
- struct union_node *un;
- struct vnode *lowervp;
-{
- union_updatevp(un, un->un_uppervp, lowervp);
-}
-
-/*
- * Set a new uppervp. The passed uppervp must be locked and will be
- * stored in the vp in a locked state. The caller should not unlock
- * uppervp.
- */
-
-static void
-union_newupper(un, uppervp)
- struct union_node *un;
- struct vnode *uppervp;
-{
- union_updatevp(un, uppervp, un->un_lowervp);
-}
-
-/*
- * Keep track of size changes in the underlying vnodes.
- * If the size changes, then callback to the vm layer
- * giving priority to the upper layer size.
- */
-void
-union_newsize(vp, uppersz, lowersz)
- struct vnode *vp;
- off_t uppersz, lowersz;
-{
- struct union_node *un;
- off_t sz;
-
- /* only interested in regular files */
- if (vp->v_type != VREG)
- return;
-
- un = VTOUNION(vp);
- sz = VNOVAL;
-
- if ((uppersz != VNOVAL) && (un->un_uppersz != uppersz)) {
- un->un_uppersz = uppersz;
- if (sz == VNOVAL)
- sz = un->un_uppersz;
- }
-
- if ((lowersz != VNOVAL) && (un->un_lowersz != lowersz)) {
- un->un_lowersz = lowersz;
- if (sz == VNOVAL)
- sz = un->un_lowersz;
- }
-
- if (sz != VNOVAL) {
- UDEBUG(("union: %s size now %ld\n",
- (uppersz != VNOVAL ? "upper" : "lower"), (long)sz));
- vnode_pager_setsize(vp, sz);
- }
-}
-
-/*
- * union_allocvp: allocate a union_node and associate it with a
- * parent union_node and one or two vnodes.
- *
- * vpp Holds the returned vnode locked and referenced if no
- * error occurs.
- *
- * mp Holds the mount point. mp may or may not be busied.
- * allocvp makes no changes to mp.
- *
- * dvp Holds the parent union_node to the one we wish to create.
- * XXX may only be used to traverse an uncopied lowervp-based
- * tree? XXX
- *
- * dvp may or may not be locked. allocvp makes no changes
- * to dvp.
- *
- * upperdvp Holds the parent vnode to uppervp, generally used along
- * with path component information to create a shadow of
- * lowervp when uppervp does not exist.
- *
- * upperdvp is referenced but unlocked on entry, and will be
- * dereferenced on return.
- *
- * uppervp Holds the new uppervp vnode to be stored in the
- * union_node we are allocating. uppervp is referenced but
- * not locked, and will be dereferenced on return.
- *
- * lowervp Holds the new lowervp vnode to be stored in the
- * union_node we are allocating. uppervp is referenced but
- * not locked, and will be dereferenced on return.
- *
- * cnp Holds path component information to be coupled with
- * lowervp and upperdvp to allow unionfs to create an uppervp
- * later on. Only used if lowervp is valid. The conents
- * of cnp is only valid for the duration of the call.
- *
- * docache Determine whether this node should be entered in the
- * cache or whether it should be destroyed as soon as possible.
- *
- * all union_nodes are maintained on a singly-linked
- * list. new nodes are only allocated when they cannot
- * be found on this list. entries on the list are
- * removed when the vfs reclaim entry is called.
- *
- * a single lock is kept for the entire list. this is
- * needed because the getnewvnode() function can block
- * waiting for a vnode to become free, in which case there
- * may be more than one process trying to get the same
- * vnode. this lock is only taken if we are going to
- * call getnewvnode, since the kernel itself is single-threaded.
- *
- * if an entry is found on the list, then call vget() to
- * take a reference. this is done because there may be
- * zero references to it and so it needs to removed from
- * the vnode free list.
- */
-
-int
-union_allocvp(vpp, mp, dvp, upperdvp, cnp, uppervp, lowervp, docache)
- struct vnode **vpp;
- struct mount *mp;
- struct vnode *dvp; /* parent union vnode */
- struct vnode *upperdvp; /* parent vnode of uppervp */
- struct componentname *cnp; /* may be null */
- struct vnode *uppervp; /* may be null */
- struct vnode *lowervp; /* may be null */
- int docache;
-{
- int error;
- struct union_node *un = 0;
- struct vnode *xlowervp = NULLVP;
- struct union_mount *um = MOUNTTOUNIONMOUNT(mp);
- struct proc *p = (cnp) ? cnp->cn_proc : curproc;
- int hash = 0;
- int vflag;
- int try;
-
- if (uppervp == NULLVP && lowervp == NULLVP)
- panic("union: unidentifiable allocation");
-
- if (uppervp && lowervp && (uppervp->v_type != lowervp->v_type)) {
- xlowervp = lowervp;
- lowervp = NULLVP;
- }
-
- /* detect the root vnode (and aliases) */
- vflag = 0;
- if ((uppervp == um->um_uppervp) &&
- ((lowervp == NULLVP) || lowervp == um->um_lowervp)) {
- if (lowervp == NULLVP) {
- lowervp = um->um_lowervp;
- if (lowervp != NULLVP)
- VREF(lowervp);
- }
- vflag = VROOT;
- }
-
-loop:
- if (!docache) {
- un = 0;
- } else for (try = 0; try < 3; try++) {
- switch (try) {
- case 0:
- if (lowervp == NULLVP)
- continue;
- hash = UNION_HASH(uppervp, lowervp);
- break;
-
- case 1:
- if (uppervp == NULLVP)
- continue;
- hash = UNION_HASH(uppervp, NULLVP);
- break;
-
- case 2:
- if (lowervp == NULLVP)
- continue;
- hash = UNION_HASH(NULLVP, lowervp);
- break;
- }
-
- while (union_list_lock(hash))
- continue;
-
- for (un = unhead[hash].lh_first; un != 0;
- un = un->un_cache.le_next) {
- if ((un->un_lowervp == lowervp ||
- un->un_lowervp == NULLVP) &&
- (un->un_uppervp == uppervp ||
- un->un_uppervp == NULLVP) &&
- (UNIONTOV(un)->v_mount == mp)) {
- if (vget(UNIONTOV(un), 0,
- cnp ? cnp->cn_proc : NULL)) {
- union_list_unlock(hash);
- goto loop;
- }
- break;
- }
- }
-
- union_list_unlock(hash);
-
- if (un)
- break;
- }
-
- if (un) {
- /*
- * Obtain a lock on the union_node. Everything is unlocked
- * except for dvp, so check that case. If they match, our
- * new un is already locked. Otherwise we have to lock our
- * new un.
- *
- * A potential deadlock situation occurs when we are holding
- * one lock while trying to get another. We must follow
- * strict ordering rules to avoid it. We try to locate dvp
- * by scanning up from un_vnode, since the most likely
- * scenario is un being under dvp.
- */
-
- if (dvp && un->un_vnode != dvp) {
- struct vnode *scan = un->un_vnode;
-
- do {
- scan = VTOUNION(scan)->un_pvp;
- } while (scan && scan->v_tag == VT_UNION && scan != dvp);
- if (scan != dvp) {
- /*
- * our new un is above dvp (we never saw dvp
- * while moving up the tree).
- */
- VREF(dvp);
- VOP_UNLOCK(dvp, 0, p);
- error = vn_lock(un->un_vnode, LK_EXCLUSIVE, p);
- vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, p);
- vrele(dvp);
- } else {
- /*
- * our new un is under dvp
- */
- error = vn_lock(un->un_vnode, LK_EXCLUSIVE, p);
- }
- } else if (dvp == NULLVP) {
- /*
- * dvp is NULL, we need to lock un.
- */
- error = vn_lock(un->un_vnode, LK_EXCLUSIVE, p);
- } else {
- /*
- * dvp == un->un_vnode, we are already locked.
- */
- error = 0;
- }
-
- if (error)
- goto loop;
-
- /*
- * At this point, the union_node is locked and referenced.
- *
- * uppervp is locked and referenced or NULL, lowervp is
- * referenced or NULL.
- */
- UDEBUG(("Modify existing un %p vn %p upper %p(refs %d) -> %p(refs %d)\n",
- un, un->un_vnode, un->un_uppervp,
- (un->un_uppervp ? un->un_uppervp->v_usecount : -99),
- uppervp,
- (uppervp ? uppervp->v_usecount : -99)
- ));
-
- if (uppervp != un->un_uppervp) {
- KASSERT(uppervp == NULL || uppervp->v_usecount > 0, ("union_allocvp: too few refs %d (at least 1 required) on uppervp", uppervp->v_usecount));
- union_newupper(un, uppervp);
- } else if (uppervp) {
- KASSERT(uppervp->v_usecount > 1, ("union_allocvp: too few refs %d (at least 2 required) on uppervp", uppervp->v_usecount));
- vrele(uppervp);
- }
-
- /*
- * Save information about the lower layer.
- * This needs to keep track of pathname
- * and directory information which union_vn_create
- * might need.
- */
- if (lowervp != un->un_lowervp) {
- union_newlower(un, lowervp);
- if (cnp && (lowervp != NULLVP)) {
- un->un_path = malloc(cnp->cn_namelen+1,
- M_TEMP, M_WAITOK);
- bcopy(cnp->cn_nameptr, un->un_path,
- cnp->cn_namelen);
- un->un_path[cnp->cn_namelen] = '\0';
- }
- } else if (lowervp) {
- vrele(lowervp);
- }
-
- /*
- * and upperdvp
- */
- if (upperdvp != un->un_dirvp) {
- if (un->un_dirvp)
- vrele(un->un_dirvp);
- un->un_dirvp = upperdvp;
- } else if (upperdvp) {
- vrele(upperdvp);
- }
-
- *vpp = UNIONTOV(un);
- return (0);
- }
-
- if (docache) {
- /*
- * otherwise lock the vp list while we call getnewvnode
- * since that can block.
- */
- hash = UNION_HASH(uppervp, lowervp);
-
- if (union_list_lock(hash))
- goto loop;
- }
-
- /*
- * Create new node rather then replace old node
- */
-
- error = getnewvnode(VT_UNION, mp, union_vnodeop_p, vpp);
- if (error) {
- /*
- * If an error occurs clear out vnodes.
- */
- if (lowervp)
- vrele(lowervp);
- if (uppervp)
- vrele(uppervp);
- if (upperdvp)
- vrele(upperdvp);
- *vpp = NULL;
- goto out;
- }
-
- MALLOC((*vpp)->v_data, void *, sizeof(struct union_node),
- M_TEMP, M_WAITOK);
-
- (*vpp)->v_flag |= vflag;
- if (uppervp)
- (*vpp)->v_type = uppervp->v_type;
- else
- (*vpp)->v_type = lowervp->v_type;
-
- un = VTOUNION(*vpp);
- bzero(un, sizeof(*un));
-
- lockinit(&un->un_lock, PVFS, "unlock", 0, 0);
- vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY, p);
-
- un->un_vnode = *vpp;
- un->un_uppervp = uppervp;
- un->un_uppersz = VNOVAL;
- un->un_lowervp = lowervp;
- un->un_lowersz = VNOVAL;
- un->un_dirvp = upperdvp;
- un->un_pvp = dvp; /* only parent dir in new allocation */
- if (dvp != NULLVP)
- VREF(dvp);
- un->un_dircache = 0;
- un->un_openl = 0;
-
- if (cnp && (lowervp != NULLVP)) {
- un->un_path = malloc(cnp->cn_namelen+1, M_TEMP, M_WAITOK);
- bcopy(cnp->cn_nameptr, un->un_path, cnp->cn_namelen);
- un->un_path[cnp->cn_namelen] = '\0';
- } else {
- un->un_path = 0;
- un->un_dirvp = NULL;
- }
-
- if (docache) {
- LIST_INSERT_HEAD(&unhead[hash], un, un_cache);
- un->un_flags |= UN_CACHED;
- }
-
-out:
- if (xlowervp)
- vrele(xlowervp);
-
- if (docache)
- union_list_unlock(hash);
-
- return (error);
-}
-
-int
-union_freevp(vp)
- struct vnode *vp;
-{
- struct union_node *un = VTOUNION(vp);
-
- if (un->un_flags & UN_CACHED) {
- un->un_flags &= ~UN_CACHED;
- LIST_REMOVE(un, un_cache);
- }
-
- if (un->un_pvp != NULLVP) {
- vrele(un->un_pvp);
- un->un_pvp = NULL;
- }
- if (un->un_uppervp != NULLVP) {
- vrele(un->un_uppervp);
- un->un_uppervp = NULL;
- }
- if (un->un_lowervp != NULLVP) {
- vrele(un->un_lowervp);
- un->un_lowervp = NULL;
- }
- if (un->un_dirvp != NULLVP) {
- vrele(un->un_dirvp);
- un->un_dirvp = NULL;
- }
- if (un->un_path) {
- free(un->un_path, M_TEMP);
- un->un_path = NULL;
- }
-
- FREE(vp->v_data, M_TEMP);
- vp->v_data = 0;
-
- return (0);
-}
-
-/*
- * copyfile. copy the vnode (fvp) to the vnode (tvp)
- * using a sequence of reads and writes. both (fvp)
- * and (tvp) are locked on entry and exit.
- *
- * fvp and tvp are both exclusive locked on call, but their refcount's
- * haven't been bumped at all.
- */
-static int
-union_copyfile(fvp, tvp, cred, p)
- struct vnode *fvp;
- struct vnode *tvp;
- struct ucred *cred;
- struct proc *p;
-{
- char *buf;
- struct uio uio;
- struct iovec iov;
- int error = 0;
-
- /*
- * strategy:
- * allocate a buffer of size MAXBSIZE.
- * loop doing reads and writes, keeping track
- * of the current uio offset.
- * give up at the first sign of trouble.
- */
-
- bzero(&uio, sizeof(uio));
-
- uio.uio_procp = p;
- uio.uio_segflg = UIO_SYSSPACE;
- uio.uio_offset = 0;
-
- VOP_LEASE(fvp, p, cred, LEASE_READ);
- VOP_LEASE(tvp, p, cred, LEASE_WRITE);
-
- buf = malloc(MAXBSIZE, M_TEMP, M_WAITOK);
-
- /* ugly loop follows... */
- do {
- off_t offset = uio.uio_offset;
- int count;
- int bufoffset;
-
- /*
- * Setup for big read
- */
- uio.uio_iov = &iov;
- uio.uio_iovcnt = 1;
- iov.iov_base = buf;
- iov.iov_len = MAXBSIZE;
- uio.uio_resid = iov.iov_len;
- uio.uio_rw = UIO_READ;
-
- if ((error = VOP_READ(fvp, &uio, 0, cred)) != 0)
- break;
-
- /*
- * Get bytes read, handle read eof case and setup for
- * write loop
- */
- if ((count = MAXBSIZE - uio.uio_resid) == 0)
- break;
- bufoffset = 0;
-
- /*
- * Write until an error occurs or our buffer has been
- * exhausted, then update the offset for the next read.
- */
- while (bufoffset < count) {
- uio.uio_iov = &iov;
- uio.uio_iovcnt = 1;
- iov.iov_base = buf + bufoffset;
- iov.iov_len = count - bufoffset;
- uio.uio_offset = offset + bufoffset;
- uio.uio_rw = UIO_WRITE;
- uio.uio_resid = iov.iov_len;
-
- if ((error = VOP_WRITE(tvp, &uio, 0, cred)) != 0)
- break;
- bufoffset += (count - bufoffset) - uio.uio_resid;
- }
- uio.uio_offset = offset + bufoffset;
- } while (error == 0);
-
- free(buf, M_TEMP);
- return (error);
-}
-
-/*
- *
- * un's vnode is assumed to be locked on entry and remains locked on exit.
- */
-
-int
-union_copyup(un, docopy, cred, p)
- struct union_node *un;
- int docopy;
- struct ucred *cred;
- struct proc *p;
-{
- int error;
- struct vnode *lvp, *uvp;
-
- /*
- * If the user does not have read permission, the vnode should not
- * be copied to upper layer.
- */
- vn_lock(un->un_lowervp, LK_EXCLUSIVE | LK_RETRY, p);
- error = VOP_ACCESS(un->un_lowervp, VREAD, cred, p);
- VOP_UNLOCK(un->un_lowervp, 0, p);
- if (error)
- return (error);
-
- error = union_vn_create(&uvp, un, p);
- if (error)
- return (error);
-
- lvp = un->un_lowervp;
-
- KASSERT(uvp->v_usecount > 0, ("copy: uvp refcount 0: %d", uvp->v_usecount));
- if (docopy) {
- /*
- * XX - should not ignore errors
- * from VOP_CLOSE
- */
- vn_lock(lvp, LK_EXCLUSIVE | LK_RETRY, p);
- error = VOP_OPEN(lvp, FREAD, cred, p);
- if (error == 0 && vn_canvmio(lvp) == TRUE)
- error = vfs_object_create(lvp, p, cred);
- if (error == 0) {
- error = union_copyfile(lvp, uvp, cred, p);
- VOP_UNLOCK(lvp, 0, p);
- (void) VOP_CLOSE(lvp, FREAD, cred, p);
- }
- if (error == 0)
- UDEBUG(("union: copied up %s\n", un->un_path));
-
- }
- VOP_UNLOCK(uvp, 0, p);
- union_newupper(un, uvp);
- KASSERT(uvp->v_usecount > 0, ("copy: uvp refcount 0: %d", uvp->v_usecount));
- union_vn_close(uvp, FWRITE, cred, p);
- KASSERT(uvp->v_usecount > 0, ("copy: uvp refcount 0: %d", uvp->v_usecount));
- /*
- * Subsequent IOs will go to the top layer, so
- * call close on the lower vnode and open on the
- * upper vnode to ensure that the filesystem keeps
- * its references counts right. This doesn't do
- * the right thing with (cred) and (FREAD) though.
- * Ignoring error returns is not right, either.
- */
- if (error == 0) {
- int i;
-
- for (i = 0; i < un->un_openl; i++) {
- (void) VOP_CLOSE(lvp, FREAD, cred, p);
- (void) VOP_OPEN(uvp, FREAD, cred, p);
- }
- if (un->un_openl) {
- if (vn_canvmio(uvp) == TRUE)
- error = vfs_object_create(uvp, p, cred);
- }
- un->un_openl = 0;
- }
-
- return (error);
-
-}
-
-/*
- * union_relookup:
- *
- * dvp should be locked on entry and will be locked on return. No
- * net change in the ref count will occur.
- *
- * If an error is returned, *vpp will be invalid, otherwise it
- * will hold a locked, referenced vnode. If *vpp == dvp then
- * remember that only one exclusive lock is held.
- */
-
-static int
-union_relookup(um, dvp, vpp, cnp, cn, path, pathlen)
- struct union_mount *um;
- struct vnode *dvp;
- struct vnode **vpp;
- struct componentname *cnp;
- struct componentname *cn;
- char *path;
- int pathlen;
-{
- int error;
-
- /*
- * A new componentname structure must be faked up because
- * there is no way to know where the upper level cnp came
- * from or what it is being used for. This must duplicate
- * some of the work done by NDINIT, some of the work done
- * by namei, some of the work done by lookup and some of
- * the work done by VOP_LOOKUP when given a CREATE flag.
- * Conclusion: Horrible.
- */
- cn->cn_namelen = pathlen;
- cn->cn_pnbuf = zalloc(namei_zone);
- bcopy(path, cn->cn_pnbuf, cn->cn_namelen);
- cn->cn_pnbuf[cn->cn_namelen] = '\0';
-
- cn->cn_nameiop = CREATE;
- cn->cn_flags = (LOCKPARENT|LOCKLEAF|HASBUF|SAVENAME|ISLASTCN);
- cn->cn_proc = cnp->cn_proc;
- if (um->um_op == UNMNT_ABOVE)
- cn->cn_cred = cnp->cn_cred;
- else
- cn->cn_cred = um->um_cred;
- cn->cn_nameptr = cn->cn_pnbuf;
- cn->cn_consume = cnp->cn_consume;
-
- VREF(dvp);
- VOP_UNLOCK(dvp, 0, cnp->cn_proc);
-
- /*
- * Pass dvp unlocked and referenced on call to relookup().
- *
- * If an error occurs, dvp will be returned unlocked and dereferenced.
- */
-
- if ((error = relookup(dvp, vpp, cn)) != 0) {
- vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, cnp->cn_proc);
- return(error);
- }
-
- /*
- * If no error occurs, dvp will be returned locked with the reference
- * left as before, and vpp will be returned referenced and locked.
- *
- * We want to return with dvp as it was passed to us, so we get
- * rid of our reference.
- */
- vrele(dvp);
- return (0);
-}
-
-/*
- * Create a shadow directory in the upper layer.
- * The new vnode is returned locked.
- *
- * (um) points to the union mount structure for access to the
- * the mounting process's credentials.
- * (dvp) is the directory in which to create the shadow directory,
- * it is locked (but not ref'd) on entry and return.
- * (cnp) is the componentname to be created.
- * (vpp) is the returned newly created shadow directory, which
- * is returned locked and ref'd
- */
-int
-union_mkshadow(um, dvp, cnp, vpp)
- struct union_mount *um;
- struct vnode *dvp;
- struct componentname *cnp;
- struct vnode **vpp;
-{
- int error;
- struct vattr va;
- struct proc *p = cnp->cn_proc;
- struct componentname cn;
-
- error = union_relookup(um, dvp, vpp, cnp, &cn,
- cnp->cn_nameptr, cnp->cn_namelen);
- if (error)
- return (error);
-
- if (*vpp) {
- if (cn.cn_flags & HASBUF) {
- zfree(namei_zone, cn.cn_pnbuf);
- cn.cn_flags &= ~HASBUF;
- }
- if (dvp == *vpp)
- vrele(*vpp);
- else
- vput(*vpp);
- *vpp = NULLVP;
- return (EEXIST);
- }
-
- /*
- * policy: when creating the shadow directory in the
- * upper layer, create it owned by the user who did
- * the mount, group from parent directory, and mode
- * 777 modified by umask (ie mostly identical to the
- * mkdir syscall). (jsp, kb)
- */
-
- VATTR_NULL(&va);
- va.va_type = VDIR;
- va.va_mode = um->um_cmode;
-
- /* VOP_LEASE: dvp is locked */
- VOP_LEASE(dvp, p, cn.cn_cred, LEASE_WRITE);
-
- error = VOP_MKDIR(dvp, vpp, &cn, &va);
- if (cn.cn_flags & HASBUF) {
- zfree(namei_zone, cn.cn_pnbuf);
- cn.cn_flags &= ~HASBUF;
- }
- /*vput(dvp);*/
- return (error);
-}
-
-/*
- * Create a whiteout entry in the upper layer.
- *
- * (um) points to the union mount structure for access to the
- * the mounting process's credentials.
- * (dvp) is the directory in which to create the whiteout.
- * it is locked on entry and return.
- * (cnp) is the componentname to be created.
- */
-int
-union_mkwhiteout(um, dvp, cnp, path)
- struct union_mount *um;
- struct vnode *dvp;
- struct componentname *cnp;
- char *path;
-{
- int error;
- struct proc *p = cnp->cn_proc;
- struct vnode *wvp;
- struct componentname cn;
-
- error = union_relookup(um, dvp, &wvp, cnp, &cn, path, strlen(path));
- if (error)
- return (error);
-
- if (wvp) {
- if (cn.cn_flags & HASBUF) {
- zfree(namei_zone, cn.cn_pnbuf);
- cn.cn_flags &= ~HASBUF;
- }
- if (wvp == dvp)
- vrele(wvp);
- else
- vput(wvp);
- return (EEXIST);
- }
-
- /* VOP_LEASE: dvp is locked */
- VOP_LEASE(dvp, p, p->p_ucred, LEASE_WRITE);
-
- error = VOP_WHITEOUT(dvp, &cn, CREATE);
- if (cn.cn_flags & HASBUF) {
- zfree(namei_zone, cn.cn_pnbuf);
- cn.cn_flags &= ~HASBUF;
- }
- return (error);
-}
-
-/*
- * union_vn_create: creates and opens a new shadow file
- * on the upper union layer. this function is similar
- * in spirit to calling vn_open but it avoids calling namei().
- * the problem with calling namei is that a) it locks too many
- * things, and b) it doesn't start at the "right" directory,
- * whereas relookup is told where to start.
- *
- * On entry, the vnode associated with un is locked. It remains locked
- * on return.
- *
- * If no error occurs, *vpp contains a locked referenced vnode for your
- * use. If an error occurs *vpp iis undefined.
- */
-static int
-union_vn_create(vpp, un, p)
- struct vnode **vpp;
- struct union_node *un;
- struct proc *p;
-{
- struct vnode *vp;
- struct ucred *cred = p->p_ucred;
- struct vattr vat;
- struct vattr *vap = &vat;
- int fmode = FFLAGS(O_WRONLY|O_CREAT|O_TRUNC|O_EXCL);
- int error;
- int cmode = UN_FILEMODE & ~p->p_fd->fd_cmask;
- struct componentname cn;
-
- *vpp = NULLVP;
-
- /*
- * Build a new componentname structure (for the same
- * reasons outlines in union_mkshadow).
- * The difference here is that the file is owned by
- * the current user, rather than by the person who
- * did the mount, since the current user needs to be
- * able to write the file (that's why it is being
- * copied in the first place).
- */
- cn.cn_namelen = strlen(un->un_path);
- cn.cn_pnbuf = zalloc(namei_zone);
- bcopy(un->un_path, cn.cn_pnbuf, cn.cn_namelen+1);
- cn.cn_nameiop = CREATE;
- cn.cn_flags = (LOCKPARENT|LOCKLEAF|HASBUF|SAVENAME|ISLASTCN);
- cn.cn_proc = p;
- cn.cn_cred = p->p_ucred;
- cn.cn_nameptr = cn.cn_pnbuf;
- cn.cn_consume = 0;
-
- /*
- * Pass dvp unlocked and referenced on call to relookup().
- *
- * If an error occurs, dvp will be returned unlocked and dereferenced.
- */
- VREF(un->un_dirvp);
- error = relookup(un->un_dirvp, &vp, &cn);
- if (error)
- return (error);
-
- /*
- * If no error occurs, dvp will be returned locked with the reference
- * left as before, and vpp will be returned referenced and locked.
- */
- if (vp) {
- vput(un->un_dirvp);
- if (cn.cn_flags & HASBUF) {
- zfree(namei_zone, cn.cn_pnbuf);
- cn.cn_flags &= ~HASBUF;
- }
- if (vp == un->un_dirvp)
- vrele(vp);
- else
- vput(vp);
- return (EEXIST);
- }
-
- /*
- * Good - there was no race to create the file
- * so go ahead and create it. The permissions
- * on the file will be 0666 modified by the
- * current user's umask. Access to the file, while
- * it is unioned, will require access to the top *and*
- * bottom files. Access when not unioned will simply
- * require access to the top-level file.
- * TODO: confirm choice of access permissions.
- */
- VATTR_NULL(vap);
- vap->va_type = VREG;
- vap->va_mode = cmode;
- VOP_LEASE(un->un_dirvp, p, cred, LEASE_WRITE);
- error = VOP_CREATE(un->un_dirvp, &vp, &cn, vap);
- if (cn.cn_flags & HASBUF) {
- zfree(namei_zone, cn.cn_pnbuf);
- cn.cn_flags &= ~HASBUF;
- }
- vput(un->un_dirvp);
- if (error)
- return (error);
-
- error = VOP_OPEN(vp, fmode, cred, p);
- if (error == 0 && vn_canvmio(vp) == TRUE)
- error = vfs_object_create(vp, p, cred);
- if (error) {
- vput(vp);
- return (error);
- }
- vp->v_writecount++;
- *vpp = vp;
- return (0);
-}
-
-static int
-union_vn_close(vp, fmode, cred, p)
- struct vnode *vp;
- int fmode;
- struct ucred *cred;
- struct proc *p;
-{
-
- if (fmode & FWRITE)
- --vp->v_writecount;
- return (VOP_CLOSE(vp, fmode, cred, p));
-}
-
-#if 0
-
-/*
- * union_removed_upper:
- *
- * called with union_node unlocked. XXX
- */
-
-void
-union_removed_upper(un)
- struct union_node *un;
-{
- struct proc *p = curproc; /* XXX */
- struct vnode **vpp;
-
- /*
- * Do not set the uppervp to NULLVP. If lowervp is NULLVP,
- * union node will have neither uppervp nor lowervp. We remove
- * the union node from cache, so that it will not be referrenced.
- */
- union_newupper(un, NULLVP);
- if (un->un_dircache != 0) {
- for (vpp = un->un_dircache; *vpp != NULLVP; vpp++)
- vrele(*vpp);
- free(un->un_dircache, M_TEMP);
- un->un_dircache = 0;
- }
-
- if (un->un_flags & UN_CACHED) {
- un->un_flags &= ~UN_CACHED;
- LIST_REMOVE(un, un_cache);
- }
-}
-
-#endif
-
-/*
- * determine whether a whiteout is needed
- * during a remove/rmdir operation.
- */
-int
-union_dowhiteout(un, cred, p)
- struct union_node *un;
- struct ucred *cred;
- struct proc *p;
-{
- struct vattr va;
-
- if (un->un_lowervp != NULLVP)
- return (1);
-
- if (VOP_GETATTR(un->un_uppervp, &va, cred, p) == 0 &&
- (va.va_flags & OPAQUE))
- return (1);
-
- return (0);
-}
-
-static void
-union_dircache_r(vp, vppp, cntp)
- struct vnode *vp;
- struct vnode ***vppp;
- int *cntp;
-{
- struct union_node *un;
-
- if (vp->v_op != union_vnodeop_p) {
- if (vppp) {
- VREF(vp);
- *(*vppp)++ = vp;
- if (--(*cntp) == 0)
- panic("union: dircache table too small");
- } else {
- (*cntp)++;
- }
-
- return;
- }
-
- un = VTOUNION(vp);
- if (un->un_uppervp != NULLVP)
- union_dircache_r(un->un_uppervp, vppp, cntp);
- if (un->un_lowervp != NULLVP)
- union_dircache_r(un->un_lowervp, vppp, cntp);
-}
-
-struct vnode *
-union_dircache(vp, p)
- struct vnode *vp;
- struct proc *p;
-{
- int cnt;
- struct vnode *nvp;
- struct vnode **vpp;
- struct vnode **dircache;
- struct union_node *un;
- int error;
-
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
- dircache = VTOUNION(vp)->un_dircache;
-
- nvp = NULLVP;
-
- if (dircache == NULL) {
- cnt = 0;
- union_dircache_r(vp, 0, &cnt);
- cnt++;
- dircache = malloc(cnt * sizeof(struct vnode *),
- M_TEMP, M_WAITOK);
- vpp = dircache;
- union_dircache_r(vp, &vpp, &cnt);
- *vpp = NULLVP;
- vpp = dircache + 1;
- } else {
- vpp = dircache;
- do {
- if (*vpp++ == VTOUNION(vp)->un_uppervp)
- break;
- } while (*vpp != NULLVP);
- }
-
- if (*vpp == NULLVP)
- goto out;
-
- /*vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY, p);*/
- UDEBUG(("ALLOCVP-3 %p ref %d\n", *vpp, (*vpp ? (*vpp)->v_usecount : -99)));
- VREF(*vpp);
- error = union_allocvp(&nvp, vp->v_mount, NULLVP, NULLVP, NULL, *vpp, NULLVP, 0);
- UDEBUG(("ALLOCVP-3B %p ref %d\n", nvp, (*vpp ? (*vpp)->v_usecount : -99)));
- if (error)
- goto out;
-
- VTOUNION(vp)->un_dircache = 0;
- un = VTOUNION(nvp);
- un->un_dircache = dircache;
-
-out:
- VOP_UNLOCK(vp, 0, p);
- return (nvp);
-}
-
-/*
- * Guarentee coherency with the VM cache by invalidating any clean VM pages
- * associated with this write and updating any dirty VM pages. Since our
- * vnode is locked, other processes will not be able to read the pages in
- * again until after our write completes.
- *
- * We also have to be coherent with reads, by flushing any pending dirty
- * pages prior to issuing the read.
- *
- * XXX this is somewhat of a hack at the moment. To support this properly
- * we would have to be able to run VOP_READ and VOP_WRITE through the VM
- * cache. Then we wouldn't need to worry about coherency.
- */
-
-void
-union_vm_coherency(struct vnode *vp, struct uio *uio, int cleanfls)
-{
- vm_object_t object;
- vm_pindex_t pstart;
- vm_pindex_t pend;
- int pgoff;
-
- if ((object = vp->v_object) == NULL)
- return;
-
- pgoff = uio->uio_offset & PAGE_MASK;
- pstart = uio->uio_offset / PAGE_SIZE;
- pend = pstart + (uio->uio_resid + pgoff + PAGE_MASK) / PAGE_SIZE;
-
- vm_object_page_clean(object, pstart, pend, OBJPC_SYNC);
- if (cleanfls)
- vm_object_page_remove(object, pstart, pend, TRUE);
-}
-
-/*
- * Module glue to remove #ifdef UNION from vfs_syscalls.c
- */
-static int
-union_dircheck(struct proc *p, struct vnode **vp, struct file *fp)
-{
- int error = 0;
-
- if ((*vp)->v_op == union_vnodeop_p) {
- struct vnode *lvp;
-
- lvp = union_dircache(*vp, p);
- if (lvp != NULLVP) {
- struct vattr va;
-
- /*
- * If the directory is opaque,
- * then don't show lower entries
- */
- error = VOP_GETATTR(*vp, &va, fp->f_cred, p);
- if (va.va_flags & OPAQUE) {
- vput(lvp);
- lvp = NULL;
- }
- }
-
- if (lvp != NULLVP) {
- error = VOP_OPEN(lvp, FREAD, fp->f_cred, p);
- if (error == 0 && vn_canvmio(lvp) == TRUE)
- error = vfs_object_create(lvp, p, fp->f_cred);
- if (error) {
- vput(lvp);
- return (error);
- }
- VOP_UNLOCK(lvp, 0, p);
- fp->f_data = (caddr_t) lvp;
- fp->f_offset = 0;
- error = vn_close(*vp, FREAD, fp->f_cred, p);
- if (error)
- return (error);
- *vp = lvp;
- return -1; /* goto unionread */
- }
- }
- return error;
-}
-
-static int
-union_modevent(module_t mod, int type, void *data)
-{
- switch (type) {
- case MOD_LOAD:
- union_dircheckp = union_dircheck;
- break;
- case MOD_UNLOAD:
- union_dircheckp = NULL;
- break;
- default:
- break;
- }
- return 0;
-}
-
-static moduledata_t union_mod = {
- "union_dircheck",
- union_modevent,
- NULL
-};
-
-DECLARE_MODULE(union_dircheck, union_mod, SI_SUB_VFS, SI_ORDER_ANY);
diff --git a/sys/fs/unionfs/union_vfsops.c b/sys/fs/unionfs/union_vfsops.c
deleted file mode 100644
index 8b58e55b17ca..000000000000
--- a/sys/fs/unionfs/union_vfsops.c
+++ /dev/null
@@ -1,509 +0,0 @@
-/*
- * Copyright (c) 1994, 1995 The Regents of the University of California.
- * Copyright (c) 1994, 1995 Jan-Simon Pendry.
- * All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)union_vfsops.c 8.20 (Berkeley) 5/20/95
- * $FreeBSD$
- */
-
-/*
- * Union Layer
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/proc.h>
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <sys/namei.h>
-#include <sys/malloc.h>
-#include <sys/filedesc.h>
-#include <miscfs/union/union.h>
-#include <vm/vm_zone.h>
-
-static MALLOC_DEFINE(M_UNIONFSMNT, "UNION mount", "UNION mount structure");
-
-extern int union_init __P((struct vfsconf *));
-static int union_mount __P((struct mount *mp, char *path, caddr_t data,
- struct nameidata *ndp, struct proc *p));
-static int union_root __P((struct mount *mp, struct vnode **vpp));
-static int union_statfs __P((struct mount *mp, struct statfs *sbp,
- struct proc *p));
-static int union_unmount __P((struct mount *mp, int mntflags,
- struct proc *p));
-
-/*
- * Mount union filesystem
- */
-static int
-union_mount(mp, path, data, ndp, p)
- struct mount *mp;
- char *path;
- caddr_t data;
- struct nameidata *ndp;
- struct proc *p;
-{
- int error = 0;
- struct union_args args;
- struct vnode *lowerrootvp = NULLVP;
- struct vnode *upperrootvp = NULLVP;
- struct union_mount *um = 0;
- struct ucred *cred = 0;
- char *cp = 0;
- int len;
- u_int size;
-
- UDEBUG(("union_mount(mp = %p)\n", (void *)mp));
-
- /*
- * Disable clustered write, otherwise system becomes unstable.
- */
- mp->mnt_flag |= MNT_NOCLUSTERW;
-
- /*
- * Update is a no-op
- */
- if (mp->mnt_flag & MNT_UPDATE) {
- /*
- * Need to provide.
- * 1. a way to convert between rdonly and rdwr mounts.
- * 2. support for nfs exports.
- */
- error = EOPNOTSUPP;
- goto bad;
- }
-
- /*
- * Get argument
- */
- error = copyin(data, (caddr_t)&args, sizeof(struct union_args));
- if (error)
- goto bad;
-
- /*
- * Obtain lower vnode. Vnode is stored in mp->mnt_vnodecovered.
- * We need to reference it but not lock it.
- */
-
- lowerrootvp = mp->mnt_vnodecovered;
- VREF(lowerrootvp);
-
-#if 0
- /*
- * Unlock lower node to avoid deadlock.
- */
- if (lowerrootvp->v_op == union_vnodeop_p)
- VOP_UNLOCK(lowerrootvp, 0, p);
-#endif
-
- /*
- * Obtain upper vnode by calling namei() on the path. The
- * upperrootvp will be turned referenced but not locked.
- */
- NDINIT(ndp, LOOKUP, FOLLOW|WANTPARENT,
- UIO_USERSPACE, args.target, p);
-
- error = namei(ndp);
-
-#if 0
- if (lowerrootvp->v_op == union_vnodeop_p)
- vn_lock(lowerrootvp, LK_EXCLUSIVE | LK_RETRY, p);
-#endif
- if (error)
- goto bad;
-
- NDFREE(ndp, NDF_ONLY_PNBUF);
- upperrootvp = ndp->ni_vp;
- vrele(ndp->ni_dvp);
- ndp->ni_dvp = NULL;
-
- UDEBUG(("mount_root UPPERVP %p locked = %d\n", upperrootvp,
- VOP_ISLOCKED(upperrootvp, NULL)));
-
- /*
- * Check multi union mount to avoid `lock myself again' panic.
- * Also require that it be a directory.
- */
- if (upperrootvp == VTOUNION(lowerrootvp)->un_uppervp) {
-#ifdef DIAGNOSTIC
- printf("union_mount: multi union mount?\n");
-#endif
- error = EDEADLK;
- goto bad;
- }
-
- if (upperrootvp->v_type != VDIR) {
- error = EINVAL;
- goto bad;
- }
-
- /*
- * Allocate our union_mount structure and populate the fields.
- * The vnode references are stored in the union_mount as held,
- * unlocked references. Depending on the _BELOW flag, the
- * filesystems are viewed in a different order. In effect this
- * is the same as providing a mount-under option to the mount
- * syscall.
- */
-
- um = (struct union_mount *) malloc(sizeof(struct union_mount),
- M_UNIONFSMNT, M_WAITOK);
-
- bzero(um, sizeof(struct union_mount));
-
- um->um_op = args.mntflags & UNMNT_OPMASK;
-
- switch (um->um_op) {
- case UNMNT_ABOVE:
- um->um_lowervp = lowerrootvp;
- um->um_uppervp = upperrootvp;
- upperrootvp = NULL;
- lowerrootvp = NULL;
- break;
-
- case UNMNT_BELOW:
- um->um_lowervp = upperrootvp;
- um->um_uppervp = lowerrootvp;
- upperrootvp = NULL;
- lowerrootvp = NULL;
- break;
-
- case UNMNT_REPLACE:
- vrele(lowerrootvp);
- lowerrootvp = NULL;
- um->um_uppervp = upperrootvp;
- um->um_lowervp = lowerrootvp;
- upperrootvp = NULL;
- break;
-
- default:
- error = EINVAL;
- goto bad;
- }
-
- /*
- * Unless the mount is readonly, ensure that the top layer
- * supports whiteout operations
- */
- if ((mp->mnt_flag & MNT_RDONLY) == 0) {
- error = VOP_WHITEOUT(um->um_uppervp, NULL, LOOKUP);
- if (error)
- goto bad;
- }
-
- um->um_cred = p->p_ucred;
- crhold(um->um_cred);
- um->um_cmode = UN_DIRMODE &~ p->p_fd->fd_cmask;
-
- /*
- * Depending on what you think the MNT_LOCAL flag might mean,
- * you may want the && to be || on the conditional below.
- * At the moment it has been defined that the filesystem is
- * only local if it is all local, ie the MNT_LOCAL flag implies
- * that the entire namespace is local. If you think the MNT_LOCAL
- * flag implies that some of the files might be stored locally
- * then you will want to change the conditional.
- */
- if (um->um_op == UNMNT_ABOVE) {
- if (((um->um_lowervp == NULLVP) ||
- (um->um_lowervp->v_mount->mnt_flag & MNT_LOCAL)) &&
- (um->um_uppervp->v_mount->mnt_flag & MNT_LOCAL))
- mp->mnt_flag |= MNT_LOCAL;
- }
-
- /*
- * Copy in the upper layer's RDONLY flag. This is for the benefit
- * of lookup() which explicitly checks the flag, rather than asking
- * the filesystem for its own opinion. This means, that an update
- * mount of the underlying filesystem to go from rdonly to rdwr
- * will leave the unioned view as read-only.
- */
- mp->mnt_flag |= (um->um_uppervp->v_mount->mnt_flag & MNT_RDONLY);
-
- mp->mnt_data = (qaddr_t) um;
- vfs_getnewfsid(mp);
-
- (void) copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size);
- bzero(mp->mnt_stat.f_mntonname + size, MNAMELEN - size);
-
- switch (um->um_op) {
- case UNMNT_ABOVE:
- cp = "<above>:";
- break;
- case UNMNT_BELOW:
- cp = "<below>:";
- break;
- case UNMNT_REPLACE:
- cp = "";
- break;
- }
- len = strlen(cp);
- bcopy(cp, mp->mnt_stat.f_mntfromname, len);
-
- cp = mp->mnt_stat.f_mntfromname + len;
- len = MNAMELEN - len;
-
- (void) copyinstr(args.target, cp, len - 1, &size);
- bzero(cp + size, len - size);
-
- (void)union_statfs(mp, &mp->mnt_stat, p);
-
- UDEBUG(("union_mount: from %s, on %s\n",
- mp->mnt_stat.f_mntfromname, mp->mnt_stat.f_mntonname));
- return (0);
-
-bad:
- if (um) {
- if (um->um_uppervp)
- vrele(um->um_uppervp);
- if (um->um_lowervp)
- vrele(um->um_lowervp);
- /* XXX other fields */
- free(um, M_UNIONFSMNT);
- }
- if (cred)
- crfree(cred);
- if (upperrootvp)
- vrele(upperrootvp);
- if (lowerrootvp)
- vrele(lowerrootvp);
- return (error);
-}
-
-/*
- * Free reference to union layer
- */
-static int
-union_unmount(mp, mntflags, p)
- struct mount *mp;
- int mntflags;
- struct proc *p;
-{
- struct union_mount *um = MOUNTTOUNIONMOUNT(mp);
- struct vnode *um_rootvp;
- int error;
- int freeing;
- int flags = 0;
-
- UDEBUG(("union_unmount(mp = %p)\n", (void *)mp));
-
- if (mntflags & MNT_FORCE)
- flags |= FORCECLOSE;
-
- if ((error = union_root(mp, &um_rootvp)) != 0)
- return (error);
-
- /*
- * Keep flushing vnodes from the mount list.
- * This is needed because of the un_pvp held
- * reference to the parent vnode.
- * If more vnodes have been freed on a given pass,
- * the try again. The loop will iterate at most
- * (d) times, where (d) is the maximum tree depth
- * in the filesystem.
- */
- for (freeing = 0; vflush(mp, um_rootvp, flags) != 0;) {
- struct vnode *vp;
- int n;
-
- /* count #vnodes held on mount list */
- for (n = 0, vp = mp->mnt_vnodelist.lh_first;
- vp != NULLVP;
- vp = vp->v_mntvnodes.le_next)
- n++;
-
- /* if this is unchanged then stop */
- if (n == freeing)
- break;
-
- /* otherwise try once more time */
- freeing = n;
- }
-
- /* At this point the root vnode should have a single reference */
- if (um_rootvp->v_usecount > 1) {
- vput(um_rootvp);
- return (EBUSY);
- }
-
-#ifdef DEBUG
- vprint("union root", um_rootvp);
-#endif
- /*
- * Discard references to upper and lower target vnodes.
- */
- if (um->um_lowervp)
- vrele(um->um_lowervp);
- vrele(um->um_uppervp);
- crfree(um->um_cred);
- /*
- * Release reference on underlying root vnode
- */
- vput(um_rootvp);
- /*
- * And blow it away for future re-use
- */
- vgone(um_rootvp);
- /*
- * Finally, throw away the union_mount structure
- */
- free(mp->mnt_data, M_UNIONFSMNT); /* XXX */
- mp->mnt_data = 0;
- return (0);
-}
-
-static int
-union_root(mp, vpp)
- struct mount *mp;
- struct vnode **vpp;
-{
- struct union_mount *um = MOUNTTOUNIONMOUNT(mp);
- int error;
-
- /*
- * Supply an unlocked reference to um_uppervp and to um_lowervp. It
- * is possible for um_uppervp to be locked without the associated
- * root union_node being locked. We let union_allocvp() deal with
- * it.
- */
- UDEBUG(("union_root UPPERVP %p locked = %d\n", um->um_uppervp,
- VOP_ISLOCKED(um->um_uppervp, NULL)));
-
- VREF(um->um_uppervp);
- if (um->um_lowervp)
- VREF(um->um_lowervp);
-
- error = union_allocvp(vpp, mp, NULLVP, NULLVP, NULL,
- um->um_uppervp, um->um_lowervp, 1);
- UDEBUG(("error %d\n", error));
- UDEBUG(("union_root2 UPPERVP %p locked = %d\n", um->um_uppervp,
- VOP_ISLOCKED(um->um_uppervp, NULL)));
-
- return (error);
-}
-
-static int
-union_statfs(mp, sbp, p)
- struct mount *mp;
- struct statfs *sbp;
- struct proc *p;
-{
- int error;
- struct union_mount *um = MOUNTTOUNIONMOUNT(mp);
- struct statfs mstat;
- int lbsize;
-
- UDEBUG(("union_statfs(mp = %p, lvp = %p, uvp = %p)\n",
- (void *)mp, (void *)um->um_lowervp, (void *)um->um_uppervp));
-
- bzero(&mstat, sizeof(mstat));
-
- if (um->um_lowervp) {
- error = VFS_STATFS(um->um_lowervp->v_mount, &mstat, p);
- if (error)
- return (error);
- }
-
- /* now copy across the "interesting" information and fake the rest */
-#if 0
- sbp->f_type = mstat.f_type;
- sbp->f_flags = mstat.f_flags;
- sbp->f_bsize = mstat.f_bsize;
- sbp->f_iosize = mstat.f_iosize;
-#endif
- lbsize = mstat.f_bsize;
- sbp->f_blocks = mstat.f_blocks;
- sbp->f_bfree = mstat.f_bfree;
- sbp->f_bavail = mstat.f_bavail;
- sbp->f_files = mstat.f_files;
- sbp->f_ffree = mstat.f_ffree;
-
- error = VFS_STATFS(um->um_uppervp->v_mount, &mstat, p);
- if (error)
- return (error);
-
- sbp->f_flags = mstat.f_flags;
- sbp->f_bsize = mstat.f_bsize;
- sbp->f_iosize = mstat.f_iosize;
-
- /*
- * if the lower and upper blocksizes differ, then frig the
- * block counts so that the sizes reported by df make some
- * kind of sense. none of this makes sense though.
- */
-
- if (mstat.f_bsize != lbsize)
- sbp->f_blocks = ((off_t) sbp->f_blocks * lbsize) / mstat.f_bsize;
-
- /*
- * The "total" fields count total resources in all layers,
- * the "free" fields count only those resources which are
- * free in the upper layer (since only the upper layer
- * is writeable).
- */
- sbp->f_blocks += mstat.f_blocks;
- sbp->f_bfree = mstat.f_bfree;
- sbp->f_bavail = mstat.f_bavail;
- sbp->f_files += mstat.f_files;
- sbp->f_ffree = mstat.f_ffree;
-
- if (sbp != &mp->mnt_stat) {
- sbp->f_type = mp->mnt_vfc->vfc_typenum;
- bcopy(&mp->mnt_stat.f_fsid, &sbp->f_fsid, sizeof(sbp->f_fsid));
- bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN);
- bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN);
- }
- return (0);
-}
-
-static struct vfsops union_vfsops = {
- union_mount,
- vfs_stdstart, /* underlying start already done */
- union_unmount,
- union_root,
- vfs_stdquotactl,
- union_statfs,
- vfs_stdsync, /* XXX assumes no cached data on union level */
- vfs_stdvget,
- vfs_stdfhtovp,
- vfs_stdcheckexp,
- vfs_stdvptofh,
- union_init,
- vfs_stduninit,
- vfs_stdextattrctl,
-};
-
-VFS_SET(union_vfsops, union, VFCF_LOOPBACK);
diff --git a/sys/fs/unionfs/union_vnops.c b/sys/fs/unionfs/union_vnops.c
deleted file mode 100644
index 03d41a01e0d8..000000000000
--- a/sys/fs/unionfs/union_vnops.c
+++ /dev/null
@@ -1,1981 +0,0 @@
-/*
- * Copyright (c) 1992, 1993, 1994, 1995 Jan-Simon Pendry.
- * Copyright (c) 1992, 1993, 1994, 1995
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)union_vnops.c 8.32 (Berkeley) 6/23/95
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/proc.h>
-#include <sys/fcntl.h>
-#include <sys/stat.h>
-#include <sys/kernel.h>
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <sys/namei.h>
-#include <sys/malloc.h>
-#include <sys/buf.h>
-#include <sys/lock.h>
-#include <sys/sysctl.h>
-#include <miscfs/union/union.h>
-
-#include <vm/vm.h>
-#include <vm/vnode_pager.h>
-
-#include <vm/vm_page.h>
-#include <vm/vm_object.h>
-
-int uniondebug = 0;
-
-#if UDEBUG_ENABLED
-SYSCTL_INT(_vfs, OID_AUTO, uniondebug, CTLFLAG_RW, &uniondebug, 0, "");
-#else
-SYSCTL_INT(_vfs, OID_AUTO, uniondebug, CTLFLAG_RD, &uniondebug, 0, "");
-#endif
-
-static int union_access __P((struct vop_access_args *ap));
-static int union_advlock __P((struct vop_advlock_args *ap));
-static int union_bmap __P((struct vop_bmap_args *ap));
-static int union_close __P((struct vop_close_args *ap));
-static int union_create __P((struct vop_create_args *ap));
-static int union_fsync __P((struct vop_fsync_args *ap));
-static int union_getattr __P((struct vop_getattr_args *ap));
-static int union_inactive __P((struct vop_inactive_args *ap));
-static int union_ioctl __P((struct vop_ioctl_args *ap));
-static int union_lease __P((struct vop_lease_args *ap));
-static int union_link __P((struct vop_link_args *ap));
-static int union_lock __P((struct vop_lock_args *ap));
-static int union_lookup __P((struct vop_lookup_args *ap));
-static int union_lookup1 __P((struct vnode *udvp, struct vnode **dvp,
- struct vnode **vpp,
- struct componentname *cnp));
-static int union_mkdir __P((struct vop_mkdir_args *ap));
-static int union_mknod __P((struct vop_mknod_args *ap));
-static int union_mmap __P((struct vop_mmap_args *ap));
-static int union_open __P((struct vop_open_args *ap));
-static int union_pathconf __P((struct vop_pathconf_args *ap));
-static int union_print __P((struct vop_print_args *ap));
-static int union_read __P((struct vop_read_args *ap));
-static int union_readdir __P((struct vop_readdir_args *ap));
-static int union_readlink __P((struct vop_readlink_args *ap));
-static int union_reclaim __P((struct vop_reclaim_args *ap));
-static int union_remove __P((struct vop_remove_args *ap));
-static int union_rename __P((struct vop_rename_args *ap));
-static int union_revoke __P((struct vop_revoke_args *ap));
-static int union_rmdir __P((struct vop_rmdir_args *ap));
-static int union_poll __P((struct vop_poll_args *ap));
-static int union_setattr __P((struct vop_setattr_args *ap));
-static int union_strategy __P((struct vop_strategy_args *ap));
-static int union_getpages __P((struct vop_getpages_args *ap));
-static int union_putpages __P((struct vop_putpages_args *ap));
-static int union_symlink __P((struct vop_symlink_args *ap));
-static int union_unlock __P((struct vop_unlock_args *ap));
-static int union_whiteout __P((struct vop_whiteout_args *ap));
-static int union_write __P((struct vop_read_args *ap));
-
-static __inline
-struct vnode *
-union_lock_upper(struct union_node *un, struct proc *p)
-{
- struct vnode *uppervp;
-
- if ((uppervp = un->un_uppervp) != NULL) {
- VREF(uppervp);
- vn_lock(uppervp, LK_EXCLUSIVE | LK_CANRECURSE | LK_RETRY, p);
- }
- KASSERT((uppervp == NULL || uppervp->v_usecount > 0), ("uppervp usecount is 0"));
- return(uppervp);
-}
-
-static __inline
-void
-union_unlock_upper(struct vnode *uppervp, struct proc *p)
-{
- vput(uppervp);
-}
-
-static __inline
-struct vnode *
-union_lock_other(struct union_node *un, struct proc *p)
-{
- struct vnode *vp;
-
- if (un->un_uppervp != NULL) {
- vp = union_lock_upper(un, p);
- } else if ((vp = un->un_lowervp) != NULL) {
- VREF(vp);
- vn_lock(vp, LK_EXCLUSIVE | LK_CANRECURSE | LK_RETRY, p);
- }
- return(vp);
-}
-
-static __inline
-void
-union_unlock_other(struct vnode *vp, struct proc *p)
-{
- vput(vp);
-}
-
-/*
- * union_lookup:
- *
- * udvp must be exclusively locked on call and will remain
- * exclusively locked on return. This is the mount point
- * for out filesystem.
- *
- * dvp Our base directory, locked and referenced.
- * The passed dvp will be dereferenced and unlocked on return
- * and a new dvp will be returned which is locked and
- * referenced in the same variable.
- *
- * vpp is filled in with the result if no error occured,
- * locked and ref'd.
- *
- * If an error is returned, *vpp is set to NULLVP. If no
- * error occurs, *vpp is returned with a reference and an
- * exclusive lock.
- */
-
-static int
-union_lookup1(udvp, pdvp, vpp, cnp)
- struct vnode *udvp;
- struct vnode **pdvp;
- struct vnode **vpp;
- struct componentname *cnp;
-{
- int error;
- struct proc *p = cnp->cn_proc;
- struct vnode *dvp = *pdvp;
- struct vnode *tdvp;
- struct mount *mp;
-
- /*
- * If stepping up the directory tree, check for going
- * back across the mount point, in which case do what
- * lookup would do by stepping back down the mount
- * hierarchy.
- */
- if (cnp->cn_flags & ISDOTDOT) {
- while ((dvp != udvp) && (dvp->v_flag & VROOT)) {
- /*
- * Don't do the NOCROSSMOUNT check
- * at this level. By definition,
- * union fs deals with namespaces, not
- * filesystems.
- */
- tdvp = dvp;
- dvp = dvp->v_mount->mnt_vnodecovered;
- VREF(dvp);
- vput(tdvp);
- vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, p);
- }
- }
-
- /*
- * Set return dvp to be the upperdvp 'parent directory.
- */
- *pdvp = dvp;
-
- /*
- * If the VOP_LOOKUP call generates an error, tdvp is invalid and no
- * changes will have been made to dvp, so we are set to return.
- */
-
- error = VOP_LOOKUP(dvp, &tdvp, cnp);
- if (error) {
- UDEBUG(("dvp %p error %d flags %lx\n", dvp, error, cnp->cn_flags));
- *vpp = NULL;
- return (error);
- }
-
- /*
- * The parent directory will have been unlocked, unless lookup
- * found the last component or if dvp == tdvp (tdvp must be locked).
- *
- * We want our dvp to remain locked and ref'd. We also want tdvp
- * to remain locked and ref'd.
- */
- UDEBUG(("parentdir %p result %p flag %lx\n", dvp, tdvp, cnp->cn_flags));
-
- if (dvp != tdvp && (cnp->cn_flags & ISLASTCN) == 0)
- vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, p);
-
- /*
- * Lastly check if the current node is a mount point in
- * which case walk up the mount hierarchy making sure not to
- * bump into the root of the mount tree (ie. dvp != udvp).
- *
- * We use dvp as a temporary variable here, it is no longer related
- * to the dvp above. However, we have to ensure that both *pdvp and
- * tdvp are locked on return.
- */
-
- dvp = tdvp;
- while (
- dvp != udvp &&
- (dvp->v_type == VDIR) &&
- (mp = dvp->v_mountedhere)
- ) {
- int relock_pdvp = 0;
-
- if (vfs_busy(mp, 0, 0, p))
- continue;
-
- if (dvp == *pdvp)
- relock_pdvp = 1;
- vput(dvp);
- dvp = NULL;
- error = VFS_ROOT(mp, &dvp);
-
- vfs_unbusy(mp, p);
-
- if (relock_pdvp)
- vn_lock(*pdvp, LK_EXCLUSIVE | LK_RETRY, p);
-
- if (error) {
- *vpp = NULL;
- return (error);
- }
- }
- *vpp = dvp;
- return (0);
-}
-
-static int
-union_lookup(ap)
- struct vop_lookup_args /* {
- struct vnodeop_desc *a_desc;
- struct vnode *a_dvp;
- struct vnode **a_vpp;
- struct componentname *a_cnp;
- } */ *ap;
-{
- int error;
- int uerror, lerror;
- struct vnode *uppervp, *lowervp;
- struct vnode *upperdvp, *lowerdvp;
- struct vnode *dvp = ap->a_dvp; /* starting dir */
- struct union_node *dun = VTOUNION(dvp); /* associated union node */
- struct componentname *cnp = ap->a_cnp;
- struct proc *p = cnp->cn_proc;
- int lockparent = cnp->cn_flags & LOCKPARENT;
- struct union_mount *um = MOUNTTOUNIONMOUNT(dvp->v_mount);
- struct ucred *saved_cred = NULL;
- int iswhiteout;
- struct vattr va;
-
- *ap->a_vpp = NULLVP;
-
- /*
- * Disallow write attemps to the filesystem mounted read-only.
- */
- if ((cnp->cn_flags & ISLASTCN) &&
- (dvp->v_mount->mnt_flag & MNT_RDONLY) &&
- (cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME)) {
- return (EROFS);
- }
-
- /*
- * For any lookup's we do, always return with the parent locked
- */
- cnp->cn_flags |= LOCKPARENT;
-
- lowerdvp = dun->un_lowervp;
- uppervp = NULLVP;
- lowervp = NULLVP;
- iswhiteout = 0;
-
- uerror = ENOENT;
- lerror = ENOENT;
-
- /*
- * Get a private lock on uppervp and a reference, effectively
- * taking it out of the union_node's control.
- *
- * We must lock upperdvp while holding our lock on dvp
- * to avoid a deadlock.
- */
- upperdvp = union_lock_upper(dun, p);
-
- /*
- * do the lookup in the upper level.
- * if that level comsumes additional pathnames,
- * then assume that something special is going
- * on and just return that vnode.
- */
- if (upperdvp != NULLVP) {
- /*
- * We do not have to worry about the DOTDOT case, we've
- * already unlocked dvp.
- */
- UDEBUG(("A %p\n", upperdvp));
-
- /*
- * Do the lookup. We must supply a locked and referenced
- * upperdvp to the function and will get a new locked and
- * referenced upperdvp back with the old having been
- * dereferenced.
- *
- * If an error is returned, uppervp will be NULLVP. If no
- * error occurs, uppervp will be the locked and referenced
- * return vnode or possibly NULL, depending on what is being
- * requested. It is possible that the returned uppervp
- * will be the same as upperdvp.
- */
- uerror = union_lookup1(um->um_uppervp, &upperdvp, &uppervp, cnp);
- UDEBUG((
- "uerror %d upperdvp %p %d/%d, uppervp %p ref=%d/lck=%d\n",
- uerror,
- upperdvp,
- upperdvp->v_usecount,
- VOP_ISLOCKED(upperdvp, NULL),
- uppervp,
- (uppervp ? uppervp->v_usecount : -99),
- (uppervp ? VOP_ISLOCKED(uppervp, NULL) : -99)
- ));
-
- /*
- * Disallow write attemps to the filesystem mounted read-only.
- */
- if (uerror == EJUSTRETURN && (cnp->cn_flags & ISLASTCN) &&
- (dvp->v_mount->mnt_flag & MNT_RDONLY) &&
- (cnp->cn_nameiop == CREATE || cnp->cn_nameiop == RENAME)) {
- error = EROFS;
- goto out;
- }
-
- /*
- * Special case. If cn_consume != 0 skip out. The result
- * of the lookup is transfered to our return variable. If
- * an error occured we have to throw away the results.
- */
-
- if (cnp->cn_consume != 0) {
- if ((error = uerror) == 0) {
- *ap->a_vpp = uppervp;
- uppervp = NULL;
- }
- goto out;
- }
-
- /*
- * Calculate whiteout, fall through
- */
-
- if (uerror == ENOENT || uerror == EJUSTRETURN) {
- if (cnp->cn_flags & ISWHITEOUT) {
- iswhiteout = 1;
- } else if (lowerdvp != NULLVP) {
- int terror;
-
- terror = VOP_GETATTR(upperdvp, &va,
- cnp->cn_cred, cnp->cn_proc);
- if (terror == 0 && (va.va_flags & OPAQUE))
- iswhiteout = 1;
- }
- }
- }
-
- /*
- * in a similar way to the upper layer, do the lookup
- * in the lower layer. this time, if there is some
- * component magic going on, then vput whatever we got
- * back from the upper layer and return the lower vnode
- * instead.
- */
-
- if (lowerdvp != NULLVP && !iswhiteout) {
- int nameiop;
-
- UDEBUG(("B %p\n", lowerdvp));
-
- /*
- * Force only LOOKUPs on the lower node, since
- * we won't be making changes to it anyway.
- */
- nameiop = cnp->cn_nameiop;
- cnp->cn_nameiop = LOOKUP;
- if (um->um_op == UNMNT_BELOW) {
- saved_cred = cnp->cn_cred;
- cnp->cn_cred = um->um_cred;
- }
-
- /*
- * We shouldn't have to worry about locking interactions
- * between the lower layer and our union layer (w.r.t.
- * `..' processing) because we don't futz with lowervp
- * locks in the union-node instantiation code path.
- *
- * union_lookup1() requires lowervp to be locked on entry,
- * and it will be unlocked on return. The ref count will
- * not change. On return lowervp doesn't represent anything
- * to us so we NULL it out.
- */
- VREF(lowerdvp);
- vn_lock(lowerdvp, LK_EXCLUSIVE | LK_RETRY, p);
- lerror = union_lookup1(um->um_lowervp, &lowerdvp, &lowervp, cnp);
- if (lowerdvp == lowervp)
- vrele(lowerdvp);
- else
- vput(lowerdvp);
- lowerdvp = NULL; /* lowerdvp invalid after vput */
-
- if (um->um_op == UNMNT_BELOW)
- cnp->cn_cred = saved_cred;
- cnp->cn_nameiop = nameiop;
-
- if (cnp->cn_consume != 0 || lerror == EACCES) {
- if ((error = lerror) == 0) {
- *ap->a_vpp = lowervp;
- lowervp = NULL;
- }
- goto out;
- }
- } else {
- UDEBUG(("C %p\n", lowerdvp));
- if ((cnp->cn_flags & ISDOTDOT) && dun->un_pvp != NULLVP) {
- if ((lowervp = LOWERVP(dun->un_pvp)) != NULL) {
- VREF(lowervp);
- vn_lock(lowervp, LK_EXCLUSIVE | LK_RETRY, p);
- lerror = 0;
- }
- }
- }
-
- /*
- * Ok. Now we have uerror, uppervp, upperdvp, lerror, and lowervp.
- *
- * 1. If both layers returned an error, select the upper layer.
- *
- * 2. If the upper layer faile and the bottom layer succeeded,
- * two subcases occur:
- *
- * a. The bottom vnode is not a directory, in which case
- * just return a new union vnode referencing an
- * empty top layer and the existing bottom layer.
- *
- * b. The button vnode is a directory, in which case
- * create a new directory in the top layer and
- * and fall through to case 3.
- *
- * 3. If the top layer succeeded then return a new union
- * vnode referencing whatever the new top layer and
- * whatever the bottom layer returned.
- */
-
- /* case 1. */
- if ((uerror != 0) && (lerror != 0)) {
- error = uerror;
- goto out;
- }
-
- /* case 2. */
- if (uerror != 0 /* && (lerror == 0) */ ) {
- if (lowervp->v_type == VDIR) { /* case 2b. */
- KASSERT(uppervp == NULL, ("uppervp unexpectedly non-NULL"));
- /*
- * oops, uppervp has a problem, we may have to shadow.
- */
- uerror = union_mkshadow(um, upperdvp, cnp, &uppervp);
- if (uerror) {
- error = uerror;
- goto out;
- }
- }
- }
-
- /*
- * Must call union_allocvp with both the upper and lower vnodes
- * referenced and the upper vnode locked. ap->a_vpp is returned
- * referenced and locked. lowervp, uppervp, and upperdvp are
- * absorbed by union_allocvp() whether it succeeds or fails.
- *
- * upperdvp is the parent directory of uppervp which may be
- * different, depending on the path, from dvp->un_uppervp. That's
- * why it is a separate argument. Note that it must be unlocked.
- *
- * dvp must be locked on entry to the call and will be locked on
- * return.
- */
-
- if (uppervp && uppervp != upperdvp)
- VOP_UNLOCK(uppervp, 0, p);
- if (lowervp)
- VOP_UNLOCK(lowervp, 0, p);
- if (upperdvp)
- VOP_UNLOCK(upperdvp, 0, p);
-
- error = union_allocvp(ap->a_vpp, dvp->v_mount, dvp, upperdvp, cnp,
- uppervp, lowervp, 1);
-
- UDEBUG(("Create %p = %p %p refs=%d\n", *ap->a_vpp, uppervp, lowervp, (*ap->a_vpp) ? ((*ap->a_vpp)->v_usecount) : -99));
-
- uppervp = NULL;
- upperdvp = NULL;
- lowervp = NULL;
-
- /*
- * Termination Code
- *
- * - put away any extra junk laying around. Note that lowervp
- * (if not NULL) will never be the same as *ap->a_vp and
- * neither will uppervp, because when we set that state we
- * NULL-out lowervp or uppervp. On the otherhand, upperdvp
- * may match uppervp or *ap->a_vpp.
- *
- * - relock/unlock dvp if appropriate.
- */
-
-out:
- if (upperdvp) {
- if (upperdvp == uppervp || upperdvp == *ap->a_vpp)
- vrele(upperdvp);
- else
- vput(upperdvp);
- }
-
- if (uppervp)
- vput(uppervp);
-
- if (lowervp)
- vput(lowervp);
-
- /*
- * Restore LOCKPARENT state
- */
-
- if (!lockparent)
- cnp->cn_flags &= ~LOCKPARENT;
-
- UDEBUG(("Out %d vpp %p/%d lower %p upper %p\n", error, *ap->a_vpp,
- ((*ap->a_vpp) ? (*ap->a_vpp)->v_usecount : -99),
- lowervp, uppervp));
-
- /*
- * dvp lock state, determine whether to relock dvp. dvp is expected
- * to be locked on return if:
- *
- * - there was an error (except not EJUSTRETURN), or
- * - we hit the last component and lockparent is true
- *
- * dvp_is_locked is the current state of the dvp lock, not counting
- * the possibility that *ap->a_vpp == dvp (in which case it is locked
- * anyway). Note that *ap->a_vpp == dvp only if no error occured.
- */
-
- if (*ap->a_vpp != dvp) {
- if ((error == 0 || error == EJUSTRETURN) &&
- (!lockparent || (cnp->cn_flags & ISLASTCN) == 0)) {
- VOP_UNLOCK(dvp, 0, p);
- }
- }
-
- /*
- * Diagnostics
- */
-
-#ifdef DIAGNOSTIC
- if (cnp->cn_namelen == 1 &&
- cnp->cn_nameptr[0] == '.' &&
- *ap->a_vpp != dvp) {
- panic("union_lookup returning . (%p) not same as startdir (%p)", ap->a_vpp, dvp);
- }
-#endif
-
- return (error);
-}
-
-/*
- * union_create:
- *
- * a_dvp is locked on entry and remains locked on return. a_vpp is returned
- * locked if no error occurs, otherwise it is garbage.
- */
-
-static int
-union_create(ap)
- struct vop_create_args /* {
- struct vnode *a_dvp;
- struct vnode **a_vpp;
- struct componentname *a_cnp;
- struct vattr *a_vap;
- } */ *ap;
-{
- struct union_node *dun = VTOUNION(ap->a_dvp);
- struct componentname *cnp = ap->a_cnp;
- struct proc *p = cnp->cn_proc;
- struct vnode *dvp;
- int error = EROFS;
-
- if ((dvp = union_lock_upper(dun, p)) != NULL) {
- struct vnode *vp;
- struct mount *mp;
-
- error = VOP_CREATE(dvp, &vp, cnp, ap->a_vap);
- if (error == 0) {
- mp = ap->a_dvp->v_mount;
- VOP_UNLOCK(vp, 0, p);
- UDEBUG(("ALLOCVP-1 FROM %p REFS %d\n", vp, vp->v_usecount));
- error = union_allocvp(ap->a_vpp, mp, NULLVP, NULLVP,
- cnp, vp, NULLVP, 1);
- UDEBUG(("ALLOCVP-2B FROM %p REFS %d\n", *ap->a_vpp, vp->v_usecount));
- }
- union_unlock_upper(dvp, p);
- }
- return (error);
-}
-
-static int
-union_whiteout(ap)
- struct vop_whiteout_args /* {
- struct vnode *a_dvp;
- struct componentname *a_cnp;
- int a_flags;
- } */ *ap;
-{
- struct union_node *un = VTOUNION(ap->a_dvp);
- struct componentname *cnp = ap->a_cnp;
- struct vnode *uppervp;
- int error = EOPNOTSUPP;
-
- if ((uppervp = union_lock_upper(un, cnp->cn_proc)) != NULLVP) {
- error = VOP_WHITEOUT(un->un_uppervp, cnp, ap->a_flags);
- union_unlock_upper(uppervp, cnp->cn_proc);
- }
- return(error);
-}
-
-/*
- * union_mknod:
- *
- * a_dvp is locked on entry and should remain locked on return.
- * a_vpp is garbagre whether an error occurs or not.
- */
-
-static int
-union_mknod(ap)
- struct vop_mknod_args /* {
- struct vnode *a_dvp;
- struct vnode **a_vpp;
- struct componentname *a_cnp;
- struct vattr *a_vap;
- } */ *ap;
-{
- struct union_node *dun = VTOUNION(ap->a_dvp);
- struct componentname *cnp = ap->a_cnp;
- struct vnode *dvp;
- int error = EROFS;
-
- if ((dvp = union_lock_upper(dun, cnp->cn_proc)) != NULL) {
- error = VOP_MKNOD(dvp, ap->a_vpp, cnp, ap->a_vap);
- union_unlock_upper(dvp, cnp->cn_proc);
- }
- return (error);
-}
-
-/*
- * union_open:
- *
- * run open VOP. When opening the underlying vnode we have to mimic
- * vn_open. What we *really* need to do to avoid screwups if the
- * open semantics change is to call vn_open(). For example, ufs blows
- * up if you open a file but do not vmio it prior to writing.
- */
-
-static int
-union_open(ap)
- struct vop_open_args /* {
- struct vnodeop_desc *a_desc;
- struct vnode *a_vp;
- int a_mode;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- struct union_node *un = VTOUNION(ap->a_vp);
- struct vnode *tvp;
- int mode = ap->a_mode;
- struct ucred *cred = ap->a_cred;
- struct proc *p = ap->a_p;
- int error = 0;
- int tvpisupper = 1;
-
- /*
- * If there is an existing upper vp then simply open that.
- * The upper vp takes precedence over the lower vp. When opening
- * a lower vp for writing copy it to the uppervp and then open the
- * uppervp.
- *
- * At the end of this section tvp will be left locked.
- */
- if ((tvp = union_lock_upper(un, p)) == NULLVP) {
- /*
- * If the lower vnode is being opened for writing, then
- * copy the file contents to the upper vnode and open that,
- * otherwise can simply open the lower vnode.
- */
- tvp = un->un_lowervp;
- if ((ap->a_mode & FWRITE) && (tvp->v_type == VREG)) {
- int docopy = !(mode & O_TRUNC);
- error = union_copyup(un, docopy, cred, p);
- tvp = union_lock_upper(un, p);
- } else {
- un->un_openl++;
- VREF(tvp);
- vn_lock(tvp, LK_EXCLUSIVE | LK_RETRY, p);
- tvpisupper = 0;
- }
- }
-
- /*
- * We are holding the correct vnode, open it
- */
-
- if (error == 0)
- error = VOP_OPEN(tvp, mode, cred, p);
-
- /*
- * Absolutely necessary or UFS will blowup
- */
- if (error == 0 && vn_canvmio(tvp) == TRUE) {
- error = vfs_object_create(tvp, p, cred);
- }
-
- /*
- * Release any locks held
- */
- if (tvpisupper) {
- if (tvp)
- union_unlock_upper(tvp, p);
- } else {
- vput(tvp);
- }
- return (error);
-}
-
-/*
- * union_close:
- *
- * It is unclear whether a_vp is passed locked or unlocked. Whatever
- * the case we do not change it.
- */
-
-static int
-union_close(ap)
- struct vop_close_args /* {
- struct vnode *a_vp;
- int a_fflag;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- struct union_node *un = VTOUNION(ap->a_vp);
- struct vnode *vp;
-
- if ((vp = un->un_uppervp) == NULLVP) {
-#ifdef UNION_DIAGNOSTIC
- if (un->un_openl <= 0)
- panic("union: un_openl cnt");
-#endif
- --un->un_openl;
- vp = un->un_lowervp;
- }
- ap->a_vp = vp;
- return (VCALL(vp, VOFFSET(vop_close), ap));
-}
-
-/*
- * Check access permission on the union vnode.
- * The access check being enforced is to check
- * against both the underlying vnode, and any
- * copied vnode. This ensures that no additional
- * file permissions are given away simply because
- * the user caused an implicit file copy.
- */
-static int
-union_access(ap)
- struct vop_access_args /* {
- struct vnodeop_desc *a_desc;
- struct vnode *a_vp;
- int a_mode;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- struct union_node *un = VTOUNION(ap->a_vp);
- struct proc *p = ap->a_p;
- int error = EACCES;
- struct vnode *vp;
-
- /*
- * Disallow write attempts on filesystems mounted read-only.
- */
- if ((ap->a_mode & VWRITE) &&
- (ap->a_vp->v_mount->mnt_flag & MNT_RDONLY)) {
- switch (ap->a_vp->v_type) {
- case VREG:
- case VDIR:
- case VLNK:
- return (EROFS);
- default:
- break;
- }
- }
-
- if ((vp = union_lock_upper(un, p)) != NULLVP) {
- ap->a_vp = vp;
- error = VCALL(vp, VOFFSET(vop_access), ap);
- union_unlock_upper(vp, p);
- return(error);
- }
-
- if ((vp = un->un_lowervp) != NULLVP) {
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
- ap->a_vp = vp;
-
- /*
- * Remove VWRITE from a_mode if our mount point is RW, because
- * we want to allow writes and lowervp may be read-only.
- */
- if ((un->un_vnode->v_mount->mnt_flag & MNT_RDONLY) == 0)
- ap->a_mode &= ~VWRITE;
-
- error = VCALL(vp, VOFFSET(vop_access), ap);
- if (error == 0) {
- struct union_mount *um;
-
- um = MOUNTTOUNIONMOUNT(un->un_vnode->v_mount);
-
- if (um->um_op == UNMNT_BELOW) {
- ap->a_cred = um->um_cred;
- error = VCALL(vp, VOFFSET(vop_access), ap);
- }
- }
- VOP_UNLOCK(vp, 0, p);
- }
- return(error);
-}
-
-/*
- * We handle getattr only to change the fsid and
- * track object sizes
- *
- * It's not clear whether VOP_GETATTR is to be
- * called with the vnode locked or not. stat() calls
- * it with (vp) locked, and fstat calls it with
- * (vp) unlocked.
- *
- * Because of this we cannot use our normal locking functions
- * if we do not intend to lock the main a_vp node. At the moment
- * we are running without any specific locking at all, but beware
- * to any programmer that care must be taken if locking is added
- * to this function.
- */
-
-static int
-union_getattr(ap)
- struct vop_getattr_args /* {
- struct vnode *a_vp;
- struct vattr *a_vap;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- int error;
- struct union_node *un = VTOUNION(ap->a_vp);
- struct vnode *vp;
- struct vattr *vap;
- struct vattr va;
-
- /*
- * Some programs walk the filesystem hierarchy by counting
- * links to directories to avoid stat'ing all the time.
- * This means the link count on directories needs to be "correct".
- * The only way to do that is to call getattr on both layers
- * and fix up the link count. The link count will not necessarily
- * be accurate but will be large enough to defeat the tree walkers.
- */
-
- vap = ap->a_vap;
-
- if ((vp = un->un_uppervp) != NULLVP) {
- error = VOP_GETATTR(vp, vap, ap->a_cred, ap->a_p);
- if (error)
- return (error);
- /* XXX isn't this dangerouso without a lock? */
- union_newsize(ap->a_vp, vap->va_size, VNOVAL);
- }
-
- if (vp == NULLVP) {
- vp = un->un_lowervp;
- } else if (vp->v_type == VDIR && un->un_lowervp != NULLVP) {
- vp = un->un_lowervp;
- vap = &va;
- } else {
- vp = NULLVP;
- }
-
- if (vp != NULLVP) {
- error = VOP_GETATTR(vp, vap, ap->a_cred, ap->a_p);
- if (error)
- return (error);
- /* XXX isn't this dangerous without a lock? */
- union_newsize(ap->a_vp, VNOVAL, vap->va_size);
- }
-
- if ((vap != ap->a_vap) && (vap->va_type == VDIR))
- ap->a_vap->va_nlink += vap->va_nlink;
- return (0);
-}
-
-static int
-union_setattr(ap)
- struct vop_setattr_args /* {
- struct vnode *a_vp;
- struct vattr *a_vap;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- struct union_node *un = VTOUNION(ap->a_vp);
- struct proc *p = ap->a_p;
- struct vattr *vap = ap->a_vap;
- struct vnode *uppervp;
- int error;
-
- /*
- * Disallow write attempts on filesystems mounted read-only.
- */
- if ((ap->a_vp->v_mount->mnt_flag & MNT_RDONLY) &&
- (vap->va_flags != VNOVAL || vap->va_uid != (uid_t)VNOVAL ||
- vap->va_gid != (gid_t)VNOVAL || vap->va_atime.tv_sec != VNOVAL ||
- vap->va_mtime.tv_sec != VNOVAL ||
- vap->va_mode != (mode_t)VNOVAL)) {
- return (EROFS);
- }
-
- /*
- * Handle case of truncating lower object to zero size,
- * by creating a zero length upper object. This is to
- * handle the case of open with O_TRUNC and O_CREAT.
- */
- if (un->un_uppervp == NULLVP && (un->un_lowervp->v_type == VREG)) {
- error = union_copyup(un, (ap->a_vap->va_size != 0),
- ap->a_cred, ap->a_p);
- if (error)
- return (error);
- }
-
- /*
- * Try to set attributes in upper layer,
- * otherwise return read-only filesystem error.
- */
- error = EROFS;
- if ((uppervp = union_lock_upper(un, p)) != NULLVP) {
- error = VOP_SETATTR(un->un_uppervp, ap->a_vap,
- ap->a_cred, ap->a_p);
- if ((error == 0) && (ap->a_vap->va_size != VNOVAL))
- union_newsize(ap->a_vp, ap->a_vap->va_size, VNOVAL);
- union_unlock_upper(uppervp, p);
- }
- return (error);
-}
-
-/*
- * union_getpages:
- */
-
-static int
-union_getpages(struct vop_getpages_args *ap)
-{
- int r;
-
- r = vnode_pager_generic_getpages(ap->a_vp, ap->a_m,
- ap->a_count, ap->a_reqpage);
- return(r);
-}
-
-/*
- * union_putpages:
- */
-
-static int
-union_putpages(struct vop_putpages_args *ap)
-{
- int r;
-
- r = vnode_pager_generic_putpages(ap->a_vp, ap->a_m, ap->a_count,
- ap->a_sync, ap->a_rtvals);
- return(r);
-}
-
-static int
-union_read(ap)
- struct vop_read_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- int a_ioflag;
- struct ucred *a_cred;
- } */ *ap;
-{
- struct union_node *un = VTOUNION(ap->a_vp);
- struct proc *p = ap->a_uio->uio_procp;
- struct vnode *uvp;
- int error;
-
- uvp = union_lock_other(un, p);
- KASSERT(uvp != NULL, ("union_read: backing vnode missing!"));
-
- if (ap->a_vp->v_flag & VOBJBUF)
- union_vm_coherency(ap->a_vp, ap->a_uio, 0);
-
- error = VOP_READ(uvp, ap->a_uio, ap->a_ioflag, ap->a_cred);
- union_unlock_other(uvp, p);
-
- /*
- * XXX
- * perhaps the size of the underlying object has changed under
- * our feet. take advantage of the offset information present
- * in the uio structure.
- */
- if (error == 0) {
- struct union_node *un = VTOUNION(ap->a_vp);
- off_t cur = ap->a_uio->uio_offset;
-
- if (uvp == un->un_uppervp) {
- if (cur > un->un_uppersz)
- union_newsize(ap->a_vp, cur, VNOVAL);
- } else {
- if (cur > un->un_lowersz)
- union_newsize(ap->a_vp, VNOVAL, cur);
- }
- }
- return (error);
-}
-
-static int
-union_write(ap)
- struct vop_read_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- int a_ioflag;
- struct ucred *a_cred;
- } */ *ap;
-{
- struct union_node *un = VTOUNION(ap->a_vp);
- struct proc *p = ap->a_uio->uio_procp;
- struct vnode *uppervp;
- int error;
-
- if ((uppervp = union_lock_upper(un, p)) == NULLVP)
- panic("union: missing upper layer in write");
-
- /*
- * Since our VM pages are associated with our vnode rather then
- * the real vnode, and since we do not run our reads and writes
- * through our own VM cache, we have a VM/VFS coherency problem.
- * We solve them by invalidating or flushing the associated VM
- * pages prior to allowing a normal read or write to occur.
- *
- * VM-backed writes (UIO_NOCOPY) have to be converted to normal
- * writes because we are not cache-coherent. Normal writes need
- * to be made coherent with our VM-backing store, which we do by
- * first flushing any dirty VM pages associated with the write
- * range, and then destroying any clean VM pages associated with
- * the write range.
- */
-
- if (ap->a_uio->uio_segflg == UIO_NOCOPY) {
- ap->a_uio->uio_segflg = UIO_SYSSPACE;
- } else if (ap->a_vp->v_flag & VOBJBUF) {
- union_vm_coherency(ap->a_vp, ap->a_uio, 1);
- }
-
- error = VOP_WRITE(uppervp, ap->a_uio, ap->a_ioflag, ap->a_cred);
-
- /*
- * the size of the underlying object may be changed by the
- * write.
- */
- if (error == 0) {
- off_t cur = ap->a_uio->uio_offset;
-
- if (cur > un->un_uppersz)
- union_newsize(ap->a_vp, cur, VNOVAL);
- }
- union_unlock_upper(uppervp, p);
- return (error);
-}
-
-static int
-union_lease(ap)
- struct vop_lease_args /* {
- struct vnode *a_vp;
- struct proc *a_p;
- struct ucred *a_cred;
- int a_flag;
- } */ *ap;
-{
- struct vnode *ovp = OTHERVP(ap->a_vp);
-
- ap->a_vp = ovp;
- return (VCALL(ovp, VOFFSET(vop_lease), ap));
-}
-
-static int
-union_ioctl(ap)
- struct vop_ioctl_args /* {
- struct vnode *a_vp;
- int a_command;
- caddr_t a_data;
- int a_fflag;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- struct vnode *ovp = OTHERVP(ap->a_vp);
-
- ap->a_vp = ovp;
- return (VCALL(ovp, VOFFSET(vop_ioctl), ap));
-}
-
-static int
-union_poll(ap)
- struct vop_poll_args /* {
- struct vnode *a_vp;
- int a_events;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- struct vnode *ovp = OTHERVP(ap->a_vp);
-
- ap->a_vp = ovp;
- return (VCALL(ovp, VOFFSET(vop_poll), ap));
-}
-
-static int
-union_revoke(ap)
- struct vop_revoke_args /* {
- struct vnode *a_vp;
- int a_flags;
- struct proc *a_p;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
-
- if (UPPERVP(vp))
- VOP_REVOKE(UPPERVP(vp), ap->a_flags);
- if (LOWERVP(vp))
- VOP_REVOKE(LOWERVP(vp), ap->a_flags);
- vgone(vp);
- return (0);
-}
-
-static int
-union_mmap(ap)
- struct vop_mmap_args /* {
- struct vnode *a_vp;
- int a_fflags;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- struct vnode *ovp = OTHERVP(ap->a_vp);
-
- ap->a_vp = ovp;
- return (VCALL(ovp, VOFFSET(vop_mmap), ap));
-}
-
-static int
-union_fsync(ap)
- struct vop_fsync_args /* {
- struct vnode *a_vp;
- struct ucred *a_cred;
- int a_waitfor;
- struct proc *a_p;
- } */ *ap;
-{
- int error = 0;
- struct proc *p = ap->a_p;
- struct vnode *targetvp;
- struct union_node *un = VTOUNION(ap->a_vp);
-
- if ((targetvp = union_lock_other(un, p)) != NULLVP) {
- error = VOP_FSYNC(targetvp, ap->a_cred, ap->a_waitfor, p);
- union_unlock_other(targetvp, p);
- }
-
- return (error);
-}
-
-/*
- * union_remove:
- *
- * Remove the specified cnp. The dvp and vp are passed to us locked
- * and must remain locked on return.
- */
-
-static int
-union_remove(ap)
- struct vop_remove_args /* {
- struct vnode *a_dvp;
- struct vnode *a_vp;
- struct componentname *a_cnp;
- } */ *ap;
-{
- struct union_node *dun = VTOUNION(ap->a_dvp);
- struct union_node *un = VTOUNION(ap->a_vp);
- struct componentname *cnp = ap->a_cnp;
- struct proc *p = cnp->cn_proc;
- struct vnode *uppervp;
- struct vnode *upperdvp;
- int error;
-
- if ((upperdvp = union_lock_upper(dun, p)) == NULLVP)
- panic("union remove: null upper vnode");
-
- if ((uppervp = union_lock_upper(un, p)) != NULLVP) {
- if (union_dowhiteout(un, cnp->cn_cred, p))
- cnp->cn_flags |= DOWHITEOUT;
- error = VOP_REMOVE(upperdvp, uppervp, cnp);
-#if 0
- /* XXX */
- if (!error)
- union_removed_upper(un);
-#endif
- union_unlock_upper(uppervp, p);
- } else {
- error = union_mkwhiteout(
- MOUNTTOUNIONMOUNT(ap->a_dvp->v_mount),
- upperdvp, ap->a_cnp, un->un_path);
- }
- union_unlock_upper(upperdvp, p);
- return (error);
-}
-
-/*
- * union_link:
- *
- * tdvp will be locked on entry, vp will not be locked on entry.
- * tdvp should remain locked on return and vp should remain unlocked
- * on return.
- */
-
-static int
-union_link(ap)
- struct vop_link_args /* {
- struct vnode *a_tdvp;
- struct vnode *a_vp;
- struct componentname *a_cnp;
- } */ *ap;
-{
- struct componentname *cnp = ap->a_cnp;
- struct proc *p = cnp->cn_proc;
- struct union_node *dun = VTOUNION(ap->a_tdvp);
- struct vnode *vp;
- struct vnode *tdvp;
- int error = 0;
-
- if (ap->a_tdvp->v_op != ap->a_vp->v_op) {
- vp = ap->a_vp;
- } else {
- struct union_node *tun = VTOUNION(ap->a_vp);
-
- if (tun->un_uppervp == NULLVP) {
- vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY, p);
-#if 0
- if (dun->un_uppervp == tun->un_dirvp) {
- if (dun->un_flags & UN_ULOCK) {
- dun->un_flags &= ~UN_ULOCK;
- VOP_UNLOCK(dun->un_uppervp, 0, p);
- }
- }
-#endif
- error = union_copyup(tun, 1, cnp->cn_cred, p);
-#if 0
- if (dun->un_uppervp == tun->un_dirvp) {
- vn_lock(dun->un_uppervp,
- LK_EXCLUSIVE | LK_RETRY, p);
- dun->un_flags |= UN_ULOCK;
- }
-#endif
- VOP_UNLOCK(ap->a_vp, 0, p);
- }
- vp = tun->un_uppervp;
- }
-
- if (error)
- return (error);
-
- /*
- * Make sure upper is locked, then unlock the union directory we were
- * called with to avoid a deadlock while we are calling VOP_LINK on
- * the upper (with tdvp locked and vp not locked). Our ap->a_tdvp
- * is expected to be locked on return.
- */
-
- if ((tdvp = union_lock_upper(dun, p)) == NULLVP)
- return (EROFS);
-
- VOP_UNLOCK(ap->a_tdvp, 0, p); /* unlock calling node */
- error = VOP_LINK(tdvp, vp, cnp); /* call link on upper */
-
- /*
- * We have to unlock tdvp prior to relocking our calling node in
- * order to avoid a deadlock.
- */
- union_unlock_upper(tdvp, p);
- vn_lock(ap->a_tdvp, LK_EXCLUSIVE | LK_RETRY, p);
- return (error);
-}
-
-static int
-union_rename(ap)
- struct vop_rename_args /* {
- struct vnode *a_fdvp;
- struct vnode *a_fvp;
- struct componentname *a_fcnp;
- struct vnode *a_tdvp;
- struct vnode *a_tvp;
- struct componentname *a_tcnp;
- } */ *ap;
-{
- int error;
- struct vnode *fdvp = ap->a_fdvp;
- struct vnode *fvp = ap->a_fvp;
- struct vnode *tdvp = ap->a_tdvp;
- struct vnode *tvp = ap->a_tvp;
-
- /*
- * Figure out what fdvp to pass to our upper or lower vnode. If we
- * replace the fdvp, release the original one and ref the new one.
- */
-
- if (fdvp->v_op == union_vnodeop_p) { /* always true */
- struct union_node *un = VTOUNION(fdvp);
- if (un->un_uppervp == NULLVP) {
- /*
- * this should never happen in normal
- * operation but might if there was
- * a problem creating the top-level shadow
- * directory.
- */
- error = EXDEV;
- goto bad;
- }
- fdvp = un->un_uppervp;
- VREF(fdvp);
- vrele(ap->a_fdvp);
- }
-
- /*
- * Figure out what fvp to pass to our upper or lower vnode. If we
- * replace the fvp, release the original one and ref the new one.
- */
-
- if (fvp->v_op == union_vnodeop_p) { /* always true */
- struct union_node *un = VTOUNION(fvp);
-#if 0
- struct union_mount *um = MOUNTTOUNIONMOUNT(fvp->v_mount);
-#endif
-
- if (un->un_uppervp == NULLVP) {
- switch(fvp->v_type) {
- case VREG:
- vn_lock(un->un_vnode, LK_EXCLUSIVE | LK_RETRY, ap->a_fcnp->cn_proc);
- error = union_copyup(un, 1, ap->a_fcnp->cn_cred, ap->a_fcnp->cn_proc);
- VOP_UNLOCK(un->un_vnode, 0, ap->a_fcnp->cn_proc);
- if (error)
- goto bad;
- break;
- case VDIR:
- /*
- * XXX not yet.
- *
- * There is only one way to rename a directory
- * based in the lowervp, and that is to copy
- * the entire directory hierarchy. Otherwise
- * it would not last across a reboot.
- */
-#if 0
- vrele(fvp);
- fvp = NULL;
- vn_lock(fdvp, LK_EXCLUSIVE | LK_RETRY, ap->a_fcnp->cn_proc);
- error = union_mkshadow(um, fdvp,
- ap->a_fcnp, &un->un_uppervp);
- VOP_UNLOCK(fdvp, 0, ap->a_fcnp->cn_proc);
- if (un->un_uppervp)
- VOP_UNLOCK(un->un_uppervp, 0, ap->a_fcnp->cn_proc);
- if (error)
- goto bad;
- break;
-#endif
- default:
- error = EXDEV;
- goto bad;
- }
- }
-
- if (un->un_lowervp != NULLVP)
- ap->a_fcnp->cn_flags |= DOWHITEOUT;
- fvp = un->un_uppervp;
- VREF(fvp);
- vrele(ap->a_fvp);
- }
-
- /*
- * Figure out what tdvp (destination directory) to pass to the
- * lower level. If we replace it with uppervp, we need to vput the
- * old one. The exclusive lock is transfered to what we will pass
- * down in the VOP_RENAME and we replace uppervp with a simple
- * reference.
- */
-
- if (tdvp->v_op == union_vnodeop_p) {
- struct union_node *un = VTOUNION(tdvp);
-
- if (un->un_uppervp == NULLVP) {
- /*
- * this should never happen in normal
- * operation but might if there was
- * a problem creating the top-level shadow
- * directory.
- */
- error = EXDEV;
- goto bad;
- }
-
- /*
- * new tdvp is a lock and reference on uppervp, put away
- * the old tdvp.
- */
- tdvp = union_lock_upper(un, ap->a_tcnp->cn_proc);
- vput(ap->a_tdvp);
- }
-
- /*
- * Figure out what tvp (destination file) to pass to the
- * lower level.
- *
- * If the uppervp file does not exist put away the (wrong)
- * file and change tvp to NULL.
- */
-
- if (tvp != NULLVP && tvp->v_op == union_vnodeop_p) {
- struct union_node *un = VTOUNION(tvp);
-
- tvp = union_lock_upper(un, ap->a_tcnp->cn_proc);
- vput(ap->a_tvp);
- /* note: tvp may be NULL */
- }
-
- /*
- * VOP_RENAME releases/vputs prior to returning, so we have no
- * cleanup to do.
- */
-
- return (VOP_RENAME(fdvp, fvp, ap->a_fcnp, tdvp, tvp, ap->a_tcnp));
-
- /*
- * Error. We still have to release / vput the various elements.
- */
-
-bad:
- vrele(fdvp);
- if (fvp)
- vrele(fvp);
- vput(tdvp);
- if (tvp != NULLVP) {
- if (tvp != tdvp)
- vput(tvp);
- else
- vrele(tvp);
- }
- return (error);
-}
-
-static int
-union_mkdir(ap)
- struct vop_mkdir_args /* {
- struct vnode *a_dvp;
- struct vnode **a_vpp;
- struct componentname *a_cnp;
- struct vattr *a_vap;
- } */ *ap;
-{
- struct union_node *dun = VTOUNION(ap->a_dvp);
- struct componentname *cnp = ap->a_cnp;
- struct proc *p = cnp->cn_proc;
- struct vnode *upperdvp;
- int error = EROFS;
-
- if ((upperdvp = union_lock_upper(dun, p)) != NULLVP) {
- struct vnode *vp;
-
- error = VOP_MKDIR(upperdvp, &vp, cnp, ap->a_vap);
- union_unlock_upper(upperdvp, p);
-
- if (error == 0) {
- VOP_UNLOCK(vp, 0, p);
- UDEBUG(("ALLOCVP-2 FROM %p REFS %d\n", vp, vp->v_usecount));
- error = union_allocvp(ap->a_vpp, ap->a_dvp->v_mount,
- ap->a_dvp, NULLVP, cnp, vp, NULLVP, 1);
- UDEBUG(("ALLOCVP-2B FROM %p REFS %d\n", *ap->a_vpp, vp->v_usecount));
- }
- }
- return (error);
-}
-
-static int
-union_rmdir(ap)
- struct vop_rmdir_args /* {
- struct vnode *a_dvp;
- struct vnode *a_vp;
- struct componentname *a_cnp;
- } */ *ap;
-{
- struct union_node *dun = VTOUNION(ap->a_dvp);
- struct union_node *un = VTOUNION(ap->a_vp);
- struct componentname *cnp = ap->a_cnp;
- struct proc *p = cnp->cn_proc;
- struct vnode *upperdvp;
- struct vnode *uppervp;
- int error;
-
- if ((upperdvp = union_lock_upper(dun, p)) == NULLVP)
- panic("union rmdir: null upper vnode");
-
- if ((uppervp = union_lock_upper(un, p)) != NULLVP) {
- if (union_dowhiteout(un, cnp->cn_cred, p))
- cnp->cn_flags |= DOWHITEOUT;
- error = VOP_RMDIR(upperdvp, uppervp, ap->a_cnp);
- union_unlock_upper(uppervp, p);
- } else {
- error = union_mkwhiteout(
- MOUNTTOUNIONMOUNT(ap->a_dvp->v_mount),
- dun->un_uppervp, ap->a_cnp, un->un_path);
- }
- union_unlock_upper(upperdvp, p);
- return (error);
-}
-
-/*
- * union_symlink:
- *
- * dvp is locked on entry and remains locked on return. a_vpp is garbage
- * (unused).
- */
-
-static int
-union_symlink(ap)
- struct vop_symlink_args /* {
- struct vnode *a_dvp;
- struct vnode **a_vpp;
- struct componentname *a_cnp;
- struct vattr *a_vap;
- char *a_target;
- } */ *ap;
-{
- struct union_node *dun = VTOUNION(ap->a_dvp);
- struct componentname *cnp = ap->a_cnp;
- struct proc *p = cnp->cn_proc;
- struct vnode *dvp;
- int error = EROFS;
-
- if ((dvp = union_lock_upper(dun, p)) != NULLVP) {
- error = VOP_SYMLINK(dvp, ap->a_vpp, cnp, ap->a_vap,
- ap->a_target);
- union_unlock_upper(dvp, p);
- }
- return (error);
-}
-
-/*
- * union_readdir works in concert with getdirentries and
- * readdir(3) to provide a list of entries in the unioned
- * directories. getdirentries is responsible for walking
- * down the union stack. readdir(3) is responsible for
- * eliminating duplicate names from the returned data stream.
- */
-static int
-union_readdir(ap)
- struct vop_readdir_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- struct ucred *a_cred;
- int *a_eofflag;
- u_long *a_cookies;
- int a_ncookies;
- } */ *ap;
-{
- struct union_node *un = VTOUNION(ap->a_vp);
- struct proc *p = ap->a_uio->uio_procp;
- struct vnode *uvp;
- int error = 0;
-
- if ((uvp = union_lock_upper(un, p)) != NULLVP) {
- ap->a_vp = uvp;
- error = VCALL(uvp, VOFFSET(vop_readdir), ap);
- union_unlock_upper(uvp, p);
- }
- return(error);
-}
-
-static int
-union_readlink(ap)
- struct vop_readlink_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- struct ucred *a_cred;
- } */ *ap;
-{
- int error;
- struct union_node *un = VTOUNION(ap->a_vp);
- struct uio *uio = ap->a_uio;
- struct proc *p = uio->uio_procp;
- struct vnode *vp;
-
- vp = union_lock_other(un, p);
- KASSERT(vp != NULL, ("union_readlink: backing vnode missing!"));
-
- ap->a_vp = vp;
- error = VCALL(vp, VOFFSET(vop_readlink), ap);
- union_unlock_other(vp, p);
-
- return (error);
-}
-
-/*
- * union_inactive:
- *
- * Called with the vnode locked. We are expected to unlock the vnode.
- */
-
-static int
-union_inactive(ap)
- struct vop_inactive_args /* {
- struct vnode *a_vp;
- struct proc *a_p;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
- struct proc *p = ap->a_p;
- struct union_node *un = VTOUNION(vp);
- struct vnode **vpp;
-
- /*
- * Do nothing (and _don't_ bypass).
- * Wait to vrele lowervp until reclaim,
- * so that until then our union_node is in the
- * cache and reusable.
- *
- * NEEDSWORK: Someday, consider inactive'ing
- * the lowervp and then trying to reactivate it
- * with capabilities (v_id)
- * like they do in the name lookup cache code.
- * That's too much work for now.
- */
-
- if (un->un_dircache != 0) {
- for (vpp = un->un_dircache; *vpp != NULLVP; vpp++)
- vrele(*vpp);
- free (un->un_dircache, M_TEMP);
- un->un_dircache = 0;
- }
-
-#if 0
- if ((un->un_flags & UN_ULOCK) && un->un_uppervp) {
- un->un_flags &= ~UN_ULOCK;
- VOP_UNLOCK(un->un_uppervp, 0, p);
- }
-#endif
-
- VOP_UNLOCK(vp, 0, p);
-
- if ((un->un_flags & UN_CACHED) == 0)
- vgone(vp);
-
- return (0);
-}
-
-static int
-union_reclaim(ap)
- struct vop_reclaim_args /* {
- struct vnode *a_vp;
- } */ *ap;
-{
- union_freevp(ap->a_vp);
-
- return (0);
-}
-
-static int
-union_lock(ap)
- struct vop_lock_args *ap;
-{
-#if 0
- struct vnode *vp = ap->a_vp;
- struct proc *p = ap->a_p;
- int flags = ap->a_flags;
- struct union_node *un;
-#endif
- int error;
-
- error = vop_stdlock(ap);
-#if 0
- un = VTOUNION(vp);
-
- if (error == 0) {
- /*
- * Lock the upper if it exists and this is an exclusive lock
- * request.
- */
- if (un->un_uppervp != NULLVP &&
- (flags & LK_TYPE_MASK) == LK_EXCLUSIVE) {
- if ((un->un_flags & UN_ULOCK) == 0 && vp->v_usecount) {
- error = vn_lock(un->un_uppervp, flags, p);
- if (error) {
- struct vop_unlock_args uap = { 0 };
- uap.a_vp = ap->a_vp;
- uap.a_flags = ap->a_flags;
- uap.a_p = ap->a_p;
- vop_stdunlock(&uap);
- return (error);
- }
- un->un_flags |= UN_ULOCK;
- }
- }
- }
-#endif
- return (error);
-}
-
-/*
- * union_unlock:
- *
- * Unlock our union node. This also unlocks uppervp.
- */
-static int
-union_unlock(ap)
- struct vop_unlock_args /* {
- struct vnode *a_vp;
- int a_flags;
- struct proc *a_p;
- } */ *ap;
-{
- struct union_node *un = VTOUNION(ap->a_vp);
- int error;
-
- KASSERT((un->un_uppervp == NULL || un->un_uppervp->v_usecount > 0), ("uppervp usecount is 0"));
-
- error = vop_stdunlock(ap);
-#if 0
-
- /*
- * If no exclusive locks remain and we are holding an uppervp lock,
- * remove the uppervp lock.
- */
-
- if ((un->un_flags & UN_ULOCK) &&
- lockstatus(&un->un_lock, NULL) != LK_EXCLUSIVE) {
- un->un_flags &= ~UN_ULOCK;
- VOP_UNLOCK(un->un_uppervp, LK_EXCLUSIVE, p);
- }
-#endif
- return(error);
-}
-
-/*
- * union_bmap:
- *
- * There isn't much we can do. We cannot push through to the real vnode
- * to get to the underlying device because this will bypass data
- * cached by the real vnode.
- *
- * For some reason we cannot return the 'real' vnode either, it seems
- * to blow up memory maps.
- */
-
-static int
-union_bmap(ap)
- struct vop_bmap_args /* {
- struct vnode *a_vp;
- daddr_t a_bn;
- struct vnode **a_vpp;
- daddr_t *a_bnp;
- int *a_runp;
- int *a_runb;
- } */ *ap;
-{
- return(EOPNOTSUPP);
-}
-
-static int
-union_print(ap)
- struct vop_print_args /* {
- struct vnode *a_vp;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
-
- printf("\ttag VT_UNION, vp=%p, uppervp=%p, lowervp=%p\n",
- vp, UPPERVP(vp), LOWERVP(vp));
- if (UPPERVP(vp) != NULLVP)
- vprint("union: upper", UPPERVP(vp));
- if (LOWERVP(vp) != NULLVP)
- vprint("union: lower", LOWERVP(vp));
-
- return (0);
-}
-
-static int
-union_pathconf(ap)
- struct vop_pathconf_args /* {
- struct vnode *a_vp;
- int a_name;
- int *a_retval;
- } */ *ap;
-{
- int error;
- struct proc *p = curproc; /* XXX */
- struct union_node *un = VTOUNION(ap->a_vp);
- struct vnode *vp;
-
- vp = union_lock_other(un, p);
- KASSERT(vp != NULL, ("union_pathconf: backing vnode missing!"));
-
- ap->a_vp = vp;
- error = VCALL(vp, VOFFSET(vop_pathconf), ap);
- union_unlock_other(vp, p);
-
- return (error);
-}
-
-static int
-union_advlock(ap)
- struct vop_advlock_args /* {
- struct vnode *a_vp;
- caddr_t a_id;
- int a_op;
- struct flock *a_fl;
- int a_flags;
- } */ *ap;
-{
- register struct vnode *ovp = OTHERVP(ap->a_vp);
-
- ap->a_vp = ovp;
- return (VCALL(ovp, VOFFSET(vop_advlock), ap));
-}
-
-
-/*
- * XXX - vop_strategy must be hand coded because it has no
- * YYY - and it is not coherent with anything
- *
- * vnode in its arguments.
- * This goes away with a merged VM/buffer cache.
- */
-static int
-union_strategy(ap)
- struct vop_strategy_args /* {
- struct vnode *a_vp;
- struct buf *a_bp;
- } */ *ap;
-{
- struct buf *bp = ap->a_bp;
- struct vnode *othervp = OTHERVP(bp->b_vp);
-
-#ifdef DIAGNOSTIC
- if (othervp == NULLVP)
- panic("union_strategy: nil vp");
- if (((bp->b_flags & B_READ) == 0) &&
- (othervp == LOWERVP(bp->b_vp)))
- panic("union_strategy: writing to lowervp");
-#endif
- return (VOP_STRATEGY(othervp, bp));
-}
-
-/*
- * Global vfs data structures
- */
-vop_t **union_vnodeop_p;
-static struct vnodeopv_entry_desc union_vnodeop_entries[] = {
- { &vop_default_desc, (vop_t *) vop_defaultop },
- { &vop_access_desc, (vop_t *) union_access },
- { &vop_advlock_desc, (vop_t *) union_advlock },
- { &vop_bmap_desc, (vop_t *) union_bmap },
- { &vop_close_desc, (vop_t *) union_close },
- { &vop_create_desc, (vop_t *) union_create },
- { &vop_fsync_desc, (vop_t *) union_fsync },
- { &vop_getpages_desc, (vop_t *) union_getpages },
- { &vop_putpages_desc, (vop_t *) union_putpages },
- { &vop_getattr_desc, (vop_t *) union_getattr },
- { &vop_inactive_desc, (vop_t *) union_inactive },
- { &vop_ioctl_desc, (vop_t *) union_ioctl },
- { &vop_islocked_desc, (vop_t *) vop_stdislocked },
- { &vop_lease_desc, (vop_t *) union_lease },
- { &vop_link_desc, (vop_t *) union_link },
- { &vop_lock_desc, (vop_t *) union_lock },
- { &vop_lookup_desc, (vop_t *) union_lookup },
- { &vop_mkdir_desc, (vop_t *) union_mkdir },
- { &vop_mknod_desc, (vop_t *) union_mknod },
- { &vop_mmap_desc, (vop_t *) union_mmap },
- { &vop_open_desc, (vop_t *) union_open },
- { &vop_pathconf_desc, (vop_t *) union_pathconf },
- { &vop_poll_desc, (vop_t *) union_poll },
- { &vop_print_desc, (vop_t *) union_print },
- { &vop_read_desc, (vop_t *) union_read },
- { &vop_readdir_desc, (vop_t *) union_readdir },
- { &vop_readlink_desc, (vop_t *) union_readlink },
- { &vop_reclaim_desc, (vop_t *) union_reclaim },
- { &vop_remove_desc, (vop_t *) union_remove },
- { &vop_rename_desc, (vop_t *) union_rename },
- { &vop_revoke_desc, (vop_t *) union_revoke },
- { &vop_rmdir_desc, (vop_t *) union_rmdir },
- { &vop_setattr_desc, (vop_t *) union_setattr },
- { &vop_strategy_desc, (vop_t *) union_strategy },
- { &vop_symlink_desc, (vop_t *) union_symlink },
- { &vop_unlock_desc, (vop_t *) union_unlock },
- { &vop_whiteout_desc, (vop_t *) union_whiteout },
- { &vop_write_desc, (vop_t *) union_write },
- { NULL, NULL }
-};
-static struct vnodeopv_desc union_vnodeop_opv_desc =
- { &union_vnodeop_p, union_vnodeop_entries };
-
-VNODEOP_SET(union_vnodeop_opv_desc);
diff --git a/sys/geom/geom_ccd.c b/sys/geom/geom_ccd.c
deleted file mode 100644
index 672ffe2fbef1..000000000000
--- a/sys/geom/geom_ccd.c
+++ /dev/null
@@ -1,1730 +0,0 @@
-/* $FreeBSD$ */
-
-/* $NetBSD: ccd.c,v 1.22 1995/12/08 19:13:26 thorpej Exp $ */
-
-/*
- * Copyright (c) 1995 Jason R. Thorpe.
- * 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 Jason R. Thorpe.
- * 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.
- */
-
-/*
- * 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. 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, Berkeley and its contributors.
- * 4. 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: cd.c 1.6 90/11/28$
- *
- * @(#)cd.c 8.2 (Berkeley) 11/16/93
- */
-
-/*
- * "Concatenated" disk driver.
- *
- * Dynamic configuration and disklabel support by:
- * Jason R. Thorpe <thorpej@nas.nasa.gov>
- * Numerical Aerodynamic Simulation Facility
- * Mail Stop 258-6
- * NASA Ames Research Center
- * Moffett Field, CA 94035
- */
-
-#include "ccd.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/proc.h>
-#include <sys/buf.h>
-#include <sys/malloc.h>
-#include <sys/namei.h>
-#include <sys/conf.h>
-#include <sys/stat.h>
-#include <sys/sysctl.h>
-#include <sys/disklabel.h>
-#include <ufs/ffs/fs.h>
-#include <sys/devicestat.h>
-#include <sys/fcntl.h>
-#include <sys/vnode.h>
-
-#include <sys/ccdvar.h>
-
-#include <vm/vm_zone.h>
-
-#if defined(CCDDEBUG) && !defined(DEBUG)
-#define DEBUG
-#endif
-
-#ifdef DEBUG
-#define CCDB_FOLLOW 0x01
-#define CCDB_INIT 0x02
-#define CCDB_IO 0x04
-#define CCDB_LABEL 0x08
-#define CCDB_VNODE 0x10
-static int ccddebug = CCDB_FOLLOW | CCDB_INIT | CCDB_IO | CCDB_LABEL |
- CCDB_VNODE;
-SYSCTL_INT(_debug, OID_AUTO, ccddebug, CTLFLAG_RW, &ccddebug, 0, "");
-#undef DEBUG
-#endif
-
-#define ccdunit(x) dkunit(x)
-#define ccdpart(x) dkpart(x)
-
-/*
- This is how mirroring works (only writes are special):
-
- When initiating a write, ccdbuffer() returns two "struct ccdbuf *"s
- linked together by the cb_mirror field. "cb_pflags &
- CCDPF_MIRROR_DONE" is set to 0 on both of them.
-
- When a component returns to ccdiodone(), it checks if "cb_pflags &
- CCDPF_MIRROR_DONE" is set or not. If not, it sets the partner's
- flag and returns. If it is, it means its partner has already
- returned, so it will go to the regular cleanup.
-
- */
-
-struct ccdbuf {
- struct buf cb_buf; /* new I/O buf */
- struct buf *cb_obp; /* ptr. to original I/O buf */
- struct ccdbuf *cb_freenext; /* free list link */
- int cb_unit; /* target unit */
- int cb_comp; /* target component */
- int cb_pflags; /* mirror/parity status flag */
- struct ccdbuf *cb_mirror; /* mirror counterpart */
-};
-
-/* bits in cb_pflags */
-#define CCDPF_MIRROR_DONE 1 /* if set, mirror counterpart is done */
-
-#define CCDLABELDEV(dev) \
- (makedev(major((dev)), dkmakeminor(ccdunit((dev)), 0, RAW_PART)))
-
-static d_open_t ccdopen;
-static d_close_t ccdclose;
-static d_strategy_t ccdstrategy;
-static d_ioctl_t ccdioctl;
-static d_dump_t ccddump;
-static d_psize_t ccdsize;
-
-#define NCCDFREEHIWAT 16
-
-#define CDEV_MAJOR 74
-#define BDEV_MAJOR 21
-
-static struct cdevsw ccd_cdevsw = {
- /* open */ ccdopen,
- /* close */ ccdclose,
- /* read */ physread,
- /* write */ physwrite,
- /* ioctl */ ccdioctl,
- /* poll */ nopoll,
- /* mmap */ nommap,
- /* strategy */ ccdstrategy,
- /* name */ "ccd",
- /* maj */ CDEV_MAJOR,
- /* dump */ ccddump,
- /* psize */ ccdsize,
- /* flags */ D_DISK,
- /* bmaj */ BDEV_MAJOR
-};
-
-/* called during module initialization */
-static void ccdattach __P((void));
-static int ccd_modevent __P((module_t, int, void *));
-
-/* called by biodone() at interrupt time */
-static void ccdiodone __P((struct ccdbuf *cbp));
-
-static void ccdstart __P((struct ccd_softc *, struct buf *));
-static void ccdinterleave __P((struct ccd_softc *, int));
-static void ccdintr __P((struct ccd_softc *, struct buf *));
-static int ccdinit __P((struct ccddevice *, char **, struct proc *));
-static int ccdlookup __P((char *, struct proc *p, struct vnode **));
-static void ccdbuffer __P((struct ccdbuf **ret, struct ccd_softc *,
- struct buf *, daddr_t, caddr_t, long));
-static void ccdgetdisklabel __P((dev_t));
-static void ccdmakedisklabel __P((struct ccd_softc *));
-static int ccdlock __P((struct ccd_softc *));
-static void ccdunlock __P((struct ccd_softc *));
-
-#ifdef DEBUG
-static void printiinfo __P((struct ccdiinfo *));
-#endif
-
-/* Non-private for the benefit of libkvm. */
-struct ccd_softc *ccd_softc;
-struct ccddevice *ccddevs;
-struct ccdbuf *ccdfreebufs;
-static int numccdfreebufs;
-static int numccd = 0;
-
-/*
- * getccdbuf() - Allocate and zero a ccd buffer.
- *
- * This routine is called at splbio().
- */
-
-static __inline
-struct ccdbuf *
-getccdbuf(struct ccdbuf *cpy)
-{
- struct ccdbuf *cbp;
-
- /*
- * Allocate from freelist or malloc as necessary
- */
- if ((cbp = ccdfreebufs) != NULL) {
- ccdfreebufs = cbp->cb_freenext;
- --numccdfreebufs;
- } else {
- cbp = malloc(sizeof(struct ccdbuf), M_DEVBUF, M_WAITOK);
- }
-
- /*
- * Used by mirroring code
- */
- if (cpy)
- bcopy(cpy, cbp, sizeof(struct ccdbuf));
- else
- bzero(cbp, sizeof(struct ccdbuf));
-
- /*
- * independant struct buf initialization
- */
- LIST_INIT(&cbp->cb_buf.b_dep);
- BUF_LOCKINIT(&cbp->cb_buf);
- BUF_LOCK(&cbp->cb_buf, LK_EXCLUSIVE);
- BUF_KERNPROC(&cbp->cb_buf);
-
- return(cbp);
-}
-
-/*
- * putccdbuf() - Free a ccd buffer.
- *
- * This routine is called at splbio().
- */
-
-static __inline
-void
-putccdbuf(struct ccdbuf *cbp)
-{
- BUF_UNLOCK(&cbp->cb_buf);
- BUF_LOCKFREE(&cbp->cb_buf);
-
- if (numccdfreebufs < NCCDFREEHIWAT) {
- cbp->cb_freenext = ccdfreebufs;
- ccdfreebufs = cbp;
- ++numccdfreebufs;
- } else {
- free((caddr_t)cbp, M_DEVBUF);
- }
-}
-
-
-/*
- * Number of blocks to untouched in front of a component partition.
- * This is to avoid violating its disklabel area when it starts at the
- * beginning of the slice.
- */
-#if !defined(CCD_OFFSET)
-#define CCD_OFFSET 16
-#endif
-
-/*
- * Called by main() during pseudo-device attachment. All we need
- * to do is allocate enough space for devices to be configured later, and
- * add devsw entries.
- */
-static void
-ccdattach()
-{
- int i;
- int num = NCCD;
-
- if (num > 1)
- printf("ccd0-%d: Concatenated disk drivers\n", num-1);
- else
- printf("ccd0: Concatenated disk driver\n");
-
- ccd_softc = (struct ccd_softc *)malloc(num * sizeof(struct ccd_softc),
- M_DEVBUF, M_NOWAIT);
- ccddevs = (struct ccddevice *)malloc(num * sizeof(struct ccddevice),
- M_DEVBUF, M_NOWAIT);
- if ((ccd_softc == NULL) || (ccddevs == NULL)) {
- printf("WARNING: no memory for concatenated disks\n");
- if (ccd_softc != NULL)
- free(ccd_softc, M_DEVBUF);
- if (ccddevs != NULL)
- free(ccddevs, M_DEVBUF);
- return;
- }
- numccd = num;
- bzero(ccd_softc, num * sizeof(struct ccd_softc));
- bzero(ccddevs, num * sizeof(struct ccddevice));
-
- cdevsw_add(&ccd_cdevsw);
- /* XXX: is this necessary? */
- for (i = 0; i < numccd; ++i)
- ccddevs[i].ccd_dk = -1;
-}
-
-static int
-ccd_modevent(mod, type, data)
- module_t mod;
- int type;
- void *data;
-{
- int error = 0;
-
- switch (type) {
- case MOD_LOAD:
- ccdattach();
- break;
-
- case MOD_UNLOAD:
- printf("ccd0: Unload not supported!\n");
- error = EOPNOTSUPP;
- break;
-
- default: /* MOD_SHUTDOWN etc */
- break;
- }
- return (error);
-}
-
-DEV_MODULE(ccd, ccd_modevent, NULL);
-
-static int
-ccdinit(ccd, cpaths, p)
- struct ccddevice *ccd;
- char **cpaths;
- struct proc *p;
-{
- struct ccd_softc *cs = &ccd_softc[ccd->ccd_unit];
- struct ccdcinfo *ci = NULL; /* XXX */
- size_t size;
- int ix;
- struct vnode *vp;
- size_t minsize;
- int maxsecsize;
- struct partinfo dpart;
- struct ccdgeom *ccg = &cs->sc_geom;
- char tmppath[MAXPATHLEN];
- int error = 0;
-
-#ifdef DEBUG
- if (ccddebug & (CCDB_FOLLOW|CCDB_INIT))
- printf("ccdinit: unit %d\n", ccd->ccd_unit);
-#endif
-
- cs->sc_size = 0;
- cs->sc_ileave = ccd->ccd_interleave;
- cs->sc_nccdisks = ccd->ccd_ndev;
-
- /* Allocate space for the component info. */
- cs->sc_cinfo = malloc(cs->sc_nccdisks * sizeof(struct ccdcinfo),
- M_DEVBUF, M_WAITOK);
-
- /*
- * Verify that each component piece exists and record
- * relevant information about it.
- */
- maxsecsize = 0;
- minsize = 0;
- for (ix = 0; ix < cs->sc_nccdisks; ix++) {
- vp = ccd->ccd_vpp[ix];
- ci = &cs->sc_cinfo[ix];
- ci->ci_vp = vp;
-
- /*
- * Copy in the pathname of the component.
- */
- bzero(tmppath, sizeof(tmppath)); /* sanity */
- if ((error = copyinstr(cpaths[ix], tmppath,
- MAXPATHLEN, &ci->ci_pathlen)) != 0) {
-#ifdef DEBUG
- if (ccddebug & (CCDB_FOLLOW|CCDB_INIT))
- printf("ccd%d: can't copy path, error = %d\n",
- ccd->ccd_unit, error);
-#endif
- goto fail;
- }
- ci->ci_path = malloc(ci->ci_pathlen, M_DEVBUF, M_WAITOK);
- bcopy(tmppath, ci->ci_path, ci->ci_pathlen);
-
- ci->ci_dev = vn_todev(vp);
-
- /*
- * Get partition information for the component.
- */
- if ((error = VOP_IOCTL(vp, DIOCGPART, (caddr_t)&dpart,
- FREAD, p->p_ucred, p)) != 0) {
-#ifdef DEBUG
- if (ccddebug & (CCDB_FOLLOW|CCDB_INIT))
- printf("ccd%d: %s: ioctl failed, error = %d\n",
- ccd->ccd_unit, ci->ci_path, error);
-#endif
- goto fail;
- }
- if (dpart.part->p_fstype == FS_BSDFFS) {
- maxsecsize =
- ((dpart.disklab->d_secsize > maxsecsize) ?
- dpart.disklab->d_secsize : maxsecsize);
- size = dpart.part->p_size - CCD_OFFSET;
- } else {
-#ifdef DEBUG
- if (ccddebug & (CCDB_FOLLOW|CCDB_INIT))
- printf("ccd%d: %s: incorrect partition type\n",
- ccd->ccd_unit, ci->ci_path);
-#endif
- error = EFTYPE;
- goto fail;
- }
-
- /*
- * Calculate the size, truncating to an interleave
- * boundary if necessary.
- */
-
- if (cs->sc_ileave > 1)
- size -= size % cs->sc_ileave;
-
- if (size == 0) {
-#ifdef DEBUG
- if (ccddebug & (CCDB_FOLLOW|CCDB_INIT))
- printf("ccd%d: %s: size == 0\n",
- ccd->ccd_unit, ci->ci_path);
-#endif
- error = ENODEV;
- goto fail;
- }
-
- if (minsize == 0 || size < minsize)
- minsize = size;
- ci->ci_size = size;
- cs->sc_size += size;
- }
-
- /*
- * Don't allow the interleave to be smaller than
- * the biggest component sector.
- */
- if ((cs->sc_ileave > 0) &&
- (cs->sc_ileave < (maxsecsize / DEV_BSIZE))) {
-#ifdef DEBUG
- if (ccddebug & (CCDB_FOLLOW|CCDB_INIT))
- printf("ccd%d: interleave must be at least %d\n",
- ccd->ccd_unit, (maxsecsize / DEV_BSIZE));
-#endif
- error = EINVAL;
- goto fail;
- }
-
- /*
- * If uniform interleave is desired set all sizes to that of
- * the smallest component. This will guarentee that a single
- * interleave table is generated.
- *
- * Lost space must be taken into account when calculating the
- * overall size. Half the space is lost when CCDF_MIRROR is
- * specified. One disk is lost when CCDF_PARITY is specified.
- */
- if (ccd->ccd_flags & CCDF_UNIFORM) {
- for (ci = cs->sc_cinfo;
- ci < &cs->sc_cinfo[cs->sc_nccdisks]; ci++) {
- ci->ci_size = minsize;
- }
- if (ccd->ccd_flags & CCDF_MIRROR) {
- /*
- * Check to see if an even number of components
- * have been specified. The interleave must also
- * be non-zero in order for us to be able to
- * guarentee the topology.
- */
- if (cs->sc_nccdisks % 2) {
- printf("ccd%d: mirroring requires an even number of disks\n", ccd->ccd_unit );
- error = EINVAL;
- goto fail;
- }
- if (cs->sc_ileave == 0) {
- printf("ccd%d: an interleave must be specified when mirroring\n", ccd->ccd_unit);
- error = EINVAL;
- goto fail;
- }
- cs->sc_size = (cs->sc_nccdisks/2) * minsize;
- } else if (ccd->ccd_flags & CCDF_PARITY) {
- cs->sc_size = (cs->sc_nccdisks-1) * minsize;
- } else {
- if (cs->sc_ileave == 0) {
- printf("ccd%d: an interleave must be specified when using parity\n", ccd->ccd_unit);
- error = EINVAL;
- goto fail;
- }
- cs->sc_size = cs->sc_nccdisks * minsize;
- }
- }
-
- /*
- * Construct the interleave table.
- */
- ccdinterleave(cs, ccd->ccd_unit);
-
- /*
- * Create pseudo-geometry based on 1MB cylinders. It's
- * pretty close.
- */
- ccg->ccg_secsize = maxsecsize;
- ccg->ccg_ntracks = 1;
- ccg->ccg_nsectors = 1024 * 1024 / ccg->ccg_secsize;
- ccg->ccg_ncylinders = cs->sc_size / ccg->ccg_nsectors;
-
- /*
- * Add an devstat entry for this device.
- */
- devstat_add_entry(&cs->device_stats, "ccd", ccd->ccd_unit,
- ccg->ccg_secsize, DEVSTAT_ALL_SUPPORTED,
- DEVSTAT_TYPE_STORARRAY |DEVSTAT_TYPE_IF_OTHER,
- DEVSTAT_PRIORITY_ARRAY);
-
- cs->sc_flags |= CCDF_INITED;
- cs->sc_cflags = ccd->ccd_flags; /* So we can find out later... */
- cs->sc_unit = ccd->ccd_unit;
- return (0);
-fail:
- while (ci > cs->sc_cinfo) {
- ci--;
- free(ci->ci_path, M_DEVBUF);
- }
- free(cs->sc_cinfo, M_DEVBUF);
- return (error);
-}
-
-static void
-ccdinterleave(cs, unit)
- struct ccd_softc *cs;
- int unit;
-{
- struct ccdcinfo *ci, *smallci;
- struct ccdiinfo *ii;
- daddr_t bn, lbn;
- int ix;
- u_long size;
-
-#ifdef DEBUG
- if (ccddebug & CCDB_INIT)
- printf("ccdinterleave(%x): ileave %d\n", cs, cs->sc_ileave);
-#endif
-
- /*
- * Allocate an interleave table. The worst case occurs when each
- * of N disks is of a different size, resulting in N interleave
- * tables.
- *
- * Chances are this is too big, but we don't care.
- */
- size = (cs->sc_nccdisks + 1) * sizeof(struct ccdiinfo);
- cs->sc_itable = (struct ccdiinfo *)malloc(size, M_DEVBUF, M_WAITOK);
- bzero((caddr_t)cs->sc_itable, size);
-
- /*
- * Trivial case: no interleave (actually interleave of disk size).
- * Each table entry represents a single component in its entirety.
- *
- * An interleave of 0 may not be used with a mirror or parity setup.
- */
- if (cs->sc_ileave == 0) {
- bn = 0;
- ii = cs->sc_itable;
-
- for (ix = 0; ix < cs->sc_nccdisks; ix++) {
- /* Allocate space for ii_index. */
- ii->ii_index = malloc(sizeof(int), M_DEVBUF, M_WAITOK);
- ii->ii_ndisk = 1;
- ii->ii_startblk = bn;
- ii->ii_startoff = 0;
- ii->ii_index[0] = ix;
- bn += cs->sc_cinfo[ix].ci_size;
- ii++;
- }
- ii->ii_ndisk = 0;
-#ifdef DEBUG
- if (ccddebug & CCDB_INIT)
- printiinfo(cs->sc_itable);
-#endif
- return;
- }
-
- /*
- * The following isn't fast or pretty; it doesn't have to be.
- */
- size = 0;
- bn = lbn = 0;
- for (ii = cs->sc_itable; ; ii++) {
- /*
- * Allocate space for ii_index. We might allocate more then
- * we use.
- */
- ii->ii_index = malloc((sizeof(int) * cs->sc_nccdisks),
- M_DEVBUF, M_WAITOK);
-
- /*
- * Locate the smallest of the remaining components
- */
- smallci = NULL;
- for (ci = cs->sc_cinfo; ci < &cs->sc_cinfo[cs->sc_nccdisks];
- ci++) {
- if (ci->ci_size > size &&
- (smallci == NULL ||
- ci->ci_size < smallci->ci_size)) {
- smallci = ci;
- }
- }
-
- /*
- * Nobody left, all done
- */
- if (smallci == NULL) {
- ii->ii_ndisk = 0;
- break;
- }
-
- /*
- * Record starting logical block using an sc_ileave blocksize.
- */
- ii->ii_startblk = bn / cs->sc_ileave;
-
- /*
- * Record starting comopnent block using an sc_ileave
- * blocksize. This value is relative to the beginning of
- * a component disk.
- */
- ii->ii_startoff = lbn;
-
- /*
- * Determine how many disks take part in this interleave
- * and record their indices.
- */
- ix = 0;
- for (ci = cs->sc_cinfo;
- ci < &cs->sc_cinfo[cs->sc_nccdisks]; ci++) {
- if (ci->ci_size >= smallci->ci_size) {
- ii->ii_index[ix++] = ci - cs->sc_cinfo;
- }
- }
- ii->ii_ndisk = ix;
- bn += ix * (smallci->ci_size - size);
- lbn = smallci->ci_size / cs->sc_ileave;
- size = smallci->ci_size;
- }
-#ifdef DEBUG
- if (ccddebug & CCDB_INIT)
- printiinfo(cs->sc_itable);
-#endif
-}
-
-/* ARGSUSED */
-static int
-ccdopen(dev, flags, fmt, p)
- dev_t dev;
- int flags, fmt;
- struct proc *p;
-{
- int unit = ccdunit(dev);
- struct ccd_softc *cs;
- struct disklabel *lp;
- int error = 0, part, pmask;
-
-#ifdef DEBUG
- if (ccddebug & CCDB_FOLLOW)
- printf("ccdopen(%x, %x)\n", dev, flags);
-#endif
- if (unit >= numccd)
- return (ENXIO);
- cs = &ccd_softc[unit];
-
- if ((error = ccdlock(cs)) != 0)
- return (error);
-
- lp = &cs->sc_label;
-
- part = ccdpart(dev);
- pmask = (1 << part);
-
- /*
- * If we're initialized, check to see if there are any other
- * open partitions. If not, then it's safe to update
- * the in-core disklabel.
- */
- if ((cs->sc_flags & CCDF_INITED) && (cs->sc_openmask == 0))
- ccdgetdisklabel(dev);
-
- /* Check that the partition exists. */
- if (part != RAW_PART && ((part >= lp->d_npartitions) ||
- (lp->d_partitions[part].p_fstype == FS_UNUSED))) {
- error = ENXIO;
- goto done;
- }
-
- cs->sc_openmask |= pmask;
- done:
- ccdunlock(cs);
- return (0);
-}
-
-/* ARGSUSED */
-static int
-ccdclose(dev, flags, fmt, p)
- dev_t dev;
- int flags, fmt;
- struct proc *p;
-{
- int unit = ccdunit(dev);
- struct ccd_softc *cs;
- int error = 0, part;
-
-#ifdef DEBUG
- if (ccddebug & CCDB_FOLLOW)
- printf("ccdclose(%x, %x)\n", dev, flags);
-#endif
-
- if (unit >= numccd)
- return (ENXIO);
- cs = &ccd_softc[unit];
-
- if ((error = ccdlock(cs)) != 0)
- return (error);
-
- part = ccdpart(dev);
-
- /* ...that much closer to allowing unconfiguration... */
- cs->sc_openmask &= ~(1 << part);
- ccdunlock(cs);
- return (0);
-}
-
-static void
-ccdstrategy(bp)
- struct buf *bp;
-{
- int unit = ccdunit(bp->b_dev);
- struct ccd_softc *cs = &ccd_softc[unit];
- int s;
- int wlabel;
- struct disklabel *lp;
-
-#ifdef DEBUG
- if (ccddebug & CCDB_FOLLOW)
- printf("ccdstrategy(%x): unit %d\n", bp, unit);
-#endif
- if ((cs->sc_flags & CCDF_INITED) == 0) {
- bp->b_error = ENXIO;
- bp->b_flags |= B_ERROR;
- goto done;
- }
-
- /* If it's a nil transfer, wake up the top half now. */
- if (bp->b_bcount == 0)
- goto done;
-
- lp = &cs->sc_label;
-
- /*
- * Do bounds checking and adjust transfer. If there's an
- * error, the bounds check will flag that for us.
- */
- wlabel = cs->sc_flags & (CCDF_WLABEL|CCDF_LABELLING);
- if (ccdpart(bp->b_dev) != RAW_PART) {
- if (bounds_check_with_label(bp, lp, wlabel) <= 0)
- goto done;
- } else {
- int pbn; /* in sc_secsize chunks */
- long sz; /* in sc_secsize chunks */
-
- pbn = bp->b_blkno / (cs->sc_geom.ccg_secsize / DEV_BSIZE);
- sz = howmany(bp->b_bcount, cs->sc_geom.ccg_secsize);
-
- /*
- * If out of bounds return an error. If at the EOF point,
- * simply read or write less.
- */
-
- if (pbn < 0 || pbn >= cs->sc_size) {
- bp->b_resid = bp->b_bcount;
- if (pbn != cs->sc_size) {
- bp->b_error = EINVAL;
- bp->b_flags |= B_ERROR | B_INVAL;
- }
- goto done;
- }
-
- /*
- * If the request crosses EOF, truncate the request.
- */
- if (pbn + sz > cs->sc_size) {
- bp->b_bcount = (cs->sc_size - pbn) *
- cs->sc_geom.ccg_secsize;
- }
- }
-
- bp->b_resid = bp->b_bcount;
-
- /*
- * "Start" the unit.
- */
- s = splbio();
- ccdstart(cs, bp);
- splx(s);
- return;
-done:
- biodone(bp);
-}
-
-static void
-ccdstart(cs, bp)
- struct ccd_softc *cs;
- struct buf *bp;
-{
- long bcount, rcount;
- struct ccdbuf *cbp[4];
- /* XXX! : 2 reads and 2 writes for RAID 4/5 */
- caddr_t addr;
- daddr_t bn;
- struct partition *pp;
-
-#ifdef DEBUG
- if (ccddebug & CCDB_FOLLOW)
- printf("ccdstart(%x, %x)\n", cs, bp);
-#endif
-
- /* Record the transaction start */
- devstat_start_transaction(&cs->device_stats);
-
- /*
- * Translate the partition-relative block number to an absolute.
- */
- bn = bp->b_blkno;
- if (ccdpart(bp->b_dev) != RAW_PART) {
- pp = &cs->sc_label.d_partitions[ccdpart(bp->b_dev)];
- bn += pp->p_offset;
- }
-
- /*
- * Allocate component buffers and fire off the requests
- */
- addr = bp->b_data;
- for (bcount = bp->b_bcount; bcount > 0; bcount -= rcount) {
- ccdbuffer(cbp, cs, bp, bn, addr, bcount);
- rcount = cbp[0]->cb_buf.b_bcount;
-
- if (cs->sc_cflags & CCDF_MIRROR) {
- /*
- * Mirroring. Writes go to both disks, reads are
- * taken from whichever disk seems most appropriate.
- *
- * We attempt to localize reads to the disk whos arm
- * is nearest the read request. We ignore seeks due
- * to writes when making this determination and we
- * also try to avoid hogging.
- */
- if ((cbp[0]->cb_buf.b_flags & B_READ) == 0) {
- cbp[0]->cb_buf.b_vp->v_numoutput++;
- cbp[1]->cb_buf.b_vp->v_numoutput++;
- VOP_STRATEGY(cbp[0]->cb_buf.b_vp,
- &cbp[0]->cb_buf);
- VOP_STRATEGY(cbp[1]->cb_buf.b_vp,
- &cbp[1]->cb_buf);
- } else {
- int pick = cs->sc_pick;
- daddr_t range = cs->sc_size / 16;
-
- if (bn < cs->sc_blk[pick] - range ||
- bn > cs->sc_blk[pick] + range
- ) {
- cs->sc_pick = pick = 1 - pick;
- }
- cs->sc_blk[pick] = bn + btodb(rcount);
- VOP_STRATEGY(cbp[pick]->cb_buf.b_vp,
- &cbp[pick]->cb_buf);
- }
- } else {
- /*
- * Not mirroring
- */
- if ((cbp[0]->cb_buf.b_flags & B_READ) == 0)
- cbp[0]->cb_buf.b_vp->v_numoutput++;
- VOP_STRATEGY(cbp[0]->cb_buf.b_vp, &cbp[0]->cb_buf);
- }
- bn += btodb(rcount);
- addr += rcount;
- }
-}
-
-/*
- * Build a component buffer header.
- */
-static void
-ccdbuffer(cb, cs, bp, bn, addr, bcount)
- struct ccdbuf **cb;
- struct ccd_softc *cs;
- struct buf *bp;
- daddr_t bn;
- caddr_t addr;
- long bcount;
-{
- struct ccdcinfo *ci, *ci2 = NULL; /* XXX */
- struct ccdbuf *cbp;
- daddr_t cbn, cboff;
- off_t cbc;
-
-#ifdef DEBUG
- if (ccddebug & CCDB_IO)
- printf("ccdbuffer(%x, %x, %d, %x, %d)\n",
- cs, bp, bn, addr, bcount);
-#endif
- /*
- * Determine which component bn falls in.
- */
- cbn = bn;
- cboff = 0;
-
- if (cs->sc_ileave == 0) {
- /*
- * Serially concatenated and neither a mirror nor a parity
- * config. This is a special case.
- */
- daddr_t sblk;
-
- sblk = 0;
- for (ci = cs->sc_cinfo; cbn >= sblk + ci->ci_size; ci++)
- sblk += ci->ci_size;
- cbn -= sblk;
- } else {
- struct ccdiinfo *ii;
- int ccdisk, off;
-
- /*
- * Calculate cbn, the logical superblock (sc_ileave chunks),
- * and cboff, a normal block offset (DEV_BSIZE chunks) relative
- * to cbn.
- */
- cboff = cbn % cs->sc_ileave; /* DEV_BSIZE gran */
- cbn = cbn / cs->sc_ileave; /* DEV_BSIZE * ileave gran */
-
- /*
- * Figure out which interleave table to use.
- */
- for (ii = cs->sc_itable; ii->ii_ndisk; ii++) {
- if (ii->ii_startblk > cbn)
- break;
- }
- ii--;
-
- /*
- * off is the logical superblock relative to the beginning
- * of this interleave block.
- */
- off = cbn - ii->ii_startblk;
-
- /*
- * We must calculate which disk component to use (ccdisk),
- * and recalculate cbn to be the superblock relative to
- * the beginning of the component. This is typically done by
- * adding 'off' and ii->ii_startoff together. However, 'off'
- * must typically be divided by the number of components in
- * this interleave array to be properly convert it from a
- * CCD-relative logical superblock number to a
- * component-relative superblock number.
- */
- if (ii->ii_ndisk == 1) {
- /*
- * When we have just one disk, it can't be a mirror
- * or a parity config.
- */
- ccdisk = ii->ii_index[0];
- cbn = ii->ii_startoff + off;
- } else {
- if (cs->sc_cflags & CCDF_MIRROR) {
- /*
- * We have forced a uniform mapping, resulting
- * in a single interleave array. We double
- * up on the first half of the available
- * components and our mirror is in the second
- * half. This only works with a single
- * interleave array because doubling up
- * doubles the number of sectors, so there
- * cannot be another interleave array because
- * the next interleave array's calculations
- * would be off.
- */
- int ndisk2 = ii->ii_ndisk / 2;
- ccdisk = ii->ii_index[off % ndisk2];
- cbn = ii->ii_startoff + off / ndisk2;
- ci2 = &cs->sc_cinfo[ccdisk + ndisk2];
- } else if (cs->sc_cflags & CCDF_PARITY) {
- /*
- * XXX not implemented yet
- */
- int ndisk2 = ii->ii_ndisk - 1;
- ccdisk = ii->ii_index[off % ndisk2];
- cbn = ii->ii_startoff + off / ndisk2;
- if (cbn % ii->ii_ndisk <= ccdisk)
- ccdisk++;
- } else {
- ccdisk = ii->ii_index[off % ii->ii_ndisk];
- cbn = ii->ii_startoff + off / ii->ii_ndisk;
- }
- }
-
- ci = &cs->sc_cinfo[ccdisk];
-
- /*
- * Convert cbn from a superblock to a normal block so it
- * can be used to calculate (along with cboff) the normal
- * block index into this particular disk.
- */
- cbn *= cs->sc_ileave;
- }
-
- /*
- * Fill in the component buf structure.
- */
- cbp = getccdbuf(NULL);
- cbp->cb_buf.b_flags = bp->b_flags | B_CALL;
- cbp->cb_buf.b_iodone = (void (*)(struct buf *))ccdiodone;
- cbp->cb_buf.b_dev = ci->ci_dev; /* XXX */
- cbp->cb_buf.b_blkno = cbn + cboff + CCD_OFFSET;
- cbp->cb_buf.b_offset = dbtob(cbn + cboff + CCD_OFFSET);
- cbp->cb_buf.b_data = addr;
- cbp->cb_buf.b_vp = ci->ci_vp;
- if (cs->sc_ileave == 0)
- cbc = dbtob((off_t)(ci->ci_size - cbn));
- else
- cbc = dbtob((off_t)(cs->sc_ileave - cboff));
- cbp->cb_buf.b_bcount = (cbc < bcount) ? cbc : bcount;
- cbp->cb_buf.b_bufsize = cbp->cb_buf.b_bcount;
-
- /*
- * context for ccdiodone
- */
- cbp->cb_obp = bp;
- cbp->cb_unit = cs - ccd_softc;
- cbp->cb_comp = ci - cs->sc_cinfo;
-
-#ifdef DEBUG
- if (ccddebug & CCDB_IO)
- printf(" dev %x(u%d): cbp %x bn %d addr %x bcnt %d\n",
- ci->ci_dev, ci-cs->sc_cinfo, cbp, cbp->cb_buf.b_blkno,
- cbp->cb_buf.b_data, cbp->cb_buf.b_bcount);
-#endif
- cb[0] = cbp;
-
- /*
- * Note: both I/O's setup when reading from mirror, but only one
- * will be executed.
- */
- if (cs->sc_cflags & CCDF_MIRROR) {
- /* mirror, setup second I/O */
- cbp = getccdbuf(cb[0]);
- cbp->cb_buf.b_dev = ci2->ci_dev;
- cbp->cb_buf.b_vp = ci2->ci_vp;
- cbp->cb_comp = ci2 - cs->sc_cinfo;
- cb[1] = cbp;
- /* link together the ccdbuf's and clear "mirror done" flag */
- cb[0]->cb_mirror = cb[1];
- cb[1]->cb_mirror = cb[0];
- cb[0]->cb_pflags &= ~CCDPF_MIRROR_DONE;
- cb[1]->cb_pflags &= ~CCDPF_MIRROR_DONE;
- }
-}
-
-static void
-ccdintr(cs, bp)
- struct ccd_softc *cs;
- struct buf *bp;
-{
-#ifdef DEBUG
- if (ccddebug & CCDB_FOLLOW)
- printf("ccdintr(%x, %x)\n", cs, bp);
-#endif
- /*
- * Request is done for better or worse, wakeup the top half.
- */
- if (bp->b_flags & B_ERROR)
- bp->b_resid = bp->b_bcount;
- devstat_end_transaction_buf(&cs->device_stats, bp);
- biodone(bp);
-}
-
-/*
- * Called at interrupt time.
- * Mark the component as done and if all components are done,
- * take a ccd interrupt.
- */
-static void
-ccdiodone(cbp)
- struct ccdbuf *cbp;
-{
- struct buf *bp = cbp->cb_obp;
- int unit = cbp->cb_unit;
- int count, s;
-
- s = splbio();
-#ifdef DEBUG
- if (ccddebug & CCDB_FOLLOW)
- printf("ccdiodone(%x)\n", cbp);
- if (ccddebug & CCDB_IO) {
- printf("ccdiodone: bp %x bcount %d resid %d\n",
- bp, bp->b_bcount, bp->b_resid);
- printf(" dev %x(u%d), cbp %x bn %d addr %x bcnt %d\n",
- cbp->cb_buf.b_dev, cbp->cb_comp, cbp,
- cbp->cb_buf.b_blkno, cbp->cb_buf.b_data,
- cbp->cb_buf.b_bcount);
- }
-#endif
- /*
- * If an error occured, report it. If this is a mirrored
- * configuration and the first of two possible reads, do not
- * set the error in the bp yet because the second read may
- * succeed.
- */
-
- if (cbp->cb_buf.b_flags & B_ERROR) {
- const char *msg = "";
-
- if ((ccd_softc[unit].sc_cflags & CCDF_MIRROR) &&
- (cbp->cb_buf.b_flags & B_READ) &&
- (cbp->cb_pflags & CCDPF_MIRROR_DONE) == 0) {
- /*
- * We will try our read on the other disk down
- * below, also reverse the default pick so if we
- * are doing a scan we do not keep hitting the
- * bad disk first.
- */
- struct ccd_softc *cs = &ccd_softc[unit];
-
- msg = ", trying other disk";
- cs->sc_pick = 1 - cs->sc_pick;
- cs->sc_blk[cs->sc_pick] = bp->b_blkno;
- } else {
- bp->b_flags |= B_ERROR;
- bp->b_error = cbp->cb_buf.b_error ?
- cbp->cb_buf.b_error : EIO;
- }
- printf("ccd%d: error %d on component %d block %d (ccd block %d)%s\n",
- unit, bp->b_error, cbp->cb_comp,
- (int)cbp->cb_buf.b_blkno, bp->b_blkno, msg);
- }
-
- /*
- * Process mirror. If we are writing, I/O has been initiated on both
- * buffers and we fall through only after both are finished.
- *
- * If we are reading only one I/O is initiated at a time. If an
- * error occurs we initiate the second I/O and return, otherwise
- * we free the second I/O without initiating it.
- */
-
- if (ccd_softc[unit].sc_cflags & CCDF_MIRROR) {
- if ((cbp->cb_buf.b_flags & B_READ) == 0) {
- /*
- * When writing, handshake with the second buffer
- * to determine when both are done. If both are not
- * done, return here.
- */
- if ((cbp->cb_pflags & CCDPF_MIRROR_DONE) == 0) {
- cbp->cb_mirror->cb_pflags |= CCDPF_MIRROR_DONE;
- putccdbuf(cbp);
- splx(s);
- return;
- }
- } else {
- /*
- * When reading, either dispose of the second buffer
- * or initiate I/O on the second buffer if an error
- * occured with this one.
- */
- if ((cbp->cb_pflags & CCDPF_MIRROR_DONE) == 0) {
- if (cbp->cb_buf.b_flags & B_ERROR) {
- cbp->cb_mirror->cb_pflags |=
- CCDPF_MIRROR_DONE;
- VOP_STRATEGY(
- cbp->cb_mirror->cb_buf.b_vp,
- &cbp->cb_mirror->cb_buf
- );
- putccdbuf(cbp);
- splx(s);
- return;
- } else {
- putccdbuf(cbp->cb_mirror);
- /* fall through */
- }
- }
- }
- }
-
- /*
- * use b_bufsize to determine how big the original request was rather
- * then b_bcount, because b_bcount may have been truncated for EOF.
- *
- * XXX We check for an error, but we do not test the resid for an
- * aligned EOF condition. This may result in character & block
- * device access not recognizing EOF properly when read or written
- * sequentially, but will not effect filesystems.
- */
- count = cbp->cb_buf.b_bufsize;
- putccdbuf(cbp);
-
- /*
- * If all done, "interrupt".
- */
- bp->b_resid -= count;
- if (bp->b_resid < 0)
- panic("ccdiodone: count");
- if (bp->b_resid == 0)
- ccdintr(&ccd_softc[unit], bp);
- splx(s);
-}
-
-static int
-ccdioctl(dev, cmd, data, flag, p)
- dev_t dev;
- u_long cmd;
- caddr_t data;
- int flag;
- struct proc *p;
-{
- int unit = ccdunit(dev);
- int i, j, lookedup = 0, error = 0;
- int part, pmask, s;
- struct ccd_softc *cs;
- struct ccd_ioctl *ccio = (struct ccd_ioctl *)data;
- struct ccddevice ccd;
- char **cpp;
- struct vnode **vpp;
-
- if (unit >= numccd)
- return (ENXIO);
- cs = &ccd_softc[unit];
-
- bzero(&ccd, sizeof(ccd));
-
- switch (cmd) {
- case CCDIOCSET:
- if (cs->sc_flags & CCDF_INITED)
- return (EBUSY);
-
- if ((flag & FWRITE) == 0)
- return (EBADF);
-
- if ((error = ccdlock(cs)) != 0)
- return (error);
-
- /* Fill in some important bits. */
- ccd.ccd_unit = unit;
- ccd.ccd_interleave = ccio->ccio_ileave;
- if (ccd.ccd_interleave == 0 &&
- ((ccio->ccio_flags & CCDF_MIRROR) ||
- (ccio->ccio_flags & CCDF_PARITY))) {
- printf("ccd%d: disabling mirror/parity, interleave is 0\n", unit);
- ccio->ccio_flags &= ~(CCDF_MIRROR | CCDF_PARITY);
- }
- if ((ccio->ccio_flags & CCDF_MIRROR) &&
- (ccio->ccio_flags & CCDF_PARITY)) {
- printf("ccd%d: can't specify both mirror and parity, using mirror\n", unit);
- ccio->ccio_flags &= ~CCDF_PARITY;
- }
- if ((ccio->ccio_flags & (CCDF_MIRROR | CCDF_PARITY)) &&
- !(ccio->ccio_flags & CCDF_UNIFORM)) {
- printf("ccd%d: mirror/parity forces uniform flag\n",
- unit);
- ccio->ccio_flags |= CCDF_UNIFORM;
- }
- ccd.ccd_flags = ccio->ccio_flags & CCDF_USERMASK;
-
- /*
- * Allocate space for and copy in the array of
- * componet pathnames and device numbers.
- */
- cpp = malloc(ccio->ccio_ndisks * sizeof(char *),
- M_DEVBUF, M_WAITOK);
- vpp = malloc(ccio->ccio_ndisks * sizeof(struct vnode *),
- M_DEVBUF, M_WAITOK);
-
- error = copyin((caddr_t)ccio->ccio_disks, (caddr_t)cpp,
- ccio->ccio_ndisks * sizeof(char **));
- if (error) {
- free(vpp, M_DEVBUF);
- free(cpp, M_DEVBUF);
- ccdunlock(cs);
- return (error);
- }
-
-#ifdef DEBUG
- if (ccddebug & CCDB_INIT)
- for (i = 0; i < ccio->ccio_ndisks; ++i)
- printf("ccdioctl: component %d: 0x%x\n",
- i, cpp[i]);
-#endif
-
- for (i = 0; i < ccio->ccio_ndisks; ++i) {
-#ifdef DEBUG
- if (ccddebug & CCDB_INIT)
- printf("ccdioctl: lookedup = %d\n", lookedup);
-#endif
- if ((error = ccdlookup(cpp[i], p, &vpp[i])) != 0) {
- for (j = 0; j < lookedup; ++j)
- (void)vn_close(vpp[j], FREAD|FWRITE,
- p->p_ucred, p);
- free(vpp, M_DEVBUF);
- free(cpp, M_DEVBUF);
- ccdunlock(cs);
- return (error);
- }
- ++lookedup;
- }
- ccd.ccd_cpp = cpp;
- ccd.ccd_vpp = vpp;
- ccd.ccd_ndev = ccio->ccio_ndisks;
-
- /*
- * Initialize the ccd. Fills in the softc for us.
- */
- if ((error = ccdinit(&ccd, cpp, p)) != 0) {
- for (j = 0; j < lookedup; ++j)
- (void)vn_close(vpp[j], FREAD|FWRITE,
- p->p_ucred, p);
- bzero(&ccd_softc[unit], sizeof(struct ccd_softc));
- free(vpp, M_DEVBUF);
- free(cpp, M_DEVBUF);
- ccdunlock(cs);
- return (error);
- }
-
- /*
- * The ccd has been successfully initialized, so
- * we can place it into the array and read the disklabel.
- */
- bcopy(&ccd, &ccddevs[unit], sizeof(ccd));
- ccio->ccio_unit = unit;
- ccio->ccio_size = cs->sc_size;
- ccdgetdisklabel(dev);
-
- ccdunlock(cs);
-
- break;
-
- case CCDIOCCLR:
- if ((cs->sc_flags & CCDF_INITED) == 0)
- return (ENXIO);
-
- if ((flag & FWRITE) == 0)
- return (EBADF);
-
- if ((error = ccdlock(cs)) != 0)
- return (error);
-
- /* Don't unconfigure if any other partitions are open */
- part = ccdpart(dev);
- pmask = (1 << part);
- if ((cs->sc_openmask & ~pmask)) {
- ccdunlock(cs);
- return (EBUSY);
- }
-
- /*
- * Free ccd_softc information and clear entry.
- */
-
- /* Close the components and free their pathnames. */
- for (i = 0; i < cs->sc_nccdisks; ++i) {
- /*
- * XXX: this close could potentially fail and
- * cause Bad Things. Maybe we need to force
- * the close to happen?
- */
-#ifdef DEBUG
- if (ccddebug & CCDB_VNODE)
- vprint("CCDIOCCLR: vnode info",
- cs->sc_cinfo[i].ci_vp);
-#endif
- (void)vn_close(cs->sc_cinfo[i].ci_vp, FREAD|FWRITE,
- p->p_ucred, p);
- free(cs->sc_cinfo[i].ci_path, M_DEVBUF);
- }
-
- /* Free interleave index. */
- for (i = 0; cs->sc_itable[i].ii_ndisk; ++i)
- free(cs->sc_itable[i].ii_index, M_DEVBUF);
-
- /* Free component info and interleave table. */
- free(cs->sc_cinfo, M_DEVBUF);
- free(cs->sc_itable, M_DEVBUF);
- cs->sc_flags &= ~CCDF_INITED;
-
- /*
- * Free ccddevice information and clear entry.
- */
- free(ccddevs[unit].ccd_cpp, M_DEVBUF);
- free(ccddevs[unit].ccd_vpp, M_DEVBUF);
- ccd.ccd_dk = -1;
- bcopy(&ccd, &ccddevs[unit], sizeof(ccd));
-
- /*
- * And remove the devstat entry.
- */
- devstat_remove_entry(&cs->device_stats);
-
- /* This must be atomic. */
- s = splhigh();
- ccdunlock(cs);
- bzero(cs, sizeof(struct ccd_softc));
- splx(s);
-
- break;
-
- case DIOCGDINFO:
- if ((cs->sc_flags & CCDF_INITED) == 0)
- return (ENXIO);
-
- *(struct disklabel *)data = cs->sc_label;
- break;
-
- case DIOCGPART:
- if ((cs->sc_flags & CCDF_INITED) == 0)
- return (ENXIO);
-
- ((struct partinfo *)data)->disklab = &cs->sc_label;
- ((struct partinfo *)data)->part =
- &cs->sc_label.d_partitions[ccdpart(dev)];
- break;
-
- case DIOCWDINFO:
- case DIOCSDINFO:
- if ((cs->sc_flags & CCDF_INITED) == 0)
- return (ENXIO);
-
- if ((flag & FWRITE) == 0)
- return (EBADF);
-
- if ((error = ccdlock(cs)) != 0)
- return (error);
-
- cs->sc_flags |= CCDF_LABELLING;
-
- error = setdisklabel(&cs->sc_label,
- (struct disklabel *)data, 0);
- if (error == 0) {
- if (cmd == DIOCWDINFO)
- error = writedisklabel(CCDLABELDEV(dev),
- &cs->sc_label);
- }
-
- cs->sc_flags &= ~CCDF_LABELLING;
-
- ccdunlock(cs);
-
- if (error)
- return (error);
- break;
-
- case DIOCWLABEL:
- if ((cs->sc_flags & CCDF_INITED) == 0)
- return (ENXIO);
-
- if ((flag & FWRITE) == 0)
- return (EBADF);
- if (*(int *)data != 0)
- cs->sc_flags |= CCDF_WLABEL;
- else
- cs->sc_flags &= ~CCDF_WLABEL;
- break;
-
- default:
- return (ENOTTY);
- }
-
- return (0);
-}
-
-static int
-ccdsize(dev)
- dev_t dev;
-{
- struct ccd_softc *cs;
- int part, size;
-
- if (ccdopen(dev, 0, S_IFCHR, curproc))
- return (-1);
-
- cs = &ccd_softc[ccdunit(dev)];
- part = ccdpart(dev);
-
- if ((cs->sc_flags & CCDF_INITED) == 0)
- return (-1);
-
- if (cs->sc_label.d_partitions[part].p_fstype != FS_SWAP)
- size = -1;
- else
- size = cs->sc_label.d_partitions[part].p_size;
-
- if (ccdclose(dev, 0, S_IFCHR, curproc))
- return (-1);
-
- return (size);
-}
-
-static int
-ccddump(dev)
- dev_t dev;
-{
-
- /* Not implemented. */
- return ENXIO;
-}
-
-/*
- * Lookup the provided name in the filesystem. If the file exists,
- * is a valid block device, and isn't being used by anyone else,
- * set *vpp to the file's vnode.
- */
-static int
-ccdlookup(path, p, vpp)
- char *path;
- struct proc *p;
- struct vnode **vpp; /* result */
-{
- struct nameidata nd;
- struct vnode *vp;
- int error;
-
- NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, path, p);
- if ((error = vn_open(&nd, FREAD|FWRITE, 0)) != 0) {
-#ifdef DEBUG
- if (ccddebug & CCDB_FOLLOW|CCDB_INIT)
- printf("ccdlookup: vn_open error = %d\n", error);
-#endif
- return (error);
- }
- vp = nd.ni_vp;
-
- if (vp->v_usecount > 1) {
- error = EBUSY;
- goto bad;
- }
-
- if (!vn_isdisk(vp, &error))
- goto bad;
-
-#ifdef DEBUG
- if (ccddebug & CCDB_VNODE)
- vprint("ccdlookup: vnode info", vp);
-#endif
-
- VOP_UNLOCK(vp, 0, p);
- NDFREE(&nd, NDF_ONLY_PNBUF);
- *vpp = vp;
- return (0);
-bad:
- VOP_UNLOCK(vp, 0, p);
- NDFREE(&nd, NDF_ONLY_PNBUF);
- /* vn_close does vrele() for vp */
- (void)vn_close(vp, FREAD|FWRITE, p->p_ucred, p);
- return (error);
-}
-
-/*
- * Read the disklabel from the ccd. If one is not present, fake one
- * up.
- */
-static void
-ccdgetdisklabel(dev)
- dev_t dev;
-{
- int unit = ccdunit(dev);
- struct ccd_softc *cs = &ccd_softc[unit];
- char *errstring;
- struct disklabel *lp = &cs->sc_label;
- struct ccdgeom *ccg = &cs->sc_geom;
-
- bzero(lp, sizeof(*lp));
-
- lp->d_secperunit = cs->sc_size;
- lp->d_secsize = ccg->ccg_secsize;
- lp->d_nsectors = ccg->ccg_nsectors;
- lp->d_ntracks = ccg->ccg_ntracks;
- lp->d_ncylinders = ccg->ccg_ncylinders;
- lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors;
-
- strncpy(lp->d_typename, "ccd", sizeof(lp->d_typename));
- lp->d_type = DTYPE_CCD;
- strncpy(lp->d_packname, "fictitious", sizeof(lp->d_packname));
- lp->d_rpm = 3600;
- lp->d_interleave = 1;
- lp->d_flags = 0;
-
- lp->d_partitions[RAW_PART].p_offset = 0;
- lp->d_partitions[RAW_PART].p_size = cs->sc_size;
- lp->d_partitions[RAW_PART].p_fstype = FS_UNUSED;
- lp->d_npartitions = RAW_PART + 1;
-
- lp->d_bbsize = BBSIZE; /* XXX */
- lp->d_sbsize = SBSIZE; /* XXX */
-
- lp->d_magic = DISKMAGIC;
- lp->d_magic2 = DISKMAGIC;
- lp->d_checksum = dkcksum(&cs->sc_label);
-
- /*
- * Call the generic disklabel extraction routine.
- */
- errstring = readdisklabel(CCDLABELDEV(dev), &cs->sc_label);
- if (errstring != NULL)
- ccdmakedisklabel(cs);
-
-#ifdef DEBUG
- /* It's actually extremely common to have unlabeled ccds. */
- if (ccddebug & CCDB_LABEL)
- if (errstring != NULL)
- printf("ccd%d: %s\n", unit, errstring);
-#endif
-}
-
-/*
- * Take care of things one might want to take care of in the event
- * that a disklabel isn't present.
- */
-static void
-ccdmakedisklabel(cs)
- struct ccd_softc *cs;
-{
- struct disklabel *lp = &cs->sc_label;
-
- /*
- * For historical reasons, if there's no disklabel present
- * the raw partition must be marked FS_BSDFFS.
- */
- lp->d_partitions[RAW_PART].p_fstype = FS_BSDFFS;
-
- strncpy(lp->d_packname, "default label", sizeof(lp->d_packname));
-}
-
-/*
- * Wait interruptibly for an exclusive lock.
- *
- * XXX
- * Several drivers do this; it should be abstracted and made MP-safe.
- */
-static int
-ccdlock(cs)
- struct ccd_softc *cs;
-{
- int error;
-
- while ((cs->sc_flags & CCDF_LOCKED) != 0) {
- cs->sc_flags |= CCDF_WANTED;
- if ((error = tsleep(cs, PRIBIO | PCATCH, "ccdlck", 0)) != 0)
- return (error);
- }
- cs->sc_flags |= CCDF_LOCKED;
- return (0);
-}
-
-/*
- * Unlock and wake up any waiters.
- */
-static void
-ccdunlock(cs)
- struct ccd_softc *cs;
-{
-
- cs->sc_flags &= ~CCDF_LOCKED;
- if ((cs->sc_flags & CCDF_WANTED) != 0) {
- cs->sc_flags &= ~CCDF_WANTED;
- wakeup(cs);
- }
-}
-
-#ifdef DEBUG
-static void
-printiinfo(ii)
- struct ccdiinfo *ii;
-{
- int ix, i;
-
- for (ix = 0; ii->ii_ndisk; ix++, ii++) {
- printf(" itab[%d]: #dk %d sblk %d soff %d",
- ix, ii->ii_ndisk, ii->ii_startblk, ii->ii_startoff);
- for (i = 0; i < ii->ii_ndisk; i++)
- printf(" %d", ii->ii_index[i]);
- printf("\n");
- }
-}
-#endif
-
-
-/* Local Variables: */
-/* c-argdecl-indent: 8 */
-/* c-continued-statement-offset: 8 */
-/* c-indent-level: 8 */
-/* End: */
diff --git a/sys/gnu/ext2fs/ext2_bmap.c b/sys/gnu/ext2fs/ext2_bmap.c
deleted file mode 100644
index 14ef56ef8b4b..000000000000
--- a/sys/gnu/ext2fs/ext2_bmap.c
+++ /dev/null
@@ -1,320 +0,0 @@
-/*
- * Copyright (c) 1989, 1991, 1993
- * The Regents of the University of California. All rights reserved.
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)ufs_bmap.c 8.7 (Berkeley) 3/21/95
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/buf.h>
-#include <sys/proc.h>
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <sys/resourcevar.h>
-#include <sys/conf.h>
-
-#include <ufs/ufs/quota.h>
-#include <ufs/ufs/inode.h>
-#include <ufs/ufs/ufsmount.h>
-#include <ufs/ufs/ufs_extern.h>
-
-/*
- * Bmap converts a the logical block number of a file to its physical block
- * number on the disk. The conversion is done by using the logical block
- * number to index into the array of block pointers described by the dinode.
- */
-int
-ufs_bmap(ap)
- struct vop_bmap_args /* {
- struct vnode *a_vp;
- ufs_daddr_t a_bn;
- struct vnode **a_vpp;
- ufs_daddr_t *a_bnp;
- int *a_runp;
- int *a_runb;
- } */ *ap;
-{
- /*
- * Check for underlying vnode requests and ensure that logical
- * to physical mapping is requested.
- */
- if (ap->a_vpp != NULL)
- *ap->a_vpp = VTOI(ap->a_vp)->i_devvp;
- if (ap->a_bnp == NULL)
- return (0);
-
- return (ufs_bmaparray(ap->a_vp, ap->a_bn, ap->a_bnp, NULL, NULL,
- ap->a_runp, ap->a_runb));
-}
-
-/*
- * Indirect blocks are now on the vnode for the file. They are given negative
- * logical block numbers. Indirect blocks are addressed by the negative
- * address of the first data block to which they point. Double indirect blocks
- * are addressed by one less than the address of the first indirect block to
- * which they point. Triple indirect blocks are addressed by one less than
- * the address of the first double indirect block to which they point.
- *
- * ufs_bmaparray does the bmap conversion, and if requested returns the
- * array of logical blocks which must be traversed to get to a block.
- * Each entry contains the offset into that block that gets you to the
- * next block and the disk address of the block (if it is assigned).
- */
-
-int
-ufs_bmaparray(vp, bn, bnp, ap, nump, runp, runb)
- struct vnode *vp;
- ufs_daddr_t bn;
- ufs_daddr_t *bnp;
- struct indir *ap;
- int *nump;
- int *runp;
- int *runb;
-{
- register struct inode *ip;
- struct buf *bp;
- struct ufsmount *ump;
- struct mount *mp;
- struct vnode *devvp;
- struct indir a[NIADDR+1], *xap;
- ufs_daddr_t daddr;
- long metalbn;
- int error, maxrun, num;
-
- ip = VTOI(vp);
- mp = vp->v_mount;
- ump = VFSTOUFS(mp);
- devvp = ump->um_devvp;
-#ifdef DIAGNOSTIC
- if ((ap != NULL && nump == NULL) || (ap == NULL && nump != NULL))
- panic("ufs_bmaparray: invalid arguments");
-#endif
-
- if (runp) {
- *runp = 0;
- }
-
- if (runb) {
- *runb = 0;
- }
-
- maxrun = mp->mnt_iosize_max / mp->mnt_stat.f_iosize - 1;
-
- xap = ap == NULL ? a : ap;
- if (!nump)
- nump = &num;
- error = ufs_getlbns(vp, bn, xap, nump);
- if (error)
- return (error);
-
- num = *nump;
- if (num == 0) {
- *bnp = blkptrtodb(ump, ip->i_db[bn]);
- if (*bnp == 0)
- *bnp = -1;
- else if (runp) {
- daddr_t bnb = bn;
- for (++bn; bn < NDADDR && *runp < maxrun &&
- is_sequential(ump, ip->i_db[bn - 1], ip->i_db[bn]);
- ++bn, ++*runp);
- bn = bnb;
- if (runb && (bn > 0)) {
- for (--bn; (bn >= 0) && (*runb < maxrun) &&
- is_sequential(ump, ip->i_db[bn],
- ip->i_db[bn+1]);
- --bn, ++*runb);
- }
- }
- return (0);
- }
-
-
- /* Get disk address out of indirect block array */
- daddr = ip->i_ib[xap->in_off];
-
- for (bp = NULL, ++xap; --num; ++xap) {
- /*
- * Exit the loop if there is no disk address assigned yet and
- * the indirect block isn't in the cache, or if we were
- * looking for an indirect block and we've found it.
- */
-
- metalbn = xap->in_lbn;
- if ((daddr == 0 && !incore(vp, metalbn)) || metalbn == bn)
- break;
- /*
- * If we get here, we've either got the block in the cache
- * or we have a disk address for it, go fetch it.
- */
- if (bp)
- bqrelse(bp);
-
- xap->in_exists = 1;
- bp = getblk(vp, metalbn, mp->mnt_stat.f_iosize, 0, 0);
- if ((bp->b_flags & B_CACHE) == 0) {
-#ifdef DIAGNOSTIC
- if (!daddr)
- panic("ufs_bmaparray: indirect block not in cache");
-#endif
- bp->b_blkno = blkptrtodb(ump, daddr);
- bp->b_flags |= B_READ;
- bp->b_flags &= ~(B_INVAL|B_ERROR);
- vfs_busy_pages(bp, 0);
- VOP_STRATEGY(bp->b_vp, bp);
- curproc->p_stats->p_ru.ru_inblock++; /* XXX */
- error = biowait(bp);
- if (error) {
- brelse(bp);
- return (error);
- }
- }
-
- daddr = ((ufs_daddr_t *)bp->b_data)[xap->in_off];
- if (num == 1 && daddr && runp) {
- for (bn = xap->in_off + 1;
- bn < MNINDIR(ump) && *runp < maxrun &&
- is_sequential(ump,
- ((ufs_daddr_t *)bp->b_data)[bn - 1],
- ((ufs_daddr_t *)bp->b_data)[bn]);
- ++bn, ++*runp);
- bn = xap->in_off;
- if (runb && bn) {
- for(--bn; bn > 0 && *runb < maxrun &&
- is_sequential(ump, ((daddr_t *)bp->b_data)[bn],
- ((daddr_t *)bp->b_data)[bn+1]);
- --bn, ++*runb);
- }
- }
- }
- if (bp)
- bqrelse(bp);
-
- daddr = blkptrtodb(ump, daddr);
- *bnp = daddr == 0 ? -1 : daddr;
- return (0);
-}
-
-/*
- * Create an array of logical block number/offset pairs which represent the
- * path of indirect blocks required to access a data block. The first "pair"
- * contains the logical block number of the appropriate single, double or
- * triple indirect block and the offset into the inode indirect block array.
- * Note, the logical block number of the inode single/double/triple indirect
- * block appears twice in the array, once with the offset into the i_ib and
- * once with the offset into the page itself.
- */
-int
-ufs_getlbns(vp, bn, ap, nump)
- struct vnode *vp;
- ufs_daddr_t bn;
- struct indir *ap;
- int *nump;
-{
- long blockcnt, metalbn, realbn;
- struct ufsmount *ump;
- int i, numlevels, off;
- int64_t qblockcnt;
-
- ump = VFSTOUFS(vp->v_mount);
- if (nump)
- *nump = 0;
- numlevels = 0;
- realbn = bn;
- if ((long)bn < 0)
- bn = -(long)bn;
-
- /* The first NDADDR blocks are direct blocks. */
- if (bn < NDADDR)
- return (0);
-
- /*
- * Determine the number of levels of indirection. After this loop
- * is done, blockcnt indicates the number of data blocks possible
- * at the previous level of indirection, and NIADDR - i is the number
- * of levels of indirection needed to locate the requested block.
- */
- for (blockcnt = 1, i = NIADDR, bn -= NDADDR;; i--, bn -= blockcnt) {
- if (i == 0)
- return (EFBIG);
- /*
- * Use int64_t's here to avoid overflow for triple indirect
- * blocks when longs have 32 bits and the block size is more
- * than 4K.
- */
- qblockcnt = (int64_t)blockcnt * MNINDIR(ump);
- if (bn < qblockcnt)
- break;
- blockcnt = qblockcnt;
- }
-
- /* Calculate the address of the first meta-block. */
- if (realbn >= 0)
- metalbn = -(realbn - bn + NIADDR - i);
- else
- metalbn = -(-realbn - bn + NIADDR - i);
-
- /*
- * At each iteration, off is the offset into the bap array which is
- * an array of disk addresses at the current level of indirection.
- * The logical block number and the offset in that block are stored
- * into the argument array.
- */
- ap->in_lbn = metalbn;
- ap->in_off = off = NIADDR - i;
- ap->in_exists = 0;
- ap++;
- for (++numlevels; i <= NIADDR; i++) {
- /* If searching for a meta-data block, quit when found. */
- if (metalbn == realbn)
- break;
-
- off = (bn / blockcnt) % MNINDIR(ump);
-
- ++numlevels;
- ap->in_lbn = metalbn;
- ap->in_off = off;
- ap->in_exists = 0;
- ++ap;
-
- metalbn -= -1 + off * blockcnt;
- blockcnt /= MNINDIR(ump);
- }
- if (nump)
- *nump = numlevels;
- return (0);
-}
diff --git a/sys/gnu/ext2fs/ext2_ihash.c b/sys/gnu/ext2fs/ext2_ihash.c
deleted file mode 100644
index 0a7c7d583191..000000000000
--- a/sys/gnu/ext2fs/ext2_ihash.c
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright (c) 1982, 1986, 1989, 1991, 1993, 1995
- * 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)ufs_ihash.c 8.7 (Berkeley) 5/17/95
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/lock.h>
-#include <sys/vnode.h>
-#include <sys/malloc.h>
-#include <sys/proc.h>
-
-#include <ufs/ufs/quota.h>
-#include <ufs/ufs/inode.h>
-#include <ufs/ufs/ufs_extern.h>
-
-static MALLOC_DEFINE(M_UFSIHASH, "UFS ihash", "UFS Inode hash tables");
-/*
- * Structures associated with inode cacheing.
- */
-static LIST_HEAD(ihashhead, inode) *ihashtbl;
-static u_long ihash; /* size of hash table - 1 */
-#define INOHASH(device, inum) (&ihashtbl[(minor(device) + (inum)) & ihash])
-#ifndef NULL_SIMPLELOCKS
-static struct simplelock ufs_ihash_slock;
-#endif
-
-/*
- * Initialize inode hash table.
- */
-void
-ufs_ihashinit()
-{
-
- ihashtbl = hashinit(desiredvnodes, M_UFSIHASH, &ihash);
- simple_lock_init(&ufs_ihash_slock);
-}
-
-/*
- * Use the device/inum pair to find the incore inode, and return a pointer
- * to it. If it is in core, return it, even if it is locked.
- */
-struct vnode *
-ufs_ihashlookup(dev, inum)
- dev_t dev;
- ino_t inum;
-{
- struct inode *ip;
-
- simple_lock(&ufs_ihash_slock);
- for (ip = INOHASH(dev, inum)->lh_first; ip; ip = ip->i_hash.le_next)
- if (inum == ip->i_number && dev == ip->i_dev)
- break;
- simple_unlock(&ufs_ihash_slock);
-
- if (ip)
- return (ITOV(ip));
- return (NULLVP);
-}
-
-/*
- * Use the device/inum pair to find the incore inode, and return a pointer
- * to it. If it is in core, but locked, wait for it.
- */
-struct vnode *
-ufs_ihashget(dev, inum)
- dev_t dev;
- ino_t inum;
-{
- struct proc *p = curproc; /* XXX */
- struct inode *ip;
- struct vnode *vp;
-
-loop:
- simple_lock(&ufs_ihash_slock);
- for (ip = INOHASH(dev, inum)->lh_first; ip; ip = ip->i_hash.le_next) {
- if (inum == ip->i_number && dev == ip->i_dev) {
- vp = ITOV(ip);
- simple_lock(&vp->v_interlock);
- simple_unlock(&ufs_ihash_slock);
- if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, p))
- goto loop;
- return (vp);
- }
- }
- simple_unlock(&ufs_ihash_slock);
- return (NULL);
-}
-
-/*
- * Insert the inode into the hash table, and return it locked.
- */
-void
-ufs_ihashins(ip)
- struct inode *ip;
-{
- struct proc *p = curproc; /* XXX */
- struct ihashhead *ipp;
-
- /* lock the inode, then put it on the appropriate hash list */
- lockmgr(&ip->i_lock, LK_EXCLUSIVE, (struct simplelock *)0, p);
-
- simple_lock(&ufs_ihash_slock);
- ipp = INOHASH(ip->i_dev, ip->i_number);
- LIST_INSERT_HEAD(ipp, ip, i_hash);
- ip->i_flag |= IN_HASHED;
- simple_unlock(&ufs_ihash_slock);
-}
-
-/*
- * Remove the inode from the hash table.
- */
-void
-ufs_ihashrem(ip)
- struct inode *ip;
-{
- simple_lock(&ufs_ihash_slock);
- if (ip->i_flag & IN_HASHED) {
- ip->i_flag &= ~IN_HASHED;
- LIST_REMOVE(ip, i_hash);
-#ifdef DIAGNOSTIC
- ip->i_hash.le_next = NULL;
- ip->i_hash.le_prev = NULL;
-#endif
- }
- simple_unlock(&ufs_ihash_slock);
-}
diff --git a/sys/gnu/ext2fs/ext2_mount.h b/sys/gnu/ext2fs/ext2_mount.h
deleted file mode 100644
index 065254521408..000000000000
--- a/sys/gnu/ext2fs/ext2_mount.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (c) 1982, 1986, 1989, 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)ufsmount.h 8.6 (Berkeley) 3/30/95
- * $FreeBSD$
- */
-
-#ifndef _UFS_UFS_UFSMOUNT_H_
-#define _UFS_UFS_UFSMOUNT_H_
-
-/*
- * Arguments to mount UFS-based filesystems
- */
-struct ufs_args {
- char *fspec; /* block special device to mount */
- struct export_args export; /* network export information */
-};
-
-/*
- * Arguments to mount MFS
- */
-struct mfs_args {
- char *fspec; /* name to export for statfs */
- struct export_args export; /* if exported MFSes are supported */
- caddr_t base; /* base of file system in memory */
- u_long size; /* size of file system */
-};
-
-#ifdef _KERNEL
-
-#ifdef MALLOC_DECLARE
-MALLOC_DECLARE(M_UFSMNT);
-#endif
-
-struct buf;
-struct inode;
-struct nameidata;
-struct timeval;
-struct ucred;
-struct uio;
-struct vnode;
-struct netexport;
-
-/* This structure describes the UFS specific mount structure data. */
-struct ufsmount {
- struct mount *um_mountp; /* filesystem vfs structure */
- dev_t um_dev; /* device mounted */
- struct vnode *um_devvp; /* block device mounted vnode */
-
- union { /* pointer to superblock */
- struct fs *fs; /* FFS */
- struct ext2_sb_info *e2fs; /* EXT2FS */
- } ufsmount_u;
-#define um_fs ufsmount_u.fs
-#define um_e2fs ufsmount_u.e2fs
-#define um_e2fsb ufsmount_u.e2fs->s_es
-
- struct vnode *um_quotas[MAXQUOTAS]; /* pointer to quota files */
- struct ucred *um_cred[MAXQUOTAS]; /* quota file access cred */
- u_long um_nindir; /* indirect ptrs per block */
- u_long um_bptrtodb; /* indir ptr to disk block */
- u_long um_seqinc; /* inc between seq blocks */
- time_t um_btime[MAXQUOTAS]; /* block quota time limit */
- time_t um_itime[MAXQUOTAS]; /* inode quota time limit */
- char um_qflags[MAXQUOTAS]; /* quota specific flags */
- struct netexport um_export; /* export information */
- int64_t um_savedmaxfilesize; /* XXX - limit maxfilesize */
- struct malloc_type *um_malloctype; /* The inodes malloctype */
- int um_i_effnlink_valid; /* i_effnlink valid? */
- int (*um_blkatoff) __P((struct vnode *, off_t, char **, struct buf **));
- int (*um_truncate) __P((struct vnode *, off_t, int, struct ucred *, struct proc *));
- int (*um_update) __P((struct vnode *, int));
- int (*um_valloc) __P((struct vnode *, int, struct ucred *, struct vnode **));
- int (*um_vfree) __P((struct vnode *, ino_t, int));
-};
-
-#define UFS_BLKATOFF(aa, bb, cc, dd) VFSTOUFS((aa)->v_mount)->um_blkatoff(aa, bb, cc, dd)
-#define UFS_TRUNCATE(aa, bb, cc, dd, ee) VFSTOUFS((aa)->v_mount)->um_truncate(aa, bb, cc, dd, ee)
-#define UFS_UPDATE(aa, bb) VFSTOUFS((aa)->v_mount)->um_update(aa, bb)
-#define UFS_VALLOC(aa, bb, cc, dd) VFSTOUFS((aa)->v_mount)->um_valloc(aa, bb, cc, dd)
-#define UFS_VFREE(aa, bb, cc) VFSTOUFS((aa)->v_mount)->um_vfree(aa, bb, cc)
-
-/*
- * Flags describing the state of quotas.
- */
-#define QTF_OPENING 0x01 /* Q_QUOTAON in progress */
-#define QTF_CLOSING 0x02 /* Q_QUOTAOFF in progress */
-
-/* Convert mount ptr to ufsmount ptr. */
-#define VFSTOUFS(mp) ((struct ufsmount *)((mp)->mnt_data))
-
-/*
- * Macros to access file system parameters in the ufsmount structure.
- * Used by ufs_bmap.
- */
-#define MNINDIR(ump) ((ump)->um_nindir)
-#define blkptrtodb(ump, b) ((b) << (ump)->um_bptrtodb)
-#define is_sequential(ump, a, b) ((b) == (a) + ump->um_seqinc)
-#endif /* _KERNEL */
-
-#endif
diff --git a/sys/gnu/ext2fs/inode.h b/sys/gnu/ext2fs/inode.h
deleted file mode 100644
index 83960b0d20f3..000000000000
--- a/sys/gnu/ext2fs/inode.h
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright (c) 1982, 1989, 1993
- * The Regents of the University of California. All rights reserved.
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)inode.h 8.9 (Berkeley) 5/14/95
- * $FreeBSD$
- */
-
-#ifndef _UFS_UFS_INODE_H_
-#define _UFS_UFS_INODE_H_
-
-#include <sys/lock.h>
-#include <sys/queue.h>
-#include <ufs/ufs/dinode.h>
-
-/*
- * The size of a logical block number.
- */
-typedef long ufs_lbn_t;
-
-/*
- * This must agree with the definition in <ufs/ufs/dir.h>.
- */
-#define doff_t int32_t
-
-/*
- * The inode is used to describe each active (or recently active) file in the
- * UFS filesystem. It is composed of two types of information. The first part
- * is the information that is needed only while the file is active (such as
- * the identity of the file and linkage to speed its lookup). The second part
- * is the permanent meta-data associated with the file which is read in
- * from the permanent dinode from long term storage when the file becomes
- * active, and is put back when the file is no longer being used.
- */
-struct inode {
- struct lock i_lock; /* Inode lock. >Keep this first< */
- LIST_ENTRY(inode) i_hash;/* Hash chain. */
- struct vnode *i_vnode;/* Vnode associated with this inode. */
- struct vnode *i_devvp;/* Vnode for block I/O. */
- u_int32_t i_flag; /* flags, see below */
- dev_t i_dev; /* Device associated with the inode. */
- ino_t i_number; /* The identity of the inode. */
- int i_effnlink; /* i_nlink when I/O completes */
-
- union { /* Associated filesystem. */
- struct fs *fs; /* FFS */
- struct ext2_sb_info *e2fs; /* EXT2FS */
- } inode_u;
-#define i_fs inode_u.fs
-#define i_e2fs inode_u.e2fs
- struct dquot *i_dquot[MAXQUOTAS]; /* Dquot structures. */
- u_quad_t i_modrev; /* Revision level for NFS lease. */
- struct lockf *i_lockf;/* Head of byte-level lock list. */
- /*
- * Side effects; used during directory lookup.
- */
- int32_t i_count; /* Size of free slot in directory. */
- doff_t i_endoff; /* End of useful stuff in directory. */
- doff_t i_diroff; /* Offset in dir, where we found last entry. */
- doff_t i_offset; /* Offset of free space in directory. */
- ino_t i_ino; /* Inode number of found directory. */
- u_int32_t i_reclen; /* Size of found directory entry. */
- u_int32_t i_spare[4]; /* XXX actually non-spare (for ext2fs). */
- /*
- * The on-disk dinode itself.
- */
- struct dinode i_din; /* 128 bytes of the on-disk dinode. */
-};
-
-#define i_atime i_din.di_atime
-#define i_atimensec i_din.di_atimensec
-#define i_blocks i_din.di_blocks
-#define i_ctime i_din.di_ctime
-#define i_ctimensec i_din.di_ctimensec
-#define i_db i_din.di_db
-#define i_flags i_din.di_flags
-#define i_gen i_din.di_gen
-#define i_gid i_din.di_gid
-#define i_ib i_din.di_ib
-#define i_mode i_din.di_mode
-#define i_mtime i_din.di_mtime
-#define i_mtimensec i_din.di_mtimensec
-#define i_nlink i_din.di_nlink
-#define i_rdev i_din.di_rdev
-#define i_shortlink i_din.di_shortlink
-#define i_size i_din.di_size
-#define i_uid i_din.di_uid
-
-/* These flags are kept in i_flag. */
-#define IN_ACCESS 0x0001 /* Access time update request. */
-#define IN_CHANGE 0x0002 /* Inode change time update request. */
-#define IN_UPDATE 0x0004 /* Modification time update request. */
-#define IN_MODIFIED 0x0008 /* Inode has been modified. */
-#define IN_RENAME 0x0010 /* Inode is being renamed. */
-#define IN_SHLOCK 0x0020 /* File has shared lock. */
-#define IN_EXLOCK 0x0040 /* File has exclusive lock. */
-#define IN_HASHED 0x0080 /* Inode is on hash list */
-#define IN_LAZYMOD 0x0100 /* Modified, but don't write yet. */
-
-#ifdef _KERNEL
-/*
- * Structure used to pass around logical block paths generated by
- * ufs_getlbns and used by truncate and bmap code.
- */
-struct indir {
- ufs_daddr_t in_lbn; /* Logical block number. */
- int in_off; /* Offset in buffer. */
- int in_exists; /* Flag if the block exists. */
-};
-
-/* Convert between inode pointers and vnode pointers. */
-#define VTOI(vp) ((struct inode *)(vp)->v_data)
-#define ITOV(ip) ((ip)->i_vnode)
-
-/* Determine if soft dependencies are being done */
-#define DOINGSOFTDEP(vp) ((vp)->v_mount->mnt_flag & MNT_SOFTDEP)
-#define DOINGASYNC(vp) ((vp)->v_mount->mnt_flag & MNT_ASYNC)
-
-/* This overlays the fid structure (see mount.h). */
-struct ufid {
- u_int16_t ufid_len; /* Length of structure. */
- u_int16_t ufid_pad; /* Force 32-bit alignment. */
- ino_t ufid_ino; /* File number (ino). */
- int32_t ufid_gen; /* Generation number. */
-};
-#endif /* _KERNEL */
-
-#endif /* !_UFS_UFS_INODE_H_ */
diff --git a/sys/gnu/fs/ext2fs/COPYRIGHT.INFO b/sys/gnu/fs/ext2fs/COPYRIGHT.INFO
deleted file mode 100644
index 699f519c02a8..000000000000
--- a/sys/gnu/fs/ext2fs/COPYRIGHT.INFO
+++ /dev/null
@@ -1,35 +0,0 @@
-$FreeBSD$
-
-Most of the files in this directory are written by Godmar Back or modified
-by him using the CSRG sources. Those files are covered by the Berkeley-style
-copyright. However the following files are covered by GPL. Since the policy
-of the FreeBSD project is to keep the files with the more restrictive
-copyright in the gnu tree and it is a good idea to keep the filesystem code
-all together, the EXT2FS in its entirety resides under the gnu tree. Note
-that only the files below are under the GPL. In the eventuality that these
-files are redesigned or rewritten, this tree can be moved back into the less
-restrictive FreeBSD tree.
-
- ext2_bitmap.c (in the cvs attic)
- ext2_fs.h
- ext2_fs_i.h
- ext2_fs_sb.h
- ext2_linux_balloc.c
- ext2_linux_ialloc.c
- ext2_super.c (in the cvs attic)
- ext2_vfsops.c (has some GPL'ed code from ext2_super.c)
- i386-bitops.h
-
-PS.
- THANKS GODMAR!!!
-
-Note that this port has been modified by John Dyson and others on
-the FreeBSD team, and it is best to send the bug reports to the FreeBSD
-team. If there are any non-FreeBSD specific bugs, fixes will be sent to
-Godmar to help him fix the original code base. It is also our intention
-to send Godmar any FreeBSD specific porting changes so that he can keep
-control of his code....
-
-John
-dyson@freebsd.org
-
diff --git a/sys/gnu/fs/ext2fs/ext2_alloc.c b/sys/gnu/fs/ext2fs/ext2_alloc.c
deleted file mode 100644
index bafcee51cf94..000000000000
--- a/sys/gnu/fs/ext2fs/ext2_alloc.c
+++ /dev/null
@@ -1,555 +0,0 @@
-/*
- * modified for Lites 1.1
- *
- * Aug 1995, Godmar Back (gback@cs.utah.edu)
- * University of Utah, Department of Computer Science
- */
-/*
- * Copyright (c) 1982, 1986, 1989, 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)ext2_alloc.c 8.8 (Berkeley) 2/21/94
- */
-
-#include "opt_quota.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/conf.h>
-#include <sys/vnode.h>
-#include <sys/stat.h>
-#include <sys/mount.h>
-#include <sys/syslog.h>
-
-#include <ufs/ufs/quota.h>
-#include <ufs/ufs/inode.h>
-#include <ufs/ufs/ufsmount.h>
-
-#include <gnu/ext2fs/ext2_fs.h>
-#include <gnu/ext2fs/ext2_fs_sb.h>
-#include <gnu/ext2fs/fs.h>
-#include <gnu/ext2fs/ext2_extern.h>
-
-static void ext2_fserr __P((struct ext2_sb_info *, u_int, char *));
-
-/*
- * Linux calls this functions at the following locations:
- * (1) the inode is freed
- * (2) a preallocation miss occurs
- * (3) truncate is called
- * (4) release_file is called and f_mode & 2
- *
- * I call it in ext2_inactive, ext2_truncate, ext2_vfree and in (2)
- * the call in vfree might be redundant
- */
-void
-ext2_discard_prealloc(ip)
- struct inode * ip;
-{
-#ifdef EXT2_PREALLOCATE
- if (ip->i_prealloc_count) {
- int i = ip->i_prealloc_count;
- ip->i_prealloc_count = 0;
- ext2_free_blocks (ITOV(ip)->v_mount,
- ip->i_prealloc_block,
- i);
- }
-#endif
-}
-
-/*
- * Allocate a block in the file system.
- *
- * this takes the framework from ffs_alloc. To implement the
- * actual allocation, it calls ext2_new_block, the ported version
- * of the same Linux routine.
- *
- * we note that this is always called in connection with ext2_blkpref
- *
- * preallocation is done as Linux does it
- */
-int
-ext2_alloc(ip, lbn, bpref, size, cred, bnp)
- register struct inode *ip;
- daddr_t lbn, bpref;
- int size;
- struct ucred *cred;
- daddr_t *bnp;
-{
- register struct ext2_sb_info *fs;
- daddr_t bno;
-#if QUOTA
- int error;
-#endif
-
- *bnp = 0;
- fs = ip->i_e2fs;
-#if DIAGNOSTIC
- if ((u_int)size > fs->s_blocksize || blkoff(fs, size) != 0) {
- printf("dev = %s, bsize = %lu, size = %d, fs = %s\n",
- devtoname(ip->i_dev), fs->s_blocksize, size, fs->fs_fsmnt);
- panic("ext2_alloc: bad size");
- }
- if (cred == NOCRED)
- panic("ext2_alloc: missing credential");
-#endif /* DIAGNOSTIC */
- if (size == fs->s_blocksize && fs->s_es->s_free_blocks_count == 0)
- goto nospace;
- if (cred->cr_uid != 0 &&
- fs->s_es->s_free_blocks_count < fs->s_es->s_r_blocks_count)
- goto nospace;
-#if QUOTA
- if ((error = chkdq(ip, (long)btodb(size), cred, 0)) != 0)
- return (error);
-#endif
- if (bpref >= fs->s_es->s_blocks_count)
- bpref = 0;
- /* call the Linux code */
-#ifdef EXT2_PREALLOCATE
- /* To have a preallocation hit, we must
- * - have at least one block preallocated
- * - and our preferred block must have that block number or one below
- */
- if (ip->i_prealloc_count &&
- (bpref == ip->i_prealloc_block ||
- bpref + 1 == ip->i_prealloc_block))
- {
- bno = ip->i_prealloc_block++;
- ip->i_prealloc_count--;
- /* ext2_debug ("preallocation hit (%lu/%lu).\n",
- ++alloc_hits, ++alloc_attempts); */
-
- /* Linux gets, clears, and releases the buffer at this
- point - we don't have to that; we leave it to the caller
- */
- } else {
- ext2_discard_prealloc (ip);
- /* ext2_debug ("preallocation miss (%lu/%lu).\n",
- alloc_hits, ++alloc_attempts); */
- if (S_ISREG(ip->i_mode))
- bno = ext2_new_block
- (ITOV(ip)->v_mount, bpref,
- &ip->i_prealloc_count,
- &ip->i_prealloc_block);
- else
- bno = (daddr_t)ext2_new_block(ITOV(ip)->v_mount,
- bpref, 0, 0);
- }
-#else
- bno = (daddr_t)ext2_new_block(ITOV(ip)->v_mount, bpref, 0, 0);
-#endif
-
- if (bno > 0) {
- /* set next_alloc fields as done in block_getblk */
- ip->i_next_alloc_block = lbn;
- ip->i_next_alloc_goal = bno;
-
- ip->i_blocks += btodb(size);
- ip->i_flag |= IN_CHANGE | IN_UPDATE;
- *bnp = bno;
- return (0);
- }
-#if QUOTA
- /*
- * Restore user's disk quota because allocation failed.
- */
- (void) chkdq(ip, (long)-btodb(size), cred, FORCE);
-#endif
-nospace:
- ext2_fserr(fs, cred->cr_uid, "file system full");
- uprintf("\n%s: write failed, file system is full\n", fs->fs_fsmnt);
- return (ENOSPC);
-}
-
-/*
- * Reallocate a sequence of blocks into a contiguous sequence of blocks.
- *
- * The vnode and an array of buffer pointers for a range of sequential
- * logical blocks to be made contiguous is given. The allocator attempts
- * to find a range of sequential blocks starting as close as possible to
- * an fs_rotdelay offset from the end of the allocation for the logical
- * block immediately preceeding the current range. If successful, the
- * physical block numbers in the buffer pointers and in the inode are
- * changed to reflect the new allocation. If unsuccessful, the allocation
- * is left unchanged. The success in doing the reallocation is returned.
- * Note that the error return is not reflected back to the user. Rather
- * the previous block allocation will be used.
- */
-
-#ifdef FANCY_REALLOC
-#include <sys/sysctl.h>
-static int doasyncfree = 1;
-#ifdef OPT_DEBUG
-SYSCTL_INT(_debug, 14, doasyncfree, CTLFLAG_RW, &doasyncfree, 0, "");
-#endif /* OPT_DEBUG */
-#endif
-
-int
-ext2_reallocblks(ap)
- struct vop_reallocblks_args /* {
- struct vnode *a_vp;
- struct cluster_save *a_buflist;
- } */ *ap;
-{
-#ifndef FANCY_REALLOC
-/* printf("ext2_reallocblks not implemented\n"); */
-return ENOSPC;
-#else
-
- struct ext2_sb_info *fs;
- struct inode *ip;
- struct vnode *vp;
- struct buf *sbp, *ebp;
- daddr_t *bap, *sbap, *ebap;
- struct cluster_save *buflist;
- daddr_t start_lbn, end_lbn, soff, eoff, newblk, blkno;
- struct indir start_ap[NIADDR + 1], end_ap[NIADDR + 1], *idp;
- int i, len, start_lvl, end_lvl, pref, ssize;
-
- vp = ap->a_vp;
- ip = VTOI(vp);
- fs = ip->i_e2fs;
-#ifdef UNKLAR
- if (fs->fs_contigsumsize <= 0)
- return (ENOSPC);
-#endif
- buflist = ap->a_buflist;
- len = buflist->bs_nchildren;
- start_lbn = buflist->bs_children[0]->b_lblkno;
- end_lbn = start_lbn + len - 1;
-#if DIAGNOSTIC
- for (i = 1; i < len; i++)
- if (buflist->bs_children[i]->b_lblkno != start_lbn + i)
- panic("ext2_reallocblks: non-cluster");
-#endif
- /*
- * If the latest allocation is in a new cylinder group, assume that
- * the filesystem has decided to move and do not force it back to
- * the previous cylinder group.
- */
- if (dtog(fs, dbtofsb(fs, buflist->bs_children[0]->b_blkno)) !=
- dtog(fs, dbtofsb(fs, buflist->bs_children[len - 1]->b_blkno)))
- return (ENOSPC);
- if (ufs_getlbns(vp, start_lbn, start_ap, &start_lvl) ||
- ufs_getlbns(vp, end_lbn, end_ap, &end_lvl))
- return (ENOSPC);
- /*
- * Get the starting offset and block map for the first block.
- */
- if (start_lvl == 0) {
- sbap = &ip->i_db[0];
- soff = start_lbn;
- } else {
- idp = &start_ap[start_lvl - 1];
- if (bread(vp, idp->in_lbn, (int)fs->s_blocksize, NOCRED, &sbp)) {
- brelse(sbp);
- return (ENOSPC);
- }
- sbap = (daddr_t *)sbp->b_data;
- soff = idp->in_off;
- }
- /*
- * Find the preferred location for the cluster.
- */
- pref = ext2_blkpref(ip, start_lbn, soff, sbap);
- /*
- * If the block range spans two block maps, get the second map.
- */
- if (end_lvl == 0 || (idp = &end_ap[end_lvl - 1])->in_off + 1 >= len) {
- ssize = len;
- } else {
-#if DIAGNOSTIC
- if (start_ap[start_lvl-1].in_lbn == idp->in_lbn)
- panic("ext2_reallocblk: start == end");
-#endif
- ssize = len - (idp->in_off + 1);
- if (bread(vp, idp->in_lbn, (int)fs->s_blocksize, NOCRED, &ebp))
- goto fail;
- ebap = (daddr_t *)ebp->b_data;
- }
- /*
- * Search the block map looking for an allocation of the desired size.
- */
- if ((newblk = (daddr_t)ext2_hashalloc(ip, dtog(fs, pref), (long)pref,
- len, (u_long (*)())ext2_clusteralloc)) == 0)
- goto fail;
- /*
- * We have found a new contiguous block.
- *
- * First we have to replace the old block pointers with the new
- * block pointers in the inode and indirect blocks associated
- * with the file.
- */
- blkno = newblk;
- for (bap = &sbap[soff], i = 0; i < len; i++, blkno += fs->s_frags_per_block) {
- if (i == ssize)
- bap = ebap;
-#if DIAGNOSTIC
- if (buflist->bs_children[i]->b_blkno != fsbtodb(fs, *bap))
- panic("ext2_reallocblks: alloc mismatch");
-#endif
- *bap++ = blkno;
- }
- /*
- * Next we must write out the modified inode and indirect blocks.
- * For strict correctness, the writes should be synchronous since
- * the old block values may have been written to disk. In practise
- * they are almost never written, but if we are concerned about
- * strict correctness, the `doasyncfree' flag should be set to zero.
- *
- * The test on `doasyncfree' should be changed to test a flag
- * that shows whether the associated buffers and inodes have
- * been written. The flag should be set when the cluster is
- * started and cleared whenever the buffer or inode is flushed.
- * We can then check below to see if it is set, and do the
- * synchronous write only when it has been cleared.
- */
- if (sbap != &ip->i_db[0]) {
- if (doasyncfree)
- bdwrite(sbp);
- else
- bwrite(sbp);
- } else {
- ip->i_flag |= IN_CHANGE | IN_UPDATE;
- if (!doasyncfree)
- UFS_UPDATE(vp, 1);
- }
- if (ssize < len)
- if (doasyncfree)
- bdwrite(ebp);
- else
- bwrite(ebp);
- /*
- * Last, free the old blocks and assign the new blocks to the buffers.
- */
- for (blkno = newblk, i = 0; i < len; i++, blkno += fs->s_frags_per_block) {
- ext2_blkfree(ip, dbtofsb(fs, buflist->bs_children[i]->b_blkno),
- fs->s_blocksize);
- buflist->bs_children[i]->b_blkno = fsbtodb(fs, blkno);
- }
- return (0);
-
-fail:
- if (ssize < len)
- brelse(ebp);
- if (sbap != &ip->i_db[0])
- brelse(sbp);
- return (ENOSPC);
-
-#endif /* FANCY_REALLOC */
-}
-
-/*
- * Allocate an inode in the file system.
- *
- * we leave the actual allocation strategy to the (modified)
- * ext2_new_inode(), to make sure we get the policies right
- */
-int
-ext2_valloc(pvp, mode, cred, vpp)
- struct vnode *pvp;
- int mode;
- struct ucred *cred;
- struct vnode **vpp;
-{
- register struct inode *pip;
- register struct ext2_sb_info *fs;
- register struct inode *ip;
- ino_t ino;
- int i, error;
-
- *vpp = NULL;
- pip = VTOI(pvp);
- fs = pip->i_e2fs;
- if (fs->s_es->s_free_inodes_count == 0)
- goto noinodes;
-
- /* call the Linux routine - it returns the inode number only */
- ino = ext2_new_inode(pip, mode);
-
- if (ino == 0)
- goto noinodes;
- error = VFS_VGET(pvp->v_mount, ino, vpp);
- if (error) {
- UFS_VFREE(pvp, ino, mode);
- return (error);
- }
- ip = VTOI(*vpp);
-
- /*
- the question is whether using VGET was such good idea at all -
- Linux doesn't read the old inode in when it's allocating a
- new one. I will set at least i_size & i_blocks the zero.
- */
- ip->i_mode = 0;
- ip->i_size = 0;
- ip->i_blocks = 0;
- ip->i_flags = 0;
- /* now we want to make sure that the block pointers are zeroed out */
- for (i = 0; i < NDADDR; i++)
- ip->i_db[i] = 0;
- for (i = 0; i < NIADDR; i++)
- ip->i_ib[i] = 0;
-
- /*
- * Set up a new generation number for this inode.
- * XXX check if this makes sense in ext2
- */
- if (ip->i_gen == 0 || ++ip->i_gen == 0)
- ip->i_gen = random() / 2 + 1;
-/*
-printf("ext2_valloc: allocated inode %d\n", ino);
-*/
- return (0);
-noinodes:
- ext2_fserr(fs, cred->cr_uid, "out of inodes");
- uprintf("\n%s: create/symlink failed, no inodes free\n", fs->fs_fsmnt);
- return (ENOSPC);
-}
-
-/*
- * Select the desired position for the next block in a file.
- *
- * we try to mimic what Remy does in inode_getblk/block_getblk
- *
- * we note: blocknr == 0 means that we're about to allocate either
- * a direct block or a pointer block at the first level of indirection
- * (In other words, stuff that will go in i_db[] or i_ib[])
- *
- * blocknr != 0 means that we're allocating a block that is none
- * of the above. Then, blocknr tells us the number of the block
- * that will hold the pointer
- */
-daddr_t
-ext2_blkpref(ip, lbn, indx, bap, blocknr)
- struct inode *ip;
- daddr_t lbn;
- int indx;
- daddr_t *bap;
- daddr_t blocknr;
-{
- int tmp;
-
- /* if the next block is actually what we thought it is,
- then set the goal to what we thought it should be
- */
- if(ip->i_next_alloc_block == lbn)
- return ip->i_next_alloc_goal;
-
- /* now check whether we were provided with an array that basically
- tells us previous blocks to which we want to stay closeby
- */
- if(bap)
- for (tmp = indx - 1; tmp >= 0; tmp--)
- if (bap[tmp])
- return bap[tmp];
-
- /* else let's fall back to the blocknr, or, if there is none,
- follow the rule that a block should be allocated near its inode
- */
- return blocknr ? blocknr :
- (daddr_t)(ip->i_block_group *
- EXT2_BLOCKS_PER_GROUP(ip->i_e2fs)) +
- ip->i_e2fs->s_es->s_first_data_block;
-}
-
-/*
- * Free a block or fragment.
- *
- * pass on to the Linux code
- */
-void
-ext2_blkfree(ip, bno, size)
- register struct inode *ip;
- daddr_t bno;
- long size;
-{
- register struct ext2_sb_info *fs;
-
- fs = ip->i_e2fs;
- /*
- * call Linux code with mount *, block number, count
- */
- ext2_free_blocks(ITOV(ip)->v_mount, bno, size / fs->s_frag_size);
-}
-
-/*
- * Free an inode.
- *
- * the maintenance of the actual bitmaps is again up to the linux code
- */
-int
-ext2_vfree(pvp, ino, mode)
- struct vnode *pvp;
- ino_t ino;
- int mode;
-{
- register struct ext2_sb_info *fs;
- register struct inode *pip;
- register mode_t save_i_mode;
-
- pip = VTOI(pvp);
- fs = pip->i_e2fs;
- if ((u_int)ino >= fs->s_inodes_per_group * fs->s_groups_count)
- panic("ext2_vfree: range: dev = (%d, %d), ino = %d, fs = %s",
- major(pip->i_dev), minor(pip->i_dev), ino, fs->fs_fsmnt);
-
-/* ext2_debug("ext2_vfree (%d, %d) called\n", pip->i_number, mode);
- */
- ext2_discard_prealloc(pip);
-
- /* we need to make sure that ext2_free_inode can adjust the
- used_dir_counts in the group summary information - I'd
- really like to know what the rationale behind this
- 'set i_mode to zero to denote an unused inode' is
- */
- save_i_mode = pip->i_mode;
- pip->i_mode = mode;
- ext2_free_inode(pip);
- pip->i_mode = save_i_mode;
- return (0);
-}
-
-/*
- * Fserr prints the name of a file system with an error diagnostic.
- *
- * The form of the error message is:
- * fs: error message
- */
-static void
-ext2_fserr(fs, uid, cp)
- struct ext2_sb_info *fs;
- u_int uid;
- char *cp;
-{
-
- log(LOG_ERR, "uid %d on %s: %s\n", uid, fs->fs_fsmnt, cp);
-}
diff --git a/sys/gnu/fs/ext2fs/ext2_balloc.c b/sys/gnu/fs/ext2fs/ext2_balloc.c
deleted file mode 100644
index 2b485c6467ae..000000000000
--- a/sys/gnu/fs/ext2fs/ext2_balloc.c
+++ /dev/null
@@ -1,313 +0,0 @@
-/*
- * modified for Lites 1.1
- *
- * Aug 1995, Godmar Back (gback@cs.utah.edu)
- * University of Utah, Department of Computer Science
- */
-/*
- * Copyright (c) 1982, 1986, 1989, 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)ffs_balloc.c 8.4 (Berkeley) 9/23/93
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/buf.h>
-#include <sys/lock.h>
-#include <sys/ucred.h>
-#include <sys/vnode.h>
-
-#include <ufs/ufs/quota.h>
-#include <ufs/ufs/inode.h>
-#include <ufs/ufs/ufs_extern.h>
-
-#include <gnu/ext2fs/ext2_fs.h>
-#include <gnu/ext2fs/ext2_fs_sb.h>
-#include <gnu/ext2fs/fs.h>
-#include <gnu/ext2fs/ext2_extern.h>
-
-/*
- * Balloc defines the structure of file system storage
- * by allocating the physical blocks on a device given
- * the inode and the logical block number in a file.
- */
-int
-ext2_balloc(ip, bn, size, cred, bpp, flags)
- register struct inode *ip;
- register daddr_t bn;
- int size;
- struct ucred *cred;
- struct buf **bpp;
- int flags;
-{
- register struct ext2_sb_info *fs;
- register daddr_t nb;
- struct buf *bp, *nbp;
- struct vnode *vp = ITOV(ip);
- struct indir indirs[NIADDR + 2];
- daddr_t newb, lbn, *bap, pref;
- int osize, nsize, num, i, error;
-/*
-ext2_debug("ext2_balloc called (%d, %d, %d)\n",
- ip->i_number, (int)bn, (int)size);
-*/
- *bpp = NULL;
- if (bn < 0)
- return (EFBIG);
- fs = ip->i_e2fs;
- lbn = bn;
-
- /*
- * check if this is a sequential block allocation.
- * If so, increment next_alloc fields to allow ext2_blkpref
- * to make a good guess
- */
- if (lbn == ip->i_next_alloc_block + 1) {
- ip->i_next_alloc_block++;
- ip->i_next_alloc_goal++;
- }
-
- /*
- * The first NDADDR blocks are direct blocks
- */
- if (bn < NDADDR) {
- nb = ip->i_db[bn];
- /* no new block is to be allocated, and no need to expand
- the file */
- if (nb != 0 && ip->i_size >= (bn + 1) * fs->s_blocksize) {
- error = bread(vp, bn, fs->s_blocksize, NOCRED, &bp);
- if (error) {
- brelse(bp);
- return (error);
- }
- *bpp = bp;
- return (0);
- }
- if (nb != 0) {
- /*
- * Consider need to reallocate a fragment.
- */
- osize = fragroundup(fs, blkoff(fs, ip->i_size));
- nsize = fragroundup(fs, size);
- if (nsize <= osize) {
- error = bread(vp, bn, osize, NOCRED, &bp);
- if (error) {
- brelse(bp);
- return (error);
- }
- } else {
- /* Godmar thinks: this shouldn't happen w/o fragments */
- printf("nsize %d(%d) > osize %d(%d) nb %d\n",
- (int)nsize, (int)size, (int)osize,
- (int)ip->i_size, (int)nb);
- panic(
- "ext2_balloc: Something is terribly wrong");
-/*
- * please note there haven't been any changes from here on -
- * FFS seems to work.
- */
- }
- } else {
- if (ip->i_size < (bn + 1) * fs->s_blocksize)
- nsize = fragroundup(fs, size);
- else
- nsize = fs->s_blocksize;
- error = ext2_alloc(ip, bn,
- ext2_blkpref(ip, bn, (int)bn, &ip->i_db[0], 0),
- nsize, cred, &newb);
- if (error)
- return (error);
- bp = getblk(vp, bn, nsize, 0, 0);
- bp->b_blkno = fsbtodb(fs, newb);
- if (flags & B_CLRBUF)
- vfs_bio_clrbuf(bp);
- }
- ip->i_db[bn] = dbtofsb(fs, bp->b_blkno);
- ip->i_flag |= IN_CHANGE | IN_UPDATE;
- *bpp = bp;
- return (0);
- }
- /*
- * Determine the number of levels of indirection.
- */
- pref = 0;
- if ((error = ufs_getlbns(vp, bn, indirs, &num)) != 0)
- return(error);
-#if DIAGNOSTIC
- if (num < 1)
- panic ("ext2_balloc: ufs_bmaparray returned indirect block");
-#endif
- /*
- * Fetch the first indirect block allocating if necessary.
- */
- --num;
- nb = ip->i_ib[indirs[0].in_off];
- if (nb == 0) {
-#if 0
- pref = ext2_blkpref(ip, lbn, 0, (daddr_t *)0, 0);
-#else
- /* see the comment by ext2_blkpref. What we do here is
- to pretend that it'd be good for a block holding indirect
- pointers to be allocated near its predecessor in terms
- of indirection, or the last direct block.
- We shamelessly exploit the fact that i_ib immediately
- follows i_db.
- Godmar thinks it make sense to allocate i_ib[0] immediately
- after i_db[11], but it's not utterly clear whether this also
- applies to i_ib[1] and i_ib[0]
- */
-
- pref = ext2_blkpref(ip, lbn, indirs[0].in_off +
- EXT2_NDIR_BLOCKS, &ip->i_db[0], 0);
-#endif
- if ((error = ext2_alloc(ip, lbn, pref, (int)fs->s_blocksize,
- cred, &newb)) != 0)
- return (error);
- nb = newb;
- bp = getblk(vp, indirs[1].in_lbn, fs->s_blocksize, 0, 0);
- bp->b_blkno = fsbtodb(fs, newb);
- vfs_bio_clrbuf(bp);
- /*
- * Write synchronously so that indirect blocks
- * never point at garbage.
- */
- if ((error = bwrite(bp)) != 0) {
- ext2_blkfree(ip, nb, fs->s_blocksize);
- return (error);
- }
- ip->i_ib[indirs[0].in_off] = newb;
- ip->i_flag |= IN_CHANGE | IN_UPDATE;
- }
- /*
- * Fetch through the indirect blocks, allocating as necessary.
- */
- for (i = 1;;) {
- error = bread(vp,
- indirs[i].in_lbn, (int)fs->s_blocksize, NOCRED, &bp);
- if (error) {
- brelse(bp);
- return (error);
- }
- bap = (daddr_t *)bp->b_data;
- nb = bap[indirs[i].in_off];
- if (i == num)
- break;
- i += 1;
- if (nb != 0) {
- brelse(bp);
- continue;
- }
- if (pref == 0)
-#if 1
- /* see the comment above and by ext2_blkpref
- * I think this implements Linux policy, but
- * does it really make sense to allocate to
- * block containing pointers together ?
- * Also, will it ever succeed ?
- */
- pref = ext2_blkpref(ip, lbn, indirs[i].in_off, bap,
- bp->b_lblkno);
-#else
- pref = ext2_blkpref(ip, lbn, 0, (daddr_t *)0, 0);
-#endif
- if ((error =
- ext2_alloc(ip, lbn, pref, (int)fs->s_blocksize, cred, &newb)) != 0) {
- brelse(bp);
- return (error);
- }
- nb = newb;
- nbp = getblk(vp, indirs[i].in_lbn, fs->s_blocksize, 0, 0);
- nbp->b_blkno = fsbtodb(fs, nb);
- vfs_bio_clrbuf(nbp);
- /*
- * Write synchronously so that indirect blocks
- * never point at garbage.
- */
- if ((error = bwrite(nbp)) != 0) {
- ext2_blkfree(ip, nb, fs->s_blocksize);
- brelse(bp);
- return (error);
- }
- bap[indirs[i - 1].in_off] = nb;
- /*
- * If required, write synchronously, otherwise use
- * delayed write.
- */
- if (flags & B_SYNC) {
- bwrite(bp);
- } else {
- bdwrite(bp);
- }
- }
- /*
- * Get the data block, allocating if necessary.
- */
- if (nb == 0) {
- pref = ext2_blkpref(ip, lbn, indirs[i].in_off, &bap[0],
- bp->b_lblkno);
- if ((error = ext2_alloc(ip,
- lbn, pref, (int)fs->s_blocksize, cred, &newb)) != 0) {
- brelse(bp);
- return (error);
- }
- nb = newb;
- nbp = getblk(vp, lbn, fs->s_blocksize, 0, 0);
- nbp->b_blkno = fsbtodb(fs, nb);
- if (flags & B_CLRBUF)
- vfs_bio_clrbuf(nbp);
- bap[indirs[i].in_off] = nb;
- /*
- * If required, write synchronously, otherwise use
- * delayed write.
- */
- if (flags & B_SYNC) {
- bwrite(bp);
- } else {
- bdwrite(bp);
- }
- *bpp = nbp;
- return (0);
- }
- brelse(bp);
- if (flags & B_CLRBUF) {
- error = bread(vp, lbn, (int)fs->s_blocksize, NOCRED, &nbp);
- if (error) {
- brelse(nbp);
- return (error);
- }
- } else {
- nbp = getblk(vp, lbn, fs->s_blocksize, 0, 0);
- nbp->b_blkno = fsbtodb(fs, nb);
- }
- *bpp = nbp;
- return (0);
-}
diff --git a/sys/gnu/fs/ext2fs/ext2_bmap.c b/sys/gnu/fs/ext2fs/ext2_bmap.c
deleted file mode 100644
index 14ef56ef8b4b..000000000000
--- a/sys/gnu/fs/ext2fs/ext2_bmap.c
+++ /dev/null
@@ -1,320 +0,0 @@
-/*
- * Copyright (c) 1989, 1991, 1993
- * The Regents of the University of California. All rights reserved.
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)ufs_bmap.c 8.7 (Berkeley) 3/21/95
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/buf.h>
-#include <sys/proc.h>
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <sys/resourcevar.h>
-#include <sys/conf.h>
-
-#include <ufs/ufs/quota.h>
-#include <ufs/ufs/inode.h>
-#include <ufs/ufs/ufsmount.h>
-#include <ufs/ufs/ufs_extern.h>
-
-/*
- * Bmap converts a the logical block number of a file to its physical block
- * number on the disk. The conversion is done by using the logical block
- * number to index into the array of block pointers described by the dinode.
- */
-int
-ufs_bmap(ap)
- struct vop_bmap_args /* {
- struct vnode *a_vp;
- ufs_daddr_t a_bn;
- struct vnode **a_vpp;
- ufs_daddr_t *a_bnp;
- int *a_runp;
- int *a_runb;
- } */ *ap;
-{
- /*
- * Check for underlying vnode requests and ensure that logical
- * to physical mapping is requested.
- */
- if (ap->a_vpp != NULL)
- *ap->a_vpp = VTOI(ap->a_vp)->i_devvp;
- if (ap->a_bnp == NULL)
- return (0);
-
- return (ufs_bmaparray(ap->a_vp, ap->a_bn, ap->a_bnp, NULL, NULL,
- ap->a_runp, ap->a_runb));
-}
-
-/*
- * Indirect blocks are now on the vnode for the file. They are given negative
- * logical block numbers. Indirect blocks are addressed by the negative
- * address of the first data block to which they point. Double indirect blocks
- * are addressed by one less than the address of the first indirect block to
- * which they point. Triple indirect blocks are addressed by one less than
- * the address of the first double indirect block to which they point.
- *
- * ufs_bmaparray does the bmap conversion, and if requested returns the
- * array of logical blocks which must be traversed to get to a block.
- * Each entry contains the offset into that block that gets you to the
- * next block and the disk address of the block (if it is assigned).
- */
-
-int
-ufs_bmaparray(vp, bn, bnp, ap, nump, runp, runb)
- struct vnode *vp;
- ufs_daddr_t bn;
- ufs_daddr_t *bnp;
- struct indir *ap;
- int *nump;
- int *runp;
- int *runb;
-{
- register struct inode *ip;
- struct buf *bp;
- struct ufsmount *ump;
- struct mount *mp;
- struct vnode *devvp;
- struct indir a[NIADDR+1], *xap;
- ufs_daddr_t daddr;
- long metalbn;
- int error, maxrun, num;
-
- ip = VTOI(vp);
- mp = vp->v_mount;
- ump = VFSTOUFS(mp);
- devvp = ump->um_devvp;
-#ifdef DIAGNOSTIC
- if ((ap != NULL && nump == NULL) || (ap == NULL && nump != NULL))
- panic("ufs_bmaparray: invalid arguments");
-#endif
-
- if (runp) {
- *runp = 0;
- }
-
- if (runb) {
- *runb = 0;
- }
-
- maxrun = mp->mnt_iosize_max / mp->mnt_stat.f_iosize - 1;
-
- xap = ap == NULL ? a : ap;
- if (!nump)
- nump = &num;
- error = ufs_getlbns(vp, bn, xap, nump);
- if (error)
- return (error);
-
- num = *nump;
- if (num == 0) {
- *bnp = blkptrtodb(ump, ip->i_db[bn]);
- if (*bnp == 0)
- *bnp = -1;
- else if (runp) {
- daddr_t bnb = bn;
- for (++bn; bn < NDADDR && *runp < maxrun &&
- is_sequential(ump, ip->i_db[bn - 1], ip->i_db[bn]);
- ++bn, ++*runp);
- bn = bnb;
- if (runb && (bn > 0)) {
- for (--bn; (bn >= 0) && (*runb < maxrun) &&
- is_sequential(ump, ip->i_db[bn],
- ip->i_db[bn+1]);
- --bn, ++*runb);
- }
- }
- return (0);
- }
-
-
- /* Get disk address out of indirect block array */
- daddr = ip->i_ib[xap->in_off];
-
- for (bp = NULL, ++xap; --num; ++xap) {
- /*
- * Exit the loop if there is no disk address assigned yet and
- * the indirect block isn't in the cache, or if we were
- * looking for an indirect block and we've found it.
- */
-
- metalbn = xap->in_lbn;
- if ((daddr == 0 && !incore(vp, metalbn)) || metalbn == bn)
- break;
- /*
- * If we get here, we've either got the block in the cache
- * or we have a disk address for it, go fetch it.
- */
- if (bp)
- bqrelse(bp);
-
- xap->in_exists = 1;
- bp = getblk(vp, metalbn, mp->mnt_stat.f_iosize, 0, 0);
- if ((bp->b_flags & B_CACHE) == 0) {
-#ifdef DIAGNOSTIC
- if (!daddr)
- panic("ufs_bmaparray: indirect block not in cache");
-#endif
- bp->b_blkno = blkptrtodb(ump, daddr);
- bp->b_flags |= B_READ;
- bp->b_flags &= ~(B_INVAL|B_ERROR);
- vfs_busy_pages(bp, 0);
- VOP_STRATEGY(bp->b_vp, bp);
- curproc->p_stats->p_ru.ru_inblock++; /* XXX */
- error = biowait(bp);
- if (error) {
- brelse(bp);
- return (error);
- }
- }
-
- daddr = ((ufs_daddr_t *)bp->b_data)[xap->in_off];
- if (num == 1 && daddr && runp) {
- for (bn = xap->in_off + 1;
- bn < MNINDIR(ump) && *runp < maxrun &&
- is_sequential(ump,
- ((ufs_daddr_t *)bp->b_data)[bn - 1],
- ((ufs_daddr_t *)bp->b_data)[bn]);
- ++bn, ++*runp);
- bn = xap->in_off;
- if (runb && bn) {
- for(--bn; bn > 0 && *runb < maxrun &&
- is_sequential(ump, ((daddr_t *)bp->b_data)[bn],
- ((daddr_t *)bp->b_data)[bn+1]);
- --bn, ++*runb);
- }
- }
- }
- if (bp)
- bqrelse(bp);
-
- daddr = blkptrtodb(ump, daddr);
- *bnp = daddr == 0 ? -1 : daddr;
- return (0);
-}
-
-/*
- * Create an array of logical block number/offset pairs which represent the
- * path of indirect blocks required to access a data block. The first "pair"
- * contains the logical block number of the appropriate single, double or
- * triple indirect block and the offset into the inode indirect block array.
- * Note, the logical block number of the inode single/double/triple indirect
- * block appears twice in the array, once with the offset into the i_ib and
- * once with the offset into the page itself.
- */
-int
-ufs_getlbns(vp, bn, ap, nump)
- struct vnode *vp;
- ufs_daddr_t bn;
- struct indir *ap;
- int *nump;
-{
- long blockcnt, metalbn, realbn;
- struct ufsmount *ump;
- int i, numlevels, off;
- int64_t qblockcnt;
-
- ump = VFSTOUFS(vp->v_mount);
- if (nump)
- *nump = 0;
- numlevels = 0;
- realbn = bn;
- if ((long)bn < 0)
- bn = -(long)bn;
-
- /* The first NDADDR blocks are direct blocks. */
- if (bn < NDADDR)
- return (0);
-
- /*
- * Determine the number of levels of indirection. After this loop
- * is done, blockcnt indicates the number of data blocks possible
- * at the previous level of indirection, and NIADDR - i is the number
- * of levels of indirection needed to locate the requested block.
- */
- for (blockcnt = 1, i = NIADDR, bn -= NDADDR;; i--, bn -= blockcnt) {
- if (i == 0)
- return (EFBIG);
- /*
- * Use int64_t's here to avoid overflow for triple indirect
- * blocks when longs have 32 bits and the block size is more
- * than 4K.
- */
- qblockcnt = (int64_t)blockcnt * MNINDIR(ump);
- if (bn < qblockcnt)
- break;
- blockcnt = qblockcnt;
- }
-
- /* Calculate the address of the first meta-block. */
- if (realbn >= 0)
- metalbn = -(realbn - bn + NIADDR - i);
- else
- metalbn = -(-realbn - bn + NIADDR - i);
-
- /*
- * At each iteration, off is the offset into the bap array which is
- * an array of disk addresses at the current level of indirection.
- * The logical block number and the offset in that block are stored
- * into the argument array.
- */
- ap->in_lbn = metalbn;
- ap->in_off = off = NIADDR - i;
- ap->in_exists = 0;
- ap++;
- for (++numlevels; i <= NIADDR; i++) {
- /* If searching for a meta-data block, quit when found. */
- if (metalbn == realbn)
- break;
-
- off = (bn / blockcnt) % MNINDIR(ump);
-
- ++numlevels;
- ap->in_lbn = metalbn;
- ap->in_off = off;
- ap->in_exists = 0;
- ++ap;
-
- metalbn -= -1 + off * blockcnt;
- blockcnt /= MNINDIR(ump);
- }
- if (nump)
- *nump = numlevels;
- return (0);
-}
diff --git a/sys/gnu/fs/ext2fs/ext2_extern.h b/sys/gnu/fs/ext2fs/ext2_extern.h
deleted file mode 100644
index 317f540af1e1..000000000000
--- a/sys/gnu/fs/ext2fs/ext2_extern.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * modified for EXT2FS support in Lites 1.1
- *
- * Aug 1995, Godmar Back (gback@cs.utah.edu)
- * University of Utah, Department of Computer Science
- */
-/*-
- * Copyright (c) 1991, 1993, 1994
- * 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)ffs_extern.h 8.3 (Berkeley) 4/16/94
- */
-
-#ifndef _SYS_GNU_EXT2FS_EXT2_EXTERN_H_
-#define _SYS_GNU_EXT2FS_EXT2_EXTERN_H_
-
-struct dinode;
-struct ext2_inode;
-struct inode;
-struct mount;
-struct vfsconf;
-struct vnode;
-
-int ext2_alloc __P((struct inode *,
- daddr_t, daddr_t, int, struct ucred *, daddr_t *));
-int ext2_balloc __P((struct inode *,
- daddr_t, int, struct ucred *, struct buf **, int));
-int ext2_blkatoff __P((struct vnode *, off_t, char **, struct buf **));
-void ext2_blkfree __P((struct inode *, daddr_t, long));
-daddr_t ext2_blkpref __P((struct inode *, daddr_t, int, daddr_t *, daddr_t));
-int ext2_bmap __P((struct vop_bmap_args *));
-int ext2_init __P((struct vfsconf *));
-int ext2_reallocblks __P((struct vop_reallocblks_args *));
-int ext2_reclaim __P((struct vop_reclaim_args *));
-void ext2_setblock __P((struct ext2_sb_info *, u_char *, daddr_t));
-int ext2_truncate __P((struct vnode *, off_t, int, struct ucred *, struct proc *));
-int ext2_update __P((struct vnode *, int));
-int ext2_valloc __P((struct vnode *, int, struct ucred *, struct vnode **));
-int ext2_vfree __P((struct vnode *, ino_t, int));
-int ext2_lookup __P((struct vop_cachedlookup_args *));
-int ext2_readdir __P((struct vop_readdir_args *));
-void ext2_print_dinode __P((struct dinode *));
-void ext2_print_inode __P((struct inode *));
-int ext2_direnter __P((struct inode *,
- struct vnode *, struct componentname *));
-int ext2_dirremove __P((struct vnode *, struct componentname *));
-int ext2_dirrewrite __P((struct inode *,
- struct inode *, struct componentname *));
-int ext2_dirempty __P((struct inode *, ino_t, struct ucred *));
-int ext2_checkpath __P((struct inode *, struct inode *, struct ucred *));
-struct ext2_group_desc * get_group_desc __P((struct mount * ,
- unsigned int , struct buf ** ));
-void ext2_discard_prealloc __P((struct inode *));
-int ext2_inactive __P((struct vop_inactive_args *));
-int ext2_new_block __P ((struct mount * mp, unsigned long goal,
- u_int32_t * prealloc_count,
- u_int32_t * prealloc_block));
-ino_t ext2_new_inode __P ((const struct inode * dir, int mode));
-unsigned long ext2_count_free __P((struct buf *map, unsigned int numchars));
-void ext2_free_blocks __P((struct mount * mp, unsigned long block,
- unsigned long count));
-void ext2_free_inode __P((struct inode * inode));
-void ext2_ei2di __P((struct ext2_inode *ei, struct dinode *di));
-void ext2_di2ei __P((struct dinode *di, struct ext2_inode *ei));
-void mark_buffer_dirty __P((struct buf *bh));
-
-/*
- * This macro allows the ufs code to distinguish between an EXT2 and a
- * non-ext2(FFS/LFS) vnode.
- */
-#define IS_EXT2_VNODE(vp) (vp->v_mount->mnt_stat.f_type == MOUNT_EXT2FS)
-
-extern vop_t **ext2_vnodeop_p;
-extern vop_t **ext2_specop_p;
-extern vop_t **ext2_fifoop_p;
-
-#endif /* !_SYS_GNU_EXT2FS_EXT2_EXTERN_H_ */
diff --git a/sys/gnu/fs/ext2fs/ext2_fs.h b/sys/gnu/fs/ext2fs/ext2_fs.h
deleted file mode 100644
index 64aff0d17bfc..000000000000
--- a/sys/gnu/fs/ext2fs/ext2_fs.h
+++ /dev/null
@@ -1,572 +0,0 @@
-/*
- * modified for EXT2FS support in Lites 1.1
- *
- * Aug 1995, Godmar Back (gback@cs.utah.edu)
- * University of Utah, Department of Computer Science
- *
- * $FreeBSD$
- */
-/*
- * linux/include/linux/ext2_fs.h
- *
- * Copyright (C) 1992, 1993, 1994, 1995
- * Remy Card (card@masi.ibp.fr)
- * Laboratoire MASI - Institut Blaise Pascal
- * Universite Pierre et Marie Curie (Paris VI)
- *
- * from
- *
- * linux/include/linux/minix_fs.h
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- */
-
-#ifndef _LINUX_EXT2_FS_H
-#define _LINUX_EXT2_FS_H
-
-#include <sys/types.h>
-
-#define __u32 u_int32_t
-#define u32 u_int32_t
-#define __u16 u_int16_t
-#define __u8 u_int8_t
-
-#define __s32 int32_t
-#define __s16 int16_t
-#define __s8 int8_t
-
-#define umode_t mode_t
-#define loff_t off_t
-
-/* the Linux implementation of EXT2 stores some information about
- * an inode in a ext2_inode_info structure which is part of the incore
- * inode in Linux
- * I decided to use the "spare" fields instead - we'll see how this
- * works out
- */
-
-#define i_block_group i_spare[0]
-#define i_next_alloc_block i_spare[1]
-#define i_next_alloc_goal i_spare[2]
-#define i_prealloc_block i_spare[3]
-#define i_prealloc_count i_din.di_spare[0]
-
-/*
- * The second extended filesystem constants/structures
- */
-
-/*
- * Define EXT2FS_DEBUG to produce debug messages
- */
-#undef EXT2FS_DEBUG
-
-/*
- * Define EXT2_PREALLOCATE to preallocate data blocks for expanding files
- */
-#define EXT2_PREALLOCATE
-#define EXT2_DEFAULT_PREALLOC_BLOCKS 8
-
-/*
- * The second extended file system version
- */
-#define EXT2FS_DATE "95/08/09"
-#define EXT2FS_VERSION "0.5b"
-
-/*
- * Debug code
- */
-#ifdef EXT2FS_DEBUG
-# define ext2_debug(f, a...) { \
- printf ("EXT2-fs DEBUG (%s, %d): %s:", \
- __FILE__, __LINE__, __FUNCTION__); \
- printf (f, ## a); \
- }
-#else
-# define ext2_debug(f, a...) /**/
-#endif
-
-/*
- * Special inodes numbers
- */
-#define EXT2_BAD_INO 1 /* Bad blocks inode */
-#define EXT2_ROOT_INO 2 /* Root inode */
-#define EXT2_ACL_IDX_INO 3 /* ACL inode */
-#define EXT2_ACL_DATA_INO 4 /* ACL inode */
-#define EXT2_BOOT_LOADER_INO 5 /* Boot loader inode */
-#define EXT2_UNDEL_DIR_INO 6 /* Undelete directory inode */
-
-/* First non-reserved inode for old ext2 filesystems */
-#define EXT2_GOOD_OLD_FIRST_INO 11
-
-/*
- * The second extended file system magic number
- */
-#define EXT2_SUPER_MAGIC 0xEF53
-
-/*
- * Maximal count of links to a file
- */
-#define EXT2_LINK_MAX 32000
-
-/*
- * Note: under FreeBSD, the "user" versions of the following macros are
- * used (and must be used) in most cases, because ((s)->u.ext2_sb.s_es is
- * not accessible. This depends on __KERNEL__ not being defined for
- * kernel builds under FreeBSD.
- */
-
-/*
- * Macro-instructions used to manage several block sizes
- */
-#define EXT2_MIN_BLOCK_SIZE 1024
-#define EXT2_MAX_BLOCK_SIZE 4096
-#define EXT2_MIN_BLOCK_LOG_SIZE 10
-#if defined(__KERNEL__) || (defined(__FreeBSD__) && defined(_KERNEL))
-# define EXT2_BLOCK_SIZE(s) ((s)->s_blocksize)
-#else
-# define EXT2_BLOCK_SIZE(s) (EXT2_MIN_BLOCK_SIZE << (s)->s_log_block_size)
-#endif
-#define EXT2_ACLE_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_acl_entry))
-#define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (__u32))
-#ifdef __KERNEL__
-# define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits)
-#else
-# define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10)
-#endif
-#ifdef notyet
-#ifdef __KERNEL__
-#define EXT2_ADDR_PER_BLOCK_BITS(s) ((s)->u.ext2_sb.s_addr_per_block_bits)
-#define EXT2_INODE_SIZE(s) ((s)->u.ext2_sb.s_inode_size)
-#define EXT2_FIRST_INO(s) ((s)->u.ext2_sb.s_first_ino)
-#else
-#define EXT2_INODE_SIZE(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
- EXT2_GOOD_OLD_INODE_SIZE : \
- (s)->s_inode_size)
-#define EXT2_FIRST_INO(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \
- EXT2_GOOD_OLD_FIRST_INO : \
- (s)->s_first_ino)
-#endif
-#else /* !notyet */
-#define EXT2_INODES_PER_BLOCK(s) ((s)->s_inodes_per_block)
-/* Should be sizeof(struct ext2_inode): */
-#define EXT2_INODE_SIZE 128
-#define EXT2_FIRST_INO 11
-#endif /* notyet */
-
-/*
- * Macro-instructions used to manage fragments
- */
-#define EXT2_MIN_FRAG_SIZE 1024
-#define EXT2_MAX_FRAG_SIZE 4096
-#define EXT2_MIN_FRAG_LOG_SIZE 10
-#ifdef __KERNEL__
-# define EXT2_FRAG_SIZE(s) ((s)->u.ext2_sb.s_frag_size)
-# define EXT2_FRAGS_PER_BLOCK(s) ((s)->u.ext2_sb.s_frags_per_block)
-#else
-# if defined(_KERNEL) && defined(__FreeBSD__)
-# define EXT2_FRAG_SIZE(s) ((s)->s_frag_size)
-# else
-# define EXT2_FRAG_SIZE(s) (EXT2_MIN_FRAG_SIZE << (s)->s_log_frag_size)
-# endif
-# define EXT2_FRAGS_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / EXT2_FRAG_SIZE(s))
-#endif
-
-/*
- * ACL structures
- */
-struct ext2_acl_header /* Header of Access Control Lists */
-{
- __u32 aclh_size;
- __u32 aclh_file_count;
- __u32 aclh_acle_count;
- __u32 aclh_first_acle;
-};
-
-struct ext2_acl_entry /* Access Control List Entry */
-{
- __u32 acle_size;
- __u16 acle_perms; /* Access permissions */
- __u16 acle_type; /* Type of entry */
- __u16 acle_tag; /* User or group identity */
- __u16 acle_pad1;
- __u32 acle_next; /* Pointer on next entry for the */
- /* same inode or on next free entry */
-};
-
-/*
- * Structure of a blocks group descriptor
- */
-struct ext2_group_desc
-{
- __u32 bg_block_bitmap; /* Blocks bitmap block */
- __u32 bg_inode_bitmap; /* Inodes bitmap block */
- __u32 bg_inode_table; /* Inodes table block */
- __u16 bg_free_blocks_count; /* Free blocks count */
- __u16 bg_free_inodes_count; /* Free inodes count */
- __u16 bg_used_dirs_count; /* Directories count */
- __u16 bg_pad;
- __u32 bg_reserved[3];
-};
-
-/*
- * Macro-instructions used to manage group descriptors
- */
-#ifdef __KERNEL__
-# define EXT2_BLOCKS_PER_GROUP(s) ((s)->u.ext2_sb.s_blocks_per_group)
-# define EXT2_DESC_PER_BLOCK(s) ((s)->u.ext2_sb.s_desc_per_block)
-# define EXT2_INODES_PER_GROUP(s) ((s)->u.ext2_sb.s_inodes_per_group)
-# define EXT2_DESC_PER_BLOCK_BITS(s) ((s)->u.ext2_sb.s_desc_per_block_bits)
-#else
-# define EXT2_BLOCKS_PER_GROUP(s) ((s)->s_blocks_per_group)
-# define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc))
-# define EXT2_INODES_PER_GROUP(s) ((s)->s_inodes_per_group)
-#endif
-
-/*
- * Constants relative to the data blocks
- */
-#define EXT2_NDIR_BLOCKS 12
-#define EXT2_IND_BLOCK EXT2_NDIR_BLOCKS
-#define EXT2_DIND_BLOCK (EXT2_IND_BLOCK + 1)
-#define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1)
-#define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1)
-#define EXT2_MAXSYMLINKLEN (EXT2_N_BLOCKS * sizeof (__u32))
-
-/*
- * Inode flags
- */
-#define EXT2_SECRM_FL 0x00000001 /* Secure deletion */
-#define EXT2_UNRM_FL 0x00000002 /* Undelete */
-#define EXT2_COMPR_FL 0x00000004 /* Compress file */
-#define EXT2_SYNC_FL 0x00000008 /* Synchronous updates */
-#define EXT2_IMMUTABLE_FL 0x00000010 /* Immutable file */
-#define EXT2_APPEND_FL 0x00000020 /* writes to file may only append */
-#define EXT2_NODUMP_FL 0x00000040 /* do not dump file */
-#define EXT2_NOATIME_FL 0x00000080 /* do not update atime */
-/* Reserved for compression usage... */
-#define EXT2_DIRTY_FL 0x00000100
-#define EXT2_COMPRBLK_FL 0x00000200 /* One or more compressed clusters */
-#define EXT2_NOCOMP_FL 0x00000400 /* Don't compress */
-#define EXT2_ECOMPR_FL 0x00000800 /* Compression error */
-/* End compression flags --- maybe not all used */
-#define EXT2_BTREE_FL 0x00001000 /* btree format dir */
-#define EXT2_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
-
-#define EXT2_FL_USER_VISIBLE 0x00001FFF /* User visible flags */
-#define EXT2_FL_USER_MODIFIABLE 0x000000FF /* User modifiable flags */
-
-/*
- * ioctl commands
- */
-#define EXT2_IOC_GETFLAGS _IOR('f', 1, long)
-#define EXT2_IOC_SETFLAGS _IOW('f', 2, long)
-#define EXT2_IOC_GETVERSION _IOR('v', 1, long)
-#define EXT2_IOC_SETVERSION _IOW('v', 2, long)
-
-/*
- * Only declare `struct ext2_inode' if <ufs/ufs/inode.h> hasn't made things
- * difficult by #defining i_mode and other struct members. The details of
- * the struct are only needed in ext2_inode_cnv.c where the ext2fs on-disk
- * inode is converted to a ufs in-core inode.
- */
-#ifndef i_mode
-
-/*
- * Structure of an inode on the disk
- */
-struct ext2_inode {
- __u16 i_mode; /* File mode */
- __u16 i_uid; /* Owner Uid */
- __u32 i_size; /* Size in bytes */
- __u32 i_atime; /* Access time */
- __u32 i_ctime; /* Creation time */
- __u32 i_mtime; /* Modification time */
- __u32 i_dtime; /* Deletion Time */
- __u16 i_gid; /* Group Id */
- __u16 i_links_count; /* Links count */
- __u32 i_blocks; /* Blocks count */
- __u32 i_flags; /* File flags */
- union {
- struct {
- __u32 l_i_reserved1;
- } linux1;
- struct {
- __u32 h_i_translator;
- } hurd1;
- struct {
- __u32 m_i_reserved1;
- } masix1;
- } osd1; /* OS dependent 1 */
- __u32 i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
- __u32 i_generation; /* File version (for NFS) */
- __u32 i_file_acl; /* File ACL */
- __u32 i_dir_acl; /* Directory ACL */
- __u32 i_faddr; /* Fragment address */
- union {
- struct {
- __u8 l_i_frag; /* Fragment number */
- __u8 l_i_fsize; /* Fragment size */
- __u16 i_pad1;
- __u32 l_i_reserved2[2];
- } linux2;
- struct {
- __u8 h_i_frag; /* Fragment number */
- __u8 h_i_fsize; /* Fragment size */
- __u16 h_i_mode_high;
- __u16 h_i_uid_high;
- __u16 h_i_gid_high;
- __u32 h_i_author;
- } hurd2;
- struct {
- __u8 m_i_frag; /* Fragment number */
- __u8 m_i_fsize; /* Fragment size */
- __u16 m_pad1;
- __u32 m_i_reserved2[2];
- } masix2;
- } osd2; /* OS dependent 2 */
-};
-
-#define i_size_high i_dir_acl
-
-#if defined(__KERNEL__) || defined(__linux__)
-#define i_reserved1 osd1.linux1.l_i_reserved1
-#define i_frag osd2.linux2.l_i_frag
-#define i_fsize osd2.linux2.l_i_fsize
-#define i_reserved2 osd2.linux2.l_i_reserved2
-#endif
-
-#ifdef __hurd__
-#define i_translator osd1.hurd1.h_i_translator
-#define i_frag osd2.hurd2.h_i_frag;
-#define i_fsize osd2.hurd2.h_i_fsize;
-#define i_uid_high osd2.hurd2.h_i_uid_high
-#define i_gid_high osd2.hurd2.h_i_gid_high
-#define i_author osd2.hurd2.h_i_author
-#endif
-
-#ifdef __masix__
-#define i_reserved1 osd1.masix1.m_i_reserved1
-#define i_frag osd2.masix2.m_i_frag
-#define i_fsize osd2.masix2.m_i_fsize
-#define i_reserved2 osd2.masix2.m_i_reserved2
-#endif
-
-#endif /* i_mode */
-
-/*
- * File system states
- */
-#define EXT2_VALID_FS 0x0001 /* Unmounted cleanly */
-#define EXT2_ERROR_FS 0x0002 /* Errors detected */
-
-/*
- * Mount flags
- */
-#define EXT2_MOUNT_CHECK_NORMAL 0x0001 /* Do some more checks */
-#define EXT2_MOUNT_CHECK_STRICT 0x0002 /* Do again more checks */
-#define EXT2_MOUNT_CHECK (EXT2_MOUNT_CHECK_NORMAL | \
- EXT2_MOUNT_CHECK_STRICT)
-#define EXT2_MOUNT_GRPID 0x0004 /* Create files with directory's group */
-#define EXT2_MOUNT_DEBUG 0x0008 /* Some debugging messages */
-#define EXT2_MOUNT_ERRORS_CONT 0x0010 /* Continue on errors */
-#define EXT2_MOUNT_ERRORS_RO 0x0020 /* Remount fs ro on errors */
-#define EXT2_MOUNT_ERRORS_PANIC 0x0040 /* Panic on errors */
-#define EXT2_MOUNT_MINIX_DF 0x0080 /* Mimics the Minix statfs */
-
-#define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
-#define set_opt(o, opt) o |= EXT2_MOUNT_##opt
-#define test_opt(sb, opt) ((sb)->u.ext2_sb.s_mount_opt & \
- EXT2_MOUNT_##opt)
-/*
- * Maximal mount counts between two filesystem checks
- */
-#define EXT2_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */
-#define EXT2_DFL_CHECKINTERVAL 0 /* Don't use interval check */
-
-/*
- * Behaviour when detecting errors
- */
-#define EXT2_ERRORS_CONTINUE 1 /* Continue execution */
-#define EXT2_ERRORS_RO 2 /* Remount fs read-only */
-#define EXT2_ERRORS_PANIC 3 /* Panic */
-#define EXT2_ERRORS_DEFAULT EXT2_ERRORS_CONTINUE
-
-/*
- * Structure of the super block
- */
-struct ext2_super_block {
- __u32 s_inodes_count; /* Inodes count */
- __u32 s_blocks_count; /* Blocks count */
- __u32 s_r_blocks_count; /* Reserved blocks count */
- __u32 s_free_blocks_count; /* Free blocks count */
- __u32 s_free_inodes_count; /* Free inodes count */
- __u32 s_first_data_block; /* First Data Block */
- __u32 s_log_block_size; /* Block size */
- __s32 s_log_frag_size; /* Fragment size */
- __u32 s_blocks_per_group; /* # Blocks per group */
- __u32 s_frags_per_group; /* # Fragments per group */
- __u32 s_inodes_per_group; /* # Inodes per group */
- __u32 s_mtime; /* Mount time */
- __u32 s_wtime; /* Write time */
- __u16 s_mnt_count; /* Mount count */
- __s16 s_max_mnt_count; /* Maximal mount count */
- __u16 s_magic; /* Magic signature */
- __u16 s_state; /* File system state */
- __u16 s_errors; /* Behaviour when detecting errors */
- __u16 s_minor_rev_level; /* minor revision level */
- __u32 s_lastcheck; /* time of last check */
- __u32 s_checkinterval; /* max. time between checks */
- __u32 s_creator_os; /* OS */
- __u32 s_rev_level; /* Revision level */
- __u16 s_def_resuid; /* Default uid for reserved blocks */
- __u16 s_def_resgid; /* Default gid for reserved blocks */
- /*
- * These fields are for EXT2_DYNAMIC_REV superblocks only.
- *
- * Note: the difference between the compatible feature set and
- * the incompatible feature set is that if there is a bit set
- * in the incompatible feature set that the kernel doesn't
- * know about, it should refuse to mount the filesystem.
- *
- * e2fsck's requirements are more strict; if it doesn't know
- * about a feature in either the compatible or incompatible
- * feature set, it must abort and not try to meddle with
- * things it doesn't understand...
- */
- __u32 s_first_ino; /* First non-reserved inode */
- __u16 s_inode_size; /* size of inode structure */
- __u16 s_block_group_nr; /* block group # of this superblock */
- __u32 s_feature_compat; /* compatible feature set */
- __u32 s_feature_incompat; /* incompatible feature set */
- __u32 s_feature_ro_compat; /* readonly-compatible feature set */
- __u8 s_uuid[16]; /* 128-bit uuid for volume */
- char s_volume_name[16]; /* volume name */
- char s_last_mounted[64]; /* directory where last mounted */
- __u32 s_algorithm_usage_bitmap; /* For compression */
- /*
- * Performance hints. Directory preallocation should only
- * happen if the EXT2_COMPAT_PREALLOC flag is on.
- */
- __u8 s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
- __u8 s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
- __u16 s_padding1;
- __u32 s_reserved[204]; /* Padding to the end of the block */
-};
-
-#ifdef __KERNEL__
-#define EXT2_SB(sb) (&((sb)->u.ext2_sb))
-#else
-/* Assume that user mode programs are passing in an ext2fs superblock, not
- * a kernel struct super_block. This will allow us to call the feature-test
- * macros from user land. */
-#define EXT2_SB(sb) (sb)
-#endif
-
-/*
- * Codes for operating systems
- */
-#define EXT2_OS_LINUX 0
-#define EXT2_OS_HURD 1
-#define EXT2_OS_MASIX 2
-#define EXT2_OS_FREEBSD 3
-#define EXT2_OS_LITES 4
-
-/*
- * Revision levels
- */
-#define EXT2_GOOD_OLD_REV 0 /* The good old (original) format */
-#define EXT2_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */
-
-#define EXT2_CURRENT_REV EXT2_GOOD_OLD_REV
-#define EXT2_MAX_SUPP_REV EXT2_DYNAMIC_REV
-
-#define EXT2_GOOD_OLD_INODE_SIZE 128
-
-/*
- * Feature set definitions
- */
-
-#define EXT2_HAS_COMPAT_FEATURE(sb,mask) \
- ( EXT2_SB(sb)->s_feature_compat & (mask) )
-#define EXT2_HAS_RO_COMPAT_FEATURE(sb,mask) \
- ( EXT2_SB(sb)->s_feature_ro_compat & (mask) )
-#define EXT2_HAS_INCOMPAT_FEATURE(sb,mask) \
- ( EXT2_SB(sb)->s_feature_incompat & (mask) )
-
-#define EXT2_FEATURE_COMPAT_DIR_PREALLOC 0x0001
-
-#define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
-#define EXT2_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
-#define EXT2_FEATURE_RO_COMPAT_BTREE_DIR 0x0004
-
-#define EXT2_FEATURE_INCOMPAT_COMPRESSION 0x0001
-#define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002
-
-#define EXT2_FEATURE_COMPAT_SUPP 0
-#define EXT2_FEATURE_INCOMPAT_SUPP EXT2_FEATURE_INCOMPAT_FILETYPE
-#ifdef notyet
-#define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
- EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
- EXT2_FEATURE_RO_COMPAT_BTREE_DIR)
-#else
-#define EXT2_FEATURE_RO_COMPAT_SUPP 0
-#endif
-
-/*
- * Default values for user and/or group using reserved blocks
- */
-#define EXT2_DEF_RESUID 0
-#define EXT2_DEF_RESGID 0
-
-/*
- * Structure of a directory entry
- */
-#define EXT2_NAME_LEN 255
-
-struct ext2_dir_entry {
- __u32 inode; /* Inode number */
- __u16 rec_len; /* Directory entry length */
- __u16 name_len; /* Name length */
- char name[EXT2_NAME_LEN]; /* File name */
-};
-
-/*
- * The new version of the directory entry. Since EXT2 structures are
- * stored in intel byte order, and the name_len field could never be
- * bigger than 255 chars, it's safe to reclaim the extra byte for the
- * file_type field.
- */
-struct ext2_dir_entry_2 {
- __u32 inode; /* Inode number */
- __u16 rec_len; /* Directory entry length */
- __u8 name_len; /* Name length */
- __u8 file_type;
- char name[EXT2_NAME_LEN]; /* File name */
-};
-
-/*
- * Ext2 directory file types. Only the low 3 bits are used. The
- * other bits are reserved for now.
- */
-#define EXT2_FT_UNKNOWN 0
-#define EXT2_FT_REG_FILE 1
-#define EXT2_FT_DIR 2
-#define EXT2_FT_CHRDEV 3
-#define EXT2_FT_BLKDEV 4
-#define EXT2_FT_FIFO 5
-#define EXT2_FT_SOCK 6
-#define EXT2_FT_SYMLINK 7
-
-#define EXT2_FT_MAX 8
-
-/*
- * EXT2_DIR_PAD defines the directory entries boundaries
- *
- * NOTE: It must be a multiple of 4
- */
-#define EXT2_DIR_PAD 4
-#define EXT2_DIR_ROUND (EXT2_DIR_PAD - 1)
-#define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \
- ~EXT2_DIR_ROUND)
-
-#endif /* _LINUX_EXT2_FS_H */
diff --git a/sys/gnu/fs/ext2fs/ext2_fs_sb.h b/sys/gnu/fs/ext2fs/ext2_fs_sb.h
deleted file mode 100644
index 85f71bf39c7e..000000000000
--- a/sys/gnu/fs/ext2fs/ext2_fs_sb.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * modified for EXT2FS support in Lites 1.1
- *
- * Aug 1995, Godmar Back (gback@cs.utah.edu)
- * University of Utah, Department of Computer Science
- */
-/*
- * linux/include/linux/ext2_fs_sb.h
- *
- * Copyright (C) 1992, 1993, 1994, 1995
- * Remy Card (card@masi.ibp.fr)
- * Laboratoire MASI - Institut Blaise Pascal
- * Universite Pierre et Marie Curie (Paris VI)
- *
- * from
- *
- * linux/include/linux/minix_fs_sb.h
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
- */
-
-#ifndef _LINUX_EXT2_FS_SB
-#define _LINUX_EXT2_FS_SB
-
-/*
- * The following is not needed anymore since the descriptors buffer
- * heads are now dynamically allocated
- */
-/* #define EXT2_MAX_GROUP_DESC 8 */
-
-#define EXT2_MAX_GROUP_LOADED 8
-
-#define buffer_head buf
-#define MAXMNTLEN 512
-
-/*
- * second extended-fs super-block data in memory
- */
-struct ext2_sb_info {
- unsigned long s_frag_size; /* Size of a fragment in bytes */
- unsigned long s_frags_per_block;/* Number of fragments per block */
- unsigned long s_inodes_per_block;/* Number of inodes per block */
- unsigned long s_frags_per_group;/* Number of fragments in a group */
- unsigned long s_blocks_per_group;/* Number of blocks in a group */
- unsigned long s_inodes_per_group;/* Number of inodes in a group */
- unsigned long s_itb_per_group; /* Number of inode table blocks per group */
- unsigned long s_db_per_group; /* Number of descriptor blocks per group */
- unsigned long s_desc_per_block; /* Number of group descriptors per block */
- unsigned long s_groups_count; /* Number of groups in the fs */
- struct buffer_head * s_sbh; /* Buffer containing the super block */
- struct ext2_super_block * s_es; /* Pointer to the super block in the buffer */
- struct buffer_head ** s_group_desc;
- unsigned short s_loaded_inode_bitmaps;
- unsigned short s_loaded_block_bitmaps;
- unsigned long s_inode_bitmap_number[EXT2_MAX_GROUP_LOADED];
- struct buffer_head * s_inode_bitmap[EXT2_MAX_GROUP_LOADED];
- unsigned long s_block_bitmap_number[EXT2_MAX_GROUP_LOADED];
- struct buffer_head * s_block_bitmap[EXT2_MAX_GROUP_LOADED];
- int s_rename_lock;
- unsigned long s_mount_opt;
- unsigned short s_resuid;
- unsigned short s_resgid;
- unsigned short s_mount_state;
- /*
- stuff that FFS keeps in its super block or that linux
- has in its non-ext2 specific super block and which is
- generally considered useful
- */
- unsigned long s_blocksize;
- unsigned long s_blocksize_bits;
- unsigned int s_bshift; /* = log2(s_blocksize) */
- quad_t s_qbmask; /* = s_blocksize - 1 */
- unsigned int s_fsbtodb; /* shift to get disk block */
- char s_rd_only; /* read-only */
- char s_dirt; /* fs modified flag */
- char s_wasvalid; /* valid at mount time */
-
- char fs_fsmnt[MAXMNTLEN]; /* name mounted on */
-};
-
-#endif /* _LINUX_EXT2_FS_SB */
diff --git a/sys/gnu/fs/ext2fs/ext2_inode.c b/sys/gnu/fs/ext2fs/ext2_inode.c
deleted file mode 100644
index 657f6999542c..000000000000
--- a/sys/gnu/fs/ext2fs/ext2_inode.c
+++ /dev/null
@@ -1,493 +0,0 @@
-/*
- * modified for Lites 1.1
- *
- * Aug 1995, Godmar Back (gback@cs.utah.edu)
- * University of Utah, Department of Computer Science
- */
-/*
- * Copyright (c) 1982, 1986, 1989, 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)ext2_inode.c 8.5 (Berkeley) 12/30/93
- */
-
-#include "opt_quota.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/mount.h>
-#include <sys/buf.h>
-#include <sys/vnode.h>
-#include <sys/malloc.h>
-
-#include <vm/vm.h>
-#include <vm/vm_extern.h>
-
-#include <ufs/ufs/quota.h>
-#include <ufs/ufs/inode.h>
-#include <ufs/ufs/ufsmount.h>
-#include <ufs/ufs/ufs_extern.h>
-
-#include <gnu/ext2fs/ext2_fs.h>
-#include <gnu/ext2fs/ext2_fs_sb.h>
-#include <gnu/ext2fs/fs.h>
-#include <gnu/ext2fs/ext2_extern.h>
-
-static int ext2_indirtrunc __P((struct inode *, daddr_t, daddr_t, daddr_t, int,
- long *));
-
-int
-ext2_init(struct vfsconf *vfsp)
-{
- return (ufs_init(vfsp));
-}
-
-/*
- * Update the access, modified, and inode change times as specified by the
- * IN_ACCESS, IN_UPDATE, and IN_CHANGE flags respectively. Write the inode
- * to disk if the IN_MODIFIED flag is set (it may be set initially, or by
- * the timestamp update). The IN_LAZYMOD flag is set to force a write
- * later if not now. If we write now, then clear both IN_MODIFIED and
- * IN_LAZYMOD to reflect the presumably successful write, and if waitfor is
- * set, then wait for the write to complete.
- */
-int
-ext2_update(vp, waitfor)
- struct vnode *vp;
- int waitfor;
-{
- register struct ext2_sb_info *fs;
- struct buf *bp;
- struct inode *ip;
- int error;
-
- ufs_itimes(vp);
- ip = VTOI(vp);
- if ((ip->i_flag & IN_MODIFIED) == 0)
- return (0);
- ip->i_flag &= ~(IN_LAZYMOD | IN_MODIFIED);
- if (vp->v_mount->mnt_flag & MNT_RDONLY)
- return (0);
- fs = ip->i_e2fs;
- if ((error = bread(ip->i_devvp,
- fsbtodb(fs, ino_to_fsba(fs, ip->i_number)),
- (int)fs->s_blocksize, NOCRED, &bp)) != 0) {
- brelse(bp);
- return (error);
- }
- ext2_di2ei( &ip->i_din, (struct ext2_inode *) ((char *)bp->b_data + EXT2_INODE_SIZE *
- ino_to_fsbo(fs, ip->i_number)));
-/*
- if (waitfor && (vp->v_mount->mnt_flag & MNT_ASYNC) == 0)
- return (bwrite(bp));
- else {
-*/
- bdwrite(bp);
- return (0);
-/*
- }
-*/
-}
-
-#define SINGLE 0 /* index of single indirect block */
-#define DOUBLE 1 /* index of double indirect block */
-#define TRIPLE 2 /* index of triple indirect block */
-/*
- * Truncate the inode oip to at most length size, freeing the
- * disk blocks.
- */
-int
-ext2_truncate(vp, length, flags, cred, p)
- struct vnode *vp;
- off_t length;
- int flags;
- struct ucred *cred;
- struct proc *p;
-{
- register struct vnode *ovp = vp;
- register daddr_t lastblock;
- register struct inode *oip;
- daddr_t bn, lbn, lastiblock[NIADDR], indir_lbn[NIADDR];
- daddr_t oldblks[NDADDR + NIADDR], newblks[NDADDR + NIADDR];
- register struct ext2_sb_info *fs;
- struct buf *bp;
- int offset, size, level;
- long count, nblocks, blocksreleased = 0;
- register int i;
- int aflags, error, allerror;
- off_t osize;
-/*
-printf("ext2_truncate called %d to %d\n", VTOI(ovp)->i_number, length);
-*/ /*
- * negative file sizes will totally break the code below and
- * are not meaningful anyways.
- */
- if (length < 0)
- return EFBIG;
-
- oip = VTOI(ovp);
- if (ovp->v_type == VLNK &&
- oip->i_size < ovp->v_mount->mnt_maxsymlinklen) {
-#if DIAGNOSTIC
- if (length != 0)
- panic("ext2_truncate: partial truncate of symlink");
-#endif
- bzero((char *)&oip->i_shortlink, (u_int)oip->i_size);
- oip->i_size = 0;
- oip->i_flag |= IN_CHANGE | IN_UPDATE;
- return (UFS_UPDATE(ovp, 1));
- }
- if (oip->i_size == length) {
- oip->i_flag |= IN_CHANGE | IN_UPDATE;
- return (UFS_UPDATE(ovp, 0));
- }
-#if QUOTA
- if ((error = getinoquota(oip)) != 0)
- return (error);
-#endif
- fs = oip->i_e2fs;
- osize = oip->i_size;
- ext2_discard_prealloc(oip);
- /*
- * Lengthen the size of the file. We must ensure that the
- * last byte of the file is allocated. Since the smallest
- * value of oszie is 0, length will be at least 1.
- */
- if (osize < length) {
- offset = blkoff(fs, length - 1);
- lbn = lblkno(fs, length - 1);
- aflags = B_CLRBUF;
- if (flags & IO_SYNC)
- aflags |= B_SYNC;
- vnode_pager_setsize(ovp, length);
- if ((error = ext2_balloc(oip, lbn, offset + 1, cred, &bp,
- aflags)) != 0)
- return (error);
- oip->i_size = length;
- if (aflags & IO_SYNC)
- bwrite(bp);
- else
- bawrite(bp);
- oip->i_flag |= IN_CHANGE | IN_UPDATE;
- return (UFS_UPDATE(ovp, 1));
- }
- /*
- * Shorten the size of the file. If the file is not being
- * truncated to a block boundry, the contents of the
- * partial block following the end of the file must be
- * zero'ed in case it ever become accessable again because
- * of subsequent file growth.
- */
- /* I don't understand the comment above */
- offset = blkoff(fs, length);
- if (offset == 0) {
- oip->i_size = length;
- } else {
- lbn = lblkno(fs, length);
- aflags = B_CLRBUF;
- if (flags & IO_SYNC)
- aflags |= B_SYNC;
- if ((error = ext2_balloc(oip, lbn, offset, cred, &bp,
- aflags)) != 0)
- return (error);
- oip->i_size = length;
- size = blksize(fs, oip, lbn);
- bzero((char *)bp->b_data + offset, (u_int)(size - offset));
- allocbuf(bp, size);
- if (aflags & IO_SYNC)
- bwrite(bp);
- else
- bawrite(bp);
- }
- /*
- * Calculate index into inode's block list of
- * last direct and indirect blocks (if any)
- * which we want to keep. Lastblock is -1 when
- * the file is truncated to 0.
- */
- lastblock = lblkno(fs, length + fs->s_blocksize - 1) - 1;
- lastiblock[SINGLE] = lastblock - NDADDR;
- lastiblock[DOUBLE] = lastiblock[SINGLE] - NINDIR(fs);
- lastiblock[TRIPLE] = lastiblock[DOUBLE] - NINDIR(fs) * NINDIR(fs);
- nblocks = btodb(fs->s_blocksize);
- /*
- * Update file and block pointers on disk before we start freeing
- * blocks. If we crash before free'ing blocks below, the blocks
- * will be returned to the free list. lastiblock values are also
- * normalized to -1 for calls to ext2_indirtrunc below.
- */
- bcopy((caddr_t)&oip->i_db[0], (caddr_t)oldblks, sizeof oldblks);
- for (level = TRIPLE; level >= SINGLE; level--)
- if (lastiblock[level] < 0) {
- oip->i_ib[level] = 0;
- lastiblock[level] = -1;
- }
- for (i = NDADDR - 1; i > lastblock; i--)
- oip->i_db[i] = 0;
- oip->i_flag |= IN_CHANGE | IN_UPDATE;
- allerror = UFS_UPDATE(ovp, 1);
-
- /*
- * Having written the new inode to disk, save its new configuration
- * and put back the old block pointers long enough to process them.
- * Note that we save the new block configuration so we can check it
- * when we are done.
- */
- bcopy((caddr_t)&oip->i_db[0], (caddr_t)newblks, sizeof newblks);
- bcopy((caddr_t)oldblks, (caddr_t)&oip->i_db[0], sizeof oldblks);
- oip->i_size = osize;
- error = vtruncbuf(ovp, cred, p, length, (int)fs->s_blocksize);
- if (error && (allerror == 0))
- allerror = error;
-
- /*
- * Indirect blocks first.
- */
- indir_lbn[SINGLE] = -NDADDR;
- indir_lbn[DOUBLE] = indir_lbn[SINGLE] - NINDIR(fs) - 1;
- indir_lbn[TRIPLE] = indir_lbn[DOUBLE] - NINDIR(fs) * NINDIR(fs) - 1;
- for (level = TRIPLE; level >= SINGLE; level--) {
- bn = oip->i_ib[level];
- if (bn != 0) {
- error = ext2_indirtrunc(oip, indir_lbn[level],
- fsbtodb(fs, bn), lastiblock[level], level, &count);
- if (error)
- allerror = error;
- blocksreleased += count;
- if (lastiblock[level] < 0) {
- oip->i_ib[level] = 0;
- ext2_blkfree(oip, bn, fs->s_frag_size);
- blocksreleased += nblocks;
- }
- }
- if (lastiblock[level] >= 0)
- goto done;
- }
-
- /*
- * All whole direct blocks or frags.
- */
- for (i = NDADDR - 1; i > lastblock; i--) {
- register long bsize;
-
- bn = oip->i_db[i];
- if (bn == 0)
- continue;
- oip->i_db[i] = 0;
- bsize = blksize(fs, oip, i);
- ext2_blkfree(oip, bn, bsize);
- blocksreleased += btodb(bsize);
- }
- if (lastblock < 0)
- goto done;
-
- /*
- * Finally, look for a change in size of the
- * last direct block; release any frags.
- */
- bn = oip->i_db[lastblock];
- if (bn != 0) {
- long oldspace, newspace;
-
- /*
- * Calculate amount of space we're giving
- * back as old block size minus new block size.
- */
- oldspace = blksize(fs, oip, lastblock);
- oip->i_size = length;
- newspace = blksize(fs, oip, lastblock);
- if (newspace == 0)
- panic("itrunc: newspace");
- if (oldspace - newspace > 0) {
- /*
- * Block number of space to be free'd is
- * the old block # plus the number of frags
- * required for the storage we're keeping.
- */
- bn += numfrags(fs, newspace);
- ext2_blkfree(oip, bn, oldspace - newspace);
- blocksreleased += btodb(oldspace - newspace);
- }
- }
-done:
-#if DIAGNOSTIC
- for (level = SINGLE; level <= TRIPLE; level++)
- if (newblks[NDADDR + level] != oip->i_ib[level])
- panic("itrunc1");
- for (i = 0; i < NDADDR; i++)
- if (newblks[i] != oip->i_db[i])
- panic("itrunc2");
- if (length == 0 && (!TAILQ_EMPTY(&ovp->v_dirtyblkhd) ||
- !TAILQ_EMPTY(&ovp->v_cleanblkhd)))
- panic("itrunc3");
-#endif /* DIAGNOSTIC */
- /*
- * Put back the real size.
- */
- oip->i_size = length;
- oip->i_blocks -= blocksreleased;
- if (oip->i_blocks < 0) /* sanity */
- oip->i_blocks = 0;
- oip->i_flag |= IN_CHANGE;
- vnode_pager_setsize(ovp, length);
-#if QUOTA
- (void) chkdq(oip, -blocksreleased, NOCRED, 0);
-#endif
- return (allerror);
-}
-
-/*
- * Release blocks associated with the inode ip and stored in the indirect
- * block bn. Blocks are free'd in LIFO order up to (but not including)
- * lastbn. If level is greater than SINGLE, the block is an indirect block
- * and recursive calls to indirtrunc must be used to cleanse other indirect
- * blocks.
- *
- * NB: triple indirect blocks are untested.
- */
-
-static int
-ext2_indirtrunc(ip, lbn, dbn, lastbn, level, countp)
- register struct inode *ip;
- daddr_t lbn, lastbn;
- daddr_t dbn;
- int level;
- long *countp;
-{
- register int i;
- struct buf *bp;
- register struct ext2_sb_info *fs = ip->i_e2fs;
- register daddr_t *bap;
- struct vnode *vp;
- daddr_t *copy, nb, nlbn, last;
- long blkcount, factor;
- int nblocks, blocksreleased = 0;
- int error = 0, allerror = 0;
-
- /*
- * Calculate index in current block of last
- * block to be kept. -1 indicates the entire
- * block so we need not calculate the index.
- */
- factor = 1;
- for (i = SINGLE; i < level; i++)
- factor *= NINDIR(fs);
- last = lastbn;
- if (lastbn > 0)
- last /= factor;
- nblocks = btodb(fs->s_blocksize);
- /*
- * Get buffer of block pointers, zero those entries corresponding
- * to blocks to be free'd, and update on disk copy first. Since
- * double(triple) indirect before single(double) indirect, calls
- * to bmap on these blocks will fail. However, we already have
- * the on disk address, so we have to set the b_blkno field
- * explicitly instead of letting bread do everything for us.
- */
- vp = ITOV(ip);
- bp = getblk(vp, lbn, (int)fs->s_blocksize, 0, 0);
- if (bp->b_flags & (B_DONE | B_DELWRI)) {
- } else {
- bp->b_flags |= B_READ;
- if (bp->b_bcount > bp->b_bufsize)
- panic("ext2_indirtrunc: bad buffer size");
- bp->b_blkno = dbn;
- vfs_busy_pages(bp, 0);
- VOP_STRATEGY(vp, bp);
- error = biowait(bp);
- }
- if (error) {
- brelse(bp);
- *countp = 0;
- return (error);
- }
-
- bap = (daddr_t *)bp->b_data;
- MALLOC(copy, daddr_t *, fs->s_blocksize, M_TEMP, M_WAITOK);
- bcopy((caddr_t)bap, (caddr_t)copy, (u_int)fs->s_blocksize);
- bzero((caddr_t)&bap[last + 1],
- (u_int)(NINDIR(fs) - (last + 1)) * sizeof (daddr_t));
- if (last == -1)
- bp->b_flags |= B_INVAL;
- error = bwrite(bp);
- if (error)
- allerror = error;
- bap = copy;
-
- /*
- * Recursively free totally unused blocks.
- */
- for (i = NINDIR(fs) - 1, nlbn = lbn + 1 - i * factor; i > last;
- i--, nlbn += factor) {
- nb = bap[i];
- if (nb == 0)
- continue;
- if (level > SINGLE) {
- if ((error = ext2_indirtrunc(ip, nlbn,
- fsbtodb(fs, nb), (daddr_t)-1, level - 1, &blkcount)) != 0)
- allerror = error;
- blocksreleased += blkcount;
- }
- ext2_blkfree(ip, nb, fs->s_blocksize);
- blocksreleased += nblocks;
- }
-
- /*
- * Recursively free last partial block.
- */
- if (level > SINGLE && lastbn >= 0) {
- last = lastbn % factor;
- nb = bap[i];
- if (nb != 0) {
- if ((error = ext2_indirtrunc(ip, nlbn, fsbtodb(fs, nb),
- last, level - 1, &blkcount)) != 0)
- allerror = error;
- blocksreleased += blkcount;
- }
- }
- FREE(copy, M_TEMP);
- *countp = blocksreleased;
- return (allerror);
-}
-
-/*
- * discard preallocated blocks
- */
-int
-ext2_inactive(ap)
- struct vop_inactive_args /* {
- struct vnode *a_vp;
- } */ *ap;
-{
- ext2_discard_prealloc(VTOI(ap->a_vp));
- return ufs_inactive(ap);
-}
-
diff --git a/sys/gnu/fs/ext2fs/ext2_inode_cnv.c b/sys/gnu/fs/ext2fs/ext2_inode_cnv.c
deleted file mode 100644
index 3e8e0ff73445..000000000000
--- a/sys/gnu/fs/ext2fs/ext2_inode_cnv.c
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright (c) 1995 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$
- * $FreeBSD$
- */
-
-/*
- * routines to convert on disk ext2 inodes in dinodes and back
- */
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/lock.h>
-#include <sys/stat.h>
-#include <sys/vnode.h>
-
-#include <ufs/ufs/quota.h>
-#include <ufs/ufs/inode.h>
-
-/*
- * Undo the definitions in <ufs/ufs/inode.h> that would destroy the include
- * of <gnu/ext2fs/ext2_fs.h>.
- */
-#undef i_atime
-#undef i_blocks
-#undef i_ctime
-#undef i_db
-#undef i_flags
-#undef i_gen
-#undef i_gid
-#undef i_ib
-#undef i_mode
-#undef i_mtime
-#undef i_nlink
-#undef i_rdev
-#undef i_shortlink
-#undef i_size
-#undef i_uid
-
-#include <gnu/ext2fs/ext2_fs.h>
-#include <gnu/ext2fs/ext2_extern.h>
-
-void
-ext2_print_dinode( di )
- struct dinode *di;
-{
- int i;
- printf( /* "Inode: %5d" */
- " Type: %10s Mode: 0x%o Flags: 0x%x Version: %d\n",
- "n/a", di->di_mode, di->di_flags, di->di_gen);
- printf( "User: %5lu Group: %5lu Size: %lu\n",
- (unsigned long)di->di_uid, (unsigned long)di->di_gid,
- (unsigned long)di->di_size);
- printf( "Links: %3d Blockcount: %d\n",
- di->di_nlink, di->di_blocks);
- printf( "ctime: 0x%x", di->di_ctime);
- printf( "atime: 0x%x", di->di_atime);
- printf( "mtime: 0x%x", di->di_mtime);
- printf( "BLOCKS: ");
- for(i=0; i < (di->di_blocks <= 24 ? ((di->di_blocks+1)/2): 12); i++)
- printf("%d ", di->di_db[i]);
- printf("\n");
-}
-
-void
-ext2_print_inode( in )
- struct inode *in;
-{
- printf( "Inode: %5d", in->i_number);
- ext2_print_dinode(&in->i_din);
-}
-
-/*
- * raw ext2 inode to dinode
- */
-void
-ext2_ei2di(ei, di)
- struct ext2_inode *ei;
- struct dinode *di;
-{
- int i;
-
- di->di_nlink = ei->i_links_count;
- /* Godmar thinks - if the link count is zero, then the inode is
- unused - according to ext2 standards. Ufs marks this fact
- by setting i_mode to zero - why ?
- I can see that this might lead to problems in an undelete.
- */
- di->di_mode = ei->i_links_count ? ei->i_mode : 0;
- di->di_size = ei->i_size;
- di->di_atime = ei->i_atime;
- di->di_mtime = ei->i_mtime;
- di->di_ctime = ei->i_ctime;
- di->di_flags = 0;
- di->di_flags |= (ei->i_flags & EXT2_APPEND_FL) ? APPEND : 0;
- di->di_flags |= (ei->i_flags & EXT2_IMMUTABLE_FL) ? IMMUTABLE : 0;
- di->di_blocks = ei->i_blocks;
- di->di_gen = ei->i_generation;
- di->di_uid = ei->i_uid;
- di->di_gid = ei->i_gid;
- /* XXX use memcpy */
- for(i = 0; i < NDADDR; i++)
- di->di_db[i] = ei->i_block[i];
- for(i = 0; i < NIADDR; i++)
- di->di_ib[i] = ei->i_block[EXT2_NDIR_BLOCKS + i];
-}
-
-/*
- * dinode to raw ext2 inode
- */
-void
-ext2_di2ei(di, ei)
- struct dinode *di;
- struct ext2_inode *ei;
-{
- int i;
-
- ei->i_mode = di->di_mode;
- ei->i_links_count = di->di_nlink;
- /*
- Godmar thinks: if dtime is nonzero, ext2 says this inode
- has been deleted, this would correspond to a zero link count
- */
- ei->i_dtime = ei->i_links_count ? 0 : di->di_mtime;
- ei->i_size = di->di_size;
- ei->i_atime = di->di_atime;
- ei->i_mtime = di->di_mtime;
- ei->i_ctime = di->di_ctime;
- ei->i_flags = di->di_flags;
- ei->i_flags = 0;
- ei->i_flags |= (di->di_flags & APPEND) ? EXT2_APPEND_FL: 0;
- ei->i_flags |= (di->di_flags & IMMUTABLE)
- ? EXT2_IMMUTABLE_FL: 0;
- ei->i_blocks = di->di_blocks;
- ei->i_generation = di->di_gen;
- ei->i_uid = di->di_uid;
- ei->i_gid = di->di_gid;
- /* XXX use memcpy */
- for(i = 0; i < NDADDR; i++)
- ei->i_block[i] = di->di_db[i];
- for(i = 0; i < NIADDR; i++)
- ei->i_block[EXT2_NDIR_BLOCKS + i] = di->di_ib[i];
-}
diff --git a/sys/gnu/fs/ext2fs/ext2_linux_balloc.c b/sys/gnu/fs/ext2fs/ext2_linux_balloc.c
deleted file mode 100644
index 5e90fee75d12..000000000000
--- a/sys/gnu/fs/ext2fs/ext2_linux_balloc.c
+++ /dev/null
@@ -1,582 +0,0 @@
-/*
- * modified for Lites 1.1
- *
- * Aug 1995, Godmar Back (gback@cs.utah.edu)
- * University of Utah, Department of Computer Science
- */
-/*
- * linux/fs/ext2/balloc.c
- *
- * Copyright (C) 1992, 1993, 1994, 1995
- * Remy Card (card@masi.ibp.fr)
- * Laboratoire MASI - Institut Blaise Pascal
- * Universite Pierre et Marie Curie (Paris VI)
- *
- * Enhanced block allocation by Stephen Tweedie (sct@dcs.ed.ac.uk), 1993
- */
-
-/*
- * The free blocks are managed by bitmaps. A file system contains several
- * blocks groups. Each group contains 1 bitmap block for blocks, 1 bitmap
- * block for inodes, N blocks for the inode table and data blocks.
- *
- * The file system contains group descriptors which are located after the
- * super block. Each descriptor contains the number of the bitmap block and
- * the free blocks count in the block. The descriptors are loaded in memory
- * when a file system is mounted (see ext2_read_super).
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/buf.h>
-#include <sys/proc.h>
-#include <sys/mount.h>
-#include <sys/vnode.h>
-
-#include <ufs/ufs/quota.h>
-#include <ufs/ufs/ufsmount.h>
-#include <gnu/ext2fs/ext2_extern.h>
-#include <gnu/ext2fs/ext2_fs.h>
-#include <gnu/ext2fs/ext2_fs_sb.h>
-#include <gnu/ext2fs/fs.h>
-
-#ifdef __i386__
-#include <gnu/ext2fs/i386-bitops.h>
-#else
-#error Provide an bitops.h file, please !
-#endif
-
-#define in_range(b, first, len) ((b) >= (first) && (b) <= (first) + (len) - 1)
-
-/* got rid of get_group_desc since it can already be found in
- * ext2_linux_ialloc.c
- */
-
-static void read_block_bitmap (struct mount * mp,
- unsigned int block_group,
- unsigned long bitmap_nr)
-{
- struct ext2_sb_info *sb = VFSTOUFS(mp)->um_e2fs;
- struct ext2_group_desc * gdp;
- struct buffer_head * bh;
- int error;
-
- gdp = get_group_desc (mp, block_group, NULL);
- if ((error = bread (VFSTOUFS(mp)->um_devvp,
- fsbtodb(sb, gdp->bg_block_bitmap),sb->s_blocksize, NOCRED, &bh)) != 0)
- panic ( "read_block_bitmap: "
- "Cannot read block bitmap - "
- "block_group = %d, block_bitmap = %lu",
- block_group, (unsigned long) gdp->bg_block_bitmap);
- sb->s_block_bitmap_number[bitmap_nr] = block_group;
- sb->s_block_bitmap[bitmap_nr] = bh;
- LCK_BUF(bh)
-}
-
-/*
- * load_block_bitmap loads the block bitmap for a blocks group
- *
- * It maintains a cache for the last bitmaps loaded. This cache is managed
- * with a LRU algorithm.
- *
- * Notes:
- * 1/ There is one cache per mounted file system.
- * 2/ If the file system contains less than EXT2_MAX_GROUP_LOADED groups,
- * this function reads the bitmap without maintaining a LRU cache.
- */
-static int load__block_bitmap (struct mount * mp,
- unsigned int block_group)
-{
- int i, j;
- struct ext2_sb_info *sb = VFSTOUFS(mp)->um_e2fs;
- unsigned long block_bitmap_number;
- struct buffer_head * block_bitmap;
-
- if (block_group >= sb->s_groups_count)
- panic ( "load_block_bitmap: "
- "block_group >= groups_count - "
- "block_group = %d, groups_count = %lu",
- block_group, sb->s_groups_count);
-
- if (sb->s_groups_count <= EXT2_MAX_GROUP_LOADED) {
- if (sb->s_block_bitmap[block_group]) {
- if (sb->s_block_bitmap_number[block_group] !=
- block_group)
- panic ( "load_block_bitmap: "
- "block_group != block_bitmap_number");
- else
- return block_group;
- } else {
- read_block_bitmap (mp, block_group, block_group);
- return block_group;
- }
- }
-
- for (i = 0; i < sb->s_loaded_block_bitmaps &&
- sb->s_block_bitmap_number[i] != block_group; i++)
- ;
- if (i < sb->s_loaded_block_bitmaps &&
- sb->s_block_bitmap_number[i] == block_group) {
- block_bitmap_number = sb->s_block_bitmap_number[i];
- block_bitmap = sb->s_block_bitmap[i];
- for (j = i; j > 0; j--) {
- sb->s_block_bitmap_number[j] =
- sb->s_block_bitmap_number[j - 1];
- sb->s_block_bitmap[j] =
- sb->s_block_bitmap[j - 1];
- }
- sb->s_block_bitmap_number[0] = block_bitmap_number;
- sb->s_block_bitmap[0] = block_bitmap;
- } else {
- if (sb->s_loaded_block_bitmaps < EXT2_MAX_GROUP_LOADED)
- sb->s_loaded_block_bitmaps++;
- else
- ULCK_BUF(sb->s_block_bitmap[EXT2_MAX_GROUP_LOADED - 1])
-
- for (j = sb->s_loaded_block_bitmaps - 1; j > 0; j--) {
- sb->s_block_bitmap_number[j] =
- sb->s_block_bitmap_number[j - 1];
- sb->s_block_bitmap[j] =
- sb->s_block_bitmap[j - 1];
- }
- read_block_bitmap (mp, block_group, 0);
- }
- return 0;
-}
-
-static __inline int load_block_bitmap (struct mount * mp,
- unsigned int block_group)
-{
- struct ext2_sb_info *sb = VFSTOUFS(mp)->um_e2fs;
- if (sb->s_loaded_block_bitmaps > 0 &&
- sb->s_block_bitmap_number[0] == block_group)
- return 0;
-
- if (sb->s_groups_count <= EXT2_MAX_GROUP_LOADED &&
- sb->s_block_bitmap_number[block_group] == block_group &&
- sb->s_block_bitmap[block_group])
- return block_group;
-
- return load__block_bitmap (mp, block_group);
-}
-
-void ext2_free_blocks (struct mount * mp, unsigned long block,
- unsigned long count)
-{
- struct ext2_sb_info *sb = VFSTOUFS(mp)->um_e2fs;
- struct buffer_head * bh;
- struct buffer_head * bh2;
- unsigned long block_group;
- unsigned long bit;
- unsigned long i;
- int bitmap_nr;
- struct ext2_group_desc * gdp;
- struct ext2_super_block * es = sb->s_es;
-
- if (!sb) {
- printf ("ext2_free_blocks: nonexistent device");
- return;
- }
- lock_super (VFSTOUFS(mp)->um_devvp);
- if (block < es->s_first_data_block ||
- (block + count) > es->s_blocks_count) {
- printf ( "ext2_free_blocks: "
- "Freeing blocks not in datazone - "
- "block = %lu, count = %lu", block, count);
- unlock_super (VFSTOUFS(mp)->um_devvp);
- return;
- }
-
- ext2_debug ("freeing blocks %lu to %lu\n", block, block+count-1);
-
- block_group = (block - es->s_first_data_block) /
- EXT2_BLOCKS_PER_GROUP(sb);
- bit = (block - es->s_first_data_block) % EXT2_BLOCKS_PER_GROUP(sb);
- if (bit + count > EXT2_BLOCKS_PER_GROUP(sb))
- panic ( "ext2_free_blocks: "
- "Freeing blocks across group boundary - "
- "Block = %lu, count = %lu",
- block, count);
- bitmap_nr = load_block_bitmap (mp, block_group);
- bh = sb->s_block_bitmap[bitmap_nr];
- gdp = get_group_desc (mp, block_group, &bh2);
-
- if (/* test_opt (sb, CHECK_STRICT) && assume always strict ! */
- (in_range (gdp->bg_block_bitmap, block, count) ||
- in_range (gdp->bg_inode_bitmap, block, count) ||
- in_range (block, gdp->bg_inode_table,
- sb->s_itb_per_group) ||
- in_range (block + count - 1, gdp->bg_inode_table,
- sb->s_itb_per_group)))
- panic ( "ext2_free_blocks: "
- "Freeing blocks in system zones - "
- "Block = %lu, count = %lu",
- block, count);
-
- for (i = 0; i < count; i++) {
- if (!clear_bit (bit + i, bh->b_data))
- printf ("ext2_free_blocks: "
- "bit already cleared for block %lu",
- block);
- else {
- gdp->bg_free_blocks_count++;
- es->s_free_blocks_count++;
- }
- }
-
- mark_buffer_dirty(bh2);
- mark_buffer_dirty(bh);
-/****
- if (sb->s_flags & MS_SYNCHRONOUS) {
- ll_rw_block (WRITE, 1, &bh);
- wait_on_buffer (bh);
- }
-****/
- sb->s_dirt = 1;
- unlock_super (VFSTOUFS(mp)->um_devvp);
- return;
-}
-
-/*
- * ext2_new_block uses a goal block to assist allocation. If the goal is
- * free, or there is a free block within 32 blocks of the goal, that block
- * is allocated. Otherwise a forward search is made for a free block; within
- * each block group the search first looks for an entire free byte in the block
- * bitmap, and then for any free bit if that fails.
- */
-int ext2_new_block (struct mount * mp, unsigned long goal,
- u_int32_t * prealloc_count,
- u_int32_t * prealloc_block)
-{
- struct ext2_sb_info *sb = VFSTOUFS(mp)->um_e2fs;
- struct buffer_head * bh;
- struct buffer_head * bh2;
- char * p, * r;
- int i, j, k, tmp;
- int bitmap_nr;
- struct ext2_group_desc * gdp;
- struct ext2_super_block * es = sb->s_es;
-
-#ifdef EXT2FS_DEBUG
- static int goal_hits = 0, goal_attempts = 0;
-#endif
- if (!sb) {
- printf ("ext2_new_block: nonexistent device");
- return 0;
- }
- lock_super (VFSTOUFS(mp)->um_devvp);
-
- ext2_debug ("goal=%lu.\n", goal);
-
-repeat:
- /*
- * First, test whether the goal block is free.
- */
- if (goal < es->s_first_data_block || goal >= es->s_blocks_count)
- goal = es->s_first_data_block;
- i = (goal - es->s_first_data_block) / EXT2_BLOCKS_PER_GROUP(sb);
- gdp = get_group_desc (mp, i, &bh2);
- if (gdp->bg_free_blocks_count > 0) {
- j = ((goal - es->s_first_data_block) % EXT2_BLOCKS_PER_GROUP(sb));
-#ifdef EXT2FS_DEBUG
- if (j)
- goal_attempts++;
-#endif
- bitmap_nr = load_block_bitmap (mp, i);
- bh = sb->s_block_bitmap[bitmap_nr];
-
- ext2_debug ("goal is at %d:%d.\n", i, j);
-
- if (!test_bit(j, bh->b_data)) {
-#ifdef EXT2FS_DEBUG
- goal_hits++;
- ext2_debug ("goal bit allocated.\n");
-#endif
- goto got_block;
- }
- if (j) {
- /*
- * The goal was occupied; search forward for a free
- * block within the next XX blocks.
- *
- * end_goal is more or less random, but it has to be
- * less than EXT2_BLOCKS_PER_GROUP. Aligning up to the
- * next 64-bit boundary is simple..
- */
- int end_goal = (j + 63) & ~63;
- j = find_next_zero_bit(bh->b_data, end_goal, j);
- if (j < end_goal)
- goto got_block;
- }
-
- ext2_debug ("Bit not found near goal\n");
-
- /*
- * There has been no free block found in the near vicinity
- * of the goal: do a search forward through the block groups,
- * searching in each group first for an entire free byte in
- * the bitmap and then for any free bit.
- *
- * Search first in the remainder of the current group; then,
- * cyclicly search through the rest of the groups.
- */
- p = ((char *) bh->b_data) + (j >> 3);
- r = memscan(p, 0, (EXT2_BLOCKS_PER_GROUP(sb) - j + 7) >> 3);
- k = (r - ((char *) bh->b_data)) << 3;
- if (k < EXT2_BLOCKS_PER_GROUP(sb)) {
- j = k;
- goto search_back;
- }
- k = find_next_zero_bit ((unsigned long *) bh->b_data,
- EXT2_BLOCKS_PER_GROUP(sb),
- j);
- if (k < EXT2_BLOCKS_PER_GROUP(sb)) {
- j = k;
- goto got_block;
- }
- }
-
- ext2_debug ("Bit not found in block group %d.\n", i);
-
- /*
- * Now search the rest of the groups. We assume that
- * i and gdp correctly point to the last group visited.
- */
- for (k = 0; k < sb->s_groups_count; k++) {
- i++;
- if (i >= sb->s_groups_count)
- i = 0;
- gdp = get_group_desc (mp, i, &bh2);
- if (gdp->bg_free_blocks_count > 0)
- break;
- }
- if (k >= sb->s_groups_count) {
- unlock_super (VFSTOUFS(mp)->um_devvp);
- return 0;
- }
- bitmap_nr = load_block_bitmap (mp, i);
- bh = sb->s_block_bitmap[bitmap_nr];
- r = memscan(bh->b_data, 0, EXT2_BLOCKS_PER_GROUP(sb) >> 3);
- j = (r - bh->b_data) << 3;
-
- if (j < EXT2_BLOCKS_PER_GROUP(sb))
- goto search_back;
- else
- j = find_first_zero_bit ((unsigned long *) bh->b_data,
- EXT2_BLOCKS_PER_GROUP(sb));
- if (j >= EXT2_BLOCKS_PER_GROUP(sb)) {
- printf ( "ext2_new_block: "
- "Free blocks count corrupted for block group %d", i);
- unlock_super (VFSTOUFS(mp)->um_devvp);
- return 0;
- }
-
-search_back:
- /*
- * We have succeeded in finding a free byte in the block
- * bitmap. Now search backwards up to 7 bits to find the
- * start of this group of free blocks.
- */
- for (k = 0; k < 7 && j > 0 && !test_bit (j - 1, bh->b_data); k++, j--);
-
-got_block:
-
- ext2_debug ("using block group %d(%d)\n", i, gdp->bg_free_blocks_count);
-
- tmp = j + i * EXT2_BLOCKS_PER_GROUP(sb) + es->s_first_data_block;
-
- if (/* test_opt (sb, CHECK_STRICT) && we are always strict. */
- (tmp == gdp->bg_block_bitmap ||
- tmp == gdp->bg_inode_bitmap ||
- in_range (tmp, gdp->bg_inode_table, sb->s_itb_per_group)))
- panic ( "ext2_new_block: "
- "Allocating block in system zone - "
- "%dth block = %u in group %u", j, tmp, i);
-
- if (set_bit (j, bh->b_data)) {
- printf ( "ext2_new_block: "
- "bit already set for block %d", j);
- goto repeat;
- }
-
- ext2_debug ("found bit %d\n", j);
-
- /*
- * Do block preallocation now if required.
- */
-#ifdef EXT2_PREALLOCATE
- if (prealloc_block) {
- *prealloc_count = 0;
- *prealloc_block = tmp + 1;
- for (k = 1;
- k < 8 && (j + k) < EXT2_BLOCKS_PER_GROUP(sb); k++) {
- if (set_bit (j + k, bh->b_data))
- break;
- (*prealloc_count)++;
- }
- gdp->bg_free_blocks_count -= *prealloc_count;
- es->s_free_blocks_count -= *prealloc_count;
- ext2_debug ("Preallocated a further %lu bits.\n",
- *prealloc_count);
- }
-#endif
-
- j = tmp;
-
- mark_buffer_dirty(bh);
-/****
- if (sb->s_flags & MS_SYNCHRONOUS) {
- ll_rw_block (WRITE, 1, &bh);
- wait_on_buffer (bh);
- }
-****/
- if (j >= es->s_blocks_count) {
- printf ( "ext2_new_block: "
- "block >= blocks count - "
- "block_group = %d, block=%d", i, j);
- unlock_super (VFSTOUFS(mp)->um_devvp);
- return 0;
- }
-
- ext2_debug ("allocating block %d. "
- "Goal hits %d of %d.\n", j, goal_hits, goal_attempts);
-
- gdp->bg_free_blocks_count--;
- mark_buffer_dirty(bh2);
- es->s_free_blocks_count--;
- sb->s_dirt = 1;
- unlock_super (VFSTOUFS(mp)->um_devvp);
- return j;
-}
-
-#ifdef unused
-static unsigned long ext2_count_free_blocks (struct mount * mp)
-{
- struct ext2_sb_info *sb = VFSTOUFS(mp)->um_e2fs;
-#ifdef EXT2FS_DEBUG
- struct ext2_super_block * es;
- unsigned long desc_count, bitmap_count, x;
- int bitmap_nr;
- struct ext2_group_desc * gdp;
- int i;
-
- lock_super (VFSTOUFS(mp)->um_devvp);
- es = sb->s_es;
- desc_count = 0;
- bitmap_count = 0;
- gdp = NULL;
- for (i = 0; i < sb->s_groups_count; i++) {
- gdp = get_group_desc (mp, i, NULL);
- desc_count += gdp->bg_free_blocks_count;
- bitmap_nr = load_block_bitmap (mp, i);
- x = ext2_count_free (sb->s_block_bitmap[bitmap_nr],
- sb->s_blocksize);
- ext2_debug ("group %d: stored = %d, counted = %lu\n",
- i, gdp->bg_free_blocks_count, x);
- bitmap_count += x;
- }
- ext2_debug( "stored = %lu, computed = %lu, %lu\n",
- es->s_free_blocks_count, desc_count, bitmap_count);
- unlock_super (VFSTOUFS(mp)->um_devvp);
- return bitmap_count;
-#else
- return sb->s_es->s_free_blocks_count;
-#endif
-}
-#endif /* unused */
-
-static __inline int block_in_use (unsigned long block,
- struct ext2_sb_info * sb,
- unsigned char * map)
-{
- return test_bit ((block - sb->s_es->s_first_data_block) %
- EXT2_BLOCKS_PER_GROUP(sb), map);
-}
-
-#ifdef unused
-static void ext2_check_blocks_bitmap (struct mount * mp)
-{
- struct ext2_sb_info *sb = VFSTOUFS(mp)->um_e2fs;
- struct buffer_head * bh;
- struct ext2_super_block * es;
- unsigned long desc_count, bitmap_count, x;
- unsigned long desc_blocks;
- int bitmap_nr;
- struct ext2_group_desc * gdp;
- int i, j;
-
- lock_super (VFSTOUFS(mp)->um_devvp);
- es = sb->s_es;
- desc_count = 0;
- bitmap_count = 0;
- gdp = NULL;
- desc_blocks = (sb->s_groups_count + EXT2_DESC_PER_BLOCK(sb) - 1) /
- EXT2_DESC_PER_BLOCK(sb);
- for (i = 0; i < sb->s_groups_count; i++) {
- gdp = get_group_desc (mp, i, NULL);
- desc_count += gdp->bg_free_blocks_count;
- bitmap_nr = load_block_bitmap (mp, i);
- bh = sb->s_block_bitmap[bitmap_nr];
-
- if (!test_bit (0, bh->b_data))
- printf ( "ext2_check_blocks_bitmap: "
- "Superblock in group %d is marked free", i);
-
- for (j = 0; j < desc_blocks; j++)
- if (!test_bit (j + 1, bh->b_data))
- printf ("ext2_check_blocks_bitmap: "
- "Descriptor block #%d in group "
- "%d is marked free", j, i);
-
- if (!block_in_use (gdp->bg_block_bitmap, sb, bh->b_data))
- printf ("ext2_check_blocks_bitmap: "
- "Block bitmap for group %d is marked free",
- i);
-
- if (!block_in_use (gdp->bg_inode_bitmap, sb, bh->b_data))
- printf ("ext2_check_blocks_bitmap: "
- "Inode bitmap for group %d is marked free",
- i);
-
- for (j = 0; j < sb->s_itb_per_group; j++)
- if (!block_in_use (gdp->bg_inode_table + j, sb, bh->b_data))
- printf ("ext2_check_blocks_bitmap: "
- "Block #%d of the inode table in "
- "group %d is marked free", j, i);
-
- x = ext2_count_free (bh, sb->s_blocksize);
- if (gdp->bg_free_blocks_count != x)
- printf ("ext2_check_blocks_bitmap: "
- "Wrong free blocks count for group %d, "
- "stored = %d, counted = %lu", i,
- gdp->bg_free_blocks_count, x);
- bitmap_count += x;
- }
- if (es->s_free_blocks_count != bitmap_count)
- printf ("ext2_check_blocks_bitmap: "
- "Wrong free blocks count in super block, "
- "stored = %lu, counted = %lu",
- (unsigned long) es->s_free_blocks_count, bitmap_count);
- unlock_super (VFSTOUFS(mp)->um_devvp);
-}
-#endif /* unused */
-
-/*
- * this function is taken from
- * linux/fs/ext2/bitmap.c
- */
-
-static int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0};
-
-unsigned long ext2_count_free (struct buffer_head * map, unsigned int numchars)
-{
- unsigned int i;
- unsigned long sum = 0;
-
- if (!map)
- return (0);
- for (i = 0; i < numchars; i++)
- sum += nibblemap[map->b_data[i] & 0xf] +
- nibblemap[(map->b_data[i] >> 4) & 0xf];
- return (sum);
-}
diff --git a/sys/gnu/fs/ext2fs/ext2_linux_ialloc.c b/sys/gnu/fs/ext2fs/ext2_linux_ialloc.c
deleted file mode 100644
index fc783914feff..000000000000
--- a/sys/gnu/fs/ext2fs/ext2_linux_ialloc.c
+++ /dev/null
@@ -1,511 +0,0 @@
-/*
- * modified for Lites 1.1
- *
- * Aug 1995, Godmar Back (gback@cs.utah.edu)
- * University of Utah, Department of Computer Science
- */
-/*
- * linux/fs/ext2/ialloc.c
- *
- * Copyright (C) 1992, 1993, 1994, 1995
- * Remy Card (card@masi.ibp.fr)
- * Laboratoire MASI - Institut Blaise Pascal
- * Universite Pierre et Marie Curie (Paris VI)
- *
- * BSD ufs-inspired inode and directory allocation by
- * Stephen Tweedie (sct@dcs.ed.ac.uk), 1993
- */
-
-/*
- * The free inodes are managed by bitmaps. A file system contains several
- * blocks groups. Each group contains 1 bitmap block for blocks, 1 bitmap
- * block for inodes, N blocks for the inode table and data blocks.
- *
- * The file system contains group descriptors which are located after the
- * super block. Each descriptor contains the number of the bitmap block and
- * the free blocks count in the block. The descriptors are loaded in memory
- * when a file system is mounted (see ext2_read_super).
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/buf.h>
-#include <sys/proc.h>
-#include <sys/mount.h>
-#include <sys/vnode.h>
-
-#include <ufs/ufs/quota.h>
-#include <ufs/ufs/inode.h>
-#include <ufs/ufs/ufsmount.h>
-#include <gnu/ext2fs/ext2_extern.h>
-#include <gnu/ext2fs/ext2_fs.h>
-#include <gnu/ext2fs/ext2_fs_sb.h>
-#include <gnu/ext2fs/fs.h>
-#include <sys/stat.h>
-
-#ifdef __i386__
-#include <gnu/ext2fs/i386-bitops.h>
-#else
-#error please provide bit operation functions
-#endif
-
-/* this is supposed to mark a buffer dirty on ready for delayed writing
- */
-void mark_buffer_dirty(struct buf *bh)
-{
- int s;
-
- s = splbio();
- bh->b_flags |= B_DIRTY;
- splx(s);
-}
-
-struct ext2_group_desc * get_group_desc (struct mount * mp,
- unsigned int block_group,
- struct buffer_head ** bh)
-{
- struct ext2_sb_info *sb = VFSTOUFS(mp)->um_e2fs;
- unsigned long group_desc;
- unsigned long desc;
- struct ext2_group_desc * gdp;
-
- if (block_group >= sb->s_groups_count)
- panic ("get_group_desc: "
- "block_group >= groups_count - "
- "block_group = %d, groups_count = %lu",
- block_group, sb->s_groups_count);
-
- group_desc = block_group / EXT2_DESC_PER_BLOCK(sb);
- desc = block_group % EXT2_DESC_PER_BLOCK(sb);
- if (!sb->s_group_desc[group_desc])
- panic ( "get_group_desc:"
- "Group descriptor not loaded - "
- "block_group = %d, group_desc = %lu, desc = %lu",
- block_group, group_desc, desc);
- gdp = (struct ext2_group_desc *)
- sb->s_group_desc[group_desc]->b_data;
- if (bh)
- *bh = sb->s_group_desc[group_desc];
- return gdp + desc;
-}
-
-static void read_inode_bitmap (struct mount * mp,
- unsigned long block_group,
- unsigned int bitmap_nr)
-{
- struct ext2_sb_info *sb = VFSTOUFS(mp)->um_e2fs;
- struct ext2_group_desc * gdp;
- struct buffer_head * bh;
- int error;
-
- gdp = get_group_desc (mp, block_group, NULL);
- if ((error = bread (VFSTOUFS(mp)->um_devvp,
- fsbtodb(sb, gdp->bg_inode_bitmap),
- sb->s_blocksize,
- NOCRED, &bh)) != 0)
- panic ( "read_inode_bitmap:"
- "Cannot read inode bitmap - "
- "block_group = %lu, inode_bitmap = %lu",
- block_group, (unsigned long) gdp->bg_inode_bitmap);
- sb->s_inode_bitmap_number[bitmap_nr] = block_group;
- sb->s_inode_bitmap[bitmap_nr] = bh;
- LCK_BUF(bh)
-}
-
-/*
- * load_inode_bitmap loads the inode bitmap for a blocks group
- *
- * It maintains a cache for the last bitmaps loaded. This cache is managed
- * with a LRU algorithm.
- *
- * Notes:
- * 1/ There is one cache per mounted file system.
- * 2/ If the file system contains less than EXT2_MAX_GROUP_LOADED groups,
- * this function reads the bitmap without maintaining a LRU cache.
- */
-static int load_inode_bitmap (struct mount * mp,
- unsigned int block_group)
-{
- struct ext2_sb_info *sb = VFSTOUFS(mp)->um_e2fs;
- int i, j;
- unsigned long inode_bitmap_number;
- struct buffer_head * inode_bitmap;
-
- if (block_group >= sb->s_groups_count)
- panic ("load_inode_bitmap:"
- "block_group >= groups_count - "
- "block_group = %d, groups_count = %lu",
- block_group, sb->s_groups_count);
- if (sb->s_loaded_inode_bitmaps > 0 &&
- sb->s_inode_bitmap_number[0] == block_group)
- return 0;
- if (sb->s_groups_count <= EXT2_MAX_GROUP_LOADED) {
- if (sb->s_inode_bitmap[block_group]) {
- if (sb->s_inode_bitmap_number[block_group] !=
- block_group)
- panic ( "load_inode_bitmap:"
- "block_group != inode_bitmap_number");
- else
- return block_group;
- } else {
- read_inode_bitmap (mp, block_group, block_group);
- return block_group;
- }
- }
-
- for (i = 0; i < sb->s_loaded_inode_bitmaps &&
- sb->s_inode_bitmap_number[i] != block_group;
- i++)
- ;
- if (i < sb->s_loaded_inode_bitmaps &&
- sb->s_inode_bitmap_number[i] == block_group) {
- inode_bitmap_number = sb->s_inode_bitmap_number[i];
- inode_bitmap = sb->s_inode_bitmap[i];
- for (j = i; j > 0; j--) {
- sb->s_inode_bitmap_number[j] =
- sb->s_inode_bitmap_number[j - 1];
- sb->s_inode_bitmap[j] =
- sb->s_inode_bitmap[j - 1];
- }
- sb->s_inode_bitmap_number[0] = inode_bitmap_number;
- sb->s_inode_bitmap[0] = inode_bitmap;
- } else {
- if (sb->s_loaded_inode_bitmaps < EXT2_MAX_GROUP_LOADED)
- sb->s_loaded_inode_bitmaps++;
- else
- ULCK_BUF(sb->s_inode_bitmap[EXT2_MAX_GROUP_LOADED - 1])
- for (j = sb->s_loaded_inode_bitmaps - 1; j > 0; j--) {
- sb->s_inode_bitmap_number[j] =
- sb->s_inode_bitmap_number[j - 1];
- sb->s_inode_bitmap[j] =
- sb->s_inode_bitmap[j - 1];
- }
- read_inode_bitmap (mp, block_group, 0);
- }
- return 0;
-}
-
-
-void ext2_free_inode (struct inode * inode)
-{
- struct ext2_sb_info * sb;
- struct buffer_head * bh;
- struct buffer_head * bh2;
- unsigned long block_group;
- unsigned long bit;
- int bitmap_nr;
- struct ext2_group_desc * gdp;
- struct ext2_super_block * es;
-
- if (!inode)
- return;
-
- if (inode->i_nlink) {
- printf ("ext2_free_inode: inode has nlink=%d\n",
- inode->i_nlink);
- return;
- }
-
- ext2_debug ("freeing inode %lu\n", inode->i_number);
-
- sb = inode->i_e2fs;
- lock_super (DEVVP(inode));
- if (inode->i_number < EXT2_FIRST_INO ||
- inode->i_number > sb->s_es->s_inodes_count) {
- printf ("free_inode reserved inode or nonexistent inode");
- unlock_super (DEVVP(inode));
- return;
- }
- es = sb->s_es;
- block_group = (inode->i_number - 1) / EXT2_INODES_PER_GROUP(sb);
- bit = (inode->i_number - 1) % EXT2_INODES_PER_GROUP(sb);
- bitmap_nr = load_inode_bitmap (ITOV(inode)->v_mount, block_group);
- bh = sb->s_inode_bitmap[bitmap_nr];
- if (!clear_bit (bit, bh->b_data))
- printf ( "ext2_free_inode:"
- "bit already cleared for inode %lu",
- (unsigned long)inode->i_number);
- else {
- gdp = get_group_desc (ITOV(inode)->v_mount, block_group, &bh2);
- gdp->bg_free_inodes_count++;
- if (S_ISDIR(inode->i_mode))
- gdp->bg_used_dirs_count--;
- mark_buffer_dirty(bh2);
- es->s_free_inodes_count++;
- }
- mark_buffer_dirty(bh);
-/*** XXX
- if (sb->s_flags & MS_SYNCHRONOUS) {
- ll_rw_block (WRITE, 1, &bh);
- wait_on_buffer (bh);
- }
-***/
- sb->s_dirt = 1;
- unlock_super (DEVVP(inode));
-}
-
-#if linux
-/*
- * This function increments the inode version number
- *
- * This may be used one day by the NFS server
- */
-static void inc_inode_version (struct inode * inode,
- struct ext2_group_desc *gdp,
- int mode)
-{
- unsigned long inode_block;
- struct buffer_head * bh;
- struct ext2_inode * raw_inode;
-
- inode_block = gdp->bg_inode_table + (((inode->i_number - 1) %
- EXT2_INODES_PER_GROUP(inode->i_sb)) /
- EXT2_INODES_PER_BLOCK(inode->i_sb));
- bh = bread (inode->i_sb->s_dev, inode_block, inode->i_sb->s_blocksize);
- if (!bh) {
- printf ("inc_inode_version Cannot load inode table block - "
- "inode=%lu, inode_block=%lu\n",
- inode->i_number, inode_block);
- inode->u.ext2_i.i_version = 1;
- return;
- }
- raw_inode = ((struct ext2_inode *) bh->b_data) +
- (((inode->i_number - 1) %
- EXT2_INODES_PER_GROUP(inode->i_sb)) %
- EXT2_INODES_PER_BLOCK(inode->i_sb));
- raw_inode->i_version++;
- inode->u.ext2_i.i_version = raw_inode->i_version;
- bdwrite (bh);
-}
-
-#endif /* linux */
-
-/*
- * There are two policies for allocating an inode. If the new inode is
- * a directory, then a forward search is made for a block group with both
- * free space and a low directory-to-inode ratio; if that fails, then of
- * the groups with above-average free space, that group with the fewest
- * directories already is chosen.
- *
- * For other inodes, search forward from the parent directory\'s block
- * group to find a free inode.
- */
-/*
- * this functino has been reduced to the actual 'find the inode number' part
- */
-ino_t ext2_new_inode (const struct inode * dir, int mode)
-{
- struct ext2_sb_info * sb;
- struct buffer_head * bh;
- struct buffer_head * bh2;
- int i, j, avefreei;
- int bitmap_nr;
- struct ext2_group_desc * gdp;
- struct ext2_group_desc * tmp;
- struct ext2_super_block * es;
-
- if (!dir)
- return 0;
- sb = dir->i_e2fs;
-
- lock_super (DEVVP(dir));
- es = sb->s_es;
-repeat:
- gdp = NULL; i=0;
-
- if (S_ISDIR(mode)) {
- avefreei = es->s_free_inodes_count /
- sb->s_groups_count;
-/* I am not yet convinced that this next bit is necessary.
- i = dir->u.ext2_i.i_block_group;
- for (j = 0; j < sb->u.ext2_sb.s_groups_count; j++) {
- tmp = get_group_desc (sb, i, &bh2);
- if ((tmp->bg_used_dirs_count << 8) <
- tmp->bg_free_inodes_count) {
- gdp = tmp;
- break;
- }
- else
- i = ++i % sb->u.ext2_sb.s_groups_count;
- }
-*/
- if (!gdp) {
- for (j = 0; j < sb->s_groups_count; j++) {
- tmp = get_group_desc(ITOV(dir)->v_mount,j,&bh2);
- if (tmp->bg_free_inodes_count &&
- tmp->bg_free_inodes_count >= avefreei) {
- if (!gdp ||
- (tmp->bg_free_blocks_count >
- gdp->bg_free_blocks_count)) {
- i = j;
- gdp = tmp;
- }
- }
- }
- }
- }
- else
- {
- /*
- * Try to place the inode in its parent directory
- */
- i = dir->i_block_group;
- tmp = get_group_desc (ITOV(dir)->v_mount, i, &bh2);
- if (tmp->bg_free_inodes_count)
- gdp = tmp;
- else
- {
- /*
- * Use a quadratic hash to find a group with a
- * free inode
- */
- for (j = 1; j < sb->s_groups_count; j <<= 1) {
- i += j;
- if (i >= sb->s_groups_count)
- i -= sb->s_groups_count;
- tmp = get_group_desc(ITOV(dir)->v_mount,i,&bh2);
- if (tmp->bg_free_inodes_count) {
- gdp = tmp;
- break;
- }
- }
- }
- if (!gdp) {
- /*
- * That failed: try linear search for a free inode
- */
- i = dir->i_block_group + 1;
- for (j = 2; j < sb->s_groups_count; j++) {
- if (++i >= sb->s_groups_count)
- i = 0;
- tmp = get_group_desc(ITOV(dir)->v_mount,i,&bh2);
- if (tmp->bg_free_inodes_count) {
- gdp = tmp;
- break;
- }
- }
- }
- }
-
- if (!gdp) {
- unlock_super (DEVVP(dir));
- return 0;
- }
- bitmap_nr = load_inode_bitmap (ITOV(dir)->v_mount, i);
- bh = sb->s_inode_bitmap[bitmap_nr];
- if ((j = find_first_zero_bit ((unsigned long *) bh->b_data,
- EXT2_INODES_PER_GROUP(sb))) <
- EXT2_INODES_PER_GROUP(sb)) {
- if (set_bit (j, bh->b_data)) {
- printf ( "ext2_new_inode:"
- "bit already set for inode %d", j);
- goto repeat;
- }
-/* Linux now does the following:
- mark_buffer_dirty(bh);
- if (sb->s_flags & MS_SYNCHRONOUS) {
- ll_rw_block (WRITE, 1, &bh);
- wait_on_buffer (bh);
- }
-*/
- mark_buffer_dirty(bh);
- } else {
- if (gdp->bg_free_inodes_count != 0) {
- printf ( "ext2_new_inode:"
- "Free inodes count corrupted in group %d",
- i);
- unlock_super (DEVVP(dir));
- return 0;
- }
- goto repeat;
- }
- j += i * EXT2_INODES_PER_GROUP(sb) + 1;
- if (j < EXT2_FIRST_INO || j > es->s_inodes_count) {
- printf ( "ext2_new_inode:"
- "reserved inode or inode > inodes count - "
- "block_group = %d,inode=%d", i, j);
- unlock_super (DEVVP(dir));
- return 0;
- }
- gdp->bg_free_inodes_count--;
- if (S_ISDIR(mode))
- gdp->bg_used_dirs_count++;
- mark_buffer_dirty(bh2);
- es->s_free_inodes_count--;
- /* mark_buffer_dirty(sb->u.ext2_sb.s_sbh, 1); */
- sb->s_dirt = 1;
- unlock_super (DEVVP(dir));
- return j;
-}
-
-#ifdef unused
-static unsigned long ext2_count_free_inodes (struct mount * mp)
-{
-#ifdef EXT2FS_DEBUG
- struct ext2_sb_info *sb = VFSTOUFS(mp)->um_e2fs;
- struct ext2_super_block * es;
- unsigned long desc_count, bitmap_count, x;
- int bitmap_nr;
- struct ext2_group_desc * gdp;
- int i;
-
- lock_super (VFSTOUFS(mp)->um_devvp);
- es = sb->s_es;
- desc_count = 0;
- bitmap_count = 0;
- gdp = NULL;
- for (i = 0; i < sb->s_groups_count; i++) {
- gdp = get_group_desc (mp, i, NULL);
- desc_count += gdp->bg_free_inodes_count;
- bitmap_nr = load_inode_bitmap (mp, i);
- x = ext2_count_free (sb->s_inode_bitmap[bitmap_nr],
- EXT2_INODES_PER_GROUP(sb) / 8);
- ext2_debug ("group %d: stored = %d, counted = %lu\n",
- i, gdp->bg_free_inodes_count, x);
- bitmap_count += x;
- }
- ext2_debug("stored = %lu, computed = %lu, %lu\n",
- es->s_free_inodes_count, desc_count, bitmap_count);
- unlock_super (VFSTOUFS(mp)->um_devvp);
- return desc_count;
-#else
- return VFSTOUFS(mp)->um_e2fsb->s_free_inodes_count;
-#endif
-}
-#endif /* unused */
-
-#ifdef LATER
-void ext2_check_inodes_bitmap (struct mount * mp)
-{
- struct ext2_super_block * es;
- unsigned long desc_count, bitmap_count, x;
- int bitmap_nr;
- struct ext2_group_desc * gdp;
- int i;
-
- lock_super (sb);
- es = sb->u.ext2_sb.s_es;
- desc_count = 0;
- bitmap_count = 0;
- gdp = NULL;
- for (i = 0; i < sb->u.ext2_sb.s_groups_count; i++) {
- gdp = get_group_desc (sb, i, NULL);
- desc_count += gdp->bg_free_inodes_count;
- bitmap_nr = load_inode_bitmap (sb, i);
- x = ext2_count_free (sb->u.ext2_sb.s_inode_bitmap[bitmap_nr],
- EXT2_INODES_PER_GROUP(sb) / 8);
- if (gdp->bg_free_inodes_count != x)
- printf ( "ext2_check_inodes_bitmap:"
- "Wrong free inodes count in group %d, "
- "stored = %d, counted = %lu", i,
- gdp->bg_free_inodes_count, x);
- bitmap_count += x;
- }
- if (es->s_free_inodes_count != bitmap_count)
- printf ( "ext2_check_inodes_bitmap:"
- "Wrong free inodes count in super block, "
- "stored = %lu, counted = %lu",
- (unsigned long) es->s_free_inodes_count, bitmap_count);
- unlock_super (sb);
-}
-#endif
diff --git a/sys/gnu/fs/ext2fs/ext2_lookup.c b/sys/gnu/fs/ext2fs/ext2_lookup.c
deleted file mode 100644
index 985dcf395fce..000000000000
--- a/sys/gnu/fs/ext2fs/ext2_lookup.c
+++ /dev/null
@@ -1,1069 +0,0 @@
-/*
- * modified for Lites 1.1
- *
- * Aug 1995, Godmar Back (gback@cs.utah.edu)
- * University of Utah, Department of Computer Science
- *
- * $FreeBSD$
- */
-/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)ufs_lookup.c 8.6 (Berkeley) 4/1/94
- */
-
-#include <stddef.h>
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/namei.h>
-#include <sys/buf.h>
-#include <sys/mount.h>
-#include <sys/vnode.h>
-#include <sys/malloc.h>
-#include <sys/dirent.h>
-
-#include <ufs/ufs/quota.h>
-#include <ufs/ufs/inode.h>
-#include <ufs/ufs/dir.h>
-#include <ufs/ufs/ufsmount.h>
-#include <ufs/ufs/ufs_extern.h>
-
-#include <gnu/ext2fs/ext2_extern.h>
-#include <gnu/ext2fs/ext2_fs.h>
-#include <gnu/ext2fs/ext2_fs_sb.h>
-
-/*
- DIRBLKSIZE in ffs is DEV_BSIZE (in most cases 512)
- while it is the native blocksize in ext2fs - thus, a #define
- is no longer appropriate
-*/
-#undef DIRBLKSIZ
-
-extern int dirchk;
-
-static u_char ext2_ft_to_dt[] = {
- DT_UNKNOWN, /* EXT2_FT_UNKNOWN */
- DT_REG, /* EXT2_FT_REG_FILE */
- DT_DIR, /* EXT2_FT_DIR */
- DT_CHR, /* EXT2_FT_CHRDEV */
- DT_BLK, /* EXT2_FT_BLKDEV */
- DT_FIFO, /* EXT2_FT_FIFO */
- DT_SOCK, /* EXT2_FT_SOCK */
- DT_LNK, /* EXT2_FT_SYMLINK */
-};
-#define FTTODT(ft) \
- ((ft) > sizeof(ext2_ft_to_dt) / sizeof(ext2_ft_to_dt[0]) ? \
- DT_UNKNOWN : ext2_ft_to_dt[(ft)])
-
-static u_char dt_to_ext2_ft[] = {
- EXT2_FT_UNKNOWN, /* DT_UNKNOWN */
- EXT2_FT_FIFO, /* DT_FIFO */
- EXT2_FT_CHRDEV, /* DT_CHR */
- EXT2_FT_UNKNOWN, /* unused */
- EXT2_FT_DIR, /* DT_DIR */
- EXT2_FT_UNKNOWN, /* unused */
- EXT2_FT_BLKDEV, /* DT_BLK */
- EXT2_FT_UNKNOWN, /* unused */
- EXT2_FT_REG_FILE, /* DT_REG */
- EXT2_FT_UNKNOWN, /* unused */
- EXT2_FT_SYMLINK, /* DT_LNK */
- EXT2_FT_UNKNOWN, /* unused */
- EXT2_FT_SOCK, /* DT_SOCK */
- EXT2_FT_UNKNOWN, /* unused */
- EXT2_FT_UNKNOWN, /* DT_WHT */
-};
-#define DTTOFT(dt) \
- ((dt) > sizeof(dt_to_ext2_ft) / sizeof(dt_to_ext2_ft[0]) ? \
- EXT2_FT_UNKNOWN : dt_to_ext2_ft[(dt)])
-
-static int ext2_dirbadentry __P((struct vnode *dp,
- struct ext2_dir_entry_2 *de,
- int entryoffsetinblock));
-
-/*
- * Vnode op for reading directories.
- *
- * The routine below assumes that the on-disk format of a directory
- * is the same as that defined by <sys/dirent.h>. If the on-disk
- * format changes, then it will be necessary to do a conversion
- * from the on-disk format that read returns to the format defined
- * by <sys/dirent.h>.
- */
-/*
- * this is exactly what we do here - the problem is that the conversion
- * will blow up some entries by four bytes, so it can't be done in place.
- * This is too bad. Right now the conversion is done entry by entry, the
- * converted entry is sent via uiomove.
- *
- * XXX allocate a buffer, convert as many entries as possible, then send
- * the whole buffer to uiomove
- */
-int
-ext2_readdir(ap)
- struct vop_readdir_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- struct ucred *a_cred;
- } */ *ap;
-{
- register struct uio *uio = ap->a_uio;
- int count, error;
-
- struct ext2_dir_entry_2 *edp, *dp;
- int ncookies;
- struct dirent dstdp;
- struct uio auio;
- struct iovec aiov;
- caddr_t dirbuf;
- int readcnt;
- u_quad_t startoffset = uio->uio_offset;
-
- count = uio->uio_resid; /* legyenek boldogok akik akarnak ... */
- uio->uio_resid = count;
- uio->uio_iov->iov_len = count;
-
-#if 0
-printf("ext2_readdir called uio->uio_offset %d uio->uio_resid %d count %d \n",
- (int)uio->uio_offset, (int)uio->uio_resid, (int)count);
-#endif
-
- auio = *uio;
- auio.uio_iov = &aiov;
- auio.uio_iovcnt = 1;
- auio.uio_segflg = UIO_SYSSPACE;
- aiov.iov_len = count;
- MALLOC(dirbuf, caddr_t, count, M_TEMP, M_WAITOK);
- aiov.iov_base = dirbuf;
- error = VOP_READ(ap->a_vp, &auio, 0, ap->a_cred);
- if (error == 0) {
- readcnt = count - auio.uio_resid;
- edp = (struct ext2_dir_entry_2 *)&dirbuf[readcnt];
- ncookies = 0;
- bzero(&dstdp, offsetof(struct dirent, d_name));
- for (dp = (struct ext2_dir_entry_2 *)dirbuf;
- !error && uio->uio_resid > 0 && dp < edp; ) {
- /*-
- * "New" ext2fs directory entries differ in 3 ways
- * from ufs on-disk ones:
- * - the name is not necessarily NUL-terminated.
- * - the file type field always exists and always
- * follows the name length field.
- * - the file type is encoded in a different way.
- *
- * "Old" ext2fs directory entries need no special
- * conversions, since they binary compatible with
- * "new" entries having a file type of 0 (i.e.,
- * EXT2_FT_UNKNOWN). Splitting the old name length
- * field didn't make a mess like it did in ufs,
- * because ext2fs uses a machine-dependent disk
- * layout.
- */
- dstdp.d_fileno = dp->inode;
- dstdp.d_type = FTTODT(dp->file_type);
- dstdp.d_namlen = dp->name_len;
- dstdp.d_reclen = GENERIC_DIRSIZ(&dstdp);
- bcopy(dp->name, dstdp.d_name, dstdp.d_namlen);
- bzero(dstdp.d_name + dstdp.d_namlen,
- dstdp.d_reclen - offsetof(struct dirent, d_name) -
- dstdp.d_namlen);
-
- if (dp->rec_len > 0) {
- if(dstdp.d_reclen <= uio->uio_resid) {
- /* advance dp */
- dp = (struct ext2_dir_entry_2 *)
- ((char *)dp + dp->rec_len);
- error =
- uiomove((caddr_t)&dstdp,
- dstdp.d_reclen, uio);
- if (!error)
- ncookies++;
- } else
- break;
- } else {
- error = EIO;
- break;
- }
- }
- /* we need to correct uio_offset */
- uio->uio_offset = startoffset + (caddr_t)dp - dirbuf;
-
- if (!error && ap->a_ncookies != NULL) {
- u_long *cookies;
- u_long *cookiep;
- off_t off;
-
- if (uio->uio_segflg != UIO_SYSSPACE || uio->uio_iovcnt != 1)
- panic("ext2fs_readdir: unexpected uio from NFS server");
- MALLOC(cookies, u_long *, ncookies * sizeof(u_long), M_TEMP,
- M_WAITOK);
- off = startoffset;
- for (dp = (struct ext2_dir_entry_2 *)dirbuf, cookiep = cookies;
- dp < edp;
- dp = (struct ext2_dir_entry_2 *)((caddr_t) dp + dp->rec_len)) {
- off += dp->rec_len;
- *cookiep++ = (u_long) off;
- }
- *ap->a_ncookies = ncookies;
- *ap->a_cookies = cookies;
- }
- }
- FREE(dirbuf, M_TEMP);
- if (ap->a_eofflag)
- *ap->a_eofflag = VTOI(ap->a_vp)->i_size <= uio->uio_offset;
- return (error);
-}
-
-/*
- * Convert a component of a pathname into a pointer to a locked inode.
- * This is a very central and rather complicated routine.
- * If the file system is not maintained in a strict tree hierarchy,
- * this can result in a deadlock situation (see comments in code below).
- *
- * The cnp->cn_nameiop argument is LOOKUP, CREATE, RENAME, or DELETE depending
- * on whether the name is to be looked up, created, renamed, or deleted.
- * When CREATE, RENAME, or DELETE is specified, information usable in
- * creating, renaming, or deleting a directory entry may be calculated.
- * If flag has LOCKPARENT or'ed into it and the target of the pathname
- * exists, lookup returns both the target and its parent directory locked.
- * When creating or renaming and LOCKPARENT is specified, the target may
- * not be ".". When deleting and LOCKPARENT is specified, the target may
- * be "."., but the caller must check to ensure it does an vrele and vput
- * instead of two vputs.
- *
- * Overall outline of ufs_lookup:
- *
- * search for name in directory, to found or notfound
- * notfound:
- * if creating, return locked directory, leaving info on available slots
- * else return error
- * found:
- * if at end of path and deleting, return information to allow delete
- * if at end of path and rewriting (RENAME and LOCKPARENT), lock target
- * inode and return info to allow rewrite
- * if not at end, add name to cache; if at end and neither creating
- * nor deleting, add name to cache
- */
-int
-ext2_lookup(ap)
- struct vop_cachedlookup_args /* {
- struct vnode *a_dvp;
- struct vnode **a_vpp;
- struct componentname *a_cnp;
- } */ *ap;
-{
- register struct vnode *vdp; /* vnode for directory being searched */
- register struct inode *dp; /* inode for directory being searched */
- struct buf *bp; /* a buffer of directory entries */
- register struct ext2_dir_entry_2 *ep; /* the current directory entry */
- int entryoffsetinblock; /* offset of ep in bp's buffer */
- enum {NONE, COMPACT, FOUND} slotstatus;
- doff_t slotoffset; /* offset of area with free space */
- int slotsize; /* size of area at slotoffset */
- int slotfreespace; /* amount of space free in slot */
- int slotneeded; /* size of the entry we're seeking */
- int numdirpasses; /* strategy for directory search */
- doff_t endsearch; /* offset to end directory search */
- doff_t prevoff; /* prev entry dp->i_offset */
- struct vnode *pdp; /* saved dp during symlink work */
- struct vnode *tdp; /* returned by VFS_VGET */
- doff_t enduseful; /* pointer past last used dir slot */
- u_long bmask; /* block offset mask */
- int lockparent; /* 1 => lockparent flag is set */
- int wantparent; /* 1 => wantparent or lockparent flag */
- int namlen, error;
- struct vnode **vpp = ap->a_vpp;
- struct componentname *cnp = ap->a_cnp;
- struct ucred *cred = cnp->cn_cred;
- int flags = cnp->cn_flags;
- int nameiop = cnp->cn_nameiop;
- struct proc *p = cnp->cn_proc;
-
- int DIRBLKSIZ = VTOI(ap->a_dvp)->i_e2fs->s_blocksize;
-
- bp = NULL;
- slotoffset = -1;
- *vpp = NULL;
- vdp = ap->a_dvp;
- dp = VTOI(vdp);
- lockparent = flags & LOCKPARENT;
- wantparent = flags & (LOCKPARENT|WANTPARENT);
-
- /*
- * We now have a segment name to search for, and a directory to search.
- */
-
- /*
- * Suppress search for slots unless creating
- * file and at end of pathname, in which case
- * we watch for a place to put the new file in
- * case it doesn't already exist.
- */
- slotstatus = FOUND;
- slotfreespace = slotsize = slotneeded = 0;
- if ((nameiop == CREATE || nameiop == RENAME) &&
- (flags & ISLASTCN)) {
- slotstatus = NONE;
- slotneeded = EXT2_DIR_REC_LEN(cnp->cn_namelen);
- /* was
- slotneeded = (sizeof(struct direct) - MAXNAMLEN +
- cnp->cn_namelen + 3) &~ 3; */
- }
-
- /*
- * If there is cached information on a previous search of
- * this directory, pick up where we last left off.
- * We cache only lookups as these are the most common
- * and have the greatest payoff. Caching CREATE has little
- * benefit as it usually must search the entire directory
- * to determine that the entry does not exist. Caching the
- * location of the last DELETE or RENAME has not reduced
- * profiling time and hence has been removed in the interest
- * of simplicity.
- */
- bmask = VFSTOUFS(vdp->v_mount)->um_mountp->mnt_stat.f_iosize - 1;
- if (nameiop != LOOKUP || dp->i_diroff == 0 ||
- dp->i_diroff > dp->i_size) {
- entryoffsetinblock = 0;
- dp->i_offset = 0;
- numdirpasses = 1;
- } else {
- dp->i_offset = dp->i_diroff;
- if ((entryoffsetinblock = dp->i_offset & bmask) &&
- (error = UFS_BLKATOFF(vdp, (off_t)dp->i_offset, NULL, &bp)))
- return (error);
- numdirpasses = 2;
- nchstats.ncs_2passes++;
- }
- prevoff = dp->i_offset;
- endsearch = roundup(dp->i_size, DIRBLKSIZ);
- enduseful = 0;
-
-searchloop:
- while (dp->i_offset < endsearch) {
- /*
- * If necessary, get the next directory block.
- */
- if ((dp->i_offset & bmask) == 0) {
- if (bp != NULL)
- brelse(bp);
- if ((error =
- UFS_BLKATOFF(vdp, (off_t)dp->i_offset, NULL, &bp)) != 0)
- return (error);
- entryoffsetinblock = 0;
- }
- /*
- * If still looking for a slot, and at a DIRBLKSIZE
- * boundary, have to start looking for free space again.
- */
- if (slotstatus == NONE &&
- (entryoffsetinblock & (DIRBLKSIZ - 1)) == 0) {
- slotoffset = -1;
- slotfreespace = 0;
- }
- /*
- * Get pointer to next entry.
- * Full validation checks are slow, so we only check
- * enough to insure forward progress through the
- * directory. Complete checks can be run by patching
- * "dirchk" to be true.
- */
- ep = (struct ext2_dir_entry_2 *)
- ((char *)bp->b_data + entryoffsetinblock);
- if (ep->rec_len == 0 ||
- (dirchk && ext2_dirbadentry(vdp, ep, entryoffsetinblock))) {
- int i;
- ufs_dirbad(dp, dp->i_offset, "mangled entry");
- i = DIRBLKSIZ - (entryoffsetinblock & (DIRBLKSIZ - 1));
- dp->i_offset += i;
- entryoffsetinblock += i;
- continue;
- }
-
- /*
- * If an appropriate sized slot has not yet been found,
- * check to see if one is available. Also accumulate space
- * in the current block so that we can determine if
- * compaction is viable.
- */
- if (slotstatus != FOUND) {
- int size = ep->rec_len;
-
- if (ep->inode != 0)
- size -= EXT2_DIR_REC_LEN(ep->name_len);
- if (size > 0) {
- if (size >= slotneeded) {
- slotstatus = FOUND;
- slotoffset = dp->i_offset;
- slotsize = ep->rec_len;
- } else if (slotstatus == NONE) {
- slotfreespace += size;
- if (slotoffset == -1)
- slotoffset = dp->i_offset;
- if (slotfreespace >= slotneeded) {
- slotstatus = COMPACT;
- slotsize = dp->i_offset +
- ep->rec_len - slotoffset;
- }
- }
- }
- }
-
- /*
- * Check for a name match.
- */
- if (ep->inode) {
- namlen = ep->name_len;
- if (namlen == cnp->cn_namelen &&
- !bcmp(cnp->cn_nameptr, ep->name,
- (unsigned)namlen)) {
- /*
- * Save directory entry's inode number and
- * reclen in ndp->ni_ufs area, and release
- * directory buffer.
- */
- dp->i_ino = ep->inode;
- dp->i_reclen = ep->rec_len;
- brelse(bp);
- goto found;
- }
- }
- prevoff = dp->i_offset;
- dp->i_offset += ep->rec_len;
- entryoffsetinblock += ep->rec_len;
- if (ep->inode)
- enduseful = dp->i_offset;
- }
-/* notfound: */
- /*
- * If we started in the middle of the directory and failed
- * to find our target, we must check the beginning as well.
- */
- if (numdirpasses == 2) {
- numdirpasses--;
- dp->i_offset = 0;
- endsearch = dp->i_diroff;
- goto searchloop;
- }
- if (bp != NULL)
- brelse(bp);
- /*
- * If creating, and at end of pathname and current
- * directory has not been removed, then can consider
- * allowing file to be created.
- */
- if ((nameiop == CREATE || nameiop == RENAME) &&
- (flags & ISLASTCN) && dp->i_nlink != 0) {
- /*
- * Access for write is interpreted as allowing
- * creation of files in the directory.
- */
- if ((error = VOP_ACCESS(vdp, VWRITE, cred, cnp->cn_proc)) != 0)
- return (error);
- /*
- * Return an indication of where the new directory
- * entry should be put. If we didn't find a slot,
- * then set dp->i_count to 0 indicating
- * that the new slot belongs at the end of the
- * directory. If we found a slot, then the new entry
- * can be put in the range from dp->i_offset to
- * dp->i_offset + dp->i_count.
- */
- if (slotstatus == NONE) {
- dp->i_offset = roundup(dp->i_size, DIRBLKSIZ);
- dp->i_count = 0;
- enduseful = dp->i_offset;
- } else {
- dp->i_offset = slotoffset;
- dp->i_count = slotsize;
- if (enduseful < slotoffset + slotsize)
- enduseful = slotoffset + slotsize;
- }
- dp->i_endoff = roundup(enduseful, DIRBLKSIZ);
- dp->i_flag |= IN_CHANGE | IN_UPDATE;
- /*
- * We return with the directory locked, so that
- * the parameters we set up above will still be
- * valid if we actually decide to do a direnter().
- * We return ni_vp == NULL to indicate that the entry
- * does not currently exist; we leave a pointer to
- * the (locked) directory inode in ndp->ni_dvp.
- * The pathname buffer is saved so that the name
- * can be obtained later.
- *
- * NB - if the directory is unlocked, then this
- * information cannot be used.
- */
- cnp->cn_flags |= SAVENAME;
- if (!lockparent)
- VOP_UNLOCK(vdp, 0, p);
- return (EJUSTRETURN);
- }
- /*
- * Insert name into cache (as non-existent) if appropriate.
- */
- if ((cnp->cn_flags & MAKEENTRY) && nameiop != CREATE)
- cache_enter(vdp, *vpp, cnp);
- return (ENOENT);
-
-found:
- if (numdirpasses == 2)
- nchstats.ncs_pass2++;
- /*
- * Check that directory length properly reflects presence
- * of this entry.
- */
- if (entryoffsetinblock + EXT2_DIR_REC_LEN(ep->name_len)
- > dp->i_size) {
- ufs_dirbad(dp, dp->i_offset, "i_size too small");
- dp->i_size = entryoffsetinblock+EXT2_DIR_REC_LEN(ep->name_len);
- dp->i_flag |= IN_CHANGE | IN_UPDATE;
- }
-
- /*
- * Found component in pathname.
- * If the final component of path name, save information
- * in the cache as to where the entry was found.
- */
- if ((flags & ISLASTCN) && nameiop == LOOKUP)
- dp->i_diroff = dp->i_offset &~ (DIRBLKSIZ - 1);
-
- /*
- * If deleting, and at end of pathname, return
- * parameters which can be used to remove file.
- * If the wantparent flag isn't set, we return only
- * the directory (in ndp->ni_dvp), otherwise we go
- * on and lock the inode, being careful with ".".
- */
- if (nameiop == DELETE && (flags & ISLASTCN)) {
- /*
- * Write access to directory required to delete files.
- */
- if ((error = VOP_ACCESS(vdp, VWRITE, cred, cnp->cn_proc)) != 0)
- return (error);
- /*
- * Return pointer to current entry in dp->i_offset,
- * and distance past previous entry (if there
- * is a previous entry in this block) in dp->i_count.
- * Save directory inode pointer in ndp->ni_dvp for dirremove().
- */
- if ((dp->i_offset & (DIRBLKSIZ - 1)) == 0)
- dp->i_count = 0;
- else
- dp->i_count = dp->i_offset - prevoff;
- if (dp->i_number == dp->i_ino) {
- VREF(vdp);
- *vpp = vdp;
- return (0);
- }
- if ((error = VFS_VGET(vdp->v_mount, dp->i_ino, &tdp)) != 0)
- return (error);
- /*
- * If directory is "sticky", then user must own
- * the directory, or the file in it, else she
- * may not delete it (unless she's root). This
- * implements append-only directories.
- */
- if ((dp->i_mode & ISVTX) &&
- cred->cr_uid != 0 &&
- cred->cr_uid != dp->i_uid &&
- VTOI(tdp)->i_uid != cred->cr_uid) {
- vput(tdp);
- return (EPERM);
- }
- *vpp = tdp;
- if (!lockparent)
- VOP_UNLOCK(vdp, 0, p);
- return (0);
- }
-
- /*
- * If rewriting (RENAME), return the inode and the
- * information required to rewrite the present directory
- * Must get inode of directory entry to verify it's a
- * regular file, or empty directory.
- */
- if (nameiop == RENAME && wantparent &&
- (flags & ISLASTCN)) {
- if ((error = VOP_ACCESS(vdp, VWRITE, cred, cnp->cn_proc)) != 0)
- return (error);
- /*
- * Careful about locking second inode.
- * This can only occur if the target is ".".
- */
- if (dp->i_number == dp->i_ino)
- return (EISDIR);
- if ((error = VFS_VGET(vdp->v_mount, dp->i_ino, &tdp)) != 0)
- return (error);
- *vpp = tdp;
- cnp->cn_flags |= SAVENAME;
- if (!lockparent)
- VOP_UNLOCK(vdp, 0, p);
- return (0);
- }
-
- /*
- * Step through the translation in the name. We do not `vput' the
- * directory because we may need it again if a symbolic link
- * is relative to the current directory. Instead we save it
- * unlocked as "pdp". We must get the target inode before unlocking
- * the directory to insure that the inode will not be removed
- * before we get it. We prevent deadlock by always fetching
- * inodes from the root, moving down the directory tree. Thus
- * when following backward pointers ".." we must unlock the
- * parent directory before getting the requested directory.
- * There is a potential race condition here if both the current
- * and parent directories are removed before the VFS_VGET for the
- * inode associated with ".." returns. We hope that this occurs
- * infrequently since we cannot avoid this race condition without
- * implementing a sophisticated deadlock detection algorithm.
- * Note also that this simple deadlock detection scheme will not
- * work if the file system has any hard links other than ".."
- * that point backwards in the directory structure.
- */
- pdp = vdp;
- if (flags & ISDOTDOT) {
- VOP_UNLOCK(pdp, 0, p); /* race to get the inode */
- if ((error = VFS_VGET(vdp->v_mount, dp->i_ino, &tdp)) != 0) {
- vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY, p);
- return (error);
- }
- if (lockparent && (flags & ISLASTCN) &&
- (error = vn_lock(pdp, LK_EXCLUSIVE, p))) {
- vput(tdp);
- return (error);
- }
- *vpp = tdp;
- } else if (dp->i_number == dp->i_ino) {
- VREF(vdp); /* we want ourself, ie "." */
- *vpp = vdp;
- } else {
- if ((error = VFS_VGET(vdp->v_mount, dp->i_ino, &tdp)) != 0)
- return (error);
- if (!lockparent || !(flags & ISLASTCN))
- VOP_UNLOCK(pdp, 0, p);
- *vpp = tdp;
- }
-
- /*
- * Insert name into cache if appropriate.
- */
- if (cnp->cn_flags & MAKEENTRY)
- cache_enter(vdp, *vpp, cnp);
- return (0);
-}
-
-/*
- * Do consistency checking on a directory entry:
- * record length must be multiple of 4
- * entry must fit in rest of its DIRBLKSIZ block
- * record must be large enough to contain entry
- * name is not longer than MAXNAMLEN
- * name must be as long as advertised, and null terminated
- */
-/*
- * changed so that it confirms to ext2_check_dir_entry
- */
-static int
-ext2_dirbadentry(dp, de, entryoffsetinblock)
- struct vnode *dp;
- register struct ext2_dir_entry_2 *de;
- int entryoffsetinblock;
-{
- int DIRBLKSIZ = VTOI(dp)->i_e2fs->s_blocksize;
-
- char * error_msg = NULL;
-
- if (de->rec_len < EXT2_DIR_REC_LEN(1))
- error_msg = "rec_len is smaller than minimal";
- else if (de->rec_len % 4 != 0)
- error_msg = "rec_len % 4 != 0";
- else if (de->rec_len < EXT2_DIR_REC_LEN(de->name_len))
- error_msg = "reclen is too small for name_len";
- else if (entryoffsetinblock + de->rec_len > DIRBLKSIZ)
- error_msg = "directory entry across blocks";
- /* else LATER
- if (de->inode > dir->i_sb->u.ext2_sb.s_es->s_inodes_count)
- error_msg = "inode out of bounds";
- */
-
- if (error_msg != NULL) {
- printf("bad directory entry: %s\n", error_msg);
- printf("offset=%d, inode=%lu, rec_len=%u, name_len=%u\n",
- entryoffsetinblock, (unsigned long)de->inode,
- de->rec_len, de->name_len);
- }
- return error_msg == NULL ? 0 : 1;
-}
-
-/*
- * Write a directory entry after a call to namei, using the parameters
- * that it left in nameidata. The argument ip is the inode which the new
- * directory entry will refer to. Dvp is a pointer to the directory to
- * be written, which was left locked by namei. Remaining parameters
- * (dp->i_offset, dp->i_count) indicate how the space for the new
- * entry is to be obtained.
- */
-int
-ext2_direnter(ip, dvp, cnp)
- struct inode *ip;
- struct vnode *dvp;
- register struct componentname *cnp;
-{
- register struct ext2_dir_entry_2 *ep, *nep;
- register struct inode *dp;
- struct buf *bp;
- struct ext2_dir_entry_2 newdir;
- struct iovec aiov;
- struct uio auio;
- u_int dsize;
- int error, loc, newentrysize, spacefree;
- char *dirbuf;
- int DIRBLKSIZ = ip->i_e2fs->s_blocksize;
-
-
-#if DIAGNOSTIC
- if ((cnp->cn_flags & SAVENAME) == 0)
- panic("direnter: missing name");
-#endif
- dp = VTOI(dvp);
- newdir.inode = ip->i_number;
- newdir.name_len = cnp->cn_namelen;
- if (EXT2_HAS_INCOMPAT_FEATURE(ip->i_e2fs->s_es,
- EXT2_FEATURE_INCOMPAT_FILETYPE))
- newdir.file_type = DTTOFT(IFTODT(ip->i_mode));
- else
- newdir.file_type = EXT2_FT_UNKNOWN;
- bcopy(cnp->cn_nameptr, newdir.name, (unsigned)cnp->cn_namelen + 1);
- newentrysize = EXT2_DIR_REC_LEN(newdir.name_len);
- if (dp->i_count == 0) {
- /*
- * If dp->i_count is 0, then namei could find no
- * space in the directory. Here, dp->i_offset will
- * be on a directory block boundary and we will write the
- * new entry into a fresh block.
- */
- if (dp->i_offset & (DIRBLKSIZ - 1))
- panic("ext2_direnter: newblk");
- auio.uio_offset = dp->i_offset;
- newdir.rec_len = DIRBLKSIZ;
- auio.uio_resid = newentrysize;
- aiov.iov_len = newentrysize;
- aiov.iov_base = (caddr_t)&newdir;
- auio.uio_iov = &aiov;
- auio.uio_iovcnt = 1;
- auio.uio_rw = UIO_WRITE;
- auio.uio_segflg = UIO_SYSSPACE;
- auio.uio_procp = (struct proc *)0;
- error = VOP_WRITE(dvp, &auio, IO_SYNC, cnp->cn_cred);
- if (DIRBLKSIZ >
- VFSTOUFS(dvp->v_mount)->um_mountp->mnt_stat.f_bsize)
- /* XXX should grow with balloc() */
- panic("ext2_direnter: frag size");
- else if (!error) {
- dp->i_size = roundup(dp->i_size, DIRBLKSIZ);
- dp->i_flag |= IN_CHANGE;
- }
- return (error);
- }
-
- /*
- * If dp->i_count is non-zero, then namei found space
- * for the new entry in the range dp->i_offset to
- * dp->i_offset + dp->i_count in the directory.
- * To use this space, we may have to compact the entries located
- * there, by copying them together towards the beginning of the
- * block, leaving the free space in one usable chunk at the end.
- */
-
- /*
- * Increase size of directory if entry eats into new space.
- * This should never push the size past a new multiple of
- * DIRBLKSIZE.
- *
- * N.B. - THIS IS AN ARTIFACT OF 4.2 AND SHOULD NEVER HAPPEN.
- */
- if (dp->i_offset + dp->i_count > dp->i_size)
- dp->i_size = dp->i_offset + dp->i_count;
- /*
- * Get the block containing the space for the new directory entry.
- */
- if ((error = UFS_BLKATOFF(dvp, (off_t)dp->i_offset, &dirbuf, &bp)) != 0)
- return (error);
- /*
- * Find space for the new entry. In the simple case, the entry at
- * offset base will have the space. If it does not, then namei
- * arranged that compacting the region dp->i_offset to
- * dp->i_offset + dp->i_count would yield the
- * space.
- */
- ep = (struct ext2_dir_entry_2 *)dirbuf;
- dsize = EXT2_DIR_REC_LEN(ep->name_len);
- spacefree = ep->rec_len - dsize;
- for (loc = ep->rec_len; loc < dp->i_count; ) {
- nep = (struct ext2_dir_entry_2 *)(dirbuf + loc);
- if (ep->inode) {
- /* trim the existing slot */
- ep->rec_len = dsize;
- ep = (struct ext2_dir_entry_2 *)((char *)ep + dsize);
- } else {
- /* overwrite; nothing there; header is ours */
- spacefree += dsize;
- }
- dsize = EXT2_DIR_REC_LEN(nep->name_len);
- spacefree += nep->rec_len - dsize;
- loc += nep->rec_len;
- bcopy((caddr_t)nep, (caddr_t)ep, dsize);
- }
- /*
- * Update the pointer fields in the previous entry (if any),
- * copy in the new entry, and write out the block.
- */
- if (ep->inode == 0) {
- if (spacefree + dsize < newentrysize)
- panic("ext2_direnter: compact1");
- newdir.rec_len = spacefree + dsize;
- } else {
- if (spacefree < newentrysize)
- panic("ext2_direnter: compact2");
- newdir.rec_len = spacefree;
- ep->rec_len = dsize;
- ep = (struct ext2_dir_entry_2 *)((char *)ep + dsize);
- }
- bcopy((caddr_t)&newdir, (caddr_t)ep, (u_int)newentrysize);
- error = VOP_BWRITE(bp->b_vp, bp);
- dp->i_flag |= IN_CHANGE | IN_UPDATE;
- if (!error && dp->i_endoff && dp->i_endoff < dp->i_size)
- error = UFS_TRUNCATE(dvp, (off_t)dp->i_endoff, IO_SYNC,
- cnp->cn_cred, cnp->cn_proc);
- return (error);
-}
-
-/*
- * Remove a directory entry after a call to namei, using
- * the parameters which it left in nameidata. The entry
- * dp->i_offset contains the offset into the directory of the
- * entry to be eliminated. The dp->i_count field contains the
- * size of the previous record in the directory. If this
- * is 0, the first entry is being deleted, so we need only
- * zero the inode number to mark the entry as free. If the
- * entry is not the first in the directory, we must reclaim
- * the space of the now empty record by adding the record size
- * to the size of the previous entry.
- */
-int
-ext2_dirremove(dvp, cnp)
- struct vnode *dvp;
- struct componentname *cnp;
-{
- register struct inode *dp;
- struct ext2_dir_entry_2 *ep;
- struct buf *bp;
- int error;
-
- dp = VTOI(dvp);
- if (dp->i_count == 0) {
- /*
- * First entry in block: set d_ino to zero.
- */
- if ((error =
- UFS_BLKATOFF(dvp, (off_t)dp->i_offset, (char **)&ep, &bp)) != 0)
- return (error);
- ep->inode = 0;
- error = VOP_BWRITE(bp->b_vp, bp);
- dp->i_flag |= IN_CHANGE | IN_UPDATE;
- return (error);
- }
- /*
- * Collapse new free space into previous entry.
- */
- if ((error = UFS_BLKATOFF(dvp, (off_t)(dp->i_offset - dp->i_count),
- (char **)&ep, &bp)) != 0)
- return (error);
- ep->rec_len += dp->i_reclen;
- error = VOP_BWRITE(bp->b_vp, bp);
- dp->i_flag |= IN_CHANGE | IN_UPDATE;
- return (error);
-}
-
-/*
- * Rewrite an existing directory entry to point at the inode
- * supplied. The parameters describing the directory entry are
- * set up by a call to namei.
- */
-int
-ext2_dirrewrite(dp, ip, cnp)
- struct inode *dp, *ip;
- struct componentname *cnp;
-{
- struct buf *bp;
- struct ext2_dir_entry_2 *ep;
- struct vnode *vdp = ITOV(dp);
- int error;
-
- if ((error = UFS_BLKATOFF(vdp, (off_t)dp->i_offset, (char **)&ep, &bp)) != 0)
- return (error);
- ep->inode = ip->i_number;
- if (EXT2_HAS_INCOMPAT_FEATURE(ip->i_e2fs->s_es,
- EXT2_FEATURE_INCOMPAT_FILETYPE))
- ep->file_type = DTTOFT(IFTODT(ip->i_mode));
- else
- ep->file_type = EXT2_FT_UNKNOWN;
- error = VOP_BWRITE(bp->b_vp, bp);
- dp->i_flag |= IN_CHANGE | IN_UPDATE;
- return (error);
-}
-
-/*
- * Check if a directory is empty or not.
- * Inode supplied must be locked.
- *
- * Using a struct dirtemplate here is not precisely
- * what we want, but better than using a struct direct.
- *
- * NB: does not handle corrupted directories.
- */
-int
-ext2_dirempty(ip, parentino, cred)
- register struct inode *ip;
- ino_t parentino;
- struct ucred *cred;
-{
- register off_t off;
- struct dirtemplate dbuf;
- register struct ext2_dir_entry_2 *dp = (struct ext2_dir_entry_2 *)&dbuf;
- int error, count, namlen;
-
-#define MINDIRSIZ (sizeof (struct dirtemplate) / 2)
-
- for (off = 0; off < ip->i_size; off += dp->rec_len) {
- error = vn_rdwr(UIO_READ, ITOV(ip), (caddr_t)dp, MINDIRSIZ, off,
- UIO_SYSSPACE, IO_NODELOCKED, cred, &count, (struct proc *)0);
- /*
- * Since we read MINDIRSIZ, residual must
- * be 0 unless we're at end of file.
- */
- if (error || count != 0)
- return (0);
- /* avoid infinite loops */
- if (dp->rec_len == 0)
- return (0);
- /* skip empty entries */
- if (dp->inode == 0)
- continue;
- /* accept only "." and ".." */
- namlen = dp->name_len;
- if (namlen > 2)
- return (0);
- if (dp->name[0] != '.')
- return (0);
- /*
- * At this point namlen must be 1 or 2.
- * 1 implies ".", 2 implies ".." if second
- * char is also "."
- */
- if (namlen == 1)
- continue;
- if (dp->name[1] == '.' && dp->inode == parentino)
- continue;
- return (0);
- }
- return (1);
-}
-
-/*
- * Check if source directory is in the path of the target directory.
- * Target is supplied locked, source is unlocked.
- * The target is always vput before returning.
- */
-int
-ext2_checkpath(source, target, cred)
- struct inode *source, *target;
- struct ucred *cred;
-{
- struct vnode *vp;
- int error, rootino, namlen;
- struct dirtemplate dirbuf;
-
- vp = ITOV(target);
- if (target->i_number == source->i_number) {
- error = EEXIST;
- goto out;
- }
- rootino = ROOTINO;
- error = 0;
- if (target->i_number == rootino)
- goto out;
-
- for (;;) {
- if (vp->v_type != VDIR) {
- error = ENOTDIR;
- break;
- }
- error = vn_rdwr(UIO_READ, vp, (caddr_t)&dirbuf,
- sizeof (struct dirtemplate), (off_t)0, UIO_SYSSPACE,
- IO_NODELOCKED, cred, (int *)0, (struct proc *)0);
- if (error != 0)
- break;
- namlen = dirbuf.dotdot_type; /* like ufs little-endian */
- if (namlen != 2 ||
- dirbuf.dotdot_name[0] != '.' ||
- dirbuf.dotdot_name[1] != '.') {
- error = ENOTDIR;
- break;
- }
- if (dirbuf.dotdot_ino == source->i_number) {
- error = EINVAL;
- break;
- }
- if (dirbuf.dotdot_ino == rootino)
- break;
- vput(vp);
- if ((error = VFS_VGET(vp->v_mount, dirbuf.dotdot_ino, &vp)) != 0) {
- vp = NULL;
- break;
- }
- }
-
-out:
- if (error == ENOTDIR)
- printf("checkpath: .. not a directory\n");
- if (vp != NULL)
- vput(vp);
- return (error);
-}
-
diff --git a/sys/gnu/fs/ext2fs/ext2_mount.h b/sys/gnu/fs/ext2fs/ext2_mount.h
deleted file mode 100644
index 065254521408..000000000000
--- a/sys/gnu/fs/ext2fs/ext2_mount.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (c) 1982, 1986, 1989, 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)ufsmount.h 8.6 (Berkeley) 3/30/95
- * $FreeBSD$
- */
-
-#ifndef _UFS_UFS_UFSMOUNT_H_
-#define _UFS_UFS_UFSMOUNT_H_
-
-/*
- * Arguments to mount UFS-based filesystems
- */
-struct ufs_args {
- char *fspec; /* block special device to mount */
- struct export_args export; /* network export information */
-};
-
-/*
- * Arguments to mount MFS
- */
-struct mfs_args {
- char *fspec; /* name to export for statfs */
- struct export_args export; /* if exported MFSes are supported */
- caddr_t base; /* base of file system in memory */
- u_long size; /* size of file system */
-};
-
-#ifdef _KERNEL
-
-#ifdef MALLOC_DECLARE
-MALLOC_DECLARE(M_UFSMNT);
-#endif
-
-struct buf;
-struct inode;
-struct nameidata;
-struct timeval;
-struct ucred;
-struct uio;
-struct vnode;
-struct netexport;
-
-/* This structure describes the UFS specific mount structure data. */
-struct ufsmount {
- struct mount *um_mountp; /* filesystem vfs structure */
- dev_t um_dev; /* device mounted */
- struct vnode *um_devvp; /* block device mounted vnode */
-
- union { /* pointer to superblock */
- struct fs *fs; /* FFS */
- struct ext2_sb_info *e2fs; /* EXT2FS */
- } ufsmount_u;
-#define um_fs ufsmount_u.fs
-#define um_e2fs ufsmount_u.e2fs
-#define um_e2fsb ufsmount_u.e2fs->s_es
-
- struct vnode *um_quotas[MAXQUOTAS]; /* pointer to quota files */
- struct ucred *um_cred[MAXQUOTAS]; /* quota file access cred */
- u_long um_nindir; /* indirect ptrs per block */
- u_long um_bptrtodb; /* indir ptr to disk block */
- u_long um_seqinc; /* inc between seq blocks */
- time_t um_btime[MAXQUOTAS]; /* block quota time limit */
- time_t um_itime[MAXQUOTAS]; /* inode quota time limit */
- char um_qflags[MAXQUOTAS]; /* quota specific flags */
- struct netexport um_export; /* export information */
- int64_t um_savedmaxfilesize; /* XXX - limit maxfilesize */
- struct malloc_type *um_malloctype; /* The inodes malloctype */
- int um_i_effnlink_valid; /* i_effnlink valid? */
- int (*um_blkatoff) __P((struct vnode *, off_t, char **, struct buf **));
- int (*um_truncate) __P((struct vnode *, off_t, int, struct ucred *, struct proc *));
- int (*um_update) __P((struct vnode *, int));
- int (*um_valloc) __P((struct vnode *, int, struct ucred *, struct vnode **));
- int (*um_vfree) __P((struct vnode *, ino_t, int));
-};
-
-#define UFS_BLKATOFF(aa, bb, cc, dd) VFSTOUFS((aa)->v_mount)->um_blkatoff(aa, bb, cc, dd)
-#define UFS_TRUNCATE(aa, bb, cc, dd, ee) VFSTOUFS((aa)->v_mount)->um_truncate(aa, bb, cc, dd, ee)
-#define UFS_UPDATE(aa, bb) VFSTOUFS((aa)->v_mount)->um_update(aa, bb)
-#define UFS_VALLOC(aa, bb, cc, dd) VFSTOUFS((aa)->v_mount)->um_valloc(aa, bb, cc, dd)
-#define UFS_VFREE(aa, bb, cc) VFSTOUFS((aa)->v_mount)->um_vfree(aa, bb, cc)
-
-/*
- * Flags describing the state of quotas.
- */
-#define QTF_OPENING 0x01 /* Q_QUOTAON in progress */
-#define QTF_CLOSING 0x02 /* Q_QUOTAOFF in progress */
-
-/* Convert mount ptr to ufsmount ptr. */
-#define VFSTOUFS(mp) ((struct ufsmount *)((mp)->mnt_data))
-
-/*
- * Macros to access file system parameters in the ufsmount structure.
- * Used by ufs_bmap.
- */
-#define MNINDIR(ump) ((ump)->um_nindir)
-#define blkptrtodb(ump, b) ((b) << (ump)->um_bptrtodb)
-#define is_sequential(ump, a, b) ((b) == (a) + ump->um_seqinc)
-#endif /* _KERNEL */
-
-#endif
diff --git a/sys/gnu/fs/ext2fs/ext2_readwrite.c b/sys/gnu/fs/ext2fs/ext2_readwrite.c
deleted file mode 100644
index d49466d0fe68..000000000000
--- a/sys/gnu/fs/ext2fs/ext2_readwrite.c
+++ /dev/null
@@ -1,297 +0,0 @@
-/*
- * modified for Lites 1.1
- *
- * Aug 1995, Godmar Back (gback@cs.utah.edu)
- * University of Utah, Department of Computer Science
- */
-/*
- * Copyright (c) 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)ufs_readwrite.c 8.7 (Berkeley) 1/21/94
- * $FreeBSD$
- */
-
-#define BLKSIZE(a, b, c) blksize(a, b, c)
-#define FS struct ext2_sb_info
-#define I_FS i_e2fs
-#define READ ext2_read
-#define READ_S "ext2_read"
-#define WRITE ext2_write
-#define WRITE_S "ext2_write"
-
-/*
- * Vnode op for reading.
- */
-/* ARGSUSED */
-static int
-READ(ap)
- struct vop_read_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- int a_ioflag;
- struct ucred *a_cred;
- } */ *ap;
-{
- register struct vnode *vp;
- register struct inode *ip;
- register struct uio *uio;
- register FS *fs;
- struct buf *bp;
- daddr_t lbn, nextlbn;
- off_t bytesinfile;
- long size, xfersize, blkoffset;
- int error, orig_resid;
- int seqcount = ap->a_ioflag >> 16;
- u_short mode;
-
- vp = ap->a_vp;
- ip = VTOI(vp);
- mode = ip->i_mode;
- uio = ap->a_uio;
-
-#ifdef DIAGNOSTIC
- if (uio->uio_rw != UIO_READ)
- panic("%s: mode", READ_S);
-
- if (vp->v_type == VLNK) {
- if ((int)ip->i_size < vp->v_mount->mnt_maxsymlinklen)
- panic("%s: short symlink", READ_S);
- } else if (vp->v_type != VREG && vp->v_type != VDIR)
- panic("%s: type %d", READ_S, vp->v_type);
-#endif
- fs = ip->I_FS;
-#if 0
- if ((u_quad_t)uio->uio_offset > fs->fs_maxfilesize)
- return (EFBIG);
-#endif
-
- orig_resid = uio->uio_resid;
- for (error = 0, bp = NULL; uio->uio_resid > 0; bp = NULL) {
- if ((bytesinfile = ip->i_size - uio->uio_offset) <= 0)
- break;
- lbn = lblkno(fs, uio->uio_offset);
- nextlbn = lbn + 1;
- size = BLKSIZE(fs, ip, lbn);
- blkoffset = blkoff(fs, uio->uio_offset);
-
- xfersize = fs->s_frag_size - blkoffset;
- if (uio->uio_resid < xfersize)
- xfersize = uio->uio_resid;
- if (bytesinfile < xfersize)
- xfersize = bytesinfile;
-
- if (lblktosize(fs, nextlbn) >= ip->i_size)
- error = bread(vp, lbn, size, NOCRED, &bp);
- else if ((vp->v_mount->mnt_flag & MNT_NOCLUSTERR) == 0)
- error = cluster_read(vp,
- ip->i_size, lbn, size, NOCRED,
- uio->uio_resid, (ap->a_ioflag >> 16), &bp);
- else if (seqcount > 1) {
- int nextsize = BLKSIZE(fs, ip, nextlbn);
- error = breadn(vp, lbn,
- size, &nextlbn, &nextsize, 1, NOCRED, &bp);
- } else
- error = bread(vp, lbn, size, NOCRED, &bp);
- if (error) {
- brelse(bp);
- bp = NULL;
- break;
- }
-
- /*
- * We should only get non-zero b_resid when an I/O error
- * has occurred, which should cause us to break above.
- * However, if the short read did not cause an error,
- * then we want to ensure that we do not uiomove bad
- * or uninitialized data.
- */
- size -= bp->b_resid;
- if (size < xfersize) {
- if (size == 0)
- break;
- xfersize = size;
- }
- error =
- uiomove((char *)bp->b_data + blkoffset, (int)xfersize, uio);
- if (error)
- break;
-
- bqrelse(bp);
- }
- if (bp != NULL)
- bqrelse(bp);
- if (orig_resid > 0 && (error == 0 || uio->uio_resid != orig_resid) &&
- (vp->v_mount->mnt_flag & MNT_NOATIME) == 0)
- ip->i_flag |= IN_ACCESS;
- return (error);
-}
-
-/*
- * Vnode op for writing.
- */
-static int
-WRITE(ap)
- struct vop_write_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- int a_ioflag;
- struct ucred *a_cred;
- } */ *ap;
-{
- register struct vnode *vp;
- register struct uio *uio;
- register struct inode *ip;
- register FS *fs;
- struct buf *bp;
- struct proc *p;
- daddr_t lbn;
- off_t osize;
- int blkoffset, error, flags, ioflag, resid, size, xfersize;
-
- ioflag = ap->a_ioflag;
- uio = ap->a_uio;
- vp = ap->a_vp;
- ip = VTOI(vp);
-
-#ifdef DIAGNOSTIC
- if (uio->uio_rw != UIO_WRITE)
- panic("%s: mode", WRITE_S);
-#endif
-
- switch (vp->v_type) {
- case VREG:
- if (ioflag & IO_APPEND)
- uio->uio_offset = ip->i_size;
- if ((ip->i_flags & APPEND) && uio->uio_offset != ip->i_size)
- return (EPERM);
- /* FALLTHROUGH */
- case VLNK:
- break;
- case VDIR:
- if ((ioflag & IO_SYNC) == 0)
- panic("%s: nonsync dir write", WRITE_S);
- break;
- default:
- panic("%s: type", WRITE_S);
- }
-
- fs = ip->I_FS;
-#if 0
- if (uio->uio_offset < 0 ||
- (u_quad_t)uio->uio_offset + uio->uio_resid > fs->fs_maxfilesize)
- return (EFBIG);
-#endif
- /*
- * Maybe this should be above the vnode op call, but so long as
- * file servers have no limits, I don't think it matters.
- */
- p = uio->uio_procp;
- if (vp->v_type == VREG && p &&
- uio->uio_offset + uio->uio_resid >
- p->p_rlimit[RLIMIT_FSIZE].rlim_cur) {
- psignal(p, SIGXFSZ);
- return (EFBIG);
- }
-
- resid = uio->uio_resid;
- osize = ip->i_size;
- flags = ioflag & IO_SYNC ? B_SYNC : 0;
-
- for (error = 0; uio->uio_resid > 0;) {
- lbn = lblkno(fs, uio->uio_offset);
- blkoffset = blkoff(fs, uio->uio_offset);
- xfersize = fs->s_frag_size - blkoffset;
- if (uio->uio_resid < xfersize)
- xfersize = uio->uio_resid;
-
- if (uio->uio_offset + xfersize > ip->i_size)
- vnode_pager_setsize(vp, uio->uio_offset + xfersize);
-
- if (fs->s_frag_size > xfersize)
- flags |= B_CLRBUF;
- else
- flags &= ~B_CLRBUF;
-
- error = ext2_balloc(ip,
- lbn, blkoffset + xfersize, ap->a_cred, &bp, flags);
- if (error)
- break;
-
- if (uio->uio_offset + xfersize > ip->i_size) {
- ip->i_size = uio->uio_offset + xfersize;
- }
-
- size = BLKSIZE(fs, ip, lbn) - bp->b_resid;
- if (size < xfersize)
- xfersize = size;
-
- error =
- uiomove((char *)bp->b_data + blkoffset, (int)xfersize, uio);
- if ((ioflag & IO_VMIO) &&
- (LIST_FIRST(&bp->b_dep) == NULL)) /* in ext2fs? */
- bp->b_flags |= B_RELBUF;
-
- if (ioflag & IO_SYNC) {
- (void)bwrite(bp);
- } else if (xfersize + blkoffset == fs->s_frag_size) {
- if ((vp->v_mount->mnt_flag & MNT_NOCLUSTERW) == 0) {
- bp->b_flags |= B_CLUSTEROK;
- cluster_write(bp, ip->i_size);
- } else {
- bawrite(bp);
- }
- } else {
- bp->b_flags |= B_CLUSTEROK;
- bdwrite(bp);
- }
- if (error || xfersize == 0)
- break;
- ip->i_flag |= IN_CHANGE | IN_UPDATE;
- }
- /*
- * If we successfully wrote any data, and we are not the superuser
- * we clear the setuid and setgid bits as a precaution against
- * tampering.
- */
- if (resid > uio->uio_resid && ap->a_cred && ap->a_cred->cr_uid != 0)
- ip->i_mode &= ~(ISUID | ISGID);
- if (error) {
- if (ioflag & IO_UNIT) {
- (void)UFS_TRUNCATE(vp, osize,
- ioflag & IO_SYNC, ap->a_cred, uio->uio_procp);
- uio->uio_offset -= resid - uio->uio_resid;
- uio->uio_resid = resid;
- }
- } else if (resid > uio->uio_resid && (ioflag & IO_SYNC))
- error = UFS_UPDATE(vp, 1);
- return (error);
-}
diff --git a/sys/gnu/fs/ext2fs/ext2_subr.c b/sys/gnu/fs/ext2fs/ext2_subr.c
deleted file mode 100644
index 8ceac7444bd9..000000000000
--- a/sys/gnu/fs/ext2fs/ext2_subr.c
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * modified for Lites 1.1
- *
- * Aug 1995, Godmar Back (gback@cs.utah.edu)
- * University of Utah, Department of Computer Science
- */
-/*
- * Copyright (c) 1982, 1986, 1989, 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)ext2_subr.c 8.2 (Berkeley) 9/21/93
- */
-
-#include <sys/param.h>
-#include <gnu/ext2fs/ext2_fs_sb.h>
-#include <gnu/ext2fs/fs.h>
-
-#include <sys/lock.h>
-#include <sys/systm.h>
-#include <sys/ucred.h>
-#include <sys/vnode.h>
-#include <gnu/ext2fs/ext2_extern.h>
-#include <sys/buf.h>
-#include <ufs/ufs/quota.h>
-#include <ufs/ufs/inode.h>
-
-#include "opt_ddb.h"
-
-#ifdef DDB
-void ext2_checkoverlap __P((struct buf *, struct inode *));
-#endif
-
-/*
- * Return buffer with the contents of block "offset" from the beginning of
- * directory "ip". If "res" is non-zero, fill it in with a pointer to the
- * remaining space in the directory.
- */
-int
-ext2_blkatoff(vp, offset, res, bpp)
- struct vnode *vp;
- off_t offset;
- char **res;
- struct buf **bpp;
-{
- struct inode *ip;
- register struct ext2_sb_info *fs;
- struct buf *bp;
- daddr_t lbn;
- int bsize, error;
-
- ip = VTOI(vp);
- fs = ip->i_e2fs;
- lbn = lblkno(fs, offset);
- bsize = blksize(fs, ip, lbn);
-
- *bpp = NULL;
- if ((error = bread(vp, lbn, bsize, NOCRED, &bp)) != 0) {
- brelse(bp);
- return (error);
- }
- if (res)
- *res = (char *)bp->b_data + blkoff(fs, offset);
- *bpp = bp;
- return (0);
-}
-
-#ifdef DDB
-void
-ext2_checkoverlap(bp, ip)
- struct buf *bp;
- struct inode *ip;
-{
- register struct buf *ebp, *ep;
- register daddr_t start, last;
- struct vnode *vp;
-
- ebp = &buf[nbuf];
- start = bp->b_blkno;
- last = start + btodb(bp->b_bcount) - 1;
- for (ep = buf; ep < ebp; ep++) {
- if (ep == bp || (ep->b_flags & B_INVAL) ||
- ep->b_vp == NULLVP)
- continue;
- if (VOP_BMAP(ep->b_vp, (daddr_t)0, &vp, (daddr_t)0, NULL, NULL))
- continue;
- if (vp != ip->i_devvp)
- continue;
- /* look for overlap */
- if (ep->b_bcount == 0 || ep->b_blkno > last ||
- ep->b_blkno + btodb(ep->b_bcount) <= start)
- continue;
- vprint("Disk overlap", vp);
- (void)printf("\tstart %d, end %d overlap start %d, end %d\n",
- start, last, ep->b_blkno,
- ep->b_blkno + btodb(ep->b_bcount) - 1);
- panic("Disk buffer overlap");
- }
-}
-#endif /* DDB */
diff --git a/sys/gnu/fs/ext2fs/ext2_vfsops.c b/sys/gnu/fs/ext2fs/ext2_vfsops.c
deleted file mode 100644
index a56a443de578..000000000000
--- a/sys/gnu/fs/ext2fs/ext2_vfsops.c
+++ /dev/null
@@ -1,1197 +0,0 @@
-/*
- * modified for EXT2FS support in Lites 1.1
- *
- * Aug 1995, Godmar Back (gback@cs.utah.edu)
- * University of Utah, Department of Computer Science
- */
-/*
- * Copyright (c) 1989, 1991, 1993, 1994
- * 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)ffs_vfsops.c 8.8 (Berkeley) 4/18/94
- * $FreeBSD$
- */
-
-#include "opt_quota.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/namei.h>
-#include <sys/proc.h>
-#include <sys/kernel.h>
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <sys/buf.h>
-#include <sys/conf.h>
-#include <sys/fcntl.h>
-#include <sys/disklabel.h>
-#include <sys/malloc.h>
-#include <sys/stat.h>
-
-#include <ufs/ufs/quota.h>
-#include <ufs/ufs/ufsmount.h>
-#include <ufs/ufs/inode.h>
-#include <ufs/ufs/ufs_extern.h>
-
-#include <vm/vm_zone.h>
-
-#include <gnu/ext2fs/fs.h>
-#include <gnu/ext2fs/ext2_extern.h>
-#include <gnu/ext2fs/ext2_fs.h>
-#include <gnu/ext2fs/ext2_fs_sb.h>
-
-static int ext2_fhtovp __P((struct mount *, struct fid *, struct vnode **));
-static int ext2_flushfiles __P((struct mount *mp, int flags, struct proc *p));
-static int ext2_mount __P((struct mount *,
- char *, caddr_t, struct nameidata *, struct proc *));
-static int ext2_mountfs __P((struct vnode *, struct mount *, struct proc *));
-static int ext2_reload __P((struct mount *mountp, struct ucred *cred,
- struct proc *p));
-static int ext2_sbupdate __P((struct ufsmount *, int));
-static int ext2_statfs __P((struct mount *, struct statfs *, struct proc *));
-static int ext2_sync __P((struct mount *, int, struct ucred *, struct proc *));
-static int ext2_unmount __P((struct mount *, int, struct proc *));
-static int ext2_vget __P((struct mount *, ino_t, struct vnode **));
-static int ext2_vptofh __P((struct vnode *, struct fid *));
-
-static MALLOC_DEFINE(M_EXT2NODE, "EXT2 node", "EXT2 vnode private part");
-
-static struct vfsops ext2fs_vfsops = {
- ext2_mount,
- ufs_start, /* empty function */
- ext2_unmount,
- ufs_root, /* root inode via vget */
- ufs_quotactl, /* does operations associated with quotas */
- ext2_statfs,
- ext2_sync,
- ext2_vget,
- ext2_fhtovp,
- ufs_check_export,
- ext2_vptofh,
- ext2_init,
- vfs_stduninit,
- vfs_stdextattrctl,
-};
-
-VFS_SET(ext2fs_vfsops, ext2fs, 0);
-#define bsd_malloc malloc
-#define bsd_free free
-
-static int ext2fs_inode_hash_lock;
-
-static int ext2_check_sb_compat __P((struct ext2_super_block *es,
- dev_t dev, int ronly));
-static int compute_sb_data __P((struct vnode * devvp,
- struct ext2_super_block * es,
- struct ext2_sb_info * fs));
-
-#ifdef notyet
-static int ext2_mountroot __P((void));
-
-/*
- * Called by main() when ext2fs is going to be mounted as root.
- *
- * Name is updated by mount(8) after booting.
- */
-#define ROOTNAME "root_device"
-
-static int
-ext2_mountroot()
-{
- register struct ext2_sb_info *fs;
- register struct mount *mp;
- struct proc *p = curproc;
- struct ufsmount *ump;
- u_int size;
- int error;
-
- if ((error = bdevvp(rootdev, &rootvp))) {
- printf("ext2_mountroot: can't find rootvp\n");
- return (error);
- }
- mp = bsd_malloc((u_long)sizeof(struct mount), M_MOUNT, M_WAITOK);
- bzero((char *)mp, (u_long)sizeof(struct mount));
- mp->mnt_op = &ext2fs_vfsops;
- mp->mnt_flag = MNT_RDONLY;
- if (error = ext2_mountfs(rootvp, mp, p)) {
- bsd_free(mp, M_MOUNT);
- return (error);
- }
- if (error = vfs_lock(mp)) {
- (void)ext2_unmount(mp, 0, p);
- bsd_free(mp, M_MOUNT);
- return (error);
- }
- TAILQ_INSERT_HEAD(&mountlist, mp, mnt_list);
- mp->mnt_flag |= MNT_ROOTFS;
- mp->mnt_vnodecovered = NULLVP;
- ump = VFSTOUFS(mp);
- fs = ump->um_e2fs;
- bzero(fs->fs_fsmnt, sizeof(fs->fs_fsmnt));
- fs->fs_fsmnt[0] = '/';
- bcopy((caddr_t)fs->fs_fsmnt, (caddr_t)mp->mnt_stat.f_mntonname,
- MNAMELEN);
- (void) copystr(ROOTNAME, mp->mnt_stat.f_mntfromname, MNAMELEN - 1,
- &size);
- bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
- (void)ext2_statfs(mp, &mp->mnt_stat, p);
- vfs_unlock(mp);
- inittodr(fs->s_es->s_wtime); /* this helps to set the time */
- return (0);
-}
-#endif
-
-/*
- * VFS Operations.
- *
- * mount system call
- */
-static int
-ext2_mount(mp, path, data, ndp, p)
- register struct mount *mp;
- char *path;
- caddr_t data; /* this is actually a (struct ufs_args *) */
- struct nameidata *ndp;
- struct proc *p;
-{
- struct vnode *devvp;
- struct ufs_args args;
- struct ufsmount *ump = 0;
- register struct ext2_sb_info *fs;
- u_int size;
- int error, flags;
- mode_t accessmode;
-
- if ((error = copyin(data, (caddr_t)&args, sizeof (struct ufs_args))) != 0)
- return (error);
- /*
- * If updating, check whether changing from read-only to
- * read/write; if there is no device name, that's all we do.
- */
- if (mp->mnt_flag & MNT_UPDATE) {
- ump = VFSTOUFS(mp);
- fs = ump->um_e2fs;
- error = 0;
- if (fs->s_rd_only == 0 && (mp->mnt_flag & MNT_RDONLY)) {
- flags = WRITECLOSE;
- if (mp->mnt_flag & MNT_FORCE)
- flags |= FORCECLOSE;
- if (vfs_busy(mp, LK_NOWAIT, 0, p))
- return (EBUSY);
- error = ext2_flushfiles(mp, flags, p);
- vfs_unbusy(mp, p);
- if (!error && fs->s_wasvalid) {
- fs->s_es->s_state |= EXT2_VALID_FS;
- ext2_sbupdate(ump, MNT_WAIT);
- }
- fs->s_rd_only = 1;
- }
- if (!error && (mp->mnt_flag & MNT_RELOAD))
- error = ext2_reload(mp, ndp->ni_cnd.cn_cred, p);
- if (error)
- return (error);
- devvp = ump->um_devvp;
- if (ext2_check_sb_compat(fs->s_es, devvp->v_rdev,
- (mp->mnt_kern_flag & MNTK_WANTRDWR) == 0) != 0)
- return (EPERM);
- if (fs->s_rd_only && (mp->mnt_kern_flag & MNTK_WANTRDWR)) {
- /*
- * If upgrade to read-write by non-root, then verify
- * that user has necessary permissions on the device.
- */
- if (p->p_ucred->cr_uid != 0) {
- vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p);
- if ((error = VOP_ACCESS(devvp, VREAD | VWRITE,
- p->p_ucred, p)) != 0) {
- VOP_UNLOCK(devvp, 0, p);
- return (error);
- }
- VOP_UNLOCK(devvp, 0, p);
- }
-
- if ((fs->s_es->s_state & EXT2_VALID_FS) == 0 ||
- (fs->s_es->s_state & EXT2_ERROR_FS)) {
- if (mp->mnt_flag & MNT_FORCE) {
- printf(
-"WARNING: %s was not properly dismounted\n",
- fs->fs_fsmnt);
- } else {
- printf(
-"WARNING: R/W mount of %s denied. Filesystem is not clean - run fsck\n",
- fs->fs_fsmnt);
- return (EPERM);
- }
- }
- fs->s_es->s_state &= ~EXT2_VALID_FS;
- ext2_sbupdate(ump, MNT_WAIT);
- fs->s_rd_only = 0;
- }
- if (args.fspec == 0) {
- /*
- * Process export requests.
- */
- return (vfs_export(mp, &ump->um_export, &args.export));
- }
- }
- /*
- * Not an update, or updating the name: look up the name
- * and verify that it refers to a sensible block device.
- */
- NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, p);
- if ((error = namei(ndp)) != 0)
- return (error);
- NDFREE(ndp, NDF_ONLY_PNBUF);
- devvp = ndp->ni_vp;
-
- if (!vn_isdisk(devvp, &error)) {
- vrele(devvp);
- return (error);
- }
-
- /*
- * If mount by non-root, then verify that user has necessary
- * permissions on the device.
- */
- if (p->p_ucred->cr_uid != 0) {
- accessmode = VREAD;
- if ((mp->mnt_flag & MNT_RDONLY) == 0)
- accessmode |= VWRITE;
- vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p);
- if ((error = VOP_ACCESS(devvp, accessmode, p->p_ucred, p)) != 0) {
- vput(devvp);
- return (error);
- }
- VOP_UNLOCK(devvp, 0, p);
- }
-
- if ((mp->mnt_flag & MNT_UPDATE) == 0) {
- error = ext2_mountfs(devvp, mp, p);
- } else {
- if (devvp != ump->um_devvp)
- error = EINVAL; /* needs translation */
- else
- vrele(devvp);
- }
- if (error) {
- vrele(devvp);
- return (error);
- }
- ump = VFSTOUFS(mp);
- fs = ump->um_e2fs;
- (void) copyinstr(path, fs->fs_fsmnt, sizeof(fs->fs_fsmnt) - 1, &size);
- bzero(fs->fs_fsmnt + size, sizeof(fs->fs_fsmnt) - size);
- bcopy((caddr_t)fs->fs_fsmnt, (caddr_t)mp->mnt_stat.f_mntonname,
- MNAMELEN);
- (void) copyinstr(args.fspec, mp->mnt_stat.f_mntfromname, MNAMELEN - 1,
- &size);
- bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
- (void)ext2_statfs(mp, &mp->mnt_stat, p);
- return (0);
-}
-
-/*
- * checks that the data in the descriptor blocks make sense
- * this is taken from ext2/super.c
- */
-static int ext2_check_descriptors (struct ext2_sb_info * sb)
-{
- int i;
- int desc_block = 0;
- unsigned long block = sb->s_es->s_first_data_block;
- struct ext2_group_desc * gdp = NULL;
-
- /* ext2_debug ("Checking group descriptors"); */
-
- for (i = 0; i < sb->s_groups_count; i++)
- {
- /* examine next descriptor block */
- if ((i % EXT2_DESC_PER_BLOCK(sb)) == 0)
- gdp = (struct ext2_group_desc *)
- sb->s_group_desc[desc_block++]->b_data;
- if (gdp->bg_block_bitmap < block ||
- gdp->bg_block_bitmap >= block + EXT2_BLOCKS_PER_GROUP(sb))
- {
- printf ("ext2_check_descriptors: "
- "Block bitmap for group %d"
- " not in group (block %lu)!\n",
- i, (unsigned long) gdp->bg_block_bitmap);
- return 0;
- }
- if (gdp->bg_inode_bitmap < block ||
- gdp->bg_inode_bitmap >= block + EXT2_BLOCKS_PER_GROUP(sb))
- {
- printf ("ext2_check_descriptors: "
- "Inode bitmap for group %d"
- " not in group (block %lu)!\n",
- i, (unsigned long) gdp->bg_inode_bitmap);
- return 0;
- }
- if (gdp->bg_inode_table < block ||
- gdp->bg_inode_table + sb->s_itb_per_group >=
- block + EXT2_BLOCKS_PER_GROUP(sb))
- {
- printf ("ext2_check_descriptors: "
- "Inode table for group %d"
- " not in group (block %lu)!\n",
- i, (unsigned long) gdp->bg_inode_table);
- return 0;
- }
- block += EXT2_BLOCKS_PER_GROUP(sb);
- gdp++;
- }
- return 1;
-}
-
-static int
-ext2_check_sb_compat(es, dev, ronly)
- struct ext2_super_block *es;
- dev_t dev;
- int ronly;
-{
-
- if (es->s_magic != EXT2_SUPER_MAGIC) {
- printf("ext2fs: %s: wrong magic number %#x (expected %#x)\n",
- devtoname(dev), es->s_magic, EXT2_SUPER_MAGIC);
- return (1);
- }
- if (es->s_rev_level > EXT2_GOOD_OLD_REV) {
- if (es->s_feature_incompat & ~EXT2_FEATURE_INCOMPAT_SUPP) {
- printf(
-"WARNING: mount of %s denied due to unsupported optional features\n",
- devtoname(dev));
- return (1);
- }
- if (!ronly &&
- (es->s_feature_ro_compat & ~EXT2_FEATURE_RO_COMPAT_SUPP)) {
- printf(
-"WARNING: R/W mount of %s denied due to unsupported optional features\n",
- devtoname(dev));
- return (1);
- }
- }
- return (0);
-}
-
-/*
- * this computes the fields of the ext2_sb_info structure from the
- * data in the ext2_super_block structure read in
- */
-static int compute_sb_data(devvp, es, fs)
- struct vnode * devvp;
- struct ext2_super_block * es;
- struct ext2_sb_info * fs;
-{
- int db_count, error;
- int i, j;
- int logic_sb_block = 1; /* XXX for now */
-
-#if 1
-#define V(v)
-#else
-#define V(v) printf(#v"= %d\n", fs->v);
-#endif
-
- fs->s_blocksize = EXT2_MIN_BLOCK_SIZE << es->s_log_block_size;
- V(s_blocksize)
- fs->s_bshift = EXT2_MIN_BLOCK_LOG_SIZE + es->s_log_block_size;
- V(s_bshift)
- fs->s_fsbtodb = es->s_log_block_size + 1;
- V(s_fsbtodb)
- fs->s_qbmask = fs->s_blocksize - 1;
- V(s_bmask)
- fs->s_blocksize_bits = EXT2_BLOCK_SIZE_BITS(es);
- V(s_blocksize_bits)
- fs->s_frag_size = EXT2_MIN_FRAG_SIZE << es->s_log_frag_size;
- V(s_frag_size)
- if (fs->s_frag_size)
- fs->s_frags_per_block = fs->s_blocksize / fs->s_frag_size;
- V(s_frags_per_block)
- fs->s_blocks_per_group = es->s_blocks_per_group;
- V(s_blocks_per_group)
- fs->s_frags_per_group = es->s_frags_per_group;
- V(s_frags_per_group)
- fs->s_inodes_per_group = es->s_inodes_per_group;
- V(s_inodes_per_group)
- fs->s_inodes_per_block = fs->s_blocksize / EXT2_INODE_SIZE;
- V(s_inodes_per_block)
- fs->s_itb_per_group = fs->s_inodes_per_group /fs->s_inodes_per_block;
- V(s_itb_per_group)
- fs->s_desc_per_block = fs->s_blocksize / sizeof (struct ext2_group_desc);
- V(s_desc_per_block)
- /* s_resuid / s_resgid ? */
- fs->s_groups_count = (es->s_blocks_count -
- es->s_first_data_block +
- EXT2_BLOCKS_PER_GROUP(fs) - 1) /
- EXT2_BLOCKS_PER_GROUP(fs);
- V(s_groups_count)
- db_count = (fs->s_groups_count + EXT2_DESC_PER_BLOCK(fs) - 1) /
- EXT2_DESC_PER_BLOCK(fs);
- fs->s_db_per_group = db_count;
- V(s_db_per_group)
-
- fs->s_group_desc = bsd_malloc(db_count * sizeof (struct buf *),
- M_UFSMNT, M_WAITOK);
-
- /* adjust logic_sb_block */
- if(fs->s_blocksize > SBSIZE)
- /* Godmar thinks: if the blocksize is greater than 1024, then
- the superblock is logically part of block zero.
- */
- logic_sb_block = 0;
-
- for (i = 0; i < db_count; i++) {
- error = bread(devvp , fsbtodb(fs, logic_sb_block + i + 1),
- fs->s_blocksize, NOCRED, &fs->s_group_desc[i]);
- if(error) {
- for (j = 0; j < i; j++)
- brelse(fs->s_group_desc[j]);
- bsd_free(fs->s_group_desc, M_UFSMNT);
- printf("EXT2-fs: unable to read group descriptors (%d)\n", error);
- return EIO;
- }
- /* Set the B_LOCKED flag on the buffer, then brelse() it */
- LCK_BUF(fs->s_group_desc[i])
- }
- if(!ext2_check_descriptors(fs)) {
- for (j = 0; j < db_count; j++)
- ULCK_BUF(fs->s_group_desc[j])
- bsd_free(fs->s_group_desc, M_UFSMNT);
- printf("EXT2-fs: (ext2_check_descriptors failure) "
- "unable to read group descriptors\n");
- return EIO;
- }
-
- for (i = 0; i < EXT2_MAX_GROUP_LOADED; i++) {
- fs->s_inode_bitmap_number[i] = 0;
- fs->s_inode_bitmap[i] = NULL;
- fs->s_block_bitmap_number[i] = 0;
- fs->s_block_bitmap[i] = NULL;
- }
- fs->s_loaded_inode_bitmaps = 0;
- fs->s_loaded_block_bitmaps = 0;
- return 0;
-}
-
-/*
- * Reload all incore data for a filesystem (used after running fsck on
- * the root filesystem and finding things to fix). The filesystem must
- * be mounted read-only.
- *
- * Things to do to update the mount:
- * 1) invalidate all cached meta-data.
- * 2) re-read superblock from disk.
- * 3) re-read summary information from disk.
- * 4) invalidate all inactive vnodes.
- * 5) invalidate all cached file data.
- * 6) re-read inode data for all active vnodes.
- */
-static int
-ext2_reload(mountp, cred, p)
- register struct mount *mountp;
- struct ucred *cred;
- struct proc *p;
-{
- register struct vnode *vp, *nvp, *devvp;
- struct inode *ip;
- struct buf *bp;
- struct ext2_super_block * es;
- struct ext2_sb_info *fs;
- int error;
-
- if ((mountp->mnt_flag & MNT_RDONLY) == 0)
- return (EINVAL);
- /*
- * Step 1: invalidate all cached meta-data.
- */
- devvp = VFSTOUFS(mountp)->um_devvp;
- if (vinvalbuf(devvp, 0, cred, p, 0, 0))
- panic("ext2_reload: dirty1");
- /*
- * Step 2: re-read superblock from disk.
- * constants have been adjusted for ext2
- */
- if ((error = bread(devvp, SBLOCK, SBSIZE, NOCRED, &bp)) != 0)
- return (error);
- es = (struct ext2_super_block *)bp->b_data;
- if (ext2_check_sb_compat(es, devvp->v_rdev, 0) != 0) {
- brelse(bp);
- return (EIO); /* XXX needs translation */
- }
- fs = VFSTOUFS(mountp)->um_e2fs;
- bcopy(bp->b_data, fs->s_es, sizeof(struct ext2_super_block));
-
- if((error = compute_sb_data(devvp, es, fs)) != 0) {
- brelse(bp);
- return error;
- }
-#ifdef UNKLAR
- if (fs->fs_sbsize < SBSIZE)
- bp->b_flags |= B_INVAL;
-#endif
- brelse(bp);
-
-loop:
- simple_lock(&mntvnode_slock);
- for (vp = mountp->mnt_vnodelist.lh_first; vp != NULL; vp = nvp) {
- if (vp->v_mount != mountp) {
- simple_unlock(&mntvnode_slock);
- goto loop;
- }
- nvp = vp->v_mntvnodes.le_next;
- /*
- * Step 4: invalidate all inactive vnodes.
- */
- if (vrecycle(vp, &mntvnode_slock, p))
- goto loop;
- /*
- * Step 5: invalidate all cached file data.
- */
- simple_lock(&vp->v_interlock);
- simple_unlock(&mntvnode_slock);
- if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, p)) {
- goto loop;
- }
- if (vinvalbuf(vp, 0, cred, p, 0, 0))
- panic("ext2_reload: dirty2");
- /*
- * Step 6: re-read inode data for all active vnodes.
- */
- ip = VTOI(vp);
- error =
- bread(devvp, fsbtodb(fs, ino_to_fsba(fs, ip->i_number)),
- (int)fs->s_blocksize, NOCRED, &bp);
- if (error) {
- vput(vp);
- return (error);
- }
- ext2_ei2di((struct ext2_inode *) ((char *)bp->b_data +
- EXT2_INODE_SIZE * ino_to_fsbo(fs, ip->i_number)),
- &ip->i_din);
- brelse(bp);
- vput(vp);
- simple_lock(&mntvnode_slock);
- }
- simple_unlock(&mntvnode_slock);
- return (0);
-}
-
-/*
- * Common code for mount and mountroot
- */
-static int
-ext2_mountfs(devvp, mp, p)
- register struct vnode *devvp;
- struct mount *mp;
- struct proc *p;
-{
- register struct ufsmount *ump;
- struct buf *bp;
- register struct ext2_sb_info *fs;
- struct ext2_super_block * es;
- dev_t dev = devvp->v_rdev;
- struct partinfo dpart;
- int havepart = 0;
- int error, i, size;
- int ronly;
-
- /*
- * Disallow multiple mounts of the same device.
- * Disallow mounting of a device that is currently in use
- * (except for root, which might share swap device for miniroot).
- * Flush out any old buffers remaining from a previous use.
- */
- if ((error = vfs_mountedon(devvp)) != 0)
- return (error);
- if (vcount(devvp) > 1 && devvp != rootvp)
- return (EBUSY);
- if ((error = vinvalbuf(devvp, V_SAVE, p->p_ucred, p, 0, 0)) != 0)
- return (error);
-#ifdef READONLY
-/* turn on this to force it to be read-only */
- mp->mnt_flag |= MNT_RDONLY;
-#endif
-
- ronly = (mp->mnt_flag & MNT_RDONLY) != 0;
- vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p);
- error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, p);
- VOP_UNLOCK(devvp, 0, p);
- if (error)
- return (error);
- if (VOP_IOCTL(devvp, DIOCGPART, (caddr_t)&dpart, FREAD, NOCRED, p) != 0)
- size = DEV_BSIZE;
- else {
- havepart = 1;
- size = dpart.disklab->d_secsize;
- }
-
- bp = NULL;
- ump = NULL;
- if ((error = bread(devvp, SBLOCK, SBSIZE, NOCRED, &bp)) != 0)
- goto out;
- es = (struct ext2_super_block *)bp->b_data;
- if (ext2_check_sb_compat(es, dev, ronly) != 0) {
- error = EINVAL; /* XXX needs translation */
- goto out;
- }
- if ((es->s_state & EXT2_VALID_FS) == 0 ||
- (es->s_state & EXT2_ERROR_FS)) {
- if (ronly || (mp->mnt_flag & MNT_FORCE)) {
- printf(
-"WARNING: Filesystem was not properly dismounted\n");
- } else {
- printf(
-"WARNING: R/W mount denied. Filesystem is not clean - run fsck\n");
- error = EPERM;
- goto out;
- }
- }
- ump = bsd_malloc(sizeof *ump, M_UFSMNT, M_WAITOK);
- bzero((caddr_t)ump, sizeof *ump);
- ump->um_malloctype = M_EXT2NODE;
- ump->um_blkatoff = ext2_blkatoff;
- ump->um_truncate = ext2_truncate;
- ump->um_update = ext2_update;
- ump->um_valloc = ext2_valloc;
- ump->um_vfree = ext2_vfree;
- /* I don't know whether this is the right strategy. Note that
- we dynamically allocate both a ext2_sb_info and a ext2_super_block
- while Linux keeps the super block in a locked buffer
- */
- ump->um_e2fs = bsd_malloc(sizeof(struct ext2_sb_info),
- M_UFSMNT, M_WAITOK);
- ump->um_e2fs->s_es = bsd_malloc(sizeof(struct ext2_super_block),
- M_UFSMNT, M_WAITOK);
- bcopy(es, ump->um_e2fs->s_es, (u_int)sizeof(struct ext2_super_block));
- if ((error = compute_sb_data(devvp, ump->um_e2fs->s_es, ump->um_e2fs)))
- goto out;
- /*
- * We don't free the group descriptors allocated by compute_sb_data()
- * until ext2_unmount(). This is OK since the mount will succeed.
- */
- brelse(bp);
- bp = NULL;
- fs = ump->um_e2fs;
- fs->s_rd_only = ronly; /* ronly is set according to mnt_flags */
- /* if the fs is not mounted read-only, make sure the super block is
- always written back on a sync()
- */
- fs->s_wasvalid = fs->s_es->s_state & EXT2_VALID_FS ? 1 : 0;
- if (ronly == 0) {
- fs->s_dirt = 1; /* mark it modified */
- fs->s_es->s_state &= ~EXT2_VALID_FS; /* set fs invalid */
- }
- mp->mnt_data = (qaddr_t)ump;
- mp->mnt_stat.f_fsid.val[0] = dev2udev(dev);
- mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum;
- mp->mnt_maxsymlinklen = EXT2_MAXSYMLINKLEN;
- mp->mnt_flag |= MNT_LOCAL;
- ump->um_mountp = mp;
- ump->um_dev = dev;
- ump->um_devvp = devvp;
- /* setting those two parameters allows us to use
- ufs_bmap w/o changse !
- */
- ump->um_nindir = EXT2_ADDR_PER_BLOCK(fs);
- ump->um_bptrtodb = fs->s_es->s_log_block_size + 1;
- ump->um_seqinc = EXT2_FRAGS_PER_BLOCK(fs);
- for (i = 0; i < MAXQUOTAS; i++)
- ump->um_quotas[i] = NULLVP;
- devvp->v_specmountpoint = mp;
- if (ronly == 0)
- ext2_sbupdate(ump, MNT_WAIT);
- return (0);
-out:
- if (bp)
- brelse(bp);
- (void)VOP_CLOSE(devvp, ronly ? FREAD : FREAD|FWRITE, NOCRED, p);
- if (ump) {
- bsd_free(ump->um_e2fs->s_es, M_UFSMNT);
- bsd_free(ump->um_e2fs, M_UFSMNT);
- bsd_free(ump, M_UFSMNT);
- mp->mnt_data = (qaddr_t)0;
- }
- return (error);
-}
-
-/*
- * unmount system call
- */
-static int
-ext2_unmount(mp, mntflags, p)
- struct mount *mp;
- int mntflags;
- struct proc *p;
-{
- register struct ufsmount *ump;
- register struct ext2_sb_info *fs;
- int error, flags, ronly, i;
-
- flags = 0;
- if (mntflags & MNT_FORCE) {
- if (mp->mnt_flag & MNT_ROOTFS)
- return (EINVAL);
- flags |= FORCECLOSE;
- }
- if ((error = ext2_flushfiles(mp, flags, p)) != 0)
- return (error);
- ump = VFSTOUFS(mp);
- fs = ump->um_e2fs;
- ronly = fs->s_rd_only;
- if (ronly == 0) {
- if (fs->s_wasvalid)
- fs->s_es->s_state |= EXT2_VALID_FS;
- ext2_sbupdate(ump, MNT_WAIT);
- }
-
- /* release buffers containing group descriptors */
- for(i = 0; i < fs->s_db_per_group; i++)
- ULCK_BUF(fs->s_group_desc[i])
- bsd_free(fs->s_group_desc, M_UFSMNT);
-
- /* release cached inode/block bitmaps */
- for (i = 0; i < EXT2_MAX_GROUP_LOADED; i++)
- if (fs->s_inode_bitmap[i])
- ULCK_BUF(fs->s_inode_bitmap[i])
-
- for (i = 0; i < EXT2_MAX_GROUP_LOADED; i++)
- if (fs->s_block_bitmap[i])
- ULCK_BUF(fs->s_block_bitmap[i])
-
- ump->um_devvp->v_specmountpoint = NULL;
- error = VOP_CLOSE(ump->um_devvp, ronly ? FREAD : FREAD|FWRITE,
- NOCRED, p);
- vrele(ump->um_devvp);
- bsd_free(fs->s_es, M_UFSMNT);
- bsd_free(fs, M_UFSMNT);
- bsd_free(ump, M_UFSMNT);
- mp->mnt_data = (qaddr_t)0;
- mp->mnt_flag &= ~MNT_LOCAL;
- return (error);
-}
-
-/*
- * Flush out all the files in a filesystem.
- */
-static int
-ext2_flushfiles(mp, flags, p)
- register struct mount *mp;
- int flags;
- struct proc *p;
-{
- register struct ufsmount *ump;
- int error;
-#if QUOTA
- int i;
-#endif
-
- ump = VFSTOUFS(mp);
-#if QUOTA
- if (mp->mnt_flag & MNT_QUOTA) {
- if ((error = vflush(mp, NULLVP, SKIPSYSTEM|flags)) != 0)
- return (error);
- for (i = 0; i < MAXQUOTAS; i++) {
- if (ump->um_quotas[i] == NULLVP)
- continue;
- quotaoff(p, mp, i);
- }
- /*
- * Here we fall through to vflush again to ensure
- * that we have gotten rid of all the system vnodes.
- */
- }
-#endif
- error = vflush(mp, NULLVP, flags);
- return (error);
-}
-
-/*
- * Get file system statistics.
- * taken from ext2/super.c ext2_statfs
- */
-static int
-ext2_statfs(mp, sbp, p)
- struct mount *mp;
- register struct statfs *sbp;
- struct proc *p;
-{
- unsigned long overhead;
- unsigned long overhead_per_group;
-
- register struct ufsmount *ump;
- register struct ext2_sb_info *fs;
- register struct ext2_super_block *es;
-
- ump = VFSTOUFS(mp);
- fs = ump->um_e2fs;
- es = fs->s_es;
-
- if (es->s_magic != EXT2_SUPER_MAGIC)
- panic("ext2_statfs - magic number spoiled");
-
- /*
- * Compute the overhead (FS structures)
- */
- overhead_per_group = 1 /* super block */ +
- fs->s_db_per_group +
- 1 /* block bitmap */ +
- 1 /* inode bitmap */ +
- fs->s_itb_per_group;
- overhead = es->s_first_data_block +
- fs->s_groups_count * overhead_per_group;
-
- sbp->f_bsize = EXT2_FRAG_SIZE(fs);
- sbp->f_iosize = EXT2_BLOCK_SIZE(fs);
- sbp->f_blocks = es->s_blocks_count - overhead;
- sbp->f_bfree = es->s_free_blocks_count;
- sbp->f_bavail = sbp->f_bfree - es->s_r_blocks_count;
- sbp->f_files = es->s_inodes_count;
- sbp->f_ffree = es->s_free_inodes_count;
- if (sbp != &mp->mnt_stat) {
- sbp->f_type = mp->mnt_vfc->vfc_typenum;
- bcopy((caddr_t)mp->mnt_stat.f_mntonname,
- (caddr_t)&sbp->f_mntonname[0], MNAMELEN);
- bcopy((caddr_t)mp->mnt_stat.f_mntfromname,
- (caddr_t)&sbp->f_mntfromname[0], MNAMELEN);
- }
- return (0);
-}
-
-/*
- * Go through the disk queues to initiate sandbagged IO;
- * go through the inodes to write those that have been modified;
- * initiate the writing of the super block if it has been modified.
- *
- * Note: we are always called with the filesystem marked `MPBUSY'.
- */
-static int
-ext2_sync(mp, waitfor, cred, p)
- struct mount *mp;
- int waitfor;
- struct ucred *cred;
- struct proc *p;
-{
- struct vnode *nvp, *vp;
- struct inode *ip;
- struct ufsmount *ump = VFSTOUFS(mp);
- struct ext2_sb_info *fs;
- int error, allerror = 0;
-
- fs = ump->um_e2fs;
- if (fs->s_dirt != 0 && fs->s_rd_only != 0) { /* XXX */
- printf("fs = %s\n", fs->fs_fsmnt);
- panic("ext2_sync: rofs mod");
- }
- /*
- * Write back each (modified) inode.
- */
- simple_lock(&mntvnode_slock);
-loop:
- for (vp = mp->mnt_vnodelist.lh_first; vp != NULL; vp = nvp) {
- /*
- * If the vnode that we are about to sync is no longer
- * associated with this mount point, start over.
- */
- if (vp->v_mount != mp)
- goto loop;
- simple_lock(&vp->v_interlock);
- nvp = vp->v_mntvnodes.le_next;
- ip = VTOI(vp);
- if (vp->v_type == VNON ||
- ((ip->i_flag &
- (IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE)) == 0 &&
- (TAILQ_EMPTY(&vp->v_dirtyblkhd) || waitfor == MNT_LAZY))) {
- simple_unlock(&vp->v_interlock);
- continue;
- }
- simple_unlock(&mntvnode_slock);
- error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT | LK_INTERLOCK, p);
- if (error) {
- simple_lock(&mntvnode_slock);
- if (error == ENOENT)
- goto loop;
- continue;
- }
- if ((error = VOP_FSYNC(vp, cred, waitfor, p)) != 0)
- allerror = error;
- VOP_UNLOCK(vp, 0, p);
- vrele(vp);
- simple_lock(&mntvnode_slock);
- }
- simple_unlock(&mntvnode_slock);
- /*
- * Force stale file system control information to be flushed.
- */
- if (waitfor != MNT_LAZY) {
- vn_lock(ump->um_devvp, LK_EXCLUSIVE | LK_RETRY, p);
- if ((error = VOP_FSYNC(ump->um_devvp, cred, waitfor, p)) != 0)
- allerror = error;
- VOP_UNLOCK(ump->um_devvp, 0, p);
- }
-#if QUOTA
- qsync(mp);
-#endif
- /*
- * Write back modified superblock.
- */
- if (fs->s_dirt != 0) {
- fs->s_dirt = 0;
- fs->s_es->s_wtime = time_second;
- if ((error = ext2_sbupdate(ump, waitfor)) != 0)
- allerror = error;
- }
- return (allerror);
-}
-
-/*
- * Look up a EXT2FS dinode number to find its incore vnode, otherwise read it
- * in from disk. If it is in core, wait for the lock bit to clear, then
- * return the inode locked. Detection and handling of mount points must be
- * done by the calling routine.
- */
-static int
-ext2_vget(mp, ino, vpp)
- struct mount *mp;
- ino_t ino;
- struct vnode **vpp;
-{
- register struct ext2_sb_info *fs;
- register struct inode *ip;
- struct ufsmount *ump;
- struct buf *bp;
- struct vnode *vp;
- dev_t dev;
- int i, error;
- int used_blocks;
-
- ump = VFSTOUFS(mp);
- dev = ump->um_dev;
-restart:
- if ((*vpp = ufs_ihashget(dev, ino)) != NULL)
- return (0);
-
- /*
- * Lock out the creation of new entries in the FFS hash table in
- * case getnewvnode() or MALLOC() blocks, otherwise a duplicate
- * may occur!
- */
- if (ext2fs_inode_hash_lock) {
- while (ext2fs_inode_hash_lock) {
- ext2fs_inode_hash_lock = -1;
- tsleep(&ext2fs_inode_hash_lock, PVM, "e2vget", 0);
- }
- goto restart;
- }
- ext2fs_inode_hash_lock = 1;
-
- /*
- * If this MALLOC() is performed after the getnewvnode()
- * it might block, leaving a vnode with a NULL v_data to be
- * found by ext2_sync() if a sync happens to fire right then,
- * which will cause a panic because ext2_sync() blindly
- * dereferences vp->v_data (as well it should).
- */
- MALLOC(ip, struct inode *, sizeof(struct inode), M_EXT2NODE, M_WAITOK);
-
- /* Allocate a new vnode/inode. */
- if ((error = getnewvnode(VT_UFS, mp, ext2_vnodeop_p, &vp)) != 0) {
- if (ext2fs_inode_hash_lock < 0)
- wakeup(&ext2fs_inode_hash_lock);
- ext2fs_inode_hash_lock = 0;
- *vpp = NULL;
- FREE(ip, M_EXT2NODE);
- return (error);
- }
- bzero((caddr_t)ip, sizeof(struct inode));
- lockinit(&ip->i_lock, PINOD, "ext2in", 0, 0);
- vp->v_data = ip;
- ip->i_vnode = vp;
- ip->i_e2fs = fs = ump->um_e2fs;
- ip->i_dev = dev;
- ip->i_number = ino;
-#if QUOTA
- for (i = 0; i < MAXQUOTAS; i++)
- ip->i_dquot[i] = NODQUOT;
-#endif
- /*
- * Put it onto its hash chain and lock it so that other requests for
- * this inode will block if they arrive while we are sleeping waiting
- * for old data structures to be purged or for the contents of the
- * disk portion of this inode to be read.
- */
- ufs_ihashins(ip);
-
- if (ext2fs_inode_hash_lock < 0)
- wakeup(&ext2fs_inode_hash_lock);
- ext2fs_inode_hash_lock = 0;
-
- /* Read in the disk contents for the inode, copy into the inode. */
-#if 0
-printf("ext2_vget(%d) dbn= %d ", ino, fsbtodb(fs, ino_to_fsba(fs, ino)));
-#endif
- if ((error = bread(ump->um_devvp, fsbtodb(fs, ino_to_fsba(fs, ino)),
- (int)fs->s_blocksize, NOCRED, &bp)) != 0) {
- /*
- * The inode does not contain anything useful, so it would
- * be misleading to leave it on its hash chain. With mode
- * still zero, it will be unlinked and returned to the free
- * list by vput().
- */
- vput(vp);
- brelse(bp);
- *vpp = NULL;
- return (error);
- }
- /* convert ext2 inode to dinode */
- ext2_ei2di((struct ext2_inode *) ((char *)bp->b_data + EXT2_INODE_SIZE *
- ino_to_fsbo(fs, ino)), &ip->i_din);
- ip->i_block_group = ino_to_cg(fs, ino);
- ip->i_next_alloc_block = 0;
- ip->i_next_alloc_goal = 0;
- ip->i_prealloc_count = 0;
- ip->i_prealloc_block = 0;
- /* now we want to make sure that block pointers for unused
- blocks are zeroed out - ext2_balloc depends on this
- although for regular files and directories only
- */
- if(S_ISDIR(ip->i_mode) || S_ISREG(ip->i_mode)) {
- used_blocks = (ip->i_size+fs->s_blocksize-1) / fs->s_blocksize;
- for(i = used_blocks; i < EXT2_NDIR_BLOCKS; i++)
- ip->i_db[i] = 0;
- }
-/*
- ext2_print_inode(ip);
-*/
- brelse(bp);
-
- /*
- * Initialize the vnode from the inode, check for aliases.
- * Note that the underlying vnode may have changed.
- */
- if ((error = ufs_vinit(mp, ext2_specop_p, ext2_fifoop_p, &vp)) != 0) {
- vput(vp);
- *vpp = NULL;
- return (error);
- }
- /*
- * Finish inode initialization now that aliasing has been resolved.
- */
- ip->i_devvp = ump->um_devvp;
- VREF(ip->i_devvp);
- /*
- * Set up a generation number for this inode if it does not
- * already have one. This should only happen on old filesystems.
- */
- if (ip->i_gen == 0) {
- ip->i_gen = random() / 2 + 1;
- if ((vp->v_mount->mnt_flag & MNT_RDONLY) == 0)
- ip->i_flag |= IN_MODIFIED;
- }
- *vpp = vp;
- return (0);
-}
-
-/*
- * File handle to vnode
- *
- * Have to be really careful about stale file handles:
- * - check that the inode number is valid
- * - call ext2_vget() to get the locked inode
- * - check for an unallocated inode (i_mode == 0)
- * - check that the given client host has export rights and return
- * those rights via. exflagsp and credanonp
- */
-static int
-ext2_fhtovp(mp, fhp, vpp)
- register struct mount *mp;
- struct fid *fhp;
- struct vnode **vpp;
-{
- register struct ufid *ufhp;
- struct ext2_sb_info *fs;
-
- ufhp = (struct ufid *)fhp;
- fs = VFSTOUFS(mp)->um_e2fs;
- if (ufhp->ufid_ino < ROOTINO ||
- ufhp->ufid_ino >= fs->s_groups_count * fs->s_es->s_inodes_per_group)
- return (ESTALE);
- return (ufs_fhtovp(mp, ufhp, vpp));
-}
-
-/*
- * Vnode pointer to File handle
- */
-/* ARGSUSED */
-static int
-ext2_vptofh(vp, fhp)
- struct vnode *vp;
- struct fid *fhp;
-{
- register struct inode *ip;
- register struct ufid *ufhp;
-
- ip = VTOI(vp);
- ufhp = (struct ufid *)fhp;
- ufhp->ufid_len = sizeof(struct ufid);
- ufhp->ufid_ino = ip->i_number;
- ufhp->ufid_gen = ip->i_gen;
- return (0);
-}
-
-/*
- * Write a superblock and associated information back to disk.
- */
-static int
-ext2_sbupdate(mp, waitfor)
- struct ufsmount *mp;
- int waitfor;
-{
- register struct ext2_sb_info *fs = mp->um_e2fs;
- register struct ext2_super_block *es = fs->s_es;
- register struct buf *bp;
- int error = 0;
-/*
-printf("\nupdating superblock, waitfor=%s\n", waitfor == MNT_WAIT ? "yes":"no");
-*/
- bp = getblk(mp->um_devvp, SBLOCK, SBSIZE, 0, 0);
- bcopy((caddr_t)es, bp->b_data, (u_int)sizeof(struct ext2_super_block));
- if (waitfor == MNT_WAIT)
- error = bwrite(bp);
- else
- bawrite(bp);
-
- /*
- * The buffers for group descriptors, inode bitmaps and block bitmaps
- * are not busy at this point and are (hopefully) written by the
- * usual sync mechanism. No need to write them here
- */
-
- return (error);
-}
diff --git a/sys/gnu/fs/ext2fs/ext2_vnops.c b/sys/gnu/fs/ext2fs/ext2_vnops.c
deleted file mode 100644
index 0e57f30af44c..000000000000
--- a/sys/gnu/fs/ext2fs/ext2_vnops.c
+++ /dev/null
@@ -1,1213 +0,0 @@
-/*
- * modified for EXT2FS support in Lites 1.1
- *
- * Aug 1995, Godmar Back (gback@cs.utah.edu)
- * University of Utah, Department of Computer Science
- */
-/*
- * Copyright (c) 1982, 1986, 1989, 1993
- * The Regents of the University of California. All rights reserved.
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)ufs_vnops.c 8.27 (Berkeley) 5/27/95
- * @(#)ext2_vnops.c 8.7 (Berkeley) 2/3/94
- * $FreeBSD$
- */
-
-#include "opt_quota.h"
-#include "opt_suiddir.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/resourcevar.h>
-#include <sys/kernel.h>
-#include <sys/stat.h>
-#include <sys/buf.h>
-#include <sys/proc.h>
-#include <sys/mount.h>
-#include <sys/time.h>
-#include <sys/vnode.h>
-#include <sys/namei.h>
-
-#include <vm/vm.h>
-#include <vm/vm_extern.h>
-#include <vm/vm_zone.h>
-#include <vm/vnode_pager.h>
-
-#include <sys/signalvar.h>
-#include <ufs/ufs/dir.h>
-#include <ufs/ufs/quota.h>
-#include <ufs/ufs/inode.h>
-#include <ufs/ufs/ufsmount.h>
-#include <ufs/ufs/ufs_extern.h>
-
-#include <gnu/ext2fs/ext2_fs_sb.h>
-#include <gnu/ext2fs/fs.h>
-#include <gnu/ext2fs/ext2_extern.h>
-#include <gnu/ext2fs/ext2_fs.h>
-
-static int ext2_makeinode __P((int mode, struct vnode *, struct vnode **, struct componentname *));
-
-static int ext2_fsync __P((struct vop_fsync_args *));
-static int ext2_read __P((struct vop_read_args *));
-static int ext2_write __P((struct vop_write_args *));
-static int ext2_remove __P((struct vop_remove_args *));
-static int ext2_link __P((struct vop_link_args *));
-static int ext2_rename __P((struct vop_rename_args *));
-static int ext2_mkdir __P((struct vop_mkdir_args *));
-static int ext2_rmdir __P((struct vop_rmdir_args *));
-static int ext2_create __P((struct vop_create_args *));
-static int ext2_mknod __P((struct vop_mknod_args *));
-static int ext2_symlink __P((struct vop_symlink_args *));
-static int ext2_getpages __P((struct vop_getpages_args *));
-static int ext2_putpages __P((struct vop_putpages_args *));
-
-/* Global vfs data structures for ufs. */
-vop_t **ext2_vnodeop_p;
-static struct vnodeopv_entry_desc ext2_vnodeop_entries[] = {
- { &vop_default_desc, (vop_t *) ufs_vnoperate },
- { &vop_cachedlookup_desc, (vop_t *) ext2_lookup },
- { &vop_fsync_desc, (vop_t *) ext2_fsync },
- { &vop_inactive_desc, (vop_t *) ext2_inactive },
- { &vop_lookup_desc, (vop_t *) vfs_cache_lookup },
- { &vop_read_desc, (vop_t *) ext2_read },
- { &vop_readdir_desc, (vop_t *) ext2_readdir },
- { &vop_reallocblks_desc, (vop_t *) ext2_reallocblks },
- { &vop_write_desc, (vop_t *) ext2_write },
- { &vop_remove_desc, (vop_t *) ext2_remove },
- { &vop_link_desc, (vop_t *) ext2_link },
- { &vop_rename_desc, (vop_t *) ext2_rename },
- { &vop_mkdir_desc, (vop_t *) ext2_mkdir },
- { &vop_rmdir_desc, (vop_t *) ext2_rmdir },
- { &vop_create_desc, (vop_t *) ext2_create },
- { &vop_mknod_desc, (vop_t *) ext2_mknod },
- { &vop_symlink_desc, (vop_t *) ext2_symlink },
- { &vop_getpages_desc, (vop_t *) ext2_getpages },
- { &vop_putpages_desc, (vop_t *) ext2_putpages },
- { NULL, NULL }
-};
-static struct vnodeopv_desc ext2fs_vnodeop_opv_desc =
- { &ext2_vnodeop_p, ext2_vnodeop_entries };
-
-vop_t **ext2_specop_p;
-static struct vnodeopv_entry_desc ext2_specop_entries[] = {
- { &vop_default_desc, (vop_t *) ufs_vnoperatespec },
- { &vop_fsync_desc, (vop_t *) ext2_fsync },
- { &vop_inactive_desc, (vop_t *) ext2_inactive },
- { NULL, NULL }
-};
-static struct vnodeopv_desc ext2fs_specop_opv_desc =
- { &ext2_specop_p, ext2_specop_entries };
-
-vop_t **ext2_fifoop_p;
-static struct vnodeopv_entry_desc ext2_fifoop_entries[] = {
- { &vop_default_desc, (vop_t *) ufs_vnoperatefifo },
- { &vop_fsync_desc, (vop_t *) ext2_fsync },
- { &vop_inactive_desc, (vop_t *) ext2_inactive },
- { NULL, NULL }
-};
-static struct vnodeopv_desc ext2fs_fifoop_opv_desc =
- { &ext2_fifoop_p, ext2_fifoop_entries };
-
- VNODEOP_SET(ext2fs_vnodeop_opv_desc);
- VNODEOP_SET(ext2fs_specop_opv_desc);
- VNODEOP_SET(ext2fs_fifoop_opv_desc);
-
-#include <gnu/ext2fs/ext2_readwrite.c>
-
-/*
- * A virgin directory (no blushing please).
- * Note that the type and namlen fields are reversed relative to ufs.
- * Also, we don't use `struct odirtemplate', since it would just cause
- * endianness problems.
- */
-static struct dirtemplate mastertemplate = {
- 0, 12, 1, EXT2_FT_DIR, ".",
- 0, DIRBLKSIZ - 12, 2, EXT2_FT_DIR, ".."
-};
-static struct dirtemplate omastertemplate = {
- 0, 12, 1, EXT2_FT_UNKNOWN, ".",
- 0, DIRBLKSIZ - 12, 2, EXT2_FT_UNKNOWN, ".."
-};
-
-/*
- * Create a regular file
- */
-static int
-ext2_create(ap)
- struct vop_create_args /* {
- struct vnode *a_dvp;
- struct vnode **a_vpp;
- struct componentname *a_cnp;
- struct vattr *a_vap;
- } */ *ap;
-{
- int error;
-
- error =
- ext2_makeinode(MAKEIMODE(ap->a_vap->va_type, ap->a_vap->va_mode),
- ap->a_dvp, ap->a_vpp, ap->a_cnp);
- if (error)
- return (error);
- return (0);
-}
-
-/*
- * Synch an open file.
- */
-/* ARGSUSED */
-static int
-ext2_fsync(ap)
- struct vop_fsync_args /* {
- struct vnode *a_vp;
- struct ucred *a_cred;
- int a_waitfor;
- struct proc *a_p;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
- register struct buf *bp;
- struct buf *nbp;
- int s;
-
- /*
- * XXX why is all this fs specific?
- */
-
- /*
- * Flush all dirty buffers associated with a vnode.
- */
- ext2_discard_prealloc(VTOI(vp));
-
-loop:
- s = splbio();
- for (bp = TAILQ_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) {
- nbp = TAILQ_NEXT(bp, b_vnbufs);
- if (BUF_LOCK(bp, LK_EXCLUSIVE | LK_NOWAIT))
- continue;
- if ((bp->b_flags & B_DELWRI) == 0)
- panic("ext2_fsync: not dirty");
- bremfree(bp);
- splx(s);
- /*
- * Wait for I/O associated with indirect blocks to complete,
- * since there is no way to quickly wait for them below.
- */
- if (bp->b_vp == vp || ap->a_waitfor == MNT_NOWAIT)
- (void) bawrite(bp);
- else
- (void) bwrite(bp);
- goto loop;
- }
- if (ap->a_waitfor == MNT_WAIT) {
- while (vp->v_numoutput) {
- vp->v_flag |= VBWAIT;
- tsleep(&vp->v_numoutput, PRIBIO + 1, "e2fsyn", 0);
- }
-#if DIAGNOSTIC
- if (!TAILQ_EMPTY(&vp->v_dirtyblkhd)) {
- vprint("ext2_fsync: dirty", vp);
- goto loop;
- }
-#endif
- }
- splx(s);
- return (UFS_UPDATE(ap->a_vp, ap->a_waitfor == MNT_WAIT));
-}
-
-/*
- * Mknod vnode call
- */
-/* ARGSUSED */
-static int
-ext2_mknod(ap)
- struct vop_mknod_args /* {
- struct vnode *a_dvp;
- struct vnode **a_vpp;
- struct componentname *a_cnp;
- struct vattr *a_vap;
- } */ *ap;
-{
- struct vattr *vap = ap->a_vap;
- struct vnode **vpp = ap->a_vpp;
- struct inode *ip;
- int error;
-
- error = ext2_makeinode(MAKEIMODE(vap->va_type, vap->va_mode),
- ap->a_dvp, vpp, ap->a_cnp);
- if (error)
- return (error);
- ip = VTOI(*vpp);
- ip->i_flag |= IN_ACCESS | IN_CHANGE | IN_UPDATE;
- if (vap->va_rdev != VNOVAL) {
- /*
- * Want to be able to use this to make badblock
- * inodes, so don't truncate the dev number.
- */
- ip->i_rdev = vap->va_rdev;
- }
- /*
- * Remove inode, then reload it through VFS_VGET so it is
- * checked to see if it is an alias of an existing entry in
- * the inode cache.
- */
- vput(*vpp);
- (*vpp)->v_type = VNON;
- vgone(*vpp);
- error = VFS_VGET(ap->a_dvp->v_mount, ip->i_ino, vpp);
- if (error) {
- *vpp = NULL;
- return (error);
- }
- return (0);
-}
-
-static int
-ext2_remove(ap)
- struct vop_remove_args /* {
- struct vnode *a_dvp;
- struct vnode *a_vp;
- struct componentname *a_cnp;
- } */ *ap;
-{
- struct inode *ip;
- struct vnode *vp = ap->a_vp;
- struct vnode *dvp = ap->a_dvp;
- int error;
-
- ip = VTOI(vp);
- if ((ip->i_flags & (NOUNLINK | IMMUTABLE | APPEND)) ||
- (VTOI(dvp)->i_flags & APPEND)) {
- error = EPERM;
- goto out;
- }
- error = ext2_dirremove(dvp, ap->a_cnp);
- if (error == 0) {
- ip->i_nlink--;
- ip->i_flag |= IN_CHANGE;
- }
-out:
- return (error);
-}
-
-/*
- * link vnode call
- */
-static int
-ext2_link(ap)
- struct vop_link_args /* {
- struct vnode *a_tdvp;
- struct vnode *a_vp;
- struct componentname *a_cnp;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
- struct vnode *tdvp = ap->a_tdvp;
- struct componentname *cnp = ap->a_cnp;
- struct proc *p = cnp->cn_proc;
- struct inode *ip;
- int error;
-
-#ifdef DIAGNOSTIC
- if ((cnp->cn_flags & HASBUF) == 0)
- panic("ufs_link: no name");
-#endif
- if (tdvp->v_mount != vp->v_mount) {
- error = EXDEV;
- goto out2;
- }
- if (tdvp != vp && (error = vn_lock(vp, LK_EXCLUSIVE, p))) {
- goto out2;
- }
- ip = VTOI(vp);
- if ((nlink_t)ip->i_nlink >= LINK_MAX) {
- error = EMLINK;
- goto out1;
- }
- if (ip->i_flags & (IMMUTABLE | APPEND)) {
- error = EPERM;
- goto out1;
- }
- ip->i_nlink++;
- ip->i_flag |= IN_CHANGE;
- error = UFS_UPDATE(vp, 1);
- if (!error)
- error = ext2_direnter(ip, tdvp, cnp);
- if (error) {
- ip->i_nlink--;
- ip->i_flag |= IN_CHANGE;
- }
-out1:
- if (tdvp != vp)
- VOP_UNLOCK(vp, 0, p);
-out2:
- return (error);
-}
-
-/*
- * Rename system call.
- * See comments in sys/ufs/ufs/ufs_vnops.c
- */
-static int
-ext2_rename(ap)
- struct vop_rename_args /* {
- struct vnode *a_fdvp;
- struct vnode *a_fvp;
- struct componentname *a_fcnp;
- struct vnode *a_tdvp;
- struct vnode *a_tvp;
- struct componentname *a_tcnp;
- } */ *ap;
-{
- struct vnode *tvp = ap->a_tvp;
- register struct vnode *tdvp = ap->a_tdvp;
- struct vnode *fvp = ap->a_fvp;
- struct vnode *fdvp = ap->a_fdvp;
- struct componentname *tcnp = ap->a_tcnp;
- struct componentname *fcnp = ap->a_fcnp;
- struct proc *p = fcnp->cn_proc;
- struct inode *ip, *xp, *dp;
- struct dirtemplate dirbuf;
- int doingdirectory = 0, oldparent = 0, newparent = 0;
- int error = 0;
- u_char namlen;
-
-#ifdef DIAGNOSTIC
- if ((tcnp->cn_flags & HASBUF) == 0 ||
- (fcnp->cn_flags & HASBUF) == 0)
- panic("ufs_rename: no name");
-#endif
- /*
- * Check for cross-device rename.
- */
- if ((fvp->v_mount != tdvp->v_mount) ||
- (tvp && (fvp->v_mount != tvp->v_mount))) {
- error = EXDEV;
-abortit:
- if (tdvp == tvp)
- vrele(tdvp);
- else
- vput(tdvp);
- if (tvp)
- vput(tvp);
- vrele(fdvp);
- vrele(fvp);
- return (error);
- }
-
- if (tvp && ((VTOI(tvp)->i_flags & (NOUNLINK | IMMUTABLE | APPEND)) ||
- (VTOI(tdvp)->i_flags & APPEND))) {
- error = EPERM;
- goto abortit;
- }
-
- /*
- * Check if just deleting a link name or if we've lost a race.
- * If another process completes the same rename after we've looked
- * up the source and have blocked looking up the target, then the
- * source and target inodes may be identical now although the
- * names were never linked.
- */
- if (fvp == tvp) {
- if (fvp->v_type == VDIR) {
- /*
- * Linked directories are impossible, so we must
- * have lost the race. Pretend that the rename
- * completed before the lookup.
- */
-#ifdef UFS_RENAME_DEBUG
- printf("ufs_rename: fvp == tvp for directories\n");
-#endif
- error = ENOENT;
- goto abortit;
- }
-
- /* Release destination completely. */
- vput(tdvp);
- vput(tvp);
-
- /*
- * Delete source. There is another race now that everything
- * is unlocked, but this doesn't cause any new complications.
- * Relookup() may find a file that is unrelated to the
- * original one, or it may fail. Too bad.
- */
- vrele(fdvp);
- vrele(fvp);
- fcnp->cn_flags &= ~MODMASK;
- fcnp->cn_flags |= LOCKPARENT | LOCKLEAF;
- fcnp->cn_nameiop = DELETE;
- VREF(fdvp);
- error = relookup(fdvp, &fvp, fcnp);
- if (error == 0)
- vrele(fdvp);
- if (fvp == NULL) {
-#ifdef UFS_RENAME_DEBUG
- printf("ufs_rename: from name disappeared\n");
-#endif
- return (ENOENT);
- }
- error = VOP_REMOVE(fdvp, fvp, fcnp);
- if (fdvp == fvp)
- vrele(fdvp);
- else
- vput(fdvp);
- if (fvp != NULLVP)
- vput(fvp);
- return (error);
- }
- if ((error = vn_lock(fvp, LK_EXCLUSIVE, p)) != 0)
- goto abortit;
- dp = VTOI(fdvp);
- ip = VTOI(fvp);
- if (ip->i_nlink >= LINK_MAX) {
- VOP_UNLOCK(fvp, 0, p);
- error = EMLINK;
- goto abortit;
- }
- if ((ip->i_flags & (NOUNLINK | IMMUTABLE | APPEND))
- || (dp->i_flags & APPEND)) {
- VOP_UNLOCK(fvp, 0, p);
- error = EPERM;
- goto abortit;
- }
- if ((ip->i_mode & IFMT) == IFDIR) {
- /*
- * Avoid ".", "..", and aliases of "." for obvious reasons.
- */
- if ((fcnp->cn_namelen == 1 && fcnp->cn_nameptr[0] == '.') ||
- dp == ip || (fcnp->cn_flags | tcnp->cn_flags) & ISDOTDOT ||
- (ip->i_flag & IN_RENAME)) {
- VOP_UNLOCK(fvp, 0, p);
- error = EINVAL;
- goto abortit;
- }
- ip->i_flag |= IN_RENAME;
- oldparent = dp->i_number;
- doingdirectory++;
- }
- vrele(fdvp);
-
- /*
- * When the target exists, both the directory
- * and target vnodes are returned locked.
- */
- dp = VTOI(tdvp);
- xp = NULL;
- if (tvp)
- xp = VTOI(tvp);
-
- /*
- * 1) Bump link count while we're moving stuff
- * around. If we crash somewhere before
- * completing our work, the link count
- * may be wrong, but correctable.
- */
- ip->i_nlink++;
- ip->i_flag |= IN_CHANGE;
- if ((error = UFS_UPDATE(fvp, 1)) != 0) {
- VOP_UNLOCK(fvp, 0, p);
- goto bad;
- }
-
- /*
- * If ".." must be changed (ie the directory gets a new
- * parent) then the source directory must not be in the
- * directory heirarchy above the target, as this would
- * orphan everything below the source directory. Also
- * the user must have write permission in the source so
- * as to be able to change "..". We must repeat the call
- * to namei, as the parent directory is unlocked by the
- * call to checkpath().
- */
- error = VOP_ACCESS(fvp, VWRITE, tcnp->cn_cred, tcnp->cn_proc);
- VOP_UNLOCK(fvp, 0, p);
- if (oldparent != dp->i_number)
- newparent = dp->i_number;
- if (doingdirectory && newparent) {
- if (error) /* write access check above */
- goto bad;
- if (xp != NULL)
- vput(tvp);
- error = ext2_checkpath(ip, dp, tcnp->cn_cred);
- if (error)
- goto out;
- VREF(tdvp);
- error = relookup(tdvp, &tvp, tcnp);
- if (error)
- goto out;
- vrele(tdvp);
- dp = VTOI(tdvp);
- xp = NULL;
- if (tvp)
- xp = VTOI(tvp);
- }
- /*
- * 2) If target doesn't exist, link the target
- * to the source and unlink the source.
- * Otherwise, rewrite the target directory
- * entry to reference the source inode and
- * expunge the original entry's existence.
- */
- if (xp == NULL) {
- if (dp->i_dev != ip->i_dev)
- panic("ufs_rename: EXDEV");
- /*
- * Account for ".." in new directory.
- * When source and destination have the same
- * parent we don't fool with the link count.
- */
- if (doingdirectory && newparent) {
- if ((nlink_t)dp->i_nlink >= LINK_MAX) {
- error = EMLINK;
- goto bad;
- }
- dp->i_nlink++;
- dp->i_flag |= IN_CHANGE;
- error = UFS_UPDATE(tdvp, 1);
- if (error)
- goto bad;
- }
- error = ext2_direnter(ip, tdvp, tcnp);
- if (error) {
- if (doingdirectory && newparent) {
- dp->i_nlink--;
- dp->i_flag |= IN_CHANGE;
- (void)UFS_UPDATE(tdvp, 1);
- }
- goto bad;
- }
- vput(tdvp);
- } else {
- if (xp->i_dev != dp->i_dev || xp->i_dev != ip->i_dev)
- panic("ufs_rename: EXDEV");
- /*
- * Short circuit rename(foo, foo).
- */
- if (xp->i_number == ip->i_number)
- panic("ufs_rename: same file");
- /*
- * If the parent directory is "sticky", then the user must
- * own the parent directory, or the destination of the rename,
- * otherwise the destination may not be changed (except by
- * root). This implements append-only directories.
- */
- if ((dp->i_mode & S_ISTXT) && tcnp->cn_cred->cr_uid != 0 &&
- tcnp->cn_cred->cr_uid != dp->i_uid &&
- xp->i_uid != tcnp->cn_cred->cr_uid) {
- error = EPERM;
- goto bad;
- }
- /*
- * Target must be empty if a directory and have no links
- * to it. Also, ensure source and target are compatible
- * (both directories, or both not directories).
- */
- if ((xp->i_mode&IFMT) == IFDIR) {
- if (! ext2_dirempty(xp, dp->i_number, tcnp->cn_cred) ||
- xp->i_nlink > 2) {
- error = ENOTEMPTY;
- goto bad;
- }
- if (!doingdirectory) {
- error = ENOTDIR;
- goto bad;
- }
- cache_purge(tdvp);
- } else if (doingdirectory) {
- error = EISDIR;
- goto bad;
- }
- error = ext2_dirrewrite(dp, ip, tcnp);
- if (error)
- goto bad;
- /*
- * If the target directory is in the same
- * directory as the source directory,
- * decrement the link count on the parent
- * of the target directory.
- */
- if (doingdirectory && !newparent) {
- dp->i_nlink--;
- dp->i_flag |= IN_CHANGE;
- }
- vput(tdvp);
- /*
- * Adjust the link count of the target to
- * reflect the dirrewrite above. If this is
- * a directory it is empty and there are
- * no links to it, so we can squash the inode and
- * any space associated with it. We disallowed
- * renaming over top of a directory with links to
- * it above, as the remaining link would point to
- * a directory without "." or ".." entries.
- */
- xp->i_nlink--;
- if (doingdirectory) {
- if (--xp->i_nlink != 0)
- panic("ufs_rename: linked directory");
- error = UFS_TRUNCATE(tvp, (off_t)0, IO_SYNC,
- tcnp->cn_cred, tcnp->cn_proc);
- }
- xp->i_flag |= IN_CHANGE;
- vput(tvp);
- xp = NULL;
- }
-
- /*
- * 3) Unlink the source.
- */
- fcnp->cn_flags &= ~MODMASK;
- fcnp->cn_flags |= LOCKPARENT | LOCKLEAF;
- VREF(fdvp);
- error = relookup(fdvp, &fvp, fcnp);
- if (error == 0)
- vrele(fdvp);
- if (fvp != NULL) {
- xp = VTOI(fvp);
- dp = VTOI(fdvp);
- } else {
- /*
- * From name has disappeared.
- */
- if (doingdirectory)
- panic("ufs_rename: lost dir entry");
- vrele(ap->a_fvp);
- return (0);
- }
- /*
- * Ensure that the directory entry still exists and has not
- * changed while the new name has been entered. If the source is
- * a file then the entry may have been unlinked or renamed. In
- * either case there is no further work to be done. If the source
- * is a directory then it cannot have been rmdir'ed; its link
- * count of three would cause a rmdir to fail with ENOTEMPTY.
- * The IN_RENAME flag ensures that it cannot be moved by another
- * rename.
- */
- if (xp != ip) {
- if (doingdirectory)
- panic("ufs_rename: lost dir entry");
- } else {
- /*
- * If the source is a directory with a
- * new parent, the link count of the old
- * parent directory must be decremented
- * and ".." set to point to the new parent.
- */
- if (doingdirectory && newparent) {
- dp->i_nlink--;
- dp->i_flag |= IN_CHANGE;
- error = vn_rdwr(UIO_READ, fvp, (caddr_t)&dirbuf,
- sizeof (struct dirtemplate), (off_t)0,
- UIO_SYSSPACE, IO_NODELOCKED,
- tcnp->cn_cred, (int *)0, (struct proc *)0);
- if (error == 0) {
- /* Like ufs little-endian: */
- namlen = dirbuf.dotdot_type;
- if (namlen != 2 ||
- dirbuf.dotdot_name[0] != '.' ||
- dirbuf.dotdot_name[1] != '.') {
- ufs_dirbad(xp, (doff_t)12,
- "rename: mangled dir");
- } else {
- dirbuf.dotdot_ino = newparent;
- (void) vn_rdwr(UIO_WRITE, fvp,
- (caddr_t)&dirbuf,
- sizeof (struct dirtemplate),
- (off_t)0, UIO_SYSSPACE,
- IO_NODELOCKED|IO_SYNC,
- tcnp->cn_cred, (int *)0,
- (struct proc *)0);
- cache_purge(fdvp);
- }
- }
- }
- error = ext2_dirremove(fdvp, fcnp);
- if (!error) {
- xp->i_nlink--;
- xp->i_flag |= IN_CHANGE;
- }
- xp->i_flag &= ~IN_RENAME;
- }
- if (dp)
- vput(fdvp);
- if (xp)
- vput(fvp);
- vrele(ap->a_fvp);
- return (error);
-
-bad:
- if (xp)
- vput(ITOV(xp));
- vput(ITOV(dp));
-out:
- if (doingdirectory)
- ip->i_flag &= ~IN_RENAME;
- if (vn_lock(fvp, LK_EXCLUSIVE, p) == 0) {
- ip->i_nlink--;
- ip->i_flag |= IN_CHANGE;
- ip->i_flag &= ~IN_RENAME;
- vput(fvp);
- } else
- vrele(fvp);
- return (error);
-}
-
-/*
- * Mkdir system call
- */
-static int
-ext2_mkdir(ap)
- struct vop_mkdir_args /* {
- struct vnode *a_dvp;
- struct vnode **a_vpp;
- struct componentname *a_cnp;
- struct vattr *a_vap;
- } */ *ap;
-{
- register struct vnode *dvp = ap->a_dvp;
- register struct vattr *vap = ap->a_vap;
- register struct componentname *cnp = ap->a_cnp;
- register struct inode *ip, *dp;
- struct vnode *tvp;
- struct dirtemplate dirtemplate, *dtp;
- int error, dmode;
-
-#ifdef DIAGNOSTIC
- if ((cnp->cn_flags & HASBUF) == 0)
- panic("ufs_mkdir: no name");
-#endif
- dp = VTOI(dvp);
- if ((nlink_t)dp->i_nlink >= LINK_MAX) {
- error = EMLINK;
- goto out;
- }
- dmode = vap->va_mode & 0777;
- dmode |= IFDIR;
- /*
- * Must simulate part of ext2_makeinode here to acquire the inode,
- * but not have it entered in the parent directory. The entry is
- * made later after writing "." and ".." entries.
- */
- error = UFS_VALLOC(dvp, dmode, cnp->cn_cred, &tvp);
- if (error)
- goto out;
- ip = VTOI(tvp);
- ip->i_gid = dp->i_gid;
-#ifdef SUIDDIR
- {
-#ifdef QUOTA
- struct ucred ucred, *ucp;
- ucp = cnp->cn_cred;
-#endif I
- /*
- * if we are hacking owners here, (only do this where told to)
- * and we are not giving it TOO root, (would subvert quotas)
- * then go ahead and give it to the other user.
- * The new directory also inherits the SUID bit.
- * If user's UID and dir UID are the same,
- * 'give it away' so that the SUID is still forced on.
- */
- if ( (dvp->v_mount->mnt_flag & MNT_SUIDDIR) &&
- (dp->i_mode & ISUID) && dp->i_uid) {
- dmode |= ISUID;
- ip->i_uid = dp->i_uid;
-#ifdef QUOTA
- if (dp->i_uid != cnp->cn_cred->cr_uid) {
- /*
- * make sure the correct user gets charged
- * for the space.
- * Make a dummy credential for the victim.
- * XXX This seems to never be accessed out of
- * our context so a stack variable is ok.
- */
- ucred.cr_ref = 1;
- ucred.cr_uid = ip->i_uid;
- ucred.cr_ngroups = 1;
- ucred.cr_groups[0] = dp->i_gid;
- ucp = &ucred;
- }
-#endif I
- } else {
- ip->i_uid = cnp->cn_cred->cr_uid;
- }
-#ifdef QUOTA
- if ((error = getinoquota(ip)) ||
- (error = chkiq(ip, 1, ucp, 0))) {
- UFS_VFREE(tvp, ip->i_number, dmode);
- vput(tvp);
- return (error);
- }
-#endif
- }
-#else
- ip->i_uid = cnp->cn_cred->cr_uid;
-#ifdef QUOTA
- if ((error = getinoquota(ip)) ||
- (error = chkiq(ip, 1, cnp->cn_cred, 0))) {
- UFS_VFREE(tvp, ip->i_number, dmode);
- vput(tvp);
- return (error);
- }
-#endif
-#endif
- ip->i_flag |= IN_ACCESS | IN_CHANGE | IN_UPDATE;
- ip->i_mode = dmode;
- tvp->v_type = VDIR; /* Rest init'd in getnewvnode(). */
- ip->i_nlink = 2;
- if (cnp->cn_flags & ISWHITEOUT)
- ip->i_flags |= UF_OPAQUE;
- error = UFS_UPDATE(tvp, 1);
-
- /*
- * Bump link count in parent directory
- * to reflect work done below. Should
- * be done before reference is created
- * so reparation is possible if we crash.
- */
- dp->i_nlink++;
- dp->i_flag |= IN_CHANGE;
- error = UFS_UPDATE(dvp, 1);
- if (error)
- goto bad;
-
- /* Initialize directory with "." and ".." from static template. */
- if (EXT2_HAS_INCOMPAT_FEATURE(ip->i_e2fs->s_es,
- EXT2_FEATURE_INCOMPAT_FILETYPE))
- dtp = &mastertemplate;
- else
- dtp = &omastertemplate;
- dirtemplate = *dtp;
- dirtemplate.dot_ino = ip->i_number;
- dirtemplate.dotdot_ino = dp->i_number;
- /* note that in ext2 DIRBLKSIZ == blocksize, not DEV_BSIZE
- * so let's just redefine it - for this function only
- */
-#undef DIRBLKSIZ
-#define DIRBLKSIZ VTOI(dvp)->i_e2fs->s_blocksize
- dirtemplate.dotdot_reclen = DIRBLKSIZ - 12;
- error = vn_rdwr(UIO_WRITE, tvp, (caddr_t)&dirtemplate,
- sizeof (dirtemplate), (off_t)0, UIO_SYSSPACE,
- IO_NODELOCKED|IO_SYNC, cnp->cn_cred, (int *)0, (struct proc *)0);
- if (error) {
- dp->i_nlink--;
- dp->i_flag |= IN_CHANGE;
- goto bad;
- }
- if (DIRBLKSIZ > VFSTOUFS(dvp->v_mount)->um_mountp->mnt_stat.f_bsize)
- panic("ufs_mkdir: blksize"); /* XXX should grow with balloc() */
- else {
- ip->i_size = DIRBLKSIZ;
- ip->i_flag |= IN_CHANGE;
- }
-
- /* Directory set up, now install its entry in the parent directory. */
- error = ext2_direnter(ip, dvp, cnp);
- if (error) {
- dp->i_nlink--;
- dp->i_flag |= IN_CHANGE;
- }
-bad:
- /*
- * No need to do an explicit VOP_TRUNCATE here, vrele will do this
- * for us because we set the link count to 0.
- */
- if (error) {
- ip->i_nlink = 0;
- ip->i_flag |= IN_CHANGE;
- vput(tvp);
- } else
- *ap->a_vpp = tvp;
-out:
- return (error);
-#undef DIRBLKSIZ
-#define DIRBLKSIZ DEV_BSIZE
-}
-
-/*
- * Rmdir system call.
- */
-static int
-ext2_rmdir(ap)
- struct vop_rmdir_args /* {
- struct vnode *a_dvp;
- struct vnode *a_vp;
- struct componentname *a_cnp;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
- struct vnode *dvp = ap->a_dvp;
- struct componentname *cnp = ap->a_cnp;
- struct proc *p = cnp->cn_proc;
- struct inode *ip, *dp;
- int error;
-
- ip = VTOI(vp);
- dp = VTOI(dvp);
-
- /*
- * Verify the directory is empty (and valid).
- * (Rmdir ".." won't be valid since
- * ".." will contain a reference to
- * the current directory and thus be
- * non-empty.)
- */
- error = 0;
- if (ip->i_nlink != 2 || !ext2_dirempty(ip, dp->i_number, cnp->cn_cred)) {
- error = ENOTEMPTY;
- goto out;
- }
- if ((dp->i_flags & APPEND)
- || (ip->i_flags & (NOUNLINK | IMMUTABLE | APPEND))) {
- error = EPERM;
- goto out;
- }
- /*
- * Delete reference to directory before purging
- * inode. If we crash in between, the directory
- * will be reattached to lost+found,
- */
- error = ext2_dirremove(dvp, cnp);
- if (error)
- goto out;
- dp->i_nlink--;
- dp->i_flag |= IN_CHANGE;
- cache_purge(dvp);
- VOP_UNLOCK(dvp, 0, p);
- /*
- * Truncate inode. The only stuff left
- * in the directory is "." and "..". The
- * "." reference is inconsequential since
- * we're quashing it. The ".." reference
- * has already been adjusted above. We've
- * removed the "." reference and the reference
- * in the parent directory, but there may be
- * other hard links so decrement by 2 and
- * worry about them later.
- */
- ip->i_nlink -= 2;
- error = UFS_TRUNCATE(vp, (off_t)0, IO_SYNC, cnp->cn_cred, p);
- cache_purge(ITOV(ip));
- vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, p);
-out:
- return (error);
-}
-
-/*
- * symlink -- make a symbolic link
- */
-static int
-ext2_symlink(ap)
- struct vop_symlink_args /* {
- struct vnode *a_dvp;
- struct vnode **a_vpp;
- struct componentname *a_cnp;
- struct vattr *a_vap;
- char *a_target;
- } */ *ap;
-{
- register struct vnode *vp, **vpp = ap->a_vpp;
- register struct inode *ip;
- int len, error;
-
- error = ext2_makeinode(IFLNK | ap->a_vap->va_mode, ap->a_dvp,
- vpp, ap->a_cnp);
- if (error)
- return (error);
- vp = *vpp;
- len = strlen(ap->a_target);
- if (len < vp->v_mount->mnt_maxsymlinklen) {
- ip = VTOI(vp);
- bcopy(ap->a_target, (char *)ip->i_shortlink, len);
- ip->i_size = len;
- ip->i_flag |= IN_CHANGE | IN_UPDATE;
- } else
- error = vn_rdwr(UIO_WRITE, vp, ap->a_target, len, (off_t)0,
- UIO_SYSSPACE, IO_NODELOCKED, ap->a_cnp->cn_cred, (int *)0,
- (struct proc *)0);
- if (error)
- vput(vp);
- return (error);
-}
-
-/*
- * Allocate a new inode.
- */
-static int
-ext2_makeinode(mode, dvp, vpp, cnp)
- int mode;
- struct vnode *dvp;
- struct vnode **vpp;
- struct componentname *cnp;
-{
- register struct inode *ip, *pdir;
- struct vnode *tvp;
- int error;
-
- pdir = VTOI(dvp);
-#ifdef DIAGNOSTIC
- if ((cnp->cn_flags & HASBUF) == 0)
- panic("ext2_makeinode: no name");
-#endif
- *vpp = NULL;
- if ((mode & IFMT) == 0)
- mode |= IFREG;
-
- error = UFS_VALLOC(dvp, mode, cnp->cn_cred, &tvp);
- if (error) {
- return (error);
- }
- ip = VTOI(tvp);
- ip->i_gid = pdir->i_gid;
-#ifdef SUIDDIR
- {
-#ifdef QUOTA
- struct ucred ucred, *ucp;
- ucp = cnp->cn_cred;
-#endif I
- /*
- * if we are
- * not the owner of the directory,
- * and we are hacking owners here, (only do this where told to)
- * and we are not giving it TOO root, (would subvert quotas)
- * then go ahead and give it to the other user.
- * Note that this drops off the execute bits for security.
- */
- if ( (dvp->v_mount->mnt_flag & MNT_SUIDDIR) &&
- (pdir->i_mode & ISUID) &&
- (pdir->i_uid != cnp->cn_cred->cr_uid) && pdir->i_uid) {
- ip->i_uid = pdir->i_uid;
- mode &= ~07111;
-#ifdef QUOTA
- /*
- * make sure the correct user gets charged
- * for the space.
- * Quickly knock up a dummy credential for the victim.
- * XXX This seems to never be accessed out of our
- * context so a stack variable is ok.
- */
- ucred.cr_ref = 1;
- ucred.cr_uid = ip->i_uid;
- ucred.cr_ngroups = 1;
- ucred.cr_groups[0] = pdir->i_gid;
- ucp = &ucred;
-#endif I
- } else {
- ip->i_uid = cnp->cn_cred->cr_uid;
- }
-
-#ifdef QUOTA
- if ((error = getinoquota(ip)) ||
- (error = chkiq(ip, 1, ucp, 0))) {
- UFS_VFREE(tvp, ip->i_number, mode);
- vput(tvp);
- return (error);
- }
-#endif
- }
-#else
- ip->i_uid = cnp->cn_cred->cr_uid;
-#ifdef QUOTA
- if ((error = getinoquota(ip)) ||
- (error = chkiq(ip, 1, cnp->cn_cred, 0))) {
- UFS_VFREE(tvp, ip->i_number, mode);
- vput(tvp);
- return (error);
- }
-#endif
-#endif
- ip->i_flag |= IN_ACCESS | IN_CHANGE | IN_UPDATE;
- ip->i_mode = mode;
- tvp->v_type = IFTOVT(mode); /* Rest init'd in getnewvnode(). */
- ip->i_nlink = 1;
- if ((ip->i_mode & ISGID) && !groupmember(ip->i_gid, cnp->cn_cred) &&
- suser_xxx(cnp->cn_cred, 0, PRISON_ROOT))
- ip->i_mode &= ~ISGID;
-
- if (cnp->cn_flags & ISWHITEOUT)
- ip->i_flags |= UF_OPAQUE;
-
- /*
- * Make sure inode goes to disk before directory entry.
- */
- error = UFS_UPDATE(tvp, 1);
- if (error)
- goto bad;
- error = ext2_direnter(ip, dvp, cnp);
- if (error)
- goto bad;
-
- *vpp = tvp;
- return (0);
-
-bad:
- /*
- * Write error occurred trying to update the inode
- * or the directory so must deallocate the inode.
- */
- ip->i_nlink = 0;
- ip->i_flag |= IN_CHANGE;
- vput(tvp);
- return (error);
-}
-
-/*
- * get page routine
- *
- * XXX By default, wimp out... note that a_offset is ignored (and always
- * XXX has been).
- */
-static int
-ext2_getpages(ap)
- struct vop_getpages_args *ap;
-{
- return (vnode_pager_generic_getpages(ap->a_vp, ap->a_m, ap->a_count,
- ap->a_reqpage));
-}
-
-/*
- * put page routine
- *
- * XXX By default, wimp out... note that a_offset is ignored (and always
- * XXX has been).
- */
-static int
-ext2_putpages(ap)
- struct vop_putpages_args *ap;
-{
- return (vnode_pager_generic_putpages(ap->a_vp, ap->a_m, ap->a_count,
- ap->a_sync, ap->a_rtvals));
-}
diff --git a/sys/gnu/fs/ext2fs/fs.h b/sys/gnu/fs/ext2fs/fs.h
deleted file mode 100644
index b8dab54606ae..000000000000
--- a/sys/gnu/fs/ext2fs/fs.h
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * modified for EXT2FS support in Lites 1.1
- *
- * Aug 1995, Godmar Back (gback@cs.utah.edu)
- * University of Utah, Department of Computer Science
- */
-/*
- * 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)fs.h 8.7 (Berkeley) 4/19/94
- */
-
-/*
- * Each disk drive contains some number of file systems.
- * A file system consists of a number of cylinder groups.
- * Each cylinder group has inodes and data.
- *
- * A file system is described by its super-block, which in turn
- * describes the cylinder groups. The super-block is critical
- * data and is replicated in each cylinder group to protect against
- * catastrophic loss. This is done at `newfs' time and the critical
- * super-block data does not change, so the copies need not be
- * referenced further unless disaster strikes.
- *
- * The first boot and super blocks are given in absolute disk addresses.
- * The byte-offset forms are preferred, as they don't imply a sector size.
- */
-#define BBSIZE 1024
-#define SBSIZE 1024
-#define BBOFF ((off_t)(0))
-#define SBOFF ((off_t)(BBOFF + BBSIZE))
-#define BBLOCK ((daddr_t)(0))
-#define SBLOCK ((daddr_t)(BBLOCK + BBSIZE / DEV_BSIZE))
-
-/*
- * The path name on which the file system is mounted is maintained
- * in fs_fsmnt. MAXMNTLEN defines the amount of space allocated in
- * the super block for this name.
- */
-#define MAXMNTLEN 512
-
-/*
- * Macros for access to superblock array structures
- */
-
-/*
- * Convert cylinder group to base address of its global summary info.
- */
-#define fs_cs(fs, cgindx) (((struct ext2_group_desc *) \
- (fs->s_group_desc[cgindx / EXT2_DESC_PER_BLOCK(fs)]->b_data)) \
- [cgindx % EXT2_DESC_PER_BLOCK(fs)])
-
-/*
- * Turn file system block numbers into disk block addresses.
- * This maps file system blocks to device size blocks.
- */
-#define fsbtodb(fs, b) ((b) << ((fs)->s_fsbtodb))
-#define dbtofsb(fs, b) ((b) >> ((fs)->s_fsbtodb))
-
-/* get group containing inode */
-#define ino_to_cg(fs, x) (((x) - 1) / EXT2_INODES_PER_GROUP(fs))
-
-/* get block containing inode from its number x */
-#define ino_to_fsba(fs, x) fs_cs(fs, ino_to_cg(fs, x)).bg_inode_table + \
- (((x)-1) % EXT2_INODES_PER_GROUP(fs))/EXT2_INODES_PER_BLOCK(fs)
-
-/* get offset for inode in block */
-#define ino_to_fsbo(fs, x) ((x-1) % EXT2_INODES_PER_BLOCK(fs))
-
-/*
- * Give cylinder group number for a file system block.
- * Give cylinder group block number for a file system block.
- */
-#define dtog(fs, d) (((d) - fs->s_es->s_first_data_block) / \
- EXT2_BLOCKS_PER_GROUP(fs))
-#define dtogd(fs, d) (((d) - fs->s_es->s_first_data_block) % \
- EXT2_BLOCKS_PER_GROUP(fs))
-
-/*
- * The following macros optimize certain frequently calculated
- * quantities by using shifts and masks in place of divisions
- * modulos and multiplications.
- */
-#define blkoff(fs, loc) /* calculates (loc % fs->fs_bsize) */ \
- ((loc) & (fs)->s_qbmask)
-
-#define lblktosize(fs, blk) /* calculates (blk * fs->fs_bsize) */ \
- ((blk) << (fs->s_bshift))
-
-#define lblkno(fs, loc) /* calculates (loc / fs->fs_bsize) */ \
- ((loc) >> (fs->s_bshift))
-
-/* no fragments -> logical block number equal # of frags */
-#define numfrags(fs, loc) /* calculates (loc / fs->fs_fsize) */ \
- ((loc) >> (fs->s_bshift))
-
-#define fragroundup(fs, size) /* calculates roundup(size, fs->fs_fsize) */ \
- roundup(size, fs->s_frag_size)
- /* was (((size) + (fs)->fs_qfmask) & (fs)->fs_fmask) */
-
-/*
- * Determining the size of a file block in the file system.
- * easy w/o fragments
- */
-#define blksize(fs, ip, lbn) ((fs)->s_frag_size)
-
-/*
- * INOPB is the number of inodes in a secondary storage block.
- */
-#define INOPB(fs) EXT2_INODES_PER_BLOCK(fs)
-
-/*
- * NINDIR is the number of indirects in a file system block.
- */
-#define NINDIR(fs) (EXT2_ADDR_PER_BLOCK(fs))
-
-extern int inside[], around[];
-extern u_char *fragtbl[];
-
-/* a few remarks about superblock locking/unlocking
- * Linux provides special routines for doing so
- * I haven't figured out yet what BSD does
- * I think I'll try a VOP_LOCK/VOP_UNLOCK on the device vnode
- */
-#define DEVVP(inode) (VFSTOUFS(ITOV(inode)->v_mount)->um_devvp)
-#define lock_super(devvp) vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, curproc)
-#define unlock_super(devvp) VOP_UNLOCK(devvp, 0, curproc)
-
-/*
- * To lock a buffer, set the B_LOCKED flag and then brelse() it. To unlock,
- * reset the B_LOCKED flag and brelse() the buffer back on the LRU list
- */
-#define LCK_BUF(bp) { \
- int s; \
- s = splbio(); \
- (bp)->b_flags |= B_LOCKED; \
- splx(s); \
- brelse(bp); \
-}
-
-#define ULCK_BUF(bp) { \
- long flags; \
- int s; \
- s = splbio(); \
- flags = (bp)->b_flags; \
- (bp)->b_flags &= ~(B_DIRTY | B_LOCKED); \
- BUF_LOCK(bp, LK_EXCLUSIVE); \
- bremfree(bp); \
- splx(s); \
- if (flags & B_DIRTY) \
- bdwrite(bp); \
- else \
- brelse(bp); \
-}
diff --git a/sys/gnu/fs/ext2fs/i386-bitops.h b/sys/gnu/fs/ext2fs/i386-bitops.h
deleted file mode 100644
index 595e870526b3..000000000000
--- a/sys/gnu/fs/ext2fs/i386-bitops.h
+++ /dev/null
@@ -1,162 +0,0 @@
-/* $FreeBSD$ */
-/*
- * this is mixture of i386/bitops.h and asm/string.h
- * taken from the Linux source tree
- *
- * XXX replace with Mach routines or reprogram in C
- */
-#ifndef _SYS_GNU_EXT2FS_I386_BITOPS_H_
-#define _SYS_GNU_EXT2FS_I386_BITOPS_H_
-
-/*
- * Copyright 1992, Linus Torvalds.
- */
-
-/*
- * These have to be done with inline assembly: that way the bit-setting
- * is guaranteed to be atomic. All bit operations return 0 if the bit
- * was cleared before the operation and != 0 if it was not.
- *
- * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
- */
-
-/*
- * Some hacks to defeat gcc over-optimizations..
- */
-struct __dummy { unsigned long a[100]; };
-#define ADDR (*(struct __dummy *) addr)
-
-static __inline__ int set_bit(int nr, void * addr)
-{
- int oldbit;
-
- __asm__ __volatile__("btsl %2,%1\n\tsbbl %0,%0"
- :"=r" (oldbit),"=m" (ADDR)
- :"ir" (nr));
- return oldbit;
-}
-
-static __inline__ int clear_bit(int nr, void * addr)
-{
- int oldbit;
-
- __asm__ __volatile__("btrl %2,%1\n\tsbbl %0,%0"
- :"=r" (oldbit),"=m" (ADDR)
- :"ir" (nr));
- return oldbit;
-}
-
-static __inline__ int change_bit(int nr, void * addr)
-{
- int oldbit;
-
- __asm__ __volatile__("btcl %2,%1\n\tsbbl %0,%0"
- :"=r" (oldbit),"=m" (ADDR)
- :"ir" (nr));
- return oldbit;
-}
-
-/*
- * This routine doesn't need to be atomic, but it's faster to code it
- * this way.
- */
-static __inline__ int test_bit(int nr, void * addr)
-{
- int oldbit;
-
- __asm__ __volatile__("btl %2,%1\n\tsbbl %0,%0"
- :"=r" (oldbit)
- :"m" (ADDR),"ir" (nr));
- return oldbit;
-}
-
-/*
- * Find-bit routines..
- */
-static __inline__ int find_first_zero_bit(void * addr, unsigned size)
-{
- int res;
- int _count = (size + 31) >> 5;
-
- if (!size)
- return 0;
- __asm__(" \n\
- cld \n\
- movl $-1,%%eax \n\
- xorl %%edx,%%edx \n\
- repe; scasl \n\
- je 1f \n\
- xorl -4(%%edi),%%eax \n\
- subl $4,%%edi \n\
- bsfl %%eax,%%edx \n\
-1: subl %%ebx,%%edi \n\
- shll $3,%%edi \n\
- addl %%edi,%%edx"
- : "=c" (_count), "=D" (addr), "=d" (res)
- : "0" (_count), "1" (addr), "b" (addr)
- : "ax");
- return res;
-}
-
-static __inline__ int find_next_zero_bit (void * addr, int size, int offset)
-{
- unsigned long * p = ((unsigned long *) addr) + (offset >> 5);
- int set = 0, bit = offset & 31, res;
-
- if (bit) {
- /*
- * Look for zero in first byte
- */
- __asm__(" \n\
- bsfl %1,%0 \n\
- jne 1f \n\
- movl $32, %0 \n\
-1: "
- : "=r" (set)
- : "r" (~(*p >> bit)));
- if (set < (32 - bit))
- return set + offset;
- set = 32 - bit;
- p++;
- }
- /*
- * No zero yet, search remaining full bytes for a zero
- */
- res = find_first_zero_bit (p, size - 32 * (p - (unsigned long *) addr));
- return (offset + set + res);
-}
-
-/*
- * ffz = Find First Zero in word. Undefined if no zero exists,
- * so code should check against ~0UL first..
- */
-static __inline__ unsigned long ffz(unsigned long word)
-{
- __asm__("bsfl %1,%0"
- :"=r" (word)
- :"r" (~word));
- return word;
-}
-
-/*
- * memscan() taken from linux asm/string.h
- */
-/*
- * find the first occurrence of byte 'c', or 1 past the area if none
- */
-static __inline__ char * memscan(void * addr, unsigned char c, int size)
-{
- if (!size)
- return addr;
- __asm__(" \n\
- cld \n\
- repnz; scasb \n\
- jnz 1f \n\
- dec %%edi \n\
-1: "
- : "=D" (addr), "=c" (size)
- : "0" (addr), "1" (size), "a" (c));
- return addr;
-}
-
-#endif /* !_SYS_GNU_EXT2FS_I386_BITOPS_H_ */
diff --git a/sys/gnu/fs/ext2fs/inode.h b/sys/gnu/fs/ext2fs/inode.h
deleted file mode 100644
index 83960b0d20f3..000000000000
--- a/sys/gnu/fs/ext2fs/inode.h
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright (c) 1982, 1989, 1993
- * The Regents of the University of California. All rights reserved.
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)inode.h 8.9 (Berkeley) 5/14/95
- * $FreeBSD$
- */
-
-#ifndef _UFS_UFS_INODE_H_
-#define _UFS_UFS_INODE_H_
-
-#include <sys/lock.h>
-#include <sys/queue.h>
-#include <ufs/ufs/dinode.h>
-
-/*
- * The size of a logical block number.
- */
-typedef long ufs_lbn_t;
-
-/*
- * This must agree with the definition in <ufs/ufs/dir.h>.
- */
-#define doff_t int32_t
-
-/*
- * The inode is used to describe each active (or recently active) file in the
- * UFS filesystem. It is composed of two types of information. The first part
- * is the information that is needed only while the file is active (such as
- * the identity of the file and linkage to speed its lookup). The second part
- * is the permanent meta-data associated with the file which is read in
- * from the permanent dinode from long term storage when the file becomes
- * active, and is put back when the file is no longer being used.
- */
-struct inode {
- struct lock i_lock; /* Inode lock. >Keep this first< */
- LIST_ENTRY(inode) i_hash;/* Hash chain. */
- struct vnode *i_vnode;/* Vnode associated with this inode. */
- struct vnode *i_devvp;/* Vnode for block I/O. */
- u_int32_t i_flag; /* flags, see below */
- dev_t i_dev; /* Device associated with the inode. */
- ino_t i_number; /* The identity of the inode. */
- int i_effnlink; /* i_nlink when I/O completes */
-
- union { /* Associated filesystem. */
- struct fs *fs; /* FFS */
- struct ext2_sb_info *e2fs; /* EXT2FS */
- } inode_u;
-#define i_fs inode_u.fs
-#define i_e2fs inode_u.e2fs
- struct dquot *i_dquot[MAXQUOTAS]; /* Dquot structures. */
- u_quad_t i_modrev; /* Revision level for NFS lease. */
- struct lockf *i_lockf;/* Head of byte-level lock list. */
- /*
- * Side effects; used during directory lookup.
- */
- int32_t i_count; /* Size of free slot in directory. */
- doff_t i_endoff; /* End of useful stuff in directory. */
- doff_t i_diroff; /* Offset in dir, where we found last entry. */
- doff_t i_offset; /* Offset of free space in directory. */
- ino_t i_ino; /* Inode number of found directory. */
- u_int32_t i_reclen; /* Size of found directory entry. */
- u_int32_t i_spare[4]; /* XXX actually non-spare (for ext2fs). */
- /*
- * The on-disk dinode itself.
- */
- struct dinode i_din; /* 128 bytes of the on-disk dinode. */
-};
-
-#define i_atime i_din.di_atime
-#define i_atimensec i_din.di_atimensec
-#define i_blocks i_din.di_blocks
-#define i_ctime i_din.di_ctime
-#define i_ctimensec i_din.di_ctimensec
-#define i_db i_din.di_db
-#define i_flags i_din.di_flags
-#define i_gen i_din.di_gen
-#define i_gid i_din.di_gid
-#define i_ib i_din.di_ib
-#define i_mode i_din.di_mode
-#define i_mtime i_din.di_mtime
-#define i_mtimensec i_din.di_mtimensec
-#define i_nlink i_din.di_nlink
-#define i_rdev i_din.di_rdev
-#define i_shortlink i_din.di_shortlink
-#define i_size i_din.di_size
-#define i_uid i_din.di_uid
-
-/* These flags are kept in i_flag. */
-#define IN_ACCESS 0x0001 /* Access time update request. */
-#define IN_CHANGE 0x0002 /* Inode change time update request. */
-#define IN_UPDATE 0x0004 /* Modification time update request. */
-#define IN_MODIFIED 0x0008 /* Inode has been modified. */
-#define IN_RENAME 0x0010 /* Inode is being renamed. */
-#define IN_SHLOCK 0x0020 /* File has shared lock. */
-#define IN_EXLOCK 0x0040 /* File has exclusive lock. */
-#define IN_HASHED 0x0080 /* Inode is on hash list */
-#define IN_LAZYMOD 0x0100 /* Modified, but don't write yet. */
-
-#ifdef _KERNEL
-/*
- * Structure used to pass around logical block paths generated by
- * ufs_getlbns and used by truncate and bmap code.
- */
-struct indir {
- ufs_daddr_t in_lbn; /* Logical block number. */
- int in_off; /* Offset in buffer. */
- int in_exists; /* Flag if the block exists. */
-};
-
-/* Convert between inode pointers and vnode pointers. */
-#define VTOI(vp) ((struct inode *)(vp)->v_data)
-#define ITOV(ip) ((ip)->i_vnode)
-
-/* Determine if soft dependencies are being done */
-#define DOINGSOFTDEP(vp) ((vp)->v_mount->mnt_flag & MNT_SOFTDEP)
-#define DOINGASYNC(vp) ((vp)->v_mount->mnt_flag & MNT_ASYNC)
-
-/* This overlays the fid structure (see mount.h). */
-struct ufid {
- u_int16_t ufid_len; /* Length of structure. */
- u_int16_t ufid_pad; /* Force 32-bit alignment. */
- ino_t ufid_ino; /* File number (ino). */
- int32_t ufid_gen; /* Generation number. */
-};
-#endif /* _KERNEL */
-
-#endif /* !_UFS_UFS_INODE_H_ */
diff --git a/sys/i386/bios/apm.c b/sys/i386/bios/apm.c
deleted file mode 100644
index 4eb99dd2804e..000000000000
--- a/sys/i386/bios/apm.c
+++ /dev/null
@@ -1,1358 +0,0 @@
-/*
- * APM (Advanced Power Management) BIOS Device Driver
- *
- * Copyright (c) 1994 UKAI, Fumitoshi.
- * Copyright (c) 1994-1995 by HOSOKAWA, Tatsumi <hosokawa@jp.FreeBSD.org>
- * Copyright (c) 1996 Nate Williams <nate@FreeBSD.org>
- * Copyright (c) 1997 Poul-Henning Kamp <phk@FreeBSD.org>
- *
- * This software may be used, modified, copied, and distributed, in
- * both source and binary form provided that the above copyright and
- * these terms are retained. Under no circumstances is the author
- * responsible for the proper functioning of this software, nor does
- * the author assume any responsibility for damages incurred with its
- * use.
- *
- * Sep, 1994 Implemented on FreeBSD 1.1.5.1R (Toshiba AVS001WD)
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/eventhandler.h>
-#include <sys/conf.h>
-#include <sys/kernel.h>
-#include <sys/time.h>
-#include <sys/reboot.h>
-#include <sys/bus.h>
-#include <sys/select.h>
-#include <sys/poll.h>
-#include <sys/fcntl.h>
-#include <sys/proc.h>
-#include <sys/uio.h>
-#include <sys/signalvar.h>
-#include <sys/sysctl.h>
-#include <machine/apm_bios.h>
-#include <machine/segments.h>
-#include <machine/clock.h>
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <vm/pmap.h>
-#include <sys/syslog.h>
-
-#include <machine/pc/bios.h>
-#include <machine/vm86.h>
-
-#include <i386/apm/apm.h>
-
-/* Used by the apm_saver screen saver module */
-int apm_display __P((int newstate));
-struct apm_softc apm_softc;
-
-static void apm_resume __P((void));
-static int apm_bioscall(void);
-static int apm_check_function_supported __P((u_int version, u_int func));
-
-static u_long apm_version;
-
-int apm_evindex;
-
-#define SCFLAG_ONORMAL 0x0000001
-#define SCFLAG_OCTL 0x0000002
-#define SCFLAG_OPEN (SCFLAG_ONORMAL|SCFLAG_OCTL)
-
-#define APMDEV(dev) (minor(dev)&0x0f)
-#define APMDEV_NORMAL 0
-#define APMDEV_CTL 8
-
-static struct apmhook *hook[NAPM_HOOK]; /* XXX */
-
-#define is_enabled(foo) ((foo) ? "enabled" : "disabled")
-
-/* Map version number to integer (keeps ordering of version numbers) */
-#define INTVERSION(major, minor) ((major)*100 + (minor))
-
-static struct callout_handle apm_timeout_ch =
- CALLOUT_HANDLE_INITIALIZER(&apm_timeout_ch);
-
-static timeout_t apm_timeout;
-static d_open_t apmopen;
-static d_close_t apmclose;
-static d_write_t apmwrite;
-static d_ioctl_t apmioctl;
-static d_poll_t apmpoll;
-
-#define CDEV_MAJOR 39
-static struct cdevsw apm_cdevsw = {
- /* open */ apmopen,
- /* close */ apmclose,
- /* read */ noread,
- /* write */ apmwrite,
- /* ioctl */ apmioctl,
- /* poll */ apmpoll,
- /* mmap */ nommap,
- /* strategy */ nostrategy,
- /* name */ "apm",
- /* maj */ CDEV_MAJOR,
- /* dump */ nodump,
- /* psize */ nopsize,
- /* flags */ 0,
- /* bmaj */ -1
-};
-
-static int apm_suspend_delay = 1;
-static int apm_standby_delay = 1;
-
-SYSCTL_INT(_machdep, OID_AUTO, apm_suspend_delay, CTLFLAG_RW, &apm_suspend_delay, 1, "");
-SYSCTL_INT(_machdep, OID_AUTO, apm_standby_delay, CTLFLAG_RW, &apm_standby_delay, 1, "");
-
-/*
- * return 0 if the function successfull,
- * return 1 if the function unsuccessfull,
- * return -1 if the function unsupported.
- */
-static int
-apm_bioscall(void)
-{
- struct apm_softc *sc = &apm_softc;
- int errno = 0;
- u_int apm_func = sc->bios.r.eax & 0xff;
-
- if (!apm_check_function_supported(sc->intversion, apm_func)) {
-#ifdef APM_DEBUG
- printf("apm_bioscall: function 0x%x is not supported in v%d.%d\n",
- apm_func, sc->majorversion, sc->minorversion);
-#endif
- return (-1);
- }
-
- sc->bios_busy = 1;
- if (sc->connectmode == APM_PROT32CONNECT) {
- set_bios_selectors(&sc->bios.seg,
- BIOSCODE_FLAG | BIOSDATA_FLAG);
- errno = bios32(&sc->bios.r,
- sc->bios.entry, GSEL(GBIOSCODE32_SEL, SEL_KPL));
- } else {
- errno = bios16(&sc->bios, NULL);
- }
- sc->bios_busy = 0;
- return (errno);
-}
-
-/* check whether APM function is supported (1) or not (0). */
-static int
-apm_check_function_supported(u_int version, u_int func)
-{
- /* except driver version */
- if (func == APM_DRVVERSION) {
- return (1);
- }
-
- switch (version) {
- case INTVERSION(1, 0):
- if (func > APM_GETPMEVENT) {
- return (0); /* not supported */
- }
- break;
- case INTVERSION(1, 1):
- if (func > APM_ENGAGEDISENGAGEPM &&
- func < APM_OEMFUNC) {
- return (0); /* not supported */
- }
- break;
- case INTVERSION(1, 2):
- break;
- }
-
- return (1); /* supported */
-}
-
-/* enable/disable power management */
-static int
-apm_enable_disable_pm(int enable)
-{
- struct apm_softc *sc = &apm_softc;
-
- sc->bios.r.eax = (APM_BIOS << 8) | APM_ENABLEDISABLEPM;
-
- if (sc->intversion >= INTVERSION(1, 1))
- sc->bios.r.ebx = PMDV_ALLDEV;
- else
- sc->bios.r.ebx = 0xffff; /* APM version 1.0 only */
- sc->bios.r.ecx = enable;
- sc->bios.r.edx = 0;
- return (apm_bioscall());
-}
-
-/* register driver version (APM 1.1 or later) */
-static int
-apm_driver_version(int version)
-{
- struct apm_softc *sc = &apm_softc;
-
- sc->bios.r.eax = (APM_BIOS << 8) | APM_DRVVERSION;
- sc->bios.r.ebx = 0x0;
- sc->bios.r.ecx = version;
- sc->bios.r.edx = 0;
-
- if (apm_bioscall() == 0 && sc->bios.r.eax == version)
- return (0);
-
- /* Some old BIOSes don't return the connection version in %ax. */
- if (sc->bios.r.eax == ((APM_BIOS << 8) | APM_DRVVERSION))
- return (0);
-
- return (1);
-}
-
-/* engage/disengage power management (APM 1.1 or later) */
-static int
-apm_engage_disengage_pm(int engage)
-{
- struct apm_softc *sc = &apm_softc;
-
- sc->bios.r.eax = (APM_BIOS << 8) | APM_ENGAGEDISENGAGEPM;
- sc->bios.r.ebx = PMDV_ALLDEV;
- sc->bios.r.ecx = engage;
- sc->bios.r.edx = 0;
- return (apm_bioscall());
-}
-
-/* get PM event */
-static u_int
-apm_getevent(void)
-{
- struct apm_softc *sc = &apm_softc;
-
- sc->bios.r.eax = (APM_BIOS << 8) | APM_GETPMEVENT;
-
- sc->bios.r.ebx = 0;
- sc->bios.r.ecx = 0;
- sc->bios.r.edx = 0;
- if (apm_bioscall())
- return (PMEV_NOEVENT);
- return (sc->bios.r.ebx & 0xffff);
-}
-
-/* suspend entire system */
-static int
-apm_suspend_system(int state)
-{
- struct apm_softc *sc = &apm_softc;
-
- sc->bios.r.eax = (APM_BIOS << 8) | APM_SETPWSTATE;
- sc->bios.r.ebx = PMDV_ALLDEV;
- sc->bios.r.ecx = state;
- sc->bios.r.edx = 0;
-
- if (apm_bioscall()) {
- printf("Entire system suspend failure: errcode = %d\n",
- 0xff & (sc->bios.r.eax >> 8));
- return 1;
- }
- return 0;
-}
-
-/* Display control */
-/*
- * Experimental implementation: My laptop machine can't handle this function
- * If your laptop can control the display via APM, please inform me.
- * HOSOKAWA, Tatsumi <hosokawa@jp.FreeBSD.org>
- */
-int
-apm_display(int newstate)
-{
- struct apm_softc *sc = &apm_softc;
-
- sc->bios.r.eax = (APM_BIOS << 8) | APM_SETPWSTATE;
- sc->bios.r.ebx = PMDV_DISP0;
- sc->bios.r.ecx = newstate ? PMST_APMENABLED:PMST_SUSPEND;
- sc->bios.r.edx = 0;
- if (apm_bioscall()) {
- printf("Display off failure: errcode = %d\n",
- 0xff & (sc->bios.r.eax >> 8));
- return 1;
- }
- return 0;
-}
-
-/*
- * Turn off the entire system.
- */
-static void
-apm_power_off(void *junk, int howto)
-{
- struct apm_softc *sc = &apm_softc;
-
- /* Not halting powering off, or not active */
- if (!(howto & RB_POWEROFF) || !apm_softc.active)
- return;
- sc->bios.r.eax = (APM_BIOS << 8) | APM_SETPWSTATE;
- sc->bios.r.ebx = PMDV_ALLDEV;
- sc->bios.r.ecx = PMST_OFF;
- sc->bios.r.edx = 0;
- (void) apm_bioscall();
-}
-
-/* APM Battery low handler */
-static void
-apm_battery_low(void)
-{
- printf("\007\007 * * * BATTERY IS LOW * * * \007\007");
-}
-
-/* APM hook manager */
-static struct apmhook *
-apm_add_hook(struct apmhook **list, struct apmhook *ah)
-{
- int s;
- struct apmhook *p, *prev;
-
-#ifdef APM_DEBUG
- printf("Add hook \"%s\"\n", ah->ah_name);
-#endif
-
- s = splhigh();
- if (ah == NULL)
- panic("illegal apm_hook!");
- prev = NULL;
- for (p = *list; p != NULL; prev = p, p = p->ah_next)
- if (p->ah_order > ah->ah_order)
- break;
-
- if (prev == NULL) {
- ah->ah_next = *list;
- *list = ah;
- } else {
- ah->ah_next = prev->ah_next;
- prev->ah_next = ah;
- }
- splx(s);
- return ah;
-}
-
-static void
-apm_del_hook(struct apmhook **list, struct apmhook *ah)
-{
- int s;
- struct apmhook *p, *prev;
-
- s = splhigh();
- prev = NULL;
- for (p = *list; p != NULL; prev = p, p = p->ah_next)
- if (p == ah)
- goto deleteit;
- panic("Tried to delete unregistered apm_hook.");
- goto nosuchnode;
-deleteit:
- if (prev != NULL)
- prev->ah_next = p->ah_next;
- else
- *list = p->ah_next;
-nosuchnode:
- splx(s);
-}
-
-
-/* APM driver calls some functions automatically */
-static void
-apm_execute_hook(struct apmhook *list)
-{
- struct apmhook *p;
-
- for (p = list; p != NULL; p = p->ah_next) {
-#ifdef APM_DEBUG
- printf("Execute APM hook \"%s.\"\n", p->ah_name);
-#endif
- if ((*(p->ah_fun))(p->ah_arg))
- printf("Warning: APM hook \"%s\" failed", p->ah_name);
- }
-}
-
-
-/* establish an apm hook */
-struct apmhook *
-apm_hook_establish(int apmh, struct apmhook *ah)
-{
- if (apmh < 0 || apmh >= NAPM_HOOK)
- return NULL;
-
- return apm_add_hook(&hook[apmh], ah);
-}
-
-/* disestablish an apm hook */
-void
-apm_hook_disestablish(int apmh, struct apmhook *ah)
-{
- if (apmh < 0 || apmh >= NAPM_HOOK)
- return;
-
- apm_del_hook(&hook[apmh], ah);
-}
-
-
-static struct timeval suspend_time;
-static struct timeval diff_time;
-
-static int
-apm_default_resume(void *arg)
-{
- int pl;
- u_int second, minute, hour;
- struct timeval resume_time, tmp_time;
-
- /* modified for adjkerntz */
- pl = splsoftclock();
- i8254_restore(); /* restore timer_freq and hz */
- inittodr(0); /* adjust time to RTC */
- microtime(&resume_time);
- getmicrotime(&tmp_time);
- timevaladd(&tmp_time, &diff_time);
-
-#ifdef FIXME
- /* XXX THIS DOESN'T WORK!!! */
- time = tmp_time;
-#endif
-
-#ifdef APM_FIXUP_CALLTODO
- /* Calculate the delta time suspended */
- timevalsub(&resume_time, &suspend_time);
- /* Fixup the calltodo list with the delta time. */
- adjust_timeout_calltodo(&resume_time);
-#endif /* APM_FIXUP_CALLTODOK */
- splx(pl);
-#ifndef APM_FIXUP_CALLTODO
- second = resume_time.tv_sec - suspend_time.tv_sec;
-#else /* APM_FIXUP_CALLTODO */
- /*
- * We've already calculated resume_time to be the delta between
- * the suspend and the resume.
- */
- second = resume_time.tv_sec;
-#endif /* APM_FIXUP_CALLTODO */
- hour = second / 3600;
- second %= 3600;
- minute = second / 60;
- second %= 60;
- log(LOG_NOTICE, "resumed from suspended mode (slept %02d:%02d:%02d)\n",
- hour, minute, second);
- return 0;
-}
-
-static int
-apm_default_suspend(void *arg)
-{
- int pl;
-
- pl = splsoftclock();
- microtime(&diff_time);
- inittodr(0);
- microtime(&suspend_time);
- timevalsub(&diff_time, &suspend_time);
- splx(pl);
- return 0;
-}
-
-static int apm_record_event __P((struct apm_softc *, u_int));
-static void apm_processevent(void);
-
-static u_int apm_op_inprog = 0;
-
-static void
-apm_do_suspend(void)
-{
- struct apm_softc *sc = &apm_softc;
- int error;
-
- if (!sc)
- return;
-
- apm_op_inprog = 0;
- sc->suspends = sc->suspend_countdown = 0;
-
- if (sc->initialized) {
- error = DEVICE_SUSPEND(root_bus);
- if (error) {
- DEVICE_RESUME(root_bus);
- } else {
- apm_execute_hook(hook[APM_HOOK_SUSPEND]);
- if (apm_suspend_system(PMST_SUSPEND) == 0) {
- apm_processevent();
- } else {
- /* Failure, 'resume' the system again */
- apm_execute_hook(hook[APM_HOOK_RESUME]);
- DEVICE_RESUME(root_bus);
- }
- }
- }
-}
-
-static void
-apm_do_standby(void)
-{
- struct apm_softc *sc = &apm_softc;
-
- if (!sc)
- return;
-
- apm_op_inprog = 0;
- sc->standbys = sc->standby_countdown = 0;
-
- if (sc->initialized) {
- /*
- * As far as standby, we don't need to execute
- * all of suspend hooks.
- */
- apm_default_suspend(&apm_softc);
- if (apm_suspend_system(PMST_STANDBY) == 0)
- apm_processevent();
- }
-}
-
-static void
-apm_lastreq_notify(void)
-{
- struct apm_softc *sc = &apm_softc;
-
- sc->bios.r.eax = (APM_BIOS << 8) | APM_SETPWSTATE;
- sc->bios.r.ebx = PMDV_ALLDEV;
- sc->bios.r.ecx = PMST_LASTREQNOTIFY;
- sc->bios.r.edx = 0;
- apm_bioscall();
-}
-
-static int
-apm_lastreq_rejected(void)
-{
- struct apm_softc *sc = &apm_softc;
-
- if (apm_op_inprog == 0) {
- return 1; /* no operation in progress */
- }
-
- sc->bios.r.eax = (APM_BIOS << 8) | APM_SETPWSTATE;
- sc->bios.r.ebx = PMDV_ALLDEV;
- sc->bios.r.ecx = PMST_LASTREQREJECT;
- sc->bios.r.edx = 0;
-
- if (apm_bioscall()) {
-#ifdef APM_DEBUG
- printf("apm_lastreq_rejected: failed\n");
-#endif
- return 1;
- }
- apm_op_inprog = 0;
- return 0;
-}
-
-/*
- * Public interface to the suspend/resume:
- *
- * Execute suspend and resume hook before and after sleep, respectively.
- *
- */
-
-void
-apm_suspend(int state)
-{
- struct apm_softc *sc = &apm_softc;
-
- if (!sc->initialized)
- return;
-
- switch (state) {
- case PMST_SUSPEND:
- if (sc->suspends)
- return;
- sc->suspends++;
- sc->suspend_countdown = apm_suspend_delay;
- break;
- case PMST_STANDBY:
- if (sc->standbys)
- return;
- sc->standbys++;
- sc->standby_countdown = apm_standby_delay;
- break;
- default:
- printf("apm_suspend: Unknown Suspend state 0x%x\n", state);
- return;
- }
-
- apm_op_inprog++;
- apm_lastreq_notify();
-}
-
-void
-apm_resume(void)
-{
- struct apm_softc *sc = &apm_softc;
-
- if (!sc)
- return;
-
- if (sc->initialized) {
- apm_execute_hook(hook[APM_HOOK_RESUME]);
- DEVICE_RESUME(root_bus);
- }
-}
-
-
-/* get APM information */
-static int
-apm_get_info(apm_info_t aip)
-{
- struct apm_softc *sc = &apm_softc;
-
- sc->bios.r.eax = (APM_BIOS << 8) | APM_GETPWSTATUS;
- sc->bios.r.ebx = PMDV_ALLDEV;
- sc->bios.r.ecx = 0;
- sc->bios.r.edx = 0xffff; /* default to unknown battery time */
-
- if (apm_bioscall())
- return 1;
-
- aip->ai_infoversion = 1;
- aip->ai_acline = (sc->bios.r.ebx >> 8) & 0xff;
- aip->ai_batt_stat = sc->bios.r.ebx & 0xff;
- aip->ai_batt_life = sc->bios.r.ecx & 0xff;
- aip->ai_major = (u_int)sc->majorversion;
- aip->ai_minor = (u_int)sc->minorversion;
- aip->ai_status = (u_int)sc->active;
- sc->bios.r.edx &= 0xffff;
- if (sc->bios.r.edx == 0xffff) /* Time is unknown */
- aip->ai_batt_time = -1;
- else if (sc->bios.r.edx & 0x8000) /* Time is in minutes */
- aip->ai_batt_time = (sc->bios.r.edx & 0x7fff) * 60;
- else /* Time is in seconds */
- aip->ai_batt_time = sc->bios.r.edx;
-
- sc->bios.r.eax = (APM_BIOS << 8) | APM_GETCAPABILITIES;
- sc->bios.r.ebx = 0;
- sc->bios.r.ecx = 0;
- sc->bios.r.edx = 0;
- if (apm_bioscall()) {
- aip->ai_batteries = -1; /* Unknown */
- aip->ai_capabilities = 0xff00; /* Unknown, with no bits set */
- } else {
- aip->ai_batteries = sc->bios.r.ebx & 0xff;
- aip->ai_capabilities = sc->bios.r.ecx & 0xf;
- }
-
- bzero(aip->ai_spare, sizeof aip->ai_spare);
-
- return 0;
-}
-
-
-/* inform APM BIOS that CPU is idle */
-void
-apm_cpu_idle(void)
-{
- struct apm_softc *sc = &apm_softc;
-
- if (sc->active) {
-
- sc->bios.r.eax = (APM_BIOS <<8) | APM_CPUIDLE;
- sc->bios.r.edx = sc->bios.r.ecx = sc->bios.r.ebx = 0;
- (void) apm_bioscall();
- }
- /*
- * Some APM implementation halts CPU in BIOS, whenever
- * "CPU-idle" function are invoked, but swtch() of
- * FreeBSD halts CPU, therefore, CPU is halted twice
- * in the sched loop. It makes the interrupt latency
- * terribly long and be able to cause a serious problem
- * in interrupt processing. We prevent it by removing
- * "hlt" operation from swtch() and managed it under
- * APM driver.
- */
- if (!sc->active || sc->always_halt_cpu)
- __asm("hlt"); /* wait for interrupt */
-}
-
-/* inform APM BIOS that CPU is busy */
-void
-apm_cpu_busy(void)
-{
- struct apm_softc *sc = &apm_softc;
-
- /*
- * The APM specification says this is only necessary if your BIOS
- * slows down the processor in the idle task, otherwise it's not
- * necessary.
- */
- if (sc->slow_idle_cpu && sc->active) {
-
- sc->bios.r.eax = (APM_BIOS <<8) | APM_CPUBUSY;
- sc->bios.r.edx = sc->bios.r.ecx = sc->bios.r.ebx = 0;
- apm_bioscall();
- }
-}
-
-
-/*
- * APM timeout routine:
- *
- * This routine is automatically called by timer once per second.
- */
-
-static void
-apm_timeout(void *dummy)
-{
- struct apm_softc *sc = &apm_softc;
-
- if (apm_op_inprog)
- apm_lastreq_notify();
-
- if (sc->standbys && sc->standby_countdown-- <= 0)
- apm_do_standby();
-
- if (sc->suspends && sc->suspend_countdown-- <= 0)
- apm_do_suspend();
-
- if (!sc->bios_busy)
- apm_processevent();
-
- if (sc->active == 1)
- /* Run slightly more oftan than 1 Hz */
- apm_timeout_ch = timeout(apm_timeout, NULL, hz - 1 );
-}
-
-/* enable APM BIOS */
-static void
-apm_event_enable(void)
-{
- struct apm_softc *sc = &apm_softc;
-
-#ifdef APM_DEBUG
- printf("called apm_event_enable()\n");
-#endif
- if (sc->initialized) {
- sc->active = 1;
- apm_timeout(sc);
- }
-}
-
-/* disable APM BIOS */
-static void
-apm_event_disable(void)
-{
- struct apm_softc *sc = &apm_softc;
-
-#ifdef APM_DEBUG
- printf("called apm_event_disable()\n");
-#endif
- if (sc->initialized) {
- untimeout(apm_timeout, NULL, apm_timeout_ch);
- sc->active = 0;
- }
-}
-
-/* halt CPU in scheduling loop */
-static void
-apm_halt_cpu(void)
-{
- struct apm_softc *sc = &apm_softc;
-
- if (sc->initialized)
- sc->always_halt_cpu = 1;
-}
-
-/* don't halt CPU in scheduling loop */
-static void
-apm_not_halt_cpu(void)
-{
- struct apm_softc *sc = &apm_softc;
-
- if (sc->initialized)
- sc->always_halt_cpu = 0;
-}
-
-/* device driver definitions */
-
-/*
- * Create "connection point"
- */
-static void
-apm_identify(driver_t *driver, device_t parent)
-{
- device_t child;
-
- child = BUS_ADD_CHILD(parent, 0, "apm", 0);
- if (child == NULL)
- panic("apm_identify");
-}
-
-/*
- * probe for APM BIOS
- */
-static int
-apm_probe(device_t dev)
-{
-#define APM_KERNBASE KERNBASE
- struct vm86frame vmf;
- struct apm_softc *sc = &apm_softc;
- int disabled, flags;
-
- if (resource_int_value("apm", 0, "disabled", &disabled) == 0
- && disabled != 0)
- return ENXIO;
-
- device_set_desc(dev, "APM BIOS");
-
- if ( device_get_unit(dev) > 0 ) {
- printf("apm: Only one APM driver supported.\n");
- return ENXIO;
- }
-
- if (resource_int_value("apm", 0, "flags", &flags) != 0)
- flags = 0;
-
- bzero(&vmf, sizeof(struct vm86frame)); /* safety */
- bzero(&apm_softc, sizeof(apm_softc));
- vmf.vmf_ah = APM_BIOS;
- vmf.vmf_al = APM_INSTCHECK;
- vmf.vmf_bx = 0;
- if (vm86_intcall(APM_INT, &vmf))
- return ENXIO; /* APM not found */
- if (vmf.vmf_bx != 0x504d) {
- printf("apm: incorrect signature (0x%x)\n", vmf.vmf_bx);
- return ENXIO;
- }
- if ((vmf.vmf_cx & (APM_32BIT_SUPPORT | APM_16BIT_SUPPORT)) == 0) {
- printf("apm: protected mode connections are not supported\n");
- return ENXIO;
- }
-
- apm_version = vmf.vmf_ax;
- sc->slow_idle_cpu = ((vmf.vmf_cx & APM_CPUIDLE_SLOW) != 0);
- sc->disabled = ((vmf.vmf_cx & APM_DISABLED) != 0);
- sc->disengaged = ((vmf.vmf_cx & APM_DISENGAGED) != 0);
-
- vmf.vmf_ah = APM_BIOS;
- vmf.vmf_al = APM_DISCONNECT;
- vmf.vmf_bx = 0;
- vm86_intcall(APM_INT, &vmf); /* disconnect, just in case */
-
- if ((vmf.vmf_cx & APM_32BIT_SUPPORT) != 0) {
- vmf.vmf_ah = APM_BIOS;
- vmf.vmf_al = APM_PROT32CONNECT;
- vmf.vmf_bx = 0;
- if (vm86_intcall(APM_INT, &vmf)) {
- printf("apm: 32-bit connection error.\n");
- return (ENXIO);
- }
- sc->bios.seg.code32.base = (vmf.vmf_ax << 4) + APM_KERNBASE;
- sc->bios.seg.code32.limit = 0xffff;
- sc->bios.seg.code16.base = (vmf.vmf_cx << 4) + APM_KERNBASE;
- sc->bios.seg.code16.limit = 0xffff;
- sc->bios.seg.data.base = (vmf.vmf_dx << 4) + APM_KERNBASE;
- sc->bios.seg.data.limit = 0xffff;
- sc->bios.entry = vmf.vmf_ebx;
- sc->connectmode = APM_PROT32CONNECT;
- } else {
- /* use 16-bit connection */
- vmf.vmf_ah = APM_BIOS;
- vmf.vmf_al = APM_PROT16CONNECT;
- vmf.vmf_bx = 0;
- if (vm86_intcall(APM_INT, &vmf)) {
- printf("apm: 16-bit connection error.\n");
- return (ENXIO);
- }
- sc->bios.seg.code16.base = (vmf.vmf_ax << 4) + APM_KERNBASE;
- sc->bios.seg.code16.limit = 0xffff;
- sc->bios.seg.data.base = (vmf.vmf_cx << 4) + APM_KERNBASE;
- sc->bios.seg.data.limit = 0xffff;
- sc->bios.entry = vmf.vmf_bx;
- sc->connectmode = APM_PROT16CONNECT;
- }
- return(0);
-}
-
-
-/*
- * return 0 if the user will notice and handle the event,
- * return 1 if the kernel driver should do so.
- */
-static int
-apm_record_event(struct apm_softc *sc, u_int event_type)
-{
- struct apm_event_info *evp;
-
- if ((sc->sc_flags & SCFLAG_OPEN) == 0)
- return 1; /* no user waiting */
- if (sc->event_count == APM_NEVENTS)
- return 1; /* overflow */
- if (sc->event_filter[event_type] == 0)
- return 1; /* not registered */
- evp = &sc->event_list[sc->event_ptr];
- sc->event_count++;
- sc->event_ptr++;
- sc->event_ptr %= APM_NEVENTS;
- evp->type = event_type;
- evp->index = ++apm_evindex;
- selwakeup(&sc->sc_rsel);
- return (sc->sc_flags & SCFLAG_OCTL) ? 0 : 1; /* user may handle */
-}
-
-/* Process APM event */
-static void
-apm_processevent(void)
-{
- int apm_event;
- struct apm_softc *sc = &apm_softc;
-
-#ifdef APM_DEBUG
-# define OPMEV_DEBUGMESSAGE(symbol) case symbol: \
- printf("Received APM Event: " #symbol "\n");
-#else
-# define OPMEV_DEBUGMESSAGE(symbol) case symbol:
-#endif
- do {
- apm_event = apm_getevent();
- switch (apm_event) {
- OPMEV_DEBUGMESSAGE(PMEV_STANDBYREQ);
- if (apm_op_inprog == 0) {
- apm_op_inprog++;
- if (apm_record_event(sc, apm_event)) {
- apm_suspend(PMST_STANDBY);
- }
- }
- break;
- OPMEV_DEBUGMESSAGE(PMEV_USERSTANDBYREQ);
- if (apm_op_inprog == 0) {
- apm_op_inprog++;
- if (apm_record_event(sc, apm_event)) {
- apm_suspend(PMST_STANDBY);
- }
- }
- break;
- OPMEV_DEBUGMESSAGE(PMEV_SUSPENDREQ);
- apm_lastreq_notify();
- if (apm_op_inprog == 0) {
- apm_op_inprog++;
- if (apm_record_event(sc, apm_event)) {
- apm_do_suspend();
- }
- }
- return; /* XXX skip the rest */
- OPMEV_DEBUGMESSAGE(PMEV_USERSUSPENDREQ);
- apm_lastreq_notify();
- if (apm_op_inprog == 0) {
- apm_op_inprog++;
- if (apm_record_event(sc, apm_event)) {
- apm_do_suspend();
- }
- }
- return; /* XXX skip the rest */
- OPMEV_DEBUGMESSAGE(PMEV_CRITSUSPEND);
- apm_do_suspend();
- break;
- OPMEV_DEBUGMESSAGE(PMEV_NORMRESUME);
- apm_record_event(sc, apm_event);
- apm_resume();
- break;
- OPMEV_DEBUGMESSAGE(PMEV_CRITRESUME);
- apm_record_event(sc, apm_event);
- apm_resume();
- break;
- OPMEV_DEBUGMESSAGE(PMEV_STANDBYRESUME);
- apm_record_event(sc, apm_event);
- apm_resume();
- break;
- OPMEV_DEBUGMESSAGE(PMEV_BATTERYLOW);
- if (apm_record_event(sc, apm_event)) {
- apm_battery_low();
- apm_suspend(PMST_SUSPEND);
- }
- break;
- OPMEV_DEBUGMESSAGE(PMEV_POWERSTATECHANGE);
- apm_record_event(sc, apm_event);
- break;
- OPMEV_DEBUGMESSAGE(PMEV_UPDATETIME);
- apm_record_event(sc, apm_event);
- inittodr(0); /* adjust time to RTC */
- break;
- OPMEV_DEBUGMESSAGE(PMEV_CAPABILITIESCHANGE);
- apm_record_event(sc, apm_event);
- break;
- case PMEV_NOEVENT:
- break;
- default:
- printf("Unknown Original APM Event 0x%x\n", apm_event);
- break;
- }
- } while (apm_event != PMEV_NOEVENT);
-}
-
-/*
- * Attach APM:
- *
- * Initialize APM driver
- */
-
-static int
-apm_attach(device_t dev)
-{
- struct apm_softc *sc = &apm_softc;
- int flags;
- int drv_version;
-
- if (resource_int_value("apm", 0, "flags", &flags) != 0)
- flags = 0;
-
- if (flags & 0x20)
- statclock_disable = 1;
-
- sc->initialized = 0;
-
- /* Must be externally enabled */
- sc->active = 0;
-
- /* Always call HLT in idle loop */
- sc->always_halt_cpu = 1;
-
- /* print bootstrap messages */
-#ifdef APM_DEBUG
- printf("apm: APM BIOS version %04x\n", apm_version);
- printf("apm: Code16 0x%08x, Data 0x%08x\n",
- sc->bios.seg.code16.base, sc->bios.seg.data.base);
- printf("apm: Code entry 0x%08x, Idling CPU %s, Management %s\n",
- sc->bios.entry, is_enabled(sc->slow_idle_cpu),
- is_enabled(!sc->disabled));
- printf("apm: CS_limit=0x%x, DS_limit=0x%x\n",
- sc->bios.seg.code16.limit, sc->bios.seg.data.limit);
-#endif /* APM_DEBUG */
-
- /*
- * In one test, apm bios version was 1.02; an attempt to register
- * a 1.04 driver resulted in a 1.00 connection! Registering a
- * 1.02 driver resulted in a 1.02 connection.
- */
- drv_version = apm_version > 0x102 ? 0x102 : apm_version;
- for (; drv_version > 0x100; drv_version--)
- if (apm_driver_version(drv_version) == 0)
- break;
- sc->minorversion = ((drv_version & 0x00f0) >> 4) * 10 +
- ((drv_version & 0x000f) >> 0);
- sc->majorversion = ((drv_version & 0xf000) >> 12) * 10 +
- ((apm_version & 0x0f00) >> 8);
-
- sc->intversion = INTVERSION(sc->majorversion, sc->minorversion);
-
-#ifdef APM_DEBUG
- if (sc->intversion >= INTVERSION(1, 1))
- printf("apm: Engaged control %s\n", is_enabled(!sc->disengaged));
-#endif
-
- printf("apm: found APM BIOS v%ld.%ld, connected at v%d.%d\n",
- ((apm_version & 0xf000) >> 12) * 10 + ((apm_version & 0x0f00) >> 8),
- ((apm_version & 0x00f0) >> 4) * 10 + ((apm_version & 0x000f) >> 0),
- sc->majorversion, sc->minorversion);
-
-#ifdef APM_DEBUG
- printf("apm: Slow Idling CPU %s\n", is_enabled(sc->slow_idle_cpu));
-#endif
-
- /* enable power management */
- if (sc->disabled) {
- if (apm_enable_disable_pm(1)) {
-#ifdef APM_DEBUG
- printf("apm: *Warning* enable function failed! [%x]\n",
- (sc->bios.r.eax >> 8) & 0xff);
-#endif
- }
- }
-
- /* engage power managment (APM 1.1 or later) */
- if (sc->intversion >= INTVERSION(1, 1) && sc->disengaged) {
- if (apm_engage_disengage_pm(1)) {
-#ifdef APM_DEBUG
- printf("apm: *Warning* engage function failed err=[%x]",
- (sc->bios.r.eax >> 8) & 0xff);
- printf(" (Docked or using external power?).\n");
-#endif
- }
- }
-
- /* default suspend hook */
- sc->sc_suspend.ah_fun = apm_default_suspend;
- sc->sc_suspend.ah_arg = sc;
- sc->sc_suspend.ah_name = "default suspend";
- sc->sc_suspend.ah_order = APM_MAX_ORDER;
-
- /* default resume hook */
- sc->sc_resume.ah_fun = apm_default_resume;
- sc->sc_resume.ah_arg = sc;
- sc->sc_resume.ah_name = "default resume";
- sc->sc_resume.ah_order = APM_MIN_ORDER;
-
- apm_hook_establish(APM_HOOK_SUSPEND, &sc->sc_suspend);
- apm_hook_establish(APM_HOOK_RESUME , &sc->sc_resume);
-
- /* Power the system off using APM */
- EVENTHANDLER_REGISTER(shutdown_final, apm_power_off, NULL,
- SHUTDOWN_PRI_LAST);
-
- sc->initialized = 1;
-
- make_dev(&apm_cdevsw, 0, 0, 5, 0660, "apm");
- make_dev(&apm_cdevsw, 8, 0, 5, 0660, "apmctl");
- return 0;
-}
-
-static int
-apmopen(dev_t dev, int flag, int fmt, struct proc *p)
-{
- struct apm_softc *sc = &apm_softc;
- int ctl = APMDEV(dev);
-
- if (!sc->initialized)
- return (ENXIO);
-
- switch (ctl) {
- case APMDEV_CTL:
- if (!(flag & FWRITE))
- return EINVAL;
- if (sc->sc_flags & SCFLAG_OCTL)
- return EBUSY;
- sc->sc_flags |= SCFLAG_OCTL;
- bzero(sc->event_filter, sizeof sc->event_filter);
- break;
- case APMDEV_NORMAL:
- sc->sc_flags |= SCFLAG_ONORMAL;
- break;
- default:
- return ENXIO;
- break;
- }
- return 0;
-}
-
-static int
-apmclose(dev_t dev, int flag, int fmt, struct proc *p)
-{
- struct apm_softc *sc = &apm_softc;
- int ctl = APMDEV(dev);
-
- switch (ctl) {
- case APMDEV_CTL:
- apm_lastreq_rejected();
- sc->sc_flags &= ~SCFLAG_OCTL;
- bzero(sc->event_filter, sizeof sc->event_filter);
- break;
- case APMDEV_NORMAL:
- sc->sc_flags &= ~SCFLAG_ONORMAL;
- break;
- }
- if ((sc->sc_flags & SCFLAG_OPEN) == 0) {
- sc->event_count = 0;
- sc->event_ptr = 0;
- }
- return 0;
-}
-
-static int
-apmioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
-{
- struct apm_softc *sc = &apm_softc;
- struct apm_bios_arg *args;
- int error = 0;
- int ret;
- int newstate;
-
- if (!sc->initialized)
- return (ENXIO);
-#ifdef APM_DEBUG
- printf("APM ioctl: cmd = 0x%x\n", cmd);
-#endif
- switch (cmd) {
- case APMIO_SUSPEND:
- if (sc->active)
- apm_suspend(PMST_SUSPEND);
- else
- error = EINVAL;
- break;
-
- case APMIO_STANDBY:
- if (sc->active)
- apm_suspend(PMST_STANDBY);
- else
- error = EINVAL;
- break;
-
- case APMIO_GETINFO_OLD:
- {
- struct apm_info info;
- apm_info_old_t aiop;
-
- if (apm_get_info(&info))
- error = ENXIO;
- aiop = (apm_info_old_t)addr;
- aiop->ai_major = info.ai_major;
- aiop->ai_minor = info.ai_minor;
- aiop->ai_acline = info.ai_acline;
- aiop->ai_batt_stat = info.ai_batt_stat;
- aiop->ai_batt_life = info.ai_batt_life;
- aiop->ai_status = info.ai_status;
- }
- break;
- case APMIO_GETINFO:
- if (apm_get_info((apm_info_t)addr))
- error = ENXIO;
- break;
- case APMIO_ENABLE:
- apm_event_enable();
- break;
- case APMIO_DISABLE:
- apm_event_disable();
- break;
- case APMIO_HALTCPU:
- apm_halt_cpu();
- break;
- case APMIO_NOTHALTCPU:
- apm_not_halt_cpu();
- break;
- case APMIO_DISPLAY:
- newstate = *(int *)addr;
- if (apm_display(newstate))
- error = ENXIO;
- break;
- case APMIO_BIOS:
- /* XXX compatibility with the old interface */
- args = (struct apm_bios_arg *)addr;
- sc->bios.r.eax = args->eax;
- sc->bios.r.ebx = args->ebx;
- sc->bios.r.ecx = args->ecx;
- sc->bios.r.edx = args->edx;
- sc->bios.r.esi = args->esi;
- sc->bios.r.edi = args->edi;
- if ((ret = apm_bioscall())) {
- /*
- * Return code 1 means bios call was unsuccessful.
- * Error code is stored in %ah.
- * Return code -1 means bios call was unsupported
- * in the APM BIOS version.
- */
- if (ret == -1) {
- error = EINVAL;
- }
- } else {
- /*
- * Return code 0 means bios call was successful.
- * We need only %al and can discard %ah.
- */
- sc->bios.r.eax &= 0xff;
- }
- args->eax = sc->bios.r.eax;
- args->ebx = sc->bios.r.ebx;
- args->ecx = sc->bios.r.ecx;
- args->edx = sc->bios.r.edx;
- args->esi = sc->bios.r.esi;
- args->edi = sc->bios.r.edi;
- break;
- default:
- error = EINVAL;
- break;
- }
-
- /* for /dev/apmctl */
- if (APMDEV(dev) == APMDEV_CTL) {
- struct apm_event_info *evp;
- int i;
-
- error = 0;
- switch (cmd) {
- case APMIO_NEXTEVENT:
- if (!sc->event_count) {
- error = EAGAIN;
- } else {
- evp = (struct apm_event_info *)addr;
- i = sc->event_ptr + APM_NEVENTS - sc->event_count;
- i %= APM_NEVENTS;
- *evp = sc->event_list[i];
- sc->event_count--;
- }
- break;
- case APMIO_REJECTLASTREQ:
- if (apm_lastreq_rejected()) {
- error = EINVAL;
- }
- break;
- default:
- error = EINVAL;
- break;
- }
- }
-
- return error;
-}
-
-static int
-apmwrite(dev_t dev, struct uio *uio, int ioflag)
-{
- struct apm_softc *sc = &apm_softc;
- u_int event_type;
- int error;
- u_char enabled;
-
- if (APMDEV(dev) != APMDEV_CTL)
- return(ENODEV);
- if (uio->uio_resid != sizeof(u_int))
- return(E2BIG);
-
- if ((error = uiomove((caddr_t)&event_type, sizeof(u_int), uio)))
- return(error);
-
- if (event_type < 0 || event_type >= APM_NPMEV)
- return(EINVAL);
-
- if (sc->event_filter[event_type] == 0) {
- enabled = 1;
- } else {
- enabled = 0;
- }
- sc->event_filter[event_type] = enabled;
-#ifdef APM_DEBUG
- printf("apmwrite: event 0x%x %s\n", event_type, is_enabled(enabled));
-#endif
-
- return uio->uio_resid;
-}
-
-static int
-apmpoll(dev_t dev, int events, struct proc *p)
-{
- struct apm_softc *sc = &apm_softc;
- int revents = 0;
-
- if (events & (POLLIN | POLLRDNORM)) {
- if (sc->event_count) {
- revents |= events & (POLLIN | POLLRDNORM);
- } else {
- selrecord(p, &sc->sc_rsel);
- }
- }
-
- return (revents);
-}
-
-static device_method_t apm_methods[] = {
- /* Device interface */
- DEVMETHOD(device_identify, apm_identify),
- DEVMETHOD(device_probe, apm_probe),
- DEVMETHOD(device_attach, apm_attach),
-
- { 0, 0 }
-};
-
-static driver_t apm_driver = {
- "apm",
- apm_methods,
- 1, /* no softc (XXX) */
-};
-
-static devclass_t apm_devclass;
-
-DRIVER_MODULE(apm, nexus, apm_driver, apm_devclass, 0, 0);
diff --git a/sys/i386/bios/apm.h b/sys/i386/bios/apm.h
deleted file mode 100644
index 242782f7faeb..000000000000
--- a/sys/i386/bios/apm.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * APM (Advanced Power Management) BIOS Device Driver
- *
- * Copyright (c) 1994 UKAI, Fumitoshi.
- * Copyright (c) 1994-1995 by HOSOKAWA, Tatsumi <hosokawa@jp.FreeBSD.org>
- * Copyright (c) 1996 Nate Williams <nate@FreeBSD.org>
- * Copyright (c) 1997 Poul-Henning Kamp <phk@FreeBSD.org>
- *
- * This software may be used, modified, copied, and distributed, in
- * both source and binary form provided that the above copyright and
- * these terms are retained. Under no circumstances is the author
- * responsible for the proper functioning of this software, nor does
- * the author assume any responsibility for damages incurred with its
- * use.
- *
- * Sep, 1994 Implemented on FreeBSD 1.1.5.1R (Toshiba AVS001WD)
- *
- * $FreeBSD$
- */
-
-#define APM_NEVENTS 16
-#define APM_NPMEV 13
-
-/* static data */
-struct apm_softc {
- int initialized, active, bios_busy;
- int always_halt_cpu, slow_idle_cpu;
- int disabled, disengaged;
- int standby_countdown, suspend_countdown;
- u_int minorversion, majorversion;
- u_int intversion, connectmode;
- u_int standbys, suspends;
- struct bios_args bios;
- struct apmhook sc_suspend;
- struct apmhook sc_resume;
- struct selinfo sc_rsel;
- int sc_flags;
- int event_count;
- int event_ptr;
- struct apm_event_info event_list[APM_NEVENTS];
- u_char event_filter[APM_NPMEV];
-};
-
diff --git a/sys/i386/conf/NOTES b/sys/i386/conf/NOTES
deleted file mode 100644
index 9f129430e341..000000000000
--- a/sys/i386/conf/NOTES
+++ /dev/null
@@ -1,2414 +0,0 @@
-#
-# LINT -- config file for checking all the sources, tries to pull in
-# as much of the source tree as it can.
-#
-# $FreeBSD$
-#
-# NB: You probably don't want to try running a kernel built from this
-# file. Instead, you should start from GENERIC, and add options from
-# this file as required.
-#
-
-#
-# This directive is mandatory; it defines the architecture to be
-# configured for; in this case, the 386 family based IBM-PC and
-# compatibles.
-#
-machine i386
-
-#
-# This is the ``identification'' of the kernel. Usually this should
-# be the same as the name of your kernel.
-#
-ident LINT
-
-#
-# The `maxusers' parameter controls the static sizing of a number of
-# internal system tables by a complicated formula defined in param.c.
-#
-maxusers 10
-
-#
-# The `makeoptions' parameter allows variables to be passed to the
-# generated Makefile in the build area.
-#
-# CONF_CFLAGS gives some extra compiler flags that are added to ${CFLAGS}
-# after most other flags. Here we use it to inhibit use of non-optimal
-# gcc builtin functions (e.g., memcmp).
-#
-# DEBUG happens to be magic.
-# The following is equivalent to 'config -g KERNELNAME' and creates
-# 'kernel.debug' compiled with -g debugging as well as a normal
-# 'kernel'. Use 'make install.debug' to install the debug kernel
-# but that isn't normally necessary as the debug symbols are not loaded
-# by the kernel and are not useful there anyway.
-#
-# KERNEL can be overridden so that you can change the default name of your
-# kernel.
-#
-makeoptions CONF_CFLAGS=-fno-builtin #Don't allow use of memcmp, etc.
-#makeoptions DEBUG=-g #Build kernel with gdb(1) debug symbols
-#makeoptions KERNEL=foo #Build kernel "foo" and install "/foo"
-
-#
-# Certain applications can grow to be larger than the 128M limit
-# that FreeBSD initially imposes. Below are some options to
-# allow that limit to grow to 256MB, and can be increased further
-# with changing the parameters. MAXDSIZ is the maximum that the
-# limit can be set to, and the DFLDSIZ is the default value for
-# the limit. You might want to set the default lower than the
-# max, and explicitly set the maximum with a shell command for processes
-# that regularly exceed the limit like INND.
-#
-options MAXDSIZ="(256*1024*1024)"
-options DFLDSIZ="(256*1024*1024)"
-
-#
-# BLKDEV_IOSIZE sets the default block size used in user block
-# device I/O. Note that this value will be overriden by the label
-# when specifying a block device from a label with a non-0
-# partition blocksize. The default is PAGE_SIZE.
-#
-options BLKDEV_IOSIZE=8192
-
-# Options for the VM subsystem
-#options PQ_NOOPT # No coloring
-options PQ_LARGECACHE # color for 512k/16k cache
-#options PQ_HUGECACHE # color for 1024k/16k cache
-#options PQ_MEDIUMCACHE # color for 64k/16k cache
-#options PQ_NORMALCACHE # color for 256k/16k cache
-
-# This allows you to actually store this configuration file into
-# the kernel binary itself, where it may be later read by saying:
-# strings -aout -n 3 /kernel | grep ^___ | sed -e 's/^___//' > MYKERNEL
-#
-options INCLUDE_CONFIG_FILE # Include this file in kernel
-
-
-#####################################################################
-# SMP OPTIONS:
-#
-# SMP enables building of a Symmetric MultiProcessor Kernel.
-# APIC_IO enables the use of the IO APIC for Symmetric I/O.
-# NCPU sets the number of CPUs, defaults to 2.
-# NBUS sets the number of busses, defaults to 4.
-# NAPIC sets the number of IO APICs on the motherboard, defaults to 1.
-# NINTR sets the total number of INTs provided by the motherboard.
-#
-# Notes:
-#
-# An SMP kernel will ONLY run on an Intel MP spec. qualified motherboard.
-#
-# Be sure to disable 'cpu I386_CPU' && 'cpu I486_CPU' for SMP kernels.
-#
-# Check the 'Rogue SMP hardware' section to see if additional options
-# are required by your hardware.
-#
-
-# Mandatory:
-options SMP # Symmetric MultiProcessor Kernel
-options APIC_IO # Symmetric (APIC) I/O
-
-# Optional, these are the defaults plus 1:
-options NCPU=5 # number of CPUs
-options NBUS=5 # number of busses
-options NAPIC=2 # number of IO APICs
-options NINTR=25 # number of INTs
-
-#
-# Rogue SMP hardware:
-#
-
-# Bridged PCI cards:
-#
-# The MP tables of most of the current generation MP motherboards
-# do NOT properly support bridged PCI cards. To use one of these
-# cards you should refer to ???
-
-
-#####################################################################
-# CPU OPTIONS
-
-#
-# You must specify at least one CPU (the one you intend to run on);
-# deleting the specification for CPUs you don't need to use may make
-# parts of the system run faster. This is especially true removing
-# I386_CPU.
-#
-cpu I386_CPU
-cpu I486_CPU
-cpu I586_CPU # aka Pentium(tm)
-cpu I686_CPU # aka Pentium Pro(tm)
-
-#
-# Options for CPU features.
-#
-# CPU_BLUELIGHTNING_FPU_OP_CACHE enables FPU operand cache on IBM
-# BlueLightning CPU. It works only with Cyrix FPU, and this option
-# should not be used with Intel FPU.
-#
-# CPU_BLUELIGHTNING_3X enables triple-clock mode on IBM Blue Lightning
-# CPU if CPU supports it. The default is double-clock mode on
-# BlueLightning CPU box.
-#
-# CPU_BTB_EN enables branch target buffer on Cyrix 5x86 (NOTE 1).
-#
-# CPU_DIRECT_MAPPED_CACHE sets L1 cache of Cyrix 486DLC CPU in direct
-# mapped mode. Default is 2-way set associative mode.
-#
-# CPU_CYRIX_NO_LOCK enables weak locking for the entire address space
-# of Cyrix 6x86 and 6x86MX CPUs by setting the NO_LOCK bit of CCR1.
-# Otherwise, the NO_LOCK bit of CCR1 is cleared. (NOTE 3)
-#
-# CPU_DISABLE_5X86_LSSER disables load store serialize (i.e. enables
-# reorder). This option should not be used if you use memory mapped
-# I/O device(s).
-#
-# CPU_FASTER_5X86_FPU enables faster FPU exception handler.
-#
-# CPU_I486_ON_386 enables CPU cache on i486 based CPU upgrade products
-# for i386 machines.
-#
-# CPU_IORT defines I/O clock delay time (NOTE 1). Default values of
-# I/O clock delay time on Cyrix 5x86 and 6x86 are 0 and 7,respectively
-# (no clock delay).
-#
-# CPU_LOOP_EN prevents flushing the prefetch buffer if the destination
-# of a jump is already present in the prefetch buffer on Cyrix 5x86(NOTE
-# 1).
-#
-# CPU_RSTK_EN enables return stack on Cyrix 5x86 (NOTE 1).
-#
-# CPU_SUSP_HLT enables suspend on HALT. If this option is set, CPU
-# enters suspend mode following execution of HALT instruction.
-#
-# CPU_WT_ALLOC enables write allocation on Cyrix 6x86/6x86MX and AMD
-# K5/K6/K6-2 cpus.
-#
-# CYRIX_CACHE_WORKS enables CPU cache on Cyrix 486 CPUs with cache
-# flush at hold state.
-#
-# CYRIX_CACHE_REALLY_WORKS enables (1) CPU cache on Cyrix 486 CPUs
-# without cache flush at hold state, and (2) write-back CPU cache on
-# Cyrix 6x86 whose revision < 2.7 (NOTE 2).
-#
-# NO_F00F_HACK disables the hack that prevents Pentiums (and ONLY
-# Pentiums) from locking up when a LOCK CMPXCHG8B instruction is
-# executed. This should be included for ALL kernels that won't run
-# on a Pentium.
-#
-# NO_MEMORY_HOLE is an optimisation for systems with AMD K6 processors
-# which indicates that the 15-16MB range is *definitely* not being
-# occupied by an ISA memory hole.
-#
-# NOTE 1: The options, CPU_BTB_EN, CPU_LOOP_EN, CPU_IORT,
-# CPU_LOOP_EN and CPU_RSTK_EN should not be used because of CPU bugs.
-# These options may crash your system.
-#
-# NOTE 2: If CYRIX_CACHE_REALLY_WORKS is not set, CPU cache is enabled
-# in write-through mode when revision < 2.7. If revision of Cyrix
-# 6x86 >= 2.7, CPU cache is always enabled in write-back mode.
-#
-# NOTE 3: This option may cause failures for software that requires
-# locked cycles in order to operate correctly.
-#
-options CPU_BLUELIGHTNING_FPU_OP_CACHE
-options CPU_BLUELIGHTNING_3X
-options CPU_BTB_EN
-options CPU_DIRECT_MAPPED_CACHE
-options CPU_DISABLE_5X86_LSSER
-options CPU_FASTER_5X86_FPU
-options CPU_I486_ON_386
-options CPU_IORT
-options CPU_LOOP_EN
-options CPU_RSTK_EN
-options CPU_SUSP_HLT
-options CPU_WT_ALLOC
-options CYRIX_CACHE_WORKS
-options CYRIX_CACHE_REALLY_WORKS
-#options NO_F00F_HACK
-
-#
-# A math emulator is mandatory if you wish to run on hardware which
-# does not have a floating-point processor. Pick either the original,
-# bogus (but freely-distributable) math emulator, or a much more
-# fully-featured but GPL-licensed emulator taken from Linux.
-#
-options MATH_EMULATE #Support for x87 emulation
-# Don't enable both of these in a real config.
-options GPL_MATH_EMULATE #Support for x87 emulation via
- #new math emulator
-
-
-#####################################################################
-# COMPATIBILITY OPTIONS
-
-#
-# Implement system calls compatible with 4.3BSD and older versions of
-# FreeBSD. You probably do NOT want to remove this as much current code
-# still relies on the 4.3 emulation.
-#
-options COMPAT_43
-
-#
-# Allow user-mode programs to manipulate their local descriptor tables.
-# This option is required for the WINE Windows(tm) emulator, and is
-# not used by anything else (that we know of).
-#
-options USER_LDT #allow user-level control of i386 ldt
-
-#
-# These three options provide support for System V Interface
-# Definition-style interprocess communication, in the form of shared
-# memory, semaphores, and message queues, respectively.
-#
-options SYSVSHM
-options SYSVSEM
-options SYSVMSG
-
-#
-# This option includes a MD5 routine in the kernel, this is used for
-# various authentication and privacy uses.
-#
-options MD5
-
-
-#####################################################################
-# DEBUGGING OPTIONS
-
-#
-# Enable the kernel debugger.
-#
-options DDB
-
-#
-# Don't drop into DDB for a panic. Intended for unattended operation
-# where you may want to drop to DDB from the console, but still want
-# the machine to recover from a panic
-#
-options DDB_UNATTENDED
-
-#
-# If using GDB remote mode to debug the kernel, there's a non-standard
-# extension to the remote protocol that can be used to use the serial
-# port as both the debugging port and the system console. It's non-
-# standard and you're on your own if you enable it. See also the
-# "remotechat" variables in the FreeBSD specific version of gdb.
-#
-options GDB_REMOTE_CHAT
-
-#
-# KTRACE enables the system-call tracing facility ktrace(2).
-#
-options KTRACE #kernel tracing
-
-#
-# The INVARIANTS option is used in a number of source files to enable
-# extra sanity checking of internal structures. This support is not
-# enabled by default because of the extra time it would take to check
-# for these conditions, which can only occur as a result of
-# programming errors.
-#
-options INVARIANTS
-
-#
-# The INVARIANT_SUPPORT option makes us compile in support for
-# verifying some of the internal structures. It is a prerequisite for
-# 'INVARIANTS', as enabling 'INVARIANTS' will make these functions be
-# called. The intent is that you can set 'INVARIANTS' for single
-# source files (by changing the source file or specifying it on the
-# command line) if you have 'INVARIANT_SUPPORT' enabled.
-#
-options INVARIANT_SUPPORT
-
-#
-# The DIAGNOSTIC option is used to enable extra debugging information
-# from some parts of the kernel. As this makes everything more noisy,
-# it is disabled by default.
-#
-options DIAGNOSTIC
-
-#
-# PERFMON causes the driver for Pentium/Pentium Pro performance counters
-# to be compiled. See perfmon(4) for more information.
-#
-options PERFMON
-
-
-#
-# This option let some drivers co-exist that can't co-exist in a running
-# system. This is used to be able to compile all kernel code in one go for
-# quality assurance purposes (like this file, which the option takes it name
-# from.)
-#
-options COMPILING_LINT
-
-
-# XXX - this doesn't belong here.
-# Allow ordinary users to take the console - this is useful for X.
-options UCONSOLE
-
-# XXX - this doesn't belong here either
-options USERCONFIG #boot -c editor
-options INTRO_USERCONFIG #imply -c and show intro screen
-options VISUAL_USERCONFIG #visual boot -c editor
-
-# XXX - neither does this
-options ROOTDEVNAME=\"da0s2e\"
-
-#####################################################################
-# NETWORKING OPTIONS
-
-#
-# Protocol families:
-# Only the INET (Internet) family is officially supported in FreeBSD.
-# Source code for the NS (Xerox Network Service) is provided for amusement
-# value.
-#
-options INET #Internet communications protocols
-options INET6 #IPv6 communications protocols
-options IPSEC #IP security
-options IPSEC_ESP #IP security (crypto; define w/ IPSEC)
-options IPSEC_IPV6FWD #IP security tunnel for IPv6
-options IPSEC_DEBUG #debug for IP security
-
-options IPX #IPX/SPX communications protocols
-options IPXIP #IPX in IP encapsulation (not available)
-options IPTUNNEL #IP in IPX encapsulation (not available)
-
-options NCP #NetWare Core protocol
-
-options NETATALK #Appletalk communications protocols
-
-# These are currently broken but are shipped due to interest.
-#options NS #Xerox NS protocols
-#options NSIP #XNS over IP
-
-# netgraph(4). Enable the base netgraph code with the NETGRAPH option.
-# Individual node types can be enabled with the corresponding option
-# listed below; however, this is not strictly necessary as netgraph
-# will automatically load the corresponding KLD module if the node type
-# is not already compiled into the kernel. Each type below has a
-# corresponding man page, e.g., ng_async(8).
-options NETGRAPH #netgraph(4) system
-options NETGRAPH_ASYNC
-options NETGRAPH_BPF
-options NETGRAPH_CISCO
-options NETGRAPH_ECHO
-options NETGRAPH_FRAME_RELAY
-options NETGRAPH_HOLE
-options NETGRAPH_IFACE
-options NETGRAPH_KSOCKET
-options NETGRAPH_LMI
-options NETGRAPH_PPP
-options NETGRAPH_PPPOE
-options NETGRAPH_PPTPGRE
-options NETGRAPH_RFC1490
-options NETGRAPH_SOCKET
-options NETGRAPH_TEE
-options NETGRAPH_TTY
-options NETGRAPH_UI
-options NETGRAPH_VJC
-
-device mn # Munich32x/Falc54 Nx64kbit/sec cards.
-
-#
-# Network interfaces:
-# The `loop' pseudo-device is MANDATORY when networking is enabled.
-# The `ether' pseudo-device provides generic code to handle
-# Ethernets; it is MANDATORY when a Ethernet device driver is
-# configured or token-ring is enabled.
-# The 'fddi' pseudo-device provides generic code to support FDDI.
-# The `sppp' pseudo-device serves a similar role for certain types
-# of synchronous PPP links (like `cx', `ar').
-# The `sl' pseudo-device implements the Serial Line IP (SLIP) service.
-# The `ppp' pseudo-device implements the Point-to-Point Protocol.
-# The `bpf' pseudo-device enables the Berkeley Packet Filter. Be
-# aware of the legal and administrative consequences of enabling this
-# option. The number of devices determines the maximum number of
-# simultaneous BPF clients programs runnable.
-# The `disc' pseudo-device implements a minimal network interface,
-# which throws away all packets sent and never receives any. It is
-# included for testing purposes. This shows up as the 'ds' interface.
-# The `tun' pseudo-device implements (user-)ppp and nos-tun
-# The `gif' pseudo-device implements IPv6 over IP4 tunneling,
-# IPv4 over IPv6 tunneling, IPv4 over IPv4 tunneling and
-# IPv6 over IPv6 tunneling.
-# The `faith' pseudo-device captures packets sent to it and diverts them
-# to the IPv4/IPv6 translation daemon.
-# The `ef' pseudo-device provides support for multiple ethernet frame types
-# specified via ETHER_* options. See ef(4) for details.
-#
-# The PPP_BSDCOMP option enables support for compress(1) style entire
-# packet compression, the PPP_DEFLATE is for zlib/gzip style compression.
-# PPP_FILTER enables code for filtering the ppp data stream and selecting
-# events for resetting the demand dial activity timer - requires bpf.
-# See pppd(8) for more details.
-#
-pseudo-device ether #Generic Ethernet
-pseudo-device token #Generic TokenRing
-pseudo-device fddi #Generic FDDI
-pseudo-device sppp #Generic Synchronous PPP
-pseudo-device loop #Network loopback device
-pseudo-device bpf #Berkeley packet filter
-pseudo-device disc #Discard device (ds0, ds1, etc)
-pseudo-device tun #Tunnel driver (ppp(8), nos-tun(8))
-pseudo-device sl 2 #Serial Line IP
-pseudo-device ppp 2 #Point-to-point protocol
-options PPP_BSDCOMP #PPP BSD-compress support
-options PPP_DEFLATE #PPP zlib/deflate/gzip support
-options PPP_FILTER #enable bpf filtering (needs bpf)
-
-pseudo-device ef # Multiple ethernet frames support
-options ETHER_II # enable Ethernet_II frame
-options ETHER_8023 # enable Ethernet_802.3 (Novell) frame
-options ETHER_8022 # enable Ethernet_802.2 frame
-options ETHER_SNAP # enable Ethernet_802.2/SNAP frame
-
-# for IPv6
-pseudo-device gif 4 #IPv6 and IPv4 tunneling
-pseudo-device faith 1 #for IPv6 and IPv4 translation
-
-#
-# Internet family options:
-#
-# TCP_COMPAT_42 causes the TCP code to emulate certain bugs present in
-# 4.2BSD. This option should not be used unless you have a 4.2BSD
-# machine and TCP connections fail.
-#
-# MROUTING enables the kernel multicast packet forwarder, which works
-# with mrouted(8).
-#
-# IPFIREWALL enables support for IP firewall construction, in
-# conjunction with the `ipfw' program. IPFIREWALL_VERBOSE sends
-# logged packets to the system logger. IPFIREWALL_VERBOSE_LIMIT
-# limits the number of times a matching entry can be logged.
-#
-# WARNING: IPFIREWALL defaults to a policy of "deny ip from any to any"
-# and if you do not add other rules during startup to allow access,
-# YOU WILL LOCK YOURSELF OUT. It is suggested that you set firewall_type=open
-# in /etc/rc.conf when first enabling this feature, then refining the
-# firewall rules in /etc/rc.firewall after you've tested that the new kernel
-# feature works properly.
-#
-# IPFIREWALL_DEFAULT_TO_ACCEPT causes the default rule (at boot) to
-# allow everything. Use with care, if a cracker can crash your
-# firewall machine, they can get to your protected machines. However,
-# if you are using it as an as-needed filter for specific problems as
-# they arise, then this may be for you. Changing the default to 'allow'
-# means that you won't get stuck if the kernel and /sbin/ipfw binary get
-# out of sync.
-#
-# IPDIVERT enables the divert IP sockets, used by ``ipfw divert''
-#
-# IPSTEALTH enables code to support stealth forwarding (i.e., forwarding
-# packets without touching the ttl). This can be useful to hide firewalls
-# from traceroute and similar tools.
-#
-# TCPDEBUG is undocumented.
-#
-options TCP_COMPAT_42 #emulate 4.2BSD TCP bugs
-options MROUTING # Multicast routing
-options IPFIREWALL #firewall
-options IPFIREWALL_VERBOSE #print information about
- # dropped packets
-options IPFIREWALL_FORWARD #enable transparent proxy support
-options IPFIREWALL_VERBOSE_LIMIT=100 #limit verbosity
-options IPFIREWALL_DEFAULT_TO_ACCEPT #allow everything by default
-options IPV6FIREWALL #firewall for IPv6
-options IPV6FIREWALL_VERBOSE
-options IPV6FIREWALL_VERBOSE_LIMIT=100
-options IPV6FIREWALL_DEFAULT_TO_ACCEPT
-options IPDIVERT #divert sockets
-options IPFILTER #ipfilter support
-options IPFILTER_LOG #ipfilter logging
-options IPSTEALTH #support for stealth forwarding
-options TCPDEBUG
-
-# The following options add sysctl variables for controlling how certain
-# TCP packets are handled.
-#
-# TCP_DROP_SYNFIN adds support for ignoring TCP packets with SYN+FIN. This
-# prevents nmap et al. from identifying the TCP/IP stack, but breaks support
-# for RFC1644 extensions and is not recommended for web servers.
-#
-# TCP_RESTRICT_RST adds support for blocking the emission of TCP RST packets.
-# This is useful on systems which are exposed to SYN floods (e.g. IRC servers)
-# or any system which one does not want to be easily portscannable.
-#
-options TCP_DROP_SYNFIN #drop TCP packets with SYN+FIN
-options TCP_RESTRICT_RST #restrict emission of TCP RST
-
-# ICMP_BANDLIM enables icmp error response bandwidth limiting. You
-# typically want this option as it will help protect the machine from
-# D.O.S. packet attacks.
-#
-options ICMP_BANDLIM
-
-# DUMMYNET enables the "dummynet" bandwidth limiter. You need
-# IPFIREWALL as well. See the dummynet(4) manpage for more info.
-# BRIDGE enables bridging between ethernet cards -- see bridge(4).
-# You can use IPFIREWALL and dummynet together with bridging.
-options DUMMYNET
-options BRIDGE
-
-#
-# ATM (HARP version) options
-#
-# ATM_CORE includes the base ATM functionality code. This must be included
-# for ATM support.
-#
-# ATM_IP includes support for running IP over ATM.
-#
-# At least one (and usually only one) of the following signalling managers
-# must be included (note that all signalling managers include PVC support):
-# ATM_SIGPVC includes support for the PVC-only signalling manager `sigpvc'.
-# ATM_SPANS includes support for the `spans' signalling manager, which runs
-# the FORE Systems's proprietary SPANS signalling protocol.
-# ATM_UNI includes support for the `uni30' and `uni31' signalling managers,
-# which run the ATM Forum UNI 3.x signalling protocols.
-#
-# The `hea' driver provides support for the Efficient Networks, Inc.
-# ENI-155p ATM PCI Adapter.
-#
-# The `hfa' driver provides support for the FORE Systems, Inc.
-# PCA-200E ATM PCI Adapter.
-#
-options ATM_CORE #core ATM protocol family
-options ATM_IP #IP over ATM support
-options ATM_SIGPVC #SIGPVC signalling manager
-options ATM_SPANS #SPANS signalling manager
-options ATM_UNI #UNI signalling manager
-device hea #Efficient ENI-155p ATM PCI
-device hfa #FORE PCA-200E ATM PCI
-
-
-#####################################################################
-# FILESYSTEM OPTIONS
-
-#
-# Only the root, /usr, and /tmp filesystems need be statically
-# compiled; everything else will be automatically loaded at mount
-# time. (Exception: the UFS family---FFS, and MFS --- cannot
-# currently be demand-loaded.) Some people still prefer to statically
-# compile other filesystems as well.
-#
-# NB: The NULL, PORTAL, UMAP and UNION filesystems are known to be
-# buggy, and WILL panic your system if you attempt to do anything with
-# them. They are included here as an incentive for some enterprising
-# soul to sit down and fix them.
-#
-
-# One of these is mandatory:
-options FFS #Fast filesystem
-options MFS #Memory File System
-options NFS #Network File System
-
-# The rest are optional:
-#options NFS_NOSERVER #Disable the NFS-server code.
-options CD9660 #ISO 9660 filesystem
-options FDESC #File descriptor filesystem
-options KERNFS #Kernel filesystem
-options MSDOSFS #MS DOS File System
-options NTFS #NT File System
-options NULLFS #NULL filesystem
-options NWFS #NetWare filesystem
-options PORTAL #Portal filesystem
-options PROCFS #Process filesystem
-options UMAPFS #UID map filesystem
-options UNION #Union filesystem
-# The xFS_ROOT options REQUIRE the associated ``options xFS''
-options CD9660_ROOT #CD-ROM usable as root device
-options FFS_ROOT #FFS usable as root device
-options NFS_ROOT #NFS usable as root device
-# This code is still experimental (e.g. doesn't handle disk slices well).
-# Also, 'options MFS' is currently incompatible with DEVFS.
-options DEVFS #devices filesystem
-
-# Soft updates is technique for improving file system speed and
-# making abrupt shutdown less risky. It is not enabled by default due
-# to copyright restraints on the code that implement it.
-#
-# Read ../../ufs/ffs/README.softupdates to learn what you need to
-# do to enable this. ../../contrib/softupdates/README gives
-# more details on how they actually work.
-#
-#options SOFTUPDATES
-
-# Make space in the kernel for a root filesystem on a md device.
-# Define to the number of kilobytes to reserve for the filesystem.
-options MD_ROOT_SIZE=10
-
-# Make the md device a potential root device, either with preloaded
-# images of type mfs_root or md_root.
-options MD_ROOT
-
-# Allow this many swap-devices.
-options NSWAPDEV=20
-
-# Disk quotas are supported when this option is enabled.
-options QUOTA #enable disk quotas
-
-# If you are running a machine just as a fileserver for PC and MAC
-# users, using SAMBA or Netatalk, you may consider setting this option
-# and keeping all those users' directories on a filesystem that is
-# mounted with the suiddir option. This gives new files the same
-# ownership as the directory (similar to group). It's a security hole
-# if you let these users run programs, so confine it to file-servers
-# (but it'll save you lots of headaches in those cases). Root owned
-# directories are exempt and X bits are cleared. The suid bit must be
-# set on the directory as well; see chmod(1) PC owners can't see/set
-# ownerships so they keep getting their toes trodden on. This saves
-# you all the support calls as the filesystem it's used on will act as
-# they expect: "It's my dir so it must be my file".
-#
-options SUIDDIR
-
-# NFS options:
-options NFS_MINATTRTIMO=3 # VREG attrib cache timeout in sec
-options NFS_MAXATTRTIMO=60
-options NFS_MINDIRATTRTIMO=30 # VDIR attrib cache timeout in sec
-options NFS_MAXDIRATTRTIMO=60
-options NFS_GATHERDELAY=10 # Default write gather delay (msec)
-options NFS_UIDHASHSIZ=29 # Tune the size of nfssvc_sock with this
-options NFS_WDELAYHASHSIZ=16 # and with this
-options NFS_MUIDHASHSIZ=63 # Tune the size of nfsmount with this
-options NFS_DEBUG # Enable NFS Debugging
-
-# Coda stuff:
-options CODA #CODA filesystem.
-pseudo-device vcoda 4 #coda minicache <-> venus comm.
-
-#
-# Add support for the EXT2FS filesystem of Linux fame. Be a bit
-# careful with this - the ext2fs code has a tendency to lag behind
-# changes and not be exercised very much, so mounting read/write could
-# be dangerous (and even mounting read only could result in panics.)
-#
-options EXT2FS
-
-# Use real implementations of the aio_* system calls. There are numerous
-# stability issues in the current aio code that make it unsuitable for
-# inclusion on shell boxes.
-options VFS_AIO
-
-
-#####################################################################
-# POSIX P1003.1B
-
-# Real time extensions added in the 1993 Posix
-# P1003_1B: Infrastructure
-# _KPOSIX_PRIORITY_SCHEDULING: Build in _POSIX_PRIORITY_SCHEDULING
-# _KPOSIX_VERSION: Version kernel is built for
-
-options P1003_1B
-options _KPOSIX_PRIORITY_SCHEDULING
-options _KPOSIX_VERSION=199309L
-
-
-#####################################################################
-# SCSI DEVICES
-
-# SCSI DEVICE CONFIGURATION
-
-# The SCSI subsystem consists of the `base' SCSI code, a number of
-# high-level SCSI device `type' drivers, and the low-level host-adapter
-# device drivers. The host adapters are listed in the ISA and PCI
-# device configuration sections below.
-#
-# Beginning with FreeBSD 2.0.5 you can wire down your SCSI devices so
-# that a given bus, target, and LUN always come on line as the same
-# device unit. In earlier versions the unit numbers were assigned
-# in the order that the devices were probed on the SCSI bus. This
-# means that if you removed a disk drive, you may have had to rewrite
-# your /etc/fstab file, and also that you had to be careful when adding
-# a new disk as it may have been probed earlier and moved your device
-# configuration around.
-
-# This old behavior is maintained as the default behavior. The unit
-# assignment begins with the first non-wired down unit for a device
-# type. For example, if you wire a disk as "da3" then the first
-# non-wired disk will be assigned da4.
-
-# The syntax for wiring down devices is:
-
-# device scbus0 at ahc0 # Single bus device
-# device scbus1 at ahc1 bus 0 # Single bus device
-# device scbus3 at ahc2 bus 0 # Twin bus device
-# device scbus2 at ahc2 bus 1 # Twin bus device
-# device da0 at scbus0 target 0 unit 0
-# device da1 at scbus3 target 1
-# device da2 at scbus2 target 3
-# device sa1 at scbus1 target 6
-# device cd
-
-# "units" (SCSI logical unit number) that are not specified are
-# treated as if specified as LUN 0.
-
-# All SCSI devices allocate as many units as are required.
-
-# The "unknown" device (uk? in pre-2.0.5) is now part of the base SCSI
-# configuration and doesn't have to be explicitly configured.
-
-device scbus #base SCSI code
-device ch #SCSI media changers
-device da #SCSI direct access devices (aka disks)
-device sa #SCSI tapes
-device cd #SCSI CD-ROMs
-device pass #CAM passthrough driver
-device pt #SCSI processor type
-device ses #SCSI SES/SAF-TE driver
-
-# CAM OPTIONS:
-# debugging options:
-# -- NOTE -- If you specify one of the bus/target/lun options, you must
-# specify them all!
-# CAMDEBUG: When defined enables debugging macros
-# CAM_DEBUG_BUS: Debug the given bus. Use -1 to debug all busses.
-# CAM_DEBUG_TARGET: Debug the given target. Use -1 to debug all targets.
-# CAM_DEBUG_LUN: Debug the given lun. Use -1 to debug all luns.
-# CAM_DEBUG_FLAGS: OR together CAM_DEBUG_INFO, CAM_DEBUG_TRACE,
-# CAM_DEBUG_SUBTRACE, and CAM_DEBUG_CDB
-#
-# CAM_MAX_HIGHPOWER: Maximum number of concurrent high power (start unit) cmds
-# SCSI_NO_SENSE_STRINGS: When defined disables sense descriptions
-# SCSI_NO_OP_STRINGS: When defined disables opcode descriptions
-# SCSI_DELAY: The number of MILLISECONDS to freeze the SIM (scsi adapter)
-# queue after a bus reset, and the number of milliseconds to
-# freeze the device queue after a bus device reset.
-options CAMDEBUG
-options CAM_DEBUG_BUS=-1
-options CAM_DEBUG_TARGET=-1
-options CAM_DEBUG_LUN=-1
-options CAM_DEBUG_FLAGS="CAM_DEBUG_INFO|CAM_DEBUG_TRACE|CAM_DEBUG_CDB"
-options CAM_MAX_HIGHPOWER=4
-options SCSI_NO_SENSE_STRINGS
-options SCSI_NO_OP_STRINGS
-options SCSI_DELAY=8000 # Be pessimistic about Joe SCSI device
-
-# Options for the CAM CDROM driver:
-# CHANGER_MIN_BUSY_SECONDS: Guaranteed minimum time quantum for a changer LUN
-# CHANGER_MAX_BUSY_SECONDS: Maximum time quantum per changer LUN, only
-# enforced if there is I/O waiting for another LUN
-# The compiled in defaults for these variables are 2 and 10 seconds,
-# respectively.
-#
-# These can also be changed on the fly with the following sysctl variables:
-# kern.cam.cd.changer.min_busy_seconds
-# kern.cam.cd.changer.max_busy_seconds
-#
-options CHANGER_MIN_BUSY_SECONDS=2
-options CHANGER_MAX_BUSY_SECONDS=10
-
-# Options for the CAM sequential access driver:
-# SA_SPACE_TIMEOUT: Timeout for space operations, in minutes
-# SA_REWIND_TIMEOUT: Timeout for rewind operations, in minutes
-# SA_ERASE_TIMEOUT: Timeout for erase operations, in minutes
-# SA_1FM_AT_EOD: Default to model which only has a default one filemark at EOT.
-options SA_SPACE_TIMEOUT="(60)"
-options SA_REWIND_TIMEOUT="(2*60)"
-options SA_ERASE_TIMEOUT="(4*60)"
-options SA_1FM_AT_EOD
-
-# Optional timeout for the CAM processor target (pt) device
-# This is specified in seconds. The default is 60 seconds.
-options SCSI_PT_DEFAULT_TIMEOUT="60"
-
-# Optional enable of doing SES passthrough on other devices (e.g., disks)
-#
-# Normally disabled because a lot of newer SCSI disks report themselves
-# as having SES capabilities, but this can then clot up attempts to build
-# build a topology with the SES device that's on the box these drives
-# are in....
-options SES_ENABLE_PASSTHROUGH
-
-
-#####################################################################
-# MISCELLANEOUS DEVICES AND OPTIONS
-
-# The `pty' device usually turns out to be ``effectively mandatory'',
-# as it is required for `telnetd', `rlogind', `screen', `emacs', and
-# `xterm', among others.
-
-pseudo-device pty #Pseudo ttys
-pseudo-device speaker #Play IBM BASIC-style noises out your speaker
-pseudo-device gzip #Exec gzipped a.out's
-pseudo-device vn #Vnode driver (turns a file into a device)
-pseudo-device md #Memory/malloc disk
-pseudo-device snp 3 #Snoop device - to look at pty/vty/etc..
-pseudo-device ccd 4 #Concatenated disk driver
-
-# Configuring Vinum into the kernel is not necessary, since the kld
-# module gets started automatically when vinum(8) starts. This
-# device is also untested. Use at your own risk.
-#
-# The option VINUMDEBUG must match the value set in CFLAGS
-# in src/sbin/vinum/Makefile. Failure to do so will result in
-# the following message from vinum(8):
-#
-# Can't get vinum config: Invalid argument
-#
-# see vinum(4) for more reasons not to use these options.
-pseudo-device vinum #Vinum concat/mirror/raid driver
-options VINUMDEBUG #enable Vinum debugging hooks
-
-# Size of the kernel message buffer. Should be N * pagesize.
-options MSGBUF_SIZE=40960
-
-
-#####################################################################
-# HARDWARE DEVICE CONFIGURATION
-
-# ISA and EISA devices:
-# EISA support is available for some device, so they can be auto-probed.
-# MicroChannel (MCA) support is available for some devices.
-
-#
-# Mandatory ISA devices: isa, npx
-#
-device isa
-
-#
-# Options for `isa':
-#
-# AUTO_EOI_1 enables the `automatic EOI' feature for the master 8259A
-# interrupt controller. This saves about 0.7-1.25 usec for each interrupt.
-# This option breaks suspend/resume on some portables.
-#
-# AUTO_EOI_2 enables the `automatic EOI' feature for the slave 8259A
-# interrupt controller. This saves about 0.7-1.25 usec for each interrupt.
-# Automatic EOI is documented not to work for for the slave with the
-# original i8259A, but it works for some clones and some integrated
-# versions.
-#
-# MAXMEM specifies the amount of RAM on the machine; if this is not
-# specified, FreeBSD will first read the amount of memory from the CMOS
-# RAM, so the amount of memory will initially be limited to 64MB or 16MB
-# depending on the BIOS. If the BIOS reports 64MB, a memory probe will
-# then attempt to detect the installed amount of RAM. If this probe
-# fails to detect >64MB RAM you will have to use the MAXMEM option.
-# The amount is in kilobytes, so for a machine with 128MB of RAM, it would
-# be 131072 (128 * 1024).
-#
-# BROKEN_KEYBOARD_RESET disables the use of the keyboard controller to
-# reset the CPU for reboot. This is needed on some systems with broken
-# keyboard controllers.
-#
-# PAS_JOYSTICK_ENABLE enables the gameport on the ProAudio Spectrum
-
-options AUTO_EOI_1
-#options AUTO_EOI_2
-options MAXMEM="(128*1024)"
-#options BROKEN_KEYBOARD_RESET
-#options PAS_JOYSTICK_ENABLE
-
-# Enable support for the kernel PLL to use an external PPS signal,
-# under supervision of [x]ntpd(8)
-# More info in ntpd documentation: http://www.eecis.udel.edu/~ntp
-
-options PPS_SYNC
-
-# If you see the "calcru: negative time of %ld usec for pid %d (%s)\n"
-# message you probably have some broken sw/hw which disables interrupts
-# for too long. You can make the system more resistant to this by
-# choosing a high value for NTIMECOUNTER. The default is 5, there
-# is no upper limit but more than a couple of hundred are not productive.
-# A better strategy may be to sysctl -w kern.timecounter.method=1
-
-options NTIMECOUNTER=20
-
-# The keyboard controller; it controls the keyboard and the PS/2 mouse.
-device atkbdc0 at isa? port IO_KBD
-
-# The AT keyboard
-device atkbd0 at atkbdc? irq 1
-
-# Options for atkbd:
-options ATKBD_DFLT_KEYMAP # specify the built-in keymap
-makeoptions ATKBD_DFLT_KEYMAP="jp.106"
-
-# These options are valid for other keyboard drivers as well.
-options KBD_DISABLE_KEYMAP_LOAD # refuse to load a keymap
-options KBD_INSTALL_CDEV # install a CDEV entry in /dev
-
-# `flags' for atkbd:
-# 0x01 Force detection of keyboard, else we always assume a keyboard
-# 0x02 Don't reset keyboard, useful for some newer ThinkPads
-# 0x04 Old-style (XT) keyboard support, useful for older ThinkPads
-
-# PS/2 mouse
-device psm0 at atkbdc? irq 12
-
-# Options for psm:
-options PSM_HOOKRESUME #hook the system resume event, useful
- #for some laptops
-options PSM_RESETAFTERSUSPEND #reset the device at the resume event
-
-# The video card driver.
-device vga0 at isa?
-
-# Options for vga:
-# Try the following option if the mouse pointer is not drawn correctly
-# or font does not seem to be loaded properly. May cause flicker on
-# some systems.
-options VGA_ALT_SEQACCESS
-
-# If you can dispense with some vga driver features, you may want to
-# use the following options to save some memory.
-options VGA_NO_FONT_LOADING # don't save/load font
-options VGA_NO_MODE_CHANGE # don't change video modes
-
-# Older video cards may require this option for proper operation.
-options VGA_SLOW_IOACCESS # do byte-wide i/o's to TS and GDC regs
-
-# The following option probably won't work with the LCD displays.
-options VGA_WIDTH90 # support 90 column modes
-
-# To include support for VESA video modes
-options VESA
-
-# Splash screen at start up! Screen savers require this too.
-pseudo-device splash
-
-# The pcvt console driver (vt220 compatible).
-device vt0 at isa?
-options XSERVER # support for running an X server on vt
-options FAT_CURSOR # start with block cursor
-# This PCVT option is for keyboards such as those used on IBM ThinkPad laptops
-options PCVT_SCANSET=2 # IBM keyboards are non-std
-# Other PCVT options are documented in pcvt(4).
-options PCVT_24LINESDEF
-options PCVT_CTRL_ALT_DEL
-options PCVT_EMU_MOUSE
-options PCVT_FREEBSD=211
-options PCVT_META_ESC
-options PCVT_NSCREENS=9
-options PCVT_PRETTYSCRNS
-options PCVT_SCREENSAVER
-options PCVT_USEKBDSEC
-options PCVT_VT220KEYB
-
-# The syscons console driver (sco color console compatible).
-device sc0 at isa?
-options MAXCONS=16 # number of virtual consoles
-options SC_ALT_MOUSE_IMAGE # simplified mouse cursor in text mode
-options SC_DFLT_FONT # compile font in
-makeoptions SC_DFLT_FONT=cp850
-options SC_DISABLE_DDBKEY # disable `debug' key
-options SC_DISABLE_REBOOT # disable reboot key sequence
-options SC_HISTORY_SIZE=200 # number of history buffer lines
-options SC_MOUSE_CHAR=0x3 # char code for text mode mouse cursor
-options SC_PIXEL_MODE # add support for the raster text mode
-
-# The following options will let you change the default colors of syscons.
-options SC_NORM_ATTR="(FG_GREEN|BG_BLACK)"
-options SC_NORM_REV_ATTR="(FG_YELLOW|BG_GREEN)"
-options SC_KERNEL_CONS_ATTR="(FG_RED|BG_BLACK)"
-options SC_KERNEL_CONS_REV_ATTR="(FG_BLACK|BG_RED)"
-
-# If you have a two button mouse, you may want to add the following option
-# to use the right button of the mouse to paste text.
-options SC_TWOBUTTON_MOUSE
-
-# You can selectively disable features in syscons.
-options SC_NO_CUTPASTE
-options SC_NO_FONT_LOADING
-options SC_NO_HISTORY
-options SC_NO_SYSMOUSE
-
-#
-# The Numeric Processing eXtension driver. In addition to this, you
-# may configure a math emulator (see above). If your machine has a
-# hardware FPU and the kernel configuration includes the npx device
-# *and* a math emulator compiled into the kernel, the hardware FPU
-# will be used, unless it is found to be broken or unless "flags" to
-# npx0 includes "0x08", which requests preference for the emulator.
-device npx0 at nexus? port IO_NPX flags 0x0 irq 13
-
-#
-# `flags' for npx0:
-# 0x01 don't use the npx registers to optimize bcopy.
-# 0x02 don't use the npx registers to optimize bzero.
-# 0x04 don't use the npx registers to optimize copyin or copyout.
-# 0x08 use emulator even if hardware FPU is available.
-# The npx registers are normally used to optimize copying and zeroing when
-# all of the following conditions are satisfied:
-# I586_CPU is an option
-# the cpu is an i586 (perhaps not a Pentium)
-# the probe for npx0 succeeds
-# INT 16 exception handling works.
-# Then copying and zeroing using the npx registers is normally 30-100% faster.
-# The flags can be used to control cases where it doesn't work or is slower.
-# Setting them at boot time using userconfig works right (the optimizations
-# are not used until later in the bootstrap when npx0 is attached).
-# Flag 0x08 automatically disables the i586 optimized routines.
-#
-
-#
-# Optional ISA and EISA devices:
-#
-
-#
-# SCSI host adapters: `aha', `aic', `bt'
-#
-# adv: All Narrow SCSI bus AdvanSys controllers.
-# adw: Second Generation AdvanSys controllers including the ADV940UW.
-# aha: Adaptec 154x
-# ahc: Adaptec 274x/284x/294x
-# aic: Adaptec 152x
-# bt: Most Buslogic controllers
-#
-# Note that the order is important in order for Buslogic cards to be
-# probed correctly.
-#
-
-device bt0 at isa? port IO_BT0
-device adv0 at isa?
-device adw
-device aha0 at isa?
-device aic0 at isa?
-
-#
-# Compaq Smart RAID, Mylex DAC960 and AMI MegaRAID controllers. Only
-# one entry is needed; the code will find and configure all supported
-# controllers.
-#
-device ida # Compaq Smart RAID
-device mlx # Mylex DAC960
-device amr # AMI MegaRAID
-
-#
-# The 'ATA' driver supports all ATA and ATAPI devices.
-# It can reuse the majors of wd.c for booting purposes.
-# You only need one "device ata" for it to find all
-# PCI ATA/ATAPI devices on modern machines.
-device ata
-device atadisk # ATA disk drives
-device atapicd # ATAPI CDROM drives
-device atapifd # ATAPI floppy drives
-device atapist # ATAPI tape drives
-
-#The folliwing options are valid on the ATA driver:
-#
-# ATA_STATIC_ID: controller numbering is static (like the old driver)
-# else the device numbers are dynamically allocated.
-# ATA_ENABLE_ATAPI_DMA: enable DMA on ATAPI device, since many ATAPI devices
-# claim to support DMA but doesn't actually work, this
-# is not enabled as default.
-
-options ATA_STATIC_ID
-options ATA_ENABLE_ATAPI_DMA
-
-#
-# For older non-PCI systems, these are the lines to use:
-#device ata0 at isa? port IO_WD1 irq 14
-#device ata1 at isa? port IO_WD2 irq 15
-
-#
-# ST-506, ESDI, and IDE hard disks: `wdc' and `wd'
-#
-# The flags fields are used to enable the multi-sector I/O and
-# the 32BIT I/O modes. The flags may be used in either the controller
-# definition or in the individual disk definitions. The controller
-# definition is supported for the boot configuration stuff.
-#
-# Each drive has a 16 bit flags value defined:
-# The low 8 bits are the maximum value for the multi-sector I/O,
-# where 0xff defaults to the maximum that the drive can handle.
-# The high bit of the 16 bit flags (0x8000) allows probing for
-# 32 bit transfers. Bit 14 (0x4000) enables a hack to wake
-# up powered-down laptop drives. Bit 13 (0x2000) allows
-# probing for PCI IDE DMA controllers, such as Intel's PIIX
-# south bridges. Bit 12 (0x1000) sets LBA mode instead of the
-# default CHS mode for accessing the drive. See the wd.4 man page.
-#
-# The flags field for the drives can be specified in the controller
-# specification with the low 16 bits for drive 0, and the high 16 bits
-# for drive 1.
-# e.g.:
-#device wdc0 at isa? port IO_WD1 irq 14 flags 0x00ff8004
-#
-# specifies that drive 0 will be allowed to probe for 32 bit transfers and
-# a maximum multi-sector transfer of 4 sectors, and drive 1 will not be
-# allowed to probe for 32 bit transfers, but will allow multi-sector
-# transfers up to the maximum that the drive supports.
-#
-# If you are using a PCI controller that is not running in compatibility
-# mode (for example, it is a 2nd IDE PCI interface), then use config line(s)
-# such as:
-#
-#device wdc2 at isa? port 0 flags 0xa0ffa0ff
-#device wd4 at wdc2 drive 0
-#device wd5 at wdc2 drive 1
-#
-#device wdc3 at isa? port 0 flags 0xa0ffa0ff
-#device wd6 at wdc3 drive 0
-#device wd7 at wdc3 drive 1
-#
-# Note that the above config would be useful for a Promise card, when used
-# on a MB that already has a PIIX controller. Note the bogus irq and port
-# entries. These are automatically filled in by the IDE/PCI support.
-#
-# This driver must be commented out because it is mutually exclusive with
-# the ata(4) driver.
-#
-device wdc0 at isa? port IO_WD1 irq 14
-device wd0 at wdc0 drive 0
-device wd1 at wdc0 drive 1
-device wdc1 at isa? port IO_WD2 irq 15
-device wd2 at wdc1 drive 0
-device wd3 at wdc1 drive 1
-
-#
-# This option allow you to override the default probe time for IDE
-# devices, to get a faster probe. Setting this below 10000 violate
-# the IDE specs, but may still work for you (it will work for most
-# people).
-#
-options IDE_DELAY=8000 # Be optimistic about Joe IDE device
-
-# IDE CD-ROM & CD-R/RW driver - requires wdc controller
-device wcd
-
-# IDE floppy driver - requires wdc controller
-device wfd
-
-# IDE tape driver - requires wdc controller
-device wst
-
-
-#
-# Standard floppy disk controllers and floppy tapes: `fdc', `fd', and `ft'
-#
-device fdc0 at isa? port IO_FD1 irq 6 drq 2
-#
-# FDC_DEBUG enables floppy debugging. Since the debug output is huge, you
-# gotta turn it actually on by setting the variable fd_debug with DDB,
-# however.
-options FDC_DEBUG
-#
-# Activate this line instead of the fdc0 line above if you happen to
-# have an Insight floppy tape. Probing them proved to be dangerous
-# for people with floppy disks only, so it's "hidden" behind a flag:
-#device fdc0 at isa? port IO_FD1 flags 1 irq 6 drq 2
-
-device fd0 at fdc0 drive 0
-device fd1 at fdc0 drive 1
-
-# M-systems DiskOnchip products see src/sys/contrib/dev/fla/README
-device fla0 at isa?
-
-#
-# Other standard PC hardware: `mse', `sio', etc.
-#
-# mse: Logitech and ATI InPort bus mouse ports
-# sio: serial ports (see sio(4))
-
-device mse0 at isa? port 0x23c irq 5
-
-device sio0 at isa? port IO_COM1 flags 0x10 irq 4
-
-#
-# `flags' for serial drivers that support consoles (only for sio now):
-# 0x10 enable console support for this unit. The other console flags
-# are ignored unless this is set. Enabling console support does
-# not make the unit the preferred console - boot with -h or set
-# the 0x20 flag for that. Currently, at most one unit can have
-# console support; the first one (in config file order) with
-# this flag set is preferred. Setting this flag for sio0 gives
-# the old behaviour.
-# 0x20 force this unit to be the console (unless there is another
-# higher priority console). This replaces the COMCONSOLE option.
-# 0x40 reserve this unit for low level console operations. Do not
-# access the device in any normal way.
-# 0x80 use this port for serial line gdb support in ddb.
-#
-# PnP `flags' (set via userconfig using pnp x flags y)
-# 0x1 disable probing of this device. Used to prevent your modem
-# from being attached as a PnP modem.
-#
-
-# Options for serial drivers that support consoles (only for sio now):
-options BREAK_TO_DEBUGGER #a BREAK on a comconsole goes to
- #DDB, if available.
-options CONSPEED=9600 #default speed for serial console (default 9600)
-
-# Options for sio:
-options COM_ESP #code for Hayes ESP
-options COM_MULTIPORT #code for some cards with shared IRQs
-
-# Other flags for sio that aren't documented in the man page.
-# 0x20000 enable hardware RTS/CTS and larger FIFOs. Only works for
-# ST16650A-compatible UARTs.
-
-#
-# Network interfaces: `cx', `ed', `el', `ep', `ie', `is', `le', `lnc'
-#
-# ar: Arnet SYNC/570i hdlc sync 2/4 port V.35/X.21 serial driver (requires sppp)
-# cs: IBM Etherjet and other Crystal Semi CS89x0-based adapters
-# cx: Cronyx/Sigma multiport sync/async (with Cisco or PPP framing)
-# ed: Western Digital and SMC 80xx; Novell NE1000 and NE2000; 3Com 3C503
-# el: 3Com 3C501 (slow!)
-# ep: 3Com 3C509
-# ex: Intel EtherExpress Pro/10 and other i82595-based adapters
-# fe: Fujitsu MB86960A/MB86965A Ethernet
-# ie: AT&T StarLAN 10 and EN100; 3Com 3C507; unknown NI5210; Intel EtherExpress
-# le: Digital Equipment EtherWorks 2 and EtherWorks 3 (DEPCA, DE100,
-# DE101, DE200, DE201, DE202, DE203, DE204, DE205, DE422)
-# lnc: Lance/PCnet cards (Isolan, Novell NE2100, NE32-VL, AMD Am7990 & Am79C960)
-# rdp: RealTek RTL 8002-based pocket ethernet adapters
-# sr: RISCom/N2 hdlc sync 1/2 port V.35/X.21 serial driver (requires sppp)
-# wl: Lucent Wavelan (ISA card only).
-# wi: Lucent WaveLAN/IEEE 802.11 PCMCIA adapters. Note: this supports both
-# the PCMCIA and ISA cards: the ISA card is really a PCMCIA to ISA
-# bridge with a PCMCIA adapter plugged into it.
-# an: Aironet 4500/4800 802.11 wireless adapters. Supports the PCMCIA,
-# PCI and ISA varieties.
-# xe: Xircom/Intel EtherExpress Pro100/16 PC Card ethernet controller.
-# oltr: Olicom ISA token-ring adapters OC-3115, OC-3117, OC-3118 and OC-3133
-# (no options needed)
-#
-device ar0 at isa? port 0x300 irq 10 iomem 0xd0000
-device cs0 at isa? port 0x300
-device cx0 at isa? port 0x240 irq 15 drq 7
-device ed0 at isa? port 0x280 irq 5 iomem 0xd8000
-device el0 at isa? port 0x300 irq 9
-device ep
-device ex
-device fe0 at isa? port 0x300
-device ie0 at isa? port 0x300 irq 5 iomem 0xd0000
-device ie1 at isa? port 0x360 irq 7 iomem 0xd0000
-device le0 at isa? port 0x300 irq 5 iomem 0xd0000
-device lnc0 at isa? port 0x280 irq 10 drq 0
-device rdp0 at isa? port 0x378 irq 7 flags 2
-device sr0 at isa? port 0x300 irq 5 iomem 0xd0000
-device sn0 at isa? port 0x300 irq 10
-device wi
-device an
-options WLCACHE # enables the signal-strength cache
-options WLDEBUG # enables verbose debugging output
-device wl0 at isa? port 0x300
-device xe0 at isa?
-
-device oltr0 at isa?
-
-#
-# ATM related options
-#
-# The `en' device provides support for Efficient Networks (ENI)
-# ENI-155 PCI midway cards, and the Adaptec 155Mbps PCI ATM cards (ANA-59x0).
-#
-# atm pseudo-device provides generic atm functions and is required for
-# atm devices.
-# NATM enables the netnatm protocol family that can be used to
-# bypass TCP/IP.
-#
-# the current driver supports only PVC operations (no atm-arp, no multicast).
-# for more details, please read the original documents at
-# http://www.ccrc.wustl.edu/pub/chuck/tech/bsdatm/bsdatm.html
-#
-pseudo-device atm
-device en
-options NATM #native ATM
-
-#
-# Audio drivers: `snd', `sb', `pas', `gus', `pca'
-#
-# snd: Voxware sound support code
-# sb: SoundBlaster PCM - SoundBlaster, SB Pro, SB16, ProAudioSpectrum
-# sbxvi: SoundBlaster 16
-# sbmidi: SoundBlaster 16 MIDI interface
-# pas: ProAudioSpectrum PCM and MIDI
-# gus: Gravis Ultrasound - Ultrasound, Ultrasound 16, Ultrasound MAX
-# gusxvi: Gravis Ultrasound 16-bit PCM (do not use)
-# mss: Microsoft Sound System
-# css: Crystal Sound System (CSS 423x PnP)
-# sscape: Ensoniq Soundscape MIDI interface
-# sscape_mss: Ensoniq Soundscape PCM (requires sscape)
-# opl: Yamaha OPL-2 and OPL-3 FM - SB, SB Pro, SB 16, ProAudioSpectrum
-# uart: stand-alone 6850 UART for MIDI
-# mpu: Roland MPU-401 stand-alone card
-#
-# Note: It has been reported that ISA DMA with the SoundBlaster will
-# lock up the machine (PR docs/5358). If this happens to you,
-# turning off USWC write posting in your machine's BIOS may fix
-# the problem.
-#
-# Beware! The addresses specified below are also hard-coded in
-# src/sys/i386/isa/sound/sound_config.h. If you change the values here, you
-# must also change the values in the include file.
-#
-# pcm: PCM audio through various sound cards.
-#
-# This has support for a large number of new audio cards, based on
-# CS423x, OPTi931, Yamaha OPL-SAx, and also for SB16, GusPnP.
-# For more information about this driver and supported cards,
-# see the pcm.4 man page.
-#
-# The flags of the device tells the device a bit more info about the
-# device that normally is obtained through the PnP interface.
-# bit 2..0 secondary DMA channel;
-# bit 4 set if the board uses two dma channels;
-# bit 15..8 board type, overrides autodetection; leave it
-# zero if don't know what to put in (and you don't,
-# since this is unsupported at the moment...).
-#
-# This driver will use the new PnP code if it's available.
-#
-# pca: PCM audio through your PC speaker
-#
-# If you have a GUS-MAX card and want to use the CS4231 codec on the
-# card the drqs for the gus max must be 8 bit (1, 2, or 3).
-#
-# If you would like to use the full duplex option on the gus, then define
-# flags to be the ``read dma channel''.
-#
-# options BROKEN_BUS_CLOCK #PAS-16 isn't working and OPTI chipset
-# options SYMPHONY_PAS #PAS-16 isn't working and SYMPHONY chipset
-# options EXCLUDE_SBPRO #PAS-16
-# options SBC_IRQ=5 #PAS-16. Must match irq on sb0 line.
-# PAS16: The order of the pas0/sb0/opl0 is important since the
-# sb emulation is enabled in the pas-16 attach.
-#
-# To override the GUS defaults use:
-# options GUS_DMA2
-# options GUS_DMA
-# options GUS_IRQ
-#
-# The src/sys/i386/isa/sound/sound.doc has more information.
-
-# Controls all "VOXWARE" driver sound devices. See Luigi's driver
-# below for an alternate which may work better for some cards.
-#
-#device snd
-#device pas0 at isa? port 0x388 irq 10 drq 6
-#device sb0 at isa? port 0x220 irq 5 drq 1
-#device sbxvi0 at isa? drq 5
-#device sbmidi0 at isa? port 0x330
-#device awe0 at isa? port 0x620
-#device gus0 at isa? port 0x220 irq 12 drq 1
-##device gus0 at isa? port 0x220 irq 12 drq 1 flags 0x3
-#device mss0 at isa? port 0x530 irq 10 drq 1
-#device css0 at isa? port 0x534 irq 5 drq 1 flags 0x08
-#device sscape0 at isa? port 0x330 irq 9 drq 0
-#device trix0 at isa? port 0x330 irq 6 drq 0
-#device sscape_mss0 at isa? port 0x534 irq 5 drq 1
-#device opl0 at isa? port 0x388
-#device mpu0 at isa? port 0x330 irq 6 drq 0
-#device uart0 at isa? port 0x330 irq 5
-
-# The newpcm driver (use INSTEAD of snd0 and all VOXWARE drivers!).
-# Note that motherboard sound devices may require options PNPBIOS.
-#
-# Supported cards include:
-# Creative SoundBlaster ISA PnP/non-PnP
-# Supports ESS and Avance ISA chips as well.
-# Gravis UltraSound ISA PnP/non-PnP
-# Crystal Semiconductor CS461x/428x PCI
-# Neomagic 256AV (ac97)
-# Most of the more common ISA/PnP sb/mss/ess compatable cards.
-
-# For non-pnp sound cards with no bridge drivers only:
-device pcm0 at isa? irq 10 drq 1 flags 0x0
-#
-# For PnP/PCI sound cards
-device pcm
-
-# The bridge drivers for sound cards. These can be seperately configured
-# for providing services to the likes of new-midi (not in the tree yet).
-# When used with 'device pcm' they also provide pcm sound services.
-#
-# sbc: Creative SoundBlaster ISA PnP/non-PnP
-# Supports ESS and Avance ISA chips as well.
-# gusc: Gravis UltraSound ISA PnP/non-PnP
-# csa: Crystal Semiconductor CS461x/428x PCI
-
-# For non-PnP cards:
-device sbc0 at isa? port 0x220 irq 5 drq 1 flags 0x15
-device gusc0 at isa? port 0x220 irq 5 drq 1 flags 0x13
-
-# Not controlled by `snd'
-device pca0 at isa? port IO_TIMER1
-
-#
-# Miscellaneous hardware:
-#
-# mcd: Mitsumi CD-ROM
-# scd: Sony CD-ROM
-# matcd: Matsushita/Panasonic CD-ROM
-# wt: Wangtek and Archive QIC-02/QIC-36 tape drives
-# ctx: Cortex-I frame grabber
-# apm: Laptop Advanced Power Management (experimental)
-# spigot: The Creative Labs Video Spigot video-acquisition board
-# meteor: Matrox Meteor video capture board
-# bktr: Brooktree bt848/848a/849a/878/879 video capture and TV Tuner board
-# cy: Cyclades serial driver
-# dgb: Digiboard PC/Xi and PC/Xe series driver (ALPHA QUALITY!)
-# dgm: Digiboard PC/Xem driver
-# gp: National Instruments AT-GPIB and AT-GPIB/TNT board
-# asc: GI1904-based hand scanners, e.g. the Trust Amiscan Grey
-# gsc: Genius GS-4500 hand scanner.
-# joy: joystick
-# labpc: National Instrument's Lab-PC and Lab-PC+
-# rc: RISCom/8 multiport card
-# rp: Comtrol Rocketport(ISA) - single card
-# tw: TW-523 power line interface for use with X-10 home control products
-# si: Specialix SI/XIO 4-32 port terminal multiplexor
-# stl: Stallion EasyIO and EasyConnection 8/32 (cd1400 based)
-# stli: Stallion EasyConnection 8/64, ONboard, Brumby (intelligent)
-
-# Notes on APM
-# The flags takes the following meaning for apm0:
-# 0x0020 Statclock is broken.
-# If apm is omitted, some systems require sysctl -w kern.timecounter.method=1
-# for correct timekeeping.
-
-# Notes on the spigot:
-# The video spigot is at 0xad6. This port address can not be changed.
-# The irq values may only be 10, 11, or 15
-# I/O memory is an 8kb region. Possible values are:
-# 0a0000, 0a2000, ..., 0fffff, f00000, f02000, ..., ffffff
-# The start address must be on an even boundary.
-# Add the following option if you want to allow non-root users to be able
-# to access the spigot. This option is not secure because it allows users
-# direct access to the I/O page.
-# options SPIGOT_UNSECURE
-
-# Notes on the Comtrol Rocketport driver:
-#
-# The exact values used for rp0 depend on how many boards you have
-# in the system. The manufacturer's sample configs are listed as:
-#
-# Comtrol Rocketport ISA single card
-# device rp0 at isa? port 0x280
-#
-# If instead you have two ISA cards, one installed at 0x100 and the
-# second installed at 0x180, then you should add the following to
-# your kernel configuration file:
-#
-# device rp0 at isa? port 0x100
-# device rp1 at isa? port 0x180
-#
-# For 4 ISA cards, it might be something like this:
-#
-# device rp0 at isa? port 0x180
-# device rp1 at isa? port 0x100
-# device rp2 at isa? port 0x340
-# device rp3 at isa? port 0x240
-#
-# And for PCI cards, you only need say:
-#
-# device rp
-
-# Notes on the Digiboard driver:
-#
-# The following flag values have special meanings:
-# 0x01 - alternate layout of pins (dgb & dgm)
-# 0x02 - use the windowed PC/Xe in 64K mode (dgb only)
-
-# Notes on the Specialix SI/XIO driver:
-# **This is NOT a Specialix supported Driver!**
-# The host card is memory, not IO mapped.
-# The Rev 1 host cards use a 64K chunk, on a 32K boundary.
-# The Rev 2 host cards use a 32K chunk, on a 32K boundary.
-# The cards can use an IRQ of 11, 12 or 15.
-
-# Notes on the Stallion stl and stli drivers:
-# See src/i386/isa/README.stl for complete instructions.
-# This is version 0.0.5alpha, unsupported by Stallion.
-# The stl driver has a secondary IO port hard coded at 0x280. You need
-# to change src/i386/isa/stallion.c if you reconfigure this on the boards.
-# The "flags" and "iosiz" settings on the stli driver depend on the board:
-# EasyConnection 8/64 ISA: flags 23 iosiz 0x1000
-# EasyConnection 8/64 EISA: flags 24 iosiz 0x10000
-# EasyConnection 8/64 MCA: flags 25 iosiz 0x1000
-# ONboard ISA: flags 4 iosiz 0x10000
-# ONboard EISA: flags 7 iosiz 0x10000
-# ONboard MCA: flags 3 iosiz 0x10000
-# Brumby: flags 2 iosiz 0x4000
-# Stallion: flags 1 iosiz 0x10000
-
-device mcd0 at isa? port 0x300 irq 10
-# for the Sony CDU31/33A CDROM
-device scd0 at isa? port 0x230
-# for the SoundBlaster 16 multicd - up to 4 devices
-device matcd0 at isa? port 0x230
-device wt0 at isa? port 0x300 irq 5 drq 1
-device ctx0 at isa? port 0x230 iomem 0xd0000
-device spigot0 at isa? port 0xad6 irq 15 iomem 0xee000
-device apm0
-device gp0 at isa? port 0x2c0
-device gsc0 at isa? port IO_GSC1 drq 3
-device joy0 at isa? port IO_GAME
-device cy0 at isa? irq 10 iomem 0xd4000 iosiz 0x2000
-options CY_PCI_FASTINTR # Use with cy_pci unless irq is shared
-device dgb0 at isa? port 0x220 iomem 0xfc000
-options NDGBPORTS=16 # Defaults to 16*NDGB
-device dgm0 at isa? port 0x104 iomem 0xd0000
-device labpc0 at isa? port 0x260 irq 5
-device rc0 at isa? port 0x220 irq 12
-device rp0 at isa? port 0x280
-# the port and irq for tw0 are fictitious
-device tw0 at isa? port 0x380 irq 11
-device si0 at isa? iomem 0xd0000 irq 12
-device asc0 at isa? port IO_ASC1 drq 3 irq 10
-device stl0 at isa? port 0x2a0 irq 10
-device stli0 at isa? port 0x2a0 iomem 0xcc000 flags 23 iosiz 0x1000
-# You are unlikely to have the hardware for loran0 <phk@FreeBSD.org>
-device loran0 at isa? irq 5
-# HOT1 Xilinx 6200 card (http://www.vcc.com/)
-device xrpu
-
-#
-# MCA devices:
-#
-# The MCA bus device is `mca'. It provides auto-detection and
-# configuration support for all devices on the MCA bus.
-#
-# The 'aha' device provides support for the Adaptec 1640
-#
-# The 'bt' device provides support for various Buslogic/Bustek
-# and Storage Dimensions SCSI adapters.
-#
-# The 'ep' device provides support for the 3Com 3C529 ethernet card.
-#
-device mca
-
-#
-# EISA devices:
-#
-# The EISA bus device is `eisa'. It provides auto-detection and
-# configuration support for all devices on the EISA bus.
-#
-# The `ahb' device provides support for the Adaptec 174X adapter.
-#
-# The `ahc' device provides support for the Adaptec 274X and 284X
-# adapters. The 284X, although a VLB card, responds to EISA probes.
-#
-# fea: DEC DEFEA EISA FDDI adapter
-#
-device eisa
-device ahb
-device ahc
-device fea
-
-# The aic7xxx driver will attempt to use memory mapped I/O for all PCI
-# controllers that have it configured only if this option is set. Unfortunately,
-# this doesn't work on some motherboards, which prevents it from being the
-# default.
-options AHC_ALLOW_MEMIO
-
-# The adw driver will attempt to use memory mapped I/O for all PCI
-# controllers that have it configured only if this option is set.
-options ADW_ALLOW_MEMIO
-
-# By default, only 10 EISA slots are probed, since the slot numbers
-# above clash with the configuration address space of the PCI subsystem,
-# and the EISA probe is not very smart about this. This is sufficient
-# for most machines, but in particular the HP NetServer LC series comes
-# with an onboard AIC7770 dual-channel SCSI controller on EISA slot #11,
-# thus you need to bump this figure to 12 for them.
-options EISA_SLOTS=12
-
-#
-# PCI devices & PCI options:
-#
-# The main PCI bus device is `pci'. It provides auto-detection and
-# configuration support for all devices on the PCI bus, using either
-# configuration mode defined in the PCI specification.
-
-device pci
-
-# PCI options
-#
-#options PCI_QUIET #quiets PCI code on chipset settings
-
-
-# The `ahc' device provides support for the Adaptec 29/3940(U)(W)
-# and motherboard based AIC7870/AIC7880 adapters.
-#
-# The `amd' device provides support for the AMD 53C974 SCSI host
-# adapter chip as found on devices such as the Tekram DC-390(T).
-#
-# The `ncr' device provides support for the NCR 53C810 and 53C825
-# self-contained SCSI host adapters.
-#
-# The `isp' device provides support for the Qlogic ISP 1020, 1040
-# nd 1040B PCI SCSI host adapters, ISP 1240 Dual Ultra SCSI,
-# ISP 1080 and 1280 (Dual) Ultra2, ISP 12160 Ultra3 SCSI, as well as
-# the Qlogic ISP 2100 and ISP 2200 Fibre Channel Host Adapters.
-#
-# The `dc' device provides support for PCI fast ethernet adapters
-# based on the DEC/Intel 21143 and various workalikes including:
-# the ADMtek AL981 Comet and AN985 Centaur, the ASIX Electronics
-# AX88140A and AX88141, the Davicom DM9100 and DM9102, the Lite-On
-# 82c168 and 82c169 PNIC, the Lite-On/Macronix LC82C115 PNIC II
-# and the Macronix 98713/98713A/98715/98715A/98725 PMAC. This driver
-# replaces the old al, ax, dm, pn and mx drivers. List of brands:
-# Digital DE500-BA, Kingston KNE100TX, D-Link DFE-570TX, SOHOware SFA110,
-# SVEC PN102-TX, CNet Pro110B, 120A, and 120B, Compex RL100-TX,
-# LinkSys LNE100TX, LNE100TX V2.0, Jaton XpressNet, Alfa Inc GFC2204,
-# KNE110TX.
-#
-# The `de' device provides support for the Digital Equipment DC21040
-# self-contained Ethernet adapter.
-#
-# The `fxp' device provides support for the Intel EtherExpress Pro/100B
-# PCI Fast Ethernet adapters.
-#
-# The 'rl' device provides support for PCI fast ethernet adapters based
-# on the RealTek 8129/8139 chipset. Note that the RealTek driver defaults
-# to using programmed I/O to do register accesses because memory mapped
-# mode seems to cause severe lockups on SMP hardware. This driver also
-# supports the Accton EN1207D `Cheetah' adapter, which uses a chip called
-# the MPX 5030/5038, which is either a RealTek in disguise or a RealTek
-# workalike. Note that the D-Link DFE-530TX+ uses the RealTek chipset
-# and is supported by this driver, not the 'vr' driver.
-#
-# The 'sf' device provides support for Adaptec Duralink PCI fast
-# ethernet adapters based on the Adaptec AIC-6915 "starfire" controller.
-# This includes dual and quad port cards, as well as one 100baseFX card.
-# Most of these are 64-bit PCI devices, except for one single port
-# card which is 32-bit.
-#
-# The 'ste' device provides support for adapters based on the Sundance
-# Technologies ST201 PCI fast ethernet controller. This includes the
-# D-Link DFE-550TX.
-#
-# The 'sis' device provides support for adapters based on the Silicon
-# Integrated Systems SiS 900 and SiS 7016 PCI fast ethernet controller
-# chips.
-#
-# The 'sk' device provides support for the SysKonnect SK-984x series
-# PCI gigabit ethernet NICs. This includes the SK-9841 and SK-9842
-# single port cards (single mode and multimode fiber) and the
-# SK-9843 and SK-9844 dual port cards (also single mode and multimode).
-# The driver will autodetect the number of ports on the card and
-# attach each one as a separate network interface.
-#
-# The 'ti' device provides support for PCI gigabit ethernet NICs based
-# on the Alteon Networks Tigon 1 and Tigon 2 chipsets. This includes the
-# Alteon AceNIC, the 3Com 3c985, the Netgear GA620 and various others.
-# Note that you will probably want to bump up NMBCLUSTERS a lot to use
-# this driver.
-#
-# The 'tl' device provides support for the Texas Instruments TNETE100
-# series 'ThunderLAN' cards and integrated ethernet controllers. This
-# includes several Compaq Netelligent 10/100 cards and the built-in
-# ethernet controllers in several Compaq Prosignia, Proliant and
-# Deskpro systems. It also supports several Olicom 10Mbps and 10/100
-# boards.
-#
-# The `tx' device provides support for the SMC 9432TX cards.
-#
-# The `vr' device provides support for various fast ethernet adapters
-# based on the VIA Technologies VT3043 `Rhine I' and VT86C100A `Rhine II'
-# chips, including the D-Link DFE530TX (see 'rl' for DFE530TX+), the Hawking
-# Technologies PN102TX, and the AOpen/Acer ALN-320.
-#
-# The `vx' device provides support for the 3Com 3C590 and 3C595
-# early support
-#
-# The `wb' device provides support for various fast ethernet adapters
-# based on the Winbond W89C840F chip. Note: this is not the same as
-# the Winbond W89C940F, which is an NE2000 clone.
-#
-# The `wx' device provides support for the Intel Gigabit Ethernet
-# PCI card (`Wiseman').
-#
-# The `xl' device provides support for the 3Com 3c900, 3c905 and
-# 3c905B (Fast) Etherlink XL cards and integrated controllers. This
-# includes the integrated 3c905B-TX chips in certain Dell Optiplex and
-# Dell Precision desktop machines and the integrated 3c905-TX chips
-# in Dell Latitude laptop docking stations.
-#
-# The `fpa' device provides support for the Digital DEFPA PCI FDDI
-# adapter. pseudo-device fddi is also needed.
-#
-# The `meteor' device is a PCI video capture board. It can also have the
-# following options:
-# options METEOR_ALLOC_PAGES=xxx preallocate kernel pages for data entry
-# figure (ROWS*COLUMN*BYTES_PER_PIXEL*FRAME+PAGE_SIZE-1)/PAGE_SIZE
-# options METEOR_DEALLOC_PAGES remove all allocated pages on close(2)
-# options METEOR_DEALLOC_ABOVE=xxx remove all allocated pages above the
-# specified amount. If this value is below the allocated amount no action
-# taken
-# options METEOR_SYSTEM_DEFAULT={METEOR_PAL|METEOR_NTSC|METEOR_SECAM}, used
-# for initialization of fps routine when a signal is not present.
-#
-# The 'bktr' device is a PCI video capture device using the Brooktree
-# bt848/bt848a/bt849a/bt878/bt879 chipset. When used with a TV Tuner it forms a
-# TV card, eg Miro PC/TV, Hauppauge WinCast/TV WinTV, VideoLogic Captivator,
-# Intel Smart Video III, AverMedia, IMS Turbo, FlyVideo.
-#
-# options OVERRIDE_CARD=xxx
-# options OVERRIDE_TUNER=xxx
-# options OVERRIDE_MSP=1
-# options OVERRIDE_DBX=1
-# These options can be used to override the auto detection
-# The current values for xxx are found in src/sys/dev/bktr/bktr_card.h
-# Using sysctl(8) run-time overrides on a per-card basis can be made
-#
-# options BROOKTREE_SYSTEM_DEFAULT=BROOKTREE_PAL
-# or
-# options BROOKTREE_SYSTEM_DEFAULT=BROOKTREE_NTSC
-# Specifes the default video capture mode.
-# This is required for Dual Crystal (28&35Mhz) boards where PAL is used
-# to prevent hangs during initialisation. eg VideoLogic Captivator PCI.
-#
-# options BKTR_USE_PLL
-# PAL or SECAM users who have a 28Mhz crystal (and no 35Mhz crystal)
-# must enable PLL mode with this option. eg some new Bt878 cards.
-#
-# options BKTR_GPIO_ACCESS
-# This enable IOCTLs which give user level access to the GPIO port.
-#
-# options BKTR_NO_MSP_RESET
-# Prevents the MSP34xx reset. Good if you initialise the MSP in another OS first
-#
-# options BKTR_430_FX_MODE
-# Switch Bt878/879 cards into Intel 430FX chipset compatibility mode.
-#
-# options BKTR_SIS_VIA_MODE
-# Switch Bt878/879 cards into SIS/VIA chipset compatibility mode which is
-# needed for some old SiS and VIA chipset motherboards.
-# This also allows Bt878/879 chips to work on old OPTi (<1997) chipset
-# motherboards and motherboards with bad or incomplete PCI 2.1 support.
-# As a rough guess, old = before 1998
-#
-#
-# The oltr driver supports the following Olicom PCI token-ring adapters
-# OC-3136, OC-3137, OC-3139, OC-3140, OC-3141, OC-3540, OC-3250
-#
-device ahc # AHA2940 and onboard AIC7xxx devices
-device amd # AMD 53C974 (Teckram DC-390(T))
-device isp # Qlogic family
-device ncr # NCR/Symbios Logic
-device sym # NCR/Symbios Logic (newer chipsets)
-#
-# Options for ISP
-#
-# SCSI_ISP_NO_FWLOAD_MASK - mask of isp unit numbers (obviously
-# a max of 32) that you wish to disable
-# to disable the loading of firmware on.
-# SCSI_ISP_NO_NVRAM_MASK - mask of isp unit numbers (obviously
-# a max of 32) that you wish to disable
-# them picking up information from NVRAM
-# (for broken cards you can't fix the NVRAM
-# on- very rare, or for systems you can't
-# change NVRAM on (e.g. alpha) and you don't
-# like what's in there)
-# SCSI_ISP_PREFER_MEM_MAP - control preference for using memory mappings
-# instead of I/O space mappings. It defaults
-# to 1 for i386, 0 for alpha. Set to 1 to
-# unconditionally prefer mapping memory,
-# else it will use I/O space mappings. Of
-# course, this can fail if the PCI implement-
-# ation doesn't support what you want.
-#
-# SCSI_ISP_FCDUPLEX - mask of isp unit numbers (obviously
-# a max of 32) that you wish to set fibre
-# channel full duplex mode on.
-# to disable the loading of firmware on.
-# SCSI_ISP_FABRIC enable loading of Fabric f/w flavor (2100).
-# SCSI_ISP_SCCLUN enable loading of expanded lun f/w (2100).
-# SCSI_ISP_WWN - define a WWN to use as a default
-#
-# ISP_DISABLE_1020_SUPPORT Disable support for 1020/1040 cards
-# ISP_DISABLE_1080_SUPPORT Disable support for 1080/1240 cards
-# ISP_DISABLE_12160_SUPPORT Disable support for 12160 cards
-# ISP_DISABLE_2100_SUPPORT Disable support for 2100 cards
-# (these really just to save some code space)
-# (use of all four will cause the kernel to not compile)
-#
-# ISP_COMPILE_FW - compile all firmware in
-# ISP_COMPILE_1020_FW - compile in 1020/1040 firmware
-# ISP_COMPILE_1080_FW - compile in 1080/1240/1280 firmware
-# ISP_COMPILE_12160_FW - compile in 12160 firmware
-# ISP_COMPILE_2100_FW - compile in 2100 firmware
-# ISP_COMPILE_2200_FW - compile in 2200 firmware
-#
-# ISP_TARGET_MODE - enable target mode operation
-#
-options SCSI_ISP_NO_FWLOAD_MASK=0x12 # disable FW load for isp1, isp4
-options SCSI_ISP_NO_NVRAM_MASK=0x1 # disable NVRAM for isp0
-options SCSI_ISP_PREFER_MEM_MAP=0 # prefer I/O mapping
-options SCSI_ISP_FCDUPLEX=0x4 # isp2 is a Fibre Channel card
- # we want in full duplex mode.
-options SCSI_ISP_WWN="0x5000000099990000"
-#options ISP_DISABLE_1020_SUPPORT
-#options ISP_DISABLE_1080_SUPPORT
-#options ISP_DISABLE_12160_SUPPORT
-#options ISP_DISABLE_2100_SUPPORT
-#options ISP_COMPILE_1020_FW=1
-#options ISP_COMPILE_1080_FW=1
-#options ISP_COMPILE_2100_FW=1
-#options ISP_COMPILE_2200_FW=1
-#options ISP_TARGET_MODE=1
-
-# Options used in dev/sym/ (Symbios SCSI driver).
-#options SYM_SETUP_LP_PROBE_MAP #-Low Priority Probe Map (bits)
- # Allows the ncr to take precedence
- # 1 (1<<0) -> 810a, 860
- # 2 (1<<1) -> 825a, 875, 885, 895
- # 4 (1<<2) -> 895a, 896, 1510d
-#options SYM_SETUP_SCSI_DIFF #-HVD support for 825a, 875, 885
- # disabled:0 (default), enabled:1
-#options SYM_SETUP_PCI_PARITY #-PCI parity checking
- # disabled:0, enabled:1 (default)
-#options SYM_SETUP_MAX_LUN #-Number of LUNs supported
- # default:8, range:[1..64]
-
-
-# MII bus support is required for some PCI 10/100 ethernet NICs,
-# namely those which use MII-compliant transceivers or implement
-# tranceiver control interfaces that operate like an MII. Adding
-# "device miibus0" to the kernel config pulls in support for
-# the generic miibus API and all of the PHY drivers, including a
-# generic one for PHYs that aren't specifically handled by an
-# individual driver.
-device miibus
-
-# PCI Ethernet NICs that use the common MII bus controller code.
-device dc # DEC/Intel 21143 and various workalikes
-device rl # RealTek 8129/8139
-device sf # Adaptec AIC-6915 (``Starfire'')
-device sis # Silicon Integrated Systems SiS 900/SiS 7016
-device ste # Sundance ST201 (D-Link DFE-550TX)
-device tl # Texas Instruments ThunderLAN
-device vr # VIA Rhine, Rhine II
-device wb # Winbond W89C840F
-device xl # 3Com 3c90x (``Boomerang'', ``Cyclone'')
-
-# PCI Ethernet NICs.
-device de # DEC/Intel DC21x4x (``Tulip'')
-device fxp # Intel EtherExpress PRO/100B (82557, 82558)
-device tx # SMC 9432TX (83c170 ``EPIC'')
-device vx # 3Com 3c590, 3c595 (``Vortex'')
-
-device sk
-device ti
-device wx
-device fpa
-device meteor
-#The oltr driver in the ISA section will also find PCI cards.
-#device oltr0
-
-
-# Brooktree driver has been ported to the new I2C framework. Thus,
-# you'll need to have the following 3 lines in the kernel config.
-# device smbus
-# device iicbus
-# device iicbb
-# The iic and smb devices are only needed if you want to control other
-# I2C slaves connected to the external connector of some cards.
-#
-device bktr
-
-#
-# PCCARD/PCMCIA
-#
-# card: pccard slots
-# pcic: isa/pccard bridge
-device pcic0 at isa?
-device pcic1 at isa?
-device card
-
-# You may need to reset all pccards after resuming
-options PCIC_RESUME_RESET # reset after resume
-
-#
-# Laptop/Notebook options:
-#
-# See also:
-# apm under `Miscellaneous hardware'
-# above.
-
-# For older notebooks that signal a powerfail condition (external
-# power supply dropped, or battery state low) by issuing an NMI:
-
-options POWERFAIL_NMI # make it beep instead of panicing
-
-#
-# SMB bus
-#
-# System Management Bus support provided by the 'smbus' device.
-#
-# Supported devices:
-# smb standard io
-#
-# Supported interfaces:
-# iicsmb I2C to SMB bridge with any iicbus interface
-# bktr brooktree848 I2C hardware interface
-# intpm Intel PIIX4 Power Management Unit
-# alpm Acer Aladdin-IV/V/Pro2 Power Management Unit
-#
-device smbus # Bus support, required for smb below.
-device intpm
-device alpm
-
-device smb
-
-#
-# I2C Bus
-#
-# Philips i2c bus support is provided by the `iicbus' device.
-#
-# Supported devices:
-# ic i2c network interface
-# iic i2c standard io
-# iicsmb i2c to smb bridge. Allow i2c i/o with smb commands.
-#
-# Supported interfaces:
-# pcf Philips PCF8584 ISA-bus controller
-# bktr brooktree848 I2C software interface
-#
-# Other:
-# iicbb generic I2C bit-banging code (needed by lpbb, bktr)
-#
-device iicbus # Bus support, required for ic/iic/iicsmb below.
-device iicbb
-
-device ic
-device iic
-device iicsmb # smb over i2c bridge
-
-device pcf0 at isa? port 0x320 irq 5
-
-# ISDN4BSD section
-#
-# See /usr/share/examples/isdn/ROADMAP for an introduction to isdn4bsd.
-#
-# i4b passive ISDN cards support (isic - I4b Siemens Isdn Chipset driver)
-# note that the ``options'' and ``device'' lines must BOTH be defined !
-#
-# Driver entries marked "(not supported yet!)" are not working currently
-# due to not being converted to newbus. We hope to get them back to support
-# in the near future.
-#
-# ISA bus non-PnP Cards:
-# ----------------------
-#
-# Teles S0/8 or Niccy 1008
-options TEL_S0_8
-device isic0 at isa? iomem 0xd0000 irq 5 flags 1
-#
-# Teles S0/16 or Creatix ISDN-S0 or Niccy 1016
-options TEL_S0_16
-#device isic0 at isa? port 0xd80 iomem 0xd0000 irq 5 flags 2
-#
-# Teles S0/16.3
-options TEL_S0_16_3
-#device isic0 at isa? port 0xd80 irq 5 flags 3
-#
-# AVM A1 or AVM Fritz!Card
-options AVM_A1
-#device isic0 at isa? port 0x340 irq 5 flags 4
-#
-# USRobotics Sportster ISDN TA intern (not supported yet!)
-#options USR_STI
-#device isic0 at isa? port 0x268 irq 5 flags 7
-#
-# ITK ix1 Micro ( < V.3, non-PnP version ) (not supported yet!)
-#options ITKIX1
-#device isic0 at isa? port 0x398 irq 10 flags 18
-#
-# ELSA PCC-16
-options "ELSA_PCC16"
-#device isic0 at isa? port 0x360 irq 10 flags 20
-#
-# ISA bus PnP Cards:
-# ------------------
-#
-# Teles S0/16.3 PnP
-options TEL_S0_16_3_P
-#device isic
-#
-# Creatix ISDN-S0 P&P
-options CRTX_S0_P
-#device isic
-#
-# Dr. Neuhaus Niccy Go@
-options DRN_NGO
-#device isic
-#
-# Sedlbauer Win Speed
-options SEDLBAUER
-#device isic
-#
-# Dynalink IS64PH (not supported yet!)
-#options DYNALINK
-#device isic
-#
-# ELSA QuickStep 1000pro ISA
-options ELSA_QS1ISA
-#device isic
-#
-# ITK ix1 Micro ( V.3, PnP version ) (not supported yet!)
-#options "ITKIX1"
-#device isic
-#
-# AVM Fritz!Card PnP (not supported yet!)
-#options "AVM_PNP"
-#device isic
-#
-# Siemens I-Surf 2.0
-options "SIEMENS_ISURF2"
-#device isic
-#
-# PCI bus Cards:
-# --------------
-#
-# ELSA MicroLink ISDN/PCI (same as ELSA QuickStep 1000pro PCI)
-options ELSA_QS1PCI
-#device isic
-#
-# AVM Fritz!Card PCI
-options "AVM_A1_PCI"
-#device isic
-#
-# PCMCIA Cards:
-# -------------
-#
-# AVM PCMCIA Fritz!Card (not supported yet!)
-#options AVM_A1_PCMCIA
-#device isic0 at isa? port 0x340 irq 5 flags 10
-#
-# Active Cards:
-# -------------
-#
-# Stollmann Tina-dd control device
-# (driver under development, not fully functional!)
-device tina0 at isa? port 0x260 irq 10
-#
-# ISDN Protocol Stack
-# -------------------
-#
-# Q.921 / layer 2 - i4b passive cards D channel handling
-pseudo-device "i4bq921"
-#
-# Q.931 / layer 3 - i4b passive cards D channel handling
-pseudo-device "i4bq931"
-#
-# layer 4 - i4b common passive and active card handling
-pseudo-device "i4b"
-#
-# ISDN devices
-# ------------
-#
-# userland driver to do ISDN tracing (for passive cards only)
-pseudo-device "i4btrc" 4
-#
-# userland driver to control the whole thing
-pseudo-device "i4bctl"
-#
-# userland driver for access to raw B channel
-pseudo-device "i4brbch" 4
-#
-# userland driver for telephony
-pseudo-device "i4btel" 2
-#
-# network driver for IP over raw HDLC ISDN
-pseudo-device "i4bipr" 4
-# enable VJ header compression detection for ipr i/f
-options IPR_VJ
-# enable logging of the first n IP packets to isdnd (n=32 here)
-#options IPR_LOG=32
-#
-# network driver for sync PPP over ISDN
-pseudo-device "i4bisppp" 4
-
-
-# Parallel-Port Bus
-#
-# Parallel port bus support is provided by the `ppbus' device.
-# Multiple devices may be attached to the parallel port, devices
-# are automatically probed and attached when found.
-#
-# Supported devices:
-# vpo Iomega Zip Drive
-# Requires SCSI disk support ('scbus' and 'da'), best
-# performance is achieved with ports in EPP 1.9 mode.
-# lpt Parallel Printer
-# plip Parallel network interface
-# ppi General-purpose I/O ("Geek Port") + IEEE1284 I/O
-# pps Pulse per second Timing Interface
-# lpbb Philips official parallel port I2C bit-banging interface
-#
-# Supported interfaces:
-# ppc ISA-bus parallel port interfaces.
-#
-
-options PPC_PROBE_CHIPSET # Enable chipset specific detection
- # (see flags in ppc(4))
-options DEBUG_1284 # IEEE1284 signaling protocol debug
-options PERIPH_1284 # Makes your computer act as a IEEE1284
- # compliant peripheral
-options DONTPROBE_1284 # Avoid boot detection of PnP parallel devices
-options VP0_DEBUG # ZIP/ZIP+ debug
-options LPT_DEBUG # Printer driver debug
-options PPC_DEBUG # Parallel chipset level debug
-options PLIP_DEBUG # Parallel network IP interface debug
-options PCFCLOCK_VERBOSE # Verbose pcfclock driver
-options PCFCLOCK_MAX_RETRIES=5 # Maximum read tries (default 10)
-
-device ppc0 at isa? irq 7
-device ppbus
-device vpo
-device lpt
-device plip
-device ppi
-device pps
-device lpbb
-device pcfclock
-
-# Kernel BOOTP support
-
-options BOOTP # Use BOOTP to obtain IP address/hostname
-options BOOTP_NFSROOT # NFS mount root filesystem using BOOTP info
-options BOOTP_NFSV3 # Use NFS v3 to NFS mount root
-options BOOTP_COMPAT # Workaround for broken bootp daemons.
-options BOOTP_WIRED_TO=fxp0 # Use interface fxp0 for BOOTP
-
-#
-# Add tie-ins for a hardware watchdog. This only enable the hooks;
-# the user must still supply the actual driver.
-#
-options HW_WDOG
-
-#
-# Set the number of PV entries per process. Increasing this can
-# stop panics related to heavy use of shared memory. However, that can
-# (combined with large amounts of physical memory) cause panics at
-# boot time due the kernel running out of VM space.
-#
-# If you're tweaking this, you might also want to increase the sysctls
-# "vm.v_free_min", "vm.v_free_reserved", and "vm.v_free_target".
-#
-# The value below is the one more than the default.
-#
-options PMAP_SHPGPERPROC=201
-
-#
-# Disable swapping. This option removes all code which actually performs
-# swapping, so it's not possible to turn it back on at run-time.
-#
-# This is sometimes usable for systems which don't have any swap space
-# (see also sysctls "vm.defer_swapspace_pageouts" and
-# "vm.disable_swapspace_pageouts")
-#
-#options NO_SWAPPING
-
-# Set the number of sf_bufs to allocate. sf_bufs are virtual buffers
-# for sendfile(2) that are used to map file VM pages, and normally
-# default to a quantity that is roughly 16*MAXUSERS+512. You would
-# typically want about 4 of these for each simultaneous file send.
-#
-options NSFBUFS=1024
-
-#
-# Enable extra debugging code for locks. This stores the filename and
-# line of whatever acquired the lock in the lock itself, and change a
-# number of function calls to pass around the relevant data. This is
-# not at all useful unless you are debugging lock code. Also note
-# that it is likely to break e.g. fstat(1) unless you recompile your
-# userland with -DDEBUG_LOCKS as well.
-#
-options DEBUG_LOCKS
-
-#
-# SysVR4 ABI emulation
-#
-# The svr4 ABI emulator can be statically compiled into the kernel or loaded as
-# a KLD module.
-# The STREAMS network emulation code can also be compiled statically or as a
-# module. If loaded as a module, it must be loaded before the svr4 module
-# (the /usr/sbin/svr4 script does this for you). If compiling statically,
-# the `streams' pseudo-device must be configured into any kernel which also
-# specifies COMPAT_SVR4. It is possible to have a statically-configured
-# STREAMS device and a dynamically loadable svr4 emulator; the /usr/sbin/svr4
-# script understands that it doesn't need to load the `streams' module under
-# those circumstances.
-# Caveat: At this time, `options KTRACE' is required for the svr4 emulator
-# (whether static or dynamic).
-#
-options COMPAT_SVR4 # build emulator statically
-options DEBUG_SVR4 # enable verbose debugging
-pseudo-device streams # STREAMS network driver (required for svr4).
-
-# More undocumented options for linting.
-# Note that documenting these are not considered an affront.
-
-options AHC_DUMP_EEPROM
-options AHC_TMODE_ENABLE
-options BUS_DEBUG
-options CAM_DEBUG_DELAY
-options CLK_CALIBRATION_LOOP
-options CLK_USE_I8254_CALIBRATION
-options CLK_USE_TSC_CALIBRATION
-options CLUSTERDEBUG
-options COMPAT_LINUX
-options CPU_UPGRADE_HW_CACHE
-options DEBUG
-options DEBUG_LINUX
-options DEBUG_VFS_LOCKS
-#options DISABLE_PSE
-options ENABLE_ALART
-options ENABLE_VFS_IOOPT
-options FB_DEBUG
-options FB_INSTALL_CDEV
-options FE_8BIT_SUPPORT
-options I4B_SMP_WORKAROUND
-options I586_PMC_GUPROF=0x70000
-options IBCS2
-options KBDIO_DEBUG=2
-options KBD_MAXRETRY=4
-options KBD_MAXWAIT=6
-options KBD_RESETDELAY=201
-options KEY
-options LOCKF_DEBUG
-options LOUTB
-options MSGMNB=2049
-options MSGMNI=41
-options MSGSEG=2049
-options MSGSSZ=16
-options MSGTQL=41
-options NBUF=512
-options NETATALKDEBUG
-options NMBCLUSTERS=1024
-options NPX_DEBUG
-#options OLTR_NO_BULLSEYE_MAC
-#options OLTR_NO_HAWKEYE_MAC
-#options OLTR_NO_TMS_MAC
-options PANIC_REBOOT_WAIT_TIME=16
-options PNPBIOS
-options PSM_DEBUG=1
-options SCSI_NCR_DEBUG
-options SCSI_NCR_MAX_SYNC=10000
-options SCSI_NCR_MAX_WIDE=1
-options SCSI_NCR_MYADDR=7
-options SC_DEBUG_LEVEL
-options SC_RENDER_DEBUG
-options SEMMAP=31
-options SEMMNI=11
-options SEMMNS=61
-options SEMMNU=31
-options SEMMSL=61
-options SEMOPM=101
-options SEMUME=11
-options SHMALL=1025
-options SHMMAX="(SHMMAXPGS*PAGE_SIZE+1)"
-options SHMMAXPGS=1025
-options SHMMIN=2
-options SHMMNI=33
-options SHMSEG=9
-options SHOW_BUSYBUFS # List buffers that prevent root unmount
-options SIMPLELOCK_DEBUG
-options SI_DEBUG
-options SLIP_IFF_OPTS
-options SPX_HACK
-options TIMER_FREQ="((14318182+6)/12)"
-options VFS_BIO_DEBUG
-options VM_KMEM_SIZE
-options VM_KMEM_SIZE_MAX
-options VM_KMEM_SIZE_SCALE
-
-# Undocumented options covering presently broken code
-#options ASUSCOM_IPAC
-
-# The 'dpt' driver provides support for DPT controllers (http://www.dpt.com/).
-# These have hardware RAID-{0,1,5} support, and do multi-initiator I/O.
-# The DPT controllers are commonly re-licensed under other brand-names -
-# some controllers by Olivetti, Dec, HP, AT&T, SNI, AST, Alphatronic, NEC and
-# Compaq are actually DPT controllers.
-#
-# See src/sys/dev/dpt for debugging and other subtle options.
-# DPT_MEASURE_PERFORMANCE Enables a set of (semi)invasive metrics. Various
-# instruments are enabled. The tools in
-# /usr/sbin/dpt_* assume these to be enabled.
-# DPT_HANDLE_TIMEOUTS Normally device timeouts are handled by the DPT.
-# If you ant the driver to handle timeouts, enable
-# this option. If your system is very busy, this
-# option will create more trouble than solve.
-# DPT_TIMEOUT_FACTOR Used to compute the excessive amount of time to
-# wait when timing out with the above option.
-# DPT_DEBUG_xxxx These are controllable from sys/dev/dpt/dpt.h
-# DPT_LOST_IRQ When enabled, will try, once per second, to catch
-# any interrupt that got lost. Seems to help in some
-# DPT-firmware/Motherboard combinations. Minimal
-# cost, great benefit.
-# DPT_RESET_HBA Make "reset" actually reset the controller
-# instead of fudging it. Only enable this if you
-# are 100% certain you need it.
-
-device dpt
-
-# DPT options
-#!CAM# options DPT_MEASURE_PERFORMANCE
-#!CAM# options DPT_HANDLE_TIMEOUTS
-options DPT_TIMEOUT_FACTOR=4
-options DPT_LOST_IRQ
-options DPT_RESET_HBA
-options DPT_ALLOW_MEMIO
-
-# USB support
-# UHCI controller
-device uhci
-# OHCI controller
-device ohci
-# General USB code (mandatory for USB)
-device usb
-#
-# Generic USB device driver
-device ugen
-# Human Interface Device (anything with buttons and dials)
-device uhid
-# USB keyboard
-device ukbd
-# USB printer
-device ulpt
-# USB Iomega Zip 100 Drive
-device umass
-# USB mouse
-device ums
-#
-# ADMtek USB ethernet. Supports the LinkSys USB100TX,
-# the Billionton USB100, the Melco LU-ATX, the D-Link DSB-650TX
-# and the SMC 2202USB. Also works with the ADMtek AN986 Pegasus
-# eval board.
-device aue
-#
-# CATC USB-EL1201A USB ethernet. Supports the CATC Netmate
-# and Netmate II, and the Belkin F5U111.
-device cue
-#
-# Kawasaki LSI ethernet. Supports the LinkSys USB10T,
-# Entrega USB-NET-E45, Peracom Ethernet Adapter, the
-# 3Com 3c19250, the ADS Technologies USB-10BT, the ATen UC10T,
-# the Netgear EA101, the D-Link DSB-650, the SMC 2102USB
-# and 2104USB, and the Corega USB-T.
-device kue
-
-# debugging options for the USB subsystem
-#
-options UHCI_DEBUG
-options OHCI_DEBUG
-options USB_DEBUG
-
-options UGEN_DEBUG
-options UHID_DEBUG
-options UHUB_DEBUG
-options UKBD_DEBUG
-options ULPT_DEBUG
-options UMASS_DEBUG
-options UMS_DEBUG
-
-# options for ukbd:
-options UKBD_DFLT_KEYMAP # specify the built-in keymap
-makeoptions UKBD_DFLT_KEYMAP=it.iso
-
-#
-# Embedded system options:
-#
-# An embedded system might want to run something other than init.
-options INIT_PATH="/sbin/init:/stand/sysinstall"
diff --git a/sys/i386/i386/apic_vector.s b/sys/i386/i386/apic_vector.s
deleted file mode 100644
index ca909d907e69..000000000000
--- a/sys/i386/i386/apic_vector.s
+++ /dev/null
@@ -1,1061 +0,0 @@
-/*
- * from: vector.s, 386BSD 0.1 unknown origin
- * $FreeBSD$
- */
-
-
-#include <machine/apic.h>
-#include <machine/smp.h>
-
-#include "i386/isa/intr_machdep.h"
-
-
-#ifdef FAST_SIMPLELOCK
-
-#define GET_FAST_INTR_LOCK \
- pushl $_fast_intr_lock ; /* address of lock */ \
- call _s_lock ; /* MP-safe */ \
- addl $4,%esp
-
-#define REL_FAST_INTR_LOCK \
- movl $0, _fast_intr_lock
-
-#else /* FAST_SIMPLELOCK */
-
-#define GET_FAST_INTR_LOCK \
- call _get_isrlock
-
-#define REL_FAST_INTR_LOCK \
- movl $_mp_lock, %edx ; /* GIANT_LOCK */ \
- call _MPrellock_edx
-
-#endif /* FAST_SIMPLELOCK */
-
-/* convert an absolute IRQ# into a bitmask */
-#define IRQ_BIT(irq_num) (1 << (irq_num))
-
-/* make an index into the IO APIC from the IRQ# */
-#define REDTBL_IDX(irq_num) (0x10 + ((irq_num) * 2))
-
-
-/*
- * Macros for interrupt interrupt entry, call to handler, and exit.
- */
-
-#ifdef FAST_WITHOUTCPL
-
-/*
- */
-#define FAST_INTR(irq_num, vec_name) \
- .text ; \
- SUPERALIGN_TEXT ; \
-IDTVEC(vec_name) ; \
- pushl %eax ; /* save only call-used registers */ \
- pushl %ecx ; \
- pushl %edx ; \
- pushl %ds ; \
- MAYBE_PUSHL_ES ; \
- pushl %fs ; \
- movl $KDSEL,%eax ; \
- movl %ax,%ds ; \
- MAYBE_MOVW_AX_ES ; \
- movl $KPSEL,%eax ; \
- movl %ax,%fs ; \
- FAKE_MCOUNT((5+ACTUALLY_PUSHED)*4(%esp)) ; \
- pushl _intr_unit + (irq_num) * 4 ; \
- GET_FAST_INTR_LOCK ; \
- call *_intr_handler + (irq_num) * 4 ; /* do the work ASAP */ \
- REL_FAST_INTR_LOCK ; \
- addl $4, %esp ; \
- movl $0, lapic_eoi ; \
- lock ; \
- incl _cnt+V_INTR ; /* book-keeping can wait */ \
- movl _intr_countp + (irq_num) * 4, %eax ; \
- lock ; \
- incl (%eax) ; \
- MEXITCOUNT ; \
- popl %fs ; \
- MAYBE_POPL_ES ; \
- popl %ds ; \
- popl %edx ; \
- popl %ecx ; \
- popl %eax ; \
- iret
-
-#else /* FAST_WITHOUTCPL */
-
-#define FAST_INTR(irq_num, vec_name) \
- .text ; \
- SUPERALIGN_TEXT ; \
-IDTVEC(vec_name) ; \
- pushl %eax ; /* save only call-used registers */ \
- pushl %ecx ; \
- pushl %edx ; \
- pushl %ds ; \
- MAYBE_PUSHL_ES ; \
- pushl %fs ; \
- movl $KDSEL, %eax ; \
- movl %ax, %ds ; \
- MAYBE_MOVW_AX_ES ; \
- movl $KPSEL, %eax ; \
- movl %ax, %fs ; \
- FAKE_MCOUNT((5+ACTUALLY_PUSHED)*4(%esp)) ; \
- GET_FAST_INTR_LOCK ; \
- pushl _intr_unit + (irq_num) * 4 ; \
- call *_intr_handler + (irq_num) * 4 ; /* do the work ASAP */ \
- addl $4, %esp ; \
- movl $0, lapic_eoi ; \
- lock ; \
- incl _cnt+V_INTR ; /* book-keeping can wait */ \
- movl _intr_countp + (irq_num) * 4,%eax ; \
- lock ; \
- incl (%eax) ; \
- movl _cpl, %eax ; /* unmasking pending HWIs or SWIs? */ \
- notl %eax ; \
- andl _ipending, %eax ; \
- jne 2f ; /* yes, maybe handle them */ \
-1: ; \
- MEXITCOUNT ; \
- REL_FAST_INTR_LOCK ; \
- popl %fs ; \
- MAYBE_POPL_ES ; \
- popl %ds ; \
- popl %edx ; \
- popl %ecx ; \
- popl %eax ; \
- iret ; \
-; \
- ALIGN_TEXT ; \
-2: ; \
- cmpb $3, _intr_nesting_level ; /* enough stack? */ \
- jae 1b ; /* no, return */ \
- movl _cpl, %eax ; \
- /* XXX next line is probably unnecessary now. */ \
- movl $HWI_MASK|SWI_MASK, _cpl ; /* limit nesting ... */ \
- lock ; \
- incb _intr_nesting_level ; /* ... really limit it ... */ \
- sti ; /* to do this as early as possible */ \
- popl %fs ; /* discard most of thin frame ... */ \
- MAYBE_POPL_ES ; /* discard most of thin frame ... */ \
- popl %ecx ; /* ... original %ds ... */ \
- popl %edx ; \
- xchgl %eax, 4(%esp) ; /* orig %eax; save cpl */ \
- pushal ; /* build fat frame (grrr) ... */ \
- pushl %ecx ; /* ... actually %ds ... */ \
- pushl %es ; \
- pushl %fs ;
- movl $KDSEL, %eax ; \
- movl %ax, %es ; \
- movl $KPSEL, %eax ;
- movl %ax, %fs ;
- movl (3+8+0)*4(%esp), %ecx ; /* %ecx from thin frame ... */ \
- movl %ecx, (3+6)*4(%esp) ; /* ... to fat frame ... */ \
- movl (3+8+1)*4(%esp), %eax ; /* ... cpl from thin frame */ \
- pushl %eax ; \
- subl $4, %esp ; /* junk for unit number */ \
- MEXITCOUNT ; \
- jmp _doreti
-
-#endif /** FAST_WITHOUTCPL */
-
-
-/*
- *
- */
-#define PUSH_FRAME \
- pushl $0 ; /* dummy error code */ \
- pushl $0 ; /* dummy trap type */ \
- pushal ; \
- pushl %ds ; /* save data and extra segments ... */ \
- pushl %es ; \
- pushl %fs
-
-#define POP_FRAME \
- popl %fs ; \
- popl %es ; \
- popl %ds ; \
- popal ; \
- addl $4+4,%esp
-
-#define IOAPICADDR(irq_num) CNAME(int_to_apicintpin) + 16 * (irq_num) + 8
-#define REDIRIDX(irq_num) CNAME(int_to_apicintpin) + 16 * (irq_num) + 12
-
-#define MASK_IRQ(irq_num) \
- IMASK_LOCK ; /* into critical reg */ \
- testl $IRQ_BIT(irq_num), _apic_imen ; \
- jne 7f ; /* masked, don't mask */ \
- orl $IRQ_BIT(irq_num), _apic_imen ; /* set the mask bit */ \
- movl IOAPICADDR(irq_num), %ecx ; /* ioapic addr */ \
- movl REDIRIDX(irq_num), %eax ; /* get the index */ \
- movl %eax, (%ecx) ; /* write the index */ \
- movl IOAPIC_WINDOW(%ecx), %eax ; /* current value */ \
- orl $IOART_INTMASK, %eax ; /* set the mask */ \
- movl %eax, IOAPIC_WINDOW(%ecx) ; /* new value */ \
-7: ; /* already masked */ \
- IMASK_UNLOCK
-/*
- * Test to see whether we are handling an edge or level triggered INT.
- * Level-triggered INTs must still be masked as we don't clear the source,
- * and the EOI cycle would cause redundant INTs to occur.
- */
-#define MASK_LEVEL_IRQ(irq_num) \
- testl $IRQ_BIT(irq_num), _apic_pin_trigger ; \
- jz 9f ; /* edge, don't mask */ \
- MASK_IRQ(irq_num) ; \
-9:
-
-
-#ifdef APIC_INTR_REORDER
-#define EOI_IRQ(irq_num) \
- movl _apic_isrbit_location + 8 * (irq_num), %eax ; \
- movl (%eax), %eax ; \
- testl _apic_isrbit_location + 4 + 8 * (irq_num), %eax ; \
- jz 9f ; /* not active */ \
- movl $0, lapic_eoi ; \
- APIC_ITRACE(apic_itrace_eoi, irq_num, APIC_ITRACE_EOI) ; \
-9:
-
-#else
-#define EOI_IRQ(irq_num) \
- testl $IRQ_BIT(irq_num), lapic_isr1; \
- jz 9f ; /* not active */ \
- movl $0, lapic_eoi; \
- APIC_ITRACE(apic_itrace_eoi, irq_num, APIC_ITRACE_EOI) ; \
-9:
-#endif
-
-
-/*
- * Test to see if the source is currntly masked, clear if so.
- */
-#define UNMASK_IRQ(irq_num) \
- IMASK_LOCK ; /* into critical reg */ \
- testl $IRQ_BIT(irq_num), _apic_imen ; \
- je 7f ; /* bit clear, not masked */ \
- andl $~IRQ_BIT(irq_num), _apic_imen ;/* clear mask bit */ \
- movl IOAPICADDR(irq_num),%ecx ; /* ioapic addr */ \
- movl REDIRIDX(irq_num), %eax ; /* get the index */ \
- movl %eax,(%ecx) ; /* write the index */ \
- movl IOAPIC_WINDOW(%ecx),%eax ; /* current value */ \
- andl $~IOART_INTMASK,%eax ; /* clear the mask */ \
- movl %eax,IOAPIC_WINDOW(%ecx) ; /* new value */ \
-7: ; \
- IMASK_UNLOCK
-
-#ifdef INTR_SIMPLELOCK
-#define ENLOCK
-#define DELOCK
-#define LATELOCK call _get_isrlock
-#else
-#define ENLOCK \
- ISR_TRYLOCK ; /* XXX this is going away... */ \
- testl %eax, %eax ; /* did we get it? */ \
- jz 3f
-#define DELOCK ISR_RELLOCK
-#define LATELOCK
-#endif
-
-#ifdef APIC_INTR_DIAGNOSTIC
-#ifdef APIC_INTR_DIAGNOSTIC_IRQ
-log_intr_event:
- pushf
- cli
- pushl $CNAME(apic_itrace_debuglock)
- call CNAME(s_lock_np)
- addl $4, %esp
- movl CNAME(apic_itrace_debugbuffer_idx), %ecx
- andl $32767, %ecx
- movl _cpuid, %eax
- shll $8, %eax
- orl 8(%esp), %eax
- movw %ax, CNAME(apic_itrace_debugbuffer)(,%ecx,2)
- incl %ecx
- andl $32767, %ecx
- movl %ecx, CNAME(apic_itrace_debugbuffer_idx)
- pushl $CNAME(apic_itrace_debuglock)
- call CNAME(s_unlock_np)
- addl $4, %esp
- popf
- ret
-
-
-#define APIC_ITRACE(name, irq_num, id) \
- lock ; /* MP-safe */ \
- incl CNAME(name) + (irq_num) * 4 ; \
- pushl %eax ; \
- pushl %ecx ; \
- pushl %edx ; \
- movl $(irq_num), %eax ; \
- cmpl $APIC_INTR_DIAGNOSTIC_IRQ, %eax ; \
- jne 7f ; \
- pushl $id ; \
- call log_intr_event ; \
- addl $4, %esp ; \
-7: ; \
- popl %edx ; \
- popl %ecx ; \
- popl %eax
-#else
-#define APIC_ITRACE(name, irq_num, id) \
- lock ; /* MP-safe */ \
- incl CNAME(name) + (irq_num) * 4
-#endif
-
-#define APIC_ITRACE_ENTER 1
-#define APIC_ITRACE_EOI 2
-#define APIC_ITRACE_TRYISRLOCK 3
-#define APIC_ITRACE_GOTISRLOCK 4
-#define APIC_ITRACE_ENTER2 5
-#define APIC_ITRACE_LEAVE 6
-#define APIC_ITRACE_UNMASK 7
-#define APIC_ITRACE_ACTIVE 8
-#define APIC_ITRACE_MASKED 9
-#define APIC_ITRACE_NOISRLOCK 10
-#define APIC_ITRACE_MASKED2 11
-#define APIC_ITRACE_SPLZ 12
-#define APIC_ITRACE_DORETI 13
-
-#else
-#define APIC_ITRACE(name, irq_num, id)
-#endif
-
-#ifdef CPL_AND_CML
-
-#define INTR(irq_num, vec_name, maybe_extra_ipending) \
- .text ; \
- SUPERALIGN_TEXT ; \
-/* _XintrNN: entry point used by IDT/HWIs & splz_unpend via _vec[]. */ \
-IDTVEC(vec_name) ; \
- PUSH_FRAME ; \
- movl $KDSEL, %eax ; /* reload with kernel's data segment */ \
- movl %ax, %ds ; \
- movl %ax, %es ; \
- movl $KPSEL, %eax ; \
- movl %ax, %fs ; \
-; \
- maybe_extra_ipending ; \
-; \
- APIC_ITRACE(apic_itrace_enter, irq_num, APIC_ITRACE_ENTER) ; \
- lock ; /* MP-safe */ \
- btsl $(irq_num), iactive ; /* lazy masking */ \
- jc 1f ; /* already active */ \
-; \
- MASK_LEVEL_IRQ(irq_num) ; \
- EOI_IRQ(irq_num) ; \
-0: ; \
- APIC_ITRACE(apic_itrace_tryisrlock, irq_num, APIC_ITRACE_TRYISRLOCK) ;\
- ENLOCK ; \
-; \
- APIC_ITRACE(apic_itrace_gotisrlock, irq_num, APIC_ITRACE_GOTISRLOCK) ;\
- AVCPL_LOCK ; /* MP-safe */ \
- testl $IRQ_BIT(irq_num), _cpl ; \
- jne 2f ; /* this INT masked */ \
- testl $IRQ_BIT(irq_num), _cml ; \
- jne 2f ; /* this INT masked */ \
- orl $IRQ_BIT(irq_num), _cil ; \
- AVCPL_UNLOCK ; \
-; \
- incb _intr_nesting_level ; \
-; \
- /* entry point used by doreti_unpend for HWIs. */ \
-__CONCAT(Xresume,irq_num): ; \
- FAKE_MCOUNT(13*4(%esp)) ; /* XXX avoid dbl cnt */ \
- lock ; incl _cnt+V_INTR ; /* tally interrupts */ \
- movl _intr_countp + (irq_num) * 4, %eax ; \
- lock ; incl (%eax) ; \
-; \
- AVCPL_LOCK ; /* MP-safe */ \
- movl _cml, %eax ; \
- pushl %eax ; \
- orl _intr_mask + (irq_num) * 4, %eax ; \
- movl %eax, _cml ; \
- AVCPL_UNLOCK ; \
-; \
- pushl _intr_unit + (irq_num) * 4 ; \
- incl _inside_intr ; \
- APIC_ITRACE(apic_itrace_enter2, irq_num, APIC_ITRACE_ENTER2) ; \
- sti ; \
- call *_intr_handler + (irq_num) * 4 ; \
- cli ; \
- APIC_ITRACE(apic_itrace_leave, irq_num, APIC_ITRACE_LEAVE) ; \
- decl _inside_intr ; \
-; \
- lock ; andl $~IRQ_BIT(irq_num), iactive ; \
- lock ; andl $~IRQ_BIT(irq_num), _cil ; \
- UNMASK_IRQ(irq_num) ; \
- APIC_ITRACE(apic_itrace_unmask, irq_num, APIC_ITRACE_UNMASK) ; \
- sti ; /* doreti repeats cli/sti */ \
- MEXITCOUNT ; \
- LATELOCK ; \
- jmp _doreti ; \
-; \
- ALIGN_TEXT ; \
-1: ; /* active */ \
- APIC_ITRACE(apic_itrace_active, irq_num, APIC_ITRACE_ACTIVE) ; \
- MASK_IRQ(irq_num) ; \
- EOI_IRQ(irq_num) ; \
- AVCPL_LOCK ; /* MP-safe */ \
- lock ; \
- orl $IRQ_BIT(irq_num), _ipending ; \
- AVCPL_UNLOCK ; \
- lock ; \
- btsl $(irq_num), iactive ; /* still active */ \
- jnc 0b ; /* retry */ \
- POP_FRAME ; \
- iret ; \
-; \
- ALIGN_TEXT ; \
-2: ; /* masked by cpl|cml */ \
- APIC_ITRACE(apic_itrace_masked, irq_num, APIC_ITRACE_MASKED) ; \
- lock ; \
- orl $IRQ_BIT(irq_num), _ipending ; \
- AVCPL_UNLOCK ; \
- DELOCK ; /* XXX this is going away... */ \
- POP_FRAME ; \
- iret ; \
- ALIGN_TEXT ; \
-3: ; /* other cpu has isr lock */ \
- APIC_ITRACE(apic_itrace_noisrlock, irq_num, APIC_ITRACE_NOISRLOCK) ;\
- AVCPL_LOCK ; /* MP-safe */ \
- lock ; \
- orl $IRQ_BIT(irq_num), _ipending ; \
- testl $IRQ_BIT(irq_num), _cpl ; \
- jne 4f ; /* this INT masked */ \
- testl $IRQ_BIT(irq_num), _cml ; \
- jne 4f ; /* this INT masked */ \
- orl $IRQ_BIT(irq_num), _cil ; \
- AVCPL_UNLOCK ; \
- call forward_irq ; /* forward irq to lock holder */ \
- POP_FRAME ; /* and return */ \
- iret ; \
- ALIGN_TEXT ; \
-4: ; /* blocked */ \
- APIC_ITRACE(apic_itrace_masked2, irq_num, APIC_ITRACE_MASKED2) ;\
- AVCPL_UNLOCK ; \
- POP_FRAME ; /* and return */ \
- iret
-
-#else /* CPL_AND_CML */
-
-
-#define INTR(irq_num, vec_name, maybe_extra_ipending) \
- .text ; \
- SUPERALIGN_TEXT ; \
-/* _XintrNN: entry point used by IDT/HWIs & splz_unpend via _vec[]. */ \
-IDTVEC(vec_name) ; \
- PUSH_FRAME ; \
- movl $KDSEL, %eax ; /* reload with kernel's data segment */ \
- movl %ax, %ds ; \
- movl %ax, %es ; \
- movl $KPSEL, %eax ; \
- movl %ax, %fs ; \
-; \
- maybe_extra_ipending ; \
-; \
- APIC_ITRACE(apic_itrace_enter, irq_num, APIC_ITRACE_ENTER) ; \
- lock ; /* MP-safe */ \
- btsl $(irq_num), iactive ; /* lazy masking */ \
- jc 1f ; /* already active */ \
-; \
- MASK_LEVEL_IRQ(irq_num) ; \
- EOI_IRQ(irq_num) ; \
-0: ; \
- APIC_ITRACE(apic_itrace_tryisrlock, irq_num, APIC_ITRACE_TRYISRLOCK) ;\
- ISR_TRYLOCK ; /* XXX this is going away... */ \
- testl %eax, %eax ; /* did we get it? */ \
- jz 3f ; /* no */ \
-; \
- APIC_ITRACE(apic_itrace_gotisrlock, irq_num, APIC_ITRACE_GOTISRLOCK) ;\
- AVCPL_LOCK ; /* MP-safe */ \
- testl $IRQ_BIT(irq_num), _cpl ; \
- jne 2f ; /* this INT masked */ \
- AVCPL_UNLOCK ; \
-; \
- incb _intr_nesting_level ; \
-; \
- /* entry point used by doreti_unpend for HWIs. */ \
-__CONCAT(Xresume,irq_num): ; \
- FAKE_MCOUNT(13*4(%esp)) ; /* XXX avoid dbl cnt */ \
- lock ; incl _cnt+V_INTR ; /* tally interrupts */ \
- movl _intr_countp + (irq_num) * 4, %eax ; \
- lock ; incl (%eax) ; \
-; \
- AVCPL_LOCK ; /* MP-safe */ \
- movl _cpl, %eax ; \
- pushl %eax ; \
- orl _intr_mask + (irq_num) * 4, %eax ; \
- movl %eax, _cpl ; \
- lock ; \
- andl $~IRQ_BIT(irq_num), _ipending ; \
- AVCPL_UNLOCK ; \
-; \
- pushl _intr_unit + (irq_num) * 4 ; \
- APIC_ITRACE(apic_itrace_enter2, irq_num, APIC_ITRACE_ENTER2) ; \
- sti ; \
- call *_intr_handler + (irq_num) * 4 ; \
- cli ; \
- APIC_ITRACE(apic_itrace_leave, irq_num, APIC_ITRACE_LEAVE) ; \
-; \
- lock ; andl $~IRQ_BIT(irq_num), iactive ; \
- UNMASK_IRQ(irq_num) ; \
- APIC_ITRACE(apic_itrace_unmask, irq_num, APIC_ITRACE_UNMASK) ; \
- sti ; /* doreti repeats cli/sti */ \
- MEXITCOUNT ; \
- jmp _doreti ; \
-; \
- ALIGN_TEXT ; \
-1: ; /* active */ \
- APIC_ITRACE(apic_itrace_active, irq_num, APIC_ITRACE_ACTIVE) ; \
- MASK_IRQ(irq_num) ; \
- EOI_IRQ(irq_num) ; \
- AVCPL_LOCK ; /* MP-safe */ \
- lock ; \
- orl $IRQ_BIT(irq_num), _ipending ; \
- AVCPL_UNLOCK ; \
- lock ; \
- btsl $(irq_num), iactive ; /* still active */ \
- jnc 0b ; /* retry */ \
- POP_FRAME ; \
- iret ; /* XXX: iactive bit might be 0 now */ \
- ALIGN_TEXT ; \
-2: ; /* masked by cpl, leave iactive set */ \
- APIC_ITRACE(apic_itrace_masked, irq_num, APIC_ITRACE_MASKED) ; \
- lock ; \
- orl $IRQ_BIT(irq_num), _ipending ; \
- AVCPL_UNLOCK ; \
- ISR_RELLOCK ; /* XXX this is going away... */ \
- POP_FRAME ; \
- iret ; \
- ALIGN_TEXT ; \
-3: ; /* other cpu has isr lock */ \
- APIC_ITRACE(apic_itrace_noisrlock, irq_num, APIC_ITRACE_NOISRLOCK) ;\
- AVCPL_LOCK ; /* MP-safe */ \
- lock ; \
- orl $IRQ_BIT(irq_num), _ipending ; \
- testl $IRQ_BIT(irq_num), _cpl ; \
- jne 4f ; /* this INT masked */ \
- AVCPL_UNLOCK ; \
- call forward_irq ; /* forward irq to lock holder */ \
- POP_FRAME ; /* and return */ \
- iret ; \
- ALIGN_TEXT ; \
-4: ; /* blocked */ \
- APIC_ITRACE(apic_itrace_masked2, irq_num, APIC_ITRACE_MASKED2) ;\
- AVCPL_UNLOCK ; \
- POP_FRAME ; /* and return */ \
- iret
-
-#endif /* CPL_AND_CML */
-
-
-/*
- * Handle "spurious INTerrupts".
- * Notes:
- * This is different than the "spurious INTerrupt" generated by an
- * 8259 PIC for missing INTs. See the APIC documentation for details.
- * This routine should NOT do an 'EOI' cycle.
- */
- .text
- SUPERALIGN_TEXT
- .globl _Xspuriousint
-_Xspuriousint:
-
- /* No EOI cycle used here */
-
- iret
-
-
-/*
- * Handle TLB shootdowns.
- */
- .text
- SUPERALIGN_TEXT
- .globl _Xinvltlb
-_Xinvltlb:
- pushl %eax
-
-#ifdef COUNT_XINVLTLB_HITS
- pushl %fs
- movl $KPSEL, %eax
- movl %ax, %fs
- movl _cpuid, %eax
- popl %fs
- ss
- incl _xhits(,%eax,4)
-#endif /* COUNT_XINVLTLB_HITS */
-
- movl %cr3, %eax /* invalidate the TLB */
- movl %eax, %cr3
-
- ss /* stack segment, avoid %ds load */
- movl $0, lapic_eoi /* End Of Interrupt to APIC */
-
- popl %eax
- iret
-
-
-#ifdef BETTER_CLOCK
-
-/*
- * Executed by a CPU when it receives an Xcpucheckstate IPI from another CPU,
- *
- * - Stores current cpu state in checkstate_cpustate[cpuid]
- * 0 == user, 1 == sys, 2 == intr
- * - Stores current process in checkstate_curproc[cpuid]
- *
- * - Signals its receipt by setting bit cpuid in checkstate_probed_cpus.
- *
- * stack: 0->ds, 4->fs, 8->ebx, 12->eax, 16->eip, 20->cs, 24->eflags
- */
-
- .text
- SUPERALIGN_TEXT
- .globl _Xcpucheckstate
- .globl _checkstate_cpustate
- .globl _checkstate_curproc
- .globl _checkstate_pc
-_Xcpucheckstate:
- pushl %eax
- pushl %ebx
- pushl %ds /* save current data segment */
- pushl %fs
-
- movl $KDSEL, %eax
- movl %ax, %ds /* use KERNEL data segment */
- movl $KPSEL, %eax
- movl %ax, %fs
-
- movl $0, lapic_eoi /* End Of Interrupt to APIC */
-
- movl $0, %ebx
- movl 20(%esp), %eax
- andl $3, %eax
- cmpl $3, %eax
- je 1f
- testl $PSL_VM, 24(%esp)
- jne 1f
- incl %ebx /* system or interrupt */
-#ifdef CPL_AND_CML
- cmpl $0, _inside_intr
- je 1f
- incl %ebx /* interrupt */
-#endif
-1:
- movl _cpuid, %eax
- movl %ebx, _checkstate_cpustate(,%eax,4)
- movl _curproc, %ebx
- movl %ebx, _checkstate_curproc(,%eax,4)
- movl 16(%esp), %ebx
- movl %ebx, _checkstate_pc(,%eax,4)
-
- lock /* checkstate_probed_cpus |= (1<<id) */
- btsl %eax, _checkstate_probed_cpus
-
- popl %fs
- popl %ds /* restore previous data segment */
- popl %ebx
- popl %eax
- iret
-
-#endif /* BETTER_CLOCK */
-
-/*
- * Executed by a CPU when it receives an Xcpuast IPI from another CPU,
- *
- * - Signals its receipt by clearing bit cpuid in checkstate_need_ast.
- *
- * - We need a better method of triggering asts on other cpus.
- */
-
- .text
- SUPERALIGN_TEXT
- .globl _Xcpuast
-_Xcpuast:
- PUSH_FRAME
- movl $KDSEL, %eax
- movl %ax, %ds /* use KERNEL data segment */
- movl %ax, %es
- movl $KPSEL, %eax
- movl %ax, %fs
-
- movl _cpuid, %eax
- lock /* checkstate_need_ast &= ~(1<<id) */
- btrl %eax, _checkstate_need_ast
- movl $0, lapic_eoi /* End Of Interrupt to APIC */
-
- lock
- btsl %eax, _checkstate_pending_ast
- jc 1f
-
- FAKE_MCOUNT(13*4(%esp))
-
- /*
- * Giant locks do not come cheap.
- * A lot of cycles are going to be wasted here.
- */
- call _get_isrlock
-
- AVCPL_LOCK
-#ifdef CPL_AND_CML
- movl _cml, %eax
-#else
- movl _cpl, %eax
-#endif
- pushl %eax
- movl $1, _astpending /* XXX */
- AVCPL_UNLOCK
- lock
- incb _intr_nesting_level
- sti
-
- pushl $0
-
- movl _cpuid, %eax
- lock
- btrl %eax, _checkstate_pending_ast
- lock
- btrl %eax, CNAME(resched_cpus)
- jnc 2f
- movl $1, CNAME(want_resched)
- lock
- incl CNAME(want_resched_cnt)
-2:
- lock
- incl CNAME(cpuast_cnt)
- MEXITCOUNT
- jmp _doreti
-1:
- /* We are already in the process of delivering an ast for this CPU */
- POP_FRAME
- iret
-
-
-/*
- * Executed by a CPU when it receives an XFORWARD_IRQ IPI.
- */
-
- .text
- SUPERALIGN_TEXT
- .globl _Xforward_irq
-_Xforward_irq:
- PUSH_FRAME
- movl $KDSEL, %eax
- movl %ax, %ds /* use KERNEL data segment */
- movl %ax, %es
- movl $KPSEL, %eax
- movl %ax, %fs
-
- movl $0, lapic_eoi /* End Of Interrupt to APIC */
-
- FAKE_MCOUNT(13*4(%esp))
-
- ISR_TRYLOCK
- testl %eax,%eax /* Did we get the lock ? */
- jz 1f /* No */
-
- lock
- incl CNAME(forward_irq_hitcnt)
- cmpb $4, _intr_nesting_level
- jae 2f
-
- AVCPL_LOCK
-#ifdef CPL_AND_CML
- movl _cml, %eax
-#else
- movl _cpl, %eax
-#endif
- pushl %eax
- AVCPL_UNLOCK
- lock
- incb _intr_nesting_level
- sti
-
- pushl $0
-
- MEXITCOUNT
- jmp _doreti /* Handle forwarded interrupt */
-1:
- lock
- incl CNAME(forward_irq_misscnt)
- call forward_irq /* Oops, we've lost the isr lock */
- MEXITCOUNT
- POP_FRAME
- iret
-2:
- lock
- incl CNAME(forward_irq_toodeepcnt)
-3:
- ISR_RELLOCK
- MEXITCOUNT
- POP_FRAME
- iret
-
-/*
- *
- */
-forward_irq:
- MCOUNT
- cmpl $0,_invltlb_ok
- jz 4f
-
- cmpl $0, CNAME(forward_irq_enabled)
- jz 4f
-
- movl _mp_lock,%eax
- cmpl $FREE_LOCK,%eax
- jne 1f
- movl $0, %eax /* Pick CPU #0 if noone has lock */
-1:
- shrl $24,%eax
- movl _cpu_num_to_apic_id(,%eax,4),%ecx
- shll $24,%ecx
- movl lapic_icr_hi, %eax
- andl $~APIC_ID_MASK, %eax
- orl %ecx, %eax
- movl %eax, lapic_icr_hi
-
-2:
- movl lapic_icr_lo, %eax
- andl $APIC_DELSTAT_MASK,%eax
- jnz 2b
- movl lapic_icr_lo, %eax
- andl $APIC_RESV2_MASK, %eax
- orl $(APIC_DEST_DESTFLD|APIC_DELMODE_FIXED|XFORWARD_IRQ_OFFSET), %eax
- movl %eax, lapic_icr_lo
-3:
- movl lapic_icr_lo, %eax
- andl $APIC_DELSTAT_MASK,%eax
- jnz 3b
-4:
- ret
-
-/*
- * Executed by a CPU when it receives an Xcpustop IPI from another CPU,
- *
- * - Signals its receipt.
- * - Waits for permission to restart.
- * - Signals its restart.
- */
-
- .text
- SUPERALIGN_TEXT
- .globl _Xcpustop
-_Xcpustop:
- pushl %ebp
- movl %esp, %ebp
- pushl %eax
- pushl %ecx
- pushl %edx
- pushl %ds /* save current data segment */
- pushl %fs
-
- movl $KDSEL, %eax
- movl %ax, %ds /* use KERNEL data segment */
- movl $KPSEL, %eax
- movl %ax, %fs
-
- movl $0, lapic_eoi /* End Of Interrupt to APIC */
-
- movl _cpuid, %eax
- imull $PCB_SIZE, %eax
- leal CNAME(stoppcbs)(%eax), %eax
- pushl %eax
- call CNAME(savectx) /* Save process context */
- addl $4, %esp
-
-
- movl _cpuid, %eax
-
- lock
- btsl %eax, _stopped_cpus /* stopped_cpus |= (1<<id) */
-1:
- btl %eax, _started_cpus /* while (!(started_cpus & (1<<id))) */
- jnc 1b
-
- lock
- btrl %eax, _started_cpus /* started_cpus &= ~(1<<id) */
- lock
- btrl %eax, _stopped_cpus /* stopped_cpus &= ~(1<<id) */
-
- test %eax, %eax
- jnz 2f
-
- movl CNAME(cpustop_restartfunc), %eax
- test %eax, %eax
- jz 2f
- movl $0, CNAME(cpustop_restartfunc) /* One-shot */
-
- call %eax
-2:
- popl %fs
- popl %ds /* restore previous data segment */
- popl %edx
- popl %ecx
- popl %eax
- movl %ebp, %esp
- popl %ebp
- iret
-
-
-MCOUNT_LABEL(bintr)
- FAST_INTR(0,fastintr0)
- FAST_INTR(1,fastintr1)
- FAST_INTR(2,fastintr2)
- FAST_INTR(3,fastintr3)
- FAST_INTR(4,fastintr4)
- FAST_INTR(5,fastintr5)
- FAST_INTR(6,fastintr6)
- FAST_INTR(7,fastintr7)
- FAST_INTR(8,fastintr8)
- FAST_INTR(9,fastintr9)
- FAST_INTR(10,fastintr10)
- FAST_INTR(11,fastintr11)
- FAST_INTR(12,fastintr12)
- FAST_INTR(13,fastintr13)
- FAST_INTR(14,fastintr14)
- FAST_INTR(15,fastintr15)
- FAST_INTR(16,fastintr16)
- FAST_INTR(17,fastintr17)
- FAST_INTR(18,fastintr18)
- FAST_INTR(19,fastintr19)
- FAST_INTR(20,fastintr20)
- FAST_INTR(21,fastintr21)
- FAST_INTR(22,fastintr22)
- FAST_INTR(23,fastintr23)
-#define CLKINTR_PENDING movl $1,CNAME(clkintr_pending)
- INTR(0,intr0, CLKINTR_PENDING)
- INTR(1,intr1,)
- INTR(2,intr2,)
- INTR(3,intr3,)
- INTR(4,intr4,)
- INTR(5,intr5,)
- INTR(6,intr6,)
- INTR(7,intr7,)
- INTR(8,intr8,)
- INTR(9,intr9,)
- INTR(10,intr10,)
- INTR(11,intr11,)
- INTR(12,intr12,)
- INTR(13,intr13,)
- INTR(14,intr14,)
- INTR(15,intr15,)
- INTR(16,intr16,)
- INTR(17,intr17,)
- INTR(18,intr18,)
- INTR(19,intr19,)
- INTR(20,intr20,)
- INTR(21,intr21,)
- INTR(22,intr22,)
- INTR(23,intr23,)
-MCOUNT_LABEL(eintr)
-
-/*
- * Executed by a CPU when it receives a RENDEZVOUS IPI from another CPU.
- *
- * - Calls the generic rendezvous action function.
- */
- .text
- SUPERALIGN_TEXT
- .globl _Xrendezvous
-_Xrendezvous:
- PUSH_FRAME
- movl $KDSEL, %eax
- movl %ax, %ds /* use KERNEL data segment */
- movl %ax, %es
- movl $KPSEL, %eax
- movl %ax, %fs
-
- call _smp_rendezvous_action
-
- movl $0, lapic_eoi /* End Of Interrupt to APIC */
- POP_FRAME
- iret
-
-
- .data
-/*
- * Addresses of interrupt handlers.
- * XresumeNN: Resumption addresses for HWIs.
- */
- .globl _ihandlers
-_ihandlers:
-/*
- * used by:
- * ipl.s: doreti_unpend
- */
- .long Xresume0, Xresume1, Xresume2, Xresume3
- .long Xresume4, Xresume5, Xresume6, Xresume7
- .long Xresume8, Xresume9, Xresume10, Xresume11
- .long Xresume12, Xresume13, Xresume14, Xresume15
- .long Xresume16, Xresume17, Xresume18, Xresume19
- .long Xresume20, Xresume21, Xresume22, Xresume23
-/*
- * used by:
- * ipl.s: doreti_unpend
- * apic_ipl.s: splz_unpend
- */
- .long _swi_null, swi_net, _swi_null, _swi_null
- .long _swi_vm, _swi_null, _softclock, _swi_null
-
-imasks: /* masks for interrupt handlers */
- .space NHWI*4 /* padding; HWI masks are elsewhere */
-
- .long SWI_TTY_MASK, SWI_NET_MASK, SWI_CAMNET_MASK, SWI_CAMBIO_MASK
- .long SWI_VM_MASK, 0, SWI_CLOCK_MASK, 0
-
-/* active flag for lazy masking */
-iactive:
- .long 0
-
-#ifdef COUNT_XINVLTLB_HITS
- .globl _xhits
-_xhits:
- .space (NCPU * 4), 0
-#endif /* COUNT_XINVLTLB_HITS */
-
-/* variables used by stop_cpus()/restart_cpus()/Xcpustop */
- .globl _stopped_cpus, _started_cpus
-_stopped_cpus:
- .long 0
-_started_cpus:
- .long 0
-
-#ifdef BETTER_CLOCK
- .globl _checkstate_probed_cpus
-_checkstate_probed_cpus:
- .long 0
-#endif /* BETTER_CLOCK */
- .globl _checkstate_need_ast
-_checkstate_need_ast:
- .long 0
-_checkstate_pending_ast:
- .long 0
- .globl CNAME(forward_irq_misscnt)
- .globl CNAME(forward_irq_toodeepcnt)
- .globl CNAME(forward_irq_hitcnt)
- .globl CNAME(resched_cpus)
- .globl CNAME(want_resched_cnt)
- .globl CNAME(cpuast_cnt)
- .globl CNAME(cpustop_restartfunc)
-CNAME(forward_irq_misscnt):
- .long 0
-CNAME(forward_irq_hitcnt):
- .long 0
-CNAME(forward_irq_toodeepcnt):
- .long 0
-CNAME(resched_cpus):
- .long 0
-CNAME(want_resched_cnt):
- .long 0
-CNAME(cpuast_cnt):
- .long 0
-CNAME(cpustop_restartfunc):
- .long 0
-
-
-
- .globl _apic_pin_trigger
-_apic_pin_trigger:
- .long 0
-
- .text
diff --git a/sys/i386/i386/legacy.c b/sys/i386/i386/legacy.c
deleted file mode 100644
index f5554f8beac1..000000000000
--- a/sys/i386/i386/legacy.c
+++ /dev/null
@@ -1,434 +0,0 @@
-/*
- * Copyright 1998 Massachusetts Institute of Technology
- *
- * Permission to use, copy, modify, and distribute this software and
- * its documentation for any purpose and without fee is hereby
- * granted, provided that both the above copyright notice and this
- * permission notice appear in all copies, that both the above
- * copyright notice and this permission notice appear in all
- * supporting documentation, and that the name of M.I.T. not be used
- * in advertising or publicity pertaining to distribution of the
- * software without specific, written prior permission. M.I.T. makes
- * no representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied
- * warranty.
- *
- * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS
- * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
- * SHALL M.I.T. 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.
- *
- * $FreeBSD$
- */
-
-/*
- * This code implements a `root nexus' for Intel Architecture
- * machines. The function of the root nexus is to serve as an
- * attachment point for both processors and buses, and to manage
- * resources which are common to all of them. In particular,
- * this code implements the core resource managers for interrupt
- * requests, DMA requests (which rightfully should be a part of the
- * ISA code but it's easier to do it here for now), I/O port addresses,
- * and I/O memory address space.
- */
-
-#include "opt_smp.h"
-#include "mca.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <machine/bus.h>
-#include <sys/rman.h>
-
-#include <machine/vmparam.h>
-#include <vm/vm.h>
-#include <vm/pmap.h>
-#include <machine/pmap.h>
-
-#include <machine/resource.h>
-#ifdef APIC_IO
-#include <machine/smp.h>
-#include <machine/mpapic.h>
-#endif
-
-#ifdef PC98
-#include <pc98/pc98/pc98.h>
-#else
-#include <i386/isa/isa.h>
-#endif
-#include <i386/isa/intr_machdep.h>
-
-static struct rman irq_rman, drq_rman, port_rman, mem_rman;
-
-static int nexus_probe(device_t);
-static int nexus_attach(device_t);
-static int nexus_print_child(device_t, device_t);
-static device_t nexus_add_child(device_t bus, int order, const char *name,
- int unit);
-static struct resource *nexus_alloc_resource(device_t, device_t, int, int *,
- u_long, u_long, u_long, u_int);
-static int nexus_activate_resource(device_t, device_t, int, int,
- struct resource *);
-static int nexus_deactivate_resource(device_t, device_t, int, int,
- struct resource *);
-static int nexus_release_resource(device_t, device_t, int, int,
- struct resource *);
-static int nexus_setup_intr(device_t, device_t, struct resource *, int flags,
- void (*)(void *), void *, void **);
-static int nexus_teardown_intr(device_t, device_t, struct resource *,
- void *);
-
-static device_method_t nexus_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, nexus_probe),
- DEVMETHOD(device_attach, nexus_attach),
- DEVMETHOD(device_detach, bus_generic_detach),
- DEVMETHOD(device_shutdown, bus_generic_shutdown),
- DEVMETHOD(device_suspend, bus_generic_suspend),
- DEVMETHOD(device_resume, bus_generic_resume),
-
- /* Bus interface */
- DEVMETHOD(bus_print_child, nexus_print_child),
- DEVMETHOD(bus_add_child, nexus_add_child),
- DEVMETHOD(bus_read_ivar, bus_generic_read_ivar),
- DEVMETHOD(bus_write_ivar, bus_generic_write_ivar),
- DEVMETHOD(bus_alloc_resource, nexus_alloc_resource),
- DEVMETHOD(bus_release_resource, nexus_release_resource),
- DEVMETHOD(bus_activate_resource, nexus_activate_resource),
- DEVMETHOD(bus_deactivate_resource, nexus_deactivate_resource),
- DEVMETHOD(bus_setup_intr, nexus_setup_intr),
- DEVMETHOD(bus_teardown_intr, nexus_teardown_intr),
-
- { 0, 0 }
-};
-
-static driver_t nexus_driver = {
- "nexus",
- nexus_methods,
- 1, /* no softc */
-};
-static devclass_t nexus_devclass;
-
-DRIVER_MODULE(nexus, root, nexus_driver, nexus_devclass, 0, 0);
-
-static int
-nexus_probe(device_t dev)
-{
-
- device_quiet(dev); /* suppress attach message for neatness */
-
- /*
- * IRQ's are on the mainboard on old systems, but on the ISA part
- * of PCI->ISA bridges. There would be multiple sets of IRQs on
- * multi-ISA-bus systems. PCI interrupts are routed to the ISA
- * component, so in a way, PCI can be a partial child of an ISA bus(!).
- * APIC interrupts are global though.
- * In the non-APIC case, disallow the use of IRQ 2.
- */
- irq_rman.rm_start = 0;
- irq_rman.rm_type = RMAN_ARRAY;
- irq_rman.rm_descr = "Interrupt request lines";
-#ifdef APIC_IO
- irq_rman.rm_end = APIC_INTMAPSIZE - 1;
- if (rman_init(&irq_rman)
- || rman_manage_region(&irq_rman,
- irq_rman.rm_start, irq_rman.rm_end))
- panic("nexus_probe irq_rman");
-#else
- irq_rman.rm_end = 15;
- if (rman_init(&irq_rman)
- || rman_manage_region(&irq_rman, irq_rman.rm_start, 1)
- || rman_manage_region(&irq_rman, 3, irq_rman.rm_end))
- panic("nexus_probe irq_rman");
-#endif
-
- /*
- * ISA DMA on PCI systems is implemented in the ISA part of each
- * PCI->ISA bridge and the channels can be duplicated if there are
- * multiple bridges. (eg: laptops with docking stations)
- */
- drq_rman.rm_start = 0;
- drq_rman.rm_end = 7;
- drq_rman.rm_type = RMAN_ARRAY;
- drq_rman.rm_descr = "DMA request lines";
- /* XXX drq 0 not available on some machines */
- if (rman_init(&drq_rman)
- || rman_manage_region(&drq_rman, 0, 7))
- panic("nexus_probe drq_rman");
-
- /*
- * However, IO ports and Memory truely are global at this level,
- * as are APIC interrupts (however many IO APICS there turn out
- * to be on large systems..)
- */
- port_rman.rm_start = 0;
- port_rman.rm_end = 0xffff;
- port_rman.rm_type = RMAN_ARRAY;
- port_rman.rm_descr = "I/O ports";
- if (rman_init(&port_rman)
- || rman_manage_region(&port_rman, 0, 0xffff))
- panic("nexus_probe port_rman");
-
- mem_rman.rm_start = 0;
- mem_rman.rm_end = ~0u;
- mem_rman.rm_type = RMAN_ARRAY;
- mem_rman.rm_descr = "I/O memory addresses";
- if (rman_init(&mem_rman)
- || rman_manage_region(&mem_rman, 0, ~0))
- panic("nexus_probe mem_rman");
-
- return bus_generic_probe(dev);
-}
-
-static int
-nexus_attach(device_t dev)
-{
- device_t child;
-
- /*
- * First, deal with the children we know about already
- */
- bus_generic_attach(dev);
- /*
- * And if we didn't see EISA or ISA on a pci bridge, create some
- * connection points now so they show up "on motherboard".
- */
- if (!devclass_get_device(devclass_find("eisa"), 0)) {
- child = device_add_child(dev, "eisa", 0);
- if (child == NULL)
- panic("nexus_attach eisa");
- device_probe_and_attach(child);
- }
-#if NMCA > 0
- if (!devclass_get_device(devclass_find("mca"), 0)) {
- child = device_add_child(dev, "mca", 0);
- if (child == 0)
- panic("nexus_probe mca");
- device_probe_and_attach(child);
- }
-#endif
- if (!devclass_get_device(devclass_find("isa"), 0)) {
- child = device_add_child(dev, "isa", 0);
- if (child == NULL)
- panic("nexus_attach isa");
- device_probe_and_attach(child);
- }
-
- return 0;
-}
-
-static int
-nexus_print_child(device_t bus, device_t child)
-{
- int retval = 0;
-
- retval += bus_print_child_header(bus, child);
- retval += printf(" on motherboard\n");
-
- return (retval);
-}
-
-static device_t
-nexus_add_child(device_t bus, int order, const char *name, int unit)
-{
- return device_add_child_ordered(bus, order, name, unit);
-}
-
-/*
- * Allocate a resource on behalf of child. NB: child is usually going to be a
- * child of one of our descendants, not a direct child of nexus0.
- * (Exceptions include npx.)
- */
-static struct resource *
-nexus_alloc_resource(device_t bus, device_t child, int type, int *rid,
- u_long start, u_long end, u_long count, u_int flags)
-{
- struct resource *rv;
- struct rman *rm;
- int needactivate = flags & RF_ACTIVE;
-
- flags &= ~RF_ACTIVE;
-
- switch (type) {
- case SYS_RES_IRQ:
- rm = &irq_rman;
- break;
-
- case SYS_RES_DRQ:
- rm = &drq_rman;
- break;
-
- case SYS_RES_IOPORT:
- rm = &port_rman;
- break;
-
- case SYS_RES_MEMORY:
- rm = &mem_rman;
- break;
-
- default:
- return 0;
- }
-
- rv = rman_reserve_resource(rm, start, end, count, flags, child);
- if (rv == 0)
- return 0;
-
- if (type == SYS_RES_MEMORY) {
- rman_set_bustag(rv, I386_BUS_SPACE_MEM);
- } else if (type == SYS_RES_IOPORT) {
- rman_set_bustag(rv, I386_BUS_SPACE_IO);
- rman_set_bushandle(rv, rv->r_start);
- }
-
- if (needactivate) {
- if (bus_activate_resource(child, type, *rid, rv)) {
- rman_release_resource(rv);
- return 0;
- }
- }
-
- return rv;
-}
-
-static int
-nexus_activate_resource(device_t bus, device_t child, int type, int rid,
- struct resource *r)
-{
- /*
- * If this is a memory resource, map it into the kernel.
- */
- if (rman_get_bustag(r) == I386_BUS_SPACE_MEM) {
- caddr_t vaddr = 0;
-
- if (r->r_end < 1024 * 1024) {
- /*
- * The first 1Mb is mapped at KERNBASE.
- */
- vaddr = (caddr_t)(uintptr_t)(KERNBASE + r->r_start);
- } else {
- u_int32_t paddr;
- u_int32_t psize;
- u_int32_t poffs;
-
- paddr = r->r_start;
- psize = r->r_end - r->r_start;
-
- poffs = paddr - trunc_page(paddr);
- vaddr = (caddr_t) pmap_mapdev(paddr-poffs, psize+poffs) + poffs;
- }
- rman_set_virtual(r, vaddr);
- rman_set_bushandle(r, (bus_space_handle_t) vaddr);
- }
- return (rman_activate_resource(r));
-}
-
-static int
-nexus_deactivate_resource(device_t bus, device_t child, int type, int rid,
- struct resource *r)
-{
- /*
- * If this is a memory resource, unmap it.
- */
- if ((rman_get_bustag(r) == I386_BUS_SPACE_MEM) && (r->r_end >= 1024 * 1024)) {
- u_int32_t psize;
-
- psize = r->r_end - r->r_start;
- pmap_unmapdev((vm_offset_t)rman_get_virtual(r), psize);
- }
-
- return (rman_deactivate_resource(r));
-}
-
-static int
-nexus_release_resource(device_t bus, device_t child, int type, int rid,
- struct resource *r)
-{
- if (r->r_flags & RF_ACTIVE) {
- int error = bus_deactivate_resource(child, type, rid, r);
- if (error)
- return error;
- }
- return (rman_release_resource(r));
-}
-
-/*
- * Currently this uses the really grody interface from kern/kern_intr.c
- * (which really doesn't belong in kern/anything.c). Eventually, all of
- * the code in kern_intr.c and machdep_intr.c should get moved here, since
- * this is going to be the official interface.
- */
-static int
-nexus_setup_intr(device_t bus, device_t child, struct resource *irq,
- int flags, void (*ihand)(void *), void *arg, void **cookiep)
-{
- intrmask_t *mask;
- driver_t *driver;
- int error, icflags;
-
- /* somebody tried to setup an irq that failed to allocate! */
- if (irq == NULL)
- panic("nexus_setup_intr: NULL irq resource!");
-
- *cookiep = 0;
- if (irq->r_flags & RF_SHAREABLE)
- icflags = 0;
- else
- icflags = INTR_EXCL;
-
- driver = device_get_driver(child);
- switch (flags) {
- case INTR_TYPE_TTY:
- mask = &tty_imask;
- break;
- case (INTR_TYPE_TTY | INTR_TYPE_FAST):
- mask = &tty_imask;
- icflags |= INTR_FAST;
- break;
- case INTR_TYPE_BIO:
- mask = &bio_imask;
- break;
- case INTR_TYPE_NET:
- mask = &net_imask;
- break;
- case INTR_TYPE_CAM:
- mask = &cam_imask;
- break;
- case INTR_TYPE_MISC:
- mask = 0;
- break;
- default:
- panic("still using grody create_intr interface");
- }
-
- /*
- * We depend here on rman_activate_resource() being idempotent.
- */
- error = rman_activate_resource(irq);
- if (error)
- return (error);
-
- *cookiep = inthand_add(device_get_nameunit(child), irq->r_start,
- ihand, arg, mask, icflags);
- if (*cookiep == NULL)
- error = EINVAL; /* XXX ??? */
-
- return (error);
-}
-
-static int
-nexus_teardown_intr(device_t dev, device_t child, struct resource *r, void *ih)
-{
- return (inthand_remove(ih));
-}
diff --git a/sys/i386/i386/mptable.c b/sys/i386/i386/mptable.c
deleted file mode 100644
index 8e349a9800e4..000000000000
--- a/sys/i386/i386/mptable.c
+++ /dev/null
@@ -1,2739 +0,0 @@
-/*
- * Copyright (c) 1996, by Steve Passe
- * 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 developer 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include "opt_smp.h"
-#include "opt_cpu.h"
-#include "opt_user_ldt.h"
-
-#ifdef SMP
-#include <machine/smptests.h>
-#else
-#error
-#endif
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/proc.h>
-#include <sys/sysctl.h>
-#include <sys/malloc.h>
-#include <sys/memrange.h>
-#ifdef BETTER_CLOCK
-#include <sys/dkstat.h>
-#endif
-#include <sys/cons.h> /* cngetc() */
-
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <vm/pmap.h>
-#include <vm/vm_kern.h>
-#include <vm/vm_extern.h>
-#ifdef BETTER_CLOCK
-#include <sys/lock.h>
-#include <vm/vm_map.h>
-#include <sys/user.h>
-#ifdef GPROF
-#include <sys/gmon.h>
-#endif
-#endif
-
-#include <machine/smp.h>
-#include <machine/apic.h>
-#include <machine/atomic.h>
-#include <machine/cpufunc.h>
-#include <machine/mpapic.h>
-#include <machine/psl.h>
-#include <machine/segments.h>
-#include <machine/smptests.h> /** TEST_DEFAULT_CONFIG, TEST_TEST1 */
-#include <machine/tss.h>
-#include <machine/specialreg.h>
-#include <machine/globaldata.h>
-
-#if defined(APIC_IO)
-#include <machine/md_var.h> /* setidt() */
-#include <i386/isa/icu.h> /* IPIs */
-#include <i386/isa/intr_machdep.h> /* IPIs */
-#endif /* APIC_IO */
-
-#if defined(TEST_DEFAULT_CONFIG)
-#define MPFPS_MPFB1 TEST_DEFAULT_CONFIG
-#else
-#define MPFPS_MPFB1 mpfps->mpfb1
-#endif /* TEST_DEFAULT_CONFIG */
-
-#define WARMBOOT_TARGET 0
-#define WARMBOOT_OFF (KERNBASE + 0x0467)
-#define WARMBOOT_SEG (KERNBASE + 0x0469)
-
-#ifdef PC98
-#define BIOS_BASE (0xe8000)
-#define BIOS_SIZE (0x18000)
-#else
-#define BIOS_BASE (0xf0000)
-#define BIOS_SIZE (0x10000)
-#endif
-#define BIOS_COUNT (BIOS_SIZE/4)
-
-#define CMOS_REG (0x70)
-#define CMOS_DATA (0x71)
-#define BIOS_RESET (0x0f)
-#define BIOS_WARM (0x0a)
-
-#define PROCENTRY_FLAG_EN 0x01
-#define PROCENTRY_FLAG_BP 0x02
-#define IOAPICENTRY_FLAG_EN 0x01
-
-
-/* MP Floating Pointer Structure */
-typedef struct MPFPS {
- char signature[4];
- void *pap;
- u_char length;
- u_char spec_rev;
- u_char checksum;
- u_char mpfb1;
- u_char mpfb2;
- u_char mpfb3;
- u_char mpfb4;
- u_char mpfb5;
-} *mpfps_t;
-
-/* MP Configuration Table Header */
-typedef struct MPCTH {
- char signature[4];
- u_short base_table_length;
- u_char spec_rev;
- u_char checksum;
- u_char oem_id[8];
- u_char product_id[12];
- void *oem_table_pointer;
- u_short oem_table_size;
- u_short entry_count;
- void *apic_address;
- u_short extended_table_length;
- u_char extended_table_checksum;
- u_char reserved;
-} *mpcth_t;
-
-
-typedef struct PROCENTRY {
- u_char type;
- u_char apic_id;
- u_char apic_version;
- u_char cpu_flags;
- u_long cpu_signature;
- u_long feature_flags;
- u_long reserved1;
- u_long reserved2;
-} *proc_entry_ptr;
-
-typedef struct BUSENTRY {
- u_char type;
- u_char bus_id;
- char bus_type[6];
-} *bus_entry_ptr;
-
-typedef struct IOAPICENTRY {
- u_char type;
- u_char apic_id;
- u_char apic_version;
- u_char apic_flags;
- void *apic_address;
-} *io_apic_entry_ptr;
-
-typedef struct INTENTRY {
- u_char type;
- u_char int_type;
- u_short int_flags;
- u_char src_bus_id;
- u_char src_bus_irq;
- u_char dst_apic_id;
- u_char dst_apic_int;
-} *int_entry_ptr;
-
-/* descriptions of MP basetable entries */
-typedef struct BASETABLE_ENTRY {
- u_char type;
- u_char length;
- char name[16];
-} basetable_entry;
-
-/*
- * this code MUST be enabled here and in mpboot.s.
- * it follows the very early stages of AP boot by placing values in CMOS ram.
- * it NORMALLY will never be needed and thus the primitive method for enabling.
- *
-#define CHECK_POINTS
- */
-
-#if defined(CHECK_POINTS) && !defined(PC98)
-#define CHECK_READ(A) (outb(CMOS_REG, (A)), inb(CMOS_DATA))
-#define CHECK_WRITE(A,D) (outb(CMOS_REG, (A)), outb(CMOS_DATA, (D)))
-
-#define CHECK_INIT(D); \
- CHECK_WRITE(0x34, (D)); \
- CHECK_WRITE(0x35, (D)); \
- CHECK_WRITE(0x36, (D)); \
- CHECK_WRITE(0x37, (D)); \
- CHECK_WRITE(0x38, (D)); \
- CHECK_WRITE(0x39, (D));
-
-#define CHECK_PRINT(S); \
- printf("%s: %d, %d, %d, %d, %d, %d\n", \
- (S), \
- CHECK_READ(0x34), \
- CHECK_READ(0x35), \
- CHECK_READ(0x36), \
- CHECK_READ(0x37), \
- CHECK_READ(0x38), \
- CHECK_READ(0x39));
-
-#else /* CHECK_POINTS */
-
-#define CHECK_INIT(D)
-#define CHECK_PRINT(S)
-
-#endif /* CHECK_POINTS */
-
-/*
- * Values to send to the POST hardware.
- */
-#define MP_BOOTADDRESS_POST 0x10
-#define MP_PROBE_POST 0x11
-#define MPTABLE_PASS1_POST 0x12
-
-#define MP_START_POST 0x13
-#define MP_ENABLE_POST 0x14
-#define MPTABLE_PASS2_POST 0x15
-
-#define START_ALL_APS_POST 0x16
-#define INSTALL_AP_TRAMP_POST 0x17
-#define START_AP_POST 0x18
-
-#define MP_ANNOUNCE_POST 0x19
-
-
-/** XXX FIXME: where does this really belong, isa.h/isa.c perhaps? */
-int current_postcode;
-
-/** XXX FIXME: what system files declare these??? */
-extern struct region_descriptor r_gdt, r_idt;
-
-int bsp_apic_ready = 0; /* flags useability of BSP apic */
-int mp_ncpus; /* # of CPUs, including BSP */
-int mp_naps; /* # of Applications processors */
-int mp_nbusses; /* # of busses */
-int mp_napics; /* # of IO APICs */
-int boot_cpu_id; /* designated BSP */
-vm_offset_t cpu_apic_address;
-vm_offset_t io_apic_address[NAPICID]; /* NAPICID is more than enough */
-extern int nkpt;
-
-u_int32_t cpu_apic_versions[NCPU];
-u_int32_t io_apic_versions[NAPIC];
-
-#ifdef APIC_INTR_DIAGNOSTIC
-int apic_itrace_enter[32];
-int apic_itrace_tryisrlock[32];
-int apic_itrace_gotisrlock[32];
-int apic_itrace_active[32];
-int apic_itrace_masked[32];
-int apic_itrace_noisrlock[32];
-int apic_itrace_masked2[32];
-int apic_itrace_unmask[32];
-int apic_itrace_noforward[32];
-int apic_itrace_leave[32];
-int apic_itrace_enter2[32];
-int apic_itrace_doreti[32];
-int apic_itrace_splz[32];
-int apic_itrace_eoi[32];
-#ifdef APIC_INTR_DIAGNOSTIC_IRQ
-unsigned short apic_itrace_debugbuffer[32768];
-int apic_itrace_debugbuffer_idx;
-struct simplelock apic_itrace_debuglock;
-#endif
-#endif
-
-#ifdef APIC_INTR_REORDER
-struct {
- volatile int *location;
- int bit;
-} apic_isrbit_location[32];
-#endif
-
-struct apic_intmapinfo int_to_apicintpin[APIC_INTMAPSIZE];
-
-/*
- * APIC ID logical/physical mapping structures.
- * We oversize these to simplify boot-time config.
- */
-int cpu_num_to_apic_id[NAPICID];
-int io_num_to_apic_id[NAPICID];
-int apic_id_to_logical[NAPICID];
-
-
-/* Bitmap of all available CPUs */
-u_int all_cpus;
-
-/* AP uses this during bootstrap. Do not staticize. */
-char *bootSTK;
-static int bootAP;
-
-/* Hotwire a 0->4MB V==P mapping */
-extern pt_entry_t *KPTphys;
-
-/* SMP page table page */
-extern pt_entry_t *SMPpt;
-
-struct pcb stoppcbs[NCPU];
-
-int smp_started; /* has the system started? */
-
-/*
- * Local data and functions.
- */
-
-static int mp_capable;
-static u_int boot_address;
-static u_int base_memory;
-
-static int picmode; /* 0: virtual wire mode, 1: PIC mode */
-static mpfps_t mpfps;
-static int search_for_sig(u_int32_t target, int count);
-static void mp_enable(u_int boot_addr);
-
-static int mptable_pass1(void);
-static int mptable_pass2(void);
-static void default_mp_table(int type);
-static void fix_mp_table(void);
-static void setup_apic_irq_mapping(void);
-static void init_locks(void);
-static int start_all_aps(u_int boot_addr);
-static void install_ap_tramp(u_int boot_addr);
-static int start_ap(int logicalCpu, u_int boot_addr);
-static int apic_int_is_bus_type(int intr, int bus_type);
-
-/*
- * Calculate usable address in base memory for AP trampoline code.
- */
-u_int
-mp_bootaddress(u_int basemem)
-{
- POSTCODE(MP_BOOTADDRESS_POST);
-
- base_memory = basemem * 1024; /* convert to bytes */
-
- boot_address = base_memory & ~0xfff; /* round down to 4k boundary */
- if ((base_memory - boot_address) < bootMP_size)
- boot_address -= 4096; /* not enough, lower by 4k */
-
- return boot_address;
-}
-
-
-/*
- * Look for an Intel MP spec table (ie, SMP capable hardware).
- */
-int
-mp_probe(void)
-{
- int x;
- u_long segment;
- u_int32_t target;
-
- POSTCODE(MP_PROBE_POST);
-
- /* see if EBDA exists */
- if ((segment = (u_long) * (u_short *) (KERNBASE + 0x40e)) != 0) {
- /* search first 1K of EBDA */
- target = (u_int32_t) (segment << 4);
- if ((x = search_for_sig(target, 1024 / 4)) >= 0)
- goto found;
- } else {
- /* last 1K of base memory, effective 'top of base' passed in */
- target = (u_int32_t) (base_memory - 0x400);
- if ((x = search_for_sig(target, 1024 / 4)) >= 0)
- goto found;
- }
-
- /* search the BIOS */
- target = (u_int32_t) BIOS_BASE;
- if ((x = search_for_sig(target, BIOS_COUNT)) >= 0)
- goto found;
-
- /* nothing found */
- mpfps = (mpfps_t)0;
- mp_capable = 0;
- return 0;
-
-found:
- /* calculate needed resources */
- mpfps = (mpfps_t)x;
- if (mptable_pass1())
- panic("you must reconfigure your kernel");
-
- /* flag fact that we are running multiple processors */
- mp_capable = 1;
- return 1;
-}
-
-
-/*
- * Startup the SMP processors.
- */
-void
-mp_start(void)
-{
- POSTCODE(MP_START_POST);
-
- /* look for MP capable motherboard */
- if (mp_capable)
- mp_enable(boot_address);
- else
- panic("MP hardware not found!");
-}
-
-
-/*
- * Print various information about the SMP system hardware and setup.
- */
-void
-mp_announce(void)
-{
- int x;
-
- POSTCODE(MP_ANNOUNCE_POST);
-
- printf("FreeBSD/SMP: Multiprocessor motherboard\n");
- printf(" cpu0 (BSP): apic id: %2d", CPU_TO_ID(0));
- printf(", version: 0x%08x", cpu_apic_versions[0]);
- printf(", at 0x%08x\n", cpu_apic_address);
- for (x = 1; x <= mp_naps; ++x) {
- printf(" cpu%d (AP): apic id: %2d", x, CPU_TO_ID(x));
- printf(", version: 0x%08x", cpu_apic_versions[x]);
- printf(", at 0x%08x\n", cpu_apic_address);
- }
-
-#if defined(APIC_IO)
- for (x = 0; x < mp_napics; ++x) {
- printf(" io%d (APIC): apic id: %2d", x, IO_TO_ID(x));
- printf(", version: 0x%08x", io_apic_versions[x]);
- printf(", at 0x%08x\n", io_apic_address[x]);
- }
-#else
- printf(" Warning: APIC I/O disabled\n");
-#endif /* APIC_IO */
-}
-
-/*
- * AP cpu's call this to sync up protected mode.
- */
-void
-init_secondary(void)
-{
- int gsel_tss;
- int x, myid = bootAP;
-
- gdt_segs[GPRIV_SEL].ssd_base = (int) &SMP_prvspace[myid];
- gdt_segs[GPROC0_SEL].ssd_base =
- (int) &SMP_prvspace[myid].globaldata.gd_common_tss;
- SMP_prvspace[myid].globaldata.gd_prvspace = &SMP_prvspace[myid];
-
- for (x = 0; x < NGDT; x++) {
- ssdtosd(&gdt_segs[x], &gdt[myid * NGDT + x].sd);
- }
-
- r_gdt.rd_limit = NGDT * sizeof(gdt[0]) - 1;
- r_gdt.rd_base = (int) &gdt[myid * NGDT];
- lgdt(&r_gdt); /* does magic intra-segment return */
-
- lidt(&r_idt);
-
- lldt(_default_ldt);
-#ifdef USER_LDT
- currentldt = _default_ldt;
-#endif
-
- gsel_tss = GSEL(GPROC0_SEL, SEL_KPL);
- gdt[myid * NGDT + GPROC0_SEL].sd.sd_type = SDT_SYS386TSS;
- common_tss.tss_esp0 = 0; /* not used until after switch */
- common_tss.tss_ss0 = GSEL(GDATA_SEL, SEL_KPL);
- common_tss.tss_ioopt = (sizeof common_tss) << 16;
- tss_gdt = &gdt[myid * NGDT + GPROC0_SEL].sd;
- common_tssd = *tss_gdt;
- ltr(gsel_tss);
-
- load_cr0(0x8005003b); /* XXX! */
-
- pmap_set_opt();
-}
-
-
-#if defined(APIC_IO)
-/*
- * Final configuration of the BSP's local APIC:
- * - disable 'pic mode'.
- * - disable 'virtual wire mode'.
- * - enable NMI.
- */
-void
-bsp_apic_configure(void)
-{
- u_char byte;
- u_int32_t temp;
-
- /* leave 'pic mode' if necessary */
- if (picmode) {
- outb(0x22, 0x70); /* select IMCR */
- byte = inb(0x23); /* current contents */
- byte |= 0x01; /* mask external INTR */
- outb(0x23, byte); /* disconnect 8259s/NMI */
- }
-
- /* mask lint0 (the 8259 'virtual wire' connection) */
- temp = lapic.lvt_lint0;
- temp |= APIC_LVT_M; /* set the mask */
- lapic.lvt_lint0 = temp;
-
- /* setup lint1 to handle NMI */
- temp = lapic.lvt_lint1;
- temp &= ~APIC_LVT_M; /* clear the mask */
- lapic.lvt_lint1 = temp;
-
- if (bootverbose)
- apic_dump("bsp_apic_configure()");
-}
-#endif /* APIC_IO */
-
-
-/*******************************************************************
- * local functions and data
- */
-
-/*
- * start the SMP system
- */
-static void
-mp_enable(u_int boot_addr)
-{
- int x;
-#if defined(APIC_IO)
- int apic;
- u_int ux;
-#endif /* APIC_IO */
-
- POSTCODE(MP_ENABLE_POST);
-
- /* turn on 4MB of V == P addressing so we can get to MP table */
- *(int *)PTD = PG_V | PG_RW | ((uintptr_t)(void *)KPTphys & PG_FRAME);
- invltlb();
-
- /* examine the MP table for needed info, uses physical addresses */
- x = mptable_pass2();
-
- *(int *)PTD = 0;
- invltlb();
-
- /* can't process default configs till the CPU APIC is pmapped */
- if (x)
- default_mp_table(x);
-
- /* post scan cleanup */
- fix_mp_table();
- setup_apic_irq_mapping();
-
-#if defined(APIC_IO)
-
- /* fill the LOGICAL io_apic_versions table */
- for (apic = 0; apic < mp_napics; ++apic) {
- ux = io_apic_read(apic, IOAPIC_VER);
- io_apic_versions[apic] = ux;
- }
-
- /* program each IO APIC in the system */
- for (apic = 0; apic < mp_napics; ++apic)
- if (io_apic_setup(apic) < 0)
- panic("IO APIC setup failure");
-
- /* install a 'Spurious INTerrupt' vector */
- setidt(XSPURIOUSINT_OFFSET, Xspuriousint,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-
- /* install an inter-CPU IPI for TLB invalidation */
- setidt(XINVLTLB_OFFSET, Xinvltlb,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-
-#ifdef BETTER_CLOCK
- /* install an inter-CPU IPI for reading processor state */
- setidt(XCPUCHECKSTATE_OFFSET, Xcpucheckstate,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-#endif
-
- /* install an inter-CPU IPI for all-CPU rendezvous */
- setidt(XRENDEZVOUS_OFFSET, Xrendezvous,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-
- /* install an inter-CPU IPI for forcing an additional software trap */
- setidt(XCPUAST_OFFSET, Xcpuast,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-
- /* install an inter-CPU IPI for interrupt forwarding */
- setidt(XFORWARD_IRQ_OFFSET, Xforward_irq,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-
- /* install an inter-CPU IPI for CPU stop/restart */
- setidt(XCPUSTOP_OFFSET, Xcpustop,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-
-#if defined(TEST_TEST1)
- /* install a "fake hardware INTerrupt" vector */
- setidt(XTEST1_OFFSET, Xtest1,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-#endif /** TEST_TEST1 */
-
-#endif /* APIC_IO */
-
- /* initialize all SMP locks */
- init_locks();
-
- /* start each Application Processor */
- start_all_aps(boot_addr);
-
- /*
- * The init process might be started on a different CPU now,
- * and the boot CPU might not call prepare_usermode to get
- * cr0 correctly configured. Thus we initialize cr0 here.
- */
- load_cr0(rcr0() | CR0_WP | CR0_AM);
-}
-
-
-/*
- * look for the MP spec signature
- */
-
-/* string defined by the Intel MP Spec as identifying the MP table */
-#define MP_SIG 0x5f504d5f /* _MP_ */
-#define NEXT(X) ((X) += 4)
-static int
-search_for_sig(u_int32_t target, int count)
-{
- int x;
- u_int32_t *addr = (u_int32_t *) (KERNBASE + target);
-
- for (x = 0; x < count; NEXT(x))
- if (addr[x] == MP_SIG)
- /* make array index a byte index */
- return (target + (x * sizeof(u_int32_t)));
-
- return -1;
-}
-
-
-static basetable_entry basetable_entry_types[] =
-{
- {0, 20, "Processor"},
- {1, 8, "Bus"},
- {2, 8, "I/O APIC"},
- {3, 8, "I/O INT"},
- {4, 8, "Local INT"}
-};
-
-typedef struct BUSDATA {
- u_char bus_id;
- enum busTypes bus_type;
-} bus_datum;
-
-typedef struct INTDATA {
- u_char int_type;
- u_short int_flags;
- u_char src_bus_id;
- u_char src_bus_irq;
- u_char dst_apic_id;
- u_char dst_apic_int;
- u_char int_vector;
-} io_int, local_int;
-
-typedef struct BUSTYPENAME {
- u_char type;
- char name[7];
-} bus_type_name;
-
-static bus_type_name bus_type_table[] =
-{
- {CBUS, "CBUS"},
- {CBUSII, "CBUSII"},
- {EISA, "EISA"},
- {MCA, "MCA"},
- {UNKNOWN_BUSTYPE, "---"},
- {ISA, "ISA"},
- {MCA, "MCA"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {PCI, "PCI"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {XPRESS, "XPRESS"},
- {UNKNOWN_BUSTYPE, "---"}
-};
-/* from MP spec v1.4, table 5-1 */
-static int default_data[7][5] =
-{
-/* nbus, id0, type0, id1, type1 */
- {1, 0, ISA, 255, 255},
- {1, 0, EISA, 255, 255},
- {1, 0, EISA, 255, 255},
- {1, 0, MCA, 255, 255},
- {2, 0, ISA, 1, PCI},
- {2, 0, EISA, 1, PCI},
- {2, 0, MCA, 1, PCI}
-};
-
-
-/* the bus data */
-static bus_datum bus_data[NBUS];
-
-/* the IO INT data, one entry per possible APIC INTerrupt */
-static io_int io_apic_ints[NINTR];
-
-static int nintrs;
-
-static int processor_entry __P((proc_entry_ptr entry, int cpu));
-static int bus_entry __P((bus_entry_ptr entry, int bus));
-static int io_apic_entry __P((io_apic_entry_ptr entry, int apic));
-static int int_entry __P((int_entry_ptr entry, int intr));
-static int lookup_bus_type __P((char *name));
-
-
-/*
- * 1st pass on motherboard's Intel MP specification table.
- *
- * initializes:
- * mp_ncpus = 1
- *
- * determines:
- * cpu_apic_address (common to all CPUs)
- * io_apic_address[N]
- * mp_naps
- * mp_nbusses
- * mp_napics
- * nintrs
- */
-static int
-mptable_pass1(void)
-{
- int x;
- mpcth_t cth;
- int totalSize;
- void* position;
- int count;
- int type;
- int mustpanic;
-
- POSTCODE(MPTABLE_PASS1_POST);
-
- mustpanic = 0;
-
- /* clear various tables */
- for (x = 0; x < NAPICID; ++x) {
- io_apic_address[x] = ~0; /* IO APIC address table */
- }
-
- /* init everything to empty */
- mp_naps = 0;
- mp_nbusses = 0;
- mp_napics = 0;
- nintrs = 0;
-
- /* check for use of 'default' configuration */
- if (MPFPS_MPFB1 != 0) {
- /* use default addresses */
- cpu_apic_address = DEFAULT_APIC_BASE;
- io_apic_address[0] = DEFAULT_IO_APIC_BASE;
-
- /* fill in with defaults */
- mp_naps = 2; /* includes BSP */
- mp_nbusses = default_data[MPFPS_MPFB1 - 1][0];
-#if defined(APIC_IO)
- mp_napics = 1;
- nintrs = 16;
-#endif /* APIC_IO */
- }
- else {
- if ((cth = mpfps->pap) == 0)
- panic("MP Configuration Table Header MISSING!");
-
- cpu_apic_address = (vm_offset_t) cth->apic_address;
-
- /* walk the table, recording info of interest */
- totalSize = cth->base_table_length - sizeof(struct MPCTH);
- position = (u_char *) cth + sizeof(struct MPCTH);
- count = cth->entry_count;
-
- while (count--) {
- switch (type = *(u_char *) position) {
- case 0: /* processor_entry */
- if (((proc_entry_ptr)position)->cpu_flags
- & PROCENTRY_FLAG_EN)
- ++mp_naps;
- break;
- case 1: /* bus_entry */
- ++mp_nbusses;
- break;
- case 2: /* io_apic_entry */
- if (((io_apic_entry_ptr)position)->apic_flags
- & IOAPICENTRY_FLAG_EN)
- io_apic_address[mp_napics++] =
- (vm_offset_t)((io_apic_entry_ptr)
- position)->apic_address;
- break;
- case 3: /* int_entry */
- ++nintrs;
- break;
- case 4: /* int_entry */
- break;
- default:
- panic("mpfps Base Table HOSED!");
- /* NOTREACHED */
- }
-
- totalSize -= basetable_entry_types[type].length;
- (u_char*)position += basetable_entry_types[type].length;
- }
- }
-
- /* qualify the numbers */
- if (mp_naps > NCPU) {
- printf("Warning: only using %d of %d available CPUs!\n",
- NCPU, mp_naps);
- mp_naps = NCPU;
- }
- if (mp_nbusses > NBUS) {
- printf("found %d busses, increase NBUS\n", mp_nbusses);
- mustpanic = 1;
- }
- if (mp_napics > NAPIC) {
- printf("found %d apics, increase NAPIC\n", mp_napics);
- mustpanic = 1;
- }
- if (nintrs > NINTR) {
- printf("found %d intrs, increase NINTR\n", nintrs);
- mustpanic = 1;
- }
-
- /*
- * Count the BSP.
- * This is also used as a counter while starting the APs.
- */
- mp_ncpus = 1;
-
- --mp_naps; /* subtract the BSP */
-
- return mustpanic;
-}
-
-
-/*
- * 2nd pass on motherboard's Intel MP specification table.
- *
- * sets:
- * boot_cpu_id
- * ID_TO_IO(N), phy APIC ID to log CPU/IO table
- * CPU_TO_ID(N), logical CPU to APIC ID table
- * IO_TO_ID(N), logical IO to APIC ID table
- * bus_data[N]
- * io_apic_ints[N]
- */
-static int
-mptable_pass2(void)
-{
- int x;
- mpcth_t cth;
- int totalSize;
- void* position;
- int count;
- int type;
- int apic, bus, cpu, intr;
-
- POSTCODE(MPTABLE_PASS2_POST);
-
- /* clear various tables */
- for (x = 0; x < NAPICID; ++x) {
- ID_TO_IO(x) = -1; /* phy APIC ID to log CPU/IO table */
- CPU_TO_ID(x) = -1; /* logical CPU to APIC ID table */
- IO_TO_ID(x) = -1; /* logical IO to APIC ID table */
- }
-
- /* clear bus data table */
- for (x = 0; x < NBUS; ++x)
- bus_data[x].bus_id = 0xff;
-
- /* clear IO APIC INT table */
- for (x = 0; x < NINTR; ++x) {
- io_apic_ints[x].int_type = 0xff;
- io_apic_ints[x].int_vector = 0xff;
- }
-
- /* setup the cpu/apic mapping arrays */
- boot_cpu_id = -1;
-
- /* record whether PIC or virtual-wire mode */
- picmode = (mpfps->mpfb2 & 0x80) ? 1 : 0;
-
- /* check for use of 'default' configuration */
- if (MPFPS_MPFB1 != 0)
- return MPFPS_MPFB1; /* return default configuration type */
-
- if ((cth = mpfps->pap) == 0)
- panic("MP Configuration Table Header MISSING!");
-
- /* walk the table, recording info of interest */
- totalSize = cth->base_table_length - sizeof(struct MPCTH);
- position = (u_char *) cth + sizeof(struct MPCTH);
- count = cth->entry_count;
- apic = bus = intr = 0;
- cpu = 1; /* pre-count the BSP */
-
- while (count--) {
- switch (type = *(u_char *) position) {
- case 0:
- if (processor_entry(position, cpu))
- ++cpu;
- break;
- case 1:
- if (bus_entry(position, bus))
- ++bus;
- break;
- case 2:
- if (io_apic_entry(position, apic))
- ++apic;
- break;
- case 3:
- if (int_entry(position, intr))
- ++intr;
- break;
- case 4:
- /* int_entry(position); */
- break;
- default:
- panic("mpfps Base Table HOSED!");
- /* NOTREACHED */
- }
-
- totalSize -= basetable_entry_types[type].length;
- (u_char *) position += basetable_entry_types[type].length;
- }
-
- if (boot_cpu_id == -1)
- panic("NO BSP found!");
-
- /* report fact that its NOT a default configuration */
- return 0;
-}
-
-
-void
-assign_apic_irq(int apic, int intpin, int irq)
-{
- int x;
-
- if (int_to_apicintpin[irq].ioapic != -1)
- panic("assign_apic_irq: inconsistent table");
-
- int_to_apicintpin[irq].ioapic = apic;
- int_to_apicintpin[irq].int_pin = intpin;
- int_to_apicintpin[irq].apic_address = ioapic[apic];
- int_to_apicintpin[irq].redirindex = IOAPIC_REDTBL + 2 * intpin;
-
- for (x = 0; x < nintrs; x++) {
- if ((io_apic_ints[x].int_type == 0 ||
- io_apic_ints[x].int_type == 3) &&
- io_apic_ints[x].int_vector == 0xff &&
- io_apic_ints[x].dst_apic_id == IO_TO_ID(apic) &&
- io_apic_ints[x].dst_apic_int == intpin)
- io_apic_ints[x].int_vector = irq;
- }
-}
-
-void
-revoke_apic_irq(int irq)
-{
- int x;
- int oldapic;
- int oldintpin;
-
- if (int_to_apicintpin[irq].ioapic == -1)
- panic("assign_apic_irq: inconsistent table");
-
- oldapic = int_to_apicintpin[irq].ioapic;
- oldintpin = int_to_apicintpin[irq].int_pin;
-
- int_to_apicintpin[irq].ioapic = -1;
- int_to_apicintpin[irq].int_pin = 0;
- int_to_apicintpin[irq].apic_address = NULL;
- int_to_apicintpin[irq].redirindex = 0;
-
- for (x = 0; x < nintrs; x++) {
- if ((io_apic_ints[x].int_type == 0 ||
- io_apic_ints[x].int_type == 3) &&
- io_apic_ints[x].int_vector == 0xff &&
- io_apic_ints[x].dst_apic_id == IO_TO_ID(oldapic) &&
- io_apic_ints[x].dst_apic_int == oldintpin)
- io_apic_ints[x].int_vector = 0xff;
- }
-}
-
-/*
- * parse an Intel MP specification table
- */
-static void
-fix_mp_table(void)
-{
- int x;
- int id;
- int bus_0 = 0; /* Stop GCC warning */
- int bus_pci = 0; /* Stop GCC warning */
- int num_pci_bus;
-
- /*
- * Fix mis-numbering of the PCI bus and its INT entries if the BIOS
- * did it wrong. The MP spec says that when more than 1 PCI bus
- * exists the BIOS must begin with bus entries for the PCI bus and use
- * actual PCI bus numbering. This implies that when only 1 PCI bus
- * exists the BIOS can choose to ignore this ordering, and indeed many
- * MP motherboards do ignore it. This causes a problem when the PCI
- * sub-system makes requests of the MP sub-system based on PCI bus
- * numbers. So here we look for the situation and renumber the
- * busses and associated INTs in an effort to "make it right".
- */
-
- /* find bus 0, PCI bus, count the number of PCI busses */
- for (num_pci_bus = 0, x = 0; x < mp_nbusses; ++x) {
- if (bus_data[x].bus_id == 0) {
- bus_0 = x;
- }
- if (bus_data[x].bus_type == PCI) {
- ++num_pci_bus;
- bus_pci = x;
- }
- }
- /*
- * bus_0 == slot of bus with ID of 0
- * bus_pci == slot of last PCI bus encountered
- */
-
- /* check the 1 PCI bus case for sanity */
- if (num_pci_bus == 1) {
-
- /* if it is number 0 all is well */
- if (bus_data[bus_pci].bus_id == 0)
- return;
-
- /* mis-numbered, swap with whichever bus uses slot 0 */
-
- /* swap the bus entry types */
- bus_data[bus_pci].bus_type = bus_data[bus_0].bus_type;
- bus_data[bus_0].bus_type = PCI;
-
- /* swap each relavant INTerrupt entry */
- id = bus_data[bus_pci].bus_id;
- for (x = 0; x < nintrs; ++x) {
- if (io_apic_ints[x].src_bus_id == id) {
- io_apic_ints[x].src_bus_id = 0;
- }
- else if (io_apic_ints[x].src_bus_id == 0) {
- io_apic_ints[x].src_bus_id = id;
- }
- }
- }
-}
-
-
-/* Assign low level interrupt handlers */
-static void
-setup_apic_irq_mapping(void)
-{
- int x;
- int int_vector;
-
- /* Clear array */
- for (x = 0; x < APIC_INTMAPSIZE; x++) {
- int_to_apicintpin[x].ioapic = -1;
- int_to_apicintpin[x].int_pin = 0;
- int_to_apicintpin[x].apic_address = NULL;
- int_to_apicintpin[x].redirindex = 0;
- }
-
- /* First assign ISA/EISA interrupts */
- for (x = 0; x < nintrs; x++) {
- int_vector = io_apic_ints[x].src_bus_irq;
- if (int_vector < APIC_INTMAPSIZE &&
- io_apic_ints[x].int_vector == 0xff &&
- int_to_apicintpin[int_vector].ioapic == -1 &&
- (apic_int_is_bus_type(x, ISA) ||
- apic_int_is_bus_type(x, EISA)) &&
- io_apic_ints[x].int_type == 0) {
- assign_apic_irq(ID_TO_IO(io_apic_ints[x].dst_apic_id),
- io_apic_ints[x].dst_apic_int,
- int_vector);
- }
- }
-
- /* Assign interrupts on first 24 intpins on IOAPIC #0 */
- for (x = 0; x < nintrs; x++) {
- int_vector = io_apic_ints[x].dst_apic_int;
- if (int_vector < APIC_INTMAPSIZE &&
- io_apic_ints[x].dst_apic_id == IO_TO_ID(0) &&
- io_apic_ints[x].int_vector == 0xff &&
- int_to_apicintpin[int_vector].ioapic == -1 &&
- (io_apic_ints[x].int_type == 0 ||
- io_apic_ints[x].int_type == 3)) {
- assign_apic_irq(0,
- io_apic_ints[x].dst_apic_int,
- int_vector);
- }
- }
- /*
- * Assign interrupts for remaining intpins.
- * Skip IOAPIC #0 intpin 0 if the type is ExtInt, since this indicates
- * that an entry for ISA/EISA irq 0 exist, and a fallback to mixed mode
- * due to 8254 interrupts not being delivered can reuse that low level
- * interrupt handler.
- */
- int_vector = 0;
- while (int_vector < APIC_INTMAPSIZE &&
- int_to_apicintpin[int_vector].ioapic != -1)
- int_vector++;
- for (x = 0; x < nintrs && int_vector < APIC_INTMAPSIZE; x++) {
- if ((io_apic_ints[x].int_type == 0 ||
- (io_apic_ints[x].int_type == 3 &&
- (io_apic_ints[x].dst_apic_id != IO_TO_ID(0) ||
- io_apic_ints[x].dst_apic_int != 0))) &&
- io_apic_ints[x].int_vector == 0xff) {
- assign_apic_irq(ID_TO_IO(io_apic_ints[x].dst_apic_id),
- io_apic_ints[x].dst_apic_int,
- int_vector);
- int_vector++;
- while (int_vector < APIC_INTMAPSIZE &&
- int_to_apicintpin[int_vector].ioapic != -1)
- int_vector++;
- }
- }
-}
-
-
-static int
-processor_entry(proc_entry_ptr entry, int cpu)
-{
- /* check for usability */
- if (!(entry->cpu_flags & PROCENTRY_FLAG_EN))
- return 0;
-
- /* check for BSP flag */
- if (entry->cpu_flags & PROCENTRY_FLAG_BP) {
- boot_cpu_id = entry->apic_id;
- CPU_TO_ID(0) = entry->apic_id;
- ID_TO_CPU(entry->apic_id) = 0;
- return 0; /* its already been counted */
- }
-
- /* add another AP to list, if less than max number of CPUs */
- else if (cpu < NCPU) {
- CPU_TO_ID(cpu) = entry->apic_id;
- ID_TO_CPU(entry->apic_id) = cpu;
- return 1;
- }
-
- return 0;
-}
-
-
-static int
-bus_entry(bus_entry_ptr entry, int bus)
-{
- int x;
- char c, name[8];
-
- /* encode the name into an index */
- for (x = 0; x < 6; ++x) {
- if ((c = entry->bus_type[x]) == ' ')
- break;
- name[x] = c;
- }
- name[x] = '\0';
-
- if ((x = lookup_bus_type(name)) == UNKNOWN_BUSTYPE)
- panic("unknown bus type: '%s'", name);
-
- bus_data[bus].bus_id = entry->bus_id;
- bus_data[bus].bus_type = x;
-
- return 1;
-}
-
-
-static int
-io_apic_entry(io_apic_entry_ptr entry, int apic)
-{
- if (!(entry->apic_flags & IOAPICENTRY_FLAG_EN))
- return 0;
-
- IO_TO_ID(apic) = entry->apic_id;
- ID_TO_IO(entry->apic_id) = apic;
-
- return 1;
-}
-
-
-static int
-lookup_bus_type(char *name)
-{
- int x;
-
- for (x = 0; x < MAX_BUSTYPE; ++x)
- if (strcmp(bus_type_table[x].name, name) == 0)
- return bus_type_table[x].type;
-
- return UNKNOWN_BUSTYPE;
-}
-
-
-static int
-int_entry(int_entry_ptr entry, int intr)
-{
- int apic;
-
- io_apic_ints[intr].int_type = entry->int_type;
- io_apic_ints[intr].int_flags = entry->int_flags;
- io_apic_ints[intr].src_bus_id = entry->src_bus_id;
- io_apic_ints[intr].src_bus_irq = entry->src_bus_irq;
- if (entry->dst_apic_id == 255) {
- /* This signal goes to all IO APICS. Select an IO APIC
- with sufficient number of interrupt pins */
- for (apic = 0; apic < mp_napics; apic++)
- if (((io_apic_read(apic, IOAPIC_VER) &
- IOART_VER_MAXREDIR) >> MAXREDIRSHIFT) >=
- entry->dst_apic_int)
- break;
- if (apic < mp_napics)
- io_apic_ints[intr].dst_apic_id = IO_TO_ID(apic);
- else
- io_apic_ints[intr].dst_apic_id = entry->dst_apic_id;
- } else
- io_apic_ints[intr].dst_apic_id = entry->dst_apic_id;
- io_apic_ints[intr].dst_apic_int = entry->dst_apic_int;
-
- return 1;
-}
-
-
-static int
-apic_int_is_bus_type(int intr, int bus_type)
-{
- int bus;
-
- for (bus = 0; bus < mp_nbusses; ++bus)
- if ((bus_data[bus].bus_id == io_apic_ints[intr].src_bus_id)
- && ((int) bus_data[bus].bus_type == bus_type))
- return 1;
-
- return 0;
-}
-
-
-/*
- * Given a traditional ISA INT mask, return an APIC mask.
- */
-u_int
-isa_apic_mask(u_int isa_mask)
-{
- int isa_irq;
- int apic_pin;
-
-#if defined(SKIP_IRQ15_REDIRECT)
- if (isa_mask == (1 << 15)) {
- printf("skipping ISA IRQ15 redirect\n");
- return isa_mask;
- }
-#endif /* SKIP_IRQ15_REDIRECT */
-
- isa_irq = ffs(isa_mask); /* find its bit position */
- if (isa_irq == 0) /* doesn't exist */
- return 0;
- --isa_irq; /* make it zero based */
-
- apic_pin = isa_apic_irq(isa_irq); /* look for APIC connection */
- if (apic_pin == -1)
- return 0;
-
- return (1 << apic_pin); /* convert pin# to a mask */
-}
-
-
-/*
- * Determine which APIC pin an ISA/EISA INT is attached to.
- */
-#define INTTYPE(I) (io_apic_ints[(I)].int_type)
-#define INTPIN(I) (io_apic_ints[(I)].dst_apic_int)
-#define INTIRQ(I) (io_apic_ints[(I)].int_vector)
-#define INTAPIC(I) (ID_TO_IO(io_apic_ints[(I)].dst_apic_id))
-
-#define SRCBUSIRQ(I) (io_apic_ints[(I)].src_bus_irq)
-int
-isa_apic_irq(int isa_irq)
-{
- int intr;
-
- for (intr = 0; intr < nintrs; ++intr) { /* check each record */
- if (INTTYPE(intr) == 0) { /* standard INT */
- if (SRCBUSIRQ(intr) == isa_irq) {
- if (apic_int_is_bus_type(intr, ISA) ||
- apic_int_is_bus_type(intr, EISA))
- return INTIRQ(intr); /* found */
- }
- }
- }
- return -1; /* NOT found */
-}
-
-
-/*
- * Determine which APIC pin a PCI INT is attached to.
- */
-#define SRCBUSID(I) (io_apic_ints[(I)].src_bus_id)
-#define SRCBUSDEVICE(I) ((io_apic_ints[(I)].src_bus_irq >> 2) & 0x1f)
-#define SRCBUSLINE(I) (io_apic_ints[(I)].src_bus_irq & 0x03)
-int
-pci_apic_irq(int pciBus, int pciDevice, int pciInt)
-{
- int intr;
-
- --pciInt; /* zero based */
-
- for (intr = 0; intr < nintrs; ++intr) /* check each record */
- if ((INTTYPE(intr) == 0) /* standard INT */
- && (SRCBUSID(intr) == pciBus)
- && (SRCBUSDEVICE(intr) == pciDevice)
- && (SRCBUSLINE(intr) == pciInt)) /* a candidate IRQ */
- if (apic_int_is_bus_type(intr, PCI))
- return INTIRQ(intr); /* exact match */
-
- return -1; /* NOT found */
-}
-
-int
-next_apic_irq(int irq)
-{
- int intr, ointr;
- int bus, bustype;
-
- bus = 0;
- bustype = 0;
- for (intr = 0; intr < nintrs; intr++) {
- if (INTIRQ(intr) != irq || INTTYPE(intr) != 0)
- continue;
- bus = SRCBUSID(intr);
- bustype = apic_bus_type(bus);
- if (bustype != ISA &&
- bustype != EISA &&
- bustype != PCI)
- continue;
- break;
- }
- if (intr >= nintrs) {
- return -1;
- }
- for (ointr = intr + 1; ointr < nintrs; ointr++) {
- if (INTTYPE(ointr) != 0)
- continue;
- if (bus != SRCBUSID(ointr))
- continue;
- if (bustype == PCI) {
- if (SRCBUSDEVICE(intr) != SRCBUSDEVICE(ointr))
- continue;
- if (SRCBUSLINE(intr) != SRCBUSLINE(ointr))
- continue;
- }
- if (bustype == ISA || bustype == EISA) {
- if (SRCBUSIRQ(intr) != SRCBUSIRQ(ointr))
- continue;
- }
- if (INTPIN(intr) == INTPIN(ointr))
- continue;
- break;
- }
- if (ointr >= nintrs) {
- return -1;
- }
- return INTIRQ(ointr);
-}
-#undef SRCBUSLINE
-#undef SRCBUSDEVICE
-#undef SRCBUSID
-#undef SRCBUSIRQ
-
-#undef INTPIN
-#undef INTIRQ
-#undef INTAPIC
-#undef INTTYPE
-
-
-/*
- * Reprogram the MB chipset to NOT redirect an ISA INTerrupt.
- *
- * XXX FIXME:
- * Exactly what this means is unclear at this point. It is a solution
- * for motherboards that redirect the MBIRQ0 pin. Generically a motherboard
- * could route any of the ISA INTs to upper (>15) IRQ values. But most would
- * NOT be redirected via MBIRQ0, thus "undirect()ing" them would NOT be an
- * option.
- */
-int
-undirect_isa_irq(int rirq)
-{
-#if defined(READY)
- if (bootverbose)
- printf("Freeing redirected ISA irq %d.\n", rirq);
- /** FIXME: tickle the MB redirector chip */
- return ???;
-#else
- if (bootverbose)
- printf("Freeing (NOT implemented) redirected ISA irq %d.\n", rirq);
- return 0;
-#endif /* READY */
-}
-
-
-/*
- * Reprogram the MB chipset to NOT redirect a PCI INTerrupt
- */
-int
-undirect_pci_irq(int rirq)
-{
-#if defined(READY)
- if (bootverbose)
- printf("Freeing redirected PCI irq %d.\n", rirq);
-
- /** FIXME: tickle the MB redirector chip */
- return ???;
-#else
- if (bootverbose)
- printf("Freeing (NOT implemented) redirected PCI irq %d.\n",
- rirq);
- return 0;
-#endif /* READY */
-}
-
-
-/*
- * given a bus ID, return:
- * the bus type if found
- * -1 if NOT found
- */
-int
-apic_bus_type(int id)
-{
- int x;
-
- for (x = 0; x < mp_nbusses; ++x)
- if (bus_data[x].bus_id == id)
- return bus_data[x].bus_type;
-
- return -1;
-}
-
-
-/*
- * given a LOGICAL APIC# and pin#, return:
- * the associated src bus ID if found
- * -1 if NOT found
- */
-int
-apic_src_bus_id(int apic, int pin)
-{
- int x;
-
- /* search each of the possible INTerrupt sources */
- for (x = 0; x < nintrs; ++x)
- if ((apic == ID_TO_IO(io_apic_ints[x].dst_apic_id)) &&
- (pin == io_apic_ints[x].dst_apic_int))
- return (io_apic_ints[x].src_bus_id);
-
- return -1; /* NOT found */
-}
-
-
-/*
- * given a LOGICAL APIC# and pin#, return:
- * the associated src bus IRQ if found
- * -1 if NOT found
- */
-int
-apic_src_bus_irq(int apic, int pin)
-{
- int x;
-
- for (x = 0; x < nintrs; x++)
- if ((apic == ID_TO_IO(io_apic_ints[x].dst_apic_id)) &&
- (pin == io_apic_ints[x].dst_apic_int))
- return (io_apic_ints[x].src_bus_irq);
-
- return -1; /* NOT found */
-}
-
-
-/*
- * given a LOGICAL APIC# and pin#, return:
- * the associated INTerrupt type if found
- * -1 if NOT found
- */
-int
-apic_int_type(int apic, int pin)
-{
- int x;
-
- /* search each of the possible INTerrupt sources */
- for (x = 0; x < nintrs; ++x)
- if ((apic == ID_TO_IO(io_apic_ints[x].dst_apic_id)) &&
- (pin == io_apic_ints[x].dst_apic_int))
- return (io_apic_ints[x].int_type);
-
- return -1; /* NOT found */
-}
-
-int
-apic_irq(int apic, int pin)
-{
- int x;
- int res;
-
- for (x = 0; x < nintrs; ++x)
- if ((apic == ID_TO_IO(io_apic_ints[x].dst_apic_id)) &&
- (pin == io_apic_ints[x].dst_apic_int)) {
- res = io_apic_ints[x].int_vector;
- if (res == 0xff)
- return -1;
- if (apic != int_to_apicintpin[res].ioapic)
- panic("apic_irq: inconsistent table");
- if (pin != int_to_apicintpin[res].int_pin)
- panic("apic_irq inconsistent table (2)");
- return res;
- }
- return -1;
-}
-
-
-/*
- * given a LOGICAL APIC# and pin#, return:
- * the associated trigger mode if found
- * -1 if NOT found
- */
-int
-apic_trigger(int apic, int pin)
-{
- int x;
-
- /* search each of the possible INTerrupt sources */
- for (x = 0; x < nintrs; ++x)
- if ((apic == ID_TO_IO(io_apic_ints[x].dst_apic_id)) &&
- (pin == io_apic_ints[x].dst_apic_int))
- return ((io_apic_ints[x].int_flags >> 2) & 0x03);
-
- return -1; /* NOT found */
-}
-
-
-/*
- * given a LOGICAL APIC# and pin#, return:
- * the associated 'active' level if found
- * -1 if NOT found
- */
-int
-apic_polarity(int apic, int pin)
-{
- int x;
-
- /* search each of the possible INTerrupt sources */
- for (x = 0; x < nintrs; ++x)
- if ((apic == ID_TO_IO(io_apic_ints[x].dst_apic_id)) &&
- (pin == io_apic_ints[x].dst_apic_int))
- return (io_apic_ints[x].int_flags & 0x03);
-
- return -1; /* NOT found */
-}
-
-
-/*
- * set data according to MP defaults
- * FIXME: probably not complete yet...
- */
-static void
-default_mp_table(int type)
-{
- int ap_cpu_id;
-#if defined(APIC_IO)
- u_int32_t ux;
- int io_apic_id;
- int pin;
-#endif /* APIC_IO */
-
-#if 0
- printf(" MP default config type: %d\n", type);
- switch (type) {
- case 1:
- printf(" bus: ISA, APIC: 82489DX\n");
- break;
- case 2:
- printf(" bus: EISA, APIC: 82489DX\n");
- break;
- case 3:
- printf(" bus: EISA, APIC: 82489DX\n");
- break;
- case 4:
- printf(" bus: MCA, APIC: 82489DX\n");
- break;
- case 5:
- printf(" bus: ISA+PCI, APIC: Integrated\n");
- break;
- case 6:
- printf(" bus: EISA+PCI, APIC: Integrated\n");
- break;
- case 7:
- printf(" bus: MCA+PCI, APIC: Integrated\n");
- break;
- default:
- printf(" future type\n");
- break;
- /* NOTREACHED */
- }
-#endif /* 0 */
-
- boot_cpu_id = (lapic.id & APIC_ID_MASK) >> 24;
- ap_cpu_id = (boot_cpu_id == 0) ? 1 : 0;
-
- /* BSP */
- CPU_TO_ID(0) = boot_cpu_id;
- ID_TO_CPU(boot_cpu_id) = 0;
-
- /* one and only AP */
- CPU_TO_ID(1) = ap_cpu_id;
- ID_TO_CPU(ap_cpu_id) = 1;
-
-#if defined(APIC_IO)
- /* one and only IO APIC */
- io_apic_id = (io_apic_read(0, IOAPIC_ID) & APIC_ID_MASK) >> 24;
-
- /*
- * sanity check, refer to MP spec section 3.6.6, last paragraph
- * necessary as some hardware isn't properly setting up the IO APIC
- */
-#if defined(REALLY_ANAL_IOAPICID_VALUE)
- if (io_apic_id != 2) {
-#else
- if ((io_apic_id == 0) || (io_apic_id == 1) || (io_apic_id == 15)) {
-#endif /* REALLY_ANAL_IOAPICID_VALUE */
- ux = io_apic_read(0, IOAPIC_ID); /* get current contents */
- ux &= ~APIC_ID_MASK; /* clear the ID field */
- ux |= 0x02000000; /* set it to '2' */
- io_apic_write(0, IOAPIC_ID, ux); /* write new value */
- ux = io_apic_read(0, IOAPIC_ID); /* re-read && test */
- if ((ux & APIC_ID_MASK) != 0x02000000)
- panic("can't control IO APIC ID, reg: 0x%08x", ux);
- io_apic_id = 2;
- }
- IO_TO_ID(0) = io_apic_id;
- ID_TO_IO(io_apic_id) = 0;
-#endif /* APIC_IO */
-
- /* fill out bus entries */
- switch (type) {
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- bus_data[0].bus_id = default_data[type - 1][1];
- bus_data[0].bus_type = default_data[type - 1][2];
- bus_data[1].bus_id = default_data[type - 1][3];
- bus_data[1].bus_type = default_data[type - 1][4];
- break;
-
- /* case 4: case 7: MCA NOT supported */
- default: /* illegal/reserved */
- panic("BAD default MP config: %d", type);
- /* NOTREACHED */
- }
-
-#if defined(APIC_IO)
- /* general cases from MP v1.4, table 5-2 */
- for (pin = 0; pin < 16; ++pin) {
- io_apic_ints[pin].int_type = 0;
- io_apic_ints[pin].int_flags = 0x05; /* edge/active-hi */
- io_apic_ints[pin].src_bus_id = 0;
- io_apic_ints[pin].src_bus_irq = pin; /* IRQ2 caught below */
- io_apic_ints[pin].dst_apic_id = io_apic_id;
- io_apic_ints[pin].dst_apic_int = pin; /* 1-to-1 */
- }
-
- /* special cases from MP v1.4, table 5-2 */
- if (type == 2) {
- io_apic_ints[2].int_type = 0xff; /* N/C */
- io_apic_ints[13].int_type = 0xff; /* N/C */
-#if !defined(APIC_MIXED_MODE)
- /** FIXME: ??? */
- panic("sorry, can't support type 2 default yet");
-#endif /* APIC_MIXED_MODE */
- }
- else
- io_apic_ints[2].src_bus_irq = 0; /* ISA IRQ0 is on APIC INT 2 */
-
- if (type == 7)
- io_apic_ints[0].int_type = 0xff; /* N/C */
- else
- io_apic_ints[0].int_type = 3; /* vectored 8259 */
-#endif /* APIC_IO */
-}
-
-
-/*
- * initialize all the SMP locks
- */
-
-/* critical region around IO APIC, apic_imen */
-struct simplelock imen_lock;
-
-/* critical region around splxx(), cpl, cml, cil, ipending */
-struct simplelock cpl_lock;
-
-/* Make FAST_INTR() routines sequential */
-struct simplelock fast_intr_lock;
-
-/* critical region around INTR() routines */
-struct simplelock intr_lock;
-
-/* lock regions protected in UP kernel via cli/sti */
-struct simplelock mpintr_lock;
-
-/* lock region used by kernel profiling */
-struct simplelock mcount_lock;
-
-#ifdef USE_COMLOCK
-/* locks com (tty) data/hardware accesses: a FASTINTR() */
-struct simplelock com_lock;
-#endif /* USE_COMLOCK */
-
-#ifdef USE_CLOCKLOCK
-/* lock regions around the clock hardware */
-struct simplelock clock_lock;
-#endif /* USE_CLOCKLOCK */
-
-/* lock around the MP rendezvous */
-static struct simplelock smp_rv_lock;
-
-static void
-init_locks(void)
-{
- /*
- * Get the initial mp_lock with a count of 1 for the BSP.
- * This uses a LOGICAL cpu ID, ie BSP == 0.
- */
- mp_lock = 0x00000001;
-
- /* ISR uses its own "giant lock" */
- isr_lock = FREE_LOCK;
-
-#if defined(APIC_INTR_DIAGNOSTIC) && defined(APIC_INTR_DIAGNOSTIC_IRQ)
- s_lock_init((struct simplelock*)&apic_itrace_debuglock);
-#endif
-
- s_lock_init((struct simplelock*)&mpintr_lock);
-
- s_lock_init((struct simplelock*)&mcount_lock);
-
- s_lock_init((struct simplelock*)&fast_intr_lock);
- s_lock_init((struct simplelock*)&intr_lock);
- s_lock_init((struct simplelock*)&imen_lock);
- s_lock_init((struct simplelock*)&cpl_lock);
- s_lock_init(&smp_rv_lock);
-
-#ifdef USE_COMLOCK
- s_lock_init((struct simplelock*)&com_lock);
-#endif /* USE_COMLOCK */
-#ifdef USE_CLOCKLOCK
- s_lock_init((struct simplelock*)&clock_lock);
-#endif /* USE_CLOCKLOCK */
-}
-
-
-/* Wait for all APs to be fully initialized */
-extern int wait_ap(unsigned int);
-
-/*
- * start each AP in our list
- */
-static int
-start_all_aps(u_int boot_addr)
-{
- int x, i, pg;
- u_char mpbiosreason;
- u_long mpbioswarmvec;
- struct globaldata *gd;
- char *stack;
-
- POSTCODE(START_ALL_APS_POST);
-
- /* initialize BSP's local APIC */
- apic_initialize();
- bsp_apic_ready = 1;
-
- /* install the AP 1st level boot code */
- install_ap_tramp(boot_addr);
-
-
- /* save the current value of the warm-start vector */
- mpbioswarmvec = *((u_long *) WARMBOOT_OFF);
-#ifndef PC98
- outb(CMOS_REG, BIOS_RESET);
- mpbiosreason = inb(CMOS_DATA);
-#endif
-
- /* record BSP in CPU map */
- all_cpus = 1;
-
- /* set up 0 -> 4MB P==V mapping for AP boot */
- *(int *)PTD = PG_V | PG_RW | ((uintptr_t)(void *)KPTphys & PG_FRAME);
- invltlb();
-
- /* start each AP */
- for (x = 1; x <= mp_naps; ++x) {
-
- /* This is a bit verbose, it will go away soon. */
-
- /* first page of AP's private space */
- pg = x * i386_btop(sizeof(struct privatespace));
-
- /* allocate a new private data page */
- gd = (struct globaldata *)kmem_alloc(kernel_map, PAGE_SIZE);
-
- /* wire it into the private page table page */
- SMPpt[pg] = (pt_entry_t)(PG_V | PG_RW | vtophys(gd));
-
- /* allocate and set up an idle stack data page */
- stack = (char *)kmem_alloc(kernel_map, UPAGES*PAGE_SIZE);
- for (i = 0; i < UPAGES; i++)
- SMPpt[pg + 5 + i] = (pt_entry_t)
- (PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack));
-
- SMPpt[pg + 1] = 0; /* *prv_CMAP1 */
- SMPpt[pg + 2] = 0; /* *prv_CMAP2 */
- SMPpt[pg + 3] = 0; /* *prv_CMAP3 */
- SMPpt[pg + 4] = 0; /* *prv_PMAP1 */
-
- /* prime data page for it to use */
- gd->gd_cpuid = x;
- gd->gd_cpu_lockid = x << 24;
- gd->gd_prv_CMAP1 = &SMPpt[pg + 1];
- gd->gd_prv_CMAP2 = &SMPpt[pg + 2];
- gd->gd_prv_CMAP3 = &SMPpt[pg + 3];
- gd->gd_prv_PMAP1 = &SMPpt[pg + 4];
- gd->gd_prv_CADDR1 = SMP_prvspace[x].CPAGE1;
- gd->gd_prv_CADDR2 = SMP_prvspace[x].CPAGE2;
- gd->gd_prv_CADDR3 = SMP_prvspace[x].CPAGE3;
- gd->gd_prv_PADDR1 = (unsigned *)SMP_prvspace[x].PPAGE1;
-
- /* setup a vector to our boot code */
- *((volatile u_short *) WARMBOOT_OFF) = WARMBOOT_TARGET;
- *((volatile u_short *) WARMBOOT_SEG) = (boot_addr >> 4);
-#ifndef PC98
- outb(CMOS_REG, BIOS_RESET);
- outb(CMOS_DATA, BIOS_WARM); /* 'warm-start' */
-#endif
-
- bootSTK = &SMP_prvspace[x].idlestack[UPAGES*PAGE_SIZE];
- bootAP = x;
-
- /* attempt to start the Application Processor */
- CHECK_INIT(99); /* setup checkpoints */
- if (!start_ap(x, boot_addr)) {
- printf("AP #%d (PHY# %d) failed!\n", x, CPU_TO_ID(x));
- CHECK_PRINT("trace"); /* show checkpoints */
- /* better panic as the AP may be running loose */
- printf("panic y/n? [y] ");
- if (cngetc() != 'n')
- panic("bye-bye");
- }
- CHECK_PRINT("trace"); /* show checkpoints */
-
- /* record its version info */
- cpu_apic_versions[x] = cpu_apic_versions[0];
-
- all_cpus |= (1 << x); /* record AP in CPU map */
- }
-
- /* build our map of 'other' CPUs */
- other_cpus = all_cpus & ~(1 << cpuid);
-
- /* fill in our (BSP) APIC version */
- cpu_apic_versions[0] = lapic.version;
-
- /* restore the warmstart vector */
- *(u_long *) WARMBOOT_OFF = mpbioswarmvec;
-#ifndef PC98
- outb(CMOS_REG, BIOS_RESET);
- outb(CMOS_DATA, mpbiosreason);
-#endif
-
- /*
- * Set up the idle context for the BSP. Similar to above except
- * that some was done by locore, some by pmap.c and some is implicit
- * because the BSP is cpu#0 and the page is initially zero, and also
- * because we can refer to variables by name on the BSP..
- */
-
- /* Allocate and setup BSP idle stack */
- stack = (char *)kmem_alloc(kernel_map, UPAGES * PAGE_SIZE);
- for (i = 0; i < UPAGES; i++)
- SMPpt[5 + i] = (pt_entry_t)
- (PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack));
-
- *(int *)PTD = 0;
- pmap_set_opt();
-
- /* number of APs actually started */
- return mp_ncpus - 1;
-}
-
-
-/*
- * load the 1st level AP boot code into base memory.
- */
-
-/* targets for relocation */
-extern void bigJump(void);
-extern void bootCodeSeg(void);
-extern void bootDataSeg(void);
-extern void MPentry(void);
-extern u_int MP_GDT;
-extern u_int mp_gdtbase;
-
-static void
-install_ap_tramp(u_int boot_addr)
-{
- int x;
- int size = *(int *) ((u_long) & bootMP_size);
- u_char *src = (u_char *) ((u_long) bootMP);
- u_char *dst = (u_char *) boot_addr + KERNBASE;
- u_int boot_base = (u_int) bootMP;
- u_int8_t *dst8;
- u_int16_t *dst16;
- u_int32_t *dst32;
-
- POSTCODE(INSTALL_AP_TRAMP_POST);
-
- for (x = 0; x < size; ++x)
- *dst++ = *src++;
-
- /*
- * modify addresses in code we just moved to basemem. unfortunately we
- * need fairly detailed info about mpboot.s for this to work. changes
- * to mpboot.s might require changes here.
- */
-
- /* boot code is located in KERNEL space */
- dst = (u_char *) boot_addr + KERNBASE;
-
- /* modify the lgdt arg */
- dst32 = (u_int32_t *) (dst + ((u_int) & mp_gdtbase - boot_base));
- *dst32 = boot_addr + ((u_int) & MP_GDT - boot_base);
-
- /* modify the ljmp target for MPentry() */
- dst32 = (u_int32_t *) (dst + ((u_int) bigJump - boot_base) + 1);
- *dst32 = ((u_int) MPentry - KERNBASE);
-
- /* modify the target for boot code segment */
- dst16 = (u_int16_t *) (dst + ((u_int) bootCodeSeg - boot_base));
- dst8 = (u_int8_t *) (dst16 + 1);
- *dst16 = (u_int) boot_addr & 0xffff;
- *dst8 = ((u_int) boot_addr >> 16) & 0xff;
-
- /* modify the target for boot data segment */
- dst16 = (u_int16_t *) (dst + ((u_int) bootDataSeg - boot_base));
- dst8 = (u_int8_t *) (dst16 + 1);
- *dst16 = (u_int) boot_addr & 0xffff;
- *dst8 = ((u_int) boot_addr >> 16) & 0xff;
-}
-
-
-/*
- * this function starts the AP (application processor) identified
- * by the APIC ID 'physicalCpu'. It does quite a "song and dance"
- * to accomplish this. This is necessary because of the nuances
- * of the different hardware we might encounter. It ain't pretty,
- * but it seems to work.
- */
-static int
-start_ap(int logical_cpu, u_int boot_addr)
-{
- int physical_cpu;
- int vector;
- int cpus;
- u_long icr_lo, icr_hi;
-
- POSTCODE(START_AP_POST);
-
- /* get the PHYSICAL APIC ID# */
- physical_cpu = CPU_TO_ID(logical_cpu);
-
- /* calculate the vector */
- vector = (boot_addr >> 12) & 0xff;
-
- /* used as a watchpoint to signal AP startup */
- cpus = mp_ncpus;
-
- /*
- * first we do an INIT/RESET IPI this INIT IPI might be run, reseting
- * and running the target CPU. OR this INIT IPI might be latched (P5
- * bug), CPU waiting for STARTUP IPI. OR this INIT IPI might be
- * ignored.
- */
-
- /* setup the address for the target AP */
- icr_hi = lapic.icr_hi & ~APIC_ID_MASK;
- icr_hi |= (physical_cpu << 24);
- lapic.icr_hi = icr_hi;
-
- /* do an INIT IPI: assert RESET */
- icr_lo = lapic.icr_lo & 0xfff00000;
- lapic.icr_lo = icr_lo | 0x0000c500;
-
- /* wait for pending status end */
- while (lapic.icr_lo & APIC_DELSTAT_MASK)
- /* spin */ ;
-
- /* do an INIT IPI: deassert RESET */
- lapic.icr_lo = icr_lo | 0x00008500;
-
- /* wait for pending status end */
- u_sleep(10000); /* wait ~10mS */
- while (lapic.icr_lo & APIC_DELSTAT_MASK)
- /* spin */ ;
-
- /*
- * next we do a STARTUP IPI: the previous INIT IPI might still be
- * latched, (P5 bug) this 1st STARTUP would then terminate
- * immediately, and the previously started INIT IPI would continue. OR
- * the previous INIT IPI has already run. and this STARTUP IPI will
- * run. OR the previous INIT IPI was ignored. and this STARTUP IPI
- * will run.
- */
-
- /* do a STARTUP IPI */
- lapic.icr_lo = icr_lo | 0x00000600 | vector;
- while (lapic.icr_lo & APIC_DELSTAT_MASK)
- /* spin */ ;
- u_sleep(200); /* wait ~200uS */
-
- /*
- * finally we do a 2nd STARTUP IPI: this 2nd STARTUP IPI should run IF
- * the previous STARTUP IPI was cancelled by a latched INIT IPI. OR
- * this STARTUP IPI will be ignored, as only ONE STARTUP IPI is
- * recognized after hardware RESET or INIT IPI.
- */
-
- lapic.icr_lo = icr_lo | 0x00000600 | vector;
- while (lapic.icr_lo & APIC_DELSTAT_MASK)
- /* spin */ ;
- u_sleep(200); /* wait ~200uS */
-
- /* wait for it to start */
- set_apic_timer(5000000);/* == 5 seconds */
- while (read_apic_timer())
- if (mp_ncpus > cpus)
- return 1; /* return SUCCESS */
-
- return 0; /* return FAILURE */
-}
-
-
-/*
- * Flush the TLB on all other CPU's
- *
- * XXX: Needs to handshake and wait for completion before proceding.
- */
-void
-smp_invltlb(void)
-{
-#if defined(APIC_IO)
- if (smp_started && invltlb_ok)
- all_but_self_ipi(XINVLTLB_OFFSET);
-#endif /* APIC_IO */
-}
-
-void
-invlpg(u_int addr)
-{
- __asm __volatile("invlpg (%0)"::"r"(addr):"memory");
-
- /* send a message to the other CPUs */
- smp_invltlb();
-}
-
-void
-invltlb(void)
-{
- u_long temp;
-
- /*
- * This should be implemented as load_cr3(rcr3()) when load_cr3() is
- * inlined.
- */
- __asm __volatile("movl %%cr3, %0; movl %0, %%cr3":"=r"(temp) :: "memory");
-
- /* send a message to the other CPUs */
- smp_invltlb();
-}
-
-
-/*
- * When called the executing CPU will send an IPI to all other CPUs
- * requesting that they halt execution.
- *
- * Usually (but not necessarily) called with 'other_cpus' as its arg.
- *
- * - Signals all CPUs in map to stop.
- * - Waits for each to stop.
- *
- * Returns:
- * -1: error
- * 0: NA
- * 1: ok
- *
- * XXX FIXME: this is not MP-safe, needs a lock to prevent multiple CPUs
- * from executing at same time.
- */
-int
-stop_cpus(u_int map)
-{
- if (!smp_started)
- return 0;
-
- /* send the Xcpustop IPI to all CPUs in map */
- selected_apic_ipi(map, XCPUSTOP_OFFSET, APIC_DELMODE_FIXED);
-
- while ((stopped_cpus & map) != map)
- /* spin */ ;
-
- return 1;
-}
-
-
-/*
- * Called by a CPU to restart stopped CPUs.
- *
- * Usually (but not necessarily) called with 'stopped_cpus' as its arg.
- *
- * - Signals all CPUs in map to restart.
- * - Waits for each to restart.
- *
- * Returns:
- * -1: error
- * 0: NA
- * 1: ok
- */
-int
-restart_cpus(u_int map)
-{
- if (!smp_started)
- return 0;
-
- started_cpus = map; /* signal other cpus to restart */
-
- while ((stopped_cpus & map) != 0) /* wait for each to clear its bit */
- /* spin */ ;
-
- return 1;
-}
-
-int smp_active = 0; /* are the APs allowed to run? */
-SYSCTL_INT(_machdep, OID_AUTO, smp_active, CTLFLAG_RW, &smp_active, 0, "");
-
-/* XXX maybe should be hw.ncpu */
-static int smp_cpus = 1; /* how many cpu's running */
-SYSCTL_INT(_machdep, OID_AUTO, smp_cpus, CTLFLAG_RD, &smp_cpus, 0, "");
-
-int invltlb_ok = 0; /* throttle smp_invltlb() till safe */
-SYSCTL_INT(_machdep, OID_AUTO, invltlb_ok, CTLFLAG_RW, &invltlb_ok, 0, "");
-
-/* Warning: Do not staticize. Used from swtch.s */
-int do_page_zero_idle = 1; /* bzero pages for fun and profit in idleloop */
-SYSCTL_INT(_machdep, OID_AUTO, do_page_zero_idle, CTLFLAG_RW,
- &do_page_zero_idle, 0, "");
-
-/* Is forwarding of a interrupt to the CPU holding the ISR lock enabled ? */
-int forward_irq_enabled = 1;
-SYSCTL_INT(_machdep, OID_AUTO, forward_irq_enabled, CTLFLAG_RW,
- &forward_irq_enabled, 0, "");
-
-/* Enable forwarding of a signal to a process running on a different CPU */
-static int forward_signal_enabled = 1;
-SYSCTL_INT(_machdep, OID_AUTO, forward_signal_enabled, CTLFLAG_RW,
- &forward_signal_enabled, 0, "");
-
-/* Enable forwarding of roundrobin to all other cpus */
-static int forward_roundrobin_enabled = 1;
-SYSCTL_INT(_machdep, OID_AUTO, forward_roundrobin_enabled, CTLFLAG_RW,
- &forward_roundrobin_enabled, 0, "");
-
-/*
- * This is called once the rest of the system is up and running and we're
- * ready to let the AP's out of the pen.
- */
-void ap_init(void);
-
-void
-ap_init()
-{
- u_int apic_id;
-
- /* BSP may have changed PTD while we're waiting for the lock */
- cpu_invltlb();
-
- smp_cpus++;
-
-#if defined(I586_CPU) && !defined(NO_F00F_HACK)
- lidt(&r_idt);
-#endif
-
- /* Build our map of 'other' CPUs. */
- other_cpus = all_cpus & ~(1 << cpuid);
-
- printf("SMP: AP CPU #%d Launched!\n", cpuid);
-
- /* XXX FIXME: i386 specific, and redundant: Setup the FPU. */
- load_cr0((rcr0() & ~CR0_EM) | CR0_MP | CR0_NE | CR0_TS);
-
- /* set up FPU state on the AP */
- npxinit(__INITIAL_NPXCW__);
-
- /* A quick check from sanity claus */
- apic_id = (apic_id_to_logical[(lapic.id & 0x0f000000) >> 24]);
- if (cpuid != apic_id) {
- printf("SMP: cpuid = %d\n", cpuid);
- printf("SMP: apic_id = %d\n", apic_id);
- printf("PTD[MPPTDI] = %p\n", (void *)PTD[MPPTDI]);
- panic("cpuid mismatch! boom!!");
- }
-
- /* Init local apic for irq's */
- apic_initialize();
-
- /* Set memory range attributes for this CPU to match the BSP */
- mem_range_AP_init();
-
- /*
- * Activate smp_invltlb, although strictly speaking, this isn't
- * quite correct yet. We should have a bitfield for cpus willing
- * to accept TLB flush IPI's or something and sync them.
- */
- if (smp_cpus == mp_ncpus) {
- invltlb_ok = 1;
- smp_started = 1; /* enable IPI's, tlb shootdown, freezes etc */
- smp_active = 1; /* historic */
- }
-}
-
-#ifdef BETTER_CLOCK
-
-#define CHECKSTATE_USER 0
-#define CHECKSTATE_SYS 1
-#define CHECKSTATE_INTR 2
-
-/* Do not staticize. Used from apic_vector.s */
-struct proc* checkstate_curproc[NCPU];
-int checkstate_cpustate[NCPU];
-u_long checkstate_pc[NCPU];
-
-extern long cp_time[CPUSTATES];
-
-#define PC_TO_INDEX(pc, prof) \
- ((int)(((u_quad_t)((pc) - (prof)->pr_off) * \
- (u_quad_t)((prof)->pr_scale)) >> 16) & ~1)
-
-static void
-addupc_intr_forwarded(struct proc *p, int id, int *astmap)
-{
- int i;
- struct uprof *prof;
- u_long pc;
-
- pc = checkstate_pc[id];
- prof = &p->p_stats->p_prof;
- if (pc >= prof->pr_off &&
- (i = PC_TO_INDEX(pc, prof)) < prof->pr_size) {
- if ((p->p_flag & P_OWEUPC) == 0) {
- prof->pr_addr = pc;
- prof->pr_ticks = 1;
- p->p_flag |= P_OWEUPC;
- }
- *astmap |= (1 << id);
- }
-}
-
-static void
-forwarded_statclock(int id, int pscnt, int *astmap)
-{
- struct pstats *pstats;
- long rss;
- struct rusage *ru;
- struct vmspace *vm;
- int cpustate;
- struct proc *p;
-#ifdef GPROF
- register struct gmonparam *g;
- int i;
-#endif
-
- p = checkstate_curproc[id];
- cpustate = checkstate_cpustate[id];
-
- switch (cpustate) {
- case CHECKSTATE_USER:
- if (p->p_flag & P_PROFIL)
- addupc_intr_forwarded(p, id, astmap);
- if (pscnt > 1)
- return;
- p->p_uticks++;
- if (p->p_nice > NZERO)
- cp_time[CP_NICE]++;
- else
- cp_time[CP_USER]++;
- break;
- case CHECKSTATE_SYS:
-#ifdef GPROF
- /*
- * Kernel statistics are just like addupc_intr, only easier.
- */
- g = &_gmonparam;
- if (g->state == GMON_PROF_ON) {
- i = checkstate_pc[id] - g->lowpc;
- if (i < g->textsize) {
- i /= HISTFRACTION * sizeof(*g->kcount);
- g->kcount[i]++;
- }
- }
-#endif
- if (pscnt > 1)
- return;
-
- if (!p)
- cp_time[CP_IDLE]++;
- else {
- p->p_sticks++;
- cp_time[CP_SYS]++;
- }
- break;
- case CHECKSTATE_INTR:
- default:
-#ifdef GPROF
- /*
- * Kernel statistics are just like addupc_intr, only easier.
- */
- g = &_gmonparam;
- if (g->state == GMON_PROF_ON) {
- i = checkstate_pc[id] - g->lowpc;
- if (i < g->textsize) {
- i /= HISTFRACTION * sizeof(*g->kcount);
- g->kcount[i]++;
- }
- }
-#endif
- if (pscnt > 1)
- return;
- if (p)
- p->p_iticks++;
- cp_time[CP_INTR]++;
- }
- if (p != NULL) {
- schedclock(p);
-
- /* Update resource usage integrals and maximums. */
- if ((pstats = p->p_stats) != NULL &&
- (ru = &pstats->p_ru) != NULL &&
- (vm = p->p_vmspace) != NULL) {
- ru->ru_ixrss += pgtok(vm->vm_tsize);
- ru->ru_idrss += pgtok(vm->vm_dsize);
- ru->ru_isrss += pgtok(vm->vm_ssize);
- rss = pgtok(vmspace_resident_count(vm));
- if (ru->ru_maxrss < rss)
- ru->ru_maxrss = rss;
- }
- }
-}
-
-void
-forward_statclock(int pscnt)
-{
- int map;
- int id;
- int i;
-
- /* Kludge. We don't yet have separate locks for the interrupts
- * and the kernel. This means that we cannot let the other processors
- * handle complex interrupts while inhibiting them from entering
- * the kernel in a non-interrupt context.
- *
- * What we can do, without changing the locking mechanisms yet,
- * is letting the other processors handle a very simple interrupt
- * (wich determines the processor states), and do the main
- * work ourself.
- */
-
- if (!smp_started || !invltlb_ok || cold || panicstr)
- return;
-
- /* Step 1: Probe state (user, cpu, interrupt, spinlock, idle ) */
-
- map = other_cpus & ~stopped_cpus ;
- checkstate_probed_cpus = 0;
- if (map != 0)
- selected_apic_ipi(map,
- XCPUCHECKSTATE_OFFSET, APIC_DELMODE_FIXED);
-
- i = 0;
- while (checkstate_probed_cpus != map) {
- /* spin */
- i++;
- if (i == 100000) {
-#ifdef BETTER_CLOCK_DIAGNOSTIC
- printf("forward_statclock: checkstate %x\n",
- checkstate_probed_cpus);
-#endif
- break;
- }
- }
-
- /*
- * Step 2: walk through other processors processes, update ticks and
- * profiling info.
- */
-
- map = 0;
- for (id = 0; id < mp_ncpus; id++) {
- if (id == cpuid)
- continue;
- if (((1 << id) & checkstate_probed_cpus) == 0)
- continue;
- forwarded_statclock(id, pscnt, &map);
- }
- if (map != 0) {
- checkstate_need_ast |= map;
- selected_apic_ipi(map, XCPUAST_OFFSET, APIC_DELMODE_FIXED);
- i = 0;
- while ((checkstate_need_ast & map) != 0) {
- /* spin */
- i++;
- if (i > 100000) {
-#ifdef BETTER_CLOCK_DIAGNOSTIC
- printf("forward_statclock: dropped ast 0x%x\n",
- checkstate_need_ast & map);
-#endif
- break;
- }
- }
- }
-}
-
-void
-forward_hardclock(int pscnt)
-{
- int map;
- int id;
- struct proc *p;
- struct pstats *pstats;
- int i;
-
- /* Kludge. We don't yet have separate locks for the interrupts
- * and the kernel. This means that we cannot let the other processors
- * handle complex interrupts while inhibiting them from entering
- * the kernel in a non-interrupt context.
- *
- * What we can do, without changing the locking mechanisms yet,
- * is letting the other processors handle a very simple interrupt
- * (wich determines the processor states), and do the main
- * work ourself.
- */
-
- if (!smp_started || !invltlb_ok || cold || panicstr)
- return;
-
- /* Step 1: Probe state (user, cpu, interrupt, spinlock, idle) */
-
- map = other_cpus & ~stopped_cpus ;
- checkstate_probed_cpus = 0;
- if (map != 0)
- selected_apic_ipi(map,
- XCPUCHECKSTATE_OFFSET, APIC_DELMODE_FIXED);
-
- i = 0;
- while (checkstate_probed_cpus != map) {
- /* spin */
- i++;
- if (i == 100000) {
-#ifdef BETTER_CLOCK_DIAGNOSTIC
- printf("forward_hardclock: checkstate %x\n",
- checkstate_probed_cpus);
-#endif
- break;
- }
- }
-
- /*
- * Step 2: walk through other processors processes, update virtual
- * timer and profiling timer. If stathz == 0, also update ticks and
- * profiling info.
- */
-
- map = 0;
- for (id = 0; id < mp_ncpus; id++) {
- if (id == cpuid)
- continue;
- if (((1 << id) & checkstate_probed_cpus) == 0)
- continue;
- p = checkstate_curproc[id];
- if (p) {
- pstats = p->p_stats;
- if (checkstate_cpustate[id] == CHECKSTATE_USER &&
- timevalisset(&pstats->p_timer[ITIMER_VIRTUAL].it_value) &&
- itimerdecr(&pstats->p_timer[ITIMER_VIRTUAL], tick) == 0) {
- psignal(p, SIGVTALRM);
- map |= (1 << id);
- }
- if (timevalisset(&pstats->p_timer[ITIMER_PROF].it_value) &&
- itimerdecr(&pstats->p_timer[ITIMER_PROF], tick) == 0) {
- psignal(p, SIGPROF);
- map |= (1 << id);
- }
- }
- if (stathz == 0) {
- forwarded_statclock( id, pscnt, &map);
- }
- }
- if (map != 0) {
- checkstate_need_ast |= map;
- selected_apic_ipi(map, XCPUAST_OFFSET, APIC_DELMODE_FIXED);
- i = 0;
- while ((checkstate_need_ast & map) != 0) {
- /* spin */
- i++;
- if (i > 100000) {
-#ifdef BETTER_CLOCK_DIAGNOSTIC
- printf("forward_hardclock: dropped ast 0x%x\n",
- checkstate_need_ast & map);
-#endif
- break;
- }
- }
- }
-}
-
-#endif /* BETTER_CLOCK */
-
-void
-forward_signal(struct proc *p)
-{
- int map;
- int id;
- int i;
-
- /* Kludge. We don't yet have separate locks for the interrupts
- * and the kernel. This means that we cannot let the other processors
- * handle complex interrupts while inhibiting them from entering
- * the kernel in a non-interrupt context.
- *
- * What we can do, without changing the locking mechanisms yet,
- * is letting the other processors handle a very simple interrupt
- * (wich determines the processor states), and do the main
- * work ourself.
- */
-
- if (!smp_started || !invltlb_ok || cold || panicstr)
- return;
- if (!forward_signal_enabled)
- return;
- while (1) {
- if (p->p_stat != SRUN)
- return;
- id = p->p_oncpu;
- if (id == 0xff)
- return;
- map = (1<<id);
- checkstate_need_ast |= map;
- selected_apic_ipi(map, XCPUAST_OFFSET, APIC_DELMODE_FIXED);
- i = 0;
- while ((checkstate_need_ast & map) != 0) {
- /* spin */
- i++;
- if (i > 100000) {
-#if 0
- printf("forward_signal: dropped ast 0x%x\n",
- checkstate_need_ast & map);
-#endif
- break;
- }
- }
- if (id == p->p_oncpu)
- return;
- }
-}
-
-void
-forward_roundrobin(void)
-{
- u_int map;
- int i;
-
- if (!smp_started || !invltlb_ok || cold || panicstr)
- return;
- if (!forward_roundrobin_enabled)
- return;
- resched_cpus |= other_cpus;
- map = other_cpus & ~stopped_cpus ;
-#if 1
- selected_apic_ipi(map, XCPUAST_OFFSET, APIC_DELMODE_FIXED);
-#else
- (void) all_but_self_ipi(XCPUAST_OFFSET);
-#endif
- i = 0;
- while ((checkstate_need_ast & map) != 0) {
- /* spin */
- i++;
- if (i > 100000) {
-#if 0
- printf("forward_roundrobin: dropped ast 0x%x\n",
- checkstate_need_ast & map);
-#endif
- break;
- }
- }
-}
-
-
-#ifdef APIC_INTR_REORDER
-/*
- * Maintain mapping from softintr vector to isr bit in local apic.
- */
-void
-set_lapic_isrloc(int intr, int vector)
-{
- if (intr < 0 || intr > 32)
- panic("set_apic_isrloc: bad intr argument: %d",intr);
- if (vector < ICU_OFFSET || vector > 255)
- panic("set_apic_isrloc: bad vector argument: %d",vector);
- apic_isrbit_location[intr].location = &lapic.isr0 + ((vector>>5)<<2);
- apic_isrbit_location[intr].bit = (1<<(vector & 31));
-}
-#endif
-
-/*
- * All-CPU rendezvous. CPUs are signalled, all execute the setup function
- * (if specified), rendezvous, execute the action function (if specified),
- * rendezvous again, execute the teardown function (if specified), and then
- * resume.
- *
- * Note that the supplied external functions _must_ be reentrant and aware
- * that they are running in parallel and in an unknown lock context.
- */
-static void (*smp_rv_setup_func)(void *arg);
-static void (*smp_rv_action_func)(void *arg);
-static void (*smp_rv_teardown_func)(void *arg);
-static void *smp_rv_func_arg;
-static volatile int smp_rv_waiters[2];
-
-void
-smp_rendezvous_action(void)
-{
- /* setup function */
- if (smp_rv_setup_func != NULL)
- smp_rv_setup_func(smp_rv_func_arg);
- /* spin on entry rendezvous */
- atomic_add_int(&smp_rv_waiters[0], 1);
- while (smp_rv_waiters[0] < mp_ncpus)
- ;
- /* action function */
- if (smp_rv_action_func != NULL)
- smp_rv_action_func(smp_rv_func_arg);
- /* spin on exit rendezvous */
- atomic_add_int(&smp_rv_waiters[1], 1);
- while (smp_rv_waiters[1] < mp_ncpus)
- ;
- /* teardown function */
- if (smp_rv_teardown_func != NULL)
- smp_rv_teardown_func(smp_rv_func_arg);
-}
-
-void
-smp_rendezvous(void (* setup_func)(void *),
- void (* action_func)(void *),
- void (* teardown_func)(void *),
- void *arg)
-{
- u_int efl;
-
- /* obtain rendezvous lock */
- s_lock(&smp_rv_lock); /* XXX sleep here? NOWAIT flag? */
-
- /* set static function pointers */
- smp_rv_setup_func = setup_func;
- smp_rv_action_func = action_func;
- smp_rv_teardown_func = teardown_func;
- smp_rv_func_arg = arg;
- smp_rv_waiters[0] = 0;
- smp_rv_waiters[1] = 0;
-
- /* disable interrupts on this CPU, save interrupt status */
- efl = read_eflags();
- write_eflags(efl & ~PSL_I);
-
- /* signal other processors, which will enter the IPI with interrupts off */
- all_but_self_ipi(XRENDEZVOUS_OFFSET);
-
- /* call executor function */
- smp_rendezvous_action();
-
- /* restore interrupt flag */
- write_eflags(efl);
-
- /* release lock */
- s_unlock(&smp_rv_lock);
-}
diff --git a/sys/i386/i386/tsc.c b/sys/i386/i386/tsc.c
deleted file mode 100644
index ea39018548b9..000000000000
--- a/sys/i386/i386/tsc.c
+++ /dev/null
@@ -1,1230 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz and Don Ahn.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)clock.c 7.2 (Berkeley) 5/12/91
- * $FreeBSD$
- */
-
-/*
- * Routines to handle clock hardware.
- */
-
-/*
- * inittodr, settodr and support routines written
- * by Christoph Robitschko <chmr@edvz.tu-graz.ac.at>
- *
- * reintroduced and updated by Chris Stenton <chris@gnome.co.uk> 8/10/94
- */
-
-#include "opt_clock.h"
-#include "apm.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/time.h>
-#include <sys/kernel.h>
-#ifndef SMP
-#include <sys/lock.h>
-#endif
-#include <sys/sysctl.h>
-#include <sys/cons.h>
-
-#include <machine/clock.h>
-#ifdef CLK_CALIBRATION_LOOP
-#endif
-#include <machine/cputypes.h>
-#include <machine/frame.h>
-#include <machine/ipl.h>
-#include <machine/limits.h>
-#include <machine/md_var.h>
-#include <machine/psl.h>
-#ifdef APIC_IO
-#include <machine/segments.h>
-#endif
-#if defined(SMP) || defined(APIC_IO)
-#include <machine/smp.h>
-#endif /* SMP || APIC_IO */
-#include <machine/specialreg.h>
-
-#include <i386/isa/icu.h>
-#include <i386/isa/isa.h>
-#include <isa/rtc.h>
-#include <i386/isa/timerreg.h>
-
-#include <i386/isa/intr_machdep.h>
-
-#include "mca.h"
-#if NMCA > 0
-#include <i386/isa/mca_machdep.h>
-#endif
-
-#ifdef SMP
-#define disable_intr() CLOCK_DISABLE_INTR()
-#define enable_intr() CLOCK_ENABLE_INTR()
-
-#ifdef APIC_IO
-#include <i386/isa/intr_machdep.h>
-/* The interrupt triggered by the 8254 (timer) chip */
-int apic_8254_intr;
-static u_long read_intr_count __P((int vec));
-static void setup_8254_mixed_mode __P((void));
-#endif
-#endif /* SMP */
-
-/*
- * 32-bit time_t's can't reach leap years before 1904 or after 2036, so we
- * can use a simple formula for leap years.
- */
-#define LEAPYEAR(y) ((u_int)(y) % 4 == 0)
-#define DAYSPERYEAR (31+28+31+30+31+30+31+31+30+31+30+31)
-
-#define TIMER_DIV(x) ((timer_freq + (x) / 2) / (x))
-
-/*
- * Time in timer cycles that it takes for microtime() to disable interrupts
- * and latch the count. microtime() currently uses "cli; outb ..." so it
- * normally takes less than 2 timer cycles. Add a few for cache misses.
- * Add a few more to allow for latency in bogus calls to microtime() with
- * interrupts already disabled.
- */
-#define TIMER0_LATCH_COUNT 20
-
-/*
- * Maximum frequency that we are willing to allow for timer0. Must be
- * low enough to guarantee that the timer interrupt handler returns
- * before the next timer interrupt.
- */
-#define TIMER0_MAX_FREQ 20000
-
-int adjkerntz; /* local offset from GMT in seconds */
-int clkintr_pending;
-int disable_rtc_set; /* disable resettodr() if != 0 */
-volatile u_int idelayed;
-int statclock_disable;
-u_int stat_imask = SWI_CLOCK_MASK;
-#ifndef TIMER_FREQ
-#define TIMER_FREQ 1193182
-#endif
-u_int timer_freq = TIMER_FREQ;
-int timer0_max_count;
-u_int tsc_freq;
-int tsc_is_broken;
-int wall_cmos_clock; /* wall CMOS clock assumed if != 0 */
-
-static int beeping = 0;
-static u_int clk_imask = HWI_MASK | SWI_MASK;
-static const u_char daysinmonth[] = {31,28,31,30,31,30,31,31,30,31,30,31};
-static u_int hardclock_max_count;
-static u_int32_t i8254_lastcount;
-static u_int32_t i8254_offset;
-static int i8254_ticked;
-/*
- * XXX new_function and timer_func should not handle clockframes, but
- * timer_func currently needs to hold hardclock to handle the
- * timer0_state == 0 case. We should use inthand_add()/inthand_remove()
- * to switch between clkintr() and a slightly different timerintr().
- */
-static void (*new_function) __P((struct clockframe *frame));
-static u_int new_rate;
-static u_char rtc_statusa = RTCSA_DIVIDER | RTCSA_NOPROF;
-static u_char rtc_statusb = RTCSB_24HR | RTCSB_PINTR;
-static u_int timer0_prescaler_count;
-
-/* Values for timerX_state: */
-#define RELEASED 0
-#define RELEASE_PENDING 1
-#define ACQUIRED 2
-#define ACQUIRE_PENDING 3
-
-static u_char timer0_state;
-static u_char timer2_state;
-static void (*timer_func) __P((struct clockframe *frame)) = hardclock;
-static u_int tsc_present;
-
-static unsigned i8254_get_timecount __P((struct timecounter *tc));
-static unsigned tsc_get_timecount __P((struct timecounter *tc));
-static void set_timer_freq(u_int freq, int intr_freq);
-
-static struct timecounter tsc_timecounter = {
- tsc_get_timecount, /* get_timecount */
- 0, /* no poll_pps */
- ~0u, /* counter_mask */
- 0, /* frequency */
- "TSC" /* name */
-};
-
-SYSCTL_OPAQUE(_debug, OID_AUTO, tsc_timecounter, CTLFLAG_RD,
- &tsc_timecounter, sizeof(tsc_timecounter), "S,timecounter", "");
-
-static struct timecounter i8254_timecounter = {
- i8254_get_timecount, /* get_timecount */
- 0, /* no poll_pps */
- ~0u, /* counter_mask */
- 0, /* frequency */
- "i8254" /* name */
-};
-
-SYSCTL_OPAQUE(_debug, OID_AUTO, i8254_timecounter, CTLFLAG_RD,
- &i8254_timecounter, sizeof(i8254_timecounter), "S,timecounter", "");
-
-static void
-clkintr(struct clockframe frame)
-{
- if (timecounter->tc_get_timecount == i8254_get_timecount) {
- disable_intr();
- if (i8254_ticked)
- i8254_ticked = 0;
- else {
- i8254_offset += timer0_max_count;
- i8254_lastcount = 0;
- }
- clkintr_pending = 0;
- enable_intr();
- }
- timer_func(&frame);
- switch (timer0_state) {
-
- case RELEASED:
- setdelayed();
- break;
-
- case ACQUIRED:
- if ((timer0_prescaler_count += timer0_max_count)
- >= hardclock_max_count) {
- timer0_prescaler_count -= hardclock_max_count;
- hardclock(&frame);
- setdelayed();
- }
- break;
-
- case ACQUIRE_PENDING:
- disable_intr();
- i8254_offset = i8254_get_timecount(NULL);
- i8254_lastcount = 0;
- timer0_max_count = TIMER_DIV(new_rate);
- outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
- outb(TIMER_CNTR0, timer0_max_count & 0xff);
- outb(TIMER_CNTR0, timer0_max_count >> 8);
- enable_intr();
- timer_func = new_function;
- timer0_state = ACQUIRED;
- setdelayed();
- break;
-
- case RELEASE_PENDING:
- if ((timer0_prescaler_count += timer0_max_count)
- >= hardclock_max_count) {
- disable_intr();
- i8254_offset = i8254_get_timecount(NULL);
- i8254_lastcount = 0;
- timer0_max_count = hardclock_max_count;
- outb(TIMER_MODE,
- TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
- outb(TIMER_CNTR0, timer0_max_count & 0xff);
- outb(TIMER_CNTR0, timer0_max_count >> 8);
- enable_intr();
- timer0_prescaler_count = 0;
- timer_func = hardclock;
- timer0_state = RELEASED;
- hardclock(&frame);
- setdelayed();
- }
- break;
- }
-#if NMCA > 0
- /* Reset clock interrupt by asserting bit 7 of port 0x61 */
- if (MCA_system)
- outb(0x61, inb(0x61) | 0x80);
-#endif
-}
-
-/*
- * The acquire and release functions must be called at ipl >= splclock().
- */
-int
-acquire_timer0(int rate, void (*function) __P((struct clockframe *frame)))
-{
- static int old_rate;
-
- if (rate <= 0 || rate > TIMER0_MAX_FREQ)
- return (-1);
- switch (timer0_state) {
-
- case RELEASED:
- timer0_state = ACQUIRE_PENDING;
- break;
-
- case RELEASE_PENDING:
- if (rate != old_rate)
- return (-1);
- /*
- * The timer has been released recently, but is being
- * re-acquired before the release completed. In this
- * case, we simply reclaim it as if it had not been
- * released at all.
- */
- timer0_state = ACQUIRED;
- break;
-
- default:
- return (-1); /* busy */
- }
- new_function = function;
- old_rate = new_rate = rate;
- return (0);
-}
-
-int
-acquire_timer2(int mode)
-{
-
- if (timer2_state != RELEASED)
- return (-1);
- timer2_state = ACQUIRED;
-
- /*
- * This access to the timer registers is as atomic as possible
- * because it is a single instruction. We could do better if we
- * knew the rate. Use of splclock() limits glitches to 10-100us,
- * and this is probably good enough for timer2, so we aren't as
- * careful with it as with timer0.
- */
- outb(TIMER_MODE, TIMER_SEL2 | (mode & 0x3f));
-
- return (0);
-}
-
-int
-release_timer0()
-{
- switch (timer0_state) {
-
- case ACQUIRED:
- timer0_state = RELEASE_PENDING;
- break;
-
- case ACQUIRE_PENDING:
- /* Nothing happened yet, release quickly. */
- timer0_state = RELEASED;
- break;
-
- default:
- return (-1);
- }
- return (0);
-}
-
-int
-release_timer2()
-{
-
- if (timer2_state != ACQUIRED)
- return (-1);
- timer2_state = RELEASED;
- outb(TIMER_MODE, TIMER_SEL2 | TIMER_SQWAVE | TIMER_16BIT);
- return (0);
-}
-
-/*
- * This routine receives statistical clock interrupts from the RTC.
- * As explained above, these occur at 128 interrupts per second.
- * When profiling, we receive interrupts at a rate of 1024 Hz.
- *
- * This does not actually add as much overhead as it sounds, because
- * when the statistical clock is active, the hardclock driver no longer
- * needs to keep (inaccurate) statistics on its own. This decouples
- * statistics gathering from scheduling interrupts.
- *
- * The RTC chip requires that we read status register C (RTC_INTR)
- * to acknowledge an interrupt, before it will generate the next one.
- * Under high interrupt load, rtcintr() can be indefinitely delayed and
- * the clock can tick immediately after the read from RTC_INTR. In this
- * case, the mc146818A interrupt signal will not drop for long enough
- * to register with the 8259 PIC. If an interrupt is missed, the stat
- * clock will halt, considerably degrading system performance. This is
- * why we use 'while' rather than a more straightforward 'if' below.
- * Stat clock ticks can still be lost, causing minor loss of accuracy
- * in the statistics, but the stat clock will no longer stop.
- */
-static void
-rtcintr(struct clockframe frame)
-{
- while (rtcin(RTC_INTR) & RTCIR_PERIOD)
- statclock(&frame);
-}
-
-#include "opt_ddb.h"
-#ifdef DDB
-#include <ddb/ddb.h>
-
-DB_SHOW_COMMAND(rtc, rtc)
-{
- printf("%02x/%02x/%02x %02x:%02x:%02x, A = %02x, B = %02x, C = %02x\n",
- rtcin(RTC_YEAR), rtcin(RTC_MONTH), rtcin(RTC_DAY),
- rtcin(RTC_HRS), rtcin(RTC_MIN), rtcin(RTC_SEC),
- rtcin(RTC_STATUSA), rtcin(RTC_STATUSB), rtcin(RTC_INTR));
-}
-#endif /* DDB */
-
-static int
-getit(void)
-{
- u_long ef;
- int high, low;
-
- ef = read_eflags();
- disable_intr();
-
- /* Select timer0 and latch counter value. */
- outb(TIMER_MODE, TIMER_SEL0 | TIMER_LATCH);
-
- low = inb(TIMER_CNTR0);
- high = inb(TIMER_CNTR0);
-
- CLOCK_UNLOCK();
- write_eflags(ef);
- return ((high << 8) | low);
-}
-
-/*
- * Wait "n" microseconds.
- * Relies on timer 1 counting down from (timer_freq / hz)
- * Note: timer had better have been programmed before this is first used!
- */
-void
-DELAY(int n)
-{
- int delta, prev_tick, tick, ticks_left;
-
-#ifdef DELAYDEBUG
- int getit_calls = 1;
- int n1;
- static int state = 0;
-
- if (state == 0) {
- state = 1;
- for (n1 = 1; n1 <= 10000000; n1 *= 10)
- DELAY(n1);
- state = 2;
- }
- if (state == 1)
- printf("DELAY(%d)...", n);
-#endif
- /*
- * Guard against the timer being uninitialized if we are called
- * early for console i/o.
- */
- if (timer0_max_count == 0)
- set_timer_freq(timer_freq, hz);
-
- /*
- * Read the counter first, so that the rest of the setup overhead is
- * counted. Guess the initial overhead is 20 usec (on most systems it
- * takes about 1.5 usec for each of the i/o's in getit(). The loop
- * takes about 6 usec on a 486/33 and 13 usec on a 386/20. The
- * multiplications and divisions to scale the count take a while).
- */
- prev_tick = getit();
- n -= 0; /* XXX actually guess no initial overhead */
- /*
- * Calculate (n * (timer_freq / 1e6)) without using floating point
- * and without any avoidable overflows.
- */
- if (n <= 0)
- ticks_left = 0;
- else if (n < 256)
- /*
- * Use fixed point to avoid a slow division by 1000000.
- * 39099 = 1193182 * 2^15 / 10^6 rounded to nearest.
- * 2^15 is the first power of 2 that gives exact results
- * for n between 0 and 256.
- */
- ticks_left = ((u_int)n * 39099 + (1 << 15) - 1) >> 15;
- else
- /*
- * Don't bother using fixed point, although gcc-2.7.2
- * generates particularly poor code for the long long
- * division, since even the slow way will complete long
- * before the delay is up (unless we're interrupted).
- */
- ticks_left = ((u_int)n * (long long)timer_freq + 999999)
- / 1000000;
-
- while (ticks_left > 0) {
- tick = getit();
-#ifdef DELAYDEBUG
- ++getit_calls;
-#endif
- delta = prev_tick - tick;
- prev_tick = tick;
- if (delta < 0) {
- delta += timer0_max_count;
- /*
- * Guard against timer0_max_count being wrong.
- * This shouldn't happen in normal operation,
- * but it may happen if set_timer_freq() is
- * traced.
- */
- if (delta < 0)
- delta = 0;
- }
- ticks_left -= delta;
- }
-#ifdef DELAYDEBUG
- if (state == 1)
- printf(" %d calls to getit() at %d usec each\n",
- getit_calls, (n + 5) / getit_calls);
-#endif
-}
-
-static void
-sysbeepstop(void *chan)
-{
- outb(IO_PPI, inb(IO_PPI)&0xFC); /* disable counter2 output to speaker */
- release_timer2();
- beeping = 0;
-}
-
-int
-sysbeep(int pitch, int period)
-{
- int x = splclock();
-
- if (acquire_timer2(TIMER_SQWAVE|TIMER_16BIT))
- if (!beeping) {
- /* Something else owns it. */
- splx(x);
- return (-1); /* XXX Should be EBUSY, but nobody cares anyway. */
- }
- disable_intr();
- outb(TIMER_CNTR2, pitch);
- outb(TIMER_CNTR2, (pitch>>8));
- enable_intr();
- if (!beeping) {
- /* enable counter2 output to speaker */
- outb(IO_PPI, inb(IO_PPI) | 3);
- beeping = period;
- timeout(sysbeepstop, (void *)NULL, period);
- }
- splx(x);
- return (0);
-}
-
-/*
- * RTC support routines
- */
-
-int
-rtcin(reg)
- int reg;
-{
- int s;
- u_char val;
-
- s = splhigh();
- outb(IO_RTC, reg);
- inb(0x84);
- val = inb(IO_RTC + 1);
- inb(0x84);
- splx(s);
- return (val);
-}
-
-static __inline void
-writertc(u_char reg, u_char val)
-{
- int s;
-
- s = splhigh();
- inb(0x84);
- outb(IO_RTC, reg);
- inb(0x84);
- outb(IO_RTC + 1, val);
- inb(0x84); /* XXX work around wrong order in rtcin() */
- splx(s);
-}
-
-static __inline int
-readrtc(int port)
-{
- return(bcd2bin(rtcin(port)));
-}
-
-static u_int
-calibrate_clocks(void)
-{
- u_int64_t old_tsc;
- u_int count, prev_count, tot_count;
- int sec, start_sec, timeout;
-
- if (bootverbose)
- printf("Calibrating clock(s) ... ");
- if (!(rtcin(RTC_STATUSD) & RTCSD_PWR))
- goto fail;
- timeout = 100000000;
-
- /* Read the mc146818A seconds counter. */
- for (;;) {
- if (!(rtcin(RTC_STATUSA) & RTCSA_TUP)) {
- sec = rtcin(RTC_SEC);
- break;
- }
- if (--timeout == 0)
- goto fail;
- }
-
- /* Wait for the mC146818A seconds counter to change. */
- start_sec = sec;
- for (;;) {
- if (!(rtcin(RTC_STATUSA) & RTCSA_TUP)) {
- sec = rtcin(RTC_SEC);
- if (sec != start_sec)
- break;
- }
- if (--timeout == 0)
- goto fail;
- }
-
- /* Start keeping track of the i8254 counter. */
- prev_count = getit();
- if (prev_count == 0 || prev_count > timer0_max_count)
- goto fail;
- tot_count = 0;
-
- if (tsc_present)
- old_tsc = rdtsc();
- else
- old_tsc = 0; /* shut up gcc */
-
- /*
- * Wait for the mc146818A seconds counter to change. Read the i8254
- * counter for each iteration since this is convenient and only
- * costs a few usec of inaccuracy. The timing of the final reads
- * of the counters almost matches the timing of the initial reads,
- * so the main cause of inaccuracy is the varying latency from
- * inside getit() or rtcin(RTC_STATUSA) to the beginning of the
- * rtcin(RTC_SEC) that returns a changed seconds count. The
- * maximum inaccuracy from this cause is < 10 usec on 486's.
- */
- start_sec = sec;
- for (;;) {
- if (!(rtcin(RTC_STATUSA) & RTCSA_TUP))
- sec = rtcin(RTC_SEC);
- count = getit();
- if (count == 0 || count > timer0_max_count)
- goto fail;
- if (count > prev_count)
- tot_count += prev_count - (count - timer0_max_count);
- else
- tot_count += prev_count - count;
- prev_count = count;
- if (sec != start_sec)
- break;
- if (--timeout == 0)
- goto fail;
- }
-
- /*
- * Read the cpu cycle counter. The timing considerations are
- * similar to those for the i8254 clock.
- */
- if (tsc_present)
- tsc_freq = rdtsc() - old_tsc;
-
- if (bootverbose) {
- if (tsc_present)
- printf("TSC clock: %u Hz, ", tsc_freq);
- printf("i8254 clock: %u Hz\n", tot_count);
- }
- return (tot_count);
-
-fail:
- if (bootverbose)
- printf("failed, using default i8254 clock of %u Hz\n",
- timer_freq);
- return (timer_freq);
-}
-
-static void
-set_timer_freq(u_int freq, int intr_freq)
-{
- u_long ef;
- int new_timer0_max_count;
-
- ef = read_eflags();
- disable_intr();
- timer_freq = freq;
- new_timer0_max_count = hardclock_max_count = TIMER_DIV(intr_freq);
- if (new_timer0_max_count != timer0_max_count) {
- timer0_max_count = new_timer0_max_count;
- outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
- outb(TIMER_CNTR0, timer0_max_count & 0xff);
- outb(TIMER_CNTR0, timer0_max_count >> 8);
- }
- CLOCK_UNLOCK();
- write_eflags(ef);
-}
-
-/*
- * i8254_restore is called from apm_default_resume() to reload
- * the countdown register.
- * this should not be necessary but there are broken laptops that
- * do not restore the countdown register on resume.
- * when it happnes, it messes up the hardclock interval and system clock,
- * which leads to the infamous "calcru: negative time" problem.
- */
-void
-i8254_restore(void)
-{
- u_long ef;
-
- ef = read_eflags();
- disable_intr();
- outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
- outb(TIMER_CNTR0, timer0_max_count & 0xff);
- outb(TIMER_CNTR0, timer0_max_count >> 8);
- CLOCK_UNLOCK();
- write_eflags(ef);
-}
-
-/*
- * Initialize 8254 timer 0 early so that it can be used in DELAY().
- * XXX initialization of other timers is unintentionally left blank.
- */
-void
-startrtclock()
-{
- u_int delta, freq;
-
- if (cpu_feature & CPUID_TSC)
- tsc_present = 1;
- else
- tsc_present = 0;
-
- writertc(RTC_STATUSA, rtc_statusa);
- writertc(RTC_STATUSB, RTCSB_24HR);
-
- set_timer_freq(timer_freq, hz);
- freq = calibrate_clocks();
-#ifdef CLK_CALIBRATION_LOOP
- if (bootverbose) {
- printf(
- "Press a key on the console to abort clock calibration\n");
- while (cncheckc() == -1)
- calibrate_clocks();
- }
-#endif
-
- /*
- * Use the calibrated i8254 frequency if it seems reasonable.
- * Otherwise use the default, and don't use the calibrated i586
- * frequency.
- */
- delta = freq > timer_freq ? freq - timer_freq : timer_freq - freq;
- if (delta < timer_freq / 100) {
-#ifndef CLK_USE_I8254_CALIBRATION
- if (bootverbose)
- printf(
-"CLK_USE_I8254_CALIBRATION not specified - using default frequency\n");
- freq = timer_freq;
-#endif
- timer_freq = freq;
- } else {
- if (bootverbose)
- printf(
- "%d Hz differs from default of %d Hz by more than 1%%\n",
- freq, timer_freq);
- tsc_freq = 0;
- }
-
- set_timer_freq(timer_freq, hz);
- i8254_timecounter.tc_frequency = timer_freq;
- init_timecounter(&i8254_timecounter);
-
-#ifndef CLK_USE_TSC_CALIBRATION
- if (tsc_freq != 0) {
- if (bootverbose)
- printf(
-"CLK_USE_TSC_CALIBRATION not specified - using old calibration method\n");
- tsc_freq = 0;
- }
-#endif
- if (tsc_present && tsc_freq == 0) {
- /*
- * Calibration of the i586 clock relative to the mc146818A
- * clock failed. Do a less accurate calibration relative
- * to the i8254 clock.
- */
- u_int64_t old_tsc = rdtsc();
-
- DELAY(1000000);
- tsc_freq = rdtsc() - old_tsc;
-#ifdef CLK_USE_TSC_CALIBRATION
- if (bootverbose)
- printf("TSC clock: %u Hz (Method B)\n", tsc_freq);
-#endif
- }
-
-#if !defined(SMP)
- /*
- * We can not use the TSC in SMP mode, until we figure out a
- * cheap (impossible), reliable and precise (yeah right!) way
- * to synchronize the TSCs of all the CPUs.
- * Curse Intel for leaving the counter out of the I/O APIC.
- */
-
-#if NAPM > 0
- /*
- * We can not use the TSC if we support APM. Precise timekeeping
- * on an APM'ed machine is at best a fools pursuit, since
- * any and all of the time spent in various SMM code can't
- * be reliably accounted for. Reading the RTC is your only
- * source of reliable time info. The i8254 looses too of course
- * but we need to have some kind of time...
- * We don't know at this point whether APM is going to be used
- * or not, nor when it might be activated. Play it safe.
- */
- return;
-#endif /* NAPM > 0 */
-
- if (tsc_present && tsc_freq != 0 && !tsc_is_broken) {
- tsc_timecounter.tc_frequency = tsc_freq;
- init_timecounter(&tsc_timecounter);
- }
-
-#endif /* !defined(SMP) */
-}
-
-/*
- * Initialize the time of day register, based on the time base which is, e.g.
- * from a filesystem.
- */
-void
-inittodr(time_t base)
-{
- unsigned long sec, days;
- int yd;
- int year, month;
- int y, m, s;
- struct timespec ts;
-
- if (base) {
- s = splclock();
- ts.tv_sec = base;
- ts.tv_nsec = 0;
- set_timecounter(&ts);
- splx(s);
- }
-
- /* Look if we have a RTC present and the time is valid */
- if (!(rtcin(RTC_STATUSD) & RTCSD_PWR))
- goto wrong_time;
-
- /* wait for time update to complete */
- /* If RTCSA_TUP is zero, we have at least 244us before next update */
- s = splhigh();
- while (rtcin(RTC_STATUSA) & RTCSA_TUP) {
- splx(s);
- s = splhigh();
- }
-
- days = 0;
-#ifdef USE_RTC_CENTURY
- year = readrtc(RTC_YEAR) + readrtc(RTC_CENTURY) * 100;
-#else
- year = readrtc(RTC_YEAR) + 1900;
- if (year < 1970)
- year += 100;
-#endif
- if (year < 1970) {
- splx(s);
- goto wrong_time;
- }
- month = readrtc(RTC_MONTH);
- for (m = 1; m < month; m++)
- days += daysinmonth[m-1];
- if ((month > 2) && LEAPYEAR(year))
- days ++;
- days += readrtc(RTC_DAY) - 1;
- yd = days;
- for (y = 1970; y < year; y++)
- days += DAYSPERYEAR + LEAPYEAR(y);
- sec = ((( days * 24 +
- readrtc(RTC_HRS)) * 60 +
- readrtc(RTC_MIN)) * 60 +
- readrtc(RTC_SEC));
- /* sec now contains the number of seconds, since Jan 1 1970,
- in the local time zone */
-
- sec += tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
-
- y = time_second - sec;
- if (y <= -2 || y >= 2) {
- /* badly off, adjust it */
- ts.tv_sec = sec;
- ts.tv_nsec = 0;
- set_timecounter(&ts);
- }
- splx(s);
- return;
-
-wrong_time:
- printf("Invalid time in real time clock.\n");
- printf("Check and reset the date immediately!\n");
-}
-
-/*
- * Write system time back to RTC
- */
-void
-resettodr()
-{
- unsigned long tm;
- int y, m, s;
-
- if (disable_rtc_set)
- return;
-
- s = splclock();
- tm = time_second;
- splx(s);
-
- /* Disable RTC updates and interrupts. */
- writertc(RTC_STATUSB, RTCSB_HALT | RTCSB_24HR);
-
- /* Calculate local time to put in RTC */
-
- tm -= tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
-
- writertc(RTC_SEC, bin2bcd(tm%60)); tm /= 60; /* Write back Seconds */
- writertc(RTC_MIN, bin2bcd(tm%60)); tm /= 60; /* Write back Minutes */
- writertc(RTC_HRS, bin2bcd(tm%24)); tm /= 24; /* Write back Hours */
-
- /* We have now the days since 01-01-1970 in tm */
- writertc(RTC_WDAY, (tm+4)%7); /* Write back Weekday */
- for (y = 1970, m = DAYSPERYEAR + LEAPYEAR(y);
- tm >= m;
- y++, m = DAYSPERYEAR + LEAPYEAR(y))
- tm -= m;
-
- /* Now we have the years in y and the day-of-the-year in tm */
- writertc(RTC_YEAR, bin2bcd(y%100)); /* Write back Year */
-#ifdef USE_RTC_CENTURY
- writertc(RTC_CENTURY, bin2bcd(y/100)); /* ... and Century */
-#endif
- for (m = 0; ; m++) {
- int ml;
-
- ml = daysinmonth[m];
- if (m == 1 && LEAPYEAR(y))
- ml++;
- if (tm < ml)
- break;
- tm -= ml;
- }
-
- writertc(RTC_MONTH, bin2bcd(m + 1)); /* Write back Month */
- writertc(RTC_DAY, bin2bcd(tm + 1)); /* Write back Month Day */
-
- /* Reenable RTC updates and interrupts. */
- writertc(RTC_STATUSB, rtc_statusb);
-}
-
-
-/*
- * Start both clocks running.
- */
-void
-cpu_initclocks()
-{
- int diag;
-#ifdef APIC_IO
- int apic_8254_trial;
- struct intrec *clkdesc;
-#endif /* APIC_IO */
-
- if (statclock_disable) {
- /*
- * The stat interrupt mask is different without the
- * statistics clock. Also, don't set the interrupt
- * flag which would normally cause the RTC to generate
- * interrupts.
- */
- stat_imask = HWI_MASK | SWI_MASK;
- rtc_statusb = RTCSB_24HR;
- } else {
- /* Setting stathz to nonzero early helps avoid races. */
- stathz = RTC_NOPROFRATE;
- profhz = RTC_PROFRATE;
- }
-
- /* Finish initializing 8253 timer 0. */
-#ifdef APIC_IO
-
- apic_8254_intr = isa_apic_irq(0);
- apic_8254_trial = 0;
- if (apic_8254_intr >= 0 ) {
- if (apic_int_type(0, 0) == 3)
- apic_8254_trial = 1;
- } else {
- /* look for ExtInt on pin 0 */
- if (apic_int_type(0, 0) == 3) {
- apic_8254_intr = apic_irq(0, 0);
- setup_8254_mixed_mode();
- } else
- panic("APIC_IO: Cannot route 8254 interrupt to CPU");
- }
-
- clkdesc = inthand_add("clk", apic_8254_intr, (inthand2_t *)clkintr,
- NULL, &clk_imask, INTR_EXCL);
- INTREN(1 << apic_8254_intr);
-
-#else /* APIC_IO */
-
- inthand_add("clk", 0, (inthand2_t *)clkintr, NULL, &clk_imask,
- INTR_EXCL);
- INTREN(IRQ0);
-
-#endif /* APIC_IO */
-
- /* Initialize RTC. */
- writertc(RTC_STATUSA, rtc_statusa);
- writertc(RTC_STATUSB, RTCSB_24HR);
-
- /* Don't bother enabling the statistics clock. */
- if (statclock_disable)
- return;
- diag = rtcin(RTC_DIAG);
- if (diag != 0)
- printf("RTC BIOS diagnostic error %b\n", diag, RTCDG_BITS);
-
-#ifdef APIC_IO
- if (isa_apic_irq(8) != 8)
- panic("APIC RTC != 8");
-#endif /* APIC_IO */
-
- inthand_add("rtc", 8, (inthand2_t *)rtcintr, NULL, &stat_imask,
- INTR_EXCL);
-
-#ifdef APIC_IO
- INTREN(APIC_IRQ8);
-#else
- INTREN(IRQ8);
-#endif /* APIC_IO */
-
- writertc(RTC_STATUSB, rtc_statusb);
-
-#ifdef APIC_IO
- if (apic_8254_trial) {
-
- printf("APIC_IO: Testing 8254 interrupt delivery\n");
- while (read_intr_count(8) < 6)
- ; /* nothing */
- if (read_intr_count(apic_8254_intr) < 3) {
- /*
- * The MP table is broken.
- * The 8254 was not connected to the specified pin
- * on the IO APIC.
- * Workaround: Limited variant of mixed mode.
- */
- INTRDIS(1 << apic_8254_intr);
- inthand_remove(clkdesc);
- printf("APIC_IO: Broken MP table detected: "
- "8254 is not connected to "
- "IOAPIC #%d intpin %d\n",
- int_to_apicintpin[apic_8254_intr].ioapic,
- int_to_apicintpin[apic_8254_intr].int_pin);
- /*
- * Revoke current ISA IRQ 0 assignment and
- * configure a fallback interrupt routing from
- * the 8254 Timer via the 8259 PIC to the
- * an ExtInt interrupt line on IOAPIC #0 intpin 0.
- * We reuse the low level interrupt handler number.
- */
- if (apic_irq(0, 0) < 0) {
- revoke_apic_irq(apic_8254_intr);
- assign_apic_irq(0, 0, apic_8254_intr);
- }
- apic_8254_intr = apic_irq(0, 0);
- setup_8254_mixed_mode();
- inthand_add("clk", apic_8254_intr,
- (inthand2_t *)clkintr,
- NULL, &clk_imask, INTR_EXCL);
- INTREN(1 << apic_8254_intr);
- }
-
- }
- if (apic_int_type(0, 0) != 3 ||
- int_to_apicintpin[apic_8254_intr].ioapic != 0 ||
- int_to_apicintpin[apic_8254_intr].int_pin != 0)
- printf("APIC_IO: routing 8254 via IOAPIC #%d intpin %d\n",
- int_to_apicintpin[apic_8254_intr].ioapic,
- int_to_apicintpin[apic_8254_intr].int_pin);
- else
- printf("APIC_IO: "
- "routing 8254 via 8259 and IOAPIC #0 intpin 0\n");
-#endif
-
-}
-
-#ifdef APIC_IO
-static u_long
-read_intr_count(int vec)
-{
- u_long *up;
- up = intr_countp[vec];
- if (up)
- return *up;
- return 0UL;
-}
-
-static void
-setup_8254_mixed_mode()
-{
- /*
- * Allow 8254 timer to INTerrupt 8259:
- * re-initialize master 8259:
- * reset; prog 4 bytes, single ICU, edge triggered
- */
- outb(IO_ICU1, 0x13);
- outb(IO_ICU1 + 1, NRSVIDT); /* start vector (unused) */
- outb(IO_ICU1 + 1, 0x00); /* ignore slave */
- outb(IO_ICU1 + 1, 0x03); /* auto EOI, 8086 */
- outb(IO_ICU1 + 1, 0xfe); /* unmask INT0 */
-
- /* program IO APIC for type 3 INT on INT0 */
- if (ext_int_setup(0, 0) < 0)
- panic("8254 redirect via APIC pin0 impossible!");
-}
-#endif
-
-void
-setstatclockrate(int newhz)
-{
- if (newhz == RTC_PROFRATE)
- rtc_statusa = RTCSA_DIVIDER | RTCSA_PROF;
- else
- rtc_statusa = RTCSA_DIVIDER | RTCSA_NOPROF;
- writertc(RTC_STATUSA, rtc_statusa);
-}
-
-static int
-sysctl_machdep_i8254_freq SYSCTL_HANDLER_ARGS
-{
- int error;
- u_int freq;
-
- /*
- * Use `i8254' instead of `timer' in external names because `timer'
- * is is too generic. Should use it everywhere.
- */
- freq = timer_freq;
- error = sysctl_handle_int(oidp, &freq, sizeof(freq), req);
- if (error == 0 && req->newptr != NULL) {
- if (timer0_state != RELEASED)
- return (EBUSY); /* too much trouble to handle */
- set_timer_freq(freq, hz);
- i8254_timecounter.tc_frequency = freq;
- update_timecounter(&i8254_timecounter);
- }
- return (error);
-}
-
-SYSCTL_PROC(_machdep, OID_AUTO, i8254_freq, CTLTYPE_INT | CTLFLAG_RW,
- 0, sizeof(u_int), sysctl_machdep_i8254_freq, "I", "");
-
-static int
-sysctl_machdep_tsc_freq SYSCTL_HANDLER_ARGS
-{
- int error;
- u_int freq;
-
- if (tsc_timecounter.tc_frequency == 0)
- return (EOPNOTSUPP);
- freq = tsc_freq;
- error = sysctl_handle_int(oidp, &freq, sizeof(freq), req);
- if (error == 0 && req->newptr != NULL) {
- tsc_freq = freq;
- tsc_timecounter.tc_frequency = tsc_freq;
- update_timecounter(&tsc_timecounter);
- }
- return (error);
-}
-
-SYSCTL_PROC(_machdep, OID_AUTO, tsc_freq, CTLTYPE_INT | CTLFLAG_RW,
- 0, sizeof(u_int), sysctl_machdep_tsc_freq, "I", "");
-
-static unsigned
-i8254_get_timecount(struct timecounter *tc)
-{
- u_int count;
- u_long ef;
- u_int high, low;
-
- ef = read_eflags();
- disable_intr();
-
- /* Select timer0 and latch counter value. */
- outb(TIMER_MODE, TIMER_SEL0 | TIMER_LATCH);
-
- low = inb(TIMER_CNTR0);
- high = inb(TIMER_CNTR0);
- count = timer0_max_count - ((high << 8) | low);
- if (count < i8254_lastcount ||
- (!i8254_ticked && (clkintr_pending ||
- ((count < 20 || (!(ef & PSL_I) && count < timer0_max_count / 2u)) &&
-#ifdef APIC_IO
-#define lapic_irr1 ((volatile u_int *)&lapic)[0x210 / 4] /* XXX XXX */
- /* XXX this assumes that apic_8254_intr is < 24. */
- (lapic_irr1 & (1 << apic_8254_intr))))
-#else
- (inb(IO_ICU1) & 1)))
-#endif
- )) {
- i8254_ticked = 1;
- i8254_offset += timer0_max_count;
- }
- i8254_lastcount = count;
- count += i8254_offset;
- CLOCK_UNLOCK();
- write_eflags(ef);
- return (count);
-}
-
-static unsigned
-tsc_get_timecount(struct timecounter *tc)
-{
- return (rdtsc());
-}
diff --git a/sys/i386/include/_limits.h b/sys/i386/include/_limits.h
deleted file mode 100644
index 0d258ff9d94c..000000000000
--- a/sys/i386/include/_limits.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * 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. 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, Berkeley and its contributors.
- * 4. 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
- * $FreeBSD$
- */
-
-#ifndef _MACHINE_LIMITS_H_
-#define _MACHINE_LIMITS_H_
-
-#define CHAR_BIT 8 /* number of bits in a char */
-#define MB_LEN_MAX 6 /* Allow 31 bit UTF2 */
-
-/*
- * According to ANSI (section 2.2.4.2), the values below must be usable by
- * #if preprocessing directives. Additionally, the expression must have the
- * same type as would an expression that is an object of the corresponding
- * type converted according to the integral promotions. The subtraction for
- * INT_MIN and LONG_MIN is so the value is not unsigned; 2147483648 is an
- * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2).
- * These numbers work for pcc as well. The UINT_MAX and ULONG_MAX values
- * are written as hex so that GCC will be quiet about large integer constants.
- */
-#define SCHAR_MAX 127 /* min value for a signed char */
-#define SCHAR_MIN (-128) /* max value for a signed char */
-
-#define UCHAR_MAX 255 /* max value for an unsigned char */
-
-#ifdef __CHAR_UNSIGNED__
-#define CHAR_MAX UCHAR_MAX /* max value for a char */
-#define CHAR_MIN 0 /* min value for a char */
-#else
-#define CHAR_MAX SCHAR_MAX /* max value for a char */
-#define CHAR_MIN SCHAR_MIN /* min value for a char */
-#endif
-
-#define USHRT_MAX 65535 /* max value for an unsigned short */
-#define SHRT_MAX 32767 /* max value for a short */
-#define SHRT_MIN (-32768) /* min value for a short */
-
-#define UINT_MAX 0xffffffff /* max value for an unsigned int */
-#define INT_MAX 2147483647 /* max value for an int */
-#define INT_MIN (-2147483647-1) /* min value for an int */
-
-#define ULONG_MAX 0xffffffff /* max value for an unsigned long */
-#define LONG_MAX 2147483647 /* max value for a long */
-#define LONG_MIN (-2147483647-1) /* min value for a long */
-
-#if !defined(_ANSI_SOURCE)
-#define SSIZE_MAX INT_MAX /* max value for a ssize_t */
-
-#if !defined(_POSIX_SOURCE)
-#define SIZE_T_MAX UINT_MAX /* max value for a size_t */
-
-/* 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 /* !_POSIX_SOURCE */
-#endif /* !_ANSI_SOURCE */
-
-#endif /* !_MACHINE_LIMITS_H_ */
diff --git a/sys/i386/include/apicreg.h b/sys/i386/include/apicreg.h
deleted file mode 100644
index be9de4f8fe1f..000000000000
--- a/sys/i386/include/apicreg.h
+++ /dev/null
@@ -1,466 +0,0 @@
-/*
- * Copyright (c) 1996, by Peter Wemm and Steve Passe
- * 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 developer 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _MACHINE_APIC_H_
-#define _MACHINE_APIC_H_
-
-/*
- * Local && I/O APIC definitions.
- */
-
-/*
- * Pentium P54C+ Build-in APIC
- * (Advanced programmable Interrupt Controller)
- *
- * Base Address of Build-in APIC in memory location
- * is 0xfee00000.
- *
- * Map of APIC REgisters:
- *
- * Offset (hex) Description Read/Write state
- * 000 Reserved
- * 010 Reserved
- * 020 ID Local APIC ID R/W
- * 030 VER Local APIC Version R
- * 040 Reserved
- * 050 Reserved
- * 060 Reserved
- * 070 Reserved
- * 080 Task Priority Register R/W
- * 090 Arbitration Priority Register R
- * 0A0 Processor Priority Register R
- * 0B0 EOI Register W
- * 0C0 RRR Remote read R
- * 0D0 Logical Destination R/W
- * 0E0 Destination Format Register 0..27 R; 28..31 R/W
- * 0F0 SVR Spurious Interrupt Vector Reg. 0..3 R; 4..9 R/W
- * 100 ISR 000-031 R
- * 110 ISR 032-063 R
- * 120 ISR 064-095 R
- * 130 ISR 095-128 R
- * 140 ISR 128-159 R
- * 150 ISR 160-191 R
- * 160 ISR 192-223 R
- * 170 ISR 224-255 R
- * 180 TMR 000-031 R
- * 190 TMR 032-063 R
- * 1A0 TMR 064-095 R
- * 1B0 TMR 095-128 R
- * 1C0 TMR 128-159 R
- * 1D0 TMR 160-191 R
- * 1E0 TMR 192-223 R
- * 1F0 TMR 224-255 R
- * 200 IRR 000-031 R
- * 210 IRR 032-063 R
- * 220 IRR 064-095 R
- * 230 IRR 095-128 R
- * 240 IRR 128-159 R
- * 250 IRR 160-191 R
- * 260 IRR 192-223 R
- * 270 IRR 224-255 R
- * 280 Error Status Register R
- * 290 Reserved
- * 2A0 Reserved
- * 2B0 Reserved
- * 2C0 Reserved
- * 2D0 Reserved
- * 2E0 Reserved
- * 2F0 Reserved
- * 300 ICR_LOW Interrupt Command Reg. (0-31) R/W
- * 310 ICR_HI Interrupt Command Reg. (32-63) R/W
- * 320 Local Vector Table (Timer) R/W
- * 330 Reserved
- * 340 Reserved
- * 350 LVT1 Local Vector Table (LINT0) R/W
- * 360 LVT2 Local Vector Table (LINT1) R/W
- * 370 LVT3 Local Vector Table (ERROR) R/W
- * 380 Initial Count Reg. for Timer R/W
- * 390 Current Count of Timer R
- * 3A0 Reserved
- * 3B0 Reserved
- * 3C0 Reserved
- * 3D0 Reserved
- * 3E0 Timer Divide Configuration Reg. R/W
- * 3F0 Reserved
- */
-
-
-/******************************************************************************
- * global defines, etc.
- */
-
-
-/******************************************************************************
- * LOCAL APIC structure
- */
-
-#ifndef LOCORE
-#include <sys/types.h>
-
-#define PAD3 int : 32; int : 32; int : 32
-#define PAD4 int : 32; int : 32; int : 32; int : 32
-
-struct LAPIC {
- /* reserved */ PAD4;
- /* reserved */ PAD4;
- u_int32_t id; PAD3;
- u_int32_t version; PAD3;
- /* reserved */ PAD4;
- /* reserved */ PAD4;
- /* reserved */ PAD4;
- /* reserved */ PAD4;
- u_int32_t tpr; PAD3;
- u_int32_t apr; PAD3;
- u_int32_t ppr; PAD3;
- u_int32_t eoi; PAD3;
- /* reserved */ PAD4;
- u_int32_t ldr; PAD3;
- u_int32_t dfr; PAD3;
- u_int32_t svr; PAD3;
- u_int32_t isr0; PAD3;
- u_int32_t isr1; PAD3;
- u_int32_t isr2; PAD3;
- u_int32_t isr3; PAD3;
- u_int32_t isr4; PAD3;
- u_int32_t isr5; PAD3;
- u_int32_t isr6; PAD3;
- u_int32_t isr7; PAD3;
- u_int32_t tmr0; PAD3;
- u_int32_t tmr1; PAD3;
- u_int32_t tmr2; PAD3;
- u_int32_t tmr3; PAD3;
- u_int32_t tmr4; PAD3;
- u_int32_t tmr5; PAD3;
- u_int32_t tmr6; PAD3;
- u_int32_t tmr7; PAD3;
- u_int32_t irr0; PAD3;
- u_int32_t irr1; PAD3;
- u_int32_t irr2; PAD3;
- u_int32_t irr3; PAD3;
- u_int32_t irr4; PAD3;
- u_int32_t irr5; PAD3;
- u_int32_t irr6; PAD3;
- u_int32_t irr7; PAD3;
- u_int32_t esr; PAD3;
- /* reserved */ PAD4;
- /* reserved */ PAD4;
- /* reserved */ PAD4;
- /* reserved */ PAD4;
- /* reserved */ PAD4;
- /* reserved */ PAD4;
- /* reserved */ PAD4;
- u_int32_t icr_lo; PAD3;
- u_int32_t icr_hi; PAD3;
- u_int32_t lvt_timer; PAD3;
- /* reserved */ PAD4;
- u_int32_t lvt_pcint; PAD3;
- u_int32_t lvt_lint0; PAD3;
- u_int32_t lvt_lint1; PAD3;
- u_int32_t lvt_error; PAD3;
- u_int32_t icr_timer; PAD3;
- u_int32_t ccr_timer; PAD3;
- /* reserved */ PAD4;
- /* reserved */ PAD4;
- /* reserved */ PAD4;
- /* reserved */ PAD4;
- u_int32_t dcr_timer; PAD3;
- /* reserved */ PAD4;
-};
-
-typedef struct LAPIC lapic_t;
-
-/******************************************************************************
- * I/O APIC structure
- */
-
-struct IOAPIC {
- u_int32_t ioregsel; PAD3;
- u_int32_t iowin; PAD3;
-};
-
-typedef struct IOAPIC ioapic_t;
-
-#undef PAD4
-#undef PAD3
-
-#endif /* !LOCORE */
-
-
-/******************************************************************************
- * various code 'logical' values
- */
-
-/* default level for TPR */
-#define LOPRIO_LEVEL 0x00000010 /* TPR of CPU accepting INTs */
-
-#ifdef GRAB_LOPRIO
-#define ALLHWI_LEVEL 0x00000000 /* TPR of CPU grabbing INTs */
-#endif /** GRAB_LOPRIO */
-
-/* XXX these 2 don't really belong here... */
-#define COUNT_FIELD 0x00ffffff /* count portion of the lock */
-#define CPU_FIELD 0xff000000 /* cpu portion of the lock */
-#define FREE_LOCK 0xffffffff /* value of lock when free */
-
-/*
- * XXX This code assummes that the reserved field of the
- * local APIC TPR can be written with all 0s.
- * This saves quite a few memory accesses.
- * If the silicon ever changes then things will break!
- * It affects mplock.s, swtch.s, and possibly other files.
- */
-#define CHEAP_TPR
-
-
-/******************************************************************************
- * LOCAL APIC defines
- */
-
-/* default physical locations of LOCAL (CPU) APICs */
-#define DEFAULT_APIC_BASE 0xfee00000
-
-/* fields in VER */
-#define APIC_VER_VERSION 0x000000ff
-#define APIC_VER_MAXLVT 0x00ff0000
-#define MAXLVTSHIFT 16
-
-/* fields in SVR */
-#define APIC_SVR_VECTOR 0x000000ff
-#define APIC_SVR_VEC_PROG 0x000000f0
-#define APIC_SVR_VEC_FIX 0x0000000f
-#define APIC_SVR_ENABLE 0x00000100
-# define APIC_SVR_SWDIS 0x00000000
-# define APIC_SVR_SWEN 0x00000100
-#define APIC_SVR_FOCUS 0x00000200
-# define APIC_SVR_FEN 0x00000000
-# define APIC_SVR_FDIS 0x00000200
-
-/* fields in TPR */
-#define APIC_TPR_PRIO 0x000000ff
-# define APIC_TPR_INT 0x000000f0
-# define APIC_TPR_SUB 0x0000000f
-
-
-/* fields in ICR_LOW */
-#define APIC_VECTOR_MASK 0x000000ff
-
-#define APIC_DELMODE_MASK 0x00000700
-# define APIC_DELMODE_FIXED 0x00000000
-# define APIC_DELMODE_LOWPRIO 0x00000100
-# define APIC_DELMODE_SMI 0x00000200
-# define APIC_DELMODE_RR 0x00000300
-# define APIC_DELMODE_NMI 0x00000400
-# define APIC_DELMODE_INIT 0x00000500
-# define APIC_DELMODE_STARTUP 0x00000600
-# define APIC_DELMODE_RESV 0x00000700
-
-#define APIC_DESTMODE_MASK 0x00000800
-# define APIC_DESTMODE_PHY 0x00000000
-# define APIC_DESTMODE_LOG 0x00000800
-
-#define APIC_DELSTAT_MASK 0x00001000
-# define APIC_DELSTAT_IDLE 0x00000000
-# define APIC_DELSTAT_PEND 0x00001000
-
-#define APIC_RESV1_MASK 0x00002000
-
-#define APIC_LEVEL_MASK 0x00004000
-# define APIC_LEVEL_DEASSERT 0x00000000
-# define APIC_LEVEL_ASSERT 0x00004000
-
-#define APIC_TRIGMOD_MASK 0x00008000
-# define APIC_TRIGMOD_EDGE 0x00000000
-# define APIC_TRIGMOD_LEVEL 0x00008000
-
-#define APIC_RRSTAT_MASK 0x00030000
-# define APIC_RRSTAT_INVALID 0x00000000
-# define APIC_RRSTAT_INPROG 0x00010000
-# define APIC_RRSTAT_VALID 0x00020000
-# define APIC_RRSTAT_RESV 0x00030000
-
-#define APIC_DEST_MASK 0x000c0000
-# define APIC_DEST_DESTFLD 0x00000000
-# define APIC_DEST_SELF 0x00040000
-# define APIC_DEST_ALLISELF 0x00080000
-# define APIC_DEST_ALLESELF 0x000c0000
-
-#define APIC_RESV2_MASK 0xfff00000
-
-
-/* fields in ICR_HIGH */
-#define APIC_ID_MASK 0x0f000000
-
-
-/* fields in LVT1/2 */
-#define APIC_LVT_VECTOR 0x000000ff
-#define APIC_LVT_DM 0x00000700
-# define APIC_LVT_DM_FIXED 0x00000000
-# define APIC_LVT_DM_NMI 0x00000400
-# define APIC_LVT_DM_EXTINT 0x00000700
-#define APIC_LVT_DS 0x00001000
-#define APIC_LVT_IIPP 0x00002000
-#define APIC_LVT_IIPP_INTALO 0x00002000
-#define APIC_LVT_IIPP_INTAHI 0x00000000
-#define APIC_LVT_RIRR 0x00004000
-#define APIC_LVT_TM 0x00008000
-#define APIC_LVT_M 0x00010000
-
-
-/* fields in LVT Timer */
-#define APIC_LVTT_VECTOR 0x000000ff
-#define APIC_LVTT_DS 0x00001000
-#define APIC_LVTT_M 0x00010000
-#define APIC_LVTT_TM 0x00020000
-
-
-/* fields in TDCR */
-#define APIC_TDCR_2 0x00
-#define APIC_TDCR_4 0x01
-#define APIC_TDCR_8 0x02
-#define APIC_TDCR_16 0x03
-#define APIC_TDCR_32 0x08
-#define APIC_TDCR_64 0x09
-#define APIC_TDCR_128 0x0a
-#define APIC_TDCR_1 0x0b
-
-
-/*
- * fields in IRR
- * ISA INTerrupts are in bits 16-31 of the 1st IRR register.
- * these masks DON'T EQUAL the isa IRQs of the same name.
- */
-#define APIC_IRQ0 0x00000001
-#define APIC_IRQ1 0x00000002
-#define APIC_IRQ2 0x00000004
-#define APIC_IRQ3 0x00000008
-#define APIC_IRQ4 0x00000010
-#define APIC_IRQ5 0x00000020
-#define APIC_IRQ6 0x00000040
-#define APIC_IRQ7 0x00000080
-#define APIC_IRQ8 0x00000100
-#define APIC_IRQ9 0x00000200
-#define APIC_IRQ10 0x00000400
-#define APIC_IRQ11 0x00000800
-#define APIC_IRQ12 0x00001000
-#define APIC_IRQ13 0x00002000
-#define APIC_IRQ14 0x00004000
-#define APIC_IRQ15 0x00008000
-#define APIC_IRQ16 0x00010000
-#define APIC_IRQ17 0x00020000
-#define APIC_IRQ18 0x00040000
-#define APIC_IRQ19 0x00080000
-#define APIC_IRQ20 0x00100000
-#define APIC_IRQ21 0x00200000
-#define APIC_IRQ22 0x00400000
-#define APIC_IRQ23 0x00800000
-
-
-/******************************************************************************
- * I/O APIC defines
- */
-
-/* default physical locations of an IO APIC */
-#define DEFAULT_IO_APIC_BASE 0xfec00000
-
-/* window register offset */
-#define IOAPIC_WINDOW 0x10
-
-/* indexes into IO APIC */
-#define IOAPIC_ID 0x00
-#define IOAPIC_VER 0x01
-#define IOAPIC_ARB 0x02
-#define IOAPIC_REDTBL 0x10
-#define IOAPIC_REDTBL0 IOAPIC_REDTBL
-#define IOAPIC_REDTBL1 (IOAPIC_REDTBL+0x02)
-#define IOAPIC_REDTBL2 (IOAPIC_REDTBL+0x04)
-#define IOAPIC_REDTBL3 (IOAPIC_REDTBL+0x06)
-#define IOAPIC_REDTBL4 (IOAPIC_REDTBL+0x08)
-#define IOAPIC_REDTBL5 (IOAPIC_REDTBL+0x0a)
-#define IOAPIC_REDTBL6 (IOAPIC_REDTBL+0x0c)
-#define IOAPIC_REDTBL7 (IOAPIC_REDTBL+0x0e)
-#define IOAPIC_REDTBL8 (IOAPIC_REDTBL+0x10)
-#define IOAPIC_REDTBL9 (IOAPIC_REDTBL+0x12)
-#define IOAPIC_REDTBL10 (IOAPIC_REDTBL+0x14)
-#define IOAPIC_REDTBL11 (IOAPIC_REDTBL+0x16)
-#define IOAPIC_REDTBL12 (IOAPIC_REDTBL+0x18)
-#define IOAPIC_REDTBL13 (IOAPIC_REDTBL+0x1a)
-#define IOAPIC_REDTBL14 (IOAPIC_REDTBL+0x1c)
-#define IOAPIC_REDTBL15 (IOAPIC_REDTBL+0x1e)
-#define IOAPIC_REDTBL16 (IOAPIC_REDTBL+0x20)
-#define IOAPIC_REDTBL17 (IOAPIC_REDTBL+0x22)
-#define IOAPIC_REDTBL18 (IOAPIC_REDTBL+0x24)
-#define IOAPIC_REDTBL19 (IOAPIC_REDTBL+0x26)
-#define IOAPIC_REDTBL20 (IOAPIC_REDTBL+0x28)
-#define IOAPIC_REDTBL21 (IOAPIC_REDTBL+0x2a)
-#define IOAPIC_REDTBL22 (IOAPIC_REDTBL+0x2c)
-#define IOAPIC_REDTBL23 (IOAPIC_REDTBL+0x2e)
-
-/* fields in VER */
-#define IOART_VER_VERSION 0x000000ff
-#define IOART_VER_MAXREDIR 0x00ff0000
-#define MAXREDIRSHIFT 16
-
-/*
- * fields in the IO APIC's redirection table entries
- */
-#define IOART_DEST APIC_ID_MASK /* broadcast addr: all APICs */
-
-#define IOART_RESV 0x00fe0000 /* reserved */
-
-#define IOART_INTMASK 0x00010000 /* R/W: INTerrupt mask */
-# define IOART_INTMCLR 0x00000000 /* clear, allow INTs */
-# define IOART_INTMSET 0x00010000 /* set, inhibit INTs */
-
-#define IOART_TRGRMOD 0x00008000 /* R/W: trigger mode */
-# define IOART_TRGREDG 0x00000000 /* edge */
-# define IOART_TRGRLVL 0x00008000 /* level */
-
-#define IOART_REM_IRR 0x00004000 /* RO: remote IRR */
-
-#define IOART_INTPOL 0x00002000 /* R/W: INT input pin polarity */
-# define IOART_INTAHI 0x00000000 /* active high */
-# define IOART_INTALO 0x00002000 /* active low */
-
-#define IOART_DELIVS 0x00001000 /* RO: delivery status */
-
-#define IOART_DESTMOD 0x00000800 /* R/W: destination mode */
-# define IOART_DESTPHY 0x00000000 /* physical */
-# define IOART_DESTLOG 0x00000800 /* logical */
-
-#define IOART_DELMOD 0x00000700 /* R/W: delivery mode */
-# define IOART_DELFIXED 0x00000000 /* fixed */
-# define IOART_DELLOPRI 0x00000100 /* lowest priority */
-# define IOART_DELSMI 0x00000200 /* System Management INT */
-# define IOART_DELRSV1 0x00000300 /* reserved */
-# define IOART_DELNMI 0x00000400 /* NMI signal */
-# define IOART_DELINIT 0x00000500 /* INIT signal */
-# define IOART_DELRSV2 0x00000600 /* reserved */
-# define IOART_DELEXINT 0x00000700 /* External INTerrupt */
-
-#define IOART_INTVEC 0x000000ff /* R/W: INTerrupt vector field */
-
-#endif /* _MACHINE_APIC_H_ */
diff --git a/sys/i386/include/bus_at386.h b/sys/i386/include/bus_at386.h
deleted file mode 100644
index 661761271085..000000000000
--- a/sys/i386/include/bus_at386.h
+++ /dev/null
@@ -1,1291 +0,0 @@
-/* $NetBSD: bus.h,v 1.12 1997/10/01 08:25:15 fvdl Exp $ */
-
-/*-
- * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
- * NASA Ames Research Center.
- *
- * 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 the NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Copyright (c) 1996 Charles M. Hannum. All rights reserved.
- * Copyright (c) 1996 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
- * for the NetBSD Project.
- * 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.
- */
-/* $FreeBSD$ */
-
-#ifndef _I386_BUS_H_
-#define _I386_BUS_H_
-
-#include <machine/cpufunc.h>
-
-/*
- * To remain compatible with NetBSD's interface, default to both memio and
- * pio when neither of them is defined.
- */
-#if !defined(_I386_BUS_PIO_H_) && !defined(_I386_BUS_MEMIO_H_)
-#define _I386_BUS_PIO_H_
-#define _I386_BUS_MEMIO_H_
-#endif
-
-/*
- * Values for the i386 bus space tag, not to be used directly by MI code.
- */
-#define I386_BUS_SPACE_IO 0 /* space is i/o space */
-#define I386_BUS_SPACE_MEM 1 /* space is mem space */
-
-/*
- * Bus address and size types
- */
-typedef u_int bus_addr_t;
-typedef u_int bus_size_t;
-
-#define BUS_SPACE_MAXSIZE_24BIT 0xFFFFFF
-#define BUS_SPACE_MAXSIZE_32BIT 0xFFFFFFFF
-#define BUS_SPACE_MAXSIZE (64 * 1024) /* Maximum supported size */
-#define BUS_SPACE_MAXADDR_24BIT 0xFFFFFF
-#define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFF
-#define BUS_SPACE_MAXADDR 0xFFFFFFFF
-
-#define BUS_SPACE_UNRESTRICTED (~0)
-
-/*
- * Access methods for bus resources and address space.
- */
-typedef int bus_space_tag_t;
-typedef u_int bus_space_handle_t;
-
-/*
- * Map a region of device bus space into CPU virtual address space.
- */
-
-#define BUS_SPACE_MAP_CACHEABLE 0x01
-#define BUS_SPACE_MAP_LINEAR 0x02
-
-int bus_space_map(bus_space_tag_t t, bus_addr_t addr, bus_size_t size,
- int flags, bus_space_handle_t *bshp);
-
-/*
- * Unmap a region of device bus space.
- */
-
-void bus_space_unmap(bus_space_tag_t t, bus_space_handle_t bsh,
- bus_size_t size);
-
-/*
- * Get a new handle for a subregion of an already-mapped area of bus space.
- */
-
-int bus_space_subregion(bus_space_tag_t t, bus_space_handle_t bsh,
- bus_size_t offset, bus_size_t size,
- bus_space_handle_t *nbshp);
-
-/*
- * Allocate a region of memory that is accessible to devices in bus space.
- */
-
-int bus_space_alloc(bus_space_tag_t t, 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);
-
-/*
- * Free a region of bus space accessible memory.
- */
-
-void bus_space_free(bus_space_tag_t t, bus_space_handle_t bsh,
- bus_size_t size);
-
-#if defined(_I386_BUS_PIO_H_) || defined(_I386_BUS_MEMIO_H_)
-
-/*
- * Read a 1, 2, 4, or 8 byte quantity from bus space
- * described by tag/handle/offset.
- */
-static __inline u_int8_t bus_space_read_1(bus_space_tag_t tag,
- bus_space_handle_t handle,
- bus_size_t offset);
-
-static __inline u_int16_t bus_space_read_2(bus_space_tag_t tag,
- bus_space_handle_t handle,
- bus_size_t offset);
-
-static __inline u_int32_t bus_space_read_4(bus_space_tag_t tag,
- bus_space_handle_t handle,
- bus_size_t offset);
-
-static __inline u_int8_t
-bus_space_read_1(bus_space_tag_t tag, bus_space_handle_t handle,
- bus_size_t offset)
-{
-#if defined (_I386_BUS_PIO_H_)
-#if defined (_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- return (inb(handle + offset));
-#endif
-#if defined (_I386_BUS_MEMIO_H_)
- return (*(volatile u_int8_t *)(handle + offset));
-#endif
-}
-
-static __inline u_int16_t
-bus_space_read_2(bus_space_tag_t tag, bus_space_handle_t handle,
- bus_size_t offset)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- return (inw(handle + offset));
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
- return (*(volatile u_int16_t *)(handle + offset));
-#endif
-}
-
-static __inline u_int32_t
-bus_space_read_4(bus_space_tag_t tag, bus_space_handle_t handle,
- bus_size_t offset)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- return (inl(handle + offset));
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
- return (*(volatile u_int32_t *)(handle + offset));
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_read_8 */
-#define bus_space_read_8(t, h, o) !!! bus_space_read_8 unimplemented !!!
-#endif
-
-/*
- * Read `count' 1, 2, 4, or 8 byte quantities from bus space
- * described by tag/handle/offset and copy into buffer provided.
- */
-static __inline void bus_space_read_multi_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t *addr,
- size_t count);
-
-static __inline void bus_space_read_multi_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t *addr,
- size_t count);
-
-static __inline void bus_space_read_multi_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t *addr,
- size_t count);
-
-static __inline void
-bus_space_read_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- insb(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: movb (%2),%%al \n\
- stosb \n\
- loop 1b" :
- "=D" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory");
- }
-#endif
-}
-
-static __inline void
-bus_space_read_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- insw(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: movw (%2),%%ax \n\
- stosw \n\
- loop 1b" :
- "=D" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory");
- }
-#endif
-}
-
-static __inline void
-bus_space_read_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- insl(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: movl (%2),%%eax \n\
- stosl \n\
- loop 1b" :
- "=D" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory");
- }
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_read_multi_8 */
-#define bus_space_read_multi_8 !!! bus_space_read_multi_8 unimplemented !!!
-#endif
-
-/*
- * Read `count' 1, 2, 4, or 8 byte quantities from bus space
- * described by tag/handle and starting at `offset' and copy into
- * buffer provided.
- */
-static __inline void bus_space_read_region_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t *addr,
- size_t count);
-
-static __inline void bus_space_read_region_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t *addr,
- size_t count);
-
-static __inline void bus_space_read_region_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t *addr,
- size_t count);
-
-
-static __inline void
-bus_space_read_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: inb %w2,%%al \n\
- stosb \n\
- incl %2 \n\
- loop 1b" :
- "=D" (addr), "=c" (count), "=d" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsb" :
- "=D" (addr), "=c" (count), "=S" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_read_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: inw %w2,%%ax \n\
- stosw \n\
- addl $2,%2 \n\
- loop 1b" :
- "=D" (addr), "=c" (count), "=d" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsw" :
- "=D" (addr), "=c" (count), "=S" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_read_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: inl %w2,%%eax \n\
- stosl \n\
- addl $4,%2 \n\
- loop 1b" :
- "=D" (addr), "=c" (count), "=d" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsl" :
- "=D" (addr), "=c" (count), "=S" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "memory", "cc");
- }
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_read_region_8 */
-#define bus_space_read_region_8 !!! bus_space_read_region_8 unimplemented !!!
-#endif
-
-/*
- * Write the 1, 2, 4, or 8 byte value `value' to bus space
- * described by tag/handle/offset.
- */
-
-static __inline void bus_space_write_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t value);
-
-static __inline void bus_space_write_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t value);
-
-static __inline void bus_space_write_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t value);
-
-static __inline void
-bus_space_write_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t value)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outb(bsh + offset, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- *(volatile u_int8_t *)(bsh + offset) = value;
-#endif
-}
-
-static __inline void
-bus_space_write_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t value)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outw(bsh + offset, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- *(volatile u_int16_t *)(bsh + offset) = value;
-#endif
-}
-
-static __inline void
-bus_space_write_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t value)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outl(bsh + offset, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- *(volatile u_int32_t *)(bsh + offset) = value;
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_write_8 */
-#define bus_space_write_8 !!! bus_space_write_8 not implemented !!!
-#endif
-
-/*
- * Write `count' 1, 2, 4, or 8 byte quantities from the buffer
- * provided to bus space described by tag/handle/offset.
- */
-
-static __inline void bus_space_write_multi_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int8_t *addr,
- size_t count);
-static __inline void bus_space_write_multi_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int16_t *addr,
- size_t count);
-
-static __inline void bus_space_write_multi_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int32_t *addr,
- size_t count);
-
-static __inline void
-bus_space_write_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int8_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outsb(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: lodsb \n\
- movb %%al,(%2) \n\
- loop 1b" :
- "=S" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_write_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int16_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outsw(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: lodsw \n\
- movw %%ax,(%1) \n\
- movw %%ax,(%2) \n\
- loop 1b" :
- "=S" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_write_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int32_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outsl(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: lodsl \n\
- movl %%eax,(%2) \n\
- loop 1b" :
- "=S" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_write_multi_8 */
-#define bus_space_write_multi_8(t, h, o, a, c) \
- !!! bus_space_write_multi_8 unimplemented !!!
-#endif
-
-/*
- * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided
- * to bus space described by tag/handle starting at `offset'.
- */
-
-static __inline void bus_space_write_region_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int8_t *addr,
- size_t count);
-static __inline void bus_space_write_region_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int16_t *addr,
- size_t count);
-static __inline void bus_space_write_region_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int32_t *addr,
- size_t count);
-
-static __inline void
-bus_space_write_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int8_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: lodsb \n\
- outb %%al,%w0 \n\
- incl %0 \n\
- loop 1b" :
- "=d" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsb" :
- "=D" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_write_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int16_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: lodsw \n\
- outw %%ax,%w0 \n\
- addl $2,%0 \n\
- loop 1b" :
- "=d" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsw" :
- "=D" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_write_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int32_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: lodsl \n\
- outl %%eax,%w0 \n\
- addl $4,%0 \n\
- loop 1b" :
- "=d" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsl" :
- "=D" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "memory", "cc");
- }
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_write_region_8 */
-#define bus_space_write_region_8 \
- !!! bus_space_write_region_8 unimplemented !!!
-#endif
-
-/*
- * Write the 1, 2, 4, or 8 byte value `val' to bus space described
- * by tag/handle/offset `count' times.
- */
-
-static __inline void bus_space_set_multi_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- u_int8_t value, size_t count);
-static __inline void bus_space_set_multi_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- u_int16_t value, size_t count);
-static __inline void bus_space_set_multi_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- u_int32_t value, size_t count);
-
-static __inline void
-bus_space_set_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- while (count--)
- outb(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- while (count--)
- *(volatile u_int8_t *)(addr) = value;
-#endif
-}
-
-static __inline void
-bus_space_set_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- while (count--)
- outw(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- while (count--)
- *(volatile u_int16_t *)(addr) = value;
-#endif
-}
-
-static __inline void
-bus_space_set_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- while (count--)
- outl(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- while (count--)
- *(volatile u_int32_t *)(addr) = value;
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_set_multi_8 */
-#define bus_space_set_multi_8 !!! bus_space_set_multi_8 unimplemented !!!
-#endif
-
-/*
- * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described
- * by tag/handle starting at `offset'.
- */
-
-static __inline void bus_space_set_region_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t value,
- size_t count);
-static __inline void bus_space_set_region_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t value,
- size_t count);
-static __inline void bus_space_set_region_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t value,
- size_t count);
-
-static __inline void
-bus_space_set_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- for (; count != 0; count--, addr++)
- outb(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- for (; count != 0; count--, addr++)
- *(volatile u_int8_t *)(addr) = value;
-#endif
-}
-
-static __inline void
-bus_space_set_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- for (; count != 0; count--, addr += 2)
- outw(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- for (; count != 0; count--, addr += 2)
- *(volatile u_int16_t *)(addr) = value;
-#endif
-}
-
-static __inline void
-bus_space_set_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- for (; count != 0; count--, addr += 4)
- outl(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- for (; count != 0; count--, addr += 4)
- *(volatile u_int32_t *)(addr) = value;
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_set_region_8 */
-#define bus_space_set_region_8 !!! bus_space_set_region_8 unimplemented !!!
-#endif
-
-/*
- * Copy `count' 1, 2, 4, or 8 byte values from bus space starting
- * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2.
- */
-
-static __inline void bus_space_copy_region_1(bus_space_tag_t tag,
- bus_space_handle_t bsh1,
- bus_size_t off1,
- bus_space_handle_t bsh2,
- bus_size_t off2, size_t count);
-
-static __inline void bus_space_copy_region_2(bus_space_tag_t tag,
- bus_space_handle_t bsh1,
- bus_size_t off1,
- bus_space_handle_t bsh2,
- bus_size_t off2, size_t count);
-
-static __inline void bus_space_copy_region_4(bus_space_tag_t tag,
- bus_space_handle_t bsh1,
- bus_size_t off1,
- bus_space_handle_t bsh2,
- bus_size_t off2, size_t count);
-
-static __inline void
-bus_space_copy_region_1(bus_space_tag_t tag, bus_space_handle_t bsh1,
- bus_size_t off1, bus_space_handle_t bsh2,
- bus_size_t off2, size_t count)
-{
- bus_addr_t addr1 = bsh1 + off1;
- bus_addr_t addr2 = bsh2 + off2;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1++, addr2++)
- outb(addr2, inb(addr1));
- } else {
- /* dest after src: copy backwards */
- for (addr1 += (count - 1), addr2 += (count - 1);
- count != 0; count--, addr1--, addr2--)
- outb(addr2, inb(addr1));
- }
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1++, addr2++)
- *(volatile u_int8_t *)(addr2) =
- *(volatile u_int8_t *)(addr1);
- } else {
- /* dest after src: copy backwards */
- for (addr1 += (count - 1), addr2 += (count - 1);
- count != 0; count--, addr1--, addr2--)
- *(volatile u_int8_t *)(addr2) =
- *(volatile u_int8_t *)(addr1);
- }
- }
-#endif
-}
-
-static __inline void
-bus_space_copy_region_2(bus_space_tag_t tag, bus_space_handle_t bsh1,
- bus_size_t off1, bus_space_handle_t bsh2,
- bus_size_t off2, size_t count)
-{
- bus_addr_t addr1 = bsh1 + off1;
- bus_addr_t addr2 = bsh2 + off2;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1 += 2, addr2 += 2)
- outw(addr2, inw(addr1));
- } else {
- /* dest after src: copy backwards */
- for (addr1 += 2 * (count - 1), addr2 += 2 * (count - 1);
- count != 0; count--, addr1 -= 2, addr2 -= 2)
- outw(addr2, inw(addr1));
- }
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1 += 2, addr2 += 2)
- *(volatile u_int16_t *)(addr2) =
- *(volatile u_int16_t *)(addr1);
- } else {
- /* dest after src: copy backwards */
- for (addr1 += 2 * (count - 1), addr2 += 2 * (count - 1);
- count != 0; count--, addr1 -= 2, addr2 -= 2)
- *(volatile u_int16_t *)(addr2) =
- *(volatile u_int16_t *)(addr1);
- }
- }
-#endif
-}
-
-static __inline void
-bus_space_copy_region_4(bus_space_tag_t tag, bus_space_handle_t bsh1,
- bus_size_t off1, bus_space_handle_t bsh2,
- bus_size_t off2, size_t count)
-{
- bus_addr_t addr1 = bsh1 + off1;
- bus_addr_t addr2 = bsh2 + off2;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1 += 4, addr2 += 4)
- outl(addr2, inl(addr1));
- } else {
- /* dest after src: copy backwards */
- for (addr1 += 4 * (count - 1), addr2 += 4 * (count - 1);
- count != 0; count--, addr1 -= 4, addr2 -= 4)
- outl(addr2, inl(addr1));
- }
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1 += 4, addr2 += 4)
- *(volatile u_int32_t *)(addr2) =
- *(volatile u_int32_t *)(addr1);
- } else {
- /* dest after src: copy backwards */
- for (addr1 += 4 * (count - 1), addr2 += 4 * (count - 1);
- count != 0; count--, addr1 -= 4, addr2 -= 4)
- *(volatile u_int32_t *)(addr2) =
- *(volatile u_int32_t *)(addr1);
- }
- }
-#endif
-}
-
-#endif /* defined(_I386_BUS_PIO_H_) || defined(_I386_MEM_IO_H_) */
-
-#if 0 /* Cause a link error for bus_space_copy_8 */
-#define bus_space_copy_region_8 !!! bus_space_copy_region_8 unimplemented !!!
-#endif
-
-/*
- * Bus read/write barrier methods.
- *
- * void bus_space_barrier(bus_space_tag_t tag, bus_space_handle_t bsh,
- * bus_size_t offset, bus_size_t len, int flags);
- *
- * Note: the i386 does not currently require barriers, but we must
- * provide the flags to MI code.
- */
-#define bus_space_barrier(t, h, o, l, f) \
- ((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f)))
-#define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */
-#define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */
-
-/*
- * Flags used in various bus DMA methods.
- */
-#define BUS_DMA_WAITOK 0x00 /* safe to sleep (pseudo-flag) */
-#define BUS_DMA_NOWAIT 0x01 /* not safe to sleep */
-#define BUS_DMA_ALLOCNOW 0x02 /* perform resource allocation now */
-#define BUS_DMAMEM_NOSYNC 0x04 /* map memory to not require sync */
-#define BUS_DMA_BUS1 0x10 /* placeholders for bus functions... */
-#define BUS_DMA_BUS2 0x20
-#define BUS_DMA_BUS3 0x40
-#define BUS_DMA_BUS4 0x80
-
-/* Forwards needed by prototypes below. */
-struct mbuf;
-struct uio;
-
-/*
- * bus_dmasync_op_t
- *
- * Operations performed by bus_dmamap_sync().
- */
-typedef enum {
- BUS_DMASYNC_PREREAD,
- BUS_DMASYNC_POSTREAD,
- BUS_DMASYNC_PREWRITE,
- BUS_DMASYNC_POSTWRITE
-} bus_dmasync_op_t;
-
-/*
- * bus_dma_tag_t
- *
- * A machine-dependent opaque type describing the characteristics
- * of how to perform DMA mappings. This structure encapsultes
- * information concerning address and alignment restrictions, number
- * of S/G segments, amount of data per S/G segment, etc.
- */
-typedef struct bus_dma_tag *bus_dma_tag_t;
-
-/*
- * bus_dmamap_t
- *
- * DMA mapping instance information.
- */
-typedef struct bus_dmamap *bus_dmamap_t;
-
-/*
- * bus_dma_segment_t
- *
- * Describes a single contiguous DMA transaction. Values
- * are suitable for programming into DMA registers.
- */
-typedef struct bus_dma_segment {
- bus_addr_t ds_addr; /* DMA address */
- bus_size_t ds_len; /* length of transfer */
-} bus_dma_segment_t;
-
-/*
- * A function that returns 1 if the address cannot be accessed by
- * a device and 0 if it can be.
- */
-typedef int bus_dma_filter_t(void *, bus_addr_t);
-
-/*
- * Allocate a device specific dma_tag encapsulating the constraints of
- * the parent tag in addition to other restrictions specified:
- *
- * alignment: alignment for segments.
- * boundary: Boundary that segments cannot cross.
- * lowaddr: Low restricted address that cannot appear in a mapping.
- * highaddr: High restricted address that cannot appear in a mapping.
- * filtfunc: An optional function to further test if an address
- * within the range of lowaddr and highaddr cannot appear
- * in a mapping.
- * filtfuncarg: An argument that will be passed to filtfunc in addition
- * to the address to test.
- * maxsize: Maximum mapping size supported by this tag.
- * nsegments: Number of discontinuities allowed in maps.
- * maxsegsz: Maximum size of a segment in the map.
- * flags: Bus DMA flags.
- * dmat: A pointer to set to a valid dma tag should the return
- * value of this function indicate success.
- */
-/* XXX Should probably allow specification of alignment */
-int bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignemnt,
- bus_size_t boundary, bus_addr_t lowaddr,
- bus_addr_t highaddr, bus_dma_filter_t *filtfunc,
- void *filtfuncarg, bus_size_t maxsize, int nsegments,
- bus_size_t maxsegsz, int flags, bus_dma_tag_t *dmat);
-
-int bus_dma_tag_destroy(bus_dma_tag_t dmat);
-
-/*
- * Allocate a handle for mapping from kva/uva/physical
- * address space into bus device space.
- */
-int bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp);
-
-/*
- * Destroy a handle for mapping from kva/uva/physical
- * address space into bus device space.
- */
-int bus_dmamap_destroy(bus_dma_tag_t dmat, bus_dmamap_t map);
-
-/*
- * Allocate a piece of memory that can be efficiently mapped into
- * bus device space based on the constraints lited in the dma tag.
- * A dmamap to for use with dmamap_load is also allocated.
- */
-int bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
- bus_dmamap_t *mapp);
-
-/*
- * Free a piece of memory and it's allociated dmamap, that was allocated
- * via bus_dmamem_alloc.
- */
-void bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map);
-
-/*
- * A function that processes a successfully loaded dma map or an error
- * from a delayed load map.
- */
-typedef void bus_dmamap_callback_t(void *, bus_dma_segment_t *, int, int);
-
-/*
- * Map the buffer buf into bus space using the dmamap map.
- */
-int bus_dmamap_load(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf,
- bus_size_t buflen, bus_dmamap_callback_t *callback,
- void *callback_arg, int flags);
-
-/*
- * Perform a syncronization operation on the given map.
- */
-void _bus_dmamap_sync(bus_dma_tag_t, bus_dmamap_t, bus_dmasync_op_t);
-#define bus_dmamap_sync(dmat, dmamap, op) \
- if ((dmamap) != NULL) \
- _bus_dmamap_sync(dmat, dmamap, op)
-
-/*
- * Release the mapping held by map.
- */
-void _bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map);
-#define bus_dmamap_unload(dmat, dmamap) \
- if ((dmamap) != NULL) \
- _bus_dmamap_unload(dmat, dmamap)
-
-#endif /* _I386_BUS_H_ */
diff --git a/sys/i386/include/bus_dma.h b/sys/i386/include/bus_dma.h
deleted file mode 100644
index 661761271085..000000000000
--- a/sys/i386/include/bus_dma.h
+++ /dev/null
@@ -1,1291 +0,0 @@
-/* $NetBSD: bus.h,v 1.12 1997/10/01 08:25:15 fvdl Exp $ */
-
-/*-
- * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
- * NASA Ames Research Center.
- *
- * 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 the NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Copyright (c) 1996 Charles M. Hannum. All rights reserved.
- * Copyright (c) 1996 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
- * for the NetBSD Project.
- * 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.
- */
-/* $FreeBSD$ */
-
-#ifndef _I386_BUS_H_
-#define _I386_BUS_H_
-
-#include <machine/cpufunc.h>
-
-/*
- * To remain compatible with NetBSD's interface, default to both memio and
- * pio when neither of them is defined.
- */
-#if !defined(_I386_BUS_PIO_H_) && !defined(_I386_BUS_MEMIO_H_)
-#define _I386_BUS_PIO_H_
-#define _I386_BUS_MEMIO_H_
-#endif
-
-/*
- * Values for the i386 bus space tag, not to be used directly by MI code.
- */
-#define I386_BUS_SPACE_IO 0 /* space is i/o space */
-#define I386_BUS_SPACE_MEM 1 /* space is mem space */
-
-/*
- * Bus address and size types
- */
-typedef u_int bus_addr_t;
-typedef u_int bus_size_t;
-
-#define BUS_SPACE_MAXSIZE_24BIT 0xFFFFFF
-#define BUS_SPACE_MAXSIZE_32BIT 0xFFFFFFFF
-#define BUS_SPACE_MAXSIZE (64 * 1024) /* Maximum supported size */
-#define BUS_SPACE_MAXADDR_24BIT 0xFFFFFF
-#define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFF
-#define BUS_SPACE_MAXADDR 0xFFFFFFFF
-
-#define BUS_SPACE_UNRESTRICTED (~0)
-
-/*
- * Access methods for bus resources and address space.
- */
-typedef int bus_space_tag_t;
-typedef u_int bus_space_handle_t;
-
-/*
- * Map a region of device bus space into CPU virtual address space.
- */
-
-#define BUS_SPACE_MAP_CACHEABLE 0x01
-#define BUS_SPACE_MAP_LINEAR 0x02
-
-int bus_space_map(bus_space_tag_t t, bus_addr_t addr, bus_size_t size,
- int flags, bus_space_handle_t *bshp);
-
-/*
- * Unmap a region of device bus space.
- */
-
-void bus_space_unmap(bus_space_tag_t t, bus_space_handle_t bsh,
- bus_size_t size);
-
-/*
- * Get a new handle for a subregion of an already-mapped area of bus space.
- */
-
-int bus_space_subregion(bus_space_tag_t t, bus_space_handle_t bsh,
- bus_size_t offset, bus_size_t size,
- bus_space_handle_t *nbshp);
-
-/*
- * Allocate a region of memory that is accessible to devices in bus space.
- */
-
-int bus_space_alloc(bus_space_tag_t t, 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);
-
-/*
- * Free a region of bus space accessible memory.
- */
-
-void bus_space_free(bus_space_tag_t t, bus_space_handle_t bsh,
- bus_size_t size);
-
-#if defined(_I386_BUS_PIO_H_) || defined(_I386_BUS_MEMIO_H_)
-
-/*
- * Read a 1, 2, 4, or 8 byte quantity from bus space
- * described by tag/handle/offset.
- */
-static __inline u_int8_t bus_space_read_1(bus_space_tag_t tag,
- bus_space_handle_t handle,
- bus_size_t offset);
-
-static __inline u_int16_t bus_space_read_2(bus_space_tag_t tag,
- bus_space_handle_t handle,
- bus_size_t offset);
-
-static __inline u_int32_t bus_space_read_4(bus_space_tag_t tag,
- bus_space_handle_t handle,
- bus_size_t offset);
-
-static __inline u_int8_t
-bus_space_read_1(bus_space_tag_t tag, bus_space_handle_t handle,
- bus_size_t offset)
-{
-#if defined (_I386_BUS_PIO_H_)
-#if defined (_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- return (inb(handle + offset));
-#endif
-#if defined (_I386_BUS_MEMIO_H_)
- return (*(volatile u_int8_t *)(handle + offset));
-#endif
-}
-
-static __inline u_int16_t
-bus_space_read_2(bus_space_tag_t tag, bus_space_handle_t handle,
- bus_size_t offset)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- return (inw(handle + offset));
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
- return (*(volatile u_int16_t *)(handle + offset));
-#endif
-}
-
-static __inline u_int32_t
-bus_space_read_4(bus_space_tag_t tag, bus_space_handle_t handle,
- bus_size_t offset)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- return (inl(handle + offset));
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
- return (*(volatile u_int32_t *)(handle + offset));
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_read_8 */
-#define bus_space_read_8(t, h, o) !!! bus_space_read_8 unimplemented !!!
-#endif
-
-/*
- * Read `count' 1, 2, 4, or 8 byte quantities from bus space
- * described by tag/handle/offset and copy into buffer provided.
- */
-static __inline void bus_space_read_multi_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t *addr,
- size_t count);
-
-static __inline void bus_space_read_multi_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t *addr,
- size_t count);
-
-static __inline void bus_space_read_multi_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t *addr,
- size_t count);
-
-static __inline void
-bus_space_read_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- insb(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: movb (%2),%%al \n\
- stosb \n\
- loop 1b" :
- "=D" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory");
- }
-#endif
-}
-
-static __inline void
-bus_space_read_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- insw(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: movw (%2),%%ax \n\
- stosw \n\
- loop 1b" :
- "=D" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory");
- }
-#endif
-}
-
-static __inline void
-bus_space_read_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- insl(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: movl (%2),%%eax \n\
- stosl \n\
- loop 1b" :
- "=D" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory");
- }
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_read_multi_8 */
-#define bus_space_read_multi_8 !!! bus_space_read_multi_8 unimplemented !!!
-#endif
-
-/*
- * Read `count' 1, 2, 4, or 8 byte quantities from bus space
- * described by tag/handle and starting at `offset' and copy into
- * buffer provided.
- */
-static __inline void bus_space_read_region_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t *addr,
- size_t count);
-
-static __inline void bus_space_read_region_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t *addr,
- size_t count);
-
-static __inline void bus_space_read_region_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t *addr,
- size_t count);
-
-
-static __inline void
-bus_space_read_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: inb %w2,%%al \n\
- stosb \n\
- incl %2 \n\
- loop 1b" :
- "=D" (addr), "=c" (count), "=d" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsb" :
- "=D" (addr), "=c" (count), "=S" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_read_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: inw %w2,%%ax \n\
- stosw \n\
- addl $2,%2 \n\
- loop 1b" :
- "=D" (addr), "=c" (count), "=d" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsw" :
- "=D" (addr), "=c" (count), "=S" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_read_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: inl %w2,%%eax \n\
- stosl \n\
- addl $4,%2 \n\
- loop 1b" :
- "=D" (addr), "=c" (count), "=d" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsl" :
- "=D" (addr), "=c" (count), "=S" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "memory", "cc");
- }
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_read_region_8 */
-#define bus_space_read_region_8 !!! bus_space_read_region_8 unimplemented !!!
-#endif
-
-/*
- * Write the 1, 2, 4, or 8 byte value `value' to bus space
- * described by tag/handle/offset.
- */
-
-static __inline void bus_space_write_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t value);
-
-static __inline void bus_space_write_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t value);
-
-static __inline void bus_space_write_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t value);
-
-static __inline void
-bus_space_write_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t value)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outb(bsh + offset, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- *(volatile u_int8_t *)(bsh + offset) = value;
-#endif
-}
-
-static __inline void
-bus_space_write_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t value)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outw(bsh + offset, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- *(volatile u_int16_t *)(bsh + offset) = value;
-#endif
-}
-
-static __inline void
-bus_space_write_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t value)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outl(bsh + offset, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- *(volatile u_int32_t *)(bsh + offset) = value;
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_write_8 */
-#define bus_space_write_8 !!! bus_space_write_8 not implemented !!!
-#endif
-
-/*
- * Write `count' 1, 2, 4, or 8 byte quantities from the buffer
- * provided to bus space described by tag/handle/offset.
- */
-
-static __inline void bus_space_write_multi_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int8_t *addr,
- size_t count);
-static __inline void bus_space_write_multi_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int16_t *addr,
- size_t count);
-
-static __inline void bus_space_write_multi_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int32_t *addr,
- size_t count);
-
-static __inline void
-bus_space_write_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int8_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outsb(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: lodsb \n\
- movb %%al,(%2) \n\
- loop 1b" :
- "=S" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_write_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int16_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outsw(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: lodsw \n\
- movw %%ax,(%1) \n\
- movw %%ax,(%2) \n\
- loop 1b" :
- "=S" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_write_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int32_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outsl(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: lodsl \n\
- movl %%eax,(%2) \n\
- loop 1b" :
- "=S" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_write_multi_8 */
-#define bus_space_write_multi_8(t, h, o, a, c) \
- !!! bus_space_write_multi_8 unimplemented !!!
-#endif
-
-/*
- * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided
- * to bus space described by tag/handle starting at `offset'.
- */
-
-static __inline void bus_space_write_region_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int8_t *addr,
- size_t count);
-static __inline void bus_space_write_region_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int16_t *addr,
- size_t count);
-static __inline void bus_space_write_region_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int32_t *addr,
- size_t count);
-
-static __inline void
-bus_space_write_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int8_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: lodsb \n\
- outb %%al,%w0 \n\
- incl %0 \n\
- loop 1b" :
- "=d" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsb" :
- "=D" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_write_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int16_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: lodsw \n\
- outw %%ax,%w0 \n\
- addl $2,%0 \n\
- loop 1b" :
- "=d" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsw" :
- "=D" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_write_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int32_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: lodsl \n\
- outl %%eax,%w0 \n\
- addl $4,%0 \n\
- loop 1b" :
- "=d" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsl" :
- "=D" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "memory", "cc");
- }
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_write_region_8 */
-#define bus_space_write_region_8 \
- !!! bus_space_write_region_8 unimplemented !!!
-#endif
-
-/*
- * Write the 1, 2, 4, or 8 byte value `val' to bus space described
- * by tag/handle/offset `count' times.
- */
-
-static __inline void bus_space_set_multi_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- u_int8_t value, size_t count);
-static __inline void bus_space_set_multi_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- u_int16_t value, size_t count);
-static __inline void bus_space_set_multi_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- u_int32_t value, size_t count);
-
-static __inline void
-bus_space_set_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- while (count--)
- outb(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- while (count--)
- *(volatile u_int8_t *)(addr) = value;
-#endif
-}
-
-static __inline void
-bus_space_set_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- while (count--)
- outw(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- while (count--)
- *(volatile u_int16_t *)(addr) = value;
-#endif
-}
-
-static __inline void
-bus_space_set_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- while (count--)
- outl(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- while (count--)
- *(volatile u_int32_t *)(addr) = value;
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_set_multi_8 */
-#define bus_space_set_multi_8 !!! bus_space_set_multi_8 unimplemented !!!
-#endif
-
-/*
- * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described
- * by tag/handle starting at `offset'.
- */
-
-static __inline void bus_space_set_region_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t value,
- size_t count);
-static __inline void bus_space_set_region_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t value,
- size_t count);
-static __inline void bus_space_set_region_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t value,
- size_t count);
-
-static __inline void
-bus_space_set_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- for (; count != 0; count--, addr++)
- outb(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- for (; count != 0; count--, addr++)
- *(volatile u_int8_t *)(addr) = value;
-#endif
-}
-
-static __inline void
-bus_space_set_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- for (; count != 0; count--, addr += 2)
- outw(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- for (; count != 0; count--, addr += 2)
- *(volatile u_int16_t *)(addr) = value;
-#endif
-}
-
-static __inline void
-bus_space_set_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- for (; count != 0; count--, addr += 4)
- outl(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- for (; count != 0; count--, addr += 4)
- *(volatile u_int32_t *)(addr) = value;
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_set_region_8 */
-#define bus_space_set_region_8 !!! bus_space_set_region_8 unimplemented !!!
-#endif
-
-/*
- * Copy `count' 1, 2, 4, or 8 byte values from bus space starting
- * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2.
- */
-
-static __inline void bus_space_copy_region_1(bus_space_tag_t tag,
- bus_space_handle_t bsh1,
- bus_size_t off1,
- bus_space_handle_t bsh2,
- bus_size_t off2, size_t count);
-
-static __inline void bus_space_copy_region_2(bus_space_tag_t tag,
- bus_space_handle_t bsh1,
- bus_size_t off1,
- bus_space_handle_t bsh2,
- bus_size_t off2, size_t count);
-
-static __inline void bus_space_copy_region_4(bus_space_tag_t tag,
- bus_space_handle_t bsh1,
- bus_size_t off1,
- bus_space_handle_t bsh2,
- bus_size_t off2, size_t count);
-
-static __inline void
-bus_space_copy_region_1(bus_space_tag_t tag, bus_space_handle_t bsh1,
- bus_size_t off1, bus_space_handle_t bsh2,
- bus_size_t off2, size_t count)
-{
- bus_addr_t addr1 = bsh1 + off1;
- bus_addr_t addr2 = bsh2 + off2;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1++, addr2++)
- outb(addr2, inb(addr1));
- } else {
- /* dest after src: copy backwards */
- for (addr1 += (count - 1), addr2 += (count - 1);
- count != 0; count--, addr1--, addr2--)
- outb(addr2, inb(addr1));
- }
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1++, addr2++)
- *(volatile u_int8_t *)(addr2) =
- *(volatile u_int8_t *)(addr1);
- } else {
- /* dest after src: copy backwards */
- for (addr1 += (count - 1), addr2 += (count - 1);
- count != 0; count--, addr1--, addr2--)
- *(volatile u_int8_t *)(addr2) =
- *(volatile u_int8_t *)(addr1);
- }
- }
-#endif
-}
-
-static __inline void
-bus_space_copy_region_2(bus_space_tag_t tag, bus_space_handle_t bsh1,
- bus_size_t off1, bus_space_handle_t bsh2,
- bus_size_t off2, size_t count)
-{
- bus_addr_t addr1 = bsh1 + off1;
- bus_addr_t addr2 = bsh2 + off2;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1 += 2, addr2 += 2)
- outw(addr2, inw(addr1));
- } else {
- /* dest after src: copy backwards */
- for (addr1 += 2 * (count - 1), addr2 += 2 * (count - 1);
- count != 0; count--, addr1 -= 2, addr2 -= 2)
- outw(addr2, inw(addr1));
- }
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1 += 2, addr2 += 2)
- *(volatile u_int16_t *)(addr2) =
- *(volatile u_int16_t *)(addr1);
- } else {
- /* dest after src: copy backwards */
- for (addr1 += 2 * (count - 1), addr2 += 2 * (count - 1);
- count != 0; count--, addr1 -= 2, addr2 -= 2)
- *(volatile u_int16_t *)(addr2) =
- *(volatile u_int16_t *)(addr1);
- }
- }
-#endif
-}
-
-static __inline void
-bus_space_copy_region_4(bus_space_tag_t tag, bus_space_handle_t bsh1,
- bus_size_t off1, bus_space_handle_t bsh2,
- bus_size_t off2, size_t count)
-{
- bus_addr_t addr1 = bsh1 + off1;
- bus_addr_t addr2 = bsh2 + off2;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1 += 4, addr2 += 4)
- outl(addr2, inl(addr1));
- } else {
- /* dest after src: copy backwards */
- for (addr1 += 4 * (count - 1), addr2 += 4 * (count - 1);
- count != 0; count--, addr1 -= 4, addr2 -= 4)
- outl(addr2, inl(addr1));
- }
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1 += 4, addr2 += 4)
- *(volatile u_int32_t *)(addr2) =
- *(volatile u_int32_t *)(addr1);
- } else {
- /* dest after src: copy backwards */
- for (addr1 += 4 * (count - 1), addr2 += 4 * (count - 1);
- count != 0; count--, addr1 -= 4, addr2 -= 4)
- *(volatile u_int32_t *)(addr2) =
- *(volatile u_int32_t *)(addr1);
- }
- }
-#endif
-}
-
-#endif /* defined(_I386_BUS_PIO_H_) || defined(_I386_MEM_IO_H_) */
-
-#if 0 /* Cause a link error for bus_space_copy_8 */
-#define bus_space_copy_region_8 !!! bus_space_copy_region_8 unimplemented !!!
-#endif
-
-/*
- * Bus read/write barrier methods.
- *
- * void bus_space_barrier(bus_space_tag_t tag, bus_space_handle_t bsh,
- * bus_size_t offset, bus_size_t len, int flags);
- *
- * Note: the i386 does not currently require barriers, but we must
- * provide the flags to MI code.
- */
-#define bus_space_barrier(t, h, o, l, f) \
- ((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f)))
-#define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */
-#define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */
-
-/*
- * Flags used in various bus DMA methods.
- */
-#define BUS_DMA_WAITOK 0x00 /* safe to sleep (pseudo-flag) */
-#define BUS_DMA_NOWAIT 0x01 /* not safe to sleep */
-#define BUS_DMA_ALLOCNOW 0x02 /* perform resource allocation now */
-#define BUS_DMAMEM_NOSYNC 0x04 /* map memory to not require sync */
-#define BUS_DMA_BUS1 0x10 /* placeholders for bus functions... */
-#define BUS_DMA_BUS2 0x20
-#define BUS_DMA_BUS3 0x40
-#define BUS_DMA_BUS4 0x80
-
-/* Forwards needed by prototypes below. */
-struct mbuf;
-struct uio;
-
-/*
- * bus_dmasync_op_t
- *
- * Operations performed by bus_dmamap_sync().
- */
-typedef enum {
- BUS_DMASYNC_PREREAD,
- BUS_DMASYNC_POSTREAD,
- BUS_DMASYNC_PREWRITE,
- BUS_DMASYNC_POSTWRITE
-} bus_dmasync_op_t;
-
-/*
- * bus_dma_tag_t
- *
- * A machine-dependent opaque type describing the characteristics
- * of how to perform DMA mappings. This structure encapsultes
- * information concerning address and alignment restrictions, number
- * of S/G segments, amount of data per S/G segment, etc.
- */
-typedef struct bus_dma_tag *bus_dma_tag_t;
-
-/*
- * bus_dmamap_t
- *
- * DMA mapping instance information.
- */
-typedef struct bus_dmamap *bus_dmamap_t;
-
-/*
- * bus_dma_segment_t
- *
- * Describes a single contiguous DMA transaction. Values
- * are suitable for programming into DMA registers.
- */
-typedef struct bus_dma_segment {
- bus_addr_t ds_addr; /* DMA address */
- bus_size_t ds_len; /* length of transfer */
-} bus_dma_segment_t;
-
-/*
- * A function that returns 1 if the address cannot be accessed by
- * a device and 0 if it can be.
- */
-typedef int bus_dma_filter_t(void *, bus_addr_t);
-
-/*
- * Allocate a device specific dma_tag encapsulating the constraints of
- * the parent tag in addition to other restrictions specified:
- *
- * alignment: alignment for segments.
- * boundary: Boundary that segments cannot cross.
- * lowaddr: Low restricted address that cannot appear in a mapping.
- * highaddr: High restricted address that cannot appear in a mapping.
- * filtfunc: An optional function to further test if an address
- * within the range of lowaddr and highaddr cannot appear
- * in a mapping.
- * filtfuncarg: An argument that will be passed to filtfunc in addition
- * to the address to test.
- * maxsize: Maximum mapping size supported by this tag.
- * nsegments: Number of discontinuities allowed in maps.
- * maxsegsz: Maximum size of a segment in the map.
- * flags: Bus DMA flags.
- * dmat: A pointer to set to a valid dma tag should the return
- * value of this function indicate success.
- */
-/* XXX Should probably allow specification of alignment */
-int bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignemnt,
- bus_size_t boundary, bus_addr_t lowaddr,
- bus_addr_t highaddr, bus_dma_filter_t *filtfunc,
- void *filtfuncarg, bus_size_t maxsize, int nsegments,
- bus_size_t maxsegsz, int flags, bus_dma_tag_t *dmat);
-
-int bus_dma_tag_destroy(bus_dma_tag_t dmat);
-
-/*
- * Allocate a handle for mapping from kva/uva/physical
- * address space into bus device space.
- */
-int bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp);
-
-/*
- * Destroy a handle for mapping from kva/uva/physical
- * address space into bus device space.
- */
-int bus_dmamap_destroy(bus_dma_tag_t dmat, bus_dmamap_t map);
-
-/*
- * Allocate a piece of memory that can be efficiently mapped into
- * bus device space based on the constraints lited in the dma tag.
- * A dmamap to for use with dmamap_load is also allocated.
- */
-int bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
- bus_dmamap_t *mapp);
-
-/*
- * Free a piece of memory and it's allociated dmamap, that was allocated
- * via bus_dmamem_alloc.
- */
-void bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map);
-
-/*
- * A function that processes a successfully loaded dma map or an error
- * from a delayed load map.
- */
-typedef void bus_dmamap_callback_t(void *, bus_dma_segment_t *, int, int);
-
-/*
- * Map the buffer buf into bus space using the dmamap map.
- */
-int bus_dmamap_load(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf,
- bus_size_t buflen, bus_dmamap_callback_t *callback,
- void *callback_arg, int flags);
-
-/*
- * Perform a syncronization operation on the given map.
- */
-void _bus_dmamap_sync(bus_dma_tag_t, bus_dmamap_t, bus_dmasync_op_t);
-#define bus_dmamap_sync(dmat, dmamap, op) \
- if ((dmamap) != NULL) \
- _bus_dmamap_sync(dmat, dmamap, op)
-
-/*
- * Release the mapping held by map.
- */
-void _bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map);
-#define bus_dmamap_unload(dmat, dmamap) \
- if ((dmamap) != NULL) \
- _bus_dmamap_unload(dmat, dmamap)
-
-#endif /* _I386_BUS_H_ */
diff --git a/sys/i386/include/bus_pc98.h b/sys/i386/include/bus_pc98.h
deleted file mode 100644
index 661761271085..000000000000
--- a/sys/i386/include/bus_pc98.h
+++ /dev/null
@@ -1,1291 +0,0 @@
-/* $NetBSD: bus.h,v 1.12 1997/10/01 08:25:15 fvdl Exp $ */
-
-/*-
- * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
- * NASA Ames Research Center.
- *
- * 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 the NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Copyright (c) 1996 Charles M. Hannum. All rights reserved.
- * Copyright (c) 1996 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
- * for the NetBSD Project.
- * 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.
- */
-/* $FreeBSD$ */
-
-#ifndef _I386_BUS_H_
-#define _I386_BUS_H_
-
-#include <machine/cpufunc.h>
-
-/*
- * To remain compatible with NetBSD's interface, default to both memio and
- * pio when neither of them is defined.
- */
-#if !defined(_I386_BUS_PIO_H_) && !defined(_I386_BUS_MEMIO_H_)
-#define _I386_BUS_PIO_H_
-#define _I386_BUS_MEMIO_H_
-#endif
-
-/*
- * Values for the i386 bus space tag, not to be used directly by MI code.
- */
-#define I386_BUS_SPACE_IO 0 /* space is i/o space */
-#define I386_BUS_SPACE_MEM 1 /* space is mem space */
-
-/*
- * Bus address and size types
- */
-typedef u_int bus_addr_t;
-typedef u_int bus_size_t;
-
-#define BUS_SPACE_MAXSIZE_24BIT 0xFFFFFF
-#define BUS_SPACE_MAXSIZE_32BIT 0xFFFFFFFF
-#define BUS_SPACE_MAXSIZE (64 * 1024) /* Maximum supported size */
-#define BUS_SPACE_MAXADDR_24BIT 0xFFFFFF
-#define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFF
-#define BUS_SPACE_MAXADDR 0xFFFFFFFF
-
-#define BUS_SPACE_UNRESTRICTED (~0)
-
-/*
- * Access methods for bus resources and address space.
- */
-typedef int bus_space_tag_t;
-typedef u_int bus_space_handle_t;
-
-/*
- * Map a region of device bus space into CPU virtual address space.
- */
-
-#define BUS_SPACE_MAP_CACHEABLE 0x01
-#define BUS_SPACE_MAP_LINEAR 0x02
-
-int bus_space_map(bus_space_tag_t t, bus_addr_t addr, bus_size_t size,
- int flags, bus_space_handle_t *bshp);
-
-/*
- * Unmap a region of device bus space.
- */
-
-void bus_space_unmap(bus_space_tag_t t, bus_space_handle_t bsh,
- bus_size_t size);
-
-/*
- * Get a new handle for a subregion of an already-mapped area of bus space.
- */
-
-int bus_space_subregion(bus_space_tag_t t, bus_space_handle_t bsh,
- bus_size_t offset, bus_size_t size,
- bus_space_handle_t *nbshp);
-
-/*
- * Allocate a region of memory that is accessible to devices in bus space.
- */
-
-int bus_space_alloc(bus_space_tag_t t, 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);
-
-/*
- * Free a region of bus space accessible memory.
- */
-
-void bus_space_free(bus_space_tag_t t, bus_space_handle_t bsh,
- bus_size_t size);
-
-#if defined(_I386_BUS_PIO_H_) || defined(_I386_BUS_MEMIO_H_)
-
-/*
- * Read a 1, 2, 4, or 8 byte quantity from bus space
- * described by tag/handle/offset.
- */
-static __inline u_int8_t bus_space_read_1(bus_space_tag_t tag,
- bus_space_handle_t handle,
- bus_size_t offset);
-
-static __inline u_int16_t bus_space_read_2(bus_space_tag_t tag,
- bus_space_handle_t handle,
- bus_size_t offset);
-
-static __inline u_int32_t bus_space_read_4(bus_space_tag_t tag,
- bus_space_handle_t handle,
- bus_size_t offset);
-
-static __inline u_int8_t
-bus_space_read_1(bus_space_tag_t tag, bus_space_handle_t handle,
- bus_size_t offset)
-{
-#if defined (_I386_BUS_PIO_H_)
-#if defined (_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- return (inb(handle + offset));
-#endif
-#if defined (_I386_BUS_MEMIO_H_)
- return (*(volatile u_int8_t *)(handle + offset));
-#endif
-}
-
-static __inline u_int16_t
-bus_space_read_2(bus_space_tag_t tag, bus_space_handle_t handle,
- bus_size_t offset)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- return (inw(handle + offset));
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
- return (*(volatile u_int16_t *)(handle + offset));
-#endif
-}
-
-static __inline u_int32_t
-bus_space_read_4(bus_space_tag_t tag, bus_space_handle_t handle,
- bus_size_t offset)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- return (inl(handle + offset));
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
- return (*(volatile u_int32_t *)(handle + offset));
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_read_8 */
-#define bus_space_read_8(t, h, o) !!! bus_space_read_8 unimplemented !!!
-#endif
-
-/*
- * Read `count' 1, 2, 4, or 8 byte quantities from bus space
- * described by tag/handle/offset and copy into buffer provided.
- */
-static __inline void bus_space_read_multi_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t *addr,
- size_t count);
-
-static __inline void bus_space_read_multi_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t *addr,
- size_t count);
-
-static __inline void bus_space_read_multi_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t *addr,
- size_t count);
-
-static __inline void
-bus_space_read_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- insb(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: movb (%2),%%al \n\
- stosb \n\
- loop 1b" :
- "=D" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory");
- }
-#endif
-}
-
-static __inline void
-bus_space_read_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- insw(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: movw (%2),%%ax \n\
- stosw \n\
- loop 1b" :
- "=D" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory");
- }
-#endif
-}
-
-static __inline void
-bus_space_read_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- insl(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: movl (%2),%%eax \n\
- stosl \n\
- loop 1b" :
- "=D" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory");
- }
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_read_multi_8 */
-#define bus_space_read_multi_8 !!! bus_space_read_multi_8 unimplemented !!!
-#endif
-
-/*
- * Read `count' 1, 2, 4, or 8 byte quantities from bus space
- * described by tag/handle and starting at `offset' and copy into
- * buffer provided.
- */
-static __inline void bus_space_read_region_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t *addr,
- size_t count);
-
-static __inline void bus_space_read_region_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t *addr,
- size_t count);
-
-static __inline void bus_space_read_region_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t *addr,
- size_t count);
-
-
-static __inline void
-bus_space_read_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: inb %w2,%%al \n\
- stosb \n\
- incl %2 \n\
- loop 1b" :
- "=D" (addr), "=c" (count), "=d" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsb" :
- "=D" (addr), "=c" (count), "=S" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_read_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: inw %w2,%%ax \n\
- stosw \n\
- addl $2,%2 \n\
- loop 1b" :
- "=D" (addr), "=c" (count), "=d" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsw" :
- "=D" (addr), "=c" (count), "=S" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_read_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: inl %w2,%%eax \n\
- stosl \n\
- addl $4,%2 \n\
- loop 1b" :
- "=D" (addr), "=c" (count), "=d" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsl" :
- "=D" (addr), "=c" (count), "=S" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "memory", "cc");
- }
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_read_region_8 */
-#define bus_space_read_region_8 !!! bus_space_read_region_8 unimplemented !!!
-#endif
-
-/*
- * Write the 1, 2, 4, or 8 byte value `value' to bus space
- * described by tag/handle/offset.
- */
-
-static __inline void bus_space_write_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t value);
-
-static __inline void bus_space_write_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t value);
-
-static __inline void bus_space_write_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t value);
-
-static __inline void
-bus_space_write_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t value)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outb(bsh + offset, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- *(volatile u_int8_t *)(bsh + offset) = value;
-#endif
-}
-
-static __inline void
-bus_space_write_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t value)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outw(bsh + offset, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- *(volatile u_int16_t *)(bsh + offset) = value;
-#endif
-}
-
-static __inline void
-bus_space_write_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t value)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outl(bsh + offset, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- *(volatile u_int32_t *)(bsh + offset) = value;
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_write_8 */
-#define bus_space_write_8 !!! bus_space_write_8 not implemented !!!
-#endif
-
-/*
- * Write `count' 1, 2, 4, or 8 byte quantities from the buffer
- * provided to bus space described by tag/handle/offset.
- */
-
-static __inline void bus_space_write_multi_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int8_t *addr,
- size_t count);
-static __inline void bus_space_write_multi_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int16_t *addr,
- size_t count);
-
-static __inline void bus_space_write_multi_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int32_t *addr,
- size_t count);
-
-static __inline void
-bus_space_write_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int8_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outsb(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: lodsb \n\
- movb %%al,(%2) \n\
- loop 1b" :
- "=S" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_write_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int16_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outsw(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: lodsw \n\
- movw %%ax,(%1) \n\
- movw %%ax,(%2) \n\
- loop 1b" :
- "=S" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_write_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int32_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outsl(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: lodsl \n\
- movl %%eax,(%2) \n\
- loop 1b" :
- "=S" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_write_multi_8 */
-#define bus_space_write_multi_8(t, h, o, a, c) \
- !!! bus_space_write_multi_8 unimplemented !!!
-#endif
-
-/*
- * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided
- * to bus space described by tag/handle starting at `offset'.
- */
-
-static __inline void bus_space_write_region_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int8_t *addr,
- size_t count);
-static __inline void bus_space_write_region_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int16_t *addr,
- size_t count);
-static __inline void bus_space_write_region_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int32_t *addr,
- size_t count);
-
-static __inline void
-bus_space_write_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int8_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: lodsb \n\
- outb %%al,%w0 \n\
- incl %0 \n\
- loop 1b" :
- "=d" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsb" :
- "=D" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_write_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int16_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: lodsw \n\
- outw %%ax,%w0 \n\
- addl $2,%0 \n\
- loop 1b" :
- "=d" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsw" :
- "=D" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_write_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int32_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: lodsl \n\
- outl %%eax,%w0 \n\
- addl $4,%0 \n\
- loop 1b" :
- "=d" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsl" :
- "=D" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "memory", "cc");
- }
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_write_region_8 */
-#define bus_space_write_region_8 \
- !!! bus_space_write_region_8 unimplemented !!!
-#endif
-
-/*
- * Write the 1, 2, 4, or 8 byte value `val' to bus space described
- * by tag/handle/offset `count' times.
- */
-
-static __inline void bus_space_set_multi_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- u_int8_t value, size_t count);
-static __inline void bus_space_set_multi_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- u_int16_t value, size_t count);
-static __inline void bus_space_set_multi_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- u_int32_t value, size_t count);
-
-static __inline void
-bus_space_set_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- while (count--)
- outb(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- while (count--)
- *(volatile u_int8_t *)(addr) = value;
-#endif
-}
-
-static __inline void
-bus_space_set_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- while (count--)
- outw(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- while (count--)
- *(volatile u_int16_t *)(addr) = value;
-#endif
-}
-
-static __inline void
-bus_space_set_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- while (count--)
- outl(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- while (count--)
- *(volatile u_int32_t *)(addr) = value;
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_set_multi_8 */
-#define bus_space_set_multi_8 !!! bus_space_set_multi_8 unimplemented !!!
-#endif
-
-/*
- * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described
- * by tag/handle starting at `offset'.
- */
-
-static __inline void bus_space_set_region_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t value,
- size_t count);
-static __inline void bus_space_set_region_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t value,
- size_t count);
-static __inline void bus_space_set_region_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t value,
- size_t count);
-
-static __inline void
-bus_space_set_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- for (; count != 0; count--, addr++)
- outb(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- for (; count != 0; count--, addr++)
- *(volatile u_int8_t *)(addr) = value;
-#endif
-}
-
-static __inline void
-bus_space_set_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- for (; count != 0; count--, addr += 2)
- outw(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- for (; count != 0; count--, addr += 2)
- *(volatile u_int16_t *)(addr) = value;
-#endif
-}
-
-static __inline void
-bus_space_set_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- for (; count != 0; count--, addr += 4)
- outl(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- for (; count != 0; count--, addr += 4)
- *(volatile u_int32_t *)(addr) = value;
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_set_region_8 */
-#define bus_space_set_region_8 !!! bus_space_set_region_8 unimplemented !!!
-#endif
-
-/*
- * Copy `count' 1, 2, 4, or 8 byte values from bus space starting
- * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2.
- */
-
-static __inline void bus_space_copy_region_1(bus_space_tag_t tag,
- bus_space_handle_t bsh1,
- bus_size_t off1,
- bus_space_handle_t bsh2,
- bus_size_t off2, size_t count);
-
-static __inline void bus_space_copy_region_2(bus_space_tag_t tag,
- bus_space_handle_t bsh1,
- bus_size_t off1,
- bus_space_handle_t bsh2,
- bus_size_t off2, size_t count);
-
-static __inline void bus_space_copy_region_4(bus_space_tag_t tag,
- bus_space_handle_t bsh1,
- bus_size_t off1,
- bus_space_handle_t bsh2,
- bus_size_t off2, size_t count);
-
-static __inline void
-bus_space_copy_region_1(bus_space_tag_t tag, bus_space_handle_t bsh1,
- bus_size_t off1, bus_space_handle_t bsh2,
- bus_size_t off2, size_t count)
-{
- bus_addr_t addr1 = bsh1 + off1;
- bus_addr_t addr2 = bsh2 + off2;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1++, addr2++)
- outb(addr2, inb(addr1));
- } else {
- /* dest after src: copy backwards */
- for (addr1 += (count - 1), addr2 += (count - 1);
- count != 0; count--, addr1--, addr2--)
- outb(addr2, inb(addr1));
- }
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1++, addr2++)
- *(volatile u_int8_t *)(addr2) =
- *(volatile u_int8_t *)(addr1);
- } else {
- /* dest after src: copy backwards */
- for (addr1 += (count - 1), addr2 += (count - 1);
- count != 0; count--, addr1--, addr2--)
- *(volatile u_int8_t *)(addr2) =
- *(volatile u_int8_t *)(addr1);
- }
- }
-#endif
-}
-
-static __inline void
-bus_space_copy_region_2(bus_space_tag_t tag, bus_space_handle_t bsh1,
- bus_size_t off1, bus_space_handle_t bsh2,
- bus_size_t off2, size_t count)
-{
- bus_addr_t addr1 = bsh1 + off1;
- bus_addr_t addr2 = bsh2 + off2;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1 += 2, addr2 += 2)
- outw(addr2, inw(addr1));
- } else {
- /* dest after src: copy backwards */
- for (addr1 += 2 * (count - 1), addr2 += 2 * (count - 1);
- count != 0; count--, addr1 -= 2, addr2 -= 2)
- outw(addr2, inw(addr1));
- }
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1 += 2, addr2 += 2)
- *(volatile u_int16_t *)(addr2) =
- *(volatile u_int16_t *)(addr1);
- } else {
- /* dest after src: copy backwards */
- for (addr1 += 2 * (count - 1), addr2 += 2 * (count - 1);
- count != 0; count--, addr1 -= 2, addr2 -= 2)
- *(volatile u_int16_t *)(addr2) =
- *(volatile u_int16_t *)(addr1);
- }
- }
-#endif
-}
-
-static __inline void
-bus_space_copy_region_4(bus_space_tag_t tag, bus_space_handle_t bsh1,
- bus_size_t off1, bus_space_handle_t bsh2,
- bus_size_t off2, size_t count)
-{
- bus_addr_t addr1 = bsh1 + off1;
- bus_addr_t addr2 = bsh2 + off2;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1 += 4, addr2 += 4)
- outl(addr2, inl(addr1));
- } else {
- /* dest after src: copy backwards */
- for (addr1 += 4 * (count - 1), addr2 += 4 * (count - 1);
- count != 0; count--, addr1 -= 4, addr2 -= 4)
- outl(addr2, inl(addr1));
- }
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1 += 4, addr2 += 4)
- *(volatile u_int32_t *)(addr2) =
- *(volatile u_int32_t *)(addr1);
- } else {
- /* dest after src: copy backwards */
- for (addr1 += 4 * (count - 1), addr2 += 4 * (count - 1);
- count != 0; count--, addr1 -= 4, addr2 -= 4)
- *(volatile u_int32_t *)(addr2) =
- *(volatile u_int32_t *)(addr1);
- }
- }
-#endif
-}
-
-#endif /* defined(_I386_BUS_PIO_H_) || defined(_I386_MEM_IO_H_) */
-
-#if 0 /* Cause a link error for bus_space_copy_8 */
-#define bus_space_copy_region_8 !!! bus_space_copy_region_8 unimplemented !!!
-#endif
-
-/*
- * Bus read/write barrier methods.
- *
- * void bus_space_barrier(bus_space_tag_t tag, bus_space_handle_t bsh,
- * bus_size_t offset, bus_size_t len, int flags);
- *
- * Note: the i386 does not currently require barriers, but we must
- * provide the flags to MI code.
- */
-#define bus_space_barrier(t, h, o, l, f) \
- ((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f)))
-#define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */
-#define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */
-
-/*
- * Flags used in various bus DMA methods.
- */
-#define BUS_DMA_WAITOK 0x00 /* safe to sleep (pseudo-flag) */
-#define BUS_DMA_NOWAIT 0x01 /* not safe to sleep */
-#define BUS_DMA_ALLOCNOW 0x02 /* perform resource allocation now */
-#define BUS_DMAMEM_NOSYNC 0x04 /* map memory to not require sync */
-#define BUS_DMA_BUS1 0x10 /* placeholders for bus functions... */
-#define BUS_DMA_BUS2 0x20
-#define BUS_DMA_BUS3 0x40
-#define BUS_DMA_BUS4 0x80
-
-/* Forwards needed by prototypes below. */
-struct mbuf;
-struct uio;
-
-/*
- * bus_dmasync_op_t
- *
- * Operations performed by bus_dmamap_sync().
- */
-typedef enum {
- BUS_DMASYNC_PREREAD,
- BUS_DMASYNC_POSTREAD,
- BUS_DMASYNC_PREWRITE,
- BUS_DMASYNC_POSTWRITE
-} bus_dmasync_op_t;
-
-/*
- * bus_dma_tag_t
- *
- * A machine-dependent opaque type describing the characteristics
- * of how to perform DMA mappings. This structure encapsultes
- * information concerning address and alignment restrictions, number
- * of S/G segments, amount of data per S/G segment, etc.
- */
-typedef struct bus_dma_tag *bus_dma_tag_t;
-
-/*
- * bus_dmamap_t
- *
- * DMA mapping instance information.
- */
-typedef struct bus_dmamap *bus_dmamap_t;
-
-/*
- * bus_dma_segment_t
- *
- * Describes a single contiguous DMA transaction. Values
- * are suitable for programming into DMA registers.
- */
-typedef struct bus_dma_segment {
- bus_addr_t ds_addr; /* DMA address */
- bus_size_t ds_len; /* length of transfer */
-} bus_dma_segment_t;
-
-/*
- * A function that returns 1 if the address cannot be accessed by
- * a device and 0 if it can be.
- */
-typedef int bus_dma_filter_t(void *, bus_addr_t);
-
-/*
- * Allocate a device specific dma_tag encapsulating the constraints of
- * the parent tag in addition to other restrictions specified:
- *
- * alignment: alignment for segments.
- * boundary: Boundary that segments cannot cross.
- * lowaddr: Low restricted address that cannot appear in a mapping.
- * highaddr: High restricted address that cannot appear in a mapping.
- * filtfunc: An optional function to further test if an address
- * within the range of lowaddr and highaddr cannot appear
- * in a mapping.
- * filtfuncarg: An argument that will be passed to filtfunc in addition
- * to the address to test.
- * maxsize: Maximum mapping size supported by this tag.
- * nsegments: Number of discontinuities allowed in maps.
- * maxsegsz: Maximum size of a segment in the map.
- * flags: Bus DMA flags.
- * dmat: A pointer to set to a valid dma tag should the return
- * value of this function indicate success.
- */
-/* XXX Should probably allow specification of alignment */
-int bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignemnt,
- bus_size_t boundary, bus_addr_t lowaddr,
- bus_addr_t highaddr, bus_dma_filter_t *filtfunc,
- void *filtfuncarg, bus_size_t maxsize, int nsegments,
- bus_size_t maxsegsz, int flags, bus_dma_tag_t *dmat);
-
-int bus_dma_tag_destroy(bus_dma_tag_t dmat);
-
-/*
- * Allocate a handle for mapping from kva/uva/physical
- * address space into bus device space.
- */
-int bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp);
-
-/*
- * Destroy a handle for mapping from kva/uva/physical
- * address space into bus device space.
- */
-int bus_dmamap_destroy(bus_dma_tag_t dmat, bus_dmamap_t map);
-
-/*
- * Allocate a piece of memory that can be efficiently mapped into
- * bus device space based on the constraints lited in the dma tag.
- * A dmamap to for use with dmamap_load is also allocated.
- */
-int bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
- bus_dmamap_t *mapp);
-
-/*
- * Free a piece of memory and it's allociated dmamap, that was allocated
- * via bus_dmamem_alloc.
- */
-void bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map);
-
-/*
- * A function that processes a successfully loaded dma map or an error
- * from a delayed load map.
- */
-typedef void bus_dmamap_callback_t(void *, bus_dma_segment_t *, int, int);
-
-/*
- * Map the buffer buf into bus space using the dmamap map.
- */
-int bus_dmamap_load(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf,
- bus_size_t buflen, bus_dmamap_callback_t *callback,
- void *callback_arg, int flags);
-
-/*
- * Perform a syncronization operation on the given map.
- */
-void _bus_dmamap_sync(bus_dma_tag_t, bus_dmamap_t, bus_dmasync_op_t);
-#define bus_dmamap_sync(dmat, dmamap, op) \
- if ((dmamap) != NULL) \
- _bus_dmamap_sync(dmat, dmamap, op)
-
-/*
- * Release the mapping held by map.
- */
-void _bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map);
-#define bus_dmamap_unload(dmat, dmamap) \
- if ((dmamap) != NULL) \
- _bus_dmamap_unload(dmat, dmamap)
-
-#endif /* _I386_BUS_H_ */
diff --git a/sys/i386/include/mptable.h b/sys/i386/include/mptable.h
deleted file mode 100644
index 8e349a9800e4..000000000000
--- a/sys/i386/include/mptable.h
+++ /dev/null
@@ -1,2739 +0,0 @@
-/*
- * Copyright (c) 1996, by Steve Passe
- * 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 developer 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include "opt_smp.h"
-#include "opt_cpu.h"
-#include "opt_user_ldt.h"
-
-#ifdef SMP
-#include <machine/smptests.h>
-#else
-#error
-#endif
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/proc.h>
-#include <sys/sysctl.h>
-#include <sys/malloc.h>
-#include <sys/memrange.h>
-#ifdef BETTER_CLOCK
-#include <sys/dkstat.h>
-#endif
-#include <sys/cons.h> /* cngetc() */
-
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <vm/pmap.h>
-#include <vm/vm_kern.h>
-#include <vm/vm_extern.h>
-#ifdef BETTER_CLOCK
-#include <sys/lock.h>
-#include <vm/vm_map.h>
-#include <sys/user.h>
-#ifdef GPROF
-#include <sys/gmon.h>
-#endif
-#endif
-
-#include <machine/smp.h>
-#include <machine/apic.h>
-#include <machine/atomic.h>
-#include <machine/cpufunc.h>
-#include <machine/mpapic.h>
-#include <machine/psl.h>
-#include <machine/segments.h>
-#include <machine/smptests.h> /** TEST_DEFAULT_CONFIG, TEST_TEST1 */
-#include <machine/tss.h>
-#include <machine/specialreg.h>
-#include <machine/globaldata.h>
-
-#if defined(APIC_IO)
-#include <machine/md_var.h> /* setidt() */
-#include <i386/isa/icu.h> /* IPIs */
-#include <i386/isa/intr_machdep.h> /* IPIs */
-#endif /* APIC_IO */
-
-#if defined(TEST_DEFAULT_CONFIG)
-#define MPFPS_MPFB1 TEST_DEFAULT_CONFIG
-#else
-#define MPFPS_MPFB1 mpfps->mpfb1
-#endif /* TEST_DEFAULT_CONFIG */
-
-#define WARMBOOT_TARGET 0
-#define WARMBOOT_OFF (KERNBASE + 0x0467)
-#define WARMBOOT_SEG (KERNBASE + 0x0469)
-
-#ifdef PC98
-#define BIOS_BASE (0xe8000)
-#define BIOS_SIZE (0x18000)
-#else
-#define BIOS_BASE (0xf0000)
-#define BIOS_SIZE (0x10000)
-#endif
-#define BIOS_COUNT (BIOS_SIZE/4)
-
-#define CMOS_REG (0x70)
-#define CMOS_DATA (0x71)
-#define BIOS_RESET (0x0f)
-#define BIOS_WARM (0x0a)
-
-#define PROCENTRY_FLAG_EN 0x01
-#define PROCENTRY_FLAG_BP 0x02
-#define IOAPICENTRY_FLAG_EN 0x01
-
-
-/* MP Floating Pointer Structure */
-typedef struct MPFPS {
- char signature[4];
- void *pap;
- u_char length;
- u_char spec_rev;
- u_char checksum;
- u_char mpfb1;
- u_char mpfb2;
- u_char mpfb3;
- u_char mpfb4;
- u_char mpfb5;
-} *mpfps_t;
-
-/* MP Configuration Table Header */
-typedef struct MPCTH {
- char signature[4];
- u_short base_table_length;
- u_char spec_rev;
- u_char checksum;
- u_char oem_id[8];
- u_char product_id[12];
- void *oem_table_pointer;
- u_short oem_table_size;
- u_short entry_count;
- void *apic_address;
- u_short extended_table_length;
- u_char extended_table_checksum;
- u_char reserved;
-} *mpcth_t;
-
-
-typedef struct PROCENTRY {
- u_char type;
- u_char apic_id;
- u_char apic_version;
- u_char cpu_flags;
- u_long cpu_signature;
- u_long feature_flags;
- u_long reserved1;
- u_long reserved2;
-} *proc_entry_ptr;
-
-typedef struct BUSENTRY {
- u_char type;
- u_char bus_id;
- char bus_type[6];
-} *bus_entry_ptr;
-
-typedef struct IOAPICENTRY {
- u_char type;
- u_char apic_id;
- u_char apic_version;
- u_char apic_flags;
- void *apic_address;
-} *io_apic_entry_ptr;
-
-typedef struct INTENTRY {
- u_char type;
- u_char int_type;
- u_short int_flags;
- u_char src_bus_id;
- u_char src_bus_irq;
- u_char dst_apic_id;
- u_char dst_apic_int;
-} *int_entry_ptr;
-
-/* descriptions of MP basetable entries */
-typedef struct BASETABLE_ENTRY {
- u_char type;
- u_char length;
- char name[16];
-} basetable_entry;
-
-/*
- * this code MUST be enabled here and in mpboot.s.
- * it follows the very early stages of AP boot by placing values in CMOS ram.
- * it NORMALLY will never be needed and thus the primitive method for enabling.
- *
-#define CHECK_POINTS
- */
-
-#if defined(CHECK_POINTS) && !defined(PC98)
-#define CHECK_READ(A) (outb(CMOS_REG, (A)), inb(CMOS_DATA))
-#define CHECK_WRITE(A,D) (outb(CMOS_REG, (A)), outb(CMOS_DATA, (D)))
-
-#define CHECK_INIT(D); \
- CHECK_WRITE(0x34, (D)); \
- CHECK_WRITE(0x35, (D)); \
- CHECK_WRITE(0x36, (D)); \
- CHECK_WRITE(0x37, (D)); \
- CHECK_WRITE(0x38, (D)); \
- CHECK_WRITE(0x39, (D));
-
-#define CHECK_PRINT(S); \
- printf("%s: %d, %d, %d, %d, %d, %d\n", \
- (S), \
- CHECK_READ(0x34), \
- CHECK_READ(0x35), \
- CHECK_READ(0x36), \
- CHECK_READ(0x37), \
- CHECK_READ(0x38), \
- CHECK_READ(0x39));
-
-#else /* CHECK_POINTS */
-
-#define CHECK_INIT(D)
-#define CHECK_PRINT(S)
-
-#endif /* CHECK_POINTS */
-
-/*
- * Values to send to the POST hardware.
- */
-#define MP_BOOTADDRESS_POST 0x10
-#define MP_PROBE_POST 0x11
-#define MPTABLE_PASS1_POST 0x12
-
-#define MP_START_POST 0x13
-#define MP_ENABLE_POST 0x14
-#define MPTABLE_PASS2_POST 0x15
-
-#define START_ALL_APS_POST 0x16
-#define INSTALL_AP_TRAMP_POST 0x17
-#define START_AP_POST 0x18
-
-#define MP_ANNOUNCE_POST 0x19
-
-
-/** XXX FIXME: where does this really belong, isa.h/isa.c perhaps? */
-int current_postcode;
-
-/** XXX FIXME: what system files declare these??? */
-extern struct region_descriptor r_gdt, r_idt;
-
-int bsp_apic_ready = 0; /* flags useability of BSP apic */
-int mp_ncpus; /* # of CPUs, including BSP */
-int mp_naps; /* # of Applications processors */
-int mp_nbusses; /* # of busses */
-int mp_napics; /* # of IO APICs */
-int boot_cpu_id; /* designated BSP */
-vm_offset_t cpu_apic_address;
-vm_offset_t io_apic_address[NAPICID]; /* NAPICID is more than enough */
-extern int nkpt;
-
-u_int32_t cpu_apic_versions[NCPU];
-u_int32_t io_apic_versions[NAPIC];
-
-#ifdef APIC_INTR_DIAGNOSTIC
-int apic_itrace_enter[32];
-int apic_itrace_tryisrlock[32];
-int apic_itrace_gotisrlock[32];
-int apic_itrace_active[32];
-int apic_itrace_masked[32];
-int apic_itrace_noisrlock[32];
-int apic_itrace_masked2[32];
-int apic_itrace_unmask[32];
-int apic_itrace_noforward[32];
-int apic_itrace_leave[32];
-int apic_itrace_enter2[32];
-int apic_itrace_doreti[32];
-int apic_itrace_splz[32];
-int apic_itrace_eoi[32];
-#ifdef APIC_INTR_DIAGNOSTIC_IRQ
-unsigned short apic_itrace_debugbuffer[32768];
-int apic_itrace_debugbuffer_idx;
-struct simplelock apic_itrace_debuglock;
-#endif
-#endif
-
-#ifdef APIC_INTR_REORDER
-struct {
- volatile int *location;
- int bit;
-} apic_isrbit_location[32];
-#endif
-
-struct apic_intmapinfo int_to_apicintpin[APIC_INTMAPSIZE];
-
-/*
- * APIC ID logical/physical mapping structures.
- * We oversize these to simplify boot-time config.
- */
-int cpu_num_to_apic_id[NAPICID];
-int io_num_to_apic_id[NAPICID];
-int apic_id_to_logical[NAPICID];
-
-
-/* Bitmap of all available CPUs */
-u_int all_cpus;
-
-/* AP uses this during bootstrap. Do not staticize. */
-char *bootSTK;
-static int bootAP;
-
-/* Hotwire a 0->4MB V==P mapping */
-extern pt_entry_t *KPTphys;
-
-/* SMP page table page */
-extern pt_entry_t *SMPpt;
-
-struct pcb stoppcbs[NCPU];
-
-int smp_started; /* has the system started? */
-
-/*
- * Local data and functions.
- */
-
-static int mp_capable;
-static u_int boot_address;
-static u_int base_memory;
-
-static int picmode; /* 0: virtual wire mode, 1: PIC mode */
-static mpfps_t mpfps;
-static int search_for_sig(u_int32_t target, int count);
-static void mp_enable(u_int boot_addr);
-
-static int mptable_pass1(void);
-static int mptable_pass2(void);
-static void default_mp_table(int type);
-static void fix_mp_table(void);
-static void setup_apic_irq_mapping(void);
-static void init_locks(void);
-static int start_all_aps(u_int boot_addr);
-static void install_ap_tramp(u_int boot_addr);
-static int start_ap(int logicalCpu, u_int boot_addr);
-static int apic_int_is_bus_type(int intr, int bus_type);
-
-/*
- * Calculate usable address in base memory for AP trampoline code.
- */
-u_int
-mp_bootaddress(u_int basemem)
-{
- POSTCODE(MP_BOOTADDRESS_POST);
-
- base_memory = basemem * 1024; /* convert to bytes */
-
- boot_address = base_memory & ~0xfff; /* round down to 4k boundary */
- if ((base_memory - boot_address) < bootMP_size)
- boot_address -= 4096; /* not enough, lower by 4k */
-
- return boot_address;
-}
-
-
-/*
- * Look for an Intel MP spec table (ie, SMP capable hardware).
- */
-int
-mp_probe(void)
-{
- int x;
- u_long segment;
- u_int32_t target;
-
- POSTCODE(MP_PROBE_POST);
-
- /* see if EBDA exists */
- if ((segment = (u_long) * (u_short *) (KERNBASE + 0x40e)) != 0) {
- /* search first 1K of EBDA */
- target = (u_int32_t) (segment << 4);
- if ((x = search_for_sig(target, 1024 / 4)) >= 0)
- goto found;
- } else {
- /* last 1K of base memory, effective 'top of base' passed in */
- target = (u_int32_t) (base_memory - 0x400);
- if ((x = search_for_sig(target, 1024 / 4)) >= 0)
- goto found;
- }
-
- /* search the BIOS */
- target = (u_int32_t) BIOS_BASE;
- if ((x = search_for_sig(target, BIOS_COUNT)) >= 0)
- goto found;
-
- /* nothing found */
- mpfps = (mpfps_t)0;
- mp_capable = 0;
- return 0;
-
-found:
- /* calculate needed resources */
- mpfps = (mpfps_t)x;
- if (mptable_pass1())
- panic("you must reconfigure your kernel");
-
- /* flag fact that we are running multiple processors */
- mp_capable = 1;
- return 1;
-}
-
-
-/*
- * Startup the SMP processors.
- */
-void
-mp_start(void)
-{
- POSTCODE(MP_START_POST);
-
- /* look for MP capable motherboard */
- if (mp_capable)
- mp_enable(boot_address);
- else
- panic("MP hardware not found!");
-}
-
-
-/*
- * Print various information about the SMP system hardware and setup.
- */
-void
-mp_announce(void)
-{
- int x;
-
- POSTCODE(MP_ANNOUNCE_POST);
-
- printf("FreeBSD/SMP: Multiprocessor motherboard\n");
- printf(" cpu0 (BSP): apic id: %2d", CPU_TO_ID(0));
- printf(", version: 0x%08x", cpu_apic_versions[0]);
- printf(", at 0x%08x\n", cpu_apic_address);
- for (x = 1; x <= mp_naps; ++x) {
- printf(" cpu%d (AP): apic id: %2d", x, CPU_TO_ID(x));
- printf(", version: 0x%08x", cpu_apic_versions[x]);
- printf(", at 0x%08x\n", cpu_apic_address);
- }
-
-#if defined(APIC_IO)
- for (x = 0; x < mp_napics; ++x) {
- printf(" io%d (APIC): apic id: %2d", x, IO_TO_ID(x));
- printf(", version: 0x%08x", io_apic_versions[x]);
- printf(", at 0x%08x\n", io_apic_address[x]);
- }
-#else
- printf(" Warning: APIC I/O disabled\n");
-#endif /* APIC_IO */
-}
-
-/*
- * AP cpu's call this to sync up protected mode.
- */
-void
-init_secondary(void)
-{
- int gsel_tss;
- int x, myid = bootAP;
-
- gdt_segs[GPRIV_SEL].ssd_base = (int) &SMP_prvspace[myid];
- gdt_segs[GPROC0_SEL].ssd_base =
- (int) &SMP_prvspace[myid].globaldata.gd_common_tss;
- SMP_prvspace[myid].globaldata.gd_prvspace = &SMP_prvspace[myid];
-
- for (x = 0; x < NGDT; x++) {
- ssdtosd(&gdt_segs[x], &gdt[myid * NGDT + x].sd);
- }
-
- r_gdt.rd_limit = NGDT * sizeof(gdt[0]) - 1;
- r_gdt.rd_base = (int) &gdt[myid * NGDT];
- lgdt(&r_gdt); /* does magic intra-segment return */
-
- lidt(&r_idt);
-
- lldt(_default_ldt);
-#ifdef USER_LDT
- currentldt = _default_ldt;
-#endif
-
- gsel_tss = GSEL(GPROC0_SEL, SEL_KPL);
- gdt[myid * NGDT + GPROC0_SEL].sd.sd_type = SDT_SYS386TSS;
- common_tss.tss_esp0 = 0; /* not used until after switch */
- common_tss.tss_ss0 = GSEL(GDATA_SEL, SEL_KPL);
- common_tss.tss_ioopt = (sizeof common_tss) << 16;
- tss_gdt = &gdt[myid * NGDT + GPROC0_SEL].sd;
- common_tssd = *tss_gdt;
- ltr(gsel_tss);
-
- load_cr0(0x8005003b); /* XXX! */
-
- pmap_set_opt();
-}
-
-
-#if defined(APIC_IO)
-/*
- * Final configuration of the BSP's local APIC:
- * - disable 'pic mode'.
- * - disable 'virtual wire mode'.
- * - enable NMI.
- */
-void
-bsp_apic_configure(void)
-{
- u_char byte;
- u_int32_t temp;
-
- /* leave 'pic mode' if necessary */
- if (picmode) {
- outb(0x22, 0x70); /* select IMCR */
- byte = inb(0x23); /* current contents */
- byte |= 0x01; /* mask external INTR */
- outb(0x23, byte); /* disconnect 8259s/NMI */
- }
-
- /* mask lint0 (the 8259 'virtual wire' connection) */
- temp = lapic.lvt_lint0;
- temp |= APIC_LVT_M; /* set the mask */
- lapic.lvt_lint0 = temp;
-
- /* setup lint1 to handle NMI */
- temp = lapic.lvt_lint1;
- temp &= ~APIC_LVT_M; /* clear the mask */
- lapic.lvt_lint1 = temp;
-
- if (bootverbose)
- apic_dump("bsp_apic_configure()");
-}
-#endif /* APIC_IO */
-
-
-/*******************************************************************
- * local functions and data
- */
-
-/*
- * start the SMP system
- */
-static void
-mp_enable(u_int boot_addr)
-{
- int x;
-#if defined(APIC_IO)
- int apic;
- u_int ux;
-#endif /* APIC_IO */
-
- POSTCODE(MP_ENABLE_POST);
-
- /* turn on 4MB of V == P addressing so we can get to MP table */
- *(int *)PTD = PG_V | PG_RW | ((uintptr_t)(void *)KPTphys & PG_FRAME);
- invltlb();
-
- /* examine the MP table for needed info, uses physical addresses */
- x = mptable_pass2();
-
- *(int *)PTD = 0;
- invltlb();
-
- /* can't process default configs till the CPU APIC is pmapped */
- if (x)
- default_mp_table(x);
-
- /* post scan cleanup */
- fix_mp_table();
- setup_apic_irq_mapping();
-
-#if defined(APIC_IO)
-
- /* fill the LOGICAL io_apic_versions table */
- for (apic = 0; apic < mp_napics; ++apic) {
- ux = io_apic_read(apic, IOAPIC_VER);
- io_apic_versions[apic] = ux;
- }
-
- /* program each IO APIC in the system */
- for (apic = 0; apic < mp_napics; ++apic)
- if (io_apic_setup(apic) < 0)
- panic("IO APIC setup failure");
-
- /* install a 'Spurious INTerrupt' vector */
- setidt(XSPURIOUSINT_OFFSET, Xspuriousint,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-
- /* install an inter-CPU IPI for TLB invalidation */
- setidt(XINVLTLB_OFFSET, Xinvltlb,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-
-#ifdef BETTER_CLOCK
- /* install an inter-CPU IPI for reading processor state */
- setidt(XCPUCHECKSTATE_OFFSET, Xcpucheckstate,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-#endif
-
- /* install an inter-CPU IPI for all-CPU rendezvous */
- setidt(XRENDEZVOUS_OFFSET, Xrendezvous,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-
- /* install an inter-CPU IPI for forcing an additional software trap */
- setidt(XCPUAST_OFFSET, Xcpuast,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-
- /* install an inter-CPU IPI for interrupt forwarding */
- setidt(XFORWARD_IRQ_OFFSET, Xforward_irq,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-
- /* install an inter-CPU IPI for CPU stop/restart */
- setidt(XCPUSTOP_OFFSET, Xcpustop,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-
-#if defined(TEST_TEST1)
- /* install a "fake hardware INTerrupt" vector */
- setidt(XTEST1_OFFSET, Xtest1,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-#endif /** TEST_TEST1 */
-
-#endif /* APIC_IO */
-
- /* initialize all SMP locks */
- init_locks();
-
- /* start each Application Processor */
- start_all_aps(boot_addr);
-
- /*
- * The init process might be started on a different CPU now,
- * and the boot CPU might not call prepare_usermode to get
- * cr0 correctly configured. Thus we initialize cr0 here.
- */
- load_cr0(rcr0() | CR0_WP | CR0_AM);
-}
-
-
-/*
- * look for the MP spec signature
- */
-
-/* string defined by the Intel MP Spec as identifying the MP table */
-#define MP_SIG 0x5f504d5f /* _MP_ */
-#define NEXT(X) ((X) += 4)
-static int
-search_for_sig(u_int32_t target, int count)
-{
- int x;
- u_int32_t *addr = (u_int32_t *) (KERNBASE + target);
-
- for (x = 0; x < count; NEXT(x))
- if (addr[x] == MP_SIG)
- /* make array index a byte index */
- return (target + (x * sizeof(u_int32_t)));
-
- return -1;
-}
-
-
-static basetable_entry basetable_entry_types[] =
-{
- {0, 20, "Processor"},
- {1, 8, "Bus"},
- {2, 8, "I/O APIC"},
- {3, 8, "I/O INT"},
- {4, 8, "Local INT"}
-};
-
-typedef struct BUSDATA {
- u_char bus_id;
- enum busTypes bus_type;
-} bus_datum;
-
-typedef struct INTDATA {
- u_char int_type;
- u_short int_flags;
- u_char src_bus_id;
- u_char src_bus_irq;
- u_char dst_apic_id;
- u_char dst_apic_int;
- u_char int_vector;
-} io_int, local_int;
-
-typedef struct BUSTYPENAME {
- u_char type;
- char name[7];
-} bus_type_name;
-
-static bus_type_name bus_type_table[] =
-{
- {CBUS, "CBUS"},
- {CBUSII, "CBUSII"},
- {EISA, "EISA"},
- {MCA, "MCA"},
- {UNKNOWN_BUSTYPE, "---"},
- {ISA, "ISA"},
- {MCA, "MCA"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {PCI, "PCI"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {XPRESS, "XPRESS"},
- {UNKNOWN_BUSTYPE, "---"}
-};
-/* from MP spec v1.4, table 5-1 */
-static int default_data[7][5] =
-{
-/* nbus, id0, type0, id1, type1 */
- {1, 0, ISA, 255, 255},
- {1, 0, EISA, 255, 255},
- {1, 0, EISA, 255, 255},
- {1, 0, MCA, 255, 255},
- {2, 0, ISA, 1, PCI},
- {2, 0, EISA, 1, PCI},
- {2, 0, MCA, 1, PCI}
-};
-
-
-/* the bus data */
-static bus_datum bus_data[NBUS];
-
-/* the IO INT data, one entry per possible APIC INTerrupt */
-static io_int io_apic_ints[NINTR];
-
-static int nintrs;
-
-static int processor_entry __P((proc_entry_ptr entry, int cpu));
-static int bus_entry __P((bus_entry_ptr entry, int bus));
-static int io_apic_entry __P((io_apic_entry_ptr entry, int apic));
-static int int_entry __P((int_entry_ptr entry, int intr));
-static int lookup_bus_type __P((char *name));
-
-
-/*
- * 1st pass on motherboard's Intel MP specification table.
- *
- * initializes:
- * mp_ncpus = 1
- *
- * determines:
- * cpu_apic_address (common to all CPUs)
- * io_apic_address[N]
- * mp_naps
- * mp_nbusses
- * mp_napics
- * nintrs
- */
-static int
-mptable_pass1(void)
-{
- int x;
- mpcth_t cth;
- int totalSize;
- void* position;
- int count;
- int type;
- int mustpanic;
-
- POSTCODE(MPTABLE_PASS1_POST);
-
- mustpanic = 0;
-
- /* clear various tables */
- for (x = 0; x < NAPICID; ++x) {
- io_apic_address[x] = ~0; /* IO APIC address table */
- }
-
- /* init everything to empty */
- mp_naps = 0;
- mp_nbusses = 0;
- mp_napics = 0;
- nintrs = 0;
-
- /* check for use of 'default' configuration */
- if (MPFPS_MPFB1 != 0) {
- /* use default addresses */
- cpu_apic_address = DEFAULT_APIC_BASE;
- io_apic_address[0] = DEFAULT_IO_APIC_BASE;
-
- /* fill in with defaults */
- mp_naps = 2; /* includes BSP */
- mp_nbusses = default_data[MPFPS_MPFB1 - 1][0];
-#if defined(APIC_IO)
- mp_napics = 1;
- nintrs = 16;
-#endif /* APIC_IO */
- }
- else {
- if ((cth = mpfps->pap) == 0)
- panic("MP Configuration Table Header MISSING!");
-
- cpu_apic_address = (vm_offset_t) cth->apic_address;
-
- /* walk the table, recording info of interest */
- totalSize = cth->base_table_length - sizeof(struct MPCTH);
- position = (u_char *) cth + sizeof(struct MPCTH);
- count = cth->entry_count;
-
- while (count--) {
- switch (type = *(u_char *) position) {
- case 0: /* processor_entry */
- if (((proc_entry_ptr)position)->cpu_flags
- & PROCENTRY_FLAG_EN)
- ++mp_naps;
- break;
- case 1: /* bus_entry */
- ++mp_nbusses;
- break;
- case 2: /* io_apic_entry */
- if (((io_apic_entry_ptr)position)->apic_flags
- & IOAPICENTRY_FLAG_EN)
- io_apic_address[mp_napics++] =
- (vm_offset_t)((io_apic_entry_ptr)
- position)->apic_address;
- break;
- case 3: /* int_entry */
- ++nintrs;
- break;
- case 4: /* int_entry */
- break;
- default:
- panic("mpfps Base Table HOSED!");
- /* NOTREACHED */
- }
-
- totalSize -= basetable_entry_types[type].length;
- (u_char*)position += basetable_entry_types[type].length;
- }
- }
-
- /* qualify the numbers */
- if (mp_naps > NCPU) {
- printf("Warning: only using %d of %d available CPUs!\n",
- NCPU, mp_naps);
- mp_naps = NCPU;
- }
- if (mp_nbusses > NBUS) {
- printf("found %d busses, increase NBUS\n", mp_nbusses);
- mustpanic = 1;
- }
- if (mp_napics > NAPIC) {
- printf("found %d apics, increase NAPIC\n", mp_napics);
- mustpanic = 1;
- }
- if (nintrs > NINTR) {
- printf("found %d intrs, increase NINTR\n", nintrs);
- mustpanic = 1;
- }
-
- /*
- * Count the BSP.
- * This is also used as a counter while starting the APs.
- */
- mp_ncpus = 1;
-
- --mp_naps; /* subtract the BSP */
-
- return mustpanic;
-}
-
-
-/*
- * 2nd pass on motherboard's Intel MP specification table.
- *
- * sets:
- * boot_cpu_id
- * ID_TO_IO(N), phy APIC ID to log CPU/IO table
- * CPU_TO_ID(N), logical CPU to APIC ID table
- * IO_TO_ID(N), logical IO to APIC ID table
- * bus_data[N]
- * io_apic_ints[N]
- */
-static int
-mptable_pass2(void)
-{
- int x;
- mpcth_t cth;
- int totalSize;
- void* position;
- int count;
- int type;
- int apic, bus, cpu, intr;
-
- POSTCODE(MPTABLE_PASS2_POST);
-
- /* clear various tables */
- for (x = 0; x < NAPICID; ++x) {
- ID_TO_IO(x) = -1; /* phy APIC ID to log CPU/IO table */
- CPU_TO_ID(x) = -1; /* logical CPU to APIC ID table */
- IO_TO_ID(x) = -1; /* logical IO to APIC ID table */
- }
-
- /* clear bus data table */
- for (x = 0; x < NBUS; ++x)
- bus_data[x].bus_id = 0xff;
-
- /* clear IO APIC INT table */
- for (x = 0; x < NINTR; ++x) {
- io_apic_ints[x].int_type = 0xff;
- io_apic_ints[x].int_vector = 0xff;
- }
-
- /* setup the cpu/apic mapping arrays */
- boot_cpu_id = -1;
-
- /* record whether PIC or virtual-wire mode */
- picmode = (mpfps->mpfb2 & 0x80) ? 1 : 0;
-
- /* check for use of 'default' configuration */
- if (MPFPS_MPFB1 != 0)
- return MPFPS_MPFB1; /* return default configuration type */
-
- if ((cth = mpfps->pap) == 0)
- panic("MP Configuration Table Header MISSING!");
-
- /* walk the table, recording info of interest */
- totalSize = cth->base_table_length - sizeof(struct MPCTH);
- position = (u_char *) cth + sizeof(struct MPCTH);
- count = cth->entry_count;
- apic = bus = intr = 0;
- cpu = 1; /* pre-count the BSP */
-
- while (count--) {
- switch (type = *(u_char *) position) {
- case 0:
- if (processor_entry(position, cpu))
- ++cpu;
- break;
- case 1:
- if (bus_entry(position, bus))
- ++bus;
- break;
- case 2:
- if (io_apic_entry(position, apic))
- ++apic;
- break;
- case 3:
- if (int_entry(position, intr))
- ++intr;
- break;
- case 4:
- /* int_entry(position); */
- break;
- default:
- panic("mpfps Base Table HOSED!");
- /* NOTREACHED */
- }
-
- totalSize -= basetable_entry_types[type].length;
- (u_char *) position += basetable_entry_types[type].length;
- }
-
- if (boot_cpu_id == -1)
- panic("NO BSP found!");
-
- /* report fact that its NOT a default configuration */
- return 0;
-}
-
-
-void
-assign_apic_irq(int apic, int intpin, int irq)
-{
- int x;
-
- if (int_to_apicintpin[irq].ioapic != -1)
- panic("assign_apic_irq: inconsistent table");
-
- int_to_apicintpin[irq].ioapic = apic;
- int_to_apicintpin[irq].int_pin = intpin;
- int_to_apicintpin[irq].apic_address = ioapic[apic];
- int_to_apicintpin[irq].redirindex = IOAPIC_REDTBL + 2 * intpin;
-
- for (x = 0; x < nintrs; x++) {
- if ((io_apic_ints[x].int_type == 0 ||
- io_apic_ints[x].int_type == 3) &&
- io_apic_ints[x].int_vector == 0xff &&
- io_apic_ints[x].dst_apic_id == IO_TO_ID(apic) &&
- io_apic_ints[x].dst_apic_int == intpin)
- io_apic_ints[x].int_vector = irq;
- }
-}
-
-void
-revoke_apic_irq(int irq)
-{
- int x;
- int oldapic;
- int oldintpin;
-
- if (int_to_apicintpin[irq].ioapic == -1)
- panic("assign_apic_irq: inconsistent table");
-
- oldapic = int_to_apicintpin[irq].ioapic;
- oldintpin = int_to_apicintpin[irq].int_pin;
-
- int_to_apicintpin[irq].ioapic = -1;
- int_to_apicintpin[irq].int_pin = 0;
- int_to_apicintpin[irq].apic_address = NULL;
- int_to_apicintpin[irq].redirindex = 0;
-
- for (x = 0; x < nintrs; x++) {
- if ((io_apic_ints[x].int_type == 0 ||
- io_apic_ints[x].int_type == 3) &&
- io_apic_ints[x].int_vector == 0xff &&
- io_apic_ints[x].dst_apic_id == IO_TO_ID(oldapic) &&
- io_apic_ints[x].dst_apic_int == oldintpin)
- io_apic_ints[x].int_vector = 0xff;
- }
-}
-
-/*
- * parse an Intel MP specification table
- */
-static void
-fix_mp_table(void)
-{
- int x;
- int id;
- int bus_0 = 0; /* Stop GCC warning */
- int bus_pci = 0; /* Stop GCC warning */
- int num_pci_bus;
-
- /*
- * Fix mis-numbering of the PCI bus and its INT entries if the BIOS
- * did it wrong. The MP spec says that when more than 1 PCI bus
- * exists the BIOS must begin with bus entries for the PCI bus and use
- * actual PCI bus numbering. This implies that when only 1 PCI bus
- * exists the BIOS can choose to ignore this ordering, and indeed many
- * MP motherboards do ignore it. This causes a problem when the PCI
- * sub-system makes requests of the MP sub-system based on PCI bus
- * numbers. So here we look for the situation and renumber the
- * busses and associated INTs in an effort to "make it right".
- */
-
- /* find bus 0, PCI bus, count the number of PCI busses */
- for (num_pci_bus = 0, x = 0; x < mp_nbusses; ++x) {
- if (bus_data[x].bus_id == 0) {
- bus_0 = x;
- }
- if (bus_data[x].bus_type == PCI) {
- ++num_pci_bus;
- bus_pci = x;
- }
- }
- /*
- * bus_0 == slot of bus with ID of 0
- * bus_pci == slot of last PCI bus encountered
- */
-
- /* check the 1 PCI bus case for sanity */
- if (num_pci_bus == 1) {
-
- /* if it is number 0 all is well */
- if (bus_data[bus_pci].bus_id == 0)
- return;
-
- /* mis-numbered, swap with whichever bus uses slot 0 */
-
- /* swap the bus entry types */
- bus_data[bus_pci].bus_type = bus_data[bus_0].bus_type;
- bus_data[bus_0].bus_type = PCI;
-
- /* swap each relavant INTerrupt entry */
- id = bus_data[bus_pci].bus_id;
- for (x = 0; x < nintrs; ++x) {
- if (io_apic_ints[x].src_bus_id == id) {
- io_apic_ints[x].src_bus_id = 0;
- }
- else if (io_apic_ints[x].src_bus_id == 0) {
- io_apic_ints[x].src_bus_id = id;
- }
- }
- }
-}
-
-
-/* Assign low level interrupt handlers */
-static void
-setup_apic_irq_mapping(void)
-{
- int x;
- int int_vector;
-
- /* Clear array */
- for (x = 0; x < APIC_INTMAPSIZE; x++) {
- int_to_apicintpin[x].ioapic = -1;
- int_to_apicintpin[x].int_pin = 0;
- int_to_apicintpin[x].apic_address = NULL;
- int_to_apicintpin[x].redirindex = 0;
- }
-
- /* First assign ISA/EISA interrupts */
- for (x = 0; x < nintrs; x++) {
- int_vector = io_apic_ints[x].src_bus_irq;
- if (int_vector < APIC_INTMAPSIZE &&
- io_apic_ints[x].int_vector == 0xff &&
- int_to_apicintpin[int_vector].ioapic == -1 &&
- (apic_int_is_bus_type(x, ISA) ||
- apic_int_is_bus_type(x, EISA)) &&
- io_apic_ints[x].int_type == 0) {
- assign_apic_irq(ID_TO_IO(io_apic_ints[x].dst_apic_id),
- io_apic_ints[x].dst_apic_int,
- int_vector);
- }
- }
-
- /* Assign interrupts on first 24 intpins on IOAPIC #0 */
- for (x = 0; x < nintrs; x++) {
- int_vector = io_apic_ints[x].dst_apic_int;
- if (int_vector < APIC_INTMAPSIZE &&
- io_apic_ints[x].dst_apic_id == IO_TO_ID(0) &&
- io_apic_ints[x].int_vector == 0xff &&
- int_to_apicintpin[int_vector].ioapic == -1 &&
- (io_apic_ints[x].int_type == 0 ||
- io_apic_ints[x].int_type == 3)) {
- assign_apic_irq(0,
- io_apic_ints[x].dst_apic_int,
- int_vector);
- }
- }
- /*
- * Assign interrupts for remaining intpins.
- * Skip IOAPIC #0 intpin 0 if the type is ExtInt, since this indicates
- * that an entry for ISA/EISA irq 0 exist, and a fallback to mixed mode
- * due to 8254 interrupts not being delivered can reuse that low level
- * interrupt handler.
- */
- int_vector = 0;
- while (int_vector < APIC_INTMAPSIZE &&
- int_to_apicintpin[int_vector].ioapic != -1)
- int_vector++;
- for (x = 0; x < nintrs && int_vector < APIC_INTMAPSIZE; x++) {
- if ((io_apic_ints[x].int_type == 0 ||
- (io_apic_ints[x].int_type == 3 &&
- (io_apic_ints[x].dst_apic_id != IO_TO_ID(0) ||
- io_apic_ints[x].dst_apic_int != 0))) &&
- io_apic_ints[x].int_vector == 0xff) {
- assign_apic_irq(ID_TO_IO(io_apic_ints[x].dst_apic_id),
- io_apic_ints[x].dst_apic_int,
- int_vector);
- int_vector++;
- while (int_vector < APIC_INTMAPSIZE &&
- int_to_apicintpin[int_vector].ioapic != -1)
- int_vector++;
- }
- }
-}
-
-
-static int
-processor_entry(proc_entry_ptr entry, int cpu)
-{
- /* check for usability */
- if (!(entry->cpu_flags & PROCENTRY_FLAG_EN))
- return 0;
-
- /* check for BSP flag */
- if (entry->cpu_flags & PROCENTRY_FLAG_BP) {
- boot_cpu_id = entry->apic_id;
- CPU_TO_ID(0) = entry->apic_id;
- ID_TO_CPU(entry->apic_id) = 0;
- return 0; /* its already been counted */
- }
-
- /* add another AP to list, if less than max number of CPUs */
- else if (cpu < NCPU) {
- CPU_TO_ID(cpu) = entry->apic_id;
- ID_TO_CPU(entry->apic_id) = cpu;
- return 1;
- }
-
- return 0;
-}
-
-
-static int
-bus_entry(bus_entry_ptr entry, int bus)
-{
- int x;
- char c, name[8];
-
- /* encode the name into an index */
- for (x = 0; x < 6; ++x) {
- if ((c = entry->bus_type[x]) == ' ')
- break;
- name[x] = c;
- }
- name[x] = '\0';
-
- if ((x = lookup_bus_type(name)) == UNKNOWN_BUSTYPE)
- panic("unknown bus type: '%s'", name);
-
- bus_data[bus].bus_id = entry->bus_id;
- bus_data[bus].bus_type = x;
-
- return 1;
-}
-
-
-static int
-io_apic_entry(io_apic_entry_ptr entry, int apic)
-{
- if (!(entry->apic_flags & IOAPICENTRY_FLAG_EN))
- return 0;
-
- IO_TO_ID(apic) = entry->apic_id;
- ID_TO_IO(entry->apic_id) = apic;
-
- return 1;
-}
-
-
-static int
-lookup_bus_type(char *name)
-{
- int x;
-
- for (x = 0; x < MAX_BUSTYPE; ++x)
- if (strcmp(bus_type_table[x].name, name) == 0)
- return bus_type_table[x].type;
-
- return UNKNOWN_BUSTYPE;
-}
-
-
-static int
-int_entry(int_entry_ptr entry, int intr)
-{
- int apic;
-
- io_apic_ints[intr].int_type = entry->int_type;
- io_apic_ints[intr].int_flags = entry->int_flags;
- io_apic_ints[intr].src_bus_id = entry->src_bus_id;
- io_apic_ints[intr].src_bus_irq = entry->src_bus_irq;
- if (entry->dst_apic_id == 255) {
- /* This signal goes to all IO APICS. Select an IO APIC
- with sufficient number of interrupt pins */
- for (apic = 0; apic < mp_napics; apic++)
- if (((io_apic_read(apic, IOAPIC_VER) &
- IOART_VER_MAXREDIR) >> MAXREDIRSHIFT) >=
- entry->dst_apic_int)
- break;
- if (apic < mp_napics)
- io_apic_ints[intr].dst_apic_id = IO_TO_ID(apic);
- else
- io_apic_ints[intr].dst_apic_id = entry->dst_apic_id;
- } else
- io_apic_ints[intr].dst_apic_id = entry->dst_apic_id;
- io_apic_ints[intr].dst_apic_int = entry->dst_apic_int;
-
- return 1;
-}
-
-
-static int
-apic_int_is_bus_type(int intr, int bus_type)
-{
- int bus;
-
- for (bus = 0; bus < mp_nbusses; ++bus)
- if ((bus_data[bus].bus_id == io_apic_ints[intr].src_bus_id)
- && ((int) bus_data[bus].bus_type == bus_type))
- return 1;
-
- return 0;
-}
-
-
-/*
- * Given a traditional ISA INT mask, return an APIC mask.
- */
-u_int
-isa_apic_mask(u_int isa_mask)
-{
- int isa_irq;
- int apic_pin;
-
-#if defined(SKIP_IRQ15_REDIRECT)
- if (isa_mask == (1 << 15)) {
- printf("skipping ISA IRQ15 redirect\n");
- return isa_mask;
- }
-#endif /* SKIP_IRQ15_REDIRECT */
-
- isa_irq = ffs(isa_mask); /* find its bit position */
- if (isa_irq == 0) /* doesn't exist */
- return 0;
- --isa_irq; /* make it zero based */
-
- apic_pin = isa_apic_irq(isa_irq); /* look for APIC connection */
- if (apic_pin == -1)
- return 0;
-
- return (1 << apic_pin); /* convert pin# to a mask */
-}
-
-
-/*
- * Determine which APIC pin an ISA/EISA INT is attached to.
- */
-#define INTTYPE(I) (io_apic_ints[(I)].int_type)
-#define INTPIN(I) (io_apic_ints[(I)].dst_apic_int)
-#define INTIRQ(I) (io_apic_ints[(I)].int_vector)
-#define INTAPIC(I) (ID_TO_IO(io_apic_ints[(I)].dst_apic_id))
-
-#define SRCBUSIRQ(I) (io_apic_ints[(I)].src_bus_irq)
-int
-isa_apic_irq(int isa_irq)
-{
- int intr;
-
- for (intr = 0; intr < nintrs; ++intr) { /* check each record */
- if (INTTYPE(intr) == 0) { /* standard INT */
- if (SRCBUSIRQ(intr) == isa_irq) {
- if (apic_int_is_bus_type(intr, ISA) ||
- apic_int_is_bus_type(intr, EISA))
- return INTIRQ(intr); /* found */
- }
- }
- }
- return -1; /* NOT found */
-}
-
-
-/*
- * Determine which APIC pin a PCI INT is attached to.
- */
-#define SRCBUSID(I) (io_apic_ints[(I)].src_bus_id)
-#define SRCBUSDEVICE(I) ((io_apic_ints[(I)].src_bus_irq >> 2) & 0x1f)
-#define SRCBUSLINE(I) (io_apic_ints[(I)].src_bus_irq & 0x03)
-int
-pci_apic_irq(int pciBus, int pciDevice, int pciInt)
-{
- int intr;
-
- --pciInt; /* zero based */
-
- for (intr = 0; intr < nintrs; ++intr) /* check each record */
- if ((INTTYPE(intr) == 0) /* standard INT */
- && (SRCBUSID(intr) == pciBus)
- && (SRCBUSDEVICE(intr) == pciDevice)
- && (SRCBUSLINE(intr) == pciInt)) /* a candidate IRQ */
- if (apic_int_is_bus_type(intr, PCI))
- return INTIRQ(intr); /* exact match */
-
- return -1; /* NOT found */
-}
-
-int
-next_apic_irq(int irq)
-{
- int intr, ointr;
- int bus, bustype;
-
- bus = 0;
- bustype = 0;
- for (intr = 0; intr < nintrs; intr++) {
- if (INTIRQ(intr) != irq || INTTYPE(intr) != 0)
- continue;
- bus = SRCBUSID(intr);
- bustype = apic_bus_type(bus);
- if (bustype != ISA &&
- bustype != EISA &&
- bustype != PCI)
- continue;
- break;
- }
- if (intr >= nintrs) {
- return -1;
- }
- for (ointr = intr + 1; ointr < nintrs; ointr++) {
- if (INTTYPE(ointr) != 0)
- continue;
- if (bus != SRCBUSID(ointr))
- continue;
- if (bustype == PCI) {
- if (SRCBUSDEVICE(intr) != SRCBUSDEVICE(ointr))
- continue;
- if (SRCBUSLINE(intr) != SRCBUSLINE(ointr))
- continue;
- }
- if (bustype == ISA || bustype == EISA) {
- if (SRCBUSIRQ(intr) != SRCBUSIRQ(ointr))
- continue;
- }
- if (INTPIN(intr) == INTPIN(ointr))
- continue;
- break;
- }
- if (ointr >= nintrs) {
- return -1;
- }
- return INTIRQ(ointr);
-}
-#undef SRCBUSLINE
-#undef SRCBUSDEVICE
-#undef SRCBUSID
-#undef SRCBUSIRQ
-
-#undef INTPIN
-#undef INTIRQ
-#undef INTAPIC
-#undef INTTYPE
-
-
-/*
- * Reprogram the MB chipset to NOT redirect an ISA INTerrupt.
- *
- * XXX FIXME:
- * Exactly what this means is unclear at this point. It is a solution
- * for motherboards that redirect the MBIRQ0 pin. Generically a motherboard
- * could route any of the ISA INTs to upper (>15) IRQ values. But most would
- * NOT be redirected via MBIRQ0, thus "undirect()ing" them would NOT be an
- * option.
- */
-int
-undirect_isa_irq(int rirq)
-{
-#if defined(READY)
- if (bootverbose)
- printf("Freeing redirected ISA irq %d.\n", rirq);
- /** FIXME: tickle the MB redirector chip */
- return ???;
-#else
- if (bootverbose)
- printf("Freeing (NOT implemented) redirected ISA irq %d.\n", rirq);
- return 0;
-#endif /* READY */
-}
-
-
-/*
- * Reprogram the MB chipset to NOT redirect a PCI INTerrupt
- */
-int
-undirect_pci_irq(int rirq)
-{
-#if defined(READY)
- if (bootverbose)
- printf("Freeing redirected PCI irq %d.\n", rirq);
-
- /** FIXME: tickle the MB redirector chip */
- return ???;
-#else
- if (bootverbose)
- printf("Freeing (NOT implemented) redirected PCI irq %d.\n",
- rirq);
- return 0;
-#endif /* READY */
-}
-
-
-/*
- * given a bus ID, return:
- * the bus type if found
- * -1 if NOT found
- */
-int
-apic_bus_type(int id)
-{
- int x;
-
- for (x = 0; x < mp_nbusses; ++x)
- if (bus_data[x].bus_id == id)
- return bus_data[x].bus_type;
-
- return -1;
-}
-
-
-/*
- * given a LOGICAL APIC# and pin#, return:
- * the associated src bus ID if found
- * -1 if NOT found
- */
-int
-apic_src_bus_id(int apic, int pin)
-{
- int x;
-
- /* search each of the possible INTerrupt sources */
- for (x = 0; x < nintrs; ++x)
- if ((apic == ID_TO_IO(io_apic_ints[x].dst_apic_id)) &&
- (pin == io_apic_ints[x].dst_apic_int))
- return (io_apic_ints[x].src_bus_id);
-
- return -1; /* NOT found */
-}
-
-
-/*
- * given a LOGICAL APIC# and pin#, return:
- * the associated src bus IRQ if found
- * -1 if NOT found
- */
-int
-apic_src_bus_irq(int apic, int pin)
-{
- int x;
-
- for (x = 0; x < nintrs; x++)
- if ((apic == ID_TO_IO(io_apic_ints[x].dst_apic_id)) &&
- (pin == io_apic_ints[x].dst_apic_int))
- return (io_apic_ints[x].src_bus_irq);
-
- return -1; /* NOT found */
-}
-
-
-/*
- * given a LOGICAL APIC# and pin#, return:
- * the associated INTerrupt type if found
- * -1 if NOT found
- */
-int
-apic_int_type(int apic, int pin)
-{
- int x;
-
- /* search each of the possible INTerrupt sources */
- for (x = 0; x < nintrs; ++x)
- if ((apic == ID_TO_IO(io_apic_ints[x].dst_apic_id)) &&
- (pin == io_apic_ints[x].dst_apic_int))
- return (io_apic_ints[x].int_type);
-
- return -1; /* NOT found */
-}
-
-int
-apic_irq(int apic, int pin)
-{
- int x;
- int res;
-
- for (x = 0; x < nintrs; ++x)
- if ((apic == ID_TO_IO(io_apic_ints[x].dst_apic_id)) &&
- (pin == io_apic_ints[x].dst_apic_int)) {
- res = io_apic_ints[x].int_vector;
- if (res == 0xff)
- return -1;
- if (apic != int_to_apicintpin[res].ioapic)
- panic("apic_irq: inconsistent table");
- if (pin != int_to_apicintpin[res].int_pin)
- panic("apic_irq inconsistent table (2)");
- return res;
- }
- return -1;
-}
-
-
-/*
- * given a LOGICAL APIC# and pin#, return:
- * the associated trigger mode if found
- * -1 if NOT found
- */
-int
-apic_trigger(int apic, int pin)
-{
- int x;
-
- /* search each of the possible INTerrupt sources */
- for (x = 0; x < nintrs; ++x)
- if ((apic == ID_TO_IO(io_apic_ints[x].dst_apic_id)) &&
- (pin == io_apic_ints[x].dst_apic_int))
- return ((io_apic_ints[x].int_flags >> 2) & 0x03);
-
- return -1; /* NOT found */
-}
-
-
-/*
- * given a LOGICAL APIC# and pin#, return:
- * the associated 'active' level if found
- * -1 if NOT found
- */
-int
-apic_polarity(int apic, int pin)
-{
- int x;
-
- /* search each of the possible INTerrupt sources */
- for (x = 0; x < nintrs; ++x)
- if ((apic == ID_TO_IO(io_apic_ints[x].dst_apic_id)) &&
- (pin == io_apic_ints[x].dst_apic_int))
- return (io_apic_ints[x].int_flags & 0x03);
-
- return -1; /* NOT found */
-}
-
-
-/*
- * set data according to MP defaults
- * FIXME: probably not complete yet...
- */
-static void
-default_mp_table(int type)
-{
- int ap_cpu_id;
-#if defined(APIC_IO)
- u_int32_t ux;
- int io_apic_id;
- int pin;
-#endif /* APIC_IO */
-
-#if 0
- printf(" MP default config type: %d\n", type);
- switch (type) {
- case 1:
- printf(" bus: ISA, APIC: 82489DX\n");
- break;
- case 2:
- printf(" bus: EISA, APIC: 82489DX\n");
- break;
- case 3:
- printf(" bus: EISA, APIC: 82489DX\n");
- break;
- case 4:
- printf(" bus: MCA, APIC: 82489DX\n");
- break;
- case 5:
- printf(" bus: ISA+PCI, APIC: Integrated\n");
- break;
- case 6:
- printf(" bus: EISA+PCI, APIC: Integrated\n");
- break;
- case 7:
- printf(" bus: MCA+PCI, APIC: Integrated\n");
- break;
- default:
- printf(" future type\n");
- break;
- /* NOTREACHED */
- }
-#endif /* 0 */
-
- boot_cpu_id = (lapic.id & APIC_ID_MASK) >> 24;
- ap_cpu_id = (boot_cpu_id == 0) ? 1 : 0;
-
- /* BSP */
- CPU_TO_ID(0) = boot_cpu_id;
- ID_TO_CPU(boot_cpu_id) = 0;
-
- /* one and only AP */
- CPU_TO_ID(1) = ap_cpu_id;
- ID_TO_CPU(ap_cpu_id) = 1;
-
-#if defined(APIC_IO)
- /* one and only IO APIC */
- io_apic_id = (io_apic_read(0, IOAPIC_ID) & APIC_ID_MASK) >> 24;
-
- /*
- * sanity check, refer to MP spec section 3.6.6, last paragraph
- * necessary as some hardware isn't properly setting up the IO APIC
- */
-#if defined(REALLY_ANAL_IOAPICID_VALUE)
- if (io_apic_id != 2) {
-#else
- if ((io_apic_id == 0) || (io_apic_id == 1) || (io_apic_id == 15)) {
-#endif /* REALLY_ANAL_IOAPICID_VALUE */
- ux = io_apic_read(0, IOAPIC_ID); /* get current contents */
- ux &= ~APIC_ID_MASK; /* clear the ID field */
- ux |= 0x02000000; /* set it to '2' */
- io_apic_write(0, IOAPIC_ID, ux); /* write new value */
- ux = io_apic_read(0, IOAPIC_ID); /* re-read && test */
- if ((ux & APIC_ID_MASK) != 0x02000000)
- panic("can't control IO APIC ID, reg: 0x%08x", ux);
- io_apic_id = 2;
- }
- IO_TO_ID(0) = io_apic_id;
- ID_TO_IO(io_apic_id) = 0;
-#endif /* APIC_IO */
-
- /* fill out bus entries */
- switch (type) {
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- bus_data[0].bus_id = default_data[type - 1][1];
- bus_data[0].bus_type = default_data[type - 1][2];
- bus_data[1].bus_id = default_data[type - 1][3];
- bus_data[1].bus_type = default_data[type - 1][4];
- break;
-
- /* case 4: case 7: MCA NOT supported */
- default: /* illegal/reserved */
- panic("BAD default MP config: %d", type);
- /* NOTREACHED */
- }
-
-#if defined(APIC_IO)
- /* general cases from MP v1.4, table 5-2 */
- for (pin = 0; pin < 16; ++pin) {
- io_apic_ints[pin].int_type = 0;
- io_apic_ints[pin].int_flags = 0x05; /* edge/active-hi */
- io_apic_ints[pin].src_bus_id = 0;
- io_apic_ints[pin].src_bus_irq = pin; /* IRQ2 caught below */
- io_apic_ints[pin].dst_apic_id = io_apic_id;
- io_apic_ints[pin].dst_apic_int = pin; /* 1-to-1 */
- }
-
- /* special cases from MP v1.4, table 5-2 */
- if (type == 2) {
- io_apic_ints[2].int_type = 0xff; /* N/C */
- io_apic_ints[13].int_type = 0xff; /* N/C */
-#if !defined(APIC_MIXED_MODE)
- /** FIXME: ??? */
- panic("sorry, can't support type 2 default yet");
-#endif /* APIC_MIXED_MODE */
- }
- else
- io_apic_ints[2].src_bus_irq = 0; /* ISA IRQ0 is on APIC INT 2 */
-
- if (type == 7)
- io_apic_ints[0].int_type = 0xff; /* N/C */
- else
- io_apic_ints[0].int_type = 3; /* vectored 8259 */
-#endif /* APIC_IO */
-}
-
-
-/*
- * initialize all the SMP locks
- */
-
-/* critical region around IO APIC, apic_imen */
-struct simplelock imen_lock;
-
-/* critical region around splxx(), cpl, cml, cil, ipending */
-struct simplelock cpl_lock;
-
-/* Make FAST_INTR() routines sequential */
-struct simplelock fast_intr_lock;
-
-/* critical region around INTR() routines */
-struct simplelock intr_lock;
-
-/* lock regions protected in UP kernel via cli/sti */
-struct simplelock mpintr_lock;
-
-/* lock region used by kernel profiling */
-struct simplelock mcount_lock;
-
-#ifdef USE_COMLOCK
-/* locks com (tty) data/hardware accesses: a FASTINTR() */
-struct simplelock com_lock;
-#endif /* USE_COMLOCK */
-
-#ifdef USE_CLOCKLOCK
-/* lock regions around the clock hardware */
-struct simplelock clock_lock;
-#endif /* USE_CLOCKLOCK */
-
-/* lock around the MP rendezvous */
-static struct simplelock smp_rv_lock;
-
-static void
-init_locks(void)
-{
- /*
- * Get the initial mp_lock with a count of 1 for the BSP.
- * This uses a LOGICAL cpu ID, ie BSP == 0.
- */
- mp_lock = 0x00000001;
-
- /* ISR uses its own "giant lock" */
- isr_lock = FREE_LOCK;
-
-#if defined(APIC_INTR_DIAGNOSTIC) && defined(APIC_INTR_DIAGNOSTIC_IRQ)
- s_lock_init((struct simplelock*)&apic_itrace_debuglock);
-#endif
-
- s_lock_init((struct simplelock*)&mpintr_lock);
-
- s_lock_init((struct simplelock*)&mcount_lock);
-
- s_lock_init((struct simplelock*)&fast_intr_lock);
- s_lock_init((struct simplelock*)&intr_lock);
- s_lock_init((struct simplelock*)&imen_lock);
- s_lock_init((struct simplelock*)&cpl_lock);
- s_lock_init(&smp_rv_lock);
-
-#ifdef USE_COMLOCK
- s_lock_init((struct simplelock*)&com_lock);
-#endif /* USE_COMLOCK */
-#ifdef USE_CLOCKLOCK
- s_lock_init((struct simplelock*)&clock_lock);
-#endif /* USE_CLOCKLOCK */
-}
-
-
-/* Wait for all APs to be fully initialized */
-extern int wait_ap(unsigned int);
-
-/*
- * start each AP in our list
- */
-static int
-start_all_aps(u_int boot_addr)
-{
- int x, i, pg;
- u_char mpbiosreason;
- u_long mpbioswarmvec;
- struct globaldata *gd;
- char *stack;
-
- POSTCODE(START_ALL_APS_POST);
-
- /* initialize BSP's local APIC */
- apic_initialize();
- bsp_apic_ready = 1;
-
- /* install the AP 1st level boot code */
- install_ap_tramp(boot_addr);
-
-
- /* save the current value of the warm-start vector */
- mpbioswarmvec = *((u_long *) WARMBOOT_OFF);
-#ifndef PC98
- outb(CMOS_REG, BIOS_RESET);
- mpbiosreason = inb(CMOS_DATA);
-#endif
-
- /* record BSP in CPU map */
- all_cpus = 1;
-
- /* set up 0 -> 4MB P==V mapping for AP boot */
- *(int *)PTD = PG_V | PG_RW | ((uintptr_t)(void *)KPTphys & PG_FRAME);
- invltlb();
-
- /* start each AP */
- for (x = 1; x <= mp_naps; ++x) {
-
- /* This is a bit verbose, it will go away soon. */
-
- /* first page of AP's private space */
- pg = x * i386_btop(sizeof(struct privatespace));
-
- /* allocate a new private data page */
- gd = (struct globaldata *)kmem_alloc(kernel_map, PAGE_SIZE);
-
- /* wire it into the private page table page */
- SMPpt[pg] = (pt_entry_t)(PG_V | PG_RW | vtophys(gd));
-
- /* allocate and set up an idle stack data page */
- stack = (char *)kmem_alloc(kernel_map, UPAGES*PAGE_SIZE);
- for (i = 0; i < UPAGES; i++)
- SMPpt[pg + 5 + i] = (pt_entry_t)
- (PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack));
-
- SMPpt[pg + 1] = 0; /* *prv_CMAP1 */
- SMPpt[pg + 2] = 0; /* *prv_CMAP2 */
- SMPpt[pg + 3] = 0; /* *prv_CMAP3 */
- SMPpt[pg + 4] = 0; /* *prv_PMAP1 */
-
- /* prime data page for it to use */
- gd->gd_cpuid = x;
- gd->gd_cpu_lockid = x << 24;
- gd->gd_prv_CMAP1 = &SMPpt[pg + 1];
- gd->gd_prv_CMAP2 = &SMPpt[pg + 2];
- gd->gd_prv_CMAP3 = &SMPpt[pg + 3];
- gd->gd_prv_PMAP1 = &SMPpt[pg + 4];
- gd->gd_prv_CADDR1 = SMP_prvspace[x].CPAGE1;
- gd->gd_prv_CADDR2 = SMP_prvspace[x].CPAGE2;
- gd->gd_prv_CADDR3 = SMP_prvspace[x].CPAGE3;
- gd->gd_prv_PADDR1 = (unsigned *)SMP_prvspace[x].PPAGE1;
-
- /* setup a vector to our boot code */
- *((volatile u_short *) WARMBOOT_OFF) = WARMBOOT_TARGET;
- *((volatile u_short *) WARMBOOT_SEG) = (boot_addr >> 4);
-#ifndef PC98
- outb(CMOS_REG, BIOS_RESET);
- outb(CMOS_DATA, BIOS_WARM); /* 'warm-start' */
-#endif
-
- bootSTK = &SMP_prvspace[x].idlestack[UPAGES*PAGE_SIZE];
- bootAP = x;
-
- /* attempt to start the Application Processor */
- CHECK_INIT(99); /* setup checkpoints */
- if (!start_ap(x, boot_addr)) {
- printf("AP #%d (PHY# %d) failed!\n", x, CPU_TO_ID(x));
- CHECK_PRINT("trace"); /* show checkpoints */
- /* better panic as the AP may be running loose */
- printf("panic y/n? [y] ");
- if (cngetc() != 'n')
- panic("bye-bye");
- }
- CHECK_PRINT("trace"); /* show checkpoints */
-
- /* record its version info */
- cpu_apic_versions[x] = cpu_apic_versions[0];
-
- all_cpus |= (1 << x); /* record AP in CPU map */
- }
-
- /* build our map of 'other' CPUs */
- other_cpus = all_cpus & ~(1 << cpuid);
-
- /* fill in our (BSP) APIC version */
- cpu_apic_versions[0] = lapic.version;
-
- /* restore the warmstart vector */
- *(u_long *) WARMBOOT_OFF = mpbioswarmvec;
-#ifndef PC98
- outb(CMOS_REG, BIOS_RESET);
- outb(CMOS_DATA, mpbiosreason);
-#endif
-
- /*
- * Set up the idle context for the BSP. Similar to above except
- * that some was done by locore, some by pmap.c and some is implicit
- * because the BSP is cpu#0 and the page is initially zero, and also
- * because we can refer to variables by name on the BSP..
- */
-
- /* Allocate and setup BSP idle stack */
- stack = (char *)kmem_alloc(kernel_map, UPAGES * PAGE_SIZE);
- for (i = 0; i < UPAGES; i++)
- SMPpt[5 + i] = (pt_entry_t)
- (PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack));
-
- *(int *)PTD = 0;
- pmap_set_opt();
-
- /* number of APs actually started */
- return mp_ncpus - 1;
-}
-
-
-/*
- * load the 1st level AP boot code into base memory.
- */
-
-/* targets for relocation */
-extern void bigJump(void);
-extern void bootCodeSeg(void);
-extern void bootDataSeg(void);
-extern void MPentry(void);
-extern u_int MP_GDT;
-extern u_int mp_gdtbase;
-
-static void
-install_ap_tramp(u_int boot_addr)
-{
- int x;
- int size = *(int *) ((u_long) & bootMP_size);
- u_char *src = (u_char *) ((u_long) bootMP);
- u_char *dst = (u_char *) boot_addr + KERNBASE;
- u_int boot_base = (u_int) bootMP;
- u_int8_t *dst8;
- u_int16_t *dst16;
- u_int32_t *dst32;
-
- POSTCODE(INSTALL_AP_TRAMP_POST);
-
- for (x = 0; x < size; ++x)
- *dst++ = *src++;
-
- /*
- * modify addresses in code we just moved to basemem. unfortunately we
- * need fairly detailed info about mpboot.s for this to work. changes
- * to mpboot.s might require changes here.
- */
-
- /* boot code is located in KERNEL space */
- dst = (u_char *) boot_addr + KERNBASE;
-
- /* modify the lgdt arg */
- dst32 = (u_int32_t *) (dst + ((u_int) & mp_gdtbase - boot_base));
- *dst32 = boot_addr + ((u_int) & MP_GDT - boot_base);
-
- /* modify the ljmp target for MPentry() */
- dst32 = (u_int32_t *) (dst + ((u_int) bigJump - boot_base) + 1);
- *dst32 = ((u_int) MPentry - KERNBASE);
-
- /* modify the target for boot code segment */
- dst16 = (u_int16_t *) (dst + ((u_int) bootCodeSeg - boot_base));
- dst8 = (u_int8_t *) (dst16 + 1);
- *dst16 = (u_int) boot_addr & 0xffff;
- *dst8 = ((u_int) boot_addr >> 16) & 0xff;
-
- /* modify the target for boot data segment */
- dst16 = (u_int16_t *) (dst + ((u_int) bootDataSeg - boot_base));
- dst8 = (u_int8_t *) (dst16 + 1);
- *dst16 = (u_int) boot_addr & 0xffff;
- *dst8 = ((u_int) boot_addr >> 16) & 0xff;
-}
-
-
-/*
- * this function starts the AP (application processor) identified
- * by the APIC ID 'physicalCpu'. It does quite a "song and dance"
- * to accomplish this. This is necessary because of the nuances
- * of the different hardware we might encounter. It ain't pretty,
- * but it seems to work.
- */
-static int
-start_ap(int logical_cpu, u_int boot_addr)
-{
- int physical_cpu;
- int vector;
- int cpus;
- u_long icr_lo, icr_hi;
-
- POSTCODE(START_AP_POST);
-
- /* get the PHYSICAL APIC ID# */
- physical_cpu = CPU_TO_ID(logical_cpu);
-
- /* calculate the vector */
- vector = (boot_addr >> 12) & 0xff;
-
- /* used as a watchpoint to signal AP startup */
- cpus = mp_ncpus;
-
- /*
- * first we do an INIT/RESET IPI this INIT IPI might be run, reseting
- * and running the target CPU. OR this INIT IPI might be latched (P5
- * bug), CPU waiting for STARTUP IPI. OR this INIT IPI might be
- * ignored.
- */
-
- /* setup the address for the target AP */
- icr_hi = lapic.icr_hi & ~APIC_ID_MASK;
- icr_hi |= (physical_cpu << 24);
- lapic.icr_hi = icr_hi;
-
- /* do an INIT IPI: assert RESET */
- icr_lo = lapic.icr_lo & 0xfff00000;
- lapic.icr_lo = icr_lo | 0x0000c500;
-
- /* wait for pending status end */
- while (lapic.icr_lo & APIC_DELSTAT_MASK)
- /* spin */ ;
-
- /* do an INIT IPI: deassert RESET */
- lapic.icr_lo = icr_lo | 0x00008500;
-
- /* wait for pending status end */
- u_sleep(10000); /* wait ~10mS */
- while (lapic.icr_lo & APIC_DELSTAT_MASK)
- /* spin */ ;
-
- /*
- * next we do a STARTUP IPI: the previous INIT IPI might still be
- * latched, (P5 bug) this 1st STARTUP would then terminate
- * immediately, and the previously started INIT IPI would continue. OR
- * the previous INIT IPI has already run. and this STARTUP IPI will
- * run. OR the previous INIT IPI was ignored. and this STARTUP IPI
- * will run.
- */
-
- /* do a STARTUP IPI */
- lapic.icr_lo = icr_lo | 0x00000600 | vector;
- while (lapic.icr_lo & APIC_DELSTAT_MASK)
- /* spin */ ;
- u_sleep(200); /* wait ~200uS */
-
- /*
- * finally we do a 2nd STARTUP IPI: this 2nd STARTUP IPI should run IF
- * the previous STARTUP IPI was cancelled by a latched INIT IPI. OR
- * this STARTUP IPI will be ignored, as only ONE STARTUP IPI is
- * recognized after hardware RESET or INIT IPI.
- */
-
- lapic.icr_lo = icr_lo | 0x00000600 | vector;
- while (lapic.icr_lo & APIC_DELSTAT_MASK)
- /* spin */ ;
- u_sleep(200); /* wait ~200uS */
-
- /* wait for it to start */
- set_apic_timer(5000000);/* == 5 seconds */
- while (read_apic_timer())
- if (mp_ncpus > cpus)
- return 1; /* return SUCCESS */
-
- return 0; /* return FAILURE */
-}
-
-
-/*
- * Flush the TLB on all other CPU's
- *
- * XXX: Needs to handshake and wait for completion before proceding.
- */
-void
-smp_invltlb(void)
-{
-#if defined(APIC_IO)
- if (smp_started && invltlb_ok)
- all_but_self_ipi(XINVLTLB_OFFSET);
-#endif /* APIC_IO */
-}
-
-void
-invlpg(u_int addr)
-{
- __asm __volatile("invlpg (%0)"::"r"(addr):"memory");
-
- /* send a message to the other CPUs */
- smp_invltlb();
-}
-
-void
-invltlb(void)
-{
- u_long temp;
-
- /*
- * This should be implemented as load_cr3(rcr3()) when load_cr3() is
- * inlined.
- */
- __asm __volatile("movl %%cr3, %0; movl %0, %%cr3":"=r"(temp) :: "memory");
-
- /* send a message to the other CPUs */
- smp_invltlb();
-}
-
-
-/*
- * When called the executing CPU will send an IPI to all other CPUs
- * requesting that they halt execution.
- *
- * Usually (but not necessarily) called with 'other_cpus' as its arg.
- *
- * - Signals all CPUs in map to stop.
- * - Waits for each to stop.
- *
- * Returns:
- * -1: error
- * 0: NA
- * 1: ok
- *
- * XXX FIXME: this is not MP-safe, needs a lock to prevent multiple CPUs
- * from executing at same time.
- */
-int
-stop_cpus(u_int map)
-{
- if (!smp_started)
- return 0;
-
- /* send the Xcpustop IPI to all CPUs in map */
- selected_apic_ipi(map, XCPUSTOP_OFFSET, APIC_DELMODE_FIXED);
-
- while ((stopped_cpus & map) != map)
- /* spin */ ;
-
- return 1;
-}
-
-
-/*
- * Called by a CPU to restart stopped CPUs.
- *
- * Usually (but not necessarily) called with 'stopped_cpus' as its arg.
- *
- * - Signals all CPUs in map to restart.
- * - Waits for each to restart.
- *
- * Returns:
- * -1: error
- * 0: NA
- * 1: ok
- */
-int
-restart_cpus(u_int map)
-{
- if (!smp_started)
- return 0;
-
- started_cpus = map; /* signal other cpus to restart */
-
- while ((stopped_cpus & map) != 0) /* wait for each to clear its bit */
- /* spin */ ;
-
- return 1;
-}
-
-int smp_active = 0; /* are the APs allowed to run? */
-SYSCTL_INT(_machdep, OID_AUTO, smp_active, CTLFLAG_RW, &smp_active, 0, "");
-
-/* XXX maybe should be hw.ncpu */
-static int smp_cpus = 1; /* how many cpu's running */
-SYSCTL_INT(_machdep, OID_AUTO, smp_cpus, CTLFLAG_RD, &smp_cpus, 0, "");
-
-int invltlb_ok = 0; /* throttle smp_invltlb() till safe */
-SYSCTL_INT(_machdep, OID_AUTO, invltlb_ok, CTLFLAG_RW, &invltlb_ok, 0, "");
-
-/* Warning: Do not staticize. Used from swtch.s */
-int do_page_zero_idle = 1; /* bzero pages for fun and profit in idleloop */
-SYSCTL_INT(_machdep, OID_AUTO, do_page_zero_idle, CTLFLAG_RW,
- &do_page_zero_idle, 0, "");
-
-/* Is forwarding of a interrupt to the CPU holding the ISR lock enabled ? */
-int forward_irq_enabled = 1;
-SYSCTL_INT(_machdep, OID_AUTO, forward_irq_enabled, CTLFLAG_RW,
- &forward_irq_enabled, 0, "");
-
-/* Enable forwarding of a signal to a process running on a different CPU */
-static int forward_signal_enabled = 1;
-SYSCTL_INT(_machdep, OID_AUTO, forward_signal_enabled, CTLFLAG_RW,
- &forward_signal_enabled, 0, "");
-
-/* Enable forwarding of roundrobin to all other cpus */
-static int forward_roundrobin_enabled = 1;
-SYSCTL_INT(_machdep, OID_AUTO, forward_roundrobin_enabled, CTLFLAG_RW,
- &forward_roundrobin_enabled, 0, "");
-
-/*
- * This is called once the rest of the system is up and running and we're
- * ready to let the AP's out of the pen.
- */
-void ap_init(void);
-
-void
-ap_init()
-{
- u_int apic_id;
-
- /* BSP may have changed PTD while we're waiting for the lock */
- cpu_invltlb();
-
- smp_cpus++;
-
-#if defined(I586_CPU) && !defined(NO_F00F_HACK)
- lidt(&r_idt);
-#endif
-
- /* Build our map of 'other' CPUs. */
- other_cpus = all_cpus & ~(1 << cpuid);
-
- printf("SMP: AP CPU #%d Launched!\n", cpuid);
-
- /* XXX FIXME: i386 specific, and redundant: Setup the FPU. */
- load_cr0((rcr0() & ~CR0_EM) | CR0_MP | CR0_NE | CR0_TS);
-
- /* set up FPU state on the AP */
- npxinit(__INITIAL_NPXCW__);
-
- /* A quick check from sanity claus */
- apic_id = (apic_id_to_logical[(lapic.id & 0x0f000000) >> 24]);
- if (cpuid != apic_id) {
- printf("SMP: cpuid = %d\n", cpuid);
- printf("SMP: apic_id = %d\n", apic_id);
- printf("PTD[MPPTDI] = %p\n", (void *)PTD[MPPTDI]);
- panic("cpuid mismatch! boom!!");
- }
-
- /* Init local apic for irq's */
- apic_initialize();
-
- /* Set memory range attributes for this CPU to match the BSP */
- mem_range_AP_init();
-
- /*
- * Activate smp_invltlb, although strictly speaking, this isn't
- * quite correct yet. We should have a bitfield for cpus willing
- * to accept TLB flush IPI's or something and sync them.
- */
- if (smp_cpus == mp_ncpus) {
- invltlb_ok = 1;
- smp_started = 1; /* enable IPI's, tlb shootdown, freezes etc */
- smp_active = 1; /* historic */
- }
-}
-
-#ifdef BETTER_CLOCK
-
-#define CHECKSTATE_USER 0
-#define CHECKSTATE_SYS 1
-#define CHECKSTATE_INTR 2
-
-/* Do not staticize. Used from apic_vector.s */
-struct proc* checkstate_curproc[NCPU];
-int checkstate_cpustate[NCPU];
-u_long checkstate_pc[NCPU];
-
-extern long cp_time[CPUSTATES];
-
-#define PC_TO_INDEX(pc, prof) \
- ((int)(((u_quad_t)((pc) - (prof)->pr_off) * \
- (u_quad_t)((prof)->pr_scale)) >> 16) & ~1)
-
-static void
-addupc_intr_forwarded(struct proc *p, int id, int *astmap)
-{
- int i;
- struct uprof *prof;
- u_long pc;
-
- pc = checkstate_pc[id];
- prof = &p->p_stats->p_prof;
- if (pc >= prof->pr_off &&
- (i = PC_TO_INDEX(pc, prof)) < prof->pr_size) {
- if ((p->p_flag & P_OWEUPC) == 0) {
- prof->pr_addr = pc;
- prof->pr_ticks = 1;
- p->p_flag |= P_OWEUPC;
- }
- *astmap |= (1 << id);
- }
-}
-
-static void
-forwarded_statclock(int id, int pscnt, int *astmap)
-{
- struct pstats *pstats;
- long rss;
- struct rusage *ru;
- struct vmspace *vm;
- int cpustate;
- struct proc *p;
-#ifdef GPROF
- register struct gmonparam *g;
- int i;
-#endif
-
- p = checkstate_curproc[id];
- cpustate = checkstate_cpustate[id];
-
- switch (cpustate) {
- case CHECKSTATE_USER:
- if (p->p_flag & P_PROFIL)
- addupc_intr_forwarded(p, id, astmap);
- if (pscnt > 1)
- return;
- p->p_uticks++;
- if (p->p_nice > NZERO)
- cp_time[CP_NICE]++;
- else
- cp_time[CP_USER]++;
- break;
- case CHECKSTATE_SYS:
-#ifdef GPROF
- /*
- * Kernel statistics are just like addupc_intr, only easier.
- */
- g = &_gmonparam;
- if (g->state == GMON_PROF_ON) {
- i = checkstate_pc[id] - g->lowpc;
- if (i < g->textsize) {
- i /= HISTFRACTION * sizeof(*g->kcount);
- g->kcount[i]++;
- }
- }
-#endif
- if (pscnt > 1)
- return;
-
- if (!p)
- cp_time[CP_IDLE]++;
- else {
- p->p_sticks++;
- cp_time[CP_SYS]++;
- }
- break;
- case CHECKSTATE_INTR:
- default:
-#ifdef GPROF
- /*
- * Kernel statistics are just like addupc_intr, only easier.
- */
- g = &_gmonparam;
- if (g->state == GMON_PROF_ON) {
- i = checkstate_pc[id] - g->lowpc;
- if (i < g->textsize) {
- i /= HISTFRACTION * sizeof(*g->kcount);
- g->kcount[i]++;
- }
- }
-#endif
- if (pscnt > 1)
- return;
- if (p)
- p->p_iticks++;
- cp_time[CP_INTR]++;
- }
- if (p != NULL) {
- schedclock(p);
-
- /* Update resource usage integrals and maximums. */
- if ((pstats = p->p_stats) != NULL &&
- (ru = &pstats->p_ru) != NULL &&
- (vm = p->p_vmspace) != NULL) {
- ru->ru_ixrss += pgtok(vm->vm_tsize);
- ru->ru_idrss += pgtok(vm->vm_dsize);
- ru->ru_isrss += pgtok(vm->vm_ssize);
- rss = pgtok(vmspace_resident_count(vm));
- if (ru->ru_maxrss < rss)
- ru->ru_maxrss = rss;
- }
- }
-}
-
-void
-forward_statclock(int pscnt)
-{
- int map;
- int id;
- int i;
-
- /* Kludge. We don't yet have separate locks for the interrupts
- * and the kernel. This means that we cannot let the other processors
- * handle complex interrupts while inhibiting them from entering
- * the kernel in a non-interrupt context.
- *
- * What we can do, without changing the locking mechanisms yet,
- * is letting the other processors handle a very simple interrupt
- * (wich determines the processor states), and do the main
- * work ourself.
- */
-
- if (!smp_started || !invltlb_ok || cold || panicstr)
- return;
-
- /* Step 1: Probe state (user, cpu, interrupt, spinlock, idle ) */
-
- map = other_cpus & ~stopped_cpus ;
- checkstate_probed_cpus = 0;
- if (map != 0)
- selected_apic_ipi(map,
- XCPUCHECKSTATE_OFFSET, APIC_DELMODE_FIXED);
-
- i = 0;
- while (checkstate_probed_cpus != map) {
- /* spin */
- i++;
- if (i == 100000) {
-#ifdef BETTER_CLOCK_DIAGNOSTIC
- printf("forward_statclock: checkstate %x\n",
- checkstate_probed_cpus);
-#endif
- break;
- }
- }
-
- /*
- * Step 2: walk through other processors processes, update ticks and
- * profiling info.
- */
-
- map = 0;
- for (id = 0; id < mp_ncpus; id++) {
- if (id == cpuid)
- continue;
- if (((1 << id) & checkstate_probed_cpus) == 0)
- continue;
- forwarded_statclock(id, pscnt, &map);
- }
- if (map != 0) {
- checkstate_need_ast |= map;
- selected_apic_ipi(map, XCPUAST_OFFSET, APIC_DELMODE_FIXED);
- i = 0;
- while ((checkstate_need_ast & map) != 0) {
- /* spin */
- i++;
- if (i > 100000) {
-#ifdef BETTER_CLOCK_DIAGNOSTIC
- printf("forward_statclock: dropped ast 0x%x\n",
- checkstate_need_ast & map);
-#endif
- break;
- }
- }
- }
-}
-
-void
-forward_hardclock(int pscnt)
-{
- int map;
- int id;
- struct proc *p;
- struct pstats *pstats;
- int i;
-
- /* Kludge. We don't yet have separate locks for the interrupts
- * and the kernel. This means that we cannot let the other processors
- * handle complex interrupts while inhibiting them from entering
- * the kernel in a non-interrupt context.
- *
- * What we can do, without changing the locking mechanisms yet,
- * is letting the other processors handle a very simple interrupt
- * (wich determines the processor states), and do the main
- * work ourself.
- */
-
- if (!smp_started || !invltlb_ok || cold || panicstr)
- return;
-
- /* Step 1: Probe state (user, cpu, interrupt, spinlock, idle) */
-
- map = other_cpus & ~stopped_cpus ;
- checkstate_probed_cpus = 0;
- if (map != 0)
- selected_apic_ipi(map,
- XCPUCHECKSTATE_OFFSET, APIC_DELMODE_FIXED);
-
- i = 0;
- while (checkstate_probed_cpus != map) {
- /* spin */
- i++;
- if (i == 100000) {
-#ifdef BETTER_CLOCK_DIAGNOSTIC
- printf("forward_hardclock: checkstate %x\n",
- checkstate_probed_cpus);
-#endif
- break;
- }
- }
-
- /*
- * Step 2: walk through other processors processes, update virtual
- * timer and profiling timer. If stathz == 0, also update ticks and
- * profiling info.
- */
-
- map = 0;
- for (id = 0; id < mp_ncpus; id++) {
- if (id == cpuid)
- continue;
- if (((1 << id) & checkstate_probed_cpus) == 0)
- continue;
- p = checkstate_curproc[id];
- if (p) {
- pstats = p->p_stats;
- if (checkstate_cpustate[id] == CHECKSTATE_USER &&
- timevalisset(&pstats->p_timer[ITIMER_VIRTUAL].it_value) &&
- itimerdecr(&pstats->p_timer[ITIMER_VIRTUAL], tick) == 0) {
- psignal(p, SIGVTALRM);
- map |= (1 << id);
- }
- if (timevalisset(&pstats->p_timer[ITIMER_PROF].it_value) &&
- itimerdecr(&pstats->p_timer[ITIMER_PROF], tick) == 0) {
- psignal(p, SIGPROF);
- map |= (1 << id);
- }
- }
- if (stathz == 0) {
- forwarded_statclock( id, pscnt, &map);
- }
- }
- if (map != 0) {
- checkstate_need_ast |= map;
- selected_apic_ipi(map, XCPUAST_OFFSET, APIC_DELMODE_FIXED);
- i = 0;
- while ((checkstate_need_ast & map) != 0) {
- /* spin */
- i++;
- if (i > 100000) {
-#ifdef BETTER_CLOCK_DIAGNOSTIC
- printf("forward_hardclock: dropped ast 0x%x\n",
- checkstate_need_ast & map);
-#endif
- break;
- }
- }
- }
-}
-
-#endif /* BETTER_CLOCK */
-
-void
-forward_signal(struct proc *p)
-{
- int map;
- int id;
- int i;
-
- /* Kludge. We don't yet have separate locks for the interrupts
- * and the kernel. This means that we cannot let the other processors
- * handle complex interrupts while inhibiting them from entering
- * the kernel in a non-interrupt context.
- *
- * What we can do, without changing the locking mechanisms yet,
- * is letting the other processors handle a very simple interrupt
- * (wich determines the processor states), and do the main
- * work ourself.
- */
-
- if (!smp_started || !invltlb_ok || cold || panicstr)
- return;
- if (!forward_signal_enabled)
- return;
- while (1) {
- if (p->p_stat != SRUN)
- return;
- id = p->p_oncpu;
- if (id == 0xff)
- return;
- map = (1<<id);
- checkstate_need_ast |= map;
- selected_apic_ipi(map, XCPUAST_OFFSET, APIC_DELMODE_FIXED);
- i = 0;
- while ((checkstate_need_ast & map) != 0) {
- /* spin */
- i++;
- if (i > 100000) {
-#if 0
- printf("forward_signal: dropped ast 0x%x\n",
- checkstate_need_ast & map);
-#endif
- break;
- }
- }
- if (id == p->p_oncpu)
- return;
- }
-}
-
-void
-forward_roundrobin(void)
-{
- u_int map;
- int i;
-
- if (!smp_started || !invltlb_ok || cold || panicstr)
- return;
- if (!forward_roundrobin_enabled)
- return;
- resched_cpus |= other_cpus;
- map = other_cpus & ~stopped_cpus ;
-#if 1
- selected_apic_ipi(map, XCPUAST_OFFSET, APIC_DELMODE_FIXED);
-#else
- (void) all_but_self_ipi(XCPUAST_OFFSET);
-#endif
- i = 0;
- while ((checkstate_need_ast & map) != 0) {
- /* spin */
- i++;
- if (i > 100000) {
-#if 0
- printf("forward_roundrobin: dropped ast 0x%x\n",
- checkstate_need_ast & map);
-#endif
- break;
- }
- }
-}
-
-
-#ifdef APIC_INTR_REORDER
-/*
- * Maintain mapping from softintr vector to isr bit in local apic.
- */
-void
-set_lapic_isrloc(int intr, int vector)
-{
- if (intr < 0 || intr > 32)
- panic("set_apic_isrloc: bad intr argument: %d",intr);
- if (vector < ICU_OFFSET || vector > 255)
- panic("set_apic_isrloc: bad vector argument: %d",vector);
- apic_isrbit_location[intr].location = &lapic.isr0 + ((vector>>5)<<2);
- apic_isrbit_location[intr].bit = (1<<(vector & 31));
-}
-#endif
-
-/*
- * All-CPU rendezvous. CPUs are signalled, all execute the setup function
- * (if specified), rendezvous, execute the action function (if specified),
- * rendezvous again, execute the teardown function (if specified), and then
- * resume.
- *
- * Note that the supplied external functions _must_ be reentrant and aware
- * that they are running in parallel and in an unknown lock context.
- */
-static void (*smp_rv_setup_func)(void *arg);
-static void (*smp_rv_action_func)(void *arg);
-static void (*smp_rv_teardown_func)(void *arg);
-static void *smp_rv_func_arg;
-static volatile int smp_rv_waiters[2];
-
-void
-smp_rendezvous_action(void)
-{
- /* setup function */
- if (smp_rv_setup_func != NULL)
- smp_rv_setup_func(smp_rv_func_arg);
- /* spin on entry rendezvous */
- atomic_add_int(&smp_rv_waiters[0], 1);
- while (smp_rv_waiters[0] < mp_ncpus)
- ;
- /* action function */
- if (smp_rv_action_func != NULL)
- smp_rv_action_func(smp_rv_func_arg);
- /* spin on exit rendezvous */
- atomic_add_int(&smp_rv_waiters[1], 1);
- while (smp_rv_waiters[1] < mp_ncpus)
- ;
- /* teardown function */
- if (smp_rv_teardown_func != NULL)
- smp_rv_teardown_func(smp_rv_func_arg);
-}
-
-void
-smp_rendezvous(void (* setup_func)(void *),
- void (* action_func)(void *),
- void (* teardown_func)(void *),
- void *arg)
-{
- u_int efl;
-
- /* obtain rendezvous lock */
- s_lock(&smp_rv_lock); /* XXX sleep here? NOWAIT flag? */
-
- /* set static function pointers */
- smp_rv_setup_func = setup_func;
- smp_rv_action_func = action_func;
- smp_rv_teardown_func = teardown_func;
- smp_rv_func_arg = arg;
- smp_rv_waiters[0] = 0;
- smp_rv_waiters[1] = 0;
-
- /* disable interrupts on this CPU, save interrupt status */
- efl = read_eflags();
- write_eflags(efl & ~PSL_I);
-
- /* signal other processors, which will enter the IPI with interrupts off */
- all_but_self_ipi(XRENDEZVOUS_OFFSET);
-
- /* call executor function */
- smp_rendezvous_action();
-
- /* restore interrupt flag */
- write_eflags(efl);
-
- /* release lock */
- s_unlock(&smp_rv_lock);
-}
diff --git a/sys/i386/include/pci_cfgreg.h b/sys/i386/include/pci_cfgreg.h
deleted file mode 100644
index 34b3fc54aaa3..000000000000
--- a/sys/i386/include/pci_cfgreg.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 1997, Stefan Esser <se@freebsd.org>
- * 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 unmodified, 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.
- *
- * $FreeBSD$
- *
- */
-
-#define CONF1_ADDR_PORT 0x0cf8
-#define CONF1_DATA_PORT 0x0cfc
-
-#define CONF1_ENABLE 0x80000000ul
-#define CONF1_ENABLE_CHK 0x80000000ul
-#define CONF1_ENABLE_MSK 0x7ff00000ul
-#define CONF1_ENABLE_CHK1 0xff000001ul
-#define CONF1_ENABLE_MSK1 0x80000001ul
-#define CONF1_ENABLE_RES1 0x80000000ul
-
-#define CONF2_ENABLE_PORT 0x0cf8
-#ifdef PC98
-#define CONF2_FORWARD_PORT 0x0cf9
-#else
-#define CONF2_FORWARD_PORT 0x0cfa
-#endif
-
-#define CONF2_ENABLE_CHK 0x0e
-#define CONF2_ENABLE_RES 0x0e
diff --git a/sys/i386/include/pcpu.h b/sys/i386/include/pcpu.h
deleted file mode 100644
index 28336d708534..000000000000
--- a/sys/i386/include/pcpu.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*-
- * Copyright (c) Peter Wemm <peter@netplex.com.au>
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-/*
- * This structure maps out the global data that needs to be kept on a
- * per-cpu basis. genassym uses this to generate offsets for the assembler
- * code, which also provides external symbols so that C can get at them as
- * though they were really globals.
- *
- * The SMP parts are setup in pmap.c and locore.s for the BSP, and
- * mp_machdep.c sets up the data for the AP's to "see" when they awake.
- * The reason for doing it via a struct is so that an array of pointers
- * to each CPU's data can be set up for things like "check curproc on all
- * other processors"
- */
-struct globaldata {
- struct privatespace *gd_prvspace; /* self-reference */
- struct proc *gd_curproc;
- struct proc *gd_npxproc;
- struct pcb *gd_curpcb;
- struct timeval gd_switchtime;
- struct i386tss gd_common_tss;
- int gd_switchticks;
- struct segment_descriptor gd_common_tssd;
- struct segment_descriptor *gd_tss_gdt;
-#ifdef USER_LDT
- int gd_currentldt;
-#endif
-#ifdef SMP
- u_int gd_cpuid;
- u_int gd_cpu_lockid;
- u_int gd_other_cpus;
- int gd_inside_intr;
- u_int gd_ss_eflags;
- pt_entry_t *gd_prv_CMAP1;
- pt_entry_t *gd_prv_CMAP2;
- pt_entry_t *gd_prv_CMAP3;
- pt_entry_t *gd_prv_PMAP1;
- caddr_t gd_prv_CADDR1;
- caddr_t gd_prv_CADDR2;
- caddr_t gd_prv_CADDR3;
- unsigned *gd_prv_PADDR1;
-#endif
-};
-
-#ifdef SMP
-/*
- * This is the upper (0xff800000) address space layout that is per-cpu.
- * It is setup in locore.s and pmap.c for the BSP and in mp_machdep.c for
- * each AP. genassym helps export this to the assembler code.
- */
-struct privatespace {
- /* page 0 - data page */
- struct globaldata globaldata;
- char __filler0[PAGE_SIZE - sizeof(struct globaldata)];
-
- /* page 1..4 - CPAGE1,CPAGE2,CPAGE3,PPAGE1 */
- char CPAGE1[PAGE_SIZE];
- char CPAGE2[PAGE_SIZE];
- char CPAGE3[PAGE_SIZE];
- char PPAGE1[PAGE_SIZE];
-
- /* page 5..4+UPAGES - idle stack (UPAGES pages) */
- char idlestack[UPAGES * PAGE_SIZE];
-};
-
-extern struct privatespace SMP_prvspace[];
-
-#endif
diff --git a/sys/i386/isa/atpic_vector.s b/sys/i386/isa/atpic_vector.s
deleted file mode 100644
index 24ce97b666b9..000000000000
--- a/sys/i386/isa/atpic_vector.s
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * from: vector.s, 386BSD 0.1 unknown origin
- * $FreeBSD$
- */
-
-/*
- * modified for PC98 by Kakefuda
- */
-
-#ifdef PC98
-#define ICU_IMR_OFFSET 2 /* IO_ICU{1,2} + 2 */
-#else
-#define ICU_IMR_OFFSET 1 /* IO_ICU{1,2} + 1 */
-#endif
-
-#define ICU_EOI 0x20 /* XXX - define elsewhere */
-
-#define IRQ_BIT(irq_num) (1 << ((irq_num) % 8))
-#define IRQ_BYTE(irq_num) ((irq_num) >> 3)
-
-#ifdef AUTO_EOI_1
-#define ENABLE_ICU1 /* use auto-EOI to reduce i/o */
-#define OUTB_ICU1
-#else
-#define ENABLE_ICU1 \
- movb $ICU_EOI,%al ; /* as soon as possible send EOI ... */ \
- OUTB_ICU1 /* ... to clear in service bit */
-#define OUTB_ICU1 \
- outb %al,$IO_ICU1
-#endif
-
-#ifdef AUTO_EOI_2
-/*
- * The data sheet says no auto-EOI on slave, but it sometimes works.
- */
-#define ENABLE_ICU1_AND_2 ENABLE_ICU1
-#else
-#define ENABLE_ICU1_AND_2 \
- movb $ICU_EOI,%al ; /* as above */ \
- outb %al,$IO_ICU2 ; /* but do second icu first ... */ \
- OUTB_ICU1 /* ... then first icu (if !AUTO_EOI_1) */
-#endif
-
-/*
- * Macros for interrupt interrupt entry, call to handler, and exit.
- */
-
-#define FAST_INTR(irq_num, vec_name, enable_icus) \
- .text ; \
- SUPERALIGN_TEXT ; \
-IDTVEC(vec_name) ; \
- pushl %eax ; /* save only call-used registers */ \
- pushl %ecx ; \
- pushl %edx ; \
- pushl %ds ; \
- MAYBE_PUSHL_ES ; \
- movl $KDSEL,%eax ; \
- movl %ax,%ds ; \
- MAYBE_MOVW_AX_ES ; \
- FAKE_MCOUNT((4+ACTUALLY_PUSHED)*4(%esp)) ; \
- pushl _intr_unit + (irq_num) * 4 ; \
- call *_intr_handler + (irq_num) * 4 ; /* do the work ASAP */ \
- enable_icus ; /* (re)enable ASAP (helps edge trigger?) */ \
- addl $4,%esp ; \
- incl _cnt+V_INTR ; /* book-keeping can wait */ \
- movl _intr_countp + (irq_num) * 4,%eax ; \
- incl (%eax) ; \
- movl _cpl,%eax ; /* are we unmasking pending HWIs or SWIs? */ \
- notl %eax ; \
- andl _ipending,%eax ; \
- jne 2f ; /* yes, maybe handle them */ \
-1: ; \
- MEXITCOUNT ; \
- MAYBE_POPL_ES ; \
- popl %ds ; \
- popl %edx ; \
- popl %ecx ; \
- popl %eax ; \
- iret ; \
-; \
- ALIGN_TEXT ; \
-2: ; \
- cmpb $3,_intr_nesting_level ; /* is there enough stack? */ \
- jae 1b ; /* no, return */ \
- movl _cpl,%eax ; \
- /* XXX next line is probably unnecessary now. */ \
- movl $HWI_MASK|SWI_MASK,_cpl ; /* limit nesting ... */ \
- incb _intr_nesting_level ; /* ... really limit it ... */ \
- sti ; /* ... to do this as early as possible */ \
- MAYBE_POPL_ES ; /* discard most of thin frame ... */ \
- popl %ecx ; /* ... original %ds ... */ \
- popl %edx ; \
- xchgl %eax,4(%esp) ; /* orig %eax; save cpl */ \
- pushal ; /* build fat frame (grrr) ... */ \
- pushl %ecx ; /* ... actually %ds ... */ \
- pushl %es ; \
- pushl %fs ; \
- movl $KDSEL,%eax ; \
- movl %ax,%es ; \
- movl %ax,%fs ; \
- movl (3+8+0)*4(%esp),%ecx ; /* ... %ecx from thin frame ... */ \
- movl %ecx,(3+6)*4(%esp) ; /* ... to fat frame ... */ \
- movl (3+8+1)*4(%esp),%eax ; /* ... cpl from thin frame */ \
- pushl %eax ; \
- subl $4,%esp ; /* junk for unit number */ \
- MEXITCOUNT ; \
- jmp _doreti
-
-#define INTR(irq_num, vec_name, icu, enable_icus, reg, maybe_extra_ipending) \
- .text ; \
- SUPERALIGN_TEXT ; \
-IDTVEC(vec_name) ; \
- pushl $0 ; /* dummy error code */ \
- pushl $0 ; /* dummy trap type */ \
- pushal ; \
- pushl %ds ; /* save our data and extra segments ... */ \
- pushl %es ; \
- pushl %fs ; \
- movl $KDSEL,%eax ; /* ... and reload with kernel's own ... */ \
- movl %ax,%ds ; /* ... early for obsolete reasons */ \
- movl %ax,%es ; \
- movl %ax,%fs ; \
- maybe_extra_ipending ; \
- movb _imen + IRQ_BYTE(irq_num),%al ; \
- orb $IRQ_BIT(irq_num),%al ; \
- movb %al,_imen + IRQ_BYTE(irq_num) ; \
- outb %al,$icu+ICU_IMR_OFFSET ; \
- enable_icus ; \
- movl _cpl,%eax ; \
- testb $IRQ_BIT(irq_num),%reg ; \
- jne 2f ; \
- incb _intr_nesting_level ; \
-__CONCAT(Xresume,irq_num): ; \
- FAKE_MCOUNT(13*4(%esp)) ; /* XXX late to avoid double count */ \
- incl _cnt+V_INTR ; /* tally interrupts */ \
- movl _intr_countp + (irq_num) * 4,%eax ; \
- incl (%eax) ; \
- movl _cpl,%eax ; \
- pushl %eax ; \
- pushl _intr_unit + (irq_num) * 4 ; \
- orl _intr_mask + (irq_num) * 4,%eax ; \
- movl %eax,_cpl ; \
- sti ; \
- call *_intr_handler + (irq_num) * 4 ; \
- cli ; /* must unmask _imen and icu atomically */ \
- movb _imen + IRQ_BYTE(irq_num),%al ; \
- andb $~IRQ_BIT(irq_num),%al ; \
- movb %al,_imen + IRQ_BYTE(irq_num) ; \
- outb %al,$icu+ICU_IMR_OFFSET ; \
- sti ; /* XXX _doreti repeats the cli/sti */ \
- MEXITCOUNT ; \
- /* We could usually avoid the following jmp by inlining some of */ \
- /* _doreti, but it's probably better to use less cache. */ \
- jmp _doreti ; \
-; \
- ALIGN_TEXT ; \
-2: ; \
- /* XXX skip mcounting here to avoid double count */ \
- orb $IRQ_BIT(irq_num),_ipending + IRQ_BYTE(irq_num) ; \
- popl %fs ; \
- popl %es ; \
- popl %ds ; \
- popal ; \
- addl $4+4,%esp ; \
- iret
-
-MCOUNT_LABEL(bintr)
- FAST_INTR(0,fastintr0, ENABLE_ICU1)
- FAST_INTR(1,fastintr1, ENABLE_ICU1)
- FAST_INTR(2,fastintr2, ENABLE_ICU1)
- FAST_INTR(3,fastintr3, ENABLE_ICU1)
- FAST_INTR(4,fastintr4, ENABLE_ICU1)
- FAST_INTR(5,fastintr5, ENABLE_ICU1)
- FAST_INTR(6,fastintr6, ENABLE_ICU1)
- FAST_INTR(7,fastintr7, ENABLE_ICU1)
- FAST_INTR(8,fastintr8, ENABLE_ICU1_AND_2)
- FAST_INTR(9,fastintr9, ENABLE_ICU1_AND_2)
- FAST_INTR(10,fastintr10, ENABLE_ICU1_AND_2)
- FAST_INTR(11,fastintr11, ENABLE_ICU1_AND_2)
- FAST_INTR(12,fastintr12, ENABLE_ICU1_AND_2)
- FAST_INTR(13,fastintr13, ENABLE_ICU1_AND_2)
- FAST_INTR(14,fastintr14, ENABLE_ICU1_AND_2)
- FAST_INTR(15,fastintr15, ENABLE_ICU1_AND_2)
-#define CLKINTR_PENDING movl $1,CNAME(clkintr_pending)
- INTR(0,intr0, IO_ICU1, ENABLE_ICU1, al, CLKINTR_PENDING)
- INTR(1,intr1, IO_ICU1, ENABLE_ICU1, al,)
- INTR(2,intr2, IO_ICU1, ENABLE_ICU1, al,)
- INTR(3,intr3, IO_ICU1, ENABLE_ICU1, al,)
- INTR(4,intr4, IO_ICU1, ENABLE_ICU1, al,)
- INTR(5,intr5, IO_ICU1, ENABLE_ICU1, al,)
- INTR(6,intr6, IO_ICU1, ENABLE_ICU1, al,)
- INTR(7,intr7, IO_ICU1, ENABLE_ICU1, al,)
- INTR(8,intr8, IO_ICU2, ENABLE_ICU1_AND_2, ah,)
- INTR(9,intr9, IO_ICU2, ENABLE_ICU1_AND_2, ah,)
- INTR(10,intr10, IO_ICU2, ENABLE_ICU1_AND_2, ah,)
- INTR(11,intr11, IO_ICU2, ENABLE_ICU1_AND_2, ah,)
- INTR(12,intr12, IO_ICU2, ENABLE_ICU1_AND_2, ah,)
- INTR(13,intr13, IO_ICU2, ENABLE_ICU1_AND_2, ah,)
- INTR(14,intr14, IO_ICU2, ENABLE_ICU1_AND_2, ah,)
- INTR(15,intr15, IO_ICU2, ENABLE_ICU1_AND_2, ah,)
-MCOUNT_LABEL(eintr)
-
- .data
- .globl _ihandlers
-_ihandlers: /* addresses of interrupt handlers */
- /* actually resumption addresses for HWI's */
- .long Xresume0, Xresume1, Xresume2, Xresume3
- .long Xresume4, Xresume5, Xresume6, Xresume7
- .long Xresume8, Xresume9, Xresume10, Xresume11
- .long Xresume12, Xresume13, Xresume14, Xresume15
- .long _swi_null, swi_net, _swi_null, _swi_null
- .long _swi_vm, _swi_null, _swi_null, _swi_null
- .long _swi_null, _swi_null, _swi_null, _swi_null
- .long _swi_null, _swi_null, _softclock, _swi_null
-
-imasks: /* masks for interrupt handlers */
- .space NHWI*4 /* padding; HWI masks are elsewhere */
-
- .long SWI_TTY_MASK, SWI_NET_MASK, SWI_CAMNET_MASK, SWI_CAMBIO_MASK
- .long SWI_VM_MASK, 0, 0, 0
- .long 0, 0, 0, 0
- .long 0, 0, SWI_CLOCK_MASK, 0
-
- .text
diff --git a/sys/i386/isa/nmi.c b/sys/i386/isa/nmi.c
deleted file mode 100644
index d1f46ca4d8cf..000000000000
--- a/sys/i386/isa/nmi.c
+++ /dev/null
@@ -1,850 +0,0 @@
-/*-
- * Copyright (c) 1991 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)isa.c 7.2 (Berkeley) 5/13/91
- * $FreeBSD$
- */
-/*
- * This file contains an aggregated module marked:
- * Copyright (c) 1997, Stefan Esser <se@freebsd.org>
- * All rights reserved.
- * See the notice for details.
- */
-
-#include "opt_auto_eoi.h"
-
-#include "isa.h"
-
-#include <sys/param.h>
-#ifndef SMP
-#include <machine/lock.h>
-#endif
-#include <sys/systm.h>
-#include <sys/syslog.h>
-#include <sys/malloc.h>
-#include <sys/errno.h>
-#include <sys/interrupt.h>
-#include <machine/ipl.h>
-#include <machine/md_var.h>
-#include <machine/segments.h>
-#include <sys/bus.h>
-
-#if defined(APIC_IO)
-#include <machine/smp.h>
-#include <machine/smptests.h> /** FAST_HI */
-#endif /* APIC_IO */
-#ifdef PC98
-#include <pc98/pc98/pc98.h>
-#include <pc98/pc98/pc98_machdep.h>
-#include <pc98/pc98/epsonio.h>
-#else
-#include <i386/isa/isa.h>
-#endif
-#include <i386/isa/icu.h>
-
-#if NISA > 0
-#include <isa/isavar.h>
-#endif
-#include <i386/isa/intr_machdep.h>
-#include <sys/interrupt.h>
-#ifdef APIC_IO
-#include <machine/clock.h>
-#endif
-
-#include "mca.h"
-#if NMCA > 0
-#include <i386/isa/mca_machdep.h>
-#endif
-
-/* XXX should be in suitable include files */
-#ifdef PC98
-#define ICU_IMR_OFFSET 2 /* IO_ICU{1,2} + 2 */
-#define ICU_SLAVEID 7
-#else
-#define ICU_IMR_OFFSET 1 /* IO_ICU{1,2} + 1 */
-#define ICU_SLAVEID 2
-#endif
-
-#ifdef APIC_IO
-/*
- * This is to accommodate "mixed-mode" programming for
- * motherboards that don't connect the 8254 to the IO APIC.
- */
-#define AUTO_EOI_1 1
-#endif
-
-#define NR_INTRNAMES (1 + ICU_LEN + 2 * ICU_LEN)
-
-u_long *intr_countp[ICU_LEN];
-inthand2_t *intr_handler[ICU_LEN];
-u_int intr_mask[ICU_LEN];
-static u_int* intr_mptr[ICU_LEN];
-void *intr_unit[ICU_LEN];
-
-static inthand_t *fastintr[ICU_LEN] = {
- &IDTVEC(fastintr0), &IDTVEC(fastintr1),
- &IDTVEC(fastintr2), &IDTVEC(fastintr3),
- &IDTVEC(fastintr4), &IDTVEC(fastintr5),
- &IDTVEC(fastintr6), &IDTVEC(fastintr7),
- &IDTVEC(fastintr8), &IDTVEC(fastintr9),
- &IDTVEC(fastintr10), &IDTVEC(fastintr11),
- &IDTVEC(fastintr12), &IDTVEC(fastintr13),
- &IDTVEC(fastintr14), &IDTVEC(fastintr15),
-#if defined(APIC_IO)
- &IDTVEC(fastintr16), &IDTVEC(fastintr17),
- &IDTVEC(fastintr18), &IDTVEC(fastintr19),
- &IDTVEC(fastintr20), &IDTVEC(fastintr21),
- &IDTVEC(fastintr22), &IDTVEC(fastintr23),
-#endif /* APIC_IO */
-};
-
-static inthand_t *slowintr[ICU_LEN] = {
- &IDTVEC(intr0), &IDTVEC(intr1), &IDTVEC(intr2), &IDTVEC(intr3),
- &IDTVEC(intr4), &IDTVEC(intr5), &IDTVEC(intr6), &IDTVEC(intr7),
- &IDTVEC(intr8), &IDTVEC(intr9), &IDTVEC(intr10), &IDTVEC(intr11),
- &IDTVEC(intr12), &IDTVEC(intr13), &IDTVEC(intr14), &IDTVEC(intr15),
-#if defined(APIC_IO)
- &IDTVEC(intr16), &IDTVEC(intr17), &IDTVEC(intr18), &IDTVEC(intr19),
- &IDTVEC(intr20), &IDTVEC(intr21), &IDTVEC(intr22), &IDTVEC(intr23),
-#endif /* APIC_IO */
-};
-
-static inthand2_t isa_strayintr;
-
-#ifdef PC98
-#define NMI_PARITY 0x04
-#define NMI_EPARITY 0x02
-#else
-#define NMI_PARITY (1 << 7)
-#define NMI_IOCHAN (1 << 6)
-#define ENMI_WATCHDOG (1 << 7)
-#define ENMI_BUSTIMER (1 << 6)
-#define ENMI_IOSTATUS (1 << 5)
-#endif
-
-/*
- * Handle a NMI, possibly a machine check.
- * return true to panic system, false to ignore.
- */
-int
-isa_nmi(cd)
- int cd;
-{
-#ifdef PC98
- int port = inb(0x33);
- if (epson_machine_id == 0x20)
- epson_outb(0xc16, epson_inb(0xc16) | 0x1);
- if (port & NMI_PARITY) {
- panic("BASE RAM parity error, likely hardware failure.");
- } else if (port & NMI_EPARITY) {
- panic("EXTENDED RAM parity error, likely hardware failure.");
- } else {
- printf("\nNMI Resume ??\n");
- return(0);
- }
-#else /* IBM-PC */
- int isa_port = inb(0x61);
- int eisa_port = inb(0x461);
-
-#if NMCA > 0
- if (MCA_system && mca_bus_nmi())
- return(0);
-#endif
-
- if (isa_port & NMI_PARITY)
- panic("RAM parity error, likely hardware failure.");
-
- if (isa_port & NMI_IOCHAN)
- panic("I/O channel check, likely hardware failure.");
-
- /*
- * On a real EISA machine, this will never happen. However it can
- * happen on ISA machines which implement XT style floating point
- * error handling (very rare). Save them from a meaningless panic.
- */
- if (eisa_port == 0xff)
- return(0);
-
- if (eisa_port & ENMI_WATCHDOG)
- panic("EISA watchdog timer expired, likely hardware failure.");
-
- if (eisa_port & ENMI_BUSTIMER)
- panic("EISA bus timeout, likely hardware failure.");
-
- if (eisa_port & ENMI_IOSTATUS)
- panic("EISA I/O port status error.");
-
- printf("\nNMI ISA %x, EISA %x\n", isa_port, eisa_port);
- return(0);
-#endif
-}
-
-/*
- * Fill in default interrupt table (in case of spuruious interrupt
- * during configuration of kernel, setup interrupt control unit
- */
-void
-isa_defaultirq()
-{
- int i;
-
- /* icu vectors */
- for (i = 0; i < ICU_LEN; i++)
- icu_unset(i, (inthand2_t *)NULL);
-
- /* initialize 8259's */
-#if NMCA > 0
- if (MCA_system)
- outb(IO_ICU1, 0x19); /* reset; program device, four bytes */
- else
-#endif
- outb(IO_ICU1, 0x11); /* reset; program device, four bytes */
-
- outb(IO_ICU1+ICU_IMR_OFFSET, NRSVIDT); /* starting at this vector index */
- outb(IO_ICU1+ICU_IMR_OFFSET, IRQ_SLAVE); /* slave on line 7 */
-#ifdef PC98
-#ifdef AUTO_EOI_1
- outb(IO_ICU1+ICU_IMR_OFFSET, 0x1f); /* (master) auto EOI, 8086 mode */
-#else
- outb(IO_ICU1+ICU_IMR_OFFSET, 0x1d); /* (master) 8086 mode */
-#endif
-#else /* IBM-PC */
-#ifdef AUTO_EOI_1
- outb(IO_ICU1+ICU_IMR_OFFSET, 2 | 1); /* auto EOI, 8086 mode */
-#else
- outb(IO_ICU1+ICU_IMR_OFFSET, 1); /* 8086 mode */
-#endif
-#endif /* PC98 */
- outb(IO_ICU1+ICU_IMR_OFFSET, 0xff); /* leave interrupts masked */
- outb(IO_ICU1, 0x0a); /* default to IRR on read */
-#ifndef PC98
- outb(IO_ICU1, 0xc0 | (3 - 1)); /* pri order 3-7, 0-2 (com2 first) */
-#endif /* !PC98 */
-
-#if NMCA > 0
- if (MCA_system)
- outb(IO_ICU2, 0x19); /* reset; program device, four bytes */
- else
-#endif
- outb(IO_ICU2, 0x11); /* reset; program device, four bytes */
-
- outb(IO_ICU2+ICU_IMR_OFFSET, NRSVIDT+8); /* staring at this vector index */
- outb(IO_ICU2+ICU_IMR_OFFSET, ICU_SLAVEID); /* my slave id is 7 */
-#ifdef PC98
- outb(IO_ICU2+ICU_IMR_OFFSET,9); /* 8086 mode */
-#else /* IBM-PC */
-#ifdef AUTO_EOI_2
- outb(IO_ICU2+ICU_IMR_OFFSET, 2 | 1); /* auto EOI, 8086 mode */
-#else
- outb(IO_ICU2+ICU_IMR_OFFSET,1); /* 8086 mode */
-#endif
-#endif /* PC98 */
- outb(IO_ICU2+ICU_IMR_OFFSET, 0xff); /* leave interrupts masked */
- outb(IO_ICU2, 0x0a); /* default to IRR on read */
-}
-
-/*
- * Caught a stray interrupt, notify
- */
-static void
-isa_strayintr(vcookiep)
- void *vcookiep;
-{
- int intr = (void **)vcookiep - &intr_unit[0];
-
- /* DON'T BOTHER FOR NOW! */
- /* for some reason, we get bursts of intr #7, even if not enabled! */
- /*
- * Well the reason you got bursts of intr #7 is because someone
- * raised an interrupt line and dropped it before the 8259 could
- * prioritize it. This is documented in the intel data book. This
- * means you have BAD hardware! I have changed this so that only
- * the first 5 get logged, then it quits logging them, and puts
- * out a special message. rgrimes 3/25/1993
- */
- /*
- * XXX TODO print a different message for #7 if it is for a
- * glitch. Glitches can be distinguished from real #7's by
- * testing that the in-service bit is _not_ set. The test
- * must be done before sending an EOI so it can't be done if
- * we are using AUTO_EOI_1.
- */
- if (intrcnt[1 + intr] <= 5)
- log(LOG_ERR, "stray irq %d\n", intr);
- if (intrcnt[1 + intr] == 5)
- log(LOG_CRIT,
- "too many stray irq %d's; not logging any more\n", intr);
-}
-
-#if NISA > 0
-/*
- * Return a bitmap of the current interrupt requests. This is 8259-specific
- * and is only suitable for use at probe time.
- */
-intrmask_t
-isa_irq_pending()
-{
- u_char irr1;
- u_char irr2;
-
- irr1 = inb(IO_ICU1);
- irr2 = inb(IO_ICU2);
- return ((irr2 << 8) | irr1);
-}
-#endif
-
-int
-update_intr_masks(void)
-{
- int intr, n=0;
- u_int mask,*maskptr;
-
- for (intr=0; intr < ICU_LEN; intr ++) {
-#if defined(APIC_IO)
- /* no 8259 SLAVE to ignore */
-#else
- if (intr==ICU_SLAVEID) continue; /* ignore 8259 SLAVE output */
-#endif /* APIC_IO */
- maskptr = intr_mptr[intr];
- if (!maskptr)
- continue;
- *maskptr |= SWI_CLOCK_MASK | (1 << intr);
- mask = *maskptr;
- if (mask != intr_mask[intr]) {
-#if 0
- printf ("intr_mask[%2d] old=%08x new=%08x ptr=%p.\n",
- intr, intr_mask[intr], mask, maskptr);
-#endif
- intr_mask[intr]=mask;
- n++;
- }
-
- }
- return (n);
-}
-
-static void
-update_intrname(int intr, char *name)
-{
- char buf[32];
- char *cp;
- int name_index, off, strayintr;
-
- /*
- * Initialise strings for bitbucket and stray interrupt counters.
- * These have statically allocated indices 0 and 1 through ICU_LEN.
- */
- if (intrnames[0] == '\0') {
- off = sprintf(intrnames, "???") + 1;
- for (strayintr = 0; strayintr < ICU_LEN; strayintr++)
- off += sprintf(intrnames + off, "stray irq%d",
- strayintr) + 1;
- }
-
- if (name == NULL)
- name = "???";
- if (snprintf(buf, sizeof(buf), "%s irq%d", name, intr) >= sizeof(buf))
- goto use_bitbucket;
-
- /*
- * Search for `buf' in `intrnames'. In the usual case when it is
- * not found, append it to the end if there is enough space (the \0
- * terminator for the previous string, if any, becomes a separator).
- */
- for (cp = intrnames, name_index = 0;
- cp != eintrnames && name_index < NR_INTRNAMES;
- cp += strlen(cp) + 1, name_index++) {
- if (*cp == '\0') {
- if (strlen(buf) >= eintrnames - cp)
- break;
- strcpy(cp, buf);
- goto found;
- }
- if (strcmp(cp, buf) == 0)
- goto found;
- }
-
-use_bitbucket:
- printf("update_intrname: counting %s irq%d as %s\n", name, intr,
- intrnames);
- name_index = 0;
-found:
- intr_countp[intr] = &intrcnt[name_index];
-}
-
-int
-icu_setup(int intr, inthand2_t *handler, void *arg, u_int *maskptr, int flags)
-{
-#ifdef FAST_HI
- int select; /* the select register is 8 bits */
- int vector;
- u_int32_t value; /* the window register is 32 bits */
-#endif /* FAST_HI */
- u_long ef;
- u_int mask = (maskptr ? *maskptr : 0);
-
-#if defined(APIC_IO)
- if ((u_int)intr >= ICU_LEN) /* no 8259 SLAVE to ignore */
-#else
- if ((u_int)intr >= ICU_LEN || intr == ICU_SLAVEID)
-#endif /* APIC_IO */
- if (intr_handler[intr] != isa_strayintr)
- return (EBUSY);
-
- ef = read_eflags();
- disable_intr();
- intr_handler[intr] = handler;
- intr_mptr[intr] = maskptr;
- intr_mask[intr] = mask | SWI_CLOCK_MASK | (1 << intr);
- intr_unit[intr] = arg;
-#ifdef FAST_HI
- if (flags & INTR_FAST) {
- vector = TPR_FAST_INTS + intr;
- setidt(vector, fastintr[intr],
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- }
- else {
- vector = TPR_SLOW_INTS + intr;
-#ifdef APIC_INTR_REORDER
-#ifdef APIC_INTR_HIGHPRI_CLOCK
- /* XXX: Hack (kludge?) for more accurate clock. */
- if (intr == apic_8254_intr || intr == 8) {
- vector = TPR_FAST_INTS + intr;
- }
-#endif
-#endif
- setidt(vector, slowintr[intr],
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- }
-#ifdef APIC_INTR_REORDER
- set_lapic_isrloc(intr, vector);
-#endif
- /*
- * Reprogram the vector in the IO APIC.
- */
- if (int_to_apicintpin[intr].ioapic >= 0) {
- select = int_to_apicintpin[intr].redirindex;
- value = io_apic_read(int_to_apicintpin[intr].ioapic,
- select) & ~IOART_INTVEC;
- io_apic_write(int_to_apicintpin[intr].ioapic,
- select, value | vector);
- }
-#else
- setidt(ICU_OFFSET + intr,
- flags & INTR_FAST ? fastintr[intr] : slowintr[intr],
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-#endif /* FAST_HI */
- INTREN(1 << intr);
- MPINTR_UNLOCK();
- write_eflags(ef);
- return (0);
-}
-
-int
-icu_unset(intr, handler)
- int intr;
- inthand2_t *handler;
-{
- u_long ef;
-
- if ((u_int)intr >= ICU_LEN || handler != intr_handler[intr])
- return (EINVAL);
-
- INTRDIS(1 << intr);
- ef = read_eflags();
- disable_intr();
- intr_countp[intr] = &intrcnt[1 + intr];
- intr_handler[intr] = isa_strayintr;
- intr_mptr[intr] = NULL;
- intr_mask[intr] = HWI_MASK | SWI_MASK;
- intr_unit[intr] = &intr_unit[intr];
-#ifdef FAST_HI_XXX
- /* XXX how do I re-create dvp here? */
- setidt(flags & INTR_FAST ? TPR_FAST_INTS + intr : TPR_SLOW_INTS + intr,
- slowintr[intr], SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-#else /* FAST_HI */
-#ifdef APIC_INTR_REORDER
- set_lapic_isrloc(intr, ICU_OFFSET + intr);
-#endif
- setidt(ICU_OFFSET + intr, slowintr[intr], SDT_SYS386IGT, SEL_KPL,
- GSEL(GCODE_SEL, SEL_KPL));
-#endif /* FAST_HI */
- MPINTR_UNLOCK();
- write_eflags(ef);
- return (0);
-}
-
-/* The following notice applies beyond this point in the file */
-
-/*
- * Copyright (c) 1997, Stefan Esser <se@freebsd.org>
- * 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 unmodified, 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.
- *
- * $FreeBSD$
- *
- */
-
-typedef struct intrec {
- intrmask_t mask;
- inthand2_t *handler;
- void *argument;
- struct intrec *next;
- char *name;
- int intr;
- intrmask_t *maskptr;
- int flags;
-} intrec;
-
-static intrec *intreclist_head[ICU_LEN];
-
-/*
- * The interrupt multiplexer calls each of the handlers in turn. The
- * ipl is initially quite low. It is raised as necessary for each call
- * and lowered after the call. Thus out of order handling is possible
- * even for interrupts of the same type. This is probably no more
- * harmful than out of order handling in general (not harmful except
- * for real time response which we don't support anyway).
- */
-static void
-intr_mux(void *arg)
-{
- intrec *p;
- intrmask_t oldspl;
-
- for (p = arg; p != NULL; p = p->next) {
- oldspl = splq(p->mask);
- p->handler(p->argument);
- splx(oldspl);
- }
-}
-
-static intrec*
-find_idesc(unsigned *maskptr, int irq)
-{
- intrec *p = intreclist_head[irq];
-
- while (p && p->maskptr != maskptr)
- p = p->next;
-
- return (p);
-}
-
-static intrec**
-find_pred(intrec *idesc, int irq)
-{
- intrec **pp = &intreclist_head[irq];
- intrec *p = *pp;
-
- while (p != idesc) {
- if (p == NULL)
- return (NULL);
- pp = &p->next;
- p = *pp;
- }
- return (pp);
-}
-
-/*
- * Both the low level handler and the shared interrupt multiplexer
- * block out further interrupts as set in the handlers "mask", while
- * the handler is running. In fact *maskptr should be used for this
- * purpose, but since this requires one more pointer dereference on
- * each interrupt, we rather bother update "mask" whenever *maskptr
- * changes. The function "update_masks" should be called **after**
- * all manipulation of the linked list of interrupt handlers hung
- * off of intrdec_head[irq] is complete, since the chain of handlers
- * will both determine the *maskptr values and the instances of mask
- * that are fixed. This function should be called with the irq for
- * which a new handler has been add blocked, since the masks may not
- * yet know about the use of this irq for a device of a certain class.
- */
-
-static void
-update_mux_masks(void)
-{
- int irq;
- for (irq = 0; irq < ICU_LEN; irq++) {
- intrec *idesc = intreclist_head[irq];
- while (idesc != NULL) {
- if (idesc->maskptr != NULL) {
- /* our copy of *maskptr may be stale, refresh */
- idesc->mask = *idesc->maskptr;
- }
- idesc = idesc->next;
- }
- }
-}
-
-static void
-update_masks(intrmask_t *maskptr, int irq)
-{
- intrmask_t mask = 1 << irq;
-
- if (maskptr == NULL)
- return;
-
- if (find_idesc(maskptr, irq) == NULL) {
- /* no reference to this maskptr was found in this irq's chain */
- if ((*maskptr & mask) == 0)
- return;
- /* the irq was included in the classes mask, remove it */
- *maskptr &= ~mask;
- } else {
- /* a reference to this maskptr was found in this irq's chain */
- if ((*maskptr & mask) != 0)
- return;
- /* put the irq into the classes mask */
- *maskptr |= mask;
- }
- /* we need to update all values in the intr_mask[irq] array */
- update_intr_masks();
- /* update mask in chains of the interrupt multiplex handler as well */
- update_mux_masks();
-}
-
-/*
- * Add interrupt handler to linked list hung off of intreclist_head[irq]
- * and install shared interrupt multiplex handler, if necessary
- */
-
-static int
-add_intrdesc(intrec *idesc)
-{
- int irq = idesc->intr;
-
- intrec *head = intreclist_head[irq];
-
- if (head == NULL) {
- /* first handler for this irq, just install it */
- if (icu_setup(irq, idesc->handler, idesc->argument,
- idesc->maskptr, idesc->flags) != 0)
- return (-1);
-
- update_intrname(irq, idesc->name);
- /* keep reference */
- intreclist_head[irq] = idesc;
- } else {
- if ((idesc->flags & INTR_EXCL) != 0
- || (head->flags & INTR_EXCL) != 0) {
- /*
- * can't append new handler, if either list head or
- * new handler do not allow interrupts to be shared
- */
- if (bootverbose)
- printf("\tdevice combination doesn't support "
- "shared irq%d\n", irq);
- return (-1);
- }
- if (head->next == NULL) {
- /*
- * second handler for this irq, replace device driver's
- * handler by shared interrupt multiplexer function
- */
- icu_unset(irq, head->handler);
- if (icu_setup(irq, intr_mux, head, 0, 0) != 0)
- return (-1);
- if (bootverbose)
- printf("\tusing shared irq%d.\n", irq);
- update_intrname(irq, "mux");
- }
- /* just append to the end of the chain */
- while (head->next != NULL)
- head = head->next;
- head->next = idesc;
- }
- update_masks(idesc->maskptr, irq);
- return (0);
-}
-
-/*
- * Create and activate an interrupt handler descriptor data structure.
- *
- * The dev_instance pointer is required for resource management, and will
- * only be passed through to resource_claim().
- *
- * There will be functions that derive a driver and unit name from a
- * dev_instance variable, and those functions will be used to maintain the
- * interrupt counter label array referenced by systat and vmstat to report
- * device interrupt rates (->update_intrlabels).
- *
- * Add the interrupt handler descriptor data structure created by an
- * earlier call of create_intr() to the linked list for its irq and
- * adjust the interrupt masks if necessary.
- */
-
-intrec *
-inthand_add(const char *name, int irq, inthand2_t handler, void *arg,
- intrmask_t *maskptr, int flags)
-{
- intrec *idesc;
- int errcode = -1;
- intrmask_t oldspl;
-
- if (ICU_LEN > 8 * sizeof *maskptr) {
- printf("create_intr: ICU_LEN of %d too high for %d bit intrmask\n",
- ICU_LEN, 8 * sizeof *maskptr);
- return (NULL);
- }
- if ((unsigned)irq >= ICU_LEN) {
- printf("create_intr: requested irq%d too high, limit is %d\n",
- irq, ICU_LEN -1);
- return (NULL);
- }
-
- idesc = malloc(sizeof *idesc, M_DEVBUF, M_WAITOK);
- if (idesc == NULL)
- return NULL;
- bzero(idesc, sizeof *idesc);
-
- if (name == NULL)
- name = "???";
- idesc->name = malloc(strlen(name) + 1, M_DEVBUF, M_WAITOK);
- if (idesc->name == NULL) {
- free(idesc, M_DEVBUF);
- return NULL;
- }
- strcpy(idesc->name, name);
-
- idesc->handler = handler;
- idesc->argument = arg;
- idesc->maskptr = maskptr;
- idesc->intr = irq;
- idesc->flags = flags;
-
- /* block this irq */
- oldspl = splq(1 << irq);
-
- /* add irq to class selected by maskptr */
- errcode = add_intrdesc(idesc);
- splx(oldspl);
-
- if (errcode != 0) {
- if (bootverbose)
- printf("\tintr_connect(irq%d) failed, result=%d\n",
- irq, errcode);
- free(idesc->name, M_DEVBUF);
- free(idesc, M_DEVBUF);
- idesc = NULL;
- }
-
- return (idesc);
-}
-
-/*
- * Deactivate and remove the interrupt handler descriptor data connected
- * created by an earlier call of intr_connect() from the linked list and
- * adjust theinterrupt masks if necessary.
- *
- * Return the memory held by the interrupt handler descriptor data structure
- * to the system. Make sure, the handler is not actively used anymore, before.
- */
-
-int
-inthand_remove(intrec *idesc)
-{
- intrec **hook, *head;
- int irq;
- int errcode = 0;
- intrmask_t oldspl;
-
- if (idesc == NULL)
- return (-1);
-
- irq = idesc->intr;
-
- /* find pointer that keeps the reference to this interrupt descriptor */
- hook = find_pred(idesc, irq);
- if (hook == NULL)
- return (-1);
-
- /* make copy of original list head, the line after may overwrite it */
- head = intreclist_head[irq];
-
- /* unlink: make predecessor point to idesc->next instead of to idesc */
- *hook = idesc->next;
-
- /* now check whether the element we removed was the list head */
- if (idesc == head) {
-
- oldspl = splq(1 << irq);
-
- /* check whether the new list head is the only element on list */
- head = intreclist_head[irq];
- if (head != NULL) {
- icu_unset(irq, intr_mux);
- if (head->next != NULL) {
- /* install the multiplex handler with new list head as argument */
- errcode = icu_setup(irq, intr_mux, head, 0, 0);
- if (errcode == 0)
- update_intrname(irq, NULL);
- } else {
- /* install the one remaining handler for this irq */
- errcode = icu_setup(irq, head->handler,
- head->argument,
- head->maskptr, head->flags);
- if (errcode == 0)
- update_intrname(irq, head->name);
- }
- } else {
- /* revert to old handler, eg: strayintr */
- icu_unset(irq, idesc->handler);
- }
- splx(oldspl);
- }
- update_masks(idesc->maskptr, irq);
- free(idesc, M_DEVBUF);
- return (0);
-}
diff --git a/sys/i386/pci/pci_bus.c b/sys/i386/pci/pci_bus.c
deleted file mode 100644
index f09c907a4346..000000000000
--- a/sys/i386/pci/pci_bus.c
+++ /dev/null
@@ -1,544 +0,0 @@
-/*
- * Copyright (c) 1997, Stefan Esser <se@freebsd.org>
- * 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 unmodified, 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.
- *
- * $FreeBSD$
- *
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/kernel.h>
-
-#include <pci/pcivar.h>
-#include <pci/pcireg.h>
-#include <i386/isa/pcibus.h>
-
-static int cfgmech;
-static int devmax;
-
-/* enable configuration space accesses and return data port address */
-
-static int
-pci_cfgenable(unsigned bus, unsigned slot, unsigned func, int reg, int bytes)
-{
- int dataport = 0;
-
- if (bus <= PCI_BUSMAX
- && slot < devmax
- && func <= PCI_FUNCMAX
- && reg <= PCI_REGMAX
- && bytes != 3
- && (unsigned) bytes <= 4
- && (reg & (bytes -1)) == 0) {
- switch (cfgmech) {
- case 1:
- outl(CONF1_ADDR_PORT, (1 << 31)
- | (bus << 16) | (slot << 11)
- | (func << 8) | (reg & ~0x03));
- dataport = CONF1_DATA_PORT + (reg & 0x03);
- break;
- case 2:
- outb(CONF2_ENABLE_PORT, 0xf0 | (func << 1));
- outb(CONF2_FORWARD_PORT, bus);
- dataport = 0xc000 | (slot << 8) | reg;
- break;
- }
- }
- return (dataport);
-}
-
-/* disable configuration space accesses */
-
-static void
-pci_cfgdisable(void)
-{
- switch (cfgmech) {
- case 1:
- outl(CONF1_ADDR_PORT, 0);
- break;
- case 2:
- outb(CONF2_ENABLE_PORT, 0);
- outb(CONF2_FORWARD_PORT, 0);
- break;
- }
-}
-
-/* read configuration space register */
-
-int
-pci_cfgread(pcicfgregs *cfg, int reg, int bytes)
-{
- int data = -1;
- int port;
-
- port = pci_cfgenable(cfg->bus, cfg->slot, cfg->func, reg, bytes);
-
- if (port != 0) {
- switch (bytes) {
- case 1:
- data = inb(port);
- break;
- case 2:
- data = inw(port);
- break;
- case 4:
- data = inl(port);
- break;
- }
- pci_cfgdisable();
- }
- return (data);
-}
-
-/* write configuration space register */
-
-void
-pci_cfgwrite(pcicfgregs *cfg, int reg, int data, int bytes)
-{
- int port;
-
- port = pci_cfgenable(cfg->bus, cfg->slot, cfg->func, reg, bytes);
- if (port != 0) {
- switch (bytes) {
- case 1:
- outb(port, data);
- break;
- case 2:
- outw(port, data);
- break;
- case 4:
- outl(port, data);
- break;
- }
- pci_cfgdisable();
- }
-}
-
-/* check whether the configuration mechanism has been correct identified */
-
-static int
-pci_cfgcheck(int maxdev)
-{
- u_char device;
-
- if (bootverbose)
- printf("pci_cfgcheck:\tdevice ");
-
- for (device = 0; device < maxdev; device++) {
- unsigned id, class, header;
- if (bootverbose)
- printf("%d ", device);
-
- id = inl(pci_cfgenable(0, device, 0, 0, 4));
- if (id == 0 || id == -1)
- continue;
-
- class = inl(pci_cfgenable(0, device, 0, 8, 4)) >> 8;
- if (bootverbose)
- printf("[class=%06x] ", class);
- if (class == 0 || (class & 0xf870ff) != 0)
- continue;
-
- header = inb(pci_cfgenable(0, device, 0, 14, 1));
- if (bootverbose)
- printf("[hdr=%02x] ", header);
- if ((header & 0x7e) != 0)
- continue;
-
- if (bootverbose)
- printf("is there (id=%08x)\n", id);
-
- pci_cfgdisable();
- return (1);
- }
- if (bootverbose)
- printf("-- nothing found\n");
-
- pci_cfgdisable();
- return (0);
-}
-
-static int
-pci_cfgopen(void)
-{
- unsigned long mode1res,oldval1;
- unsigned char mode2res,oldval2;
-
- oldval1 = inl(CONF1_ADDR_PORT);
-
- if (bootverbose) {
- printf("pci_open(1):\tmode 1 addr port (0x0cf8) is 0x%08lx\n",
- oldval1);
- }
-
- if ((oldval1 & CONF1_ENABLE_MSK) == 0) {
-
- cfgmech = 1;
- devmax = 32;
-
- outl(CONF1_ADDR_PORT, CONF1_ENABLE_CHK);
- outb(CONF1_ADDR_PORT +3, 0);
- mode1res = inl(CONF1_ADDR_PORT);
- outl(CONF1_ADDR_PORT, oldval1);
-
- if (bootverbose)
- printf("pci_open(1a):\tmode1res=0x%08lx (0x%08lx)\n",
- mode1res, CONF1_ENABLE_CHK);
-
- if (mode1res) {
- if (pci_cfgcheck(32))
- return (cfgmech);
- }
-
- outl(CONF1_ADDR_PORT, CONF1_ENABLE_CHK1);
- mode1res = inl(CONF1_ADDR_PORT);
- outl(CONF1_ADDR_PORT, oldval1);
-
- if (bootverbose)
- printf("pci_open(1b):\tmode1res=0x%08lx (0x%08lx)\n",
- mode1res, CONF1_ENABLE_CHK1);
-
- if ((mode1res & CONF1_ENABLE_MSK1) == CONF1_ENABLE_RES1) {
- if (pci_cfgcheck(32))
- return (cfgmech);
- }
- }
-
- oldval2 = inb(CONF2_ENABLE_PORT);
-
- if (bootverbose) {
- printf("pci_open(2):\tmode 2 enable port (0x0cf8) is 0x%02x\n",
- oldval2);
- }
-
- if ((oldval2 & 0xf0) == 0) {
-
- cfgmech = 2;
- devmax = 16;
-
- outb(CONF2_ENABLE_PORT, CONF2_ENABLE_CHK);
- mode2res = inb(CONF2_ENABLE_PORT);
- outb(CONF2_ENABLE_PORT, oldval2);
-
- if (bootverbose)
- printf("pci_open(2a):\tmode2res=0x%02x (0x%02x)\n",
- mode2res, CONF2_ENABLE_CHK);
-
- if (mode2res == CONF2_ENABLE_RES) {
- if (bootverbose)
- printf("pci_open(2a):\tnow trying mechanism 2\n");
-
- if (pci_cfgcheck(16))
- return (cfgmech);
- }
- }
-
- cfgmech = 0;
- devmax = 0;
- return (cfgmech);
-}
-
-static devclass_t pcib_devclass;
-
-static const char *
-nexus_pcib_is_host_bridge(pcicfgregs *cfg,
- u_int32_t id, u_int8_t class, u_int8_t subclass,
- u_int8_t *busnum)
-{
- const char *s = NULL;
- static u_int8_t pxb[4]; /* hack for 450nx */
-
- *busnum = 0;
-
- switch (id) {
- case 0x12258086:
- s = "Intel 824?? host to PCI bridge";
- /* XXX This is a guess */
- /* *busnum = pci_cfgread(cfg, 0x41, 1); */
- *busnum = cfg->bus;
- break;
- case 0x71208086:
- s = "Intel 82810 (i810 GMCH) Host To Hub bridge";
- break;
- case 0x71228086:
- s = "Intel 82810-DC100 (i810-DC100 GMCH) Host To Hub bridge";
- break;
- case 0x71248086:
- s = "Intel 82810E (i810E GMCH) Host To Hub bridge";
- break;
- case 0x71808086:
- s = "Intel 82443LX (440 LX) host to PCI bridge";
- break;
- case 0x71908086:
- s = "Intel 82443BX (440 BX) host to PCI bridge";
- break;
- case 0x71928086:
- s = "Intel 82443BX host to PCI bridge (AGP disabled)";
- break;
- case 0x71a08086:
- s = "Intel 82443GX host to PCI bridge";
- break;
- case 0x71a18086:
- s = "Intel 82443GX host to AGP bridge";
- break;
- case 0x71a28086:
- s = "Intel 82443GX host to PCI bridge (AGP disabled)";
- break;
- case 0x84c48086:
- s = "Intel 82454KX/GX (Orion) host to PCI bridge";
- *busnum = pci_cfgread(cfg, 0x4a, 1);
- break;
- case 0x84ca8086:
- /*
- * For the 450nx chipset, there is a whole bundle of
- * things pretending to be host bridges. The MIOC will
- * be seen first and isn't really a pci bridge (the
- * actual busses are attached to the PXB's). We need to
- * read the registers of the MIOC to figure out the
- * bus numbers for the PXB channels.
- *
- * Since the MIOC doesn't have a pci bus attached, we
- * pretend it wasn't there.
- */
- pxb[0] = pci_cfgread(cfg, 0xd0, 1); /* BUSNO[0] */
- pxb[1] = pci_cfgread(cfg, 0xd1, 1) + 1; /* SUBA[0]+1 */
- pxb[2] = pci_cfgread(cfg, 0xd3, 1); /* BUSNO[1] */
- pxb[3] = pci_cfgread(cfg, 0xd4, 1) + 1; /* SUBA[1]+1 */
- return NULL;
- case 0x84cb8086:
- switch (cfg->slot) {
- case 0x12:
- s = "Intel 82454NX PXB#0, Bus#A";
- *busnum = pxb[0];
- break;
- case 0x13:
- s = "Intel 82454NX PXB#0, Bus#B";
- *busnum = pxb[1];
- break;
- case 0x14:
- s = "Intel 82454NX PXB#1, Bus#A";
- *busnum = pxb[2];
- break;
- case 0x15:
- s = "Intel 82454NX PXB#1, Bus#B";
- *busnum = pxb[3];
- break;
- }
- break;
-
- /* AMD -- vendor 0x1022 */
- case 0x70061022:
- s = "AMD-751 host to PCI bridge";
- break;
-
- /* SiS -- vendor 0x1039 */
- case 0x04961039:
- s = "SiS 85c496";
- break;
- case 0x04061039:
- s = "SiS 85c501";
- break;
- case 0x06011039:
- s = "SiS 85c601";
- break;
- case 0x55911039:
- s = "SiS 5591 host to PCI bridge";
- break;
- case 0x00011039:
- s = "SiS 5591 host to AGP bridge";
- break;
-
- /* VLSI -- vendor 0x1004 */
- case 0x00051004:
- s = "VLSI 82C592 Host to PCI bridge";
- break;
-
- /* XXX Here is MVP3, I got the datasheet but NO M/B to test it */
- /* totally. Please let me know if anything wrong. -F */
- /* XXX need info on the MVP3 -- any takers? */
- case 0x05981106:
- s = "VIA 82C598MVP (Apollo MVP3) host bridge";
- break;
-
- /* AcerLabs -- vendor 0x10b9 */
- /* Funny : The datasheet told me vendor id is "10b8",sub-vendor */
- /* id is '10b9" but the register always shows "10b9". -Foxfair */
- case 0x154110b9:
- s = "AcerLabs M1541 (Aladdin-V) PCI host bridge";
- break;
-
- /* OPTi -- vendor 0x1045 */
- case 0xc8221045:
- s = "OPTi 82C822 host to PCI Bridge";
- break;
-
- /* RCC -- vendor 0x1166 */
- case 0x00051166:
- s = "RCC HE host to PCI bridge";
- *busnum = pci_cfgread(cfg, 0x44, 1);
- break;
-
- case 0x00061166:
- /* FALLTHROUGH */
- case 0x00081166:
- s = "RCC host to PCI bridge";
- *busnum = pci_cfgread(cfg, 0x44, 1);
- break;
-
- case 0x00091166:
- s = "RCC LE host to PCI bridge";
- *busnum = pci_cfgread(cfg, 0x44, 1);
- break;
-
- /* Integrated Micro Solutions -- vendor 0x10e0 */
- case 0x884910e0:
- s = "Integrated Micro Solutions VL Bridge";
- break;
-
- default:
- if (class == PCIC_BRIDGE && subclass == PCIS_BRIDGE_HOST)
- s = "Host to PCI bridge";
- break;
- }
-
- return s;
-}
-
-/*
- * Scan the first pci bus for host-pci bridges and add pcib instances
- * to the nexus for each bridge.
- */
-static void
-nexus_pcib_identify(driver_t *driver, device_t parent)
-{
- pcicfgregs probe;
- u_int8_t hdrtype;
- int found = 0;
- int pcifunchigh;
- int found824xx = 0;
-
- if (pci_cfgopen() == 0)
- return;
- probe.hose = 0;
- probe.bus = 0;
- retry:
- for (probe.slot = 0; probe.slot <= PCI_SLOTMAX; probe.slot++) {
- probe.func = 0;
- hdrtype = pci_cfgread(&probe, PCIR_HEADERTYPE, 1);
- if (hdrtype & PCIM_MFDEV)
- pcifunchigh = 7;
- else
- pcifunchigh = 0;
- for (probe.func = 0;
- probe.func <= pcifunchigh;
- probe.func++) {
- /*
- * Read the IDs and class from the device.
- */
- u_int32_t id;
- u_int8_t class, subclass, busnum;
- device_t child;
- const char *s;
-
- id = pci_cfgread(&probe, PCIR_DEVVENDOR, 4);
- if (id == -1)
- continue;
- class = pci_cfgread(&probe, PCIR_CLASS, 1);
- subclass = pci_cfgread(&probe, PCIR_SUBCLASS, 1);
-
- s = nexus_pcib_is_host_bridge(&probe, id,
- class, subclass,
- &busnum);
- if (s) {
- /*
- * Add at priority 100 to make sure we
- * go after any motherboard resources
- */
- child = BUS_ADD_CHILD(parent, 100,
- "pcib", busnum);
- device_set_desc(child, s);
- found = 1;
- if (id == 0x12258086)
- found824xx = 1;
- }
- }
- }
- if (found824xx && probe.bus == 0) {
- probe.bus++;
- goto retry;
- }
-
- /*
- * Make sure we add at least one bridge since some old
- * hardware doesn't actually have a host-pci bridge device.
- * Note that pci_cfgopen() thinks we have PCI devices..
- */
- if (!found) {
- if (bootverbose)
- printf(
- "nexus_pcib_identify: no bridge found, adding pcib0 anyway\n");
- BUS_ADD_CHILD(parent, 100, "pcib", 0);
- }
-}
-
-static int
-nexus_pcib_probe(device_t dev)
-{
- if (pci_cfgopen() != 0) {
- device_add_child(dev, "pci", device_get_unit(dev));
- return 0;
- }
- return ENXIO;
-}
-
-static device_method_t nexus_pcib_methods[] = {
- /* Device interface */
- DEVMETHOD(device_identify, nexus_pcib_identify),
- DEVMETHOD(device_probe, nexus_pcib_probe),
- DEVMETHOD(device_attach, bus_generic_attach),
- DEVMETHOD(device_shutdown, bus_generic_shutdown),
- DEVMETHOD(device_suspend, bus_generic_suspend),
- DEVMETHOD(device_resume, bus_generic_resume),
-
- /* Bus interface */
- DEVMETHOD(bus_print_child, bus_generic_print_child),
- DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
- DEVMETHOD(bus_release_resource, bus_generic_release_resource),
- DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
- DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
- DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
- DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
-
- { 0, 0 }
-};
-
-static driver_t nexus_pcib_driver = {
- "pcib",
- nexus_pcib_methods,
- 1,
-};
-
-DRIVER_MODULE(pcib, nexus, nexus_pcib_driver, pcib_devclass, 0, 0);
diff --git a/sys/i386/pci/pci_cfgreg.c b/sys/i386/pci/pci_cfgreg.c
deleted file mode 100644
index f09c907a4346..000000000000
--- a/sys/i386/pci/pci_cfgreg.c
+++ /dev/null
@@ -1,544 +0,0 @@
-/*
- * Copyright (c) 1997, Stefan Esser <se@freebsd.org>
- * 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 unmodified, 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.
- *
- * $FreeBSD$
- *
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/kernel.h>
-
-#include <pci/pcivar.h>
-#include <pci/pcireg.h>
-#include <i386/isa/pcibus.h>
-
-static int cfgmech;
-static int devmax;
-
-/* enable configuration space accesses and return data port address */
-
-static int
-pci_cfgenable(unsigned bus, unsigned slot, unsigned func, int reg, int bytes)
-{
- int dataport = 0;
-
- if (bus <= PCI_BUSMAX
- && slot < devmax
- && func <= PCI_FUNCMAX
- && reg <= PCI_REGMAX
- && bytes != 3
- && (unsigned) bytes <= 4
- && (reg & (bytes -1)) == 0) {
- switch (cfgmech) {
- case 1:
- outl(CONF1_ADDR_PORT, (1 << 31)
- | (bus << 16) | (slot << 11)
- | (func << 8) | (reg & ~0x03));
- dataport = CONF1_DATA_PORT + (reg & 0x03);
- break;
- case 2:
- outb(CONF2_ENABLE_PORT, 0xf0 | (func << 1));
- outb(CONF2_FORWARD_PORT, bus);
- dataport = 0xc000 | (slot << 8) | reg;
- break;
- }
- }
- return (dataport);
-}
-
-/* disable configuration space accesses */
-
-static void
-pci_cfgdisable(void)
-{
- switch (cfgmech) {
- case 1:
- outl(CONF1_ADDR_PORT, 0);
- break;
- case 2:
- outb(CONF2_ENABLE_PORT, 0);
- outb(CONF2_FORWARD_PORT, 0);
- break;
- }
-}
-
-/* read configuration space register */
-
-int
-pci_cfgread(pcicfgregs *cfg, int reg, int bytes)
-{
- int data = -1;
- int port;
-
- port = pci_cfgenable(cfg->bus, cfg->slot, cfg->func, reg, bytes);
-
- if (port != 0) {
- switch (bytes) {
- case 1:
- data = inb(port);
- break;
- case 2:
- data = inw(port);
- break;
- case 4:
- data = inl(port);
- break;
- }
- pci_cfgdisable();
- }
- return (data);
-}
-
-/* write configuration space register */
-
-void
-pci_cfgwrite(pcicfgregs *cfg, int reg, int data, int bytes)
-{
- int port;
-
- port = pci_cfgenable(cfg->bus, cfg->slot, cfg->func, reg, bytes);
- if (port != 0) {
- switch (bytes) {
- case 1:
- outb(port, data);
- break;
- case 2:
- outw(port, data);
- break;
- case 4:
- outl(port, data);
- break;
- }
- pci_cfgdisable();
- }
-}
-
-/* check whether the configuration mechanism has been correct identified */
-
-static int
-pci_cfgcheck(int maxdev)
-{
- u_char device;
-
- if (bootverbose)
- printf("pci_cfgcheck:\tdevice ");
-
- for (device = 0; device < maxdev; device++) {
- unsigned id, class, header;
- if (bootverbose)
- printf("%d ", device);
-
- id = inl(pci_cfgenable(0, device, 0, 0, 4));
- if (id == 0 || id == -1)
- continue;
-
- class = inl(pci_cfgenable(0, device, 0, 8, 4)) >> 8;
- if (bootverbose)
- printf("[class=%06x] ", class);
- if (class == 0 || (class & 0xf870ff) != 0)
- continue;
-
- header = inb(pci_cfgenable(0, device, 0, 14, 1));
- if (bootverbose)
- printf("[hdr=%02x] ", header);
- if ((header & 0x7e) != 0)
- continue;
-
- if (bootverbose)
- printf("is there (id=%08x)\n", id);
-
- pci_cfgdisable();
- return (1);
- }
- if (bootverbose)
- printf("-- nothing found\n");
-
- pci_cfgdisable();
- return (0);
-}
-
-static int
-pci_cfgopen(void)
-{
- unsigned long mode1res,oldval1;
- unsigned char mode2res,oldval2;
-
- oldval1 = inl(CONF1_ADDR_PORT);
-
- if (bootverbose) {
- printf("pci_open(1):\tmode 1 addr port (0x0cf8) is 0x%08lx\n",
- oldval1);
- }
-
- if ((oldval1 & CONF1_ENABLE_MSK) == 0) {
-
- cfgmech = 1;
- devmax = 32;
-
- outl(CONF1_ADDR_PORT, CONF1_ENABLE_CHK);
- outb(CONF1_ADDR_PORT +3, 0);
- mode1res = inl(CONF1_ADDR_PORT);
- outl(CONF1_ADDR_PORT, oldval1);
-
- if (bootverbose)
- printf("pci_open(1a):\tmode1res=0x%08lx (0x%08lx)\n",
- mode1res, CONF1_ENABLE_CHK);
-
- if (mode1res) {
- if (pci_cfgcheck(32))
- return (cfgmech);
- }
-
- outl(CONF1_ADDR_PORT, CONF1_ENABLE_CHK1);
- mode1res = inl(CONF1_ADDR_PORT);
- outl(CONF1_ADDR_PORT, oldval1);
-
- if (bootverbose)
- printf("pci_open(1b):\tmode1res=0x%08lx (0x%08lx)\n",
- mode1res, CONF1_ENABLE_CHK1);
-
- if ((mode1res & CONF1_ENABLE_MSK1) == CONF1_ENABLE_RES1) {
- if (pci_cfgcheck(32))
- return (cfgmech);
- }
- }
-
- oldval2 = inb(CONF2_ENABLE_PORT);
-
- if (bootverbose) {
- printf("pci_open(2):\tmode 2 enable port (0x0cf8) is 0x%02x\n",
- oldval2);
- }
-
- if ((oldval2 & 0xf0) == 0) {
-
- cfgmech = 2;
- devmax = 16;
-
- outb(CONF2_ENABLE_PORT, CONF2_ENABLE_CHK);
- mode2res = inb(CONF2_ENABLE_PORT);
- outb(CONF2_ENABLE_PORT, oldval2);
-
- if (bootverbose)
- printf("pci_open(2a):\tmode2res=0x%02x (0x%02x)\n",
- mode2res, CONF2_ENABLE_CHK);
-
- if (mode2res == CONF2_ENABLE_RES) {
- if (bootverbose)
- printf("pci_open(2a):\tnow trying mechanism 2\n");
-
- if (pci_cfgcheck(16))
- return (cfgmech);
- }
- }
-
- cfgmech = 0;
- devmax = 0;
- return (cfgmech);
-}
-
-static devclass_t pcib_devclass;
-
-static const char *
-nexus_pcib_is_host_bridge(pcicfgregs *cfg,
- u_int32_t id, u_int8_t class, u_int8_t subclass,
- u_int8_t *busnum)
-{
- const char *s = NULL;
- static u_int8_t pxb[4]; /* hack for 450nx */
-
- *busnum = 0;
-
- switch (id) {
- case 0x12258086:
- s = "Intel 824?? host to PCI bridge";
- /* XXX This is a guess */
- /* *busnum = pci_cfgread(cfg, 0x41, 1); */
- *busnum = cfg->bus;
- break;
- case 0x71208086:
- s = "Intel 82810 (i810 GMCH) Host To Hub bridge";
- break;
- case 0x71228086:
- s = "Intel 82810-DC100 (i810-DC100 GMCH) Host To Hub bridge";
- break;
- case 0x71248086:
- s = "Intel 82810E (i810E GMCH) Host To Hub bridge";
- break;
- case 0x71808086:
- s = "Intel 82443LX (440 LX) host to PCI bridge";
- break;
- case 0x71908086:
- s = "Intel 82443BX (440 BX) host to PCI bridge";
- break;
- case 0x71928086:
- s = "Intel 82443BX host to PCI bridge (AGP disabled)";
- break;
- case 0x71a08086:
- s = "Intel 82443GX host to PCI bridge";
- break;
- case 0x71a18086:
- s = "Intel 82443GX host to AGP bridge";
- break;
- case 0x71a28086:
- s = "Intel 82443GX host to PCI bridge (AGP disabled)";
- break;
- case 0x84c48086:
- s = "Intel 82454KX/GX (Orion) host to PCI bridge";
- *busnum = pci_cfgread(cfg, 0x4a, 1);
- break;
- case 0x84ca8086:
- /*
- * For the 450nx chipset, there is a whole bundle of
- * things pretending to be host bridges. The MIOC will
- * be seen first and isn't really a pci bridge (the
- * actual busses are attached to the PXB's). We need to
- * read the registers of the MIOC to figure out the
- * bus numbers for the PXB channels.
- *
- * Since the MIOC doesn't have a pci bus attached, we
- * pretend it wasn't there.
- */
- pxb[0] = pci_cfgread(cfg, 0xd0, 1); /* BUSNO[0] */
- pxb[1] = pci_cfgread(cfg, 0xd1, 1) + 1; /* SUBA[0]+1 */
- pxb[2] = pci_cfgread(cfg, 0xd3, 1); /* BUSNO[1] */
- pxb[3] = pci_cfgread(cfg, 0xd4, 1) + 1; /* SUBA[1]+1 */
- return NULL;
- case 0x84cb8086:
- switch (cfg->slot) {
- case 0x12:
- s = "Intel 82454NX PXB#0, Bus#A";
- *busnum = pxb[0];
- break;
- case 0x13:
- s = "Intel 82454NX PXB#0, Bus#B";
- *busnum = pxb[1];
- break;
- case 0x14:
- s = "Intel 82454NX PXB#1, Bus#A";
- *busnum = pxb[2];
- break;
- case 0x15:
- s = "Intel 82454NX PXB#1, Bus#B";
- *busnum = pxb[3];
- break;
- }
- break;
-
- /* AMD -- vendor 0x1022 */
- case 0x70061022:
- s = "AMD-751 host to PCI bridge";
- break;
-
- /* SiS -- vendor 0x1039 */
- case 0x04961039:
- s = "SiS 85c496";
- break;
- case 0x04061039:
- s = "SiS 85c501";
- break;
- case 0x06011039:
- s = "SiS 85c601";
- break;
- case 0x55911039:
- s = "SiS 5591 host to PCI bridge";
- break;
- case 0x00011039:
- s = "SiS 5591 host to AGP bridge";
- break;
-
- /* VLSI -- vendor 0x1004 */
- case 0x00051004:
- s = "VLSI 82C592 Host to PCI bridge";
- break;
-
- /* XXX Here is MVP3, I got the datasheet but NO M/B to test it */
- /* totally. Please let me know if anything wrong. -F */
- /* XXX need info on the MVP3 -- any takers? */
- case 0x05981106:
- s = "VIA 82C598MVP (Apollo MVP3) host bridge";
- break;
-
- /* AcerLabs -- vendor 0x10b9 */
- /* Funny : The datasheet told me vendor id is "10b8",sub-vendor */
- /* id is '10b9" but the register always shows "10b9". -Foxfair */
- case 0x154110b9:
- s = "AcerLabs M1541 (Aladdin-V) PCI host bridge";
- break;
-
- /* OPTi -- vendor 0x1045 */
- case 0xc8221045:
- s = "OPTi 82C822 host to PCI Bridge";
- break;
-
- /* RCC -- vendor 0x1166 */
- case 0x00051166:
- s = "RCC HE host to PCI bridge";
- *busnum = pci_cfgread(cfg, 0x44, 1);
- break;
-
- case 0x00061166:
- /* FALLTHROUGH */
- case 0x00081166:
- s = "RCC host to PCI bridge";
- *busnum = pci_cfgread(cfg, 0x44, 1);
- break;
-
- case 0x00091166:
- s = "RCC LE host to PCI bridge";
- *busnum = pci_cfgread(cfg, 0x44, 1);
- break;
-
- /* Integrated Micro Solutions -- vendor 0x10e0 */
- case 0x884910e0:
- s = "Integrated Micro Solutions VL Bridge";
- break;
-
- default:
- if (class == PCIC_BRIDGE && subclass == PCIS_BRIDGE_HOST)
- s = "Host to PCI bridge";
- break;
- }
-
- return s;
-}
-
-/*
- * Scan the first pci bus for host-pci bridges and add pcib instances
- * to the nexus for each bridge.
- */
-static void
-nexus_pcib_identify(driver_t *driver, device_t parent)
-{
- pcicfgregs probe;
- u_int8_t hdrtype;
- int found = 0;
- int pcifunchigh;
- int found824xx = 0;
-
- if (pci_cfgopen() == 0)
- return;
- probe.hose = 0;
- probe.bus = 0;
- retry:
- for (probe.slot = 0; probe.slot <= PCI_SLOTMAX; probe.slot++) {
- probe.func = 0;
- hdrtype = pci_cfgread(&probe, PCIR_HEADERTYPE, 1);
- if (hdrtype & PCIM_MFDEV)
- pcifunchigh = 7;
- else
- pcifunchigh = 0;
- for (probe.func = 0;
- probe.func <= pcifunchigh;
- probe.func++) {
- /*
- * Read the IDs and class from the device.
- */
- u_int32_t id;
- u_int8_t class, subclass, busnum;
- device_t child;
- const char *s;
-
- id = pci_cfgread(&probe, PCIR_DEVVENDOR, 4);
- if (id == -1)
- continue;
- class = pci_cfgread(&probe, PCIR_CLASS, 1);
- subclass = pci_cfgread(&probe, PCIR_SUBCLASS, 1);
-
- s = nexus_pcib_is_host_bridge(&probe, id,
- class, subclass,
- &busnum);
- if (s) {
- /*
- * Add at priority 100 to make sure we
- * go after any motherboard resources
- */
- child = BUS_ADD_CHILD(parent, 100,
- "pcib", busnum);
- device_set_desc(child, s);
- found = 1;
- if (id == 0x12258086)
- found824xx = 1;
- }
- }
- }
- if (found824xx && probe.bus == 0) {
- probe.bus++;
- goto retry;
- }
-
- /*
- * Make sure we add at least one bridge since some old
- * hardware doesn't actually have a host-pci bridge device.
- * Note that pci_cfgopen() thinks we have PCI devices..
- */
- if (!found) {
- if (bootverbose)
- printf(
- "nexus_pcib_identify: no bridge found, adding pcib0 anyway\n");
- BUS_ADD_CHILD(parent, 100, "pcib", 0);
- }
-}
-
-static int
-nexus_pcib_probe(device_t dev)
-{
- if (pci_cfgopen() != 0) {
- device_add_child(dev, "pci", device_get_unit(dev));
- return 0;
- }
- return ENXIO;
-}
-
-static device_method_t nexus_pcib_methods[] = {
- /* Device interface */
- DEVMETHOD(device_identify, nexus_pcib_identify),
- DEVMETHOD(device_probe, nexus_pcib_probe),
- DEVMETHOD(device_attach, bus_generic_attach),
- DEVMETHOD(device_shutdown, bus_generic_shutdown),
- DEVMETHOD(device_suspend, bus_generic_suspend),
- DEVMETHOD(device_resume, bus_generic_resume),
-
- /* Bus interface */
- DEVMETHOD(bus_print_child, bus_generic_print_child),
- DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
- DEVMETHOD(bus_release_resource, bus_generic_release_resource),
- DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
- DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
- DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
- DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
-
- { 0, 0 }
-};
-
-static driver_t nexus_pcib_driver = {
- "pcib",
- nexus_pcib_methods,
- 1,
-};
-
-DRIVER_MODULE(pcib, nexus, nexus_pcib_driver, pcib_devclass, 0, 0);
diff --git a/sys/i386/pci/pci_pir.c b/sys/i386/pci/pci_pir.c
deleted file mode 100644
index f09c907a4346..000000000000
--- a/sys/i386/pci/pci_pir.c
+++ /dev/null
@@ -1,544 +0,0 @@
-/*
- * Copyright (c) 1997, Stefan Esser <se@freebsd.org>
- * 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 unmodified, 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.
- *
- * $FreeBSD$
- *
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/kernel.h>
-
-#include <pci/pcivar.h>
-#include <pci/pcireg.h>
-#include <i386/isa/pcibus.h>
-
-static int cfgmech;
-static int devmax;
-
-/* enable configuration space accesses and return data port address */
-
-static int
-pci_cfgenable(unsigned bus, unsigned slot, unsigned func, int reg, int bytes)
-{
- int dataport = 0;
-
- if (bus <= PCI_BUSMAX
- && slot < devmax
- && func <= PCI_FUNCMAX
- && reg <= PCI_REGMAX
- && bytes != 3
- && (unsigned) bytes <= 4
- && (reg & (bytes -1)) == 0) {
- switch (cfgmech) {
- case 1:
- outl(CONF1_ADDR_PORT, (1 << 31)
- | (bus << 16) | (slot << 11)
- | (func << 8) | (reg & ~0x03));
- dataport = CONF1_DATA_PORT + (reg & 0x03);
- break;
- case 2:
- outb(CONF2_ENABLE_PORT, 0xf0 | (func << 1));
- outb(CONF2_FORWARD_PORT, bus);
- dataport = 0xc000 | (slot << 8) | reg;
- break;
- }
- }
- return (dataport);
-}
-
-/* disable configuration space accesses */
-
-static void
-pci_cfgdisable(void)
-{
- switch (cfgmech) {
- case 1:
- outl(CONF1_ADDR_PORT, 0);
- break;
- case 2:
- outb(CONF2_ENABLE_PORT, 0);
- outb(CONF2_FORWARD_PORT, 0);
- break;
- }
-}
-
-/* read configuration space register */
-
-int
-pci_cfgread(pcicfgregs *cfg, int reg, int bytes)
-{
- int data = -1;
- int port;
-
- port = pci_cfgenable(cfg->bus, cfg->slot, cfg->func, reg, bytes);
-
- if (port != 0) {
- switch (bytes) {
- case 1:
- data = inb(port);
- break;
- case 2:
- data = inw(port);
- break;
- case 4:
- data = inl(port);
- break;
- }
- pci_cfgdisable();
- }
- return (data);
-}
-
-/* write configuration space register */
-
-void
-pci_cfgwrite(pcicfgregs *cfg, int reg, int data, int bytes)
-{
- int port;
-
- port = pci_cfgenable(cfg->bus, cfg->slot, cfg->func, reg, bytes);
- if (port != 0) {
- switch (bytes) {
- case 1:
- outb(port, data);
- break;
- case 2:
- outw(port, data);
- break;
- case 4:
- outl(port, data);
- break;
- }
- pci_cfgdisable();
- }
-}
-
-/* check whether the configuration mechanism has been correct identified */
-
-static int
-pci_cfgcheck(int maxdev)
-{
- u_char device;
-
- if (bootverbose)
- printf("pci_cfgcheck:\tdevice ");
-
- for (device = 0; device < maxdev; device++) {
- unsigned id, class, header;
- if (bootverbose)
- printf("%d ", device);
-
- id = inl(pci_cfgenable(0, device, 0, 0, 4));
- if (id == 0 || id == -1)
- continue;
-
- class = inl(pci_cfgenable(0, device, 0, 8, 4)) >> 8;
- if (bootverbose)
- printf("[class=%06x] ", class);
- if (class == 0 || (class & 0xf870ff) != 0)
- continue;
-
- header = inb(pci_cfgenable(0, device, 0, 14, 1));
- if (bootverbose)
- printf("[hdr=%02x] ", header);
- if ((header & 0x7e) != 0)
- continue;
-
- if (bootverbose)
- printf("is there (id=%08x)\n", id);
-
- pci_cfgdisable();
- return (1);
- }
- if (bootverbose)
- printf("-- nothing found\n");
-
- pci_cfgdisable();
- return (0);
-}
-
-static int
-pci_cfgopen(void)
-{
- unsigned long mode1res,oldval1;
- unsigned char mode2res,oldval2;
-
- oldval1 = inl(CONF1_ADDR_PORT);
-
- if (bootverbose) {
- printf("pci_open(1):\tmode 1 addr port (0x0cf8) is 0x%08lx\n",
- oldval1);
- }
-
- if ((oldval1 & CONF1_ENABLE_MSK) == 0) {
-
- cfgmech = 1;
- devmax = 32;
-
- outl(CONF1_ADDR_PORT, CONF1_ENABLE_CHK);
- outb(CONF1_ADDR_PORT +3, 0);
- mode1res = inl(CONF1_ADDR_PORT);
- outl(CONF1_ADDR_PORT, oldval1);
-
- if (bootverbose)
- printf("pci_open(1a):\tmode1res=0x%08lx (0x%08lx)\n",
- mode1res, CONF1_ENABLE_CHK);
-
- if (mode1res) {
- if (pci_cfgcheck(32))
- return (cfgmech);
- }
-
- outl(CONF1_ADDR_PORT, CONF1_ENABLE_CHK1);
- mode1res = inl(CONF1_ADDR_PORT);
- outl(CONF1_ADDR_PORT, oldval1);
-
- if (bootverbose)
- printf("pci_open(1b):\tmode1res=0x%08lx (0x%08lx)\n",
- mode1res, CONF1_ENABLE_CHK1);
-
- if ((mode1res & CONF1_ENABLE_MSK1) == CONF1_ENABLE_RES1) {
- if (pci_cfgcheck(32))
- return (cfgmech);
- }
- }
-
- oldval2 = inb(CONF2_ENABLE_PORT);
-
- if (bootverbose) {
- printf("pci_open(2):\tmode 2 enable port (0x0cf8) is 0x%02x\n",
- oldval2);
- }
-
- if ((oldval2 & 0xf0) == 0) {
-
- cfgmech = 2;
- devmax = 16;
-
- outb(CONF2_ENABLE_PORT, CONF2_ENABLE_CHK);
- mode2res = inb(CONF2_ENABLE_PORT);
- outb(CONF2_ENABLE_PORT, oldval2);
-
- if (bootverbose)
- printf("pci_open(2a):\tmode2res=0x%02x (0x%02x)\n",
- mode2res, CONF2_ENABLE_CHK);
-
- if (mode2res == CONF2_ENABLE_RES) {
- if (bootverbose)
- printf("pci_open(2a):\tnow trying mechanism 2\n");
-
- if (pci_cfgcheck(16))
- return (cfgmech);
- }
- }
-
- cfgmech = 0;
- devmax = 0;
- return (cfgmech);
-}
-
-static devclass_t pcib_devclass;
-
-static const char *
-nexus_pcib_is_host_bridge(pcicfgregs *cfg,
- u_int32_t id, u_int8_t class, u_int8_t subclass,
- u_int8_t *busnum)
-{
- const char *s = NULL;
- static u_int8_t pxb[4]; /* hack for 450nx */
-
- *busnum = 0;
-
- switch (id) {
- case 0x12258086:
- s = "Intel 824?? host to PCI bridge";
- /* XXX This is a guess */
- /* *busnum = pci_cfgread(cfg, 0x41, 1); */
- *busnum = cfg->bus;
- break;
- case 0x71208086:
- s = "Intel 82810 (i810 GMCH) Host To Hub bridge";
- break;
- case 0x71228086:
- s = "Intel 82810-DC100 (i810-DC100 GMCH) Host To Hub bridge";
- break;
- case 0x71248086:
- s = "Intel 82810E (i810E GMCH) Host To Hub bridge";
- break;
- case 0x71808086:
- s = "Intel 82443LX (440 LX) host to PCI bridge";
- break;
- case 0x71908086:
- s = "Intel 82443BX (440 BX) host to PCI bridge";
- break;
- case 0x71928086:
- s = "Intel 82443BX host to PCI bridge (AGP disabled)";
- break;
- case 0x71a08086:
- s = "Intel 82443GX host to PCI bridge";
- break;
- case 0x71a18086:
- s = "Intel 82443GX host to AGP bridge";
- break;
- case 0x71a28086:
- s = "Intel 82443GX host to PCI bridge (AGP disabled)";
- break;
- case 0x84c48086:
- s = "Intel 82454KX/GX (Orion) host to PCI bridge";
- *busnum = pci_cfgread(cfg, 0x4a, 1);
- break;
- case 0x84ca8086:
- /*
- * For the 450nx chipset, there is a whole bundle of
- * things pretending to be host bridges. The MIOC will
- * be seen first and isn't really a pci bridge (the
- * actual busses are attached to the PXB's). We need to
- * read the registers of the MIOC to figure out the
- * bus numbers for the PXB channels.
- *
- * Since the MIOC doesn't have a pci bus attached, we
- * pretend it wasn't there.
- */
- pxb[0] = pci_cfgread(cfg, 0xd0, 1); /* BUSNO[0] */
- pxb[1] = pci_cfgread(cfg, 0xd1, 1) + 1; /* SUBA[0]+1 */
- pxb[2] = pci_cfgread(cfg, 0xd3, 1); /* BUSNO[1] */
- pxb[3] = pci_cfgread(cfg, 0xd4, 1) + 1; /* SUBA[1]+1 */
- return NULL;
- case 0x84cb8086:
- switch (cfg->slot) {
- case 0x12:
- s = "Intel 82454NX PXB#0, Bus#A";
- *busnum = pxb[0];
- break;
- case 0x13:
- s = "Intel 82454NX PXB#0, Bus#B";
- *busnum = pxb[1];
- break;
- case 0x14:
- s = "Intel 82454NX PXB#1, Bus#A";
- *busnum = pxb[2];
- break;
- case 0x15:
- s = "Intel 82454NX PXB#1, Bus#B";
- *busnum = pxb[3];
- break;
- }
- break;
-
- /* AMD -- vendor 0x1022 */
- case 0x70061022:
- s = "AMD-751 host to PCI bridge";
- break;
-
- /* SiS -- vendor 0x1039 */
- case 0x04961039:
- s = "SiS 85c496";
- break;
- case 0x04061039:
- s = "SiS 85c501";
- break;
- case 0x06011039:
- s = "SiS 85c601";
- break;
- case 0x55911039:
- s = "SiS 5591 host to PCI bridge";
- break;
- case 0x00011039:
- s = "SiS 5591 host to AGP bridge";
- break;
-
- /* VLSI -- vendor 0x1004 */
- case 0x00051004:
- s = "VLSI 82C592 Host to PCI bridge";
- break;
-
- /* XXX Here is MVP3, I got the datasheet but NO M/B to test it */
- /* totally. Please let me know if anything wrong. -F */
- /* XXX need info on the MVP3 -- any takers? */
- case 0x05981106:
- s = "VIA 82C598MVP (Apollo MVP3) host bridge";
- break;
-
- /* AcerLabs -- vendor 0x10b9 */
- /* Funny : The datasheet told me vendor id is "10b8",sub-vendor */
- /* id is '10b9" but the register always shows "10b9". -Foxfair */
- case 0x154110b9:
- s = "AcerLabs M1541 (Aladdin-V) PCI host bridge";
- break;
-
- /* OPTi -- vendor 0x1045 */
- case 0xc8221045:
- s = "OPTi 82C822 host to PCI Bridge";
- break;
-
- /* RCC -- vendor 0x1166 */
- case 0x00051166:
- s = "RCC HE host to PCI bridge";
- *busnum = pci_cfgread(cfg, 0x44, 1);
- break;
-
- case 0x00061166:
- /* FALLTHROUGH */
- case 0x00081166:
- s = "RCC host to PCI bridge";
- *busnum = pci_cfgread(cfg, 0x44, 1);
- break;
-
- case 0x00091166:
- s = "RCC LE host to PCI bridge";
- *busnum = pci_cfgread(cfg, 0x44, 1);
- break;
-
- /* Integrated Micro Solutions -- vendor 0x10e0 */
- case 0x884910e0:
- s = "Integrated Micro Solutions VL Bridge";
- break;
-
- default:
- if (class == PCIC_BRIDGE && subclass == PCIS_BRIDGE_HOST)
- s = "Host to PCI bridge";
- break;
- }
-
- return s;
-}
-
-/*
- * Scan the first pci bus for host-pci bridges and add pcib instances
- * to the nexus for each bridge.
- */
-static void
-nexus_pcib_identify(driver_t *driver, device_t parent)
-{
- pcicfgregs probe;
- u_int8_t hdrtype;
- int found = 0;
- int pcifunchigh;
- int found824xx = 0;
-
- if (pci_cfgopen() == 0)
- return;
- probe.hose = 0;
- probe.bus = 0;
- retry:
- for (probe.slot = 0; probe.slot <= PCI_SLOTMAX; probe.slot++) {
- probe.func = 0;
- hdrtype = pci_cfgread(&probe, PCIR_HEADERTYPE, 1);
- if (hdrtype & PCIM_MFDEV)
- pcifunchigh = 7;
- else
- pcifunchigh = 0;
- for (probe.func = 0;
- probe.func <= pcifunchigh;
- probe.func++) {
- /*
- * Read the IDs and class from the device.
- */
- u_int32_t id;
- u_int8_t class, subclass, busnum;
- device_t child;
- const char *s;
-
- id = pci_cfgread(&probe, PCIR_DEVVENDOR, 4);
- if (id == -1)
- continue;
- class = pci_cfgread(&probe, PCIR_CLASS, 1);
- subclass = pci_cfgread(&probe, PCIR_SUBCLASS, 1);
-
- s = nexus_pcib_is_host_bridge(&probe, id,
- class, subclass,
- &busnum);
- if (s) {
- /*
- * Add at priority 100 to make sure we
- * go after any motherboard resources
- */
- child = BUS_ADD_CHILD(parent, 100,
- "pcib", busnum);
- device_set_desc(child, s);
- found = 1;
- if (id == 0x12258086)
- found824xx = 1;
- }
- }
- }
- if (found824xx && probe.bus == 0) {
- probe.bus++;
- goto retry;
- }
-
- /*
- * Make sure we add at least one bridge since some old
- * hardware doesn't actually have a host-pci bridge device.
- * Note that pci_cfgopen() thinks we have PCI devices..
- */
- if (!found) {
- if (bootverbose)
- printf(
- "nexus_pcib_identify: no bridge found, adding pcib0 anyway\n");
- BUS_ADD_CHILD(parent, 100, "pcib", 0);
- }
-}
-
-static int
-nexus_pcib_probe(device_t dev)
-{
- if (pci_cfgopen() != 0) {
- device_add_child(dev, "pci", device_get_unit(dev));
- return 0;
- }
- return ENXIO;
-}
-
-static device_method_t nexus_pcib_methods[] = {
- /* Device interface */
- DEVMETHOD(device_identify, nexus_pcib_identify),
- DEVMETHOD(device_probe, nexus_pcib_probe),
- DEVMETHOD(device_attach, bus_generic_attach),
- DEVMETHOD(device_shutdown, bus_generic_shutdown),
- DEVMETHOD(device_suspend, bus_generic_suspend),
- DEVMETHOD(device_resume, bus_generic_resume),
-
- /* Bus interface */
- DEVMETHOD(bus_print_child, bus_generic_print_child),
- DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
- DEVMETHOD(bus_release_resource, bus_generic_release_resource),
- DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
- DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
- DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
- DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
-
- { 0, 0 }
-};
-
-static driver_t nexus_pcib_driver = {
- "pcib",
- nexus_pcib_methods,
- 1,
-};
-
-DRIVER_MODULE(pcib, nexus, nexus_pcib_driver, pcib_devclass, 0, 0);
diff --git a/sys/i4b/include/i4b_cause.h b/sys/i4b/include/i4b_cause.h
deleted file mode 100644
index 96589e52a32a..000000000000
--- a/sys/i4b/include/i4b_cause.h
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (c) 1997, 1999 Hellmuth Michaelis. 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 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 AUTHOR 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.
- *
- *---------------------------------------------------------------------------
- *
- * i4b_cause.h - causes and cause handling for i4b
- * -----------------------------------------------
- *
- * $Id: i4b_cause.h,v 1.11 1999/12/13 21:25:28 hm Exp $
- *
- * $FreeBSD$
- *
- * last edit-date: [Mon Dec 13 22:06:51 1999]
- *
- *---------------------------------------------------------------------------*/
-
-#ifndef _I4B_CAUSE_H_
-#define _I4B_CAUSE_H_
-
-/*---------------------------------------------------------------------------*
- * ISDN4BSD internal causes specification
- *---------------------------------------------------------------------------*/
-
-#define CAUSE_VAL 0x000000ff /* cause value */
-#define CAUSE_TYPE 0x0000ff00 /* cause type */
-#define CAUSET_Q850 0 /* value coded according to Q.850 */
-#define CAUSET_I4B 1 /* i4b protocol independent causes*/
-
-#define GET_CAUSE_VAL(cause) ((cause) & 0xff)
-#define SET_CAUSE_VAL(dest, val) ((dest) = ((dest & 0xffffff00) | \
- (val & 0x000000ff)))
-
-#define GET_CAUSE_TYPE(cause) (((cause) >> 8) & 0xff)
-#define SET_CAUSE_TYPE(dest, type) ((dest) = ((dest & 0xffff00ff) | \
- ((type << 8) & 0x0000ff00)))
-
-#define SET_CAUSE_TV(dest, type, val) ((dest) = ((val & 0x000000ff) | \
- ((type << 8) & 0x0000ff00)))
-
-/* CAUSET_I4B - protocol independent cause values */
-
-#define CAUSE_I4B_NORMAL 0 /* normal call clearing */
-#define CAUSE_I4B_BUSY 1 /* user busy */
-#define CAUSE_I4B_NOCHAN 2 /* circuit/channel not available*/
-#define CAUSE_I4B_INCOMP 3 /* incompatible source/dest */
-#define CAUSE_I4B_REJECT 4 /* call rejected */
-#define CAUSE_I4B_OOO 5 /* destination out of order */
-#define CAUSE_I4B_TMPFAIL 6 /* temporary failure */
-#define CAUSE_I4B_L1ERROR 7 /* L1 error / persistent deact */
-#define CAUSE_I4B_LLDIAL 8 /* no dialout on leased line */
-#define CAUSE_I4B_MAX 9
- /* NOTE: update isdnd/pcause.c when adding causes !!!!! */
-
-/* CAUSET_Q850 - causes defined in Q.850 */
-
-#define CAUSE_Q850_SHUTDN 0x00 /* normal D-channel shutdown */
-#define CAUSE_Q850_NUNALLC 0x01 /* Unallocated (unassigned) number */
-#define CAUSE_Q850_NRTTN 0x02 /* No route to specified transit network */
-#define CAUSE_Q850_NRTDST 0x03 /* No route to destination */
-#define CAUSE_Q850_SSINFTN 0x04 /* Send special information tone */
-#define CAUSE_Q850_MDIALTP 0x05 /* Misdialled trunk prefix */
-#define CAUSE_Q850_CHUNACC 0x06 /* Channel unacceptable */
-#define CAUSE_Q850_CALLAWD 0x07 /* Call awarded and being delivered in an established channel */
-#define CAUSE_Q850_PREEMPT 0x08 /* Preemption */
-#define CAUSE_Q850_PREECRR 0x09 /* Preemption - circuit reserved for reuse */
-#define CAUSE_Q850_NCCLR 0x10 /* Normal call clearing */
-#define CAUSE_Q850_USRBSY 0x11 /* User busy */
-#define CAUSE_Q850_NOUSRRSP 0x12 /* No user responding */
-#define CAUSE_Q850_NOANSWR 0x13 /* No answer from user (user alerted) */
-#define CAUSE_Q850_SUBSABS 0x14 /* Subscriber absent */
-#define CAUSE_Q850_CALLREJ 0x15 /* Call rejected */
-#define CAUSE_Q850_NUCHNG 0x16 /* Number changed */
-#define CAUSE_Q850_NONSELUC 0x1A /* Non-selected user clearing */
-#define CAUSE_Q850_DSTOOORDR 0x1B /* Destination out of order */
-#define CAUSE_Q850_INVNUFMT 0x1C /* Invalid number format */
-#define CAUSE_Q850_FACREJ 0x1D /* Facility rejected */
-#define CAUSE_Q850_STENQRSP 0x1E /* Response to STATUS ENQUIRY */
-#define CAUSE_Q850_NORMUNSP 0x1F /* Normal, unspecified */
-#define CAUSE_Q850_NOCAVAIL 0x22 /* No circuit / channel available */
-#define CAUSE_Q850_NETOOORDR 0x26 /* Network out of order */
-#define CAUSE_Q850_PFMCDOOSERV 0x27 /* Permanent frame mode connection out of service */
-#define CAUSE_Q850_PFMCOPER 0x28 /* Permanent frame mode connection operational */
-#define CAUSE_Q850_TMPFAIL 0x29 /* Temporary failure */
-#define CAUSE_Q850_SWEQCONG 0x2A /* Switching equipment congestion */
-#define CAUSE_Q850_ACCINFDIS 0x2B /* Access information discarded */
-#define CAUSE_Q850_REQCNOTAV 0x2C /* Requested circuit/channel not available */
-#define CAUSE_Q850_PRECALBLK 0x2E /* Precedence call blocked */
-#define CAUSE_Q850_RESUNAVAIL 0x2F /* Resources unavailable, unspecified */
-#define CAUSE_Q850_QOSUNAVAIL 0x31 /* Quality of service unavailable */
-#define CAUSE_Q850_REQSERVNS 0x32 /* Requested facility not subscribed */
-#define CAUSE_Q850_OCBARRCUG 0x35 /* Outgoing calls barred within CUG */
-#define CAUSE_Q850_ICBARRCUG 0x36 /* Incoming calls barred within CUG */
-#define CAUSE_Q850_BCAPNAUTH 0x39 /* Bearer capability not authorized */
-#define CAUSE_Q850_BCAPNAVAIL 0x3A /* Bearer capability not presently available */
-#define CAUSE_Q850_INCSTOACISC 0x3E /* Inconsistenciy in designated outgoing access information and subscriber class */
-#define CAUSE_Q850_SOONOTAVAIL 0x3F /* Service or option not available, unspecified */
-#define CAUSE_Q850_BCAPNOTIMPL 0x41 /* Bearer capability not implemented */
-#define CAUSE_Q850_CHTYPNIMPL 0x42 /* Channel type not implemented */
-#define CAUSE_Q850_REQFACNIMPL 0x45 /* Requested facility not implemented */
-#define CAUSE_Q850_ORDINBCAVL 0x46 /* Only restricted digital information bearer capability is available */
-#define CAUSE_Q850_SOONOTIMPL 0x4F /* Service or option not implemented, unspecified */
-#define CAUSE_Q850_INVCLRFVAL 0x51 /* Invalid call reference value */
-#define CAUSE_Q850_IDCHDNOEX 0x52 /* Identified channel does not exist */
-#define CAUSE_Q850_SUSCAEXIN 0x53 /* A suspended call exists, but this call identity does not */
-#define CAUSE_Q850_CLIDINUSE 0x54 /* Call identity in use */
-#define CAUSE_Q850_NOCLSUSP 0x55 /* No call suspended */
-#define CAUSE_Q850_CLIDCLRD 0x56 /* Call having the requested call identity has been cleared */
-#define CAUSE_Q850_UNOTMEMCUG 0x57 /* User not member of CUG */
-#define CAUSE_Q850_INCDEST 0x58 /* Incompatible destination */
-#define CAUSE_Q850_NONEXCUG 0x5A /* Non-existent CUG */
-#define CAUSE_Q850_INVNTWSEL 0x5B /* Invalid transit network selection */
-#define CAUSE_Q850_INVMSG 0x5F /* Invalid message, unspecified */
-#define CAUSE_Q850_MIEMISS 0x60 /* Mandatory information element is missing */
-#define CAUSE_Q850_MSGTNI 0x61 /* Message type non-existent or not implemented */
-#define CAUSE_Q850_MSGNCMPT 0x62 /* Message not compatible with call state or message type non-existent or not implemented */
-#define CAUSE_Q850_IENENI 0x63 /* Information element/parameter non-existent or not implemented */
-#define CAUSE_Q850_INVIEC 0x64 /* Invalid information element contents */
-#define CAUSE_Q850_MSGNCWCS 0x65 /* Message not compatible with call state */
-#define CAUSE_Q850_RECOTIMEXP 0x66 /* Recovery on timer expiry */
-#define CAUSE_Q850_PARMNENIPO 0x67 /* Parameter non-existent or not implemented, passed on */
-#define CAUSE_Q850_MSGUNRDPRM 0x6E /* Message with unrecognized parameter, discarded */
-#define CAUSE_Q850_PROTERR 0x6F /* Protocol error, unspecified */
-#define CAUSE_Q850_INTWRKU 0x7F /* Interworking, unspecified */
-
-#define CAUSE_Q850_MAX 128
-
-#endif /* _I4B_CAUSE_H_ */
diff --git a/sys/i4b/include/i4b_debug.h b/sys/i4b/include/i4b_debug.h
deleted file mode 100644
index aabc49857aad..000000000000
--- a/sys/i4b/include/i4b_debug.h
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- * Copyright (c) 1997, 1999 Hellmuth Michaelis. 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 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 AUTHOR 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.
- *
- *---------------------------------------------------------------------------
- *
- * i4b_debug.h - i4b debug header file
- * -----------------------------------
- *
- * $Id: i4b_debug.h,v 1.20 1999/12/13 21:25:28 hm Exp $
- *
- * $FreeBSD$
- *
- * last edit-date: [Mon Dec 13 22:06:59 1999]
- *
- *---------------------------------------------------------------------------*/
-
-#define DO_I4B_DEBUG /* enable debugging code inclusion */
-
-#undef DO_I4B_MAXDEBUG /* enable ALL debug messages by default */
-
-#ifdef DO_I4B_DEBUG
-
-extern unsigned int i4b_l1_debug;
-extern unsigned int i4b_l2_debug;
-extern unsigned int i4b_l3_debug;
-extern unsigned int i4b_l4_debug;
-
-#define DBGL1(bits, routine, what) \
- if(bits & i4b_l1_debug) \
- { \
- printf("i4b-L1-%s: ", routine); \
- printf what ; \
- }
-
-#define DBGL2(bits, routine, what) \
- if(bits & i4b_l2_debug) \
- { \
- printf("i4b-L2-%s: ", routine); \
- printf what ; \
- }
-
-#define DBGL3(bits, routine, what) \
- if(bits & i4b_l3_debug) \
- { \
- printf("i4b-L3-%s: ", routine); \
- printf what ; \
- }
-
-#define DBGL4(bits, routine, what) \
- if(bits & i4b_l4_debug) \
- { \
- printf("i4b-L4-%s: ", routine); \
- printf what ; \
- }
-#else /* !DO_I4B_DEBUG */
-
-#define DBGL1(bits, routine, what);
-#define DBGL2(bits, routine, what);
-#define DBGL3(bits, routine, what);
-#define DBGL4(bits, routine, what);
-
-#endif /* DO_I4B_DEBUG */
-
-/* Layer 1 */
-
-#define L1_ERROR 0x0001 /* general error message*/
-#define L1_PRIM 0x0002 /* interlayer primitives*/
-#define L1_BCHAN 0x0004 /* B channel action */
-#define L1_H_ERR 0x0008 /* HSCX errors */
-#define L1_H_IRQ 0x0010 /* HSCX IRQ messages */
-#define L1_I_ERR 0x0020 /* ISAC errors */
-#define L1_I_MSG 0x0040 /* ISAC messages */
-#define L1_I_SETUP 0x0080 /* ISAC setup messages */
-#define L1_F_MSG 0x0100 /* FSM messages */
-#define L1_F_ERR 0x0200 /* FSM error messages */
-#define L1_T_MSG 0x0400 /* Timer messages */
-#define L1_T_ERR 0x0800 /* Timer error messages */
-#define L1_H_XFRERR 0x1000 /* HSCX data xfer error */
-#define L1_I_CICO 0x2000 /* ISAC command in/out */
-
-#define L1_DEBUG_MAX 0x3fef /* all messages on except IRQ! */
-#define L1_DEBUG_ERR (L1_H_ERR | L1_I_ERR | L1_F_ERR | L1_T_ERR | L1_ERROR)
-
-#ifndef L1_DEBUG_DEFAULT
-#ifdef DO_I4B_MAXDEBUG
-#define L1_DEBUG_DEFAULT L1_DEBUG_MAX
-#else
-#define L1_DEBUG_DEFAULT L1_DEBUG_ERR
-#endif
-#endif
-
-/* Layer 2 */
-
-#define L2_ERROR 0x0001 /* general error message */
-#define L2_PRIM 0x0002 /* interlayer primitives */
-#define L2_U_MSG 0x0004 /* U frame messages */
-#define L2_U_ERR 0x0008 /* U frame error messages */
-#define L2_S_MSG 0x0010 /* S frame messages */
-#define L2_S_ERR 0x0020 /* S frame error messages */
-#define L2_I_MSG 0x0040 /* I frame messages */
-#define L2_I_ERR 0x0080 /* I frame error messages */
-#define L2_F_MSG 0x0100 /* FSM messages */
-#define L2_F_ERR 0x0200 /* FSM error messages */
-#define L2_T_MSG 0x0400 /* timer messages */
-#define L2_T_ERR 0x0800 /* timer error messages */
-#define L2_TEI_MSG 0x1000 /* TEI messages */
-#define L2_TEI_ERR 0x2000 /* TEI error messages */
-
-#define L2_DEBUG_MAX 0x3fff /* all messages on */
-#define L2_DEBUG_ERR (L2_ERROR | L2_I_ERR | L2_F_ERR | L2_T_ERR | L2_S_ERR | L2_TEI_ERR | L2_U_ERR )
-
-#ifndef L2_DEBUG_DEFAULT
-#ifdef DO_I4B_MAXDEBUG
-#define L2_DEBUG_DEFAULT L2_DEBUG_MAX
-#else
-#define L2_DEBUG_DEFAULT L2_DEBUG_ERR
-#endif
-#endif
-
-/* Layer 3 */
-
-#define L3_ERR 0x0001 /* general error message */
-#define L3_MSG 0x0002 /* general message */
-#define L3_F_MSG 0x0004 /* FSM messages */
-#define L3_F_ERR 0x0008 /* FSM error messages */
-#define L3_T_MSG 0x0010 /* timer messages */
-#define L3_T_ERR 0x0020 /* timer error messages */
-#define L3_P_MSG 0x0040 /* protocol messages */
-#define L3_P_ERR 0x0080 /* protocol error messages */
-#define L3_A_MSG 0x0100 /* AOC messages */
-#define L3_A_ERR 0x0200 /* AOC error messages */
-#define L3_PRIM 0x0400 /* messages exchanged */
-
-#define L3_DEBUG_MAX 0x07ff /* all messages on */
-#define L3_DEBUG_ERR (L3_ERR | L3_F_ERR | L3_T_ERR | L3_P_ERR | L3_A_ERR)
-
-#ifndef L3_DEBUG_DEFAULT
-#ifdef DO_I4B_MAXDEBUG
-#define L3_DEBUG_DEFAULT L3_DEBUG_MAX
-#else
-#define L3_DEBUG_DEFAULT L3_DEBUG_ERR
-#endif
-#endif
-
-/* Layer 4 */
-
-#define L4_ERR 0x0001 /* general error message */
-#define L4_MSG 0x0002 /* general message */
-#define L4_TIMO 0x0004 /* b channel idle timeout msgs */
-#define L4_DIALST 0x0008 /* network driver dial states */
-#define L4_IPRDBG 0x0010 /* ipr driver debug messages */
-#define L4_RBCHDBG 0x0020 /* rbch driver debug messages */
-#define L4_ISPDBG 0x0040 /* isp driver debug messages */
-#define L4_TELDBG 0x0080 /* tel driver debug messages */
-#define L4_TINADBG 0x0100 /* tina driver debug messages */
-#define L4_TINAMSG 0x0200 /* tina driver messages */
-#define L4_TINAERR 0x0400 /* tina driver error messages */
-
-#define L4_DEBUG_MAX 0x07ff /* all messages on */
-#define L4_DEBUG_ERR (L4_ERR | L4_TINADBG | L4_TINAMSG | L4_TINAERR)
-
-#ifndef L4_DEBUG_DEFAULT
-#ifdef DO_I4B_MAXDEBUG
-#define L4_DEBUG_DEFAULT L4_DEBUG_MAX
-#else
-#define L4_DEBUG_DEFAULT L4_DEBUG_ERR
-#endif
-#endif
-
-/*---------------------------------------------------------------------------*
- * ioctl via /dev/i4bctl:
- * get/set current debug bits settings
- *---------------------------------------------------------------------------*/
-
-typedef struct {
- unsigned int l1;
- unsigned int l2;
- unsigned int l3;
- unsigned int l4;
-} ctl_debug_t;
-
-#define I4B_CTL_GET_DEBUG _IOR('C', 0, ctl_debug_t)
-
-#define I4B_CTL_SET_DEBUG _IOW('C', 1, ctl_debug_t)
-
-/*---------------------------------------------------------------------------*
- * get hscx statistics
- *---------------------------------------------------------------------------*/
-
-typedef struct {
- int unit; /* controller number */
- int chan; /* channel number */
- int vfr;
- int rdo;
- int crc;
- int rab;
- int xdu;
- int rfo;
-} hscxstat_t;
-
-#define I4B_CTL_GET_HSCXSTAT _IOWR('C', 2, hscxstat_t)
-
-#define I4B_CTL_CLR_HSCXSTAT _IOW('C', 3, hscxstat_t)
-
-/*---------------------------------------------------------------------------*
- * get LAPD/Q.921 statistics
- *---------------------------------------------------------------------------*/
-typedef struct {
- /* transmit */
-
- u_long tx_i; /* I */
- u_long tx_rr; /* RR */
- u_long tx_rnr; /* RNR */
- u_long tx_rej; /* REJ */
- u_long tx_sabme; /* SABME*/
- u_long tx_dm; /* DM */
- u_long tx_disc; /* DISC */
- u_long tx_ua; /* UA */
- u_long tx_frmr; /* FRMR */
- u_long tx_tei; /* TEI */
-
- /* receive */
-
- u_long rx_i; /* I */
- u_long rx_rr; /* RR */
- u_long rx_rnr; /* RNR */
- u_long rx_rej; /* REJ */
- u_long rx_sabme; /* SABME*/
- u_long rx_tei; /* TEI */
- u_long rx_ui; /* UI */
- u_long rx_disc; /* DISC */
- u_long rx_xid; /* XID */
- u_long rx_dm; /* DM */
- u_long rx_ua; /* UA */
- u_long rx_frmr; /* FRMR */
-
- /* errors */
-
- u_long err_rx_len; /* incorrect length */
- u_long err_rx_badf; /* bad frame type */
- u_long err_rx_bads; /* bad s frame */
- u_long err_rx_badu; /* bad u frame */
- u_long err_rx_badui; /* bad ui frame */
-} lapdstat_t;
-
-typedef struct {
- int unit;
- lapdstat_t lapdstat;
-} l2stat_t;
-
-#define I4B_CTL_GET_LAPDSTAT _IOWR('C', 4, l2stat_t)
-
-#define I4B_CTL_CLR_LAPDSTAT _IOW('C', 5, int)
-
-/* EOF */
diff --git a/sys/i4b/include/i4b_ioctl.h b/sys/i4b/include/i4b_ioctl.h
deleted file mode 100644
index c2a2460037aa..000000000000
--- a/sys/i4b/include/i4b_ioctl.h
+++ /dev/null
@@ -1,672 +0,0 @@
-/*
- * Copyright (c) 1997, 1999 Hellmuth Michaelis. 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 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 AUTHOR 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.
- *
- *---------------------------------------------------------------------------
- *
- * i4b_ioctl.h - messages kernel <--> userland
- * -------------------------------------------
- *
- * $Id: i4b_ioctl.h,v 1.150 1999/12/13 21:25:28 hm Exp $
- *
- * $FreeBSD$
- *
- * last edit-date: [Mon Dec 13 22:12:16 1999]
- *
- *---------------------------------------------------------------------------*/
-
-#ifndef _I4B_IOCTL_H_
-#define _I4B_IOCTL_H_
-
-#if defined(__FreeBSD__) && __FreeBSD__ >= 3
-#ifndef _MACHINE_TYPES_H_
-#include <machine/types.h>
-#endif /* _MACHINE_TYPES_H_ */
-#endif /* __FreeBSD__ */
-
-/*---------------------------------------------------------------------------*
- * version and release number for isdn4bsd package
- *---------------------------------------------------------------------------*/
-#define VERSION 0 /* version number */
-#define REL 90 /* release number */
-#define STEP 1 /* release step */
-
-/*---------------------------------------------------------------------------*
- * date/time format in i4b log messages
- * ------------------------------------
- * Being year 2000 clean is not easy with the current state of the
- * ANSI C library standard and it's implementation for some locales.
- * You might like to use the "%c" format of "strftime" sometimes,
- * but this breaks Y2K in some locales. Also the old standard logfile
- * format "%d.%m.%y %H:%M:%S" is non compliant.
- * NetBSD's current toolset warns about this problems, and we compile
- * with -Werror, so this problems need to be resolved.
- *---------------------------------------------------------------------------*/
-#define I4B_TIME_FORMAT "%d.%m.%Y %H:%M:%S"
-
-/*---------------------------------------------------------------------------*
- * max number of controllers in system
- *---------------------------------------------------------------------------*/
-#define MAX_CONTROLLERS 8 /* max number of controllers */
-
-/*---------------------------------------------------------------------------*
- * ISDN D-channel protocols
- *---------------------------------------------------------------------------*/
-#define PROTOCOL_DSS1 0 /* default, Euro-ISDN/DSS1 */
-#define PROTOCOL_D64S 1 /* 64k leased line, no protocol */
-
-/*---------------------------------------------------------------------------*
- * controller types
- *---------------------------------------------------------------------------*/
-#define CTRL_INVALID (-1) /* invalid, error */
-#define CTRL_UNKNOWN 0 /* unknown controller type */
-#define CTRL_PASSIVE 1 /* passive ISDN controller cards*/
-#define CTRL_DAIC 2 /* Diehl active controller cards*/
-#define CTRL_TINADD 3 /* Stollmann Tina-dd active card*/
-#define CTRL_AVMB1 4 /* AVM B1 active card */
-#define CTRL_NUMTYPES 5 /* number of controller types */
-
-/*---------------------------------------------------------------------------*
- * card types for CTRL_PASSIVE
- *---------------------------------------------------------------------------*/
-#define CARD_TYPEP_INVAL (-1) /* invalid, error */
-#define CARD_TYPEP_UNK 0 /* unknown */
-#define CARD_TYPEP_8 1 /* Teles, S0/8 */
-#define CARD_TYPEP_16 2 /* Teles, S0/16 */
-#define CARD_TYPEP_16_3 3 /* Teles, S0/16.3 */
-#define CARD_TYPEP_AVMA1 4 /* AVM A1 or AVM Fritz!Card */
-#define CARD_TYPEP_163P 5 /* Teles, S0/16.3 PnP */
-#define CARD_TYPEP_CS0P 6 /* Creatix, S0 PnP */
-#define CARD_TYPEP_USRTA 7 /* US Robotics ISDN TA internal */
-#define CARD_TYPEP_DRNNGO 8 /* Dr. Neuhaus Niccy GO@ */
-#define CARD_TYPEP_SWS 9 /* Sedlbauer Win Speed */
-#define CARD_TYPEP_DYNALINK 10 /* Dynalink IS64PH */
-#define CARD_TYPEP_BLMASTER 11 /* ISDN Blaster / ISDN Master */
-#define CARD_TYPEP_PCFRITZ 12 /* AVM PCMCIA Fritz!Card */
-#define CARD_TYPEP_ELSAQS1ISA 13 /* ELSA QuickStep 1000pro ISA */
-#define CARD_TYPEP_ELSAQS1PCI 14 /* ELSA QuickStep 1000pro PCI */
-#define CARD_TYPEP_SIEMENSITALK 15 /* Siemens I-Talk */
-#define CARD_TYPEP_ELSAMLIMC 16 /* ELSA MicroLink ISDN/MC */
-#define CARD_TYPEP_ELSAMLMCALL 17 /* ELSA MicroLink MCall */
-#define CARD_TYPEP_ITKIX1 18 /* ITK ix1 micro */
-#define CARD_TYPEP_AVMA1PCI 19 /* AVM FRITZ!CARD PCI */
-#define CARD_TYPEP_PCC16 20 /* ELSA PCC-16 */
-#define CARD_TYPEP_AVM_PNP 21 /* AVM FRITZ!CARD PnP */
-#define CARD_TYPEP_SIE_ISURF2 22 /* Siemens I-Surf 2 PnP */
-#define CARD_TYPEP_ASUSCOMIPAC 23 /* Asuscom ISDNlink 128 K PnP */
-/*
- * in case you add support for more cards, please update:
- *
- * isdnd: support.c, name_of_controller()
- * diehl/diehlctl: main.c, listall()
- *
- * and adjust CARD_TYPEP_MAX below.
- */
-
-#define CARD_TYPEP_MAX 23 /* max type */
-
-/*---------------------------------------------------------------------------*
- * card types for CTRL_DAIC
- *---------------------------------------------------------------------------*/
-#define CARD_TYPEA_DAIC_UNK 0
-#define CARD_TYPEA_DAIC_S 1
-#define CARD_TYPEA_DAIC_SX 2
-#define CARD_TYPEA_DAIC_SCOM 3
-#define CARD_TYPEA_DAIC_QUAD 4
-
-/*---------------------------------------------------------------------------*
- * max length of some strings
- *---------------------------------------------------------------------------*/
-#define TELNO_MAX 41 /* max length of a telephone number (+ '\0') */
-#define DISPLAY_MAX 91 /* max length of display information (+ '\0') */
-#define DATETIME_MAX 21 /* max length of datetime information (+ '\0')*/
-
-/*---------------------------------------------------------------------------*
- * in case the src or dst telephone number is empty
- *---------------------------------------------------------------------------*/
-#define TELNO_EMPTY "NotAvailable"
-
-/*---------------------------------------------------------------------------*
- * B channel parameters
- *---------------------------------------------------------------------------*/
-#define BCH_MAX_DATALEN 2048 /* max length of a B channel frame */
-
-/*---------------------------------------------------------------------------*
- * userland driver types
- * ---------------------
- * a "driver" is defined here as a piece of software interfacing an
- * ISDN B channel with a userland service, such as IP, Telephony etc.
- *---------------------------------------------------------------------------*/
-#define BDRV_RBCH 0 /* raw b-channel interface driver */
-#define BDRV_TEL 1 /* telephone (speech) interface driver */
-#define BDRV_IPR 2 /* IP over raw HDLC interface driver */
-#define BDRV_ISPPP 3 /* sync Kernel PPP interface driver */
-#define BDRV_IBC 4 /* BSD/OS point to point driver */
-
-/*---------------------------------------------------------------------------*
- * B channel protocol
- *---------------------------------------------------------------------------*/
-#define BPROT_NONE 0 /* no protocol at all, raw data */
-#define BPROT_RHDLC 1 /* raw HDLC: flag, data, crc, flag */
-
-/*---------------------------------------------------------------------------*
- * causes data type
- *---------------------------------------------------------------------------*/
-typedef unsigned int cause_t; /* 32 bit unsigned int */
-
-/*---------------------------------------------------------------------------*
- * call descriptor id (cdid) definitions
- *---------------------------------------------------------------------------*/
-#define CDID_UNUSED 0 /* cdid is invalid and unused */
-#define CDID_MAX 99999 /* highest valid cdid, wraparound to 1 */
-
-/*---------------------------------------------------------------------------*
- * The shorthold algorithm to use
- *---------------------------------------------------------------------------*/
-#define SHA_FIXU 0 /* timeout algorithm for fix unit charging */
-#define SHA_VARU 1 /* timeout algorithm for variable unit charging */
-
-/*---------------------------------------------------------------------------*
- * The shorthold data struct
- *---------------------------------------------------------------------------*/
-typedef struct {
- int shorthold_algorithm; /* shorthold algorithm to use */
- int unitlen_time; /* length of a charging unit */
- int idle_time; /* time without activity on b ch*/
- int earlyhup_time; /* safety area at end of unit */
-} msg_shorthold_t;
-
-
-/****************************************************************************
-
- outgoing call:
- --------------
-
- userland kernel
- -------- ------
-
- CDID_REQ ----------------->
-
- <------------------ cdid
-
- CONNECT_REQ -------------->
-
- <------------------ PROCEEDING_IND (if connect req ok)
-
- <------------------ CONNECT_ACTIVE_IND (if connection ok)
-
- or
-
- <------------------ DISCONNECT_IND (if connection failed)
-
-
-
- incoming call:
- --------------
-
- userland kernel
- -------- ------
-
- <------------------ CONNECT_IND
-
- CONNECT_RESP ------------->
-
- <------------------ CONNECT_ACTIVE_IND (if accepted)
-
-
-
- active disconnect:
- ------------------
-
- userland kernel
- -------- ------
-
- DISCONNECT_REQ ------------>
-
- <------------------ DISCONNECT_IND
-
-
- passive disconnect:
- -------------------
-
- userland kernel
- -------- ------
-
- <------------------ DISCONNECT_IND
-
-
-****************************************************************************/
-
-
-/*===========================================================================*
- *===========================================================================*
- * "read" messages from kernel -> userland
- *===========================================================================*
- *===========================================================================*/
-
-
-/*---------------------------------------------------------------------------*
- * message header, included in every message
- *---------------------------------------------------------------------------*/
-typedef struct {
- char type; /* message identifier */
-#define MSG_CONNECT_IND 'a'
-#define MSG_CONNECT_ACTIVE_IND 'b'
-#define MSG_DISCONNECT_IND 'c'
-#define MSG_DIALOUT_IND 'd'
-#define MSG_IDLE_TIMEOUT_IND 'e'
-#define MSG_ACCT_IND 'f'
-#define MSG_CHARGING_IND 'g'
-#define MSG_PROCEEDING_IND 'h'
-#define MSG_ALERT_IND 'i'
-#define MSG_DRVRDISC_REQ 'j'
-#define MSG_L12STAT_IND 'k'
-#define MSG_TEIASG_IND 'l'
-#define MSG_PDEACT_IND 'm'
-#define MSG_NEGCOMP_IND 'n'
-#define MSG_IFSTATE_CHANGED_IND 'o'
-#define MSG_DIALOUTNUMBER_IND 'p'
-#define MSG_PACKET_IND 'q'
- int cdid; /* call descriptor id */
-} msg_hdr_t;
-
-/*---------------------------------------------------------------------------*
- * connect indication
- * indicates incoming connection
- *---------------------------------------------------------------------------*/
-typedef struct {
- msg_hdr_t header; /* common header */
- int controller; /* controller number */
- int channel; /* channel number */
-#define CHAN_B1 0 /* this _must_ be 0, HSCX B1 is also 0 */
-#define CHAN_B2 1 /* this _must_ be 1, HSCX B2 is also 1 */
-#define CHAN_ANY (-1) /* outgoing, not possible for incoming */
-#define CHAN_NO (-2) /* call waiting (CW) for incoming */
- int bprot; /* b channel protocot, see BPROT_XXX */
- char dst_telno[TELNO_MAX]; /* destination telno */
- char src_telno[TELNO_MAX]; /* source telno */
- int scr_ind;/* screening indicator */
-#define SCR_NONE 0 /* no screening indicator transmitted */
-#define SCR_USR_NOSC 1 /* screening user provided, not screened*/
-#define SCR_USR_PASS 2 /* screening user provided, verified & passed */
-#define SCR_USR_FAIL 3 /* screening user provided, verified & failed */
-#define SCR_NET 4 /* screening network provided */
- char display[DISPLAY_MAX]; /* content of display IE*/
-} msg_connect_ind_t;
-
-/*---------------------------------------------------------------------------*
- * connect active indication
- * indicates active connection
- *---------------------------------------------------------------------------*/
-typedef struct {
- msg_hdr_t header; /* common header */
- int controller; /* controller number actually used */
- int channel; /* channel number actually used */
- char datetime[DATETIME_MAX]; /* content of date/time IE */
-} msg_connect_active_ind_t;
-
-/*---------------------------------------------------------------------------*
- * disconnect indication
- * indicates a disconnect
- *---------------------------------------------------------------------------*/
-typedef struct {
- msg_hdr_t header; /* common header */
- cause_t cause; /* cause code */
-} msg_disconnect_ind_t;
-
-/*---------------------------------------------------------------------------*
- * negotiation complete
- * indicates an interface is completely up & running
- *---------------------------------------------------------------------------*/
-typedef struct {
- msg_hdr_t header; /* common header */
-} msg_negcomplete_ind_t;
-
-/*---------------------------------------------------------------------------*
- * interface changes internal state
- * indicates an interface has somehow switched its FSM
- *---------------------------------------------------------------------------*/
-typedef struct {
- msg_hdr_t header; /* common header */
- int state; /* new interface state */
-} msg_ifstatechg_ind_t;
-
-/*---------------------------------------------------------------------------*
- * initiate a call to a remote site
- * i.e. the IP driver got a packet and wants a connection
- *---------------------------------------------------------------------------*/
-typedef struct {
- msg_hdr_t header; /* common header */
- int driver; /* driver type */
- int driver_unit; /* driver unit number */
-} msg_dialout_ind_t;
-
-/*---------------------------------------------------------------------------*
- * dial a number
- *---------------------------------------------------------------------------*/
-typedef struct {
- msg_hdr_t header; /* common header */
- int driver; /* driver type */
- int driver_unit; /* driver unit number */
- int cmdlen; /* length of string */
- char cmd[TELNO_MAX]; /* the number to dial */
-} msg_dialoutnumber_ind_t;
-
-/*---------------------------------------------------------------------------*
- * idle timeout disconnect sent indication
- * kernel has sent disconnect request because of b-ch idle
- *---------------------------------------------------------------------------*/
-typedef struct {
- msg_hdr_t header; /* common header */
-} msg_idle_timeout_ind_t;
-
-/*---------------------------------------------------------------------------*
- * accounting information from userland interface driver to daemon
- *---------------------------------------------------------------------------*/
-typedef struct {
- msg_hdr_t header; /* common header */
- int accttype; /* accounting type */
-#define ACCT_DURING 0
-#define ACCT_FINAL 1
- int driver; /* driver type */
- int driver_unit; /* driver unit number */
- int ioutbytes; /* ISDN # of bytes sent */
- int iinbytes; /* ISDN # of bytes received */
- int outbps; /* bytes per sec out */
- int inbps; /* bytes per sec in */
- int outbytes; /* driver # of bytes sent */
- int inbytes; /* driver # of bytes received */
-} msg_accounting_ind_t;
-
-/*---------------------------------------------------------------------------*
- * charging information from isdn driver to daemon
- *---------------------------------------------------------------------------*/
-typedef struct {
- msg_hdr_t header; /* common header */
- int units; /* number of units */
- int units_type; /* type of units info */
-#define CHARGE_INVALID 0 /* invalid, unknown */
-#define CHARGE_AOCD 1 /* advice of charge during call */
-#define CHARGE_AOCE 2 /* advice of charge at end of call */
-#define CHARGE_CALC 3 /* locally calculated from rates information */
-} msg_charging_ind_t;
-
-/*---------------------------------------------------------------------------*
- * call proceeding indication
- * indicates outgoing SETUP has been acknowleged
- *---------------------------------------------------------------------------*/
-typedef struct {
- msg_hdr_t header; /* common header */
- int controller; /* controller number actually used */
- int channel; /* channel number actually used */
-} msg_proceeding_ind_t;
-
-/*---------------------------------------------------------------------------*
- * alert indication
- * indicates remote user side "rings"
- *---------------------------------------------------------------------------*/
-typedef struct {
- msg_hdr_t header; /* common header */
-} msg_alert_ind_t;
-
-/*---------------------------------------------------------------------------*
- * driver requests to disconnect line
- *---------------------------------------------------------------------------*/
-typedef struct {
- msg_hdr_t header; /* common header */
- int driver; /* driver type */
- int driver_unit; /* driver unit number */
-} msg_drvrdisc_req_t;
-
-/*---------------------------------------------------------------------------*
- * connect packet logging
- *---------------------------------------------------------------------------*/
-
-typedef struct {
- msg_hdr_t header; /* common header */
- int driver; /* driver type */
- int driver_unit; /* driver unit number */
- int direction; /* 0=in 1=out */
-#define DIRECTION_IN 0 /* sending packet to remote */
-#define DIRECTION_OUT 1 /* received packet from remote */
-#define MAX_PACKET_LOG 40 /* space for IP and TCP header */
- u_int8_t pktdata[MAX_PACKET_LOG];
-} msg_packet_ind_t;
-
-/*---------------------------------------------------------------------------*
- * state of layer 1/2
- *---------------------------------------------------------------------------*/
-typedef struct {
- msg_hdr_t header; /* common header */
- int controller; /* controller unit */
- int layer; /* layer number (1/2) */
-#define LAYER_ONE 1
-#define LAYER_TWO 2
- int state; /* state info */
-#define LAYER_IDLE 0
-#define LAYER_ACTIVE 1
-} msg_l12stat_ind_t;
-
-/*---------------------------------------------------------------------------*
- * TEI assignment messages
- *---------------------------------------------------------------------------*/
-typedef struct {
- msg_hdr_t header; /* common header */
- int controller; /* controller unit */
- int tei; /* TEI or -1 if invalid */
-} msg_teiasg_ind_t;
-
-/*---------------------------------------------------------------------------*
- * persistent deactivation state of stack
- *---------------------------------------------------------------------------*/
-typedef struct {
- msg_hdr_t header; /* common header */
- int controller; /* controller unit */
- int numactive; /* number of active connections */
-} msg_pdeact_ind_t;
-
-
-/*===========================================================================*
- *===========================================================================*
- * "ioctl" messages from userland -> kernel
- *===========================================================================*
- *===========================================================================*/
-
-/*---------------------------------------------------------------------------*
- * request a unique cdid (to setup an outgoing call)
- *---------------------------------------------------------------------------*/
-typedef struct {
- int cdid; /* call descriptor id */
-} msg_cdid_req_t;
-
-#define I4B_CDID_REQ _IOWR('4', 0, int)
-
-/*---------------------------------------------------------------------------*
- * connect request
- * requests an outgoing connection
- *---------------------------------------------------------------------------*/
-typedef struct {
- int cdid; /* call descriptor id */
- int controller; /* controller to use */
- int channel; /* channel to use */
- int txdelay; /* tx delay after connect */
- int bprot; /* b channel protocol */
- int driver; /* driver to route b channel data to */
- int driver_unit; /* unit number for above driver */
- msg_shorthold_t shorthold_data; /* the shorthold data */
- int unitlen_method; /* how to calculate the unitlength */
-#define ULEN_METHOD_STATIC 0 /* use unitlen_time value (see above) */
-#define ULEN_METHOD_DYNAMIC 1 /* use AOCD */
- char dst_telno[TELNO_MAX]; /* destination telephone no */
- char src_telno[TELNO_MAX]; /* source telephone number */
-} msg_connect_req_t;
-
-#define I4B_CONNECT_REQ _IOW('4', 1, msg_connect_req_t)
-
-/*---------------------------------------------------------------------------*
- * connect response
- * this is the answer to an incoming connect indication
- *---------------------------------------------------------------------------*/
-typedef struct {
- int cdid; /* call descriptor id */
- int response; /* what to do with incoming call */
-#define SETUP_RESP_DNTCRE 0 /* dont care, call is not for me */
-#define SETUP_RESP_REJECT 1 /* reject call */
-#define SETUP_RESP_ACCEPT 2 /* accept call */
- cause_t cause; /* cause for case SETUP_RESP_REJECT */
- /* the following are only used for SETUP_RESP_ACCEPT !! */
- int txdelay; /* tx delay after connect */
- int bprot; /* B chan protocol */
- int driver; /* driver to route b channel data to */
- int driver_unit; /* unit number for above driver */
- int max_idle_time; /* max time without activity on b ch */
-} msg_connect_resp_t;
-
-#define I4B_CONNECT_RESP _IOW('4', 2, msg_connect_resp_t)
-
-/*---------------------------------------------------------------------------*
- * disconnect request
- * active disconnect request
- *---------------------------------------------------------------------------*/
-typedef struct {
- int cdid; /* call descriptor id */
- cause_t cause; /* protocol independent cause */
-} msg_discon_req_t;
-
-#define I4B_DISCONNECT_REQ _IOW('4', 3, msg_discon_req_t)
-
-/*---------------------------------------------------------------------------*
- * controller info request
- *---------------------------------------------------------------------------*/
-typedef struct {
- int controller; /* controller number */
- int ncontroller; /* number of controllers in system */
- int ctrl_type; /* controller type passive/active */
- int card_type; /* brand / version */
- int tei; /* tei controller probably has */
-} msg_ctrl_info_req_t;
-
-#define I4B_CTRL_INFO_REQ _IOWR('4', 4, msg_ctrl_info_req_t)
-
-/*---------------------------------------------------------------------------*
- * dialout response
- * status report to driver who requested a dialout
- *---------------------------------------------------------------------------*/
-typedef struct {
- int driver; /* driver to route b channel data to */
- int driver_unit; /* unit number for above driver */
- int stat; /* state of dialout request */
-#define DSTAT_NONE 0
-#define DSTAT_TFAIL 1 /* transient failure */
-#define DSTAT_PFAIL 2 /* permanent failure */
-#define DSTAT_INONLY 3 /* no outgoing dials allowed */
- cause_t cause; /* exact i4b cause */
-} msg_dialout_resp_t;
-
-#define I4B_DIALOUT_RESP _IOW('4', 5, msg_dialout_resp_t)
-
-/*---------------------------------------------------------------------------*
- * timeout value update
- *---------------------------------------------------------------------------*/
-typedef struct {
- int cdid; /* call descriptor id */
- msg_shorthold_t shorthold_data;
-} msg_timeout_upd_t;
-
-#define I4B_TIMEOUT_UPD _IOW('4', 6, msg_timeout_upd_t)
-
-/*---------------------------------------------------------------------------*
- * soft enable/disable
- *---------------------------------------------------------------------------*/
-typedef struct {
- int driver; /* driver to route b channel data to */
- int driver_unit; /* unit number for above driver */
- int updown; /* what to do */
-#define SOFT_ENA 0 /* enable interface */
-#define SOFT_DIS 1 /* disable interface */
-} msg_updown_ind_t;
-
-#define I4B_UPDOWN_IND _IOW('4', 7, msg_updown_ind_t)
-
-/*---------------------------------------------------------------------------*
- * send alert request
- *---------------------------------------------------------------------------*/
-typedef struct {
- int cdid; /* call descriptor id */
-} msg_alert_req_t;
-
-#define I4B_ALERT_REQ _IOW('4', 8, msg_alert_req_t)
-
-/*---------------------------------------------------------------------------*
- * request version and release info from kernel part
- * (msg_vr_req_t is also used by tel & rbch drivers)
- *---------------------------------------------------------------------------*/
-typedef struct {
- int version; /* version number */
- int release; /* release number */
- int step; /* release step number */
-} msg_vr_req_t;
-
-#define I4B_VR_REQ _IOR('4', 9, msg_vr_req_t)
-
-/*---------------------------------------------------------------------------*
- * set ISDN protocol used by a controller
- *---------------------------------------------------------------------------*/
-typedef struct {
- int controller; /* controller number */
- int protocol; /* ISDN D-channel protocol type */
-} msg_prot_ind_t;
-
-#define I4B_PROT_IND _IOW('4', 10, msg_prot_ind_t)
-
-/*---------------------------------------------------------------------------*
- * Protocol download to active cards
- *---------------------------------------------------------------------------*/
-struct isdn_dr_prot {
- size_t bytecount; /* length of code */
- u_int8_t *microcode; /* pointer to microcode */
-};
-
-struct isdn_download_request {
- int controller; /* controller number */
- int numprotos; /* number of protocols in 'protocols' */
- struct isdn_dr_prot *protocols;
-};
-
-#define I4B_CTRL_DOWNLOAD _IOW('4', 100, struct isdn_download_request)
-
-/*---------------------------------------------------------------------------*
- * Generic diagnostic interface for active cards
- *---------------------------------------------------------------------------*/
-struct isdn_diagnostic_request {
- int controller; /* controller number */
- u_int32_t cmd; /* diagnostic command to execute */
- size_t in_param_len; /* length of additional input parameter */
- void *in_param; /* optional input parameter */
- size_t out_param_len; /* available output space */
- void *out_param; /* output data goes here */
-};
-
-#define I4B_ACTIVE_DIAGNOSTIC _IOW('4', 102, struct isdn_diagnostic_request)
-
-#endif /* _I4B_IOCTL_H_ */
diff --git a/sys/i4b/include/i4b_rbch_ioctl.h b/sys/i4b/include/i4b_rbch_ioctl.h
deleted file mode 100644
index 88142adc910d..000000000000
--- a/sys/i4b/include/i4b_rbch_ioctl.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 1999 Hellmuth Michaelis. 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 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 AUTHOR 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.
- *
- *---------------------------------------------------------------------------
- *
- * i4b_rbch_ioctl.h raw B-channel driver interface ioctls
- * ------------------------------------------------------
- *
- * $Id: i4b_rbch_ioctl.h,v 1.2 1999/12/13 21:25:28 hm Exp $
- *
- * $FreeBSD$
- *
- * last edit-date: [Mon Dec 13 22:07:12 1999]
- *
- *---------------------------------------------------------------------------*/
-
-#ifndef _I4B_RBCH_IOCTL_H_
-#define _I4B_RBCH_IOCTL_H_
-
-/*---------------------------------------------------------------------------*
- * instruct the rbch device to dial the given number
- *---------------------------------------------------------------------------*/
-
-typedef char telno_t[TELNO_MAX];
-
-#define I4B_RBCH_DIALOUT _IOW('R', 1, telno_t)
-
-/*---------------------------------------------------------------------------*
- * request version and release info from kernel part
- *---------------------------------------------------------------------------*/
-
-#define I4B_RBCH_VR_REQ _IOR('R', 2, msg_vr_req_t)
-
-#endif /* _I4B_RBCH_IOCTL_H_ */
diff --git a/sys/i4b/include/i4b_tel_ioctl.h b/sys/i4b/include/i4b_tel_ioctl.h
deleted file mode 100644
index 2cc9e1582c8f..000000000000
--- a/sys/i4b/include/i4b_tel_ioctl.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 1997, 1999 Hellmuth Michaelis. 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 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 AUTHOR 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.
- *
- *---------------------------------------------------------------------------
- *
- * i4b_tel_ioctl.h telephony interface ioctls
- * ------------------------------------------
- *
- * $Id: i4b_tel_ioctl.h,v 1.11 1999/12/13 21:25:28 hm Exp $
- *
- * $FreeBSD$
- *
- * last edit-date: [Mon Dec 13 22:07:18 1999]
- *
- *---------------------------------------------------------------------------*/
-
-#ifndef _I4B_TEL_IOCTL_H_
-#define _I4B_TEL_IOCTL_H_
-
-/*===========================================================================*
- * /dev/i4btel<n> devices (audio data)
- *===========================================================================*/
-
-/* supported audio format conversions */
-
-#define CVT_NONE 0 /* no A-law/u-law conversion */
-#define CVT_ALAW2ULAW 1 /* ISDN line: A-law, user: u-law */
-#define CVT_ULAW2ALAW 2 /* ISDN line: u-law, user: A-law */
-
-/*---------------------------------------------------------------------------*
- * get / set audio format
- *---------------------------------------------------------------------------*/
-
-#define I4B_TEL_GETAUDIOFMT _IOR('A', 0, int)
-#define I4B_TEL_SETAUDIOFMT _IOW('A', 1, int)
-#define I4B_TEL_EMPTYINPUTQUEUE _IOW('A', 2, int)
-
-/*---------------------------------------------------------------------------*
- * request version and release info from kernel part
- *---------------------------------------------------------------------------*/
-
-#define I4B_TEL_VR_REQ _IOR('A', 3, msg_vr_req_t)
-
-/*===========================================================================*
- * /dev/i4bteld<n> devices (dialer interface)
- *===========================================================================*/
-
-/* dialer commands */
-
-#define CMD_DIAL 'D' /* dial the following number string */
-#define CMD_HUP 'H' /* hangup */
-
-/* dialer responses */
-
-#define RSP_CONN '0' /* connect */
-#define RSP_BUSY '1' /* busy */
-#define RSP_HUP '2' /* hangup */
-#define RSP_NOA '3' /* no answer */
-
-#endif /* _I4B_TEL_IOCTL_H_ */
diff --git a/sys/i4b/include/i4b_trace.h b/sys/i4b/include/i4b_trace.h
deleted file mode 100644
index fa1a9a63317a..000000000000
--- a/sys/i4b/include/i4b_trace.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (c) 1997, 1999 Hellmuth Michaelis. 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 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 AUTHOR 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.
- *
- *---------------------------------------------------------------------------
- *
- * i4b_trace.h - header file for trace data read device
- * ----------------------------------------------------
- *
- * $Id: i4b_trace.h,v 1.7 1999/12/13 21:25:28 hm Exp $
- *
- * $FreeBSD$
- *
- * last edit-date: [Mon Dec 13 22:07:25 1999]
- *
- *---------------------------------------------------------------------------*/
-
-#ifndef _I4B_TRACE_H_
-#define _I4B_TRACE_H_
-
-/*---------------------------------------------------------------------------*
- * structure of the header at the beginning of every trace mbuf
- *---------------------------------------------------------------------------*/
-typedef struct {
- int length; /* length of the following mbuf */
- int unit; /* controller unit number */
- int type; /* type of channel */
-#define TRC_CH_I 0 /* Layer 1 INFO's */
-#define TRC_CH_D 1 /* D channel */
-#define TRC_CH_B1 2 /* B1 channel */
-#define TRC_CH_B2 3 /* B2 channel */
- int dir; /* direction */
-#define FROM_TE 0 /* user -> network */
-#define FROM_NT 1 /* network -> user */
- int trunc; /* # of truncated bytes (frame > MCLBYTES) */
- unsigned int count; /* frame count for this unit/type */
- struct timeval time; /* timestamp for this frame */
-} i4b_trace_hdr_t;
-
-#define INFO0 0 /* layer 1 */
-#define INFO1_8 1
-#define INFO1_10 2
-#define INFO2 3
-#define INFO3 4
-#define INFO4_8 5
-#define INFO4_10 6
-
-/*---------------------------------------------------------------------------*
- * ioctl via /dev/i4btrc device(s):
- * get/set current trace flag settings
- *---------------------------------------------------------------------------*/
-
-#define I4B_TRC_GET _IOR('T', 0, int) /* get trace settings */
-#define I4B_TRC_SET _IOW('T', 1, int) /* set trace settings */
-
-#define TRACE_OFF 0x00 /* tracing off */
-#define TRACE_I 0x01 /* trace L1 INFO's on */
-#define TRACE_D_TX 0x02 /* trace D channel on */
-#define TRACE_D_RX 0x04 /* trace D channel on */
-#define TRACE_B_TX 0x08 /* trace B channel on */
-#define TRACE_B_RX 0x10 /* trace B channel on */
-
-typedef struct {
- int rxunit; /* unit # for rx frames */
- int rxflags; /* d and/or b channel */
- int txunit; /* unit # for tx frames */
- int txflags; /* d and/or b channel */
-} i4b_trace_setupa_t;
-
-#define I4B_TRC_SETA _IOW('T', 2, i4b_trace_setupa_t) /* set analyze mode */
-#define I4B_TRC_RESETA _IOW('T', 3, int) /* reset analyze mode */
-
-#endif /* _I4B_TRACE_H_ */
diff --git a/sys/isa/atrtc.c b/sys/isa/atrtc.c
deleted file mode 100644
index ea39018548b9..000000000000
--- a/sys/isa/atrtc.c
+++ /dev/null
@@ -1,1230 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz and Don Ahn.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)clock.c 7.2 (Berkeley) 5/12/91
- * $FreeBSD$
- */
-
-/*
- * Routines to handle clock hardware.
- */
-
-/*
- * inittodr, settodr and support routines written
- * by Christoph Robitschko <chmr@edvz.tu-graz.ac.at>
- *
- * reintroduced and updated by Chris Stenton <chris@gnome.co.uk> 8/10/94
- */
-
-#include "opt_clock.h"
-#include "apm.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/time.h>
-#include <sys/kernel.h>
-#ifndef SMP
-#include <sys/lock.h>
-#endif
-#include <sys/sysctl.h>
-#include <sys/cons.h>
-
-#include <machine/clock.h>
-#ifdef CLK_CALIBRATION_LOOP
-#endif
-#include <machine/cputypes.h>
-#include <machine/frame.h>
-#include <machine/ipl.h>
-#include <machine/limits.h>
-#include <machine/md_var.h>
-#include <machine/psl.h>
-#ifdef APIC_IO
-#include <machine/segments.h>
-#endif
-#if defined(SMP) || defined(APIC_IO)
-#include <machine/smp.h>
-#endif /* SMP || APIC_IO */
-#include <machine/specialreg.h>
-
-#include <i386/isa/icu.h>
-#include <i386/isa/isa.h>
-#include <isa/rtc.h>
-#include <i386/isa/timerreg.h>
-
-#include <i386/isa/intr_machdep.h>
-
-#include "mca.h"
-#if NMCA > 0
-#include <i386/isa/mca_machdep.h>
-#endif
-
-#ifdef SMP
-#define disable_intr() CLOCK_DISABLE_INTR()
-#define enable_intr() CLOCK_ENABLE_INTR()
-
-#ifdef APIC_IO
-#include <i386/isa/intr_machdep.h>
-/* The interrupt triggered by the 8254 (timer) chip */
-int apic_8254_intr;
-static u_long read_intr_count __P((int vec));
-static void setup_8254_mixed_mode __P((void));
-#endif
-#endif /* SMP */
-
-/*
- * 32-bit time_t's can't reach leap years before 1904 or after 2036, so we
- * can use a simple formula for leap years.
- */
-#define LEAPYEAR(y) ((u_int)(y) % 4 == 0)
-#define DAYSPERYEAR (31+28+31+30+31+30+31+31+30+31+30+31)
-
-#define TIMER_DIV(x) ((timer_freq + (x) / 2) / (x))
-
-/*
- * Time in timer cycles that it takes for microtime() to disable interrupts
- * and latch the count. microtime() currently uses "cli; outb ..." so it
- * normally takes less than 2 timer cycles. Add a few for cache misses.
- * Add a few more to allow for latency in bogus calls to microtime() with
- * interrupts already disabled.
- */
-#define TIMER0_LATCH_COUNT 20
-
-/*
- * Maximum frequency that we are willing to allow for timer0. Must be
- * low enough to guarantee that the timer interrupt handler returns
- * before the next timer interrupt.
- */
-#define TIMER0_MAX_FREQ 20000
-
-int adjkerntz; /* local offset from GMT in seconds */
-int clkintr_pending;
-int disable_rtc_set; /* disable resettodr() if != 0 */
-volatile u_int idelayed;
-int statclock_disable;
-u_int stat_imask = SWI_CLOCK_MASK;
-#ifndef TIMER_FREQ
-#define TIMER_FREQ 1193182
-#endif
-u_int timer_freq = TIMER_FREQ;
-int timer0_max_count;
-u_int tsc_freq;
-int tsc_is_broken;
-int wall_cmos_clock; /* wall CMOS clock assumed if != 0 */
-
-static int beeping = 0;
-static u_int clk_imask = HWI_MASK | SWI_MASK;
-static const u_char daysinmonth[] = {31,28,31,30,31,30,31,31,30,31,30,31};
-static u_int hardclock_max_count;
-static u_int32_t i8254_lastcount;
-static u_int32_t i8254_offset;
-static int i8254_ticked;
-/*
- * XXX new_function and timer_func should not handle clockframes, but
- * timer_func currently needs to hold hardclock to handle the
- * timer0_state == 0 case. We should use inthand_add()/inthand_remove()
- * to switch between clkintr() and a slightly different timerintr().
- */
-static void (*new_function) __P((struct clockframe *frame));
-static u_int new_rate;
-static u_char rtc_statusa = RTCSA_DIVIDER | RTCSA_NOPROF;
-static u_char rtc_statusb = RTCSB_24HR | RTCSB_PINTR;
-static u_int timer0_prescaler_count;
-
-/* Values for timerX_state: */
-#define RELEASED 0
-#define RELEASE_PENDING 1
-#define ACQUIRED 2
-#define ACQUIRE_PENDING 3
-
-static u_char timer0_state;
-static u_char timer2_state;
-static void (*timer_func) __P((struct clockframe *frame)) = hardclock;
-static u_int tsc_present;
-
-static unsigned i8254_get_timecount __P((struct timecounter *tc));
-static unsigned tsc_get_timecount __P((struct timecounter *tc));
-static void set_timer_freq(u_int freq, int intr_freq);
-
-static struct timecounter tsc_timecounter = {
- tsc_get_timecount, /* get_timecount */
- 0, /* no poll_pps */
- ~0u, /* counter_mask */
- 0, /* frequency */
- "TSC" /* name */
-};
-
-SYSCTL_OPAQUE(_debug, OID_AUTO, tsc_timecounter, CTLFLAG_RD,
- &tsc_timecounter, sizeof(tsc_timecounter), "S,timecounter", "");
-
-static struct timecounter i8254_timecounter = {
- i8254_get_timecount, /* get_timecount */
- 0, /* no poll_pps */
- ~0u, /* counter_mask */
- 0, /* frequency */
- "i8254" /* name */
-};
-
-SYSCTL_OPAQUE(_debug, OID_AUTO, i8254_timecounter, CTLFLAG_RD,
- &i8254_timecounter, sizeof(i8254_timecounter), "S,timecounter", "");
-
-static void
-clkintr(struct clockframe frame)
-{
- if (timecounter->tc_get_timecount == i8254_get_timecount) {
- disable_intr();
- if (i8254_ticked)
- i8254_ticked = 0;
- else {
- i8254_offset += timer0_max_count;
- i8254_lastcount = 0;
- }
- clkintr_pending = 0;
- enable_intr();
- }
- timer_func(&frame);
- switch (timer0_state) {
-
- case RELEASED:
- setdelayed();
- break;
-
- case ACQUIRED:
- if ((timer0_prescaler_count += timer0_max_count)
- >= hardclock_max_count) {
- timer0_prescaler_count -= hardclock_max_count;
- hardclock(&frame);
- setdelayed();
- }
- break;
-
- case ACQUIRE_PENDING:
- disable_intr();
- i8254_offset = i8254_get_timecount(NULL);
- i8254_lastcount = 0;
- timer0_max_count = TIMER_DIV(new_rate);
- outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
- outb(TIMER_CNTR0, timer0_max_count & 0xff);
- outb(TIMER_CNTR0, timer0_max_count >> 8);
- enable_intr();
- timer_func = new_function;
- timer0_state = ACQUIRED;
- setdelayed();
- break;
-
- case RELEASE_PENDING:
- if ((timer0_prescaler_count += timer0_max_count)
- >= hardclock_max_count) {
- disable_intr();
- i8254_offset = i8254_get_timecount(NULL);
- i8254_lastcount = 0;
- timer0_max_count = hardclock_max_count;
- outb(TIMER_MODE,
- TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
- outb(TIMER_CNTR0, timer0_max_count & 0xff);
- outb(TIMER_CNTR0, timer0_max_count >> 8);
- enable_intr();
- timer0_prescaler_count = 0;
- timer_func = hardclock;
- timer0_state = RELEASED;
- hardclock(&frame);
- setdelayed();
- }
- break;
- }
-#if NMCA > 0
- /* Reset clock interrupt by asserting bit 7 of port 0x61 */
- if (MCA_system)
- outb(0x61, inb(0x61) | 0x80);
-#endif
-}
-
-/*
- * The acquire and release functions must be called at ipl >= splclock().
- */
-int
-acquire_timer0(int rate, void (*function) __P((struct clockframe *frame)))
-{
- static int old_rate;
-
- if (rate <= 0 || rate > TIMER0_MAX_FREQ)
- return (-1);
- switch (timer0_state) {
-
- case RELEASED:
- timer0_state = ACQUIRE_PENDING;
- break;
-
- case RELEASE_PENDING:
- if (rate != old_rate)
- return (-1);
- /*
- * The timer has been released recently, but is being
- * re-acquired before the release completed. In this
- * case, we simply reclaim it as if it had not been
- * released at all.
- */
- timer0_state = ACQUIRED;
- break;
-
- default:
- return (-1); /* busy */
- }
- new_function = function;
- old_rate = new_rate = rate;
- return (0);
-}
-
-int
-acquire_timer2(int mode)
-{
-
- if (timer2_state != RELEASED)
- return (-1);
- timer2_state = ACQUIRED;
-
- /*
- * This access to the timer registers is as atomic as possible
- * because it is a single instruction. We could do better if we
- * knew the rate. Use of splclock() limits glitches to 10-100us,
- * and this is probably good enough for timer2, so we aren't as
- * careful with it as with timer0.
- */
- outb(TIMER_MODE, TIMER_SEL2 | (mode & 0x3f));
-
- return (0);
-}
-
-int
-release_timer0()
-{
- switch (timer0_state) {
-
- case ACQUIRED:
- timer0_state = RELEASE_PENDING;
- break;
-
- case ACQUIRE_PENDING:
- /* Nothing happened yet, release quickly. */
- timer0_state = RELEASED;
- break;
-
- default:
- return (-1);
- }
- return (0);
-}
-
-int
-release_timer2()
-{
-
- if (timer2_state != ACQUIRED)
- return (-1);
- timer2_state = RELEASED;
- outb(TIMER_MODE, TIMER_SEL2 | TIMER_SQWAVE | TIMER_16BIT);
- return (0);
-}
-
-/*
- * This routine receives statistical clock interrupts from the RTC.
- * As explained above, these occur at 128 interrupts per second.
- * When profiling, we receive interrupts at a rate of 1024 Hz.
- *
- * This does not actually add as much overhead as it sounds, because
- * when the statistical clock is active, the hardclock driver no longer
- * needs to keep (inaccurate) statistics on its own. This decouples
- * statistics gathering from scheduling interrupts.
- *
- * The RTC chip requires that we read status register C (RTC_INTR)
- * to acknowledge an interrupt, before it will generate the next one.
- * Under high interrupt load, rtcintr() can be indefinitely delayed and
- * the clock can tick immediately after the read from RTC_INTR. In this
- * case, the mc146818A interrupt signal will not drop for long enough
- * to register with the 8259 PIC. If an interrupt is missed, the stat
- * clock will halt, considerably degrading system performance. This is
- * why we use 'while' rather than a more straightforward 'if' below.
- * Stat clock ticks can still be lost, causing minor loss of accuracy
- * in the statistics, but the stat clock will no longer stop.
- */
-static void
-rtcintr(struct clockframe frame)
-{
- while (rtcin(RTC_INTR) & RTCIR_PERIOD)
- statclock(&frame);
-}
-
-#include "opt_ddb.h"
-#ifdef DDB
-#include <ddb/ddb.h>
-
-DB_SHOW_COMMAND(rtc, rtc)
-{
- printf("%02x/%02x/%02x %02x:%02x:%02x, A = %02x, B = %02x, C = %02x\n",
- rtcin(RTC_YEAR), rtcin(RTC_MONTH), rtcin(RTC_DAY),
- rtcin(RTC_HRS), rtcin(RTC_MIN), rtcin(RTC_SEC),
- rtcin(RTC_STATUSA), rtcin(RTC_STATUSB), rtcin(RTC_INTR));
-}
-#endif /* DDB */
-
-static int
-getit(void)
-{
- u_long ef;
- int high, low;
-
- ef = read_eflags();
- disable_intr();
-
- /* Select timer0 and latch counter value. */
- outb(TIMER_MODE, TIMER_SEL0 | TIMER_LATCH);
-
- low = inb(TIMER_CNTR0);
- high = inb(TIMER_CNTR0);
-
- CLOCK_UNLOCK();
- write_eflags(ef);
- return ((high << 8) | low);
-}
-
-/*
- * Wait "n" microseconds.
- * Relies on timer 1 counting down from (timer_freq / hz)
- * Note: timer had better have been programmed before this is first used!
- */
-void
-DELAY(int n)
-{
- int delta, prev_tick, tick, ticks_left;
-
-#ifdef DELAYDEBUG
- int getit_calls = 1;
- int n1;
- static int state = 0;
-
- if (state == 0) {
- state = 1;
- for (n1 = 1; n1 <= 10000000; n1 *= 10)
- DELAY(n1);
- state = 2;
- }
- if (state == 1)
- printf("DELAY(%d)...", n);
-#endif
- /*
- * Guard against the timer being uninitialized if we are called
- * early for console i/o.
- */
- if (timer0_max_count == 0)
- set_timer_freq(timer_freq, hz);
-
- /*
- * Read the counter first, so that the rest of the setup overhead is
- * counted. Guess the initial overhead is 20 usec (on most systems it
- * takes about 1.5 usec for each of the i/o's in getit(). The loop
- * takes about 6 usec on a 486/33 and 13 usec on a 386/20. The
- * multiplications and divisions to scale the count take a while).
- */
- prev_tick = getit();
- n -= 0; /* XXX actually guess no initial overhead */
- /*
- * Calculate (n * (timer_freq / 1e6)) without using floating point
- * and without any avoidable overflows.
- */
- if (n <= 0)
- ticks_left = 0;
- else if (n < 256)
- /*
- * Use fixed point to avoid a slow division by 1000000.
- * 39099 = 1193182 * 2^15 / 10^6 rounded to nearest.
- * 2^15 is the first power of 2 that gives exact results
- * for n between 0 and 256.
- */
- ticks_left = ((u_int)n * 39099 + (1 << 15) - 1) >> 15;
- else
- /*
- * Don't bother using fixed point, although gcc-2.7.2
- * generates particularly poor code for the long long
- * division, since even the slow way will complete long
- * before the delay is up (unless we're interrupted).
- */
- ticks_left = ((u_int)n * (long long)timer_freq + 999999)
- / 1000000;
-
- while (ticks_left > 0) {
- tick = getit();
-#ifdef DELAYDEBUG
- ++getit_calls;
-#endif
- delta = prev_tick - tick;
- prev_tick = tick;
- if (delta < 0) {
- delta += timer0_max_count;
- /*
- * Guard against timer0_max_count being wrong.
- * This shouldn't happen in normal operation,
- * but it may happen if set_timer_freq() is
- * traced.
- */
- if (delta < 0)
- delta = 0;
- }
- ticks_left -= delta;
- }
-#ifdef DELAYDEBUG
- if (state == 1)
- printf(" %d calls to getit() at %d usec each\n",
- getit_calls, (n + 5) / getit_calls);
-#endif
-}
-
-static void
-sysbeepstop(void *chan)
-{
- outb(IO_PPI, inb(IO_PPI)&0xFC); /* disable counter2 output to speaker */
- release_timer2();
- beeping = 0;
-}
-
-int
-sysbeep(int pitch, int period)
-{
- int x = splclock();
-
- if (acquire_timer2(TIMER_SQWAVE|TIMER_16BIT))
- if (!beeping) {
- /* Something else owns it. */
- splx(x);
- return (-1); /* XXX Should be EBUSY, but nobody cares anyway. */
- }
- disable_intr();
- outb(TIMER_CNTR2, pitch);
- outb(TIMER_CNTR2, (pitch>>8));
- enable_intr();
- if (!beeping) {
- /* enable counter2 output to speaker */
- outb(IO_PPI, inb(IO_PPI) | 3);
- beeping = period;
- timeout(sysbeepstop, (void *)NULL, period);
- }
- splx(x);
- return (0);
-}
-
-/*
- * RTC support routines
- */
-
-int
-rtcin(reg)
- int reg;
-{
- int s;
- u_char val;
-
- s = splhigh();
- outb(IO_RTC, reg);
- inb(0x84);
- val = inb(IO_RTC + 1);
- inb(0x84);
- splx(s);
- return (val);
-}
-
-static __inline void
-writertc(u_char reg, u_char val)
-{
- int s;
-
- s = splhigh();
- inb(0x84);
- outb(IO_RTC, reg);
- inb(0x84);
- outb(IO_RTC + 1, val);
- inb(0x84); /* XXX work around wrong order in rtcin() */
- splx(s);
-}
-
-static __inline int
-readrtc(int port)
-{
- return(bcd2bin(rtcin(port)));
-}
-
-static u_int
-calibrate_clocks(void)
-{
- u_int64_t old_tsc;
- u_int count, prev_count, tot_count;
- int sec, start_sec, timeout;
-
- if (bootverbose)
- printf("Calibrating clock(s) ... ");
- if (!(rtcin(RTC_STATUSD) & RTCSD_PWR))
- goto fail;
- timeout = 100000000;
-
- /* Read the mc146818A seconds counter. */
- for (;;) {
- if (!(rtcin(RTC_STATUSA) & RTCSA_TUP)) {
- sec = rtcin(RTC_SEC);
- break;
- }
- if (--timeout == 0)
- goto fail;
- }
-
- /* Wait for the mC146818A seconds counter to change. */
- start_sec = sec;
- for (;;) {
- if (!(rtcin(RTC_STATUSA) & RTCSA_TUP)) {
- sec = rtcin(RTC_SEC);
- if (sec != start_sec)
- break;
- }
- if (--timeout == 0)
- goto fail;
- }
-
- /* Start keeping track of the i8254 counter. */
- prev_count = getit();
- if (prev_count == 0 || prev_count > timer0_max_count)
- goto fail;
- tot_count = 0;
-
- if (tsc_present)
- old_tsc = rdtsc();
- else
- old_tsc = 0; /* shut up gcc */
-
- /*
- * Wait for the mc146818A seconds counter to change. Read the i8254
- * counter for each iteration since this is convenient and only
- * costs a few usec of inaccuracy. The timing of the final reads
- * of the counters almost matches the timing of the initial reads,
- * so the main cause of inaccuracy is the varying latency from
- * inside getit() or rtcin(RTC_STATUSA) to the beginning of the
- * rtcin(RTC_SEC) that returns a changed seconds count. The
- * maximum inaccuracy from this cause is < 10 usec on 486's.
- */
- start_sec = sec;
- for (;;) {
- if (!(rtcin(RTC_STATUSA) & RTCSA_TUP))
- sec = rtcin(RTC_SEC);
- count = getit();
- if (count == 0 || count > timer0_max_count)
- goto fail;
- if (count > prev_count)
- tot_count += prev_count - (count - timer0_max_count);
- else
- tot_count += prev_count - count;
- prev_count = count;
- if (sec != start_sec)
- break;
- if (--timeout == 0)
- goto fail;
- }
-
- /*
- * Read the cpu cycle counter. The timing considerations are
- * similar to those for the i8254 clock.
- */
- if (tsc_present)
- tsc_freq = rdtsc() - old_tsc;
-
- if (bootverbose) {
- if (tsc_present)
- printf("TSC clock: %u Hz, ", tsc_freq);
- printf("i8254 clock: %u Hz\n", tot_count);
- }
- return (tot_count);
-
-fail:
- if (bootverbose)
- printf("failed, using default i8254 clock of %u Hz\n",
- timer_freq);
- return (timer_freq);
-}
-
-static void
-set_timer_freq(u_int freq, int intr_freq)
-{
- u_long ef;
- int new_timer0_max_count;
-
- ef = read_eflags();
- disable_intr();
- timer_freq = freq;
- new_timer0_max_count = hardclock_max_count = TIMER_DIV(intr_freq);
- if (new_timer0_max_count != timer0_max_count) {
- timer0_max_count = new_timer0_max_count;
- outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
- outb(TIMER_CNTR0, timer0_max_count & 0xff);
- outb(TIMER_CNTR0, timer0_max_count >> 8);
- }
- CLOCK_UNLOCK();
- write_eflags(ef);
-}
-
-/*
- * i8254_restore is called from apm_default_resume() to reload
- * the countdown register.
- * this should not be necessary but there are broken laptops that
- * do not restore the countdown register on resume.
- * when it happnes, it messes up the hardclock interval and system clock,
- * which leads to the infamous "calcru: negative time" problem.
- */
-void
-i8254_restore(void)
-{
- u_long ef;
-
- ef = read_eflags();
- disable_intr();
- outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
- outb(TIMER_CNTR0, timer0_max_count & 0xff);
- outb(TIMER_CNTR0, timer0_max_count >> 8);
- CLOCK_UNLOCK();
- write_eflags(ef);
-}
-
-/*
- * Initialize 8254 timer 0 early so that it can be used in DELAY().
- * XXX initialization of other timers is unintentionally left blank.
- */
-void
-startrtclock()
-{
- u_int delta, freq;
-
- if (cpu_feature & CPUID_TSC)
- tsc_present = 1;
- else
- tsc_present = 0;
-
- writertc(RTC_STATUSA, rtc_statusa);
- writertc(RTC_STATUSB, RTCSB_24HR);
-
- set_timer_freq(timer_freq, hz);
- freq = calibrate_clocks();
-#ifdef CLK_CALIBRATION_LOOP
- if (bootverbose) {
- printf(
- "Press a key on the console to abort clock calibration\n");
- while (cncheckc() == -1)
- calibrate_clocks();
- }
-#endif
-
- /*
- * Use the calibrated i8254 frequency if it seems reasonable.
- * Otherwise use the default, and don't use the calibrated i586
- * frequency.
- */
- delta = freq > timer_freq ? freq - timer_freq : timer_freq - freq;
- if (delta < timer_freq / 100) {
-#ifndef CLK_USE_I8254_CALIBRATION
- if (bootverbose)
- printf(
-"CLK_USE_I8254_CALIBRATION not specified - using default frequency\n");
- freq = timer_freq;
-#endif
- timer_freq = freq;
- } else {
- if (bootverbose)
- printf(
- "%d Hz differs from default of %d Hz by more than 1%%\n",
- freq, timer_freq);
- tsc_freq = 0;
- }
-
- set_timer_freq(timer_freq, hz);
- i8254_timecounter.tc_frequency = timer_freq;
- init_timecounter(&i8254_timecounter);
-
-#ifndef CLK_USE_TSC_CALIBRATION
- if (tsc_freq != 0) {
- if (bootverbose)
- printf(
-"CLK_USE_TSC_CALIBRATION not specified - using old calibration method\n");
- tsc_freq = 0;
- }
-#endif
- if (tsc_present && tsc_freq == 0) {
- /*
- * Calibration of the i586 clock relative to the mc146818A
- * clock failed. Do a less accurate calibration relative
- * to the i8254 clock.
- */
- u_int64_t old_tsc = rdtsc();
-
- DELAY(1000000);
- tsc_freq = rdtsc() - old_tsc;
-#ifdef CLK_USE_TSC_CALIBRATION
- if (bootverbose)
- printf("TSC clock: %u Hz (Method B)\n", tsc_freq);
-#endif
- }
-
-#if !defined(SMP)
- /*
- * We can not use the TSC in SMP mode, until we figure out a
- * cheap (impossible), reliable and precise (yeah right!) way
- * to synchronize the TSCs of all the CPUs.
- * Curse Intel for leaving the counter out of the I/O APIC.
- */
-
-#if NAPM > 0
- /*
- * We can not use the TSC if we support APM. Precise timekeeping
- * on an APM'ed machine is at best a fools pursuit, since
- * any and all of the time spent in various SMM code can't
- * be reliably accounted for. Reading the RTC is your only
- * source of reliable time info. The i8254 looses too of course
- * but we need to have some kind of time...
- * We don't know at this point whether APM is going to be used
- * or not, nor when it might be activated. Play it safe.
- */
- return;
-#endif /* NAPM > 0 */
-
- if (tsc_present && tsc_freq != 0 && !tsc_is_broken) {
- tsc_timecounter.tc_frequency = tsc_freq;
- init_timecounter(&tsc_timecounter);
- }
-
-#endif /* !defined(SMP) */
-}
-
-/*
- * Initialize the time of day register, based on the time base which is, e.g.
- * from a filesystem.
- */
-void
-inittodr(time_t base)
-{
- unsigned long sec, days;
- int yd;
- int year, month;
- int y, m, s;
- struct timespec ts;
-
- if (base) {
- s = splclock();
- ts.tv_sec = base;
- ts.tv_nsec = 0;
- set_timecounter(&ts);
- splx(s);
- }
-
- /* Look if we have a RTC present and the time is valid */
- if (!(rtcin(RTC_STATUSD) & RTCSD_PWR))
- goto wrong_time;
-
- /* wait for time update to complete */
- /* If RTCSA_TUP is zero, we have at least 244us before next update */
- s = splhigh();
- while (rtcin(RTC_STATUSA) & RTCSA_TUP) {
- splx(s);
- s = splhigh();
- }
-
- days = 0;
-#ifdef USE_RTC_CENTURY
- year = readrtc(RTC_YEAR) + readrtc(RTC_CENTURY) * 100;
-#else
- year = readrtc(RTC_YEAR) + 1900;
- if (year < 1970)
- year += 100;
-#endif
- if (year < 1970) {
- splx(s);
- goto wrong_time;
- }
- month = readrtc(RTC_MONTH);
- for (m = 1; m < month; m++)
- days += daysinmonth[m-1];
- if ((month > 2) && LEAPYEAR(year))
- days ++;
- days += readrtc(RTC_DAY) - 1;
- yd = days;
- for (y = 1970; y < year; y++)
- days += DAYSPERYEAR + LEAPYEAR(y);
- sec = ((( days * 24 +
- readrtc(RTC_HRS)) * 60 +
- readrtc(RTC_MIN)) * 60 +
- readrtc(RTC_SEC));
- /* sec now contains the number of seconds, since Jan 1 1970,
- in the local time zone */
-
- sec += tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
-
- y = time_second - sec;
- if (y <= -2 || y >= 2) {
- /* badly off, adjust it */
- ts.tv_sec = sec;
- ts.tv_nsec = 0;
- set_timecounter(&ts);
- }
- splx(s);
- return;
-
-wrong_time:
- printf("Invalid time in real time clock.\n");
- printf("Check and reset the date immediately!\n");
-}
-
-/*
- * Write system time back to RTC
- */
-void
-resettodr()
-{
- unsigned long tm;
- int y, m, s;
-
- if (disable_rtc_set)
- return;
-
- s = splclock();
- tm = time_second;
- splx(s);
-
- /* Disable RTC updates and interrupts. */
- writertc(RTC_STATUSB, RTCSB_HALT | RTCSB_24HR);
-
- /* Calculate local time to put in RTC */
-
- tm -= tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
-
- writertc(RTC_SEC, bin2bcd(tm%60)); tm /= 60; /* Write back Seconds */
- writertc(RTC_MIN, bin2bcd(tm%60)); tm /= 60; /* Write back Minutes */
- writertc(RTC_HRS, bin2bcd(tm%24)); tm /= 24; /* Write back Hours */
-
- /* We have now the days since 01-01-1970 in tm */
- writertc(RTC_WDAY, (tm+4)%7); /* Write back Weekday */
- for (y = 1970, m = DAYSPERYEAR + LEAPYEAR(y);
- tm >= m;
- y++, m = DAYSPERYEAR + LEAPYEAR(y))
- tm -= m;
-
- /* Now we have the years in y and the day-of-the-year in tm */
- writertc(RTC_YEAR, bin2bcd(y%100)); /* Write back Year */
-#ifdef USE_RTC_CENTURY
- writertc(RTC_CENTURY, bin2bcd(y/100)); /* ... and Century */
-#endif
- for (m = 0; ; m++) {
- int ml;
-
- ml = daysinmonth[m];
- if (m == 1 && LEAPYEAR(y))
- ml++;
- if (tm < ml)
- break;
- tm -= ml;
- }
-
- writertc(RTC_MONTH, bin2bcd(m + 1)); /* Write back Month */
- writertc(RTC_DAY, bin2bcd(tm + 1)); /* Write back Month Day */
-
- /* Reenable RTC updates and interrupts. */
- writertc(RTC_STATUSB, rtc_statusb);
-}
-
-
-/*
- * Start both clocks running.
- */
-void
-cpu_initclocks()
-{
- int diag;
-#ifdef APIC_IO
- int apic_8254_trial;
- struct intrec *clkdesc;
-#endif /* APIC_IO */
-
- if (statclock_disable) {
- /*
- * The stat interrupt mask is different without the
- * statistics clock. Also, don't set the interrupt
- * flag which would normally cause the RTC to generate
- * interrupts.
- */
- stat_imask = HWI_MASK | SWI_MASK;
- rtc_statusb = RTCSB_24HR;
- } else {
- /* Setting stathz to nonzero early helps avoid races. */
- stathz = RTC_NOPROFRATE;
- profhz = RTC_PROFRATE;
- }
-
- /* Finish initializing 8253 timer 0. */
-#ifdef APIC_IO
-
- apic_8254_intr = isa_apic_irq(0);
- apic_8254_trial = 0;
- if (apic_8254_intr >= 0 ) {
- if (apic_int_type(0, 0) == 3)
- apic_8254_trial = 1;
- } else {
- /* look for ExtInt on pin 0 */
- if (apic_int_type(0, 0) == 3) {
- apic_8254_intr = apic_irq(0, 0);
- setup_8254_mixed_mode();
- } else
- panic("APIC_IO: Cannot route 8254 interrupt to CPU");
- }
-
- clkdesc = inthand_add("clk", apic_8254_intr, (inthand2_t *)clkintr,
- NULL, &clk_imask, INTR_EXCL);
- INTREN(1 << apic_8254_intr);
-
-#else /* APIC_IO */
-
- inthand_add("clk", 0, (inthand2_t *)clkintr, NULL, &clk_imask,
- INTR_EXCL);
- INTREN(IRQ0);
-
-#endif /* APIC_IO */
-
- /* Initialize RTC. */
- writertc(RTC_STATUSA, rtc_statusa);
- writertc(RTC_STATUSB, RTCSB_24HR);
-
- /* Don't bother enabling the statistics clock. */
- if (statclock_disable)
- return;
- diag = rtcin(RTC_DIAG);
- if (diag != 0)
- printf("RTC BIOS diagnostic error %b\n", diag, RTCDG_BITS);
-
-#ifdef APIC_IO
- if (isa_apic_irq(8) != 8)
- panic("APIC RTC != 8");
-#endif /* APIC_IO */
-
- inthand_add("rtc", 8, (inthand2_t *)rtcintr, NULL, &stat_imask,
- INTR_EXCL);
-
-#ifdef APIC_IO
- INTREN(APIC_IRQ8);
-#else
- INTREN(IRQ8);
-#endif /* APIC_IO */
-
- writertc(RTC_STATUSB, rtc_statusb);
-
-#ifdef APIC_IO
- if (apic_8254_trial) {
-
- printf("APIC_IO: Testing 8254 interrupt delivery\n");
- while (read_intr_count(8) < 6)
- ; /* nothing */
- if (read_intr_count(apic_8254_intr) < 3) {
- /*
- * The MP table is broken.
- * The 8254 was not connected to the specified pin
- * on the IO APIC.
- * Workaround: Limited variant of mixed mode.
- */
- INTRDIS(1 << apic_8254_intr);
- inthand_remove(clkdesc);
- printf("APIC_IO: Broken MP table detected: "
- "8254 is not connected to "
- "IOAPIC #%d intpin %d\n",
- int_to_apicintpin[apic_8254_intr].ioapic,
- int_to_apicintpin[apic_8254_intr].int_pin);
- /*
- * Revoke current ISA IRQ 0 assignment and
- * configure a fallback interrupt routing from
- * the 8254 Timer via the 8259 PIC to the
- * an ExtInt interrupt line on IOAPIC #0 intpin 0.
- * We reuse the low level interrupt handler number.
- */
- if (apic_irq(0, 0) < 0) {
- revoke_apic_irq(apic_8254_intr);
- assign_apic_irq(0, 0, apic_8254_intr);
- }
- apic_8254_intr = apic_irq(0, 0);
- setup_8254_mixed_mode();
- inthand_add("clk", apic_8254_intr,
- (inthand2_t *)clkintr,
- NULL, &clk_imask, INTR_EXCL);
- INTREN(1 << apic_8254_intr);
- }
-
- }
- if (apic_int_type(0, 0) != 3 ||
- int_to_apicintpin[apic_8254_intr].ioapic != 0 ||
- int_to_apicintpin[apic_8254_intr].int_pin != 0)
- printf("APIC_IO: routing 8254 via IOAPIC #%d intpin %d\n",
- int_to_apicintpin[apic_8254_intr].ioapic,
- int_to_apicintpin[apic_8254_intr].int_pin);
- else
- printf("APIC_IO: "
- "routing 8254 via 8259 and IOAPIC #0 intpin 0\n");
-#endif
-
-}
-
-#ifdef APIC_IO
-static u_long
-read_intr_count(int vec)
-{
- u_long *up;
- up = intr_countp[vec];
- if (up)
- return *up;
- return 0UL;
-}
-
-static void
-setup_8254_mixed_mode()
-{
- /*
- * Allow 8254 timer to INTerrupt 8259:
- * re-initialize master 8259:
- * reset; prog 4 bytes, single ICU, edge triggered
- */
- outb(IO_ICU1, 0x13);
- outb(IO_ICU1 + 1, NRSVIDT); /* start vector (unused) */
- outb(IO_ICU1 + 1, 0x00); /* ignore slave */
- outb(IO_ICU1 + 1, 0x03); /* auto EOI, 8086 */
- outb(IO_ICU1 + 1, 0xfe); /* unmask INT0 */
-
- /* program IO APIC for type 3 INT on INT0 */
- if (ext_int_setup(0, 0) < 0)
- panic("8254 redirect via APIC pin0 impossible!");
-}
-#endif
-
-void
-setstatclockrate(int newhz)
-{
- if (newhz == RTC_PROFRATE)
- rtc_statusa = RTCSA_DIVIDER | RTCSA_PROF;
- else
- rtc_statusa = RTCSA_DIVIDER | RTCSA_NOPROF;
- writertc(RTC_STATUSA, rtc_statusa);
-}
-
-static int
-sysctl_machdep_i8254_freq SYSCTL_HANDLER_ARGS
-{
- int error;
- u_int freq;
-
- /*
- * Use `i8254' instead of `timer' in external names because `timer'
- * is is too generic. Should use it everywhere.
- */
- freq = timer_freq;
- error = sysctl_handle_int(oidp, &freq, sizeof(freq), req);
- if (error == 0 && req->newptr != NULL) {
- if (timer0_state != RELEASED)
- return (EBUSY); /* too much trouble to handle */
- set_timer_freq(freq, hz);
- i8254_timecounter.tc_frequency = freq;
- update_timecounter(&i8254_timecounter);
- }
- return (error);
-}
-
-SYSCTL_PROC(_machdep, OID_AUTO, i8254_freq, CTLTYPE_INT | CTLFLAG_RW,
- 0, sizeof(u_int), sysctl_machdep_i8254_freq, "I", "");
-
-static int
-sysctl_machdep_tsc_freq SYSCTL_HANDLER_ARGS
-{
- int error;
- u_int freq;
-
- if (tsc_timecounter.tc_frequency == 0)
- return (EOPNOTSUPP);
- freq = tsc_freq;
- error = sysctl_handle_int(oidp, &freq, sizeof(freq), req);
- if (error == 0 && req->newptr != NULL) {
- tsc_freq = freq;
- tsc_timecounter.tc_frequency = tsc_freq;
- update_timecounter(&tsc_timecounter);
- }
- return (error);
-}
-
-SYSCTL_PROC(_machdep, OID_AUTO, tsc_freq, CTLTYPE_INT | CTLFLAG_RW,
- 0, sizeof(u_int), sysctl_machdep_tsc_freq, "I", "");
-
-static unsigned
-i8254_get_timecount(struct timecounter *tc)
-{
- u_int count;
- u_long ef;
- u_int high, low;
-
- ef = read_eflags();
- disable_intr();
-
- /* Select timer0 and latch counter value. */
- outb(TIMER_MODE, TIMER_SEL0 | TIMER_LATCH);
-
- low = inb(TIMER_CNTR0);
- high = inb(TIMER_CNTR0);
- count = timer0_max_count - ((high << 8) | low);
- if (count < i8254_lastcount ||
- (!i8254_ticked && (clkintr_pending ||
- ((count < 20 || (!(ef & PSL_I) && count < timer0_max_count / 2u)) &&
-#ifdef APIC_IO
-#define lapic_irr1 ((volatile u_int *)&lapic)[0x210 / 4] /* XXX XXX */
- /* XXX this assumes that apic_8254_intr is < 24. */
- (lapic_irr1 & (1 << apic_8254_intr))))
-#else
- (inb(IO_ICU1) & 1)))
-#endif
- )) {
- i8254_ticked = 1;
- i8254_offset += timer0_max_count;
- }
- i8254_lastcount = count;
- count += i8254_offset;
- CLOCK_UNLOCK();
- write_eflags(ef);
- return (count);
-}
-
-static unsigned
-tsc_get_timecount(struct timecounter *tc)
-{
- return (rdtsc());
-}
diff --git a/sys/kern/kern_random.c b/sys/kern/kern_random.c
deleted file mode 100644
index ef63742579e0..000000000000
--- a/sys/kern/kern_random.c
+++ /dev/null
@@ -1,378 +0,0 @@
-/*
- * random_machdep.c -- A strong random number generator
- *
- * $FreeBSD$
- *
- * Version 0.95, last modified 18-Oct-95
- *
- * Copyright Theodore Ts'o, 1994, 1995. 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, and the entire permission notice in its entirety,
- * including the disclaimer of warranties.
- * 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.
- *
- * ALTERNATIVELY, this product may be distributed under the terms of
- * the GNU Public License, in which case the provisions of the GPL are
- * required INSTEAD OF the above restrictions. (This clause is
- * necessary due to a potential bad interaction between the GPL and
- * the restrictions contained in a BSD-style copyright.)
- *
- * 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 <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/select.h>
-#include <sys/poll.h>
-#include <sys/md5.h>
-
-#include <machine/random.h>
-
-#include <i386/isa/icu.h>
-
-#define MAX_BLKDEV 4
-
-/*
- * The pool is stirred with a primitive polynomial of degree 128
- * over GF(2), namely x^128 + x^99 + x^59 + x^31 + x^9 + x^7 + 1.
- * For a pool of size 64, try x^64+x^62+x^38+x^10+x^6+x+1.
- */
-#define POOLWORDS 128 /* Power of 2 - note that this is 32-bit words */
-#define POOLBITS (POOLWORDS*32)
-
-#if POOLWORDS == 128
-#define TAP1 99 /* The polynomial taps */
-#define TAP2 59
-#define TAP3 31
-#define TAP4 9
-#define TAP5 7
-#elif POOLWORDS == 64
-#define TAP1 62 /* The polynomial taps */
-#define TAP2 38
-#define TAP3 10
-#define TAP4 6
-#define TAP5 1
-#else
-#error No primitive polynomial available for chosen POOLWORDS
-#endif
-
-#define WRITEBUFFER 512 /* size in bytes */
-
-/* There is actually only one of these, globally. */
-struct random_bucket {
- u_int add_ptr;
- u_int entropy_count;
- int input_rotate;
- u_int32_t *pool;
- struct selinfo rsel;
-};
-
-/* There is one of these per entropy source */
-struct timer_rand_state {
- u_long last_time;
- int last_delta;
- int nbits;
-};
-
-static struct random_bucket random_state;
-static u_int32_t random_pool[POOLWORDS];
-static struct timer_rand_state keyboard_timer_state;
-static struct timer_rand_state extract_timer_state;
-static struct timer_rand_state irq_timer_state[ICU_LEN];
-#ifdef notyet
-static struct timer_rand_state blkdev_timer_state[MAX_BLKDEV];
-#endif
-static struct wait_queue *random_wait;
-
-#ifndef MIN
-#define MIN(a,b) (((a) < (b)) ? (a) : (b))
-#endif
-
-void
-rand_initialize(void)
-{
- random_state.add_ptr = 0;
- random_state.entropy_count = 0;
- random_state.pool = random_pool;
- random_wait = NULL;
- random_state.rsel.si_flags = 0;
- random_state.rsel.si_pid = 0;
-}
-
-/*
- * This function adds an int into the entropy "pool". It does not
- * update the entropy estimate. The caller must do this if appropriate.
- *
- * The pool is stirred with a primitive polynomial of degree 128
- * over GF(2), namely x^128 + x^99 + x^59 + x^31 + x^9 + x^7 + 1.
- * For a pool of size 64, try x^64+x^62+x^38+x^10+x^6+x+1.
- *
- * We rotate the input word by a changing number of bits, to help
- * assure that all bits in the entropy get toggled. Otherwise, if we
- * consistently feed the entropy pool small numbers (like ticks and
- * scancodes, for example), the upper bits of the entropy pool don't
- * get affected. --- TYT, 10/11/95
- */
-static __inline void
-add_entropy_word(struct random_bucket *r, const u_int32_t input)
-{
- u_int i;
- u_int32_t w;
-
- w = (input << r->input_rotate) | (input >> (32 - r->input_rotate));
- i = r->add_ptr = (r->add_ptr - 1) & (POOLWORDS-1);
- if (i)
- r->input_rotate = (r->input_rotate + 7) & 31;
- else
- /*
- * At the beginning of the pool, add an extra 7 bits
- * rotation, so that successive passes spread the
- * input bits across the pool evenly.
- */
- r->input_rotate = (r->input_rotate + 14) & 31;
-
- /* XOR in the various taps */
- w ^= r->pool[(i+TAP1)&(POOLWORDS-1)];
- w ^= r->pool[(i+TAP2)&(POOLWORDS-1)];
- w ^= r->pool[(i+TAP3)&(POOLWORDS-1)];
- w ^= r->pool[(i+TAP4)&(POOLWORDS-1)];
- w ^= r->pool[(i+TAP5)&(POOLWORDS-1)];
- w ^= r->pool[i];
- /* Rotate w left 1 bit (stolen from SHA) and store */
- r->pool[i] = (w << 1) | (w >> 31);
-}
-
-/*
- * This function adds entropy to the entropy "pool" by using timing
- * delays. It uses the timer_rand_state structure to make an estimate
- * of how any bits of entropy this call has added to the pool.
- *
- * The number "num" is also added to the pool - it should somehow describe
- * the type of event which just happened. This is currently 0-255 for
- * keyboard scan codes, and 256 upwards for interrupts.
- * On the i386, this is assumed to be at most 16 bits, and the high bits
- * are used for a high-resolution timer.
- */
-static void
-add_timer_randomness(struct random_bucket *r, struct timer_rand_state *state,
- u_int num)
-{
- int delta, delta2;
- u_int nbits;
- u_int32_t time;
-
- num ^= timecounter->tc_get_timecount(timecounter) << 16;
- r->entropy_count += 2;
-
- time = ticks;
-
- add_entropy_word(r, (u_int32_t) num);
- add_entropy_word(r, time);
-
- /*
- * Calculate number of bits of randomness we probably
- * added. We take into account the first and second order
- * deltas in order to make our estimate.
- */
- delta = time - state->last_time;
- state->last_time = time;
-
- delta2 = delta - state->last_delta;
- state->last_delta = delta;
-
- if (delta < 0) delta = -delta;
- if (delta2 < 0) delta2 = -delta2;
- delta = MIN(delta, delta2) >> 1;
- for (nbits = 0; delta; nbits++)
- delta >>= 1;
-
- r->entropy_count += nbits;
-
- /* Prevent overflow */
- if (r->entropy_count > POOLBITS)
- r->entropy_count = POOLBITS;
-
- if (r->entropy_count >= 8)
- selwakeup(&random_state.rsel);
-}
-
-void
-add_keyboard_randomness(u_char scancode)
-{
- add_timer_randomness(&random_state, &keyboard_timer_state, scancode);
-}
-
-void
-add_interrupt_randomness(void *vsc)
-{
- int intr;
- struct random_softc *sc = vsc;
-
- (sc->sc_handler)(sc->sc_arg);
- intr = sc->sc_intr;
- add_timer_randomness(&random_state, &irq_timer_state[intr], intr);
-}
-
-#ifdef notused
-void
-add_blkdev_randomness(int major)
-{
- if (major >= MAX_BLKDEV)
- return;
-
- add_timer_randomness(&random_state, &blkdev_timer_state[major],
- 0x200+major);
-}
-#endif /* notused */
-
-#if POOLWORDS % 16
-#error extract_entropy() assumes that POOLWORDS is a multiple of 16 words.
-#endif
-/*
- * This function extracts randomness from the "entropy pool", and
- * returns it in a buffer. This function computes how many remaining
- * bits of entropy are left in the pool, but it does not restrict the
- * number of bytes that are actually obtained.
- */
-static __inline int
-extract_entropy(struct random_bucket *r, char *buf, int nbytes)
-{
- int ret, i;
- u_int32_t tmp[4];
-
- add_timer_randomness(r, &extract_timer_state, nbytes);
-
- /* Redundant, but just in case... */
- if (r->entropy_count > POOLBITS)
- r->entropy_count = POOLBITS;
- /* Why is this here? Left in from Ted Ts'o. Perhaps to limit time. */
- if (nbytes > 32768)
- nbytes = 32768;
-
- ret = nbytes;
- if (r->entropy_count / 8 >= nbytes)
- r->entropy_count -= nbytes*8;
- else
- r->entropy_count = 0;
-
- while (nbytes) {
- /* Hash the pool to get the output */
- tmp[0] = 0x67452301;
- tmp[1] = 0xefcdab89;
- tmp[2] = 0x98badcfe;
- tmp[3] = 0x10325476;
- for (i = 0; i < POOLWORDS; i += 16)
- MD5Transform(tmp, (char *)(r->pool+i));
- /* Modify pool so next hash will produce different results */
- add_entropy_word(r, tmp[0]);
- add_entropy_word(r, tmp[1]);
- add_entropy_word(r, tmp[2]);
- add_entropy_word(r, tmp[3]);
- /*
- * Run the MD5 Transform one more time, since we want
- * to add at least minimal obscuring of the inputs to
- * add_entropy_word(). --- TYT
- */
- MD5Transform(tmp, (char *)(r->pool));
-
- /* Copy data to destination buffer */
- i = MIN(nbytes, 16);
- bcopy(tmp, buf, i);
- nbytes -= i;
- buf += i;
- }
-
- /* Wipe data from memory */
- bzero(tmp, sizeof(tmp));
-
- return ret;
-}
-
-#ifdef notused /* XXX NOT the exported kernel interface */
-/*
- * This function is the exported kernel interface. It returns some
- * number of good random numbers, suitable for seeding TCP sequence
- * numbers, etc.
- */
-void
-get_random_bytes(void *buf, u_int nbytes)
-{
- extract_entropy(&random_state, (char *) buf, nbytes);
-}
-#endif /* notused */
-
-u_int
-read_random(void *buf, u_int nbytes)
-{
- if ((nbytes * 8) > random_state.entropy_count)
- nbytes = random_state.entropy_count / 8;
-
- return extract_entropy(&random_state, (char *)buf, nbytes);
-}
-
-u_int
-read_random_unlimited(void *buf, u_int nbytes)
-{
- return extract_entropy(&random_state, (char *)buf, nbytes);
-}
-
-#ifdef notused
-u_int
-write_random(const char *buf, u_int nbytes)
-{
- u_int i;
- u_int32_t word, *p;
-
- for (i = nbytes, p = (u_int32_t *)buf;
- i >= sizeof(u_int32_t);
- i-= sizeof(u_int32_t), p++)
- add_entropy_word(&random_state, *p);
- if (i) {
- word = 0;
- bcopy(p, &word, i);
- add_entropy_word(&random_state, word);
- }
- return nbytes;
-}
-#endif /* notused */
-
-int
-random_poll(dev_t dev, int events, struct proc *p)
-{
- int s;
- int revents = 0;
-
- s = splhigh();
- if (events & (POLLIN | POLLRDNORM)) {
- if (random_state.entropy_count >= 8)
- revents |= events & (POLLIN | POLLRDNORM);
- else
- selrecord(p, &random_state.rsel);
- }
- splx(s);
- if (events & (POLLOUT | POLLWRNORM))
- revents |= events & (POLLOUT | POLLWRNORM); /* heh */
-
- return (revents);
-}
-
diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c
deleted file mode 100644
index 6166e1cb2518..000000000000
--- a/sys/kern/kern_tc.c
+++ /dev/null
@@ -1,1004 +0,0 @@
-/*-
- * Copyright (c) 1997, 1998 Poul-Henning Kamp <phk@FreeBSD.org>
- * Copyright (c) 1982, 1986, 1991, 1993
- * The Regents of the University of California. All rights reserved.
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)kern_clock.c 8.5 (Berkeley) 1/21/94
- * $FreeBSD$
- */
-
-#include "opt_ntp.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/dkstat.h>
-#include <sys/callout.h>
-#include <sys/kernel.h>
-#include <sys/proc.h>
-#include <sys/malloc.h>
-#include <sys/resourcevar.h>
-#include <sys/signalvar.h>
-#include <sys/timex.h>
-#include <sys/timepps.h>
-#include <vm/vm.h>
-#include <sys/lock.h>
-#include <vm/pmap.h>
-#include <vm/vm_map.h>
-#include <sys/sysctl.h>
-
-#include <machine/cpu.h>
-#include <machine/limits.h>
-
-#ifdef GPROF
-#include <sys/gmon.h>
-#endif
-
-#if defined(SMP) && defined(BETTER_CLOCK)
-#include <machine/smp.h>
-#endif
-
-/*
- * Number of timecounters used to implement stable storage
- */
-#ifndef NTIMECOUNTER
-#define NTIMECOUNTER 5
-#endif
-
-static MALLOC_DEFINE(M_TIMECOUNTER, "timecounter",
- "Timecounter stable storage");
-
-static void initclocks __P((void *dummy));
-SYSINIT(clocks, SI_SUB_CLOCKS, SI_ORDER_FIRST, initclocks, NULL)
-
-static void tco_forward __P((int force));
-static void tco_setscales __P((struct timecounter *tc));
-static __inline unsigned tco_delta __P((struct timecounter *tc));
-
-/* Some of these don't belong here, but it's easiest to concentrate them. */
-#if defined(SMP) && defined(BETTER_CLOCK)
-long cp_time[CPUSTATES];
-#else
-static long cp_time[CPUSTATES];
-#endif
-
-long tk_cancc;
-long tk_nin;
-long tk_nout;
-long tk_rawcc;
-
-time_t time_second;
-
-struct timeval boottime;
-SYSCTL_STRUCT(_kern, KERN_BOOTTIME, boottime, CTLFLAG_RD,
- &boottime, timeval, "System boottime");
-
-/*
- * Which update policy to use.
- * 0 - every tick, bad hardware may fail with "calcru negative..."
- * 1 - more resistent to the above hardware, but less efficient.
- */
-static int tco_method;
-
-/*
- * Implement a dummy timecounter which we can use until we get a real one
- * in the air. This allows the console and other early stuff to use
- * timeservices.
- */
-
-static unsigned
-dummy_get_timecount(struct timecounter *tc)
-{
- static unsigned now;
- return (++now);
-}
-
-static struct timecounter dummy_timecounter = {
- dummy_get_timecount,
- 0,
- ~0u,
- 1000000,
- "dummy"
-};
-
-struct timecounter *timecounter = &dummy_timecounter;
-
-/*
- * Clock handling routines.
- *
- * This code is written to operate with two timers that run independently of
- * each other.
- *
- * The main timer, running hz times per second, is used to trigger interval
- * timers, timeouts and rescheduling as needed.
- *
- * The second timer handles kernel and user profiling,
- * and does resource use estimation. If the second timer is programmable,
- * it is randomized to avoid aliasing between the two clocks. For example,
- * the randomization prevents an adversary from always giving up the cpu
- * just before its quantum expires. Otherwise, it would never accumulate
- * cpu ticks. The mean frequency of the second timer is stathz.
- *
- * If no second timer exists, stathz will be zero; in this case we drive
- * profiling and statistics off the main clock. This WILL NOT be accurate;
- * do not do it unless absolutely necessary.
- *
- * The statistics clock may (or may not) be run at a higher rate while
- * profiling. This profile clock runs at profhz. We require that profhz
- * be an integral multiple of stathz.
- *
- * If the statistics clock is running fast, it must be divided by the ratio
- * profhz/stathz for statistics. (For profiling, every tick counts.)
- *
- * Time-of-day is maintained using a "timecounter", which may or may
- * not be related to the hardware generating the above mentioned
- * interrupts.
- */
-
-int stathz;
-int profhz;
-static int profprocs;
-int ticks;
-static int psdiv, pscnt; /* prof => stat divider */
-int psratio; /* ratio: prof / stat */
-
-/*
- * Initialize clock frequencies and start both clocks running.
- */
-/* ARGSUSED*/
-static void
-initclocks(dummy)
- void *dummy;
-{
- register int i;
-
- /*
- * Set divisors to 1 (normal case) and let the machine-specific
- * code do its bit.
- */
- psdiv = pscnt = 1;
- cpu_initclocks();
-
- /*
- * Compute profhz/stathz, and fix profhz if needed.
- */
- i = stathz ? stathz : hz;
- if (profhz == 0)
- profhz = i;
- psratio = profhz / i;
-}
-
-/*
- * The real-time timer, interrupting hz times per second.
- */
-void
-hardclock(frame)
- register struct clockframe *frame;
-{
- register struct proc *p;
-
- p = curproc;
- if (p) {
- register struct pstats *pstats;
-
- /*
- * Run current process's virtual and profile time, as needed.
- */
- pstats = p->p_stats;
- if (CLKF_USERMODE(frame) &&
- timevalisset(&pstats->p_timer[ITIMER_VIRTUAL].it_value) &&
- itimerdecr(&pstats->p_timer[ITIMER_VIRTUAL], tick) == 0)
- psignal(p, SIGVTALRM);
- if (timevalisset(&pstats->p_timer[ITIMER_PROF].it_value) &&
- itimerdecr(&pstats->p_timer[ITIMER_PROF], tick) == 0)
- psignal(p, SIGPROF);
- }
-
-#if defined(SMP) && defined(BETTER_CLOCK)
- forward_hardclock(pscnt);
-#endif
-
- /*
- * If no separate statistics clock is available, run it from here.
- */
- if (stathz == 0)
- statclock(frame);
-
- tco_forward(0);
- ticks++;
-
- /*
- * Process callouts at a very low cpu priority, so we don't keep the
- * relatively high clock interrupt priority any longer than necessary.
- */
- if (TAILQ_FIRST(&callwheel[ticks & callwheelmask]) != NULL) {
- if (CLKF_BASEPRI(frame)) {
- /*
- * Save the overhead of a software interrupt;
- * it will happen as soon as we return, so do it now.
- */
- (void)splsoftclock();
- softclock();
- } else
- setsoftclock();
- } else if (softticks + 1 == ticks)
- ++softticks;
-}
-
-/*
- * Compute number of ticks in the specified amount of time.
- */
-int
-tvtohz(tv)
- struct timeval *tv;
-{
- register unsigned long ticks;
- register long sec, usec;
-
- /*
- * If the number of usecs in the whole seconds part of the time
- * difference fits in a long, then the total number of usecs will
- * fit in an unsigned long. Compute the total and convert it to
- * ticks, rounding up and adding 1 to allow for the current tick
- * to expire. Rounding also depends on unsigned long arithmetic
- * to avoid overflow.
- *
- * Otherwise, if the number of ticks in the whole seconds part of
- * the time difference fits in a long, then convert the parts to
- * ticks separately and add, using similar rounding methods and
- * overflow avoidance. This method would work in the previous
- * case but it is slightly slower and assumes that hz is integral.
- *
- * Otherwise, round the time difference down to the maximum
- * representable value.
- *
- * If ints have 32 bits, then the maximum value for any timeout in
- * 10ms ticks is 248 days.
- */
- sec = tv->tv_sec;
- usec = tv->tv_usec;
- if (usec < 0) {
- sec--;
- usec += 1000000;
- }
- if (sec < 0) {
-#ifdef DIAGNOSTIC
- if (usec > 0) {
- sec++;
- usec -= 1000000;
- }
- printf("tvotohz: negative time difference %ld sec %ld usec\n",
- sec, usec);
-#endif
- ticks = 1;
- } else if (sec <= LONG_MAX / 1000000)
- ticks = (sec * 1000000 + (unsigned long)usec + (tick - 1))
- / tick + 1;
- else if (sec <= LONG_MAX / hz)
- ticks = sec * hz
- + ((unsigned long)usec + (tick - 1)) / tick + 1;
- else
- ticks = LONG_MAX;
- if (ticks > INT_MAX)
- ticks = INT_MAX;
- return ((int)ticks);
-}
-
-/*
- * Start profiling on a process.
- *
- * Kernel profiling passes proc0 which never exits and hence
- * keeps the profile clock running constantly.
- */
-void
-startprofclock(p)
- register struct proc *p;
-{
- int s;
-
- if ((p->p_flag & P_PROFIL) == 0) {
- p->p_flag |= P_PROFIL;
- if (++profprocs == 1 && stathz != 0) {
- s = splstatclock();
- psdiv = pscnt = psratio;
- setstatclockrate(profhz);
- splx(s);
- }
- }
-}
-
-/*
- * Stop profiling on a process.
- */
-void
-stopprofclock(p)
- register struct proc *p;
-{
- int s;
-
- if (p->p_flag & P_PROFIL) {
- p->p_flag &= ~P_PROFIL;
- if (--profprocs == 0 && stathz != 0) {
- s = splstatclock();
- psdiv = pscnt = 1;
- setstatclockrate(stathz);
- splx(s);
- }
- }
-}
-
-/*
- * Statistics clock. Grab profile sample, and if divider reaches 0,
- * do process and kernel statistics. Most of the statistics are only
- * used by user-level statistics programs. The main exceptions are
- * p->p_uticks, p->p_sticks, p->p_iticks, and p->p_estcpu.
- */
-void
-statclock(frame)
- register struct clockframe *frame;
-{
-#ifdef GPROF
- register struct gmonparam *g;
- int i;
-#endif
- register struct proc *p;
- struct pstats *pstats;
- long rss;
- struct rusage *ru;
- struct vmspace *vm;
-
- if (curproc != NULL && CLKF_USERMODE(frame)) {
- /*
- * Came from user mode; CPU was in user state.
- * If this process is being profiled, record the tick.
- */
- p = curproc;
- if (p->p_flag & P_PROFIL)
- addupc_intr(p, CLKF_PC(frame), 1);
-#if defined(SMP) && defined(BETTER_CLOCK)
- if (stathz != 0)
- forward_statclock(pscnt);
-#endif
- if (--pscnt > 0)
- return;
- /*
- * Charge the time as appropriate.
- */
- p->p_uticks++;
- if (p->p_nice > NZERO)
- cp_time[CP_NICE]++;
- else
- cp_time[CP_USER]++;
- } else {
-#ifdef GPROF
- /*
- * Kernel statistics are just like addupc_intr, only easier.
- */
- g = &_gmonparam;
- if (g->state == GMON_PROF_ON) {
- i = CLKF_PC(frame) - g->lowpc;
- if (i < g->textsize) {
- i /= HISTFRACTION * sizeof(*g->kcount);
- g->kcount[i]++;
- }
- }
-#endif
-#if defined(SMP) && defined(BETTER_CLOCK)
- if (stathz != 0)
- forward_statclock(pscnt);
-#endif
- if (--pscnt > 0)
- return;
- /*
- * Came from kernel mode, so we were:
- * - handling an interrupt,
- * - doing syscall or trap work on behalf of the current
- * user process, or
- * - spinning in the idle loop.
- * Whichever it is, charge the time as appropriate.
- * Note that we charge interrupts to the current process,
- * regardless of whether they are ``for'' that process,
- * so that we know how much of its real time was spent
- * in ``non-process'' (i.e., interrupt) work.
- */
- p = curproc;
- if (CLKF_INTR(frame)) {
- if (p != NULL)
- p->p_iticks++;
- cp_time[CP_INTR]++;
- } else if (p != NULL) {
- p->p_sticks++;
- cp_time[CP_SYS]++;
- } else
- cp_time[CP_IDLE]++;
- }
- pscnt = psdiv;
-
- if (p != NULL) {
- schedclock(p);
-
- /* Update resource usage integrals and maximums. */
- if ((pstats = p->p_stats) != NULL &&
- (ru = &pstats->p_ru) != NULL &&
- (vm = p->p_vmspace) != NULL) {
- ru->ru_ixrss += pgtok(vm->vm_tsize);
- ru->ru_idrss += pgtok(vm->vm_dsize);
- ru->ru_isrss += pgtok(vm->vm_ssize);
- rss = pgtok(vmspace_resident_count(vm));
- if (ru->ru_maxrss < rss)
- ru->ru_maxrss = rss;
- }
- }
-}
-
-/*
- * Return information about system clocks.
- */
-static int
-sysctl_kern_clockrate SYSCTL_HANDLER_ARGS
-{
- struct clockinfo clkinfo;
- /*
- * Construct clockinfo structure.
- */
- clkinfo.hz = hz;
- clkinfo.tick = tick;
- clkinfo.tickadj = tickadj;
- clkinfo.profhz = profhz;
- clkinfo.stathz = stathz ? stathz : hz;
- return (sysctl_handle_opaque(oidp, &clkinfo, sizeof clkinfo, req));
-}
-
-SYSCTL_PROC(_kern, KERN_CLOCKRATE, clockrate, CTLTYPE_STRUCT|CTLFLAG_RD,
- 0, 0, sysctl_kern_clockrate, "S,clockinfo","");
-
-static __inline unsigned
-tco_delta(struct timecounter *tc)
-{
-
- return ((tc->tc_get_timecount(tc) - tc->tc_offset_count) &
- tc->tc_counter_mask);
-}
-
-/*
- * We have eight functions for looking at the clock, four for
- * microseconds and four for nanoseconds. For each there is fast
- * but less precise version "get{nano|micro}[up]time" which will
- * return a time which is up to 1/HZ previous to the call, whereas
- * the raw version "{nano|micro}[up]time" will return a timestamp
- * which is as precise as possible. The "up" variants return the
- * time relative to system boot, these are well suited for time
- * interval measurements.
- */
-
-void
-getmicrotime(struct timeval *tvp)
-{
- struct timecounter *tc;
-
- if (!tco_method) {
- tc = timecounter;
- *tvp = tc->tc_microtime;
- } else {
- microtime(tvp);
- }
-}
-
-void
-getnanotime(struct timespec *tsp)
-{
- struct timecounter *tc;
-
- if (!tco_method) {
- tc = timecounter;
- *tsp = tc->tc_nanotime;
- } else {
- nanotime(tsp);
- }
-}
-
-void
-microtime(struct timeval *tv)
-{
- struct timecounter *tc;
-
- tc = timecounter;
- tv->tv_sec = tc->tc_offset_sec;
- tv->tv_usec = tc->tc_offset_micro;
- tv->tv_usec += ((u_int64_t)tco_delta(tc) * tc->tc_scale_micro) >> 32;
- tv->tv_usec += boottime.tv_usec;
- tv->tv_sec += boottime.tv_sec;
- while (tv->tv_usec >= 1000000) {
- tv->tv_usec -= 1000000;
- tv->tv_sec++;
- }
-}
-
-void
-nanotime(struct timespec *ts)
-{
- unsigned count;
- u_int64_t delta;
- struct timecounter *tc;
-
- tc = timecounter;
- ts->tv_sec = tc->tc_offset_sec;
- count = tco_delta(tc);
- delta = tc->tc_offset_nano;
- delta += ((u_int64_t)count * tc->tc_scale_nano_f);
- delta >>= 32;
- delta += ((u_int64_t)count * tc->tc_scale_nano_i);
- delta += boottime.tv_usec * 1000;
- ts->tv_sec += boottime.tv_sec;
- while (delta >= 1000000000) {
- delta -= 1000000000;
- ts->tv_sec++;
- }
- ts->tv_nsec = delta;
-}
-
-void
-getmicrouptime(struct timeval *tvp)
-{
- struct timecounter *tc;
-
- if (!tco_method) {
- tc = timecounter;
- tvp->tv_sec = tc->tc_offset_sec;
- tvp->tv_usec = tc->tc_offset_micro;
- } else {
- microuptime(tvp);
- }
-}
-
-void
-getnanouptime(struct timespec *tsp)
-{
- struct timecounter *tc;
-
- if (!tco_method) {
- tc = timecounter;
- tsp->tv_sec = tc->tc_offset_sec;
- tsp->tv_nsec = tc->tc_offset_nano >> 32;
- } else {
- nanouptime(tsp);
- }
-}
-
-void
-microuptime(struct timeval *tv)
-{
- struct timecounter *tc;
-
- tc = timecounter;
- tv->tv_sec = tc->tc_offset_sec;
- tv->tv_usec = tc->tc_offset_micro;
- tv->tv_usec += ((u_int64_t)tco_delta(tc) * tc->tc_scale_micro) >> 32;
- if (tv->tv_usec >= 1000000) {
- tv->tv_usec -= 1000000;
- tv->tv_sec++;
- }
-}
-
-void
-nanouptime(struct timespec *ts)
-{
- unsigned count;
- u_int64_t delta;
- struct timecounter *tc;
-
- tc = timecounter;
- ts->tv_sec = tc->tc_offset_sec;
- count = tco_delta(tc);
- delta = tc->tc_offset_nano;
- delta += ((u_int64_t)count * tc->tc_scale_nano_f);
- delta >>= 32;
- delta += ((u_int64_t)count * tc->tc_scale_nano_i);
- if (delta >= 1000000000) {
- delta -= 1000000000;
- ts->tv_sec++;
- }
- ts->tv_nsec = delta;
-}
-
-static void
-tco_setscales(struct timecounter *tc)
-{
- u_int64_t scale;
-
- scale = 1000000000LL << 32;
- scale += tc->tc_adjustment;
- scale /= tc->tc_tweak->tc_frequency;
- tc->tc_scale_micro = scale / 1000;
- tc->tc_scale_nano_f = scale & 0xffffffff;
- tc->tc_scale_nano_i = scale >> 32;
-}
-
-void
-update_timecounter(struct timecounter *tc)
-{
- tco_setscales(tc);
-}
-
-void
-init_timecounter(struct timecounter *tc)
-{
- struct timespec ts1;
- struct timecounter *t1, *t2, *t3;
- int i;
-
- tc->tc_adjustment = 0;
- tc->tc_tweak = tc;
- tco_setscales(tc);
- tc->tc_offset_count = tc->tc_get_timecount(tc);
- if (timecounter == &dummy_timecounter)
- tc->tc_avail = tc;
- else {
- tc->tc_avail = timecounter->tc_tweak->tc_avail;
- timecounter->tc_tweak->tc_avail = tc;
- }
- MALLOC(t1, struct timecounter *, sizeof *t1, M_TIMECOUNTER, M_WAITOK);
- tc->tc_other = t1;
- *t1 = *tc;
- t2 = t1;
- for (i = 1; i < NTIMECOUNTER; i++) {
- MALLOC(t3, struct timecounter *, sizeof *t3,
- M_TIMECOUNTER, M_WAITOK);
- *t3 = *tc;
- t3->tc_other = t2;
- t2 = t3;
- }
- t1->tc_other = t3;
- tc = t1;
-
- printf("Timecounter \"%s\" frequency %lu Hz\n",
- tc->tc_name, (u_long)tc->tc_frequency);
-
- /* XXX: For now always start using the counter. */
- tc->tc_offset_count = tc->tc_get_timecount(tc);
- nanouptime(&ts1);
- tc->tc_offset_nano = (u_int64_t)ts1.tv_nsec << 32;
- tc->tc_offset_micro = ts1.tv_nsec / 1000;
- tc->tc_offset_sec = ts1.tv_sec;
- timecounter = tc;
-}
-
-void
-set_timecounter(struct timespec *ts)
-{
- struct timespec ts2;
-
- nanouptime(&ts2);
- boottime.tv_sec = ts->tv_sec - ts2.tv_sec;
- boottime.tv_usec = (ts->tv_nsec - ts2.tv_nsec) / 1000;
- if (boottime.tv_usec < 0) {
- boottime.tv_usec += 1000000;
- boottime.tv_sec--;
- }
- /* fiddle all the little crinkly bits around the fiords... */
- tco_forward(1);
-}
-
-static void
-switch_timecounter(struct timecounter *newtc)
-{
- int s;
- struct timecounter *tc;
- struct timespec ts;
-
- s = splclock();
- tc = timecounter;
- if (newtc->tc_tweak == tc->tc_tweak) {
- splx(s);
- return;
- }
- newtc = newtc->tc_tweak->tc_other;
- nanouptime(&ts);
- newtc->tc_offset_sec = ts.tv_sec;
- newtc->tc_offset_nano = (u_int64_t)ts.tv_nsec << 32;
- newtc->tc_offset_micro = ts.tv_nsec / 1000;
- newtc->tc_offset_count = newtc->tc_get_timecount(newtc);
- tco_setscales(newtc);
- timecounter = newtc;
- splx(s);
-}
-
-static struct timecounter *
-sync_other_counter(void)
-{
- struct timecounter *tc, *tcn, *tco;
- unsigned delta;
-
- tco = timecounter;
- tc = tco->tc_other;
- tcn = tc->tc_other;
- *tc = *tco;
- tc->tc_other = tcn;
- delta = tco_delta(tc);
- tc->tc_offset_count += delta;
- tc->tc_offset_count &= tc->tc_counter_mask;
- tc->tc_offset_nano += (u_int64_t)delta * tc->tc_scale_nano_f;
- tc->tc_offset_nano += (u_int64_t)delta * tc->tc_scale_nano_i << 32;
- return (tc);
-}
-
-static void
-tco_forward(int force)
-{
- struct timecounter *tc, *tco;
- struct timeval tvt;
-
- tco = timecounter;
- tc = sync_other_counter();
- /*
- * We may be inducing a tiny error here, the tc_poll_pps() may
- * process a latched count which happens after the tco_delta()
- * in sync_other_counter(), which would extend the previous
- * counters parameters into the domain of this new one.
- * Since the timewindow is very small for this, the error is
- * going to be only a few weenieseconds (as Dave Mills would
- * say), so lets just not talk more about it, OK ?
- */
- if (tco->tc_poll_pps)
- tco->tc_poll_pps(tco);
- if (timedelta != 0) {
- tvt = boottime;
- tvt.tv_usec += tickdelta;
- if (tvt.tv_usec >= 1000000) {
- tvt.tv_sec++;
- tvt.tv_usec -= 1000000;
- } else if (tvt.tv_usec < 0) {
- tvt.tv_sec--;
- tvt.tv_usec += 1000000;
- }
- boottime = tvt;
- timedelta -= tickdelta;
- }
-
- while (tc->tc_offset_nano >= 1000000000ULL << 32) {
- tc->tc_offset_nano -= 1000000000ULL << 32;
- tc->tc_offset_sec++;
- ntp_update_second(tc); /* XXX only needed if xntpd runs */
- tco_setscales(tc);
- force++;
- }
-
- if (tco_method && !force)
- return;
-
- tc->tc_offset_micro = (tc->tc_offset_nano / 1000) >> 32;
-
- /* Figure out the wall-clock time */
- tc->tc_nanotime.tv_sec = tc->tc_offset_sec + boottime.tv_sec;
- tc->tc_nanotime.tv_nsec =
- (tc->tc_offset_nano >> 32) + boottime.tv_usec * 1000;
- tc->tc_microtime.tv_usec = tc->tc_offset_micro + boottime.tv_usec;
- if (tc->tc_nanotime.tv_nsec >= 1000000000) {
- tc->tc_nanotime.tv_nsec -= 1000000000;
- tc->tc_microtime.tv_usec -= 1000000;
- tc->tc_nanotime.tv_sec++;
- }
- time_second = tc->tc_microtime.tv_sec = tc->tc_nanotime.tv_sec;
-
- timecounter = tc;
-}
-
-SYSCTL_NODE(_kern, OID_AUTO, timecounter, CTLFLAG_RW, 0, "");
-
-SYSCTL_INT(_kern_timecounter, OID_AUTO, method, CTLFLAG_RW, &tco_method, 0,
- "This variable determines the method used for updating timecounters. "
- "If the default algorithm (0) fails with \"calcru negative...\" messages "
- "try the alternate algorithm (1) which handles bad hardware better."
-
-);
-
-static int
-sysctl_kern_timecounter_hardware SYSCTL_HANDLER_ARGS
-{
- char newname[32];
- struct timecounter *newtc, *tc;
- int error;
-
- tc = timecounter->tc_tweak;
- strncpy(newname, tc->tc_name, sizeof(newname));
- error = sysctl_handle_string(oidp, &newname[0], sizeof(newname), req);
- if (error == 0 && req->newptr != NULL &&
- strcmp(newname, tc->tc_name) != 0) {
- for (newtc = tc->tc_avail; newtc != tc;
- newtc = newtc->tc_avail) {
- if (strcmp(newname, newtc->tc_name) == 0) {
- /* Warm up new timecounter. */
- (void)newtc->tc_get_timecount(newtc);
-
- switch_timecounter(newtc);
- return (0);
- }
- }
- return (EINVAL);
- }
- return (error);
-}
-
-SYSCTL_PROC(_kern_timecounter, OID_AUTO, hardware, CTLTYPE_STRING | CTLFLAG_RW,
- 0, 0, sysctl_kern_timecounter_hardware, "A", "");
-
-
-int
-pps_ioctl(u_long cmd, caddr_t data, struct pps_state *pps)
-{
- pps_params_t *app;
- struct pps_fetch_args *fapi;
-#ifdef PPS_SYNC
- struct pps_kcbind_args *kapi;
-#endif
-
- switch (cmd) {
- case PPS_IOC_CREATE:
- return (0);
- case PPS_IOC_DESTROY:
- return (0);
- case PPS_IOC_SETPARAMS:
- app = (pps_params_t *)data;
- if (app->mode & ~pps->ppscap)
- return (EINVAL);
- pps->ppsparam = *app;
- return (0);
- case PPS_IOC_GETPARAMS:
- app = (pps_params_t *)data;
- *app = pps->ppsparam;
- app->api_version = PPS_API_VERS_1;
- return (0);
- case PPS_IOC_GETCAP:
- *(int*)data = pps->ppscap;
- return (0);
- case PPS_IOC_FETCH:
- fapi = (struct pps_fetch_args *)data;
- if (fapi->tsformat && fapi->tsformat != PPS_TSFMT_TSPEC)
- return (EINVAL);
- if (fapi->timeout.tv_sec || fapi->timeout.tv_nsec)
- return (EOPNOTSUPP);
- pps->ppsinfo.current_mode = pps->ppsparam.mode;
- fapi->pps_info_buf = pps->ppsinfo;
- return (0);
- case PPS_IOC_KCBIND:
-#ifdef PPS_SYNC
- kapi = (struct pps_kcbind_args *)data;
- /* XXX Only root should be able to do this */
- if (kapi->tsformat && kapi->tsformat != PPS_TSFMT_TSPEC)
- return (EINVAL);
- if (kapi->kernel_consumer != PPS_KC_HARDPPS)
- return (EINVAL);
- if (kapi->edge & ~pps->ppscap)
- return (EINVAL);
- pps->kcmode = kapi->edge;
- return (0);
-#else
- return (EOPNOTSUPP);
-#endif
- default:
- return (ENOTTY);
- }
-}
-
-void
-pps_init(struct pps_state *pps)
-{
- pps->ppscap |= PPS_TSFMT_TSPEC;
- if (pps->ppscap & PPS_CAPTUREASSERT)
- pps->ppscap |= PPS_OFFSETASSERT;
- if (pps->ppscap & PPS_CAPTURECLEAR)
- pps->ppscap |= PPS_OFFSETCLEAR;
-}
-
-void
-pps_event(struct pps_state *pps, struct timecounter *tc, unsigned count, int event)
-{
- struct timespec ts, *tsp, *osp;
- u_int64_t delta;
- unsigned tcount, *pcount;
- int foff, fhard;
- pps_seq_t *pseq;
-
- /* Things would be easier with arrays... */
- if (event == PPS_CAPTUREASSERT) {
- tsp = &pps->ppsinfo.assert_timestamp;
- osp = &pps->ppsparam.assert_offset;
- foff = pps->ppsparam.mode & PPS_OFFSETASSERT;
- fhard = pps->kcmode & PPS_CAPTUREASSERT;
- pcount = &pps->ppscount[0];
- pseq = &pps->ppsinfo.assert_sequence;
- } else {
- tsp = &pps->ppsinfo.clear_timestamp;
- osp = &pps->ppsparam.clear_offset;
- foff = pps->ppsparam.mode & PPS_OFFSETCLEAR;
- fhard = pps->kcmode & PPS_CAPTURECLEAR;
- pcount = &pps->ppscount[1];
- pseq = &pps->ppsinfo.clear_sequence;
- }
-
- /* The timecounter changed: bail */
- if (!pps->ppstc ||
- pps->ppstc->tc_name != tc->tc_name ||
- tc->tc_name != timecounter->tc_name) {
- pps->ppstc = tc;
- *pcount = count;
- return;
- }
-
- /* Nothing really happened */
- if (*pcount == count)
- return;
-
- *pcount = count;
-
- /* Convert the count to timespec */
- ts.tv_sec = tc->tc_offset_sec;
- tcount = count - tc->tc_offset_count;
- tcount &= tc->tc_counter_mask;
- delta = tc->tc_offset_nano;
- delta += ((u_int64_t)tcount * tc->tc_scale_nano_f);
- delta >>= 32;
- delta += ((u_int64_t)tcount * tc->tc_scale_nano_i);
- delta += boottime.tv_usec * 1000;
- ts.tv_sec += boottime.tv_sec;
- while (delta >= 1000000000) {
- delta -= 1000000000;
- ts.tv_sec++;
- }
- ts.tv_nsec = delta;
-
- (*pseq)++;
- *tsp = ts;
-
- if (foff) {
- timespecadd(tsp, osp);
- if (tsp->tv_nsec < 0) {
- tsp->tv_nsec += 1000000000;
- tsp->tv_sec -= 1;
- }
- }
-#ifdef PPS_SYNC
- if (fhard) {
- /* magic, at its best... */
- tcount = count - pps->ppscount[2];
- pps->ppscount[2] = count;
- tcount &= tc->tc_counter_mask;
- delta = ((u_int64_t)tcount * tc->tc_tweak->tc_scale_nano_f);
- delta >>= 32;
- delta += ((u_int64_t)tcount * tc->tc_tweak->tc_scale_nano_i);
- hardpps(tsp, delta);
- }
-#endif
-}
diff --git a/sys/kern/ksched.c b/sys/kern/ksched.c
deleted file mode 100644
index 8f297b21ecab..000000000000
--- a/sys/kern/ksched.c
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * Copyright (c) 1996, 1997
- * HD Associates, Inc. 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 HD Associates, Inc
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES 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 HD ASSOCIATES 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.
- *
- * $FreeBSD$
- */
-
-/* ksched: Soft real time scheduling based on "rtprio".
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/proc.h>
-#include <sys/kernel.h>
-#include <sys/resource.h>
-#include <machine/cpu.h> /* For need_resched */
-
-#include <posix4/posix4.h>
-
-/* ksched: Real-time extension to support POSIX priority scheduling.
- */
-
-struct ksched {
- struct timespec rr_interval;
-};
-
-int ksched_attach(struct ksched **p)
-{
- struct ksched *ksched= p31b_malloc(sizeof(*ksched));
-
- ksched->rr_interval.tv_sec = 0;
- ksched->rr_interval.tv_nsec = 1000000000L / roundrobin_interval();
-
- *p = ksched;
- return 0;
-}
-
-int ksched_detach(struct ksched *p)
-{
- p31b_free(p);
-
- return 0;
-}
-
-/*
- * XXX About priorities
- *
- * POSIX 1003.1b requires that numerically higher priorities be of
- * higher priority. It also permits sched_setparam to be
- * implementation defined for SCHED_OTHER. I don't like
- * the notion of inverted priorites for normal processes when
- * you can use "setpriority" for that.
- *
- * I'm rejecting sched_setparam for SCHED_OTHER with EINVAL.
- */
-
-/* Macros to convert between the unix (lower numerically is higher priority)
- * and POSIX 1003.1b (higher numerically is higher priority)
- */
-
-#define p4prio_to_rtpprio(P) (RTP_PRIO_MAX - (P))
-#define rtpprio_to_p4prio(P) (RTP_PRIO_MAX - (P))
-
-/* These improve readability a bit for me:
- */
-#define P1B_PRIO_MIN rtpprio_to_p4prio(RTP_PRIO_MAX)
-#define P1B_PRIO_MAX rtpprio_to_p4prio(RTP_PRIO_MIN)
-
-static __inline int
-getscheduler(register_t *ret, struct ksched *ksched, struct proc *p)
-{
- int e = 0;
-
- switch (p->p_rtprio.type)
- {
- case RTP_PRIO_FIFO:
- *ret = SCHED_FIFO;
- break;
-
- case RTP_PRIO_REALTIME:
- *ret = SCHED_RR;
- break;
-
- default:
- *ret = SCHED_OTHER;
- break;
- }
-
- return e;
-}
-
-int ksched_setparam(register_t *ret, struct ksched *ksched,
- struct proc *p, const struct sched_param *param)
-{
- register_t policy;
- int e;
-
- e = getscheduler(&policy, ksched, p);
-
- if (e == 0)
- {
- if (policy == SCHED_OTHER)
- e = EINVAL;
- else
- e = ksched_setscheduler(ret, ksched, p, policy, param);
- }
-
- return e;
-}
-
-int ksched_getparam(register_t *ret, struct ksched *ksched,
- struct proc *p, struct sched_param *param)
-{
- if (RTP_PRIO_IS_REALTIME(p->p_rtprio.type))
- param->sched_priority = rtpprio_to_p4prio(p->p_rtprio.prio);
-
- return 0;
-}
-
-/*
- * XXX The priority and scheduler modifications should
- * be moved into published interfaces in kern/kern_sync.
- *
- * The permissions to modify process p were checked in "p31b_proc()".
- *
- */
-int ksched_setscheduler(register_t *ret, struct ksched *ksched,
- struct proc *p, int policy, const struct sched_param *param)
-{
- int e = 0;
- struct rtprio rtp;
-
- switch(policy)
- {
- case SCHED_RR:
- case SCHED_FIFO:
-
- if (param->sched_priority >= P1B_PRIO_MIN &&
- param->sched_priority <= P1B_PRIO_MAX)
- {
- rtp.prio = p4prio_to_rtpprio(param->sched_priority);
- rtp.type = (policy == SCHED_FIFO)
- ? RTP_PRIO_FIFO : RTP_PRIO_REALTIME;
-
- p->p_rtprio = rtp;
- need_resched();
- }
- else
- e = EPERM;
-
-
- break;
-
- case SCHED_OTHER:
- {
- rtp.type = RTP_PRIO_NORMAL;
- rtp.prio = p4prio_to_rtpprio(param->sched_priority);
- p->p_rtprio = rtp;
-
- /* XXX Simply revert to whatever we had for last
- * normal scheduler priorities.
- * This puts a requirement
- * on the scheduling code: You must leave the
- * scheduling info alone.
- */
- need_resched();
- }
- break;
- }
-
- return e;
-}
-
-int ksched_getscheduler(register_t *ret, struct ksched *ksched, struct proc *p)
-{
- return getscheduler(ret, ksched, p);
-}
-
-/* ksched_yield: Yield the CPU.
- */
-int ksched_yield(register_t *ret, struct ksched *ksched)
-{
- need_resched();
- return 0;
-}
-
-int ksched_get_priority_max(register_t*ret, struct ksched *ksched, int policy)
-{
- int e = 0;
-
- switch (policy)
- {
- case SCHED_FIFO:
- case SCHED_RR:
- *ret = RTP_PRIO_MAX;
- break;
-
- case SCHED_OTHER:
- *ret = PRIO_MAX;
- break;
-
- default:
- e = EINVAL;
- }
-
- return e;
-}
-
-int ksched_get_priority_min(register_t *ret, struct ksched *ksched, int policy)
-{
- int e = 0;
-
- switch (policy)
- {
- case SCHED_FIFO:
- case SCHED_RR:
- *ret = P1B_PRIO_MIN;
- break;
-
- case SCHED_OTHER:
- *ret = PRIO_MIN;
- break;
-
- default:
- e = EINVAL;
- }
-
- return e;
-}
-
-int ksched_rr_get_interval(register_t *ret, struct ksched *ksched,
- struct proc *p, struct timespec *timespec)
-{
- *timespec = ksched->rr_interval;
-
- return 0;
-}
diff --git a/sys/kern/link_elf_obj.c b/sys/kern/link_elf_obj.c
deleted file mode 100644
index daf3b3072702..000000000000
--- a/sys/kern/link_elf_obj.c
+++ /dev/null
@@ -1,985 +0,0 @@
-/*-
- * Copyright (c) 1998 Doug Rabson
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/malloc.h>
-#include <sys/proc.h>
-#include <sys/namei.h>
-#include <sys/fcntl.h>
-#include <sys/vnode.h>
-#include <sys/linker.h>
-#include <machine/elf.h>
-
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <vm/vm_zone.h>
-#include <sys/lock.h>
-#ifdef SPARSE_MAPPING
-#include <vm/vm_object.h>
-#include <vm/vm_kern.h>
-#include <vm/vm_extern.h>
-#endif
-#include <vm/pmap.h>
-#include <vm/vm_map.h>
-
-static int link_elf_load_module(const char*, linker_file_t*);
-static int link_elf_load_file(const char*, linker_file_t*);
-static int link_elf_lookup_symbol(linker_file_t, const char*,
- c_linker_sym_t*);
-static int link_elf_symbol_values(linker_file_t, c_linker_sym_t, linker_symval_t*);
-static int link_elf_search_symbol(linker_file_t, caddr_t value,
- c_linker_sym_t* sym, long* diffp);
-
-static void link_elf_unload_file(linker_file_t);
-static void link_elf_unload_module(linker_file_t);
-
-static struct linker_class_ops link_elf_class_ops = {
- link_elf_load_module,
-};
-
-static struct linker_file_ops link_elf_file_ops = {
- link_elf_lookup_symbol,
- link_elf_symbol_values,
- link_elf_search_symbol,
- link_elf_unload_file,
-};
-
-static struct linker_file_ops link_elf_module_ops = {
- link_elf_lookup_symbol,
- link_elf_symbol_values,
- link_elf_search_symbol,
- link_elf_unload_module,
-};
-typedef struct elf_file {
- caddr_t address; /* Relocation address */
-#ifdef SPARSE_MAPPING
- vm_object_t object; /* VM object to hold file pages */
-#endif
- const Elf_Dyn* dynamic; /* Symbol table etc. */
- Elf_Off nbuckets; /* DT_HASH info */
- Elf_Off nchains;
- const Elf_Off* buckets;
- const Elf_Off* chains;
- caddr_t hash;
- caddr_t strtab; /* DT_STRTAB */
- int strsz; /* DT_STRSZ */
- const Elf_Sym* symtab; /* DT_SYMTAB */
- Elf_Addr* got; /* DT_PLTGOT */
- const Elf_Rel* pltrel; /* DT_JMPREL */
- int pltrelsize; /* DT_PLTRELSZ */
- const Elf_Rela* pltrela; /* DT_JMPREL */
- int pltrelasize; /* DT_PLTRELSZ */
- const Elf_Rel* rel; /* DT_REL */
- int relsize; /* DT_RELSZ */
- const Elf_Rela* rela; /* DT_RELA */
- int relasize; /* DT_RELASZ */
- caddr_t modptr;
- const Elf_Sym* ddbsymtab; /* The symbol table we are using */
- long ddbsymcnt; /* Number of symbols */
- caddr_t ddbstrtab; /* String table */
- long ddbstrcnt; /* number of bytes in string table */
- caddr_t symbase; /* malloc'ed symbold base */
- caddr_t strbase; /* malloc'ed string base */
-} *elf_file_t;
-
-static int parse_dynamic(linker_file_t lf);
-static int load_dependancies(linker_file_t lf);
-static int relocate_file(linker_file_t lf);
-static int parse_module_symbols(linker_file_t lf);
-
-/*
- * The kernel symbol table starts here.
- */
-extern struct _dynamic _DYNAMIC;
-
-static void
-link_elf_init(void* arg)
-{
-#ifdef __ELF__
- Elf_Dyn *dp;
- caddr_t modptr, baseptr, sizeptr;
- elf_file_t ef;
- char *modname;
-#endif
-
-#if ELF_TARG_CLASS == ELFCLASS32
- linker_add_class("elf32", NULL, &link_elf_class_ops);
-#else
- linker_add_class("elf64", NULL, &link_elf_class_ops);
-#endif
-
-#ifdef __ELF__
- dp = (Elf_Dyn*) &_DYNAMIC;
- if (dp) {
- ef = malloc(sizeof(struct elf_file), M_LINKER, M_NOWAIT);
- if (ef == NULL)
- panic("link_elf_init: Can't create linker structures for kernel");
- bzero(ef, sizeof(*ef));
-
- ef->address = 0;
-#ifdef SPARSE_MAPPING
- ef->object = 0;
-#endif
- ef->dynamic = dp;
- modname = NULL;
- modptr = preload_search_by_type("elf kernel");
- if (modptr)
- modname = (char *)preload_search_info(modptr, MODINFO_NAME);
- if (modname == NULL)
- modname = "kernel";
- linker_kernel_file = linker_make_file(modname, ef, &link_elf_file_ops);
- if (linker_kernel_file == NULL)
- panic("link_elf_init: Can't create linker structures for kernel");
- parse_dynamic(linker_kernel_file);
- linker_kernel_file->address = (caddr_t) KERNBASE;
- linker_kernel_file->size = -(intptr_t)linker_kernel_file->address;
-
- if (modptr) {
- ef->modptr = modptr;
- baseptr = preload_search_info(modptr, MODINFO_ADDR);
- if (baseptr)
- linker_kernel_file->address = *(caddr_t *)baseptr;
- sizeptr = preload_search_info(modptr, MODINFO_SIZE);
- if (sizeptr)
- linker_kernel_file->size = *(size_t *)sizeptr;
- }
- (void)parse_module_symbols(linker_kernel_file);
- linker_current_file = linker_kernel_file;
- linker_kernel_file->flags |= LINKER_FILE_LINKED;
- }
-#endif
-}
-
-SYSINIT(link_elf, SI_SUB_KLD, SI_ORDER_SECOND, link_elf_init, 0);
-
-static int
-parse_module_symbols(linker_file_t lf)
-{
- elf_file_t ef = lf->priv;
- caddr_t pointer;
- caddr_t ssym, esym, base;
- caddr_t strtab;
- int strcnt;
- Elf_Sym* symtab;
- int symcnt;
-
- if (ef->modptr == NULL)
- return 0;
- pointer = preload_search_info(ef->modptr, MODINFO_METADATA|MODINFOMD_SSYM);
- if (pointer == NULL)
- return 0;
- ssym = *(caddr_t *)pointer;
- pointer = preload_search_info(ef->modptr, MODINFO_METADATA|MODINFOMD_ESYM);
- if (pointer == NULL)
- return 0;
- esym = *(caddr_t *)pointer;
-
- base = ssym;
-
- symcnt = *(long *)base;
- base += sizeof(long);
- symtab = (Elf_Sym *)base;
- base += roundup(symcnt, sizeof(long));
-
- if (base > esym || base < ssym) {
- printf("Symbols are corrupt!\n");
- return EINVAL;
- }
-
- strcnt = *(long *)base;
- base += sizeof(long);
- strtab = base;
- base += roundup(strcnt, sizeof(long));
-
- if (base > esym || base < ssym) {
- printf("Symbols are corrupt!\n");
- return EINVAL;
- }
-
- ef->ddbsymtab = symtab;
- ef->ddbsymcnt = symcnt / sizeof(Elf_Sym);
- ef->ddbstrtab = strtab;
- ef->ddbstrcnt = strcnt;
-
- return 0;
-}
-
-static int
-parse_dynamic(linker_file_t lf)
-{
- elf_file_t ef = lf->priv;
- const Elf_Dyn *dp;
- int plttype = DT_REL;
-
- for (dp = ef->dynamic; dp->d_tag != DT_NULL; dp++) {
- switch (dp->d_tag) {
- case DT_HASH:
- {
- /* From src/libexec/rtld-elf/rtld.c */
- const Elf_Off *hashtab = (const Elf_Off *)
- (ef->address + dp->d_un.d_ptr);
- ef->nbuckets = hashtab[0];
- ef->nchains = hashtab[1];
- ef->buckets = hashtab + 2;
- ef->chains = ef->buckets + ef->nbuckets;
- break;
- }
- case DT_STRTAB:
- ef->strtab = (caddr_t) (ef->address + dp->d_un.d_ptr);
- break;
- case DT_STRSZ:
- ef->strsz = dp->d_un.d_val;
- break;
- case DT_SYMTAB:
- ef->symtab = (Elf_Sym*) (ef->address + dp->d_un.d_ptr);
- break;
- case DT_SYMENT:
- if (dp->d_un.d_val != sizeof(Elf_Sym))
- return ENOEXEC;
- break;
- case DT_PLTGOT:
- ef->got = (Elf_Addr *) (ef->address + dp->d_un.d_ptr);
- break;
- case DT_REL:
- ef->rel = (const Elf_Rel *) (ef->address + dp->d_un.d_ptr);
- break;
- case DT_RELSZ:
- ef->relsize = dp->d_un.d_val;
- break;
- case DT_RELENT:
- if (dp->d_un.d_val != sizeof(Elf_Rel))
- return ENOEXEC;
- break;
- case DT_JMPREL:
- ef->pltrel = (const Elf_Rel *) (ef->address + dp->d_un.d_ptr);
- break;
- case DT_PLTRELSZ:
- ef->pltrelsize = dp->d_un.d_val;
- break;
- case DT_RELA:
- ef->rela = (const Elf_Rela *) (ef->address + dp->d_un.d_ptr);
- break;
- case DT_RELASZ:
- ef->relasize = dp->d_un.d_val;
- break;
- case DT_RELAENT:
- if (dp->d_un.d_val != sizeof(Elf_Rela))
- return ENOEXEC;
- break;
- case DT_PLTREL:
- plttype = dp->d_un.d_val;
- if (plttype != DT_REL && plttype != DT_RELA)
- return ENOEXEC;
- break;
- }
- }
-
- if (plttype == DT_RELA) {
- ef->pltrela = (const Elf_Rela *) ef->pltrel;
- ef->pltrel = NULL;
- ef->pltrelasize = ef->pltrelsize;
- ef->pltrelsize = 0;
- }
-
- ef->ddbsymtab = ef->symtab;
- ef->ddbsymcnt = ef->nchains;
- ef->ddbstrtab = ef->strtab;
- ef->ddbstrcnt = ef->strsz;
-
- return 0;
-}
-
-static void
-link_elf_error(const char *s)
-{
- printf("kldload: %s\n", s);
-}
-
-static int
-link_elf_load_module(const char *filename, linker_file_t *result)
-{
- caddr_t modptr, baseptr, sizeptr, dynptr;
- char *type;
- elf_file_t ef;
- linker_file_t lf;
- int error;
- vm_offset_t dp;
-
- /* Look to see if we have the module preloaded */
- modptr = preload_search_by_name(filename);
- if (modptr == NULL)
- return (link_elf_load_file(filename, result));
-
- /* It's preloaded, check we can handle it and collect information */
- type = (char *)preload_search_info(modptr, MODINFO_TYPE);
- baseptr = preload_search_info(modptr, MODINFO_ADDR);
- sizeptr = preload_search_info(modptr, MODINFO_SIZE);
- dynptr = preload_search_info(modptr, MODINFO_METADATA|MODINFOMD_DYNAMIC);
- if (type == NULL || strcmp(type, "elf module") != 0)
- return (EFTYPE);
- if (baseptr == NULL || sizeptr == NULL || dynptr == NULL)
- return (EINVAL);
-
- ef = malloc(sizeof(struct elf_file), M_LINKER, M_WAITOK);
- if (ef == NULL)
- return (ENOMEM);
- bzero(ef, sizeof(*ef));
- ef->modptr = modptr;
- ef->address = *(caddr_t *)baseptr;
-#ifdef SPARSE_MAPPING
- ef->object = 0;
-#endif
- dp = (vm_offset_t)ef->address + *(vm_offset_t *)dynptr;
- ef->dynamic = (Elf_Dyn *)dp;
- lf = linker_make_file(filename, ef, &link_elf_module_ops);
- if (lf == NULL) {
- free(ef, M_LINKER);
- return ENOMEM;
- }
- lf->address = ef->address;
- lf->size = *(size_t *)sizeptr;
-
- error = parse_dynamic(lf);
- if (error) {
- linker_file_unload(lf);
- return error;
- }
- error = load_dependancies(lf);
- if (error) {
- linker_file_unload(lf);
- return error;
- }
- error = relocate_file(lf);
- if (error) {
- linker_file_unload(lf);
- return error;
- }
- (void)parse_module_symbols(lf);
- lf->flags |= LINKER_FILE_LINKED;
- *result = lf;
- return (0);
-}
-
-static int
-link_elf_load_file(const char* filename, linker_file_t* result)
-{
- struct nameidata nd;
- struct proc* p = curproc; /* XXX */
- Elf_Ehdr *hdr;
- caddr_t firstpage;
- int nbytes, i;
- Elf_Phdr *phdr;
- Elf_Phdr *phlimit;
- Elf_Phdr *segs[2];
- int nsegs;
- Elf_Phdr *phdyn;
- Elf_Phdr *phphdr;
- caddr_t mapbase;
- size_t mapsize;
- Elf_Off base_offset;
- Elf_Addr base_vaddr;
- Elf_Addr base_vlimit;
- int error = 0;
- int resid;
- elf_file_t ef;
- linker_file_t lf;
- char *pathname;
- Elf_Shdr *shdr;
- int symtabindex;
- int symstrindex;
- int symcnt;
- int strcnt;
-
- shdr = NULL;
- lf = NULL;
-
- pathname = linker_search_path(filename);
- if (pathname == NULL)
- return ENOENT;
-
- NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, pathname, p);
- error = vn_open(&nd, FREAD, 0);
- free(pathname, M_LINKER);
- if (error)
- return error;
- NDFREE(&nd, NDF_ONLY_PNBUF);
-
- /*
- * Read the elf header from the file.
- */
- firstpage = malloc(PAGE_SIZE, M_LINKER, M_WAITOK);
- if (firstpage == NULL) {
- error = ENOMEM;
- goto out;
- }
- hdr = (Elf_Ehdr *)firstpage;
- error = vn_rdwr(UIO_READ, nd.ni_vp, firstpage, PAGE_SIZE, 0,
- UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred, &resid, p);
- nbytes = PAGE_SIZE - resid;
- if (error)
- goto out;
-
- if (!IS_ELF(*hdr)) {
- error = ENOEXEC;
- goto out;
- }
-
- if (hdr->e_ident[EI_CLASS] != ELF_TARG_CLASS
- || hdr->e_ident[EI_DATA] != ELF_TARG_DATA) {
- link_elf_error("Unsupported file layout");
- error = ENOEXEC;
- goto out;
- }
- if (hdr->e_ident[EI_VERSION] != EV_CURRENT
- || hdr->e_version != EV_CURRENT) {
- link_elf_error("Unsupported file version");
- error = ENOEXEC;
- goto out;
- }
- if (hdr->e_type != ET_EXEC && hdr->e_type != ET_DYN) {
- link_elf_error("Unsupported file type");
- error = ENOEXEC;
- goto out;
- }
- if (hdr->e_machine != ELF_TARG_MACH) {
- link_elf_error("Unsupported machine");
- error = ENOEXEC;
- goto out;
- }
-
- /*
- * We rely on the program header being in the first page. This is
- * not strictly required by the ABI specification, but it seems to
- * always true in practice. And, it simplifies things considerably.
- */
- if (!((hdr->e_phentsize == sizeof(Elf_Phdr)) &&
- (hdr->e_phoff + hdr->e_phnum*sizeof(Elf_Phdr) <= PAGE_SIZE) &&
- (hdr->e_phoff + hdr->e_phnum*sizeof(Elf_Phdr) <= nbytes)))
- link_elf_error("Unreadable program headers");
-
- /*
- * Scan the program header entries, and save key information.
- *
- * We rely on there being exactly two load segments, text and data,
- * in that order.
- */
- phdr = (Elf_Phdr *) (firstpage + hdr->e_phoff);
- phlimit = phdr + hdr->e_phnum;
- nsegs = 0;
- phdyn = NULL;
- phphdr = NULL;
- while (phdr < phlimit) {
- switch (phdr->p_type) {
-
- case PT_LOAD:
- if (nsegs == 2) {
- link_elf_error("Too many sections");
- error = ENOEXEC;
- goto out;
- }
- segs[nsegs] = phdr;
- ++nsegs;
- break;
-
- case PT_PHDR:
- phphdr = phdr;
- break;
-
- case PT_DYNAMIC:
- phdyn = phdr;
- break;
- }
-
- ++phdr;
- }
- if (phdyn == NULL) {
- link_elf_error("Object is not dynamically-linked");
- error = ENOEXEC;
- goto out;
- }
-
- /*
- * Allocate the entire address space of the object, to stake out our
- * contiguous region, and to establish the base address for relocation.
- */
- base_offset = trunc_page(segs[0]->p_offset);
- base_vaddr = trunc_page(segs[0]->p_vaddr);
- base_vlimit = round_page(segs[1]->p_vaddr + segs[1]->p_memsz);
- mapsize = base_vlimit - base_vaddr;
-
- ef = malloc(sizeof(struct elf_file), M_LINKER, M_WAITOK);
- bzero(ef, sizeof(*ef));
-#ifdef SPARSE_MAPPING
- ef->object = vm_object_allocate(OBJT_DEFAULT, mapsize >> PAGE_SHIFT);
- if (ef->object == NULL) {
- free(ef, M_LINKER);
- error = ENOMEM;
- goto out;
- }
- vm_object_reference(ef->object);
- ef->address = (caddr_t) vm_map_min(kernel_map);
- error = vm_map_find(kernel_map, ef->object, 0,
- (vm_offset_t *) &ef->address,
- mapsize, 1,
- VM_PROT_ALL, VM_PROT_ALL, 0);
- if (error) {
- vm_object_deallocate(ef->object);
- free(ef, M_LINKER);
- goto out;
- }
-#else
- ef->address = malloc(mapsize, M_LINKER, M_WAITOK);
-#endif
- mapbase = ef->address;
-
- /*
- * Read the text and data sections and zero the bss.
- */
- for (i = 0; i < 2; i++) {
- caddr_t segbase = mapbase + segs[i]->p_vaddr - base_vaddr;
- error = vn_rdwr(UIO_READ, nd.ni_vp,
- segbase, segs[i]->p_filesz, segs[i]->p_offset,
- UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred, &resid, p);
- if (error) {
-#ifdef SPARSE_MAPPING
- vm_map_remove(kernel_map, (vm_offset_t) ef->address,
- (vm_offset_t) ef->address
- + (ef->object->size << PAGE_SHIFT));
- vm_object_deallocate(ef->object);
-#else
- free(ef->address, M_LINKER);
-#endif
- free(ef, M_LINKER);
- goto out;
- }
- bzero(segbase + segs[i]->p_filesz,
- segs[i]->p_memsz - segs[i]->p_filesz);
-
-#ifdef SPARSE_MAPPING
- /*
- * Wire down the pages
- */
- vm_map_pageable(kernel_map,
- (vm_offset_t) segbase,
- (vm_offset_t) segbase + segs[i]->p_memsz,
- FALSE);
-#endif
- }
-
- ef->dynamic = (const Elf_Dyn *) (mapbase + phdyn->p_vaddr - base_vaddr);
-
- lf = linker_make_file(filename, ef, &link_elf_file_ops);
- if (lf == NULL) {
-#ifdef SPARSE_MAPPING
- vm_map_remove(kernel_map, (vm_offset_t) ef->address,
- (vm_offset_t) ef->address
- + (ef->object->size << PAGE_SHIFT));
- vm_object_deallocate(ef->object);
-#else
- free(ef->address, M_LINKER);
-#endif
- free(ef, M_LINKER);
- error = ENOMEM;
- goto out;
- }
- lf->address = ef->address;
- lf->size = mapsize;
-
- error = parse_dynamic(lf);
- if (error)
- goto out;
- error = load_dependancies(lf);
- if (error)
- goto out;
- error = relocate_file(lf);
- if (error)
- goto out;
-
- /* Try and load the symbol table if it's present. (you can strip it!) */
- nbytes = hdr->e_shnum * hdr->e_shentsize;
- if (nbytes == 0 || hdr->e_shoff == 0)
- goto nosyms;
- shdr = malloc(nbytes, M_LINKER, M_WAITOK);
- if (shdr == NULL) {
- error = ENOMEM;
- goto out;
- }
- bzero(shdr, nbytes);
- error = vn_rdwr(UIO_READ, nd.ni_vp,
- (caddr_t)shdr, nbytes, hdr->e_shoff,
- UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred, &resid, p);
- if (error)
- goto out;
- symtabindex = -1;
- symstrindex = -1;
- for (i = 0; i < hdr->e_shnum; i++) {
- if (shdr[i].sh_type == SHT_SYMTAB) {
- symtabindex = i;
- symstrindex = shdr[i].sh_link;
- }
- }
- if (symtabindex < 0 || symstrindex < 0)
- goto nosyms;
-
- symcnt = shdr[symtabindex].sh_size;
- ef->symbase = malloc(symcnt, M_LINKER, M_WAITOK);
- strcnt = shdr[symstrindex].sh_size;
- ef->strbase = malloc(strcnt, M_LINKER, M_WAITOK);
-
- if (ef->symbase == NULL || ef->strbase == NULL) {
- error = ENOMEM;
- goto out;
- }
- error = vn_rdwr(UIO_READ, nd.ni_vp,
- ef->symbase, symcnt, shdr[symtabindex].sh_offset,
- UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred, &resid, p);
- if (error)
- goto out;
- error = vn_rdwr(UIO_READ, nd.ni_vp,
- ef->strbase, strcnt, shdr[symstrindex].sh_offset,
- UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred, &resid, p);
- if (error)
- goto out;
-
- ef->ddbsymcnt = symcnt / sizeof(Elf_Sym);
- ef->ddbsymtab = (const Elf_Sym *)ef->symbase;
- ef->ddbstrcnt = strcnt;
- ef->ddbstrtab = ef->strbase;
-
- lf->flags |= LINKER_FILE_LINKED;
-
-nosyms:
-
- *result = lf;
-
-out:
- if (error && lf)
- linker_file_unload(lf);
- if (shdr)
- free(shdr, M_LINKER);
- if (firstpage)
- free(firstpage, M_LINKER);
- VOP_UNLOCK(nd.ni_vp, 0, p);
- vn_close(nd.ni_vp, FREAD, p->p_ucred, p);
-
- return error;
-}
-
-static void
-link_elf_unload_file(linker_file_t file)
-{
- elf_file_t ef = file->priv;
-
- if (ef) {
-#ifdef SPARSE_MAPPING
- if (ef->object) {
- vm_map_remove(kernel_map, (vm_offset_t) ef->address,
- (vm_offset_t) ef->address
- + (ef->object->size << PAGE_SHIFT));
- vm_object_deallocate(ef->object);
- }
-#else
- if (ef->address)
- free(ef->address, M_LINKER);
-#endif
- if (ef->symbase)
- free(ef->symbase, M_LINKER);
- if (ef->strbase)
- free(ef->strbase, M_LINKER);
- free(ef, M_LINKER);
- }
-}
-
-static void
-link_elf_unload_module(linker_file_t file)
-{
- elf_file_t ef = file->priv;
-
- if (ef)
- free(ef, M_LINKER);
- if (file->filename)
- preload_delete_name(file->filename);
-}
-
-static int
-load_dependancies(linker_file_t lf)
-{
- elf_file_t ef = lf->priv;
- linker_file_t lfdep;
- char* name;
- const Elf_Dyn *dp;
- int error = 0;
-
- /*
- * All files are dependant on /kernel.
- */
- if (linker_kernel_file) {
- linker_kernel_file->refs++;
- linker_file_add_dependancy(lf, linker_kernel_file);
- }
-
- for (dp = ef->dynamic; dp->d_tag != DT_NULL; dp++) {
- if (dp->d_tag == DT_NEEDED) {
- name = ef->strtab + dp->d_un.d_val;
-
- error = linker_load_file(name, &lfdep);
- if (error)
- goto out;
- error = linker_file_add_dependancy(lf, lfdep);
- if (error)
- goto out;
- }
- }
-
-out:
- return error;
-}
-
-static const char *
-symbol_name(elf_file_t ef, Elf_Word r_info)
-{
- const Elf_Sym *ref;
-
- if (ELF_R_SYM(r_info)) {
- ref = ef->symtab + ELF_R_SYM(r_info);
- return ef->strtab + ref->st_name;
- } else
- return NULL;
-}
-
-static int
-relocate_file(linker_file_t lf)
-{
- elf_file_t ef = lf->priv;
- const Elf_Rel *rellim;
- const Elf_Rel *rel;
- const Elf_Rela *relalim;
- const Elf_Rela *rela;
- const char *symname;
-
- /* Perform relocations without addend if there are any: */
- rel = ef->rel;
- if (rel) {
- rellim = (const Elf_Rel *)((const char *)ef->rel + ef->relsize);
- while (rel < rellim) {
- symname = symbol_name(ef, rel->r_info);
- if (elf_reloc(lf, rel, ELF_RELOC_REL, symname)) {
- printf("link_elf: symbol %s undefined\n", symname);
- return ENOENT;
- }
- rel++;
- }
- }
-
- /* Perform relocations with addend if there are any: */
- rela = ef->rela;
- if (rela) {
- relalim = (const Elf_Rela *)((const char *)ef->rela + ef->relasize);
- while (rela < relalim) {
- symname = symbol_name(ef, rela->r_info);
- if (elf_reloc(lf, rela, ELF_RELOC_RELA, symname)) {
- printf("link_elf: symbol %s undefined\n", symname);
- return ENOENT;
- }
- rela++;
- }
- }
-
- /* Perform PLT relocations without addend if there are any: */
- rel = ef->pltrel;
- if (rel) {
- rellim = (const Elf_Rel *)((const char *)ef->pltrel + ef->pltrelsize);
- while (rel < rellim) {
- symname = symbol_name(ef, rel->r_info);
- if (elf_reloc(lf, rel, ELF_RELOC_REL, symname)) {
- printf("link_elf: symbol %s undefined\n", symname);
- return ENOENT;
- }
- rel++;
- }
- }
-
- /* Perform relocations with addend if there are any: */
- rela = ef->pltrela;
- if (rela) {
- relalim = (const Elf_Rela *)((const char *)ef->pltrela + ef->pltrelasize);
- while (rela < relalim) {
- symname = symbol_name(ef, rela->r_info);
- if (elf_reloc(lf, rela, ELF_RELOC_RELA, symname)) {
- printf("link_elf: symbol %s undefined\n", symname);
- return ENOENT;
- }
- rela++;
- }
- }
-
- return 0;
-}
-
-/*
- * Hash function for symbol table lookup. Don't even think about changing
- * this. It is specified by the System V ABI.
- */
-static unsigned long
-elf_hash(const char *name)
-{
- const unsigned char *p = (const unsigned char *) name;
- unsigned long h = 0;
- unsigned long g;
-
- while (*p != '\0') {
- h = (h << 4) + *p++;
- if ((g = h & 0xf0000000) != 0)
- h ^= g >> 24;
- h &= ~g;
- }
- return h;
-}
-
-int
-link_elf_lookup_symbol(linker_file_t lf, const char* name, c_linker_sym_t* sym)
-{
- elf_file_t ef = lf->priv;
- unsigned long symnum;
- const Elf_Sym* symp;
- const char *strp;
- unsigned long hash;
- int i;
-
- /* First, search hashed global symbols */
- hash = elf_hash(name);
- symnum = ef->buckets[hash % ef->nbuckets];
-
- while (symnum != STN_UNDEF) {
- if (symnum >= ef->nchains) {
- printf("link_elf_lookup_symbol: corrupt symbol table\n");
- return ENOENT;
- }
-
- symp = ef->symtab + symnum;
- if (symp->st_name == 0) {
- printf("link_elf_lookup_symbol: corrupt symbol table\n");
- return ENOENT;
- }
-
- strp = ef->strtab + symp->st_name;
-
- if (strcmp(name, strp) == 0) {
- if (symp->st_shndx != SHN_UNDEF ||
- (symp->st_value != 0 &&
- ELF_ST_TYPE(symp->st_info) == STT_FUNC)) {
- *sym = (c_linker_sym_t) symp;
- return 0;
- } else
- return ENOENT;
- }
-
- symnum = ef->chains[symnum];
- }
-
- /* If we have not found it, look at the full table (if loaded) */
- if (ef->symtab == ef->ddbsymtab)
- return ENOENT;
-
- /* Exhaustive search */
- for (i = 0, symp = ef->ddbsymtab; i < ef->ddbsymcnt; i++, symp++) {
- strp = ef->ddbstrtab + symp->st_name;
- if (strcmp(name, strp) == 0) {
- if (symp->st_shndx != SHN_UNDEF ||
- (symp->st_value != 0 &&
- ELF_ST_TYPE(symp->st_info) == STT_FUNC)) {
- *sym = (c_linker_sym_t) symp;
- return 0;
- } else
- return ENOENT;
- }
- }
-
- return ENOENT;
-}
-
-static int
-link_elf_symbol_values(linker_file_t lf, c_linker_sym_t sym, linker_symval_t* symval)
-{
- elf_file_t ef = lf->priv;
- const Elf_Sym* es = (const Elf_Sym*) sym;
-
- if (es >= ef->symtab && ((es - ef->symtab) < ef->nchains)) {
- symval->name = ef->strtab + es->st_name;
- symval->value = (caddr_t) ef->address + es->st_value;
- symval->size = es->st_size;
- return 0;
- }
- if (ef->symtab == ef->ddbsymtab)
- return ENOENT;
- if (es >= ef->ddbsymtab && ((es - ef->ddbsymtab) < ef->ddbsymcnt)) {
- symval->name = ef->ddbstrtab + es->st_name;
- symval->value = (caddr_t) ef->address + es->st_value;
- symval->size = es->st_size;
- return 0;
- }
- return ENOENT;
-}
-
-static int
-link_elf_search_symbol(linker_file_t lf, caddr_t value,
- c_linker_sym_t* sym, long* diffp)
-{
- elf_file_t ef = lf->priv;
- u_long off = (uintptr_t) (void *) value;
- u_long diff = off;
- u_long st_value;
- const Elf_Sym* es;
- const Elf_Sym* best = 0;
- int i;
-
- for (i = 0, es = ef->ddbsymtab; i < ef->ddbsymcnt; i++, es++) {
- if (es->st_name == 0)
- continue;
- st_value = es->st_value + (uintptr_t) (void *) ef->address;
- if (off >= st_value) {
- if (off - st_value < diff) {
- diff = off - st_value;
- best = es;
- if (diff == 0)
- break;
- } else if (off - st_value == diff) {
- best = es;
- }
- }
- }
- if (best == 0)
- *diffp = off;
- else
- *diffp = diff;
- *sym = (c_linker_sym_t) best;
-
- return 0;
-}
diff --git a/sys/kern/p1003_1b.c b/sys/kern/p1003_1b.c
deleted file mode 100644
index 36f4bc24153d..000000000000
--- a/sys/kern/p1003_1b.c
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- * Copyright (c) 1996, 1997, 1998
- * HD Associates, Inc. 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 HD Associates, Inc
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES 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 HD ASSOCIATES 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.
- *
- */
-
-/* p1003_1b: Real Time common code.
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/sysent.h>
-#include <sys/proc.h>
-#include <sys/syslog.h>
-#include <sys/module.h>
-#include <sys/sysproto.h>
-#include <sys/sysctl.h>
-
-#include <posix4/posix4.h>
-
-MALLOC_DEFINE(M_P31B, "p1003.1b", "Posix 1003.1B");
-
-/* p31b_proc: Return a proc struct corresponding to a pid to operate on.
- *
- * Enforce permission policy.
- *
- * The policy is the same as for sending signals except there
- * is no notion of process groups.
- *
- * pid == 0 means my process.
- *
- * This is disabled until I've got a permission gate in again:
- * only root can do this.
- */
-
-#if 0
-/*
- * This is stolen from CANSIGNAL in kern_sig:
- *
- * Can process p, with pcred pc, do "write flavor" operations to process q?
- */
-#define CAN_AFFECT(p, pc, q) \
- ((pc)->pc_ucred->cr_uid == 0 || \
- (pc)->p_ruid == (q)->p_cred->p_ruid || \
- (pc)->pc_ucred->cr_uid == (q)->p_cred->p_ruid || \
- (pc)->p_ruid == (q)->p_ucred->cr_uid || \
- (pc)->pc_ucred->cr_uid == (q)->p_ucred->cr_uid)
-#else
-#define CAN_AFFECT(p, pc, q) ((pc)->pc_ucred->cr_uid == 0)
-#endif
-
-/*
- * p31b_proc: Look up a proc from a PID. If proc is 0 it is
- * my own proc.
- */
-int p31b_proc(struct proc *p, pid_t pid, struct proc **pp)
-{
- int ret = 0;
- struct proc *other_proc = 0;
-
- if (pid == 0)
- other_proc = p;
- else
- other_proc = pfind(pid);
-
- if (other_proc)
- {
- /* Enforce permission policy.
- */
- if (CAN_AFFECT(p, p->p_cred, other_proc))
- *pp = other_proc;
- else
- ret = EPERM;
- }
- else
- ret = ESRCH;
-
- return ret;
-}
-
-/* The system calls return ENOSYS if an entry is called that is
- * not run-time supported. I am also logging since some programs
- * start to use this when they shouldn't. That will be removed if annoying.
- */
-int
-syscall_not_present(struct proc *p, const char *s, struct nosys_args *uap)
-{
- log(LOG_ERR, "cmd %s pid %d tried to use non-present %s\n",
- p->p_comm, p->p_pid, s);
-
- /* a " return nosys(p, uap); " here causes a core dump.
- */
-
- return ENOSYS;
-}
-
-#if !defined(_KPOSIX_PRIORITY_SCHEDULING)
-
-/* Not configured but loadable via a module:
- */
-
-static int sched_attach(void)
-{
- return 0;
-}
-
-SYSCALL_NOT_PRESENT_GEN(sched_setparam)
-SYSCALL_NOT_PRESENT_GEN(sched_getparam)
-SYSCALL_NOT_PRESENT_GEN(sched_setscheduler)
-SYSCALL_NOT_PRESENT_GEN(sched_getscheduler)
-SYSCALL_NOT_PRESENT_GEN(sched_yield)
-SYSCALL_NOT_PRESENT_GEN(sched_get_priority_max)
-SYSCALL_NOT_PRESENT_GEN(sched_get_priority_min)
-SYSCALL_NOT_PRESENT_GEN(sched_rr_get_interval)
-
-#else
-
-/* Configured in kernel version:
- */
-static struct ksched *ksched;
-
-static int sched_attach(void)
-{
- int ret = ksched_attach(&ksched);
-
- if (ret == 0)
- p31b_setcfg(CTL_P1003_1B_PRIORITY_SCHEDULING, 1);
-
- return ret;
-}
-
-int sched_setparam(struct proc *p,
- struct sched_setparam_args *uap)
-{
- int e;
-
- struct sched_param sched_param;
- copyin(uap->param, &sched_param, sizeof(sched_param));
-
- (void) (0
- || (e = p31b_proc(p, uap->pid, &p))
- || (e = ksched_setparam(&p->p_retval[0], ksched, p,
- (const struct sched_param *)&sched_param))
- );
-
- return e;
-}
-
-int sched_getparam(struct proc *p,
- struct sched_getparam_args *uap)
-{
- int e;
- struct sched_param sched_param;
-
- (void) (0
- || (e = p31b_proc(p, uap->pid, &p))
- || (e = ksched_getparam(&p->p_retval[0], ksched, p, &sched_param))
- );
-
- if (!e)
- copyout(&sched_param, uap->param, sizeof(sched_param));
-
- return e;
-}
-int sched_setscheduler(struct proc *p,
- struct sched_setscheduler_args *uap)
-{
- int e;
-
- struct sched_param sched_param;
- copyin(uap->param, &sched_param, sizeof(sched_param));
-
- (void) (0
- || (e = p31b_proc(p, uap->pid, &p))
- || (e = ksched_setscheduler(&p->p_retval[0],
- ksched, p, uap->policy,
- (const struct sched_param *)&sched_param))
- );
-
- return e;
-}
-int sched_getscheduler(struct proc *p,
- struct sched_getscheduler_args *uap)
-{
- int e;
- (void) (0
- || (e = p31b_proc(p, uap->pid, &p))
- || (e = ksched_getscheduler(&p->p_retval[0], ksched, p))
- );
-
- return e;
-}
-int sched_yield(struct proc *p,
- struct sched_yield_args *uap)
-{
- return ksched_yield(&p->p_retval[0], ksched);
-}
-int sched_get_priority_max(struct proc *p,
- struct sched_get_priority_max_args *uap)
-{
- return ksched_get_priority_max(&p->p_retval[0],
- ksched, uap->policy);
-}
-int sched_get_priority_min(struct proc *p,
- struct sched_get_priority_min_args *uap)
-{
- return ksched_get_priority_min(&p->p_retval[0],
- ksched, uap->policy);
-}
-int sched_rr_get_interval(struct proc *p,
- struct sched_rr_get_interval_args *uap)
-{
- int e;
-
- (void) (0
- || (e = p31b_proc(p, uap->pid, &p))
- || (e = ksched_rr_get_interval(&p->p_retval[0], ksched,
- p, uap->interval))
- );
-
- return e;
-}
-
-#endif
-
-static void p31binit(void *notused)
-{
- (void) sched_attach();
- p31b_setcfg(CTL_P1003_1B_PAGESIZE, PAGE_SIZE);
-}
-
-SYSINIT(p31b, SI_SUB_P1003_1B, SI_ORDER_FIRST, p31binit, NULL);
diff --git a/sys/kern/posix4_mib.c b/sys/kern/posix4_mib.c
deleted file mode 100644
index ba4a853ea66d..000000000000
--- a/sys/kern/posix4_mib.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/*-
- * Copyright (c) 1998
- * HD Associates, Inc. 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 HD Associates, Inc
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES 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 HD ASSOCIATES 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 <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/queue.h>
-#include <sys/sysctl.h>
-#include <posix4/posix4.h>
-
-static int facility[CTL_P1003_1B_MAXID - 1];
-
-/* OID_AUTO isn't working with sysconf(3). I guess I'd have to
- * modify it to do a lookup by name from the index.
- * For now I've left it a top-level sysctl.
- */
-
-#if 1
-
-SYSCTL_DECL(_p1003_1b);
-
-#define P1B_SYSCTL(num, name) \
-SYSCTL_INT(_p1003_1b, num, \
- name, CTLFLAG_RD, facility + num - 1, 0, "");
-
-#else
-
-SYSCTL_DECL(_kern_p1003_1b);
-
-#define P1B_SYSCTL(num, name) \
-SYSCTL_INT(_kern_p1003_1b, OID_AUTO, \
- name, CTLFLAG_RD, facility + num - 1, 0, "");
-SYSCTL_NODE(_kern, OID_AUTO, p1003_1b, CTLFLAG_RW, 0, "P1003.1B");
-
-#endif
-
-P1B_SYSCTL(CTL_P1003_1B_ASYNCHRONOUS_IO, asynchronous_io);
-P1B_SYSCTL(CTL_P1003_1B_MAPPED_FILES, mapped_files);
-P1B_SYSCTL(CTL_P1003_1B_MEMLOCK, memlock);
-P1B_SYSCTL(CTL_P1003_1B_MEMLOCK_RANGE, memlock_range);
-P1B_SYSCTL(CTL_P1003_1B_MEMORY_PROTECTION, memory_protection);
-P1B_SYSCTL(CTL_P1003_1B_MESSAGE_PASSING, message_passing);
-P1B_SYSCTL(CTL_P1003_1B_PRIORITIZED_IO, prioritized_io);
-P1B_SYSCTL(CTL_P1003_1B_PRIORITY_SCHEDULING, priority_scheduling);
-P1B_SYSCTL(CTL_P1003_1B_REALTIME_SIGNALS, realtime_signals);
-P1B_SYSCTL(CTL_P1003_1B_SEMAPHORES, semaphores);
-P1B_SYSCTL(CTL_P1003_1B_FSYNC, fsync);
-P1B_SYSCTL(CTL_P1003_1B_SHARED_MEMORY_OBJECTS, shared_memory_objects);
-P1B_SYSCTL(CTL_P1003_1B_SYNCHRONIZED_IO, synchronized_io);
-P1B_SYSCTL(CTL_P1003_1B_TIMERS, timers);
-P1B_SYSCTL(CTL_P1003_1B_AIO_LISTIO_MAX, aio_listio_max);
-P1B_SYSCTL(CTL_P1003_1B_AIO_MAX, aio_max);
-P1B_SYSCTL(CTL_P1003_1B_AIO_PRIO_DELTA_MAX, aio_prio_delta_max);
-P1B_SYSCTL(CTL_P1003_1B_DELAYTIMER_MAX, delaytimer_max);
-P1B_SYSCTL(CTL_P1003_1B_MQ_OPEN_MAX, mq_open_max);
-P1B_SYSCTL(CTL_P1003_1B_PAGESIZE, pagesize);
-P1B_SYSCTL(CTL_P1003_1B_RTSIG_MAX, rtsig_max);
-P1B_SYSCTL(CTL_P1003_1B_SEM_NSEMS_MAX, sem_nsems_max);
-P1B_SYSCTL(CTL_P1003_1B_SEM_VALUE_MAX, sem_value_max);
-P1B_SYSCTL(CTL_P1003_1B_SIGQUEUE_MAX, sigqueue_max);
-P1B_SYSCTL(CTL_P1003_1B_TIMER_MAX, timer_max);
-
-/* p31b_setcfg: Set the configuration
- */
-void p31b_setcfg(int num, int value)
-{
- if (num >= 1 && num < CTL_P1003_1B_MAXID)
- facility[num - 1] = value;
-}
diff --git a/sys/kern/subr_acl_posix1e.c b/sys/kern/subr_acl_posix1e.c
deleted file mode 100644
index bd4a52f52def..000000000000
--- a/sys/kern/subr_acl_posix1e.c
+++ /dev/null
@@ -1,277 +0,0 @@
-/*-
- * Copyright (c) 1999, 2000 Robert N. M. Watson
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Generic routines to support file system ACLs, at a syntactic level
- * Semantics are the responsibility of the underlying file system
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/sysproto.h>
-#include <sys/kernel.h>
-#include <sys/malloc.h>
-#include <sys/vnode.h>
-#include <sys/lock.h>
-#include <sys/namei.h>
-#include <sys/file.h>
-#include <sys/proc.h>
-#include <sys/sysent.h>
-#include <sys/errno.h>
-#include <sys/stat.h>
-#include <sys/acl.h>
-#include <vm/vm_zone.h>
-
-static MALLOC_DEFINE(M_ACL, "acl", "access control list");
-
-static int vacl_set_acl(struct proc *p, struct vnode *vp, acl_type_t type,
- struct acl *aclp);
-static int vacl_get_acl(struct proc *p, struct vnode *vp, acl_type_t type,
- struct acl *aclp);
-static int vacl_aclcheck(struct proc *p, struct vnode *vp, acl_type_t type,
- struct acl *aclp);
-
-/*
- * These calls wrap the real vnode operations, and are called by the
- * syscall code once the syscall has converted the path or file
- * descriptor to a vnode (unlocked). The aclp pointer is assumed
- * still to point to userland, so this should not be consumed within
- * the kernel except by syscall code. Other code should directly
- * invoke VOP_{SET,GET}ACL.
- */
-
-/*
- * Given a vnode, set its ACL.
- */
-static int
-vacl_set_acl(struct proc *p, struct vnode *vp, acl_type_t type,
- struct acl *aclp)
-{
- struct acl inkernacl;
- int error;
-
- error = copyin(aclp, &inkernacl, sizeof(struct acl));
- if (error)
- return(error);
- VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
- error = VOP_SETACL(vp, type, &inkernacl, p->p_ucred, p);
- VOP_UNLOCK(vp, 0, p);
- return(error);
-}
-
-/*
- * Given a vnode, get its ACL.
- */
-static int
-vacl_get_acl(struct proc *p, struct vnode *vp, acl_type_t type,
- struct acl *aclp)
-{
- struct acl inkernelacl;
- int error;
-
- error = VOP_GETACL(vp, type, &inkernelacl, p->p_ucred, p);
- if (error == 0)
- error = copyout(&inkernelacl, aclp, sizeof(struct acl));
- return (error);
-}
-
-/*
- * Given a vnode, delete its ACL.
- */
-static int
-vacl_delete(struct proc *p, struct vnode *vp, acl_type_t type)
-{
- int error;
-
- VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
- error = VOP_SETACL(vp, ACL_TYPE_DEFAULT, 0, p->p_ucred, p);
- VOP_UNLOCK(vp, 0, p);
- return (error);
-}
-
-/*
- * Given a vnode, check whether an ACL is appropriate for it
- */
-static int
-vacl_aclcheck(struct proc *p, struct vnode *vp, acl_type_t type,
- struct acl *aclp)
-{
- struct acl inkernelacl;
- int error;
-
- error = copyin(aclp, &inkernelacl, sizeof(struct acl));
- if (error)
- return(error);
- error = VOP_ACLCHECK(vp, type, &inkernelacl, p->p_ucred, p);
- return (error);
-}
-
-/*
- * syscalls -- convert the path/fd to a vnode, and call vacl_whatever.
- * Don't need to lock, as the vacl_ code will get/release any locks
- * required.
- */
-
-/*
- * Given a file path, get an ACL for it
- */
-int
-__acl_get_file(struct proc *p, struct __acl_get_file_args *uap)
-{
- struct nameidata nd;
- int error;
-
- /* what flags are required here -- possible not LOCKLEAF? */
- NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
- error = namei(&nd);
- if (error)
- return(error);
- error = vacl_get_acl(p, nd.ni_vp, SCARG(uap, type), SCARG(uap, aclp));
- NDFREE(&nd, 0);
- return (error);
-}
-
-/*
- * Given a file path, set an ACL for it
- */
-int
-__acl_set_file(struct proc *p, struct __acl_set_file_args *uap)
-{
- struct nameidata nd;
- int error;
-
- NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
- error = namei(&nd);
- if (error)
- return(error);
- error = vacl_set_acl(p, nd.ni_vp, SCARG(uap, type), SCARG(uap, aclp));
- NDFREE(&nd, 0);
- return (error);
-}
-
-/*
- * Given a file descriptor, get an ACL for it
- */
-int
-__acl_get_fd(struct proc *p, struct __acl_get_fd_args *uap)
-{
- struct file *fp;
- int error;
-
- error = getvnode(p->p_fd, SCARG(uap, filedes), &fp);
- if (error)
- return(error);
- return vacl_get_acl(p, (struct vnode *)fp->f_data, SCARG(uap, type),
- SCARG(uap, aclp));
-}
-
-/*
- * Given a file descriptor, set an ACL for it
- */
-int
-__acl_set_fd(struct proc *p, struct __acl_set_fd_args *uap)
-{
- struct file *fp;
- int error;
-
- error = getvnode(p->p_fd, SCARG(uap, filedes), &fp);
- if (error)
- return(error);
- return vacl_set_acl(p, (struct vnode *)fp->f_data, SCARG(uap, type),
- SCARG(uap, aclp));
-}
-
-/*
- * Given a file path, delete an ACL from it.
- */
-int
-__acl_delete_file(struct proc *p, struct __acl_delete_file_args *uap)
-{
- struct nameidata nd;
- int error;
-
- NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
- error = namei(&nd);
- if (error)
- return(error);
- error = vacl_delete(p, nd.ni_vp, SCARG(uap, type));
- NDFREE(&nd, 0);
- return (error);
-}
-
-/*
- * Given a file path, delete an ACL from it.
- */
-int
-__acl_delete_fd(struct proc *p, struct __acl_delete_fd_args *uap)
-{
- struct file *fp;
- int error;
-
- error = getvnode(p->p_fd, SCARG(uap, filedes), &fp);
- if (error)
- return(error);
- error = vacl_delete(p, (struct vnode *)fp->f_data, SCARG(uap, type));
- return (error);
-}
-
-/*
- * Given a file path, check an ACL for it
- */
-int
-__acl_aclcheck_file(struct proc *p, struct __acl_aclcheck_file_args *uap)
-{
- struct nameidata nd;
- int error;
-
- NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
- error = namei(&nd);
- if (error)
- return(error);
- error = vacl_aclcheck(p, nd.ni_vp, SCARG(uap, type), SCARG(uap, aclp));
- NDFREE(&nd, 0);
- return (error);
-}
-
-/*
- * Given a file descriptor, check an ACL for it
- */
-int
-__acl_aclcheck_fd(struct proc *p, struct __acl_aclcheck_fd_args *uap)
-{
- struct file *fp;
- int error;
-
- error = getvnode(p->p_fd, SCARG(uap, filedes), &fp);
- if (error)
- return(error);
- return vacl_aclcheck(p, (struct vnode *)fp->f_data, SCARG(uap, type),
- SCARG(uap, aclp));
-}
diff --git a/sys/kern/subr_clist.c b/sys/kern/subr_clist.c
deleted file mode 100644
index a7d1daf79e8e..000000000000
--- a/sys/kern/subr_clist.c
+++ /dev/null
@@ -1,696 +0,0 @@
-/*
- * Copyright (c) 1994, David Greenman
- * 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 unmodified, 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-/*
- * clist support routines
- */
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/malloc.h>
-#include <sys/tty.h>
-#include <sys/clist.h>
-
-static void clist_init __P((void *));
-SYSINIT(clist, SI_SUB_CLIST, SI_ORDER_FIRST, clist_init, NULL)
-
-static struct cblock *cfreelist = 0;
-int cfreecount = 0;
-static int cslushcount;
-static int ctotcount;
-
-#ifndef INITIAL_CBLOCKS
-#define INITIAL_CBLOCKS 50
-#endif
-
-static struct cblock *cblock_alloc __P((void));
-static void cblock_alloc_cblocks __P((int number));
-static void cblock_free __P((struct cblock *cblockp));
-static void cblock_free_cblocks __P((int number));
-
-#include "opt_ddb.h"
-#ifdef DDB
-#include <ddb/ddb.h>
-
-DB_SHOW_COMMAND(cbstat, cbstat)
-{
- int cbsize = CBSIZE;
-
- printf(
- "tot = %d (active = %d, free = %d (reserved = %d, slush = %d))\n",
- ctotcount * cbsize, ctotcount * cbsize - cfreecount, cfreecount,
- cfreecount - cslushcount * cbsize, cslushcount * cbsize);
-}
-#endif /* DDB */
-
-/*
- * Called from init_main.c
- */
-/* ARGSUSED*/
-static void
-clist_init(dummy)
- void *dummy;
-{
- /*
- * Allocate an initial base set of cblocks as a 'slush'.
- * We allocate non-slush cblocks with each initial ttyopen() and
- * deallocate them with each ttyclose().
- * We should adjust the slush allocation. This can't be done in
- * the i/o routines because they are sometimes called from
- * interrupt handlers when it may be unsafe to call malloc().
- */
- cblock_alloc_cblocks(cslushcount = INITIAL_CBLOCKS);
-}
-
-/*
- * Remove a cblock from the cfreelist queue and return a pointer
- * to it.
- */
-static __inline struct cblock *
-cblock_alloc()
-{
- struct cblock *cblockp;
-
- cblockp = cfreelist;
- if (cblockp == NULL)
- panic("clist reservation botch");
- cfreelist = cblockp->c_next;
- cblockp->c_next = NULL;
- cfreecount -= CBSIZE;
- return (cblockp);
-}
-
-/*
- * Add a cblock to the cfreelist queue.
- */
-static __inline void
-cblock_free(cblockp)
- struct cblock *cblockp;
-{
- if (isset(cblockp->c_quote, CBQSIZE * NBBY - 1))
- bzero(cblockp->c_quote, sizeof cblockp->c_quote);
- cblockp->c_next = cfreelist;
- cfreelist = cblockp;
- cfreecount += CBSIZE;
-}
-
-/*
- * Allocate some cblocks for the cfreelist queue.
- */
-static void
-cblock_alloc_cblocks(number)
- int number;
-{
- int i;
- struct cblock *cbp;
-
- for (i = 0; i < number; ++i) {
- cbp = malloc(sizeof *cbp, M_TTYS, M_NOWAIT);
- if (cbp == NULL) {
- printf(
-"clist_alloc_cblocks: M_NOWAIT malloc failed, trying M_WAITOK\n");
- cbp = malloc(sizeof *cbp, M_TTYS, M_WAITOK);
- }
- /*
- * Freed cblocks have zero quotes and garbage elsewhere.
- * Set the may-have-quote bit to force zeroing the quotes.
- */
- setbit(cbp->c_quote, CBQSIZE * NBBY - 1);
- cblock_free(cbp);
- }
- ctotcount += number;
-}
-
-/*
- * Set the cblock allocation policy for a a clist.
- * Must be called in process context at spltty().
- */
-void
-clist_alloc_cblocks(clistp, ccmax, ccreserved)
- struct clist *clistp;
- int ccmax;
- int ccreserved;
-{
- int dcbr;
-
- /*
- * Allow for wasted space at the head.
- */
- if (ccmax != 0)
- ccmax += CBSIZE - 1;
- if (ccreserved != 0)
- ccreserved += CBSIZE - 1;
-
- clistp->c_cbmax = roundup(ccmax, CBSIZE) / CBSIZE;
- dcbr = roundup(ccreserved, CBSIZE) / CBSIZE - clistp->c_cbreserved;
- if (dcbr >= 0)
- cblock_alloc_cblocks(dcbr);
- else {
- if (clistp->c_cbreserved + dcbr < clistp->c_cbcount)
- dcbr = clistp->c_cbcount - clistp->c_cbreserved;
- cblock_free_cblocks(-dcbr);
- }
- clistp->c_cbreserved += dcbr;
-}
-
-/*
- * Free some cblocks from the cfreelist queue back to the
- * system malloc pool.
- */
-static void
-cblock_free_cblocks(number)
- int number;
-{
- int i;
-
- for (i = 0; i < number; ++i)
- free(cblock_alloc(), M_TTYS);
- ctotcount -= number;
-}
-
-/*
- * Free the cblocks reserved for a clist.
- * Must be called at spltty().
- */
-void
-clist_free_cblocks(clistp)
- struct clist *clistp;
-{
- if (clistp->c_cbcount != 0)
- panic("freeing active clist cblocks");
- cblock_free_cblocks(clistp->c_cbreserved);
- clistp->c_cbmax = 0;
- clistp->c_cbreserved = 0;
-}
-
-/*
- * Get a character from the head of a clist.
- */
-int
-getc(clistp)
- struct clist *clistp;
-{
- int chr = -1;
- int s;
- struct cblock *cblockp;
-
- s = spltty();
-
- /* If there are characters in the list, get one */
- if (clistp->c_cc) {
- cblockp = (struct cblock *)((intptr_t)clistp->c_cf & ~CROUND);
- chr = (u_char)*clistp->c_cf;
-
- /*
- * If this char is quoted, set the flag.
- */
- if (isset(cblockp->c_quote, clistp->c_cf - (char *)cblockp->c_info))
- chr |= TTY_QUOTE;
-
- /*
- * Advance to next character.
- */
- clistp->c_cf++;
- clistp->c_cc--;
- /*
- * If we have advanced the 'first' character pointer
- * past the end of this cblock, advance to the next one.
- * If there are no more characters, set the first and
- * last pointers to NULL. In either case, free the
- * current cblock.
- */
- if ((clistp->c_cf >= (char *)(cblockp+1)) || (clistp->c_cc == 0)) {
- if (clistp->c_cc > 0) {
- clistp->c_cf = cblockp->c_next->c_info;
- } else {
- clistp->c_cf = clistp->c_cl = NULL;
- }
- cblock_free(cblockp);
- if (--clistp->c_cbcount >= clistp->c_cbreserved)
- ++cslushcount;
- }
- }
-
- splx(s);
- return (chr);
-}
-
-/*
- * Copy 'amount' of chars, beginning at head of clist 'clistp' to
- * destination linear buffer 'dest'. Return number of characters
- * actually copied.
- */
-int
-q_to_b(clistp, dest, amount)
- struct clist *clistp;
- char *dest;
- int amount;
-{
- struct cblock *cblockp;
- struct cblock *cblockn;
- char *dest_orig = dest;
- int numc;
- int s;
-
- s = spltty();
-
- while (clistp && amount && (clistp->c_cc > 0)) {
- cblockp = (struct cblock *)((intptr_t)clistp->c_cf & ~CROUND);
- cblockn = cblockp + 1; /* pointer arithmetic! */
- numc = min(amount, (char *)cblockn - clistp->c_cf);
- numc = min(numc, clistp->c_cc);
- bcopy(clistp->c_cf, dest, numc);
- amount -= numc;
- clistp->c_cf += numc;
- clistp->c_cc -= numc;
- dest += numc;
- /*
- * If this cblock has been emptied, advance to the next
- * one. If there are no more characters, set the first
- * and last pointer to NULL. In either case, free the
- * current cblock.
- */
- if ((clistp->c_cf >= (char *)cblockn) || (clistp->c_cc == 0)) {
- if (clistp->c_cc > 0) {
- clistp->c_cf = cblockp->c_next->c_info;
- } else {
- clistp->c_cf = clistp->c_cl = NULL;
- }
- cblock_free(cblockp);
- if (--clistp->c_cbcount >= clistp->c_cbreserved)
- ++cslushcount;
- }
- }
-
- splx(s);
- return (dest - dest_orig);
-}
-
-/*
- * Flush 'amount' of chars, beginning at head of clist 'clistp'.
- */
-void
-ndflush(clistp, amount)
- struct clist *clistp;
- int amount;
-{
- struct cblock *cblockp;
- struct cblock *cblockn;
- int numc;
- int s;
-
- s = spltty();
-
- while (amount && (clistp->c_cc > 0)) {
- cblockp = (struct cblock *)((intptr_t)clistp->c_cf & ~CROUND);
- cblockn = cblockp + 1; /* pointer arithmetic! */
- numc = min(amount, (char *)cblockn - clistp->c_cf);
- numc = min(numc, clistp->c_cc);
- amount -= numc;
- clistp->c_cf += numc;
- clistp->c_cc -= numc;
- /*
- * If this cblock has been emptied, advance to the next
- * one. If there are no more characters, set the first
- * and last pointer to NULL. In either case, free the
- * current cblock.
- */
- if ((clistp->c_cf >= (char *)cblockn) || (clistp->c_cc == 0)) {
- if (clistp->c_cc > 0) {
- clistp->c_cf = cblockp->c_next->c_info;
- } else {
- clistp->c_cf = clistp->c_cl = NULL;
- }
- cblock_free(cblockp);
- if (--clistp->c_cbcount >= clistp->c_cbreserved)
- ++cslushcount;
- }
- }
-
- splx(s);
-}
-
-/*
- * Add a character to the end of a clist. Return -1 is no
- * more clists, or 0 for success.
- */
-int
-putc(chr, clistp)
- int chr;
- struct clist *clistp;
-{
- struct cblock *cblockp;
- int s;
-
- s = spltty();
-
- if (clistp->c_cl == NULL) {
- if (clistp->c_cbreserved < 1) {
- splx(s);
- printf("putc to a clist with no reserved cblocks\n");
- return (-1); /* nothing done */
- }
- cblockp = cblock_alloc();
- clistp->c_cbcount = 1;
- clistp->c_cf = clistp->c_cl = cblockp->c_info;
- clistp->c_cc = 0;
- } else {
- cblockp = (struct cblock *)((intptr_t)clistp->c_cl & ~CROUND);
- if (((intptr_t)clistp->c_cl & CROUND) == 0) {
- struct cblock *prev = (cblockp - 1);
-
- if (clistp->c_cbcount >= clistp->c_cbreserved) {
- if (clistp->c_cbcount >= clistp->c_cbmax
- || cslushcount <= 0) {
- splx(s);
- return (-1);
- }
- --cslushcount;
- }
- cblockp = cblock_alloc();
- clistp->c_cbcount++;
- prev->c_next = cblockp;
- clistp->c_cl = cblockp->c_info;
- }
- }
-
- /*
- * If this character is quoted, set the quote bit, if not, clear it.
- */
- if (chr & TTY_QUOTE) {
- setbit(cblockp->c_quote, clistp->c_cl - (char *)cblockp->c_info);
- /*
- * Use one of the spare quote bits to record that something
- * may be quoted.
- */
- setbit(cblockp->c_quote, CBQSIZE * NBBY - 1);
- } else
- clrbit(cblockp->c_quote, clistp->c_cl - (char *)cblockp->c_info);
-
- *clistp->c_cl++ = chr;
- clistp->c_cc++;
-
- splx(s);
- return (0);
-}
-
-/*
- * Copy data from linear buffer to clist chain. Return the
- * number of characters not copied.
- */
-int
-b_to_q(src, amount, clistp)
- char *src;
- int amount;
- struct clist *clistp;
-{
- struct cblock *cblockp;
- char *firstbyte, *lastbyte;
- u_char startmask, endmask;
- int startbit, endbit, num_between, numc;
- int s;
-
- /*
- * Avoid allocating an initial cblock and then not using it.
- * c_cc == 0 must imply c_cbount == 0.
- */
- if (amount <= 0)
- return (amount);
-
- s = spltty();
-
- /*
- * If there are no cblocks assigned to this clist yet,
- * then get one.
- */
- if (clistp->c_cl == NULL) {
- if (clistp->c_cbreserved < 1) {
- splx(s);
- printf("b_to_q to a clist with no reserved cblocks.\n");
- return (amount); /* nothing done */
- }
- cblockp = cblock_alloc();
- clistp->c_cbcount = 1;
- clistp->c_cf = clistp->c_cl = cblockp->c_info;
- clistp->c_cc = 0;
- } else {
- cblockp = (struct cblock *)((intptr_t)clistp->c_cl & ~CROUND);
- }
-
- while (amount) {
- /*
- * Get another cblock if needed.
- */
- if (((intptr_t)clistp->c_cl & CROUND) == 0) {
- struct cblock *prev = cblockp - 1;
-
- if (clistp->c_cbcount >= clistp->c_cbreserved) {
- if (clistp->c_cbcount >= clistp->c_cbmax
- || cslushcount <= 0) {
- splx(s);
- return (amount);
- }
- --cslushcount;
- }
- cblockp = cblock_alloc();
- clistp->c_cbcount++;
- prev->c_next = cblockp;
- clistp->c_cl = cblockp->c_info;
- }
-
- /*
- * Copy a chunk of the linear buffer up to the end
- * of this cblock.
- */
- numc = min(amount, (char *)(cblockp + 1) - clistp->c_cl);
- bcopy(src, clistp->c_cl, numc);
-
- /*
- * Clear quote bits if they aren't known to be clear.
- * The following could probably be made into a seperate
- * "bitzero()" routine, but why bother?
- */
- if (isset(cblockp->c_quote, CBQSIZE * NBBY - 1)) {
- startbit = clistp->c_cl - (char *)cblockp->c_info;
- endbit = startbit + numc - 1;
-
- firstbyte = (u_char *)cblockp->c_quote + (startbit / NBBY);
- lastbyte = (u_char *)cblockp->c_quote + (endbit / NBBY);
-
- /*
- * Calculate mask of bits to preserve in first and
- * last bytes.
- */
- startmask = NBBY - (startbit % NBBY);
- startmask = 0xff >> startmask;
- endmask = (endbit % NBBY);
- endmask = 0xff << (endmask + 1);
-
- if (firstbyte != lastbyte) {
- *firstbyte &= startmask;
- *lastbyte &= endmask;
-
- num_between = lastbyte - firstbyte - 1;
- if (num_between)
- bzero(firstbyte + 1, num_between);
- } else {
- *firstbyte &= (startmask | endmask);
- }
- }
-
- /*
- * ...and update pointer for the next chunk.
- */
- src += numc;
- clistp->c_cl += numc;
- clistp->c_cc += numc;
- amount -= numc;
- /*
- * If we go through the loop again, it's always
- * for data in the next cblock, so by adding one (cblock),
- * (which makes the pointer 1 beyond the end of this
- * cblock) we prepare for the assignment of 'prev'
- * above.
- */
- cblockp += 1;
-
- }
-
- splx(s);
- return (amount);
-}
-
-/*
- * Get the next character in the clist. Store it at dst. Don't
- * advance any clist pointers, but return a pointer to the next
- * character position.
- */
-char *
-nextc(clistp, cp, dst)
- struct clist *clistp;
- char *cp;
- int *dst;
-{
- struct cblock *cblockp;
-
- ++cp;
- /*
- * See if the next character is beyond the end of
- * the clist.
- */
- if (clistp->c_cc && (cp != clistp->c_cl)) {
- /*
- * If the next character is beyond the end of this
- * cblock, advance to the next cblock.
- */
- if (((intptr_t)cp & CROUND) == 0)
- cp = ((struct cblock *)cp - 1)->c_next->c_info;
- cblockp = (struct cblock *)((intptr_t)cp & ~CROUND);
-
- /*
- * Get the character. Set the quote flag if this character
- * is quoted.
- */
- *dst = (u_char)*cp | (isset(cblockp->c_quote, cp - (char *)cblockp->c_info) ? TTY_QUOTE : 0);
-
- return (cp);
- }
-
- return (NULL);
-}
-
-/*
- * "Unput" a character from a clist.
- */
-int
-unputc(clistp)
- struct clist *clistp;
-{
- struct cblock *cblockp = 0, *cbp = 0;
- int s;
- int chr = -1;
-
-
- s = spltty();
-
- if (clistp->c_cc) {
- --clistp->c_cc;
- --clistp->c_cl;
-
- chr = (u_char)*clistp->c_cl;
-
- cblockp = (struct cblock *)((intptr_t)clistp->c_cl & ~CROUND);
-
- /*
- * Set quote flag if this character was quoted.
- */
- if (isset(cblockp->c_quote, (u_char *)clistp->c_cl - cblockp->c_info))
- chr |= TTY_QUOTE;
-
- /*
- * If all of the characters have been unput in this
- * cblock, then find the previous one and free this
- * one.
- */
- if (clistp->c_cc && (clistp->c_cl <= (char *)cblockp->c_info)) {
- cbp = (struct cblock *)((intptr_t)clistp->c_cf & ~CROUND);
-
- while (cbp->c_next != cblockp)
- cbp = cbp->c_next;
-
- /*
- * When the previous cblock is at the end, the 'last'
- * pointer always points (invalidly) one past.
- */
- clistp->c_cl = (char *)(cbp+1);
- cblock_free(cblockp);
- if (--clistp->c_cbcount >= clistp->c_cbreserved)
- ++cslushcount;
- cbp->c_next = NULL;
- }
- }
-
- /*
- * If there are no more characters on the list, then
- * free the last cblock.
- */
- if ((clistp->c_cc == 0) && clistp->c_cl) {
- cblockp = (struct cblock *)((intptr_t)clistp->c_cl & ~CROUND);
- cblock_free(cblockp);
- if (--clistp->c_cbcount >= clistp->c_cbreserved)
- ++cslushcount;
- clistp->c_cf = clistp->c_cl = NULL;
- }
-
- splx(s);
- return (chr);
-}
-
-/*
- * Move characters in source clist to destination clist,
- * preserving quote bits.
- */
-void
-catq(src_clistp, dest_clistp)
- struct clist *src_clistp, *dest_clistp;
-{
- int chr, s;
-
- s = spltty();
- /*
- * If the destination clist is empty (has no cblocks atttached),
- * and there are no possible complications with the resource counters,
- * then we simply assign the current clist to the destination.
- */
- if (!dest_clistp->c_cf
- && src_clistp->c_cbcount <= src_clistp->c_cbmax
- && src_clistp->c_cbcount <= dest_clistp->c_cbmax) {
- dest_clistp->c_cf = src_clistp->c_cf;
- dest_clistp->c_cl = src_clistp->c_cl;
- src_clistp->c_cf = src_clistp->c_cl = NULL;
-
- dest_clistp->c_cc = src_clistp->c_cc;
- src_clistp->c_cc = 0;
- dest_clistp->c_cbcount = src_clistp->c_cbcount;
- src_clistp->c_cbcount = 0;
-
- splx(s);
- return;
- }
-
- splx(s);
-
- /*
- * XXX This should probably be optimized to more than one
- * character at a time.
- */
- while ((chr = getc(src_clistp)) != -1)
- putc(chr, dest_clistp);
-}
diff --git a/sys/kern/subr_disklabel.c b/sys/kern/subr_disklabel.c
deleted file mode 100644
index 9184f2ff0e2a..000000000000
--- a/sys/kern/subr_disklabel.c
+++ /dev/null
@@ -1,408 +0,0 @@
-/*
- * Copyright (c) 1982, 1986, 1988, 1993
- * The Regents of the University of California. All rights reserved.
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)ufs_disksubr.c 8.5 (Berkeley) 1/21/94
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/buf.h>
-#include <sys/conf.h>
-#include <sys/disklabel.h>
-#include <sys/diskslice.h>
-#include <sys/syslog.h>
-
-/*
- * Seek sort for disks.
- *
- * The buf_queue keep two queues, sorted in ascending block order. The first
- * queue holds those requests which are positioned after the current block
- * (in the first request); the second, which starts at queue->switch_point,
- * holds requests which came in after their block number was passed. Thus
- * we implement a one way scan, retracting after reaching the end of the drive
- * to the first request on the second queue, at which time it becomes the
- * first queue.
- *
- * A one-way scan is natural because of the way UNIX read-ahead blocks are
- * allocated.
- */
-
-void
-bufqdisksort(bufq, bp)
- struct buf_queue_head *bufq;
- struct buf *bp;
-{
- struct buf *bq;
- struct buf *bn;
- struct buf *be;
-
- be = TAILQ_LAST(&bufq->queue, buf_queue);
- /*
- * If the queue is empty or we are an
- * ordered transaction, then it's easy.
- */
- if ((bq = bufq_first(bufq)) == NULL
- || (bp->b_flags & B_ORDERED) != 0) {
- bufq_insert_tail(bufq, bp);
- return;
- } else if (bufq->insert_point != NULL) {
-
- /*
- * A certain portion of the list is
- * "locked" to preserve ordering, so
- * we can only insert after the insert
- * point.
- */
- bq = bufq->insert_point;
- } else {
-
- /*
- * If we lie before the last removed (currently active)
- * request, and are not inserting ourselves into the
- * "locked" portion of the list, then we must add ourselves
- * to the second request list.
- */
- if (bp->b_pblkno < bufq->last_pblkno) {
-
- bq = bufq->switch_point;
- /*
- * If we are starting a new secondary list,
- * then it's easy.
- */
- if (bq == NULL) {
- bufq->switch_point = bp;
- bufq_insert_tail(bufq, bp);
- return;
- }
- /*
- * If we lie ahead of the current switch point,
- * insert us before the switch point and move
- * the switch point.
- */
- if (bp->b_pblkno < bq->b_pblkno) {
- bufq->switch_point = bp;
- TAILQ_INSERT_BEFORE(bq, bp, b_act);
- return;
- }
- } else {
- if (bufq->switch_point != NULL)
- be = TAILQ_PREV(bufq->switch_point,
- buf_queue, b_act);
- /*
- * If we lie between last_pblkno and bq,
- * insert before bq.
- */
- if (bp->b_pblkno < bq->b_pblkno) {
- TAILQ_INSERT_BEFORE(bq, bp, b_act);
- return;
- }
- }
- }
-
- /*
- * Request is at/after our current position in the list.
- * Optimize for sequential I/O by seeing if we go at the tail.
- */
- if (bp->b_pblkno > be->b_pblkno) {
- TAILQ_INSERT_AFTER(&bufq->queue, be, bp, b_act);
- return;
- }
-
- /* Otherwise, insertion sort */
- while ((bn = TAILQ_NEXT(bq, b_act)) != NULL) {
-
- /*
- * We want to go after the current request if it is the end
- * of the first request list, or if the next request is a
- * larger cylinder than our request.
- */
- if (bn == bufq->switch_point
- || bp->b_pblkno < bn->b_pblkno)
- break;
- bq = bn;
- }
- TAILQ_INSERT_AFTER(&bufq->queue, bq, bp, b_act);
-}
-
-
-/*
- * 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 in the strategy routine (e.g., dummy bounds for the
- * partition containing the label) must be filled in before calling us.
- * Returns NULL on success and an error string on failure.
- */
-char *
-readdisklabel(dev, lp)
- dev_t dev;
- register struct disklabel *lp;
-{
- register struct buf *bp;
- struct disklabel *dlp;
- char *msg = NULL;
-
- bp = geteblk((int)lp->d_secsize);
- bp->b_dev = dev;
- bp->b_blkno = LABELSECTOR * ((int)lp->d_secsize/DEV_BSIZE);
- bp->b_bcount = lp->d_secsize;
- bp->b_flags &= ~B_INVAL;
- bp->b_flags |= B_READ;
- BUF_STRATEGY(bp, 1);
- if (biowait(bp))
- msg = "I/O error";
- else for (dlp = (struct disklabel *)bp->b_data;
- dlp <= (struct disklabel *)((char *)bp->b_data +
- lp->d_secsize - sizeof(*dlp));
- dlp = (struct disklabel *)((char *)dlp + sizeof(long))) {
- if (dlp->d_magic != DISKMAGIC || dlp->d_magic2 != DISKMAGIC) {
- if (msg == NULL)
- msg = "no disk label";
- } else if (dlp->d_npartitions > MAXPARTITIONS ||
- dkcksum(dlp) != 0)
- msg = "disk label corrupted";
- else {
- *lp = *dlp;
- msg = NULL;
- break;
- }
- }
- bp->b_flags |= B_INVAL | B_AGE;
- brelse(bp);
- return (msg);
-}
-
-/*
- * Check new disk label for sensibility before setting it.
- */
-int
-setdisklabel(olp, nlp, openmask)
- register struct disklabel *olp, *nlp;
- u_long openmask;
-{
- register int i;
- register struct partition *opp, *npp;
-
- /*
- * Check it is actually a disklabel we are looking at.
- */
- if (nlp->d_magic != DISKMAGIC || nlp->d_magic2 != DISKMAGIC ||
- dkcksum(nlp) != 0)
- return (EINVAL);
- /*
- * For each partition that we think is open,
- */
- while ((i = ffs((long)openmask)) != 0) {
- i--;
- /*
- * Check it is not changing....
- */
- openmask &= ~(1 << i);
- if (nlp->d_npartitions <= i)
- return (EBUSY);
- opp = &olp->d_partitions[i];
- npp = &nlp->d_partitions[i];
- if (npp->p_offset != opp->p_offset || npp->p_size < opp->p_size)
- return (EBUSY);
- /*
- * Copy internally-set partition information
- * if new label doesn't include it. XXX
- * (If we are using it then we had better stay the same type)
- * This is possibly dubious, as someone else noted (XXX)
- */
- if (npp->p_fstype == FS_UNUSED && opp->p_fstype != FS_UNUSED) {
- npp->p_fstype = opp->p_fstype;
- npp->p_fsize = opp->p_fsize;
- npp->p_frag = opp->p_frag;
- npp->p_cpg = opp->p_cpg;
- }
- }
- nlp->d_checksum = 0;
- nlp->d_checksum = dkcksum(nlp);
- *olp = *nlp;
- return (0);
-}
-
-/*
- * Write disk label back to device after modification.
- */
-int
-writedisklabel(dev, lp)
- dev_t dev;
- register struct disklabel *lp;
-{
- struct buf *bp;
- struct disklabel *dlp;
- int error = 0;
-
- if (lp->d_partitions[RAW_PART].p_offset != 0)
- return (EXDEV); /* not quite right */
- bp = geteblk((int)lp->d_secsize);
- bp->b_dev = dkmodpart(dev, RAW_PART);
- bp->b_blkno = LABELSECTOR * ((int)lp->d_secsize/DEV_BSIZE);
- bp->b_bcount = lp->d_secsize;
-#if 1
- /*
- * We read the label first to see if it's there,
- * in which case we will put ours at the same offset into the block..
- * (I think this is stupid [Julian])
- * Note that you can't write a label out over a corrupted label!
- * (also stupid.. how do you write the first one? by raw writes?)
- */
- bp->b_flags &= ~B_INVAL;
- bp->b_flags |= B_READ;
- BUF_STRATEGY(bp, 1);
- error = biowait(bp);
- if (error)
- goto done;
- for (dlp = (struct disklabel *)bp->b_data;
- dlp <= (struct disklabel *)
- ((char *)bp->b_data + lp->d_secsize - sizeof(*dlp));
- dlp = (struct disklabel *)((char *)dlp + sizeof(long))) {
- if (dlp->d_magic == DISKMAGIC && dlp->d_magic2 == DISKMAGIC &&
- dkcksum(dlp) == 0) {
- *dlp = *lp;
- bp->b_flags &= ~(B_DONE | B_READ);
- bp->b_flags |= B_WRITE;
-#ifdef __alpha__
- alpha_fix_srm_checksum(bp);
-#endif
- BUF_STRATEGY(bp, 1);
- error = biowait(bp);
- goto done;
- }
- }
- error = ESRCH;
-done:
-#else
- bzero(bp->b_data, lp->d_secsize);
- dlp = (struct disklabel *)bp->b_data;
- *dlp = *lp;
- bp->b_flags &= ~B_INVAL;
- bp->b_flags |= B_WRITE;
- BUF_STRATEGY(bp, 1);
- error = biowait(bp);
-#endif
- bp->b_flags |= B_INVAL | B_AGE;
- brelse(bp);
- return (error);
-}
-
-/*
- * Compute checksum for disk label.
- */
-u_int
-dkcksum(lp)
- register struct disklabel *lp;
-{
- register u_short *start, *end;
- register u_short sum = 0;
-
- start = (u_short *)lp;
- end = (u_short *)&lp->d_partitions[lp->d_npartitions];
- while (start < end)
- sum ^= *start++;
- return (sum);
-}
-
-/*
- * Disk error is the preface to plaintive error messages
- * about failing disk transfers. It prints messages of the form
-
-hp0g: hard error reading fsbn 12345 of 12344-12347 (hp0 bn %d cn %d tn %d sn %d)
-
- * if the offset of the error in the transfer and a disk label
- * are both available. blkdone should be -1 if the position of the error
- * is unknown; the disklabel pointer may be null from drivers that have not
- * been converted to use them. The message is printed with printf
- * if pri is LOG_PRINTF, otherwise it uses log at the specified priority.
- * The message should be completed (with at least a newline) with printf
- * or addlog, respectively. There is no trailing space.
- */
-void
-diskerr(bp, what, pri, blkdone, lp)
- register struct buf *bp;
- char *what;
- int pri, blkdone;
- register struct disklabel *lp;
-{
- int unit = dkunit(bp->b_dev);
- int slice = dkslice(bp->b_dev);
- int part = dkpart(bp->b_dev);
- register int (*pr) __P((const char *, ...));
- char partname[2];
- char *sname;
- daddr_t sn;
-
- if (pri != LOG_PRINTF) {
- log(pri, "%s", "");
- pr = addlog;
- } else
- pr = printf;
- sname = dsname(bp->b_dev, unit, slice, part, partname);
- (*pr)("%s%s: %s %sing fsbn ", sname, partname, what,
- bp->b_flags & B_READ ? "read" : "writ");
- sn = bp->b_blkno;
- if (bp->b_bcount <= DEV_BSIZE)
- (*pr)("%ld", (long)sn);
- else {
- if (blkdone >= 0) {
- sn += blkdone;
- (*pr)("%ld of ", (long)sn);
- }
- (*pr)("%ld-%ld", (long)bp->b_blkno,
- (long)(bp->b_blkno + (bp->b_bcount - 1) / DEV_BSIZE));
- }
- if (lp && (blkdone >= 0 || bp->b_bcount <= lp->d_secsize)) {
-#ifdef tahoe
- sn *= DEV_BSIZE / lp->d_secsize; /* XXX */
-#endif
- sn += lp->d_partitions[part].p_offset;
- /*
- * XXX should add slice offset and not print the slice,
- * but we don't know the slice pointer.
- * XXX should print bp->b_pblkno so that this will work
- * independent of slices, labels and bad sector remapping,
- * but some drivers don't set bp->b_pblkno.
- */
- (*pr)(" (%s bn %ld; cn %ld", sname, (long)sn,
- (long)(sn / lp->d_secpercyl));
- sn %= (long)lp->d_secpercyl;
- (*pr)(" tn %ld sn %ld)", (long)(sn / lp->d_nsectors),
- (long)(sn % lp->d_nsectors));
- }
-}
diff --git a/sys/kern/subr_param.c b/sys/kern/subr_param.c
deleted file mode 100644
index 7ae2ade9bdca..000000000000
--- a/sys/kern/subr_param.c
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Copyright (c) 1980, 1986, 1989, 1993
- * The Regents of the University of California. All rights reserved.
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)param.c 8.3 (Berkeley) 8/20/94
- * $FreeBSD$
- */
-
-#include <stddef.h>
-
-#include "opt_sysvipc.h"
-#include "opt_param.h"
-
-#include <sys/param.h>
-
-#ifdef SYSVSHM
-#include <machine/vmparam.h>
-#include <sys/shm.h>
-#endif
-#ifdef SYSVSEM
-#include <sys/sem.h>
-#endif
-#ifdef SYSVMSG
-#include <sys/msg.h>
-#endif
-
-/*
- * System parameter formulae.
- *
- * This file is copied into each directory where we compile
- * the kernel; it should be modified there to suit local taste
- * if necessary.
- *
- * Compiled with -DMAXUSERS=xx
- */
-
-#ifndef HZ
-#define HZ 100
-#endif
-int hz = HZ;
-int tick = 1000000 / HZ;
-int tickadj = howmany(30000, 60 * HZ); /* can adjust 30ms in 60s */
-#define NPROC (20 + 16 * MAXUSERS)
-#ifndef MAXFILES
-#define MAXFILES (NPROC*2)
-#endif
-int maxproc = NPROC; /* maximum # of processes */
-int maxprocperuid = NPROC-1; /* maximum # of processes per user */
-int maxfiles = MAXFILES; /* system wide open files limit */
-int maxfilesperproc = MAXFILES; /* per-process open files limit */
-int ncallout = 16 + NPROC + MAXFILES; /* maximum # of timer events */
-int mbuf_wait = 32; /* mbuf sleep time in ticks */
-
-/* maximum # of sf_bufs (sendfile(2) zero-copy virtual buffers) */
-#ifndef NSFBUFS
-#define NSFBUFS (512 + MAXUSERS * 16)
-#endif
-int nsfbufs = NSFBUFS;
-
-/*
- * Values in support of System V compatible shared memory. XXX
- */
-#ifdef SYSVSHM
-#ifndef SHMMAX
-#define SHMMAX (SHMMAXPGS*PAGE_SIZE)
-#endif
-#ifndef SHMMIN
-#define SHMMIN 1
-#endif
-#ifndef SHMMNI
-#define SHMMNI 32 /* <= SHMMMNI in shm.h */
-#endif
-#ifndef SHMSEG
-#define SHMSEG 8
-#endif
-#ifndef SHMALL
-#define SHMALL (SHMMAXPGS)
-#endif
-
-struct shminfo shminfo = {
- SHMMAX,
- SHMMIN,
- SHMMNI,
- SHMSEG,
- SHMALL
-};
-#endif
-
-/*
- * Values in support of System V compatible semaphores.
- */
-
-#ifdef SYSVSEM
-
-struct seminfo seminfo = {
- SEMMAP, /* # of entries in semaphore map */
- SEMMNI, /* # of semaphore identifiers */
- SEMMNS, /* # of semaphores in system */
- SEMMNU, /* # of undo structures in system */
- SEMMSL, /* max # of semaphores per id */
- SEMOPM, /* max # of operations per semop call */
- SEMUME, /* max # of undo entries per process */
- SEMUSZ, /* size in bytes of undo structure */
- SEMVMX, /* semaphore maximum value */
- SEMAEM /* adjust on exit max value */
-};
-#endif
-
-/*
- * Values in support of System V compatible messages.
- */
-
-#ifdef SYSVMSG
-
-struct msginfo msginfo = {
- MSGMAX, /* max chars in a message */
- MSGMNI, /* # of message queue identifiers */
- MSGMNB, /* max chars in a queue */
- MSGTQL, /* max messages in system */
- MSGSSZ, /* size of a message segment */
- /* (must be small power of 2 greater than 4) */
- MSGSEG /* number of message segments */
-};
-#endif
-
-/*
- * These may be set to nonzero here or by patching.
- * If they are nonzero at bootstrap time then they are
- * initialized to values dependent on the memory size.
- */
-#ifdef NBUF
-int nbuf = NBUF;
-#else
-int nbuf = 0;
-#endif
-int nswbuf = 0;
-
-/*
- * These have to be allocated somewhere; allocating
- * them here forces loader errors if this file is omitted
- * (if they've been externed everywhere else; hah!).
- */
-struct buf *swbuf;
diff --git a/sys/kern/subr_smp.c b/sys/kern/subr_smp.c
deleted file mode 100644
index 8e349a9800e4..000000000000
--- a/sys/kern/subr_smp.c
+++ /dev/null
@@ -1,2739 +0,0 @@
-/*
- * Copyright (c) 1996, by Steve Passe
- * 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 developer 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include "opt_smp.h"
-#include "opt_cpu.h"
-#include "opt_user_ldt.h"
-
-#ifdef SMP
-#include <machine/smptests.h>
-#else
-#error
-#endif
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/proc.h>
-#include <sys/sysctl.h>
-#include <sys/malloc.h>
-#include <sys/memrange.h>
-#ifdef BETTER_CLOCK
-#include <sys/dkstat.h>
-#endif
-#include <sys/cons.h> /* cngetc() */
-
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <vm/pmap.h>
-#include <vm/vm_kern.h>
-#include <vm/vm_extern.h>
-#ifdef BETTER_CLOCK
-#include <sys/lock.h>
-#include <vm/vm_map.h>
-#include <sys/user.h>
-#ifdef GPROF
-#include <sys/gmon.h>
-#endif
-#endif
-
-#include <machine/smp.h>
-#include <machine/apic.h>
-#include <machine/atomic.h>
-#include <machine/cpufunc.h>
-#include <machine/mpapic.h>
-#include <machine/psl.h>
-#include <machine/segments.h>
-#include <machine/smptests.h> /** TEST_DEFAULT_CONFIG, TEST_TEST1 */
-#include <machine/tss.h>
-#include <machine/specialreg.h>
-#include <machine/globaldata.h>
-
-#if defined(APIC_IO)
-#include <machine/md_var.h> /* setidt() */
-#include <i386/isa/icu.h> /* IPIs */
-#include <i386/isa/intr_machdep.h> /* IPIs */
-#endif /* APIC_IO */
-
-#if defined(TEST_DEFAULT_CONFIG)
-#define MPFPS_MPFB1 TEST_DEFAULT_CONFIG
-#else
-#define MPFPS_MPFB1 mpfps->mpfb1
-#endif /* TEST_DEFAULT_CONFIG */
-
-#define WARMBOOT_TARGET 0
-#define WARMBOOT_OFF (KERNBASE + 0x0467)
-#define WARMBOOT_SEG (KERNBASE + 0x0469)
-
-#ifdef PC98
-#define BIOS_BASE (0xe8000)
-#define BIOS_SIZE (0x18000)
-#else
-#define BIOS_BASE (0xf0000)
-#define BIOS_SIZE (0x10000)
-#endif
-#define BIOS_COUNT (BIOS_SIZE/4)
-
-#define CMOS_REG (0x70)
-#define CMOS_DATA (0x71)
-#define BIOS_RESET (0x0f)
-#define BIOS_WARM (0x0a)
-
-#define PROCENTRY_FLAG_EN 0x01
-#define PROCENTRY_FLAG_BP 0x02
-#define IOAPICENTRY_FLAG_EN 0x01
-
-
-/* MP Floating Pointer Structure */
-typedef struct MPFPS {
- char signature[4];
- void *pap;
- u_char length;
- u_char spec_rev;
- u_char checksum;
- u_char mpfb1;
- u_char mpfb2;
- u_char mpfb3;
- u_char mpfb4;
- u_char mpfb5;
-} *mpfps_t;
-
-/* MP Configuration Table Header */
-typedef struct MPCTH {
- char signature[4];
- u_short base_table_length;
- u_char spec_rev;
- u_char checksum;
- u_char oem_id[8];
- u_char product_id[12];
- void *oem_table_pointer;
- u_short oem_table_size;
- u_short entry_count;
- void *apic_address;
- u_short extended_table_length;
- u_char extended_table_checksum;
- u_char reserved;
-} *mpcth_t;
-
-
-typedef struct PROCENTRY {
- u_char type;
- u_char apic_id;
- u_char apic_version;
- u_char cpu_flags;
- u_long cpu_signature;
- u_long feature_flags;
- u_long reserved1;
- u_long reserved2;
-} *proc_entry_ptr;
-
-typedef struct BUSENTRY {
- u_char type;
- u_char bus_id;
- char bus_type[6];
-} *bus_entry_ptr;
-
-typedef struct IOAPICENTRY {
- u_char type;
- u_char apic_id;
- u_char apic_version;
- u_char apic_flags;
- void *apic_address;
-} *io_apic_entry_ptr;
-
-typedef struct INTENTRY {
- u_char type;
- u_char int_type;
- u_short int_flags;
- u_char src_bus_id;
- u_char src_bus_irq;
- u_char dst_apic_id;
- u_char dst_apic_int;
-} *int_entry_ptr;
-
-/* descriptions of MP basetable entries */
-typedef struct BASETABLE_ENTRY {
- u_char type;
- u_char length;
- char name[16];
-} basetable_entry;
-
-/*
- * this code MUST be enabled here and in mpboot.s.
- * it follows the very early stages of AP boot by placing values in CMOS ram.
- * it NORMALLY will never be needed and thus the primitive method for enabling.
- *
-#define CHECK_POINTS
- */
-
-#if defined(CHECK_POINTS) && !defined(PC98)
-#define CHECK_READ(A) (outb(CMOS_REG, (A)), inb(CMOS_DATA))
-#define CHECK_WRITE(A,D) (outb(CMOS_REG, (A)), outb(CMOS_DATA, (D)))
-
-#define CHECK_INIT(D); \
- CHECK_WRITE(0x34, (D)); \
- CHECK_WRITE(0x35, (D)); \
- CHECK_WRITE(0x36, (D)); \
- CHECK_WRITE(0x37, (D)); \
- CHECK_WRITE(0x38, (D)); \
- CHECK_WRITE(0x39, (D));
-
-#define CHECK_PRINT(S); \
- printf("%s: %d, %d, %d, %d, %d, %d\n", \
- (S), \
- CHECK_READ(0x34), \
- CHECK_READ(0x35), \
- CHECK_READ(0x36), \
- CHECK_READ(0x37), \
- CHECK_READ(0x38), \
- CHECK_READ(0x39));
-
-#else /* CHECK_POINTS */
-
-#define CHECK_INIT(D)
-#define CHECK_PRINT(S)
-
-#endif /* CHECK_POINTS */
-
-/*
- * Values to send to the POST hardware.
- */
-#define MP_BOOTADDRESS_POST 0x10
-#define MP_PROBE_POST 0x11
-#define MPTABLE_PASS1_POST 0x12
-
-#define MP_START_POST 0x13
-#define MP_ENABLE_POST 0x14
-#define MPTABLE_PASS2_POST 0x15
-
-#define START_ALL_APS_POST 0x16
-#define INSTALL_AP_TRAMP_POST 0x17
-#define START_AP_POST 0x18
-
-#define MP_ANNOUNCE_POST 0x19
-
-
-/** XXX FIXME: where does this really belong, isa.h/isa.c perhaps? */
-int current_postcode;
-
-/** XXX FIXME: what system files declare these??? */
-extern struct region_descriptor r_gdt, r_idt;
-
-int bsp_apic_ready = 0; /* flags useability of BSP apic */
-int mp_ncpus; /* # of CPUs, including BSP */
-int mp_naps; /* # of Applications processors */
-int mp_nbusses; /* # of busses */
-int mp_napics; /* # of IO APICs */
-int boot_cpu_id; /* designated BSP */
-vm_offset_t cpu_apic_address;
-vm_offset_t io_apic_address[NAPICID]; /* NAPICID is more than enough */
-extern int nkpt;
-
-u_int32_t cpu_apic_versions[NCPU];
-u_int32_t io_apic_versions[NAPIC];
-
-#ifdef APIC_INTR_DIAGNOSTIC
-int apic_itrace_enter[32];
-int apic_itrace_tryisrlock[32];
-int apic_itrace_gotisrlock[32];
-int apic_itrace_active[32];
-int apic_itrace_masked[32];
-int apic_itrace_noisrlock[32];
-int apic_itrace_masked2[32];
-int apic_itrace_unmask[32];
-int apic_itrace_noforward[32];
-int apic_itrace_leave[32];
-int apic_itrace_enter2[32];
-int apic_itrace_doreti[32];
-int apic_itrace_splz[32];
-int apic_itrace_eoi[32];
-#ifdef APIC_INTR_DIAGNOSTIC_IRQ
-unsigned short apic_itrace_debugbuffer[32768];
-int apic_itrace_debugbuffer_idx;
-struct simplelock apic_itrace_debuglock;
-#endif
-#endif
-
-#ifdef APIC_INTR_REORDER
-struct {
- volatile int *location;
- int bit;
-} apic_isrbit_location[32];
-#endif
-
-struct apic_intmapinfo int_to_apicintpin[APIC_INTMAPSIZE];
-
-/*
- * APIC ID logical/physical mapping structures.
- * We oversize these to simplify boot-time config.
- */
-int cpu_num_to_apic_id[NAPICID];
-int io_num_to_apic_id[NAPICID];
-int apic_id_to_logical[NAPICID];
-
-
-/* Bitmap of all available CPUs */
-u_int all_cpus;
-
-/* AP uses this during bootstrap. Do not staticize. */
-char *bootSTK;
-static int bootAP;
-
-/* Hotwire a 0->4MB V==P mapping */
-extern pt_entry_t *KPTphys;
-
-/* SMP page table page */
-extern pt_entry_t *SMPpt;
-
-struct pcb stoppcbs[NCPU];
-
-int smp_started; /* has the system started? */
-
-/*
- * Local data and functions.
- */
-
-static int mp_capable;
-static u_int boot_address;
-static u_int base_memory;
-
-static int picmode; /* 0: virtual wire mode, 1: PIC mode */
-static mpfps_t mpfps;
-static int search_for_sig(u_int32_t target, int count);
-static void mp_enable(u_int boot_addr);
-
-static int mptable_pass1(void);
-static int mptable_pass2(void);
-static void default_mp_table(int type);
-static void fix_mp_table(void);
-static void setup_apic_irq_mapping(void);
-static void init_locks(void);
-static int start_all_aps(u_int boot_addr);
-static void install_ap_tramp(u_int boot_addr);
-static int start_ap(int logicalCpu, u_int boot_addr);
-static int apic_int_is_bus_type(int intr, int bus_type);
-
-/*
- * Calculate usable address in base memory for AP trampoline code.
- */
-u_int
-mp_bootaddress(u_int basemem)
-{
- POSTCODE(MP_BOOTADDRESS_POST);
-
- base_memory = basemem * 1024; /* convert to bytes */
-
- boot_address = base_memory & ~0xfff; /* round down to 4k boundary */
- if ((base_memory - boot_address) < bootMP_size)
- boot_address -= 4096; /* not enough, lower by 4k */
-
- return boot_address;
-}
-
-
-/*
- * Look for an Intel MP spec table (ie, SMP capable hardware).
- */
-int
-mp_probe(void)
-{
- int x;
- u_long segment;
- u_int32_t target;
-
- POSTCODE(MP_PROBE_POST);
-
- /* see if EBDA exists */
- if ((segment = (u_long) * (u_short *) (KERNBASE + 0x40e)) != 0) {
- /* search first 1K of EBDA */
- target = (u_int32_t) (segment << 4);
- if ((x = search_for_sig(target, 1024 / 4)) >= 0)
- goto found;
- } else {
- /* last 1K of base memory, effective 'top of base' passed in */
- target = (u_int32_t) (base_memory - 0x400);
- if ((x = search_for_sig(target, 1024 / 4)) >= 0)
- goto found;
- }
-
- /* search the BIOS */
- target = (u_int32_t) BIOS_BASE;
- if ((x = search_for_sig(target, BIOS_COUNT)) >= 0)
- goto found;
-
- /* nothing found */
- mpfps = (mpfps_t)0;
- mp_capable = 0;
- return 0;
-
-found:
- /* calculate needed resources */
- mpfps = (mpfps_t)x;
- if (mptable_pass1())
- panic("you must reconfigure your kernel");
-
- /* flag fact that we are running multiple processors */
- mp_capable = 1;
- return 1;
-}
-
-
-/*
- * Startup the SMP processors.
- */
-void
-mp_start(void)
-{
- POSTCODE(MP_START_POST);
-
- /* look for MP capable motherboard */
- if (mp_capable)
- mp_enable(boot_address);
- else
- panic("MP hardware not found!");
-}
-
-
-/*
- * Print various information about the SMP system hardware and setup.
- */
-void
-mp_announce(void)
-{
- int x;
-
- POSTCODE(MP_ANNOUNCE_POST);
-
- printf("FreeBSD/SMP: Multiprocessor motherboard\n");
- printf(" cpu0 (BSP): apic id: %2d", CPU_TO_ID(0));
- printf(", version: 0x%08x", cpu_apic_versions[0]);
- printf(", at 0x%08x\n", cpu_apic_address);
- for (x = 1; x <= mp_naps; ++x) {
- printf(" cpu%d (AP): apic id: %2d", x, CPU_TO_ID(x));
- printf(", version: 0x%08x", cpu_apic_versions[x]);
- printf(", at 0x%08x\n", cpu_apic_address);
- }
-
-#if defined(APIC_IO)
- for (x = 0; x < mp_napics; ++x) {
- printf(" io%d (APIC): apic id: %2d", x, IO_TO_ID(x));
- printf(", version: 0x%08x", io_apic_versions[x]);
- printf(", at 0x%08x\n", io_apic_address[x]);
- }
-#else
- printf(" Warning: APIC I/O disabled\n");
-#endif /* APIC_IO */
-}
-
-/*
- * AP cpu's call this to sync up protected mode.
- */
-void
-init_secondary(void)
-{
- int gsel_tss;
- int x, myid = bootAP;
-
- gdt_segs[GPRIV_SEL].ssd_base = (int) &SMP_prvspace[myid];
- gdt_segs[GPROC0_SEL].ssd_base =
- (int) &SMP_prvspace[myid].globaldata.gd_common_tss;
- SMP_prvspace[myid].globaldata.gd_prvspace = &SMP_prvspace[myid];
-
- for (x = 0; x < NGDT; x++) {
- ssdtosd(&gdt_segs[x], &gdt[myid * NGDT + x].sd);
- }
-
- r_gdt.rd_limit = NGDT * sizeof(gdt[0]) - 1;
- r_gdt.rd_base = (int) &gdt[myid * NGDT];
- lgdt(&r_gdt); /* does magic intra-segment return */
-
- lidt(&r_idt);
-
- lldt(_default_ldt);
-#ifdef USER_LDT
- currentldt = _default_ldt;
-#endif
-
- gsel_tss = GSEL(GPROC0_SEL, SEL_KPL);
- gdt[myid * NGDT + GPROC0_SEL].sd.sd_type = SDT_SYS386TSS;
- common_tss.tss_esp0 = 0; /* not used until after switch */
- common_tss.tss_ss0 = GSEL(GDATA_SEL, SEL_KPL);
- common_tss.tss_ioopt = (sizeof common_tss) << 16;
- tss_gdt = &gdt[myid * NGDT + GPROC0_SEL].sd;
- common_tssd = *tss_gdt;
- ltr(gsel_tss);
-
- load_cr0(0x8005003b); /* XXX! */
-
- pmap_set_opt();
-}
-
-
-#if defined(APIC_IO)
-/*
- * Final configuration of the BSP's local APIC:
- * - disable 'pic mode'.
- * - disable 'virtual wire mode'.
- * - enable NMI.
- */
-void
-bsp_apic_configure(void)
-{
- u_char byte;
- u_int32_t temp;
-
- /* leave 'pic mode' if necessary */
- if (picmode) {
- outb(0x22, 0x70); /* select IMCR */
- byte = inb(0x23); /* current contents */
- byte |= 0x01; /* mask external INTR */
- outb(0x23, byte); /* disconnect 8259s/NMI */
- }
-
- /* mask lint0 (the 8259 'virtual wire' connection) */
- temp = lapic.lvt_lint0;
- temp |= APIC_LVT_M; /* set the mask */
- lapic.lvt_lint0 = temp;
-
- /* setup lint1 to handle NMI */
- temp = lapic.lvt_lint1;
- temp &= ~APIC_LVT_M; /* clear the mask */
- lapic.lvt_lint1 = temp;
-
- if (bootverbose)
- apic_dump("bsp_apic_configure()");
-}
-#endif /* APIC_IO */
-
-
-/*******************************************************************
- * local functions and data
- */
-
-/*
- * start the SMP system
- */
-static void
-mp_enable(u_int boot_addr)
-{
- int x;
-#if defined(APIC_IO)
- int apic;
- u_int ux;
-#endif /* APIC_IO */
-
- POSTCODE(MP_ENABLE_POST);
-
- /* turn on 4MB of V == P addressing so we can get to MP table */
- *(int *)PTD = PG_V | PG_RW | ((uintptr_t)(void *)KPTphys & PG_FRAME);
- invltlb();
-
- /* examine the MP table for needed info, uses physical addresses */
- x = mptable_pass2();
-
- *(int *)PTD = 0;
- invltlb();
-
- /* can't process default configs till the CPU APIC is pmapped */
- if (x)
- default_mp_table(x);
-
- /* post scan cleanup */
- fix_mp_table();
- setup_apic_irq_mapping();
-
-#if defined(APIC_IO)
-
- /* fill the LOGICAL io_apic_versions table */
- for (apic = 0; apic < mp_napics; ++apic) {
- ux = io_apic_read(apic, IOAPIC_VER);
- io_apic_versions[apic] = ux;
- }
-
- /* program each IO APIC in the system */
- for (apic = 0; apic < mp_napics; ++apic)
- if (io_apic_setup(apic) < 0)
- panic("IO APIC setup failure");
-
- /* install a 'Spurious INTerrupt' vector */
- setidt(XSPURIOUSINT_OFFSET, Xspuriousint,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-
- /* install an inter-CPU IPI for TLB invalidation */
- setidt(XINVLTLB_OFFSET, Xinvltlb,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-
-#ifdef BETTER_CLOCK
- /* install an inter-CPU IPI for reading processor state */
- setidt(XCPUCHECKSTATE_OFFSET, Xcpucheckstate,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-#endif
-
- /* install an inter-CPU IPI for all-CPU rendezvous */
- setidt(XRENDEZVOUS_OFFSET, Xrendezvous,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-
- /* install an inter-CPU IPI for forcing an additional software trap */
- setidt(XCPUAST_OFFSET, Xcpuast,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-
- /* install an inter-CPU IPI for interrupt forwarding */
- setidt(XFORWARD_IRQ_OFFSET, Xforward_irq,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-
- /* install an inter-CPU IPI for CPU stop/restart */
- setidt(XCPUSTOP_OFFSET, Xcpustop,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-
-#if defined(TEST_TEST1)
- /* install a "fake hardware INTerrupt" vector */
- setidt(XTEST1_OFFSET, Xtest1,
- SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
-#endif /** TEST_TEST1 */
-
-#endif /* APIC_IO */
-
- /* initialize all SMP locks */
- init_locks();
-
- /* start each Application Processor */
- start_all_aps(boot_addr);
-
- /*
- * The init process might be started on a different CPU now,
- * and the boot CPU might not call prepare_usermode to get
- * cr0 correctly configured. Thus we initialize cr0 here.
- */
- load_cr0(rcr0() | CR0_WP | CR0_AM);
-}
-
-
-/*
- * look for the MP spec signature
- */
-
-/* string defined by the Intel MP Spec as identifying the MP table */
-#define MP_SIG 0x5f504d5f /* _MP_ */
-#define NEXT(X) ((X) += 4)
-static int
-search_for_sig(u_int32_t target, int count)
-{
- int x;
- u_int32_t *addr = (u_int32_t *) (KERNBASE + target);
-
- for (x = 0; x < count; NEXT(x))
- if (addr[x] == MP_SIG)
- /* make array index a byte index */
- return (target + (x * sizeof(u_int32_t)));
-
- return -1;
-}
-
-
-static basetable_entry basetable_entry_types[] =
-{
- {0, 20, "Processor"},
- {1, 8, "Bus"},
- {2, 8, "I/O APIC"},
- {3, 8, "I/O INT"},
- {4, 8, "Local INT"}
-};
-
-typedef struct BUSDATA {
- u_char bus_id;
- enum busTypes bus_type;
-} bus_datum;
-
-typedef struct INTDATA {
- u_char int_type;
- u_short int_flags;
- u_char src_bus_id;
- u_char src_bus_irq;
- u_char dst_apic_id;
- u_char dst_apic_int;
- u_char int_vector;
-} io_int, local_int;
-
-typedef struct BUSTYPENAME {
- u_char type;
- char name[7];
-} bus_type_name;
-
-static bus_type_name bus_type_table[] =
-{
- {CBUS, "CBUS"},
- {CBUSII, "CBUSII"},
- {EISA, "EISA"},
- {MCA, "MCA"},
- {UNKNOWN_BUSTYPE, "---"},
- {ISA, "ISA"},
- {MCA, "MCA"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {PCI, "PCI"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {UNKNOWN_BUSTYPE, "---"},
- {XPRESS, "XPRESS"},
- {UNKNOWN_BUSTYPE, "---"}
-};
-/* from MP spec v1.4, table 5-1 */
-static int default_data[7][5] =
-{
-/* nbus, id0, type0, id1, type1 */
- {1, 0, ISA, 255, 255},
- {1, 0, EISA, 255, 255},
- {1, 0, EISA, 255, 255},
- {1, 0, MCA, 255, 255},
- {2, 0, ISA, 1, PCI},
- {2, 0, EISA, 1, PCI},
- {2, 0, MCA, 1, PCI}
-};
-
-
-/* the bus data */
-static bus_datum bus_data[NBUS];
-
-/* the IO INT data, one entry per possible APIC INTerrupt */
-static io_int io_apic_ints[NINTR];
-
-static int nintrs;
-
-static int processor_entry __P((proc_entry_ptr entry, int cpu));
-static int bus_entry __P((bus_entry_ptr entry, int bus));
-static int io_apic_entry __P((io_apic_entry_ptr entry, int apic));
-static int int_entry __P((int_entry_ptr entry, int intr));
-static int lookup_bus_type __P((char *name));
-
-
-/*
- * 1st pass on motherboard's Intel MP specification table.
- *
- * initializes:
- * mp_ncpus = 1
- *
- * determines:
- * cpu_apic_address (common to all CPUs)
- * io_apic_address[N]
- * mp_naps
- * mp_nbusses
- * mp_napics
- * nintrs
- */
-static int
-mptable_pass1(void)
-{
- int x;
- mpcth_t cth;
- int totalSize;
- void* position;
- int count;
- int type;
- int mustpanic;
-
- POSTCODE(MPTABLE_PASS1_POST);
-
- mustpanic = 0;
-
- /* clear various tables */
- for (x = 0; x < NAPICID; ++x) {
- io_apic_address[x] = ~0; /* IO APIC address table */
- }
-
- /* init everything to empty */
- mp_naps = 0;
- mp_nbusses = 0;
- mp_napics = 0;
- nintrs = 0;
-
- /* check for use of 'default' configuration */
- if (MPFPS_MPFB1 != 0) {
- /* use default addresses */
- cpu_apic_address = DEFAULT_APIC_BASE;
- io_apic_address[0] = DEFAULT_IO_APIC_BASE;
-
- /* fill in with defaults */
- mp_naps = 2; /* includes BSP */
- mp_nbusses = default_data[MPFPS_MPFB1 - 1][0];
-#if defined(APIC_IO)
- mp_napics = 1;
- nintrs = 16;
-#endif /* APIC_IO */
- }
- else {
- if ((cth = mpfps->pap) == 0)
- panic("MP Configuration Table Header MISSING!");
-
- cpu_apic_address = (vm_offset_t) cth->apic_address;
-
- /* walk the table, recording info of interest */
- totalSize = cth->base_table_length - sizeof(struct MPCTH);
- position = (u_char *) cth + sizeof(struct MPCTH);
- count = cth->entry_count;
-
- while (count--) {
- switch (type = *(u_char *) position) {
- case 0: /* processor_entry */
- if (((proc_entry_ptr)position)->cpu_flags
- & PROCENTRY_FLAG_EN)
- ++mp_naps;
- break;
- case 1: /* bus_entry */
- ++mp_nbusses;
- break;
- case 2: /* io_apic_entry */
- if (((io_apic_entry_ptr)position)->apic_flags
- & IOAPICENTRY_FLAG_EN)
- io_apic_address[mp_napics++] =
- (vm_offset_t)((io_apic_entry_ptr)
- position)->apic_address;
- break;
- case 3: /* int_entry */
- ++nintrs;
- break;
- case 4: /* int_entry */
- break;
- default:
- panic("mpfps Base Table HOSED!");
- /* NOTREACHED */
- }
-
- totalSize -= basetable_entry_types[type].length;
- (u_char*)position += basetable_entry_types[type].length;
- }
- }
-
- /* qualify the numbers */
- if (mp_naps > NCPU) {
- printf("Warning: only using %d of %d available CPUs!\n",
- NCPU, mp_naps);
- mp_naps = NCPU;
- }
- if (mp_nbusses > NBUS) {
- printf("found %d busses, increase NBUS\n", mp_nbusses);
- mustpanic = 1;
- }
- if (mp_napics > NAPIC) {
- printf("found %d apics, increase NAPIC\n", mp_napics);
- mustpanic = 1;
- }
- if (nintrs > NINTR) {
- printf("found %d intrs, increase NINTR\n", nintrs);
- mustpanic = 1;
- }
-
- /*
- * Count the BSP.
- * This is also used as a counter while starting the APs.
- */
- mp_ncpus = 1;
-
- --mp_naps; /* subtract the BSP */
-
- return mustpanic;
-}
-
-
-/*
- * 2nd pass on motherboard's Intel MP specification table.
- *
- * sets:
- * boot_cpu_id
- * ID_TO_IO(N), phy APIC ID to log CPU/IO table
- * CPU_TO_ID(N), logical CPU to APIC ID table
- * IO_TO_ID(N), logical IO to APIC ID table
- * bus_data[N]
- * io_apic_ints[N]
- */
-static int
-mptable_pass2(void)
-{
- int x;
- mpcth_t cth;
- int totalSize;
- void* position;
- int count;
- int type;
- int apic, bus, cpu, intr;
-
- POSTCODE(MPTABLE_PASS2_POST);
-
- /* clear various tables */
- for (x = 0; x < NAPICID; ++x) {
- ID_TO_IO(x) = -1; /* phy APIC ID to log CPU/IO table */
- CPU_TO_ID(x) = -1; /* logical CPU to APIC ID table */
- IO_TO_ID(x) = -1; /* logical IO to APIC ID table */
- }
-
- /* clear bus data table */
- for (x = 0; x < NBUS; ++x)
- bus_data[x].bus_id = 0xff;
-
- /* clear IO APIC INT table */
- for (x = 0; x < NINTR; ++x) {
- io_apic_ints[x].int_type = 0xff;
- io_apic_ints[x].int_vector = 0xff;
- }
-
- /* setup the cpu/apic mapping arrays */
- boot_cpu_id = -1;
-
- /* record whether PIC or virtual-wire mode */
- picmode = (mpfps->mpfb2 & 0x80) ? 1 : 0;
-
- /* check for use of 'default' configuration */
- if (MPFPS_MPFB1 != 0)
- return MPFPS_MPFB1; /* return default configuration type */
-
- if ((cth = mpfps->pap) == 0)
- panic("MP Configuration Table Header MISSING!");
-
- /* walk the table, recording info of interest */
- totalSize = cth->base_table_length - sizeof(struct MPCTH);
- position = (u_char *) cth + sizeof(struct MPCTH);
- count = cth->entry_count;
- apic = bus = intr = 0;
- cpu = 1; /* pre-count the BSP */
-
- while (count--) {
- switch (type = *(u_char *) position) {
- case 0:
- if (processor_entry(position, cpu))
- ++cpu;
- break;
- case 1:
- if (bus_entry(position, bus))
- ++bus;
- break;
- case 2:
- if (io_apic_entry(position, apic))
- ++apic;
- break;
- case 3:
- if (int_entry(position, intr))
- ++intr;
- break;
- case 4:
- /* int_entry(position); */
- break;
- default:
- panic("mpfps Base Table HOSED!");
- /* NOTREACHED */
- }
-
- totalSize -= basetable_entry_types[type].length;
- (u_char *) position += basetable_entry_types[type].length;
- }
-
- if (boot_cpu_id == -1)
- panic("NO BSP found!");
-
- /* report fact that its NOT a default configuration */
- return 0;
-}
-
-
-void
-assign_apic_irq(int apic, int intpin, int irq)
-{
- int x;
-
- if (int_to_apicintpin[irq].ioapic != -1)
- panic("assign_apic_irq: inconsistent table");
-
- int_to_apicintpin[irq].ioapic = apic;
- int_to_apicintpin[irq].int_pin = intpin;
- int_to_apicintpin[irq].apic_address = ioapic[apic];
- int_to_apicintpin[irq].redirindex = IOAPIC_REDTBL + 2 * intpin;
-
- for (x = 0; x < nintrs; x++) {
- if ((io_apic_ints[x].int_type == 0 ||
- io_apic_ints[x].int_type == 3) &&
- io_apic_ints[x].int_vector == 0xff &&
- io_apic_ints[x].dst_apic_id == IO_TO_ID(apic) &&
- io_apic_ints[x].dst_apic_int == intpin)
- io_apic_ints[x].int_vector = irq;
- }
-}
-
-void
-revoke_apic_irq(int irq)
-{
- int x;
- int oldapic;
- int oldintpin;
-
- if (int_to_apicintpin[irq].ioapic == -1)
- panic("assign_apic_irq: inconsistent table");
-
- oldapic = int_to_apicintpin[irq].ioapic;
- oldintpin = int_to_apicintpin[irq].int_pin;
-
- int_to_apicintpin[irq].ioapic = -1;
- int_to_apicintpin[irq].int_pin = 0;
- int_to_apicintpin[irq].apic_address = NULL;
- int_to_apicintpin[irq].redirindex = 0;
-
- for (x = 0; x < nintrs; x++) {
- if ((io_apic_ints[x].int_type == 0 ||
- io_apic_ints[x].int_type == 3) &&
- io_apic_ints[x].int_vector == 0xff &&
- io_apic_ints[x].dst_apic_id == IO_TO_ID(oldapic) &&
- io_apic_ints[x].dst_apic_int == oldintpin)
- io_apic_ints[x].int_vector = 0xff;
- }
-}
-
-/*
- * parse an Intel MP specification table
- */
-static void
-fix_mp_table(void)
-{
- int x;
- int id;
- int bus_0 = 0; /* Stop GCC warning */
- int bus_pci = 0; /* Stop GCC warning */
- int num_pci_bus;
-
- /*
- * Fix mis-numbering of the PCI bus and its INT entries if the BIOS
- * did it wrong. The MP spec says that when more than 1 PCI bus
- * exists the BIOS must begin with bus entries for the PCI bus and use
- * actual PCI bus numbering. This implies that when only 1 PCI bus
- * exists the BIOS can choose to ignore this ordering, and indeed many
- * MP motherboards do ignore it. This causes a problem when the PCI
- * sub-system makes requests of the MP sub-system based on PCI bus
- * numbers. So here we look for the situation and renumber the
- * busses and associated INTs in an effort to "make it right".
- */
-
- /* find bus 0, PCI bus, count the number of PCI busses */
- for (num_pci_bus = 0, x = 0; x < mp_nbusses; ++x) {
- if (bus_data[x].bus_id == 0) {
- bus_0 = x;
- }
- if (bus_data[x].bus_type == PCI) {
- ++num_pci_bus;
- bus_pci = x;
- }
- }
- /*
- * bus_0 == slot of bus with ID of 0
- * bus_pci == slot of last PCI bus encountered
- */
-
- /* check the 1 PCI bus case for sanity */
- if (num_pci_bus == 1) {
-
- /* if it is number 0 all is well */
- if (bus_data[bus_pci].bus_id == 0)
- return;
-
- /* mis-numbered, swap with whichever bus uses slot 0 */
-
- /* swap the bus entry types */
- bus_data[bus_pci].bus_type = bus_data[bus_0].bus_type;
- bus_data[bus_0].bus_type = PCI;
-
- /* swap each relavant INTerrupt entry */
- id = bus_data[bus_pci].bus_id;
- for (x = 0; x < nintrs; ++x) {
- if (io_apic_ints[x].src_bus_id == id) {
- io_apic_ints[x].src_bus_id = 0;
- }
- else if (io_apic_ints[x].src_bus_id == 0) {
- io_apic_ints[x].src_bus_id = id;
- }
- }
- }
-}
-
-
-/* Assign low level interrupt handlers */
-static void
-setup_apic_irq_mapping(void)
-{
- int x;
- int int_vector;
-
- /* Clear array */
- for (x = 0; x < APIC_INTMAPSIZE; x++) {
- int_to_apicintpin[x].ioapic = -1;
- int_to_apicintpin[x].int_pin = 0;
- int_to_apicintpin[x].apic_address = NULL;
- int_to_apicintpin[x].redirindex = 0;
- }
-
- /* First assign ISA/EISA interrupts */
- for (x = 0; x < nintrs; x++) {
- int_vector = io_apic_ints[x].src_bus_irq;
- if (int_vector < APIC_INTMAPSIZE &&
- io_apic_ints[x].int_vector == 0xff &&
- int_to_apicintpin[int_vector].ioapic == -1 &&
- (apic_int_is_bus_type(x, ISA) ||
- apic_int_is_bus_type(x, EISA)) &&
- io_apic_ints[x].int_type == 0) {
- assign_apic_irq(ID_TO_IO(io_apic_ints[x].dst_apic_id),
- io_apic_ints[x].dst_apic_int,
- int_vector);
- }
- }
-
- /* Assign interrupts on first 24 intpins on IOAPIC #0 */
- for (x = 0; x < nintrs; x++) {
- int_vector = io_apic_ints[x].dst_apic_int;
- if (int_vector < APIC_INTMAPSIZE &&
- io_apic_ints[x].dst_apic_id == IO_TO_ID(0) &&
- io_apic_ints[x].int_vector == 0xff &&
- int_to_apicintpin[int_vector].ioapic == -1 &&
- (io_apic_ints[x].int_type == 0 ||
- io_apic_ints[x].int_type == 3)) {
- assign_apic_irq(0,
- io_apic_ints[x].dst_apic_int,
- int_vector);
- }
- }
- /*
- * Assign interrupts for remaining intpins.
- * Skip IOAPIC #0 intpin 0 if the type is ExtInt, since this indicates
- * that an entry for ISA/EISA irq 0 exist, and a fallback to mixed mode
- * due to 8254 interrupts not being delivered can reuse that low level
- * interrupt handler.
- */
- int_vector = 0;
- while (int_vector < APIC_INTMAPSIZE &&
- int_to_apicintpin[int_vector].ioapic != -1)
- int_vector++;
- for (x = 0; x < nintrs && int_vector < APIC_INTMAPSIZE; x++) {
- if ((io_apic_ints[x].int_type == 0 ||
- (io_apic_ints[x].int_type == 3 &&
- (io_apic_ints[x].dst_apic_id != IO_TO_ID(0) ||
- io_apic_ints[x].dst_apic_int != 0))) &&
- io_apic_ints[x].int_vector == 0xff) {
- assign_apic_irq(ID_TO_IO(io_apic_ints[x].dst_apic_id),
- io_apic_ints[x].dst_apic_int,
- int_vector);
- int_vector++;
- while (int_vector < APIC_INTMAPSIZE &&
- int_to_apicintpin[int_vector].ioapic != -1)
- int_vector++;
- }
- }
-}
-
-
-static int
-processor_entry(proc_entry_ptr entry, int cpu)
-{
- /* check for usability */
- if (!(entry->cpu_flags & PROCENTRY_FLAG_EN))
- return 0;
-
- /* check for BSP flag */
- if (entry->cpu_flags & PROCENTRY_FLAG_BP) {
- boot_cpu_id = entry->apic_id;
- CPU_TO_ID(0) = entry->apic_id;
- ID_TO_CPU(entry->apic_id) = 0;
- return 0; /* its already been counted */
- }
-
- /* add another AP to list, if less than max number of CPUs */
- else if (cpu < NCPU) {
- CPU_TO_ID(cpu) = entry->apic_id;
- ID_TO_CPU(entry->apic_id) = cpu;
- return 1;
- }
-
- return 0;
-}
-
-
-static int
-bus_entry(bus_entry_ptr entry, int bus)
-{
- int x;
- char c, name[8];
-
- /* encode the name into an index */
- for (x = 0; x < 6; ++x) {
- if ((c = entry->bus_type[x]) == ' ')
- break;
- name[x] = c;
- }
- name[x] = '\0';
-
- if ((x = lookup_bus_type(name)) == UNKNOWN_BUSTYPE)
- panic("unknown bus type: '%s'", name);
-
- bus_data[bus].bus_id = entry->bus_id;
- bus_data[bus].bus_type = x;
-
- return 1;
-}
-
-
-static int
-io_apic_entry(io_apic_entry_ptr entry, int apic)
-{
- if (!(entry->apic_flags & IOAPICENTRY_FLAG_EN))
- return 0;
-
- IO_TO_ID(apic) = entry->apic_id;
- ID_TO_IO(entry->apic_id) = apic;
-
- return 1;
-}
-
-
-static int
-lookup_bus_type(char *name)
-{
- int x;
-
- for (x = 0; x < MAX_BUSTYPE; ++x)
- if (strcmp(bus_type_table[x].name, name) == 0)
- return bus_type_table[x].type;
-
- return UNKNOWN_BUSTYPE;
-}
-
-
-static int
-int_entry(int_entry_ptr entry, int intr)
-{
- int apic;
-
- io_apic_ints[intr].int_type = entry->int_type;
- io_apic_ints[intr].int_flags = entry->int_flags;
- io_apic_ints[intr].src_bus_id = entry->src_bus_id;
- io_apic_ints[intr].src_bus_irq = entry->src_bus_irq;
- if (entry->dst_apic_id == 255) {
- /* This signal goes to all IO APICS. Select an IO APIC
- with sufficient number of interrupt pins */
- for (apic = 0; apic < mp_napics; apic++)
- if (((io_apic_read(apic, IOAPIC_VER) &
- IOART_VER_MAXREDIR) >> MAXREDIRSHIFT) >=
- entry->dst_apic_int)
- break;
- if (apic < mp_napics)
- io_apic_ints[intr].dst_apic_id = IO_TO_ID(apic);
- else
- io_apic_ints[intr].dst_apic_id = entry->dst_apic_id;
- } else
- io_apic_ints[intr].dst_apic_id = entry->dst_apic_id;
- io_apic_ints[intr].dst_apic_int = entry->dst_apic_int;
-
- return 1;
-}
-
-
-static int
-apic_int_is_bus_type(int intr, int bus_type)
-{
- int bus;
-
- for (bus = 0; bus < mp_nbusses; ++bus)
- if ((bus_data[bus].bus_id == io_apic_ints[intr].src_bus_id)
- && ((int) bus_data[bus].bus_type == bus_type))
- return 1;
-
- return 0;
-}
-
-
-/*
- * Given a traditional ISA INT mask, return an APIC mask.
- */
-u_int
-isa_apic_mask(u_int isa_mask)
-{
- int isa_irq;
- int apic_pin;
-
-#if defined(SKIP_IRQ15_REDIRECT)
- if (isa_mask == (1 << 15)) {
- printf("skipping ISA IRQ15 redirect\n");
- return isa_mask;
- }
-#endif /* SKIP_IRQ15_REDIRECT */
-
- isa_irq = ffs(isa_mask); /* find its bit position */
- if (isa_irq == 0) /* doesn't exist */
- return 0;
- --isa_irq; /* make it zero based */
-
- apic_pin = isa_apic_irq(isa_irq); /* look for APIC connection */
- if (apic_pin == -1)
- return 0;
-
- return (1 << apic_pin); /* convert pin# to a mask */
-}
-
-
-/*
- * Determine which APIC pin an ISA/EISA INT is attached to.
- */
-#define INTTYPE(I) (io_apic_ints[(I)].int_type)
-#define INTPIN(I) (io_apic_ints[(I)].dst_apic_int)
-#define INTIRQ(I) (io_apic_ints[(I)].int_vector)
-#define INTAPIC(I) (ID_TO_IO(io_apic_ints[(I)].dst_apic_id))
-
-#define SRCBUSIRQ(I) (io_apic_ints[(I)].src_bus_irq)
-int
-isa_apic_irq(int isa_irq)
-{
- int intr;
-
- for (intr = 0; intr < nintrs; ++intr) { /* check each record */
- if (INTTYPE(intr) == 0) { /* standard INT */
- if (SRCBUSIRQ(intr) == isa_irq) {
- if (apic_int_is_bus_type(intr, ISA) ||
- apic_int_is_bus_type(intr, EISA))
- return INTIRQ(intr); /* found */
- }
- }
- }
- return -1; /* NOT found */
-}
-
-
-/*
- * Determine which APIC pin a PCI INT is attached to.
- */
-#define SRCBUSID(I) (io_apic_ints[(I)].src_bus_id)
-#define SRCBUSDEVICE(I) ((io_apic_ints[(I)].src_bus_irq >> 2) & 0x1f)
-#define SRCBUSLINE(I) (io_apic_ints[(I)].src_bus_irq & 0x03)
-int
-pci_apic_irq(int pciBus, int pciDevice, int pciInt)
-{
- int intr;
-
- --pciInt; /* zero based */
-
- for (intr = 0; intr < nintrs; ++intr) /* check each record */
- if ((INTTYPE(intr) == 0) /* standard INT */
- && (SRCBUSID(intr) == pciBus)
- && (SRCBUSDEVICE(intr) == pciDevice)
- && (SRCBUSLINE(intr) == pciInt)) /* a candidate IRQ */
- if (apic_int_is_bus_type(intr, PCI))
- return INTIRQ(intr); /* exact match */
-
- return -1; /* NOT found */
-}
-
-int
-next_apic_irq(int irq)
-{
- int intr, ointr;
- int bus, bustype;
-
- bus = 0;
- bustype = 0;
- for (intr = 0; intr < nintrs; intr++) {
- if (INTIRQ(intr) != irq || INTTYPE(intr) != 0)
- continue;
- bus = SRCBUSID(intr);
- bustype = apic_bus_type(bus);
- if (bustype != ISA &&
- bustype != EISA &&
- bustype != PCI)
- continue;
- break;
- }
- if (intr >= nintrs) {
- return -1;
- }
- for (ointr = intr + 1; ointr < nintrs; ointr++) {
- if (INTTYPE(ointr) != 0)
- continue;
- if (bus != SRCBUSID(ointr))
- continue;
- if (bustype == PCI) {
- if (SRCBUSDEVICE(intr) != SRCBUSDEVICE(ointr))
- continue;
- if (SRCBUSLINE(intr) != SRCBUSLINE(ointr))
- continue;
- }
- if (bustype == ISA || bustype == EISA) {
- if (SRCBUSIRQ(intr) != SRCBUSIRQ(ointr))
- continue;
- }
- if (INTPIN(intr) == INTPIN(ointr))
- continue;
- break;
- }
- if (ointr >= nintrs) {
- return -1;
- }
- return INTIRQ(ointr);
-}
-#undef SRCBUSLINE
-#undef SRCBUSDEVICE
-#undef SRCBUSID
-#undef SRCBUSIRQ
-
-#undef INTPIN
-#undef INTIRQ
-#undef INTAPIC
-#undef INTTYPE
-
-
-/*
- * Reprogram the MB chipset to NOT redirect an ISA INTerrupt.
- *
- * XXX FIXME:
- * Exactly what this means is unclear at this point. It is a solution
- * for motherboards that redirect the MBIRQ0 pin. Generically a motherboard
- * could route any of the ISA INTs to upper (>15) IRQ values. But most would
- * NOT be redirected via MBIRQ0, thus "undirect()ing" them would NOT be an
- * option.
- */
-int
-undirect_isa_irq(int rirq)
-{
-#if defined(READY)
- if (bootverbose)
- printf("Freeing redirected ISA irq %d.\n", rirq);
- /** FIXME: tickle the MB redirector chip */
- return ???;
-#else
- if (bootverbose)
- printf("Freeing (NOT implemented) redirected ISA irq %d.\n", rirq);
- return 0;
-#endif /* READY */
-}
-
-
-/*
- * Reprogram the MB chipset to NOT redirect a PCI INTerrupt
- */
-int
-undirect_pci_irq(int rirq)
-{
-#if defined(READY)
- if (bootverbose)
- printf("Freeing redirected PCI irq %d.\n", rirq);
-
- /** FIXME: tickle the MB redirector chip */
- return ???;
-#else
- if (bootverbose)
- printf("Freeing (NOT implemented) redirected PCI irq %d.\n",
- rirq);
- return 0;
-#endif /* READY */
-}
-
-
-/*
- * given a bus ID, return:
- * the bus type if found
- * -1 if NOT found
- */
-int
-apic_bus_type(int id)
-{
- int x;
-
- for (x = 0; x < mp_nbusses; ++x)
- if (bus_data[x].bus_id == id)
- return bus_data[x].bus_type;
-
- return -1;
-}
-
-
-/*
- * given a LOGICAL APIC# and pin#, return:
- * the associated src bus ID if found
- * -1 if NOT found
- */
-int
-apic_src_bus_id(int apic, int pin)
-{
- int x;
-
- /* search each of the possible INTerrupt sources */
- for (x = 0; x < nintrs; ++x)
- if ((apic == ID_TO_IO(io_apic_ints[x].dst_apic_id)) &&
- (pin == io_apic_ints[x].dst_apic_int))
- return (io_apic_ints[x].src_bus_id);
-
- return -1; /* NOT found */
-}
-
-
-/*
- * given a LOGICAL APIC# and pin#, return:
- * the associated src bus IRQ if found
- * -1 if NOT found
- */
-int
-apic_src_bus_irq(int apic, int pin)
-{
- int x;
-
- for (x = 0; x < nintrs; x++)
- if ((apic == ID_TO_IO(io_apic_ints[x].dst_apic_id)) &&
- (pin == io_apic_ints[x].dst_apic_int))
- return (io_apic_ints[x].src_bus_irq);
-
- return -1; /* NOT found */
-}
-
-
-/*
- * given a LOGICAL APIC# and pin#, return:
- * the associated INTerrupt type if found
- * -1 if NOT found
- */
-int
-apic_int_type(int apic, int pin)
-{
- int x;
-
- /* search each of the possible INTerrupt sources */
- for (x = 0; x < nintrs; ++x)
- if ((apic == ID_TO_IO(io_apic_ints[x].dst_apic_id)) &&
- (pin == io_apic_ints[x].dst_apic_int))
- return (io_apic_ints[x].int_type);
-
- return -1; /* NOT found */
-}
-
-int
-apic_irq(int apic, int pin)
-{
- int x;
- int res;
-
- for (x = 0; x < nintrs; ++x)
- if ((apic == ID_TO_IO(io_apic_ints[x].dst_apic_id)) &&
- (pin == io_apic_ints[x].dst_apic_int)) {
- res = io_apic_ints[x].int_vector;
- if (res == 0xff)
- return -1;
- if (apic != int_to_apicintpin[res].ioapic)
- panic("apic_irq: inconsistent table");
- if (pin != int_to_apicintpin[res].int_pin)
- panic("apic_irq inconsistent table (2)");
- return res;
- }
- return -1;
-}
-
-
-/*
- * given a LOGICAL APIC# and pin#, return:
- * the associated trigger mode if found
- * -1 if NOT found
- */
-int
-apic_trigger(int apic, int pin)
-{
- int x;
-
- /* search each of the possible INTerrupt sources */
- for (x = 0; x < nintrs; ++x)
- if ((apic == ID_TO_IO(io_apic_ints[x].dst_apic_id)) &&
- (pin == io_apic_ints[x].dst_apic_int))
- return ((io_apic_ints[x].int_flags >> 2) & 0x03);
-
- return -1; /* NOT found */
-}
-
-
-/*
- * given a LOGICAL APIC# and pin#, return:
- * the associated 'active' level if found
- * -1 if NOT found
- */
-int
-apic_polarity(int apic, int pin)
-{
- int x;
-
- /* search each of the possible INTerrupt sources */
- for (x = 0; x < nintrs; ++x)
- if ((apic == ID_TO_IO(io_apic_ints[x].dst_apic_id)) &&
- (pin == io_apic_ints[x].dst_apic_int))
- return (io_apic_ints[x].int_flags & 0x03);
-
- return -1; /* NOT found */
-}
-
-
-/*
- * set data according to MP defaults
- * FIXME: probably not complete yet...
- */
-static void
-default_mp_table(int type)
-{
- int ap_cpu_id;
-#if defined(APIC_IO)
- u_int32_t ux;
- int io_apic_id;
- int pin;
-#endif /* APIC_IO */
-
-#if 0
- printf(" MP default config type: %d\n", type);
- switch (type) {
- case 1:
- printf(" bus: ISA, APIC: 82489DX\n");
- break;
- case 2:
- printf(" bus: EISA, APIC: 82489DX\n");
- break;
- case 3:
- printf(" bus: EISA, APIC: 82489DX\n");
- break;
- case 4:
- printf(" bus: MCA, APIC: 82489DX\n");
- break;
- case 5:
- printf(" bus: ISA+PCI, APIC: Integrated\n");
- break;
- case 6:
- printf(" bus: EISA+PCI, APIC: Integrated\n");
- break;
- case 7:
- printf(" bus: MCA+PCI, APIC: Integrated\n");
- break;
- default:
- printf(" future type\n");
- break;
- /* NOTREACHED */
- }
-#endif /* 0 */
-
- boot_cpu_id = (lapic.id & APIC_ID_MASK) >> 24;
- ap_cpu_id = (boot_cpu_id == 0) ? 1 : 0;
-
- /* BSP */
- CPU_TO_ID(0) = boot_cpu_id;
- ID_TO_CPU(boot_cpu_id) = 0;
-
- /* one and only AP */
- CPU_TO_ID(1) = ap_cpu_id;
- ID_TO_CPU(ap_cpu_id) = 1;
-
-#if defined(APIC_IO)
- /* one and only IO APIC */
- io_apic_id = (io_apic_read(0, IOAPIC_ID) & APIC_ID_MASK) >> 24;
-
- /*
- * sanity check, refer to MP spec section 3.6.6, last paragraph
- * necessary as some hardware isn't properly setting up the IO APIC
- */
-#if defined(REALLY_ANAL_IOAPICID_VALUE)
- if (io_apic_id != 2) {
-#else
- if ((io_apic_id == 0) || (io_apic_id == 1) || (io_apic_id == 15)) {
-#endif /* REALLY_ANAL_IOAPICID_VALUE */
- ux = io_apic_read(0, IOAPIC_ID); /* get current contents */
- ux &= ~APIC_ID_MASK; /* clear the ID field */
- ux |= 0x02000000; /* set it to '2' */
- io_apic_write(0, IOAPIC_ID, ux); /* write new value */
- ux = io_apic_read(0, IOAPIC_ID); /* re-read && test */
- if ((ux & APIC_ID_MASK) != 0x02000000)
- panic("can't control IO APIC ID, reg: 0x%08x", ux);
- io_apic_id = 2;
- }
- IO_TO_ID(0) = io_apic_id;
- ID_TO_IO(io_apic_id) = 0;
-#endif /* APIC_IO */
-
- /* fill out bus entries */
- switch (type) {
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- bus_data[0].bus_id = default_data[type - 1][1];
- bus_data[0].bus_type = default_data[type - 1][2];
- bus_data[1].bus_id = default_data[type - 1][3];
- bus_data[1].bus_type = default_data[type - 1][4];
- break;
-
- /* case 4: case 7: MCA NOT supported */
- default: /* illegal/reserved */
- panic("BAD default MP config: %d", type);
- /* NOTREACHED */
- }
-
-#if defined(APIC_IO)
- /* general cases from MP v1.4, table 5-2 */
- for (pin = 0; pin < 16; ++pin) {
- io_apic_ints[pin].int_type = 0;
- io_apic_ints[pin].int_flags = 0x05; /* edge/active-hi */
- io_apic_ints[pin].src_bus_id = 0;
- io_apic_ints[pin].src_bus_irq = pin; /* IRQ2 caught below */
- io_apic_ints[pin].dst_apic_id = io_apic_id;
- io_apic_ints[pin].dst_apic_int = pin; /* 1-to-1 */
- }
-
- /* special cases from MP v1.4, table 5-2 */
- if (type == 2) {
- io_apic_ints[2].int_type = 0xff; /* N/C */
- io_apic_ints[13].int_type = 0xff; /* N/C */
-#if !defined(APIC_MIXED_MODE)
- /** FIXME: ??? */
- panic("sorry, can't support type 2 default yet");
-#endif /* APIC_MIXED_MODE */
- }
- else
- io_apic_ints[2].src_bus_irq = 0; /* ISA IRQ0 is on APIC INT 2 */
-
- if (type == 7)
- io_apic_ints[0].int_type = 0xff; /* N/C */
- else
- io_apic_ints[0].int_type = 3; /* vectored 8259 */
-#endif /* APIC_IO */
-}
-
-
-/*
- * initialize all the SMP locks
- */
-
-/* critical region around IO APIC, apic_imen */
-struct simplelock imen_lock;
-
-/* critical region around splxx(), cpl, cml, cil, ipending */
-struct simplelock cpl_lock;
-
-/* Make FAST_INTR() routines sequential */
-struct simplelock fast_intr_lock;
-
-/* critical region around INTR() routines */
-struct simplelock intr_lock;
-
-/* lock regions protected in UP kernel via cli/sti */
-struct simplelock mpintr_lock;
-
-/* lock region used by kernel profiling */
-struct simplelock mcount_lock;
-
-#ifdef USE_COMLOCK
-/* locks com (tty) data/hardware accesses: a FASTINTR() */
-struct simplelock com_lock;
-#endif /* USE_COMLOCK */
-
-#ifdef USE_CLOCKLOCK
-/* lock regions around the clock hardware */
-struct simplelock clock_lock;
-#endif /* USE_CLOCKLOCK */
-
-/* lock around the MP rendezvous */
-static struct simplelock smp_rv_lock;
-
-static void
-init_locks(void)
-{
- /*
- * Get the initial mp_lock with a count of 1 for the BSP.
- * This uses a LOGICAL cpu ID, ie BSP == 0.
- */
- mp_lock = 0x00000001;
-
- /* ISR uses its own "giant lock" */
- isr_lock = FREE_LOCK;
-
-#if defined(APIC_INTR_DIAGNOSTIC) && defined(APIC_INTR_DIAGNOSTIC_IRQ)
- s_lock_init((struct simplelock*)&apic_itrace_debuglock);
-#endif
-
- s_lock_init((struct simplelock*)&mpintr_lock);
-
- s_lock_init((struct simplelock*)&mcount_lock);
-
- s_lock_init((struct simplelock*)&fast_intr_lock);
- s_lock_init((struct simplelock*)&intr_lock);
- s_lock_init((struct simplelock*)&imen_lock);
- s_lock_init((struct simplelock*)&cpl_lock);
- s_lock_init(&smp_rv_lock);
-
-#ifdef USE_COMLOCK
- s_lock_init((struct simplelock*)&com_lock);
-#endif /* USE_COMLOCK */
-#ifdef USE_CLOCKLOCK
- s_lock_init((struct simplelock*)&clock_lock);
-#endif /* USE_CLOCKLOCK */
-}
-
-
-/* Wait for all APs to be fully initialized */
-extern int wait_ap(unsigned int);
-
-/*
- * start each AP in our list
- */
-static int
-start_all_aps(u_int boot_addr)
-{
- int x, i, pg;
- u_char mpbiosreason;
- u_long mpbioswarmvec;
- struct globaldata *gd;
- char *stack;
-
- POSTCODE(START_ALL_APS_POST);
-
- /* initialize BSP's local APIC */
- apic_initialize();
- bsp_apic_ready = 1;
-
- /* install the AP 1st level boot code */
- install_ap_tramp(boot_addr);
-
-
- /* save the current value of the warm-start vector */
- mpbioswarmvec = *((u_long *) WARMBOOT_OFF);
-#ifndef PC98
- outb(CMOS_REG, BIOS_RESET);
- mpbiosreason = inb(CMOS_DATA);
-#endif
-
- /* record BSP in CPU map */
- all_cpus = 1;
-
- /* set up 0 -> 4MB P==V mapping for AP boot */
- *(int *)PTD = PG_V | PG_RW | ((uintptr_t)(void *)KPTphys & PG_FRAME);
- invltlb();
-
- /* start each AP */
- for (x = 1; x <= mp_naps; ++x) {
-
- /* This is a bit verbose, it will go away soon. */
-
- /* first page of AP's private space */
- pg = x * i386_btop(sizeof(struct privatespace));
-
- /* allocate a new private data page */
- gd = (struct globaldata *)kmem_alloc(kernel_map, PAGE_SIZE);
-
- /* wire it into the private page table page */
- SMPpt[pg] = (pt_entry_t)(PG_V | PG_RW | vtophys(gd));
-
- /* allocate and set up an idle stack data page */
- stack = (char *)kmem_alloc(kernel_map, UPAGES*PAGE_SIZE);
- for (i = 0; i < UPAGES; i++)
- SMPpt[pg + 5 + i] = (pt_entry_t)
- (PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack));
-
- SMPpt[pg + 1] = 0; /* *prv_CMAP1 */
- SMPpt[pg + 2] = 0; /* *prv_CMAP2 */
- SMPpt[pg + 3] = 0; /* *prv_CMAP3 */
- SMPpt[pg + 4] = 0; /* *prv_PMAP1 */
-
- /* prime data page for it to use */
- gd->gd_cpuid = x;
- gd->gd_cpu_lockid = x << 24;
- gd->gd_prv_CMAP1 = &SMPpt[pg + 1];
- gd->gd_prv_CMAP2 = &SMPpt[pg + 2];
- gd->gd_prv_CMAP3 = &SMPpt[pg + 3];
- gd->gd_prv_PMAP1 = &SMPpt[pg + 4];
- gd->gd_prv_CADDR1 = SMP_prvspace[x].CPAGE1;
- gd->gd_prv_CADDR2 = SMP_prvspace[x].CPAGE2;
- gd->gd_prv_CADDR3 = SMP_prvspace[x].CPAGE3;
- gd->gd_prv_PADDR1 = (unsigned *)SMP_prvspace[x].PPAGE1;
-
- /* setup a vector to our boot code */
- *((volatile u_short *) WARMBOOT_OFF) = WARMBOOT_TARGET;
- *((volatile u_short *) WARMBOOT_SEG) = (boot_addr >> 4);
-#ifndef PC98
- outb(CMOS_REG, BIOS_RESET);
- outb(CMOS_DATA, BIOS_WARM); /* 'warm-start' */
-#endif
-
- bootSTK = &SMP_prvspace[x].idlestack[UPAGES*PAGE_SIZE];
- bootAP = x;
-
- /* attempt to start the Application Processor */
- CHECK_INIT(99); /* setup checkpoints */
- if (!start_ap(x, boot_addr)) {
- printf("AP #%d (PHY# %d) failed!\n", x, CPU_TO_ID(x));
- CHECK_PRINT("trace"); /* show checkpoints */
- /* better panic as the AP may be running loose */
- printf("panic y/n? [y] ");
- if (cngetc() != 'n')
- panic("bye-bye");
- }
- CHECK_PRINT("trace"); /* show checkpoints */
-
- /* record its version info */
- cpu_apic_versions[x] = cpu_apic_versions[0];
-
- all_cpus |= (1 << x); /* record AP in CPU map */
- }
-
- /* build our map of 'other' CPUs */
- other_cpus = all_cpus & ~(1 << cpuid);
-
- /* fill in our (BSP) APIC version */
- cpu_apic_versions[0] = lapic.version;
-
- /* restore the warmstart vector */
- *(u_long *) WARMBOOT_OFF = mpbioswarmvec;
-#ifndef PC98
- outb(CMOS_REG, BIOS_RESET);
- outb(CMOS_DATA, mpbiosreason);
-#endif
-
- /*
- * Set up the idle context for the BSP. Similar to above except
- * that some was done by locore, some by pmap.c and some is implicit
- * because the BSP is cpu#0 and the page is initially zero, and also
- * because we can refer to variables by name on the BSP..
- */
-
- /* Allocate and setup BSP idle stack */
- stack = (char *)kmem_alloc(kernel_map, UPAGES * PAGE_SIZE);
- for (i = 0; i < UPAGES; i++)
- SMPpt[5 + i] = (pt_entry_t)
- (PG_V | PG_RW | vtophys(PAGE_SIZE * i + stack));
-
- *(int *)PTD = 0;
- pmap_set_opt();
-
- /* number of APs actually started */
- return mp_ncpus - 1;
-}
-
-
-/*
- * load the 1st level AP boot code into base memory.
- */
-
-/* targets for relocation */
-extern void bigJump(void);
-extern void bootCodeSeg(void);
-extern void bootDataSeg(void);
-extern void MPentry(void);
-extern u_int MP_GDT;
-extern u_int mp_gdtbase;
-
-static void
-install_ap_tramp(u_int boot_addr)
-{
- int x;
- int size = *(int *) ((u_long) & bootMP_size);
- u_char *src = (u_char *) ((u_long) bootMP);
- u_char *dst = (u_char *) boot_addr + KERNBASE;
- u_int boot_base = (u_int) bootMP;
- u_int8_t *dst8;
- u_int16_t *dst16;
- u_int32_t *dst32;
-
- POSTCODE(INSTALL_AP_TRAMP_POST);
-
- for (x = 0; x < size; ++x)
- *dst++ = *src++;
-
- /*
- * modify addresses in code we just moved to basemem. unfortunately we
- * need fairly detailed info about mpboot.s for this to work. changes
- * to mpboot.s might require changes here.
- */
-
- /* boot code is located in KERNEL space */
- dst = (u_char *) boot_addr + KERNBASE;
-
- /* modify the lgdt arg */
- dst32 = (u_int32_t *) (dst + ((u_int) & mp_gdtbase - boot_base));
- *dst32 = boot_addr + ((u_int) & MP_GDT - boot_base);
-
- /* modify the ljmp target for MPentry() */
- dst32 = (u_int32_t *) (dst + ((u_int) bigJump - boot_base) + 1);
- *dst32 = ((u_int) MPentry - KERNBASE);
-
- /* modify the target for boot code segment */
- dst16 = (u_int16_t *) (dst + ((u_int) bootCodeSeg - boot_base));
- dst8 = (u_int8_t *) (dst16 + 1);
- *dst16 = (u_int) boot_addr & 0xffff;
- *dst8 = ((u_int) boot_addr >> 16) & 0xff;
-
- /* modify the target for boot data segment */
- dst16 = (u_int16_t *) (dst + ((u_int) bootDataSeg - boot_base));
- dst8 = (u_int8_t *) (dst16 + 1);
- *dst16 = (u_int) boot_addr & 0xffff;
- *dst8 = ((u_int) boot_addr >> 16) & 0xff;
-}
-
-
-/*
- * this function starts the AP (application processor) identified
- * by the APIC ID 'physicalCpu'. It does quite a "song and dance"
- * to accomplish this. This is necessary because of the nuances
- * of the different hardware we might encounter. It ain't pretty,
- * but it seems to work.
- */
-static int
-start_ap(int logical_cpu, u_int boot_addr)
-{
- int physical_cpu;
- int vector;
- int cpus;
- u_long icr_lo, icr_hi;
-
- POSTCODE(START_AP_POST);
-
- /* get the PHYSICAL APIC ID# */
- physical_cpu = CPU_TO_ID(logical_cpu);
-
- /* calculate the vector */
- vector = (boot_addr >> 12) & 0xff;
-
- /* used as a watchpoint to signal AP startup */
- cpus = mp_ncpus;
-
- /*
- * first we do an INIT/RESET IPI this INIT IPI might be run, reseting
- * and running the target CPU. OR this INIT IPI might be latched (P5
- * bug), CPU waiting for STARTUP IPI. OR this INIT IPI might be
- * ignored.
- */
-
- /* setup the address for the target AP */
- icr_hi = lapic.icr_hi & ~APIC_ID_MASK;
- icr_hi |= (physical_cpu << 24);
- lapic.icr_hi = icr_hi;
-
- /* do an INIT IPI: assert RESET */
- icr_lo = lapic.icr_lo & 0xfff00000;
- lapic.icr_lo = icr_lo | 0x0000c500;
-
- /* wait for pending status end */
- while (lapic.icr_lo & APIC_DELSTAT_MASK)
- /* spin */ ;
-
- /* do an INIT IPI: deassert RESET */
- lapic.icr_lo = icr_lo | 0x00008500;
-
- /* wait for pending status end */
- u_sleep(10000); /* wait ~10mS */
- while (lapic.icr_lo & APIC_DELSTAT_MASK)
- /* spin */ ;
-
- /*
- * next we do a STARTUP IPI: the previous INIT IPI might still be
- * latched, (P5 bug) this 1st STARTUP would then terminate
- * immediately, and the previously started INIT IPI would continue. OR
- * the previous INIT IPI has already run. and this STARTUP IPI will
- * run. OR the previous INIT IPI was ignored. and this STARTUP IPI
- * will run.
- */
-
- /* do a STARTUP IPI */
- lapic.icr_lo = icr_lo | 0x00000600 | vector;
- while (lapic.icr_lo & APIC_DELSTAT_MASK)
- /* spin */ ;
- u_sleep(200); /* wait ~200uS */
-
- /*
- * finally we do a 2nd STARTUP IPI: this 2nd STARTUP IPI should run IF
- * the previous STARTUP IPI was cancelled by a latched INIT IPI. OR
- * this STARTUP IPI will be ignored, as only ONE STARTUP IPI is
- * recognized after hardware RESET or INIT IPI.
- */
-
- lapic.icr_lo = icr_lo | 0x00000600 | vector;
- while (lapic.icr_lo & APIC_DELSTAT_MASK)
- /* spin */ ;
- u_sleep(200); /* wait ~200uS */
-
- /* wait for it to start */
- set_apic_timer(5000000);/* == 5 seconds */
- while (read_apic_timer())
- if (mp_ncpus > cpus)
- return 1; /* return SUCCESS */
-
- return 0; /* return FAILURE */
-}
-
-
-/*
- * Flush the TLB on all other CPU's
- *
- * XXX: Needs to handshake and wait for completion before proceding.
- */
-void
-smp_invltlb(void)
-{
-#if defined(APIC_IO)
- if (smp_started && invltlb_ok)
- all_but_self_ipi(XINVLTLB_OFFSET);
-#endif /* APIC_IO */
-}
-
-void
-invlpg(u_int addr)
-{
- __asm __volatile("invlpg (%0)"::"r"(addr):"memory");
-
- /* send a message to the other CPUs */
- smp_invltlb();
-}
-
-void
-invltlb(void)
-{
- u_long temp;
-
- /*
- * This should be implemented as load_cr3(rcr3()) when load_cr3() is
- * inlined.
- */
- __asm __volatile("movl %%cr3, %0; movl %0, %%cr3":"=r"(temp) :: "memory");
-
- /* send a message to the other CPUs */
- smp_invltlb();
-}
-
-
-/*
- * When called the executing CPU will send an IPI to all other CPUs
- * requesting that they halt execution.
- *
- * Usually (but not necessarily) called with 'other_cpus' as its arg.
- *
- * - Signals all CPUs in map to stop.
- * - Waits for each to stop.
- *
- * Returns:
- * -1: error
- * 0: NA
- * 1: ok
- *
- * XXX FIXME: this is not MP-safe, needs a lock to prevent multiple CPUs
- * from executing at same time.
- */
-int
-stop_cpus(u_int map)
-{
- if (!smp_started)
- return 0;
-
- /* send the Xcpustop IPI to all CPUs in map */
- selected_apic_ipi(map, XCPUSTOP_OFFSET, APIC_DELMODE_FIXED);
-
- while ((stopped_cpus & map) != map)
- /* spin */ ;
-
- return 1;
-}
-
-
-/*
- * Called by a CPU to restart stopped CPUs.
- *
- * Usually (but not necessarily) called with 'stopped_cpus' as its arg.
- *
- * - Signals all CPUs in map to restart.
- * - Waits for each to restart.
- *
- * Returns:
- * -1: error
- * 0: NA
- * 1: ok
- */
-int
-restart_cpus(u_int map)
-{
- if (!smp_started)
- return 0;
-
- started_cpus = map; /* signal other cpus to restart */
-
- while ((stopped_cpus & map) != 0) /* wait for each to clear its bit */
- /* spin */ ;
-
- return 1;
-}
-
-int smp_active = 0; /* are the APs allowed to run? */
-SYSCTL_INT(_machdep, OID_AUTO, smp_active, CTLFLAG_RW, &smp_active, 0, "");
-
-/* XXX maybe should be hw.ncpu */
-static int smp_cpus = 1; /* how many cpu's running */
-SYSCTL_INT(_machdep, OID_AUTO, smp_cpus, CTLFLAG_RD, &smp_cpus, 0, "");
-
-int invltlb_ok = 0; /* throttle smp_invltlb() till safe */
-SYSCTL_INT(_machdep, OID_AUTO, invltlb_ok, CTLFLAG_RW, &invltlb_ok, 0, "");
-
-/* Warning: Do not staticize. Used from swtch.s */
-int do_page_zero_idle = 1; /* bzero pages for fun and profit in idleloop */
-SYSCTL_INT(_machdep, OID_AUTO, do_page_zero_idle, CTLFLAG_RW,
- &do_page_zero_idle, 0, "");
-
-/* Is forwarding of a interrupt to the CPU holding the ISR lock enabled ? */
-int forward_irq_enabled = 1;
-SYSCTL_INT(_machdep, OID_AUTO, forward_irq_enabled, CTLFLAG_RW,
- &forward_irq_enabled, 0, "");
-
-/* Enable forwarding of a signal to a process running on a different CPU */
-static int forward_signal_enabled = 1;
-SYSCTL_INT(_machdep, OID_AUTO, forward_signal_enabled, CTLFLAG_RW,
- &forward_signal_enabled, 0, "");
-
-/* Enable forwarding of roundrobin to all other cpus */
-static int forward_roundrobin_enabled = 1;
-SYSCTL_INT(_machdep, OID_AUTO, forward_roundrobin_enabled, CTLFLAG_RW,
- &forward_roundrobin_enabled, 0, "");
-
-/*
- * This is called once the rest of the system is up and running and we're
- * ready to let the AP's out of the pen.
- */
-void ap_init(void);
-
-void
-ap_init()
-{
- u_int apic_id;
-
- /* BSP may have changed PTD while we're waiting for the lock */
- cpu_invltlb();
-
- smp_cpus++;
-
-#if defined(I586_CPU) && !defined(NO_F00F_HACK)
- lidt(&r_idt);
-#endif
-
- /* Build our map of 'other' CPUs. */
- other_cpus = all_cpus & ~(1 << cpuid);
-
- printf("SMP: AP CPU #%d Launched!\n", cpuid);
-
- /* XXX FIXME: i386 specific, and redundant: Setup the FPU. */
- load_cr0((rcr0() & ~CR0_EM) | CR0_MP | CR0_NE | CR0_TS);
-
- /* set up FPU state on the AP */
- npxinit(__INITIAL_NPXCW__);
-
- /* A quick check from sanity claus */
- apic_id = (apic_id_to_logical[(lapic.id & 0x0f000000) >> 24]);
- if (cpuid != apic_id) {
- printf("SMP: cpuid = %d\n", cpuid);
- printf("SMP: apic_id = %d\n", apic_id);
- printf("PTD[MPPTDI] = %p\n", (void *)PTD[MPPTDI]);
- panic("cpuid mismatch! boom!!");
- }
-
- /* Init local apic for irq's */
- apic_initialize();
-
- /* Set memory range attributes for this CPU to match the BSP */
- mem_range_AP_init();
-
- /*
- * Activate smp_invltlb, although strictly speaking, this isn't
- * quite correct yet. We should have a bitfield for cpus willing
- * to accept TLB flush IPI's or something and sync them.
- */
- if (smp_cpus == mp_ncpus) {
- invltlb_ok = 1;
- smp_started = 1; /* enable IPI's, tlb shootdown, freezes etc */
- smp_active = 1; /* historic */
- }
-}
-
-#ifdef BETTER_CLOCK
-
-#define CHECKSTATE_USER 0
-#define CHECKSTATE_SYS 1
-#define CHECKSTATE_INTR 2
-
-/* Do not staticize. Used from apic_vector.s */
-struct proc* checkstate_curproc[NCPU];
-int checkstate_cpustate[NCPU];
-u_long checkstate_pc[NCPU];
-
-extern long cp_time[CPUSTATES];
-
-#define PC_TO_INDEX(pc, prof) \
- ((int)(((u_quad_t)((pc) - (prof)->pr_off) * \
- (u_quad_t)((prof)->pr_scale)) >> 16) & ~1)
-
-static void
-addupc_intr_forwarded(struct proc *p, int id, int *astmap)
-{
- int i;
- struct uprof *prof;
- u_long pc;
-
- pc = checkstate_pc[id];
- prof = &p->p_stats->p_prof;
- if (pc >= prof->pr_off &&
- (i = PC_TO_INDEX(pc, prof)) < prof->pr_size) {
- if ((p->p_flag & P_OWEUPC) == 0) {
- prof->pr_addr = pc;
- prof->pr_ticks = 1;
- p->p_flag |= P_OWEUPC;
- }
- *astmap |= (1 << id);
- }
-}
-
-static void
-forwarded_statclock(int id, int pscnt, int *astmap)
-{
- struct pstats *pstats;
- long rss;
- struct rusage *ru;
- struct vmspace *vm;
- int cpustate;
- struct proc *p;
-#ifdef GPROF
- register struct gmonparam *g;
- int i;
-#endif
-
- p = checkstate_curproc[id];
- cpustate = checkstate_cpustate[id];
-
- switch (cpustate) {
- case CHECKSTATE_USER:
- if (p->p_flag & P_PROFIL)
- addupc_intr_forwarded(p, id, astmap);
- if (pscnt > 1)
- return;
- p->p_uticks++;
- if (p->p_nice > NZERO)
- cp_time[CP_NICE]++;
- else
- cp_time[CP_USER]++;
- break;
- case CHECKSTATE_SYS:
-#ifdef GPROF
- /*
- * Kernel statistics are just like addupc_intr, only easier.
- */
- g = &_gmonparam;
- if (g->state == GMON_PROF_ON) {
- i = checkstate_pc[id] - g->lowpc;
- if (i < g->textsize) {
- i /= HISTFRACTION * sizeof(*g->kcount);
- g->kcount[i]++;
- }
- }
-#endif
- if (pscnt > 1)
- return;
-
- if (!p)
- cp_time[CP_IDLE]++;
- else {
- p->p_sticks++;
- cp_time[CP_SYS]++;
- }
- break;
- case CHECKSTATE_INTR:
- default:
-#ifdef GPROF
- /*
- * Kernel statistics are just like addupc_intr, only easier.
- */
- g = &_gmonparam;
- if (g->state == GMON_PROF_ON) {
- i = checkstate_pc[id] - g->lowpc;
- if (i < g->textsize) {
- i /= HISTFRACTION * sizeof(*g->kcount);
- g->kcount[i]++;
- }
- }
-#endif
- if (pscnt > 1)
- return;
- if (p)
- p->p_iticks++;
- cp_time[CP_INTR]++;
- }
- if (p != NULL) {
- schedclock(p);
-
- /* Update resource usage integrals and maximums. */
- if ((pstats = p->p_stats) != NULL &&
- (ru = &pstats->p_ru) != NULL &&
- (vm = p->p_vmspace) != NULL) {
- ru->ru_ixrss += pgtok(vm->vm_tsize);
- ru->ru_idrss += pgtok(vm->vm_dsize);
- ru->ru_isrss += pgtok(vm->vm_ssize);
- rss = pgtok(vmspace_resident_count(vm));
- if (ru->ru_maxrss < rss)
- ru->ru_maxrss = rss;
- }
- }
-}
-
-void
-forward_statclock(int pscnt)
-{
- int map;
- int id;
- int i;
-
- /* Kludge. We don't yet have separate locks for the interrupts
- * and the kernel. This means that we cannot let the other processors
- * handle complex interrupts while inhibiting them from entering
- * the kernel in a non-interrupt context.
- *
- * What we can do, without changing the locking mechanisms yet,
- * is letting the other processors handle a very simple interrupt
- * (wich determines the processor states), and do the main
- * work ourself.
- */
-
- if (!smp_started || !invltlb_ok || cold || panicstr)
- return;
-
- /* Step 1: Probe state (user, cpu, interrupt, spinlock, idle ) */
-
- map = other_cpus & ~stopped_cpus ;
- checkstate_probed_cpus = 0;
- if (map != 0)
- selected_apic_ipi(map,
- XCPUCHECKSTATE_OFFSET, APIC_DELMODE_FIXED);
-
- i = 0;
- while (checkstate_probed_cpus != map) {
- /* spin */
- i++;
- if (i == 100000) {
-#ifdef BETTER_CLOCK_DIAGNOSTIC
- printf("forward_statclock: checkstate %x\n",
- checkstate_probed_cpus);
-#endif
- break;
- }
- }
-
- /*
- * Step 2: walk through other processors processes, update ticks and
- * profiling info.
- */
-
- map = 0;
- for (id = 0; id < mp_ncpus; id++) {
- if (id == cpuid)
- continue;
- if (((1 << id) & checkstate_probed_cpus) == 0)
- continue;
- forwarded_statclock(id, pscnt, &map);
- }
- if (map != 0) {
- checkstate_need_ast |= map;
- selected_apic_ipi(map, XCPUAST_OFFSET, APIC_DELMODE_FIXED);
- i = 0;
- while ((checkstate_need_ast & map) != 0) {
- /* spin */
- i++;
- if (i > 100000) {
-#ifdef BETTER_CLOCK_DIAGNOSTIC
- printf("forward_statclock: dropped ast 0x%x\n",
- checkstate_need_ast & map);
-#endif
- break;
- }
- }
- }
-}
-
-void
-forward_hardclock(int pscnt)
-{
- int map;
- int id;
- struct proc *p;
- struct pstats *pstats;
- int i;
-
- /* Kludge. We don't yet have separate locks for the interrupts
- * and the kernel. This means that we cannot let the other processors
- * handle complex interrupts while inhibiting them from entering
- * the kernel in a non-interrupt context.
- *
- * What we can do, without changing the locking mechanisms yet,
- * is letting the other processors handle a very simple interrupt
- * (wich determines the processor states), and do the main
- * work ourself.
- */
-
- if (!smp_started || !invltlb_ok || cold || panicstr)
- return;
-
- /* Step 1: Probe state (user, cpu, interrupt, spinlock, idle) */
-
- map = other_cpus & ~stopped_cpus ;
- checkstate_probed_cpus = 0;
- if (map != 0)
- selected_apic_ipi(map,
- XCPUCHECKSTATE_OFFSET, APIC_DELMODE_FIXED);
-
- i = 0;
- while (checkstate_probed_cpus != map) {
- /* spin */
- i++;
- if (i == 100000) {
-#ifdef BETTER_CLOCK_DIAGNOSTIC
- printf("forward_hardclock: checkstate %x\n",
- checkstate_probed_cpus);
-#endif
- break;
- }
- }
-
- /*
- * Step 2: walk through other processors processes, update virtual
- * timer and profiling timer. If stathz == 0, also update ticks and
- * profiling info.
- */
-
- map = 0;
- for (id = 0; id < mp_ncpus; id++) {
- if (id == cpuid)
- continue;
- if (((1 << id) & checkstate_probed_cpus) == 0)
- continue;
- p = checkstate_curproc[id];
- if (p) {
- pstats = p->p_stats;
- if (checkstate_cpustate[id] == CHECKSTATE_USER &&
- timevalisset(&pstats->p_timer[ITIMER_VIRTUAL].it_value) &&
- itimerdecr(&pstats->p_timer[ITIMER_VIRTUAL], tick) == 0) {
- psignal(p, SIGVTALRM);
- map |= (1 << id);
- }
- if (timevalisset(&pstats->p_timer[ITIMER_PROF].it_value) &&
- itimerdecr(&pstats->p_timer[ITIMER_PROF], tick) == 0) {
- psignal(p, SIGPROF);
- map |= (1 << id);
- }
- }
- if (stathz == 0) {
- forwarded_statclock( id, pscnt, &map);
- }
- }
- if (map != 0) {
- checkstate_need_ast |= map;
- selected_apic_ipi(map, XCPUAST_OFFSET, APIC_DELMODE_FIXED);
- i = 0;
- while ((checkstate_need_ast & map) != 0) {
- /* spin */
- i++;
- if (i > 100000) {
-#ifdef BETTER_CLOCK_DIAGNOSTIC
- printf("forward_hardclock: dropped ast 0x%x\n",
- checkstate_need_ast & map);
-#endif
- break;
- }
- }
- }
-}
-
-#endif /* BETTER_CLOCK */
-
-void
-forward_signal(struct proc *p)
-{
- int map;
- int id;
- int i;
-
- /* Kludge. We don't yet have separate locks for the interrupts
- * and the kernel. This means that we cannot let the other processors
- * handle complex interrupts while inhibiting them from entering
- * the kernel in a non-interrupt context.
- *
- * What we can do, without changing the locking mechanisms yet,
- * is letting the other processors handle a very simple interrupt
- * (wich determines the processor states), and do the main
- * work ourself.
- */
-
- if (!smp_started || !invltlb_ok || cold || panicstr)
- return;
- if (!forward_signal_enabled)
- return;
- while (1) {
- if (p->p_stat != SRUN)
- return;
- id = p->p_oncpu;
- if (id == 0xff)
- return;
- map = (1<<id);
- checkstate_need_ast |= map;
- selected_apic_ipi(map, XCPUAST_OFFSET, APIC_DELMODE_FIXED);
- i = 0;
- while ((checkstate_need_ast & map) != 0) {
- /* spin */
- i++;
- if (i > 100000) {
-#if 0
- printf("forward_signal: dropped ast 0x%x\n",
- checkstate_need_ast & map);
-#endif
- break;
- }
- }
- if (id == p->p_oncpu)
- return;
- }
-}
-
-void
-forward_roundrobin(void)
-{
- u_int map;
- int i;
-
- if (!smp_started || !invltlb_ok || cold || panicstr)
- return;
- if (!forward_roundrobin_enabled)
- return;
- resched_cpus |= other_cpus;
- map = other_cpus & ~stopped_cpus ;
-#if 1
- selected_apic_ipi(map, XCPUAST_OFFSET, APIC_DELMODE_FIXED);
-#else
- (void) all_but_self_ipi(XCPUAST_OFFSET);
-#endif
- i = 0;
- while ((checkstate_need_ast & map) != 0) {
- /* spin */
- i++;
- if (i > 100000) {
-#if 0
- printf("forward_roundrobin: dropped ast 0x%x\n",
- checkstate_need_ast & map);
-#endif
- break;
- }
- }
-}
-
-
-#ifdef APIC_INTR_REORDER
-/*
- * Maintain mapping from softintr vector to isr bit in local apic.
- */
-void
-set_lapic_isrloc(int intr, int vector)
-{
- if (intr < 0 || intr > 32)
- panic("set_apic_isrloc: bad intr argument: %d",intr);
- if (vector < ICU_OFFSET || vector > 255)
- panic("set_apic_isrloc: bad vector argument: %d",vector);
- apic_isrbit_location[intr].location = &lapic.isr0 + ((vector>>5)<<2);
- apic_isrbit_location[intr].bit = (1<<(vector & 31));
-}
-#endif
-
-/*
- * All-CPU rendezvous. CPUs are signalled, all execute the setup function
- * (if specified), rendezvous, execute the action function (if specified),
- * rendezvous again, execute the teardown function (if specified), and then
- * resume.
- *
- * Note that the supplied external functions _must_ be reentrant and aware
- * that they are running in parallel and in an unknown lock context.
- */
-static void (*smp_rv_setup_func)(void *arg);
-static void (*smp_rv_action_func)(void *arg);
-static void (*smp_rv_teardown_func)(void *arg);
-static void *smp_rv_func_arg;
-static volatile int smp_rv_waiters[2];
-
-void
-smp_rendezvous_action(void)
-{
- /* setup function */
- if (smp_rv_setup_func != NULL)
- smp_rv_setup_func(smp_rv_func_arg);
- /* spin on entry rendezvous */
- atomic_add_int(&smp_rv_waiters[0], 1);
- while (smp_rv_waiters[0] < mp_ncpus)
- ;
- /* action function */
- if (smp_rv_action_func != NULL)
- smp_rv_action_func(smp_rv_func_arg);
- /* spin on exit rendezvous */
- atomic_add_int(&smp_rv_waiters[1], 1);
- while (smp_rv_waiters[1] < mp_ncpus)
- ;
- /* teardown function */
- if (smp_rv_teardown_func != NULL)
- smp_rv_teardown_func(smp_rv_func_arg);
-}
-
-void
-smp_rendezvous(void (* setup_func)(void *),
- void (* action_func)(void *),
- void (* teardown_func)(void *),
- void *arg)
-{
- u_int efl;
-
- /* obtain rendezvous lock */
- s_lock(&smp_rv_lock); /* XXX sleep here? NOWAIT flag? */
-
- /* set static function pointers */
- smp_rv_setup_func = setup_func;
- smp_rv_action_func = action_func;
- smp_rv_teardown_func = teardown_func;
- smp_rv_func_arg = arg;
- smp_rv_waiters[0] = 0;
- smp_rv_waiters[1] = 0;
-
- /* disable interrupts on this CPU, save interrupt status */
- efl = read_eflags();
- write_eflags(efl & ~PSL_I);
-
- /* signal other processors, which will enter the IPI with interrupts off */
- all_but_self_ipi(XRENDEZVOUS_OFFSET);
-
- /* call executor function */
- smp_rendezvous_action();
-
- /* restore interrupt flag */
- write_eflags(efl);
-
- /* release lock */
- s_unlock(&smp_rv_lock);
-}
diff --git a/sys/kern/subr_trap.c b/sys/kern/subr_trap.c
deleted file mode 100644
index a8b73cf6a02b..000000000000
--- a/sys/kern/subr_trap.c
+++ /dev/null
@@ -1,1152 +0,0 @@
-/*-
- * Copyright (C) 1994, David Greenman
- * 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 University of Utah, and William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)trap.c 7.4 (Berkeley) 5/13/91
- * $FreeBSD$
- */
-
-/*
- * 386 Trap and System call handling
- */
-
-#include "opt_cpu.h"
-#include "opt_ddb.h"
-#include "opt_ktrace.h"
-#include "opt_clock.h"
-#include "opt_trap.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/proc.h>
-#include <sys/pioctl.h>
-#include <sys/kernel.h>
-#include <sys/resourcevar.h>
-#include <sys/signalvar.h>
-#include <sys/syscall.h>
-#include <sys/sysent.h>
-#include <sys/uio.h>
-#include <sys/vmmeter.h>
-#ifdef KTRACE
-#include <sys/ktrace.h>
-#endif
-
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <sys/lock.h>
-#include <vm/pmap.h>
-#include <vm/vm_kern.h>
-#include <vm/vm_map.h>
-#include <vm/vm_page.h>
-#include <vm/vm_extern.h>
-
-#include <machine/cpu.h>
-#include <machine/ipl.h>
-#include <machine/md_var.h>
-#include <machine/pcb.h>
-#ifdef SMP
-#include <machine/smp.h>
-#endif
-#include <machine/tss.h>
-
-#include <i386/isa/intr_machdep.h>
-
-#ifdef POWERFAIL_NMI
-#include <sys/syslog.h>
-#include <machine/clock.h>
-#endif
-
-#include <machine/vm86.h>
-
-#include <ddb/ddb.h>
-
-#include "isa.h"
-#include "npx.h"
-
-int (*pmath_emulate) __P((struct trapframe *));
-
-extern void trap __P((struct trapframe frame));
-extern int trapwrite __P((unsigned addr));
-extern void syscall __P((struct trapframe frame));
-
-static int trap_pfault __P((struct trapframe *, int, vm_offset_t));
-static void trap_fatal __P((struct trapframe *, vm_offset_t));
-void dblfault_handler __P((void));
-
-extern inthand_t IDTVEC(syscall);
-
-#define MAX_TRAP_MSG 28
-static char *trap_msg[] = {
- "", /* 0 unused */
- "privileged instruction fault", /* 1 T_PRIVINFLT */
- "", /* 2 unused */
- "breakpoint instruction fault", /* 3 T_BPTFLT */
- "", /* 4 unused */
- "", /* 5 unused */
- "arithmetic trap", /* 6 T_ARITHTRAP */
- "system forced exception", /* 7 T_ASTFLT */
- "", /* 8 unused */
- "general protection fault", /* 9 T_PROTFLT */
- "trace trap", /* 10 T_TRCTRAP */
- "", /* 11 unused */
- "page fault", /* 12 T_PAGEFLT */
- "", /* 13 unused */
- "alignment fault", /* 14 T_ALIGNFLT */
- "", /* 15 unused */
- "", /* 16 unused */
- "", /* 17 unused */
- "integer divide fault", /* 18 T_DIVIDE */
- "non-maskable interrupt trap", /* 19 T_NMI */
- "overflow trap", /* 20 T_OFLOW */
- "FPU bounds check fault", /* 21 T_BOUND */
- "FPU device not available", /* 22 T_DNA */
- "double fault", /* 23 T_DOUBLEFLT */
- "FPU operand fetch fault", /* 24 T_FPOPFLT */
- "invalid TSS fault", /* 25 T_TSSFLT */
- "segment not present fault", /* 26 T_SEGNPFLT */
- "stack fault", /* 27 T_STKFLT */
- "machine check trap", /* 28 T_MCHK */
-};
-
-static __inline void userret __P((struct proc *p, struct trapframe *frame,
- u_quad_t oticks));
-
-#if defined(I586_CPU) && !defined(NO_F00F_HACK)
-extern int has_f00f_bug;
-#endif
-
-static __inline void
-userret(p, frame, oticks)
- struct proc *p;
- struct trapframe *frame;
- u_quad_t oticks;
-{
- int sig, s;
-
- while ((sig = CURSIG(p)) != 0)
- postsig(sig);
-
-#if 0
- if (!want_resched &&
- (p->p_priority <= p->p_usrpri) &&
- (p->p_rtprio.type == RTP_PRIO_NORMAL)) {
- int newpriority;
- p->p_estcpu += 1;
- newpriority = PUSER + p->p_estcpu / 4 + 2 * p->p_nice;
- newpriority = min(newpriority, MAXPRI);
- p->p_usrpri = newpriority;
- }
-#endif
-
- p->p_priority = p->p_usrpri;
- if (want_resched) {
- /*
- * Since we are curproc, clock will normally just change
- * our priority without moving us from one queue to another
- * (since the running process is not on a queue.)
- * If that happened after we setrunqueue ourselves but before we
- * mi_switch()'ed, we might not be on the queue indicated by
- * our priority.
- */
- s = splhigh();
- setrunqueue(p);
- p->p_stats->p_ru.ru_nivcsw++;
- mi_switch();
- splx(s);
- while ((sig = CURSIG(p)) != 0)
- postsig(sig);
- }
- /*
- * Charge system time if profiling.
- */
- if (p->p_flag & P_PROFIL)
- addupc_task(p, frame->tf_eip,
- (u_int)(p->p_sticks - oticks) * psratio);
-
- curpriority = p->p_priority;
-}
-
-/*
- * Exception, fault, and trap interface to the FreeBSD kernel.
- * This common code is called from assembly language IDT gate entry
- * routines that prepare a suitable stack frame, and restore this
- * frame after the exception has been processed.
- */
-
-void
-trap(frame)
- struct trapframe frame;
-{
- struct proc *p = curproc;
- u_quad_t sticks = 0;
- int i = 0, ucode = 0, type, code;
- vm_offset_t eva;
-
- if (!(frame.tf_eflags & PSL_I)) {
- /*
- * Buggy application or kernel code has disabled interrupts
- * and then trapped. Enabling interrupts now is wrong, but
- * it is better than running with interrupts disabled until
- * they are accidentally enabled later.
- */
- type = frame.tf_trapno;
- if (ISPL(frame.tf_cs) == SEL_UPL || (frame.tf_eflags & PSL_VM))
- printf(
- "pid %ld (%s): trap %d with interrupts disabled\n",
- (long)curproc->p_pid, curproc->p_comm, type);
- else if (type != T_BPTFLT && type != T_TRCTRAP)
- /*
- * XXX not quite right, since this may be for a
- * multiple fault in user mode.
- */
- printf("kernel trap %d with interrupts disabled\n",
- type);
- enable_intr();
- }
-
- eva = 0;
- if (frame.tf_trapno == T_PAGEFLT) {
- /*
- * For some Cyrix CPUs, %cr2 is clobbered by interrupts.
- * This problem is worked around by using an interrupt
- * gate for the pagefault handler. We are finally ready
- * to read %cr2 and then must reenable interrupts.
- *
- * XXX this should be in the switch statement, but the
- * NO_FOOF_HACK and VM86 goto and ifdefs obfuscate the
- * flow of control too much for this to be obviously
- * correct.
- */
- eva = rcr2();
- enable_intr();
- }
-
-#if defined(I586_CPU) && !defined(NO_F00F_HACK)
-restart:
-#endif
- type = frame.tf_trapno;
- code = frame.tf_err;
-
- if (in_vm86call) {
- if (frame.tf_eflags & PSL_VM &&
- (type == T_PROTFLT || type == T_STKFLT)) {
- i = vm86_emulate((struct vm86frame *)&frame);
- if (i != 0)
- /*
- * returns to original process
- */
- vm86_trap((struct vm86frame *)&frame);
- return;
- }
- switch (type) {
- /*
- * these traps want either a process context, or
- * assume a normal userspace trap.
- */
- case T_PROTFLT:
- case T_SEGNPFLT:
- trap_fatal(&frame, eva);
- return;
- case T_TRCTRAP:
- type = T_BPTFLT; /* kernel breakpoint */
- /* FALL THROUGH */
- }
- goto kernel_trap; /* normal kernel trap handling */
- }
-
- if ((ISPL(frame.tf_cs) == SEL_UPL) || (frame.tf_eflags & PSL_VM)) {
- /* user trap */
-
- sticks = p->p_sticks;
- p->p_md.md_regs = &frame;
-
- switch (type) {
- case T_PRIVINFLT: /* privileged instruction fault */
- ucode = type;
- i = SIGILL;
- break;
-
- case T_BPTFLT: /* bpt instruction fault */
- case T_TRCTRAP: /* trace trap */
- frame.tf_eflags &= ~PSL_T;
- i = SIGTRAP;
- break;
-
- case T_ARITHTRAP: /* arithmetic trap */
- ucode = code;
- i = SIGFPE;
- break;
-
- case T_ASTFLT: /* Allow process switch */
- astoff();
- cnt.v_soft++;
- if (p->p_flag & P_OWEUPC) {
- p->p_flag &= ~P_OWEUPC;
- addupc_task(p, p->p_stats->p_prof.pr_addr,
- p->p_stats->p_prof.pr_ticks);
- }
- goto out;
-
- /*
- * The following two traps can happen in
- * vm86 mode, and, if so, we want to handle
- * them specially.
- */
- case T_PROTFLT: /* general protection fault */
- case T_STKFLT: /* stack fault */
- if (frame.tf_eflags & PSL_VM) {
- i = vm86_emulate((struct vm86frame *)&frame);
- if (i == 0)
- goto out;
- break;
- }
- /* FALL THROUGH */
-
- case T_SEGNPFLT: /* segment not present fault */
- case T_TSSFLT: /* invalid TSS fault */
- case T_DOUBLEFLT: /* double fault */
- default:
- ucode = code + BUS_SEGM_FAULT ;
- i = SIGBUS;
- break;
-
- case T_PAGEFLT: /* page fault */
- i = trap_pfault(&frame, TRUE, eva);
- if (i == -1)
- return;
-#if defined(I586_CPU) && !defined(NO_F00F_HACK)
- if (i == -2)
- goto restart;
-#endif
- if (i == 0)
- goto out;
-
- ucode = T_PAGEFLT;
- break;
-
- case T_DIVIDE: /* integer divide fault */
- ucode = FPE_INTDIV;
- i = SIGFPE;
- break;
-
-#if NISA > 0
- case T_NMI:
-#ifdef POWERFAIL_NMI
- goto handle_powerfail;
-#else /* !POWERFAIL_NMI */
-#ifdef DDB
- /* NMI can be hooked up to a pushbutton for debugging */
- printf ("NMI ... going to debugger\n");
- if (kdb_trap (type, 0, &frame))
- return;
-#endif /* DDB */
- /* machine/parity/power fail/"kitchen sink" faults */
- if (isa_nmi(code) == 0) return;
- panic("NMI indicates hardware failure");
-#endif /* POWERFAIL_NMI */
-#endif /* NISA > 0 */
-
- case T_OFLOW: /* integer overflow fault */
- ucode = FPE_INTOVF;
- i = SIGFPE;
- break;
-
- case T_BOUND: /* bounds check fault */
- ucode = FPE_FLTSUB;
- i = SIGFPE;
- break;
-
- case T_DNA:
-#if NNPX > 0
- /* if a transparent fault (due to context switch "late") */
- if (npxdna())
- return;
-#endif
- if (!pmath_emulate) {
- i = SIGFPE;
- ucode = FPE_FPU_NP_TRAP;
- break;
- }
- i = (*pmath_emulate)(&frame);
- if (i == 0) {
- if (!(frame.tf_eflags & PSL_T))
- return;
- frame.tf_eflags &= ~PSL_T;
- i = SIGTRAP;
- }
- /* else ucode = emulator_only_knows() XXX */
- break;
-
- case T_FPOPFLT: /* FPU operand fetch fault */
- ucode = T_FPOPFLT;
- i = SIGILL;
- break;
- }
- } else {
-kernel_trap:
- /* kernel trap */
-
- switch (type) {
- case T_PAGEFLT: /* page fault */
- (void) trap_pfault(&frame, FALSE, eva);
- return;
-
- case T_DNA:
-#if NNPX > 0
- /*
- * The kernel is apparently using npx for copying.
- * XXX this should be fatal unless the kernel has
- * registered such use.
- */
- if (npxdna())
- return;
-#endif
- break;
-
- case T_PROTFLT: /* general protection fault */
- case T_SEGNPFLT: /* segment not present fault */
- /*
- * Invalid segment selectors and out of bounds
- * %eip's and %esp's can be set up in user mode.
- * This causes a fault in kernel mode when the
- * kernel tries to return to user mode. We want
- * to get this fault so that we can fix the
- * problem here and not have to check all the
- * selectors and pointers when the user changes
- * them.
- */
-#define MAYBE_DORETI_FAULT(where, whereto) \
- do { \
- if (frame.tf_eip == (int)where) { \
- frame.tf_eip = (int)whereto; \
- return; \
- } \
- } while (0)
-
- if (intr_nesting_level == 0) {
- /*
- * Invalid %fs's and %gs's can be created using
- * procfs or PT_SETREGS or by invalidating the
- * underlying LDT entry. This causes a fault
- * in kernel mode when the kernel attempts to
- * switch contexts. Lose the bad context
- * (XXX) so that we can continue, and generate
- * a signal.
- */
- if (frame.tf_eip == (int)cpu_switch_load_gs) {
- curpcb->pcb_gs = 0;
- psignal(p, SIGBUS);
- return;
- }
- MAYBE_DORETI_FAULT(doreti_iret,
- doreti_iret_fault);
- MAYBE_DORETI_FAULT(doreti_popl_ds,
- doreti_popl_ds_fault);
- MAYBE_DORETI_FAULT(doreti_popl_es,
- doreti_popl_es_fault);
- MAYBE_DORETI_FAULT(doreti_popl_fs,
- doreti_popl_fs_fault);
- if (curpcb && curpcb->pcb_onfault) {
- frame.tf_eip = (int)curpcb->pcb_onfault;
- return;
- }
- }
- break;
-
- case T_TSSFLT:
- /*
- * PSL_NT can be set in user mode and isn't cleared
- * automatically when the kernel is entered. This
- * causes a TSS fault when the kernel attempts to
- * `iret' because the TSS link is uninitialized. We
- * want to get this fault so that we can fix the
- * problem here and not every time the kernel is
- * entered.
- */
- if (frame.tf_eflags & PSL_NT) {
- frame.tf_eflags &= ~PSL_NT;
- return;
- }
- break;
-
- case T_TRCTRAP: /* trace trap */
- if (frame.tf_eip == (int)IDTVEC(syscall)) {
- /*
- * We've just entered system mode via the
- * syscall lcall. Continue single stepping
- * silently until the syscall handler has
- * saved the flags.
- */
- return;
- }
- if (frame.tf_eip == (int)IDTVEC(syscall) + 1) {
- /*
- * The syscall handler has now saved the
- * flags. Stop single stepping it.
- */
- frame.tf_eflags &= ~PSL_T;
- return;
- }
- /*
- * Ignore debug register trace traps due to
- * accesses in the user's address space, which
- * can happen under several conditions such as
- * if a user sets a watchpoint on a buffer and
- * then passes that buffer to a system call.
- * We still want to get TRCTRAPS for addresses
- * in kernel space because that is useful when
- * debugging the kernel.
- */
- if (user_dbreg_trap()) {
- /*
- * Reset breakpoint bits because the
- * processor doesn't
- */
- load_dr6(rdr6() & 0xfffffff0);
- return;
- }
- /*
- * Fall through (TRCTRAP kernel mode, kernel address)
- */
- case T_BPTFLT:
- /*
- * If DDB is enabled, let it handle the debugger trap.
- * Otherwise, debugger traps "can't happen".
- */
-#ifdef DDB
- if (kdb_trap (type, 0, &frame))
- return;
-#endif
- break;
-
-#if NISA > 0
- case T_NMI:
-#ifdef POWERFAIL_NMI
-#ifndef TIMER_FREQ
-# define TIMER_FREQ 1193182
-#endif
- handle_powerfail:
- {
- static unsigned lastalert = 0;
-
- if(time_second - lastalert > 10)
- {
- log(LOG_WARNING, "NMI: power fail\n");
- sysbeep(TIMER_FREQ/880, hz);
- lastalert = time_second;
- }
- return;
- }
-#else /* !POWERFAIL_NMI */
-#ifdef DDB
- /* NMI can be hooked up to a pushbutton for debugging */
- printf ("NMI ... going to debugger\n");
- if (kdb_trap (type, 0, &frame))
- return;
-#endif /* DDB */
- /* machine/parity/power fail/"kitchen sink" faults */
- if (isa_nmi(code) == 0) return;
- /* FALL THROUGH */
-#endif /* POWERFAIL_NMI */
-#endif /* NISA > 0 */
- }
-
- trap_fatal(&frame, eva);
- return;
- }
-
- /* Translate fault for emulators (e.g. Linux) */
- if (*p->p_sysent->sv_transtrap)
- i = (*p->p_sysent->sv_transtrap)(i, type);
-
- trapsignal(p, i, ucode);
-
-#ifdef DEBUG
- if (type <= MAX_TRAP_MSG) {
- uprintf("fatal process exception: %s",
- trap_msg[type]);
- if ((type == T_PAGEFLT) || (type == T_PROTFLT))
- uprintf(", fault VA = 0x%lx", (u_long)eva);
- uprintf("\n");
- }
-#endif
-
-out:
- userret(p, &frame, sticks);
-}
-
-#ifdef notyet
-/*
- * This version doesn't allow a page fault to user space while
- * in the kernel. The rest of the kernel needs to be made "safe"
- * before this can be used. I think the only things remaining
- * to be made safe are the iBCS2 code and the process tracing/
- * debugging code.
- */
-static int
-trap_pfault(frame, usermode, eva)
- struct trapframe *frame;
- int usermode;
- vm_offset_t eva;
-{
- vm_offset_t va;
- struct vmspace *vm = NULL;
- vm_map_t map = 0;
- int rv = 0;
- vm_prot_t ftype;
- struct proc *p = curproc;
-
- if (frame->tf_err & PGEX_W)
- ftype = VM_PROT_READ | VM_PROT_WRITE;
- else
- ftype = VM_PROT_READ;
-
- va = trunc_page(eva);
- if (va < VM_MIN_KERNEL_ADDRESS) {
- vm_offset_t v;
- vm_page_t mpte;
-
- if (p == NULL ||
- (!usermode && va < VM_MAXUSER_ADDRESS &&
- (intr_nesting_level != 0 || curpcb == NULL ||
- curpcb->pcb_onfault == NULL))) {
- trap_fatal(frame, eva);
- return (-1);
- }
-
- /*
- * This is a fault on non-kernel virtual memory.
- * vm is initialized above to NULL. If curproc is NULL
- * or curproc->p_vmspace is NULL the fault is fatal.
- */
- vm = p->p_vmspace;
- if (vm == NULL)
- goto nogo;
-
- map = &vm->vm_map;
-
- /*
- * Keep swapout from messing with us during this
- * critical time.
- */
- ++p->p_lock;
-
- /*
- * Grow the stack if necessary
- */
- /* grow_stack returns false only if va falls into
- * a growable stack region and the stack growth
- * fails. It returns true if va was not within
- * a growable stack region, or if the stack
- * growth succeeded.
- */
- if (!grow_stack (p, va)) {
- rv = KERN_FAILURE;
- --p->p_lock;
- goto nogo;
- }
-
- /* Fault in the user page: */
- rv = vm_fault(map, va, ftype,
- (ftype & VM_PROT_WRITE) ? VM_FAULT_DIRTY
- : VM_FAULT_NORMAL);
-
- --p->p_lock;
- } else {
- /*
- * Don't allow user-mode faults in kernel address space.
- */
- if (usermode)
- goto nogo;
-
- /*
- * Since we know that kernel virtual address addresses
- * always have pte pages mapped, we just have to fault
- * the page.
- */
- rv = vm_fault(kernel_map, va, ftype, VM_FAULT_NORMAL);
- }
-
- if (rv == KERN_SUCCESS)
- return (0);
-nogo:
- if (!usermode) {
- if (intr_nesting_level == 0 && curpcb && curpcb->pcb_onfault) {
- frame->tf_eip = (int)curpcb->pcb_onfault;
- return (0);
- }
- trap_fatal(frame, eva);
- return (-1);
- }
-
- /* kludge to pass faulting virtual address to sendsig */
- frame->tf_err = eva;
-
- return((rv == KERN_PROTECTION_FAILURE) ? SIGBUS : SIGSEGV);
-}
-#endif
-
-int
-trap_pfault(frame, usermode, eva)
- struct trapframe *frame;
- int usermode;
- vm_offset_t eva;
-{
- vm_offset_t va;
- struct vmspace *vm = NULL;
- vm_map_t map = 0;
- int rv = 0;
- vm_prot_t ftype;
- struct proc *p = curproc;
-
- va = trunc_page(eva);
- if (va >= KERNBASE) {
- /*
- * Don't allow user-mode faults in kernel address space.
- * An exception: if the faulting address is the invalid
- * instruction entry in the IDT, then the Intel Pentium
- * F00F bug workaround was triggered, and we need to
- * treat it is as an illegal instruction, and not a page
- * fault.
- */
-#if defined(I586_CPU) && !defined(NO_F00F_HACK)
- if ((eva == (unsigned int)&idt[6]) && has_f00f_bug) {
- frame->tf_trapno = T_PRIVINFLT;
- return -2;
- }
-#endif
- if (usermode)
- goto nogo;
-
- map = kernel_map;
- } else {
- /*
- * This is a fault on non-kernel virtual memory.
- * vm is initialized above to NULL. If curproc is NULL
- * or curproc->p_vmspace is NULL the fault is fatal.
- */
- if (p != NULL)
- vm = p->p_vmspace;
-
- if (vm == NULL)
- goto nogo;
-
- map = &vm->vm_map;
- }
-
- if (frame->tf_err & PGEX_W)
- ftype = VM_PROT_READ | VM_PROT_WRITE;
- else
- ftype = VM_PROT_READ;
-
- if (map != kernel_map) {
- /*
- * Keep swapout from messing with us during this
- * critical time.
- */
- ++p->p_lock;
-
- /*
- * Grow the stack if necessary
- */
- /* grow_stack returns false only if va falls into
- * a growable stack region and the stack growth
- * fails. It returns true if va was not within
- * a growable stack region, or if the stack
- * growth succeeded.
- */
- if (!grow_stack (p, va)) {
- rv = KERN_FAILURE;
- --p->p_lock;
- goto nogo;
- }
-
- /* Fault in the user page: */
- rv = vm_fault(map, va, ftype,
- (ftype & VM_PROT_WRITE) ? VM_FAULT_DIRTY
- : VM_FAULT_NORMAL);
-
- --p->p_lock;
- } else {
- /*
- * Don't have to worry about process locking or stacks in the kernel.
- */
- rv = vm_fault(map, va, ftype, VM_FAULT_NORMAL);
- }
-
- if (rv == KERN_SUCCESS)
- return (0);
-nogo:
- if (!usermode) {
- if (intr_nesting_level == 0 && curpcb && curpcb->pcb_onfault) {
- frame->tf_eip = (int)curpcb->pcb_onfault;
- return (0);
- }
- trap_fatal(frame, eva);
- return (-1);
- }
-
- /* kludge to pass faulting virtual address to sendsig */
- frame->tf_err = eva;
-
- return((rv == KERN_PROTECTION_FAILURE) ? SIGBUS : SIGSEGV);
-}
-
-static void
-trap_fatal(frame, eva)
- struct trapframe *frame;
- vm_offset_t eva;
-{
- int code, type, ss, esp;
- struct soft_segment_descriptor softseg;
-
- code = frame->tf_err;
- type = frame->tf_trapno;
- sdtossd(&gdt[IDXSEL(frame->tf_cs & 0xffff)].sd, &softseg);
-
- if (type <= MAX_TRAP_MSG)
- printf("\n\nFatal trap %d: %s while in %s mode\n",
- type, trap_msg[type],
- frame->tf_eflags & PSL_VM ? "vm86" :
- ISPL(frame->tf_cs) == SEL_UPL ? "user" : "kernel");
-#ifdef SMP
- /* three seperate prints in case of a trap on an unmapped page */
- printf("mp_lock = %08x; ", mp_lock);
- printf("cpuid = %d; ", cpuid);
- printf("lapic.id = %08x\n", lapic.id);
-#endif
- if (type == T_PAGEFLT) {
- printf("fault virtual address = 0x%x\n", eva);
- printf("fault code = %s %s, %s\n",
- code & PGEX_U ? "user" : "supervisor",
- code & PGEX_W ? "write" : "read",
- code & PGEX_P ? "protection violation" : "page not present");
- }
- printf("instruction pointer = 0x%x:0x%x\n",
- frame->tf_cs & 0xffff, frame->tf_eip);
- if ((ISPL(frame->tf_cs) == SEL_UPL) || (frame->tf_eflags & PSL_VM)) {
- ss = frame->tf_ss & 0xffff;
- esp = frame->tf_esp;
- } else {
- ss = GSEL(GDATA_SEL, SEL_KPL);
- esp = (int)&frame->tf_esp;
- }
- printf("stack pointer = 0x%x:0x%x\n", ss, esp);
- printf("frame pointer = 0x%x:0x%x\n", ss, frame->tf_ebp);
- printf("code segment = base 0x%x, limit 0x%x, type 0x%x\n",
- softseg.ssd_base, softseg.ssd_limit, softseg.ssd_type);
- printf(" = DPL %d, pres %d, def32 %d, gran %d\n",
- softseg.ssd_dpl, softseg.ssd_p, softseg.ssd_def32,
- softseg.ssd_gran);
- printf("processor eflags = ");
- if (frame->tf_eflags & PSL_T)
- printf("trace trap, ");
- if (frame->tf_eflags & PSL_I)
- printf("interrupt enabled, ");
- if (frame->tf_eflags & PSL_NT)
- printf("nested task, ");
- if (frame->tf_eflags & PSL_RF)
- printf("resume, ");
- if (frame->tf_eflags & PSL_VM)
- printf("vm86, ");
- printf("IOPL = %d\n", (frame->tf_eflags & PSL_IOPL) >> 12);
- printf("current process = ");
- if (curproc) {
- printf("%lu (%s)\n",
- (u_long)curproc->p_pid, curproc->p_comm ?
- curproc->p_comm : "");
- } else {
- printf("Idle\n");
- }
- printf("interrupt mask = ");
- if ((cpl & net_imask) == net_imask)
- printf("net ");
- if ((cpl & tty_imask) == tty_imask)
- printf("tty ");
- if ((cpl & bio_imask) == bio_imask)
- printf("bio ");
- if ((cpl & cam_imask) == cam_imask)
- printf("cam ");
- if (cpl == 0)
- printf("none");
-#ifdef SMP
-/**
- * XXX FIXME:
- * we probably SHOULD have stopped the other CPUs before now!
- * another CPU COULD have been touching cpl at this moment...
- */
- printf(" <- SMP: XXX");
-#endif
- printf("\n");
-
-#ifdef KDB
- if (kdb_trap(&psl))
- return;
-#endif
-#ifdef DDB
- if ((debugger_on_panic || db_active) && kdb_trap(type, 0, frame))
- return;
-#endif
- printf("trap number = %d\n", type);
- if (type <= MAX_TRAP_MSG)
- panic(trap_msg[type]);
- else
- panic("unknown/reserved trap");
-}
-
-/*
- * Double fault handler. Called when a fault occurs while writing
- * a frame for a trap/exception onto the stack. This usually occurs
- * when the stack overflows (such is the case with infinite recursion,
- * for example).
- *
- * XXX Note that the current PTD gets replaced by IdlePTD when the
- * task switch occurs. This means that the stack that was active at
- * the time of the double fault is not available at <kstack> unless
- * the machine was idle when the double fault occurred. The downside
- * of this is that "trace <ebp>" in ddb won't work.
- */
-void
-dblfault_handler()
-{
- printf("\nFatal double fault:\n");
- printf("eip = 0x%x\n", common_tss.tss_eip);
- printf("esp = 0x%x\n", common_tss.tss_esp);
- printf("ebp = 0x%x\n", common_tss.tss_ebp);
-#ifdef SMP
- /* three seperate prints in case of a trap on an unmapped page */
- printf("mp_lock = %08x; ", mp_lock);
- printf("cpuid = %d; ", cpuid);
- printf("lapic.id = %08x\n", lapic.id);
-#endif
- panic("double fault");
-}
-
-/*
- * Compensate for 386 brain damage (missing URKR).
- * This is a little simpler than the pagefault handler in trap() because
- * it the page tables have already been faulted in and high addresses
- * are thrown out early for other reasons.
- */
-int trapwrite(addr)
- unsigned addr;
-{
- struct proc *p;
- vm_offset_t va;
- struct vmspace *vm;
- int rv;
-
- va = trunc_page((vm_offset_t)addr);
- /*
- * XXX - MAX is END. Changed > to >= for temp. fix.
- */
- if (va >= VM_MAXUSER_ADDRESS)
- return (1);
-
- p = curproc;
- vm = p->p_vmspace;
-
- ++p->p_lock;
-
- if (!grow_stack (p, va)) {
- --p->p_lock;
- return (1);
- }
-
- /*
- * fault the data page
- */
- rv = vm_fault(&vm->vm_map, va, VM_PROT_READ|VM_PROT_WRITE, VM_FAULT_DIRTY);
-
- --p->p_lock;
-
- if (rv != KERN_SUCCESS)
- return 1;
-
- return (0);
-}
-
-/*
- * System call request from POSIX system call gate interface to kernel.
- * Like trap(), argument is call by reference.
- */
-void
-syscall(frame)
- struct trapframe frame;
-{
- caddr_t params;
- int i;
- struct sysent *callp;
- struct proc *p = curproc;
- u_quad_t sticks;
- int error;
- int args[8];
- u_int code;
-
-#ifdef DIAGNOSTIC
- if (ISPL(frame.tf_cs) != SEL_UPL)
- panic("syscall");
-#endif
- sticks = p->p_sticks;
- p->p_md.md_regs = &frame;
- params = (caddr_t)frame.tf_esp + sizeof(int);
- code = frame.tf_eax;
- if (p->p_sysent->sv_prepsyscall) {
- (*p->p_sysent->sv_prepsyscall)(&frame, args, &code, &params);
- } else {
- /*
- * Need to check if this is a 32 bit or 64 bit syscall.
- */
- if (code == SYS_syscall) {
- /*
- * Code is first argument, followed by actual args.
- */
- code = fuword(params);
- params += sizeof(int);
- } else if (code == SYS___syscall) {
- /*
- * Like syscall, but code is a quad, so as to maintain
- * quad alignment for the rest of the arguments.
- */
- code = fuword(params);
- params += sizeof(quad_t);
- }
- }
-
- if (p->p_sysent->sv_mask)
- code &= p->p_sysent->sv_mask;
-
- if (code >= p->p_sysent->sv_size)
- callp = &p->p_sysent->sv_table[0];
- else
- callp = &p->p_sysent->sv_table[code];
-
- if (params && (i = callp->sy_narg * sizeof(int)) &&
- (error = copyin(params, (caddr_t)args, (u_int)i))) {
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSCALL))
- ktrsyscall(p->p_tracep, code, callp->sy_narg, args);
-#endif
- goto bad;
- }
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSCALL))
- ktrsyscall(p->p_tracep, code, callp->sy_narg, args);
-#endif
- p->p_retval[0] = 0;
- p->p_retval[1] = frame.tf_edx;
-
- STOPEVENT(p, S_SCE, callp->sy_narg);
-
- error = (*callp->sy_call)(p, args);
-
- switch (error) {
-
- case 0:
- /*
- * Reinitialize proc pointer `p' as it may be different
- * if this is a child returning from fork syscall.
- */
- p = curproc;
- frame.tf_eax = p->p_retval[0];
- frame.tf_edx = p->p_retval[1];
- frame.tf_eflags &= ~PSL_C;
- break;
-
- case ERESTART:
- /*
- * Reconstruct pc, assuming lcall $X,y is 7 bytes,
- * int 0x80 is 2 bytes. We saved this in tf_err.
- */
- frame.tf_eip -= frame.tf_err;
- break;
-
- case EJUSTRETURN:
- break;
-
- default:
-bad:
- if (p->p_sysent->sv_errsize) {
- if (error >= p->p_sysent->sv_errsize)
- error = -1; /* XXX */
- else
- error = p->p_sysent->sv_errtbl[error];
- }
- frame.tf_eax = error;
- frame.tf_eflags |= PSL_C;
- break;
- }
-
- if ((frame.tf_eflags & PSL_T) && !(frame.tf_eflags & PSL_VM)) {
- /* Traced syscall. */
- frame.tf_eflags &= ~PSL_T;
- trapsignal(p, SIGTRAP, 0);
- }
-
- userret(p, &frame, sticks);
-
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSRET))
- ktrsysret(p->p_tracep, code, error, p->p_retval[0]);
-#endif
-
- /*
- * This works because errno is findable through the
- * register set. If we ever support an emulation where this
- * is not the case, this code will need to be revisited.
- */
- STOPEVENT(p, S_SCX, code);
-
-}
-
-/*
- * Simplified back end of syscall(), used when returning from fork()
- * directly into user mode.
- */
-void
-fork_return(p, frame)
- struct proc *p;
- struct trapframe frame;
-{
- frame.tf_eax = 0; /* Child returns zero */
- frame.tf_eflags &= ~PSL_C; /* success */
- frame.tf_edx = 1;
-
- userret(p, &frame, 0);
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_SYSRET))
- ktrsysret(p->p_tracep, SYS_fork, 0, 0);
-#endif
-}
diff --git a/sys/kern/uipc_sockbuf.c b/sys/kern/uipc_sockbuf.c
deleted file mode 100644
index 93d1fdacec5a..000000000000
--- a/sys/kern/uipc_sockbuf.c
+++ /dev/null
@@ -1,1006 +0,0 @@
-/*
- * Copyright (c) 1982, 1986, 1988, 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)uipc_socket2.c 8.1 (Berkeley) 6/10/93
- * $FreeBSD$
- */
-
-#include "opt_param.h"
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/domain.h>
-#include <sys/file.h> /* for maxfiles */
-#include <sys/kernel.h>
-#include <sys/proc.h>
-#include <sys/malloc.h>
-#include <sys/mbuf.h>
-#include <sys/protosw.h>
-#include <sys/resourcevar.h>
-#include <sys/stat.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-#include <sys/signalvar.h>
-#include <sys/sysctl.h>
-#include <sys/aio.h> /* for aio_swake proto */
-
-int maxsockets;
-
-/*
- * Primitive routines for operating on sockets and socket buffers
- */
-
-u_long sb_max = SB_MAX; /* XXX should be static */
-
-static u_long sb_efficiency = 8; /* parameter for sbreserve() */
-
-/*
- * Procedures to manipulate state flags of socket
- * and do appropriate wakeups. Normal sequence from the
- * active (originating) side is that soisconnecting() is
- * called during processing of connect() call,
- * resulting in an eventual call to soisconnected() if/when the
- * connection is established. When the connection is torn down
- * soisdisconnecting() is called during processing of disconnect() call,
- * and soisdisconnected() is called when the connection to the peer
- * is totally severed. The semantics of these routines are such that
- * connectionless protocols can call soisconnected() and soisdisconnected()
- * only, bypassing the in-progress calls when setting up a ``connection''
- * takes no time.
- *
- * From the passive side, a socket is created with
- * two queues of sockets: so_incomp for connections in progress
- * and so_comp for connections already made and awaiting user acceptance.
- * As a protocol is preparing incoming connections, it creates a socket
- * structure queued on so_incomp by calling sonewconn(). When the connection
- * is established, soisconnected() is called, and transfers the
- * socket structure to so_comp, making it available to accept().
- *
- * If a socket is closed with sockets on either
- * so_incomp or so_comp, these sockets are dropped.
- *
- * If higher level protocols are implemented in
- * the kernel, the wakeups done here will sometimes
- * cause software-interrupt process scheduling.
- */
-
-void
-soisconnecting(so)
- register struct socket *so;
-{
-
- so->so_state &= ~(SS_ISCONNECTED|SS_ISDISCONNECTING);
- so->so_state |= SS_ISCONNECTING;
-}
-
-void
-soisconnected(so)
- register struct socket *so;
-{
- register struct socket *head = so->so_head;
-
- so->so_state &= ~(SS_ISCONNECTING|SS_ISDISCONNECTING|SS_ISCONFIRMING);
- so->so_state |= SS_ISCONNECTED;
- if (head && (so->so_state & SS_INCOMP)) {
- TAILQ_REMOVE(&head->so_incomp, so, so_list);
- head->so_incqlen--;
- so->so_state &= ~SS_INCOMP;
- TAILQ_INSERT_TAIL(&head->so_comp, so, so_list);
- so->so_state |= SS_COMP;
- sorwakeup(head);
- wakeup_one(&head->so_timeo);
- } else {
- wakeup(&so->so_timeo);
- sorwakeup(so);
- sowwakeup(so);
- }
-}
-
-void
-soisdisconnecting(so)
- register struct socket *so;
-{
-
- so->so_state &= ~SS_ISCONNECTING;
- so->so_state |= (SS_ISDISCONNECTING|SS_CANTRCVMORE|SS_CANTSENDMORE);
- wakeup((caddr_t)&so->so_timeo);
- sowwakeup(so);
- sorwakeup(so);
-}
-
-void
-soisdisconnected(so)
- register struct socket *so;
-{
-
- so->so_state &= ~(SS_ISCONNECTING|SS_ISCONNECTED|SS_ISDISCONNECTING);
- so->so_state |= (SS_CANTRCVMORE|SS_CANTSENDMORE|SS_ISDISCONNECTED);
- wakeup((caddr_t)&so->so_timeo);
- sowwakeup(so);
- sorwakeup(so);
-}
-
-/*
- * Return a random connection that hasn't been serviced yet and
- * is eligible for discard. There is a one in qlen chance that
- * we will return a null, saying that there are no dropable
- * requests. In this case, the protocol specific code should drop
- * the new request. This insures fairness.
- *
- * This may be used in conjunction with protocol specific queue
- * congestion routines.
- */
-struct socket *
-sodropablereq(head)
- register struct socket *head;
-{
- register struct socket *so;
- unsigned int i, j, qlen;
- static int rnd;
- static struct timeval old_runtime;
- static unsigned int cur_cnt, old_cnt;
- struct timeval tv;
-
- getmicrouptime(&tv);
- if ((i = (tv.tv_sec - old_runtime.tv_sec)) != 0) {
- old_runtime = tv;
- old_cnt = cur_cnt / i;
- cur_cnt = 0;
- }
-
- so = TAILQ_FIRST(&head->so_incomp);
- if (!so)
- return (so);
-
- qlen = head->so_incqlen;
- if (++cur_cnt > qlen || old_cnt > qlen) {
- rnd = (314159 * rnd + 66329) & 0xffff;
- j = ((qlen + 1) * rnd) >> 16;
-
- while (j-- && so)
- so = TAILQ_NEXT(so, so_list);
- }
-
- return (so);
-}
-
-/*
- * When an attempt at a new connection is noted on a socket
- * which accepts connections, sonewconn is called. If the
- * connection is possible (subject to space constraints, etc.)
- * then we allocate a new structure, propoerly linked into the
- * data structure of the original socket, and return this.
- * Connstatus may be 0, or SO_ISCONFIRMING, or SO_ISCONNECTED.
- */
-struct socket *
-sonewconn(head, connstatus)
- register struct socket *head;
- int connstatus;
-{
-
- return (sonewconn3(head, connstatus, NULL));
-}
-
-struct socket *
-sonewconn3(head, connstatus, p)
- register struct socket *head;
- int connstatus;
- struct proc *p;
-{
- register struct socket *so;
-
- if (head->so_qlen > 3 * head->so_qlimit / 2)
- return ((struct socket *)0);
- so = soalloc(0);
- if (so == NULL)
- return ((struct socket *)0);
- so->so_head = head;
- so->so_type = head->so_type;
- so->so_options = head->so_options &~ SO_ACCEPTCONN;
- so->so_linger = head->so_linger;
- so->so_state = head->so_state | SS_NOFDREF;
- so->so_proto = head->so_proto;
- so->so_timeo = head->so_timeo;
- so->so_cred = p ? p->p_ucred : head->so_cred;
- crhold(so->so_cred);
- if (soreserve(so, head->so_snd.sb_hiwat, head->so_rcv.sb_hiwat) ||
- (*so->so_proto->pr_usrreqs->pru_attach)(so, 0, NULL)) {
- sodealloc(so);
- return ((struct socket *)0);
- }
-
- if (connstatus) {
- TAILQ_INSERT_TAIL(&head->so_comp, so, so_list);
- so->so_state |= SS_COMP;
- } else {
- TAILQ_INSERT_TAIL(&head->so_incomp, so, so_list);
- so->so_state |= SS_INCOMP;
- head->so_incqlen++;
- }
- head->so_qlen++;
- if (connstatus) {
- sorwakeup(head);
- wakeup((caddr_t)&head->so_timeo);
- so->so_state |= connstatus;
- }
- return (so);
-}
-
-/*
- * Socantsendmore indicates that no more data will be sent on the
- * socket; it would normally be applied to a socket when the user
- * informs the system that no more data is to be sent, by the protocol
- * code (in case PRU_SHUTDOWN). Socantrcvmore indicates that no more data
- * will be received, and will normally be applied to the socket by a
- * protocol when it detects that the peer will send no more data.
- * Data queued for reading in the socket may yet be read.
- */
-
-void
-socantsendmore(so)
- struct socket *so;
-{
-
- so->so_state |= SS_CANTSENDMORE;
- sowwakeup(so);
-}
-
-void
-socantrcvmore(so)
- struct socket *so;
-{
-
- so->so_state |= SS_CANTRCVMORE;
- sorwakeup(so);
-}
-
-/*
- * Wait for data to arrive at/drain from a socket buffer.
- */
-int
-sbwait(sb)
- struct sockbuf *sb;
-{
-
- sb->sb_flags |= SB_WAIT;
- return (tsleep((caddr_t)&sb->sb_cc,
- (sb->sb_flags & SB_NOINTR) ? PSOCK : PSOCK | PCATCH, "sbwait",
- sb->sb_timeo));
-}
-
-/*
- * Lock a sockbuf already known to be locked;
- * return any error returned from sleep (EINTR).
- */
-int
-sb_lock(sb)
- register struct sockbuf *sb;
-{
- int error;
-
- while (sb->sb_flags & SB_LOCK) {
- sb->sb_flags |= SB_WANT;
- error = tsleep((caddr_t)&sb->sb_flags,
- (sb->sb_flags & SB_NOINTR) ? PSOCK : PSOCK|PCATCH,
- "sblock", 0);
- if (error)
- return (error);
- }
- sb->sb_flags |= SB_LOCK;
- return (0);
-}
-
-/*
- * Wakeup processes waiting on a socket buffer.
- * Do asynchronous notification via SIGIO
- * if the socket has the SS_ASYNC flag set.
- */
-void
-sowakeup(so, sb)
- register struct socket *so;
- register struct sockbuf *sb;
-{
- selwakeup(&sb->sb_sel);
- sb->sb_flags &= ~SB_SEL;
- if (sb->sb_flags & SB_WAIT) {
- sb->sb_flags &= ~SB_WAIT;
- wakeup((caddr_t)&sb->sb_cc);
- }
- if ((so->so_state & SS_ASYNC) && so->so_sigio != NULL)
- pgsigio(so->so_sigio, SIGIO, 0);
- if (sb->sb_flags & SB_UPCALL)
- (*so->so_upcall)(so, so->so_upcallarg, M_DONTWAIT);
- if (sb->sb_flags & SB_AIO)
- aio_swake(so, sb);
-}
-
-/*
- * Socket buffer (struct sockbuf) utility routines.
- *
- * Each socket contains two socket buffers: one for sending data and
- * one for receiving data. Each buffer contains a queue of mbufs,
- * information about the number of mbufs and amount of data in the
- * queue, and other fields allowing select() statements and notification
- * on data availability to be implemented.
- *
- * Data stored in a socket buffer is maintained as a list of records.
- * Each record is a list of mbufs chained together with the m_next
- * field. Records are chained together with the m_nextpkt field. The upper
- * level routine soreceive() expects the following conventions to be
- * observed when placing information in the receive buffer:
- *
- * 1. If the protocol requires each message be preceded by the sender's
- * name, then a record containing that name must be present before
- * any associated data (mbuf's must be of type MT_SONAME).
- * 2. If the protocol supports the exchange of ``access rights'' (really
- * just additional data associated with the message), and there are
- * ``rights'' to be received, then a record containing this data
- * should be present (mbuf's must be of type MT_RIGHTS).
- * 3. If a name or rights record exists, then it must be followed by
- * a data record, perhaps of zero length.
- *
- * Before using a new socket structure it is first necessary to reserve
- * buffer space to the socket, by calling sbreserve(). This should commit
- * some of the available buffer space in the system buffer pool for the
- * socket (currently, it does nothing but enforce limits). The space
- * should be released by calling sbrelease() when the socket is destroyed.
- */
-
-int
-soreserve(so, sndcc, rcvcc)
- register struct socket *so;
- u_long sndcc, rcvcc;
-{
- struct proc *p = curproc;
-
- if (sbreserve(&so->so_snd, sndcc, so, p) == 0)
- goto bad;
- if (sbreserve(&so->so_rcv, rcvcc, so, p) == 0)
- goto bad2;
- if (so->so_rcv.sb_lowat == 0)
- so->so_rcv.sb_lowat = 1;
- if (so->so_snd.sb_lowat == 0)
- so->so_snd.sb_lowat = MCLBYTES;
- if (so->so_snd.sb_lowat > so->so_snd.sb_hiwat)
- so->so_snd.sb_lowat = so->so_snd.sb_hiwat;
- return (0);
-bad2:
- sbrelease(&so->so_snd, so);
-bad:
- return (ENOBUFS);
-}
-
-/*
- * Allot mbufs to a sockbuf.
- * Attempt to scale mbmax so that mbcnt doesn't become limiting
- * if buffering efficiency is near the normal case.
- */
-int
-sbreserve(sb, cc, so, p)
- struct sockbuf *sb;
- u_long cc;
- struct socket *so;
- struct proc *p;
-{
- rlim_t delta;
-
- /*
- * p will only be NULL when we're in an interrupt
- * (e.g. in tcp_input())
- */
- if ((u_quad_t)cc > (u_quad_t)sb_max * MCLBYTES / (MSIZE + MCLBYTES))
- return (0);
- delta = (rlim_t)cc - sb->sb_hiwat;
- if (p && delta >= 0 && chgsbsize(so->so_cred->cr_uid, 0) + delta >
- p->p_rlimit[RLIMIT_SBSIZE].rlim_cur)
- return (0);
- (void)chgsbsize(so->so_cred->cr_uid, delta);
- sb->sb_hiwat = cc;
- sb->sb_mbmax = min(cc * sb_efficiency, sb_max);
- if (sb->sb_lowat > sb->sb_hiwat)
- sb->sb_lowat = sb->sb_hiwat;
- return (1);
-}
-
-/*
- * Free mbufs held by a socket, and reserved mbuf space.
- */
-void
-sbrelease(sb, so)
- struct sockbuf *sb;
- struct socket *so;
-{
-
- sbflush(sb);
- (void)chgsbsize(so->so_cred->cr_uid, -(rlim_t)sb->sb_hiwat);
- sb->sb_hiwat = sb->sb_mbmax = 0;
-}
-
-/*
- * Routines to add and remove
- * data from an mbuf queue.
- *
- * The routines sbappend() or sbappendrecord() are normally called to
- * append new mbufs to a socket buffer, after checking that adequate
- * space is available, comparing the function sbspace() with the amount
- * of data to be added. sbappendrecord() differs from sbappend() in
- * that data supplied is treated as the beginning of a new record.
- * To place a sender's address, optional access rights, and data in a
- * socket receive buffer, sbappendaddr() should be used. To place
- * access rights and data in a socket receive buffer, sbappendrights()
- * should be used. In either case, the new data begins a new record.
- * Note that unlike sbappend() and sbappendrecord(), these routines check
- * for the caller that there will be enough space to store the data.
- * Each fails if there is not enough space, or if it cannot find mbufs
- * to store additional information in.
- *
- * Reliable protocols may use the socket send buffer to hold data
- * awaiting acknowledgement. Data is normally copied from a socket
- * send buffer in a protocol with m_copy for output to a peer,
- * and then removing the data from the socket buffer with sbdrop()
- * or sbdroprecord() when the data is acknowledged by the peer.
- */
-
-/*
- * Append mbuf chain m to the last record in the
- * socket buffer sb. The additional space associated
- * the mbuf chain is recorded in sb. Empty mbufs are
- * discarded and mbufs are compacted where possible.
- */
-void
-sbappend(sb, m)
- struct sockbuf *sb;
- struct mbuf *m;
-{
- register struct mbuf *n;
-
- if (m == 0)
- return;
- n = sb->sb_mb;
- if (n) {
- while (n->m_nextpkt)
- n = n->m_nextpkt;
- do {
- if (n->m_flags & M_EOR) {
- sbappendrecord(sb, m); /* XXXXXX!!!! */
- return;
- }
- } while (n->m_next && (n = n->m_next));
- }
- sbcompress(sb, m, n);
-}
-
-#ifdef SOCKBUF_DEBUG
-void
-sbcheck(sb)
- register struct sockbuf *sb;
-{
- register struct mbuf *m;
- register struct mbuf *n = 0;
- register u_long len = 0, mbcnt = 0;
-
- for (m = sb->sb_mb; m; m = n) {
- n = m->m_nextpkt;
- for (; m; m = m->m_next) {
- len += m->m_len;
- mbcnt += MSIZE;
- if (m->m_flags & M_EXT) /*XXX*/ /* pretty sure this is bogus */
- mbcnt += m->m_ext.ext_size;
- }
- }
- if (len != sb->sb_cc || mbcnt != sb->sb_mbcnt) {
- printf("cc %ld != %ld || mbcnt %ld != %ld\n", len, sb->sb_cc,
- mbcnt, sb->sb_mbcnt);
- panic("sbcheck");
- }
-}
-#endif
-
-/*
- * As above, except the mbuf chain
- * begins a new record.
- */
-void
-sbappendrecord(sb, m0)
- register struct sockbuf *sb;
- register struct mbuf *m0;
-{
- register struct mbuf *m;
-
- if (m0 == 0)
- return;
- m = sb->sb_mb;
- if (m)
- while (m->m_nextpkt)
- m = m->m_nextpkt;
- /*
- * Put the first mbuf on the queue.
- * Note this permits zero length records.
- */
- sballoc(sb, m0);
- if (m)
- m->m_nextpkt = m0;
- else
- sb->sb_mb = m0;
- m = m0->m_next;
- m0->m_next = 0;
- if (m && (m0->m_flags & M_EOR)) {
- m0->m_flags &= ~M_EOR;
- m->m_flags |= M_EOR;
- }
- sbcompress(sb, m, m0);
-}
-
-/*
- * As above except that OOB data
- * is inserted at the beginning of the sockbuf,
- * but after any other OOB data.
- */
-void
-sbinsertoob(sb, m0)
- register struct sockbuf *sb;
- register struct mbuf *m0;
-{
- register struct mbuf *m;
- register struct mbuf **mp;
-
- if (m0 == 0)
- return;
- for (mp = &sb->sb_mb; *mp ; mp = &((*mp)->m_nextpkt)) {
- m = *mp;
- again:
- switch (m->m_type) {
-
- case MT_OOBDATA:
- continue; /* WANT next train */
-
- case MT_CONTROL:
- m = m->m_next;
- if (m)
- goto again; /* inspect THIS train further */
- }
- break;
- }
- /*
- * Put the first mbuf on the queue.
- * Note this permits zero length records.
- */
- sballoc(sb, m0);
- m0->m_nextpkt = *mp;
- *mp = m0;
- m = m0->m_next;
- m0->m_next = 0;
- if (m && (m0->m_flags & M_EOR)) {
- m0->m_flags &= ~M_EOR;
- m->m_flags |= M_EOR;
- }
- sbcompress(sb, m, m0);
-}
-
-/*
- * Append address and data, and optionally, control (ancillary) data
- * to the receive queue of a socket. If present,
- * m0 must include a packet header with total length.
- * Returns 0 if no space in sockbuf or insufficient mbufs.
- */
-int
-sbappendaddr(sb, asa, m0, control)
- register struct sockbuf *sb;
- struct sockaddr *asa;
- struct mbuf *m0, *control;
-{
- register struct mbuf *m, *n;
- int space = asa->sa_len;
-
-if (m0 && (m0->m_flags & M_PKTHDR) == 0)
-panic("sbappendaddr");
- if (m0)
- space += m0->m_pkthdr.len;
- for (n = control; n; n = n->m_next) {
- space += n->m_len;
- if (n->m_next == 0) /* keep pointer to last control buf */
- break;
- }
- if (space > sbspace(sb))
- return (0);
- if (asa->sa_len > MLEN)
- return (0);
- MGET(m, M_DONTWAIT, MT_SONAME);
- if (m == 0)
- return (0);
- m->m_len = asa->sa_len;
- bcopy((caddr_t)asa, mtod(m, caddr_t), asa->sa_len);
- if (n)
- n->m_next = m0; /* concatenate data to control */
- else
- control = m0;
- m->m_next = control;
- for (n = m; n; n = n->m_next)
- sballoc(sb, n);
- n = sb->sb_mb;
- if (n) {
- while (n->m_nextpkt)
- n = n->m_nextpkt;
- n->m_nextpkt = m;
- } else
- sb->sb_mb = m;
- return (1);
-}
-
-int
-sbappendcontrol(sb, m0, control)
- struct sockbuf *sb;
- struct mbuf *control, *m0;
-{
- register struct mbuf *m, *n;
- int space = 0;
-
- if (control == 0)
- panic("sbappendcontrol");
- for (m = control; ; m = m->m_next) {
- space += m->m_len;
- if (m->m_next == 0)
- break;
- }
- n = m; /* save pointer to last control buffer */
- for (m = m0; m; m = m->m_next)
- space += m->m_len;
- if (space > sbspace(sb))
- return (0);
- n->m_next = m0; /* concatenate data to control */
- for (m = control; m; m = m->m_next)
- sballoc(sb, m);
- n = sb->sb_mb;
- if (n) {
- while (n->m_nextpkt)
- n = n->m_nextpkt;
- n->m_nextpkt = control;
- } else
- sb->sb_mb = control;
- return (1);
-}
-
-/*
- * Compress mbuf chain m into the socket
- * buffer sb following mbuf n. If n
- * is null, the buffer is presumed empty.
- */
-void
-sbcompress(sb, m, n)
- register struct sockbuf *sb;
- register struct mbuf *m, *n;
-{
- register int eor = 0;
- register struct mbuf *o;
-
- while (m) {
- eor |= m->m_flags & M_EOR;
- if (m->m_len == 0 &&
- (eor == 0 ||
- (((o = m->m_next) || (o = n)) &&
- o->m_type == m->m_type))) {
- m = m_free(m);
- continue;
- }
- if (n && (n->m_flags & (M_EXT | M_EOR)) == 0 &&
- (n->m_data + n->m_len + m->m_len) < &n->m_dat[MLEN] &&
- n->m_type == m->m_type) {
- bcopy(mtod(m, caddr_t), mtod(n, caddr_t) + n->m_len,
- (unsigned)m->m_len);
- n->m_len += m->m_len;
- sb->sb_cc += m->m_len;
- m = m_free(m);
- continue;
- }
- if (n)
- n->m_next = m;
- else
- sb->sb_mb = m;
- sballoc(sb, m);
- n = m;
- m->m_flags &= ~M_EOR;
- m = m->m_next;
- n->m_next = 0;
- }
- if (eor) {
- if (n)
- n->m_flags |= eor;
- else
- printf("semi-panic: sbcompress\n");
- }
-}
-
-/*
- * Free all mbufs in a sockbuf.
- * Check that all resources are reclaimed.
- */
-void
-sbflush(sb)
- register struct sockbuf *sb;
-{
-
- if (sb->sb_flags & SB_LOCK)
- panic("sbflush: locked");
- while (sb->sb_mbcnt) {
- /*
- * Don't call sbdrop(sb, 0) if the leading mbuf is non-empty:
- * we would loop forever. Panic instead.
- */
- if (!sb->sb_cc && (sb->sb_mb == NULL || sb->sb_mb->m_len))
- break;
- sbdrop(sb, (int)sb->sb_cc);
- }
- if (sb->sb_cc || sb->sb_mb || sb->sb_mbcnt)
- panic("sbflush: cc %ld || mb %p || mbcnt %ld", sb->sb_cc, (void *)sb->sb_mb, sb->sb_mbcnt);
-}
-
-/*
- * Drop data from (the front of) a sockbuf.
- */
-void
-sbdrop(sb, len)
- register struct sockbuf *sb;
- register int len;
-{
- register struct mbuf *m, *mn;
- struct mbuf *next;
-
- next = (m = sb->sb_mb) ? m->m_nextpkt : 0;
- while (len > 0) {
- if (m == 0) {
- if (next == 0)
- panic("sbdrop");
- m = next;
- next = m->m_nextpkt;
- continue;
- }
- if (m->m_len > len) {
- m->m_len -= len;
- m->m_data += len;
- sb->sb_cc -= len;
- break;
- }
- len -= m->m_len;
- sbfree(sb, m);
- MFREE(m, mn);
- m = mn;
- }
- while (m && m->m_len == 0) {
- sbfree(sb, m);
- MFREE(m, mn);
- m = mn;
- }
- if (m) {
- sb->sb_mb = m;
- m->m_nextpkt = next;
- } else
- sb->sb_mb = next;
-}
-
-/*
- * Drop a record off the front of a sockbuf
- * and move the next record to the front.
- */
-void
-sbdroprecord(sb)
- register struct sockbuf *sb;
-{
- register struct mbuf *m, *mn;
-
- m = sb->sb_mb;
- if (m) {
- sb->sb_mb = m->m_nextpkt;
- do {
- sbfree(sb, m);
- MFREE(m, mn);
- m = mn;
- } while (m);
- }
-}
-
-/*
- * Create a "control" mbuf containing the specified data
- * with the specified type for presentation on a socket buffer.
- */
-struct mbuf *
-sbcreatecontrol(p, size, type, level)
- caddr_t p;
- register int size;
- int type, level;
-{
- register struct cmsghdr *cp;
- struct mbuf *m;
-
- if (CMSG_SPACE((u_int)size) > MLEN)
- return ((struct mbuf *) NULL);
- if ((m = m_get(M_DONTWAIT, MT_CONTROL)) == NULL)
- return ((struct mbuf *) NULL);
- cp = mtod(m, struct cmsghdr *);
- /* XXX check size? */
- (void)memcpy(CMSG_DATA(cp), p, size);
- m->m_len = CMSG_SPACE(size);
- cp->cmsg_len = CMSG_LEN(size);
- cp->cmsg_level = level;
- cp->cmsg_type = type;
- return (m);
-}
-
-/*
- * Some routines that return EOPNOTSUPP for entry points that are not
- * supported by a protocol. Fill in as needed.
- */
-int
-pru_accept_notsupp(struct socket *so, struct sockaddr **nam)
-{
- return EOPNOTSUPP;
-}
-
-int
-pru_connect_notsupp(struct socket *so, struct sockaddr *nam, struct proc *p)
-{
- return EOPNOTSUPP;
-}
-
-int
-pru_connect2_notsupp(struct socket *so1, struct socket *so2)
-{
- return EOPNOTSUPP;
-}
-
-int
-pru_control_notsupp(struct socket *so, u_long cmd, caddr_t data,
- struct ifnet *ifp, struct proc *p)
-{
- return EOPNOTSUPP;
-}
-
-int
-pru_listen_notsupp(struct socket *so, struct proc *p)
-{
- return EOPNOTSUPP;
-}
-
-int
-pru_rcvd_notsupp(struct socket *so, int flags)
-{
- return EOPNOTSUPP;
-}
-
-int
-pru_rcvoob_notsupp(struct socket *so, struct mbuf *m, int flags)
-{
- return EOPNOTSUPP;
-}
-
-/*
- * This isn't really a ``null'' operation, but it's the default one
- * and doesn't do anything destructive.
- */
-int
-pru_sense_null(struct socket *so, struct stat *sb)
-{
- sb->st_blksize = so->so_snd.sb_hiwat;
- return 0;
-}
-
-/*
- * Make a copy of a sockaddr in a malloced buffer of type M_SONAME.
- */
-struct sockaddr *
-dup_sockaddr(sa, canwait)
- struct sockaddr *sa;
- int canwait;
-{
- struct sockaddr *sa2;
-
- MALLOC(sa2, struct sockaddr *, sa->sa_len, M_SONAME,
- canwait ? M_WAITOK : M_NOWAIT);
- if (sa2)
- bcopy(sa, sa2, sa->sa_len);
- return sa2;
-}
-
-/*
- * Create an external-format (``xsocket'') structure using the information
- * in the kernel-format socket structure pointed to by so. This is done
- * to reduce the spew of irrelevant information over this interface,
- * to isolate user code from changes in the kernel structure, and
- * potentially to provide information-hiding if we decide that
- * some of this information should be hidden from users.
- */
-void
-sotoxsocket(struct socket *so, struct xsocket *xso)
-{
- xso->xso_len = sizeof *xso;
- xso->xso_so = so;
- xso->so_type = so->so_type;
- xso->so_options = so->so_options;
- xso->so_linger = so->so_linger;
- xso->so_state = so->so_state;
- xso->so_pcb = so->so_pcb;
- xso->xso_protocol = so->so_proto->pr_protocol;
- xso->xso_family = so->so_proto->pr_domain->dom_family;
- xso->so_qlen = so->so_qlen;
- xso->so_incqlen = so->so_incqlen;
- xso->so_qlimit = so->so_qlimit;
- xso->so_timeo = so->so_timeo;
- xso->so_error = so->so_error;
- xso->so_pgid = so->so_sigio ? so->so_sigio->sio_pgid : 0;
- xso->so_oobmark = so->so_oobmark;
- sbtoxsockbuf(&so->so_snd, &xso->so_snd);
- sbtoxsockbuf(&so->so_rcv, &xso->so_rcv);
- xso->so_uid = so->so_cred->cr_uid;
-}
-
-/*
- * This does the same for sockbufs. Note that the xsockbuf structure,
- * since it is always embedded in a socket, does not include a self
- * pointer nor a length. We make this entry point public in case
- * some other mechanism needs it.
- */
-void
-sbtoxsockbuf(struct sockbuf *sb, struct xsockbuf *xsb)
-{
- xsb->sb_cc = sb->sb_cc;
- xsb->sb_hiwat = sb->sb_hiwat;
- xsb->sb_mbcnt = sb->sb_mbcnt;
- xsb->sb_mbmax = sb->sb_mbmax;
- xsb->sb_lowat = sb->sb_lowat;
- xsb->sb_flags = sb->sb_flags;
- xsb->sb_timeo = sb->sb_timeo;
-}
-
-/*
- * Here is the definition of some of the basic objects in the kern.ipc
- * branch of the MIB.
- */
-SYSCTL_NODE(_kern, KERN_IPC, ipc, CTLFLAG_RW, 0, "IPC");
-
-/* This takes the place of kern.maxsockbuf, which moved to kern.ipc. */
-static int dummy;
-SYSCTL_INT(_kern, KERN_DUMMY, dummy, CTLFLAG_RW, &dummy, 0, "");
-
-SYSCTL_INT(_kern_ipc, KIPC_MAXSOCKBUF, maxsockbuf, CTLFLAG_RW,
- &sb_max, 0, "Maximum socket buffer size");
-SYSCTL_INT(_kern_ipc, OID_AUTO, maxsockets, CTLFLAG_RD,
- &maxsockets, 0, "Maximum number of sockets avaliable");
-SYSCTL_INT(_kern_ipc, KIPC_SOCKBUF_WASTE, sockbuf_waste_factor, CTLFLAG_RW,
- &sb_efficiency, 0, "");
-
-/*
- * Initialise maxsockets
- */
-static void init_maxsockets(void *ignored)
-{
- TUNABLE_INT_FETCH("kern.ipc.maxsockets", 0, maxsockets);
- maxsockets = imax(maxsockets, imax(maxfiles, nmbclusters));
-}
-SYSINIT(param, SI_SUB_TUNABLES, SI_ORDER_ANY, init_maxsockets, NULL);
diff --git a/sys/kern/vfs_acl.c b/sys/kern/vfs_acl.c
deleted file mode 100644
index bd4a52f52def..000000000000
--- a/sys/kern/vfs_acl.c
+++ /dev/null
@@ -1,277 +0,0 @@
-/*-
- * Copyright (c) 1999, 2000 Robert N. M. Watson
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Generic routines to support file system ACLs, at a syntactic level
- * Semantics are the responsibility of the underlying file system
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/sysproto.h>
-#include <sys/kernel.h>
-#include <sys/malloc.h>
-#include <sys/vnode.h>
-#include <sys/lock.h>
-#include <sys/namei.h>
-#include <sys/file.h>
-#include <sys/proc.h>
-#include <sys/sysent.h>
-#include <sys/errno.h>
-#include <sys/stat.h>
-#include <sys/acl.h>
-#include <vm/vm_zone.h>
-
-static MALLOC_DEFINE(M_ACL, "acl", "access control list");
-
-static int vacl_set_acl(struct proc *p, struct vnode *vp, acl_type_t type,
- struct acl *aclp);
-static int vacl_get_acl(struct proc *p, struct vnode *vp, acl_type_t type,
- struct acl *aclp);
-static int vacl_aclcheck(struct proc *p, struct vnode *vp, acl_type_t type,
- struct acl *aclp);
-
-/*
- * These calls wrap the real vnode operations, and are called by the
- * syscall code once the syscall has converted the path or file
- * descriptor to a vnode (unlocked). The aclp pointer is assumed
- * still to point to userland, so this should not be consumed within
- * the kernel except by syscall code. Other code should directly
- * invoke VOP_{SET,GET}ACL.
- */
-
-/*
- * Given a vnode, set its ACL.
- */
-static int
-vacl_set_acl(struct proc *p, struct vnode *vp, acl_type_t type,
- struct acl *aclp)
-{
- struct acl inkernacl;
- int error;
-
- error = copyin(aclp, &inkernacl, sizeof(struct acl));
- if (error)
- return(error);
- VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
- error = VOP_SETACL(vp, type, &inkernacl, p->p_ucred, p);
- VOP_UNLOCK(vp, 0, p);
- return(error);
-}
-
-/*
- * Given a vnode, get its ACL.
- */
-static int
-vacl_get_acl(struct proc *p, struct vnode *vp, acl_type_t type,
- struct acl *aclp)
-{
- struct acl inkernelacl;
- int error;
-
- error = VOP_GETACL(vp, type, &inkernelacl, p->p_ucred, p);
- if (error == 0)
- error = copyout(&inkernelacl, aclp, sizeof(struct acl));
- return (error);
-}
-
-/*
- * Given a vnode, delete its ACL.
- */
-static int
-vacl_delete(struct proc *p, struct vnode *vp, acl_type_t type)
-{
- int error;
-
- VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
- error = VOP_SETACL(vp, ACL_TYPE_DEFAULT, 0, p->p_ucred, p);
- VOP_UNLOCK(vp, 0, p);
- return (error);
-}
-
-/*
- * Given a vnode, check whether an ACL is appropriate for it
- */
-static int
-vacl_aclcheck(struct proc *p, struct vnode *vp, acl_type_t type,
- struct acl *aclp)
-{
- struct acl inkernelacl;
- int error;
-
- error = copyin(aclp, &inkernelacl, sizeof(struct acl));
- if (error)
- return(error);
- error = VOP_ACLCHECK(vp, type, &inkernelacl, p->p_ucred, p);
- return (error);
-}
-
-/*
- * syscalls -- convert the path/fd to a vnode, and call vacl_whatever.
- * Don't need to lock, as the vacl_ code will get/release any locks
- * required.
- */
-
-/*
- * Given a file path, get an ACL for it
- */
-int
-__acl_get_file(struct proc *p, struct __acl_get_file_args *uap)
-{
- struct nameidata nd;
- int error;
-
- /* what flags are required here -- possible not LOCKLEAF? */
- NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
- error = namei(&nd);
- if (error)
- return(error);
- error = vacl_get_acl(p, nd.ni_vp, SCARG(uap, type), SCARG(uap, aclp));
- NDFREE(&nd, 0);
- return (error);
-}
-
-/*
- * Given a file path, set an ACL for it
- */
-int
-__acl_set_file(struct proc *p, struct __acl_set_file_args *uap)
-{
- struct nameidata nd;
- int error;
-
- NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
- error = namei(&nd);
- if (error)
- return(error);
- error = vacl_set_acl(p, nd.ni_vp, SCARG(uap, type), SCARG(uap, aclp));
- NDFREE(&nd, 0);
- return (error);
-}
-
-/*
- * Given a file descriptor, get an ACL for it
- */
-int
-__acl_get_fd(struct proc *p, struct __acl_get_fd_args *uap)
-{
- struct file *fp;
- int error;
-
- error = getvnode(p->p_fd, SCARG(uap, filedes), &fp);
- if (error)
- return(error);
- return vacl_get_acl(p, (struct vnode *)fp->f_data, SCARG(uap, type),
- SCARG(uap, aclp));
-}
-
-/*
- * Given a file descriptor, set an ACL for it
- */
-int
-__acl_set_fd(struct proc *p, struct __acl_set_fd_args *uap)
-{
- struct file *fp;
- int error;
-
- error = getvnode(p->p_fd, SCARG(uap, filedes), &fp);
- if (error)
- return(error);
- return vacl_set_acl(p, (struct vnode *)fp->f_data, SCARG(uap, type),
- SCARG(uap, aclp));
-}
-
-/*
- * Given a file path, delete an ACL from it.
- */
-int
-__acl_delete_file(struct proc *p, struct __acl_delete_file_args *uap)
-{
- struct nameidata nd;
- int error;
-
- NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
- error = namei(&nd);
- if (error)
- return(error);
- error = vacl_delete(p, nd.ni_vp, SCARG(uap, type));
- NDFREE(&nd, 0);
- return (error);
-}
-
-/*
- * Given a file path, delete an ACL from it.
- */
-int
-__acl_delete_fd(struct proc *p, struct __acl_delete_fd_args *uap)
-{
- struct file *fp;
- int error;
-
- error = getvnode(p->p_fd, SCARG(uap, filedes), &fp);
- if (error)
- return(error);
- error = vacl_delete(p, (struct vnode *)fp->f_data, SCARG(uap, type));
- return (error);
-}
-
-/*
- * Given a file path, check an ACL for it
- */
-int
-__acl_aclcheck_file(struct proc *p, struct __acl_aclcheck_file_args *uap)
-{
- struct nameidata nd;
- int error;
-
- NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
- error = namei(&nd);
- if (error)
- return(error);
- error = vacl_aclcheck(p, nd.ni_vp, SCARG(uap, type), SCARG(uap, aclp));
- NDFREE(&nd, 0);
- return (error);
-}
-
-/*
- * Given a file descriptor, check an ACL for it
- */
-int
-__acl_aclcheck_fd(struct proc *p, struct __acl_aclcheck_fd_args *uap)
-{
- struct file *fp;
- int error;
-
- error = getvnode(p->p_fd, SCARG(uap, filedes), &fp);
- if (error)
- return(error);
- return vacl_aclcheck(p, (struct vnode *)fp->f_data, SCARG(uap, type),
- SCARG(uap, aclp));
-}
diff --git a/sys/kern/vfs_export.c b/sys/kern/vfs_export.c
deleted file mode 100644
index 7d61a1864a23..000000000000
--- a/sys/kern/vfs_export.c
+++ /dev/null
@@ -1,2974 +0,0 @@
-/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)vfs_subr.c 8.31 (Berkeley) 5/26/95
- * $FreeBSD$
- */
-
-/*
- * External virtual filesystem routines
- */
-#include "opt_ddb.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/buf.h>
-#include <sys/conf.h>
-#include <sys/dirent.h>
-#include <sys/domain.h>
-#include <sys/eventhandler.h>
-#include <sys/fcntl.h>
-#include <sys/kernel.h>
-#include <sys/kthread.h>
-#include <sys/malloc.h>
-#include <sys/mount.h>
-#include <sys/namei.h>
-#include <sys/proc.h>
-#include <sys/reboot.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <sys/sysctl.h>
-#include <sys/vmmeter.h>
-#include <sys/vnode.h>
-
-#include <machine/limits.h>
-
-#include <vm/vm.h>
-#include <vm/vm_object.h>
-#include <vm/vm_extern.h>
-#include <vm/pmap.h>
-#include <vm/vm_map.h>
-#include <vm/vm_page.h>
-#include <vm/vm_pager.h>
-#include <vm/vnode_pager.h>
-#include <vm/vm_zone.h>
-
-static MALLOC_DEFINE(M_NETADDR, "Export Host", "Export host address structure");
-
-static void insmntque __P((struct vnode *vp, struct mount *mp));
-static void vclean __P((struct vnode *vp, int flags, struct proc *p));
-static void vfree __P((struct vnode *));
-static unsigned long numvnodes;
-SYSCTL_INT(_debug, OID_AUTO, numvnodes, CTLFLAG_RD, &numvnodes, 0, "");
-
-enum vtype iftovt_tab[16] = {
- VNON, VFIFO, VCHR, VNON, VDIR, VNON, VBLK, VNON,
- VREG, VNON, VLNK, VNON, VSOCK, VNON, VNON, VBAD,
-};
-int vttoif_tab[9] = {
- 0, S_IFREG, S_IFDIR, S_IFBLK, S_IFCHR, S_IFLNK,
- S_IFSOCK, S_IFIFO, S_IFMT,
-};
-
-static TAILQ_HEAD(freelst, vnode) vnode_free_list; /* vnode free list */
-struct tobefreelist vnode_tobefree_list; /* vnode free list */
-
-static u_long wantfreevnodes = 25;
-SYSCTL_INT(_debug, OID_AUTO, wantfreevnodes, CTLFLAG_RW, &wantfreevnodes, 0, "");
-static u_long freevnodes = 0;
-SYSCTL_INT(_debug, OID_AUTO, freevnodes, CTLFLAG_RD, &freevnodes, 0, "");
-
-static int reassignbufcalls;
-SYSCTL_INT(_vfs, OID_AUTO, reassignbufcalls, CTLFLAG_RW, &reassignbufcalls, 0, "");
-static int reassignbufloops;
-SYSCTL_INT(_vfs, OID_AUTO, reassignbufloops, CTLFLAG_RW, &reassignbufloops, 0, "");
-static int reassignbufsortgood;
-SYSCTL_INT(_vfs, OID_AUTO, reassignbufsortgood, CTLFLAG_RW, &reassignbufsortgood, 0, "");
-static int reassignbufsortbad;
-SYSCTL_INT(_vfs, OID_AUTO, reassignbufsortbad, CTLFLAG_RW, &reassignbufsortbad, 0, "");
-static int reassignbufmethod = 1;
-SYSCTL_INT(_vfs, OID_AUTO, reassignbufmethod, CTLFLAG_RW, &reassignbufmethod, 0, "");
-
-#ifdef ENABLE_VFS_IOOPT
-int vfs_ioopt = 0;
-SYSCTL_INT(_vfs, OID_AUTO, ioopt, CTLFLAG_RW, &vfs_ioopt, 0, "");
-#endif
-
-struct mntlist mountlist = TAILQ_HEAD_INITIALIZER(mountlist); /* mounted fs */
-struct simplelock mountlist_slock;
-struct simplelock mntvnode_slock;
-int nfs_mount_type = -1;
-#ifndef NULL_SIMPLELOCKS
-static struct simplelock mntid_slock;
-static struct simplelock vnode_free_list_slock;
-static struct simplelock spechash_slock;
-#endif
-struct nfs_public nfs_pub; /* publicly exported FS */
-static vm_zone_t vnode_zone;
-
-/*
- * The workitem queue.
- */
-#define SYNCER_MAXDELAY 32
-static int syncer_maxdelay = SYNCER_MAXDELAY; /* maximum delay time */
-time_t syncdelay = 30; /* max time to delay syncing data */
-time_t filedelay = 30; /* time to delay syncing files */
-SYSCTL_INT(_kern, OID_AUTO, filedelay, CTLFLAG_RW, &filedelay, 0, "");
-time_t dirdelay = 29; /* time to delay syncing directories */
-SYSCTL_INT(_kern, OID_AUTO, dirdelay, CTLFLAG_RW, &dirdelay, 0, "");
-time_t metadelay = 28; /* time to delay syncing metadata */
-SYSCTL_INT(_kern, OID_AUTO, metadelay, CTLFLAG_RW, &metadelay, 0, "");
-static int rushjob; /* number of slots to run ASAP */
-static int stat_rush_requests; /* number of times I/O speeded up */
-SYSCTL_INT(_debug, OID_AUTO, rush_requests, CTLFLAG_RW, &stat_rush_requests, 0, "");
-
-static int syncer_delayno = 0;
-static long syncer_mask;
-LIST_HEAD(synclist, vnode);
-static struct synclist *syncer_workitem_pending;
-
-int desiredvnodes;
-SYSCTL_INT(_kern, KERN_MAXVNODES, maxvnodes, CTLFLAG_RW,
- &desiredvnodes, 0, "Maximum number of vnodes");
-
-static void vfs_free_addrlist __P((struct netexport *nep));
-static int vfs_free_netcred __P((struct radix_node *rn, void *w));
-static int vfs_hang_addrlist __P((struct mount *mp, struct netexport *nep,
- struct export_args *argp));
-
-/*
- * Initialize the vnode management data structures.
- */
-void
-vntblinit()
-{
-
- desiredvnodes = maxproc + cnt.v_page_count / 4;
- simple_lock_init(&mntvnode_slock);
- simple_lock_init(&mntid_slock);
- simple_lock_init(&spechash_slock);
- TAILQ_INIT(&vnode_free_list);
- TAILQ_INIT(&vnode_tobefree_list);
- simple_lock_init(&vnode_free_list_slock);
- vnode_zone = zinit("VNODE", sizeof (struct vnode), 0, 0, 5);
- /*
- * Initialize the filesystem syncer.
- */
- syncer_workitem_pending = hashinit(syncer_maxdelay, M_VNODE,
- &syncer_mask);
- syncer_maxdelay = syncer_mask + 1;
-}
-
-/*
- * Mark a mount point as busy. Used to synchronize access and to delay
- * unmounting. Interlock is not released on failure.
- */
-int
-vfs_busy(mp, flags, interlkp, p)
- struct mount *mp;
- int flags;
- struct simplelock *interlkp;
- struct proc *p;
-{
- int lkflags;
-
- if (mp->mnt_kern_flag & MNTK_UNMOUNT) {
- if (flags & LK_NOWAIT)
- return (ENOENT);
- mp->mnt_kern_flag |= MNTK_MWAIT;
- if (interlkp) {
- simple_unlock(interlkp);
- }
- /*
- * Since all busy locks are shared except the exclusive
- * lock granted when unmounting, the only place that a
- * wakeup needs to be done is at the release of the
- * exclusive lock at the end of dounmount.
- */
- tsleep((caddr_t)mp, PVFS, "vfs_busy", 0);
- if (interlkp) {
- simple_lock(interlkp);
- }
- return (ENOENT);
- }
- lkflags = LK_SHARED | LK_NOPAUSE;
- if (interlkp)
- lkflags |= LK_INTERLOCK;
- if (lockmgr(&mp->mnt_lock, lkflags, interlkp, p))
- panic("vfs_busy: unexpected lock failure");
- return (0);
-}
-
-/*
- * Free a busy filesystem.
- */
-void
-vfs_unbusy(mp, p)
- struct mount *mp;
- struct proc *p;
-{
-
- lockmgr(&mp->mnt_lock, LK_RELEASE, NULL, p);
-}
-
-/*
- * Lookup a filesystem type, and if found allocate and initialize
- * a mount structure for it.
- *
- * Devname is usually updated by mount(8) after booting.
- */
-int
-vfs_rootmountalloc(fstypename, devname, mpp)
- char *fstypename;
- char *devname;
- struct mount **mpp;
-{
- struct proc *p = curproc; /* XXX */
- struct vfsconf *vfsp;
- struct mount *mp;
-
- if (fstypename == NULL)
- return (ENODEV);
- for (vfsp = vfsconf; vfsp; vfsp = vfsp->vfc_next)
- if (!strcmp(vfsp->vfc_name, fstypename))
- break;
- if (vfsp == NULL)
- return (ENODEV);
- mp = malloc((u_long)sizeof(struct mount), M_MOUNT, M_WAITOK);
- bzero((char *)mp, (u_long)sizeof(struct mount));
- lockinit(&mp->mnt_lock, PVFS, "vfslock", 0, LK_NOPAUSE);
- (void)vfs_busy(mp, LK_NOWAIT, 0, p);
- LIST_INIT(&mp->mnt_vnodelist);
- mp->mnt_vfc = vfsp;
- mp->mnt_op = vfsp->vfc_vfsops;
- mp->mnt_flag = MNT_RDONLY;
- mp->mnt_vnodecovered = NULLVP;
- vfsp->vfc_refcount++;
- mp->mnt_iosize_max = DFLTPHYS;
- mp->mnt_stat.f_type = vfsp->vfc_typenum;
- mp->mnt_flag |= vfsp->vfc_flags & MNT_VISFLAGMASK;
- strncpy(mp->mnt_stat.f_fstypename, vfsp->vfc_name, MFSNAMELEN);
- mp->mnt_stat.f_mntonname[0] = '/';
- mp->mnt_stat.f_mntonname[1] = 0;
- (void) copystr(devname, mp->mnt_stat.f_mntfromname, MNAMELEN - 1, 0);
- *mpp = mp;
- return (0);
-}
-
-/*
- * Find an appropriate filesystem to use for the root. If a filesystem
- * has not been preselected, walk through the list of known filesystems
- * trying those that have mountroot routines, and try them until one
- * works or we have tried them all.
- */
-#ifdef notdef /* XXX JH */
-int
-lite2_vfs_mountroot()
-{
- struct vfsconf *vfsp;
- extern int (*lite2_mountroot) __P((void));
- int error;
-
- if (lite2_mountroot != NULL)
- return ((*lite2_mountroot)());
- for (vfsp = vfsconf; vfsp; vfsp = vfsp->vfc_next) {
- if (vfsp->vfc_mountroot == NULL)
- continue;
- if ((error = (*vfsp->vfc_mountroot)()) == 0)
- return (0);
- printf("%s_mountroot failed: %d\n", vfsp->vfc_name, error);
- }
- return (ENODEV);
-}
-#endif
-
-/*
- * Lookup a mount point by filesystem identifier.
- */
-struct mount *
-vfs_getvfs(fsid)
- fsid_t *fsid;
-{
- register struct mount *mp;
-
- simple_lock(&mountlist_slock);
- TAILQ_FOREACH(mp, &mountlist, mnt_list) {
- if (mp->mnt_stat.f_fsid.val[0] == fsid->val[0] &&
- mp->mnt_stat.f_fsid.val[1] == fsid->val[1]) {
- simple_unlock(&mountlist_slock);
- return (mp);
- }
- }
- simple_unlock(&mountlist_slock);
- return ((struct mount *) 0);
-}
-
-/*
- * Get a new unique fsid. Try to make its val[0] unique mod 2^16, since
- * this value may be used to create fake device numbers for stat(), and
- * some emulators only support 16-bit device numbers.
- *
- * Keep in mind that several mounts may be running in parallel. Starting
- * the search one past where the previous search terminated (mod 0x10) is
- * both a micro-optimization and (incomplete) defense against returning
- * the same fsid to different mounts.
- */
-void
-vfs_getnewfsid(mp)
- struct mount *mp;
-{
- static u_int mntid_base;
- fsid_t tfsid;
- u_int i;
- int mtype, mynor;
-
- simple_lock(&mntid_slock);
- mtype = mp->mnt_vfc->vfc_typenum;
- tfsid.val[1] = mtype;
- for (i = 0; ; i++) {
- /*
- * mtype needs to be uniquely encoded in the minor number
- * so that uniqueness of the full fsid implies uniqueness
- * of the device number. We are short of bits and only
- * guarantee uniqueness of the device number mod 2^16 if
- * mtype is always < 16 and there are never more than
- * 16 mounts per vfs type.
- */
- mynor = ((mntid_base++ & 0xFFFFF) << 4) | (mtype & 0xF);
- if (i < 0x10)
- mynor &= 0xFF;
- tfsid.val[0] = makeudev(255, mynor);
- if (vfs_getvfs(&tfsid) == NULL)
- break;
- }
- mp->mnt_stat.f_fsid.val[0] = tfsid.val[0];
- mp->mnt_stat.f_fsid.val[1] = tfsid.val[1];
- simple_unlock(&mntid_slock);
-}
-
-/*
- * Knob to control the precision of file timestamps:
- *
- * 0 = seconds only; nanoseconds zeroed.
- * 1 = seconds and nanoseconds, accurate within 1/HZ.
- * 2 = seconds and nanoseconds, truncated to microseconds.
- * >=3 = seconds and nanoseconds, maximum precision.
- */
-enum { TSP_SEC, TSP_HZ, TSP_USEC, TSP_NSEC };
-
-static int timestamp_precision = TSP_SEC;
-SYSCTL_INT(_vfs, OID_AUTO, timestamp_precision, CTLFLAG_RW,
- &timestamp_precision, 0, "");
-
-/*
- * Get a current timestamp.
- */
-void
-vfs_timestamp(tsp)
- struct timespec *tsp;
-{
- struct timeval tv;
-
- switch (timestamp_precision) {
- case TSP_SEC:
- tsp->tv_sec = time_second;
- tsp->tv_nsec = 0;
- break;
- case TSP_HZ:
- getnanotime(tsp);
- break;
- case TSP_USEC:
- microtime(&tv);
- TIMEVAL_TO_TIMESPEC(&tv, tsp);
- break;
- case TSP_NSEC:
- default:
- nanotime(tsp);
- break;
- }
-}
-
-/*
- * Set vnode attributes to VNOVAL
- */
-void
-vattr_null(vap)
- register struct vattr *vap;
-{
-
- vap->va_type = VNON;
- vap->va_size = VNOVAL;
- vap->va_bytes = VNOVAL;
- vap->va_mode = VNOVAL;
- vap->va_nlink = VNOVAL;
- vap->va_uid = VNOVAL;
- vap->va_gid = VNOVAL;
- vap->va_fsid = VNOVAL;
- vap->va_fileid = VNOVAL;
- vap->va_blocksize = VNOVAL;
- vap->va_rdev = VNOVAL;
- vap->va_atime.tv_sec = VNOVAL;
- vap->va_atime.tv_nsec = VNOVAL;
- vap->va_mtime.tv_sec = VNOVAL;
- vap->va_mtime.tv_nsec = VNOVAL;
- vap->va_ctime.tv_sec = VNOVAL;
- vap->va_ctime.tv_nsec = VNOVAL;
- vap->va_flags = VNOVAL;
- vap->va_gen = VNOVAL;
- vap->va_vaflags = 0;
-}
-
-/*
- * Routines having to do with the management of the vnode table.
- */
-extern vop_t **dead_vnodeop_p;
-
-/*
- * Return the next vnode from the free list.
- */
-int
-getnewvnode(tag, mp, vops, vpp)
- enum vtagtype tag;
- struct mount *mp;
- vop_t **vops;
- struct vnode **vpp;
-{
- int s;
- struct proc *p = curproc; /* XXX */
- struct vnode *vp, *tvp, *nvp;
- vm_object_t object;
- TAILQ_HEAD(freelst, vnode) vnode_tmp_list;
-
- /*
- * We take the least recently used vnode from the freelist
- * if we can get it and it has no cached pages, and no
- * namecache entries are relative to it.
- * Otherwise we allocate a new vnode
- */
-
- s = splbio();
- simple_lock(&vnode_free_list_slock);
- TAILQ_INIT(&vnode_tmp_list);
-
- for (vp = TAILQ_FIRST(&vnode_tobefree_list); vp; vp = nvp) {
- nvp = TAILQ_NEXT(vp, v_freelist);
- TAILQ_REMOVE(&vnode_tobefree_list, vp, v_freelist);
- if (vp->v_flag & VAGE) {
- TAILQ_INSERT_HEAD(&vnode_free_list, vp, v_freelist);
- } else {
- TAILQ_INSERT_TAIL(&vnode_free_list, vp, v_freelist);
- }
- vp->v_flag &= ~(VTBFREE|VAGE);
- vp->v_flag |= VFREE;
- if (vp->v_usecount)
- panic("tobe free vnode isn't");
- freevnodes++;
- }
-
- if (wantfreevnodes && freevnodes < wantfreevnodes) {
- vp = NULL;
- } else if (!wantfreevnodes && freevnodes <= desiredvnodes) {
- /*
- * XXX: this is only here to be backwards compatible
- */
- vp = NULL;
- } else {
- for (vp = TAILQ_FIRST(&vnode_free_list); vp; vp = nvp) {
- nvp = TAILQ_NEXT(vp, v_freelist);
- if (!simple_lock_try(&vp->v_interlock))
- continue;
- if (vp->v_usecount)
- panic("free vnode isn't");
-
- object = vp->v_object;
- if (object && (object->resident_page_count || object->ref_count)) {
- printf("object inconsistant state: RPC: %d, RC: %d\n",
- object->resident_page_count, object->ref_count);
- /* Don't recycle if it's caching some pages */
- TAILQ_REMOVE(&vnode_free_list, vp, v_freelist);
- TAILQ_INSERT_TAIL(&vnode_tmp_list, vp, v_freelist);
- continue;
- } else if (LIST_FIRST(&vp->v_cache_src)) {
- /* Don't recycle if active in the namecache */
- simple_unlock(&vp->v_interlock);
- continue;
- } else {
- break;
- }
- }
- }
-
- for (tvp = TAILQ_FIRST(&vnode_tmp_list); tvp; tvp = nvp) {
- nvp = TAILQ_NEXT(tvp, v_freelist);
- TAILQ_REMOVE(&vnode_tmp_list, tvp, v_freelist);
- TAILQ_INSERT_TAIL(&vnode_free_list, tvp, v_freelist);
- simple_unlock(&tvp->v_interlock);
- }
-
- if (vp) {
- vp->v_flag |= VDOOMED;
- TAILQ_REMOVE(&vnode_free_list, vp, v_freelist);
- freevnodes--;
- simple_unlock(&vnode_free_list_slock);
- cache_purge(vp);
- vp->v_lease = NULL;
- if (vp->v_type != VBAD) {
- vgonel(vp, p);
- } else {
- simple_unlock(&vp->v_interlock);
- }
-
-#ifdef INVARIANTS
- {
- int s;
-
- if (vp->v_data)
- panic("cleaned vnode isn't");
- s = splbio();
- if (vp->v_numoutput)
- panic("Clean vnode has pending I/O's");
- splx(s);
- }
-#endif
- vp->v_flag = 0;
- vp->v_lastw = 0;
- vp->v_lasta = 0;
- vp->v_cstart = 0;
- vp->v_clen = 0;
- vp->v_socket = 0;
- vp->v_writecount = 0; /* XXX */
- } else {
- simple_unlock(&vnode_free_list_slock);
- vp = (struct vnode *) zalloc(vnode_zone);
- bzero((char *) vp, sizeof *vp);
- simple_lock_init(&vp->v_interlock);
- vp->v_dd = vp;
- cache_purge(vp);
- LIST_INIT(&vp->v_cache_src);
- TAILQ_INIT(&vp->v_cache_dst);
- numvnodes++;
- }
-
- TAILQ_INIT(&vp->v_cleanblkhd);
- TAILQ_INIT(&vp->v_dirtyblkhd);
- vp->v_type = VNON;
- vp->v_tag = tag;
- vp->v_op = vops;
- insmntque(vp, mp);
- *vpp = vp;
- vp->v_usecount = 1;
- vp->v_data = 0;
- splx(s);
-
- vfs_object_create(vp, p, p->p_ucred);
- return (0);
-}
-
-/*
- * Move a vnode from one mount queue to another.
- */
-static void
-insmntque(vp, mp)
- register struct vnode *vp;
- register struct mount *mp;
-{
-
- simple_lock(&mntvnode_slock);
- /*
- * Delete from old mount point vnode list, if on one.
- */
- if (vp->v_mount != NULL)
- LIST_REMOVE(vp, v_mntvnodes);
- /*
- * Insert into list of vnodes for the new mount point, if available.
- */
- if ((vp->v_mount = mp) == NULL) {
- simple_unlock(&mntvnode_slock);
- return;
- }
- LIST_INSERT_HEAD(&mp->mnt_vnodelist, vp, v_mntvnodes);
- simple_unlock(&mntvnode_slock);
-}
-
-/*
- * Update outstanding I/O count and do wakeup if requested.
- */
-void
-vwakeup(bp)
- register struct buf *bp;
-{
- register struct vnode *vp;
-
- bp->b_flags &= ~B_WRITEINPROG;
- if ((vp = bp->b_vp)) {
- vp->v_numoutput--;
- if (vp->v_numoutput < 0)
- panic("vwakeup: neg numoutput");
- if ((vp->v_numoutput == 0) && (vp->v_flag & VBWAIT)) {
- vp->v_flag &= ~VBWAIT;
- wakeup((caddr_t) &vp->v_numoutput);
- }
- }
-}
-
-/*
- * Flush out and invalidate all buffers associated with a vnode.
- * Called with the underlying object locked.
- */
-int
-vinvalbuf(vp, flags, cred, p, slpflag, slptimeo)
- register struct vnode *vp;
- int flags;
- struct ucred *cred;
- struct proc *p;
- int slpflag, slptimeo;
-{
- register struct buf *bp;
- struct buf *nbp, *blist;
- int s, error;
- vm_object_t object;
-
- if (flags & V_SAVE) {
- s = splbio();
- while (vp->v_numoutput) {
- vp->v_flag |= VBWAIT;
- error = tsleep((caddr_t)&vp->v_numoutput,
- slpflag | (PRIBIO + 1), "vinvlbuf", slptimeo);
- if (error) {
- splx(s);
- return (error);
- }
- }
- if (!TAILQ_EMPTY(&vp->v_dirtyblkhd)) {
- splx(s);
- if ((error = VOP_FSYNC(vp, cred, MNT_WAIT, p)) != 0)
- return (error);
- s = splbio();
- if (vp->v_numoutput > 0 ||
- !TAILQ_EMPTY(&vp->v_dirtyblkhd))
- panic("vinvalbuf: dirty bufs");
- }
- splx(s);
- }
- s = splbio();
- for (;;) {
- blist = TAILQ_FIRST(&vp->v_cleanblkhd);
- if (!blist)
- blist = TAILQ_FIRST(&vp->v_dirtyblkhd);
- if (!blist)
- break;
-
- for (bp = blist; bp; bp = nbp) {
- nbp = TAILQ_NEXT(bp, b_vnbufs);
- if (BUF_LOCK(bp, LK_EXCLUSIVE | LK_NOWAIT)) {
- error = BUF_TIMELOCK(bp,
- LK_EXCLUSIVE | LK_SLEEPFAIL,
- "vinvalbuf", slpflag, slptimeo);
- if (error == ENOLCK)
- break;
- splx(s);
- return (error);
- }
- /*
- * XXX Since there are no node locks for NFS, I
- * believe there is a slight chance that a delayed
- * write will occur while sleeping just above, so
- * check for it. Note that vfs_bio_awrite expects
- * buffers to reside on a queue, while VOP_BWRITE and
- * brelse do not.
- */
- if (((bp->b_flags & (B_DELWRI | B_INVAL)) == B_DELWRI) &&
- (flags & V_SAVE)) {
-
- if (bp->b_vp == vp) {
- if (bp->b_flags & B_CLUSTEROK) {
- BUF_UNLOCK(bp);
- vfs_bio_awrite(bp);
- } else {
- bremfree(bp);
- bp->b_flags |= B_ASYNC;
- VOP_BWRITE(bp->b_vp, bp);
- }
- } else {
- bremfree(bp);
- (void) VOP_BWRITE(bp->b_vp, bp);
- }
- break;
- }
- bremfree(bp);
- bp->b_flags |= (B_INVAL | B_NOCACHE | B_RELBUF);
- bp->b_flags &= ~B_ASYNC;
- brelse(bp);
- }
- }
-
- while (vp->v_numoutput > 0) {
- vp->v_flag |= VBWAIT;
- tsleep(&vp->v_numoutput, PVM, "vnvlbv", 0);
- }
-
- splx(s);
-
- /*
- * Destroy the copy in the VM cache, too.
- */
- simple_lock(&vp->v_interlock);
- object = vp->v_object;
- if (object != NULL) {
- vm_object_page_remove(object, 0, 0,
- (flags & V_SAVE) ? TRUE : FALSE);
- }
- simple_unlock(&vp->v_interlock);
-
- if (!TAILQ_EMPTY(&vp->v_dirtyblkhd) || !TAILQ_EMPTY(&vp->v_cleanblkhd))
- panic("vinvalbuf: flush failed");
- return (0);
-}
-
-/*
- * Truncate a file's buffer and pages to a specified length. This
- * is in lieu of the old vinvalbuf mechanism, which performed unneeded
- * sync activity.
- */
-int
-vtruncbuf(vp, cred, p, length, blksize)
- register struct vnode *vp;
- struct ucred *cred;
- struct proc *p;
- off_t length;
- int blksize;
-{
- register struct buf *bp;
- struct buf *nbp;
- int s, anyfreed;
- int trunclbn;
-
- /*
- * Round up to the *next* lbn.
- */
- trunclbn = (length + blksize - 1) / blksize;
-
- s = splbio();
-restart:
- anyfreed = 1;
- for (;anyfreed;) {
- anyfreed = 0;
- for (bp = TAILQ_FIRST(&vp->v_cleanblkhd); bp; bp = nbp) {
- nbp = TAILQ_NEXT(bp, b_vnbufs);
- if (bp->b_lblkno >= trunclbn) {
- if (BUF_LOCK(bp, LK_EXCLUSIVE | LK_NOWAIT)) {
- BUF_LOCK(bp, LK_EXCLUSIVE|LK_SLEEPFAIL);
- goto restart;
- } else {
- bremfree(bp);
- bp->b_flags |= (B_INVAL | B_RELBUF);
- bp->b_flags &= ~B_ASYNC;
- brelse(bp);
- anyfreed = 1;
- }
- if (nbp &&
- (((nbp->b_xflags & BX_VNCLEAN) == 0) ||
- (nbp->b_vp != vp) ||
- (nbp->b_flags & B_DELWRI))) {
- goto restart;
- }
- }
- }
-
- for (bp = TAILQ_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) {
- nbp = TAILQ_NEXT(bp, b_vnbufs);
- if (bp->b_lblkno >= trunclbn) {
- if (BUF_LOCK(bp, LK_EXCLUSIVE | LK_NOWAIT)) {
- BUF_LOCK(bp, LK_EXCLUSIVE|LK_SLEEPFAIL);
- goto restart;
- } else {
- bremfree(bp);
- bp->b_flags |= (B_INVAL | B_RELBUF);
- bp->b_flags &= ~B_ASYNC;
- brelse(bp);
- anyfreed = 1;
- }
- if (nbp &&
- (((nbp->b_xflags & BX_VNDIRTY) == 0) ||
- (nbp->b_vp != vp) ||
- (nbp->b_flags & B_DELWRI) == 0)) {
- goto restart;
- }
- }
- }
- }
-
- if (length > 0) {
-restartsync:
- for (bp = TAILQ_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) {
- nbp = TAILQ_NEXT(bp, b_vnbufs);
- if ((bp->b_flags & B_DELWRI) && (bp->b_lblkno < 0)) {
- if (BUF_LOCK(bp, LK_EXCLUSIVE | LK_NOWAIT)) {
- BUF_LOCK(bp, LK_EXCLUSIVE|LK_SLEEPFAIL);
- goto restart;
- } else {
- bremfree(bp);
- if (bp->b_vp == vp) {
- bp->b_flags |= B_ASYNC;
- } else {
- bp->b_flags &= ~B_ASYNC;
- }
- VOP_BWRITE(bp->b_vp, bp);
- }
- goto restartsync;
- }
-
- }
- }
-
- while (vp->v_numoutput > 0) {
- vp->v_flag |= VBWAIT;
- tsleep(&vp->v_numoutput, PVM, "vbtrunc", 0);
- }
-
- splx(s);
-
- vnode_pager_setsize(vp, length);
-
- return (0);
-}
-
-/*
- * Associate a buffer with a vnode.
- */
-void
-bgetvp(vp, bp)
- register struct vnode *vp;
- register struct buf *bp;
-{
- int s;
-
- KASSERT(bp->b_vp == NULL, ("bgetvp: not free"));
-
- vhold(vp);
- bp->b_vp = vp;
- bp->b_dev = vn_todev(vp);
- /*
- * Insert onto list for new vnode.
- */
- s = splbio();
- bp->b_xflags |= BX_VNCLEAN;
- bp->b_xflags &= ~BX_VNDIRTY;
- TAILQ_INSERT_TAIL(&vp->v_cleanblkhd, bp, b_vnbufs);
- splx(s);
-}
-
-/*
- * Disassociate a buffer from a vnode.
- */
-void
-brelvp(bp)
- register struct buf *bp;
-{
- struct vnode *vp;
- struct buflists *listheadp;
- int s;
-
- KASSERT(bp->b_vp != NULL, ("brelvp: NULL"));
-
- /*
- * Delete from old vnode list, if on one.
- */
- vp = bp->b_vp;
- s = splbio();
- if (bp->b_xflags & (BX_VNDIRTY | BX_VNCLEAN)) {
- if (bp->b_xflags & BX_VNDIRTY)
- listheadp = &vp->v_dirtyblkhd;
- else
- listheadp = &vp->v_cleanblkhd;
- TAILQ_REMOVE(listheadp, bp, b_vnbufs);
- bp->b_xflags &= ~(BX_VNDIRTY | BX_VNCLEAN);
- }
- if ((vp->v_flag & VONWORKLST) && TAILQ_EMPTY(&vp->v_dirtyblkhd)) {
- vp->v_flag &= ~VONWORKLST;
- LIST_REMOVE(vp, v_synclist);
- }
- splx(s);
- bp->b_vp = (struct vnode *) 0;
- vdrop(vp);
-}
-
-/*
- * The workitem queue.
- *
- * It is useful to delay writes of file data and filesystem metadata
- * for tens of seconds so that quickly created and deleted files need
- * not waste disk bandwidth being created and removed. To realize this,
- * we append vnodes to a "workitem" queue. When running with a soft
- * updates implementation, most pending metadata dependencies should
- * not wait for more than a few seconds. Thus, mounted on block devices
- * are delayed only about a half the time that file data is delayed.
- * Similarly, directory updates are more critical, so are only delayed
- * about a third the time that file data is delayed. Thus, there are
- * SYNCER_MAXDELAY queues that are processed round-robin at a rate of
- * one each second (driven off the filesystem syncer process). The
- * syncer_delayno variable indicates the next queue that is to be processed.
- * Items that need to be processed soon are placed in this queue:
- *
- * syncer_workitem_pending[syncer_delayno]
- *
- * A delay of fifteen seconds is done by placing the request fifteen
- * entries later in the queue:
- *
- * syncer_workitem_pending[(syncer_delayno + 15) & syncer_mask]
- *
- */
-
-/*
- * Add an item to the syncer work queue.
- */
-static void
-vn_syncer_add_to_worklist(struct vnode *vp, int delay)
-{
- int s, slot;
-
- s = splbio();
-
- if (vp->v_flag & VONWORKLST) {
- LIST_REMOVE(vp, v_synclist);
- }
-
- if (delay > syncer_maxdelay - 2)
- delay = syncer_maxdelay - 2;
- slot = (syncer_delayno + delay) & syncer_mask;
-
- LIST_INSERT_HEAD(&syncer_workitem_pending[slot], vp, v_synclist);
- vp->v_flag |= VONWORKLST;
- splx(s);
-}
-
-struct proc *updateproc;
-static void sched_sync __P((void));
-static struct kproc_desc up_kp = {
- "syncer",
- sched_sync,
- &updateproc
-};
-SYSINIT(syncer, SI_SUB_KTHREAD_UPDATE, SI_ORDER_FIRST, kproc_start, &up_kp)
-
-/*
- * System filesystem synchronizer daemon.
- */
-void
-sched_sync(void)
-{
- struct synclist *slp;
- struct vnode *vp;
- long starttime;
- int s;
- struct proc *p = updateproc;
-
- EVENTHANDLER_REGISTER(shutdown_pre_sync, shutdown_kproc, p,
- SHUTDOWN_PRI_LAST);
-
- for (;;) {
- kproc_suspend_loop(p);
-
- starttime = time_second;
-
- /*
- * Push files whose dirty time has expired. Be careful
- * of interrupt race on slp queue.
- */
- s = splbio();
- slp = &syncer_workitem_pending[syncer_delayno];
- syncer_delayno += 1;
- if (syncer_delayno == syncer_maxdelay)
- syncer_delayno = 0;
- splx(s);
-
- while ((vp = LIST_FIRST(slp)) != NULL) {
- if (VOP_ISLOCKED(vp, NULL) == 0) {
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
- (void) VOP_FSYNC(vp, p->p_ucred, MNT_LAZY, p);
- VOP_UNLOCK(vp, 0, p);
- }
- s = splbio();
- if (LIST_FIRST(slp) == vp) {
- /*
- * Note: v_tag VT_VFS vps can remain on the
- * worklist too with no dirty blocks, but
- * since sync_fsync() moves it to a different
- * slot we are safe.
- */
- if (TAILQ_EMPTY(&vp->v_dirtyblkhd) &&
- !vn_isdisk(vp, NULL))
- panic("sched_sync: fsync failed vp %p tag %d", vp, vp->v_tag);
- /*
- * Put us back on the worklist. The worklist
- * routine will remove us from our current
- * position and then add us back in at a later
- * position.
- */
- vn_syncer_add_to_worklist(vp, syncdelay);
- }
- splx(s);
- }
-
- /*
- * Do soft update processing.
- */
- if (bioops.io_sync)
- (*bioops.io_sync)(NULL);
-
- /*
- * The variable rushjob allows the kernel to speed up the
- * processing of the filesystem syncer process. A rushjob
- * value of N tells the filesystem syncer to process the next
- * N seconds worth of work on its queue ASAP. Currently rushjob
- * is used by the soft update code to speed up the filesystem
- * syncer process when the incore state is getting so far
- * ahead of the disk that the kernel memory pool is being
- * threatened with exhaustion.
- */
- if (rushjob > 0) {
- rushjob -= 1;
- continue;
- }
- /*
- * If it has taken us less than a second to process the
- * current work, then wait. Otherwise start right over
- * again. We can still lose time if any single round
- * takes more than two seconds, but it does not really
- * matter as we are just trying to generally pace the
- * filesystem activity.
- */
- if (time_second == starttime)
- tsleep(&lbolt, PPAUSE, "syncer", 0);
- }
-}
-
-/*
- * Request the syncer daemon to speed up its work.
- * We never push it to speed up more than half of its
- * normal turn time, otherwise it could take over the cpu.
- */
-int
-speedup_syncer()
-{
- int s;
-
- s = splhigh();
- if (updateproc->p_wchan == &lbolt)
- setrunnable(updateproc);
- splx(s);
- if (rushjob < syncdelay / 2) {
- rushjob += 1;
- stat_rush_requests += 1;
- return (1);
- }
- return(0);
-}
-
-/*
- * Associate a p-buffer with a vnode.
- *
- * Also sets B_PAGING flag to indicate that vnode is not fully associated
- * with the buffer. i.e. the bp has not been linked into the vnode or
- * ref-counted.
- */
-void
-pbgetvp(vp, bp)
- register struct vnode *vp;
- register struct buf *bp;
-{
-
- KASSERT(bp->b_vp == NULL, ("pbgetvp: not free"));
-
- bp->b_vp = vp;
- bp->b_flags |= B_PAGING;
- bp->b_dev = vn_todev(vp);
-}
-
-/*
- * Disassociate a p-buffer from a vnode.
- */
-void
-pbrelvp(bp)
- register struct buf *bp;
-{
-
- KASSERT(bp->b_vp != NULL, ("pbrelvp: NULL"));
-
-#if !defined(MAX_PERF)
- /* XXX REMOVE ME */
- if (bp->b_vnbufs.tqe_next != NULL) {
- panic(
- "relpbuf(): b_vp was probably reassignbuf()d %p %x",
- bp,
- (int)bp->b_flags
- );
- }
-#endif
- bp->b_vp = (struct vnode *) 0;
- bp->b_flags &= ~B_PAGING;
-}
-
-void
-pbreassignbuf(bp, newvp)
- struct buf *bp;
- struct vnode *newvp;
-{
-#if !defined(MAX_PERF)
- if ((bp->b_flags & B_PAGING) == 0) {
- panic(
- "pbreassignbuf() on non phys bp %p",
- bp
- );
- }
-#endif
- bp->b_vp = newvp;
-}
-
-/*
- * Reassign a buffer from one vnode to another.
- * Used to assign file specific control information
- * (indirect blocks) to the vnode to which they belong.
- */
-void
-reassignbuf(bp, newvp)
- register struct buf *bp;
- register struct vnode *newvp;
-{
- struct buflists *listheadp;
- int delay;
- int s;
-
- if (newvp == NULL) {
- printf("reassignbuf: NULL");
- return;
- }
- ++reassignbufcalls;
-
-#if !defined(MAX_PERF)
- /*
- * B_PAGING flagged buffers cannot be reassigned because their vp
- * is not fully linked in.
- */
- if (bp->b_flags & B_PAGING)
- panic("cannot reassign paging buffer");
-#endif
-
- s = splbio();
- /*
- * Delete from old vnode list, if on one.
- */
- if (bp->b_xflags & (BX_VNDIRTY | BX_VNCLEAN)) {
- if (bp->b_xflags & BX_VNDIRTY)
- listheadp = &bp->b_vp->v_dirtyblkhd;
- else
- listheadp = &bp->b_vp->v_cleanblkhd;
- TAILQ_REMOVE(listheadp, bp, b_vnbufs);
- bp->b_xflags &= ~(BX_VNDIRTY | BX_VNCLEAN);
- if (bp->b_vp != newvp) {
- vdrop(bp->b_vp);
- bp->b_vp = NULL; /* for clarification */
- }
- }
- /*
- * If dirty, put on list of dirty buffers; otherwise insert onto list
- * of clean buffers.
- */
- if (bp->b_flags & B_DELWRI) {
- struct buf *tbp;
-
- listheadp = &newvp->v_dirtyblkhd;
- if ((newvp->v_flag & VONWORKLST) == 0) {
- switch (newvp->v_type) {
- case VDIR:
- delay = dirdelay;
- break;
- case VCHR:
- case VBLK:
- if (newvp->v_specmountpoint != NULL) {
- delay = metadelay;
- break;
- }
- /* fall through */
- default:
- delay = filedelay;
- }
- vn_syncer_add_to_worklist(newvp, delay);
- }
- bp->b_xflags |= BX_VNDIRTY;
- tbp = TAILQ_FIRST(listheadp);
- if (tbp == NULL ||
- bp->b_lblkno == 0 ||
- (bp->b_lblkno > 0 && tbp->b_lblkno < 0) ||
- (bp->b_lblkno > 0 && bp->b_lblkno < tbp->b_lblkno)) {
- TAILQ_INSERT_HEAD(listheadp, bp, b_vnbufs);
- ++reassignbufsortgood;
- } else if (bp->b_lblkno < 0) {
- TAILQ_INSERT_TAIL(listheadp, bp, b_vnbufs);
- ++reassignbufsortgood;
- } else if (reassignbufmethod == 1) {
- /*
- * New sorting algorithm, only handle sequential case,
- * otherwise append to end (but before metadata)
- */
- if ((tbp = gbincore(newvp, bp->b_lblkno - 1)) != NULL &&
- (tbp->b_xflags & BX_VNDIRTY)) {
- /*
- * Found the best place to insert the buffer
- */
- TAILQ_INSERT_AFTER(listheadp, tbp, bp, b_vnbufs);
- ++reassignbufsortgood;
- } else {
- /*
- * Missed, append to end, but before meta-data.
- * We know that the head buffer in the list is
- * not meta-data due to prior conditionals.
- *
- * Indirect effects: NFS second stage write
- * tends to wind up here, giving maximum
- * distance between the unstable write and the
- * commit rpc.
- */
- tbp = TAILQ_LAST(listheadp, buflists);
- while (tbp && tbp->b_lblkno < 0)
- tbp = TAILQ_PREV(tbp, buflists, b_vnbufs);
- TAILQ_INSERT_AFTER(listheadp, tbp, bp, b_vnbufs);
- ++reassignbufsortbad;
- }
- } else {
- /*
- * Old sorting algorithm, scan queue and insert
- */
- struct buf *ttbp;
- while ((ttbp = TAILQ_NEXT(tbp, b_vnbufs)) &&
- (ttbp->b_lblkno < bp->b_lblkno)) {
- ++reassignbufloops;
- tbp = ttbp;
- }
- TAILQ_INSERT_AFTER(listheadp, tbp, bp, b_vnbufs);
- }
- } else {
- bp->b_xflags |= BX_VNCLEAN;
- TAILQ_INSERT_TAIL(&newvp->v_cleanblkhd, bp, b_vnbufs);
- if ((newvp->v_flag & VONWORKLST) &&
- TAILQ_EMPTY(&newvp->v_dirtyblkhd)) {
- newvp->v_flag &= ~VONWORKLST;
- LIST_REMOVE(newvp, v_synclist);
- }
- }
- if (bp->b_vp != newvp) {
- bp->b_vp = newvp;
- vhold(bp->b_vp);
- }
- splx(s);
-}
-
-/*
- * Create a vnode for a block device.
- * Used for mounting the root file system.
- */
-int
-bdevvp(dev, vpp)
- dev_t dev;
- struct vnode **vpp;
-{
- register struct vnode *vp;
- struct vnode *nvp;
- int error;
-
- if (dev == NODEV) {
- *vpp = NULLVP;
- return (ENXIO);
- }
- error = getnewvnode(VT_NON, (struct mount *)0, spec_vnodeop_p, &nvp);
- if (error) {
- *vpp = NULLVP;
- return (error);
- }
- vp = nvp;
- vp->v_type = VBLK;
- addalias(vp, dev);
- *vpp = vp;
- return (0);
-}
-
-/*
- * Add vnode to the alias list hung off the dev_t.
- *
- * The reason for this gunk is that multiple vnodes can reference
- * the same physical device, so checking vp->v_usecount to see
- * how many users there are is inadequate; the v_usecount for
- * the vnodes need to be accumulated. vcount() does that.
- */
-void
-addaliasu(nvp, nvp_rdev)
- struct vnode *nvp;
- udev_t nvp_rdev;
-{
-
- if (nvp->v_type != VBLK && nvp->v_type != VCHR)
- panic("addaliasu on non-special vnode");
- addalias(nvp, udev2dev(nvp_rdev, nvp->v_type == VBLK ? 1 : 0));
-}
-
-void
-addalias(nvp, dev)
- struct vnode *nvp;
- dev_t dev;
-{
-
- if (nvp->v_type != VBLK && nvp->v_type != VCHR)
- panic("addalias on non-special vnode");
-
- nvp->v_rdev = dev;
- simple_lock(&spechash_slock);
- SLIST_INSERT_HEAD(&dev->si_hlist, nvp, v_specnext);
- simple_unlock(&spechash_slock);
-}
-
-/*
- * Grab a particular vnode from the free list, increment its
- * reference count and lock it. The vnode lock bit is set if the
- * vnode is being eliminated in vgone. The process is awakened
- * when the transition is completed, and an error returned to
- * indicate that the vnode is no longer usable (possibly having
- * been changed to a new file system type).
- */
-int
-vget(vp, flags, p)
- register struct vnode *vp;
- int flags;
- struct proc *p;
-{
- int error;
-
- /*
- * If the vnode is in the process of being cleaned out for
- * another use, we wait for the cleaning to finish and then
- * return failure. Cleaning is determined by checking that
- * the VXLOCK flag is set.
- */
- if ((flags & LK_INTERLOCK) == 0) {
- simple_lock(&vp->v_interlock);
- }
- if (vp->v_flag & VXLOCK) {
- vp->v_flag |= VXWANT;
- simple_unlock(&vp->v_interlock);
- tsleep((caddr_t)vp, PINOD, "vget", 0);
- return (ENOENT);
- }
-
- vp->v_usecount++;
-
- if (VSHOULDBUSY(vp))
- vbusy(vp);
- if (flags & LK_TYPE_MASK) {
- if ((error = vn_lock(vp, flags | LK_INTERLOCK, p)) != 0) {
- /*
- * must expand vrele here because we do not want
- * to call VOP_INACTIVE if the reference count
- * drops back to zero since it was never really
- * active. We must remove it from the free list
- * before sleeping so that multiple processes do
- * not try to recycle it.
- */
- simple_lock(&vp->v_interlock);
- vp->v_usecount--;
- if (VSHOULDFREE(vp))
- vfree(vp);
- simple_unlock(&vp->v_interlock);
- }
- return (error);
- }
- simple_unlock(&vp->v_interlock);
- return (0);
-}
-
-void
-vref(struct vnode *vp)
-{
- simple_lock(&vp->v_interlock);
- vp->v_usecount++;
- simple_unlock(&vp->v_interlock);
-}
-
-/*
- * Vnode put/release.
- * If count drops to zero, call inactive routine and return to freelist.
- */
-void
-vrele(vp)
- struct vnode *vp;
-{
- struct proc *p = curproc; /* XXX */
-
- KASSERT(vp != NULL, ("vrele: null vp"));
-
- simple_lock(&vp->v_interlock);
-
- if (vp->v_usecount > 1) {
-
- vp->v_usecount--;
- simple_unlock(&vp->v_interlock);
-
- return;
- }
-
- if (vp->v_usecount == 1) {
-
- vp->v_usecount--;
- if (VSHOULDFREE(vp))
- vfree(vp);
- /*
- * If we are doing a vput, the node is already locked, and we must
- * call VOP_INACTIVE with the node locked. So, in the case of
- * vrele, we explicitly lock the vnode before calling VOP_INACTIVE.
- */
- if (vn_lock(vp, LK_EXCLUSIVE | LK_INTERLOCK, p) == 0) {
- VOP_INACTIVE(vp, p);
- }
-
- } else {
-#ifdef DIAGNOSTIC
- vprint("vrele: negative ref count", vp);
- simple_unlock(&vp->v_interlock);
-#endif
- panic("vrele: negative ref cnt");
- }
-}
-
-void
-vput(vp)
- struct vnode *vp;
-{
- struct proc *p = curproc; /* XXX */
-
- KASSERT(vp != NULL, ("vput: null vp"));
-
- simple_lock(&vp->v_interlock);
-
- if (vp->v_usecount > 1) {
-
- vp->v_usecount--;
- VOP_UNLOCK(vp, LK_INTERLOCK, p);
- return;
-
- }
-
- if (vp->v_usecount == 1) {
-
- vp->v_usecount--;
- if (VSHOULDFREE(vp))
- vfree(vp);
- /*
- * If we are doing a vput, the node is already locked, and we must
- * call VOP_INACTIVE with the node locked. So, in the case of
- * vrele, we explicitly lock the vnode before calling VOP_INACTIVE.
- */
- simple_unlock(&vp->v_interlock);
- VOP_INACTIVE(vp, p);
-
- } else {
-#ifdef DIAGNOSTIC
- vprint("vput: negative ref count", vp);
-#endif
- panic("vput: negative ref cnt");
- }
-}
-
-/*
- * Somebody doesn't want the vnode recycled.
- */
-void
-vhold(vp)
- register struct vnode *vp;
-{
- int s;
-
- s = splbio();
- vp->v_holdcnt++;
- if (VSHOULDBUSY(vp))
- vbusy(vp);
- splx(s);
-}
-
-/*
- * One less who cares about this vnode.
- */
-void
-vdrop(vp)
- register struct vnode *vp;
-{
- int s;
-
- s = splbio();
- if (vp->v_holdcnt <= 0)
- panic("vdrop: holdcnt");
- vp->v_holdcnt--;
- if (VSHOULDFREE(vp))
- vfree(vp);
- splx(s);
-}
-
-/*
- * Remove any vnodes in the vnode table belonging to mount point mp.
- *
- * If MNT_NOFORCE is specified, there should not be any active ones,
- * return error if any are found (nb: this is a user error, not a
- * system error). If MNT_FORCE is specified, detach any active vnodes
- * that are found.
- */
-#ifdef DIAGNOSTIC
-static int busyprt = 0; /* print out busy vnodes */
-SYSCTL_INT(_debug, OID_AUTO, busyprt, CTLFLAG_RW, &busyprt, 0, "");
-#endif
-
-int
-vflush(mp, skipvp, flags)
- struct mount *mp;
- struct vnode *skipvp;
- int flags;
-{
- struct proc *p = curproc; /* XXX */
- struct vnode *vp, *nvp;
- int busy = 0;
-
- simple_lock(&mntvnode_slock);
-loop:
- for (vp = LIST_FIRST(&mp->mnt_vnodelist); vp; vp = nvp) {
- /*
- * Make sure this vnode wasn't reclaimed in getnewvnode().
- * Start over if it has (it won't be on the list anymore).
- */
- if (vp->v_mount != mp)
- goto loop;
- nvp = LIST_NEXT(vp, v_mntvnodes);
- /*
- * Skip over a selected vnode.
- */
- if (vp == skipvp)
- continue;
-
- simple_lock(&vp->v_interlock);
- /*
- * Skip over a vnodes marked VSYSTEM.
- */
- if ((flags & SKIPSYSTEM) && (vp->v_flag & VSYSTEM)) {
- simple_unlock(&vp->v_interlock);
- continue;
- }
- /*
- * If WRITECLOSE is set, only flush out regular file vnodes
- * open for writing.
- */
- if ((flags & WRITECLOSE) &&
- (vp->v_writecount == 0 || vp->v_type != VREG)) {
- simple_unlock(&vp->v_interlock);
- continue;
- }
-
- /*
- * With v_usecount == 0, all we need to do is clear out the
- * vnode data structures and we are done.
- */
- if (vp->v_usecount == 0) {
- simple_unlock(&mntvnode_slock);
- vgonel(vp, p);
- simple_lock(&mntvnode_slock);
- continue;
- }
-
- /*
- * If FORCECLOSE is set, forcibly close the vnode. For block
- * or character devices, revert to an anonymous device. For
- * all other files, just kill them.
- */
- if (flags & FORCECLOSE) {
- simple_unlock(&mntvnode_slock);
- if (vp->v_type != VBLK && vp->v_type != VCHR) {
- vgonel(vp, p);
- } else {
- vclean(vp, 0, p);
- vp->v_op = spec_vnodeop_p;
- insmntque(vp, (struct mount *) 0);
- }
- simple_lock(&mntvnode_slock);
- continue;
- }
-#ifdef DIAGNOSTIC
- if (busyprt)
- vprint("vflush: busy vnode", vp);
-#endif
- simple_unlock(&vp->v_interlock);
- busy++;
- }
- simple_unlock(&mntvnode_slock);
- if (busy)
- return (EBUSY);
- return (0);
-}
-
-/*
- * Disassociate the underlying file system from a vnode.
- */
-static void
-vclean(vp, flags, p)
- struct vnode *vp;
- int flags;
- struct proc *p;
-{
- int active;
- vm_object_t obj;
-
- /*
- * Check to see if the vnode is in use. If so we have to reference it
- * before we clean it out so that its count cannot fall to zero and
- * generate a race against ourselves to recycle it.
- */
- if ((active = vp->v_usecount))
- vp->v_usecount++;
-
- /*
- * Prevent the vnode from being recycled or brought into use while we
- * clean it out.
- */
- if (vp->v_flag & VXLOCK)
- panic("vclean: deadlock");
- vp->v_flag |= VXLOCK;
- /*
- * Even if the count is zero, the VOP_INACTIVE routine may still
- * have the object locked while it cleans it out. The VOP_LOCK
- * ensures that the VOP_INACTIVE routine is done with its work.
- * For active vnodes, it ensures that no other activity can
- * occur while the underlying object is being cleaned out.
- */
- VOP_LOCK(vp, LK_DRAIN | LK_INTERLOCK, p);
-
- /*
- * Clean out any buffers associated with the vnode.
- */
- vinvalbuf(vp, V_SAVE, NOCRED, p, 0, 0);
- if ((obj = vp->v_object) != NULL) {
- if (obj->ref_count == 0) {
- /*
- * vclean() may be called twice. The first time removes the
- * primary reference to the object, the second time goes
- * one further and is a special-case to terminate the object.
- */
- vm_object_terminate(obj);
- } else {
- /*
- * Woe to the process that tries to page now :-).
- */
- vm_pager_deallocate(obj);
- }
- }
-
- /*
- * If purging an active vnode, it must be closed and
- * deactivated before being reclaimed. Note that the
- * VOP_INACTIVE will unlock the vnode.
- */
- if (active) {
- if (flags & DOCLOSE)
- VOP_CLOSE(vp, FNONBLOCK, NOCRED, p);
- VOP_INACTIVE(vp, p);
- } else {
- /*
- * Any other processes trying to obtain this lock must first
- * wait for VXLOCK to clear, then call the new lock operation.
- */
- VOP_UNLOCK(vp, 0, p);
- }
- /*
- * Reclaim the vnode.
- */
- if (VOP_RECLAIM(vp, p))
- panic("vclean: cannot reclaim");
-
- if (active) {
- /*
- * Inline copy of vrele() since VOP_INACTIVE
- * has already been called.
- */
- simple_lock(&vp->v_interlock);
- if (--vp->v_usecount <= 0) {
-#ifdef DIAGNOSTIC
- if (vp->v_usecount < 0 || vp->v_writecount != 0) {
- vprint("vclean: bad ref count", vp);
- panic("vclean: ref cnt");
- }
-#endif
- vfree(vp);
- }
- simple_unlock(&vp->v_interlock);
- }
-
- cache_purge(vp);
- if (vp->v_vnlock) {
- FREE(vp->v_vnlock, M_VNODE);
- vp->v_vnlock = NULL;
- }
-
- if (VSHOULDFREE(vp))
- vfree(vp);
-
- /*
- * Done with purge, notify sleepers of the grim news.
- */
- vp->v_op = dead_vnodeop_p;
- vn_pollgone(vp);
- vp->v_tag = VT_NON;
- vp->v_flag &= ~VXLOCK;
- if (vp->v_flag & VXWANT) {
- vp->v_flag &= ~VXWANT;
- wakeup((caddr_t) vp);
- }
-}
-
-/*
- * Eliminate all activity associated with the requested vnode
- * and with all vnodes aliased to the requested vnode.
- */
-int
-vop_revoke(ap)
- struct vop_revoke_args /* {
- struct vnode *a_vp;
- int a_flags;
- } */ *ap;
-{
- struct vnode *vp, *vq;
- dev_t dev;
-
- KASSERT((ap->a_flags & REVOKEALL) != 0, ("vop_revoke"));
-
- vp = ap->a_vp;
- /*
- * If a vgone (or vclean) is already in progress,
- * wait until it is done and return.
- */
- if (vp->v_flag & VXLOCK) {
- vp->v_flag |= VXWANT;
- simple_unlock(&vp->v_interlock);
- tsleep((caddr_t)vp, PINOD, "vop_revokeall", 0);
- return (0);
- }
- dev = vp->v_rdev;
- for (;;) {
- simple_lock(&spechash_slock);
- vq = SLIST_FIRST(&dev->si_hlist);
- simple_unlock(&spechash_slock);
- if (!vq)
- break;
- vgone(vq);
- }
- return (0);
-}
-
-/*
- * Recycle an unused vnode to the front of the free list.
- * Release the passed interlock if the vnode will be recycled.
- */
-int
-vrecycle(vp, inter_lkp, p)
- struct vnode *vp;
- struct simplelock *inter_lkp;
- struct proc *p;
-{
-
- simple_lock(&vp->v_interlock);
- if (vp->v_usecount == 0) {
- if (inter_lkp) {
- simple_unlock(inter_lkp);
- }
- vgonel(vp, p);
- return (1);
- }
- simple_unlock(&vp->v_interlock);
- return (0);
-}
-
-/*
- * Eliminate all activity associated with a vnode
- * in preparation for reuse.
- */
-void
-vgone(vp)
- register struct vnode *vp;
-{
- struct proc *p = curproc; /* XXX */
-
- simple_lock(&vp->v_interlock);
- vgonel(vp, p);
-}
-
-/*
- * vgone, with the vp interlock held.
- */
-void
-vgonel(vp, p)
- struct vnode *vp;
- struct proc *p;
-{
- int s;
-
- /*
- * If a vgone (or vclean) is already in progress,
- * wait until it is done and return.
- */
- if (vp->v_flag & VXLOCK) {
- vp->v_flag |= VXWANT;
- simple_unlock(&vp->v_interlock);
- tsleep((caddr_t)vp, PINOD, "vgone", 0);
- return;
- }
-
- /*
- * Clean out the filesystem specific data.
- */
- vclean(vp, DOCLOSE, p);
- simple_lock(&vp->v_interlock);
-
- /*
- * Delete from old mount point vnode list, if on one.
- */
- if (vp->v_mount != NULL)
- insmntque(vp, (struct mount *)0);
- /*
- * If special device, remove it from special device alias list
- * if it is on one.
- */
- if ((vp->v_type == VBLK || vp->v_type == VCHR) && vp->v_rdev != NULL) {
- simple_lock(&spechash_slock);
- SLIST_REMOVE(&vp->v_hashchain, vp, vnode, v_specnext);
- freedev(vp->v_rdev);
- simple_unlock(&spechash_slock);
- vp->v_rdev = NULL;
- }
-
- /*
- * If it is on the freelist and not already at the head,
- * move it to the head of the list. The test of the back
- * pointer and the reference count of zero is because
- * it will be removed from the free list by getnewvnode,
- * but will not have its reference count incremented until
- * after calling vgone. If the reference count were
- * incremented first, vgone would (incorrectly) try to
- * close the previous instance of the underlying object.
- */
- if (vp->v_usecount == 0 && !(vp->v_flag & VDOOMED)) {
- s = splbio();
- simple_lock(&vnode_free_list_slock);
- if (vp->v_flag & VFREE) {
- TAILQ_REMOVE(&vnode_free_list, vp, v_freelist);
- } else if (vp->v_flag & VTBFREE) {
- TAILQ_REMOVE(&vnode_tobefree_list, vp, v_freelist);
- vp->v_flag &= ~VTBFREE;
- freevnodes++;
- } else
- freevnodes++;
- vp->v_flag |= VFREE;
- TAILQ_INSERT_HEAD(&vnode_free_list, vp, v_freelist);
- simple_unlock(&vnode_free_list_slock);
- splx(s);
- }
-
- vp->v_type = VBAD;
- simple_unlock(&vp->v_interlock);
-}
-
-/*
- * Lookup a vnode by device number.
- */
-int
-vfinddev(dev, type, vpp)
- dev_t dev;
- enum vtype type;
- struct vnode **vpp;
-{
- struct vnode *vp;
-
- simple_lock(&spechash_slock);
- SLIST_FOREACH(vp, &dev->si_hlist, v_specnext) {
- if (type == vp->v_type) {
- *vpp = vp;
- simple_unlock(&spechash_slock);
- return (1);
- }
- }
- simple_unlock(&spechash_slock);
- return (0);
-}
-
-/*
- * Calculate the total number of references to a special device.
- */
-int
-vcount(vp)
- struct vnode *vp;
-{
- struct vnode *vq;
- int count;
-
- count = 0;
- simple_lock(&spechash_slock);
- SLIST_FOREACH(vq, &vp->v_hashchain, v_specnext)
- count += vq->v_usecount;
- simple_unlock(&spechash_slock);
- return (count);
-}
-
-/*
- * Same as above, but using the dev_t as argument
- */
-
-int
-count_dev(dev)
- dev_t dev;
-{
- struct vnode *vp;
-
- vp = SLIST_FIRST(&dev->si_hlist);
- if (vp == NULL)
- return (0);
- return(vcount(vp));
-}
-
-/*
- * Print out a description of a vnode.
- */
-static char *typename[] =
-{"VNON", "VREG", "VDIR", "VBLK", "VCHR", "VLNK", "VSOCK", "VFIFO", "VBAD"};
-
-void
-vprint(label, vp)
- char *label;
- struct vnode *vp;
-{
- char buf[96];
-
- if (label != NULL)
- printf("%s: %p: ", label, (void *)vp);
- else
- printf("%p: ", (void *)vp);
- printf("type %s, usecount %d, writecount %d, refcount %d,",
- typename[vp->v_type], vp->v_usecount, vp->v_writecount,
- vp->v_holdcnt);
- buf[0] = '\0';
- if (vp->v_flag & VROOT)
- strcat(buf, "|VROOT");
- if (vp->v_flag & VTEXT)
- strcat(buf, "|VTEXT");
- if (vp->v_flag & VSYSTEM)
- strcat(buf, "|VSYSTEM");
- if (vp->v_flag & VXLOCK)
- strcat(buf, "|VXLOCK");
- if (vp->v_flag & VXWANT)
- strcat(buf, "|VXWANT");
- if (vp->v_flag & VBWAIT)
- strcat(buf, "|VBWAIT");
- if (vp->v_flag & VDOOMED)
- strcat(buf, "|VDOOMED");
- if (vp->v_flag & VFREE)
- strcat(buf, "|VFREE");
- if (vp->v_flag & VOBJBUF)
- strcat(buf, "|VOBJBUF");
- if (buf[0] != '\0')
- printf(" flags (%s)", &buf[1]);
- if (vp->v_data == NULL) {
- printf("\n");
- } else {
- printf("\n\t");
- VOP_PRINT(vp);
- }
-}
-
-#ifdef DDB
-#include <ddb/ddb.h>
-/*
- * List all of the locked vnodes in the system.
- * Called when debugging the kernel.
- */
-DB_SHOW_COMMAND(lockedvnodes, lockedvnodes)
-{
- struct proc *p = curproc; /* XXX */
- struct mount *mp, *nmp;
- struct vnode *vp;
-
- printf("Locked vnodes\n");
- simple_lock(&mountlist_slock);
- for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) {
- if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, p)) {
- nmp = TAILQ_NEXT(mp, mnt_list);
- continue;
- }
- LIST_FOREACH(vp, &mp->mnt_vnodelist, v_mntvnodes) {
- if (VOP_ISLOCKED(vp, NULL))
- vprint((char *)0, vp);
- }
- simple_lock(&mountlist_slock);
- nmp = TAILQ_NEXT(mp, mnt_list);
- vfs_unbusy(mp, p);
- }
- simple_unlock(&mountlist_slock);
-}
-#endif
-
-/*
- * Top level filesystem related information gathering.
- */
-static int sysctl_ovfs_conf __P(SYSCTL_HANDLER_ARGS);
-
-static int
-vfs_sysctl SYSCTL_HANDLER_ARGS
-{
- int *name = (int *)arg1 - 1; /* XXX */
- u_int namelen = arg2 + 1; /* XXX */
- struct vfsconf *vfsp;
-
-#if 1 || defined(COMPAT_PRELITE2)
- /* Resolve ambiguity between VFS_VFSCONF and VFS_GENERIC. */
- if (namelen == 1)
- return (sysctl_ovfs_conf(oidp, arg1, arg2, req));
-#endif
-
-#ifdef notyet
- /* all sysctl names at this level are at least name and field */
- if (namelen < 2)
- return (ENOTDIR); /* overloaded */
- if (name[0] != VFS_GENERIC) {
- for (vfsp = vfsconf; vfsp; vfsp = vfsp->vfc_next)
- if (vfsp->vfc_typenum == name[0])
- break;
- if (vfsp == NULL)
- return (EOPNOTSUPP);
- return ((*vfsp->vfc_vfsops->vfs_sysctl)(&name[1], namelen - 1,
- oldp, oldlenp, newp, newlen, p));
- }
-#endif
- switch (name[1]) {
- case VFS_MAXTYPENUM:
- if (namelen != 2)
- return (ENOTDIR);
- return (SYSCTL_OUT(req, &maxvfsconf, sizeof(int)));
- case VFS_CONF:
- if (namelen != 3)
- return (ENOTDIR); /* overloaded */
- for (vfsp = vfsconf; vfsp; vfsp = vfsp->vfc_next)
- if (vfsp->vfc_typenum == name[2])
- break;
- if (vfsp == NULL)
- return (EOPNOTSUPP);
- return (SYSCTL_OUT(req, vfsp, sizeof *vfsp));
- }
- return (EOPNOTSUPP);
-}
-
-SYSCTL_NODE(_vfs, VFS_GENERIC, generic, CTLFLAG_RD, vfs_sysctl,
- "Generic filesystem");
-
-#if 1 || defined(COMPAT_PRELITE2)
-
-static int
-sysctl_ovfs_conf SYSCTL_HANDLER_ARGS
-{
- int error;
- struct vfsconf *vfsp;
- struct ovfsconf ovfs;
-
- for (vfsp = vfsconf; vfsp; vfsp = vfsp->vfc_next) {
- ovfs.vfc_vfsops = vfsp->vfc_vfsops; /* XXX used as flag */
- strcpy(ovfs.vfc_name, vfsp->vfc_name);
- ovfs.vfc_index = vfsp->vfc_typenum;
- ovfs.vfc_refcount = vfsp->vfc_refcount;
- ovfs.vfc_flags = vfsp->vfc_flags;
- error = SYSCTL_OUT(req, &ovfs, sizeof ovfs);
- if (error)
- return error;
- }
- return 0;
-}
-
-#endif /* 1 || COMPAT_PRELITE2 */
-
-#if 0
-#define KINFO_VNODESLOP 10
-/*
- * Dump vnode list (via sysctl).
- * Copyout address of vnode followed by vnode.
- */
-/* ARGSUSED */
-static int
-sysctl_vnode SYSCTL_HANDLER_ARGS
-{
- struct proc *p = curproc; /* XXX */
- struct mount *mp, *nmp;
- struct vnode *nvp, *vp;
- int error;
-
-#define VPTRSZ sizeof (struct vnode *)
-#define VNODESZ sizeof (struct vnode)
-
- req->lock = 0;
- if (!req->oldptr) /* Make an estimate */
- return (SYSCTL_OUT(req, 0,
- (numvnodes + KINFO_VNODESLOP) * (VPTRSZ + VNODESZ)));
-
- simple_lock(&mountlist_slock);
- for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) {
- if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, p)) {
- nmp = TAILQ_NEXT(mp, mnt_list);
- continue;
- }
-again:
- simple_lock(&mntvnode_slock);
- for (vp = LIST_FIRST(&mp->mnt_vnodelist);
- vp != NULL;
- vp = nvp) {
- /*
- * Check that the vp is still associated with
- * this filesystem. RACE: could have been
- * recycled onto the same filesystem.
- */
- if (vp->v_mount != mp) {
- simple_unlock(&mntvnode_slock);
- goto again;
- }
- nvp = LIST_NEXT(vp, v_mntvnodes);
- simple_unlock(&mntvnode_slock);
- if ((error = SYSCTL_OUT(req, &vp, VPTRSZ)) ||
- (error = SYSCTL_OUT(req, vp, VNODESZ)))
- return (error);
- simple_lock(&mntvnode_slock);
- }
- simple_unlock(&mntvnode_slock);
- simple_lock(&mountlist_slock);
- nmp = TAILQ_NEXT(mp, mnt_list);
- vfs_unbusy(mp, p);
- }
- simple_unlock(&mountlist_slock);
-
- return (0);
-}
-#endif
-
-/*
- * XXX
- * Exporting the vnode list on large systems causes them to crash.
- * Exporting the vnode list on medium systems causes sysctl to coredump.
- */
-#if 0
-SYSCTL_PROC(_kern, KERN_VNODE, vnode, CTLTYPE_OPAQUE|CTLFLAG_RD,
- 0, 0, sysctl_vnode, "S,vnode", "");
-#endif
-
-/*
- * Check to see if a filesystem is mounted on a block device.
- */
-int
-vfs_mountedon(vp)
- struct vnode *vp;
-{
-
- if (vp->v_specmountpoint != NULL)
- return (EBUSY);
- return (0);
-}
-
-/*
- * Unmount all filesystems. The list is traversed in reverse order
- * of mounting to avoid dependencies.
- */
-void
-vfs_unmountall()
-{
- struct mount *mp;
- struct proc *p;
- int error;
-
- if (curproc != NULL)
- p = curproc;
- else
- p = initproc; /* XXX XXX should this be proc0? */
- /*
- * Since this only runs when rebooting, it is not interlocked.
- */
- while(!TAILQ_EMPTY(&mountlist)) {
- mp = TAILQ_LAST(&mountlist, mntlist);
- error = dounmount(mp, MNT_FORCE, p);
- if (error) {
- TAILQ_REMOVE(&mountlist, mp, mnt_list);
- printf("unmount of %s failed (",
- mp->mnt_stat.f_mntonname);
- if (error == EBUSY)
- printf("BUSY)\n");
- else
- printf("%d)\n", error);
- } else {
- /* The unmount has removed mp from the mountlist */
- }
- }
-}
-
-/*
- * Build hash lists of net addresses and hang them off the mount point.
- * Called by ufs_mount() to set up the lists of export addresses.
- */
-static int
-vfs_hang_addrlist(mp, nep, argp)
- struct mount *mp;
- struct netexport *nep;
- struct export_args *argp;
-{
- register struct netcred *np;
- register struct radix_node_head *rnh;
- register int i;
- struct radix_node *rn;
- struct sockaddr *saddr, *smask = 0;
- struct domain *dom;
- int error;
-
- if (argp->ex_addrlen == 0) {
- if (mp->mnt_flag & MNT_DEFEXPORTED)
- return (EPERM);
- np = &nep->ne_defexported;
- np->netc_exflags = argp->ex_flags;
- np->netc_anon = argp->ex_anon;
- np->netc_anon.cr_ref = 1;
- mp->mnt_flag |= MNT_DEFEXPORTED;
- return (0);
- }
- i = sizeof(struct netcred) + argp->ex_addrlen + argp->ex_masklen;
- np = (struct netcred *) malloc(i, M_NETADDR, M_WAITOK);
- bzero((caddr_t) np, i);
- saddr = (struct sockaddr *) (np + 1);
- if ((error = copyin(argp->ex_addr, (caddr_t) saddr, argp->ex_addrlen)))
- goto out;
- if (saddr->sa_len > argp->ex_addrlen)
- saddr->sa_len = argp->ex_addrlen;
- if (argp->ex_masklen) {
- smask = (struct sockaddr *) ((caddr_t) saddr + argp->ex_addrlen);
- error = copyin(argp->ex_mask, (caddr_t) smask, argp->ex_masklen);
- if (error)
- goto out;
- if (smask->sa_len > argp->ex_masklen)
- smask->sa_len = argp->ex_masklen;
- }
- i = saddr->sa_family;
- if ((rnh = nep->ne_rtable[i]) == 0) {
- /*
- * Seems silly to initialize every AF when most are not used,
- * do so on demand here
- */
- for (dom = domains; dom; dom = dom->dom_next)
- if (dom->dom_family == i && dom->dom_rtattach) {
- dom->dom_rtattach((void **) &nep->ne_rtable[i],
- dom->dom_rtoffset);
- break;
- }
- if ((rnh = nep->ne_rtable[i]) == 0) {
- error = ENOBUFS;
- goto out;
- }
- }
- rn = (*rnh->rnh_addaddr) ((caddr_t) saddr, (caddr_t) smask, rnh,
- np->netc_rnodes);
- if (rn == 0 || np != (struct netcred *) rn) { /* already exists */
- error = EPERM;
- goto out;
- }
- np->netc_exflags = argp->ex_flags;
- np->netc_anon = argp->ex_anon;
- np->netc_anon.cr_ref = 1;
- return (0);
-out:
- free(np, M_NETADDR);
- return (error);
-}
-
-/* ARGSUSED */
-static int
-vfs_free_netcred(rn, w)
- struct radix_node *rn;
- void *w;
-{
- register struct radix_node_head *rnh = (struct radix_node_head *) w;
-
- (*rnh->rnh_deladdr) (rn->rn_key, rn->rn_mask, rnh);
- free((caddr_t) rn, M_NETADDR);
- return (0);
-}
-
-/*
- * Free the net address hash lists that are hanging off the mount points.
- */
-static void
-vfs_free_addrlist(nep)
- struct netexport *nep;
-{
- register int i;
- register struct radix_node_head *rnh;
-
- for (i = 0; i <= AF_MAX; i++)
- if ((rnh = nep->ne_rtable[i])) {
- (*rnh->rnh_walktree) (rnh, vfs_free_netcred,
- (caddr_t) rnh);
- free((caddr_t) rnh, M_RTABLE);
- nep->ne_rtable[i] = 0;
- }
-}
-
-int
-vfs_export(mp, nep, argp)
- struct mount *mp;
- struct netexport *nep;
- struct export_args *argp;
-{
- int error;
-
- if (argp->ex_flags & MNT_DELEXPORT) {
- if (mp->mnt_flag & MNT_EXPUBLIC) {
- vfs_setpublicfs(NULL, NULL, NULL);
- mp->mnt_flag &= ~MNT_EXPUBLIC;
- }
- vfs_free_addrlist(nep);
- mp->mnt_flag &= ~(MNT_EXPORTED | MNT_DEFEXPORTED);
- }
- if (argp->ex_flags & MNT_EXPORTED) {
- if (argp->ex_flags & MNT_EXPUBLIC) {
- if ((error = vfs_setpublicfs(mp, nep, argp)) != 0)
- return (error);
- mp->mnt_flag |= MNT_EXPUBLIC;
- }
- if ((error = vfs_hang_addrlist(mp, nep, argp)))
- return (error);
- mp->mnt_flag |= MNT_EXPORTED;
- }
- return (0);
-}
-
-
-/*
- * Set the publicly exported filesystem (WebNFS). Currently, only
- * one public filesystem is possible in the spec (RFC 2054 and 2055)
- */
-int
-vfs_setpublicfs(mp, nep, argp)
- struct mount *mp;
- struct netexport *nep;
- struct export_args *argp;
-{
- int error;
- struct vnode *rvp;
- char *cp;
-
- /*
- * mp == NULL -> invalidate the current info, the FS is
- * no longer exported. May be called from either vfs_export
- * or unmount, so check if it hasn't already been done.
- */
- if (mp == NULL) {
- if (nfs_pub.np_valid) {
- nfs_pub.np_valid = 0;
- if (nfs_pub.np_index != NULL) {
- FREE(nfs_pub.np_index, M_TEMP);
- nfs_pub.np_index = NULL;
- }
- }
- return (0);
- }
-
- /*
- * Only one allowed at a time.
- */
- if (nfs_pub.np_valid != 0 && mp != nfs_pub.np_mount)
- return (EBUSY);
-
- /*
- * Get real filehandle for root of exported FS.
- */
- bzero((caddr_t)&nfs_pub.np_handle, sizeof(nfs_pub.np_handle));
- nfs_pub.np_handle.fh_fsid = mp->mnt_stat.f_fsid;
-
- if ((error = VFS_ROOT(mp, &rvp)))
- return (error);
-
- if ((error = VFS_VPTOFH(rvp, &nfs_pub.np_handle.fh_fid)))
- return (error);
-
- vput(rvp);
-
- /*
- * If an indexfile was specified, pull it in.
- */
- if (argp->ex_indexfile != NULL) {
- MALLOC(nfs_pub.np_index, char *, MAXNAMLEN + 1, M_TEMP,
- M_WAITOK);
- error = copyinstr(argp->ex_indexfile, nfs_pub.np_index,
- MAXNAMLEN, (size_t *)0);
- if (!error) {
- /*
- * Check for illegal filenames.
- */
- for (cp = nfs_pub.np_index; *cp; cp++) {
- if (*cp == '/') {
- error = EINVAL;
- break;
- }
- }
- }
- if (error) {
- FREE(nfs_pub.np_index, M_TEMP);
- return (error);
- }
- }
-
- nfs_pub.np_mount = mp;
- nfs_pub.np_valid = 1;
- return (0);
-}
-
-struct netcred *
-vfs_export_lookup(mp, nep, nam)
- register struct mount *mp;
- struct netexport *nep;
- struct sockaddr *nam;
-{
- register struct netcred *np;
- register struct radix_node_head *rnh;
- struct sockaddr *saddr;
-
- np = NULL;
- if (mp->mnt_flag & MNT_EXPORTED) {
- /*
- * Lookup in the export list first.
- */
- if (nam != NULL) {
- saddr = nam;
- rnh = nep->ne_rtable[saddr->sa_family];
- if (rnh != NULL) {
- np = (struct netcred *)
- (*rnh->rnh_matchaddr)((caddr_t)saddr,
- rnh);
- if (np && np->netc_rnodes->rn_flags & RNF_ROOT)
- np = NULL;
- }
- }
- /*
- * If no address match, use the default if it exists.
- */
- if (np == NULL && mp->mnt_flag & MNT_DEFEXPORTED)
- np = &nep->ne_defexported;
- }
- return (np);
-}
-
-/*
- * perform msync on all vnodes under a mount point
- * the mount point must be locked.
- */
-void
-vfs_msync(struct mount *mp, int flags) {
- struct vnode *vp, *nvp;
- struct vm_object *obj;
- int anyio, tries;
-
- tries = 5;
-loop:
- anyio = 0;
- for (vp = LIST_FIRST(&mp->mnt_vnodelist); vp != NULL; vp = nvp) {
-
- nvp = LIST_NEXT(vp, v_mntvnodes);
-
- if (vp->v_mount != mp) {
- goto loop;
- }
-
- if (vp->v_flag & VXLOCK) /* XXX: what if MNT_WAIT? */
- continue;
-
- if (flags != MNT_WAIT) {
- obj = vp->v_object;
- if (obj == NULL || (obj->flags & OBJ_MIGHTBEDIRTY) == 0)
- continue;
- if (VOP_ISLOCKED(vp, NULL))
- continue;
- }
-
- simple_lock(&vp->v_interlock);
- if (vp->v_object &&
- (vp->v_object->flags & OBJ_MIGHTBEDIRTY)) {
- if (!vget(vp,
- LK_INTERLOCK | LK_EXCLUSIVE | LK_RETRY | LK_NOOBJ, curproc)) {
- if (vp->v_object) {
- vm_object_page_clean(vp->v_object, 0, 0, flags == MNT_WAIT ? OBJPC_SYNC : OBJPC_NOSYNC);
- anyio = 1;
- }
- vput(vp);
- }
- } else {
- simple_unlock(&vp->v_interlock);
- }
- }
- if (anyio && (--tries > 0))
- goto loop;
-}
-
-/*
- * Create the VM object needed for VMIO and mmap support. This
- * is done for all VREG files in the system. Some filesystems might
- * afford the additional metadata buffering capability of the
- * VMIO code by making the device node be VMIO mode also.
- *
- * vp must be locked when vfs_object_create is called.
- */
-int
-vfs_object_create(vp, p, cred)
- struct vnode *vp;
- struct proc *p;
- struct ucred *cred;
-{
- struct vattr vat;
- vm_object_t object;
- int error = 0;
-
- if (!vn_isdisk(vp, NULL) && vn_canvmio(vp) == FALSE)
- return 0;
-
-retry:
- if ((object = vp->v_object) == NULL) {
- if (vp->v_type == VREG || vp->v_type == VDIR) {
- if ((error = VOP_GETATTR(vp, &vat, cred, p)) != 0)
- goto retn;
- object = vnode_pager_alloc(vp, vat.va_size, 0, 0);
- } else if (devsw(vp->v_rdev) != NULL) {
- /*
- * This simply allocates the biggest object possible
- * for a disk vnode. This should be fixed, but doesn't
- * cause any problems (yet).
- */
- object = vnode_pager_alloc(vp, IDX_TO_OFF(INT_MAX), 0, 0);
- } else {
- goto retn;
- }
- /*
- * Dereference the reference we just created. This assumes
- * that the object is associated with the vp.
- */
- object->ref_count--;
- vp->v_usecount--;
- } else {
- if (object->flags & OBJ_DEAD) {
- VOP_UNLOCK(vp, 0, p);
- tsleep(object, PVM, "vodead", 0);
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
- goto retry;
- }
- }
-
- KASSERT(vp->v_object != NULL, ("vfs_object_create: NULL object"));
- vp->v_flag |= VOBJBUF;
-
-retn:
- return error;
-}
-
-static void
-vfree(vp)
- struct vnode *vp;
-{
- int s;
-
- s = splbio();
- simple_lock(&vnode_free_list_slock);
- if (vp->v_flag & VTBFREE) {
- TAILQ_REMOVE(&vnode_tobefree_list, vp, v_freelist);
- vp->v_flag &= ~VTBFREE;
- }
- if (vp->v_flag & VAGE) {
- TAILQ_INSERT_HEAD(&vnode_free_list, vp, v_freelist);
- } else {
- TAILQ_INSERT_TAIL(&vnode_free_list, vp, v_freelist);
- }
- freevnodes++;
- simple_unlock(&vnode_free_list_slock);
- vp->v_flag &= ~VAGE;
- vp->v_flag |= VFREE;
- splx(s);
-}
-
-void
-vbusy(vp)
- struct vnode *vp;
-{
- int s;
-
- s = splbio();
- simple_lock(&vnode_free_list_slock);
- if (vp->v_flag & VTBFREE) {
- TAILQ_REMOVE(&vnode_tobefree_list, vp, v_freelist);
- vp->v_flag &= ~VTBFREE;
- } else {
- TAILQ_REMOVE(&vnode_free_list, vp, v_freelist);
- freevnodes--;
- }
- simple_unlock(&vnode_free_list_slock);
- vp->v_flag &= ~(VFREE|VAGE);
- splx(s);
-}
-
-/*
- * Record a process's interest in events which might happen to
- * a vnode. Because poll uses the historic select-style interface
- * internally, this routine serves as both the ``check for any
- * pending events'' and the ``record my interest in future events''
- * functions. (These are done together, while the lock is held,
- * to avoid race conditions.)
- */
-int
-vn_pollrecord(vp, p, events)
- struct vnode *vp;
- struct proc *p;
- short events;
-{
- simple_lock(&vp->v_pollinfo.vpi_lock);
- if (vp->v_pollinfo.vpi_revents & events) {
- /*
- * This leaves events we are not interested
- * in available for the other process which
- * which presumably had requested them
- * (otherwise they would never have been
- * recorded).
- */
- events &= vp->v_pollinfo.vpi_revents;
- vp->v_pollinfo.vpi_revents &= ~events;
-
- simple_unlock(&vp->v_pollinfo.vpi_lock);
- return events;
- }
- vp->v_pollinfo.vpi_events |= events;
- selrecord(p, &vp->v_pollinfo.vpi_selinfo);
- simple_unlock(&vp->v_pollinfo.vpi_lock);
- return 0;
-}
-
-/*
- * Note the occurrence of an event. If the VN_POLLEVENT macro is used,
- * it is possible for us to miss an event due to race conditions, but
- * that condition is expected to be rare, so for the moment it is the
- * preferred interface.
- */
-void
-vn_pollevent(vp, events)
- struct vnode *vp;
- short events;
-{
- simple_lock(&vp->v_pollinfo.vpi_lock);
- if (vp->v_pollinfo.vpi_events & events) {
- /*
- * We clear vpi_events so that we don't
- * call selwakeup() twice if two events are
- * posted before the polling process(es) is
- * awakened. This also ensures that we take at
- * most one selwakeup() if the polling process
- * is no longer interested. However, it does
- * mean that only one event can be noticed at
- * a time. (Perhaps we should only clear those
- * event bits which we note?) XXX
- */
- vp->v_pollinfo.vpi_events = 0; /* &= ~events ??? */
- vp->v_pollinfo.vpi_revents |= events;
- selwakeup(&vp->v_pollinfo.vpi_selinfo);
- }
- simple_unlock(&vp->v_pollinfo.vpi_lock);
-}
-
-/*
- * Wake up anyone polling on vp because it is being revoked.
- * This depends on dead_poll() returning POLLHUP for correct
- * behavior.
- */
-void
-vn_pollgone(vp)
- struct vnode *vp;
-{
- simple_lock(&vp->v_pollinfo.vpi_lock);
- if (vp->v_pollinfo.vpi_events) {
- vp->v_pollinfo.vpi_events = 0;
- selwakeup(&vp->v_pollinfo.vpi_selinfo);
- }
- simple_unlock(&vp->v_pollinfo.vpi_lock);
-}
-
-
-
-/*
- * Routine to create and manage a filesystem syncer vnode.
- */
-#define sync_close ((int (*) __P((struct vop_close_args *)))nullop)
-static int sync_fsync __P((struct vop_fsync_args *));
-static int sync_inactive __P((struct vop_inactive_args *));
-static int sync_reclaim __P((struct vop_reclaim_args *));
-#define sync_lock ((int (*) __P((struct vop_lock_args *)))vop_nolock)
-#define sync_unlock ((int (*) __P((struct vop_unlock_args *)))vop_nounlock)
-static int sync_print __P((struct vop_print_args *));
-#define sync_islocked ((int(*) __P((struct vop_islocked_args *)))vop_noislocked)
-
-static vop_t **sync_vnodeop_p;
-static struct vnodeopv_entry_desc sync_vnodeop_entries[] = {
- { &vop_default_desc, (vop_t *) vop_eopnotsupp },
- { &vop_close_desc, (vop_t *) sync_close }, /* close */
- { &vop_fsync_desc, (vop_t *) sync_fsync }, /* fsync */
- { &vop_inactive_desc, (vop_t *) sync_inactive }, /* inactive */
- { &vop_reclaim_desc, (vop_t *) sync_reclaim }, /* reclaim */
- { &vop_lock_desc, (vop_t *) sync_lock }, /* lock */
- { &vop_unlock_desc, (vop_t *) sync_unlock }, /* unlock */
- { &vop_print_desc, (vop_t *) sync_print }, /* print */
- { &vop_islocked_desc, (vop_t *) sync_islocked }, /* islocked */
- { NULL, NULL }
-};
-static struct vnodeopv_desc sync_vnodeop_opv_desc =
- { &sync_vnodeop_p, sync_vnodeop_entries };
-
-VNODEOP_SET(sync_vnodeop_opv_desc);
-
-/*
- * Create a new filesystem syncer vnode for the specified mount point.
- */
-int
-vfs_allocate_syncvnode(mp)
- struct mount *mp;
-{
- struct vnode *vp;
- static long start, incr, next;
- int error;
-
- /* Allocate a new vnode */
- if ((error = getnewvnode(VT_VFS, mp, sync_vnodeop_p, &vp)) != 0) {
- mp->mnt_syncer = NULL;
- return (error);
- }
- vp->v_type = VNON;
- /*
- * Place the vnode onto the syncer worklist. We attempt to
- * scatter them about on the list so that they will go off
- * at evenly distributed times even if all the filesystems
- * are mounted at once.
- */
- next += incr;
- if (next == 0 || next > syncer_maxdelay) {
- start /= 2;
- incr /= 2;
- if (start == 0) {
- start = syncer_maxdelay / 2;
- incr = syncer_maxdelay;
- }
- next = start;
- }
- vn_syncer_add_to_worklist(vp, syncdelay > 0 ? next % syncdelay : 0);
- mp->mnt_syncer = vp;
- return (0);
-}
-
-/*
- * Do a lazy sync of the filesystem.
- */
-static int
-sync_fsync(ap)
- struct vop_fsync_args /* {
- struct vnode *a_vp;
- struct ucred *a_cred;
- int a_waitfor;
- struct proc *a_p;
- } */ *ap;
-{
- struct vnode *syncvp = ap->a_vp;
- struct mount *mp = syncvp->v_mount;
- struct proc *p = ap->a_p;
- int asyncflag;
-
- /*
- * We only need to do something if this is a lazy evaluation.
- */
- if (ap->a_waitfor != MNT_LAZY)
- return (0);
-
- /*
- * Move ourselves to the back of the sync list.
- */
- vn_syncer_add_to_worklist(syncvp, syncdelay);
-
- /*
- * Walk the list of vnodes pushing all that are dirty and
- * not already on the sync list.
- */
- simple_lock(&mountlist_slock);
- if (vfs_busy(mp, LK_EXCLUSIVE | LK_NOWAIT, &mountlist_slock, p) != 0) {
- simple_unlock(&mountlist_slock);
- return (0);
- }
- asyncflag = mp->mnt_flag & MNT_ASYNC;
- mp->mnt_flag &= ~MNT_ASYNC;
- vfs_msync(mp, MNT_NOWAIT);
- VFS_SYNC(mp, MNT_LAZY, ap->a_cred, p);
- if (asyncflag)
- mp->mnt_flag |= MNT_ASYNC;
- vfs_unbusy(mp, p);
- return (0);
-}
-
-/*
- * The syncer vnode is no referenced.
- */
-static int
-sync_inactive(ap)
- struct vop_inactive_args /* {
- struct vnode *a_vp;
- struct proc *a_p;
- } */ *ap;
-{
-
- vgone(ap->a_vp);
- return (0);
-}
-
-/*
- * The syncer vnode is no longer needed and is being decommissioned.
- *
- * Modifications to the worklist must be protected at splbio().
- */
-static int
-sync_reclaim(ap)
- struct vop_reclaim_args /* {
- struct vnode *a_vp;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
- int s;
-
- s = splbio();
- vp->v_mount->mnt_syncer = NULL;
- if (vp->v_flag & VONWORKLST) {
- LIST_REMOVE(vp, v_synclist);
- vp->v_flag &= ~VONWORKLST;
- }
- splx(s);
-
- return (0);
-}
-
-/*
- * Print out a syncer vnode.
- */
-static int
-sync_print(ap)
- struct vop_print_args /* {
- struct vnode *a_vp;
- } */ *ap;
-{
- struct vnode *vp = ap->a_vp;
-
- printf("syncer vnode");
- if (vp->v_vnlock != NULL)
- lockmgr_printinfo(vp->v_vnlock);
- printf("\n");
- return (0);
-}
-
-/*
- * extract the dev_t from a VBLK or VCHR
- */
-dev_t
-vn_todev(vp)
- struct vnode *vp;
-{
- if (vp->v_type != VBLK && vp->v_type != VCHR)
- return (NODEV);
- return (vp->v_rdev);
-}
-
-/*
- * Check if vnode represents a disk device
- */
-int
-vn_isdisk(vp, errp)
- struct vnode *vp;
- int *errp;
-{
- if (vp->v_type != VBLK && vp->v_type != VCHR) {
- if (errp != NULL)
- *errp = ENOTBLK;
- return (0);
- }
- if (!devsw(vp->v_rdev)) {
- if (errp != NULL)
- *errp = ENXIO;
- return (0);
- }
- if (!(devsw(vp->v_rdev)->d_flags & D_DISK)) {
- if (errp != NULL)
- *errp = ENOTBLK;
- return (0);
- }
- if (errp != NULL)
- *errp = 0;
- return (1);
-}
-
-void
-NDFREE(ndp, flags)
- struct nameidata *ndp;
- const uint flags;
-{
- if (!(flags & NDF_NO_FREE_PNBUF) &&
- (ndp->ni_cnd.cn_flags & HASBUF)) {
- zfree(namei_zone, ndp->ni_cnd.cn_pnbuf);
- ndp->ni_cnd.cn_flags &= ~HASBUF;
- }
- if (!(flags & NDF_NO_DVP_UNLOCK) &&
- (ndp->ni_cnd.cn_flags & LOCKPARENT) &&
- ndp->ni_dvp != ndp->ni_vp)
- VOP_UNLOCK(ndp->ni_dvp, 0, ndp->ni_cnd.cn_proc);
- if (!(flags & NDF_NO_DVP_RELE) &&
- (ndp->ni_cnd.cn_flags & (LOCKPARENT|WANTPARENT))) {
- vrele(ndp->ni_dvp);
- ndp->ni_dvp = NULL;
- }
- if (!(flags & NDF_NO_VP_UNLOCK) &&
- (ndp->ni_cnd.cn_flags & LOCKLEAF) && ndp->ni_vp)
- VOP_UNLOCK(ndp->ni_vp, 0, ndp->ni_cnd.cn_proc);
- if (!(flags & NDF_NO_VP_RELE) &&
- ndp->ni_vp) {
- vrele(ndp->ni_vp);
- ndp->ni_vp = NULL;
- }
- if (!(flags & NDF_NO_STARTDIR_RELE) &&
- (ndp->ni_cnd.cn_flags & SAVESTART)) {
- vrele(ndp->ni_startdir);
- ndp->ni_startdir = NULL;
- }
-}
diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c
deleted file mode 100644
index 142a2c339422..000000000000
--- a/sys/kern/vfs_extattr.c
+++ /dev/null
@@ -1,3564 +0,0 @@
-/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)vfs_syscalls.c 8.13 (Berkeley) 4/15/94
- * $FreeBSD$
- */
-
-/* For 4.3 integer FS ID compatibility */
-#include "opt_compat.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/buf.h>
-#include <sys/sysent.h>
-#include <sys/malloc.h>
-#include <sys/mount.h>
-#include <sys/sysproto.h>
-#include <sys/namei.h>
-#include <sys/filedesc.h>
-#include <sys/kernel.h>
-#include <sys/fcntl.h>
-#include <sys/file.h>
-#include <sys/linker.h>
-#include <sys/stat.h>
-#include <sys/unistd.h>
-#include <sys/vnode.h>
-#include <sys/proc.h>
-#include <sys/dirent.h>
-#include <sys/extattr.h>
-
-#include <machine/limits.h>
-#include <miscfs/union/union.h>
-#include <sys/sysctl.h>
-#include <vm/vm.h>
-#include <vm/vm_object.h>
-#include <vm/vm_zone.h>
-
-static int change_dir __P((struct nameidata *ndp, struct proc *p));
-static void checkdirs __P((struct vnode *olddp));
-static int chroot_refuse_vdir_fds __P((struct filedesc *fdp));
-static int getutimes __P((const struct timeval *, struct timespec *));
-static int setfown __P((struct proc *, struct vnode *, uid_t, gid_t));
-static int setfmode __P((struct proc *, struct vnode *, int));
-static int setfflags __P((struct proc *, struct vnode *, int));
-static int setutimes __P((struct proc *, struct vnode *,
- const struct timespec *, int));
-static int usermount = 0; /* if 1, non-root can mount fs. */
-
-int (*union_dircheckp) __P((struct proc *, struct vnode **, struct file *));
-
-SYSCTL_INT(_vfs, OID_AUTO, usermount, CTLFLAG_RW, &usermount, 0, "");
-
-/*
- * Virtual File System System Calls
- */
-
-/*
- * Mount a file system.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct mount_args {
- char *type;
- char *path;
- int flags;
- caddr_t data;
-};
-#endif
-/* ARGSUSED */
-int
-mount(p, uap)
- struct proc *p;
- register struct mount_args /* {
- syscallarg(char *) type;
- syscallarg(char *) path;
- syscallarg(int) flags;
- syscallarg(caddr_t) data;
- } */ *uap;
-{
- struct vnode *vp;
- struct mount *mp;
- struct vfsconf *vfsp;
- int error, flag = 0, flag2 = 0;
- struct vattr va;
-#ifdef COMPAT_43
- u_long fstypenum;
-#endif
- struct nameidata nd;
- char fstypename[MFSNAMELEN];
-
- if (usermount == 0 && (error = suser(p)))
- return (error);
- /*
- * Do not allow NFS export by non-root users.
- */
- if (SCARG(uap, flags) & MNT_EXPORTED) {
- error = suser(p);
- if (error)
- return (error);
- }
- /*
- * Silently enforce MNT_NOSUID and MNT_NODEV for non-root users
- */
- if (suser_xxx(p->p_ucred, 0, 0))
- SCARG(uap, flags) |= MNT_NOSUID | MNT_NODEV;
- /*
- * Get vnode to be covered
- */
- NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE,
- SCARG(uap, path), p);
- if ((error = namei(&nd)) != 0)
- return (error);
- NDFREE(&nd, NDF_ONLY_PNBUF);
- vp = nd.ni_vp;
- if (SCARG(uap, flags) & MNT_UPDATE) {
- if ((vp->v_flag & VROOT) == 0) {
- vput(vp);
- return (EINVAL);
- }
- mp = vp->v_mount;
- flag = mp->mnt_flag;
- flag2 = mp->mnt_kern_flag;
- /*
- * We only allow the filesystem to be reloaded if it
- * is currently mounted read-only.
- */
- if ((SCARG(uap, flags) & MNT_RELOAD) &&
- ((mp->mnt_flag & MNT_RDONLY) == 0)) {
- vput(vp);
- return (EOPNOTSUPP); /* Needs translation */
- }
- mp->mnt_flag |=
- SCARG(uap, flags) & (MNT_RELOAD | MNT_FORCE | MNT_UPDATE);
- /*
- * Only root, or the user that did the original mount is
- * permitted to update it.
- */
- if (mp->mnt_stat.f_owner != p->p_ucred->cr_uid &&
- (error = suser(p))) {
- vput(vp);
- return (error);
- }
- if (vfs_busy(mp, LK_NOWAIT, 0, p)) {
- vput(vp);
- return (EBUSY);
- }
- VOP_UNLOCK(vp, 0, p);
- goto update;
- }
- /*
- * If the user is not root, ensure that they own the directory
- * onto which we are attempting to mount.
- */
- if ((error = VOP_GETATTR(vp, &va, p->p_ucred, p)) ||
- (va.va_uid != p->p_ucred->cr_uid &&
- (error = suser(p)))) {
- vput(vp);
- return (error);
- }
- if ((error = vinvalbuf(vp, V_SAVE, p->p_ucred, p, 0, 0)) != 0)
- return (error);
- if (vp->v_type != VDIR) {
- vput(vp);
- return (ENOTDIR);
- }
-#ifdef COMPAT_43
- /*
- * Historically filesystem types were identified by number. If we
- * get an integer for the filesystem type instead of a string, we
- * check to see if it matches one of the historic filesystem types.
- */
- fstypenum = (uintptr_t)SCARG(uap, type);
- if (fstypenum < maxvfsconf) {
- for (vfsp = vfsconf; vfsp; vfsp = vfsp->vfc_next)
- if (vfsp->vfc_typenum == fstypenum)
- break;
- if (vfsp == NULL) {
- vput(vp);
- return (ENODEV);
- }
- strncpy(fstypename, vfsp->vfc_name, MFSNAMELEN);
- } else
-#endif /* COMPAT_43 */
- if ((error = copyinstr(SCARG(uap, type), fstypename, MFSNAMELEN, NULL)) != 0) {
- vput(vp);
- return (error);
- }
- for (vfsp = vfsconf; vfsp; vfsp = vfsp->vfc_next)
- if (!strcmp(vfsp->vfc_name, fstypename))
- break;
- if (vfsp == NULL) {
- linker_file_t lf;
-
- /* Refuse to load modules if securelevel raised */
- if (securelevel > 0) {
- vput(vp);
- return EPERM;
- }
- /* Only load modules for root (very important!) */
- if ((error = suser(p)) != 0) {
- vput(vp);
- return error;
- }
- error = linker_load_file(fstypename, &lf);
- if (error || lf == NULL) {
- vput(vp);
- if (lf == NULL)
- error = ENODEV;
- return error;
- }
- lf->userrefs++;
- /* lookup again, see if the VFS was loaded */
- for (vfsp = vfsconf; vfsp; vfsp = vfsp->vfc_next)
- if (!strcmp(vfsp->vfc_name, fstypename))
- break;
- if (vfsp == NULL) {
- lf->userrefs--;
- linker_file_unload(lf);
- vput(vp);
- return (ENODEV);
- }
- }
- simple_lock(&vp->v_interlock);
- if ((vp->v_flag & VMOUNT) != 0 ||
- vp->v_mountedhere != NULL) {
- simple_unlock(&vp->v_interlock);
- vput(vp);
- return (EBUSY);
- }
- vp->v_flag |= VMOUNT;
- simple_unlock(&vp->v_interlock);
-
- /*
- * Allocate and initialize the filesystem.
- */
- mp = malloc(sizeof(struct mount), M_MOUNT, M_WAITOK);
- bzero((char *)mp, (u_long)sizeof(struct mount));
- lockinit(&mp->mnt_lock, PVFS, "vfslock", 0, LK_NOPAUSE);
- (void)vfs_busy(mp, LK_NOWAIT, 0, p);
- mp->mnt_op = vfsp->vfc_vfsops;
- mp->mnt_vfc = vfsp;
- vfsp->vfc_refcount++;
- mp->mnt_stat.f_type = vfsp->vfc_typenum;
- mp->mnt_flag |= vfsp->vfc_flags & MNT_VISFLAGMASK;
- strncpy(mp->mnt_stat.f_fstypename, vfsp->vfc_name, MFSNAMELEN);
- mp->mnt_vnodecovered = vp;
- mp->mnt_stat.f_owner = p->p_ucred->cr_uid;
- mp->mnt_iosize_max = DFLTPHYS;
- VOP_UNLOCK(vp, 0, p);
-update:
- /*
- * Set the mount level flags.
- */
- if (SCARG(uap, flags) & MNT_RDONLY)
- mp->mnt_flag |= MNT_RDONLY;
- else if (mp->mnt_flag & MNT_RDONLY)
- mp->mnt_kern_flag |= MNTK_WANTRDWR;
- mp->mnt_flag &=~ (MNT_NOSUID | MNT_NOEXEC | MNT_NODEV |
- MNT_SYNCHRONOUS | MNT_UNION | MNT_ASYNC | MNT_NOATIME |
- MNT_NOSYMFOLLOW | MNT_IGNORE |
- MNT_NOCLUSTERR | MNT_NOCLUSTERW | MNT_SUIDDIR);
- mp->mnt_flag |= SCARG(uap, flags) & (MNT_NOSUID | MNT_NOEXEC |
- MNT_NODEV | MNT_SYNCHRONOUS | MNT_UNION | MNT_ASYNC | MNT_FORCE |
- MNT_NOSYMFOLLOW | MNT_IGNORE |
- MNT_NOATIME | MNT_NOCLUSTERR | MNT_NOCLUSTERW | MNT_SUIDDIR);
- /*
- * Mount the filesystem.
- * XXX The final recipients of VFS_MOUNT just overwrite the ndp they
- * get. No freeing of cn_pnbuf.
- */
- error = VFS_MOUNT(mp, SCARG(uap, path), SCARG(uap, data), &nd, p);
- if (mp->mnt_flag & MNT_UPDATE) {
- vrele(vp);
- if (mp->mnt_kern_flag & MNTK_WANTRDWR)
- mp->mnt_flag &= ~MNT_RDONLY;
- mp->mnt_flag &=~ (MNT_UPDATE | MNT_RELOAD | MNT_FORCE);
- mp->mnt_kern_flag &=~ MNTK_WANTRDWR;
- if (error) {
- mp->mnt_flag = flag;
- mp->mnt_kern_flag = flag2;
- }
- if ((mp->mnt_flag & MNT_RDONLY) == 0) {
- if (mp->mnt_syncer == NULL)
- error = vfs_allocate_syncvnode(mp);
- } else {
- if (mp->mnt_syncer != NULL)
- vrele(mp->mnt_syncer);
- mp->mnt_syncer = NULL;
- }
- vfs_unbusy(mp, p);
- return (error);
- }
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
- /*
- * Put the new filesystem on the mount list after root.
- */
- cache_purge(vp);
- if (!error) {
- simple_lock(&vp->v_interlock);
- vp->v_flag &= ~VMOUNT;
- vp->v_mountedhere = mp;
- simple_unlock(&vp->v_interlock);
- simple_lock(&mountlist_slock);
- TAILQ_INSERT_TAIL(&mountlist, mp, mnt_list);
- simple_unlock(&mountlist_slock);
- checkdirs(vp);
- VOP_UNLOCK(vp, 0, p);
- if ((mp->mnt_flag & MNT_RDONLY) == 0)
- error = vfs_allocate_syncvnode(mp);
- vfs_unbusy(mp, p);
- if ((error = VFS_START(mp, 0, p)) != 0)
- vrele(vp);
- } else {
- simple_lock(&vp->v_interlock);
- vp->v_flag &= ~VMOUNT;
- simple_unlock(&vp->v_interlock);
- mp->mnt_vfc->vfc_refcount--;
- vfs_unbusy(mp, p);
- free((caddr_t)mp, M_MOUNT);
- vput(vp);
- }
- return (error);
-}
-
-/*
- * Scan all active processes to see if any of them have a current
- * or root directory onto which the new filesystem has just been
- * mounted. If so, replace them with the new mount point.
- */
-static void
-checkdirs(olddp)
- struct vnode *olddp;
-{
- struct filedesc *fdp;
- struct vnode *newdp;
- struct proc *p;
-
- if (olddp->v_usecount == 1)
- return;
- if (VFS_ROOT(olddp->v_mountedhere, &newdp))
- panic("mount: lost mount");
- LIST_FOREACH(p, &allproc, p_list) {
- fdp = p->p_fd;
- if (fdp->fd_cdir == olddp) {
- vrele(fdp->fd_cdir);
- VREF(newdp);
- fdp->fd_cdir = newdp;
- }
- if (fdp->fd_rdir == olddp) {
- vrele(fdp->fd_rdir);
- VREF(newdp);
- fdp->fd_rdir = newdp;
- }
- }
- if (rootvnode == olddp) {
- vrele(rootvnode);
- VREF(newdp);
- rootvnode = newdp;
- }
- vput(newdp);
-}
-
-/*
- * Unmount a file system.
- *
- * Note: unmount takes a path to the vnode mounted on as argument,
- * not special file (as before).
- */
-#ifndef _SYS_SYSPROTO_H_
-struct unmount_args {
- char *path;
- int flags;
-};
-#endif
-/* ARGSUSED */
-int
-unmount(p, uap)
- struct proc *p;
- register struct unmount_args /* {
- syscallarg(char *) path;
- syscallarg(int) flags;
- } */ *uap;
-{
- register struct vnode *vp;
- struct mount *mp;
- int error;
- struct nameidata nd;
-
- NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE,
- SCARG(uap, path), p);
- if ((error = namei(&nd)) != 0)
- return (error);
- vp = nd.ni_vp;
- NDFREE(&nd, NDF_ONLY_PNBUF);
- mp = vp->v_mount;
-
- /*
- * Only root, or the user that did the original mount is
- * permitted to unmount this filesystem.
- */
- if ((mp->mnt_stat.f_owner != p->p_ucred->cr_uid) &&
- (error = suser(p))) {
- vput(vp);
- return (error);
- }
-
- /*
- * Don't allow unmounting the root file system.
- */
- if (mp->mnt_flag & MNT_ROOTFS) {
- vput(vp);
- return (EINVAL);
- }
-
- /*
- * Must be the root of the filesystem
- */
- if ((vp->v_flag & VROOT) == 0) {
- vput(vp);
- return (EINVAL);
- }
- vput(vp);
- return (dounmount(mp, SCARG(uap, flags), p));
-}
-
-/*
- * Do the actual file system unmount.
- */
-int
-dounmount(mp, flags, p)
- register struct mount *mp;
- int flags;
- struct proc *p;
-{
- struct vnode *coveredvp;
- int error;
- int async_flag;
-
- simple_lock(&mountlist_slock);
- mp->mnt_kern_flag |= MNTK_UNMOUNT;
- lockmgr(&mp->mnt_lock, LK_DRAIN | LK_INTERLOCK, &mountlist_slock, p);
-
- if (mp->mnt_flag & MNT_EXPUBLIC)
- vfs_setpublicfs(NULL, NULL, NULL);
-
- vfs_msync(mp, MNT_WAIT);
- async_flag = mp->mnt_flag & MNT_ASYNC;
- mp->mnt_flag &=~ MNT_ASYNC;
- cache_purgevfs(mp); /* remove cache entries for this file sys */
- if (mp->mnt_syncer != NULL)
- vrele(mp->mnt_syncer);
- if (((mp->mnt_flag & MNT_RDONLY) ||
- (error = VFS_SYNC(mp, MNT_WAIT, p->p_ucred, p)) == 0) ||
- (flags & MNT_FORCE))
- error = VFS_UNMOUNT(mp, flags, p);
- simple_lock(&mountlist_slock);
- if (error) {
- if ((mp->mnt_flag & MNT_RDONLY) == 0 && mp->mnt_syncer == NULL)
- (void) vfs_allocate_syncvnode(mp);
- mp->mnt_kern_flag &= ~MNTK_UNMOUNT;
- mp->mnt_flag |= async_flag;
- lockmgr(&mp->mnt_lock, LK_RELEASE | LK_INTERLOCK | LK_REENABLE,
- &mountlist_slock, p);
- if (mp->mnt_kern_flag & MNTK_MWAIT)
- wakeup((caddr_t)mp);
- return (error);
- }
- TAILQ_REMOVE(&mountlist, mp, mnt_list);
- if ((coveredvp = mp->mnt_vnodecovered) != NULLVP) {
- coveredvp->v_mountedhere = (struct mount *)0;
- vrele(coveredvp);
- }
- mp->mnt_vfc->vfc_refcount--;
- if (!LIST_EMPTY(&mp->mnt_vnodelist))
- panic("unmount: dangling vnode");
- lockmgr(&mp->mnt_lock, LK_RELEASE | LK_INTERLOCK, &mountlist_slock, p);
- if (mp->mnt_kern_flag & MNTK_MWAIT)
- wakeup((caddr_t)mp);
- free((caddr_t)mp, M_MOUNT);
- return (0);
-}
-
-/*
- * Sync each mounted filesystem.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct sync_args {
- int dummy;
-};
-#endif
-
-#ifdef DEBUG
-static int syncprt = 0;
-SYSCTL_INT(_debug, OID_AUTO, syncprt, CTLFLAG_RW, &syncprt, 0, "");
-#endif
-
-/* ARGSUSED */
-int
-sync(p, uap)
- struct proc *p;
- struct sync_args *uap;
-{
- register struct mount *mp, *nmp;
- int asyncflag;
-
- simple_lock(&mountlist_slock);
- for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) {
- if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, p)) {
- nmp = TAILQ_NEXT(mp, mnt_list);
- continue;
- }
- if ((mp->mnt_flag & MNT_RDONLY) == 0) {
- asyncflag = mp->mnt_flag & MNT_ASYNC;
- mp->mnt_flag &= ~MNT_ASYNC;
- vfs_msync(mp, MNT_NOWAIT);
- VFS_SYNC(mp, MNT_NOWAIT,
- ((p != NULL) ? p->p_ucred : NOCRED), p);
- mp->mnt_flag |= asyncflag;
- }
- simple_lock(&mountlist_slock);
- nmp = TAILQ_NEXT(mp, mnt_list);
- vfs_unbusy(mp, p);
- }
- simple_unlock(&mountlist_slock);
-#if 0
-/*
- * XXX don't call vfs_bufstats() yet because that routine
- * was not imported in the Lite2 merge.
- */
-#ifdef DIAGNOSTIC
- if (syncprt)
- vfs_bufstats();
-#endif /* DIAGNOSTIC */
-#endif
- return (0);
-}
-
-/* XXX PRISON: could be per prison flag */
-static int prison_quotas;
-#if 0
-SYSCTL_INT(_kern_prison, OID_AUTO, quotas, CTLFLAG_RW, &prison_quotas, 0, "");
-#endif
-
-/*
- * Change filesystem quotas.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct quotactl_args {
- char *path;
- int cmd;
- int uid;
- caddr_t arg;
-};
-#endif
-/* ARGSUSED */
-int
-quotactl(p, uap)
- struct proc *p;
- register struct quotactl_args /* {
- syscallarg(char *) path;
- syscallarg(int) cmd;
- syscallarg(int) uid;
- syscallarg(caddr_t) arg;
- } */ *uap;
-{
- register struct mount *mp;
- int error;
- struct nameidata nd;
-
- if (p->p_prison && !prison_quotas)
- return (EPERM);
- NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
- if ((error = namei(&nd)) != 0)
- return (error);
- mp = nd.ni_vp->v_mount;
- NDFREE(&nd, NDF_ONLY_PNBUF);
- vrele(nd.ni_vp);
- return (VFS_QUOTACTL(mp, SCARG(uap, cmd), SCARG(uap, uid),
- SCARG(uap, arg), p));
-}
-
-/*
- * Get filesystem statistics.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct statfs_args {
- char *path;
- struct statfs *buf;
-};
-#endif
-/* ARGSUSED */
-int
-statfs(p, uap)
- struct proc *p;
- register struct statfs_args /* {
- syscallarg(char *) path;
- syscallarg(struct statfs *) buf;
- } */ *uap;
-{
- register struct mount *mp;
- register struct statfs *sp;
- int error;
- struct nameidata nd;
- struct statfs sb;
-
- NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
- if ((error = namei(&nd)) != 0)
- return (error);
- mp = nd.ni_vp->v_mount;
- sp = &mp->mnt_stat;
- NDFREE(&nd, NDF_ONLY_PNBUF);
- vrele(nd.ni_vp);
- error = VFS_STATFS(mp, sp, p);
- if (error)
- return (error);
- sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
- if (suser_xxx(p->p_ucred, 0, 0)) {
- bcopy((caddr_t)sp, (caddr_t)&sb, sizeof(sb));
- sb.f_fsid.val[0] = sb.f_fsid.val[1] = 0;
- sp = &sb;
- }
- return (copyout((caddr_t)sp, (caddr_t)SCARG(uap, buf), sizeof(*sp)));
-}
-
-/*
- * Get filesystem statistics.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct fstatfs_args {
- int fd;
- struct statfs *buf;
-};
-#endif
-/* ARGSUSED */
-int
-fstatfs(p, uap)
- struct proc *p;
- register struct fstatfs_args /* {
- syscallarg(int) fd;
- syscallarg(struct statfs *) buf;
- } */ *uap;
-{
- struct file *fp;
- struct mount *mp;
- register struct statfs *sp;
- int error;
- struct statfs sb;
-
- if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
- return (error);
- mp = ((struct vnode *)fp->f_data)->v_mount;
- sp = &mp->mnt_stat;
- error = VFS_STATFS(mp, sp, p);
- if (error)
- return (error);
- sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
- if (suser_xxx(p->p_ucred, 0, 0)) {
- bcopy((caddr_t)sp, (caddr_t)&sb, sizeof(sb));
- sb.f_fsid.val[0] = sb.f_fsid.val[1] = 0;
- sp = &sb;
- }
- return (copyout((caddr_t)sp, (caddr_t)SCARG(uap, buf), sizeof(*sp)));
-}
-
-/*
- * Get statistics on all filesystems.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct getfsstat_args {
- struct statfs *buf;
- long bufsize;
- int flags;
-};
-#endif
-int
-getfsstat(p, uap)
- struct proc *p;
- register struct getfsstat_args /* {
- syscallarg(struct statfs *) buf;
- syscallarg(long) bufsize;
- syscallarg(int) flags;
- } */ *uap;
-{
- register struct mount *mp, *nmp;
- register struct statfs *sp;
- caddr_t sfsp;
- long count, maxcount, error;
-
- maxcount = SCARG(uap, bufsize) / sizeof(struct statfs);
- sfsp = (caddr_t)SCARG(uap, buf);
- count = 0;
- simple_lock(&mountlist_slock);
- for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) {
- if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock, p)) {
- nmp = TAILQ_NEXT(mp, mnt_list);
- continue;
- }
- if (sfsp && count < maxcount) {
- sp = &mp->mnt_stat;
- /*
- * If MNT_NOWAIT or MNT_LAZY is specified, do not
- * refresh the fsstat cache. MNT_NOWAIT or MNT_LAZY
- * overrides MNT_WAIT.
- */
- if (((SCARG(uap, flags) & (MNT_LAZY|MNT_NOWAIT)) == 0 ||
- (SCARG(uap, flags) & MNT_WAIT)) &&
- (error = VFS_STATFS(mp, sp, p))) {
- simple_lock(&mountlist_slock);
- nmp = TAILQ_NEXT(mp, mnt_list);
- vfs_unbusy(mp, p);
- continue;
- }
- sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
- error = copyout((caddr_t)sp, sfsp, sizeof(*sp));
- if (error) {
- vfs_unbusy(mp, p);
- return (error);
- }
- sfsp += sizeof(*sp);
- }
- count++;
- simple_lock(&mountlist_slock);
- nmp = TAILQ_NEXT(mp, mnt_list);
- vfs_unbusy(mp, p);
- }
- simple_unlock(&mountlist_slock);
- if (sfsp && count > maxcount)
- p->p_retval[0] = maxcount;
- else
- p->p_retval[0] = count;
- return (0);
-}
-
-/*
- * Change current working directory to a given file descriptor.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct fchdir_args {
- int fd;
-};
-#endif
-/* ARGSUSED */
-int
-fchdir(p, uap)
- struct proc *p;
- struct fchdir_args /* {
- syscallarg(int) fd;
- } */ *uap;
-{
- register struct filedesc *fdp = p->p_fd;
- struct vnode *vp, *tdp;
- struct mount *mp;
- struct file *fp;
- int error;
-
- if ((error = getvnode(fdp, SCARG(uap, fd), &fp)) != 0)
- return (error);
- vp = (struct vnode *)fp->f_data;
- VREF(vp);
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
- if (vp->v_type != VDIR)
- error = ENOTDIR;
- else
- error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p);
- while (!error && (mp = vp->v_mountedhere) != NULL) {
- if (vfs_busy(mp, 0, 0, p))
- continue;
- error = VFS_ROOT(mp, &tdp);
- vfs_unbusy(mp, p);
- if (error)
- break;
- vput(vp);
- vp = tdp;
- }
- if (error) {
- vput(vp);
- return (error);
- }
- VOP_UNLOCK(vp, 0, p);
- vrele(fdp->fd_cdir);
- fdp->fd_cdir = vp;
- return (0);
-}
-
-/*
- * Change current working directory (``.'').
- */
-#ifndef _SYS_SYSPROTO_H_
-struct chdir_args {
- char *path;
-};
-#endif
-/* ARGSUSED */
-int
-chdir(p, uap)
- struct proc *p;
- struct chdir_args /* {
- syscallarg(char *) path;
- } */ *uap;
-{
- register struct filedesc *fdp = p->p_fd;
- int error;
- struct nameidata nd;
-
- NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE,
- SCARG(uap, path), p);
- if ((error = change_dir(&nd, p)) != 0)
- return (error);
- NDFREE(&nd, NDF_ONLY_PNBUF);
- vrele(fdp->fd_cdir);
- fdp->fd_cdir = nd.ni_vp;
- return (0);
-}
-
-/*
- * Helper function for raised chroot(2) security function: Refuse if
- * any filedescriptors are open directories.
- */
-static int
-chroot_refuse_vdir_fds(fdp)
- struct filedesc *fdp;
-{
- struct vnode *vp;
- struct file *fp;
- int error;
- int fd;
-
- for (fd = 0; fd < fdp->fd_nfiles ; fd++) {
- error = getvnode(fdp, fd, &fp);
- if (error)
- continue;
- vp = (struct vnode *)fp->f_data;
- if (vp->v_type != VDIR)
- continue;
- return(EPERM);
- }
- return (0);
-}
-
-/*
- * This sysctl determines if we will allow a process to chroot(2) if it
- * has a directory open:
- * 0: disallowed for all processes.
- * 1: allowed for processes that were not already chroot(2)'ed.
- * 2: allowed for all processes.
- */
-
-static int chroot_allow_open_directories = 1;
-
-SYSCTL_INT(_kern, OID_AUTO, chroot_allow_open_directories, CTLFLAG_RW,
- &chroot_allow_open_directories, 0, "");
-
-/*
- * Change notion of root (``/'') directory.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct chroot_args {
- char *path;
-};
-#endif
-/* ARGSUSED */
-int
-chroot(p, uap)
- struct proc *p;
- struct chroot_args /* {
- syscallarg(char *) path;
- } */ *uap;
-{
- register struct filedesc *fdp = p->p_fd;
- int error;
- struct nameidata nd;
-
- error = suser_xxx(0, p, PRISON_ROOT);
- if (error)
- return (error);
- if (chroot_allow_open_directories == 0 ||
- (chroot_allow_open_directories == 1 && fdp->fd_rdir != rootvnode))
- error = chroot_refuse_vdir_fds(fdp);
- if (error)
- return (error);
- NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE,
- SCARG(uap, path), p);
- if ((error = change_dir(&nd, p)) != 0)
- return (error);
- NDFREE(&nd, NDF_ONLY_PNBUF);
- vrele(fdp->fd_rdir);
- fdp->fd_rdir = nd.ni_vp;
- if (!fdp->fd_jdir) {
- fdp->fd_jdir = nd.ni_vp;
- VREF(fdp->fd_jdir);
- }
- return (0);
-}
-
-/*
- * Common routine for chroot and chdir.
- */
-static int
-change_dir(ndp, p)
- register struct nameidata *ndp;
- struct proc *p;
-{
- struct vnode *vp;
- int error;
-
- error = namei(ndp);
- if (error)
- return (error);
- vp = ndp->ni_vp;
- if (vp->v_type != VDIR)
- error = ENOTDIR;
- else
- error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p);
- if (error)
- vput(vp);
- else
- VOP_UNLOCK(vp, 0, p);
- return (error);
-}
-
-/*
- * Check permissions, allocate an open file structure,
- * and call the device open routine if any.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct open_args {
- char *path;
- int flags;
- int mode;
-};
-#endif
-int
-open(p, uap)
- struct proc *p;
- register struct open_args /* {
- syscallarg(char *) path;
- syscallarg(int) flags;
- syscallarg(int) mode;
- } */ *uap;
-{
- register struct filedesc *fdp = p->p_fd;
- register struct file *fp;
- register struct vnode *vp;
- int cmode, flags, oflags;
- struct file *nfp;
- int type, indx, error;
- struct flock lf;
- struct nameidata nd;
-
- oflags = SCARG(uap, flags);
- if ((oflags & O_ACCMODE) == O_ACCMODE)
- return (EINVAL);
- flags = FFLAGS(oflags);
- error = falloc(p, &nfp, &indx);
- if (error)
- return (error);
- fp = nfp;
- cmode = ((SCARG(uap, mode) &~ fdp->fd_cmask) & ALLPERMS) &~ S_ISTXT;
- NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
- p->p_dupfd = -indx - 1; /* XXX check for fdopen */
- error = vn_open(&nd, flags, cmode);
- if (error) {
- ffree(fp);
- if ((error == ENODEV || error == ENXIO) &&
- p->p_dupfd >= 0 && /* XXX from fdopen */
- (error =
- dupfdopen(fdp, indx, p->p_dupfd, flags, error)) == 0) {
- p->p_retval[0] = indx;
- return (0);
- }
- if (error == ERESTART)
- error = EINTR;
- fdp->fd_ofiles[indx] = NULL;
- return (error);
- }
- p->p_dupfd = 0;
- NDFREE(&nd, NDF_ONLY_PNBUF);
- vp = nd.ni_vp;
-
- fp->f_data = (caddr_t)vp;
- fp->f_flag = flags & FMASK;
- fp->f_ops = &vnops;
- fp->f_type = (vp->v_type == VFIFO ? DTYPE_FIFO : DTYPE_VNODE);
- if (flags & (O_EXLOCK | O_SHLOCK)) {
- lf.l_whence = SEEK_SET;
- lf.l_start = 0;
- lf.l_len = 0;
- if (flags & O_EXLOCK)
- lf.l_type = F_WRLCK;
- else
- lf.l_type = F_RDLCK;
- type = F_FLOCK;
- if ((flags & FNONBLOCK) == 0)
- type |= F_WAIT;
- VOP_UNLOCK(vp, 0, p);
- if ((error = VOP_ADVLOCK(vp, (caddr_t)fp, F_SETLK, &lf, type)) != 0) {
- (void) vn_close(vp, fp->f_flag, fp->f_cred, p);
- ffree(fp);
- fdp->fd_ofiles[indx] = NULL;
- return (error);
- }
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
- fp->f_flag |= FHASLOCK;
- }
- /* assert that vn_open created a backing object if one is needed */
- KASSERT(!vn_canvmio(vp) || vp->v_object != NULL,
- ("open: vmio vnode has no backing object after vn_open"));
- VOP_UNLOCK(vp, 0, p);
- p->p_retval[0] = indx;
- return (0);
-}
-
-#ifdef COMPAT_43
-/*
- * Create a file.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct ocreat_args {
- char *path;
- int mode;
-};
-#endif
-int
-ocreat(p, uap)
- struct proc *p;
- register struct ocreat_args /* {
- syscallarg(char *) path;
- syscallarg(int) mode;
- } */ *uap;
-{
- struct open_args /* {
- syscallarg(char *) path;
- syscallarg(int) flags;
- syscallarg(int) mode;
- } */ nuap;
-
- SCARG(&nuap, path) = SCARG(uap, path);
- SCARG(&nuap, mode) = SCARG(uap, mode);
- SCARG(&nuap, flags) = O_WRONLY | O_CREAT | O_TRUNC;
- return (open(p, &nuap));
-}
-#endif /* COMPAT_43 */
-
-/*
- * Create a special file.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct mknod_args {
- char *path;
- int mode;
- int dev;
-};
-#endif
-/* ARGSUSED */
-int
-mknod(p, uap)
- struct proc *p;
- register struct mknod_args /* {
- syscallarg(char *) path;
- syscallarg(int) mode;
- syscallarg(int) dev;
- } */ *uap;
-{
- register struct vnode *vp;
- struct vattr vattr;
- int error;
- int whiteout = 0;
- struct nameidata nd;
-
- switch (SCARG(uap, mode) & S_IFMT) {
- case S_IFCHR:
- case S_IFBLK:
- error = suser(p);
- break;
- default:
- error = suser_xxx(0, p, PRISON_ROOT);
- break;
- }
- if (error)
- return (error);
- bwillwrite();
- NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, SCARG(uap, path), p);
- if ((error = namei(&nd)) != 0)
- return (error);
- vp = nd.ni_vp;
- if (vp != NULL)
- error = EEXIST;
- else {
- VATTR_NULL(&vattr);
- vattr.va_mode = (SCARG(uap, mode) & ALLPERMS) &~ p->p_fd->fd_cmask;
- vattr.va_rdev = SCARG(uap, dev);
- whiteout = 0;
-
- switch (SCARG(uap, mode) & S_IFMT) {
- case S_IFMT: /* used by badsect to flag bad sectors */
- vattr.va_type = VBAD;
- break;
- case S_IFCHR:
- vattr.va_type = VCHR;
- break;
- case S_IFBLK:
- vattr.va_type = VBLK;
- break;
- case S_IFWHT:
- whiteout = 1;
- break;
- default:
- error = EINVAL;
- break;
- }
- }
- if (!error) {
- VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
- if (whiteout)
- error = VOP_WHITEOUT(nd.ni_dvp, &nd.ni_cnd, CREATE);
- else {
- error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp,
- &nd.ni_cnd, &vattr);
- if (error == 0)
- vput(nd.ni_vp);
- }
- NDFREE(&nd, NDF_ONLY_PNBUF);
- vput(nd.ni_dvp);
- } else {
- NDFREE(&nd, NDF_ONLY_PNBUF);
- if (nd.ni_dvp == vp)
- vrele(nd.ni_dvp);
- else
- vput(nd.ni_dvp);
- if (vp)
- vrele(vp);
- }
- ASSERT_VOP_UNLOCKED(nd.ni_dvp, "mknod");
- ASSERT_VOP_UNLOCKED(nd.ni_vp, "mknod");
- return (error);
-}
-
-/*
- * Create a named pipe.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct mkfifo_args {
- char *path;
- int mode;
-};
-#endif
-/* ARGSUSED */
-int
-mkfifo(p, uap)
- struct proc *p;
- register struct mkfifo_args /* {
- syscallarg(char *) path;
- syscallarg(int) mode;
- } */ *uap;
-{
- struct vattr vattr;
- int error;
- struct nameidata nd;
-
- bwillwrite();
- NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, SCARG(uap, path), p);
- if ((error = namei(&nd)) != 0)
- return (error);
- if (nd.ni_vp != NULL) {
- NDFREE(&nd, NDF_ONLY_PNBUF);
- if (nd.ni_dvp == nd.ni_vp)
- vrele(nd.ni_dvp);
- else
- vput(nd.ni_dvp);
- vrele(nd.ni_vp);
- return (EEXIST);
- }
- VATTR_NULL(&vattr);
- vattr.va_type = VFIFO;
- vattr.va_mode = (SCARG(uap, mode) & ALLPERMS) &~ p->p_fd->fd_cmask;
- VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
- error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr);
- if (error == 0)
- vput(nd.ni_vp);
- NDFREE(&nd, NDF_ONLY_PNBUF);
- vput(nd.ni_dvp);
- return (error);
-}
-
-/*
- * Make a hard file link.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct link_args {
- char *path;
- char *link;
-};
-#endif
-/* ARGSUSED */
-int
-link(p, uap)
- struct proc *p;
- register struct link_args /* {
- syscallarg(char *) path;
- syscallarg(char *) link;
- } */ *uap;
-{
- register struct vnode *vp;
- struct nameidata nd;
- int error;
-
- bwillwrite();
- NDINIT(&nd, LOOKUP, FOLLOW|NOOBJ, UIO_USERSPACE, SCARG(uap, path), p);
- if ((error = namei(&nd)) != 0)
- return (error);
- NDFREE(&nd, NDF_ONLY_PNBUF);
- vp = nd.ni_vp;
- if (vp->v_type == VDIR)
- error = EPERM; /* POSIX */
- else {
- NDINIT(&nd, CREATE, LOCKPARENT|NOOBJ, UIO_USERSPACE, SCARG(uap, link), p);
- error = namei(&nd);
- if (!error) {
- if (nd.ni_vp != NULL) {
- if (nd.ni_vp)
- vrele(nd.ni_vp);
- error = EEXIST;
- } else {
- VOP_LEASE(nd.ni_dvp, p, p->p_ucred,
- LEASE_WRITE);
- VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
- error = VOP_LINK(nd.ni_dvp, vp, &nd.ni_cnd);
- }
- NDFREE(&nd, NDF_ONLY_PNBUF);
- if (nd.ni_dvp == nd.ni_vp)
- vrele(nd.ni_dvp);
- else
- vput(nd.ni_dvp);
- }
- }
- vrele(vp);
- ASSERT_VOP_UNLOCKED(nd.ni_dvp, "link");
- ASSERT_VOP_UNLOCKED(nd.ni_vp, "link");
- return (error);
-}
-
-/*
- * Make a symbolic link.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct symlink_args {
- char *path;
- char *link;
-};
-#endif
-/* ARGSUSED */
-int
-symlink(p, uap)
- struct proc *p;
- register struct symlink_args /* {
- syscallarg(char *) path;
- syscallarg(char *) link;
- } */ *uap;
-{
- struct vattr vattr;
- char *path;
- int error;
- struct nameidata nd;
-
- path = zalloc(namei_zone);
- if ((error = copyinstr(SCARG(uap, path), path, MAXPATHLEN, NULL)) != 0)
- goto out;
- bwillwrite();
- NDINIT(&nd, CREATE, LOCKPARENT|NOOBJ, UIO_USERSPACE, SCARG(uap, link), p);
- if ((error = namei(&nd)) != 0)
- goto out;
- if (nd.ni_vp) {
- NDFREE(&nd, NDF_ONLY_PNBUF);
- if (nd.ni_dvp == nd.ni_vp)
- vrele(nd.ni_dvp);
- else
- vput(nd.ni_dvp);
- vrele(nd.ni_vp);
- error = EEXIST;
- goto out;
- }
- VATTR_NULL(&vattr);
- vattr.va_mode = ACCESSPERMS &~ p->p_fd->fd_cmask;
- VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
- error = VOP_SYMLINK(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr, path);
- NDFREE(&nd, NDF_ONLY_PNBUF);
- if (error == 0)
- vput(nd.ni_vp);
- vput(nd.ni_dvp);
- ASSERT_VOP_UNLOCKED(nd.ni_dvp, "symlink");
- ASSERT_VOP_UNLOCKED(nd.ni_vp, "symlink");
-out:
- zfree(namei_zone, path);
- return (error);
-}
-
-/*
- * Delete a whiteout from the filesystem.
- */
-/* ARGSUSED */
-int
-undelete(p, uap)
- struct proc *p;
- register struct undelete_args /* {
- syscallarg(char *) path;
- } */ *uap;
-{
- int error;
- struct nameidata nd;
-
- bwillwrite();
- NDINIT(&nd, DELETE, LOCKPARENT|DOWHITEOUT, UIO_USERSPACE,
- SCARG(uap, path), p);
- error = namei(&nd);
- if (error)
- return (error);
-
- if (nd.ni_vp != NULLVP || !(nd.ni_cnd.cn_flags & ISWHITEOUT)) {
- NDFREE(&nd, NDF_ONLY_PNBUF);
- if (nd.ni_dvp == nd.ni_vp)
- vrele(nd.ni_dvp);
- else
- vput(nd.ni_dvp);
- if (nd.ni_vp)
- vrele(nd.ni_vp);
- return (EEXIST);
- }
-
- VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
- error = VOP_WHITEOUT(nd.ni_dvp, &nd.ni_cnd, DELETE);
- NDFREE(&nd, NDF_ONLY_PNBUF);
- vput(nd.ni_dvp);
- ASSERT_VOP_UNLOCKED(nd.ni_dvp, "undelete");
- ASSERT_VOP_UNLOCKED(nd.ni_vp, "undelete");
- return (error);
-}
-
-/*
- * Delete a name from the filesystem.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct unlink_args {
- char *path;
-};
-#endif
-/* ARGSUSED */
-int
-unlink(p, uap)
- struct proc *p;
- struct unlink_args /* {
- syscallarg(char *) path;
- } */ *uap;
-{
- register struct vnode *vp;
- int error;
- struct nameidata nd;
-
- bwillwrite();
- NDINIT(&nd, DELETE, LOCKPARENT, UIO_USERSPACE, SCARG(uap, path), p);
- if ((error = namei(&nd)) != 0)
- return (error);
- vp = nd.ni_vp;
- VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
-
- if (vp->v_type == VDIR)
- error = EPERM; /* POSIX */
- else {
- /*
- * The root of a mounted filesystem cannot be deleted.
- *
- * XXX: can this only be a VDIR case?
- */
- if (vp->v_flag & VROOT)
- error = EBUSY;
- }
-
- if (!error) {
- VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
- error = VOP_REMOVE(nd.ni_dvp, vp, &nd.ni_cnd);
- }
- NDFREE(&nd, NDF_ONLY_PNBUF);
- if (nd.ni_dvp == vp)
- vrele(nd.ni_dvp);
- else
- vput(nd.ni_dvp);
- if (vp != NULLVP)
- vput(vp);
- ASSERT_VOP_UNLOCKED(nd.ni_dvp, "unlink");
- ASSERT_VOP_UNLOCKED(nd.ni_vp, "unlink");
- return (error);
-}
-
-/*
- * Reposition read/write file offset.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct lseek_args {
- int fd;
- int pad;
- off_t offset;
- int whence;
-};
-#endif
-int
-lseek(p, uap)
- struct proc *p;
- register struct lseek_args /* {
- syscallarg(int) fd;
- syscallarg(int) pad;
- syscallarg(off_t) offset;
- syscallarg(int) whence;
- } */ *uap;
-{
- struct ucred *cred = p->p_ucred;
- register struct filedesc *fdp = p->p_fd;
- register struct file *fp;
- struct vattr vattr;
- int error;
-
- if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles ||
- (fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL)
- return (EBADF);
- if (fp->f_type != DTYPE_VNODE)
- return (ESPIPE);
- switch (SCARG(uap, whence)) {
- case L_INCR:
- fp->f_offset += SCARG(uap, offset);
- break;
- case L_XTND:
- error=VOP_GETATTR((struct vnode *)fp->f_data, &vattr, cred, p);
- if (error)
- return (error);
- fp->f_offset = SCARG(uap, offset) + vattr.va_size;
- break;
- case L_SET:
- fp->f_offset = SCARG(uap, offset);
- break;
- default:
- return (EINVAL);
- }
- *(off_t *)(p->p_retval) = fp->f_offset;
- return (0);
-}
-
-#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
-/*
- * Reposition read/write file offset.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct olseek_args {
- int fd;
- long offset;
- int whence;
-};
-#endif
-int
-olseek(p, uap)
- struct proc *p;
- register struct olseek_args /* {
- syscallarg(int) fd;
- syscallarg(long) offset;
- syscallarg(int) whence;
- } */ *uap;
-{
- struct lseek_args /* {
- syscallarg(int) fd;
- syscallarg(int) pad;
- syscallarg(off_t) offset;
- syscallarg(int) whence;
- } */ nuap;
- int error;
-
- SCARG(&nuap, fd) = SCARG(uap, fd);
- SCARG(&nuap, offset) = SCARG(uap, offset);
- SCARG(&nuap, whence) = SCARG(uap, whence);
- error = lseek(p, &nuap);
- return (error);
-}
-#endif /* COMPAT_43 */
-
-/*
- * Check access permissions.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct access_args {
- char *path;
- int flags;
-};
-#endif
-int
-access(p, uap)
- struct proc *p;
- register struct access_args /* {
- syscallarg(char *) path;
- syscallarg(int) flags;
- } */ *uap;
-{
- register struct ucred *cred = p->p_ucred;
- register struct vnode *vp;
- int error, flags, t_gid, t_uid;
- struct nameidata nd;
-
- t_uid = cred->cr_uid;
- t_gid = cred->cr_groups[0];
- cred->cr_uid = p->p_cred->p_ruid;
- cred->cr_groups[0] = p->p_cred->p_rgid;
- NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE,
- SCARG(uap, path), p);
- if ((error = namei(&nd)) != 0)
- goto out1;
- vp = nd.ni_vp;
-
- /* Flags == 0 means only check for existence. */
- if (SCARG(uap, flags)) {
- flags = 0;
- if (SCARG(uap, flags) & R_OK)
- flags |= VREAD;
- if (SCARG(uap, flags) & W_OK)
- flags |= VWRITE;
- if (SCARG(uap, flags) & X_OK)
- flags |= VEXEC;
- if ((flags & VWRITE) == 0 || (error = vn_writechk(vp)) == 0)
- error = VOP_ACCESS(vp, flags, cred, p);
- }
- NDFREE(&nd, NDF_ONLY_PNBUF);
- vput(vp);
-out1:
- cred->cr_uid = t_uid;
- cred->cr_groups[0] = t_gid;
- return (error);
-}
-
-#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
-/*
- * Get file status; this version follows links.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct ostat_args {
- char *path;
- struct ostat *ub;
-};
-#endif
-/* ARGSUSED */
-int
-ostat(p, uap)
- struct proc *p;
- register struct ostat_args /* {
- syscallarg(char *) path;
- syscallarg(struct ostat *) ub;
- } */ *uap;
-{
- struct stat sb;
- struct ostat osb;
- int error;
- struct nameidata nd;
-
- NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE,
- SCARG(uap, path), p);
- if ((error = namei(&nd)) != 0)
- return (error);
- NDFREE(&nd, NDF_ONLY_PNBUF);
- error = vn_stat(nd.ni_vp, &sb, p);
- vput(nd.ni_vp);
- if (error)
- return (error);
- cvtstat(&sb, &osb);
- error = copyout((caddr_t)&osb, (caddr_t)SCARG(uap, ub), sizeof (osb));
- return (error);
-}
-
-/*
- * Get file status; this version does not follow links.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct olstat_args {
- char *path;
- struct ostat *ub;
-};
-#endif
-/* ARGSUSED */
-int
-olstat(p, uap)
- struct proc *p;
- register struct olstat_args /* {
- syscallarg(char *) path;
- syscallarg(struct ostat *) ub;
- } */ *uap;
-{
- struct vnode *vp;
- struct stat sb;
- struct ostat osb;
- int error;
- struct nameidata nd;
-
- NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE,
- SCARG(uap, path), p);
- if ((error = namei(&nd)) != 0)
- return (error);
- vp = nd.ni_vp;
- error = vn_stat(vp, &sb, p);
- NDFREE(&nd, NDF_ONLY_PNBUF);
- vput(vp);
- if (error)
- return (error);
- cvtstat(&sb, &osb);
- error = copyout((caddr_t)&osb, (caddr_t)SCARG(uap, ub), sizeof (osb));
- return (error);
-}
-
-/*
- * Convert from an old to a new stat structure.
- */
-void
-cvtstat(st, ost)
- struct stat *st;
- struct ostat *ost;
-{
-
- ost->st_dev = st->st_dev;
- ost->st_ino = st->st_ino;
- ost->st_mode = st->st_mode;
- ost->st_nlink = st->st_nlink;
- ost->st_uid = st->st_uid;
- ost->st_gid = st->st_gid;
- ost->st_rdev = st->st_rdev;
- if (st->st_size < (quad_t)1 << 32)
- ost->st_size = st->st_size;
- else
- ost->st_size = -2;
- ost->st_atime = st->st_atime;
- ost->st_mtime = st->st_mtime;
- ost->st_ctime = st->st_ctime;
- ost->st_blksize = st->st_blksize;
- ost->st_blocks = st->st_blocks;
- ost->st_flags = st->st_flags;
- ost->st_gen = st->st_gen;
-}
-#endif /* COMPAT_43 || COMPAT_SUNOS */
-
-/*
- * Get file status; this version follows links.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct stat_args {
- char *path;
- struct stat *ub;
-};
-#endif
-/* ARGSUSED */
-int
-stat(p, uap)
- struct proc *p;
- register struct stat_args /* {
- syscallarg(char *) path;
- syscallarg(struct stat *) ub;
- } */ *uap;
-{
- struct stat sb;
- int error;
- struct nameidata nd;
-
- NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE,
- SCARG(uap, path), p);
- if ((error = namei(&nd)) != 0)
- return (error);
- error = vn_stat(nd.ni_vp, &sb, p);
- NDFREE(&nd, NDF_ONLY_PNBUF);
- vput(nd.ni_vp);
- if (error)
- return (error);
- error = copyout((caddr_t)&sb, (caddr_t)SCARG(uap, ub), sizeof (sb));
- return (error);
-}
-
-/*
- * Get file status; this version does not follow links.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct lstat_args {
- char *path;
- struct stat *ub;
-};
-#endif
-/* ARGSUSED */
-int
-lstat(p, uap)
- struct proc *p;
- register struct lstat_args /* {
- syscallarg(char *) path;
- syscallarg(struct stat *) ub;
- } */ *uap;
-{
- int error;
- struct vnode *vp;
- struct stat sb;
- struct nameidata nd;
-
- NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE,
- SCARG(uap, path), p);
- if ((error = namei(&nd)) != 0)
- return (error);
- vp = nd.ni_vp;
- error = vn_stat(vp, &sb, p);
- NDFREE(&nd, NDF_ONLY_PNBUF);
- vput(vp);
- if (error)
- return (error);
- error = copyout((caddr_t)&sb, (caddr_t)SCARG(uap, ub), sizeof (sb));
- return (error);
-}
-
-void
-cvtnstat(sb, nsb)
- struct stat *sb;
- struct nstat *nsb;
-{
- nsb->st_dev = sb->st_dev;
- nsb->st_ino = sb->st_ino;
- nsb->st_mode = sb->st_mode;
- nsb->st_nlink = sb->st_nlink;
- nsb->st_uid = sb->st_uid;
- nsb->st_gid = sb->st_gid;
- nsb->st_rdev = sb->st_rdev;
- nsb->st_atimespec = sb->st_atimespec;
- nsb->st_mtimespec = sb->st_mtimespec;
- nsb->st_ctimespec = sb->st_ctimespec;
- nsb->st_size = sb->st_size;
- nsb->st_blocks = sb->st_blocks;
- nsb->st_blksize = sb->st_blksize;
- nsb->st_flags = sb->st_flags;
- nsb->st_gen = sb->st_gen;
- nsb->st_qspare[0] = sb->st_qspare[0];
- nsb->st_qspare[1] = sb->st_qspare[1];
-}
-
-#ifndef _SYS_SYSPROTO_H_
-struct nstat_args {
- char *path;
- struct nstat *ub;
-};
-#endif
-/* ARGSUSED */
-int
-nstat(p, uap)
- struct proc *p;
- register struct nstat_args /* {
- syscallarg(char *) path;
- syscallarg(struct nstat *) ub;
- } */ *uap;
-{
- struct stat sb;
- struct nstat nsb;
- int error;
- struct nameidata nd;
-
- NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE,
- SCARG(uap, path), p);
- if ((error = namei(&nd)) != 0)
- return (error);
- NDFREE(&nd, NDF_ONLY_PNBUF);
- error = vn_stat(nd.ni_vp, &sb, p);
- vput(nd.ni_vp);
- if (error)
- return (error);
- cvtnstat(&sb, &nsb);
- error = copyout((caddr_t)&nsb, (caddr_t)SCARG(uap, ub), sizeof (nsb));
- return (error);
-}
-
-/*
- * Get file status; this version does not follow links.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct lstat_args {
- char *path;
- struct stat *ub;
-};
-#endif
-/* ARGSUSED */
-int
-nlstat(p, uap)
- struct proc *p;
- register struct nlstat_args /* {
- syscallarg(char *) path;
- syscallarg(struct nstat *) ub;
- } */ *uap;
-{
- int error;
- struct vnode *vp;
- struct stat sb;
- struct nstat nsb;
- struct nameidata nd;
-
- NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE,
- SCARG(uap, path), p);
- if ((error = namei(&nd)) != 0)
- return (error);
- vp = nd.ni_vp;
- NDFREE(&nd, NDF_ONLY_PNBUF);
- error = vn_stat(vp, &sb, p);
- vput(vp);
- if (error)
- return (error);
- cvtnstat(&sb, &nsb);
- error = copyout((caddr_t)&nsb, (caddr_t)SCARG(uap, ub), sizeof (nsb));
- return (error);
-}
-
-/*
- * Get configurable pathname variables.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct pathconf_args {
- char *path;
- int name;
-};
-#endif
-/* ARGSUSED */
-int
-pathconf(p, uap)
- struct proc *p;
- register struct pathconf_args /* {
- syscallarg(char *) path;
- syscallarg(int) name;
- } */ *uap;
-{
- int error;
- struct nameidata nd;
-
- NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE,
- SCARG(uap, path), p);
- if ((error = namei(&nd)) != 0)
- return (error);
- NDFREE(&nd, NDF_ONLY_PNBUF);
- error = VOP_PATHCONF(nd.ni_vp, SCARG(uap, name), p->p_retval);
- vput(nd.ni_vp);
- return (error);
-}
-
-/*
- * Return target name of a symbolic link.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct readlink_args {
- char *path;
- char *buf;
- int count;
-};
-#endif
-/* ARGSUSED */
-int
-readlink(p, uap)
- struct proc *p;
- register struct readlink_args /* {
- syscallarg(char *) path;
- syscallarg(char *) buf;
- syscallarg(int) count;
- } */ *uap;
-{
- register struct vnode *vp;
- struct iovec aiov;
- struct uio auio;
- int error;
- struct nameidata nd;
-
- NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE,
- SCARG(uap, path), p);
- if ((error = namei(&nd)) != 0)
- return (error);
- NDFREE(&nd, NDF_ONLY_PNBUF);
- vp = nd.ni_vp;
- if (vp->v_type != VLNK)
- error = EINVAL;
- else {
- aiov.iov_base = SCARG(uap, buf);
- aiov.iov_len = SCARG(uap, count);
- auio.uio_iov = &aiov;
- auio.uio_iovcnt = 1;
- auio.uio_offset = 0;
- auio.uio_rw = UIO_READ;
- auio.uio_segflg = UIO_USERSPACE;
- auio.uio_procp = p;
- auio.uio_resid = SCARG(uap, count);
- error = VOP_READLINK(vp, &auio, p->p_ucred);
- }
- vput(vp);
- p->p_retval[0] = SCARG(uap, count) - auio.uio_resid;
- return (error);
-}
-
-static int
-setfflags(p, vp, flags)
- struct proc *p;
- struct vnode *vp;
- int flags;
-{
- int error;
- struct vattr vattr;
-
- /*
- * Prevent non-root users from setting flags on devices. When
- * a device is reused, users can retain ownership of the device
- * if they are allowed to set flags and programs assume that
- * chown can't fail when done as root.
- */
- if ((vp->v_type == VCHR || vp->v_type == VBLK) &&
- ((error = suser_xxx(p->p_ucred, p, PRISON_ROOT)) != 0))
- return (error);
-
- VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
- VATTR_NULL(&vattr);
- vattr.va_flags = flags;
- error = VOP_SETATTR(vp, &vattr, p->p_ucred, p);
- VOP_UNLOCK(vp, 0, p);
- return (error);
-}
-
-/*
- * Change flags of a file given a path name.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct chflags_args {
- char *path;
- int flags;
-};
-#endif
-/* ARGSUSED */
-int
-chflags(p, uap)
- struct proc *p;
- register struct chflags_args /* {
- syscallarg(char *) path;
- syscallarg(int) flags;
- } */ *uap;
-{
- int error;
- struct nameidata nd;
-
- NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
- if ((error = namei(&nd)) != 0)
- return (error);
- NDFREE(&nd, NDF_ONLY_PNBUF);
- error = setfflags(p, nd.ni_vp, SCARG(uap, flags));
- vrele(nd.ni_vp);
- return error;
-}
-
-/*
- * Change flags of a file given a file descriptor.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct fchflags_args {
- int fd;
- int flags;
-};
-#endif
-/* ARGSUSED */
-int
-fchflags(p, uap)
- struct proc *p;
- register struct fchflags_args /* {
- syscallarg(int) fd;
- syscallarg(int) flags;
- } */ *uap;
-{
- struct file *fp;
- int error;
-
- if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
- return (error);
- return setfflags(p, (struct vnode *) fp->f_data, SCARG(uap, flags));
-}
-
-static int
-setfmode(p, vp, mode)
- struct proc *p;
- struct vnode *vp;
- int mode;
-{
- int error;
- struct vattr vattr;
-
- VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
- VATTR_NULL(&vattr);
- vattr.va_mode = mode & ALLPERMS;
- error = VOP_SETATTR(vp, &vattr, p->p_ucred, p);
- VOP_UNLOCK(vp, 0, p);
- return error;
-}
-
-/*
- * Change mode of a file given path name.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct chmod_args {
- char *path;
- int mode;
-};
-#endif
-/* ARGSUSED */
-int
-chmod(p, uap)
- struct proc *p;
- register struct chmod_args /* {
- syscallarg(char *) path;
- syscallarg(int) mode;
- } */ *uap;
-{
- int error;
- struct nameidata nd;
-
- NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
- if ((error = namei(&nd)) != 0)
- return (error);
- NDFREE(&nd, NDF_ONLY_PNBUF);
- error = setfmode(p, nd.ni_vp, SCARG(uap, mode));
- vrele(nd.ni_vp);
- return error;
-}
-
-/*
- * Change mode of a file given path name (don't follow links.)
- */
-#ifndef _SYS_SYSPROTO_H_
-struct lchmod_args {
- char *path;
- int mode;
-};
-#endif
-/* ARGSUSED */
-int
-lchmod(p, uap)
- struct proc *p;
- register struct lchmod_args /* {
- syscallarg(char *) path;
- syscallarg(int) mode;
- } */ *uap;
-{
- int error;
- struct nameidata nd;
-
- NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
- if ((error = namei(&nd)) != 0)
- return (error);
- NDFREE(&nd, NDF_ONLY_PNBUF);
- error = setfmode(p, nd.ni_vp, SCARG(uap, mode));
- vrele(nd.ni_vp);
- return error;
-}
-
-/*
- * Change mode of a file given a file descriptor.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct fchmod_args {
- int fd;
- int mode;
-};
-#endif
-/* ARGSUSED */
-int
-fchmod(p, uap)
- struct proc *p;
- register struct fchmod_args /* {
- syscallarg(int) fd;
- syscallarg(int) mode;
- } */ *uap;
-{
- struct file *fp;
- int error;
-
- if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
- return (error);
- return setfmode(p, (struct vnode *)fp->f_data, SCARG(uap, mode));
-}
-
-static int
-setfown(p, vp, uid, gid)
- struct proc *p;
- struct vnode *vp;
- uid_t uid;
- gid_t gid;
-{
- int error;
- struct vattr vattr;
-
- VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
- VATTR_NULL(&vattr);
- vattr.va_uid = uid;
- vattr.va_gid = gid;
- error = VOP_SETATTR(vp, &vattr, p->p_ucred, p);
- VOP_UNLOCK(vp, 0, p);
- return error;
-}
-
-/*
- * Set ownership given a path name.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct chown_args {
- char *path;
- int uid;
- int gid;
-};
-#endif
-/* ARGSUSED */
-int
-chown(p, uap)
- struct proc *p;
- register struct chown_args /* {
- syscallarg(char *) path;
- syscallarg(int) uid;
- syscallarg(int) gid;
- } */ *uap;
-{
- int error;
- struct nameidata nd;
-
- NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
- if ((error = namei(&nd)) != 0)
- return (error);
- NDFREE(&nd, NDF_ONLY_PNBUF);
- error = setfown(p, nd.ni_vp, SCARG(uap, uid), SCARG(uap, gid));
- vrele(nd.ni_vp);
- return (error);
-}
-
-/*
- * Set ownership given a path name, do not cross symlinks.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct lchown_args {
- char *path;
- int uid;
- int gid;
-};
-#endif
-/* ARGSUSED */
-int
-lchown(p, uap)
- struct proc *p;
- register struct lchown_args /* {
- syscallarg(char *) path;
- syscallarg(int) uid;
- syscallarg(int) gid;
- } */ *uap;
-{
- int error;
- struct nameidata nd;
-
- NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
- if ((error = namei(&nd)) != 0)
- return (error);
- NDFREE(&nd, NDF_ONLY_PNBUF);
- error = setfown(p, nd.ni_vp, SCARG(uap, uid), SCARG(uap, gid));
- vrele(nd.ni_vp);
- return (error);
-}
-
-/*
- * Set ownership given a file descriptor.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct fchown_args {
- int fd;
- int uid;
- int gid;
-};
-#endif
-/* ARGSUSED */
-int
-fchown(p, uap)
- struct proc *p;
- register struct fchown_args /* {
- syscallarg(int) fd;
- syscallarg(int) uid;
- syscallarg(int) gid;
- } */ *uap;
-{
- struct file *fp;
- int error;
-
- if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
- return (error);
- return setfown(p, (struct vnode *)fp->f_data,
- SCARG(uap, uid), SCARG(uap, gid));
-}
-
-static int
-getutimes(usrtvp, tsp)
- const struct timeval *usrtvp;
- struct timespec *tsp;
-{
- struct timeval tv[2];
- int error;
-
- if (usrtvp == NULL) {
- microtime(&tv[0]);
- TIMEVAL_TO_TIMESPEC(&tv[0], &tsp[0]);
- tsp[1] = tsp[0];
- } else {
- if ((error = copyin(usrtvp, tv, sizeof (tv))) != 0)
- return (error);
- TIMEVAL_TO_TIMESPEC(&tv[0], &tsp[0]);
- TIMEVAL_TO_TIMESPEC(&tv[1], &tsp[1]);
- }
- return 0;
-}
-
-static int
-setutimes(p, vp, ts, nullflag)
- struct proc *p;
- struct vnode *vp;
- const struct timespec *ts;
- int nullflag;
-{
- int error;
- struct vattr vattr;
-
- VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
- VATTR_NULL(&vattr);
- vattr.va_atime = ts[0];
- vattr.va_mtime = ts[1];
- if (nullflag)
- vattr.va_vaflags |= VA_UTIMES_NULL;
- error = VOP_SETATTR(vp, &vattr, p->p_ucred, p);
- VOP_UNLOCK(vp, 0, p);
- return error;
-}
-
-/*
- * Set the access and modification times of a file.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct utimes_args {
- char *path;
- struct timeval *tptr;
-};
-#endif
-/* ARGSUSED */
-int
-utimes(p, uap)
- struct proc *p;
- register struct utimes_args /* {
- syscallarg(char *) path;
- syscallarg(struct timeval *) tptr;
- } */ *uap;
-{
- struct timespec ts[2];
- struct timeval *usrtvp;
- int error;
- struct nameidata nd;
-
- usrtvp = SCARG(uap, tptr);
- if ((error = getutimes(usrtvp, ts)) != 0)
- return (error);
- NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
- if ((error = namei(&nd)) != 0)
- return (error);
- NDFREE(&nd, NDF_ONLY_PNBUF);
- error = setutimes(p, nd.ni_vp, ts, usrtvp == NULL);
- vrele(nd.ni_vp);
- return (error);
-}
-
-/*
- * Set the access and modification times of a file.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct lutimes_args {
- char *path;
- struct timeval *tptr;
-};
-#endif
-/* ARGSUSED */
-int
-lutimes(p, uap)
- struct proc *p;
- register struct lutimes_args /* {
- syscallarg(char *) path;
- syscallarg(struct timeval *) tptr;
- } */ *uap;
-{
- struct timespec ts[2];
- struct timeval *usrtvp;
- int error;
- struct nameidata nd;
-
- usrtvp = SCARG(uap, tptr);
- if ((error = getutimes(usrtvp, ts)) != 0)
- return (error);
- NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
- if ((error = namei(&nd)) != 0)
- return (error);
- NDFREE(&nd, NDF_ONLY_PNBUF);
- error = setutimes(p, nd.ni_vp, ts, usrtvp == NULL);
- vrele(nd.ni_vp);
- return (error);
-}
-
-/*
- * Set the access and modification times of a file.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct futimes_args {
- int fd;
- struct timeval *tptr;
-};
-#endif
-/* ARGSUSED */
-int
-futimes(p, uap)
- struct proc *p;
- register struct futimes_args /* {
- syscallarg(int ) fd;
- syscallarg(struct timeval *) tptr;
- } */ *uap;
-{
- struct timespec ts[2];
- struct file *fp;
- struct timeval *usrtvp;
- int error;
-
- usrtvp = SCARG(uap, tptr);
- if ((error = getutimes(usrtvp, ts)) != 0)
- return (error);
- if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
- return (error);
- return setutimes(p, (struct vnode *)fp->f_data, ts, usrtvp == NULL);
-}
-
-/*
- * Truncate a file given its path name.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct truncate_args {
- char *path;
- int pad;
- off_t length;
-};
-#endif
-/* ARGSUSED */
-int
-truncate(p, uap)
- struct proc *p;
- register struct truncate_args /* {
- syscallarg(char *) path;
- syscallarg(int) pad;
- syscallarg(off_t) length;
- } */ *uap;
-{
- register struct vnode *vp;
- struct vattr vattr;
- int error;
- struct nameidata nd;
-
- if (uap->length < 0)
- return(EINVAL);
- NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
- if ((error = namei(&nd)) != 0)
- return (error);
- vp = nd.ni_vp;
- NDFREE(&nd, NDF_ONLY_PNBUF);
- VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
- if (vp->v_type == VDIR)
- error = EISDIR;
- else if ((error = vn_writechk(vp)) == 0 &&
- (error = VOP_ACCESS(vp, VWRITE, p->p_ucred, p)) == 0) {
- VATTR_NULL(&vattr);
- vattr.va_size = SCARG(uap, length);
- error = VOP_SETATTR(vp, &vattr, p->p_ucred, p);
- }
- vput(vp);
- return (error);
-}
-
-/*
- * Truncate a file given a file descriptor.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct ftruncate_args {
- int fd;
- int pad;
- off_t length;
-};
-#endif
-/* ARGSUSED */
-int
-ftruncate(p, uap)
- struct proc *p;
- register struct ftruncate_args /* {
- syscallarg(int) fd;
- syscallarg(int) pad;
- syscallarg(off_t) length;
- } */ *uap;
-{
- struct vattr vattr;
- struct vnode *vp;
- struct file *fp;
- int error;
-
- if (uap->length < 0)
- return(EINVAL);
- if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
- return (error);
- if ((fp->f_flag & FWRITE) == 0)
- return (EINVAL);
- vp = (struct vnode *)fp->f_data;
- VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
- if (vp->v_type == VDIR)
- error = EISDIR;
- else if ((error = vn_writechk(vp)) == 0) {
- VATTR_NULL(&vattr);
- vattr.va_size = SCARG(uap, length);
- error = VOP_SETATTR(vp, &vattr, fp->f_cred, p);
- }
- VOP_UNLOCK(vp, 0, p);
- return (error);
-}
-
-#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
-/*
- * Truncate a file given its path name.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct otruncate_args {
- char *path;
- long length;
-};
-#endif
-/* ARGSUSED */
-int
-otruncate(p, uap)
- struct proc *p;
- register struct otruncate_args /* {
- syscallarg(char *) path;
- syscallarg(long) length;
- } */ *uap;
-{
- struct truncate_args /* {
- syscallarg(char *) path;
- syscallarg(int) pad;
- syscallarg(off_t) length;
- } */ nuap;
-
- SCARG(&nuap, path) = SCARG(uap, path);
- SCARG(&nuap, length) = SCARG(uap, length);
- return (truncate(p, &nuap));
-}
-
-/*
- * Truncate a file given a file descriptor.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct oftruncate_args {
- int fd;
- long length;
-};
-#endif
-/* ARGSUSED */
-int
-oftruncate(p, uap)
- struct proc *p;
- register struct oftruncate_args /* {
- syscallarg(int) fd;
- syscallarg(long) length;
- } */ *uap;
-{
- struct ftruncate_args /* {
- syscallarg(int) fd;
- syscallarg(int) pad;
- syscallarg(off_t) length;
- } */ nuap;
-
- SCARG(&nuap, fd) = SCARG(uap, fd);
- SCARG(&nuap, length) = SCARG(uap, length);
- return (ftruncate(p, &nuap));
-}
-#endif /* COMPAT_43 || COMPAT_SUNOS */
-
-/*
- * Sync an open file.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct fsync_args {
- int fd;
-};
-#endif
-/* ARGSUSED */
-int
-fsync(p, uap)
- struct proc *p;
- struct fsync_args /* {
- syscallarg(int) fd;
- } */ *uap;
-{
- register struct vnode *vp;
- struct file *fp;
- int error;
-
- if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
- return (error);
- vp = (struct vnode *)fp->f_data;
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
- if (vp->v_object)
- vm_object_page_clean(vp->v_object, 0, 0, 0);
- if ((error = VOP_FSYNC(vp, fp->f_cred, MNT_WAIT, p)) == 0 &&
- vp->v_mount && (vp->v_mount->mnt_flag & MNT_SOFTDEP) &&
- bioops.io_fsync)
- error = (*bioops.io_fsync)(vp);
- VOP_UNLOCK(vp, 0, p);
- return (error);
-}
-
-/*
- * Rename files. Source and destination must either both be directories,
- * or both not be directories. If target is a directory, it must be empty.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct rename_args {
- char *from;
- char *to;
-};
-#endif
-/* ARGSUSED */
-int
-rename(p, uap)
- struct proc *p;
- register struct rename_args /* {
- syscallarg(char *) from;
- syscallarg(char *) to;
- } */ *uap;
-{
- register struct vnode *tvp, *fvp, *tdvp;
- struct nameidata fromnd, tond;
- int error;
-
- bwillwrite();
- NDINIT(&fromnd, DELETE, WANTPARENT | SAVESTART, UIO_USERSPACE,
- SCARG(uap, from), p);
- if ((error = namei(&fromnd)) != 0)
- return (error);
- fvp = fromnd.ni_vp;
- NDINIT(&tond, RENAME, LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART | NOOBJ,
- UIO_USERSPACE, SCARG(uap, to), p);
- if (fromnd.ni_vp->v_type == VDIR)
- tond.ni_cnd.cn_flags |= WILLBEDIR;
- if ((error = namei(&tond)) != 0) {
- /* Translate error code for rename("dir1", "dir2/."). */
- if (error == EISDIR && fvp->v_type == VDIR)
- error = EINVAL;
- NDFREE(&fromnd, NDF_ONLY_PNBUF);
- vrele(fromnd.ni_dvp);
- vrele(fvp);
- goto out1;
- }
- tdvp = tond.ni_dvp;
- tvp = tond.ni_vp;
- if (tvp != NULL) {
- if (fvp->v_type == VDIR && tvp->v_type != VDIR) {
- error = ENOTDIR;
- goto out;
- } else if (fvp->v_type != VDIR && tvp->v_type == VDIR) {
- error = EISDIR;
- goto out;
- }
- }
- if (fvp == tdvp)
- error = EINVAL;
- /*
- * If source is the same as the destination (that is the
- * same inode number with the same name in the same directory),
- * then there is nothing to do.
- */
- if (fvp == tvp && fromnd.ni_dvp == tdvp &&
- fromnd.ni_cnd.cn_namelen == tond.ni_cnd.cn_namelen &&
- !bcmp(fromnd.ni_cnd.cn_nameptr, tond.ni_cnd.cn_nameptr,
- fromnd.ni_cnd.cn_namelen))
- error = -1;
-out:
- if (!error) {
- VOP_LEASE(tdvp, p, p->p_ucred, LEASE_WRITE);
- if (fromnd.ni_dvp != tdvp) {
- VOP_LEASE(fromnd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
- }
- if (tvp) {
- VOP_LEASE(tvp, p, p->p_ucred, LEASE_WRITE);
- }
- error = VOP_RENAME(fromnd.ni_dvp, fromnd.ni_vp, &fromnd.ni_cnd,
- tond.ni_dvp, tond.ni_vp, &tond.ni_cnd);
- NDFREE(&fromnd, NDF_ONLY_PNBUF);
- NDFREE(&tond, NDF_ONLY_PNBUF);
- } else {
- NDFREE(&fromnd, NDF_ONLY_PNBUF);
- NDFREE(&tond, NDF_ONLY_PNBUF);
- if (tdvp == tvp)
- vrele(tdvp);
- else
- vput(tdvp);
- if (tvp)
- vput(tvp);
- vrele(fromnd.ni_dvp);
- vrele(fvp);
- }
- vrele(tond.ni_startdir);
- ASSERT_VOP_UNLOCKED(fromnd.ni_dvp, "rename");
- ASSERT_VOP_UNLOCKED(fromnd.ni_vp, "rename");
- ASSERT_VOP_UNLOCKED(tond.ni_dvp, "rename");
- ASSERT_VOP_UNLOCKED(tond.ni_vp, "rename");
-out1:
- if (fromnd.ni_startdir)
- vrele(fromnd.ni_startdir);
- if (error == -1)
- return (0);
- return (error);
-}
-
-/*
- * Make a directory file.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct mkdir_args {
- char *path;
- int mode;
-};
-#endif
-/* ARGSUSED */
-int
-mkdir(p, uap)
- struct proc *p;
- register struct mkdir_args /* {
- syscallarg(char *) path;
- syscallarg(int) mode;
- } */ *uap;
-{
- register struct vnode *vp;
- struct vattr vattr;
- int error;
- struct nameidata nd;
-
- bwillwrite();
- NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, SCARG(uap, path), p);
- nd.ni_cnd.cn_flags |= WILLBEDIR;
- if ((error = namei(&nd)) != 0)
- return (error);
- vp = nd.ni_vp;
- if (vp != NULL) {
- NDFREE(&nd, NDF_ONLY_PNBUF);
- if (nd.ni_dvp == vp)
- vrele(nd.ni_dvp);
- else
- vput(nd.ni_dvp);
- vrele(vp);
- return (EEXIST);
- }
- VATTR_NULL(&vattr);
- vattr.va_type = VDIR;
- vattr.va_mode = (SCARG(uap, mode) & ACCESSPERMS) &~ p->p_fd->fd_cmask;
- VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
- error = VOP_MKDIR(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr);
- NDFREE(&nd, NDF_ONLY_PNBUF);
- vput(nd.ni_dvp);
- if (!error)
- vput(nd.ni_vp);
- ASSERT_VOP_UNLOCKED(nd.ni_dvp, "mkdir");
- ASSERT_VOP_UNLOCKED(nd.ni_vp, "mkdir");
- return (error);
-}
-
-/*
- * Remove a directory file.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct rmdir_args {
- char *path;
-};
-#endif
-/* ARGSUSED */
-int
-rmdir(p, uap)
- struct proc *p;
- struct rmdir_args /* {
- syscallarg(char *) path;
- } */ *uap;
-{
- register struct vnode *vp;
- int error;
- struct nameidata nd;
-
- bwillwrite();
- NDINIT(&nd, DELETE, LOCKPARENT | LOCKLEAF, UIO_USERSPACE,
- SCARG(uap, path), p);
- if ((error = namei(&nd)) != 0)
- return (error);
- vp = nd.ni_vp;
- if (vp->v_type != VDIR) {
- error = ENOTDIR;
- goto out;
- }
- /*
- * No rmdir "." please.
- */
- if (nd.ni_dvp == vp) {
- error = EINVAL;
- goto out;
- }
- /*
- * The root of a mounted filesystem cannot be deleted.
- */
- if (vp->v_flag & VROOT)
- error = EBUSY;
- else {
- VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
- VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
- error = VOP_RMDIR(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd);
- }
-out:
- NDFREE(&nd, NDF_ONLY_PNBUF);
- if (nd.ni_dvp == vp)
- vrele(nd.ni_dvp);
- else
- vput(nd.ni_dvp);
- if (vp != NULLVP)
- vput(vp);
- ASSERT_VOP_UNLOCKED(nd.ni_dvp, "rmdir");
- ASSERT_VOP_UNLOCKED(nd.ni_vp, "rmdir");
- return (error);
-}
-
-#ifdef COMPAT_43
-/*
- * Read a block of directory entries in a file system independent format.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct ogetdirentries_args {
- int fd;
- char *buf;
- u_int count;
- long *basep;
-};
-#endif
-int
-ogetdirentries(p, uap)
- struct proc *p;
- register struct ogetdirentries_args /* {
- syscallarg(int) fd;
- syscallarg(char *) buf;
- syscallarg(u_int) count;
- syscallarg(long *) basep;
- } */ *uap;
-{
- struct vnode *vp;
- struct file *fp;
- struct uio auio, kuio;
- struct iovec aiov, kiov;
- struct dirent *dp, *edp;
- caddr_t dirbuf;
- int error, eofflag, readcnt;
- long loff;
-
- if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
- return (error);
- if ((fp->f_flag & FREAD) == 0)
- return (EBADF);
- vp = (struct vnode *)fp->f_data;
-unionread:
- if (vp->v_type != VDIR)
- return (EINVAL);
- aiov.iov_base = SCARG(uap, buf);
- aiov.iov_len = SCARG(uap, count);
- auio.uio_iov = &aiov;
- auio.uio_iovcnt = 1;
- auio.uio_rw = UIO_READ;
- auio.uio_segflg = UIO_USERSPACE;
- auio.uio_procp = p;
- auio.uio_resid = SCARG(uap, count);
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
- loff = auio.uio_offset = fp->f_offset;
-# if (BYTE_ORDER != LITTLE_ENDIAN)
- if (vp->v_mount->mnt_maxsymlinklen <= 0) {
- error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag,
- NULL, NULL);
- fp->f_offset = auio.uio_offset;
- } else
-# endif
- {
- kuio = auio;
- kuio.uio_iov = &kiov;
- kuio.uio_segflg = UIO_SYSSPACE;
- kiov.iov_len = SCARG(uap, count);
- MALLOC(dirbuf, caddr_t, SCARG(uap, count), M_TEMP, M_WAITOK);
- kiov.iov_base = dirbuf;
- error = VOP_READDIR(vp, &kuio, fp->f_cred, &eofflag,
- NULL, NULL);
- fp->f_offset = kuio.uio_offset;
- if (error == 0) {
- readcnt = SCARG(uap, count) - kuio.uio_resid;
- edp = (struct dirent *)&dirbuf[readcnt];
- for (dp = (struct dirent *)dirbuf; dp < edp; ) {
-# if (BYTE_ORDER == LITTLE_ENDIAN)
- /*
- * The expected low byte of
- * dp->d_namlen is our dp->d_type.
- * The high MBZ byte of dp->d_namlen
- * is our dp->d_namlen.
- */
- dp->d_type = dp->d_namlen;
- dp->d_namlen = 0;
-# else
- /*
- * The dp->d_type is the high byte
- * of the expected dp->d_namlen,
- * so must be zero'ed.
- */
- dp->d_type = 0;
-# endif
- if (dp->d_reclen > 0) {
- dp = (struct dirent *)
- ((char *)dp + dp->d_reclen);
- } else {
- error = EIO;
- break;
- }
- }
- if (dp >= edp)
- error = uiomove(dirbuf, readcnt, &auio);
- }
- FREE(dirbuf, M_TEMP);
- }
- VOP_UNLOCK(vp, 0, p);
- if (error)
- return (error);
- if (SCARG(uap, count) == auio.uio_resid) {
- if (union_dircheckp) {
- error = union_dircheckp(p, &vp, fp);
- if (error == -1)
- goto unionread;
- if (error)
- return (error);
- }
- if ((vp->v_flag & VROOT) &&
- (vp->v_mount->mnt_flag & MNT_UNION)) {
- struct vnode *tvp = vp;
- vp = vp->v_mount->mnt_vnodecovered;
- VREF(vp);
- fp->f_data = (caddr_t) vp;
- fp->f_offset = 0;
- vrele(tvp);
- goto unionread;
- }
- }
- error = copyout((caddr_t)&loff, (caddr_t)SCARG(uap, basep),
- sizeof(long));
- p->p_retval[0] = SCARG(uap, count) - auio.uio_resid;
- return (error);
-}
-#endif /* COMPAT_43 */
-
-/*
- * Read a block of directory entries in a file system independent format.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct getdirentries_args {
- int fd;
- char *buf;
- u_int count;
- long *basep;
-};
-#endif
-int
-getdirentries(p, uap)
- struct proc *p;
- register struct getdirentries_args /* {
- syscallarg(int) fd;
- syscallarg(char *) buf;
- syscallarg(u_int) count;
- syscallarg(long *) basep;
- } */ *uap;
-{
- struct vnode *vp;
- struct file *fp;
- struct uio auio;
- struct iovec aiov;
- long loff;
- int error, eofflag;
-
- if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
- return (error);
- if ((fp->f_flag & FREAD) == 0)
- return (EBADF);
- vp = (struct vnode *)fp->f_data;
-unionread:
- if (vp->v_type != VDIR)
- return (EINVAL);
- aiov.iov_base = SCARG(uap, buf);
- aiov.iov_len = SCARG(uap, count);
- auio.uio_iov = &aiov;
- auio.uio_iovcnt = 1;
- auio.uio_rw = UIO_READ;
- auio.uio_segflg = UIO_USERSPACE;
- auio.uio_procp = p;
- auio.uio_resid = SCARG(uap, count);
- /* vn_lock(vp, LK_SHARED | LK_RETRY, p); */
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
- loff = auio.uio_offset = fp->f_offset;
- error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, NULL, NULL);
- fp->f_offset = auio.uio_offset;
- VOP_UNLOCK(vp, 0, p);
- if (error)
- return (error);
- if (SCARG(uap, count) == auio.uio_resid) {
- if (union_dircheckp) {
- error = union_dircheckp(p, &vp, fp);
- if (error == -1)
- goto unionread;
- if (error)
- return (error);
- }
- if ((vp->v_flag & VROOT) &&
- (vp->v_mount->mnt_flag & MNT_UNION)) {
- struct vnode *tvp = vp;
- vp = vp->v_mount->mnt_vnodecovered;
- VREF(vp);
- fp->f_data = (caddr_t) vp;
- fp->f_offset = 0;
- vrele(tvp);
- goto unionread;
- }
- }
- if (SCARG(uap, basep) != NULL) {
- error = copyout((caddr_t)&loff, (caddr_t)SCARG(uap, basep),
- sizeof(long));
- }
- p->p_retval[0] = SCARG(uap, count) - auio.uio_resid;
- return (error);
-}
-#ifndef _SYS_SYSPROTO_H_
-struct getdents_args {
- int fd;
- char *buf;
- size_t count;
-};
-#endif
-int
-getdents(p, uap)
- struct proc *p;
- register struct getdents_args /* {
- syscallarg(int) fd;
- syscallarg(char *) buf;
- syscallarg(u_int) count;
- } */ *uap;
-{
- struct getdirentries_args ap;
- ap.fd = uap->fd;
- ap.buf = uap->buf;
- ap.count = uap->count;
- ap.basep = NULL;
- return getdirentries(p, &ap);
-}
-
-/*
- * Set the mode mask for creation of filesystem nodes.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct umask_args {
- int newmask;
-};
-#endif
-int
-umask(p, uap)
- struct proc *p;
- struct umask_args /* {
- syscallarg(int) newmask;
- } */ *uap;
-{
- register struct filedesc *fdp;
-
- fdp = p->p_fd;
- p->p_retval[0] = fdp->fd_cmask;
- fdp->fd_cmask = SCARG(uap, newmask) & ALLPERMS;
- return (0);
-}
-
-/*
- * Void all references to file by ripping underlying filesystem
- * away from vnode.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct revoke_args {
- char *path;
-};
-#endif
-/* ARGSUSED */
-int
-revoke(p, uap)
- struct proc *p;
- register struct revoke_args /* {
- syscallarg(char *) path;
- } */ *uap;
-{
- register struct vnode *vp;
- struct vattr vattr;
- int error;
- struct nameidata nd;
-
- NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
- if ((error = namei(&nd)) != 0)
- return (error);
- vp = nd.ni_vp;
- NDFREE(&nd, NDF_ONLY_PNBUF);
- if (vp->v_type != VCHR && vp->v_type != VBLK) {
- error = EINVAL;
- goto out;
- }
- if ((error = VOP_GETATTR(vp, &vattr, p->p_ucred, p)) != 0)
- goto out;
- if (p->p_ucred->cr_uid != vattr.va_uid &&
- (error = suser_xxx(0, p, PRISON_ROOT)))
- goto out;
- if (vcount(vp) > 1)
- VOP_REVOKE(vp, REVOKEALL);
-out:
- vrele(vp);
- return (error);
-}
-
-/*
- * Convert a user file descriptor to a kernel file entry.
- */
-int
-getvnode(fdp, fd, fpp)
- struct filedesc *fdp;
- int fd;
- struct file **fpp;
-{
- struct file *fp;
-
- if ((u_int)fd >= fdp->fd_nfiles ||
- (fp = fdp->fd_ofiles[fd]) == NULL)
- return (EBADF);
- if (fp->f_type != DTYPE_VNODE && fp->f_type != DTYPE_FIFO)
- return (EINVAL);
- *fpp = fp;
- return (0);
-}
-/*
- * Get (NFS) file handle
- */
-#ifndef _SYS_SYSPROTO_H_
-struct getfh_args {
- char *fname;
- fhandle_t *fhp;
-};
-#endif
-int
-getfh(p, uap)
- struct proc *p;
- register struct getfh_args *uap;
-{
- struct nameidata nd;
- fhandle_t fh;
- register struct vnode *vp;
- int error;
-
- /*
- * Must be super user
- */
- error = suser(p);
- if (error)
- return (error);
- NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->fname, p);
- error = namei(&nd);
- if (error)
- return (error);
- NDFREE(&nd, NDF_ONLY_PNBUF);
- vp = nd.ni_vp;
- bzero(&fh, sizeof(fh));
- fh.fh_fsid = vp->v_mount->mnt_stat.f_fsid;
- error = VFS_VPTOFH(vp, &fh.fh_fid);
- vput(vp);
- if (error)
- return (error);
- error = copyout(&fh, uap->fhp, sizeof (fh));
- return (error);
-}
-
-/*
- * syscall for the rpc.lockd to use to translate a NFS file handle into
- * an open descriptor.
- *
- * warning: do not remove the suser() call or this becomes one giant
- * security hole.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct fhopen_args {
- const struct fhandle *u_fhp;
- int flags;
-};
-#endif
-int
-fhopen(p, uap)
- struct proc *p;
- struct fhopen_args /* {
- syscallarg(const struct fhandle *) u_fhp;
- syscallarg(int) flags;
- } */ *uap;
-{
- struct mount *mp;
- struct vnode *vp;
- struct fhandle fhp;
- struct vattr vat;
- struct vattr *vap = &vat;
- struct flock lf;
- struct file *fp;
- register struct filedesc *fdp = p->p_fd;
- int fmode, mode, error, type;
- struct file *nfp;
- int indx;
-
- /*
- * Must be super user
- */
- error = suser(p);
- if (error)
- return (error);
-
- fmode = FFLAGS(SCARG(uap, flags));
- /* why not allow a non-read/write open for our lockd? */
- if (((fmode & (FREAD | FWRITE)) == 0) || (fmode & O_CREAT))
- return (EINVAL);
- error = copyin(SCARG(uap,u_fhp), &fhp, sizeof(fhp));
- if (error)
- return(error);
- /* find the mount point */
- mp = vfs_getvfs(&fhp.fh_fsid);
- if (mp == NULL)
- return (ESTALE);
- /* now give me my vnode, it gets returned to me locked */
- error = VFS_FHTOVP(mp, &fhp.fh_fid, &vp);
- if (error)
- return (error);
- /*
- * from now on we have to make sure not
- * to forget about the vnode
- * any error that causes an abort must vput(vp)
- * just set error = err and 'goto bad;'.
- */
-
- /*
- * from vn_open
- */
- if (vp->v_type == VLNK) {
- error = EMLINK;
- goto bad;
- }
- if (vp->v_type == VSOCK) {
- error = EOPNOTSUPP;
- goto bad;
- }
- mode = 0;
- if (fmode & (FWRITE | O_TRUNC)) {
- if (vp->v_type == VDIR) {
- error = EISDIR;
- goto bad;
- }
- error = vn_writechk(vp);
- if (error)
- goto bad;
- mode |= VWRITE;
- }
- if (fmode & FREAD)
- mode |= VREAD;
- if (mode) {
- error = VOP_ACCESS(vp, mode, p->p_ucred, p);
- if (error)
- goto bad;
- }
- if (fmode & O_TRUNC) {
- VOP_UNLOCK(vp, 0, p); /* XXX */
- VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); /* XXX */
- VATTR_NULL(vap);
- vap->va_size = 0;
- error = VOP_SETATTR(vp, vap, p->p_ucred, p);
- if (error)
- goto bad;
- }
- error = VOP_OPEN(vp, fmode, p->p_ucred, p);
- if (error)
- goto bad;
- /*
- * Make sure that a VM object is created for VMIO support.
- */
- if (vn_canvmio(vp) == TRUE) {
- if ((error = vfs_object_create(vp, p, p->p_ucred)) != 0)
- goto bad;
- }
- if (fmode & FWRITE)
- vp->v_writecount++;
-
- /*
- * end of vn_open code
- */
-
- if ((error = falloc(p, &nfp, &indx)) != 0)
- goto bad;
- fp = nfp;
- nfp->f_data = (caddr_t)vp;
- nfp->f_flag = fmode & FMASK;
- nfp->f_ops = &vnops;
- nfp->f_type = DTYPE_VNODE;
- if (fmode & (O_EXLOCK | O_SHLOCK)) {
- lf.l_whence = SEEK_SET;
- lf.l_start = 0;
- lf.l_len = 0;
- if (fmode & O_EXLOCK)
- lf.l_type = F_WRLCK;
- else
- lf.l_type = F_RDLCK;
- type = F_FLOCK;
- if ((fmode & FNONBLOCK) == 0)
- type |= F_WAIT;
- VOP_UNLOCK(vp, 0, p);
- if ((error = VOP_ADVLOCK(vp, (caddr_t)fp, F_SETLK, &lf, type)) != 0) {
- (void) vn_close(vp, fp->f_flag, fp->f_cred, p);
- ffree(fp);
- fdp->fd_ofiles[indx] = NULL;
- return (error);
- }
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
- fp->f_flag |= FHASLOCK;
- }
- if ((vp->v_type == VREG) && (vp->v_object == NULL))
- vfs_object_create(vp, p, p->p_ucred);
-
- VOP_UNLOCK(vp, 0, p);
- p->p_retval[0] = indx;
- return (0);
-
-bad:
- vput(vp);
- return (error);
-}
-
-#ifndef _SYS_SYSPROTO_H_
-struct fhstat_args {
- struct fhandle *u_fhp;
- struct stat *sb;
-};
-#endif
-int
-fhstat(p, uap)
- struct proc *p;
- register struct fhstat_args /* {
- syscallarg(struct fhandle *) u_fhp;
- syscallarg(struct stat *) sb;
- } */ *uap;
-{
- struct stat sb;
- fhandle_t fh;
- struct mount *mp;
- struct vnode *vp;
- int error;
-
- /*
- * Must be super user
- */
- error = suser(p);
- if (error)
- return (error);
-
- error = copyin(SCARG(uap, u_fhp), &fh, sizeof(fhandle_t));
- if (error)
- return (error);
-
- if ((mp = vfs_getvfs(&fh.fh_fsid)) == NULL)
- return (ESTALE);
- if ((error = VFS_FHTOVP(mp, &fh.fh_fid, &vp)))
- return (error);
- error = vn_stat(vp, &sb, p);
- vput(vp);
- if (error)
- return (error);
- error = copyout(&sb, SCARG(uap, sb), sizeof(sb));
- return (error);
-}
-
-#ifndef _SYS_SYSPROTO_H_
-struct fhstatfs_args {
- struct fhandle *u_fhp;
- struct statfs *buf;
-};
-#endif
-int
-fhstatfs(p, uap)
- struct proc *p;
- struct fhstatfs_args /* {
- syscallarg(struct fhandle) *u_fhp;
- syscallarg(struct statfs) *buf;
- } */ *uap;
-{
- struct statfs *sp;
- struct mount *mp;
- struct vnode *vp;
- struct statfs sb;
- fhandle_t fh;
- int error;
-
- /*
- * Must be super user
- */
- if ((error = suser(p)))
- return (error);
-
- if ((error = copyin(SCARG(uap, u_fhp), &fh, sizeof(fhandle_t))) != 0)
- return (error);
-
- if ((mp = vfs_getvfs(&fh.fh_fsid)) == NULL)
- return (ESTALE);
- if ((error = VFS_FHTOVP(mp, &fh.fh_fid, &vp)))
- return (error);
- mp = vp->v_mount;
- sp = &mp->mnt_stat;
- vput(vp);
- if ((error = VFS_STATFS(mp, sp, p)) != 0)
- return (error);
- sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
- if (suser_xxx(p->p_ucred, 0, 0)) {
- bcopy((caddr_t)sp, (caddr_t)&sb, sizeof(sb));
- sb.f_fsid.val[0] = sb.f_fsid.val[1] = 0;
- sp = &sb;
- }
- return (copyout(sp, SCARG(uap, buf), sizeof(*sp)));
-}
-
-/*
- * Syscall to push extended attribute configuration information into the
- * VFS. Accepts a path, which it converts to a mountpoint, as well as
- * a command (int cmd), and attribute name and misc data. For now, the
- * attribute name is left in userspace for consumption by the VFS_op.
- * It will probably be changed to be copied into sysspace by the
- * syscall in the future, once issues with various consumers of the
- * attribute code have raised their hands.
- *
- * Currently this is used only by UFS Extended Attributes.
- */
-int
-extattrctl(p, uap)
- struct proc *p;
- struct extattrctl_args *uap;
-{
- struct nameidata nd;
- struct mount *mp;
- int error;
-
- NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
- if ((error = namei(&nd)) != 0)
- return (error);
- mp = nd.ni_vp->v_mount;
- NDFREE(&nd, 0);
- return (VFS_EXTATTRCTL(mp, SCARG(uap, cmd), SCARG(uap, attrname),
- SCARG(uap, arg), p));
-}
-
-/*
- * Syscall to set a named extended attribute on a file or directory.
- * Accepts attribute name, and a uio structure pointing to the data to set.
- * The uio is consumed in the style of writev(). The real work happens
- * in VOP_SETEXTATTR().
- */
-int
-extattr_set_file(p, uap)
- struct proc *p;
- struct extattr_set_file_args *uap;
-{
- struct nameidata nd;
- struct uio auio;
- struct iovec *iov, *needfree = NULL, aiov[UIO_SMALLIOV];
- char attrname[EXTATTR_MAXNAMELEN];
- u_int iovlen, cnt;
- int error, i;
-
- error = copyin(SCARG(uap, attrname), attrname, EXTATTR_MAXNAMELEN);
- if (error)
- return (error);
- NDINIT(&nd, LOOKUP, LOCKLEAF | FOLLOW, UIO_USERSPACE, SCARG(uap, path),
- p);
- if ((error = namei(&nd)) != 0)
- return(error);
- iovlen = uap->iovcnt * sizeof(struct iovec);
- if (uap->iovcnt > UIO_SMALLIOV) {
- if (uap->iovcnt > UIO_MAXIOV) {
- error = EINVAL;
- goto done;
- }
- MALLOC(iov, struct iovec *, iovlen, M_IOV, M_WAITOK);
- needfree = iov;
- } else
- iov = aiov;
- auio.uio_iov = iov;
- auio.uio_iovcnt = uap->iovcnt;
- auio.uio_rw = UIO_WRITE;
- auio.uio_segflg = UIO_USERSPACE;
- auio.uio_procp = p;
- auio.uio_offset = 0;
- if ((error = copyin((caddr_t)uap->iovp, (caddr_t)iov, iovlen)))
- goto done;
- auio.uio_resid = 0;
- for (i = 0; i < uap->iovcnt; i++) {
- if (iov->iov_len > INT_MAX - auio.uio_resid) {
- error = EINVAL;
- goto done;
- }
- auio.uio_resid += iov->iov_len;
- iov++;
- }
- cnt = auio.uio_resid;
- error = VOP_SETEXTATTR(nd.ni_vp, attrname, &auio, p->p_cred->pc_ucred,
- p);
- if (auio.uio_resid != cnt && (error == ERESTART ||
- error == EINTR || error == EWOULDBLOCK))
- error = 0;
- cnt -= auio.uio_resid;
- p->p_retval[0] = cnt;
-done:
- if (needfree)
- FREE(needfree, M_IOV);
- NDFREE(&nd, 0);
- return (error);
-}
-
-/*
- * Syscall to get a named extended attribute on a file or directory.
- * Accepts attribute name, and a uio structure pointing to a buffer for the
- * data. The uio is consumed in the style of readv(). The real work
- * happens in VOP_GETEXTATTR();
- */
-int
-extattr_get_file(p, uap)
- struct proc *p;
- struct extattr_get_file_args *uap;
-{
- struct nameidata nd;
- struct uio auio;
- struct iovec *iov, *needfree, aiov[UIO_SMALLIOV];
- char attrname[EXTATTR_MAXNAMELEN];
- u_int iovlen, cnt;
- int error, i;
-
- error = copyin(SCARG(uap, attrname), attrname, EXTATTR_MAXNAMELEN);
- if (error)
- return (error);
- NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
- if ((error = namei(&nd)) != 0)
- return (error);
- iovlen = uap->iovcnt * sizeof (struct iovec);
- if (uap->iovcnt > UIO_SMALLIOV) {
- if (uap->iovcnt > UIO_MAXIOV) {
- NDFREE(&nd, 0);
- return (EINVAL);
- }
- MALLOC(iov, struct iovec *, iovlen, M_IOV, M_WAITOK);
- needfree = iov;
- } else {
- iov = aiov;
- needfree = NULL;
- }
- auio.uio_iov = iov;
- auio.uio_iovcnt = uap->iovcnt;
- auio.uio_rw = UIO_READ;
- auio.uio_segflg = UIO_USERSPACE;
- auio.uio_procp = p;
- auio.uio_offset = 0;
- if ((error = copyin((caddr_t)uap->iovp, (caddr_t)iov, iovlen)))
- goto done;
- auio.uio_resid = 0;
- for (i = 0; i < uap->iovcnt; i++) {
- if (iov->iov_len > INT_MAX - auio.uio_resid) {
- error = EINVAL;
- goto done;
- }
- auio.uio_resid += iov->iov_len;
- iov++;
- }
- cnt = auio.uio_resid;
- error = VOP_GETEXTATTR(nd.ni_vp, attrname, &auio, p->p_cred->pc_ucred,
- p);
- if (auio.uio_resid != cnt && (error == ERESTART ||
- error == EINTR || error == EWOULDBLOCK))
- error = 0;
- cnt -= auio.uio_resid;
- p->p_retval[0] = cnt;
-done:
- if (needfree)
- FREE(needfree, M_IOV);
- NDFREE(&nd, 0);
- return(error);
-}
-
-/*
- * Syscall to delete a named extended attribute from a file or directory.
- * Accepts attribute name. The real work happens in VOP_SETEXTATTR().
- */
-int
-extattr_delete_file(p, uap)
- struct proc *p;
- struct extattr_delete_file_args *uap;
-{
- struct nameidata nd;
- char attrname[EXTATTR_MAXNAMELEN];
- int error;
-
- error = copyin(SCARG(uap, attrname), attrname, EXTATTR_MAXNAMELEN);
- if (error)
- return(error);
- NDINIT(&nd, LOOKUP, LOCKLEAF | FOLLOW, UIO_USERSPACE, SCARG(uap, path),
- p);
- if ((error = namei(&nd)) != 0)
- return(error);
- error = VOP_SETEXTATTR(nd.ni_vp, attrname, NULL, p->p_cred->pc_ucred,
- p);
- NDFREE(&nd, 0);
- return(error);
-}
diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c
deleted file mode 100644
index 8aaa4824cb4f..000000000000
--- a/sys/kern/vfs_mount.c
+++ /dev/null
@@ -1,366 +0,0 @@
-/*-
- * Copyright (c) 1999 Michael Smith
- * All rights reserved.
- * Copyright (c) 1999 Poul-Henning Kamp
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-/*
- * Locate and mount the root filesystem.
- *
- * The root filesystem is detailed in the kernel environment variable
- * vfs.root.mountfrom, which is expected to be in the general format
- *
- * <vfsname>:[<path>]
- * vfsname := the name of a VFS known to the kernel and capable
- * of being mounted as root
- * path := disk device name or other data used by the filesystem
- * to locate its physical store
- *
- */
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/proc.h>
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <sys/malloc.h>
-#include <sys/reboot.h>
-#include <sys/diskslice.h>
-#include <sys/disklabel.h>
-#include <sys/conf.h>
-#include <sys/cons.h>
-
-MALLOC_DEFINE(M_MOUNT, "mount", "vfs mount structure");
-
-#define ROOTNAME "root_device"
-
-struct vnode *rootvnode;
-
-/*
- * The root specifiers we will try if RB_CDROM is specified.
- */
-static char *cdrom_rootdevnames[] = {
- "cd9660:cd0a",
- "cd9660:acd0a",
- "cd9660:wcd0a",
- NULL
-};
-
-static void vfs_mountroot(void *junk);
-static int vfs_mountroot_try(char *mountfrom);
-static int vfs_mountroot_ask(void);
-static void gets(char *cp);
-
-/* legacy find-root code */
-char *rootdevnames[2] = {NULL, NULL};
-static int setrootbyname(char *name);
-
-SYSINIT(mountroot, SI_SUB_MOUNT_ROOT, SI_ORDER_SECOND, vfs_mountroot, NULL);
-
-/*
- * Find and mount the root filesystem
- */
-static void
-vfs_mountroot(void *junk)
-{
- int i;
-
- /*
- * The root filesystem information is compiled in, and we are
- * booted with instructions to use it.
- */
-#ifdef ROOTDEVNAME
- if ((boothowto & RB_DFLTROOT) &&
- !vfs_mountroot_try(ROOTDEVNAME))
- return;
-#endif
- /*
- * We are booted with instructions to prompt for the root filesystem,
- * or to use the compiled-in default when it doesn't exist.
- */
- if (boothowto & (RB_DFLTROOT | RB_ASKNAME)) {
- if (!vfs_mountroot_ask())
- return;
- }
-
- /*
- * We've been given the generic "use CDROM as root" flag. This is
- * necessary because one media may be used in many different
- * devices, so we need to search for them.
- */
- if (boothowto & RB_CDROM) {
- for (i = 0; cdrom_rootdevnames[i] != NULL; i++) {
- if (!vfs_mountroot_try(cdrom_rootdevnames[i]))
- return;
- }
- }
-
- /*
- * Try to use the value read by the loader from /etc/fstab, or
- * supplied via some other means. This is the preferred
- * mechanism.
- */
- if (!vfs_mountroot_try(getenv("vfs.root.mountfrom")))
- return;
-
- /*
- * Try values that may have been computed by the machine-dependant
- * legacy code.
- */
- if (!vfs_mountroot_try(rootdevnames[0]))
- return;
- if (!vfs_mountroot_try(rootdevnames[1]))
- return;
-
- /*
- * If we have a compiled-in default, and haven't already tried it, try
- * it now.
- */
-#ifdef ROOTDEVNAME
- if (!(boothowto & RB_DFLTROOT))
- if (!vfs_mountroot_try(ROOTDEVNAME))
- return;
-#endif
-
- /*
- * Everything so far has failed, prompt on the console if we haven't
- * already tried that.
- */
- if (!(boothowto & (RB_DFLTROOT | RB_ASKNAME)) && !vfs_mountroot_ask())
- return;
- panic("Root mount failed, startup aborted.");
-}
-
-/*
- * Mount (mountfrom) as the root filesystem.
- */
-static int
-vfs_mountroot_try(char *mountfrom)
-{
- struct mount *mp;
- char *vfsname, *path;
- int error;
- char patt[32];
- int s;
-
- vfsname = NULL;
- path = NULL;
- mp = NULL;
- error = EINVAL;
-
- if (mountfrom == NULL)
- return(error); /* don't complain */
-
- s = splcam(); /* Overkill, but annoying without it */
- printf("Mounting root from %s\n", mountfrom);
- splx(s);
-
- /* parse vfs name and path */
- vfsname = malloc(MFSNAMELEN, M_MOUNT, M_WAITOK);
- path = malloc(MNAMELEN, M_MOUNT, M_WAITOK);
- vfsname[0] = path[0] = 0;
- sprintf(patt, "%%%d[a-z0-9]:%%%ds", MFSNAMELEN, MNAMELEN);
- if (sscanf(mountfrom, patt, vfsname, path) < 1)
- goto done;
-
- /* allocate a root mount */
- error = vfs_rootmountalloc(vfsname, path[0] != 0 ? path : ROOTNAME,
- &mp);
- if (error != 0) {
- printf("Can't allocate root mount for filesystem '%s': %d\n",
- vfsname, error);
- goto done;
- }
- mp->mnt_flag |= MNT_ROOTFS;
-
- /* do our best to set rootdev */
- if ((path[0] != 0) && setrootbyname(path))
- printf("setrootbyname failed\n");
-
- /* If the root device is a type "memory disk", mount RW */
- if (rootdev != NODEV && devsw(rootdev) &&
- (devsw(rootdev)->d_flags & D_MEMDISK))
- mp->mnt_flag &= ~MNT_RDONLY;
-
- error = VFS_MOUNT(mp, NULL, NULL, NULL, curproc);
-
-done:
- if (vfsname != NULL)
- free(vfsname, M_MOUNT);
- if (path != NULL)
- free(path, M_MOUNT);
- if (error != 0) {
- if (mp != NULL) {
- vfs_unbusy(mp, curproc);
- free(mp, M_MOUNT);
- }
- printf("Root mount failed: %d\n", error);
- } else {
-
- /* register with list of mounted filesystems */
- simple_lock(&mountlist_slock);
- TAILQ_INSERT_HEAD(&mountlist, mp, mnt_list);
- simple_unlock(&mountlist_slock);
-
- /* sanity check system clock against root filesystem timestamp */
- inittodr(mp->mnt_time);
- vfs_unbusy(mp, curproc);
- }
- return(error);
-}
-
-/*
- * Spin prompting on the console for a suitable root filesystem
- */
-static int
-vfs_mountroot_ask(void)
-{
- char name[128];
- int i;
- dev_t dev;
-
- for(;;) {
- printf("\nManual root filesystem specification:\n");
- printf(" <fstype>:<device> Mount <device> using filesystem <fstype>\n");
- printf(" eg. ufs:/dev/da0s1a\n");
- printf(" ? List valid disk boot devices\n");
- printf(" <empty line> Abort manual input\n");
- printf("\nmountroot> ");
- gets(name);
- if (name[0] == 0)
- return(1);
- if (name[0] == '?') {
- printf("Possibly valid devices for 'ufs' root:\n");
- for (i = 0; i < NUMCDEVSW; i++) {
- dev = makedev(i, 0);
- if (devsw(dev) != NULL)
- printf(" \"%s\"", devsw(dev)->d_name);
- }
- printf("\n");
- continue;
- }
- if (!vfs_mountroot_try(name))
- return(0);
- }
-}
-
-static void
-gets(char *cp)
-{
- char *lp;
- int c;
-
- lp = cp;
- for (;;) {
- printf("%c", c = cngetc() & 0177);
- switch (c) {
- case -1:
- case '\n':
- case '\r':
- *lp++ = '\0';
- return;
- case '\b':
- case '\177':
- if (lp > cp) {
- printf(" \b");
- lp--;
- }
- continue;
- case '#':
- lp--;
- if (lp < cp)
- lp = cp;
- continue;
- case '@':
- case 'u' & 037:
- lp = cp;
- printf("%c", '\n');
- continue;
- default:
- *lp++ = c;
- }
- }
-}
-
-/*
- * Set rootdev to match (name), given that we expect it to
- * refer to a disk-like device.
- */
-static int
-setrootbyname(char *name)
-{
- char *cp;
- int cd, unit, slice, part;
- dev_t dev;
-
- slice = 0;
- part = 0;
- cp = rindex(name, '/');
- if (cp != NULL) {
- name = cp + 1;
- }
- cp = name;
- while (cp != '\0' && (*cp < '0' || *cp > '9'))
- cp++;
- if (cp == name) {
- printf("missing device name\n");
- return(1);
- }
- if (*cp == '\0') {
- printf("missing unit number\n");
- return(1);
- }
- unit = *cp - '0';
- *cp++ = '\0';
- for (cd = 0; cd < NUMCDEVSW; cd++) {
- dev = makedev(cd, 0);
- if (devsw(dev) != NULL &&
- strcmp(devsw(dev)->d_name, name) == 0)
- goto gotit;
- }
- printf("no such device '%s'\n", name);
- return (2);
-gotit:
- while (*cp >= '0' && *cp <= '9')
- unit += 10 * unit + *cp++ - '0';
- if (*cp == 's' && cp[1] >= '0' && cp[1] <= '9') {
- slice = cp[1] - '0' + 1;
- cp += 2;
- }
- if (*cp >= 'a' && *cp <= 'h') {
- part = *cp - 'a';
- cp++;
- }
- if (*cp != '\0') {
- printf("junk after name\n");
- return (1);
- }
- rootdev = makedev(cd, dkmakeminor(unit, slice, part));
- return 0;
-}
-
diff --git a/sys/libkern/fnmatch.c b/sys/libkern/fnmatch.c
deleted file mode 100644
index c3312b42110a..000000000000
--- a/sys/libkern/fnmatch.c
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * Copyright (c) 1989, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Guido van Rossum.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)fnmatch.c 8.2 (Berkeley) 4/16/94";
-#endif /* LIBC_SCCS and not lint */
-
-/*
- * Function fnmatch() as specified in POSIX 1003.2-1992, section B.6.
- * Compares a filename or pathname to a pattern.
- */
-
-#include <ctype.h>
-#include <fnmatch.h>
-#include <string.h>
-#include <stdio.h>
-
-#include "collate.h"
-
-#define EOS '\0'
-
-#define RANGE_MATCH 1
-#define RANGE_NOMATCH 0
-#define RANGE_ERROR (-1)
-
-static int rangematch __P((const char *, char, int, char **));
-
-int
-fnmatch(pattern, string, flags)
- const char *pattern, *string;
- int flags;
-{
- const char *stringstart;
- char *newp;
- char c, test;
-
- for (stringstart = string;;)
- switch (c = *pattern++) {
- case EOS:
- if ((flags & FNM_LEADING_DIR) && *string == '/')
- return (0);
- return (*string == EOS ? 0 : FNM_NOMATCH);
- case '?':
- if (*string == EOS)
- return (FNM_NOMATCH);
- if (*string == '/' && (flags & FNM_PATHNAME))
- return (FNM_NOMATCH);
- if (*string == '.' && (flags & FNM_PERIOD) &&
- (string == stringstart ||
- ((flags & FNM_PATHNAME) && *(string - 1) == '/')))
- return (FNM_NOMATCH);
- ++string;
- break;
- case '*':
- c = *pattern;
- /* Collapse multiple stars. */
- while (c == '*')
- c = *++pattern;
-
- if (*string == '.' && (flags & FNM_PERIOD) &&
- (string == stringstart ||
- ((flags & FNM_PATHNAME) && *(string - 1) == '/')))
- return (FNM_NOMATCH);
-
- /* Optimize for pattern with * at end or before /. */
- if (c == EOS)
- if (flags & FNM_PATHNAME)
- return ((flags & FNM_LEADING_DIR) ||
- strchr(string, '/') == NULL ?
- 0 : FNM_NOMATCH);
- else
- return (0);
- else if (c == '/' && flags & FNM_PATHNAME) {
- if ((string = strchr(string, '/')) == NULL)
- return (FNM_NOMATCH);
- break;
- }
-
- /* General case, use recursion. */
- while ((test = *string) != EOS) {
- if (!fnmatch(pattern, string, flags & ~FNM_PERIOD))
- return (0);
- if (test == '/' && flags & FNM_PATHNAME)
- break;
- ++string;
- }
- return (FNM_NOMATCH);
- case '[':
- if (*string == EOS)
- return (FNM_NOMATCH);
- if (*string == '/' && (flags & FNM_PATHNAME))
- return (FNM_NOMATCH);
- if (*string == '.' && (flags & FNM_PERIOD) &&
- (string == stringstart ||
- ((flags & FNM_PATHNAME) && *(string - 1) == '/')))
- return (FNM_NOMATCH);
-
- switch (rangematch(pattern, *string, flags, &newp)) {
- case RANGE_ERROR:
- goto norm;
- case RANGE_MATCH:
- pattern = newp;
- break;
- case RANGE_NOMATCH:
- return (FNM_NOMATCH);
- }
- ++string;
- break;
- case '\\':
- if (!(flags & FNM_NOESCAPE)) {
- if ((c = *pattern++) == EOS) {
- c = '\\';
- --pattern;
- }
- }
- /* FALLTHROUGH */
- default:
- norm:
- if (c == *string)
- ;
- else if ((flags & FNM_CASEFOLD) &&
- (tolower((unsigned char)c) ==
- tolower((unsigned char)*string)))
- ;
- else
- return (FNM_NOMATCH);
- string++;
- break;
- }
- /* NOTREACHED */
-}
-
-static int
-rangematch(pattern, test, flags, newp)
- const char *pattern;
- char test;
- int flags;
- char **newp;
-{
- int negate, ok;
- char c, c2;
-
- /*
- * A bracket expression starting with an unquoted circumflex
- * character produces unspecified results (IEEE 1003.2-1992,
- * 3.13.2). This implementation treats it like '!', for
- * consistency with the regular expression syntax.
- * J.T. Conklin (conklin@ngai.kaleida.com)
- */
- if ( (negate = (*pattern == '!' || *pattern == '^')) )
- ++pattern;
-
- if (flags & FNM_CASEFOLD)
- test = tolower((unsigned char)test);
-
- /*
- * A right bracket shall lose its special meaning and represent
- * itself in a bracket expression if it occurs first in the list.
- * -- POSIX.2 2.8.3.2
- */
- ok = 0;
- c = *pattern++;
- do {
- if (c == '\\' && !(flags & FNM_NOESCAPE))
- c = *pattern++;
- if (c == EOS)
- return (RANGE_ERROR);
-
- if (c == '/' && (flags & FNM_PATHNAME))
- return (RANGE_NOMATCH);
-
- if (flags & FNM_CASEFOLD)
- c = tolower((unsigned char)c);
-
- if (*pattern == '-'
- && (c2 = *(pattern+1)) != EOS && c2 != ']') {
- pattern += 2;
- if (c2 == '\\' && !(flags & FNM_NOESCAPE))
- c2 = *pattern++;
- if (c2 == EOS)
- return (RANGE_ERROR);
-
- if (flags & FNM_CASEFOLD)
- c2 = tolower((unsigned char)c2);
-
- if (__collate_load_error ?
- c <= test && test <= c2 :
- __collate_range_cmp(c, test) <= 0
- && __collate_range_cmp(test, c2) <= 0
- )
- ok = 1;
- } else if (c == test)
- ok = 1;
- } while ((c = *pattern++) != ']');
-
- *newp = (char *)pattern;
- return (ok == negate ? RANGE_NOMATCH : RANGE_MATCH);
-}
diff --git a/sys/libkern/strlcat.c b/sys/libkern/strlcat.c
deleted file mode 100644
index 599994edf5af..000000000000
--- a/sys/libkern/strlcat.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/* $OpenBSD: strlcat.c,v 1.2 1999/06/17 16:28:58 millert Exp $ */
-
-/*
- * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
- * 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 ``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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$OpenBSD: strlcat.c,v 1.2 1999/06/17 16:28:58 millert Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/types.h>
-#include <string.h>
-
-/*
- * Appends src to string dst of size siz (unlike strncat, siz is the
- * full size of dst, not space left). At most siz-1 characters
- * will be copied. Always NUL terminates (unless siz == 0).
- * Returns strlen(src); if retval >= siz, truncation occurred.
- */
-size_t strlcat(dst, src, siz)
- char *dst;
- const char *src;
- size_t siz;
-{
- register char *d = dst;
- register const char *s = src;
- register size_t n = siz;
- size_t dlen;
-
- /* Find the end of dst and adjust bytes left but don't go past end */
- while (*d != '\0' && n-- != 0)
- d++;
- dlen = d - dst;
- n = siz - dlen;
-
- if (n == 0)
- return(dlen + strlen(s));
- while (*s != '\0') {
- if (n != 1) {
- *d++ = *s;
- n--;
- }
- s++;
- }
- *d = '\0';
-
- return(dlen + (s - src)); /* count does not include NUL */
-}
diff --git a/sys/libkern/strlcpy.c b/sys/libkern/strlcpy.c
deleted file mode 100644
index 300a28bc3911..000000000000
--- a/sys/libkern/strlcpy.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/* $OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp $ */
-
-/*
- * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
- * 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 ``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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/types.h>
-#include <string.h>
-
-/*
- * Copy src to string dst of size siz. At most siz-1 characters
- * will be copied. Always NUL terminates (unless siz == 0).
- * Returns strlen(src); if retval >= siz, truncation occurred.
- */
-size_t strlcpy(dst, src, siz)
- char *dst;
- const char *src;
- size_t siz;
-{
- register char *d = dst;
- register const char *s = src;
- register size_t n = siz;
-
- /* Copy as many bytes as will fit */
- if (n != 0 && --n != 0) {
- do {
- if ((*d++ = *s++) == 0)
- break;
- } while (--n != 0);
- }
-
- /* Not enough room in dst, add NUL and traverse rest of src */
- if (n == 0) {
- if (siz != 0)
- *d = '\0'; /* NUL-terminate dst */
- while (*s++)
- ;
- }
-
- return(s - src - 1); /* count does not include NUL */
-}
diff --git a/sys/libkern/strsep.c b/sys/libkern/strsep.c
deleted file mode 100644
index ddad5964ce19..000000000000
--- a/sys/libkern/strsep.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/*-
- * 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. 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, Berkeley and its contributors.
- * 4. 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 <sys/cdefs.h>
-#include <string.h>
-#include <stdio.h>
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)strsep.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
-
-/*
- * Get next token from string *stringp, where tokens are possibly-empty
- * strings separated by characters from delim.
- *
- * Writes NULs into the string at *stringp to end tokens.
- * delim need not remain constant from call to call.
- * On return, *stringp points past the last NUL written (if there might
- * be further tokens), or is NULL (if there are definitely no more tokens).
- *
- * If *stringp is NULL, strsep returns NULL.
- */
-char *
-strsep(stringp, delim)
- register char **stringp;
- register const char *delim;
-{
- register char *s;
- register const char *spanp;
- register int c, sc;
- char *tok;
-
- if ((s = *stringp) == NULL)
- return (NULL);
- for (tok = s;;) {
- c = *s++;
- spanp = delim;
- do {
- if ((sc = *spanp++) == c) {
- if (c == 0)
- s = NULL;
- else
- s[-1] = 0;
- *stringp = s;
- return (tok);
- }
- } while (sc != 0);
- }
- /* NOTREACHED */
-}
diff --git a/sys/modules/fdescfs/Makefile b/sys/modules/fdescfs/Makefile
deleted file mode 100644
index 09f3ba5ae0d6..000000000000
--- a/sys/modules/fdescfs/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
-# $FreeBSD$
-
-.PATH: ${.CURDIR}/../../miscfs/fdesc
-KMOD= fdesc
-SRCS= vnode_if.h \
- fdesc_vfsops.c fdesc_vnops.c
-NOMAN=
-CFLAGS+= -DFDESC
-
-.include <bsd.kmod.mk>
diff --git a/sys/modules/msdosfs/Makefile b/sys/modules/msdosfs/Makefile
deleted file mode 100644
index 1ac0016ca6f6..000000000000
--- a/sys/modules/msdosfs/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
-# $FreeBSD$
-
-.PATH: ${.CURDIR}/../../msdosfs
-KMOD= msdos
-SRCS= vnode_if.h \
- msdosfs_conv.c msdosfs_denode.c msdosfs_fat.c msdosfs_lookup.c \
- msdosfs_vfsops.c msdosfs_vnops.c
-NOMAN=
-
-.include <bsd.kmod.mk>
diff --git a/sys/modules/netgraph/UI/ng_UI.4 b/sys/modules/netgraph/UI/ng_UI.4
deleted file mode 100644
index ab551bb28f69..000000000000
--- a/sys/modules/netgraph/UI/ng_UI.4
+++ /dev/null
@@ -1,91 +0,0 @@
-.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
-.\" All rights reserved.
-.\"
-.\" Subject to the following obligations and disclaimer of warranty, use and
-.\" redistribution of this software, in source or object code forms, with or
-.\" without modifications are expressly permitted by Whistle Communications;
-.\" provided, however, that:
-.\" 1. Any and all reproductions of the source or object code must include the
-.\" copyright notice above and the following disclaimer of warranties; and
-.\" 2. No rights are granted, in any manner or form, to use Whistle
-.\" Communications, Inc. trademarks, including the mark "WHISTLE
-.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
-.\" such appears in the above copyright notice or in the software.
-.\"
-.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
-.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
-.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
-.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
-.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
-.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
-.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
-.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
-.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
-.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
-.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
-.\" OF SUCH DAMAGE.
-.\"
-.\" Author: Archie Cobbs <archie@whistle.com>
-.\"
-.\" $FreeBSD$
-.\" $Whistle: ng_UI.8,v 1.4 1999/01/25 02:37:56 archie Exp $
-.\"
-.Dd January 19, 1999
-.Dt NG_UI 8
-.Os FreeBSD
-.Sh NAME
-.Nm ng_UI
-.Nd UI netgraph node type
-.Sh SYNOPSIS
-.Fd #include <netgraph/ng_UI.h>
-.Sh DESCRIPTION
-The
-.Nm UI
-node type has two hooks,
-.Dv upstream
-and
-.Dv downstream .
-Packets received on
-.Dv downstream
-must have 0x03 (indicating unnumbered information) as their first byte;
-if not the packet is dropped. This byte is then stripped and the
-remainder of the packet sent out on
-.Dv upstream .
-.Pp
-Conversely, packets received on
-.Dv upstream
-will have a 0x03 byte prepended to them before being forwarded out on the
-.Dv downstream
-hook.
-.Sh HOOKS
-This node type supports the following hooks:
-.Pp
-.Bl -tag -width foobar
-.It Dv downstream
-Downstream connection. Packets on this side of the node have a 0x03 as
-their first byte.
-.It Dv upstream
-Upstream connection. Packets on this side of the node have the
-initial 0x03 byte stripped off.
-.El
-.Sh CONTROL MESSAGES
-This node type supports only the generic control messages.
-.Sh SHUTDOWN
-This node shuts down upon receipt of a
-.Dv NGM_SHUTDOWN
-control message, or when both hooks have been disconnected.
-.Sh SEE ALSO
-.Xr netgraph 4 ,
-.Xr ngctl 8 .
-.Sh HISTORY
-The
-.Nm
-node type was implemented in
-.Fx 4.0 .
-.Sh AUTHORS
-.An Julian Elischer Aq julian@whistle.com
diff --git a/sys/modules/netgraph/async/ng_async.4 b/sys/modules/netgraph/async/ng_async.4
deleted file mode 100644
index 6f9693e177a0..000000000000
--- a/sys/modules/netgraph/async/ng_async.4
+++ /dev/null
@@ -1,169 +0,0 @@
-.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
-.\" All rights reserved.
-.\"
-.\" Subject to the following obligations and disclaimer of warranty, use and
-.\" redistribution of this software, in source or object code forms, with or
-.\" without modifications are expressly permitted by Whistle Communications;
-.\" provided, however, that:
-.\" 1. Any and all reproductions of the source or object code must include the
-.\" copyright notice above and the following disclaimer of warranties; and
-.\" 2. No rights are granted, in any manner or form, to use Whistle
-.\" Communications, Inc. trademarks, including the mark "WHISTLE
-.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
-.\" such appears in the above copyright notice or in the software.
-.\"
-.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
-.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
-.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
-.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
-.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
-.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
-.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
-.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
-.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
-.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
-.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
-.\" OF SUCH DAMAGE.
-.\"
-.\" Author: Archie Cobbs <archie@whistle.com>
-.\"
-.\" $FreeBSD$
-.\" $Whistle: ng_async.8,v 1.6 1999/01/25 23:46:25 archie Exp $
-.\"
-.Dd January 19, 1999
-.Dt NG_ASYNC 8
-.Os FreeBSD
-.Sh NAME
-.Nm ng_async
-.Nd asynchronous framing netgraph node type
-.Sh SYNOPSIS
-.Fd #include <netgraph/ng_async.h>
-.Sh DESCRIPTION
-The
-.Nm async
-node type performs conversion between synchronous frames and
-asynchronous frames, as defined for the PPP protocol in RFC 1662.
-Asynchronous framing uses flag bytes and octet-stuffing
-to simulate a frame oriented connection over an octet-oriented
-asynchronous serial line.
-.Pp
-The node transmits and receives asynchronous data on the
-.Dv async
-hook. Mbuf boundaries of incoming data are ignored.
-Once a complete packet has been received, it is decoded and
-stripped of all framing bytes, and transmitted out the
-.Dv sync
-hook as a single frame.
-.Pp
-Synchronous frames are transmitted and received on the
-.Dv sync
-hook.
-Packets received on this hook are encoded as asynchronous frames
-and sent out on
-.Dv async .
-Received packets should start with the address and control fields,
-or the PPP protocol field if address and control field compression
-is employed, and contain no checksum field. If the first four bytes are
-.Dv "0xff 0x03 0xc0 0x21"
-(an LCP protocol frame) then complete control character escaping
-is enabled for that frame (in PPP, LCP packets are always sent with
-no address and control field compression and all control characters
-escaped).
-.Pp
-This node supports
-.Dq flag sharing
-for packets transmitted on
-.Dv async .
-This is an optimization where the trailing flag byte
-of one frame is shared with the opening flag byte of the next.
-Flag sharing between frames is disabled after one second of transmit
-idle time.
-.Sh HOOKS
-This node type supports the following hooks:
-.Pp
-.Bl -tag -width foobar
-.It Dv async
-Asynchronous connection.
-Typically this hook would be connected to a
-.Xr ng_tty 8
-node, which handles transmission of serial data over a tty device.
-.It Dv sync
-Synchronous connection. This hook sends and receives synchronous frames.
-For PPP, these frames should contain address, control, and protocol fields,
-but no checksum field.
-Typically this hook would be connected to an individual link hook of a
-.Xr ng_ppp 8
-type node.
-.El
-.Sh CONTROL MESSAGES
-This node type supports the generic control messages, plus the following:
-.Bl -tag -width foo
-.It Dv NGM_ASYNC_CMD_GET_STATS
-This command returns a
-.Dv "struct ng_async_stat"
-containing node statistics for packet, octet, and error counts.
-.It Dv NGM_ASYNC_CMD_CLR_STATS
-Clears the node statistics.
-.It Dv NGM_ASYNC_CMD_SET_CONFIG
-Sets the node configuration, which is described by a
-.Dv "struct ng_async_cfg" :
-.Bd -literal -offset 4n
-struct ng_async_cfg {
- u_char enabled; /* Turn encoding on/off */
- u_int16_t amru; /* Max receive async frame len */
- u_int16_t smru; /* Max receive sync frame len */
- u_int32_t accm; /* ACCM encoding */
-};
-.Ed
-.Pp
-The
-.Dv enabled
-field enables or disables all encoding/decoding functions (default disabled).
-When disabled, the node operates in simple
-.Dq pass through
-mode.
-The
-.Dv amru
-and
-.Dv smru
-fields are the asynchronous and synchronous MRU (maximum receive unit) values,
-respectively. These both default to 1600; note that the async MRU
-applies to the incoming frame length after asynchronous decoding.
-The
-.Dv accm
-field is the asynchronous character control map, which controls the escaping
-of characters 0x00 thorough 0x1f (default 0xffffffff).
-.It Dv NGM_ASYNC_CMD_GET_CONFIG
-This command returns the current configuration structure.
-.El
-.Sh SHUTDOWN
-This node shuts down upon receipt of a
-.Dv NGM_SHUTDOWN
-control message, or when all hooks have been disconnected.
-.Sh SEE ALSO
-.Xr netgraph 4 ,
-.Xr ng_ppp 8 ,
-.Xr ng_tty 8 ,
-.Xr ngctl 8 .
-.Rs
-.%A W. Simpson
-.%T "PPP in HDLC-link Framing"
-.%O RFC 1662
-.Re
-.Rs
-.%A W. Simpson
-.%T "The Point-to-Point Protocol (PPP)"
-.%O RFC 1661
-.Re
-.Sh HISTORY
-The
-.Nm
-node type was implemented in
-.Fx 4.0 .
-.Sh AUTHORS
-.An Archie Cobbs Aq archie@whistle.com
diff --git a/sys/modules/netgraph/bpf/ng_bpf.4 b/sys/modules/netgraph/bpf/ng_bpf.4
deleted file mode 100644
index ef33495f855b..000000000000
--- a/sys/modules/netgraph/bpf/ng_bpf.4
+++ /dev/null
@@ -1,154 +0,0 @@
-.\" Copyright (c) 1999 Whistle Communications, Inc.
-.\" All rights reserved.
-.\"
-.\" Subject to the following obligations and disclaimer of warranty, use and
-.\" redistribution of this software, in source or object code forms, with or
-.\" without modifications are expressly permitted by Whistle Communications;
-.\" provided, however, that:
-.\" 1. Any and all reproductions of the source or object code must include the
-.\" copyright notice above and the following disclaimer of warranties; and
-.\" 2. No rights are granted, in any manner or form, to use Whistle
-.\" Communications, Inc. trademarks, including the mark "WHISTLE
-.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
-.\" such appears in the above copyright notice or in the software.
-.\"
-.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
-.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
-.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
-.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
-.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
-.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
-.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
-.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
-.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
-.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
-.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
-.\" OF SUCH DAMAGE.
-.\"
-.\" Author: Archie Cobbs <archie@whistle.com>
-.\"
-.\" $FreeBSD$
-.\" $Whistle: ng_bpf.8,v 1.2 1999/12/03 01:57:12 archie Exp $
-.\"
-.Dd December 2, 1999
-.Dt NG_BPF 8
-.Os FreeBSD
-.Sh NAME
-.Nm ng_bpf
-.Nd Berkeley packet filter netgraph node type
-.Sh SYNOPSIS
-.Fd #include <net/bpf.h>
-.Fd #include <netgraph/ng_bpf.h>
-.Sh DESCRIPTION
-The
-.Nm bpf
-node type allows Berkeley Packet Filter (see
-.Xr bpf 4 )
-filters to be applied to data travelling through a Netgraph network.
-Each node allows an arbitrary number of connections to arbitrarily
-named hooks. With each hook is associated a
-.Xf bpf 4
-filter program which is applied to incoming data only, a destination hook
-for matching packets, a destination hook for non-matching packets,
-and various statistics counters.
-.Pp
-A
-.Xr bpf 4
-program returns an unsigned integer, which is normally interpreted as
-the length of the prefix of the packet to return. In the context of this
-node type, returning zero is considered a non-match, in which case the
-entire packet is delivered out the non-match destination hook.
-Returning a value greater than zero causes the packet to be truncated
-to that length and delivered out the match destination hook.
-Either or both destination hooks may be the empty string, or may
-not exist, in which case the packet is dropped.
-.Pp
-New hooks are initially configured to drop all packets.
-A new filter may be installed using the
-.Dv NGM_BPF_SET_FILTER
-control message.
-.Sh HOOKS
-This node type supports any number of hooks having arbitrary names.
-.Sh CONTROL MESSAGES
-This node type supports the generic control messages, plus the following:
-.Bl -tag -width foo
-.It Dv NGM_BPF_SET_FILTER
-This command sets the filter program that will be applied to incoming
-data on a hook. The following structure must be supplied as an argument:
-.Bd -literal -offset 4n
-struct ngm_bpf_hookprog {
- char thisHook[NG_HOOKLEN+1]; /* name of hook */
- char ifMatch[NG_HOOKLEN+1]; /* match dest hook */
- char ifNotMatch[NG_HOOKLEN+1]; /* !match dest hook */
- int32_t bpf_prog_len; /* #isns in program */
- struct bpf_insn bpf_prog[0]; /* bpf program */
-};
-.Ed
-.Pp
-The hook to be updated is specified in
-.Dv thisHook .
-The BPF program is the sequence of instructions in the
-.Dv bpf_prog
-array; there must be
-.Dv bpf_prog_len
-of them.
-Matching and non-matching incoming packets are delivered out the hooks named
-.Dv ifMatch
-and
-.Dv ifNotMatch ,
-respectively. The program must be a valid
-.Xr bpf 4
-program or else
-.Er EINVAL
-is returned.
-.It Dv NGM_BPF_GET_FILTER
-This command takes an
-.Tn ASCII
-string argument, the hook name, and returns the
-corresponding
-.Dv "struct ngm_bpf_hookprog"
-as shown above.
-.It Dv NGM_BPF_GET_STATS
-This command takes an
-.Tn ASCII
-string argument, the hook name, and returns the
-statistics associated with the hook as a
-.Dv "struct ng_bpf_hookstat" .
-.It Dv NGM_BPF_CLR_STATS
-This command takes an
-.Tn ASCII
-string argument, the hook name, and clears the
-statistics associated with the hook.
-.It Dv NGM_BPF_GETCLR_STATS
-This command is identical to
-.Dv NGM_BPF_GET_STATS ,
-except that the statistics are also atomically cleared.
-.El
-.Sh SHUTDOWN
-This node shuts down upon receipt of a
-.Dv NGM_SHUTDOWN
-control message, or when all hooks have been disconnected.
-.Sh BUGS
-When built as a loadable kernel module, this module includes the file
-.Pa net/bpf_filter.c .
-Although loading the module should fail if
-.Pa net/bpf_filter.c
-already exists in the kernel, currently it does not, and the duplicate
-copies of the file do not interfere.
-However, this may change in the future.
-.Sh HISTORY
-The
-.Nm
-node type was implemented in
-.Fx 4.0 .
-.Sh SEE ALSO
-.Xr netgraph 4 ,
-.Xr bpf 4 ,
-.Xr ngctl 8 .
-.Sh AUTHORS
-.An Archie Cobbs Aq archie@whistle.com
diff --git a/sys/modules/netgraph/cisco/ng_cisco.4 b/sys/modules/netgraph/cisco/ng_cisco.4
deleted file mode 100644
index 03ffcb4f8547..000000000000
--- a/sys/modules/netgraph/cisco/ng_cisco.4
+++ /dev/null
@@ -1,171 +0,0 @@
-.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
-.\" All rights reserved.
-.\"
-.\" Subject to the following obligations and disclaimer of warranty, use and
-.\" redistribution of this software, in source or object code forms, with or
-.\" without modifications are expressly permitted by Whistle Communications;
-.\" provided, however, that:
-.\" 1. Any and all reproductions of the source or object code must include the
-.\" copyright notice above and the following disclaimer of warranties; and
-.\" 2. No rights are granted, in any manner or form, to use Whistle
-.\" Communications, Inc. trademarks, including the mark "WHISTLE
-.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
-.\" such appears in the above copyright notice or in the software.
-.\"
-.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
-.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
-.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
-.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
-.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
-.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
-.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
-.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
-.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
-.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
-.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
-.\" OF SUCH DAMAGE.
-.\"
-.\" Author: Archie Cobbs <archie@whistle.com>
-.\"
-.\" $FreeBSD$
-.\" $Whistle: ng_cisco.8,v 1.5 1999/01/25 23:46:26 archie Exp $
-.\"
-.Dd January 19, 1999
-.Dt NG_CISCO 8
-.Os FreeBSD
-.Sh NAME
-.Nm ng_cisco
-.Nd Cisco HDLC protocol netgraph node type
-.Sh SYNOPSIS
-.Fd #include <netinet/in.h>
-.Fd #include <netgraph/ng_cisco.h>
-.Sh DESCRIPTION
-The
-.Nm cisco
-node type performs encapsulation and de-encapsulation of packets
-using the Cisco HDLC protocol. This is a fairly simple
-protocol for the transmission of packets across
-high speed synchronous lines. Each packet is prepended with
-an Ethertype, indicating the protocol. There is also a
-.Dq keep alive
-and an
-.Dq inquire
-capability.
-.Pp
-The
-.Dv downstream
-hook should connect to the synchronous line. On the other side
-of the node are the
-.Dv inet ,
-.Dv atalk ,
-and
-.Dv ipx
-hooks, which transmit and receive raw IP, AppleTalk, and IPX packets,
-respectively. Typically these hooks would connect to the corresponding
-hooks on an
-.Xr ng_iface 8
-type node.
-.Sh IP Configuration
-In order to function properly for IP traffic, the node must be informed
-of the local IP address and netmask setting. This is because the protocol
-includes an
-.Dq inquire
-packet which we must be prepared to answer.
-There are two ways to accomplish this, manually and automatically.
-.Pp
-Whenever such an inquire packet is received, the node sends a
-.Dv NGM_CISCO_GET_IPADDR
-control message to the peer node connected to the
-.Dv inet
-hook (if any).
-If the peer responds, then that response is used. This is the automatic method.
-.Pp
-If the peer does not respond, the node falls back on its cached value
-for the IP address and netmask. This cached value can be set at any time
-with a
-.Dv NGM_CISCO_SET_IPADDR
-message, and this is the manual method.
-.Pp
-If the
-.Dv inet
-hook is connected to the
-.Dv inet
-hook of an
-.Xr ng_iface 8
-node, as is usually the case, then configuration is automatic as the
-.Xr ng_iface 8
-understands the
-.Dv NGM_CISCO_GET_IPADDR
-message.
-.Sh HOOKS
-This node type supports the following hooks:
-.Pp
-.Bl -tag -width foobarbazio
-.It Dv downstream
-The connection to the synchronous line.
-.It Dv inet
-IP hook.
-.It Dv atalk
-AppleTalk hook.
-.It Dv ipx
-IPX hook
-.El
-.Sh CONTROL MESSAGES
-This node type supports the generic control messages, plus the following:
-.Bl -tag -width foo
-.It Dv NGM_CISCO_SET_IPADDR
-This command takes an array of two
-.Dv "struct in_addr"
-arguments. The first is the IP address of the corresponding interface
-and the second is the netmask.
-.It Dv NGM_CISCO_GET_IPADDR
-This command returns the IP configuration in the same format used by
-.Dv NGM_CISCO_SET_IPADDR .
-This command is also
-.Em sent
-by this node type to the
-.Dv inet
-peer whenever an IP address inquiry packet is received.
-.It Dv NGM_CISCO_GET_STATUS
-Returns a
-.Dv "struct ngciscostat" :
-.Bd -literal -offset 4n
-struct ngciscostat {
- u_int32_t seq_retries; /* # unack'd retries */
- u_int32_t keepalive_period; /* in seconds */
-};
-.Ed
-.El
-.Sh SHUTDOWN
-This node shuts down upon receipt of a
-.Dv NGM_SHUTDOWN
-control message, or when all hooks have been disconnected.
-.Sh BUGS
-Not all of the functionality has been implemented. For example,
-the node does not support querying the remote end for its IP address
-and netmask.
-.Sh SEE ALSO
-.Xr netgraph 4 ,
-.Xr ng_iface 8 ,
-.Xr ngctl 8 .
-.Rs
-.%A D. Perkins
-.%T "Requirements for an Internet Standard Point-to-Point Protocol"
-.%O RFC 1547
-.Re
-.Sh LEGAL
-.Tn Cisco
-is a trademark of Cisco Systems, Inc.
-.Sh HISTORY
-The
-.Nm
-node type was implemented in
-.Fx 4.0 .
-.Sh AUTHORS
-.An Julian Elischer Aq julian@whistle.com ,
-.An Archie Cobbs Aq archie@whistle.com
diff --git a/sys/modules/netgraph/echo/ng_echo.4 b/sys/modules/netgraph/echo/ng_echo.4
deleted file mode 100644
index bdef682362e7..000000000000
--- a/sys/modules/netgraph/echo/ng_echo.4
+++ /dev/null
@@ -1,73 +0,0 @@
-.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
-.\" All rights reserved.
-.\"
-.\" Subject to the following obligations and disclaimer of warranty, use and
-.\" redistribution of this software, in source or object code forms, with or
-.\" without modifications are expressly permitted by Whistle Communications;
-.\" provided, however, that:
-.\" 1. Any and all reproductions of the source or object code must include the
-.\" copyright notice above and the following disclaimer of warranties; and
-.\" 2. No rights are granted, in any manner or form, to use Whistle
-.\" Communications, Inc. trademarks, including the mark "WHISTLE
-.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
-.\" such appears in the above copyright notice or in the software.
-.\"
-.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
-.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
-.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
-.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
-.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
-.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
-.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
-.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
-.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
-.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
-.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
-.\" OF SUCH DAMAGE.
-.\"
-.\" Author: Archie Cobbs <archie@whistle.com>
-.\"
-.\" $FreeBSD$
-.\" $Whistle: ng_echo.8,v 1.4 1999/01/25 23:46:26 archie Exp $
-.\"
-.Dd January 19, 1999
-.Dt NG_ECHO 8
-.Os FreeBSD
-.Sh NAME
-.Nm ng_echo
-.Nd netgraph echo node type
-.Sh SYNOPSIS
-.Fd #include <netgraph/ng_echo.h>
-.Sh DESCRIPTION
-The
-.Nm echo
-node type reflects all data and control messages back to the sender.
-This node type is used for testing and debugging.
-.Sh HOOKS
-A
-.Nm echo
-node accepts any request to connect, regardless of the hook name,
-as long as the name is unique.
-.Sh CONTROL MESSAGES
-This node type supports only the generic control messages.
-Any other control messages are reflected back to the sender.
-.Sh SHUTDOWN
-This node shuts down upon receipt of a
-.Dv NGM_SHUTDOWN
-control message, or when all hooks have been disconnected.
-.Sh SEE ALSO
-.Xr netgraph 4 ,
-.Xr ng_hole 8 ,
-.Xr ngctl 8 .
-.Sh HISTORY
-The
-.Nm
-node type was implemented in
-.Fx 4.0 .
-.Sh AUTHORS
-.An Julian Elischer Aq julian@whistle.com
diff --git a/sys/modules/netgraph/frame_relay/ng_frame_relay.4 b/sys/modules/netgraph/frame_relay/ng_frame_relay.4
deleted file mode 100644
index 7686d0ee8acb..000000000000
--- a/sys/modules/netgraph/frame_relay/ng_frame_relay.4
+++ /dev/null
@@ -1,98 +0,0 @@
-.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
-.\" All rights reserved.
-.\"
-.\" Subject to the following obligations and disclaimer of warranty, use and
-.\" redistribution of this software, in source or object code forms, with or
-.\" without modifications are expressly permitted by Whistle Communications;
-.\" provided, however, that:
-.\" 1. Any and all reproductions of the source or object code must include the
-.\" copyright notice above and the following disclaimer of warranties; and
-.\" 2. No rights are granted, in any manner or form, to use Whistle
-.\" Communications, Inc. trademarks, including the mark "WHISTLE
-.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
-.\" such appears in the above copyright notice or in the software.
-.\"
-.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
-.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
-.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
-.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
-.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
-.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
-.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
-.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
-.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
-.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
-.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
-.\" OF SUCH DAMAGE.
-.\"
-.\" Author: Archie Cobbs <archie@whistle.com>
-.\"
-.\" $FreeBSD$
-.\" $Whistle: ng_frame_relay.8,v 1.4 1999/01/25 23:46:26 archie Exp $
-.\"
-.Dd January 19, 1999
-.Dt NG_FRAME_RELAY 8
-.Os FreeBSD
-.Sh NAME
-.Nm ng_frame_relay
-.Nd frame relay netgraph node type
-.Sh SYNOPSIS
-.Fd #include <netgraph/ng_frame_relay.h>
-.Sh DESCRIPTION
-The
-.Nm frame_relay
-node type performs encapsulation, de-encapsulation, and multiplexing
-of packets using the frame relay protocol. It supports up to 1024 DLCI's.
-The LMI protocol is handled by a separate node type (see
-.Xr ng_lmi 8 ).
-.Pp
-The
-.Dv downstream
-hook should be connected to the synchronous line, i.e., the switch.
-Then hooks
-.Dv dlci0 ,
-.Dv dlci1 ,
-through
-.Dv dlci1023
-are available to connect to each of the DLCI channels.
-.Sh HOOKS
-This node type supports the following hooks:
-.Pp
-.Bl -tag -width foobar
-.It Dv downstream
-The connection to the synchronous line.
-.It Dv dlciX
-Here X is a decimal number from 0 to 1023. This hook corresponds
-to the DLCI X frame relay virtual channel.
-.El
-.Sh CONTROL MESSAGES
-This node type supports only the generic control messages.
-.Sh SHUTDOWN
-This node shuts down upon receipt of a
-.Dv NGM_SHUTDOWN
-control message, or when all hooks have been disconnected.
-.Sh BUGS
-Technically, frames on DLCI X should not be transmitted to the switch
-until the LMI protocol entity on both ends has configured DLCI X as active.
-The
-.Nm
-node type ignores this restriction, and will always pass data received
-on a DLCI hook to
-.Dv downstream .
-Instead, it should query the LMI node first.
-.Sh SEE ALSO
-.Xr netgraph 4 ,
-.Xr ng_lmi 8 ,
-.Xr ngctl 8 .
-.Sh HISTORY
-The
-.Nm
-node type was implemented in
-.Fx 4.0 .
-.Sh AUTHORS
-.An Julian Elischer Aq julian@whistle.com
diff --git a/sys/modules/netgraph/hole/ng_hole.4 b/sys/modules/netgraph/hole/ng_hole.4
deleted file mode 100644
index f1a701474092..000000000000
--- a/sys/modules/netgraph/hole/ng_hole.4
+++ /dev/null
@@ -1,73 +0,0 @@
-.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
-.\" All rights reserved.
-.\"
-.\" Subject to the following obligations and disclaimer of warranty, use and
-.\" redistribution of this software, in source or object code forms, with or
-.\" without modifications are expressly permitted by Whistle Communications;
-.\" provided, however, that:
-.\" 1. Any and all reproductions of the source or object code must include the
-.\" copyright notice above and the following disclaimer of warranties; and
-.\" 2. No rights are granted, in any manner or form, to use Whistle
-.\" Communications, Inc. trademarks, including the mark "WHISTLE
-.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
-.\" such appears in the above copyright notice or in the software.
-.\"
-.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
-.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
-.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
-.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
-.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
-.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
-.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
-.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
-.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
-.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
-.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
-.\" OF SUCH DAMAGE.
-.\"
-.\" Author: Archie Cobbs <archie@whistle.com>
-.\"
-.\" $FreeBSD$
-.\" $Whistle: ng_hole.8,v 1.4 1999/01/25 23:46:26 archie Exp $
-.\"
-.Dd January 19, 1999
-.Dt NG_HOLE 8
-.Os FreeBSD
-.Sh NAME
-.Nm ng_hole
-.Nd netgraph discard node type
-.Sh SYNOPSIS
-.Fd #include <netgraph/ng_hole.h>
-.Sh DESCRIPTION
-The
-.Nm hole
-node type silently discards all data and control messages it receives.
-This type is used for testing and debugging.
-.Sh HOOKS
-A
-.Nm
-node accepts any request to connect, regardless of the hook name,
-as long as the name is unique.
-.Sh CONTROL MESSAGES
-This node type supports only the generic control messages.
-Other control messages are silently discarded.
-.Sh SHUTDOWN
-This node shuts down upon receipt of a
-.Dv NGM_SHUTDOWN
-control message, or when all hooks have been disconnected.
-.Sh SEE ALSO
-.Xr netgraph 4 ,
-.Xr ng_echo 8 ,
-.Xr ngctl 8 .
-.Sh HISTORY
-The
-.Nm
-node type was implemented in
-.Fx 4.0 .
-.Sh AUTHORS
-.An Julian Elischer Aq julian@whistle.com
diff --git a/sys/modules/netgraph/iface/ng_iface.4 b/sys/modules/netgraph/iface/ng_iface.4
deleted file mode 100644
index 40c6f8812b1e..000000000000
--- a/sys/modules/netgraph/iface/ng_iface.4
+++ /dev/null
@@ -1,134 +0,0 @@
-.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
-.\" All rights reserved.
-.\"
-.\" Subject to the following obligations and disclaimer of warranty, use and
-.\" redistribution of this software, in source or object code forms, with or
-.\" without modifications are expressly permitted by Whistle Communications;
-.\" provided, however, that:
-.\" 1. Any and all reproductions of the source or object code must include the
-.\" copyright notice above and the following disclaimer of warranties; and
-.\" 2. No rights are granted, in any manner or form, to use Whistle
-.\" Communications, Inc. trademarks, including the mark "WHISTLE
-.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
-.\" such appears in the above copyright notice or in the software.
-.\"
-.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
-.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
-.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
-.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
-.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
-.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
-.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
-.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
-.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
-.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
-.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
-.\" OF SUCH DAMAGE.
-.\"
-.\" Author: Archie Cobbs <archie@whistle.com>
-.\"
-.\" $FreeBSD$
-.\" $Whistle: ng_iface.8,v 1.5 1999/01/25 23:46:26 archie Exp $
-.\"
-.Dd January 19, 1999
-.Dt NG_IFACE 8
-.Os FreeBSD
-.Sh NAME
-.Nm ng_iface
-.Nd interface netgraph node type
-.Sh SYNOPSIS
-.Fd #include <netgraph/ng_iface.h>
-.Sh DESCRIPTION
-An
-.Nm iface
-node is both a netgraph node and a system networking interface. When an
-.Nm
-node is created, a new point-to-point interface appears which is accessible via
-.Xr ifconfig 8 .
-The new interfaces are named
-.Dv ng0 ,
-.Dv ng1 ,
-etc. The node is assigned the same name as its interface, unless the name
-already exists, in which case the node remains unnamed.
-.Pp
-An
-.Nm
-node has a single hook corresponding to each supported protocol.
-Packets transmitted via the interface flow out the corresponding
-protocol-specific hook.
-Similarly, packets received on a hook appear on the interface as
-packets received in the corresponding protocol.
-.Pp
-The currently supported protocols are IP, IPX, AppleTalk, and NS.
-In the KLD module, only support for IP is compiled in by default.
-.Pp
-An
-.Nm
-node supports the Berkeley Packet Filter (BPF).
-.Sh HOOKS
-This node type supports the following hooks:
-.Pp
-.Bl -tag -width foobar
-.It Dv inet
-Transmission and reception of IP packets.
-.It Dv ipx
-Transmission and reception of IPX packets.
-.It Dv atalk
-Transmission and reception of AppleTalk packets.
-.It Dv ns
-Transmission and reception of NS packets.
-.El
-.Sh CONTROL MESSAGES
-This node type supports the generic control messages, plus the following:
-.Bl -tag -width foo
-.It Dv NGM_IFACE_GET_IFNAME
-Returns the name of the interface corresponding to this node in a
-.Dv "struct ng_iface_ifname" :
-.Bd -literal -offset 4n
-struct ng_iface_ifname {
- char ngif_name[NG_IFACE_IFACE_NAME_MAX + 1];
-};
-.Ed
-.It Dv NGM_IFACE_GET_IFADDRS
-Returns the list of addresses associated with this interface.
-The list is returned in the same format as the
-.Dv SIOCGIFCONF
-.Fn ioctl .
-.It Dv NGM_CISCO_GET_IPADDR
-This message is defined by the
-.Xr ng_cisco 8
-node type; see
-.Xr ng_cisco 8
-for a description.
-.El
-.Sh SHUTDOWN
-Because it is currently not possible to remove a system networking
-interface in
-.Fx ,
-.Nm
-nodes are
-.Em persistent.
-That is, once created they are never destroyed.
-The receipt of a
-.Dv NGM_SHUTDOWN
-control message disconnects all hooks but does not remove the node.
-.Sh SEE ALSO
-.Xr bpf 4 ,
-.Xr netgraph 4 ,
-.Xr ifconfig 8 ,
-.Xr ng_cisco 8 ,
-.Xr ng_ppp 8 ,
-.Xr ng_rfc1490 8 ,
-.Xr ngctl 8 .
-.Sh HISTORY
-The
-.Nm
-node type was implemented in
-.Fx 4.0 .
-.Sh AUTHORS
-.An Archie Cobbs Aq archie@whistle.com
diff --git a/sys/modules/netgraph/ksocket/ng_ksocket.4 b/sys/modules/netgraph/ksocket/ng_ksocket.4
deleted file mode 100644
index ff0abc7a77fd..000000000000
--- a/sys/modules/netgraph/ksocket/ng_ksocket.4
+++ /dev/null
@@ -1,187 +0,0 @@
-.\" Copyright (c) 1999 Whistle Communications, Inc.
-.\" All rights reserved.
-.\"
-.\" Subject to the following obligations and disclaimer of warranty, use and
-.\" redistribution of this software, in source or object code forms, with or
-.\" without modifications are expressly permitted by Whistle Communications;
-.\" provided, however, that:
-.\" 1. Any and all reproductions of the source or object code must include the
-.\" copyright notice above and the following disclaimer of warranties; and
-.\" 2. No rights are granted, in any manner or form, to use Whistle
-.\" Communications, Inc. trademarks, including the mark "WHISTLE
-.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
-.\" such appears in the above copyright notice or in the software.
-.\"
-.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
-.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
-.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
-.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
-.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
-.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
-.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
-.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
-.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
-.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
-.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
-.\" OF SUCH DAMAGE.
-.\"
-.\" Author: Archie Cobbs <archie@whistle.com>
-.\"
-.\" $FreeBSD$
-.\"
-.Dd November 15, 1999
-.Dt NG_KSOCKET 8
-.Os FreeBSD
-.Sh NAME
-.Nm ng_ksocket
-.Nd kernel socket netgraph node type
-.Sh SYNOPSIS
-.Fd #include <netgraph/ng_ksocket.h>
-.Sh DESCRIPTION
-A
-.Nm ksocket
-node is both a netgraph node and a BSD socket. The
-.Nm
-node type allows one to open a socket inside the kernel and have
-it appear as a Netgraph node. The
-.Nm
-node type is the reverse of the socket node type (see
-.Xr ng_socket 8 ) :
-whereas the socket node type enables the user-level manipulation (via
-a socket) of what is normally a kernel-level entity (the associated
-Netgraph node), the
-.Nm
-node type enables the kernel-level manipulation (via a Netgraph node) of
-what is normally a user-level entity (the associated socket).
-.Pp
-A
-.Nm
-node allows at most one hook connection. Connecting to the node is
-equivalent to opening the associated socket. The name given to the hook
-determines what kind of socket the node will open (see below).
-When the hook is disconnected and/or the node is shutdown, the
-associated socket is closed.
-.Sh HOOKS
-This node type supports a single hook connection at a time.
-The name of the hook must be of the form
-.Dv Em <family>/<type>/<proto> ,
-where the
-.Dv Em family ,
-.Dv Em type ,
-and
-.Dv Em proto
-are the decimal equivalent of the same arguments to
-.Xr socket 2 .
-Alternately, aliases for the commonly used values are accepted as
-well. For example
-.Dv inet/dgram/udp
-is a more readable but equivalent version of
-.Dv 2/2/17 .
-.Sh CONTROL MESSAGES
-This node type supports the generic control messages, plus the following:
-.Bl -tag -width foo
-.It Dv NGM_KSOCKET_BIND
-This functions exactly like the
-.Xr bind 2
-system call. The
-.Dv "struct sockaddr"
-socket address parameter should be supplied as an argument.
-.It Dv NGM_KSOCKET_LISTEN
-This functions exactly like the
-.Xr listen 2
-system call. The backlog paramter (a single 32 bit
-.Dv int )
-should be supplied as an argument.
-.It Dv NGM_KSOCKET_CONNECT
-This functions exactly like the
-.Xr connect 2
-system call. The
-.Dv "struct sockaddr"
-destination address parameter should be supplied as an argument.
-.It Dv NGM_KSOCKET_ACCEPT
-Currently unimplemented.
-.It Dv NGM_KSOCKET_GETNAME
-Equivalent to the
-.Xr getname 2
-system call. The name is returned as a
-.Dv "struct sockaddr"
-in the arguments field of the reply.
-.It Dv NGM_KSOCKET_GETPEERNAME
-Equivalent to the
-.Xr getpeername 2
-system call. The name is returned as a
-.Dv "struct sockaddr"
-in the arguments field of the reply.
-.It Dv NGM_KSOCKET_SETOPT
-Equivalent to the
-.Xr setsockopt 2
-system call, except that the option name, level, and value are passed in a
-.Dv "struct ng_ksocket_sockopt" .
-.It Dv NGM_KSOCKET_GETOPT
-Equivalent to the
-.Xr getsockopt 2
-system call, except that the option is passed in a
-.Dv "struct ng_ksocket_sockopt" .
-When sending this command, the
-.Dv value
-field should be empty; upon return, it will contain the
-retrieved value.
-.El
-.Pp
-.Sh ASCII FORM CONTROL MESSAGES
-For control messages that pass a
-.Dv "struct sockaddr"
-in the argument field, the normal
-.Tn ASCII
-equivalent of the C structure
-is an acceptable form. For the
-.Dv PF_INET
-and
-.Dv PF_LOCAL
-address families, a more convenient form is also used, which is
-the protocol family name, followed by a slash, followed by the actual
-address. For
-.Dv PF_INET ,
-the address is an IP address followed by an optional colon and port number.
-For
-.Dv PF_LOCAL ,
-the address is the pathname as a doubly quoted string.
-.Pp
-Examples:
-.Bl -tag -width XXXXXXXXXX
-.It Dv PF_LOCAL
-inet/192.168.1.1:1234
-.It Dv PF_INET
-local/"/tmp/foo.socket"
-.It Other
-.Dv "{ family=16 len=16 data=[0x70 0x00 0x01 0x23] }"
-.El
-.Pp
-For control messages that pass a
-.Dv "struct ng_ksocket_sockopt" ,
-the normal
-.Tn ASCII
-form for that structure is used. In the future, more
-convenient encoding of the more common socket options may be supported.
-.Sh SHUTDOWN
-This node shuts down upon receipt of a
-.Dv NGM_SHUTDOWN
-control message, or when the hook is disconnected.
-Shutdown of the node closes the associated socket.
-.Sh SEE ALSO
-.Xr socket 2 ,
-.Xr netgraph 4 ,
-.Xr ng_socket 8 ,
-.Xr ngctl 8 .
-.Sh HISTORY
-The
-.Nm
-node type was implemented in
-.Fx 4.0 .
-.Sh AUTHORS
-.An Archie Cobbs Aq archie@whistle.com
diff --git a/sys/modules/netgraph/lmi/ng_lmi.4 b/sys/modules/netgraph/lmi/ng_lmi.4
deleted file mode 100644
index d03c0188226c..000000000000
--- a/sys/modules/netgraph/lmi/ng_lmi.4
+++ /dev/null
@@ -1,135 +0,0 @@
-.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
-.\" All rights reserved.
-.\"
-.\" Subject to the following obligations and disclaimer of warranty, use and
-.\" redistribution of this software, in source or object code forms, with or
-.\" without modifications are expressly permitted by Whistle Communications;
-.\" provided, however, that:
-.\" 1. Any and all reproductions of the source or object code must include the
-.\" copyright notice above and the following disclaimer of warranties; and
-.\" 2. No rights are granted, in any manner or form, to use Whistle
-.\" Communications, Inc. trademarks, including the mark "WHISTLE
-.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
-.\" such appears in the above copyright notice or in the software.
-.\"
-.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
-.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
-.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
-.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
-.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
-.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
-.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
-.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
-.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
-.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
-.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
-.\" OF SUCH DAMAGE.
-.\"
-.\" Author: Archie Cobbs <archie@whistle.com>
-.\"
-.\" $FreeBSD$
-.\" $Whistle: ng_lmi.8,v 1.4 1999/01/25 23:46:27 archie Exp $
-.\"
-.Dd January 19, 1999
-.Dt NG_LMI 8
-.Os FreeBSD
-.Sh NAME
-.Nm ng_lmi
-.Nd frame relay LMI protocol netgraph node type
-.Sh SYNOPSIS
-.Fd #include <netgraph/ng_lmi.h>
-.Sh DESCRIPTION
-The
-.Nm lmi
-node type performs the frame relay LMI protocol. It supports
-the ITU Annex A, ANSI Annex D, and Group-of-four LMI types.
-It also supports auto-detection of the LMI type.
-.Pp
-To enable a specific LMI type, connect the corresponding hook (
-.Dv annexA ,
-.Dv annexD ,
-or
-.Dv group4 ")"
-to DLCI 0 or 1023 of a
-.Xr ng_frame_relay 8
-node.
-Typically, Annex A and Annex D live on DLCI 0 while Group-of-four
-lives on DLCI 1023.
-.Pp
-To enable LMI type auto-detection, connect the
-.Dv auto0
-hook to DLCI 0 and the
-.Dv auto1023
-hook to DLCI 1023. The node will attempt to automatically determine
-which LMI type is running at the switch, and go into that mode.
-.Pp
-Only one fixed LMI type, or auto-detection, can be active at any given time.
-.Pp
-The
-.Dv NGM_LMI_GET_STATUS
-control message can be used at any time to query the current status
-of the LMI protocol and each DLCI channel. This node also supports the
-.Dv NGM_TEXT_STATUS
-control message.
-.Sh HOOKS
-This node type supports the following hooks:
-.Pp
-.Bl -tag -width foobarbaz
-.It Dv annexA
-ITU Annex A LMI hook.
-.It Dv annexD
-ANSI Annex D LMI hook.
-.It Dv group4
-Group-of-four LMI hook.
-.It Dv auto0
-Auto-detection hook for DLCI 0.
-.It Dv auto1023
-Auto-detection hook for DLCI 1023.
-.El
-.Sh CONTROL MESSAGES
-This node type supports the generic control messages, plus the following:
-.Bl -tag -width foo
-.It Dv NGM_LMI_GET_STATUS
-This command returns status information in a
-.Dv "struct nglmistat" :
-.Bd -literal -offset 4n
-#define NGM_LMI_STAT_ARYSIZE (1024/8)
-
-struct nglmistat {
- u_char proto[12]; /* Active proto (same as hook name) */
- u_char hook[12]; /* Active hook */
- u_char fixed; /* If set to fixed LMI mode */
- u_char autod; /* If currently auto-detecting */
- u_char seen[NGM_LMI_STAT_ARYSIZE]; /* bitmap DLCIs seen */
- u_char up[NGM_LMI_STAT_ARYSIZE]; /* bitmap DLCIs up */
-};
-.Ed
-.It Dv NGM_TEXT_STATUS
-This generic message returns is a human-readable version of the node status.
-.El
-.Sh SHUTDOWN
-This node shuts down upon receipt of a
-.Dv NGM_SHUTDOWN
-control message, or when all hooks have been disconnected.
-.Sh SEE ALSO
-.Xr netgraph 4 ,
-.Xr ng_frame_relay 8 ,
-.Xr ngctl 8 .
-.Rs
-.%T "ANSI T1.617-1991 Annex D"
-.Re
-.Rs
-.%T "ITU-T Q.933 Digital Subscriber Signaling System No. 1 - Signaling Specification for Frame Mode Basic Call Control, Annex A"
-.Re
-.Sh HISTORY
-The
-.Nm
-node type was implemented in
-.Fx 4.0 .
-.Sh AUTHORS
-.An Julian Elischer Aq julian@whistle.com
diff --git a/sys/modules/netgraph/ppp/ng_ppp.4 b/sys/modules/netgraph/ppp/ng_ppp.4
deleted file mode 100644
index 96045e0d1df3..000000000000
--- a/sys/modules/netgraph/ppp/ng_ppp.4
+++ /dev/null
@@ -1,386 +0,0 @@
-.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
-.\" All rights reserved.
-.\"
-.\" Subject to the following obligations and disclaimer of warranty, use and
-.\" redistribution of this software, in source or object code forms, with or
-.\" without modifications are expressly permitted by Whistle Communications;
-.\" provided, however, that:
-.\" 1. Any and all reproductions of the source or object code must include the
-.\" copyright notice above and the following disclaimer of warranties; and
-.\" 2. No rights are granted, in any manner or form, to use Whistle
-.\" Communications, Inc. trademarks, including the mark "WHISTLE
-.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
-.\" such appears in the above copyright notice or in the software.
-.\"
-.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
-.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
-.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
-.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
-.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
-.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
-.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
-.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
-.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
-.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
-.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
-.\" OF SUCH DAMAGE.
-.\"
-.\" Author: Archie Cobbs <archie@whistle.com>
-.\"
-.\" $FreeBSD$
-.\" $Whistle: ng_ppp.8,v 1.3 1999/01/25 23:46:27 archie Exp $
-.\"
-.Dd January 19, 1999
-.Dt NG_PPP 8
-.Os FreeBSD
-.Sh NAME
-.Nm ng_ppp
-.Nd PPP protocol netgraph node type
-.Sh SYNOPSIS
-.Fd #include <netgraph/ng_ppp.h>
-.Sh DESCRIPTION
-The
-.Nm ppp
-node type performs multiplexing for the PPP protocol. It handles
-only packets that contain data, and forwards protocol negotiation
-and control packets to a separate controlling entity (e.g., a
-user-land daemon). This approach combines the fast dispatch of
-kernel implementations with the configuration flexibility of a
-user-land implementations. The PPP node type directly supports
-multi-link PPP, Van Jacobsen compression, PPP compression, PPP
-encryption, and the IP, IPX, and AppleTalk protocols. A single
-PPP node corresponds to one PPP multi-link bundle.
-.Pp
-There is a separate hook for each PPP link in the bundle, plus
-several hooks corresponding to the directly supported protocols.
-For compression and encryption, separate attached nodes are required
-to do the actual work. The node type used will of course depend
-on the algorithm negotiated. There is also a
-.Dv bypass
-hook which is used to handle any protocol not directly supported
-by the node. This includes all of the control protocols: LCP, IPCP,
-CCP, etc. Typically this node is connected to a user-land daemon
-via a
-.Xr ng_socket 8
-type node.
-.Sh ENABLING FUNCTIONALITY
-In general, the PPP node enables a specific link or functionality when
-(a) a
-.Dv NGM_PPP_SET_CONFIG
-message has been received which enables it, and
-(b) the corresponding hook(s) are connected.
-This allows the controlling entity to use either method (a) or (b)
-(or both) to control the node's behavior.
-When a link is connected but disabled, traffic can still flow on
-the link via the
-.Dv bypass
-hook (see below).
-.Sh LINK HOOKS
-During normal operation, the individual PPP links are connected to hooks
-.Dv link0 ,
-.Dv link1 ,
-etc. Up to
-.Dv NG_PPP_MAX_LINKS
-links are supported.
-These device-independent hooks transmit and receive full PPP
-frames, which include the PPP protocol, address, control, and
-information fields, but no checksum or other link-specific fields.
-.Pp
-On outgoing frames, when protocol compression
-has been enabled and the protocol number is suitable for compression,
-the protocol field will be compressed (i.e., sent as one byte
-instead of two). Either compressed or uncompressed protocol fields
-are accepted on incoming frames. Similarly, if address and control
-field compression has been enabled for the link, the address and
-control fields will be omitted (except for LCP frames as required
-by the standards). Incoming frames have the address and control fields
-stripped automatically if present.
-.Pp
-Since all negotiation is handled outside the PPP node, the links
-should not be connected and enabled until the corresponding link
-has reached the network phase (i.e., LCP negotiation and authentication
-have completed successfully) and the PPP node has been informed of
-the link parameters via the
-.Dv NGM_PPP_LINK_CONFIG
-message.
-.Pp
-When a link is connected but disabled, all received frames are forwarded
-directly out the
-.Dv bypass
-hook, and conversely, frames may be transmitted via the
-.Dv bypass
-hook as well. This mode is appropriate for the link authentication phase.
-As soon as the link is enabled, the PPP node will
-begin processing frames received on the link.
-.Sh COMPRESSION AND ENCRYPTION
-Compression is supported via two hooks,
-.Dv compress
-and
-.Dv decompress .
-When enabled and connected, the PPP node writes outgoing frames on the
-.Dv comp
-hook and expects to receive back the compressed frame on the same hook.
-Similarly, the
-.Dv decompress
-hook is used to uncompress incoming frames when decompression is
-negotiated (compression and decompression are independently negotiable).
-The type of node attached to these hooks should correspond
-to the type of compression negotiated, e.g., Deflate, Predictor-1, etc.
-.Pp
-Encryption works exactly analogously via the
-.Dv encrypt
-and
-.Dv decrypt
-nodes. Data is always compressed before being encrypted,
-and decrypted before being decompressed.
-.Pp
-Only bundle-level compression and encryption is directly supported;
-link-level compression and encryption can be handled transparently
-by downstream nodes.
-.Sh VAN JACOBSEN COMPRESSION
-When all of the
-.Dv vjc_ip ,
-.Dv vjc_vjcomp ,
-.Dv vjc_vjuncomp ,
-and
-.Dv vjc_vjip
-hooks are connected, and the corresponding configuration flag is
-enabled, Van Jacobsen compression and/or decompression will become active.
-Normally these hooks connect to the corresponding hooks of a single
-.Xr ng_vjc 8
-node. The PPP node is compatible with the
-.Dq pass through
-modes of the
-.Xr ng_vjc 8
-node type.
-.Sh BYPASS HOOK
-When a frame is received on a link with an unsupported protocol,
-or a protocol which is disabled or for which the corresponding hook
-is unconnected, the PPP node forwards the frame out the
-.Dv bypass
-hook, prepended with a four byte prefix. This first two bytes of
-the prefix indicate the link number on which the frame was received
-(in network order).
-For such frames received over the bundle (i.e., encapsulated in the
-multi-link protocol), the special link number
-.Dv NG_PPP_BUNDLE_LINKNUM
-is used. After the two byte link number is the two byte PPP protocol number
-(also in network order).
-The PPP protocol number is two bytes long even if the original frame
-was protocol compressed.
-.Pp
-Conversely, any data written to the
-.Dv bypass
-hook is assumed to be in this same format. The four byte header is
-stripped off, the PPP protocol number is prepended (possibly compressed),
-and the frame is delivered over the desired link.
-If the link number is
-.Dv NG_PPP_BUNDLE_LINKNUM
-the frame will be delivered over the multi-link bundle; or, if multi-link
-is disabled, over the (single) PPP link.
-.Pp
-Typically when the controlling entity receives a packet on the bypass
-hook it responds either by dropping the frame (if it's not ready for
-the protocol) or with an LCP protocol reject (if it doesn't recognize
-or expect the protocol).
-.Sh MULTILINK OPERATION
-To enable multi-link PPP, the corresponding configuration flag must be set
-and at least one link connected. The PPP node will not allow more than
-one link to be connected if multi-link is not enabled, nor will it allow
-certain multi-link settings to be changed while multi-link operation is
-active (e.g., short sequence number header format).
-.Pp
-Because packets are sent as fragments across multiple individual links,
-it is important that when a link goes down the PPP node is notified
-immediately, either by disconnecting the corresponding hook or disabling
-the link via the
-.Dv NGM_PPP_SET_CONFIG
-control message.
-.Pp
-Each link has configuration parameters for latency (specified in
-milliseconds) and bandwidth (specified in tens of bytes per second).
-The PPP node can be configured for
-.Em round-robin
-or
-.Em optimized
-packet delivery.
-.Pp
-When configured for round-robin delivery, the latency and bandwidth
-values are ignored and the PPP node simply sends each frame as a
-single fragment, alternating frames across all the links in the
-bundle. This scheme has the advantage that even if one link fails
-silently, some packets will still get through. It has the disadvantage
-of sub-optimal overall bundle latency, which is important for
-interactive response time, and sub-optimal overall bundle bandwidth
-when links with different bandwidths exist in the same bundle.
-.Pp
-When configured for optimal delivery, the PPP node distributes the
-packet across the links in a way that minimizes the time it takes
-for the completed packet to be received by the far end. This
-involves taking into account each link's latency, bandwidth, and
-current queue length. Therefore these numbers should be
-configured as accurately as possible. The algorithm does require
-some computation, so may not be appropriate for very slow machines
-and/or very fast links.
-.Pp
-As a special case, if all links have identical latency and bandwidth,
-then the above algorithm is disabled (because it is unnecessary)
-and the PPP node simply fragments frames into equal sized portions
-across all of the links.
-.Sh HOOKS
-This node type supports the following hooks:
-.Pp
-.Bl -tag -compact -width vjc_vjuncomp
-.It Dv link<N>
-Individual PPP link number
-.Dv <N>
-.It Dv compress
-Connection to compression engine
-.It Dv decompress
-Connection to decompression engine
-.It Dv encrypt
-Connection to encryption engine
-.It Dv decrypt
-Connection to decryption engine
-.It Dv vjc_ip
-Connection to
-.Xr ng_vjc 8
-.Dv ip
-hook
-.It Dv vjc_vjcomp
-Connection to
-.Xr ng_vjc 8
-.Dv vjcomp
-hook
-.It Dv vjc_vjuncomp
-Connection to
-.Xr ng_vjc 8
-.Dv vjuncomp
-hook
-.It Dv vjc_vjip
-Connection to
-.Xr ng_vjc 8
-.Dv vjip
-hook
-.It Dv inet
-IP packet data
-.It Dv atalk
-AppleTalk packet data
-.It Dv ipx
-IPX packet data
-.It Dv bypass
-Bypass hook; frames have a four byte header consisting of
-a link number and a PPP protocol number.
-.El
-.Pp
-.Sh CONTROL MESSAGES
-This node type supports the generic control messages, plus the following:
-.Bl -tag -width foo
-.It Dv NGM_PPP_SET_CONFIG
-This command configures all aspects of the node. This includes enabling
-multi-link PPP, encryption, compression, Van Jacobsen compression, and IP,
-AppleTalk, and IPX packet delivery. It includes per-link configuration,
-including enabling the link, setting latency and bandwidth parameters,
-and enabling protocol field compression. Note that no link or functionality
-is active until the corresponding hook is also connected.
-This command takes a
-.Dv "struct ng_ppp_node_config"
-as an argument:
-.Bd -literal -offset 0
-/* Per-link config structure */
-struct ng_ppp_link_config {
- u_char enableLink; /* enable this link */
- u_char enableProtoComp;/* enable protocol field compression */
- u_char enableACFComp; /* enable addr/ctrl field compression */
- u_int16_t mru; /* peer MRU */
- u_int32_t latency; /* link latency (in milliseconds) */
- u_int32_t bandwidth; /* link bandwidth (in bytes/second) */
-};
-
-/* Node config structure */
-struct ng_ppp_node_config {
- u_int16_t mrru; /* multilink peer MRRU */
- u_char enableMultilink; /* enable multilink */
- u_char recvShortSeq; /* recv multilink short seq # */
- u_char xmitShortSeq; /* xmit multilink short seq # */
- u_char enableRoundRobin; /* xmit whole packets */
- u_char enableIP; /* enable IP data flow */
- u_char enableAtalk; /* enable AppleTalk data flow */
- u_char enableIPX; /* enable IPX data flow */
- u_char enableCompression; /* enable PPP compression */
- u_char enableDecompression; /* enable PPP decompression */
- u_char enableEncryption; /* enable PPP encryption */
- u_char enableDecryption; /* enable PPP decryption */
- u_char enableVJCompression; /* enable VJ compression */
- u_char enableVJDecompression; /* enable VJ decompression */
- struct ng_ppp_link_config /* per link config params */
- links[NG_PPP_MAX_LINKS];
-};
-.Ed
-.Pp
-.It Dv NGM_PPP_GET_CONFIG
-Returns the current configuration as a
-.Dv "struct ng_ppp_node_config" .
-.It Dv NGM_PPP_GET_LINK_STATS
-This command takes a two byte link number as an argument and returns a
-.Dv "struct ng_ppp_link_stat"
-containing statistics for the corresponding link. Here
-.Dv NG_PPP_BUNDLE_LINKNUM
-is a valid link number corresponding to the multi-link bundle.
-.It Dv NGM_PPP_CLR_LINK_STATS
-This command takes a two byte link number as an argument and
-clears the statistics for that link.
-.It Dv NGM_PPP_GETCLR_LINK_STATS
-Same as
-.Dv NGM_PPP_GET_LINK_STATS ,
-but also atomically clears the statistics as well.
-.El
-.Pp
-This node type also accepts the control messages accepted by the
-.Xr ng_vjc 8
-node type. When received, these messages are simply forwarded to
-the adjacent
-.Xr ng_vjc 8
-node, if any. This is particularly useful when the individual
-PPP links are able to generate
-.Dv NGM_VJC_RECV_ERROR
-messages (see
-.Xr ng_vjc 8
-for a description).
-.Sh SHUTDOWN
-This node shuts down upon receipt of a
-.Dv NGM_SHUTDOWN
-control message, or when all hooks have been disconnected.
-.Sh SEE ALSO
-.Xr netgraph 4 ,
-.Xr ng_async 8 ,
-.Xr ng_iface 8 ,
-.Xr ng_vjc 8 ,
-.Xr ng_pppoe 8 ,
-.Xr ngctl 8 .
-.Rs
-.%A W. Simpson
-.%T "The Point-to-Point Protocol (PPP)"
-.%O RFC 1661
-.Re
-.Rs
-.%A K. Sklower
-.%A B. Lloyd
-.%A G. McGregor
-.%A D. Carr
-.%A T. Coradetti
-.%T "The PPP Multilink Protocol (MP)"
-.%O RFC 1990
-.Re
-.Sh HISTORY
-The
-.Nm
-node type was implemented in
-.Fx 4.0 .
-.Sh AUTHORS
-.An Archie Cobbs Aq archie@whistle.com
diff --git a/sys/modules/netgraph/pppoe/ng_pppoe.4 b/sys/modules/netgraph/pppoe/ng_pppoe.4
deleted file mode 100644
index 60c40691e5ed..000000000000
--- a/sys/modules/netgraph/pppoe/ng_pppoe.4
+++ /dev/null
@@ -1,404 +0,0 @@
-.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
-.\" All rights reserved.
-.\"
-.\" Subject to the following obligations and disclaimer of warranty, use and
-.\" redistribution of this software, in source or object code forms, with or
-.\" without modifications are expressly permitted by Whistle Communications;
-.\" provided, however, that:
-.\" 1. Any and all reproductions of the source or object code must include the
-.\" copyright notice above and the following disclaimer of warranties; and
-.\" 2. No rights are granted, in any manner or form, to use Whistle
-.\" Communications, Inc. trademarks, including the mark "WHISTLE
-.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
-.\" such appears in the above copyright notice or in the software.
-.\"
-.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
-.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
-.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
-.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
-.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
-.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
-.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
-.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
-.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
-.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
-.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
-.\" OF SUCH DAMAGE.
-.\"
-.\" Author: Archie Cobbs <archie@whistle.com>
-.\"
-.\" $FreeBSD$
-.\" $Whistle: ng_pppoe.8,v 1.1 1999/01/25 23:46:27 archie Exp $
-.\"
-.Dd October 28, 1999
-.Dt NG_PPPOE 8
-.Os FreeBSD
-.Sh NAME
-.Nm ng_pppoe
-.Nd RFC 2516 PPPOE protocol netgraph node type
-.Sh SYNOPSIS
-.Fd #include <net/ethernet.h>
-.Fd #include <netgraph/ng_pppoe.h>
-.Sh DESCRIPTION
-The
-.Nm pppoe
-node type performs the PPPoE protocol. It is used in conjunction with the
-.Xr netgraph 4
-extensions to the Ethernet framework to divert and inject Ethernet packets
-to and from a PPP agent (which is not specified).
-.Pp
-The
-.Dv NGM_PPPOE_GET_STATUS
-control message can be used at any time to query the current status
-of the PPPOE module. The only statistics presently available are the
-total packet counts for input and output. This node does not yet support
-the
-.Dv NGM_TEXT_STATUS
-control message.
-.Sh HOOKS
-This node type supports the following hooks:
-.Pp
-.Bl -tag -width foobarbaz
-.It Dv ethernet
-The hook that should normally be connected to an Ethernet node.
-.It Dv debug
-Presently no use.
-.It Dv [unspecified]
-Any other name is assumed to be a session hook that will be connected to
-a PPP client agent, or a ppp server agent.
-.El
-.Sh CONTROL MESSAGES
-This node type supports the generic control messages, plus the following:
-.Bl -tag -width foo
-.It Dv NGM_PPPOE_GET_STATUS
-This command returns status information in a
-.Dv "struct ngpppoestat" :
-.Bd -literal -offset 4n
-struct ngpppoestat {
- u_int packets_in; /* packets in from ethernet */
- u_int packets_out; /* packets out towards ethernet */
-};
-.Ed
-.It Dv NGM_TEXT_STATUS
-This generic message returns is a human-readable version of the node status.
-(not yet)
-.It Dv NGM_PPPOE_CONNECT
-Tell a nominated newly created hook that it's session should enter
-the state machine in a manner to become a client. It must be newly created and
-a service name can be given as an argument. It is legal to specify a zero length
-service name. This is common on some DSL setups. A session request packet
-will be broadcast on the Ethernet.
-This command uses the
-.Dv ngpppoe_init_data
-structure shown below.
-.It Dv NGM_PPPOE_LISTEN
-Tell a nominated newly created hook that it's session should enter
-the state machine in a manner to become a server listener. The argument
-given is the name of the service to listen on behalf of. A zero length service
-length will match all requests for service. A matching service request
-packet will be passed unmodified back to the process responsible
-for starting the service. It can then examine it and pass it on to
-the session that is started to answer the request.
-This command uses the
-.Dv ngpppoe_init_data
-structure shown below.
-.It Dv NGM_PPPOE_OFFER
-Tell a nominated newly created hook that it's session should enter
-the state machine in a manner to become a server. The argument
-given is the name of the service to offer. A zero length service
-is legal. The State machine will progress to a state where it will await
-a request packet to be forwarded to it from the startup server,
-which in turn probably received it from a LISTEN mode hook ( see above).
-This is so
-that information that is required for the session that is embedded in
-the original session request packet, is made available to the state machine
-that eventually answers the request. When the Session request packet is
-received, the session negotiation will proceed.
-This command uses the
-.Dv ngpppoe_init_data
-structure shown below.
-.Pp
-The three commands above use a common data structure:
-.Bd -literal -offset 4n
-struct ngpppoe_init_data {
- char hook[NG_HOOKLEN + 1]; /* hook to monitor on */
- u_int16_t data_len; /* service name length */
- char data[0]; /* init data goes here */
-};
-.Ed
-.It Dv NGM_PPPOE_SUCCESS
-This command is sent to the node that started this session with one of the
-above messages, and reports a state change. This message reports
-successful Session negotiation. It uses the structure shown below, and
-reports back the hook name corresponding to the successful session.
-.It Dv NGM_NGM_PPPOE_FAIL
-This command is sent to the node that started this session with one of the
-above messages, and reports a state change. This message reports
-failed Session negotiation. It uses the structure shown below, and
-reports back the hook name corresponding to the failed session.
-The hook will probably have been removed immediately after sending this message
-.It Dv NGM_NGM_PPPOE_CLOSE
-This command is sent to the node that started this session with one of the
-above messages, and reports a state change. This message reports
-a request to close a session. It uses the structure shown below, and
-reports back the hook name corresponding to the closed session.
-The hook will probably have been removed immediately after sending this
-message. At present this message is not yet used and a 'failed' message
-will be received at closure instead.
-.Pp
-The three commands above use a common data structure:
-.Bd -literal -offset 4n
-struct ngpppoe_sts {
- char hook[NG_HOOKLEN + 1]; /* hook associated with event session */
-};
-
-.El
-.Sh SHUTDOWN
-This node shuts down upon receipt of a
-.Dv NGM_SHUTDOWN
-control message, when all session have been disconnected or when the
-.Dv ethernet
-hook is disconnected.
-.Sh EXAMPLES
-The following code uses
-.Dv libnetgraph
-to set up a
-.Nm
-node and connect it to both a socket node and an Ethernet node. It can handle
-the case of when a
-.Nm
-node is already attached to the Ethernet. It then starts a client session.
-.Bd -literal
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <unistd.h>
-#include <sysexits.h>
-#include <errno.h>
-#include <err.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/select.h>
-#include <net/ethernet.h>
-
-#include <netgraph.h>
-#include <netgraph/ng_ether.h>
-#include <netgraph/ng_pppoe.h>
-#include <netgraph/ng_socket.h>
-static int setup(char *ethername, char *service, char *sessname,
- int *dfd, int *cfd);
-
-int
-main()
-{
- int fd1, fd2;
- setup("xl0", NULL, "fred", &fd1, &fd2);
- sleep (30);
-}
-
-static int
-setup(char *ethername, char *service, char *sessname,
- int *dfd, int *cfd)
-{
- struct ngm_connect ngc; /* connect */
- struct ngm_mkpeer mkp; /* mkpeer */
- /******** nodeinfo stuff **********/
- u_char rbuf[2 * 1024];
- struct ng_mesg *const resp = (struct ng_mesg *) rbuf;
- struct hooklist *const hlist
- = (struct hooklist *) resp->data;
- struct nodeinfo *const ninfo = &hlist->nodeinfo;
- int ch, no_hooks = 0;
- struct linkinfo *link;
- struct nodeinfo *peer;
- /****message to connect pppoe session*****/
- struct {
- struct ngPPPoE_init_data idata;
- char service[100];
- } message;
- /********tracking our little graph ********/
- char path[100];
- char source_ID[NG_NODELEN + 1];
- char pppoe_node_name[100];
- int k;
-
- /*
- * Create the data and control sockets
- */
- if (NgMkSockNode(NULL, cfd, dfd) < 0) {
- return (errno);
- }
- /*
- * find the ether node of the name requested by asking it for
- * it's inquiry information.
- */
- if (strlen(ethername) > 16)
- return (EINVAL);
- sprintf(path, "%s:", ethername);
- if (NgSendMsg(*cfd, path, NGM_GENERIC_COOKIE,
- NGM_LISTHOOKS, NULL, 0) < 0) {
- return (errno);
- }
- /*
- * the command was accepted so it exists. Await the reply (It's
- * almost certainly already waiting).
- */
- if (NgRecvMsg(*cfd, resp, sizeof(rbuf), NULL) < 0) {
- return (errno);
- }
- /**
- * The following is available about the node:
- * ninfo->name (string)
- * ninfo->type (string)
- * ninfo->id (u_int32_t)
- * ninfo->hooks (u_int32_t) (count of hooks)
- * check it is the correct type. and get it's ID for use
- * with mkpeer later.
- */
- if (strncmp(ninfo->type, NG_ETHER_NODE_TYPE,
- strlen(NG_ETHER_NODE_TYPE)) != 0) {
- return (EPROTOTYPE);
- }
- sprintf(source_ID, "[%08x]:", ninfo->id);
-
- /*
- * look for a hook already attached.
- */
- for (k = 0; k < ninfo->hooks; k++) {
- /**
- * The following are available about each hook.
- * link->ourhook (string)
- * link->peerhook (string)
- * peer->name (string)
- * peer->type (string)
- * peer->id (u_int32_t)
- * peer->hooks (u_int32_t)
- */
- link = &hlist->link[k];
- peer = &hlist->link[k].nodeinfo;
-
- /* Ignore debug hooks */
- if (strcmp("debug", link->ourhook) == 0)
- continue;
-
- /* If the orphans hook is attached, use that */
- if (strcmp(NG_ETHER_HOOK_ORPHAN,
- link->ourhook) == 0) {
- break;
- }
- /* the other option is the 'divert' hook */
- if (strcmp("NG_ETHER_HOOK_DIVERT",
- link->ourhook) == 0) {
- break;
- }
- }
-
- /*
- * See if we found a hook there.
- */
- if (k < ninfo->hooks) {
- if (strcmp(peer->type, NG_PPPOE_NODE_TYPE) == 0) {
- /*
- * If it's a type pppoe, we skip making one
- * ourself, but we continue, using
- * the existing one.
- */
- sprintf(pppoe_node_name, "[%08x]:", peer->id);
- } else {
- /*
- * There is already someone hogging the data,
- * return an error. Some day we'll try
- * daisy-chaining..
- */
- return (EBUSY);
- }
- } else {
-
- /*
- * Try make a node of type pppoe against node "ID"
- * On hook NG_ETHER_HOOK_ORPHAN.
- */
- snprintf(mkp.type, sizeof(mkp.type),
- "%s", NG_PPPOE_NODE_TYPE);
- snprintf(mkp.ourhook, sizeof(mkp.ourhook),
- "%s", NG_ETHER_HOOK_ORPHAN);
- snprintf(mkp.peerhook, sizeof(mkp.peerhook),
- "%s", NG_PPPOE_HOOK_ETHERNET);
- /* Send message */
- if (NgSendMsg(*cfd, source_ID, NGM_GENERIC_COOKIE,
- NGM_MKPEER, &mkp, sizeof(mkp)) < 0) {
- return (errno);
- }
- /*
- * Work out a name for the new node.
- */
- sprintf(pppoe_node_name, "%s:%s",
- source_ID, NG_ETHER_HOOK_ORPHAN);
- }
- /*
- * We now have a pppoe node attached to the ethernet
- * card. The Ethernet is addressed as ethername: The pppoe
- * node is addressed as pppoe_node_name: attach to it.
- * Connect socket node to specified node Use the same hook
- * name on both ends of the link.
- */
- snprintf(ngc.path, sizeof(ngc.path), "%s", pppoe_node_name);
- snprintf(ngc.ourhook, sizeof(ngc.ourhook), "%s", sessname);
- snprintf(ngc.peerhook, sizeof(ngc.peerhook), "%s", sessname);
-
- if (NgSendMsg(*cfd, ".:", NGM_GENERIC_COOKIE,
- NGM_CONNECT, &ngc, sizeof(ngc)) < 0) {
- return (errno);
- }
- /*
- * Send it a message telling it to start up.
- */
- bzero(&message, sizeof(message));
- snprintf(message.idata.hook, sizeof(message.idata.hook),
- "%s", sessname);
- if (service == NULL) {
- message.idata.data_len = 0;
- } else {
- snprintf(message.idata.data,
- sizeof(message.idata.data), "%s", service);
- message.idata.data_len = strlen(service);
- }
- /* Tell session/hook to start up as a client */
- if (NgSendMsg(*cfd, ngc.path,
- NGM_PPPOE_COOKIE, NGM_PPPOE_CONNECT, &message.idata,
- sizeof(message.idata) + message.idata.data_len) < 0) {
- return (errno);
- }
- return (0);
-}
-.Ed
-.Sh SEE ALSO
-.Xr netgraph 3 ,
-.Xr netgraph 4 ,
-.Xr ng_socket 8 ,
-.Xr ng_ppp 8 ,
-.Xr ngctl 8 .
-.Rs
-.%A L. Mamakos
-.%A K. Lidl
-.%A J. Evarts
-.%A D. Carrel
-.%A D. Simone
-.%A R. Wheeler
-.%T "A Method for transmitting PPP over Ethernet (PPPoE)"
-.%O RFC 2516
-.Re
-.Sh HISTORY
-The
-.Nm
-node type was implemented in
-.Fx 4.0 .
-.Sh AUTHORS
-.An Julian Elischer Aq julian@whistle.com
diff --git a/sys/modules/netgraph/pptpgre/ng_pptpgre.4 b/sys/modules/netgraph/pptpgre/ng_pptpgre.4
deleted file mode 100644
index 2b59eaa6e833..000000000000
--- a/sys/modules/netgraph/pptpgre/ng_pptpgre.4
+++ /dev/null
@@ -1,141 +0,0 @@
-.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
-.\" All rights reserved.
-.\"
-.\" Subject to the following obligations and disclaimer of warranty, use and
-.\" redistribution of this software, in source or object code forms, with or
-.\" without modifications are expressly permitted by Whistle Communications;
-.\" provided, however, that:
-.\" 1. Any and all reproductions of the source or object code must include the
-.\" copyright notice above and the following disclaimer of warranties; and
-.\" 2. No rights are granted, in any manner or form, to use Whistle
-.\" Communications, Inc. trademarks, including the mark "WHISTLE
-.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
-.\" such appears in the above copyright notice or in the software.
-.\"
-.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
-.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
-.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
-.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
-.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
-.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
-.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
-.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
-.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
-.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
-.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
-.\" OF SUCH DAMAGE.
-.\"
-.\" Author: Archie Cobbs <archie@whistle.com>
-.\"
-.\" $FreeBSD$
-.\" $Whistle: ng_pptpgre.8,v 1.2 1999/12/08 00:20:53 archie Exp $
-.\"
-.Dd November 29, 1999
-.Dt NG_PPTPGRE 8
-.Os FreeBSD
-.Sh NAME
-.Nm ng_pptpgre
-.Nd PPTP GRE protocol netgraph node type
-.Sh SYNOPSIS
-.Fd #include <netgraph/ng_pptpgre.h>
-.Sh DESCRIPTION
-The
-.Nm pptpgre
-node type performs Generic Routing Encapsulation (GRE) over IP
-for the PPTP protocol as specified by RFC 2637. This involves packet
-encapsulation, sequencing, acknowlegement, and an adaptive timeout
-sliding window mechanism. This node type does not handle any of
-the TCP control protocol or call negotiation defined by PPTP.
-.Pp
-The typical use for this node type would be to connect the
-.Dv upper
-hook to one of the link hooks of a
-.Xr ng_ppp 8
-node, and the
-.Dv lower
-hook to the
-.Dv "inet/raw/gre"
-hook of a
-.Xr ng_ksocket 8
-node.
-.Sh HOOKS
-This node type supports the following hooks:
-.Pp
-.Bl -tag -compact -width vjc_vjuncomp
-.It Dv upper
-Connection to the upper protocol layers
-.It Dv lower
-Connection to the lower protocol layers
-.El
-.Pp
-.Sh CONTROL MESSAGES
-This node type supports the generic control messages, plus the following:
-.Bl -tag -width foo
-.It Dv NGM_PPTPGRE_SET_CONFIG
-This command resets and configures the node for a session.
-This command takes a
-.Dv "struct ng_pptpgre_conf"
-as an argument:
-.Bd -literal -offset 0
-/* Configuration for a session */
-struct ng_pptpgre_conf {
- u_char enabled; /* enables traffic flow */
- u_char enableDelayedAck; /* enables delayed acks */
- u_int16_t cid; /* my call id */
- u_int16_t peerCid; /* peer call id */
- u_int16_t recvWin; /* peer recv window size */
- u_int16_t peerPpd; /* peer packet processing delay
- (in 1/10 of a second) */
-};
-
-.Ed
-The
-.Dv enabled
-field enables traffic flow through the node. The
-.Dv enableDelayedAck
-field enables delayed acknowledgement (maximum 250 miliseconds), which
-is a useful optimization and should generally be turned on.
-The remaining fields are as supplied by the PPTP virtual call setup process.
-.It Dv NGM_PPTPGRE_GET_CONFIG
-Returns the current configuration as a
-.Dv "struct ng_pptpgre_conf" .
-.El
-.Sh SHUTDOWN
-This node shuts down upon receipt of a
-.Dv NGM_SHUTDOWN
-control message, or when both hooks have been disconnected.
-.Sh SEE ALSO
-.Xr netgraph 4 ,
-.Xr ng_ksocket 8 ,
-.Xr ng_ppp 8 ,
-.Xr ngctl 8 .
-.Rs
-.%A K. Hamzeh
-.%A G. Pall
-.%A W. Verthein
-.%A J. Taarud
-.%A W. Little
-.%A G. Zorn
-.%T "Point-to-Point Tunneling Protocol (PPTP)"
-.%O RFC 2637
-.Re
-.Rs
-.%A S. Hanks
-.%A T. \&Li
-.%A D. Farinacci
-.%A P. Traina
-.%T "Generic Routing Encapsulation over IPv4 networks"
-.%O RFC 1702
-.Re
-.Sh HISTORY
-The
-.Nm
-node type was implemented in
-.Fx 4.0 .
-.Sh AUTHORS
-.An Archie Cobbs Aq archie@whistle.com
diff --git a/sys/modules/netgraph/rfc1490/ng_rfc1490.4 b/sys/modules/netgraph/rfc1490/ng_rfc1490.4
deleted file mode 100644
index f8d3e015f625..000000000000
--- a/sys/modules/netgraph/rfc1490/ng_rfc1490.4
+++ /dev/null
@@ -1,114 +0,0 @@
-.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
-.\" All rights reserved.
-.\"
-.\" Subject to the following obligations and disclaimer of warranty, use and
-.\" redistribution of this software, in source or object code forms, with or
-.\" without modifications are expressly permitted by Whistle Communications;
-.\" provided, however, that:
-.\" 1. Any and all reproductions of the source or object code must include the
-.\" copyright notice above and the following disclaimer of warranties; and
-.\" 2. No rights are granted, in any manner or form, to use Whistle
-.\" Communications, Inc. trademarks, including the mark "WHISTLE
-.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
-.\" such appears in the above copyright notice or in the software.
-.\"
-.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
-.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
-.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
-.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
-.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
-.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
-.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
-.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
-.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
-.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
-.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
-.\" OF SUCH DAMAGE.
-.\"
-.\" Author: Archie Cobbs <archie@whistle.com>
-.\"
-.\" $FreeBSD$
-.\" $Whistle: ng_rfc1490.8,v 1.4 1999/01/25 23:46:27 archie Exp $
-.\"
-.Dd January 19, 1999
-.Dt NG_RFC1490 8
-.Os FreeBSD
-.Sh NAME
-.Nm ng_rfc1490
-.Nd RFC 1490 netgraph node type
-.Sh SYNOPSIS
-.Fd #include <netgraph/ng_rfc1490.h>
-.Sh DESCRIPTION
-The
-.Nm rfc1490
-node type performs protocol encapsulation, de-encapsulation, and
-multiplexing according to RFC 1490 (which has since been updated by RFC 2427).
-This particular type of encapsulation is often used on top of frame relay
-DLCI channels.
-.Pp
-The
-.Dv downstream
-hook is used to transmit and receive encapsulated frames. On the other
-side of the node, the
-.Dv inet
-and
-.Dv ppp
-hooks are used to transmit and receive raw IP frames and PPP frames,
-respectively. PPP frames are transmitted and received according to
-RFC 1973; in particular, frames appearing on the
-.Dv ppp
-hook begin with the PPP protocol number.
-.Pp
-Typically the
-.Dv inet
-hook is connected to the
-.Dv inet
-hook of an
-.Xr ng_iface 8
-node.
-.Sh HOOKS
-This node type supports the following hooks:
-.Pp
-.Bl -tag -width foobarbazum
-.It Dv downstream
-Connects to the RFC 1490 peer entity.
-.It Dv inet
-Transmits and receives raw IP frames.
-.It Dv ppp
-Transmits and receives PPP frames.
-.El
-.Sh CONTROL MESSAGES
-This node type only supports the generic control messages.
-.Sh SHUTDOWN
-This node shuts down upon receipt of a
-.Dv NGM_SHUTDOWN
-control message, or when all hooks have been disconnected.
-.Sh BUGS
-Not all of RFC 1490 is implemented.
-.Sh SEE ALSO
-.Xr netgraph 4 ,
-.Xr ng_frame_relay 8 ,
-.Xr ng_iface 8 ,
-.Xr ngctl 8 .
-.Rs
-.%A C. Brown, A. Malis
-.%T "Multiprotocol Interconnect over Frame Relay"
-.%O RFC 2427
-.Re
-.Rs
-.%A W. Simpson
-.%T "PPP in Frame Relay"
-.%O RFC 1973
-.Re
-.Sh HISTORY
-The
-.Nm
-node type was implemented in
-.Fx 4.0 .
-.Sh AUTHORS
-.An Julian Elischer Aq julian@whistle.com
diff --git a/sys/modules/netgraph/socket/ng_socket.4 b/sys/modules/netgraph/socket/ng_socket.4
deleted file mode 100644
index 2a43b6a30e88..000000000000
--- a/sys/modules/netgraph/socket/ng_socket.4
+++ /dev/null
@@ -1,178 +0,0 @@
-.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
-.\" All rights reserved.
-.\"
-.\" Subject to the following obligations and disclaimer of warranty, use and
-.\" redistribution of this software, in source or object code forms, with or
-.\" without modifications are expressly permitted by Whistle Communications;
-.\" provided, however, that:
-.\" 1. Any and all reproductions of the source or object code must include the
-.\" copyright notice above and the following disclaimer of warranties; and
-.\" 2. No rights are granted, in any manner or form, to use Whistle
-.\" Communications, Inc. trademarks, including the mark "WHISTLE
-.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
-.\" such appears in the above copyright notice or in the software.
-.\"
-.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
-.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
-.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
-.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
-.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
-.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
-.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
-.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
-.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
-.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
-.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
-.\" OF SUCH DAMAGE.
-.\"
-.\" Author: Archie Cobbs <archie@whistle.com>
-.\"
-.\" $FreeBSD$
-.\" $Whistle: ng_socket.8,v 1.5 1999/01/25 23:46:27 archie Exp $
-.\"
-.Dd January 19, 1999
-.Dt NG_SOCKET 8
-.Os FreeBSD
-.Sh NAME
-.Nm ng_socket
-.Nd netgraph socket node type
-.Sh SYNOPSIS
-.Fd #include <netgraph/ng_message.h>
-.Fd #include <netgraph/ng_socket.h>
-.Sh DESCRIPTION
-A
-.Nm socket
-node is both a BSD socket and a netgraph node. The
-.Nm
-node type allows user-mode processes to participate in the kernel
-.Xr netgraph 4
-networking subsystem using the BSD socket interface. The process must have
-root privileges to be able to create netgraph sockets however once created,
-any process that has one may use it.
-.Pp
-A new
-.Nm
-node is created by creating a new socket of type
-.Dv NG_CONTROL
-in the protocol family
-.Dv PF_NETGRAPH ,
-using the
-.Xr socket 2
-system call.
-Any control messages received by the node
-and not having a cookie value of
-.Dv NGM_SOCKET_COOKIE
-are received by the process, using
-.Xr recvfrom 2 ;
-the socket address argument is a
-.Dv "struct sockaddr_ng"
-containing the sender's netgraph address. Conversely, control messages
-can be sent to any node by calling
-.Xr sendto 2 ,
-supplying the recipient's address in a
-.Dv "struct sockaddr_ng" .
-The
-.Xr bind 2
-system call may be used to assign a global netgraph name to the node.
-.Pp
-To transmit and receive netgraph data packets, a
-.Dv NG_DATA
-socket must also be created using
-.Xr socket 2
-and associated with a
-.Nm
-node.
-.Dv NG_DATA sockets do not automatically
-have nodes associated with them; they are bound to a specific node via the
-.Xr connect 2
-system call. The address argument is the netgraph address of the
-.Nm
-node already created. Once a data socket is associated with a node,
-any data packets received by the node are read using
-.Xr recvfrom 2
-and any packets to be sent out from the node are written using
-.Xr sendto 2 .
-In the case of data sockets, the
-.Dv "struct sockaddr_ng"
-contains the name of the
-.Em hook
-on which the data was received or should be sent.
-.Pp
-As a special case, to allow netgraph data sockets to be used as stdin or stdout
-on naive programs, a
-.Xr sendto 2
-with a NULL sockaddr pointer, a
-.Xr send 2
-or a
-.Xr write 2
-will succeed in the case where there is exactly ONE hook attached to
-the socket node, (and thus the path is unambiguous).
-.Pp
-There is a user library that simplifies using netgraph sockets; see
-.Xr netgraph 3 .
-.Sh HOOKS
-This node type supports hooks with arbitrary names (as long as
-they are unique) and always accepts hook connection requests.
-.Sh CONTROL MESSAGES
-This node type supports the generic control messages, plus the following:
-.Bl -tag -width foo
-.It Dv NGM_SOCK_CMD_NOLINGER
-When the last hook is removed from this node, it will shut down as
-if it had received a
-.Dv NGM_SHUTDOWN
-message. Attempts to access the sockets associated will return
-.Er ENOTCONN .
-.It Dv NGM_SOCK_CMD_LINGER
-This is the default mode. When the last hook is removed, the node will
-continue to exist, ready to accept new hooks until it
-is explicitly shut down.
-.El
-.Pp
-All other messages
-with neither the
-.Dv NGM_SOCKET_COOKIE
-or
-.Dv NGM_GENERIC_COOKIE
-will be passed unaltered up the
-.Dv NG_CONTROL
-socket.
-.Sh SHUTDOWN
-This node type shuts down and disappears when both the associated
-.Dv NG_CONTROL
-and
-.Dv NG_DATA
-sockets have been closed, or a
-.Dv NGM_SHUTDOWN
-control message is received. In the latter case, attempts to write
-to the still-open sockets will return
-.Er ENOTCONN .
-If the
-.Dv NGM_SOCK_CMD_NOLINGER
-message has been received, closure of the last hook will also initiate
-a shutdown of the node.
-.Sh BUGS
-It is not possible to reject the connection of a hook, though any
-data received on that hook can certainly be ignored.
-.Pp
-The controlling process is not notified of all events that an in-kernel node
-would be notified of, e.g. a new hook, or hook removal. We should define
-some node-initiated messages for this purpose (to be sent up the control
-socket).
-.Sh SEE ALSO
-.Xr socket 2 ,
-.Xr netgraph 3 ,
-.Xr netgraph 4 ,
-.Xr ng_ksocket 8 ,
-.Xr ngctl 8 .
-.Sh HISTORY
-The
-.Nm
-node type was implemented in
-.Fx 4.0 .
-.Sh AUTHORS
-.An Julian Elischer Aq julian@whistle.com
diff --git a/sys/modules/netgraph/tee/ng_tee.4 b/sys/modules/netgraph/tee/ng_tee.4
deleted file mode 100644
index 6116d27d9a16..000000000000
--- a/sys/modules/netgraph/tee/ng_tee.4
+++ /dev/null
@@ -1,124 +0,0 @@
-.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
-.\" All rights reserved.
-.\"
-.\" Subject to the following obligations and disclaimer of warranty, use and
-.\" redistribution of this software, in source or object code forms, with or
-.\" without modifications are expressly permitted by Whistle Communications;
-.\" provided, however, that:
-.\" 1. Any and all reproductions of the source or object code must include the
-.\" copyright notice above and the following disclaimer of warranties; and
-.\" 2. No rights are granted, in any manner or form, to use Whistle
-.\" Communications, Inc. trademarks, including the mark "WHISTLE
-.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
-.\" such appears in the above copyright notice or in the software.
-.\"
-.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
-.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
-.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
-.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
-.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
-.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
-.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
-.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
-.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
-.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
-.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
-.\" OF SUCH DAMAGE.
-.\"
-.\" Author: Archie Cobbs <archie@whistle.com>
-.\"
-.\" $FreeBSD$
-.\" $Whistle: ng_tee.8,v 1.4 1999/01/25 23:46:27 archie Exp $
-.\"
-.Dd January 19, 1999
-.Dt NG_TEE 8
-.Os FreeBSD
-.Sh NAME
-.Nm ng_tee
-.Nd netgraph ``tee'' node type
-.Sh SYNOPSIS
-.Fd #include <netgraph/ng_tee.h>
-.Sh DESCRIPTION
-The
-.Nm tee
-node type has a purpose similar to the
-.Xr tee 1
-command.
-.Nm Tee
-nodes are useful for debugging or
-.Dq snooping
-on a connection
-between two netgraph nodes.
-.Nm Tee
-nodes have four hooks,
-.Dv right ,
-.Dv left ,
-.Dv right2left ,
-and
-.Dv left2right .
-All data received on
-.Dv right
-is sent unmodified to
-.Em both
-hooks
-.Dv left
-and
-.Dv right2left .
-Similarly, all data received on
-.Dv left
-is sent unmodified to both
-.Dv right
-and
-.Dv left2right .
-.Pp
-Packets may also be received on
-.Dv right2left
-and
-.Dv left2right ;
-if so, they are forwarded unchanged out hooks
-.Dv left
-and
-.Dv right ,
-respectively.
-.Sh HOOKS
-This node type supports the following hooks:
-.Pp
-.Bl -tag -width foobarbarfoo
-.It Dv right
-The connection to the node on the right.
-.It Dv left
-The connection to the node on the left.
-.It Dv right2left
-Tap for right to left traffic.
-.It Dv left2right
-Tap for left to right traffic.
-.El
-.Sh CONTROL MESSAGES
-This node type supports the generic control messages, plus the following.
-.Bl -tag -width foo
-.It Dv NGM_TEE_GET_STATS
-Get statistics, returned as a
-.Dv "struct ng_tee_stats" .
-.It Dv NGM_TEE_CLR_STATS
-Clear statistics.
-.El
-.Sh SHUTDOWN
-This node shuts down upon receipt of a
-.Dv NGM_SHUTDOWN
-control message, or when all hooks have been disconnected.
-.Sh SEE ALSO
-.Xr tee 1 ,
-.Xr netgraph 4 ,
-.Xr ngctl 8 .
-.Sh HISTORY
-The
-.Nm
-node type was implemented in
-.Fx 4.0 .
-.Sh AUTHORS
-.An Julian Elischer Aq julian@whistle.com
diff --git a/sys/modules/netgraph/tty/ng_tty.4 b/sys/modules/netgraph/tty/ng_tty.4
deleted file mode 100644
index de4a4c20d731..000000000000
--- a/sys/modules/netgraph/tty/ng_tty.4
+++ /dev/null
@@ -1,139 +0,0 @@
-.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
-.\" All rights reserved.
-.\"
-.\" Subject to the following obligations and disclaimer of warranty, use and
-.\" redistribution of this software, in source or object code forms, with or
-.\" without modifications are expressly permitted by Whistle Communications;
-.\" provided, however, that:
-.\" 1. Any and all reproductions of the source or object code must include the
-.\" copyright notice above and the following disclaimer of warranties; and
-.\" 2. No rights are granted, in any manner or form, to use Whistle
-.\" Communications, Inc. trademarks, including the mark "WHISTLE
-.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
-.\" such appears in the above copyright notice or in the software.
-.\"
-.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
-.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
-.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
-.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
-.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
-.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
-.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
-.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
-.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
-.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
-.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
-.\" OF SUCH DAMAGE.
-.\"
-.\" Author: Archie Cobbs <archie@whistle.com>
-.\"
-.\" $FreeBSD$
-.\" $Whistle: ng_tty.8,v 1.5 1999/01/25 23:46:28 archie Exp $
-.\"
-.Dd January 19, 1999
-.Dt NG_TTY 8
-.Os FreeBSD
-.Sh NAME
-.Nm ng_tty
-.Nd netgraph node type that is also a line discipline
-.Sh SYNOPSIS
-.Fd #include <sys/ttycom.h>
-.Fd #include <netgraph/ng_message.h>
-.Fd #include <netgraph/ng_tty.h>
-.Sh DESCRIPTION
-The
-.Nm tty
-node type is both a netgraph node type and a line discipline.
-A new node is created when the corresponding line discipline,
-.Dv NETGRAPHDISC ,
-is registered on a tty device (see
-.Xr tty 4 ) .
-.Pp
-The node has a single hook called
-.Dv hook .
-Incoming bytes received on the tty device are sent out on this hook,
-and frames received on
-.Dv hook
-are transmitted out on the tty device.
-No modification to the data is performed in either direction.
-While the line discipline is installed on a tty, the normal
-read and write operations are unavailable, returning
-.Er EIO .
-.Pp
-The node supports an optional
-.Dq hot character .
-If set to non-zero, incoming
-data from the tty device is queued until this character is seen.
-This avoids sending lots of mbufs containing a small number of bytes,
-but introduces potentially infinite latency.
-The default hot character is 0x7e, consistent with
-.Dv hook
-being connected to a
-.Xr ng_async 8
-type node. The hot character has no effect on the transmission of data.
-.Pp
-The node will attempt to give itself the same netgraph name as the name
-of the tty device.
-In any case, information about the node is available via the netgraph
-.Xr ioctl 2
-command
-.Dv NGIOCGINFO .
-This command returns a
-.Dv "struct nodeinfo"
-similar to the
-.Dv NGM_NODEINFO
-netgraph control message.
-.Sh HOOKS
-This node type supports the following hooks:
-.Pp
-.Bl -tag -width foobar
-.It Dv hook
-.Xr tty 4
-serial data contained in
-.Dv mbuf
-structures, with arbitrary inter-frame boundaries.
-.El
-.Sh CONTROL MESSAGES
-This node type supports the generic control messages, plus the following:
-.Bl -tag -width foo
-.It Dv NGM_TTY_SET_HOTCHAR
-This command takes an integer argument and sets the hot character
-from the lower 8 bits. A hot character of zero disables queueing,
-so that all received data is forwarded immediately.
-.It Dv NGM_TTY_GET_HOTCHAR
-Returns an integer containing the current hot character in the lower
-eight bits.
-.Sh SHUTDOWN
-This node shuts down when the corresponding device is closed
-(or the line discipline is uninstalled on the device).
-The
-.Dv NGM_SHUTDOWN
-control message is not valid, and always returns the error
-.Er EOPNOTSUPP .
-.Sh BUGS
-The serial driver code also has a notion of a
-.Dq hot character .
-Unfortunately, this value is statically defined in terms of the
-line discipline and cannot be changed.
-Therefore, if a hot character other than 0x7e (the default) is set for the
-.Nm
-node, the node has no way to convey this information to the
-serial driver, and sub-optimal performance may result.
-.Sh SEE ALSO
-.Xr ioctl 2 ,
-.Xr netgraph 4 ,
-.Xr tty 4 ,
-.Xr ng_async 8 ,
-.Xr ngctl 8 .
-.Sh HISTORY
-The
-.Nm
-node type was implemented in
-.Fx 4.0 .
-.Sh AUTHORS
-.An Archie Cobbs Aq archie@whistle.com
diff --git a/sys/modules/netgraph/vjc/ng_vjc.4 b/sys/modules/netgraph/vjc/ng_vjc.4
deleted file mode 100644
index 618489fdd501..000000000000
--- a/sys/modules/netgraph/vjc/ng_vjc.4
+++ /dev/null
@@ -1,223 +0,0 @@
-.\" Copyright (c) 1996-1999 Whistle Communications, Inc.
-.\" All rights reserved.
-.\"
-.\" Subject to the following obligations and disclaimer of warranty, use and
-.\" redistribution of this software, in source or object code forms, with or
-.\" without modifications are expressly permitted by Whistle Communications;
-.\" provided, however, that:
-.\" 1. Any and all reproductions of the source or object code must include the
-.\" copyright notice above and the following disclaimer of warranties; and
-.\" 2. No rights are granted, in any manner or form, to use Whistle
-.\" Communications, Inc. trademarks, including the mark "WHISTLE
-.\" COMMUNICATIONS" on advertising, endorsements, or otherwise except as
-.\" such appears in the above copyright notice or in the software.
-.\"
-.\" THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
-.\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
-.\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
-.\" INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
-.\" WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
-.\" REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
-.\" SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
-.\" IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
-.\" RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
-.\" WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-.\" PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
-.\" SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
-.\" OF SUCH DAMAGE.
-.\"
-.\" Author: Archie Cobbs <archie@whistle.com>
-.\"
-.\" $FreeBSD$
-.\" $Whistle: ng_vjc.8,v 1.4 1999/01/25 23:46:28 archie Exp $
-.\"
-.Dd January 19, 1999
-.Dt NG_VJC 8
-.Os FreeBSD
-.Sh NAME
-.Nm ng_vjc
-.Nd Van Jacobsen compression netgraph node type
-.Sh SYNOPSIS
-.Fd #include <net/slcompress.h>
-.Fd #include <netgraph/ng_vjc.h>
-.Sh DESCRIPTION
-The
-.Nm vjc
-node type performs Van Jacobsen compression, which is used
-over PPP, SLIP, and other point-to-point IP connections to
-compress TCP packet headers. The
-.Dv ip
-hook represents the uncompressed side of the node, while the
-.Dv vjcomp ,
-.Dv vjuncomp ,
-and
-.Dv vjip
-hooks represent the compressed side of the node. Packets received on the
-.Dv ip
-will be compressed or passed through as appropriate. Packets received
-on the other three hooks will be uncompressed as appropriate.
-This node also supports
-.Dq always pass through
-mode in either direction.
-.Pp
-Van Jacobsen compression only applies to TCP packets.
-Only
-.Dq normal
-(i.e., common case) TCP packets are actually compressed.
-These are output on the
-.Dv vjcomp
-hook. Other TCP packets are run through the state machine but not
-compressed; these appear on the
-.Dv vjuncomp
-hook.
-Other non-TCP IP packets are forwarded unchanged to
-.Dv vjip .
-.Pp
-When connecting to a
-.Xr ng_ppp 8
-node, the
-.Dv ip ,
-.Dv vjuncomp ,
-.Dv vjcomp ,
-and
-.Dv vjip
-hooks should be connected to the
-.Xr ng_ppp 8
-node's
-.Dv vjc_ip ,
-.Dv vjc_vjcomp ,
-.Dv vjc_vjuncomp ,
-and
-.Dv vjc_ip
-hooks, respectively.
-.Sh HOOKS
-This node type supports the following hooks:
-.Pp
-.Bl -tag -width foobarbazi
-.It Dv ip
-Upstream (uncompressed) IP packets.
-.It Dv vjcomp
-Downstream compressed TCP packets.
-.It Dv vjuncomp
-Downstream uncompressed TCP packets.
-.It Dv vjip
-Downstream uncompressed IP packets.
-.Sh CONTROL MESSAGES
-This node type supports the generic control messages, plus the following:
-.Bl -tag -width foo
-.It Dv NGM_VJC_SET_CONFIG
-This command resets the compression state and configures it according
-to the supplied
-.Dv "struct ngm_vjc_config"
-argument. This structure contains the following fields:
-.Bd -literal -offset 4n
-struct ngm_vjc_config {
- u_char enableComp; /* Enable compression */
- u_char enableDecomp; /* Enable decompression */
- u_char maxChannel; /* Number of outgoing channels - 1 */
- u_char compressCID; /* OK to compress outgoing CID's */
-};
-.Ed
-.Pp
-When
-.Dv enableComp
-is set to zero, all packets received on the
-.Dv ip
-hook are forwarded unchanged out the
-.Dv vjip
-hook. Similarly, when
-.Dv enableDecomp
-is set to zero, all packets received on the
-.Dv vjip
-hook are forwarded unchanged out the
-.Dv ip
-hook, and packets are not accepted on the
-.Dv vjcomp
-and
-.Dv vjuncomp
-hooks.
-When a node is first created,
-both compression and decompression are disabled and the node is
-therefore operating in bi-directional
-.Dq pass through
-mode.
-.Pp
-When enabling compression,
-.Dv maxChannel
-should be set to the number of outgoing compression channels minus one,
-and is a value between 3 and 15, inclusive. The
-.Dv compressCID
-field indicates whether it is OK to compress the CID header field for
-outgoing compressed TCP packets. This value should be zero unless
-either (a) it is not possible for an outgoing frame to be lost, or
-(b) lost frames can be reliably detected and immediately
-reported to the peer's decompression engine (see
-.Dv NGM_VJC_RECV_ERROR
-below).
-.It Dv NGM_VJC_GET_STATE
-This command returns the node's current state described by the
-.Dv "struct slcompress"
-structure, which is defined in
-.Pa net/slcompress.h .
-.It Dv NGM_VJC_CLR_STATS
-Clears the node statistics counters. Statistics are also cleared whenever the
-.Dv enableComp
-or
-.Dv enableDecomp
-fields are changed from zero to one by a
-.Dv NGM_VJC_SET_CONFIG
-control message.
-.It Dv NGM_VJC_RECV_ERROR
-When the peer has CID header field compression enabled,
-this message must be sent to the local
-.Nm vjc
-node immediately
-after detecting that a received frame has been lost, due to a bad
-checksum or for any other reason. Failing to do this can result
-in corrupted TCP stream data.
-.Sh SHUTDOWN
-This node shuts down upon receipt of a
-.Dv NGM_SHUTDOWN
-control message, or when all hooks have been disconnected.
-.Sh BUGS
-Because the initialization routine in the kernel implementation of
-Van Jacobsen compression initializes both compression and decompression
-at once, this node does not allow compression and decompression to
-be enabled in separate operations. In order to enable one when
-the other is already enabled, first both must be disabled, then
-both enabled. This of course resets the node state. This restriction
-may be lifted in a later version.
-.Pp
-When built as a loadable kernel module, this module includes the file
-.Pa net/slcompress.c .
-Although loading the module should fail if
-.Pa net/slcompress.c
-already exists in the kernel, currently it does not, and the duplicate
-copies of the file do not interfere.
-However, this may change in the future.
-.Sh SEE ALSO
-.Xr netgraph 4 ,
-.Xr ng_ppp 8 ,
-.Xr ng_iface 8 ,
-.Xr ngctl 8 .
-.Rs
-.%A V. Jacobsen
-.%T "Compressing TCP/IP Headers"
-.%O RFC 1144
-.Re
-.Rs
-.%A G. McGregor
-.%T "The PPP Internet Control Protocol (IPCP)"
-.%O RFC 1332
-.Re
-.Sh HISTORY
-The
-.Nm
-node type was implemented in
-.Fx 4.0 .
-.Sh AUTHORS
-.An Archie Cobbs Aq archie@whistle.com
diff --git a/sys/modules/nfsclient/Makefile b/sys/modules/nfsclient/Makefile
deleted file mode 100644
index 34d4006a038f..000000000000
--- a/sys/modules/nfsclient/Makefile
+++ /dev/null
@@ -1,18 +0,0 @@
-# $FreeBSD$
-
-.PATH: ${.CURDIR}/../../nfs
-KMOD= nfs
-SRCS= vnode_if.h \
- nfs_bio.c nfs_node.c nfs_nqlease.c nfs_serv.c nfs_socket.c \
- nfs_srvcache.c nfs_subs.c nfs_syscalls.c nfs_vfsops.c \
- nfs_vnops.c opt_inet.h opt_nfs.h opt_vmpage.h opt_bootp.h
-NFS_INET?= 1 # 0/1 - requires INET to be configured in kernel
-NOMAN=
-
-opt_inet.h:
- touch ${.TARGET}
-.if ${NFS_INET} > 0
- echo "#define INET 1" > ${.TARGET}
-.endif
-
-.include <bsd.kmod.mk>
diff --git a/sys/modules/nfsserver/Makefile b/sys/modules/nfsserver/Makefile
deleted file mode 100644
index 34d4006a038f..000000000000
--- a/sys/modules/nfsserver/Makefile
+++ /dev/null
@@ -1,18 +0,0 @@
-# $FreeBSD$
-
-.PATH: ${.CURDIR}/../../nfs
-KMOD= nfs
-SRCS= vnode_if.h \
- nfs_bio.c nfs_node.c nfs_nqlease.c nfs_serv.c nfs_socket.c \
- nfs_srvcache.c nfs_subs.c nfs_syscalls.c nfs_vfsops.c \
- nfs_vnops.c opt_inet.h opt_nfs.h opt_vmpage.h opt_bootp.h
-NFS_INET?= 1 # 0/1 - requires INET to be configured in kernel
-NOMAN=
-
-opt_inet.h:
- touch ${.TARGET}
-.if ${NFS_INET} > 0
- echo "#define INET 1" > ${.TARGET}
-.endif
-
-.include <bsd.kmod.mk>
diff --git a/sys/modules/portalfs/Makefile b/sys/modules/portalfs/Makefile
deleted file mode 100644
index 5cc476778021..000000000000
--- a/sys/modules/portalfs/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-# $FreeBSD$
-
-.PATH: ${.CURDIR}/../../miscfs/portal
-KMOD= portal
-SRCS= vnode_if.h \
- portal_vfsops.c portal_vnops.c
-NOMAN=
-
-.include <bsd.kmod.mk>
diff --git a/sys/modules/unionfs/Makefile b/sys/modules/unionfs/Makefile
deleted file mode 100644
index 6825a6376d91..000000000000
--- a/sys/modules/unionfs/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-# $FreeBSD$
-
-.PATH: ${.CURDIR}/../../miscfs/union
-KMOD= union
-SRCS= vnode_if.h \
- union_subr.c union_vfsops.c union_vnops.c
-NOMAN=
-
-.include <bsd.kmod.mk>
diff --git a/sys/net/fddi.h b/sys/net/fddi.h
deleted file mode 100644
index 9f83882cdf10..000000000000
--- a/sys/net/fddi.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 1982, 1986, 1993
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1995 Matt Thomas (thomas@lkg.dec.com)
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)if_fddi.h 8.1 (Berkeley) 6/10/93
- * $FreeBSD$
- */
-
-#ifndef _NETINET_IF_FDDI_H_
-#define _NETINET_IF_FDDI_H_
-
-/*
- * Structure of an 100Mb/s FDDI header.
- */
-struct fddi_header {
- u_char fddi_fc;
- u_char fddi_dhost[6];
- u_char fddi_shost[6];
-};
-
-#define FDDIIPMTU 4352
-#define FDDIMTU 4470
-#define FDDIMIN 3
-
-#define FDDIFC_C 0x80 /* 0b10000000 */
-#define FDDIFC_L 0x40 /* 0b01000000 */
-#define FDDIFC_F 0x30 /* 0b00110000 */
-#define FDDIFC_Z 0x0F /* 0b00001111 */
-
-#define FDDIFC_LLC_ASYNC 0x50
-#define FDDIFC_LLC_PRIO0 0
-#define FDDIFC_LLC_PRIO1 1
-#define FDDIFC_LLC_PRIO2 2
-#define FDDIFC_LLC_PRIO3 3
-#define FDDIFC_LLC_PRIO4 4
-#define FDDIFC_LLC_PRIO5 5
-#define FDDIFC_LLC_PRIO6 6
-#define FDDIFC_LLC_PRIO7 7
-#define FDDIFC_LLC_SYNC 0xd0
-#define FDDIFC_SMT 0x40
-
-#if defined(_KERNEL)
-#define fddibroadcastaddr etherbroadcastaddr
-#define fddi_ipmulticast_min ether_ipmulticast_min
-#define fddi_ipmulticast_max ether_ipmulticast_max
-#define fddi_addmulti ether_addmulti
-#define fddi_delmulti ether_delmulti
-#define fddi_sprintf ether_sprintf
-
-void fddi_ifattach __P((struct ifnet *));
-void fddi_input __P((struct ifnet *, struct fddi_header *, struct mbuf *));
-int fddi_output __P((struct ifnet *,
- struct mbuf *, struct sockaddr *, struct rtentry *));
-
-#endif
-
-#endif
diff --git a/sys/netatalk/ddp_pcb.c b/sys/netatalk/ddp_pcb.c
deleted file mode 100644
index 9fa97893853e..000000000000
--- a/sys/netatalk/ddp_pcb.c
+++ /dev/null
@@ -1,585 +0,0 @@
-/*
- * Copyright (c) 1990,1994 Regents of The University of Michigan.
- * All Rights Reserved. See COPYRIGHT.
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/proc.h>
-#include <sys/malloc.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-#include <sys/protosw.h>
-#include <net/if.h>
-#include <net/route.h>
-
-#include <netatalk/at.h>
-#include <netatalk/at_var.h>
-#include <netatalk/ddp_var.h>
-#include <netatalk/at_extern.h>
-
-static void at_pcbdisconnect( struct ddpcb *ddp );
-static void at_sockaddr(struct ddpcb *ddp, struct sockaddr **addr);
-static int at_pcbsetaddr(struct ddpcb *ddp, struct sockaddr *addr,
- struct proc *p);
-static int at_pcbconnect(struct ddpcb *ddp, struct sockaddr *addr,
- struct proc *p);
-static void at_pcbdetach(struct socket *so, struct ddpcb *ddp);
-static int at_pcballoc(struct socket *so);
-
-struct ddpcb *ddp_ports[ ATPORT_LAST ];
-struct ddpcb *ddpcb = NULL;
-static u_long ddp_sendspace = DDP_MAXSZ; /* Max ddp size + 1 (ddp_type) */
-static u_long ddp_recvspace = 10 * ( 587 + sizeof( struct sockaddr_at ));
-
-
-static int
-ddp_attach(struct socket *so, int proto, struct proc *p)
-{
- struct ddpcb *ddp;
- int error = 0;
- int s;
-
-
- ddp = sotoddpcb( so );
- if ( ddp != NULL ) {
- return( EINVAL);
- }
-
- s = splnet();
- error = at_pcballoc( so );
- splx(s);
- if (error) {
- return (error);
- }
- return (soreserve( so, ddp_sendspace, ddp_recvspace ));
-}
-
-static int
-ddp_detach(struct socket *so)
-{
- struct ddpcb *ddp;
- int s;
-
- ddp = sotoddpcb( so );
- if ( ddp == NULL ) {
- return( EINVAL);
- }
- s = splnet();
- at_pcbdetach( so, ddp );
- splx(s);
- return(0);
-}
-
-static int
-ddp_bind(struct socket *so, struct sockaddr *nam, struct proc *p)
-{
- struct ddpcb *ddp;
- int error = 0;
- int s;
-
- ddp = sotoddpcb( so );
- if ( ddp == NULL ) {
- return( EINVAL);
- }
- s = splnet();
- error = at_pcbsetaddr(ddp, nam, p);
- splx(s);
- return (error);
-}
-
-static int
-ddp_connect(struct socket *so, struct sockaddr *nam, struct proc *p)
-{
- struct ddpcb *ddp;
- int error = 0;
- int s;
-
- ddp = sotoddpcb( so );
- if ( ddp == NULL ) {
- return( EINVAL);
- }
-
- if ( ddp->ddp_fsat.sat_port != ATADDR_ANYPORT ) {
- return(EISCONN);
- }
-
- s = splnet();
- error = at_pcbconnect( ddp, nam, p );
- splx(s);
- if ( error == 0 )
- soisconnected( so );
- return(error);
-}
-
-static int
-ddp_disconnect(struct socket *so)
-{
-
- struct ddpcb *ddp;
- int s;
-
- ddp = sotoddpcb( so );
- if ( ddp == NULL ) {
- return( EINVAL);
- }
- if ( ddp->ddp_fsat.sat_addr.s_node == ATADDR_ANYNODE ) {
- return(ENOTCONN);
- }
-
- s = splnet();
- at_pcbdisconnect( ddp );
- ddp->ddp_fsat.sat_addr.s_node = ATADDR_ANYNODE;
- splx(s);
- soisdisconnected( so );
- return(0);
-}
-
-static int
-ddp_shutdown(struct socket *so)
-{
- struct ddpcb *ddp;
-
- ddp = sotoddpcb( so );
- if ( ddp == NULL ) {
- return( EINVAL);
- }
- socantsendmore( so );
- return(0);
-}
-
-static int
-ddp_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr,
- struct mbuf *control, struct proc *p)
-{
- struct ddpcb *ddp;
- int error = 0;
- int s;
-
- ddp = sotoddpcb( so );
- if ( ddp == NULL ) {
- return(EINVAL);
- }
-
- if ( control && control->m_len ) {
- return(EINVAL);
- }
-
- if ( addr ) {
- if ( ddp->ddp_fsat.sat_port != ATADDR_ANYPORT ) {
- return(EISCONN);
- }
-
- s = splnet();
- error = at_pcbconnect(ddp, addr, p);
- splx( s );
- if ( error ) {
- return(error);
- }
- } else {
- if ( ddp->ddp_fsat.sat_port == ATADDR_ANYPORT ) {
- return(ENOTCONN);
- }
- }
-
- s = splnet();
- error = ddp_output( m, so );
- if ( addr ) {
- at_pcbdisconnect( ddp );
- }
- splx(s);
- return(error);
-}
-
-static int
-ddp_abort(struct socket *so)
-{
- struct ddpcb *ddp;
- int s;
-
- ddp = sotoddpcb( so );
- if ( ddp == NULL ) {
- return(EINVAL);
- }
- soisdisconnected( so );
- s = splnet();
- at_pcbdetach( so, ddp );
- splx(s);
- return(0);
-}
-
-
-static void
-at_sockaddr(struct ddpcb *ddp, struct sockaddr **addr)
-{
- *addr = dup_sockaddr((struct sockaddr *)&ddp->ddp_lsat, 0);
-}
-
-static int
-at_pcbsetaddr(struct ddpcb *ddp, struct sockaddr *addr, struct proc *p)
-{
- struct sockaddr_at lsat, *sat;
- struct at_ifaddr *aa;
- struct ddpcb *ddpp;
-
- if ( ddp->ddp_lsat.sat_port != ATADDR_ANYPORT ) { /* shouldn't be bound */
- return( EINVAL );
- }
-
- if (addr != 0) { /* validate passed address */
- sat = (struct sockaddr_at *)addr;
- if (sat->sat_family != AF_APPLETALK) {
- return(EAFNOSUPPORT);
- }
-
- if ( sat->sat_addr.s_node != ATADDR_ANYNODE ||
- sat->sat_addr.s_net != ATADDR_ANYNET ) {
- for ( aa = at_ifaddr; aa; aa = aa->aa_next ) {
- if (( sat->sat_addr.s_net == AA_SAT( aa )->sat_addr.s_net ) &&
- ( sat->sat_addr.s_node == AA_SAT( aa )->sat_addr.s_node )) {
- break;
- }
- }
- if ( !aa ) {
- return( EADDRNOTAVAIL );
- }
- }
-
- if ( sat->sat_port != ATADDR_ANYPORT ) {
- if ( sat->sat_port < ATPORT_FIRST ||
- sat->sat_port >= ATPORT_LAST ) {
- return( EINVAL );
- }
- if ( sat->sat_port < ATPORT_RESERVED &&
- suser(p) ) {
- return( EACCES );
- }
- }
- } else {
- bzero( (caddr_t)&lsat, sizeof( struct sockaddr_at ));
- lsat.sat_len = sizeof(struct sockaddr_at);
- lsat.sat_addr.s_node = ATADDR_ANYNODE;
- lsat.sat_addr.s_net = ATADDR_ANYNET;
- lsat.sat_family = AF_APPLETALK;
- sat = &lsat;
- }
-
- if ( sat->sat_addr.s_node == ATADDR_ANYNODE &&
- sat->sat_addr.s_net == ATADDR_ANYNET ) {
- if ( at_ifaddr == NULL ) {
- return( EADDRNOTAVAIL );
- }
- sat->sat_addr = AA_SAT( at_ifaddr )->sat_addr;
- }
- ddp->ddp_lsat = *sat;
-
- /*
- * Choose port.
- */
- if ( sat->sat_port == ATADDR_ANYPORT ) {
- for ( sat->sat_port = ATPORT_RESERVED;
- sat->sat_port < ATPORT_LAST; sat->sat_port++ ) {
- if ( ddp_ports[ sat->sat_port - 1 ] == 0 ) {
- break;
- }
- }
- if ( sat->sat_port == ATPORT_LAST ) {
- return( EADDRNOTAVAIL );
- }
- ddp->ddp_lsat.sat_port = sat->sat_port;
- ddp_ports[ sat->sat_port - 1 ] = ddp;
- } else {
- for ( ddpp = ddp_ports[ sat->sat_port - 1 ]; ddpp;
- ddpp = ddpp->ddp_pnext ) {
- if ( ddpp->ddp_lsat.sat_addr.s_net == sat->sat_addr.s_net &&
- ddpp->ddp_lsat.sat_addr.s_node == sat->sat_addr.s_node ) {
- break;
- }
- }
- if ( ddpp != NULL ) {
- return( EADDRINUSE );
- }
- ddp->ddp_pnext = ddp_ports[ sat->sat_port - 1 ];
- ddp_ports[ sat->sat_port - 1 ] = ddp;
- if ( ddp->ddp_pnext ) {
- ddp->ddp_pnext->ddp_pprev = ddp;
- }
- }
-
- return( 0 );
-}
-
-static int
-at_pcbconnect(struct ddpcb *ddp, struct sockaddr *addr, struct proc *p)
-{
- struct sockaddr_at *sat = (struct sockaddr_at *)addr;
- struct route *ro;
- struct at_ifaddr *aa = 0;
- struct ifnet *ifp;
- u_short hintnet = 0, net;
-
- if (sat->sat_family != AF_APPLETALK) {
- return(EAFNOSUPPORT);
- }
-
- /*
- * Under phase 2, network 0 means "the network". We take "the
- * network" to mean the network the control block is bound to.
- * If the control block is not bound, there is an error.
- */
- if ( sat->sat_addr.s_net == ATADDR_ANYNET
- && sat->sat_addr.s_node != ATADDR_ANYNODE ) {
- if ( ddp->ddp_lsat.sat_port == ATADDR_ANYPORT ) {
- return( EADDRNOTAVAIL );
- }
- hintnet = ddp->ddp_lsat.sat_addr.s_net;
- }
-
- ro = &ddp->ddp_route;
- /*
- * If we've got an old route for this pcb, check that it is valid.
- * If we've changed our address, we may have an old "good looking"
- * route here. Attempt to detect it.
- */
- if ( ro->ro_rt ) {
- if ( hintnet ) {
- net = hintnet;
- } else {
- net = sat->sat_addr.s_net;
- }
- aa = 0;
- if ((ifp = ro->ro_rt->rt_ifp) != NULL) {
- for ( aa = at_ifaddr; aa; aa = aa->aa_next ) {
- if ( aa->aa_ifp == ifp &&
- ntohs( net ) >= ntohs( aa->aa_firstnet ) &&
- ntohs( net ) <= ntohs( aa->aa_lastnet )) {
- break;
- }
- }
- }
- if ( aa == NULL || ( satosat( &ro->ro_dst )->sat_addr.s_net !=
- ( hintnet ? hintnet : sat->sat_addr.s_net ) ||
- satosat( &ro->ro_dst )->sat_addr.s_node !=
- sat->sat_addr.s_node )) {
- RTFREE( ro->ro_rt );
- ro->ro_rt = (struct rtentry *)0;
- }
- }
-
- /*
- * If we've got no route for this interface, try to find one.
- */
- if ( ro->ro_rt == (struct rtentry *)0 ||
- ro->ro_rt->rt_ifp == (struct ifnet *)0 ) {
- ro->ro_dst.sa_len = sizeof( struct sockaddr_at );
- ro->ro_dst.sa_family = AF_APPLETALK;
- if ( hintnet ) {
- satosat( &ro->ro_dst )->sat_addr.s_net = hintnet;
- } else {
- satosat( &ro->ro_dst )->sat_addr.s_net = sat->sat_addr.s_net;
- }
- satosat( &ro->ro_dst )->sat_addr.s_node = sat->sat_addr.s_node;
- rtalloc( ro );
- }
-
- /*
- * Make sure any route that we have has a valid interface.
- */
- aa = 0;
- if ( ro->ro_rt && ( ifp = ro->ro_rt->rt_ifp )) {
- for ( aa = at_ifaddr; aa; aa = aa->aa_next ) {
- if ( aa->aa_ifp == ifp ) {
- break;
- }
- }
- }
- if ( aa == 0 ) {
- return( ENETUNREACH );
- }
-
- ddp->ddp_fsat = *sat;
- if ( ddp->ddp_lsat.sat_port == ATADDR_ANYPORT ) {
- return(at_pcbsetaddr(ddp, (struct sockaddr *)0, p));
- }
- return( 0 );
-}
-
-static void
-at_pcbdisconnect( struct ddpcb *ddp )
-{
- ddp->ddp_fsat.sat_addr.s_net = ATADDR_ANYNET;
- ddp->ddp_fsat.sat_addr.s_node = ATADDR_ANYNODE;
- ddp->ddp_fsat.sat_port = ATADDR_ANYPORT;
-}
-
-static int
-at_pcballoc( struct socket *so )
-{
- struct ddpcb *ddp;
-
- MALLOC(ddp, struct ddpcb *, sizeof *ddp, M_PCB, M_WAITOK);
- bzero(ddp, sizeof *ddp);
- ddp->ddp_lsat.sat_port = ATADDR_ANYPORT;
-
- ddp->ddp_next = ddpcb;
- ddp->ddp_prev = NULL;
- ddp->ddp_pprev = NULL;
- ddp->ddp_pnext = NULL;
- if (ddpcb) {
- ddpcb->ddp_prev = ddp;
- }
- ddpcb = ddp;
-
- ddp->ddp_socket = so;
- so->so_pcb = (caddr_t)ddp;
- return(0);
-}
-
-static void
-at_pcbdetach( struct socket *so, struct ddpcb *ddp)
-{
- soisdisconnected( so );
- so->so_pcb = 0;
- sofree( so );
-
- /* remove ddp from ddp_ports list */
- if ( ddp->ddp_lsat.sat_port != ATADDR_ANYPORT &&
- ddp_ports[ ddp->ddp_lsat.sat_port - 1 ] != NULL ) {
- if ( ddp->ddp_pprev != NULL ) {
- ddp->ddp_pprev->ddp_pnext = ddp->ddp_pnext;
- } else {
- ddp_ports[ ddp->ddp_lsat.sat_port - 1 ] = ddp->ddp_pnext;
- }
- if ( ddp->ddp_pnext != NULL ) {
- ddp->ddp_pnext->ddp_pprev = ddp->ddp_pprev;
- }
- }
-
- if ( ddp->ddp_route.ro_rt ) {
- rtfree( ddp->ddp_route.ro_rt );
- }
-
- if ( ddp->ddp_prev ) {
- ddp->ddp_prev->ddp_next = ddp->ddp_next;
- } else {
- ddpcb = ddp->ddp_next;
- }
- if ( ddp->ddp_next ) {
- ddp->ddp_next->ddp_prev = ddp->ddp_prev;
- }
- FREE(ddp, M_PCB);
-}
-
-/*
- * For the moment, this just find the pcb with the correct local address.
- * In the future, this will actually do some real searching, so we can use
- * the sender's address to do de-multiplexing on a single port to many
- * sockets (pcbs).
- */
-struct ddpcb *
-ddp_search( struct sockaddr_at *from, struct sockaddr_at *to,
- struct at_ifaddr *aa)
-{
- struct ddpcb *ddp;
-
- /*
- * Check for bad ports.
- */
- if ( to->sat_port < ATPORT_FIRST || to->sat_port >= ATPORT_LAST ) {
- return( NULL );
- }
-
- /*
- * Make sure the local address matches the sent address. What about
- * the interface?
- */
- for ( ddp = ddp_ports[ to->sat_port - 1 ]; ddp; ddp = ddp->ddp_pnext ) {
- /* XXX should we handle 0.YY? */
-
- /* XXXX.YY to socket on destination interface */
- if ( to->sat_addr.s_net == ddp->ddp_lsat.sat_addr.s_net &&
- to->sat_addr.s_node == ddp->ddp_lsat.sat_addr.s_node ) {
- break;
- }
-
- /* 0.255 to socket on receiving interface */
- if ( to->sat_addr.s_node == ATADDR_BCAST && ( to->sat_addr.s_net == 0 ||
- to->sat_addr.s_net == ddp->ddp_lsat.sat_addr.s_net ) &&
- ddp->ddp_lsat.sat_addr.s_net == AA_SAT( aa )->sat_addr.s_net ) {
- break;
- }
-
- /* XXXX.0 to socket on destination interface */
- if ( to->sat_addr.s_net == aa->aa_firstnet &&
- to->sat_addr.s_node == 0 &&
- ntohs( ddp->ddp_lsat.sat_addr.s_net ) >=
- ntohs( aa->aa_firstnet ) &&
- ntohs( ddp->ddp_lsat.sat_addr.s_net ) <=
- ntohs( aa->aa_lastnet )) {
- break;
- }
- }
- return( ddp );
-}
-static int
-at_setpeeraddr(struct socket *so, struct sockaddr **nam)
-{
- return(EOPNOTSUPP);
-}
-
-static int
-at_setsockaddr(struct socket *so, struct sockaddr **nam)
-{
- struct ddpcb *ddp;
-
- ddp = sotoddpcb( so );
- if ( ddp == NULL ) {
- return( EINVAL);
- }
- at_sockaddr( ddp, nam );
- return(0);
-}
-
-
-void
-ddp_init(void )
-{
- atintrq1.ifq_maxlen = IFQ_MAXLEN;
- atintrq2.ifq_maxlen = IFQ_MAXLEN;
-}
-
-#if 0
-static void
-ddp_clean(void )
-{
- struct ddpcb *ddp;
-
- for ( ddp = ddpcb; ddp; ddp = ddp->ddp_next ) {
- at_pcbdetach( ddp->ddp_socket, ddp );
- }
-}
-#endif
-
-struct pr_usrreqs ddp_usrreqs = {
- ddp_abort,
- pru_accept_notsupp,
- ddp_attach,
- ddp_bind,
- ddp_connect,
- pru_connect2_notsupp,
- at_control,
- ddp_detach,
- ddp_disconnect,
- pru_listen_notsupp,
- at_setpeeraddr,
- pru_rcvd_notsupp,
- pru_rcvoob_notsupp,
- ddp_send,
- pru_sense_null,
- ddp_shutdown,
- at_setsockaddr,
- sosend,
- soreceive,
- sopoll
-};
diff --git a/sys/netinet/libalias/HISTORY b/sys/netinet/libalias/HISTORY
deleted file mode 100644
index 575d1b4aa13d..000000000000
--- a/sys/netinet/libalias/HISTORY
+++ /dev/null
@@ -1,134 +0,0 @@
-Version 1.0: August 11, 1996 (cjm)
-
-Version 1.1: August 20, 1996 (cjm)
- - Host accepts incoming connections for ports 0 to 1023.
-
-Version 1.2: September 7, 1996 (cjm)
- - Fragment handling error in alias_db.c corrected.
-
-Version 1.3: September 15, 1996 (cjm)
- - Generalized mechanism for handling incoming
- connections (no more 0 to 1023 restriction).
-
- - Increased ICMP support (will handle traceroute now).
-
- - Improved TCP close connection logic.
-
-Version 1.4: September 16, 1996 (cjm)
-
-Version 1.5: September 17, 1996 (cjm)
- - Corrected error in handling incoming UDP packets
- with zero checksum.
-
-Version 1.6: September 18, 1996
- - Simplified ICMP data storage. Will now handle
- tracert from Win95 and NT as well as FreeBSD
- traceroute, which uses UDP packets to non-existent
- ports.
-
-Verstion 1.7: January 9, 1997 (cjm)
- - Reduced malloc() activity for ICMP echo and
- timestamp requests.
-
- - Added handling for out-of-order IP fragments.
-
- - Switched to differential checksum computation
- for IP headers (TCP, UDP and ICMP checksums
- were already differential).
-
- - Accepts FTP data connections from other than
- port 20. This allows one ftp connections
- from two hosts which are both running packet
- aliasing.
-
- - Checksum error on FTP transfers. Problem
- in code located by Martin Renters and
- Brian Somers.
-
-Version 1.8: January 14, 1997 (cjm)
- - Fixed data type error in function StartPoint()
- in alias_db.c (this bug did not exist before v1.7)
- Problem in code located by Ari Suutari.
-
-Version 1.9: February 1, 1997 (Eivind Eklund <perhaps@yes.no>)
- - Added support for IRC DCC (ee)
-
- - Changed the aliasing routines to use ANSI style
- throughout (ee)
-
- - Minor API changes for integration with other
- programs than PPP (ee)
-
- - Fixed minor security hole in alias_ftp.c for
- other applications of the aliasing software.
- Hole could _not_ manifest in ppp+pktAlias, but
- could potentially manifest in other applications
- of the aliasing. (ee)
-
- - Connections initiated from packet aliasing
- host machine will not have their port number
- aliased unless it conflicts with an aliasing
- port already being used. (There is an option
- to disable this for debugging) (cjm)
-
- - Sockets will be allocated in cases where
- there might be port interference with the
- host machine. This can be disabled in cases
- where the ppp host will be acting purely as a
- masquerading router and not generate any
- traffic of its own.
- (cjm)
-
-Version 2.0: March, 1997 (cjm)
- - Aliasing links are cleared only when a host interface address
- changes.
-
- - PacketAliasPermanentLink() API added.
-
- - Option for only aliasing private, unregistered
- IP addresses added.
-
- - Substantial rework to the aliasing lookup engine.
-
-Version 2.1: May, 1997 (cjm)
- - Continuing rework to the aliasing lookup engine
- to support multiple incoming addresses and static
- NAT. PacketAliasRedirectPort() and
- PacketAliasRedirectAddr() added to API.
-
- - Now supports outgoing as well as incoming ICMP
- error messges.
-
-Version 2.2: July, 1997 (cjm)
- - Rationalized API function names to all begin with
- "PacketAlias..." Old function names are retained
- for backwards compatitibility.
-
- - Packet aliasing engine will now free memory of
- fragments which are never resolved after a timeout
- period. Once a fragment is resolved, it becomes
- the users responsibility to free the memory.
-
-Version 2.3: August 11, 1997 (cjm)
- - Problem associated with socket file descriptor
- accumulation in alias_db.c corrected. The sockets
- had to be closed when a binding failed. Problem
- in code located by Gordon Burditt.
-
-Version 2.4: September 1, 1997 (cjm)
- - PKT_ALIAS_UNREGISTERED_ONLY option repaired.
- This part of the code was incorrectly re-implemented
- in version 2.1.
-
-Version 2.5: December, 1997 (ee)
- - Added PKT_ALIAS_PUNCH_FW mode for firewall
- bypass of FTP/IRC DCC data connections. Also added
- improved TCP connection monitoring.
-
-Version 2.6: May, 1998 (amurai)
- - Added supporting routine for NetBios over TCP/IP.
-
-Version 3.0: January 1, 1999
- - Transparent proxying support added.
- - PPTP redirecting support added based on patches
- contributed by Dru Nelson <dnelson@redwoodsoft.com>.
diff --git a/sys/netinet/libalias/Makefile b/sys/netinet/libalias/Makefile
deleted file mode 100644
index 05411f574d44..000000000000
--- a/sys/netinet/libalias/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-# $FreeBSD$
-
-LIB= alias
-SHLIB_MAJOR= 3
-SHLIB_MINOR= 0
-CFLAGS+= -Wall -I${.CURDIR}
-SRCS= alias.c alias_cuseeme.c alias_db.c alias_ftp.c alias_irc.c \
- alias_nbt.c alias_proxy.c alias_util.c
-INCS= alias.h
-MAN3= libalias.3
-
-.include <bsd.lib.mk>
diff --git a/sys/netinet/libalias/alias.c b/sys/netinet/libalias/alias.c
deleted file mode 100644
index 9c072dfcfa20..000000000000
--- a/sys/netinet/libalias/alias.c
+++ /dev/null
@@ -1,1335 +0,0 @@
-/* -*- mode: c; tab-width: 8; c-basic-indent: 4; -*- */
-/*
- Alias.c provides supervisory control for the functions of the
- packet aliasing software. It consists of routines to monitor
- TCP connection state, protocol-specific aliasing routines,
- fragment handling and the following outside world functional
- interfaces: SaveFragmentPtr, GetFragmentPtr, FragmentAliasIn,
- PacketAliasIn and PacketAliasOut.
-
- The other C program files are briefly described. The data
- structure framework which holds information needed to translate
- packets is encapsulated in alias_db.c. Data is accessed by
- function calls, so other segments of the program need not know
- about the underlying data structures. Alias_ftp.c contains
- special code for modifying the ftp PORT command used to establish
- data connections, while alias_irc.c do the same for IRC
- DCC. Alias_util.c contains a few utility routines.
-
- This software is placed into the public domain with no restrictions
- on its distribution.
-
- Version 1.0 August, 1996 (cjm)
-
- Version 1.1 August 20, 1996 (cjm)
- PPP host accepts incoming connections for ports 0 to 1023.
- (Gary Roberts pointed out the need to handle incoming
- connections.)
-
- Version 1.2 September 7, 1996 (cjm)
- Fragment handling error in alias_db.c corrected.
- (Tom Torrance helped fix this problem.)
-
- Version 1.4 September 16, 1996 (cjm)
- - A more generalized method for handling incoming
- connections, without the 0-1023 restriction, is
- implemented in alias_db.c
- - Improved ICMP support in alias.c. Traceroute
- packet streams can now be correctly aliased.
- - TCP connection closing logic simplified in
- alias.c and now allows for additional 1 minute
- "grace period" after FIN or RST is observed.
-
- Version 1.5 September 17, 1996 (cjm)
- Corrected error in handling incoming UDP packets with 0 checksum.
- (Tom Torrance helped fix this problem.)
-
- Version 1.6 September 18, 1996 (cjm)
- Simplified ICMP aliasing scheme. Should now support
- traceroute from Win95 as well as FreeBSD.
-
- Version 1.7 January 9, 1997 (cjm)
- - Out-of-order fragment handling.
- - IP checksum error fixed for ftp transfers
- from aliasing host.
- - Integer return codes added to all
- aliasing/de-aliasing functions.
- - Some obsolete comments cleaned up.
- - Differential checksum computations for
- IP header (TCP, UDP and ICMP were already
- differential).
-
- Version 2.1 May 1997 (cjm)
- - Added support for outgoing ICMP error
- messages.
- - Added two functions PacketAliasIn2()
- and PacketAliasOut2() for dynamic address
- control (e.g. round-robin allocation of
- incoming packets).
-
- Version 2.2 July 1997 (cjm)
- - Rationalized API function names to begin
- with "PacketAlias..."
- - Eliminated PacketAliasIn2() and
- PacketAliasOut2() as poorly conceived.
-
- Version 2.3 Dec 1998 (dillon)
- - Major bounds checking additions, see FreeBSD/CVS
-
- See HISTORY file for additional revisions.
-
- $FreeBSD$
-*/
-
-#include <stdio.h>
-#include <unistd.h>
-
-#include <sys/param.h>
-#include <sys/types.h>
-
-#include <netinet/in_systm.h>
-#include <netinet/in.h>
-#include <netinet/ip.h>
-#include <netinet/ip_icmp.h>
-#include <netinet/tcp.h>
-#include <netinet/udp.h>
-
-#ifndef IPPROTO_GRE
-#define IPPROTO_GRE 47
-#define IPPROTO_ESP 50
-#define IPPROTO_AH 51
-#endif
-
-#include "alias_local.h"
-#include "alias.h"
-
-#define NETBIOS_NS_PORT_NUMBER 137
-#define NETBIOS_DGM_PORT_NUMBER 138
-#define FTP_CONTROL_PORT_NUMBER 21
-#define IRC_CONTROL_PORT_NUMBER_1 6667
-#define IRC_CONTROL_PORT_NUMBER_2 6668
-#define CUSEEME_PORT_NUMBER 7648
-
-
-
-
-/* TCP Handling Routines
-
- TcpMonitorIn() -- These routines monitor TCP connections, and
- TcpMonitorOut() delete a link when a connection is closed.
-
-These routines look for SYN, FIN and RST flags to determine when TCP
-connections open and close. When a TCP connection closes, the data
-structure containing packet aliasing information is deleted after
-a timeout period.
-*/
-
-/* Local prototypes */
-static void TcpMonitorIn(struct ip *, struct alias_link *);
-
-static void TcpMonitorOut(struct ip *, struct alias_link *);
-
-
-static void
-TcpMonitorIn(struct ip *pip, struct alias_link *link)
-{
- struct tcphdr *tc;
-
- tc = (struct tcphdr *) ((char *) pip + (pip->ip_hl << 2));
-
- switch (GetStateIn(link))
- {
- case ALIAS_TCP_STATE_NOT_CONNECTED:
- if (tc->th_flags & TH_RST)
- SetStateIn(link, ALIAS_TCP_STATE_DISCONNECTED);
- else if (tc->th_flags & TH_SYN)
- SetStateIn(link, ALIAS_TCP_STATE_CONNECTED);
- break;
- case ALIAS_TCP_STATE_CONNECTED:
- if (tc->th_flags & (TH_FIN | TH_RST))
- SetStateIn(link, ALIAS_TCP_STATE_DISCONNECTED);
- break;
- }
-}
-
-static void
-TcpMonitorOut(struct ip *pip, struct alias_link *link)
-{
- struct tcphdr *tc;
-
- tc = (struct tcphdr *) ((char *) pip + (pip->ip_hl << 2));
-
- switch (GetStateOut(link))
- {
- case ALIAS_TCP_STATE_NOT_CONNECTED:
- if (tc->th_flags & TH_RST)
- SetStateOut(link, ALIAS_TCP_STATE_DISCONNECTED);
- else if (tc->th_flags & TH_SYN)
- SetStateOut(link, ALIAS_TCP_STATE_CONNECTED);
- break;
- case ALIAS_TCP_STATE_CONNECTED:
- if (tc->th_flags & (TH_FIN | TH_RST))
- SetStateOut(link, ALIAS_TCP_STATE_DISCONNECTED);
- break;
- }
-}
-
-
-
-
-
-/* Protocol Specific Packet Aliasing Routines
-
- IcmpAliasIn(), IcmpAliasIn1(), IcmpAliasIn2(), IcmpAliasIn3()
- IcmpAliasOut(), IcmpAliasOut1(), IcmpAliasOut2(), IcmpAliasOut3()
- UdpAliasIn(), UdpAliasOut()
- TcpAliasIn(), TcpAliasOut()
-
-These routines handle protocol specific details of packet aliasing.
-One may observe a certain amount of repetitive arithmetic in these
-functions, the purpose of which is to compute a revised checksum
-without actually summing over the entire data packet, which could be
-unnecessarily time consuming.
-
-The purpose of the packet aliasing routines is to replace the source
-address of the outgoing packet and then correctly put it back for
-any incoming packets. For TCP and UDP, ports are also re-mapped.
-
-For ICMP echo/timestamp requests and replies, the following scheme
-is used: the id number is replaced by an alias for the outgoing
-packet.
-
-ICMP error messages are handled by looking at the IP fragment
-in the data section of the message.
-
-For TCP and UDP protocols, a port number is chosen for an outgoing
-packet, and then incoming packets are identified by IP address and
-port numbers. For TCP packets, there is additional logic in the event
-that sequence and ack numbers have been altered (as is the case for
-FTP data port commands).
-
-The port numbers used by the packet aliasing module are not true
-ports in the Unix sense. No sockets are actually bound to ports.
-They are more correctly thought of as placeholders.
-
-All packets go through the aliasing mechanism, whether they come from
-the gateway machine or other machines on a local area network.
-*/
-
-
-/* Local prototypes */
-static int IcmpAliasIn1(struct ip *);
-static int IcmpAliasIn2(struct ip *);
-static int IcmpAliasIn3(struct ip *);
-static int IcmpAliasIn (struct ip *);
-
-static int IcmpAliasOut1(struct ip *);
-static int IcmpAliasOut2(struct ip *);
-static int IcmpAliasOut3(struct ip *);
-static int IcmpAliasOut (struct ip *);
-
-static int UdpAliasOut(struct ip *);
-static int UdpAliasIn (struct ip *);
-
-static int TcpAliasOut(struct ip *, int);
-static int TcpAliasIn (struct ip *);
-
-
-static int
-IcmpAliasIn1(struct ip *pip)
-{
-/*
- De-alias incoming echo and timestamp replies
-*/
- struct alias_link *link;
- struct icmp *ic;
-
- ic = (struct icmp *) ((char *) pip + (pip->ip_hl << 2));
-
-/* Get source address from ICMP data field and restore original data */
- link = FindIcmpIn(pip->ip_src, pip->ip_dst, ic->icmp_id);
- if (link != NULL)
- {
- u_short original_id;
- int accumulate;
-
- original_id = GetOriginalPort(link);
-
-/* Adjust ICMP checksum */
- accumulate = ic->icmp_id;
- accumulate -= original_id;
- ADJUST_CHECKSUM(accumulate, ic->icmp_cksum)
-
-/* Put original sequence number back in */
- ic->icmp_id = original_id;
-
-/* Put original address back into IP header */
- {
- struct in_addr original_address;
-
- original_address = GetOriginalAddress(link);
- DifferentialChecksum(&pip->ip_sum,
- (u_short *) &original_address,
- (u_short *) &pip->ip_dst,
- 2);
- pip->ip_dst = original_address;
- }
-
- return(PKT_ALIAS_OK);
- }
- return(PKT_ALIAS_IGNORED);
-}
-
-static int
-IcmpAliasIn2(struct ip *pip)
-{
-/*
- Alias incoming ICMP error messages containing
- IP header and first 64 bits of datagram.
-*/
- struct ip *ip;
- struct icmp *ic, *ic2;
- struct udphdr *ud;
- struct tcphdr *tc;
- struct alias_link *link;
-
- ic = (struct icmp *) ((char *) pip + (pip->ip_hl << 2));
- ip = (struct ip *) ic->icmp_data;
-
- ud = (struct udphdr *) ((char *) ip + (ip->ip_hl <<2));
- tc = (struct tcphdr *) ud;
- ic2 = (struct icmp *) ud;
-
- if (ip->ip_p == IPPROTO_UDP)
- link = FindUdpTcpIn(ip->ip_dst, ip->ip_src,
- ud->uh_dport, ud->uh_sport,
- IPPROTO_UDP);
- else if (ip->ip_p == IPPROTO_TCP)
- link = FindUdpTcpIn(ip->ip_dst, ip->ip_src,
- tc->th_dport, tc->th_sport,
- IPPROTO_TCP);
- else if (ip->ip_p == IPPROTO_ICMP) {
- if (ic2->icmp_type == ICMP_ECHO || ic2->icmp_type == ICMP_TSTAMP)
- link = FindIcmpIn(ip->ip_dst, ip->ip_src, ic2->icmp_id);
- else
- link = NULL;
- } else
- link = NULL;
-
- if (link != NULL)
- {
- if (ip->ip_p == IPPROTO_UDP || ip->ip_p == IPPROTO_TCP)
- {
- u_short *sptr;
- int accumulate;
- struct in_addr original_address;
- u_short original_port;
-
- original_address = GetOriginalAddress(link);
- original_port = GetOriginalPort(link);
-
-/* Adjust ICMP checksum */
- sptr = (u_short *) &(ip->ip_src);
- accumulate = *sptr++;
- accumulate += *sptr;
- sptr = (u_short *) &original_address;
- accumulate -= *sptr++;
- accumulate -= *sptr;
- accumulate += ud->uh_sport;
- accumulate -= original_port;
- ADJUST_CHECKSUM(accumulate, ic->icmp_cksum)
-
-/* Un-alias address in IP header */
- DifferentialChecksum(&pip->ip_sum,
- (u_short *) &original_address,
- (u_short *) &pip->ip_dst,
- 2);
- pip->ip_dst = original_address;
-
-/* Un-alias address and port number of original IP packet
-fragment contained in ICMP data section */
- ip->ip_src = original_address;
- ud->uh_sport = original_port;
- }
- else if (pip->ip_p == IPPROTO_ICMP)
- {
- u_short *sptr;
- int accumulate;
- struct in_addr original_address;
- u_short original_id;
-
- original_address = GetOriginalAddress(link);
- original_id = GetOriginalPort(link);
-
-/* Adjust ICMP checksum */
- sptr = (u_short *) &(ip->ip_src);
- accumulate = *sptr++;
- accumulate += *sptr;
- sptr = (u_short *) &original_address;
- accumulate -= *sptr++;
- accumulate -= *sptr;
- accumulate += ic2->icmp_id;
- accumulate -= original_id;
- ADJUST_CHECKSUM(accumulate, ic->icmp_cksum)
-
-/* Un-alias address in IP header */
- DifferentialChecksum(&pip->ip_sum,
- (u_short *) &original_address,
- (u_short *) &pip->ip_dst,
- 2);
- pip->ip_dst = original_address;
-
-/* Un-alias address of original IP packet and seqence number of
- embedded icmp datagram */
- ip->ip_src = original_address;
- ic2->icmp_id = original_id;
- }
- return(PKT_ALIAS_OK);
- }
- return(PKT_ALIAS_IGNORED);
-}
-
-static int
-IcmpAliasIn3(struct ip *pip)
-{
- struct in_addr original_address;
-
- original_address = FindOriginalAddress(pip->ip_dst);
- DifferentialChecksum(&pip->ip_sum,
- (u_short *) &original_address,
- (u_short *) &pip->ip_dst,
- 2);
- pip->ip_dst = original_address;
-
- return PKT_ALIAS_OK;
-}
-
-
-static int
-IcmpAliasIn(struct ip *pip)
-{
- int iresult;
- struct icmp *ic;
-
-/* Return if proxy-only mode is enabled */
- if (packetAliasMode & PKT_ALIAS_PROXY_ONLY)
- return PKT_ALIAS_OK;
-
- ic = (struct icmp *) ((char *) pip + (pip->ip_hl << 2));
-
- iresult = PKT_ALIAS_IGNORED;
- switch (ic->icmp_type)
- {
- case ICMP_ECHOREPLY:
- case ICMP_TSTAMPREPLY:
- if (ic->icmp_code == 0)
- {
- iresult = IcmpAliasIn1(pip);
- }
- break;
- case ICMP_UNREACH:
- case ICMP_SOURCEQUENCH:
- case ICMP_TIMXCEED:
- case ICMP_PARAMPROB:
- iresult = IcmpAliasIn2(pip);
- break;
- case ICMP_ECHO:
- case ICMP_TSTAMP:
- iresult = IcmpAliasIn3(pip);
- break;
- }
- return(iresult);
-}
-
-
-static int
-IcmpAliasOut1(struct ip *pip)
-{
-/*
- Alias ICMP echo and timestamp packets
-*/
- struct alias_link *link;
- struct icmp *ic;
-
- ic = (struct icmp *) ((char *) pip + (pip->ip_hl << 2));
-
-/* Save overwritten data for when echo packet returns */
- link = FindIcmpOut(pip->ip_src, pip->ip_dst, ic->icmp_id);
- if (link != NULL)
- {
- u_short alias_id;
- int accumulate;
-
- alias_id = GetAliasPort(link);
-
-/* Since data field is being modified, adjust ICMP checksum */
- accumulate = ic->icmp_id;
- accumulate -= alias_id;
- ADJUST_CHECKSUM(accumulate, ic->icmp_cksum)
-
-/* Alias sequence number */
- ic->icmp_id = alias_id;
-
-/* Change source address */
- {
- struct in_addr alias_address;
-
- alias_address = GetAliasAddress(link);
- DifferentialChecksum(&pip->ip_sum,
- (u_short *) &alias_address,
- (u_short *) &pip->ip_src,
- 2);
- pip->ip_src = alias_address;
- }
-
- return(PKT_ALIAS_OK);
- }
- return(PKT_ALIAS_IGNORED);
-}
-
-
-static int
-IcmpAliasOut2(struct ip *pip)
-{
-/*
- Alias outgoing ICMP error messages containing
- IP header and first 64 bits of datagram.
-*/
- struct in_addr alias_addr;
- struct ip *ip;
- struct icmp *ic;
-
- ic = (struct icmp *) ((char *) pip + (pip->ip_hl << 2));
- ip = (struct ip *) ic->icmp_data;
-
- alias_addr = FindAliasAddress(ip->ip_src);
-
-/* Alias destination address in IP fragment */
- DifferentialChecksum(&ic->icmp_cksum,
- (u_short *) &alias_addr,
- (u_short *) &ip->ip_dst,
- 2);
- ip->ip_dst = alias_addr;
-
-/* alias source address in IP header */
- DifferentialChecksum(&pip->ip_sum,
- (u_short *) &alias_addr,
- (u_short *) &pip->ip_src,
- 2);
- pip->ip_src = alias_addr;
-
- return PKT_ALIAS_OK;
-}
-
-
-static int
-IcmpAliasOut3(struct ip *pip)
-{
-/*
- Handle outgoing echo and timestamp replies. The
- only thing which is done in this case is to alias
- the source IP address of the packet.
-*/
- struct in_addr alias_addr;
-
- alias_addr = FindAliasAddress(pip->ip_src);
- DifferentialChecksum(&pip->ip_sum,
- (u_short *) &alias_addr,
- (u_short *) &pip->ip_src,
- 2);
- pip->ip_src = alias_addr;
-
- return PKT_ALIAS_OK;
-}
-
-
-static int
-IcmpAliasOut(struct ip *pip)
-{
- int iresult;
- struct icmp *ic;
-
-/* Return if proxy-only mode is enabled */
- if (packetAliasMode & PKT_ALIAS_PROXY_ONLY)
- return PKT_ALIAS_OK;
-
- ic = (struct icmp *) ((char *) pip + (pip->ip_hl << 2));
-
- iresult = PKT_ALIAS_IGNORED;
- switch (ic->icmp_type)
- {
- case ICMP_ECHO:
- case ICMP_TSTAMP:
- if (ic->icmp_code == 0)
- {
- iresult = IcmpAliasOut1(pip);
- }
- break;
- case ICMP_UNREACH:
- case ICMP_SOURCEQUENCH:
- case ICMP_TIMXCEED:
- case ICMP_PARAMPROB:
- iresult = IcmpAliasOut2(pip);
- break;
- case ICMP_ECHOREPLY:
- case ICMP_TSTAMPREPLY:
- iresult = IcmpAliasOut3(pip);
- }
- return(iresult);
-}
-
-
-
-static int
-PptpAliasIn(struct ip *pip)
-{
-/*
- Handle incoming PPTP packets. The
- only thing which is done in this case is to alias
- the dest IP address of the packet to our inside
- machine.
-*/
- struct in_addr alias_addr;
-
- if (!GetPptpAlias (&alias_addr))
- return PKT_ALIAS_IGNORED;
-
- if (pip->ip_src.s_addr != alias_addr.s_addr) {
-
- DifferentialChecksum(&pip->ip_sum,
- (u_short *) &alias_addr,
- (u_short *) &pip->ip_dst,
- 2);
- pip->ip_dst = alias_addr;
- }
-
- return PKT_ALIAS_OK;
-}
-
-
-static int
-PptpAliasOut(struct ip *pip)
-{
-/*
- Handle outgoing PPTP packets. The
- only thing which is done in this case is to alias
- the source IP address of the packet.
-*/
- struct in_addr alias_addr;
-
- if (!GetPptpAlias (&alias_addr))
- return PKT_ALIAS_IGNORED;
-
- if (pip->ip_src.s_addr == alias_addr.s_addr) {
-
- alias_addr = FindAliasAddress(pip->ip_src);
- DifferentialChecksum(&pip->ip_sum,
- (u_short *) &alias_addr,
- (u_short *) &pip->ip_src,
- 2);
- pip->ip_src = alias_addr;
- }
-
- return PKT_ALIAS_OK;
-}
-
-
-
-static int
-UdpAliasIn(struct ip *pip)
-{
- struct udphdr *ud;
- struct alias_link *link;
-
-/* Return if proxy-only mode is enabled */
- if (packetAliasMode & PKT_ALIAS_PROXY_ONLY)
- return PKT_ALIAS_OK;
-
- ud = (struct udphdr *) ((char *) pip + (pip->ip_hl << 2));
-
- link = FindUdpTcpIn(pip->ip_src, pip->ip_dst,
- ud->uh_sport, ud->uh_dport,
- IPPROTO_UDP);
- if (link != NULL)
- {
- struct in_addr alias_address;
- struct in_addr original_address;
- u_short alias_port;
- int accumulate;
- u_short *sptr;
- int r = 0;
-
- alias_address = GetAliasAddress(link);
- original_address = GetOriginalAddress(link);
- alias_port = ud->uh_dport;
- ud->uh_dport = GetOriginalPort(link);
-
-/* If NETBIOS Datagram, It should be alias address in UDP Data, too */
- if (ntohs(ud->uh_dport) == NETBIOS_DGM_PORT_NUMBER
- || ntohs(ud->uh_sport) == NETBIOS_DGM_PORT_NUMBER )
- {
- r = AliasHandleUdpNbt(pip, link, &original_address, ud->uh_dport);
- } else if (ntohs(ud->uh_dport) == NETBIOS_NS_PORT_NUMBER
- || ntohs(ud->uh_sport) == NETBIOS_NS_PORT_NUMBER )
- {
- r = AliasHandleUdpNbtNS(pip, link,
- &alias_address,
- &alias_port,
- &original_address,
- &ud->uh_dport );
- }
-
- if (ntohs(ud->uh_dport) == CUSEEME_PORT_NUMBER)
- AliasHandleCUSeeMeIn(pip, original_address);
-
-/* If UDP checksum is not zero, then adjust since destination port */
-/* is being unaliased and destination port is being altered. */
- if (ud->uh_sum != 0)
- {
- accumulate = alias_port;
- accumulate -= ud->uh_dport;
- sptr = (u_short *) &alias_address;
- accumulate += *sptr++;
- accumulate += *sptr;
- sptr = (u_short *) &original_address;
- accumulate -= *sptr++;
- accumulate -= *sptr;
- ADJUST_CHECKSUM(accumulate, ud->uh_sum)
- }
-
-/* Restore original IP address */
- DifferentialChecksum(&pip->ip_sum,
- (u_short *) &original_address,
- (u_short *) &pip->ip_dst,
- 2);
- pip->ip_dst = original_address;
-
- /*
- * If we cannot figure out the packet, ignore it.
- */
- if (r < 0)
- return(PKT_ALIAS_IGNORED);
- else
- return(PKT_ALIAS_OK);
- }
- return(PKT_ALIAS_IGNORED);
-}
-
-static int
-UdpAliasOut(struct ip *pip)
-{
- struct udphdr *ud;
- struct alias_link *link;
-
-/* Return if proxy-only mode is enabled */
- if (packetAliasMode & PKT_ALIAS_PROXY_ONLY)
- return PKT_ALIAS_OK;
-
- ud = (struct udphdr *) ((char *) pip + (pip->ip_hl << 2));
-
- link = FindUdpTcpOut(pip->ip_src, pip->ip_dst,
- ud->uh_sport, ud->uh_dport,
- IPPROTO_UDP);
- if (link != NULL)
- {
- u_short alias_port;
- struct in_addr alias_address;
-
- alias_address = GetAliasAddress(link);
- alias_port = GetAliasPort(link);
-
- if (ntohs(ud->uh_dport) == CUSEEME_PORT_NUMBER)
- AliasHandleCUSeeMeOut(pip, link);
-
-/* If NETBIOS Datagram, It should be alias address in UDP Data, too */
- if (ntohs(ud->uh_dport) == NETBIOS_DGM_PORT_NUMBER
- || ntohs(ud->uh_sport) == NETBIOS_DGM_PORT_NUMBER )
- {
- AliasHandleUdpNbt(pip, link, &alias_address, alias_port);
- } else if (ntohs(ud->uh_dport) == NETBIOS_NS_PORT_NUMBER
- || ntohs(ud->uh_sport) == NETBIOS_NS_PORT_NUMBER )
- {
- AliasHandleUdpNbtNS(pip, link,
- &pip->ip_src,
- &ud->uh_sport,
- &alias_address,
- &alias_port);
- }
-
-/* If UDP checksum is not zero, adjust since source port is */
-/* being aliased and source address is being altered */
- if (ud->uh_sum != 0)
- {
- int accumulate;
- u_short *sptr;
-
- accumulate = ud->uh_sport;
- accumulate -= alias_port;
- sptr = (u_short *) &(pip->ip_src);
- accumulate += *sptr++;
- accumulate += *sptr;
- sptr = (u_short *) &alias_address;
- accumulate -= *sptr++;
- accumulate -= *sptr;
- ADJUST_CHECKSUM(accumulate, ud->uh_sum)
- }
-
-/* Put alias port in UDP header */
- ud->uh_sport = alias_port;
-
-/* Change source address */
- DifferentialChecksum(&pip->ip_sum,
- (u_short *) &alias_address,
- (u_short *) &pip->ip_src,
- 2);
- pip->ip_src = alias_address;
-
- return(PKT_ALIAS_OK);
- }
- return(PKT_ALIAS_IGNORED);
-}
-
-
-
-static int
-TcpAliasIn(struct ip *pip)
-{
- struct tcphdr *tc;
- struct alias_link *link;
-
- tc = (struct tcphdr *) ((char *) pip + (pip->ip_hl << 2));
-
- link = FindUdpTcpIn(pip->ip_src, pip->ip_dst,
- tc->th_sport, tc->th_dport,
- IPPROTO_TCP);
- if (link != NULL)
- {
- struct in_addr alias_address;
- struct in_addr original_address;
- struct in_addr proxy_address;
- u_short alias_port;
- u_short proxy_port;
- int accumulate;
- u_short *sptr;
-
- alias_address = GetAliasAddress(link);
- original_address = GetOriginalAddress(link);
- proxy_address = GetProxyAddress(link);
- alias_port = tc->th_dport;
- tc->th_dport = GetOriginalPort(link);
- proxy_port = GetProxyPort(link);
-
-/* Adjust TCP checksum since destination port is being unaliased */
-/* and destination port is being altered. */
- accumulate = alias_port;
- accumulate -= tc->th_dport;
- sptr = (u_short *) &alias_address;
- accumulate += *sptr++;
- accumulate += *sptr;
- sptr = (u_short *) &original_address;
- accumulate -= *sptr++;
- accumulate -= *sptr;
-
-/* If this is a proxy, then modify the tcp source port and
- checksum accumulation */
- if (proxy_port != 0)
- {
- accumulate += tc->th_sport;
- tc->th_sport = proxy_port;
- accumulate -= tc->th_sport;
-
- sptr = (u_short *) &pip->ip_src;
- accumulate += *sptr++;
- accumulate += *sptr;
- sptr = (u_short *) &proxy_address;
- accumulate -= *sptr++;
- accumulate -= *sptr;
- }
-
-/* See if ack number needs to be modified */
- if (GetAckModified(link) == 1)
- {
- int delta;
-
- delta = GetDeltaAckIn(pip, link);
- if (delta != 0)
- {
- sptr = (u_short *) &tc->th_ack;
- accumulate += *sptr++;
- accumulate += *sptr;
- tc->th_ack = htonl(ntohl(tc->th_ack) - delta);
- sptr = (u_short *) &tc->th_ack;
- accumulate -= *sptr++;
- accumulate -= *sptr;
- }
- }
-
- ADJUST_CHECKSUM(accumulate, tc->th_sum);
-
-/* Restore original IP address */
- sptr = (u_short *) &pip->ip_dst;
- accumulate = *sptr++;
- accumulate += *sptr;
- pip->ip_dst = original_address;
- sptr = (u_short *) &pip->ip_dst;
- accumulate -= *sptr++;
- accumulate -= *sptr;
-
-/* If this is a transparent proxy packet, then modify the source
- address */
- if (proxy_address.s_addr != 0)
- {
- sptr = (u_short *) &pip->ip_src;
- accumulate += *sptr++;
- accumulate += *sptr;
- pip->ip_src = proxy_address;
- sptr = (u_short *) &pip->ip_src;
- accumulate -= *sptr++;
- accumulate -= *sptr;
- }
-
- ADJUST_CHECKSUM(accumulate, pip->ip_sum);
-
-/* Monitor TCP connection state */
- TcpMonitorIn(pip, link);
-
- return(PKT_ALIAS_OK);
- }
- return(PKT_ALIAS_IGNORED);
-}
-
-static int
-TcpAliasOut(struct ip *pip, int maxpacketsize)
-{
- int proxy_type;
- u_short dest_port;
- u_short proxy_server_port;
- struct in_addr dest_address;
- struct in_addr proxy_server_address;
- struct tcphdr *tc;
- struct alias_link *link;
-
- tc = (struct tcphdr *) ((char *) pip + (pip->ip_hl << 2));
-
- proxy_type = ProxyCheck(pip, &proxy_server_address, &proxy_server_port);
-
- if (proxy_type == 0 && (packetAliasMode & PKT_ALIAS_PROXY_ONLY))
- return PKT_ALIAS_OK;
-
-/* If this is a transparent proxy, save original destination,
- then alter the destination and adust checksums */
- dest_port = tc->th_dport;
- dest_address = pip->ip_dst;
- if (proxy_type != 0)
- {
- int accumulate;
- u_short *sptr;
-
- accumulate = tc->th_dport;
- tc->th_dport = proxy_server_port;
- accumulate -= tc->th_dport;
-
- sptr = (u_short *) &(pip->ip_dst);
- accumulate += *sptr++;
- accumulate += *sptr;
- sptr = (u_short *) &proxy_server_address;
- accumulate -= *sptr++;
- accumulate -= *sptr;
-
- ADJUST_CHECKSUM(accumulate, tc->th_sum);
-
- sptr = (u_short *) &(pip->ip_dst);
- accumulate = *sptr++;
- accumulate += *sptr;
- pip->ip_dst = proxy_server_address;
- sptr = (u_short *) &(pip->ip_dst);
- accumulate -= *sptr++;
- accumulate -= *sptr;
-
- ADJUST_CHECKSUM(accumulate, pip->ip_sum);
- }
-
- link = FindUdpTcpOut(pip->ip_src, pip->ip_dst,
- tc->th_sport, tc->th_dport,
- IPPROTO_TCP);
- if (link !=NULL)
- {
- u_short alias_port;
- struct in_addr alias_address;
- int accumulate;
- u_short *sptr;
-
-/* Save original destination address, if this is a proxy packet.
- Also modify packet to include destination encoding. */
- if (proxy_type != 0)
- {
- SetProxyPort(link, dest_port);
- SetProxyAddress(link, dest_address);
- ProxyModify(link, pip, maxpacketsize, proxy_type);
- }
-
-/* Get alias address and port */
- alias_port = GetAliasPort(link);
- alias_address = GetAliasAddress(link);
-
-/* Monitor tcp connection state */
- TcpMonitorOut(pip, link);
-
-/* Special processing for IP encoding protocols */
- if (ntohs(tc->th_dport) == FTP_CONTROL_PORT_NUMBER
- || ntohs(tc->th_sport) == FTP_CONTROL_PORT_NUMBER)
- AliasHandleFtpOut(pip, link, maxpacketsize);
- if (ntohs(tc->th_dport) == IRC_CONTROL_PORT_NUMBER_1
- || ntohs(tc->th_dport) == IRC_CONTROL_PORT_NUMBER_2)
- AliasHandleIrcOut(pip, link, maxpacketsize);
-
-/* Adjust TCP checksum since source port is being aliased */
-/* and source address is being altered */
- accumulate = tc->th_sport;
- tc->th_sport = alias_port;
- accumulate -= tc->th_sport;
-
- sptr = (u_short *) &(pip->ip_src);
- accumulate += *sptr++;
- accumulate += *sptr;
- sptr = (u_short *) &alias_address;
- accumulate -= *sptr++;
- accumulate -= *sptr;
-
-/* Modify sequence number if necessary */
- if (GetAckModified(link) == 1)
- {
- int delta;
-
- delta = GetDeltaSeqOut(pip, link);
- if (delta != 0)
- {
- sptr = (u_short *) &tc->th_seq;
- accumulate += *sptr++;
- accumulate += *sptr;
- tc->th_seq = htonl(ntohl(tc->th_seq) + delta);
- sptr = (u_short *) &tc->th_seq;
- accumulate -= *sptr++;
- accumulate -= *sptr;
- }
- }
-
- ADJUST_CHECKSUM(accumulate, tc->th_sum)
-
-/* Change source address */
- sptr = (u_short *) &(pip->ip_src);
- accumulate = *sptr++;
- accumulate += *sptr;
- pip->ip_src = alias_address;
- sptr = (u_short *) &(pip->ip_src);
- accumulate -= *sptr++;
- accumulate -= *sptr;
-
- ADJUST_CHECKSUM(accumulate, pip->ip_sum)
-
- return(PKT_ALIAS_OK);
- }
- return(PKT_ALIAS_IGNORED);
-}
-
-
-
-
-/* Fragment Handling
-
- FragmentIn()
- FragmentOut()
-
-The packet aliasing module has a limited ability for handling IP
-fragments. If the ICMP, TCP or UDP header is in the first fragment
-received, then the id number of the IP packet is saved, and other
-fragments are identified according to their ID number and IP address
-they were sent from. Pointers to unresolved fragments can also be
-saved and recalled when a header fragment is seen.
-*/
-
-/* Local prototypes */
-static int FragmentIn(struct ip *);
-static int FragmentOut(struct ip *);
-
-
-static int
-FragmentIn(struct ip *pip)
-{
- struct alias_link *link;
-
- link = FindFragmentIn2(pip->ip_src, pip->ip_dst, pip->ip_id);
- if (link != NULL)
- {
- struct in_addr original_address;
-
- GetFragmentAddr(link, &original_address);
- DifferentialChecksum(&pip->ip_sum,
- (u_short *) &original_address,
- (u_short *) &pip->ip_dst,
- 2);
- pip->ip_dst = original_address;
-
- return(PKT_ALIAS_OK);
- }
- return(PKT_ALIAS_UNRESOLVED_FRAGMENT);
-}
-
-
-static int
-FragmentOut(struct ip *pip)
-{
- struct in_addr alias_address;
-
- alias_address = FindAliasAddress(pip->ip_src);
- DifferentialChecksum(&pip->ip_sum,
- (u_short *) &alias_address,
- (u_short *) &pip->ip_src,
- 2);
- pip->ip_src = alias_address;
-
- return(PKT_ALIAS_OK);
-}
-
-
-
-
-
-
-/* Outside World Access
-
- PacketAliasSaveFragment()
- PacketAliasGetFragment()
- PacketAliasFragmentIn()
- PacketAliasIn()
- PacketAliasOut()
-
-(prototypes in alias.h)
-*/
-
-
-int
-PacketAliasSaveFragment(char *ptr)
-{
- int iresult;
- struct alias_link *link;
- struct ip *pip;
-
- pip = (struct ip *) ptr;
- link = AddFragmentPtrLink(pip->ip_src, pip->ip_id);
- iresult = PKT_ALIAS_ERROR;
- if (link != NULL)
- {
- SetFragmentPtr(link, ptr);
- iresult = PKT_ALIAS_OK;
- }
- return(iresult);
-}
-
-
-char *
-PacketAliasGetFragment(char *ptr)
-{
- struct alias_link *link;
- char *fptr;
- struct ip *pip;
-
- pip = (struct ip *) ptr;
- link = FindFragmentPtr(pip->ip_src, pip->ip_id);
- if (link != NULL)
- {
- GetFragmentPtr(link, &fptr);
- SetFragmentPtr(link, NULL);
- SetExpire(link, 0); /* Deletes link */
-
- return(fptr);
- }
- else
- {
- return(NULL);
- }
-}
-
-
-void
-PacketAliasFragmentIn(char *ptr, /* Points to correctly de-aliased
- header fragment */
- char *ptr_fragment /* Points to fragment which must
- be de-aliased */
- )
-{
- struct ip *pip;
- struct ip *fpip;
-
- pip = (struct ip *) ptr;
- fpip = (struct ip *) ptr_fragment;
-
- DifferentialChecksum(&fpip->ip_sum,
- (u_short *) &pip->ip_dst,
- (u_short *) &fpip->ip_dst,
- 2);
- fpip->ip_dst = pip->ip_dst;
-}
-
-
-int
-PacketAliasIn(char *ptr, int maxpacketsize)
-{
- struct in_addr alias_addr;
- struct ip *pip;
- int iresult;
-
- if (packetAliasMode & PKT_ALIAS_REVERSE) {
- packetAliasMode &= ~PKT_ALIAS_REVERSE;
- iresult = PacketAliasOut(ptr, maxpacketsize);
- packetAliasMode |= PKT_ALIAS_REVERSE;
- return iresult;
- }
-
- HouseKeeping();
- ClearCheckNewLink();
- pip = (struct ip *) ptr;
- alias_addr = pip->ip_dst;
-
- /* Defense against mangled packets */
- if (ntohs(pip->ip_len) > maxpacketsize
- || (pip->ip_hl<<2) > maxpacketsize)
- return PKT_ALIAS_IGNORED;
-
- iresult = PKT_ALIAS_IGNORED;
- if ( (ntohs(pip->ip_off) & IP_OFFMASK) == 0 )
- {
- switch (pip->ip_p)
- {
- case IPPROTO_ICMP:
- iresult = IcmpAliasIn(pip);
- break;
- case IPPROTO_UDP:
- iresult = UdpAliasIn(pip);
- break;
- case IPPROTO_TCP:
- iresult = TcpAliasIn(pip);
- break;
- case IPPROTO_GRE:
- case IPPROTO_ESP:
- case IPPROTO_AH:
- iresult = PptpAliasIn(pip);
- break;
- }
-
- if (ntohs(pip->ip_off) & IP_MF)
- {
- struct alias_link *link;
-
- link = FindFragmentIn1(pip->ip_src, alias_addr, pip->ip_id);
- if (link != NULL)
- {
- iresult = PKT_ALIAS_FOUND_HEADER_FRAGMENT;
- SetFragmentAddr(link, pip->ip_dst);
- }
- else
- {
- iresult = PKT_ALIAS_ERROR;
- }
- }
- }
- else
- {
- iresult = FragmentIn(pip);
- }
-
- return(iresult);
-}
-
-
-
-/* Unregistered address ranges */
-
-/* 10.0.0.0 -> 10.255.255.255 */
-#define UNREG_ADDR_A_LOWER 0x0a000000
-#define UNREG_ADDR_A_UPPER 0x0affffff
-
-/* 172.16.0.0 -> 172.31.255.255 */
-#define UNREG_ADDR_B_LOWER 0xac100000
-#define UNREG_ADDR_B_UPPER 0xac1fffff
-
-/* 192.168.0.0 -> 192.168.255.255 */
-#define UNREG_ADDR_C_LOWER 0xc0a80000
-#define UNREG_ADDR_C_UPPER 0xc0a8ffff
-
-int
-PacketAliasOut(char *ptr, /* valid IP packet */
- int maxpacketsize /* How much the packet data may grow
- (FTP and IRC inline changes) */
- )
-{
- int iresult;
- struct in_addr addr_save;
- struct ip *pip;
-
- if (packetAliasMode & PKT_ALIAS_REVERSE) {
- packetAliasMode &= ~PKT_ALIAS_REVERSE;
- iresult = PacketAliasIn(ptr, maxpacketsize);
- packetAliasMode |= PKT_ALIAS_REVERSE;
- return iresult;
- }
-
- HouseKeeping();
- ClearCheckNewLink();
- pip = (struct ip *) ptr;
-
- /* Defense against mangled packets */
- if (ntohs(pip->ip_len) > maxpacketsize
- || (pip->ip_hl<<2) > maxpacketsize)
- return PKT_ALIAS_IGNORED;
-
- addr_save = GetDefaultAliasAddress();
- if (packetAliasMode & PKT_ALIAS_UNREGISTERED_ONLY)
- {
- unsigned int addr;
- int iclass;
-
- iclass = 0;
- addr = ntohl(pip->ip_src.s_addr);
- if (addr >= UNREG_ADDR_C_LOWER && addr <= UNREG_ADDR_C_UPPER)
- iclass = 3;
- else if (addr >= UNREG_ADDR_B_LOWER && addr <= UNREG_ADDR_B_UPPER)
- iclass = 2;
- else if (addr >= UNREG_ADDR_A_LOWER && addr <= UNREG_ADDR_A_UPPER)
- iclass = 1;
-
- if (iclass == 0)
- {
- SetDefaultAliasAddress(pip->ip_src);
- }
- }
-
- iresult = PKT_ALIAS_IGNORED;
- if ((ntohs(pip->ip_off) & IP_OFFMASK) == 0)
- {
- switch (pip->ip_p)
- {
- case IPPROTO_ICMP:
- iresult = IcmpAliasOut(pip);
- break;
- case IPPROTO_UDP:
- iresult = UdpAliasOut(pip);
- break;
- case IPPROTO_TCP:
- iresult = TcpAliasOut(pip, maxpacketsize);
- break;
- case IPPROTO_GRE:
- case IPPROTO_ESP:
- case IPPROTO_AH:
- iresult = PptpAliasOut(pip);
- break;
- }
- }
- else
- {
- iresult = FragmentOut(pip);
- }
-
- SetDefaultAliasAddress(addr_save);
- return(iresult);
-}
diff --git a/sys/netinet/libalias/alias.h b/sys/netinet/libalias/alias.h
deleted file mode 100644
index 063f1bcfc843..000000000000
--- a/sys/netinet/libalias/alias.h
+++ /dev/null
@@ -1,166 +0,0 @@
-/*lint -save -library Flexelint comment for external headers */
-
-/*
- Alias.h defines the outside world interfaces for the packet
- aliasing software.
-
- This software is placed into the public domain with no restrictions
- on its distribution.
-
- $FreeBSD$
-*/
-
-
-#ifndef _ALIAS_H_
-#define _ALIAS_H_
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-/* Alias link representative (incomplete struct) */
-struct alias_link;
-
-/* External interfaces (API) to packet aliasing engine */
-
-/* Initialization and Control */
- extern void
- PacketAliasInit(void);
-
- extern void
- PacketAliasUninit(void);
-
- extern void
- PacketAliasSetAddress(struct in_addr);
-
- extern unsigned int
- PacketAliasSetMode(unsigned int, unsigned int);
-
-#ifndef NO_FW_PUNCH
- extern void
- PacketAliasSetFWBase(unsigned int, unsigned int);
-#endif
-
-/* Packet Handling */
- extern int
- PacketAliasIn(char *, int maxpacketsize);
-
- extern int
- PacketAliasOut(char *, int maxpacketsize);
-
-/* Port and Address Redirection */
- extern struct alias_link *
- PacketAliasRedirectPort(struct in_addr, u_short,
- struct in_addr, u_short,
- struct in_addr, u_short,
- u_char);
-
- extern int
- PacketAliasPptp(struct in_addr);
-
-
- extern struct alias_link *
- PacketAliasRedirectAddr(struct in_addr,
- struct in_addr);
-
- extern void
- PacketAliasRedirectDelete(struct alias_link *);
-
-/* Fragment Handling */
- extern int
- PacketAliasSaveFragment(char *);
-
- extern char *
- PacketAliasGetFragment(char *);
-
- extern void
- PacketAliasFragmentIn(char *, char *);
-
-/* Miscellaneous Functions */
- extern void
- PacketAliasSetTarget(struct in_addr addr);
-
- extern int
- PacketAliasCheckNewLink(void);
-
- extern u_short
- PacketAliasInternetChecksum(u_short *, int);
-
-/* Transparent Proxying */
- extern int
- PacketAliasProxyRule(const char *);
-
-
-/********************** Mode flags ********************/
-/* Set these flags using SetPacketAliasMode() */
-
-/* If PKT_ALIAS_LOG is set, a message will be printed to
- /var/log/alias.log every time a link is created or deleted. This
- is useful for debugging */
-#define PKT_ALIAS_LOG 0x01
-
-/* If PKT_ALIAS_DENY_INCOMING is set, then incoming connections (e.g.
- to ftp, telnet or web servers will be prevented by the aliasing
- mechanism. */
-#define PKT_ALIAS_DENY_INCOMING 0x02
-
-/* If PKT_ALIAS_SAME_PORTS is set, packets will be attempted sent from
- the same port as they originated on. This allows eg rsh to work
- *99% of the time*, but _not_ 100%. (It will be slightly flakey
- instead of not working at all.) This mode bit is set by
- PacketAliasInit(), so it is a default mode of operation. */
-#define PKT_ALIAS_SAME_PORTS 0x04
-
-/* If PKT_ALIAS_USE_SOCKETS is set, then when partially specified
- links (e.g. destination port and/or address is zero), the packet
- aliasing engine will attempt to allocate a socket for the aliasing
- port it chooses. This will avoid interference with the host
- machine. Fully specified links do not require this. This bit
- is set after a call to PacketAliasInit(), so it is a default
- mode of operation.*/
-#define PKT_ALIAS_USE_SOCKETS 0x08
-
-/* If PKT_ALIAS_UNREGISTERED_ONLY is set, then only packets with with
- unregistered source addresses will be aliased (along with those
- of the ppp host maching itself. Private addresses are those
- in the following ranges:
- 10.0.0.0 -> 10.255.255.255
- 172.16.0.0 -> 172.31.255.255
- 192.168.0.0 -> 192.168.255.255 */
-#define PKT_ALIAS_UNREGISTERED_ONLY 0x10
-
-/* If PKT_ALIAS_RESET_ON_ADDR_CHANGE is set, then the table of dynamic
- aliasing links will be reset whenever PacketAliasSetAddress()
- changes the default aliasing address. If the default aliasing
- address is left unchanged by this functions call, then the
- table of dynamic aliasing links will be left intact. This
- bit is set after a call to PacketAliasInit(). */
-#define PKT_ALIAS_RESET_ON_ADDR_CHANGE 0x20
-
-#ifndef NO_FW_PUNCH
-/* If PKT_ALIAS_PUNCH_FW is set, active FTP and IRC DCC connections
- will create a 'hole' in the firewall to allow the transfers to
- work. Where (IPFW "line-numbers") the hole is created is
- controlled by PacketAliasSetFWBase(base, size). The hole will be
- attached to that particular alias_link, so when the link goes away
- so do the hole. */
-#define PKT_ALIAS_PUNCH_FW 0x100
-#endif
-
-/* If PKT_ALIAS_PROXY_ONLY is set, then NAT will be disabled and only
- transparent proxying performed */
-#define PKT_ALIAS_PROXY_ONLY 0x40
-
-/* If PKT_ALIAS_REVERSE is set, the actions of PacketAliasIn()
- and PacketAliasOut() are reversed */
-#define PKT_ALIAS_REVERSE 0x80
-
-/* Return Codes */
-#define PKT_ALIAS_ERROR -1
-#define PKT_ALIAS_OK 1
-#define PKT_ALIAS_IGNORED 2
-#define PKT_ALIAS_UNRESOLVED_FRAGMENT 3
-#define PKT_ALIAS_FOUND_HEADER_FRAGMENT 4
-
-#endif
-/*lint -restore */
diff --git a/sys/netinet/libalias/alias_cuseeme.c b/sys/netinet/libalias/alias_cuseeme.c
deleted file mode 100644
index b1b95f49e0d4..000000000000
--- a/sys/netinet/libalias/alias_cuseeme.c
+++ /dev/null
@@ -1,120 +0,0 @@
-/*-
- * Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
- * with the aid of code written by
- * Junichi SATOH <junichi@astec.co.jp> 1996, 1997.
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/types.h>
-#include <netinet/in_systm.h>
-#include <netinet/in.h>
-#include <netinet/ip.h>
-#include <netinet/udp.h>
-
-#include "alias_local.h"
-
-/* CU-SeeMe Data Header */
-struct cu_header {
- u_int16_t dest_family;
- u_int16_t dest_port;
- u_int32_t dest_addr;
- int16_t family;
- u_int16_t port;
- u_int32_t addr;
- u_int32_t seq;
- u_int16_t msg;
- u_int16_t data_type;
- u_int16_t packet_len;
-};
-
-/* Open Continue Header */
-struct oc_header {
- u_int16_t client_count; /* Number of client info structs */
- u_int32_t seq_no;
- char user_name[20];
- char reserved[4]; /* flags, version stuff, etc */
-};
-
-/* client info structures */
-struct client_info {
- u_int32_t address; /* Client address */
- char reserved[8]; /* Flags, pruning bitfield, packet counts etc */
-};
-
-void
-AliasHandleCUSeeMeOut(struct ip *pip, struct alias_link *link)
-{
- struct udphdr *ud;
-
- ud = (struct udphdr *)((char *)pip + (pip->ip_hl << 2));
- if(ud->uh_ulen >= sizeof(struct cu_header)) {
- struct cu_header *cu;
- struct alias_link *cu_link;
-
- cu = (struct cu_header *)(ud + 1);
- if (cu->addr)
- cu->addr = (u_int32_t)GetAliasAddress(link).s_addr;
-
- cu_link = FindUdpTcpOut(pip->ip_src, GetDestAddress(link),
- ud->uh_dport, 0, IPPROTO_UDP);
-
-#ifndef NO_FW_PUNCH
- if (cu_link)
- PunchFWHole(cu_link);
-#endif
- }
-}
-
-void
-AliasHandleCUSeeMeIn(struct ip *pip, struct in_addr original_addr)
-{
- struct in_addr alias_addr;
- struct udphdr *ud;
- struct cu_header *cu;
- struct oc_header *oc;
- struct client_info *ci;
- char *end;
- int i;
-
- alias_addr.s_addr = pip->ip_dst.s_addr;
- ud = (struct udphdr *)((char *)pip + (pip->ip_hl << 2));
- cu = (struct cu_header *)(ud + 1);
- oc = (struct oc_header *)(cu + 1);
- ci = (struct client_info *)(oc + 1);
- end = (char *)cu + ud->uh_ulen;
-
- if ((char *)oc <= end) {
- if(cu->dest_addr)
- cu->dest_addr = (u_int32_t)original_addr.s_addr;
- if(ntohs(cu->data_type) == 101)
- /* Find and change our address */
- for(i = 0; (char *)(ci + 1) <= end && i < oc->client_count; i++, ci++)
- if(ci->address == (u_int32_t)alias_addr.s_addr) {
- ci->address = (u_int32_t)original_addr.s_addr;
- break;
- }
- }
-}
diff --git a/sys/netinet/libalias/alias_db.c b/sys/netinet/libalias/alias_db.c
deleted file mode 100644
index 618162cf37e1..000000000000
--- a/sys/netinet/libalias/alias_db.c
+++ /dev/null
@@ -1,2394 +0,0 @@
-/* -*- mode: c; tab-width: 8; c-basic-indent: 4; -*-
- Alias_db.c encapsulates all data structures used for storing
- packet aliasing data. Other parts of the aliasing software
- access data through functions provided in this file.
-
- Data storage is based on the notion of a "link", which is
- established for ICMP echo/reply packets, UDP datagrams and
- TCP stream connections. A link stores the original source
- and destination addresses. For UDP and TCP, it also stores
- source and destination port numbers, as well as an alias
- port number. Links are also used to store information about
- fragments.
-
- There is a facility for sweeping through and deleting old
- links as new packets are sent through. A simple timeout is
- used for ICMP and UDP links. TCP links are left alone unless
- there is an incomplete connection, in which case the link
- can be deleted after a certain amount of time.
-
-
- This software is placed into the public domain with no restrictions
- on its distribution.
-
- Initial version: August, 1996 (cjm)
-
- Version 1.4: September 16, 1996 (cjm)
- Facility for handling incoming links added.
-
- Version 1.6: September 18, 1996 (cjm)
- ICMP data handling simplified.
-
- Version 1.7: January 9, 1997 (cjm)
- Fragment handling simplified.
- Saves pointers for unresolved fragments.
- Permits links for unspecied remote ports
- or unspecified remote addresses.
- Fixed bug which did not properly zero port
- table entries after a link was deleted.
- Cleaned up some obsolete comments.
-
- Version 1.8: January 14, 1997 (cjm)
- Fixed data type error in StartPoint().
- (This error did not exist prior to v1.7
- and was discovered and fixed by Ari Suutari)
-
- Version 1.9: February 1, 1997
- Optionally, connections initiated from packet aliasing host
- machine will will not have their port number aliased unless it
- conflicts with an aliasing port already being used. (cjm)
-
- All options earlier being #ifdef'ed now are available through
- a new interface, SetPacketAliasMode(). This allow run time
- control (which is now available in PPP+pktAlias through the
- 'alias' keyword). (ee)
-
- Added ability to create an alias port without
- either destination address or port specified.
- port type = ALIAS_PORT_UNKNOWN_DEST_ALL (ee)
-
- Removed K&R style function headers
- and general cleanup. (ee)
-
- Added packetAliasMode to replace compiler #defines's (ee)
-
- Allocates sockets for partially specified
- ports if ALIAS_USE_SOCKETS defined. (cjm)
-
- Version 2.0: March, 1997
- SetAliasAddress() will now clean up alias links
- if the aliasing address is changed. (cjm)
-
- PacketAliasPermanentLink() function added to support permanent
- links. (J. Fortes suggested the need for this.)
- Examples:
-
- (192.168.0.1, port 23) <-> alias port 6002, unknown dest addr/port
-
- (192.168.0.2, port 21) <-> alias port 3604, known dest addr
- unknown dest port
-
- These permament links allow for incoming connections to
- machines on the local network. They can be given with a
- user-chosen amount of specificity, with increasing specificity
- meaning more security. (cjm)
-
- Quite a bit of rework to the basic engine. The portTable[]
- array, which kept track of which ports were in use was replaced
- by a table/linked list structure. (cjm)
-
- SetExpire() function added. (cjm)
-
- DeleteLink() no longer frees memory association with a pointer
- to a fragment (this bug was first recognized by E. Eklund in
- v1.9).
-
- Version 2.1: May, 1997 (cjm)
- Packet aliasing engine reworked so that it can handle
- multiple external addresses rather than just a single
- host address.
-
- PacketAliasRedirectPort() and PacketAliasRedirectAddr()
- added to the API. The first function is a more generalized
- version of PacketAliasPermanentLink(). The second function
- implements static network address translation.
-
- See HISTORY file for additional revisions.
-
- $FreeBSD$
-*/
-
-
-/* System include files */
-#include <errno.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <sys/types.h>
-
-/* BSD network include files */
-#include <netinet/in_systm.h>
-#include <netinet/in.h>
-#include <netinet/ip.h>
-#include <netinet/tcp.h>
-#include <arpa/inet.h>
-
-#include "alias.h"
-#include "alias_local.h"
-
-
-
-/*
- Constants (note: constants are also defined
- near relevant functions or structs)
-*/
-
-/* Sizes of input and output link tables */
-#define LINK_TABLE_OUT_SIZE 101
-#define LINK_TABLE_IN_SIZE 4001
-
-/* Parameters used for cleanup of expired links */
-#define ALIAS_CLEANUP_INTERVAL_SECS 60
-#define ALIAS_CLEANUP_MAX_SPOKES 30
-
-/* Timeouts (in seconds) for different link types */
-#define ICMP_EXPIRE_TIME 60
-#define UDP_EXPIRE_TIME 60
-#define FRAGMENT_ID_EXPIRE_TIME 10
-#define FRAGMENT_PTR_EXPIRE_TIME 30
-
-/* TCP link expire time for different cases */
-/* When the link has been used and closed - minimal grace time to
- allow ACKs and potential re-connect in FTP (XXX - is this allowed?) */
-#ifndef TCP_EXPIRE_DEAD
-# define TCP_EXPIRE_DEAD 10
-#endif
-
-/* When the link has been used and closed on one side - the other side
- is allowed to still send data */
-#ifndef TCP_EXPIRE_SINGLEDEAD
-# define TCP_EXPIRE_SINGLEDEAD 90
-#endif
-
-/* When the link isn't yet up */
-#ifndef TCP_EXPIRE_INITIAL
-# define TCP_EXPIRE_INITIAL 300
-#endif
-
-/* When the link is up */
-#ifndef TCP_EXPIRE_CONNECTED
-# define TCP_EXPIRE_CONNECTED 86400
-#endif
-
-
-/* Dummy port number codes used for FindLinkIn/Out() and AddLink().
- These constants can be anything except zero, which indicates an
- unknown port number. */
-
-#define NO_DEST_PORT 1
-#define NO_SRC_PORT 1
-
-
-
-/* Data Structures
-
- The fundamental data structure used in this program is
- "struct alias_link". Whenever a TCP connection is made,
- a UDP datagram is sent out, or an ICMP echo request is made,
- a link record is made (if it has not already been created).
- The link record is identified by the source address/port
- and the destination address/port. In the case of an ICMP
- echo request, the source port is treated as being equivalent
- with the 16-bit id number of the ICMP packet.
-
- The link record also can store some auxiliary data. For
- TCP connections that have had sequence and acknowledgment
- modifications, data space is available to track these changes.
- A state field is used to keep track in changes to the tcp
- connection state. Id numbers of fragments can also be
- stored in the auxiliary space. Pointers to unresolved
- framgents can also be stored.
-
- The link records support two independent chainings. Lookup
- tables for input and out tables hold the initial pointers
- the link chains. On input, the lookup table indexes on alias
- port and link type. On output, the lookup table indexes on
- source addreess, destination address, source port, destination
- port and link type.
-*/
-
-struct ack_data_record /* used to save changes to ack/seq numbers */
-{
- u_long ack_old;
- u_long ack_new;
- int delta;
- int active;
-};
-
-struct tcp_state /* Information about tcp connection */
-{
- int in; /* State for outside -> inside */
- int out; /* State for inside -> outside */
- int index; /* Index to ack data array */
- int ack_modified; /* Indicates whether ack and seq numbers */
- /* been modified */
-};
-
-#define N_LINK_TCP_DATA 3 /* Number of distinct ack number changes
- saved for a modified TCP stream */
-struct tcp_dat
-{
- struct tcp_state state;
- struct ack_data_record ack[N_LINK_TCP_DATA];
- int fwhole; /* Which firewall record is used for this hole? */
-};
-
-struct alias_link /* Main data structure */
-{
- struct in_addr src_addr; /* Address and port information */
- struct in_addr dst_addr;
- struct in_addr alias_addr;
- struct in_addr proxy_addr;
- u_short src_port;
- u_short dst_port;
- u_short alias_port;
- u_short proxy_port;
-
- int link_type; /* Type of link: tcp, udp, icmp, frag */
-
-/* values for link_type */
-#define LINK_ICMP 1
-#define LINK_UDP 2
-#define LINK_TCP 3
-#define LINK_FRAGMENT_ID 4
-#define LINK_FRAGMENT_PTR 5
-#define LINK_ADDR 6
-
- int flags; /* indicates special characteristics */
-
-/* flag bits */
-#define LINK_UNKNOWN_DEST_PORT 0x01
-#define LINK_UNKNOWN_DEST_ADDR 0x02
-#define LINK_PERMANENT 0x04
-#define LINK_PARTIALLY_SPECIFIED 0x03 /* logical-or of first two bits */
-#define LINK_UNFIREWALLED 0x08
-
- int timestamp; /* Time link was last accessed */
- int expire_time; /* Expire time for link */
-
- int sockfd; /* socket descriptor */
-
- u_int start_point_out; /* Index number in output lookup table */
- u_int start_point_in;
- struct alias_link *next_out; /* Linked list pointers for input and */
- struct alias_link *last_out; /* output tables */
- struct alias_link *next_in; /* . */
- struct alias_link *last_in; /* . */
-
- union /* Auxiliary data */
- {
- char *frag_ptr;
- struct in_addr frag_addr;
- struct tcp_dat *tcp;
- } data;
-};
-
-
-
-
-
-/* Global Variables
-
- The global variables listed here are only accessed from
- within alias_db.c and so are prefixed with the static
- designation.
-*/
-
-int packetAliasMode; /* Mode flags */
- /* - documented in alias.h */
-
-static struct in_addr aliasAddress; /* Address written onto source */
- /* field of IP packet. */
-
-static struct in_addr targetAddress; /* IP address incoming packets */
- /* are sent to if no aliasing */
- /* link already exists */
-
-static struct in_addr nullAddress; /* Used as a dummy parameter for */
- /* some function calls */
-static struct alias_link *
-linkTableOut[LINK_TABLE_OUT_SIZE]; /* Lookup table of pointers to */
- /* chains of link records. Each */
-static struct alias_link * /* link record is doubly indexed */
-linkTableIn[LINK_TABLE_IN_SIZE]; /* into input and output lookup */
- /* tables. */
-
-static int icmpLinkCount; /* Link statistics */
-static int udpLinkCount;
-static int tcpLinkCount;
-static int fragmentIdLinkCount;
-static int fragmentPtrLinkCount;
-static int sockCount;
-
-static int cleanupIndex; /* Index to chain of link table */
- /* being inspected for old links */
-
-static int timeStamp; /* System time in seconds for */
- /* current packet */
-
-static int lastCleanupTime; /* Last time IncrementalCleanup() */
- /* was called */
-
-static int houseKeepingResidual; /* used by HouseKeeping() */
-
-static int deleteAllLinks; /* If equal to zero, DeleteLink() */
- /* will not remove permanent links */
-
-static FILE *monitorFile; /* File descriptor for link */
- /* statistics monitoring file */
-
-static int newDefaultLink; /* Indicates if a new aliasing */
- /* link has been created after a */
- /* call to PacketAliasIn/Out(). */
-
-#ifndef NO_FW_PUNCH
-static int fireWallFD = -1; /* File descriptor to be able to */
- /* control firewall. Opened by */
- /* PacketAliasSetMode on first */
- /* setting the PKT_ALIAS_PUNCH_FW */
- /* flag. */
-#endif
-
-static int pptpAliasFlag; /* Indicates if PPTP aliasing is */
- /* on or off */
-static struct in_addr pptpAliasAddr; /* Address of source of PPTP */
- /* packets. */
-
-
-
-
-
-
-
-/* Internal utility routines (used only in alias_db.c)
-
-Lookup table starting points:
- StartPointIn() -- link table initial search point for
- incoming packets
- StartPointOut() -- port table initial search point for
- outgoing packets
-
-Miscellaneous:
- SeqDiff() -- difference between two TCP sequences
- ShowAliasStats() -- send alias statistics to a monitor file
-*/
-
-
-/* Local prototypes */
-static u_int StartPointIn(struct in_addr, u_short, int);
-
-static u_int StartPointOut(struct in_addr, struct in_addr,
- u_short, u_short, int);
-
-static int SeqDiff(u_long, u_long);
-
-static void ShowAliasStats(void);
-
-#ifndef NO_FW_PUNCH
-/* Firewall control */
-static void InitPunchFW(void);
-static void UninitPunchFW(void);
-static void ClearFWHole(struct alias_link *link);
-#endif
-
-/* Log file control */
-static void InitPacketAliasLog(void);
-static void UninitPacketAliasLog(void);
-
-static u_int
-StartPointIn(struct in_addr alias_addr,
- u_short alias_port,
- int link_type)
-{
- u_int n;
-
- n = alias_addr.s_addr;
- n += alias_port;
- n += link_type;
- return(n % LINK_TABLE_IN_SIZE);
-}
-
-
-static u_int
-StartPointOut(struct in_addr src_addr, struct in_addr dst_addr,
- u_short src_port, u_short dst_port, int link_type)
-{
- u_int n;
-
- n = src_addr.s_addr;
- n += dst_addr.s_addr;
- n += src_port;
- n += dst_port;
- n += link_type;
-
- return(n % LINK_TABLE_OUT_SIZE);
-}
-
-
-static int
-SeqDiff(u_long x, u_long y)
-{
-/* Return the difference between two TCP sequence numbers */
-
-/*
- This function is encapsulated in case there are any unusual
- arithmetic conditions that need to be considered.
-*/
-
- return (ntohl(y) - ntohl(x));
-}
-
-
-static void
-ShowAliasStats(void)
-{
-/* Used for debugging */
-
- if (monitorFile)
- {
- fprintf(monitorFile, "icmp=%d, udp=%d, tcp=%d, frag_id=%d frag_ptr=%d",
- icmpLinkCount,
- udpLinkCount,
- tcpLinkCount,
- fragmentIdLinkCount,
- fragmentPtrLinkCount);
-
- fprintf(monitorFile, " / tot=%d (sock=%d)\n",
- icmpLinkCount + udpLinkCount
- + tcpLinkCount
- + fragmentIdLinkCount
- + fragmentPtrLinkCount,
- sockCount);
-
- fflush(monitorFile);
- }
-}
-
-
-
-
-
-/* Internal routines for finding, deleting and adding links
-
-Port Allocation:
- GetNewPort() -- find and reserve new alias port number
- GetSocket() -- try to allocate a socket for a given port
-
-Link creation and deletion:
- CleanupAliasData() - remove all link chains from lookup table
- IncrementalCleanup() - look for stale links in a single chain
- DeleteLink() - remove link
- AddLink() - add link
- ReLink() - change link
-
-Link search:
- FindLinkOut() - find link for outgoing packets
- FindLinkIn() - find link for incoming packets
-*/
-
-/* Local prototypes */
-static int GetNewPort(struct alias_link *, int);
-
-static u_short GetSocket(u_short, int *, int);
-
-static void CleanupAliasData(void);
-
-static void IncrementalCleanup(void);
-
-static void DeleteLink(struct alias_link *);
-
-static struct alias_link *
-AddLink(struct in_addr, struct in_addr, struct in_addr,
- u_short, u_short, int, int);
-
-static struct alias_link *
-ReLink(struct alias_link *,
- struct in_addr, struct in_addr, struct in_addr,
- u_short, u_short, int, int);
-
-static struct alias_link *
-FindLinkOut(struct in_addr, struct in_addr, u_short, u_short, int, int);
-
-static struct alias_link *
-FindLinkIn(struct in_addr, struct in_addr, u_short, u_short, int, int);
-
-
-#define ALIAS_PORT_BASE 0x08000
-#define ALIAS_PORT_MASK 0x07fff
-#define GET_NEW_PORT_MAX_ATTEMPTS 20
-
-#define GET_ALIAS_PORT -1
-#define GET_ALIAS_ID GET_ALIAS_PORT
-
-/* GetNewPort() allocates port numbers. Note that if a port number
- is already in use, that does not mean that it cannot be used by
- another link concurrently. This is because GetNewPort() looks for
- unused triplets: (dest addr, dest port, alias port). */
-
-static int
-GetNewPort(struct alias_link *link, int alias_port_param)
-{
- int i;
- int max_trials;
- u_short port_sys;
- u_short port_net;
-
-/*
- Description of alias_port_param for GetNewPort(). When
- this parameter is zero or positive, it precisely specifies
- the port number. GetNewPort() will return this number
- without check that it is in use.
-
- Whis this parameter is -1, it indicates to get a randomly
- selected port number.
-*/
-
- if (alias_port_param == GET_ALIAS_PORT)
- {
- /*
- * The aliasing port is automatically selected
- * by one of two methods below:
- */
- max_trials = GET_NEW_PORT_MAX_ATTEMPTS;
-
- if (packetAliasMode & PKT_ALIAS_SAME_PORTS)
- {
- /*
- * When the ALIAS_SAME_PORTS option is
- * chosen, the first try will be the
- * actual source port. If this is already
- * in use, the remainder of the trials
- * will be random.
- */
- port_net = link->src_port;
- port_sys = ntohs(port_net);
- }
- else
- {
- /* First trial and all subsequent are random. */
- port_sys = random() & ALIAS_PORT_MASK;
- port_sys += ALIAS_PORT_BASE;
- port_net = htons(port_sys);
- }
- }
- else if (alias_port_param >= 0 && alias_port_param < 0x10000)
- {
- link->alias_port = (u_short) alias_port_param;
- return(0);
- }
- else
- {
-#ifdef DEBUG
- fprintf(stderr, "PacketAlias/GetNewPort(): ");
- fprintf(stderr, "input parameter error\n");
-#endif
- return(-1);
- }
-
-
-/* Port number search */
- for (i=0; i<max_trials; i++)
- {
- int go_ahead;
- struct alias_link *search_result;
-
- search_result = FindLinkIn(link->dst_addr, link->alias_addr,
- link->dst_port, port_net,
- link->link_type, 0);
-
- if (search_result == NULL)
- go_ahead = 1;
- else if (!(link->flags & LINK_PARTIALLY_SPECIFIED)
- && (search_result->flags & LINK_PARTIALLY_SPECIFIED))
- go_ahead = 1;
- else
- go_ahead = 0;
-
- if (go_ahead)
- {
- if ((packetAliasMode & PKT_ALIAS_USE_SOCKETS)
- && (link->flags & LINK_PARTIALLY_SPECIFIED))
- {
- if (GetSocket(port_net, &link->sockfd, link->link_type))
- {
- link->alias_port = port_net;
- return(0);
- }
- }
- else
- {
- link->alias_port = port_net;
- return(0);
- }
- }
-
- port_sys = random() & ALIAS_PORT_MASK;
- port_sys += ALIAS_PORT_BASE;
- port_net = htons(port_sys);
- }
-
-#ifdef DEBUG
- fprintf(stderr, "PacketAlias/GetnewPort(): ");
- fprintf(stderr, "could not find free port\n");
-#endif
-
- return(-1);
-}
-
-
-static u_short
-GetSocket(u_short port_net, int *sockfd, int link_type)
-{
- int err;
- int sock;
- struct sockaddr_in sock_addr;
-
- if (link_type == LINK_TCP)
- sock = socket(AF_INET, SOCK_STREAM, 0);
- else if (link_type == LINK_UDP)
- sock = socket(AF_INET, SOCK_DGRAM, 0);
- else
- {
-#ifdef DEBUG
- fprintf(stderr, "PacketAlias/GetSocket(): ");
- fprintf(stderr, "incorrect link type\n");
-#endif
- return(0);
- }
-
- if (sock < 0)
- {
-#ifdef DEBUG
- fprintf(stderr, "PacketAlias/GetSocket(): ");
- fprintf(stderr, "socket() error %d\n", *sockfd);
-#endif
- return(0);
- }
-
- sock_addr.sin_family = AF_INET;
- sock_addr.sin_addr.s_addr = htonl(INADDR_ANY);
- sock_addr.sin_port = port_net;
-
- err = bind(sock,
- (struct sockaddr *) &sock_addr,
- sizeof(sock_addr));
- if (err == 0)
- {
- sockCount++;
- *sockfd = sock;
- return(1);
- }
- else
- {
- close(sock);
- return(0);
- }
-}
-
-
-static void
-CleanupAliasData(void)
-{
- struct alias_link *link;
- int i, icount;
-
- icount = 0;
- for (i=0; i<LINK_TABLE_OUT_SIZE; i++)
- {
- link = linkTableOut[i];
- while (link != NULL)
- {
- struct alias_link *link_next;
- link_next = link->next_out;
- icount++;
- DeleteLink(link);
- link = link_next;
- }
- }
-
- cleanupIndex =0;
-}
-
-
-static void
-IncrementalCleanup(void)
-{
- int icount;
- struct alias_link *link;
-
- icount = 0;
- link = linkTableOut[cleanupIndex++];
- while (link != NULL)
- {
- int idelta;
- struct alias_link *link_next;
-
- link_next = link->next_out;
- idelta = timeStamp - link->timestamp;
- switch (link->link_type)
- {
- case LINK_ICMP:
- case LINK_UDP:
- case LINK_FRAGMENT_ID:
- case LINK_FRAGMENT_PTR:
- if (idelta > link->expire_time)
- {
- DeleteLink(link);
- icount++;
- }
- break;
- case LINK_TCP:
- if (idelta > link->expire_time)
- {
- struct tcp_dat *tcp_aux;
-
- tcp_aux = link->data.tcp;
- if (tcp_aux->state.in != ALIAS_TCP_STATE_CONNECTED
- || tcp_aux->state.out != ALIAS_TCP_STATE_CONNECTED)
- {
- DeleteLink(link);
- icount++;
- }
- }
- break;
- }
- link = link_next;
- }
-
- if (cleanupIndex == LINK_TABLE_OUT_SIZE)
- cleanupIndex = 0;
-}
-
-void
-DeleteLink(struct alias_link *link)
-{
- struct alias_link *link_last;
- struct alias_link *link_next;
-
-/* Don't do anything if the link is marked permanent */
- if (deleteAllLinks == 0 && link->flags & LINK_PERMANENT)
- return;
-
-#ifndef NO_FW_PUNCH
-/* Delete associatied firewall hole, if any */
- ClearFWHole(link);
-#endif
-
-/* Adjust output table pointers */
- link_last = link->last_out;
- link_next = link->next_out;
-
- if (link_last != NULL)
- link_last->next_out = link_next;
- else
- linkTableOut[link->start_point_out] = link_next;
-
- if (link_next != NULL)
- link_next->last_out = link_last;
-
-/* Adjust input table pointers */
- link_last = link->last_in;
- link_next = link->next_in;
-
- if (link_last != NULL)
- link_last->next_in = link_next;
- else
- linkTableIn[link->start_point_in] = link_next;
-
- if (link_next != NULL)
- link_next->last_in = link_last;
-
-/* Close socket, if one has been allocated */
- if (link->sockfd != -1)
- {
- sockCount--;
- close(link->sockfd);
- }
-
-/* Link-type dependent cleanup */
- switch(link->link_type)
- {
- case LINK_ICMP:
- icmpLinkCount--;
- break;
- case LINK_UDP:
- udpLinkCount--;
- break;
- case LINK_TCP:
- tcpLinkCount--;
- if (link->data.tcp != NULL)
- free(link->data.tcp);
- break;
- case LINK_FRAGMENT_ID:
- fragmentIdLinkCount--;
- break;
- case LINK_FRAGMENT_PTR:
- fragmentPtrLinkCount--;
- if (link->data.frag_ptr != NULL)
- free(link->data.frag_ptr);
- break;
- }
-
-/* Free memory */
- free(link);
-
-/* Write statistics, if logging enabled */
- if (packetAliasMode & PKT_ALIAS_LOG)
- {
- ShowAliasStats();
- }
-}
-
-
-static struct alias_link *
-AddLink(struct in_addr src_addr,
- struct in_addr dst_addr,
- struct in_addr alias_addr,
- u_short src_port,
- u_short dst_port,
- int alias_port_param, /* if less than zero, alias */
- int link_type) /* port will be automatically */
-{ /* chosen. If greater than */
- u_int start_point; /* zero, equal to alias port */
- struct alias_link *link;
- struct alias_link *first_link;
-
- link = malloc(sizeof(struct alias_link));
- if (link != NULL)
- {
- /* Basic initialization */
- link->src_addr = src_addr;
- link->dst_addr = dst_addr;
- link->alias_addr = alias_addr;
- link->proxy_addr.s_addr = 0;
- link->src_port = src_port;
- link->dst_port = dst_port;
- link->proxy_port = 0;
- link->link_type = link_type;
- link->sockfd = -1;
- link->flags = 0;
- link->timestamp = timeStamp;
-
- /* Expiration time */
- switch (link_type)
- {
- case LINK_ICMP:
- link->expire_time = ICMP_EXPIRE_TIME;
- break;
- case LINK_UDP:
- link->expire_time = UDP_EXPIRE_TIME;
- break;
- case LINK_TCP:
- link->expire_time = TCP_EXPIRE_INITIAL;
- break;
- case LINK_FRAGMENT_ID:
- link->expire_time = FRAGMENT_ID_EXPIRE_TIME;
- break;
- case LINK_FRAGMENT_PTR:
- link->expire_time = FRAGMENT_PTR_EXPIRE_TIME;
- break;
- }
-
- /* Determine alias flags */
- if (dst_addr.s_addr == 0)
- link->flags |= LINK_UNKNOWN_DEST_ADDR;
- if (dst_port == 0)
- link->flags |= LINK_UNKNOWN_DEST_PORT;
-
- /* Determine alias port */
- if (GetNewPort(link, alias_port_param) != 0)
- {
- free(link);
- return(NULL);
- }
-
- /* Set up pointers for output lookup table */
- start_point = StartPointOut(src_addr, dst_addr,
- src_port, dst_port, link_type);
- first_link = linkTableOut[start_point];
-
- link->last_out = NULL;
- link->next_out = first_link;
- link->start_point_out = start_point;
-
- if (first_link != NULL)
- first_link->last_out = link;
-
- linkTableOut[start_point] = link;
-
- /* Set up pointers for input lookup table */
- start_point = StartPointIn(alias_addr, link->alias_port, link_type);
- first_link = linkTableIn[start_point];
-
- link->last_in = NULL;
- link->next_in = first_link;
- link->start_point_in = start_point;
-
- if (first_link != NULL)
- first_link->last_in = link;
-
- linkTableIn[start_point] = link;
-
- /* Link-type dependent initialization */
- switch(link_type)
- {
- struct tcp_dat *aux_tcp;
-
- case LINK_ICMP:
- icmpLinkCount++;
- break;
- case LINK_UDP:
- udpLinkCount++;
- break;
- case LINK_TCP:
- aux_tcp = malloc(sizeof(struct tcp_dat));
- link->data.tcp = aux_tcp;
- if (aux_tcp != NULL)
- {
- int i;
-
- tcpLinkCount++;
- aux_tcp->state.in = ALIAS_TCP_STATE_NOT_CONNECTED;
- aux_tcp->state.out = ALIAS_TCP_STATE_NOT_CONNECTED;
- aux_tcp->state.index = 0;
- aux_tcp->state.ack_modified = 0;
- for (i=0; i<N_LINK_TCP_DATA; i++)
- aux_tcp->ack[i].active = 0;
- aux_tcp->fwhole = -1;
- }
- else
- {
-#ifdef DEBUG
- fprintf(stderr, "PacketAlias/AddLink: ");
- fprintf(stderr, " cannot allocate auxiliary TCP data\n");
-#endif
- }
- break;
- case LINK_FRAGMENT_ID:
- fragmentIdLinkCount++;
- break;
- case LINK_FRAGMENT_PTR:
- fragmentPtrLinkCount++;
- break;
- }
- }
- else
- {
-#ifdef DEBUG
- fprintf(stderr, "PacketAlias/AddLink(): ");
- fprintf(stderr, "malloc() call failed.\n");
-#endif
- }
-
- if (packetAliasMode & PKT_ALIAS_LOG)
- {
- ShowAliasStats();
- }
-
- return(link);
-}
-
-static struct alias_link *
-ReLink(struct alias_link *old_link,
- struct in_addr src_addr,
- struct in_addr dst_addr,
- struct in_addr alias_addr,
- u_short src_port,
- u_short dst_port,
- int alias_port_param, /* if less than zero, alias */
- int link_type) /* port will be automatically */
-{ /* chosen. If greater than */
- struct alias_link *new_link; /* zero, equal to alias port */
-
- new_link = AddLink(src_addr, dst_addr, alias_addr,
- src_port, dst_port, alias_port_param,
- link_type);
-#ifndef NO_FW_PUNCH
- if (new_link != NULL &&
- old_link->link_type == LINK_TCP &&
- old_link->data.tcp &&
- old_link->data.tcp->fwhole > 0) {
- PunchFWHole(new_link);
- }
-#endif
- DeleteLink(old_link);
- return new_link;
-}
-
-static struct alias_link *
-_FindLinkOut(struct in_addr src_addr,
- struct in_addr dst_addr,
- u_short src_port,
- u_short dst_port,
- int link_type,
- int replace_partial_links)
-{
- u_int i;
- struct alias_link *link;
-
- i = StartPointOut(src_addr, dst_addr, src_port, dst_port, link_type);
- link = linkTableOut[i];
- while (link != NULL)
- {
- if (link->src_addr.s_addr == src_addr.s_addr
- && link->dst_addr.s_addr == dst_addr.s_addr
- && link->dst_port == dst_port
- && link->src_port == src_port
- && link->link_type == link_type)
- {
- link->timestamp = timeStamp;
- break;
- }
- link = link->next_out;
- }
-
-/* Search for partially specified links. */
- if (link == NULL)
- {
- if (dst_port != 0)
- {
- link = _FindLinkOut(src_addr, dst_addr, src_port, 0,
- link_type, 0);
- if (link != NULL && replace_partial_links)
- {
- link = ReLink(link,
- src_addr, dst_addr, link->alias_addr,
- src_port, dst_port, link->alias_port,
- link_type);
- }
- }
- else if (dst_addr.s_addr != 0)
- {
- link = _FindLinkOut(src_addr, nullAddress, src_port, 0,
- link_type, 0);
- }
- }
-
- return(link);
-}
-
-static struct alias_link *
-FindLinkOut(struct in_addr src_addr,
- struct in_addr dst_addr,
- u_short src_port,
- u_short dst_port,
- int link_type,
- int replace_partial_links)
-{
- struct alias_link *link;
-
- link = _FindLinkOut(src_addr, dst_addr, src_port, dst_port,
- link_type, replace_partial_links);
-
- if (link == NULL)
- {
- /* The following allows permanent links to be
- specified as using the default source address
- (i.e. device interface address) without knowing
- in advance what that address is. */
- if (aliasAddress.s_addr != 0 &&
- src_addr.s_addr == aliasAddress.s_addr)
- {
- link = _FindLinkOut(nullAddress, dst_addr, src_port, dst_port,
- link_type, replace_partial_links);
- }
- }
-
- return(link);
-}
-
-
-struct alias_link *
-_FindLinkIn(struct in_addr dst_addr,
- struct in_addr alias_addr,
- u_short dst_port,
- u_short alias_port,
- int link_type,
- int replace_partial_links)
-{
- int flags_in;
- u_int start_point;
- struct alias_link *link;
- struct alias_link *link_fully_specified;
- struct alias_link *link_unknown_all;
- struct alias_link *link_unknown_dst_addr;
- struct alias_link *link_unknown_dst_port;
-
-/* Initialize pointers */
- link_fully_specified = NULL;
- link_unknown_all = NULL;
- link_unknown_dst_addr = NULL;
- link_unknown_dst_port = NULL;
-
-/* If either the dest addr or port is unknown, the search
- loop will have to know about this. */
-
- flags_in = 0;
- if (dst_addr.s_addr == 0)
- flags_in |= LINK_UNKNOWN_DEST_ADDR;
- if (dst_port == 0)
- flags_in |= LINK_UNKNOWN_DEST_PORT;
-
-/* Search loop */
- start_point = StartPointIn(alias_addr, alias_port, link_type);
- link = linkTableIn[start_point];
- while (link != NULL)
- {
- int flags;
-
- flags = flags_in | link->flags;
- if (!(flags & LINK_PARTIALLY_SPECIFIED))
- {
- if (link->alias_addr.s_addr == alias_addr.s_addr
- && link->alias_port == alias_port
- && link->dst_addr.s_addr == dst_addr.s_addr
- && link->dst_port == dst_port
- && link->link_type == link_type)
- {
- link_fully_specified = link;
- break;
- }
- }
- else if ((flags & LINK_UNKNOWN_DEST_ADDR)
- && (flags & LINK_UNKNOWN_DEST_PORT))
- {
- if (link->alias_addr.s_addr == alias_addr.s_addr
- && link->alias_port == alias_port
- && link->link_type == link_type)
- {
- if (link_unknown_all == NULL)
- link_unknown_all = link;
- }
- }
- else if (flags & LINK_UNKNOWN_DEST_ADDR)
- {
- if (link->alias_addr.s_addr == alias_addr.s_addr
- && link->alias_port == alias_port
- && link->link_type == link_type
- && link->dst_port == dst_port)
- {
- if (link_unknown_dst_addr == NULL)
- link_unknown_dst_addr = link;
- }
- }
- else if (flags & LINK_UNKNOWN_DEST_PORT)
- {
- if (link->alias_addr.s_addr == alias_addr.s_addr
- && link->alias_port == alias_port
- && link->link_type == link_type
- && link->dst_addr.s_addr == dst_addr.s_addr)
- {
- if (link_unknown_dst_port == NULL)
- link_unknown_dst_port = link;
- }
- }
- link = link->next_in;
- }
-
-
-
- if (link_fully_specified != NULL)
- {
- link_fully_specified->timestamp = timeStamp;
- return link_fully_specified;
- }
- else if (link_unknown_dst_port != NULL)
- {
- return replace_partial_links
- ? ReLink(link_unknown_dst_port,
- link_unknown_dst_port->src_addr, dst_addr, alias_addr,
- link_unknown_dst_port->src_port, dst_port, alias_port,
- link_type)
- : link_unknown_dst_port;
- }
- else if (link_unknown_dst_addr != NULL)
- {
- return replace_partial_links
- ? ReLink(link_unknown_dst_addr,
- link_unknown_dst_addr->src_addr, dst_addr, alias_addr,
- link_unknown_dst_addr->src_port, dst_port, alias_port,
- link_type)
- : link_unknown_dst_addr;
- }
- else if (link_unknown_all != NULL)
- {
- return replace_partial_links
- ? ReLink(link_unknown_all,
- link_unknown_all->src_addr, dst_addr, alias_addr,
- link_unknown_all->src_port, dst_port, alias_port,
- link_type)
- : link_unknown_all;
- }
- else
- {
- return(NULL);
- }
-}
-
-struct alias_link *
-FindLinkIn(struct in_addr dst_addr,
- struct in_addr alias_addr,
- u_short dst_port,
- u_short alias_port,
- int link_type,
- int replace_partial_links)
-{
- struct alias_link *link;
-
- link = _FindLinkIn(dst_addr, alias_addr, dst_port, alias_port,
- link_type, replace_partial_links);
-
- if (link == NULL)
- {
- /* The following allows permanent links to be
- specified as using the default aliasing address
- (i.e. device interface address) without knowing
- in advance what that address is. */
- if (aliasAddress.s_addr != 0 &&
- alias_addr.s_addr == aliasAddress.s_addr)
- {
- link = _FindLinkIn(dst_addr, nullAddress, dst_port, alias_port,
- link_type, replace_partial_links);
- }
- }
-
- return(link);
-}
-
-
-
-
-/* External routines for finding/adding links
-
--- "external" means outside alias_db.c, but within alias*.c --
-
- FindIcmpIn(), FindIcmpOut()
- FindFragmentIn1(), FindFragmentIn2()
- AddFragmentPtrLink(), FindFragmentPtr()
- FindUdpTcpIn(), FindUdpTcpOut()
- FindOriginalAddress(), FindAliasAddress()
-
-(prototypes in alias_local.h)
-*/
-
-
-struct alias_link *
-FindIcmpIn(struct in_addr dst_addr,
- struct in_addr alias_addr,
- u_short id_alias)
-{
- return FindLinkIn(dst_addr, alias_addr,
- NO_DEST_PORT, id_alias,
- LINK_ICMP, 0);
-}
-
-
-struct alias_link *
-FindIcmpOut(struct in_addr src_addr,
- struct in_addr dst_addr,
- u_short id)
-{
- struct alias_link * link;
-
- link = FindLinkOut(src_addr, dst_addr,
- id, NO_DEST_PORT,
- LINK_ICMP, 0);
- if (link == NULL)
- {
- struct in_addr alias_addr;
-
- alias_addr = FindAliasAddress(src_addr);
- link = AddLink(src_addr, dst_addr, alias_addr,
- id, NO_DEST_PORT, GET_ALIAS_ID,
- LINK_ICMP);
- }
-
- return(link);
-}
-
-
-struct alias_link *
-FindFragmentIn1(struct in_addr dst_addr,
- struct in_addr alias_addr,
- u_short ip_id)
-{
- struct alias_link *link;
-
- link = FindLinkIn(dst_addr, alias_addr,
- NO_DEST_PORT, ip_id,
- LINK_FRAGMENT_ID, 0);
-
- if (link == NULL)
- {
- link = AddLink(nullAddress, dst_addr, alias_addr,
- NO_SRC_PORT, NO_DEST_PORT, ip_id,
- LINK_FRAGMENT_ID);
- }
-
- return(link);
-}
-
-
-struct alias_link *
-FindFragmentIn2(struct in_addr dst_addr, /* Doesn't add a link if one */
- struct in_addr alias_addr, /* is not found. */
- u_short ip_id)
-{
- return FindLinkIn(dst_addr, alias_addr,
- NO_DEST_PORT, ip_id,
- LINK_FRAGMENT_ID, 0);
-}
-
-
-struct alias_link *
-AddFragmentPtrLink(struct in_addr dst_addr,
- u_short ip_id)
-{
- return AddLink(nullAddress, dst_addr, nullAddress,
- NO_SRC_PORT, NO_DEST_PORT, ip_id,
- LINK_FRAGMENT_PTR);
-}
-
-
-struct alias_link *
-FindFragmentPtr(struct in_addr dst_addr,
- u_short ip_id)
-{
- return FindLinkIn(dst_addr, nullAddress,
- NO_DEST_PORT, ip_id,
- LINK_FRAGMENT_PTR, 0);
-}
-
-
-struct alias_link *
-FindUdpTcpIn(struct in_addr dst_addr,
- struct in_addr alias_addr,
- u_short dst_port,
- u_short alias_port,
- u_char proto)
-{
- int link_type;
- struct alias_link *link;
-
- switch (proto)
- {
- case IPPROTO_UDP:
- link_type = LINK_UDP;
- break;
- case IPPROTO_TCP:
- link_type = LINK_TCP;
- break;
- default:
- return NULL;
- break;
- }
-
- link = FindLinkIn(dst_addr, alias_addr,
- dst_port, alias_port,
- link_type, 1);
-
- if (!(packetAliasMode & PKT_ALIAS_DENY_INCOMING)
- && !(packetAliasMode & PKT_ALIAS_PROXY_ONLY)
- && link == NULL)
- {
- struct in_addr target_addr;
-
- target_addr = FindOriginalAddress(alias_addr);
- link = AddLink(target_addr, dst_addr, alias_addr,
- alias_port, dst_port, alias_port,
- link_type);
- }
-
- return(link);
-}
-
-
-struct alias_link *
-FindUdpTcpOut(struct in_addr src_addr,
- struct in_addr dst_addr,
- u_short src_port,
- u_short dst_port,
- u_char proto)
-{
- int link_type;
- struct alias_link *link;
-
- switch (proto)
- {
- case IPPROTO_UDP:
- link_type = LINK_UDP;
- break;
- case IPPROTO_TCP:
- link_type = LINK_TCP;
- break;
- default:
- return NULL;
- break;
- }
-
- link = FindLinkOut(src_addr, dst_addr, src_port, dst_port, link_type, 1);
-
- if (link == NULL)
- {
- struct in_addr alias_addr;
-
- alias_addr = FindAliasAddress(src_addr);
- link = AddLink(src_addr, dst_addr, alias_addr,
- src_port, dst_port, GET_ALIAS_PORT,
- link_type);
- }
-
- return(link);
-}
-
-
-struct in_addr
-FindOriginalAddress(struct in_addr alias_addr)
-{
- struct alias_link *link;
-
- link = FindLinkIn(nullAddress, alias_addr,
- 0, 0, LINK_ADDR, 0);
- if (link == NULL)
- {
- newDefaultLink = 1;
- if (targetAddress.s_addr != 0)
- return targetAddress;
- else
- return alias_addr;
- }
- else
- {
- if (link->src_addr.s_addr == 0)
- return aliasAddress;
- else
- return link->src_addr;
- }
-}
-
-
-struct in_addr
-FindAliasAddress(struct in_addr original_addr)
-{
- struct alias_link *link;
-
- link = FindLinkOut(original_addr, nullAddress,
- 0, 0, LINK_ADDR, 0);
- if (link == NULL)
- {
- return aliasAddress;
- }
- else
- {
- if (link->alias_addr.s_addr == 0)
- return aliasAddress;
- else
- return link->alias_addr;
- }
-}
-
-
-/* External routines for getting or changing link data
- (external to alias_db.c, but internal to alias*.c)
-
- SetFragmentData(), GetFragmentData()
- SetFragmentPtr(), GetFragmentPtr()
- SetStateIn(), SetStateOut(), GetStateIn(), GetStateOut()
- GetOriginalAddress(), GetDestAddress(), GetAliasAddress()
- GetOriginalPort(), GetAliasPort()
- SetAckModified(), GetAckModified()
- GetDeltaAckIn(), GetDeltaSeqOut(), AddSeq()
-*/
-
-
-void
-SetFragmentAddr(struct alias_link *link, struct in_addr src_addr)
-{
- link->data.frag_addr = src_addr;
-}
-
-
-void
-GetFragmentAddr(struct alias_link *link, struct in_addr *src_addr)
-{
- *src_addr = link->data.frag_addr;
-}
-
-
-void
-SetFragmentPtr(struct alias_link *link, char *fptr)
-{
- link->data.frag_ptr = fptr;
-}
-
-
-void
-GetFragmentPtr(struct alias_link *link, char **fptr)
-{
- *fptr = link->data.frag_ptr;
-}
-
-
-void
-SetStateIn(struct alias_link *link, int state)
-{
- /* TCP input state */
- switch (state) {
- case ALIAS_TCP_STATE_DISCONNECTED:
- if (link->data.tcp->state.out != ALIAS_TCP_STATE_CONNECTED) {
- link->expire_time = TCP_EXPIRE_DEAD;
- } else {
- link->expire_time = TCP_EXPIRE_SINGLEDEAD;
- }
- link->data.tcp->state.in = state;
- break;
- case ALIAS_TCP_STATE_CONNECTED:
- link->expire_time = TCP_EXPIRE_CONNECTED;
- /*FALLTHROUGH*/
- case ALIAS_TCP_STATE_NOT_CONNECTED:
- link->data.tcp->state.in = state;
- break;
- default:
- abort();
- }
-}
-
-
-void
-SetStateOut(struct alias_link *link, int state)
-{
- /* TCP output state */
- switch (state) {
- case ALIAS_TCP_STATE_DISCONNECTED:
- if (link->data.tcp->state.in != ALIAS_TCP_STATE_CONNECTED) {
- link->expire_time = TCP_EXPIRE_DEAD;
- } else {
- link->expire_time = TCP_EXPIRE_SINGLEDEAD;
- }
- link->data.tcp->state.out = state;
- break;
- case ALIAS_TCP_STATE_CONNECTED:
- link->expire_time = TCP_EXPIRE_CONNECTED;
- /*FALLTHROUGH*/
- case ALIAS_TCP_STATE_NOT_CONNECTED:
- link->data.tcp->state.out = state;
- break;
- default:
- abort();
- }
-}
-
-
-int
-GetStateIn(struct alias_link *link)
-{
- /* TCP input state */
- return link->data.tcp->state.in;
-}
-
-
-int
-GetStateOut(struct alias_link *link)
-{
- /* TCP output state */
- return link->data.tcp->state.out;
-}
-
-
-struct in_addr
-GetOriginalAddress(struct alias_link *link)
-{
- if (link->src_addr.s_addr == 0)
- return aliasAddress;
- else
- return(link->src_addr);
-}
-
-
-struct in_addr
-GetDestAddress(struct alias_link *link)
-{
- return(link->dst_addr);
-}
-
-
-struct in_addr
-GetAliasAddress(struct alias_link *link)
-{
- if (link->alias_addr.s_addr == 0)
- return aliasAddress;
- else
- return link->alias_addr;
-}
-
-
-struct in_addr
-GetDefaultAliasAddress()
-{
- return aliasAddress;
-}
-
-
-void
-SetDefaultAliasAddress(struct in_addr alias_addr)
-{
- aliasAddress = alias_addr;
-}
-
-
-u_short
-GetOriginalPort(struct alias_link *link)
-{
- return(link->src_port);
-}
-
-
-u_short
-GetAliasPort(struct alias_link *link)
-{
- return(link->alias_port);
-}
-
-u_short
-GetDestPort(struct alias_link *link)
-{
- return(link->dst_port);
-}
-
-void
-SetAckModified(struct alias_link *link)
-{
-/* Indicate that ack numbers have been modified in a TCP connection */
- link->data.tcp->state.ack_modified = 1;
-}
-
-
-struct in_addr
-GetProxyAddress(struct alias_link *link)
-{
- return link->proxy_addr;
-}
-
-
-void
-SetProxyAddress(struct alias_link *link, struct in_addr addr)
-{
- link->proxy_addr = addr;
-}
-
-
-u_short
-GetProxyPort(struct alias_link *link)
-{
- return link->proxy_port;
-}
-
-
-void
-SetProxyPort(struct alias_link *link, u_short port)
-{
- link->proxy_port = port;
-}
-
-
-int
-GetAckModified(struct alias_link *link)
-{
-/* See if ack numbers have been modified */
- return link->data.tcp->state.ack_modified;
-}
-
-
-int
-GetDeltaAckIn(struct ip *pip, struct alias_link *link)
-{
-/*
-Find out how much the ack number has been altered for an incoming
-TCP packet. To do this, a circular list is ack numbers where the TCP
-packet size was altered is searched.
-*/
-
- int i;
- struct tcphdr *tc;
- int delta, ack_diff_min;
- u_long ack;
-
- tc = (struct tcphdr *) ((char *) pip + (pip->ip_hl << 2));
- ack = tc->th_ack;
-
- delta = 0;
- ack_diff_min = -1;
- for (i=0; i<N_LINK_TCP_DATA; i++)
- {
- struct ack_data_record x;
-
- x = link->data.tcp->ack[i];
- if (x.active == 1)
- {
- int ack_diff;
-
- ack_diff = SeqDiff(x.ack_new, ack);
- if (ack_diff >= 0)
- {
- if (ack_diff_min >= 0)
- {
- if (ack_diff < ack_diff_min)
- {
- delta = x.delta;
- ack_diff_min = ack_diff;
- }
- }
- else
- {
- delta = x.delta;
- ack_diff_min = ack_diff;
- }
- }
- }
- }
- return (delta);
-}
-
-
-int
-GetDeltaSeqOut(struct ip *pip, struct alias_link *link)
-{
-/*
-Find out how much the seq number has been altered for an outgoing
-TCP packet. To do this, a circular list is ack numbers where the TCP
-packet size was altered is searched.
-*/
-
- int i;
- struct tcphdr *tc;
- int delta, seq_diff_min;
- u_long seq;
-
- tc = (struct tcphdr *) ((char *) pip + (pip->ip_hl << 2));
- seq = tc->th_seq;
-
- delta = 0;
- seq_diff_min = -1;
- for (i=0; i<N_LINK_TCP_DATA; i++)
- {
- struct ack_data_record x;
-
- x = link->data.tcp->ack[i];
- if (x.active == 1)
- {
- int seq_diff;
-
- seq_diff = SeqDiff(x.ack_old, seq);
- if (seq_diff >= 0)
- {
- if (seq_diff_min >= 0)
- {
- if (seq_diff < seq_diff_min)
- {
- delta = x.delta;
- seq_diff_min = seq_diff;
- }
- }
- else
- {
- delta = x.delta;
- seq_diff_min = seq_diff;
- }
- }
- }
- }
- return (delta);
-}
-
-
-void
-AddSeq(struct ip *pip, struct alias_link *link, int delta)
-{
-/*
-When a TCP packet has been altered in length, save this
-information in a circular list. If enough packets have
-been altered, then this list will begin to overwrite itself.
-*/
-
- struct tcphdr *tc;
- struct ack_data_record x;
- int hlen, tlen, dlen;
- int i;
-
- tc = (struct tcphdr *) ((char *) pip + (pip->ip_hl << 2));
-
- hlen = (pip->ip_hl + tc->th_off) << 2;
- tlen = ntohs(pip->ip_len);
- dlen = tlen - hlen;
-
- x.ack_old = htonl(ntohl(tc->th_seq) + dlen);
- x.ack_new = htonl(ntohl(tc->th_seq) + dlen + delta);
- x.delta = delta;
- x.active = 1;
-
- i = link->data.tcp->state.index;
- link->data.tcp->ack[i] = x;
-
- i++;
- if (i == N_LINK_TCP_DATA)
- link->data.tcp->state.index = 0;
- else
- link->data.tcp->state.index = i;
-}
-
-void
-SetExpire(struct alias_link *link, int expire)
-{
- if (expire == 0)
- {
- link->flags &= ~LINK_PERMANENT;
- DeleteLink(link);
- }
- else if (expire == -1)
- {
- link->flags |= LINK_PERMANENT;
- }
- else if (expire > 0)
- {
- link->expire_time = expire;
- }
- else
- {
-#ifdef DEBUG
- fprintf(stderr, "PacketAlias/SetExpire(): ");
- fprintf(stderr, "error in expire parameter\n");
-#endif
- }
-}
-
-void
-ClearCheckNewLink(void)
-{
- newDefaultLink = 0;
-}
-
-
-/* Miscellaneous Functions
-
- HouseKeeping()
- InitPacketAliasLog()
- UninitPacketAliasLog()
-*/
-
-/*
- Whenever an outgoing or incoming packet is handled, HouseKeeping()
- is called to find and remove timed-out aliasing links. Logic exists
- to sweep through the entire table and linked list structure
- every 60 seconds.
-
- (prototype in alias_local.h)
-*/
-
-void
-HouseKeeping(void)
-{
- int i, n, n100;
- struct timeval tv;
- struct timezone tz;
-
- /*
- * Save system time (seconds) in global variable timeStamp for
- * use by other functions. This is done so as not to unnecessarily
- * waste timeline by making system calls.
- */
- gettimeofday(&tv, &tz);
- timeStamp = tv.tv_sec;
-
- /* Compute number of spokes (output table link chains) to cover */
- n100 = LINK_TABLE_OUT_SIZE * 100 + houseKeepingResidual;
- n100 *= timeStamp - lastCleanupTime;
- n100 /= ALIAS_CLEANUP_INTERVAL_SECS;
-
- n = n100/100;
-
- /* Handle different cases */
- if (n > ALIAS_CLEANUP_MAX_SPOKES)
- {
- n = ALIAS_CLEANUP_MAX_SPOKES;
- lastCleanupTime = timeStamp;
- houseKeepingResidual = 0;
-
- for (i=0; i<n; i++)
- IncrementalCleanup();
- }
- else if (n > 0)
- {
- lastCleanupTime = timeStamp;
- houseKeepingResidual = n100 - 100*n;
-
- for (i=0; i<n; i++)
- IncrementalCleanup();
- }
- else if (n < 0)
- {
-#ifdef DEBUG
- fprintf(stderr, "PacketAlias/HouseKeeping(): ");
- fprintf(stderr, "something unexpected in time values\n");
-#endif
- lastCleanupTime = timeStamp;
- houseKeepingResidual = 0;
- }
-}
-
-
-/* Init the log file and enable logging */
-static void
-InitPacketAliasLog(void)
-{
- if ((~packetAliasMode & PKT_ALIAS_LOG)
- && (monitorFile = fopen("/var/log/alias.log", "w")))
- {
- packetAliasMode |= PKT_ALIAS_LOG;
- fprintf(monitorFile,
- "PacketAlias/InitPacketAliasLog: Packet alias logging enabled.\n");
- }
-}
-
-
-/* Close the log-file and disable logging. */
-static void
-UninitPacketAliasLog(void)
-{
- if (monitorFile) {
- fclose(monitorFile);
- monitorFile = NULL;
- }
- packetAliasMode &= ~PKT_ALIAS_LOG;
-}
-
-
-
-
-
-
-/* Outside world interfaces
-
--- "outside world" means other than alias*.c routines --
-
- PacketAliasRedirectPort()
- PacketAliasRedirectAddr()
- PacketAliasRedirectDelete()
- PacketAliasSetAddress()
- PacketAliasInit()
- PacketAliasUninit()
- PacketAliasSetMode()
-
-(prototypes in alias.h)
-*/
-
-/* Redirection from a specific public addr:port to a
- a private addr:port */
-struct alias_link *
-PacketAliasRedirectPort(struct in_addr src_addr, u_short src_port,
- struct in_addr dst_addr, u_short dst_port,
- struct in_addr alias_addr, u_short alias_port,
- u_char proto)
-{
- int link_type;
- struct alias_link *link;
-
- switch(proto)
- {
- case IPPROTO_UDP:
- link_type = LINK_UDP;
- break;
- case IPPROTO_TCP:
- link_type = LINK_TCP;
- break;
- default:
-#ifdef DEBUG
- fprintf(stderr, "PacketAliasRedirectPort(): ");
- fprintf(stderr, "only TCP and UDP protocols allowed\n");
-#endif
- return NULL;
- }
-
- link = AddLink(src_addr, dst_addr, alias_addr,
- src_port, dst_port, alias_port,
- link_type);
-
- if (link != NULL)
- {
- link->flags |= LINK_PERMANENT;
- }
-#ifdef DEBUG
- else
- {
- fprintf(stderr, "PacketAliasRedirectPort(): "
- "call to AddLink() failed\n");
- }
-#endif
-
- return link;
-}
-
-/* Translate PPTP packets to a machine on the inside
- */
-int
-PacketAliasPptp(struct in_addr src_addr)
-{
-
- pptpAliasAddr = src_addr; /* Address of the inside PPTP machine */
- pptpAliasFlag = src_addr.s_addr != INADDR_NONE;
-
- return 1;
-}
-
-int GetPptpAlias (struct in_addr* alias_addr)
-{
- if (pptpAliasFlag)
- *alias_addr = pptpAliasAddr;
-
- return pptpAliasFlag;
-}
-
-/* Static address translation */
-struct alias_link *
-PacketAliasRedirectAddr(struct in_addr src_addr,
- struct in_addr alias_addr)
-{
- struct alias_link *link;
-
- link = AddLink(src_addr, nullAddress, alias_addr,
- 0, 0, 0,
- LINK_ADDR);
-
- if (link != NULL)
- {
- link->flags |= LINK_PERMANENT;
- }
-#ifdef DEBUG
- else
- {
- fprintf(stderr, "PacketAliasRedirectAddr(): "
- "call to AddLink() failed\n");
- }
-#endif
-
- return link;
-}
-
-
-void
-PacketAliasRedirectDelete(struct alias_link *link)
-{
-/* This is a dangerous function to put in the API,
- because an invalid pointer can crash the program. */
-
- deleteAllLinks = 1;
- DeleteLink(link);
- deleteAllLinks = 0;
-}
-
-
-void
-PacketAliasSetAddress(struct in_addr addr)
-{
- if (packetAliasMode & PKT_ALIAS_RESET_ON_ADDR_CHANGE
- && aliasAddress.s_addr != addr.s_addr)
- CleanupAliasData();
-
- aliasAddress = addr;
-}
-
-
-void
-PacketAliasSetTarget(struct in_addr target_addr)
-{
- targetAddress = target_addr;
-}
-
-
-void
-PacketAliasInit(void)
-{
- int i;
- struct timeval tv;
- struct timezone tz;
- static int firstCall = 1;
-
- if (firstCall == 1)
- {
- gettimeofday(&tv, &tz);
- timeStamp = tv.tv_sec;
- lastCleanupTime = tv.tv_sec;
- houseKeepingResidual = 0;
-
- for (i=0; i<LINK_TABLE_OUT_SIZE; i++)
- linkTableOut[i] = NULL;
- for (i=0; i<LINK_TABLE_IN_SIZE; i++)
- linkTableIn[i] = NULL;
-
- atexit(PacketAliasUninit);
- firstCall = 0;
- }
- else
- {
- deleteAllLinks = 1;
- CleanupAliasData();
- deleteAllLinks = 0;
- }
-
- aliasAddress.s_addr = 0;
- targetAddress.s_addr = 0;
-
- icmpLinkCount = 0;
- udpLinkCount = 0;
- tcpLinkCount = 0;
- fragmentIdLinkCount = 0;
- fragmentPtrLinkCount = 0;
- sockCount = 0;
-
- cleanupIndex =0;
-
- packetAliasMode = PKT_ALIAS_SAME_PORTS
- | PKT_ALIAS_USE_SOCKETS
- | PKT_ALIAS_RESET_ON_ADDR_CHANGE;
-
- pptpAliasFlag = 0;
-}
-
-void
-PacketAliasUninit(void) {
- deleteAllLinks = 1;
- CleanupAliasData();
- deleteAllLinks = 0;
- UninitPacketAliasLog();
-#ifndef NO_FW_PUNCH
- UninitPunchFW();
-#endif
-}
-
-
-/* Change mode for some operations */
-unsigned int
-PacketAliasSetMode(
- unsigned int flags, /* Which state to bring flags to */
- unsigned int mask /* Mask of which flags to affect (use 0 to do a
- probe for flag values) */
-)
-{
-/* Enable logging? */
- if (flags & mask & PKT_ALIAS_LOG)
- {
- InitPacketAliasLog(); /* Do the enable */
- } else
-/* _Disable_ logging? */
- if (~flags & mask & PKT_ALIAS_LOG) {
- UninitPacketAliasLog();
- }
-
-#ifndef NO_FW_PUNCH
-/* Start punching holes in the firewall? */
- if (flags & mask & PKT_ALIAS_PUNCH_FW) {
- InitPunchFW();
- } else
-/* Stop punching holes in the firewall? */
- if (~flags & mask & PKT_ALIAS_PUNCH_FW) {
- UninitPunchFW();
- }
-#endif
-
-/* Other flags can be set/cleared without special action */
- packetAliasMode = (flags & mask) | (packetAliasMode & ~mask);
- return packetAliasMode;
-}
-
-
-int
-PacketAliasCheckNewLink(void)
-{
- return newDefaultLink;
-}
-
-
-#ifndef NO_FW_PUNCH
-
-/*****************
- Code to support firewall punching. This shouldn't really be in this
- file, but making variables global is evil too.
- ****************/
-
-/* Firewall include files */
-#include <sys/queue.h>
-#include <net/if.h>
-#include <netinet/ip_fw.h>
-#include <string.h>
-#include <err.h>
-
-static void ClearAllFWHoles(void);
-
-static int fireWallBaseNum; /* The first firewall entry free for our use */
-static int fireWallNumNums; /* How many entries can we use? */
-static int fireWallActiveNum; /* Which entry did we last use? */
-static char *fireWallField; /* bool array for entries */
-
-#define fw_setfield(field, num) \
-do { \
- (field)[num] = 1; \
-} /*lint -save -e717 */ while(0) /*lint -restore */
-#define fw_clrfield(field, num) \
-do { \
- (field)[num] = 0; \
-} /*lint -save -e717 */ while(0) /*lint -restore */
-#define fw_tstfield(field, num) ((field)[num])
-
-void
-PacketAliasSetFWBase(unsigned int base, unsigned int num) {
- fireWallBaseNum = base;
- fireWallNumNums = num;
-}
-
-static void
-InitPunchFW(void) {
- fireWallField = malloc(fireWallNumNums);
- if (fireWallField) {
- memset(fireWallField, 0, fireWallNumNums);
- if (fireWallFD < 0) {
- fireWallFD = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
- }
- ClearAllFWHoles();
- fireWallActiveNum = fireWallBaseNum;
- }
-}
-
-static void
-UninitPunchFW(void) {
- ClearAllFWHoles();
- if (fireWallFD >= 0)
- close(fireWallFD);
- fireWallFD = -1;
- if (fireWallField)
- free(fireWallField);
- fireWallField = NULL;
- packetAliasMode &= ~PKT_ALIAS_PUNCH_FW;
-}
-
-/* Make a certain link go through the firewall */
-void
-PunchFWHole(struct alias_link *link) {
- int r; /* Result code */
- struct ip_fw rule; /* On-the-fly built rule */
- int fwhole; /* Where to punch hole */
-
-/* Don't do anything unless we are asked to */
- if ( !(packetAliasMode & PKT_ALIAS_PUNCH_FW) ||
- fireWallFD < 0 ||
- link->link_type != LINK_TCP ||
- !link->data.tcp)
- return;
-
- memset(&rule, 0, sizeof rule);
-
-/** Build rule **/
-
- /* Find empty slot */
- for (fwhole = fireWallActiveNum;
- fwhole < fireWallBaseNum + fireWallNumNums &&
- fw_tstfield(fireWallField, fwhole);
- fwhole++)
- ;
- if (fwhole >= fireWallBaseNum + fireWallNumNums ||
- fw_tstfield(fireWallField, fwhole)) {
- for (fwhole = fireWallBaseNum;
- fwhole < fireWallActiveNum &&
- fw_tstfield(fireWallField, fwhole);
- fwhole++)
- ;
- if (fwhole == fireWallActiveNum) {
- /* No rule point empty - we can't punch more holes. */
- fireWallActiveNum = fireWallBaseNum;
-#ifdef DEBUG
- fprintf(stderr, "libalias: Unable to create firewall hole!\n");
-#endif
- return;
- }
- }
- /* Start next search at next position */
- fireWallActiveNum = fwhole+1;
-
- /* Build generic part of the two rules */
- rule.fw_number = fwhole;
- rule.fw_nports = 1; /* Number of source ports; dest ports follow */
- rule.fw_flg = IP_FW_F_ACCEPT;
- rule.fw_prot = IPPROTO_TCP;
- rule.fw_smsk.s_addr = INADDR_BROADCAST;
- rule.fw_dmsk.s_addr = INADDR_BROADCAST;
-
- /* Build and apply specific part of the rules */
- rule.fw_src = GetOriginalAddress(link);
- rule.fw_dst = GetDestAddress(link);
- rule.fw_uar.fw_pts[0] = ntohs(GetOriginalPort(link));
- rule.fw_uar.fw_pts[1] = ntohs(GetDestPort(link));
-
- /* Skip non-bound links - XXX should not be strictly necessary,
- but seems to leave hole if not done. Leak of non-bound links?
- (Code should be left even if the problem is fixed - it is a
- clear optimization) */
- if (rule.fw_uar.fw_pts[0] != 0 && rule.fw_uar.fw_pts[1] != 0) {
- r = setsockopt(fireWallFD, IPPROTO_IP, IP_FW_ADD, &rule, sizeof rule);
-#ifdef DEBUG
- if (r)
- err(1, "alias punch inbound(1) setsockopt(IP_FW_ADD)");
-#endif
- rule.fw_src = GetDestAddress(link);
- rule.fw_dst = GetOriginalAddress(link);
- rule.fw_uar.fw_pts[0] = ntohs(GetDestPort(link));
- rule.fw_uar.fw_pts[1] = ntohs(GetOriginalPort(link));
- r = setsockopt(fireWallFD, IPPROTO_IP, IP_FW_ADD, &rule, sizeof rule);
-#ifdef DEBUG
- if (r)
- err(1, "alias punch inbound(2) setsockopt(IP_FW_ADD)");
-#endif
- }
-/* Indicate hole applied */
- link->data.tcp->fwhole = fwhole;
- fw_setfield(fireWallField, fwhole);
-}
-
-/* Remove a hole in a firewall associated with a particular alias
- link. Calling this too often is harmless. */
-static void
-ClearFWHole(struct alias_link *link) {
- if (link->link_type == LINK_TCP && link->data.tcp) {
- int fwhole = link->data.tcp->fwhole; /* Where is the firewall hole? */
- struct ip_fw rule;
-
- if (fwhole < 0)
- return;
-
- memset(&rule, 0, sizeof rule);
- rule.fw_number = fwhole;
- while (!setsockopt(fireWallFD, IPPROTO_IP, IP_FW_DEL, &rule, sizeof rule))
- ;
- fw_clrfield(fireWallField, fwhole);
- link->data.tcp->fwhole = -1;
- }
-}
-
-/* Clear out the entire range dedicated to firewall holes. */
-static void
-ClearAllFWHoles(void) {
- struct ip_fw rule; /* On-the-fly built rule */
- int i;
-
- if (fireWallFD < 0)
- return;
-
- memset(&rule, 0, sizeof rule);
- for (i = fireWallBaseNum; i < fireWallBaseNum + fireWallNumNums; i++) {
- rule.fw_number = i;
- while (!setsockopt(fireWallFD, IPPROTO_IP, IP_FW_DEL, &rule, sizeof rule))
- ;
- }
- memset(fireWallField, 0, fireWallNumNums);
-}
-#endif
diff --git a/sys/netinet/libalias/alias_ftp.c b/sys/netinet/libalias/alias_ftp.c
deleted file mode 100644
index ca2d53b21525..000000000000
--- a/sys/netinet/libalias/alias_ftp.c
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- Alias_ftp.c performs special processing for FTP sessions under
- TCP. Specifically, when a PORT command from the client side
- is sent, it is intercepted and modified. The address is changed
- to the gateway machine and an aliasing port is used.
-
- For this routine to work, the PORT command must fit entirely
- into a single TCP packet. This is typically the case, but exceptions
- can easily be envisioned under the actual specifications.
-
- Probably the most troubling aspect of the approach taken here is
- that the new PORT command will typically be a different length, and
- this causes a certain amount of bookkeeping to keep track of the
- changes of sequence and acknowledgment numbers, since the client
- machine is totally unaware of the modification to the TCP stream.
-
-
- This software is placed into the public domain with no restrictions
- on its distribution.
-
- Initial version: August, 1996 (cjm)
-
- Version 1.6
- Brian Somers and Martin Renters identified an IP checksum
- error for modified IP packets.
-
- Version 1.7: January 9, 1996 (cjm)
- Differental checksum computation for change
- in IP packet length.
-
- Version 2.1: May, 1997 (cjm)
- Very minor changes to conform with
- local/global/function naming conventions
- withing the packet alising module.
-
- See HISTORY file for record of revisions.
-
- $FreeBSD$
-*/
-
-/* Includes */
-#include <ctype.h>
-#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <netinet/in_systm.h>
-#include <netinet/in.h>
-#include <netinet/ip.h>
-#include <netinet/tcp.h>
-
-#include "alias_local.h"
-
-static void NewFtpPortCommand(struct ip *, struct alias_link *, struct in_addr, u_short, int);
-
-
-
-void
-AliasHandleFtpOut(
-struct ip *pip, /* IP packet to examine/patch */
-struct alias_link *link, /* The link to go through (aliased port) */
-int maxpacketsize /* The maximum size this packet can grow to (including headers) */)
-{
- int hlen, tlen, dlen;
- struct in_addr true_addr;
- u_short true_port;
- char *sptr;
- struct tcphdr *tc;
-
-/* Calculate data length of TCP packet */
- tc = (struct tcphdr *) ((char *) pip + (pip->ip_hl << 2));
- hlen = (pip->ip_hl + tc->th_off) << 2;
- tlen = ntohs(pip->ip_len);
- dlen = tlen - hlen;
-
-/* Return is data length is too long or too short */
- if (dlen<10 || dlen>80)
- return;
-
-/* Place string pointer and beginning of data */
- sptr = (char *) pip;
- sptr += hlen;
-
-/* Parse through string using state diagram method */
- {
- char ch, zero;
- int i, state;
- u_long a1, a2, a3, a4;
- u_short p1, p2;
-
- a1=0; a2=0; a3=0; a4=0; p1=0; p2=0;
- zero = '0';
- state=-4;
- for (i=0; i<dlen; i++)
- {
- ch = sptr[i];
- switch (state)
- {
- case -4: if (ch == 'P') state=-3; else return; break;
- case -3: if (ch == 'O') state=-2; else return; break;
- case -2: if (ch == 'R') state=-1; else return; break;
- case -1: if (ch == 'T') state= 0; else return; break;
-
- case 0 :
- if (isdigit(ch)) {a1=ch-zero; state=1 ;} break;
- case 1 :
- if (isdigit(ch)) a1=10*a1+ch-zero; else state=2 ; break;
- case 2 :
- if (isdigit(ch)) {a2=ch-zero; state=3 ;} break;
- case 3 :
- if (isdigit(ch)) a2=10*a2+ch-zero; else state=4 ; break;
- case 4 :
- if (isdigit(ch)) {a3=ch-zero; state=5 ;} break;
- case 5 :
- if (isdigit(ch)) a3=10*a3+ch-zero; else state=6 ; break;
- case 6 :
- if (isdigit(ch)) {a4=ch-zero; state=7 ;} break;
- case 7 :
- if (isdigit(ch)) a4=10*a4+ch-zero; else state=8 ; break;
- case 8 :
- if (isdigit(ch)) {p1=ch-zero; state=9 ;} break;
- case 9 :
- if (isdigit(ch)) p1=10*p1+ch-zero; else state=10; break;
- case 10:
- if (isdigit(ch)) {p2=ch-zero; state=11;} break;
- case 11:
- if (isdigit(ch)) p2=10*p2+ch-zero; break;
- }
- }
-
- if (state == 11)
- {
- true_port = htons((p1<<8) + p2);
- true_addr.s_addr = htonl((a1<<24) + (a2<<16) +(a3<<8) + a4);
- NewFtpPortCommand(pip, link, true_addr, true_port, maxpacketsize);
- }
- }
-}
-
-static void
-NewFtpPortCommand(struct ip *pip,
- struct alias_link *link,
- struct in_addr true_addr,
- u_short true_port,
- int maxpacketsize)
-{
- struct alias_link *ftp_link;
-
-/* Establish link to address and port found in PORT command */
- ftp_link = FindUdpTcpOut(true_addr, GetDestAddress(link),
- true_port, 0, IPPROTO_TCP);
-
- if (ftp_link != NULL)
- {
- int slen, hlen, tlen, dlen;
- struct tcphdr *tc;
-
-#ifndef NO_FW_PUNCH
-/* Punch hole in firewall */
- PunchFWHole(ftp_link);
-#endif
-
-/* Calculate data length of TCP packet */
- tc = (struct tcphdr *) ((char *) pip + (pip->ip_hl << 2));
- hlen = (pip->ip_hl + tc->th_off) << 2;
- tlen = ntohs(pip->ip_len);
- dlen = tlen - hlen;
-
-/* Create new PORT command */
- {
- char stemp[80];
- char *sptr;
- u_short alias_port;
- u_char *ptr;
- int a1, a2, a3, a4, p1, p2;
- struct in_addr alias_address;
-
-/* Decompose alias address into quad format */
- alias_address = GetAliasAddress(link);
- ptr = (u_char *) &alias_address.s_addr;
- a1 = *ptr++; a2=*ptr++; a3=*ptr++; a4=*ptr;
-
-/* Decompose alias port into pair format */
- alias_port = GetAliasPort(ftp_link);
- ptr = (char *) &alias_port;
- p1 = *ptr++; p2=*ptr;
-
-/* Generate command string */
- sprintf(stemp, "PORT %d,%d,%d,%d,%d,%d\r\n",
- a1,a2,a3,a4,p1,p2);
-
-/* Save string length for IP header modification */
- slen = strlen(stemp);
-
-/* Copy into IP packet */
- sptr = (char *) pip; sptr += hlen;
- strncpy(sptr, stemp, maxpacketsize-hlen);
- }
-
-/* Save information regarding modified seq and ack numbers */
- {
- int delta;
-
- SetAckModified(link);
- delta = GetDeltaSeqOut(pip, link);
- AddSeq(pip, link, delta+slen-dlen);
- }
-
-/* Revise IP header */
- {
- u_short new_len;
-
- new_len = htons(hlen + slen);
- DifferentialChecksum(&pip->ip_sum,
- &new_len,
- &pip->ip_len,
- 1);
- pip->ip_len = new_len;
- }
-
-/* Compute TCP checksum for revised packet */
- tc->th_sum = 0;
- tc->th_sum = TcpChecksum(pip);
- }
- else
- {
-#ifdef DEBUG
- fprintf(stderr,
- "PacketAlias/HandleFtpOut: Cannot allocate FTP data port\n");
-#endif
- }
-}
diff --git a/sys/netinet/libalias/alias_irc.c b/sys/netinet/libalias/alias_irc.c
deleted file mode 100644
index 8c52c1f76534..000000000000
--- a/sys/netinet/libalias/alias_irc.c
+++ /dev/null
@@ -1,318 +0,0 @@
-/* Alias_irc.c intercepts packages contain IRC CTCP commands, and
- changes DCC commands to export a port on the aliasing host instead
- of an aliased host.
-
- For this routine to work, the DCC command must fit entirely into a
- single TCP packet. This will usually happen, but is not
- guaranteed.
-
- The interception is likely to change the length of the packet.
- The handling of this is copied more-or-less verbatim from
- ftp_alias.c
-
- This software is placed into the public domain with no restrictions
- on its distribution.
-
- Initial version: Eivind Eklund <perhaps@yes.no> (ee) 97-01-29
-
- Version 2.1: May, 1997 (cjm)
- Very minor changes to conform with
- local/global/function naming conventions
- withing the packet alising module.
-
- $FreeBSD$
-*/
-
-/* Includes */
-#include <ctype.h>
-#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <netinet/in_systm.h>
-#include <netinet/in.h>
-#include <netinet/ip.h>
-#include <netinet/tcp.h>
-#include <limits.h>
-
-#include "alias_local.h"
-
-/* Local defines */
-#define DBprintf(a)
-
-
-void
-AliasHandleIrcOut(struct ip *pip, /* IP packet to examine */
- struct alias_link *link, /* Which link are we on? */
- int maxsize /* Maximum size of IP packet including headers */
- )
-{
- int hlen, tlen, dlen;
- struct in_addr true_addr;
- u_short true_port;
- char *sptr;
- struct tcphdr *tc;
- int i; /* Iterator through the source */
-
-/* Calculate data length of TCP packet */
- tc = (struct tcphdr *) ((char *) pip + (pip->ip_hl << 2));
- hlen = (pip->ip_hl + tc->th_off) << 2;
- tlen = ntohs(pip->ip_len);
- dlen = tlen - hlen;
-
- /* Return if data length is too short - assume an entire PRIVMSG in each packet. */
- if (dlen<sizeof(":A!a@n.n PRIVMSG A :aDCC 1 1a")-1)
- return;
-
-/* Place string pointer at beginning of data */
- sptr = (char *) pip;
- sptr += hlen;
- maxsize -= hlen; /* We're interested in maximum size of data, not packet */
-
- /* Search for a CTCP command [Note 1] */
- for( i=0; i<dlen; i++ ) {
- if(sptr[i]=='\001')
- goto lFOUND_CTCP;
- }
- return; /* No CTCP commands in */
- /* Handle CTCP commands - the buffer may have to be copied */
-lFOUND_CTCP:
- {
- char newpacket[65536]; /* Estimate of maximum packet size :) */
- int copyat = i; /* Same */
- int iCopy = 0; /* How much data have we written to copy-back string? */
- unsigned long org_addr; /* Original IP address */
- unsigned short org_port; /* Original source port address */
- lCTCP_START:
- if( i >= dlen || iCopy >= sizeof(newpacket) )
- goto lPACKET_DONE;
- newpacket[iCopy++] = sptr[i++]; /* Copy the CTCP start character */
- /* Start of a CTCP */
- if( i+4 >= dlen ) /* Too short for DCC */
- goto lBAD_CTCP;
- if( sptr[i+0] != 'D' )
- goto lBAD_CTCP;
- if( sptr[i+1] != 'C' )
- goto lBAD_CTCP;
- if( sptr[i+2] != 'C' )
- goto lBAD_CTCP;
- if( sptr[i+3] != ' ' )
- goto lBAD_CTCP;
- /* We have a DCC command - handle it! */
- i+= 4; /* Skip "DCC " */
- if( iCopy+4 > sizeof(newpacket) )
- goto lPACKET_DONE;
- newpacket[iCopy++] = 'D';
- newpacket[iCopy++] = 'C';
- newpacket[iCopy++] = 'C';
- newpacket[iCopy++] = ' ';
-
- DBprintf(("Found DCC\n"));
- /* Skip any extra spaces (should not occur according to
- protocol, but DCC breaks CTCP protocol anyway */
- while(sptr[i] == ' ') {
- if( ++i >= dlen) {
- DBprintf(("DCC packet terminated in just spaces\n"));
- goto lPACKET_DONE;
- }
- }
-
- DBprintf(("Transferring command...\n"));
- while(sptr[i] != ' ') {
- newpacket[iCopy++] = sptr[i];
- if( ++i >= dlen || iCopy >= sizeof(newpacket) ) {
- DBprintf(("DCC packet terminated during command\n"));
- goto lPACKET_DONE;
- }
- }
- /* Copy _one_ space */
- if( i+1 < dlen && iCopy < sizeof(newpacket) )
- newpacket[iCopy++] = sptr[i++];
-
- DBprintf(("Done command - removing spaces\n"));
- /* Skip any extra spaces (should not occur according to
- protocol, but DCC breaks CTCP protocol anyway */
- while(sptr[i] == ' ') {
- if( ++i >= dlen ) {
- DBprintf(("DCC packet terminated in just spaces (post-command)\n"));
- goto lPACKET_DONE;
- }
- }
-
- DBprintf(("Transferring filename...\n"));
- while(sptr[i] != ' ') {
- newpacket[iCopy++] = sptr[i];
- if( ++i >= dlen || iCopy >= sizeof(newpacket) ) {
- DBprintf(("DCC packet terminated during filename\n"));
- goto lPACKET_DONE;
- }
- }
- /* Copy _one_ space */
- if( i+1 < dlen && iCopy < sizeof(newpacket) )
- newpacket[iCopy++] = sptr[i++];
-
- DBprintf(("Done filename - removing spaces\n"));
- /* Skip any extra spaces (should not occur according to
- protocol, but DCC breaks CTCP protocol anyway */
- while(sptr[i] == ' ') {
- if( ++i >= dlen ) {
- DBprintf(("DCC packet terminated in just spaces (post-filename)\n"));
- goto lPACKET_DONE;
- }
- }
-
- DBprintf(("Fetching IP address\n"));
- /* Fetch IP address */
- org_addr = 0;
- while(i<dlen && isdigit(sptr[i])) {
- if( org_addr > ULONG_MAX/10UL ) { /* Terminate on overflow */
- DBprintf(("DCC Address overflow (org_addr == 0x%08lx, next char %c\n", org_addr, sptr[i]));
- goto lBAD_CTCP;
- }
- org_addr *= 10;
- org_addr += sptr[i++]-'0';
- }
- DBprintf(("Skipping space\n"));
- if( i+1 >= dlen || sptr[i] != ' ' ) {
- DBprintf(("Overflow (%d >= %d) or bad character (%02x) terminating IP address\n", i+1, dlen, sptr[i]));
- goto lBAD_CTCP;
- }
- /* Skip any extra spaces (should not occur according to
- protocol, but DCC breaks CTCP protocol anyway, so we might
- as well play it safe */
- while(sptr[i] == ' ') {
- if( ++i >= dlen ) {
- DBprintf(("Packet failure - space overflow.\n"));
- goto lPACKET_DONE;
- }
- }
- DBprintf(("Fetching port number\n"));
- /* Fetch source port */
- org_port = 0;
- while(i<dlen && isdigit(sptr[i])) {
- if( org_port > 6554 ) { /* Terminate on overflow (65536/10 rounded up*/
- DBprintf(("DCC: port number overflow\n"));
- goto lBAD_CTCP;
- }
- org_port *= 10;
- org_port += sptr[i++]-'0';
- }
- /* Skip illegal addresses (or early termination) */
- if( i >= dlen || (sptr[i] != '\001' && sptr[i] != ' ') ) {
- DBprintf(("Bad port termination\n"));
- goto lBAD_CTCP;
- }
- DBprintf(("Got IP %lu and port %u\n", org_addr, (unsigned)org_port));
-
- /* We've got the address and port - now alias it */
- {
- struct alias_link *dcc_link;
- struct in_addr destaddr;
-
-
- true_port = htons(org_port);
- true_addr.s_addr = htonl(org_addr);
- destaddr.s_addr = 0;
-
- /* Steal the FTP_DATA_PORT - it doesn't really matter, and this
- would probably allow it through at least _some_
- firewalls. */
- dcc_link = FindUdpTcpOut (true_addr,
- destaddr,
- true_port,
- 0, IPPROTO_TCP);
- DBprintf(("Got a DCC link\n"));
- if ( dcc_link ) {
- struct in_addr alias_address; /* Address from aliasing */
- u_short alias_port; /* Port given by aliasing */
-
-#ifndef NO_FW_PUNCH
- /* Generate firewall hole as appropriate */
- PunchFWHole(dcc_link);
-#endif
-
- alias_address = GetAliasAddress(link);
- iCopy += snprintf(&newpacket[iCopy],
- sizeof(newpacket)-iCopy,
- "%lu ", (u_long)htonl(alias_address.s_addr));
- if( iCopy >= sizeof(newpacket) ) { /* Truncated/fit exactly - bad news */
- DBprintf(("DCC constructed packet overflow.\n"));
- goto lBAD_CTCP;
- }
- alias_port = GetAliasPort(dcc_link);
- iCopy += snprintf(&newpacket[iCopy],
- sizeof(newpacket)-iCopy,
- "%u", htons(alias_port) );
- /* Done - truncated cases will be taken care of by lBAD_CTCP */
- DBprintf(("Aliased IP %lu and port %u\n", alias_address.s_addr, (unsigned)alias_port));
- }
- }
- /* An uninteresting CTCP - state entered right after '\001' has
- been pushed. Also used to copy the rest of a DCC, after IP
- address and port has been handled */
- lBAD_CTCP:
- for(; i<dlen && iCopy<sizeof(newpacket); i++,iCopy++) {
- newpacket[iCopy] = sptr[i]; /* Copy CTCP unchanged */
- if(sptr[i] == '\001') {
- goto lNORMAL_TEXT;
- }
- }
- goto lPACKET_DONE;
- /* Normal text */
- lNORMAL_TEXT:
- for(; i<dlen && iCopy<sizeof(newpacket); i++,iCopy++) {
- newpacket[iCopy] = sptr[i]; /* Copy CTCP unchanged */
- if(sptr[i] == '\001') {
- goto lCTCP_START;
- }
- }
- /* Handle the end of a packet */
- lPACKET_DONE:
- iCopy = iCopy > maxsize-copyat ? maxsize-copyat : iCopy;
- memcpy(sptr+copyat, newpacket, iCopy);
-
-/* Save information regarding modified seq and ack numbers */
- {
- int delta;
-
- SetAckModified(link);
- delta = GetDeltaSeqOut(pip, link);
- AddSeq(pip, link, delta+copyat+iCopy-dlen);
- }
-
- /* Revise IP header */
- {
- u_short new_len;
-
- new_len = htons(hlen + iCopy + copyat);
- DifferentialChecksum(&pip->ip_sum,
- &new_len,
- &pip->ip_len,
- 1);
- pip->ip_len = new_len;
- }
-
- /* Compute TCP checksum for revised packet */
- tc->th_sum = 0;
- tc->th_sum = TcpChecksum(pip);
- return;
- }
-}
-
-/* Notes:
- [Note 1]
- The initial search will most often fail; it could be replaced with a 32-bit specific search.
- Such a search would be done for 32-bit unsigned value V:
- V ^= 0x01010101; (Search is for null bytes)
- if( ((V-0x01010101)^V) & 0x80808080 ) {
- (found a null bytes which was a 01 byte)
- }
- To assert that the processor is 32-bits, do
- extern int ircdccar[32]; (32 bits)
- extern int ircdccar[CHAR_BIT*sizeof(unsigned int)];
- which will generate a type-error on all but 32-bit machines.
-
- [Note 2] This routine really ought to be replaced with one that
- creates a transparent proxy on the aliasing host, to allow arbitary
- changes in the TCP stream. This should not be too difficult given
- this base; I (ee) will try to do this some time later.
- */
diff --git a/sys/netinet/libalias/alias_local.h b/sys/netinet/libalias/alias_local.h
deleted file mode 100644
index 6b4389c8ee39..000000000000
--- a/sys/netinet/libalias/alias_local.h
+++ /dev/null
@@ -1,172 +0,0 @@
-/* -*- mode: c; tab-width: 3; c-basic-offset: 3; -*-
- Alias_local.h contains the function prototypes for alias.c,
- alias_db.c, alias_util.c and alias_ftp.c, alias_irc.c (as well
- as any future add-ons). It also includes macros, globals and
- struct definitions shared by more than one alias*.c file.
-
- This include file is intended to be used only within the aliasing
- software. Outside world interfaces are defined in alias.h
-
- This software is placed into the public domain with no restrictions
- on its distribution.
-
- Initial version: August, 1996 (cjm)
-
- <updated several times by original author and Eivind Eklund>
-
- $FreeBSD$
-*/
-#ifndef ALIAS_LOCAL_H
-#define ALIAS_LOCAL_H
-
-
-/*
- Macros
- */
-
-/*
- The following macro is used to update an
- internet checksum. "delta" is a 32-bit
- accumulation of all the changes to the
- checksum (adding in new 16-bit words and
- subtracting out old words), and "cksum"
- is the checksum value to be updated.
-*/
-#define ADJUST_CHECKSUM(acc, cksum) { \
- acc += cksum; \
- if (acc < 0) \
- { \
- acc = -acc; \
- acc = (acc >> 16) + (acc & 0xffff); \
- acc += acc >> 16; \
- cksum = (u_short) ~acc; \
- } \
- else \
- { \
- acc = (acc >> 16) + (acc & 0xffff); \
- acc += acc >> 16; \
- cksum = (u_short) acc; \
- } \
-}
-
-
-/*
- Globals
-*/
-
-extern int packetAliasMode;
-
-
-/*
- Structs
-*/
-
-struct alias_link; /* Incomplete structure */
-
-
-/*
- Prototypes
-*/
-
-/* General utilities */
-u_short IpChecksum(struct ip *);
-u_short TcpChecksum(struct ip *);
-void DifferentialChecksum(u_short *, u_short *, u_short *, int);
-
-/* Internal data access */
-struct alias_link *
-FindIcmpIn(struct in_addr, struct in_addr, u_short);
-
-struct alias_link *
-FindIcmpOut(struct in_addr, struct in_addr, u_short);
-
-struct alias_link *
-FindFragmentIn1(struct in_addr, struct in_addr, u_short);
-
-struct alias_link *
-FindFragmentIn2(struct in_addr, struct in_addr, u_short);
-
-struct alias_link *
-AddFragmentPtrLink(struct in_addr, u_short);
-
-struct alias_link *
-FindFragmentPtr(struct in_addr, u_short);
-
-struct alias_link *
-FindUdpTcpIn (struct in_addr, struct in_addr, u_short, u_short, u_char);
-
-struct alias_link *
-FindUdpTcpOut(struct in_addr, struct in_addr, u_short, u_short, u_char);
-
-struct in_addr
-FindOriginalAddress(struct in_addr);
-
-struct in_addr
-FindAliasAddress(struct in_addr);
-
-/* External data access/modification */
-void GetFragmentAddr(struct alias_link *, struct in_addr *);
-void SetFragmentAddr(struct alias_link *, struct in_addr);
-void GetFragmentPtr(struct alias_link *, char **);
-void SetFragmentPtr(struct alias_link *, char *);
-void SetStateIn(struct alias_link *, int);
-void SetStateOut(struct alias_link *, int);
-int GetStateIn(struct alias_link *);
-int GetStateOut(struct alias_link *);
-struct in_addr GetOriginalAddress(struct alias_link *);
-struct in_addr GetDestAddress(struct alias_link *);
-struct in_addr GetAliasAddress(struct alias_link *);
-struct in_addr GetDefaultAliasAddress(void);
-void SetDefaultAliasAddress(struct in_addr);
-u_short GetOriginalPort(struct alias_link *);
-u_short GetAliasPort(struct alias_link *);
-struct in_addr GetProxyAddress(struct alias_link *);
-void SetProxyAddress(struct alias_link *, struct in_addr);
-u_short GetProxyPort(struct alias_link *);
-void SetProxyPort(struct alias_link *, u_short);
-void SetAckModified(struct alias_link *);
-int GetAckModified(struct alias_link *);
-int GetDeltaAckIn(struct ip *, struct alias_link *);
-int GetDeltaSeqOut(struct ip *, struct alias_link *);
-void AddSeq(struct ip *, struct alias_link *, int);
-void SetExpire(struct alias_link *, int);
-void ClearCheckNewLink(void);
-#ifndef NO_FW_PUNCH
-void PunchFWHole(struct alias_link *);
-#endif
-
-
-/* Housekeeping function */
-void HouseKeeping(void);
-
-/* Tcp specfic routines */
-/*lint -save -library Suppress flexelint warnings */
-
-/* FTP routines */
-void AliasHandleFtpOut(struct ip *, struct alias_link *, int);
-
-/* IRC routines */
-void AliasHandleIrcOut(struct ip *, struct alias_link *, int);
-
-/* NetBIOS routines */
-int AliasHandleUdpNbt(struct ip *, struct alias_link *, struct in_addr *, u_short);
-int AliasHandleUdpNbtNS(struct ip *, struct alias_link *, struct in_addr *, u_short *, struct in_addr *, u_short *);
-
-/* CUSeeMe routines */
-void AliasHandleCUSeeMeOut(struct ip *, struct alias_link *);
-void AliasHandleCUSeeMeIn(struct ip *, struct in_addr);
-
-/* Transparent proxy routines */
-int ProxyCheck(struct ip *, struct in_addr *, u_short *);
-void ProxyModify(struct alias_link *, struct ip *, int, int);
-
-
-enum alias_tcp_state {
- ALIAS_TCP_STATE_NOT_CONNECTED,
- ALIAS_TCP_STATE_CONNECTED,
- ALIAS_TCP_STATE_DISCONNECTED
-};
-
-int GetPptpAlias (struct in_addr*);
-/*lint -restore */
-#endif /* defined(ALIAS_LOCAL_H) */
diff --git a/sys/netinet/libalias/alias_nbt.c b/sys/netinet/libalias/alias_nbt.c
deleted file mode 100644
index b5afedf1ab56..000000000000
--- a/sys/netinet/libalias/alias_nbt.c
+++ /dev/null
@@ -1,711 +0,0 @@
-/*
- * Written by Atsushi Murai <amurai@spec.co.jp>
- *
- * Copyright (C) 1998, System Planning and Engineering Co. All rights reserverd.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the System Planning and Engineering Co. The name of the
- * SPEC 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 WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * $FreeBSD$
- *
- * TODO:
- * oClean up.
- * oConsidering for word alignment for other platform.
- */
-/*
- alias_nbt.c performs special processing for NetBios over TCP/IP
- sessions by UDP.
-
- Initial version: May, 1998 (Atsushi Murai <amurai@spec.co.jp>)
-
- See HISTORY file for record of revisions.
-*/
-
-/* Includes */
-#include <ctype.h>
-#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <netinet/in_systm.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netinet/ip.h>
-#include <netinet/udp.h>
-#include <netinet/tcp.h>
-
-#include "alias_local.h"
-
-#define ADJUST_CHECKSUM(acc, cksum) { \
- acc += cksum; \
- if (acc < 0) \
- { \
- acc = -acc; \
- acc = (acc >> 16) + (acc & 0xffff); \
- acc += acc >> 16; \
- cksum = (u_short) ~acc; \
- } \
- else \
- { \
- acc = (acc >> 16) + (acc & 0xffff); \
- acc += acc >> 16; \
- cksum = (u_short) acc; \
- } \
-}
-
-typedef struct {
- struct in_addr oldaddr;
- u_short oldport;
- struct in_addr newaddr;
- u_short newport;
- u_short *uh_sum;
-} NBTArguments;
-
-typedef struct {
- unsigned char type;
- unsigned char flags;
- u_short id;
- struct in_addr source_ip;
- u_short source_port;
- u_short len;
- u_short offset;
-} NbtDataHeader;
-
-#define OpQuery 0
-#define OpUnknown 4
-#define OpRegist 5
-#define OpRelease 6
-#define OpWACK 7
-#define OpRefresh 8
-typedef struct {
- u_short nametrid;
- u_short dir:1, opcode:4, nmflags:7, rcode:4;
- u_short qdcount;
- u_short ancount;
- u_short nscount;
- u_short arcount;
-} NbtNSHeader;
-
-#define FMT_ERR 0x1
-#define SRV_ERR 0x2
-#define IMP_ERR 0x4
-#define RFS_ERR 0x5
-#define ACT_ERR 0x6
-#define CFT_ERR 0x7
-
-
-#ifdef DEBUG
-static void PrintRcode( u_char rcode ) {
-
- switch (rcode) {
- case FMT_ERR:
- printf("\nFormat Error.");
- case SRV_ERR:
- printf("\nSever failure.");
- case IMP_ERR:
- printf("\nUnsupported request error.\n");
- case RFS_ERR:
- printf("\nRefused error.\n");
- case ACT_ERR:
- printf("\nActive error.\n");
- case CFT_ERR:
- printf("\nName in conflict error.\n");
- default:
- printf("\n???=%0x\n", rcode );
-
- }
-}
-#endif
-
-
-/* Handling Name field */
-static u_char *AliasHandleName ( u_char *p, char *pmax ) {
-
- u_char *s;
- u_char c;
- int compress;
-
- /* Following length field */
-
- if (p == NULL || (char *)p >= pmax)
- return(NULL);
-
- if (*p & 0xc0 ) {
- p = p + 2;
- if ((char *)p > pmax)
- return(NULL);
- return ((u_char *)p);
- }
- while ( ( *p & 0x3f) != 0x00 ) {
- s = p + 1;
- if ( *p == 0x20 )
- compress = 1;
- else
- compress = 0;
-
- /* Get next length field */
- p = (u_char *)(p + (*p & 0x3f) + 1);
- if ((char *)p > pmax) {
- p = NULL;
- break;
- }
-#ifdef DEBUG
- printf(":");
-#endif
- while (s < p) {
- if ( compress == 1 ) {
- c = (u_char )(((((*s & 0x0f) << 4) | (*(s+1) & 0x0f)) - 0x11));
-#ifdef DEBUG
- if (isprint( c ) )
- printf("%c", c );
- else
- printf("<0x%02x>", c );
-#endif
- s +=2;
- } else {
-#ifdef DEBUG
- printf("%c", *s);
-#endif
- s++;
- }
- }
-#ifdef DEBUG
- printf(":");
-#endif
- fflush(stdout);
- }
-
- /* Set up to out of Name field */
- if (p == NULL || (char *)p >= pmax)
- p = NULL;
- else
- p++;
- return ((u_char *)p);
-}
-
-/*
- * NetBios Datagram Handler (IP/UDP)
- */
-#define DGM_DIRECT_UNIQ 0x10
-#define DGM_DIRECT_GROUP 0x11
-#define DGM_BROADCAST 0x12
-#define DGM_ERROR 0x13
-#define DGM_QUERY 0x14
-#define DGM_POSITIVE_RES 0x15
-#define DGM_NEGATIVE_RES 0x16
-
-int AliasHandleUdpNbt(
- struct ip *pip, /* IP packet to examine/patch */
- struct alias_link *link,
- struct in_addr *alias_address,
- u_short alias_port
-) {
- struct udphdr * uh;
- NbtDataHeader *ndh;
- u_char *p = NULL;
- char *pmax;
-
- /* Calculate data length of UDP packet */
- uh = (struct udphdr *) ((char *) pip + (pip->ip_hl << 2));
- pmax = (char *)uh + ntohs( uh->uh_ulen );
-
- ndh = (NbtDataHeader *)((char *)uh + (sizeof (struct udphdr)));
- if ((char *)(ndh + 1) > pmax)
- return(-1);
-#ifdef DEBUG
- printf("\nType=%02x,", ndh->type );
-#endif
- switch ( ndh->type ) {
- case DGM_DIRECT_UNIQ:
- case DGM_DIRECT_GROUP:
- case DGM_BROADCAST:
- p = (u_char *)ndh + 14;
- p = AliasHandleName ( p, pmax ); /* Source Name */
- p = AliasHandleName ( p, pmax ); /* Destination Name */
- break;
- case DGM_ERROR:
- p = (u_char *)ndh + 11;
- break;
- case DGM_QUERY:
- case DGM_POSITIVE_RES:
- case DGM_NEGATIVE_RES:
- p = (u_char *)ndh + 10;
- p = AliasHandleName ( p, pmax ); /* Destination Name */
- break;
- }
- if (p == NULL || (char *)p > pmax)
- p = NULL;
-#ifdef DEBUG
- printf("%s:%d-->", inet_ntoa(ndh->source_ip), ntohs(ndh->source_port) );
-#endif
- /* Doing a IP address and Port number Translation */
- if ( uh->uh_sum != 0 ) {
- int acc;
- u_short *sptr;
- acc = ndh->source_port;
- acc -= alias_port;
- sptr = (u_short *) &(ndh->source_ip);
- acc += *sptr++;
- acc += *sptr;
- sptr = (u_short *) alias_address;
- acc -= *sptr++;
- acc -= *sptr;
- ADJUST_CHECKSUM(acc, uh->uh_sum)
- }
- ndh->source_ip = *alias_address;
- ndh->source_port = alias_port;
-#ifdef DEBUG
- printf("%s:%d\n", inet_ntoa(ndh->source_ip), ntohs(ndh->source_port) );
- fflush(stdout);
-#endif
- return((p == NULL) ? -1 : 0);
-}
-/* Question Section */
-#define QS_TYPE_NB 0x0020
-#define QS_TYPE_NBSTAT 0x0021
-#define QS_CLAS_IN 0x0001
-typedef struct {
- u_short type; /* The type of Request */
- u_short class; /* The class of Request */
-} NBTNsQuestion;
-
-static u_char *
-AliasHandleQuestion(
- u_short count,
- NBTNsQuestion *q,
- char *pmax,
- NBTArguments *nbtarg)
-{
-
- while ( count != 0 ) {
- /* Name Filed */
- q = (NBTNsQuestion *)AliasHandleName((u_char *)q, pmax);
-
- if (q == NULL || (char *)(q + 1) > pmax) {
- q = NULL;
- break;
- }
-
- /* Type and Class filed */
- switch ( ntohs(q->type) ) {
- case QS_TYPE_NB:
- case QS_TYPE_NBSTAT:
- q= q+1;
- break;
- default:
-#ifdef DEBUG
- printf("\nUnknown Type on Question %0x\n", ntohs(q->type) );
-#endif
- break;
- }
- count--;
- }
-
- /* Set up to out of Question Section */
- return ((u_char *)q);
-}
-
-/* Resource Record */
-#define RR_TYPE_A 0x0001
-#define RR_TYPE_NS 0x0002
-#define RR_TYPE_NULL 0x000a
-#define RR_TYPE_NB 0x0020
-#define RR_TYPE_NBSTAT 0x0021
-#define RR_CLAS_IN 0x0001
-#define SizeOfNsResource 8
-typedef struct {
- u_short type;
- u_short class;
- unsigned int ttl;
- u_short rdlen;
-} NBTNsResource;
-
-#define SizeOfNsRNB 6
-typedef struct {
- u_short g:1, ont:2, resv:13;
- struct in_addr addr;
-} NBTNsRNB;
-
-static u_char *
-AliasHandleResourceNB(
- NBTNsResource *q,
- char *pmax,
- NBTArguments *nbtarg)
-{
- NBTNsRNB *nb;
- u_short bcount;
-
- if (q == NULL || (char *)(q + 1) > pmax)
- return(NULL);
- /* Check out a length */
- bcount = ntohs(q->rdlen);
-
- /* Forward to Resource NB position */
- nb = (NBTNsRNB *)((u_char *)q + SizeOfNsResource);
-
- /* Processing all in_addr array */
-#ifdef DEBUG
- printf("NB rec[%s", inet_ntoa(nbtarg->oldaddr));
- printf("->%s, %dbytes] ",inet_ntoa(nbtarg->newaddr ), bcount);
-#endif
- while ( nb != NULL && bcount != 0 ) {
- if ((char *)(nb + 1) > pmax) {
- nb = NULL;
- break;
- }
-#ifdef DEBUG
- printf("<%s>", inet_ntoa(nb->addr) );
-#endif
- if (!bcmp(&nbtarg->oldaddr,&nb->addr, sizeof(struct in_addr) ) ) {
- if ( *nbtarg->uh_sum != 0 ) {
- int acc;
- u_short *sptr;
-
- sptr = (u_short *) &(nb->addr);
- acc = *sptr++;
- acc += *sptr;
- sptr = (u_short *) &(nbtarg->newaddr);
- acc -= *sptr++;
- acc -= *sptr;
- ADJUST_CHECKSUM(acc, *nbtarg->uh_sum)
- }
-
- nb->addr = nbtarg->newaddr;
-#ifdef DEBUG
- printf("O");
-#endif
- }
-#ifdef DEBUG
- else {
- printf(".");
- }
-#endif
- nb=(NBTNsRNB *)((u_char *)nb + SizeOfNsRNB);
- bcount -= SizeOfNsRNB;
- }
- if (nb == NULL || (char *)(nb + 1) > pmax) {
- nb = NULL;
- }
-
- return ((u_char *)nb);
-}
-
-#define SizeOfResourceA 6
-typedef struct {
- struct in_addr addr;
-} NBTNsResourceA;
-
-static u_char *
-AliasHandleResourceA(
- NBTNsResource *q,
- char *pmax,
- NBTArguments *nbtarg)
-{
- NBTNsResourceA *a;
- u_short bcount;
-
- if (q == NULL || (char *)(q + 1) > pmax)
- return(NULL);
-
- /* Forward to Resource A position */
- a = (NBTNsResourceA *)( (u_char *)q + sizeof(NBTNsResource) );
-
- /* Check out of length */
- bcount = ntohs(q->rdlen);
-
- /* Processing all in_addr array */
-#ifdef DEBUG
- printf("Arec [%s", inet_ntoa(nbtarg->oldaddr));
- printf("->%s]",inet_ntoa(nbtarg->newaddr ));
-#endif
- while ( bcount != 0 ) {
- if (a == NULL || (char *)(a + 1) > pmax)
- return(NULL);
-#ifdef DEBUG
- printf("..%s", inet_ntoa(a->addr) );
-#endif
- if ( !bcmp(&nbtarg->oldaddr, &a->addr, sizeof(struct in_addr) ) ) {
- if ( *nbtarg->uh_sum != 0 ) {
- int acc;
- u_short *sptr;
-
- sptr = (u_short *) &(a->addr); /* Old */
- acc = *sptr++;
- acc += *sptr;
- sptr = (u_short *) &nbtarg->newaddr; /* New */
- acc -= *sptr++;
- acc -= *sptr;
- ADJUST_CHECKSUM(acc, *nbtarg->uh_sum)
- }
-
- a->addr = nbtarg->newaddr;
- }
- a++; /*XXXX*/
- bcount -= SizeOfResourceA;
- }
- if (a == NULL || (char *)(a + 1) > pmax)
- a = NULL;
- return ((u_char *)a);
-}
-
-typedef struct {
- u_short opcode:4, flags:8, resv:4;
-} NBTNsResourceNULL;
-
-static u_char *
-AliasHandleResourceNULL(
- NBTNsResource *q,
- char *pmax,
- NBTArguments *nbtarg)
-{
- NBTNsResourceNULL *n;
- u_short bcount;
-
- if (q == NULL || (char *)(q + 1) > pmax)
- return(NULL);
-
- /* Forward to Resource NULL position */
- n = (NBTNsResourceNULL *)( (u_char *)q + sizeof(NBTNsResource) );
-
- /* Check out of length */
- bcount = ntohs(q->rdlen);
-
- /* Processing all in_addr array */
- while ( bcount != 0 ) {
- if ((char *)(n + 1) > pmax) {
- n = NULL;
- break;
- }
- n++;
- bcount -= sizeof(NBTNsResourceNULL);
- }
- if ((char *)(n + 1) > pmax)
- n = NULL;
-
- return ((u_char *)n);
-}
-
-static u_char *
-AliasHandleResourceNS(
- NBTNsResource *q,
- char *pmax,
- NBTArguments *nbtarg)
-{
- NBTNsResourceNULL *n;
- u_short bcount;
-
- if (q == NULL || (char *)(q + 1) > pmax)
- return(NULL);
-
- /* Forward to Resource NULL position */
- n = (NBTNsResourceNULL *)( (u_char *)q + sizeof(NBTNsResource) );
-
- /* Check out of length */
- bcount = ntohs(q->rdlen);
-
- /* Resource Record Name Filed */
- q = (NBTNsResource *)AliasHandleName( (u_char *)n, pmax ); /* XXX */
-
- if (q == NULL || (char *)((u_char *)n + bcount) > pmax)
- return(NULL);
- else
- return ((u_char *)n + bcount);
-}
-
-typedef struct {
- u_short numnames;
-} NBTNsResourceNBSTAT;
-
-static u_char *
-AliasHandleResourceNBSTAT(
- NBTNsResource *q,
- char *pmax,
- NBTArguments *nbtarg)
-{
- NBTNsResourceNBSTAT *n;
- u_short bcount;
-
- if (q == NULL || (char *)(q + 1) > pmax)
- return(NULL);
-
- /* Forward to Resource NBSTAT position */
- n = (NBTNsResourceNBSTAT *)( (u_char *)q + sizeof(NBTNsResource) );
-
- /* Check out of length */
- bcount = ntohs(q->rdlen);
-
- if (q == NULL || (char *)((u_char *)n + bcount) > pmax)
- return(NULL);
- else
- return ((u_char *)n + bcount);
-}
-
-static u_char *
-AliasHandleResource(
- u_short count,
- NBTNsResource *q,
- char *pmax,
- NBTArguments
- *nbtarg)
-{
- while ( count != 0 ) {
- /* Resource Record Name Filed */
- q = (NBTNsResource *)AliasHandleName( (u_char *)q, pmax );
-
- if (q == NULL || (char *)(q + 1) > pmax)
- break;
-#ifdef DEBUG
- printf("type=%02x, count=%d\n", ntohs(q->type), count );
-#endif
-
- /* Type and Class filed */
- switch ( ntohs(q->type) ) {
- case RR_TYPE_NB:
- q = (NBTNsResource *)AliasHandleResourceNB(
- q,
- pmax,
- nbtarg
- );
- break;
- case RR_TYPE_A:
- q = (NBTNsResource *)AliasHandleResourceA(
- q,
- pmax,
- nbtarg
- );
- break;
- case RR_TYPE_NS:
- q = (NBTNsResource *)AliasHandleResourceNS(
- q,
- pmax,
- nbtarg
- );
- break;
- case RR_TYPE_NULL:
- q = (NBTNsResource *)AliasHandleResourceNULL(
- q,
- pmax,
- nbtarg
- );
- break;
- case RR_TYPE_NBSTAT:
- q = (NBTNsResource *)AliasHandleResourceNBSTAT(
- q,
- pmax,
- nbtarg
- );
- break;
- default:
-#ifdef DEBUG
- printf(
- "\nUnknown Type of Resource %0x\n",
- ntohs(q->type)
- );
-#endif
- break;
- }
- count--;
- }
- fflush(stdout);
- return ((u_char *)q);
-}
-
-int AliasHandleUdpNbtNS(
- struct ip *pip, /* IP packet to examine/patch */
- struct alias_link *link,
- struct in_addr *alias_address,
- u_short *alias_port,
- struct in_addr *original_address,
- u_short *original_port )
-{
- struct udphdr * uh;
- NbtNSHeader * nsh;
- u_char * p;
- char *pmax;
- NBTArguments nbtarg;
-
- /* Set up Common Parameter */
- nbtarg.oldaddr = *alias_address;
- nbtarg.oldport = *alias_port;
- nbtarg.newaddr = *original_address;
- nbtarg.newport = *original_port;
-
- /* Calculate data length of UDP packet */
- uh = (struct udphdr *) ((char *) pip + (pip->ip_hl << 2));
- nbtarg.uh_sum = &(uh->uh_sum);
- nsh = (NbtNSHeader *)((char *)uh + (sizeof(struct udphdr)));
- p = (u_char *)(nsh + 1);
- pmax = (char *)uh + ntohs( uh->uh_ulen );
-
- if ((char *)(nsh + 1) > pmax)
- return(-1);
-
-#ifdef DEBUG
- printf(" [%s] ID=%02x, op=%01x, flag=%02x, rcode=%01x, qd=%04x"
- ", an=%04x, ns=%04x, ar=%04x, [%d]-->",
- nsh->dir ? "Response": "Request",
- nsh->nametrid,
- nsh->opcode,
- nsh->nmflags,
- nsh->rcode,
- ntohs(nsh->qdcount),
- ntohs(nsh->ancount),
- ntohs(nsh->nscount),
- ntohs(nsh->arcount),
- (u_char *)p -(u_char *)nsh
- );
-#endif
-
- /* Question Entries */
- if (ntohs(nsh->qdcount) !=0 ) {
- p = AliasHandleQuestion(
- ntohs(nsh->qdcount),
- (NBTNsQuestion *)p,
- pmax,
- &nbtarg
- );
- }
-
- /* Answer Resource Records */
- if (ntohs(nsh->ancount) !=0 ) {
- p = AliasHandleResource(
- ntohs(nsh->ancount),
- (NBTNsResource *)p,
- pmax,
- &nbtarg
- );
- }
-
- /* Authority Resource Recodrs */
- if (ntohs(nsh->nscount) !=0 ) {
- p = AliasHandleResource(
- ntohs(nsh->nscount),
- (NBTNsResource *)p,
- pmax,
- &nbtarg
- );
- }
-
- /* Additional Resource Recodrs */
- if (ntohs(nsh->arcount) !=0 ) {
- p = AliasHandleResource(
- ntohs(nsh->arcount),
- (NBTNsResource *)p,
- pmax,
- &nbtarg
- );
- }
-
-#ifdef DEBUG
- PrintRcode(nsh->rcode);
-#endif
- return ((p == NULL) ? -1 : 0);
-}
diff --git a/sys/netinet/libalias/alias_proxy.c b/sys/netinet/libalias/alias_proxy.c
deleted file mode 100644
index 02e176532232..000000000000
--- a/sys/netinet/libalias/alias_proxy.c
+++ /dev/null
@@ -1,807 +0,0 @@
-/* file: alias_proxy.c
-
- This file encapsulates special operations related to transparent
- proxy redirection. This is where packets with a particular destination,
- usually tcp port 80, are redirected to a proxy server.
-
- When packets are proxied, the destination address and port are
- modified. In certain cases, it is necessary to somehow encode
- the original address/port info into the packet. Two methods are
- presently supported: addition of a [DEST addr port] string at the
- beginning a of tcp stream, or inclusion of an optional field
- in the IP header.
-
- There is one public API function:
-
- PacketAliasProxyRule() -- Adds and deletes proxy
- rules.
-
- Rules are stored in a linear linked list, so lookup efficiency
- won't be too good for large lists.
-
-
- Initial development: April, 1998 (cjm)
-
- $FreeBSD$
-*/
-
-
-/* System includes */
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <netdb.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-
-/* BSD IPV4 includes */
-#include <netinet/in_systm.h>
-#include <netinet/in.h>
-#include <netinet/ip.h>
-#include <netinet/tcp.h>
-
-#include <arpa/inet.h>
-
-#include "alias_local.h" /* Functions used by alias*.c */
-#include "alias.h" /* Public API functions for libalias */
-
-
-
-/*
- Data structures
- */
-
-/*
- * A linked list of arbitrary length, based on struct proxy_entry is
- * used to store proxy rules.
- */
-struct proxy_entry
-{
-#define PROXY_TYPE_ENCODE_NONE 1
-#define PROXY_TYPE_ENCODE_TCPSTREAM 2
-#define PROXY_TYPE_ENCODE_IPHDR 3
- int rule_index;
- int proxy_type;
- u_char proto;
- u_short proxy_port;
- u_short server_port;
-
- struct in_addr server_addr;
-
- struct in_addr src_addr;
- struct in_addr src_mask;
-
- struct in_addr dst_addr;
- struct in_addr dst_mask;
-
- struct proxy_entry *next;
- struct proxy_entry *last;
-};
-
-
-
-/*
- File scope variables
-*/
-
-static struct proxy_entry *proxyList;
-
-
-
-/* Local (static) functions:
-
- IpMask() -- Utility function for creating IP
- masks from integer (1-32) specification.
- IpAddr() -- Utility function for converting string
- to IP address
- IpPort() -- Utility function for converting string
- to port number
- RuleAdd() -- Adds an element to the rule list.
- RuleDelete() -- Removes an element from the rule list.
- RuleNumberDelete() -- Removes all elements from the rule list
- having a certain rule number.
- ProxyEncodeTcpStream() -- Adds [DEST x.x.x.x xxxx] to the beginning
- of a TCP stream.
- ProxyEncodeIpHeader() -- Adds an IP option indicating the true
- destination of a proxied IP packet
-*/
-
-static int IpMask(int, struct in_addr *);
-static int IpAddr(char *, struct in_addr *);
-static int IpPort(char *, int, int *);
-static void RuleAdd(struct proxy_entry *);
-static void RuleDelete(struct proxy_entry *);
-static int RuleNumberDelete(int);
-static void ProxyEncodeTcpStream(struct alias_link *, struct ip *, int);
-static void ProxyEncodeIpHeader(struct ip *, int);
-
-static int
-IpMask(int nbits, struct in_addr *mask)
-{
- int i;
- u_int imask;
-
- if (nbits < 0 || nbits > 32)
- return -1;
-
- imask = 0;
- for (i=0; i<nbits; i++)
- imask = (imask >> 1) + 0x80000000;
- mask->s_addr = htonl(imask);
-
- return 0;
-}
-
-static int
-IpAddr(char *s, struct in_addr *addr)
-{
- if (inet_aton(s, addr) == 0)
- return -1;
- else
- return 0;
-}
-
-static int
-IpPort(char *s, int proto, int *port)
-{
- int n;
-
- n = sscanf(s, "%d", port);
- if (n != 1)
- {
- struct servent *se;
-
- if (proto == IPPROTO_TCP)
- se = getservbyname(s, "tcp");
- else if (proto == IPPROTO_UDP)
- se = getservbyname(s, "udp");
- else
- return -1;
-
- if (se == NULL)
- return -1;
-
- *port = (u_int) ntohs(se->s_port);
- }
-
- return 0;
-}
-
-void
-RuleAdd(struct proxy_entry *entry)
-{
- int rule_index;
- struct proxy_entry *ptr;
- struct proxy_entry *ptr_last;
-
- if (proxyList == NULL)
- {
- proxyList = entry;
- entry->last = NULL;
- entry->next = NULL;
- return;
- }
-
- rule_index = entry->rule_index;
- ptr = proxyList;
- ptr_last = NULL;
- while (ptr != NULL)
- {
- if (ptr->rule_index >= rule_index)
- {
- if (ptr_last == NULL)
- {
- entry->next = proxyList;
- entry->last = NULL;
- proxyList->last = entry;
- proxyList = entry;
- return;
- }
-
- ptr_last->next = entry;
- ptr->last = entry;
- entry->last = ptr->last;
- entry->next = ptr;
- return;
- }
- ptr_last = ptr;
- ptr = ptr->next;
- }
-
- ptr_last->next = entry;
- entry->last = ptr_last;
- entry->next = NULL;
-}
-
-static void
-RuleDelete(struct proxy_entry *entry)
-{
- if (entry->last != NULL)
- entry->last->next = entry->next;
- else
- proxyList = entry->next;
-
- if (entry->next != NULL)
- entry->next->last = entry->last;
-
- free(entry);
-}
-
-static int
-RuleNumberDelete(int rule_index)
-{
- int err;
- struct proxy_entry *ptr;
-
- err = -1;
- ptr = proxyList;
- while (ptr != NULL)
- {
- struct proxy_entry *ptr_next;
-
- ptr_next = ptr->next;
- if (ptr->rule_index == rule_index)
- {
- err = 0;
- RuleDelete(ptr);
- }
-
- ptr = ptr_next;
- }
-
- return err;
-}
-
-static void
-ProxyEncodeTcpStream(struct alias_link *link,
- struct ip *pip,
- int maxpacketsize)
-{
- int slen;
- char buffer[40];
- struct tcphdr *tc;
-
-/* Compute pointer to tcp header */
- tc = (struct tcphdr *) ((char *) pip + (pip->ip_hl << 2));
-
-/* Don't modify if once already modified */
-
- if (GetAckModified (link))
- return;
-
-/* Translate destination address and port to string form */
- snprintf(buffer, sizeof(buffer) - 2, "[DEST %s %d]",
- inet_ntoa(GetProxyAddress (link)), (u_int) ntohs(GetProxyPort (link)));
-
-/* Pad string out to a multiple of two in length */
- slen = strlen(buffer);
- switch (slen % 2)
- {
- case 0:
- strcat(buffer, " \n");
- slen += 2;
- break;
- case 1:
- strcat(buffer, "\n");
- slen += 1;
- }
-
-/* Check for packet overflow */
- if ((ntohs(pip->ip_len) + strlen(buffer)) > maxpacketsize)
- return;
-
-/* Shift existing TCP data and insert destination string */
- {
- int dlen;
- int hlen;
- u_char *p;
-
- hlen = (pip->ip_hl + tc->th_off) << 2;
- dlen = ntohs (pip->ip_len) - hlen;
-
-/* Modify first packet that has data in it */
-
- if (dlen == 0)
- return;
-
- p = (char *) pip;
- p += hlen;
-
- memmove(p + slen, p, dlen);
- memcpy(p, buffer, slen);
- }
-
-/* Save information about modfied sequence number */
- {
- int delta;
-
- SetAckModified(link);
- delta = GetDeltaSeqOut(pip, link);
- AddSeq(pip, link, delta+slen);
- }
-
-/* Update IP header packet length and checksum */
- {
- int accumulate;
-
- accumulate = pip->ip_len;
- pip->ip_len = htons(ntohs(pip->ip_len) + slen);
- accumulate -= pip->ip_len;
-
- ADJUST_CHECKSUM(accumulate, pip->ip_sum);
- }
-
-/* Update TCP checksum, Use TcpChecksum since so many things have
- already changed. */
-
- tc->th_sum = 0;
- tc->th_sum = TcpChecksum (pip);
-}
-
-static void
-ProxyEncodeIpHeader(struct ip *pip,
- int maxpacketsize)
-{
-#define OPTION_LEN_BYTES 8
-#define OPTION_LEN_INT16 4
-#define OPTION_LEN_INT32 2
- u_char option[OPTION_LEN_BYTES];
-
-#ifdef DEBUG
- fprintf(stdout, " ip cksum 1 = %x\n", (u_int) IpChecksum(pip));
- fprintf(stdout, "tcp cksum 1 = %x\n", (u_int) TcpChecksum(pip));
-#endif
-
-/* Check to see that there is room to add an IP option */
- if (pip->ip_hl > (0x0f - OPTION_LEN_INT32))
- return;
-
-/* Build option and copy into packet */
- {
- u_char *ptr;
- struct tcphdr *tc;
-
- ptr = (u_char *) pip;
- ptr += 20;
- memcpy(ptr + OPTION_LEN_BYTES, ptr, ntohs(pip->ip_len) - 20);
-
- option[0] = 0x64; /* class: 3 (reserved), option 4 */
- option[1] = OPTION_LEN_BYTES;
-
- memcpy(&option[2], (u_char *) &pip->ip_dst, 4);
-
- tc = (struct tcphdr *) ((char *) pip + (pip->ip_hl << 2));
- memcpy(&option[6], (u_char *) &tc->th_sport, 2);
-
- memcpy(ptr, option, 8);
- }
-
-/* Update checksum, header length and packet length */
- {
- int i;
- int accumulate;
- u_short *sptr;
-
- sptr = (u_short *) option;
- accumulate = 0;
- for (i=0; i<OPTION_LEN_INT16; i++)
- accumulate -= *(sptr++);
-
- sptr = (u_short *) pip;
- accumulate += *sptr;
- pip->ip_hl += OPTION_LEN_INT32;
- accumulate -= *sptr;
-
- accumulate += pip->ip_len;
- pip->ip_len = htons(ntohs(pip->ip_len) + OPTION_LEN_BYTES);
- accumulate -= pip->ip_len;
-
- ADJUST_CHECKSUM(accumulate, pip->ip_sum);
- }
-#undef OPTION_LEN_BYTES
-#undef OPTION_LEN_INT16
-#undef OPTION_LEN_INT32
-#ifdef DEBUG
- fprintf(stdout, " ip cksum 2 = %x\n", (u_int) IpChecksum(pip));
- fprintf(stdout, "tcp cksum 2 = %x\n", (u_int) TcpChecksum(pip));
-#endif
-}
-
-
-/* Functions by other packet alias source files
-
- ProxyCheck() -- Checks whether an outgoing packet should
- be proxied.
- ProxyModify() -- Encodes the original destination address/port
- for a packet which is to be redirected to
- a proxy server.
-*/
-
-int
-ProxyCheck(struct ip *pip,
- struct in_addr *proxy_server_addr,
- u_short *proxy_server_port)
-{
- u_short dst_port;
- struct in_addr src_addr;
- struct in_addr dst_addr;
- struct proxy_entry *ptr;
-
- src_addr = pip->ip_src;
- dst_addr = pip->ip_dst;
- dst_port = ((struct tcphdr *) ((char *) pip + (pip->ip_hl << 2)))
- ->th_dport;
-
- ptr = proxyList;
- while (ptr != NULL)
- {
- u_short proxy_port;
-
- proxy_port = ptr->proxy_port;
- if ((dst_port == proxy_port || proxy_port == 0)
- && pip->ip_p == ptr->proto
- && src_addr.s_addr != ptr->server_addr.s_addr)
- {
- struct in_addr src_addr_masked;
- struct in_addr dst_addr_masked;
-
- src_addr_masked.s_addr = src_addr.s_addr & ptr->src_mask.s_addr;
- dst_addr_masked.s_addr = dst_addr.s_addr & ptr->dst_mask.s_addr;
-
- if ((src_addr_masked.s_addr == ptr->src_addr.s_addr)
- && (dst_addr_masked.s_addr == ptr->dst_addr.s_addr))
- {
- if ((*proxy_server_port = ptr->server_port) == 0)
- *proxy_server_port = dst_port;
- *proxy_server_addr = ptr->server_addr;
- return ptr->proxy_type;
- }
- }
- ptr = ptr->next;
- }
-
- return 0;
-}
-
-void
-ProxyModify(struct alias_link *link,
- struct ip *pip,
- int maxpacketsize,
- int proxy_type)
-{
- switch (proxy_type)
- {
- case PROXY_TYPE_ENCODE_IPHDR:
- ProxyEncodeIpHeader(pip, maxpacketsize);
- break;
-
- case PROXY_TYPE_ENCODE_TCPSTREAM:
- ProxyEncodeTcpStream(link, pip, maxpacketsize);
- break;
- }
-}
-
-
-/*
- Public API functions
-*/
-
-int
-PacketAliasProxyRule(const char *cmd)
-{
-/*
- * This function takes command strings of the form:
- *
- * server <addr>[:<port>]
- * [port <port>]
- * [rule n]
- * [proto tcp|udp]
- * [src <addr>[/n]]
- * [dst <addr>[/n]]
- * [type encode_tcp_stream|encode_ip_hdr|no_encode]
- *
- * delete <rule number>
- *
- * Subfields can be in arbitrary order. Port numbers and addresses
- * must be in either numeric or symbolic form. An optional rule number
- * is used to control the order in which rules are searched. If two
- * rules have the same number, then search order cannot be guaranteed,
- * and the rules should be disjoint. If no rule number is specified,
- * then 0 is used, and group 0 rules are always checked before any
- * others.
- */
- int i, n, len;
- int cmd_len;
- int token_count;
- int state;
- char *token;
- char buffer[256];
- char str_port[sizeof(buffer)];
- char str_server_port[sizeof(buffer)];
-
- int rule_index;
- int proto;
- int proxy_type;
- int proxy_port;
- int server_port;
- struct in_addr server_addr;
- struct in_addr src_addr, src_mask;
- struct in_addr dst_addr, dst_mask;
- struct proxy_entry *proxy_entry;
-
-/* Copy command line into a buffer */
- cmd_len = strlen(cmd);
- if (cmd_len > (sizeof(buffer) - 1))
- return -1;
- strcpy(buffer, cmd);
-
-/* Convert to lower case */
- len = strlen(buffer);
- for (i=0; i<len; i++)
- buffer[i] = tolower(buffer[i]);
-
-/* Set default proxy type */
-
-/* Set up default values */
- rule_index = 0;
- proxy_type = PROXY_TYPE_ENCODE_NONE;
- proto = IPPROTO_TCP;
- proxy_port = 0;
- server_addr.s_addr = 0;
- server_port = 0;
- src_addr.s_addr = 0;
- IpMask(0, &src_mask);
- dst_addr.s_addr = 0;
- IpMask(0, &dst_mask);
-
- str_port[0] = 0;
- str_server_port[0] = 0;
-
-/* Parse command string with state machine */
-#define STATE_READ_KEYWORD 0
-#define STATE_READ_TYPE 1
-#define STATE_READ_PORT 2
-#define STATE_READ_SERVER 3
-#define STATE_READ_RULE 4
-#define STATE_READ_DELETE 5
-#define STATE_READ_PROTO 6
-#define STATE_READ_SRC 7
-#define STATE_READ_DST 8
- state = STATE_READ_KEYWORD;
- token = strtok(buffer, " \t");
- token_count = 0;
- while (token != NULL)
- {
- token_count++;
- switch (state)
- {
- case STATE_READ_KEYWORD:
- if (strcmp(token, "type") == 0)
- state = STATE_READ_TYPE;
- else if (strcmp(token, "port") == 0)
- state = STATE_READ_PORT;
- else if (strcmp(token, "server") == 0)
- state = STATE_READ_SERVER;
- else if (strcmp(token, "rule") == 0)
- state = STATE_READ_RULE;
- else if (strcmp(token, "delete") == 0)
- state = STATE_READ_DELETE;
- else if (strcmp(token, "proto") == 0)
- state = STATE_READ_PROTO;
- else if (strcmp(token, "src") == 0)
- state = STATE_READ_SRC;
- else if (strcmp(token, "dst") == 0)
- state = STATE_READ_DST;
- else
- return -1;
- break;
-
- case STATE_READ_TYPE:
- if (strcmp(token, "encode_ip_hdr") == 0)
- proxy_type = PROXY_TYPE_ENCODE_IPHDR;
- else if (strcmp(token, "encode_tcp_stream") == 0)
- proxy_type = PROXY_TYPE_ENCODE_TCPSTREAM;
- else if (strcmp(token, "no_encode") == 0)
- proxy_type = PROXY_TYPE_ENCODE_NONE;
- else
- return -1;
- state = STATE_READ_KEYWORD;
- break;
-
- case STATE_READ_PORT:
- strcpy(str_port, token);
- state = STATE_READ_KEYWORD;
- break;
-
- case STATE_READ_SERVER:
- {
- int err;
- char *p;
- char s[sizeof(buffer)];
-
- p = token;
- while (*p != ':' && *p != 0)
- p++;
-
- if (*p != ':')
- {
- err = IpAddr(token, &server_addr);
- if (err)
- return -1;
- }
- else
- {
- *p = ' ';
-
- n = sscanf(token, "%s %s", s, str_server_port);
- if (n != 2)
- return -1;
-
- err = IpAddr(s, &server_addr);
- if (err)
- return -1;
- }
- }
- state = STATE_READ_KEYWORD;
- break;
-
- case STATE_READ_RULE:
- n = sscanf(token, "%d", &rule_index);
- if (n != 1 || rule_index < 0)
- return -1;
- state = STATE_READ_KEYWORD;
- break;
-
- case STATE_READ_DELETE:
- {
- int err;
- int rule_to_delete;
-
- if (token_count != 2)
- return -1;
-
- n = sscanf(token, "%d", &rule_to_delete);
- if (n != 1)
- return -1;
- err = RuleNumberDelete(rule_to_delete);
- if (err)
- return -1;
- return 0;
- }
-
- case STATE_READ_PROTO:
- if (strcmp(token, "tcp") == 0)
- proto = IPPROTO_TCP;
- else if (strcmp(token, "udp") == 0)
- proto = IPPROTO_UDP;
- else
- return -1;
- state = STATE_READ_KEYWORD;
- break;
-
- case STATE_READ_SRC:
- case STATE_READ_DST:
- {
- int err;
- char *p;
- struct in_addr mask;
- struct in_addr addr;
-
- p = token;
- while (*p != '/' && *p != 0)
- p++;
-
- if (*p != '/')
- {
- IpMask(32, &mask);
- err = IpAddr(token, &addr);
- if (err)
- return -1;
- }
- else
- {
- int n;
- int nbits;
- char s[sizeof(buffer)];
-
- *p = ' ';
- n = sscanf(token, "%s %d", s, &nbits);
- if (n != 2)
- return -1;
-
- err = IpAddr(s, &addr);
- if (err)
- return -1;
-
- err = IpMask(nbits, &mask);
- if (err)
- return -1;
- }
-
- if (state == STATE_READ_SRC)
- {
- src_addr = addr;
- src_mask = mask;
- }
- else
- {
- dst_addr = addr;
- dst_mask = mask;
- }
- }
- state = STATE_READ_KEYWORD;
- break;
-
- default:
- return -1;
- break;
- }
-
- token = strtok(NULL, " \t");
- }
-#undef STATE_READ_KEYWORD
-#undef STATE_READ_TYPE
-#undef STATE_READ_PORT
-#undef STATE_READ_SERVER
-#undef STATE_READ_RULE
-#undef STATE_READ_DELETE
-#undef STATE_READ_PROTO
-#undef STATE_READ_SRC
-#undef STATE_READ_DST
-
-/* Convert port strings to numbers. This needs to be done after
- the string is parsed, because the prototype might not be designated
- before the ports (which might be symbolic entries in /etc/services) */
-
- if (strlen(str_port) != 0)
- {
- int err;
-
- err = IpPort(str_port, proto, &proxy_port);
- if (err)
- return -1;
- }
- else
- {
- proxy_port = 0;
- }
-
- if (strlen(str_server_port) != 0)
- {
- int err;
-
- err = IpPort(str_server_port, proto, &server_port);
- if (err)
- return -1;
- }
- else
- {
- server_port = 0;
- }
-
-/* Check that at least the server address has been defined */
- if (server_addr.s_addr == 0)
- return -1;
-
-/* Add to linked list */
- proxy_entry = malloc(sizeof(struct proxy_entry));
- if (proxy_entry == NULL)
- return -1;
-
- proxy_entry->proxy_type = proxy_type;
- proxy_entry->rule_index = rule_index;
- proxy_entry->proto = proto;
- proxy_entry->proxy_port = htons(proxy_port);
- proxy_entry->server_port = htons(server_port);
- proxy_entry->server_addr = server_addr;
- proxy_entry->src_addr.s_addr = src_addr.s_addr & src_mask.s_addr;
- proxy_entry->dst_addr.s_addr = dst_addr.s_addr & dst_mask.s_addr;
- proxy_entry->src_mask = src_mask;
- proxy_entry->dst_mask = dst_mask;
-
- RuleAdd(proxy_entry);
-
- return 0;
-}
diff --git a/sys/netinet/libalias/alias_util.c b/sys/netinet/libalias/alias_util.c
deleted file mode 100644
index 41ca6cc2c437..000000000000
--- a/sys/netinet/libalias/alias_util.c
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- Alias_util.h contains general utilities used by other functions
- in the packet aliasing module. At the moment, there are functions
- for computing IP header and TCP packet checksums.
-
- The checksum routines are based upon example code in a Unix networking
- text written by Stevens (sorry, I can't remember the title -- but
- at least this is a good author).
-
- Initial Version: August, 1996 (cjm)
-
- Version 1.7: January 9, 1997
- Added differential checksum update function.
-
- $FreeBSD$
-*/
-
-/*
-Note: the checksum routines assume that the actual checksum word has
-been zeroed out. If the checksum workd is filled with the proper value,
-then these routines will give a result of zero (useful for testing
-purposes);
-*/
-
-#include <sys/types.h>
-#include <netinet/in_systm.h>
-#include <netinet/in.h>
-#include <netinet/ip.h>
-#include <netinet/tcp.h>
-
-#include "alias.h"
-#include "alias_local.h"
-
-u_short
-PacketAliasInternetChecksum(u_short *ptr, int nbytes)
-{
- int sum, oddbyte;
-
- sum = 0;
- while (nbytes > 1)
- {
- sum += *ptr++;
- nbytes -= 2;
- }
- if (nbytes == 1)
- {
- oddbyte = 0;
- ((u_char *) &oddbyte)[0] = *(u_char *) ptr;
- ((u_char *) &oddbyte)[1] = 0;
- sum += oddbyte;
- }
- sum = (sum >> 16) + (sum & 0xffff);
- sum += (sum >> 16);
- return(~sum);
-}
-
-u_short
-IpChecksum(struct ip *pip)
-{
- return( PacketAliasInternetChecksum((u_short *) pip,
- (pip->ip_hl << 2)) );
-
-}
-
-u_short
-TcpChecksum(struct ip *pip)
-{
- u_short *ptr;
- struct tcphdr *tc;
- int nhdr, ntcp, nbytes;
- int sum, oddbyte;
-
- nhdr = pip->ip_hl << 2;
- ntcp = ntohs(pip->ip_len) - nhdr;
-
- tc = (struct tcphdr *) ((char *) pip + nhdr);
- ptr = (u_short *) tc;
-
-/* Add up TCP header and data */
- nbytes = ntcp;
- sum = 0;
- while (nbytes > 1)
- {
- sum += *ptr++;
- nbytes -= 2;
- }
- if (nbytes == 1)
- {
- oddbyte = 0;
- ((u_char *) &oddbyte)[0] = *(u_char *) ptr;
- ((u_char *) &oddbyte)[1] = 0;
- sum += oddbyte;
- }
-
-/* "Pseudo-header" data */
- ptr = (u_short *) &(pip->ip_dst);
- sum += *ptr++;
- sum += *ptr;
- ptr = (u_short *) &(pip->ip_src);
- sum += *ptr++;
- sum += *ptr;
- sum += htons((u_short) ntcp);
- sum += htons((u_short) pip->ip_p);
-
-/* Roll over carry bits */
- sum = (sum >> 16) + (sum & 0xffff);
- sum += (sum >> 16);
-
-/* Return checksum */
- return((u_short) ~sum);
-}
-
-
-void
-DifferentialChecksum(u_short *cksum, u_short *new, u_short *old, int n)
-{
- int i;
- int accumulate;
-
- accumulate = *cksum;
- for (i=0; i<n; i++)
- {
- accumulate -= *new++;
- accumulate += *old++;
- }
-
- if (accumulate < 0)
- {
- accumulate = -accumulate;
- accumulate = (accumulate >> 16) + (accumulate & 0xffff);
- accumulate += accumulate >> 16;
- *cksum = (u_short) ~accumulate;
- }
- else
- {
- accumulate = (accumulate >> 16) + (accumulate & 0xffff);
- accumulate += accumulate >> 16;
- *cksum = (u_short) accumulate;
- }
-}
-
diff --git a/sys/netinet/libalias/libalias.3 b/sys/netinet/libalias/libalias.3
deleted file mode 100644
index df1440ca4638..000000000000
--- a/sys/netinet/libalias/libalias.3
+++ /dev/null
@@ -1,890 +0,0 @@
-.\" $FreeBSD$
-.\"
-.Dd July, 1997
-.Dt LIBALIAS 3
-.Os
-.Sh NAME
-.Nm libalias
-.Nd packet aliasing library for masquerading and address translation (NAT)
-.Sh SYNOPSIS
-.Fd #include <sys/types.h>
-.Fd #include <netinet/in.h>
-.Fd #include <alias.h>
-
-Function prototypes are given in the main body
-of the text.
-.Sh DESCRIPTION
-The
-.Nm
-library is a collection of
-functions for aliasing and de-aliasing
-of IP packets, intended for masquerading and
-network address translation (NAT).
-.Sh CONTENTS
-.Bd -literal -offset left
-1. Introduction
-2. Initialization and Control
- 2.1 PacketAliasInit()
- 2.2 PacketAliasUninit()
- 2.3 PacketAliasSetAddress()
- 2.4 PacketAliasSetMode()
- 2.5 PacketAliasSetFWBase()
-3. Packet Handling
- 3.1 PacketAliasIn()
- 3.2 PacketAliasOut()
-4. Port and Address Redirection
- 4.1 PacketAliasRedirectPort()
- 4.2 PacketAliasRedirectAddr()
- 4.3 PacketAliasRedirectDelete()
- 4.4 PacketAliasProxyRule()
- 4.5 PacketAliasPptp()
-5. Fragment Handling
- 5.1 PacketAliasSaveFragment()
- 5.2 PacketAliasGetFragment()
- 5.3 PacketAliasFragmentIn()
-6. Miscellaneous Functions
- 6.1 PacketAliasSetTarget()
- 6.2 PacketAliasCheckNewLink()
- 6.3 PacketAliasInternetChecksum()
-7. Authors
-8. Acknowledgments
-
-Appendix A: Conceptual Background
- A.1 Aliasing Links
- A.2 Static and Dynamic Links
- A.3 Partially Specified Links
- A.4 Dynamic Link Creation
-.Ed
-.Sh 1. Introduction
-This library is a moderately portable
-set of functions designed to assist
-in the process of IP masquerading and
-network address translation. Outgoing
-packets from a local network with
-unregistered IP addresses can be aliased
-to appear as if they came from an
-accessible IP address. Incoming packets
-are then de-aliased so that they are sent
-to the correct machine on the local network.
-
-A certain amount of flexibility is built
-into the packet aliasing engine. In
-the simplest mode of operation, a
-many-to-one address mapping takes place
-between local network and the packet
-aliasing host. This is known as IP
-masquerading. In addition, one-to-one
-mappings between local and public addresses
-can also be implemented, which is known as
-static NAT. In between these extremes,
-different groups of private addresses
-can be linked to different public addresses,
-comprising several distinct many-to-one
-mappings. Also, a given public address
-and port can be statically redirected to
-a private address/port.
-
-The packet aliasing engine was designed
-to operate in user space outside of the
-kernel, without any access to private
-kernel data structure, but the source code
-can also be ported to a kernel environment.
-.Sh 2. Initialization and Control
-Two specific functions, PacketAliasInit()
-and PacketAliasSetAddress(), must always be
-called before any packet handling may be
-performed. In addition, the operating mode
-of the packet aliasing engine can be customized
-by calling PacketAliasSetMode().
-.Ss 2.1 PacketAliasInit()
-
-.Ft void
-.Fn PacketAliasInit "void"
-
-This function has no argument or return
-value and is used to initialize internal
-data structures.
-The following mode bits
-are always set after calling
-PacketAliasInit(). See section 2.3 for
-the meaning of these mode bits.
-.Bd -literal -offset indent
- PKT_ALIAS_USE_SAME_PORTS
- PKT_ALIAS_USE_SOCKETS
- PKT_ALIAS_RESET_ON_ADDR_CHANGE
-
-.Ed
-This function will always return the packet
-aliasing engine to the same initial state.
-PacketAliasSetAddress() must be called afterwards,
-and any desired changes from the default mode
-bits listed above require a call to
-PacketAliasSetMode().
-
-It is mandatory that this function be called
-at the beginning of a program prior to any
-packet handling.
-.Ss 2.2 PacketAliasUninit()
-
-.Ft void
-.Fn PacketAliasUninit "void"
-
-This function has no argument or return
-value and is used to clear any resources
-attached to internal data structures.
-
-This functions should be called when a
-program stop using the aliasing engine;
-it does, amongst other things, clear out any
-firewall holes. To provide backwards
-compatibility and extra security, it is
-added to the atexit() chain by
-PacketAliasInit(). Calling it multiple
-times is harmless.
-.Ss 2.3 PacketAliasSetAddress()
-
-.Ft void
-.Fn PacketAliasSetAddress "struct in_addr addr"
-
-This function sets the source address to which
-outgoing packets from the local area network
-are aliased. All outgoing packets are remapped
-to this address unless overridden by a static
-address mapping established by
-PacketAliasRedirectAddr().
-
-If the PKT_ALIAS_RESET_ON_ADDR_CHANGE mode bit
-is set (the default mode of operation), then
-the internal aliasing link tables will be reset
-any time the aliasing address changes.
-This is useful
-for interfaces such as ppp where the IP
-address may or may not change on successive
-dial-up attempts.
-
-If the PKT_ALIAS_RESET_ON_ADDR_CHANGE mode bit
-is set to zero, this function can also be used to
-dynamically change the aliasing address on a
-packet to packet basis (it is a low overhead
-call).
-
-It is mandatory that this function be called
-prior to any packet handling.
-.Ss 2.4 PacketAliasSetMode()
-
-.Ft unsigned int
-.Fn PacketAliasSetMode "unsigned int mode" "unsigned int mask"
-
-This function sets or clears mode bits
-according to the value of
-.Em mode .
-Only bits marked in
-.Em mask
-are affected. The following mode bits are
-defined in alias.h:
-.Bl -hang -offset left
-.It PKT_ALIAS_LOG.
-Enables logging /var/log/alias.log. The log file
-shows total numbers of links (icmp, tcp, udp) each
-time an aliasing link is created or deleted. Mainly
-useful for debugging when the log file is viewed
-continuously with "tail -f".
-.It PKT_ALIAS_DENY_INCOMING.
-If this mode bit is set, all incoming packets
-associated with new TCP connections or new
-UDP transactions will be marked for being
-ignored (PacketAliasIn() return code
-PKT_ALIAS_IGNORED) by the calling program.
-Response packets to connections or transactions
-initiated from the packet aliasing host or
-local network will be unaffected. This mode
-bit is useful for implementing a one-way firewall.
-.It PKT_ALIAS_SAME_PORTS.
-If this mode bit is set, the packet aliasing
-engine will attempt to leave the alias port
-numbers unchanged from the actual local port
-number. This can be done as long as the
-quintuple (proto, alias addr, alias port,
-remote addr, remote port) is unique. If a
-conflict exists, a new aliasing port number is
-chosen even if this mode bit is set.
-.It PKT_ALIAS_USE_SOCKETS.
-This bit should be set when the packet
-aliasing host originates network traffic as
-well as forwards it. When the packet aliasing
-host is waiting for a connection from an
-unknown host address or unknown port number
-(e.g. an FTP data connection), this mode bit
-specifies that a socket be allocated as a place
-holder to prevent port conflicts. Once a
-connection is established, usually within a
-minute or so, the socket is closed.
-.It PKT_ALIAS_UNREGISTERED_ONLY.
-If this mode bit is set, traffic on the
-local network which does not originate from
-unregistered address spaces will be ignored.
-Standard Class A, B and C unregistered addresses
-are:
-.Bd -literal -offset indent
- 10.0.0.0 -> 10.255.255.255 (Class A subnet)
- 172.16.0.0 -> 172.31.255.255 (Class B subnets)
- 192.168.0.0 -> 192.168.255.255 (Class C subnets)
-
-.Ed
-This option is useful in the case that
-packet aliasing host has both registered and
-unregistered subnets on different interfaces.
-The registered subnet is fully accessible to
-the outside world, so traffic from it doesn't
-need to be passed through the packet aliasing
-engine.
-.It PKT_ALIAS_RESET_ON_ADDR_CHANGE.
-When this mode bit is set and
-PacketAliasSetAddress() is called to change
-the aliasing address, the internal link table
-of the packet aliasing engine will be cleared.
-This operating mode is useful for ppp links
-where the interface address can sometimes
-change or remain the same between dial-ups.
-If this mode bit is not set, the link table
-will never be reset in the event of an
-address change.
-.It PKT_ALIAS_PUNCH_FW.
-This option makes libalias `punch holes' in an
-ipfw based firewall for FTP/IRC DCC connections.
-The holes punched are bound by from/to IP address
-and port; it will not be possible to use a hole
-for another connection. A hole is removed when
-the connection that uses it dies. To cater to
-unexpected death of a program using libalias (e.g
-kill -9), changing the state of the flag will
-clear the entire ipfw range allocated for holes.
-This will also happen on the initial call to
-PacketAliasSetFWBase(). This call must happen
-prior to setting this flag.
-.It PKT_ALIAS_REVERSE.
-This option makes libalias reverse the way it
-handles incoming and outgoing packets, allowing
-it to be fed data that passes through the internal
-interface rather than the external one.
-.It PKT_ALIAS_PROXY_ONLY.
-This option tells libalias to obey transparent proxy
-rules only. Normal packet aliasing is not performed.
-See
-.Fn PacketAliasProxyRule
-below for details.
-.El
-
-.Ss 2.5 PacketAliasSetFWBase()
-
-.Ft void
-.Fn PacketAliasSetFWBase "unsigned int base" "unsigned int num"
-
-Set IPFW range allocated for punching firewall holes (with the
-PKT_ALIAS_PUNCH_FW flag). The range will be cleared for all rules on
-initialization.
-.Sh 3. Packet Handling
-The packet handling functions are used to
-modify incoming (remote->local) and outgoing
-(local->remote) packets. The calling program
-is responsible for receiving and sending
-packets via network interfaces.
-
-Along with PacketAliasInit() and PacketAliasSetAddress(),
-the two packet handling functions, PacketAliasIn()
-and PacketAliasOut(), comprise minimal set of functions
-needed for a basic IP masquerading implementation.
-.Ss 3.1 PacketAliasIn()
-
-.Ft int
-.Fn PacketAliasIn "char *buffer" "int maxpacketsize"
-
-An incoming packet coming from a remote machine to
-the local network is de-aliased by this function.
-The IP packet is pointed to by
-.Em buffer ,
-and
-.Em maxpacketsize
-indicates the size of the data structure containing
-the packet and should be at least as large as the
-actual packet size.
-
-Return codes:
-.Bl -hang -offset left
-.It PKT_ALIAS_ERROR.
-An internal error within the packet aliasing
-engine occurred.
-.It PKT_ALIAS_OK.
-The packet aliasing process was successful.
-.It PKT_ALIAS_IGNORED.
-The packet was ignored and not de-aliased.
-This can happen if the protocol is unrecognized,
-possibly an ICMP message type is not handled or
-if incoming packets for new connections are being
-ignored (see PKT_ALIAS_DENY_INCOMING in section
-2.2).
-.It PKT_ALIAS_UNRESOLVED_FRAGMENT.
-This is returned when a fragment cannot be
-resolved because the header fragment has not
-been sent yet. In this situation, fragments
-must be saved with PacketAliasSaveFragment()
-until a header fragment is found.
-.It PKT_ALIAS_FOUND_HEADER_FRAGMENT.
-The packet aliasing process was successful,
-and a header fragment was found. This is a
-signal to retrieve any unresolved fragments
-with PacketAliasGetFragment() and de-alias
-them with PacketAliasFragmentIn().
-.El
-.Ss 3.2 PacketAliasOut()
-
-.Ft int
-.Fn PacketAliasOut "char *buffer" "int maxpacketsize"
-
-An outgoing packet coming from the local network
-to a remote machine is aliased by this function.
-The IP packet is pointed to by
-.Em buffer ,
-and
-.Em maxpacketsize
-indicates the maximum packet size permissible
-should the packet length be changed. IP encoding
-protocols place address and port information in
-the encapsulated data stream which have to be
-modified and can account for changes in packet
-length. Well known examples of such protocols
-are FTP and IRC DCC.
-
-Return codes:
-.Bl -hang -offset left
-.It PKT_ALIAS_ERROR.
-An internal error within the packet aliasing
-engine occurred.
-.It PKT_ALIAS_OK.
-The packet aliasing process was successful.
-.It PKT_ALIAS_IGNORED.
-The packet was ignored and not de-aliased.
-This can happen if the protocol is unrecognized,
-or possibly an ICMP message type is not handled.
-.El
-.Sh 4. Port and Address Redirection
-The functions described in this section allow machines
-on the local network to be accessible in some degree
-to new incoming connections from the external network.
-Individual ports can be re-mapped or static network
-address translations can be designated.
-.Ss 4.1 PacketAliasRedirectPort()
-
-.Ft struct alias_link *
-.Fo PacketAliasRedirectPort
-.Fa "struct in_addr local_addr"
-.Fa "u_short local_port"
-.Fa "struct in_addr remote_addr"
-.Fa "u_short remote_port"
-.Fa "struct in_addr alias_addr"
-.Fa "u_short alias_port"
-.Fa "u_char proto"
-.Fc
-
-This function specifies that traffic from a
-given remote address/port to an alias address/port
-be redirected to a specified local address/port.
-The parameter
-.Em proto
-can be either IPPROTO_TCP or IPPROTO_UDP, as
-defined in <netinet/in.h>.
-
-If
-.Em local_addr
-or
-.Em alias_addr
-is zero, this indicates that the packet aliasing
-address as established by PacketAliasSetAddress()
-is to be used. Even if PacketAliasSetAddress() is
-called to change the address after PacketAliasRedirectPort()
-is called, a zero reference will track this change.
-
-If
-.Em remote_addr
-is zero, this indicates to redirect packets from
-any remote address. Likewise, if
-.Em remote_port
-is zero, this indicates to redirect packets originating
-from any remote port number. Almost always, the remote
-port specification will be zero, but non-zero remote
-addresses can sometimes be useful for firewalling.
-If two calls to PacketAliasRedirectPort() overlap in
-their address/port specifications, then the most recent
-call will have precedence.
-
-This function returns a pointer which can subsequently
-be used by PacketAliasRedirectDelete(). If NULL is
-returned, then the function call did not complete
-successfully.
-
-All port numbers are in network address byte order,
-so it is necessary to use htons() to convert these
-parameters from internally readable numbers to
-network byte order. Addresses are also in network
-byte order, which is implicit in the use of the
-.Em struct in_addr
-data type.
-.Ss 4.2 PacketAliasRedirectAddr()
-
-.Ft struct alias_link *
-.Fo PacketAliasRedirectAddr
-.Fa "struct in_addr local_addr"
-.Fa "struct in_addr alias_addr"
-.Fc
-
-This function desgnates that all incoming
-traffic to
-.Em alias_addr
-be redirected to
-.Em local_addr.
-Similarly, all outgoing traffic from
-.Em local_addr
-is aliased to
-.Em alias_addr .
-
-If
-.Em local_addr
-or
-.Em alias_addr
-is zero, this indicates that the packet aliasing
-address as established by PacketAliasSetAddress()
-is to be used. Even if PacketAliasSetAddress() is
-called to change the address after PacketAliasRedirectAddr()
-is called, a zero reference will track this change.
-
-If subsequent calls to PacketAliasRedirectAddr()
-use the same aliasing address, all new incoming
-traffic to this aliasing address will be redirected
-to the local address made in the last function call.
-New traffic generated by any of the local machines, designated
-in the several function calls, will be aliased to
-the same address. Consider the following example:
-.Bd -literal -offset left
- PacketAliasRedirectAddr(inet_aton("192.168.0.2"),
- inet_aton("141.221.254.101"));
- PacketAliasRedirectAddr(inet_aton("192.168.0.3"),
- inet_aton("141.221.254.101"));
- PacketAliasRedirectAddr(inet_aton("192.168.0.4"),
- inet_aton("141.221.254.101"));
-.Ed
-
-Any outgoing connections such as telnet or ftp
-from 192.168.0.2, 192.168.0.3, 192.168.0.4 will
-appear to come from 141.221.254.101. Any incoming
-connections to 141.221.254.101 will be directed
-to 192.168.0.4.
-
-Any calls to PacketAliasRedirectPort() will
-have precedence over address mappings designated
-by PacketAliasRedirectAddr().
-
-This function returns a pointer which can subsequently
-be used by PacketAliasRedirectDelete(). If NULL is
-returned, then the function call did not complete
-successfully.
-.Ss 4.3 PacketAliasRedirectDelete()
-
-.Ft void
-.Fn PacketAliasRedirectDelete "struct alias_link *ptr"
-
-This function will delete a specific static redirect
-rule entered by PacketAliasRedirectPort() or
-PacketAliasRedirectAddr(). The parameter
-.Em ptr
-is the pointer returned by either of the redirection
-functions. If an invalid pointer is passed to
-PacketAliasRedirectDelete(), then a program crash
-or unpredictable operation could result, so it is
-necessary to be careful using this function.
-.Ss 4.4 PacketAliasProxyRule()
-
-.Ft int
-.Fn PacketAliasProxyRule "const char *cmd"
-
-The passed
-.Ar cmd
-string consists of one or more pairs of words. The first word in each
-pair is a token and the second is the value that should be applied for
-that token. Tokens and their argument types are as follows:
-
-.Bl -tag -offset XXX -width XXX
-.It type encode_ip_hdr|encode_tcp_stream|no_encode
-In order to support transparent proxying, it is necessary to somehow
-pass the original address and port information into the new destination
-server. If
-.Dq encode_ip_hdr
-is specified, the original address and port is passed as an extra IP
-option. If
-.Dq encode_tcp_stream
-is specified, the original address and port is passed as the first
-piece of data in the tcp stream in the format
-.Dq DEST Ar IP port .
-.It port Ar portnum
-Only packets with the destination port
-.Ar portnum
-are proxied.
-.It server Ar host[:portnum]
-This specifies the
-.Ar host
-and
-.Ar portnum
-that the data is to be redirected to.
-.Ar host
-must be an IP address rather than a DNS host name. If
-.Ar portnum
-is not specified, the destination port number is not changed.
-.Pp
-The
-.Ar server
-specification is mandatory unless the
-.Dq delete
-command is being used.
-.It rule Ar index
-Normally, each call to
-.Fn PacketAliasProxyRule
-inserts the next rule at the start of a linear list of rules. If an
-.Ar index
-is specified, the new rule will be checked after all rules with lower
-indices. Calls to
-.Fn PacketAliasProxyRule
-that do not specify a rule are assigned rule 0.
-.It delete Ar index
-This token and its argument must not be used with any other tokens. When
-used, all existing rules with the given
-.Ar index
-are deleted.
-.It proto tcp|udp
-If specified, only packets of the given protocol type are matched.
-.It src Ar IP[/bits]
-If specified, only packets with a source address matching the given
-.Ar IP
-are matched. If
-.Ar bits
-is also specified, then the first
-.Ar bits
-bits of
-.Ar IP
-are taken as a network specification, and all IP addresses from that
-network will be matched.
-.It dst Ar IP[/bits]
-If specified, only packets with a destination address matching the given
-.Ar IP
-are matched. If
-.Ar bits
-is also specified, then the first
-.Ar bits
-bits of
-.Ar IP
-are taken as a network specification, and all IP addresses from that
-network will be matched.
-.El
-
-This function is usually used to redirect outgoing connections for
-internal machines that are not permitted certain types of internet
-access, or to restrict access to certain external machines.
-.Ss 4.5 PacketAliasPptp()
-
-.Ft extern int
-.Fn PacketAliasPptp "struct in_addr addr"
-
-This function causes any
-.Em G Ns No eneral
-.Em R Ns No outing
-.Em E Ns No ncapsulation
-.Pq Dv IPPROTO_GRE
-packets to be aliased using
-.Ar addr
-rather than the address set via
-.Fn PacketAliasSetAddress .
-This allows the uses of the
-.Em P Ns No oint
-to
-.Em P Ns No oint
-.Em T Ns No unneling
-.Em P Ns No rotocol
-on a machine on the internal network.
-.Pp
-If the passed address is
-.Dv INADDR_NONE
-.Pq 255.255.255.255 ,
-.Dv PPTP
-aliasing is disabled.
-.Sh 5. Fragment Handling
-The functions in this section are used to deal with
-incoming fragments.
-
-Outgoing fragments are handled within PacketAliasOut()
-by changing the address according to any
-applicable mapping set by PacketAliasRedirectAddress(),
-or the default aliasing address set by
-PacketAliasSetAddress().
-
-Incoming fragments are handled in one of two ways.
-If the header of a fragmented IP packet has already
-been seen, then all subsequent fragments will be
-re-mapped in the same manner the header fragment
-was. Fragments which arrive before the header
-are saved and then retrieved once the header fragment
-has been resolved.
-.Ss 5.1 PacketAliasSaveFragment()
-
-.Ft int
-.Fn PacketAliasSaveFragment "char *ptr"
-
-When PacketAliasIn() returns
-PKT_ALIAS_UNRESOLVED_FRAGMENT, this
-function can be used to save the pointer to
-the unresolved fragment.
-
-It is implicitly assumed that
-.Em ptr
-points to a block of memory allocated by
-malloc(). If the fragment is never
-resolved, the packet aliasing engine will
-automatically free the memory after a
-timeout period. [Eventually this function
-should be modified so that a callback
-function for freeing memory is passed as
-an argument.]
-
-This function returns PKT_ALIAS_OK if it
-was successful and PKT_ALIAS_ERROR if there
-was an error.
-
-.Ss 5.2 PacketAliasGetFragment()
-
-.Ft char *
-.Fn PacketAliasGetFragment "char *buffer"
-
-This function can be used to retrieve fragment
-pointers saved by PacketAliasSaveFragment().
-The IP header fragment pointed to by
-.Em buffer
-is the header fragment indicated when
-PacketAliasIn() returns PKT_ALIAS_FOUND_HEADER_FRAGMENT.
-Once a a fragment pointer is retrieved, it
-becomes the calling program's responsibility
-to free the dynamically allocated memory for
-the fragment.
-
-PacketAliasGetFragment() can be called
-sequentially until there are no more fragments
-available, at which time it returns NULL.
-.Ss 5.3 PacketAliasFragmentIn()
-
-.Ft void
-.Fn PacketAliasFragmentIn "char *header" "char *fragment"
-
-When a fragment is retrieved with
-PacketAliasGetFragment(), it can then be
-de-aliased with a call to PacketAliasFragmentIn().
-.Em header
-is the pointer to a header fragment used as a
-template, and
-.Em fragment
-is the pointer to the packet to be de-aliased.
-.Sh 6. Miscellaneous Functions
-
-.Ss 6.1 PacketAliasSetTarget()
-
-.Ft void
-.Fn PacketAliasSetTarget "struct in_addr addr"
-
-When an incoming packet not associated with
-any pre-existing aliasing link arrives at the
-host machine, it will be sent to the address
-indicated by a call to PacketAliasSetTarget().
-
-If this function is not called, or is called
-with a zero address argument, then all new
-incoming packets go to the address set by
-PacketAliasSetAddress.
-.Ss 6.2 PacketAliasCheckNewLink()
-
-.Ft int
-.Fn PacketAliasCheckNewLink "void"
-
-This function returns a non-zero value when
-a new aliasing link is created. In circumstances
-where incoming traffic is being sequentially
-sent to different local servers, this function
-can be used to trigger when PacketAliasSetTarget()
-is called to change the default target address.
-.Ss 6.3 PacketAliasInternetChecksum()
-
-.Ft u_short
-.Fn PacketAliasInternetChecksum "u_short *buffer" "int nbytes"
-
-This is a utility function that does not seem
-to be available elswhere and is included as a
-convenience. It computes the internet checksum,
-which is used in both IP and protocol-specific
-headers (TCP, UDP, ICMP).
-
-.Em buffer
-points to the data block to be checksummed, and
-.Em nbytes
-is the number of bytes. The 16-bit checksum
-field should be zeroed before computing the checksum.
-
-Checksums can also be verified by operating on a block
-of data including its checksum. If the checksum is
-valid, PacketAliasInternetChecksum() will return zero.
-.Sh 7. Authors
-Charles Mott (cmott@srv.net), versions 1.0 - 1.8, 2.0 - 2.4.
-
-Eivind Eklund (eivind@freebsd.org), versions 1.8b, 1.9 and
-2.5. Added IRC DCC support as well as contributing a number of
-architectural improvements; added the firewall bypass
-for FTP/IRC DCC.
-.Sh 8. Acknowledgments
-
-Listed below, in approximate chronological
-order, are individuals who have provided
-valuable comments and/or debugging assistance.
-
-.Bl -inset -compact -offset left
-.It Gary Roberts
-.It Tom Torrance
-.It Reto Burkhalter
-.It Martin Renters
-.It Brian Somers
-.It Paul Traina
-.It Ari Suutari
-.It Dave Remien
-.It J. Fortes
-.It Andrzej Bialeki
-.It Gordon Burditt
-.El
-.Sh Appendix: Conceptual Background
-This appendix is intended for those who
-are planning to modify the source code or want
-to create somewhat esoteric applications using
-the packet aliasing functions.
-
-The conceptual framework under which the
-packet aliasing engine operates is described here.
-Central to the discussion is the idea of an
-"aliasing link" which describes the relationship
-for a given packet transaction between the local
-machine, aliased identity and remote machine. It
-is discussed how such links come into existence
-and are destroyed.
-.Ss A.1 Aliasing Links
-There is a notion of an "aliasing link",
-which is 7-tuple describing a specific
-translation:
-.Bd -literal -offset indent
-(local addr, local port, alias addr, alias port,
- remote addr, remote port, protocol)
-.Ed
-
-Outgoing packets have the local address and
-port number replaced with the alias address
-and port number. Incoming packets undergo the
-reverse process. The packet aliasing engine
-attempts to match packets against an internal
-table of aliasing links to determine how to
-modify a given IP packet. Both the IP
-header and protocol dependent headers are
-modified as necessary. Aliasing links are
-created and deleted as necessary according
-to network traffic.
-
-Protocols can be TCP, UDP or even ICMP in
-certain circumstances. (Some types of ICMP
-packets can be aliased according to sequence
-or id number which acts as an equivalent port
-number for identifying how individual packets
-should be handled.)
-
-Each aliasing link must have a unique
-combination of the following five quantities:
-alias address/port, remote address/port
-and protocol. This ensures that several
-machines on a local network can share the
-same aliased IP address. In cases where
-conflicts might arise, the aliasing port
-is chosen so that uniqueness is maintained.
-.Ss A.2 Static and Dynamic Links
-Aliasing links can either be static or dynamic.
-Static links persist indefinitely and represent
-fixed rules for translating IP packets. Dynamic
-links come into existence for a specific TCP
-connection or UDP transaction or ICMP echo
-sequence. For the case of TCP, the connection
-can be monitored to see when the associated
-aliasing link should be deleted. Aliasing links
-for UDP transactions (and ICMP echo and timestamp
-requests) work on a simple timeout rule. When
-no activity is observed on a dynamic link for
-a certain amount of time it is automatically
-deleted. Timeout rules also apply to TCP
-connections which do not open or close
-properly.
-.Ss A.3 Partially Specified Aliasing Links
-Aliasing links can be partially specified,
-meaning that the remote address and/or remote
-ports are unknown. In this case, when a packet
-matching the incomplete specification is found,
-a fully specified dynamic link is created. If
-the original partially specified link is dynamic,
-it will be deleted after the fully specified link
-is created, otherwise it will persist.
-
-For instance, a partially specified link might
-be
-.Bd -literal -offset indent
-(192.168.0.4, 23, 204.228.203.215, 8066, 0, 0, tcp)
-.Ed
-
-The zeros denote unspecified components for
-the remote address and port. If this link were
-static it would have the effect of redirecting
-all incoming traffic from port 8066 of
-204.228.203.215 to port 23 (telnet) of machine
-192.168.0.4 on the local network. Each
-individual telnet connection would initiate
-the creation of a distinct dynamic link.
-.Ss A.4 Dynamic Link Creation
-In addition to aliasing links, there are
-also address mappings that can be stored
-within the internal data table of the packet
-aliasing mechanism.
-.Bd -literal -offset indent
-(local addr, alias addr)
-.Ed
-
-Address mappings are searched when creating
-new dynamic links.
-
-All outgoing packets from the local network
-automatically create a dynamic link if
-they do not match an already existing fully
-specified link. If an address mapping exists
-for the outgoing packet, this determines
-the alias address to be used. If no mapping
-exists, then a default address, usually the
-address of the packet aliasing host, is used.
-If necessary, this default address can be
-changed as often as each individual packet
-arrives.
-
-The aliasing port number is determined
-such that the new dynamic link does not
-conflict with any existing links. In the
-default operating mode, the packet aliasing
-engine attempts to set the aliasing port
-equal to the local port number. If this
-results in a conflict, then port numbers
-are randomly chosen until a unique aliasing
-link can be established. In an alternate
-operating mode, the first choice of an
-aliasing port is also random and unrelated
-to the local port number.
-
diff --git a/sys/netinet/tcp_reass.c b/sys/netinet/tcp_reass.c
deleted file mode 100644
index 1d2d8c38e58f..000000000000
--- a/sys/netinet/tcp_reass.c
+++ /dev/null
@@ -1,2782 +0,0 @@
-/*
- * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1994, 1995
- * 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)tcp_input.c 8.12 (Berkeley) 5/24/95
- * $FreeBSD$
- */
-
-#include "opt_ipfw.h" /* for ipfw_fwd */
-#include "opt_inet6.h"
-#include "opt_ipsec.h"
-#include "opt_tcpdebug.h"
-#include "opt_tcp_input.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/sysctl.h>
-#include <sys/malloc.h>
-#include <sys/mbuf.h>
-#include <sys/proc.h> /* for proc0 declaration */
-#include <sys/protosw.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-#include <sys/syslog.h>
-
-#include <machine/cpu.h> /* before tcp_seq.h, for tcp_random18() */
-
-#include <net/if.h>
-#include <net/route.h>
-
-#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <netinet/ip_icmp.h> /* for ICMP_BANDLIM */
-#ifdef INET6
-#include <netinet/ip6.h>
-#include <netinet/in_var.h>
-#include <netinet6/nd6.h>
-#include <netinet/icmp6.h>
-#endif
-#include <netinet/in_pcb.h>
-#ifdef INET6
-#include <netinet6/in6_pcb.h>
-#endif
-#include <netinet/ip_var.h>
-#ifdef INET6
-#include <netinet6/ip6_var.h>
-#endif
-#include <netinet/icmp_var.h> /* for ICMP_BANDLIM */
-#include <netinet/tcp.h>
-#include <netinet/tcp_fsm.h>
-#include <netinet/tcp_seq.h>
-#include <netinet/tcp_timer.h>
-#include <netinet/tcp_var.h>
-#ifdef INET6
-#include <netinet6/tcp6_var.h>
-#endif
-#include <netinet/tcpip.h>
-#ifdef TCPDEBUG
-#include <netinet/tcp_debug.h>
-
-u_char tcp_saveipgen[40]; /* the size must be of max ip header, now IPv6 */
-struct tcphdr tcp_savetcp;
-#endif /* TCPDEBUG */
-
-#ifdef IPSEC
-#include <netinet6/ipsec.h>
-#ifdef INET6
-#include <netinet6/ipsec6.h>
-#endif
-#include <netkey/key.h>
-#endif /*IPSEC*/
-
-MALLOC_DEFINE(M_TSEGQ, "tseg_qent", "TCP segment queue entry");
-
-static int tcprexmtthresh = 3;
-tcp_seq tcp_iss;
-tcp_cc tcp_ccgen;
-
-struct tcpstat tcpstat;
-SYSCTL_STRUCT(_net_inet_tcp, TCPCTL_STATS, stats, CTLFLAG_RD,
- &tcpstat , tcpstat, "TCP statistics (struct tcpstat, netinet/tcp_var.h)");
-
-static int log_in_vain = 0;
-SYSCTL_INT(_net_inet_tcp, OID_AUTO, log_in_vain, CTLFLAG_RW,
- &log_in_vain, 0, "Log all incoming TCP connections");
-
-static int blackhole = 0;
-SYSCTL_INT(_net_inet_tcp, OID_AUTO, blackhole, CTLFLAG_RW,
- &blackhole, 0, "Do not send RST when dropping refused connections");
-
-int tcp_delack_enabled = 1;
-SYSCTL_INT(_net_inet_tcp, OID_AUTO, delayed_ack, CTLFLAG_RW,
- &tcp_delack_enabled, 0,
- "Delay ACK to try and piggyback it onto a data packet");
-
-#ifdef TCP_DROP_SYNFIN
-static int drop_synfin = 0;
-SYSCTL_INT(_net_inet_tcp, OID_AUTO, drop_synfin, CTLFLAG_RW,
- &drop_synfin, 0, "Drop TCP packets with SYN+FIN set");
-#endif
-
-#ifdef TCP_RESTRICT_RST
-static int restrict_rst = 0;
-SYSCTL_INT(_net_inet_tcp, OID_AUTO, restrict_rst, CTLFLAG_RW,
- &restrict_rst, 0, "Restrict RST emission");
-#endif
-
-struct inpcbhead tcb;
-#define tcb6 tcb /* for KAME src sync over BSD*'s */
-struct inpcbinfo tcbinfo;
-
-static void tcp_dooptions __P((struct tcpcb *,
- u_char *, int, struct tcphdr *, struct tcpopt *));
-static void tcp_pulloutofband __P((struct socket *,
- struct tcphdr *, struct mbuf *, int));
-static int tcp_reass __P((struct tcpcb *, struct tcphdr *, int *,
- struct mbuf *));
-static void tcp_xmit_timer __P((struct tcpcb *, int));
-
-/* Neighbor Discovery, Neighbor Unreachability Detection Upper layer hint. */
-#ifdef INET6
-#define ND6_HINT(tp) \
-do { \
- if ((tp) && (tp)->t_inpcb && \
- ((tp)->t_inpcb->inp_vflag & INP_IPV6) != 0 && \
- (tp)->t_inpcb->in6p_route.ro_rt) \
- nd6_nud_hint((tp)->t_inpcb->in6p_route.ro_rt, NULL); \
-} while (0)
-#else
-#define ND6_HINT(tp)
-#endif
-
-/*
- * Insert segment which inludes th into reassembly queue of tcp with
- * control block tp. Return TH_FIN if reassembly now includes
- * a segment with FIN. The macro form does the common case inline
- * (segment is the next to be received on an established connection,
- * and the queue is empty), avoiding linkage into and removal
- * from the queue and repetition of various conversions.
- * Set DELACK for segments received in order, but ack immediately
- * when segments are out of order (so fast retransmit can work).
- */
-#define TCP_REASS(tp, th, tlenp, m, so, flags) { \
- if ((th)->th_seq == (tp)->rcv_nxt && \
- LIST_EMPTY(&(tp)->t_segq) && \
- (tp)->t_state == TCPS_ESTABLISHED) { \
- if (tcp_delack_enabled) \
- callout_reset(tp->tt_delack, tcp_delacktime, \
- tcp_timer_delack, tp); \
- else \
- tp->t_flags |= TF_ACKNOW; \
- (tp)->rcv_nxt += *(tlenp); \
- flags = (th)->th_flags & TH_FIN; \
- tcpstat.tcps_rcvpack++;\
- tcpstat.tcps_rcvbyte += *(tlenp);\
- ND6_HINT(tp); \
- sbappend(&(so)->so_rcv, (m)); \
- sorwakeup(so); \
- } else { \
- (flags) = tcp_reass((tp), (th), (tlenp), (m)); \
- tp->t_flags |= TF_ACKNOW; \
- } \
-}
-
-static int
-tcp_reass(tp, th, tlenp, m)
- register struct tcpcb *tp;
- register struct tcphdr *th;
- int *tlenp;
- struct mbuf *m;
-{
- struct tseg_qent *q;
- struct tseg_qent *p = NULL;
- struct tseg_qent *nq;
- struct tseg_qent *te;
- struct socket *so = tp->t_inpcb->inp_socket;
- int flags;
-
- /*
- * Call with th==0 after become established to
- * force pre-ESTABLISHED data up to user socket.
- */
- if (th == 0)
- goto present;
-
- /* Allocate a new queue entry. If we can't, just drop the pkt. XXX */
- MALLOC(te, struct tseg_qent *, sizeof (struct tseg_qent), M_TSEGQ,
- M_NOWAIT);
- if (te == NULL) {
- tcpstat.tcps_rcvmemdrop++;
- m_freem(m);
- return (0);
- }
-
- /*
- * Find a segment which begins after this one does.
- */
- LIST_FOREACH(q, &tp->t_segq, tqe_q) {
- if (SEQ_GT(q->tqe_th->th_seq, th->th_seq))
- break;
- p = q;
- }
-
- /*
- * If there is a preceding segment, it may provide some of
- * our data already. If so, drop the data from the incoming
- * segment. If it provides all of our data, drop us.
- */
- if (p != NULL) {
- register int i;
- /* conversion to int (in i) handles seq wraparound */
- i = p->tqe_th->th_seq + p->tqe_len - th->th_seq;
- if (i > 0) {
- if (i >= *tlenp) {
- tcpstat.tcps_rcvduppack++;
- tcpstat.tcps_rcvdupbyte += *tlenp;
- m_freem(m);
- FREE(te, M_TSEGQ);
- /*
- * Try to present any queued data
- * at the left window edge to the user.
- * This is needed after the 3-WHS
- * completes.
- */
- goto present; /* ??? */
- }
- m_adj(m, i);
- *tlenp -= i;
- th->th_seq += i;
- }
- }
- tcpstat.tcps_rcvoopack++;
- tcpstat.tcps_rcvoobyte += *tlenp;
-
- /*
- * While we overlap succeeding segments trim them or,
- * if they are completely covered, dequeue them.
- */
- while (q) {
- register int i = (th->th_seq + *tlenp) - q->tqe_th->th_seq;
- if (i <= 0)
- break;
- if (i < q->tqe_len) {
- q->tqe_th->th_seq += i;
- q->tqe_len -= i;
- m_adj(q->tqe_m, i);
- break;
- }
-
- nq = LIST_NEXT(q, tqe_q);
- LIST_REMOVE(q, tqe_q);
- m_freem(q->tqe_m);
- FREE(q, M_TSEGQ);
- q = nq;
- }
-
- /* Insert the new segment queue entry into place. */
- te->tqe_m = m;
- te->tqe_th = th;
- te->tqe_len = *tlenp;
-
- if (p == NULL) {
- LIST_INSERT_HEAD(&tp->t_segq, te, tqe_q);
- } else {
- LIST_INSERT_AFTER(p, te, tqe_q);
- }
-
-present:
- /*
- * Present data to user, advancing rcv_nxt through
- * completed sequence space.
- */
- if (!TCPS_HAVEESTABLISHED(tp->t_state))
- return (0);
- q = LIST_FIRST(&tp->t_segq);
- if (!q || q->tqe_th->th_seq != tp->rcv_nxt)
- return (0);
- do {
- tp->rcv_nxt += q->tqe_len;
- flags = q->tqe_th->th_flags & TH_FIN;
- nq = LIST_NEXT(q, tqe_q);
- LIST_REMOVE(q, tqe_q);
- if (so->so_state & SS_CANTRCVMORE)
- m_freem(q->tqe_m);
- else
- sbappend(&so->so_rcv, q->tqe_m);
- FREE(q, M_TSEGQ);
- q = nq;
- } while (q && q->tqe_th->th_seq == tp->rcv_nxt);
- ND6_HINT(tp);
- sorwakeup(so);
- return (flags);
-}
-
-/*
- * TCP input routine, follows pages 65-76 of the
- * protocol specification dated September, 1981 very closely.
- */
-#ifdef INET6
-int
-tcp6_input(mp, offp, proto)
- struct mbuf **mp;
- int *offp, proto;
-{
- register struct mbuf *m = *mp;
-
- IP6_EXTHDR_CHECK(m, *offp, sizeof(struct tcphdr), IPPROTO_DONE);
-
- /*
- * draft-itojun-ipv6-tcp-to-anycast
- * better place to put this in?
- */
- if (m->m_flags & M_ANYCAST6) {
- struct ip6_hdr *ip6;
-
- ip6 = mtod(m, struct ip6_hdr *);
- icmp6_error(m, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_ADDR,
- (caddr_t)&ip6->ip6_dst - (caddr_t)ip6);
- return IPPROTO_DONE;
- }
-
- tcp_input(m, *offp, proto);
- return IPPROTO_DONE;
-}
-#endif
-
-void
-tcp_input(m, off0, proto)
- register struct mbuf *m;
- int off0, proto;
-{
- register struct tcphdr *th;
- register struct ip *ip = NULL;
- register struct ipovly *ipov;
- register struct inpcb *inp;
- u_char *optp = NULL;
- int optlen = 0;
- int len, tlen, off;
- int drop_hdrlen;
- register struct tcpcb *tp = 0;
- register int thflags;
- struct socket *so = 0;
- int todrop, acked, ourfinisacked, needoutput = 0;
- struct in_addr laddr;
-#ifdef INET6
- struct in6_addr laddr6;
-#endif
- int dropsocket = 0;
- int iss = 0;
- u_long tiwin;
- struct tcpopt to; /* options in this segment */
- struct rmxp_tao *taop; /* pointer to our TAO cache entry */
- struct rmxp_tao tao_noncached; /* in case there's no cached entry */
-#ifdef TCPDEBUG
- short ostate = 0;
-#endif
-#ifdef INET6
- struct ip6_hdr *ip6 = NULL;
- int isipv6;
-#endif /* INET6 */
-
-#ifdef INET6
- isipv6 = (mtod(m, struct ip *)->ip_v == 6) ? 1 : 0;
-#endif
- bzero((char *)&to, sizeof(to));
-
- tcpstat.tcps_rcvtotal++;
-
-#ifdef INET6
- if (isipv6) {
- /* IP6_EXTHDR_CHECK() is already done at tcp6_input() */
- ip6 = mtod(m, struct ip6_hdr *);
- tlen = sizeof(*ip6) + ntohs(ip6->ip6_plen) - off0;
- if (in6_cksum(m, IPPROTO_TCP, off0, tlen)) {
- tcpstat.tcps_rcvbadsum++;
- goto drop;
- }
- th = (struct tcphdr *)((caddr_t)ip6 + off0);
- } else
-#endif /* INET6 */
- {
- /*
- * Get IP and TCP header together in first mbuf.
- * Note: IP leaves IP header in first mbuf.
- */
- if (off0 > sizeof (struct ip)) {
- ip_stripoptions(m, (struct mbuf *)0);
- off0 = sizeof(struct ip);
- }
- if (m->m_len < sizeof (struct tcpiphdr)) {
- if ((m = m_pullup(m, sizeof (struct tcpiphdr))) == 0) {
- tcpstat.tcps_rcvshort++;
- return;
- }
- }
- ip = mtod(m, struct ip *);
- ipov = (struct ipovly *)ip;
-
- /*
- * Checksum extended TCP header and data.
- */
- tlen = ip->ip_len;
- len = sizeof (struct ip) + tlen;
- bzero(ipov->ih_x1, sizeof(ipov->ih_x1));
- ipov->ih_len = (u_short)tlen;
- HTONS(ipov->ih_len);
- th = (struct tcphdr *)((caddr_t)ip + off0);
- th->th_sum = in_cksum(m, len);
- if (th->th_sum) {
- tcpstat.tcps_rcvbadsum++;
- goto drop;
- }
-#ifdef INET6
- /* Re-initialization for later version check */
- ip->ip_v = IPVERSION;
-#endif
- }
-
- /*
- * Check that TCP offset makes sense,
- * pull out TCP options and adjust length. XXX
- */
- off = th->th_off << 2;
- if (off < sizeof (struct tcphdr) || off > tlen) {
- tcpstat.tcps_rcvbadoff++;
- goto drop;
- }
- tlen -= off; /* tlen is used instead of ti->ti_len */
- if (off > sizeof (struct tcphdr)) {
-#ifdef INET6
- if (isipv6) {
- IP6_EXTHDR_CHECK(m, off0, off, );
- ip6 = mtod(m, struct ip6_hdr *);
- th = (struct tcphdr *)((caddr_t)ip6 + off0);
- } else
-#endif /* INET6 */
- {
- if (m->m_len < sizeof(struct ip) + off) {
- if ((m = m_pullup(m, sizeof (struct ip) + off)) == 0) {
- tcpstat.tcps_rcvshort++;
- return;
- }
- ip = mtod(m, struct ip *);
- ipov = (struct ipovly *)ip;
- th = (struct tcphdr *)((caddr_t)ip + off0);
- }
- }
- optlen = off - sizeof (struct tcphdr);
- optp = (u_char *)(th + 1);
- }
- thflags = th->th_flags;
-
-#ifdef TCP_DROP_SYNFIN
- /*
- * If the drop_synfin option is enabled, drop all packets with
- * both the SYN and FIN bits set. This prevents e.g. nmap from
- * identifying the TCP/IP stack.
- *
- * This is incompatible with RFC1644 extensions (T/TCP).
- */
- if (drop_synfin && (thflags & (TH_SYN|TH_FIN)) == (TH_SYN|TH_FIN))
- goto drop;
-#endif
-
- /*
- * Convert TCP protocol specific fields to host format.
- */
- NTOHL(th->th_seq);
- NTOHL(th->th_ack);
- NTOHS(th->th_win);
- NTOHS(th->th_urp);
-
- /*
- * Delay droping TCP, IP headers, IPv6 ext headers, and TCP options,
- * until after ip6_savecontrol() is called and before other functions
- * which don't want those proto headers.
- * Because ip6_savecontrol() is going to parse the mbuf to
- * search for data to be passed up to user-land, it wants mbuf
- * parameters to be unchanged.
- */
- drop_hdrlen = off0 + off;
-
- /*
- * Locate pcb for segment.
- */
-findpcb:
-#ifdef IPFIREWALL_FORWARD
- if (ip_fw_fwd_addr != NULL
-#ifdef INET6
- && isipv6 == NULL /* IPv6 support is not yet */
-#endif /* INET6 */
- ) {
- /*
- * Diverted. Pretend to be the destination.
- * already got one like this?
- */
- inp = in_pcblookup_hash(&tcbinfo, ip->ip_src, th->th_sport,
- ip->ip_dst, th->th_dport, 0, m->m_pkthdr.rcvif);
- if (!inp) {
- /*
- * No, then it's new. Try find the ambushing socket
- */
- if (!ip_fw_fwd_addr->sin_port) {
- inp = in_pcblookup_hash(&tcbinfo, ip->ip_src,
- th->th_sport, ip_fw_fwd_addr->sin_addr,
- th->th_dport, 1, m->m_pkthdr.rcvif);
- } else {
- inp = in_pcblookup_hash(&tcbinfo,
- ip->ip_src, th->th_sport,
- ip_fw_fwd_addr->sin_addr,
- ntohs(ip_fw_fwd_addr->sin_port), 1,
- m->m_pkthdr.rcvif);
- }
- }
- ip_fw_fwd_addr = NULL;
- } else
-#endif /* IPFIREWALL_FORWARD */
- {
-#ifdef INET6
- if (isipv6)
- inp = in6_pcblookup_hash(&tcbinfo, &ip6->ip6_src, th->th_sport,
- &ip6->ip6_dst, th->th_dport, 1,
- m->m_pkthdr.rcvif);
- else
-#endif /* INET6 */
- inp = in_pcblookup_hash(&tcbinfo, ip->ip_src, th->th_sport,
- ip->ip_dst, th->th_dport, 1, m->m_pkthdr.rcvif);
- }
-
-#ifdef IPSEC
-#ifdef INET6
- if (isipv6) {
- if (inp != NULL && ipsec6_in_reject_so(m, inp->inp_socket)) {
- ipsec6stat.in_polvio++;
- goto drop;
- }
- } else
-#endif /* INET6 */
- if (inp != NULL && ipsec4_in_reject_so(m, inp->inp_socket)) {
- ipsecstat.in_polvio++;
- goto drop;
- }
-#endif /*IPSEC*/
-
- /*
- * If the state is CLOSED (i.e., TCB does not exist) then
- * all data in the incoming segment is discarded.
- * If the TCB exists but is in CLOSED state, it is embryonic,
- * but should either do a listen or a connect soon.
- */
- if (inp == NULL) {
- if (log_in_vain) {
-#ifdef INET6
- char dbuf[INET6_ADDRSTRLEN], sbuf[INET6_ADDRSTRLEN];
-#else /* INET6 */
- char dbuf[4*sizeof "123"], sbuf[4*sizeof "123"];
-#endif /* INET6 */
-
-#ifdef INET6
- if (isipv6) {
- strcpy(dbuf, ip6_sprintf(&ip6->ip6_dst));
- strcpy(sbuf, ip6_sprintf(&ip6->ip6_src));
- } else
-#endif
- {
- strcpy(dbuf, inet_ntoa(ip->ip_dst));
- strcpy(sbuf, inet_ntoa(ip->ip_src));
- }
- switch (log_in_vain) {
- case 1:
- if(thflags & TH_SYN)
- log(LOG_INFO,
- "Connection attempt to TCP %s:%d from %s:%d\n",
- dbuf, ntohs(th->th_dport),
- sbuf,
- ntohs(th->th_sport));
- break;
- case 2:
- log(LOG_INFO,
- "Connection attempt to TCP %s:%d from %s:%d flags:0x%x\n",
- dbuf, ntohs(th->th_dport), sbuf,
- ntohs(th->th_sport), thflags);
- break;
- default:
- break;
- }
- }
- if (blackhole) {
- switch (blackhole) {
- case 1:
- if (thflags & TH_SYN)
- goto drop;
- break;
- case 2:
- goto drop;
- default:
- goto drop;
- }
- }
- goto maybedropwithreset;
- }
- tp = intotcpcb(inp);
- if (tp == 0)
- goto maybedropwithreset;
- if (tp->t_state == TCPS_CLOSED)
- goto drop;
-
- /* Unscale the window into a 32-bit value. */
- if ((thflags & TH_SYN) == 0)
- tiwin = th->th_win << tp->snd_scale;
- else
- tiwin = th->th_win;
-
-#ifdef INET6
- /* save packet options if user wanted */
- if (isipv6 && inp->in6p_flags & INP_CONTROLOPTS) {
- if (inp->in6p_options) {
- m_freem(inp->in6p_options);
- inp->in6p_options = 0;
- }
- ip6_savecontrol(inp, &inp->in6p_options, ip6, m);
- }
- /* else, should also do ip_srcroute() here? */
-#endif /* INET6 */
-
- so = inp->inp_socket;
- if (so->so_options & (SO_DEBUG|SO_ACCEPTCONN)) {
-#ifdef TCPDEBUG
- if (so->so_options & SO_DEBUG) {
- ostate = tp->t_state;
-#ifdef INET6
- if (isipv6)
- bcopy((char *)ip6, (char *)tcp_saveipgen,
- sizeof(*ip6));
- else
-#endif /* INET6 */
- bcopy((char *)ip, (char *)tcp_saveipgen, sizeof(*ip));
- tcp_savetcp = *th;
- }
-#endif
- if (so->so_options & SO_ACCEPTCONN) {
- register struct tcpcb *tp0 = tp;
- struct socket *so2;
-#ifdef IPSEC
- struct socket *oso;
-#endif
-#ifdef INET6
- struct inpcb *oinp = sotoinpcb(so);
-#endif /* INET6 */
-
-#ifndef IPSEC
- /*
- * Current IPsec implementation makes incorrect IPsec
- * cache if this check is done here.
- * So delay this until duplicated socket is created.
- */
- if ((thflags & (TH_RST|TH_ACK|TH_SYN)) != TH_SYN) {
- /*
- * Note: dropwithreset makes sure we don't
- * send a RST in response to a RST.
- */
- if (thflags & TH_ACK) {
- tcpstat.tcps_badsyn++;
- goto maybedropwithreset;
- }
- goto drop;
- }
-#endif
- so2 = sonewconn(so, 0);
- if (so2 == 0) {
- tcpstat.tcps_listendrop++;
- so2 = sodropablereq(so);
- if (so2) {
- tcp_drop(sototcpcb(so2), ETIMEDOUT);
- so2 = sonewconn(so, 0);
- }
- if (!so2)
- goto drop;
- }
-#ifdef IPSEC
- oso = so;
-#endif
- so = so2;
- /*
- * This is ugly, but ....
- *
- * Mark socket as temporary until we're
- * committed to keeping it. The code at
- * ``drop'' and ``dropwithreset'' check the
- * flag dropsocket to see if the temporary
- * socket created here should be discarded.
- * We mark the socket as discardable until
- * we're committed to it below in TCPS_LISTEN.
- */
- dropsocket++;
- inp = (struct inpcb *)so->so_pcb;
-#ifdef INET6
- if (isipv6)
- inp->in6p_laddr = ip6->ip6_dst;
- else {
- if (ip6_mapped_addr_on) {
- inp->inp_vflag &= ~INP_IPV6;
- inp->inp_vflag |= INP_IPV4;
- }
-#endif /* INET6 */
- inp->inp_laddr = ip->ip_dst;
-#ifdef INET6
- }
-#endif /* INET6 */
- inp->inp_lport = th->th_dport;
- if (in_pcbinshash(inp) != 0) {
- /*
- * Undo the assignments above if we failed to
- * put the PCB on the hash lists.
- */
-#ifdef INET6
- if (isipv6)
- inp->in6p_laddr = in6addr_any;
- else
-#endif /* INET6 */
- inp->inp_laddr.s_addr = INADDR_ANY;
- inp->inp_lport = 0;
- goto drop;
- }
-#ifdef IPSEC
- /*
- * To avoid creating incorrectly cached IPsec
- * association, this is need to be done here.
- *
- * Subject: (KAME-snap 748)
- * From: Wayne Knowles <w.knowles@niwa.cri.nz>
- * ftp://ftp.kame.net/pub/mail-list/snap-users/748
- */
- if ((thflags & (TH_RST|TH_ACK|TH_SYN)) != TH_SYN) {
- /*
- * Note: dropwithreset makes sure we don't
- * send a RST in response to a RST.
- */
- if (thflags & TH_ACK) {
- tcpstat.tcps_badsyn++;
- goto maybedropwithreset;
- }
- goto drop;
- }
-#endif
-#ifdef INET6
- if (isipv6) {
- /*
- * inherit socket options from the listening
- * socket.
- */
- inp->inp_flags |=
- oinp->inp_flags & INP_CONTROLOPTS;
- if (inp->inp_flags & INP_CONTROLOPTS) {
- if (inp->in6p_options) {
- m_freem(inp->in6p_options);
- inp->in6p_options = 0;
- }
- ip6_savecontrol(inp,
- &inp->in6p_options,
- ip6, m);
- }
- } else
-#endif /* INET6 */
- inp->inp_options = ip_srcroute();
-#ifdef IPSEC
- /* copy old policy into new socket's */
- if (ipsec_copy_policy(sotoinpcb(oso)->inp_sp,
- inp->inp_sp))
- printf("tcp_input: could not copy policy\n");
-#endif
- tp = intotcpcb(inp);
- tp->t_state = TCPS_LISTEN;
- tp->t_flags |= tp0->t_flags & (TF_NOPUSH|TF_NOOPT);
-
- /* Compute proper scaling value from buffer space */
- while (tp->request_r_scale < TCP_MAX_WINSHIFT &&
- TCP_MAXWIN << tp->request_r_scale <
- so->so_rcv.sb_hiwat)
- tp->request_r_scale++;
- }
- }
-
- /*
- * Segment received on connection.
- * Reset idle time and keep-alive timer.
- */
- tp->t_rcvtime = ticks;
- if (TCPS_HAVEESTABLISHED(tp->t_state))
- callout_reset(tp->tt_keep, tcp_keepidle, tcp_timer_keep, tp);
-
- /*
- * Process options if not in LISTEN state,
- * else do it below (after getting remote address).
- */
- if (tp->t_state != TCPS_LISTEN)
- tcp_dooptions(tp, optp, optlen, th, &to);
-
- /*
- * Header prediction: check for the two common cases
- * of a uni-directional data xfer. If the packet has
- * no control flags, is in-sequence, the window didn't
- * change and we're not retransmitting, it's a
- * candidate. If the length is zero and the ack moved
- * forward, we're the sender side of the xfer. Just
- * free the data acked & wake any higher level process
- * that was blocked waiting for space. If the length
- * is non-zero and the ack didn't move, we're the
- * receiver side. If we're getting packets in-order
- * (the reassembly queue is empty), add the data to
- * the socket buffer and note that we need a delayed ack.
- * Make sure that the hidden state-flags are also off.
- * Since we check for TCPS_ESTABLISHED above, it can only
- * be TH_NEEDSYN.
- */
- if (tp->t_state == TCPS_ESTABLISHED &&
- (thflags & (TH_SYN|TH_FIN|TH_RST|TH_URG|TH_ACK)) == TH_ACK &&
- ((tp->t_flags & (TF_NEEDSYN|TF_NEEDFIN)) == 0) &&
- ((to.to_flag & TOF_TS) == 0 ||
- TSTMP_GEQ(to.to_tsval, tp->ts_recent)) &&
- /*
- * Using the CC option is compulsory if once started:
- * the segment is OK if no T/TCP was negotiated or
- * if the segment has a CC option equal to CCrecv
- */
- ((tp->t_flags & (TF_REQ_CC|TF_RCVD_CC)) != (TF_REQ_CC|TF_RCVD_CC) ||
- ((to.to_flag & TOF_CC) != 0 && to.to_cc == tp->cc_recv)) &&
- th->th_seq == tp->rcv_nxt &&
- tiwin && tiwin == tp->snd_wnd &&
- tp->snd_nxt == tp->snd_max) {
-
- /*
- * If last ACK falls within this segment's sequence numbers,
- * record the timestamp.
- * NOTE that the test is modified according to the latest
- * proposal of the tcplw@cray.com list (Braden 1993/04/26).
- */
- if ((to.to_flag & TOF_TS) != 0 &&
- SEQ_LEQ(th->th_seq, tp->last_ack_sent)) {
- tp->ts_recent_age = ticks;
- tp->ts_recent = to.to_tsval;
- }
-
- if (tlen == 0) {
- if (SEQ_GT(th->th_ack, tp->snd_una) &&
- SEQ_LEQ(th->th_ack, tp->snd_max) &&
- tp->snd_cwnd >= tp->snd_wnd &&
- tp->t_dupacks < tcprexmtthresh) {
- /*
- * this is a pure ack for outstanding data.
- */
- ++tcpstat.tcps_predack;
- /*
- * "bad retransmit" recovery
- */
- if (tp->t_rxtshift == 1 &&
- ticks < tp->t_badrxtwin) {
- tp->snd_cwnd = tp->snd_cwnd_prev;
- tp->snd_ssthresh =
- tp->snd_ssthresh_prev;
- tp->snd_nxt = tp->snd_max;
- tp->t_badrxtwin = 0;
- }
- if ((to.to_flag & TOF_TS) != 0)
- tcp_xmit_timer(tp,
- ticks - to.to_tsecr + 1);
- else if (tp->t_rtttime &&
- SEQ_GT(th->th_ack, tp->t_rtseq))
- tcp_xmit_timer(tp, ticks - tp->t_rtttime);
- acked = th->th_ack - tp->snd_una;
- tcpstat.tcps_rcvackpack++;
- tcpstat.tcps_rcvackbyte += acked;
- sbdrop(&so->so_snd, acked);
- tp->snd_una = th->th_ack;
- m_freem(m);
- ND6_HINT(tp); /* some progress has been done */
-
- /*
- * If all outstanding data are acked, stop
- * retransmit timer, otherwise restart timer
- * using current (possibly backed-off) value.
- * If process is waiting for space,
- * wakeup/selwakeup/signal. If data
- * are ready to send, let tcp_output
- * decide between more output or persist.
- */
- if (tp->snd_una == tp->snd_max)
- callout_stop(tp->tt_rexmt);
- else if (!callout_active(tp->tt_persist))
- callout_reset(tp->tt_rexmt,
- tp->t_rxtcur,
- tcp_timer_rexmt, tp);
-
- sowwakeup(so);
- if (so->so_snd.sb_cc)
- (void) tcp_output(tp);
- return;
- }
- } else if (th->th_ack == tp->snd_una &&
- LIST_EMPTY(&tp->t_segq) &&
- tlen <= sbspace(&so->so_rcv)) {
- /*
- * this is a pure, in-sequence data packet
- * with nothing on the reassembly queue and
- * we have enough buffer space to take it.
- */
- ++tcpstat.tcps_preddat;
- tp->rcv_nxt += tlen;
- tcpstat.tcps_rcvpack++;
- tcpstat.tcps_rcvbyte += tlen;
- ND6_HINT(tp); /* some progress has been done */
- /*
- * Add data to socket buffer.
- */
- m_adj(m, drop_hdrlen); /* delayed header drop */
- sbappend(&so->so_rcv, m);
- sorwakeup(so);
- if (tcp_delack_enabled) {
- callout_reset(tp->tt_delack, tcp_delacktime,
- tcp_timer_delack, tp);
- } else {
- tp->t_flags |= TF_ACKNOW;
- tcp_output(tp);
- }
- return;
- }
- }
-
- /*
- * Calculate amount of space in receive window,
- * and then do TCP input processing.
- * Receive window is amount of space in rcv queue,
- * but not less than advertised window.
- */
- { int win;
-
- win = sbspace(&so->so_rcv);
- if (win < 0)
- win = 0;
- tp->rcv_wnd = imax(win, (int)(tp->rcv_adv - tp->rcv_nxt));
- }
-
- switch (tp->t_state) {
-
- /*
- * If the state is LISTEN then ignore segment if it contains an RST.
- * If the segment contains an ACK then it is bad and send a RST.
- * If it does not contain a SYN then it is not interesting; drop it.
- * If it is from this socket, drop it, it must be forged.
- * Don't bother responding if the destination was a broadcast.
- * Otherwise initialize tp->rcv_nxt, and tp->irs, select an initial
- * tp->iss, and send a segment:
- * <SEQ=ISS><ACK=RCV_NXT><CTL=SYN,ACK>
- * Also initialize tp->snd_nxt to tp->iss+1 and tp->snd_una to tp->iss.
- * Fill in remote peer address fields if not previously specified.
- * Enter SYN_RECEIVED state, and process any other fields of this
- * segment in this state.
- */
- case TCPS_LISTEN: {
- register struct sockaddr_in *sin;
-#ifdef INET6
- register struct sockaddr_in6 *sin6;
-#endif
-
- if (thflags & TH_RST)
- goto drop;
- if (thflags & TH_ACK)
- goto maybedropwithreset;
- if ((thflags & TH_SYN) == 0)
- goto drop;
- if (th->th_dport == th->th_sport) {
-#ifdef INET6
- if (isipv6) {
- if (IN6_ARE_ADDR_EQUAL(&ip6->ip6_dst,
- &ip6->ip6_src))
- goto drop;
- } else
-#endif /* INET6 */
- if (ip->ip_dst.s_addr == ip->ip_src.s_addr)
- goto drop;
- }
- /*
- * RFC1122 4.2.3.10, p. 104: discard bcast/mcast SYN
- * in_broadcast() should never return true on a received
- * packet with M_BCAST not set.
- *
- * Packets with a multicast source address should also
- * be discarded.
- */
- if (m->m_flags & (M_BCAST|M_MCAST))
- goto drop;
-#ifdef INET6
- if (isipv6) {
- if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst) ||
- IN6_IS_ADDR_MULTICAST(&ip6->ip6_src))
- goto drop;
- } else
-#endif
- if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) ||
- IN_MULTICAST(ntohl(ip->ip_src.s_addr)) ||
- ip->ip_src.s_addr == htonl(INADDR_BROADCAST))
- goto drop;
-#ifdef INET6
- if (isipv6) {
- MALLOC(sin6, struct sockaddr_in6 *, sizeof *sin6,
- M_SONAME, M_NOWAIT);
- if (sin6 == NULL)
- goto drop;
- bzero(sin6, sizeof(*sin6));
- sin6->sin6_family = AF_INET6;
- sin6->sin6_len = sizeof(*sin6);
- sin6->sin6_addr = ip6->ip6_src;
- sin6->sin6_port = th->th_sport;
- laddr6 = inp->in6p_laddr;
- if (IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr))
- inp->in6p_laddr = ip6->ip6_dst;
- if (in6_pcbconnect(inp, (struct sockaddr *)sin6,
- &proc0)) {
- inp->in6p_laddr = laddr6;
- FREE(sin6, M_SONAME);
- goto drop;
- }
- FREE(sin6, M_SONAME);
- } else
-#endif
- {
- MALLOC(sin, struct sockaddr_in *, sizeof *sin, M_SONAME,
- M_NOWAIT);
- if (sin == NULL)
- goto drop;
- sin->sin_family = AF_INET;
- sin->sin_len = sizeof(*sin);
- sin->sin_addr = ip->ip_src;
- sin->sin_port = th->th_sport;
- bzero((caddr_t)sin->sin_zero, sizeof(sin->sin_zero));
- laddr = inp->inp_laddr;
- if (inp->inp_laddr.s_addr == INADDR_ANY)
- inp->inp_laddr = ip->ip_dst;
- if (in_pcbconnect(inp, (struct sockaddr *)sin, &proc0)) {
- inp->inp_laddr = laddr;
- FREE(sin, M_SONAME);
- goto drop;
- }
- FREE(sin, M_SONAME);
- }
- tp->t_template = tcp_template(tp);
- if (tp->t_template == 0) {
- tp = tcp_drop(tp, ENOBUFS);
- dropsocket = 0; /* socket is already gone */
- goto drop;
- }
- if ((taop = tcp_gettaocache(inp)) == NULL) {
- taop = &tao_noncached;
- bzero(taop, sizeof(*taop));
- }
- tcp_dooptions(tp, optp, optlen, th, &to);
- if (iss)
- tp->iss = iss;
- else
- tp->iss = tcp_iss;
- tcp_iss += TCP_ISSINCR/4;
- tp->irs = th->th_seq;
- tcp_sendseqinit(tp);
- tcp_rcvseqinit(tp);
- /*
- * Initialization of the tcpcb for transaction;
- * set SND.WND = SEG.WND,
- * initialize CCsend and CCrecv.
- */
- tp->snd_wnd = tiwin; /* initial send-window */
- tp->cc_send = CC_INC(tcp_ccgen);
- tp->cc_recv = to.to_cc;
- /*
- * Perform TAO test on incoming CC (SEG.CC) option, if any.
- * - compare SEG.CC against cached CC from the same host,
- * if any.
- * - if SEG.CC > chached value, SYN must be new and is accepted
- * immediately: save new CC in the cache, mark the socket
- * connected, enter ESTABLISHED state, turn on flag to
- * send a SYN in the next segment.
- * A virtual advertised window is set in rcv_adv to
- * initialize SWS prevention. Then enter normal segment
- * processing: drop SYN, process data and FIN.
- * - otherwise do a normal 3-way handshake.
- */
- if ((to.to_flag & TOF_CC) != 0) {
- if (((tp->t_flags & TF_NOPUSH) != 0) &&
- taop->tao_cc != 0 && CC_GT(to.to_cc, taop->tao_cc)) {
-
- taop->tao_cc = to.to_cc;
- tp->t_starttime = ticks;
- tp->t_state = TCPS_ESTABLISHED;
-
- /*
- * If there is a FIN, or if there is data and the
- * connection is local, then delay SYN,ACK(SYN) in
- * the hope of piggy-backing it on a response
- * segment. Otherwise must send ACK now in case
- * the other side is slow starting.
- */
- if (tcp_delack_enabled && ((thflags & TH_FIN) ||
- (tlen != 0 &&
-#ifdef INET6
- ((isipv6 && in6_localaddr(&inp->in6p_faddr))
- ||
- (!isipv6 &&
-#endif
- in_localaddr(inp->inp_faddr)
-#ifdef INET6
- ))
-#endif
- ))) {
- callout_reset(tp->tt_delack, tcp_delacktime,
- tcp_timer_delack, tp);
- tp->t_flags |= TF_NEEDSYN;
- } else
- tp->t_flags |= (TF_ACKNOW | TF_NEEDSYN);
-
- /*
- * Limit the `virtual advertised window' to TCP_MAXWIN
- * here. Even if we requested window scaling, it will
- * become effective only later when our SYN is acked.
- */
- tp->rcv_adv += min(tp->rcv_wnd, TCP_MAXWIN);
- tcpstat.tcps_connects++;
- soisconnected(so);
- callout_reset(tp->tt_keep, tcp_keepinit,
- tcp_timer_keep, tp);
- dropsocket = 0; /* committed to socket */
- tcpstat.tcps_accepts++;
- goto trimthenstep6;
- }
- /* else do standard 3-way handshake */
- } else {
- /*
- * No CC option, but maybe CC.NEW:
- * invalidate cached value.
- */
- taop->tao_cc = 0;
- }
- /*
- * TAO test failed or there was no CC option,
- * do a standard 3-way handshake.
- */
- tp->t_flags |= TF_ACKNOW;
- tp->t_state = TCPS_SYN_RECEIVED;
- callout_reset(tp->tt_keep, tcp_keepinit, tcp_timer_keep, tp);
- dropsocket = 0; /* committed to socket */
- tcpstat.tcps_accepts++;
- ND6_HINT((struct tcpcb *)inp->inp_ppcb);
- goto trimthenstep6;
- }
-
- /*
- * If the state is SYN_RECEIVED:
- * if seg contains an ACK, but not for our SYN/ACK, send a RST.
- */
- case TCPS_SYN_RECEIVED:
- if ((thflags & TH_ACK) &&
- (SEQ_LEQ(th->th_ack, tp->snd_una) ||
- SEQ_GT(th->th_ack, tp->snd_max)))
- goto maybedropwithreset;
- break;
-
- /*
- * If the state is SYN_SENT:
- * if seg contains an ACK, but not for our SYN, drop the input.
- * if seg contains a RST, then drop the connection.
- * if seg does not contain SYN, then drop it.
- * Otherwise this is an acceptable SYN segment
- * initialize tp->rcv_nxt and tp->irs
- * if seg contains ack then advance tp->snd_una
- * if SYN has been acked change to ESTABLISHED else SYN_RCVD state
- * arrange for segment to be acked (eventually)
- * continue processing rest of data/controls, beginning with URG
- */
- case TCPS_SYN_SENT:
- if ((taop = tcp_gettaocache(inp)) == NULL) {
- taop = &tao_noncached;
- bzero(taop, sizeof(*taop));
- }
-
- if ((thflags & TH_ACK) &&
- (SEQ_LEQ(th->th_ack, tp->iss) ||
- SEQ_GT(th->th_ack, tp->snd_max))) {
- /*
- * If we have a cached CCsent for the remote host,
- * hence we haven't just crashed and restarted,
- * do not send a RST. This may be a retransmission
- * from the other side after our earlier ACK was lost.
- * Our new SYN, when it arrives, will serve as the
- * needed ACK.
- */
- if (taop->tao_ccsent != 0)
- goto drop;
- else
- goto dropwithreset;
- }
- if (thflags & TH_RST) {
- if (thflags & TH_ACK)
- tp = tcp_drop(tp, ECONNREFUSED);
- goto drop;
- }
- if ((thflags & TH_SYN) == 0)
- goto drop;
- tp->snd_wnd = th->th_win; /* initial send window */
- tp->cc_recv = to.to_cc; /* foreign CC */
-
- tp->irs = th->th_seq;
- tcp_rcvseqinit(tp);
- if (thflags & TH_ACK) {
- /*
- * Our SYN was acked. If segment contains CC.ECHO
- * option, check it to make sure this segment really
- * matches our SYN. If not, just drop it as old
- * duplicate, but send an RST if we're still playing
- * by the old rules. If no CC.ECHO option, make sure
- * we don't get fooled into using T/TCP.
- */
- if (to.to_flag & TOF_CCECHO) {
- if (tp->cc_send != to.to_ccecho) {
- if (taop->tao_ccsent != 0)
- goto drop;
- else
- goto dropwithreset;
- }
- } else
- tp->t_flags &= ~TF_RCVD_CC;
- tcpstat.tcps_connects++;
- soisconnected(so);
- /* Do window scaling on this connection? */
- if ((tp->t_flags & (TF_RCVD_SCALE|TF_REQ_SCALE)) ==
- (TF_RCVD_SCALE|TF_REQ_SCALE)) {
- tp->snd_scale = tp->requested_s_scale;
- tp->rcv_scale = tp->request_r_scale;
- }
- /* Segment is acceptable, update cache if undefined. */
- if (taop->tao_ccsent == 0)
- taop->tao_ccsent = to.to_ccecho;
-
- tp->rcv_adv += tp->rcv_wnd;
- tp->snd_una++; /* SYN is acked */
- /*
- * If there's data, delay ACK; if there's also a FIN
- * ACKNOW will be turned on later.
- */
- if (tcp_delack_enabled && tlen != 0)
- callout_reset(tp->tt_delack, tcp_delacktime,
- tcp_timer_delack, tp);
- else
- tp->t_flags |= TF_ACKNOW;
- /*
- * Received <SYN,ACK> in SYN_SENT[*] state.
- * Transitions:
- * SYN_SENT --> ESTABLISHED
- * SYN_SENT* --> FIN_WAIT_1
- */
- tp->t_starttime = ticks;
- if (tp->t_flags & TF_NEEDFIN) {
- tp->t_state = TCPS_FIN_WAIT_1;
- tp->t_flags &= ~TF_NEEDFIN;
- thflags &= ~TH_SYN;
- } else {
- tp->t_state = TCPS_ESTABLISHED;
- callout_reset(tp->tt_keep, tcp_keepidle,
- tcp_timer_keep, tp);
- }
- } else {
- /*
- * Received initial SYN in SYN-SENT[*] state => simul-
- * taneous open. If segment contains CC option and there is
- * a cached CC, apply TAO test; if it succeeds, connection is
- * half-synchronized. Otherwise, do 3-way handshake:
- * SYN-SENT -> SYN-RECEIVED
- * SYN-SENT* -> SYN-RECEIVED*
- * If there was no CC option, clear cached CC value.
- */
- tp->t_flags |= TF_ACKNOW;
- callout_stop(tp->tt_rexmt);
- if (to.to_flag & TOF_CC) {
- if (taop->tao_cc != 0 &&
- CC_GT(to.to_cc, taop->tao_cc)) {
- /*
- * update cache and make transition:
- * SYN-SENT -> ESTABLISHED*
- * SYN-SENT* -> FIN-WAIT-1*
- */
- taop->tao_cc = to.to_cc;
- tp->t_starttime = ticks;
- if (tp->t_flags & TF_NEEDFIN) {
- tp->t_state = TCPS_FIN_WAIT_1;
- tp->t_flags &= ~TF_NEEDFIN;
- } else {
- tp->t_state = TCPS_ESTABLISHED;
- callout_reset(tp->tt_keep,
- tcp_keepidle,
- tcp_timer_keep,
- tp);
- }
- tp->t_flags |= TF_NEEDSYN;
- } else
- tp->t_state = TCPS_SYN_RECEIVED;
- } else {
- /* CC.NEW or no option => invalidate cache */
- taop->tao_cc = 0;
- tp->t_state = TCPS_SYN_RECEIVED;
- }
- }
-
-trimthenstep6:
- /*
- * Advance th->th_seq to correspond to first data byte.
- * If data, trim to stay within window,
- * dropping FIN if necessary.
- */
- th->th_seq++;
- if (tlen > tp->rcv_wnd) {
- todrop = tlen - tp->rcv_wnd;
- m_adj(m, -todrop);
- tlen = tp->rcv_wnd;
- thflags &= ~TH_FIN;
- tcpstat.tcps_rcvpackafterwin++;
- tcpstat.tcps_rcvbyteafterwin += todrop;
- }
- tp->snd_wl1 = th->th_seq - 1;
- tp->rcv_up = th->th_seq;
- /*
- * Client side of transaction: already sent SYN and data.
- * If the remote host used T/TCP to validate the SYN,
- * our data will be ACK'd; if so, enter normal data segment
- * processing in the middle of step 5, ack processing.
- * Otherwise, goto step 6.
- */
- if (thflags & TH_ACK)
- goto process_ACK;
- goto step6;
- /*
- * If the state is LAST_ACK or CLOSING or TIME_WAIT:
- * if segment contains a SYN and CC [not CC.NEW] option:
- * if state == TIME_WAIT and connection duration > MSL,
- * drop packet and send RST;
- *
- * if SEG.CC > CCrecv then is new SYN, and can implicitly
- * ack the FIN (and data) in retransmission queue.
- * Complete close and delete TCPCB. Then reprocess
- * segment, hoping to find new TCPCB in LISTEN state;
- *
- * else must be old SYN; drop it.
- * else do normal processing.
- */
- case TCPS_LAST_ACK:
- case TCPS_CLOSING:
- case TCPS_TIME_WAIT:
- if ((thflags & TH_SYN) &&
- (to.to_flag & TOF_CC) && tp->cc_recv != 0) {
- if (tp->t_state == TCPS_TIME_WAIT &&
- (ticks - tp->t_starttime) > tcp_msl)
- goto dropwithreset;
- if (CC_GT(to.to_cc, tp->cc_recv)) {
- tp = tcp_close(tp);
- goto findpcb;
- }
- else
- goto drop;
- }
- break; /* continue normal processing */
- }
-
- /*
- * States other than LISTEN or SYN_SENT.
- * First check the RST flag and sequence number since reset segments
- * are exempt from the timestamp and connection count tests. This
- * fixes a bug introduced by the Stevens, vol. 2, p. 960 bugfix
- * below which allowed reset segments in half the sequence space
- * to fall though and be processed (which gives forged reset
- * segments with a random sequence number a 50 percent chance of
- * killing a connection).
- * Then check timestamp, if present.
- * Then check the connection count, if present.
- * Then check that at least some bytes of segment are within
- * receive window. If segment begins before rcv_nxt,
- * drop leading data (and SYN); if nothing left, just ack.
- *
- *
- * If the RST bit is set, check the sequence number to see
- * if this is a valid reset segment.
- * RFC 793 page 37:
- * In all states except SYN-SENT, all reset (RST) segments
- * are validated by checking their SEQ-fields. A reset is
- * valid if its sequence number is in the window.
- * Note: this does not take into account delayed ACKs, so
- * we should test against last_ack_sent instead of rcv_nxt.
- * The sequence number in the reset segment is normally an
- * echo of our outgoing acknowlegement numbers, but some hosts
- * send a reset with the sequence number at the rightmost edge
- * of our receive window, and we have to handle this case.
- * If we have multiple segments in flight, the intial reset
- * segment sequence numbers will be to the left of last_ack_sent,
- * but they will eventually catch up.
- * In any case, it never made sense to trim reset segments to
- * fit the receive window since RFC 1122 says:
- * 4.2.2.12 RST Segment: RFC-793 Section 3.4
- *
- * A TCP SHOULD allow a received RST segment to include data.
- *
- * DISCUSSION
- * It has been suggested that a RST segment could contain
- * ASCII text that encoded and explained the cause of the
- * RST. No standard has yet been established for such
- * data.
- *
- * If the reset segment passes the sequence number test examine
- * the state:
- * SYN_RECEIVED STATE:
- * If passive open, return to LISTEN state.
- * If active open, inform user that connection was refused.
- * ESTABLISHED, FIN_WAIT_1, FIN_WAIT2, CLOSE_WAIT STATES:
- * Inform user that connection was reset, and close tcb.
- * CLOSING, LAST_ACK STATES:
- * Close the tcb.
- * TIME_WAIT STATE:
- * Drop the segment - see Stevens, vol. 2, p. 964 and
- * RFC 1337.
- */
- if (thflags & TH_RST) {
- if (SEQ_GEQ(th->th_seq, tp->last_ack_sent) &&
- SEQ_LT(th->th_seq, tp->last_ack_sent + tp->rcv_wnd)) {
- switch (tp->t_state) {
-
- case TCPS_SYN_RECEIVED:
- so->so_error = ECONNREFUSED;
- goto close;
-
- case TCPS_ESTABLISHED:
- case TCPS_FIN_WAIT_1:
- case TCPS_FIN_WAIT_2:
- case TCPS_CLOSE_WAIT:
- so->so_error = ECONNRESET;
- close:
- tp->t_state = TCPS_CLOSED;
- tcpstat.tcps_drops++;
- tp = tcp_close(tp);
- break;
-
- case TCPS_CLOSING:
- case TCPS_LAST_ACK:
- tp = tcp_close(tp);
- break;
-
- case TCPS_TIME_WAIT:
- break;
- }
- }
- goto drop;
- }
-
- /*
- * RFC 1323 PAWS: If we have a timestamp reply on this segment
- * and it's less than ts_recent, drop it.
- */
- if ((to.to_flag & TOF_TS) != 0 && tp->ts_recent &&
- TSTMP_LT(to.to_tsval, tp->ts_recent)) {
-
- /* Check to see if ts_recent is over 24 days old. */
- if ((int)(ticks - tp->ts_recent_age) > TCP_PAWS_IDLE) {
- /*
- * Invalidate ts_recent. If this segment updates
- * ts_recent, the age will be reset later and ts_recent
- * will get a valid value. If it does not, setting
- * ts_recent to zero will at least satisfy the
- * requirement that zero be placed in the timestamp
- * echo reply when ts_recent isn't valid. The
- * age isn't reset until we get a valid ts_recent
- * because we don't want out-of-order segments to be
- * dropped when ts_recent is old.
- */
- tp->ts_recent = 0;
- } else {
- tcpstat.tcps_rcvduppack++;
- tcpstat.tcps_rcvdupbyte += tlen;
- tcpstat.tcps_pawsdrop++;
- goto dropafterack;
- }
- }
-
- /*
- * T/TCP mechanism
- * If T/TCP was negotiated and the segment doesn't have CC,
- * or if its CC is wrong then drop the segment.
- * RST segments do not have to comply with this.
- */
- if ((tp->t_flags & (TF_REQ_CC|TF_RCVD_CC)) == (TF_REQ_CC|TF_RCVD_CC) &&
- ((to.to_flag & TOF_CC) == 0 || tp->cc_recv != to.to_cc))
- goto dropafterack;
-
- /*
- * In the SYN-RECEIVED state, validate that the packet belongs to
- * this connection before trimming the data to fit the receive
- * window. Check the sequence number versus IRS since we know
- * the sequence numbers haven't wrapped. This is a partial fix
- * for the "LAND" DoS attack.
- */
- if (tp->t_state == TCPS_SYN_RECEIVED && SEQ_LT(th->th_seq, tp->irs))
- goto maybedropwithreset;
-
- todrop = tp->rcv_nxt - th->th_seq;
- if (todrop > 0) {
- if (thflags & TH_SYN) {
- thflags &= ~TH_SYN;
- th->th_seq++;
- if (th->th_urp > 1)
- th->th_urp--;
- else
- thflags &= ~TH_URG;
- todrop--;
- }
- /*
- * Following if statement from Stevens, vol. 2, p. 960.
- */
- if (todrop > tlen
- || (todrop == tlen && (thflags & TH_FIN) == 0)) {
- /*
- * Any valid FIN must be to the left of the window.
- * At this point the FIN must be a duplicate or out
- * of sequence; drop it.
- */
- thflags &= ~TH_FIN;
-
- /*
- * Send an ACK to resynchronize and drop any data.
- * But keep on processing for RST or ACK.
- */
- tp->t_flags |= TF_ACKNOW;
- todrop = tlen;
- tcpstat.tcps_rcvduppack++;
- tcpstat.tcps_rcvdupbyte += todrop;
- } else {
- tcpstat.tcps_rcvpartduppack++;
- tcpstat.tcps_rcvpartdupbyte += todrop;
- }
- drop_hdrlen += todrop; /* drop from the top afterwards */
- th->th_seq += todrop;
- tlen -= todrop;
- if (th->th_urp > todrop)
- th->th_urp -= todrop;
- else {
- thflags &= ~TH_URG;
- th->th_urp = 0;
- }
- }
-
- /*
- * If new data are received on a connection after the
- * user processes are gone, then RST the other end.
- */
- if ((so->so_state & SS_NOFDREF) &&
- tp->t_state > TCPS_CLOSE_WAIT && tlen) {
- tp = tcp_close(tp);
- tcpstat.tcps_rcvafterclose++;
- goto dropwithreset;
- }
-
- /*
- * If segment ends after window, drop trailing data
- * (and PUSH and FIN); if nothing left, just ACK.
- */
- todrop = (th->th_seq+tlen) - (tp->rcv_nxt+tp->rcv_wnd);
- if (todrop > 0) {
- tcpstat.tcps_rcvpackafterwin++;
- if (todrop >= tlen) {
- tcpstat.tcps_rcvbyteafterwin += tlen;
- /*
- * If a new connection request is received
- * while in TIME_WAIT, drop the old connection
- * and start over if the sequence numbers
- * are above the previous ones.
- */
- if (thflags & TH_SYN &&
- tp->t_state == TCPS_TIME_WAIT &&
- SEQ_GT(th->th_seq, tp->rcv_nxt)) {
- iss = tp->snd_nxt + TCP_ISSINCR;
- tp = tcp_close(tp);
- goto findpcb;
- }
- /*
- * If window is closed can only take segments at
- * window edge, and have to drop data and PUSH from
- * incoming segments. Continue processing, but
- * remember to ack. Otherwise, drop segment
- * and ack.
- */
- if (tp->rcv_wnd == 0 && th->th_seq == tp->rcv_nxt) {
- tp->t_flags |= TF_ACKNOW;
- tcpstat.tcps_rcvwinprobe++;
- } else
- goto dropafterack;
- } else
- tcpstat.tcps_rcvbyteafterwin += todrop;
- m_adj(m, -todrop);
- tlen -= todrop;
- thflags &= ~(TH_PUSH|TH_FIN);
- }
-
- /*
- * If last ACK falls within this segment's sequence numbers,
- * record its timestamp.
- * NOTE that the test is modified according to the latest
- * proposal of the tcplw@cray.com list (Braden 1993/04/26).
- */
- if ((to.to_flag & TOF_TS) != 0 &&
- SEQ_LEQ(th->th_seq, tp->last_ack_sent)) {
- tp->ts_recent_age = ticks;
- tp->ts_recent = to.to_tsval;
- }
-
- /*
- * If a SYN is in the window, then this is an
- * error and we send an RST and drop the connection.
- */
- if (thflags & TH_SYN) {
- tp = tcp_drop(tp, ECONNRESET);
- goto dropwithreset;
- }
-
- /*
- * If the ACK bit is off: if in SYN-RECEIVED state or SENDSYN
- * flag is on (half-synchronized state), then queue data for
- * later processing; else drop segment and return.
- */
- if ((thflags & TH_ACK) == 0) {
- if (tp->t_state == TCPS_SYN_RECEIVED ||
- (tp->t_flags & TF_NEEDSYN))
- goto step6;
- else
- goto drop;
- }
-
- /*
- * Ack processing.
- */
- switch (tp->t_state) {
-
- /*
- * In SYN_RECEIVED state, the ack ACKs our SYN, so enter
- * ESTABLISHED state and continue processing.
- * The ACK was checked above.
- */
- case TCPS_SYN_RECEIVED:
-
- tcpstat.tcps_connects++;
- soisconnected(so);
- /* Do window scaling? */
- if ((tp->t_flags & (TF_RCVD_SCALE|TF_REQ_SCALE)) ==
- (TF_RCVD_SCALE|TF_REQ_SCALE)) {
- tp->snd_scale = tp->requested_s_scale;
- tp->rcv_scale = tp->request_r_scale;
- }
- /*
- * Upon successful completion of 3-way handshake,
- * update cache.CC if it was undefined, pass any queued
- * data to the user, and advance state appropriately.
- */
- if ((taop = tcp_gettaocache(inp)) != NULL &&
- taop->tao_cc == 0)
- taop->tao_cc = tp->cc_recv;
-
- /*
- * Make transitions:
- * SYN-RECEIVED -> ESTABLISHED
- * SYN-RECEIVED* -> FIN-WAIT-1
- */
- tp->t_starttime = ticks;
- if (tp->t_flags & TF_NEEDFIN) {
- tp->t_state = TCPS_FIN_WAIT_1;
- tp->t_flags &= ~TF_NEEDFIN;
- } else {
- tp->t_state = TCPS_ESTABLISHED;
- callout_reset(tp->tt_keep, tcp_keepidle,
- tcp_timer_keep, tp);
- }
- /*
- * If segment contains data or ACK, will call tcp_reass()
- * later; if not, do so now to pass queued data to user.
- */
- if (tlen == 0 && (thflags & TH_FIN) == 0)
- (void) tcp_reass(tp, (struct tcphdr *)0, 0,
- (struct mbuf *)0);
- tp->snd_wl1 = th->th_seq - 1;
- /* fall into ... */
-
- /*
- * In ESTABLISHED state: drop duplicate ACKs; ACK out of range
- * ACKs. If the ack is in the range
- * tp->snd_una < th->th_ack <= tp->snd_max
- * then advance tp->snd_una to th->th_ack and drop
- * data from the retransmission queue. If this ACK reflects
- * more up to date window information we update our window information.
- */
- case TCPS_ESTABLISHED:
- case TCPS_FIN_WAIT_1:
- case TCPS_FIN_WAIT_2:
- case TCPS_CLOSE_WAIT:
- case TCPS_CLOSING:
- case TCPS_LAST_ACK:
- case TCPS_TIME_WAIT:
-
- if (SEQ_LEQ(th->th_ack, tp->snd_una)) {
- if (tlen == 0 && tiwin == tp->snd_wnd) {
- tcpstat.tcps_rcvdupack++;
- /*
- * If we have outstanding data (other than
- * a window probe), this is a completely
- * duplicate ack (ie, window info didn't
- * change), the ack is the biggest we've
- * seen and we've seen exactly our rexmt
- * threshhold of them, assume a packet
- * has been dropped and retransmit it.
- * Kludge snd_nxt & the congestion
- * window so we send only this one
- * packet.
- *
- * We know we're losing at the current
- * window size so do congestion avoidance
- * (set ssthresh to half the current window
- * and pull our congestion window back to
- * the new ssthresh).
- *
- * Dup acks mean that packets have left the
- * network (they're now cached at the receiver)
- * so bump cwnd by the amount in the receiver
- * to keep a constant cwnd packets in the
- * network.
- */
- if (!callout_active(tp->tt_rexmt) ||
- th->th_ack != tp->snd_una)
- tp->t_dupacks = 0;
- else if (++tp->t_dupacks == tcprexmtthresh) {
- tcp_seq onxt = tp->snd_nxt;
- u_int win =
- min(tp->snd_wnd, tp->snd_cwnd) / 2 /
- tp->t_maxseg;
-
- if (win < 2)
- win = 2;
- tp->snd_ssthresh = win * tp->t_maxseg;
- callout_stop(tp->tt_rexmt);
- tp->t_rtttime = 0;
- tp->snd_nxt = th->th_ack;
- tp->snd_cwnd = tp->t_maxseg;
- (void) tcp_output(tp);
- tp->snd_cwnd = tp->snd_ssthresh +
- tp->t_maxseg * tp->t_dupacks;
- if (SEQ_GT(onxt, tp->snd_nxt))
- tp->snd_nxt = onxt;
- goto drop;
- } else if (tp->t_dupacks > tcprexmtthresh) {
- tp->snd_cwnd += tp->t_maxseg;
- (void) tcp_output(tp);
- goto drop;
- }
- } else
- tp->t_dupacks = 0;
- break;
- }
- /*
- * If the congestion window was inflated to account
- * for the other side's cached packets, retract it.
- */
- if (tp->t_dupacks >= tcprexmtthresh &&
- tp->snd_cwnd > tp->snd_ssthresh)
- tp->snd_cwnd = tp->snd_ssthresh;
- tp->t_dupacks = 0;
- if (SEQ_GT(th->th_ack, tp->snd_max)) {
- tcpstat.tcps_rcvacktoomuch++;
- goto dropafterack;
- }
- /*
- * If we reach this point, ACK is not a duplicate,
- * i.e., it ACKs something we sent.
- */
- if (tp->t_flags & TF_NEEDSYN) {
- /*
- * T/TCP: Connection was half-synchronized, and our
- * SYN has been ACK'd (so connection is now fully
- * synchronized). Go to non-starred state,
- * increment snd_una for ACK of SYN, and check if
- * we can do window scaling.
- */
- tp->t_flags &= ~TF_NEEDSYN;
- tp->snd_una++;
- /* Do window scaling? */
- if ((tp->t_flags & (TF_RCVD_SCALE|TF_REQ_SCALE)) ==
- (TF_RCVD_SCALE|TF_REQ_SCALE)) {
- tp->snd_scale = tp->requested_s_scale;
- tp->rcv_scale = tp->request_r_scale;
- }
- }
-
-process_ACK:
- acked = th->th_ack - tp->snd_una;
- tcpstat.tcps_rcvackpack++;
- tcpstat.tcps_rcvackbyte += acked;
-
- /*
- * If we just performed our first retransmit, and the ACK
- * arrives within our recovery window, then it was a mistake
- * to do the retransmit in the first place. Recover our
- * original cwnd and ssthresh, and proceed to transmit where
- * we left off.
- */
- if (tp->t_rxtshift == 1 && ticks < tp->t_badrxtwin) {
- tp->snd_cwnd = tp->snd_cwnd_prev;
- tp->snd_ssthresh = tp->snd_ssthresh_prev;
- tp->snd_nxt = tp->snd_max;
- tp->t_badrxtwin = 0; /* XXX probably not required */
- }
-
- /*
- * If we have a timestamp reply, update smoothed
- * round trip time. If no timestamp is present but
- * transmit timer is running and timed sequence
- * number was acked, update smoothed round trip time.
- * Since we now have an rtt measurement, cancel the
- * timer backoff (cf., Phil Karn's retransmit alg.).
- * Recompute the initial retransmit timer.
- */
- if (to.to_flag & TOF_TS)
- tcp_xmit_timer(tp, ticks - to.to_tsecr + 1);
- else if (tp->t_rtttime && SEQ_GT(th->th_ack, tp->t_rtseq))
- tcp_xmit_timer(tp, ticks - tp->t_rtttime);
-
- /*
- * If all outstanding data is acked, stop retransmit
- * timer and remember to restart (more output or persist).
- * If there is more data to be acked, restart retransmit
- * timer, using current (possibly backed-off) value.
- */
- if (th->th_ack == tp->snd_max) {
- callout_stop(tp->tt_rexmt);
- needoutput = 1;
- } else if (!callout_active(tp->tt_persist))
- callout_reset(tp->tt_rexmt, tp->t_rxtcur,
- tcp_timer_rexmt, tp);
-
- /*
- * If no data (only SYN) was ACK'd,
- * skip rest of ACK processing.
- */
- if (acked == 0)
- goto step6;
-
- /*
- * When new data is acked, open the congestion window.
- * If the window gives us less than ssthresh packets
- * in flight, open exponentially (maxseg per packet).
- * Otherwise open linearly: maxseg per window
- * (maxseg^2 / cwnd per packet).
- */
- {
- register u_int cw = tp->snd_cwnd;
- register u_int incr = tp->t_maxseg;
-
- if (cw > tp->snd_ssthresh)
- incr = incr * incr / cw;
- tp->snd_cwnd = min(cw + incr, TCP_MAXWIN << tp->snd_scale);
- }
- if (acked > so->so_snd.sb_cc) {
- tp->snd_wnd -= so->so_snd.sb_cc;
- sbdrop(&so->so_snd, (int)so->so_snd.sb_cc);
- ourfinisacked = 1;
- } else {
- sbdrop(&so->so_snd, acked);
- tp->snd_wnd -= acked;
- ourfinisacked = 0;
- }
- sowwakeup(so);
- tp->snd_una = th->th_ack;
- if (SEQ_LT(tp->snd_nxt, tp->snd_una))
- tp->snd_nxt = tp->snd_una;
-
- switch (tp->t_state) {
-
- /*
- * In FIN_WAIT_1 STATE in addition to the processing
- * for the ESTABLISHED state if our FIN is now acknowledged
- * then enter FIN_WAIT_2.
- */
- case TCPS_FIN_WAIT_1:
- if (ourfinisacked) {
- /*
- * If we can't receive any more
- * data, then closing user can proceed.
- * Starting the timer is contrary to the
- * specification, but if we don't get a FIN
- * we'll hang forever.
- */
- if (so->so_state & SS_CANTRCVMORE) {
- soisdisconnected(so);
- callout_reset(tp->tt_2msl, tcp_maxidle,
- tcp_timer_2msl, tp);
- }
- tp->t_state = TCPS_FIN_WAIT_2;
- }
- break;
-
- /*
- * In CLOSING STATE in addition to the processing for
- * the ESTABLISHED state if the ACK acknowledges our FIN
- * then enter the TIME-WAIT state, otherwise ignore
- * the segment.
- */
- case TCPS_CLOSING:
- if (ourfinisacked) {
- tp->t_state = TCPS_TIME_WAIT;
- tcp_canceltimers(tp);
- /* Shorten TIME_WAIT [RFC-1644, p.28] */
- if (tp->cc_recv != 0 &&
- (ticks - tp->t_starttime) < tcp_msl)
- callout_reset(tp->tt_2msl,
- tp->t_rxtcur *
- TCPTV_TWTRUNC,
- tcp_timer_2msl, tp);
- else
- callout_reset(tp->tt_2msl, 2 * tcp_msl,
- tcp_timer_2msl, tp);
- soisdisconnected(so);
- }
- break;
-
- /*
- * In LAST_ACK, we may still be waiting for data to drain
- * and/or to be acked, as well as for the ack of our FIN.
- * If our FIN is now acknowledged, delete the TCB,
- * enter the closed state and return.
- */
- case TCPS_LAST_ACK:
- if (ourfinisacked) {
- tp = tcp_close(tp);
- goto drop;
- }
- break;
-
- /*
- * In TIME_WAIT state the only thing that should arrive
- * is a retransmission of the remote FIN. Acknowledge
- * it and restart the finack timer.
- */
- case TCPS_TIME_WAIT:
- callout_reset(tp->tt_2msl, 2 * tcp_msl,
- tcp_timer_2msl, tp);
- goto dropafterack;
- }
- }
-
-step6:
- /*
- * Update window information.
- * Don't look at window if no ACK: TAC's send garbage on first SYN.
- */
- if ((thflags & TH_ACK) &&
- (SEQ_LT(tp->snd_wl1, th->th_seq) ||
- (tp->snd_wl1 == th->th_seq && (SEQ_LT(tp->snd_wl2, th->th_ack) ||
- (tp->snd_wl2 == th->th_ack && tiwin > tp->snd_wnd))))) {
- /* keep track of pure window updates */
- if (tlen == 0 &&
- tp->snd_wl2 == th->th_ack && tiwin > tp->snd_wnd)
- tcpstat.tcps_rcvwinupd++;
- tp->snd_wnd = tiwin;
- tp->snd_wl1 = th->th_seq;
- tp->snd_wl2 = th->th_ack;
- if (tp->snd_wnd > tp->max_sndwnd)
- tp->max_sndwnd = tp->snd_wnd;
- needoutput = 1;
- }
-
- /*
- * Process segments with URG.
- */
- if ((thflags & TH_URG) && th->th_urp &&
- TCPS_HAVERCVDFIN(tp->t_state) == 0) {
- /*
- * This is a kludge, but if we receive and accept
- * random urgent pointers, we'll crash in
- * soreceive. It's hard to imagine someone
- * actually wanting to send this much urgent data.
- */
- if (th->th_urp + so->so_rcv.sb_cc > sb_max) {
- th->th_urp = 0; /* XXX */
- thflags &= ~TH_URG; /* XXX */
- goto dodata; /* XXX */
- }
- /*
- * If this segment advances the known urgent pointer,
- * then mark the data stream. This should not happen
- * in CLOSE_WAIT, CLOSING, LAST_ACK or TIME_WAIT STATES since
- * a FIN has been received from the remote side.
- * In these states we ignore the URG.
- *
- * According to RFC961 (Assigned Protocols),
- * the urgent pointer points to the last octet
- * of urgent data. We continue, however,
- * to consider it to indicate the first octet
- * of data past the urgent section as the original
- * spec states (in one of two places).
- */
- if (SEQ_GT(th->th_seq+th->th_urp, tp->rcv_up)) {
- tp->rcv_up = th->th_seq + th->th_urp;
- so->so_oobmark = so->so_rcv.sb_cc +
- (tp->rcv_up - tp->rcv_nxt) - 1;
- if (so->so_oobmark == 0)
- so->so_state |= SS_RCVATMARK;
- sohasoutofband(so);
- tp->t_oobflags &= ~(TCPOOB_HAVEDATA | TCPOOB_HADDATA);
- }
- /*
- * Remove out of band data so doesn't get presented to user.
- * This can happen independent of advancing the URG pointer,
- * but if two URG's are pending at once, some out-of-band
- * data may creep in... ick.
- */
- if (th->th_urp <= (u_long)tlen
-#ifdef SO_OOBINLINE
- && (so->so_options & SO_OOBINLINE) == 0
-#endif
- )
- tcp_pulloutofband(so, th, m,
- drop_hdrlen); /* hdr drop is delayed */
- } else
- /*
- * If no out of band data is expected,
- * pull receive urgent pointer along
- * with the receive window.
- */
- if (SEQ_GT(tp->rcv_nxt, tp->rcv_up))
- tp->rcv_up = tp->rcv_nxt;
-dodata: /* XXX */
-
- /*
- * Process the segment text, merging it into the TCP sequencing queue,
- * and arranging for acknowledgment of receipt if necessary.
- * This process logically involves adjusting tp->rcv_wnd as data
- * is presented to the user (this happens in tcp_usrreq.c,
- * case PRU_RCVD). If a FIN has already been received on this
- * connection then we just ignore the text.
- */
- if ((tlen || (thflags&TH_FIN)) &&
- TCPS_HAVERCVDFIN(tp->t_state) == 0) {
- m_adj(m, drop_hdrlen); /* delayed header drop */
- TCP_REASS(tp, th, &tlen, m, so, thflags);
- /*
- * Note the amount of data that peer has sent into
- * our window, in order to estimate the sender's
- * buffer size.
- */
- len = so->so_rcv.sb_hiwat - (tp->rcv_adv - tp->rcv_nxt);
- } else {
- m_freem(m);
- thflags &= ~TH_FIN;
- }
-
- /*
- * If FIN is received ACK the FIN and let the user know
- * that the connection is closing.
- */
- if (thflags & TH_FIN) {
- if (TCPS_HAVERCVDFIN(tp->t_state) == 0) {
- socantrcvmore(so);
- /*
- * If connection is half-synchronized
- * (ie NEEDSYN flag on) then delay ACK,
- * so it may be piggybacked when SYN is sent.
- * Otherwise, since we received a FIN then no
- * more input can be expected, send ACK now.
- */
- if (tcp_delack_enabled && (tp->t_flags & TF_NEEDSYN))
- callout_reset(tp->tt_delack, tcp_delacktime,
- tcp_timer_delack, tp);
- else
- tp->t_flags |= TF_ACKNOW;
- tp->rcv_nxt++;
- }
- switch (tp->t_state) {
-
- /*
- * In SYN_RECEIVED and ESTABLISHED STATES
- * enter the CLOSE_WAIT state.
- */
- case TCPS_SYN_RECEIVED:
- tp->t_starttime = ticks;
- /*FALLTHROUGH*/
- case TCPS_ESTABLISHED:
- tp->t_state = TCPS_CLOSE_WAIT;
- break;
-
- /*
- * If still in FIN_WAIT_1 STATE FIN has not been acked so
- * enter the CLOSING state.
- */
- case TCPS_FIN_WAIT_1:
- tp->t_state = TCPS_CLOSING;
- break;
-
- /*
- * In FIN_WAIT_2 state enter the TIME_WAIT state,
- * starting the time-wait timer, turning off the other
- * standard timers.
- */
- case TCPS_FIN_WAIT_2:
- tp->t_state = TCPS_TIME_WAIT;
- tcp_canceltimers(tp);
- /* Shorten TIME_WAIT [RFC-1644, p.28] */
- if (tp->cc_recv != 0 &&
- (ticks - tp->t_starttime) < tcp_msl) {
- callout_reset(tp->tt_2msl,
- tp->t_rxtcur * TCPTV_TWTRUNC,
- tcp_timer_2msl, tp);
- /* For transaction client, force ACK now. */
- tp->t_flags |= TF_ACKNOW;
- }
- else
- callout_reset(tp->tt_2msl, 2 * tcp_msl,
- tcp_timer_2msl, tp);
- soisdisconnected(so);
- break;
-
- /*
- * In TIME_WAIT state restart the 2 MSL time_wait timer.
- */
- case TCPS_TIME_WAIT:
- callout_reset(tp->tt_2msl, 2 * tcp_msl,
- tcp_timer_2msl, tp);
- break;
- }
- }
-#ifdef TCPDEBUG
- if (so->so_options & SO_DEBUG)
- tcp_trace(TA_INPUT, ostate, tp, (void *)tcp_saveipgen,
- &tcp_savetcp, 0);
-#endif
-
- /*
- * Return any desired output.
- */
- if (needoutput || (tp->t_flags & TF_ACKNOW))
- (void) tcp_output(tp);
- return;
-
-dropafterack:
- /*
- * Generate an ACK dropping incoming segment if it occupies
- * sequence space, where the ACK reflects our state.
- *
- * We can now skip the test for the RST flag since all
- * paths to this code happen after packets containing
- * RST have been dropped.
- *
- * In the SYN-RECEIVED state, don't send an ACK unless the
- * segment we received passes the SYN-RECEIVED ACK test.
- * If it fails send a RST. This breaks the loop in the
- * "LAND" DoS attack, and also prevents an ACK storm
- * between two listening ports that have been sent forged
- * SYN segments, each with the source address of the other.
- */
- if (tp->t_state == TCPS_SYN_RECEIVED && (thflags & TH_ACK) &&
- (SEQ_GT(tp->snd_una, th->th_ack) ||
- SEQ_GT(th->th_ack, tp->snd_max)) )
- goto maybedropwithreset;
-#ifdef TCPDEBUG
- if (so->so_options & SO_DEBUG)
- tcp_trace(TA_DROP, ostate, tp, (void *)tcp_saveipgen,
- &tcp_savetcp, 0);
-#endif
- m_freem(m);
- tp->t_flags |= TF_ACKNOW;
- (void) tcp_output(tp);
- return;
-
-
- /*
- * Conditionally drop with reset or just drop depending on whether
- * we think we are under attack or not.
- */
-maybedropwithreset:
-#ifdef ICMP_BANDLIM
- if (badport_bandlim(1) < 0)
- goto drop;
-#endif
- /* fall through */
-dropwithreset:
-#ifdef TCP_RESTRICT_RST
- if (restrict_rst)
- goto drop;
-#endif
- /*
- * Generate a RST, dropping incoming segment.
- * Make ACK acceptable to originator of segment.
- * Don't bother to respond if destination was broadcast/multicast.
- */
- if ((thflags & TH_RST) || m->m_flags & (M_BCAST|M_MCAST))
- goto drop;
-#ifdef INET6
- if (isipv6) {
- if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst) ||
- IN6_IS_ADDR_MULTICAST(&ip6->ip6_src))
- goto drop;
- } else
-#endif /* INET6 */
- if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) ||
- IN_MULTICAST(ntohl(ip->ip_src.s_addr)) ||
- ip->ip_src.s_addr == htonl(INADDR_BROADCAST))
- goto drop;
- /* IPv6 anycast check is done at tcp6_input() */
-#ifdef TCPDEBUG
- if (tp == 0 || (tp->t_inpcb->inp_socket->so_options & SO_DEBUG))
- tcp_trace(TA_DROP, ostate, tp, (void *)tcp_saveipgen,
- &tcp_savetcp, 0);
-#endif
- if (thflags & TH_ACK)
- /* mtod() below is safe as long as hdr dropping is delayed */
- tcp_respond(tp, mtod(m, void *), th, m, (tcp_seq)0, th->th_ack,
- TH_RST);
- else {
- if (thflags & TH_SYN)
- tlen++;
- /* mtod() below is safe as long as hdr dropping is delayed */
- tcp_respond(tp, mtod(m, void *), th, m, th->th_seq+tlen,
- (tcp_seq)0, TH_RST|TH_ACK);
- }
- /* destroy temporarily created socket */
- if (dropsocket)
- (void) soabort(so);
- return;
-
-drop:
- /*
- * Drop space held by incoming segment and return.
- */
-#ifdef TCPDEBUG
- if (tp == 0 || (tp->t_inpcb->inp_socket->so_options & SO_DEBUG))
- tcp_trace(TA_DROP, ostate, tp, (void *)tcp_saveipgen,
- &tcp_savetcp, 0);
-#endif
- m_freem(m);
- /* destroy temporarily created socket */
- if (dropsocket)
- (void) soabort(so);
- return;
-}
-
-static void
-tcp_dooptions(tp, cp, cnt, th, to)
- struct tcpcb *tp;
- u_char *cp;
- int cnt;
- struct tcphdr *th;
- struct tcpopt *to;
-{
- u_short mss = 0;
- int opt, optlen;
-
- for (; cnt > 0; cnt -= optlen, cp += optlen) {
- opt = cp[0];
- if (opt == TCPOPT_EOL)
- break;
- if (opt == TCPOPT_NOP)
- optlen = 1;
- else {
- optlen = cp[1];
- if (optlen <= 0)
- break;
- }
- switch (opt) {
-
- default:
- continue;
-
- case TCPOPT_MAXSEG:
- if (optlen != TCPOLEN_MAXSEG)
- continue;
- if (!(th->th_flags & TH_SYN))
- continue;
- bcopy((char *) cp + 2, (char *) &mss, sizeof(mss));
- NTOHS(mss);
- break;
-
- case TCPOPT_WINDOW:
- if (optlen != TCPOLEN_WINDOW)
- continue;
- if (!(th->th_flags & TH_SYN))
- continue;
- tp->t_flags |= TF_RCVD_SCALE;
- tp->requested_s_scale = min(cp[2], TCP_MAX_WINSHIFT);
- break;
-
- case TCPOPT_TIMESTAMP:
- if (optlen != TCPOLEN_TIMESTAMP)
- continue;
- to->to_flag |= TOF_TS;
- bcopy((char *)cp + 2,
- (char *)&to->to_tsval, sizeof(to->to_tsval));
- NTOHL(to->to_tsval);
- bcopy((char *)cp + 6,
- (char *)&to->to_tsecr, sizeof(to->to_tsecr));
- NTOHL(to->to_tsecr);
-
- /*
- * A timestamp received in a SYN makes
- * it ok to send timestamp requests and replies.
- */
- if (th->th_flags & TH_SYN) {
- tp->t_flags |= TF_RCVD_TSTMP;
- tp->ts_recent = to->to_tsval;
- tp->ts_recent_age = ticks;
- }
- break;
- case TCPOPT_CC:
- if (optlen != TCPOLEN_CC)
- continue;
- to->to_flag |= TOF_CC;
- bcopy((char *)cp + 2,
- (char *)&to->to_cc, sizeof(to->to_cc));
- NTOHL(to->to_cc);
- /*
- * A CC or CC.new option received in a SYN makes
- * it ok to send CC in subsequent segments.
- */
- if (th->th_flags & TH_SYN)
- tp->t_flags |= TF_RCVD_CC;
- break;
- case TCPOPT_CCNEW:
- if (optlen != TCPOLEN_CC)
- continue;
- if (!(th->th_flags & TH_SYN))
- continue;
- to->to_flag |= TOF_CCNEW;
- bcopy((char *)cp + 2,
- (char *)&to->to_cc, sizeof(to->to_cc));
- NTOHL(to->to_cc);
- /*
- * A CC or CC.new option received in a SYN makes
- * it ok to send CC in subsequent segments.
- */
- tp->t_flags |= TF_RCVD_CC;
- break;
- case TCPOPT_CCECHO:
- if (optlen != TCPOLEN_CC)
- continue;
- if (!(th->th_flags & TH_SYN))
- continue;
- to->to_flag |= TOF_CCECHO;
- bcopy((char *)cp + 2,
- (char *)&to->to_ccecho, sizeof(to->to_ccecho));
- NTOHL(to->to_ccecho);
- break;
- }
- }
- if (th->th_flags & TH_SYN)
- tcp_mss(tp, mss); /* sets t_maxseg */
-}
-
-/*
- * Pull out of band byte out of a segment so
- * it doesn't appear in the user's data queue.
- * It is still reflected in the segment length for
- * sequencing purposes.
- */
-static void
-tcp_pulloutofband(so, th, m, off)
- struct socket *so;
- struct tcphdr *th;
- register struct mbuf *m;
- int off; /* delayed to be droped hdrlen */
-{
- int cnt = off + th->th_urp - 1;
-
- while (cnt >= 0) {
- if (m->m_len > cnt) {
- char *cp = mtod(m, caddr_t) + cnt;
- struct tcpcb *tp = sototcpcb(so);
-
- tp->t_iobc = *cp;
- tp->t_oobflags |= TCPOOB_HAVEDATA;
- bcopy(cp+1, cp, (unsigned)(m->m_len - cnt - 1));
- m->m_len--;
- if (m->m_flags & M_PKTHDR)
- m->m_pkthdr.len--;
- return;
- }
- cnt -= m->m_len;
- m = m->m_next;
- if (m == 0)
- break;
- }
- panic("tcp_pulloutofband");
-}
-
-/*
- * Collect new round-trip time estimate
- * and update averages and current timeout.
- */
-static void
-tcp_xmit_timer(tp, rtt)
- register struct tcpcb *tp;
- int rtt;
-{
- register int delta;
-
- tcpstat.tcps_rttupdated++;
- tp->t_rttupdated++;
- if (tp->t_srtt != 0) {
- /*
- * srtt is stored as fixed point with 5 bits after the
- * binary point (i.e., scaled by 8). The following magic
- * is equivalent to the smoothing algorithm in rfc793 with
- * an alpha of .875 (srtt = rtt/8 + srtt*7/8 in fixed
- * point). Adjust rtt to origin 0.
- */
- delta = ((rtt - 1) << TCP_DELTA_SHIFT)
- - (tp->t_srtt >> (TCP_RTT_SHIFT - TCP_DELTA_SHIFT));
-
- if ((tp->t_srtt += delta) <= 0)
- tp->t_srtt = 1;
-
- /*
- * We accumulate a smoothed rtt variance (actually, a
- * smoothed mean difference), then set the retransmit
- * timer to smoothed rtt + 4 times the smoothed variance.
- * rttvar is stored as fixed point with 4 bits after the
- * binary point (scaled by 16). The following is
- * equivalent to rfc793 smoothing with an alpha of .75
- * (rttvar = rttvar*3/4 + |delta| / 4). This replaces
- * rfc793's wired-in beta.
- */
- if (delta < 0)
- delta = -delta;
- delta -= tp->t_rttvar >> (TCP_RTTVAR_SHIFT - TCP_DELTA_SHIFT);
- if ((tp->t_rttvar += delta) <= 0)
- tp->t_rttvar = 1;
- } else {
- /*
- * No rtt measurement yet - use the unsmoothed rtt.
- * Set the variance to half the rtt (so our first
- * retransmit happens at 3*rtt).
- */
- tp->t_srtt = rtt << TCP_RTT_SHIFT;
- tp->t_rttvar = rtt << (TCP_RTTVAR_SHIFT - 1);
- }
- tp->t_rtttime = 0;
- tp->t_rxtshift = 0;
-
- /*
- * the retransmit should happen at rtt + 4 * rttvar.
- * Because of the way we do the smoothing, srtt and rttvar
- * will each average +1/2 tick of bias. When we compute
- * the retransmit timer, we want 1/2 tick of rounding and
- * 1 extra tick because of +-1/2 tick uncertainty in the
- * firing of the timer. The bias will give us exactly the
- * 1.5 tick we need. But, because the bias is
- * statistical, we have to test that we don't drop below
- * the minimum feasible timer (which is 2 ticks).
- */
- TCPT_RANGESET(tp->t_rxtcur, TCP_REXMTVAL(tp),
- max(tp->t_rttmin, rtt + 2), TCPTV_REXMTMAX);
-
- /*
- * We received an ack for a packet that wasn't retransmitted;
- * it is probably safe to discard any error indications we've
- * received recently. This isn't quite right, but close enough
- * for now (a route might have failed after we sent a segment,
- * and the return path might not be symmetrical).
- */
- tp->t_softerror = 0;
-}
-
-/*
- * Determine a reasonable value for maxseg size.
- * If the route is known, check route for mtu.
- * If none, use an mss that can be handled on the outgoing
- * interface without forcing IP to fragment; if bigger than
- * an mbuf cluster (MCLBYTES), round down to nearest multiple of MCLBYTES
- * to utilize large mbufs. If no route is found, route has no mtu,
- * or the destination isn't local, use a default, hopefully conservative
- * size (usually 512 or the default IP max size, but no more than the mtu
- * of the interface), as we can't discover anything about intervening
- * gateways or networks. We also initialize the congestion/slow start
- * window to be a single segment if the destination isn't local.
- * While looking at the routing entry, we also initialize other path-dependent
- * parameters from pre-set or cached values in the routing entry.
- *
- * Also take into account the space needed for options that we
- * send regularly. Make maxseg shorter by that amount to assure
- * that we can send maxseg amount of data even when the options
- * are present. Store the upper limit of the length of options plus
- * data in maxopd.
- *
- * NOTE that this routine is only called when we process an incoming
- * segment, for outgoing segments only tcp_mssopt is called.
- *
- * In case of T/TCP, we call this routine during implicit connection
- * setup as well (offer = -1), to initialize maxseg from the cached
- * MSS of our peer.
- */
-void
-tcp_mss(tp, offer)
- struct tcpcb *tp;
- int offer;
-{
- register struct rtentry *rt;
- struct ifnet *ifp;
- register int rtt, mss;
- u_long bufsize;
- struct inpcb *inp;
- struct socket *so;
- struct rmxp_tao *taop;
- int origoffer = offer;
-#ifdef INET6
- int isipv6;
- int min_protoh;
-#endif
-
- inp = tp->t_inpcb;
-#ifdef INET6
- isipv6 = ((inp->inp_vflag & INP_IPV6) != 0) ? 1 : 0;
- min_protoh = isipv6 ? sizeof (struct ip6_hdr) + sizeof (struct tcphdr)
- : sizeof (struct tcpiphdr);
-#else
-#define min_protoh (sizeof (struct tcpiphdr))
-#endif
-#ifdef INET6
- if (isipv6)
- rt = tcp_rtlookup6(inp);
- else
-#endif
- rt = tcp_rtlookup(inp);
- if (rt == NULL) {
- tp->t_maxopd = tp->t_maxseg =
-#ifdef INET6
- isipv6 ? tcp_v6mssdflt :
-#endif /* INET6 */
- tcp_mssdflt;
- return;
- }
- ifp = rt->rt_ifp;
- so = inp->inp_socket;
-
- taop = rmx_taop(rt->rt_rmx);
- /*
- * Offer == -1 means that we didn't receive SYN yet,
- * use cached value in that case;
- */
- if (offer == -1)
- offer = taop->tao_mssopt;
- /*
- * Offer == 0 means that there was no MSS on the SYN segment,
- * in this case we use tcp_mssdflt.
- */
- if (offer == 0)
- offer =
-#ifdef INET6
- isipv6 ? tcp_v6mssdflt :
-#endif /* INET6 */
- tcp_mssdflt;
- else
- /*
- * Sanity check: make sure that maxopd will be large
- * enough to allow some data on segments even is the
- * all the option space is used (40bytes). Otherwise
- * funny things may happen in tcp_output.
- */
- offer = max(offer, 64);
- taop->tao_mssopt = offer;
-
- /*
- * While we're here, check if there's an initial rtt
- * or rttvar. Convert from the route-table units
- * to scaled multiples of the slow timeout timer.
- */
- if (tp->t_srtt == 0 && (rtt = rt->rt_rmx.rmx_rtt)) {
- /*
- * XXX the lock bit for RTT indicates that the value
- * is also a minimum value; this is subject to time.
- */
- if (rt->rt_rmx.rmx_locks & RTV_RTT)
- tp->t_rttmin = rtt / (RTM_RTTUNIT / hz);
- tp->t_srtt = rtt / (RTM_RTTUNIT / (hz * TCP_RTT_SCALE));
- tcpstat.tcps_usedrtt++;
- if (rt->rt_rmx.rmx_rttvar) {
- tp->t_rttvar = rt->rt_rmx.rmx_rttvar /
- (RTM_RTTUNIT / (hz * TCP_RTTVAR_SCALE));
- tcpstat.tcps_usedrttvar++;
- } else {
- /* default variation is +- 1 rtt */
- tp->t_rttvar =
- tp->t_srtt * TCP_RTTVAR_SCALE / TCP_RTT_SCALE;
- }
- TCPT_RANGESET(tp->t_rxtcur,
- ((tp->t_srtt >> 2) + tp->t_rttvar) >> 1,
- tp->t_rttmin, TCPTV_REXMTMAX);
- }
- /*
- * if there's an mtu associated with the route, use it
- * else, use the link mtu.
- */
- if (rt->rt_rmx.rmx_mtu)
- mss = rt->rt_rmx.rmx_mtu - min_protoh;
- else
- {
- mss =
-#ifdef INET6
- (isipv6 ? nd_ifinfo[rt->rt_ifp->if_index].linkmtu :
-#endif
- ifp->if_mtu
-#ifdef INET6
- )
-#endif
- - min_protoh;
-#ifdef INET6
- if (isipv6) {
- if (!in6_localaddr(&inp->in6p_faddr))
- mss = min(mss, tcp_v6mssdflt);
- } else
-#endif
- if (!in_localaddr(inp->inp_faddr))
- mss = min(mss, tcp_mssdflt);
- }
- mss = min(mss, offer);
- /*
- * maxopd stores the maximum length of data AND options
- * in a segment; maxseg is the amount of data in a normal
- * segment. We need to store this value (maxopd) apart
- * from maxseg, because now every segment carries options
- * and thus we normally have somewhat less data in segments.
- */
- tp->t_maxopd = mss;
-
- /*
- * In case of T/TCP, origoffer==-1 indicates, that no segments
- * were received yet. In this case we just guess, otherwise
- * we do the same as before T/TCP.
- */
- if ((tp->t_flags & (TF_REQ_TSTMP|TF_NOOPT)) == TF_REQ_TSTMP &&
- (origoffer == -1 ||
- (tp->t_flags & TF_RCVD_TSTMP) == TF_RCVD_TSTMP))
- mss -= TCPOLEN_TSTAMP_APPA;
- if ((tp->t_flags & (TF_REQ_CC|TF_NOOPT)) == TF_REQ_CC &&
- (origoffer == -1 ||
- (tp->t_flags & TF_RCVD_CC) == TF_RCVD_CC))
- mss -= TCPOLEN_CC_APPA;
-
-#if (MCLBYTES & (MCLBYTES - 1)) == 0
- if (mss > MCLBYTES)
- mss &= ~(MCLBYTES-1);
-#else
- if (mss > MCLBYTES)
- mss = mss / MCLBYTES * MCLBYTES;
-#endif
- /*
- * If there's a pipesize, change the socket buffer
- * to that size. Make the socket buffers an integral
- * number of mss units; if the mss is larger than
- * the socket buffer, decrease the mss.
- */
-#ifdef RTV_SPIPE
- if ((bufsize = rt->rt_rmx.rmx_sendpipe) == 0)
-#endif
- bufsize = so->so_snd.sb_hiwat;
- if (bufsize < mss)
- mss = bufsize;
- else {
- bufsize = roundup(bufsize, mss);
- if (bufsize > sb_max)
- bufsize = sb_max;
- (void)sbreserve(&so->so_snd, bufsize, so, NULL);
- }
- tp->t_maxseg = mss;
-
-#ifdef RTV_RPIPE
- if ((bufsize = rt->rt_rmx.rmx_recvpipe) == 0)
-#endif
- bufsize = so->so_rcv.sb_hiwat;
- if (bufsize > mss) {
- bufsize = roundup(bufsize, mss);
- if (bufsize > sb_max)
- bufsize = sb_max;
- (void)sbreserve(&so->so_rcv, bufsize, so, NULL);
- }
-
- /*
- * Set the slow-start flight size depending on whether this
- * is a local network or not.
- */
- if (
-#ifdef INET6
- (isipv6 && in6_localaddr(&inp->in6p_faddr)) ||
- (!isipv6 &&
-#endif
- in_localaddr(inp->inp_faddr)
-#ifdef INET6
- )
-#endif
- )
- tp->snd_cwnd = mss * ss_fltsz_local;
- else
- tp->snd_cwnd = mss * ss_fltsz;
-
- if (rt->rt_rmx.rmx_ssthresh) {
- /*
- * There's some sort of gateway or interface
- * buffer limit on the path. Use this to set
- * the slow start threshhold, but set the
- * threshold to no less than 2*mss.
- */
- tp->snd_ssthresh = max(2 * mss, rt->rt_rmx.rmx_ssthresh);
- tcpstat.tcps_usedssthresh++;
- }
-}
-
-/*
- * Determine the MSS option to send on an outgoing SYN.
- */
-int
-tcp_mssopt(tp)
- struct tcpcb *tp;
-{
- struct rtentry *rt;
-#ifdef INET6
- int isipv6;
- int min_protoh;
-#endif
-
-#ifdef INET6
- isipv6 = ((tp->t_inpcb->inp_vflag & INP_IPV6) != 0) ? 1 : 0;
- min_protoh = isipv6 ? sizeof (struct ip6_hdr) + sizeof (struct tcphdr)
- : sizeof (struct tcpiphdr);
-#else
-#define min_protoh (sizeof (struct tcpiphdr))
-#endif
-#ifdef INET6
- if (isipv6)
- rt = tcp_rtlookup6(tp->t_inpcb);
- else
-#endif /* INET6 */
- rt = tcp_rtlookup(tp->t_inpcb);
- if (rt == NULL)
- return
-#ifdef INET6
- isipv6 ? tcp_v6mssdflt :
-#endif /* INET6 */
- tcp_mssdflt;
-
- return rt->rt_ifp->if_mtu - min_protoh;
-}
diff --git a/sys/netinet/tcp_timewait.c b/sys/netinet/tcp_timewait.c
deleted file mode 100644
index ee62998c63ef..000000000000
--- a/sys/netinet/tcp_timewait.c
+++ /dev/null
@@ -1,1303 +0,0 @@
-/*
- * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
- * 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)tcp_subr.c 8.2 (Berkeley) 5/24/95
- * $FreeBSD$
- */
-
-#include "opt_compat.h"
-#include "opt_inet6.h"
-#include "opt_ipsec.h"
-#include "opt_tcpdebug.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/callout.h>
-#include <sys/kernel.h>
-#include <sys/sysctl.h>
-#include <sys/malloc.h>
-#include <sys/mbuf.h>
-#ifdef INET6
-#include <sys/domain.h>
-#endif
-#include <sys/proc.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-#include <sys/protosw.h>
-
-#include <vm/vm_zone.h>
-
-#include <net/route.h>
-#include <net/if.h>
-
-#define _IP_VHL
-#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#ifdef INET6
-#include <netinet/ip6.h>
-#endif
-#include <netinet/in_pcb.h>
-#ifdef INET6
-#include <netinet6/in6_pcb.h>
-#endif
-#include <netinet/in_var.h>
-#include <netinet/ip_var.h>
-#ifdef INET6
-#include <netinet6/ip6_var.h>
-#endif
-#include <netinet/tcp.h>
-#include <netinet/tcp_fsm.h>
-#include <netinet/tcp_seq.h>
-#include <netinet/tcp_timer.h>
-#include <netinet/tcp_var.h>
-#ifdef INET6
-#include <netinet6/tcp6_var.h>
-#endif
-#include <netinet/tcpip.h>
-#ifdef TCPDEBUG
-#include <netinet/tcp_debug.h>
-#endif
-#include <netinet6/ip6protosw.h>
-
-#ifdef IPSEC
-#include <netinet6/ipsec.h>
-#endif /*IPSEC*/
-
-int tcp_mssdflt = TCP_MSS;
-SYSCTL_INT(_net_inet_tcp, TCPCTL_MSSDFLT, mssdflt, CTLFLAG_RW,
- &tcp_mssdflt , 0, "Default TCP Maximum Segment Size");
-
-#ifdef INET6
-int tcp_v6mssdflt = TCP6_MSS;
-SYSCTL_INT(_net_inet_tcp, TCPCTL_V6MSSDFLT, v6mssdflt,
- CTLFLAG_RW, &tcp_v6mssdflt , 0,
- "Default TCP Maximum Segment Size for IPv6");
-#endif
-
-#if 0
-static int tcp_rttdflt = TCPTV_SRTTDFLT / PR_SLOWHZ;
-SYSCTL_INT(_net_inet_tcp, TCPCTL_RTTDFLT, rttdflt, CTLFLAG_RW,
- &tcp_rttdflt , 0, "Default maximum TCP Round Trip Time");
-#endif
-
-static int tcp_do_rfc1323 = 1;
-SYSCTL_INT(_net_inet_tcp, TCPCTL_DO_RFC1323, rfc1323, CTLFLAG_RW,
- &tcp_do_rfc1323 , 0, "Enable rfc1323 (high performance TCP) extensions");
-
-static int tcp_do_rfc1644 = 0;
-SYSCTL_INT(_net_inet_tcp, TCPCTL_DO_RFC1644, rfc1644, CTLFLAG_RW,
- &tcp_do_rfc1644 , 0, "Enable rfc1644 (TTCP) extensions");
-
-static int tcp_tcbhashsize = 0;
-SYSCTL_INT(_net_inet_tcp, OID_AUTO, tcbhashsize, CTLFLAG_RD,
- &tcp_tcbhashsize, 0, "Size of TCP control-block hashtable");
-
-static int do_tcpdrain = 1;
-SYSCTL_INT(_debug, OID_AUTO, do_tcpdrain, CTLFLAG_RW, &do_tcpdrain, 0,
- "Enable non Net3 compliant tcp_drain");
-
-SYSCTL_INT(_net_inet_tcp, OID_AUTO, pcbcount, CTLFLAG_RD,
- &tcbinfo.ipi_count, 0, "Number of active PCBs");
-
-static void tcp_cleartaocache __P((void));
-static void tcp_notify __P((struct inpcb *, int));
-
-/*
- * Target size of TCP PCB hash tables. Must be a power of two.
- *
- * Note that this can be overridden by the kernel environment
- * variable net.inet.tcp.tcbhashsize
- */
-#ifndef TCBHASHSIZE
-#define TCBHASHSIZE 512
-#endif
-
-/*
- * This is the actual shape of what we allocate using the zone
- * allocator. Doing it this way allows us to protect both structures
- * using the same generation count, and also eliminates the overhead
- * of allocating tcpcbs separately. By hiding the structure here,
- * we avoid changing most of the rest of the code (although it needs
- * to be changed, eventually, for greater efficiency).
- */
-#define ALIGNMENT 32
-#define ALIGNM1 (ALIGNMENT - 1)
-struct inp_tp {
- union {
- struct inpcb inp;
- char align[(sizeof(struct inpcb) + ALIGNM1) & ~ALIGNM1];
- } inp_tp_u;
- struct tcpcb tcb;
- struct callout inp_tp_rexmt, inp_tp_persist, inp_tp_keep, inp_tp_2msl;
- struct callout inp_tp_delack;
-};
-#undef ALIGNMENT
-#undef ALIGNM1
-
-/*
- * Tcp initialization
- */
-void
-tcp_init()
-{
- int hashsize;
-
- tcp_iss = random(); /* wrong, but better than a constant */
- tcp_ccgen = 1;
- tcp_cleartaocache();
-
- tcp_delacktime = TCPTV_DELACK;
- tcp_keepinit = TCPTV_KEEP_INIT;
- tcp_keepidle = TCPTV_KEEP_IDLE;
- tcp_keepintvl = TCPTV_KEEPINTVL;
- tcp_maxpersistidle = TCPTV_KEEP_IDLE;
- tcp_msl = TCPTV_MSL;
-
- LIST_INIT(&tcb);
- tcbinfo.listhead = &tcb;
- TUNABLE_INT_FETCH("net.inet.tcp.tcbhashsize", TCBHASHSIZE, hashsize);
- if (!powerof2(hashsize)) {
- printf("WARNING: TCB hash size not a power of 2\n");
- hashsize = 512; /* safe default */
- }
- tcp_tcbhashsize = hashsize;
- tcbinfo.hashbase = hashinit(hashsize, M_PCB, &tcbinfo.hashmask);
- tcbinfo.porthashbase = hashinit(hashsize, M_PCB,
- &tcbinfo.porthashmask);
- tcbinfo.ipi_zone = zinit("tcpcb", sizeof(struct inp_tp), maxsockets,
- ZONE_INTERRUPT, 0);
-#ifdef INET6
-#define TCP_MINPROTOHDR (sizeof(struct ip6_hdr) + sizeof(struct tcphdr))
-#else /* INET6 */
-#define TCP_MINPROTOHDR (sizeof(struct tcpiphdr))
-#endif /* INET6 */
- if (max_protohdr < TCP_MINPROTOHDR)
- max_protohdr = TCP_MINPROTOHDR;
- if (max_linkhdr + TCP_MINPROTOHDR > MHLEN)
- panic("tcp_init");
-#undef TCP_MINPROTOHDR
-}
-
-/*
- * Create template to be used to send tcp packets on a connection.
- * Call after host entry created, allocates an mbuf and fills
- * in a skeletal tcp/ip header, minimizing the amount of work
- * necessary when the connection is used.
- */
-struct tcptemp *
-tcp_template(tp)
- struct tcpcb *tp;
-{
- register struct inpcb *inp = tp->t_inpcb;
- register struct mbuf *m;
- register struct tcptemp *n;
-
- if ((n = tp->t_template) == 0) {
- m = m_get(M_DONTWAIT, MT_HEADER);
- if (m == NULL)
- return (0);
- m->m_len = sizeof (struct tcptemp);
- n = mtod(m, struct tcptemp *);
- }
-#ifdef INET6
- if ((inp->inp_vflag & INP_IPV6) != 0) {
- register struct ip6_hdr *ip6;
-
- ip6 = (struct ip6_hdr *)n->tt_ipgen;
- ip6->ip6_flow = (ip6->ip6_flow & ~IPV6_FLOWINFO_MASK) |
- (inp->in6p_flowinfo & IPV6_FLOWINFO_MASK);
- ip6->ip6_vfc = (ip6->ip6_vfc & ~IPV6_VERSION_MASK) |
- (IPV6_VERSION & IPV6_VERSION_MASK);
- ip6->ip6_nxt = IPPROTO_TCP;
- ip6->ip6_plen = sizeof(struct tcphdr);
- ip6->ip6_src = inp->in6p_laddr;
- ip6->ip6_dst = inp->in6p_faddr;
- } else
-#endif
- {
- register struct ipovly *ipov;
-
- ipov = (struct ipovly *)n->tt_ipgen;
- bzero(ipov->ih_x1, sizeof(ipov->ih_x1));
- ipov->ih_pr = IPPROTO_TCP;
- ipov->ih_len = htons(sizeof (struct tcpiphdr) - sizeof (struct ip));
- ipov->ih_src = inp->inp_laddr;
- ipov->ih_dst = inp->inp_faddr;
- }
- n->tt_t.th_sport = inp->inp_lport;
- n->tt_t.th_dport = inp->inp_fport;
- n->tt_t.th_seq = 0;
- n->tt_t.th_ack = 0;
- n->tt_t.th_x2 = 0;
- n->tt_t.th_off = 5;
- n->tt_t.th_flags = 0;
- n->tt_t.th_win = 0;
- n->tt_t.th_sum = 0;
- n->tt_t.th_urp = 0;
- return (n);
-}
-
-/*
- * Send a single message to the TCP at address specified by
- * the given TCP/IP header. If m == 0, then we make a copy
- * of the tcpiphdr at ti and send directly to the addressed host.
- * This is used to force keep alive messages out using the TCP
- * template for a connection tp->t_template. If flags are given
- * then we send a message back to the TCP which originated the
- * segment ti, and discard the mbuf containing it and any other
- * attached mbufs.
- *
- * In any case the ack and sequence number of the transmitted
- * segment are as specified by the parameters.
- *
- * NOTE: If m != NULL, then ti must point to *inside* the mbuf.
- */
-void
-tcp_respond(tp, ipgen, th, m, ack, seq, flags)
- struct tcpcb *tp;
- void *ipgen;
- register struct tcphdr *th;
- register struct mbuf *m;
- tcp_seq ack, seq;
- int flags;
-{
- register int tlen;
- int win = 0;
- struct route *ro = 0;
- struct route sro;
- struct ip *ip;
- struct ipovly *ipov;
- struct tcphdr *nth;
-#ifdef INET6
- struct route_in6 *ro6 = 0;
- struct route_in6 sro6;
- struct ip6_hdr *ip6;
- int isipv6;
-#endif /* INET6 */
- int ipflags = 0;
-
-#ifdef INET6
- isipv6 = IP_VHL_V(((struct ip *)ipgen)->ip_vhl) == 6;
- ip6 = ipgen;
-#endif /* INET6 */
- ip = ipgen;
- ipov = ipgen;
-
- if (tp) {
- if (!(flags & TH_RST)) {
- win = sbspace(&tp->t_inpcb->inp_socket->so_rcv);
- if (win > (long)TCP_MAXWIN << tp->rcv_scale)
- win = (long)TCP_MAXWIN << tp->rcv_scale;
- }
-#ifdef INET6
- if (isipv6)
- ro6 = &tp->t_inpcb->in6p_route;
- else
-#endif /* INET6 */
- ro = &tp->t_inpcb->inp_route;
- } else {
-#ifdef INET6
- if (isipv6) {
- ro6 = &sro6;
- bzero(ro6, sizeof *ro6);
- } else
-#endif /* INET6 */
- {
- ro = &sro;
- bzero(ro, sizeof *ro);
- }
- }
- if (m == 0) {
- m = m_gethdr(M_DONTWAIT, MT_HEADER);
- if (m == NULL)
- return;
-#ifdef TCP_COMPAT_42
- tlen = 1;
-#else
- tlen = 0;
-#endif
- m->m_data += max_linkhdr;
-#ifdef INET6
- if (isipv6) {
- bcopy((caddr_t)ip6, mtod(m, caddr_t),
- sizeof(struct ip6_hdr));
- ip6 = mtod(m, struct ip6_hdr *);
- nth = (struct tcphdr *)(ip6 + 1);
- } else
-#endif /* INET6 */
- {
- bcopy((caddr_t)ip, mtod(m, caddr_t), sizeof(struct ip));
- ip = mtod(m, struct ip *);
- ipov = mtod(m, struct ipovly *);
- nth = (struct tcphdr *)(ip + 1);
- }
- bcopy((caddr_t)th, (caddr_t)nth, sizeof(struct tcphdr));
- flags = TH_ACK;
- } else {
- m_freem(m->m_next);
- m->m_next = 0;
- m->m_data = (caddr_t)ipgen;
- /* m_len is set later */
- tlen = 0;
-#define xchg(a,b,type) { type t; t=a; a=b; b=t; }
-#ifdef INET6
- if (isipv6) {
- xchg(ip6->ip6_dst, ip6->ip6_src, struct in6_addr);
- nth = (struct tcphdr *)(ip6 + 1);
- } else
-#endif /* INET6 */
- {
- xchg(ip->ip_dst.s_addr, ip->ip_src.s_addr, n_long);
- nth = (struct tcphdr *)(ip + 1);
- }
- if (th != nth) {
- /*
- * this is usually a case when an extension header
- * exists between the IPv6 header and the
- * TCP header.
- */
- nth->th_sport = th->th_sport;
- nth->th_dport = th->th_dport;
- }
- xchg(nth->th_dport, nth->th_sport, n_short);
-#undef xchg
- }
-#ifdef INET6
- if (isipv6) {
- ip6->ip6_plen = htons((u_short)(sizeof (struct tcphdr) +
- tlen));
- tlen += sizeof (struct ip6_hdr) + sizeof (struct tcphdr);
- } else
-#endif
- {
- ipov->ih_len = htons((u_short)(sizeof (struct tcphdr) + tlen));
- tlen += sizeof (struct tcpiphdr);
- }
- m->m_len = tlen;
- m->m_pkthdr.len = tlen;
- m->m_pkthdr.rcvif = (struct ifnet *) 0;
- nth->th_seq = htonl(seq);
- nth->th_ack = htonl(ack);
- nth->th_x2 = 0;
- nth->th_off = sizeof (struct tcphdr) >> 2;
- nth->th_flags = flags;
- if (tp)
- nth->th_win = htons((u_short) (win >> tp->rcv_scale));
- else
- nth->th_win = htons((u_short)win);
- nth->th_urp = 0;
- nth->th_sum = 0;
-#ifdef INET6
- if (isipv6) {
- nth->th_sum = in6_cksum(m, IPPROTO_TCP,
- sizeof(struct ip6_hdr),
- tlen - sizeof(struct ip6_hdr));
- ip6->ip6_hlim = in6_selecthlim(tp ? tp->t_inpcb : NULL,
- ro6 && ro6->ro_rt ?
- ro6->ro_rt->rt_ifp :
- NULL);
- } else
-#endif /* INET6 */
- {
- bzero(ipov->ih_x1, sizeof(ipov->ih_x1));
- nth->th_sum = in_cksum(m, tlen);
-#ifdef INET6
- /* Re-initialization for later version check */
- ip->ip_vhl = IP_MAKE_VHL(IPVERSION, 0);
-#endif /* INET6 */
- ip->ip_len = tlen;
- ip->ip_ttl = ip_defttl;
- }
-#ifdef TCPDEBUG
- if (tp == NULL || (tp->t_inpcb->inp_socket->so_options & SO_DEBUG))
- tcp_trace(TA_OUTPUT, 0, tp, mtod(m, void *), th, 0);
-#endif
-#ifdef IPSEC
- if (tp != NULL) {
- m->m_pkthdr.rcvif = (struct ifnet *)tp->t_inpcb->inp_socket;
- ipflags |=
-#ifdef INET6
- isipv6 ? IPV6_SOCKINMRCVIF :
-#endif
- IP_SOCKINMRCVIF;
- }
-#endif
-#ifdef INET6
- if (isipv6) {
- (void)ip6_output(m, NULL, ro6, ipflags, NULL, NULL);
- if (ro6 == &sro6 && ro6->ro_rt) {
- RTFREE(ro6->ro_rt);
- ro6->ro_rt = NULL;
- }
- } else
-#endif /* INET6 */
- {
- (void) ip_output(m, NULL, ro, ipflags, NULL);
- if (ro == &sro && ro->ro_rt) {
- RTFREE(ro->ro_rt);
- ro->ro_rt = NULL;
- }
- }
-}
-
-/*
- * Create a new TCP control block, making an
- * empty reassembly queue and hooking it to the argument
- * protocol control block. The `inp' parameter must have
- * come from the zone allocator set up in tcp_init().
- */
-struct tcpcb *
-tcp_newtcpcb(inp)
- struct inpcb *inp;
-{
- struct inp_tp *it;
- register struct tcpcb *tp;
-#ifdef INET6
- int isipv6 = (inp->inp_vflag & INP_IPV6) != 0;
-#endif /* INET6 */
-
- it = (struct inp_tp *)inp;
- tp = &it->tcb;
- bzero((char *) tp, sizeof(struct tcpcb));
- LIST_INIT(&tp->t_segq);
- tp->t_maxseg = tp->t_maxopd =
-#ifdef INET6
- isipv6 ? tcp_v6mssdflt :
-#endif /* INET6 */
- tcp_mssdflt;
-
- /* Set up our timeouts. */
- callout_init(tp->tt_rexmt = &it->inp_tp_rexmt);
- callout_init(tp->tt_persist = &it->inp_tp_persist);
- callout_init(tp->tt_keep = &it->inp_tp_keep);
- callout_init(tp->tt_2msl = &it->inp_tp_2msl);
- callout_init(tp->tt_delack = &it->inp_tp_delack);
-
- if (tcp_do_rfc1323)
- tp->t_flags = (TF_REQ_SCALE|TF_REQ_TSTMP);
- if (tcp_do_rfc1644)
- tp->t_flags |= TF_REQ_CC;
- tp->t_inpcb = inp; /* XXX */
- /*
- * Init srtt to TCPTV_SRTTBASE (0), so we can tell that we have no
- * rtt estimate. Set rttvar so that srtt + 4 * rttvar gives
- * reasonable initial retransmit time.
- */
- tp->t_srtt = TCPTV_SRTTBASE;
- tp->t_rttvar = ((TCPTV_RTOBASE - TCPTV_SRTTBASE) << TCP_RTTVAR_SHIFT) / 4;
- tp->t_rttmin = TCPTV_MIN;
- tp->t_rxtcur = TCPTV_RTOBASE;
- tp->snd_cwnd = TCP_MAXWIN << TCP_MAX_WINSHIFT;
- tp->snd_ssthresh = TCP_MAXWIN << TCP_MAX_WINSHIFT;
- tp->t_rcvtime = ticks;
- /*
- * IPv4 TTL initialization is necessary for an IPv6 socket as well,
- * because the socket may be bound to an IPv6 wildcard address,
- * which may match an IPv4-mapped IPv6 address.
- */
- inp->inp_ip_ttl = ip_defttl;
- inp->inp_ppcb = (caddr_t)tp;
- return (tp); /* XXX */
-}
-
-/*
- * Drop a TCP connection, reporting
- * the specified error. If connection is synchronized,
- * then send a RST to peer.
- */
-struct tcpcb *
-tcp_drop(tp, errno)
- register struct tcpcb *tp;
- int errno;
-{
- struct socket *so = tp->t_inpcb->inp_socket;
-
- if (TCPS_HAVERCVDSYN(tp->t_state)) {
- tp->t_state = TCPS_CLOSED;
- (void) tcp_output(tp);
- tcpstat.tcps_drops++;
- } else
- tcpstat.tcps_conndrops++;
- if (errno == ETIMEDOUT && tp->t_softerror)
- errno = tp->t_softerror;
- so->so_error = errno;
- return (tcp_close(tp));
-}
-
-/*
- * Close a TCP control block:
- * discard all space held by the tcp
- * discard internet protocol block
- * wake up any sleepers
- */
-struct tcpcb *
-tcp_close(tp)
- register struct tcpcb *tp;
-{
- register struct tseg_qent *q;
- struct inpcb *inp = tp->t_inpcb;
- struct socket *so = inp->inp_socket;
-#ifdef INET6
- int isipv6 = (inp->inp_vflag & INP_IPV6) != 0;
-#endif /* INET6 */
- register struct rtentry *rt;
- int dosavessthresh;
-
- /*
- * Make sure that all of our timers are stopped before we
- * delete the PCB.
- */
- callout_stop(tp->tt_rexmt);
- callout_stop(tp->tt_persist);
- callout_stop(tp->tt_keep);
- callout_stop(tp->tt_2msl);
- callout_stop(tp->tt_delack);
-
- /*
- * If we got enough samples through the srtt filter,
- * save the rtt and rttvar in the routing entry.
- * 'Enough' is arbitrarily defined as the 16 samples.
- * 16 samples is enough for the srtt filter to converge
- * to within 5% of the correct value; fewer samples and
- * we could save a very bogus rtt.
- *
- * Don't update the default route's characteristics and don't
- * update anything that the user "locked".
- */
- if (tp->t_rttupdated >= 16) {
- register u_long i = 0;
-#ifdef INET6
- if (isipv6) {
- struct sockaddr_in6 *sin6;
-
- if ((rt = inp->in6p_route.ro_rt) == NULL)
- goto no_valid_rt;
- sin6 = (struct sockaddr_in6 *)rt_key(rt);
- if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr))
- goto no_valid_rt;
- }
- else
-#endif /* INET6 */
- if ((rt = inp->inp_route.ro_rt) == NULL ||
- ((struct sockaddr_in *)rt_key(rt))->sin_addr.s_addr
- == INADDR_ANY)
- goto no_valid_rt;
-
- if ((rt->rt_rmx.rmx_locks & RTV_RTT) == 0) {
- i = tp->t_srtt *
- (RTM_RTTUNIT / (hz * TCP_RTT_SCALE));
- if (rt->rt_rmx.rmx_rtt && i)
- /*
- * filter this update to half the old & half
- * the new values, converting scale.
- * See route.h and tcp_var.h for a
- * description of the scaling constants.
- */
- rt->rt_rmx.rmx_rtt =
- (rt->rt_rmx.rmx_rtt + i) / 2;
- else
- rt->rt_rmx.rmx_rtt = i;
- tcpstat.tcps_cachedrtt++;
- }
- if ((rt->rt_rmx.rmx_locks & RTV_RTTVAR) == 0) {
- i = tp->t_rttvar *
- (RTM_RTTUNIT / (hz * TCP_RTTVAR_SCALE));
- if (rt->rt_rmx.rmx_rttvar && i)
- rt->rt_rmx.rmx_rttvar =
- (rt->rt_rmx.rmx_rttvar + i) / 2;
- else
- rt->rt_rmx.rmx_rttvar = i;
- tcpstat.tcps_cachedrttvar++;
- }
- /*
- * The old comment here said:
- * update the pipelimit (ssthresh) if it has been updated
- * already or if a pipesize was specified & the threshhold
- * got below half the pipesize. I.e., wait for bad news
- * before we start updating, then update on both good
- * and bad news.
- *
- * But we want to save the ssthresh even if no pipesize is
- * specified explicitly in the route, because such
- * connections still have an implicit pipesize specified
- * by the global tcp_sendspace. In the absence of a reliable
- * way to calculate the pipesize, it will have to do.
- */
- i = tp->snd_ssthresh;
- if (rt->rt_rmx.rmx_sendpipe != 0)
- dosavessthresh = (i < rt->rt_rmx.rmx_sendpipe / 2);
- else
- dosavessthresh = (i < so->so_snd.sb_hiwat / 2);
- if (((rt->rt_rmx.rmx_locks & RTV_SSTHRESH) == 0 &&
- i != 0 && rt->rt_rmx.rmx_ssthresh != 0)
- || dosavessthresh) {
- /*
- * convert the limit from user data bytes to
- * packets then to packet data bytes.
- */
- i = (i + tp->t_maxseg / 2) / tp->t_maxseg;
- if (i < 2)
- i = 2;
- i *= (u_long)(tp->t_maxseg +
-#ifdef INET6
- (isipv6 ? sizeof (struct ip6_hdr) +
- sizeof (struct tcphdr) :
-#endif
- sizeof (struct tcpiphdr)
-#ifdef INET6
- )
-#endif
- );
- if (rt->rt_rmx.rmx_ssthresh)
- rt->rt_rmx.rmx_ssthresh =
- (rt->rt_rmx.rmx_ssthresh + i) / 2;
- else
- rt->rt_rmx.rmx_ssthresh = i;
- tcpstat.tcps_cachedssthresh++;
- }
- }
- no_valid_rt:
- /* free the reassembly queue, if any */
- while((q = LIST_FIRST(&tp->t_segq)) != NULL) {
- LIST_REMOVE(q, tqe_q);
- m_freem(q->tqe_m);
- FREE(q, M_TSEGQ);
- }
- if (tp->t_template)
- (void) m_free(dtom(tp->t_template));
- inp->inp_ppcb = NULL;
- soisdisconnected(so);
-#ifdef INET6
- if (INP_CHECK_SOCKAF(so, AF_INET6))
- in6_pcbdetach(inp);
- else
-#endif /* INET6 */
- in_pcbdetach(inp);
- tcpstat.tcps_closed++;
- return ((struct tcpcb *)0);
-}
-
-void
-tcp_drain()
-{
- if (do_tcpdrain)
- {
- struct inpcb *inpb;
- struct tcpcb *tcpb;
- struct tseg_qent *te;
-
- /*
- * Walk the tcpbs, if existing, and flush the reassembly queue,
- * if there is one...
- * XXX: The "Net/3" implementation doesn't imply that the TCP
- * reassembly queue should be flushed, but in a situation
- * where we're really low on mbufs, this is potentially
- * usefull.
- */
- for (inpb = tcbinfo.listhead->lh_first; inpb;
- inpb = inpb->inp_list.le_next) {
- if ((tcpb = intotcpcb(inpb))) {
- while ((te = LIST_FIRST(&tcpb->t_segq))
- != NULL) {
- LIST_REMOVE(te, tqe_q);
- m_freem(te->tqe_m);
- FREE(te, M_TSEGQ);
- }
- }
- }
-
- }
-}
-
-/*
- * Notify a tcp user of an asynchronous error;
- * store error as soft error, but wake up user
- * (for now, won't do anything until can select for soft error).
- */
-static void
-tcp_notify(inp, error)
- struct inpcb *inp;
- int error;
-{
- register struct tcpcb *tp = (struct tcpcb *)inp->inp_ppcb;
- register struct socket *so = inp->inp_socket;
-
- /*
- * Ignore some errors if we are hooked up.
- * If connection hasn't completed, has retransmitted several times,
- * and receives a second error, give up now. This is better
- * than waiting a long time to establish a connection that
- * can never complete.
- */
- if (tp->t_state == TCPS_ESTABLISHED &&
- (error == EHOSTUNREACH || error == ENETUNREACH ||
- error == EHOSTDOWN)) {
- return;
- } else if (tp->t_state < TCPS_ESTABLISHED && tp->t_rxtshift > 3 &&
- tp->t_softerror)
- so->so_error = error;
- else
- tp->t_softerror = error;
- wakeup((caddr_t) &so->so_timeo);
- sorwakeup(so);
- sowwakeup(so);
-}
-
-static int
-tcp_pcblist SYSCTL_HANDLER_ARGS
-{
- int error, i, n, s;
- struct inpcb *inp, **inp_list;
- inp_gen_t gencnt;
- struct xinpgen xig;
-
- /*
- * The process of preparing the TCB list is too time-consuming and
- * resource-intensive to repeat twice on every request.
- */
- if (req->oldptr == 0) {
- n = tcbinfo.ipi_count;
- req->oldidx = 2 * (sizeof xig)
- + (n + n/8) * sizeof(struct xtcpcb);
- return 0;
- }
-
- if (req->newptr != 0)
- return EPERM;
-
- /*
- * OK, now we're committed to doing something.
- */
- s = splnet();
- gencnt = tcbinfo.ipi_gencnt;
- n = tcbinfo.ipi_count;
- splx(s);
-
- xig.xig_len = sizeof xig;
- xig.xig_count = n;
- xig.xig_gen = gencnt;
- xig.xig_sogen = so_gencnt;
- error = SYSCTL_OUT(req, &xig, sizeof xig);
- if (error)
- return error;
-
- inp_list = malloc(n * sizeof *inp_list, M_TEMP, M_WAITOK);
- if (inp_list == 0)
- return ENOMEM;
-
- s = splnet();
- for (inp = tcbinfo.listhead->lh_first, i = 0; inp && i < n;
- inp = inp->inp_list.le_next) {
- if (inp->inp_gencnt <= gencnt && !prison_xinpcb(req->p, inp))
- inp_list[i++] = inp;
- }
- splx(s);
- n = i;
-
- error = 0;
- for (i = 0; i < n; i++) {
- inp = inp_list[i];
- if (inp->inp_gencnt <= gencnt) {
- struct xtcpcb xt;
- caddr_t inp_ppcb;
- xt.xt_len = sizeof xt;
- /* XXX should avoid extra copy */
- bcopy(inp, &xt.xt_inp, sizeof *inp);
- inp_ppcb = inp->inp_ppcb;
- if (inp_ppcb != NULL)
- bcopy(inp_ppcb, &xt.xt_tp, sizeof xt.xt_tp);
- else
- bzero((char *) &xt.xt_tp, sizeof xt.xt_tp);
- if (inp->inp_socket)
- sotoxsocket(inp->inp_socket, &xt.xt_socket);
- error = SYSCTL_OUT(req, &xt, sizeof xt);
- }
- }
- if (!error) {
- /*
- * Give the user an updated idea of our state.
- * If the generation differs from what we told
- * her before, she knows that something happened
- * while we were processing this request, and it
- * might be necessary to retry.
- */
- s = splnet();
- xig.xig_gen = tcbinfo.ipi_gencnt;
- xig.xig_sogen = so_gencnt;
- xig.xig_count = tcbinfo.ipi_count;
- splx(s);
- error = SYSCTL_OUT(req, &xig, sizeof xig);
- }
- free(inp_list, M_TEMP);
- return error;
-}
-
-SYSCTL_PROC(_net_inet_tcp, TCPCTL_PCBLIST, pcblist, CTLFLAG_RD, 0, 0,
- tcp_pcblist, "S,xtcpcb", "List of active TCP connections");
-
-static int
-tcp_getcred SYSCTL_HANDLER_ARGS
-{
- struct sockaddr_in addrs[2];
- struct inpcb *inp;
- int error, s;
-
- error = suser(req->p);
- if (error)
- return (error);
- error = SYSCTL_IN(req, addrs, sizeof(addrs));
- if (error)
- return (error);
- s = splnet();
- inp = in_pcblookup_hash(&tcbinfo, addrs[1].sin_addr, addrs[1].sin_port,
- addrs[0].sin_addr, addrs[0].sin_port, 0, NULL);
- if (inp == NULL || inp->inp_socket == NULL) {
- error = ENOENT;
- goto out;
- }
- error = SYSCTL_OUT(req, inp->inp_socket->so_cred, sizeof(struct ucred));
-out:
- splx(s);
- return (error);
-}
-
-SYSCTL_PROC(_net_inet_tcp, OID_AUTO, getcred, CTLTYPE_OPAQUE|CTLFLAG_RW,
- 0, 0, tcp_getcred, "S,ucred", "Get the ucred of a TCP connection");
-
-#ifdef INET6
-static int
-tcp6_getcred SYSCTL_HANDLER_ARGS
-{
- struct sockaddr_in6 addrs[2];
- struct inpcb *inp;
- int error, s, mapped = 0;
-
- error = suser(req->p);
- if (error)
- return (error);
- error = SYSCTL_IN(req, addrs, sizeof(addrs));
- if (error)
- return (error);
- if (IN6_IS_ADDR_V4MAPPED(&addrs[0].sin6_addr)) {
- if (IN6_IS_ADDR_V4MAPPED(&addrs[1].sin6_addr))
- mapped = 1;
- else
- return (EINVAL);
- }
- s = splnet();
- if (mapped == 1)
- inp = in_pcblookup_hash(&tcbinfo,
- *(struct in_addr *)&addrs[1].sin6_addr.s6_addr[12],
- addrs[1].sin6_port,
- *(struct in_addr *)&addrs[0].sin6_addr.s6_addr[12],
- addrs[0].sin6_port,
- 0, NULL);
- else
- inp = in6_pcblookup_hash(&tcbinfo, &addrs[1].sin6_addr,
- addrs[1].sin6_port,
- &addrs[0].sin6_addr, addrs[0].sin6_port,
- 0, NULL);
- if (inp == NULL || inp->inp_socket == NULL) {
- error = ENOENT;
- goto out;
- }
- error = SYSCTL_OUT(req, inp->inp_socket->so_cred,
- sizeof(struct ucred));
-out:
- splx(s);
- return (error);
-}
-
-SYSCTL_PROC(_net_inet6_tcp6, OID_AUTO, getcred, CTLTYPE_OPAQUE|CTLFLAG_RW,
- 0, 0,
- tcp6_getcred, "S,ucred", "Get the ucred of a TCP6 connection");
-#endif
-
-
-void
-tcp_ctlinput(cmd, sa, vip)
- int cmd;
- struct sockaddr *sa;
- void *vip;
-{
- register struct ip *ip = vip;
- register struct tcphdr *th;
- void (*notify) __P((struct inpcb *, int)) = tcp_notify;
-
- if (cmd == PRC_QUENCH)
- notify = tcp_quench;
- else if (cmd == PRC_MSGSIZE)
- notify = tcp_mtudisc;
- else if (!PRC_IS_REDIRECT(cmd) &&
- ((unsigned)cmd > PRC_NCMDS || inetctlerrmap[cmd] == 0))
- return;
- if (ip) {
- th = (struct tcphdr *)((caddr_t)ip
- + (IP_VHL_HL(ip->ip_vhl) << 2));
- in_pcbnotify(&tcb, sa, th->th_dport, ip->ip_src, th->th_sport,
- cmd, notify);
- } else
- in_pcbnotify(&tcb, sa, 0, zeroin_addr, 0, cmd, notify);
-}
-
-#ifdef INET6
-void
-tcp6_ctlinput(cmd, sa, d)
- int cmd;
- struct sockaddr *sa;
- void *d;
-{
- register struct tcphdr *thp;
- struct tcphdr th;
- void (*notify) __P((struct inpcb *, int)) = tcp_notify;
- struct sockaddr_in6 sa6;
- struct ip6_hdr *ip6;
- struct mbuf *m;
- int off;
-
- if (sa->sa_family != AF_INET6 ||
- sa->sa_len != sizeof(struct sockaddr_in6))
- return;
-
- if (cmd == PRC_QUENCH)
- notify = tcp_quench;
- else if (cmd == PRC_MSGSIZE)
- notify = tcp_mtudisc;
- else if (!PRC_IS_REDIRECT(cmd) &&
- ((unsigned)cmd > PRC_NCMDS || inet6ctlerrmap[cmd] == 0))
- return;
-
- /* if the parameter is from icmp6, decode it. */
- if (d != NULL) {
- struct ip6ctlparam *ip6cp = (struct ip6ctlparam *)d;
- m = ip6cp->ip6c_m;
- ip6 = ip6cp->ip6c_ip6;
- off = ip6cp->ip6c_off;
- } else {
- m = NULL;
- ip6 = NULL;
- }
-
- /*
- * Translate addresses into internal form.
- * Sa check if it is AF_INET6 is done at the top of this funciton.
- */
- sa6 = *(struct sockaddr_in6 *)sa;
- if (IN6_IS_ADDR_LINKLOCAL(&sa6.sin6_addr) != 0 && m != NULL &&
- m->m_pkthdr.rcvif != NULL)
- sa6.sin6_addr.s6_addr16[1] = htons(m->m_pkthdr.rcvif->if_index);
-
- if (ip6) {
- /*
- * XXX: We assume that when IPV6 is non NULL,
- * M and OFF are valid.
- */
- struct in6_addr s;
-
- /* translate addresses into internal form */
- memcpy(&s, &ip6->ip6_src, sizeof(s));
- if (IN6_IS_ADDR_LINKLOCAL(&s) != 0 && m != NULL &&
- m->m_pkthdr.rcvif != NULL)
- s.s6_addr16[1] = htons(m->m_pkthdr.rcvif->if_index);
-
- if (m->m_len < off + sizeof(*thp)) {
- /*
- * this should be rare case
- * because now MINCLSIZE is "(MHLEN + 1)",
- * so we compromise on this copy...
- */
- m_copydata(m, off, sizeof(th), (caddr_t)&th);
- thp = &th;
- } else
- thp = (struct tcphdr *)(mtod(m, caddr_t) + off);
- in6_pcbnotify(&tcb, (struct sockaddr *)&sa6, thp->th_dport,
- &s, thp->th_sport, cmd, notify);
- } else
- in6_pcbnotify(&tcb, (struct sockaddr *)&sa6, 0, &zeroin6_addr,
- 0, cmd, notify);
-}
-#endif /* INET6 */
-
-/*
- * When a source quench is received, close congestion window
- * to one segment. We will gradually open it again as we proceed.
- */
-void
-tcp_quench(inp, errno)
- struct inpcb *inp;
- int errno;
-{
- struct tcpcb *tp = intotcpcb(inp);
-
- if (tp)
- tp->snd_cwnd = tp->t_maxseg;
-}
-
-/*
- * When `need fragmentation' ICMP is received, update our idea of the MSS
- * based on the new value in the route. Also nudge TCP to send something,
- * since we know the packet we just sent was dropped.
- * This duplicates some code in the tcp_mss() function in tcp_input.c.
- */
-void
-tcp_mtudisc(inp, errno)
- struct inpcb *inp;
- int errno;
-{
- struct tcpcb *tp = intotcpcb(inp);
- struct rtentry *rt;
- struct rmxp_tao *taop;
- struct socket *so = inp->inp_socket;
- int offered;
- int mss;
-#ifdef INET6
- int isipv6 = (tp->t_inpcb->inp_vflag & INP_IPV6) != 0;
-#endif /* INET6 */
-
- if (tp) {
-#ifdef INET6
- if (isipv6)
- rt = tcp_rtlookup6(inp);
- else
-#endif /* INET6 */
- rt = tcp_rtlookup(inp);
- if (!rt || !rt->rt_rmx.rmx_mtu) {
- tp->t_maxopd = tp->t_maxseg =
-#ifdef INET6
- isipv6 ? tcp_v6mssdflt :
-#endif /* INET6 */
- tcp_mssdflt;
- return;
- }
- taop = rmx_taop(rt->rt_rmx);
- offered = taop->tao_mssopt;
- mss = rt->rt_rmx.rmx_mtu -
-#ifdef INET6
- (isipv6 ?
- sizeof(struct ip6_hdr) + sizeof(struct tcphdr) :
-#endif /* INET6 */
- sizeof(struct tcpiphdr)
-#ifdef INET6
- )
-#endif /* INET6 */
- ;
-
- if (offered)
- mss = min(mss, offered);
- /*
- * XXX - The above conditional probably violates the TCP
- * spec. The problem is that, since we don't know the
- * other end's MSS, we are supposed to use a conservative
- * default. But, if we do that, then MTU discovery will
- * never actually take place, because the conservative
- * default is much less than the MTUs typically seen
- * on the Internet today. For the moment, we'll sweep
- * this under the carpet.
- *
- * The conservative default might not actually be a problem
- * if the only case this occurs is when sending an initial
- * SYN with options and data to a host we've never talked
- * to before. Then, they will reply with an MSS value which
- * will get recorded and the new parameters should get
- * recomputed. For Further Study.
- */
- if (tp->t_maxopd <= mss)
- return;
- tp->t_maxopd = mss;
-
- if ((tp->t_flags & (TF_REQ_TSTMP|TF_NOOPT)) == TF_REQ_TSTMP &&
- (tp->t_flags & TF_RCVD_TSTMP) == TF_RCVD_TSTMP)
- mss -= TCPOLEN_TSTAMP_APPA;
- if ((tp->t_flags & (TF_REQ_CC|TF_NOOPT)) == TF_REQ_CC &&
- (tp->t_flags & TF_RCVD_CC) == TF_RCVD_CC)
- mss -= TCPOLEN_CC_APPA;
-#if (MCLBYTES & (MCLBYTES - 1)) == 0
- if (mss > MCLBYTES)
- mss &= ~(MCLBYTES-1);
-#else
- if (mss > MCLBYTES)
- mss = mss / MCLBYTES * MCLBYTES;
-#endif
- if (so->so_snd.sb_hiwat < mss)
- mss = so->so_snd.sb_hiwat;
-
- tp->t_maxseg = mss;
-
- tcpstat.tcps_mturesent++;
- tp->t_rtttime = 0;
- tp->snd_nxt = tp->snd_una;
- tcp_output(tp);
- }
-}
-
-/*
- * Look-up the routing entry to the peer of this inpcb. If no route
- * is found and it cannot be allocated the return NULL. This routine
- * is called by TCP routines that access the rmx structure and by tcp_mss
- * to get the interface MTU.
- */
-struct rtentry *
-tcp_rtlookup(inp)
- struct inpcb *inp;
-{
- struct route *ro;
- struct rtentry *rt;
-
- ro = &inp->inp_route;
- rt = ro->ro_rt;
- if (rt == NULL || !(rt->rt_flags & RTF_UP)) {
- /* No route yet, so try to acquire one */
- if (inp->inp_faddr.s_addr != INADDR_ANY) {
- ro->ro_dst.sa_family = AF_INET;
- ro->ro_dst.sa_len = sizeof(ro->ro_dst);
- ((struct sockaddr_in *) &ro->ro_dst)->sin_addr =
- inp->inp_faddr;
- rtalloc(ro);
- rt = ro->ro_rt;
- }
- }
- return rt;
-}
-
-#ifdef INET6
-struct rtentry *
-tcp_rtlookup6(inp)
- struct inpcb *inp;
-{
- struct route_in6 *ro6;
- struct rtentry *rt;
-
- ro6 = &inp->in6p_route;
- rt = ro6->ro_rt;
- if (rt == NULL || !(rt->rt_flags & RTF_UP)) {
- /* No route yet, so try to acquire one */
- if (!IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr)) {
- ro6->ro_dst.sin6_family = AF_INET6;
- ro6->ro_dst.sin6_len = sizeof(ro6->ro_dst);
- ro6->ro_dst.sin6_addr = inp->in6p_faddr;
- rtalloc((struct route *)ro6);
- rt = ro6->ro_rt;
- }
- }
- return rt;
-}
-#endif /* INET6 */
-
-#ifdef IPSEC
-/* compute ESP/AH header size for TCP, including outer IP header. */
-size_t
-ipsec_hdrsiz_tcp(tp)
- struct tcpcb *tp;
-{
- struct inpcb *inp;
- struct mbuf *m;
- size_t hdrsiz;
- struct ip *ip;
-#ifdef INET6
- struct ip6_hdr *ip6;
-#endif /* INET6 */
- struct tcphdr *th;
-
- if (!tp || !tp->t_template || !(inp = tp->t_inpcb))
- return 0;
- MGETHDR(m, M_DONTWAIT, MT_DATA);
- if (!m)
- return 0;
-
-#ifdef INET6
- if ((inp->inp_vflag & INP_IPV6) != 0) {
- ip6 = mtod(m, struct ip6_hdr *);
- th = (struct tcphdr *)(ip6 + 1);
- m->m_pkthdr.len = m->m_len =
- sizeof(struct ip6_hdr) + sizeof(struct tcphdr);
- bcopy((caddr_t)tp->t_template->tt_ipgen, (caddr_t)ip6,
- sizeof(struct ip6_hdr));
- bcopy((caddr_t)&tp->t_template->tt_t, (caddr_t)th,
- sizeof(struct tcphdr));
- hdrsiz = ipsec6_hdrsiz(m, IPSEC_DIR_OUTBOUND, inp);
- } else
-#endif /* INET6 */
- {
- ip = mtod(m, struct ip *);
- th = (struct tcphdr *)(ip + 1);
- m->m_pkthdr.len = m->m_len = sizeof(struct tcpiphdr);
- bcopy((caddr_t)tp->t_template->tt_ipgen, (caddr_t)ip,
- sizeof(struct ip));
- bcopy((caddr_t)&tp->t_template->tt_t, (caddr_t)th,
- sizeof(struct tcphdr));
- hdrsiz = ipsec4_hdrsiz(m, IPSEC_DIR_OUTBOUND, inp);
- }
-
- m_free(m);
- return hdrsiz;
-}
-#endif /*IPSEC*/
-
-/*
- * Return a pointer to the cached information about the remote host.
- * The cached information is stored in the protocol specific part of
- * the route metrics.
- */
-struct rmxp_tao *
-tcp_gettaocache(inp)
- struct inpcb *inp;
-{
- struct rtentry *rt;
-
-#ifdef INET6
- if ((inp->inp_vflag & INP_IPV6) != 0)
- rt = tcp_rtlookup6(inp);
- else
-#endif /* INET6 */
- rt = tcp_rtlookup(inp);
-
- /* Make sure this is a host route and is up. */
- if (rt == NULL ||
- (rt->rt_flags & (RTF_UP|RTF_HOST)) != (RTF_UP|RTF_HOST))
- return NULL;
-
- return rmx_taop(rt->rt_rmx);
-}
-
-/*
- * Clear all the TAO cache entries, called from tcp_init.
- *
- * XXX
- * This routine is just an empty one, because we assume that the routing
- * routing tables are initialized at the same time when TCP, so there is
- * nothing in the cache left over.
- */
-static void
-tcp_cleartaocache()
-{
-}
diff --git a/sys/nfs/nfs_common.c b/sys/nfs/nfs_common.c
deleted file mode 100644
index 2e197211f72a..000000000000
--- a/sys/nfs/nfs_common.c
+++ /dev/null
@@ -1,2229 +0,0 @@
-/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Rick Macklem at The University of Guelph.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)nfs_subs.c 8.8 (Berkeley) 5/22/95
- * $FreeBSD$
- */
-
-/*
- * These functions support the macros and help fiddle mbuf chains for
- * the nfs op functions. They do things like create the rpc header and
- * copy data between mbuf chains and uio lists.
- */
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/buf.h>
-#include <sys/proc.h>
-#include <sys/mount.h>
-#include <sys/vnode.h>
-#include <sys/namei.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <sys/malloc.h>
-#include <sys/sysent.h>
-#include <sys/syscall.h>
-#include <sys/conf.h>
-
-#include <vm/vm.h>
-#include <vm/vm_object.h>
-#include <vm/vm_extern.h>
-#include <vm/vm_zone.h>
-
-#include <nfs/rpcv2.h>
-#include <nfs/nfsproto.h>
-#include <nfs/nfs.h>
-#include <nfs/nfsnode.h>
-#include <nfs/xdr_subs.h>
-#include <nfs/nfsm_subs.h>
-#include <nfs/nfsmount.h>
-#include <nfs/nqnfs.h>
-#include <nfs/nfsrtt.h>
-
-#include <netinet/in.h>
-
-/*
- * Data items converted to xdr at startup, since they are constant
- * This is kinda hokey, but may save a little time doing byte swaps
- */
-u_int32_t nfs_xdrneg1;
-u_int32_t rpc_call, rpc_vers, rpc_reply, rpc_msgdenied, rpc_autherr,
- rpc_mismatch, rpc_auth_unix, rpc_msgaccepted,
- rpc_auth_kerb;
-u_int32_t nfs_prog, nqnfs_prog, nfs_true, nfs_false;
-
-/* And other global data */
-static u_int32_t nfs_xid = 0;
-static enum vtype nv2tov_type[8]= {
- VNON, VREG, VDIR, VBLK, VCHR, VLNK, VNON, VNON
-};
-enum vtype nv3tov_type[8]= {
- VNON, VREG, VDIR, VBLK, VCHR, VLNK, VSOCK, VFIFO
-};
-
-int nfs_ticks;
-int nfs_pbuf_freecnt = -1; /* start out unlimited */
-
-struct nfs_reqq nfs_reqq;
-struct nfssvc_sockhead nfssvc_sockhead;
-int nfssvc_sockhead_flag;
-struct nfsd_head nfsd_head;
-int nfsd_head_flag;
-struct nfs_bufq nfs_bufq;
-struct nqtimerhead nqtimerhead;
-struct nqfhhashhead *nqfhhashtbl;
-u_long nqfhhash;
-
-static void (*nfs_prev_lease_updatetime) __P((int));
-static int nfs_prev_nfssvc_sy_narg;
-static sy_call_t *nfs_prev_nfssvc_sy_call;
-
-#ifndef NFS_NOSERVER
-
-static vop_t *nfs_prev_vop_lease_check;
-
-/*
- * Mapping of old NFS Version 2 RPC numbers to generic numbers.
- */
-int nfsv3_procid[NFS_NPROCS] = {
- NFSPROC_NULL,
- NFSPROC_GETATTR,
- NFSPROC_SETATTR,
- NFSPROC_NOOP,
- NFSPROC_LOOKUP,
- NFSPROC_READLINK,
- NFSPROC_READ,
- NFSPROC_NOOP,
- NFSPROC_WRITE,
- NFSPROC_CREATE,
- NFSPROC_REMOVE,
- NFSPROC_RENAME,
- NFSPROC_LINK,
- NFSPROC_SYMLINK,
- NFSPROC_MKDIR,
- NFSPROC_RMDIR,
- NFSPROC_READDIR,
- NFSPROC_FSSTAT,
- NFSPROC_NOOP,
- NFSPROC_NOOP,
- NFSPROC_NOOP,
- NFSPROC_NOOP,
- NFSPROC_NOOP,
- NFSPROC_NOOP,
- NFSPROC_NOOP,
- NFSPROC_NOOP
-};
-
-#endif /* NFS_NOSERVER */
-/*
- * and the reverse mapping from generic to Version 2 procedure numbers
- */
-int nfsv2_procid[NFS_NPROCS] = {
- NFSV2PROC_NULL,
- NFSV2PROC_GETATTR,
- NFSV2PROC_SETATTR,
- NFSV2PROC_LOOKUP,
- NFSV2PROC_NOOP,
- NFSV2PROC_READLINK,
- NFSV2PROC_READ,
- NFSV2PROC_WRITE,
- NFSV2PROC_CREATE,
- NFSV2PROC_MKDIR,
- NFSV2PROC_SYMLINK,
- NFSV2PROC_CREATE,
- NFSV2PROC_REMOVE,
- NFSV2PROC_RMDIR,
- NFSV2PROC_RENAME,
- NFSV2PROC_LINK,
- NFSV2PROC_READDIR,
- NFSV2PROC_NOOP,
- NFSV2PROC_STATFS,
- NFSV2PROC_NOOP,
- NFSV2PROC_NOOP,
- NFSV2PROC_NOOP,
- NFSV2PROC_NOOP,
- NFSV2PROC_NOOP,
- NFSV2PROC_NOOP,
- NFSV2PROC_NOOP,
-};
-
-#ifndef NFS_NOSERVER
-/*
- * Maps errno values to nfs error numbers.
- * Use NFSERR_IO as the catch all for ones not specifically defined in
- * RFC 1094.
- */
-static u_char nfsrv_v2errmap[ELAST] = {
- NFSERR_PERM, NFSERR_NOENT, NFSERR_IO, NFSERR_IO, NFSERR_IO,
- NFSERR_NXIO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
- NFSERR_IO, NFSERR_IO, NFSERR_ACCES, NFSERR_IO, NFSERR_IO,
- NFSERR_IO, NFSERR_EXIST, NFSERR_IO, NFSERR_NODEV, NFSERR_NOTDIR,
- NFSERR_ISDIR, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
- NFSERR_IO, NFSERR_FBIG, NFSERR_NOSPC, NFSERR_IO, NFSERR_ROFS,
- NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
- NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
- NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
- NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
- NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
- NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
- NFSERR_IO, NFSERR_IO, NFSERR_NAMETOL, NFSERR_IO, NFSERR_IO,
- NFSERR_NOTEMPTY, NFSERR_IO, NFSERR_IO, NFSERR_DQUOT, NFSERR_STALE,
- NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
- NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
- NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
- NFSERR_IO /* << Last is 86 */
-};
-
-/*
- * Maps errno values to nfs error numbers.
- * Although it is not obvious whether or not NFS clients really care if
- * a returned error value is in the specified list for the procedure, the
- * safest thing to do is filter them appropriately. For Version 2, the
- * X/Open XNFS document is the only specification that defines error values
- * for each RPC (The RFC simply lists all possible error values for all RPCs),
- * so I have decided to not do this for Version 2.
- * The first entry is the default error return and the rest are the valid
- * errors for that RPC in increasing numeric order.
- */
-static short nfsv3err_null[] = {
- 0,
- 0,
-};
-
-static short nfsv3err_getattr[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_setattr[] = {
- NFSERR_IO,
- NFSERR_PERM,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_INVAL,
- NFSERR_NOSPC,
- NFSERR_ROFS,
- NFSERR_DQUOT,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_NOT_SYNC,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_lookup[] = {
- NFSERR_IO,
- NFSERR_NOENT,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_NOTDIR,
- NFSERR_NAMETOL,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_access[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_readlink[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_INVAL,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_NOTSUPP,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_read[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_NXIO,
- NFSERR_ACCES,
- NFSERR_INVAL,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_write[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_INVAL,
- NFSERR_FBIG,
- NFSERR_NOSPC,
- NFSERR_ROFS,
- NFSERR_DQUOT,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_create[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_EXIST,
- NFSERR_NOTDIR,
- NFSERR_NOSPC,
- NFSERR_ROFS,
- NFSERR_NAMETOL,
- NFSERR_DQUOT,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_NOTSUPP,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_mkdir[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_EXIST,
- NFSERR_NOTDIR,
- NFSERR_NOSPC,
- NFSERR_ROFS,
- NFSERR_NAMETOL,
- NFSERR_DQUOT,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_NOTSUPP,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_symlink[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_EXIST,
- NFSERR_NOTDIR,
- NFSERR_NOSPC,
- NFSERR_ROFS,
- NFSERR_NAMETOL,
- NFSERR_DQUOT,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_NOTSUPP,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_mknod[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_EXIST,
- NFSERR_NOTDIR,
- NFSERR_NOSPC,
- NFSERR_ROFS,
- NFSERR_NAMETOL,
- NFSERR_DQUOT,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_NOTSUPP,
- NFSERR_SERVERFAULT,
- NFSERR_BADTYPE,
- 0,
-};
-
-static short nfsv3err_remove[] = {
- NFSERR_IO,
- NFSERR_NOENT,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_NOTDIR,
- NFSERR_ROFS,
- NFSERR_NAMETOL,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_rmdir[] = {
- NFSERR_IO,
- NFSERR_NOENT,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_EXIST,
- NFSERR_NOTDIR,
- NFSERR_INVAL,
- NFSERR_ROFS,
- NFSERR_NAMETOL,
- NFSERR_NOTEMPTY,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_NOTSUPP,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_rename[] = {
- NFSERR_IO,
- NFSERR_NOENT,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_EXIST,
- NFSERR_XDEV,
- NFSERR_NOTDIR,
- NFSERR_ISDIR,
- NFSERR_INVAL,
- NFSERR_NOSPC,
- NFSERR_ROFS,
- NFSERR_MLINK,
- NFSERR_NAMETOL,
- NFSERR_NOTEMPTY,
- NFSERR_DQUOT,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_NOTSUPP,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_link[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_EXIST,
- NFSERR_XDEV,
- NFSERR_NOTDIR,
- NFSERR_INVAL,
- NFSERR_NOSPC,
- NFSERR_ROFS,
- NFSERR_MLINK,
- NFSERR_NAMETOL,
- NFSERR_DQUOT,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_NOTSUPP,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_readdir[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_NOTDIR,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_BAD_COOKIE,
- NFSERR_TOOSMALL,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_readdirplus[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_NOTDIR,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_BAD_COOKIE,
- NFSERR_NOTSUPP,
- NFSERR_TOOSMALL,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_fsstat[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_fsinfo[] = {
- NFSERR_STALE,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_pathconf[] = {
- NFSERR_STALE,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_commit[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short *nfsrv_v3errmap[] = {
- nfsv3err_null,
- nfsv3err_getattr,
- nfsv3err_setattr,
- nfsv3err_lookup,
- nfsv3err_access,
- nfsv3err_readlink,
- nfsv3err_read,
- nfsv3err_write,
- nfsv3err_create,
- nfsv3err_mkdir,
- nfsv3err_symlink,
- nfsv3err_mknod,
- nfsv3err_remove,
- nfsv3err_rmdir,
- nfsv3err_rename,
- nfsv3err_link,
- nfsv3err_readdir,
- nfsv3err_readdirplus,
- nfsv3err_fsstat,
- nfsv3err_fsinfo,
- nfsv3err_pathconf,
- nfsv3err_commit,
-};
-
-#endif /* NFS_NOSERVER */
-
-extern struct nfsrtt nfsrtt;
-extern time_t nqnfsstarttime;
-extern int nqsrv_clockskew;
-extern int nqsrv_writeslack;
-extern int nqsrv_maxlease;
-extern struct nfsstats nfsstats;
-extern int nqnfs_piggy[NFS_NPROCS];
-extern nfstype nfsv2_type[9];
-extern nfstype nfsv3_type[9];
-extern struct nfsnodehashhead *nfsnodehashtbl;
-extern u_long nfsnodehash;
-
-struct nfssvc_args;
-extern int nfssvc(struct proc *, struct nfssvc_args *, int *);
-
-LIST_HEAD(nfsnodehashhead, nfsnode);
-
-int nfs_webnamei __P((struct nameidata *, struct vnode *, struct proc *));
-
-u_quad_t
-nfs_curusec()
-{
- struct timeval tv;
-
- getmicrotime(&tv);
- return ((u_quad_t)tv.tv_sec * 1000000 + (u_quad_t)tv.tv_usec);
-}
-
-/*
- * Create the header for an rpc request packet
- * The hsiz is the size of the rest of the nfs request header.
- * (just used to decide if a cluster is a good idea)
- */
-struct mbuf *
-nfsm_reqh(vp, procid, hsiz, bposp)
- struct vnode *vp;
- u_long procid;
- int hsiz;
- caddr_t *bposp;
-{
- register struct mbuf *mb;
- register u_int32_t *tl;
- register caddr_t bpos;
- struct mbuf *mb2;
- struct nfsmount *nmp;
- int nqflag;
-
- MGET(mb, M_WAIT, MT_DATA);
- if (hsiz >= MINCLSIZE)
- MCLGET(mb, M_WAIT);
- mb->m_len = 0;
- bpos = mtod(mb, caddr_t);
-
- /*
- * For NQNFS, add lease request.
- */
- if (vp) {
- nmp = VFSTONFS(vp->v_mount);
- if (nmp->nm_flag & NFSMNT_NQNFS) {
- nqflag = NQNFS_NEEDLEASE(vp, procid);
- if (nqflag) {
- nfsm_build(tl, u_int32_t *, 2*NFSX_UNSIGNED);
- *tl++ = txdr_unsigned(nqflag);
- *tl = txdr_unsigned(nmp->nm_leaseterm);
- } else {
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);
- *tl = 0;
- }
- }
- }
- /* Finally, return values */
- *bposp = bpos;
- return (mb);
-}
-
-/*
- * Build the RPC header and fill in the authorization info.
- * The authorization string argument is only used when the credentials
- * come from outside of the kernel.
- * Returns the head of the mbuf list.
- */
-struct mbuf *
-nfsm_rpchead(cr, nmflag, procid, auth_type, auth_len, auth_str, verf_len,
- verf_str, mrest, mrest_len, mbp, xidp)
- register struct ucred *cr;
- int nmflag;
- int procid;
- int auth_type;
- int auth_len;
- char *auth_str;
- int verf_len;
- char *verf_str;
- struct mbuf *mrest;
- int mrest_len;
- struct mbuf **mbp;
- u_int32_t *xidp;
-{
- register struct mbuf *mb;
- register u_int32_t *tl;
- register caddr_t bpos;
- register int i;
- struct mbuf *mreq, *mb2;
- int siz, grpsiz, authsiz;
-
- authsiz = nfsm_rndup(auth_len);
- MGETHDR(mb, M_WAIT, MT_DATA);
- if ((authsiz + 10 * NFSX_UNSIGNED) >= MINCLSIZE) {
- MCLGET(mb, M_WAIT);
- } else if ((authsiz + 10 * NFSX_UNSIGNED) < MHLEN) {
- MH_ALIGN(mb, authsiz + 10 * NFSX_UNSIGNED);
- } else {
- MH_ALIGN(mb, 8 * NFSX_UNSIGNED);
- }
- mb->m_len = 0;
- mreq = mb;
- bpos = mtod(mb, caddr_t);
-
- /*
- * First the RPC header.
- */
- nfsm_build(tl, u_int32_t *, 8 * NFSX_UNSIGNED);
-
- /* Get a pretty random xid to start with */
- if (!nfs_xid)
- nfs_xid = random();
- /*
- * Skip zero xid if it should ever happen.
- */
- if (++nfs_xid == 0)
- nfs_xid++;
-
- *tl++ = *xidp = txdr_unsigned(nfs_xid);
- *tl++ = rpc_call;
- *tl++ = rpc_vers;
- if (nmflag & NFSMNT_NQNFS) {
- *tl++ = txdr_unsigned(NQNFS_PROG);
- *tl++ = txdr_unsigned(NQNFS_VER3);
- } else {
- *tl++ = txdr_unsigned(NFS_PROG);
- if (nmflag & NFSMNT_NFSV3)
- *tl++ = txdr_unsigned(NFS_VER3);
- else
- *tl++ = txdr_unsigned(NFS_VER2);
- }
- if (nmflag & NFSMNT_NFSV3)
- *tl++ = txdr_unsigned(procid);
- else
- *tl++ = txdr_unsigned(nfsv2_procid[procid]);
-
- /*
- * And then the authorization cred.
- */
- *tl++ = txdr_unsigned(auth_type);
- *tl = txdr_unsigned(authsiz);
- switch (auth_type) {
- case RPCAUTH_UNIX:
- nfsm_build(tl, u_int32_t *, auth_len);
- *tl++ = 0; /* stamp ?? */
- *tl++ = 0; /* NULL hostname */
- *tl++ = txdr_unsigned(cr->cr_uid);
- *tl++ = txdr_unsigned(cr->cr_groups[0]);
- grpsiz = (auth_len >> 2) - 5;
- *tl++ = txdr_unsigned(grpsiz);
- for (i = 1; i <= grpsiz; i++)
- *tl++ = txdr_unsigned(cr->cr_groups[i]);
- break;
- case RPCAUTH_KERB4:
- siz = auth_len;
- while (siz > 0) {
- if (M_TRAILINGSPACE(mb) == 0) {
- MGET(mb2, M_WAIT, MT_DATA);
- if (siz >= MINCLSIZE)
- MCLGET(mb2, M_WAIT);
- mb->m_next = mb2;
- mb = mb2;
- mb->m_len = 0;
- bpos = mtod(mb, caddr_t);
- }
- i = min(siz, M_TRAILINGSPACE(mb));
- bcopy(auth_str, bpos, i);
- mb->m_len += i;
- auth_str += i;
- bpos += i;
- siz -= i;
- }
- if ((siz = (nfsm_rndup(auth_len) - auth_len)) > 0) {
- for (i = 0; i < siz; i++)
- *bpos++ = '\0';
- mb->m_len += siz;
- }
- break;
- };
-
- /*
- * And the verifier...
- */
- nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
- if (verf_str) {
- *tl++ = txdr_unsigned(RPCAUTH_KERB4);
- *tl = txdr_unsigned(verf_len);
- siz = verf_len;
- while (siz > 0) {
- if (M_TRAILINGSPACE(mb) == 0) {
- MGET(mb2, M_WAIT, MT_DATA);
- if (siz >= MINCLSIZE)
- MCLGET(mb2, M_WAIT);
- mb->m_next = mb2;
- mb = mb2;
- mb->m_len = 0;
- bpos = mtod(mb, caddr_t);
- }
- i = min(siz, M_TRAILINGSPACE(mb));
- bcopy(verf_str, bpos, i);
- mb->m_len += i;
- verf_str += i;
- bpos += i;
- siz -= i;
- }
- if ((siz = (nfsm_rndup(verf_len) - verf_len)) > 0) {
- for (i = 0; i < siz; i++)
- *bpos++ = '\0';
- mb->m_len += siz;
- }
- } else {
- *tl++ = txdr_unsigned(RPCAUTH_NULL);
- *tl = 0;
- }
- mb->m_next = mrest;
- mreq->m_pkthdr.len = authsiz + 10 * NFSX_UNSIGNED + mrest_len;
- mreq->m_pkthdr.rcvif = (struct ifnet *)0;
- *mbp = mb;
- return (mreq);
-}
-
-/*
- * copies mbuf chain to the uio scatter/gather list
- */
-int
-nfsm_mbuftouio(mrep, uiop, siz, dpos)
- struct mbuf **mrep;
- register struct uio *uiop;
- int siz;
- caddr_t *dpos;
-{
- register char *mbufcp, *uiocp;
- register int xfer, left, len;
- register struct mbuf *mp;
- long uiosiz, rem;
- int error = 0;
-
- mp = *mrep;
- mbufcp = *dpos;
- len = mtod(mp, caddr_t)+mp->m_len-mbufcp;
- rem = nfsm_rndup(siz)-siz;
- while (siz > 0) {
- if (uiop->uio_iovcnt <= 0 || uiop->uio_iov == NULL)
- return (EFBIG);
- left = uiop->uio_iov->iov_len;
- uiocp = uiop->uio_iov->iov_base;
- if (left > siz)
- left = siz;
- uiosiz = left;
- while (left > 0) {
- while (len == 0) {
- mp = mp->m_next;
- if (mp == NULL)
- return (EBADRPC);
- mbufcp = mtod(mp, caddr_t);
- len = mp->m_len;
- }
- xfer = (left > len) ? len : left;
-#ifdef notdef
- /* Not Yet.. */
- if (uiop->uio_iov->iov_op != NULL)
- (*(uiop->uio_iov->iov_op))
- (mbufcp, uiocp, xfer);
- else
-#endif
- if (uiop->uio_segflg == UIO_SYSSPACE)
- bcopy(mbufcp, uiocp, xfer);
- else
- copyout(mbufcp, uiocp, xfer);
- left -= xfer;
- len -= xfer;
- mbufcp += xfer;
- uiocp += xfer;
- uiop->uio_offset += xfer;
- uiop->uio_resid -= xfer;
- }
- if (uiop->uio_iov->iov_len <= siz) {
- uiop->uio_iovcnt--;
- uiop->uio_iov++;
- } else {
- uiop->uio_iov->iov_base += uiosiz;
- uiop->uio_iov->iov_len -= uiosiz;
- }
- siz -= uiosiz;
- }
- *dpos = mbufcp;
- *mrep = mp;
- if (rem > 0) {
- if (len < rem)
- error = nfs_adv(mrep, dpos, rem, len);
- else
- *dpos += rem;
- }
- return (error);
-}
-
-/*
- * copies a uio scatter/gather list to an mbuf chain.
- * NOTE: can ony handle iovcnt == 1
- */
-int
-nfsm_uiotombuf(uiop, mq, siz, bpos)
- register struct uio *uiop;
- struct mbuf **mq;
- int siz;
- caddr_t *bpos;
-{
- register char *uiocp;
- register struct mbuf *mp, *mp2;
- register int xfer, left, mlen;
- int uiosiz, clflg, rem;
- char *cp;
-
-#ifdef DIAGNOSTIC
- if (uiop->uio_iovcnt != 1)
- panic("nfsm_uiotombuf: iovcnt != 1");
-#endif
-
- if (siz > MLEN) /* or should it >= MCLBYTES ?? */
- clflg = 1;
- else
- clflg = 0;
- rem = nfsm_rndup(siz)-siz;
- mp = mp2 = *mq;
- while (siz > 0) {
- left = uiop->uio_iov->iov_len;
- uiocp = uiop->uio_iov->iov_base;
- if (left > siz)
- left = siz;
- uiosiz = left;
- while (left > 0) {
- mlen = M_TRAILINGSPACE(mp);
- if (mlen == 0) {
- MGET(mp, M_WAIT, MT_DATA);
- if (clflg)
- MCLGET(mp, M_WAIT);
- mp->m_len = 0;
- mp2->m_next = mp;
- mp2 = mp;
- mlen = M_TRAILINGSPACE(mp);
- }
- xfer = (left > mlen) ? mlen : left;
-#ifdef notdef
- /* Not Yet.. */
- if (uiop->uio_iov->iov_op != NULL)
- (*(uiop->uio_iov->iov_op))
- (uiocp, mtod(mp, caddr_t)+mp->m_len, xfer);
- else
-#endif
- if (uiop->uio_segflg == UIO_SYSSPACE)
- bcopy(uiocp, mtod(mp, caddr_t)+mp->m_len, xfer);
- else
- copyin(uiocp, mtod(mp, caddr_t)+mp->m_len, xfer);
- mp->m_len += xfer;
- left -= xfer;
- uiocp += xfer;
- uiop->uio_offset += xfer;
- uiop->uio_resid -= xfer;
- }
- uiop->uio_iov->iov_base += uiosiz;
- uiop->uio_iov->iov_len -= uiosiz;
- siz -= uiosiz;
- }
- if (rem > 0) {
- if (rem > M_TRAILINGSPACE(mp)) {
- MGET(mp, M_WAIT, MT_DATA);
- mp->m_len = 0;
- mp2->m_next = mp;
- }
- cp = mtod(mp, caddr_t)+mp->m_len;
- for (left = 0; left < rem; left++)
- *cp++ = '\0';
- mp->m_len += rem;
- *bpos = cp;
- } else
- *bpos = mtod(mp, caddr_t)+mp->m_len;
- *mq = mp;
- return (0);
-}
-
-/*
- * Help break down an mbuf chain by setting the first siz bytes contiguous
- * pointed to by returned val.
- * This is used by the macros nfsm_dissect and nfsm_dissecton for tough
- * cases. (The macros use the vars. dpos and dpos2)
- */
-int
-nfsm_disct(mdp, dposp, siz, left, cp2)
- struct mbuf **mdp;
- caddr_t *dposp;
- int siz;
- int left;
- caddr_t *cp2;
-{
- register struct mbuf *mp, *mp2;
- register int siz2, xfer;
- register caddr_t p;
-
- mp = *mdp;
- while (left == 0) {
- *mdp = mp = mp->m_next;
- if (mp == NULL)
- return (EBADRPC);
- left = mp->m_len;
- *dposp = mtod(mp, caddr_t);
- }
- if (left >= siz) {
- *cp2 = *dposp;
- *dposp += siz;
- } else if (mp->m_next == NULL) {
- return (EBADRPC);
- } else if (siz > MHLEN) {
- panic("nfs S too big");
- } else {
- MGET(mp2, M_WAIT, MT_DATA);
- mp2->m_next = mp->m_next;
- mp->m_next = mp2;
- mp->m_len -= left;
- mp = mp2;
- *cp2 = p = mtod(mp, caddr_t);
- bcopy(*dposp, p, left); /* Copy what was left */
- siz2 = siz-left;
- p += left;
- mp2 = mp->m_next;
- /* Loop around copying up the siz2 bytes */
- while (siz2 > 0) {
- if (mp2 == NULL)
- return (EBADRPC);
- xfer = (siz2 > mp2->m_len) ? mp2->m_len : siz2;
- if (xfer > 0) {
- bcopy(mtod(mp2, caddr_t), p, xfer);
- NFSMADV(mp2, xfer);
- mp2->m_len -= xfer;
- p += xfer;
- siz2 -= xfer;
- }
- if (siz2 > 0)
- mp2 = mp2->m_next;
- }
- mp->m_len = siz;
- *mdp = mp2;
- *dposp = mtod(mp2, caddr_t);
- }
- return (0);
-}
-
-/*
- * Advance the position in the mbuf chain.
- */
-int
-nfs_adv(mdp, dposp, offs, left)
- struct mbuf **mdp;
- caddr_t *dposp;
- int offs;
- int left;
-{
- register struct mbuf *m;
- register int s;
-
- m = *mdp;
- s = left;
- while (s < offs) {
- offs -= s;
- m = m->m_next;
- if (m == NULL)
- return (EBADRPC);
- s = m->m_len;
- }
- *mdp = m;
- *dposp = mtod(m, caddr_t)+offs;
- return (0);
-}
-
-/*
- * Copy a string into mbufs for the hard cases...
- */
-int
-nfsm_strtmbuf(mb, bpos, cp, siz)
- struct mbuf **mb;
- char **bpos;
- const char *cp;
- long siz;
-{
- register struct mbuf *m1 = NULL, *m2;
- long left, xfer, len, tlen;
- u_int32_t *tl;
- int putsize;
-
- putsize = 1;
- m2 = *mb;
- left = M_TRAILINGSPACE(m2);
- if (left > 0) {
- tl = ((u_int32_t *)(*bpos));
- *tl++ = txdr_unsigned(siz);
- putsize = 0;
- left -= NFSX_UNSIGNED;
- m2->m_len += NFSX_UNSIGNED;
- if (left > 0) {
- bcopy(cp, (caddr_t) tl, left);
- siz -= left;
- cp += left;
- m2->m_len += left;
- left = 0;
- }
- }
- /* Loop around adding mbufs */
- while (siz > 0) {
- MGET(m1, M_WAIT, MT_DATA);
- if (siz > MLEN)
- MCLGET(m1, M_WAIT);
- m1->m_len = NFSMSIZ(m1);
- m2->m_next = m1;
- m2 = m1;
- tl = mtod(m1, u_int32_t *);
- tlen = 0;
- if (putsize) {
- *tl++ = txdr_unsigned(siz);
- m1->m_len -= NFSX_UNSIGNED;
- tlen = NFSX_UNSIGNED;
- putsize = 0;
- }
- if (siz < m1->m_len) {
- len = nfsm_rndup(siz);
- xfer = siz;
- if (xfer < len)
- *(tl+(xfer>>2)) = 0;
- } else {
- xfer = len = m1->m_len;
- }
- bcopy(cp, (caddr_t) tl, xfer);
- m1->m_len = len+tlen;
- siz -= xfer;
- cp += xfer;
- }
- *mb = m1;
- *bpos = mtod(m1, caddr_t)+m1->m_len;
- return (0);
-}
-
-/*
- * Called once to initialize data structures...
- */
-int
-nfs_init(vfsp)
- struct vfsconf *vfsp;
-{
- register int i;
-
- nfsmount_zone = zinit("NFSMOUNT", sizeof(struct nfsmount), 0, 0, 1);
-
- nfs_mount_type = vfsp->vfc_typenum;
- nfsrtt.pos = 0;
- rpc_vers = txdr_unsigned(RPC_VER2);
- rpc_call = txdr_unsigned(RPC_CALL);
- rpc_reply = txdr_unsigned(RPC_REPLY);
- rpc_msgdenied = txdr_unsigned(RPC_MSGDENIED);
- rpc_msgaccepted = txdr_unsigned(RPC_MSGACCEPTED);
- rpc_mismatch = txdr_unsigned(RPC_MISMATCH);
- rpc_autherr = txdr_unsigned(RPC_AUTHERR);
- rpc_auth_unix = txdr_unsigned(RPCAUTH_UNIX);
- rpc_auth_kerb = txdr_unsigned(RPCAUTH_KERB4);
- nfs_prog = txdr_unsigned(NFS_PROG);
- nqnfs_prog = txdr_unsigned(NQNFS_PROG);
- nfs_true = txdr_unsigned(TRUE);
- nfs_false = txdr_unsigned(FALSE);
- nfs_xdrneg1 = txdr_unsigned(-1);
- nfs_ticks = (hz * NFS_TICKINTVL + 500) / 1000;
- if (nfs_ticks < 1)
- nfs_ticks = 1;
- /* Ensure async daemons disabled */
- for (i = 0; i < NFS_MAXASYNCDAEMON; i++) {
- nfs_iodwant[i] = (struct proc *)0;
- nfs_iodmount[i] = (struct nfsmount *)0;
- }
- nfs_nhinit(); /* Init the nfsnode table */
-#ifndef NFS_NOSERVER
- nfsrv_init(0); /* Init server data structures */
- nfsrv_initcache(); /* Init the server request cache */
-#endif
-
- /*
- * Initialize the nqnfs server stuff.
- */
- if (nqnfsstarttime == 0) {
- nqnfsstarttime = boottime.tv_sec + nqsrv_maxlease
- + nqsrv_clockskew + nqsrv_writeslack;
- NQLOADNOVRAM(nqnfsstarttime);
- CIRCLEQ_INIT(&nqtimerhead);
- nqfhhashtbl = hashinit(NQLCHSZ, M_NQLEASE, &nqfhhash);
- }
-
- /*
- * Initialize reply list and start timer
- */
- TAILQ_INIT(&nfs_reqq);
-
- nfs_timer(0);
-
- /*
- * Set up lease_check and lease_updatetime so that other parts
- * of the system can call us, if we are loadable.
- */
-#ifndef NFS_NOSERVER
- nfs_prev_vop_lease_check = default_vnodeop_p[VOFFSET(vop_lease)];
- default_vnodeop_p[VOFFSET(vop_lease)] = (vop_t *)nqnfs_vop_lease_check;
-#endif
- nfs_prev_lease_updatetime = lease_updatetime;
- lease_updatetime = nfs_lease_updatetime;
- nfs_prev_nfssvc_sy_narg = sysent[SYS_nfssvc].sy_narg;
- sysent[SYS_nfssvc].sy_narg = 2;
- nfs_prev_nfssvc_sy_call = sysent[SYS_nfssvc].sy_call;
- sysent[SYS_nfssvc].sy_call = (sy_call_t *)nfssvc;
-
- nfs_pbuf_freecnt = nswbuf / 2 + 1;
-
- return (0);
-}
-
-int
-nfs_uninit(vfsp)
- struct vfsconf *vfsp;
-{
-
- untimeout(nfs_timer, (void *)NULL, nfs_timer_handle);
- nfs_mount_type = -1;
-#ifndef NFS_NOSERVER
- default_vnodeop_p[VOFFSET(vop_lease)] = nfs_prev_vop_lease_check;
-#endif
- lease_updatetime = nfs_prev_lease_updatetime;
- sysent[SYS_nfssvc].sy_narg = nfs_prev_nfssvc_sy_narg;
- sysent[SYS_nfssvc].sy_call = nfs_prev_nfssvc_sy_call;
- return (0);
-}
-
-/*
- * Attribute cache routines.
- * nfs_loadattrcache() - loads or updates the cache contents from attributes
- * that are on the mbuf list
- * nfs_getattrcache() - returns valid attributes if found in cache, returns
- * error otherwise
- */
-
-/*
- * Load the attribute cache (that lives in the nfsnode entry) with
- * the values on the mbuf list and
- * Iff vap not NULL
- * copy the attributes to *vaper
- */
-int
-nfs_loadattrcache(vpp, mdp, dposp, vaper)
- struct vnode **vpp;
- struct mbuf **mdp;
- caddr_t *dposp;
- struct vattr *vaper;
-{
- register struct vnode *vp = *vpp;
- register struct vattr *vap;
- register struct nfs_fattr *fp;
- register struct nfsnode *np;
- register int32_t t1;
- caddr_t cp2;
- int error = 0, rdev;
- struct mbuf *md;
- enum vtype vtyp;
- u_short vmode;
- struct timespec mtime;
- int v3 = NFS_ISV3(vp);
-
- md = *mdp;
- t1 = (mtod(md, caddr_t) + md->m_len) - *dposp;
- if ((error = nfsm_disct(mdp, dposp, NFSX_FATTR(v3), t1, &cp2)) != 0)
- return (error);
- fp = (struct nfs_fattr *)cp2;
- if (v3) {
- vtyp = nfsv3tov_type(fp->fa_type);
- vmode = fxdr_unsigned(u_short, fp->fa_mode);
- rdev = makeudev(fxdr_unsigned(int, fp->fa3_rdev.specdata1),
- fxdr_unsigned(int, fp->fa3_rdev.specdata2));
- fxdr_nfsv3time(&fp->fa3_mtime, &mtime);
- } else {
- vtyp = nfsv2tov_type(fp->fa_type);
- vmode = fxdr_unsigned(u_short, fp->fa_mode);
- /*
- * XXX
- *
- * The duplicate information returned in fa_type and fa_mode
- * is an ambiguity in the NFS version 2 protocol.
- *
- * VREG should be taken literally as a regular file. If a
- * server intents to return some type information differently
- * in the upper bits of the mode field (e.g. for sockets, or
- * FIFOs), NFSv2 mandates fa_type to be VNON. Anyway, we
- * leave the examination of the mode bits even in the VREG
- * case to avoid breakage for bogus servers, but we make sure
- * that there are actually type bits set in the upper part of
- * fa_mode (and failing that, trust the va_type field).
- *
- * NFSv3 cleared the issue, and requires fa_mode to not
- * contain any type information (while also introduing sockets
- * and FIFOs for fa_type).
- */
- if (vtyp == VNON || (vtyp == VREG && (vmode & S_IFMT) != 0))
- vtyp = IFTOVT(vmode);
- rdev = fxdr_unsigned(int32_t, fp->fa2_rdev);
- fxdr_nfsv2time(&fp->fa2_mtime, &mtime);
-
- /*
- * Really ugly NFSv2 kludge.
- */
- if (vtyp == VCHR && rdev == 0xffffffff)
- vtyp = VFIFO;
- }
-
- /*
- * If v_type == VNON it is a new node, so fill in the v_type,
- * n_mtime fields. Check to see if it represents a special
- * device, and if so, check for a possible alias. Once the
- * correct vnode has been obtained, fill in the rest of the
- * information.
- */
- np = VTONFS(vp);
- if (vp->v_type != vtyp) {
- vp->v_type = vtyp;
- if (vp->v_type == VFIFO) {
- vp->v_op = fifo_nfsv2nodeop_p;
- }
- if (vp->v_type == VCHR || vp->v_type == VBLK) {
- vp->v_op = spec_nfsv2nodeop_p;
- addaliasu(vp, rdev);
- }
- np->n_mtime = mtime.tv_sec;
- }
- vap = &np->n_vattr;
- vap->va_type = vtyp;
- vap->va_mode = (vmode & 07777);
- vap->va_rdev = rdev;
- vap->va_mtime = mtime;
- vap->va_fsid = vp->v_mount->mnt_stat.f_fsid.val[0];
- if (v3) {
- vap->va_nlink = fxdr_unsigned(u_short, fp->fa_nlink);
- vap->va_uid = fxdr_unsigned(uid_t, fp->fa_uid);
- vap->va_gid = fxdr_unsigned(gid_t, fp->fa_gid);
- vap->va_size = fxdr_hyper(&fp->fa3_size);
- vap->va_blocksize = NFS_FABLKSIZE;
- vap->va_bytes = fxdr_hyper(&fp->fa3_used);
- vap->va_fileid = fxdr_unsigned(int32_t,
- fp->fa3_fileid.nfsuquad[1]);
- fxdr_nfsv3time(&fp->fa3_atime, &vap->va_atime);
- fxdr_nfsv3time(&fp->fa3_ctime, &vap->va_ctime);
- vap->va_flags = 0;
- vap->va_filerev = 0;
- } else {
- vap->va_nlink = fxdr_unsigned(u_short, fp->fa_nlink);
- vap->va_uid = fxdr_unsigned(uid_t, fp->fa_uid);
- vap->va_gid = fxdr_unsigned(gid_t, fp->fa_gid);
- vap->va_size = fxdr_unsigned(u_int32_t, fp->fa2_size);
- vap->va_blocksize = fxdr_unsigned(int32_t, fp->fa2_blocksize);
- vap->va_bytes = (u_quad_t)fxdr_unsigned(int32_t, fp->fa2_blocks)
- * NFS_FABLKSIZE;
- vap->va_fileid = fxdr_unsigned(int32_t, fp->fa2_fileid);
- fxdr_nfsv2time(&fp->fa2_atime, &vap->va_atime);
- vap->va_flags = 0;
- vap->va_ctime.tv_sec = fxdr_unsigned(u_int32_t,
- fp->fa2_ctime.nfsv2_sec);
- vap->va_ctime.tv_nsec = 0;
- vap->va_gen = fxdr_unsigned(u_int32_t,fp->fa2_ctime.nfsv2_usec);
- vap->va_filerev = 0;
- }
- if (vap->va_size != np->n_size) {
- if (vap->va_type == VREG) {
- if (np->n_flag & NMODIFIED) {
- if (vap->va_size < np->n_size)
- vap->va_size = np->n_size;
- else
- np->n_size = vap->va_size;
- } else {
- np->n_size = vap->va_size;
- }
- vnode_pager_setsize(vp, np->n_size);
- } else {
- np->n_size = vap->va_size;
- }
- }
- np->n_attrstamp = time_second;
- if (vaper != NULL) {
- bcopy((caddr_t)vap, (caddr_t)vaper, sizeof(*vap));
- if (np->n_flag & NCHG) {
- if (np->n_flag & NACC)
- vaper->va_atime = np->n_atim;
- if (np->n_flag & NUPD)
- vaper->va_mtime = np->n_mtim;
- }
- }
- return (0);
-}
-
-#ifdef NFS_ACDEBUG
-#include <sys/sysctl.h>
-SYSCTL_DECL(_vfs_nfs);
-static int nfs_acdebug;
-SYSCTL_INT(_vfs_nfs, OID_AUTO, acdebug, CTLFLAG_RW, &nfs_acdebug, 0, "");
-#endif
-
-/*
- * Check the time stamp
- * If the cache is valid, copy contents to *vap and return 0
- * otherwise return an error
- */
-int
-nfs_getattrcache(vp, vaper)
- register struct vnode *vp;
- struct vattr *vaper;
-{
- register struct nfsnode *np;
- register struct vattr *vap;
- struct nfsmount *nmp;
- int timeo;
-
- np = VTONFS(vp);
- vap = &np->n_vattr;
- nmp = VFSTONFS(vp->v_mount);
- /* XXX n_mtime doesn't seem to be updated on a miss-and-reload */
- timeo = (time_second - np->n_mtime) / 10;
-
-#ifdef NFS_ACDEBUG
- if (nfs_acdebug>1)
- printf("nfs_getattrcache: initial timeo = %d\n", timeo);
-#endif
-
- if (vap->va_type == VDIR) {
- if ((np->n_flag & NMODIFIED) || timeo < nmp->nm_acdirmin)
- timeo = nmp->nm_acdirmin;
- else if (timeo > nmp->nm_acdirmax)
- timeo = nmp->nm_acdirmax;
- } else {
- if ((np->n_flag & NMODIFIED) || timeo < nmp->nm_acregmin)
- timeo = nmp->nm_acregmin;
- else if (timeo > nmp->nm_acregmax)
- timeo = nmp->nm_acregmax;
- }
-
-#ifdef NFS_ACDEBUG
- if (nfs_acdebug > 2)
- printf("acregmin %d; acregmax %d; acdirmin %d; acdirmax %d\n",
- nmp->nm_acregmin, nmp->nm_acregmax,
- nmp->nm_acdirmin, nmp->nm_acdirmax);
-
- if (nfs_acdebug)
- printf("nfs_getattrcache: age = %d; final timeo = %d\n",
- (time_second - np->n_attrstamp), timeo);
-#endif
-
- if ((time_second - np->n_attrstamp) >= timeo) {
- nfsstats.attrcache_misses++;
- return (ENOENT);
- }
- nfsstats.attrcache_hits++;
- if (vap->va_size != np->n_size) {
- if (vap->va_type == VREG) {
- if (np->n_flag & NMODIFIED) {
- if (vap->va_size < np->n_size)
- vap->va_size = np->n_size;
- else
- np->n_size = vap->va_size;
- } else {
- np->n_size = vap->va_size;
- }
- vnode_pager_setsize(vp, np->n_size);
- } else {
- np->n_size = vap->va_size;
- }
- }
- bcopy((caddr_t)vap, (caddr_t)vaper, sizeof(struct vattr));
- if (np->n_flag & NCHG) {
- if (np->n_flag & NACC)
- vaper->va_atime = np->n_atim;
- if (np->n_flag & NUPD)
- vaper->va_mtime = np->n_mtim;
- }
- return (0);
-}
-
-#ifndef NFS_NOSERVER
-/*
- * Set up nameidata for a lookup() call and do it.
- *
- * If pubflag is set, this call is done for a lookup operation on the
- * public filehandle. In that case we allow crossing mountpoints and
- * absolute pathnames. However, the caller is expected to check that
- * the lookup result is within the public fs, and deny access if
- * it is not.
- *
- * nfs_namei() clears out garbage fields that namei() might leave garbage.
- * This is mainly ni_vp and ni_dvp when an error occurs, and ni_dvp when no
- * error occurs but the parent was not requested.
- *
- * dirp may be set whether an error is returned or not, and must be
- * released by the caller.
- */
-int
-nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag, pubflag)
- register struct nameidata *ndp;
- fhandle_t *fhp;
- int len;
- struct nfssvc_sock *slp;
- struct sockaddr *nam;
- struct mbuf **mdp;
- caddr_t *dposp;
- struct vnode **retdirp;
- struct proc *p;
- int kerbflag, pubflag;
-{
- register int i, rem;
- register struct mbuf *md;
- register char *fromcp, *tocp, *cp;
- struct iovec aiov;
- struct uio auio;
- struct vnode *dp;
- int error, rdonly, linklen;
- struct componentname *cnp = &ndp->ni_cnd;
-
- *retdirp = (struct vnode *)0;
- cnp->cn_pnbuf = zalloc(namei_zone);
-
- /*
- * Copy the name from the mbuf list to ndp->ni_pnbuf
- * and set the various ndp fields appropriately.
- */
- fromcp = *dposp;
- tocp = cnp->cn_pnbuf;
- md = *mdp;
- rem = mtod(md, caddr_t) + md->m_len - fromcp;
- for (i = 0; i < len; i++) {
- while (rem == 0) {
- md = md->m_next;
- if (md == NULL) {
- error = EBADRPC;
- goto out;
- }
- fromcp = mtod(md, caddr_t);
- rem = md->m_len;
- }
- if (*fromcp == '\0' || (!pubflag && *fromcp == '/')) {
- error = EACCES;
- goto out;
- }
- *tocp++ = *fromcp++;
- rem--;
- }
- *tocp = '\0';
- *mdp = md;
- *dposp = fromcp;
- len = nfsm_rndup(len)-len;
- if (len > 0) {
- if (rem >= len)
- *dposp += len;
- else if ((error = nfs_adv(mdp, dposp, len, rem)) != 0)
- goto out;
- }
-
- /*
- * Extract and set starting directory.
- */
- error = nfsrv_fhtovp(fhp, FALSE, &dp, ndp->ni_cnd.cn_cred, slp,
- nam, &rdonly, kerbflag, pubflag);
- if (error)
- goto out;
- if (dp->v_type != VDIR) {
- vrele(dp);
- error = ENOTDIR;
- goto out;
- }
-
- if (rdonly)
- cnp->cn_flags |= RDONLY;
-
- /*
- * Set return directory. Reference to dp is implicitly transfered
- * to the returned pointer
- */
- *retdirp = dp;
-
- if (pubflag) {
- /*
- * Oh joy. For WebNFS, handle those pesky '%' escapes,
- * and the 'native path' indicator.
- */
- cp = zalloc(namei_zone);
- fromcp = cnp->cn_pnbuf;
- tocp = cp;
- if ((unsigned char)*fromcp >= WEBNFS_SPECCHAR_START) {
- switch ((unsigned char)*fromcp) {
- case WEBNFS_NATIVE_CHAR:
- /*
- * 'Native' path for us is the same
- * as a path according to the NFS spec,
- * just skip the escape char.
- */
- fromcp++;
- break;
- /*
- * More may be added in the future, range 0x80-0xff
- */
- default:
- error = EIO;
- zfree(namei_zone, cp);
- goto out;
- }
- }
- /*
- * Translate the '%' escapes, URL-style.
- */
- while (*fromcp != '\0') {
- if (*fromcp == WEBNFS_ESC_CHAR) {
- if (fromcp[1] != '\0' && fromcp[2] != '\0') {
- fromcp++;
- *tocp++ = HEXSTRTOI(fromcp);
- fromcp += 2;
- continue;
- } else {
- error = ENOENT;
- zfree(namei_zone, cp);
- goto out;
- }
- } else
- *tocp++ = *fromcp++;
- }
- *tocp = '\0';
- zfree(namei_zone, cnp->cn_pnbuf);
- cnp->cn_pnbuf = cp;
- }
-
- ndp->ni_pathlen = (tocp - cnp->cn_pnbuf) + 1;
- ndp->ni_segflg = UIO_SYSSPACE;
-
- if (pubflag) {
- ndp->ni_rootdir = rootvnode;
- ndp->ni_loopcnt = 0;
- if (cnp->cn_pnbuf[0] == '/')
- dp = rootvnode;
- } else {
- cnp->cn_flags |= NOCROSSMOUNT;
- }
-
- /*
- * Initialize for scan, set ni_startdir and bump ref on dp again
- * becuase lookup() will dereference ni_startdir.
- */
-
- cnp->cn_proc = p;
- VREF(dp);
- ndp->ni_startdir = dp;
-
- for (;;) {
- cnp->cn_nameptr = cnp->cn_pnbuf;
- /*
- * Call lookup() to do the real work. If an error occurs,
- * ndp->ni_vp and ni_dvp are left uninitialized or NULL and
- * we do not have to dereference anything before returning.
- * In either case ni_startdir will be dereferenced and NULLed
- * out.
- */
- error = lookup(ndp);
- if (error)
- break;
-
- /*
- * Check for encountering a symbolic link. Trivial
- * termination occurs if no symlink encountered.
- * Note: zfree is safe because error is 0, so we will
- * not zfree it again when we break.
- */
- if ((cnp->cn_flags & ISSYMLINK) == 0) {
- nfsrv_object_create(ndp->ni_vp);
- if (cnp->cn_flags & (SAVENAME | SAVESTART))
- cnp->cn_flags |= HASBUF;
- else
- zfree(namei_zone, cnp->cn_pnbuf);
- break;
- }
-
- /*
- * Validate symlink
- */
- if ((cnp->cn_flags & LOCKPARENT) && ndp->ni_pathlen == 1)
- VOP_UNLOCK(ndp->ni_dvp, 0, p);
- if (!pubflag) {
- error = EINVAL;
- goto badlink2;
- }
-
- if (ndp->ni_loopcnt++ >= MAXSYMLINKS) {
- error = ELOOP;
- goto badlink2;
- }
- if (ndp->ni_pathlen > 1)
- cp = zalloc(namei_zone);
- else
- cp = cnp->cn_pnbuf;
- aiov.iov_base = cp;
- aiov.iov_len = MAXPATHLEN;
- auio.uio_iov = &aiov;
- auio.uio_iovcnt = 1;
- auio.uio_offset = 0;
- auio.uio_rw = UIO_READ;
- auio.uio_segflg = UIO_SYSSPACE;
- auio.uio_procp = (struct proc *)0;
- auio.uio_resid = MAXPATHLEN;
- error = VOP_READLINK(ndp->ni_vp, &auio, cnp->cn_cred);
- if (error) {
- badlink1:
- if (ndp->ni_pathlen > 1)
- zfree(namei_zone, cp);
- badlink2:
- vrele(ndp->ni_dvp);
- vput(ndp->ni_vp);
- break;
- }
- linklen = MAXPATHLEN - auio.uio_resid;
- if (linklen == 0) {
- error = ENOENT;
- goto badlink1;
- }
- if (linklen + ndp->ni_pathlen >= MAXPATHLEN) {
- error = ENAMETOOLONG;
- goto badlink1;
- }
-
- /*
- * Adjust or replace path
- */
- if (ndp->ni_pathlen > 1) {
- bcopy(ndp->ni_next, cp + linklen, ndp->ni_pathlen);
- zfree(namei_zone, cnp->cn_pnbuf);
- cnp->cn_pnbuf = cp;
- } else
- cnp->cn_pnbuf[linklen] = '\0';
- ndp->ni_pathlen += linklen;
-
- /*
- * Cleanup refs for next loop and check if root directory
- * should replace current directory. Normally ni_dvp
- * becomes the new base directory and is cleaned up when
- * we loop. Explicitly null pointers after invalidation
- * to clarify operation.
- */
- vput(ndp->ni_vp);
- ndp->ni_vp = NULL;
-
- if (cnp->cn_pnbuf[0] == '/') {
- vrele(ndp->ni_dvp);
- ndp->ni_dvp = ndp->ni_rootdir;
- VREF(ndp->ni_dvp);
- }
- ndp->ni_startdir = ndp->ni_dvp;
- ndp->ni_dvp = NULL;
- }
-
- /*
- * nfs_namei() guarentees that fields will not contain garbage
- * whether an error occurs or not. This allows the caller to track
- * cleanup state trivially.
- */
-out:
- if (error) {
- zfree(namei_zone, cnp->cn_pnbuf);
- ndp->ni_vp = NULL;
- ndp->ni_dvp = NULL;
- ndp->ni_startdir = NULL;
- cnp->cn_flags &= ~HASBUF;
- } else if ((ndp->ni_cnd.cn_flags & (WANTPARENT|LOCKPARENT)) == 0) {
- ndp->ni_dvp = NULL;
- }
- return (error);
-}
-
-/*
- * A fiddled version of m_adj() that ensures null fill to a long
- * boundary and only trims off the back end
- */
-void
-nfsm_adj(mp, len, nul)
- struct mbuf *mp;
- register int len;
- int nul;
-{
- register struct mbuf *m;
- register int count, i;
- register char *cp;
-
- /*
- * Trim from tail. Scan the mbuf chain,
- * calculating its length and finding the last mbuf.
- * If the adjustment only affects this mbuf, then just
- * adjust and return. Otherwise, rescan and truncate
- * after the remaining size.
- */
- count = 0;
- m = mp;
- for (;;) {
- count += m->m_len;
- if (m->m_next == (struct mbuf *)0)
- break;
- m = m->m_next;
- }
- if (m->m_len > len) {
- m->m_len -= len;
- if (nul > 0) {
- cp = mtod(m, caddr_t)+m->m_len-nul;
- for (i = 0; i < nul; i++)
- *cp++ = '\0';
- }
- return;
- }
- count -= len;
- if (count < 0)
- count = 0;
- /*
- * Correct length for chain is "count".
- * Find the mbuf with last data, adjust its length,
- * and toss data from remaining mbufs on chain.
- */
- for (m = mp; m; m = m->m_next) {
- if (m->m_len >= count) {
- m->m_len = count;
- if (nul > 0) {
- cp = mtod(m, caddr_t)+m->m_len-nul;
- for (i = 0; i < nul; i++)
- *cp++ = '\0';
- }
- break;
- }
- count -= m->m_len;
- }
- for (m = m->m_next;m;m = m->m_next)
- m->m_len = 0;
-}
-
-/*
- * Make these functions instead of macros, so that the kernel text size
- * doesn't get too big...
- */
-void
-nfsm_srvwcc(nfsd, before_ret, before_vap, after_ret, after_vap, mbp, bposp)
- struct nfsrv_descript *nfsd;
- int before_ret;
- register struct vattr *before_vap;
- int after_ret;
- struct vattr *after_vap;
- struct mbuf **mbp;
- char **bposp;
-{
- register struct mbuf *mb = *mbp, *mb2;
- register char *bpos = *bposp;
- register u_int32_t *tl;
-
- if (before_ret) {
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);
- *tl = nfs_false;
- } else {
- nfsm_build(tl, u_int32_t *, 7 * NFSX_UNSIGNED);
- *tl++ = nfs_true;
- txdr_hyper(before_vap->va_size, tl);
- tl += 2;
- txdr_nfsv3time(&(before_vap->va_mtime), tl);
- tl += 2;
- txdr_nfsv3time(&(before_vap->va_ctime), tl);
- }
- *bposp = bpos;
- *mbp = mb;
- nfsm_srvpostopattr(nfsd, after_ret, after_vap, mbp, bposp);
-}
-
-void
-nfsm_srvpostopattr(nfsd, after_ret, after_vap, mbp, bposp)
- struct nfsrv_descript *nfsd;
- int after_ret;
- struct vattr *after_vap;
- struct mbuf **mbp;
- char **bposp;
-{
- register struct mbuf *mb = *mbp, *mb2;
- register char *bpos = *bposp;
- register u_int32_t *tl;
- register struct nfs_fattr *fp;
-
- if (after_ret) {
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);
- *tl = nfs_false;
- } else {
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED + NFSX_V3FATTR);
- *tl++ = nfs_true;
- fp = (struct nfs_fattr *)tl;
- nfsm_srvfattr(nfsd, after_vap, fp);
- }
- *mbp = mb;
- *bposp = bpos;
-}
-
-void
-nfsm_srvfattr(nfsd, vap, fp)
- register struct nfsrv_descript *nfsd;
- register struct vattr *vap;
- register struct nfs_fattr *fp;
-{
-
- fp->fa_nlink = txdr_unsigned(vap->va_nlink);
- fp->fa_uid = txdr_unsigned(vap->va_uid);
- fp->fa_gid = txdr_unsigned(vap->va_gid);
- if (nfsd->nd_flag & ND_NFSV3) {
- fp->fa_type = vtonfsv3_type(vap->va_type);
- fp->fa_mode = vtonfsv3_mode(vap->va_mode);
- txdr_hyper(vap->va_size, &fp->fa3_size);
- txdr_hyper(vap->va_bytes, &fp->fa3_used);
- fp->fa3_rdev.specdata1 = txdr_unsigned(umajor(vap->va_rdev));
- fp->fa3_rdev.specdata2 = txdr_unsigned(uminor(vap->va_rdev));
- fp->fa3_fsid.nfsuquad[0] = 0;
- fp->fa3_fsid.nfsuquad[1] = txdr_unsigned(vap->va_fsid);
- fp->fa3_fileid.nfsuquad[0] = 0;
- fp->fa3_fileid.nfsuquad[1] = txdr_unsigned(vap->va_fileid);
- txdr_nfsv3time(&vap->va_atime, &fp->fa3_atime);
- txdr_nfsv3time(&vap->va_mtime, &fp->fa3_mtime);
- txdr_nfsv3time(&vap->va_ctime, &fp->fa3_ctime);
- } else {
- fp->fa_type = vtonfsv2_type(vap->va_type);
- fp->fa_mode = vtonfsv2_mode(vap->va_type, vap->va_mode);
- fp->fa2_size = txdr_unsigned(vap->va_size);
- fp->fa2_blocksize = txdr_unsigned(vap->va_blocksize);
- if (vap->va_type == VFIFO)
- fp->fa2_rdev = 0xffffffff;
- else
- fp->fa2_rdev = txdr_unsigned(vap->va_rdev);
- fp->fa2_blocks = txdr_unsigned(vap->va_bytes / NFS_FABLKSIZE);
- fp->fa2_fsid = txdr_unsigned(vap->va_fsid);
- fp->fa2_fileid = txdr_unsigned(vap->va_fileid);
- txdr_nfsv2time(&vap->va_atime, &fp->fa2_atime);
- txdr_nfsv2time(&vap->va_mtime, &fp->fa2_mtime);
- txdr_nfsv2time(&vap->va_ctime, &fp->fa2_ctime);
- }
-}
-
-/*
- * nfsrv_fhtovp() - convert a fh to a vnode ptr (optionally locked)
- * - look up fsid in mount list (if not found ret error)
- * - get vp and export rights by calling VFS_FHTOVP()
- * - if cred->cr_uid == 0 or MNT_EXPORTANON set it to credanon
- * - if not lockflag unlock it with VOP_UNLOCK()
- */
-int
-nfsrv_fhtovp(fhp, lockflag, vpp, cred, slp, nam, rdonlyp, kerbflag, pubflag)
- fhandle_t *fhp;
- int lockflag;
- struct vnode **vpp;
- struct ucred *cred;
- struct nfssvc_sock *slp;
- struct sockaddr *nam;
- int *rdonlyp;
- int kerbflag;
- int pubflag;
-{
- struct proc *p = curproc; /* XXX */
- register struct mount *mp;
- register int i;
- struct ucred *credanon;
- int error, exflags;
-#ifdef MNT_EXNORESPORT /* XXX needs mountd and /etc/exports help yet */
- struct sockaddr_int *saddr;
-#endif
-
- *vpp = (struct vnode *)0;
-
- if (nfs_ispublicfh(fhp)) {
- if (!pubflag || !nfs_pub.np_valid)
- return (ESTALE);
- fhp = &nfs_pub.np_handle;
- }
-
- mp = vfs_getvfs(&fhp->fh_fsid);
- if (!mp)
- return (ESTALE);
- error = VFS_CHECKEXP(mp, nam, &exflags, &credanon);
- if (error)
- return (error);
- error = VFS_FHTOVP(mp, &fhp->fh_fid, vpp);
- if (error)
- return (error);
-#ifdef MNT_EXNORESPORT
- if (!(exflags & (MNT_EXNORESPORT|MNT_EXPUBLIC))) {
- saddr = (struct sockaddr_in *)nam;
- if (saddr->sin_family == AF_INET &&
- ntohs(saddr->sin_port) >= IPPORT_RESERVED) {
- vput(*vpp);
- *vpp = NULL;
- return (NFSERR_AUTHERR | AUTH_TOOWEAK);
- }
- }
-#endif
- /*
- * Check/setup credentials.
- */
- if (exflags & MNT_EXKERB) {
- if (!kerbflag) {
- vput(*vpp);
- *vpp = NULL;
- return (NFSERR_AUTHERR | AUTH_TOOWEAK);
- }
- } else if (kerbflag) {
- vput(*vpp);
- *vpp = NULL;
- return (NFSERR_AUTHERR | AUTH_TOOWEAK);
- } else if (cred->cr_uid == 0 || (exflags & MNT_EXPORTANON)) {
- cred->cr_uid = credanon->cr_uid;
- for (i = 0; i < credanon->cr_ngroups && i < NGROUPS; i++)
- cred->cr_groups[i] = credanon->cr_groups[i];
- cred->cr_ngroups = i;
- }
- if (exflags & MNT_EXRDONLY)
- *rdonlyp = 1;
- else
- *rdonlyp = 0;
-
- nfsrv_object_create(*vpp);
-
- if (!lockflag)
- VOP_UNLOCK(*vpp, 0, p);
- return (0);
-}
-
-
-/*
- * WebNFS: check if a filehandle is a public filehandle. For v3, this
- * means a length of 0, for v2 it means all zeroes. nfsm_srvmtofh has
- * transformed this to all zeroes in both cases, so check for it.
- */
-int
-nfs_ispublicfh(fhp)
- fhandle_t *fhp;
-{
- char *cp = (char *)fhp;
- int i;
-
- for (i = 0; i < NFSX_V3FH; i++)
- if (*cp++ != 0)
- return (FALSE);
- return (TRUE);
-}
-
-#endif /* NFS_NOSERVER */
-/*
- * This function compares two net addresses by family and returns TRUE
- * if they are the same host.
- * If there is any doubt, return FALSE.
- * The AF_INET family is handled as a special case so that address mbufs
- * don't need to be saved to store "struct in_addr", which is only 4 bytes.
- */
-int
-netaddr_match(family, haddr, nam)
- int family;
- union nethostaddr *haddr;
- struct sockaddr *nam;
-{
- register struct sockaddr_in *inetaddr;
-
- switch (family) {
- case AF_INET:
- inetaddr = (struct sockaddr_in *)nam;
- if (inetaddr->sin_family == AF_INET &&
- inetaddr->sin_addr.s_addr == haddr->had_inetaddr)
- return (1);
- break;
- default:
- break;
- };
- return (0);
-}
-
-static nfsuint64 nfs_nullcookie = { { 0, 0 } };
-/*
- * This function finds the directory cookie that corresponds to the
- * logical byte offset given.
- */
-nfsuint64 *
-nfs_getcookie(np, off, add)
- register struct nfsnode *np;
- off_t off;
- int add;
-{
- register struct nfsdmap *dp, *dp2;
- register int pos;
-
- pos = (uoff_t)off / NFS_DIRBLKSIZ;
- if (pos == 0 || off < 0) {
-#ifdef DIAGNOSTIC
- if (add)
- panic("nfs getcookie add at <= 0");
-#endif
- return (&nfs_nullcookie);
- }
- pos--;
- dp = np->n_cookies.lh_first;
- if (!dp) {
- if (add) {
- MALLOC(dp, struct nfsdmap *, sizeof (struct nfsdmap),
- M_NFSDIROFF, M_WAITOK);
- dp->ndm_eocookie = 0;
- LIST_INSERT_HEAD(&np->n_cookies, dp, ndm_list);
- } else
- return ((nfsuint64 *)0);
- }
- while (pos >= NFSNUMCOOKIES) {
- pos -= NFSNUMCOOKIES;
- if (dp->ndm_list.le_next) {
- if (!add && dp->ndm_eocookie < NFSNUMCOOKIES &&
- pos >= dp->ndm_eocookie)
- return ((nfsuint64 *)0);
- dp = dp->ndm_list.le_next;
- } else if (add) {
- MALLOC(dp2, struct nfsdmap *, sizeof (struct nfsdmap),
- M_NFSDIROFF, M_WAITOK);
- dp2->ndm_eocookie = 0;
- LIST_INSERT_AFTER(dp, dp2, ndm_list);
- dp = dp2;
- } else
- return ((nfsuint64 *)0);
- }
- if (pos >= dp->ndm_eocookie) {
- if (add)
- dp->ndm_eocookie = pos + 1;
- else
- return ((nfsuint64 *)0);
- }
- return (&dp->ndm_cookies[pos]);
-}
-
-/*
- * Invalidate cached directory information, except for the actual directory
- * blocks (which are invalidated separately).
- * Done mainly to avoid the use of stale offset cookies.
- */
-void
-nfs_invaldir(vp)
- register struct vnode *vp;
-{
- register struct nfsnode *np = VTONFS(vp);
-
-#ifdef DIAGNOSTIC
- if (vp->v_type != VDIR)
- panic("nfs: invaldir not dir");
-#endif
- np->n_direofoffset = 0;
- np->n_cookieverf.nfsuquad[0] = 0;
- np->n_cookieverf.nfsuquad[1] = 0;
- if (np->n_cookies.lh_first)
- np->n_cookies.lh_first->ndm_eocookie = 0;
-}
-
-/*
- * The write verifier has changed (probably due to a server reboot), so all
- * B_NEEDCOMMIT blocks will have to be written again. Since they are on the
- * dirty block list as B_DELWRI, all this takes is clearing the B_NEEDCOMMIT
- * and B_CLUSTEROK flags. Once done the new write verifier can be set for the
- * mount point.
- *
- * B_CLUSTEROK must be cleared along with B_NEEDCOMMIT because stage 1 data
- * writes are not clusterable.
- */
-void
-nfs_clearcommit(mp)
- struct mount *mp;
-{
- register struct vnode *vp, *nvp;
- register struct buf *bp, *nbp;
- int s;
-
- s = splbio();
-loop:
- for (vp = mp->mnt_vnodelist.lh_first; vp; vp = nvp) {
- if (vp->v_mount != mp) /* Paranoia */
- goto loop;
- nvp = vp->v_mntvnodes.le_next;
- for (bp = TAILQ_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) {
- nbp = TAILQ_NEXT(bp, b_vnbufs);
- if (BUF_REFCNT(bp) == 0 &&
- (bp->b_flags & (B_DELWRI | B_NEEDCOMMIT))
- == (B_DELWRI | B_NEEDCOMMIT))
- bp->b_flags &= ~(B_NEEDCOMMIT | B_CLUSTEROK);
- }
- }
- splx(s);
-}
-
-#ifndef NFS_NOSERVER
-/*
- * Map errnos to NFS error numbers. For Version 3 also filter out error
- * numbers not specified for the associated procedure.
- */
-int
-nfsrv_errmap(nd, err)
- struct nfsrv_descript *nd;
- register int err;
-{
- register short *defaulterrp, *errp;
-
- if (nd->nd_flag & ND_NFSV3) {
- if (nd->nd_procnum <= NFSPROC_COMMIT) {
- errp = defaulterrp = nfsrv_v3errmap[nd->nd_procnum];
- while (*++errp) {
- if (*errp == err)
- return (err);
- else if (*errp > err)
- break;
- }
- return ((int)*defaulterrp);
- } else
- return (err & 0xffff);
- }
- if (err <= ELAST)
- return ((int)nfsrv_v2errmap[err - 1]);
- return (NFSERR_IO);
-}
-
-int
-nfsrv_object_create(vp)
- struct vnode *vp;
-{
-
- if (vp == NULL || vp->v_type != VREG)
- return (1);
- return (vfs_object_create(vp, curproc,
- curproc ? curproc->p_ucred : NULL));
-}
-
-/*
- * Sort the group list in increasing numerical order.
- * (Insertion sort by Chris Torek, who was grossed out by the bubble sort
- * that used to be here.)
- */
-void
-nfsrvw_sort(list, num)
- register gid_t *list;
- register int num;
-{
- register int i, j;
- gid_t v;
-
- /* Insertion sort. */
- for (i = 1; i < num; i++) {
- v = list[i];
- /* find correct slot for value v, moving others up */
- for (j = i; --j >= 0 && v < list[j];)
- list[j + 1] = list[j];
- list[j + 1] = v;
- }
-}
-
-/*
- * copy credentials making sure that the result can be compared with bcmp().
- */
-void
-nfsrv_setcred(incred, outcred)
- register struct ucred *incred, *outcred;
-{
- register int i;
-
- bzero((caddr_t)outcred, sizeof (struct ucred));
- outcred->cr_ref = 1;
- outcred->cr_uid = incred->cr_uid;
- outcred->cr_ngroups = incred->cr_ngroups;
- for (i = 0; i < incred->cr_ngroups; i++)
- outcred->cr_groups[i] = incred->cr_groups[i];
- nfsrvw_sort(outcred->cr_groups, outcred->cr_ngroups);
-}
-#endif /* NFS_NOSERVER */
diff --git a/sys/nfs/nfs_common.h b/sys/nfs/nfs_common.h
deleted file mode 100644
index b13c0099b816..000000000000
--- a/sys/nfs/nfs_common.h
+++ /dev/null
@@ -1,564 +0,0 @@
-/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Rick Macklem at The University of Guelph.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)nfsm_subs.h 8.2 (Berkeley) 3/30/95
- * $FreeBSD$
- */
-
-
-#ifndef _NFS_NFSM_SUBS_H_
-#define _NFS_NFSM_SUBS_H_
-
-struct ucred;
-struct vnode;
-
-/*
- * These macros do strange and peculiar things to mbuf chains for
- * the assistance of the nfs code. To attempt to use them for any
- * other purpose will be dangerous. (they make weird assumptions)
- */
-
-/*
- * First define what the actual subs. return
- */
-struct mbuf *nfsm_reqh __P((struct vnode *vp, u_long procid, int hsiz,
- caddr_t *bposp));
-struct mbuf *nfsm_rpchead __P((struct ucred *cr, int nmflag, int procid,
- int auth_type, int auth_len, char *auth_str,
- int verf_len, char *verf_str,
- struct mbuf *mrest, int mrest_len,
- struct mbuf **mbp, u_int32_t *xidp));
-
-#define M_HASCL(m) ((m)->m_flags & M_EXT)
-#define NFSMINOFF(m) \
- do { \
- if (M_HASCL(m)) \
- (m)->m_data = (m)->m_ext.ext_buf; \
- else if ((m)->m_flags & M_PKTHDR) \
- (m)->m_data = (m)->m_pktdat; \
- else \
- (m)->m_data = (m)->m_dat; \
- } while (0)
-#define NFSMADV(m, s) \
- do { \
- (m)->m_data += (s); \
- } while (0)
-#define NFSMSIZ(m) ((M_HASCL(m))?MCLBYTES: \
- (((m)->m_flags & M_PKTHDR)?MHLEN:MLEN))
-
-/*
- * Now for the macros that do the simple stuff and call the functions
- * for the hard stuff.
- * These macros use several vars. declared in nfsm_reqhead and these
- * vars. must not be used elsewhere unless you are careful not to corrupt
- * them. The vars. starting with pN and tN (N=1,2,3,..) are temporaries
- * that may be used so long as the value is not expected to retained
- * after a macro.
- * I know, this is kind of dorkey, but it makes the actual op functions
- * fairly clean and deals with the mess caused by the xdr discriminating
- * unions.
- */
-
-#define nfsm_build(a,c,s) \
- do { \
- if ((s) > M_TRAILINGSPACE(mb)) { \
- MGET(mb2, M_WAIT, MT_DATA); \
- if ((s) > MLEN) \
- panic("build > MLEN"); \
- mb->m_next = mb2; \
- mb = mb2; \
- mb->m_len = 0; \
- bpos = mtod(mb, caddr_t); \
- } \
- (a) = (c)(bpos); \
- mb->m_len += (s); \
- bpos += (s); \
- } while (0)
-
-#define nfsm_dissect(a, c, s) \
- do { \
- t1 = mtod(md, caddr_t)+md->m_len-dpos; \
- if (t1 >= (s)) { \
- (a) = (c)(dpos); \
- dpos += (s); \
- } else if ((t1 = nfsm_disct(&md, &dpos, (s), t1, &cp2)) != 0){ \
- error = t1; \
- m_freem(mrep); \
- goto nfsmout; \
- } else { \
- (a) = (c)cp2; \
- } \
- } while (0)
-
-#define nfsm_fhtom(v, v3) \
- do { \
- if (v3) { \
- t2 = nfsm_rndup(VTONFS(v)->n_fhsize) + NFSX_UNSIGNED; \
- if (t2 <= M_TRAILINGSPACE(mb)) { \
- nfsm_build(tl, u_int32_t *, t2); \
- *tl++ = txdr_unsigned(VTONFS(v)->n_fhsize); \
- *(tl + ((t2>>2) - 2)) = 0; \
- bcopy((caddr_t)VTONFS(v)->n_fhp,(caddr_t)tl, \
- VTONFS(v)->n_fhsize); \
- } else if ((t2 = nfsm_strtmbuf(&mb, &bpos, \
- (caddr_t)VTONFS(v)->n_fhp, \
- VTONFS(v)->n_fhsize)) != 0) { \
- error = t2; \
- m_freem(mreq); \
- goto nfsmout; \
- } \
- } else { \
- nfsm_build(cp, caddr_t, NFSX_V2FH); \
- bcopy((caddr_t)VTONFS(v)->n_fhp, cp, NFSX_V2FH); \
- } \
- } while (0)
-
-#define nfsm_srvfhtom(f, v3) \
- do { \
- if (v3) { \
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED + NFSX_V3FH);\
- *tl++ = txdr_unsigned(NFSX_V3FH); \
- bcopy((caddr_t)(f), (caddr_t)tl, NFSX_V3FH); \
- } else { \
- nfsm_build(cp, caddr_t, NFSX_V2FH); \
- bcopy((caddr_t)(f), cp, NFSX_V2FH); \
- } \
- } while (0)
-
-#define nfsm_srvpostop_fh(f) \
- do { \
- nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED + NFSX_V3FH); \
- *tl++ = nfs_true; \
- *tl++ = txdr_unsigned(NFSX_V3FH); \
- bcopy((caddr_t)(f), (caddr_t)tl, NFSX_V3FH); \
- } while (0)
-
-#define nfsm_mtofh(d, v, v3, f) \
- do { \
- struct nfsnode *ttnp; nfsfh_t *ttfhp; int ttfhsize; \
- if (v3) { \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- (f) = fxdr_unsigned(int, *tl); \
- } else \
- (f) = 1; \
- if (f) { \
- nfsm_getfh(ttfhp, ttfhsize, (v3)); \
- if ((t1 = nfs_nget((d)->v_mount, ttfhp, ttfhsize, \
- &ttnp)) != 0) { \
- error = t1; \
- m_freem(mrep); \
- goto nfsmout; \
- } \
- (v) = NFSTOV(ttnp); \
- } \
- if (v3) { \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- if (f) \
- (f) = fxdr_unsigned(int, *tl); \
- else if (fxdr_unsigned(int, *tl)) \
- nfsm_adv(NFSX_V3FATTR); \
- } \
- if (f) \
- nfsm_loadattr((v), (struct vattr *)0); \
- } while (0)
-
-#define nfsm_getfh(f, s, v3) \
- do { \
- if (v3) { \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- if (((s) = fxdr_unsigned(int, *tl)) <= 0 || \
- (s) > NFSX_V3FHMAX) { \
- m_freem(mrep); \
- error = EBADRPC; \
- goto nfsmout; \
- } \
- } else \
- (s) = NFSX_V2FH; \
- nfsm_dissect((f), nfsfh_t *, nfsm_rndup(s)); \
- } while (0)
-
-#define nfsm_loadattr(v, a) \
- do { \
- struct vnode *ttvp = (v); \
- if ((t1 = nfs_loadattrcache(&ttvp, &md, &dpos, (a))) != 0) { \
- error = t1; \
- m_freem(mrep); \
- goto nfsmout; \
- } \
- (v) = ttvp; \
- } while (0)
-
-#define nfsm_postop_attr(v, f) \
- do { \
- struct vnode *ttvp = (v); \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- if (((f) = fxdr_unsigned(int, *tl)) != 0) { \
- if ((t1 = nfs_loadattrcache(&ttvp, &md, &dpos, \
- (struct vattr *)0)) != 0) { \
- error = t1; \
- (f) = 0; \
- m_freem(mrep); \
- goto nfsmout; \
- } \
- (v) = ttvp; \
- } \
- } while (0)
-
-/* Used as (f) for nfsm_wcc_data() */
-#define NFSV3_WCCRATTR 0
-#define NFSV3_WCCCHK 1
-
-#define nfsm_wcc_data(v, f) \
- do { \
- int ttattrf, ttretf = 0; \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- if (*tl == nfs_true) { \
- nfsm_dissect(tl, u_int32_t *, 6 * NFSX_UNSIGNED); \
- if (f) \
- ttretf = (VTONFS(v)->n_mtime == \
- fxdr_unsigned(u_int32_t, *(tl + 2))); \
- } \
- nfsm_postop_attr((v), ttattrf); \
- if (f) { \
- (f) = ttretf; \
- } else { \
- (f) = ttattrf; \
- } \
- } while (0)
-
-/* If full is true, set all fields, otherwise just set mode and time fields */
-#define nfsm_v3attrbuild(a, full) \
- do { \
- if ((a)->va_mode != (mode_t)VNOVAL) { \
- nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
- *tl++ = nfs_true; \
- *tl = txdr_unsigned((a)->va_mode); \
- } else { \
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \
- *tl = nfs_false; \
- } \
- if ((full) && (a)->va_uid != (uid_t)VNOVAL) { \
- nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
- *tl++ = nfs_true; \
- *tl = txdr_unsigned((a)->va_uid); \
- } else { \
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \
- *tl = nfs_false; \
- } \
- if ((full) && (a)->va_gid != (gid_t)VNOVAL) { \
- nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
- *tl++ = nfs_true; \
- *tl = txdr_unsigned((a)->va_gid); \
- } else { \
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \
- *tl = nfs_false; \
- } \
- if ((full) && (a)->va_size != VNOVAL) { \
- nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED); \
- *tl++ = nfs_true; \
- txdr_hyper((a)->va_size, tl); \
- } else { \
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \
- *tl = nfs_false; \
- } \
- if ((a)->va_atime.tv_sec != VNOVAL) { \
- if ((a)->va_atime.tv_sec != time_second) { \
- nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED);\
- *tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT);\
- txdr_nfsv3time(&(a)->va_atime, tl); \
- } else { \
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \
- *tl = txdr_unsigned(NFSV3SATTRTIME_TOSERVER); \
- } \
- } else { \
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \
- *tl = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE); \
- } \
- if ((a)->va_mtime.tv_sec != VNOVAL) { \
- if ((a)->va_mtime.tv_sec != time_second) { \
- nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED);\
- *tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT);\
- txdr_nfsv3time(&(a)->va_mtime, tl); \
- } else { \
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \
- *tl = txdr_unsigned(NFSV3SATTRTIME_TOSERVER); \
- } \
- } else { \
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \
- *tl = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE); \
- } \
- } while (0)
-
-
-#define nfsm_strsiz(s,m) \
- do { \
- nfsm_dissect(tl,u_int32_t *,NFSX_UNSIGNED); \
- if (((s) = fxdr_unsigned(int32_t,*tl)) > (m)) { \
- m_freem(mrep); \
- error = EBADRPC; \
- goto nfsmout; \
- } \
- } while (0)
-
-#define nfsm_srvstrsiz(s,m) \
- do { \
- nfsm_dissect(tl,u_int32_t *,NFSX_UNSIGNED); \
- if (((s) = fxdr_unsigned(int32_t,*tl)) > (m) || (s) <= 0) { \
- error = EBADRPC; \
- nfsm_reply(0); \
- } \
- } while (0)
-
-#define nfsm_srvnamesiz(s) \
- do { \
- nfsm_dissect(tl,u_int32_t *,NFSX_UNSIGNED); \
- if (((s) = fxdr_unsigned(int32_t,*tl)) > NFS_MAXNAMLEN) \
- error = NFSERR_NAMETOL; \
- if ((s) <= 0) \
- error = EBADRPC; \
- if (error) \
- nfsm_reply(0); \
- } while (0)
-
-#define nfsm_mtouio(p,s) \
- do {\
- if ((s) > 0 && \
- (t1 = nfsm_mbuftouio(&md,(p),(s),&dpos)) != 0) { \
- error = t1; \
- m_freem(mrep); \
- goto nfsmout; \
- } \
- } while (0)
-
-#define nfsm_uiotom(p,s) \
- do { \
- if ((t1 = nfsm_uiotombuf((p),&mb,(s),&bpos)) != 0) { \
- error = t1; \
- m_freem(mreq); \
- goto nfsmout; \
- } \
- } while (0)
-
-#define nfsm_reqhead(v,a,s) \
- do { \
- mb = mreq = nfsm_reqh((v),(a),(s),&bpos); \
- } while (0)
-
-#define nfsm_reqdone \
- do { \
- m_freem(mrep); \
- nfsmout: \
- } while (0)
-
-#define nfsm_rndup(a) (((a)+3)&(~0x3))
-
-#define nfsm_request(v, t, p, c) \
- do { \
- if ((error = nfs_request((v), mreq, (t), (p), \
- (c), &mrep, &md, &dpos)) != 0) { \
- if (error & NFSERR_RETERR) \
- error &= ~NFSERR_RETERR; \
- else \
- goto nfsmout; \
- } \
- } while (0)
-
-#define nfsm_strtom(a,s,m) \
- do {\
- if ((s) > (m)) { \
- m_freem(mreq); \
- error = ENAMETOOLONG; \
- goto nfsmout; \
- } \
- t2 = nfsm_rndup(s)+NFSX_UNSIGNED; \
- if (t2 <= M_TRAILINGSPACE(mb)) { \
- nfsm_build(tl,u_int32_t *,t2); \
- *tl++ = txdr_unsigned(s); \
- *(tl+((t2>>2)-2)) = 0; \
- bcopy((const char *)(a), (caddr_t)tl, (s)); \
- } else if ((t2 = nfsm_strtmbuf(&mb, &bpos, (a), (s))) != 0) { \
- error = t2; \
- m_freem(mreq); \
- goto nfsmout; \
- } \
- } while (0)
-
-#define nfsm_srvdone \
- do { \
- nfsmout: \
- return (error); \
- } while (0)
-
-#define nfsm_reply(s) \
- do { \
- nfsd->nd_repstat = error; \
- if (error && !(nfsd->nd_flag & ND_NFSV3)) \
- (void) nfs_rephead(0, nfsd, slp, error, cache, &frev, \
- mrq, &mb, &bpos); \
- else \
- (void) nfs_rephead((s), nfsd, slp, error, cache, &frev, \
- mrq, &mb, &bpos); \
- if (mrep != NULL) { \
- m_freem(mrep); \
- mrep = NULL; \
- } \
- mreq = *mrq; \
- if (error && (!(nfsd->nd_flag & ND_NFSV3) || \
- error == EBADRPC)) { \
- error = 0; \
- goto nfsmout; \
- } \
- } while (0)
-
-#define nfsm_writereply(s, v3) \
- do { \
- nfsd->nd_repstat = error; \
- if (error && !(v3)) \
- (void) nfs_rephead(0, nfsd, slp, error, cache, &frev, \
- &mreq, &mb, &bpos); \
- else \
- (void) nfs_rephead((s), nfsd, slp, error, cache, &frev, \
- &mreq, &mb, &bpos); \
- } while (0)
-
-#define nfsm_adv(s) \
- do { \
- t1 = mtod(md, caddr_t)+md->m_len-dpos; \
- if (t1 >= (s)) { \
- dpos += (s); \
- } else if ((t1 = nfs_adv(&md, &dpos, (s), t1)) != 0) { \
- error = t1; \
- m_freem(mrep); \
- goto nfsmout; \
- } \
- } while (0)
-
-#define nfsm_srvmtofh(f) \
- do { \
- int fhlen; \
- if (nfsd->nd_flag & ND_NFSV3) { \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- fhlen = fxdr_unsigned(int, *tl); \
- if (fhlen != 0 && fhlen != NFSX_V3FH) { \
- error = EBADRPC; \
- nfsm_reply(0); \
- } \
- } else { \
- fhlen = NFSX_V2FH; \
- } \
- if (fhlen != 0) { \
- nfsm_dissect(tl, u_int32_t *, fhlen); \
- bcopy((caddr_t)tl, (caddr_t)(f), fhlen); \
- } else {\
- bzero((caddr_t)(f), NFSX_V3FH); \
- } \
- } while (0)
-
-#define nfsm_clget \
- do { \
- if (bp >= be) { \
- if (mp == mb) \
- mp->m_len += bp-bpos; \
- MGET(mp, M_WAIT, MT_DATA); \
- MCLGET(mp, M_WAIT); \
- mp->m_len = NFSMSIZ(mp); \
- mp2->m_next = mp; \
- mp2 = mp; \
- bp = mtod(mp, caddr_t); \
- be = bp+mp->m_len; \
- } \
- tl = (u_int32_t *)bp; \
- } while (0)
-
-#define nfsm_srvfillattr(a, f) \
- do { \
- nfsm_srvfattr(nfsd, (a), (f)); \
- } while (0)
-
-#define nfsm_srvwcc_data(br, b, ar, a) \
- do { \
- nfsm_srvwcc(nfsd, (br), (b), (ar), (a), &mb, &bpos); \
- } while (0)
-
-#define nfsm_srvpostop_attr(r, a) \
- do { \
- nfsm_srvpostopattr(nfsd, (r), (a), &mb, &bpos); \
- } while (0)
-
-#define nfsm_srvsattr(a) \
- do { \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- if (*tl == nfs_true) { \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- (a)->va_mode = nfstov_mode(*tl); \
- } \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- if (*tl == nfs_true) { \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- (a)->va_uid = fxdr_unsigned(uid_t, *tl); \
- } \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- if (*tl == nfs_true) { \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- (a)->va_gid = fxdr_unsigned(gid_t, *tl); \
- } \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- if (*tl == nfs_true) { \
- nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
- (a)->va_size = fxdr_hyper(tl); \
- } \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- switch (fxdr_unsigned(int, *tl)) { \
- case NFSV3SATTRTIME_TOCLIENT: \
- nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
- fxdr_nfsv3time(tl, &(a)->va_atime); \
- break; \
- case NFSV3SATTRTIME_TOSERVER: \
- getnanotime(&(a)->va_atime); \
- break; \
- }; \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- switch (fxdr_unsigned(int, *tl)) { \
- case NFSV3SATTRTIME_TOCLIENT: \
- nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
- fxdr_nfsv3time(tl, &(a)->va_mtime); \
- break; \
- case NFSV3SATTRTIME_TOSERVER: \
- getnanotime(&(a)->va_mtime); \
- break; \
- } \
- } while (0)
-
-#endif
diff --git a/sys/nfsclient/bootp_subr.c b/sys/nfsclient/bootp_subr.c
deleted file mode 100644
index 32952484de43..000000000000
--- a/sys/nfsclient/bootp_subr.c
+++ /dev/null
@@ -1,1257 +0,0 @@
-/* $FreeBSD$ */
-
-/*
- * Copyright (c) 1995 Gordon Ross, Adam Glass
- * Copyright (c) 1992 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.
- *
- * 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 the University of
- * California, Lawrence Berkeley Laboratory and its contributors.
- * 4. 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.
- *
- * based on:
- * nfs/krpc_subr.c
- * $NetBSD: krpc_subr.c,v 1.10 1995/08/08 20:43:43 gwr Exp $
- */
-
-#include "opt_bootp.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/sockio.h>
-#include <sys/proc.h>
-#include <sys/mount.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-#include <sys/uio.h>
-
-#include <net/if.h>
-#include <net/route.h>
-
-#include <netinet/in.h>
-#include <net/if_types.h>
-#include <net/if_dl.h>
-
-#include <nfs/rpcv2.h>
-#include <nfs/nfsproto.h>
-#include <nfs/nfs.h>
-#include <nfs/nfsdiskless.h>
-#include <nfs/krpc.h>
-#include <nfs/xdr_subs.h>
-
-
-#define BOOTP_MIN_LEN 300 /* Minimum size of bootp udp packet */
-
-/*
- * What is the longest we will wait before re-sending a request?
- * Note this is also the frequency of "RPC timeout" messages.
- * The re-send loop count sup linearly to this maximum, so the
- * first complaint will happen after (1+2+3+4+5)=15 seconds.
- */
-#define MAX_RESEND_DELAY 5 /* seconds */
-
-/* Definitions from RFC951 */
-struct bootp_packet {
- u_int8_t op;
- u_int8_t htype;
- u_int8_t hlen;
- u_int8_t hops;
- u_int32_t xid;
- u_int16_t secs;
- u_int16_t flags;
- struct in_addr ciaddr;
- struct in_addr yiaddr;
- struct in_addr siaddr;
- struct in_addr giaddr;
- unsigned char chaddr[16];
- char sname[64];
- char file[128];
- unsigned char vend[256];
-};
-
-#define IPPORT_BOOTPC 68
-#define IPPORT_BOOTPS 67
-
-extern int nfs_diskless_valid;
-extern struct nfsv3_diskless nfsv3_diskless;
-
-/* mountd RPC */
-static int md_mount __P((struct sockaddr_in *mdsin, char *path,
- u_char *fhp, int *fhsizep, struct nfs_args *args,struct proc *procp));
-static int md_lookup_swap __P((struct sockaddr_in *mdsin,char *path,
- u_char *fhp, int *fhsizep,
- struct nfs_args *args,
- struct proc *procp));
-static int setfs __P((struct sockaddr_in *addr, char *path, char *p));
-static int getdec __P((char **ptr));
-static char *substr __P((char *a,char *b));
-static void mountopts __P((struct nfs_args *args, char *p));
-static int xdr_opaque_decode __P((struct mbuf **ptr,u_char *buf,
- int len));
-static int xdr_int_decode __P((struct mbuf **ptr,int *iptr));
-static void printip __P((char *prefix,struct in_addr addr));
-
-#ifdef BOOTP_DEBUG
-void bootpboot_p_sa(struct sockaddr *sa,struct sockaddr *ma);
-void bootpboot_p_ma(struct sockaddr *ma);
-void bootpboot_p_rtentry(struct rtentry *rt);
-void bootpboot_p_tree(struct radix_node *rn);
-void bootpboot_p_rtlist(void);
-void bootpboot_p_iflist(void);
-#endif
-
-static int bootpc_call(struct bootp_packet *call,
- struct bootp_packet *reply,
- struct proc *procp);
-
-static int bootpc_fakeup_interface(struct ifreq *ireq,
- struct socket *so,
- struct proc *procp);
-
-static int
-bootpc_adjust_interface(struct ifreq *ireq,struct socket *so,
- struct sockaddr_in *myaddr,
- struct sockaddr_in *netmask,
- struct sockaddr_in *gw,
- struct proc *procp);
-
-void bootpc_init(void);
-
-#ifdef BOOTP_DEBUG
-void bootpboot_p_sa(sa,ma)
- struct sockaddr *sa;
- struct sockaddr *ma;
-{
- if (!sa) {
- printf("(sockaddr *) <null>");
- return;
- }
- switch (sa->sa_family) {
- case AF_INET:
- {
- struct sockaddr_in *sin = (struct sockaddr_in *) sa;
- printf("inet %x",ntohl(sin->sin_addr.s_addr));
- if (ma) {
- struct sockaddr_in *sin = (struct sockaddr_in *) ma;
- printf(" mask %x",ntohl(sin->sin_addr.s_addr));
- }
- }
- break;
- case AF_LINK:
- {
- struct sockaddr_dl *sli = (struct sockaddr_dl *) sa;
- int i;
- printf("link %.*s ",sli->sdl_nlen,sli->sdl_data);
- for (i=0;i<sli->sdl_alen;i++) {
- if (i>0)
- printf(":");
- printf("%x",(unsigned char) sli->sdl_data[i+sli->sdl_nlen]);
- }
- }
- break;
- default:
- printf("af%d",sa->sa_family);
- }
-}
-
-void bootpboot_p_ma(ma)
- struct sockaddr *ma;
-{
- if (!ma) {
- printf("<null>");
- return;
- }
- printf("%x",*(int*)ma);
-}
-
-void bootpboot_p_rtentry(rt)
- struct rtentry *rt;
-{
- bootpboot_p_sa(rt_key(rt),rt_mask(rt));
- printf(" ");
- bootpboot_p_ma(rt->rt_genmask);
- printf(" ");
- bootpboot_p_sa(rt->rt_gateway,NULL);
- printf(" ");
- printf("flags %x",(unsigned short) rt->rt_flags);
- printf(" %d",rt->rt_rmx.rmx_expire);
- printf(" %s%d\n",rt->rt_ifp->if_name,rt->rt_ifp->if_unit);
-}
-void bootpboot_p_tree(rn)
- struct radix_node *rn;
-{
- while (rn) {
- if (rn->rn_b < 0) {
- if (rn->rn_flags & RNF_ROOT) {
- } else {
- bootpboot_p_rtentry((struct rtentry *) rn);
- }
- rn = rn->rn_dupedkey;
- } else {
- bootpboot_p_tree(rn->rn_l);
- bootpboot_p_tree(rn->rn_r);
- return;
- }
-
- }
-}
-
-void bootpboot_p_rtlist(void)
-{
- printf("Routing table:\n");
- bootpboot_p_tree(rt_tables[AF_INET]->rnh_treetop);
-}
-
-void bootpboot_p_iflist(void)
-{
- struct ifnet *ifp;
- struct ifaddr *ifa;
- printf("Interface list:\n");
- for (ifp = TAILQ_FIRST(&ifnet); ifp != 0; ifp = TAILQ_NEXT(ifp,if_link))
- {
- for (ifa = TAILQ_FIRST(&ifp->if_addrhead) ;ifa;
- ifa=TAILQ_NEXT(ifa,ifa_link))
- if (ifa->ifa_addr->sa_family == AF_INET ) {
- printf("%s%d flags %x, addr %x, bcast %x, net %x\n",
- ifp->if_name,ifp->if_unit,
- (unsigned short) ifp->if_flags,
- ntohl(((struct sockaddr_in *) ifa->ifa_addr)->sin_addr.s_addr),
- ntohl(((struct sockaddr_in *) ifa->ifa_dstaddr)->sin_addr.s_addr),
- ntohl(((struct sockaddr_in *) ifa->ifa_netmask)->sin_addr.s_addr)
- );
- }
- }
-}
-#endif
-
-static int
-bootpc_call(call,reply,procp)
- struct bootp_packet *call;
- struct bootp_packet *reply; /* output */
- struct proc *procp;
-{
- struct socket *so;
- struct sockaddr_in *sin, sa;
- struct uio auio;
- struct sockopt sopt;
- struct iovec aio;
- struct timeval tv;
- int error, on, len, rcvflg, secs, timo;
-
- /*
- * Create socket and set its recieve timeout.
- */
- if ((error = socreate(AF_INET, &so, SOCK_DGRAM, 0,procp)))
- goto out;
-
- tv.tv_sec = 1;
- tv.tv_usec = 0;
- bzero(&sopt, sizeof sopt);
- sopt.sopt_level = SOL_SOCKET;
- sopt.sopt_name = SO_RCVTIMEO;
- sopt.sopt_val = &tv;
- sopt.sopt_valsize = sizeof tv;
-
- if ((error = sosetopt(so, &sopt)) != 0)
- goto out;
-
- /*
- * Enable broadcast.
- */
- on = 1;
- sopt.sopt_val = &on;
- sopt.sopt_valsize = sizeof on;
- sopt.sopt_name = SO_BROADCAST;
- if ((error = sosetopt(so, &sopt)) != 0)
- goto out;
-
- /*
- * Bind the local endpoint to a bootp client port.
- */
- sin = &sa;
- bzero(sin, sizeof *sin);
- sin->sin_len = sizeof(*sin);
- sin->sin_family = AF_INET;
- sin->sin_addr.s_addr = INADDR_ANY;
- sin->sin_port = htons(IPPORT_BOOTPC);
- error = sobind(so, (struct sockaddr *)sin, procp);
- if (error) {
- printf("bind failed\n");
- goto out;
- }
-
- /*
- * Setup socket address for the server.
- */
- sin = &sa;
- bzero(sin, sizeof *sin);
- sin->sin_len = sizeof(*sin);
- sin->sin_family = AF_INET;
- sin->sin_addr.s_addr = INADDR_BROADCAST;
- sin->sin_port = htons(IPPORT_BOOTPS);
-
- /*
- * Send it, repeatedly, until a reply is received,
- * but delay each re-send by an increasing amount.
- * If the delay hits the maximum, start complaining.
- */
- timo = 0;
- for (;;) {
- /* Send BOOTP request (or re-send). */
-
- aio.iov_base = (caddr_t) call;
- aio.iov_len = sizeof(*call);
-
- auio.uio_iov = &aio;
- auio.uio_iovcnt = 1;
- auio.uio_segflg = UIO_SYSSPACE;
- auio.uio_rw = UIO_WRITE;
- auio.uio_offset = 0;
- auio.uio_resid = sizeof(*call);
- auio.uio_procp = procp;
-
- error = sosend(so, (struct sockaddr *)sin, &auio, NULL,
- NULL, 0, procp);
- if (error) {
- printf("bootpc_call: sosend: %d state %08x\n", error, (int)so->so_state);
- goto out;
- }
-
- /* Determine new timeout. */
- if (timo < MAX_RESEND_DELAY)
- timo++;
- else
- printf("BOOTP timeout for server 0x%lx\n",
- (u_long)ntohl(sin->sin_addr.s_addr));
-
- /*
- * Wait for up to timo seconds for a reply.
- * The socket receive timeout was set to 1 second.
- */
- secs = timo;
- while (secs > 0) {
- aio.iov_base = (caddr_t) reply;
- aio.iov_len = sizeof(*reply);
-
- auio.uio_iov = &aio;
- auio.uio_iovcnt = 1;
- auio.uio_segflg = UIO_SYSSPACE;
- auio.uio_rw = UIO_READ;
- auio.uio_offset = 0;
- auio.uio_resid = sizeof(*reply);
- auio.uio_procp = procp;
-
- rcvflg = 0;
- error = soreceive(so, NULL, &auio, NULL, NULL, &rcvflg);
- if (error == EWOULDBLOCK) {
- secs--;
- call->secs=htons(ntohs(call->secs)+1);
- continue;
- }
- if (error)
- goto out;
- len = sizeof(*reply) - auio.uio_resid;
-
- /* Do we have the required number of bytes ? */
- if (len < BOOTP_MIN_LEN)
- continue;
-
- /* Is it the right reply? */
- if (reply->op != 2)
- continue;
-
- if (reply->xid != call->xid)
- continue;
-
- if (reply->hlen != call->hlen)
- continue;
-
- if (bcmp(reply->chaddr,call->chaddr,call->hlen))
- continue;
-
- goto gotreply; /* break two levels */
-
- } /* while secs */
- } /* forever send/receive */
-
- error = ETIMEDOUT;
- goto out;
-
- gotreply:
- out:
- soclose(so);
- return error;
-}
-
-static int
-bootpc_fakeup_interface(struct ifreq *ireq,struct socket *so,
- struct proc *procp)
-{
- struct sockaddr_in *sin;
- int error;
- struct sockaddr_in dst;
- struct sockaddr_in gw;
- struct sockaddr_in mask;
-
- /*
- * Bring up the interface.
- *
- * Get the old interface flags and or IFF_UP into them; if
- * IFF_UP set blindly, interface selection can be clobbered.
- */
- error = ifioctl(so, SIOCGIFFLAGS, (caddr_t)ireq, procp);
- if (error)
- panic("bootpc_fakeup_interface: GIFFLAGS, error=%d", error);
- ireq->ifr_flags |= IFF_UP;
- error = ifioctl(so, SIOCSIFFLAGS, (caddr_t)ireq, procp);
- if (error)
- panic("bootpc_fakeup_interface: SIFFLAGS, error=%d", error);
-
- /*
- * Do enough of ifconfig(8) so that the chosen interface
- * can talk to the servers. (just set the address)
- */
-
- /* addr is 0.0.0.0 */
-
- sin = (struct sockaddr_in *)&ireq->ifr_addr;
- bzero((caddr_t)sin, sizeof(*sin));
- sin->sin_len = sizeof(*sin);
- sin->sin_family = AF_INET;
- sin->sin_addr.s_addr = INADDR_ANY;
- error = ifioctl(so, SIOCSIFADDR, (caddr_t)ireq, procp);
- if (error)
- panic("bootpc_fakeup_interface: set if addr, error=%d", error);
-
- /* netmask is 0.0.0.0 */
-
- sin = (struct sockaddr_in *)&ireq->ifr_addr;
- bzero((caddr_t)sin, sizeof(*sin));
- sin->sin_len = sizeof(*sin);
- sin->sin_family = AF_INET;
- sin->sin_addr.s_addr = INADDR_ANY;
- error = ifioctl(so, SIOCSIFNETMASK, (caddr_t)ireq, procp);
- if (error)
- panic("bootpc_fakeup_interface: set if net addr, error=%d", error);
-
- /* Broadcast is 255.255.255.255 */
-
- sin = (struct sockaddr_in *)&ireq->ifr_addr;
- bzero((caddr_t)sin, sizeof(*sin));
- sin->sin_len = sizeof(*sin);
- sin->sin_family = AF_INET;
- sin->sin_addr.s_addr = INADDR_BROADCAST;
- error = ifioctl(so, SIOCSIFBRDADDR, (caddr_t)ireq, procp);
- if (error)
- panic("bootpc_fakeup_interface: set if broadcast addr, error=%d", error);
-
- /* Add default route to 0.0.0.0 so we can send data */
-
- bzero((caddr_t) &dst, sizeof(dst));
- dst.sin_len=sizeof(dst);
- dst.sin_family=AF_INET;
- dst.sin_addr.s_addr = htonl(0);
-
- bzero((caddr_t) &gw, sizeof(gw));
- gw.sin_len=sizeof(gw);
- gw.sin_family=AF_INET;
- gw.sin_addr.s_addr = htonl(0x0);
-
- bzero((caddr_t) &mask, sizeof(mask));
- mask.sin_len=sizeof(mask);
- mask.sin_family=AF_INET;
- mask.sin_addr.s_addr = htonl(0);
-
- error = rtrequest(RTM_ADD,
- (struct sockaddr *) &dst,
- (struct sockaddr *) &gw,
- (struct sockaddr *) &mask,
- RTF_UP | RTF_STATIC
- , NULL);
- if (error)
- printf("bootpc_fakeup_interface: add default route, error=%d\n", error);
- return error;
-}
-
-static int
-bootpc_adjust_interface(struct ifreq *ireq,struct socket *so,
- struct sockaddr_in *myaddr,
- struct sockaddr_in *netmask,
- struct sockaddr_in *gw,
- struct proc *procp)
-{
- int error;
- struct sockaddr_in oldgw;
- struct sockaddr_in olddst;
- struct sockaddr_in oldmask;
- struct sockaddr_in *sin;
-
- /* Remove old default route to 0.0.0.0 */
-
- bzero((caddr_t) &olddst, sizeof(olddst));
- olddst.sin_len=sizeof(olddst);
- olddst.sin_family=AF_INET;
- olddst.sin_addr.s_addr = INADDR_ANY;
-
- bzero((caddr_t) &oldgw, sizeof(oldgw));
- oldgw.sin_len=sizeof(oldgw);
- oldgw.sin_family=AF_INET;
- oldgw.sin_addr.s_addr = INADDR_ANY;
-
- bzero((caddr_t) &oldmask, sizeof(oldmask));
- oldmask.sin_len=sizeof(oldmask);
- oldmask.sin_family=AF_INET;
- oldmask.sin_addr.s_addr = INADDR_ANY;
-
- error = rtrequest(RTM_DELETE,
- (struct sockaddr *) &olddst,
- (struct sockaddr *) &oldgw,
- (struct sockaddr *) &oldmask,
- (RTF_UP | RTF_STATIC), NULL);
- if (error) {
- printf("nfs_boot: del default route, error=%d\n", error);
- return error;
- }
-
- /*
- * Do enough of ifconfig(8) so that the chosen interface
- * can talk to the servers. (just set the address)
- */
- bcopy(netmask,&ireq->ifr_addr,sizeof(*netmask));
- error = ifioctl(so, SIOCSIFNETMASK, (caddr_t)ireq, procp);
- if (error)
- panic("nfs_boot: set if netmask, error=%d", error);
-
- /* Broadcast is with host part of IP address all 1's */
-
- sin = (struct sockaddr_in *)&ireq->ifr_addr;
- bzero((caddr_t)sin, sizeof(*sin));
- sin->sin_len = sizeof(*sin);
- sin->sin_family = AF_INET;
- sin->sin_addr.s_addr = myaddr->sin_addr.s_addr | ~ netmask->sin_addr.s_addr;
- error = ifioctl(so, SIOCSIFBRDADDR, (caddr_t)ireq, procp);
- if (error)
- panic("bootpc_call: set if broadcast addr, error=%d", error);
-
- bcopy(myaddr,&ireq->ifr_addr,sizeof(*myaddr));
- error = ifioctl(so, SIOCSIFADDR, (caddr_t)ireq, procp);
- if (error)
- panic("nfs_boot: set if addr, error=%d", error);
-
- /* Add new default route */
-
- error = rtrequest(RTM_ADD,
- (struct sockaddr *) &olddst,
- (struct sockaddr *) gw,
- (struct sockaddr *) &oldmask,
- (RTF_UP | RTF_GATEWAY | RTF_STATIC), NULL);
- if (error) {
- printf("nfs_boot: add net route, error=%d\n", error);
- return error;
- }
-
- return 0;
-}
-
-static int setfs(addr, path, p)
- struct sockaddr_in *addr;
- char *path;
- char *p;
-{
- unsigned ip = 0;
- int val;
-
- if (((val = getdec(&p)) < 0) || (val > 255)) return(0);
- ip = val << 24;
- if (*p != '.') return(0);
- p++;
- if (((val = getdec(&p)) < 0) || (val > 255)) return(0);
- ip |= (val << 16);
- if (*p != '.') return(0);
- p++;
- if (((val = getdec(&p)) < 0) || (val > 255)) return(0);
- ip |= (val << 8);
- if (*p != '.') return(0);
- p++;
- if (((val = getdec(&p)) < 0) || (val > 255)) return(0);
- ip |= val;
- if (*p != ':') return(0);
- p++;
-
- addr->sin_addr.s_addr = htonl(ip);
- addr->sin_len = sizeof(struct sockaddr_in);
- addr->sin_family = AF_INET;
-
- strncpy(path,p,MNAMELEN-1);
- return(1);
-}
-
-static int getdec(ptr)
- char **ptr;
-{
- char *p = *ptr;
- int ret=0;
- if ((*p < '0') || (*p > '9')) return(-1);
- while ((*p >= '0') && (*p <= '9')) {
- ret = ret*10 + (*p - '0');
- p++;
- }
- *ptr = p;
- return(ret);
-}
-
-static char *substr(a,b)
- char *a,*b;
-{
- char *loc1;
- char *loc2;
-
- while (*a != '\0') {
- loc1 = a;
- loc2 = b;
- while (*loc1 == *loc2++) {
- if (*loc1 == '\0') return (0);
- loc1++;
- if (*loc2 == '\0') return (loc1);
- }
- a++;
- }
- return (0);
-}
-
-static void mountopts(args,p)
- struct nfs_args *args;
- char *p;
-{
- char *tmp;
-
- args->flags = NFSMNT_RSIZE | NFSMNT_WSIZE | NFSMNT_RESVPORT;
- args->sotype = SOCK_DGRAM;
- if ((tmp = (char *)substr(p,"rsize=")))
- args->rsize=getdec(&tmp);
- if ((tmp = (char *)substr(p,"wsize=")))
- args->wsize=getdec(&tmp);
- if ((tmp = (char *)substr(p,"intr")))
- args->flags |= NFSMNT_INT;
- if ((tmp = (char *)substr(p,"soft")))
- args->flags |= NFSMNT_SOFT;
- if ((tmp = (char *)substr(p,"noconn")))
- args->flags |= NFSMNT_NOCONN;
- if ((tmp = (char *)substr(p, "tcp")))
- args->sotype = SOCK_STREAM;
-}
-
-static int xdr_opaque_decode(mptr,buf,len)
- struct mbuf **mptr;
- u_char *buf;
- int len;
-{
- struct mbuf *m;
- int alignedlen;
-
- m = *mptr;
- alignedlen = ( len + 3 ) & ~3;
-
- if (m->m_len < alignedlen) {
- m = m_pullup(m,alignedlen);
- if (m == NULL) {
- *mptr = NULL;
- return EBADRPC;
- }
- }
- bcopy(mtod(m,u_char *),buf,len);
- m_adj(m,alignedlen);
- *mptr = m;
- return 0;
-}
-
-static int xdr_int_decode(mptr,iptr)
- struct mbuf **mptr;
- int *iptr;
-{
- u_int32_t i;
- if (xdr_opaque_decode(mptr,(u_char *) &i,sizeof(u_int32_t)))
- return EBADRPC;
- *iptr = fxdr_unsigned(u_int32_t,i);
- return 0;
-}
-
-static void printip(char *prefix,struct in_addr addr)
-{
- unsigned int ip;
-
- ip = ntohl(addr.s_addr);
-
- printf("%s is %d.%d.%d.%d\n",prefix,
- ip >> 24, (ip >> 16) & 255 ,(ip >> 8) & 255 ,ip & 255 );
-}
-
-void
-bootpc_init(void)
-{
- struct bootp_packet call;
- struct bootp_packet reply;
- static u_int32_t xid = ~0xFF;
-
- struct ifreq ireq;
- struct ifnet *ifp;
- struct socket *so;
- int error;
- int code,ncode,len;
- int j;
- char *p;
- unsigned int ip;
-
- struct sockaddr_in myaddr;
- struct sockaddr_in netmask;
- struct sockaddr_in gw;
- int gotgw=0;
- int gotnetmask=0;
- int gotrootpath=0;
- int gotswappath=0;
- char lookup_path[24];
-
-#define EALEN 6
- struct ifaddr *ifa;
- struct sockaddr_dl *sdl = NULL;
- char *delim;
-
- struct nfsv3_diskless *nd = &nfsv3_diskless;
- struct proc *procp = curproc;
-
- /*
- * If already filled in, don't touch it here
- */
- if (nfs_diskless_valid)
- return;
-
- /*
- * Wait until arp entries can be handled.
- */
- while (time_second == 0)
- tsleep(&time_second, PZERO+8, "arpkludge", 10);
-
- /*
- * Find a network interface.
- */
-#ifdef BOOTP_WIRED_TO
- printf("bootpc_init: wired to interface '%s'\n",
- __XSTRING(BOOTP_WIRED_TO));
-#endif
- bzero(&ireq, sizeof(ireq));
- for (ifp = TAILQ_FIRST(&ifnet); ifp != 0; ifp = TAILQ_NEXT(ifp,if_link))
- {
- snprintf(ireq.ifr_name, sizeof(ireq.ifr_name),
- "%s%d", ifp->if_name, ifp->if_unit);
-#ifdef BOOTP_WIRED_TO
- if (strcmp(ireq.ifr_name, __XSTRING(BOOTP_WIRED_TO)) == 0)
- break;
-#else
- if ((ifp->if_flags &
- (IFF_LOOPBACK|IFF_POINTOPOINT)) == 0)
- break;
-#endif
- }
- if (ifp == NULL)
- panic("bootpc_init: no suitable interface");
- strcpy(nd->myif.ifra_name,ireq.ifr_name);
- printf("bootpc_init: using network interface '%s'\n",
- ireq.ifr_name);
-
- if ((error = socreate(AF_INET, &so, SOCK_DGRAM, 0,procp)) != 0)
- panic("nfs_boot: socreate, error=%d", error);
-
- bootpc_fakeup_interface(&ireq,so,procp);
-
- printf("Bootpc testing starting\n");
-
- /* Get HW address */
-
- for (ifa = TAILQ_FIRST(&ifp->if_addrhead) ;ifa;
- ifa=TAILQ_NEXT(ifa,ifa_link))
- if (ifa->ifa_addr->sa_family == AF_LINK &&
- (sdl = ((struct sockaddr_dl *) ifa->ifa_addr)) &&
- sdl->sdl_type == IFT_ETHER)
- break;
-
- if (!sdl)
- panic("bootpc: Unable to find HW address");
- if (sdl->sdl_alen != EALEN )
- panic("bootpc: HW address len is %d, expected value is %d",
- sdl->sdl_alen,EALEN);
-
- printf("bootpc hw address is ");
- delim="";
- for (j=0;j<sdl->sdl_alen;j++) {
- printf("%s%x",delim,((unsigned char *)LLADDR(sdl))[j]);
- delim=":";
- }
- printf("\n");
-
-#if 0
- bootpboot_p_iflist();
- bootpboot_p_rtlist();
-#endif
-
- bzero((caddr_t) &call, sizeof(call));
-
- /* bootpc part */
- call.op = 1; /* BOOTREQUEST */
- call.htype= 1; /* 10mb ethernet */
- call.hlen=sdl->sdl_alen; /* Hardware address length */
- call.hops=0;
- xid++;
- call.xid = txdr_unsigned(xid);
- bcopy(LLADDR(sdl),&call.chaddr,sdl->sdl_alen);
-
- call.vend[0]=99;
- call.vend[1]=130;
- call.vend[2]=83;
- call.vend[3]=99;
- call.vend[4]=255;
-
- call.secs = 0;
- call.flags = htons(0x8000); /* We need an broadcast answer */
-
- error = bootpc_call(&call,&reply,procp);
-
- if (error) {
-#ifdef BOOTP_NFSROOT
- panic("BOOTP call failed");
-#endif
- return;
- }
-
- bzero(&myaddr,sizeof(myaddr));
- bzero(&netmask,sizeof(netmask));
- bzero(&gw,sizeof(gw));
-
- myaddr.sin_len = sizeof(myaddr);
- myaddr.sin_family = AF_INET;
-
- netmask.sin_len = sizeof(netmask);
- netmask.sin_family = AF_INET;
-
- gw.sin_len = sizeof(gw);
- gw.sin_family= AF_INET;
-
- nd->root_args.version = NFS_ARGSVERSION;
- nd->root_args.rsize = 8192;
- nd->root_args.wsize = 8192;
- nd->root_args.sotype = SOCK_DGRAM;
- nd->root_args.flags = (NFSMNT_WSIZE | NFSMNT_RSIZE | NFSMNT_RESVPORT);
-
- nd->swap_saddr.sin_len = sizeof(gw);
- nd->swap_saddr.sin_family = AF_INET;
-
- nd->swap_args.version = NFS_ARGSVERSION;
- nd->swap_args.rsize = 8192;
- nd->swap_args.wsize = 8192;
- nd->swap_args.sotype = SOCK_DGRAM;
- nd->swap_args.flags = (NFSMNT_WSIZE | NFSMNT_RSIZE | NFSMNT_RESVPORT);
-
- myaddr.sin_addr = reply.yiaddr;
-
- ip = ntohl(myaddr.sin_addr.s_addr);
- snprintf(lookup_path, sizeof(lookup_path), "swap.%d.%d.%d.%d",
- ip >> 24, (ip >> 16) & 255 ,(ip >> 8) & 255 ,ip & 255 );
-
- printip("My ip address",myaddr.sin_addr);
-
- printip("Server ip address",reply.siaddr);
-
- gw.sin_addr = reply.giaddr;
- printip("Gateway ip address",reply.giaddr);
-
- if (reply.sname[0])
- printf("Server name is %s\n",reply.sname);
- if (reply.file[0])
- printf("boot file is %s\n",reply.file);
- if (reply.vend[0]==99 && reply.vend[1]==130 &&
- reply.vend[2]==83 && reply.vend[3]==99) {
- j=4;
- ncode = reply.vend[j];
- while (j<sizeof(reply.vend)) {
- code = reply.vend[j] = ncode;
- if (code==255)
- break;
- if (code==0) {
- j++;
- continue;
- }
- len = reply.vend[j+1];
- j+=2;
- if (len+j>=sizeof(reply.vend)) {
- printf("Truncated field");
- break;
- }
- ncode = reply.vend[j+len];
- reply.vend[j+len]='\0';
- p = &reply.vend[j];
- switch (code) {
- case 1:
- if (len!=4)
- panic("bootpc: subnet mask len is %d",len);
- bcopy(&reply.vend[j],&netmask.sin_addr,4);
- gotnetmask=1;
- printip("Subnet mask",netmask.sin_addr);
- break;
- case 6: /* Domain Name servers. Unused */
- case 16: /* Swap server IP address. unused */
- case 2:
- /* Time offset */
- break;
- case 3:
- /* Routers */
- if (len % 4)
- panic("bootpc: Router Len is %d",len);
- if (len > 0) {
- bcopy(&reply.vend[j],&gw.sin_addr,4);
- printip("Router",gw.sin_addr);
- gotgw=1;
- }
- break;
- case 17:
- if (setfs(&nd->root_saddr, nd->root_hostnam, p)) {
- printf("rootfs is %s\n",p);
- gotrootpath=1;
- } else
- panic("Failed to set rootfs to %s",p);
- break;
- case 12:
- if (len>=MAXHOSTNAMELEN)
- panic("bootpc: hostname >=%d bytes",MAXHOSTNAMELEN);
- strncpy(nd->my_hostnam,&reply.vend[j],len);
- nd->my_hostnam[len]=0;
- strncpy(hostname,&reply.vend[j],len);
- hostname[len]=0;
- printf("Hostname is %s\n",hostname);
- break;
- case 128:
- if (setfs(&nd->swap_saddr, nd->swap_hostnam, p)) {
- gotswappath=1;
- printf("swapfs is %s\n",p);
- } else
- panic("Failed to set swapfs to %s",p);
- break;
- case 129:
- {
- int swaplen;
- if (len!=4)
- panic("bootpc: Expected 4 bytes for swaplen, not %d bytes",len);
- bcopy(&reply.vend[j],&swaplen,4);
- nd->swap_nblks = ntohl(swaplen);
- printf("bootpc: Swap size is %d KB\n",nd->swap_nblks);
- }
- break;
- case 130: /* root mount options */
- mountopts(&nd->root_args,p);
- break;
- case 131: /* swap mount options */
- mountopts(&nd->swap_args,p);
- break;
- default:
- printf("Ignoring field type %d\n",code);
- }
- j+=len;
- }
- }
-
- if (!gotswappath)
- nd->swap_nblks = 0;
-#ifdef BOOTP_NFSROOT
- if (!gotrootpath)
- panic("bootpc: No root path offered");
-#endif
-
- if (!gotnetmask) {
- if (IN_CLASSA(ntohl(myaddr.sin_addr.s_addr)))
- netmask.sin_addr.s_addr = htonl(IN_CLASSA_NET);
- else if (IN_CLASSB(ntohl(myaddr.sin_addr.s_addr)))
- netmask.sin_addr.s_addr = htonl(IN_CLASSB_NET);
- else
- netmask.sin_addr.s_addr = htonl(IN_CLASSC_NET);
- }
- if (!gotgw) {
- /* Use proxyarp */
- gw.sin_addr.s_addr = myaddr.sin_addr.s_addr;
- }
-
-#if 0
- bootpboot_p_iflist();
- bootpboot_p_rtlist();
-#endif
- error = bootpc_adjust_interface(&ireq,so,
- &myaddr,&netmask,&gw,procp);
-
- soclose(so);
-
-#if 0
- bootpboot_p_iflist();
- bootpboot_p_rtlist();
-#endif
-
- if (gotrootpath) {
-
- error = md_mount(&nd->root_saddr, nd->root_hostnam,
- nd->root_fh, &nd->root_fhsize,
- &nd->root_args,procp);
- if (error)
- panic("nfs_boot: mountd root, error=%d", error);
-
- if (gotswappath) {
-
- error = md_mount(&nd->swap_saddr,
- nd->swap_hostnam,
- nd->swap_fh, &nd->swap_fhsize,&nd->swap_args,procp);
- if (error)
- panic("nfs_boot: mountd swap, error=%d", error);
-
- error = md_lookup_swap(&nd->swap_saddr,lookup_path,nd->swap_fh,
- &nd->swap_fhsize, &nd->swap_args,procp);
- if (error)
- panic("nfs_boot: lookup swap, error=%d", error);
- }
- nfs_diskless_valid = 3;
- }
-
-
- bcopy(&myaddr,&nd->myif.ifra_addr,sizeof(myaddr));
- bcopy(&myaddr,&nd->myif.ifra_broadaddr,sizeof(myaddr));
- ((struct sockaddr_in *) &nd->myif.ifra_broadaddr)->sin_addr.s_addr =
- myaddr.sin_addr.s_addr | ~ netmask.sin_addr.s_addr;
- bcopy(&netmask,&nd->myif.ifra_mask,sizeof(netmask));
-
-#if 0
- bootpboot_p_iflist();
- bootpboot_p_rtlist();
-#endif
- return;
-}
-
-/*
- * RPC: mountd/mount
- * Given a server pathname, get an NFS file handle.
- * Also, sets sin->sin_port to the NFS service port.
- */
-static int
-md_mount(mdsin, path, fhp, fhsizep, args, procp)
- struct sockaddr_in *mdsin; /* mountd server address */
- char *path;
- u_char *fhp;
- int *fhsizep;
- struct nfs_args *args;
- struct proc *procp;
-{
- struct mbuf *m;
- int error;
- int authunixok;
- int authcount;
- int authver;
-
-#ifdef BOOTP_NFSV3
- /* First try NFS v3 */
- /* Get port number for MOUNTD. */
- error = krpc_portmap(mdsin, RPCPROG_MNT, RPCMNT_VER3,
- &mdsin->sin_port, procp);
- if (!error) {
- m = xdr_string_encode(path, strlen(path));
-
- /* Do RPC to mountd. */
- error = krpc_call(mdsin, RPCPROG_MNT, RPCMNT_VER3,
- RPCMNT_MOUNT, &m, NULL, curproc);
- }
- if (!error) {
- args->flags |= NFSMNT_NFSV3;
- } else {
-#endif
- /* Fallback to NFS v2 */
-
- /* Get port number for MOUNTD. */
- error = krpc_portmap(mdsin, RPCPROG_MNT, RPCMNT_VER1,
- &mdsin->sin_port, procp);
- if (error) return error;
-
- m = xdr_string_encode(path, strlen(path));
-
- /* Do RPC to mountd. */
- error = krpc_call(mdsin, RPCPROG_MNT, RPCMNT_VER1,
- RPCMNT_MOUNT, &m, NULL, curproc);
- if (error)
- return error; /* message already freed */
-
-#ifdef BOOTP_NFSV3
- }
-#endif
-
- if (xdr_int_decode(&m,&error) || error)
- goto bad;
-
- if (args->flags & NFSMNT_NFSV3) {
- if (xdr_int_decode(&m,fhsizep) ||
- *fhsizep > NFSX_V3FHMAX || *fhsizep <= 0 )
- goto bad;
- } else
- *fhsizep = NFSX_V2FH;
-
- if (xdr_opaque_decode(&m,fhp,*fhsizep))
- goto bad;
-
- if (args->flags & NFSMNT_NFSV3) {
- if (xdr_int_decode(&m,&authcount))
- goto bad;
- authunixok = 0;
- if (authcount<0 || authcount>100)
- goto bad;
- while (authcount>0) {
- if (xdr_int_decode(&m,&authver))
- goto bad;
- if (authver == RPCAUTH_UNIX)
- authunixok = 1;
- authcount--;
- }
- if (!authunixok)
- goto bad;
- }
-
- /* Set port number for NFS use. */
- error = krpc_portmap(mdsin, NFS_PROG,
- (args->flags & NFSMNT_NFSV3)?NFS_VER3:NFS_VER2,
- &mdsin->sin_port, procp);
-
- goto out;
-
-bad:
- error = EBADRPC;
-
-out:
- m_freem(m);
- return error;
-}
-
-
-static int md_lookup_swap(mdsin, path, fhp, fhsizep, args, procp)
- struct sockaddr_in *mdsin; /* mountd server address */
- char *path;
- u_char *fhp;
- int *fhsizep;
- struct nfs_args *args;
- struct proc *procp;
-{
- struct mbuf *m;
- int error;
- int size = -1;
- int attribs_present;
- int status;
- union {
- u_int32_t v2[17];
- u_int32_t v3[21];
- } fattribs;
-
- m = m_get(M_WAIT,MT_DATA);
- if (!m)
- return ENOBUFS;
-
- if (args->flags & NFSMNT_NFSV3) {
- *mtod(m,u_int32_t *) = txdr_unsigned(*fhsizep);
- bcopy(fhp,mtod(m,u_char *)+sizeof(u_int32_t),*fhsizep);
- m->m_len = *fhsizep + sizeof(u_int32_t);
- } else {
- bcopy(fhp,mtod(m,u_char *),NFSX_V2FH);
- m->m_len = NFSX_V2FH;
- }
-
- m->m_next = xdr_string_encode(path, strlen(path));
- if (!m->m_next) {
- error = ENOBUFS;
- goto out;
- }
-
- /* Do RPC to nfsd. */
- if (args->flags & NFSMNT_NFSV3)
- error = krpc_call(mdsin, NFS_PROG, NFS_VER3,
- NFSPROC_LOOKUP, &m, NULL, procp);
- else
- error = krpc_call(mdsin, NFS_PROG, NFS_VER2,
- NFSV2PROC_LOOKUP, &m, NULL, procp);
- if (error)
- return error; /* message already freed */
-
- if (xdr_int_decode(&m,&status))
- goto bad;
- if (status) {
- error = ENOENT;
- goto out;
- }
-
- if (args->flags & NFSMNT_NFSV3) {
- if (xdr_int_decode(&m,fhsizep) ||
- *fhsizep > NFSX_V3FHMAX || *fhsizep <= 0 )
- goto bad;
- } else
- *fhsizep = NFSX_V2FH;
-
- if (xdr_opaque_decode(&m, fhp, *fhsizep))
- goto bad;
-
- if (args->flags & NFSMNT_NFSV3) {
- if (xdr_int_decode(&m,&attribs_present))
- goto bad;
- if (attribs_present) {
- if (xdr_opaque_decode(&m,(u_char *) &fattribs.v3,
- sizeof(u_int32_t)*21))
- goto bad;
- size = fxdr_unsigned(u_int32_t, fattribs.v3[6]);
- }
- } else {
- if (xdr_opaque_decode(&m,(u_char *) &fattribs.v2,
- sizeof(u_int32_t)*17))
- goto bad;
- size = fxdr_unsigned(u_int32_t, fattribs.v2[5]);
- }
-
- if (!nfsv3_diskless.swap_nblks && size!= -1) {
- nfsv3_diskless.swap_nblks = size/1024;
- printf("md_lookup_swap: Swap size is %d KB\n",
- nfsv3_diskless.swap_nblks);
- }
-
- goto out;
-
-bad:
- error = EBADRPC;
-
-out:
- m_freem(m);
- return error;
-}
diff --git a/sys/nfsclient/krpc.h b/sys/nfsclient/krpc.h
deleted file mode 100644
index 6c889b57f77c..000000000000
--- a/sys/nfsclient/krpc.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* $NetBSD: krpc.h,v 1.4 1995/12/19 23:07:11 cgd Exp $ */
-/* $FreeBSD$ */
-
-#include <sys/cdefs.h>
-
-struct mbuf;
-struct proc;
-struct sockaddr;
-struct sockaddr_in;
-
-int krpc_call __P((struct sockaddr_in *_sin,
- u_int prog, u_int vers, u_int func,
- struct mbuf **data, struct sockaddr **from, struct proc *procp));
-
-int krpc_portmap __P((struct sockaddr_in *_sin,
- u_int prog, u_int vers, u_int16_t *portp,struct proc *procp));
-
-struct mbuf *xdr_string_encode __P((char *str, int len));
-
-/*
- * RPC definitions for the portmapper
- */
-#define PMAPPORT 111
-#define PMAPPROG 100000
-#define PMAPVERS 2
-#define PMAPPROC_NULL 0
-#define PMAPPROC_SET 1
-#define PMAPPROC_UNSET 2
-#define PMAPPROC_GETPORT 3
-#define PMAPPROC_DUMP 4
-#define PMAPPROC_CALLIT 5
diff --git a/sys/nfsclient/krpc_subr.c b/sys/nfsclient/krpc_subr.c
deleted file mode 100644
index 2127d46a6d29..000000000000
--- a/sys/nfsclient/krpc_subr.c
+++ /dev/null
@@ -1,481 +0,0 @@
-/* $NetBSD: krpc_subr.c,v 1.12.4.1 1996/06/07 00:52:26 cgd Exp $ */
-/* $FreeBSD$ */
-
-/*
- * Copyright (c) 1995 Gordon Ross, Adam Glass
- * Copyright (c) 1992 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.
- *
- * 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 the University of
- * California, Lawrence Berkeley Laboratory and its contributors.
- * 4. 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.
- *
- * partially based on:
- * libnetboot/rpc.c
- * @(#) Header: rpc.c,v 1.12 93/09/28 08:31:56 leres Exp (LBL)
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/malloc.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-#include <sys/uio.h>
-
-#include <net/if.h>
-#include <netinet/in.h>
-
-#include <nfs/rpcv2.h>
-#include <nfs/krpc.h>
-#include <nfs/xdr_subs.h>
-
-/*
- * Kernel support for Sun RPC
- *
- * Used currently for bootstrapping in nfs diskless configurations.
- */
-
-/*
- * Generic RPC headers
- */
-
-struct auth_info {
- u_int32_t authtype; /* auth type */
- u_int32_t authlen; /* auth length */
-};
-
-struct auth_unix {
- int32_t ua_time;
- int32_t ua_hostname; /* null */
- int32_t ua_uid;
- int32_t ua_gid;
- int32_t ua_gidlist; /* null */
-};
-
-struct rpc_call {
- u_int32_t rp_xid; /* request transaction id */
- int32_t rp_direction; /* call direction (0) */
- u_int32_t rp_rpcvers; /* rpc version (2) */
- u_int32_t rp_prog; /* program */
- u_int32_t rp_vers; /* version */
- u_int32_t rp_proc; /* procedure */
- struct auth_info rpc_auth;
- struct auth_unix rpc_unix;
- struct auth_info rpc_verf;
-};
-
-struct rpc_reply {
- u_int32_t rp_xid; /* request transaction id */
- int32_t rp_direction; /* call direction (1) */
- int32_t rp_astatus; /* accept status (0: accepted) */
- union {
- u_int32_t rpu_errno;
- struct {
- struct auth_info rok_auth;
- u_int32_t rok_status;
- } rpu_rok;
- } rp_u;
-};
-#define rp_errno rp_u.rpu_errno
-#define rp_auth rp_u.rpu_rok.rok_auth
-#define rp_status rp_u.rpu_rok.rok_status
-
-#define MIN_REPLY_HDR 16 /* xid, dir, astat, errno */
-
-/*
- * What is the longest we will wait before re-sending a request?
- * Note this is also the frequency of "RPC timeout" messages.
- * The re-send loop count sup linearly to this maximum, so the
- * first complaint will happen after (1+2+3+4+5)=15 seconds.
- */
-#define MAX_RESEND_DELAY 5 /* seconds */
-
-/*
- * Call portmap to lookup a port number for a particular rpc program
- * Returns non-zero error on failure.
- */
-int
-krpc_portmap(sin, prog, vers, portp, procp)
- struct sockaddr_in *sin; /* server address */
- u_int prog, vers; /* host order */
- u_int16_t *portp; /* network order */
- struct proc *procp;
-{
- struct sdata {
- u_int32_t prog; /* call program */
- u_int32_t vers; /* call version */
- u_int32_t proto; /* call protocol */
- u_int32_t port; /* call port (unused) */
- } *sdata;
- struct rdata {
- u_int16_t pad;
- u_int16_t port;
- } *rdata;
- struct mbuf *m;
- int error;
-
- /* The portmapper port is fixed. */
- if (prog == PMAPPROG) {
- *portp = htons(PMAPPORT);
- return 0;
- }
-
- m = m_get(M_WAIT, MT_DATA);
- if (m == NULL)
- return ENOBUFS;
- sdata = mtod(m, struct sdata *);
- m->m_len = sizeof(*sdata);
-
- /* Do the RPC to get it. */
- sdata->prog = txdr_unsigned(prog);
- sdata->vers = txdr_unsigned(vers);
- sdata->proto = txdr_unsigned(IPPROTO_UDP);
- sdata->port = 0;
-
- sin->sin_port = htons(PMAPPORT);
- error = krpc_call(sin, PMAPPROG, PMAPVERS,
- PMAPPROC_GETPORT, &m, NULL, procp);
- if (error)
- return error;
-
- if (m->m_len < sizeof(*rdata)) {
- m = m_pullup(m, sizeof(*rdata));
- if (m == NULL)
- return ENOBUFS;
- }
- rdata = mtod(m, struct rdata *);
- *portp = rdata->port;
-
- m_freem(m);
- return 0;
-}
-
-/*
- * Do a remote procedure call (RPC) and wait for its reply.
- * If from_p is non-null, then we are doing broadcast, and
- * the address from whence the response came is saved there.
- */
-int
-krpc_call(sa, prog, vers, func, data, from_p, procp)
- struct sockaddr_in *sa;
- u_int prog, vers, func;
- struct mbuf **data; /* input/output */
- struct sockaddr **from_p; /* output */
- struct proc *procp;
-{
- struct socket *so;
- struct sockaddr_in *sin, ssin;
- struct sockaddr *from;
- struct mbuf *m, *nam, *mhead;
- struct rpc_call *call;
- struct rpc_reply *reply;
- struct sockopt sopt;
- struct timeval tv;
- struct uio auio;
- int error, rcvflg, timo, secs, len;
- static u_int32_t xid = ~0xFF;
- u_int16_t tport;
-
- /*
- * Validate address family.
- * Sorry, this is INET specific...
- */
- if (sa->sin_family != AF_INET)
- return (EAFNOSUPPORT);
-
- /* Free at end if not null. */
- nam = mhead = NULL;
- from = NULL;
-
- /*
- * Create socket and set its recieve timeout.
- */
- if ((error = socreate(AF_INET, &so, SOCK_DGRAM, 0, procp)))
- goto out;
-
- tv.tv_sec = 1;
- tv.tv_usec = 0;
- bzero(&sopt, sizeof sopt);
- sopt.sopt_level = SOL_SOCKET;
- sopt.sopt_name = SO_RCVTIMEO;
- sopt.sopt_val = &tv;
- sopt.sopt_valsize = sizeof tv;
-
- if ((error = sosetopt(so, &sopt)) != 0)
- goto out;
-
- /*
- * Enable broadcast if necessary.
- */
- if (from_p) {
- int on = 1;
- sopt.sopt_name = SO_BROADCAST;
- sopt.sopt_val = &on;
- sopt.sopt_valsize = sizeof on;
- if ((error = sosetopt(so, &sopt)) != 0)
- goto out;
- }
-
- /*
- * Bind the local endpoint to a reserved port,
- * because some NFS servers refuse requests from
- * non-reserved (non-privileged) ports.
- */
- sin = &ssin;
- bzero(sin, sizeof *sin);
- sin->sin_len = sizeof(*sin);
- sin->sin_family = AF_INET;
- sin->sin_addr.s_addr = INADDR_ANY;
- tport = IPPORT_RESERVED;
- do {
- tport--;
- sin->sin_port = htons(tport);
- error = sobind(so, (struct sockaddr *)sin, procp);
- } while (error == EADDRINUSE &&
- tport > IPPORT_RESERVED / 2);
- if (error) {
- printf("bind failed\n");
- goto out;
- }
-
- /*
- * Setup socket address for the server.
- */
-
- /*
- * Prepend RPC message header.
- */
- mhead = m_gethdr(M_WAIT, MT_DATA);
- mhead->m_next = *data;
- call = mtod(mhead, struct rpc_call *);
- mhead->m_len = sizeof(*call);
- bzero((caddr_t)call, sizeof(*call));
- /* rpc_call part */
- xid++;
- call->rp_xid = txdr_unsigned(xid);
- /* call->rp_direction = 0; */
- call->rp_rpcvers = txdr_unsigned(2);
- call->rp_prog = txdr_unsigned(prog);
- call->rp_vers = txdr_unsigned(vers);
- call->rp_proc = txdr_unsigned(func);
- /* rpc_auth part (auth_unix as root) */
- call->rpc_auth.authtype = txdr_unsigned(RPCAUTH_UNIX);
- call->rpc_auth.authlen = txdr_unsigned(sizeof(struct auth_unix));
- /* rpc_verf part (auth_null) */
- call->rpc_verf.authtype = 0;
- call->rpc_verf.authlen = 0;
-
- /*
- * Setup packet header
- */
- len = 0;
- m = mhead;
- while (m) {
- len += m->m_len;
- m = m->m_next;
- }
- mhead->m_pkthdr.len = len;
- mhead->m_pkthdr.rcvif = NULL;
-
- /*
- * Send it, repeatedly, until a reply is received,
- * but delay each re-send by an increasing amount.
- * If the delay hits the maximum, start complaining.
- */
- timo = 0;
- for (;;) {
- /* Send RPC request (or re-send). */
- m = m_copym(mhead, 0, M_COPYALL, M_WAIT);
- if (m == NULL) {
- error = ENOBUFS;
- goto out;
- }
- error = sosend(so, (struct sockaddr *)sa, NULL, m,
- NULL, 0, 0);
- if (error) {
- printf("krpc_call: sosend: %d\n", error);
- goto out;
- }
- m = NULL;
-
- /* Determine new timeout. */
- if (timo < MAX_RESEND_DELAY)
- timo++;
- else
- printf("RPC timeout for server 0x%lx\n",
- (u_long)ntohl(sa->sin_addr.s_addr));
-
- /*
- * Wait for up to timo seconds for a reply.
- * The socket receive timeout was set to 1 second.
- */
- secs = timo;
- while (secs > 0) {
- if (from) {
- FREE(from, M_SONAME);
- from = NULL;
- }
- if (m) {
- m_freem(m);
- m = NULL;
- }
- bzero(&auio,sizeof(auio));
- auio.uio_resid = len = 1<<16;
- rcvflg = 0;
- error = soreceive(so, &from, &auio, &m, NULL, &rcvflg);
- if (error == EWOULDBLOCK) {
- secs--;
- continue;
- }
- if (error)
- goto out;
- len -= auio.uio_resid;
-
- /* Does the reply contain at least a header? */
- if (len < MIN_REPLY_HDR)
- continue;
- if (m->m_len < MIN_REPLY_HDR)
- continue;
- reply = mtod(m, struct rpc_reply *);
-
- /* Is it the right reply? */
- if (reply->rp_direction != txdr_unsigned(RPC_REPLY))
- continue;
-
- if (reply->rp_xid != txdr_unsigned(xid))
- continue;
-
- /* Was RPC accepted? (authorization OK) */
- if (reply->rp_astatus != 0) {
- error = fxdr_unsigned(u_int32_t, reply->rp_errno);
- printf("rpc denied, error=%d\n", error);
- continue;
- }
-
- /* Did the call succeed? */
- if (reply->rp_status != 0) {
- error = fxdr_unsigned(u_int32_t, reply->rp_status);
- if (error == RPC_PROGMISMATCH) {
- error = EBADRPC;
- goto out;
- }
- printf("rpc denied, status=%d\n", error);
- continue;
- }
-
- goto gotreply; /* break two levels */
-
- } /* while secs */
- } /* forever send/receive */
-
- error = ETIMEDOUT;
- goto out;
-
- gotreply:
-
- /*
- * Get RPC reply header into first mbuf,
- * get its length, then strip it off.
- */
- len = sizeof(*reply);
- if (m->m_len < len) {
- m = m_pullup(m, len);
- if (m == NULL) {
- error = ENOBUFS;
- goto out;
- }
- }
- reply = mtod(m, struct rpc_reply *);
- if (reply->rp_auth.authtype != 0) {
- len += fxdr_unsigned(u_int32_t, reply->rp_auth.authlen);
- len = (len + 3) & ~3; /* XXX? */
- }
- m_adj(m, len);
-
- /* result */
- *data = m;
- if (from_p) {
- *from_p = from;
- from = NULL;
- }
-
- out:
- if (mhead) m_freem(mhead);
- if (from) free(from, M_SONAME);
- soclose(so);
- return error;
-}
-
-/*
- * eXternal Data Representation routines.
- * (but with non-standard args...)
- */
-
-/*
- * String representation for RPC.
- */
-struct xdr_string {
- u_int32_t len; /* length without null or padding */
- char data[4]; /* data (longer, of course) */
- /* data is padded to a long-word boundary */
-};
-
-struct mbuf *
-xdr_string_encode(str, len)
- char *str;
- int len;
-{
- struct mbuf *m;
- struct xdr_string *xs;
- int dlen; /* padded string length */
- int mlen; /* message length */
-
- dlen = (len + 3) & ~3;
- mlen = dlen + 4;
-
- if (mlen > MCLBYTES) /* If too big, we just can't do it. */
- return (NULL);
-
- m = m_get(M_WAIT, MT_DATA);
- if (mlen > MLEN) {
- MCLGET(m, M_WAIT);
- if ((m->m_flags & M_EXT) == 0) {
- (void) m_free(m); /* There can be only one. */
- return (NULL);
- }
- }
- xs = mtod(m, struct xdr_string *);
- m->m_len = mlen;
- xs->len = txdr_unsigned(len);
- bcopy(str, xs->data, len);
- return (m);
-}
diff --git a/sys/nfsclient/nfs.h b/sys/nfsclient/nfs.h
deleted file mode 100644
index e07a4f5315d1..000000000000
--- a/sys/nfsclient/nfs.h
+++ /dev/null
@@ -1,727 +0,0 @@
-/*
- * Copyright (c) 1989, 1993, 1995
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Rick Macklem at The University of Guelph.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)nfs.h 8.4 (Berkeley) 5/1/95
- * $FreeBSD$
- */
-
-#ifndef _NFS_NFS_H_
-#define _NFS_NFS_H_
-
-#ifdef _KERNEL
-#include "opt_nfs.h"
-#endif
-
-/*
- * Tunable constants for nfs
- */
-
-#define NFS_MAXIOVEC 34
-#define NFS_TICKINTVL 5 /* Desired time for a tick (msec) */
-#define NFS_HZ (hz / nfs_ticks) /* Ticks/sec */
-#define NFS_TIMEO (1 * NFS_HZ) /* Default timeout = 1 second */
-#define NFS_MINTIMEO (1 * NFS_HZ) /* Min timeout to use */
-#define NFS_MAXTIMEO (60 * NFS_HZ) /* Max timeout to backoff to */
-#define NFS_MINIDEMTIMEO (5 * NFS_HZ) /* Min timeout for non-idempotent ops*/
-#define NFS_MAXREXMIT 100 /* Stop counting after this many */
-#define NFS_MAXWINDOW 1024 /* Max number of outstanding requests */
-#define NFS_RETRANS 10 /* Num of retrans for soft mounts */
-#define NFS_MAXGRPS 16 /* Max. size of groups list */
-#ifndef NFS_MINATTRTIMO
-#define NFS_MINATTRTIMO 3 /* VREG attrib cache timeout in sec */
-#endif
-#ifndef NFS_MAXATTRTIMO
-#define NFS_MAXATTRTIMO 60
-#endif
-#ifndef NFS_MINDIRATTRTIMO
-#define NFS_MINDIRATTRTIMO 30 /* VDIR attrib cache timeout in sec */
-#endif
-#ifndef NFS_MAXDIRATTRTIMO
-#define NFS_MAXDIRATTRTIMO 60
-#endif
-#define NFS_WSIZE 8192 /* Def. write data size <= 8192 */
-#define NFS_RSIZE 8192 /* Def. read data size <= 8192 */
-#define NFS_READDIRSIZE 8192 /* Def. readdir size */
-#define NFS_DEFRAHEAD 1 /* Def. read ahead # blocks */
-#define NFS_MAXRAHEAD 4 /* Max. read ahead # blocks */
-#define NFS_MAXUIDHASH 64 /* Max. # of hashed uid entries/mp */
-#define NFS_MAXASYNCDAEMON 20 /* Max. number async_daemons runnable */
-#define NFS_MAXGATHERDELAY 100 /* Max. write gather delay (msec) */
-#ifndef NFS_GATHERDELAY
-#define NFS_GATHERDELAY 10 /* Default write gather delay (msec) */
-#endif
-#define NFS_DIRBLKSIZ 4096 /* Must be a multiple of DIRBLKSIZ */
-#ifdef _KERNEL
-#define DIRBLKSIZ 512 /* XXX we used to use ufs's DIRBLKSIZ */
-#endif
-
-/*
- * Oddballs
- */
-#define NMOD(a) ((a) % nfs_asyncdaemons)
-#define NFS_CMPFH(n, f, s) \
- ((n)->n_fhsize == (s) && !bcmp((caddr_t)(n)->n_fhp, (caddr_t)(f), (s)))
-#define NFS_ISV3(v) (VFSTONFS((v)->v_mount)->nm_flag & NFSMNT_NFSV3)
-#define NFS_SRVMAXDATA(n) \
- (((n)->nd_flag & ND_NFSV3) ? (((n)->nd_nam2) ? \
- NFS_MAXDGRAMDATA : NFS_MAXDATA) : NFS_V2MAXDATA)
-
-/*
- * XXX
- * The B_INVAFTERWRITE flag should be set to whatever is required by the
- * buffer cache code to say "Invalidate the block after it is written back".
- */
-#define B_INVAFTERWRITE B_NOCACHE
-
-/*
- * The IO_METASYNC flag should be implemented for local file systems.
- * (Until then, it is nothin at all.)
- */
-#ifndef IO_METASYNC
-#define IO_METASYNC 0
-#endif
-
-/*
- * Arguments to mount NFS
- */
-#define NFS_ARGSVERSION 3 /* change when nfs_args changes */
-struct nfs_args {
- int version; /* args structure version number */
- struct sockaddr *addr; /* file server address */
- int addrlen; /* length of address */
- int sotype; /* Socket type */
- int proto; /* and Protocol */
- u_char *fh; /* File handle to be mounted */
- int fhsize; /* Size, in bytes, of fh */
- int flags; /* flags */
- int wsize; /* write size in bytes */
- int rsize; /* read size in bytes */
- int readdirsize; /* readdir size in bytes */
- int timeo; /* initial timeout in .1 secs */
- int retrans; /* times to retry send */
- int maxgrouplist; /* Max. size of group list */
- int readahead; /* # of blocks to readahead */
- int leaseterm; /* Term (sec) of lease */
- int deadthresh; /* Retrans threshold */
- char *hostname; /* server's name */
- int acregmin; /* cache attrs for reg files min time */
- int acregmax; /* cache attrs for reg files max time */
- int acdirmin; /* cache attrs for dirs min time */
- int acdirmax; /* cache attrs for dirs max time */
-};
-
-/*
- * NFS mount option flags
- */
-#define NFSMNT_SOFT 0x00000001 /* soft mount (hard is default) */
-#define NFSMNT_WSIZE 0x00000002 /* set write size */
-#define NFSMNT_RSIZE 0x00000004 /* set read size */
-#define NFSMNT_TIMEO 0x00000008 /* set initial timeout */
-#define NFSMNT_RETRANS 0x00000010 /* set number of request retries */
-#define NFSMNT_MAXGRPS 0x00000020 /* set maximum grouplist size */
-#define NFSMNT_INT 0x00000040 /* allow interrupts on hard mount */
-#define NFSMNT_NOCONN 0x00000080 /* Don't Connect the socket */
-#define NFSMNT_NQNFS 0x00000100 /* Use Nqnfs protocol */
-#define NFSMNT_NFSV3 0x00000200 /* Use NFS Version 3 protocol */
-#define NFSMNT_KERB 0x00000400 /* Use Kerberos authentication */
-#define NFSMNT_DUMBTIMR 0x00000800 /* Don't estimate rtt dynamically */
-#define NFSMNT_LEASETERM 0x00001000 /* set lease term (nqnfs) */
-#define NFSMNT_READAHEAD 0x00002000 /* set read ahead */
-#define NFSMNT_DEADTHRESH 0x00004000 /* set dead server retry thresh */
-#define NFSMNT_RESVPORT 0x00008000 /* Allocate a reserved port */
-#define NFSMNT_RDIRPLUS 0x00010000 /* Use Readdirplus for V3 */
-#define NFSMNT_READDIRSIZE 0x00020000 /* Set readdir size */
-#define NFSMNT_ACREGMIN 0x00040000
-#define NFSMNT_ACREGMAX 0x00080000
-#define NFSMNT_ACDIRMIN 0x00100000
-#define NFSMNT_ACDIRMAX 0x00200000
-
-#define NFSSTA_HASWRITEVERF 0x00040000 /* Has write verifier for V3 */
-#define NFSSTA_GOTPATHCONF 0x00080000 /* Got the V3 pathconf info */
-#define NFSSTA_GOTFSINFO 0x00100000 /* Got the V3 fsinfo */
-#define NFSSTA_MNTD 0x00200000 /* Mnt server for mnt point */
-#define NFSSTA_DISMINPROG 0x00400000 /* Dismount in progress */
-#define NFSSTA_DISMNT 0x00800000 /* Dismounted */
-#define NFSSTA_SNDLOCK 0x01000000 /* Send socket lock */
-#define NFSSTA_WANTSND 0x02000000 /* Want above */
-#define NFSSTA_RCVLOCK 0x04000000 /* Rcv socket lock */
-#define NFSSTA_WANTRCV 0x08000000 /* Want above */
-#define NFSSTA_WAITAUTH 0x10000000 /* Wait for authentication */
-#define NFSSTA_HASAUTH 0x20000000 /* Has authenticator */
-#define NFSSTA_WANTAUTH 0x40000000 /* Wants an authenticator */
-#define NFSSTA_AUTHERR 0x80000000 /* Authentication error */
-
-/*
- * Structures for the nfssvc(2) syscall. Not that anyone but nfsd and mount_nfs
- * should ever try and use it.
- */
-struct nfsd_args {
- int sock; /* Socket to serve */
- caddr_t name; /* Client addr for connection based sockets */
- int namelen; /* Length of name */
-};
-
-struct nfsd_srvargs {
- struct nfsd *nsd_nfsd; /* Pointer to in kernel nfsd struct */
- uid_t nsd_uid; /* Effective uid mapped to cred */
- u_int32_t nsd_haddr; /* Ip address of client */
- struct ucred nsd_cr; /* Cred. uid maps to */
- int nsd_authlen; /* Length of auth string (ret) */
- u_char *nsd_authstr; /* Auth string (ret) */
- int nsd_verflen; /* and the verfier */
- u_char *nsd_verfstr;
- struct timeval nsd_timestamp; /* timestamp from verifier */
- u_int32_t nsd_ttl; /* credential ttl (sec) */
- NFSKERBKEY_T nsd_key; /* Session key */
-};
-
-struct nfsd_cargs {
- char *ncd_dirp; /* Mount dir path */
- uid_t ncd_authuid; /* Effective uid */
- int ncd_authtype; /* Type of authenticator */
- int ncd_authlen; /* Length of authenticator string */
- u_char *ncd_authstr; /* Authenticator string */
- int ncd_verflen; /* and the verifier */
- u_char *ncd_verfstr;
- NFSKERBKEY_T ncd_key; /* Session key */
-};
-
-/*
- * XXX to allow amd to include nfs.h without nfsproto.h
- */
-#ifdef NFS_NPROCS
-/*
- * Stats structure
- */
-struct nfsstats {
- int attrcache_hits;
- int attrcache_misses;
- int lookupcache_hits;
- int lookupcache_misses;
- int direofcache_hits;
- int direofcache_misses;
- int biocache_reads;
- int read_bios;
- int read_physios;
- int biocache_writes;
- int write_bios;
- int write_physios;
- int biocache_readlinks;
- int readlink_bios;
- int biocache_readdirs;
- int readdir_bios;
- int rpccnt[NFS_NPROCS];
- int rpcretries;
- int srvrpccnt[NFS_NPROCS];
- int srvrpc_errs;
- int srv_errs;
- int rpcrequests;
- int rpctimeouts;
- int rpcunexpected;
- int rpcinvalid;
- int srvcache_inproghits;
- int srvcache_idemdonehits;
- int srvcache_nonidemdonehits;
- int srvcache_misses;
- int srvnqnfs_leases;
- int srvnqnfs_maxleases;
- int srvnqnfs_getleases;
- int srvvop_writes;
- int accesscache_hits;
- int accesscache_misses;
-};
-#endif
-
-/*
- * Flags for nfssvc() system call.
- */
-#define NFSSVC_BIOD 0x002
-#define NFSSVC_NFSD 0x004
-#define NFSSVC_ADDSOCK 0x008
-#define NFSSVC_AUTHIN 0x010
-#define NFSSVC_GOTAUTH 0x040
-#define NFSSVC_AUTHINFAIL 0x080
-#define NFSSVC_MNTD 0x100
-
-/*
- * fs.nfs sysctl(3) identifiers
- */
-#define NFS_NFSSTATS 1 /* struct: struct nfsstats */
-#define NFS_NFSPRIVPORT 2 /* int: prohibit nfs to resvports */
-
-#define FS_NFS_NAMES { \
- { 0, 0 }, \
- { "nfsstats", CTLTYPE_STRUCT }, \
- { "nfsprivport", CTLTYPE_INT }, \
-}
-
-#ifdef _KERNEL
-
-#ifdef MALLOC_DECLARE
-MALLOC_DECLARE(M_NFSREQ);
-MALLOC_DECLARE(M_NFSDIROFF);
-MALLOC_DECLARE(M_NFSRVDESC);
-MALLOC_DECLARE(M_NFSUID);
-MALLOC_DECLARE(M_NQLEASE);
-MALLOC_DECLARE(M_NFSD);
-MALLOC_DECLARE(M_NFSBIGFH);
-MALLOC_DECLARE(M_NFSHASH);
-#endif
-
-#ifdef ZONE_INTERRUPT
-extern vm_zone_t nfsmount_zone;
-#endif
-
-extern struct callout_handle nfs_timer_handle;
-
-struct uio; struct buf; struct vattr; struct nameidata; /* XXX */
-
-/*
- * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts.
- * What should be in this set is open to debate, but I believe that since
- * I/O system calls on ufs are never interrupted by signals the set should
- * be minimal. My reasoning is that many current programs that use signals
- * such as SIGALRM will not expect file I/O system calls to be interrupted
- * by them and break.
- */
-#define NFSINT_SIGMASK(set) \
- (SIGISMEMBER(set, SIGINT) || SIGISMEMBER(set, SIGTERM) || \
- SIGISMEMBER(set, SIGHUP) || SIGISMEMBER(set, SIGKILL) || \
- SIGISMEMBER(set, SIGQUIT))
-
-/*
- * Socket errors ignored for connectionless sockets??
- * For now, ignore them all
- */
-#define NFSIGNORE_SOERROR(s, e) \
- ((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \
- ((s) & PR_CONNREQUIRED) == 0)
-
-/*
- * Nfs outstanding request list element
- */
-struct nfsreq {
- TAILQ_ENTRY(nfsreq) r_chain;
- struct mbuf *r_mreq;
- struct mbuf *r_mrep;
- struct mbuf *r_md;
- caddr_t r_dpos;
- struct nfsmount *r_nmp;
- struct vnode *r_vp;
- u_int32_t r_xid;
- int r_flags; /* flags on request, see below */
- int r_retry; /* max retransmission count */
- int r_rexmit; /* current retrans count */
- int r_timer; /* tick counter on reply */
- u_int32_t r_procnum; /* NFS procedure number */
- int r_rtt; /* RTT for rpc */
- struct proc *r_procp; /* Proc that did I/O system call */
-};
-
-/*
- * Queue head for nfsreq's
- */
-extern TAILQ_HEAD(nfs_reqq, nfsreq) nfs_reqq;
-
-/* Flag values for r_flags */
-#define R_TIMING 0x01 /* timing request (in mntp) */
-#define R_SENT 0x02 /* request has been sent */
-#define R_SOFTTERM 0x04 /* soft mnt, too many retries */
-#define R_INTR 0x08 /* intr mnt, signal pending */
-#define R_SOCKERR 0x10 /* Fatal error on socket */
-#define R_TPRINTFMSG 0x20 /* Did a tprintf msg. */
-#define R_MUSTRESEND 0x40 /* Must resend request */
-#define R_GETONEREP 0x80 /* Probe for one reply only */
-
-/*
- * A list of nfssvc_sock structures is maintained with all the sockets
- * that require service by the nfsd.
- * The nfsuid structs hang off of the nfssvc_sock structs in both lru
- * and uid hash lists.
- */
-#ifndef NFS_UIDHASHSIZ
-#define NFS_UIDHASHSIZ 29 /* Tune the size of nfssvc_sock with this */
-#endif
-#define NUIDHASH(sock, uid) \
- (&(sock)->ns_uidhashtbl[(uid) % NFS_UIDHASHSIZ])
-#ifndef NFS_WDELAYHASHSIZ
-#define NFS_WDELAYHASHSIZ 16 /* and with this */
-#endif
-#define NWDELAYHASH(sock, f) \
- (&(sock)->ns_wdelayhashtbl[(*((u_int32_t *)(f))) % NFS_WDELAYHASHSIZ])
-#ifndef NFS_MUIDHASHSIZ
-#define NFS_MUIDHASHSIZ 63 /* Tune the size of nfsmount with this */
-#endif
-#define NMUIDHASH(nmp, uid) \
- (&(nmp)->nm_uidhashtbl[(uid) % NFS_MUIDHASHSIZ])
-#define NFSNOHASH(fhsum) \
- (&nfsnodehashtbl[(fhsum) & nfsnodehash])
-
-/*
- * Network address hash list element
- */
-union nethostaddr {
- u_int32_t had_inetaddr;
- struct sockaddr *had_nam;
-};
-
-struct nfsuid {
- TAILQ_ENTRY(nfsuid) nu_lru; /* LRU chain */
- LIST_ENTRY(nfsuid) nu_hash; /* Hash list */
- int nu_flag; /* Flags */
- union nethostaddr nu_haddr; /* Host addr. for dgram sockets */
- struct ucred nu_cr; /* Cred uid mapped to */
- int nu_expire; /* Expiry time (sec) */
- struct timeval nu_timestamp; /* Kerb. timestamp */
- u_int32_t nu_nickname; /* Nickname on server */
- NFSKERBKEY_T nu_key; /* and session key */
-};
-
-#define nu_inetaddr nu_haddr.had_inetaddr
-#define nu_nam nu_haddr.had_nam
-/* Bits for nu_flag */
-#define NU_INETADDR 0x1
-#define NU_NAM 0x2
-#define NU_NETFAM(u) (((u)->nu_flag & NU_INETADDR) ? AF_INET : AF_ISO)
-
-struct nfsrv_rec {
- STAILQ_ENTRY(nfsrv_rec) nr_link;
- struct sockaddr *nr_address;
- struct mbuf *nr_packet;
-};
-
-struct nfssvc_sock {
- TAILQ_ENTRY(nfssvc_sock) ns_chain; /* List of all nfssvc_sock's */
- TAILQ_HEAD(, nfsuid) ns_uidlruhead;
- struct file *ns_fp;
- struct socket *ns_so;
- struct sockaddr *ns_nam;
- struct mbuf *ns_raw;
- struct mbuf *ns_rawend;
- STAILQ_HEAD(, nfsrv_rec) ns_rec;
- struct mbuf *ns_frag;
- int ns_flag;
- int ns_solock;
- int ns_cc;
- int ns_reclen;
- int ns_numuids;
- u_int32_t ns_sref;
- LIST_HEAD(, nfsrv_descript) ns_tq; /* Write gather lists */
- LIST_HEAD(, nfsuid) ns_uidhashtbl[NFS_UIDHASHSIZ];
- LIST_HEAD(nfsrvw_delayhash, nfsrv_descript) ns_wdelayhashtbl[NFS_WDELAYHASHSIZ];
-};
-
-/* Bits for "ns_flag" */
-#define SLP_VALID 0x01
-#define SLP_DOREC 0x02
-#define SLP_NEEDQ 0x04
-#define SLP_DISCONN 0x08
-#define SLP_GETSTREAM 0x10
-#define SLP_LASTFRAG 0x20
-#define SLP_ALLFLAGS 0xff
-
-extern TAILQ_HEAD(nfssvc_sockhead, nfssvc_sock) nfssvc_sockhead;
-extern int nfssvc_sockhead_flag;
-#define SLP_INIT 0x01
-#define SLP_WANTINIT 0x02
-
-/*
- * One of these structures is allocated for each nfsd.
- */
-struct nfsd {
- TAILQ_ENTRY(nfsd) nfsd_chain; /* List of all nfsd's */
- int nfsd_flag; /* NFSD_ flags */
- struct nfssvc_sock *nfsd_slp; /* Current socket */
- int nfsd_authlen; /* Authenticator len */
- u_char nfsd_authstr[RPCAUTH_MAXSIZ]; /* Authenticator data */
- int nfsd_verflen; /* and the Verifier */
- u_char nfsd_verfstr[RPCVERF_MAXSIZ];
- struct proc *nfsd_procp; /* Proc ptr */
- struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */
-};
-
-/* Bits for "nfsd_flag" */
-#define NFSD_WAITING 0x01
-#define NFSD_REQINPROG 0x02
-#define NFSD_NEEDAUTH 0x04
-#define NFSD_AUTHFAIL 0x08
-
-/*
- * This structure is used by the server for describing each request.
- * Some fields are used only when write request gathering is performed.
- */
-struct nfsrv_descript {
- u_quad_t nd_time; /* Write deadline (usec) */
- off_t nd_off; /* Start byte offset */
- off_t nd_eoff; /* and end byte offset */
- LIST_ENTRY(nfsrv_descript) nd_hash; /* Hash list */
- LIST_ENTRY(nfsrv_descript) nd_tq; /* and timer list */
- LIST_HEAD(,nfsrv_descript) nd_coalesce; /* coalesced writes */
- struct mbuf *nd_mrep; /* Request mbuf list */
- struct mbuf *nd_md; /* Current dissect mbuf */
- struct mbuf *nd_mreq; /* Reply mbuf list */
- struct sockaddr *nd_nam; /* and socket addr */
- struct sockaddr *nd_nam2; /* return socket addr */
- caddr_t nd_dpos; /* Current dissect pos */
- u_int32_t nd_procnum; /* RPC # */
- int nd_stable; /* storage type */
- int nd_flag; /* nd_flag */
- int nd_len; /* Length of this write */
- int nd_repstat; /* Reply status */
- u_int32_t nd_retxid; /* Reply xid */
- u_int32_t nd_duration; /* Lease duration */
- struct timeval nd_starttime; /* Time RPC initiated */
- fhandle_t nd_fh; /* File handle */
- struct ucred nd_cr; /* Credentials */
-};
-
-/* Bits for "nd_flag" */
-#define ND_READ LEASE_READ
-#define ND_WRITE LEASE_WRITE
-#define ND_CHECK 0x04
-#define ND_LEASE (ND_READ | ND_WRITE | ND_CHECK)
-#define ND_NFSV3 0x08
-#define ND_NQNFS 0x10
-#define ND_KERBNICK 0x20
-#define ND_KERBFULL 0x40
-#define ND_KERBAUTH (ND_KERBNICK | ND_KERBFULL)
-
-extern TAILQ_HEAD(nfsd_head, nfsd) nfsd_head;
-extern int nfsd_head_flag;
-#define NFSD_CHECKSLP 0x01
-
-/*
- * These macros compare nfsrv_descript structures.
- */
-#define NFSW_CONTIG(o, n) \
- ((o)->nd_eoff >= (n)->nd_off && \
- !bcmp((caddr_t)&(o)->nd_fh, (caddr_t)&(n)->nd_fh, NFSX_V3FH))
-
-#define NFSW_SAMECRED(o, n) \
- (((o)->nd_flag & ND_KERBAUTH) == ((n)->nd_flag & ND_KERBAUTH) && \
- !bcmp((caddr_t)&(o)->nd_cr, (caddr_t)&(n)->nd_cr, \
- sizeof (struct ucred)))
-
-/*
- * Defines for WebNFS
- */
-
-#define WEBNFS_ESC_CHAR '%'
-#define WEBNFS_SPECCHAR_START 0x80
-
-#define WEBNFS_NATIVE_CHAR 0x80
-/*
- * ..
- * Possibly more here in the future.
- */
-
-/*
- * Macro for converting escape characters in WebNFS pathnames.
- * Should really be in libkern.
- */
-
-#define HEXTOC(c) \
- ((c) >= 'a' ? ((c) - ('a' - 10)) : \
- ((c) >= 'A' ? ((c) - ('A' - 10)) : ((c) - '0')))
-#define HEXSTRTOI(p) \
- ((HEXTOC(p[0]) << 4) + HEXTOC(p[1]))
-
-#ifdef NFS_DEBUG
-
-extern int nfs_debug;
-#define NFS_DEBUG_ASYNCIO 1 /* asynchronous i/o */
-#define NFS_DEBUG_WG 2 /* server write gathering */
-#define NFS_DEBUG_RC 4 /* server request caching */
-
-#define NFS_DPF(cat, args) \
- do { \
- if (nfs_debug & NFS_DEBUG_##cat) printf args; \
- } while (0)
-
-#else
-
-#define NFS_DPF(cat, args)
-
-#endif
-
-u_quad_t nfs_curusec __P((void));
-int nfs_init __P((struct vfsconf *vfsp));
-int nfs_uninit __P((struct vfsconf *vfsp));
-int nfs_reply __P((struct nfsreq *));
-int nfs_getreq __P((struct nfsrv_descript *,struct nfsd *,int));
-int nfs_send __P((struct socket *, struct sockaddr *, struct mbuf *,
- struct nfsreq *));
-int nfs_rephead __P((int, struct nfsrv_descript *, struct nfssvc_sock *,
- int, int, u_quad_t *, struct mbuf **, struct mbuf **,
- caddr_t *));
-int nfs_sndlock __P((struct nfsreq *));
-void nfs_sndunlock __P((struct nfsreq *));
-int nfs_slplock __P((struct nfssvc_sock *, int));
-void nfs_slpunlock __P((struct nfssvc_sock *));
-int nfs_disct __P((struct mbuf **, caddr_t *, int, int, caddr_t *));
-int nfs_vinvalbuf __P((struct vnode *, int, struct ucred *, struct proc *,
- int));
-int nfs_readrpc __P((struct vnode *, struct uio *, struct ucred *));
-int nfs_writerpc __P((struct vnode *, struct uio *, struct ucred *, int *,
- int *));
-int nfs_commit __P((struct vnode *vp, u_quad_t offset, int cnt,
- struct ucred *cred, struct proc *procp));
-int nfs_readdirrpc __P((struct vnode *, struct uio *, struct ucred *));
-int nfs_asyncio __P((struct buf *, struct ucred *, struct proc *));
-int nfs_doio __P((struct buf *, struct ucred *, struct proc *));
-int nfs_readlinkrpc __P((struct vnode *, struct uio *, struct ucred *));
-int nfs_sigintr __P((struct nfsmount *, struct nfsreq *, struct proc *));
-int nfs_readdirplusrpc __P((struct vnode *, struct uio *, struct ucred *));
-int nfsm_disct __P((struct mbuf **, caddr_t *, int, int, caddr_t *));
-void nfsm_srvfattr __P((struct nfsrv_descript *, struct vattr *,
- struct nfs_fattr *));
-void nfsm_srvwcc __P((struct nfsrv_descript *, int, struct vattr *, int,
- struct vattr *, struct mbuf **, char **));
-void nfsm_srvpostopattr __P((struct nfsrv_descript *, int, struct vattr *,
- struct mbuf **, char **));
-int netaddr_match __P((int, union nethostaddr *, struct sockaddr *));
-int nfs_request __P((struct vnode *, struct mbuf *, int, struct proc *,
- struct ucred *, struct mbuf **, struct mbuf **,
- caddr_t *));
-int nfs_loadattrcache __P((struct vnode **, struct mbuf **, caddr_t *,
- struct vattr *));
-int nfs_namei __P((struct nameidata *, fhandle_t *, int,
- struct nfssvc_sock *, struct sockaddr *, struct mbuf **,
- caddr_t *, struct vnode **, struct proc *, int, int));
-void nfsm_adj __P((struct mbuf *, int, int));
-int nfsm_mbuftouio __P((struct mbuf **, struct uio *, int, caddr_t *));
-void nfsrv_initcache __P((void));
-int nfs_getauth __P((struct nfsmount *, struct nfsreq *, struct ucred *,
- char **, int *, char *, int *, NFSKERBKEY_T));
-int nfs_getnickauth __P((struct nfsmount *, struct ucred *, char **,
- int *, char *, int));
-int nfs_savenickauth __P((struct nfsmount *, struct ucred *, int,
- NFSKERBKEY_T, struct mbuf **, char **,
- struct mbuf *));
-int nfs_adv __P((struct mbuf **, caddr_t *, int, int));
-void nfs_nhinit __P((void));
-void nfs_timer __P((void*));
-u_long nfs_hash __P((nfsfh_t *, int));
-int nfsrv_dorec __P((struct nfssvc_sock *, struct nfsd *,
- struct nfsrv_descript **));
-int nfsrv_getcache __P((struct nfsrv_descript *, struct nfssvc_sock *,
- struct mbuf **));
-void nfsrv_updatecache __P((struct nfsrv_descript *, int, struct mbuf *));
-void nfsrv_cleancache __P((void));
-int nfs_connect __P((struct nfsmount *, struct nfsreq *));
-void nfs_disconnect __P((struct nfsmount *));
-void nfs_safedisconnect __P((struct nfsmount *));
-int nfs_getattrcache __P((struct vnode *, struct vattr *));
-int nfsm_strtmbuf __P((struct mbuf **, char **, const char *, long));
-int nfs_bioread __P((struct vnode *, struct uio *, int, struct ucred *));
-int nfsm_uiotombuf __P((struct uio *, struct mbuf **, int, caddr_t *));
-void nfsrv_init __P((int));
-void nfs_clearcommit __P((struct mount *));
-int nfsrv_errmap __P((struct nfsrv_descript *, int));
-void nfsrvw_sort __P((gid_t *, int));
-void nfsrv_setcred __P((struct ucred *, struct ucred *));
-int nfs_writebp __P((struct buf *, int, struct proc *));
-int nfsrv_object_create __P((struct vnode *));
-void nfsrv_wakenfsd __P((struct nfssvc_sock *slp));
-int nfsrv_writegather __P((struct nfsrv_descript **, struct nfssvc_sock *,
- struct proc *, struct mbuf **));
-int nfs_fsinfo __P((struct nfsmount *, struct vnode *, struct ucred *,
- struct proc *p));
-
-int nfsrv3_access __P((struct nfsrv_descript *nfsd,
- struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_commit __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_create __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_fhtovp __P((fhandle_t *, int, struct vnode **, struct ucred *,
- struct nfssvc_sock *, struct sockaddr *, int *,
- int, int));
-int nfsrv_setpublicfs __P((struct mount *, struct netexport *,
- struct export_args *));
-int nfs_ispublicfh __P((fhandle_t *));
-int nfsrv_fsinfo __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_getattr __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_link __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_lookup __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_mkdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_mknod __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_noop __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_null __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_pathconf __P((struct nfsrv_descript *nfsd,
- struct nfssvc_sock *slp, struct proc *procp,
- struct mbuf **mrq));
-int nfsrv_read __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_readdir __P((struct nfsrv_descript *nfsd,
- struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_readdirplus __P((struct nfsrv_descript *nfsd,
- struct nfssvc_sock *slp, struct proc *procp,
- struct mbuf **mrq));
-int nfsrv_readlink __P((struct nfsrv_descript *nfsd,
- struct nfssvc_sock *slp, struct proc *procp,
- struct mbuf **mrq));
-int nfsrv_remove __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_rename __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_rmdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_setattr __P((struct nfsrv_descript *nfsd,
- struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_statfs __P((struct nfsrv_descript *nfsd,
- struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_symlink __P((struct nfsrv_descript *nfsd,
- struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_write __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-void nfsrv_rcv __P((struct socket *so, void *arg, int waitflag));
-void nfsrv_slpderef __P((struct nfssvc_sock *slp));
-#endif /* _KERNEL */
-
-#endif
diff --git a/sys/nfsclient/nfs_bio.c b/sys/nfsclient/nfs_bio.c
deleted file mode 100644
index 4b9dcec8c7ab..000000000000
--- a/sys/nfsclient/nfs_bio.c
+++ /dev/null
@@ -1,1593 +0,0 @@
-/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Rick Macklem at The University of Guelph.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)nfs_bio.c 8.9 (Berkeley) 3/30/95
- * $FreeBSD$
- */
-
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/resourcevar.h>
-#include <sys/signalvar.h>
-#include <sys/proc.h>
-#include <sys/buf.h>
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <sys/kernel.h>
-
-#include <vm/vm.h>
-#include <vm/vm_extern.h>
-#include <vm/vm_page.h>
-#include <vm/vm_object.h>
-#include <vm/vm_pager.h>
-#include <vm/vnode_pager.h>
-
-#include <nfs/rpcv2.h>
-#include <nfs/nfsproto.h>
-#include <nfs/nfs.h>
-#include <nfs/nfsmount.h>
-#include <nfs/nqnfs.h>
-#include <nfs/nfsnode.h>
-
-static struct buf *nfs_getcacheblk __P((struct vnode *vp, daddr_t bn, int size,
- struct proc *p));
-
-extern int nfs_numasync;
-extern int nfs_pbuf_freecnt;
-extern struct nfsstats nfsstats;
-
-/*
- * Vnode op for VM getpages.
- */
-int
-nfs_getpages(ap)
- struct vop_getpages_args /* {
- struct vnode *a_vp;
- vm_page_t *a_m;
- int a_count;
- int a_reqpage;
- vm_ooffset_t a_offset;
- } */ *ap;
-{
- int i, error, nextoff, size, toff, count, npages;
- struct uio uio;
- struct iovec iov;
- vm_offset_t kva;
- struct buf *bp;
- struct vnode *vp;
- struct proc *p;
- struct ucred *cred;
- struct nfsmount *nmp;
- vm_page_t *pages;
-
- vp = ap->a_vp;
- p = curproc; /* XXX */
- cred = curproc->p_ucred; /* XXX */
- nmp = VFSTONFS(vp->v_mount);
- pages = ap->a_m;
- count = ap->a_count;
-
- if (vp->v_object == NULL) {
- printf("nfs_getpages: called with non-merged cache vnode??\n");
- return VM_PAGER_ERROR;
- }
-
- if ((nmp->nm_flag & NFSMNT_NFSV3) != 0 &&
- (nmp->nm_state & NFSSTA_GOTFSINFO) == 0)
- (void)nfs_fsinfo(nmp, vp, cred, p);
-
- npages = btoc(count);
-
- /*
- * If the requested page is partially valid, just return it and
- * allow the pager to zero-out the blanks. Partially valid pages
- * can only occur at the file EOF.
- */
-
- {
- vm_page_t m = pages[ap->a_reqpage];
-
- if (m->valid != 0) {
- /* handled by vm_fault now */
- /* vm_page_zero_invalid(m, TRUE); */
- for (i = 0; i < npages; ++i) {
- if (i != ap->a_reqpage)
- vnode_pager_freepage(pages[i]);
- }
- return(0);
- }
- }
-
- /*
- * We use only the kva address for the buffer, but this is extremely
- * convienient and fast.
- */
- bp = getpbuf(&nfs_pbuf_freecnt);
-
- kva = (vm_offset_t) bp->b_data;
- pmap_qenter(kva, pages, npages);
-
- iov.iov_base = (caddr_t) kva;
- iov.iov_len = count;
- uio.uio_iov = &iov;
- uio.uio_iovcnt = 1;
- uio.uio_offset = IDX_TO_OFF(pages[0]->pindex);
- uio.uio_resid = count;
- uio.uio_segflg = UIO_SYSSPACE;
- uio.uio_rw = UIO_READ;
- uio.uio_procp = p;
-
- error = nfs_readrpc(vp, &uio, cred);
- pmap_qremove(kva, npages);
-
- relpbuf(bp, &nfs_pbuf_freecnt);
-
- if (error && (uio.uio_resid == count)) {
- printf("nfs_getpages: error %d\n", error);
- for (i = 0; i < npages; ++i) {
- if (i != ap->a_reqpage)
- vnode_pager_freepage(pages[i]);
- }
- return VM_PAGER_ERROR;
- }
-
- /*
- * Calculate the number of bytes read and validate only that number
- * of bytes. Note that due to pending writes, size may be 0. This
- * does not mean that the remaining data is invalid!
- */
-
- size = count - uio.uio_resid;
-
- for (i = 0, toff = 0; i < npages; i++, toff = nextoff) {
- vm_page_t m;
- nextoff = toff + PAGE_SIZE;
- m = pages[i];
-
- m->flags &= ~PG_ZERO;
-
- if (nextoff <= size) {
- /*
- * Read operation filled an entire page
- */
- m->valid = VM_PAGE_BITS_ALL;
- vm_page_undirty(m);
- } else if (size > toff) {
- /*
- * Read operation filled a partial page.
- */
- m->valid = 0;
- vm_page_set_validclean(m, 0, size - toff);
- /* handled by vm_fault now */
- /* vm_page_zero_invalid(m, TRUE); */
- }
-
- if (i != ap->a_reqpage) {
- /*
- * Whether or not to leave the page activated is up in
- * the air, but we should put the page on a page queue
- * somewhere (it already is in the object). Result:
- * It appears that emperical results show that
- * deactivating pages is best.
- */
-
- /*
- * Just in case someone was asking for this page we
- * now tell them that it is ok to use.
- */
- if (!error) {
- if (m->flags & PG_WANTED)
- vm_page_activate(m);
- else
- vm_page_deactivate(m);
- vm_page_wakeup(m);
- } else {
- vnode_pager_freepage(m);
- }
- }
- }
- return 0;
-}
-
-/*
- * Vnode op for VM putpages.
- */
-int
-nfs_putpages(ap)
- struct vop_putpages_args /* {
- struct vnode *a_vp;
- vm_page_t *a_m;
- int a_count;
- int a_sync;
- int *a_rtvals;
- vm_ooffset_t a_offset;
- } */ *ap;
-{
- struct uio uio;
- struct iovec iov;
- vm_offset_t kva;
- struct buf *bp;
- int iomode, must_commit, i, error, npages, count;
- off_t offset;
- int *rtvals;
- struct vnode *vp;
- struct proc *p;
- struct ucred *cred;
- struct nfsmount *nmp;
- struct nfsnode *np;
- vm_page_t *pages;
-
- vp = ap->a_vp;
- np = VTONFS(vp);
- p = curproc; /* XXX */
- cred = curproc->p_ucred; /* XXX */
- nmp = VFSTONFS(vp->v_mount);
- pages = ap->a_m;
- count = ap->a_count;
- rtvals = ap->a_rtvals;
- npages = btoc(count);
- offset = IDX_TO_OFF(pages[0]->pindex);
-
- if ((nmp->nm_flag & NFSMNT_NFSV3) != 0 &&
- (nmp->nm_state & NFSSTA_GOTFSINFO) == 0)
- (void)nfs_fsinfo(nmp, vp, cred, p);
-
- for (i = 0; i < npages; i++) {
- rtvals[i] = VM_PAGER_AGAIN;
- }
-
- /*
- * When putting pages, do not extend file past EOF.
- */
-
- if (offset + count > np->n_size) {
- count = np->n_size - offset;
- if (count < 0)
- count = 0;
- }
-
- /*
- * We use only the kva address for the buffer, but this is extremely
- * convienient and fast.
- */
- bp = getpbuf(&nfs_pbuf_freecnt);
-
- kva = (vm_offset_t) bp->b_data;
- pmap_qenter(kva, pages, npages);
-
- iov.iov_base = (caddr_t) kva;
- iov.iov_len = count;
- uio.uio_iov = &iov;
- uio.uio_iovcnt = 1;
- uio.uio_offset = offset;
- uio.uio_resid = count;
- uio.uio_segflg = UIO_SYSSPACE;
- uio.uio_rw = UIO_WRITE;
- uio.uio_procp = p;
-
- if ((ap->a_sync & VM_PAGER_PUT_SYNC) == 0)
- iomode = NFSV3WRITE_UNSTABLE;
- else
- iomode = NFSV3WRITE_FILESYNC;
-
- error = nfs_writerpc(vp, &uio, cred, &iomode, &must_commit);
-
- pmap_qremove(kva, npages);
- relpbuf(bp, &nfs_pbuf_freecnt);
-
- if (!error) {
- int nwritten = round_page(count - uio.uio_resid) / PAGE_SIZE;
- for (i = 0; i < nwritten; i++) {
- rtvals[i] = VM_PAGER_OK;
- vm_page_undirty(pages[i]);
- }
- if (must_commit)
- nfs_clearcommit(vp->v_mount);
- }
- return rtvals[0];
-}
-
-/*
- * Vnode op for read using bio
- */
-int
-nfs_bioread(vp, uio, ioflag, cred)
- register struct vnode *vp;
- register struct uio *uio;
- int ioflag;
- struct ucred *cred;
-{
- register struct nfsnode *np = VTONFS(vp);
- register int biosize, i;
- struct buf *bp = 0, *rabp;
- struct vattr vattr;
- struct proc *p;
- struct nfsmount *nmp = VFSTONFS(vp->v_mount);
- daddr_t lbn, rabn;
- int bcount;
- int seqcount;
- int nra, error = 0, n = 0, on = 0;
-
-#ifdef DIAGNOSTIC
- if (uio->uio_rw != UIO_READ)
- panic("nfs_read mode");
-#endif
- if (uio->uio_resid == 0)
- return (0);
- if (uio->uio_offset < 0) /* XXX VDIR cookies can be negative */
- return (EINVAL);
- p = uio->uio_procp;
-
- if ((nmp->nm_flag & NFSMNT_NFSV3) != 0 &&
- (nmp->nm_state & NFSSTA_GOTFSINFO) == 0)
- (void)nfs_fsinfo(nmp, vp, cred, p);
- if (vp->v_type != VDIR &&
- (uio->uio_offset + uio->uio_resid) > nmp->nm_maxfilesize)
- return (EFBIG);
- biosize = vp->v_mount->mnt_stat.f_iosize;
- seqcount = (int)((off_t)(ioflag >> 16) * biosize / BKVASIZE);
- /*
- * For nfs, cache consistency can only be maintained approximately.
- * Although RFC1094 does not specify the criteria, the following is
- * believed to be compatible with the reference port.
- * For nqnfs, full cache consistency is maintained within the loop.
- * For nfs:
- * If the file's modify time on the server has changed since the
- * last read rpc or you have written to the file,
- * you may have lost data cache consistency with the
- * server, so flush all of the file's data out of the cache.
- * Then force a getattr rpc to ensure that you have up to date
- * attributes.
- * NB: This implies that cache data can be read when up to
- * NFS_ATTRTIMEO seconds out of date. If you find that you need current
- * attributes this could be forced by setting n_attrstamp to 0 before
- * the VOP_GETATTR() call.
- */
- if ((nmp->nm_flag & NFSMNT_NQNFS) == 0) {
- if (np->n_flag & NMODIFIED) {
- if (vp->v_type != VREG) {
- if (vp->v_type != VDIR)
- panic("nfs: bioread, not dir");
- nfs_invaldir(vp);
- error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1);
- if (error)
- return (error);
- }
- np->n_attrstamp = 0;
- error = VOP_GETATTR(vp, &vattr, cred, p);
- if (error)
- return (error);
- np->n_mtime = vattr.va_mtime.tv_sec;
- } else {
- error = VOP_GETATTR(vp, &vattr, cred, p);
- if (error)
- return (error);
- if (np->n_mtime != vattr.va_mtime.tv_sec) {
- if (vp->v_type == VDIR)
- nfs_invaldir(vp);
- error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1);
- if (error)
- return (error);
- np->n_mtime = vattr.va_mtime.tv_sec;
- }
- }
- }
- do {
-
- /*
- * Get a valid lease. If cached data is stale, flush it.
- */
- if (nmp->nm_flag & NFSMNT_NQNFS) {
- if (NQNFS_CKINVALID(vp, np, ND_READ)) {
- do {
- error = nqnfs_getlease(vp, ND_READ, cred, p);
- } while (error == NQNFS_EXPIRED);
- if (error)
- return (error);
- if (np->n_lrev != np->n_brev ||
- (np->n_flag & NQNFSNONCACHE) ||
- ((np->n_flag & NMODIFIED) && vp->v_type == VDIR)) {
- if (vp->v_type == VDIR)
- nfs_invaldir(vp);
- error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1);
- if (error)
- return (error);
- np->n_brev = np->n_lrev;
- }
- } else if (vp->v_type == VDIR && (np->n_flag & NMODIFIED)) {
- nfs_invaldir(vp);
- error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1);
- if (error)
- return (error);
- }
- }
- if (np->n_flag & NQNFSNONCACHE) {
- switch (vp->v_type) {
- case VREG:
- return (nfs_readrpc(vp, uio, cred));
- case VLNK:
- return (nfs_readlinkrpc(vp, uio, cred));
- case VDIR:
- break;
- default:
- printf(" NQNFSNONCACHE: type %x unexpected\n",
- vp->v_type);
- };
- }
- switch (vp->v_type) {
- case VREG:
- nfsstats.biocache_reads++;
- lbn = uio->uio_offset / biosize;
- on = uio->uio_offset & (biosize - 1);
-
- /*
- * Start the read ahead(s), as required.
- */
- if (nfs_numasync > 0 && nmp->nm_readahead > 0) {
- for (nra = 0; nra < nmp->nm_readahead && nra < seqcount &&
- (off_t)(lbn + 1 + nra) * biosize < np->n_size; nra++) {
- rabn = lbn + 1 + nra;
- if (!incore(vp, rabn)) {
- rabp = nfs_getcacheblk(vp, rabn, biosize, p);
- if (!rabp)
- return (EINTR);
- if ((rabp->b_flags & (B_CACHE|B_DELWRI)) == 0) {
- rabp->b_flags |= (B_READ | B_ASYNC);
- vfs_busy_pages(rabp, 0);
- if (nfs_asyncio(rabp, cred, p)) {
- rabp->b_flags |= B_INVAL|B_ERROR;
- vfs_unbusy_pages(rabp);
- brelse(rabp);
- break;
- }
- } else {
- brelse(rabp);
- }
- }
- }
- }
-
- /*
- * Obtain the buffer cache block. Figure out the buffer size
- * when we are at EOF. If we are modifying the size of the
- * buffer based on an EOF condition we need to hold
- * nfs_rslock() through obtaining the buffer to prevent
- * a potential writer-appender from messing with n_size.
- * Otherwise we may accidently truncate the buffer and
- * lose dirty data.
- *
- * Note that bcount is *not* DEV_BSIZE aligned.
- */
-
-again:
- bcount = biosize;
- if ((off_t)lbn * biosize >= np->n_size) {
- bcount = 0;
- } else if ((off_t)(lbn + 1) * biosize > np->n_size) {
- bcount = np->n_size - (off_t)lbn * biosize;
- }
- if (bcount != biosize) {
- switch(nfs_rslock(np, p)) {
- case ENOLCK:
- goto again;
- /* not reached */
- case EINTR:
- case ERESTART:
- return(EINTR);
- /* not reached */
- default:
- break;
- }
- }
-
- bp = nfs_getcacheblk(vp, lbn, bcount, p);
-
- if (bcount != biosize)
- nfs_rsunlock(np, p);
- if (!bp)
- return (EINTR);
-
- /*
- * If B_CACHE is not set, we must issue the read. If this
- * fails, we return an error.
- */
-
- if ((bp->b_flags & B_CACHE) == 0) {
- bp->b_flags |= B_READ;
- vfs_busy_pages(bp, 0);
- error = nfs_doio(bp, cred, p);
- if (error) {
- brelse(bp);
- return (error);
- }
- }
-
- /*
- * on is the offset into the current bp. Figure out how many
- * bytes we can copy out of the bp. Note that bcount is
- * NOT DEV_BSIZE aligned.
- *
- * Then figure out how many bytes we can copy into the uio.
- */
-
- n = 0;
- if (on < bcount)
- n = min((unsigned)(bcount - on), uio->uio_resid);
- break;
- case VLNK:
- nfsstats.biocache_readlinks++;
- bp = nfs_getcacheblk(vp, (daddr_t)0, NFS_MAXPATHLEN, p);
- if (!bp)
- return (EINTR);
- if ((bp->b_flags & B_CACHE) == 0) {
- bp->b_flags |= B_READ;
- vfs_busy_pages(bp, 0);
- error = nfs_doio(bp, cred, p);
- if (error) {
- bp->b_flags |= B_ERROR;
- brelse(bp);
- return (error);
- }
- }
- n = min(uio->uio_resid, NFS_MAXPATHLEN - bp->b_resid);
- on = 0;
- break;
- case VDIR:
- nfsstats.biocache_readdirs++;
- if (np->n_direofoffset
- && uio->uio_offset >= np->n_direofoffset) {
- return (0);
- }
- lbn = (uoff_t)uio->uio_offset / NFS_DIRBLKSIZ;
- on = uio->uio_offset & (NFS_DIRBLKSIZ - 1);
- bp = nfs_getcacheblk(vp, lbn, NFS_DIRBLKSIZ, p);
- if (!bp)
- return (EINTR);
- if ((bp->b_flags & B_CACHE) == 0) {
- bp->b_flags |= B_READ;
- vfs_busy_pages(bp, 0);
- error = nfs_doio(bp, cred, p);
- if (error) {
- brelse(bp);
- }
- while (error == NFSERR_BAD_COOKIE) {
- printf("got bad cookie vp %p bp %p\n", vp, bp);
- nfs_invaldir(vp);
- error = nfs_vinvalbuf(vp, 0, cred, p, 1);
- /*
- * Yuck! The directory has been modified on the
- * server. The only way to get the block is by
- * reading from the beginning to get all the
- * offset cookies.
- *
- * Leave the last bp intact unless there is an error.
- * Loop back up to the while if the error is another
- * NFSERR_BAD_COOKIE (double yuch!).
- */
- for (i = 0; i <= lbn && !error; i++) {
- if (np->n_direofoffset
- && (i * NFS_DIRBLKSIZ) >= np->n_direofoffset)
- return (0);
- bp = nfs_getcacheblk(vp, i, NFS_DIRBLKSIZ, p);
- if (!bp)
- return (EINTR);
- if ((bp->b_flags & B_CACHE) == 0) {
- bp->b_flags |= B_READ;
- vfs_busy_pages(bp, 0);
- error = nfs_doio(bp, cred, p);
- /*
- * no error + B_INVAL == directory EOF,
- * use the block.
- */
- if (error == 0 && (bp->b_flags & B_INVAL))
- break;
- }
- /*
- * An error will throw away the block and the
- * for loop will break out. If no error and this
- * is not the block we want, we throw away the
- * block and go for the next one via the for loop.
- */
- if (error || i < lbn)
- brelse(bp);
- }
- }
- /*
- * The above while is repeated if we hit another cookie
- * error. If we hit an error and it wasn't a cookie error,
- * we give up.
- */
- if (error)
- return (error);
- }
-
- /*
- * If not eof and read aheads are enabled, start one.
- * (You need the current block first, so that you have the
- * directory offset cookie of the next block.)
- */
- if (nfs_numasync > 0 && nmp->nm_readahead > 0 &&
- (bp->b_flags & B_INVAL) == 0 &&
- (np->n_direofoffset == 0 ||
- (lbn + 1) * NFS_DIRBLKSIZ < np->n_direofoffset) &&
- !(np->n_flag & NQNFSNONCACHE) &&
- !incore(vp, lbn + 1)) {
- rabp = nfs_getcacheblk(vp, lbn + 1, NFS_DIRBLKSIZ, p);
- if (rabp) {
- if ((rabp->b_flags & (B_CACHE|B_DELWRI)) == 0) {
- rabp->b_flags |= (B_READ | B_ASYNC);
- vfs_busy_pages(rabp, 0);
- if (nfs_asyncio(rabp, cred, p)) {
- rabp->b_flags |= B_INVAL|B_ERROR;
- vfs_unbusy_pages(rabp);
- brelse(rabp);
- }
- } else {
- brelse(rabp);
- }
- }
- }
- /*
- * Unlike VREG files, whos buffer size ( bp->b_bcount ) is
- * chopped for the EOF condition, we cannot tell how large
- * NFS directories are going to be until we hit EOF. So
- * an NFS directory buffer is *not* chopped to its EOF. Now,
- * it just so happens that b_resid will effectively chop it
- * to EOF. *BUT* this information is lost if the buffer goes
- * away and is reconstituted into a B_CACHE state ( due to
- * being VMIO ) later. So we keep track of the directory eof
- * in np->n_direofoffset and chop it off as an extra step
- * right here.
- */
- n = lmin(uio->uio_resid, NFS_DIRBLKSIZ - bp->b_resid - on);
- if (np->n_direofoffset && n > np->n_direofoffset - uio->uio_offset)
- n = np->n_direofoffset - uio->uio_offset;
- break;
- default:
- printf(" nfs_bioread: type %x unexpected\n",vp->v_type);
- break;
- };
-
- if (n > 0) {
- error = uiomove(bp->b_data + on, (int)n, uio);
- }
- switch (vp->v_type) {
- case VREG:
- break;
- case VLNK:
- n = 0;
- break;
- case VDIR:
- /*
- * Invalidate buffer if caching is disabled, forcing a
- * re-read from the remote later.
- */
- if (np->n_flag & NQNFSNONCACHE)
- bp->b_flags |= B_INVAL;
- break;
- default:
- printf(" nfs_bioread: type %x unexpected\n",vp->v_type);
- }
- brelse(bp);
- } while (error == 0 && uio->uio_resid > 0 && n > 0);
- return (error);
-}
-
-/*
- * Vnode op for write using bio
- */
-int
-nfs_write(ap)
- struct vop_write_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- int a_ioflag;
- struct ucred *a_cred;
- } */ *ap;
-{
- int biosize;
- struct uio *uio = ap->a_uio;
- struct proc *p = uio->uio_procp;
- struct vnode *vp = ap->a_vp;
- struct nfsnode *np = VTONFS(vp);
- struct ucred *cred = ap->a_cred;
- int ioflag = ap->a_ioflag;
- struct buf *bp;
- struct vattr vattr;
- struct nfsmount *nmp = VFSTONFS(vp->v_mount);
- daddr_t lbn;
- int bcount;
- int n, on, error = 0, iomode, must_commit;
- int haverslock = 0;
-
-#ifdef DIAGNOSTIC
- if (uio->uio_rw != UIO_WRITE)
- panic("nfs_write mode");
- if (uio->uio_segflg == UIO_USERSPACE && uio->uio_procp != curproc)
- panic("nfs_write proc");
-#endif
- if (vp->v_type != VREG)
- return (EIO);
- if (np->n_flag & NWRITEERR) {
- np->n_flag &= ~NWRITEERR;
- return (np->n_error);
- }
- if ((nmp->nm_flag & NFSMNT_NFSV3) != 0 &&
- (nmp->nm_state & NFSSTA_GOTFSINFO) == 0)
- (void)nfs_fsinfo(nmp, vp, cred, p);
-
- /*
- * Synchronously flush pending buffers if we are in synchronous
- * mode or if we are appending.
- */
- if (ioflag & (IO_APPEND | IO_SYNC)) {
- if (np->n_flag & NMODIFIED) {
- np->n_attrstamp = 0;
- error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1);
- if (error)
- return (error);
- }
- }
-
- /*
- * If IO_APPEND then load uio_offset. We restart here if we cannot
- * get the append lock.
- */
-restart:
- if (ioflag & IO_APPEND) {
- np->n_attrstamp = 0;
- error = VOP_GETATTR(vp, &vattr, cred, p);
- if (error)
- return (error);
- uio->uio_offset = np->n_size;
- }
-
- if (uio->uio_offset < 0)
- return (EINVAL);
- if ((uio->uio_offset + uio->uio_resid) > nmp->nm_maxfilesize)
- return (EFBIG);
- if (uio->uio_resid == 0)
- return (0);
-
- /*
- * We need to obtain the rslock if we intend to modify np->n_size
- * in order to guarentee the append point with multiple contending
- * writers, to guarentee that no other appenders modify n_size
- * while we are trying to obtain a truncated buffer (i.e. to avoid
- * accidently truncating data written by another appender due to
- * the race), and to ensure that the buffer is populated prior to
- * our extending of the file. We hold rslock through the entire
- * operation.
- *
- * Note that we do not synchronize the case where someone truncates
- * the file while we are appending to it because attempting to lock
- * this case may deadlock other parts of the system unexpectedly.
- */
- if ((ioflag & IO_APPEND) ||
- uio->uio_offset + uio->uio_resid > np->n_size) {
- switch(nfs_rslock(np, p)) {
- case ENOLCK:
- goto restart;
- /* not reached */
- case EINTR:
- case ERESTART:
- return(EINTR);
- /* not reached */
- default:
- break;
- }
- haverslock = 1;
- }
-
- /*
- * Maybe this should be above the vnode op call, but so long as
- * file servers have no limits, i don't think it matters
- */
- if (p && uio->uio_offset + uio->uio_resid >
- p->p_rlimit[RLIMIT_FSIZE].rlim_cur) {
- psignal(p, SIGXFSZ);
- if (haverslock)
- nfs_rsunlock(np, p);
- return (EFBIG);
- }
-
- biosize = vp->v_mount->mnt_stat.f_iosize;
-
- do {
- /*
- * Check for a valid write lease.
- */
- if ((nmp->nm_flag & NFSMNT_NQNFS) &&
- NQNFS_CKINVALID(vp, np, ND_WRITE)) {
- do {
- error = nqnfs_getlease(vp, ND_WRITE, cred, p);
- } while (error == NQNFS_EXPIRED);
- if (error)
- break;
- if (np->n_lrev != np->n_brev ||
- (np->n_flag & NQNFSNONCACHE)) {
- error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1);
- if (error)
- break;
- np->n_brev = np->n_lrev;
- }
- }
- if ((np->n_flag & NQNFSNONCACHE) && uio->uio_iovcnt == 1) {
- iomode = NFSV3WRITE_FILESYNC;
- error = nfs_writerpc(vp, uio, cred, &iomode, &must_commit);
- if (must_commit)
- nfs_clearcommit(vp->v_mount);
- break;
- }
- nfsstats.biocache_writes++;
- lbn = uio->uio_offset / biosize;
- on = uio->uio_offset & (biosize-1);
- n = min((unsigned)(biosize - on), uio->uio_resid);
-again:
- /*
- * Handle direct append and file extension cases, calculate
- * unaligned buffer size.
- */
-
- if (uio->uio_offset == np->n_size && n) {
- /*
- * Get the buffer (in its pre-append state to maintain
- * B_CACHE if it was previously set). Resize the
- * nfsnode after we have locked the buffer to prevent
- * readers from reading garbage.
- */
- bcount = on;
- bp = nfs_getcacheblk(vp, lbn, bcount, p);
-
- if (bp != NULL) {
- long save;
-
- np->n_size = uio->uio_offset + n;
- np->n_flag |= NMODIFIED;
- vnode_pager_setsize(vp, np->n_size);
-
- save = bp->b_flags & B_CACHE;
- bcount += n;
- allocbuf(bp, bcount);
- bp->b_flags |= save;
- }
- } else {
- /*
- * Obtain the locked cache block first, and then
- * adjust the file's size as appropriate.
- */
- bcount = on + n;
- if ((off_t)lbn * biosize + bcount < np->n_size) {
- if ((off_t)(lbn + 1) * biosize < np->n_size)
- bcount = biosize;
- else
- bcount = np->n_size - (off_t)lbn * biosize;
- }
-
- bp = nfs_getcacheblk(vp, lbn, bcount, p);
-
- if (uio->uio_offset + n > np->n_size) {
- np->n_size = uio->uio_offset + n;
- np->n_flag |= NMODIFIED;
- vnode_pager_setsize(vp, np->n_size);
- }
- }
-
- if (!bp) {
- error = EINTR;
- break;
- }
-
- /*
- * Issue a READ if B_CACHE is not set. In special-append
- * mode, B_CACHE is based on the buffer prior to the write
- * op and is typically set, avoiding the read. If a read
- * is required in special append mode, the server will
- * probably send us a short-read since we extended the file
- * on our end, resulting in b_resid == 0 and, thusly,
- * B_CACHE getting set.
- *
- * We can also avoid issuing the read if the write covers
- * the entire buffer. We have to make sure the buffer state
- * is reasonable in this case since we will not be initiating
- * I/O. See the comments in kern/vfs_bio.c's getblk() for
- * more information.
- *
- * B_CACHE may also be set due to the buffer being cached
- * normally.
- */
-
- if (on == 0 && n == bcount) {
- bp->b_flags |= B_CACHE;
- bp->b_flags &= ~(B_ERROR | B_INVAL);
- }
-
- if ((bp->b_flags & B_CACHE) == 0) {
- bp->b_flags |= B_READ;
- vfs_busy_pages(bp, 0);
- error = nfs_doio(bp, cred, p);
- if (error) {
- brelse(bp);
- break;
- }
- }
- if (!bp) {
- error = EINTR;
- break;
- }
- if (bp->b_wcred == NOCRED) {
- crhold(cred);
- bp->b_wcred = cred;
- }
- np->n_flag |= NMODIFIED;
-
- /*
- * If dirtyend exceeds file size, chop it down. This should
- * not normally occur but there is an append race where it
- * might occur XXX, so we log it.
- *
- * If the chopping creates a reverse-indexed or degenerate
- * situation with dirtyoff/end, we 0 both of them.
- */
-
- if (bp->b_dirtyend > bcount) {
- printf("NFS append race @%lx:%d\n",
- (long)bp->b_blkno * DEV_BSIZE,
- bp->b_dirtyend - bcount);
- bp->b_dirtyend = bcount;
- }
-
- if (bp->b_dirtyoff >= bp->b_dirtyend)
- bp->b_dirtyoff = bp->b_dirtyend = 0;
-
- /*
- * If the new write will leave a contiguous dirty
- * area, just update the b_dirtyoff and b_dirtyend,
- * otherwise force a write rpc of the old dirty area.
- *
- * While it is possible to merge discontiguous writes due to
- * our having a B_CACHE buffer ( and thus valid read data
- * for the hole), we don't because it could lead to
- * significant cache coherency problems with multiple clients,
- * especially if locking is implemented later on.
- *
- * as an optimization we could theoretically maintain
- * a linked list of discontinuous areas, but we would still
- * have to commit them separately so there isn't much
- * advantage to it except perhaps a bit of asynchronization.
- */
-
- if (bp->b_dirtyend > 0 &&
- (on > bp->b_dirtyend || (on + n) < bp->b_dirtyoff)) {
- if (VOP_BWRITE(bp->b_vp, bp) == EINTR)
- return (EINTR);
- goto again;
- }
-
- /*
- * Check for valid write lease and get one as required.
- * In case getblk() and/or bwrite() delayed us.
- */
- if ((nmp->nm_flag & NFSMNT_NQNFS) &&
- NQNFS_CKINVALID(vp, np, ND_WRITE)) {
- do {
- error = nqnfs_getlease(vp, ND_WRITE, cred, p);
- } while (error == NQNFS_EXPIRED);
- if (error) {
- brelse(bp);
- break;
- }
- if (np->n_lrev != np->n_brev ||
- (np->n_flag & NQNFSNONCACHE)) {
- brelse(bp);
- error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1);
- if (error)
- break;
- np->n_brev = np->n_lrev;
- goto again;
- }
- }
-
- error = uiomove((char *)bp->b_data + on, n, uio);
-
- /*
- * Since this block is being modified, it must be written
- * again and not just committed. Since write clustering does
- * not work for the stage 1 data write, only the stage 2
- * commit rpc, we have to clear B_CLUSTEROK as well.
- */
- bp->b_flags &= ~(B_NEEDCOMMIT | B_CLUSTEROK);
-
- if (error) {
- bp->b_flags |= B_ERROR;
- brelse(bp);
- break;
- }
-
- /*
- * Only update dirtyoff/dirtyend if not a degenerate
- * condition.
- */
- if (n) {
- if (bp->b_dirtyend > 0) {
- bp->b_dirtyoff = min(on, bp->b_dirtyoff);
- bp->b_dirtyend = max((on + n), bp->b_dirtyend);
- } else {
- bp->b_dirtyoff = on;
- bp->b_dirtyend = on + n;
- }
- vfs_bio_set_validclean(bp, on, n);
- }
-
- /*
- * If the lease is non-cachable or IO_SYNC do bwrite().
- *
- * IO_INVAL appears to be unused. The idea appears to be
- * to turn off caching in this case. Very odd. XXX
- */
- if ((np->n_flag & NQNFSNONCACHE) || (ioflag & IO_SYNC)) {
- if (ioflag & IO_INVAL)
- bp->b_flags |= B_NOCACHE;
- error = VOP_BWRITE(bp->b_vp, bp);
- if (error)
- break;
- if (np->n_flag & NQNFSNONCACHE) {
- error = nfs_vinvalbuf(vp, V_SAVE, cred, p, 1);
- if (error)
- break;
- }
- } else if ((n + on) == biosize &&
- (nmp->nm_flag & NFSMNT_NQNFS) == 0) {
- bp->b_flags |= B_ASYNC;
- (void)nfs_writebp(bp, 0, 0);
- } else {
- bdwrite(bp);
- }
- } while (uio->uio_resid > 0 && n > 0);
-
- if (haverslock)
- nfs_rsunlock(np, p);
-
- return (error);
-}
-
-/*
- * Get an nfs cache block.
- *
- * Allocate a new one if the block isn't currently in the cache
- * and return the block marked busy. If the calling process is
- * interrupted by a signal for an interruptible mount point, return
- * NULL.
- *
- * The caller must carefully deal with the possible B_INVAL state of
- * the buffer. nfs_doio() clears B_INVAL (and nfs_asyncio() clears it
- * indirectly), so synchronous reads can be issued without worrying about
- * the B_INVAL state. We have to be a little more careful when dealing
- * with writes (see comments in nfs_write()) when extending a file past
- * its EOF.
- */
-static struct buf *
-nfs_getcacheblk(vp, bn, size, p)
- struct vnode *vp;
- daddr_t bn;
- int size;
- struct proc *p;
-{
- register struct buf *bp;
- struct mount *mp;
- struct nfsmount *nmp;
-
- mp = vp->v_mount;
- nmp = VFSTONFS(mp);
-
- if (nmp->nm_flag & NFSMNT_INT) {
- bp = getblk(vp, bn, size, PCATCH, 0);
- while (bp == (struct buf *)0) {
- if (nfs_sigintr(nmp, (struct nfsreq *)0, p))
- return ((struct buf *)0);
- bp = getblk(vp, bn, size, 0, 2 * hz);
- }
- } else {
- bp = getblk(vp, bn, size, 0, 0);
- }
-
- if (vp->v_type == VREG) {
- int biosize;
-
- biosize = mp->mnt_stat.f_iosize;
- bp->b_blkno = bn * (biosize / DEV_BSIZE);
- }
- return (bp);
-}
-
-/*
- * Flush and invalidate all dirty buffers. If another process is already
- * doing the flush, just wait for completion.
- */
-int
-nfs_vinvalbuf(vp, flags, cred, p, intrflg)
- struct vnode *vp;
- int flags;
- struct ucred *cred;
- struct proc *p;
- int intrflg;
-{
- register struct nfsnode *np = VTONFS(vp);
- struct nfsmount *nmp = VFSTONFS(vp->v_mount);
- int error = 0, slpflag, slptimeo;
-
- if (vp->v_flag & VXLOCK) {
- return (0);
- }
-
- if ((nmp->nm_flag & NFSMNT_INT) == 0)
- intrflg = 0;
- if (intrflg) {
- slpflag = PCATCH;
- slptimeo = 2 * hz;
- } else {
- slpflag = 0;
- slptimeo = 0;
- }
- /*
- * First wait for any other process doing a flush to complete.
- */
- while (np->n_flag & NFLUSHINPROG) {
- np->n_flag |= NFLUSHWANT;
- error = tsleep((caddr_t)&np->n_flag, PRIBIO + 2, "nfsvinval",
- slptimeo);
- if (error && intrflg && nfs_sigintr(nmp, (struct nfsreq *)0, p))
- return (EINTR);
- }
-
- /*
- * Now, flush as required.
- */
- np->n_flag |= NFLUSHINPROG;
- error = vinvalbuf(vp, flags, cred, p, slpflag, 0);
- while (error) {
- if (intrflg && nfs_sigintr(nmp, (struct nfsreq *)0, p)) {
- np->n_flag &= ~NFLUSHINPROG;
- if (np->n_flag & NFLUSHWANT) {
- np->n_flag &= ~NFLUSHWANT;
- wakeup((caddr_t)&np->n_flag);
- }
- return (EINTR);
- }
- error = vinvalbuf(vp, flags, cred, p, 0, slptimeo);
- }
- np->n_flag &= ~(NMODIFIED | NFLUSHINPROG);
- if (np->n_flag & NFLUSHWANT) {
- np->n_flag &= ~NFLUSHWANT;
- wakeup((caddr_t)&np->n_flag);
- }
- return (0);
-}
-
-/*
- * Initiate asynchronous I/O. Return an error if no nfsiods are available.
- * This is mainly to avoid queueing async I/O requests when the nfsiods
- * are all hung on a dead server.
- *
- * Note: nfs_asyncio() does not clear (B_ERROR|B_INVAL) but when the bp
- * is eventually dequeued by the async daemon, nfs_doio() *will*.
- */
-int
-nfs_asyncio(bp, cred, procp)
- register struct buf *bp;
- struct ucred *cred;
- struct proc *procp;
-{
- struct nfsmount *nmp;
- int i;
- int gotiod;
- int slpflag = 0;
- int slptimeo = 0;
- int error;
-
- /*
- * If no async daemons then return EIO to force caller to run the rpc
- * synchronously.
- */
- if (nfs_numasync == 0)
- return (EIO);
-
- nmp = VFSTONFS(bp->b_vp->v_mount);
-
- /*
- * Commits are usually short and sweet so lets save some cpu and
- * leave the async daemons for more important rpc's (such as reads
- * and writes).
- */
- if ((bp->b_flags & (B_READ|B_NEEDCOMMIT)) == B_NEEDCOMMIT &&
- (nmp->nm_bufqiods > nfs_numasync / 2)) {
- return(EIO);
- }
-
-again:
- if (nmp->nm_flag & NFSMNT_INT)
- slpflag = PCATCH;
- gotiod = FALSE;
-
- /*
- * Find a free iod to process this request.
- */
- for (i = 0; i < NFS_MAXASYNCDAEMON; i++)
- if (nfs_iodwant[i]) {
- /*
- * Found one, so wake it up and tell it which
- * mount to process.
- */
- NFS_DPF(ASYNCIO,
- ("nfs_asyncio: waking iod %d for mount %p\n",
- i, nmp));
- nfs_iodwant[i] = (struct proc *)0;
- nfs_iodmount[i] = nmp;
- nmp->nm_bufqiods++;
- wakeup((caddr_t)&nfs_iodwant[i]);
- gotiod = TRUE;
- break;
- }
-
- /*
- * If none are free, we may already have an iod working on this mount
- * point. If so, it will process our request.
- */
- if (!gotiod) {
- if (nmp->nm_bufqiods > 0) {
- NFS_DPF(ASYNCIO,
- ("nfs_asyncio: %d iods are already processing mount %p\n",
- nmp->nm_bufqiods, nmp));
- gotiod = TRUE;
- }
- }
-
- /*
- * If we have an iod which can process the request, then queue
- * the buffer.
- */
- if (gotiod) {
- /*
- * Ensure that the queue never grows too large. We still want
- * to asynchronize so we block rather then return EIO.
- */
- while (nmp->nm_bufqlen >= 2*nfs_numasync) {
- NFS_DPF(ASYNCIO,
- ("nfs_asyncio: waiting for mount %p queue to drain\n", nmp));
- nmp->nm_bufqwant = TRUE;
- error = tsleep(&nmp->nm_bufq, slpflag | PRIBIO,
- "nfsaio", slptimeo);
- if (error) {
- if (nfs_sigintr(nmp, NULL, procp))
- return (EINTR);
- if (slpflag == PCATCH) {
- slpflag = 0;
- slptimeo = 2 * hz;
- }
- }
- /*
- * We might have lost our iod while sleeping,
- * so check and loop if nescessary.
- */
- if (nmp->nm_bufqiods == 0) {
- NFS_DPF(ASYNCIO,
- ("nfs_asyncio: no iods after mount %p queue was drained, looping\n", nmp));
- goto again;
- }
- }
-
- if (bp->b_flags & B_READ) {
- if (bp->b_rcred == NOCRED && cred != NOCRED) {
- crhold(cred);
- bp->b_rcred = cred;
- }
- } else {
- bp->b_flags |= B_WRITEINPROG;
- if (bp->b_wcred == NOCRED && cred != NOCRED) {
- crhold(cred);
- bp->b_wcred = cred;
- }
- }
-
- BUF_KERNPROC(bp);
- TAILQ_INSERT_TAIL(&nmp->nm_bufq, bp, b_freelist);
- nmp->nm_bufqlen++;
- return (0);
- }
-
- /*
- * All the iods are busy on other mounts, so return EIO to
- * force the caller to process the i/o synchronously.
- */
- NFS_DPF(ASYNCIO, ("nfs_asyncio: no iods available, i/o is synchronous\n"));
- return (EIO);
-}
-
-/*
- * Do an I/O operation to/from a cache block. This may be called
- * synchronously or from an nfsiod.
- */
-int
-nfs_doio(bp, cr, p)
- struct buf *bp;
- struct ucred *cr;
- struct proc *p;
-{
- struct uio *uiop;
- struct vnode *vp;
- struct nfsnode *np;
- struct nfsmount *nmp;
- int error = 0, iomode, must_commit = 0;
- struct uio uio;
- struct iovec io;
-
- vp = bp->b_vp;
- np = VTONFS(vp);
- nmp = VFSTONFS(vp->v_mount);
- uiop = &uio;
- uiop->uio_iov = &io;
- uiop->uio_iovcnt = 1;
- uiop->uio_segflg = UIO_SYSSPACE;
- uiop->uio_procp = p;
-
- /*
- * clear B_ERROR and B_INVAL state prior to initiating the I/O. We
- * do this here so we do not have to do it in all the code that
- * calls us.
- */
- bp->b_flags &= ~(B_ERROR | B_INVAL);
-
- KASSERT(!(bp->b_flags & B_DONE), ("nfs_doio: bp %p already marked done", bp));
-
- /*
- * Historically, paging was done with physio, but no more.
- */
- if (bp->b_flags & B_PHYS) {
- /*
- * ...though reading /dev/drum still gets us here.
- */
- io.iov_len = uiop->uio_resid = bp->b_bcount;
- /* mapping was done by vmapbuf() */
- io.iov_base = bp->b_data;
- uiop->uio_offset = ((off_t)bp->b_blkno) * DEV_BSIZE;
- if (bp->b_flags & B_READ) {
- uiop->uio_rw = UIO_READ;
- nfsstats.read_physios++;
- error = nfs_readrpc(vp, uiop, cr);
- } else {
- int com;
-
- iomode = NFSV3WRITE_DATASYNC;
- uiop->uio_rw = UIO_WRITE;
- nfsstats.write_physios++;
- error = nfs_writerpc(vp, uiop, cr, &iomode, &com);
- }
- if (error) {
- bp->b_flags |= B_ERROR;
- bp->b_error = error;
- }
- } else if (bp->b_flags & B_READ) {
- io.iov_len = uiop->uio_resid = bp->b_bcount;
- io.iov_base = bp->b_data;
- uiop->uio_rw = UIO_READ;
- switch (vp->v_type) {
- case VREG:
- uiop->uio_offset = ((off_t)bp->b_blkno) * DEV_BSIZE;
- nfsstats.read_bios++;
- error = nfs_readrpc(vp, uiop, cr);
- if (!error) {
- if (uiop->uio_resid) {
- /*
- * If we had a short read with no error, we must have
- * hit a file hole. We should zero-fill the remainder.
- * This can also occur if the server hits the file EOF.
- *
- * Holes used to be able to occur due to pending
- * writes, but that is not possible any longer.
- */
- int nread = bp->b_bcount - uiop->uio_resid;
- int left = bp->b_bcount - nread;
-
- if (left > 0)
- bzero((char *)bp->b_data + nread, left);
- uiop->uio_resid = 0;
- }
- }
- if (p && (vp->v_flag & VTEXT) &&
- (((nmp->nm_flag & NFSMNT_NQNFS) &&
- NQNFS_CKINVALID(vp, np, ND_READ) &&
- np->n_lrev != np->n_brev) ||
- (!(nmp->nm_flag & NFSMNT_NQNFS) &&
- np->n_mtime != np->n_vattr.va_mtime.tv_sec))) {
- uprintf("Process killed due to text file modification\n");
- psignal(p, SIGKILL);
- PHOLD(p);
- }
- break;
- case VLNK:
- uiop->uio_offset = (off_t)0;
- nfsstats.readlink_bios++;
- error = nfs_readlinkrpc(vp, uiop, cr);
- break;
- case VDIR:
- nfsstats.readdir_bios++;
- uiop->uio_offset = ((u_quad_t)bp->b_lblkno) * NFS_DIRBLKSIZ;
- if (nmp->nm_flag & NFSMNT_RDIRPLUS) {
- error = nfs_readdirplusrpc(vp, uiop, cr);
- if (error == NFSERR_NOTSUPP)
- nmp->nm_flag &= ~NFSMNT_RDIRPLUS;
- }
- if ((nmp->nm_flag & NFSMNT_RDIRPLUS) == 0)
- error = nfs_readdirrpc(vp, uiop, cr);
- /*
- * end-of-directory sets B_INVAL but does not generate an
- * error.
- */
- if (error == 0 && uiop->uio_resid == bp->b_bcount)
- bp->b_flags |= B_INVAL;
- break;
- default:
- printf("nfs_doio: type %x unexpected\n",vp->v_type);
- break;
- };
- if (error) {
- bp->b_flags |= B_ERROR;
- bp->b_error = error;
- }
- } else {
- /*
- * If we only need to commit, try to commit
- */
- if (bp->b_flags & B_NEEDCOMMIT) {
- int retv;
- off_t off;
-
- off = ((u_quad_t)bp->b_blkno) * DEV_BSIZE + bp->b_dirtyoff;
- bp->b_flags |= B_WRITEINPROG;
- retv = nfs_commit(
- bp->b_vp, off, bp->b_dirtyend-bp->b_dirtyoff,
- bp->b_wcred, p);
- bp->b_flags &= ~B_WRITEINPROG;
- if (retv == 0) {
- bp->b_dirtyoff = bp->b_dirtyend = 0;
- bp->b_flags &= ~(B_NEEDCOMMIT | B_CLUSTEROK);
- bp->b_resid = 0;
- biodone(bp);
- return (0);
- }
- if (retv == NFSERR_STALEWRITEVERF) {
- nfs_clearcommit(bp->b_vp->v_mount);
- }
- }
-
- /*
- * Setup for actual write
- */
-
- if ((off_t)bp->b_blkno * DEV_BSIZE + bp->b_dirtyend > np->n_size)
- bp->b_dirtyend = np->n_size - (off_t)bp->b_blkno * DEV_BSIZE;
-
- if (bp->b_dirtyend > bp->b_dirtyoff) {
- io.iov_len = uiop->uio_resid = bp->b_dirtyend
- - bp->b_dirtyoff;
- uiop->uio_offset = (off_t)bp->b_blkno * DEV_BSIZE
- + bp->b_dirtyoff;
- io.iov_base = (char *)bp->b_data + bp->b_dirtyoff;
- uiop->uio_rw = UIO_WRITE;
- nfsstats.write_bios++;
-
- if ((bp->b_flags & (B_ASYNC | B_NEEDCOMMIT | B_NOCACHE | B_CLUSTER)) == B_ASYNC)
- iomode = NFSV3WRITE_UNSTABLE;
- else
- iomode = NFSV3WRITE_FILESYNC;
-
- bp->b_flags |= B_WRITEINPROG;
- error = nfs_writerpc(vp, uiop, cr, &iomode, &must_commit);
-
- /*
- * When setting B_NEEDCOMMIT also set B_CLUSTEROK to try
- * to cluster the buffers needing commit. This will allow
- * the system to submit a single commit rpc for the whole
- * cluster. We can do this even if the buffer is not 100%
- * dirty (relative to the NFS blocksize), so we optimize the
- * append-to-file-case.
- *
- * (when clearing B_NEEDCOMMIT, B_CLUSTEROK must also be
- * cleared because write clustering only works for commit
- * rpc's, not for the data portion of the write).
- */
-
- if (!error && iomode == NFSV3WRITE_UNSTABLE) {
- bp->b_flags |= B_NEEDCOMMIT;
- if (bp->b_dirtyoff == 0
- && bp->b_dirtyend == bp->b_bcount)
- bp->b_flags |= B_CLUSTEROK;
- } else {
- bp->b_flags &= ~(B_NEEDCOMMIT | B_CLUSTEROK);
- }
- bp->b_flags &= ~B_WRITEINPROG;
-
- /*
- * For an interrupted write, the buffer is still valid
- * and the write hasn't been pushed to the server yet,
- * so we can't set B_ERROR and report the interruption
- * by setting B_EINTR. For the B_ASYNC case, B_EINTR
- * is not relevant, so the rpc attempt is essentially
- * a noop. For the case of a V3 write rpc not being
- * committed to stable storage, the block is still
- * dirty and requires either a commit rpc or another
- * write rpc with iomode == NFSV3WRITE_FILESYNC before
- * the block is reused. This is indicated by setting
- * the B_DELWRI and B_NEEDCOMMIT flags.
- *
- * If the buffer is marked B_PAGING, it does not reside on
- * the vp's paging queues so we cannot call bdirty(). The
- * bp in this case is not an NFS cache block so we should
- * be safe. XXX
- */
- if (error == EINTR
- || (!error && (bp->b_flags & B_NEEDCOMMIT))) {
- int s;
-
- s = splbio();
- bp->b_flags &= ~(B_INVAL|B_NOCACHE);
- if ((bp->b_flags & B_PAGING) == 0) {
- bdirty(bp);
- bp->b_flags &= ~B_DONE;
- }
- if (error && (bp->b_flags & B_ASYNC) == 0)
- bp->b_flags |= B_EINTR;
- splx(s);
- } else {
- if (error) {
- bp->b_flags |= B_ERROR;
- bp->b_error = np->n_error = error;
- np->n_flag |= NWRITEERR;
- }
- bp->b_dirtyoff = bp->b_dirtyend = 0;
- }
- } else {
- bp->b_resid = 0;
- biodone(bp);
- return (0);
- }
- }
- bp->b_resid = uiop->uio_resid;
- if (must_commit)
- nfs_clearcommit(vp->v_mount);
- biodone(bp);
- return (error);
-}
diff --git a/sys/nfsclient/nfs_nfsiod.c b/sys/nfsclient/nfs_nfsiod.c
deleted file mode 100644
index 14ff8d1f0145..000000000000
--- a/sys/nfsclient/nfs_nfsiod.c
+++ /dev/null
@@ -1,1187 +0,0 @@
-/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Rick Macklem at The University of Guelph.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)nfs_syscalls.c 8.5 (Berkeley) 3/30/95
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/sysproto.h>
-#include <sys/kernel.h>
-#include <sys/sysctl.h>
-#include <sys/file.h>
-#include <sys/filedesc.h>
-#include <sys/vnode.h>
-#include <sys/malloc.h>
-#include <sys/mount.h>
-#include <sys/proc.h>
-#include <sys/buf.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-#include <sys/domain.h>
-#include <sys/protosw.h>
-#include <sys/namei.h>
-#include <vm/vm_zone.h>
-
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-#include <nfs/xdr_subs.h>
-#include <nfs/rpcv2.h>
-#include <nfs/nfsproto.h>
-#include <nfs/nfs.h>
-#include <nfs/nfsm_subs.h>
-#include <nfs/nfsrvcache.h>
-#include <nfs/nfsmount.h>
-#include <nfs/nfsnode.h>
-#include <nfs/nqnfs.h>
-#include <nfs/nfsrtt.h>
-
-static MALLOC_DEFINE(M_NFSSVC, "NFS srvsock", "Nfs server structure");
-
-/* Global defs. */
-extern int32_t (*nfsrv3_procs[NFS_NPROCS]) __P((struct nfsrv_descript *nd,
- struct nfssvc_sock *slp,
- struct proc *procp,
- struct mbuf **mreqp));
-extern int nfs_numasync;
-extern time_t nqnfsstarttime;
-extern int nqsrv_writeslack;
-extern int nfsrtton;
-extern struct nfsstats nfsstats;
-extern int nfsrvw_procrastinate;
-extern int nfsrvw_procrastinate_v3;
-static int nuidhash_max = NFS_MAXUIDHASH;
-
-#ifndef NFS_NOSERVER
-static void nfsrv_zapsock __P((struct nfssvc_sock *slp));
-#endif
-static int nfssvc_iod __P((struct proc *));
-
-#define TRUE 1
-#define FALSE 0
-
-static int nfs_asyncdaemon[NFS_MAXASYNCDAEMON];
-
-SYSCTL_DECL(_vfs_nfs);
-
-#ifndef NFS_NOSERVER
-int nfsd_waiting = 0;
-static struct nfsdrt nfsdrt;
-static int nfs_numnfsd = 0;
-static int notstarted = 1;
-static int modify_flag = 0;
-static void nfsd_rt __P((int sotype, struct nfsrv_descript *nd,
- int cacherep));
-static int nfssvc_addsock __P((struct file *, struct sockaddr *,
- struct proc *));
-static int nfssvc_nfsd __P((struct nfsd_srvargs *,caddr_t,struct proc *));
-
-static int nfs_privport = 0;
-SYSCTL_INT(_vfs_nfs, NFS_NFSPRIVPORT, nfs_privport, CTLFLAG_RW, &nfs_privport, 0, "");
-SYSCTL_INT(_vfs_nfs, OID_AUTO, gatherdelay, CTLFLAG_RW, &nfsrvw_procrastinate, 0, "");
-SYSCTL_INT(_vfs_nfs, OID_AUTO, gatherdelay_v3, CTLFLAG_RW, &nfsrvw_procrastinate_v3, 0, "");
-
-/*
- * NFS server system calls
- */
-
-#endif /* NFS_NOSERVER */
-/*
- * Nfs server psuedo system call for the nfsd's
- * Based on the flag value it either:
- * - adds a socket to the selection list
- * - remains in the kernel as an nfsd
- * - remains in the kernel as an nfsiod
- */
-#ifndef _SYS_SYSPROTO_H_
-struct nfssvc_args {
- int flag;
- caddr_t argp;
-};
-#endif
-int
-nfssvc(p, uap)
- struct proc *p;
- register struct nfssvc_args *uap;
-{
-#ifndef NFS_NOSERVER
- struct nameidata nd;
- struct file *fp;
- struct sockaddr *nam;
- struct nfsd_args nfsdarg;
- struct nfsd_srvargs nfsd_srvargs, *nsd = &nfsd_srvargs;
- struct nfsd_cargs ncd;
- struct nfsd *nfsd;
- struct nfssvc_sock *slp;
- struct nfsuid *nuidp;
- struct nfsmount *nmp;
-#endif /* NFS_NOSERVER */
- int error;
-
- /*
- * Must be super user
- */
- error = suser(p);
- if(error)
- return (error);
- while (nfssvc_sockhead_flag & SLP_INIT) {
- nfssvc_sockhead_flag |= SLP_WANTINIT;
- (void) tsleep((caddr_t)&nfssvc_sockhead, PSOCK, "nfsd init", 0);
- }
- if (uap->flag & NFSSVC_BIOD)
- error = nfssvc_iod(p);
-#ifdef NFS_NOSERVER
- else
- error = ENXIO;
-#else /* !NFS_NOSERVER */
- else if (uap->flag & NFSSVC_MNTD) {
- error = copyin(uap->argp, (caddr_t)&ncd, sizeof (ncd));
- if (error)
- return (error);
- NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE,
- ncd.ncd_dirp, p);
- error = namei(&nd);
- if (error)
- return (error);
- NDFREE(&nd, NDF_ONLY_PNBUF);
- if ((nd.ni_vp->v_flag & VROOT) == 0)
- error = EINVAL;
- nmp = VFSTONFS(nd.ni_vp->v_mount);
- vput(nd.ni_vp);
- if (error)
- return (error);
- if ((nmp->nm_state & NFSSTA_MNTD) &&
- (uap->flag & NFSSVC_GOTAUTH) == 0)
- return (0);
- nmp->nm_state |= NFSSTA_MNTD;
- error = nqnfs_clientd(nmp, p->p_ucred, &ncd, uap->flag,
- uap->argp, p);
- } else if (uap->flag & NFSSVC_ADDSOCK) {
- error = copyin(uap->argp, (caddr_t)&nfsdarg, sizeof(nfsdarg));
- if (error)
- return (error);
- error = getsock(p->p_fd, nfsdarg.sock, &fp);
- if (error)
- return (error);
- /*
- * Get the client address for connected sockets.
- */
- if (nfsdarg.name == NULL || nfsdarg.namelen == 0)
- nam = (struct sockaddr *)0;
- else {
- error = getsockaddr(&nam, nfsdarg.name,
- nfsdarg.namelen);
- if (error)
- return (error);
- }
- error = nfssvc_addsock(fp, nam, p);
- } else {
- error = copyin(uap->argp, (caddr_t)nsd, sizeof (*nsd));
- if (error)
- return (error);
- if ((uap->flag & NFSSVC_AUTHIN) &&
- ((nfsd = nsd->nsd_nfsd)) != NULL &&
- (nfsd->nfsd_slp->ns_flag & SLP_VALID)) {
- slp = nfsd->nfsd_slp;
-
- /*
- * First check to see if another nfsd has already
- * added this credential.
- */
- for (nuidp = NUIDHASH(slp,nsd->nsd_cr.cr_uid)->lh_first;
- nuidp != 0; nuidp = nuidp->nu_hash.le_next) {
- if (nuidp->nu_cr.cr_uid == nsd->nsd_cr.cr_uid &&
- (!nfsd->nfsd_nd->nd_nam2 ||
- netaddr_match(NU_NETFAM(nuidp),
- &nuidp->nu_haddr, nfsd->nfsd_nd->nd_nam2)))
- break;
- }
- if (nuidp) {
- nfsrv_setcred(&nuidp->nu_cr,&nfsd->nfsd_nd->nd_cr);
- nfsd->nfsd_nd->nd_flag |= ND_KERBFULL;
- } else {
- /*
- * Nope, so we will.
- */
- if (slp->ns_numuids < nuidhash_max) {
- slp->ns_numuids++;
- nuidp = (struct nfsuid *)
- malloc(sizeof (struct nfsuid), M_NFSUID,
- M_WAITOK);
- } else
- nuidp = (struct nfsuid *)0;
- if ((slp->ns_flag & SLP_VALID) == 0) {
- if (nuidp)
- free((caddr_t)nuidp, M_NFSUID);
- } else {
- if (nuidp == (struct nfsuid *)0) {
- nuidp = slp->ns_uidlruhead.tqh_first;
- LIST_REMOVE(nuidp, nu_hash);
- TAILQ_REMOVE(&slp->ns_uidlruhead, nuidp,
- nu_lru);
- if (nuidp->nu_flag & NU_NAM)
- FREE(nuidp->nu_nam, M_SONAME);
- }
- nuidp->nu_flag = 0;
- nuidp->nu_cr = nsd->nsd_cr;
- if (nuidp->nu_cr.cr_ngroups > NGROUPS)
- nuidp->nu_cr.cr_ngroups = NGROUPS;
- nuidp->nu_cr.cr_ref = 1;
- nuidp->nu_timestamp = nsd->nsd_timestamp;
- nuidp->nu_expire = time_second + nsd->nsd_ttl;
- /*
- * and save the session key in nu_key.
- */
- bcopy(nsd->nsd_key, nuidp->nu_key,
- sizeof (nsd->nsd_key));
- if (nfsd->nfsd_nd->nd_nam2) {
- struct sockaddr_in *saddr;
-
- saddr = (struct sockaddr_in *)
- nfsd->nfsd_nd->nd_nam2;
- switch (saddr->sin_family) {
- case AF_INET:
- nuidp->nu_flag |= NU_INETADDR;
- nuidp->nu_inetaddr =
- saddr->sin_addr.s_addr;
- break;
- case AF_ISO:
- default:
- nuidp->nu_flag |= NU_NAM;
- nuidp->nu_nam =
- dup_sockaddr(nfsd->nfsd_nd->
- nd_nam2, 1);
- break;
- };
- }
- TAILQ_INSERT_TAIL(&slp->ns_uidlruhead, nuidp,
- nu_lru);
- LIST_INSERT_HEAD(NUIDHASH(slp, nsd->nsd_uid),
- nuidp, nu_hash);
- nfsrv_setcred(&nuidp->nu_cr,
- &nfsd->nfsd_nd->nd_cr);
- nfsd->nfsd_nd->nd_flag |= ND_KERBFULL;
- }
- }
- }
- if ((uap->flag & NFSSVC_AUTHINFAIL) && (nfsd = nsd->nsd_nfsd))
- nfsd->nfsd_flag |= NFSD_AUTHFAIL;
- error = nfssvc_nfsd(nsd, uap->argp, p);
- }
-#endif /* NFS_NOSERVER */
- if (error == EINTR || error == ERESTART)
- error = 0;
- return (error);
-}
-
-#ifndef NFS_NOSERVER
-/*
- * Adds a socket to the list for servicing by nfsds.
- */
-static int
-nfssvc_addsock(fp, mynam, p)
- struct file *fp;
- struct sockaddr *mynam;
- struct proc *p;
-{
- register int siz;
- register struct nfssvc_sock *slp;
- register struct socket *so;
- int error, s;
-
- so = (struct socket *)fp->f_data;
-#if 0
- tslp = (struct nfssvc_sock *)0;
- /*
- * Add it to the list, as required.
- */
- if (so->so_proto->pr_protocol == IPPROTO_UDP) {
- tslp = nfs_udpsock;
- if (tslp->ns_flag & SLP_VALID) {
- if (mynam != NULL)
- FREE(mynam, M_SONAME);
- return (EPERM);
- }
- }
-#endif
- if (so->so_type == SOCK_STREAM)
- siz = NFS_MAXPACKET + sizeof (u_long);
- else
- siz = NFS_MAXPACKET;
- error = soreserve(so, siz, siz);
- if (error) {
- if (mynam != NULL)
- FREE(mynam, M_SONAME);
- return (error);
- }
-
- /*
- * Set protocol specific options { for now TCP only } and
- * reserve some space. For datagram sockets, this can get called
- * repeatedly for the same socket, but that isn't harmful.
- */
- if (so->so_type == SOCK_STREAM) {
- struct sockopt sopt;
- int val;
-
- bzero(&sopt, sizeof sopt);
- sopt.sopt_level = SOL_SOCKET;
- sopt.sopt_name = SO_KEEPALIVE;
- sopt.sopt_val = &val;
- sopt.sopt_valsize = sizeof val;
- val = 1;
- sosetopt(so, &sopt);
- }
- if (so->so_proto->pr_domain->dom_family == AF_INET &&
- so->so_proto->pr_protocol == IPPROTO_TCP) {
- struct sockopt sopt;
- int val;
-
- bzero(&sopt, sizeof sopt);
- sopt.sopt_level = IPPROTO_TCP;
- sopt.sopt_name = TCP_NODELAY;
- sopt.sopt_val = &val;
- sopt.sopt_valsize = sizeof val;
- val = 1;
- sosetopt(so, &sopt);
- }
- so->so_rcv.sb_flags &= ~SB_NOINTR;
- so->so_rcv.sb_timeo = 0;
- so->so_snd.sb_flags &= ~SB_NOINTR;
- so->so_snd.sb_timeo = 0;
-
- slp = (struct nfssvc_sock *)
- malloc(sizeof (struct nfssvc_sock), M_NFSSVC, M_WAITOK);
- bzero((caddr_t)slp, sizeof (struct nfssvc_sock));
- STAILQ_INIT(&slp->ns_rec);
- TAILQ_INIT(&slp->ns_uidlruhead);
- TAILQ_INSERT_TAIL(&nfssvc_sockhead, slp, ns_chain);
-
- slp->ns_so = so;
- slp->ns_nam = mynam;
- fp->f_count++;
- slp->ns_fp = fp;
- s = splnet();
- so->so_upcallarg = (caddr_t)slp;
- so->so_upcall = nfsrv_rcv;
- so->so_rcv.sb_flags |= SB_UPCALL;
- slp->ns_flag = (SLP_VALID | SLP_NEEDQ);
- nfsrv_wakenfsd(slp);
- splx(s);
- return (0);
-}
-
-/*
- * Called by nfssvc() for nfsds. Just loops around servicing rpc requests
- * until it is killed by a signal.
- */
-static int
-nfssvc_nfsd(nsd, argp, p)
- struct nfsd_srvargs *nsd;
- caddr_t argp;
- struct proc *p;
-{
- register int siz;
- register struct nfssvc_sock *slp;
- struct nfsd *nfsd = nsd->nsd_nfsd;
- struct nfsrv_descript *nd = NULL;
- struct mbuf *m, *mreq;
- int error = 0, cacherep, s, sotype, writes_todo;
- int procrastinate;
- u_quad_t cur_usec;
-
-#ifndef nolint
- cacherep = RC_DOIT;
- writes_todo = 0;
-#endif
- if (nfsd == (struct nfsd *)0) {
- nsd->nsd_nfsd = nfsd = (struct nfsd *)
- malloc(sizeof (struct nfsd), M_NFSD, M_WAITOK);
- bzero((caddr_t)nfsd, sizeof (struct nfsd));
- s = splnet();
- nfsd->nfsd_procp = p;
- TAILQ_INSERT_TAIL(&nfsd_head, nfsd, nfsd_chain);
- nfs_numnfsd++;
- } else
- s = splnet();
-
- /*
- * Loop getting rpc requests until SIGKILL.
- */
- for (;;) {
- if ((nfsd->nfsd_flag & NFSD_REQINPROG) == 0) {
- while (nfsd->nfsd_slp == (struct nfssvc_sock *)0 &&
- (nfsd_head_flag & NFSD_CHECKSLP) == 0) {
- nfsd->nfsd_flag |= NFSD_WAITING;
- nfsd_waiting++;
- error = tsleep((caddr_t)nfsd, PSOCK | PCATCH,
- "nfsd", 0);
- nfsd_waiting--;
- if (error)
- goto done;
- }
- if (nfsd->nfsd_slp == (struct nfssvc_sock *)0 &&
- (nfsd_head_flag & NFSD_CHECKSLP) != 0) {
- for (slp = nfssvc_sockhead.tqh_first; slp != 0;
- slp = slp->ns_chain.tqe_next) {
- if ((slp->ns_flag & (SLP_VALID | SLP_DOREC))
- == (SLP_VALID | SLP_DOREC)) {
- slp->ns_flag &= ~SLP_DOREC;
- slp->ns_sref++;
- nfsd->nfsd_slp = slp;
- break;
- }
- }
- if (slp == 0)
- nfsd_head_flag &= ~NFSD_CHECKSLP;
- }
- if ((slp = nfsd->nfsd_slp) == (struct nfssvc_sock *)0)
- continue;
- if (slp->ns_flag & SLP_VALID) {
- if (slp->ns_flag & SLP_DISCONN)
- nfsrv_zapsock(slp);
- else if (slp->ns_flag & SLP_NEEDQ) {
- slp->ns_flag &= ~SLP_NEEDQ;
- (void) nfs_slplock(slp, 1);
- nfsrv_rcv(slp->ns_so, (caddr_t)slp,
- M_WAIT);
- nfs_slpunlock(slp);
- }
- error = nfsrv_dorec(slp, nfsd, &nd);
- cur_usec = nfs_curusec();
- if (error && slp->ns_tq.lh_first &&
- slp->ns_tq.lh_first->nd_time <= cur_usec) {
- error = 0;
- cacherep = RC_DOIT;
- writes_todo = 1;
- } else
- writes_todo = 0;
- nfsd->nfsd_flag |= NFSD_REQINPROG;
- }
- } else {
- error = 0;
- slp = nfsd->nfsd_slp;
- }
- if (error || (slp->ns_flag & SLP_VALID) == 0) {
- if (nd) {
- free((caddr_t)nd, M_NFSRVDESC);
- nd = NULL;
- }
- nfsd->nfsd_slp = (struct nfssvc_sock *)0;
- nfsd->nfsd_flag &= ~NFSD_REQINPROG;
- nfsrv_slpderef(slp);
- continue;
- }
- splx(s);
- sotype = slp->ns_so->so_type;
- if (nd) {
- getmicrotime(&nd->nd_starttime);
- if (nd->nd_nam2)
- nd->nd_nam = nd->nd_nam2;
- else
- nd->nd_nam = slp->ns_nam;
-
- /*
- * Check to see if authorization is needed.
- */
- if (nfsd->nfsd_flag & NFSD_NEEDAUTH) {
- nfsd->nfsd_flag &= ~NFSD_NEEDAUTH;
- nsd->nsd_haddr =
- ((struct sockaddr_in *)
- nd->nd_nam)->sin_addr.s_addr;
- nsd->nsd_authlen = nfsd->nfsd_authlen;
- nsd->nsd_verflen = nfsd->nfsd_verflen;
- if (!copyout(nfsd->nfsd_authstr,nsd->nsd_authstr,
- nfsd->nfsd_authlen) &&
- !copyout(nfsd->nfsd_verfstr, nsd->nsd_verfstr,
- nfsd->nfsd_verflen) &&
- !copyout((caddr_t)nsd, argp, sizeof (*nsd)))
- return (ENEEDAUTH);
- cacherep = RC_DROPIT;
- } else
- cacherep = nfsrv_getcache(nd, slp, &mreq);
-
- /*
- * Check for just starting up for NQNFS and send
- * fake "try again later" replies to the NQNFS clients.
- */
- if (notstarted && nqnfsstarttime <= time_second) {
- if (modify_flag) {
- nqnfsstarttime = time_second + nqsrv_writeslack;
- modify_flag = 0;
- } else
- notstarted = 0;
- }
- if (notstarted) {
- if ((nd->nd_flag & ND_NQNFS) == 0)
- cacherep = RC_DROPIT;
- else if (nd->nd_procnum != NFSPROC_WRITE) {
- nd->nd_procnum = NFSPROC_NOOP;
- nd->nd_repstat = NQNFS_TRYLATER;
- cacherep = RC_DOIT;
- } else
- modify_flag = 1;
- } else if (nfsd->nfsd_flag & NFSD_AUTHFAIL) {
- nfsd->nfsd_flag &= ~NFSD_AUTHFAIL;
- nd->nd_procnum = NFSPROC_NOOP;
- nd->nd_repstat = (NFSERR_AUTHERR | AUTH_TOOWEAK);
- cacherep = RC_DOIT;
- } else if (nfs_privport) {
- /* Check if source port is privileged */
- u_short port;
- struct sockaddr *nam = nd->nd_nam;
- struct sockaddr_in *sin;
-
- sin = (struct sockaddr_in *)nam;
- port = ntohs(sin->sin_port);
- if (port >= IPPORT_RESERVED &&
- nd->nd_procnum != NFSPROC_NULL) {
- nd->nd_procnum = NFSPROC_NOOP;
- nd->nd_repstat = (NFSERR_AUTHERR | AUTH_TOOWEAK);
- cacherep = RC_DOIT;
- printf("NFS request from unprivileged port (%s:%d)\n",
- inet_ntoa(sin->sin_addr), port);
- }
- }
-
- }
-
- /*
- * Loop to get all the write rpc relies that have been
- * gathered together.
- */
- do {
- switch (cacherep) {
- case RC_DOIT:
- if (nd && (nd->nd_flag & ND_NFSV3))
- procrastinate = nfsrvw_procrastinate_v3;
- else
- procrastinate = nfsrvw_procrastinate;
- if (writes_todo || (nd->nd_procnum == NFSPROC_WRITE &&
- procrastinate > 0 && !notstarted))
- error = nfsrv_writegather(&nd, slp,
- nfsd->nfsd_procp, &mreq);
- else
- error = (*(nfsrv3_procs[nd->nd_procnum]))(nd,
- slp, nfsd->nfsd_procp, &mreq);
- if (mreq == NULL)
- break;
- if (error != 0 && error != NFSERR_RETVOID) {
- if (nd->nd_procnum != NQNFSPROC_VACATED)
- nfsstats.srv_errs++;
- nfsrv_updatecache(nd, FALSE, mreq);
- if (nd->nd_nam2)
- FREE(nd->nd_nam2, M_SONAME);
- break;
- }
- nfsstats.srvrpccnt[nd->nd_procnum]++;
- nfsrv_updatecache(nd, TRUE, mreq);
- nd->nd_mrep = (struct mbuf *)0;
- case RC_REPLY:
- m = mreq;
- siz = 0;
- while (m) {
- siz += m->m_len;
- m = m->m_next;
- }
- if (siz <= 0 || siz > NFS_MAXPACKET) {
- printf("mbuf siz=%d\n",siz);
- panic("Bad nfs svc reply");
- }
- m = mreq;
- m->m_pkthdr.len = siz;
- m->m_pkthdr.rcvif = (struct ifnet *)0;
- /*
- * For stream protocols, prepend a Sun RPC
- * Record Mark.
- */
- if (sotype == SOCK_STREAM) {
- M_PREPEND(m, NFSX_UNSIGNED, M_WAIT);
- *mtod(m, u_int32_t *) = htonl(0x80000000 | siz);
- }
- if (slp->ns_so->so_proto->pr_flags & PR_CONNREQUIRED)
- (void) nfs_slplock(slp, 1);
- if (slp->ns_flag & SLP_VALID)
- error = nfs_send(slp->ns_so, nd->nd_nam2, m, NULL);
- else {
- error = EPIPE;
- m_freem(m);
- }
- if (nfsrtton)
- nfsd_rt(sotype, nd, cacherep);
- if (nd->nd_nam2)
- FREE(nd->nd_nam2, M_SONAME);
- if (nd->nd_mrep)
- m_freem(nd->nd_mrep);
- if (error == EPIPE)
- nfsrv_zapsock(slp);
- if (slp->ns_so->so_proto->pr_flags & PR_CONNREQUIRED)
- nfs_slpunlock(slp);
- if (error == EINTR || error == ERESTART) {
- free((caddr_t)nd, M_NFSRVDESC);
- nfsrv_slpderef(slp);
- s = splnet();
- goto done;
- }
- break;
- case RC_DROPIT:
- if (nfsrtton)
- nfsd_rt(sotype, nd, cacherep);
- m_freem(nd->nd_mrep);
- if (nd->nd_nam2)
- FREE(nd->nd_nam2, M_SONAME);
- break;
- };
- if (nd) {
- FREE((caddr_t)nd, M_NFSRVDESC);
- nd = NULL;
- }
-
- /*
- * Check to see if there are outstanding writes that
- * need to be serviced.
- */
- cur_usec = nfs_curusec();
- s = splsoftclock();
- if (slp->ns_tq.lh_first &&
- slp->ns_tq.lh_first->nd_time <= cur_usec) {
- cacherep = RC_DOIT;
- writes_todo = 1;
- } else
- writes_todo = 0;
- splx(s);
- } while (writes_todo);
- s = splnet();
- if (nfsrv_dorec(slp, nfsd, &nd)) {
- nfsd->nfsd_flag &= ~NFSD_REQINPROG;
- nfsd->nfsd_slp = NULL;
- nfsrv_slpderef(slp);
- }
- }
-done:
- TAILQ_REMOVE(&nfsd_head, nfsd, nfsd_chain);
- splx(s);
- free((caddr_t)nfsd, M_NFSD);
- nsd->nsd_nfsd = (struct nfsd *)0;
- if (--nfs_numnfsd == 0)
- nfsrv_init(TRUE); /* Reinitialize everything */
- return (error);
-}
-
-/*
- * Shut down a socket associated with an nfssvc_sock structure.
- * Should be called with the send lock set, if required.
- * The trick here is to increment the sref at the start, so that the nfsds
- * will stop using it and clear ns_flag at the end so that it will not be
- * reassigned during cleanup.
- */
-static void
-nfsrv_zapsock(slp)
- register struct nfssvc_sock *slp;
-{
- register struct nfsuid *nuidp, *nnuidp;
- register struct nfsrv_descript *nwp, *nnwp;
- struct socket *so;
- struct file *fp;
- struct nfsrv_rec *rec;
- int s;
-
- slp->ns_flag &= ~SLP_ALLFLAGS;
- fp = slp->ns_fp;
- if (fp) {
- slp->ns_fp = (struct file *)0;
- so = slp->ns_so;
- so->so_rcv.sb_flags &= ~SB_UPCALL;
- so->so_upcall = NULL;
- so->so_upcallarg = NULL;
- soshutdown(so, 2);
- closef(fp, (struct proc *)0);
- if (slp->ns_nam)
- FREE(slp->ns_nam, M_SONAME);
- m_freem(slp->ns_raw);
- while ((rec = STAILQ_FIRST(&slp->ns_rec)) != NULL) {
- STAILQ_REMOVE_HEAD(&slp->ns_rec, nr_link);
- if (rec->nr_address)
- FREE(rec->nr_address, M_SONAME);
- m_freem(rec->nr_packet);
- free(rec, M_NFSRVDESC);
- }
- for (nuidp = slp->ns_uidlruhead.tqh_first; nuidp != 0;
- nuidp = nnuidp) {
- nnuidp = nuidp->nu_lru.tqe_next;
- LIST_REMOVE(nuidp, nu_hash);
- TAILQ_REMOVE(&slp->ns_uidlruhead, nuidp, nu_lru);
- if (nuidp->nu_flag & NU_NAM)
- FREE(nuidp->nu_nam, M_SONAME);
- free((caddr_t)nuidp, M_NFSUID);
- }
- s = splsoftclock();
- for (nwp = slp->ns_tq.lh_first; nwp; nwp = nnwp) {
- nnwp = nwp->nd_tq.le_next;
- LIST_REMOVE(nwp, nd_tq);
- free((caddr_t)nwp, M_NFSRVDESC);
- }
- LIST_INIT(&slp->ns_tq);
- splx(s);
- }
-}
-
-/*
- * Derefence a server socket structure. If it has no more references and
- * is no longer valid, you can throw it away.
- */
-void
-nfsrv_slpderef(slp)
- register struct nfssvc_sock *slp;
-{
- if (--(slp->ns_sref) == 0 && (slp->ns_flag & SLP_VALID) == 0) {
- TAILQ_REMOVE(&nfssvc_sockhead, slp, ns_chain);
- free((caddr_t)slp, M_NFSSVC);
- }
-}
-
-/*
- * Lock a socket against others.
- */
-int
-nfs_slplock(slp, wait)
- register struct nfssvc_sock *slp;
- int wait;
-{
- int *statep = &slp->ns_solock;
-
- if (!wait && (*statep & NFSSTA_SNDLOCK))
- return(0); /* already locked, fail */
- while (*statep & NFSSTA_SNDLOCK) {
- *statep |= NFSSTA_WANTSND;
- (void) tsleep((caddr_t)statep, PZERO - 1, "nfsslplck", 0);
- }
- *statep |= NFSSTA_SNDLOCK;
- return (1);
-}
-
-/*
- * Unlock the stream socket for others.
- */
-void
-nfs_slpunlock(slp)
- register struct nfssvc_sock *slp;
-{
- int *statep = &slp->ns_solock;
-
- if ((*statep & NFSSTA_SNDLOCK) == 0)
- panic("nfs slpunlock");
- *statep &= ~NFSSTA_SNDLOCK;
- if (*statep & NFSSTA_WANTSND) {
- *statep &= ~NFSSTA_WANTSND;
- wakeup((caddr_t)statep);
- }
-}
-
-/*
- * Initialize the data structures for the server.
- * Handshake with any new nfsds starting up to avoid any chance of
- * corruption.
- */
-void
-nfsrv_init(terminating)
- int terminating;
-{
- register struct nfssvc_sock *slp, *nslp;
-
- if (nfssvc_sockhead_flag & SLP_INIT)
- panic("nfsd init");
- nfssvc_sockhead_flag |= SLP_INIT;
- if (terminating) {
- for (slp = nfssvc_sockhead.tqh_first; slp != 0; slp = nslp) {
- nslp = slp->ns_chain.tqe_next;
- if (slp->ns_flag & SLP_VALID)
- nfsrv_zapsock(slp);
- TAILQ_REMOVE(&nfssvc_sockhead, slp, ns_chain);
- free((caddr_t)slp, M_NFSSVC);
- }
- nfsrv_cleancache(); /* And clear out server cache */
- } else
- nfs_pub.np_valid = 0;
-
- TAILQ_INIT(&nfssvc_sockhead);
- nfssvc_sockhead_flag &= ~SLP_INIT;
- if (nfssvc_sockhead_flag & SLP_WANTINIT) {
- nfssvc_sockhead_flag &= ~SLP_WANTINIT;
- wakeup((caddr_t)&nfssvc_sockhead);
- }
-
- TAILQ_INIT(&nfsd_head);
- nfsd_head_flag &= ~NFSD_CHECKSLP;
-
-#if 0
- nfs_udpsock = (struct nfssvc_sock *)
- malloc(sizeof (struct nfssvc_sock), M_NFSSVC, M_WAITOK);
- bzero((caddr_t)nfs_udpsock, sizeof (struct nfssvc_sock));
- STAILQ_INIT(&nfs_udpsock->ns_rec);
- TAILQ_INIT(&nfs_udpsock->ns_uidlruhead);
- TAILQ_INSERT_HEAD(&nfssvc_sockhead, nfs_udpsock, ns_chain);
-
- nfs_cltpsock = (struct nfssvc_sock *)
- malloc(sizeof (struct nfssvc_sock), M_NFSSVC, M_WAITOK);
- bzero((caddr_t)nfs_cltpsock, sizeof (struct nfssvc_sock));
- STAILQ_INIT(&nfs_cltpsock->ns_rec);
- TAILQ_INIT(&nfs_cltpsock->ns_uidlruhead);
- TAILQ_INSERT_TAIL(&nfssvc_sockhead, nfs_cltpsock, ns_chain);
-#endif
-}
-
-/*
- * Add entries to the server monitor log.
- */
-static void
-nfsd_rt(sotype, nd, cacherep)
- int sotype;
- register struct nfsrv_descript *nd;
- int cacherep;
-{
- register struct drt *rt;
-
- rt = &nfsdrt.drt[nfsdrt.pos];
- if (cacherep == RC_DOIT)
- rt->flag = 0;
- else if (cacherep == RC_REPLY)
- rt->flag = DRT_CACHEREPLY;
- else
- rt->flag = DRT_CACHEDROP;
- if (sotype == SOCK_STREAM)
- rt->flag |= DRT_TCP;
- if (nd->nd_flag & ND_NQNFS)
- rt->flag |= DRT_NQNFS;
- else if (nd->nd_flag & ND_NFSV3)
- rt->flag |= DRT_NFSV3;
- rt->proc = nd->nd_procnum;
- if (nd->nd_nam->sa_family == AF_INET)
- rt->ipadr = ((struct sockaddr_in *)nd->nd_nam)->sin_addr.s_addr;
- else
- rt->ipadr = INADDR_ANY;
- rt->resptime = nfs_curusec() - (nd->nd_starttime.tv_sec * 1000000 + nd->nd_starttime.tv_usec);
- getmicrotime(&rt->tstamp);
- nfsdrt.pos = (nfsdrt.pos + 1) % NFSRTTLOGSIZ;
-}
-#endif /* NFS_NOSERVER */
-
-static int nfs_defect = 0;
-SYSCTL_INT(_vfs_nfs, OID_AUTO, defect, CTLFLAG_RW, &nfs_defect, 0, "");
-
-/*
- * Asynchronous I/O daemons for client nfs.
- * They do read-ahead and write-behind operations on the block I/O cache.
- * Never returns unless it fails or gets killed.
- */
-static int
-nfssvc_iod(p)
- struct proc *p;
-{
- register struct buf *bp;
- register int i, myiod;
- struct nfsmount *nmp;
- int error = 0;
-
- /*
- * Assign my position or return error if too many already running
- */
- myiod = -1;
- for (i = 0; i < NFS_MAXASYNCDAEMON; i++)
- if (nfs_asyncdaemon[i] == 0) {
- nfs_asyncdaemon[i]++;
- myiod = i;
- break;
- }
- if (myiod == -1)
- return (EBUSY);
- nfs_numasync++;
- /*
- * Just loop around doin our stuff until SIGKILL
- */
- for (;;) {
- while (((nmp = nfs_iodmount[myiod]) == NULL
- || nmp->nm_bufq.tqh_first == NULL)
- && error == 0) {
- if (nmp)
- nmp->nm_bufqiods--;
- nfs_iodwant[myiod] = p;
- nfs_iodmount[myiod] = NULL;
- error = tsleep((caddr_t)&nfs_iodwant[myiod],
- PWAIT | PCATCH, "nfsidl", 0);
- }
- if (error) {
- nfs_asyncdaemon[myiod] = 0;
- if (nmp)
- nmp->nm_bufqiods--;
- nfs_iodwant[myiod] = NULL;
- nfs_iodmount[myiod] = NULL;
- nfs_numasync--;
- return (error);
- }
- while ((bp = nmp->nm_bufq.tqh_first) != NULL) {
- /* Take one off the front of the list */
- TAILQ_REMOVE(&nmp->nm_bufq, bp, b_freelist);
- nmp->nm_bufqlen--;
- if (nmp->nm_bufqwant && nmp->nm_bufqlen <= nfs_numasync) {
- nmp->nm_bufqwant = FALSE;
- wakeup(&nmp->nm_bufq);
- }
- if (bp->b_flags & B_READ)
- (void) nfs_doio(bp, bp->b_rcred, (struct proc *)0);
- else
- (void) nfs_doio(bp, bp->b_wcred, (struct proc *)0);
- /*
- * If there are more than one iod on this mount, then defect
- * so that the iods can be shared out fairly between the mounts
- */
- if (nfs_defect && nmp->nm_bufqiods > 1) {
- NFS_DPF(ASYNCIO,
- ("nfssvc_iod: iod %d defecting from mount %p\n",
- myiod, nmp));
- nfs_iodmount[myiod] = NULL;
- nmp->nm_bufqiods--;
- break;
- }
- }
- }
-}
-
-
-/*
- * Get an authorization string for the uid by having the mount_nfs sitting
- * on this mount point porpous out of the kernel and do it.
- */
-int
-nfs_getauth(nmp, rep, cred, auth_str, auth_len, verf_str, verf_len, key)
- register struct nfsmount *nmp;
- struct nfsreq *rep;
- struct ucred *cred;
- char **auth_str;
- int *auth_len;
- char *verf_str;
- int *verf_len;
- NFSKERBKEY_T key; /* return session key */
-{
- int error = 0;
-
- while ((nmp->nm_state & NFSSTA_WAITAUTH) == 0) {
- nmp->nm_state |= NFSSTA_WANTAUTH;
- (void) tsleep((caddr_t)&nmp->nm_authtype, PSOCK,
- "nfsauth1", 2 * hz);
- error = nfs_sigintr(nmp, rep, rep->r_procp);
- if (error) {
- nmp->nm_state &= ~NFSSTA_WANTAUTH;
- return (error);
- }
- }
- nmp->nm_state &= ~(NFSSTA_WAITAUTH | NFSSTA_WANTAUTH);
- nmp->nm_authstr = *auth_str = (char *)malloc(RPCAUTH_MAXSIZ, M_TEMP, M_WAITOK);
- nmp->nm_authlen = RPCAUTH_MAXSIZ;
- nmp->nm_verfstr = verf_str;
- nmp->nm_verflen = *verf_len;
- nmp->nm_authuid = cred->cr_uid;
- wakeup((caddr_t)&nmp->nm_authstr);
-
- /*
- * And wait for mount_nfs to do its stuff.
- */
- while ((nmp->nm_state & NFSSTA_HASAUTH) == 0 && error == 0) {
- (void) tsleep((caddr_t)&nmp->nm_authlen, PSOCK,
- "nfsauth2", 2 * hz);
- error = nfs_sigintr(nmp, rep, rep->r_procp);
- }
- if (nmp->nm_state & NFSSTA_AUTHERR) {
- nmp->nm_state &= ~NFSSTA_AUTHERR;
- error = EAUTH;
- }
- if (error)
- free((caddr_t)*auth_str, M_TEMP);
- else {
- *auth_len = nmp->nm_authlen;
- *verf_len = nmp->nm_verflen;
- bcopy((caddr_t)nmp->nm_key, (caddr_t)key, sizeof (key));
- }
- nmp->nm_state &= ~NFSSTA_HASAUTH;
- nmp->nm_state |= NFSSTA_WAITAUTH;
- if (nmp->nm_state & NFSSTA_WANTAUTH) {
- nmp->nm_state &= ~NFSSTA_WANTAUTH;
- wakeup((caddr_t)&nmp->nm_authtype);
- }
- return (error);
-}
-
-/*
- * Get a nickname authenticator and verifier.
- */
-int
-nfs_getnickauth(nmp, cred, auth_str, auth_len, verf_str, verf_len)
- struct nfsmount *nmp;
- struct ucred *cred;
- char **auth_str;
- int *auth_len;
- char *verf_str;
- int verf_len;
-{
- register struct nfsuid *nuidp;
- register u_int32_t *nickp, *verfp;
- struct timeval ktvin, ktvout;
-
-#ifdef DIAGNOSTIC
- if (verf_len < (4 * NFSX_UNSIGNED))
- panic("nfs_getnickauth verf too small");
-#endif
- for (nuidp = NMUIDHASH(nmp, cred->cr_uid)->lh_first;
- nuidp != 0; nuidp = nuidp->nu_hash.le_next) {
- if (nuidp->nu_cr.cr_uid == cred->cr_uid)
- break;
- }
- if (!nuidp || nuidp->nu_expire < time_second)
- return (EACCES);
-
- /*
- * Move to the end of the lru list (end of lru == most recently used).
- */
- TAILQ_REMOVE(&nmp->nm_uidlruhead, nuidp, nu_lru);
- TAILQ_INSERT_TAIL(&nmp->nm_uidlruhead, nuidp, nu_lru);
-
- nickp = (u_int32_t *)malloc(2 * NFSX_UNSIGNED, M_TEMP, M_WAITOK);
- *nickp++ = txdr_unsigned(RPCAKN_NICKNAME);
- *nickp = txdr_unsigned(nuidp->nu_nickname);
- *auth_str = (char *)nickp;
- *auth_len = 2 * NFSX_UNSIGNED;
-
- /*
- * Now we must encrypt the verifier and package it up.
- */
- verfp = (u_int32_t *)verf_str;
- *verfp++ = txdr_unsigned(RPCAKN_NICKNAME);
- if (time_second > nuidp->nu_timestamp.tv_sec ||
- (time_second == nuidp->nu_timestamp.tv_sec &&
- time_second > nuidp->nu_timestamp.tv_usec))
- getmicrotime(&nuidp->nu_timestamp);
- else
- nuidp->nu_timestamp.tv_usec++;
- ktvin.tv_sec = txdr_unsigned(nuidp->nu_timestamp.tv_sec);
- ktvin.tv_usec = txdr_unsigned(nuidp->nu_timestamp.tv_usec);
-
- /*
- * Now encrypt the timestamp verifier in ecb mode using the session
- * key.
- */
-#ifdef NFSKERB
- XXX
-#endif
-
- *verfp++ = ktvout.tv_sec;
- *verfp++ = ktvout.tv_usec;
- *verfp = 0;
- return (0);
-}
-
-/*
- * Save the current nickname in a hash list entry on the mount point.
- */
-int
-nfs_savenickauth(nmp, cred, len, key, mdp, dposp, mrep)
- register struct nfsmount *nmp;
- struct ucred *cred;
- int len;
- NFSKERBKEY_T key;
- struct mbuf **mdp;
- char **dposp;
- struct mbuf *mrep;
-{
- register struct nfsuid *nuidp;
- register u_int32_t *tl;
- register int32_t t1;
- struct mbuf *md = *mdp;
- struct timeval ktvin, ktvout;
- u_int32_t nick;
- char *dpos = *dposp, *cp2;
- int deltasec, error = 0;
-
- if (len == (3 * NFSX_UNSIGNED)) {
- nfsm_dissect(tl, u_int32_t *, 3 * NFSX_UNSIGNED);
- ktvin.tv_sec = *tl++;
- ktvin.tv_usec = *tl++;
- nick = fxdr_unsigned(u_int32_t, *tl);
-
- /*
- * Decrypt the timestamp in ecb mode.
- */
-#ifdef NFSKERB
- XXX
-#endif
- ktvout.tv_sec = fxdr_unsigned(long, ktvout.tv_sec);
- ktvout.tv_usec = fxdr_unsigned(long, ktvout.tv_usec);
- deltasec = time_second - ktvout.tv_sec;
- if (deltasec < 0)
- deltasec = -deltasec;
- /*
- * If ok, add it to the hash list for the mount point.
- */
- if (deltasec <= NFS_KERBCLOCKSKEW) {
- if (nmp->nm_numuids < nuidhash_max) {
- nmp->nm_numuids++;
- nuidp = (struct nfsuid *)
- malloc(sizeof (struct nfsuid), M_NFSUID,
- M_WAITOK);
- } else {
- nuidp = nmp->nm_uidlruhead.tqh_first;
- LIST_REMOVE(nuidp, nu_hash);
- TAILQ_REMOVE(&nmp->nm_uidlruhead, nuidp,
- nu_lru);
- }
- nuidp->nu_flag = 0;
- nuidp->nu_cr.cr_uid = cred->cr_uid;
- nuidp->nu_expire = time_second + NFS_KERBTTL;
- nuidp->nu_timestamp = ktvout;
- nuidp->nu_nickname = nick;
- bcopy(key, nuidp->nu_key, sizeof (key));
- TAILQ_INSERT_TAIL(&nmp->nm_uidlruhead, nuidp,
- nu_lru);
- LIST_INSERT_HEAD(NMUIDHASH(nmp, cred->cr_uid),
- nuidp, nu_hash);
- }
- } else
- nfsm_adv(nfsm_rndup(len));
-nfsmout:
- *mdp = md;
- *dposp = dpos;
- return (error);
-}
diff --git a/sys/nfsclient/nfs_node.c b/sys/nfsclient/nfs_node.c
deleted file mode 100644
index 1de873908dfa..000000000000
--- a/sys/nfsclient/nfs_node.c
+++ /dev/null
@@ -1,402 +0,0 @@
-/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Rick Macklem at The University of Guelph.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)nfs_node.c 8.6 (Berkeley) 5/22/95
- * $FreeBSD$
- */
-
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/proc.h>
-#include <sys/mount.h>
-#include <sys/namei.h>
-#include <sys/vnode.h>
-#include <sys/malloc.h>
-
-#include <vm/vm_zone.h>
-
-#include <nfs/rpcv2.h>
-#include <nfs/nfsproto.h>
-#include <nfs/nfs.h>
-#include <nfs/nfsnode.h>
-#include <nfs/nfsmount.h>
-
-static vm_zone_t nfsnode_zone;
-static LIST_HEAD(nfsnodehashhead, nfsnode) *nfsnodehashtbl;
-static u_long nfsnodehash;
-
-#define TRUE 1
-#define FALSE 0
-
-/*
- * Initialize hash links for nfsnodes
- * and build nfsnode free list.
- */
-void
-nfs_nhinit()
-{
- nfsnode_zone = zinit("NFSNODE", sizeof(struct nfsnode), 0, 0, 1);
- nfsnodehashtbl = hashinit(desiredvnodes, M_NFSHASH, &nfsnodehash);
-}
-
-/*
- * Compute an entry in the NFS hash table structure
- */
-u_long
-nfs_hash(fhp, fhsize)
- register nfsfh_t *fhp;
- int fhsize;
-{
- register u_char *fhpp;
- register u_long fhsum;
- register int i;
-
- fhpp = &fhp->fh_bytes[0];
- fhsum = 0;
- for (i = 0; i < fhsize; i++)
- fhsum += *fhpp++;
- return (fhsum);
-}
-
-/*
- * Look up a vnode/nfsnode by file handle.
- * Callers must check for mount points!!
- * In all cases, a pointer to a
- * nfsnode structure is returned.
- */
-static int nfs_node_hash_lock;
-
-int
-nfs_nget(mntp, fhp, fhsize, npp)
- struct mount *mntp;
- register nfsfh_t *fhp;
- int fhsize;
- struct nfsnode **npp;
-{
- struct proc *p = curproc; /* XXX */
- struct nfsnode *np, *np2;
- struct nfsnodehashhead *nhpp;
- register struct vnode *vp;
- struct vnode *nvp;
- int error;
- int rsflags;
- struct nfsmount *nmp;
-
- /*
- * Calculate nfs mount point and figure out whether the rslock should
- * be interruptable or not.
- */
- nmp = VFSTONFS(mntp);
- if (nmp->nm_flag & NFSMNT_INT)
- rsflags = PCATCH;
- else
- rsflags = 0;
-
-retry:
- nhpp = NFSNOHASH(nfs_hash(fhp, fhsize));
-loop:
- for (np = nhpp->lh_first; np != 0; np = np->n_hash.le_next) {
- if (mntp != NFSTOV(np)->v_mount || np->n_fhsize != fhsize ||
- bcmp((caddr_t)fhp, (caddr_t)np->n_fhp, fhsize))
- continue;
- vp = NFSTOV(np);
- if (vget(vp, LK_EXCLUSIVE, p))
- goto loop;
- *npp = np;
- return(0);
- }
- /*
- * Obtain a lock to prevent a race condition if the getnewvnode()
- * or MALLOC() below happens to block.
- */
- if (nfs_node_hash_lock) {
- while (nfs_node_hash_lock) {
- nfs_node_hash_lock = -1;
- tsleep(&nfs_node_hash_lock, PVM, "nfsngt", 0);
- }
- goto loop;
- }
- nfs_node_hash_lock = 1;
-
- /*
- * Allocate before getnewvnode since doing so afterward
- * might cause a bogus v_data pointer to get dereferenced
- * elsewhere if zalloc should block.
- */
- np = zalloc(nfsnode_zone);
-
- error = getnewvnode(VT_NFS, mntp, nfsv2_vnodeop_p, &nvp);
- if (error) {
- if (nfs_node_hash_lock < 0)
- wakeup(&nfs_node_hash_lock);
- nfs_node_hash_lock = 0;
- *npp = 0;
- zfree(nfsnode_zone, np);
- return (error);
- }
- vp = nvp;
- bzero((caddr_t)np, sizeof *np);
- vp->v_data = np;
- np->n_vnode = vp;
- /*
- * Insert the nfsnode in the hash queue for its new file handle
- */
- for (np2 = nhpp->lh_first; np2 != 0; np2 = np2->n_hash.le_next) {
- if (mntp != NFSTOV(np2)->v_mount || np2->n_fhsize != fhsize ||
- bcmp((caddr_t)fhp, (caddr_t)np2->n_fhp, fhsize))
- continue;
- vrele(vp);
- if (nfs_node_hash_lock < 0)
- wakeup(&nfs_node_hash_lock);
- nfs_node_hash_lock = 0;
- zfree(nfsnode_zone, np);
- goto retry;
- }
- LIST_INSERT_HEAD(nhpp, np, n_hash);
- if (fhsize > NFS_SMALLFH) {
- MALLOC(np->n_fhp, nfsfh_t *, fhsize, M_NFSBIGFH, M_WAITOK);
- } else
- np->n_fhp = &np->n_fh;
- bcopy((caddr_t)fhp, (caddr_t)np->n_fhp, fhsize);
- np->n_fhsize = fhsize;
- lockinit(&np->n_rslock, PVFS | rsflags, "nfrslk", 0, LK_NOPAUSE);
- *npp = np;
-
- if (nfs_node_hash_lock < 0)
- wakeup(&nfs_node_hash_lock);
- nfs_node_hash_lock = 0;
-
- /*
- * Lock the new nfsnode.
- */
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
-
- return (0);
-}
-
-int
-nfs_inactive(ap)
- struct vop_inactive_args /* {
- struct vnode *a_vp;
- struct proc *a_p;
- } */ *ap;
-{
- register struct nfsnode *np;
- register struct sillyrename *sp;
- struct proc *p = curproc; /* XXX */
-
- np = VTONFS(ap->a_vp);
- if (prtactive && ap->a_vp->v_usecount != 0)
- vprint("nfs_inactive: pushing active", ap->a_vp);
- if (ap->a_vp->v_type != VDIR) {
- sp = np->n_sillyrename;
- np->n_sillyrename = (struct sillyrename *)0;
- } else
- sp = (struct sillyrename *)0;
- if (sp) {
- /*
- * We need a reference to keep the vnode from being
- * recycled by getnewvnode while we do the I/O
- * associated with discarding the buffers unless we
- * are being forcibly unmounted in which case we already
- * have our own reference.
- */
- if (ap->a_vp->v_usecount > 0)
- (void) nfs_vinvalbuf(ap->a_vp, 0, sp->s_cred, p, 1);
- else if (vget(ap->a_vp, 0, p))
- panic("nfs_inactive: lost vnode");
- else {
- (void) nfs_vinvalbuf(ap->a_vp, 0, sp->s_cred, p, 1);
- vrele(ap->a_vp);
- }
- /*
- * Remove the silly file that was rename'd earlier
- */
- nfs_removeit(sp);
- crfree(sp->s_cred);
- vrele(sp->s_dvp);
- FREE((caddr_t)sp, M_NFSREQ);
- }
- np->n_flag &= (NMODIFIED | NFLUSHINPROG | NFLUSHWANT | NQNFSEVICTED |
- NQNFSNONCACHE | NQNFSWRITE);
- VOP_UNLOCK(ap->a_vp, 0, ap->a_p);
- return (0);
-}
-
-/*
- * Reclaim an nfsnode so that it can be used for other purposes.
- */
-int
-nfs_reclaim(ap)
- struct vop_reclaim_args /* {
- struct vnode *a_vp;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
- register struct nfsnode *np = VTONFS(vp);
- register struct nfsmount *nmp = VFSTONFS(vp->v_mount);
- register struct nfsdmap *dp, *dp2;
-
- if (prtactive && vp->v_usecount != 0)
- vprint("nfs_reclaim: pushing active", vp);
-
- if (np->n_hash.le_prev != NULL)
- LIST_REMOVE(np, n_hash);
-
- /*
- * For nqnfs, take it off the timer queue as required.
- */
- if ((nmp->nm_flag & NFSMNT_NQNFS) && np->n_timer.cqe_next != 0) {
- CIRCLEQ_REMOVE(&nmp->nm_timerhead, np, n_timer);
- }
-
- /*
- * Free up any directory cookie structures and
- * large file handle structures that might be associated with
- * this nfs node.
- */
- if (vp->v_type == VDIR) {
- dp = np->n_cookies.lh_first;
- while (dp) {
- dp2 = dp;
- dp = dp->ndm_list.le_next;
- FREE((caddr_t)dp2, M_NFSDIROFF);
- }
- }
- if (np->n_fhsize > NFS_SMALLFH) {
- FREE((caddr_t)np->n_fhp, M_NFSBIGFH);
- }
-
- cache_purge(vp);
- zfree(nfsnode_zone, vp->v_data);
- vp->v_data = (void *)0;
- return (0);
-}
-
-#if 0
-/*
- * Lock an nfsnode
- */
-int
-nfs_lock(ap)
- struct vop_lock_args /* {
- struct vnode *a_vp;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
-
- /*
- * Ugh, another place where interruptible mounts will get hung.
- * If you make this sleep interruptible, then you have to fix all
- * the VOP_LOCK() calls to expect interruptibility.
- */
- while (vp->v_flag & VXLOCK) {
- vp->v_flag |= VXWANT;
- (void) tsleep((caddr_t)vp, PINOD, "nfslck", 0);
- }
- if (vp->v_tag == VT_NON)
- return (ENOENT);
-
-#if 0
- /*
- * Only lock regular files. If a server crashed while we were
- * holding a directory lock, we could easily end up sleeping
- * until the server rebooted while holding a lock on the root.
- * Locks are only needed for protecting critical sections in
- * VMIO at the moment.
- * New vnodes will have type VNON but they should be locked
- * since they may become VREG. This is checked in loadattrcache
- * and unwanted locks are released there.
- */
- if (vp->v_type == VREG || vp->v_type == VNON) {
- while (np->n_flag & NLOCKED) {
- np->n_flag |= NWANTED;
- (void) tsleep((caddr_t) np, PINOD, "nfslck2", 0);
- /*
- * If the vnode has transmuted into a VDIR while we
- * were asleep, then skip the lock.
- */
- if (vp->v_type != VREG && vp->v_type != VNON)
- return (0);
- }
- np->n_flag |= NLOCKED;
- }
-#endif
-
- return (0);
-}
-
-/*
- * Unlock an nfsnode
- */
-int
-nfs_unlock(ap)
- struct vop_unlock_args /* {
- struct vnode *a_vp;
- } */ *ap;
-{
-#if 0
- struct vnode* vp = ap->a_vp;
- struct nfsnode* np = VTONFS(vp);
-
- if (vp->v_type == VREG || vp->v_type == VNON) {
- if (!(np->n_flag & NLOCKED))
- panic("nfs_unlock: nfsnode not locked");
- np->n_flag &= ~NLOCKED;
- if (np->n_flag & NWANTED) {
- np->n_flag &= ~NWANTED;
- wakeup((caddr_t) np);
- }
- }
-#endif
-
- return (0);
-}
-
-/*
- * Check for a locked nfsnode
- */
-int
-nfs_islocked(ap)
- struct vop_islocked_args /* {
- struct vnode *a_vp;
- struct proc *a_p;
- } */ *ap;
-{
- return VTONFS(ap->a_vp)->n_flag & NLOCKED ? 1 : 0;
-}
-#endif
-
diff --git a/sys/nfsclient/nfs_socket.c b/sys/nfsclient/nfs_socket.c
deleted file mode 100644
index b2d6bf53dbe3..000000000000
--- a/sys/nfsclient/nfs_socket.c
+++ /dev/null
@@ -1,2284 +0,0 @@
-/*
- * Copyright (c) 1989, 1991, 1993, 1995
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Rick Macklem at The University of Guelph.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)nfs_socket.c 8.5 (Berkeley) 3/30/95
- * $FreeBSD$
- */
-
-/*
- * Socket operations for use by nfs
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/proc.h>
-#include <sys/malloc.h>
-#include <sys/mount.h>
-#include <sys/kernel.h>
-#include <sys/mbuf.h>
-#include <sys/vnode.h>
-#include <sys/protosw.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-#include <sys/syslog.h>
-#include <sys/tprintf.h>
-#include <sys/sysctl.h>
-#include <sys/signalvar.h>
-
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-
-#include <nfs/rpcv2.h>
-#include <nfs/nfsproto.h>
-#include <nfs/nfs.h>
-#include <nfs/xdr_subs.h>
-#include <nfs/nfsm_subs.h>
-#include <nfs/nfsmount.h>
-#include <nfs/nfsnode.h>
-#include <nfs/nfsrtt.h>
-#include <nfs/nqnfs.h>
-
-#define TRUE 1
-#define FALSE 0
-
-/*
- * Estimate rto for an nfs rpc sent via. an unreliable datagram.
- * Use the mean and mean deviation of rtt for the appropriate type of rpc
- * for the frequent rpcs and a default for the others.
- * The justification for doing "other" this way is that these rpcs
- * happen so infrequently that timer est. would probably be stale.
- * Also, since many of these rpcs are
- * non-idempotent, a conservative timeout is desired.
- * getattr, lookup - A+2D
- * read, write - A+4D
- * other - nm_timeo
- */
-#define NFS_RTO(n, t) \
- ((t) == 0 ? (n)->nm_timeo : \
- ((t) < 3 ? \
- (((((n)->nm_srtt[t-1] + 3) >> 2) + (n)->nm_sdrtt[t-1] + 1) >> 1) : \
- ((((n)->nm_srtt[t-1] + 7) >> 3) + (n)->nm_sdrtt[t-1] + 1)))
-#define NFS_SRTT(r) (r)->r_nmp->nm_srtt[proct[(r)->r_procnum] - 1]
-#define NFS_SDRTT(r) (r)->r_nmp->nm_sdrtt[proct[(r)->r_procnum] - 1]
-/*
- * External data, mostly RPC constants in XDR form
- */
-extern u_int32_t rpc_reply, rpc_msgdenied, rpc_mismatch, rpc_vers,
- rpc_auth_unix, rpc_msgaccepted, rpc_call, rpc_autherr,
- rpc_auth_kerb;
-extern u_int32_t nfs_prog, nqnfs_prog;
-extern time_t nqnfsstarttime;
-extern struct nfsstats nfsstats;
-extern int nfsv3_procid[NFS_NPROCS];
-extern int nfs_ticks;
-
-/*
- * Defines which timer to use for the procnum.
- * 0 - default
- * 1 - getattr
- * 2 - lookup
- * 3 - read
- * 4 - write
- */
-static int proct[NFS_NPROCS] = {
- 0, 1, 0, 2, 1, 3, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 0, 0, 0, 0, 0,
- 0, 0, 0,
-};
-
-static int nfs_realign_test;
-static int nfs_realign_count;
-
-SYSCTL_DECL(_vfs_nfs);
-
-SYSCTL_INT(_vfs_nfs, OID_AUTO, realign_test, CTLFLAG_RD, &nfs_realign_test, 0, "");
-SYSCTL_INT(_vfs_nfs, OID_AUTO, realign_count, CTLFLAG_RD, &nfs_realign_count, 0, "");
-
-
-/*
- * There is a congestion window for outstanding rpcs maintained per mount
- * point. The cwnd size is adjusted in roughly the way that:
- * Van Jacobson, Congestion avoidance and Control, In "Proceedings of
- * SIGCOMM '88". ACM, August 1988.
- * describes for TCP. The cwnd size is chopped in half on a retransmit timeout
- * and incremented by 1/cwnd when each rpc reply is received and a full cwnd
- * of rpcs is in progress.
- * (The sent count and cwnd are scaled for integer arith.)
- * Variants of "slow start" were tried and were found to be too much of a
- * performance hit (ave. rtt 3 times larger),
- * I suspect due to the large rtt that nfs rpcs have.
- */
-#define NFS_CWNDSCALE 256
-#define NFS_MAXCWND (NFS_CWNDSCALE * 32)
-static int nfs_backoff[8] = { 2, 4, 8, 16, 32, 64, 128, 256, };
-int nfsrtton = 0;
-struct nfsrtt nfsrtt;
-struct callout_handle nfs_timer_handle;
-
-static int nfs_msg __P((struct proc *,char *,char *));
-static int nfs_rcvlock __P((struct nfsreq *));
-static void nfs_rcvunlock __P((struct nfsreq *));
-static void nfs_realign __P((struct mbuf **pm, int hsiz));
-static int nfs_receive __P((struct nfsreq *rep, struct sockaddr **aname,
- struct mbuf **mp));
-static void nfs_softterm __P((struct nfsreq *rep));
-static int nfs_reconnect __P((struct nfsreq *rep));
-#ifndef NFS_NOSERVER
-static int nfsrv_getstream __P((struct nfssvc_sock *,int));
-
-int (*nfsrv3_procs[NFS_NPROCS]) __P((struct nfsrv_descript *nd,
- struct nfssvc_sock *slp,
- struct proc *procp,
- struct mbuf **mreqp)) = {
- nfsrv_null,
- nfsrv_getattr,
- nfsrv_setattr,
- nfsrv_lookup,
- nfsrv3_access,
- nfsrv_readlink,
- nfsrv_read,
- nfsrv_write,
- nfsrv_create,
- nfsrv_mkdir,
- nfsrv_symlink,
- nfsrv_mknod,
- nfsrv_remove,
- nfsrv_rmdir,
- nfsrv_rename,
- nfsrv_link,
- nfsrv_readdir,
- nfsrv_readdirplus,
- nfsrv_statfs,
- nfsrv_fsinfo,
- nfsrv_pathconf,
- nfsrv_commit,
- nqnfsrv_getlease,
- nqnfsrv_vacated,
- nfsrv_noop,
- nfsrv_noop
-};
-#endif /* NFS_NOSERVER */
-
-/*
- * Initialize sockets and congestion for a new NFS connection.
- * We do not free the sockaddr if error.
- */
-int
-nfs_connect(nmp, rep)
- register struct nfsmount *nmp;
- struct nfsreq *rep;
-{
- register struct socket *so;
- int s, error, rcvreserve, sndreserve;
- struct sockaddr *saddr;
- struct sockaddr_in *sin;
- struct proc *p = &proc0; /* only used for socreate and sobind */
-
- nmp->nm_so = (struct socket *)0;
- saddr = nmp->nm_nam;
- error = socreate(saddr->sa_family, &nmp->nm_so, nmp->nm_sotype,
- nmp->nm_soproto, p);
- if (error)
- goto bad;
- so = nmp->nm_so;
- nmp->nm_soflags = so->so_proto->pr_flags;
-
- /*
- * Some servers require that the client port be a reserved port number.
- */
- if (saddr->sa_family == AF_INET && (nmp->nm_flag & NFSMNT_RESVPORT)) {
- struct sockopt sopt;
- int ip;
- struct sockaddr_in ssin;
-
- bzero(&sopt, sizeof sopt);
- ip = IP_PORTRANGE_LOW;
- sopt.sopt_dir = SOPT_SET;
- sopt.sopt_level = IPPROTO_IP;
- sopt.sopt_name = IP_PORTRANGE;
- sopt.sopt_val = (void *)&ip;
- sopt.sopt_valsize = sizeof(ip);
- sopt.sopt_p = NULL;
- error = sosetopt(so, &sopt);
- if (error)
- goto bad;
- bzero(&ssin, sizeof ssin);
- sin = &ssin;
- sin->sin_len = sizeof (struct sockaddr_in);
- sin->sin_family = AF_INET;
- sin->sin_addr.s_addr = INADDR_ANY;
- sin->sin_port = htons(0);
- error = sobind(so, (struct sockaddr *)sin, p);
- if (error)
- goto bad;
- bzero(&sopt, sizeof sopt);
- ip = IP_PORTRANGE_DEFAULT;
- sopt.sopt_dir = SOPT_SET;
- sopt.sopt_level = IPPROTO_IP;
- sopt.sopt_name = IP_PORTRANGE;
- sopt.sopt_val = (void *)&ip;
- sopt.sopt_valsize = sizeof(ip);
- sopt.sopt_p = NULL;
- error = sosetopt(so, &sopt);
- if (error)
- goto bad;
- }
-
- /*
- * Protocols that do not require connections may be optionally left
- * unconnected for servers that reply from a port other than NFS_PORT.
- */
- if (nmp->nm_flag & NFSMNT_NOCONN) {
- if (nmp->nm_soflags & PR_CONNREQUIRED) {
- error = ENOTCONN;
- goto bad;
- }
- } else {
- error = soconnect(so, nmp->nm_nam, p);
- if (error)
- goto bad;
-
- /*
- * Wait for the connection to complete. Cribbed from the
- * connect system call but with the wait timing out so
- * that interruptible mounts don't hang here for a long time.
- */
- s = splnet();
- while ((so->so_state & SS_ISCONNECTING) && so->so_error == 0) {
- (void) tsleep((caddr_t)&so->so_timeo, PSOCK,
- "nfscon", 2 * hz);
- if ((so->so_state & SS_ISCONNECTING) &&
- so->so_error == 0 && rep &&
- (error = nfs_sigintr(nmp, rep, rep->r_procp)) != 0){
- so->so_state &= ~SS_ISCONNECTING;
- splx(s);
- goto bad;
- }
- }
- if (so->so_error) {
- error = so->so_error;
- so->so_error = 0;
- splx(s);
- goto bad;
- }
- splx(s);
- }
- if (nmp->nm_flag & (NFSMNT_SOFT | NFSMNT_INT)) {
- so->so_rcv.sb_timeo = (5 * hz);
- so->so_snd.sb_timeo = (5 * hz);
- } else {
- so->so_rcv.sb_timeo = 0;
- so->so_snd.sb_timeo = 0;
- }
- if (nmp->nm_sotype == SOCK_DGRAM) {
- sndreserve = (nmp->nm_wsize + NFS_MAXPKTHDR) * 2;
- rcvreserve = (max(nmp->nm_rsize, nmp->nm_readdirsize) +
- NFS_MAXPKTHDR) * 2;
- } else if (nmp->nm_sotype == SOCK_SEQPACKET) {
- sndreserve = (nmp->nm_wsize + NFS_MAXPKTHDR) * 2;
- rcvreserve = (max(nmp->nm_rsize, nmp->nm_readdirsize) +
- NFS_MAXPKTHDR) * 2;
- } else {
- if (nmp->nm_sotype != SOCK_STREAM)
- panic("nfscon sotype");
- if (so->so_proto->pr_flags & PR_CONNREQUIRED) {
- struct sockopt sopt;
- int val;
-
- bzero(&sopt, sizeof sopt);
- sopt.sopt_level = SOL_SOCKET;
- sopt.sopt_name = SO_KEEPALIVE;
- sopt.sopt_val = &val;
- sopt.sopt_valsize = sizeof val;
- val = 1;
- sosetopt(so, &sopt);
- }
- if (so->so_proto->pr_protocol == IPPROTO_TCP) {
- struct sockopt sopt;
- int val;
-
- bzero(&sopt, sizeof sopt);
- sopt.sopt_level = IPPROTO_TCP;
- sopt.sopt_name = TCP_NODELAY;
- sopt.sopt_val = &val;
- sopt.sopt_valsize = sizeof val;
- val = 1;
- sosetopt(so, &sopt);
- }
- sndreserve = (nmp->nm_wsize + NFS_MAXPKTHDR +
- sizeof (u_int32_t)) * 2;
- rcvreserve = (nmp->nm_rsize + NFS_MAXPKTHDR +
- sizeof (u_int32_t)) * 2;
- }
- error = soreserve(so, sndreserve, rcvreserve);
- if (error)
- goto bad;
- so->so_rcv.sb_flags |= SB_NOINTR;
- so->so_snd.sb_flags |= SB_NOINTR;
-
- /* Initialize other non-zero congestion variables */
- nmp->nm_srtt[0] = nmp->nm_srtt[1] = nmp->nm_srtt[2] =
- nmp->nm_srtt[3] = (NFS_TIMEO << 3);
- nmp->nm_sdrtt[0] = nmp->nm_sdrtt[1] = nmp->nm_sdrtt[2] =
- nmp->nm_sdrtt[3] = 0;
- nmp->nm_cwnd = NFS_MAXCWND / 2; /* Initial send window */
- nmp->nm_sent = 0;
- nmp->nm_timeouts = 0;
- return (0);
-
-bad:
- nfs_disconnect(nmp);
- return (error);
-}
-
-/*
- * Reconnect routine:
- * Called when a connection is broken on a reliable protocol.
- * - clean up the old socket
- * - nfs_connect() again
- * - set R_MUSTRESEND for all outstanding requests on mount point
- * If this fails the mount point is DEAD!
- * nb: Must be called with the nfs_sndlock() set on the mount point.
- */
-static int
-nfs_reconnect(rep)
- register struct nfsreq *rep;
-{
- register struct nfsreq *rp;
- register struct nfsmount *nmp = rep->r_nmp;
- int error;
-
- nfs_disconnect(nmp);
- while ((error = nfs_connect(nmp, rep)) != 0) {
- if (error == EINTR || error == ERESTART)
- return (EINTR);
- (void) tsleep((caddr_t)&lbolt, PSOCK, "nfscon", 0);
- }
-
- /*
- * Loop through outstanding request list and fix up all requests
- * on old socket.
- */
- for (rp = nfs_reqq.tqh_first; rp != 0; rp = rp->r_chain.tqe_next) {
- if (rp->r_nmp == nmp)
- rp->r_flags |= R_MUSTRESEND;
- }
- return (0);
-}
-
-/*
- * NFS disconnect. Clean up and unlink.
- */
-void
-nfs_disconnect(nmp)
- register struct nfsmount *nmp;
-{
- register struct socket *so;
-
- if (nmp->nm_so) {
- so = nmp->nm_so;
- nmp->nm_so = (struct socket *)0;
- soshutdown(so, 2);
- soclose(so);
- }
-}
-
-void
-nfs_safedisconnect(nmp)
- struct nfsmount *nmp;
-{
- struct nfsreq dummyreq;
-
- bzero(&dummyreq, sizeof(dummyreq));
- dummyreq.r_nmp = nmp;
- nfs_rcvlock(&dummyreq);
- nfs_disconnect(nmp);
- nfs_rcvunlock(&dummyreq);
-}
-
-/*
- * This is the nfs send routine. For connection based socket types, it
- * must be called with an nfs_sndlock() on the socket.
- * "rep == NULL" indicates that it has been called from a server.
- * For the client side:
- * - return EINTR if the RPC is terminated, 0 otherwise
- * - set R_MUSTRESEND if the send fails for any reason
- * - do any cleanup required by recoverable socket errors (?)
- * For the server side:
- * - return EINTR or ERESTART if interrupted by a signal
- * - return EPIPE if a connection is lost for connection based sockets (TCP...)
- * - do any cleanup required by recoverable socket errors (?)
- */
-int
-nfs_send(so, nam, top, rep)
- register struct socket *so;
- struct sockaddr *nam;
- register struct mbuf *top;
- struct nfsreq *rep;
-{
- struct sockaddr *sendnam;
- int error, soflags, flags;
-
- if (rep) {
- if (rep->r_flags & R_SOFTTERM) {
- m_freem(top);
- return (EINTR);
- }
- if ((so = rep->r_nmp->nm_so) == NULL) {
- rep->r_flags |= R_MUSTRESEND;
- m_freem(top);
- return (0);
- }
- rep->r_flags &= ~R_MUSTRESEND;
- soflags = rep->r_nmp->nm_soflags;
- } else
- soflags = so->so_proto->pr_flags;
- if ((soflags & PR_CONNREQUIRED) || (so->so_state & SS_ISCONNECTED))
- sendnam = (struct sockaddr *)0;
- else
- sendnam = nam;
- if (so->so_type == SOCK_SEQPACKET)
- flags = MSG_EOR;
- else
- flags = 0;
-
- error = so->so_proto->pr_usrreqs->pru_sosend(so, sendnam, 0, top, 0,
- flags, curproc /*XXX*/);
- /*
- * ENOBUFS for dgram sockets is transient and non fatal.
- * No need to log, and no need to break a soft mount.
- */
- if (error == ENOBUFS && so->so_type == SOCK_DGRAM) {
- error = 0;
- if (rep) /* do backoff retransmit on client */
- rep->r_flags |= R_MUSTRESEND;
- }
-
- if (error) {
- if (rep) {
- log(LOG_INFO, "nfs send error %d for server %s\n",error,
- rep->r_nmp->nm_mountp->mnt_stat.f_mntfromname);
- /*
- * Deal with errors for the client side.
- */
- if (rep->r_flags & R_SOFTTERM)
- error = EINTR;
- else
- rep->r_flags |= R_MUSTRESEND;
- } else
- log(LOG_INFO, "nfsd send error %d\n", error);
-
- /*
- * Handle any recoverable (soft) socket errors here. (?)
- */
- if (error != EINTR && error != ERESTART &&
- error != EWOULDBLOCK && error != EPIPE)
- error = 0;
- }
- return (error);
-}
-
-/*
- * Receive a Sun RPC Request/Reply. For SOCK_DGRAM, the work is all
- * done by soreceive(), but for SOCK_STREAM we must deal with the Record
- * Mark and consolidate the data into a new mbuf list.
- * nb: Sometimes TCP passes the data up to soreceive() in long lists of
- * small mbufs.
- * For SOCK_STREAM we must be very careful to read an entire record once
- * we have read any of it, even if the system call has been interrupted.
- */
-static int
-nfs_receive(rep, aname, mp)
- register struct nfsreq *rep;
- struct sockaddr **aname;
- struct mbuf **mp;
-{
- register struct socket *so;
- struct uio auio;
- struct iovec aio;
- register struct mbuf *m;
- struct mbuf *control;
- u_int32_t len;
- struct sockaddr **getnam;
- int error, sotype, rcvflg;
- struct proc *p = curproc; /* XXX */
-
- /*
- * Set up arguments for soreceive()
- */
- *mp = (struct mbuf *)0;
- *aname = (struct sockaddr *)0;
- sotype = rep->r_nmp->nm_sotype;
-
- /*
- * For reliable protocols, lock against other senders/receivers
- * in case a reconnect is necessary.
- * For SOCK_STREAM, first get the Record Mark to find out how much
- * more there is to get.
- * We must lock the socket against other receivers
- * until we have an entire rpc request/reply.
- */
- if (sotype != SOCK_DGRAM) {
- error = nfs_sndlock(rep);
- if (error)
- return (error);
-tryagain:
- /*
- * Check for fatal errors and resending request.
- */
- /*
- * Ugh: If a reconnect attempt just happened, nm_so
- * would have changed. NULL indicates a failed
- * attempt that has essentially shut down this
- * mount point.
- */
- if (rep->r_mrep || (rep->r_flags & R_SOFTTERM)) {
- nfs_sndunlock(rep);
- return (EINTR);
- }
- so = rep->r_nmp->nm_so;
- if (!so) {
- error = nfs_reconnect(rep);
- if (error) {
- nfs_sndunlock(rep);
- return (error);
- }
- goto tryagain;
- }
- while (rep->r_flags & R_MUSTRESEND) {
- m = m_copym(rep->r_mreq, 0, M_COPYALL, M_WAIT);
- nfsstats.rpcretries++;
- error = nfs_send(so, rep->r_nmp->nm_nam, m, rep);
- if (error) {
- if (error == EINTR || error == ERESTART ||
- (error = nfs_reconnect(rep)) != 0) {
- nfs_sndunlock(rep);
- return (error);
- }
- goto tryagain;
- }
- }
- nfs_sndunlock(rep);
- if (sotype == SOCK_STREAM) {
- aio.iov_base = (caddr_t) &len;
- aio.iov_len = sizeof(u_int32_t);
- auio.uio_iov = &aio;
- auio.uio_iovcnt = 1;
- auio.uio_segflg = UIO_SYSSPACE;
- auio.uio_rw = UIO_READ;
- auio.uio_offset = 0;
- auio.uio_resid = sizeof(u_int32_t);
- auio.uio_procp = p;
- do {
- rcvflg = MSG_WAITALL;
- error = so->so_proto->pr_usrreqs->pru_soreceive
- (so, (struct sockaddr **)0, &auio,
- (struct mbuf **)0, (struct mbuf **)0,
- &rcvflg);
- if (error == EWOULDBLOCK && rep) {
- if (rep->r_flags & R_SOFTTERM)
- return (EINTR);
- }
- } while (error == EWOULDBLOCK);
- if (!error && auio.uio_resid > 0) {
- /*
- * Don't log a 0 byte receive; it means
- * that the socket has been closed, and
- * can happen during normal operation
- * (forcible unmount or Solaris server).
- */
- if (auio.uio_resid != sizeof (u_int32_t))
- log(LOG_INFO,
- "short receive (%d/%d) from nfs server %s\n",
- (int)(sizeof(u_int32_t) - auio.uio_resid),
- (int)sizeof(u_int32_t),
- rep->r_nmp->nm_mountp->mnt_stat.f_mntfromname);
- error = EPIPE;
- }
- if (error)
- goto errout;
- len = ntohl(len) & ~0x80000000;
- /*
- * This is SERIOUS! We are out of sync with the sender
- * and forcing a disconnect/reconnect is all I can do.
- */
- if (len > NFS_MAXPACKET) {
- log(LOG_ERR, "%s (%d) from nfs server %s\n",
- "impossible packet length",
- len,
- rep->r_nmp->nm_mountp->mnt_stat.f_mntfromname);
- error = EFBIG;
- goto errout;
- }
- auio.uio_resid = len;
- do {
- rcvflg = MSG_WAITALL;
- error = so->so_proto->pr_usrreqs->pru_soreceive
- (so, (struct sockaddr **)0,
- &auio, mp, (struct mbuf **)0, &rcvflg);
- } while (error == EWOULDBLOCK || error == EINTR ||
- error == ERESTART);
- if (!error && auio.uio_resid > 0) {
- if (len != auio.uio_resid)
- log(LOG_INFO,
- "short receive (%d/%d) from nfs server %s\n",
- len - auio.uio_resid, len,
- rep->r_nmp->nm_mountp->mnt_stat.f_mntfromname);
- error = EPIPE;
- }
- } else {
- /*
- * NB: Since uio_resid is big, MSG_WAITALL is ignored
- * and soreceive() will return when it has either a
- * control msg or a data msg.
- * We have no use for control msg., but must grab them
- * and then throw them away so we know what is going
- * on.
- */
- auio.uio_resid = len = 100000000; /* Anything Big */
- auio.uio_procp = p;
- do {
- rcvflg = 0;
- error = so->so_proto->pr_usrreqs->pru_soreceive
- (so, (struct sockaddr **)0,
- &auio, mp, &control, &rcvflg);
- if (control)
- m_freem(control);
- if (error == EWOULDBLOCK && rep) {
- if (rep->r_flags & R_SOFTTERM)
- return (EINTR);
- }
- } while (error == EWOULDBLOCK ||
- (!error && *mp == NULL && control));
- if ((rcvflg & MSG_EOR) == 0)
- printf("Egad!!\n");
- if (!error && *mp == NULL)
- error = EPIPE;
- len -= auio.uio_resid;
- }
-errout:
- if (error && error != EINTR && error != ERESTART) {
- m_freem(*mp);
- *mp = (struct mbuf *)0;
- if (error != EPIPE)
- log(LOG_INFO,
- "receive error %d from nfs server %s\n",
- error,
- rep->r_nmp->nm_mountp->mnt_stat.f_mntfromname);
- error = nfs_sndlock(rep);
- if (!error)
- error = nfs_reconnect(rep);
- if (!error)
- goto tryagain;
- else
- nfs_sndunlock(rep);
- }
- } else {
- if ((so = rep->r_nmp->nm_so) == NULL)
- return (EACCES);
- if (so->so_state & SS_ISCONNECTED)
- getnam = (struct sockaddr **)0;
- else
- getnam = aname;
- auio.uio_resid = len = 1000000;
- auio.uio_procp = p;
- do {
- rcvflg = 0;
- error = so->so_proto->pr_usrreqs->pru_soreceive
- (so, getnam, &auio, mp,
- (struct mbuf **)0, &rcvflg);
- if (error == EWOULDBLOCK &&
- (rep->r_flags & R_SOFTTERM))
- return (EINTR);
- } while (error == EWOULDBLOCK);
- len -= auio.uio_resid;
- }
- if (error) {
- m_freem(*mp);
- *mp = (struct mbuf *)0;
- }
- /*
- * Search for any mbufs that are not a multiple of 4 bytes long
- * or with m_data not longword aligned.
- * These could cause pointer alignment problems, so copy them to
- * well aligned mbufs.
- */
- nfs_realign(mp, 5 * NFSX_UNSIGNED);
- return (error);
-}
-
-/*
- * Implement receipt of reply on a socket.
- * We must search through the list of received datagrams matching them
- * with outstanding requests using the xid, until ours is found.
- */
-/* ARGSUSED */
-int
-nfs_reply(myrep)
- struct nfsreq *myrep;
-{
- register struct nfsreq *rep;
- register struct nfsmount *nmp = myrep->r_nmp;
- register int32_t t1;
- struct mbuf *mrep, *md;
- struct sockaddr *nam;
- u_int32_t rxid, *tl;
- caddr_t dpos, cp2;
- int error;
-
- /*
- * Loop around until we get our own reply
- */
- for (;;) {
- /*
- * Lock against other receivers so that I don't get stuck in
- * sbwait() after someone else has received my reply for me.
- * Also necessary for connection based protocols to avoid
- * race conditions during a reconnect.
- * If nfs_rcvlock() returns EALREADY, that means that
- * the reply has already been recieved by another
- * process and we can return immediately. In this
- * case, the lock is not taken to avoid races with
- * other processes.
- */
- error = nfs_rcvlock(myrep);
- if (error == EALREADY)
- return (0);
- if (error)
- return (error);
- /*
- * Get the next Rpc reply off the socket
- */
- error = nfs_receive(myrep, &nam, &mrep);
- nfs_rcvunlock(myrep);
- if (error) {
-
- /*
- * Ignore routing errors on connectionless protocols??
- */
- if (NFSIGNORE_SOERROR(nmp->nm_soflags, error)) {
- nmp->nm_so->so_error = 0;
- if (myrep->r_flags & R_GETONEREP)
- return (0);
- continue;
- }
- return (error);
- }
- if (nam)
- FREE(nam, M_SONAME);
-
- /*
- * Get the xid and check that it is an rpc reply
- */
- md = mrep;
- dpos = mtod(md, caddr_t);
- nfsm_dissect(tl, u_int32_t *, 2*NFSX_UNSIGNED);
- rxid = *tl++;
- if (*tl != rpc_reply) {
-#ifndef NFS_NOSERVER
- if (nmp->nm_flag & NFSMNT_NQNFS) {
- if (nqnfs_callback(nmp, mrep, md, dpos))
- nfsstats.rpcinvalid++;
- } else {
- nfsstats.rpcinvalid++;
- m_freem(mrep);
- }
-#else
- nfsstats.rpcinvalid++;
- m_freem(mrep);
-#endif
-nfsmout:
- if (myrep->r_flags & R_GETONEREP)
- return (0);
- continue;
- }
-
- /*
- * Loop through the request list to match up the reply
- * Iff no match, just drop the datagram
- */
- for (rep = nfs_reqq.tqh_first; rep != 0;
- rep = rep->r_chain.tqe_next) {
- if (rep->r_mrep == NULL && rxid == rep->r_xid) {
- /* Found it.. */
- rep->r_mrep = mrep;
- rep->r_md = md;
- rep->r_dpos = dpos;
- if (nfsrtton) {
- struct rttl *rt;
-
- rt = &nfsrtt.rttl[nfsrtt.pos];
- rt->proc = rep->r_procnum;
- rt->rto = NFS_RTO(nmp, proct[rep->r_procnum]);
- rt->sent = nmp->nm_sent;
- rt->cwnd = nmp->nm_cwnd;
- rt->srtt = nmp->nm_srtt[proct[rep->r_procnum] - 1];
- rt->sdrtt = nmp->nm_sdrtt[proct[rep->r_procnum] - 1];
- rt->fsid = nmp->nm_mountp->mnt_stat.f_fsid;
- getmicrotime(&rt->tstamp);
- if (rep->r_flags & R_TIMING)
- rt->rtt = rep->r_rtt;
- else
- rt->rtt = 1000000;
- nfsrtt.pos = (nfsrtt.pos + 1) % NFSRTTLOGSIZ;
- }
- /*
- * Update congestion window.
- * Do the additive increase of
- * one rpc/rtt.
- */
- if (nmp->nm_cwnd <= nmp->nm_sent) {
- nmp->nm_cwnd +=
- (NFS_CWNDSCALE * NFS_CWNDSCALE +
- (nmp->nm_cwnd >> 1)) / nmp->nm_cwnd;
- if (nmp->nm_cwnd > NFS_MAXCWND)
- nmp->nm_cwnd = NFS_MAXCWND;
- }
- if (rep->r_flags & R_SENT) {
- rep->r_flags &= ~R_SENT;
- nmp->nm_sent -= NFS_CWNDSCALE;
- }
- /*
- * Update rtt using a gain of 0.125 on the mean
- * and a gain of 0.25 on the deviation.
- */
- if (rep->r_flags & R_TIMING) {
- /*
- * Since the timer resolution of
- * NFS_HZ is so course, it can often
- * result in r_rtt == 0. Since
- * r_rtt == N means that the actual
- * rtt is between N+dt and N+2-dt ticks,
- * add 1.
- */
- t1 = rep->r_rtt + 1;
- t1 -= (NFS_SRTT(rep) >> 3);
- NFS_SRTT(rep) += t1;
- if (t1 < 0)
- t1 = -t1;
- t1 -= (NFS_SDRTT(rep) >> 2);
- NFS_SDRTT(rep) += t1;
- }
- nmp->nm_timeouts = 0;
- break;
- }
- }
- /*
- * If not matched to a request, drop it.
- * If it's mine, get out.
- */
- if (rep == 0) {
- nfsstats.rpcunexpected++;
- m_freem(mrep);
- } else if (rep == myrep) {
- if (rep->r_mrep == NULL)
- panic("nfsreply nil");
- return (0);
- }
- if (myrep->r_flags & R_GETONEREP)
- return (0);
- }
-}
-
-/*
- * nfs_request - goes something like this
- * - fill in request struct
- * - links it into list
- * - calls nfs_send() for first transmit
- * - calls nfs_receive() to get reply
- * - break down rpc header and return with nfs reply pointed to
- * by mrep or error
- * nb: always frees up mreq mbuf list
- */
-int
-nfs_request(vp, mrest, procnum, procp, cred, mrp, mdp, dposp)
- struct vnode *vp;
- struct mbuf *mrest;
- int procnum;
- struct proc *procp;
- struct ucred *cred;
- struct mbuf **mrp;
- struct mbuf **mdp;
- caddr_t *dposp;
-{
- register struct mbuf *mrep, *m2;
- register struct nfsreq *rep;
- register u_int32_t *tl;
- register int i;
- struct nfsmount *nmp;
- struct mbuf *m, *md, *mheadend;
- struct nfsnode *np;
- char nickv[RPCX_NICKVERF];
- time_t reqtime, waituntil;
- caddr_t dpos, cp2;
- int t1, nqlflag, cachable, s, error = 0, mrest_len, auth_len, auth_type;
- int trylater_delay = NQ_TRYLATERDEL, trylater_cnt = 0, failed_auth = 0;
- int verf_len, verf_type;
- u_int32_t xid;
- u_quad_t frev;
- char *auth_str, *verf_str;
- NFSKERBKEY_T key; /* save session key */
-
- nmp = VFSTONFS(vp->v_mount);
- MALLOC(rep, struct nfsreq *, sizeof(struct nfsreq), M_NFSREQ, M_WAITOK);
- rep->r_nmp = nmp;
- rep->r_vp = vp;
- rep->r_procp = procp;
- rep->r_procnum = procnum;
- i = 0;
- m = mrest;
- while (m) {
- i += m->m_len;
- m = m->m_next;
- }
- mrest_len = i;
-
- /*
- * Get the RPC header with authorization.
- */
-kerbauth:
- verf_str = auth_str = (char *)0;
- if (nmp->nm_flag & NFSMNT_KERB) {
- verf_str = nickv;
- verf_len = sizeof (nickv);
- auth_type = RPCAUTH_KERB4;
- bzero((caddr_t)key, sizeof (key));
- if (failed_auth || nfs_getnickauth(nmp, cred, &auth_str,
- &auth_len, verf_str, verf_len)) {
- error = nfs_getauth(nmp, rep, cred, &auth_str,
- &auth_len, verf_str, &verf_len, key);
- if (error) {
- free((caddr_t)rep, M_NFSREQ);
- m_freem(mrest);
- return (error);
- }
- }
- } else {
- auth_type = RPCAUTH_UNIX;
- if (cred->cr_ngroups < 1)
- panic("nfsreq nogrps");
- auth_len = ((((cred->cr_ngroups - 1) > nmp->nm_numgrps) ?
- nmp->nm_numgrps : (cred->cr_ngroups - 1)) << 2) +
- 5 * NFSX_UNSIGNED;
- }
- m = nfsm_rpchead(cred, nmp->nm_flag, procnum, auth_type, auth_len,
- auth_str, verf_len, verf_str, mrest, mrest_len, &mheadend, &xid);
- if (auth_str)
- free(auth_str, M_TEMP);
-
- /*
- * For stream protocols, insert a Sun RPC Record Mark.
- */
- if (nmp->nm_sotype == SOCK_STREAM) {
- M_PREPEND(m, NFSX_UNSIGNED, M_WAIT);
- *mtod(m, u_int32_t *) = htonl(0x80000000 |
- (m->m_pkthdr.len - NFSX_UNSIGNED));
- }
- rep->r_mreq = m;
- rep->r_xid = xid;
-tryagain:
- if (nmp->nm_flag & NFSMNT_SOFT)
- rep->r_retry = nmp->nm_retry;
- else
- rep->r_retry = NFS_MAXREXMIT + 1; /* past clip limit */
- rep->r_rtt = rep->r_rexmit = 0;
- if (proct[procnum] > 0)
- rep->r_flags = R_TIMING;
- else
- rep->r_flags = 0;
- rep->r_mrep = NULL;
-
- /*
- * Do the client side RPC.
- */
- nfsstats.rpcrequests++;
- /*
- * Chain request into list of outstanding requests. Be sure
- * to put it LAST so timer finds oldest requests first.
- */
- s = splsoftclock();
- TAILQ_INSERT_TAIL(&nfs_reqq, rep, r_chain);
-
- /* Get send time for nqnfs */
- reqtime = time_second;
-
- /*
- * If backing off another request or avoiding congestion, don't
- * send this one now but let timer do it. If not timing a request,
- * do it now.
- */
- if (nmp->nm_so && (nmp->nm_sotype != SOCK_DGRAM ||
- (nmp->nm_flag & NFSMNT_DUMBTIMR) ||
- nmp->nm_sent < nmp->nm_cwnd)) {
- splx(s);
- if (nmp->nm_soflags & PR_CONNREQUIRED)
- error = nfs_sndlock(rep);
- if (!error) {
- m2 = m_copym(m, 0, M_COPYALL, M_WAIT);
- error = nfs_send(nmp->nm_so, nmp->nm_nam, m2, rep);
- if (nmp->nm_soflags & PR_CONNREQUIRED)
- nfs_sndunlock(rep);
- }
- if (!error && (rep->r_flags & R_MUSTRESEND) == 0) {
- nmp->nm_sent += NFS_CWNDSCALE;
- rep->r_flags |= R_SENT;
- }
- } else {
- splx(s);
- rep->r_rtt = -1;
- }
-
- /*
- * Wait for the reply from our send or the timer's.
- */
- if (!error || error == EPIPE)
- error = nfs_reply(rep);
-
- /*
- * RPC done, unlink the request.
- */
- s = splsoftclock();
- TAILQ_REMOVE(&nfs_reqq, rep, r_chain);
- splx(s);
-
- /*
- * Decrement the outstanding request count.
- */
- if (rep->r_flags & R_SENT) {
- rep->r_flags &= ~R_SENT; /* paranoia */
- nmp->nm_sent -= NFS_CWNDSCALE;
- }
-
- /*
- * If there was a successful reply and a tprintf msg.
- * tprintf a response.
- */
- if (!error && (rep->r_flags & R_TPRINTFMSG))
- nfs_msg(rep->r_procp, nmp->nm_mountp->mnt_stat.f_mntfromname,
- "is alive again");
- mrep = rep->r_mrep;
- md = rep->r_md;
- dpos = rep->r_dpos;
- if (error) {
- m_freem(rep->r_mreq);
- free((caddr_t)rep, M_NFSREQ);
- return (error);
- }
-
- /*
- * break down the rpc header and check if ok
- */
- nfsm_dissect(tl, u_int32_t *, 3 * NFSX_UNSIGNED);
- if (*tl++ == rpc_msgdenied) {
- if (*tl == rpc_mismatch)
- error = EOPNOTSUPP;
- else if ((nmp->nm_flag & NFSMNT_KERB) && *tl++ == rpc_autherr) {
- if (!failed_auth) {
- failed_auth++;
- mheadend->m_next = (struct mbuf *)0;
- m_freem(mrep);
- m_freem(rep->r_mreq);
- goto kerbauth;
- } else
- error = EAUTH;
- } else
- error = EACCES;
- m_freem(mrep);
- m_freem(rep->r_mreq);
- free((caddr_t)rep, M_NFSREQ);
- return (error);
- }
-
- /*
- * Grab any Kerberos verifier, otherwise just throw it away.
- */
- verf_type = fxdr_unsigned(int, *tl++);
- i = fxdr_unsigned(int32_t, *tl);
- if ((nmp->nm_flag & NFSMNT_KERB) && verf_type == RPCAUTH_KERB4) {
- error = nfs_savenickauth(nmp, cred, i, key, &md, &dpos, mrep);
- if (error)
- goto nfsmout;
- } else if (i > 0)
- nfsm_adv(nfsm_rndup(i));
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED);
- /* 0 == ok */
- if (*tl == 0) {
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED);
- if (*tl != 0) {
- error = fxdr_unsigned(int, *tl);
- if ((nmp->nm_flag & NFSMNT_NFSV3) &&
- error == NFSERR_TRYLATER) {
- m_freem(mrep);
- error = 0;
- waituntil = time_second + trylater_delay;
- while (time_second < waituntil)
- (void) tsleep((caddr_t)&lbolt,
- PSOCK, "nqnfstry", 0);
- trylater_delay *= nfs_backoff[trylater_cnt];
- if (trylater_cnt < 7)
- trylater_cnt++;
- goto tryagain;
- }
-
- /*
- * If the File Handle was stale, invalidate the
- * lookup cache, just in case.
- */
- if (error == ESTALE)
- cache_purge(vp);
- if (nmp->nm_flag & NFSMNT_NFSV3) {
- *mrp = mrep;
- *mdp = md;
- *dposp = dpos;
- error |= NFSERR_RETERR;
- } else
- m_freem(mrep);
- m_freem(rep->r_mreq);
- free((caddr_t)rep, M_NFSREQ);
- return (error);
- }
-
- /*
- * For nqnfs, get any lease in reply
- */
- if (nmp->nm_flag & NFSMNT_NQNFS) {
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED);
- if (*tl) {
- np = VTONFS(vp);
- nqlflag = fxdr_unsigned(int, *tl);
- nfsm_dissect(tl, u_int32_t *, 4*NFSX_UNSIGNED);
- cachable = fxdr_unsigned(int, *tl++);
- reqtime += fxdr_unsigned(int, *tl++);
- if (reqtime > time_second) {
- frev = fxdr_hyper(tl);
- nqnfs_clientlease(nmp, np, nqlflag,
- cachable, reqtime, frev);
- }
- }
- }
- *mrp = mrep;
- *mdp = md;
- *dposp = dpos;
- m_freem(rep->r_mreq);
- FREE((caddr_t)rep, M_NFSREQ);
- return (0);
- }
- m_freem(mrep);
- error = EPROTONOSUPPORT;
-nfsmout:
- m_freem(rep->r_mreq);
- free((caddr_t)rep, M_NFSREQ);
- return (error);
-}
-
-#ifndef NFS_NOSERVER
-/*
- * Generate the rpc reply header
- * siz arg. is used to decide if adding a cluster is worthwhile
- */
-int
-nfs_rephead(siz, nd, slp, err, cache, frev, mrq, mbp, bposp)
- int siz;
- struct nfsrv_descript *nd;
- struct nfssvc_sock *slp;
- int err;
- int cache;
- u_quad_t *frev;
- struct mbuf **mrq;
- struct mbuf **mbp;
- caddr_t *bposp;
-{
- register u_int32_t *tl;
- register struct mbuf *mreq;
- caddr_t bpos;
- struct mbuf *mb, *mb2;
-
- MGETHDR(mreq, M_WAIT, MT_DATA);
- mb = mreq;
- /*
- * If this is a big reply, use a cluster else
- * try and leave leading space for the lower level headers.
- */
- siz += RPC_REPLYSIZ;
- if ((max_hdr + siz) >= MINCLSIZE) {
- MCLGET(mreq, M_WAIT);
- } else
- mreq->m_data += max_hdr;
- tl = mtod(mreq, u_int32_t *);
- mreq->m_len = 6 * NFSX_UNSIGNED;
- bpos = ((caddr_t)tl) + mreq->m_len;
- *tl++ = txdr_unsigned(nd->nd_retxid);
- *tl++ = rpc_reply;
- if (err == ERPCMISMATCH || (err & NFSERR_AUTHERR)) {
- *tl++ = rpc_msgdenied;
- if (err & NFSERR_AUTHERR) {
- *tl++ = rpc_autherr;
- *tl = txdr_unsigned(err & ~NFSERR_AUTHERR);
- mreq->m_len -= NFSX_UNSIGNED;
- bpos -= NFSX_UNSIGNED;
- } else {
- *tl++ = rpc_mismatch;
- *tl++ = txdr_unsigned(RPC_VER2);
- *tl = txdr_unsigned(RPC_VER2);
- }
- } else {
- *tl++ = rpc_msgaccepted;
-
- /*
- * For Kerberos authentication, we must send the nickname
- * verifier back, otherwise just RPCAUTH_NULL.
- */
- if (nd->nd_flag & ND_KERBFULL) {
- register struct nfsuid *nuidp;
- struct timeval ktvin, ktvout;
-
- for (nuidp = NUIDHASH(slp, nd->nd_cr.cr_uid)->lh_first;
- nuidp != 0; nuidp = nuidp->nu_hash.le_next) {
- if (nuidp->nu_cr.cr_uid == nd->nd_cr.cr_uid &&
- (!nd->nd_nam2 || netaddr_match(NU_NETFAM(nuidp),
- &nuidp->nu_haddr, nd->nd_nam2)))
- break;
- }
- if (nuidp) {
- ktvin.tv_sec =
- txdr_unsigned(nuidp->nu_timestamp.tv_sec - 1);
- ktvin.tv_usec =
- txdr_unsigned(nuidp->nu_timestamp.tv_usec);
-
- /*
- * Encrypt the timestamp in ecb mode using the
- * session key.
- */
-#ifdef NFSKERB
- XXX
-#endif
-
- *tl++ = rpc_auth_kerb;
- *tl++ = txdr_unsigned(3 * NFSX_UNSIGNED);
- *tl = ktvout.tv_sec;
- nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED);
- *tl++ = ktvout.tv_usec;
- *tl++ = txdr_unsigned(nuidp->nu_cr.cr_uid);
- } else {
- *tl++ = 0;
- *tl++ = 0;
- }
- } else {
- *tl++ = 0;
- *tl++ = 0;
- }
- switch (err) {
- case EPROGUNAVAIL:
- *tl = txdr_unsigned(RPC_PROGUNAVAIL);
- break;
- case EPROGMISMATCH:
- *tl = txdr_unsigned(RPC_PROGMISMATCH);
- nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
- if (nd->nd_flag & ND_NQNFS) {
- *tl++ = txdr_unsigned(3);
- *tl = txdr_unsigned(3);
- } else {
- *tl++ = txdr_unsigned(2);
- *tl = txdr_unsigned(3);
- }
- break;
- case EPROCUNAVAIL:
- *tl = txdr_unsigned(RPC_PROCUNAVAIL);
- break;
- case EBADRPC:
- *tl = txdr_unsigned(RPC_GARBAGE);
- break;
- default:
- *tl = 0;
- if (err != NFSERR_RETVOID) {
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);
- if (err)
- *tl = txdr_unsigned(nfsrv_errmap(nd, err));
- else
- *tl = 0;
- }
- break;
- };
- }
-
- /*
- * For nqnfs, piggyback lease as requested.
- */
- if ((nd->nd_flag & ND_NQNFS) && err == 0) {
- if (nd->nd_flag & ND_LEASE) {
- nfsm_build(tl, u_int32_t *, 5 * NFSX_UNSIGNED);
- *tl++ = txdr_unsigned(nd->nd_flag & ND_LEASE);
- *tl++ = txdr_unsigned(cache);
- *tl++ = txdr_unsigned(nd->nd_duration);
- txdr_hyper(*frev, tl);
- } else {
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);
- *tl = 0;
- }
- }
- if (mrq != NULL)
- *mrq = mreq;
- *mbp = mb;
- *bposp = bpos;
- if (err != 0 && err != NFSERR_RETVOID)
- nfsstats.srvrpc_errs++;
- return (0);
-}
-
-
-#endif /* NFS_NOSERVER */
-/*
- * Nfs timer routine
- * Scan the nfsreq list and retranmit any requests that have timed out
- * To avoid retransmission attempts on STREAM sockets (in the future) make
- * sure to set the r_retry field to 0 (implies nm_retry == 0).
- */
-void
-nfs_timer(arg)
- void *arg; /* never used */
-{
- register struct nfsreq *rep;
- register struct mbuf *m;
- register struct socket *so;
- register struct nfsmount *nmp;
- register int timeo;
- int s, error;
-#ifndef NFS_NOSERVER
- static long lasttime = 0;
- register struct nfssvc_sock *slp;
- u_quad_t cur_usec;
-#endif /* NFS_NOSERVER */
- struct proc *p = &proc0; /* XXX for credentials, will break if sleep */
-
- s = splnet();
- for (rep = nfs_reqq.tqh_first; rep != 0; rep = rep->r_chain.tqe_next) {
- nmp = rep->r_nmp;
- if (rep->r_mrep || (rep->r_flags & R_SOFTTERM))
- continue;
- if (nfs_sigintr(nmp, rep, rep->r_procp)) {
- nfs_softterm(rep);
- continue;
- }
- if (rep->r_rtt >= 0) {
- rep->r_rtt++;
- if (nmp->nm_flag & NFSMNT_DUMBTIMR)
- timeo = nmp->nm_timeo;
- else
- timeo = NFS_RTO(nmp, proct[rep->r_procnum]);
- if (nmp->nm_timeouts > 0)
- timeo *= nfs_backoff[nmp->nm_timeouts - 1];
- if (rep->r_rtt <= timeo)
- continue;
- if (nmp->nm_timeouts < 8)
- nmp->nm_timeouts++;
- }
- /*
- * Check for server not responding
- */
- if ((rep->r_flags & R_TPRINTFMSG) == 0 &&
- rep->r_rexmit > nmp->nm_deadthresh) {
- nfs_msg(rep->r_procp,
- nmp->nm_mountp->mnt_stat.f_mntfromname,
- "not responding");
- rep->r_flags |= R_TPRINTFMSG;
- }
- if (rep->r_rexmit >= rep->r_retry) { /* too many */
- nfsstats.rpctimeouts++;
- nfs_softterm(rep);
- continue;
- }
- if (nmp->nm_sotype != SOCK_DGRAM) {
- if (++rep->r_rexmit > NFS_MAXREXMIT)
- rep->r_rexmit = NFS_MAXREXMIT;
- continue;
- }
- if ((so = nmp->nm_so) == NULL)
- continue;
-
- /*
- * If there is enough space and the window allows..
- * Resend it
- * Set r_rtt to -1 in case we fail to send it now.
- */
- rep->r_rtt = -1;
- if (sbspace(&so->so_snd) >= rep->r_mreq->m_pkthdr.len &&
- ((nmp->nm_flag & NFSMNT_DUMBTIMR) ||
- (rep->r_flags & R_SENT) ||
- nmp->nm_sent < nmp->nm_cwnd) &&
- (m = m_copym(rep->r_mreq, 0, M_COPYALL, M_DONTWAIT))){
- if ((nmp->nm_flag & NFSMNT_NOCONN) == 0)
- error = (*so->so_proto->pr_usrreqs->pru_send)
- (so, 0, m, (struct sockaddr *)0,
- (struct mbuf *)0, p);
- else
- error = (*so->so_proto->pr_usrreqs->pru_send)
- (so, 0, m, nmp->nm_nam, (struct mbuf *)0,
- p);
- if (error) {
- if (NFSIGNORE_SOERROR(nmp->nm_soflags, error))
- so->so_error = 0;
- } else {
- /*
- * Iff first send, start timing
- * else turn timing off, backoff timer
- * and divide congestion window by 2.
- */
- if (rep->r_flags & R_SENT) {
- rep->r_flags &= ~R_TIMING;
- if (++rep->r_rexmit > NFS_MAXREXMIT)
- rep->r_rexmit = NFS_MAXREXMIT;
- nmp->nm_cwnd >>= 1;
- if (nmp->nm_cwnd < NFS_CWNDSCALE)
- nmp->nm_cwnd = NFS_CWNDSCALE;
- nfsstats.rpcretries++;
- } else {
- rep->r_flags |= R_SENT;
- nmp->nm_sent += NFS_CWNDSCALE;
- }
- rep->r_rtt = 0;
- }
- }
- }
-#ifndef NFS_NOSERVER
- /*
- * Call the nqnfs server timer once a second to handle leases.
- */
- if (lasttime != time_second) {
- lasttime = time_second;
- nqnfs_serverd();
- }
-
- /*
- * Scan the write gathering queues for writes that need to be
- * completed now.
- */
- cur_usec = nfs_curusec();
- for (slp = nfssvc_sockhead.tqh_first; slp != 0;
- slp = slp->ns_chain.tqe_next) {
- if (slp->ns_tq.lh_first && slp->ns_tq.lh_first->nd_time<=cur_usec)
- nfsrv_wakenfsd(slp);
- }
-#endif /* NFS_NOSERVER */
- splx(s);
- nfs_timer_handle = timeout(nfs_timer, (void *)0, nfs_ticks);
-}
-
-/*
- * Flag a request as being about to terminate (due to NFSMNT_INT/NFSMNT_SOFT).
- * The nm_send count is decremented now to avoid deadlocks when the process in
- * soreceive() hasn't yet managed to send its own request.
- */
-
-static void
-nfs_softterm(rep)
- struct nfsreq *rep;
-{
- rep->r_flags |= R_SOFTTERM;
-
- if (rep->r_flags & R_SENT) {
- rep->r_nmp->nm_sent -= NFS_CWNDSCALE;
- rep->r_flags &= ~R_SENT;
- }
-}
-
-/*
- * Test for a termination condition pending on the process.
- * This is used for NFSMNT_INT mounts.
- */
-int
-nfs_sigintr(nmp, rep, p)
- struct nfsmount *nmp;
- struct nfsreq *rep;
- register struct proc *p;
-{
- sigset_t tmpset;
-
- if (rep && (rep->r_flags & R_SOFTTERM))
- return (EINTR);
- if (!(nmp->nm_flag & NFSMNT_INT))
- return (0);
- if (p == NULL)
- return (0);
-
- tmpset = p->p_siglist;
- SIGSETNAND(tmpset, p->p_sigmask);
- SIGSETNAND(tmpset, p->p_sigignore);
- if (SIGNOTEMPTY(p->p_siglist) && NFSINT_SIGMASK(tmpset))
- return (EINTR);
-
- return (0);
-}
-
-/*
- * Lock a socket against others.
- * Necessary for STREAM sockets to ensure you get an entire rpc request/reply
- * and also to avoid race conditions between the processes with nfs requests
- * in progress when a reconnect is necessary.
- */
-int
-nfs_sndlock(rep)
- struct nfsreq *rep;
-{
- register int *statep = &rep->r_nmp->nm_state;
- struct proc *p;
- int slpflag = 0, slptimeo = 0;
-
- if (rep) {
- p = rep->r_procp;
- if (rep->r_nmp->nm_flag & NFSMNT_INT)
- slpflag = PCATCH;
- } else
- p = (struct proc *)0;
- while (*statep & NFSSTA_SNDLOCK) {
- if (nfs_sigintr(rep->r_nmp, rep, p))
- return (EINTR);
- *statep |= NFSSTA_WANTSND;
- (void) tsleep((caddr_t)statep, slpflag | (PZERO - 1),
- "nfsndlck", slptimeo);
- if (slpflag == PCATCH) {
- slpflag = 0;
- slptimeo = 2 * hz;
- }
- }
- *statep |= NFSSTA_SNDLOCK;
- return (0);
-}
-
-/*
- * Unlock the stream socket for others.
- */
-void
-nfs_sndunlock(rep)
- struct nfsreq *rep;
-{
- register int *statep = &rep->r_nmp->nm_state;
-
- if ((*statep & NFSSTA_SNDLOCK) == 0)
- panic("nfs sndunlock");
- *statep &= ~NFSSTA_SNDLOCK;
- if (*statep & NFSSTA_WANTSND) {
- *statep &= ~NFSSTA_WANTSND;
- wakeup((caddr_t)statep);
- }
-}
-
-static int
-nfs_rcvlock(rep)
- register struct nfsreq *rep;
-{
- register int *statep = &rep->r_nmp->nm_state;
- int slpflag, slptimeo = 0;
-
- if (rep->r_nmp->nm_flag & NFSMNT_INT)
- slpflag = PCATCH;
- else
- slpflag = 0;
- while (*statep & NFSSTA_RCVLOCK) {
- if (nfs_sigintr(rep->r_nmp, rep, rep->r_procp))
- return (EINTR);
- *statep |= NFSSTA_WANTRCV;
- (void) tsleep((caddr_t)statep, slpflag | (PZERO - 1), "nfsrcvlk",
- slptimeo);
- /*
- * If our reply was recieved while we were sleeping,
- * then just return without taking the lock to avoid a
- * situation where a single iod could 'capture' the
- * recieve lock.
- */
- if (rep->r_mrep != NULL)
- return (EALREADY);
- if (slpflag == PCATCH) {
- slpflag = 0;
- slptimeo = 2 * hz;
- }
- }
- *statep |= NFSSTA_RCVLOCK;
- return (0);
-}
-
-/*
- * Unlock the stream socket for others.
- */
-static void
-nfs_rcvunlock(rep)
- register struct nfsreq *rep;
-{
- register int *statep = &rep->r_nmp->nm_state;
-
- if ((*statep & NFSSTA_RCVLOCK) == 0)
- panic("nfs rcvunlock");
- *statep &= ~NFSSTA_RCVLOCK;
- if (*statep & NFSSTA_WANTRCV) {
- *statep &= ~NFSSTA_WANTRCV;
- wakeup((caddr_t)statep);
- }
-}
-
-/*
- * nfs_realign:
- *
- * Check for badly aligned mbuf data and realign by copying the unaligned
- * portion of the data into a new mbuf chain and freeing the portions
- * of the old chain that were replaced.
- *
- * We cannot simply realign the data within the existing mbuf chain
- * because the underlying buffers may contain other rpc commands and
- * we cannot afford to overwrite them.
- *
- * We would prefer to avoid this situation entirely. The situation does
- * not occur with NFS/UDP and is supposed to only occassionally occur
- * with TCP. Use vfs.nfs.realign_count and realign_test to check this.
- */
-static void
-nfs_realign(pm, hsiz)
- register struct mbuf **pm;
- int hsiz;
-{
- struct mbuf *m;
- struct mbuf *n = NULL;
- int off = 0;
-
- ++nfs_realign_test;
-
- while ((m = *pm) != NULL) {
- if ((m->m_len & 0x3) || (mtod(m, intptr_t) & 0x3)) {
- MGET(n, M_WAIT, MT_DATA);
- if (m->m_len >= MINCLSIZE) {
- MCLGET(n, M_WAIT);
- }
- n->m_len = 0;
- break;
- }
- pm = &m->m_next;
- }
-
- /*
- * If n is non-NULL, loop on m copying data, then replace the
- * portion of the chain that had to be realigned.
- */
- if (n != NULL) {
- ++nfs_realign_count;
- while (m) {
- m_copyback(n, off, m->m_len, mtod(m, caddr_t));
- off += m->m_len;
- m = m->m_next;
- }
- m_freem(*pm);
- *pm = n;
- }
-}
-
-#ifndef NFS_NOSERVER
-
-/*
- * Parse an RPC request
- * - verify it
- * - fill in the cred struct.
- */
-int
-nfs_getreq(nd, nfsd, has_header)
- register struct nfsrv_descript *nd;
- struct nfsd *nfsd;
- int has_header;
-{
- register int len, i;
- register u_int32_t *tl;
- register int32_t t1;
- struct uio uio;
- struct iovec iov;
- caddr_t dpos, cp2, cp;
- u_int32_t nfsvers, auth_type;
- uid_t nickuid;
- int error = 0, nqnfs = 0, ticklen;
- struct mbuf *mrep, *md;
- register struct nfsuid *nuidp;
- struct timeval tvin, tvout;
-#if 0 /* until encrypted keys are implemented */
- NFSKERBKEYSCHED_T keys; /* stores key schedule */
-#endif
-
- mrep = nd->nd_mrep;
- md = nd->nd_md;
- dpos = nd->nd_dpos;
- if (has_header) {
- nfsm_dissect(tl, u_int32_t *, 10 * NFSX_UNSIGNED);
- nd->nd_retxid = fxdr_unsigned(u_int32_t, *tl++);
- if (*tl++ != rpc_call) {
- m_freem(mrep);
- return (EBADRPC);
- }
- } else
- nfsm_dissect(tl, u_int32_t *, 8 * NFSX_UNSIGNED);
- nd->nd_repstat = 0;
- nd->nd_flag = 0;
- if (*tl++ != rpc_vers) {
- nd->nd_repstat = ERPCMISMATCH;
- nd->nd_procnum = NFSPROC_NOOP;
- return (0);
- }
- if (*tl != nfs_prog) {
- if (*tl == nqnfs_prog)
- nqnfs++;
- else {
- nd->nd_repstat = EPROGUNAVAIL;
- nd->nd_procnum = NFSPROC_NOOP;
- return (0);
- }
- }
- tl++;
- nfsvers = fxdr_unsigned(u_int32_t, *tl++);
- if (((nfsvers < NFS_VER2 || nfsvers > NFS_VER3) && !nqnfs) ||
- (nfsvers != NQNFS_VER3 && nqnfs)) {
- nd->nd_repstat = EPROGMISMATCH;
- nd->nd_procnum = NFSPROC_NOOP;
- return (0);
- }
- if (nqnfs)
- nd->nd_flag = (ND_NFSV3 | ND_NQNFS);
- else if (nfsvers == NFS_VER3)
- nd->nd_flag = ND_NFSV3;
- nd->nd_procnum = fxdr_unsigned(u_int32_t, *tl++);
- if (nd->nd_procnum == NFSPROC_NULL)
- return (0);
- if (nd->nd_procnum >= NFS_NPROCS ||
- (!nqnfs && nd->nd_procnum >= NQNFSPROC_GETLEASE) ||
- (!nd->nd_flag && nd->nd_procnum > NFSV2PROC_STATFS)) {
- nd->nd_repstat = EPROCUNAVAIL;
- nd->nd_procnum = NFSPROC_NOOP;
- return (0);
- }
- if ((nd->nd_flag & ND_NFSV3) == 0)
- nd->nd_procnum = nfsv3_procid[nd->nd_procnum];
- auth_type = *tl++;
- len = fxdr_unsigned(int, *tl++);
- if (len < 0 || len > RPCAUTH_MAXSIZ) {
- m_freem(mrep);
- return (EBADRPC);
- }
-
- nd->nd_flag &= ~ND_KERBAUTH;
- /*
- * Handle auth_unix or auth_kerb.
- */
- if (auth_type == rpc_auth_unix) {
- len = fxdr_unsigned(int, *++tl);
- if (len < 0 || len > NFS_MAXNAMLEN) {
- m_freem(mrep);
- return (EBADRPC);
- }
- nfsm_adv(nfsm_rndup(len));
- nfsm_dissect(tl, u_int32_t *, 3 * NFSX_UNSIGNED);
- bzero((caddr_t)&nd->nd_cr, sizeof (struct ucred));
- nd->nd_cr.cr_ref = 1;
- nd->nd_cr.cr_uid = fxdr_unsigned(uid_t, *tl++);
- nd->nd_cr.cr_gid = fxdr_unsigned(gid_t, *tl++);
- len = fxdr_unsigned(int, *tl);
- if (len < 0 || len > RPCAUTH_UNIXGIDS) {
- m_freem(mrep);
- return (EBADRPC);
- }
- nfsm_dissect(tl, u_int32_t *, (len + 2) * NFSX_UNSIGNED);
- for (i = 1; i <= len; i++)
- if (i < NGROUPS)
- nd->nd_cr.cr_groups[i] = fxdr_unsigned(gid_t, *tl++);
- else
- tl++;
- nd->nd_cr.cr_ngroups = (len >= NGROUPS) ? NGROUPS : (len + 1);
- if (nd->nd_cr.cr_ngroups > 1)
- nfsrvw_sort(nd->nd_cr.cr_groups, nd->nd_cr.cr_ngroups);
- len = fxdr_unsigned(int, *++tl);
- if (len < 0 || len > RPCAUTH_MAXSIZ) {
- m_freem(mrep);
- return (EBADRPC);
- }
- if (len > 0)
- nfsm_adv(nfsm_rndup(len));
- } else if (auth_type == rpc_auth_kerb) {
- switch (fxdr_unsigned(int, *tl++)) {
- case RPCAKN_FULLNAME:
- ticklen = fxdr_unsigned(int, *tl);
- *((u_int32_t *)nfsd->nfsd_authstr) = *tl;
- uio.uio_resid = nfsm_rndup(ticklen) + NFSX_UNSIGNED;
- nfsd->nfsd_authlen = uio.uio_resid + NFSX_UNSIGNED;
- if (uio.uio_resid > (len - 2 * NFSX_UNSIGNED)) {
- m_freem(mrep);
- return (EBADRPC);
- }
- uio.uio_offset = 0;
- uio.uio_iov = &iov;
- uio.uio_iovcnt = 1;
- uio.uio_segflg = UIO_SYSSPACE;
- iov.iov_base = (caddr_t)&nfsd->nfsd_authstr[4];
- iov.iov_len = RPCAUTH_MAXSIZ - 4;
- nfsm_mtouio(&uio, uio.uio_resid);
- nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
- if (*tl++ != rpc_auth_kerb ||
- fxdr_unsigned(int, *tl) != 4 * NFSX_UNSIGNED) {
- printf("Bad kerb verifier\n");
- nd->nd_repstat = (NFSERR_AUTHERR|AUTH_BADVERF);
- nd->nd_procnum = NFSPROC_NOOP;
- return (0);
- }
- nfsm_dissect(cp, caddr_t, 4 * NFSX_UNSIGNED);
- tl = (u_int32_t *)cp;
- if (fxdr_unsigned(int, *tl) != RPCAKN_FULLNAME) {
- printf("Not fullname kerb verifier\n");
- nd->nd_repstat = (NFSERR_AUTHERR|AUTH_BADVERF);
- nd->nd_procnum = NFSPROC_NOOP;
- return (0);
- }
- cp += NFSX_UNSIGNED;
- bcopy(cp, nfsd->nfsd_verfstr, 3 * NFSX_UNSIGNED);
- nfsd->nfsd_verflen = 3 * NFSX_UNSIGNED;
- nd->nd_flag |= ND_KERBFULL;
- nfsd->nfsd_flag |= NFSD_NEEDAUTH;
- break;
- case RPCAKN_NICKNAME:
- if (len != 2 * NFSX_UNSIGNED) {
- printf("Kerb nickname short\n");
- nd->nd_repstat = (NFSERR_AUTHERR|AUTH_BADCRED);
- nd->nd_procnum = NFSPROC_NOOP;
- return (0);
- }
- nickuid = fxdr_unsigned(uid_t, *tl);
- nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
- if (*tl++ != rpc_auth_kerb ||
- fxdr_unsigned(int, *tl) != 3 * NFSX_UNSIGNED) {
- printf("Kerb nick verifier bad\n");
- nd->nd_repstat = (NFSERR_AUTHERR|AUTH_BADVERF);
- nd->nd_procnum = NFSPROC_NOOP;
- return (0);
- }
- nfsm_dissect(tl, u_int32_t *, 3 * NFSX_UNSIGNED);
- tvin.tv_sec = *tl++;
- tvin.tv_usec = *tl;
-
- for (nuidp = NUIDHASH(nfsd->nfsd_slp,nickuid)->lh_first;
- nuidp != 0; nuidp = nuidp->nu_hash.le_next) {
- if (nuidp->nu_cr.cr_uid == nickuid &&
- (!nd->nd_nam2 ||
- netaddr_match(NU_NETFAM(nuidp),
- &nuidp->nu_haddr, nd->nd_nam2)))
- break;
- }
- if (!nuidp) {
- nd->nd_repstat =
- (NFSERR_AUTHERR|AUTH_REJECTCRED);
- nd->nd_procnum = NFSPROC_NOOP;
- return (0);
- }
-
- /*
- * Now, decrypt the timestamp using the session key
- * and validate it.
- */
-#ifdef NFSKERB
- XXX
-#endif
-
- tvout.tv_sec = fxdr_unsigned(long, tvout.tv_sec);
- tvout.tv_usec = fxdr_unsigned(long, tvout.tv_usec);
- if (nuidp->nu_expire < time_second ||
- nuidp->nu_timestamp.tv_sec > tvout.tv_sec ||
- (nuidp->nu_timestamp.tv_sec == tvout.tv_sec &&
- nuidp->nu_timestamp.tv_usec > tvout.tv_usec)) {
- nuidp->nu_expire = 0;
- nd->nd_repstat =
- (NFSERR_AUTHERR|AUTH_REJECTVERF);
- nd->nd_procnum = NFSPROC_NOOP;
- return (0);
- }
- nfsrv_setcred(&nuidp->nu_cr, &nd->nd_cr);
- nd->nd_flag |= ND_KERBNICK;
- };
- } else {
- nd->nd_repstat = (NFSERR_AUTHERR | AUTH_REJECTCRED);
- nd->nd_procnum = NFSPROC_NOOP;
- return (0);
- }
-
- /*
- * For nqnfs, get piggybacked lease request.
- */
- if (nqnfs && nd->nd_procnum != NQNFSPROC_EVICTED) {
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED);
- nd->nd_flag |= fxdr_unsigned(int, *tl);
- if (nd->nd_flag & ND_LEASE) {
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED);
- nd->nd_duration = fxdr_unsigned(int32_t, *tl);
- } else
- nd->nd_duration = NQ_MINLEASE;
- } else
- nd->nd_duration = NQ_MINLEASE;
- nd->nd_md = md;
- nd->nd_dpos = dpos;
- return (0);
-nfsmout:
- return (error);
-}
-
-#endif
-
-static int
-nfs_msg(p, server, msg)
- struct proc *p;
- char *server, *msg;
-{
- tpr_t tpr;
-
- if (p)
- tpr = tprintf_open(p);
- else
- tpr = NULL;
- tprintf(tpr, "nfs server %s: %s\n", server, msg);
- tprintf_close(tpr);
- return (0);
-}
-
-#ifndef NFS_NOSERVER
-/*
- * Socket upcall routine for the nfsd sockets.
- * The caddr_t arg is a pointer to the "struct nfssvc_sock".
- * Essentially do as much as possible non-blocking, else punt and it will
- * be called with M_WAIT from an nfsd.
- */
-void
-nfsrv_rcv(so, arg, waitflag)
- struct socket *so;
- void *arg;
- int waitflag;
-{
- register struct nfssvc_sock *slp = (struct nfssvc_sock *)arg;
- register struct mbuf *m;
- struct mbuf *mp;
- struct sockaddr *nam;
- struct uio auio;
- int flags, error;
-
- if ((slp->ns_flag & SLP_VALID) == 0)
- return;
-#ifdef notdef
- /*
- * Define this to test for nfsds handling this under heavy load.
- */
- if (waitflag == M_DONTWAIT) {
- slp->ns_flag |= SLP_NEEDQ; goto dorecs;
- }
-#endif
- auio.uio_procp = NULL;
- if (so->so_type == SOCK_STREAM) {
- /*
- * If there are already records on the queue, defer soreceive()
- * to an nfsd so that there is feedback to the TCP layer that
- * the nfs servers are heavily loaded.
- */
- if (STAILQ_FIRST(&slp->ns_rec) && waitflag == M_DONTWAIT) {
- slp->ns_flag |= SLP_NEEDQ;
- goto dorecs;
- }
-
- /*
- * Do soreceive().
- */
- auio.uio_resid = 1000000000;
- flags = MSG_DONTWAIT;
- error = so->so_proto->pr_usrreqs->pru_soreceive
- (so, &nam, &auio, &mp, (struct mbuf **)0, &flags);
- if (error || mp == (struct mbuf *)0) {
- if (error == EWOULDBLOCK)
- slp->ns_flag |= SLP_NEEDQ;
- else
- slp->ns_flag |= SLP_DISCONN;
- goto dorecs;
- }
- m = mp;
- if (slp->ns_rawend) {
- slp->ns_rawend->m_next = m;
- slp->ns_cc += 1000000000 - auio.uio_resid;
- } else {
- slp->ns_raw = m;
- slp->ns_cc = 1000000000 - auio.uio_resid;
- }
- while (m->m_next)
- m = m->m_next;
- slp->ns_rawend = m;
-
- /*
- * Now try and parse record(s) out of the raw stream data.
- */
- error = nfsrv_getstream(slp, waitflag);
- if (error) {
- if (error == EPERM)
- slp->ns_flag |= SLP_DISCONN;
- else
- slp->ns_flag |= SLP_NEEDQ;
- }
- } else {
- do {
- auio.uio_resid = 1000000000;
- flags = MSG_DONTWAIT;
- error = so->so_proto->pr_usrreqs->pru_soreceive
- (so, &nam, &auio, &mp,
- (struct mbuf **)0, &flags);
- if (mp) {
- struct nfsrv_rec *rec;
- rec = malloc(sizeof(struct nfsrv_rec),
- M_NFSRVDESC, waitflag);
- if (!rec) {
- if (nam)
- FREE(nam, M_SONAME);
- m_freem(mp);
- continue;
- }
- nfs_realign(&mp, 10 * NFSX_UNSIGNED);
- rec->nr_address = nam;
- rec->nr_packet = mp;
- STAILQ_INSERT_TAIL(&slp->ns_rec, rec, nr_link);
- }
- if (error) {
- if ((so->so_proto->pr_flags & PR_CONNREQUIRED)
- && error != EWOULDBLOCK) {
- slp->ns_flag |= SLP_DISCONN;
- goto dorecs;
- }
- }
- } while (mp);
- }
-
- /*
- * Now try and process the request records, non-blocking.
- */
-dorecs:
- if (waitflag == M_DONTWAIT &&
- (STAILQ_FIRST(&slp->ns_rec)
- || (slp->ns_flag & (SLP_NEEDQ | SLP_DISCONN))))
- nfsrv_wakenfsd(slp);
-}
-
-/*
- * Try and extract an RPC request from the mbuf data list received on a
- * stream socket. The "waitflag" argument indicates whether or not it
- * can sleep.
- */
-static int
-nfsrv_getstream(slp, waitflag)
- register struct nfssvc_sock *slp;
- int waitflag;
-{
- register struct mbuf *m, **mpp;
- register char *cp1, *cp2;
- register int len;
- struct mbuf *om, *m2, *recm = NULL;
- u_int32_t recmark;
-
- if (slp->ns_flag & SLP_GETSTREAM)
- panic("nfs getstream");
- slp->ns_flag |= SLP_GETSTREAM;
- for (;;) {
- if (slp->ns_reclen == 0) {
- if (slp->ns_cc < NFSX_UNSIGNED) {
- slp->ns_flag &= ~SLP_GETSTREAM;
- return (0);
- }
- m = slp->ns_raw;
- if (m->m_len >= NFSX_UNSIGNED) {
- bcopy(mtod(m, caddr_t), (caddr_t)&recmark, NFSX_UNSIGNED);
- m->m_data += NFSX_UNSIGNED;
- m->m_len -= NFSX_UNSIGNED;
- } else {
- cp1 = (caddr_t)&recmark;
- cp2 = mtod(m, caddr_t);
- while (cp1 < ((caddr_t)&recmark) + NFSX_UNSIGNED) {
- while (m->m_len == 0) {
- m = m->m_next;
- cp2 = mtod(m, caddr_t);
- }
- *cp1++ = *cp2++;
- m->m_data++;
- m->m_len--;
- }
- }
- slp->ns_cc -= NFSX_UNSIGNED;
- recmark = ntohl(recmark);
- slp->ns_reclen = recmark & ~0x80000000;
- if (recmark & 0x80000000)
- slp->ns_flag |= SLP_LASTFRAG;
- else
- slp->ns_flag &= ~SLP_LASTFRAG;
- if (slp->ns_reclen > NFS_MAXPACKET) {
- slp->ns_flag &= ~SLP_GETSTREAM;
- return (EPERM);
- }
- }
-
- /*
- * Now get the record part.
- */
- if (slp->ns_cc == slp->ns_reclen) {
- recm = slp->ns_raw;
- slp->ns_raw = slp->ns_rawend = (struct mbuf *)0;
- slp->ns_cc = slp->ns_reclen = 0;
- } else if (slp->ns_cc > slp->ns_reclen) {
- len = 0;
- m = slp->ns_raw;
- om = (struct mbuf *)0;
- while (len < slp->ns_reclen) {
- if ((len + m->m_len) > slp->ns_reclen) {
- m2 = m_copym(m, 0, slp->ns_reclen - len,
- waitflag);
- if (m2) {
- if (om) {
- om->m_next = m2;
- recm = slp->ns_raw;
- } else
- recm = m2;
- m->m_data += slp->ns_reclen - len;
- m->m_len -= slp->ns_reclen - len;
- len = slp->ns_reclen;
- } else {
- slp->ns_flag &= ~SLP_GETSTREAM;
- return (EWOULDBLOCK);
- }
- } else if ((len + m->m_len) == slp->ns_reclen) {
- om = m;
- len += m->m_len;
- m = m->m_next;
- recm = slp->ns_raw;
- om->m_next = (struct mbuf *)0;
- } else {
- om = m;
- len += m->m_len;
- m = m->m_next;
- }
- }
- slp->ns_raw = m;
- slp->ns_cc -= len;
- slp->ns_reclen = 0;
- } else {
- slp->ns_flag &= ~SLP_GETSTREAM;
- return (0);
- }
-
- /*
- * Accumulate the fragments into a record.
- */
- mpp = &slp->ns_frag;
- while (*mpp)
- mpp = &((*mpp)->m_next);
- *mpp = recm;
- if (slp->ns_flag & SLP_LASTFRAG) {
- struct nfsrv_rec *rec;
- rec = malloc(sizeof(struct nfsrv_rec), M_NFSRVDESC, waitflag);
- if (!rec) {
- m_freem(slp->ns_frag);
- } else {
- nfs_realign(&slp->ns_frag, 10 * NFSX_UNSIGNED);
- rec->nr_address = (struct sockaddr *)0;
- rec->nr_packet = slp->ns_frag;
- STAILQ_INSERT_TAIL(&slp->ns_rec, rec, nr_link);
- }
- slp->ns_frag = (struct mbuf *)0;
- }
- }
-}
-
-/*
- * Parse an RPC header.
- */
-int
-nfsrv_dorec(slp, nfsd, ndp)
- register struct nfssvc_sock *slp;
- struct nfsd *nfsd;
- struct nfsrv_descript **ndp;
-{
- struct nfsrv_rec *rec;
- register struct mbuf *m;
- struct sockaddr *nam;
- register struct nfsrv_descript *nd;
- int error;
-
- *ndp = NULL;
- if ((slp->ns_flag & SLP_VALID) == 0 || !STAILQ_FIRST(&slp->ns_rec))
- return (ENOBUFS);
- rec = STAILQ_FIRST(&slp->ns_rec);
- STAILQ_REMOVE_HEAD(&slp->ns_rec, nr_link);
- nam = rec->nr_address;
- m = rec->nr_packet;
- free(rec, M_NFSRVDESC);
- MALLOC(nd, struct nfsrv_descript *, sizeof (struct nfsrv_descript),
- M_NFSRVDESC, M_WAITOK);
- nd->nd_md = nd->nd_mrep = m;
- nd->nd_nam2 = nam;
- nd->nd_dpos = mtod(m, caddr_t);
- error = nfs_getreq(nd, nfsd, TRUE);
- if (error) {
- if (nam) {
- FREE(nam, M_SONAME);
- }
- free((caddr_t)nd, M_NFSRVDESC);
- return (error);
- }
- *ndp = nd;
- nfsd->nfsd_nd = nd;
- return (0);
-}
-
-/*
- * Search for a sleeping nfsd and wake it up.
- * SIDE EFFECT: If none found, set NFSD_CHECKSLP flag, so that one of the
- * running nfsds will go look for the work in the nfssvc_sock list.
- */
-void
-nfsrv_wakenfsd(slp)
- struct nfssvc_sock *slp;
-{
- register struct nfsd *nd;
-
- if ((slp->ns_flag & SLP_VALID) == 0)
- return;
- for (nd = nfsd_head.tqh_first; nd != 0; nd = nd->nfsd_chain.tqe_next) {
- if (nd->nfsd_flag & NFSD_WAITING) {
- nd->nfsd_flag &= ~NFSD_WAITING;
- if (nd->nfsd_slp)
- panic("nfsd wakeup");
- slp->ns_sref++;
- nd->nfsd_slp = slp;
- wakeup((caddr_t)nd);
- return;
- }
- }
- slp->ns_flag |= SLP_DOREC;
- nfsd_head_flag |= NFSD_CHECKSLP;
-}
-#endif /* NFS_NOSERVER */
diff --git a/sys/nfsclient/nfs_subs.c b/sys/nfsclient/nfs_subs.c
deleted file mode 100644
index 2e197211f72a..000000000000
--- a/sys/nfsclient/nfs_subs.c
+++ /dev/null
@@ -1,2229 +0,0 @@
-/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Rick Macklem at The University of Guelph.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)nfs_subs.c 8.8 (Berkeley) 5/22/95
- * $FreeBSD$
- */
-
-/*
- * These functions support the macros and help fiddle mbuf chains for
- * the nfs op functions. They do things like create the rpc header and
- * copy data between mbuf chains and uio lists.
- */
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/buf.h>
-#include <sys/proc.h>
-#include <sys/mount.h>
-#include <sys/vnode.h>
-#include <sys/namei.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <sys/malloc.h>
-#include <sys/sysent.h>
-#include <sys/syscall.h>
-#include <sys/conf.h>
-
-#include <vm/vm.h>
-#include <vm/vm_object.h>
-#include <vm/vm_extern.h>
-#include <vm/vm_zone.h>
-
-#include <nfs/rpcv2.h>
-#include <nfs/nfsproto.h>
-#include <nfs/nfs.h>
-#include <nfs/nfsnode.h>
-#include <nfs/xdr_subs.h>
-#include <nfs/nfsm_subs.h>
-#include <nfs/nfsmount.h>
-#include <nfs/nqnfs.h>
-#include <nfs/nfsrtt.h>
-
-#include <netinet/in.h>
-
-/*
- * Data items converted to xdr at startup, since they are constant
- * This is kinda hokey, but may save a little time doing byte swaps
- */
-u_int32_t nfs_xdrneg1;
-u_int32_t rpc_call, rpc_vers, rpc_reply, rpc_msgdenied, rpc_autherr,
- rpc_mismatch, rpc_auth_unix, rpc_msgaccepted,
- rpc_auth_kerb;
-u_int32_t nfs_prog, nqnfs_prog, nfs_true, nfs_false;
-
-/* And other global data */
-static u_int32_t nfs_xid = 0;
-static enum vtype nv2tov_type[8]= {
- VNON, VREG, VDIR, VBLK, VCHR, VLNK, VNON, VNON
-};
-enum vtype nv3tov_type[8]= {
- VNON, VREG, VDIR, VBLK, VCHR, VLNK, VSOCK, VFIFO
-};
-
-int nfs_ticks;
-int nfs_pbuf_freecnt = -1; /* start out unlimited */
-
-struct nfs_reqq nfs_reqq;
-struct nfssvc_sockhead nfssvc_sockhead;
-int nfssvc_sockhead_flag;
-struct nfsd_head nfsd_head;
-int nfsd_head_flag;
-struct nfs_bufq nfs_bufq;
-struct nqtimerhead nqtimerhead;
-struct nqfhhashhead *nqfhhashtbl;
-u_long nqfhhash;
-
-static void (*nfs_prev_lease_updatetime) __P((int));
-static int nfs_prev_nfssvc_sy_narg;
-static sy_call_t *nfs_prev_nfssvc_sy_call;
-
-#ifndef NFS_NOSERVER
-
-static vop_t *nfs_prev_vop_lease_check;
-
-/*
- * Mapping of old NFS Version 2 RPC numbers to generic numbers.
- */
-int nfsv3_procid[NFS_NPROCS] = {
- NFSPROC_NULL,
- NFSPROC_GETATTR,
- NFSPROC_SETATTR,
- NFSPROC_NOOP,
- NFSPROC_LOOKUP,
- NFSPROC_READLINK,
- NFSPROC_READ,
- NFSPROC_NOOP,
- NFSPROC_WRITE,
- NFSPROC_CREATE,
- NFSPROC_REMOVE,
- NFSPROC_RENAME,
- NFSPROC_LINK,
- NFSPROC_SYMLINK,
- NFSPROC_MKDIR,
- NFSPROC_RMDIR,
- NFSPROC_READDIR,
- NFSPROC_FSSTAT,
- NFSPROC_NOOP,
- NFSPROC_NOOP,
- NFSPROC_NOOP,
- NFSPROC_NOOP,
- NFSPROC_NOOP,
- NFSPROC_NOOP,
- NFSPROC_NOOP,
- NFSPROC_NOOP
-};
-
-#endif /* NFS_NOSERVER */
-/*
- * and the reverse mapping from generic to Version 2 procedure numbers
- */
-int nfsv2_procid[NFS_NPROCS] = {
- NFSV2PROC_NULL,
- NFSV2PROC_GETATTR,
- NFSV2PROC_SETATTR,
- NFSV2PROC_LOOKUP,
- NFSV2PROC_NOOP,
- NFSV2PROC_READLINK,
- NFSV2PROC_READ,
- NFSV2PROC_WRITE,
- NFSV2PROC_CREATE,
- NFSV2PROC_MKDIR,
- NFSV2PROC_SYMLINK,
- NFSV2PROC_CREATE,
- NFSV2PROC_REMOVE,
- NFSV2PROC_RMDIR,
- NFSV2PROC_RENAME,
- NFSV2PROC_LINK,
- NFSV2PROC_READDIR,
- NFSV2PROC_NOOP,
- NFSV2PROC_STATFS,
- NFSV2PROC_NOOP,
- NFSV2PROC_NOOP,
- NFSV2PROC_NOOP,
- NFSV2PROC_NOOP,
- NFSV2PROC_NOOP,
- NFSV2PROC_NOOP,
- NFSV2PROC_NOOP,
-};
-
-#ifndef NFS_NOSERVER
-/*
- * Maps errno values to nfs error numbers.
- * Use NFSERR_IO as the catch all for ones not specifically defined in
- * RFC 1094.
- */
-static u_char nfsrv_v2errmap[ELAST] = {
- NFSERR_PERM, NFSERR_NOENT, NFSERR_IO, NFSERR_IO, NFSERR_IO,
- NFSERR_NXIO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
- NFSERR_IO, NFSERR_IO, NFSERR_ACCES, NFSERR_IO, NFSERR_IO,
- NFSERR_IO, NFSERR_EXIST, NFSERR_IO, NFSERR_NODEV, NFSERR_NOTDIR,
- NFSERR_ISDIR, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
- NFSERR_IO, NFSERR_FBIG, NFSERR_NOSPC, NFSERR_IO, NFSERR_ROFS,
- NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
- NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
- NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
- NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
- NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
- NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
- NFSERR_IO, NFSERR_IO, NFSERR_NAMETOL, NFSERR_IO, NFSERR_IO,
- NFSERR_NOTEMPTY, NFSERR_IO, NFSERR_IO, NFSERR_DQUOT, NFSERR_STALE,
- NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
- NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
- NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
- NFSERR_IO /* << Last is 86 */
-};
-
-/*
- * Maps errno values to nfs error numbers.
- * Although it is not obvious whether or not NFS clients really care if
- * a returned error value is in the specified list for the procedure, the
- * safest thing to do is filter them appropriately. For Version 2, the
- * X/Open XNFS document is the only specification that defines error values
- * for each RPC (The RFC simply lists all possible error values for all RPCs),
- * so I have decided to not do this for Version 2.
- * The first entry is the default error return and the rest are the valid
- * errors for that RPC in increasing numeric order.
- */
-static short nfsv3err_null[] = {
- 0,
- 0,
-};
-
-static short nfsv3err_getattr[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_setattr[] = {
- NFSERR_IO,
- NFSERR_PERM,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_INVAL,
- NFSERR_NOSPC,
- NFSERR_ROFS,
- NFSERR_DQUOT,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_NOT_SYNC,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_lookup[] = {
- NFSERR_IO,
- NFSERR_NOENT,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_NOTDIR,
- NFSERR_NAMETOL,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_access[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_readlink[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_INVAL,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_NOTSUPP,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_read[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_NXIO,
- NFSERR_ACCES,
- NFSERR_INVAL,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_write[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_INVAL,
- NFSERR_FBIG,
- NFSERR_NOSPC,
- NFSERR_ROFS,
- NFSERR_DQUOT,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_create[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_EXIST,
- NFSERR_NOTDIR,
- NFSERR_NOSPC,
- NFSERR_ROFS,
- NFSERR_NAMETOL,
- NFSERR_DQUOT,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_NOTSUPP,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_mkdir[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_EXIST,
- NFSERR_NOTDIR,
- NFSERR_NOSPC,
- NFSERR_ROFS,
- NFSERR_NAMETOL,
- NFSERR_DQUOT,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_NOTSUPP,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_symlink[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_EXIST,
- NFSERR_NOTDIR,
- NFSERR_NOSPC,
- NFSERR_ROFS,
- NFSERR_NAMETOL,
- NFSERR_DQUOT,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_NOTSUPP,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_mknod[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_EXIST,
- NFSERR_NOTDIR,
- NFSERR_NOSPC,
- NFSERR_ROFS,
- NFSERR_NAMETOL,
- NFSERR_DQUOT,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_NOTSUPP,
- NFSERR_SERVERFAULT,
- NFSERR_BADTYPE,
- 0,
-};
-
-static short nfsv3err_remove[] = {
- NFSERR_IO,
- NFSERR_NOENT,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_NOTDIR,
- NFSERR_ROFS,
- NFSERR_NAMETOL,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_rmdir[] = {
- NFSERR_IO,
- NFSERR_NOENT,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_EXIST,
- NFSERR_NOTDIR,
- NFSERR_INVAL,
- NFSERR_ROFS,
- NFSERR_NAMETOL,
- NFSERR_NOTEMPTY,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_NOTSUPP,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_rename[] = {
- NFSERR_IO,
- NFSERR_NOENT,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_EXIST,
- NFSERR_XDEV,
- NFSERR_NOTDIR,
- NFSERR_ISDIR,
- NFSERR_INVAL,
- NFSERR_NOSPC,
- NFSERR_ROFS,
- NFSERR_MLINK,
- NFSERR_NAMETOL,
- NFSERR_NOTEMPTY,
- NFSERR_DQUOT,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_NOTSUPP,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_link[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_EXIST,
- NFSERR_XDEV,
- NFSERR_NOTDIR,
- NFSERR_INVAL,
- NFSERR_NOSPC,
- NFSERR_ROFS,
- NFSERR_MLINK,
- NFSERR_NAMETOL,
- NFSERR_DQUOT,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_NOTSUPP,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_readdir[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_NOTDIR,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_BAD_COOKIE,
- NFSERR_TOOSMALL,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_readdirplus[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_NOTDIR,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_BAD_COOKIE,
- NFSERR_NOTSUPP,
- NFSERR_TOOSMALL,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_fsstat[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_fsinfo[] = {
- NFSERR_STALE,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_pathconf[] = {
- NFSERR_STALE,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_commit[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short *nfsrv_v3errmap[] = {
- nfsv3err_null,
- nfsv3err_getattr,
- nfsv3err_setattr,
- nfsv3err_lookup,
- nfsv3err_access,
- nfsv3err_readlink,
- nfsv3err_read,
- nfsv3err_write,
- nfsv3err_create,
- nfsv3err_mkdir,
- nfsv3err_symlink,
- nfsv3err_mknod,
- nfsv3err_remove,
- nfsv3err_rmdir,
- nfsv3err_rename,
- nfsv3err_link,
- nfsv3err_readdir,
- nfsv3err_readdirplus,
- nfsv3err_fsstat,
- nfsv3err_fsinfo,
- nfsv3err_pathconf,
- nfsv3err_commit,
-};
-
-#endif /* NFS_NOSERVER */
-
-extern struct nfsrtt nfsrtt;
-extern time_t nqnfsstarttime;
-extern int nqsrv_clockskew;
-extern int nqsrv_writeslack;
-extern int nqsrv_maxlease;
-extern struct nfsstats nfsstats;
-extern int nqnfs_piggy[NFS_NPROCS];
-extern nfstype nfsv2_type[9];
-extern nfstype nfsv3_type[9];
-extern struct nfsnodehashhead *nfsnodehashtbl;
-extern u_long nfsnodehash;
-
-struct nfssvc_args;
-extern int nfssvc(struct proc *, struct nfssvc_args *, int *);
-
-LIST_HEAD(nfsnodehashhead, nfsnode);
-
-int nfs_webnamei __P((struct nameidata *, struct vnode *, struct proc *));
-
-u_quad_t
-nfs_curusec()
-{
- struct timeval tv;
-
- getmicrotime(&tv);
- return ((u_quad_t)tv.tv_sec * 1000000 + (u_quad_t)tv.tv_usec);
-}
-
-/*
- * Create the header for an rpc request packet
- * The hsiz is the size of the rest of the nfs request header.
- * (just used to decide if a cluster is a good idea)
- */
-struct mbuf *
-nfsm_reqh(vp, procid, hsiz, bposp)
- struct vnode *vp;
- u_long procid;
- int hsiz;
- caddr_t *bposp;
-{
- register struct mbuf *mb;
- register u_int32_t *tl;
- register caddr_t bpos;
- struct mbuf *mb2;
- struct nfsmount *nmp;
- int nqflag;
-
- MGET(mb, M_WAIT, MT_DATA);
- if (hsiz >= MINCLSIZE)
- MCLGET(mb, M_WAIT);
- mb->m_len = 0;
- bpos = mtod(mb, caddr_t);
-
- /*
- * For NQNFS, add lease request.
- */
- if (vp) {
- nmp = VFSTONFS(vp->v_mount);
- if (nmp->nm_flag & NFSMNT_NQNFS) {
- nqflag = NQNFS_NEEDLEASE(vp, procid);
- if (nqflag) {
- nfsm_build(tl, u_int32_t *, 2*NFSX_UNSIGNED);
- *tl++ = txdr_unsigned(nqflag);
- *tl = txdr_unsigned(nmp->nm_leaseterm);
- } else {
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);
- *tl = 0;
- }
- }
- }
- /* Finally, return values */
- *bposp = bpos;
- return (mb);
-}
-
-/*
- * Build the RPC header and fill in the authorization info.
- * The authorization string argument is only used when the credentials
- * come from outside of the kernel.
- * Returns the head of the mbuf list.
- */
-struct mbuf *
-nfsm_rpchead(cr, nmflag, procid, auth_type, auth_len, auth_str, verf_len,
- verf_str, mrest, mrest_len, mbp, xidp)
- register struct ucred *cr;
- int nmflag;
- int procid;
- int auth_type;
- int auth_len;
- char *auth_str;
- int verf_len;
- char *verf_str;
- struct mbuf *mrest;
- int mrest_len;
- struct mbuf **mbp;
- u_int32_t *xidp;
-{
- register struct mbuf *mb;
- register u_int32_t *tl;
- register caddr_t bpos;
- register int i;
- struct mbuf *mreq, *mb2;
- int siz, grpsiz, authsiz;
-
- authsiz = nfsm_rndup(auth_len);
- MGETHDR(mb, M_WAIT, MT_DATA);
- if ((authsiz + 10 * NFSX_UNSIGNED) >= MINCLSIZE) {
- MCLGET(mb, M_WAIT);
- } else if ((authsiz + 10 * NFSX_UNSIGNED) < MHLEN) {
- MH_ALIGN(mb, authsiz + 10 * NFSX_UNSIGNED);
- } else {
- MH_ALIGN(mb, 8 * NFSX_UNSIGNED);
- }
- mb->m_len = 0;
- mreq = mb;
- bpos = mtod(mb, caddr_t);
-
- /*
- * First the RPC header.
- */
- nfsm_build(tl, u_int32_t *, 8 * NFSX_UNSIGNED);
-
- /* Get a pretty random xid to start with */
- if (!nfs_xid)
- nfs_xid = random();
- /*
- * Skip zero xid if it should ever happen.
- */
- if (++nfs_xid == 0)
- nfs_xid++;
-
- *tl++ = *xidp = txdr_unsigned(nfs_xid);
- *tl++ = rpc_call;
- *tl++ = rpc_vers;
- if (nmflag & NFSMNT_NQNFS) {
- *tl++ = txdr_unsigned(NQNFS_PROG);
- *tl++ = txdr_unsigned(NQNFS_VER3);
- } else {
- *tl++ = txdr_unsigned(NFS_PROG);
- if (nmflag & NFSMNT_NFSV3)
- *tl++ = txdr_unsigned(NFS_VER3);
- else
- *tl++ = txdr_unsigned(NFS_VER2);
- }
- if (nmflag & NFSMNT_NFSV3)
- *tl++ = txdr_unsigned(procid);
- else
- *tl++ = txdr_unsigned(nfsv2_procid[procid]);
-
- /*
- * And then the authorization cred.
- */
- *tl++ = txdr_unsigned(auth_type);
- *tl = txdr_unsigned(authsiz);
- switch (auth_type) {
- case RPCAUTH_UNIX:
- nfsm_build(tl, u_int32_t *, auth_len);
- *tl++ = 0; /* stamp ?? */
- *tl++ = 0; /* NULL hostname */
- *tl++ = txdr_unsigned(cr->cr_uid);
- *tl++ = txdr_unsigned(cr->cr_groups[0]);
- grpsiz = (auth_len >> 2) - 5;
- *tl++ = txdr_unsigned(grpsiz);
- for (i = 1; i <= grpsiz; i++)
- *tl++ = txdr_unsigned(cr->cr_groups[i]);
- break;
- case RPCAUTH_KERB4:
- siz = auth_len;
- while (siz > 0) {
- if (M_TRAILINGSPACE(mb) == 0) {
- MGET(mb2, M_WAIT, MT_DATA);
- if (siz >= MINCLSIZE)
- MCLGET(mb2, M_WAIT);
- mb->m_next = mb2;
- mb = mb2;
- mb->m_len = 0;
- bpos = mtod(mb, caddr_t);
- }
- i = min(siz, M_TRAILINGSPACE(mb));
- bcopy(auth_str, bpos, i);
- mb->m_len += i;
- auth_str += i;
- bpos += i;
- siz -= i;
- }
- if ((siz = (nfsm_rndup(auth_len) - auth_len)) > 0) {
- for (i = 0; i < siz; i++)
- *bpos++ = '\0';
- mb->m_len += siz;
- }
- break;
- };
-
- /*
- * And the verifier...
- */
- nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
- if (verf_str) {
- *tl++ = txdr_unsigned(RPCAUTH_KERB4);
- *tl = txdr_unsigned(verf_len);
- siz = verf_len;
- while (siz > 0) {
- if (M_TRAILINGSPACE(mb) == 0) {
- MGET(mb2, M_WAIT, MT_DATA);
- if (siz >= MINCLSIZE)
- MCLGET(mb2, M_WAIT);
- mb->m_next = mb2;
- mb = mb2;
- mb->m_len = 0;
- bpos = mtod(mb, caddr_t);
- }
- i = min(siz, M_TRAILINGSPACE(mb));
- bcopy(verf_str, bpos, i);
- mb->m_len += i;
- verf_str += i;
- bpos += i;
- siz -= i;
- }
- if ((siz = (nfsm_rndup(verf_len) - verf_len)) > 0) {
- for (i = 0; i < siz; i++)
- *bpos++ = '\0';
- mb->m_len += siz;
- }
- } else {
- *tl++ = txdr_unsigned(RPCAUTH_NULL);
- *tl = 0;
- }
- mb->m_next = mrest;
- mreq->m_pkthdr.len = authsiz + 10 * NFSX_UNSIGNED + mrest_len;
- mreq->m_pkthdr.rcvif = (struct ifnet *)0;
- *mbp = mb;
- return (mreq);
-}
-
-/*
- * copies mbuf chain to the uio scatter/gather list
- */
-int
-nfsm_mbuftouio(mrep, uiop, siz, dpos)
- struct mbuf **mrep;
- register struct uio *uiop;
- int siz;
- caddr_t *dpos;
-{
- register char *mbufcp, *uiocp;
- register int xfer, left, len;
- register struct mbuf *mp;
- long uiosiz, rem;
- int error = 0;
-
- mp = *mrep;
- mbufcp = *dpos;
- len = mtod(mp, caddr_t)+mp->m_len-mbufcp;
- rem = nfsm_rndup(siz)-siz;
- while (siz > 0) {
- if (uiop->uio_iovcnt <= 0 || uiop->uio_iov == NULL)
- return (EFBIG);
- left = uiop->uio_iov->iov_len;
- uiocp = uiop->uio_iov->iov_base;
- if (left > siz)
- left = siz;
- uiosiz = left;
- while (left > 0) {
- while (len == 0) {
- mp = mp->m_next;
- if (mp == NULL)
- return (EBADRPC);
- mbufcp = mtod(mp, caddr_t);
- len = mp->m_len;
- }
- xfer = (left > len) ? len : left;
-#ifdef notdef
- /* Not Yet.. */
- if (uiop->uio_iov->iov_op != NULL)
- (*(uiop->uio_iov->iov_op))
- (mbufcp, uiocp, xfer);
- else
-#endif
- if (uiop->uio_segflg == UIO_SYSSPACE)
- bcopy(mbufcp, uiocp, xfer);
- else
- copyout(mbufcp, uiocp, xfer);
- left -= xfer;
- len -= xfer;
- mbufcp += xfer;
- uiocp += xfer;
- uiop->uio_offset += xfer;
- uiop->uio_resid -= xfer;
- }
- if (uiop->uio_iov->iov_len <= siz) {
- uiop->uio_iovcnt--;
- uiop->uio_iov++;
- } else {
- uiop->uio_iov->iov_base += uiosiz;
- uiop->uio_iov->iov_len -= uiosiz;
- }
- siz -= uiosiz;
- }
- *dpos = mbufcp;
- *mrep = mp;
- if (rem > 0) {
- if (len < rem)
- error = nfs_adv(mrep, dpos, rem, len);
- else
- *dpos += rem;
- }
- return (error);
-}
-
-/*
- * copies a uio scatter/gather list to an mbuf chain.
- * NOTE: can ony handle iovcnt == 1
- */
-int
-nfsm_uiotombuf(uiop, mq, siz, bpos)
- register struct uio *uiop;
- struct mbuf **mq;
- int siz;
- caddr_t *bpos;
-{
- register char *uiocp;
- register struct mbuf *mp, *mp2;
- register int xfer, left, mlen;
- int uiosiz, clflg, rem;
- char *cp;
-
-#ifdef DIAGNOSTIC
- if (uiop->uio_iovcnt != 1)
- panic("nfsm_uiotombuf: iovcnt != 1");
-#endif
-
- if (siz > MLEN) /* or should it >= MCLBYTES ?? */
- clflg = 1;
- else
- clflg = 0;
- rem = nfsm_rndup(siz)-siz;
- mp = mp2 = *mq;
- while (siz > 0) {
- left = uiop->uio_iov->iov_len;
- uiocp = uiop->uio_iov->iov_base;
- if (left > siz)
- left = siz;
- uiosiz = left;
- while (left > 0) {
- mlen = M_TRAILINGSPACE(mp);
- if (mlen == 0) {
- MGET(mp, M_WAIT, MT_DATA);
- if (clflg)
- MCLGET(mp, M_WAIT);
- mp->m_len = 0;
- mp2->m_next = mp;
- mp2 = mp;
- mlen = M_TRAILINGSPACE(mp);
- }
- xfer = (left > mlen) ? mlen : left;
-#ifdef notdef
- /* Not Yet.. */
- if (uiop->uio_iov->iov_op != NULL)
- (*(uiop->uio_iov->iov_op))
- (uiocp, mtod(mp, caddr_t)+mp->m_len, xfer);
- else
-#endif
- if (uiop->uio_segflg == UIO_SYSSPACE)
- bcopy(uiocp, mtod(mp, caddr_t)+mp->m_len, xfer);
- else
- copyin(uiocp, mtod(mp, caddr_t)+mp->m_len, xfer);
- mp->m_len += xfer;
- left -= xfer;
- uiocp += xfer;
- uiop->uio_offset += xfer;
- uiop->uio_resid -= xfer;
- }
- uiop->uio_iov->iov_base += uiosiz;
- uiop->uio_iov->iov_len -= uiosiz;
- siz -= uiosiz;
- }
- if (rem > 0) {
- if (rem > M_TRAILINGSPACE(mp)) {
- MGET(mp, M_WAIT, MT_DATA);
- mp->m_len = 0;
- mp2->m_next = mp;
- }
- cp = mtod(mp, caddr_t)+mp->m_len;
- for (left = 0; left < rem; left++)
- *cp++ = '\0';
- mp->m_len += rem;
- *bpos = cp;
- } else
- *bpos = mtod(mp, caddr_t)+mp->m_len;
- *mq = mp;
- return (0);
-}
-
-/*
- * Help break down an mbuf chain by setting the first siz bytes contiguous
- * pointed to by returned val.
- * This is used by the macros nfsm_dissect and nfsm_dissecton for tough
- * cases. (The macros use the vars. dpos and dpos2)
- */
-int
-nfsm_disct(mdp, dposp, siz, left, cp2)
- struct mbuf **mdp;
- caddr_t *dposp;
- int siz;
- int left;
- caddr_t *cp2;
-{
- register struct mbuf *mp, *mp2;
- register int siz2, xfer;
- register caddr_t p;
-
- mp = *mdp;
- while (left == 0) {
- *mdp = mp = mp->m_next;
- if (mp == NULL)
- return (EBADRPC);
- left = mp->m_len;
- *dposp = mtod(mp, caddr_t);
- }
- if (left >= siz) {
- *cp2 = *dposp;
- *dposp += siz;
- } else if (mp->m_next == NULL) {
- return (EBADRPC);
- } else if (siz > MHLEN) {
- panic("nfs S too big");
- } else {
- MGET(mp2, M_WAIT, MT_DATA);
- mp2->m_next = mp->m_next;
- mp->m_next = mp2;
- mp->m_len -= left;
- mp = mp2;
- *cp2 = p = mtod(mp, caddr_t);
- bcopy(*dposp, p, left); /* Copy what was left */
- siz2 = siz-left;
- p += left;
- mp2 = mp->m_next;
- /* Loop around copying up the siz2 bytes */
- while (siz2 > 0) {
- if (mp2 == NULL)
- return (EBADRPC);
- xfer = (siz2 > mp2->m_len) ? mp2->m_len : siz2;
- if (xfer > 0) {
- bcopy(mtod(mp2, caddr_t), p, xfer);
- NFSMADV(mp2, xfer);
- mp2->m_len -= xfer;
- p += xfer;
- siz2 -= xfer;
- }
- if (siz2 > 0)
- mp2 = mp2->m_next;
- }
- mp->m_len = siz;
- *mdp = mp2;
- *dposp = mtod(mp2, caddr_t);
- }
- return (0);
-}
-
-/*
- * Advance the position in the mbuf chain.
- */
-int
-nfs_adv(mdp, dposp, offs, left)
- struct mbuf **mdp;
- caddr_t *dposp;
- int offs;
- int left;
-{
- register struct mbuf *m;
- register int s;
-
- m = *mdp;
- s = left;
- while (s < offs) {
- offs -= s;
- m = m->m_next;
- if (m == NULL)
- return (EBADRPC);
- s = m->m_len;
- }
- *mdp = m;
- *dposp = mtod(m, caddr_t)+offs;
- return (0);
-}
-
-/*
- * Copy a string into mbufs for the hard cases...
- */
-int
-nfsm_strtmbuf(mb, bpos, cp, siz)
- struct mbuf **mb;
- char **bpos;
- const char *cp;
- long siz;
-{
- register struct mbuf *m1 = NULL, *m2;
- long left, xfer, len, tlen;
- u_int32_t *tl;
- int putsize;
-
- putsize = 1;
- m2 = *mb;
- left = M_TRAILINGSPACE(m2);
- if (left > 0) {
- tl = ((u_int32_t *)(*bpos));
- *tl++ = txdr_unsigned(siz);
- putsize = 0;
- left -= NFSX_UNSIGNED;
- m2->m_len += NFSX_UNSIGNED;
- if (left > 0) {
- bcopy(cp, (caddr_t) tl, left);
- siz -= left;
- cp += left;
- m2->m_len += left;
- left = 0;
- }
- }
- /* Loop around adding mbufs */
- while (siz > 0) {
- MGET(m1, M_WAIT, MT_DATA);
- if (siz > MLEN)
- MCLGET(m1, M_WAIT);
- m1->m_len = NFSMSIZ(m1);
- m2->m_next = m1;
- m2 = m1;
- tl = mtod(m1, u_int32_t *);
- tlen = 0;
- if (putsize) {
- *tl++ = txdr_unsigned(siz);
- m1->m_len -= NFSX_UNSIGNED;
- tlen = NFSX_UNSIGNED;
- putsize = 0;
- }
- if (siz < m1->m_len) {
- len = nfsm_rndup(siz);
- xfer = siz;
- if (xfer < len)
- *(tl+(xfer>>2)) = 0;
- } else {
- xfer = len = m1->m_len;
- }
- bcopy(cp, (caddr_t) tl, xfer);
- m1->m_len = len+tlen;
- siz -= xfer;
- cp += xfer;
- }
- *mb = m1;
- *bpos = mtod(m1, caddr_t)+m1->m_len;
- return (0);
-}
-
-/*
- * Called once to initialize data structures...
- */
-int
-nfs_init(vfsp)
- struct vfsconf *vfsp;
-{
- register int i;
-
- nfsmount_zone = zinit("NFSMOUNT", sizeof(struct nfsmount), 0, 0, 1);
-
- nfs_mount_type = vfsp->vfc_typenum;
- nfsrtt.pos = 0;
- rpc_vers = txdr_unsigned(RPC_VER2);
- rpc_call = txdr_unsigned(RPC_CALL);
- rpc_reply = txdr_unsigned(RPC_REPLY);
- rpc_msgdenied = txdr_unsigned(RPC_MSGDENIED);
- rpc_msgaccepted = txdr_unsigned(RPC_MSGACCEPTED);
- rpc_mismatch = txdr_unsigned(RPC_MISMATCH);
- rpc_autherr = txdr_unsigned(RPC_AUTHERR);
- rpc_auth_unix = txdr_unsigned(RPCAUTH_UNIX);
- rpc_auth_kerb = txdr_unsigned(RPCAUTH_KERB4);
- nfs_prog = txdr_unsigned(NFS_PROG);
- nqnfs_prog = txdr_unsigned(NQNFS_PROG);
- nfs_true = txdr_unsigned(TRUE);
- nfs_false = txdr_unsigned(FALSE);
- nfs_xdrneg1 = txdr_unsigned(-1);
- nfs_ticks = (hz * NFS_TICKINTVL + 500) / 1000;
- if (nfs_ticks < 1)
- nfs_ticks = 1;
- /* Ensure async daemons disabled */
- for (i = 0; i < NFS_MAXASYNCDAEMON; i++) {
- nfs_iodwant[i] = (struct proc *)0;
- nfs_iodmount[i] = (struct nfsmount *)0;
- }
- nfs_nhinit(); /* Init the nfsnode table */
-#ifndef NFS_NOSERVER
- nfsrv_init(0); /* Init server data structures */
- nfsrv_initcache(); /* Init the server request cache */
-#endif
-
- /*
- * Initialize the nqnfs server stuff.
- */
- if (nqnfsstarttime == 0) {
- nqnfsstarttime = boottime.tv_sec + nqsrv_maxlease
- + nqsrv_clockskew + nqsrv_writeslack;
- NQLOADNOVRAM(nqnfsstarttime);
- CIRCLEQ_INIT(&nqtimerhead);
- nqfhhashtbl = hashinit(NQLCHSZ, M_NQLEASE, &nqfhhash);
- }
-
- /*
- * Initialize reply list and start timer
- */
- TAILQ_INIT(&nfs_reqq);
-
- nfs_timer(0);
-
- /*
- * Set up lease_check and lease_updatetime so that other parts
- * of the system can call us, if we are loadable.
- */
-#ifndef NFS_NOSERVER
- nfs_prev_vop_lease_check = default_vnodeop_p[VOFFSET(vop_lease)];
- default_vnodeop_p[VOFFSET(vop_lease)] = (vop_t *)nqnfs_vop_lease_check;
-#endif
- nfs_prev_lease_updatetime = lease_updatetime;
- lease_updatetime = nfs_lease_updatetime;
- nfs_prev_nfssvc_sy_narg = sysent[SYS_nfssvc].sy_narg;
- sysent[SYS_nfssvc].sy_narg = 2;
- nfs_prev_nfssvc_sy_call = sysent[SYS_nfssvc].sy_call;
- sysent[SYS_nfssvc].sy_call = (sy_call_t *)nfssvc;
-
- nfs_pbuf_freecnt = nswbuf / 2 + 1;
-
- return (0);
-}
-
-int
-nfs_uninit(vfsp)
- struct vfsconf *vfsp;
-{
-
- untimeout(nfs_timer, (void *)NULL, nfs_timer_handle);
- nfs_mount_type = -1;
-#ifndef NFS_NOSERVER
- default_vnodeop_p[VOFFSET(vop_lease)] = nfs_prev_vop_lease_check;
-#endif
- lease_updatetime = nfs_prev_lease_updatetime;
- sysent[SYS_nfssvc].sy_narg = nfs_prev_nfssvc_sy_narg;
- sysent[SYS_nfssvc].sy_call = nfs_prev_nfssvc_sy_call;
- return (0);
-}
-
-/*
- * Attribute cache routines.
- * nfs_loadattrcache() - loads or updates the cache contents from attributes
- * that are on the mbuf list
- * nfs_getattrcache() - returns valid attributes if found in cache, returns
- * error otherwise
- */
-
-/*
- * Load the attribute cache (that lives in the nfsnode entry) with
- * the values on the mbuf list and
- * Iff vap not NULL
- * copy the attributes to *vaper
- */
-int
-nfs_loadattrcache(vpp, mdp, dposp, vaper)
- struct vnode **vpp;
- struct mbuf **mdp;
- caddr_t *dposp;
- struct vattr *vaper;
-{
- register struct vnode *vp = *vpp;
- register struct vattr *vap;
- register struct nfs_fattr *fp;
- register struct nfsnode *np;
- register int32_t t1;
- caddr_t cp2;
- int error = 0, rdev;
- struct mbuf *md;
- enum vtype vtyp;
- u_short vmode;
- struct timespec mtime;
- int v3 = NFS_ISV3(vp);
-
- md = *mdp;
- t1 = (mtod(md, caddr_t) + md->m_len) - *dposp;
- if ((error = nfsm_disct(mdp, dposp, NFSX_FATTR(v3), t1, &cp2)) != 0)
- return (error);
- fp = (struct nfs_fattr *)cp2;
- if (v3) {
- vtyp = nfsv3tov_type(fp->fa_type);
- vmode = fxdr_unsigned(u_short, fp->fa_mode);
- rdev = makeudev(fxdr_unsigned(int, fp->fa3_rdev.specdata1),
- fxdr_unsigned(int, fp->fa3_rdev.specdata2));
- fxdr_nfsv3time(&fp->fa3_mtime, &mtime);
- } else {
- vtyp = nfsv2tov_type(fp->fa_type);
- vmode = fxdr_unsigned(u_short, fp->fa_mode);
- /*
- * XXX
- *
- * The duplicate information returned in fa_type and fa_mode
- * is an ambiguity in the NFS version 2 protocol.
- *
- * VREG should be taken literally as a regular file. If a
- * server intents to return some type information differently
- * in the upper bits of the mode field (e.g. for sockets, or
- * FIFOs), NFSv2 mandates fa_type to be VNON. Anyway, we
- * leave the examination of the mode bits even in the VREG
- * case to avoid breakage for bogus servers, but we make sure
- * that there are actually type bits set in the upper part of
- * fa_mode (and failing that, trust the va_type field).
- *
- * NFSv3 cleared the issue, and requires fa_mode to not
- * contain any type information (while also introduing sockets
- * and FIFOs for fa_type).
- */
- if (vtyp == VNON || (vtyp == VREG && (vmode & S_IFMT) != 0))
- vtyp = IFTOVT(vmode);
- rdev = fxdr_unsigned(int32_t, fp->fa2_rdev);
- fxdr_nfsv2time(&fp->fa2_mtime, &mtime);
-
- /*
- * Really ugly NFSv2 kludge.
- */
- if (vtyp == VCHR && rdev == 0xffffffff)
- vtyp = VFIFO;
- }
-
- /*
- * If v_type == VNON it is a new node, so fill in the v_type,
- * n_mtime fields. Check to see if it represents a special
- * device, and if so, check for a possible alias. Once the
- * correct vnode has been obtained, fill in the rest of the
- * information.
- */
- np = VTONFS(vp);
- if (vp->v_type != vtyp) {
- vp->v_type = vtyp;
- if (vp->v_type == VFIFO) {
- vp->v_op = fifo_nfsv2nodeop_p;
- }
- if (vp->v_type == VCHR || vp->v_type == VBLK) {
- vp->v_op = spec_nfsv2nodeop_p;
- addaliasu(vp, rdev);
- }
- np->n_mtime = mtime.tv_sec;
- }
- vap = &np->n_vattr;
- vap->va_type = vtyp;
- vap->va_mode = (vmode & 07777);
- vap->va_rdev = rdev;
- vap->va_mtime = mtime;
- vap->va_fsid = vp->v_mount->mnt_stat.f_fsid.val[0];
- if (v3) {
- vap->va_nlink = fxdr_unsigned(u_short, fp->fa_nlink);
- vap->va_uid = fxdr_unsigned(uid_t, fp->fa_uid);
- vap->va_gid = fxdr_unsigned(gid_t, fp->fa_gid);
- vap->va_size = fxdr_hyper(&fp->fa3_size);
- vap->va_blocksize = NFS_FABLKSIZE;
- vap->va_bytes = fxdr_hyper(&fp->fa3_used);
- vap->va_fileid = fxdr_unsigned(int32_t,
- fp->fa3_fileid.nfsuquad[1]);
- fxdr_nfsv3time(&fp->fa3_atime, &vap->va_atime);
- fxdr_nfsv3time(&fp->fa3_ctime, &vap->va_ctime);
- vap->va_flags = 0;
- vap->va_filerev = 0;
- } else {
- vap->va_nlink = fxdr_unsigned(u_short, fp->fa_nlink);
- vap->va_uid = fxdr_unsigned(uid_t, fp->fa_uid);
- vap->va_gid = fxdr_unsigned(gid_t, fp->fa_gid);
- vap->va_size = fxdr_unsigned(u_int32_t, fp->fa2_size);
- vap->va_blocksize = fxdr_unsigned(int32_t, fp->fa2_blocksize);
- vap->va_bytes = (u_quad_t)fxdr_unsigned(int32_t, fp->fa2_blocks)
- * NFS_FABLKSIZE;
- vap->va_fileid = fxdr_unsigned(int32_t, fp->fa2_fileid);
- fxdr_nfsv2time(&fp->fa2_atime, &vap->va_atime);
- vap->va_flags = 0;
- vap->va_ctime.tv_sec = fxdr_unsigned(u_int32_t,
- fp->fa2_ctime.nfsv2_sec);
- vap->va_ctime.tv_nsec = 0;
- vap->va_gen = fxdr_unsigned(u_int32_t,fp->fa2_ctime.nfsv2_usec);
- vap->va_filerev = 0;
- }
- if (vap->va_size != np->n_size) {
- if (vap->va_type == VREG) {
- if (np->n_flag & NMODIFIED) {
- if (vap->va_size < np->n_size)
- vap->va_size = np->n_size;
- else
- np->n_size = vap->va_size;
- } else {
- np->n_size = vap->va_size;
- }
- vnode_pager_setsize(vp, np->n_size);
- } else {
- np->n_size = vap->va_size;
- }
- }
- np->n_attrstamp = time_second;
- if (vaper != NULL) {
- bcopy((caddr_t)vap, (caddr_t)vaper, sizeof(*vap));
- if (np->n_flag & NCHG) {
- if (np->n_flag & NACC)
- vaper->va_atime = np->n_atim;
- if (np->n_flag & NUPD)
- vaper->va_mtime = np->n_mtim;
- }
- }
- return (0);
-}
-
-#ifdef NFS_ACDEBUG
-#include <sys/sysctl.h>
-SYSCTL_DECL(_vfs_nfs);
-static int nfs_acdebug;
-SYSCTL_INT(_vfs_nfs, OID_AUTO, acdebug, CTLFLAG_RW, &nfs_acdebug, 0, "");
-#endif
-
-/*
- * Check the time stamp
- * If the cache is valid, copy contents to *vap and return 0
- * otherwise return an error
- */
-int
-nfs_getattrcache(vp, vaper)
- register struct vnode *vp;
- struct vattr *vaper;
-{
- register struct nfsnode *np;
- register struct vattr *vap;
- struct nfsmount *nmp;
- int timeo;
-
- np = VTONFS(vp);
- vap = &np->n_vattr;
- nmp = VFSTONFS(vp->v_mount);
- /* XXX n_mtime doesn't seem to be updated on a miss-and-reload */
- timeo = (time_second - np->n_mtime) / 10;
-
-#ifdef NFS_ACDEBUG
- if (nfs_acdebug>1)
- printf("nfs_getattrcache: initial timeo = %d\n", timeo);
-#endif
-
- if (vap->va_type == VDIR) {
- if ((np->n_flag & NMODIFIED) || timeo < nmp->nm_acdirmin)
- timeo = nmp->nm_acdirmin;
- else if (timeo > nmp->nm_acdirmax)
- timeo = nmp->nm_acdirmax;
- } else {
- if ((np->n_flag & NMODIFIED) || timeo < nmp->nm_acregmin)
- timeo = nmp->nm_acregmin;
- else if (timeo > nmp->nm_acregmax)
- timeo = nmp->nm_acregmax;
- }
-
-#ifdef NFS_ACDEBUG
- if (nfs_acdebug > 2)
- printf("acregmin %d; acregmax %d; acdirmin %d; acdirmax %d\n",
- nmp->nm_acregmin, nmp->nm_acregmax,
- nmp->nm_acdirmin, nmp->nm_acdirmax);
-
- if (nfs_acdebug)
- printf("nfs_getattrcache: age = %d; final timeo = %d\n",
- (time_second - np->n_attrstamp), timeo);
-#endif
-
- if ((time_second - np->n_attrstamp) >= timeo) {
- nfsstats.attrcache_misses++;
- return (ENOENT);
- }
- nfsstats.attrcache_hits++;
- if (vap->va_size != np->n_size) {
- if (vap->va_type == VREG) {
- if (np->n_flag & NMODIFIED) {
- if (vap->va_size < np->n_size)
- vap->va_size = np->n_size;
- else
- np->n_size = vap->va_size;
- } else {
- np->n_size = vap->va_size;
- }
- vnode_pager_setsize(vp, np->n_size);
- } else {
- np->n_size = vap->va_size;
- }
- }
- bcopy((caddr_t)vap, (caddr_t)vaper, sizeof(struct vattr));
- if (np->n_flag & NCHG) {
- if (np->n_flag & NACC)
- vaper->va_atime = np->n_atim;
- if (np->n_flag & NUPD)
- vaper->va_mtime = np->n_mtim;
- }
- return (0);
-}
-
-#ifndef NFS_NOSERVER
-/*
- * Set up nameidata for a lookup() call and do it.
- *
- * If pubflag is set, this call is done for a lookup operation on the
- * public filehandle. In that case we allow crossing mountpoints and
- * absolute pathnames. However, the caller is expected to check that
- * the lookup result is within the public fs, and deny access if
- * it is not.
- *
- * nfs_namei() clears out garbage fields that namei() might leave garbage.
- * This is mainly ni_vp and ni_dvp when an error occurs, and ni_dvp when no
- * error occurs but the parent was not requested.
- *
- * dirp may be set whether an error is returned or not, and must be
- * released by the caller.
- */
-int
-nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag, pubflag)
- register struct nameidata *ndp;
- fhandle_t *fhp;
- int len;
- struct nfssvc_sock *slp;
- struct sockaddr *nam;
- struct mbuf **mdp;
- caddr_t *dposp;
- struct vnode **retdirp;
- struct proc *p;
- int kerbflag, pubflag;
-{
- register int i, rem;
- register struct mbuf *md;
- register char *fromcp, *tocp, *cp;
- struct iovec aiov;
- struct uio auio;
- struct vnode *dp;
- int error, rdonly, linklen;
- struct componentname *cnp = &ndp->ni_cnd;
-
- *retdirp = (struct vnode *)0;
- cnp->cn_pnbuf = zalloc(namei_zone);
-
- /*
- * Copy the name from the mbuf list to ndp->ni_pnbuf
- * and set the various ndp fields appropriately.
- */
- fromcp = *dposp;
- tocp = cnp->cn_pnbuf;
- md = *mdp;
- rem = mtod(md, caddr_t) + md->m_len - fromcp;
- for (i = 0; i < len; i++) {
- while (rem == 0) {
- md = md->m_next;
- if (md == NULL) {
- error = EBADRPC;
- goto out;
- }
- fromcp = mtod(md, caddr_t);
- rem = md->m_len;
- }
- if (*fromcp == '\0' || (!pubflag && *fromcp == '/')) {
- error = EACCES;
- goto out;
- }
- *tocp++ = *fromcp++;
- rem--;
- }
- *tocp = '\0';
- *mdp = md;
- *dposp = fromcp;
- len = nfsm_rndup(len)-len;
- if (len > 0) {
- if (rem >= len)
- *dposp += len;
- else if ((error = nfs_adv(mdp, dposp, len, rem)) != 0)
- goto out;
- }
-
- /*
- * Extract and set starting directory.
- */
- error = nfsrv_fhtovp(fhp, FALSE, &dp, ndp->ni_cnd.cn_cred, slp,
- nam, &rdonly, kerbflag, pubflag);
- if (error)
- goto out;
- if (dp->v_type != VDIR) {
- vrele(dp);
- error = ENOTDIR;
- goto out;
- }
-
- if (rdonly)
- cnp->cn_flags |= RDONLY;
-
- /*
- * Set return directory. Reference to dp is implicitly transfered
- * to the returned pointer
- */
- *retdirp = dp;
-
- if (pubflag) {
- /*
- * Oh joy. For WebNFS, handle those pesky '%' escapes,
- * and the 'native path' indicator.
- */
- cp = zalloc(namei_zone);
- fromcp = cnp->cn_pnbuf;
- tocp = cp;
- if ((unsigned char)*fromcp >= WEBNFS_SPECCHAR_START) {
- switch ((unsigned char)*fromcp) {
- case WEBNFS_NATIVE_CHAR:
- /*
- * 'Native' path for us is the same
- * as a path according to the NFS spec,
- * just skip the escape char.
- */
- fromcp++;
- break;
- /*
- * More may be added in the future, range 0x80-0xff
- */
- default:
- error = EIO;
- zfree(namei_zone, cp);
- goto out;
- }
- }
- /*
- * Translate the '%' escapes, URL-style.
- */
- while (*fromcp != '\0') {
- if (*fromcp == WEBNFS_ESC_CHAR) {
- if (fromcp[1] != '\0' && fromcp[2] != '\0') {
- fromcp++;
- *tocp++ = HEXSTRTOI(fromcp);
- fromcp += 2;
- continue;
- } else {
- error = ENOENT;
- zfree(namei_zone, cp);
- goto out;
- }
- } else
- *tocp++ = *fromcp++;
- }
- *tocp = '\0';
- zfree(namei_zone, cnp->cn_pnbuf);
- cnp->cn_pnbuf = cp;
- }
-
- ndp->ni_pathlen = (tocp - cnp->cn_pnbuf) + 1;
- ndp->ni_segflg = UIO_SYSSPACE;
-
- if (pubflag) {
- ndp->ni_rootdir = rootvnode;
- ndp->ni_loopcnt = 0;
- if (cnp->cn_pnbuf[0] == '/')
- dp = rootvnode;
- } else {
- cnp->cn_flags |= NOCROSSMOUNT;
- }
-
- /*
- * Initialize for scan, set ni_startdir and bump ref on dp again
- * becuase lookup() will dereference ni_startdir.
- */
-
- cnp->cn_proc = p;
- VREF(dp);
- ndp->ni_startdir = dp;
-
- for (;;) {
- cnp->cn_nameptr = cnp->cn_pnbuf;
- /*
- * Call lookup() to do the real work. If an error occurs,
- * ndp->ni_vp and ni_dvp are left uninitialized or NULL and
- * we do not have to dereference anything before returning.
- * In either case ni_startdir will be dereferenced and NULLed
- * out.
- */
- error = lookup(ndp);
- if (error)
- break;
-
- /*
- * Check for encountering a symbolic link. Trivial
- * termination occurs if no symlink encountered.
- * Note: zfree is safe because error is 0, so we will
- * not zfree it again when we break.
- */
- if ((cnp->cn_flags & ISSYMLINK) == 0) {
- nfsrv_object_create(ndp->ni_vp);
- if (cnp->cn_flags & (SAVENAME | SAVESTART))
- cnp->cn_flags |= HASBUF;
- else
- zfree(namei_zone, cnp->cn_pnbuf);
- break;
- }
-
- /*
- * Validate symlink
- */
- if ((cnp->cn_flags & LOCKPARENT) && ndp->ni_pathlen == 1)
- VOP_UNLOCK(ndp->ni_dvp, 0, p);
- if (!pubflag) {
- error = EINVAL;
- goto badlink2;
- }
-
- if (ndp->ni_loopcnt++ >= MAXSYMLINKS) {
- error = ELOOP;
- goto badlink2;
- }
- if (ndp->ni_pathlen > 1)
- cp = zalloc(namei_zone);
- else
- cp = cnp->cn_pnbuf;
- aiov.iov_base = cp;
- aiov.iov_len = MAXPATHLEN;
- auio.uio_iov = &aiov;
- auio.uio_iovcnt = 1;
- auio.uio_offset = 0;
- auio.uio_rw = UIO_READ;
- auio.uio_segflg = UIO_SYSSPACE;
- auio.uio_procp = (struct proc *)0;
- auio.uio_resid = MAXPATHLEN;
- error = VOP_READLINK(ndp->ni_vp, &auio, cnp->cn_cred);
- if (error) {
- badlink1:
- if (ndp->ni_pathlen > 1)
- zfree(namei_zone, cp);
- badlink2:
- vrele(ndp->ni_dvp);
- vput(ndp->ni_vp);
- break;
- }
- linklen = MAXPATHLEN - auio.uio_resid;
- if (linklen == 0) {
- error = ENOENT;
- goto badlink1;
- }
- if (linklen + ndp->ni_pathlen >= MAXPATHLEN) {
- error = ENAMETOOLONG;
- goto badlink1;
- }
-
- /*
- * Adjust or replace path
- */
- if (ndp->ni_pathlen > 1) {
- bcopy(ndp->ni_next, cp + linklen, ndp->ni_pathlen);
- zfree(namei_zone, cnp->cn_pnbuf);
- cnp->cn_pnbuf = cp;
- } else
- cnp->cn_pnbuf[linklen] = '\0';
- ndp->ni_pathlen += linklen;
-
- /*
- * Cleanup refs for next loop and check if root directory
- * should replace current directory. Normally ni_dvp
- * becomes the new base directory and is cleaned up when
- * we loop. Explicitly null pointers after invalidation
- * to clarify operation.
- */
- vput(ndp->ni_vp);
- ndp->ni_vp = NULL;
-
- if (cnp->cn_pnbuf[0] == '/') {
- vrele(ndp->ni_dvp);
- ndp->ni_dvp = ndp->ni_rootdir;
- VREF(ndp->ni_dvp);
- }
- ndp->ni_startdir = ndp->ni_dvp;
- ndp->ni_dvp = NULL;
- }
-
- /*
- * nfs_namei() guarentees that fields will not contain garbage
- * whether an error occurs or not. This allows the caller to track
- * cleanup state trivially.
- */
-out:
- if (error) {
- zfree(namei_zone, cnp->cn_pnbuf);
- ndp->ni_vp = NULL;
- ndp->ni_dvp = NULL;
- ndp->ni_startdir = NULL;
- cnp->cn_flags &= ~HASBUF;
- } else if ((ndp->ni_cnd.cn_flags & (WANTPARENT|LOCKPARENT)) == 0) {
- ndp->ni_dvp = NULL;
- }
- return (error);
-}
-
-/*
- * A fiddled version of m_adj() that ensures null fill to a long
- * boundary and only trims off the back end
- */
-void
-nfsm_adj(mp, len, nul)
- struct mbuf *mp;
- register int len;
- int nul;
-{
- register struct mbuf *m;
- register int count, i;
- register char *cp;
-
- /*
- * Trim from tail. Scan the mbuf chain,
- * calculating its length and finding the last mbuf.
- * If the adjustment only affects this mbuf, then just
- * adjust and return. Otherwise, rescan and truncate
- * after the remaining size.
- */
- count = 0;
- m = mp;
- for (;;) {
- count += m->m_len;
- if (m->m_next == (struct mbuf *)0)
- break;
- m = m->m_next;
- }
- if (m->m_len > len) {
- m->m_len -= len;
- if (nul > 0) {
- cp = mtod(m, caddr_t)+m->m_len-nul;
- for (i = 0; i < nul; i++)
- *cp++ = '\0';
- }
- return;
- }
- count -= len;
- if (count < 0)
- count = 0;
- /*
- * Correct length for chain is "count".
- * Find the mbuf with last data, adjust its length,
- * and toss data from remaining mbufs on chain.
- */
- for (m = mp; m; m = m->m_next) {
- if (m->m_len >= count) {
- m->m_len = count;
- if (nul > 0) {
- cp = mtod(m, caddr_t)+m->m_len-nul;
- for (i = 0; i < nul; i++)
- *cp++ = '\0';
- }
- break;
- }
- count -= m->m_len;
- }
- for (m = m->m_next;m;m = m->m_next)
- m->m_len = 0;
-}
-
-/*
- * Make these functions instead of macros, so that the kernel text size
- * doesn't get too big...
- */
-void
-nfsm_srvwcc(nfsd, before_ret, before_vap, after_ret, after_vap, mbp, bposp)
- struct nfsrv_descript *nfsd;
- int before_ret;
- register struct vattr *before_vap;
- int after_ret;
- struct vattr *after_vap;
- struct mbuf **mbp;
- char **bposp;
-{
- register struct mbuf *mb = *mbp, *mb2;
- register char *bpos = *bposp;
- register u_int32_t *tl;
-
- if (before_ret) {
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);
- *tl = nfs_false;
- } else {
- nfsm_build(tl, u_int32_t *, 7 * NFSX_UNSIGNED);
- *tl++ = nfs_true;
- txdr_hyper(before_vap->va_size, tl);
- tl += 2;
- txdr_nfsv3time(&(before_vap->va_mtime), tl);
- tl += 2;
- txdr_nfsv3time(&(before_vap->va_ctime), tl);
- }
- *bposp = bpos;
- *mbp = mb;
- nfsm_srvpostopattr(nfsd, after_ret, after_vap, mbp, bposp);
-}
-
-void
-nfsm_srvpostopattr(nfsd, after_ret, after_vap, mbp, bposp)
- struct nfsrv_descript *nfsd;
- int after_ret;
- struct vattr *after_vap;
- struct mbuf **mbp;
- char **bposp;
-{
- register struct mbuf *mb = *mbp, *mb2;
- register char *bpos = *bposp;
- register u_int32_t *tl;
- register struct nfs_fattr *fp;
-
- if (after_ret) {
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);
- *tl = nfs_false;
- } else {
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED + NFSX_V3FATTR);
- *tl++ = nfs_true;
- fp = (struct nfs_fattr *)tl;
- nfsm_srvfattr(nfsd, after_vap, fp);
- }
- *mbp = mb;
- *bposp = bpos;
-}
-
-void
-nfsm_srvfattr(nfsd, vap, fp)
- register struct nfsrv_descript *nfsd;
- register struct vattr *vap;
- register struct nfs_fattr *fp;
-{
-
- fp->fa_nlink = txdr_unsigned(vap->va_nlink);
- fp->fa_uid = txdr_unsigned(vap->va_uid);
- fp->fa_gid = txdr_unsigned(vap->va_gid);
- if (nfsd->nd_flag & ND_NFSV3) {
- fp->fa_type = vtonfsv3_type(vap->va_type);
- fp->fa_mode = vtonfsv3_mode(vap->va_mode);
- txdr_hyper(vap->va_size, &fp->fa3_size);
- txdr_hyper(vap->va_bytes, &fp->fa3_used);
- fp->fa3_rdev.specdata1 = txdr_unsigned(umajor(vap->va_rdev));
- fp->fa3_rdev.specdata2 = txdr_unsigned(uminor(vap->va_rdev));
- fp->fa3_fsid.nfsuquad[0] = 0;
- fp->fa3_fsid.nfsuquad[1] = txdr_unsigned(vap->va_fsid);
- fp->fa3_fileid.nfsuquad[0] = 0;
- fp->fa3_fileid.nfsuquad[1] = txdr_unsigned(vap->va_fileid);
- txdr_nfsv3time(&vap->va_atime, &fp->fa3_atime);
- txdr_nfsv3time(&vap->va_mtime, &fp->fa3_mtime);
- txdr_nfsv3time(&vap->va_ctime, &fp->fa3_ctime);
- } else {
- fp->fa_type = vtonfsv2_type(vap->va_type);
- fp->fa_mode = vtonfsv2_mode(vap->va_type, vap->va_mode);
- fp->fa2_size = txdr_unsigned(vap->va_size);
- fp->fa2_blocksize = txdr_unsigned(vap->va_blocksize);
- if (vap->va_type == VFIFO)
- fp->fa2_rdev = 0xffffffff;
- else
- fp->fa2_rdev = txdr_unsigned(vap->va_rdev);
- fp->fa2_blocks = txdr_unsigned(vap->va_bytes / NFS_FABLKSIZE);
- fp->fa2_fsid = txdr_unsigned(vap->va_fsid);
- fp->fa2_fileid = txdr_unsigned(vap->va_fileid);
- txdr_nfsv2time(&vap->va_atime, &fp->fa2_atime);
- txdr_nfsv2time(&vap->va_mtime, &fp->fa2_mtime);
- txdr_nfsv2time(&vap->va_ctime, &fp->fa2_ctime);
- }
-}
-
-/*
- * nfsrv_fhtovp() - convert a fh to a vnode ptr (optionally locked)
- * - look up fsid in mount list (if not found ret error)
- * - get vp and export rights by calling VFS_FHTOVP()
- * - if cred->cr_uid == 0 or MNT_EXPORTANON set it to credanon
- * - if not lockflag unlock it with VOP_UNLOCK()
- */
-int
-nfsrv_fhtovp(fhp, lockflag, vpp, cred, slp, nam, rdonlyp, kerbflag, pubflag)
- fhandle_t *fhp;
- int lockflag;
- struct vnode **vpp;
- struct ucred *cred;
- struct nfssvc_sock *slp;
- struct sockaddr *nam;
- int *rdonlyp;
- int kerbflag;
- int pubflag;
-{
- struct proc *p = curproc; /* XXX */
- register struct mount *mp;
- register int i;
- struct ucred *credanon;
- int error, exflags;
-#ifdef MNT_EXNORESPORT /* XXX needs mountd and /etc/exports help yet */
- struct sockaddr_int *saddr;
-#endif
-
- *vpp = (struct vnode *)0;
-
- if (nfs_ispublicfh(fhp)) {
- if (!pubflag || !nfs_pub.np_valid)
- return (ESTALE);
- fhp = &nfs_pub.np_handle;
- }
-
- mp = vfs_getvfs(&fhp->fh_fsid);
- if (!mp)
- return (ESTALE);
- error = VFS_CHECKEXP(mp, nam, &exflags, &credanon);
- if (error)
- return (error);
- error = VFS_FHTOVP(mp, &fhp->fh_fid, vpp);
- if (error)
- return (error);
-#ifdef MNT_EXNORESPORT
- if (!(exflags & (MNT_EXNORESPORT|MNT_EXPUBLIC))) {
- saddr = (struct sockaddr_in *)nam;
- if (saddr->sin_family == AF_INET &&
- ntohs(saddr->sin_port) >= IPPORT_RESERVED) {
- vput(*vpp);
- *vpp = NULL;
- return (NFSERR_AUTHERR | AUTH_TOOWEAK);
- }
- }
-#endif
- /*
- * Check/setup credentials.
- */
- if (exflags & MNT_EXKERB) {
- if (!kerbflag) {
- vput(*vpp);
- *vpp = NULL;
- return (NFSERR_AUTHERR | AUTH_TOOWEAK);
- }
- } else if (kerbflag) {
- vput(*vpp);
- *vpp = NULL;
- return (NFSERR_AUTHERR | AUTH_TOOWEAK);
- } else if (cred->cr_uid == 0 || (exflags & MNT_EXPORTANON)) {
- cred->cr_uid = credanon->cr_uid;
- for (i = 0; i < credanon->cr_ngroups && i < NGROUPS; i++)
- cred->cr_groups[i] = credanon->cr_groups[i];
- cred->cr_ngroups = i;
- }
- if (exflags & MNT_EXRDONLY)
- *rdonlyp = 1;
- else
- *rdonlyp = 0;
-
- nfsrv_object_create(*vpp);
-
- if (!lockflag)
- VOP_UNLOCK(*vpp, 0, p);
- return (0);
-}
-
-
-/*
- * WebNFS: check if a filehandle is a public filehandle. For v3, this
- * means a length of 0, for v2 it means all zeroes. nfsm_srvmtofh has
- * transformed this to all zeroes in both cases, so check for it.
- */
-int
-nfs_ispublicfh(fhp)
- fhandle_t *fhp;
-{
- char *cp = (char *)fhp;
- int i;
-
- for (i = 0; i < NFSX_V3FH; i++)
- if (*cp++ != 0)
- return (FALSE);
- return (TRUE);
-}
-
-#endif /* NFS_NOSERVER */
-/*
- * This function compares two net addresses by family and returns TRUE
- * if they are the same host.
- * If there is any doubt, return FALSE.
- * The AF_INET family is handled as a special case so that address mbufs
- * don't need to be saved to store "struct in_addr", which is only 4 bytes.
- */
-int
-netaddr_match(family, haddr, nam)
- int family;
- union nethostaddr *haddr;
- struct sockaddr *nam;
-{
- register struct sockaddr_in *inetaddr;
-
- switch (family) {
- case AF_INET:
- inetaddr = (struct sockaddr_in *)nam;
- if (inetaddr->sin_family == AF_INET &&
- inetaddr->sin_addr.s_addr == haddr->had_inetaddr)
- return (1);
- break;
- default:
- break;
- };
- return (0);
-}
-
-static nfsuint64 nfs_nullcookie = { { 0, 0 } };
-/*
- * This function finds the directory cookie that corresponds to the
- * logical byte offset given.
- */
-nfsuint64 *
-nfs_getcookie(np, off, add)
- register struct nfsnode *np;
- off_t off;
- int add;
-{
- register struct nfsdmap *dp, *dp2;
- register int pos;
-
- pos = (uoff_t)off / NFS_DIRBLKSIZ;
- if (pos == 0 || off < 0) {
-#ifdef DIAGNOSTIC
- if (add)
- panic("nfs getcookie add at <= 0");
-#endif
- return (&nfs_nullcookie);
- }
- pos--;
- dp = np->n_cookies.lh_first;
- if (!dp) {
- if (add) {
- MALLOC(dp, struct nfsdmap *, sizeof (struct nfsdmap),
- M_NFSDIROFF, M_WAITOK);
- dp->ndm_eocookie = 0;
- LIST_INSERT_HEAD(&np->n_cookies, dp, ndm_list);
- } else
- return ((nfsuint64 *)0);
- }
- while (pos >= NFSNUMCOOKIES) {
- pos -= NFSNUMCOOKIES;
- if (dp->ndm_list.le_next) {
- if (!add && dp->ndm_eocookie < NFSNUMCOOKIES &&
- pos >= dp->ndm_eocookie)
- return ((nfsuint64 *)0);
- dp = dp->ndm_list.le_next;
- } else if (add) {
- MALLOC(dp2, struct nfsdmap *, sizeof (struct nfsdmap),
- M_NFSDIROFF, M_WAITOK);
- dp2->ndm_eocookie = 0;
- LIST_INSERT_AFTER(dp, dp2, ndm_list);
- dp = dp2;
- } else
- return ((nfsuint64 *)0);
- }
- if (pos >= dp->ndm_eocookie) {
- if (add)
- dp->ndm_eocookie = pos + 1;
- else
- return ((nfsuint64 *)0);
- }
- return (&dp->ndm_cookies[pos]);
-}
-
-/*
- * Invalidate cached directory information, except for the actual directory
- * blocks (which are invalidated separately).
- * Done mainly to avoid the use of stale offset cookies.
- */
-void
-nfs_invaldir(vp)
- register struct vnode *vp;
-{
- register struct nfsnode *np = VTONFS(vp);
-
-#ifdef DIAGNOSTIC
- if (vp->v_type != VDIR)
- panic("nfs: invaldir not dir");
-#endif
- np->n_direofoffset = 0;
- np->n_cookieverf.nfsuquad[0] = 0;
- np->n_cookieverf.nfsuquad[1] = 0;
- if (np->n_cookies.lh_first)
- np->n_cookies.lh_first->ndm_eocookie = 0;
-}
-
-/*
- * The write verifier has changed (probably due to a server reboot), so all
- * B_NEEDCOMMIT blocks will have to be written again. Since they are on the
- * dirty block list as B_DELWRI, all this takes is clearing the B_NEEDCOMMIT
- * and B_CLUSTEROK flags. Once done the new write verifier can be set for the
- * mount point.
- *
- * B_CLUSTEROK must be cleared along with B_NEEDCOMMIT because stage 1 data
- * writes are not clusterable.
- */
-void
-nfs_clearcommit(mp)
- struct mount *mp;
-{
- register struct vnode *vp, *nvp;
- register struct buf *bp, *nbp;
- int s;
-
- s = splbio();
-loop:
- for (vp = mp->mnt_vnodelist.lh_first; vp; vp = nvp) {
- if (vp->v_mount != mp) /* Paranoia */
- goto loop;
- nvp = vp->v_mntvnodes.le_next;
- for (bp = TAILQ_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) {
- nbp = TAILQ_NEXT(bp, b_vnbufs);
- if (BUF_REFCNT(bp) == 0 &&
- (bp->b_flags & (B_DELWRI | B_NEEDCOMMIT))
- == (B_DELWRI | B_NEEDCOMMIT))
- bp->b_flags &= ~(B_NEEDCOMMIT | B_CLUSTEROK);
- }
- }
- splx(s);
-}
-
-#ifndef NFS_NOSERVER
-/*
- * Map errnos to NFS error numbers. For Version 3 also filter out error
- * numbers not specified for the associated procedure.
- */
-int
-nfsrv_errmap(nd, err)
- struct nfsrv_descript *nd;
- register int err;
-{
- register short *defaulterrp, *errp;
-
- if (nd->nd_flag & ND_NFSV3) {
- if (nd->nd_procnum <= NFSPROC_COMMIT) {
- errp = defaulterrp = nfsrv_v3errmap[nd->nd_procnum];
- while (*++errp) {
- if (*errp == err)
- return (err);
- else if (*errp > err)
- break;
- }
- return ((int)*defaulterrp);
- } else
- return (err & 0xffff);
- }
- if (err <= ELAST)
- return ((int)nfsrv_v2errmap[err - 1]);
- return (NFSERR_IO);
-}
-
-int
-nfsrv_object_create(vp)
- struct vnode *vp;
-{
-
- if (vp == NULL || vp->v_type != VREG)
- return (1);
- return (vfs_object_create(vp, curproc,
- curproc ? curproc->p_ucred : NULL));
-}
-
-/*
- * Sort the group list in increasing numerical order.
- * (Insertion sort by Chris Torek, who was grossed out by the bubble sort
- * that used to be here.)
- */
-void
-nfsrvw_sort(list, num)
- register gid_t *list;
- register int num;
-{
- register int i, j;
- gid_t v;
-
- /* Insertion sort. */
- for (i = 1; i < num; i++) {
- v = list[i];
- /* find correct slot for value v, moving others up */
- for (j = i; --j >= 0 && v < list[j];)
- list[j + 1] = list[j];
- list[j + 1] = v;
- }
-}
-
-/*
- * copy credentials making sure that the result can be compared with bcmp().
- */
-void
-nfsrv_setcred(incred, outcred)
- register struct ucred *incred, *outcred;
-{
- register int i;
-
- bzero((caddr_t)outcred, sizeof (struct ucred));
- outcred->cr_ref = 1;
- outcred->cr_uid = incred->cr_uid;
- outcred->cr_ngroups = incred->cr_ngroups;
- for (i = 0; i < incred->cr_ngroups; i++)
- outcred->cr_groups[i] = incred->cr_groups[i];
- nfsrvw_sort(outcred->cr_groups, outcred->cr_ngroups);
-}
-#endif /* NFS_NOSERVER */
diff --git a/sys/nfsclient/nfs_vfsops.c b/sys/nfsclient/nfs_vfsops.c
deleted file mode 100644
index c2d365b319f8..000000000000
--- a/sys/nfsclient/nfs_vfsops.c
+++ /dev/null
@@ -1,1090 +0,0 @@
-/*
- * Copyright (c) 1989, 1993, 1995
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Rick Macklem at The University of Guelph.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)nfs_vfsops.c 8.12 (Berkeley) 5/20/95
- * $FreeBSD$
- */
-
-#include "opt_bootp.h"
-
-#include <sys/param.h>
-#include <sys/sockio.h>
-#include <sys/proc.h>
-#include <sys/vnode.h>
-#include <sys/kernel.h>
-#include <sys/sysctl.h>
-#include <sys/malloc.h>
-#include <sys/mount.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-#include <sys/systm.h>
-
-#include <vm/vm.h>
-#include <vm/vm_extern.h>
-#include <vm/vm_zone.h>
-
-#include <net/if.h>
-#include <net/route.h>
-#include <netinet/in.h>
-
-#include <nfs/rpcv2.h>
-#include <nfs/nfsproto.h>
-#include <nfs/nfs.h>
-#include <nfs/nfsnode.h>
-#include <nfs/nfsmount.h>
-#include <nfs/xdr_subs.h>
-#include <nfs/nfsm_subs.h>
-#include <nfs/nfsdiskless.h>
-#include <nfs/nqnfs.h>
-
-extern int nfs_mountroot __P((struct mount *mp));
-
-extern int nfs_ticks;
-
-MALLOC_DEFINE(M_NFSREQ, "NFS req", "NFS request header");
-MALLOC_DEFINE(M_NFSBIGFH, "NFSV3 bigfh", "NFS version 3 file handle");
-MALLOC_DEFINE(M_NFSD, "NFS daemon", "Nfs server daemon structure");
-MALLOC_DEFINE(M_NFSDIROFF, "NFSV3 diroff", "NFS directory offset data");
-MALLOC_DEFINE(M_NFSRVDESC, "NFSV3 srvdesc", "NFS server socket descriptor");
-MALLOC_DEFINE(M_NFSUID, "NFS uid", "Nfs uid mapping structure");
-MALLOC_DEFINE(M_NQLEASE, "NQNFS Lease", "Nqnfs lease");
-MALLOC_DEFINE(M_NFSHASH, "NFS hash", "NFS hash tables");
-
-vm_zone_t nfsmount_zone;
-
-struct nfsstats nfsstats;
-SYSCTL_NODE(_vfs, OID_AUTO, nfs, CTLFLAG_RW, 0, "NFS filesystem");
-SYSCTL_STRUCT(_vfs_nfs, NFS_NFSSTATS, nfsstats, CTLFLAG_RD,
- &nfsstats, nfsstats, "");
-#ifdef NFS_DEBUG
-int nfs_debug;
-SYSCTL_INT(_vfs_nfs, OID_AUTO, debug, CTLFLAG_RW, &nfs_debug, 0, "");
-#endif
-
-static int nfs_iosize __P((struct nfsmount *nmp));
-static void nfs_decode_args __P((struct nfsmount *nmp,
- struct nfs_args *argp));
-static int mountnfs __P((struct nfs_args *,struct mount *,
- struct sockaddr *,char *,char *,struct vnode **));
-static int nfs_mount __P(( struct mount *mp, char *path, caddr_t data,
- struct nameidata *ndp, struct proc *p));
-static int nfs_unmount __P(( struct mount *mp, int mntflags,
- struct proc *p));
-static int nfs_root __P(( struct mount *mp, struct vnode **vpp));
-static int nfs_statfs __P(( struct mount *mp, struct statfs *sbp,
- struct proc *p));
-static int nfs_sync __P(( struct mount *mp, int waitfor,
- struct ucred *cred, struct proc *p));
-
-/*
- * nfs vfs operations.
- */
-static struct vfsops nfs_vfsops = {
- nfs_mount,
- vfs_stdstart,
- nfs_unmount,
- nfs_root,
- vfs_stdquotactl,
- nfs_statfs,
- nfs_sync,
- vfs_stdvget,
- vfs_stdfhtovp, /* shouldn't happen */
- vfs_stdcheckexp,
- vfs_stdvptofh, /* shouldn't happen */
- nfs_init,
- nfs_uninit,
- vfs_stdextattrctl,
-};
-VFS_SET(nfs_vfsops, nfs, VFCF_NETWORK);
-
-/*
- * This structure must be filled in by a primary bootstrap or bootstrap
- * server for a diskless/dataless machine. It is initialized below just
- * to ensure that it is allocated to initialized data (.data not .bss).
- */
-struct nfs_diskless nfs_diskless = { { { 0 } } };
-struct nfsv3_diskless nfsv3_diskless = { { { 0 } } };
-int nfs_diskless_valid = 0;
-
-SYSCTL_INT(_vfs_nfs, OID_AUTO, diskless_valid, CTLFLAG_RD,
- &nfs_diskless_valid, 0, "");
-
-SYSCTL_STRING(_vfs_nfs, OID_AUTO, diskless_rootpath, CTLFLAG_RD,
- nfsv3_diskless.root_hostnam, 0, "");
-
-SYSCTL_OPAQUE(_vfs_nfs, OID_AUTO, diskless_rootaddr, CTLFLAG_RD,
- &nfsv3_diskless.root_saddr, sizeof nfsv3_diskless.root_saddr,
- "%Ssockaddr_in", "");
-
-SYSCTL_STRING(_vfs_nfs, OID_AUTO, diskless_swappath, CTLFLAG_RD,
- nfsv3_diskless.swap_hostnam, 0, "");
-
-SYSCTL_OPAQUE(_vfs_nfs, OID_AUTO, diskless_swapaddr, CTLFLAG_RD,
- &nfsv3_diskless.swap_saddr, sizeof nfsv3_diskless.swap_saddr,
- "%Ssockaddr_in","");
-
-
-void nfsargs_ntoh __P((struct nfs_args *));
-static int nfs_mountdiskless __P((char *, char *, int,
- struct sockaddr_in *, struct nfs_args *,
- struct proc *, struct vnode **,
- struct mount **));
-static void nfs_convert_diskless __P((void));
-static void nfs_convert_oargs __P((struct nfs_args *args,
- struct onfs_args *oargs));
-
-static int
-nfs_iosize(nmp)
- struct nfsmount* nmp;
-{
- int iosize;
-
- /*
- * Calculate the size used for io buffers. Use the larger
- * of the two sizes to minimise nfs requests but make sure
- * that it is at least one VM page to avoid wasting buffer
- * space.
- */
- iosize = max(nmp->nm_rsize, nmp->nm_wsize);
- if (iosize < PAGE_SIZE) iosize = PAGE_SIZE;
- return iosize;
-}
-
-static void
-nfs_convert_oargs(args, oargs)
- struct nfs_args *args;
- struct onfs_args *oargs;
-{
- args->version = NFS_ARGSVERSION;
- args->addr = oargs->addr;
- args->addrlen = oargs->addrlen;
- args->sotype = oargs->sotype;
- args->proto = oargs->proto;
- args->fh = oargs->fh;
- args->fhsize = oargs->fhsize;
- args->flags = oargs->flags;
- args->wsize = oargs->wsize;
- args->rsize = oargs->rsize;
- args->readdirsize = oargs->readdirsize;
- args->timeo = oargs->timeo;
- args->retrans = oargs->retrans;
- args->maxgrouplist = oargs->maxgrouplist;
- args->readahead = oargs->readahead;
- args->leaseterm = oargs->leaseterm;
- args->deadthresh = oargs->deadthresh;
- args->hostname = oargs->hostname;
-}
-
-static void
-nfs_convert_diskless()
-{
- bcopy(&nfs_diskless.myif, &nfsv3_diskless.myif,
- sizeof(struct ifaliasreq));
- bcopy(&nfs_diskless.mygateway, &nfsv3_diskless.mygateway,
- sizeof(struct sockaddr_in));
- nfs_convert_oargs(&nfsv3_diskless.swap_args,&nfs_diskless.swap_args);
- nfsv3_diskless.swap_fhsize = NFSX_V2FH;
- bcopy(nfs_diskless.swap_fh,nfsv3_diskless.swap_fh,NFSX_V2FH);
- bcopy(&nfs_diskless.swap_saddr,&nfsv3_diskless.swap_saddr,
- sizeof(struct sockaddr_in));
- bcopy(nfs_diskless.swap_hostnam,nfsv3_diskless.swap_hostnam, MNAMELEN);
- nfsv3_diskless.swap_nblks = nfs_diskless.swap_nblks;
- bcopy(&nfs_diskless.swap_ucred, &nfsv3_diskless.swap_ucred,
- sizeof(struct ucred));
- nfs_convert_oargs(&nfsv3_diskless.root_args,&nfs_diskless.root_args);
- nfsv3_diskless.root_fhsize = NFSX_V2FH;
- bcopy(nfs_diskless.root_fh,nfsv3_diskless.root_fh,NFSX_V2FH);
- bcopy(&nfs_diskless.root_saddr,&nfsv3_diskless.root_saddr,
- sizeof(struct sockaddr_in));
- bcopy(nfs_diskless.root_hostnam,nfsv3_diskless.root_hostnam, MNAMELEN);
- nfsv3_diskless.root_time = nfs_diskless.root_time;
- bcopy(nfs_diskless.my_hostnam,nfsv3_diskless.my_hostnam,
- MAXHOSTNAMELEN);
- nfs_diskless_valid = 3;
-}
-
-/*
- * nfs statfs call
- */
-int
-nfs_statfs(mp, sbp, p)
- struct mount *mp;
- register struct statfs *sbp;
- struct proc *p;
-{
- register struct vnode *vp;
- register struct nfs_statfs *sfp;
- register caddr_t cp;
- register u_int32_t *tl;
- register int32_t t1, t2;
- caddr_t bpos, dpos, cp2;
- struct nfsmount *nmp = VFSTONFS(mp);
- int error = 0, v3 = (nmp->nm_flag & NFSMNT_NFSV3), retattr;
- struct mbuf *mreq, *mrep, *md, *mb, *mb2;
- struct ucred *cred;
- struct nfsnode *np;
- u_quad_t tquad;
-
-#ifndef nolint
- sfp = (struct nfs_statfs *)0;
-#endif
- error = nfs_nget(mp, (nfsfh_t *)nmp->nm_fh, nmp->nm_fhsize, &np);
- if (error)
- return (error);
- vp = NFSTOV(np);
- cred = crget();
- cred->cr_ngroups = 1;
- if (v3 && (nmp->nm_state & NFSSTA_GOTFSINFO) == 0)
- (void)nfs_fsinfo(nmp, vp, cred, p);
- nfsstats.rpccnt[NFSPROC_FSSTAT]++;
- nfsm_reqhead(vp, NFSPROC_FSSTAT, NFSX_FH(v3));
- nfsm_fhtom(vp, v3);
- nfsm_request(vp, NFSPROC_FSSTAT, p, cred);
- if (v3)
- nfsm_postop_attr(vp, retattr);
- if (error) {
- if (mrep != NULL)
- m_freem(mrep);
- goto nfsmout;
- }
- nfsm_dissect(sfp, struct nfs_statfs *, NFSX_STATFS(v3));
- sbp->f_flags = nmp->nm_flag;
- sbp->f_iosize = nfs_iosize(nmp);
- if (v3) {
- sbp->f_bsize = NFS_FABLKSIZE;
- tquad = fxdr_hyper(&sfp->sf_tbytes);
- sbp->f_blocks = (long)(tquad / ((u_quad_t)NFS_FABLKSIZE));
- tquad = fxdr_hyper(&sfp->sf_fbytes);
- sbp->f_bfree = (long)(tquad / ((u_quad_t)NFS_FABLKSIZE));
- tquad = fxdr_hyper(&sfp->sf_abytes);
- sbp->f_bavail = (long)(tquad / ((u_quad_t)NFS_FABLKSIZE));
- sbp->f_files = (fxdr_unsigned(int32_t,
- sfp->sf_tfiles.nfsuquad[1]) & 0x7fffffff);
- sbp->f_ffree = (fxdr_unsigned(int32_t,
- sfp->sf_ffiles.nfsuquad[1]) & 0x7fffffff);
- } else {
- sbp->f_bsize = fxdr_unsigned(int32_t, sfp->sf_bsize);
- sbp->f_blocks = fxdr_unsigned(int32_t, sfp->sf_blocks);
- sbp->f_bfree = fxdr_unsigned(int32_t, sfp->sf_bfree);
- sbp->f_bavail = fxdr_unsigned(int32_t, sfp->sf_bavail);
- sbp->f_files = 0;
- sbp->f_ffree = 0;
- }
- if (sbp != &mp->mnt_stat) {
- sbp->f_type = mp->mnt_vfc->vfc_typenum;
- bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN);
- bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN);
- }
- nfsm_reqdone;
- vput(vp);
- crfree(cred);
- return (error);
-}
-
-/*
- * nfs version 3 fsinfo rpc call
- */
-int
-nfs_fsinfo(nmp, vp, cred, p)
- register struct nfsmount *nmp;
- register struct vnode *vp;
- struct ucred *cred;
- struct proc *p;
-{
- register struct nfsv3_fsinfo *fsp;
- register caddr_t cp;
- register int32_t t1, t2;
- register u_int32_t *tl, pref, max;
- caddr_t bpos, dpos, cp2;
- int error = 0, retattr;
- struct mbuf *mreq, *mrep, *md, *mb, *mb2;
- u_int64_t maxfsize;
-
- nfsstats.rpccnt[NFSPROC_FSINFO]++;
- nfsm_reqhead(vp, NFSPROC_FSINFO, NFSX_FH(1));
- nfsm_fhtom(vp, 1);
- nfsm_request(vp, NFSPROC_FSINFO, p, cred);
- nfsm_postop_attr(vp, retattr);
- if (!error) {
- nfsm_dissect(fsp, struct nfsv3_fsinfo *, NFSX_V3FSINFO);
- pref = fxdr_unsigned(u_int32_t, fsp->fs_wtpref);
- if (pref < nmp->nm_wsize && pref >= NFS_FABLKSIZE)
- nmp->nm_wsize = (pref + NFS_FABLKSIZE - 1) &
- ~(NFS_FABLKSIZE - 1);
- max = fxdr_unsigned(u_int32_t, fsp->fs_wtmax);
- if (max < nmp->nm_wsize && max > 0) {
- nmp->nm_wsize = max & ~(NFS_FABLKSIZE - 1);
- if (nmp->nm_wsize == 0)
- nmp->nm_wsize = max;
- }
- pref = fxdr_unsigned(u_int32_t, fsp->fs_rtpref);
- if (pref < nmp->nm_rsize && pref >= NFS_FABLKSIZE)
- nmp->nm_rsize = (pref + NFS_FABLKSIZE - 1) &
- ~(NFS_FABLKSIZE - 1);
- max = fxdr_unsigned(u_int32_t, fsp->fs_rtmax);
- if (max < nmp->nm_rsize && max > 0) {
- nmp->nm_rsize = max & ~(NFS_FABLKSIZE - 1);
- if (nmp->nm_rsize == 0)
- nmp->nm_rsize = max;
- }
- pref = fxdr_unsigned(u_int32_t, fsp->fs_dtpref);
- if (pref < nmp->nm_readdirsize && pref >= NFS_DIRBLKSIZ)
- nmp->nm_readdirsize = (pref + NFS_DIRBLKSIZ - 1) &
- ~(NFS_DIRBLKSIZ - 1);
- if (max < nmp->nm_readdirsize && max > 0) {
- nmp->nm_readdirsize = max & ~(NFS_DIRBLKSIZ - 1);
- if (nmp->nm_readdirsize == 0)
- nmp->nm_readdirsize = max;
- }
- maxfsize = fxdr_hyper(&fsp->fs_maxfilesize);
- if (maxfsize > 0 && maxfsize < nmp->nm_maxfilesize)
- nmp->nm_maxfilesize = maxfsize;
- nmp->nm_state |= NFSSTA_GOTFSINFO;
- }
- nfsm_reqdone;
- return (error);
-}
-
-/*
- * Mount a remote root fs via. nfs. This depends on the info in the
- * nfs_diskless structure that has been filled in properly by some primary
- * bootstrap.
- * It goes something like this:
- * - do enough of "ifconfig" by calling ifioctl() so that the system
- * can talk to the server
- * - If nfs_diskless.mygateway is filled in, use that address as
- * a default gateway.
- * - build the rootfs mount point and call mountnfs() to do the rest.
- */
-int
-nfs_mountroot(mp)
- struct mount *mp;
-{
- struct mount *swap_mp;
- struct nfsv3_diskless *nd = &nfsv3_diskless;
- struct socket *so;
- struct vnode *vp;
- struct proc *p = curproc; /* XXX */
- int error, i;
- u_long l;
- char buf[128];
-
-#if defined(BOOTP_NFSROOT) && defined(BOOTP)
- bootpc_init(); /* use bootp to get nfs_diskless filled in */
-#endif
-
- /*
- * XXX time must be non-zero when we init the interface or else
- * the arp code will wedge...
- */
- while (time_second == 0)
- tsleep(&time_second, PZERO+8, "arpkludge", 10);
-
- if (nfs_diskless_valid==1)
- nfs_convert_diskless();
-
- /*
- * XXX splnet, so networks will receive...
- */
- splnet();
-
-#ifdef notyet
- /* Set up swap credentials. */
- proc0.p_ucred->cr_uid = ntohl(nd->swap_ucred.cr_uid);
- proc0.p_ucred->cr_gid = ntohl(nd->swap_ucred.cr_gid);
- if ((proc0.p_ucred->cr_ngroups = ntohs(nd->swap_ucred.cr_ngroups)) >
- NGROUPS)
- proc0.p_ucred->cr_ngroups = NGROUPS;
- for (i = 0; i < proc0.p_ucred->cr_ngroups; i++)
- proc0.p_ucred->cr_groups[i] = ntohl(nd->swap_ucred.cr_groups[i]);
-#endif
-
- /*
- * Do enough of ifconfig(8) so that the critical net interface can
- * talk to the server.
- */
- error = socreate(nd->myif.ifra_addr.sa_family, &so, SOCK_DGRAM, 0, p);
- if (error)
- panic("nfs_mountroot: socreate(%04x): %d",
- nd->myif.ifra_addr.sa_family, error);
-
- /*
- * We might not have been told the right interface, so we pass
- * over the first ten interfaces of the same kind, until we get
- * one of them configured.
- */
-
- for (i = strlen(nd->myif.ifra_name) - 1;
- nd->myif.ifra_name[i] >= '0' &&
- nd->myif.ifra_name[i] <= '9';
- nd->myif.ifra_name[i] ++) {
- error = ifioctl(so, SIOCAIFADDR, (caddr_t)&nd->myif, p);
- if(!error)
- break;
- }
- if (error)
- panic("nfs_mountroot: SIOCAIFADDR: %d", error);
- soclose(so);
-
- /*
- * If the gateway field is filled in, set it as the default route.
- */
- if (nd->mygateway.sin_len != 0) {
- struct sockaddr_in mask, sin;
-
- bzero((caddr_t)&mask, sizeof(mask));
- sin = mask;
- sin.sin_family = AF_INET;
- sin.sin_len = sizeof(sin);
- error = rtrequest(RTM_ADD, (struct sockaddr *)&sin,
- (struct sockaddr *)&nd->mygateway,
- (struct sockaddr *)&mask,
- RTF_UP | RTF_GATEWAY, (struct rtentry **)0);
- if (error)
- panic("nfs_mountroot: RTM_ADD: %d", error);
- }
-
- /*
- * Create the rootfs mount point.
- */
- nd->root_args.fh = nd->root_fh;
- nd->root_args.fhsize = nd->root_fhsize;
- l = ntohl(nd->root_saddr.sin_addr.s_addr);
- snprintf(buf, sizeof(buf), "%ld.%ld.%ld.%ld:%s",
- (l >> 24) & 0xff, (l >> 16) & 0xff,
- (l >> 8) & 0xff, (l >> 0) & 0xff,nd->root_hostnam);
- printf("NFS ROOT: %s\n",buf);
- if ((error = nfs_mountdiskless(buf, "/", MNT_RDONLY,
- &nd->root_saddr, &nd->root_args, p, &vp, &mp)) != 0) {
- if (swap_mp) {
- mp->mnt_vfc->vfc_refcount--;
- free(swap_mp, M_MOUNT);
- }
- return (error);
- }
-
- swap_mp = NULL;
- if (nd->swap_nblks) {
-
- /* Convert to DEV_BSIZE instead of Kilobyte */
- nd->swap_nblks *= 2;
-
- /*
- * Create a fake mount point just for the swap vnode so that the
- * swap file can be on a different server from the rootfs.
- */
- nd->swap_args.fh = nd->swap_fh;
- nd->swap_args.fhsize = nd->swap_fhsize;
- l = ntohl(nd->swap_saddr.sin_addr.s_addr);
- snprintf(buf, sizeof(buf), "%ld.%ld.%ld.%ld:%s",
- (l >> 24) & 0xff, (l >> 16) & 0xff,
- (l >> 8) & 0xff, (l >> 0) & 0xff,nd->swap_hostnam);
- printf("NFS SWAP: %s\n",buf);
- if ((error = nfs_mountdiskless(buf, "/swap", 0,
- &nd->swap_saddr, &nd->swap_args, p, &vp, &swap_mp)) != 0)
- return (error);
- vfs_unbusy(swap_mp, p);
-
- VTONFS(vp)->n_size = VTONFS(vp)->n_vattr.va_size =
- nd->swap_nblks * DEV_BSIZE ;
-
- /*
- * Since the swap file is not the root dir of a file system,
- * hack it to a regular file.
- */
- vp->v_type = VREG;
- vp->v_flag = 0;
- VREF(vp);
- swaponvp(p, vp, NODEV, nd->swap_nblks);
- }
-
- mp->mnt_flag |= MNT_ROOTFS;
- mp->mnt_vnodecovered = NULLVP;
- rootvp = vp;
- vfs_unbusy(mp, p);
-
- /*
- * This is not really an nfs issue, but it is much easier to
- * set hostname here and then let the "/etc/rc.xxx" files
- * mount the right /var based upon its preset value.
- */
- bcopy(nd->my_hostnam, hostname, MAXHOSTNAMELEN);
- hostname[MAXHOSTNAMELEN - 1] = '\0';
- for (i = 0; i < MAXHOSTNAMELEN; i++)
- if (hostname[i] == '\0')
- break;
- inittodr(ntohl(nd->root_time));
- return (0);
-}
-
-/*
- * Internal version of mount system call for diskless setup.
- */
-static int
-nfs_mountdiskless(path, which, mountflag, sin, args, p, vpp, mpp)
- char *path;
- char *which;
- int mountflag;
- struct sockaddr_in *sin;
- struct nfs_args *args;
- struct proc *p;
- struct vnode **vpp;
- struct mount **mpp;
-{
- struct mount *mp;
- struct sockaddr *nam;
- int error;
-
- mp = *mpp;
-
- if (!mp && (error = vfs_rootmountalloc("nfs", path, &mp))) {
- printf("nfs_mountroot: NFS not configured");
- return (error);
- }
-
- mp->mnt_kern_flag = 0;
- mp->mnt_flag = mountflag;
- nam = dup_sockaddr((struct sockaddr *)sin, 1);
- if ((error = mountnfs(args, mp, nam, which, path, vpp)) != 0) {
- printf("nfs_mountroot: mount %s on %s: %d", path, which, error);
- mp->mnt_vfc->vfc_refcount--;
- vfs_unbusy(mp, p);
- free(mp, M_MOUNT);
- FREE(nam, M_SONAME);
- return (error);
- }
- (void) copystr(which, mp->mnt_stat.f_mntonname, MNAMELEN - 1, 0);
- *mpp = mp;
- return (0);
-}
-
-static void
-nfs_decode_args(nmp, argp)
- struct nfsmount *nmp;
- struct nfs_args *argp;
-{
- int s;
- int adjsock;
- int maxio;
-
- s = splnet();
- /*
- * Silently clear NFSMNT_NOCONN if it's a TCP mount, it makes
- * no sense in that context.
- */
- if (argp->sotype == SOCK_STREAM)
- nmp->nm_flag &= ~NFSMNT_NOCONN;
-
- /* Also clear RDIRPLUS if not NFSv3, it crashes some servers */
- if ((argp->flags & NFSMNT_NFSV3) == 0)
- nmp->nm_flag &= ~NFSMNT_RDIRPLUS;
-
- /* Re-bind if rsrvd port requested and wasn't on one */
- adjsock = !(nmp->nm_flag & NFSMNT_RESVPORT)
- && (argp->flags & NFSMNT_RESVPORT);
- /* Also re-bind if we're switching to/from a connected UDP socket */
- adjsock |= ((nmp->nm_flag & NFSMNT_NOCONN) !=
- (argp->flags & NFSMNT_NOCONN));
-
- /* Update flags atomically. Don't change the lock bits. */
- nmp->nm_flag = argp->flags | nmp->nm_flag;
- splx(s);
-
- if ((argp->flags & NFSMNT_TIMEO) && argp->timeo > 0) {
- nmp->nm_timeo = (argp->timeo * NFS_HZ + 5) / 10;
- if (nmp->nm_timeo < NFS_MINTIMEO)
- nmp->nm_timeo = NFS_MINTIMEO;
- else if (nmp->nm_timeo > NFS_MAXTIMEO)
- nmp->nm_timeo = NFS_MAXTIMEO;
- }
-
- if ((argp->flags & NFSMNT_RETRANS) && argp->retrans > 1) {
- nmp->nm_retry = argp->retrans;
- if (nmp->nm_retry > NFS_MAXREXMIT)
- nmp->nm_retry = NFS_MAXREXMIT;
- }
-
- if (argp->flags & NFSMNT_NFSV3) {
- if (argp->sotype == SOCK_DGRAM)
- maxio = NFS_MAXDGRAMDATA;
- else
- maxio = NFS_MAXDATA;
- } else
- maxio = NFS_V2MAXDATA;
-
- if ((argp->flags & NFSMNT_WSIZE) && argp->wsize > 0) {
- nmp->nm_wsize = argp->wsize;
- /* Round down to multiple of blocksize */
- nmp->nm_wsize &= ~(NFS_FABLKSIZE - 1);
- if (nmp->nm_wsize <= 0)
- nmp->nm_wsize = NFS_FABLKSIZE;
- }
- if (nmp->nm_wsize > maxio)
- nmp->nm_wsize = maxio;
- if (nmp->nm_wsize > MAXBSIZE)
- nmp->nm_wsize = MAXBSIZE;
-
- if ((argp->flags & NFSMNT_RSIZE) && argp->rsize > 0) {
- nmp->nm_rsize = argp->rsize;
- /* Round down to multiple of blocksize */
- nmp->nm_rsize &= ~(NFS_FABLKSIZE - 1);
- if (nmp->nm_rsize <= 0)
- nmp->nm_rsize = NFS_FABLKSIZE;
- }
- if (nmp->nm_rsize > maxio)
- nmp->nm_rsize = maxio;
- if (nmp->nm_rsize > MAXBSIZE)
- nmp->nm_rsize = MAXBSIZE;
-
- if ((argp->flags & NFSMNT_READDIRSIZE) && argp->readdirsize > 0) {
- nmp->nm_readdirsize = argp->readdirsize;
- }
- if (nmp->nm_readdirsize > maxio)
- nmp->nm_readdirsize = maxio;
- if (nmp->nm_readdirsize > nmp->nm_rsize)
- nmp->nm_readdirsize = nmp->nm_rsize;
-
- if ((argp->flags & NFSMNT_ACREGMIN) && argp->acregmin >= 0)
- nmp->nm_acregmin = argp->acregmin;
- else
- nmp->nm_acregmin = NFS_MINATTRTIMO;
- if ((argp->flags & NFSMNT_ACREGMAX) && argp->acregmax >= 0)
- nmp->nm_acregmax = argp->acregmax;
- else
- nmp->nm_acregmax = NFS_MAXATTRTIMO;
- if ((argp->flags & NFSMNT_ACDIRMIN) && argp->acdirmin >= 0)
- nmp->nm_acdirmin = argp->acdirmin;
- else
- nmp->nm_acdirmin = NFS_MINDIRATTRTIMO;
- if ((argp->flags & NFSMNT_ACDIRMAX) && argp->acdirmax >= 0)
- nmp->nm_acdirmax = argp->acdirmax;
- else
- nmp->nm_acdirmax = NFS_MAXDIRATTRTIMO;
- if (nmp->nm_acdirmin > nmp->nm_acdirmax)
- nmp->nm_acdirmin = nmp->nm_acdirmax;
- if (nmp->nm_acregmin > nmp->nm_acregmax)
- nmp->nm_acregmin = nmp->nm_acregmax;
-
- if ((argp->flags & NFSMNT_MAXGRPS) && argp->maxgrouplist >= 0) {
- if (argp->maxgrouplist <= NFS_MAXGRPS)
- nmp->nm_numgrps = argp->maxgrouplist;
- else
- nmp->nm_numgrps = NFS_MAXGRPS;
- }
- if ((argp->flags & NFSMNT_READAHEAD) && argp->readahead >= 0) {
- if (argp->readahead <= NFS_MAXRAHEAD)
- nmp->nm_readahead = argp->readahead;
- else
- nmp->nm_readahead = NFS_MAXRAHEAD;
- }
- if ((argp->flags & NFSMNT_LEASETERM) && argp->leaseterm >= 2) {
- if (argp->leaseterm <= NQ_MAXLEASE)
- nmp->nm_leaseterm = argp->leaseterm;
- else
- nmp->nm_leaseterm = NQ_MAXLEASE;
- }
- if ((argp->flags & NFSMNT_DEADTHRESH) && argp->deadthresh >= 1) {
- if (argp->deadthresh <= NQ_NEVERDEAD)
- nmp->nm_deadthresh = argp->deadthresh;
- else
- nmp->nm_deadthresh = NQ_NEVERDEAD;
- }
-
- adjsock |= ((nmp->nm_sotype != argp->sotype) ||
- (nmp->nm_soproto != argp->proto));
- nmp->nm_sotype = argp->sotype;
- nmp->nm_soproto = argp->proto;
-
- if (nmp->nm_so && adjsock) {
- nfs_safedisconnect(nmp);
- if (nmp->nm_sotype == SOCK_DGRAM)
- while (nfs_connect(nmp, (struct nfsreq *)0)) {
- printf("nfs_args: retrying connect\n");
- (void) tsleep((caddr_t)&lbolt,
- PSOCK, "nfscon", 0);
- }
- }
-}
-
-/*
- * VFS Operations.
- *
- * mount system call
- * It seems a bit dumb to copyinstr() the host and path here and then
- * bcopy() them in mountnfs(), but I wanted to detect errors before
- * doing the sockargs() call because sockargs() allocates an mbuf and
- * an error after that means that I have to release the mbuf.
- */
-/* ARGSUSED */
-static int
-nfs_mount(mp, path, data, ndp, p)
- struct mount *mp;
- char *path;
- caddr_t data;
- struct nameidata *ndp;
- struct proc *p;
-{
- int error;
- struct nfs_args args;
- struct sockaddr *nam;
- struct vnode *vp;
- char pth[MNAMELEN], hst[MNAMELEN];
- size_t len;
- u_char nfh[NFSX_V3FHMAX];
-
- if (path == NULL) {
- nfs_mountroot(mp);
- return (0);
- }
- error = copyin(data, (caddr_t)&args, sizeof (struct nfs_args));
- if (error)
- return (error);
- if (args.version != NFS_ARGSVERSION) {
-#ifdef COMPAT_PRELITE2
- /*
- * If the argument version is unknown, then assume the
- * caller is a pre-lite2 4.4BSD client and convert its
- * arguments.
- */
- struct onfs_args oargs;
- error = copyin(data, (caddr_t)&oargs, sizeof (struct onfs_args));
- if (error)
- return (error);
- nfs_convert_oargs(&args,&oargs);
-#else /* !COMPAT_PRELITE2 */
- return (EPROGMISMATCH);
-#endif /* COMPAT_PRELITE2 */
- }
- if (mp->mnt_flag & MNT_UPDATE) {
- register struct nfsmount *nmp = VFSTONFS(mp);
-
- if (nmp == NULL)
- return (EIO);
- /*
- * When doing an update, we can't change from or to
- * v3 and/or nqnfs, or change cookie translation
- */
- args.flags = (args.flags &
- ~(NFSMNT_NFSV3|NFSMNT_NQNFS /*|NFSMNT_XLATECOOKIE*/)) |
- (nmp->nm_flag &
- (NFSMNT_NFSV3|NFSMNT_NQNFS /*|NFSMNT_XLATECOOKIE*/));
- nfs_decode_args(nmp, &args);
- return (0);
- }
- error = copyin((caddr_t)args.fh, (caddr_t)nfh, args.fhsize);
- if (error)
- return (error);
- error = copyinstr(path, pth, MNAMELEN-1, &len);
- if (error)
- return (error);
- bzero(&pth[len], MNAMELEN - len);
- error = copyinstr(args.hostname, hst, MNAMELEN-1, &len);
- if (error)
- return (error);
- bzero(&hst[len], MNAMELEN - len);
- /* sockargs() call must be after above copyin() calls */
- error = getsockaddr(&nam, (caddr_t)args.addr, args.addrlen);
- if (error)
- return (error);
- args.fh = nfh;
- error = mountnfs(&args, mp, nam, pth, hst, &vp);
- return (error);
-}
-
-/*
- * Common code for mount and mountroot
- */
-static int
-mountnfs(argp, mp, nam, pth, hst, vpp)
- register struct nfs_args *argp;
- register struct mount *mp;
- struct sockaddr *nam;
- char *pth, *hst;
- struct vnode **vpp;
-{
- register struct nfsmount *nmp;
- struct nfsnode *np;
- int error;
- struct vattr attrs;
-
- if (mp->mnt_flag & MNT_UPDATE) {
- nmp = VFSTONFS(mp);
- /* update paths, file handles, etc, here XXX */
- FREE(nam, M_SONAME);
- return (0);
- } else {
- nmp = zalloc(nfsmount_zone);
- bzero((caddr_t)nmp, sizeof (struct nfsmount));
- TAILQ_INIT(&nmp->nm_uidlruhead);
- TAILQ_INIT(&nmp->nm_bufq);
- mp->mnt_data = (qaddr_t)nmp;
- }
- vfs_getnewfsid(mp);
- nmp->nm_mountp = mp;
- if (argp->flags & NFSMNT_NQNFS)
- /*
- * We have to set mnt_maxsymlink to a non-zero value so
- * that COMPAT_43 routines will know that we are setting
- * the d_type field in directories (and can zero it for
- * unsuspecting binaries).
- */
- mp->mnt_maxsymlinklen = 1;
-
- /*
- * V2 can only handle 32 bit filesizes. A 4GB-1 limit may be too
- * high, depending on whether we end up with negative offsets in
- * the client or server somewhere. 2GB-1 may be safer.
- *
- * For V3, nfs_fsinfo will adjust this as necessary. Assume maximum
- * that we can handle until we find out otherwise.
- * XXX Our "safe" limit on the client is what we can store in our
- * buffer cache using signed(!) block numbers.
- */
- if ((argp->flags & NFSMNT_NFSV3) == 0)
- nmp->nm_maxfilesize = 0xffffffffLL;
- else
- nmp->nm_maxfilesize = (u_int64_t)0x80000000 * DEV_BSIZE - 1;
-
- nmp->nm_timeo = NFS_TIMEO;
- nmp->nm_retry = NFS_RETRANS;
- nmp->nm_wsize = NFS_WSIZE;
- nmp->nm_rsize = NFS_RSIZE;
- nmp->nm_readdirsize = NFS_READDIRSIZE;
- nmp->nm_numgrps = NFS_MAXGRPS;
- nmp->nm_readahead = NFS_DEFRAHEAD;
- nmp->nm_leaseterm = NQ_DEFLEASE;
- nmp->nm_deadthresh = NQ_DEADTHRESH;
- CIRCLEQ_INIT(&nmp->nm_timerhead);
- nmp->nm_inprog = NULLVP;
- nmp->nm_fhsize = argp->fhsize;
- bcopy((caddr_t)argp->fh, (caddr_t)nmp->nm_fh, argp->fhsize);
- bcopy(hst, mp->mnt_stat.f_mntfromname, MNAMELEN);
- bcopy(pth, mp->mnt_stat.f_mntonname, MNAMELEN);
- nmp->nm_nam = nam;
- /* Set up the sockets and per-host congestion */
- nmp->nm_sotype = argp->sotype;
- nmp->nm_soproto = argp->proto;
-
- nfs_decode_args(nmp, argp);
-
- /*
- * For Connection based sockets (TCP,...) defer the connect until
- * the first request, in case the server is not responding.
- */
- if (nmp->nm_sotype == SOCK_DGRAM &&
- (error = nfs_connect(nmp, (struct nfsreq *)0)))
- goto bad;
-
- /*
- * This is silly, but it has to be set so that vinifod() works.
- * We do not want to do an nfs_statfs() here since we can get
- * stuck on a dead server and we are holding a lock on the mount
- * point.
- */
- mp->mnt_stat.f_iosize = nfs_iosize(nmp);
- /*
- * A reference count is needed on the nfsnode representing the
- * remote root. If this object is not persistent, then backward
- * traversals of the mount point (i.e. "..") will not work if
- * the nfsnode gets flushed out of the cache. Ufs does not have
- * this problem, because one can identify root inodes by their
- * number == ROOTINO (2).
- */
- error = nfs_nget(mp, (nfsfh_t *)nmp->nm_fh, nmp->nm_fhsize, &np);
- if (error)
- goto bad;
- *vpp = NFSTOV(np);
-
- /*
- * Get file attributes for the mountpoint. This has the side
- * effect of filling in (*vpp)->v_type with the correct value.
- */
- VOP_GETATTR(*vpp, &attrs, curproc->p_ucred, curproc);
-
- /*
- * Lose the lock but keep the ref.
- */
- VOP_UNLOCK(*vpp, 0, curproc);
-
- return (0);
-bad:
- nfs_disconnect(nmp);
- zfree(nfsmount_zone, nmp);
- FREE(nam, M_SONAME);
- return (error);
-}
-
-/*
- * unmount system call
- */
-static int
-nfs_unmount(mp, mntflags, p)
- struct mount *mp;
- int mntflags;
- struct proc *p;
-{
- register struct nfsmount *nmp;
- struct nfsnode *np;
- struct vnode *vp;
- int error, flags = 0;
-
- if (mntflags & MNT_FORCE)
- flags |= FORCECLOSE;
- nmp = VFSTONFS(mp);
- /*
- * Goes something like this..
- * - Check for activity on the root vnode (other than ourselves).
- * - Call vflush() to clear out vnodes for this file system,
- * except for the root vnode.
- * - Decrement reference on the vnode representing remote root.
- * - Close the socket
- * - Free up the data structures
- */
- /*
- * We need to decrement the ref. count on the nfsnode representing
- * the remote root. See comment in mountnfs(). The VFS unmount()
- * has done vput on this vnode, otherwise we would get deadlock!
- */
- error = nfs_nget(mp, (nfsfh_t *)nmp->nm_fh, nmp->nm_fhsize, &np);
- if (error)
- return(error);
- vp = NFSTOV(np);
- if (vp->v_usecount > 2) {
- vput(vp);
- return (EBUSY);
- }
-
- /*
- * Must handshake with nqnfs_clientd() if it is active.
- */
- nmp->nm_state |= NFSSTA_DISMINPROG;
- while (nmp->nm_inprog != NULLVP)
- (void) tsleep((caddr_t)&lbolt, PSOCK, "nfsdism", 0);
- error = vflush(mp, vp, flags);
- if (error) {
- vput(vp);
- nmp->nm_state &= ~NFSSTA_DISMINPROG;
- return (error);
- }
-
- /*
- * We are now committed to the unmount.
- * For NQNFS, let the server daemon free the nfsmount structure.
- */
- if (nmp->nm_flag & (NFSMNT_NQNFS | NFSMNT_KERB))
- nmp->nm_state |= NFSSTA_DISMNT;
-
- /*
- * There are two reference counts and one lock to get rid of here.
- */
- vput(vp);
- vrele(vp);
- vgone(vp);
- nfs_disconnect(nmp);
- FREE(nmp->nm_nam, M_SONAME);
-
- if ((nmp->nm_flag & (NFSMNT_NQNFS | NFSMNT_KERB)) == 0)
- zfree(nfsmount_zone, nmp);
- return (0);
-}
-
-/*
- * Return root of a filesystem
- */
-static int
-nfs_root(mp, vpp)
- struct mount *mp;
- struct vnode **vpp;
-{
- register struct vnode *vp;
- struct nfsmount *nmp;
- struct nfsnode *np;
- int error;
-
- nmp = VFSTONFS(mp);
- error = nfs_nget(mp, (nfsfh_t *)nmp->nm_fh, nmp->nm_fhsize, &np);
- if (error)
- return (error);
- vp = NFSTOV(np);
- if (vp->v_type == VNON)
- vp->v_type = VDIR;
- vp->v_flag = VROOT;
- *vpp = vp;
- return (0);
-}
-
-extern int syncprt;
-
-/*
- * Flush out the buffer cache
- */
-/* ARGSUSED */
-static int
-nfs_sync(mp, waitfor, cred, p)
- struct mount *mp;
- int waitfor;
- struct ucred *cred;
- struct proc *p;
-{
- register struct vnode *vp;
- int error, allerror = 0;
-
- /*
- * Force stale buffer cache information to be flushed.
- */
-loop:
- for (vp = mp->mnt_vnodelist.lh_first;
- vp != NULL;
- vp = vp->v_mntvnodes.le_next) {
- /*
- * If the vnode that we are about to sync is no longer
- * associated with this mount point, start over.
- */
- if (vp->v_mount != mp)
- goto loop;
- if (VOP_ISLOCKED(vp, NULL) || TAILQ_EMPTY(&vp->v_dirtyblkhd) ||
- waitfor == MNT_LAZY)
- continue;
- if (vget(vp, LK_EXCLUSIVE, p))
- goto loop;
- error = VOP_FSYNC(vp, cred, waitfor, p);
- if (error)
- allerror = error;
- vput(vp);
- }
- return (allerror);
-}
-
diff --git a/sys/nfsclient/nfs_vnops.c b/sys/nfsclient/nfs_vnops.c
deleted file mode 100644
index 0a6de2f722c1..000000000000
--- a/sys/nfsclient/nfs_vnops.c
+++ /dev/null
@@ -1,3372 +0,0 @@
-/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Rick Macklem at The University of Guelph.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)nfs_vnops.c 8.16 (Berkeley) 5/27/95
- * $FreeBSD$
- */
-
-
-/*
- * vnode op calls for Sun NFS version 2 and 3
- */
-
-#include "opt_inet.h"
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/resourcevar.h>
-#include <sys/proc.h>
-#include <sys/mount.h>
-#include <sys/buf.h>
-#include <sys/malloc.h>
-#include <sys/mbuf.h>
-#include <sys/namei.h>
-#include <sys/socket.h>
-#include <sys/vnode.h>
-#include <sys/dirent.h>
-#include <sys/fcntl.h>
-#include <sys/lockf.h>
-#include <sys/stat.h>
-#include <sys/sysctl.h>
-#include <sys/conf.h>
-
-#include <vm/vm.h>
-#include <vm/vm_extern.h>
-#include <vm/vm_zone.h>
-
-#include <miscfs/fifofs/fifo.h>
-
-#include <nfs/rpcv2.h>
-#include <nfs/nfsproto.h>
-#include <nfs/nfs.h>
-#include <nfs/nfsnode.h>
-#include <nfs/nfsmount.h>
-#include <nfs/xdr_subs.h>
-#include <nfs/nfsm_subs.h>
-#include <nfs/nqnfs.h>
-
-#include <net/if.h>
-#include <netinet/in.h>
-#include <netinet/in_var.h>
-
-/* Defs */
-#define TRUE 1
-#define FALSE 0
-
-/*
- * Ifdef for FreeBSD-current merged buffer cache. It is unfortunate that these
- * calls are not in getblk() and brelse() so that they would not be necessary
- * here.
- */
-#ifndef B_VMIO
-#define vfs_busy_pages(bp, f)
-#endif
-
-static int nfsspec_read __P((struct vop_read_args *));
-static int nfsspec_write __P((struct vop_write_args *));
-static int nfsfifo_read __P((struct vop_read_args *));
-static int nfsfifo_write __P((struct vop_write_args *));
-static int nfsspec_close __P((struct vop_close_args *));
-static int nfsfifo_close __P((struct vop_close_args *));
-#define nfs_poll vop_nopoll
-static int nfs_flush __P((struct vnode *,struct ucred *,int,struct proc *,int));
-static int nfs_setattrrpc __P((struct vnode *,struct vattr *,struct ucred *,struct proc *));
-static int nfs_lookup __P((struct vop_lookup_args *));
-static int nfs_create __P((struct vop_create_args *));
-static int nfs_mknod __P((struct vop_mknod_args *));
-static int nfs_open __P((struct vop_open_args *));
-static int nfs_close __P((struct vop_close_args *));
-static int nfs_access __P((struct vop_access_args *));
-static int nfs_getattr __P((struct vop_getattr_args *));
-static int nfs_setattr __P((struct vop_setattr_args *));
-static int nfs_read __P((struct vop_read_args *));
-static int nfs_mmap __P((struct vop_mmap_args *));
-static int nfs_fsync __P((struct vop_fsync_args *));
-static int nfs_remove __P((struct vop_remove_args *));
-static int nfs_link __P((struct vop_link_args *));
-static int nfs_rename __P((struct vop_rename_args *));
-static int nfs_mkdir __P((struct vop_mkdir_args *));
-static int nfs_rmdir __P((struct vop_rmdir_args *));
-static int nfs_symlink __P((struct vop_symlink_args *));
-static int nfs_readdir __P((struct vop_readdir_args *));
-static int nfs_bmap __P((struct vop_bmap_args *));
-static int nfs_strategy __P((struct vop_strategy_args *));
-static int nfs_lookitup __P((struct vnode *, const char *, int,
- struct ucred *, struct proc *, struct nfsnode **));
-static int nfs_sillyrename __P((struct vnode *,struct vnode *,struct componentname *));
-static int nfsspec_access __P((struct vop_access_args *));
-static int nfs_readlink __P((struct vop_readlink_args *));
-static int nfs_print __P((struct vop_print_args *));
-static int nfs_advlock __P((struct vop_advlock_args *));
-static int nfs_bwrite __P((struct vop_bwrite_args *));
-/*
- * Global vfs data structures for nfs
- */
-vop_t **nfsv2_vnodeop_p;
-static struct vnodeopv_entry_desc nfsv2_vnodeop_entries[] = {
- { &vop_default_desc, (vop_t *) vop_defaultop },
- { &vop_access_desc, (vop_t *) nfs_access },
- { &vop_advlock_desc, (vop_t *) nfs_advlock },
- { &vop_bmap_desc, (vop_t *) nfs_bmap },
- { &vop_bwrite_desc, (vop_t *) nfs_bwrite },
- { &vop_close_desc, (vop_t *) nfs_close },
- { &vop_create_desc, (vop_t *) nfs_create },
- { &vop_fsync_desc, (vop_t *) nfs_fsync },
- { &vop_getattr_desc, (vop_t *) nfs_getattr },
- { &vop_getpages_desc, (vop_t *) nfs_getpages },
- { &vop_putpages_desc, (vop_t *) nfs_putpages },
- { &vop_inactive_desc, (vop_t *) nfs_inactive },
- { &vop_lease_desc, (vop_t *) vop_null },
- { &vop_link_desc, (vop_t *) nfs_link },
- { &vop_lock_desc, (vop_t *) vop_sharedlock },
- { &vop_lookup_desc, (vop_t *) nfs_lookup },
- { &vop_mkdir_desc, (vop_t *) nfs_mkdir },
- { &vop_mknod_desc, (vop_t *) nfs_mknod },
- { &vop_mmap_desc, (vop_t *) nfs_mmap },
- { &vop_open_desc, (vop_t *) nfs_open },
- { &vop_poll_desc, (vop_t *) nfs_poll },
- { &vop_print_desc, (vop_t *) nfs_print },
- { &vop_read_desc, (vop_t *) nfs_read },
- { &vop_readdir_desc, (vop_t *) nfs_readdir },
- { &vop_readlink_desc, (vop_t *) nfs_readlink },
- { &vop_reclaim_desc, (vop_t *) nfs_reclaim },
- { &vop_remove_desc, (vop_t *) nfs_remove },
- { &vop_rename_desc, (vop_t *) nfs_rename },
- { &vop_rmdir_desc, (vop_t *) nfs_rmdir },
- { &vop_setattr_desc, (vop_t *) nfs_setattr },
- { &vop_strategy_desc, (vop_t *) nfs_strategy },
- { &vop_symlink_desc, (vop_t *) nfs_symlink },
- { &vop_write_desc, (vop_t *) nfs_write },
- { NULL, NULL }
-};
-static struct vnodeopv_desc nfsv2_vnodeop_opv_desc =
- { &nfsv2_vnodeop_p, nfsv2_vnodeop_entries };
-VNODEOP_SET(nfsv2_vnodeop_opv_desc);
-
-/*
- * Special device vnode ops
- */
-vop_t **spec_nfsv2nodeop_p;
-static struct vnodeopv_entry_desc nfsv2_specop_entries[] = {
- { &vop_default_desc, (vop_t *) spec_vnoperate },
- { &vop_access_desc, (vop_t *) nfsspec_access },
- { &vop_close_desc, (vop_t *) nfsspec_close },
- { &vop_fsync_desc, (vop_t *) nfs_fsync },
- { &vop_getattr_desc, (vop_t *) nfs_getattr },
- { &vop_inactive_desc, (vop_t *) nfs_inactive },
- { &vop_lock_desc, (vop_t *) vop_sharedlock },
- { &vop_print_desc, (vop_t *) nfs_print },
- { &vop_read_desc, (vop_t *) nfsspec_read },
- { &vop_reclaim_desc, (vop_t *) nfs_reclaim },
- { &vop_setattr_desc, (vop_t *) nfs_setattr },
- { &vop_write_desc, (vop_t *) nfsspec_write },
- { NULL, NULL }
-};
-static struct vnodeopv_desc spec_nfsv2nodeop_opv_desc =
- { &spec_nfsv2nodeop_p, nfsv2_specop_entries };
-VNODEOP_SET(spec_nfsv2nodeop_opv_desc);
-
-vop_t **fifo_nfsv2nodeop_p;
-static struct vnodeopv_entry_desc nfsv2_fifoop_entries[] = {
- { &vop_default_desc, (vop_t *) fifo_vnoperate },
- { &vop_access_desc, (vop_t *) nfsspec_access },
- { &vop_close_desc, (vop_t *) nfsfifo_close },
- { &vop_fsync_desc, (vop_t *) nfs_fsync },
- { &vop_getattr_desc, (vop_t *) nfs_getattr },
- { &vop_inactive_desc, (vop_t *) nfs_inactive },
- { &vop_lock_desc, (vop_t *) vop_sharedlock },
- { &vop_print_desc, (vop_t *) nfs_print },
- { &vop_read_desc, (vop_t *) nfsfifo_read },
- { &vop_reclaim_desc, (vop_t *) nfs_reclaim },
- { &vop_setattr_desc, (vop_t *) nfs_setattr },
- { &vop_write_desc, (vop_t *) nfsfifo_write },
- { NULL, NULL }
-};
-static struct vnodeopv_desc fifo_nfsv2nodeop_opv_desc =
- { &fifo_nfsv2nodeop_p, nfsv2_fifoop_entries };
-VNODEOP_SET(fifo_nfsv2nodeop_opv_desc);
-
-static int nfs_mknodrpc __P((struct vnode *dvp, struct vnode **vpp,
- struct componentname *cnp,
- struct vattr *vap));
-static int nfs_removerpc __P((struct vnode *dvp, const char *name,
- int namelen,
- struct ucred *cred, struct proc *proc));
-static int nfs_renamerpc __P((struct vnode *fdvp, const char *fnameptr,
- int fnamelen, struct vnode *tdvp,
- const char *tnameptr, int tnamelen,
- struct ucred *cred, struct proc *proc));
-static int nfs_renameit __P((struct vnode *sdvp,
- struct componentname *scnp,
- struct sillyrename *sp));
-
-/*
- * Global variables
- */
-extern u_int32_t nfs_true, nfs_false;
-extern u_int32_t nfs_xdrneg1;
-extern struct nfsstats nfsstats;
-extern nfstype nfsv3_type[9];
-struct proc *nfs_iodwant[NFS_MAXASYNCDAEMON];
-struct nfsmount *nfs_iodmount[NFS_MAXASYNCDAEMON];
-int nfs_numasync = 0;
-#define DIRHDSIZ (sizeof (struct dirent) - (MAXNAMLEN + 1))
-
-SYSCTL_DECL(_vfs_nfs);
-
-static int nfsaccess_cache_timeout = NFS_MAXATTRTIMO;
-SYSCTL_INT(_vfs_nfs, OID_AUTO, access_cache_timeout, CTLFLAG_RW,
- &nfsaccess_cache_timeout, 0, "NFS ACCESS cache timeout");
-
-static int nfsv3_commit_on_close = 0;
-SYSCTL_INT(_vfs_nfs, OID_AUTO, nfsv3_commit_on_close, CTLFLAG_RW,
- &nfsv3_commit_on_close, 0, "write+commit on close, else only write");
-#if 0
-SYSCTL_INT(_vfs_nfs, OID_AUTO, access_cache_hits, CTLFLAG_RD,
- &nfsstats.accesscache_hits, 0, "NFS ACCESS cache hit count");
-
-SYSCTL_INT(_vfs_nfs, OID_AUTO, access_cache_misses, CTLFLAG_RD,
- &nfsstats.accesscache_misses, 0, "NFS ACCESS cache miss count");
-#endif
-
-#define NFSV3ACCESS_ALL (NFSV3ACCESS_READ | NFSV3ACCESS_MODIFY \
- | NFSV3ACCESS_EXTEND | NFSV3ACCESS_EXECUTE \
- | NFSV3ACCESS_DELETE | NFSV3ACCESS_LOOKUP)
-static int
-nfs3_access_otw(struct vnode *vp,
- int wmode,
- struct proc *p,
- struct ucred *cred)
-{
- const int v3 = 1;
- u_int32_t *tl;
- int error = 0, attrflag;
-
- struct mbuf *mreq, *mrep, *md, *mb, *mb2;
- caddr_t bpos, dpos, cp2;
- register int32_t t1, t2;
- register caddr_t cp;
- u_int32_t rmode;
- struct nfsnode *np = VTONFS(vp);
-
- nfsstats.rpccnt[NFSPROC_ACCESS]++;
- nfsm_reqhead(vp, NFSPROC_ACCESS, NFSX_FH(v3) + NFSX_UNSIGNED);
- nfsm_fhtom(vp, v3);
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);
- *tl = txdr_unsigned(wmode);
- nfsm_request(vp, NFSPROC_ACCESS, p, cred);
- nfsm_postop_attr(vp, attrflag);
- if (!error) {
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED);
- rmode = fxdr_unsigned(u_int32_t, *tl);
- np->n_mode = rmode;
- np->n_modeuid = cred->cr_uid;
- np->n_modestamp = time_second;
- }
- nfsm_reqdone;
- return error;
-}
-
-/*
- * nfs access vnode op.
- * For nfs version 2, just return ok. File accesses may fail later.
- * For nfs version 3, use the access rpc to check accessibility. If file modes
- * are changed on the server, accesses might still fail later.
- */
-static int
-nfs_access(ap)
- struct vop_access_args /* {
- struct vnode *a_vp;
- int a_mode;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
- int error = 0;
- u_int32_t mode, wmode;
- int v3 = NFS_ISV3(vp);
- struct nfsnode *np = VTONFS(vp);
-
- /*
- * Disallow write attempts on filesystems mounted read-only;
- * unless the file is a socket, fifo, or a block or character
- * device resident on the filesystem.
- */
- if ((ap->a_mode & VWRITE) && (vp->v_mount->mnt_flag & MNT_RDONLY)) {
- switch (vp->v_type) {
- case VREG:
- case VDIR:
- case VLNK:
- return (EROFS);
- default:
- break;
- }
- }
- /*
- * For nfs v3, check to see if we have done this recently, and if
- * so return our cached result instead of making an ACCESS call.
- * If not, do an access rpc, otherwise you are stuck emulating
- * ufs_access() locally using the vattr. This may not be correct,
- * since the server may apply other access criteria such as
- * client uid-->server uid mapping that we do not know about.
- */
- if (v3) {
- if (ap->a_mode & VREAD)
- mode = NFSV3ACCESS_READ;
- else
- mode = 0;
- if (vp->v_type != VDIR) {
- if (ap->a_mode & VWRITE)
- mode |= (NFSV3ACCESS_MODIFY | NFSV3ACCESS_EXTEND);
- if (ap->a_mode & VEXEC)
- mode |= NFSV3ACCESS_EXECUTE;
- } else {
- if (ap->a_mode & VWRITE)
- mode |= (NFSV3ACCESS_MODIFY | NFSV3ACCESS_EXTEND |
- NFSV3ACCESS_DELETE);
- if (ap->a_mode & VEXEC)
- mode |= NFSV3ACCESS_LOOKUP;
- }
- /* XXX safety belt, only make blanket request if caching */
- if (nfsaccess_cache_timeout > 0) {
- wmode = NFSV3ACCESS_READ | NFSV3ACCESS_MODIFY |
- NFSV3ACCESS_EXTEND | NFSV3ACCESS_EXECUTE |
- NFSV3ACCESS_DELETE | NFSV3ACCESS_LOOKUP;
- } else {
- wmode = mode;
- }
-
- /*
- * Does our cached result allow us to give a definite yes to
- * this request?
- */
- if ((time_second < (np->n_modestamp + nfsaccess_cache_timeout)) &&
- (ap->a_cred->cr_uid == np->n_modeuid) &&
- ((np->n_mode & mode) == mode)) {
- nfsstats.accesscache_hits++;
- } else {
- /*
- * Either a no, or a don't know. Go to the wire.
- */
- nfsstats.accesscache_misses++;
- error = nfs3_access_otw(vp, wmode, ap->a_p,ap->a_cred);
- if (!error) {
- if ((np->n_mode & mode) != mode) {
- error = EACCES;
- }
- }
- }
- return (error);
- } else {
- if ((error = nfsspec_access(ap)) != 0)
- return (error);
-
- /*
- * Attempt to prevent a mapped root from accessing a file
- * which it shouldn't. We try to read a byte from the file
- * if the user is root and the file is not zero length.
- * After calling nfsspec_access, we should have the correct
- * file size cached.
- */
- if (ap->a_cred->cr_uid == 0 && (ap->a_mode & VREAD)
- && VTONFS(vp)->n_size > 0) {
- struct iovec aiov;
- struct uio auio;
- char buf[1];
-
- aiov.iov_base = buf;
- aiov.iov_len = 1;
- auio.uio_iov = &aiov;
- auio.uio_iovcnt = 1;
- auio.uio_offset = 0;
- auio.uio_resid = 1;
- auio.uio_segflg = UIO_SYSSPACE;
- auio.uio_rw = UIO_READ;
- auio.uio_procp = ap->a_p;
-
- if (vp->v_type == VREG)
- error = nfs_readrpc(vp, &auio, ap->a_cred);
- else if (vp->v_type == VDIR) {
- char* bp;
- bp = malloc(NFS_DIRBLKSIZ, M_TEMP, M_WAITOK);
- aiov.iov_base = bp;
- aiov.iov_len = auio.uio_resid = NFS_DIRBLKSIZ;
- error = nfs_readdirrpc(vp, &auio, ap->a_cred);
- free(bp, M_TEMP);
- } else if (vp->v_type == VLNK)
- error = nfs_readlinkrpc(vp, &auio, ap->a_cred);
- else
- error = EACCES;
- }
- return (error);
- }
-}
-
-/*
- * nfs open vnode op
- * Check to see if the type is ok
- * and that deletion is not in progress.
- * For paged in text files, you will need to flush the page cache
- * if consistency is lost.
- */
-/* ARGSUSED */
-static int
-nfs_open(ap)
- struct vop_open_args /* {
- struct vnode *a_vp;
- int a_mode;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
- struct nfsnode *np = VTONFS(vp);
- struct nfsmount *nmp = VFSTONFS(vp->v_mount);
- struct vattr vattr;
- int error;
-
- if (vp->v_type != VREG && vp->v_type != VDIR && vp->v_type != VLNK) {
-#ifdef DIAGNOSTIC
- printf("open eacces vtyp=%d\n",vp->v_type);
-#endif
- return (EACCES);
- }
- /*
- * Get a valid lease. If cached data is stale, flush it.
- */
- if (nmp->nm_flag & NFSMNT_NQNFS) {
- if (NQNFS_CKINVALID(vp, np, ND_READ)) {
- do {
- error = nqnfs_getlease(vp, ND_READ, ap->a_cred,
- ap->a_p);
- } while (error == NQNFS_EXPIRED);
- if (error)
- return (error);
- if (np->n_lrev != np->n_brev ||
- (np->n_flag & NQNFSNONCACHE)) {
- if ((error = nfs_vinvalbuf(vp, V_SAVE, ap->a_cred,
- ap->a_p, 1)) == EINTR)
- return (error);
- np->n_brev = np->n_lrev;
- }
- }
- } else {
- if (np->n_flag & NMODIFIED) {
- if ((error = nfs_vinvalbuf(vp, V_SAVE, ap->a_cred,
- ap->a_p, 1)) == EINTR)
- return (error);
- np->n_attrstamp = 0;
- if (vp->v_type == VDIR)
- np->n_direofoffset = 0;
- error = VOP_GETATTR(vp, &vattr, ap->a_cred, ap->a_p);
- if (error)
- return (error);
- np->n_mtime = vattr.va_mtime.tv_sec;
- } else {
- error = VOP_GETATTR(vp, &vattr, ap->a_cred, ap->a_p);
- if (error)
- return (error);
- if (np->n_mtime != vattr.va_mtime.tv_sec) {
- if (vp->v_type == VDIR)
- np->n_direofoffset = 0;
- if ((error = nfs_vinvalbuf(vp, V_SAVE,
- ap->a_cred, ap->a_p, 1)) == EINTR)
- return (error);
- np->n_mtime = vattr.va_mtime.tv_sec;
- }
- }
- }
- if ((nmp->nm_flag & NFSMNT_NQNFS) == 0)
- np->n_attrstamp = 0; /* For Open/Close consistency */
- return (0);
-}
-
-/*
- * nfs close vnode op
- * What an NFS client should do upon close after writing is a debatable issue.
- * Most NFS clients push delayed writes to the server upon close, basically for
- * two reasons:
- * 1 - So that any write errors may be reported back to the client process
- * doing the close system call. By far the two most likely errors are
- * NFSERR_NOSPC and NFSERR_DQUOT to indicate space allocation failure.
- * 2 - To put a worst case upper bound on cache inconsistency between
- * multiple clients for the file.
- * There is also a consistency problem for Version 2 of the protocol w.r.t.
- * not being able to tell if other clients are writing a file concurrently,
- * since there is no way of knowing if the changed modify time in the reply
- * is only due to the write for this client.
- * (NFS Version 3 provides weak cache consistency data in the reply that
- * should be sufficient to detect and handle this case.)
- *
- * The current code does the following:
- * for NFS Version 2 - play it safe and flush/invalidate all dirty buffers
- * for NFS Version 3 - flush dirty buffers to the server but don't invalidate
- * or commit them (this satisfies 1 and 2 except for the
- * case where the server crashes after this close but
- * before the commit RPC, which is felt to be "good
- * enough". Changing the last argument to nfs_flush() to
- * a 1 would force a commit operation, if it is felt a
- * commit is necessary now.
- * for NQNFS - do nothing now, since 2 is dealt with via leases and
- * 1 should be dealt with via an fsync() system call for
- * cases where write errors are important.
- */
-/* ARGSUSED */
-static int
-nfs_close(ap)
- struct vop_close_args /* {
- struct vnodeop_desc *a_desc;
- struct vnode *a_vp;
- int a_fflag;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
- register struct nfsnode *np = VTONFS(vp);
- int error = 0;
-
- if (vp->v_type == VREG) {
- if ((VFSTONFS(vp->v_mount)->nm_flag & NFSMNT_NQNFS) == 0 &&
- (np->n_flag & NMODIFIED)) {
- if (NFS_ISV3(vp)) {
- /*
- * Under NFSv3 we have dirty buffers to dispose of. We
- * must flush them to the NFS server. We have the option
- * of waiting all the way through the commit rpc or just
- * waiting for the initial write. The default is to only
- * wait through the initial write so the data is in the
- * server's cache, which is roughly similar to the state
- * a standard disk subsystem leaves the file in on close().
- *
- * We cannot clear the NMODIFIED bit in np->n_flag due to
- * potential races with other processes, and certainly
- * cannot clear it if we don't commit.
- */
- int cm = nfsv3_commit_on_close ? 1 : 0;
- error = nfs_flush(vp, ap->a_cred, MNT_WAIT, ap->a_p, cm);
- /* np->n_flag &= ~NMODIFIED; */
- } else {
- error = nfs_vinvalbuf(vp, V_SAVE, ap->a_cred, ap->a_p, 1);
- }
- np->n_attrstamp = 0;
- }
- if (np->n_flag & NWRITEERR) {
- np->n_flag &= ~NWRITEERR;
- error = np->n_error;
- }
- }
- return (error);
-}
-
-/*
- * nfs getattr call from vfs.
- */
-static int
-nfs_getattr(ap)
- struct vop_getattr_args /* {
- struct vnode *a_vp;
- struct vattr *a_vap;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
- register struct nfsnode *np = VTONFS(vp);
- register caddr_t cp;
- register u_int32_t *tl;
- register int32_t t1, t2;
- caddr_t bpos, dpos;
- int error = 0;
- struct mbuf *mreq, *mrep, *md, *mb, *mb2;
- int v3 = NFS_ISV3(vp);
-
- /*
- * Update local times for special files.
- */
- if (np->n_flag & (NACC | NUPD))
- np->n_flag |= NCHG;
- /*
- * First look in the cache.
- */
- if (nfs_getattrcache(vp, ap->a_vap) == 0)
- return (0);
-
- if (v3 && nfsaccess_cache_timeout > 0) {
- nfsstats.accesscache_misses++;
- nfs3_access_otw(vp, NFSV3ACCESS_ALL, ap->a_p, ap->a_cred);
- if (nfs_getattrcache(vp, ap->a_vap) == 0)
- return (0);
- }
-
- nfsstats.rpccnt[NFSPROC_GETATTR]++;
- nfsm_reqhead(vp, NFSPROC_GETATTR, NFSX_FH(v3));
- nfsm_fhtom(vp, v3);
- nfsm_request(vp, NFSPROC_GETATTR, ap->a_p, ap->a_cred);
- if (!error) {
- nfsm_loadattr(vp, ap->a_vap);
- }
- nfsm_reqdone;
- return (error);
-}
-
-/*
- * nfs setattr call.
- */
-static int
-nfs_setattr(ap)
- struct vop_setattr_args /* {
- struct vnodeop_desc *a_desc;
- struct vnode *a_vp;
- struct vattr *a_vap;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
- register struct nfsnode *np = VTONFS(vp);
- register struct vattr *vap = ap->a_vap;
- int error = 0;
- u_quad_t tsize;
-
-#ifndef nolint
- tsize = (u_quad_t)0;
-#endif
-
- /*
- * Setting of flags is not supported.
- */
- if (vap->va_flags != VNOVAL)
- return (EOPNOTSUPP);
-
- /*
- * Disallow write attempts if the filesystem is mounted read-only.
- */
- if ((vap->va_flags != VNOVAL || vap->va_uid != (uid_t)VNOVAL ||
- vap->va_gid != (gid_t)VNOVAL || vap->va_atime.tv_sec != VNOVAL ||
- vap->va_mtime.tv_sec != VNOVAL || vap->va_mode != (mode_t)VNOVAL) &&
- (vp->v_mount->mnt_flag & MNT_RDONLY))
- return (EROFS);
- if (vap->va_size != VNOVAL) {
- switch (vp->v_type) {
- case VDIR:
- return (EISDIR);
- case VCHR:
- case VBLK:
- case VSOCK:
- case VFIFO:
- if (vap->va_mtime.tv_sec == VNOVAL &&
- vap->va_atime.tv_sec == VNOVAL &&
- vap->va_mode == (mode_t)VNOVAL &&
- vap->va_uid == (uid_t)VNOVAL &&
- vap->va_gid == (gid_t)VNOVAL)
- return (0);
- vap->va_size = VNOVAL;
- break;
- default:
- /*
- * Disallow write attempts if the filesystem is
- * mounted read-only.
- */
- if (vp->v_mount->mnt_flag & MNT_RDONLY)
- return (EROFS);
- vnode_pager_setsize(vp, vap->va_size);
- if (np->n_flag & NMODIFIED) {
- if (vap->va_size == 0)
- error = nfs_vinvalbuf(vp, 0,
- ap->a_cred, ap->a_p, 1);
- else
- error = nfs_vinvalbuf(vp, V_SAVE,
- ap->a_cred, ap->a_p, 1);
- if (error) {
- vnode_pager_setsize(vp, np->n_size);
- return (error);
- }
- }
- tsize = np->n_size;
- np->n_size = np->n_vattr.va_size = vap->va_size;
- };
- } else if ((vap->va_mtime.tv_sec != VNOVAL ||
- vap->va_atime.tv_sec != VNOVAL) && (np->n_flag & NMODIFIED) &&
- vp->v_type == VREG &&
- (error = nfs_vinvalbuf(vp, V_SAVE, ap->a_cred,
- ap->a_p, 1)) == EINTR)
- return (error);
- error = nfs_setattrrpc(vp, vap, ap->a_cred, ap->a_p);
- if (error && vap->va_size != VNOVAL) {
- np->n_size = np->n_vattr.va_size = tsize;
- vnode_pager_setsize(vp, np->n_size);
- }
- return (error);
-}
-
-/*
- * Do an nfs setattr rpc.
- */
-static int
-nfs_setattrrpc(vp, vap, cred, procp)
- register struct vnode *vp;
- register struct vattr *vap;
- struct ucred *cred;
- struct proc *procp;
-{
- register struct nfsv2_sattr *sp;
- register caddr_t cp;
- register int32_t t1, t2;
- caddr_t bpos, dpos, cp2;
- u_int32_t *tl;
- int error = 0, wccflag = NFSV3_WCCRATTR;
- struct mbuf *mreq, *mrep, *md, *mb, *mb2;
- int v3 = NFS_ISV3(vp);
-
- nfsstats.rpccnt[NFSPROC_SETATTR]++;
- nfsm_reqhead(vp, NFSPROC_SETATTR, NFSX_FH(v3) + NFSX_SATTR(v3));
- nfsm_fhtom(vp, v3);
- if (v3) {
- nfsm_v3attrbuild(vap, TRUE);
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);
- *tl = nfs_false;
- } else {
- nfsm_build(sp, struct nfsv2_sattr *, NFSX_V2SATTR);
- if (vap->va_mode == (mode_t)VNOVAL)
- sp->sa_mode = nfs_xdrneg1;
- else
- sp->sa_mode = vtonfsv2_mode(vp->v_type, vap->va_mode);
- if (vap->va_uid == (uid_t)VNOVAL)
- sp->sa_uid = nfs_xdrneg1;
- else
- sp->sa_uid = txdr_unsigned(vap->va_uid);
- if (vap->va_gid == (gid_t)VNOVAL)
- sp->sa_gid = nfs_xdrneg1;
- else
- sp->sa_gid = txdr_unsigned(vap->va_gid);
- sp->sa_size = txdr_unsigned(vap->va_size);
- txdr_nfsv2time(&vap->va_atime, &sp->sa_atime);
- txdr_nfsv2time(&vap->va_mtime, &sp->sa_mtime);
- }
- nfsm_request(vp, NFSPROC_SETATTR, procp, cred);
- if (v3) {
- nfsm_wcc_data(vp, wccflag);
- } else
- nfsm_loadattr(vp, (struct vattr *)0);
- nfsm_reqdone;
- return (error);
-}
-
-/*
- * nfs lookup call, one step at a time...
- * First look in cache
- * If not found, unlock the directory nfsnode and do the rpc
- */
-static int
-nfs_lookup(ap)
- struct vop_lookup_args /* {
- struct vnodeop_desc *a_desc;
- struct vnode *a_dvp;
- struct vnode **a_vpp;
- struct componentname *a_cnp;
- } */ *ap;
-{
- struct componentname *cnp = ap->a_cnp;
- struct vnode *dvp = ap->a_dvp;
- struct vnode **vpp = ap->a_vpp;
- int flags = cnp->cn_flags;
- struct vnode *newvp;
- u_int32_t *tl;
- caddr_t cp;
- int32_t t1, t2;
- struct nfsmount *nmp;
- caddr_t bpos, dpos, cp2;
- struct mbuf *mreq, *mrep, *md, *mb, *mb2;
- long len;
- nfsfh_t *fhp;
- struct nfsnode *np;
- int lockparent, wantparent, error = 0, attrflag, fhsize;
- int v3 = NFS_ISV3(dvp);
- struct proc *p = cnp->cn_proc;
-
- *vpp = NULLVP;
- if ((flags & ISLASTCN) && (dvp->v_mount->mnt_flag & MNT_RDONLY) &&
- (cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME))
- return (EROFS);
- if (dvp->v_type != VDIR)
- return (ENOTDIR);
- lockparent = flags & LOCKPARENT;
- wantparent = flags & (LOCKPARENT|WANTPARENT);
- nmp = VFSTONFS(dvp->v_mount);
- np = VTONFS(dvp);
- if ((error = cache_lookup(dvp, vpp, cnp)) && error != ENOENT) {
- struct vattr vattr;
- int vpid;
-
- if ((error = VOP_ACCESS(dvp, VEXEC, cnp->cn_cred, p)) != 0) {
- *vpp = NULLVP;
- return (error);
- }
-
- newvp = *vpp;
- vpid = newvp->v_id;
- /*
- * See the comment starting `Step through' in ufs/ufs_lookup.c
- * for an explanation of the locking protocol
- */
- if (dvp == newvp) {
- VREF(newvp);
- error = 0;
- } else if (flags & ISDOTDOT) {
- VOP_UNLOCK(dvp, 0, p);
- error = vget(newvp, LK_EXCLUSIVE, p);
- if (!error && lockparent && (flags & ISLASTCN))
- error = vn_lock(dvp, LK_EXCLUSIVE, p);
- } else {
- error = vget(newvp, LK_EXCLUSIVE, p);
- if (!lockparent || error || !(flags & ISLASTCN))
- VOP_UNLOCK(dvp, 0, p);
- }
- if (!error) {
- if (vpid == newvp->v_id) {
- if (!VOP_GETATTR(newvp, &vattr, cnp->cn_cred, p)
- && vattr.va_ctime.tv_sec == VTONFS(newvp)->n_ctime) {
- nfsstats.lookupcache_hits++;
- if (cnp->cn_nameiop != LOOKUP &&
- (flags & ISLASTCN))
- cnp->cn_flags |= SAVENAME;
- return (0);
- }
- cache_purge(newvp);
- }
- vput(newvp);
- if (lockparent && dvp != newvp && (flags & ISLASTCN))
- VOP_UNLOCK(dvp, 0, p);
- }
- error = vn_lock(dvp, LK_EXCLUSIVE, p);
- *vpp = NULLVP;
- if (error)
- return (error);
- }
- error = 0;
- newvp = NULLVP;
- nfsstats.lookupcache_misses++;
- nfsstats.rpccnt[NFSPROC_LOOKUP]++;
- len = cnp->cn_namelen;
- nfsm_reqhead(dvp, NFSPROC_LOOKUP,
- NFSX_FH(v3) + NFSX_UNSIGNED + nfsm_rndup(len));
- nfsm_fhtom(dvp, v3);
- nfsm_strtom(cnp->cn_nameptr, len, NFS_MAXNAMLEN);
- nfsm_request(dvp, NFSPROC_LOOKUP, cnp->cn_proc, cnp->cn_cred);
- if (error) {
- nfsm_postop_attr(dvp, attrflag);
- m_freem(mrep);
- goto nfsmout;
- }
- nfsm_getfh(fhp, fhsize, v3);
-
- /*
- * Handle RENAME case...
- */
- if (cnp->cn_nameiop == RENAME && wantparent && (flags & ISLASTCN)) {
- if (NFS_CMPFH(np, fhp, fhsize)) {
- m_freem(mrep);
- return (EISDIR);
- }
- error = nfs_nget(dvp->v_mount, fhp, fhsize, &np);
- if (error) {
- m_freem(mrep);
- return (error);
- }
- newvp = NFSTOV(np);
- if (v3) {
- nfsm_postop_attr(newvp, attrflag);
- nfsm_postop_attr(dvp, attrflag);
- } else
- nfsm_loadattr(newvp, (struct vattr *)0);
- *vpp = newvp;
- m_freem(mrep);
- cnp->cn_flags |= SAVENAME;
- if (!lockparent)
- VOP_UNLOCK(dvp, 0, p);
- return (0);
- }
-
- if (flags & ISDOTDOT) {
- VOP_UNLOCK(dvp, 0, p);
- error = nfs_nget(dvp->v_mount, fhp, fhsize, &np);
- if (error) {
- vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, p);
- return (error);
- }
- newvp = NFSTOV(np);
- if (lockparent && (flags & ISLASTCN) &&
- (error = vn_lock(dvp, LK_EXCLUSIVE, p))) {
- vput(newvp);
- return (error);
- }
- } else if (NFS_CMPFH(np, fhp, fhsize)) {
- VREF(dvp);
- newvp = dvp;
- } else {
- error = nfs_nget(dvp->v_mount, fhp, fhsize, &np);
- if (error) {
- m_freem(mrep);
- return (error);
- }
- if (!lockparent || !(flags & ISLASTCN))
- VOP_UNLOCK(dvp, 0, p);
- newvp = NFSTOV(np);
- }
- if (v3) {
- nfsm_postop_attr(newvp, attrflag);
- nfsm_postop_attr(dvp, attrflag);
- } else
- nfsm_loadattr(newvp, (struct vattr *)0);
- if (cnp->cn_nameiop != LOOKUP && (flags & ISLASTCN))
- cnp->cn_flags |= SAVENAME;
- if ((cnp->cn_flags & MAKEENTRY) &&
- (cnp->cn_nameiop != DELETE || !(flags & ISLASTCN))) {
- np->n_ctime = np->n_vattr.va_ctime.tv_sec;
- cache_enter(dvp, newvp, cnp);
- }
- *vpp = newvp;
- nfsm_reqdone;
- if (error) {
- if (newvp != NULLVP) {
- vrele(newvp);
- *vpp = NULLVP;
- }
- if ((cnp->cn_nameiop == CREATE || cnp->cn_nameiop == RENAME) &&
- (flags & ISLASTCN) && error == ENOENT) {
- if (!lockparent)
- VOP_UNLOCK(dvp, 0, p);
- if (dvp->v_mount->mnt_flag & MNT_RDONLY)
- error = EROFS;
- else
- error = EJUSTRETURN;
- }
- if (cnp->cn_nameiop != LOOKUP && (flags & ISLASTCN))
- cnp->cn_flags |= SAVENAME;
- }
- return (error);
-}
-
-/*
- * nfs read call.
- * Just call nfs_bioread() to do the work.
- */
-static int
-nfs_read(ap)
- struct vop_read_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- int a_ioflag;
- struct ucred *a_cred;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
-
- if (vp->v_type != VREG)
- return (EPERM);
- return (nfs_bioread(vp, ap->a_uio, ap->a_ioflag, ap->a_cred));
-}
-
-/*
- * nfs readlink call
- */
-static int
-nfs_readlink(ap)
- struct vop_readlink_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- struct ucred *a_cred;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
-
- if (vp->v_type != VLNK)
- return (EINVAL);
- return (nfs_bioread(vp, ap->a_uio, 0, ap->a_cred));
-}
-
-/*
- * Do a readlink rpc.
- * Called by nfs_doio() from below the buffer cache.
- */
-int
-nfs_readlinkrpc(vp, uiop, cred)
- register struct vnode *vp;
- struct uio *uiop;
- struct ucred *cred;
-{
- register u_int32_t *tl;
- register caddr_t cp;
- register int32_t t1, t2;
- caddr_t bpos, dpos, cp2;
- int error = 0, len, attrflag;
- struct mbuf *mreq, *mrep, *md, *mb, *mb2;
- int v3 = NFS_ISV3(vp);
-
- nfsstats.rpccnt[NFSPROC_READLINK]++;
- nfsm_reqhead(vp, NFSPROC_READLINK, NFSX_FH(v3));
- nfsm_fhtom(vp, v3);
- nfsm_request(vp, NFSPROC_READLINK, uiop->uio_procp, cred);
- if (v3)
- nfsm_postop_attr(vp, attrflag);
- if (!error) {
- nfsm_strsiz(len, NFS_MAXPATHLEN);
- if (len == NFS_MAXPATHLEN) {
- struct nfsnode *np = VTONFS(vp);
- if (np->n_size && np->n_size < NFS_MAXPATHLEN)
- len = np->n_size;
- }
- nfsm_mtouio(uiop, len);
- }
- nfsm_reqdone;
- return (error);
-}
-
-/*
- * nfs read rpc call
- * Ditto above
- */
-int
-nfs_readrpc(vp, uiop, cred)
- register struct vnode *vp;
- struct uio *uiop;
- struct ucred *cred;
-{
- register u_int32_t *tl;
- register caddr_t cp;
- register int32_t t1, t2;
- caddr_t bpos, dpos, cp2;
- struct mbuf *mreq, *mrep, *md, *mb, *mb2;
- struct nfsmount *nmp;
- int error = 0, len, retlen, tsiz, eof, attrflag;
- int v3 = NFS_ISV3(vp);
-
-#ifndef nolint
- eof = 0;
-#endif
- nmp = VFSTONFS(vp->v_mount);
- tsiz = uiop->uio_resid;
- if (uiop->uio_offset + tsiz > nmp->nm_maxfilesize)
- return (EFBIG);
- while (tsiz > 0) {
- nfsstats.rpccnt[NFSPROC_READ]++;
- len = (tsiz > nmp->nm_rsize) ? nmp->nm_rsize : tsiz;
- nfsm_reqhead(vp, NFSPROC_READ, NFSX_FH(v3) + NFSX_UNSIGNED * 3);
- nfsm_fhtom(vp, v3);
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED * 3);
- if (v3) {
- txdr_hyper(uiop->uio_offset, tl);
- *(tl + 2) = txdr_unsigned(len);
- } else {
- *tl++ = txdr_unsigned(uiop->uio_offset);
- *tl++ = txdr_unsigned(len);
- *tl = 0;
- }
- nfsm_request(vp, NFSPROC_READ, uiop->uio_procp, cred);
- if (v3) {
- nfsm_postop_attr(vp, attrflag);
- if (error) {
- m_freem(mrep);
- goto nfsmout;
- }
- nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
- eof = fxdr_unsigned(int, *(tl + 1));
- } else
- nfsm_loadattr(vp, (struct vattr *)0);
- nfsm_strsiz(retlen, nmp->nm_rsize);
- nfsm_mtouio(uiop, retlen);
- m_freem(mrep);
- tsiz -= retlen;
- if (v3) {
- if (eof || retlen == 0)
- tsiz = 0;
- } else if (retlen < len)
- tsiz = 0;
- }
-nfsmout:
- return (error);
-}
-
-/*
- * nfs write call
- */
-int
-nfs_writerpc(vp, uiop, cred, iomode, must_commit)
- register struct vnode *vp;
- register struct uio *uiop;
- struct ucred *cred;
- int *iomode, *must_commit;
-{
- register u_int32_t *tl;
- register caddr_t cp;
- register int32_t t1, t2, backup;
- caddr_t bpos, dpos, cp2;
- struct mbuf *mreq, *mrep, *md, *mb, *mb2;
- struct nfsmount *nmp = VFSTONFS(vp->v_mount);
- int error = 0, len, tsiz, wccflag = NFSV3_WCCRATTR, rlen, commit;
- int v3 = NFS_ISV3(vp), committed = NFSV3WRITE_FILESYNC;
-
-#ifndef DIAGNOSTIC
- if (uiop->uio_iovcnt != 1)
- panic("nfs: writerpc iovcnt > 1");
-#endif
- *must_commit = 0;
- tsiz = uiop->uio_resid;
- if (uiop->uio_offset + tsiz > nmp->nm_maxfilesize)
- return (EFBIG);
- while (tsiz > 0) {
- nfsstats.rpccnt[NFSPROC_WRITE]++;
- len = (tsiz > nmp->nm_wsize) ? nmp->nm_wsize : tsiz;
- nfsm_reqhead(vp, NFSPROC_WRITE,
- NFSX_FH(v3) + 5 * NFSX_UNSIGNED + nfsm_rndup(len));
- nfsm_fhtom(vp, v3);
- if (v3) {
- nfsm_build(tl, u_int32_t *, 5 * NFSX_UNSIGNED);
- txdr_hyper(uiop->uio_offset, tl);
- tl += 2;
- *tl++ = txdr_unsigned(len);
- *tl++ = txdr_unsigned(*iomode);
- *tl = txdr_unsigned(len);
- } else {
- register u_int32_t x;
-
- nfsm_build(tl, u_int32_t *, 4 * NFSX_UNSIGNED);
- /* Set both "begin" and "current" to non-garbage. */
- x = txdr_unsigned((u_int32_t)uiop->uio_offset);
- *tl++ = x; /* "begin offset" */
- *tl++ = x; /* "current offset" */
- x = txdr_unsigned(len);
- *tl++ = x; /* total to this offset */
- *tl = x; /* size of this write */
- }
- nfsm_uiotom(uiop, len);
- nfsm_request(vp, NFSPROC_WRITE, uiop->uio_procp, cred);
- if (v3) {
- wccflag = NFSV3_WCCCHK;
- nfsm_wcc_data(vp, wccflag);
- if (!error) {
- nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED
- + NFSX_V3WRITEVERF);
- rlen = fxdr_unsigned(int, *tl++);
- if (rlen == 0) {
- error = NFSERR_IO;
- m_freem(mrep);
- break;
- } else if (rlen < len) {
- backup = len - rlen;
- uiop->uio_iov->iov_base -= backup;
- uiop->uio_iov->iov_len += backup;
- uiop->uio_offset -= backup;
- uiop->uio_resid += backup;
- len = rlen;
- }
- commit = fxdr_unsigned(int, *tl++);
-
- /*
- * Return the lowest committment level
- * obtained by any of the RPCs.
- */
- if (committed == NFSV3WRITE_FILESYNC)
- committed = commit;
- else if (committed == NFSV3WRITE_DATASYNC &&
- commit == NFSV3WRITE_UNSTABLE)
- committed = commit;
- if ((nmp->nm_state & NFSSTA_HASWRITEVERF) == 0){
- bcopy((caddr_t)tl, (caddr_t)nmp->nm_verf,
- NFSX_V3WRITEVERF);
- nmp->nm_state |= NFSSTA_HASWRITEVERF;
- } else if (bcmp((caddr_t)tl,
- (caddr_t)nmp->nm_verf, NFSX_V3WRITEVERF)) {
- *must_commit = 1;
- bcopy((caddr_t)tl, (caddr_t)nmp->nm_verf,
- NFSX_V3WRITEVERF);
- }
- }
- } else
- nfsm_loadattr(vp, (struct vattr *)0);
- if (wccflag)
- VTONFS(vp)->n_mtime = VTONFS(vp)->n_vattr.va_mtime.tv_sec;
- m_freem(mrep);
- if (error)
- break;
- tsiz -= len;
- }
-nfsmout:
- if (vp->v_mount->mnt_flag & MNT_ASYNC)
- committed = NFSV3WRITE_FILESYNC;
- *iomode = committed;
- if (error)
- uiop->uio_resid = tsiz;
- return (error);
-}
-
-/*
- * nfs mknod rpc
- * For NFS v2 this is a kludge. Use a create rpc but with the IFMT bits of the
- * mode set to specify the file type and the size field for rdev.
- */
-static int
-nfs_mknodrpc(dvp, vpp, cnp, vap)
- register struct vnode *dvp;
- register struct vnode **vpp;
- register struct componentname *cnp;
- register struct vattr *vap;
-{
- register struct nfsv2_sattr *sp;
- register u_int32_t *tl;
- register caddr_t cp;
- register int32_t t1, t2;
- struct vnode *newvp = (struct vnode *)0;
- struct nfsnode *np = (struct nfsnode *)0;
- struct vattr vattr;
- char *cp2;
- caddr_t bpos, dpos;
- int error = 0, wccflag = NFSV3_WCCRATTR, gotvp = 0;
- struct mbuf *mreq, *mrep, *md, *mb, *mb2;
- u_int32_t rdev;
- int v3 = NFS_ISV3(dvp);
-
- if (vap->va_type == VCHR || vap->va_type == VBLK)
- rdev = txdr_unsigned(vap->va_rdev);
- else if (vap->va_type == VFIFO || vap->va_type == VSOCK)
- rdev = nfs_xdrneg1;
- else {
- return (EOPNOTSUPP);
- }
- if ((error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred, cnp->cn_proc)) != 0) {
- return (error);
- }
- nfsstats.rpccnt[NFSPROC_MKNOD]++;
- nfsm_reqhead(dvp, NFSPROC_MKNOD, NFSX_FH(v3) + 4 * NFSX_UNSIGNED +
- + nfsm_rndup(cnp->cn_namelen) + NFSX_SATTR(v3));
- nfsm_fhtom(dvp, v3);
- nfsm_strtom(cnp->cn_nameptr, cnp->cn_namelen, NFS_MAXNAMLEN);
- if (v3) {
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);
- *tl++ = vtonfsv3_type(vap->va_type);
- nfsm_v3attrbuild(vap, FALSE);
- if (vap->va_type == VCHR || vap->va_type == VBLK) {
- nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
- *tl++ = txdr_unsigned(umajor(vap->va_rdev));
- *tl = txdr_unsigned(uminor(vap->va_rdev));
- }
- } else {
- nfsm_build(sp, struct nfsv2_sattr *, NFSX_V2SATTR);
- sp->sa_mode = vtonfsv2_mode(vap->va_type, vap->va_mode);
- sp->sa_uid = nfs_xdrneg1;
- sp->sa_gid = nfs_xdrneg1;
- sp->sa_size = rdev;
- txdr_nfsv2time(&vap->va_atime, &sp->sa_atime);
- txdr_nfsv2time(&vap->va_mtime, &sp->sa_mtime);
- }
- nfsm_request(dvp, NFSPROC_MKNOD, cnp->cn_proc, cnp->cn_cred);
- if (!error) {
- nfsm_mtofh(dvp, newvp, v3, gotvp);
- if (!gotvp) {
- if (newvp) {
- vput(newvp);
- newvp = (struct vnode *)0;
- }
- error = nfs_lookitup(dvp, cnp->cn_nameptr,
- cnp->cn_namelen, cnp->cn_cred, cnp->cn_proc, &np);
- if (!error)
- newvp = NFSTOV(np);
- }
- }
- if (v3)
- nfsm_wcc_data(dvp, wccflag);
- nfsm_reqdone;
- if (error) {
- if (newvp)
- vput(newvp);
- } else {
- if (cnp->cn_flags & MAKEENTRY)
- cache_enter(dvp, newvp, cnp);
- *vpp = newvp;
- }
- VTONFS(dvp)->n_flag |= NMODIFIED;
- if (!wccflag)
- VTONFS(dvp)->n_attrstamp = 0;
- return (error);
-}
-
-/*
- * nfs mknod vop
- * just call nfs_mknodrpc() to do the work.
- */
-/* ARGSUSED */
-static int
-nfs_mknod(ap)
- struct vop_mknod_args /* {
- struct vnode *a_dvp;
- struct vnode **a_vpp;
- struct componentname *a_cnp;
- struct vattr *a_vap;
- } */ *ap;
-{
- return nfs_mknodrpc(ap->a_dvp, ap->a_vpp, ap->a_cnp, ap->a_vap);
-}
-
-static u_long create_verf;
-/*
- * nfs file create call
- */
-static int
-nfs_create(ap)
- struct vop_create_args /* {
- struct vnode *a_dvp;
- struct vnode **a_vpp;
- struct componentname *a_cnp;
- struct vattr *a_vap;
- } */ *ap;
-{
- register struct vnode *dvp = ap->a_dvp;
- register struct vattr *vap = ap->a_vap;
- register struct componentname *cnp = ap->a_cnp;
- register struct nfsv2_sattr *sp;
- register u_int32_t *tl;
- register caddr_t cp;
- register int32_t t1, t2;
- struct nfsnode *np = (struct nfsnode *)0;
- struct vnode *newvp = (struct vnode *)0;
- caddr_t bpos, dpos, cp2;
- int error = 0, wccflag = NFSV3_WCCRATTR, gotvp = 0, fmode = 0;
- struct mbuf *mreq, *mrep, *md, *mb, *mb2;
- struct vattr vattr;
- int v3 = NFS_ISV3(dvp);
-
- /*
- * Oops, not for me..
- */
- if (vap->va_type == VSOCK)
- return (nfs_mknodrpc(dvp, ap->a_vpp, cnp, vap));
-
- if ((error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred, cnp->cn_proc)) != 0) {
- return (error);
- }
- if (vap->va_vaflags & VA_EXCLUSIVE)
- fmode |= O_EXCL;
-again:
- nfsstats.rpccnt[NFSPROC_CREATE]++;
- nfsm_reqhead(dvp, NFSPROC_CREATE, NFSX_FH(v3) + 2 * NFSX_UNSIGNED +
- nfsm_rndup(cnp->cn_namelen) + NFSX_SATTR(v3));
- nfsm_fhtom(dvp, v3);
- nfsm_strtom(cnp->cn_nameptr, cnp->cn_namelen, NFS_MAXNAMLEN);
- if (v3) {
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);
- if (fmode & O_EXCL) {
- *tl = txdr_unsigned(NFSV3CREATE_EXCLUSIVE);
- nfsm_build(tl, u_int32_t *, NFSX_V3CREATEVERF);
-#ifdef INET
- if (!TAILQ_EMPTY(&in_ifaddrhead))
- *tl++ = IA_SIN(in_ifaddrhead.tqh_first)->sin_addr.s_addr;
- else
-#endif
- *tl++ = create_verf;
- *tl = ++create_verf;
- } else {
- *tl = txdr_unsigned(NFSV3CREATE_UNCHECKED);
- nfsm_v3attrbuild(vap, FALSE);
- }
- } else {
- nfsm_build(sp, struct nfsv2_sattr *, NFSX_V2SATTR);
- sp->sa_mode = vtonfsv2_mode(vap->va_type, vap->va_mode);
- sp->sa_uid = nfs_xdrneg1;
- sp->sa_gid = nfs_xdrneg1;
- sp->sa_size = 0;
- txdr_nfsv2time(&vap->va_atime, &sp->sa_atime);
- txdr_nfsv2time(&vap->va_mtime, &sp->sa_mtime);
- }
- nfsm_request(dvp, NFSPROC_CREATE, cnp->cn_proc, cnp->cn_cred);
- if (!error) {
- nfsm_mtofh(dvp, newvp, v3, gotvp);
- if (!gotvp) {
- if (newvp) {
- vput(newvp);
- newvp = (struct vnode *)0;
- }
- error = nfs_lookitup(dvp, cnp->cn_nameptr,
- cnp->cn_namelen, cnp->cn_cred, cnp->cn_proc, &np);
- if (!error)
- newvp = NFSTOV(np);
- }
- }
- if (v3)
- nfsm_wcc_data(dvp, wccflag);
- nfsm_reqdone;
- if (error) {
- if (v3 && (fmode & O_EXCL) && error == NFSERR_NOTSUPP) {
- fmode &= ~O_EXCL;
- goto again;
- }
- if (newvp)
- vput(newvp);
- } else if (v3 && (fmode & O_EXCL))
- error = nfs_setattrrpc(newvp, vap, cnp->cn_cred, cnp->cn_proc);
- if (!error) {
- if (cnp->cn_flags & MAKEENTRY)
- cache_enter(dvp, newvp, cnp);
- *ap->a_vpp = newvp;
- }
- VTONFS(dvp)->n_flag |= NMODIFIED;
- if (!wccflag)
- VTONFS(dvp)->n_attrstamp = 0;
- return (error);
-}
-
-/*
- * nfs file remove call
- * To try and make nfs semantics closer to ufs semantics, a file that has
- * other processes using the vnode is renamed instead of removed and then
- * removed later on the last close.
- * - If v_usecount > 1
- * If a rename is not already in the works
- * call nfs_sillyrename() to set it up
- * else
- * do the remove rpc
- */
-static int
-nfs_remove(ap)
- struct vop_remove_args /* {
- struct vnodeop_desc *a_desc;
- struct vnode * a_dvp;
- struct vnode * a_vp;
- struct componentname * a_cnp;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
- register struct vnode *dvp = ap->a_dvp;
- register struct componentname *cnp = ap->a_cnp;
- register struct nfsnode *np = VTONFS(vp);
- int error = 0;
- struct vattr vattr;
-
-#ifndef DIAGNOSTIC
- if ((cnp->cn_flags & HASBUF) == 0)
- panic("nfs_remove: no name");
- if (vp->v_usecount < 1)
- panic("nfs_remove: bad v_usecount");
-#endif
- if (vp->v_type == VDIR)
- error = EPERM;
- else if (vp->v_usecount == 1 || (np->n_sillyrename &&
- VOP_GETATTR(vp, &vattr, cnp->cn_cred, cnp->cn_proc) == 0 &&
- vattr.va_nlink > 1)) {
- /*
- * Purge the name cache so that the chance of a lookup for
- * the name succeeding while the remove is in progress is
- * minimized. Without node locking it can still happen, such
- * that an I/O op returns ESTALE, but since you get this if
- * another host removes the file..
- */
- cache_purge(vp);
- /*
- * throw away biocache buffers, mainly to avoid
- * unnecessary delayed writes later.
- */
- error = nfs_vinvalbuf(vp, 0, cnp->cn_cred, cnp->cn_proc, 1);
- /* Do the rpc */
- if (error != EINTR)
- error = nfs_removerpc(dvp, cnp->cn_nameptr,
- cnp->cn_namelen, cnp->cn_cred, cnp->cn_proc);
- /*
- * Kludge City: If the first reply to the remove rpc is lost..
- * the reply to the retransmitted request will be ENOENT
- * since the file was in fact removed
- * Therefore, we cheat and return success.
- */
- if (error == ENOENT)
- error = 0;
- } else if (!np->n_sillyrename)
- error = nfs_sillyrename(dvp, vp, cnp);
- np->n_attrstamp = 0;
- return (error);
-}
-
-/*
- * nfs file remove rpc called from nfs_inactive
- */
-int
-nfs_removeit(sp)
- register struct sillyrename *sp;
-{
-
- return (nfs_removerpc(sp->s_dvp, sp->s_name, sp->s_namlen, sp->s_cred,
- (struct proc *)0));
-}
-
-/*
- * Nfs remove rpc, called from nfs_remove() and nfs_removeit().
- */
-static int
-nfs_removerpc(dvp, name, namelen, cred, proc)
- register struct vnode *dvp;
- const char *name;
- int namelen;
- struct ucred *cred;
- struct proc *proc;
-{
- register u_int32_t *tl;
- register caddr_t cp;
- register int32_t t1, t2;
- caddr_t bpos, dpos, cp2;
- int error = 0, wccflag = NFSV3_WCCRATTR;
- struct mbuf *mreq, *mrep, *md, *mb, *mb2;
- int v3 = NFS_ISV3(dvp);
-
- nfsstats.rpccnt[NFSPROC_REMOVE]++;
- nfsm_reqhead(dvp, NFSPROC_REMOVE,
- NFSX_FH(v3) + NFSX_UNSIGNED + nfsm_rndup(namelen));
- nfsm_fhtom(dvp, v3);
- nfsm_strtom(name, namelen, NFS_MAXNAMLEN);
- nfsm_request(dvp, NFSPROC_REMOVE, proc, cred);
- if (v3)
- nfsm_wcc_data(dvp, wccflag);
- nfsm_reqdone;
- VTONFS(dvp)->n_flag |= NMODIFIED;
- if (!wccflag)
- VTONFS(dvp)->n_attrstamp = 0;
- return (error);
-}
-
-/*
- * nfs file rename call
- */
-static int
-nfs_rename(ap)
- struct vop_rename_args /* {
- struct vnode *a_fdvp;
- struct vnode *a_fvp;
- struct componentname *a_fcnp;
- struct vnode *a_tdvp;
- struct vnode *a_tvp;
- struct componentname *a_tcnp;
- } */ *ap;
-{
- register struct vnode *fvp = ap->a_fvp;
- register struct vnode *tvp = ap->a_tvp;
- register struct vnode *fdvp = ap->a_fdvp;
- register struct vnode *tdvp = ap->a_tdvp;
- register struct componentname *tcnp = ap->a_tcnp;
- register struct componentname *fcnp = ap->a_fcnp;
- int error;
-
-#ifndef DIAGNOSTIC
- if ((tcnp->cn_flags & HASBUF) == 0 ||
- (fcnp->cn_flags & HASBUF) == 0)
- panic("nfs_rename: no name");
-#endif
- /* Check for cross-device rename */
- if ((fvp->v_mount != tdvp->v_mount) ||
- (tvp && (fvp->v_mount != tvp->v_mount))) {
- error = EXDEV;
- goto out;
- }
-
- /*
- * We have to flush B_DELWRI data prior to renaming
- * the file. If we don't, the delayed-write buffers
- * can be flushed out later after the file has gone stale
- * under NFSV3. NFSV2 does not have this problem because
- * ( as far as I can tell ) it flushes dirty buffers more
- * often.
- */
-
- VOP_FSYNC(fvp, fcnp->cn_cred, MNT_WAIT, fcnp->cn_proc);
- if (tvp)
- VOP_FSYNC(tvp, tcnp->cn_cred, MNT_WAIT, tcnp->cn_proc);
-
- /*
- * If the tvp exists and is in use, sillyrename it before doing the
- * rename of the new file over it.
- * XXX Can't sillyrename a directory.
- */
- if (tvp && tvp->v_usecount > 1 && !VTONFS(tvp)->n_sillyrename &&
- tvp->v_type != VDIR && !nfs_sillyrename(tdvp, tvp, tcnp)) {
- vput(tvp);
- tvp = NULL;
- }
-
- error = nfs_renamerpc(fdvp, fcnp->cn_nameptr, fcnp->cn_namelen,
- tdvp, tcnp->cn_nameptr, tcnp->cn_namelen, tcnp->cn_cred,
- tcnp->cn_proc);
-
- if (fvp->v_type == VDIR) {
- if (tvp != NULL && tvp->v_type == VDIR)
- cache_purge(tdvp);
- cache_purge(fdvp);
- }
-
-out:
- if (tdvp == tvp)
- vrele(tdvp);
- else
- vput(tdvp);
- if (tvp)
- vput(tvp);
- vrele(fdvp);
- vrele(fvp);
- /*
- * Kludge: Map ENOENT => 0 assuming that it is a reply to a retry.
- */
- if (error == ENOENT)
- error = 0;
- return (error);
-}
-
-/*
- * nfs file rename rpc called from nfs_remove() above
- */
-static int
-nfs_renameit(sdvp, scnp, sp)
- struct vnode *sdvp;
- struct componentname *scnp;
- register struct sillyrename *sp;
-{
- return (nfs_renamerpc(sdvp, scnp->cn_nameptr, scnp->cn_namelen,
- sdvp, sp->s_name, sp->s_namlen, scnp->cn_cred, scnp->cn_proc));
-}
-
-/*
- * Do an nfs rename rpc. Called from nfs_rename() and nfs_renameit().
- */
-static int
-nfs_renamerpc(fdvp, fnameptr, fnamelen, tdvp, tnameptr, tnamelen, cred, proc)
- register struct vnode *fdvp;
- const char *fnameptr;
- int fnamelen;
- register struct vnode *tdvp;
- const char *tnameptr;
- int tnamelen;
- struct ucred *cred;
- struct proc *proc;
-{
- register u_int32_t *tl;
- register caddr_t cp;
- register int32_t t1, t2;
- caddr_t bpos, dpos, cp2;
- int error = 0, fwccflag = NFSV3_WCCRATTR, twccflag = NFSV3_WCCRATTR;
- struct mbuf *mreq, *mrep, *md, *mb, *mb2;
- int v3 = NFS_ISV3(fdvp);
-
- nfsstats.rpccnt[NFSPROC_RENAME]++;
- nfsm_reqhead(fdvp, NFSPROC_RENAME,
- (NFSX_FH(v3) + NFSX_UNSIGNED)*2 + nfsm_rndup(fnamelen) +
- nfsm_rndup(tnamelen));
- nfsm_fhtom(fdvp, v3);
- nfsm_strtom(fnameptr, fnamelen, NFS_MAXNAMLEN);
- nfsm_fhtom(tdvp, v3);
- nfsm_strtom(tnameptr, tnamelen, NFS_MAXNAMLEN);
- nfsm_request(fdvp, NFSPROC_RENAME, proc, cred);
- if (v3) {
- nfsm_wcc_data(fdvp, fwccflag);
- nfsm_wcc_data(tdvp, twccflag);
- }
- nfsm_reqdone;
- VTONFS(fdvp)->n_flag |= NMODIFIED;
- VTONFS(tdvp)->n_flag |= NMODIFIED;
- if (!fwccflag)
- VTONFS(fdvp)->n_attrstamp = 0;
- if (!twccflag)
- VTONFS(tdvp)->n_attrstamp = 0;
- return (error);
-}
-
-/*
- * nfs hard link create call
- */
-static int
-nfs_link(ap)
- struct vop_link_args /* {
- struct vnode *a_tdvp;
- struct vnode *a_vp;
- struct componentname *a_cnp;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
- register struct vnode *tdvp = ap->a_tdvp;
- register struct componentname *cnp = ap->a_cnp;
- register u_int32_t *tl;
- register caddr_t cp;
- register int32_t t1, t2;
- caddr_t bpos, dpos, cp2;
- int error = 0, wccflag = NFSV3_WCCRATTR, attrflag = 0;
- struct mbuf *mreq, *mrep, *md, *mb, *mb2;
- int v3;
-
- if (vp->v_mount != tdvp->v_mount) {
- return (EXDEV);
- }
-
- /*
- * Push all writes to the server, so that the attribute cache
- * doesn't get "out of sync" with the server.
- * XXX There should be a better way!
- */
- VOP_FSYNC(vp, cnp->cn_cred, MNT_WAIT, cnp->cn_proc);
-
- v3 = NFS_ISV3(vp);
- nfsstats.rpccnt[NFSPROC_LINK]++;
- nfsm_reqhead(vp, NFSPROC_LINK,
- NFSX_FH(v3)*2 + NFSX_UNSIGNED + nfsm_rndup(cnp->cn_namelen));
- nfsm_fhtom(vp, v3);
- nfsm_fhtom(tdvp, v3);
- nfsm_strtom(cnp->cn_nameptr, cnp->cn_namelen, NFS_MAXNAMLEN);
- nfsm_request(vp, NFSPROC_LINK, cnp->cn_proc, cnp->cn_cred);
- if (v3) {
- nfsm_postop_attr(vp, attrflag);
- nfsm_wcc_data(tdvp, wccflag);
- }
- nfsm_reqdone;
- VTONFS(tdvp)->n_flag |= NMODIFIED;
- if (!attrflag)
- VTONFS(vp)->n_attrstamp = 0;
- if (!wccflag)
- VTONFS(tdvp)->n_attrstamp = 0;
- /*
- * Kludge: Map EEXIST => 0 assuming that it is a reply to a retry.
- */
- if (error == EEXIST)
- error = 0;
- return (error);
-}
-
-/*
- * nfs symbolic link create call
- */
-static int
-nfs_symlink(ap)
- struct vop_symlink_args /* {
- struct vnode *a_dvp;
- struct vnode **a_vpp;
- struct componentname *a_cnp;
- struct vattr *a_vap;
- char *a_target;
- } */ *ap;
-{
- register struct vnode *dvp = ap->a_dvp;
- register struct vattr *vap = ap->a_vap;
- register struct componentname *cnp = ap->a_cnp;
- register struct nfsv2_sattr *sp;
- register u_int32_t *tl;
- register caddr_t cp;
- register int32_t t1, t2;
- caddr_t bpos, dpos, cp2;
- int slen, error = 0, wccflag = NFSV3_WCCRATTR, gotvp;
- struct mbuf *mreq, *mrep, *md, *mb, *mb2;
- struct vnode *newvp = (struct vnode *)0;
- int v3 = NFS_ISV3(dvp);
-
- nfsstats.rpccnt[NFSPROC_SYMLINK]++;
- slen = strlen(ap->a_target);
- nfsm_reqhead(dvp, NFSPROC_SYMLINK, NFSX_FH(v3) + 2*NFSX_UNSIGNED +
- nfsm_rndup(cnp->cn_namelen) + nfsm_rndup(slen) + NFSX_SATTR(v3));
- nfsm_fhtom(dvp, v3);
- nfsm_strtom(cnp->cn_nameptr, cnp->cn_namelen, NFS_MAXNAMLEN);
- if (v3) {
- nfsm_v3attrbuild(vap, FALSE);
- }
- nfsm_strtom(ap->a_target, slen, NFS_MAXPATHLEN);
- if (!v3) {
- nfsm_build(sp, struct nfsv2_sattr *, NFSX_V2SATTR);
- sp->sa_mode = vtonfsv2_mode(VLNK, vap->va_mode);
- sp->sa_uid = nfs_xdrneg1;
- sp->sa_gid = nfs_xdrneg1;
- sp->sa_size = nfs_xdrneg1;
- txdr_nfsv2time(&vap->va_atime, &sp->sa_atime);
- txdr_nfsv2time(&vap->va_mtime, &sp->sa_mtime);
- }
-
- /*
- * Issue the NFS request and get the rpc response.
- *
- * Only NFSv3 responses returning an error of 0 actually return
- * a file handle that can be converted into newvp without having
- * to do an extra lookup rpc.
- */
- nfsm_request(dvp, NFSPROC_SYMLINK, cnp->cn_proc, cnp->cn_cred);
- if (v3) {
- if (error == 0)
- nfsm_mtofh(dvp, newvp, v3, gotvp);
- nfsm_wcc_data(dvp, wccflag);
- }
-
- /*
- * out code jumps -> here, mrep is also freed.
- */
-
- nfsm_reqdone;
-
- /*
- * If we get an EEXIST error, silently convert it to no-error
- * in case of an NFS retry.
- */
- if (error == EEXIST)
- error = 0;
-
- /*
- * If we do not have (or no longer have) an error, and we could
- * not extract the newvp from the response due to the request being
- * NFSv2 or the error being EEXIST. We have to do a lookup in order
- * to obtain a newvp to return.
- */
- if (error == 0 && newvp == NULL) {
- struct nfsnode *np = NULL;
-
- error = nfs_lookitup(dvp, cnp->cn_nameptr, cnp->cn_namelen,
- cnp->cn_cred, cnp->cn_proc, &np);
- if (!error)
- newvp = NFSTOV(np);
- }
- if (error) {
- if (newvp)
- vput(newvp);
- } else {
- *ap->a_vpp = newvp;
- }
- VTONFS(dvp)->n_flag |= NMODIFIED;
- if (!wccflag)
- VTONFS(dvp)->n_attrstamp = 0;
- return (error);
-}
-
-/*
- * nfs make dir call
- */
-static int
-nfs_mkdir(ap)
- struct vop_mkdir_args /* {
- struct vnode *a_dvp;
- struct vnode **a_vpp;
- struct componentname *a_cnp;
- struct vattr *a_vap;
- } */ *ap;
-{
- register struct vnode *dvp = ap->a_dvp;
- register struct vattr *vap = ap->a_vap;
- register struct componentname *cnp = ap->a_cnp;
- register struct nfsv2_sattr *sp;
- register u_int32_t *tl;
- register caddr_t cp;
- register int32_t t1, t2;
- register int len;
- struct nfsnode *np = (struct nfsnode *)0;
- struct vnode *newvp = (struct vnode *)0;
- caddr_t bpos, dpos, cp2;
- int error = 0, wccflag = NFSV3_WCCRATTR;
- int gotvp = 0;
- struct mbuf *mreq, *mrep, *md, *mb, *mb2;
- struct vattr vattr;
- int v3 = NFS_ISV3(dvp);
-
- if ((error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred, cnp->cn_proc)) != 0) {
- return (error);
- }
- len = cnp->cn_namelen;
- nfsstats.rpccnt[NFSPROC_MKDIR]++;
- nfsm_reqhead(dvp, NFSPROC_MKDIR,
- NFSX_FH(v3) + NFSX_UNSIGNED + nfsm_rndup(len) + NFSX_SATTR(v3));
- nfsm_fhtom(dvp, v3);
- nfsm_strtom(cnp->cn_nameptr, len, NFS_MAXNAMLEN);
- if (v3) {
- nfsm_v3attrbuild(vap, FALSE);
- } else {
- nfsm_build(sp, struct nfsv2_sattr *, NFSX_V2SATTR);
- sp->sa_mode = vtonfsv2_mode(VDIR, vap->va_mode);
- sp->sa_uid = nfs_xdrneg1;
- sp->sa_gid = nfs_xdrneg1;
- sp->sa_size = nfs_xdrneg1;
- txdr_nfsv2time(&vap->va_atime, &sp->sa_atime);
- txdr_nfsv2time(&vap->va_mtime, &sp->sa_mtime);
- }
- nfsm_request(dvp, NFSPROC_MKDIR, cnp->cn_proc, cnp->cn_cred);
- if (!error)
- nfsm_mtofh(dvp, newvp, v3, gotvp);
- if (v3)
- nfsm_wcc_data(dvp, wccflag);
- nfsm_reqdone;
- VTONFS(dvp)->n_flag |= NMODIFIED;
- if (!wccflag)
- VTONFS(dvp)->n_attrstamp = 0;
- /*
- * Kludge: Map EEXIST => 0 assuming that you have a reply to a retry
- * if we can succeed in looking up the directory.
- */
- if (error == EEXIST || (!error && !gotvp)) {
- if (newvp) {
- vrele(newvp);
- newvp = (struct vnode *)0;
- }
- error = nfs_lookitup(dvp, cnp->cn_nameptr, len, cnp->cn_cred,
- cnp->cn_proc, &np);
- if (!error) {
- newvp = NFSTOV(np);
- if (newvp->v_type != VDIR)
- error = EEXIST;
- }
- }
- if (error) {
- if (newvp)
- vrele(newvp);
- } else
- *ap->a_vpp = newvp;
- return (error);
-}
-
-/*
- * nfs remove directory call
- */
-static int
-nfs_rmdir(ap)
- struct vop_rmdir_args /* {
- struct vnode *a_dvp;
- struct vnode *a_vp;
- struct componentname *a_cnp;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
- register struct vnode *dvp = ap->a_dvp;
- register struct componentname *cnp = ap->a_cnp;
- register u_int32_t *tl;
- register caddr_t cp;
- register int32_t t1, t2;
- caddr_t bpos, dpos, cp2;
- int error = 0, wccflag = NFSV3_WCCRATTR;
- struct mbuf *mreq, *mrep, *md, *mb, *mb2;
- int v3 = NFS_ISV3(dvp);
-
- if (dvp == vp)
- return (EINVAL);
- nfsstats.rpccnt[NFSPROC_RMDIR]++;
- nfsm_reqhead(dvp, NFSPROC_RMDIR,
- NFSX_FH(v3) + NFSX_UNSIGNED + nfsm_rndup(cnp->cn_namelen));
- nfsm_fhtom(dvp, v3);
- nfsm_strtom(cnp->cn_nameptr, cnp->cn_namelen, NFS_MAXNAMLEN);
- nfsm_request(dvp, NFSPROC_RMDIR, cnp->cn_proc, cnp->cn_cred);
- if (v3)
- nfsm_wcc_data(dvp, wccflag);
- nfsm_reqdone;
- VTONFS(dvp)->n_flag |= NMODIFIED;
- if (!wccflag)
- VTONFS(dvp)->n_attrstamp = 0;
- cache_purge(dvp);
- cache_purge(vp);
- /*
- * Kludge: Map ENOENT => 0 assuming that you have a reply to a retry.
- */
- if (error == ENOENT)
- error = 0;
- return (error);
-}
-
-/*
- * nfs readdir call
- */
-static int
-nfs_readdir(ap)
- struct vop_readdir_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- struct ucred *a_cred;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
- register struct nfsnode *np = VTONFS(vp);
- register struct uio *uio = ap->a_uio;
- int tresid, error;
- struct vattr vattr;
-
- if (vp->v_type != VDIR)
- return (EPERM);
- /*
- * First, check for hit on the EOF offset cache
- */
- if (np->n_direofoffset > 0 && uio->uio_offset >= np->n_direofoffset &&
- (np->n_flag & NMODIFIED) == 0) {
- if (VFSTONFS(vp->v_mount)->nm_flag & NFSMNT_NQNFS) {
- if (NQNFS_CKCACHABLE(vp, ND_READ)) {
- nfsstats.direofcache_hits++;
- return (0);
- }
- } else if (VOP_GETATTR(vp, &vattr, ap->a_cred, uio->uio_procp) == 0 &&
- np->n_mtime == vattr.va_mtime.tv_sec) {
- nfsstats.direofcache_hits++;
- return (0);
- }
- }
-
- /*
- * Call nfs_bioread() to do the real work.
- */
- tresid = uio->uio_resid;
- error = nfs_bioread(vp, uio, 0, ap->a_cred);
-
- if (!error && uio->uio_resid == tresid)
- nfsstats.direofcache_misses++;
- return (error);
-}
-
-/*
- * Readdir rpc call.
- * Called from below the buffer cache by nfs_doio().
- */
-int
-nfs_readdirrpc(vp, uiop, cred)
- struct vnode *vp;
- register struct uio *uiop;
- struct ucred *cred;
-
-{
- register int len, left;
- register struct dirent *dp = NULL;
- register u_int32_t *tl;
- register caddr_t cp;
- register int32_t t1, t2;
- register nfsuint64 *cookiep;
- caddr_t bpos, dpos, cp2;
- struct mbuf *mreq, *mrep, *md, *mb, *mb2;
- nfsuint64 cookie;
- struct nfsmount *nmp = VFSTONFS(vp->v_mount);
- struct nfsnode *dnp = VTONFS(vp);
- u_quad_t fileno;
- int error = 0, tlen, more_dirs = 1, blksiz = 0, bigenough = 1;
- int attrflag;
- int v3 = NFS_ISV3(vp);
-
-#ifndef DIAGNOSTIC
- if (uiop->uio_iovcnt != 1 || (uiop->uio_offset & (DIRBLKSIZ - 1)) ||
- (uiop->uio_resid & (DIRBLKSIZ - 1)))
- panic("nfs readdirrpc bad uio");
-#endif
-
- /*
- * If there is no cookie, assume directory was stale.
- */
- cookiep = nfs_getcookie(dnp, uiop->uio_offset, 0);
- if (cookiep)
- cookie = *cookiep;
- else
- return (NFSERR_BAD_COOKIE);
- /*
- * Loop around doing readdir rpc's of size nm_readdirsize
- * truncated to a multiple of DIRBLKSIZ.
- * The stopping criteria is EOF or buffer full.
- */
- while (more_dirs && bigenough) {
- nfsstats.rpccnt[NFSPROC_READDIR]++;
- nfsm_reqhead(vp, NFSPROC_READDIR, NFSX_FH(v3) +
- NFSX_READDIR(v3));
- nfsm_fhtom(vp, v3);
- if (v3) {
- nfsm_build(tl, u_int32_t *, 5 * NFSX_UNSIGNED);
- *tl++ = cookie.nfsuquad[0];
- *tl++ = cookie.nfsuquad[1];
- *tl++ = dnp->n_cookieverf.nfsuquad[0];
- *tl++ = dnp->n_cookieverf.nfsuquad[1];
- } else {
- nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
- *tl++ = cookie.nfsuquad[0];
- }
- *tl = txdr_unsigned(nmp->nm_readdirsize);
- nfsm_request(vp, NFSPROC_READDIR, uiop->uio_procp, cred);
- if (v3) {
- nfsm_postop_attr(vp, attrflag);
- if (!error) {
- nfsm_dissect(tl, u_int32_t *,
- 2 * NFSX_UNSIGNED);
- dnp->n_cookieverf.nfsuquad[0] = *tl++;
- dnp->n_cookieverf.nfsuquad[1] = *tl;
- } else {
- m_freem(mrep);
- goto nfsmout;
- }
- }
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED);
- more_dirs = fxdr_unsigned(int, *tl);
-
- /* loop thru the dir entries, doctoring them to 4bsd form */
- while (more_dirs && bigenough) {
- if (v3) {
- nfsm_dissect(tl, u_int32_t *,
- 3 * NFSX_UNSIGNED);
- fileno = fxdr_hyper(tl);
- len = fxdr_unsigned(int, *(tl + 2));
- } else {
- nfsm_dissect(tl, u_int32_t *,
- 2 * NFSX_UNSIGNED);
- fileno = fxdr_unsigned(u_quad_t, *tl++);
- len = fxdr_unsigned(int, *tl);
- }
- if (len <= 0 || len > NFS_MAXNAMLEN) {
- error = EBADRPC;
- m_freem(mrep);
- goto nfsmout;
- }
- tlen = nfsm_rndup(len);
- if (tlen == len)
- tlen += 4; /* To ensure null termination */
- left = DIRBLKSIZ - blksiz;
- if ((tlen + DIRHDSIZ) > left) {
- dp->d_reclen += left;
- uiop->uio_iov->iov_base += left;
- uiop->uio_iov->iov_len -= left;
- uiop->uio_offset += left;
- uiop->uio_resid -= left;
- blksiz = 0;
- }
- if ((tlen + DIRHDSIZ) > uiop->uio_resid)
- bigenough = 0;
- if (bigenough) {
- dp = (struct dirent *)uiop->uio_iov->iov_base;
- dp->d_fileno = (int)fileno;
- dp->d_namlen = len;
- dp->d_reclen = tlen + DIRHDSIZ;
- dp->d_type = DT_UNKNOWN;
- blksiz += dp->d_reclen;
- if (blksiz == DIRBLKSIZ)
- blksiz = 0;
- uiop->uio_offset += DIRHDSIZ;
- uiop->uio_resid -= DIRHDSIZ;
- uiop->uio_iov->iov_base += DIRHDSIZ;
- uiop->uio_iov->iov_len -= DIRHDSIZ;
- nfsm_mtouio(uiop, len);
- cp = uiop->uio_iov->iov_base;
- tlen -= len;
- *cp = '\0'; /* null terminate */
- uiop->uio_iov->iov_base += tlen;
- uiop->uio_iov->iov_len -= tlen;
- uiop->uio_offset += tlen;
- uiop->uio_resid -= tlen;
- } else
- nfsm_adv(nfsm_rndup(len));
- if (v3) {
- nfsm_dissect(tl, u_int32_t *,
- 3 * NFSX_UNSIGNED);
- } else {
- nfsm_dissect(tl, u_int32_t *,
- 2 * NFSX_UNSIGNED);
- }
- if (bigenough) {
- cookie.nfsuquad[0] = *tl++;
- if (v3)
- cookie.nfsuquad[1] = *tl++;
- } else if (v3)
- tl += 2;
- else
- tl++;
- more_dirs = fxdr_unsigned(int, *tl);
- }
- /*
- * If at end of rpc data, get the eof boolean
- */
- if (!more_dirs) {
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED);
- more_dirs = (fxdr_unsigned(int, *tl) == 0);
- }
- m_freem(mrep);
- }
- /*
- * Fill last record, iff any, out to a multiple of DIRBLKSIZ
- * by increasing d_reclen for the last record.
- */
- if (blksiz > 0) {
- left = DIRBLKSIZ - blksiz;
- dp->d_reclen += left;
- uiop->uio_iov->iov_base += left;
- uiop->uio_iov->iov_len -= left;
- uiop->uio_offset += left;
- uiop->uio_resid -= left;
- }
-
- /*
- * We are now either at the end of the directory or have filled the
- * block.
- */
- if (bigenough)
- dnp->n_direofoffset = uiop->uio_offset;
- else {
- if (uiop->uio_resid > 0)
- printf("EEK! readdirrpc resid > 0\n");
- cookiep = nfs_getcookie(dnp, uiop->uio_offset, 1);
- *cookiep = cookie;
- }
-nfsmout:
- return (error);
-}
-
-/*
- * NFS V3 readdir plus RPC. Used in place of nfs_readdirrpc().
- */
-int
-nfs_readdirplusrpc(vp, uiop, cred)
- struct vnode *vp;
- register struct uio *uiop;
- struct ucred *cred;
-{
- register int len, left;
- register struct dirent *dp;
- register u_int32_t *tl;
- register caddr_t cp;
- register int32_t t1, t2;
- register struct vnode *newvp;
- register nfsuint64 *cookiep;
- caddr_t bpos, dpos, cp2, dpossav1, dpossav2;
- struct mbuf *mreq, *mrep, *md, *mb, *mb2, *mdsav1, *mdsav2;
- struct nameidata nami, *ndp = &nami;
- struct componentname *cnp = &ndp->ni_cnd;
- nfsuint64 cookie;
- struct nfsmount *nmp = VFSTONFS(vp->v_mount);
- struct nfsnode *dnp = VTONFS(vp), *np;
- nfsfh_t *fhp;
- u_quad_t fileno;
- int error = 0, tlen, more_dirs = 1, blksiz = 0, doit, bigenough = 1, i;
- int attrflag, fhsize;
-
-#ifndef nolint
- dp = (struct dirent *)0;
-#endif
-#ifndef DIAGNOSTIC
- if (uiop->uio_iovcnt != 1 || (uiop->uio_offset & (DIRBLKSIZ - 1)) ||
- (uiop->uio_resid & (DIRBLKSIZ - 1)))
- panic("nfs readdirplusrpc bad uio");
-#endif
- ndp->ni_dvp = vp;
- newvp = NULLVP;
-
- /*
- * If there is no cookie, assume directory was stale.
- */
- cookiep = nfs_getcookie(dnp, uiop->uio_offset, 0);
- if (cookiep)
- cookie = *cookiep;
- else
- return (NFSERR_BAD_COOKIE);
- /*
- * Loop around doing readdir rpc's of size nm_readdirsize
- * truncated to a multiple of DIRBLKSIZ.
- * The stopping criteria is EOF or buffer full.
- */
- while (more_dirs && bigenough) {
- nfsstats.rpccnt[NFSPROC_READDIRPLUS]++;
- nfsm_reqhead(vp, NFSPROC_READDIRPLUS,
- NFSX_FH(1) + 6 * NFSX_UNSIGNED);
- nfsm_fhtom(vp, 1);
- nfsm_build(tl, u_int32_t *, 6 * NFSX_UNSIGNED);
- *tl++ = cookie.nfsuquad[0];
- *tl++ = cookie.nfsuquad[1];
- *tl++ = dnp->n_cookieverf.nfsuquad[0];
- *tl++ = dnp->n_cookieverf.nfsuquad[1];
- *tl++ = txdr_unsigned(nmp->nm_readdirsize);
- *tl = txdr_unsigned(nmp->nm_rsize);
- nfsm_request(vp, NFSPROC_READDIRPLUS, uiop->uio_procp, cred);
- nfsm_postop_attr(vp, attrflag);
- if (error) {
- m_freem(mrep);
- goto nfsmout;
- }
- nfsm_dissect(tl, u_int32_t *, 3 * NFSX_UNSIGNED);
- dnp->n_cookieverf.nfsuquad[0] = *tl++;
- dnp->n_cookieverf.nfsuquad[1] = *tl++;
- more_dirs = fxdr_unsigned(int, *tl);
-
- /* loop thru the dir entries, doctoring them to 4bsd form */
- while (more_dirs && bigenough) {
- nfsm_dissect(tl, u_int32_t *, 3 * NFSX_UNSIGNED);
- fileno = fxdr_hyper(tl);
- len = fxdr_unsigned(int, *(tl + 2));
- if (len <= 0 || len > NFS_MAXNAMLEN) {
- error = EBADRPC;
- m_freem(mrep);
- goto nfsmout;
- }
- tlen = nfsm_rndup(len);
- if (tlen == len)
- tlen += 4; /* To ensure null termination*/
- left = DIRBLKSIZ - blksiz;
- if ((tlen + DIRHDSIZ) > left) {
- dp->d_reclen += left;
- uiop->uio_iov->iov_base += left;
- uiop->uio_iov->iov_len -= left;
- uiop->uio_offset += left;
- uiop->uio_resid -= left;
- blksiz = 0;
- }
- if ((tlen + DIRHDSIZ) > uiop->uio_resid)
- bigenough = 0;
- if (bigenough) {
- dp = (struct dirent *)uiop->uio_iov->iov_base;
- dp->d_fileno = (int)fileno;
- dp->d_namlen = len;
- dp->d_reclen = tlen + DIRHDSIZ;
- dp->d_type = DT_UNKNOWN;
- blksiz += dp->d_reclen;
- if (blksiz == DIRBLKSIZ)
- blksiz = 0;
- uiop->uio_offset += DIRHDSIZ;
- uiop->uio_resid -= DIRHDSIZ;
- uiop->uio_iov->iov_base += DIRHDSIZ;
- uiop->uio_iov->iov_len -= DIRHDSIZ;
- cnp->cn_nameptr = uiop->uio_iov->iov_base;
- cnp->cn_namelen = len;
- nfsm_mtouio(uiop, len);
- cp = uiop->uio_iov->iov_base;
- tlen -= len;
- *cp = '\0';
- uiop->uio_iov->iov_base += tlen;
- uiop->uio_iov->iov_len -= tlen;
- uiop->uio_offset += tlen;
- uiop->uio_resid -= tlen;
- } else
- nfsm_adv(nfsm_rndup(len));
- nfsm_dissect(tl, u_int32_t *, 3 * NFSX_UNSIGNED);
- if (bigenough) {
- cookie.nfsuquad[0] = *tl++;
- cookie.nfsuquad[1] = *tl++;
- } else
- tl += 2;
-
- /*
- * Since the attributes are before the file handle
- * (sigh), we must skip over the attributes and then
- * come back and get them.
- */
- attrflag = fxdr_unsigned(int, *tl);
- if (attrflag) {
- dpossav1 = dpos;
- mdsav1 = md;
- nfsm_adv(NFSX_V3FATTR);
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED);
- doit = fxdr_unsigned(int, *tl);
- if (doit) {
- nfsm_getfh(fhp, fhsize, 1);
- if (NFS_CMPFH(dnp, fhp, fhsize)) {
- VREF(vp);
- newvp = vp;
- np = dnp;
- } else {
- error = nfs_nget(vp->v_mount, fhp,
- fhsize, &np);
- if (error)
- doit = 0;
- else
- newvp = NFSTOV(np);
- }
- }
- if (doit && bigenough) {
- dpossav2 = dpos;
- dpos = dpossav1;
- mdsav2 = md;
- md = mdsav1;
- nfsm_loadattr(newvp, (struct vattr *)0);
- dpos = dpossav2;
- md = mdsav2;
- dp->d_type =
- IFTODT(VTTOIF(np->n_vattr.va_type));
- ndp->ni_vp = newvp;
- cache_enter(ndp->ni_dvp, ndp->ni_vp, cnp);
- }
- } else {
- /* Just skip over the file handle */
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED);
- i = fxdr_unsigned(int, *tl);
- nfsm_adv(nfsm_rndup(i));
- }
- if (newvp != NULLVP) {
- if (newvp == vp)
- vrele(newvp);
- else
- vput(newvp);
- newvp = NULLVP;
- }
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED);
- more_dirs = fxdr_unsigned(int, *tl);
- }
- /*
- * If at end of rpc data, get the eof boolean
- */
- if (!more_dirs) {
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED);
- more_dirs = (fxdr_unsigned(int, *tl) == 0);
- }
- m_freem(mrep);
- }
- /*
- * Fill last record, iff any, out to a multiple of DIRBLKSIZ
- * by increasing d_reclen for the last record.
- */
- if (blksiz > 0) {
- left = DIRBLKSIZ - blksiz;
- dp->d_reclen += left;
- uiop->uio_iov->iov_base += left;
- uiop->uio_iov->iov_len -= left;
- uiop->uio_offset += left;
- uiop->uio_resid -= left;
- }
-
- /*
- * We are now either at the end of the directory or have filled the
- * block.
- */
- if (bigenough)
- dnp->n_direofoffset = uiop->uio_offset;
- else {
- if (uiop->uio_resid > 0)
- printf("EEK! readdirplusrpc resid > 0\n");
- cookiep = nfs_getcookie(dnp, uiop->uio_offset, 1);
- *cookiep = cookie;
- }
-nfsmout:
- if (newvp != NULLVP) {
- if (newvp == vp)
- vrele(newvp);
- else
- vput(newvp);
- newvp = NULLVP;
- }
- return (error);
-}
-
-/*
- * Silly rename. To make the NFS filesystem that is stateless look a little
- * more like the "ufs" a remove of an active vnode is translated to a rename
- * to a funny looking filename that is removed by nfs_inactive on the
- * nfsnode. There is the potential for another process on a different client
- * to create the same funny name between the nfs_lookitup() fails and the
- * nfs_rename() completes, but...
- */
-static int
-nfs_sillyrename(dvp, vp, cnp)
- struct vnode *dvp, *vp;
- struct componentname *cnp;
-{
- register struct sillyrename *sp;
- struct nfsnode *np;
- int error;
- short pid;
-
- cache_purge(dvp);
- np = VTONFS(vp);
-#ifndef DIAGNOSTIC
- if (vp->v_type == VDIR)
- panic("nfs: sillyrename dir");
-#endif
- MALLOC(sp, struct sillyrename *, sizeof (struct sillyrename),
- M_NFSREQ, M_WAITOK);
- sp->s_cred = crdup(cnp->cn_cred);
- sp->s_dvp = dvp;
- VREF(dvp);
-
- /* Fudge together a funny name */
- pid = cnp->cn_proc->p_pid;
- sp->s_namlen = sprintf(sp->s_name, ".nfsA%04x4.4", pid);
-
- /* Try lookitups until we get one that isn't there */
- while (nfs_lookitup(dvp, sp->s_name, sp->s_namlen, sp->s_cred,
- cnp->cn_proc, (struct nfsnode **)0) == 0) {
- sp->s_name[4]++;
- if (sp->s_name[4] > 'z') {
- error = EINVAL;
- goto bad;
- }
- }
- error = nfs_renameit(dvp, cnp, sp);
- if (error)
- goto bad;
- error = nfs_lookitup(dvp, sp->s_name, sp->s_namlen, sp->s_cred,
- cnp->cn_proc, &np);
- np->n_sillyrename = sp;
- return (0);
-bad:
- vrele(sp->s_dvp);
- crfree(sp->s_cred);
- free((caddr_t)sp, M_NFSREQ);
- return (error);
-}
-
-/*
- * Look up a file name and optionally either update the file handle or
- * allocate an nfsnode, depending on the value of npp.
- * npp == NULL --> just do the lookup
- * *npp == NULL --> allocate a new nfsnode and make sure attributes are
- * handled too
- * *npp != NULL --> update the file handle in the vnode
- */
-static int
-nfs_lookitup(dvp, name, len, cred, procp, npp)
- register struct vnode *dvp;
- const char *name;
- int len;
- struct ucred *cred;
- struct proc *procp;
- struct nfsnode **npp;
-{
- register u_int32_t *tl;
- register caddr_t cp;
- register int32_t t1, t2;
- struct vnode *newvp = (struct vnode *)0;
- struct nfsnode *np, *dnp = VTONFS(dvp);
- caddr_t bpos, dpos, cp2;
- int error = 0, fhlen, attrflag;
- struct mbuf *mreq, *mrep, *md, *mb, *mb2;
- nfsfh_t *nfhp;
- int v3 = NFS_ISV3(dvp);
-
- nfsstats.rpccnt[NFSPROC_LOOKUP]++;
- nfsm_reqhead(dvp, NFSPROC_LOOKUP,
- NFSX_FH(v3) + NFSX_UNSIGNED + nfsm_rndup(len));
- nfsm_fhtom(dvp, v3);
- nfsm_strtom(name, len, NFS_MAXNAMLEN);
- nfsm_request(dvp, NFSPROC_LOOKUP, procp, cred);
- if (npp && !error) {
- nfsm_getfh(nfhp, fhlen, v3);
- if (*npp) {
- np = *npp;
- if (np->n_fhsize > NFS_SMALLFH && fhlen <= NFS_SMALLFH) {
- free((caddr_t)np->n_fhp, M_NFSBIGFH);
- np->n_fhp = &np->n_fh;
- } else if (np->n_fhsize <= NFS_SMALLFH && fhlen>NFS_SMALLFH)
- np->n_fhp =(nfsfh_t *)malloc(fhlen,M_NFSBIGFH,M_WAITOK);
- bcopy((caddr_t)nfhp, (caddr_t)np->n_fhp, fhlen);
- np->n_fhsize = fhlen;
- newvp = NFSTOV(np);
- } else if (NFS_CMPFH(dnp, nfhp, fhlen)) {
- VREF(dvp);
- newvp = dvp;
- } else {
- error = nfs_nget(dvp->v_mount, nfhp, fhlen, &np);
- if (error) {
- m_freem(mrep);
- return (error);
- }
- newvp = NFSTOV(np);
- }
- if (v3) {
- nfsm_postop_attr(newvp, attrflag);
- if (!attrflag && *npp == NULL) {
- m_freem(mrep);
- if (newvp == dvp)
- vrele(newvp);
- else
- vput(newvp);
- return (ENOENT);
- }
- } else
- nfsm_loadattr(newvp, (struct vattr *)0);
- }
- nfsm_reqdone;
- if (npp && *npp == NULL) {
- if (error) {
- if (newvp) {
- if (newvp == dvp)
- vrele(newvp);
- else
- vput(newvp);
- }
- } else
- *npp = np;
- }
- return (error);
-}
-
-/*
- * Nfs Version 3 commit rpc
- */
-int
-nfs_commit(vp, offset, cnt, cred, procp)
- struct vnode *vp;
- u_quad_t offset;
- int cnt;
- struct ucred *cred;
- struct proc *procp;
-{
- register caddr_t cp;
- register u_int32_t *tl;
- register int32_t t1, t2;
- register struct nfsmount *nmp = VFSTONFS(vp->v_mount);
- caddr_t bpos, dpos, cp2;
- int error = 0, wccflag = NFSV3_WCCRATTR;
- struct mbuf *mreq, *mrep, *md, *mb, *mb2;
-
- if ((nmp->nm_state & NFSSTA_HASWRITEVERF) == 0)
- return (0);
- nfsstats.rpccnt[NFSPROC_COMMIT]++;
- nfsm_reqhead(vp, NFSPROC_COMMIT, NFSX_FH(1));
- nfsm_fhtom(vp, 1);
- nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED);
- txdr_hyper(offset, tl);
- tl += 2;
- *tl = txdr_unsigned(cnt);
- nfsm_request(vp, NFSPROC_COMMIT, procp, cred);
- nfsm_wcc_data(vp, wccflag);
- if (!error) {
- nfsm_dissect(tl, u_int32_t *, NFSX_V3WRITEVERF);
- if (bcmp((caddr_t)nmp->nm_verf, (caddr_t)tl,
- NFSX_V3WRITEVERF)) {
- bcopy((caddr_t)tl, (caddr_t)nmp->nm_verf,
- NFSX_V3WRITEVERF);
- error = NFSERR_STALEWRITEVERF;
- }
- }
- nfsm_reqdone;
- return (error);
-}
-
-/*
- * Kludge City..
- * - make nfs_bmap() essentially a no-op that does no translation
- * - do nfs_strategy() by doing I/O with nfs_readrpc/nfs_writerpc
- * (Maybe I could use the process's page mapping, but I was concerned that
- * Kernel Write might not be enabled and also figured copyout() would do
- * a lot more work than bcopy() and also it currently happens in the
- * context of the swapper process (2).
- */
-static int
-nfs_bmap(ap)
- struct vop_bmap_args /* {
- struct vnode *a_vp;
- daddr_t a_bn;
- struct vnode **a_vpp;
- daddr_t *a_bnp;
- int *a_runp;
- int *a_runb;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
-
- if (ap->a_vpp != NULL)
- *ap->a_vpp = vp;
- if (ap->a_bnp != NULL)
- *ap->a_bnp = ap->a_bn * btodb(vp->v_mount->mnt_stat.f_iosize);
- if (ap->a_runp != NULL)
- *ap->a_runp = 0;
- if (ap->a_runb != NULL)
- *ap->a_runb = 0;
- return (0);
-}
-
-/*
- * Strategy routine.
- * For async requests when nfsiod(s) are running, queue the request by
- * calling nfs_asyncio(), otherwise just all nfs_doio() to do the
- * request.
- */
-static int
-nfs_strategy(ap)
- struct vop_strategy_args *ap;
-{
- register struct buf *bp = ap->a_bp;
- struct ucred *cr;
- struct proc *p;
- int error = 0;
-
- KASSERT(!(bp->b_flags & B_DONE), ("nfs_strategy: buffer %p unexpectedly marked B_DONE", bp));
- KASSERT(BUF_REFCNT(bp) > 0, ("nfs_strategy: buffer %p not locked", bp));
-
- if (bp->b_flags & B_PHYS)
- panic("nfs physio");
-
- if (bp->b_flags & B_ASYNC)
- p = (struct proc *)0;
- else
- p = curproc; /* XXX */
-
- if (bp->b_flags & B_READ)
- cr = bp->b_rcred;
- else
- cr = bp->b_wcred;
-
- /*
- * If the op is asynchronous and an i/o daemon is waiting
- * queue the request, wake it up and wait for completion
- * otherwise just do it ourselves.
- */
- if ((bp->b_flags & B_ASYNC) == 0 ||
- nfs_asyncio(bp, NOCRED, p))
- error = nfs_doio(bp, cr, p);
- return (error);
-}
-
-/*
- * Mmap a file
- *
- * NB Currently unsupported.
- */
-/* ARGSUSED */
-static int
-nfs_mmap(ap)
- struct vop_mmap_args /* {
- struct vnode *a_vp;
- int a_fflags;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
-
- return (EINVAL);
-}
-
-/*
- * fsync vnode op. Just call nfs_flush() with commit == 1.
- */
-/* ARGSUSED */
-static int
-nfs_fsync(ap)
- struct vop_fsync_args /* {
- struct vnodeop_desc *a_desc;
- struct vnode * a_vp;
- struct ucred * a_cred;
- int a_waitfor;
- struct proc * a_p;
- } */ *ap;
-{
-
- return (nfs_flush(ap->a_vp, ap->a_cred, ap->a_waitfor, ap->a_p, 1));
-}
-
-/*
- * Flush all the blocks associated with a vnode.
- * Walk through the buffer pool and push any dirty pages
- * associated with the vnode.
- */
-static int
-nfs_flush(vp, cred, waitfor, p, commit)
- register struct vnode *vp;
- struct ucred *cred;
- int waitfor;
- struct proc *p;
- int commit;
-{
- register struct nfsnode *np = VTONFS(vp);
- register struct buf *bp;
- register int i;
- struct buf *nbp;
- struct nfsmount *nmp = VFSTONFS(vp->v_mount);
- int s, error = 0, slptimeo = 0, slpflag = 0, retv, bvecpos;
- int passone = 1;
- u_quad_t off, endoff, toff;
- struct ucred* wcred = NULL;
- struct buf **bvec = NULL;
-#ifndef NFS_COMMITBVECSIZ
-#define NFS_COMMITBVECSIZ 20
-#endif
- struct buf *bvec_on_stack[NFS_COMMITBVECSIZ];
- int bvecsize = 0, bveccount;
-
- if (nmp->nm_flag & NFSMNT_INT)
- slpflag = PCATCH;
- if (!commit)
- passone = 0;
- /*
- * A b_flags == (B_DELWRI | B_NEEDCOMMIT) block has been written to the
- * server, but nas not been committed to stable storage on the server
- * yet. On the first pass, the byte range is worked out and the commit
- * rpc is done. On the second pass, nfs_writebp() is called to do the
- * job.
- */
-again:
- off = (u_quad_t)-1;
- endoff = 0;
- bvecpos = 0;
- if (NFS_ISV3(vp) && commit) {
- s = splbio();
- /*
- * Count up how many buffers waiting for a commit.
- */
- bveccount = 0;
- for (bp = TAILQ_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) {
- nbp = TAILQ_NEXT(bp, b_vnbufs);
- if (BUF_REFCNT(bp) == 0 &&
- (bp->b_flags & (B_DELWRI | B_NEEDCOMMIT))
- == (B_DELWRI | B_NEEDCOMMIT))
- bveccount++;
- }
- /*
- * Allocate space to remember the list of bufs to commit. It is
- * important to use M_NOWAIT here to avoid a race with nfs_write.
- * If we can't get memory (for whatever reason), we will end up
- * committing the buffers one-by-one in the loop below.
- */
- if (bveccount > NFS_COMMITBVECSIZ) {
- if (bvec != NULL && bvec != bvec_on_stack)
- free(bvec, M_TEMP);
- bvec = (struct buf **)
- malloc(bveccount * sizeof(struct buf *),
- M_TEMP, M_NOWAIT);
- if (bvec == NULL) {
- bvec = bvec_on_stack;
- bvecsize = NFS_COMMITBVECSIZ;
- } else
- bvecsize = bveccount;
- } else {
- bvec = bvec_on_stack;
- bvecsize = NFS_COMMITBVECSIZ;
- }
- for (bp = TAILQ_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) {
- nbp = TAILQ_NEXT(bp, b_vnbufs);
- if (bvecpos >= bvecsize)
- break;
- if ((bp->b_flags & (B_DELWRI | B_NEEDCOMMIT)) !=
- (B_DELWRI | B_NEEDCOMMIT) ||
- BUF_LOCK(bp, LK_EXCLUSIVE | LK_NOWAIT))
- continue;
- bremfree(bp);
- /*
- * Work out if all buffers are using the same cred
- * so we can deal with them all with one commit.
- *
- * NOTE: we are not clearing B_DONE here, so we have
- * to do it later on in this routine if we intend to
- * initiate I/O on the bp.
- */
- if (wcred == NULL)
- wcred = bp->b_wcred;
- else if (wcred != bp->b_wcred)
- wcred = NOCRED;
- bp->b_flags |= B_WRITEINPROG;
- vfs_busy_pages(bp, 1);
-
- /*
- * bp is protected by being locked, but nbp is not
- * and vfs_busy_pages() may sleep. We have to
- * recalculate nbp.
- */
- nbp = TAILQ_NEXT(bp, b_vnbufs);
-
- /*
- * A list of these buffers is kept so that the
- * second loop knows which buffers have actually
- * been committed. This is necessary, since there
- * may be a race between the commit rpc and new
- * uncommitted writes on the file.
- */
- bvec[bvecpos++] = bp;
- toff = ((u_quad_t)bp->b_blkno) * DEV_BSIZE +
- bp->b_dirtyoff;
- if (toff < off)
- off = toff;
- toff += (u_quad_t)(bp->b_dirtyend - bp->b_dirtyoff);
- if (toff > endoff)
- endoff = toff;
- }
- splx(s);
- }
- if (bvecpos > 0) {
- /*
- * Commit data on the server, as required.
- * If all bufs are using the same wcred, then use that with
- * one call for all of them, otherwise commit each one
- * separately.
- */
- if (wcred != NOCRED)
- retv = nfs_commit(vp, off, (int)(endoff - off),
- wcred, p);
- else {
- retv = 0;
- for (i = 0; i < bvecpos; i++) {
- off_t off, size;
- bp = bvec[i];
- off = ((u_quad_t)bp->b_blkno) * DEV_BSIZE +
- bp->b_dirtyoff;
- size = (u_quad_t)(bp->b_dirtyend
- - bp->b_dirtyoff);
- retv = nfs_commit(vp, off, (int)size,
- bp->b_wcred, p);
- if (retv) break;
- }
- }
-
- if (retv == NFSERR_STALEWRITEVERF)
- nfs_clearcommit(vp->v_mount);
-
- /*
- * Now, either mark the blocks I/O done or mark the
- * blocks dirty, depending on whether the commit
- * succeeded.
- */
- for (i = 0; i < bvecpos; i++) {
- bp = bvec[i];
- bp->b_flags &= ~(B_NEEDCOMMIT | B_WRITEINPROG | B_CLUSTEROK);
- if (retv) {
- /*
- * Error, leave B_DELWRI intact
- */
- vfs_unbusy_pages(bp);
- brelse(bp);
- } else {
- /*
- * Success, remove B_DELWRI ( bundirty() ).
- *
- * b_dirtyoff/b_dirtyend seem to be NFS
- * specific. We should probably move that
- * into bundirty(). XXX
- */
- s = splbio();
- vp->v_numoutput++;
- bp->b_flags |= B_ASYNC;
- bundirty(bp);
- bp->b_flags &= ~(B_READ|B_DONE|B_ERROR);
- bp->b_dirtyoff = bp->b_dirtyend = 0;
- splx(s);
- biodone(bp);
- }
- }
- }
-
- /*
- * Start/do any write(s) that are required.
- */
-loop:
- s = splbio();
- for (bp = TAILQ_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) {
- nbp = TAILQ_NEXT(bp, b_vnbufs);
- if (BUF_LOCK(bp, LK_EXCLUSIVE | LK_NOWAIT)) {
- if (waitfor != MNT_WAIT || passone)
- continue;
- error = BUF_TIMELOCK(bp, LK_EXCLUSIVE | LK_SLEEPFAIL,
- "nfsfsync", slpflag, slptimeo);
- splx(s);
- if (error == 0)
- panic("nfs_fsync: inconsistent lock");
- if (error == ENOLCK)
- goto loop;
- if (nfs_sigintr(nmp, (struct nfsreq *)0, p)) {
- error = EINTR;
- goto done;
- }
- if (slpflag == PCATCH) {
- slpflag = 0;
- slptimeo = 2 * hz;
- }
- goto loop;
- }
- if ((bp->b_flags & B_DELWRI) == 0)
- panic("nfs_fsync: not dirty");
- if ((passone || !commit) && (bp->b_flags & B_NEEDCOMMIT)) {
- BUF_UNLOCK(bp);
- continue;
- }
- bremfree(bp);
- if (passone || !commit)
- bp->b_flags |= B_ASYNC;
- else
- bp->b_flags |= B_ASYNC | B_WRITEINPROG;
- splx(s);
- VOP_BWRITE(bp->b_vp, bp);
- goto loop;
- }
- splx(s);
- if (passone) {
- passone = 0;
- goto again;
- }
- if (waitfor == MNT_WAIT) {
- while (vp->v_numoutput) {
- vp->v_flag |= VBWAIT;
- error = tsleep((caddr_t)&vp->v_numoutput,
- slpflag | (PRIBIO + 1), "nfsfsync", slptimeo);
- if (error) {
- if (nfs_sigintr(nmp, (struct nfsreq *)0, p)) {
- error = EINTR;
- goto done;
- }
- if (slpflag == PCATCH) {
- slpflag = 0;
- slptimeo = 2 * hz;
- }
- }
- }
- if (!TAILQ_EMPTY(&vp->v_dirtyblkhd) && commit) {
- goto loop;
- }
- }
- if (np->n_flag & NWRITEERR) {
- error = np->n_error;
- np->n_flag &= ~NWRITEERR;
- }
-done:
- if (bvec != NULL && bvec != bvec_on_stack)
- free(bvec, M_TEMP);
- return (error);
-}
-
-/*
- * NFS advisory byte-level locks.
- * Currently unsupported.
- */
-static int
-nfs_advlock(ap)
- struct vop_advlock_args /* {
- struct vnode *a_vp;
- caddr_t a_id;
- int a_op;
- struct flock *a_fl;
- int a_flags;
- } */ *ap;
-{
- register struct nfsnode *np = VTONFS(ap->a_vp);
-
- /*
- * The following kludge is to allow diskless support to work
- * until a real NFS lockd is implemented. Basically, just pretend
- * that this is a local lock.
- */
- return (lf_advlock(ap, &(np->n_lockf), np->n_size));
-}
-
-/*
- * Print out the contents of an nfsnode.
- */
-static int
-nfs_print(ap)
- struct vop_print_args /* {
- struct vnode *a_vp;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
- register struct nfsnode *np = VTONFS(vp);
-
- printf("tag VT_NFS, fileid %ld fsid 0x%x",
- np->n_vattr.va_fileid, np->n_vattr.va_fsid);
- if (vp->v_type == VFIFO)
- fifo_printinfo(vp);
- printf("\n");
- return (0);
-}
-
-/*
- * Just call nfs_writebp() with the force argument set to 1.
- *
- * NOTE: B_DONE may or may not be set in a_bp on call.
- */
-static int
-nfs_bwrite(ap)
- struct vop_bwrite_args /* {
- struct vnode *a_bp;
- } */ *ap;
-{
- return (nfs_writebp(ap->a_bp, 1, curproc));
-}
-
-/*
- * This is a clone of vn_bwrite(), except that B_WRITEINPROG isn't set unless
- * the force flag is one and it also handles the B_NEEDCOMMIT flag. We set
- * B_CACHE if this is a VMIO buffer.
- */
-int
-nfs_writebp(bp, force, procp)
- register struct buf *bp;
- int force;
- struct proc *procp;
-{
- int s;
- int oldflags = bp->b_flags;
-#if 0
- int retv = 1;
- off_t off;
-#endif
-
- if (BUF_REFCNT(bp) == 0)
- panic("bwrite: buffer is not locked???");
-
- if (bp->b_flags & B_INVAL) {
- brelse(bp);
- return(0);
- }
-
- bp->b_flags |= B_CACHE;
-
- /*
- * Undirty the bp. We will redirty it later if the I/O fails.
- */
-
- s = splbio();
- bundirty(bp);
- bp->b_flags &= ~(B_READ|B_DONE|B_ERROR);
-
- bp->b_vp->v_numoutput++;
- curproc->p_stats->p_ru.ru_oublock++;
- splx(s);
-
- vfs_busy_pages(bp, 1);
- if (force)
- bp->b_flags |= B_WRITEINPROG;
- BUF_KERNPROC(bp);
- VOP_STRATEGY(bp->b_vp, bp);
-
- if( (oldflags & B_ASYNC) == 0) {
- int rtval = biowait(bp);
-
- if (oldflags & B_DELWRI) {
- s = splbio();
- reassignbuf(bp, bp->b_vp);
- splx(s);
- }
-
- brelse(bp);
- return (rtval);
- }
-
- return (0);
-}
-
-/*
- * nfs special file access vnode op.
- * Essentially just get vattr and then imitate iaccess() since the device is
- * local to the client.
- */
-static int
-nfsspec_access(ap)
- struct vop_access_args /* {
- struct vnode *a_vp;
- int a_mode;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- register struct vattr *vap;
- register gid_t *gp;
- register struct ucred *cred = ap->a_cred;
- struct vnode *vp = ap->a_vp;
- mode_t mode = ap->a_mode;
- struct vattr vattr;
- register int i;
- int error;
-
- /*
- * Disallow write attempts on filesystems mounted read-only;
- * unless the file is a socket, fifo, or a block or character
- * device resident on the filesystem.
- */
- if ((mode & VWRITE) && (vp->v_mount->mnt_flag & MNT_RDONLY)) {
- switch (vp->v_type) {
- case VREG:
- case VDIR:
- case VLNK:
- return (EROFS);
- default:
- break;
- }
- }
- /*
- * If you're the super-user,
- * you always get access.
- */
- if (cred->cr_uid == 0)
- return (0);
- vap = &vattr;
- error = VOP_GETATTR(vp, vap, cred, ap->a_p);
- if (error)
- return (error);
- /*
- * Access check is based on only one of owner, group, public.
- * If not owner, then check group. If not a member of the
- * group, then check public access.
- */
- if (cred->cr_uid != vap->va_uid) {
- mode >>= 3;
- gp = cred->cr_groups;
- for (i = 0; i < cred->cr_ngroups; i++, gp++)
- if (vap->va_gid == *gp)
- goto found;
- mode >>= 3;
-found:
- ;
- }
- error = (vap->va_mode & mode) == mode ? 0 : EACCES;
- return (error);
-}
-
-/*
- * Read wrapper for special devices.
- */
-static int
-nfsspec_read(ap)
- struct vop_read_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- int a_ioflag;
- struct ucred *a_cred;
- } */ *ap;
-{
- register struct nfsnode *np = VTONFS(ap->a_vp);
-
- /*
- * Set access flag.
- */
- np->n_flag |= NACC;
- getnanotime(&np->n_atim);
- return (VOCALL(spec_vnodeop_p, VOFFSET(vop_read), ap));
-}
-
-/*
- * Write wrapper for special devices.
- */
-static int
-nfsspec_write(ap)
- struct vop_write_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- int a_ioflag;
- struct ucred *a_cred;
- } */ *ap;
-{
- register struct nfsnode *np = VTONFS(ap->a_vp);
-
- /*
- * Set update flag.
- */
- np->n_flag |= NUPD;
- getnanotime(&np->n_mtim);
- return (VOCALL(spec_vnodeop_p, VOFFSET(vop_write), ap));
-}
-
-/*
- * Close wrapper for special devices.
- *
- * Update the times on the nfsnode then do device close.
- */
-static int
-nfsspec_close(ap)
- struct vop_close_args /* {
- struct vnode *a_vp;
- int a_fflag;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
- register struct nfsnode *np = VTONFS(vp);
- struct vattr vattr;
-
- if (np->n_flag & (NACC | NUPD)) {
- np->n_flag |= NCHG;
- if (vp->v_usecount == 1 &&
- (vp->v_mount->mnt_flag & MNT_RDONLY) == 0) {
- VATTR_NULL(&vattr);
- if (np->n_flag & NACC)
- vattr.va_atime = np->n_atim;
- if (np->n_flag & NUPD)
- vattr.va_mtime = np->n_mtim;
- (void)VOP_SETATTR(vp, &vattr, ap->a_cred, ap->a_p);
- }
- }
- return (VOCALL(spec_vnodeop_p, VOFFSET(vop_close), ap));
-}
-
-/*
- * Read wrapper for fifos.
- */
-static int
-nfsfifo_read(ap)
- struct vop_read_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- int a_ioflag;
- struct ucred *a_cred;
- } */ *ap;
-{
- register struct nfsnode *np = VTONFS(ap->a_vp);
-
- /*
- * Set access flag.
- */
- np->n_flag |= NACC;
- getnanotime(&np->n_atim);
- return (VOCALL(fifo_vnodeop_p, VOFFSET(vop_read), ap));
-}
-
-/*
- * Write wrapper for fifos.
- */
-static int
-nfsfifo_write(ap)
- struct vop_write_args /* {
- struct vnode *a_vp;
- struct uio *a_uio;
- int a_ioflag;
- struct ucred *a_cred;
- } */ *ap;
-{
- register struct nfsnode *np = VTONFS(ap->a_vp);
-
- /*
- * Set update flag.
- */
- np->n_flag |= NUPD;
- getnanotime(&np->n_mtim);
- return (VOCALL(fifo_vnodeop_p, VOFFSET(vop_write), ap));
-}
-
-/*
- * Close wrapper for fifos.
- *
- * Update the times on the nfsnode then do fifo close.
- */
-static int
-nfsfifo_close(ap)
- struct vop_close_args /* {
- struct vnode *a_vp;
- int a_fflag;
- struct ucred *a_cred;
- struct proc *a_p;
- } */ *ap;
-{
- register struct vnode *vp = ap->a_vp;
- register struct nfsnode *np = VTONFS(vp);
- struct vattr vattr;
- struct timespec ts;
-
- if (np->n_flag & (NACC | NUPD)) {
- getnanotime(&ts);
- if (np->n_flag & NACC)
- np->n_atim = ts;
- if (np->n_flag & NUPD)
- np->n_mtim = ts;
- np->n_flag |= NCHG;
- if (vp->v_usecount == 1 &&
- (vp->v_mount->mnt_flag & MNT_RDONLY) == 0) {
- VATTR_NULL(&vattr);
- if (np->n_flag & NACC)
- vattr.va_atime = np->n_atim;
- if (np->n_flag & NUPD)
- vattr.va_mtime = np->n_mtim;
- (void)VOP_SETATTR(vp, &vattr, ap->a_cred, ap->a_p);
- }
- }
- return (VOCALL(fifo_vnodeop_p, VOFFSET(vop_close), ap));
-}
diff --git a/sys/nfsclient/nfsargs.h b/sys/nfsclient/nfsargs.h
deleted file mode 100644
index e07a4f5315d1..000000000000
--- a/sys/nfsclient/nfsargs.h
+++ /dev/null
@@ -1,727 +0,0 @@
-/*
- * Copyright (c) 1989, 1993, 1995
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Rick Macklem at The University of Guelph.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)nfs.h 8.4 (Berkeley) 5/1/95
- * $FreeBSD$
- */
-
-#ifndef _NFS_NFS_H_
-#define _NFS_NFS_H_
-
-#ifdef _KERNEL
-#include "opt_nfs.h"
-#endif
-
-/*
- * Tunable constants for nfs
- */
-
-#define NFS_MAXIOVEC 34
-#define NFS_TICKINTVL 5 /* Desired time for a tick (msec) */
-#define NFS_HZ (hz / nfs_ticks) /* Ticks/sec */
-#define NFS_TIMEO (1 * NFS_HZ) /* Default timeout = 1 second */
-#define NFS_MINTIMEO (1 * NFS_HZ) /* Min timeout to use */
-#define NFS_MAXTIMEO (60 * NFS_HZ) /* Max timeout to backoff to */
-#define NFS_MINIDEMTIMEO (5 * NFS_HZ) /* Min timeout for non-idempotent ops*/
-#define NFS_MAXREXMIT 100 /* Stop counting after this many */
-#define NFS_MAXWINDOW 1024 /* Max number of outstanding requests */
-#define NFS_RETRANS 10 /* Num of retrans for soft mounts */
-#define NFS_MAXGRPS 16 /* Max. size of groups list */
-#ifndef NFS_MINATTRTIMO
-#define NFS_MINATTRTIMO 3 /* VREG attrib cache timeout in sec */
-#endif
-#ifndef NFS_MAXATTRTIMO
-#define NFS_MAXATTRTIMO 60
-#endif
-#ifndef NFS_MINDIRATTRTIMO
-#define NFS_MINDIRATTRTIMO 30 /* VDIR attrib cache timeout in sec */
-#endif
-#ifndef NFS_MAXDIRATTRTIMO
-#define NFS_MAXDIRATTRTIMO 60
-#endif
-#define NFS_WSIZE 8192 /* Def. write data size <= 8192 */
-#define NFS_RSIZE 8192 /* Def. read data size <= 8192 */
-#define NFS_READDIRSIZE 8192 /* Def. readdir size */
-#define NFS_DEFRAHEAD 1 /* Def. read ahead # blocks */
-#define NFS_MAXRAHEAD 4 /* Max. read ahead # blocks */
-#define NFS_MAXUIDHASH 64 /* Max. # of hashed uid entries/mp */
-#define NFS_MAXASYNCDAEMON 20 /* Max. number async_daemons runnable */
-#define NFS_MAXGATHERDELAY 100 /* Max. write gather delay (msec) */
-#ifndef NFS_GATHERDELAY
-#define NFS_GATHERDELAY 10 /* Default write gather delay (msec) */
-#endif
-#define NFS_DIRBLKSIZ 4096 /* Must be a multiple of DIRBLKSIZ */
-#ifdef _KERNEL
-#define DIRBLKSIZ 512 /* XXX we used to use ufs's DIRBLKSIZ */
-#endif
-
-/*
- * Oddballs
- */
-#define NMOD(a) ((a) % nfs_asyncdaemons)
-#define NFS_CMPFH(n, f, s) \
- ((n)->n_fhsize == (s) && !bcmp((caddr_t)(n)->n_fhp, (caddr_t)(f), (s)))
-#define NFS_ISV3(v) (VFSTONFS((v)->v_mount)->nm_flag & NFSMNT_NFSV3)
-#define NFS_SRVMAXDATA(n) \
- (((n)->nd_flag & ND_NFSV3) ? (((n)->nd_nam2) ? \
- NFS_MAXDGRAMDATA : NFS_MAXDATA) : NFS_V2MAXDATA)
-
-/*
- * XXX
- * The B_INVAFTERWRITE flag should be set to whatever is required by the
- * buffer cache code to say "Invalidate the block after it is written back".
- */
-#define B_INVAFTERWRITE B_NOCACHE
-
-/*
- * The IO_METASYNC flag should be implemented for local file systems.
- * (Until then, it is nothin at all.)
- */
-#ifndef IO_METASYNC
-#define IO_METASYNC 0
-#endif
-
-/*
- * Arguments to mount NFS
- */
-#define NFS_ARGSVERSION 3 /* change when nfs_args changes */
-struct nfs_args {
- int version; /* args structure version number */
- struct sockaddr *addr; /* file server address */
- int addrlen; /* length of address */
- int sotype; /* Socket type */
- int proto; /* and Protocol */
- u_char *fh; /* File handle to be mounted */
- int fhsize; /* Size, in bytes, of fh */
- int flags; /* flags */
- int wsize; /* write size in bytes */
- int rsize; /* read size in bytes */
- int readdirsize; /* readdir size in bytes */
- int timeo; /* initial timeout in .1 secs */
- int retrans; /* times to retry send */
- int maxgrouplist; /* Max. size of group list */
- int readahead; /* # of blocks to readahead */
- int leaseterm; /* Term (sec) of lease */
- int deadthresh; /* Retrans threshold */
- char *hostname; /* server's name */
- int acregmin; /* cache attrs for reg files min time */
- int acregmax; /* cache attrs for reg files max time */
- int acdirmin; /* cache attrs for dirs min time */
- int acdirmax; /* cache attrs for dirs max time */
-};
-
-/*
- * NFS mount option flags
- */
-#define NFSMNT_SOFT 0x00000001 /* soft mount (hard is default) */
-#define NFSMNT_WSIZE 0x00000002 /* set write size */
-#define NFSMNT_RSIZE 0x00000004 /* set read size */
-#define NFSMNT_TIMEO 0x00000008 /* set initial timeout */
-#define NFSMNT_RETRANS 0x00000010 /* set number of request retries */
-#define NFSMNT_MAXGRPS 0x00000020 /* set maximum grouplist size */
-#define NFSMNT_INT 0x00000040 /* allow interrupts on hard mount */
-#define NFSMNT_NOCONN 0x00000080 /* Don't Connect the socket */
-#define NFSMNT_NQNFS 0x00000100 /* Use Nqnfs protocol */
-#define NFSMNT_NFSV3 0x00000200 /* Use NFS Version 3 protocol */
-#define NFSMNT_KERB 0x00000400 /* Use Kerberos authentication */
-#define NFSMNT_DUMBTIMR 0x00000800 /* Don't estimate rtt dynamically */
-#define NFSMNT_LEASETERM 0x00001000 /* set lease term (nqnfs) */
-#define NFSMNT_READAHEAD 0x00002000 /* set read ahead */
-#define NFSMNT_DEADTHRESH 0x00004000 /* set dead server retry thresh */
-#define NFSMNT_RESVPORT 0x00008000 /* Allocate a reserved port */
-#define NFSMNT_RDIRPLUS 0x00010000 /* Use Readdirplus for V3 */
-#define NFSMNT_READDIRSIZE 0x00020000 /* Set readdir size */
-#define NFSMNT_ACREGMIN 0x00040000
-#define NFSMNT_ACREGMAX 0x00080000
-#define NFSMNT_ACDIRMIN 0x00100000
-#define NFSMNT_ACDIRMAX 0x00200000
-
-#define NFSSTA_HASWRITEVERF 0x00040000 /* Has write verifier for V3 */
-#define NFSSTA_GOTPATHCONF 0x00080000 /* Got the V3 pathconf info */
-#define NFSSTA_GOTFSINFO 0x00100000 /* Got the V3 fsinfo */
-#define NFSSTA_MNTD 0x00200000 /* Mnt server for mnt point */
-#define NFSSTA_DISMINPROG 0x00400000 /* Dismount in progress */
-#define NFSSTA_DISMNT 0x00800000 /* Dismounted */
-#define NFSSTA_SNDLOCK 0x01000000 /* Send socket lock */
-#define NFSSTA_WANTSND 0x02000000 /* Want above */
-#define NFSSTA_RCVLOCK 0x04000000 /* Rcv socket lock */
-#define NFSSTA_WANTRCV 0x08000000 /* Want above */
-#define NFSSTA_WAITAUTH 0x10000000 /* Wait for authentication */
-#define NFSSTA_HASAUTH 0x20000000 /* Has authenticator */
-#define NFSSTA_WANTAUTH 0x40000000 /* Wants an authenticator */
-#define NFSSTA_AUTHERR 0x80000000 /* Authentication error */
-
-/*
- * Structures for the nfssvc(2) syscall. Not that anyone but nfsd and mount_nfs
- * should ever try and use it.
- */
-struct nfsd_args {
- int sock; /* Socket to serve */
- caddr_t name; /* Client addr for connection based sockets */
- int namelen; /* Length of name */
-};
-
-struct nfsd_srvargs {
- struct nfsd *nsd_nfsd; /* Pointer to in kernel nfsd struct */
- uid_t nsd_uid; /* Effective uid mapped to cred */
- u_int32_t nsd_haddr; /* Ip address of client */
- struct ucred nsd_cr; /* Cred. uid maps to */
- int nsd_authlen; /* Length of auth string (ret) */
- u_char *nsd_authstr; /* Auth string (ret) */
- int nsd_verflen; /* and the verfier */
- u_char *nsd_verfstr;
- struct timeval nsd_timestamp; /* timestamp from verifier */
- u_int32_t nsd_ttl; /* credential ttl (sec) */
- NFSKERBKEY_T nsd_key; /* Session key */
-};
-
-struct nfsd_cargs {
- char *ncd_dirp; /* Mount dir path */
- uid_t ncd_authuid; /* Effective uid */
- int ncd_authtype; /* Type of authenticator */
- int ncd_authlen; /* Length of authenticator string */
- u_char *ncd_authstr; /* Authenticator string */
- int ncd_verflen; /* and the verifier */
- u_char *ncd_verfstr;
- NFSKERBKEY_T ncd_key; /* Session key */
-};
-
-/*
- * XXX to allow amd to include nfs.h without nfsproto.h
- */
-#ifdef NFS_NPROCS
-/*
- * Stats structure
- */
-struct nfsstats {
- int attrcache_hits;
- int attrcache_misses;
- int lookupcache_hits;
- int lookupcache_misses;
- int direofcache_hits;
- int direofcache_misses;
- int biocache_reads;
- int read_bios;
- int read_physios;
- int biocache_writes;
- int write_bios;
- int write_physios;
- int biocache_readlinks;
- int readlink_bios;
- int biocache_readdirs;
- int readdir_bios;
- int rpccnt[NFS_NPROCS];
- int rpcretries;
- int srvrpccnt[NFS_NPROCS];
- int srvrpc_errs;
- int srv_errs;
- int rpcrequests;
- int rpctimeouts;
- int rpcunexpected;
- int rpcinvalid;
- int srvcache_inproghits;
- int srvcache_idemdonehits;
- int srvcache_nonidemdonehits;
- int srvcache_misses;
- int srvnqnfs_leases;
- int srvnqnfs_maxleases;
- int srvnqnfs_getleases;
- int srvvop_writes;
- int accesscache_hits;
- int accesscache_misses;
-};
-#endif
-
-/*
- * Flags for nfssvc() system call.
- */
-#define NFSSVC_BIOD 0x002
-#define NFSSVC_NFSD 0x004
-#define NFSSVC_ADDSOCK 0x008
-#define NFSSVC_AUTHIN 0x010
-#define NFSSVC_GOTAUTH 0x040
-#define NFSSVC_AUTHINFAIL 0x080
-#define NFSSVC_MNTD 0x100
-
-/*
- * fs.nfs sysctl(3) identifiers
- */
-#define NFS_NFSSTATS 1 /* struct: struct nfsstats */
-#define NFS_NFSPRIVPORT 2 /* int: prohibit nfs to resvports */
-
-#define FS_NFS_NAMES { \
- { 0, 0 }, \
- { "nfsstats", CTLTYPE_STRUCT }, \
- { "nfsprivport", CTLTYPE_INT }, \
-}
-
-#ifdef _KERNEL
-
-#ifdef MALLOC_DECLARE
-MALLOC_DECLARE(M_NFSREQ);
-MALLOC_DECLARE(M_NFSDIROFF);
-MALLOC_DECLARE(M_NFSRVDESC);
-MALLOC_DECLARE(M_NFSUID);
-MALLOC_DECLARE(M_NQLEASE);
-MALLOC_DECLARE(M_NFSD);
-MALLOC_DECLARE(M_NFSBIGFH);
-MALLOC_DECLARE(M_NFSHASH);
-#endif
-
-#ifdef ZONE_INTERRUPT
-extern vm_zone_t nfsmount_zone;
-#endif
-
-extern struct callout_handle nfs_timer_handle;
-
-struct uio; struct buf; struct vattr; struct nameidata; /* XXX */
-
-/*
- * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts.
- * What should be in this set is open to debate, but I believe that since
- * I/O system calls on ufs are never interrupted by signals the set should
- * be minimal. My reasoning is that many current programs that use signals
- * such as SIGALRM will not expect file I/O system calls to be interrupted
- * by them and break.
- */
-#define NFSINT_SIGMASK(set) \
- (SIGISMEMBER(set, SIGINT) || SIGISMEMBER(set, SIGTERM) || \
- SIGISMEMBER(set, SIGHUP) || SIGISMEMBER(set, SIGKILL) || \
- SIGISMEMBER(set, SIGQUIT))
-
-/*
- * Socket errors ignored for connectionless sockets??
- * For now, ignore them all
- */
-#define NFSIGNORE_SOERROR(s, e) \
- ((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \
- ((s) & PR_CONNREQUIRED) == 0)
-
-/*
- * Nfs outstanding request list element
- */
-struct nfsreq {
- TAILQ_ENTRY(nfsreq) r_chain;
- struct mbuf *r_mreq;
- struct mbuf *r_mrep;
- struct mbuf *r_md;
- caddr_t r_dpos;
- struct nfsmount *r_nmp;
- struct vnode *r_vp;
- u_int32_t r_xid;
- int r_flags; /* flags on request, see below */
- int r_retry; /* max retransmission count */
- int r_rexmit; /* current retrans count */
- int r_timer; /* tick counter on reply */
- u_int32_t r_procnum; /* NFS procedure number */
- int r_rtt; /* RTT for rpc */
- struct proc *r_procp; /* Proc that did I/O system call */
-};
-
-/*
- * Queue head for nfsreq's
- */
-extern TAILQ_HEAD(nfs_reqq, nfsreq) nfs_reqq;
-
-/* Flag values for r_flags */
-#define R_TIMING 0x01 /* timing request (in mntp) */
-#define R_SENT 0x02 /* request has been sent */
-#define R_SOFTTERM 0x04 /* soft mnt, too many retries */
-#define R_INTR 0x08 /* intr mnt, signal pending */
-#define R_SOCKERR 0x10 /* Fatal error on socket */
-#define R_TPRINTFMSG 0x20 /* Did a tprintf msg. */
-#define R_MUSTRESEND 0x40 /* Must resend request */
-#define R_GETONEREP 0x80 /* Probe for one reply only */
-
-/*
- * A list of nfssvc_sock structures is maintained with all the sockets
- * that require service by the nfsd.
- * The nfsuid structs hang off of the nfssvc_sock structs in both lru
- * and uid hash lists.
- */
-#ifndef NFS_UIDHASHSIZ
-#define NFS_UIDHASHSIZ 29 /* Tune the size of nfssvc_sock with this */
-#endif
-#define NUIDHASH(sock, uid) \
- (&(sock)->ns_uidhashtbl[(uid) % NFS_UIDHASHSIZ])
-#ifndef NFS_WDELAYHASHSIZ
-#define NFS_WDELAYHASHSIZ 16 /* and with this */
-#endif
-#define NWDELAYHASH(sock, f) \
- (&(sock)->ns_wdelayhashtbl[(*((u_int32_t *)(f))) % NFS_WDELAYHASHSIZ])
-#ifndef NFS_MUIDHASHSIZ
-#define NFS_MUIDHASHSIZ 63 /* Tune the size of nfsmount with this */
-#endif
-#define NMUIDHASH(nmp, uid) \
- (&(nmp)->nm_uidhashtbl[(uid) % NFS_MUIDHASHSIZ])
-#define NFSNOHASH(fhsum) \
- (&nfsnodehashtbl[(fhsum) & nfsnodehash])
-
-/*
- * Network address hash list element
- */
-union nethostaddr {
- u_int32_t had_inetaddr;
- struct sockaddr *had_nam;
-};
-
-struct nfsuid {
- TAILQ_ENTRY(nfsuid) nu_lru; /* LRU chain */
- LIST_ENTRY(nfsuid) nu_hash; /* Hash list */
- int nu_flag; /* Flags */
- union nethostaddr nu_haddr; /* Host addr. for dgram sockets */
- struct ucred nu_cr; /* Cred uid mapped to */
- int nu_expire; /* Expiry time (sec) */
- struct timeval nu_timestamp; /* Kerb. timestamp */
- u_int32_t nu_nickname; /* Nickname on server */
- NFSKERBKEY_T nu_key; /* and session key */
-};
-
-#define nu_inetaddr nu_haddr.had_inetaddr
-#define nu_nam nu_haddr.had_nam
-/* Bits for nu_flag */
-#define NU_INETADDR 0x1
-#define NU_NAM 0x2
-#define NU_NETFAM(u) (((u)->nu_flag & NU_INETADDR) ? AF_INET : AF_ISO)
-
-struct nfsrv_rec {
- STAILQ_ENTRY(nfsrv_rec) nr_link;
- struct sockaddr *nr_address;
- struct mbuf *nr_packet;
-};
-
-struct nfssvc_sock {
- TAILQ_ENTRY(nfssvc_sock) ns_chain; /* List of all nfssvc_sock's */
- TAILQ_HEAD(, nfsuid) ns_uidlruhead;
- struct file *ns_fp;
- struct socket *ns_so;
- struct sockaddr *ns_nam;
- struct mbuf *ns_raw;
- struct mbuf *ns_rawend;
- STAILQ_HEAD(, nfsrv_rec) ns_rec;
- struct mbuf *ns_frag;
- int ns_flag;
- int ns_solock;
- int ns_cc;
- int ns_reclen;
- int ns_numuids;
- u_int32_t ns_sref;
- LIST_HEAD(, nfsrv_descript) ns_tq; /* Write gather lists */
- LIST_HEAD(, nfsuid) ns_uidhashtbl[NFS_UIDHASHSIZ];
- LIST_HEAD(nfsrvw_delayhash, nfsrv_descript) ns_wdelayhashtbl[NFS_WDELAYHASHSIZ];
-};
-
-/* Bits for "ns_flag" */
-#define SLP_VALID 0x01
-#define SLP_DOREC 0x02
-#define SLP_NEEDQ 0x04
-#define SLP_DISCONN 0x08
-#define SLP_GETSTREAM 0x10
-#define SLP_LASTFRAG 0x20
-#define SLP_ALLFLAGS 0xff
-
-extern TAILQ_HEAD(nfssvc_sockhead, nfssvc_sock) nfssvc_sockhead;
-extern int nfssvc_sockhead_flag;
-#define SLP_INIT 0x01
-#define SLP_WANTINIT 0x02
-
-/*
- * One of these structures is allocated for each nfsd.
- */
-struct nfsd {
- TAILQ_ENTRY(nfsd) nfsd_chain; /* List of all nfsd's */
- int nfsd_flag; /* NFSD_ flags */
- struct nfssvc_sock *nfsd_slp; /* Current socket */
- int nfsd_authlen; /* Authenticator len */
- u_char nfsd_authstr[RPCAUTH_MAXSIZ]; /* Authenticator data */
- int nfsd_verflen; /* and the Verifier */
- u_char nfsd_verfstr[RPCVERF_MAXSIZ];
- struct proc *nfsd_procp; /* Proc ptr */
- struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */
-};
-
-/* Bits for "nfsd_flag" */
-#define NFSD_WAITING 0x01
-#define NFSD_REQINPROG 0x02
-#define NFSD_NEEDAUTH 0x04
-#define NFSD_AUTHFAIL 0x08
-
-/*
- * This structure is used by the server for describing each request.
- * Some fields are used only when write request gathering is performed.
- */
-struct nfsrv_descript {
- u_quad_t nd_time; /* Write deadline (usec) */
- off_t nd_off; /* Start byte offset */
- off_t nd_eoff; /* and end byte offset */
- LIST_ENTRY(nfsrv_descript) nd_hash; /* Hash list */
- LIST_ENTRY(nfsrv_descript) nd_tq; /* and timer list */
- LIST_HEAD(,nfsrv_descript) nd_coalesce; /* coalesced writes */
- struct mbuf *nd_mrep; /* Request mbuf list */
- struct mbuf *nd_md; /* Current dissect mbuf */
- struct mbuf *nd_mreq; /* Reply mbuf list */
- struct sockaddr *nd_nam; /* and socket addr */
- struct sockaddr *nd_nam2; /* return socket addr */
- caddr_t nd_dpos; /* Current dissect pos */
- u_int32_t nd_procnum; /* RPC # */
- int nd_stable; /* storage type */
- int nd_flag; /* nd_flag */
- int nd_len; /* Length of this write */
- int nd_repstat; /* Reply status */
- u_int32_t nd_retxid; /* Reply xid */
- u_int32_t nd_duration; /* Lease duration */
- struct timeval nd_starttime; /* Time RPC initiated */
- fhandle_t nd_fh; /* File handle */
- struct ucred nd_cr; /* Credentials */
-};
-
-/* Bits for "nd_flag" */
-#define ND_READ LEASE_READ
-#define ND_WRITE LEASE_WRITE
-#define ND_CHECK 0x04
-#define ND_LEASE (ND_READ | ND_WRITE | ND_CHECK)
-#define ND_NFSV3 0x08
-#define ND_NQNFS 0x10
-#define ND_KERBNICK 0x20
-#define ND_KERBFULL 0x40
-#define ND_KERBAUTH (ND_KERBNICK | ND_KERBFULL)
-
-extern TAILQ_HEAD(nfsd_head, nfsd) nfsd_head;
-extern int nfsd_head_flag;
-#define NFSD_CHECKSLP 0x01
-
-/*
- * These macros compare nfsrv_descript structures.
- */
-#define NFSW_CONTIG(o, n) \
- ((o)->nd_eoff >= (n)->nd_off && \
- !bcmp((caddr_t)&(o)->nd_fh, (caddr_t)&(n)->nd_fh, NFSX_V3FH))
-
-#define NFSW_SAMECRED(o, n) \
- (((o)->nd_flag & ND_KERBAUTH) == ((n)->nd_flag & ND_KERBAUTH) && \
- !bcmp((caddr_t)&(o)->nd_cr, (caddr_t)&(n)->nd_cr, \
- sizeof (struct ucred)))
-
-/*
- * Defines for WebNFS
- */
-
-#define WEBNFS_ESC_CHAR '%'
-#define WEBNFS_SPECCHAR_START 0x80
-
-#define WEBNFS_NATIVE_CHAR 0x80
-/*
- * ..
- * Possibly more here in the future.
- */
-
-/*
- * Macro for converting escape characters in WebNFS pathnames.
- * Should really be in libkern.
- */
-
-#define HEXTOC(c) \
- ((c) >= 'a' ? ((c) - ('a' - 10)) : \
- ((c) >= 'A' ? ((c) - ('A' - 10)) : ((c) - '0')))
-#define HEXSTRTOI(p) \
- ((HEXTOC(p[0]) << 4) + HEXTOC(p[1]))
-
-#ifdef NFS_DEBUG
-
-extern int nfs_debug;
-#define NFS_DEBUG_ASYNCIO 1 /* asynchronous i/o */
-#define NFS_DEBUG_WG 2 /* server write gathering */
-#define NFS_DEBUG_RC 4 /* server request caching */
-
-#define NFS_DPF(cat, args) \
- do { \
- if (nfs_debug & NFS_DEBUG_##cat) printf args; \
- } while (0)
-
-#else
-
-#define NFS_DPF(cat, args)
-
-#endif
-
-u_quad_t nfs_curusec __P((void));
-int nfs_init __P((struct vfsconf *vfsp));
-int nfs_uninit __P((struct vfsconf *vfsp));
-int nfs_reply __P((struct nfsreq *));
-int nfs_getreq __P((struct nfsrv_descript *,struct nfsd *,int));
-int nfs_send __P((struct socket *, struct sockaddr *, struct mbuf *,
- struct nfsreq *));
-int nfs_rephead __P((int, struct nfsrv_descript *, struct nfssvc_sock *,
- int, int, u_quad_t *, struct mbuf **, struct mbuf **,
- caddr_t *));
-int nfs_sndlock __P((struct nfsreq *));
-void nfs_sndunlock __P((struct nfsreq *));
-int nfs_slplock __P((struct nfssvc_sock *, int));
-void nfs_slpunlock __P((struct nfssvc_sock *));
-int nfs_disct __P((struct mbuf **, caddr_t *, int, int, caddr_t *));
-int nfs_vinvalbuf __P((struct vnode *, int, struct ucred *, struct proc *,
- int));
-int nfs_readrpc __P((struct vnode *, struct uio *, struct ucred *));
-int nfs_writerpc __P((struct vnode *, struct uio *, struct ucred *, int *,
- int *));
-int nfs_commit __P((struct vnode *vp, u_quad_t offset, int cnt,
- struct ucred *cred, struct proc *procp));
-int nfs_readdirrpc __P((struct vnode *, struct uio *, struct ucred *));
-int nfs_asyncio __P((struct buf *, struct ucred *, struct proc *));
-int nfs_doio __P((struct buf *, struct ucred *, struct proc *));
-int nfs_readlinkrpc __P((struct vnode *, struct uio *, struct ucred *));
-int nfs_sigintr __P((struct nfsmount *, struct nfsreq *, struct proc *));
-int nfs_readdirplusrpc __P((struct vnode *, struct uio *, struct ucred *));
-int nfsm_disct __P((struct mbuf **, caddr_t *, int, int, caddr_t *));
-void nfsm_srvfattr __P((struct nfsrv_descript *, struct vattr *,
- struct nfs_fattr *));
-void nfsm_srvwcc __P((struct nfsrv_descript *, int, struct vattr *, int,
- struct vattr *, struct mbuf **, char **));
-void nfsm_srvpostopattr __P((struct nfsrv_descript *, int, struct vattr *,
- struct mbuf **, char **));
-int netaddr_match __P((int, union nethostaddr *, struct sockaddr *));
-int nfs_request __P((struct vnode *, struct mbuf *, int, struct proc *,
- struct ucred *, struct mbuf **, struct mbuf **,
- caddr_t *));
-int nfs_loadattrcache __P((struct vnode **, struct mbuf **, caddr_t *,
- struct vattr *));
-int nfs_namei __P((struct nameidata *, fhandle_t *, int,
- struct nfssvc_sock *, struct sockaddr *, struct mbuf **,
- caddr_t *, struct vnode **, struct proc *, int, int));
-void nfsm_adj __P((struct mbuf *, int, int));
-int nfsm_mbuftouio __P((struct mbuf **, struct uio *, int, caddr_t *));
-void nfsrv_initcache __P((void));
-int nfs_getauth __P((struct nfsmount *, struct nfsreq *, struct ucred *,
- char **, int *, char *, int *, NFSKERBKEY_T));
-int nfs_getnickauth __P((struct nfsmount *, struct ucred *, char **,
- int *, char *, int));
-int nfs_savenickauth __P((struct nfsmount *, struct ucred *, int,
- NFSKERBKEY_T, struct mbuf **, char **,
- struct mbuf *));
-int nfs_adv __P((struct mbuf **, caddr_t *, int, int));
-void nfs_nhinit __P((void));
-void nfs_timer __P((void*));
-u_long nfs_hash __P((nfsfh_t *, int));
-int nfsrv_dorec __P((struct nfssvc_sock *, struct nfsd *,
- struct nfsrv_descript **));
-int nfsrv_getcache __P((struct nfsrv_descript *, struct nfssvc_sock *,
- struct mbuf **));
-void nfsrv_updatecache __P((struct nfsrv_descript *, int, struct mbuf *));
-void nfsrv_cleancache __P((void));
-int nfs_connect __P((struct nfsmount *, struct nfsreq *));
-void nfs_disconnect __P((struct nfsmount *));
-void nfs_safedisconnect __P((struct nfsmount *));
-int nfs_getattrcache __P((struct vnode *, struct vattr *));
-int nfsm_strtmbuf __P((struct mbuf **, char **, const char *, long));
-int nfs_bioread __P((struct vnode *, struct uio *, int, struct ucred *));
-int nfsm_uiotombuf __P((struct uio *, struct mbuf **, int, caddr_t *));
-void nfsrv_init __P((int));
-void nfs_clearcommit __P((struct mount *));
-int nfsrv_errmap __P((struct nfsrv_descript *, int));
-void nfsrvw_sort __P((gid_t *, int));
-void nfsrv_setcred __P((struct ucred *, struct ucred *));
-int nfs_writebp __P((struct buf *, int, struct proc *));
-int nfsrv_object_create __P((struct vnode *));
-void nfsrv_wakenfsd __P((struct nfssvc_sock *slp));
-int nfsrv_writegather __P((struct nfsrv_descript **, struct nfssvc_sock *,
- struct proc *, struct mbuf **));
-int nfs_fsinfo __P((struct nfsmount *, struct vnode *, struct ucred *,
- struct proc *p));
-
-int nfsrv3_access __P((struct nfsrv_descript *nfsd,
- struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_commit __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_create __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_fhtovp __P((fhandle_t *, int, struct vnode **, struct ucred *,
- struct nfssvc_sock *, struct sockaddr *, int *,
- int, int));
-int nfsrv_setpublicfs __P((struct mount *, struct netexport *,
- struct export_args *));
-int nfs_ispublicfh __P((fhandle_t *));
-int nfsrv_fsinfo __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_getattr __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_link __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_lookup __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_mkdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_mknod __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_noop __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_null __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_pathconf __P((struct nfsrv_descript *nfsd,
- struct nfssvc_sock *slp, struct proc *procp,
- struct mbuf **mrq));
-int nfsrv_read __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_readdir __P((struct nfsrv_descript *nfsd,
- struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_readdirplus __P((struct nfsrv_descript *nfsd,
- struct nfssvc_sock *slp, struct proc *procp,
- struct mbuf **mrq));
-int nfsrv_readlink __P((struct nfsrv_descript *nfsd,
- struct nfssvc_sock *slp, struct proc *procp,
- struct mbuf **mrq));
-int nfsrv_remove __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_rename __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_rmdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_setattr __P((struct nfsrv_descript *nfsd,
- struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_statfs __P((struct nfsrv_descript *nfsd,
- struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_symlink __P((struct nfsrv_descript *nfsd,
- struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_write __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-void nfsrv_rcv __P((struct socket *so, void *arg, int waitflag));
-void nfsrv_slpderef __P((struct nfssvc_sock *slp));
-#endif /* _KERNEL */
-
-#endif
diff --git a/sys/nfsclient/nfsdiskless.h b/sys/nfsclient/nfsdiskless.h
deleted file mode 100644
index 487e0bf65226..000000000000
--- a/sys/nfsclient/nfsdiskless.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (c) 1991, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Rick Macklem at The University of Guelph.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)nfsdiskless.h 8.2 (Berkeley) 3/30/95
- * $FreeBSD$
- */
-
-
-#ifndef _NFS_NFSDISKLESS_H_
-#define _NFS_NFSDISKLESS_H_
-
-/*
- * Structure that must be initialized for a diskless nfs client.
- * This structure is used by nfs_mountroot() to set up the root vnode,
- * and to do a partial ifconfig(8) and route(8) so that the critical net
- * interface can communicate with the server.
- * The primary bootstrap is expected to fill in the appropriate fields before
- * starting the kernel. Whether or not the swap area is nfs mounted is
- * determined by the value in swdevt[0]. (equal to NODEV --> swap over nfs)
- * Currently only works for AF_INET protocols.
- * NB: All fields are stored in net byte order to avoid hassles with
- * client/server byte ordering differences.
- */
-
-/*
- * I have defined a new structure that can handle an NFS Version 3 file handle
- * but the kernel still expects the old Version 2 one to be provided. The
- * changes required in nfs_vfsops.c for using the new are documented there in
- * comments. (I felt that breaking network booting code by changing this
- * structure would not be prudent at this time, since almost all servers are
- * still Version 2 anyhow.)
- */
-struct nfsv3_diskless {
- struct ifaliasreq myif; /* Default interface */
- struct sockaddr_in mygateway; /* Default gateway */
- struct nfs_args swap_args; /* Mount args for swap file */
- int swap_fhsize; /* Size of file handle */
- u_char swap_fh[NFSX_V3FHMAX]; /* Swap file's file handle */
- struct sockaddr_in swap_saddr; /* Address of swap server */
- char swap_hostnam[MNAMELEN]; /* Host name for mount pt */
- int swap_nblks; /* Size of server swap file */
- struct ucred swap_ucred; /* Swap credentials */
- struct nfs_args root_args; /* Mount args for root fs */
- int root_fhsize; /* Size of root file handle */
- u_char root_fh[NFSX_V3FHMAX]; /* File handle of root dir */
- struct sockaddr_in root_saddr; /* Address of root server */
- char root_hostnam[MNAMELEN]; /* Host name for mount pt */
- long root_time; /* Timestamp of root fs */
- char my_hostnam[MAXHOSTNAMELEN]; /* Client host name */
-};
-
-/*
- * Old arguments to mount NFS
- */
-struct onfs_args {
- struct sockaddr *addr; /* file server address */
- int addrlen; /* length of address */
- int sotype; /* Socket type */
- int proto; /* and Protocol */
- u_char *fh; /* File handle to be mounted */
- int fhsize; /* Size, in bytes, of fh */
- int flags; /* flags */
- int wsize; /* write size in bytes */
- int rsize; /* read size in bytes */
- int readdirsize; /* readdir size in bytes */
- int timeo; /* initial timeout in .1 secs */
- int retrans; /* times to retry send */
- int maxgrouplist; /* Max. size of group list */
- int readahead; /* # of blocks to readahead */
- int leaseterm; /* Term (sec) of lease */
- int deadthresh; /* Retrans threshold */
- char *hostname; /* server's name */
-};
-
-struct nfs_diskless {
- struct ifaliasreq myif; /* Default interface */
- struct sockaddr_in mygateway; /* Default gateway */
- struct onfs_args swap_args; /* Mount args for swap file */
- u_char swap_fh[NFSX_V2FH]; /* Swap file's file handle */
- struct sockaddr_in swap_saddr; /* Address of swap server */
- char swap_hostnam[MNAMELEN]; /* Host name for mount pt */
- int swap_nblks; /* Size of server swap file */
- struct ucred swap_ucred; /* Swap credentials */
- struct onfs_args root_args; /* Mount args for root fs */
- u_char root_fh[NFSX_V2FH]; /* File handle of root dir */
- struct sockaddr_in root_saddr; /* Address of root server */
- char root_hostnam[MNAMELEN]; /* Host name for mount pt */
- long root_time; /* Timestamp of root fs */
- char my_hostnam[MAXHOSTNAMELEN]; /* Client host name */
-};
-
-#endif
diff --git a/sys/nfsclient/nfsm_subs.h b/sys/nfsclient/nfsm_subs.h
deleted file mode 100644
index b13c0099b816..000000000000
--- a/sys/nfsclient/nfsm_subs.h
+++ /dev/null
@@ -1,564 +0,0 @@
-/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Rick Macklem at The University of Guelph.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)nfsm_subs.h 8.2 (Berkeley) 3/30/95
- * $FreeBSD$
- */
-
-
-#ifndef _NFS_NFSM_SUBS_H_
-#define _NFS_NFSM_SUBS_H_
-
-struct ucred;
-struct vnode;
-
-/*
- * These macros do strange and peculiar things to mbuf chains for
- * the assistance of the nfs code. To attempt to use them for any
- * other purpose will be dangerous. (they make weird assumptions)
- */
-
-/*
- * First define what the actual subs. return
- */
-struct mbuf *nfsm_reqh __P((struct vnode *vp, u_long procid, int hsiz,
- caddr_t *bposp));
-struct mbuf *nfsm_rpchead __P((struct ucred *cr, int nmflag, int procid,
- int auth_type, int auth_len, char *auth_str,
- int verf_len, char *verf_str,
- struct mbuf *mrest, int mrest_len,
- struct mbuf **mbp, u_int32_t *xidp));
-
-#define M_HASCL(m) ((m)->m_flags & M_EXT)
-#define NFSMINOFF(m) \
- do { \
- if (M_HASCL(m)) \
- (m)->m_data = (m)->m_ext.ext_buf; \
- else if ((m)->m_flags & M_PKTHDR) \
- (m)->m_data = (m)->m_pktdat; \
- else \
- (m)->m_data = (m)->m_dat; \
- } while (0)
-#define NFSMADV(m, s) \
- do { \
- (m)->m_data += (s); \
- } while (0)
-#define NFSMSIZ(m) ((M_HASCL(m))?MCLBYTES: \
- (((m)->m_flags & M_PKTHDR)?MHLEN:MLEN))
-
-/*
- * Now for the macros that do the simple stuff and call the functions
- * for the hard stuff.
- * These macros use several vars. declared in nfsm_reqhead and these
- * vars. must not be used elsewhere unless you are careful not to corrupt
- * them. The vars. starting with pN and tN (N=1,2,3,..) are temporaries
- * that may be used so long as the value is not expected to retained
- * after a macro.
- * I know, this is kind of dorkey, but it makes the actual op functions
- * fairly clean and deals with the mess caused by the xdr discriminating
- * unions.
- */
-
-#define nfsm_build(a,c,s) \
- do { \
- if ((s) > M_TRAILINGSPACE(mb)) { \
- MGET(mb2, M_WAIT, MT_DATA); \
- if ((s) > MLEN) \
- panic("build > MLEN"); \
- mb->m_next = mb2; \
- mb = mb2; \
- mb->m_len = 0; \
- bpos = mtod(mb, caddr_t); \
- } \
- (a) = (c)(bpos); \
- mb->m_len += (s); \
- bpos += (s); \
- } while (0)
-
-#define nfsm_dissect(a, c, s) \
- do { \
- t1 = mtod(md, caddr_t)+md->m_len-dpos; \
- if (t1 >= (s)) { \
- (a) = (c)(dpos); \
- dpos += (s); \
- } else if ((t1 = nfsm_disct(&md, &dpos, (s), t1, &cp2)) != 0){ \
- error = t1; \
- m_freem(mrep); \
- goto nfsmout; \
- } else { \
- (a) = (c)cp2; \
- } \
- } while (0)
-
-#define nfsm_fhtom(v, v3) \
- do { \
- if (v3) { \
- t2 = nfsm_rndup(VTONFS(v)->n_fhsize) + NFSX_UNSIGNED; \
- if (t2 <= M_TRAILINGSPACE(mb)) { \
- nfsm_build(tl, u_int32_t *, t2); \
- *tl++ = txdr_unsigned(VTONFS(v)->n_fhsize); \
- *(tl + ((t2>>2) - 2)) = 0; \
- bcopy((caddr_t)VTONFS(v)->n_fhp,(caddr_t)tl, \
- VTONFS(v)->n_fhsize); \
- } else if ((t2 = nfsm_strtmbuf(&mb, &bpos, \
- (caddr_t)VTONFS(v)->n_fhp, \
- VTONFS(v)->n_fhsize)) != 0) { \
- error = t2; \
- m_freem(mreq); \
- goto nfsmout; \
- } \
- } else { \
- nfsm_build(cp, caddr_t, NFSX_V2FH); \
- bcopy((caddr_t)VTONFS(v)->n_fhp, cp, NFSX_V2FH); \
- } \
- } while (0)
-
-#define nfsm_srvfhtom(f, v3) \
- do { \
- if (v3) { \
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED + NFSX_V3FH);\
- *tl++ = txdr_unsigned(NFSX_V3FH); \
- bcopy((caddr_t)(f), (caddr_t)tl, NFSX_V3FH); \
- } else { \
- nfsm_build(cp, caddr_t, NFSX_V2FH); \
- bcopy((caddr_t)(f), cp, NFSX_V2FH); \
- } \
- } while (0)
-
-#define nfsm_srvpostop_fh(f) \
- do { \
- nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED + NFSX_V3FH); \
- *tl++ = nfs_true; \
- *tl++ = txdr_unsigned(NFSX_V3FH); \
- bcopy((caddr_t)(f), (caddr_t)tl, NFSX_V3FH); \
- } while (0)
-
-#define nfsm_mtofh(d, v, v3, f) \
- do { \
- struct nfsnode *ttnp; nfsfh_t *ttfhp; int ttfhsize; \
- if (v3) { \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- (f) = fxdr_unsigned(int, *tl); \
- } else \
- (f) = 1; \
- if (f) { \
- nfsm_getfh(ttfhp, ttfhsize, (v3)); \
- if ((t1 = nfs_nget((d)->v_mount, ttfhp, ttfhsize, \
- &ttnp)) != 0) { \
- error = t1; \
- m_freem(mrep); \
- goto nfsmout; \
- } \
- (v) = NFSTOV(ttnp); \
- } \
- if (v3) { \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- if (f) \
- (f) = fxdr_unsigned(int, *tl); \
- else if (fxdr_unsigned(int, *tl)) \
- nfsm_adv(NFSX_V3FATTR); \
- } \
- if (f) \
- nfsm_loadattr((v), (struct vattr *)0); \
- } while (0)
-
-#define nfsm_getfh(f, s, v3) \
- do { \
- if (v3) { \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- if (((s) = fxdr_unsigned(int, *tl)) <= 0 || \
- (s) > NFSX_V3FHMAX) { \
- m_freem(mrep); \
- error = EBADRPC; \
- goto nfsmout; \
- } \
- } else \
- (s) = NFSX_V2FH; \
- nfsm_dissect((f), nfsfh_t *, nfsm_rndup(s)); \
- } while (0)
-
-#define nfsm_loadattr(v, a) \
- do { \
- struct vnode *ttvp = (v); \
- if ((t1 = nfs_loadattrcache(&ttvp, &md, &dpos, (a))) != 0) { \
- error = t1; \
- m_freem(mrep); \
- goto nfsmout; \
- } \
- (v) = ttvp; \
- } while (0)
-
-#define nfsm_postop_attr(v, f) \
- do { \
- struct vnode *ttvp = (v); \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- if (((f) = fxdr_unsigned(int, *tl)) != 0) { \
- if ((t1 = nfs_loadattrcache(&ttvp, &md, &dpos, \
- (struct vattr *)0)) != 0) { \
- error = t1; \
- (f) = 0; \
- m_freem(mrep); \
- goto nfsmout; \
- } \
- (v) = ttvp; \
- } \
- } while (0)
-
-/* Used as (f) for nfsm_wcc_data() */
-#define NFSV3_WCCRATTR 0
-#define NFSV3_WCCCHK 1
-
-#define nfsm_wcc_data(v, f) \
- do { \
- int ttattrf, ttretf = 0; \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- if (*tl == nfs_true) { \
- nfsm_dissect(tl, u_int32_t *, 6 * NFSX_UNSIGNED); \
- if (f) \
- ttretf = (VTONFS(v)->n_mtime == \
- fxdr_unsigned(u_int32_t, *(tl + 2))); \
- } \
- nfsm_postop_attr((v), ttattrf); \
- if (f) { \
- (f) = ttretf; \
- } else { \
- (f) = ttattrf; \
- } \
- } while (0)
-
-/* If full is true, set all fields, otherwise just set mode and time fields */
-#define nfsm_v3attrbuild(a, full) \
- do { \
- if ((a)->va_mode != (mode_t)VNOVAL) { \
- nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
- *tl++ = nfs_true; \
- *tl = txdr_unsigned((a)->va_mode); \
- } else { \
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \
- *tl = nfs_false; \
- } \
- if ((full) && (a)->va_uid != (uid_t)VNOVAL) { \
- nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
- *tl++ = nfs_true; \
- *tl = txdr_unsigned((a)->va_uid); \
- } else { \
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \
- *tl = nfs_false; \
- } \
- if ((full) && (a)->va_gid != (gid_t)VNOVAL) { \
- nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
- *tl++ = nfs_true; \
- *tl = txdr_unsigned((a)->va_gid); \
- } else { \
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \
- *tl = nfs_false; \
- } \
- if ((full) && (a)->va_size != VNOVAL) { \
- nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED); \
- *tl++ = nfs_true; \
- txdr_hyper((a)->va_size, tl); \
- } else { \
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \
- *tl = nfs_false; \
- } \
- if ((a)->va_atime.tv_sec != VNOVAL) { \
- if ((a)->va_atime.tv_sec != time_second) { \
- nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED);\
- *tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT);\
- txdr_nfsv3time(&(a)->va_atime, tl); \
- } else { \
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \
- *tl = txdr_unsigned(NFSV3SATTRTIME_TOSERVER); \
- } \
- } else { \
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \
- *tl = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE); \
- } \
- if ((a)->va_mtime.tv_sec != VNOVAL) { \
- if ((a)->va_mtime.tv_sec != time_second) { \
- nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED);\
- *tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT);\
- txdr_nfsv3time(&(a)->va_mtime, tl); \
- } else { \
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \
- *tl = txdr_unsigned(NFSV3SATTRTIME_TOSERVER); \
- } \
- } else { \
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \
- *tl = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE); \
- } \
- } while (0)
-
-
-#define nfsm_strsiz(s,m) \
- do { \
- nfsm_dissect(tl,u_int32_t *,NFSX_UNSIGNED); \
- if (((s) = fxdr_unsigned(int32_t,*tl)) > (m)) { \
- m_freem(mrep); \
- error = EBADRPC; \
- goto nfsmout; \
- } \
- } while (0)
-
-#define nfsm_srvstrsiz(s,m) \
- do { \
- nfsm_dissect(tl,u_int32_t *,NFSX_UNSIGNED); \
- if (((s) = fxdr_unsigned(int32_t,*tl)) > (m) || (s) <= 0) { \
- error = EBADRPC; \
- nfsm_reply(0); \
- } \
- } while (0)
-
-#define nfsm_srvnamesiz(s) \
- do { \
- nfsm_dissect(tl,u_int32_t *,NFSX_UNSIGNED); \
- if (((s) = fxdr_unsigned(int32_t,*tl)) > NFS_MAXNAMLEN) \
- error = NFSERR_NAMETOL; \
- if ((s) <= 0) \
- error = EBADRPC; \
- if (error) \
- nfsm_reply(0); \
- } while (0)
-
-#define nfsm_mtouio(p,s) \
- do {\
- if ((s) > 0 && \
- (t1 = nfsm_mbuftouio(&md,(p),(s),&dpos)) != 0) { \
- error = t1; \
- m_freem(mrep); \
- goto nfsmout; \
- } \
- } while (0)
-
-#define nfsm_uiotom(p,s) \
- do { \
- if ((t1 = nfsm_uiotombuf((p),&mb,(s),&bpos)) != 0) { \
- error = t1; \
- m_freem(mreq); \
- goto nfsmout; \
- } \
- } while (0)
-
-#define nfsm_reqhead(v,a,s) \
- do { \
- mb = mreq = nfsm_reqh((v),(a),(s),&bpos); \
- } while (0)
-
-#define nfsm_reqdone \
- do { \
- m_freem(mrep); \
- nfsmout: \
- } while (0)
-
-#define nfsm_rndup(a) (((a)+3)&(~0x3))
-
-#define nfsm_request(v, t, p, c) \
- do { \
- if ((error = nfs_request((v), mreq, (t), (p), \
- (c), &mrep, &md, &dpos)) != 0) { \
- if (error & NFSERR_RETERR) \
- error &= ~NFSERR_RETERR; \
- else \
- goto nfsmout; \
- } \
- } while (0)
-
-#define nfsm_strtom(a,s,m) \
- do {\
- if ((s) > (m)) { \
- m_freem(mreq); \
- error = ENAMETOOLONG; \
- goto nfsmout; \
- } \
- t2 = nfsm_rndup(s)+NFSX_UNSIGNED; \
- if (t2 <= M_TRAILINGSPACE(mb)) { \
- nfsm_build(tl,u_int32_t *,t2); \
- *tl++ = txdr_unsigned(s); \
- *(tl+((t2>>2)-2)) = 0; \
- bcopy((const char *)(a), (caddr_t)tl, (s)); \
- } else if ((t2 = nfsm_strtmbuf(&mb, &bpos, (a), (s))) != 0) { \
- error = t2; \
- m_freem(mreq); \
- goto nfsmout; \
- } \
- } while (0)
-
-#define nfsm_srvdone \
- do { \
- nfsmout: \
- return (error); \
- } while (0)
-
-#define nfsm_reply(s) \
- do { \
- nfsd->nd_repstat = error; \
- if (error && !(nfsd->nd_flag & ND_NFSV3)) \
- (void) nfs_rephead(0, nfsd, slp, error, cache, &frev, \
- mrq, &mb, &bpos); \
- else \
- (void) nfs_rephead((s), nfsd, slp, error, cache, &frev, \
- mrq, &mb, &bpos); \
- if (mrep != NULL) { \
- m_freem(mrep); \
- mrep = NULL; \
- } \
- mreq = *mrq; \
- if (error && (!(nfsd->nd_flag & ND_NFSV3) || \
- error == EBADRPC)) { \
- error = 0; \
- goto nfsmout; \
- } \
- } while (0)
-
-#define nfsm_writereply(s, v3) \
- do { \
- nfsd->nd_repstat = error; \
- if (error && !(v3)) \
- (void) nfs_rephead(0, nfsd, slp, error, cache, &frev, \
- &mreq, &mb, &bpos); \
- else \
- (void) nfs_rephead((s), nfsd, slp, error, cache, &frev, \
- &mreq, &mb, &bpos); \
- } while (0)
-
-#define nfsm_adv(s) \
- do { \
- t1 = mtod(md, caddr_t)+md->m_len-dpos; \
- if (t1 >= (s)) { \
- dpos += (s); \
- } else if ((t1 = nfs_adv(&md, &dpos, (s), t1)) != 0) { \
- error = t1; \
- m_freem(mrep); \
- goto nfsmout; \
- } \
- } while (0)
-
-#define nfsm_srvmtofh(f) \
- do { \
- int fhlen; \
- if (nfsd->nd_flag & ND_NFSV3) { \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- fhlen = fxdr_unsigned(int, *tl); \
- if (fhlen != 0 && fhlen != NFSX_V3FH) { \
- error = EBADRPC; \
- nfsm_reply(0); \
- } \
- } else { \
- fhlen = NFSX_V2FH; \
- } \
- if (fhlen != 0) { \
- nfsm_dissect(tl, u_int32_t *, fhlen); \
- bcopy((caddr_t)tl, (caddr_t)(f), fhlen); \
- } else {\
- bzero((caddr_t)(f), NFSX_V3FH); \
- } \
- } while (0)
-
-#define nfsm_clget \
- do { \
- if (bp >= be) { \
- if (mp == mb) \
- mp->m_len += bp-bpos; \
- MGET(mp, M_WAIT, MT_DATA); \
- MCLGET(mp, M_WAIT); \
- mp->m_len = NFSMSIZ(mp); \
- mp2->m_next = mp; \
- mp2 = mp; \
- bp = mtod(mp, caddr_t); \
- be = bp+mp->m_len; \
- } \
- tl = (u_int32_t *)bp; \
- } while (0)
-
-#define nfsm_srvfillattr(a, f) \
- do { \
- nfsm_srvfattr(nfsd, (a), (f)); \
- } while (0)
-
-#define nfsm_srvwcc_data(br, b, ar, a) \
- do { \
- nfsm_srvwcc(nfsd, (br), (b), (ar), (a), &mb, &bpos); \
- } while (0)
-
-#define nfsm_srvpostop_attr(r, a) \
- do { \
- nfsm_srvpostopattr(nfsd, (r), (a), &mb, &bpos); \
- } while (0)
-
-#define nfsm_srvsattr(a) \
- do { \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- if (*tl == nfs_true) { \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- (a)->va_mode = nfstov_mode(*tl); \
- } \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- if (*tl == nfs_true) { \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- (a)->va_uid = fxdr_unsigned(uid_t, *tl); \
- } \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- if (*tl == nfs_true) { \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- (a)->va_gid = fxdr_unsigned(gid_t, *tl); \
- } \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- if (*tl == nfs_true) { \
- nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
- (a)->va_size = fxdr_hyper(tl); \
- } \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- switch (fxdr_unsigned(int, *tl)) { \
- case NFSV3SATTRTIME_TOCLIENT: \
- nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
- fxdr_nfsv3time(tl, &(a)->va_atime); \
- break; \
- case NFSV3SATTRTIME_TOSERVER: \
- getnanotime(&(a)->va_atime); \
- break; \
- }; \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- switch (fxdr_unsigned(int, *tl)) { \
- case NFSV3SATTRTIME_TOCLIENT: \
- nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
- fxdr_nfsv3time(tl, &(a)->va_mtime); \
- break; \
- case NFSV3SATTRTIME_TOSERVER: \
- getnanotime(&(a)->va_mtime); \
- break; \
- } \
- } while (0)
-
-#endif
diff --git a/sys/nfsclient/nfsmount.h b/sys/nfsclient/nfsmount.h
deleted file mode 100644
index 8efd1dfcbc38..000000000000
--- a/sys/nfsclient/nfsmount.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Rick Macklem at The University of Guelph.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)nfsmount.h 8.3 (Berkeley) 3/30/95
- * $FreeBSD$
- */
-
-
-#ifndef _NFS_NFSMOUNT_H_
-#define _NFS_NFSMOUNT_H_
-
-/*
- * Mount structure.
- * One allocated on every NFS mount.
- * Holds NFS specific information for mount.
- */
-struct nfsmount {
- int nm_flag; /* Flags for soft/hard... */
- int nm_state; /* Internal state flags */
- struct mount *nm_mountp; /* Vfs structure for this filesystem */
- int nm_numgrps; /* Max. size of groupslist */
- u_char nm_fh[NFSX_V3FHMAX]; /* File handle of root dir */
- int nm_fhsize; /* Size of root file handle */
- struct socket *nm_so; /* Rpc socket */
- int nm_sotype; /* Type of socket */
- int nm_soproto; /* and protocol */
- int nm_soflags; /* pr_flags for socket protocol */
- struct sockaddr *nm_nam; /* Addr of server */
- int nm_timeo; /* Init timer for NFSMNT_DUMBTIMR */
- int nm_retry; /* Max retries */
- int nm_srtt[4]; /* Timers for rpcs */
- int nm_sdrtt[4];
- int nm_sent; /* Request send count */
- int nm_cwnd; /* Request send window */
- int nm_timeouts; /* Request timeouts */
- int nm_deadthresh; /* Threshold of timeouts-->dead server*/
- int nm_rsize; /* Max size of read rpc */
- int nm_wsize; /* Max size of write rpc */
- int nm_readdirsize; /* Size of a readdir rpc */
- int nm_readahead; /* Num. of blocks to readahead */
- int nm_leaseterm; /* Term (sec) for NQNFS lease */
- int nm_acdirmin; /* Directory attr cache min lifetime */
- int nm_acdirmax; /* Directory attr cache max lifetime */
- int nm_acregmin; /* Reg file attr cache min lifetime */
- int nm_acregmax; /* Reg file attr cache max lifetime */
- CIRCLEQ_HEAD(, nfsnode) nm_timerhead; /* Head of lease timer queue */
- struct vnode *nm_inprog; /* Vnode in prog by nqnfs_clientd() */
- uid_t nm_authuid; /* Uid for authenticator */
- int nm_authtype; /* Authenticator type */
- int nm_authlen; /* and length */
- char *nm_authstr; /* Authenticator string */
- char *nm_verfstr; /* and the verifier */
- int nm_verflen;
- u_char nm_verf[NFSX_V3WRITEVERF]; /* V3 write verifier */
- NFSKERBKEY_T nm_key; /* and the session key */
- int nm_numuids; /* Number of nfsuid mappings */
- TAILQ_HEAD(, nfsuid) nm_uidlruhead; /* Lists of nfsuid mappings */
- LIST_HEAD(, nfsuid) nm_uidhashtbl[NFS_MUIDHASHSIZ];
- TAILQ_HEAD(, buf) nm_bufq; /* async io buffer queue */
- short nm_bufqlen; /* number of buffers in queue */
- short nm_bufqwant; /* process wants to add to the queue */
- int nm_bufqiods; /* number of iods processing queue */
- u_int64_t nm_maxfilesize; /* maximum file size */
-};
-
-#if defined(_KERNEL)
-/*
- * Convert mount ptr to nfsmount ptr.
- */
-#define VFSTONFS(mp) ((struct nfsmount *)((mp)->mnt_data))
-
-#endif
-
-#endif
diff --git a/sys/nfsclient/nfsnode.h b/sys/nfsclient/nfsnode.h
deleted file mode 100644
index dac6020f66e3..000000000000
--- a/sys/nfsclient/nfsnode.h
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Rick Macklem at The University of Guelph.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)nfsnode.h 8.9 (Berkeley) 5/14/95
- * $FreeBSD$
- */
-
-
-#ifndef _NFS_NFSNODE_H_
-#define _NFS_NFSNODE_H_
-
-#if !defined(_NFS_NFS_H_) && !defined(_KERNEL)
-#include <nfs/nfs.h>
-#endif
-
-/*
- * Silly rename structure that hangs off the nfsnode until the name
- * can be removed by nfs_inactive()
- */
-struct sillyrename {
- struct ucred *s_cred;
- struct vnode *s_dvp;
- long s_namlen;
- char s_name[20];
-};
-
-/*
- * This structure is used to save the logical directory offset to
- * NFS cookie mappings.
- * The mappings are stored in a list headed
- * by n_cookies, as required.
- * There is one mapping for each NFS_DIRBLKSIZ bytes of directory information
- * stored in increasing logical offset byte order.
- */
-#define NFSNUMCOOKIES 31
-
-struct nfsdmap {
- LIST_ENTRY(nfsdmap) ndm_list;
- int ndm_eocookie;
- nfsuint64 ndm_cookies[NFSNUMCOOKIES];
-};
-
-/*
- * The nfsnode is the nfs equivalent to ufs's inode. Any similarity
- * is purely coincidental.
- * There is a unique nfsnode allocated for each active file,
- * each current directory, each mounted-on file, text file, and the root.
- * An nfsnode is 'named' by its file handle. (nget/nfs_node.c)
- * If this structure exceeds 256 bytes (it is currently 256 using 4.4BSD-Lite
- * type definitions), file handles of > 32 bytes should probably be split out
- * into a separate MALLOC()'d data structure. (Reduce the size of nfsfh_t by
- * changing the definition in nfsproto.h of NFS_SMALLFH.)
- * NB: Hopefully the current order of the fields is such that everything will
- * be well aligned and, therefore, tightly packed.
- */
-struct nfsnode {
- LIST_ENTRY(nfsnode) n_hash; /* Hash chain */
- CIRCLEQ_ENTRY(nfsnode) n_timer; /* Nqnfs timer chain */
- u_quad_t n_size; /* Current size of file */
- u_quad_t n_brev; /* Modify rev when cached */
- u_quad_t n_lrev; /* Modify rev for lease */
- struct vattr n_vattr; /* Vnode attribute cache */
- time_t n_attrstamp; /* Attr. cache timestamp */
- u_int32_t n_mode; /* ACCESS mode cache */
- uid_t n_modeuid; /* credentials having mode */
- time_t n_modestamp; /* mode cache timestamp */
- time_t n_mtime; /* Prev modify time. */
- time_t n_ctime; /* Prev create time. */
- time_t n_expiry; /* Lease expiry time */
- nfsfh_t *n_fhp; /* NFS File Handle */
- struct vnode *n_vnode; /* associated vnode */
- struct lockf *n_lockf; /* Locking record of file */
- int n_error; /* Save write error value */
- union {
- struct timespec nf_atim; /* Special file times */
- nfsuint64 nd_cookieverf; /* Cookie verifier (dir only) */
- } n_un1;
- union {
- struct timespec nf_mtim;
- off_t nd_direof; /* Dir. EOF offset cache */
- } n_un2;
- union {
- struct sillyrename *nf_silly; /* Ptr to silly rename struct */
- LIST_HEAD(, nfsdmap) nd_cook; /* cookies */
- } n_un3;
- short n_fhsize; /* size in bytes, of fh */
- short n_flag; /* Flag for locking.. */
- nfsfh_t n_fh; /* Small File Handle */
- struct lock n_rslock;
-};
-
-#define n_atim n_un1.nf_atim
-#define n_mtim n_un2.nf_mtim
-#define n_sillyrename n_un3.nf_silly
-#define n_cookieverf n_un1.nd_cookieverf
-#define n_direofoffset n_un2.nd_direof
-#define n_cookies n_un3.nd_cook
-
-/*
- * Flags for n_flag
- */
-#define NFLUSHWANT 0x0001 /* Want wakeup from a flush in prog. */
-#define NFLUSHINPROG 0x0002 /* Avoid multiple calls to vinvalbuf() */
-#define NMODIFIED 0x0004 /* Might have a modified buffer in bio */
-#define NWRITEERR 0x0008 /* Flag write errors so close will know */
-#define NQNFSNONCACHE 0x0020 /* Non-cachable lease */
-#define NQNFSWRITE 0x0040 /* Write lease */
-#define NQNFSEVICTED 0x0080 /* Has been evicted */
-#define NACC 0x0100 /* Special file accessed */
-#define NUPD 0x0200 /* Special file updated */
-#define NCHG 0x0400 /* Special file times changed */
-#define NLOCKED 0x0800 /* node is locked */
-#define NWANTED 0x0100 /* someone wants to lock */
-
-/*
- * Convert between nfsnode pointers and vnode pointers
- */
-#define VTONFS(vp) ((struct nfsnode *)(vp)->v_data)
-#define NFSTOV(np) ((struct vnode *)(np)->n_vnode)
-
-/*
- * Queue head for nfsiod's
- */
-extern TAILQ_HEAD(nfs_bufq, buf) nfs_bufq;
-extern struct proc *nfs_iodwant[NFS_MAXASYNCDAEMON];
-extern struct nfsmount *nfs_iodmount[NFS_MAXASYNCDAEMON];
-
-#if defined(_KERNEL)
-
-/*
- * nfs_rslock - Attempt to obtain lock on nfsnode
- *
- * Attempt to obtain a lock on the passed nfsnode, returning ENOLCK
- * if the lock could not be obtained due to our having to sleep. This
- * function is generally used to lock around code that modifies an
- * NFS file's size. In order to avoid deadlocks the lock
- * should not be obtained while other locks are being held.
- */
-
-static __inline
-int
-nfs_rslock(struct nfsnode *np, struct proc *p)
-{
- return(lockmgr(&np->n_rslock, LK_EXCLUSIVE | LK_CANRECURSE | LK_SLEEPFAIL, NULL, p));
-}
-
-static __inline
-void
-nfs_rsunlock(struct nfsnode *np, struct proc *p)
-{
- (void)lockmgr(&np->n_rslock, LK_RELEASE, NULL, p);
-}
-
-extern vop_t **fifo_nfsv2nodeop_p;
-extern vop_t **nfsv2_vnodeop_p;
-extern vop_t **spec_nfsv2nodeop_p;
-
-/*
- * Prototypes for NFS vnode operations
- */
-int nfs_getpages __P((struct vop_getpages_args *));
-int nfs_putpages __P((struct vop_putpages_args *));
-int nfs_write __P((struct vop_write_args *));
-int nqnfs_vop_lease_check __P((struct vop_lease_args *));
-int nfs_inactive __P((struct vop_inactive_args *));
-int nfs_reclaim __P((struct vop_reclaim_args *));
-
-/* other stuff */
-int nfs_removeit __P((struct sillyrename *));
-int nfs_nget __P((struct mount *,nfsfh_t *,int,struct nfsnode **));
-nfsuint64 *nfs_getcookie __P((struct nfsnode *, off_t, int));
-void nfs_invaldir __P((struct vnode *));
-
-#define nqnfs_lease_updatetime nfs_lease_updatetime
-
-#endif /* _KERNEL */
-
-#endif
diff --git a/sys/nfsclient/nfsstats.h b/sys/nfsclient/nfsstats.h
deleted file mode 100644
index e07a4f5315d1..000000000000
--- a/sys/nfsclient/nfsstats.h
+++ /dev/null
@@ -1,727 +0,0 @@
-/*
- * Copyright (c) 1989, 1993, 1995
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Rick Macklem at The University of Guelph.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)nfs.h 8.4 (Berkeley) 5/1/95
- * $FreeBSD$
- */
-
-#ifndef _NFS_NFS_H_
-#define _NFS_NFS_H_
-
-#ifdef _KERNEL
-#include "opt_nfs.h"
-#endif
-
-/*
- * Tunable constants for nfs
- */
-
-#define NFS_MAXIOVEC 34
-#define NFS_TICKINTVL 5 /* Desired time for a tick (msec) */
-#define NFS_HZ (hz / nfs_ticks) /* Ticks/sec */
-#define NFS_TIMEO (1 * NFS_HZ) /* Default timeout = 1 second */
-#define NFS_MINTIMEO (1 * NFS_HZ) /* Min timeout to use */
-#define NFS_MAXTIMEO (60 * NFS_HZ) /* Max timeout to backoff to */
-#define NFS_MINIDEMTIMEO (5 * NFS_HZ) /* Min timeout for non-idempotent ops*/
-#define NFS_MAXREXMIT 100 /* Stop counting after this many */
-#define NFS_MAXWINDOW 1024 /* Max number of outstanding requests */
-#define NFS_RETRANS 10 /* Num of retrans for soft mounts */
-#define NFS_MAXGRPS 16 /* Max. size of groups list */
-#ifndef NFS_MINATTRTIMO
-#define NFS_MINATTRTIMO 3 /* VREG attrib cache timeout in sec */
-#endif
-#ifndef NFS_MAXATTRTIMO
-#define NFS_MAXATTRTIMO 60
-#endif
-#ifndef NFS_MINDIRATTRTIMO
-#define NFS_MINDIRATTRTIMO 30 /* VDIR attrib cache timeout in sec */
-#endif
-#ifndef NFS_MAXDIRATTRTIMO
-#define NFS_MAXDIRATTRTIMO 60
-#endif
-#define NFS_WSIZE 8192 /* Def. write data size <= 8192 */
-#define NFS_RSIZE 8192 /* Def. read data size <= 8192 */
-#define NFS_READDIRSIZE 8192 /* Def. readdir size */
-#define NFS_DEFRAHEAD 1 /* Def. read ahead # blocks */
-#define NFS_MAXRAHEAD 4 /* Max. read ahead # blocks */
-#define NFS_MAXUIDHASH 64 /* Max. # of hashed uid entries/mp */
-#define NFS_MAXASYNCDAEMON 20 /* Max. number async_daemons runnable */
-#define NFS_MAXGATHERDELAY 100 /* Max. write gather delay (msec) */
-#ifndef NFS_GATHERDELAY
-#define NFS_GATHERDELAY 10 /* Default write gather delay (msec) */
-#endif
-#define NFS_DIRBLKSIZ 4096 /* Must be a multiple of DIRBLKSIZ */
-#ifdef _KERNEL
-#define DIRBLKSIZ 512 /* XXX we used to use ufs's DIRBLKSIZ */
-#endif
-
-/*
- * Oddballs
- */
-#define NMOD(a) ((a) % nfs_asyncdaemons)
-#define NFS_CMPFH(n, f, s) \
- ((n)->n_fhsize == (s) && !bcmp((caddr_t)(n)->n_fhp, (caddr_t)(f), (s)))
-#define NFS_ISV3(v) (VFSTONFS((v)->v_mount)->nm_flag & NFSMNT_NFSV3)
-#define NFS_SRVMAXDATA(n) \
- (((n)->nd_flag & ND_NFSV3) ? (((n)->nd_nam2) ? \
- NFS_MAXDGRAMDATA : NFS_MAXDATA) : NFS_V2MAXDATA)
-
-/*
- * XXX
- * The B_INVAFTERWRITE flag should be set to whatever is required by the
- * buffer cache code to say "Invalidate the block after it is written back".
- */
-#define B_INVAFTERWRITE B_NOCACHE
-
-/*
- * The IO_METASYNC flag should be implemented for local file systems.
- * (Until then, it is nothin at all.)
- */
-#ifndef IO_METASYNC
-#define IO_METASYNC 0
-#endif
-
-/*
- * Arguments to mount NFS
- */
-#define NFS_ARGSVERSION 3 /* change when nfs_args changes */
-struct nfs_args {
- int version; /* args structure version number */
- struct sockaddr *addr; /* file server address */
- int addrlen; /* length of address */
- int sotype; /* Socket type */
- int proto; /* and Protocol */
- u_char *fh; /* File handle to be mounted */
- int fhsize; /* Size, in bytes, of fh */
- int flags; /* flags */
- int wsize; /* write size in bytes */
- int rsize; /* read size in bytes */
- int readdirsize; /* readdir size in bytes */
- int timeo; /* initial timeout in .1 secs */
- int retrans; /* times to retry send */
- int maxgrouplist; /* Max. size of group list */
- int readahead; /* # of blocks to readahead */
- int leaseterm; /* Term (sec) of lease */
- int deadthresh; /* Retrans threshold */
- char *hostname; /* server's name */
- int acregmin; /* cache attrs for reg files min time */
- int acregmax; /* cache attrs for reg files max time */
- int acdirmin; /* cache attrs for dirs min time */
- int acdirmax; /* cache attrs for dirs max time */
-};
-
-/*
- * NFS mount option flags
- */
-#define NFSMNT_SOFT 0x00000001 /* soft mount (hard is default) */
-#define NFSMNT_WSIZE 0x00000002 /* set write size */
-#define NFSMNT_RSIZE 0x00000004 /* set read size */
-#define NFSMNT_TIMEO 0x00000008 /* set initial timeout */
-#define NFSMNT_RETRANS 0x00000010 /* set number of request retries */
-#define NFSMNT_MAXGRPS 0x00000020 /* set maximum grouplist size */
-#define NFSMNT_INT 0x00000040 /* allow interrupts on hard mount */
-#define NFSMNT_NOCONN 0x00000080 /* Don't Connect the socket */
-#define NFSMNT_NQNFS 0x00000100 /* Use Nqnfs protocol */
-#define NFSMNT_NFSV3 0x00000200 /* Use NFS Version 3 protocol */
-#define NFSMNT_KERB 0x00000400 /* Use Kerberos authentication */
-#define NFSMNT_DUMBTIMR 0x00000800 /* Don't estimate rtt dynamically */
-#define NFSMNT_LEASETERM 0x00001000 /* set lease term (nqnfs) */
-#define NFSMNT_READAHEAD 0x00002000 /* set read ahead */
-#define NFSMNT_DEADTHRESH 0x00004000 /* set dead server retry thresh */
-#define NFSMNT_RESVPORT 0x00008000 /* Allocate a reserved port */
-#define NFSMNT_RDIRPLUS 0x00010000 /* Use Readdirplus for V3 */
-#define NFSMNT_READDIRSIZE 0x00020000 /* Set readdir size */
-#define NFSMNT_ACREGMIN 0x00040000
-#define NFSMNT_ACREGMAX 0x00080000
-#define NFSMNT_ACDIRMIN 0x00100000
-#define NFSMNT_ACDIRMAX 0x00200000
-
-#define NFSSTA_HASWRITEVERF 0x00040000 /* Has write verifier for V3 */
-#define NFSSTA_GOTPATHCONF 0x00080000 /* Got the V3 pathconf info */
-#define NFSSTA_GOTFSINFO 0x00100000 /* Got the V3 fsinfo */
-#define NFSSTA_MNTD 0x00200000 /* Mnt server for mnt point */
-#define NFSSTA_DISMINPROG 0x00400000 /* Dismount in progress */
-#define NFSSTA_DISMNT 0x00800000 /* Dismounted */
-#define NFSSTA_SNDLOCK 0x01000000 /* Send socket lock */
-#define NFSSTA_WANTSND 0x02000000 /* Want above */
-#define NFSSTA_RCVLOCK 0x04000000 /* Rcv socket lock */
-#define NFSSTA_WANTRCV 0x08000000 /* Want above */
-#define NFSSTA_WAITAUTH 0x10000000 /* Wait for authentication */
-#define NFSSTA_HASAUTH 0x20000000 /* Has authenticator */
-#define NFSSTA_WANTAUTH 0x40000000 /* Wants an authenticator */
-#define NFSSTA_AUTHERR 0x80000000 /* Authentication error */
-
-/*
- * Structures for the nfssvc(2) syscall. Not that anyone but nfsd and mount_nfs
- * should ever try and use it.
- */
-struct nfsd_args {
- int sock; /* Socket to serve */
- caddr_t name; /* Client addr for connection based sockets */
- int namelen; /* Length of name */
-};
-
-struct nfsd_srvargs {
- struct nfsd *nsd_nfsd; /* Pointer to in kernel nfsd struct */
- uid_t nsd_uid; /* Effective uid mapped to cred */
- u_int32_t nsd_haddr; /* Ip address of client */
- struct ucred nsd_cr; /* Cred. uid maps to */
- int nsd_authlen; /* Length of auth string (ret) */
- u_char *nsd_authstr; /* Auth string (ret) */
- int nsd_verflen; /* and the verfier */
- u_char *nsd_verfstr;
- struct timeval nsd_timestamp; /* timestamp from verifier */
- u_int32_t nsd_ttl; /* credential ttl (sec) */
- NFSKERBKEY_T nsd_key; /* Session key */
-};
-
-struct nfsd_cargs {
- char *ncd_dirp; /* Mount dir path */
- uid_t ncd_authuid; /* Effective uid */
- int ncd_authtype; /* Type of authenticator */
- int ncd_authlen; /* Length of authenticator string */
- u_char *ncd_authstr; /* Authenticator string */
- int ncd_verflen; /* and the verifier */
- u_char *ncd_verfstr;
- NFSKERBKEY_T ncd_key; /* Session key */
-};
-
-/*
- * XXX to allow amd to include nfs.h without nfsproto.h
- */
-#ifdef NFS_NPROCS
-/*
- * Stats structure
- */
-struct nfsstats {
- int attrcache_hits;
- int attrcache_misses;
- int lookupcache_hits;
- int lookupcache_misses;
- int direofcache_hits;
- int direofcache_misses;
- int biocache_reads;
- int read_bios;
- int read_physios;
- int biocache_writes;
- int write_bios;
- int write_physios;
- int biocache_readlinks;
- int readlink_bios;
- int biocache_readdirs;
- int readdir_bios;
- int rpccnt[NFS_NPROCS];
- int rpcretries;
- int srvrpccnt[NFS_NPROCS];
- int srvrpc_errs;
- int srv_errs;
- int rpcrequests;
- int rpctimeouts;
- int rpcunexpected;
- int rpcinvalid;
- int srvcache_inproghits;
- int srvcache_idemdonehits;
- int srvcache_nonidemdonehits;
- int srvcache_misses;
- int srvnqnfs_leases;
- int srvnqnfs_maxleases;
- int srvnqnfs_getleases;
- int srvvop_writes;
- int accesscache_hits;
- int accesscache_misses;
-};
-#endif
-
-/*
- * Flags for nfssvc() system call.
- */
-#define NFSSVC_BIOD 0x002
-#define NFSSVC_NFSD 0x004
-#define NFSSVC_ADDSOCK 0x008
-#define NFSSVC_AUTHIN 0x010
-#define NFSSVC_GOTAUTH 0x040
-#define NFSSVC_AUTHINFAIL 0x080
-#define NFSSVC_MNTD 0x100
-
-/*
- * fs.nfs sysctl(3) identifiers
- */
-#define NFS_NFSSTATS 1 /* struct: struct nfsstats */
-#define NFS_NFSPRIVPORT 2 /* int: prohibit nfs to resvports */
-
-#define FS_NFS_NAMES { \
- { 0, 0 }, \
- { "nfsstats", CTLTYPE_STRUCT }, \
- { "nfsprivport", CTLTYPE_INT }, \
-}
-
-#ifdef _KERNEL
-
-#ifdef MALLOC_DECLARE
-MALLOC_DECLARE(M_NFSREQ);
-MALLOC_DECLARE(M_NFSDIROFF);
-MALLOC_DECLARE(M_NFSRVDESC);
-MALLOC_DECLARE(M_NFSUID);
-MALLOC_DECLARE(M_NQLEASE);
-MALLOC_DECLARE(M_NFSD);
-MALLOC_DECLARE(M_NFSBIGFH);
-MALLOC_DECLARE(M_NFSHASH);
-#endif
-
-#ifdef ZONE_INTERRUPT
-extern vm_zone_t nfsmount_zone;
-#endif
-
-extern struct callout_handle nfs_timer_handle;
-
-struct uio; struct buf; struct vattr; struct nameidata; /* XXX */
-
-/*
- * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts.
- * What should be in this set is open to debate, but I believe that since
- * I/O system calls on ufs are never interrupted by signals the set should
- * be minimal. My reasoning is that many current programs that use signals
- * such as SIGALRM will not expect file I/O system calls to be interrupted
- * by them and break.
- */
-#define NFSINT_SIGMASK(set) \
- (SIGISMEMBER(set, SIGINT) || SIGISMEMBER(set, SIGTERM) || \
- SIGISMEMBER(set, SIGHUP) || SIGISMEMBER(set, SIGKILL) || \
- SIGISMEMBER(set, SIGQUIT))
-
-/*
- * Socket errors ignored for connectionless sockets??
- * For now, ignore them all
- */
-#define NFSIGNORE_SOERROR(s, e) \
- ((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \
- ((s) & PR_CONNREQUIRED) == 0)
-
-/*
- * Nfs outstanding request list element
- */
-struct nfsreq {
- TAILQ_ENTRY(nfsreq) r_chain;
- struct mbuf *r_mreq;
- struct mbuf *r_mrep;
- struct mbuf *r_md;
- caddr_t r_dpos;
- struct nfsmount *r_nmp;
- struct vnode *r_vp;
- u_int32_t r_xid;
- int r_flags; /* flags on request, see below */
- int r_retry; /* max retransmission count */
- int r_rexmit; /* current retrans count */
- int r_timer; /* tick counter on reply */
- u_int32_t r_procnum; /* NFS procedure number */
- int r_rtt; /* RTT for rpc */
- struct proc *r_procp; /* Proc that did I/O system call */
-};
-
-/*
- * Queue head for nfsreq's
- */
-extern TAILQ_HEAD(nfs_reqq, nfsreq) nfs_reqq;
-
-/* Flag values for r_flags */
-#define R_TIMING 0x01 /* timing request (in mntp) */
-#define R_SENT 0x02 /* request has been sent */
-#define R_SOFTTERM 0x04 /* soft mnt, too many retries */
-#define R_INTR 0x08 /* intr mnt, signal pending */
-#define R_SOCKERR 0x10 /* Fatal error on socket */
-#define R_TPRINTFMSG 0x20 /* Did a tprintf msg. */
-#define R_MUSTRESEND 0x40 /* Must resend request */
-#define R_GETONEREP 0x80 /* Probe for one reply only */
-
-/*
- * A list of nfssvc_sock structures is maintained with all the sockets
- * that require service by the nfsd.
- * The nfsuid structs hang off of the nfssvc_sock structs in both lru
- * and uid hash lists.
- */
-#ifndef NFS_UIDHASHSIZ
-#define NFS_UIDHASHSIZ 29 /* Tune the size of nfssvc_sock with this */
-#endif
-#define NUIDHASH(sock, uid) \
- (&(sock)->ns_uidhashtbl[(uid) % NFS_UIDHASHSIZ])
-#ifndef NFS_WDELAYHASHSIZ
-#define NFS_WDELAYHASHSIZ 16 /* and with this */
-#endif
-#define NWDELAYHASH(sock, f) \
- (&(sock)->ns_wdelayhashtbl[(*((u_int32_t *)(f))) % NFS_WDELAYHASHSIZ])
-#ifndef NFS_MUIDHASHSIZ
-#define NFS_MUIDHASHSIZ 63 /* Tune the size of nfsmount with this */
-#endif
-#define NMUIDHASH(nmp, uid) \
- (&(nmp)->nm_uidhashtbl[(uid) % NFS_MUIDHASHSIZ])
-#define NFSNOHASH(fhsum) \
- (&nfsnodehashtbl[(fhsum) & nfsnodehash])
-
-/*
- * Network address hash list element
- */
-union nethostaddr {
- u_int32_t had_inetaddr;
- struct sockaddr *had_nam;
-};
-
-struct nfsuid {
- TAILQ_ENTRY(nfsuid) nu_lru; /* LRU chain */
- LIST_ENTRY(nfsuid) nu_hash; /* Hash list */
- int nu_flag; /* Flags */
- union nethostaddr nu_haddr; /* Host addr. for dgram sockets */
- struct ucred nu_cr; /* Cred uid mapped to */
- int nu_expire; /* Expiry time (sec) */
- struct timeval nu_timestamp; /* Kerb. timestamp */
- u_int32_t nu_nickname; /* Nickname on server */
- NFSKERBKEY_T nu_key; /* and session key */
-};
-
-#define nu_inetaddr nu_haddr.had_inetaddr
-#define nu_nam nu_haddr.had_nam
-/* Bits for nu_flag */
-#define NU_INETADDR 0x1
-#define NU_NAM 0x2
-#define NU_NETFAM(u) (((u)->nu_flag & NU_INETADDR) ? AF_INET : AF_ISO)
-
-struct nfsrv_rec {
- STAILQ_ENTRY(nfsrv_rec) nr_link;
- struct sockaddr *nr_address;
- struct mbuf *nr_packet;
-};
-
-struct nfssvc_sock {
- TAILQ_ENTRY(nfssvc_sock) ns_chain; /* List of all nfssvc_sock's */
- TAILQ_HEAD(, nfsuid) ns_uidlruhead;
- struct file *ns_fp;
- struct socket *ns_so;
- struct sockaddr *ns_nam;
- struct mbuf *ns_raw;
- struct mbuf *ns_rawend;
- STAILQ_HEAD(, nfsrv_rec) ns_rec;
- struct mbuf *ns_frag;
- int ns_flag;
- int ns_solock;
- int ns_cc;
- int ns_reclen;
- int ns_numuids;
- u_int32_t ns_sref;
- LIST_HEAD(, nfsrv_descript) ns_tq; /* Write gather lists */
- LIST_HEAD(, nfsuid) ns_uidhashtbl[NFS_UIDHASHSIZ];
- LIST_HEAD(nfsrvw_delayhash, nfsrv_descript) ns_wdelayhashtbl[NFS_WDELAYHASHSIZ];
-};
-
-/* Bits for "ns_flag" */
-#define SLP_VALID 0x01
-#define SLP_DOREC 0x02
-#define SLP_NEEDQ 0x04
-#define SLP_DISCONN 0x08
-#define SLP_GETSTREAM 0x10
-#define SLP_LASTFRAG 0x20
-#define SLP_ALLFLAGS 0xff
-
-extern TAILQ_HEAD(nfssvc_sockhead, nfssvc_sock) nfssvc_sockhead;
-extern int nfssvc_sockhead_flag;
-#define SLP_INIT 0x01
-#define SLP_WANTINIT 0x02
-
-/*
- * One of these structures is allocated for each nfsd.
- */
-struct nfsd {
- TAILQ_ENTRY(nfsd) nfsd_chain; /* List of all nfsd's */
- int nfsd_flag; /* NFSD_ flags */
- struct nfssvc_sock *nfsd_slp; /* Current socket */
- int nfsd_authlen; /* Authenticator len */
- u_char nfsd_authstr[RPCAUTH_MAXSIZ]; /* Authenticator data */
- int nfsd_verflen; /* and the Verifier */
- u_char nfsd_verfstr[RPCVERF_MAXSIZ];
- struct proc *nfsd_procp; /* Proc ptr */
- struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */
-};
-
-/* Bits for "nfsd_flag" */
-#define NFSD_WAITING 0x01
-#define NFSD_REQINPROG 0x02
-#define NFSD_NEEDAUTH 0x04
-#define NFSD_AUTHFAIL 0x08
-
-/*
- * This structure is used by the server for describing each request.
- * Some fields are used only when write request gathering is performed.
- */
-struct nfsrv_descript {
- u_quad_t nd_time; /* Write deadline (usec) */
- off_t nd_off; /* Start byte offset */
- off_t nd_eoff; /* and end byte offset */
- LIST_ENTRY(nfsrv_descript) nd_hash; /* Hash list */
- LIST_ENTRY(nfsrv_descript) nd_tq; /* and timer list */
- LIST_HEAD(,nfsrv_descript) nd_coalesce; /* coalesced writes */
- struct mbuf *nd_mrep; /* Request mbuf list */
- struct mbuf *nd_md; /* Current dissect mbuf */
- struct mbuf *nd_mreq; /* Reply mbuf list */
- struct sockaddr *nd_nam; /* and socket addr */
- struct sockaddr *nd_nam2; /* return socket addr */
- caddr_t nd_dpos; /* Current dissect pos */
- u_int32_t nd_procnum; /* RPC # */
- int nd_stable; /* storage type */
- int nd_flag; /* nd_flag */
- int nd_len; /* Length of this write */
- int nd_repstat; /* Reply status */
- u_int32_t nd_retxid; /* Reply xid */
- u_int32_t nd_duration; /* Lease duration */
- struct timeval nd_starttime; /* Time RPC initiated */
- fhandle_t nd_fh; /* File handle */
- struct ucred nd_cr; /* Credentials */
-};
-
-/* Bits for "nd_flag" */
-#define ND_READ LEASE_READ
-#define ND_WRITE LEASE_WRITE
-#define ND_CHECK 0x04
-#define ND_LEASE (ND_READ | ND_WRITE | ND_CHECK)
-#define ND_NFSV3 0x08
-#define ND_NQNFS 0x10
-#define ND_KERBNICK 0x20
-#define ND_KERBFULL 0x40
-#define ND_KERBAUTH (ND_KERBNICK | ND_KERBFULL)
-
-extern TAILQ_HEAD(nfsd_head, nfsd) nfsd_head;
-extern int nfsd_head_flag;
-#define NFSD_CHECKSLP 0x01
-
-/*
- * These macros compare nfsrv_descript structures.
- */
-#define NFSW_CONTIG(o, n) \
- ((o)->nd_eoff >= (n)->nd_off && \
- !bcmp((caddr_t)&(o)->nd_fh, (caddr_t)&(n)->nd_fh, NFSX_V3FH))
-
-#define NFSW_SAMECRED(o, n) \
- (((o)->nd_flag & ND_KERBAUTH) == ((n)->nd_flag & ND_KERBAUTH) && \
- !bcmp((caddr_t)&(o)->nd_cr, (caddr_t)&(n)->nd_cr, \
- sizeof (struct ucred)))
-
-/*
- * Defines for WebNFS
- */
-
-#define WEBNFS_ESC_CHAR '%'
-#define WEBNFS_SPECCHAR_START 0x80
-
-#define WEBNFS_NATIVE_CHAR 0x80
-/*
- * ..
- * Possibly more here in the future.
- */
-
-/*
- * Macro for converting escape characters in WebNFS pathnames.
- * Should really be in libkern.
- */
-
-#define HEXTOC(c) \
- ((c) >= 'a' ? ((c) - ('a' - 10)) : \
- ((c) >= 'A' ? ((c) - ('A' - 10)) : ((c) - '0')))
-#define HEXSTRTOI(p) \
- ((HEXTOC(p[0]) << 4) + HEXTOC(p[1]))
-
-#ifdef NFS_DEBUG
-
-extern int nfs_debug;
-#define NFS_DEBUG_ASYNCIO 1 /* asynchronous i/o */
-#define NFS_DEBUG_WG 2 /* server write gathering */
-#define NFS_DEBUG_RC 4 /* server request caching */
-
-#define NFS_DPF(cat, args) \
- do { \
- if (nfs_debug & NFS_DEBUG_##cat) printf args; \
- } while (0)
-
-#else
-
-#define NFS_DPF(cat, args)
-
-#endif
-
-u_quad_t nfs_curusec __P((void));
-int nfs_init __P((struct vfsconf *vfsp));
-int nfs_uninit __P((struct vfsconf *vfsp));
-int nfs_reply __P((struct nfsreq *));
-int nfs_getreq __P((struct nfsrv_descript *,struct nfsd *,int));
-int nfs_send __P((struct socket *, struct sockaddr *, struct mbuf *,
- struct nfsreq *));
-int nfs_rephead __P((int, struct nfsrv_descript *, struct nfssvc_sock *,
- int, int, u_quad_t *, struct mbuf **, struct mbuf **,
- caddr_t *));
-int nfs_sndlock __P((struct nfsreq *));
-void nfs_sndunlock __P((struct nfsreq *));
-int nfs_slplock __P((struct nfssvc_sock *, int));
-void nfs_slpunlock __P((struct nfssvc_sock *));
-int nfs_disct __P((struct mbuf **, caddr_t *, int, int, caddr_t *));
-int nfs_vinvalbuf __P((struct vnode *, int, struct ucred *, struct proc *,
- int));
-int nfs_readrpc __P((struct vnode *, struct uio *, struct ucred *));
-int nfs_writerpc __P((struct vnode *, struct uio *, struct ucred *, int *,
- int *));
-int nfs_commit __P((struct vnode *vp, u_quad_t offset, int cnt,
- struct ucred *cred, struct proc *procp));
-int nfs_readdirrpc __P((struct vnode *, struct uio *, struct ucred *));
-int nfs_asyncio __P((struct buf *, struct ucred *, struct proc *));
-int nfs_doio __P((struct buf *, struct ucred *, struct proc *));
-int nfs_readlinkrpc __P((struct vnode *, struct uio *, struct ucred *));
-int nfs_sigintr __P((struct nfsmount *, struct nfsreq *, struct proc *));
-int nfs_readdirplusrpc __P((struct vnode *, struct uio *, struct ucred *));
-int nfsm_disct __P((struct mbuf **, caddr_t *, int, int, caddr_t *));
-void nfsm_srvfattr __P((struct nfsrv_descript *, struct vattr *,
- struct nfs_fattr *));
-void nfsm_srvwcc __P((struct nfsrv_descript *, int, struct vattr *, int,
- struct vattr *, struct mbuf **, char **));
-void nfsm_srvpostopattr __P((struct nfsrv_descript *, int, struct vattr *,
- struct mbuf **, char **));
-int netaddr_match __P((int, union nethostaddr *, struct sockaddr *));
-int nfs_request __P((struct vnode *, struct mbuf *, int, struct proc *,
- struct ucred *, struct mbuf **, struct mbuf **,
- caddr_t *));
-int nfs_loadattrcache __P((struct vnode **, struct mbuf **, caddr_t *,
- struct vattr *));
-int nfs_namei __P((struct nameidata *, fhandle_t *, int,
- struct nfssvc_sock *, struct sockaddr *, struct mbuf **,
- caddr_t *, struct vnode **, struct proc *, int, int));
-void nfsm_adj __P((struct mbuf *, int, int));
-int nfsm_mbuftouio __P((struct mbuf **, struct uio *, int, caddr_t *));
-void nfsrv_initcache __P((void));
-int nfs_getauth __P((struct nfsmount *, struct nfsreq *, struct ucred *,
- char **, int *, char *, int *, NFSKERBKEY_T));
-int nfs_getnickauth __P((struct nfsmount *, struct ucred *, char **,
- int *, char *, int));
-int nfs_savenickauth __P((struct nfsmount *, struct ucred *, int,
- NFSKERBKEY_T, struct mbuf **, char **,
- struct mbuf *));
-int nfs_adv __P((struct mbuf **, caddr_t *, int, int));
-void nfs_nhinit __P((void));
-void nfs_timer __P((void*));
-u_long nfs_hash __P((nfsfh_t *, int));
-int nfsrv_dorec __P((struct nfssvc_sock *, struct nfsd *,
- struct nfsrv_descript **));
-int nfsrv_getcache __P((struct nfsrv_descript *, struct nfssvc_sock *,
- struct mbuf **));
-void nfsrv_updatecache __P((struct nfsrv_descript *, int, struct mbuf *));
-void nfsrv_cleancache __P((void));
-int nfs_connect __P((struct nfsmount *, struct nfsreq *));
-void nfs_disconnect __P((struct nfsmount *));
-void nfs_safedisconnect __P((struct nfsmount *));
-int nfs_getattrcache __P((struct vnode *, struct vattr *));
-int nfsm_strtmbuf __P((struct mbuf **, char **, const char *, long));
-int nfs_bioread __P((struct vnode *, struct uio *, int, struct ucred *));
-int nfsm_uiotombuf __P((struct uio *, struct mbuf **, int, caddr_t *));
-void nfsrv_init __P((int));
-void nfs_clearcommit __P((struct mount *));
-int nfsrv_errmap __P((struct nfsrv_descript *, int));
-void nfsrvw_sort __P((gid_t *, int));
-void nfsrv_setcred __P((struct ucred *, struct ucred *));
-int nfs_writebp __P((struct buf *, int, struct proc *));
-int nfsrv_object_create __P((struct vnode *));
-void nfsrv_wakenfsd __P((struct nfssvc_sock *slp));
-int nfsrv_writegather __P((struct nfsrv_descript **, struct nfssvc_sock *,
- struct proc *, struct mbuf **));
-int nfs_fsinfo __P((struct nfsmount *, struct vnode *, struct ucred *,
- struct proc *p));
-
-int nfsrv3_access __P((struct nfsrv_descript *nfsd,
- struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_commit __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_create __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_fhtovp __P((fhandle_t *, int, struct vnode **, struct ucred *,
- struct nfssvc_sock *, struct sockaddr *, int *,
- int, int));
-int nfsrv_setpublicfs __P((struct mount *, struct netexport *,
- struct export_args *));
-int nfs_ispublicfh __P((fhandle_t *));
-int nfsrv_fsinfo __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_getattr __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_link __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_lookup __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_mkdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_mknod __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_noop __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_null __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_pathconf __P((struct nfsrv_descript *nfsd,
- struct nfssvc_sock *slp, struct proc *procp,
- struct mbuf **mrq));
-int nfsrv_read __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_readdir __P((struct nfsrv_descript *nfsd,
- struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_readdirplus __P((struct nfsrv_descript *nfsd,
- struct nfssvc_sock *slp, struct proc *procp,
- struct mbuf **mrq));
-int nfsrv_readlink __P((struct nfsrv_descript *nfsd,
- struct nfssvc_sock *slp, struct proc *procp,
- struct mbuf **mrq));
-int nfsrv_remove __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_rename __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_rmdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_setattr __P((struct nfsrv_descript *nfsd,
- struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_statfs __P((struct nfsrv_descript *nfsd,
- struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_symlink __P((struct nfsrv_descript *nfsd,
- struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_write __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-void nfsrv_rcv __P((struct socket *so, void *arg, int waitflag));
-void nfsrv_slpderef __P((struct nfssvc_sock *slp));
-#endif /* _KERNEL */
-
-#endif
diff --git a/sys/nfsserver/nfs.h b/sys/nfsserver/nfs.h
deleted file mode 100644
index e07a4f5315d1..000000000000
--- a/sys/nfsserver/nfs.h
+++ /dev/null
@@ -1,727 +0,0 @@
-/*
- * Copyright (c) 1989, 1993, 1995
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Rick Macklem at The University of Guelph.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)nfs.h 8.4 (Berkeley) 5/1/95
- * $FreeBSD$
- */
-
-#ifndef _NFS_NFS_H_
-#define _NFS_NFS_H_
-
-#ifdef _KERNEL
-#include "opt_nfs.h"
-#endif
-
-/*
- * Tunable constants for nfs
- */
-
-#define NFS_MAXIOVEC 34
-#define NFS_TICKINTVL 5 /* Desired time for a tick (msec) */
-#define NFS_HZ (hz / nfs_ticks) /* Ticks/sec */
-#define NFS_TIMEO (1 * NFS_HZ) /* Default timeout = 1 second */
-#define NFS_MINTIMEO (1 * NFS_HZ) /* Min timeout to use */
-#define NFS_MAXTIMEO (60 * NFS_HZ) /* Max timeout to backoff to */
-#define NFS_MINIDEMTIMEO (5 * NFS_HZ) /* Min timeout for non-idempotent ops*/
-#define NFS_MAXREXMIT 100 /* Stop counting after this many */
-#define NFS_MAXWINDOW 1024 /* Max number of outstanding requests */
-#define NFS_RETRANS 10 /* Num of retrans for soft mounts */
-#define NFS_MAXGRPS 16 /* Max. size of groups list */
-#ifndef NFS_MINATTRTIMO
-#define NFS_MINATTRTIMO 3 /* VREG attrib cache timeout in sec */
-#endif
-#ifndef NFS_MAXATTRTIMO
-#define NFS_MAXATTRTIMO 60
-#endif
-#ifndef NFS_MINDIRATTRTIMO
-#define NFS_MINDIRATTRTIMO 30 /* VDIR attrib cache timeout in sec */
-#endif
-#ifndef NFS_MAXDIRATTRTIMO
-#define NFS_MAXDIRATTRTIMO 60
-#endif
-#define NFS_WSIZE 8192 /* Def. write data size <= 8192 */
-#define NFS_RSIZE 8192 /* Def. read data size <= 8192 */
-#define NFS_READDIRSIZE 8192 /* Def. readdir size */
-#define NFS_DEFRAHEAD 1 /* Def. read ahead # blocks */
-#define NFS_MAXRAHEAD 4 /* Max. read ahead # blocks */
-#define NFS_MAXUIDHASH 64 /* Max. # of hashed uid entries/mp */
-#define NFS_MAXASYNCDAEMON 20 /* Max. number async_daemons runnable */
-#define NFS_MAXGATHERDELAY 100 /* Max. write gather delay (msec) */
-#ifndef NFS_GATHERDELAY
-#define NFS_GATHERDELAY 10 /* Default write gather delay (msec) */
-#endif
-#define NFS_DIRBLKSIZ 4096 /* Must be a multiple of DIRBLKSIZ */
-#ifdef _KERNEL
-#define DIRBLKSIZ 512 /* XXX we used to use ufs's DIRBLKSIZ */
-#endif
-
-/*
- * Oddballs
- */
-#define NMOD(a) ((a) % nfs_asyncdaemons)
-#define NFS_CMPFH(n, f, s) \
- ((n)->n_fhsize == (s) && !bcmp((caddr_t)(n)->n_fhp, (caddr_t)(f), (s)))
-#define NFS_ISV3(v) (VFSTONFS((v)->v_mount)->nm_flag & NFSMNT_NFSV3)
-#define NFS_SRVMAXDATA(n) \
- (((n)->nd_flag & ND_NFSV3) ? (((n)->nd_nam2) ? \
- NFS_MAXDGRAMDATA : NFS_MAXDATA) : NFS_V2MAXDATA)
-
-/*
- * XXX
- * The B_INVAFTERWRITE flag should be set to whatever is required by the
- * buffer cache code to say "Invalidate the block after it is written back".
- */
-#define B_INVAFTERWRITE B_NOCACHE
-
-/*
- * The IO_METASYNC flag should be implemented for local file systems.
- * (Until then, it is nothin at all.)
- */
-#ifndef IO_METASYNC
-#define IO_METASYNC 0
-#endif
-
-/*
- * Arguments to mount NFS
- */
-#define NFS_ARGSVERSION 3 /* change when nfs_args changes */
-struct nfs_args {
- int version; /* args structure version number */
- struct sockaddr *addr; /* file server address */
- int addrlen; /* length of address */
- int sotype; /* Socket type */
- int proto; /* and Protocol */
- u_char *fh; /* File handle to be mounted */
- int fhsize; /* Size, in bytes, of fh */
- int flags; /* flags */
- int wsize; /* write size in bytes */
- int rsize; /* read size in bytes */
- int readdirsize; /* readdir size in bytes */
- int timeo; /* initial timeout in .1 secs */
- int retrans; /* times to retry send */
- int maxgrouplist; /* Max. size of group list */
- int readahead; /* # of blocks to readahead */
- int leaseterm; /* Term (sec) of lease */
- int deadthresh; /* Retrans threshold */
- char *hostname; /* server's name */
- int acregmin; /* cache attrs for reg files min time */
- int acregmax; /* cache attrs for reg files max time */
- int acdirmin; /* cache attrs for dirs min time */
- int acdirmax; /* cache attrs for dirs max time */
-};
-
-/*
- * NFS mount option flags
- */
-#define NFSMNT_SOFT 0x00000001 /* soft mount (hard is default) */
-#define NFSMNT_WSIZE 0x00000002 /* set write size */
-#define NFSMNT_RSIZE 0x00000004 /* set read size */
-#define NFSMNT_TIMEO 0x00000008 /* set initial timeout */
-#define NFSMNT_RETRANS 0x00000010 /* set number of request retries */
-#define NFSMNT_MAXGRPS 0x00000020 /* set maximum grouplist size */
-#define NFSMNT_INT 0x00000040 /* allow interrupts on hard mount */
-#define NFSMNT_NOCONN 0x00000080 /* Don't Connect the socket */
-#define NFSMNT_NQNFS 0x00000100 /* Use Nqnfs protocol */
-#define NFSMNT_NFSV3 0x00000200 /* Use NFS Version 3 protocol */
-#define NFSMNT_KERB 0x00000400 /* Use Kerberos authentication */
-#define NFSMNT_DUMBTIMR 0x00000800 /* Don't estimate rtt dynamically */
-#define NFSMNT_LEASETERM 0x00001000 /* set lease term (nqnfs) */
-#define NFSMNT_READAHEAD 0x00002000 /* set read ahead */
-#define NFSMNT_DEADTHRESH 0x00004000 /* set dead server retry thresh */
-#define NFSMNT_RESVPORT 0x00008000 /* Allocate a reserved port */
-#define NFSMNT_RDIRPLUS 0x00010000 /* Use Readdirplus for V3 */
-#define NFSMNT_READDIRSIZE 0x00020000 /* Set readdir size */
-#define NFSMNT_ACREGMIN 0x00040000
-#define NFSMNT_ACREGMAX 0x00080000
-#define NFSMNT_ACDIRMIN 0x00100000
-#define NFSMNT_ACDIRMAX 0x00200000
-
-#define NFSSTA_HASWRITEVERF 0x00040000 /* Has write verifier for V3 */
-#define NFSSTA_GOTPATHCONF 0x00080000 /* Got the V3 pathconf info */
-#define NFSSTA_GOTFSINFO 0x00100000 /* Got the V3 fsinfo */
-#define NFSSTA_MNTD 0x00200000 /* Mnt server for mnt point */
-#define NFSSTA_DISMINPROG 0x00400000 /* Dismount in progress */
-#define NFSSTA_DISMNT 0x00800000 /* Dismounted */
-#define NFSSTA_SNDLOCK 0x01000000 /* Send socket lock */
-#define NFSSTA_WANTSND 0x02000000 /* Want above */
-#define NFSSTA_RCVLOCK 0x04000000 /* Rcv socket lock */
-#define NFSSTA_WANTRCV 0x08000000 /* Want above */
-#define NFSSTA_WAITAUTH 0x10000000 /* Wait for authentication */
-#define NFSSTA_HASAUTH 0x20000000 /* Has authenticator */
-#define NFSSTA_WANTAUTH 0x40000000 /* Wants an authenticator */
-#define NFSSTA_AUTHERR 0x80000000 /* Authentication error */
-
-/*
- * Structures for the nfssvc(2) syscall. Not that anyone but nfsd and mount_nfs
- * should ever try and use it.
- */
-struct nfsd_args {
- int sock; /* Socket to serve */
- caddr_t name; /* Client addr for connection based sockets */
- int namelen; /* Length of name */
-};
-
-struct nfsd_srvargs {
- struct nfsd *nsd_nfsd; /* Pointer to in kernel nfsd struct */
- uid_t nsd_uid; /* Effective uid mapped to cred */
- u_int32_t nsd_haddr; /* Ip address of client */
- struct ucred nsd_cr; /* Cred. uid maps to */
- int nsd_authlen; /* Length of auth string (ret) */
- u_char *nsd_authstr; /* Auth string (ret) */
- int nsd_verflen; /* and the verfier */
- u_char *nsd_verfstr;
- struct timeval nsd_timestamp; /* timestamp from verifier */
- u_int32_t nsd_ttl; /* credential ttl (sec) */
- NFSKERBKEY_T nsd_key; /* Session key */
-};
-
-struct nfsd_cargs {
- char *ncd_dirp; /* Mount dir path */
- uid_t ncd_authuid; /* Effective uid */
- int ncd_authtype; /* Type of authenticator */
- int ncd_authlen; /* Length of authenticator string */
- u_char *ncd_authstr; /* Authenticator string */
- int ncd_verflen; /* and the verifier */
- u_char *ncd_verfstr;
- NFSKERBKEY_T ncd_key; /* Session key */
-};
-
-/*
- * XXX to allow amd to include nfs.h without nfsproto.h
- */
-#ifdef NFS_NPROCS
-/*
- * Stats structure
- */
-struct nfsstats {
- int attrcache_hits;
- int attrcache_misses;
- int lookupcache_hits;
- int lookupcache_misses;
- int direofcache_hits;
- int direofcache_misses;
- int biocache_reads;
- int read_bios;
- int read_physios;
- int biocache_writes;
- int write_bios;
- int write_physios;
- int biocache_readlinks;
- int readlink_bios;
- int biocache_readdirs;
- int readdir_bios;
- int rpccnt[NFS_NPROCS];
- int rpcretries;
- int srvrpccnt[NFS_NPROCS];
- int srvrpc_errs;
- int srv_errs;
- int rpcrequests;
- int rpctimeouts;
- int rpcunexpected;
- int rpcinvalid;
- int srvcache_inproghits;
- int srvcache_idemdonehits;
- int srvcache_nonidemdonehits;
- int srvcache_misses;
- int srvnqnfs_leases;
- int srvnqnfs_maxleases;
- int srvnqnfs_getleases;
- int srvvop_writes;
- int accesscache_hits;
- int accesscache_misses;
-};
-#endif
-
-/*
- * Flags for nfssvc() system call.
- */
-#define NFSSVC_BIOD 0x002
-#define NFSSVC_NFSD 0x004
-#define NFSSVC_ADDSOCK 0x008
-#define NFSSVC_AUTHIN 0x010
-#define NFSSVC_GOTAUTH 0x040
-#define NFSSVC_AUTHINFAIL 0x080
-#define NFSSVC_MNTD 0x100
-
-/*
- * fs.nfs sysctl(3) identifiers
- */
-#define NFS_NFSSTATS 1 /* struct: struct nfsstats */
-#define NFS_NFSPRIVPORT 2 /* int: prohibit nfs to resvports */
-
-#define FS_NFS_NAMES { \
- { 0, 0 }, \
- { "nfsstats", CTLTYPE_STRUCT }, \
- { "nfsprivport", CTLTYPE_INT }, \
-}
-
-#ifdef _KERNEL
-
-#ifdef MALLOC_DECLARE
-MALLOC_DECLARE(M_NFSREQ);
-MALLOC_DECLARE(M_NFSDIROFF);
-MALLOC_DECLARE(M_NFSRVDESC);
-MALLOC_DECLARE(M_NFSUID);
-MALLOC_DECLARE(M_NQLEASE);
-MALLOC_DECLARE(M_NFSD);
-MALLOC_DECLARE(M_NFSBIGFH);
-MALLOC_DECLARE(M_NFSHASH);
-#endif
-
-#ifdef ZONE_INTERRUPT
-extern vm_zone_t nfsmount_zone;
-#endif
-
-extern struct callout_handle nfs_timer_handle;
-
-struct uio; struct buf; struct vattr; struct nameidata; /* XXX */
-
-/*
- * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts.
- * What should be in this set is open to debate, but I believe that since
- * I/O system calls on ufs are never interrupted by signals the set should
- * be minimal. My reasoning is that many current programs that use signals
- * such as SIGALRM will not expect file I/O system calls to be interrupted
- * by them and break.
- */
-#define NFSINT_SIGMASK(set) \
- (SIGISMEMBER(set, SIGINT) || SIGISMEMBER(set, SIGTERM) || \
- SIGISMEMBER(set, SIGHUP) || SIGISMEMBER(set, SIGKILL) || \
- SIGISMEMBER(set, SIGQUIT))
-
-/*
- * Socket errors ignored for connectionless sockets??
- * For now, ignore them all
- */
-#define NFSIGNORE_SOERROR(s, e) \
- ((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \
- ((s) & PR_CONNREQUIRED) == 0)
-
-/*
- * Nfs outstanding request list element
- */
-struct nfsreq {
- TAILQ_ENTRY(nfsreq) r_chain;
- struct mbuf *r_mreq;
- struct mbuf *r_mrep;
- struct mbuf *r_md;
- caddr_t r_dpos;
- struct nfsmount *r_nmp;
- struct vnode *r_vp;
- u_int32_t r_xid;
- int r_flags; /* flags on request, see below */
- int r_retry; /* max retransmission count */
- int r_rexmit; /* current retrans count */
- int r_timer; /* tick counter on reply */
- u_int32_t r_procnum; /* NFS procedure number */
- int r_rtt; /* RTT for rpc */
- struct proc *r_procp; /* Proc that did I/O system call */
-};
-
-/*
- * Queue head for nfsreq's
- */
-extern TAILQ_HEAD(nfs_reqq, nfsreq) nfs_reqq;
-
-/* Flag values for r_flags */
-#define R_TIMING 0x01 /* timing request (in mntp) */
-#define R_SENT 0x02 /* request has been sent */
-#define R_SOFTTERM 0x04 /* soft mnt, too many retries */
-#define R_INTR 0x08 /* intr mnt, signal pending */
-#define R_SOCKERR 0x10 /* Fatal error on socket */
-#define R_TPRINTFMSG 0x20 /* Did a tprintf msg. */
-#define R_MUSTRESEND 0x40 /* Must resend request */
-#define R_GETONEREP 0x80 /* Probe for one reply only */
-
-/*
- * A list of nfssvc_sock structures is maintained with all the sockets
- * that require service by the nfsd.
- * The nfsuid structs hang off of the nfssvc_sock structs in both lru
- * and uid hash lists.
- */
-#ifndef NFS_UIDHASHSIZ
-#define NFS_UIDHASHSIZ 29 /* Tune the size of nfssvc_sock with this */
-#endif
-#define NUIDHASH(sock, uid) \
- (&(sock)->ns_uidhashtbl[(uid) % NFS_UIDHASHSIZ])
-#ifndef NFS_WDELAYHASHSIZ
-#define NFS_WDELAYHASHSIZ 16 /* and with this */
-#endif
-#define NWDELAYHASH(sock, f) \
- (&(sock)->ns_wdelayhashtbl[(*((u_int32_t *)(f))) % NFS_WDELAYHASHSIZ])
-#ifndef NFS_MUIDHASHSIZ
-#define NFS_MUIDHASHSIZ 63 /* Tune the size of nfsmount with this */
-#endif
-#define NMUIDHASH(nmp, uid) \
- (&(nmp)->nm_uidhashtbl[(uid) % NFS_MUIDHASHSIZ])
-#define NFSNOHASH(fhsum) \
- (&nfsnodehashtbl[(fhsum) & nfsnodehash])
-
-/*
- * Network address hash list element
- */
-union nethostaddr {
- u_int32_t had_inetaddr;
- struct sockaddr *had_nam;
-};
-
-struct nfsuid {
- TAILQ_ENTRY(nfsuid) nu_lru; /* LRU chain */
- LIST_ENTRY(nfsuid) nu_hash; /* Hash list */
- int nu_flag; /* Flags */
- union nethostaddr nu_haddr; /* Host addr. for dgram sockets */
- struct ucred nu_cr; /* Cred uid mapped to */
- int nu_expire; /* Expiry time (sec) */
- struct timeval nu_timestamp; /* Kerb. timestamp */
- u_int32_t nu_nickname; /* Nickname on server */
- NFSKERBKEY_T nu_key; /* and session key */
-};
-
-#define nu_inetaddr nu_haddr.had_inetaddr
-#define nu_nam nu_haddr.had_nam
-/* Bits for nu_flag */
-#define NU_INETADDR 0x1
-#define NU_NAM 0x2
-#define NU_NETFAM(u) (((u)->nu_flag & NU_INETADDR) ? AF_INET : AF_ISO)
-
-struct nfsrv_rec {
- STAILQ_ENTRY(nfsrv_rec) nr_link;
- struct sockaddr *nr_address;
- struct mbuf *nr_packet;
-};
-
-struct nfssvc_sock {
- TAILQ_ENTRY(nfssvc_sock) ns_chain; /* List of all nfssvc_sock's */
- TAILQ_HEAD(, nfsuid) ns_uidlruhead;
- struct file *ns_fp;
- struct socket *ns_so;
- struct sockaddr *ns_nam;
- struct mbuf *ns_raw;
- struct mbuf *ns_rawend;
- STAILQ_HEAD(, nfsrv_rec) ns_rec;
- struct mbuf *ns_frag;
- int ns_flag;
- int ns_solock;
- int ns_cc;
- int ns_reclen;
- int ns_numuids;
- u_int32_t ns_sref;
- LIST_HEAD(, nfsrv_descript) ns_tq; /* Write gather lists */
- LIST_HEAD(, nfsuid) ns_uidhashtbl[NFS_UIDHASHSIZ];
- LIST_HEAD(nfsrvw_delayhash, nfsrv_descript) ns_wdelayhashtbl[NFS_WDELAYHASHSIZ];
-};
-
-/* Bits for "ns_flag" */
-#define SLP_VALID 0x01
-#define SLP_DOREC 0x02
-#define SLP_NEEDQ 0x04
-#define SLP_DISCONN 0x08
-#define SLP_GETSTREAM 0x10
-#define SLP_LASTFRAG 0x20
-#define SLP_ALLFLAGS 0xff
-
-extern TAILQ_HEAD(nfssvc_sockhead, nfssvc_sock) nfssvc_sockhead;
-extern int nfssvc_sockhead_flag;
-#define SLP_INIT 0x01
-#define SLP_WANTINIT 0x02
-
-/*
- * One of these structures is allocated for each nfsd.
- */
-struct nfsd {
- TAILQ_ENTRY(nfsd) nfsd_chain; /* List of all nfsd's */
- int nfsd_flag; /* NFSD_ flags */
- struct nfssvc_sock *nfsd_slp; /* Current socket */
- int nfsd_authlen; /* Authenticator len */
- u_char nfsd_authstr[RPCAUTH_MAXSIZ]; /* Authenticator data */
- int nfsd_verflen; /* and the Verifier */
- u_char nfsd_verfstr[RPCVERF_MAXSIZ];
- struct proc *nfsd_procp; /* Proc ptr */
- struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */
-};
-
-/* Bits for "nfsd_flag" */
-#define NFSD_WAITING 0x01
-#define NFSD_REQINPROG 0x02
-#define NFSD_NEEDAUTH 0x04
-#define NFSD_AUTHFAIL 0x08
-
-/*
- * This structure is used by the server for describing each request.
- * Some fields are used only when write request gathering is performed.
- */
-struct nfsrv_descript {
- u_quad_t nd_time; /* Write deadline (usec) */
- off_t nd_off; /* Start byte offset */
- off_t nd_eoff; /* and end byte offset */
- LIST_ENTRY(nfsrv_descript) nd_hash; /* Hash list */
- LIST_ENTRY(nfsrv_descript) nd_tq; /* and timer list */
- LIST_HEAD(,nfsrv_descript) nd_coalesce; /* coalesced writes */
- struct mbuf *nd_mrep; /* Request mbuf list */
- struct mbuf *nd_md; /* Current dissect mbuf */
- struct mbuf *nd_mreq; /* Reply mbuf list */
- struct sockaddr *nd_nam; /* and socket addr */
- struct sockaddr *nd_nam2; /* return socket addr */
- caddr_t nd_dpos; /* Current dissect pos */
- u_int32_t nd_procnum; /* RPC # */
- int nd_stable; /* storage type */
- int nd_flag; /* nd_flag */
- int nd_len; /* Length of this write */
- int nd_repstat; /* Reply status */
- u_int32_t nd_retxid; /* Reply xid */
- u_int32_t nd_duration; /* Lease duration */
- struct timeval nd_starttime; /* Time RPC initiated */
- fhandle_t nd_fh; /* File handle */
- struct ucred nd_cr; /* Credentials */
-};
-
-/* Bits for "nd_flag" */
-#define ND_READ LEASE_READ
-#define ND_WRITE LEASE_WRITE
-#define ND_CHECK 0x04
-#define ND_LEASE (ND_READ | ND_WRITE | ND_CHECK)
-#define ND_NFSV3 0x08
-#define ND_NQNFS 0x10
-#define ND_KERBNICK 0x20
-#define ND_KERBFULL 0x40
-#define ND_KERBAUTH (ND_KERBNICK | ND_KERBFULL)
-
-extern TAILQ_HEAD(nfsd_head, nfsd) nfsd_head;
-extern int nfsd_head_flag;
-#define NFSD_CHECKSLP 0x01
-
-/*
- * These macros compare nfsrv_descript structures.
- */
-#define NFSW_CONTIG(o, n) \
- ((o)->nd_eoff >= (n)->nd_off && \
- !bcmp((caddr_t)&(o)->nd_fh, (caddr_t)&(n)->nd_fh, NFSX_V3FH))
-
-#define NFSW_SAMECRED(o, n) \
- (((o)->nd_flag & ND_KERBAUTH) == ((n)->nd_flag & ND_KERBAUTH) && \
- !bcmp((caddr_t)&(o)->nd_cr, (caddr_t)&(n)->nd_cr, \
- sizeof (struct ucred)))
-
-/*
- * Defines for WebNFS
- */
-
-#define WEBNFS_ESC_CHAR '%'
-#define WEBNFS_SPECCHAR_START 0x80
-
-#define WEBNFS_NATIVE_CHAR 0x80
-/*
- * ..
- * Possibly more here in the future.
- */
-
-/*
- * Macro for converting escape characters in WebNFS pathnames.
- * Should really be in libkern.
- */
-
-#define HEXTOC(c) \
- ((c) >= 'a' ? ((c) - ('a' - 10)) : \
- ((c) >= 'A' ? ((c) - ('A' - 10)) : ((c) - '0')))
-#define HEXSTRTOI(p) \
- ((HEXTOC(p[0]) << 4) + HEXTOC(p[1]))
-
-#ifdef NFS_DEBUG
-
-extern int nfs_debug;
-#define NFS_DEBUG_ASYNCIO 1 /* asynchronous i/o */
-#define NFS_DEBUG_WG 2 /* server write gathering */
-#define NFS_DEBUG_RC 4 /* server request caching */
-
-#define NFS_DPF(cat, args) \
- do { \
- if (nfs_debug & NFS_DEBUG_##cat) printf args; \
- } while (0)
-
-#else
-
-#define NFS_DPF(cat, args)
-
-#endif
-
-u_quad_t nfs_curusec __P((void));
-int nfs_init __P((struct vfsconf *vfsp));
-int nfs_uninit __P((struct vfsconf *vfsp));
-int nfs_reply __P((struct nfsreq *));
-int nfs_getreq __P((struct nfsrv_descript *,struct nfsd *,int));
-int nfs_send __P((struct socket *, struct sockaddr *, struct mbuf *,
- struct nfsreq *));
-int nfs_rephead __P((int, struct nfsrv_descript *, struct nfssvc_sock *,
- int, int, u_quad_t *, struct mbuf **, struct mbuf **,
- caddr_t *));
-int nfs_sndlock __P((struct nfsreq *));
-void nfs_sndunlock __P((struct nfsreq *));
-int nfs_slplock __P((struct nfssvc_sock *, int));
-void nfs_slpunlock __P((struct nfssvc_sock *));
-int nfs_disct __P((struct mbuf **, caddr_t *, int, int, caddr_t *));
-int nfs_vinvalbuf __P((struct vnode *, int, struct ucred *, struct proc *,
- int));
-int nfs_readrpc __P((struct vnode *, struct uio *, struct ucred *));
-int nfs_writerpc __P((struct vnode *, struct uio *, struct ucred *, int *,
- int *));
-int nfs_commit __P((struct vnode *vp, u_quad_t offset, int cnt,
- struct ucred *cred, struct proc *procp));
-int nfs_readdirrpc __P((struct vnode *, struct uio *, struct ucred *));
-int nfs_asyncio __P((struct buf *, struct ucred *, struct proc *));
-int nfs_doio __P((struct buf *, struct ucred *, struct proc *));
-int nfs_readlinkrpc __P((struct vnode *, struct uio *, struct ucred *));
-int nfs_sigintr __P((struct nfsmount *, struct nfsreq *, struct proc *));
-int nfs_readdirplusrpc __P((struct vnode *, struct uio *, struct ucred *));
-int nfsm_disct __P((struct mbuf **, caddr_t *, int, int, caddr_t *));
-void nfsm_srvfattr __P((struct nfsrv_descript *, struct vattr *,
- struct nfs_fattr *));
-void nfsm_srvwcc __P((struct nfsrv_descript *, int, struct vattr *, int,
- struct vattr *, struct mbuf **, char **));
-void nfsm_srvpostopattr __P((struct nfsrv_descript *, int, struct vattr *,
- struct mbuf **, char **));
-int netaddr_match __P((int, union nethostaddr *, struct sockaddr *));
-int nfs_request __P((struct vnode *, struct mbuf *, int, struct proc *,
- struct ucred *, struct mbuf **, struct mbuf **,
- caddr_t *));
-int nfs_loadattrcache __P((struct vnode **, struct mbuf **, caddr_t *,
- struct vattr *));
-int nfs_namei __P((struct nameidata *, fhandle_t *, int,
- struct nfssvc_sock *, struct sockaddr *, struct mbuf **,
- caddr_t *, struct vnode **, struct proc *, int, int));
-void nfsm_adj __P((struct mbuf *, int, int));
-int nfsm_mbuftouio __P((struct mbuf **, struct uio *, int, caddr_t *));
-void nfsrv_initcache __P((void));
-int nfs_getauth __P((struct nfsmount *, struct nfsreq *, struct ucred *,
- char **, int *, char *, int *, NFSKERBKEY_T));
-int nfs_getnickauth __P((struct nfsmount *, struct ucred *, char **,
- int *, char *, int));
-int nfs_savenickauth __P((struct nfsmount *, struct ucred *, int,
- NFSKERBKEY_T, struct mbuf **, char **,
- struct mbuf *));
-int nfs_adv __P((struct mbuf **, caddr_t *, int, int));
-void nfs_nhinit __P((void));
-void nfs_timer __P((void*));
-u_long nfs_hash __P((nfsfh_t *, int));
-int nfsrv_dorec __P((struct nfssvc_sock *, struct nfsd *,
- struct nfsrv_descript **));
-int nfsrv_getcache __P((struct nfsrv_descript *, struct nfssvc_sock *,
- struct mbuf **));
-void nfsrv_updatecache __P((struct nfsrv_descript *, int, struct mbuf *));
-void nfsrv_cleancache __P((void));
-int nfs_connect __P((struct nfsmount *, struct nfsreq *));
-void nfs_disconnect __P((struct nfsmount *));
-void nfs_safedisconnect __P((struct nfsmount *));
-int nfs_getattrcache __P((struct vnode *, struct vattr *));
-int nfsm_strtmbuf __P((struct mbuf **, char **, const char *, long));
-int nfs_bioread __P((struct vnode *, struct uio *, int, struct ucred *));
-int nfsm_uiotombuf __P((struct uio *, struct mbuf **, int, caddr_t *));
-void nfsrv_init __P((int));
-void nfs_clearcommit __P((struct mount *));
-int nfsrv_errmap __P((struct nfsrv_descript *, int));
-void nfsrvw_sort __P((gid_t *, int));
-void nfsrv_setcred __P((struct ucred *, struct ucred *));
-int nfs_writebp __P((struct buf *, int, struct proc *));
-int nfsrv_object_create __P((struct vnode *));
-void nfsrv_wakenfsd __P((struct nfssvc_sock *slp));
-int nfsrv_writegather __P((struct nfsrv_descript **, struct nfssvc_sock *,
- struct proc *, struct mbuf **));
-int nfs_fsinfo __P((struct nfsmount *, struct vnode *, struct ucred *,
- struct proc *p));
-
-int nfsrv3_access __P((struct nfsrv_descript *nfsd,
- struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_commit __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_create __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_fhtovp __P((fhandle_t *, int, struct vnode **, struct ucred *,
- struct nfssvc_sock *, struct sockaddr *, int *,
- int, int));
-int nfsrv_setpublicfs __P((struct mount *, struct netexport *,
- struct export_args *));
-int nfs_ispublicfh __P((fhandle_t *));
-int nfsrv_fsinfo __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_getattr __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_link __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_lookup __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_mkdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_mknod __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_noop __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_null __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_pathconf __P((struct nfsrv_descript *nfsd,
- struct nfssvc_sock *slp, struct proc *procp,
- struct mbuf **mrq));
-int nfsrv_read __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_readdir __P((struct nfsrv_descript *nfsd,
- struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_readdirplus __P((struct nfsrv_descript *nfsd,
- struct nfssvc_sock *slp, struct proc *procp,
- struct mbuf **mrq));
-int nfsrv_readlink __P((struct nfsrv_descript *nfsd,
- struct nfssvc_sock *slp, struct proc *procp,
- struct mbuf **mrq));
-int nfsrv_remove __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_rename __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_rmdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_setattr __P((struct nfsrv_descript *nfsd,
- struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_statfs __P((struct nfsrv_descript *nfsd,
- struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_symlink __P((struct nfsrv_descript *nfsd,
- struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_write __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-void nfsrv_rcv __P((struct socket *so, void *arg, int waitflag));
-void nfsrv_slpderef __P((struct nfssvc_sock *slp));
-#endif /* _KERNEL */
-
-#endif
diff --git a/sys/nfsserver/nfs_serv.c b/sys/nfsserver/nfs_serv.c
deleted file mode 100644
index 0d286709ae18..000000000000
--- a/sys/nfsserver/nfs_serv.c
+++ /dev/null
@@ -1,4068 +0,0 @@
-/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Rick Macklem at The University of Guelph.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)nfs_serv.c 8.8 (Berkeley) 7/31/95
- * $FreeBSD$
- */
-
-/*
- * nfs version 2 and 3 server calls to vnode ops
- * - these routines generally have 3 phases
- * 1 - break down and validate rpc request in mbuf list
- * 2 - do the vnode ops for the request
- * (surprisingly ?? many are very similar to syscalls in vfs_syscalls.c)
- * 3 - build the rpc reply in an mbuf list
- * nb:
- * - do not mix the phases, since the nfsm_?? macros can return failures
- * on a bad rpc or similar and do not do any vrele() or vput()'s
- *
- * - the nfsm_reply() macro generates an nfs rpc reply with the nfs
- * error number iff error != 0 whereas
- * returning an error from the server function implies a fatal error
- * such as a badly constructed rpc request that should be dropped without
- * a reply.
- * For Version 3, nfsm_reply() does not return for the error case, since
- * most version 3 rpcs return more than the status for error cases.
- *
- * Other notes:
- * Warning: always pay careful attention to resource cleanup on return
- * and note that nfsm_*() macros can terminate a procedure on certain
- * errors.
- *
- * lookup() and namei()
- * may return garbage in various structural fields/return elements
- * if an error is returned, and may garbage up nd.ni_dvp even if no
- * error is returned and you did not request LOCKPARENT or WANTPARENT.
- *
- * We use the ni_cnd.cn_flags 'HASBUF' flag to track whether the name
- * buffer has been freed or not.
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/proc.h>
-#include <sys/namei.h>
-#include <sys/unistd.h>
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-#include <sys/malloc.h>
-#include <sys/mbuf.h>
-#include <sys/dirent.h>
-#include <sys/stat.h>
-#include <sys/kernel.h>
-#include <sys/sysctl.h>
-#include <sys/buf.h>
-
-#include <vm/vm.h>
-#include <vm/vm_extern.h>
-#include <vm/vm_zone.h>
-#include <vm/vm_object.h>
-
-#include <nfs/nfsproto.h>
-#include <nfs/rpcv2.h>
-#include <nfs/nfs.h>
-#include <nfs/xdr_subs.h>
-#include <nfs/nfsm_subs.h>
-#include <nfs/nqnfs.h>
-
-#ifdef NFSRV_DEBUG
-#define nfsdbprintf(info) printf info
-#else
-#define nfsdbprintf(info)
-#endif
-
-#define MAX_COMMIT_COUNT (1024 * 1024)
-
-#define NUM_HEURISTIC 64
-#define NHUSE_INIT 64
-#define NHUSE_INC 16
-#define NHUSE_MAX 2048
-
-static struct nfsheur {
- struct vnode *nh_vp; /* vp to match (unreferenced pointer) */
- off_t nh_nextr; /* next offset for sequential detection */
- int nh_use; /* use count for selection */
- int nh_seqcount; /* heuristic */
-} nfsheur[NUM_HEURISTIC];
-
-nfstype nfsv3_type[9] = { NFNON, NFREG, NFDIR, NFBLK, NFCHR, NFLNK, NFSOCK,
- NFFIFO, NFNON };
-#ifndef NFS_NOSERVER
-nfstype nfsv2_type[9] = { NFNON, NFREG, NFDIR, NFBLK, NFCHR, NFLNK, NFNON,
- NFCHR, NFNON };
-/* Global vars */
-extern u_int32_t nfs_xdrneg1;
-extern u_int32_t nfs_false, nfs_true;
-extern enum vtype nv3tov_type[8];
-extern struct nfsstats nfsstats;
-
-int nfsrvw_procrastinate = NFS_GATHERDELAY * 1000;
-int nfsrvw_procrastinate_v3 = 0;
-
-static struct timeval nfsver = { 0 };
-
-SYSCTL_DECL(_vfs_nfs);
-
-static int nfs_async;
-SYSCTL_INT(_vfs_nfs, OID_AUTO, async, CTLFLAG_RW, &nfs_async, 0, "");
-static int nfs_commit_blks;
-static int nfs_commit_miss;
-SYSCTL_INT(_vfs_nfs, OID_AUTO, commit_blks, CTLFLAG_RW, &nfs_commit_blks, 0, "");
-SYSCTL_INT(_vfs_nfs, OID_AUTO, commit_miss, CTLFLAG_RW, &nfs_commit_miss, 0, "");
-
-static int nfsrv_access __P((struct vnode *,int,struct ucred *,int,
- struct proc *, int));
-static void nfsrvw_coalesce __P((struct nfsrv_descript *,
- struct nfsrv_descript *));
-
-/*
- * Clear nameidata fields that are tested in nsfmout cleanup code prior
- * to using first nfsm macro (that might jump to the cleanup code).
- */
-
-static __inline
-void
-ndclear(struct nameidata *nd)
-{
- nd->ni_cnd.cn_flags = 0;
- nd->ni_vp = NULL;
- nd->ni_dvp = NULL;
- nd->ni_startdir = NULL;
-}
-
-/*
- * nfs v3 access service
- */
-int
-nfsrv3_access(nfsd, slp, procp, mrq)
- struct nfsrv_descript *nfsd;
- struct nfssvc_sock *slp;
- struct proc *procp;
- struct mbuf **mrq;
-{
- struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md;
- struct sockaddr *nam = nfsd->nd_nam;
- caddr_t dpos = nfsd->nd_dpos;
- struct ucred *cred = &nfsd->nd_cr;
- struct vnode *vp = NULL;
- nfsfh_t nfh;
- fhandle_t *fhp;
- register u_int32_t *tl;
- register int32_t t1;
- caddr_t bpos;
- int error = 0, rdonly, cache, getret;
- char *cp2;
- struct mbuf *mb, *mreq, *mb2;
- struct vattr vattr, *vap = &vattr;
- u_long testmode, nfsmode;
- u_quad_t frev;
-
- nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
-#ifndef nolint
- cache = 0;
-#endif
- fhp = &nfh.fh_generic;
- nfsm_srvmtofh(fhp);
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED);
- error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, &rdonly,
- (nfsd->nd_flag & ND_KERBAUTH), TRUE);
- if (error) {
- nfsm_reply(NFSX_UNSIGNED);
- nfsm_srvpostop_attr(1, (struct vattr *)0);
- error = 0;
- goto nfsmout;
- }
- nfsmode = fxdr_unsigned(u_int32_t, *tl);
- if ((nfsmode & NFSV3ACCESS_READ) &&
- nfsrv_access(vp, VREAD, cred, rdonly, procp, 0))
- nfsmode &= ~NFSV3ACCESS_READ;
- if (vp->v_type == VDIR)
- testmode = (NFSV3ACCESS_MODIFY | NFSV3ACCESS_EXTEND |
- NFSV3ACCESS_DELETE);
- else
- testmode = (NFSV3ACCESS_MODIFY | NFSV3ACCESS_EXTEND);
- if ((nfsmode & testmode) &&
- nfsrv_access(vp, VWRITE, cred, rdonly, procp, 0))
- nfsmode &= ~testmode;
- if (vp->v_type == VDIR)
- testmode = NFSV3ACCESS_LOOKUP;
- else
- testmode = NFSV3ACCESS_EXECUTE;
- if ((nfsmode & testmode) &&
- nfsrv_access(vp, VEXEC, cred, rdonly, procp, 0))
- nfsmode &= ~testmode;
- getret = VOP_GETATTR(vp, vap, cred, procp);
- vput(vp);
- vp = NULL;
- nfsm_reply(NFSX_POSTOPATTR(1) + NFSX_UNSIGNED);
- nfsm_srvpostop_attr(getret, vap);
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);
- *tl = txdr_unsigned(nfsmode);
-nfsmout:
- if (vp)
- vput(vp);
- return(error);
-}
-
-/*
- * nfs getattr service
- */
-int
-nfsrv_getattr(nfsd, slp, procp, mrq)
- struct nfsrv_descript *nfsd;
- struct nfssvc_sock *slp;
- struct proc *procp;
- struct mbuf **mrq;
-{
- struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md;
- struct sockaddr *nam = nfsd->nd_nam;
- caddr_t dpos = nfsd->nd_dpos;
- struct ucred *cred = &nfsd->nd_cr;
- register struct nfs_fattr *fp;
- struct vattr va;
- register struct vattr *vap = &va;
- struct vnode *vp = NULL;
- nfsfh_t nfh;
- fhandle_t *fhp;
- register u_int32_t *tl;
- register int32_t t1;
- caddr_t bpos;
- int error = 0, rdonly, cache;
- char *cp2;
- struct mbuf *mb, *mb2, *mreq;
- u_quad_t frev;
-
- nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
- fhp = &nfh.fh_generic;
- nfsm_srvmtofh(fhp);
- error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam,
- &rdonly, (nfsd->nd_flag & ND_KERBAUTH), TRUE);
- if (error) {
- nfsm_reply(0);
- error = 0;
- goto nfsmout;
- }
- nqsrv_getl(vp, ND_READ);
- error = VOP_GETATTR(vp, vap, cred, procp);
- vput(vp);
- vp = NULL;
- nfsm_reply(NFSX_FATTR(nfsd->nd_flag & ND_NFSV3));
- if (error) {
- error = 0;
- goto nfsmout;
- }
- nfsm_build(fp, struct nfs_fattr *, NFSX_FATTR(nfsd->nd_flag & ND_NFSV3));
- nfsm_srvfillattr(vap, fp);
- /* fall through */
-
-nfsmout:
- if (vp)
- vput(vp);
- return(error);
-}
-
-/*
- * nfs setattr service
- */
-int
-nfsrv_setattr(nfsd, slp, procp, mrq)
- struct nfsrv_descript *nfsd;
- struct nfssvc_sock *slp;
- struct proc *procp;
- struct mbuf **mrq;
-{
- struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md;
- struct sockaddr *nam = nfsd->nd_nam;
- caddr_t dpos = nfsd->nd_dpos;
- struct ucred *cred = &nfsd->nd_cr;
- struct vattr va, preat;
- register struct vattr *vap = &va;
- register struct nfsv2_sattr *sp;
- register struct nfs_fattr *fp;
- struct vnode *vp = NULL;
- nfsfh_t nfh;
- fhandle_t *fhp;
- register u_int32_t *tl;
- register int32_t t1;
- caddr_t bpos;
- int error = 0, rdonly, cache, preat_ret = 1, postat_ret = 1;
- int v3 = (nfsd->nd_flag & ND_NFSV3), gcheck = 0;
- char *cp2;
- struct mbuf *mb, *mb2, *mreq;
- u_quad_t frev;
- struct timespec guard;
-
- nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
- fhp = &nfh.fh_generic;
- nfsm_srvmtofh(fhp);
- VATTR_NULL(vap);
- if (v3) {
- nfsm_srvsattr(vap);
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED);
- gcheck = fxdr_unsigned(int, *tl);
- if (gcheck) {
- nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
- fxdr_nfsv3time(tl, &guard);
- }
- } else {
- nfsm_dissect(sp, struct nfsv2_sattr *, NFSX_V2SATTR);
- /*
- * Nah nah nah nah na nah
- * There is a bug in the Sun client that puts 0xffff in the mode
- * field of sattr when it should put in 0xffffffff. The u_short
- * doesn't sign extend.
- * --> check the low order 2 bytes for 0xffff
- */
- if ((fxdr_unsigned(int, sp->sa_mode) & 0xffff) != 0xffff)
- vap->va_mode = nfstov_mode(sp->sa_mode);
- if (sp->sa_uid != nfs_xdrneg1)
- vap->va_uid = fxdr_unsigned(uid_t, sp->sa_uid);
- if (sp->sa_gid != nfs_xdrneg1)
- vap->va_gid = fxdr_unsigned(gid_t, sp->sa_gid);
- if (sp->sa_size != nfs_xdrneg1)
- vap->va_size = fxdr_unsigned(u_quad_t, sp->sa_size);
- if (sp->sa_atime.nfsv2_sec != nfs_xdrneg1) {
-#ifdef notyet
- fxdr_nfsv2time(&sp->sa_atime, &vap->va_atime);
-#else
- vap->va_atime.tv_sec =
- fxdr_unsigned(int32_t, sp->sa_atime.nfsv2_sec);
- vap->va_atime.tv_nsec = 0;
-#endif
- }
- if (sp->sa_mtime.nfsv2_sec != nfs_xdrneg1)
- fxdr_nfsv2time(&sp->sa_mtime, &vap->va_mtime);
-
- }
-
- /*
- * Now that we have all the fields, lets do it.
- */
- error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, &rdonly,
- (nfsd->nd_flag & ND_KERBAUTH), TRUE);
- if (error) {
- nfsm_reply(2 * NFSX_UNSIGNED);
- nfsm_srvwcc_data(preat_ret, &preat, postat_ret, vap);
- error = 0;
- goto nfsmout;
- }
-
- /*
- * vp now an active resource, pay careful attention to cleanup
- */
-
- nqsrv_getl(vp, ND_WRITE);
- if (v3) {
- error = preat_ret = VOP_GETATTR(vp, &preat, cred, procp);
- if (!error && gcheck &&
- (preat.va_ctime.tv_sec != guard.tv_sec ||
- preat.va_ctime.tv_nsec != guard.tv_nsec))
- error = NFSERR_NOT_SYNC;
- if (error) {
- vput(vp);
- vp = NULL;
- nfsm_reply(NFSX_WCCDATA(v3));
- nfsm_srvwcc_data(preat_ret, &preat, postat_ret, vap);
- error = 0;
- goto nfsmout;
- }
- }
-
- /*
- * If the size is being changed write acces is required, otherwise
- * just check for a read only file system.
- */
- if (vap->va_size == ((u_quad_t)((quad_t) -1))) {
- if (rdonly || (vp->v_mount->mnt_flag & MNT_RDONLY)) {
- error = EROFS;
- goto out;
- }
- } else {
- if (vp->v_type == VDIR) {
- error = EISDIR;
- goto out;
- } else if ((error = nfsrv_access(vp, VWRITE, cred, rdonly,
- procp, 0)) != 0)
- goto out;
- }
- error = VOP_SETATTR(vp, vap, cred, procp);
- postat_ret = VOP_GETATTR(vp, vap, cred, procp);
- if (!error)
- error = postat_ret;
-out:
- vput(vp);
- vp = NULL;
- nfsm_reply(NFSX_WCCORFATTR(v3));
- if (v3) {
- nfsm_srvwcc_data(preat_ret, &preat, postat_ret, vap);
- error = 0;
- goto nfsmout;
- } else {
- nfsm_build(fp, struct nfs_fattr *, NFSX_V2FATTR);
- nfsm_srvfillattr(vap, fp);
- }
- /* fall through */
-
-nfsmout:
- if (vp)
- vput(vp);
- return(error);
-}
-
-/*
- * nfs lookup rpc
- */
-int
-nfsrv_lookup(nfsd, slp, procp, mrq)
- struct nfsrv_descript *nfsd;
- struct nfssvc_sock *slp;
- struct proc *procp;
- struct mbuf **mrq;
-{
- struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md;
- struct sockaddr *nam = nfsd->nd_nam;
- caddr_t dpos = nfsd->nd_dpos;
- struct ucred *cred = &nfsd->nd_cr;
- register struct nfs_fattr *fp;
- struct nameidata nd, ind, *ndp = &nd;
- struct vnode *vp, *dirp = NULL;
- nfsfh_t nfh;
- fhandle_t *fhp;
- register caddr_t cp;
- register u_int32_t *tl;
- register int32_t t1;
- caddr_t bpos;
- int error = 0, cache, len, dirattr_ret = 1;
- int v3 = (nfsd->nd_flag & ND_NFSV3), pubflag;
- char *cp2;
- struct mbuf *mb, *mb2, *mreq;
- struct vattr va, dirattr, *vap = &va;
- u_quad_t frev;
-
- nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
- ndclear(&nd);
-
- fhp = &nfh.fh_generic;
- nfsm_srvmtofh(fhp);
- nfsm_srvnamesiz(len);
-
- pubflag = nfs_ispublicfh(fhp);
-
- nd.ni_cnd.cn_cred = cred;
- nd.ni_cnd.cn_nameiop = LOOKUP;
- nd.ni_cnd.cn_flags = LOCKLEAF | SAVESTART;
- error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos,
- &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), pubflag);
-
- /*
- * namei failure, only dirp to cleanup. Clear out garbarge from
- * structure in case macros jump to nfsmout.
- */
-
- if (error) {
- if (dirp) {
- if (v3)
- dirattr_ret = VOP_GETATTR(dirp, &dirattr, cred,
- procp);
- vrele(dirp);
- dirp = NULL;
- }
- nfsm_reply(NFSX_POSTOPATTR(v3));
- nfsm_srvpostop_attr(dirattr_ret, &dirattr);
- error = 0;
- goto nfsmout;
- }
-
- /*
- * Locate index file for public filehandle
- *
- * error is 0 on entry and 0 on exit from this block.
- */
-
- if (pubflag) {
- if (nd.ni_vp->v_type == VDIR && nfs_pub.np_index != NULL) {
- /*
- * Setup call to lookup() to see if we can find
- * the index file. Arguably, this doesn't belong
- * in a kernel.. Ugh. If an error occurs, do not
- * try to install an index file and then clear the
- * error.
- *
- * When we replace nd with ind and redirect ndp,
- * maintenance of ni_startdir and ni_vp shift to
- * ind and we have to clean them up in the old nd.
- * However, the cnd resource continues to be maintained
- * via the original nd. Confused? You aren't alone!
- */
- ind = nd;
- VOP_UNLOCK(nd.ni_vp, 0, procp);
- ind.ni_pathlen = strlen(nfs_pub.np_index);
- ind.ni_cnd.cn_nameptr = ind.ni_cnd.cn_pnbuf =
- nfs_pub.np_index;
- ind.ni_startdir = nd.ni_vp;
- VREF(ind.ni_startdir);
-
- error = lookup(&ind);
- ind.ni_dvp = NULL;
-
- if (error == 0) {
- /*
- * Found an index file. Get rid of
- * the old references. transfer nd.ni_vp'
- */
- if (dirp)
- vrele(dirp);
- dirp = nd.ni_vp;
- nd.ni_vp = NULL;
- vrele(nd.ni_startdir);
- nd.ni_startdir = NULL;
- ndp = &ind;
- }
- error = 0;
- }
- /*
- * If the public filehandle was used, check that this lookup
- * didn't result in a filehandle outside the publicly exported
- * filesystem. We clear the poor vp here to avoid lockups due
- * to NFS I/O.
- */
-
- if (ndp->ni_vp->v_mount != nfs_pub.np_mount) {
- vput(nd.ni_vp);
- nd.ni_vp = NULL;
- error = EPERM;
- }
- }
-
- if (dirp) {
- if (v3)
- dirattr_ret = VOP_GETATTR(dirp, &dirattr, cred,
- procp);
- vrele(dirp);
- dirp = NULL;
- }
-
- /*
- * Resources at this point:
- * ndp->ni_vp may not be NULL
- *
- */
-
- if (error) {
- nfsm_reply(NFSX_POSTOPATTR(v3));
- nfsm_srvpostop_attr(dirattr_ret, &dirattr);
- error = 0;
- goto nfsmout;
- }
-
- nqsrv_getl(ndp->ni_startdir, ND_READ);
-
- /*
- * Clear out some resources prior to potentially blocking. This
- * is not as critical as ni_dvp resources in other routines, but
- * it helps.
- */
- vrele(ndp->ni_startdir);
- ndp->ni_startdir = NULL;
- NDFREE(&nd, NDF_ONLY_PNBUF);
-
- /*
- * Get underlying attribute, then release remaining resources ( for
- * the same potential blocking reason ) and reply.
- */
- vp = ndp->ni_vp;
- bzero((caddr_t)fhp, sizeof(nfh));
- fhp->fh_fsid = vp->v_mount->mnt_stat.f_fsid;
- error = VFS_VPTOFH(vp, &fhp->fh_fid);
- if (!error)
- error = VOP_GETATTR(vp, vap, cred, procp);
-
- vput(vp);
- ndp->ni_vp = NULL;
- nfsm_reply(NFSX_SRVFH(v3) + NFSX_POSTOPORFATTR(v3) + NFSX_POSTOPATTR(v3));
- if (error) {
- nfsm_srvpostop_attr(dirattr_ret, &dirattr);
- error = 0;
- goto nfsmout;
- }
- nfsm_srvfhtom(fhp, v3);
- if (v3) {
- nfsm_srvpostop_attr(0, vap);
- nfsm_srvpostop_attr(dirattr_ret, &dirattr);
- } else {
- nfsm_build(fp, struct nfs_fattr *, NFSX_V2FATTR);
- nfsm_srvfillattr(vap, fp);
- }
-
-nfsmout:
- if (dirp)
- vrele(dirp);
- NDFREE(&nd, NDF_ONLY_PNBUF);
- if (ndp->ni_startdir)
- vrele(ndp->ni_startdir);
- if (ndp->ni_vp)
- vput(ndp->ni_vp);
- return (error);
-}
-
-/*
- * nfs readlink service
- */
-int
-nfsrv_readlink(nfsd, slp, procp, mrq)
- struct nfsrv_descript *nfsd;
- struct nfssvc_sock *slp;
- struct proc *procp;
- struct mbuf **mrq;
-{
- struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md;
- struct sockaddr *nam = nfsd->nd_nam;
- caddr_t dpos = nfsd->nd_dpos;
- struct ucred *cred = &nfsd->nd_cr;
- struct iovec iv[(NFS_MAXPATHLEN+MLEN-1)/MLEN];
- register struct iovec *ivp = iv;
- register struct mbuf *mp;
- register u_int32_t *tl;
- register int32_t t1;
- caddr_t bpos;
- int error = 0, rdonly, cache, i, tlen, len, getret;
- int v3 = (nfsd->nd_flag & ND_NFSV3);
- char *cp2;
- struct mbuf *mb, *mb2, *mp2, *mp3, *mreq;
- struct vnode *vp = NULL;
- struct vattr attr;
- nfsfh_t nfh;
- fhandle_t *fhp;
- struct uio io, *uiop = &io;
- u_quad_t frev;
-
- nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
-#ifndef nolint
- mp2 = (struct mbuf *)0;
-#endif
- mp3 = NULL;
- fhp = &nfh.fh_generic;
- nfsm_srvmtofh(fhp);
- len = 0;
- i = 0;
- while (len < NFS_MAXPATHLEN) {
- MGET(mp, M_WAIT, MT_DATA);
- MCLGET(mp, M_WAIT);
- mp->m_len = NFSMSIZ(mp);
- if (len == 0)
- mp3 = mp2 = mp;
- else {
- mp2->m_next = mp;
- mp2 = mp;
- }
- if ((len+mp->m_len) > NFS_MAXPATHLEN) {
- mp->m_len = NFS_MAXPATHLEN-len;
- len = NFS_MAXPATHLEN;
- } else
- len += mp->m_len;
- ivp->iov_base = mtod(mp, caddr_t);
- ivp->iov_len = mp->m_len;
- i++;
- ivp++;
- }
- uiop->uio_iov = iv;
- uiop->uio_iovcnt = i;
- uiop->uio_offset = 0;
- uiop->uio_resid = len;
- uiop->uio_rw = UIO_READ;
- uiop->uio_segflg = UIO_SYSSPACE;
- uiop->uio_procp = (struct proc *)0;
- error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam,
- &rdonly, (nfsd->nd_flag & ND_KERBAUTH), TRUE);
- if (error) {
- nfsm_reply(2 * NFSX_UNSIGNED);
- nfsm_srvpostop_attr(1, (struct vattr *)0);
- error = 0;
- goto nfsmout;
- }
- if (vp->v_type != VLNK) {
- if (v3)
- error = EINVAL;
- else
- error = ENXIO;
- goto out;
- }
- nqsrv_getl(vp, ND_READ);
- error = VOP_READLINK(vp, uiop, cred);
-out:
- getret = VOP_GETATTR(vp, &attr, cred, procp);
- vput(vp);
- vp = NULL;
- nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_UNSIGNED);
- if (v3) {
- nfsm_srvpostop_attr(getret, &attr);
- if (error) {
- error = 0;
- goto nfsmout;
- }
- }
- if (uiop->uio_resid > 0) {
- len -= uiop->uio_resid;
- tlen = nfsm_rndup(len);
- nfsm_adj(mp3, NFS_MAXPATHLEN-tlen, tlen-len);
- }
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);
- *tl = txdr_unsigned(len);
- mb->m_next = mp3;
- mp3 = NULL;
-nfsmout:
- if (mp3)
- m_freem(mp3);
- if (vp)
- vput(vp);
- return(error);
-}
-
-/*
- * nfs read service
- */
-int
-nfsrv_read(nfsd, slp, procp, mrq)
- struct nfsrv_descript *nfsd;
- struct nfssvc_sock *slp;
- struct proc *procp;
- struct mbuf **mrq;
-{
- struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md;
- struct sockaddr *nam = nfsd->nd_nam;
- caddr_t dpos = nfsd->nd_dpos;
- struct ucred *cred = &nfsd->nd_cr;
- register struct iovec *iv;
- struct iovec *iv2;
- register struct mbuf *m;
- register struct nfs_fattr *fp;
- register u_int32_t *tl;
- register int32_t t1;
- register int i;
- caddr_t bpos;
- int error = 0, rdonly, cache, cnt, len, left, siz, tlen, getret;
- int v3 = (nfsd->nd_flag & ND_NFSV3), reqlen;
- char *cp2;
- struct mbuf *mb, *mb2, *mreq;
- struct mbuf *m2;
- struct vnode *vp = NULL;
- nfsfh_t nfh;
- fhandle_t *fhp;
- struct uio io, *uiop = &io;
- struct vattr va, *vap = &va;
- struct nfsheur *nh;
- off_t off;
- int ioflag = 0;
- u_quad_t frev;
-
- nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
- fhp = &nfh.fh_generic;
- nfsm_srvmtofh(fhp);
- if (v3) {
- nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
- off = fxdr_hyper(tl);
- } else {
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED);
- off = (off_t)fxdr_unsigned(u_int32_t, *tl);
- }
- nfsm_srvstrsiz(reqlen, NFS_SRVMAXDATA(nfsd));
-
- /*
- * Reference vp. If an error occurs, vp will be invalid, but we
- * have to NULL it just in case. The macros might goto nfsmout
- * as well.
- */
-
- error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam,
- &rdonly, (nfsd->nd_flag & ND_KERBAUTH), TRUE);
- if (error) {
- vp = NULL;
- nfsm_reply(2 * NFSX_UNSIGNED);
- nfsm_srvpostop_attr(1, (struct vattr *)0);
- error = 0;
- goto nfsmout;
- }
-
- if (vp->v_type != VREG) {
- if (v3)
- error = EINVAL;
- else
- error = (vp->v_type == VDIR) ? EISDIR : EACCES;
- }
- if (!error) {
- nqsrv_getl(vp, ND_READ);
- if ((error = nfsrv_access(vp, VREAD, cred, rdonly, procp, 1)) != 0)
- error = nfsrv_access(vp, VEXEC, cred, rdonly, procp, 1);
- }
- getret = VOP_GETATTR(vp, vap, cred, procp);
- if (!error)
- error = getret;
- if (error) {
- vput(vp);
- vp = NULL;
- nfsm_reply(NFSX_POSTOPATTR(v3));
- nfsm_srvpostop_attr(getret, vap);
- error = 0;
- goto nfsmout;
- }
-
- /*
- * Calculate byte count to read
- */
-
- if (off >= vap->va_size)
- cnt = 0;
- else if ((off + reqlen) > vap->va_size)
- cnt = vap->va_size - off;
- else
- cnt = reqlen;
-
- /*
- * Calculate seqcount for heuristic
- */
-
- {
- int hi;
- int try = 4;
-
- /*
- * Locate best candidate
- */
-
- hi = ((int)(vm_offset_t)vp / sizeof(struct vnode)) & (NUM_HEURISTIC - 1);
- nh = &nfsheur[hi];
-
- while (try--) {
- if (nfsheur[hi].nh_vp == vp) {
- nh = &nfsheur[hi];
- break;
- }
- if (nfsheur[hi].nh_use > 0)
- --nfsheur[hi].nh_use;
- hi = (hi + 1) & (NUM_HEURISTIC - 1);
- if (nfsheur[hi].nh_use < nh->nh_use)
- nh = &nfsheur[hi];
- }
-
- if (nh->nh_vp != vp) {
- nh->nh_vp = vp;
- nh->nh_nextr = off;
- nh->nh_use = NHUSE_INIT;
- if (off == 0)
- nh->nh_seqcount = 4;
- else
- nh->nh_seqcount = 1;
- }
-
- /*
- * Calculate heuristic
- */
-
- if ((off == 0 && nh->nh_seqcount > 0) || off == nh->nh_nextr) {
- if (++nh->nh_seqcount > 127)
- nh->nh_seqcount = 127;
- } else if (nh->nh_seqcount > 1) {
- nh->nh_seqcount = 1;
- } else {
- nh->nh_seqcount = 0;
- }
- nh->nh_use += NHUSE_INC;
- if (nh->nh_use > NHUSE_MAX)
- nh->nh_use = NHUSE_MAX;
- ioflag |= nh->nh_seqcount << 16;
- }
-
- nfsm_reply(NFSX_POSTOPORFATTR(v3) + 3 * NFSX_UNSIGNED+nfsm_rndup(cnt));
- if (v3) {
- nfsm_build(tl, u_int32_t *, NFSX_V3FATTR + 4 * NFSX_UNSIGNED);
- *tl++ = nfs_true;
- fp = (struct nfs_fattr *)tl;
- tl += (NFSX_V3FATTR / sizeof (u_int32_t));
- } else {
- nfsm_build(tl, u_int32_t *, NFSX_V2FATTR + NFSX_UNSIGNED);
- fp = (struct nfs_fattr *)tl;
- tl += (NFSX_V2FATTR / sizeof (u_int32_t));
- }
- len = left = nfsm_rndup(cnt);
- if (cnt > 0) {
- /*
- * Generate the mbuf list with the uio_iov ref. to it.
- */
- i = 0;
- m = m2 = mb;
- while (left > 0) {
- siz = min(M_TRAILINGSPACE(m), left);
- if (siz > 0) {
- left -= siz;
- i++;
- }
- if (left > 0) {
- MGET(m, M_WAIT, MT_DATA);
- MCLGET(m, M_WAIT);
- m->m_len = 0;
- m2->m_next = m;
- m2 = m;
- }
- }
- MALLOC(iv, struct iovec *, i * sizeof (struct iovec),
- M_TEMP, M_WAITOK);
- uiop->uio_iov = iv2 = iv;
- m = mb;
- left = len;
- i = 0;
- while (left > 0) {
- if (m == NULL)
- panic("nfsrv_read iov");
- siz = min(M_TRAILINGSPACE(m), left);
- if (siz > 0) {
- iv->iov_base = mtod(m, caddr_t) + m->m_len;
- iv->iov_len = siz;
- m->m_len += siz;
- left -= siz;
- iv++;
- i++;
- }
- m = m->m_next;
- }
- uiop->uio_iovcnt = i;
- uiop->uio_offset = off;
- uiop->uio_resid = len;
- uiop->uio_rw = UIO_READ;
- uiop->uio_segflg = UIO_SYSSPACE;
- error = VOP_READ(vp, uiop, IO_NODELOCKED | ioflag, cred);
- off = uiop->uio_offset;
- nh->nh_nextr = off;
- FREE((caddr_t)iv2, M_TEMP);
- if (error || (getret = VOP_GETATTR(vp, vap, cred, procp))) {
- if (!error)
- error = getret;
- m_freem(mreq);
- vput(vp);
- vp = NULL;
- nfsm_reply(NFSX_POSTOPATTR(v3));
- nfsm_srvpostop_attr(getret, vap);
- error = 0;
- goto nfsmout;
- }
- } else {
- uiop->uio_resid = 0;
- }
- vput(vp);
- vp = NULL;
- nfsm_srvfillattr(vap, fp);
- tlen = len - uiop->uio_resid;
- cnt = cnt < tlen ? cnt : tlen;
- tlen = nfsm_rndup(cnt);
- if (len != tlen || tlen != cnt)
- nfsm_adj(mb, len - tlen, tlen - cnt);
- if (v3) {
- *tl++ = txdr_unsigned(cnt);
- if (len < reqlen)
- *tl++ = nfs_true;
- else
- *tl++ = nfs_false;
- }
- *tl = txdr_unsigned(cnt);
-nfsmout:
- if (vp)
- vput(vp);
- return(error);
-}
-
-/*
- * nfs write service
- */
-int
-nfsrv_write(nfsd, slp, procp, mrq)
- struct nfsrv_descript *nfsd;
- struct nfssvc_sock *slp;
- struct proc *procp;
- struct mbuf **mrq;
-{
- struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md;
- struct sockaddr *nam = nfsd->nd_nam;
- caddr_t dpos = nfsd->nd_dpos;
- struct ucred *cred = &nfsd->nd_cr;
- register struct iovec *ivp;
- register int i, cnt;
- register struct mbuf *mp;
- register struct nfs_fattr *fp;
- struct iovec *iv;
- struct vattr va, forat;
- register struct vattr *vap = &va;
- register u_int32_t *tl;
- register int32_t t1;
- caddr_t bpos;
- int error = 0, rdonly, cache, len, forat_ret = 1;
- int ioflags, aftat_ret = 1, retlen, zeroing, adjust;
- int stable = NFSV3WRITE_FILESYNC;
- int v3 = (nfsd->nd_flag & ND_NFSV3);
- char *cp2;
- struct mbuf *mb, *mb2, *mreq;
- struct vnode *vp = NULL;
- nfsfh_t nfh;
- fhandle_t *fhp;
- struct uio io, *uiop = &io;
- off_t off;
- u_quad_t frev;
-
- nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
- if (mrep == NULL) {
- *mrq = NULL;
- error = 0;
- goto nfsmout;
- }
- fhp = &nfh.fh_generic;
- nfsm_srvmtofh(fhp);
- if (v3) {
- nfsm_dissect(tl, u_int32_t *, 5 * NFSX_UNSIGNED);
- off = fxdr_hyper(tl);
- tl += 3;
- stable = fxdr_unsigned(int, *tl++);
- } else {
- nfsm_dissect(tl, u_int32_t *, 4 * NFSX_UNSIGNED);
- off = (off_t)fxdr_unsigned(u_int32_t, *++tl);
- tl += 2;
- if (nfs_async)
- stable = NFSV3WRITE_UNSTABLE;
- }
- retlen = len = fxdr_unsigned(int32_t, *tl);
- cnt = i = 0;
-
- /*
- * For NFS Version 2, it is not obvious what a write of zero length
- * should do, but I might as well be consistent with Version 3,
- * which is to return ok so long as there are no permission problems.
- */
- if (len > 0) {
- zeroing = 1;
- mp = mrep;
- while (mp) {
- if (mp == md) {
- zeroing = 0;
- adjust = dpos - mtod(mp, caddr_t);
- mp->m_len -= adjust;
- if (mp->m_len > 0 && adjust > 0)
- NFSMADV(mp, adjust);
- }
- if (zeroing)
- mp->m_len = 0;
- else if (mp->m_len > 0) {
- i += mp->m_len;
- if (i > len) {
- mp->m_len -= (i - len);
- zeroing = 1;
- }
- if (mp->m_len > 0)
- cnt++;
- }
- mp = mp->m_next;
- }
- }
- if (len > NFS_MAXDATA || len < 0 || i < len) {
- error = EIO;
- nfsm_reply(2 * NFSX_UNSIGNED);
- nfsm_srvwcc_data(forat_ret, &forat, aftat_ret, vap);
- error = 0;
- goto nfsmout;
- }
- error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam,
- &rdonly, (nfsd->nd_flag & ND_KERBAUTH), TRUE);
- if (error) {
- vp = NULL;
- nfsm_reply(2 * NFSX_UNSIGNED);
- nfsm_srvwcc_data(forat_ret, &forat, aftat_ret, vap);
- error = 0;
- goto nfsmout;
- }
- if (v3)
- forat_ret = VOP_GETATTR(vp, &forat, cred, procp);
- if (vp->v_type != VREG) {
- if (v3)
- error = EINVAL;
- else
- error = (vp->v_type == VDIR) ? EISDIR : EACCES;
- }
- if (!error) {
- nqsrv_getl(vp, ND_WRITE);
- error = nfsrv_access(vp, VWRITE, cred, rdonly, procp, 1);
- }
- if (error) {
- vput(vp);
- vp = NULL;
- nfsm_reply(NFSX_WCCDATA(v3));
- nfsm_srvwcc_data(forat_ret, &forat, aftat_ret, vap);
- error = 0;
- goto nfsmout;
- }
-
- if (len > 0) {
- MALLOC(ivp, struct iovec *, cnt * sizeof (struct iovec), M_TEMP,
- M_WAITOK);
- uiop->uio_iov = iv = ivp;
- uiop->uio_iovcnt = cnt;
- mp = mrep;
- while (mp) {
- if (mp->m_len > 0) {
- ivp->iov_base = mtod(mp, caddr_t);
- ivp->iov_len = mp->m_len;
- ivp++;
- }
- mp = mp->m_next;
- }
-
- /*
- * XXX
- * The IO_METASYNC flag indicates that all metadata (and not just
- * enough to ensure data integrity) mus be written to stable storage
- * synchronously.
- * (IO_METASYNC is not yet implemented in 4.4BSD-Lite.)
- */
- if (stable == NFSV3WRITE_UNSTABLE)
- ioflags = IO_NODELOCKED;
- else if (stable == NFSV3WRITE_DATASYNC)
- ioflags = (IO_SYNC | IO_NODELOCKED);
- else
- ioflags = (IO_METASYNC | IO_SYNC | IO_NODELOCKED);
- uiop->uio_resid = len;
- uiop->uio_rw = UIO_WRITE;
- uiop->uio_segflg = UIO_SYSSPACE;
- uiop->uio_procp = (struct proc *)0;
- uiop->uio_offset = off;
- error = VOP_WRITE(vp, uiop, ioflags, cred);
- nfsstats.srvvop_writes++;
- FREE((caddr_t)iv, M_TEMP);
- }
- aftat_ret = VOP_GETATTR(vp, vap, cred, procp);
- vput(vp);
- vp = NULL;
- if (!error)
- error = aftat_ret;
- nfsm_reply(NFSX_PREOPATTR(v3) + NFSX_POSTOPORFATTR(v3) +
- 2 * NFSX_UNSIGNED + NFSX_WRITEVERF(v3));
- if (v3) {
- nfsm_srvwcc_data(forat_ret, &forat, aftat_ret, vap);
- if (error) {
- error = 0;
- goto nfsmout;
- }
- nfsm_build(tl, u_int32_t *, 4 * NFSX_UNSIGNED);
- *tl++ = txdr_unsigned(retlen);
- /*
- * If nfs_async is set, then pretend the write was FILESYNC.
- */
- if (stable == NFSV3WRITE_UNSTABLE && !nfs_async)
- *tl++ = txdr_unsigned(stable);
- else
- *tl++ = txdr_unsigned(NFSV3WRITE_FILESYNC);
- /*
- * Actually, there is no need to txdr these fields,
- * but it may make the values more human readable,
- * for debugging purposes.
- */
- if (nfsver.tv_sec == 0)
- nfsver = boottime;
- *tl++ = txdr_unsigned(nfsver.tv_sec);
- *tl = txdr_unsigned(nfsver.tv_usec);
- } else {
- nfsm_build(fp, struct nfs_fattr *, NFSX_V2FATTR);
- nfsm_srvfillattr(vap, fp);
- }
-nfsmout:
- if (vp)
- vput(vp);
- return(error);
-}
-
-/*
- * NFS write service with write gathering support. Called when
- * nfsrvw_procrastinate > 0.
- * See: Chet Juszczak, "Improving the Write Performance of an NFS Server",
- * in Proc. of the Winter 1994 Usenix Conference, pg. 247-259, San Franscisco,
- * Jan. 1994.
- */
-int
-nfsrv_writegather(ndp, slp, procp, mrq)
- struct nfsrv_descript **ndp;
- struct nfssvc_sock *slp;
- struct proc *procp;
- struct mbuf **mrq;
-{
- register struct iovec *ivp;
- register struct mbuf *mp;
- register struct nfsrv_descript *wp, *nfsd, *owp, *swp;
- register struct nfs_fattr *fp;
- register int i;
- struct iovec *iov;
- struct nfsrvw_delayhash *wpp;
- struct ucred *cred;
- struct vattr va, forat;
- register u_int32_t *tl;
- register int32_t t1;
- caddr_t bpos, dpos;
- int error = 0, rdonly, cache, len, forat_ret = 1;
- int ioflags, aftat_ret = 1, s, adjust, v3, zeroing;
- char *cp2;
- struct mbuf *mb, *mb2, *mreq, *mrep, *md;
- struct vnode *vp = NULL;
- struct uio io, *uiop = &io;
- u_quad_t frev, cur_usec;
-
- nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
-#ifndef nolint
- i = 0;
- len = 0;
-#endif
- *mrq = NULL;
- if (*ndp) {
- nfsd = *ndp;
- *ndp = NULL;
- mrep = nfsd->nd_mrep;
- md = nfsd->nd_md;
- dpos = nfsd->nd_dpos;
- cred = &nfsd->nd_cr;
- v3 = (nfsd->nd_flag & ND_NFSV3);
- LIST_INIT(&nfsd->nd_coalesce);
- nfsd->nd_mreq = NULL;
- nfsd->nd_stable = NFSV3WRITE_FILESYNC;
- cur_usec = nfs_curusec();
- nfsd->nd_time = cur_usec +
- (v3 ? nfsrvw_procrastinate_v3 : nfsrvw_procrastinate);
-
- /*
- * Now, get the write header..
- */
- nfsm_srvmtofh(&nfsd->nd_fh);
- if (v3) {
- nfsm_dissect(tl, u_int32_t *, 5 * NFSX_UNSIGNED);
- nfsd->nd_off = fxdr_hyper(tl);
- tl += 3;
- nfsd->nd_stable = fxdr_unsigned(int, *tl++);
- } else {
- nfsm_dissect(tl, u_int32_t *, 4 * NFSX_UNSIGNED);
- nfsd->nd_off = (off_t)fxdr_unsigned(u_int32_t, *++tl);
- tl += 2;
- if (nfs_async)
- nfsd->nd_stable = NFSV3WRITE_UNSTABLE;
- }
- len = fxdr_unsigned(int32_t, *tl);
- nfsd->nd_len = len;
- nfsd->nd_eoff = nfsd->nd_off + len;
-
- /*
- * Trim the header out of the mbuf list and trim off any trailing
- * junk so that the mbuf list has only the write data.
- */
- zeroing = 1;
- i = 0;
- mp = mrep;
- while (mp) {
- if (mp == md) {
- zeroing = 0;
- adjust = dpos - mtod(mp, caddr_t);
- mp->m_len -= adjust;
- if (mp->m_len > 0 && adjust > 0)
- NFSMADV(mp, adjust);
- }
- if (zeroing)
- mp->m_len = 0;
- else {
- i += mp->m_len;
- if (i > len) {
- mp->m_len -= (i - len);
- zeroing = 1;
- }
- }
- mp = mp->m_next;
- }
- if (len > NFS_MAXDATA || len < 0 || i < len) {
-nfsmout:
- m_freem(mrep);
- error = EIO;
- nfsm_writereply(2 * NFSX_UNSIGNED, v3);
- if (v3)
- nfsm_srvwcc_data(forat_ret, &forat, aftat_ret, &va);
- nfsd->nd_mreq = mreq;
- nfsd->nd_mrep = NULL;
- nfsd->nd_time = 0;
- }
-
- /*
- * Add this entry to the hash and time queues.
- */
- s = splsoftclock();
- owp = NULL;
- wp = slp->ns_tq.lh_first;
- while (wp && wp->nd_time < nfsd->nd_time) {
- owp = wp;
- wp = wp->nd_tq.le_next;
- }
- NFS_DPF(WG, ("Q%03x", nfsd->nd_retxid & 0xfff));
- if (owp) {
- LIST_INSERT_AFTER(owp, nfsd, nd_tq);
- } else {
- LIST_INSERT_HEAD(&slp->ns_tq, nfsd, nd_tq);
- }
- if (nfsd->nd_mrep) {
- wpp = NWDELAYHASH(slp, nfsd->nd_fh.fh_fid.fid_data);
- owp = NULL;
- wp = wpp->lh_first;
- while (wp &&
- bcmp((caddr_t)&nfsd->nd_fh,(caddr_t)&wp->nd_fh,NFSX_V3FH)) {
- owp = wp;
- wp = wp->nd_hash.le_next;
- }
- while (wp && wp->nd_off < nfsd->nd_off &&
- !bcmp((caddr_t)&nfsd->nd_fh,(caddr_t)&wp->nd_fh,NFSX_V3FH)) {
- owp = wp;
- wp = wp->nd_hash.le_next;
- }
- if (owp) {
- LIST_INSERT_AFTER(owp, nfsd, nd_hash);
-
- /*
- * Search the hash list for overlapping entries and
- * coalesce.
- */
- for(; nfsd && NFSW_CONTIG(owp, nfsd); nfsd = wp) {
- wp = nfsd->nd_hash.le_next;
- if (NFSW_SAMECRED(owp, nfsd))
- nfsrvw_coalesce(owp, nfsd);
- }
- } else {
- LIST_INSERT_HEAD(wpp, nfsd, nd_hash);
- }
- }
- splx(s);
- }
-
- /*
- * Now, do VOP_WRITE()s for any one(s) that need to be done now
- * and generate the associated reply mbuf list(s).
- */
-loop1:
- cur_usec = nfs_curusec();
- s = splsoftclock();
- for (nfsd = slp->ns_tq.lh_first; nfsd; nfsd = owp) {
- owp = nfsd->nd_tq.le_next;
- if (nfsd->nd_time > cur_usec)
- break;
- if (nfsd->nd_mreq)
- continue;
- NFS_DPF(WG, ("P%03x", nfsd->nd_retxid & 0xfff));
- LIST_REMOVE(nfsd, nd_tq);
- LIST_REMOVE(nfsd, nd_hash);
- splx(s);
- mrep = nfsd->nd_mrep;
- nfsd->nd_mrep = NULL;
- cred = &nfsd->nd_cr;
- v3 = (nfsd->nd_flag & ND_NFSV3);
- forat_ret = aftat_ret = 1;
- error = nfsrv_fhtovp(&nfsd->nd_fh, 1, &vp, cred, slp,
- nfsd->nd_nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH), TRUE);
- if (!error) {
- if (v3)
- forat_ret = VOP_GETATTR(vp, &forat, cred, procp);
- if (vp->v_type != VREG) {
- if (v3)
- error = EINVAL;
- else
- error = (vp->v_type == VDIR) ? EISDIR : EACCES;
- }
- } else {
- vp = NULL;
- }
- if (!error) {
- nqsrv_getl(vp, ND_WRITE);
- error = nfsrv_access(vp, VWRITE, cred, rdonly, procp, 1);
- }
-
- if (nfsd->nd_stable == NFSV3WRITE_UNSTABLE)
- ioflags = IO_NODELOCKED;
- else if (nfsd->nd_stable == NFSV3WRITE_DATASYNC)
- ioflags = (IO_SYNC | IO_NODELOCKED);
- else
- ioflags = (IO_METASYNC | IO_SYNC | IO_NODELOCKED);
- uiop->uio_rw = UIO_WRITE;
- uiop->uio_segflg = UIO_SYSSPACE;
- uiop->uio_procp = (struct proc *)0;
- uiop->uio_offset = nfsd->nd_off;
- uiop->uio_resid = nfsd->nd_eoff - nfsd->nd_off;
- if (uiop->uio_resid > 0) {
- mp = mrep;
- i = 0;
- while (mp) {
- if (mp->m_len > 0)
- i++;
- mp = mp->m_next;
- }
- uiop->uio_iovcnt = i;
- MALLOC(iov, struct iovec *, i * sizeof (struct iovec),
- M_TEMP, M_WAITOK);
- uiop->uio_iov = ivp = iov;
- mp = mrep;
- while (mp) {
- if (mp->m_len > 0) {
- ivp->iov_base = mtod(mp, caddr_t);
- ivp->iov_len = mp->m_len;
- ivp++;
- }
- mp = mp->m_next;
- }
- if (!error) {
- error = VOP_WRITE(vp, uiop, ioflags, cred);
- nfsstats.srvvop_writes++;
- }
- FREE((caddr_t)iov, M_TEMP);
- }
- m_freem(mrep);
- if (vp) {
- aftat_ret = VOP_GETATTR(vp, &va, cred, procp);
- vput(vp);
- vp = NULL;
- }
-
- /*
- * Loop around generating replies for all write rpcs that have
- * now been completed.
- */
- swp = nfsd;
- do {
- NFS_DPF(WG, ("R%03x", nfsd->nd_retxid & 0xfff));
- if (error) {
- nfsm_writereply(NFSX_WCCDATA(v3), v3);
- if (v3) {
- nfsm_srvwcc_data(forat_ret, &forat, aftat_ret, &va);
- }
- } else {
- nfsm_writereply(NFSX_PREOPATTR(v3) +
- NFSX_POSTOPORFATTR(v3) + 2 * NFSX_UNSIGNED +
- NFSX_WRITEVERF(v3), v3);
- if (v3) {
- nfsm_srvwcc_data(forat_ret, &forat, aftat_ret, &va);
- nfsm_build(tl, u_int32_t *, 4 * NFSX_UNSIGNED);
- *tl++ = txdr_unsigned(nfsd->nd_len);
- *tl++ = txdr_unsigned(swp->nd_stable);
- /*
- * Actually, there is no need to txdr these fields,
- * but it may make the values more human readable,
- * for debugging purposes.
- */
- if (nfsver.tv_sec == 0)
- nfsver = boottime;
- *tl++ = txdr_unsigned(nfsver.tv_sec);
- *tl = txdr_unsigned(nfsver.tv_usec);
- } else {
- nfsm_build(fp, struct nfs_fattr *, NFSX_V2FATTR);
- nfsm_srvfillattr(&va, fp);
- }
- }
- nfsd->nd_mreq = mreq;
- if (nfsd->nd_mrep)
- panic("nfsrv_write: nd_mrep not free");
-
- /*
- * Done. Put it at the head of the timer queue so that
- * the final phase can return the reply.
- */
- s = splsoftclock();
- if (nfsd != swp) {
- nfsd->nd_time = 0;
- LIST_INSERT_HEAD(&slp->ns_tq, nfsd, nd_tq);
- }
- nfsd = swp->nd_coalesce.lh_first;
- if (nfsd) {
- LIST_REMOVE(nfsd, nd_tq);
- }
- splx(s);
- } while (nfsd);
- s = splsoftclock();
- swp->nd_time = 0;
- LIST_INSERT_HEAD(&slp->ns_tq, swp, nd_tq);
- splx(s);
- goto loop1;
- }
- splx(s);
-
- /*
- * Search for a reply to return.
- */
- s = splsoftclock();
- for (nfsd = slp->ns_tq.lh_first; nfsd; nfsd = nfsd->nd_tq.le_next)
- if (nfsd->nd_mreq) {
- NFS_DPF(WG, ("X%03x", nfsd->nd_retxid & 0xfff));
- LIST_REMOVE(nfsd, nd_tq);
- *mrq = nfsd->nd_mreq;
- *ndp = nfsd;
- break;
- }
- splx(s);
- return (0);
-}
-
-/*
- * Coalesce the write request nfsd into owp. To do this we must:
- * - remove nfsd from the queues
- * - merge nfsd->nd_mrep into owp->nd_mrep
- * - update the nd_eoff and nd_stable for owp
- * - put nfsd on owp's nd_coalesce list
- * NB: Must be called at splsoftclock().
- */
-static void
-nfsrvw_coalesce(owp, nfsd)
- register struct nfsrv_descript *owp;
- register struct nfsrv_descript *nfsd;
-{
- register int overlap;
- register struct mbuf *mp;
- struct nfsrv_descript *p;
-
- NFS_DPF(WG, ("C%03x-%03x",
- nfsd->nd_retxid & 0xfff, owp->nd_retxid & 0xfff));
- LIST_REMOVE(nfsd, nd_hash);
- LIST_REMOVE(nfsd, nd_tq);
- if (owp->nd_eoff < nfsd->nd_eoff) {
- overlap = owp->nd_eoff - nfsd->nd_off;
- if (overlap < 0)
- panic("nfsrv_coalesce: bad off");
- if (overlap > 0)
- m_adj(nfsd->nd_mrep, overlap);
- mp = owp->nd_mrep;
- while (mp->m_next)
- mp = mp->m_next;
- mp->m_next = nfsd->nd_mrep;
- owp->nd_eoff = nfsd->nd_eoff;
- } else
- m_freem(nfsd->nd_mrep);
- nfsd->nd_mrep = NULL;
- if (nfsd->nd_stable == NFSV3WRITE_FILESYNC)
- owp->nd_stable = NFSV3WRITE_FILESYNC;
- else if (nfsd->nd_stable == NFSV3WRITE_DATASYNC &&
- owp->nd_stable == NFSV3WRITE_UNSTABLE)
- owp->nd_stable = NFSV3WRITE_DATASYNC;
- LIST_INSERT_HEAD(&owp->nd_coalesce, nfsd, nd_tq);
-
- /*
- * If nfsd had anything else coalesced into it, transfer them
- * to owp, otherwise their replies will never get sent.
- */
- for (p = nfsd->nd_coalesce.lh_first; p;
- p = nfsd->nd_coalesce.lh_first) {
- LIST_REMOVE(p, nd_tq);
- LIST_INSERT_HEAD(&owp->nd_coalesce, p, nd_tq);
- }
-}
-
-/*
- * nfs create service
- * now does a truncate to 0 length via. setattr if it already exists
- */
-int
-nfsrv_create(nfsd, slp, procp, mrq)
- struct nfsrv_descript *nfsd;
- struct nfssvc_sock *slp;
- struct proc *procp;
- struct mbuf **mrq;
-{
- struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md;
- struct sockaddr *nam = nfsd->nd_nam;
- caddr_t dpos = nfsd->nd_dpos;
- struct ucred *cred = &nfsd->nd_cr;
- register struct nfs_fattr *fp;
- struct vattr va, dirfor, diraft;
- register struct vattr *vap = &va;
- register struct nfsv2_sattr *sp;
- register u_int32_t *tl;
- struct nameidata nd;
- register int32_t t1;
- caddr_t bpos;
- int error = 0, rdev, cache, len, tsize, dirfor_ret = 1, diraft_ret = 1;
- int v3 = (nfsd->nd_flag & ND_NFSV3), how, exclusive_flag = 0;
- caddr_t cp;
- char *cp2;
- struct mbuf *mb, *mb2, *mreq;
- struct vnode *dirp = (struct vnode *)0;
- nfsfh_t nfh;
- fhandle_t *fhp;
- u_quad_t frev, tempsize;
- u_char cverf[NFSX_V3CREATEVERF];
-
- nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
-#ifndef nolint
- rdev = 0;
-#endif
- ndclear(&nd);
-
- fhp = &nfh.fh_generic;
- nfsm_srvmtofh(fhp);
- nfsm_srvnamesiz(len);
-
- nd.ni_cnd.cn_cred = cred;
- nd.ni_cnd.cn_nameiop = CREATE;
- nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | SAVESTART;
-
- /*
- * Call namei and do initial cleanup to get a few things
- * out of the way. If we get an initial error we cleanup
- * and return here to avoid special-casing the invalid nd
- * structure through the rest of the case. dirp may be
- * set even if an error occurs, but the nd structure will not
- * be valid at all if an error occurs so we have to invalidate it
- * prior to calling nfsm_reply ( which might goto nfsmout ).
- */
- error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos,
- &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE);
- if (dirp) {
- if (v3) {
- dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred,
- procp);
- } else {
- vrele(dirp);
- dirp = NULL;
- }
- }
- if (error) {
- nfsm_reply(NFSX_WCCDATA(v3));
- nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft);
- error = 0;
- goto nfsmout;
- }
-
- /*
- * No error. Continue. State:
- *
- * startdir is valid ( we release this immediately )
- * dirp may be valid
- * nd.ni_vp may be valid
- * nd.ni_dvp is valid
- *
- * The error state is set through the code and we may also do some
- * opportunistic releasing of vnodes to avoid holding locks through
- * NFS I/O. The cleanup at the end is a catch-all
- */
-
- VATTR_NULL(vap);
- if (v3) {
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED);
- how = fxdr_unsigned(int, *tl);
- switch (how) {
- case NFSV3CREATE_GUARDED:
- if (nd.ni_vp) {
- error = EEXIST;
- break;
- }
- /* fall through */
- case NFSV3CREATE_UNCHECKED:
- nfsm_srvsattr(vap);
- break;
- case NFSV3CREATE_EXCLUSIVE:
- nfsm_dissect(cp, caddr_t, NFSX_V3CREATEVERF);
- bcopy(cp, cverf, NFSX_V3CREATEVERF);
- exclusive_flag = 1;
- if (nd.ni_vp == NULL)
- vap->va_mode = 0;
- break;
- };
- vap->va_type = VREG;
- } else {
- nfsm_dissect(sp, struct nfsv2_sattr *, NFSX_V2SATTR);
- vap->va_type = IFTOVT(fxdr_unsigned(u_int32_t, sp->sa_mode));
- if (vap->va_type == VNON)
- vap->va_type = VREG;
- vap->va_mode = nfstov_mode(sp->sa_mode);
- switch (vap->va_type) {
- case VREG:
- tsize = fxdr_unsigned(int32_t, sp->sa_size);
- if (tsize != -1)
- vap->va_size = (u_quad_t)tsize;
- break;
- case VCHR:
- case VBLK:
- case VFIFO:
- rdev = fxdr_unsigned(long, sp->sa_size);
- break;
- default:
- break;
- };
- }
-
- /*
- * Iff doesn't exist, create it
- * otherwise just truncate to 0 length
- * should I set the mode too ?
- *
- * The only possible error we can have at this point is EEXIST.
- * nd.ni_vp will also be non-NULL in that case.
- */
- if (nd.ni_vp == NULL) {
- if (vap->va_type == VREG || vap->va_type == VSOCK) {
- nqsrv_getl(nd.ni_dvp, ND_WRITE);
- error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap);
- if (error)
- NDFREE(&nd, NDF_ONLY_PNBUF);
- else {
- nfsrv_object_create(nd.ni_vp);
- if (exclusive_flag) {
- exclusive_flag = 0;
- VATTR_NULL(vap);
- bcopy(cverf, (caddr_t)&vap->va_atime,
- NFSX_V3CREATEVERF);
- error = VOP_SETATTR(nd.ni_vp, vap, cred,
- procp);
- }
- }
- } else if (
- vap->va_type == VCHR ||
- vap->va_type == VBLK ||
- vap->va_type == VFIFO
- ) {
- /*
- * Handle SysV FIFO node special cases. All other
- * devices require super user to access.
- */
- if (vap->va_type == VCHR && rdev == 0xffffffff)
- vap->va_type = VFIFO;
- if (vap->va_type != VFIFO &&
- (error = suser_xxx(cred, 0, 0))) {
- goto nfsmreply0;
- }
- vap->va_rdev = rdev;
- nqsrv_getl(nd.ni_dvp, ND_WRITE);
-
- error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap);
- if (error) {
- NDFREE(&nd, NDF_ONLY_PNBUF);
- goto nfsmreply0;
- }
- vput(nd.ni_vp);
- nd.ni_vp = NULL;
-
- /*
- * release dvp prior to lookup
- */
- vput(nd.ni_dvp);
- nd.ni_dvp = NULL;
-
- /*
- * Setup for lookup.
- *
- * Even though LOCKPARENT was cleared, ni_dvp may
- * be garbage.
- */
- nd.ni_cnd.cn_nameiop = LOOKUP;
- nd.ni_cnd.cn_flags &= ~(LOCKPARENT);
- nd.ni_cnd.cn_proc = procp;
- nd.ni_cnd.cn_cred = cred;
-
- error = lookup(&nd);
- nd.ni_dvp = NULL;
-
- if (error != 0) {
- nfsm_reply(0);
- /* fall through on certain errors */
- }
- nfsrv_object_create(nd.ni_vp);
- if (nd.ni_cnd.cn_flags & ISSYMLINK) {
- error = EINVAL;
- goto nfsmreply0;
- }
- } else {
- error = ENXIO;
- }
- } else {
- if (vap->va_size != -1) {
- error = nfsrv_access(nd.ni_vp, VWRITE, cred,
- (nd.ni_cnd.cn_flags & RDONLY), procp, 0);
- if (!error) {
- nqsrv_getl(nd.ni_vp, ND_WRITE);
- tempsize = vap->va_size;
- VATTR_NULL(vap);
- vap->va_size = tempsize;
- error = VOP_SETATTR(nd.ni_vp, vap, cred,
- procp);
- }
- }
- }
-
- if (!error) {
- bzero((caddr_t)fhp, sizeof(nfh));
- fhp->fh_fsid = nd.ni_vp->v_mount->mnt_stat.f_fsid;
- error = VFS_VPTOFH(nd.ni_vp, &fhp->fh_fid);
- if (!error)
- error = VOP_GETATTR(nd.ni_vp, vap, cred, procp);
- }
- if (v3) {
- if (exclusive_flag && !error &&
- bcmp(cverf, (caddr_t)&vap->va_atime, NFSX_V3CREATEVERF))
- error = EEXIST;
- diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp);
- vrele(dirp);
- dirp = NULL;
- }
- nfsm_reply(NFSX_SRVFH(v3) + NFSX_FATTR(v3) + NFSX_WCCDATA(v3));
- if (v3) {
- if (!error) {
- nfsm_srvpostop_fh(fhp);
- nfsm_srvpostop_attr(0, vap);
- }
- nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft);
- error = 0;
- } else {
- nfsm_srvfhtom(fhp, v3);
- nfsm_build(fp, struct nfs_fattr *, NFSX_V2FATTR);
- nfsm_srvfillattr(vap, fp);
- }
- goto nfsmout;
-
-nfsmreply0:
- nfsm_reply(0);
- error = 0;
- /* fall through */
-
-nfsmout:
- if (nd.ni_startdir) {
- vrele(nd.ni_startdir);
- nd.ni_startdir = NULL;
- }
- if (dirp)
- vrele(dirp);
- NDFREE(&nd, NDF_ONLY_PNBUF);
- if (nd.ni_dvp) {
- if (nd.ni_dvp == nd.ni_vp)
- vrele(nd.ni_dvp);
- else
- vput(nd.ni_dvp);
- }
- if (nd.ni_vp)
- vput(nd.ni_vp);
- return (error);
-}
-
-/*
- * nfs v3 mknod service
- */
-int
-nfsrv_mknod(nfsd, slp, procp, mrq)
- struct nfsrv_descript *nfsd;
- struct nfssvc_sock *slp;
- struct proc *procp;
- struct mbuf **mrq;
-{
- struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md;
- struct sockaddr *nam = nfsd->nd_nam;
- caddr_t dpos = nfsd->nd_dpos;
- struct ucred *cred = &nfsd->nd_cr;
- struct vattr va, dirfor, diraft;
- register struct vattr *vap = &va;
- register u_int32_t *tl;
- struct nameidata nd;
- register int32_t t1;
- caddr_t bpos;
- int error = 0, cache, len, dirfor_ret = 1, diraft_ret = 1;
- u_int32_t major, minor;
- enum vtype vtyp;
- char *cp2;
- struct mbuf *mb, *mb2, *mreq;
- struct vnode *vp, *dirp = (struct vnode *)0;
- nfsfh_t nfh;
- fhandle_t *fhp;
- u_quad_t frev;
-
- nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
- ndclear(&nd);
-
- fhp = &nfh.fh_generic;
- nfsm_srvmtofh(fhp);
- nfsm_srvnamesiz(len);
-
- nd.ni_cnd.cn_cred = cred;
- nd.ni_cnd.cn_nameiop = CREATE;
- nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | SAVESTART;
-
- /*
- * Handle nfs_namei() call. If an error occurs, the nd structure
- * is not valid. However, nfsm_*() routines may still jump to
- * nfsmout.
- */
-
- error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos,
- &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE);
- if (dirp)
- dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, procp);
- if (error) {
- nfsm_reply(NFSX_WCCDATA(1));
- nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft);
- error = 0;
- goto nfsmout;
- }
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED);
- vtyp = nfsv3tov_type(*tl);
- if (vtyp != VCHR && vtyp != VBLK && vtyp != VSOCK && vtyp != VFIFO) {
- error = NFSERR_BADTYPE;
- goto out;
- }
- VATTR_NULL(vap);
- nfsm_srvsattr(vap);
- if (vtyp == VCHR || vtyp == VBLK) {
- nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
- major = fxdr_unsigned(u_int32_t, *tl++);
- minor = fxdr_unsigned(u_int32_t, *tl);
- vap->va_rdev = makeudev(major, minor);
- }
-
- /*
- * Iff doesn't exist, create it.
- */
- if (nd.ni_vp) {
- error = EEXIST;
- goto out;
- }
- vap->va_type = vtyp;
- if (vtyp == VSOCK) {
- vrele(nd.ni_startdir);
- nd.ni_startdir = NULL;
- nqsrv_getl(nd.ni_dvp, ND_WRITE);
- error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap);
- if (error)
- NDFREE(&nd, NDF_ONLY_PNBUF);
- } else {
- if (vtyp != VFIFO && (error = suser_xxx(cred, 0, 0)))
- goto out;
- nqsrv_getl(nd.ni_dvp, ND_WRITE);
-
- error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap);
- if (error) {
- NDFREE(&nd, NDF_ONLY_PNBUF);
- goto out;
- }
- vput(nd.ni_vp);
- nd.ni_vp = NULL;
-
- /*
- * Release dvp prior to lookup
- */
- vput(nd.ni_dvp);
- nd.ni_dvp = NULL;
-
- nd.ni_cnd.cn_nameiop = LOOKUP;
- nd.ni_cnd.cn_flags &= ~(LOCKPARENT);
- nd.ni_cnd.cn_proc = procp;
- nd.ni_cnd.cn_cred = procp->p_ucred;
-
- error = lookup(&nd);
- nd.ni_dvp = NULL;
-
- if (error)
- goto out;
- if (nd.ni_cnd.cn_flags & ISSYMLINK)
- error = EINVAL;
- }
-
- /*
- * send response, cleanup, return.
- */
-out:
- if (nd.ni_startdir) {
- vrele(nd.ni_startdir);
- nd.ni_startdir = NULL;
- }
- NDFREE(&nd, NDF_ONLY_PNBUF);
- if (nd.ni_dvp) {
- if (nd.ni_dvp == nd.ni_vp)
- vrele(nd.ni_dvp);
- else
- vput(nd.ni_dvp);
- nd.ni_dvp = NULL;
- }
- vp = nd.ni_vp;
- if (!error) {
- bzero((caddr_t)fhp, sizeof(nfh));
- fhp->fh_fsid = vp->v_mount->mnt_stat.f_fsid;
- error = VFS_VPTOFH(vp, &fhp->fh_fid);
- if (!error)
- error = VOP_GETATTR(vp, vap, cred, procp);
- vput(vp);
- vp = NULL;
- nd.ni_vp = NULL;
- }
- diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp);
- if (dirp) {
- vrele(dirp);
- dirp = NULL;
- }
- nfsm_reply(NFSX_SRVFH(1) + NFSX_POSTOPATTR(1) + NFSX_WCCDATA(1));
- if (!error) {
- nfsm_srvpostop_fh(fhp);
- nfsm_srvpostop_attr(0, vap);
- }
- nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft);
- return (0);
-nfsmout:
- if (dirp)
- vrele(dirp);
- if (nd.ni_startdir)
- vrele(nd.ni_startdir);
- NDFREE(&nd, NDF_ONLY_PNBUF);
- if (nd.ni_dvp) {
- if (nd.ni_dvp == nd.ni_vp)
- vrele(nd.ni_dvp);
- else
- vput(nd.ni_dvp);
- }
- if (nd.ni_vp)
- vput(nd.ni_vp);
- return (error);
-}
-
-/*
- * nfs remove service
- */
-int
-nfsrv_remove(nfsd, slp, procp, mrq)
- struct nfsrv_descript *nfsd;
- struct nfssvc_sock *slp;
- struct proc *procp;
- struct mbuf **mrq;
-{
- struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md;
- struct sockaddr *nam = nfsd->nd_nam;
- caddr_t dpos = nfsd->nd_dpos;
- struct ucred *cred = &nfsd->nd_cr;
- struct nameidata nd;
- register u_int32_t *tl;
- register int32_t t1;
- caddr_t bpos;
- int error = 0, cache, len, dirfor_ret = 1, diraft_ret = 1;
- int v3 = (nfsd->nd_flag & ND_NFSV3);
- char *cp2;
- struct mbuf *mb, *mreq;
- struct vnode *dirp;
- struct vattr dirfor, diraft;
- nfsfh_t nfh;
- fhandle_t *fhp;
- u_quad_t frev;
-
- nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
- ndclear(&nd);
-
- fhp = &nfh.fh_generic;
- nfsm_srvmtofh(fhp);
- nfsm_srvnamesiz(len);
-
- nd.ni_cnd.cn_cred = cred;
- nd.ni_cnd.cn_nameiop = DELETE;
- nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF;
- error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos,
- &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE);
- if (dirp) {
- if (v3) {
- dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred,
- procp);
- } else {
- vrele(dirp);
- dirp = NULL;
- }
- }
- if (error == 0) {
- if (nd.ni_vp->v_type == VDIR) {
- error = EPERM; /* POSIX */
- goto out;
- }
- /*
- * The root of a mounted filesystem cannot be deleted.
- */
- if (nd.ni_vp->v_flag & VROOT) {
- error = EBUSY;
- goto out;
- }
-out:
- if (!error) {
- nqsrv_getl(nd.ni_dvp, ND_WRITE);
- nqsrv_getl(nd.ni_vp, ND_WRITE);
- error = VOP_REMOVE(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd);
- NDFREE(&nd, NDF_ONLY_PNBUF);
- }
- }
- if (dirp && v3) {
- diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp);
- vrele(dirp);
- dirp = NULL;
- }
- nfsm_reply(NFSX_WCCDATA(v3));
- if (v3) {
- nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft);
- error = 0;
- }
-nfsmout:
- NDFREE(&nd, NDF_ONLY_PNBUF);
- if (nd.ni_dvp) {
- if (nd.ni_dvp == nd.ni_vp)
- vrele(nd.ni_dvp);
- else
- vput(nd.ni_dvp);
- }
- if (nd.ni_vp)
- vput(nd.ni_vp);
- return(error);
-}
-
-/*
- * nfs rename service
- */
-int
-nfsrv_rename(nfsd, slp, procp, mrq)
- struct nfsrv_descript *nfsd;
- struct nfssvc_sock *slp;
- struct proc *procp;
- struct mbuf **mrq;
-{
- struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md;
- struct sockaddr *nam = nfsd->nd_nam;
- caddr_t dpos = nfsd->nd_dpos;
- struct ucred *cred = &nfsd->nd_cr;
- register u_int32_t *tl;
- register int32_t t1;
- caddr_t bpos;
- int error = 0, cache, len, len2, fdirfor_ret = 1, fdiraft_ret = 1;
- int tdirfor_ret = 1, tdiraft_ret = 1;
- int v3 = (nfsd->nd_flag & ND_NFSV3);
- char *cp2;
- struct mbuf *mb, *mreq;
- struct nameidata fromnd, tond;
- struct vnode *fvp, *tvp, *tdvp, *fdirp = (struct vnode *)0;
- struct vnode *tdirp = (struct vnode *)0;
- struct vattr fdirfor, fdiraft, tdirfor, tdiraft;
- nfsfh_t fnfh, tnfh;
- fhandle_t *ffhp, *tfhp;
- u_quad_t frev;
- uid_t saved_uid;
-
- nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
-#ifndef nolint
- fvp = (struct vnode *)0;
-#endif
- ffhp = &fnfh.fh_generic;
- tfhp = &tnfh.fh_generic;
-
- /*
- * Clear fields incase goto nfsmout occurs from macro.
- */
-
- ndclear(&fromnd);
- ndclear(&tond);
-
- nfsm_srvmtofh(ffhp);
- nfsm_srvnamesiz(len);
- /*
- * Remember our original uid so that we can reset cr_uid before
- * the second nfs_namei() call, in case it is remapped.
- */
- saved_uid = cred->cr_uid;
- fromnd.ni_cnd.cn_cred = cred;
- fromnd.ni_cnd.cn_nameiop = DELETE;
- fromnd.ni_cnd.cn_flags = WANTPARENT | SAVESTART;
- error = nfs_namei(&fromnd, ffhp, len, slp, nam, &md,
- &dpos, &fdirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE);
- if (fdirp) {
- if (v3) {
- fdirfor_ret = VOP_GETATTR(fdirp, &fdirfor, cred,
- procp);
- } else {
- vrele(fdirp);
- fdirp = NULL;
- }
- }
- if (error) {
- nfsm_reply(2 * NFSX_WCCDATA(v3));
- nfsm_srvwcc_data(fdirfor_ret, &fdirfor, fdiraft_ret, &fdiraft);
- nfsm_srvwcc_data(tdirfor_ret, &tdirfor, tdiraft_ret, &tdiraft);
- error = 0;
- goto nfsmout;
- }
- fvp = fromnd.ni_vp;
- nfsm_srvmtofh(tfhp);
- nfsm_strsiz(len2, NFS_MAXNAMLEN);
- cred->cr_uid = saved_uid;
- tond.ni_cnd.cn_cred = cred;
- tond.ni_cnd.cn_nameiop = RENAME;
- tond.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART;
- error = nfs_namei(&tond, tfhp, len2, slp, nam, &md,
- &dpos, &tdirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE);
- if (tdirp) {
- if (v3) {
- tdirfor_ret = VOP_GETATTR(tdirp, &tdirfor, cred,
- procp);
- } else {
- vrele(tdirp);
- tdirp = NULL;
- }
- }
- if (error)
- goto out1;
-
- tdvp = tond.ni_dvp;
- tvp = tond.ni_vp;
- if (tvp != NULL) {
- if (fvp->v_type == VDIR && tvp->v_type != VDIR) {
- if (v3)
- error = EEXIST;
- else
- error = EISDIR;
- goto out;
- } else if (fvp->v_type != VDIR && tvp->v_type == VDIR) {
- if (v3)
- error = EEXIST;
- else
- error = ENOTDIR;
- goto out;
- }
- if (tvp->v_type == VDIR && tvp->v_mountedhere) {
- if (v3)
- error = EXDEV;
- else
- error = ENOTEMPTY;
- goto out;
- }
- }
- if (fvp->v_type == VDIR && fvp->v_mountedhere) {
- if (v3)
- error = EXDEV;
- else
- error = ENOTEMPTY;
- goto out;
- }
- if (fvp->v_mount != tdvp->v_mount) {
- if (v3)
- error = EXDEV;
- else
- error = ENOTEMPTY;
- goto out;
- }
- if (fvp == tdvp) {
- if (v3)
- error = EINVAL;
- else
- error = ENOTEMPTY;
- }
- /*
- * If source is the same as the destination (that is the
- * same vnode with the same name in the same directory),
- * then there is nothing to do.
- */
- if (fvp == tvp && fromnd.ni_dvp == tdvp &&
- fromnd.ni_cnd.cn_namelen == tond.ni_cnd.cn_namelen &&
- !bcmp(fromnd.ni_cnd.cn_nameptr, tond.ni_cnd.cn_nameptr,
- fromnd.ni_cnd.cn_namelen))
- error = -1;
-out:
- if (!error) {
- /*
- * The VOP_RENAME function releases all vnode references &
- * locks prior to returning so we need to clear the pointers
- * to bypass cleanup code later on.
- */
- nqsrv_getl(fromnd.ni_dvp, ND_WRITE);
- nqsrv_getl(tdvp, ND_WRITE);
- if (tvp) {
- nqsrv_getl(tvp, ND_WRITE);
- }
- error = VOP_RENAME(fromnd.ni_dvp, fromnd.ni_vp, &fromnd.ni_cnd,
- tond.ni_dvp, tond.ni_vp, &tond.ni_cnd);
- fromnd.ni_dvp = NULL;
- fromnd.ni_vp = NULL;
- tond.ni_dvp = NULL;
- tond.ni_vp = NULL;
- if (error) {
- fromnd.ni_cnd.cn_flags &= ~HASBUF;
- tond.ni_cnd.cn_flags &= ~HASBUF;
- }
- } else {
- if (error == -1)
- error = 0;
- }
- /* fall through */
-
-out1:
- if (fdirp)
- fdiraft_ret = VOP_GETATTR(fdirp, &fdiraft, cred, procp);
- if (tdirp)
- tdiraft_ret = VOP_GETATTR(tdirp, &tdiraft, cred, procp);
- nfsm_reply(2 * NFSX_WCCDATA(v3));
- if (v3) {
- nfsm_srvwcc_data(fdirfor_ret, &fdirfor, fdiraft_ret, &fdiraft);
- nfsm_srvwcc_data(tdirfor_ret, &tdirfor, tdiraft_ret, &tdiraft);
- }
- error = 0;
- /* fall through */
-
-nfsmout:
- /*
- * Clear out tond related fields
- */
- if (tdirp)
- vrele(tdirp);
- if (tond.ni_startdir)
- vrele(tond.ni_startdir);
- NDFREE(&tond, NDF_ONLY_PNBUF);
- if (tond.ni_dvp) {
- if (tond.ni_dvp == tond.ni_vp)
- vrele(tond.ni_dvp);
- else
- vput(tond.ni_dvp);
- }
- if (tond.ni_vp)
- vput(tond.ni_vp);
-
- /*
- * Clear out fromnd related fields
- */
- if (fdirp)
- vrele(fdirp);
- if (fromnd.ni_startdir)
- vrele(fromnd.ni_startdir);
- NDFREE(&fromnd, NDF_ONLY_PNBUF);
- if (fromnd.ni_dvp)
- vrele(fromnd.ni_dvp);
- if (fromnd.ni_vp)
- vrele(fromnd.ni_vp);
-
- return (error);
-}
-
-/*
- * nfs link service
- */
-int
-nfsrv_link(nfsd, slp, procp, mrq)
- struct nfsrv_descript *nfsd;
- struct nfssvc_sock *slp;
- struct proc *procp;
- struct mbuf **mrq;
-{
- struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md;
- struct sockaddr *nam = nfsd->nd_nam;
- caddr_t dpos = nfsd->nd_dpos;
- struct ucred *cred = &nfsd->nd_cr;
- struct nameidata nd;
- register u_int32_t *tl;
- register int32_t t1;
- caddr_t bpos;
- int error = 0, rdonly, cache, len, dirfor_ret = 1, diraft_ret = 1;
- int getret = 1, v3 = (nfsd->nd_flag & ND_NFSV3);
- char *cp2;
- struct mbuf *mb, *mreq;
- struct vnode *vp = NULL, *xp, *dirp = (struct vnode *)0;
- struct vattr dirfor, diraft, at;
- nfsfh_t nfh, dnfh;
- fhandle_t *fhp, *dfhp;
- u_quad_t frev;
-
- nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
- ndclear(&nd);
-
- fhp = &nfh.fh_generic;
- dfhp = &dnfh.fh_generic;
- nfsm_srvmtofh(fhp);
- nfsm_srvmtofh(dfhp);
- nfsm_srvnamesiz(len);
-
- error = nfsrv_fhtovp(fhp, FALSE, &vp, cred, slp, nam,
- &rdonly, (nfsd->nd_flag & ND_KERBAUTH), TRUE);
- if (error) {
- nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3));
- nfsm_srvpostop_attr(getret, &at);
- nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft);
- vp = NULL;
- error = 0;
- goto nfsmout;
- }
- if (vp->v_type == VDIR) {
- error = EPERM; /* POSIX */
- goto out1;
- }
- nd.ni_cnd.cn_cred = cred;
- nd.ni_cnd.cn_nameiop = CREATE;
- nd.ni_cnd.cn_flags = LOCKPARENT;
- error = nfs_namei(&nd, dfhp, len, slp, nam, &md, &dpos,
- &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE);
- if (dirp) {
- if (v3) {
- dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred,
- procp);
- } else {
- vrele(dirp);
- dirp = NULL;
- }
- }
- if (error)
- goto out1;
-
- xp = nd.ni_vp;
- if (xp != NULL) {
- error = EEXIST;
- goto out;
- }
- xp = nd.ni_dvp;
- if (vp->v_mount != xp->v_mount)
- error = EXDEV;
-out:
- if (!error) {
- nqsrv_getl(vp, ND_WRITE);
- nqsrv_getl(xp, ND_WRITE);
- error = VOP_LINK(nd.ni_dvp, vp, &nd.ni_cnd);
- NDFREE(&nd, NDF_ONLY_PNBUF);
- }
- /* fall through */
-
-out1:
- if (v3)
- getret = VOP_GETATTR(vp, &at, cred, procp);
- if (dirp)
- diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp);
- nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3));
- if (v3) {
- nfsm_srvpostop_attr(getret, &at);
- nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft);
- error = 0;
- }
- /* fall through */
-
-nfsmout:
- NDFREE(&nd, NDF_ONLY_PNBUF);
- if (dirp)
- vrele(dirp);
- if (vp)
- vrele(vp);
- if (nd.ni_dvp) {
- if (nd.ni_dvp == nd.ni_vp)
- vrele(nd.ni_dvp);
- else
- vput(nd.ni_dvp);
- }
- if (nd.ni_vp)
- vrele(nd.ni_vp);
- return(error);
-}
-
-/*
- * nfs symbolic link service
- */
-int
-nfsrv_symlink(nfsd, slp, procp, mrq)
- struct nfsrv_descript *nfsd;
- struct nfssvc_sock *slp;
- struct proc *procp;
- struct mbuf **mrq;
-{
- struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md;
- struct sockaddr *nam = nfsd->nd_nam;
- caddr_t dpos = nfsd->nd_dpos;
- struct ucred *cred = &nfsd->nd_cr;
- struct vattr va, dirfor, diraft;
- struct nameidata nd;
- register struct vattr *vap = &va;
- register u_int32_t *tl;
- register int32_t t1;
- struct nfsv2_sattr *sp;
- char *bpos, *pathcp = (char *)0, *cp2;
- struct uio io;
- struct iovec iv;
- int error = 0, cache, len, len2, dirfor_ret = 1, diraft_ret = 1;
- int v3 = (nfsd->nd_flag & ND_NFSV3);
- struct mbuf *mb, *mreq, *mb2;
- struct vnode *dirp = (struct vnode *)0;
- nfsfh_t nfh;
- fhandle_t *fhp;
- u_quad_t frev;
-
- nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
- ndclear(&nd);
-
- fhp = &nfh.fh_generic;
- nfsm_srvmtofh(fhp);
- nfsm_srvnamesiz(len);
- nd.ni_cnd.cn_cred = cred;
- nd.ni_cnd.cn_nameiop = CREATE;
- nd.ni_cnd.cn_flags = LOCKPARENT | SAVESTART;
- error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos,
- &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE);
- if (dirp) {
- if (v3) {
- dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred,
- procp);
- } else {
- vrele(dirp);
- dirp = NULL;
- }
- }
- if (error)
- goto out;
-
- VATTR_NULL(vap);
- if (v3)
- nfsm_srvsattr(vap);
- nfsm_strsiz(len2, NFS_MAXPATHLEN);
- MALLOC(pathcp, caddr_t, len2 + 1, M_TEMP, M_WAITOK);
- iv.iov_base = pathcp;
- iv.iov_len = len2;
- io.uio_resid = len2;
- io.uio_offset = 0;
- io.uio_iov = &iv;
- io.uio_iovcnt = 1;
- io.uio_segflg = UIO_SYSSPACE;
- io.uio_rw = UIO_READ;
- io.uio_procp = (struct proc *)0;
- nfsm_mtouio(&io, len2);
- if (!v3) {
- nfsm_dissect(sp, struct nfsv2_sattr *, NFSX_V2SATTR);
- vap->va_mode = fxdr_unsigned(u_int16_t, sp->sa_mode);
- }
- *(pathcp + len2) = '\0';
- if (nd.ni_vp) {
- error = EEXIST;
- goto out;
- }
-
- /*
- * issue symlink op. SAVESTART is set so the underlying path component
- * is only freed by the VOP if an error occurs.
- */
- nqsrv_getl(nd.ni_dvp, ND_WRITE);
- error = VOP_SYMLINK(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap, pathcp);
- if (error)
- NDFREE(&nd, NDF_ONLY_PNBUF);
- else {
- vput(nd.ni_vp);
- nd.ni_vp = NULL;
- }
- /*
- * releases directory prior to potential lookup op.
- */
- vput(nd.ni_dvp);
- nd.ni_dvp = NULL;
-
- if (error == 0) {
- if (v3) {
- /*
- * Issue lookup. Leave SAVESTART set so we can easily free
- * the name buffer later on.
- *
- * since LOCKPARENT is not set, ni_dvp will be garbage on
- * return whether an error occurs or not.
- */
- nd.ni_cnd.cn_nameiop = LOOKUP;
- nd.ni_cnd.cn_flags &= ~(LOCKPARENT | FOLLOW);
- nd.ni_cnd.cn_flags |= (NOFOLLOW | LOCKLEAF);
- nd.ni_cnd.cn_proc = procp;
- nd.ni_cnd.cn_cred = cred;
-
- error = lookup(&nd);
- nd.ni_dvp = NULL;
-
- if (error == 0) {
- bzero((caddr_t)fhp, sizeof(nfh));
- fhp->fh_fsid = nd.ni_vp->v_mount->mnt_stat.f_fsid;
- error = VFS_VPTOFH(nd.ni_vp, &fhp->fh_fid);
- if (!error)
- error = VOP_GETATTR(nd.ni_vp, vap, cred,
- procp);
- vput(nd.ni_vp);
- nd.ni_vp = NULL;
- }
- }
- }
-out:
- /*
- * These releases aren't strictly required, does even doing them
- * make any sense? XXX can nfsm_reply() block?
- */
- if (pathcp) {
- FREE(pathcp, M_TEMP);
- pathcp = NULL;
- }
- if (dirp) {
- diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp);
- vrele(dirp);
- dirp = NULL;
- }
- if (nd.ni_startdir) {
- vrele(nd.ni_startdir);
- nd.ni_startdir = NULL;
- }
- nfsm_reply(NFSX_SRVFH(v3) + NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3));
- if (v3) {
- if (!error) {
- nfsm_srvpostop_fh(fhp);
- nfsm_srvpostop_attr(0, vap);
- }
- nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft);
- }
- error = 0;
- /* fall through */
-
-nfsmout:
- NDFREE(&nd, NDF_ONLY_PNBUF);
- if (nd.ni_dvp) {
- if (nd.ni_dvp == nd.ni_vp)
- vrele(nd.ni_dvp);
- else
- vput(nd.ni_dvp);
- }
- if (nd.ni_vp)
- vrele(nd.ni_vp);
- if (nd.ni_startdir)
- vrele(nd.ni_startdir);
- if (dirp)
- vrele(dirp);
- if (pathcp)
- FREE(pathcp, M_TEMP);
-
- return (error);
-}
-
-/*
- * nfs mkdir service
- */
-int
-nfsrv_mkdir(nfsd, slp, procp, mrq)
- struct nfsrv_descript *nfsd;
- struct nfssvc_sock *slp;
- struct proc *procp;
- struct mbuf **mrq;
-{
- struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md;
- struct sockaddr *nam = nfsd->nd_nam;
- caddr_t dpos = nfsd->nd_dpos;
- struct ucred *cred = &nfsd->nd_cr;
- struct vattr va, dirfor, diraft;
- register struct vattr *vap = &va;
- register struct nfs_fattr *fp;
- struct nameidata nd;
- register caddr_t cp;
- register u_int32_t *tl;
- register int32_t t1;
- caddr_t bpos;
- int error = 0, cache, len, dirfor_ret = 1, diraft_ret = 1;
- int v3 = (nfsd->nd_flag & ND_NFSV3);
- char *cp2;
- struct mbuf *mb, *mb2, *mreq;
- struct vnode *dirp = NULL;
- int vpexcl = 0;
- nfsfh_t nfh;
- fhandle_t *fhp;
- u_quad_t frev;
-
- nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
- ndclear(&nd);
-
- fhp = &nfh.fh_generic;
- nfsm_srvmtofh(fhp);
- nfsm_srvnamesiz(len);
- nd.ni_cnd.cn_cred = cred;
- nd.ni_cnd.cn_nameiop = CREATE;
- nd.ni_cnd.cn_flags = LOCKPARENT;
-
- error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos,
- &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE);
- if (dirp) {
- if (v3) {
- dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred,
- procp);
- } else {
- vrele(dirp);
- dirp = NULL;
- }
- }
- if (error) {
- nfsm_reply(NFSX_WCCDATA(v3));
- nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft);
- error = 0;
- goto nfsmout;
- }
- VATTR_NULL(vap);
- if (v3) {
- nfsm_srvsattr(vap);
- } else {
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED);
- vap->va_mode = nfstov_mode(*tl++);
- }
-
- /*
- * At this point nd.ni_dvp is referenced and exclusively locked and
- * nd.ni_vp, if it exists, is referenced but not locked.
- */
-
- vap->va_type = VDIR;
- if (nd.ni_vp != NULL) {
- NDFREE(&nd, NDF_ONLY_PNBUF);
- error = EEXIST;
- goto out;
- }
-
- /*
- * Issue mkdir op. Since SAVESTART is not set, the pathname
- * component is freed by the VOP call. This will fill-in
- * nd.ni_vp, reference, and exclusively lock it.
- */
- nqsrv_getl(nd.ni_dvp, ND_WRITE);
- error = VOP_MKDIR(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap);
- NDFREE(&nd, NDF_ONLY_PNBUF);
- vpexcl = 1;
-
- vput(nd.ni_dvp);
- nd.ni_dvp = NULL;
-
- if (!error) {
- bzero((caddr_t)fhp, sizeof(nfh));
- fhp->fh_fsid = nd.ni_vp->v_mount->mnt_stat.f_fsid;
- error = VFS_VPTOFH(nd.ni_vp, &fhp->fh_fid);
- if (!error)
- error = VOP_GETATTR(nd.ni_vp, vap, cred, procp);
- }
-out:
- if (dirp)
- diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp);
- nfsm_reply(NFSX_SRVFH(v3) + NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3));
- if (v3) {
- if (!error) {
- nfsm_srvpostop_fh(fhp);
- nfsm_srvpostop_attr(0, vap);
- }
- nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft);
- } else {
- nfsm_srvfhtom(fhp, v3);
- nfsm_build(fp, struct nfs_fattr *, NFSX_V2FATTR);
- nfsm_srvfillattr(vap, fp);
- }
- error = 0;
- /* fall through */
-
-nfsmout:
- if (dirp)
- vrele(dirp);
- if (nd.ni_dvp) {
- NDFREE(&nd, NDF_ONLY_PNBUF);
- if (nd.ni_dvp == nd.ni_vp && vpexcl)
- vrele(nd.ni_dvp);
- else
- vput(nd.ni_dvp);
- }
- if (nd.ni_vp) {
- if (vpexcl)
- vput(nd.ni_vp);
- else
- vrele(nd.ni_vp);
- }
- return (error);
-}
-
-/*
- * nfs rmdir service
- */
-int
-nfsrv_rmdir(nfsd, slp, procp, mrq)
- struct nfsrv_descript *nfsd;
- struct nfssvc_sock *slp;
- struct proc *procp;
- struct mbuf **mrq;
-{
- struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md;
- struct sockaddr *nam = nfsd->nd_nam;
- caddr_t dpos = nfsd->nd_dpos;
- struct ucred *cred = &nfsd->nd_cr;
- register u_int32_t *tl;
- register int32_t t1;
- caddr_t bpos;
- int error = 0, cache, len, dirfor_ret = 1, diraft_ret = 1;
- int v3 = (nfsd->nd_flag & ND_NFSV3);
- char *cp2;
- struct mbuf *mb, *mreq;
- struct vnode *vp, *dirp = (struct vnode *)0;
- struct vattr dirfor, diraft;
- nfsfh_t nfh;
- fhandle_t *fhp;
- struct nameidata nd;
- u_quad_t frev;
-
- nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
- ndclear(&nd);
-
- fhp = &nfh.fh_generic;
- nfsm_srvmtofh(fhp);
- nfsm_srvnamesiz(len);
- nd.ni_cnd.cn_cred = cred;
- nd.ni_cnd.cn_nameiop = DELETE;
- nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF;
- error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos,
- &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE);
- if (dirp) {
- if (v3) {
- dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred,
- procp);
- } else {
- vrele(dirp);
- dirp = NULL;
- }
- }
- if (error) {
- nfsm_reply(NFSX_WCCDATA(v3));
- nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft);
- error = 0;
- goto nfsmout;
- }
- vp = nd.ni_vp;
- if (vp->v_type != VDIR) {
- error = ENOTDIR;
- goto out;
- }
- /*
- * No rmdir "." please.
- */
- if (nd.ni_dvp == vp) {
- error = EINVAL;
- goto out;
- }
- /*
- * The root of a mounted filesystem cannot be deleted.
- */
- if (vp->v_flag & VROOT)
- error = EBUSY;
-out:
- /*
- * Issue or abort op. Since SAVESTART is not set, path name
- * component is freed by the VOP after either.
- */
- if (!error) {
- nqsrv_getl(nd.ni_dvp, ND_WRITE);
- nqsrv_getl(vp, ND_WRITE);
- error = VOP_RMDIR(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd);
- }
- NDFREE(&nd, NDF_ONLY_PNBUF);
-
- if (dirp)
- diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp);
- nfsm_reply(NFSX_WCCDATA(v3));
- if (v3) {
- nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft);
- error = 0;
- }
- /* fall through */
-
-nfsmout:
- NDFREE(&nd, NDF_ONLY_PNBUF);
- if (dirp)
- vrele(dirp);
- if (nd.ni_dvp) {
- if (nd.ni_dvp == nd.ni_vp)
- vrele(nd.ni_dvp);
- else
- vput(nd.ni_dvp);
- }
- if (nd.ni_vp)
- vput(nd.ni_vp);
-
- return(error);
-}
-
-/*
- * nfs readdir service
- * - mallocs what it thinks is enough to read
- * count rounded up to a multiple of NFS_DIRBLKSIZ <= NFS_MAXREADDIR
- * - calls VOP_READDIR()
- * - loops around building the reply
- * if the output generated exceeds count break out of loop
- * The nfsm_clget macro is used here so that the reply will be packed
- * tightly in mbuf clusters.
- * - it only knows that it has encountered eof when the VOP_READDIR()
- * reads nothing
- * - as such one readdir rpc will return eof false although you are there
- * and then the next will return eof
- * - it trims out records with d_fileno == 0
- * this doesn't matter for Unix clients, but they might confuse clients
- * for other os'.
- * NB: It is tempting to set eof to true if the VOP_READDIR() reads less
- * than requested, but this may not apply to all filesystems. For
- * example, client NFS does not { although it is never remote mounted
- * anyhow }
- * The alternate call nfsrv_readdirplus() does lookups as well.
- * PS: The NFS protocol spec. does not clarify what the "count" byte
- * argument is a count of.. just name strings and file id's or the
- * entire reply rpc or ...
- * I tried just file name and id sizes and it confused the Sun client,
- * so I am using the full rpc size now. The "paranoia.." comment refers
- * to including the status longwords that are not a part of the dir.
- * "entry" structures, but are in the rpc.
- */
-struct flrep {
- nfsuint64 fl_off;
- u_int32_t fl_postopok;
- u_int32_t fl_fattr[NFSX_V3FATTR / sizeof (u_int32_t)];
- u_int32_t fl_fhok;
- u_int32_t fl_fhsize;
- u_int32_t fl_nfh[NFSX_V3FH / sizeof (u_int32_t)];
-};
-
-int
-nfsrv_readdir(nfsd, slp, procp, mrq)
- struct nfsrv_descript *nfsd;
- struct nfssvc_sock *slp;
- struct proc *procp;
- struct mbuf **mrq;
-{
- struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md;
- struct sockaddr *nam = nfsd->nd_nam;
- caddr_t dpos = nfsd->nd_dpos;
- struct ucred *cred = &nfsd->nd_cr;
- register char *bp, *be;
- register struct mbuf *mp;
- register struct dirent *dp;
- register caddr_t cp;
- register u_int32_t *tl;
- register int32_t t1;
- caddr_t bpos;
- struct mbuf *mb, *mb2, *mreq, *mp2;
- char *cpos, *cend, *cp2, *rbuf;
- struct vnode *vp = NULL;
- struct vattr at;
- nfsfh_t nfh;
- fhandle_t *fhp;
- struct uio io;
- struct iovec iv;
- int len, nlen, rem, xfer, tsiz, i, error = 0, getret = 1;
- int siz, cnt, fullsiz, eofflag, rdonly, cache, ncookies;
- int v3 = (nfsd->nd_flag & ND_NFSV3);
- u_quad_t frev, off, toff, verf;
- u_long *cookies = NULL, *cookiep; /* needs to be int64_t or off_t */
-
- nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
- fhp = &nfh.fh_generic;
- nfsm_srvmtofh(fhp);
- if (v3) {
- nfsm_dissect(tl, u_int32_t *, 5 * NFSX_UNSIGNED);
- toff = fxdr_hyper(tl);
- tl += 2;
- verf = fxdr_hyper(tl);
- tl += 2;
- } else {
- nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
- toff = fxdr_unsigned(u_quad_t, *tl++);
- verf = 0; /* shut up gcc */
- }
- off = toff;
- cnt = fxdr_unsigned(int, *tl);
- siz = ((cnt + DIRBLKSIZ - 1) & ~(DIRBLKSIZ - 1));
- xfer = NFS_SRVMAXDATA(nfsd);
- if (siz > xfer)
- siz = xfer;
- fullsiz = siz;
- error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam,
- &rdonly, (nfsd->nd_flag & ND_KERBAUTH), TRUE);
- if (!error && vp->v_type != VDIR) {
- error = ENOTDIR;
- vput(vp);
- vp = NULL;
- }
- if (error) {
- nfsm_reply(NFSX_UNSIGNED);
- nfsm_srvpostop_attr(getret, &at);
- error = 0;
- goto nfsmout;
- }
-
- /*
- * Obtain lock on vnode for this section of the code
- */
-
- nqsrv_getl(vp, ND_READ);
- if (v3) {
- error = getret = VOP_GETATTR(vp, &at, cred, procp);
-#if 0
- /*
- * XXX This check may be too strict for Solaris 2.5 clients.
- */
- if (!error && toff && verf && verf != at.va_filerev)
- error = NFSERR_BAD_COOKIE;
-#endif
- }
- if (!error)
- error = nfsrv_access(vp, VEXEC, cred, rdonly, procp, 0);
- if (error) {
- vput(vp);
- vp = NULL;
- nfsm_reply(NFSX_POSTOPATTR(v3));
- nfsm_srvpostop_attr(getret, &at);
- error = 0;
- goto nfsmout;
- }
- VOP_UNLOCK(vp, 0, procp);
-
- /*
- * end section. Allocate rbuf and continue
- */
- MALLOC(rbuf, caddr_t, siz, M_TEMP, M_WAITOK);
-again:
- iv.iov_base = rbuf;
- iv.iov_len = fullsiz;
- io.uio_iov = &iv;
- io.uio_iovcnt = 1;
- io.uio_offset = (off_t)off;
- io.uio_resid = fullsiz;
- io.uio_segflg = UIO_SYSSPACE;
- io.uio_rw = UIO_READ;
- io.uio_procp = (struct proc *)0;
- eofflag = 0;
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, procp);
- if (cookies) {
- free((caddr_t)cookies, M_TEMP);
- cookies = NULL;
- }
- error = VOP_READDIR(vp, &io, cred, &eofflag, &ncookies, &cookies);
- off = (off_t)io.uio_offset;
- if (!cookies && !error)
- error = NFSERR_PERM;
- if (v3) {
- getret = VOP_GETATTR(vp, &at, cred, procp);
- if (!error)
- error = getret;
- }
- VOP_UNLOCK(vp, 0, procp);
- if (error) {
- vrele(vp);
- vp = NULL;
- free((caddr_t)rbuf, M_TEMP);
- if (cookies)
- free((caddr_t)cookies, M_TEMP);
- nfsm_reply(NFSX_POSTOPATTR(v3));
- nfsm_srvpostop_attr(getret, &at);
- error = 0;
- goto nfsmout;
- }
- if (io.uio_resid) {
- siz -= io.uio_resid;
-
- /*
- * If nothing read, return eof
- * rpc reply
- */
- if (siz == 0) {
- vrele(vp);
- vp = NULL;
- nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_COOKIEVERF(v3) +
- 2 * NFSX_UNSIGNED);
- if (v3) {
- nfsm_srvpostop_attr(getret, &at);
- nfsm_build(tl, u_int32_t *, 4 * NFSX_UNSIGNED);
- txdr_hyper(at.va_filerev, tl);
- tl += 2;
- } else
- nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
- *tl++ = nfs_false;
- *tl = nfs_true;
- FREE((caddr_t)rbuf, M_TEMP);
- FREE((caddr_t)cookies, M_TEMP);
- error = 0;
- goto nfsmout;
- }
- }
-
- /*
- * Check for degenerate cases of nothing useful read.
- * If so go try again
- */
- cpos = rbuf;
- cend = rbuf + siz;
- dp = (struct dirent *)cpos;
- cookiep = cookies;
- /*
- * For some reason FreeBSD's ufs_readdir() chooses to back the
- * directory offset up to a block boundary, so it is necessary to
- * skip over the records that preceed the requested offset. This
- * requires the assumption that file offset cookies monotonically
- * increase.
- */
- while (cpos < cend && ncookies > 0 &&
- (dp->d_fileno == 0 || dp->d_type == DT_WHT ||
- ((u_quad_t)(*cookiep)) <= toff)) {
- cpos += dp->d_reclen;
- dp = (struct dirent *)cpos;
- cookiep++;
- ncookies--;
- }
- if (cpos >= cend || ncookies == 0) {
- toff = off;
- siz = fullsiz;
- goto again;
- }
-
- len = 3 * NFSX_UNSIGNED; /* paranoia, probably can be 0 */
- nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_COOKIEVERF(v3) + siz);
- if (v3) {
- nfsm_srvpostop_attr(getret, &at);
- nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
- txdr_hyper(at.va_filerev, tl);
- }
- mp = mp2 = mb;
- bp = bpos;
- be = bp + M_TRAILINGSPACE(mp);
-
- /* Loop through the records and build reply */
- while (cpos < cend && ncookies > 0) {
- if (dp->d_fileno != 0 && dp->d_type != DT_WHT) {
- nlen = dp->d_namlen;
- rem = nfsm_rndup(nlen) - nlen;
- len += (4 * NFSX_UNSIGNED + nlen + rem);
- if (v3)
- len += 2 * NFSX_UNSIGNED;
- if (len > cnt) {
- eofflag = 0;
- break;
- }
- /*
- * Build the directory record xdr from
- * the dirent entry.
- */
- nfsm_clget;
- *tl = nfs_true;
- bp += NFSX_UNSIGNED;
- if (v3) {
- nfsm_clget;
- *tl = 0;
- bp += NFSX_UNSIGNED;
- }
- nfsm_clget;
- *tl = txdr_unsigned(dp->d_fileno);
- bp += NFSX_UNSIGNED;
- nfsm_clget;
- *tl = txdr_unsigned(nlen);
- bp += NFSX_UNSIGNED;
-
- /* And loop around copying the name */
- xfer = nlen;
- cp = dp->d_name;
- while (xfer > 0) {
- nfsm_clget;
- if ((bp+xfer) > be)
- tsiz = be-bp;
- else
- tsiz = xfer;
- bcopy(cp, bp, tsiz);
- bp += tsiz;
- xfer -= tsiz;
- if (xfer > 0)
- cp += tsiz;
- }
- /* And null pad to a int32_t boundary */
- for (i = 0; i < rem; i++)
- *bp++ = '\0';
- nfsm_clget;
-
- /* Finish off the record */
- if (v3) {
- *tl = 0;
- bp += NFSX_UNSIGNED;
- nfsm_clget;
- }
- *tl = txdr_unsigned(*cookiep);
- bp += NFSX_UNSIGNED;
- }
- cpos += dp->d_reclen;
- dp = (struct dirent *)cpos;
- cookiep++;
- ncookies--;
- }
- vrele(vp);
- vp = NULL;
- nfsm_clget;
- *tl = nfs_false;
- bp += NFSX_UNSIGNED;
- nfsm_clget;
- if (eofflag)
- *tl = nfs_true;
- else
- *tl = nfs_false;
- bp += NFSX_UNSIGNED;
- if (mp != mb) {
- if (bp < be)
- mp->m_len = bp - mtod(mp, caddr_t);
- } else
- mp->m_len += bp - bpos;
- FREE((caddr_t)rbuf, M_TEMP);
- FREE((caddr_t)cookies, M_TEMP);
-
-nfsmout:
- if (vp)
- vrele(vp);
- return(error);
-}
-
-int
-nfsrv_readdirplus(nfsd, slp, procp, mrq)
- struct nfsrv_descript *nfsd;
- struct nfssvc_sock *slp;
- struct proc *procp;
- struct mbuf **mrq;
-{
- struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md;
- struct sockaddr *nam = nfsd->nd_nam;
- caddr_t dpos = nfsd->nd_dpos;
- struct ucred *cred = &nfsd->nd_cr;
- register char *bp, *be;
- register struct mbuf *mp;
- register struct dirent *dp;
- register caddr_t cp;
- register u_int32_t *tl;
- register int32_t t1;
- caddr_t bpos;
- struct mbuf *mb, *mb2, *mreq, *mp2;
- char *cpos, *cend, *cp2, *rbuf;
- struct vnode *vp = NULL, *nvp;
- struct flrep fl;
- nfsfh_t nfh;
- fhandle_t *fhp, *nfhp = (fhandle_t *)fl.fl_nfh;
- struct uio io;
- struct iovec iv;
- struct vattr va, at, *vap = &va;
- struct nfs_fattr *fp;
- int len, nlen, rem, xfer, tsiz, i, error = 0, getret = 1;
- int siz, cnt, fullsiz, eofflag, rdonly, cache, dirlen, ncookies;
- u_quad_t frev, off, toff, verf;
- u_long *cookies = NULL, *cookiep; /* needs to be int64_t or off_t */
-
- nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
- fhp = &nfh.fh_generic;
- nfsm_srvmtofh(fhp);
- nfsm_dissect(tl, u_int32_t *, 6 * NFSX_UNSIGNED);
- toff = fxdr_hyper(tl);
- tl += 2;
- verf = fxdr_hyper(tl);
- tl += 2;
- siz = fxdr_unsigned(int, *tl++);
- cnt = fxdr_unsigned(int, *tl);
- off = toff;
- siz = ((siz + DIRBLKSIZ - 1) & ~(DIRBLKSIZ - 1));
- xfer = NFS_SRVMAXDATA(nfsd);
- if (siz > xfer)
- siz = xfer;
- fullsiz = siz;
- error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam,
- &rdonly, (nfsd->nd_flag & ND_KERBAUTH), TRUE);
- if (!error && vp->v_type != VDIR) {
- error = ENOTDIR;
- vput(vp);
- vp = NULL;
- }
- if (error) {
- nfsm_reply(NFSX_UNSIGNED);
- nfsm_srvpostop_attr(getret, &at);
- error = 0;
- goto nfsmout;
- }
- error = getret = VOP_GETATTR(vp, &at, cred, procp);
-#if 0
- /*
- * XXX This check may be too strict for Solaris 2.5 clients.
- */
- if (!error && toff && verf && verf != at.va_filerev)
- error = NFSERR_BAD_COOKIE;
-#endif
- if (!error) {
- nqsrv_getl(vp, ND_READ);
- error = nfsrv_access(vp, VEXEC, cred, rdonly, procp, 0);
- }
- if (error) {
- vput(vp);
- vp = NULL;
- nfsm_reply(NFSX_V3POSTOPATTR);
- nfsm_srvpostop_attr(getret, &at);
- error = 0;
- goto nfsmout;
- }
- VOP_UNLOCK(vp, 0, procp);
- MALLOC(rbuf, caddr_t, siz, M_TEMP, M_WAITOK);
-again:
- iv.iov_base = rbuf;
- iv.iov_len = fullsiz;
- io.uio_iov = &iv;
- io.uio_iovcnt = 1;
- io.uio_offset = (off_t)off;
- io.uio_resid = fullsiz;
- io.uio_segflg = UIO_SYSSPACE;
- io.uio_rw = UIO_READ;
- io.uio_procp = (struct proc *)0;
- eofflag = 0;
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, procp);
- if (cookies) {
- free((caddr_t)cookies, M_TEMP);
- cookies = NULL;
- }
- error = VOP_READDIR(vp, &io, cred, &eofflag, &ncookies, &cookies);
- off = (u_quad_t)io.uio_offset;
- getret = VOP_GETATTR(vp, &at, cred, procp);
- VOP_UNLOCK(vp, 0, procp);
- if (!cookies && !error)
- error = NFSERR_PERM;
- if (!error)
- error = getret;
- if (error) {
- vrele(vp);
- vp = NULL;
- if (cookies)
- free((caddr_t)cookies, M_TEMP);
- free((caddr_t)rbuf, M_TEMP);
- nfsm_reply(NFSX_V3POSTOPATTR);
- nfsm_srvpostop_attr(getret, &at);
- error = 0;
- goto nfsmout;
- }
- if (io.uio_resid) {
- siz -= io.uio_resid;
-
- /*
- * If nothing read, return eof
- * rpc reply
- */
- if (siz == 0) {
- vrele(vp);
- vp = NULL;
- nfsm_reply(NFSX_V3POSTOPATTR + NFSX_V3COOKIEVERF +
- 2 * NFSX_UNSIGNED);
- nfsm_srvpostop_attr(getret, &at);
- nfsm_build(tl, u_int32_t *, 4 * NFSX_UNSIGNED);
- txdr_hyper(at.va_filerev, tl);
- tl += 2;
- *tl++ = nfs_false;
- *tl = nfs_true;
- FREE((caddr_t)cookies, M_TEMP);
- FREE((caddr_t)rbuf, M_TEMP);
- error = 0;
- goto nfsmout;
- }
- }
-
- /*
- * Check for degenerate cases of nothing useful read.
- * If so go try again
- */
- cpos = rbuf;
- cend = rbuf + siz;
- dp = (struct dirent *)cpos;
- cookiep = cookies;
- /*
- * For some reason FreeBSD's ufs_readdir() chooses to back the
- * directory offset up to a block boundary, so it is necessary to
- * skip over the records that preceed the requested offset. This
- * requires the assumption that file offset cookies monotonically
- * increase.
- */
- while (cpos < cend && ncookies > 0 &&
- (dp->d_fileno == 0 || dp->d_type == DT_WHT ||
- ((u_quad_t)(*cookiep)) <= toff)) {
- cpos += dp->d_reclen;
- dp = (struct dirent *)cpos;
- cookiep++;
- ncookies--;
- }
- if (cpos >= cend || ncookies == 0) {
- toff = off;
- siz = fullsiz;
- goto again;
- }
-
- /*
- * Probe one of the directory entries to see if the filesystem
- * supports VGET.
- */
- if (VFS_VGET(vp->v_mount, dp->d_fileno, &nvp) == EOPNOTSUPP) {
- error = NFSERR_NOTSUPP;
- vrele(vp);
- vp = NULL;
- free((caddr_t)cookies, M_TEMP);
- free((caddr_t)rbuf, M_TEMP);
- nfsm_reply(NFSX_V3POSTOPATTR);
- nfsm_srvpostop_attr(getret, &at);
- error = 0;
- goto nfsmout;
- }
- vput(nvp);
- nvp = NULL;
-
- dirlen = len = NFSX_V3POSTOPATTR + NFSX_V3COOKIEVERF + 2 * NFSX_UNSIGNED;
- nfsm_reply(cnt);
- nfsm_srvpostop_attr(getret, &at);
- nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
- txdr_hyper(at.va_filerev, tl);
- mp = mp2 = mb;
- bp = bpos;
- be = bp + M_TRAILINGSPACE(mp);
-
- /* Loop through the records and build reply */
- while (cpos < cend && ncookies > 0) {
- if (dp->d_fileno != 0 && dp->d_type != DT_WHT) {
- nlen = dp->d_namlen;
- rem = nfsm_rndup(nlen)-nlen;
-
- /*
- * For readdir_and_lookup get the vnode using
- * the file number.
- */
- if (VFS_VGET(vp->v_mount, dp->d_fileno, &nvp))
- goto invalid;
- bzero((caddr_t)nfhp, NFSX_V3FH);
- nfhp->fh_fsid =
- nvp->v_mount->mnt_stat.f_fsid;
- if (VFS_VPTOFH(nvp, &nfhp->fh_fid)) {
- vput(nvp);
- nvp = NULL;
- goto invalid;
- }
- if (VOP_GETATTR(nvp, vap, cred, procp)) {
- vput(nvp);
- nvp = NULL;
- goto invalid;
- }
- vput(nvp);
- nvp = NULL;
-
- /*
- * If either the dircount or maxcount will be
- * exceeded, get out now. Both of these lengths
- * are calculated conservatively, including all
- * XDR overheads.
- */
- len += (8 * NFSX_UNSIGNED + nlen + rem + NFSX_V3FH +
- NFSX_V3POSTOPATTR);
- dirlen += (6 * NFSX_UNSIGNED + nlen + rem);
- if (len > cnt || dirlen > fullsiz) {
- eofflag = 0;
- break;
- }
-
- /*
- * Build the directory record xdr from
- * the dirent entry.
- */
- fp = (struct nfs_fattr *)&fl.fl_fattr;
- nfsm_srvfillattr(vap, fp);
- fl.fl_fhsize = txdr_unsigned(NFSX_V3FH);
- fl.fl_fhok = nfs_true;
- fl.fl_postopok = nfs_true;
- fl.fl_off.nfsuquad[0] = 0;
- fl.fl_off.nfsuquad[1] = txdr_unsigned(*cookiep);
-
- nfsm_clget;
- *tl = nfs_true;
- bp += NFSX_UNSIGNED;
- nfsm_clget;
- *tl = 0;
- bp += NFSX_UNSIGNED;
- nfsm_clget;
- *tl = txdr_unsigned(dp->d_fileno);
- bp += NFSX_UNSIGNED;
- nfsm_clget;
- *tl = txdr_unsigned(nlen);
- bp += NFSX_UNSIGNED;
-
- /* And loop around copying the name */
- xfer = nlen;
- cp = dp->d_name;
- while (xfer > 0) {
- nfsm_clget;
- if ((bp + xfer) > be)
- tsiz = be - bp;
- else
- tsiz = xfer;
- bcopy(cp, bp, tsiz);
- bp += tsiz;
- xfer -= tsiz;
- if (xfer > 0)
- cp += tsiz;
- }
- /* And null pad to a int32_t boundary */
- for (i = 0; i < rem; i++)
- *bp++ = '\0';
-
- /*
- * Now copy the flrep structure out.
- */
- xfer = sizeof (struct flrep);
- cp = (caddr_t)&fl;
- while (xfer > 0) {
- nfsm_clget;
- if ((bp + xfer) > be)
- tsiz = be - bp;
- else
- tsiz = xfer;
- bcopy(cp, bp, tsiz);
- bp += tsiz;
- xfer -= tsiz;
- if (xfer > 0)
- cp += tsiz;
- }
- }
-invalid:
- cpos += dp->d_reclen;
- dp = (struct dirent *)cpos;
- cookiep++;
- ncookies--;
- }
- vrele(vp);
- vp = NULL;
- nfsm_clget;
- *tl = nfs_false;
- bp += NFSX_UNSIGNED;
- nfsm_clget;
- if (eofflag)
- *tl = nfs_true;
- else
- *tl = nfs_false;
- bp += NFSX_UNSIGNED;
- if (mp != mb) {
- if (bp < be)
- mp->m_len = bp - mtod(mp, caddr_t);
- } else
- mp->m_len += bp - bpos;
- FREE((caddr_t)cookies, M_TEMP);
- FREE((caddr_t)rbuf, M_TEMP);
-nfsmout:
- if (vp)
- vrele(vp);
- return(error);
-}
-
-/*
- * nfs commit service
- */
-int
-nfsrv_commit(nfsd, slp, procp, mrq)
- struct nfsrv_descript *nfsd;
- struct nfssvc_sock *slp;
- struct proc *procp;
- struct mbuf **mrq;
-{
- struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md;
- struct sockaddr *nam = nfsd->nd_nam;
- caddr_t dpos = nfsd->nd_dpos;
- struct ucred *cred = &nfsd->nd_cr;
- struct vattr bfor, aft;
- struct vnode *vp = NULL;
- nfsfh_t nfh;
- fhandle_t *fhp;
- register u_int32_t *tl;
- register int32_t t1;
- caddr_t bpos;
- int error = 0, rdonly, for_ret = 1, aft_ret = 1, cnt, cache;
- char *cp2;
- struct mbuf *mb, *mb2, *mreq;
- u_quad_t frev, off;
-
- nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
-#ifndef nolint
- cache = 0;
-#endif
- fhp = &nfh.fh_generic;
- nfsm_srvmtofh(fhp);
- nfsm_dissect(tl, u_int32_t *, 3 * NFSX_UNSIGNED);
-
- /*
- * XXX At this time VOP_FSYNC() does not accept offset and byte
- * count parameters, so these arguments are useless (someday maybe).
- */
- off = fxdr_hyper(tl);
- tl += 2;
- cnt = fxdr_unsigned(int, *tl);
- error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam,
- &rdonly, (nfsd->nd_flag & ND_KERBAUTH), TRUE);
- if (error) {
- nfsm_reply(2 * NFSX_UNSIGNED);
- nfsm_srvwcc_data(for_ret, &bfor, aft_ret, &aft);
- error = 0;
- goto nfsmout;
- }
- for_ret = VOP_GETATTR(vp, &bfor, cred, procp);
-
- if (cnt > MAX_COMMIT_COUNT) {
- /*
- * Give up and do the whole thing
- */
- if (vp->v_object &&
- (vp->v_object->flags & OBJ_MIGHTBEDIRTY)) {
- vm_object_page_clean(vp->v_object, 0, 0, OBJPC_SYNC);
- }
- error = VOP_FSYNC(vp, cred, MNT_WAIT, procp);
- } else {
- /*
- * Locate and synchronously write any buffers that fall
- * into the requested range. Note: we are assuming that
- * f_iosize is a power of 2.
- */
- int iosize = vp->v_mount->mnt_stat.f_iosize;
- int iomask = iosize - 1;
- int s;
- daddr_t lblkno;
-
- /*
- * Align to iosize boundry, super-align to page boundry.
- */
- if (off & iomask) {
- cnt += off & iomask;
- off &= ~(u_quad_t)iomask;
- }
- if (off & PAGE_MASK) {
- cnt += off & PAGE_MASK;
- off &= ~(u_quad_t)PAGE_MASK;
- }
- lblkno = off / iosize;
-
- if (vp->v_object &&
- (vp->v_object->flags & OBJ_MIGHTBEDIRTY)) {
- vm_object_page_clean(vp->v_object, off / PAGE_SIZE, (cnt + PAGE_MASK) / PAGE_SIZE, OBJPC_SYNC);
- }
-
- s = splbio();
- while (cnt > 0) {
- struct buf *bp;
-
- /*
- * If we have a buffer and it is marked B_DELWRI we
- * have to lock and write it. Otherwise the prior
- * write is assumed to have already been committed.
- */
- if ((bp = gbincore(vp, lblkno)) != NULL && (bp->b_flags & B_DELWRI)) {
- if (BUF_LOCK(bp, LK_EXCLUSIVE | LK_NOWAIT)) {
- BUF_LOCK(bp, LK_EXCLUSIVE | LK_SLEEPFAIL);
- continue; /* retry */
- }
- bremfree(bp);
- bp->b_flags &= ~B_ASYNC;
- VOP_BWRITE(bp->b_vp, bp);
- ++nfs_commit_miss;
- }
- ++nfs_commit_blks;
- if (cnt < iosize)
- break;
- cnt -= iosize;
- ++lblkno;
- }
- splx(s);
- }
-
- aft_ret = VOP_GETATTR(vp, &aft, cred, procp);
- vput(vp);
- vp = NULL;
- nfsm_reply(NFSX_V3WCCDATA + NFSX_V3WRITEVERF);
- nfsm_srvwcc_data(for_ret, &bfor, aft_ret, &aft);
- if (!error) {
- nfsm_build(tl, u_int32_t *, NFSX_V3WRITEVERF);
- if (nfsver.tv_sec == 0)
- nfsver = boottime;
- *tl++ = txdr_unsigned(nfsver.tv_sec);
- *tl = txdr_unsigned(nfsver.tv_usec);
- } else {
- error = 0;
- }
-nfsmout:
- if (vp)
- vput(vp);
- return(error);
-}
-
-/*
- * nfs statfs service
- */
-int
-nfsrv_statfs(nfsd, slp, procp, mrq)
- struct nfsrv_descript *nfsd;
- struct nfssvc_sock *slp;
- struct proc *procp;
- struct mbuf **mrq;
-{
- struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md;
- struct sockaddr *nam = nfsd->nd_nam;
- caddr_t dpos = nfsd->nd_dpos;
- struct ucred *cred = &nfsd->nd_cr;
- register struct statfs *sf;
- register struct nfs_statfs *sfp;
- register u_int32_t *tl;
- register int32_t t1;
- caddr_t bpos;
- int error = 0, rdonly, cache, getret = 1;
- int v3 = (nfsd->nd_flag & ND_NFSV3);
- char *cp2;
- struct mbuf *mb, *mb2, *mreq;
- struct vnode *vp = NULL;
- struct vattr at;
- nfsfh_t nfh;
- fhandle_t *fhp;
- struct statfs statfs;
- u_quad_t frev, tval;
-
- nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
-#ifndef nolint
- cache = 0;
-#endif
- fhp = &nfh.fh_generic;
- nfsm_srvmtofh(fhp);
- error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam,
- &rdonly, (nfsd->nd_flag & ND_KERBAUTH), TRUE);
- if (error) {
- nfsm_reply(NFSX_UNSIGNED);
- nfsm_srvpostop_attr(getret, &at);
- error = 0;
- goto nfsmout;
- }
- sf = &statfs;
- error = VFS_STATFS(vp->v_mount, sf, procp);
- getret = VOP_GETATTR(vp, &at, cred, procp);
- vput(vp);
- vp = NULL;
- nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_STATFS(v3));
- if (v3)
- nfsm_srvpostop_attr(getret, &at);
- if (error) {
- error = 0;
- goto nfsmout;
- }
- nfsm_build(sfp, struct nfs_statfs *, NFSX_STATFS(v3));
- if (v3) {
- tval = (u_quad_t)sf->f_blocks;
- tval *= (u_quad_t)sf->f_bsize;
- txdr_hyper(tval, &sfp->sf_tbytes);
- tval = (u_quad_t)sf->f_bfree;
- tval *= (u_quad_t)sf->f_bsize;
- txdr_hyper(tval, &sfp->sf_fbytes);
- tval = (u_quad_t)sf->f_bavail;
- tval *= (u_quad_t)sf->f_bsize;
- txdr_hyper(tval, &sfp->sf_abytes);
- sfp->sf_tfiles.nfsuquad[0] = 0;
- sfp->sf_tfiles.nfsuquad[1] = txdr_unsigned(sf->f_files);
- sfp->sf_ffiles.nfsuquad[0] = 0;
- sfp->sf_ffiles.nfsuquad[1] = txdr_unsigned(sf->f_ffree);
- sfp->sf_afiles.nfsuquad[0] = 0;
- sfp->sf_afiles.nfsuquad[1] = txdr_unsigned(sf->f_ffree);
- sfp->sf_invarsec = 0;
- } else {
- sfp->sf_tsize = txdr_unsigned(NFS_MAXDGRAMDATA);
- sfp->sf_bsize = txdr_unsigned(sf->f_bsize);
- sfp->sf_blocks = txdr_unsigned(sf->f_blocks);
- sfp->sf_bfree = txdr_unsigned(sf->f_bfree);
- sfp->sf_bavail = txdr_unsigned(sf->f_bavail);
- }
-nfsmout:
- if (vp)
- vput(vp);
- return(error);
-}
-
-/*
- * nfs fsinfo service
- */
-int
-nfsrv_fsinfo(nfsd, slp, procp, mrq)
- struct nfsrv_descript *nfsd;
- struct nfssvc_sock *slp;
- struct proc *procp;
- struct mbuf **mrq;
-{
- struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md;
- struct sockaddr *nam = nfsd->nd_nam;
- caddr_t dpos = nfsd->nd_dpos;
- struct ucred *cred = &nfsd->nd_cr;
- register u_int32_t *tl;
- register struct nfsv3_fsinfo *sip;
- register int32_t t1;
- caddr_t bpos;
- int error = 0, rdonly, cache, getret = 1, pref;
- char *cp2;
- struct mbuf *mb, *mb2, *mreq;
- struct vnode *vp = NULL;
- struct vattr at;
- nfsfh_t nfh;
- fhandle_t *fhp;
- u_quad_t frev, maxfsize;
- struct statfs sb;
-
- nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
-#ifndef nolint
- cache = 0;
-#endif
- fhp = &nfh.fh_generic;
- nfsm_srvmtofh(fhp);
- error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam,
- &rdonly, (nfsd->nd_flag & ND_KERBAUTH), TRUE);
- if (error) {
- nfsm_reply(NFSX_UNSIGNED);
- nfsm_srvpostop_attr(getret, &at);
- error = 0;
- goto nfsmout;
- }
-
- /* XXX Try to make a guess on the max file size. */
- VFS_STATFS(vp->v_mount, &sb, procp);
- maxfsize = (u_quad_t)0x80000000 * sb.f_bsize - 1;
-
- getret = VOP_GETATTR(vp, &at, cred, procp);
- vput(vp);
- vp = NULL;
- nfsm_reply(NFSX_V3POSTOPATTR + NFSX_V3FSINFO);
- nfsm_srvpostop_attr(getret, &at);
- nfsm_build(sip, struct nfsv3_fsinfo *, NFSX_V3FSINFO);
-
- /*
- * XXX
- * There should be file system VFS OP(s) to get this information.
- * For now, assume ufs.
- */
- if (slp->ns_so->so_type == SOCK_DGRAM)
- pref = NFS_MAXDGRAMDATA;
- else
- pref = NFS_MAXDATA;
- sip->fs_rtmax = txdr_unsigned(NFS_MAXDATA);
- sip->fs_rtpref = txdr_unsigned(pref);
- sip->fs_rtmult = txdr_unsigned(NFS_FABLKSIZE);
- sip->fs_wtmax = txdr_unsigned(NFS_MAXDATA);
- sip->fs_wtpref = txdr_unsigned(pref);
- sip->fs_wtmult = txdr_unsigned(NFS_FABLKSIZE);
- sip->fs_dtpref = txdr_unsigned(pref);
- txdr_hyper(maxfsize, &sip->fs_maxfilesize);
- sip->fs_timedelta.nfsv3_sec = 0;
- sip->fs_timedelta.nfsv3_nsec = txdr_unsigned(1);
- sip->fs_properties = txdr_unsigned(NFSV3FSINFO_LINK |
- NFSV3FSINFO_SYMLINK | NFSV3FSINFO_HOMOGENEOUS |
- NFSV3FSINFO_CANSETTIME);
-nfsmout:
- if (vp)
- vput(vp);
- return(error);
-}
-
-/*
- * nfs pathconf service
- */
-int
-nfsrv_pathconf(nfsd, slp, procp, mrq)
- struct nfsrv_descript *nfsd;
- struct nfssvc_sock *slp;
- struct proc *procp;
- struct mbuf **mrq;
-{
- struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md;
- struct sockaddr *nam = nfsd->nd_nam;
- caddr_t dpos = nfsd->nd_dpos;
- struct ucred *cred = &nfsd->nd_cr;
- register u_int32_t *tl;
- register struct nfsv3_pathconf *pc;
- register int32_t t1;
- caddr_t bpos;
- int error = 0, rdonly, cache, getret = 1;
- register_t linkmax, namemax, chownres, notrunc;
- char *cp2;
- struct mbuf *mb, *mb2, *mreq;
- struct vnode *vp = NULL;
- struct vattr at;
- nfsfh_t nfh;
- fhandle_t *fhp;
- u_quad_t frev;
-
- nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
-#ifndef nolint
- cache = 0;
-#endif
- fhp = &nfh.fh_generic;
- nfsm_srvmtofh(fhp);
- error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam,
- &rdonly, (nfsd->nd_flag & ND_KERBAUTH), TRUE);
- if (error) {
- nfsm_reply(NFSX_UNSIGNED);
- nfsm_srvpostop_attr(getret, &at);
- error = 0;
- goto nfsmout;
- }
- error = VOP_PATHCONF(vp, _PC_LINK_MAX, &linkmax);
- if (!error)
- error = VOP_PATHCONF(vp, _PC_NAME_MAX, &namemax);
- if (!error)
- error = VOP_PATHCONF(vp, _PC_CHOWN_RESTRICTED, &chownres);
- if (!error)
- error = VOP_PATHCONF(vp, _PC_NO_TRUNC, &notrunc);
- getret = VOP_GETATTR(vp, &at, cred, procp);
- vput(vp);
- vp = NULL;
- nfsm_reply(NFSX_V3POSTOPATTR + NFSX_V3PATHCONF);
- nfsm_srvpostop_attr(getret, &at);
- if (error) {
- error = 0;
- goto nfsmout;
- }
- nfsm_build(pc, struct nfsv3_pathconf *, NFSX_V3PATHCONF);
-
- pc->pc_linkmax = txdr_unsigned(linkmax);
- pc->pc_namemax = txdr_unsigned(namemax);
- pc->pc_notrunc = txdr_unsigned(notrunc);
- pc->pc_chownrestricted = txdr_unsigned(chownres);
-
- /*
- * These should probably be supported by VOP_PATHCONF(), but
- * until msdosfs is exportable (why would you want to?), the
- * Unix defaults should be ok.
- */
- pc->pc_caseinsensitive = nfs_false;
- pc->pc_casepreserving = nfs_true;
-nfsmout:
- if (vp)
- vput(vp);
- return(error);
-}
-
-/*
- * Null operation, used by clients to ping server
- */
-/* ARGSUSED */
-int
-nfsrv_null(nfsd, slp, procp, mrq)
- struct nfsrv_descript *nfsd;
- struct nfssvc_sock *slp;
- struct proc *procp;
- struct mbuf **mrq;
-{
- struct mbuf *mrep = nfsd->nd_mrep;
- caddr_t bpos;
- int error = NFSERR_RETVOID, cache;
- struct mbuf *mb, *mreq;
- u_quad_t frev;
-
- nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
-#ifndef nolint
- cache = 0;
-#endif
- nfsm_reply(0);
- nfsm_srvdone;
-}
-
-/*
- * No operation, used for obsolete procedures
- */
-/* ARGSUSED */
-int
-nfsrv_noop(nfsd, slp, procp, mrq)
- struct nfsrv_descript *nfsd;
- struct nfssvc_sock *slp;
- struct proc *procp;
- struct mbuf **mrq;
-{
- struct mbuf *mrep = nfsd->nd_mrep;
- caddr_t bpos;
- int error, cache;
- struct mbuf *mb, *mreq;
- u_quad_t frev;
-
- nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
-#ifndef nolint
- cache = 0;
-#endif
- if (nfsd->nd_repstat)
- error = nfsd->nd_repstat;
- else
- error = EPROCUNAVAIL;
- nfsm_reply(0);
- nfsm_srvdone;
-}
-
-/*
- * Perform access checking for vnodes obtained from file handles that would
- * refer to files already opened by a Unix client. You cannot just use
- * vn_writechk() and VOP_ACCESS() for two reasons.
- * 1 - You must check for exported rdonly as well as MNT_RDONLY for the write case
- * 2 - The owner is to be given access irrespective of mode bits for some
- * operations, so that processes that chmod after opening a file don't
- * break. I don't like this because it opens a security hole, but since
- * the nfs server opens a security hole the size of a barn door anyhow,
- * what the heck.
- *
- * The exception to rule 2 is EPERM. If a file is IMMUTABLE, VOP_ACCESS()
- * will return EPERM instead of EACCESS. EPERM is always an error.
- */
-static int
-nfsrv_access(vp, flags, cred, rdonly, p, override)
- register struct vnode *vp;
- int flags;
- register struct ucred *cred;
- int rdonly;
- struct proc *p;
- int override;
-{
- struct vattr vattr;
- int error;
-
- nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
- if (flags & VWRITE) {
- /* Just vn_writechk() changed to check rdonly */
- /*
- * Disallow write attempts on read-only file systems;
- * unless the file is a socket or a block or character
- * device resident on the file system.
- */
- if (rdonly || (vp->v_mount->mnt_flag & MNT_RDONLY)) {
- switch (vp->v_type) {
- case VREG:
- case VDIR:
- case VLNK:
- return (EROFS);
- default:
- break;
- }
- }
- /*
- * If there's shared text associated with
- * the inode, we can't allow writing.
- */
- if (vp->v_flag & VTEXT)
- return (ETXTBSY);
- }
- error = VOP_GETATTR(vp, &vattr, cred, p);
- if (error)
- return (error);
- error = VOP_ACCESS(vp, flags, cred, p);
- /*
- * Allow certain operations for the owner (reads and writes
- * on files that are already open).
- */
- if (override && error == EACCES && cred->cr_uid == vattr.va_uid)
- error = 0;
- return error;
-}
-#endif /* NFS_NOSERVER */
-
diff --git a/sys/nfsserver/nfs_srvcache.c b/sys/nfsserver/nfs_srvcache.c
deleted file mode 100644
index 9eb168f6086e..000000000000
--- a/sys/nfsserver/nfs_srvcache.c
+++ /dev/null
@@ -1,353 +0,0 @@
-/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Rick Macklem at The University of Guelph.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)nfs_srvcache.c 8.3 (Berkeley) 3/30/95
- * $FreeBSD$
- */
-
-/*
- * Reference: Chet Juszczak, "Improving the Performance and Correctness
- * of an NFS Server", in Proc. Winter 1989 USENIX Conference,
- * pages 53-63. San Diego, February 1989.
- */
-#include <sys/param.h>
-#include <sys/malloc.h>
-#include <sys/mount.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h> /* for dup_sockaddr */
-
-#include <netinet/in.h>
-#include <nfs/rpcv2.h>
-#include <nfs/nfsproto.h>
-#include <nfs/nfs.h>
-#include <nfs/nfsrvcache.h>
-
-#ifndef NFS_NOSERVER
-extern struct nfsstats nfsstats;
-extern int nfsv2_procid[NFS_NPROCS];
-static long numnfsrvcache;
-static long desirednfsrvcache = NFSRVCACHESIZ;
-
-#define NFSRCHASH(xid) \
- (&nfsrvhashtbl[((xid) + ((xid) >> 24)) & nfsrvhash])
-static LIST_HEAD(nfsrvhash, nfsrvcache) *nfsrvhashtbl;
-static TAILQ_HEAD(nfsrvlru, nfsrvcache) nfsrvlruhead;
-static u_long nfsrvhash;
-
-#define TRUE 1
-#define FALSE 0
-
-#define NETFAMILY(rp) \
- (((rp)->rc_flag & RC_INETADDR) ? AF_INET : AF_ISO)
-
-/*
- * Static array that defines which nfs rpc's are nonidempotent
- */
-static int nonidempotent[NFS_NPROCS] = {
- FALSE,
- FALSE,
- TRUE,
- FALSE,
- FALSE,
- FALSE,
- FALSE,
- TRUE,
- TRUE,
- TRUE,
- TRUE,
- TRUE,
- TRUE,
- TRUE,
- TRUE,
- TRUE,
- FALSE,
- FALSE,
- FALSE,
- FALSE,
- FALSE,
- FALSE,
- FALSE,
- FALSE,
- FALSE,
- FALSE,
-};
-
-/* True iff the rpc reply is an nfs status ONLY! */
-static int nfsv2_repstat[NFS_NPROCS] = {
- FALSE,
- FALSE,
- FALSE,
- FALSE,
- FALSE,
- FALSE,
- FALSE,
- FALSE,
- FALSE,
- FALSE,
- TRUE,
- TRUE,
- TRUE,
- TRUE,
- FALSE,
- TRUE,
- FALSE,
- FALSE,
-};
-
-/*
- * Initialize the server request cache list
- */
-void
-nfsrv_initcache()
-{
-
- nfsrvhashtbl = hashinit(desirednfsrvcache, M_NFSD, &nfsrvhash);
- TAILQ_INIT(&nfsrvlruhead);
-}
-
-/*
- * Look for the request in the cache
- * If found then
- * return action and optionally reply
- * else
- * insert it in the cache
- *
- * The rules are as follows:
- * - if in progress, return DROP request
- * - if completed within DELAY of the current time, return DROP it
- * - if completed a longer time ago return REPLY if the reply was cached or
- * return DOIT
- * Update/add new request at end of lru list
- */
-int
-nfsrv_getcache(nd, slp, repp)
- register struct nfsrv_descript *nd;
- struct nfssvc_sock *slp;
- struct mbuf **repp;
-{
- register struct nfsrvcache *rp;
- struct mbuf *mb;
- struct sockaddr_in *saddr;
- caddr_t bpos;
- int ret;
-
- /*
- * Don't cache recent requests for reliable transport protocols.
- * (Maybe we should for the case of a reconnect, but..)
- */
- if (!nd->nd_nam2)
- return (RC_DOIT);
-loop:
- for (rp = NFSRCHASH(nd->nd_retxid)->lh_first; rp != 0;
- rp = rp->rc_hash.le_next) {
- if (nd->nd_retxid == rp->rc_xid && nd->nd_procnum == rp->rc_proc &&
- netaddr_match(NETFAMILY(rp), &rp->rc_haddr, nd->nd_nam)) {
- NFS_DPF(RC, ("H%03x", rp->rc_xid & 0xfff));
- if ((rp->rc_flag & RC_LOCKED) != 0) {
- rp->rc_flag |= RC_WANTED;
- (void) tsleep((caddr_t)rp, PZERO-1, "nfsrc", 0);
- goto loop;
- }
- rp->rc_flag |= RC_LOCKED;
- /* If not at end of LRU chain, move it there */
- if (rp->rc_lru.tqe_next) {
- TAILQ_REMOVE(&nfsrvlruhead, rp, rc_lru);
- TAILQ_INSERT_TAIL(&nfsrvlruhead, rp, rc_lru);
- }
- if (rp->rc_state == RC_UNUSED)
- panic("nfsrv cache");
- if (rp->rc_state == RC_INPROG) {
- nfsstats.srvcache_inproghits++;
- ret = RC_DROPIT;
- } else if (rp->rc_flag & RC_REPSTATUS) {
- nfsstats.srvcache_nonidemdonehits++;
- nfs_rephead(0, nd, slp, rp->rc_status,
- 0, (u_quad_t *)0, repp, &mb, &bpos);
- ret = RC_REPLY;
- } else if (rp->rc_flag & RC_REPMBUF) {
- nfsstats.srvcache_nonidemdonehits++;
- *repp = m_copym(rp->rc_reply, 0, M_COPYALL,
- M_WAIT);
- ret = RC_REPLY;
- } else {
- nfsstats.srvcache_idemdonehits++;
- rp->rc_state = RC_INPROG;
- ret = RC_DOIT;
- }
- rp->rc_flag &= ~RC_LOCKED;
- if (rp->rc_flag & RC_WANTED) {
- rp->rc_flag &= ~RC_WANTED;
- wakeup((caddr_t)rp);
- }
- return (ret);
- }
- }
- nfsstats.srvcache_misses++;
- NFS_DPF(RC, ("M%03x", nd->nd_retxid & 0xfff));
- if (numnfsrvcache < desirednfsrvcache) {
- rp = (struct nfsrvcache *)malloc((u_long)sizeof *rp,
- M_NFSD, M_WAITOK);
- bzero((char *)rp, sizeof *rp);
- numnfsrvcache++;
- rp->rc_flag = RC_LOCKED;
- } else {
- rp = nfsrvlruhead.tqh_first;
- while ((rp->rc_flag & RC_LOCKED) != 0) {
- rp->rc_flag |= RC_WANTED;
- (void) tsleep((caddr_t)rp, PZERO-1, "nfsrc", 0);
- rp = nfsrvlruhead.tqh_first;
- }
- rp->rc_flag |= RC_LOCKED;
- LIST_REMOVE(rp, rc_hash);
- TAILQ_REMOVE(&nfsrvlruhead, rp, rc_lru);
- if (rp->rc_flag & RC_REPMBUF)
- m_freem(rp->rc_reply);
- if (rp->rc_flag & RC_NAM)
- FREE(rp->rc_nam, M_SONAME);
- rp->rc_flag &= (RC_LOCKED | RC_WANTED);
- }
- TAILQ_INSERT_TAIL(&nfsrvlruhead, rp, rc_lru);
- rp->rc_state = RC_INPROG;
- rp->rc_xid = nd->nd_retxid;
- saddr = (struct sockaddr_in *)nd->nd_nam;
- switch (saddr->sin_family) {
- case AF_INET:
- rp->rc_flag |= RC_INETADDR;
- rp->rc_inetaddr = saddr->sin_addr.s_addr;
- break;
- case AF_ISO:
- default:
- rp->rc_flag |= RC_NAM;
- rp->rc_nam = dup_sockaddr(nd->nd_nam, 1);
- break;
- };
- rp->rc_proc = nd->nd_procnum;
- LIST_INSERT_HEAD(NFSRCHASH(nd->nd_retxid), rp, rc_hash);
- rp->rc_flag &= ~RC_LOCKED;
- if (rp->rc_flag & RC_WANTED) {
- rp->rc_flag &= ~RC_WANTED;
- wakeup((caddr_t)rp);
- }
- return (RC_DOIT);
-}
-
-/*
- * Update a request cache entry after the rpc has been done
- */
-void
-nfsrv_updatecache(nd, repvalid, repmbuf)
- register struct nfsrv_descript *nd;
- int repvalid;
- struct mbuf *repmbuf;
-{
- register struct nfsrvcache *rp;
-
- if (!nd->nd_nam2)
- return;
-loop:
- for (rp = NFSRCHASH(nd->nd_retxid)->lh_first; rp != 0;
- rp = rp->rc_hash.le_next) {
- if (nd->nd_retxid == rp->rc_xid && nd->nd_procnum == rp->rc_proc &&
- netaddr_match(NETFAMILY(rp), &rp->rc_haddr, nd->nd_nam)) {
- NFS_DPF(RC, ("U%03x", rp->rc_xid & 0xfff));
- if ((rp->rc_flag & RC_LOCKED) != 0) {
- rp->rc_flag |= RC_WANTED;
- (void) tsleep((caddr_t)rp, PZERO-1, "nfsrc", 0);
- goto loop;
- }
- rp->rc_flag |= RC_LOCKED;
- if (rp->rc_state == RC_DONE) {
- /*
- * This can occur if the cache is too small.
- * Retransmits of the same request aren't
- * dropped so we may see the operation
- * complete more then once.
- */
- if (rp->rc_flag & RC_REPMBUF) {
- m_freem(rp->rc_reply);
- rp->rc_flag &= ~RC_REPMBUF;
- }
- }
- rp->rc_state = RC_DONE;
- /*
- * If we have a valid reply update status and save
- * the reply for non-idempotent rpc's.
- */
- if (repvalid && nonidempotent[nd->nd_procnum]) {
- if ((nd->nd_flag & ND_NFSV3) == 0 &&
- nfsv2_repstat[nfsv2_procid[nd->nd_procnum]]) {
- rp->rc_status = nd->nd_repstat;
- rp->rc_flag |= RC_REPSTATUS;
- } else {
- rp->rc_reply = m_copym(repmbuf,
- 0, M_COPYALL, M_WAIT);
- rp->rc_flag |= RC_REPMBUF;
- }
- }
- rp->rc_flag &= ~RC_LOCKED;
- if (rp->rc_flag & RC_WANTED) {
- rp->rc_flag &= ~RC_WANTED;
- wakeup((caddr_t)rp);
- }
- return;
- }
- }
- NFS_DPF(RC, ("L%03x", nd->nd_retxid & 0xfff));
-}
-
-/*
- * Clean out the cache. Called when the last nfsd terminates.
- */
-void
-nfsrv_cleancache()
-{
- register struct nfsrvcache *rp, *nextrp;
-
- for (rp = nfsrvlruhead.tqh_first; rp != 0; rp = nextrp) {
- nextrp = rp->rc_lru.tqe_next;
- LIST_REMOVE(rp, rc_hash);
- TAILQ_REMOVE(&nfsrvlruhead, rp, rc_lru);
- if (rp->rc_flag & RC_REPMBUF)
- m_freem(rp->rc_reply);
- if (rp->rc_flag & RC_NAM)
- free(rp->rc_nam, M_SONAME);
- free(rp, M_NFSD);
- }
- numnfsrvcache = 0;
-}
-
-#endif /* NFS_NOSERVER */
diff --git a/sys/nfsserver/nfs_srvsock.c b/sys/nfsserver/nfs_srvsock.c
deleted file mode 100644
index b2d6bf53dbe3..000000000000
--- a/sys/nfsserver/nfs_srvsock.c
+++ /dev/null
@@ -1,2284 +0,0 @@
-/*
- * Copyright (c) 1989, 1991, 1993, 1995
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Rick Macklem at The University of Guelph.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)nfs_socket.c 8.5 (Berkeley) 3/30/95
- * $FreeBSD$
- */
-
-/*
- * Socket operations for use by nfs
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/proc.h>
-#include <sys/malloc.h>
-#include <sys/mount.h>
-#include <sys/kernel.h>
-#include <sys/mbuf.h>
-#include <sys/vnode.h>
-#include <sys/protosw.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-#include <sys/syslog.h>
-#include <sys/tprintf.h>
-#include <sys/sysctl.h>
-#include <sys/signalvar.h>
-
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-
-#include <nfs/rpcv2.h>
-#include <nfs/nfsproto.h>
-#include <nfs/nfs.h>
-#include <nfs/xdr_subs.h>
-#include <nfs/nfsm_subs.h>
-#include <nfs/nfsmount.h>
-#include <nfs/nfsnode.h>
-#include <nfs/nfsrtt.h>
-#include <nfs/nqnfs.h>
-
-#define TRUE 1
-#define FALSE 0
-
-/*
- * Estimate rto for an nfs rpc sent via. an unreliable datagram.
- * Use the mean and mean deviation of rtt for the appropriate type of rpc
- * for the frequent rpcs and a default for the others.
- * The justification for doing "other" this way is that these rpcs
- * happen so infrequently that timer est. would probably be stale.
- * Also, since many of these rpcs are
- * non-idempotent, a conservative timeout is desired.
- * getattr, lookup - A+2D
- * read, write - A+4D
- * other - nm_timeo
- */
-#define NFS_RTO(n, t) \
- ((t) == 0 ? (n)->nm_timeo : \
- ((t) < 3 ? \
- (((((n)->nm_srtt[t-1] + 3) >> 2) + (n)->nm_sdrtt[t-1] + 1) >> 1) : \
- ((((n)->nm_srtt[t-1] + 7) >> 3) + (n)->nm_sdrtt[t-1] + 1)))
-#define NFS_SRTT(r) (r)->r_nmp->nm_srtt[proct[(r)->r_procnum] - 1]
-#define NFS_SDRTT(r) (r)->r_nmp->nm_sdrtt[proct[(r)->r_procnum] - 1]
-/*
- * External data, mostly RPC constants in XDR form
- */
-extern u_int32_t rpc_reply, rpc_msgdenied, rpc_mismatch, rpc_vers,
- rpc_auth_unix, rpc_msgaccepted, rpc_call, rpc_autherr,
- rpc_auth_kerb;
-extern u_int32_t nfs_prog, nqnfs_prog;
-extern time_t nqnfsstarttime;
-extern struct nfsstats nfsstats;
-extern int nfsv3_procid[NFS_NPROCS];
-extern int nfs_ticks;
-
-/*
- * Defines which timer to use for the procnum.
- * 0 - default
- * 1 - getattr
- * 2 - lookup
- * 3 - read
- * 4 - write
- */
-static int proct[NFS_NPROCS] = {
- 0, 1, 0, 2, 1, 3, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 0, 0, 0, 0, 0,
- 0, 0, 0,
-};
-
-static int nfs_realign_test;
-static int nfs_realign_count;
-
-SYSCTL_DECL(_vfs_nfs);
-
-SYSCTL_INT(_vfs_nfs, OID_AUTO, realign_test, CTLFLAG_RD, &nfs_realign_test, 0, "");
-SYSCTL_INT(_vfs_nfs, OID_AUTO, realign_count, CTLFLAG_RD, &nfs_realign_count, 0, "");
-
-
-/*
- * There is a congestion window for outstanding rpcs maintained per mount
- * point. The cwnd size is adjusted in roughly the way that:
- * Van Jacobson, Congestion avoidance and Control, In "Proceedings of
- * SIGCOMM '88". ACM, August 1988.
- * describes for TCP. The cwnd size is chopped in half on a retransmit timeout
- * and incremented by 1/cwnd when each rpc reply is received and a full cwnd
- * of rpcs is in progress.
- * (The sent count and cwnd are scaled for integer arith.)
- * Variants of "slow start" were tried and were found to be too much of a
- * performance hit (ave. rtt 3 times larger),
- * I suspect due to the large rtt that nfs rpcs have.
- */
-#define NFS_CWNDSCALE 256
-#define NFS_MAXCWND (NFS_CWNDSCALE * 32)
-static int nfs_backoff[8] = { 2, 4, 8, 16, 32, 64, 128, 256, };
-int nfsrtton = 0;
-struct nfsrtt nfsrtt;
-struct callout_handle nfs_timer_handle;
-
-static int nfs_msg __P((struct proc *,char *,char *));
-static int nfs_rcvlock __P((struct nfsreq *));
-static void nfs_rcvunlock __P((struct nfsreq *));
-static void nfs_realign __P((struct mbuf **pm, int hsiz));
-static int nfs_receive __P((struct nfsreq *rep, struct sockaddr **aname,
- struct mbuf **mp));
-static void nfs_softterm __P((struct nfsreq *rep));
-static int nfs_reconnect __P((struct nfsreq *rep));
-#ifndef NFS_NOSERVER
-static int nfsrv_getstream __P((struct nfssvc_sock *,int));
-
-int (*nfsrv3_procs[NFS_NPROCS]) __P((struct nfsrv_descript *nd,
- struct nfssvc_sock *slp,
- struct proc *procp,
- struct mbuf **mreqp)) = {
- nfsrv_null,
- nfsrv_getattr,
- nfsrv_setattr,
- nfsrv_lookup,
- nfsrv3_access,
- nfsrv_readlink,
- nfsrv_read,
- nfsrv_write,
- nfsrv_create,
- nfsrv_mkdir,
- nfsrv_symlink,
- nfsrv_mknod,
- nfsrv_remove,
- nfsrv_rmdir,
- nfsrv_rename,
- nfsrv_link,
- nfsrv_readdir,
- nfsrv_readdirplus,
- nfsrv_statfs,
- nfsrv_fsinfo,
- nfsrv_pathconf,
- nfsrv_commit,
- nqnfsrv_getlease,
- nqnfsrv_vacated,
- nfsrv_noop,
- nfsrv_noop
-};
-#endif /* NFS_NOSERVER */
-
-/*
- * Initialize sockets and congestion for a new NFS connection.
- * We do not free the sockaddr if error.
- */
-int
-nfs_connect(nmp, rep)
- register struct nfsmount *nmp;
- struct nfsreq *rep;
-{
- register struct socket *so;
- int s, error, rcvreserve, sndreserve;
- struct sockaddr *saddr;
- struct sockaddr_in *sin;
- struct proc *p = &proc0; /* only used for socreate and sobind */
-
- nmp->nm_so = (struct socket *)0;
- saddr = nmp->nm_nam;
- error = socreate(saddr->sa_family, &nmp->nm_so, nmp->nm_sotype,
- nmp->nm_soproto, p);
- if (error)
- goto bad;
- so = nmp->nm_so;
- nmp->nm_soflags = so->so_proto->pr_flags;
-
- /*
- * Some servers require that the client port be a reserved port number.
- */
- if (saddr->sa_family == AF_INET && (nmp->nm_flag & NFSMNT_RESVPORT)) {
- struct sockopt sopt;
- int ip;
- struct sockaddr_in ssin;
-
- bzero(&sopt, sizeof sopt);
- ip = IP_PORTRANGE_LOW;
- sopt.sopt_dir = SOPT_SET;
- sopt.sopt_level = IPPROTO_IP;
- sopt.sopt_name = IP_PORTRANGE;
- sopt.sopt_val = (void *)&ip;
- sopt.sopt_valsize = sizeof(ip);
- sopt.sopt_p = NULL;
- error = sosetopt(so, &sopt);
- if (error)
- goto bad;
- bzero(&ssin, sizeof ssin);
- sin = &ssin;
- sin->sin_len = sizeof (struct sockaddr_in);
- sin->sin_family = AF_INET;
- sin->sin_addr.s_addr = INADDR_ANY;
- sin->sin_port = htons(0);
- error = sobind(so, (struct sockaddr *)sin, p);
- if (error)
- goto bad;
- bzero(&sopt, sizeof sopt);
- ip = IP_PORTRANGE_DEFAULT;
- sopt.sopt_dir = SOPT_SET;
- sopt.sopt_level = IPPROTO_IP;
- sopt.sopt_name = IP_PORTRANGE;
- sopt.sopt_val = (void *)&ip;
- sopt.sopt_valsize = sizeof(ip);
- sopt.sopt_p = NULL;
- error = sosetopt(so, &sopt);
- if (error)
- goto bad;
- }
-
- /*
- * Protocols that do not require connections may be optionally left
- * unconnected for servers that reply from a port other than NFS_PORT.
- */
- if (nmp->nm_flag & NFSMNT_NOCONN) {
- if (nmp->nm_soflags & PR_CONNREQUIRED) {
- error = ENOTCONN;
- goto bad;
- }
- } else {
- error = soconnect(so, nmp->nm_nam, p);
- if (error)
- goto bad;
-
- /*
- * Wait for the connection to complete. Cribbed from the
- * connect system call but with the wait timing out so
- * that interruptible mounts don't hang here for a long time.
- */
- s = splnet();
- while ((so->so_state & SS_ISCONNECTING) && so->so_error == 0) {
- (void) tsleep((caddr_t)&so->so_timeo, PSOCK,
- "nfscon", 2 * hz);
- if ((so->so_state & SS_ISCONNECTING) &&
- so->so_error == 0 && rep &&
- (error = nfs_sigintr(nmp, rep, rep->r_procp)) != 0){
- so->so_state &= ~SS_ISCONNECTING;
- splx(s);
- goto bad;
- }
- }
- if (so->so_error) {
- error = so->so_error;
- so->so_error = 0;
- splx(s);
- goto bad;
- }
- splx(s);
- }
- if (nmp->nm_flag & (NFSMNT_SOFT | NFSMNT_INT)) {
- so->so_rcv.sb_timeo = (5 * hz);
- so->so_snd.sb_timeo = (5 * hz);
- } else {
- so->so_rcv.sb_timeo = 0;
- so->so_snd.sb_timeo = 0;
- }
- if (nmp->nm_sotype == SOCK_DGRAM) {
- sndreserve = (nmp->nm_wsize + NFS_MAXPKTHDR) * 2;
- rcvreserve = (max(nmp->nm_rsize, nmp->nm_readdirsize) +
- NFS_MAXPKTHDR) * 2;
- } else if (nmp->nm_sotype == SOCK_SEQPACKET) {
- sndreserve = (nmp->nm_wsize + NFS_MAXPKTHDR) * 2;
- rcvreserve = (max(nmp->nm_rsize, nmp->nm_readdirsize) +
- NFS_MAXPKTHDR) * 2;
- } else {
- if (nmp->nm_sotype != SOCK_STREAM)
- panic("nfscon sotype");
- if (so->so_proto->pr_flags & PR_CONNREQUIRED) {
- struct sockopt sopt;
- int val;
-
- bzero(&sopt, sizeof sopt);
- sopt.sopt_level = SOL_SOCKET;
- sopt.sopt_name = SO_KEEPALIVE;
- sopt.sopt_val = &val;
- sopt.sopt_valsize = sizeof val;
- val = 1;
- sosetopt(so, &sopt);
- }
- if (so->so_proto->pr_protocol == IPPROTO_TCP) {
- struct sockopt sopt;
- int val;
-
- bzero(&sopt, sizeof sopt);
- sopt.sopt_level = IPPROTO_TCP;
- sopt.sopt_name = TCP_NODELAY;
- sopt.sopt_val = &val;
- sopt.sopt_valsize = sizeof val;
- val = 1;
- sosetopt(so, &sopt);
- }
- sndreserve = (nmp->nm_wsize + NFS_MAXPKTHDR +
- sizeof (u_int32_t)) * 2;
- rcvreserve = (nmp->nm_rsize + NFS_MAXPKTHDR +
- sizeof (u_int32_t)) * 2;
- }
- error = soreserve(so, sndreserve, rcvreserve);
- if (error)
- goto bad;
- so->so_rcv.sb_flags |= SB_NOINTR;
- so->so_snd.sb_flags |= SB_NOINTR;
-
- /* Initialize other non-zero congestion variables */
- nmp->nm_srtt[0] = nmp->nm_srtt[1] = nmp->nm_srtt[2] =
- nmp->nm_srtt[3] = (NFS_TIMEO << 3);
- nmp->nm_sdrtt[0] = nmp->nm_sdrtt[1] = nmp->nm_sdrtt[2] =
- nmp->nm_sdrtt[3] = 0;
- nmp->nm_cwnd = NFS_MAXCWND / 2; /* Initial send window */
- nmp->nm_sent = 0;
- nmp->nm_timeouts = 0;
- return (0);
-
-bad:
- nfs_disconnect(nmp);
- return (error);
-}
-
-/*
- * Reconnect routine:
- * Called when a connection is broken on a reliable protocol.
- * - clean up the old socket
- * - nfs_connect() again
- * - set R_MUSTRESEND for all outstanding requests on mount point
- * If this fails the mount point is DEAD!
- * nb: Must be called with the nfs_sndlock() set on the mount point.
- */
-static int
-nfs_reconnect(rep)
- register struct nfsreq *rep;
-{
- register struct nfsreq *rp;
- register struct nfsmount *nmp = rep->r_nmp;
- int error;
-
- nfs_disconnect(nmp);
- while ((error = nfs_connect(nmp, rep)) != 0) {
- if (error == EINTR || error == ERESTART)
- return (EINTR);
- (void) tsleep((caddr_t)&lbolt, PSOCK, "nfscon", 0);
- }
-
- /*
- * Loop through outstanding request list and fix up all requests
- * on old socket.
- */
- for (rp = nfs_reqq.tqh_first; rp != 0; rp = rp->r_chain.tqe_next) {
- if (rp->r_nmp == nmp)
- rp->r_flags |= R_MUSTRESEND;
- }
- return (0);
-}
-
-/*
- * NFS disconnect. Clean up and unlink.
- */
-void
-nfs_disconnect(nmp)
- register struct nfsmount *nmp;
-{
- register struct socket *so;
-
- if (nmp->nm_so) {
- so = nmp->nm_so;
- nmp->nm_so = (struct socket *)0;
- soshutdown(so, 2);
- soclose(so);
- }
-}
-
-void
-nfs_safedisconnect(nmp)
- struct nfsmount *nmp;
-{
- struct nfsreq dummyreq;
-
- bzero(&dummyreq, sizeof(dummyreq));
- dummyreq.r_nmp = nmp;
- nfs_rcvlock(&dummyreq);
- nfs_disconnect(nmp);
- nfs_rcvunlock(&dummyreq);
-}
-
-/*
- * This is the nfs send routine. For connection based socket types, it
- * must be called with an nfs_sndlock() on the socket.
- * "rep == NULL" indicates that it has been called from a server.
- * For the client side:
- * - return EINTR if the RPC is terminated, 0 otherwise
- * - set R_MUSTRESEND if the send fails for any reason
- * - do any cleanup required by recoverable socket errors (?)
- * For the server side:
- * - return EINTR or ERESTART if interrupted by a signal
- * - return EPIPE if a connection is lost for connection based sockets (TCP...)
- * - do any cleanup required by recoverable socket errors (?)
- */
-int
-nfs_send(so, nam, top, rep)
- register struct socket *so;
- struct sockaddr *nam;
- register struct mbuf *top;
- struct nfsreq *rep;
-{
- struct sockaddr *sendnam;
- int error, soflags, flags;
-
- if (rep) {
- if (rep->r_flags & R_SOFTTERM) {
- m_freem(top);
- return (EINTR);
- }
- if ((so = rep->r_nmp->nm_so) == NULL) {
- rep->r_flags |= R_MUSTRESEND;
- m_freem(top);
- return (0);
- }
- rep->r_flags &= ~R_MUSTRESEND;
- soflags = rep->r_nmp->nm_soflags;
- } else
- soflags = so->so_proto->pr_flags;
- if ((soflags & PR_CONNREQUIRED) || (so->so_state & SS_ISCONNECTED))
- sendnam = (struct sockaddr *)0;
- else
- sendnam = nam;
- if (so->so_type == SOCK_SEQPACKET)
- flags = MSG_EOR;
- else
- flags = 0;
-
- error = so->so_proto->pr_usrreqs->pru_sosend(so, sendnam, 0, top, 0,
- flags, curproc /*XXX*/);
- /*
- * ENOBUFS for dgram sockets is transient and non fatal.
- * No need to log, and no need to break a soft mount.
- */
- if (error == ENOBUFS && so->so_type == SOCK_DGRAM) {
- error = 0;
- if (rep) /* do backoff retransmit on client */
- rep->r_flags |= R_MUSTRESEND;
- }
-
- if (error) {
- if (rep) {
- log(LOG_INFO, "nfs send error %d for server %s\n",error,
- rep->r_nmp->nm_mountp->mnt_stat.f_mntfromname);
- /*
- * Deal with errors for the client side.
- */
- if (rep->r_flags & R_SOFTTERM)
- error = EINTR;
- else
- rep->r_flags |= R_MUSTRESEND;
- } else
- log(LOG_INFO, "nfsd send error %d\n", error);
-
- /*
- * Handle any recoverable (soft) socket errors here. (?)
- */
- if (error != EINTR && error != ERESTART &&
- error != EWOULDBLOCK && error != EPIPE)
- error = 0;
- }
- return (error);
-}
-
-/*
- * Receive a Sun RPC Request/Reply. For SOCK_DGRAM, the work is all
- * done by soreceive(), but for SOCK_STREAM we must deal with the Record
- * Mark and consolidate the data into a new mbuf list.
- * nb: Sometimes TCP passes the data up to soreceive() in long lists of
- * small mbufs.
- * For SOCK_STREAM we must be very careful to read an entire record once
- * we have read any of it, even if the system call has been interrupted.
- */
-static int
-nfs_receive(rep, aname, mp)
- register struct nfsreq *rep;
- struct sockaddr **aname;
- struct mbuf **mp;
-{
- register struct socket *so;
- struct uio auio;
- struct iovec aio;
- register struct mbuf *m;
- struct mbuf *control;
- u_int32_t len;
- struct sockaddr **getnam;
- int error, sotype, rcvflg;
- struct proc *p = curproc; /* XXX */
-
- /*
- * Set up arguments for soreceive()
- */
- *mp = (struct mbuf *)0;
- *aname = (struct sockaddr *)0;
- sotype = rep->r_nmp->nm_sotype;
-
- /*
- * For reliable protocols, lock against other senders/receivers
- * in case a reconnect is necessary.
- * For SOCK_STREAM, first get the Record Mark to find out how much
- * more there is to get.
- * We must lock the socket against other receivers
- * until we have an entire rpc request/reply.
- */
- if (sotype != SOCK_DGRAM) {
- error = nfs_sndlock(rep);
- if (error)
- return (error);
-tryagain:
- /*
- * Check for fatal errors and resending request.
- */
- /*
- * Ugh: If a reconnect attempt just happened, nm_so
- * would have changed. NULL indicates a failed
- * attempt that has essentially shut down this
- * mount point.
- */
- if (rep->r_mrep || (rep->r_flags & R_SOFTTERM)) {
- nfs_sndunlock(rep);
- return (EINTR);
- }
- so = rep->r_nmp->nm_so;
- if (!so) {
- error = nfs_reconnect(rep);
- if (error) {
- nfs_sndunlock(rep);
- return (error);
- }
- goto tryagain;
- }
- while (rep->r_flags & R_MUSTRESEND) {
- m = m_copym(rep->r_mreq, 0, M_COPYALL, M_WAIT);
- nfsstats.rpcretries++;
- error = nfs_send(so, rep->r_nmp->nm_nam, m, rep);
- if (error) {
- if (error == EINTR || error == ERESTART ||
- (error = nfs_reconnect(rep)) != 0) {
- nfs_sndunlock(rep);
- return (error);
- }
- goto tryagain;
- }
- }
- nfs_sndunlock(rep);
- if (sotype == SOCK_STREAM) {
- aio.iov_base = (caddr_t) &len;
- aio.iov_len = sizeof(u_int32_t);
- auio.uio_iov = &aio;
- auio.uio_iovcnt = 1;
- auio.uio_segflg = UIO_SYSSPACE;
- auio.uio_rw = UIO_READ;
- auio.uio_offset = 0;
- auio.uio_resid = sizeof(u_int32_t);
- auio.uio_procp = p;
- do {
- rcvflg = MSG_WAITALL;
- error = so->so_proto->pr_usrreqs->pru_soreceive
- (so, (struct sockaddr **)0, &auio,
- (struct mbuf **)0, (struct mbuf **)0,
- &rcvflg);
- if (error == EWOULDBLOCK && rep) {
- if (rep->r_flags & R_SOFTTERM)
- return (EINTR);
- }
- } while (error == EWOULDBLOCK);
- if (!error && auio.uio_resid > 0) {
- /*
- * Don't log a 0 byte receive; it means
- * that the socket has been closed, and
- * can happen during normal operation
- * (forcible unmount or Solaris server).
- */
- if (auio.uio_resid != sizeof (u_int32_t))
- log(LOG_INFO,
- "short receive (%d/%d) from nfs server %s\n",
- (int)(sizeof(u_int32_t) - auio.uio_resid),
- (int)sizeof(u_int32_t),
- rep->r_nmp->nm_mountp->mnt_stat.f_mntfromname);
- error = EPIPE;
- }
- if (error)
- goto errout;
- len = ntohl(len) & ~0x80000000;
- /*
- * This is SERIOUS! We are out of sync with the sender
- * and forcing a disconnect/reconnect is all I can do.
- */
- if (len > NFS_MAXPACKET) {
- log(LOG_ERR, "%s (%d) from nfs server %s\n",
- "impossible packet length",
- len,
- rep->r_nmp->nm_mountp->mnt_stat.f_mntfromname);
- error = EFBIG;
- goto errout;
- }
- auio.uio_resid = len;
- do {
- rcvflg = MSG_WAITALL;
- error = so->so_proto->pr_usrreqs->pru_soreceive
- (so, (struct sockaddr **)0,
- &auio, mp, (struct mbuf **)0, &rcvflg);
- } while (error == EWOULDBLOCK || error == EINTR ||
- error == ERESTART);
- if (!error && auio.uio_resid > 0) {
- if (len != auio.uio_resid)
- log(LOG_INFO,
- "short receive (%d/%d) from nfs server %s\n",
- len - auio.uio_resid, len,
- rep->r_nmp->nm_mountp->mnt_stat.f_mntfromname);
- error = EPIPE;
- }
- } else {
- /*
- * NB: Since uio_resid is big, MSG_WAITALL is ignored
- * and soreceive() will return when it has either a
- * control msg or a data msg.
- * We have no use for control msg., but must grab them
- * and then throw them away so we know what is going
- * on.
- */
- auio.uio_resid = len = 100000000; /* Anything Big */
- auio.uio_procp = p;
- do {
- rcvflg = 0;
- error = so->so_proto->pr_usrreqs->pru_soreceive
- (so, (struct sockaddr **)0,
- &auio, mp, &control, &rcvflg);
- if (control)
- m_freem(control);
- if (error == EWOULDBLOCK && rep) {
- if (rep->r_flags & R_SOFTTERM)
- return (EINTR);
- }
- } while (error == EWOULDBLOCK ||
- (!error && *mp == NULL && control));
- if ((rcvflg & MSG_EOR) == 0)
- printf("Egad!!\n");
- if (!error && *mp == NULL)
- error = EPIPE;
- len -= auio.uio_resid;
- }
-errout:
- if (error && error != EINTR && error != ERESTART) {
- m_freem(*mp);
- *mp = (struct mbuf *)0;
- if (error != EPIPE)
- log(LOG_INFO,
- "receive error %d from nfs server %s\n",
- error,
- rep->r_nmp->nm_mountp->mnt_stat.f_mntfromname);
- error = nfs_sndlock(rep);
- if (!error)
- error = nfs_reconnect(rep);
- if (!error)
- goto tryagain;
- else
- nfs_sndunlock(rep);
- }
- } else {
- if ((so = rep->r_nmp->nm_so) == NULL)
- return (EACCES);
- if (so->so_state & SS_ISCONNECTED)
- getnam = (struct sockaddr **)0;
- else
- getnam = aname;
- auio.uio_resid = len = 1000000;
- auio.uio_procp = p;
- do {
- rcvflg = 0;
- error = so->so_proto->pr_usrreqs->pru_soreceive
- (so, getnam, &auio, mp,
- (struct mbuf **)0, &rcvflg);
- if (error == EWOULDBLOCK &&
- (rep->r_flags & R_SOFTTERM))
- return (EINTR);
- } while (error == EWOULDBLOCK);
- len -= auio.uio_resid;
- }
- if (error) {
- m_freem(*mp);
- *mp = (struct mbuf *)0;
- }
- /*
- * Search for any mbufs that are not a multiple of 4 bytes long
- * or with m_data not longword aligned.
- * These could cause pointer alignment problems, so copy them to
- * well aligned mbufs.
- */
- nfs_realign(mp, 5 * NFSX_UNSIGNED);
- return (error);
-}
-
-/*
- * Implement receipt of reply on a socket.
- * We must search through the list of received datagrams matching them
- * with outstanding requests using the xid, until ours is found.
- */
-/* ARGSUSED */
-int
-nfs_reply(myrep)
- struct nfsreq *myrep;
-{
- register struct nfsreq *rep;
- register struct nfsmount *nmp = myrep->r_nmp;
- register int32_t t1;
- struct mbuf *mrep, *md;
- struct sockaddr *nam;
- u_int32_t rxid, *tl;
- caddr_t dpos, cp2;
- int error;
-
- /*
- * Loop around until we get our own reply
- */
- for (;;) {
- /*
- * Lock against other receivers so that I don't get stuck in
- * sbwait() after someone else has received my reply for me.
- * Also necessary for connection based protocols to avoid
- * race conditions during a reconnect.
- * If nfs_rcvlock() returns EALREADY, that means that
- * the reply has already been recieved by another
- * process and we can return immediately. In this
- * case, the lock is not taken to avoid races with
- * other processes.
- */
- error = nfs_rcvlock(myrep);
- if (error == EALREADY)
- return (0);
- if (error)
- return (error);
- /*
- * Get the next Rpc reply off the socket
- */
- error = nfs_receive(myrep, &nam, &mrep);
- nfs_rcvunlock(myrep);
- if (error) {
-
- /*
- * Ignore routing errors on connectionless protocols??
- */
- if (NFSIGNORE_SOERROR(nmp->nm_soflags, error)) {
- nmp->nm_so->so_error = 0;
- if (myrep->r_flags & R_GETONEREP)
- return (0);
- continue;
- }
- return (error);
- }
- if (nam)
- FREE(nam, M_SONAME);
-
- /*
- * Get the xid and check that it is an rpc reply
- */
- md = mrep;
- dpos = mtod(md, caddr_t);
- nfsm_dissect(tl, u_int32_t *, 2*NFSX_UNSIGNED);
- rxid = *tl++;
- if (*tl != rpc_reply) {
-#ifndef NFS_NOSERVER
- if (nmp->nm_flag & NFSMNT_NQNFS) {
- if (nqnfs_callback(nmp, mrep, md, dpos))
- nfsstats.rpcinvalid++;
- } else {
- nfsstats.rpcinvalid++;
- m_freem(mrep);
- }
-#else
- nfsstats.rpcinvalid++;
- m_freem(mrep);
-#endif
-nfsmout:
- if (myrep->r_flags & R_GETONEREP)
- return (0);
- continue;
- }
-
- /*
- * Loop through the request list to match up the reply
- * Iff no match, just drop the datagram
- */
- for (rep = nfs_reqq.tqh_first; rep != 0;
- rep = rep->r_chain.tqe_next) {
- if (rep->r_mrep == NULL && rxid == rep->r_xid) {
- /* Found it.. */
- rep->r_mrep = mrep;
- rep->r_md = md;
- rep->r_dpos = dpos;
- if (nfsrtton) {
- struct rttl *rt;
-
- rt = &nfsrtt.rttl[nfsrtt.pos];
- rt->proc = rep->r_procnum;
- rt->rto = NFS_RTO(nmp, proct[rep->r_procnum]);
- rt->sent = nmp->nm_sent;
- rt->cwnd = nmp->nm_cwnd;
- rt->srtt = nmp->nm_srtt[proct[rep->r_procnum] - 1];
- rt->sdrtt = nmp->nm_sdrtt[proct[rep->r_procnum] - 1];
- rt->fsid = nmp->nm_mountp->mnt_stat.f_fsid;
- getmicrotime(&rt->tstamp);
- if (rep->r_flags & R_TIMING)
- rt->rtt = rep->r_rtt;
- else
- rt->rtt = 1000000;
- nfsrtt.pos = (nfsrtt.pos + 1) % NFSRTTLOGSIZ;
- }
- /*
- * Update congestion window.
- * Do the additive increase of
- * one rpc/rtt.
- */
- if (nmp->nm_cwnd <= nmp->nm_sent) {
- nmp->nm_cwnd +=
- (NFS_CWNDSCALE * NFS_CWNDSCALE +
- (nmp->nm_cwnd >> 1)) / nmp->nm_cwnd;
- if (nmp->nm_cwnd > NFS_MAXCWND)
- nmp->nm_cwnd = NFS_MAXCWND;
- }
- if (rep->r_flags & R_SENT) {
- rep->r_flags &= ~R_SENT;
- nmp->nm_sent -= NFS_CWNDSCALE;
- }
- /*
- * Update rtt using a gain of 0.125 on the mean
- * and a gain of 0.25 on the deviation.
- */
- if (rep->r_flags & R_TIMING) {
- /*
- * Since the timer resolution of
- * NFS_HZ is so course, it can often
- * result in r_rtt == 0. Since
- * r_rtt == N means that the actual
- * rtt is between N+dt and N+2-dt ticks,
- * add 1.
- */
- t1 = rep->r_rtt + 1;
- t1 -= (NFS_SRTT(rep) >> 3);
- NFS_SRTT(rep) += t1;
- if (t1 < 0)
- t1 = -t1;
- t1 -= (NFS_SDRTT(rep) >> 2);
- NFS_SDRTT(rep) += t1;
- }
- nmp->nm_timeouts = 0;
- break;
- }
- }
- /*
- * If not matched to a request, drop it.
- * If it's mine, get out.
- */
- if (rep == 0) {
- nfsstats.rpcunexpected++;
- m_freem(mrep);
- } else if (rep == myrep) {
- if (rep->r_mrep == NULL)
- panic("nfsreply nil");
- return (0);
- }
- if (myrep->r_flags & R_GETONEREP)
- return (0);
- }
-}
-
-/*
- * nfs_request - goes something like this
- * - fill in request struct
- * - links it into list
- * - calls nfs_send() for first transmit
- * - calls nfs_receive() to get reply
- * - break down rpc header and return with nfs reply pointed to
- * by mrep or error
- * nb: always frees up mreq mbuf list
- */
-int
-nfs_request(vp, mrest, procnum, procp, cred, mrp, mdp, dposp)
- struct vnode *vp;
- struct mbuf *mrest;
- int procnum;
- struct proc *procp;
- struct ucred *cred;
- struct mbuf **mrp;
- struct mbuf **mdp;
- caddr_t *dposp;
-{
- register struct mbuf *mrep, *m2;
- register struct nfsreq *rep;
- register u_int32_t *tl;
- register int i;
- struct nfsmount *nmp;
- struct mbuf *m, *md, *mheadend;
- struct nfsnode *np;
- char nickv[RPCX_NICKVERF];
- time_t reqtime, waituntil;
- caddr_t dpos, cp2;
- int t1, nqlflag, cachable, s, error = 0, mrest_len, auth_len, auth_type;
- int trylater_delay = NQ_TRYLATERDEL, trylater_cnt = 0, failed_auth = 0;
- int verf_len, verf_type;
- u_int32_t xid;
- u_quad_t frev;
- char *auth_str, *verf_str;
- NFSKERBKEY_T key; /* save session key */
-
- nmp = VFSTONFS(vp->v_mount);
- MALLOC(rep, struct nfsreq *, sizeof(struct nfsreq), M_NFSREQ, M_WAITOK);
- rep->r_nmp = nmp;
- rep->r_vp = vp;
- rep->r_procp = procp;
- rep->r_procnum = procnum;
- i = 0;
- m = mrest;
- while (m) {
- i += m->m_len;
- m = m->m_next;
- }
- mrest_len = i;
-
- /*
- * Get the RPC header with authorization.
- */
-kerbauth:
- verf_str = auth_str = (char *)0;
- if (nmp->nm_flag & NFSMNT_KERB) {
- verf_str = nickv;
- verf_len = sizeof (nickv);
- auth_type = RPCAUTH_KERB4;
- bzero((caddr_t)key, sizeof (key));
- if (failed_auth || nfs_getnickauth(nmp, cred, &auth_str,
- &auth_len, verf_str, verf_len)) {
- error = nfs_getauth(nmp, rep, cred, &auth_str,
- &auth_len, verf_str, &verf_len, key);
- if (error) {
- free((caddr_t)rep, M_NFSREQ);
- m_freem(mrest);
- return (error);
- }
- }
- } else {
- auth_type = RPCAUTH_UNIX;
- if (cred->cr_ngroups < 1)
- panic("nfsreq nogrps");
- auth_len = ((((cred->cr_ngroups - 1) > nmp->nm_numgrps) ?
- nmp->nm_numgrps : (cred->cr_ngroups - 1)) << 2) +
- 5 * NFSX_UNSIGNED;
- }
- m = nfsm_rpchead(cred, nmp->nm_flag, procnum, auth_type, auth_len,
- auth_str, verf_len, verf_str, mrest, mrest_len, &mheadend, &xid);
- if (auth_str)
- free(auth_str, M_TEMP);
-
- /*
- * For stream protocols, insert a Sun RPC Record Mark.
- */
- if (nmp->nm_sotype == SOCK_STREAM) {
- M_PREPEND(m, NFSX_UNSIGNED, M_WAIT);
- *mtod(m, u_int32_t *) = htonl(0x80000000 |
- (m->m_pkthdr.len - NFSX_UNSIGNED));
- }
- rep->r_mreq = m;
- rep->r_xid = xid;
-tryagain:
- if (nmp->nm_flag & NFSMNT_SOFT)
- rep->r_retry = nmp->nm_retry;
- else
- rep->r_retry = NFS_MAXREXMIT + 1; /* past clip limit */
- rep->r_rtt = rep->r_rexmit = 0;
- if (proct[procnum] > 0)
- rep->r_flags = R_TIMING;
- else
- rep->r_flags = 0;
- rep->r_mrep = NULL;
-
- /*
- * Do the client side RPC.
- */
- nfsstats.rpcrequests++;
- /*
- * Chain request into list of outstanding requests. Be sure
- * to put it LAST so timer finds oldest requests first.
- */
- s = splsoftclock();
- TAILQ_INSERT_TAIL(&nfs_reqq, rep, r_chain);
-
- /* Get send time for nqnfs */
- reqtime = time_second;
-
- /*
- * If backing off another request or avoiding congestion, don't
- * send this one now but let timer do it. If not timing a request,
- * do it now.
- */
- if (nmp->nm_so && (nmp->nm_sotype != SOCK_DGRAM ||
- (nmp->nm_flag & NFSMNT_DUMBTIMR) ||
- nmp->nm_sent < nmp->nm_cwnd)) {
- splx(s);
- if (nmp->nm_soflags & PR_CONNREQUIRED)
- error = nfs_sndlock(rep);
- if (!error) {
- m2 = m_copym(m, 0, M_COPYALL, M_WAIT);
- error = nfs_send(nmp->nm_so, nmp->nm_nam, m2, rep);
- if (nmp->nm_soflags & PR_CONNREQUIRED)
- nfs_sndunlock(rep);
- }
- if (!error && (rep->r_flags & R_MUSTRESEND) == 0) {
- nmp->nm_sent += NFS_CWNDSCALE;
- rep->r_flags |= R_SENT;
- }
- } else {
- splx(s);
- rep->r_rtt = -1;
- }
-
- /*
- * Wait for the reply from our send or the timer's.
- */
- if (!error || error == EPIPE)
- error = nfs_reply(rep);
-
- /*
- * RPC done, unlink the request.
- */
- s = splsoftclock();
- TAILQ_REMOVE(&nfs_reqq, rep, r_chain);
- splx(s);
-
- /*
- * Decrement the outstanding request count.
- */
- if (rep->r_flags & R_SENT) {
- rep->r_flags &= ~R_SENT; /* paranoia */
- nmp->nm_sent -= NFS_CWNDSCALE;
- }
-
- /*
- * If there was a successful reply and a tprintf msg.
- * tprintf a response.
- */
- if (!error && (rep->r_flags & R_TPRINTFMSG))
- nfs_msg(rep->r_procp, nmp->nm_mountp->mnt_stat.f_mntfromname,
- "is alive again");
- mrep = rep->r_mrep;
- md = rep->r_md;
- dpos = rep->r_dpos;
- if (error) {
- m_freem(rep->r_mreq);
- free((caddr_t)rep, M_NFSREQ);
- return (error);
- }
-
- /*
- * break down the rpc header and check if ok
- */
- nfsm_dissect(tl, u_int32_t *, 3 * NFSX_UNSIGNED);
- if (*tl++ == rpc_msgdenied) {
- if (*tl == rpc_mismatch)
- error = EOPNOTSUPP;
- else if ((nmp->nm_flag & NFSMNT_KERB) && *tl++ == rpc_autherr) {
- if (!failed_auth) {
- failed_auth++;
- mheadend->m_next = (struct mbuf *)0;
- m_freem(mrep);
- m_freem(rep->r_mreq);
- goto kerbauth;
- } else
- error = EAUTH;
- } else
- error = EACCES;
- m_freem(mrep);
- m_freem(rep->r_mreq);
- free((caddr_t)rep, M_NFSREQ);
- return (error);
- }
-
- /*
- * Grab any Kerberos verifier, otherwise just throw it away.
- */
- verf_type = fxdr_unsigned(int, *tl++);
- i = fxdr_unsigned(int32_t, *tl);
- if ((nmp->nm_flag & NFSMNT_KERB) && verf_type == RPCAUTH_KERB4) {
- error = nfs_savenickauth(nmp, cred, i, key, &md, &dpos, mrep);
- if (error)
- goto nfsmout;
- } else if (i > 0)
- nfsm_adv(nfsm_rndup(i));
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED);
- /* 0 == ok */
- if (*tl == 0) {
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED);
- if (*tl != 0) {
- error = fxdr_unsigned(int, *tl);
- if ((nmp->nm_flag & NFSMNT_NFSV3) &&
- error == NFSERR_TRYLATER) {
- m_freem(mrep);
- error = 0;
- waituntil = time_second + trylater_delay;
- while (time_second < waituntil)
- (void) tsleep((caddr_t)&lbolt,
- PSOCK, "nqnfstry", 0);
- trylater_delay *= nfs_backoff[trylater_cnt];
- if (trylater_cnt < 7)
- trylater_cnt++;
- goto tryagain;
- }
-
- /*
- * If the File Handle was stale, invalidate the
- * lookup cache, just in case.
- */
- if (error == ESTALE)
- cache_purge(vp);
- if (nmp->nm_flag & NFSMNT_NFSV3) {
- *mrp = mrep;
- *mdp = md;
- *dposp = dpos;
- error |= NFSERR_RETERR;
- } else
- m_freem(mrep);
- m_freem(rep->r_mreq);
- free((caddr_t)rep, M_NFSREQ);
- return (error);
- }
-
- /*
- * For nqnfs, get any lease in reply
- */
- if (nmp->nm_flag & NFSMNT_NQNFS) {
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED);
- if (*tl) {
- np = VTONFS(vp);
- nqlflag = fxdr_unsigned(int, *tl);
- nfsm_dissect(tl, u_int32_t *, 4*NFSX_UNSIGNED);
- cachable = fxdr_unsigned(int, *tl++);
- reqtime += fxdr_unsigned(int, *tl++);
- if (reqtime > time_second) {
- frev = fxdr_hyper(tl);
- nqnfs_clientlease(nmp, np, nqlflag,
- cachable, reqtime, frev);
- }
- }
- }
- *mrp = mrep;
- *mdp = md;
- *dposp = dpos;
- m_freem(rep->r_mreq);
- FREE((caddr_t)rep, M_NFSREQ);
- return (0);
- }
- m_freem(mrep);
- error = EPROTONOSUPPORT;
-nfsmout:
- m_freem(rep->r_mreq);
- free((caddr_t)rep, M_NFSREQ);
- return (error);
-}
-
-#ifndef NFS_NOSERVER
-/*
- * Generate the rpc reply header
- * siz arg. is used to decide if adding a cluster is worthwhile
- */
-int
-nfs_rephead(siz, nd, slp, err, cache, frev, mrq, mbp, bposp)
- int siz;
- struct nfsrv_descript *nd;
- struct nfssvc_sock *slp;
- int err;
- int cache;
- u_quad_t *frev;
- struct mbuf **mrq;
- struct mbuf **mbp;
- caddr_t *bposp;
-{
- register u_int32_t *tl;
- register struct mbuf *mreq;
- caddr_t bpos;
- struct mbuf *mb, *mb2;
-
- MGETHDR(mreq, M_WAIT, MT_DATA);
- mb = mreq;
- /*
- * If this is a big reply, use a cluster else
- * try and leave leading space for the lower level headers.
- */
- siz += RPC_REPLYSIZ;
- if ((max_hdr + siz) >= MINCLSIZE) {
- MCLGET(mreq, M_WAIT);
- } else
- mreq->m_data += max_hdr;
- tl = mtod(mreq, u_int32_t *);
- mreq->m_len = 6 * NFSX_UNSIGNED;
- bpos = ((caddr_t)tl) + mreq->m_len;
- *tl++ = txdr_unsigned(nd->nd_retxid);
- *tl++ = rpc_reply;
- if (err == ERPCMISMATCH || (err & NFSERR_AUTHERR)) {
- *tl++ = rpc_msgdenied;
- if (err & NFSERR_AUTHERR) {
- *tl++ = rpc_autherr;
- *tl = txdr_unsigned(err & ~NFSERR_AUTHERR);
- mreq->m_len -= NFSX_UNSIGNED;
- bpos -= NFSX_UNSIGNED;
- } else {
- *tl++ = rpc_mismatch;
- *tl++ = txdr_unsigned(RPC_VER2);
- *tl = txdr_unsigned(RPC_VER2);
- }
- } else {
- *tl++ = rpc_msgaccepted;
-
- /*
- * For Kerberos authentication, we must send the nickname
- * verifier back, otherwise just RPCAUTH_NULL.
- */
- if (nd->nd_flag & ND_KERBFULL) {
- register struct nfsuid *nuidp;
- struct timeval ktvin, ktvout;
-
- for (nuidp = NUIDHASH(slp, nd->nd_cr.cr_uid)->lh_first;
- nuidp != 0; nuidp = nuidp->nu_hash.le_next) {
- if (nuidp->nu_cr.cr_uid == nd->nd_cr.cr_uid &&
- (!nd->nd_nam2 || netaddr_match(NU_NETFAM(nuidp),
- &nuidp->nu_haddr, nd->nd_nam2)))
- break;
- }
- if (nuidp) {
- ktvin.tv_sec =
- txdr_unsigned(nuidp->nu_timestamp.tv_sec - 1);
- ktvin.tv_usec =
- txdr_unsigned(nuidp->nu_timestamp.tv_usec);
-
- /*
- * Encrypt the timestamp in ecb mode using the
- * session key.
- */
-#ifdef NFSKERB
- XXX
-#endif
-
- *tl++ = rpc_auth_kerb;
- *tl++ = txdr_unsigned(3 * NFSX_UNSIGNED);
- *tl = ktvout.tv_sec;
- nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED);
- *tl++ = ktvout.tv_usec;
- *tl++ = txdr_unsigned(nuidp->nu_cr.cr_uid);
- } else {
- *tl++ = 0;
- *tl++ = 0;
- }
- } else {
- *tl++ = 0;
- *tl++ = 0;
- }
- switch (err) {
- case EPROGUNAVAIL:
- *tl = txdr_unsigned(RPC_PROGUNAVAIL);
- break;
- case EPROGMISMATCH:
- *tl = txdr_unsigned(RPC_PROGMISMATCH);
- nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
- if (nd->nd_flag & ND_NQNFS) {
- *tl++ = txdr_unsigned(3);
- *tl = txdr_unsigned(3);
- } else {
- *tl++ = txdr_unsigned(2);
- *tl = txdr_unsigned(3);
- }
- break;
- case EPROCUNAVAIL:
- *tl = txdr_unsigned(RPC_PROCUNAVAIL);
- break;
- case EBADRPC:
- *tl = txdr_unsigned(RPC_GARBAGE);
- break;
- default:
- *tl = 0;
- if (err != NFSERR_RETVOID) {
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);
- if (err)
- *tl = txdr_unsigned(nfsrv_errmap(nd, err));
- else
- *tl = 0;
- }
- break;
- };
- }
-
- /*
- * For nqnfs, piggyback lease as requested.
- */
- if ((nd->nd_flag & ND_NQNFS) && err == 0) {
- if (nd->nd_flag & ND_LEASE) {
- nfsm_build(tl, u_int32_t *, 5 * NFSX_UNSIGNED);
- *tl++ = txdr_unsigned(nd->nd_flag & ND_LEASE);
- *tl++ = txdr_unsigned(cache);
- *tl++ = txdr_unsigned(nd->nd_duration);
- txdr_hyper(*frev, tl);
- } else {
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);
- *tl = 0;
- }
- }
- if (mrq != NULL)
- *mrq = mreq;
- *mbp = mb;
- *bposp = bpos;
- if (err != 0 && err != NFSERR_RETVOID)
- nfsstats.srvrpc_errs++;
- return (0);
-}
-
-
-#endif /* NFS_NOSERVER */
-/*
- * Nfs timer routine
- * Scan the nfsreq list and retranmit any requests that have timed out
- * To avoid retransmission attempts on STREAM sockets (in the future) make
- * sure to set the r_retry field to 0 (implies nm_retry == 0).
- */
-void
-nfs_timer(arg)
- void *arg; /* never used */
-{
- register struct nfsreq *rep;
- register struct mbuf *m;
- register struct socket *so;
- register struct nfsmount *nmp;
- register int timeo;
- int s, error;
-#ifndef NFS_NOSERVER
- static long lasttime = 0;
- register struct nfssvc_sock *slp;
- u_quad_t cur_usec;
-#endif /* NFS_NOSERVER */
- struct proc *p = &proc0; /* XXX for credentials, will break if sleep */
-
- s = splnet();
- for (rep = nfs_reqq.tqh_first; rep != 0; rep = rep->r_chain.tqe_next) {
- nmp = rep->r_nmp;
- if (rep->r_mrep || (rep->r_flags & R_SOFTTERM))
- continue;
- if (nfs_sigintr(nmp, rep, rep->r_procp)) {
- nfs_softterm(rep);
- continue;
- }
- if (rep->r_rtt >= 0) {
- rep->r_rtt++;
- if (nmp->nm_flag & NFSMNT_DUMBTIMR)
- timeo = nmp->nm_timeo;
- else
- timeo = NFS_RTO(nmp, proct[rep->r_procnum]);
- if (nmp->nm_timeouts > 0)
- timeo *= nfs_backoff[nmp->nm_timeouts - 1];
- if (rep->r_rtt <= timeo)
- continue;
- if (nmp->nm_timeouts < 8)
- nmp->nm_timeouts++;
- }
- /*
- * Check for server not responding
- */
- if ((rep->r_flags & R_TPRINTFMSG) == 0 &&
- rep->r_rexmit > nmp->nm_deadthresh) {
- nfs_msg(rep->r_procp,
- nmp->nm_mountp->mnt_stat.f_mntfromname,
- "not responding");
- rep->r_flags |= R_TPRINTFMSG;
- }
- if (rep->r_rexmit >= rep->r_retry) { /* too many */
- nfsstats.rpctimeouts++;
- nfs_softterm(rep);
- continue;
- }
- if (nmp->nm_sotype != SOCK_DGRAM) {
- if (++rep->r_rexmit > NFS_MAXREXMIT)
- rep->r_rexmit = NFS_MAXREXMIT;
- continue;
- }
- if ((so = nmp->nm_so) == NULL)
- continue;
-
- /*
- * If there is enough space and the window allows..
- * Resend it
- * Set r_rtt to -1 in case we fail to send it now.
- */
- rep->r_rtt = -1;
- if (sbspace(&so->so_snd) >= rep->r_mreq->m_pkthdr.len &&
- ((nmp->nm_flag & NFSMNT_DUMBTIMR) ||
- (rep->r_flags & R_SENT) ||
- nmp->nm_sent < nmp->nm_cwnd) &&
- (m = m_copym(rep->r_mreq, 0, M_COPYALL, M_DONTWAIT))){
- if ((nmp->nm_flag & NFSMNT_NOCONN) == 0)
- error = (*so->so_proto->pr_usrreqs->pru_send)
- (so, 0, m, (struct sockaddr *)0,
- (struct mbuf *)0, p);
- else
- error = (*so->so_proto->pr_usrreqs->pru_send)
- (so, 0, m, nmp->nm_nam, (struct mbuf *)0,
- p);
- if (error) {
- if (NFSIGNORE_SOERROR(nmp->nm_soflags, error))
- so->so_error = 0;
- } else {
- /*
- * Iff first send, start timing
- * else turn timing off, backoff timer
- * and divide congestion window by 2.
- */
- if (rep->r_flags & R_SENT) {
- rep->r_flags &= ~R_TIMING;
- if (++rep->r_rexmit > NFS_MAXREXMIT)
- rep->r_rexmit = NFS_MAXREXMIT;
- nmp->nm_cwnd >>= 1;
- if (nmp->nm_cwnd < NFS_CWNDSCALE)
- nmp->nm_cwnd = NFS_CWNDSCALE;
- nfsstats.rpcretries++;
- } else {
- rep->r_flags |= R_SENT;
- nmp->nm_sent += NFS_CWNDSCALE;
- }
- rep->r_rtt = 0;
- }
- }
- }
-#ifndef NFS_NOSERVER
- /*
- * Call the nqnfs server timer once a second to handle leases.
- */
- if (lasttime != time_second) {
- lasttime = time_second;
- nqnfs_serverd();
- }
-
- /*
- * Scan the write gathering queues for writes that need to be
- * completed now.
- */
- cur_usec = nfs_curusec();
- for (slp = nfssvc_sockhead.tqh_first; slp != 0;
- slp = slp->ns_chain.tqe_next) {
- if (slp->ns_tq.lh_first && slp->ns_tq.lh_first->nd_time<=cur_usec)
- nfsrv_wakenfsd(slp);
- }
-#endif /* NFS_NOSERVER */
- splx(s);
- nfs_timer_handle = timeout(nfs_timer, (void *)0, nfs_ticks);
-}
-
-/*
- * Flag a request as being about to terminate (due to NFSMNT_INT/NFSMNT_SOFT).
- * The nm_send count is decremented now to avoid deadlocks when the process in
- * soreceive() hasn't yet managed to send its own request.
- */
-
-static void
-nfs_softterm(rep)
- struct nfsreq *rep;
-{
- rep->r_flags |= R_SOFTTERM;
-
- if (rep->r_flags & R_SENT) {
- rep->r_nmp->nm_sent -= NFS_CWNDSCALE;
- rep->r_flags &= ~R_SENT;
- }
-}
-
-/*
- * Test for a termination condition pending on the process.
- * This is used for NFSMNT_INT mounts.
- */
-int
-nfs_sigintr(nmp, rep, p)
- struct nfsmount *nmp;
- struct nfsreq *rep;
- register struct proc *p;
-{
- sigset_t tmpset;
-
- if (rep && (rep->r_flags & R_SOFTTERM))
- return (EINTR);
- if (!(nmp->nm_flag & NFSMNT_INT))
- return (0);
- if (p == NULL)
- return (0);
-
- tmpset = p->p_siglist;
- SIGSETNAND(tmpset, p->p_sigmask);
- SIGSETNAND(tmpset, p->p_sigignore);
- if (SIGNOTEMPTY(p->p_siglist) && NFSINT_SIGMASK(tmpset))
- return (EINTR);
-
- return (0);
-}
-
-/*
- * Lock a socket against others.
- * Necessary for STREAM sockets to ensure you get an entire rpc request/reply
- * and also to avoid race conditions between the processes with nfs requests
- * in progress when a reconnect is necessary.
- */
-int
-nfs_sndlock(rep)
- struct nfsreq *rep;
-{
- register int *statep = &rep->r_nmp->nm_state;
- struct proc *p;
- int slpflag = 0, slptimeo = 0;
-
- if (rep) {
- p = rep->r_procp;
- if (rep->r_nmp->nm_flag & NFSMNT_INT)
- slpflag = PCATCH;
- } else
- p = (struct proc *)0;
- while (*statep & NFSSTA_SNDLOCK) {
- if (nfs_sigintr(rep->r_nmp, rep, p))
- return (EINTR);
- *statep |= NFSSTA_WANTSND;
- (void) tsleep((caddr_t)statep, slpflag | (PZERO - 1),
- "nfsndlck", slptimeo);
- if (slpflag == PCATCH) {
- slpflag = 0;
- slptimeo = 2 * hz;
- }
- }
- *statep |= NFSSTA_SNDLOCK;
- return (0);
-}
-
-/*
- * Unlock the stream socket for others.
- */
-void
-nfs_sndunlock(rep)
- struct nfsreq *rep;
-{
- register int *statep = &rep->r_nmp->nm_state;
-
- if ((*statep & NFSSTA_SNDLOCK) == 0)
- panic("nfs sndunlock");
- *statep &= ~NFSSTA_SNDLOCK;
- if (*statep & NFSSTA_WANTSND) {
- *statep &= ~NFSSTA_WANTSND;
- wakeup((caddr_t)statep);
- }
-}
-
-static int
-nfs_rcvlock(rep)
- register struct nfsreq *rep;
-{
- register int *statep = &rep->r_nmp->nm_state;
- int slpflag, slptimeo = 0;
-
- if (rep->r_nmp->nm_flag & NFSMNT_INT)
- slpflag = PCATCH;
- else
- slpflag = 0;
- while (*statep & NFSSTA_RCVLOCK) {
- if (nfs_sigintr(rep->r_nmp, rep, rep->r_procp))
- return (EINTR);
- *statep |= NFSSTA_WANTRCV;
- (void) tsleep((caddr_t)statep, slpflag | (PZERO - 1), "nfsrcvlk",
- slptimeo);
- /*
- * If our reply was recieved while we were sleeping,
- * then just return without taking the lock to avoid a
- * situation where a single iod could 'capture' the
- * recieve lock.
- */
- if (rep->r_mrep != NULL)
- return (EALREADY);
- if (slpflag == PCATCH) {
- slpflag = 0;
- slptimeo = 2 * hz;
- }
- }
- *statep |= NFSSTA_RCVLOCK;
- return (0);
-}
-
-/*
- * Unlock the stream socket for others.
- */
-static void
-nfs_rcvunlock(rep)
- register struct nfsreq *rep;
-{
- register int *statep = &rep->r_nmp->nm_state;
-
- if ((*statep & NFSSTA_RCVLOCK) == 0)
- panic("nfs rcvunlock");
- *statep &= ~NFSSTA_RCVLOCK;
- if (*statep & NFSSTA_WANTRCV) {
- *statep &= ~NFSSTA_WANTRCV;
- wakeup((caddr_t)statep);
- }
-}
-
-/*
- * nfs_realign:
- *
- * Check for badly aligned mbuf data and realign by copying the unaligned
- * portion of the data into a new mbuf chain and freeing the portions
- * of the old chain that were replaced.
- *
- * We cannot simply realign the data within the existing mbuf chain
- * because the underlying buffers may contain other rpc commands and
- * we cannot afford to overwrite them.
- *
- * We would prefer to avoid this situation entirely. The situation does
- * not occur with NFS/UDP and is supposed to only occassionally occur
- * with TCP. Use vfs.nfs.realign_count and realign_test to check this.
- */
-static void
-nfs_realign(pm, hsiz)
- register struct mbuf **pm;
- int hsiz;
-{
- struct mbuf *m;
- struct mbuf *n = NULL;
- int off = 0;
-
- ++nfs_realign_test;
-
- while ((m = *pm) != NULL) {
- if ((m->m_len & 0x3) || (mtod(m, intptr_t) & 0x3)) {
- MGET(n, M_WAIT, MT_DATA);
- if (m->m_len >= MINCLSIZE) {
- MCLGET(n, M_WAIT);
- }
- n->m_len = 0;
- break;
- }
- pm = &m->m_next;
- }
-
- /*
- * If n is non-NULL, loop on m copying data, then replace the
- * portion of the chain that had to be realigned.
- */
- if (n != NULL) {
- ++nfs_realign_count;
- while (m) {
- m_copyback(n, off, m->m_len, mtod(m, caddr_t));
- off += m->m_len;
- m = m->m_next;
- }
- m_freem(*pm);
- *pm = n;
- }
-}
-
-#ifndef NFS_NOSERVER
-
-/*
- * Parse an RPC request
- * - verify it
- * - fill in the cred struct.
- */
-int
-nfs_getreq(nd, nfsd, has_header)
- register struct nfsrv_descript *nd;
- struct nfsd *nfsd;
- int has_header;
-{
- register int len, i;
- register u_int32_t *tl;
- register int32_t t1;
- struct uio uio;
- struct iovec iov;
- caddr_t dpos, cp2, cp;
- u_int32_t nfsvers, auth_type;
- uid_t nickuid;
- int error = 0, nqnfs = 0, ticklen;
- struct mbuf *mrep, *md;
- register struct nfsuid *nuidp;
- struct timeval tvin, tvout;
-#if 0 /* until encrypted keys are implemented */
- NFSKERBKEYSCHED_T keys; /* stores key schedule */
-#endif
-
- mrep = nd->nd_mrep;
- md = nd->nd_md;
- dpos = nd->nd_dpos;
- if (has_header) {
- nfsm_dissect(tl, u_int32_t *, 10 * NFSX_UNSIGNED);
- nd->nd_retxid = fxdr_unsigned(u_int32_t, *tl++);
- if (*tl++ != rpc_call) {
- m_freem(mrep);
- return (EBADRPC);
- }
- } else
- nfsm_dissect(tl, u_int32_t *, 8 * NFSX_UNSIGNED);
- nd->nd_repstat = 0;
- nd->nd_flag = 0;
- if (*tl++ != rpc_vers) {
- nd->nd_repstat = ERPCMISMATCH;
- nd->nd_procnum = NFSPROC_NOOP;
- return (0);
- }
- if (*tl != nfs_prog) {
- if (*tl == nqnfs_prog)
- nqnfs++;
- else {
- nd->nd_repstat = EPROGUNAVAIL;
- nd->nd_procnum = NFSPROC_NOOP;
- return (0);
- }
- }
- tl++;
- nfsvers = fxdr_unsigned(u_int32_t, *tl++);
- if (((nfsvers < NFS_VER2 || nfsvers > NFS_VER3) && !nqnfs) ||
- (nfsvers != NQNFS_VER3 && nqnfs)) {
- nd->nd_repstat = EPROGMISMATCH;
- nd->nd_procnum = NFSPROC_NOOP;
- return (0);
- }
- if (nqnfs)
- nd->nd_flag = (ND_NFSV3 | ND_NQNFS);
- else if (nfsvers == NFS_VER3)
- nd->nd_flag = ND_NFSV3;
- nd->nd_procnum = fxdr_unsigned(u_int32_t, *tl++);
- if (nd->nd_procnum == NFSPROC_NULL)
- return (0);
- if (nd->nd_procnum >= NFS_NPROCS ||
- (!nqnfs && nd->nd_procnum >= NQNFSPROC_GETLEASE) ||
- (!nd->nd_flag && nd->nd_procnum > NFSV2PROC_STATFS)) {
- nd->nd_repstat = EPROCUNAVAIL;
- nd->nd_procnum = NFSPROC_NOOP;
- return (0);
- }
- if ((nd->nd_flag & ND_NFSV3) == 0)
- nd->nd_procnum = nfsv3_procid[nd->nd_procnum];
- auth_type = *tl++;
- len = fxdr_unsigned(int, *tl++);
- if (len < 0 || len > RPCAUTH_MAXSIZ) {
- m_freem(mrep);
- return (EBADRPC);
- }
-
- nd->nd_flag &= ~ND_KERBAUTH;
- /*
- * Handle auth_unix or auth_kerb.
- */
- if (auth_type == rpc_auth_unix) {
- len = fxdr_unsigned(int, *++tl);
- if (len < 0 || len > NFS_MAXNAMLEN) {
- m_freem(mrep);
- return (EBADRPC);
- }
- nfsm_adv(nfsm_rndup(len));
- nfsm_dissect(tl, u_int32_t *, 3 * NFSX_UNSIGNED);
- bzero((caddr_t)&nd->nd_cr, sizeof (struct ucred));
- nd->nd_cr.cr_ref = 1;
- nd->nd_cr.cr_uid = fxdr_unsigned(uid_t, *tl++);
- nd->nd_cr.cr_gid = fxdr_unsigned(gid_t, *tl++);
- len = fxdr_unsigned(int, *tl);
- if (len < 0 || len > RPCAUTH_UNIXGIDS) {
- m_freem(mrep);
- return (EBADRPC);
- }
- nfsm_dissect(tl, u_int32_t *, (len + 2) * NFSX_UNSIGNED);
- for (i = 1; i <= len; i++)
- if (i < NGROUPS)
- nd->nd_cr.cr_groups[i] = fxdr_unsigned(gid_t, *tl++);
- else
- tl++;
- nd->nd_cr.cr_ngroups = (len >= NGROUPS) ? NGROUPS : (len + 1);
- if (nd->nd_cr.cr_ngroups > 1)
- nfsrvw_sort(nd->nd_cr.cr_groups, nd->nd_cr.cr_ngroups);
- len = fxdr_unsigned(int, *++tl);
- if (len < 0 || len > RPCAUTH_MAXSIZ) {
- m_freem(mrep);
- return (EBADRPC);
- }
- if (len > 0)
- nfsm_adv(nfsm_rndup(len));
- } else if (auth_type == rpc_auth_kerb) {
- switch (fxdr_unsigned(int, *tl++)) {
- case RPCAKN_FULLNAME:
- ticklen = fxdr_unsigned(int, *tl);
- *((u_int32_t *)nfsd->nfsd_authstr) = *tl;
- uio.uio_resid = nfsm_rndup(ticklen) + NFSX_UNSIGNED;
- nfsd->nfsd_authlen = uio.uio_resid + NFSX_UNSIGNED;
- if (uio.uio_resid > (len - 2 * NFSX_UNSIGNED)) {
- m_freem(mrep);
- return (EBADRPC);
- }
- uio.uio_offset = 0;
- uio.uio_iov = &iov;
- uio.uio_iovcnt = 1;
- uio.uio_segflg = UIO_SYSSPACE;
- iov.iov_base = (caddr_t)&nfsd->nfsd_authstr[4];
- iov.iov_len = RPCAUTH_MAXSIZ - 4;
- nfsm_mtouio(&uio, uio.uio_resid);
- nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
- if (*tl++ != rpc_auth_kerb ||
- fxdr_unsigned(int, *tl) != 4 * NFSX_UNSIGNED) {
- printf("Bad kerb verifier\n");
- nd->nd_repstat = (NFSERR_AUTHERR|AUTH_BADVERF);
- nd->nd_procnum = NFSPROC_NOOP;
- return (0);
- }
- nfsm_dissect(cp, caddr_t, 4 * NFSX_UNSIGNED);
- tl = (u_int32_t *)cp;
- if (fxdr_unsigned(int, *tl) != RPCAKN_FULLNAME) {
- printf("Not fullname kerb verifier\n");
- nd->nd_repstat = (NFSERR_AUTHERR|AUTH_BADVERF);
- nd->nd_procnum = NFSPROC_NOOP;
- return (0);
- }
- cp += NFSX_UNSIGNED;
- bcopy(cp, nfsd->nfsd_verfstr, 3 * NFSX_UNSIGNED);
- nfsd->nfsd_verflen = 3 * NFSX_UNSIGNED;
- nd->nd_flag |= ND_KERBFULL;
- nfsd->nfsd_flag |= NFSD_NEEDAUTH;
- break;
- case RPCAKN_NICKNAME:
- if (len != 2 * NFSX_UNSIGNED) {
- printf("Kerb nickname short\n");
- nd->nd_repstat = (NFSERR_AUTHERR|AUTH_BADCRED);
- nd->nd_procnum = NFSPROC_NOOP;
- return (0);
- }
- nickuid = fxdr_unsigned(uid_t, *tl);
- nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
- if (*tl++ != rpc_auth_kerb ||
- fxdr_unsigned(int, *tl) != 3 * NFSX_UNSIGNED) {
- printf("Kerb nick verifier bad\n");
- nd->nd_repstat = (NFSERR_AUTHERR|AUTH_BADVERF);
- nd->nd_procnum = NFSPROC_NOOP;
- return (0);
- }
- nfsm_dissect(tl, u_int32_t *, 3 * NFSX_UNSIGNED);
- tvin.tv_sec = *tl++;
- tvin.tv_usec = *tl;
-
- for (nuidp = NUIDHASH(nfsd->nfsd_slp,nickuid)->lh_first;
- nuidp != 0; nuidp = nuidp->nu_hash.le_next) {
- if (nuidp->nu_cr.cr_uid == nickuid &&
- (!nd->nd_nam2 ||
- netaddr_match(NU_NETFAM(nuidp),
- &nuidp->nu_haddr, nd->nd_nam2)))
- break;
- }
- if (!nuidp) {
- nd->nd_repstat =
- (NFSERR_AUTHERR|AUTH_REJECTCRED);
- nd->nd_procnum = NFSPROC_NOOP;
- return (0);
- }
-
- /*
- * Now, decrypt the timestamp using the session key
- * and validate it.
- */
-#ifdef NFSKERB
- XXX
-#endif
-
- tvout.tv_sec = fxdr_unsigned(long, tvout.tv_sec);
- tvout.tv_usec = fxdr_unsigned(long, tvout.tv_usec);
- if (nuidp->nu_expire < time_second ||
- nuidp->nu_timestamp.tv_sec > tvout.tv_sec ||
- (nuidp->nu_timestamp.tv_sec == tvout.tv_sec &&
- nuidp->nu_timestamp.tv_usec > tvout.tv_usec)) {
- nuidp->nu_expire = 0;
- nd->nd_repstat =
- (NFSERR_AUTHERR|AUTH_REJECTVERF);
- nd->nd_procnum = NFSPROC_NOOP;
- return (0);
- }
- nfsrv_setcred(&nuidp->nu_cr, &nd->nd_cr);
- nd->nd_flag |= ND_KERBNICK;
- };
- } else {
- nd->nd_repstat = (NFSERR_AUTHERR | AUTH_REJECTCRED);
- nd->nd_procnum = NFSPROC_NOOP;
- return (0);
- }
-
- /*
- * For nqnfs, get piggybacked lease request.
- */
- if (nqnfs && nd->nd_procnum != NQNFSPROC_EVICTED) {
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED);
- nd->nd_flag |= fxdr_unsigned(int, *tl);
- if (nd->nd_flag & ND_LEASE) {
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED);
- nd->nd_duration = fxdr_unsigned(int32_t, *tl);
- } else
- nd->nd_duration = NQ_MINLEASE;
- } else
- nd->nd_duration = NQ_MINLEASE;
- nd->nd_md = md;
- nd->nd_dpos = dpos;
- return (0);
-nfsmout:
- return (error);
-}
-
-#endif
-
-static int
-nfs_msg(p, server, msg)
- struct proc *p;
- char *server, *msg;
-{
- tpr_t tpr;
-
- if (p)
- tpr = tprintf_open(p);
- else
- tpr = NULL;
- tprintf(tpr, "nfs server %s: %s\n", server, msg);
- tprintf_close(tpr);
- return (0);
-}
-
-#ifndef NFS_NOSERVER
-/*
- * Socket upcall routine for the nfsd sockets.
- * The caddr_t arg is a pointer to the "struct nfssvc_sock".
- * Essentially do as much as possible non-blocking, else punt and it will
- * be called with M_WAIT from an nfsd.
- */
-void
-nfsrv_rcv(so, arg, waitflag)
- struct socket *so;
- void *arg;
- int waitflag;
-{
- register struct nfssvc_sock *slp = (struct nfssvc_sock *)arg;
- register struct mbuf *m;
- struct mbuf *mp;
- struct sockaddr *nam;
- struct uio auio;
- int flags, error;
-
- if ((slp->ns_flag & SLP_VALID) == 0)
- return;
-#ifdef notdef
- /*
- * Define this to test for nfsds handling this under heavy load.
- */
- if (waitflag == M_DONTWAIT) {
- slp->ns_flag |= SLP_NEEDQ; goto dorecs;
- }
-#endif
- auio.uio_procp = NULL;
- if (so->so_type == SOCK_STREAM) {
- /*
- * If there are already records on the queue, defer soreceive()
- * to an nfsd so that there is feedback to the TCP layer that
- * the nfs servers are heavily loaded.
- */
- if (STAILQ_FIRST(&slp->ns_rec) && waitflag == M_DONTWAIT) {
- slp->ns_flag |= SLP_NEEDQ;
- goto dorecs;
- }
-
- /*
- * Do soreceive().
- */
- auio.uio_resid = 1000000000;
- flags = MSG_DONTWAIT;
- error = so->so_proto->pr_usrreqs->pru_soreceive
- (so, &nam, &auio, &mp, (struct mbuf **)0, &flags);
- if (error || mp == (struct mbuf *)0) {
- if (error == EWOULDBLOCK)
- slp->ns_flag |= SLP_NEEDQ;
- else
- slp->ns_flag |= SLP_DISCONN;
- goto dorecs;
- }
- m = mp;
- if (slp->ns_rawend) {
- slp->ns_rawend->m_next = m;
- slp->ns_cc += 1000000000 - auio.uio_resid;
- } else {
- slp->ns_raw = m;
- slp->ns_cc = 1000000000 - auio.uio_resid;
- }
- while (m->m_next)
- m = m->m_next;
- slp->ns_rawend = m;
-
- /*
- * Now try and parse record(s) out of the raw stream data.
- */
- error = nfsrv_getstream(slp, waitflag);
- if (error) {
- if (error == EPERM)
- slp->ns_flag |= SLP_DISCONN;
- else
- slp->ns_flag |= SLP_NEEDQ;
- }
- } else {
- do {
- auio.uio_resid = 1000000000;
- flags = MSG_DONTWAIT;
- error = so->so_proto->pr_usrreqs->pru_soreceive
- (so, &nam, &auio, &mp,
- (struct mbuf **)0, &flags);
- if (mp) {
- struct nfsrv_rec *rec;
- rec = malloc(sizeof(struct nfsrv_rec),
- M_NFSRVDESC, waitflag);
- if (!rec) {
- if (nam)
- FREE(nam, M_SONAME);
- m_freem(mp);
- continue;
- }
- nfs_realign(&mp, 10 * NFSX_UNSIGNED);
- rec->nr_address = nam;
- rec->nr_packet = mp;
- STAILQ_INSERT_TAIL(&slp->ns_rec, rec, nr_link);
- }
- if (error) {
- if ((so->so_proto->pr_flags & PR_CONNREQUIRED)
- && error != EWOULDBLOCK) {
- slp->ns_flag |= SLP_DISCONN;
- goto dorecs;
- }
- }
- } while (mp);
- }
-
- /*
- * Now try and process the request records, non-blocking.
- */
-dorecs:
- if (waitflag == M_DONTWAIT &&
- (STAILQ_FIRST(&slp->ns_rec)
- || (slp->ns_flag & (SLP_NEEDQ | SLP_DISCONN))))
- nfsrv_wakenfsd(slp);
-}
-
-/*
- * Try and extract an RPC request from the mbuf data list received on a
- * stream socket. The "waitflag" argument indicates whether or not it
- * can sleep.
- */
-static int
-nfsrv_getstream(slp, waitflag)
- register struct nfssvc_sock *slp;
- int waitflag;
-{
- register struct mbuf *m, **mpp;
- register char *cp1, *cp2;
- register int len;
- struct mbuf *om, *m2, *recm = NULL;
- u_int32_t recmark;
-
- if (slp->ns_flag & SLP_GETSTREAM)
- panic("nfs getstream");
- slp->ns_flag |= SLP_GETSTREAM;
- for (;;) {
- if (slp->ns_reclen == 0) {
- if (slp->ns_cc < NFSX_UNSIGNED) {
- slp->ns_flag &= ~SLP_GETSTREAM;
- return (0);
- }
- m = slp->ns_raw;
- if (m->m_len >= NFSX_UNSIGNED) {
- bcopy(mtod(m, caddr_t), (caddr_t)&recmark, NFSX_UNSIGNED);
- m->m_data += NFSX_UNSIGNED;
- m->m_len -= NFSX_UNSIGNED;
- } else {
- cp1 = (caddr_t)&recmark;
- cp2 = mtod(m, caddr_t);
- while (cp1 < ((caddr_t)&recmark) + NFSX_UNSIGNED) {
- while (m->m_len == 0) {
- m = m->m_next;
- cp2 = mtod(m, caddr_t);
- }
- *cp1++ = *cp2++;
- m->m_data++;
- m->m_len--;
- }
- }
- slp->ns_cc -= NFSX_UNSIGNED;
- recmark = ntohl(recmark);
- slp->ns_reclen = recmark & ~0x80000000;
- if (recmark & 0x80000000)
- slp->ns_flag |= SLP_LASTFRAG;
- else
- slp->ns_flag &= ~SLP_LASTFRAG;
- if (slp->ns_reclen > NFS_MAXPACKET) {
- slp->ns_flag &= ~SLP_GETSTREAM;
- return (EPERM);
- }
- }
-
- /*
- * Now get the record part.
- */
- if (slp->ns_cc == slp->ns_reclen) {
- recm = slp->ns_raw;
- slp->ns_raw = slp->ns_rawend = (struct mbuf *)0;
- slp->ns_cc = slp->ns_reclen = 0;
- } else if (slp->ns_cc > slp->ns_reclen) {
- len = 0;
- m = slp->ns_raw;
- om = (struct mbuf *)0;
- while (len < slp->ns_reclen) {
- if ((len + m->m_len) > slp->ns_reclen) {
- m2 = m_copym(m, 0, slp->ns_reclen - len,
- waitflag);
- if (m2) {
- if (om) {
- om->m_next = m2;
- recm = slp->ns_raw;
- } else
- recm = m2;
- m->m_data += slp->ns_reclen - len;
- m->m_len -= slp->ns_reclen - len;
- len = slp->ns_reclen;
- } else {
- slp->ns_flag &= ~SLP_GETSTREAM;
- return (EWOULDBLOCK);
- }
- } else if ((len + m->m_len) == slp->ns_reclen) {
- om = m;
- len += m->m_len;
- m = m->m_next;
- recm = slp->ns_raw;
- om->m_next = (struct mbuf *)0;
- } else {
- om = m;
- len += m->m_len;
- m = m->m_next;
- }
- }
- slp->ns_raw = m;
- slp->ns_cc -= len;
- slp->ns_reclen = 0;
- } else {
- slp->ns_flag &= ~SLP_GETSTREAM;
- return (0);
- }
-
- /*
- * Accumulate the fragments into a record.
- */
- mpp = &slp->ns_frag;
- while (*mpp)
- mpp = &((*mpp)->m_next);
- *mpp = recm;
- if (slp->ns_flag & SLP_LASTFRAG) {
- struct nfsrv_rec *rec;
- rec = malloc(sizeof(struct nfsrv_rec), M_NFSRVDESC, waitflag);
- if (!rec) {
- m_freem(slp->ns_frag);
- } else {
- nfs_realign(&slp->ns_frag, 10 * NFSX_UNSIGNED);
- rec->nr_address = (struct sockaddr *)0;
- rec->nr_packet = slp->ns_frag;
- STAILQ_INSERT_TAIL(&slp->ns_rec, rec, nr_link);
- }
- slp->ns_frag = (struct mbuf *)0;
- }
- }
-}
-
-/*
- * Parse an RPC header.
- */
-int
-nfsrv_dorec(slp, nfsd, ndp)
- register struct nfssvc_sock *slp;
- struct nfsd *nfsd;
- struct nfsrv_descript **ndp;
-{
- struct nfsrv_rec *rec;
- register struct mbuf *m;
- struct sockaddr *nam;
- register struct nfsrv_descript *nd;
- int error;
-
- *ndp = NULL;
- if ((slp->ns_flag & SLP_VALID) == 0 || !STAILQ_FIRST(&slp->ns_rec))
- return (ENOBUFS);
- rec = STAILQ_FIRST(&slp->ns_rec);
- STAILQ_REMOVE_HEAD(&slp->ns_rec, nr_link);
- nam = rec->nr_address;
- m = rec->nr_packet;
- free(rec, M_NFSRVDESC);
- MALLOC(nd, struct nfsrv_descript *, sizeof (struct nfsrv_descript),
- M_NFSRVDESC, M_WAITOK);
- nd->nd_md = nd->nd_mrep = m;
- nd->nd_nam2 = nam;
- nd->nd_dpos = mtod(m, caddr_t);
- error = nfs_getreq(nd, nfsd, TRUE);
- if (error) {
- if (nam) {
- FREE(nam, M_SONAME);
- }
- free((caddr_t)nd, M_NFSRVDESC);
- return (error);
- }
- *ndp = nd;
- nfsd->nfsd_nd = nd;
- return (0);
-}
-
-/*
- * Search for a sleeping nfsd and wake it up.
- * SIDE EFFECT: If none found, set NFSD_CHECKSLP flag, so that one of the
- * running nfsds will go look for the work in the nfssvc_sock list.
- */
-void
-nfsrv_wakenfsd(slp)
- struct nfssvc_sock *slp;
-{
- register struct nfsd *nd;
-
- if ((slp->ns_flag & SLP_VALID) == 0)
- return;
- for (nd = nfsd_head.tqh_first; nd != 0; nd = nd->nfsd_chain.tqe_next) {
- if (nd->nfsd_flag & NFSD_WAITING) {
- nd->nfsd_flag &= ~NFSD_WAITING;
- if (nd->nfsd_slp)
- panic("nfsd wakeup");
- slp->ns_sref++;
- nd->nfsd_slp = slp;
- wakeup((caddr_t)nd);
- return;
- }
- }
- slp->ns_flag |= SLP_DOREC;
- nfsd_head_flag |= NFSD_CHECKSLP;
-}
-#endif /* NFS_NOSERVER */
diff --git a/sys/nfsserver/nfs_srvsubs.c b/sys/nfsserver/nfs_srvsubs.c
deleted file mode 100644
index 2e197211f72a..000000000000
--- a/sys/nfsserver/nfs_srvsubs.c
+++ /dev/null
@@ -1,2229 +0,0 @@
-/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Rick Macklem at The University of Guelph.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)nfs_subs.c 8.8 (Berkeley) 5/22/95
- * $FreeBSD$
- */
-
-/*
- * These functions support the macros and help fiddle mbuf chains for
- * the nfs op functions. They do things like create the rpc header and
- * copy data between mbuf chains and uio lists.
- */
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/buf.h>
-#include <sys/proc.h>
-#include <sys/mount.h>
-#include <sys/vnode.h>
-#include <sys/namei.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <sys/malloc.h>
-#include <sys/sysent.h>
-#include <sys/syscall.h>
-#include <sys/conf.h>
-
-#include <vm/vm.h>
-#include <vm/vm_object.h>
-#include <vm/vm_extern.h>
-#include <vm/vm_zone.h>
-
-#include <nfs/rpcv2.h>
-#include <nfs/nfsproto.h>
-#include <nfs/nfs.h>
-#include <nfs/nfsnode.h>
-#include <nfs/xdr_subs.h>
-#include <nfs/nfsm_subs.h>
-#include <nfs/nfsmount.h>
-#include <nfs/nqnfs.h>
-#include <nfs/nfsrtt.h>
-
-#include <netinet/in.h>
-
-/*
- * Data items converted to xdr at startup, since they are constant
- * This is kinda hokey, but may save a little time doing byte swaps
- */
-u_int32_t nfs_xdrneg1;
-u_int32_t rpc_call, rpc_vers, rpc_reply, rpc_msgdenied, rpc_autherr,
- rpc_mismatch, rpc_auth_unix, rpc_msgaccepted,
- rpc_auth_kerb;
-u_int32_t nfs_prog, nqnfs_prog, nfs_true, nfs_false;
-
-/* And other global data */
-static u_int32_t nfs_xid = 0;
-static enum vtype nv2tov_type[8]= {
- VNON, VREG, VDIR, VBLK, VCHR, VLNK, VNON, VNON
-};
-enum vtype nv3tov_type[8]= {
- VNON, VREG, VDIR, VBLK, VCHR, VLNK, VSOCK, VFIFO
-};
-
-int nfs_ticks;
-int nfs_pbuf_freecnt = -1; /* start out unlimited */
-
-struct nfs_reqq nfs_reqq;
-struct nfssvc_sockhead nfssvc_sockhead;
-int nfssvc_sockhead_flag;
-struct nfsd_head nfsd_head;
-int nfsd_head_flag;
-struct nfs_bufq nfs_bufq;
-struct nqtimerhead nqtimerhead;
-struct nqfhhashhead *nqfhhashtbl;
-u_long nqfhhash;
-
-static void (*nfs_prev_lease_updatetime) __P((int));
-static int nfs_prev_nfssvc_sy_narg;
-static sy_call_t *nfs_prev_nfssvc_sy_call;
-
-#ifndef NFS_NOSERVER
-
-static vop_t *nfs_prev_vop_lease_check;
-
-/*
- * Mapping of old NFS Version 2 RPC numbers to generic numbers.
- */
-int nfsv3_procid[NFS_NPROCS] = {
- NFSPROC_NULL,
- NFSPROC_GETATTR,
- NFSPROC_SETATTR,
- NFSPROC_NOOP,
- NFSPROC_LOOKUP,
- NFSPROC_READLINK,
- NFSPROC_READ,
- NFSPROC_NOOP,
- NFSPROC_WRITE,
- NFSPROC_CREATE,
- NFSPROC_REMOVE,
- NFSPROC_RENAME,
- NFSPROC_LINK,
- NFSPROC_SYMLINK,
- NFSPROC_MKDIR,
- NFSPROC_RMDIR,
- NFSPROC_READDIR,
- NFSPROC_FSSTAT,
- NFSPROC_NOOP,
- NFSPROC_NOOP,
- NFSPROC_NOOP,
- NFSPROC_NOOP,
- NFSPROC_NOOP,
- NFSPROC_NOOP,
- NFSPROC_NOOP,
- NFSPROC_NOOP
-};
-
-#endif /* NFS_NOSERVER */
-/*
- * and the reverse mapping from generic to Version 2 procedure numbers
- */
-int nfsv2_procid[NFS_NPROCS] = {
- NFSV2PROC_NULL,
- NFSV2PROC_GETATTR,
- NFSV2PROC_SETATTR,
- NFSV2PROC_LOOKUP,
- NFSV2PROC_NOOP,
- NFSV2PROC_READLINK,
- NFSV2PROC_READ,
- NFSV2PROC_WRITE,
- NFSV2PROC_CREATE,
- NFSV2PROC_MKDIR,
- NFSV2PROC_SYMLINK,
- NFSV2PROC_CREATE,
- NFSV2PROC_REMOVE,
- NFSV2PROC_RMDIR,
- NFSV2PROC_RENAME,
- NFSV2PROC_LINK,
- NFSV2PROC_READDIR,
- NFSV2PROC_NOOP,
- NFSV2PROC_STATFS,
- NFSV2PROC_NOOP,
- NFSV2PROC_NOOP,
- NFSV2PROC_NOOP,
- NFSV2PROC_NOOP,
- NFSV2PROC_NOOP,
- NFSV2PROC_NOOP,
- NFSV2PROC_NOOP,
-};
-
-#ifndef NFS_NOSERVER
-/*
- * Maps errno values to nfs error numbers.
- * Use NFSERR_IO as the catch all for ones not specifically defined in
- * RFC 1094.
- */
-static u_char nfsrv_v2errmap[ELAST] = {
- NFSERR_PERM, NFSERR_NOENT, NFSERR_IO, NFSERR_IO, NFSERR_IO,
- NFSERR_NXIO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
- NFSERR_IO, NFSERR_IO, NFSERR_ACCES, NFSERR_IO, NFSERR_IO,
- NFSERR_IO, NFSERR_EXIST, NFSERR_IO, NFSERR_NODEV, NFSERR_NOTDIR,
- NFSERR_ISDIR, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
- NFSERR_IO, NFSERR_FBIG, NFSERR_NOSPC, NFSERR_IO, NFSERR_ROFS,
- NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
- NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
- NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
- NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
- NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
- NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
- NFSERR_IO, NFSERR_IO, NFSERR_NAMETOL, NFSERR_IO, NFSERR_IO,
- NFSERR_NOTEMPTY, NFSERR_IO, NFSERR_IO, NFSERR_DQUOT, NFSERR_STALE,
- NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
- NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
- NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO, NFSERR_IO,
- NFSERR_IO /* << Last is 86 */
-};
-
-/*
- * Maps errno values to nfs error numbers.
- * Although it is not obvious whether or not NFS clients really care if
- * a returned error value is in the specified list for the procedure, the
- * safest thing to do is filter them appropriately. For Version 2, the
- * X/Open XNFS document is the only specification that defines error values
- * for each RPC (The RFC simply lists all possible error values for all RPCs),
- * so I have decided to not do this for Version 2.
- * The first entry is the default error return and the rest are the valid
- * errors for that RPC in increasing numeric order.
- */
-static short nfsv3err_null[] = {
- 0,
- 0,
-};
-
-static short nfsv3err_getattr[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_setattr[] = {
- NFSERR_IO,
- NFSERR_PERM,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_INVAL,
- NFSERR_NOSPC,
- NFSERR_ROFS,
- NFSERR_DQUOT,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_NOT_SYNC,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_lookup[] = {
- NFSERR_IO,
- NFSERR_NOENT,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_NOTDIR,
- NFSERR_NAMETOL,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_access[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_readlink[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_INVAL,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_NOTSUPP,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_read[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_NXIO,
- NFSERR_ACCES,
- NFSERR_INVAL,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_write[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_INVAL,
- NFSERR_FBIG,
- NFSERR_NOSPC,
- NFSERR_ROFS,
- NFSERR_DQUOT,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_create[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_EXIST,
- NFSERR_NOTDIR,
- NFSERR_NOSPC,
- NFSERR_ROFS,
- NFSERR_NAMETOL,
- NFSERR_DQUOT,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_NOTSUPP,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_mkdir[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_EXIST,
- NFSERR_NOTDIR,
- NFSERR_NOSPC,
- NFSERR_ROFS,
- NFSERR_NAMETOL,
- NFSERR_DQUOT,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_NOTSUPP,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_symlink[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_EXIST,
- NFSERR_NOTDIR,
- NFSERR_NOSPC,
- NFSERR_ROFS,
- NFSERR_NAMETOL,
- NFSERR_DQUOT,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_NOTSUPP,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_mknod[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_EXIST,
- NFSERR_NOTDIR,
- NFSERR_NOSPC,
- NFSERR_ROFS,
- NFSERR_NAMETOL,
- NFSERR_DQUOT,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_NOTSUPP,
- NFSERR_SERVERFAULT,
- NFSERR_BADTYPE,
- 0,
-};
-
-static short nfsv3err_remove[] = {
- NFSERR_IO,
- NFSERR_NOENT,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_NOTDIR,
- NFSERR_ROFS,
- NFSERR_NAMETOL,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_rmdir[] = {
- NFSERR_IO,
- NFSERR_NOENT,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_EXIST,
- NFSERR_NOTDIR,
- NFSERR_INVAL,
- NFSERR_ROFS,
- NFSERR_NAMETOL,
- NFSERR_NOTEMPTY,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_NOTSUPP,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_rename[] = {
- NFSERR_IO,
- NFSERR_NOENT,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_EXIST,
- NFSERR_XDEV,
- NFSERR_NOTDIR,
- NFSERR_ISDIR,
- NFSERR_INVAL,
- NFSERR_NOSPC,
- NFSERR_ROFS,
- NFSERR_MLINK,
- NFSERR_NAMETOL,
- NFSERR_NOTEMPTY,
- NFSERR_DQUOT,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_NOTSUPP,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_link[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_EXIST,
- NFSERR_XDEV,
- NFSERR_NOTDIR,
- NFSERR_INVAL,
- NFSERR_NOSPC,
- NFSERR_ROFS,
- NFSERR_MLINK,
- NFSERR_NAMETOL,
- NFSERR_DQUOT,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_NOTSUPP,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_readdir[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_NOTDIR,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_BAD_COOKIE,
- NFSERR_TOOSMALL,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_readdirplus[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_ACCES,
- NFSERR_NOTDIR,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_BAD_COOKIE,
- NFSERR_NOTSUPP,
- NFSERR_TOOSMALL,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_fsstat[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_fsinfo[] = {
- NFSERR_STALE,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_pathconf[] = {
- NFSERR_STALE,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short nfsv3err_commit[] = {
- NFSERR_IO,
- NFSERR_IO,
- NFSERR_STALE,
- NFSERR_BADHANDLE,
- NFSERR_SERVERFAULT,
- 0,
-};
-
-static short *nfsrv_v3errmap[] = {
- nfsv3err_null,
- nfsv3err_getattr,
- nfsv3err_setattr,
- nfsv3err_lookup,
- nfsv3err_access,
- nfsv3err_readlink,
- nfsv3err_read,
- nfsv3err_write,
- nfsv3err_create,
- nfsv3err_mkdir,
- nfsv3err_symlink,
- nfsv3err_mknod,
- nfsv3err_remove,
- nfsv3err_rmdir,
- nfsv3err_rename,
- nfsv3err_link,
- nfsv3err_readdir,
- nfsv3err_readdirplus,
- nfsv3err_fsstat,
- nfsv3err_fsinfo,
- nfsv3err_pathconf,
- nfsv3err_commit,
-};
-
-#endif /* NFS_NOSERVER */
-
-extern struct nfsrtt nfsrtt;
-extern time_t nqnfsstarttime;
-extern int nqsrv_clockskew;
-extern int nqsrv_writeslack;
-extern int nqsrv_maxlease;
-extern struct nfsstats nfsstats;
-extern int nqnfs_piggy[NFS_NPROCS];
-extern nfstype nfsv2_type[9];
-extern nfstype nfsv3_type[9];
-extern struct nfsnodehashhead *nfsnodehashtbl;
-extern u_long nfsnodehash;
-
-struct nfssvc_args;
-extern int nfssvc(struct proc *, struct nfssvc_args *, int *);
-
-LIST_HEAD(nfsnodehashhead, nfsnode);
-
-int nfs_webnamei __P((struct nameidata *, struct vnode *, struct proc *));
-
-u_quad_t
-nfs_curusec()
-{
- struct timeval tv;
-
- getmicrotime(&tv);
- return ((u_quad_t)tv.tv_sec * 1000000 + (u_quad_t)tv.tv_usec);
-}
-
-/*
- * Create the header for an rpc request packet
- * The hsiz is the size of the rest of the nfs request header.
- * (just used to decide if a cluster is a good idea)
- */
-struct mbuf *
-nfsm_reqh(vp, procid, hsiz, bposp)
- struct vnode *vp;
- u_long procid;
- int hsiz;
- caddr_t *bposp;
-{
- register struct mbuf *mb;
- register u_int32_t *tl;
- register caddr_t bpos;
- struct mbuf *mb2;
- struct nfsmount *nmp;
- int nqflag;
-
- MGET(mb, M_WAIT, MT_DATA);
- if (hsiz >= MINCLSIZE)
- MCLGET(mb, M_WAIT);
- mb->m_len = 0;
- bpos = mtod(mb, caddr_t);
-
- /*
- * For NQNFS, add lease request.
- */
- if (vp) {
- nmp = VFSTONFS(vp->v_mount);
- if (nmp->nm_flag & NFSMNT_NQNFS) {
- nqflag = NQNFS_NEEDLEASE(vp, procid);
- if (nqflag) {
- nfsm_build(tl, u_int32_t *, 2*NFSX_UNSIGNED);
- *tl++ = txdr_unsigned(nqflag);
- *tl = txdr_unsigned(nmp->nm_leaseterm);
- } else {
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);
- *tl = 0;
- }
- }
- }
- /* Finally, return values */
- *bposp = bpos;
- return (mb);
-}
-
-/*
- * Build the RPC header and fill in the authorization info.
- * The authorization string argument is only used when the credentials
- * come from outside of the kernel.
- * Returns the head of the mbuf list.
- */
-struct mbuf *
-nfsm_rpchead(cr, nmflag, procid, auth_type, auth_len, auth_str, verf_len,
- verf_str, mrest, mrest_len, mbp, xidp)
- register struct ucred *cr;
- int nmflag;
- int procid;
- int auth_type;
- int auth_len;
- char *auth_str;
- int verf_len;
- char *verf_str;
- struct mbuf *mrest;
- int mrest_len;
- struct mbuf **mbp;
- u_int32_t *xidp;
-{
- register struct mbuf *mb;
- register u_int32_t *tl;
- register caddr_t bpos;
- register int i;
- struct mbuf *mreq, *mb2;
- int siz, grpsiz, authsiz;
-
- authsiz = nfsm_rndup(auth_len);
- MGETHDR(mb, M_WAIT, MT_DATA);
- if ((authsiz + 10 * NFSX_UNSIGNED) >= MINCLSIZE) {
- MCLGET(mb, M_WAIT);
- } else if ((authsiz + 10 * NFSX_UNSIGNED) < MHLEN) {
- MH_ALIGN(mb, authsiz + 10 * NFSX_UNSIGNED);
- } else {
- MH_ALIGN(mb, 8 * NFSX_UNSIGNED);
- }
- mb->m_len = 0;
- mreq = mb;
- bpos = mtod(mb, caddr_t);
-
- /*
- * First the RPC header.
- */
- nfsm_build(tl, u_int32_t *, 8 * NFSX_UNSIGNED);
-
- /* Get a pretty random xid to start with */
- if (!nfs_xid)
- nfs_xid = random();
- /*
- * Skip zero xid if it should ever happen.
- */
- if (++nfs_xid == 0)
- nfs_xid++;
-
- *tl++ = *xidp = txdr_unsigned(nfs_xid);
- *tl++ = rpc_call;
- *tl++ = rpc_vers;
- if (nmflag & NFSMNT_NQNFS) {
- *tl++ = txdr_unsigned(NQNFS_PROG);
- *tl++ = txdr_unsigned(NQNFS_VER3);
- } else {
- *tl++ = txdr_unsigned(NFS_PROG);
- if (nmflag & NFSMNT_NFSV3)
- *tl++ = txdr_unsigned(NFS_VER3);
- else
- *tl++ = txdr_unsigned(NFS_VER2);
- }
- if (nmflag & NFSMNT_NFSV3)
- *tl++ = txdr_unsigned(procid);
- else
- *tl++ = txdr_unsigned(nfsv2_procid[procid]);
-
- /*
- * And then the authorization cred.
- */
- *tl++ = txdr_unsigned(auth_type);
- *tl = txdr_unsigned(authsiz);
- switch (auth_type) {
- case RPCAUTH_UNIX:
- nfsm_build(tl, u_int32_t *, auth_len);
- *tl++ = 0; /* stamp ?? */
- *tl++ = 0; /* NULL hostname */
- *tl++ = txdr_unsigned(cr->cr_uid);
- *tl++ = txdr_unsigned(cr->cr_groups[0]);
- grpsiz = (auth_len >> 2) - 5;
- *tl++ = txdr_unsigned(grpsiz);
- for (i = 1; i <= grpsiz; i++)
- *tl++ = txdr_unsigned(cr->cr_groups[i]);
- break;
- case RPCAUTH_KERB4:
- siz = auth_len;
- while (siz > 0) {
- if (M_TRAILINGSPACE(mb) == 0) {
- MGET(mb2, M_WAIT, MT_DATA);
- if (siz >= MINCLSIZE)
- MCLGET(mb2, M_WAIT);
- mb->m_next = mb2;
- mb = mb2;
- mb->m_len = 0;
- bpos = mtod(mb, caddr_t);
- }
- i = min(siz, M_TRAILINGSPACE(mb));
- bcopy(auth_str, bpos, i);
- mb->m_len += i;
- auth_str += i;
- bpos += i;
- siz -= i;
- }
- if ((siz = (nfsm_rndup(auth_len) - auth_len)) > 0) {
- for (i = 0; i < siz; i++)
- *bpos++ = '\0';
- mb->m_len += siz;
- }
- break;
- };
-
- /*
- * And the verifier...
- */
- nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
- if (verf_str) {
- *tl++ = txdr_unsigned(RPCAUTH_KERB4);
- *tl = txdr_unsigned(verf_len);
- siz = verf_len;
- while (siz > 0) {
- if (M_TRAILINGSPACE(mb) == 0) {
- MGET(mb2, M_WAIT, MT_DATA);
- if (siz >= MINCLSIZE)
- MCLGET(mb2, M_WAIT);
- mb->m_next = mb2;
- mb = mb2;
- mb->m_len = 0;
- bpos = mtod(mb, caddr_t);
- }
- i = min(siz, M_TRAILINGSPACE(mb));
- bcopy(verf_str, bpos, i);
- mb->m_len += i;
- verf_str += i;
- bpos += i;
- siz -= i;
- }
- if ((siz = (nfsm_rndup(verf_len) - verf_len)) > 0) {
- for (i = 0; i < siz; i++)
- *bpos++ = '\0';
- mb->m_len += siz;
- }
- } else {
- *tl++ = txdr_unsigned(RPCAUTH_NULL);
- *tl = 0;
- }
- mb->m_next = mrest;
- mreq->m_pkthdr.len = authsiz + 10 * NFSX_UNSIGNED + mrest_len;
- mreq->m_pkthdr.rcvif = (struct ifnet *)0;
- *mbp = mb;
- return (mreq);
-}
-
-/*
- * copies mbuf chain to the uio scatter/gather list
- */
-int
-nfsm_mbuftouio(mrep, uiop, siz, dpos)
- struct mbuf **mrep;
- register struct uio *uiop;
- int siz;
- caddr_t *dpos;
-{
- register char *mbufcp, *uiocp;
- register int xfer, left, len;
- register struct mbuf *mp;
- long uiosiz, rem;
- int error = 0;
-
- mp = *mrep;
- mbufcp = *dpos;
- len = mtod(mp, caddr_t)+mp->m_len-mbufcp;
- rem = nfsm_rndup(siz)-siz;
- while (siz > 0) {
- if (uiop->uio_iovcnt <= 0 || uiop->uio_iov == NULL)
- return (EFBIG);
- left = uiop->uio_iov->iov_len;
- uiocp = uiop->uio_iov->iov_base;
- if (left > siz)
- left = siz;
- uiosiz = left;
- while (left > 0) {
- while (len == 0) {
- mp = mp->m_next;
- if (mp == NULL)
- return (EBADRPC);
- mbufcp = mtod(mp, caddr_t);
- len = mp->m_len;
- }
- xfer = (left > len) ? len : left;
-#ifdef notdef
- /* Not Yet.. */
- if (uiop->uio_iov->iov_op != NULL)
- (*(uiop->uio_iov->iov_op))
- (mbufcp, uiocp, xfer);
- else
-#endif
- if (uiop->uio_segflg == UIO_SYSSPACE)
- bcopy(mbufcp, uiocp, xfer);
- else
- copyout(mbufcp, uiocp, xfer);
- left -= xfer;
- len -= xfer;
- mbufcp += xfer;
- uiocp += xfer;
- uiop->uio_offset += xfer;
- uiop->uio_resid -= xfer;
- }
- if (uiop->uio_iov->iov_len <= siz) {
- uiop->uio_iovcnt--;
- uiop->uio_iov++;
- } else {
- uiop->uio_iov->iov_base += uiosiz;
- uiop->uio_iov->iov_len -= uiosiz;
- }
- siz -= uiosiz;
- }
- *dpos = mbufcp;
- *mrep = mp;
- if (rem > 0) {
- if (len < rem)
- error = nfs_adv(mrep, dpos, rem, len);
- else
- *dpos += rem;
- }
- return (error);
-}
-
-/*
- * copies a uio scatter/gather list to an mbuf chain.
- * NOTE: can ony handle iovcnt == 1
- */
-int
-nfsm_uiotombuf(uiop, mq, siz, bpos)
- register struct uio *uiop;
- struct mbuf **mq;
- int siz;
- caddr_t *bpos;
-{
- register char *uiocp;
- register struct mbuf *mp, *mp2;
- register int xfer, left, mlen;
- int uiosiz, clflg, rem;
- char *cp;
-
-#ifdef DIAGNOSTIC
- if (uiop->uio_iovcnt != 1)
- panic("nfsm_uiotombuf: iovcnt != 1");
-#endif
-
- if (siz > MLEN) /* or should it >= MCLBYTES ?? */
- clflg = 1;
- else
- clflg = 0;
- rem = nfsm_rndup(siz)-siz;
- mp = mp2 = *mq;
- while (siz > 0) {
- left = uiop->uio_iov->iov_len;
- uiocp = uiop->uio_iov->iov_base;
- if (left > siz)
- left = siz;
- uiosiz = left;
- while (left > 0) {
- mlen = M_TRAILINGSPACE(mp);
- if (mlen == 0) {
- MGET(mp, M_WAIT, MT_DATA);
- if (clflg)
- MCLGET(mp, M_WAIT);
- mp->m_len = 0;
- mp2->m_next = mp;
- mp2 = mp;
- mlen = M_TRAILINGSPACE(mp);
- }
- xfer = (left > mlen) ? mlen : left;
-#ifdef notdef
- /* Not Yet.. */
- if (uiop->uio_iov->iov_op != NULL)
- (*(uiop->uio_iov->iov_op))
- (uiocp, mtod(mp, caddr_t)+mp->m_len, xfer);
- else
-#endif
- if (uiop->uio_segflg == UIO_SYSSPACE)
- bcopy(uiocp, mtod(mp, caddr_t)+mp->m_len, xfer);
- else
- copyin(uiocp, mtod(mp, caddr_t)+mp->m_len, xfer);
- mp->m_len += xfer;
- left -= xfer;
- uiocp += xfer;
- uiop->uio_offset += xfer;
- uiop->uio_resid -= xfer;
- }
- uiop->uio_iov->iov_base += uiosiz;
- uiop->uio_iov->iov_len -= uiosiz;
- siz -= uiosiz;
- }
- if (rem > 0) {
- if (rem > M_TRAILINGSPACE(mp)) {
- MGET(mp, M_WAIT, MT_DATA);
- mp->m_len = 0;
- mp2->m_next = mp;
- }
- cp = mtod(mp, caddr_t)+mp->m_len;
- for (left = 0; left < rem; left++)
- *cp++ = '\0';
- mp->m_len += rem;
- *bpos = cp;
- } else
- *bpos = mtod(mp, caddr_t)+mp->m_len;
- *mq = mp;
- return (0);
-}
-
-/*
- * Help break down an mbuf chain by setting the first siz bytes contiguous
- * pointed to by returned val.
- * This is used by the macros nfsm_dissect and nfsm_dissecton for tough
- * cases. (The macros use the vars. dpos and dpos2)
- */
-int
-nfsm_disct(mdp, dposp, siz, left, cp2)
- struct mbuf **mdp;
- caddr_t *dposp;
- int siz;
- int left;
- caddr_t *cp2;
-{
- register struct mbuf *mp, *mp2;
- register int siz2, xfer;
- register caddr_t p;
-
- mp = *mdp;
- while (left == 0) {
- *mdp = mp = mp->m_next;
- if (mp == NULL)
- return (EBADRPC);
- left = mp->m_len;
- *dposp = mtod(mp, caddr_t);
- }
- if (left >= siz) {
- *cp2 = *dposp;
- *dposp += siz;
- } else if (mp->m_next == NULL) {
- return (EBADRPC);
- } else if (siz > MHLEN) {
- panic("nfs S too big");
- } else {
- MGET(mp2, M_WAIT, MT_DATA);
- mp2->m_next = mp->m_next;
- mp->m_next = mp2;
- mp->m_len -= left;
- mp = mp2;
- *cp2 = p = mtod(mp, caddr_t);
- bcopy(*dposp, p, left); /* Copy what was left */
- siz2 = siz-left;
- p += left;
- mp2 = mp->m_next;
- /* Loop around copying up the siz2 bytes */
- while (siz2 > 0) {
- if (mp2 == NULL)
- return (EBADRPC);
- xfer = (siz2 > mp2->m_len) ? mp2->m_len : siz2;
- if (xfer > 0) {
- bcopy(mtod(mp2, caddr_t), p, xfer);
- NFSMADV(mp2, xfer);
- mp2->m_len -= xfer;
- p += xfer;
- siz2 -= xfer;
- }
- if (siz2 > 0)
- mp2 = mp2->m_next;
- }
- mp->m_len = siz;
- *mdp = mp2;
- *dposp = mtod(mp2, caddr_t);
- }
- return (0);
-}
-
-/*
- * Advance the position in the mbuf chain.
- */
-int
-nfs_adv(mdp, dposp, offs, left)
- struct mbuf **mdp;
- caddr_t *dposp;
- int offs;
- int left;
-{
- register struct mbuf *m;
- register int s;
-
- m = *mdp;
- s = left;
- while (s < offs) {
- offs -= s;
- m = m->m_next;
- if (m == NULL)
- return (EBADRPC);
- s = m->m_len;
- }
- *mdp = m;
- *dposp = mtod(m, caddr_t)+offs;
- return (0);
-}
-
-/*
- * Copy a string into mbufs for the hard cases...
- */
-int
-nfsm_strtmbuf(mb, bpos, cp, siz)
- struct mbuf **mb;
- char **bpos;
- const char *cp;
- long siz;
-{
- register struct mbuf *m1 = NULL, *m2;
- long left, xfer, len, tlen;
- u_int32_t *tl;
- int putsize;
-
- putsize = 1;
- m2 = *mb;
- left = M_TRAILINGSPACE(m2);
- if (left > 0) {
- tl = ((u_int32_t *)(*bpos));
- *tl++ = txdr_unsigned(siz);
- putsize = 0;
- left -= NFSX_UNSIGNED;
- m2->m_len += NFSX_UNSIGNED;
- if (left > 0) {
- bcopy(cp, (caddr_t) tl, left);
- siz -= left;
- cp += left;
- m2->m_len += left;
- left = 0;
- }
- }
- /* Loop around adding mbufs */
- while (siz > 0) {
- MGET(m1, M_WAIT, MT_DATA);
- if (siz > MLEN)
- MCLGET(m1, M_WAIT);
- m1->m_len = NFSMSIZ(m1);
- m2->m_next = m1;
- m2 = m1;
- tl = mtod(m1, u_int32_t *);
- tlen = 0;
- if (putsize) {
- *tl++ = txdr_unsigned(siz);
- m1->m_len -= NFSX_UNSIGNED;
- tlen = NFSX_UNSIGNED;
- putsize = 0;
- }
- if (siz < m1->m_len) {
- len = nfsm_rndup(siz);
- xfer = siz;
- if (xfer < len)
- *(tl+(xfer>>2)) = 0;
- } else {
- xfer = len = m1->m_len;
- }
- bcopy(cp, (caddr_t) tl, xfer);
- m1->m_len = len+tlen;
- siz -= xfer;
- cp += xfer;
- }
- *mb = m1;
- *bpos = mtod(m1, caddr_t)+m1->m_len;
- return (0);
-}
-
-/*
- * Called once to initialize data structures...
- */
-int
-nfs_init(vfsp)
- struct vfsconf *vfsp;
-{
- register int i;
-
- nfsmount_zone = zinit("NFSMOUNT", sizeof(struct nfsmount), 0, 0, 1);
-
- nfs_mount_type = vfsp->vfc_typenum;
- nfsrtt.pos = 0;
- rpc_vers = txdr_unsigned(RPC_VER2);
- rpc_call = txdr_unsigned(RPC_CALL);
- rpc_reply = txdr_unsigned(RPC_REPLY);
- rpc_msgdenied = txdr_unsigned(RPC_MSGDENIED);
- rpc_msgaccepted = txdr_unsigned(RPC_MSGACCEPTED);
- rpc_mismatch = txdr_unsigned(RPC_MISMATCH);
- rpc_autherr = txdr_unsigned(RPC_AUTHERR);
- rpc_auth_unix = txdr_unsigned(RPCAUTH_UNIX);
- rpc_auth_kerb = txdr_unsigned(RPCAUTH_KERB4);
- nfs_prog = txdr_unsigned(NFS_PROG);
- nqnfs_prog = txdr_unsigned(NQNFS_PROG);
- nfs_true = txdr_unsigned(TRUE);
- nfs_false = txdr_unsigned(FALSE);
- nfs_xdrneg1 = txdr_unsigned(-1);
- nfs_ticks = (hz * NFS_TICKINTVL + 500) / 1000;
- if (nfs_ticks < 1)
- nfs_ticks = 1;
- /* Ensure async daemons disabled */
- for (i = 0; i < NFS_MAXASYNCDAEMON; i++) {
- nfs_iodwant[i] = (struct proc *)0;
- nfs_iodmount[i] = (struct nfsmount *)0;
- }
- nfs_nhinit(); /* Init the nfsnode table */
-#ifndef NFS_NOSERVER
- nfsrv_init(0); /* Init server data structures */
- nfsrv_initcache(); /* Init the server request cache */
-#endif
-
- /*
- * Initialize the nqnfs server stuff.
- */
- if (nqnfsstarttime == 0) {
- nqnfsstarttime = boottime.tv_sec + nqsrv_maxlease
- + nqsrv_clockskew + nqsrv_writeslack;
- NQLOADNOVRAM(nqnfsstarttime);
- CIRCLEQ_INIT(&nqtimerhead);
- nqfhhashtbl = hashinit(NQLCHSZ, M_NQLEASE, &nqfhhash);
- }
-
- /*
- * Initialize reply list and start timer
- */
- TAILQ_INIT(&nfs_reqq);
-
- nfs_timer(0);
-
- /*
- * Set up lease_check and lease_updatetime so that other parts
- * of the system can call us, if we are loadable.
- */
-#ifndef NFS_NOSERVER
- nfs_prev_vop_lease_check = default_vnodeop_p[VOFFSET(vop_lease)];
- default_vnodeop_p[VOFFSET(vop_lease)] = (vop_t *)nqnfs_vop_lease_check;
-#endif
- nfs_prev_lease_updatetime = lease_updatetime;
- lease_updatetime = nfs_lease_updatetime;
- nfs_prev_nfssvc_sy_narg = sysent[SYS_nfssvc].sy_narg;
- sysent[SYS_nfssvc].sy_narg = 2;
- nfs_prev_nfssvc_sy_call = sysent[SYS_nfssvc].sy_call;
- sysent[SYS_nfssvc].sy_call = (sy_call_t *)nfssvc;
-
- nfs_pbuf_freecnt = nswbuf / 2 + 1;
-
- return (0);
-}
-
-int
-nfs_uninit(vfsp)
- struct vfsconf *vfsp;
-{
-
- untimeout(nfs_timer, (void *)NULL, nfs_timer_handle);
- nfs_mount_type = -1;
-#ifndef NFS_NOSERVER
- default_vnodeop_p[VOFFSET(vop_lease)] = nfs_prev_vop_lease_check;
-#endif
- lease_updatetime = nfs_prev_lease_updatetime;
- sysent[SYS_nfssvc].sy_narg = nfs_prev_nfssvc_sy_narg;
- sysent[SYS_nfssvc].sy_call = nfs_prev_nfssvc_sy_call;
- return (0);
-}
-
-/*
- * Attribute cache routines.
- * nfs_loadattrcache() - loads or updates the cache contents from attributes
- * that are on the mbuf list
- * nfs_getattrcache() - returns valid attributes if found in cache, returns
- * error otherwise
- */
-
-/*
- * Load the attribute cache (that lives in the nfsnode entry) with
- * the values on the mbuf list and
- * Iff vap not NULL
- * copy the attributes to *vaper
- */
-int
-nfs_loadattrcache(vpp, mdp, dposp, vaper)
- struct vnode **vpp;
- struct mbuf **mdp;
- caddr_t *dposp;
- struct vattr *vaper;
-{
- register struct vnode *vp = *vpp;
- register struct vattr *vap;
- register struct nfs_fattr *fp;
- register struct nfsnode *np;
- register int32_t t1;
- caddr_t cp2;
- int error = 0, rdev;
- struct mbuf *md;
- enum vtype vtyp;
- u_short vmode;
- struct timespec mtime;
- int v3 = NFS_ISV3(vp);
-
- md = *mdp;
- t1 = (mtod(md, caddr_t) + md->m_len) - *dposp;
- if ((error = nfsm_disct(mdp, dposp, NFSX_FATTR(v3), t1, &cp2)) != 0)
- return (error);
- fp = (struct nfs_fattr *)cp2;
- if (v3) {
- vtyp = nfsv3tov_type(fp->fa_type);
- vmode = fxdr_unsigned(u_short, fp->fa_mode);
- rdev = makeudev(fxdr_unsigned(int, fp->fa3_rdev.specdata1),
- fxdr_unsigned(int, fp->fa3_rdev.specdata2));
- fxdr_nfsv3time(&fp->fa3_mtime, &mtime);
- } else {
- vtyp = nfsv2tov_type(fp->fa_type);
- vmode = fxdr_unsigned(u_short, fp->fa_mode);
- /*
- * XXX
- *
- * The duplicate information returned in fa_type and fa_mode
- * is an ambiguity in the NFS version 2 protocol.
- *
- * VREG should be taken literally as a regular file. If a
- * server intents to return some type information differently
- * in the upper bits of the mode field (e.g. for sockets, or
- * FIFOs), NFSv2 mandates fa_type to be VNON. Anyway, we
- * leave the examination of the mode bits even in the VREG
- * case to avoid breakage for bogus servers, but we make sure
- * that there are actually type bits set in the upper part of
- * fa_mode (and failing that, trust the va_type field).
- *
- * NFSv3 cleared the issue, and requires fa_mode to not
- * contain any type information (while also introduing sockets
- * and FIFOs for fa_type).
- */
- if (vtyp == VNON || (vtyp == VREG && (vmode & S_IFMT) != 0))
- vtyp = IFTOVT(vmode);
- rdev = fxdr_unsigned(int32_t, fp->fa2_rdev);
- fxdr_nfsv2time(&fp->fa2_mtime, &mtime);
-
- /*
- * Really ugly NFSv2 kludge.
- */
- if (vtyp == VCHR && rdev == 0xffffffff)
- vtyp = VFIFO;
- }
-
- /*
- * If v_type == VNON it is a new node, so fill in the v_type,
- * n_mtime fields. Check to see if it represents a special
- * device, and if so, check for a possible alias. Once the
- * correct vnode has been obtained, fill in the rest of the
- * information.
- */
- np = VTONFS(vp);
- if (vp->v_type != vtyp) {
- vp->v_type = vtyp;
- if (vp->v_type == VFIFO) {
- vp->v_op = fifo_nfsv2nodeop_p;
- }
- if (vp->v_type == VCHR || vp->v_type == VBLK) {
- vp->v_op = spec_nfsv2nodeop_p;
- addaliasu(vp, rdev);
- }
- np->n_mtime = mtime.tv_sec;
- }
- vap = &np->n_vattr;
- vap->va_type = vtyp;
- vap->va_mode = (vmode & 07777);
- vap->va_rdev = rdev;
- vap->va_mtime = mtime;
- vap->va_fsid = vp->v_mount->mnt_stat.f_fsid.val[0];
- if (v3) {
- vap->va_nlink = fxdr_unsigned(u_short, fp->fa_nlink);
- vap->va_uid = fxdr_unsigned(uid_t, fp->fa_uid);
- vap->va_gid = fxdr_unsigned(gid_t, fp->fa_gid);
- vap->va_size = fxdr_hyper(&fp->fa3_size);
- vap->va_blocksize = NFS_FABLKSIZE;
- vap->va_bytes = fxdr_hyper(&fp->fa3_used);
- vap->va_fileid = fxdr_unsigned(int32_t,
- fp->fa3_fileid.nfsuquad[1]);
- fxdr_nfsv3time(&fp->fa3_atime, &vap->va_atime);
- fxdr_nfsv3time(&fp->fa3_ctime, &vap->va_ctime);
- vap->va_flags = 0;
- vap->va_filerev = 0;
- } else {
- vap->va_nlink = fxdr_unsigned(u_short, fp->fa_nlink);
- vap->va_uid = fxdr_unsigned(uid_t, fp->fa_uid);
- vap->va_gid = fxdr_unsigned(gid_t, fp->fa_gid);
- vap->va_size = fxdr_unsigned(u_int32_t, fp->fa2_size);
- vap->va_blocksize = fxdr_unsigned(int32_t, fp->fa2_blocksize);
- vap->va_bytes = (u_quad_t)fxdr_unsigned(int32_t, fp->fa2_blocks)
- * NFS_FABLKSIZE;
- vap->va_fileid = fxdr_unsigned(int32_t, fp->fa2_fileid);
- fxdr_nfsv2time(&fp->fa2_atime, &vap->va_atime);
- vap->va_flags = 0;
- vap->va_ctime.tv_sec = fxdr_unsigned(u_int32_t,
- fp->fa2_ctime.nfsv2_sec);
- vap->va_ctime.tv_nsec = 0;
- vap->va_gen = fxdr_unsigned(u_int32_t,fp->fa2_ctime.nfsv2_usec);
- vap->va_filerev = 0;
- }
- if (vap->va_size != np->n_size) {
- if (vap->va_type == VREG) {
- if (np->n_flag & NMODIFIED) {
- if (vap->va_size < np->n_size)
- vap->va_size = np->n_size;
- else
- np->n_size = vap->va_size;
- } else {
- np->n_size = vap->va_size;
- }
- vnode_pager_setsize(vp, np->n_size);
- } else {
- np->n_size = vap->va_size;
- }
- }
- np->n_attrstamp = time_second;
- if (vaper != NULL) {
- bcopy((caddr_t)vap, (caddr_t)vaper, sizeof(*vap));
- if (np->n_flag & NCHG) {
- if (np->n_flag & NACC)
- vaper->va_atime = np->n_atim;
- if (np->n_flag & NUPD)
- vaper->va_mtime = np->n_mtim;
- }
- }
- return (0);
-}
-
-#ifdef NFS_ACDEBUG
-#include <sys/sysctl.h>
-SYSCTL_DECL(_vfs_nfs);
-static int nfs_acdebug;
-SYSCTL_INT(_vfs_nfs, OID_AUTO, acdebug, CTLFLAG_RW, &nfs_acdebug, 0, "");
-#endif
-
-/*
- * Check the time stamp
- * If the cache is valid, copy contents to *vap and return 0
- * otherwise return an error
- */
-int
-nfs_getattrcache(vp, vaper)
- register struct vnode *vp;
- struct vattr *vaper;
-{
- register struct nfsnode *np;
- register struct vattr *vap;
- struct nfsmount *nmp;
- int timeo;
-
- np = VTONFS(vp);
- vap = &np->n_vattr;
- nmp = VFSTONFS(vp->v_mount);
- /* XXX n_mtime doesn't seem to be updated on a miss-and-reload */
- timeo = (time_second - np->n_mtime) / 10;
-
-#ifdef NFS_ACDEBUG
- if (nfs_acdebug>1)
- printf("nfs_getattrcache: initial timeo = %d\n", timeo);
-#endif
-
- if (vap->va_type == VDIR) {
- if ((np->n_flag & NMODIFIED) || timeo < nmp->nm_acdirmin)
- timeo = nmp->nm_acdirmin;
- else if (timeo > nmp->nm_acdirmax)
- timeo = nmp->nm_acdirmax;
- } else {
- if ((np->n_flag & NMODIFIED) || timeo < nmp->nm_acregmin)
- timeo = nmp->nm_acregmin;
- else if (timeo > nmp->nm_acregmax)
- timeo = nmp->nm_acregmax;
- }
-
-#ifdef NFS_ACDEBUG
- if (nfs_acdebug > 2)
- printf("acregmin %d; acregmax %d; acdirmin %d; acdirmax %d\n",
- nmp->nm_acregmin, nmp->nm_acregmax,
- nmp->nm_acdirmin, nmp->nm_acdirmax);
-
- if (nfs_acdebug)
- printf("nfs_getattrcache: age = %d; final timeo = %d\n",
- (time_second - np->n_attrstamp), timeo);
-#endif
-
- if ((time_second - np->n_attrstamp) >= timeo) {
- nfsstats.attrcache_misses++;
- return (ENOENT);
- }
- nfsstats.attrcache_hits++;
- if (vap->va_size != np->n_size) {
- if (vap->va_type == VREG) {
- if (np->n_flag & NMODIFIED) {
- if (vap->va_size < np->n_size)
- vap->va_size = np->n_size;
- else
- np->n_size = vap->va_size;
- } else {
- np->n_size = vap->va_size;
- }
- vnode_pager_setsize(vp, np->n_size);
- } else {
- np->n_size = vap->va_size;
- }
- }
- bcopy((caddr_t)vap, (caddr_t)vaper, sizeof(struct vattr));
- if (np->n_flag & NCHG) {
- if (np->n_flag & NACC)
- vaper->va_atime = np->n_atim;
- if (np->n_flag & NUPD)
- vaper->va_mtime = np->n_mtim;
- }
- return (0);
-}
-
-#ifndef NFS_NOSERVER
-/*
- * Set up nameidata for a lookup() call and do it.
- *
- * If pubflag is set, this call is done for a lookup operation on the
- * public filehandle. In that case we allow crossing mountpoints and
- * absolute pathnames. However, the caller is expected to check that
- * the lookup result is within the public fs, and deny access if
- * it is not.
- *
- * nfs_namei() clears out garbage fields that namei() might leave garbage.
- * This is mainly ni_vp and ni_dvp when an error occurs, and ni_dvp when no
- * error occurs but the parent was not requested.
- *
- * dirp may be set whether an error is returned or not, and must be
- * released by the caller.
- */
-int
-nfs_namei(ndp, fhp, len, slp, nam, mdp, dposp, retdirp, p, kerbflag, pubflag)
- register struct nameidata *ndp;
- fhandle_t *fhp;
- int len;
- struct nfssvc_sock *slp;
- struct sockaddr *nam;
- struct mbuf **mdp;
- caddr_t *dposp;
- struct vnode **retdirp;
- struct proc *p;
- int kerbflag, pubflag;
-{
- register int i, rem;
- register struct mbuf *md;
- register char *fromcp, *tocp, *cp;
- struct iovec aiov;
- struct uio auio;
- struct vnode *dp;
- int error, rdonly, linklen;
- struct componentname *cnp = &ndp->ni_cnd;
-
- *retdirp = (struct vnode *)0;
- cnp->cn_pnbuf = zalloc(namei_zone);
-
- /*
- * Copy the name from the mbuf list to ndp->ni_pnbuf
- * and set the various ndp fields appropriately.
- */
- fromcp = *dposp;
- tocp = cnp->cn_pnbuf;
- md = *mdp;
- rem = mtod(md, caddr_t) + md->m_len - fromcp;
- for (i = 0; i < len; i++) {
- while (rem == 0) {
- md = md->m_next;
- if (md == NULL) {
- error = EBADRPC;
- goto out;
- }
- fromcp = mtod(md, caddr_t);
- rem = md->m_len;
- }
- if (*fromcp == '\0' || (!pubflag && *fromcp == '/')) {
- error = EACCES;
- goto out;
- }
- *tocp++ = *fromcp++;
- rem--;
- }
- *tocp = '\0';
- *mdp = md;
- *dposp = fromcp;
- len = nfsm_rndup(len)-len;
- if (len > 0) {
- if (rem >= len)
- *dposp += len;
- else if ((error = nfs_adv(mdp, dposp, len, rem)) != 0)
- goto out;
- }
-
- /*
- * Extract and set starting directory.
- */
- error = nfsrv_fhtovp(fhp, FALSE, &dp, ndp->ni_cnd.cn_cred, slp,
- nam, &rdonly, kerbflag, pubflag);
- if (error)
- goto out;
- if (dp->v_type != VDIR) {
- vrele(dp);
- error = ENOTDIR;
- goto out;
- }
-
- if (rdonly)
- cnp->cn_flags |= RDONLY;
-
- /*
- * Set return directory. Reference to dp is implicitly transfered
- * to the returned pointer
- */
- *retdirp = dp;
-
- if (pubflag) {
- /*
- * Oh joy. For WebNFS, handle those pesky '%' escapes,
- * and the 'native path' indicator.
- */
- cp = zalloc(namei_zone);
- fromcp = cnp->cn_pnbuf;
- tocp = cp;
- if ((unsigned char)*fromcp >= WEBNFS_SPECCHAR_START) {
- switch ((unsigned char)*fromcp) {
- case WEBNFS_NATIVE_CHAR:
- /*
- * 'Native' path for us is the same
- * as a path according to the NFS spec,
- * just skip the escape char.
- */
- fromcp++;
- break;
- /*
- * More may be added in the future, range 0x80-0xff
- */
- default:
- error = EIO;
- zfree(namei_zone, cp);
- goto out;
- }
- }
- /*
- * Translate the '%' escapes, URL-style.
- */
- while (*fromcp != '\0') {
- if (*fromcp == WEBNFS_ESC_CHAR) {
- if (fromcp[1] != '\0' && fromcp[2] != '\0') {
- fromcp++;
- *tocp++ = HEXSTRTOI(fromcp);
- fromcp += 2;
- continue;
- } else {
- error = ENOENT;
- zfree(namei_zone, cp);
- goto out;
- }
- } else
- *tocp++ = *fromcp++;
- }
- *tocp = '\0';
- zfree(namei_zone, cnp->cn_pnbuf);
- cnp->cn_pnbuf = cp;
- }
-
- ndp->ni_pathlen = (tocp - cnp->cn_pnbuf) + 1;
- ndp->ni_segflg = UIO_SYSSPACE;
-
- if (pubflag) {
- ndp->ni_rootdir = rootvnode;
- ndp->ni_loopcnt = 0;
- if (cnp->cn_pnbuf[0] == '/')
- dp = rootvnode;
- } else {
- cnp->cn_flags |= NOCROSSMOUNT;
- }
-
- /*
- * Initialize for scan, set ni_startdir and bump ref on dp again
- * becuase lookup() will dereference ni_startdir.
- */
-
- cnp->cn_proc = p;
- VREF(dp);
- ndp->ni_startdir = dp;
-
- for (;;) {
- cnp->cn_nameptr = cnp->cn_pnbuf;
- /*
- * Call lookup() to do the real work. If an error occurs,
- * ndp->ni_vp and ni_dvp are left uninitialized or NULL and
- * we do not have to dereference anything before returning.
- * In either case ni_startdir will be dereferenced and NULLed
- * out.
- */
- error = lookup(ndp);
- if (error)
- break;
-
- /*
- * Check for encountering a symbolic link. Trivial
- * termination occurs if no symlink encountered.
- * Note: zfree is safe because error is 0, so we will
- * not zfree it again when we break.
- */
- if ((cnp->cn_flags & ISSYMLINK) == 0) {
- nfsrv_object_create(ndp->ni_vp);
- if (cnp->cn_flags & (SAVENAME | SAVESTART))
- cnp->cn_flags |= HASBUF;
- else
- zfree(namei_zone, cnp->cn_pnbuf);
- break;
- }
-
- /*
- * Validate symlink
- */
- if ((cnp->cn_flags & LOCKPARENT) && ndp->ni_pathlen == 1)
- VOP_UNLOCK(ndp->ni_dvp, 0, p);
- if (!pubflag) {
- error = EINVAL;
- goto badlink2;
- }
-
- if (ndp->ni_loopcnt++ >= MAXSYMLINKS) {
- error = ELOOP;
- goto badlink2;
- }
- if (ndp->ni_pathlen > 1)
- cp = zalloc(namei_zone);
- else
- cp = cnp->cn_pnbuf;
- aiov.iov_base = cp;
- aiov.iov_len = MAXPATHLEN;
- auio.uio_iov = &aiov;
- auio.uio_iovcnt = 1;
- auio.uio_offset = 0;
- auio.uio_rw = UIO_READ;
- auio.uio_segflg = UIO_SYSSPACE;
- auio.uio_procp = (struct proc *)0;
- auio.uio_resid = MAXPATHLEN;
- error = VOP_READLINK(ndp->ni_vp, &auio, cnp->cn_cred);
- if (error) {
- badlink1:
- if (ndp->ni_pathlen > 1)
- zfree(namei_zone, cp);
- badlink2:
- vrele(ndp->ni_dvp);
- vput(ndp->ni_vp);
- break;
- }
- linklen = MAXPATHLEN - auio.uio_resid;
- if (linklen == 0) {
- error = ENOENT;
- goto badlink1;
- }
- if (linklen + ndp->ni_pathlen >= MAXPATHLEN) {
- error = ENAMETOOLONG;
- goto badlink1;
- }
-
- /*
- * Adjust or replace path
- */
- if (ndp->ni_pathlen > 1) {
- bcopy(ndp->ni_next, cp + linklen, ndp->ni_pathlen);
- zfree(namei_zone, cnp->cn_pnbuf);
- cnp->cn_pnbuf = cp;
- } else
- cnp->cn_pnbuf[linklen] = '\0';
- ndp->ni_pathlen += linklen;
-
- /*
- * Cleanup refs for next loop and check if root directory
- * should replace current directory. Normally ni_dvp
- * becomes the new base directory and is cleaned up when
- * we loop. Explicitly null pointers after invalidation
- * to clarify operation.
- */
- vput(ndp->ni_vp);
- ndp->ni_vp = NULL;
-
- if (cnp->cn_pnbuf[0] == '/') {
- vrele(ndp->ni_dvp);
- ndp->ni_dvp = ndp->ni_rootdir;
- VREF(ndp->ni_dvp);
- }
- ndp->ni_startdir = ndp->ni_dvp;
- ndp->ni_dvp = NULL;
- }
-
- /*
- * nfs_namei() guarentees that fields will not contain garbage
- * whether an error occurs or not. This allows the caller to track
- * cleanup state trivially.
- */
-out:
- if (error) {
- zfree(namei_zone, cnp->cn_pnbuf);
- ndp->ni_vp = NULL;
- ndp->ni_dvp = NULL;
- ndp->ni_startdir = NULL;
- cnp->cn_flags &= ~HASBUF;
- } else if ((ndp->ni_cnd.cn_flags & (WANTPARENT|LOCKPARENT)) == 0) {
- ndp->ni_dvp = NULL;
- }
- return (error);
-}
-
-/*
- * A fiddled version of m_adj() that ensures null fill to a long
- * boundary and only trims off the back end
- */
-void
-nfsm_adj(mp, len, nul)
- struct mbuf *mp;
- register int len;
- int nul;
-{
- register struct mbuf *m;
- register int count, i;
- register char *cp;
-
- /*
- * Trim from tail. Scan the mbuf chain,
- * calculating its length and finding the last mbuf.
- * If the adjustment only affects this mbuf, then just
- * adjust and return. Otherwise, rescan and truncate
- * after the remaining size.
- */
- count = 0;
- m = mp;
- for (;;) {
- count += m->m_len;
- if (m->m_next == (struct mbuf *)0)
- break;
- m = m->m_next;
- }
- if (m->m_len > len) {
- m->m_len -= len;
- if (nul > 0) {
- cp = mtod(m, caddr_t)+m->m_len-nul;
- for (i = 0; i < nul; i++)
- *cp++ = '\0';
- }
- return;
- }
- count -= len;
- if (count < 0)
- count = 0;
- /*
- * Correct length for chain is "count".
- * Find the mbuf with last data, adjust its length,
- * and toss data from remaining mbufs on chain.
- */
- for (m = mp; m; m = m->m_next) {
- if (m->m_len >= count) {
- m->m_len = count;
- if (nul > 0) {
- cp = mtod(m, caddr_t)+m->m_len-nul;
- for (i = 0; i < nul; i++)
- *cp++ = '\0';
- }
- break;
- }
- count -= m->m_len;
- }
- for (m = m->m_next;m;m = m->m_next)
- m->m_len = 0;
-}
-
-/*
- * Make these functions instead of macros, so that the kernel text size
- * doesn't get too big...
- */
-void
-nfsm_srvwcc(nfsd, before_ret, before_vap, after_ret, after_vap, mbp, bposp)
- struct nfsrv_descript *nfsd;
- int before_ret;
- register struct vattr *before_vap;
- int after_ret;
- struct vattr *after_vap;
- struct mbuf **mbp;
- char **bposp;
-{
- register struct mbuf *mb = *mbp, *mb2;
- register char *bpos = *bposp;
- register u_int32_t *tl;
-
- if (before_ret) {
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);
- *tl = nfs_false;
- } else {
- nfsm_build(tl, u_int32_t *, 7 * NFSX_UNSIGNED);
- *tl++ = nfs_true;
- txdr_hyper(before_vap->va_size, tl);
- tl += 2;
- txdr_nfsv3time(&(before_vap->va_mtime), tl);
- tl += 2;
- txdr_nfsv3time(&(before_vap->va_ctime), tl);
- }
- *bposp = bpos;
- *mbp = mb;
- nfsm_srvpostopattr(nfsd, after_ret, after_vap, mbp, bposp);
-}
-
-void
-nfsm_srvpostopattr(nfsd, after_ret, after_vap, mbp, bposp)
- struct nfsrv_descript *nfsd;
- int after_ret;
- struct vattr *after_vap;
- struct mbuf **mbp;
- char **bposp;
-{
- register struct mbuf *mb = *mbp, *mb2;
- register char *bpos = *bposp;
- register u_int32_t *tl;
- register struct nfs_fattr *fp;
-
- if (after_ret) {
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);
- *tl = nfs_false;
- } else {
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED + NFSX_V3FATTR);
- *tl++ = nfs_true;
- fp = (struct nfs_fattr *)tl;
- nfsm_srvfattr(nfsd, after_vap, fp);
- }
- *mbp = mb;
- *bposp = bpos;
-}
-
-void
-nfsm_srvfattr(nfsd, vap, fp)
- register struct nfsrv_descript *nfsd;
- register struct vattr *vap;
- register struct nfs_fattr *fp;
-{
-
- fp->fa_nlink = txdr_unsigned(vap->va_nlink);
- fp->fa_uid = txdr_unsigned(vap->va_uid);
- fp->fa_gid = txdr_unsigned(vap->va_gid);
- if (nfsd->nd_flag & ND_NFSV3) {
- fp->fa_type = vtonfsv3_type(vap->va_type);
- fp->fa_mode = vtonfsv3_mode(vap->va_mode);
- txdr_hyper(vap->va_size, &fp->fa3_size);
- txdr_hyper(vap->va_bytes, &fp->fa3_used);
- fp->fa3_rdev.specdata1 = txdr_unsigned(umajor(vap->va_rdev));
- fp->fa3_rdev.specdata2 = txdr_unsigned(uminor(vap->va_rdev));
- fp->fa3_fsid.nfsuquad[0] = 0;
- fp->fa3_fsid.nfsuquad[1] = txdr_unsigned(vap->va_fsid);
- fp->fa3_fileid.nfsuquad[0] = 0;
- fp->fa3_fileid.nfsuquad[1] = txdr_unsigned(vap->va_fileid);
- txdr_nfsv3time(&vap->va_atime, &fp->fa3_atime);
- txdr_nfsv3time(&vap->va_mtime, &fp->fa3_mtime);
- txdr_nfsv3time(&vap->va_ctime, &fp->fa3_ctime);
- } else {
- fp->fa_type = vtonfsv2_type(vap->va_type);
- fp->fa_mode = vtonfsv2_mode(vap->va_type, vap->va_mode);
- fp->fa2_size = txdr_unsigned(vap->va_size);
- fp->fa2_blocksize = txdr_unsigned(vap->va_blocksize);
- if (vap->va_type == VFIFO)
- fp->fa2_rdev = 0xffffffff;
- else
- fp->fa2_rdev = txdr_unsigned(vap->va_rdev);
- fp->fa2_blocks = txdr_unsigned(vap->va_bytes / NFS_FABLKSIZE);
- fp->fa2_fsid = txdr_unsigned(vap->va_fsid);
- fp->fa2_fileid = txdr_unsigned(vap->va_fileid);
- txdr_nfsv2time(&vap->va_atime, &fp->fa2_atime);
- txdr_nfsv2time(&vap->va_mtime, &fp->fa2_mtime);
- txdr_nfsv2time(&vap->va_ctime, &fp->fa2_ctime);
- }
-}
-
-/*
- * nfsrv_fhtovp() - convert a fh to a vnode ptr (optionally locked)
- * - look up fsid in mount list (if not found ret error)
- * - get vp and export rights by calling VFS_FHTOVP()
- * - if cred->cr_uid == 0 or MNT_EXPORTANON set it to credanon
- * - if not lockflag unlock it with VOP_UNLOCK()
- */
-int
-nfsrv_fhtovp(fhp, lockflag, vpp, cred, slp, nam, rdonlyp, kerbflag, pubflag)
- fhandle_t *fhp;
- int lockflag;
- struct vnode **vpp;
- struct ucred *cred;
- struct nfssvc_sock *slp;
- struct sockaddr *nam;
- int *rdonlyp;
- int kerbflag;
- int pubflag;
-{
- struct proc *p = curproc; /* XXX */
- register struct mount *mp;
- register int i;
- struct ucred *credanon;
- int error, exflags;
-#ifdef MNT_EXNORESPORT /* XXX needs mountd and /etc/exports help yet */
- struct sockaddr_int *saddr;
-#endif
-
- *vpp = (struct vnode *)0;
-
- if (nfs_ispublicfh(fhp)) {
- if (!pubflag || !nfs_pub.np_valid)
- return (ESTALE);
- fhp = &nfs_pub.np_handle;
- }
-
- mp = vfs_getvfs(&fhp->fh_fsid);
- if (!mp)
- return (ESTALE);
- error = VFS_CHECKEXP(mp, nam, &exflags, &credanon);
- if (error)
- return (error);
- error = VFS_FHTOVP(mp, &fhp->fh_fid, vpp);
- if (error)
- return (error);
-#ifdef MNT_EXNORESPORT
- if (!(exflags & (MNT_EXNORESPORT|MNT_EXPUBLIC))) {
- saddr = (struct sockaddr_in *)nam;
- if (saddr->sin_family == AF_INET &&
- ntohs(saddr->sin_port) >= IPPORT_RESERVED) {
- vput(*vpp);
- *vpp = NULL;
- return (NFSERR_AUTHERR | AUTH_TOOWEAK);
- }
- }
-#endif
- /*
- * Check/setup credentials.
- */
- if (exflags & MNT_EXKERB) {
- if (!kerbflag) {
- vput(*vpp);
- *vpp = NULL;
- return (NFSERR_AUTHERR | AUTH_TOOWEAK);
- }
- } else if (kerbflag) {
- vput(*vpp);
- *vpp = NULL;
- return (NFSERR_AUTHERR | AUTH_TOOWEAK);
- } else if (cred->cr_uid == 0 || (exflags & MNT_EXPORTANON)) {
- cred->cr_uid = credanon->cr_uid;
- for (i = 0; i < credanon->cr_ngroups && i < NGROUPS; i++)
- cred->cr_groups[i] = credanon->cr_groups[i];
- cred->cr_ngroups = i;
- }
- if (exflags & MNT_EXRDONLY)
- *rdonlyp = 1;
- else
- *rdonlyp = 0;
-
- nfsrv_object_create(*vpp);
-
- if (!lockflag)
- VOP_UNLOCK(*vpp, 0, p);
- return (0);
-}
-
-
-/*
- * WebNFS: check if a filehandle is a public filehandle. For v3, this
- * means a length of 0, for v2 it means all zeroes. nfsm_srvmtofh has
- * transformed this to all zeroes in both cases, so check for it.
- */
-int
-nfs_ispublicfh(fhp)
- fhandle_t *fhp;
-{
- char *cp = (char *)fhp;
- int i;
-
- for (i = 0; i < NFSX_V3FH; i++)
- if (*cp++ != 0)
- return (FALSE);
- return (TRUE);
-}
-
-#endif /* NFS_NOSERVER */
-/*
- * This function compares two net addresses by family and returns TRUE
- * if they are the same host.
- * If there is any doubt, return FALSE.
- * The AF_INET family is handled as a special case so that address mbufs
- * don't need to be saved to store "struct in_addr", which is only 4 bytes.
- */
-int
-netaddr_match(family, haddr, nam)
- int family;
- union nethostaddr *haddr;
- struct sockaddr *nam;
-{
- register struct sockaddr_in *inetaddr;
-
- switch (family) {
- case AF_INET:
- inetaddr = (struct sockaddr_in *)nam;
- if (inetaddr->sin_family == AF_INET &&
- inetaddr->sin_addr.s_addr == haddr->had_inetaddr)
- return (1);
- break;
- default:
- break;
- };
- return (0);
-}
-
-static nfsuint64 nfs_nullcookie = { { 0, 0 } };
-/*
- * This function finds the directory cookie that corresponds to the
- * logical byte offset given.
- */
-nfsuint64 *
-nfs_getcookie(np, off, add)
- register struct nfsnode *np;
- off_t off;
- int add;
-{
- register struct nfsdmap *dp, *dp2;
- register int pos;
-
- pos = (uoff_t)off / NFS_DIRBLKSIZ;
- if (pos == 0 || off < 0) {
-#ifdef DIAGNOSTIC
- if (add)
- panic("nfs getcookie add at <= 0");
-#endif
- return (&nfs_nullcookie);
- }
- pos--;
- dp = np->n_cookies.lh_first;
- if (!dp) {
- if (add) {
- MALLOC(dp, struct nfsdmap *, sizeof (struct nfsdmap),
- M_NFSDIROFF, M_WAITOK);
- dp->ndm_eocookie = 0;
- LIST_INSERT_HEAD(&np->n_cookies, dp, ndm_list);
- } else
- return ((nfsuint64 *)0);
- }
- while (pos >= NFSNUMCOOKIES) {
- pos -= NFSNUMCOOKIES;
- if (dp->ndm_list.le_next) {
- if (!add && dp->ndm_eocookie < NFSNUMCOOKIES &&
- pos >= dp->ndm_eocookie)
- return ((nfsuint64 *)0);
- dp = dp->ndm_list.le_next;
- } else if (add) {
- MALLOC(dp2, struct nfsdmap *, sizeof (struct nfsdmap),
- M_NFSDIROFF, M_WAITOK);
- dp2->ndm_eocookie = 0;
- LIST_INSERT_AFTER(dp, dp2, ndm_list);
- dp = dp2;
- } else
- return ((nfsuint64 *)0);
- }
- if (pos >= dp->ndm_eocookie) {
- if (add)
- dp->ndm_eocookie = pos + 1;
- else
- return ((nfsuint64 *)0);
- }
- return (&dp->ndm_cookies[pos]);
-}
-
-/*
- * Invalidate cached directory information, except for the actual directory
- * blocks (which are invalidated separately).
- * Done mainly to avoid the use of stale offset cookies.
- */
-void
-nfs_invaldir(vp)
- register struct vnode *vp;
-{
- register struct nfsnode *np = VTONFS(vp);
-
-#ifdef DIAGNOSTIC
- if (vp->v_type != VDIR)
- panic("nfs: invaldir not dir");
-#endif
- np->n_direofoffset = 0;
- np->n_cookieverf.nfsuquad[0] = 0;
- np->n_cookieverf.nfsuquad[1] = 0;
- if (np->n_cookies.lh_first)
- np->n_cookies.lh_first->ndm_eocookie = 0;
-}
-
-/*
- * The write verifier has changed (probably due to a server reboot), so all
- * B_NEEDCOMMIT blocks will have to be written again. Since they are on the
- * dirty block list as B_DELWRI, all this takes is clearing the B_NEEDCOMMIT
- * and B_CLUSTEROK flags. Once done the new write verifier can be set for the
- * mount point.
- *
- * B_CLUSTEROK must be cleared along with B_NEEDCOMMIT because stage 1 data
- * writes are not clusterable.
- */
-void
-nfs_clearcommit(mp)
- struct mount *mp;
-{
- register struct vnode *vp, *nvp;
- register struct buf *bp, *nbp;
- int s;
-
- s = splbio();
-loop:
- for (vp = mp->mnt_vnodelist.lh_first; vp; vp = nvp) {
- if (vp->v_mount != mp) /* Paranoia */
- goto loop;
- nvp = vp->v_mntvnodes.le_next;
- for (bp = TAILQ_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) {
- nbp = TAILQ_NEXT(bp, b_vnbufs);
- if (BUF_REFCNT(bp) == 0 &&
- (bp->b_flags & (B_DELWRI | B_NEEDCOMMIT))
- == (B_DELWRI | B_NEEDCOMMIT))
- bp->b_flags &= ~(B_NEEDCOMMIT | B_CLUSTEROK);
- }
- }
- splx(s);
-}
-
-#ifndef NFS_NOSERVER
-/*
- * Map errnos to NFS error numbers. For Version 3 also filter out error
- * numbers not specified for the associated procedure.
- */
-int
-nfsrv_errmap(nd, err)
- struct nfsrv_descript *nd;
- register int err;
-{
- register short *defaulterrp, *errp;
-
- if (nd->nd_flag & ND_NFSV3) {
- if (nd->nd_procnum <= NFSPROC_COMMIT) {
- errp = defaulterrp = nfsrv_v3errmap[nd->nd_procnum];
- while (*++errp) {
- if (*errp == err)
- return (err);
- else if (*errp > err)
- break;
- }
- return ((int)*defaulterrp);
- } else
- return (err & 0xffff);
- }
- if (err <= ELAST)
- return ((int)nfsrv_v2errmap[err - 1]);
- return (NFSERR_IO);
-}
-
-int
-nfsrv_object_create(vp)
- struct vnode *vp;
-{
-
- if (vp == NULL || vp->v_type != VREG)
- return (1);
- return (vfs_object_create(vp, curproc,
- curproc ? curproc->p_ucred : NULL));
-}
-
-/*
- * Sort the group list in increasing numerical order.
- * (Insertion sort by Chris Torek, who was grossed out by the bubble sort
- * that used to be here.)
- */
-void
-nfsrvw_sort(list, num)
- register gid_t *list;
- register int num;
-{
- register int i, j;
- gid_t v;
-
- /* Insertion sort. */
- for (i = 1; i < num; i++) {
- v = list[i];
- /* find correct slot for value v, moving others up */
- for (j = i; --j >= 0 && v < list[j];)
- list[j + 1] = list[j];
- list[j + 1] = v;
- }
-}
-
-/*
- * copy credentials making sure that the result can be compared with bcmp().
- */
-void
-nfsrv_setcred(incred, outcred)
- register struct ucred *incred, *outcred;
-{
- register int i;
-
- bzero((caddr_t)outcred, sizeof (struct ucred));
- outcred->cr_ref = 1;
- outcred->cr_uid = incred->cr_uid;
- outcred->cr_ngroups = incred->cr_ngroups;
- for (i = 0; i < incred->cr_ngroups; i++)
- outcred->cr_groups[i] = incred->cr_groups[i];
- nfsrvw_sort(outcred->cr_groups, outcred->cr_ngroups);
-}
-#endif /* NFS_NOSERVER */
diff --git a/sys/nfsserver/nfs_syscalls.c b/sys/nfsserver/nfs_syscalls.c
deleted file mode 100644
index 14ff8d1f0145..000000000000
--- a/sys/nfsserver/nfs_syscalls.c
+++ /dev/null
@@ -1,1187 +0,0 @@
-/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Rick Macklem at The University of Guelph.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)nfs_syscalls.c 8.5 (Berkeley) 3/30/95
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/sysproto.h>
-#include <sys/kernel.h>
-#include <sys/sysctl.h>
-#include <sys/file.h>
-#include <sys/filedesc.h>
-#include <sys/vnode.h>
-#include <sys/malloc.h>
-#include <sys/mount.h>
-#include <sys/proc.h>
-#include <sys/buf.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-#include <sys/domain.h>
-#include <sys/protosw.h>
-#include <sys/namei.h>
-#include <vm/vm_zone.h>
-
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-#include <nfs/xdr_subs.h>
-#include <nfs/rpcv2.h>
-#include <nfs/nfsproto.h>
-#include <nfs/nfs.h>
-#include <nfs/nfsm_subs.h>
-#include <nfs/nfsrvcache.h>
-#include <nfs/nfsmount.h>
-#include <nfs/nfsnode.h>
-#include <nfs/nqnfs.h>
-#include <nfs/nfsrtt.h>
-
-static MALLOC_DEFINE(M_NFSSVC, "NFS srvsock", "Nfs server structure");
-
-/* Global defs. */
-extern int32_t (*nfsrv3_procs[NFS_NPROCS]) __P((struct nfsrv_descript *nd,
- struct nfssvc_sock *slp,
- struct proc *procp,
- struct mbuf **mreqp));
-extern int nfs_numasync;
-extern time_t nqnfsstarttime;
-extern int nqsrv_writeslack;
-extern int nfsrtton;
-extern struct nfsstats nfsstats;
-extern int nfsrvw_procrastinate;
-extern int nfsrvw_procrastinate_v3;
-static int nuidhash_max = NFS_MAXUIDHASH;
-
-#ifndef NFS_NOSERVER
-static void nfsrv_zapsock __P((struct nfssvc_sock *slp));
-#endif
-static int nfssvc_iod __P((struct proc *));
-
-#define TRUE 1
-#define FALSE 0
-
-static int nfs_asyncdaemon[NFS_MAXASYNCDAEMON];
-
-SYSCTL_DECL(_vfs_nfs);
-
-#ifndef NFS_NOSERVER
-int nfsd_waiting = 0;
-static struct nfsdrt nfsdrt;
-static int nfs_numnfsd = 0;
-static int notstarted = 1;
-static int modify_flag = 0;
-static void nfsd_rt __P((int sotype, struct nfsrv_descript *nd,
- int cacherep));
-static int nfssvc_addsock __P((struct file *, struct sockaddr *,
- struct proc *));
-static int nfssvc_nfsd __P((struct nfsd_srvargs *,caddr_t,struct proc *));
-
-static int nfs_privport = 0;
-SYSCTL_INT(_vfs_nfs, NFS_NFSPRIVPORT, nfs_privport, CTLFLAG_RW, &nfs_privport, 0, "");
-SYSCTL_INT(_vfs_nfs, OID_AUTO, gatherdelay, CTLFLAG_RW, &nfsrvw_procrastinate, 0, "");
-SYSCTL_INT(_vfs_nfs, OID_AUTO, gatherdelay_v3, CTLFLAG_RW, &nfsrvw_procrastinate_v3, 0, "");
-
-/*
- * NFS server system calls
- */
-
-#endif /* NFS_NOSERVER */
-/*
- * Nfs server psuedo system call for the nfsd's
- * Based on the flag value it either:
- * - adds a socket to the selection list
- * - remains in the kernel as an nfsd
- * - remains in the kernel as an nfsiod
- */
-#ifndef _SYS_SYSPROTO_H_
-struct nfssvc_args {
- int flag;
- caddr_t argp;
-};
-#endif
-int
-nfssvc(p, uap)
- struct proc *p;
- register struct nfssvc_args *uap;
-{
-#ifndef NFS_NOSERVER
- struct nameidata nd;
- struct file *fp;
- struct sockaddr *nam;
- struct nfsd_args nfsdarg;
- struct nfsd_srvargs nfsd_srvargs, *nsd = &nfsd_srvargs;
- struct nfsd_cargs ncd;
- struct nfsd *nfsd;
- struct nfssvc_sock *slp;
- struct nfsuid *nuidp;
- struct nfsmount *nmp;
-#endif /* NFS_NOSERVER */
- int error;
-
- /*
- * Must be super user
- */
- error = suser(p);
- if(error)
- return (error);
- while (nfssvc_sockhead_flag & SLP_INIT) {
- nfssvc_sockhead_flag |= SLP_WANTINIT;
- (void) tsleep((caddr_t)&nfssvc_sockhead, PSOCK, "nfsd init", 0);
- }
- if (uap->flag & NFSSVC_BIOD)
- error = nfssvc_iod(p);
-#ifdef NFS_NOSERVER
- else
- error = ENXIO;
-#else /* !NFS_NOSERVER */
- else if (uap->flag & NFSSVC_MNTD) {
- error = copyin(uap->argp, (caddr_t)&ncd, sizeof (ncd));
- if (error)
- return (error);
- NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE,
- ncd.ncd_dirp, p);
- error = namei(&nd);
- if (error)
- return (error);
- NDFREE(&nd, NDF_ONLY_PNBUF);
- if ((nd.ni_vp->v_flag & VROOT) == 0)
- error = EINVAL;
- nmp = VFSTONFS(nd.ni_vp->v_mount);
- vput(nd.ni_vp);
- if (error)
- return (error);
- if ((nmp->nm_state & NFSSTA_MNTD) &&
- (uap->flag & NFSSVC_GOTAUTH) == 0)
- return (0);
- nmp->nm_state |= NFSSTA_MNTD;
- error = nqnfs_clientd(nmp, p->p_ucred, &ncd, uap->flag,
- uap->argp, p);
- } else if (uap->flag & NFSSVC_ADDSOCK) {
- error = copyin(uap->argp, (caddr_t)&nfsdarg, sizeof(nfsdarg));
- if (error)
- return (error);
- error = getsock(p->p_fd, nfsdarg.sock, &fp);
- if (error)
- return (error);
- /*
- * Get the client address for connected sockets.
- */
- if (nfsdarg.name == NULL || nfsdarg.namelen == 0)
- nam = (struct sockaddr *)0;
- else {
- error = getsockaddr(&nam, nfsdarg.name,
- nfsdarg.namelen);
- if (error)
- return (error);
- }
- error = nfssvc_addsock(fp, nam, p);
- } else {
- error = copyin(uap->argp, (caddr_t)nsd, sizeof (*nsd));
- if (error)
- return (error);
- if ((uap->flag & NFSSVC_AUTHIN) &&
- ((nfsd = nsd->nsd_nfsd)) != NULL &&
- (nfsd->nfsd_slp->ns_flag & SLP_VALID)) {
- slp = nfsd->nfsd_slp;
-
- /*
- * First check to see if another nfsd has already
- * added this credential.
- */
- for (nuidp = NUIDHASH(slp,nsd->nsd_cr.cr_uid)->lh_first;
- nuidp != 0; nuidp = nuidp->nu_hash.le_next) {
- if (nuidp->nu_cr.cr_uid == nsd->nsd_cr.cr_uid &&
- (!nfsd->nfsd_nd->nd_nam2 ||
- netaddr_match(NU_NETFAM(nuidp),
- &nuidp->nu_haddr, nfsd->nfsd_nd->nd_nam2)))
- break;
- }
- if (nuidp) {
- nfsrv_setcred(&nuidp->nu_cr,&nfsd->nfsd_nd->nd_cr);
- nfsd->nfsd_nd->nd_flag |= ND_KERBFULL;
- } else {
- /*
- * Nope, so we will.
- */
- if (slp->ns_numuids < nuidhash_max) {
- slp->ns_numuids++;
- nuidp = (struct nfsuid *)
- malloc(sizeof (struct nfsuid), M_NFSUID,
- M_WAITOK);
- } else
- nuidp = (struct nfsuid *)0;
- if ((slp->ns_flag & SLP_VALID) == 0) {
- if (nuidp)
- free((caddr_t)nuidp, M_NFSUID);
- } else {
- if (nuidp == (struct nfsuid *)0) {
- nuidp = slp->ns_uidlruhead.tqh_first;
- LIST_REMOVE(nuidp, nu_hash);
- TAILQ_REMOVE(&slp->ns_uidlruhead, nuidp,
- nu_lru);
- if (nuidp->nu_flag & NU_NAM)
- FREE(nuidp->nu_nam, M_SONAME);
- }
- nuidp->nu_flag = 0;
- nuidp->nu_cr = nsd->nsd_cr;
- if (nuidp->nu_cr.cr_ngroups > NGROUPS)
- nuidp->nu_cr.cr_ngroups = NGROUPS;
- nuidp->nu_cr.cr_ref = 1;
- nuidp->nu_timestamp = nsd->nsd_timestamp;
- nuidp->nu_expire = time_second + nsd->nsd_ttl;
- /*
- * and save the session key in nu_key.
- */
- bcopy(nsd->nsd_key, nuidp->nu_key,
- sizeof (nsd->nsd_key));
- if (nfsd->nfsd_nd->nd_nam2) {
- struct sockaddr_in *saddr;
-
- saddr = (struct sockaddr_in *)
- nfsd->nfsd_nd->nd_nam2;
- switch (saddr->sin_family) {
- case AF_INET:
- nuidp->nu_flag |= NU_INETADDR;
- nuidp->nu_inetaddr =
- saddr->sin_addr.s_addr;
- break;
- case AF_ISO:
- default:
- nuidp->nu_flag |= NU_NAM;
- nuidp->nu_nam =
- dup_sockaddr(nfsd->nfsd_nd->
- nd_nam2, 1);
- break;
- };
- }
- TAILQ_INSERT_TAIL(&slp->ns_uidlruhead, nuidp,
- nu_lru);
- LIST_INSERT_HEAD(NUIDHASH(slp, nsd->nsd_uid),
- nuidp, nu_hash);
- nfsrv_setcred(&nuidp->nu_cr,
- &nfsd->nfsd_nd->nd_cr);
- nfsd->nfsd_nd->nd_flag |= ND_KERBFULL;
- }
- }
- }
- if ((uap->flag & NFSSVC_AUTHINFAIL) && (nfsd = nsd->nsd_nfsd))
- nfsd->nfsd_flag |= NFSD_AUTHFAIL;
- error = nfssvc_nfsd(nsd, uap->argp, p);
- }
-#endif /* NFS_NOSERVER */
- if (error == EINTR || error == ERESTART)
- error = 0;
- return (error);
-}
-
-#ifndef NFS_NOSERVER
-/*
- * Adds a socket to the list for servicing by nfsds.
- */
-static int
-nfssvc_addsock(fp, mynam, p)
- struct file *fp;
- struct sockaddr *mynam;
- struct proc *p;
-{
- register int siz;
- register struct nfssvc_sock *slp;
- register struct socket *so;
- int error, s;
-
- so = (struct socket *)fp->f_data;
-#if 0
- tslp = (struct nfssvc_sock *)0;
- /*
- * Add it to the list, as required.
- */
- if (so->so_proto->pr_protocol == IPPROTO_UDP) {
- tslp = nfs_udpsock;
- if (tslp->ns_flag & SLP_VALID) {
- if (mynam != NULL)
- FREE(mynam, M_SONAME);
- return (EPERM);
- }
- }
-#endif
- if (so->so_type == SOCK_STREAM)
- siz = NFS_MAXPACKET + sizeof (u_long);
- else
- siz = NFS_MAXPACKET;
- error = soreserve(so, siz, siz);
- if (error) {
- if (mynam != NULL)
- FREE(mynam, M_SONAME);
- return (error);
- }
-
- /*
- * Set protocol specific options { for now TCP only } and
- * reserve some space. For datagram sockets, this can get called
- * repeatedly for the same socket, but that isn't harmful.
- */
- if (so->so_type == SOCK_STREAM) {
- struct sockopt sopt;
- int val;
-
- bzero(&sopt, sizeof sopt);
- sopt.sopt_level = SOL_SOCKET;
- sopt.sopt_name = SO_KEEPALIVE;
- sopt.sopt_val = &val;
- sopt.sopt_valsize = sizeof val;
- val = 1;
- sosetopt(so, &sopt);
- }
- if (so->so_proto->pr_domain->dom_family == AF_INET &&
- so->so_proto->pr_protocol == IPPROTO_TCP) {
- struct sockopt sopt;
- int val;
-
- bzero(&sopt, sizeof sopt);
- sopt.sopt_level = IPPROTO_TCP;
- sopt.sopt_name = TCP_NODELAY;
- sopt.sopt_val = &val;
- sopt.sopt_valsize = sizeof val;
- val = 1;
- sosetopt(so, &sopt);
- }
- so->so_rcv.sb_flags &= ~SB_NOINTR;
- so->so_rcv.sb_timeo = 0;
- so->so_snd.sb_flags &= ~SB_NOINTR;
- so->so_snd.sb_timeo = 0;
-
- slp = (struct nfssvc_sock *)
- malloc(sizeof (struct nfssvc_sock), M_NFSSVC, M_WAITOK);
- bzero((caddr_t)slp, sizeof (struct nfssvc_sock));
- STAILQ_INIT(&slp->ns_rec);
- TAILQ_INIT(&slp->ns_uidlruhead);
- TAILQ_INSERT_TAIL(&nfssvc_sockhead, slp, ns_chain);
-
- slp->ns_so = so;
- slp->ns_nam = mynam;
- fp->f_count++;
- slp->ns_fp = fp;
- s = splnet();
- so->so_upcallarg = (caddr_t)slp;
- so->so_upcall = nfsrv_rcv;
- so->so_rcv.sb_flags |= SB_UPCALL;
- slp->ns_flag = (SLP_VALID | SLP_NEEDQ);
- nfsrv_wakenfsd(slp);
- splx(s);
- return (0);
-}
-
-/*
- * Called by nfssvc() for nfsds. Just loops around servicing rpc requests
- * until it is killed by a signal.
- */
-static int
-nfssvc_nfsd(nsd, argp, p)
- struct nfsd_srvargs *nsd;
- caddr_t argp;
- struct proc *p;
-{
- register int siz;
- register struct nfssvc_sock *slp;
- struct nfsd *nfsd = nsd->nsd_nfsd;
- struct nfsrv_descript *nd = NULL;
- struct mbuf *m, *mreq;
- int error = 0, cacherep, s, sotype, writes_todo;
- int procrastinate;
- u_quad_t cur_usec;
-
-#ifndef nolint
- cacherep = RC_DOIT;
- writes_todo = 0;
-#endif
- if (nfsd == (struct nfsd *)0) {
- nsd->nsd_nfsd = nfsd = (struct nfsd *)
- malloc(sizeof (struct nfsd), M_NFSD, M_WAITOK);
- bzero((caddr_t)nfsd, sizeof (struct nfsd));
- s = splnet();
- nfsd->nfsd_procp = p;
- TAILQ_INSERT_TAIL(&nfsd_head, nfsd, nfsd_chain);
- nfs_numnfsd++;
- } else
- s = splnet();
-
- /*
- * Loop getting rpc requests until SIGKILL.
- */
- for (;;) {
- if ((nfsd->nfsd_flag & NFSD_REQINPROG) == 0) {
- while (nfsd->nfsd_slp == (struct nfssvc_sock *)0 &&
- (nfsd_head_flag & NFSD_CHECKSLP) == 0) {
- nfsd->nfsd_flag |= NFSD_WAITING;
- nfsd_waiting++;
- error = tsleep((caddr_t)nfsd, PSOCK | PCATCH,
- "nfsd", 0);
- nfsd_waiting--;
- if (error)
- goto done;
- }
- if (nfsd->nfsd_slp == (struct nfssvc_sock *)0 &&
- (nfsd_head_flag & NFSD_CHECKSLP) != 0) {
- for (slp = nfssvc_sockhead.tqh_first; slp != 0;
- slp = slp->ns_chain.tqe_next) {
- if ((slp->ns_flag & (SLP_VALID | SLP_DOREC))
- == (SLP_VALID | SLP_DOREC)) {
- slp->ns_flag &= ~SLP_DOREC;
- slp->ns_sref++;
- nfsd->nfsd_slp = slp;
- break;
- }
- }
- if (slp == 0)
- nfsd_head_flag &= ~NFSD_CHECKSLP;
- }
- if ((slp = nfsd->nfsd_slp) == (struct nfssvc_sock *)0)
- continue;
- if (slp->ns_flag & SLP_VALID) {
- if (slp->ns_flag & SLP_DISCONN)
- nfsrv_zapsock(slp);
- else if (slp->ns_flag & SLP_NEEDQ) {
- slp->ns_flag &= ~SLP_NEEDQ;
- (void) nfs_slplock(slp, 1);
- nfsrv_rcv(slp->ns_so, (caddr_t)slp,
- M_WAIT);
- nfs_slpunlock(slp);
- }
- error = nfsrv_dorec(slp, nfsd, &nd);
- cur_usec = nfs_curusec();
- if (error && slp->ns_tq.lh_first &&
- slp->ns_tq.lh_first->nd_time <= cur_usec) {
- error = 0;
- cacherep = RC_DOIT;
- writes_todo = 1;
- } else
- writes_todo = 0;
- nfsd->nfsd_flag |= NFSD_REQINPROG;
- }
- } else {
- error = 0;
- slp = nfsd->nfsd_slp;
- }
- if (error || (slp->ns_flag & SLP_VALID) == 0) {
- if (nd) {
- free((caddr_t)nd, M_NFSRVDESC);
- nd = NULL;
- }
- nfsd->nfsd_slp = (struct nfssvc_sock *)0;
- nfsd->nfsd_flag &= ~NFSD_REQINPROG;
- nfsrv_slpderef(slp);
- continue;
- }
- splx(s);
- sotype = slp->ns_so->so_type;
- if (nd) {
- getmicrotime(&nd->nd_starttime);
- if (nd->nd_nam2)
- nd->nd_nam = nd->nd_nam2;
- else
- nd->nd_nam = slp->ns_nam;
-
- /*
- * Check to see if authorization is needed.
- */
- if (nfsd->nfsd_flag & NFSD_NEEDAUTH) {
- nfsd->nfsd_flag &= ~NFSD_NEEDAUTH;
- nsd->nsd_haddr =
- ((struct sockaddr_in *)
- nd->nd_nam)->sin_addr.s_addr;
- nsd->nsd_authlen = nfsd->nfsd_authlen;
- nsd->nsd_verflen = nfsd->nfsd_verflen;
- if (!copyout(nfsd->nfsd_authstr,nsd->nsd_authstr,
- nfsd->nfsd_authlen) &&
- !copyout(nfsd->nfsd_verfstr, nsd->nsd_verfstr,
- nfsd->nfsd_verflen) &&
- !copyout((caddr_t)nsd, argp, sizeof (*nsd)))
- return (ENEEDAUTH);
- cacherep = RC_DROPIT;
- } else
- cacherep = nfsrv_getcache(nd, slp, &mreq);
-
- /*
- * Check for just starting up for NQNFS and send
- * fake "try again later" replies to the NQNFS clients.
- */
- if (notstarted && nqnfsstarttime <= time_second) {
- if (modify_flag) {
- nqnfsstarttime = time_second + nqsrv_writeslack;
- modify_flag = 0;
- } else
- notstarted = 0;
- }
- if (notstarted) {
- if ((nd->nd_flag & ND_NQNFS) == 0)
- cacherep = RC_DROPIT;
- else if (nd->nd_procnum != NFSPROC_WRITE) {
- nd->nd_procnum = NFSPROC_NOOP;
- nd->nd_repstat = NQNFS_TRYLATER;
- cacherep = RC_DOIT;
- } else
- modify_flag = 1;
- } else if (nfsd->nfsd_flag & NFSD_AUTHFAIL) {
- nfsd->nfsd_flag &= ~NFSD_AUTHFAIL;
- nd->nd_procnum = NFSPROC_NOOP;
- nd->nd_repstat = (NFSERR_AUTHERR | AUTH_TOOWEAK);
- cacherep = RC_DOIT;
- } else if (nfs_privport) {
- /* Check if source port is privileged */
- u_short port;
- struct sockaddr *nam = nd->nd_nam;
- struct sockaddr_in *sin;
-
- sin = (struct sockaddr_in *)nam;
- port = ntohs(sin->sin_port);
- if (port >= IPPORT_RESERVED &&
- nd->nd_procnum != NFSPROC_NULL) {
- nd->nd_procnum = NFSPROC_NOOP;
- nd->nd_repstat = (NFSERR_AUTHERR | AUTH_TOOWEAK);
- cacherep = RC_DOIT;
- printf("NFS request from unprivileged port (%s:%d)\n",
- inet_ntoa(sin->sin_addr), port);
- }
- }
-
- }
-
- /*
- * Loop to get all the write rpc relies that have been
- * gathered together.
- */
- do {
- switch (cacherep) {
- case RC_DOIT:
- if (nd && (nd->nd_flag & ND_NFSV3))
- procrastinate = nfsrvw_procrastinate_v3;
- else
- procrastinate = nfsrvw_procrastinate;
- if (writes_todo || (nd->nd_procnum == NFSPROC_WRITE &&
- procrastinate > 0 && !notstarted))
- error = nfsrv_writegather(&nd, slp,
- nfsd->nfsd_procp, &mreq);
- else
- error = (*(nfsrv3_procs[nd->nd_procnum]))(nd,
- slp, nfsd->nfsd_procp, &mreq);
- if (mreq == NULL)
- break;
- if (error != 0 && error != NFSERR_RETVOID) {
- if (nd->nd_procnum != NQNFSPROC_VACATED)
- nfsstats.srv_errs++;
- nfsrv_updatecache(nd, FALSE, mreq);
- if (nd->nd_nam2)
- FREE(nd->nd_nam2, M_SONAME);
- break;
- }
- nfsstats.srvrpccnt[nd->nd_procnum]++;
- nfsrv_updatecache(nd, TRUE, mreq);
- nd->nd_mrep = (struct mbuf *)0;
- case RC_REPLY:
- m = mreq;
- siz = 0;
- while (m) {
- siz += m->m_len;
- m = m->m_next;
- }
- if (siz <= 0 || siz > NFS_MAXPACKET) {
- printf("mbuf siz=%d\n",siz);
- panic("Bad nfs svc reply");
- }
- m = mreq;
- m->m_pkthdr.len = siz;
- m->m_pkthdr.rcvif = (struct ifnet *)0;
- /*
- * For stream protocols, prepend a Sun RPC
- * Record Mark.
- */
- if (sotype == SOCK_STREAM) {
- M_PREPEND(m, NFSX_UNSIGNED, M_WAIT);
- *mtod(m, u_int32_t *) = htonl(0x80000000 | siz);
- }
- if (slp->ns_so->so_proto->pr_flags & PR_CONNREQUIRED)
- (void) nfs_slplock(slp, 1);
- if (slp->ns_flag & SLP_VALID)
- error = nfs_send(slp->ns_so, nd->nd_nam2, m, NULL);
- else {
- error = EPIPE;
- m_freem(m);
- }
- if (nfsrtton)
- nfsd_rt(sotype, nd, cacherep);
- if (nd->nd_nam2)
- FREE(nd->nd_nam2, M_SONAME);
- if (nd->nd_mrep)
- m_freem(nd->nd_mrep);
- if (error == EPIPE)
- nfsrv_zapsock(slp);
- if (slp->ns_so->so_proto->pr_flags & PR_CONNREQUIRED)
- nfs_slpunlock(slp);
- if (error == EINTR || error == ERESTART) {
- free((caddr_t)nd, M_NFSRVDESC);
- nfsrv_slpderef(slp);
- s = splnet();
- goto done;
- }
- break;
- case RC_DROPIT:
- if (nfsrtton)
- nfsd_rt(sotype, nd, cacherep);
- m_freem(nd->nd_mrep);
- if (nd->nd_nam2)
- FREE(nd->nd_nam2, M_SONAME);
- break;
- };
- if (nd) {
- FREE((caddr_t)nd, M_NFSRVDESC);
- nd = NULL;
- }
-
- /*
- * Check to see if there are outstanding writes that
- * need to be serviced.
- */
- cur_usec = nfs_curusec();
- s = splsoftclock();
- if (slp->ns_tq.lh_first &&
- slp->ns_tq.lh_first->nd_time <= cur_usec) {
- cacherep = RC_DOIT;
- writes_todo = 1;
- } else
- writes_todo = 0;
- splx(s);
- } while (writes_todo);
- s = splnet();
- if (nfsrv_dorec(slp, nfsd, &nd)) {
- nfsd->nfsd_flag &= ~NFSD_REQINPROG;
- nfsd->nfsd_slp = NULL;
- nfsrv_slpderef(slp);
- }
- }
-done:
- TAILQ_REMOVE(&nfsd_head, nfsd, nfsd_chain);
- splx(s);
- free((caddr_t)nfsd, M_NFSD);
- nsd->nsd_nfsd = (struct nfsd *)0;
- if (--nfs_numnfsd == 0)
- nfsrv_init(TRUE); /* Reinitialize everything */
- return (error);
-}
-
-/*
- * Shut down a socket associated with an nfssvc_sock structure.
- * Should be called with the send lock set, if required.
- * The trick here is to increment the sref at the start, so that the nfsds
- * will stop using it and clear ns_flag at the end so that it will not be
- * reassigned during cleanup.
- */
-static void
-nfsrv_zapsock(slp)
- register struct nfssvc_sock *slp;
-{
- register struct nfsuid *nuidp, *nnuidp;
- register struct nfsrv_descript *nwp, *nnwp;
- struct socket *so;
- struct file *fp;
- struct nfsrv_rec *rec;
- int s;
-
- slp->ns_flag &= ~SLP_ALLFLAGS;
- fp = slp->ns_fp;
- if (fp) {
- slp->ns_fp = (struct file *)0;
- so = slp->ns_so;
- so->so_rcv.sb_flags &= ~SB_UPCALL;
- so->so_upcall = NULL;
- so->so_upcallarg = NULL;
- soshutdown(so, 2);
- closef(fp, (struct proc *)0);
- if (slp->ns_nam)
- FREE(slp->ns_nam, M_SONAME);
- m_freem(slp->ns_raw);
- while ((rec = STAILQ_FIRST(&slp->ns_rec)) != NULL) {
- STAILQ_REMOVE_HEAD(&slp->ns_rec, nr_link);
- if (rec->nr_address)
- FREE(rec->nr_address, M_SONAME);
- m_freem(rec->nr_packet);
- free(rec, M_NFSRVDESC);
- }
- for (nuidp = slp->ns_uidlruhead.tqh_first; nuidp != 0;
- nuidp = nnuidp) {
- nnuidp = nuidp->nu_lru.tqe_next;
- LIST_REMOVE(nuidp, nu_hash);
- TAILQ_REMOVE(&slp->ns_uidlruhead, nuidp, nu_lru);
- if (nuidp->nu_flag & NU_NAM)
- FREE(nuidp->nu_nam, M_SONAME);
- free((caddr_t)nuidp, M_NFSUID);
- }
- s = splsoftclock();
- for (nwp = slp->ns_tq.lh_first; nwp; nwp = nnwp) {
- nnwp = nwp->nd_tq.le_next;
- LIST_REMOVE(nwp, nd_tq);
- free((caddr_t)nwp, M_NFSRVDESC);
- }
- LIST_INIT(&slp->ns_tq);
- splx(s);
- }
-}
-
-/*
- * Derefence a server socket structure. If it has no more references and
- * is no longer valid, you can throw it away.
- */
-void
-nfsrv_slpderef(slp)
- register struct nfssvc_sock *slp;
-{
- if (--(slp->ns_sref) == 0 && (slp->ns_flag & SLP_VALID) == 0) {
- TAILQ_REMOVE(&nfssvc_sockhead, slp, ns_chain);
- free((caddr_t)slp, M_NFSSVC);
- }
-}
-
-/*
- * Lock a socket against others.
- */
-int
-nfs_slplock(slp, wait)
- register struct nfssvc_sock *slp;
- int wait;
-{
- int *statep = &slp->ns_solock;
-
- if (!wait && (*statep & NFSSTA_SNDLOCK))
- return(0); /* already locked, fail */
- while (*statep & NFSSTA_SNDLOCK) {
- *statep |= NFSSTA_WANTSND;
- (void) tsleep((caddr_t)statep, PZERO - 1, "nfsslplck", 0);
- }
- *statep |= NFSSTA_SNDLOCK;
- return (1);
-}
-
-/*
- * Unlock the stream socket for others.
- */
-void
-nfs_slpunlock(slp)
- register struct nfssvc_sock *slp;
-{
- int *statep = &slp->ns_solock;
-
- if ((*statep & NFSSTA_SNDLOCK) == 0)
- panic("nfs slpunlock");
- *statep &= ~NFSSTA_SNDLOCK;
- if (*statep & NFSSTA_WANTSND) {
- *statep &= ~NFSSTA_WANTSND;
- wakeup((caddr_t)statep);
- }
-}
-
-/*
- * Initialize the data structures for the server.
- * Handshake with any new nfsds starting up to avoid any chance of
- * corruption.
- */
-void
-nfsrv_init(terminating)
- int terminating;
-{
- register struct nfssvc_sock *slp, *nslp;
-
- if (nfssvc_sockhead_flag & SLP_INIT)
- panic("nfsd init");
- nfssvc_sockhead_flag |= SLP_INIT;
- if (terminating) {
- for (slp = nfssvc_sockhead.tqh_first; slp != 0; slp = nslp) {
- nslp = slp->ns_chain.tqe_next;
- if (slp->ns_flag & SLP_VALID)
- nfsrv_zapsock(slp);
- TAILQ_REMOVE(&nfssvc_sockhead, slp, ns_chain);
- free((caddr_t)slp, M_NFSSVC);
- }
- nfsrv_cleancache(); /* And clear out server cache */
- } else
- nfs_pub.np_valid = 0;
-
- TAILQ_INIT(&nfssvc_sockhead);
- nfssvc_sockhead_flag &= ~SLP_INIT;
- if (nfssvc_sockhead_flag & SLP_WANTINIT) {
- nfssvc_sockhead_flag &= ~SLP_WANTINIT;
- wakeup((caddr_t)&nfssvc_sockhead);
- }
-
- TAILQ_INIT(&nfsd_head);
- nfsd_head_flag &= ~NFSD_CHECKSLP;
-
-#if 0
- nfs_udpsock = (struct nfssvc_sock *)
- malloc(sizeof (struct nfssvc_sock), M_NFSSVC, M_WAITOK);
- bzero((caddr_t)nfs_udpsock, sizeof (struct nfssvc_sock));
- STAILQ_INIT(&nfs_udpsock->ns_rec);
- TAILQ_INIT(&nfs_udpsock->ns_uidlruhead);
- TAILQ_INSERT_HEAD(&nfssvc_sockhead, nfs_udpsock, ns_chain);
-
- nfs_cltpsock = (struct nfssvc_sock *)
- malloc(sizeof (struct nfssvc_sock), M_NFSSVC, M_WAITOK);
- bzero((caddr_t)nfs_cltpsock, sizeof (struct nfssvc_sock));
- STAILQ_INIT(&nfs_cltpsock->ns_rec);
- TAILQ_INIT(&nfs_cltpsock->ns_uidlruhead);
- TAILQ_INSERT_TAIL(&nfssvc_sockhead, nfs_cltpsock, ns_chain);
-#endif
-}
-
-/*
- * Add entries to the server monitor log.
- */
-static void
-nfsd_rt(sotype, nd, cacherep)
- int sotype;
- register struct nfsrv_descript *nd;
- int cacherep;
-{
- register struct drt *rt;
-
- rt = &nfsdrt.drt[nfsdrt.pos];
- if (cacherep == RC_DOIT)
- rt->flag = 0;
- else if (cacherep == RC_REPLY)
- rt->flag = DRT_CACHEREPLY;
- else
- rt->flag = DRT_CACHEDROP;
- if (sotype == SOCK_STREAM)
- rt->flag |= DRT_TCP;
- if (nd->nd_flag & ND_NQNFS)
- rt->flag |= DRT_NQNFS;
- else if (nd->nd_flag & ND_NFSV3)
- rt->flag |= DRT_NFSV3;
- rt->proc = nd->nd_procnum;
- if (nd->nd_nam->sa_family == AF_INET)
- rt->ipadr = ((struct sockaddr_in *)nd->nd_nam)->sin_addr.s_addr;
- else
- rt->ipadr = INADDR_ANY;
- rt->resptime = nfs_curusec() - (nd->nd_starttime.tv_sec * 1000000 + nd->nd_starttime.tv_usec);
- getmicrotime(&rt->tstamp);
- nfsdrt.pos = (nfsdrt.pos + 1) % NFSRTTLOGSIZ;
-}
-#endif /* NFS_NOSERVER */
-
-static int nfs_defect = 0;
-SYSCTL_INT(_vfs_nfs, OID_AUTO, defect, CTLFLAG_RW, &nfs_defect, 0, "");
-
-/*
- * Asynchronous I/O daemons for client nfs.
- * They do read-ahead and write-behind operations on the block I/O cache.
- * Never returns unless it fails or gets killed.
- */
-static int
-nfssvc_iod(p)
- struct proc *p;
-{
- register struct buf *bp;
- register int i, myiod;
- struct nfsmount *nmp;
- int error = 0;
-
- /*
- * Assign my position or return error if too many already running
- */
- myiod = -1;
- for (i = 0; i < NFS_MAXASYNCDAEMON; i++)
- if (nfs_asyncdaemon[i] == 0) {
- nfs_asyncdaemon[i]++;
- myiod = i;
- break;
- }
- if (myiod == -1)
- return (EBUSY);
- nfs_numasync++;
- /*
- * Just loop around doin our stuff until SIGKILL
- */
- for (;;) {
- while (((nmp = nfs_iodmount[myiod]) == NULL
- || nmp->nm_bufq.tqh_first == NULL)
- && error == 0) {
- if (nmp)
- nmp->nm_bufqiods--;
- nfs_iodwant[myiod] = p;
- nfs_iodmount[myiod] = NULL;
- error = tsleep((caddr_t)&nfs_iodwant[myiod],
- PWAIT | PCATCH, "nfsidl", 0);
- }
- if (error) {
- nfs_asyncdaemon[myiod] = 0;
- if (nmp)
- nmp->nm_bufqiods--;
- nfs_iodwant[myiod] = NULL;
- nfs_iodmount[myiod] = NULL;
- nfs_numasync--;
- return (error);
- }
- while ((bp = nmp->nm_bufq.tqh_first) != NULL) {
- /* Take one off the front of the list */
- TAILQ_REMOVE(&nmp->nm_bufq, bp, b_freelist);
- nmp->nm_bufqlen--;
- if (nmp->nm_bufqwant && nmp->nm_bufqlen <= nfs_numasync) {
- nmp->nm_bufqwant = FALSE;
- wakeup(&nmp->nm_bufq);
- }
- if (bp->b_flags & B_READ)
- (void) nfs_doio(bp, bp->b_rcred, (struct proc *)0);
- else
- (void) nfs_doio(bp, bp->b_wcred, (struct proc *)0);
- /*
- * If there are more than one iod on this mount, then defect
- * so that the iods can be shared out fairly between the mounts
- */
- if (nfs_defect && nmp->nm_bufqiods > 1) {
- NFS_DPF(ASYNCIO,
- ("nfssvc_iod: iod %d defecting from mount %p\n",
- myiod, nmp));
- nfs_iodmount[myiod] = NULL;
- nmp->nm_bufqiods--;
- break;
- }
- }
- }
-}
-
-
-/*
- * Get an authorization string for the uid by having the mount_nfs sitting
- * on this mount point porpous out of the kernel and do it.
- */
-int
-nfs_getauth(nmp, rep, cred, auth_str, auth_len, verf_str, verf_len, key)
- register struct nfsmount *nmp;
- struct nfsreq *rep;
- struct ucred *cred;
- char **auth_str;
- int *auth_len;
- char *verf_str;
- int *verf_len;
- NFSKERBKEY_T key; /* return session key */
-{
- int error = 0;
-
- while ((nmp->nm_state & NFSSTA_WAITAUTH) == 0) {
- nmp->nm_state |= NFSSTA_WANTAUTH;
- (void) tsleep((caddr_t)&nmp->nm_authtype, PSOCK,
- "nfsauth1", 2 * hz);
- error = nfs_sigintr(nmp, rep, rep->r_procp);
- if (error) {
- nmp->nm_state &= ~NFSSTA_WANTAUTH;
- return (error);
- }
- }
- nmp->nm_state &= ~(NFSSTA_WAITAUTH | NFSSTA_WANTAUTH);
- nmp->nm_authstr = *auth_str = (char *)malloc(RPCAUTH_MAXSIZ, M_TEMP, M_WAITOK);
- nmp->nm_authlen = RPCAUTH_MAXSIZ;
- nmp->nm_verfstr = verf_str;
- nmp->nm_verflen = *verf_len;
- nmp->nm_authuid = cred->cr_uid;
- wakeup((caddr_t)&nmp->nm_authstr);
-
- /*
- * And wait for mount_nfs to do its stuff.
- */
- while ((nmp->nm_state & NFSSTA_HASAUTH) == 0 && error == 0) {
- (void) tsleep((caddr_t)&nmp->nm_authlen, PSOCK,
- "nfsauth2", 2 * hz);
- error = nfs_sigintr(nmp, rep, rep->r_procp);
- }
- if (nmp->nm_state & NFSSTA_AUTHERR) {
- nmp->nm_state &= ~NFSSTA_AUTHERR;
- error = EAUTH;
- }
- if (error)
- free((caddr_t)*auth_str, M_TEMP);
- else {
- *auth_len = nmp->nm_authlen;
- *verf_len = nmp->nm_verflen;
- bcopy((caddr_t)nmp->nm_key, (caddr_t)key, sizeof (key));
- }
- nmp->nm_state &= ~NFSSTA_HASAUTH;
- nmp->nm_state |= NFSSTA_WAITAUTH;
- if (nmp->nm_state & NFSSTA_WANTAUTH) {
- nmp->nm_state &= ~NFSSTA_WANTAUTH;
- wakeup((caddr_t)&nmp->nm_authtype);
- }
- return (error);
-}
-
-/*
- * Get a nickname authenticator and verifier.
- */
-int
-nfs_getnickauth(nmp, cred, auth_str, auth_len, verf_str, verf_len)
- struct nfsmount *nmp;
- struct ucred *cred;
- char **auth_str;
- int *auth_len;
- char *verf_str;
- int verf_len;
-{
- register struct nfsuid *nuidp;
- register u_int32_t *nickp, *verfp;
- struct timeval ktvin, ktvout;
-
-#ifdef DIAGNOSTIC
- if (verf_len < (4 * NFSX_UNSIGNED))
- panic("nfs_getnickauth verf too small");
-#endif
- for (nuidp = NMUIDHASH(nmp, cred->cr_uid)->lh_first;
- nuidp != 0; nuidp = nuidp->nu_hash.le_next) {
- if (nuidp->nu_cr.cr_uid == cred->cr_uid)
- break;
- }
- if (!nuidp || nuidp->nu_expire < time_second)
- return (EACCES);
-
- /*
- * Move to the end of the lru list (end of lru == most recently used).
- */
- TAILQ_REMOVE(&nmp->nm_uidlruhead, nuidp, nu_lru);
- TAILQ_INSERT_TAIL(&nmp->nm_uidlruhead, nuidp, nu_lru);
-
- nickp = (u_int32_t *)malloc(2 * NFSX_UNSIGNED, M_TEMP, M_WAITOK);
- *nickp++ = txdr_unsigned(RPCAKN_NICKNAME);
- *nickp = txdr_unsigned(nuidp->nu_nickname);
- *auth_str = (char *)nickp;
- *auth_len = 2 * NFSX_UNSIGNED;
-
- /*
- * Now we must encrypt the verifier and package it up.
- */
- verfp = (u_int32_t *)verf_str;
- *verfp++ = txdr_unsigned(RPCAKN_NICKNAME);
- if (time_second > nuidp->nu_timestamp.tv_sec ||
- (time_second == nuidp->nu_timestamp.tv_sec &&
- time_second > nuidp->nu_timestamp.tv_usec))
- getmicrotime(&nuidp->nu_timestamp);
- else
- nuidp->nu_timestamp.tv_usec++;
- ktvin.tv_sec = txdr_unsigned(nuidp->nu_timestamp.tv_sec);
- ktvin.tv_usec = txdr_unsigned(nuidp->nu_timestamp.tv_usec);
-
- /*
- * Now encrypt the timestamp verifier in ecb mode using the session
- * key.
- */
-#ifdef NFSKERB
- XXX
-#endif
-
- *verfp++ = ktvout.tv_sec;
- *verfp++ = ktvout.tv_usec;
- *verfp = 0;
- return (0);
-}
-
-/*
- * Save the current nickname in a hash list entry on the mount point.
- */
-int
-nfs_savenickauth(nmp, cred, len, key, mdp, dposp, mrep)
- register struct nfsmount *nmp;
- struct ucred *cred;
- int len;
- NFSKERBKEY_T key;
- struct mbuf **mdp;
- char **dposp;
- struct mbuf *mrep;
-{
- register struct nfsuid *nuidp;
- register u_int32_t *tl;
- register int32_t t1;
- struct mbuf *md = *mdp;
- struct timeval ktvin, ktvout;
- u_int32_t nick;
- char *dpos = *dposp, *cp2;
- int deltasec, error = 0;
-
- if (len == (3 * NFSX_UNSIGNED)) {
- nfsm_dissect(tl, u_int32_t *, 3 * NFSX_UNSIGNED);
- ktvin.tv_sec = *tl++;
- ktvin.tv_usec = *tl++;
- nick = fxdr_unsigned(u_int32_t, *tl);
-
- /*
- * Decrypt the timestamp in ecb mode.
- */
-#ifdef NFSKERB
- XXX
-#endif
- ktvout.tv_sec = fxdr_unsigned(long, ktvout.tv_sec);
- ktvout.tv_usec = fxdr_unsigned(long, ktvout.tv_usec);
- deltasec = time_second - ktvout.tv_sec;
- if (deltasec < 0)
- deltasec = -deltasec;
- /*
- * If ok, add it to the hash list for the mount point.
- */
- if (deltasec <= NFS_KERBCLOCKSKEW) {
- if (nmp->nm_numuids < nuidhash_max) {
- nmp->nm_numuids++;
- nuidp = (struct nfsuid *)
- malloc(sizeof (struct nfsuid), M_NFSUID,
- M_WAITOK);
- } else {
- nuidp = nmp->nm_uidlruhead.tqh_first;
- LIST_REMOVE(nuidp, nu_hash);
- TAILQ_REMOVE(&nmp->nm_uidlruhead, nuidp,
- nu_lru);
- }
- nuidp->nu_flag = 0;
- nuidp->nu_cr.cr_uid = cred->cr_uid;
- nuidp->nu_expire = time_second + NFS_KERBTTL;
- nuidp->nu_timestamp = ktvout;
- nuidp->nu_nickname = nick;
- bcopy(key, nuidp->nu_key, sizeof (key));
- TAILQ_INSERT_TAIL(&nmp->nm_uidlruhead, nuidp,
- nu_lru);
- LIST_INSERT_HEAD(NMUIDHASH(nmp, cred->cr_uid),
- nuidp, nu_hash);
- }
- } else
- nfsm_adv(nfsm_rndup(len));
-nfsmout:
- *mdp = md;
- *dposp = dpos;
- return (error);
-}
diff --git a/sys/nfsserver/nfsm_subs.h b/sys/nfsserver/nfsm_subs.h
deleted file mode 100644
index b13c0099b816..000000000000
--- a/sys/nfsserver/nfsm_subs.h
+++ /dev/null
@@ -1,564 +0,0 @@
-/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Rick Macklem at The University of Guelph.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)nfsm_subs.h 8.2 (Berkeley) 3/30/95
- * $FreeBSD$
- */
-
-
-#ifndef _NFS_NFSM_SUBS_H_
-#define _NFS_NFSM_SUBS_H_
-
-struct ucred;
-struct vnode;
-
-/*
- * These macros do strange and peculiar things to mbuf chains for
- * the assistance of the nfs code. To attempt to use them for any
- * other purpose will be dangerous. (they make weird assumptions)
- */
-
-/*
- * First define what the actual subs. return
- */
-struct mbuf *nfsm_reqh __P((struct vnode *vp, u_long procid, int hsiz,
- caddr_t *bposp));
-struct mbuf *nfsm_rpchead __P((struct ucred *cr, int nmflag, int procid,
- int auth_type, int auth_len, char *auth_str,
- int verf_len, char *verf_str,
- struct mbuf *mrest, int mrest_len,
- struct mbuf **mbp, u_int32_t *xidp));
-
-#define M_HASCL(m) ((m)->m_flags & M_EXT)
-#define NFSMINOFF(m) \
- do { \
- if (M_HASCL(m)) \
- (m)->m_data = (m)->m_ext.ext_buf; \
- else if ((m)->m_flags & M_PKTHDR) \
- (m)->m_data = (m)->m_pktdat; \
- else \
- (m)->m_data = (m)->m_dat; \
- } while (0)
-#define NFSMADV(m, s) \
- do { \
- (m)->m_data += (s); \
- } while (0)
-#define NFSMSIZ(m) ((M_HASCL(m))?MCLBYTES: \
- (((m)->m_flags & M_PKTHDR)?MHLEN:MLEN))
-
-/*
- * Now for the macros that do the simple stuff and call the functions
- * for the hard stuff.
- * These macros use several vars. declared in nfsm_reqhead and these
- * vars. must not be used elsewhere unless you are careful not to corrupt
- * them. The vars. starting with pN and tN (N=1,2,3,..) are temporaries
- * that may be used so long as the value is not expected to retained
- * after a macro.
- * I know, this is kind of dorkey, but it makes the actual op functions
- * fairly clean and deals with the mess caused by the xdr discriminating
- * unions.
- */
-
-#define nfsm_build(a,c,s) \
- do { \
- if ((s) > M_TRAILINGSPACE(mb)) { \
- MGET(mb2, M_WAIT, MT_DATA); \
- if ((s) > MLEN) \
- panic("build > MLEN"); \
- mb->m_next = mb2; \
- mb = mb2; \
- mb->m_len = 0; \
- bpos = mtod(mb, caddr_t); \
- } \
- (a) = (c)(bpos); \
- mb->m_len += (s); \
- bpos += (s); \
- } while (0)
-
-#define nfsm_dissect(a, c, s) \
- do { \
- t1 = mtod(md, caddr_t)+md->m_len-dpos; \
- if (t1 >= (s)) { \
- (a) = (c)(dpos); \
- dpos += (s); \
- } else if ((t1 = nfsm_disct(&md, &dpos, (s), t1, &cp2)) != 0){ \
- error = t1; \
- m_freem(mrep); \
- goto nfsmout; \
- } else { \
- (a) = (c)cp2; \
- } \
- } while (0)
-
-#define nfsm_fhtom(v, v3) \
- do { \
- if (v3) { \
- t2 = nfsm_rndup(VTONFS(v)->n_fhsize) + NFSX_UNSIGNED; \
- if (t2 <= M_TRAILINGSPACE(mb)) { \
- nfsm_build(tl, u_int32_t *, t2); \
- *tl++ = txdr_unsigned(VTONFS(v)->n_fhsize); \
- *(tl + ((t2>>2) - 2)) = 0; \
- bcopy((caddr_t)VTONFS(v)->n_fhp,(caddr_t)tl, \
- VTONFS(v)->n_fhsize); \
- } else if ((t2 = nfsm_strtmbuf(&mb, &bpos, \
- (caddr_t)VTONFS(v)->n_fhp, \
- VTONFS(v)->n_fhsize)) != 0) { \
- error = t2; \
- m_freem(mreq); \
- goto nfsmout; \
- } \
- } else { \
- nfsm_build(cp, caddr_t, NFSX_V2FH); \
- bcopy((caddr_t)VTONFS(v)->n_fhp, cp, NFSX_V2FH); \
- } \
- } while (0)
-
-#define nfsm_srvfhtom(f, v3) \
- do { \
- if (v3) { \
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED + NFSX_V3FH);\
- *tl++ = txdr_unsigned(NFSX_V3FH); \
- bcopy((caddr_t)(f), (caddr_t)tl, NFSX_V3FH); \
- } else { \
- nfsm_build(cp, caddr_t, NFSX_V2FH); \
- bcopy((caddr_t)(f), cp, NFSX_V2FH); \
- } \
- } while (0)
-
-#define nfsm_srvpostop_fh(f) \
- do { \
- nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED + NFSX_V3FH); \
- *tl++ = nfs_true; \
- *tl++ = txdr_unsigned(NFSX_V3FH); \
- bcopy((caddr_t)(f), (caddr_t)tl, NFSX_V3FH); \
- } while (0)
-
-#define nfsm_mtofh(d, v, v3, f) \
- do { \
- struct nfsnode *ttnp; nfsfh_t *ttfhp; int ttfhsize; \
- if (v3) { \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- (f) = fxdr_unsigned(int, *tl); \
- } else \
- (f) = 1; \
- if (f) { \
- nfsm_getfh(ttfhp, ttfhsize, (v3)); \
- if ((t1 = nfs_nget((d)->v_mount, ttfhp, ttfhsize, \
- &ttnp)) != 0) { \
- error = t1; \
- m_freem(mrep); \
- goto nfsmout; \
- } \
- (v) = NFSTOV(ttnp); \
- } \
- if (v3) { \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- if (f) \
- (f) = fxdr_unsigned(int, *tl); \
- else if (fxdr_unsigned(int, *tl)) \
- nfsm_adv(NFSX_V3FATTR); \
- } \
- if (f) \
- nfsm_loadattr((v), (struct vattr *)0); \
- } while (0)
-
-#define nfsm_getfh(f, s, v3) \
- do { \
- if (v3) { \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- if (((s) = fxdr_unsigned(int, *tl)) <= 0 || \
- (s) > NFSX_V3FHMAX) { \
- m_freem(mrep); \
- error = EBADRPC; \
- goto nfsmout; \
- } \
- } else \
- (s) = NFSX_V2FH; \
- nfsm_dissect((f), nfsfh_t *, nfsm_rndup(s)); \
- } while (0)
-
-#define nfsm_loadattr(v, a) \
- do { \
- struct vnode *ttvp = (v); \
- if ((t1 = nfs_loadattrcache(&ttvp, &md, &dpos, (a))) != 0) { \
- error = t1; \
- m_freem(mrep); \
- goto nfsmout; \
- } \
- (v) = ttvp; \
- } while (0)
-
-#define nfsm_postop_attr(v, f) \
- do { \
- struct vnode *ttvp = (v); \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- if (((f) = fxdr_unsigned(int, *tl)) != 0) { \
- if ((t1 = nfs_loadattrcache(&ttvp, &md, &dpos, \
- (struct vattr *)0)) != 0) { \
- error = t1; \
- (f) = 0; \
- m_freem(mrep); \
- goto nfsmout; \
- } \
- (v) = ttvp; \
- } \
- } while (0)
-
-/* Used as (f) for nfsm_wcc_data() */
-#define NFSV3_WCCRATTR 0
-#define NFSV3_WCCCHK 1
-
-#define nfsm_wcc_data(v, f) \
- do { \
- int ttattrf, ttretf = 0; \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- if (*tl == nfs_true) { \
- nfsm_dissect(tl, u_int32_t *, 6 * NFSX_UNSIGNED); \
- if (f) \
- ttretf = (VTONFS(v)->n_mtime == \
- fxdr_unsigned(u_int32_t, *(tl + 2))); \
- } \
- nfsm_postop_attr((v), ttattrf); \
- if (f) { \
- (f) = ttretf; \
- } else { \
- (f) = ttattrf; \
- } \
- } while (0)
-
-/* If full is true, set all fields, otherwise just set mode and time fields */
-#define nfsm_v3attrbuild(a, full) \
- do { \
- if ((a)->va_mode != (mode_t)VNOVAL) { \
- nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
- *tl++ = nfs_true; \
- *tl = txdr_unsigned((a)->va_mode); \
- } else { \
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \
- *tl = nfs_false; \
- } \
- if ((full) && (a)->va_uid != (uid_t)VNOVAL) { \
- nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
- *tl++ = nfs_true; \
- *tl = txdr_unsigned((a)->va_uid); \
- } else { \
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \
- *tl = nfs_false; \
- } \
- if ((full) && (a)->va_gid != (gid_t)VNOVAL) { \
- nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
- *tl++ = nfs_true; \
- *tl = txdr_unsigned((a)->va_gid); \
- } else { \
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \
- *tl = nfs_false; \
- } \
- if ((full) && (a)->va_size != VNOVAL) { \
- nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED); \
- *tl++ = nfs_true; \
- txdr_hyper((a)->va_size, tl); \
- } else { \
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \
- *tl = nfs_false; \
- } \
- if ((a)->va_atime.tv_sec != VNOVAL) { \
- if ((a)->va_atime.tv_sec != time_second) { \
- nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED);\
- *tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT);\
- txdr_nfsv3time(&(a)->va_atime, tl); \
- } else { \
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \
- *tl = txdr_unsigned(NFSV3SATTRTIME_TOSERVER); \
- } \
- } else { \
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \
- *tl = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE); \
- } \
- if ((a)->va_mtime.tv_sec != VNOVAL) { \
- if ((a)->va_mtime.tv_sec != time_second) { \
- nfsm_build(tl, u_int32_t *, 3 * NFSX_UNSIGNED);\
- *tl++ = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT);\
- txdr_nfsv3time(&(a)->va_mtime, tl); \
- } else { \
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \
- *tl = txdr_unsigned(NFSV3SATTRTIME_TOSERVER); \
- } \
- } else { \
- nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); \
- *tl = txdr_unsigned(NFSV3SATTRTIME_DONTCHANGE); \
- } \
- } while (0)
-
-
-#define nfsm_strsiz(s,m) \
- do { \
- nfsm_dissect(tl,u_int32_t *,NFSX_UNSIGNED); \
- if (((s) = fxdr_unsigned(int32_t,*tl)) > (m)) { \
- m_freem(mrep); \
- error = EBADRPC; \
- goto nfsmout; \
- } \
- } while (0)
-
-#define nfsm_srvstrsiz(s,m) \
- do { \
- nfsm_dissect(tl,u_int32_t *,NFSX_UNSIGNED); \
- if (((s) = fxdr_unsigned(int32_t,*tl)) > (m) || (s) <= 0) { \
- error = EBADRPC; \
- nfsm_reply(0); \
- } \
- } while (0)
-
-#define nfsm_srvnamesiz(s) \
- do { \
- nfsm_dissect(tl,u_int32_t *,NFSX_UNSIGNED); \
- if (((s) = fxdr_unsigned(int32_t,*tl)) > NFS_MAXNAMLEN) \
- error = NFSERR_NAMETOL; \
- if ((s) <= 0) \
- error = EBADRPC; \
- if (error) \
- nfsm_reply(0); \
- } while (0)
-
-#define nfsm_mtouio(p,s) \
- do {\
- if ((s) > 0 && \
- (t1 = nfsm_mbuftouio(&md,(p),(s),&dpos)) != 0) { \
- error = t1; \
- m_freem(mrep); \
- goto nfsmout; \
- } \
- } while (0)
-
-#define nfsm_uiotom(p,s) \
- do { \
- if ((t1 = nfsm_uiotombuf((p),&mb,(s),&bpos)) != 0) { \
- error = t1; \
- m_freem(mreq); \
- goto nfsmout; \
- } \
- } while (0)
-
-#define nfsm_reqhead(v,a,s) \
- do { \
- mb = mreq = nfsm_reqh((v),(a),(s),&bpos); \
- } while (0)
-
-#define nfsm_reqdone \
- do { \
- m_freem(mrep); \
- nfsmout: \
- } while (0)
-
-#define nfsm_rndup(a) (((a)+3)&(~0x3))
-
-#define nfsm_request(v, t, p, c) \
- do { \
- if ((error = nfs_request((v), mreq, (t), (p), \
- (c), &mrep, &md, &dpos)) != 0) { \
- if (error & NFSERR_RETERR) \
- error &= ~NFSERR_RETERR; \
- else \
- goto nfsmout; \
- } \
- } while (0)
-
-#define nfsm_strtom(a,s,m) \
- do {\
- if ((s) > (m)) { \
- m_freem(mreq); \
- error = ENAMETOOLONG; \
- goto nfsmout; \
- } \
- t2 = nfsm_rndup(s)+NFSX_UNSIGNED; \
- if (t2 <= M_TRAILINGSPACE(mb)) { \
- nfsm_build(tl,u_int32_t *,t2); \
- *tl++ = txdr_unsigned(s); \
- *(tl+((t2>>2)-2)) = 0; \
- bcopy((const char *)(a), (caddr_t)tl, (s)); \
- } else if ((t2 = nfsm_strtmbuf(&mb, &bpos, (a), (s))) != 0) { \
- error = t2; \
- m_freem(mreq); \
- goto nfsmout; \
- } \
- } while (0)
-
-#define nfsm_srvdone \
- do { \
- nfsmout: \
- return (error); \
- } while (0)
-
-#define nfsm_reply(s) \
- do { \
- nfsd->nd_repstat = error; \
- if (error && !(nfsd->nd_flag & ND_NFSV3)) \
- (void) nfs_rephead(0, nfsd, slp, error, cache, &frev, \
- mrq, &mb, &bpos); \
- else \
- (void) nfs_rephead((s), nfsd, slp, error, cache, &frev, \
- mrq, &mb, &bpos); \
- if (mrep != NULL) { \
- m_freem(mrep); \
- mrep = NULL; \
- } \
- mreq = *mrq; \
- if (error && (!(nfsd->nd_flag & ND_NFSV3) || \
- error == EBADRPC)) { \
- error = 0; \
- goto nfsmout; \
- } \
- } while (0)
-
-#define nfsm_writereply(s, v3) \
- do { \
- nfsd->nd_repstat = error; \
- if (error && !(v3)) \
- (void) nfs_rephead(0, nfsd, slp, error, cache, &frev, \
- &mreq, &mb, &bpos); \
- else \
- (void) nfs_rephead((s), nfsd, slp, error, cache, &frev, \
- &mreq, &mb, &bpos); \
- } while (0)
-
-#define nfsm_adv(s) \
- do { \
- t1 = mtod(md, caddr_t)+md->m_len-dpos; \
- if (t1 >= (s)) { \
- dpos += (s); \
- } else if ((t1 = nfs_adv(&md, &dpos, (s), t1)) != 0) { \
- error = t1; \
- m_freem(mrep); \
- goto nfsmout; \
- } \
- } while (0)
-
-#define nfsm_srvmtofh(f) \
- do { \
- int fhlen; \
- if (nfsd->nd_flag & ND_NFSV3) { \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- fhlen = fxdr_unsigned(int, *tl); \
- if (fhlen != 0 && fhlen != NFSX_V3FH) { \
- error = EBADRPC; \
- nfsm_reply(0); \
- } \
- } else { \
- fhlen = NFSX_V2FH; \
- } \
- if (fhlen != 0) { \
- nfsm_dissect(tl, u_int32_t *, fhlen); \
- bcopy((caddr_t)tl, (caddr_t)(f), fhlen); \
- } else {\
- bzero((caddr_t)(f), NFSX_V3FH); \
- } \
- } while (0)
-
-#define nfsm_clget \
- do { \
- if (bp >= be) { \
- if (mp == mb) \
- mp->m_len += bp-bpos; \
- MGET(mp, M_WAIT, MT_DATA); \
- MCLGET(mp, M_WAIT); \
- mp->m_len = NFSMSIZ(mp); \
- mp2->m_next = mp; \
- mp2 = mp; \
- bp = mtod(mp, caddr_t); \
- be = bp+mp->m_len; \
- } \
- tl = (u_int32_t *)bp; \
- } while (0)
-
-#define nfsm_srvfillattr(a, f) \
- do { \
- nfsm_srvfattr(nfsd, (a), (f)); \
- } while (0)
-
-#define nfsm_srvwcc_data(br, b, ar, a) \
- do { \
- nfsm_srvwcc(nfsd, (br), (b), (ar), (a), &mb, &bpos); \
- } while (0)
-
-#define nfsm_srvpostop_attr(r, a) \
- do { \
- nfsm_srvpostopattr(nfsd, (r), (a), &mb, &bpos); \
- } while (0)
-
-#define nfsm_srvsattr(a) \
- do { \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- if (*tl == nfs_true) { \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- (a)->va_mode = nfstov_mode(*tl); \
- } \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- if (*tl == nfs_true) { \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- (a)->va_uid = fxdr_unsigned(uid_t, *tl); \
- } \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- if (*tl == nfs_true) { \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- (a)->va_gid = fxdr_unsigned(gid_t, *tl); \
- } \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- if (*tl == nfs_true) { \
- nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
- (a)->va_size = fxdr_hyper(tl); \
- } \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- switch (fxdr_unsigned(int, *tl)) { \
- case NFSV3SATTRTIME_TOCLIENT: \
- nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
- fxdr_nfsv3time(tl, &(a)->va_atime); \
- break; \
- case NFSV3SATTRTIME_TOSERVER: \
- getnanotime(&(a)->va_atime); \
- break; \
- }; \
- nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
- switch (fxdr_unsigned(int, *tl)) { \
- case NFSV3SATTRTIME_TOCLIENT: \
- nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
- fxdr_nfsv3time(tl, &(a)->va_mtime); \
- break; \
- case NFSV3SATTRTIME_TOSERVER: \
- getnanotime(&(a)->va_mtime); \
- break; \
- } \
- } while (0)
-
-#endif
diff --git a/sys/nfsserver/nfsproto.h b/sys/nfsserver/nfsproto.h
deleted file mode 100644
index cbb2832704bd..000000000000
--- a/sys/nfsserver/nfsproto.h
+++ /dev/null
@@ -1,439 +0,0 @@
-/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Rick Macklem at The University of Guelph.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)nfsproto.h 8.2 (Berkeley) 3/30/95
- * $FreeBSD$
- */
-
-#ifndef _NFS_NFSPROTO_H_
-#define _NFS_NFSPROTO_H_
-
-/*
- * nfs definitions as per the Version 2 and 3 specs
- */
-
-/*
- * Constants as defined in the Sun NFS Version 2 and 3 specs.
- * "NFS: Network File System Protocol Specification" RFC1094
- * and in the "NFS: Network File System Version 3 Protocol
- * Specification"
- */
-
-#define NFS_PORT 2049
-#define NFS_PROG 100003
-#define NFS_VER2 2
-#define NFS_VER3 3
-#define NFS_V2MAXDATA 8192
-#define NFS_MAXDGRAMDATA 16384
-#define NFS_MAXDATA 32768
-#define NFS_MAXPATHLEN 1024
-#define NFS_MAXNAMLEN 255
-#define NFS_MAXPKTHDR 404
-#define NFS_MAXPACKET (NFS_MAXPKTHDR + NFS_MAXDATA)
-#define NFS_MINPACKET 20
-#define NFS_FABLKSIZE 512 /* Size in bytes of a block wrt fa_blocks */
-
-/* Stat numbers for rpc returns (version 2 and 3) */
-#define NFS_OK 0
-#define NFSERR_PERM 1
-#define NFSERR_NOENT 2
-#define NFSERR_IO 5
-#define NFSERR_NXIO 6
-#define NFSERR_ACCES 13
-#define NFSERR_EXIST 17
-#define NFSERR_XDEV 18 /* Version 3 only */
-#define NFSERR_NODEV 19
-#define NFSERR_NOTDIR 20
-#define NFSERR_ISDIR 21
-#define NFSERR_INVAL 22 /* Version 3 only */
-#define NFSERR_FBIG 27
-#define NFSERR_NOSPC 28
-#define NFSERR_ROFS 30
-#define NFSERR_MLINK 31 /* Version 3 only */
-#define NFSERR_NAMETOL 63
-#define NFSERR_NOTEMPTY 66
-#define NFSERR_DQUOT 69
-#define NFSERR_STALE 70
-#define NFSERR_REMOTE 71 /* Version 3 only */
-#define NFSERR_WFLUSH 99 /* Version 2 only */
-#define NFSERR_BADHANDLE 10001 /* The rest Version 3 only */
-#define NFSERR_NOT_SYNC 10002
-#define NFSERR_BAD_COOKIE 10003
-#define NFSERR_NOTSUPP 10004
-#define NFSERR_TOOSMALL 10005
-#define NFSERR_SERVERFAULT 10006
-#define NFSERR_BADTYPE 10007
-#define NFSERR_JUKEBOX 10008
-#define NFSERR_TRYLATER NFSERR_JUKEBOX
-#define NFSERR_STALEWRITEVERF 30001 /* Fake return for nfs_commit() */
-
-#define NFSERR_RETVOID 0x20000000 /* Return void, not error */
-#define NFSERR_AUTHERR 0x40000000 /* Mark an authentication error */
-#define NFSERR_RETERR 0x80000000 /* Mark an error return for V3 */
-
-/* Sizes in bytes of various nfs rpc components */
-#define NFSX_UNSIGNED 4
-
-/* specific to NFS Version 2 */
-#define NFSX_V2FH 32
-#define NFSX_V2FATTR 68
-#define NFSX_V2SATTR 32
-#define NFSX_V2COOKIE 4
-#define NFSX_V2STATFS 20
-
-/* specific to NFS Version 3 */
-#define NFSX_V3FH (sizeof (fhandle_t)) /* size this server uses */
-#define NFSX_V3FHMAX 64 /* max. allowed by protocol */
-#define NFSX_V3FATTR 84
-#define NFSX_V3SATTR 60 /* max. all fields filled in */
-#define NFSX_V3SRVSATTR (sizeof (struct nfsv3_sattr))
-#define NFSX_V3POSTOPATTR (NFSX_V3FATTR + NFSX_UNSIGNED)
-#define NFSX_V3WCCDATA (NFSX_V3POSTOPATTR + 8 * NFSX_UNSIGNED)
-#define NFSX_V3COOKIEVERF 8
-#define NFSX_V3WRITEVERF 8
-#define NFSX_V3CREATEVERF 8
-#define NFSX_V3STATFS 52
-#define NFSX_V3FSINFO 48
-#define NFSX_V3PATHCONF 24
-
-/* variants for both versions */
-#define NFSX_FH(v3) ((v3) ? (NFSX_V3FHMAX + NFSX_UNSIGNED) : \
- NFSX_V2FH)
-#define NFSX_SRVFH(v3) ((v3) ? NFSX_V3FH : NFSX_V2FH)
-#define NFSX_FATTR(v3) ((v3) ? NFSX_V3FATTR : NFSX_V2FATTR)
-#define NFSX_PREOPATTR(v3) ((v3) ? (7 * NFSX_UNSIGNED) : 0)
-#define NFSX_POSTOPATTR(v3) ((v3) ? (NFSX_V3FATTR + NFSX_UNSIGNED) : 0)
-#define NFSX_POSTOPORFATTR(v3) ((v3) ? (NFSX_V3FATTR + NFSX_UNSIGNED) : \
- NFSX_V2FATTR)
-#define NFSX_WCCDATA(v3) ((v3) ? NFSX_V3WCCDATA : 0)
-#define NFSX_WCCORFATTR(v3) ((v3) ? NFSX_V3WCCDATA : NFSX_V2FATTR)
-#define NFSX_SATTR(v3) ((v3) ? NFSX_V3SATTR : NFSX_V2SATTR)
-#define NFSX_COOKIEVERF(v3) ((v3) ? NFSX_V3COOKIEVERF : 0)
-#define NFSX_WRITEVERF(v3) ((v3) ? NFSX_V3WRITEVERF : 0)
-#define NFSX_READDIR(v3) ((v3) ? (5 * NFSX_UNSIGNED) : \
- (2 * NFSX_UNSIGNED))
-#define NFSX_STATFS(v3) ((v3) ? NFSX_V3STATFS : NFSX_V2STATFS)
-
-/* nfs rpc procedure numbers (before version mapping) */
-#define NFSPROC_NULL 0
-#define NFSPROC_GETATTR 1
-#define NFSPROC_SETATTR 2
-#define NFSPROC_LOOKUP 3
-#define NFSPROC_ACCESS 4
-#define NFSPROC_READLINK 5
-#define NFSPROC_READ 6
-#define NFSPROC_WRITE 7
-#define NFSPROC_CREATE 8
-#define NFSPROC_MKDIR 9
-#define NFSPROC_SYMLINK 10
-#define NFSPROC_MKNOD 11
-#define NFSPROC_REMOVE 12
-#define NFSPROC_RMDIR 13
-#define NFSPROC_RENAME 14
-#define NFSPROC_LINK 15
-#define NFSPROC_READDIR 16
-#define NFSPROC_READDIRPLUS 17
-#define NFSPROC_FSSTAT 18
-#define NFSPROC_FSINFO 19
-#define NFSPROC_PATHCONF 20
-#define NFSPROC_COMMIT 21
-
-/* And leasing (nqnfs) procedure numbers (must be last) */
-#define NQNFSPROC_GETLEASE 22
-#define NQNFSPROC_VACATED 23
-#define NQNFSPROC_EVICTED 24
-
-#define NFSPROC_NOOP 25
-#define NFS_NPROCS 26
-
-/* Actual Version 2 procedure numbers */
-#define NFSV2PROC_NULL 0
-#define NFSV2PROC_GETATTR 1
-#define NFSV2PROC_SETATTR 2
-#define NFSV2PROC_NOOP 3
-#define NFSV2PROC_ROOT NFSV2PROC_NOOP /* Obsolete */
-#define NFSV2PROC_LOOKUP 4
-#define NFSV2PROC_READLINK 5
-#define NFSV2PROC_READ 6
-#define NFSV2PROC_WRITECACHE NFSV2PROC_NOOP /* Obsolete */
-#define NFSV2PROC_WRITE 8
-#define NFSV2PROC_CREATE 9
-#define NFSV2PROC_REMOVE 10
-#define NFSV2PROC_RENAME 11
-#define NFSV2PROC_LINK 12
-#define NFSV2PROC_SYMLINK 13
-#define NFSV2PROC_MKDIR 14
-#define NFSV2PROC_RMDIR 15
-#define NFSV2PROC_READDIR 16
-#define NFSV2PROC_STATFS 17
-
-/*
- * Constants used by the Version 3 protocol for various RPCs
- */
-#define NFSV3SATTRTIME_DONTCHANGE 0
-#define NFSV3SATTRTIME_TOSERVER 1
-#define NFSV3SATTRTIME_TOCLIENT 2
-
-#define NFSV3ACCESS_READ 0x01
-#define NFSV3ACCESS_LOOKUP 0x02
-#define NFSV3ACCESS_MODIFY 0x04
-#define NFSV3ACCESS_EXTEND 0x08
-#define NFSV3ACCESS_DELETE 0x10
-#define NFSV3ACCESS_EXECUTE 0x20
-
-#define NFSV3WRITE_UNSTABLE 0
-#define NFSV3WRITE_DATASYNC 1
-#define NFSV3WRITE_FILESYNC 2
-
-#define NFSV3CREATE_UNCHECKED 0
-#define NFSV3CREATE_GUARDED 1
-#define NFSV3CREATE_EXCLUSIVE 2
-
-#define NFSV3FSINFO_LINK 0x01
-#define NFSV3FSINFO_SYMLINK 0x02
-#define NFSV3FSINFO_HOMOGENEOUS 0x08
-#define NFSV3FSINFO_CANSETTIME 0x10
-
-/* Conversion macros */
-#define vtonfsv2_mode(t,m) \
- txdr_unsigned(((t) == VFIFO) ? MAKEIMODE(VCHR, (m)) : \
- MAKEIMODE((t), (m)))
-#define vtonfsv3_mode(m) txdr_unsigned((m) & ALLPERMS)
-#define nfstov_mode(a) (fxdr_unsigned(u_int32_t, (a)) & ALLPERMS)
-#define vtonfsv2_type(a) txdr_unsigned(nfsv2_type[((int32_t)(a))])
-#define vtonfsv3_type(a) txdr_unsigned(nfsv3_type[((int32_t)(a))])
-#define nfsv2tov_type(a) nv2tov_type[fxdr_unsigned(u_int32_t,(a))&0x7]
-#define nfsv3tov_type(a) nv3tov_type[fxdr_unsigned(u_int32_t,(a))&0x7]
-
-/* File types */
-typedef enum { NFNON=0, NFREG=1, NFDIR=2, NFBLK=3, NFCHR=4, NFLNK=5,
- NFSOCK=6, NFFIFO=7 } nfstype;
-
-/* Structs for common parts of the rpc's */
-/*
- * File Handle (32 bytes for version 2), variable up to 64 for version 3.
- * File Handles of up to NFS_SMALLFH in size are stored directly in the
- * nfs node, whereas larger ones are malloc'd. (This never happens when
- * NFS_SMALLFH is set to 64.)
- * NFS_SMALLFH should be in the range of 32 to 64 and be divisible by 4.
- */
-#ifndef NFS_SMALLFH
-#define NFS_SMALLFH 64
-#endif
-union nfsfh {
- fhandle_t fh_generic;
- u_char fh_bytes[NFS_SMALLFH];
-};
-typedef union nfsfh nfsfh_t;
-
-struct nfsv2_time {
- u_int32_t nfsv2_sec;
- u_int32_t nfsv2_usec;
-};
-typedef struct nfsv2_time nfstime2;
-
-struct nfsv3_time {
- u_int32_t nfsv3_sec;
- u_int32_t nfsv3_nsec;
-};
-typedef struct nfsv3_time nfstime3;
-
-/*
- * Quads are defined as arrays of 2 longs to ensure dense packing for the
- * protocol and to facilitate xdr conversion.
- */
-struct nfs_uquad {
- u_int32_t nfsuquad[2];
-};
-typedef struct nfs_uquad nfsuint64;
-
-/*
- * Used to convert between two u_longs and a u_quad_t.
- */
-union nfs_quadconvert {
- u_int32_t lval[2];
- u_quad_t qval;
-};
-typedef union nfs_quadconvert nfsquad_t;
-
-/*
- * NFS Version 3 special file number.
- */
-struct nfsv3_spec {
- u_int32_t specdata1;
- u_int32_t specdata2;
-};
-typedef struct nfsv3_spec nfsv3spec;
-
-/*
- * File attributes and setable attributes. These structures cover both
- * NFS version 2 and the version 3 protocol. Note that the union is only
- * used so that one pointer can refer to both variants. These structures
- * go out on the wire and must be densely packed, so no quad data types
- * are used. (all fields are longs or u_longs or structures of same)
- * NB: You can't do sizeof(struct nfs_fattr), you must use the
- * NFSX_FATTR(v3) macro.
- */
-struct nfs_fattr {
- u_int32_t fa_type;
- u_int32_t fa_mode;
- u_int32_t fa_nlink;
- u_int32_t fa_uid;
- u_int32_t fa_gid;
- union {
- struct {
- u_int32_t nfsv2fa_size;
- u_int32_t nfsv2fa_blocksize;
- u_int32_t nfsv2fa_rdev;
- u_int32_t nfsv2fa_blocks;
- u_int32_t nfsv2fa_fsid;
- u_int32_t nfsv2fa_fileid;
- nfstime2 nfsv2fa_atime;
- nfstime2 nfsv2fa_mtime;
- nfstime2 nfsv2fa_ctime;
- } fa_nfsv2;
- struct {
- nfsuint64 nfsv3fa_size;
- nfsuint64 nfsv3fa_used;
- nfsv3spec nfsv3fa_rdev;
- nfsuint64 nfsv3fa_fsid;
- nfsuint64 nfsv3fa_fileid;
- nfstime3 nfsv3fa_atime;
- nfstime3 nfsv3fa_mtime;
- nfstime3 nfsv3fa_ctime;
- } fa_nfsv3;
- } fa_un;
-};
-
-/* and some ugly defines for accessing union components */
-#define fa2_size fa_un.fa_nfsv2.nfsv2fa_size
-#define fa2_blocksize fa_un.fa_nfsv2.nfsv2fa_blocksize
-#define fa2_rdev fa_un.fa_nfsv2.nfsv2fa_rdev
-#define fa2_blocks fa_un.fa_nfsv2.nfsv2fa_blocks
-#define fa2_fsid fa_un.fa_nfsv2.nfsv2fa_fsid
-#define fa2_fileid fa_un.fa_nfsv2.nfsv2fa_fileid
-#define fa2_atime fa_un.fa_nfsv2.nfsv2fa_atime
-#define fa2_mtime fa_un.fa_nfsv2.nfsv2fa_mtime
-#define fa2_ctime fa_un.fa_nfsv2.nfsv2fa_ctime
-#define fa3_size fa_un.fa_nfsv3.nfsv3fa_size
-#define fa3_used fa_un.fa_nfsv3.nfsv3fa_used
-#define fa3_rdev fa_un.fa_nfsv3.nfsv3fa_rdev
-#define fa3_fsid fa_un.fa_nfsv3.nfsv3fa_fsid
-#define fa3_fileid fa_un.fa_nfsv3.nfsv3fa_fileid
-#define fa3_atime fa_un.fa_nfsv3.nfsv3fa_atime
-#define fa3_mtime fa_un.fa_nfsv3.nfsv3fa_mtime
-#define fa3_ctime fa_un.fa_nfsv3.nfsv3fa_ctime
-
-struct nfsv2_sattr {
- u_int32_t sa_mode;
- u_int32_t sa_uid;
- u_int32_t sa_gid;
- u_int32_t sa_size;
- nfstime2 sa_atime;
- nfstime2 sa_mtime;
-};
-
-/*
- * NFS Version 3 sattr structure for the new node creation case.
- */
-struct nfsv3_sattr {
- u_int32_t sa_modetrue;
- u_int32_t sa_mode;
- u_int32_t sa_uidfalse;
- u_int32_t sa_gidfalse;
- u_int32_t sa_sizefalse;
- u_int32_t sa_atimetype;
- nfstime3 sa_atime;
- u_int32_t sa_mtimetype;
- nfstime3 sa_mtime;
-};
-
-struct nfs_statfs {
- union {
- struct {
- u_int32_t nfsv2sf_tsize;
- u_int32_t nfsv2sf_bsize;
- u_int32_t nfsv2sf_blocks;
- u_int32_t nfsv2sf_bfree;
- u_int32_t nfsv2sf_bavail;
- } sf_nfsv2;
- struct {
- nfsuint64 nfsv3sf_tbytes;
- nfsuint64 nfsv3sf_fbytes;
- nfsuint64 nfsv3sf_abytes;
- nfsuint64 nfsv3sf_tfiles;
- nfsuint64 nfsv3sf_ffiles;
- nfsuint64 nfsv3sf_afiles;
- u_int32_t nfsv3sf_invarsec;
- } sf_nfsv3;
- } sf_un;
-};
-
-#define sf_tsize sf_un.sf_nfsv2.nfsv2sf_tsize
-#define sf_bsize sf_un.sf_nfsv2.nfsv2sf_bsize
-#define sf_blocks sf_un.sf_nfsv2.nfsv2sf_blocks
-#define sf_bfree sf_un.sf_nfsv2.nfsv2sf_bfree
-#define sf_bavail sf_un.sf_nfsv2.nfsv2sf_bavail
-#define sf_tbytes sf_un.sf_nfsv3.nfsv3sf_tbytes
-#define sf_fbytes sf_un.sf_nfsv3.nfsv3sf_fbytes
-#define sf_abytes sf_un.sf_nfsv3.nfsv3sf_abytes
-#define sf_tfiles sf_un.sf_nfsv3.nfsv3sf_tfiles
-#define sf_ffiles sf_un.sf_nfsv3.nfsv3sf_ffiles
-#define sf_afiles sf_un.sf_nfsv3.nfsv3sf_afiles
-#define sf_invarsec sf_un.sf_nfsv3.nfsv3sf_invarsec
-
-struct nfsv3_fsinfo {
- u_int32_t fs_rtmax;
- u_int32_t fs_rtpref;
- u_int32_t fs_rtmult;
- u_int32_t fs_wtmax;
- u_int32_t fs_wtpref;
- u_int32_t fs_wtmult;
- u_int32_t fs_dtpref;
- nfsuint64 fs_maxfilesize;
- nfstime3 fs_timedelta;
- u_int32_t fs_properties;
-};
-
-struct nfsv3_pathconf {
- u_int32_t pc_linkmax;
- u_int32_t pc_namemax;
- u_int32_t pc_notrunc;
- u_int32_t pc_chownrestricted;
- u_int32_t pc_caseinsensitive;
- u_int32_t pc_casepreserving;
-};
-
-#endif
diff --git a/sys/nfsserver/nfsrvcache.h b/sys/nfsserver/nfsrvcache.h
deleted file mode 100644
index eec5850bd381..000000000000
--- a/sys/nfsserver/nfsrvcache.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Rick Macklem at The University of Guelph.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)nfsrvcache.h 8.3 (Berkeley) 3/30/95
- * $FreeBSD$
- */
-
-
-#ifndef _NFS_NFSRVCACHE_H_
-#define _NFS_NFSRVCACHE_H_
-
-#include <sys/queue.h>
-
-/*
- * Definitions for the server recent request cache
- */
-
-#define NFSRVCACHESIZ 64
-
-struct nfsrvcache {
- TAILQ_ENTRY(nfsrvcache) rc_lru; /* LRU chain */
- LIST_ENTRY(nfsrvcache) rc_hash; /* Hash chain */
- u_int32_t rc_xid; /* rpc id number */
- union {
- struct mbuf *ru_repmb; /* Reply mbuf list OR */
- int ru_repstat; /* Reply status */
- } rc_un;
- union nethostaddr rc_haddr; /* Host address */
- u_int32_t rc_proc; /* rpc proc number */
- u_char rc_state; /* Current state of request */
- u_char rc_flag; /* Flag bits */
-};
-
-#define rc_reply rc_un.ru_repmb
-#define rc_status rc_un.ru_repstat
-#define rc_inetaddr rc_haddr.had_inetaddr
-#define rc_nam rc_haddr.had_nam
-
-/* Cache entry states */
-#define RC_UNUSED 0
-#define RC_INPROG 1
-#define RC_DONE 2
-
-/* Return values */
-#define RC_DROPIT 0
-#define RC_REPLY 1
-#define RC_DOIT 2
-#define RC_CHECKIT 3
-
-/* Flag bits */
-#define RC_LOCKED 0x01
-#define RC_WANTED 0x02
-#define RC_REPSTATUS 0x04
-#define RC_REPMBUF 0x08
-#define RC_NQNFS 0x10
-#define RC_INETADDR 0x20
-#define RC_NAM 0x40
-
-#endif
diff --git a/sys/nfsserver/nfsrvstats.h b/sys/nfsserver/nfsrvstats.h
deleted file mode 100644
index e07a4f5315d1..000000000000
--- a/sys/nfsserver/nfsrvstats.h
+++ /dev/null
@@ -1,727 +0,0 @@
-/*
- * Copyright (c) 1989, 1993, 1995
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Rick Macklem at The University of Guelph.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)nfs.h 8.4 (Berkeley) 5/1/95
- * $FreeBSD$
- */
-
-#ifndef _NFS_NFS_H_
-#define _NFS_NFS_H_
-
-#ifdef _KERNEL
-#include "opt_nfs.h"
-#endif
-
-/*
- * Tunable constants for nfs
- */
-
-#define NFS_MAXIOVEC 34
-#define NFS_TICKINTVL 5 /* Desired time for a tick (msec) */
-#define NFS_HZ (hz / nfs_ticks) /* Ticks/sec */
-#define NFS_TIMEO (1 * NFS_HZ) /* Default timeout = 1 second */
-#define NFS_MINTIMEO (1 * NFS_HZ) /* Min timeout to use */
-#define NFS_MAXTIMEO (60 * NFS_HZ) /* Max timeout to backoff to */
-#define NFS_MINIDEMTIMEO (5 * NFS_HZ) /* Min timeout for non-idempotent ops*/
-#define NFS_MAXREXMIT 100 /* Stop counting after this many */
-#define NFS_MAXWINDOW 1024 /* Max number of outstanding requests */
-#define NFS_RETRANS 10 /* Num of retrans for soft mounts */
-#define NFS_MAXGRPS 16 /* Max. size of groups list */
-#ifndef NFS_MINATTRTIMO
-#define NFS_MINATTRTIMO 3 /* VREG attrib cache timeout in sec */
-#endif
-#ifndef NFS_MAXATTRTIMO
-#define NFS_MAXATTRTIMO 60
-#endif
-#ifndef NFS_MINDIRATTRTIMO
-#define NFS_MINDIRATTRTIMO 30 /* VDIR attrib cache timeout in sec */
-#endif
-#ifndef NFS_MAXDIRATTRTIMO
-#define NFS_MAXDIRATTRTIMO 60
-#endif
-#define NFS_WSIZE 8192 /* Def. write data size <= 8192 */
-#define NFS_RSIZE 8192 /* Def. read data size <= 8192 */
-#define NFS_READDIRSIZE 8192 /* Def. readdir size */
-#define NFS_DEFRAHEAD 1 /* Def. read ahead # blocks */
-#define NFS_MAXRAHEAD 4 /* Max. read ahead # blocks */
-#define NFS_MAXUIDHASH 64 /* Max. # of hashed uid entries/mp */
-#define NFS_MAXASYNCDAEMON 20 /* Max. number async_daemons runnable */
-#define NFS_MAXGATHERDELAY 100 /* Max. write gather delay (msec) */
-#ifndef NFS_GATHERDELAY
-#define NFS_GATHERDELAY 10 /* Default write gather delay (msec) */
-#endif
-#define NFS_DIRBLKSIZ 4096 /* Must be a multiple of DIRBLKSIZ */
-#ifdef _KERNEL
-#define DIRBLKSIZ 512 /* XXX we used to use ufs's DIRBLKSIZ */
-#endif
-
-/*
- * Oddballs
- */
-#define NMOD(a) ((a) % nfs_asyncdaemons)
-#define NFS_CMPFH(n, f, s) \
- ((n)->n_fhsize == (s) && !bcmp((caddr_t)(n)->n_fhp, (caddr_t)(f), (s)))
-#define NFS_ISV3(v) (VFSTONFS((v)->v_mount)->nm_flag & NFSMNT_NFSV3)
-#define NFS_SRVMAXDATA(n) \
- (((n)->nd_flag & ND_NFSV3) ? (((n)->nd_nam2) ? \
- NFS_MAXDGRAMDATA : NFS_MAXDATA) : NFS_V2MAXDATA)
-
-/*
- * XXX
- * The B_INVAFTERWRITE flag should be set to whatever is required by the
- * buffer cache code to say "Invalidate the block after it is written back".
- */
-#define B_INVAFTERWRITE B_NOCACHE
-
-/*
- * The IO_METASYNC flag should be implemented for local file systems.
- * (Until then, it is nothin at all.)
- */
-#ifndef IO_METASYNC
-#define IO_METASYNC 0
-#endif
-
-/*
- * Arguments to mount NFS
- */
-#define NFS_ARGSVERSION 3 /* change when nfs_args changes */
-struct nfs_args {
- int version; /* args structure version number */
- struct sockaddr *addr; /* file server address */
- int addrlen; /* length of address */
- int sotype; /* Socket type */
- int proto; /* and Protocol */
- u_char *fh; /* File handle to be mounted */
- int fhsize; /* Size, in bytes, of fh */
- int flags; /* flags */
- int wsize; /* write size in bytes */
- int rsize; /* read size in bytes */
- int readdirsize; /* readdir size in bytes */
- int timeo; /* initial timeout in .1 secs */
- int retrans; /* times to retry send */
- int maxgrouplist; /* Max. size of group list */
- int readahead; /* # of blocks to readahead */
- int leaseterm; /* Term (sec) of lease */
- int deadthresh; /* Retrans threshold */
- char *hostname; /* server's name */
- int acregmin; /* cache attrs for reg files min time */
- int acregmax; /* cache attrs for reg files max time */
- int acdirmin; /* cache attrs for dirs min time */
- int acdirmax; /* cache attrs for dirs max time */
-};
-
-/*
- * NFS mount option flags
- */
-#define NFSMNT_SOFT 0x00000001 /* soft mount (hard is default) */
-#define NFSMNT_WSIZE 0x00000002 /* set write size */
-#define NFSMNT_RSIZE 0x00000004 /* set read size */
-#define NFSMNT_TIMEO 0x00000008 /* set initial timeout */
-#define NFSMNT_RETRANS 0x00000010 /* set number of request retries */
-#define NFSMNT_MAXGRPS 0x00000020 /* set maximum grouplist size */
-#define NFSMNT_INT 0x00000040 /* allow interrupts on hard mount */
-#define NFSMNT_NOCONN 0x00000080 /* Don't Connect the socket */
-#define NFSMNT_NQNFS 0x00000100 /* Use Nqnfs protocol */
-#define NFSMNT_NFSV3 0x00000200 /* Use NFS Version 3 protocol */
-#define NFSMNT_KERB 0x00000400 /* Use Kerberos authentication */
-#define NFSMNT_DUMBTIMR 0x00000800 /* Don't estimate rtt dynamically */
-#define NFSMNT_LEASETERM 0x00001000 /* set lease term (nqnfs) */
-#define NFSMNT_READAHEAD 0x00002000 /* set read ahead */
-#define NFSMNT_DEADTHRESH 0x00004000 /* set dead server retry thresh */
-#define NFSMNT_RESVPORT 0x00008000 /* Allocate a reserved port */
-#define NFSMNT_RDIRPLUS 0x00010000 /* Use Readdirplus for V3 */
-#define NFSMNT_READDIRSIZE 0x00020000 /* Set readdir size */
-#define NFSMNT_ACREGMIN 0x00040000
-#define NFSMNT_ACREGMAX 0x00080000
-#define NFSMNT_ACDIRMIN 0x00100000
-#define NFSMNT_ACDIRMAX 0x00200000
-
-#define NFSSTA_HASWRITEVERF 0x00040000 /* Has write verifier for V3 */
-#define NFSSTA_GOTPATHCONF 0x00080000 /* Got the V3 pathconf info */
-#define NFSSTA_GOTFSINFO 0x00100000 /* Got the V3 fsinfo */
-#define NFSSTA_MNTD 0x00200000 /* Mnt server for mnt point */
-#define NFSSTA_DISMINPROG 0x00400000 /* Dismount in progress */
-#define NFSSTA_DISMNT 0x00800000 /* Dismounted */
-#define NFSSTA_SNDLOCK 0x01000000 /* Send socket lock */
-#define NFSSTA_WANTSND 0x02000000 /* Want above */
-#define NFSSTA_RCVLOCK 0x04000000 /* Rcv socket lock */
-#define NFSSTA_WANTRCV 0x08000000 /* Want above */
-#define NFSSTA_WAITAUTH 0x10000000 /* Wait for authentication */
-#define NFSSTA_HASAUTH 0x20000000 /* Has authenticator */
-#define NFSSTA_WANTAUTH 0x40000000 /* Wants an authenticator */
-#define NFSSTA_AUTHERR 0x80000000 /* Authentication error */
-
-/*
- * Structures for the nfssvc(2) syscall. Not that anyone but nfsd and mount_nfs
- * should ever try and use it.
- */
-struct nfsd_args {
- int sock; /* Socket to serve */
- caddr_t name; /* Client addr for connection based sockets */
- int namelen; /* Length of name */
-};
-
-struct nfsd_srvargs {
- struct nfsd *nsd_nfsd; /* Pointer to in kernel nfsd struct */
- uid_t nsd_uid; /* Effective uid mapped to cred */
- u_int32_t nsd_haddr; /* Ip address of client */
- struct ucred nsd_cr; /* Cred. uid maps to */
- int nsd_authlen; /* Length of auth string (ret) */
- u_char *nsd_authstr; /* Auth string (ret) */
- int nsd_verflen; /* and the verfier */
- u_char *nsd_verfstr;
- struct timeval nsd_timestamp; /* timestamp from verifier */
- u_int32_t nsd_ttl; /* credential ttl (sec) */
- NFSKERBKEY_T nsd_key; /* Session key */
-};
-
-struct nfsd_cargs {
- char *ncd_dirp; /* Mount dir path */
- uid_t ncd_authuid; /* Effective uid */
- int ncd_authtype; /* Type of authenticator */
- int ncd_authlen; /* Length of authenticator string */
- u_char *ncd_authstr; /* Authenticator string */
- int ncd_verflen; /* and the verifier */
- u_char *ncd_verfstr;
- NFSKERBKEY_T ncd_key; /* Session key */
-};
-
-/*
- * XXX to allow amd to include nfs.h without nfsproto.h
- */
-#ifdef NFS_NPROCS
-/*
- * Stats structure
- */
-struct nfsstats {
- int attrcache_hits;
- int attrcache_misses;
- int lookupcache_hits;
- int lookupcache_misses;
- int direofcache_hits;
- int direofcache_misses;
- int biocache_reads;
- int read_bios;
- int read_physios;
- int biocache_writes;
- int write_bios;
- int write_physios;
- int biocache_readlinks;
- int readlink_bios;
- int biocache_readdirs;
- int readdir_bios;
- int rpccnt[NFS_NPROCS];
- int rpcretries;
- int srvrpccnt[NFS_NPROCS];
- int srvrpc_errs;
- int srv_errs;
- int rpcrequests;
- int rpctimeouts;
- int rpcunexpected;
- int rpcinvalid;
- int srvcache_inproghits;
- int srvcache_idemdonehits;
- int srvcache_nonidemdonehits;
- int srvcache_misses;
- int srvnqnfs_leases;
- int srvnqnfs_maxleases;
- int srvnqnfs_getleases;
- int srvvop_writes;
- int accesscache_hits;
- int accesscache_misses;
-};
-#endif
-
-/*
- * Flags for nfssvc() system call.
- */
-#define NFSSVC_BIOD 0x002
-#define NFSSVC_NFSD 0x004
-#define NFSSVC_ADDSOCK 0x008
-#define NFSSVC_AUTHIN 0x010
-#define NFSSVC_GOTAUTH 0x040
-#define NFSSVC_AUTHINFAIL 0x080
-#define NFSSVC_MNTD 0x100
-
-/*
- * fs.nfs sysctl(3) identifiers
- */
-#define NFS_NFSSTATS 1 /* struct: struct nfsstats */
-#define NFS_NFSPRIVPORT 2 /* int: prohibit nfs to resvports */
-
-#define FS_NFS_NAMES { \
- { 0, 0 }, \
- { "nfsstats", CTLTYPE_STRUCT }, \
- { "nfsprivport", CTLTYPE_INT }, \
-}
-
-#ifdef _KERNEL
-
-#ifdef MALLOC_DECLARE
-MALLOC_DECLARE(M_NFSREQ);
-MALLOC_DECLARE(M_NFSDIROFF);
-MALLOC_DECLARE(M_NFSRVDESC);
-MALLOC_DECLARE(M_NFSUID);
-MALLOC_DECLARE(M_NQLEASE);
-MALLOC_DECLARE(M_NFSD);
-MALLOC_DECLARE(M_NFSBIGFH);
-MALLOC_DECLARE(M_NFSHASH);
-#endif
-
-#ifdef ZONE_INTERRUPT
-extern vm_zone_t nfsmount_zone;
-#endif
-
-extern struct callout_handle nfs_timer_handle;
-
-struct uio; struct buf; struct vattr; struct nameidata; /* XXX */
-
-/*
- * The set of signals the interrupt an I/O in progress for NFSMNT_INT mounts.
- * What should be in this set is open to debate, but I believe that since
- * I/O system calls on ufs are never interrupted by signals the set should
- * be minimal. My reasoning is that many current programs that use signals
- * such as SIGALRM will not expect file I/O system calls to be interrupted
- * by them and break.
- */
-#define NFSINT_SIGMASK(set) \
- (SIGISMEMBER(set, SIGINT) || SIGISMEMBER(set, SIGTERM) || \
- SIGISMEMBER(set, SIGHUP) || SIGISMEMBER(set, SIGKILL) || \
- SIGISMEMBER(set, SIGQUIT))
-
-/*
- * Socket errors ignored for connectionless sockets??
- * For now, ignore them all
- */
-#define NFSIGNORE_SOERROR(s, e) \
- ((e) != EINTR && (e) != ERESTART && (e) != EWOULDBLOCK && \
- ((s) & PR_CONNREQUIRED) == 0)
-
-/*
- * Nfs outstanding request list element
- */
-struct nfsreq {
- TAILQ_ENTRY(nfsreq) r_chain;
- struct mbuf *r_mreq;
- struct mbuf *r_mrep;
- struct mbuf *r_md;
- caddr_t r_dpos;
- struct nfsmount *r_nmp;
- struct vnode *r_vp;
- u_int32_t r_xid;
- int r_flags; /* flags on request, see below */
- int r_retry; /* max retransmission count */
- int r_rexmit; /* current retrans count */
- int r_timer; /* tick counter on reply */
- u_int32_t r_procnum; /* NFS procedure number */
- int r_rtt; /* RTT for rpc */
- struct proc *r_procp; /* Proc that did I/O system call */
-};
-
-/*
- * Queue head for nfsreq's
- */
-extern TAILQ_HEAD(nfs_reqq, nfsreq) nfs_reqq;
-
-/* Flag values for r_flags */
-#define R_TIMING 0x01 /* timing request (in mntp) */
-#define R_SENT 0x02 /* request has been sent */
-#define R_SOFTTERM 0x04 /* soft mnt, too many retries */
-#define R_INTR 0x08 /* intr mnt, signal pending */
-#define R_SOCKERR 0x10 /* Fatal error on socket */
-#define R_TPRINTFMSG 0x20 /* Did a tprintf msg. */
-#define R_MUSTRESEND 0x40 /* Must resend request */
-#define R_GETONEREP 0x80 /* Probe for one reply only */
-
-/*
- * A list of nfssvc_sock structures is maintained with all the sockets
- * that require service by the nfsd.
- * The nfsuid structs hang off of the nfssvc_sock structs in both lru
- * and uid hash lists.
- */
-#ifndef NFS_UIDHASHSIZ
-#define NFS_UIDHASHSIZ 29 /* Tune the size of nfssvc_sock with this */
-#endif
-#define NUIDHASH(sock, uid) \
- (&(sock)->ns_uidhashtbl[(uid) % NFS_UIDHASHSIZ])
-#ifndef NFS_WDELAYHASHSIZ
-#define NFS_WDELAYHASHSIZ 16 /* and with this */
-#endif
-#define NWDELAYHASH(sock, f) \
- (&(sock)->ns_wdelayhashtbl[(*((u_int32_t *)(f))) % NFS_WDELAYHASHSIZ])
-#ifndef NFS_MUIDHASHSIZ
-#define NFS_MUIDHASHSIZ 63 /* Tune the size of nfsmount with this */
-#endif
-#define NMUIDHASH(nmp, uid) \
- (&(nmp)->nm_uidhashtbl[(uid) % NFS_MUIDHASHSIZ])
-#define NFSNOHASH(fhsum) \
- (&nfsnodehashtbl[(fhsum) & nfsnodehash])
-
-/*
- * Network address hash list element
- */
-union nethostaddr {
- u_int32_t had_inetaddr;
- struct sockaddr *had_nam;
-};
-
-struct nfsuid {
- TAILQ_ENTRY(nfsuid) nu_lru; /* LRU chain */
- LIST_ENTRY(nfsuid) nu_hash; /* Hash list */
- int nu_flag; /* Flags */
- union nethostaddr nu_haddr; /* Host addr. for dgram sockets */
- struct ucred nu_cr; /* Cred uid mapped to */
- int nu_expire; /* Expiry time (sec) */
- struct timeval nu_timestamp; /* Kerb. timestamp */
- u_int32_t nu_nickname; /* Nickname on server */
- NFSKERBKEY_T nu_key; /* and session key */
-};
-
-#define nu_inetaddr nu_haddr.had_inetaddr
-#define nu_nam nu_haddr.had_nam
-/* Bits for nu_flag */
-#define NU_INETADDR 0x1
-#define NU_NAM 0x2
-#define NU_NETFAM(u) (((u)->nu_flag & NU_INETADDR) ? AF_INET : AF_ISO)
-
-struct nfsrv_rec {
- STAILQ_ENTRY(nfsrv_rec) nr_link;
- struct sockaddr *nr_address;
- struct mbuf *nr_packet;
-};
-
-struct nfssvc_sock {
- TAILQ_ENTRY(nfssvc_sock) ns_chain; /* List of all nfssvc_sock's */
- TAILQ_HEAD(, nfsuid) ns_uidlruhead;
- struct file *ns_fp;
- struct socket *ns_so;
- struct sockaddr *ns_nam;
- struct mbuf *ns_raw;
- struct mbuf *ns_rawend;
- STAILQ_HEAD(, nfsrv_rec) ns_rec;
- struct mbuf *ns_frag;
- int ns_flag;
- int ns_solock;
- int ns_cc;
- int ns_reclen;
- int ns_numuids;
- u_int32_t ns_sref;
- LIST_HEAD(, nfsrv_descript) ns_tq; /* Write gather lists */
- LIST_HEAD(, nfsuid) ns_uidhashtbl[NFS_UIDHASHSIZ];
- LIST_HEAD(nfsrvw_delayhash, nfsrv_descript) ns_wdelayhashtbl[NFS_WDELAYHASHSIZ];
-};
-
-/* Bits for "ns_flag" */
-#define SLP_VALID 0x01
-#define SLP_DOREC 0x02
-#define SLP_NEEDQ 0x04
-#define SLP_DISCONN 0x08
-#define SLP_GETSTREAM 0x10
-#define SLP_LASTFRAG 0x20
-#define SLP_ALLFLAGS 0xff
-
-extern TAILQ_HEAD(nfssvc_sockhead, nfssvc_sock) nfssvc_sockhead;
-extern int nfssvc_sockhead_flag;
-#define SLP_INIT 0x01
-#define SLP_WANTINIT 0x02
-
-/*
- * One of these structures is allocated for each nfsd.
- */
-struct nfsd {
- TAILQ_ENTRY(nfsd) nfsd_chain; /* List of all nfsd's */
- int nfsd_flag; /* NFSD_ flags */
- struct nfssvc_sock *nfsd_slp; /* Current socket */
- int nfsd_authlen; /* Authenticator len */
- u_char nfsd_authstr[RPCAUTH_MAXSIZ]; /* Authenticator data */
- int nfsd_verflen; /* and the Verifier */
- u_char nfsd_verfstr[RPCVERF_MAXSIZ];
- struct proc *nfsd_procp; /* Proc ptr */
- struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */
-};
-
-/* Bits for "nfsd_flag" */
-#define NFSD_WAITING 0x01
-#define NFSD_REQINPROG 0x02
-#define NFSD_NEEDAUTH 0x04
-#define NFSD_AUTHFAIL 0x08
-
-/*
- * This structure is used by the server for describing each request.
- * Some fields are used only when write request gathering is performed.
- */
-struct nfsrv_descript {
- u_quad_t nd_time; /* Write deadline (usec) */
- off_t nd_off; /* Start byte offset */
- off_t nd_eoff; /* and end byte offset */
- LIST_ENTRY(nfsrv_descript) nd_hash; /* Hash list */
- LIST_ENTRY(nfsrv_descript) nd_tq; /* and timer list */
- LIST_HEAD(,nfsrv_descript) nd_coalesce; /* coalesced writes */
- struct mbuf *nd_mrep; /* Request mbuf list */
- struct mbuf *nd_md; /* Current dissect mbuf */
- struct mbuf *nd_mreq; /* Reply mbuf list */
- struct sockaddr *nd_nam; /* and socket addr */
- struct sockaddr *nd_nam2; /* return socket addr */
- caddr_t nd_dpos; /* Current dissect pos */
- u_int32_t nd_procnum; /* RPC # */
- int nd_stable; /* storage type */
- int nd_flag; /* nd_flag */
- int nd_len; /* Length of this write */
- int nd_repstat; /* Reply status */
- u_int32_t nd_retxid; /* Reply xid */
- u_int32_t nd_duration; /* Lease duration */
- struct timeval nd_starttime; /* Time RPC initiated */
- fhandle_t nd_fh; /* File handle */
- struct ucred nd_cr; /* Credentials */
-};
-
-/* Bits for "nd_flag" */
-#define ND_READ LEASE_READ
-#define ND_WRITE LEASE_WRITE
-#define ND_CHECK 0x04
-#define ND_LEASE (ND_READ | ND_WRITE | ND_CHECK)
-#define ND_NFSV3 0x08
-#define ND_NQNFS 0x10
-#define ND_KERBNICK 0x20
-#define ND_KERBFULL 0x40
-#define ND_KERBAUTH (ND_KERBNICK | ND_KERBFULL)
-
-extern TAILQ_HEAD(nfsd_head, nfsd) nfsd_head;
-extern int nfsd_head_flag;
-#define NFSD_CHECKSLP 0x01
-
-/*
- * These macros compare nfsrv_descript structures.
- */
-#define NFSW_CONTIG(o, n) \
- ((o)->nd_eoff >= (n)->nd_off && \
- !bcmp((caddr_t)&(o)->nd_fh, (caddr_t)&(n)->nd_fh, NFSX_V3FH))
-
-#define NFSW_SAMECRED(o, n) \
- (((o)->nd_flag & ND_KERBAUTH) == ((n)->nd_flag & ND_KERBAUTH) && \
- !bcmp((caddr_t)&(o)->nd_cr, (caddr_t)&(n)->nd_cr, \
- sizeof (struct ucred)))
-
-/*
- * Defines for WebNFS
- */
-
-#define WEBNFS_ESC_CHAR '%'
-#define WEBNFS_SPECCHAR_START 0x80
-
-#define WEBNFS_NATIVE_CHAR 0x80
-/*
- * ..
- * Possibly more here in the future.
- */
-
-/*
- * Macro for converting escape characters in WebNFS pathnames.
- * Should really be in libkern.
- */
-
-#define HEXTOC(c) \
- ((c) >= 'a' ? ((c) - ('a' - 10)) : \
- ((c) >= 'A' ? ((c) - ('A' - 10)) : ((c) - '0')))
-#define HEXSTRTOI(p) \
- ((HEXTOC(p[0]) << 4) + HEXTOC(p[1]))
-
-#ifdef NFS_DEBUG
-
-extern int nfs_debug;
-#define NFS_DEBUG_ASYNCIO 1 /* asynchronous i/o */
-#define NFS_DEBUG_WG 2 /* server write gathering */
-#define NFS_DEBUG_RC 4 /* server request caching */
-
-#define NFS_DPF(cat, args) \
- do { \
- if (nfs_debug & NFS_DEBUG_##cat) printf args; \
- } while (0)
-
-#else
-
-#define NFS_DPF(cat, args)
-
-#endif
-
-u_quad_t nfs_curusec __P((void));
-int nfs_init __P((struct vfsconf *vfsp));
-int nfs_uninit __P((struct vfsconf *vfsp));
-int nfs_reply __P((struct nfsreq *));
-int nfs_getreq __P((struct nfsrv_descript *,struct nfsd *,int));
-int nfs_send __P((struct socket *, struct sockaddr *, struct mbuf *,
- struct nfsreq *));
-int nfs_rephead __P((int, struct nfsrv_descript *, struct nfssvc_sock *,
- int, int, u_quad_t *, struct mbuf **, struct mbuf **,
- caddr_t *));
-int nfs_sndlock __P((struct nfsreq *));
-void nfs_sndunlock __P((struct nfsreq *));
-int nfs_slplock __P((struct nfssvc_sock *, int));
-void nfs_slpunlock __P((struct nfssvc_sock *));
-int nfs_disct __P((struct mbuf **, caddr_t *, int, int, caddr_t *));
-int nfs_vinvalbuf __P((struct vnode *, int, struct ucred *, struct proc *,
- int));
-int nfs_readrpc __P((struct vnode *, struct uio *, struct ucred *));
-int nfs_writerpc __P((struct vnode *, struct uio *, struct ucred *, int *,
- int *));
-int nfs_commit __P((struct vnode *vp, u_quad_t offset, int cnt,
- struct ucred *cred, struct proc *procp));
-int nfs_readdirrpc __P((struct vnode *, struct uio *, struct ucred *));
-int nfs_asyncio __P((struct buf *, struct ucred *, struct proc *));
-int nfs_doio __P((struct buf *, struct ucred *, struct proc *));
-int nfs_readlinkrpc __P((struct vnode *, struct uio *, struct ucred *));
-int nfs_sigintr __P((struct nfsmount *, struct nfsreq *, struct proc *));
-int nfs_readdirplusrpc __P((struct vnode *, struct uio *, struct ucred *));
-int nfsm_disct __P((struct mbuf **, caddr_t *, int, int, caddr_t *));
-void nfsm_srvfattr __P((struct nfsrv_descript *, struct vattr *,
- struct nfs_fattr *));
-void nfsm_srvwcc __P((struct nfsrv_descript *, int, struct vattr *, int,
- struct vattr *, struct mbuf **, char **));
-void nfsm_srvpostopattr __P((struct nfsrv_descript *, int, struct vattr *,
- struct mbuf **, char **));
-int netaddr_match __P((int, union nethostaddr *, struct sockaddr *));
-int nfs_request __P((struct vnode *, struct mbuf *, int, struct proc *,
- struct ucred *, struct mbuf **, struct mbuf **,
- caddr_t *));
-int nfs_loadattrcache __P((struct vnode **, struct mbuf **, caddr_t *,
- struct vattr *));
-int nfs_namei __P((struct nameidata *, fhandle_t *, int,
- struct nfssvc_sock *, struct sockaddr *, struct mbuf **,
- caddr_t *, struct vnode **, struct proc *, int, int));
-void nfsm_adj __P((struct mbuf *, int, int));
-int nfsm_mbuftouio __P((struct mbuf **, struct uio *, int, caddr_t *));
-void nfsrv_initcache __P((void));
-int nfs_getauth __P((struct nfsmount *, struct nfsreq *, struct ucred *,
- char **, int *, char *, int *, NFSKERBKEY_T));
-int nfs_getnickauth __P((struct nfsmount *, struct ucred *, char **,
- int *, char *, int));
-int nfs_savenickauth __P((struct nfsmount *, struct ucred *, int,
- NFSKERBKEY_T, struct mbuf **, char **,
- struct mbuf *));
-int nfs_adv __P((struct mbuf **, caddr_t *, int, int));
-void nfs_nhinit __P((void));
-void nfs_timer __P((void*));
-u_long nfs_hash __P((nfsfh_t *, int));
-int nfsrv_dorec __P((struct nfssvc_sock *, struct nfsd *,
- struct nfsrv_descript **));
-int nfsrv_getcache __P((struct nfsrv_descript *, struct nfssvc_sock *,
- struct mbuf **));
-void nfsrv_updatecache __P((struct nfsrv_descript *, int, struct mbuf *));
-void nfsrv_cleancache __P((void));
-int nfs_connect __P((struct nfsmount *, struct nfsreq *));
-void nfs_disconnect __P((struct nfsmount *));
-void nfs_safedisconnect __P((struct nfsmount *));
-int nfs_getattrcache __P((struct vnode *, struct vattr *));
-int nfsm_strtmbuf __P((struct mbuf **, char **, const char *, long));
-int nfs_bioread __P((struct vnode *, struct uio *, int, struct ucred *));
-int nfsm_uiotombuf __P((struct uio *, struct mbuf **, int, caddr_t *));
-void nfsrv_init __P((int));
-void nfs_clearcommit __P((struct mount *));
-int nfsrv_errmap __P((struct nfsrv_descript *, int));
-void nfsrvw_sort __P((gid_t *, int));
-void nfsrv_setcred __P((struct ucred *, struct ucred *));
-int nfs_writebp __P((struct buf *, int, struct proc *));
-int nfsrv_object_create __P((struct vnode *));
-void nfsrv_wakenfsd __P((struct nfssvc_sock *slp));
-int nfsrv_writegather __P((struct nfsrv_descript **, struct nfssvc_sock *,
- struct proc *, struct mbuf **));
-int nfs_fsinfo __P((struct nfsmount *, struct vnode *, struct ucred *,
- struct proc *p));
-
-int nfsrv3_access __P((struct nfsrv_descript *nfsd,
- struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_commit __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_create __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_fhtovp __P((fhandle_t *, int, struct vnode **, struct ucred *,
- struct nfssvc_sock *, struct sockaddr *, int *,
- int, int));
-int nfsrv_setpublicfs __P((struct mount *, struct netexport *,
- struct export_args *));
-int nfs_ispublicfh __P((fhandle_t *));
-int nfsrv_fsinfo __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_getattr __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_link __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_lookup __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_mkdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_mknod __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_noop __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_null __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_pathconf __P((struct nfsrv_descript *nfsd,
- struct nfssvc_sock *slp, struct proc *procp,
- struct mbuf **mrq));
-int nfsrv_read __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_readdir __P((struct nfsrv_descript *nfsd,
- struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_readdirplus __P((struct nfsrv_descript *nfsd,
- struct nfssvc_sock *slp, struct proc *procp,
- struct mbuf **mrq));
-int nfsrv_readlink __P((struct nfsrv_descript *nfsd,
- struct nfssvc_sock *slp, struct proc *procp,
- struct mbuf **mrq));
-int nfsrv_remove __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_rename __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_rmdir __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_setattr __P((struct nfsrv_descript *nfsd,
- struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_statfs __P((struct nfsrv_descript *nfsd,
- struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_symlink __P((struct nfsrv_descript *nfsd,
- struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-int nfsrv_write __P((struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
- struct proc *procp, struct mbuf **mrq));
-void nfsrv_rcv __P((struct socket *so, void *arg, int waitflag));
-void nfsrv_slpderef __P((struct nfssvc_sock *slp));
-#endif /* _KERNEL */
-
-#endif
diff --git a/sys/pc98/cbus/30line.h b/sys/pc98/cbus/30line.h
deleted file mode 100644
index a6b7b7cc61e8..000000000000
--- a/sys/pc98/cbus/30line.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (c) 1994, 1995, 1996. FreeBSD(98) porting team.
- * 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 as
- * the first lines of this file unmodified.
- * 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.
- */
-
-#ifndef __PC98_PC98_30LINE_H__
-#define __PC98_PC98_30LINE_H__
-
-#include <pc98/pc98/module.h>
-
-#ifndef LINE30_ROW
-#define LINE30_ROW 30
-#endif
-
-#define _CR 80
-#ifndef _VS
-#define _VS 7
-#endif
-#ifndef _HS
-#define _HS 6 + 1
-#endif
-#ifndef _HFP
-#define _HFP 10 + 1
-#endif
-#ifndef _HBP
-#define _HBP 7 + 1
-#endif
-#ifndef _VFP
-#define _VFP 7
-#endif
-#ifndef _VBP
-#define _VBP 25
-#endif
-
-#define _LF LINE30_ROW*16
-
-#define _GDC_RESET 0x00
-#define _GDC_SYNC 0x0e
-#define _GDC_MASTER 0x6f
-#define _GDC_SLAVE 0x6e
-#define _GDC_START 0x0d
-#define _GDC_STOP 0x0c
-#define _GDC_SCROLL 0x70
-#define _GDC_PITCH 0x47
-
-#define GDC_CR 0
-#define GDC_VS 1
-#define GDC_HS 2
-#define GDC_HFP 3
-#define GDC_HBP 4
-#define GDC_VFP 5
-#define GDC_VBP 6
-#define GDC_LF 7
-
-
-#define _2_5MHZ 0
-#define _5MHZ 1
-
-#define _25L 0
-#define _30L 1
-
-#define T25_G400 0
-#define T30_G400 1
-#define T30_G480 2
-
-static void master_gdc_cmd(unsigned int);
-static void master_gdc_prm(unsigned int);
-static void master_gdc_word_prm(unsigned int);
-static void master_gdc_fifo_empty(void);
-static void master_gdc_wait_vsync(void);
-
-static void gdc_cmd(unsigned int);
-static void gdc_prm(unsigned int);
-static void gdc_word_prm(unsigned int);
-static void gdc_fifo_empty(void);
-static void gdc_wait_vsync(void);
-
-static int check_gdc_clock(void);
-
-static int gdc_INFO = _25L;
-static void initialize_gdc(unsigned int);
-
-static unsigned int master_param[2][8] = {
-{78, 8, 7, 9, 7, 7, 25, 400},
-{_CR-2, _VS, _HS-1, _HFP-1, _HBP-1, _VFP, _VBP, _LF}};
-
-static unsigned int slave_param[6][8] = {
-{38, 8, 3, 4, 3, 7, 25, 400}, /* normal */
-{78, 8, 7, 9, 7, 7, 25, 400},
-{_CR/2-2, _VS, (_HS)/2-1, (_HFP)/2-1, (_HBP)/2-1,
-_VFP+(_LF-400)/2+8, _VBP+(_LF-400)/2-8, 400}, /* 30 & 400 */
-{_CR-2, _VS, _HS-1, _HFP-1, _HBP-1,
-_VFP+(_LF-400)/2+8, _VBP+(_LF-400)/2-8, 400},
-{_CR/2-2, _VS, (_HS)/2-1, (_HFP)/2-1, (_HBP)/2-1,
-_VFP, _VBP, _LF}, /* 30 & 480 */
-{_CR-2, _VS, _HS-1, _HFP-1, _HBP-1, _VFP, _VBP, _LF}};
-
-static int SlavePCH[2] = {40,80};
-static int MasterPCH = 80;
-static int SlaveScrlLF[3] = {400,400,_LF};
-
-#endif
diff --git a/sys/pc98/cbus/cbus.h b/sys/pc98/cbus/cbus.h
deleted file mode 100644
index e148441fb84e..000000000000
--- a/sys/pc98/cbus/cbus.h
+++ /dev/null
@@ -1,183 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)isa.h 5.7 (Berkeley) 5/9/91
- * $FreeBSD$
- */
-
-#ifndef _PC98_PC98_PC98_H_
-#define _PC98_PC98_PC98_H_
-
-/* BEWARE: Included in both assembler and C code */
-
-/*
- * PC98 Bus conventions
- * modified for PC9801 by A.Kojima F.Ukai M.Ishii
- * Kyoto University Microcomputer Club (KMC)
- */
-
-/*
- * Input / Output Port Assignments
- */
-#ifndef IO_ISABEGIN
-#define IO_ISABEGIN 0x000 /* 0x000 - Beginning of I/O Registers */
-
-/* PC98 IO address ... very dirty (^_^; */
-
-#define IO_ICU1 0x000 /* 8259A Interrupt Controller #1 */
-#define IO_DMA 0x001 /* 8237A DMA Controller */
-#define IO_ICU2 0x008 /* 8259A Interrupt Controller #2 */
-#define IO_RTC 0x020 /* 4990A RTC */
-#define IO_DMAPG 0x021 /* DMA Page Registers */
-#define IO_COM1 0x030 /* 8251A RS232C serial I/O (int) */
-#define IO_SYSPORT 0x031 /* 8255A System Port */
-#define IO_PPI 0x035 /* Programmable Peripheral Interface */
-#define IO_LPT 0x040 /* 8255A Printer Port */
-#define IO_KBD 0x041 /* 8251A Keyboard */
-#define IO_NMI 0x050 /* NMI Control */
-#define IO_WAIT 0x05F /* WAIT 0.6 us */
-#define IO_GDC1 0x060 /* 7220 GDC Text Control */
-#define IO_TIMER1 0x071 /* 8253C Timer */
-#define IO_SASI 0x080 /* SASI Hard Disk Controller */
-#define IO_FD1 0x090 /* 765A 1MB FDC */
-#define IO_GDC2 0x0A0 /* 7220 GDC Graphic Control */
-#define IO_CGROM 0x0A1 /* Character ROM */
-#define IO_COM2 0x0B1 /* 8251A RS232C serial I/O (ext) */
-#define IO_COM3 0x0B9 /* 8251A RS232C serial I/O (ext) */
-#define IO_FDPORT 0x0BE /* FD I/F port (1M<->640K,EMTON) */
-#define IO_FD2 0x0C8 /* 765A 640KB FDC */
-#define IO_SIO1 0x0D0 /* MC16550II ext RS232C */
-#define IO_REEST 0x0F0 /* CPU FPU reset */
-#define IO_A2OEN 0x0F2 /* A20 enable */
-#define IO_A20CT 0x0F6 /* A20 control enable/disable */
-#define IO_NPX 0x0F8 /* Numeric Coprocessor */
-#define IO_SOUND 0x188 /* YM2203 FM sound board */
-#define IO_EGC 0x4A0 /* 7220 GDC Graphic Control */
-#define IO_SCSI 0xCC0 /* SCSI Controller */
-#define IO_SIO2 0x8D0 /* MC16550II ext RS232C */
-#define IO_BEEPF 0x3FDB /* beep frequency */
-#define IO_MOUSE 0x7FD9 /* mouse */
-#define IO_BMS 0x7FD9 /* Bus Mouse */
-#define IO_MSE 0x7FD9 /* Bus Mouse */
-#define IO_MOUSETM 0xDFBD /* mouse timer */
-
-#define IO_WD1_NEC 0x640 /* 98note IDE Hard disk controller */
-#define IO_WD1_EPSON 0x80 /* 386note Hard disk controller */
-#define IO_WD1 IO_WD1_NEC /* IDE Hard disk controller */
-
-#define IO_ISAEND 0xFFFF /* - 0x3FF End of I/O Registers */
-#endif /* !IO_ISABEGIN */
-
-/*
- * Input / Output Port Sizes - these are from several sources, and tend
- * to be the larger of what was found, ie COM ports can be 4, but some
- * boards do not fully decode the address, thus 8 ports are used.
- */
-#ifndef IO_ISASIZES
-#define IO_ISASIZES
-
-#define IO_ASCSIZE 5 /* AmiScan GI1904-based hand scanner */
-#define IO_CGASIZE 16 /* CGA controllers */
-#define IO_COMSIZE 8 /* 8250, 16X50 com controllers (4?) */
-#define IO_DMASIZE 16 /* 8237 DMA controllers */
-#define IO_DPGSIZE 32 /* 74LS612 DMA page registers */
-#define IO_EISASIZE 4096 /* EISA controllers */
-#define IO_FDCSIZE 8 /* Nec765 floppy controllers */
-#define IO_GAMSIZE 16 /* AT compatible game controllers */
-#define IO_GSCSIZE 8 /* GeniScan GS-4500G hand scanner */
-#define IO_ICUSIZE 16 /* 8259A interrupt controllers */
-#define IO_KBDSIZE 16 /* 8042 Keyboard controllers */
-#define IO_LPTSIZE 8 /* LPT controllers, some use only 4 */
-#define IO_MDASIZE 16 /* Monochrome display controllers */
-#define IO_NPXSIZE 16 /* 80387/80487 NPX registers */
-#define IO_PMPSIZE 2 /* 82347 power management peripheral */
-#define IO_PSMSIZE 5 /* 8042 Keyboard controllers */
-#define IO_RTCSIZE 16 /* CMOS real time clock, NMI control */
-#define IO_TMRSIZE 16 /* 8253 programmable timers */
-#define IO_VGASIZE 16 /* VGA controllers */
-#define IO_WDCSIZE 8 /* WD compatible disk controllers */
-
-#endif /* !IO_ISASIZES */
-
-/*
- * Input / Output Memory Physical Addresses
- */
-#ifndef IOM_BEGIN
-#define IOM_BEGIN 0x0A0000 /* Start of I/O Memory "hole" */
-#define IOM_END 0x100000 /* End of I/O Memory "hole" */
-#define IOM_SIZE (IOM_END - IOM_BEGIN)
-#endif /* !IOM_BEGIN */
-
-/*
- * RAM Physical Address Space (ignoring the above mentioned "hole")
- */
-#ifndef RAM_BEGIN
-#define RAM_BEGIN 0x0000000 /* Start of RAM Memory */
-#ifdef EPSON_BOUNCEDMA
-#define RAM_END 0x0f00000 /* End of EPSON GR?? RAM Memory */
-#else
-#define RAM_END 0x1000000 /* End of RAM Memory */
-#endif
-#define RAM_SIZE (RAM_END - RAM_BEGIN)
-#endif /* !RAM_BEGIN */
-
-#ifndef PC98 /* IBM-PC */
-/*
- * Oddball Physical Memory Addresses
- */
-#ifndef COMPAQ_RAMRELOC
-#define COMPAQ_RAMRELOC 0x80C00000 /* Compaq RAM relocation/diag */
-#define COMPAQ_RAMSETUP 0x80C00002 /* Compaq RAM setup */
-#define WEITEK_FPU 0xC0000000 /* WTL 2167 */
-#define CYRIX_EMC 0xC0000000 /* Cyrix EMC */
-#endif /* !COMPAQ_RAMRELOC */
-#endif
-
-#define M_NEC_PC98 0x0001
-#define M_EPSON_PC98 0x0002
-#define M_NOT_H98 0x0010
-#define M_H98 0x0020
-#define M_NOTE 0x0040
-#define M_NORMAL 0x1000
-#define M_8M 0x8000
-
-/*
- * Obtained from NetBSD/pc98
- */
-#define MADDRUNK -1
-#define IRQUNK 0
-#define DRQUNK -1
-
-#endif /* !_PC98_PC98_PC98_H_ */
diff --git a/sys/pc98/cbus/cbus_dma.c b/sys/pc98/cbus/cbus_dma.c
deleted file mode 100644
index 1866acd2bbc7..000000000000
--- a/sys/pc98/cbus/cbus_dma.c
+++ /dev/null
@@ -1,568 +0,0 @@
-/*-
- * Copyright (c) 1991 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)isa.c 7.2 (Berkeley) 5/13/91
- * $FreeBSD$
- */
-
-/*
- * code to manage AT bus
- *
- * 92/08/18 Frank P. MacLachlan (fpm@crash.cts.com):
- * Fixed uninitialized variable problem and added code to deal
- * with DMA page boundaries in isa_dmarangecheck(). Fixed word
- * mode DMA count compution and reorganized DMA setup code in
- * isa_dmastart()
- */
-
-#ifdef PC98
-#include "opt_pc98.h"
-#endif
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/buf.h> /* B_READ and B_RAW */
-#include <sys/malloc.h>
-#ifdef PC98
-#include <machine/md_var.h>
-#endif
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <vm/pmap.h>
-#ifdef PC98
-#include <pc98/pc98/pc98.h>
-#else
-#include <i386/isa/isa.h>
-#endif
-#include <i386/isa/isa_dma.h>
-#include <i386/isa/ic/i8237.h>
-
-/*
-** Register definitions for DMA controller 1 (channels 0..3):
-*/
-#ifdef PC98
-#define DMA1_CHN(c) (IO_DMA + (4*(c))) /* addr reg for channel c */
-#define DMA1_SMSK (IO_DMA + 0x14) /* single mask register */
-#define DMA1_MODE (IO_DMA + 0x16) /* mode register */
-#define DMA1_FFC (IO_DMA + 0x18) /* clear first/last FF */
-#else
-#define DMA1_CHN(c) (IO_DMA1 + 1*(2*(c))) /* addr reg for channel c */
-#define DMA1_SMSK (IO_DMA1 + 1*10) /* single mask register */
-#define DMA1_MODE (IO_DMA1 + 1*11) /* mode register */
-#define DMA1_FFC (IO_DMA1 + 1*12) /* clear first/last FF */
-#endif
-
-/*
-** Register definitions for DMA controller 2 (channels 4..7):
-*/
-#define DMA2_CHN(c) (IO_DMA2 + 2*(2*(c))) /* addr reg for channel c */
-#define DMA2_SMSK (IO_DMA2 + 2*10) /* single mask register */
-#define DMA2_MODE (IO_DMA2 + 2*11) /* mode register */
-#define DMA2_FFC (IO_DMA2 + 2*12) /* clear first/last FF */
-
-static int isa_dmarangecheck __P((caddr_t va, u_int length, int chan));
-
-#ifdef PC98
-static caddr_t dma_bouncebuf[4];
-static u_int dma_bouncebufsize[4];
-#else
-static caddr_t dma_bouncebuf[8];
-static u_int dma_bouncebufsize[8];
-#endif
-static u_int8_t dma_bounced = 0;
-static u_int8_t dma_busy = 0; /* Used in isa_dmastart() */
-static u_int8_t dma_inuse = 0; /* User for acquire/release */
-static u_int8_t dma_auto_mode = 0;
-
-#ifdef PC98
-#define VALID_DMA_MASK (3)
-#else
-#define VALID_DMA_MASK (7)
-#endif
-
-/* high byte of address is stored in this port for i-th dma channel */
-#ifdef PC98
-static int dmapageport[4] = { 0x27, 0x21, 0x23, 0x25 };
-#else
-static int dmapageport[8] = { 0x87, 0x83, 0x81, 0x82, 0x8f, 0x8b, 0x89, 0x8a };
-#endif
-
-/*
- * Setup a DMA channel's bounce buffer.
- */
-void
-isa_dmainit(chan, bouncebufsize)
- int chan;
- u_int bouncebufsize;
-{
- void *buf;
-
-#ifdef DIAGNOSTIC
- if (chan & ~VALID_DMA_MASK)
- panic("isa_dmainit: channel out of range");
-
- if (dma_bouncebuf[chan] != NULL)
- panic("isa_dmainit: impossible request");
-#endif
-
- dma_bouncebufsize[chan] = bouncebufsize;
-
- /* Try malloc() first. It works better if it works. */
- buf = malloc(bouncebufsize, M_DEVBUF, M_NOWAIT);
- if (buf != NULL) {
- if (isa_dmarangecheck(buf, bouncebufsize, chan) == 0) {
- dma_bouncebuf[chan] = buf;
- return;
- }
- free(buf, M_DEVBUF);
- }
- buf = contigmalloc(bouncebufsize, M_DEVBUF, M_NOWAIT, 0ul, 0xfffffful,
- 1ul, chan & 4 ? 0x20000ul : 0x10000ul);
- if (buf == NULL)
- printf("isa_dmainit(%d, %d) failed\n", chan, bouncebufsize);
- else
- dma_bouncebuf[chan] = buf;
-}
-
-/*
- * Register a DMA channel's usage. Usually called from a device driver
- * in open() or during its initialization.
- */
-int
-isa_dma_acquire(chan)
- int chan;
-{
-#ifdef DIAGNOSTIC
- if (chan & ~VALID_DMA_MASK)
- panic("isa_dma_acquire: channel out of range");
-#endif
-
- if (dma_inuse & (1 << chan)) {
- printf("isa_dma_acquire: channel %d already in use\n", chan);
- return (EBUSY);
- }
- dma_inuse |= (1 << chan);
- dma_auto_mode &= ~(1 << chan);
-
- return (0);
-}
-
-/*
- * Unregister a DMA channel's usage. Usually called from a device driver
- * during close() or during its shutdown.
- */
-void
-isa_dma_release(chan)
- int chan;
-{
-#ifdef DIAGNOSTIC
- if (chan & ~VALID_DMA_MASK)
- panic("isa_dma_release: channel out of range");
-
- if ((dma_inuse & (1 << chan)) == 0)
- printf("isa_dma_release: channel %d not in use\n", chan);
-#endif
-
- if (dma_busy & (1 << chan)) {
- dma_busy &= ~(1 << chan);
- /*
- * XXX We should also do "dma_bounced &= (1 << chan);"
- * because we are acting on behalf of isa_dmadone() which
- * was not called to end the last DMA operation. This does
- * not matter now, but it may in the future.
- */
- }
-
- dma_inuse &= ~(1 << chan);
- dma_auto_mode &= ~(1 << chan);
-}
-
-#ifndef PC98
-/*
- * isa_dmacascade(): program 8237 DMA controller channel to accept
- * external dma control by a board.
- */
-void
-isa_dmacascade(chan)
- int chan;
-{
-#ifdef DIAGNOSTIC
- if (chan & ~VALID_DMA_MASK)
- panic("isa_dmacascade: channel out of range");
-#endif
-
- /* set dma channel mode, and set dma channel mode */
- if ((chan & 4) == 0) {
- outb(DMA1_MODE, DMA37MD_CASCADE | chan);
- outb(DMA1_SMSK, chan);
- } else {
- outb(DMA2_MODE, DMA37MD_CASCADE | (chan & 3));
- outb(DMA2_SMSK, chan & 3);
- }
-}
-#endif
-
-/*
- * isa_dmastart(): program 8237 DMA controller channel, avoid page alignment
- * problems by using a bounce buffer.
- */
-void
-isa_dmastart(int flags, caddr_t addr, u_int nbytes, int chan)
-{
- vm_offset_t phys;
- int waport;
- caddr_t newaddr;
-
-#ifdef DIAGNOSTIC
- if (chan & ~VALID_DMA_MASK)
- panic("isa_dmastart: channel out of range");
-
- if ((chan < 4 && nbytes > (1<<16))
- || (chan >= 4 && (nbytes > (1<<17) || (u_int)addr & 1)))
- panic("isa_dmastart: impossible request");
-
- if ((dma_inuse & (1 << chan)) == 0)
- printf("isa_dmastart: channel %d not acquired\n", chan);
-#endif
-
-#if 0
- /*
- * XXX This should be checked, but drivers like ad1848 only call
- * isa_dmastart() once because they use Auto DMA mode. If we
- * leave this in, drivers that do this will print this continuously.
- */
- if (dma_busy & (1 << chan))
- printf("isa_dmastart: channel %d busy\n", chan);
-#endif
-
- dma_busy |= (1 << chan);
-
- if (isa_dmarangecheck(addr, nbytes, chan)) {
- if (dma_bouncebuf[chan] == NULL
- || dma_bouncebufsize[chan] < nbytes)
- panic("isa_dmastart: bad bounce buffer");
- dma_bounced |= (1 << chan);
- newaddr = dma_bouncebuf[chan];
-
- /* copy bounce buffer on write */
- if (!(flags & B_READ))
- bcopy(addr, newaddr, nbytes);
- addr = newaddr;
- }
-
- /* translate to physical */
- phys = pmap_extract(pmap_kernel(), (vm_offset_t)addr);
-
- if (flags & B_RAW) {
- dma_auto_mode |= (1 << chan);
- } else {
- dma_auto_mode &= ~(1 << chan);
- }
-
-#ifdef PC98
- if (need_pre_dma_flush)
- wbinvd(); /* wbinvd (WB cache flush) */
-#endif
-
-#ifndef PC98
- if ((chan & 4) == 0) {
- /*
- * Program one of DMA channels 0..3. These are
- * byte mode channels.
- */
-#endif
- /* set dma channel mode, and reset address ff */
-
- /* If B_RAW flag is set, then use autoinitialise mode */
- if (flags & B_RAW) {
- if (flags & B_READ)
- outb(DMA1_MODE, DMA37MD_AUTO|DMA37MD_WRITE|chan);
- else
- outb(DMA1_MODE, DMA37MD_AUTO|DMA37MD_READ|chan);
- }
- else
- if (flags & B_READ)
- outb(DMA1_MODE, DMA37MD_SINGLE|DMA37MD_WRITE|chan);
- else
- outb(DMA1_MODE, DMA37MD_SINGLE|DMA37MD_READ|chan);
- outb(DMA1_FFC, 0);
-
- /* send start address */
- waport = DMA1_CHN(chan);
- outb(waport, phys);
- outb(waport, phys>>8);
- outb(dmapageport[chan], phys>>16);
-
- /* send count */
-#ifdef PC98
- outb(waport + 2, --nbytes);
- outb(waport + 2, nbytes>>8);
-#else
- outb(waport + 1, --nbytes);
- outb(waport + 1, nbytes>>8);
-#endif
-
- /* unmask channel */
- outb(DMA1_SMSK, chan);
-#ifndef PC98
- } else {
- /*
- * Program one of DMA channels 4..7. These are
- * word mode channels.
- */
- /* set dma channel mode, and reset address ff */
-
- /* If B_RAW flag is set, then use autoinitialise mode */
- if (flags & B_RAW) {
- if (flags & B_READ)
- outb(DMA2_MODE, DMA37MD_AUTO|DMA37MD_WRITE|(chan&3));
- else
- outb(DMA2_MODE, DMA37MD_AUTO|DMA37MD_READ|(chan&3));
- }
- else
- if (flags & B_READ)
- outb(DMA2_MODE, DMA37MD_SINGLE|DMA37MD_WRITE|(chan&3));
- else
- outb(DMA2_MODE, DMA37MD_SINGLE|DMA37MD_READ|(chan&3));
- outb(DMA2_FFC, 0);
-
- /* send start address */
- waport = DMA2_CHN(chan - 4);
- outb(waport, phys>>1);
- outb(waport, phys>>9);
- outb(dmapageport[chan], phys>>16);
-
- /* send count */
- nbytes >>= 1;
- outb(waport + 2, --nbytes);
- outb(waport + 2, nbytes>>8);
-
- /* unmask channel */
- outb(DMA2_SMSK, chan & 3);
- }
-#endif
-}
-
-void
-isa_dmadone(int flags, caddr_t addr, int nbytes, int chan)
-{
-#ifdef PC98
- if (flags & B_READ) {
- /* cache flush only after reading 92/12/9 by A.Kojima */
- if (need_post_dma_flush)
- invd();
- }
-#endif
-
-#ifdef DIAGNOSTIC
- if (chan & ~VALID_DMA_MASK)
- panic("isa_dmadone: channel out of range");
-
- if ((dma_inuse & (1 << chan)) == 0)
- printf("isa_dmadone: channel %d not acquired\n", chan);
-#endif
-
- if (((dma_busy & (1 << chan)) == 0) &&
- (dma_auto_mode & (1 << chan)) == 0 )
- printf("isa_dmadone: channel %d not busy\n", chan);
-
-#ifdef PC98
- if ((dma_auto_mode & (1 << chan)) == 0)
- outb(DMA1_SMSK, (chan & 3) | 4);
-#else
- if ((dma_auto_mode & (1 << chan)) == 0)
- outb(chan & 4 ? DMA2_SMSK : DMA1_SMSK, (chan & 3) | 4);
-#endif
-
- if (dma_bounced & (1 << chan)) {
- /* copy bounce buffer on read */
- if (flags & B_READ)
- bcopy(dma_bouncebuf[chan], addr, nbytes);
-
- dma_bounced &= ~(1 << chan);
- }
- dma_busy &= ~(1 << chan);
-}
-
-/*
- * Check for problems with the address range of a DMA transfer
- * (non-contiguous physical pages, outside of bus address space,
- * crossing DMA page boundaries).
- * Return true if special handling needed.
- */
-
-static int
-isa_dmarangecheck(caddr_t va, u_int length, int chan)
-{
- vm_offset_t phys, priorpage = 0, endva;
- u_int dma_pgmsk = (chan & 4) ? ~(128*1024-1) : ~(64*1024-1);
-
- endva = (vm_offset_t)round_page((vm_offset_t)va + length);
- for (; va < (caddr_t) endva ; va += PAGE_SIZE) {
- phys = trunc_page(pmap_extract(pmap_kernel(), (vm_offset_t)va));
-#ifdef EPSON_BOUNCEDMA
-#define ISARAM_END 0xf00000
-#else
-#define ISARAM_END RAM_END
-#endif
- if (phys == 0)
- panic("isa_dmacheck: no physical page present");
- if (phys >= ISARAM_END)
- return (1);
- if (priorpage) {
- if (priorpage + PAGE_SIZE != phys)
- return (1);
- /* check if crossing a DMA page boundary */
- if (((u_int)priorpage ^ (u_int)phys) & dma_pgmsk)
- return (1);
- }
- priorpage = phys;
- }
- return (0);
-}
-
-/*
- * Query the progress of a transfer on a DMA channel.
- *
- * To avoid having to interrupt a transfer in progress, we sample
- * each of the high and low databytes twice, and apply the following
- * logic to determine the correct count.
- *
- * Reads are performed with interrupts disabled, thus it is to be
- * expected that the time between reads is very small. At most
- * one rollover in the low count byte can be expected within the
- * four reads that are performed.
- *
- * There are three gaps in which a rollover can occur :
- *
- * - read low1
- * gap1
- * - read high1
- * gap2
- * - read low2
- * gap3
- * - read high2
- *
- * If a rollover occurs in gap1 or gap2, the low2 value will be
- * greater than the low1 value. In this case, low2 and high2 are a
- * corresponding pair.
- *
- * In any other case, low1 and high1 can be considered to be correct.
- *
- * The function returns the number of bytes remaining in the transfer,
- * or -1 if the channel requested is not active.
- *
- */
-int
-isa_dmastatus(int chan)
-{
- u_long cnt = 0;
- int ffport, waport;
- u_long low1, high1, low2, high2;
-
- /* channel active? */
- if ((dma_inuse & (1 << chan)) == 0) {
- printf("isa_dmastatus: channel %d not active\n", chan);
- return(-1);
- }
- /* channel busy? */
-
- if (((dma_busy & (1 << chan)) == 0) &&
- (dma_auto_mode & (1 << chan)) == 0 ) {
- printf("chan %d not busy\n", chan);
- return -2 ;
- }
-#ifdef PC98
- ffport = DMA1_FFC;
- waport = DMA1_CHN(chan) + 2;
-#else
- if (chan < 4) { /* low DMA controller */
- ffport = DMA1_FFC;
- waport = DMA1_CHN(chan) + 1;
- } else { /* high DMA controller */
- ffport = DMA2_FFC;
- waport = DMA2_CHN(chan - 4) + 2;
- }
-#endif
-
- disable_intr(); /* no interrupts Mr Jones! */
- outb(ffport, 0); /* clear register LSB flipflop */
- low1 = inb(waport);
- high1 = inb(waport);
- outb(ffport, 0); /* clear again */
- low2 = inb(waport);
- high2 = inb(waport);
- enable_intr(); /* enable interrupts again */
-
- /*
- * Now decide if a wrap has tried to skew our results.
- * Note that after TC, the count will read 0xffff, while we want
- * to return zero, so we add and then mask to compensate.
- */
- if (low1 >= low2) {
- cnt = (low1 + (high1 << 8) + 1) & 0xffff;
- } else {
- cnt = (low2 + (high2 << 8) + 1) & 0xffff;
- }
-
- if (chan >= 4) /* high channels move words */
- cnt *= 2;
- return(cnt);
-}
-
-/*
- * Stop a DMA transfer currently in progress.
- */
-int
-isa_dmastop(int chan)
-{
- if ((dma_inuse & (1 << chan)) == 0)
- printf("isa_dmastop: channel %d not acquired\n", chan);
-
- if (((dma_busy & (1 << chan)) == 0) &&
- ((dma_auto_mode & (1 << chan)) == 0)) {
- printf("chan %d not busy\n", chan);
- return -2 ;
- }
-
- if ((chan & 4) == 0) {
- outb(DMA1_SMSK, (chan & 3) | 4 /* disable mask */);
- } else {
-#ifndef PC98
- outb(DMA2_SMSK, (chan & 3) | 4 /* disable mask */);
-#endif
- }
- return(isa_dmastatus(chan));
-}
diff --git a/sys/pc98/cbus/clock.c b/sys/pc98/cbus/clock.c
deleted file mode 100644
index bd29e52a5a27..000000000000
--- a/sys/pc98/cbus/clock.c
+++ /dev/null
@@ -1,1572 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz and Don Ahn.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)clock.c 7.2 (Berkeley) 5/12/91
- * $FreeBSD$
- */
-
-/*
- * Routines to handle clock hardware.
- */
-
-/*
- * inittodr, settodr and support routines written
- * by Christoph Robitschko <chmr@edvz.tu-graz.ac.at>
- *
- * reintroduced and updated by Chris Stenton <chris@gnome.co.uk> 8/10/94
- */
-
-/*
- * modified for PC98 by Kakefuda
- */
-
-#include "opt_clock.h"
-#include "apm.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/time.h>
-#include <sys/kernel.h>
-#ifndef SMP
-#include <sys/lock.h>
-#endif
-#include <sys/sysctl.h>
-#include <sys/cons.h>
-
-#include <machine/clock.h>
-#ifdef CLK_CALIBRATION_LOOP
-#endif
-#include <machine/cputypes.h>
-#include <machine/frame.h>
-#include <machine/ipl.h>
-#include <machine/limits.h>
-#include <machine/md_var.h>
-#include <machine/psl.h>
-#ifdef APIC_IO
-#include <machine/segments.h>
-#endif
-#if defined(SMP) || defined(APIC_IO)
-#include <machine/smp.h>
-#endif /* SMP || APIC_IO */
-#include <machine/specialreg.h>
-
-#include <i386/isa/icu.h>
-#ifdef PC98
-#include <pc98/pc98/pc98.h>
-#include <pc98/pc98/pc98_machdep.h>
-#include <i386/isa/isa_device.h>
-#else
-#include <i386/isa/isa.h>
-#include <isa/rtc.h>
-#endif
-#include <i386/isa/timerreg.h>
-
-#include <i386/isa/intr_machdep.h>
-
-#include "mca.h"
-#if NMCA > 0
-#include <i386/isa/mca_machdep.h>
-#endif
-
-#ifdef SMP
-#define disable_intr() CLOCK_DISABLE_INTR()
-#define enable_intr() CLOCK_ENABLE_INTR()
-
-#ifdef APIC_IO
-#include <i386/isa/intr_machdep.h>
-/* The interrupt triggered by the 8254 (timer) chip */
-int apic_8254_intr;
-static u_long read_intr_count __P((int vec));
-static void setup_8254_mixed_mode __P((void));
-#endif
-#endif /* SMP */
-
-/*
- * 32-bit time_t's can't reach leap years before 1904 or after 2036, so we
- * can use a simple formula for leap years.
- */
-#define LEAPYEAR(y) ((u_int)(y) % 4 == 0)
-#define DAYSPERYEAR (31+28+31+30+31+30+31+31+30+31+30+31)
-
-#define TIMER_DIV(x) ((timer_freq + (x) / 2) / (x))
-
-/*
- * Time in timer cycles that it takes for microtime() to disable interrupts
- * and latch the count. microtime() currently uses "cli; outb ..." so it
- * normally takes less than 2 timer cycles. Add a few for cache misses.
- * Add a few more to allow for latency in bogus calls to microtime() with
- * interrupts already disabled.
- */
-#define TIMER0_LATCH_COUNT 20
-
-/*
- * Maximum frequency that we are willing to allow for timer0. Must be
- * low enough to guarantee that the timer interrupt handler returns
- * before the next timer interrupt.
- */
-#define TIMER0_MAX_FREQ 20000
-
-int adjkerntz; /* local offset from GMT in seconds */
-int clkintr_pending;
-int disable_rtc_set; /* disable resettodr() if != 0 */
-volatile u_int idelayed;
-int statclock_disable;
-u_int stat_imask = SWI_CLOCK_MASK;
-#ifndef TIMER_FREQ
-#ifdef PC98
-#define TIMER_FREQ 2457600;
-#else /* IBM-PC */
-#define TIMER_FREQ 1193182;
-#endif /* PC98 */
-#endif
-u_int timer_freq = TIMER_FREQ;
-int timer0_max_count;
-u_int tsc_freq;
-int tsc_is_broken;
-int wall_cmos_clock; /* wall CMOS clock assumed if != 0 */
-
-static int beeping = 0;
-static u_int clk_imask = HWI_MASK | SWI_MASK;
-static const u_char daysinmonth[] = {31,28,31,30,31,30,31,31,30,31,30,31};
-static u_int hardclock_max_count;
-static u_int32_t i8254_lastcount;
-static u_int32_t i8254_offset;
-static int i8254_ticked;
-/*
- * XXX new_function and timer_func should not handle clockframes, but
- * timer_func currently needs to hold hardclock to handle the
- * timer0_state == 0 case. We should use inthand_add()/inthand_remove()
- * to switch between clkintr() and a slightly different timerintr().
- */
-static void (*new_function) __P((struct clockframe *frame));
-static u_int new_rate;
-#ifndef PC98
-static u_char rtc_statusa = RTCSA_DIVIDER | RTCSA_NOPROF;
-static u_char rtc_statusb = RTCSB_24HR | RTCSB_PINTR;
-#endif
-static u_int timer0_prescaler_count;
-
-/* Values for timerX_state: */
-#define RELEASED 0
-#define RELEASE_PENDING 1
-#define ACQUIRED 2
-#define ACQUIRE_PENDING 3
-
-static u_char timer0_state;
-#ifdef PC98
-static u_char timer1_state;
-#endif
-static u_char timer2_state;
-static void (*timer_func) __P((struct clockframe *frame)) = hardclock;
-#ifdef PC98
-static void rtc_serialcombit __P((int));
-static void rtc_serialcom __P((int));
-static int rtc_inb __P((void));
-static void rtc_outb __P((int));
-#endif
-static u_int tsc_present;
-
-static unsigned i8254_get_timecount __P((struct timecounter *tc));
-static unsigned tsc_get_timecount __P((struct timecounter *tc));
-static void set_timer_freq(u_int freq, int intr_freq);
-
-static struct timecounter tsc_timecounter = {
- tsc_get_timecount, /* get_timecount */
- 0, /* no poll_pps */
- ~0u, /* counter_mask */
- 0, /* frequency */
- "TSC" /* name */
-};
-
-SYSCTL_OPAQUE(_debug, OID_AUTO, tsc_timecounter, CTLFLAG_RD,
- &tsc_timecounter, sizeof(tsc_timecounter), "S,timecounter", "");
-
-static struct timecounter i8254_timecounter = {
- i8254_get_timecount, /* get_timecount */
- 0, /* no poll_pps */
- ~0u, /* counter_mask */
- 0, /* frequency */
- "i8254" /* name */
-};
-
-SYSCTL_OPAQUE(_debug, OID_AUTO, i8254_timecounter, CTLFLAG_RD,
- &i8254_timecounter, sizeof(i8254_timecounter), "S,timecounter", "");
-
-static void
-clkintr(struct clockframe frame)
-{
- if (timecounter->tc_get_timecount == i8254_get_timecount) {
- disable_intr();
- if (i8254_ticked)
- i8254_ticked = 0;
- else {
- i8254_offset += timer0_max_count;
- i8254_lastcount = 0;
- }
- clkintr_pending = 0;
- enable_intr();
- }
- timer_func(&frame);
- switch (timer0_state) {
-
- case RELEASED:
- setdelayed();
- break;
-
- case ACQUIRED:
- if ((timer0_prescaler_count += timer0_max_count)
- >= hardclock_max_count) {
- timer0_prescaler_count -= hardclock_max_count;
- hardclock(&frame);
- setdelayed();
- }
- break;
-
- case ACQUIRE_PENDING:
- disable_intr();
- i8254_offset = i8254_get_timecount(NULL);
- i8254_lastcount = 0;
- timer0_max_count = TIMER_DIV(new_rate);
- outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
- outb(TIMER_CNTR0, timer0_max_count & 0xff);
- outb(TIMER_CNTR0, timer0_max_count >> 8);
- enable_intr();
- timer_func = new_function;
- timer0_state = ACQUIRED;
- setdelayed();
- break;
-
- case RELEASE_PENDING:
- if ((timer0_prescaler_count += timer0_max_count)
- >= hardclock_max_count) {
- disable_intr();
- i8254_offset = i8254_get_timecount(NULL);
- i8254_lastcount = 0;
- timer0_max_count = hardclock_max_count;
- outb(TIMER_MODE,
- TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
- outb(TIMER_CNTR0, timer0_max_count & 0xff);
- outb(TIMER_CNTR0, timer0_max_count >> 8);
- enable_intr();
- timer0_prescaler_count = 0;
- timer_func = hardclock;
- timer0_state = RELEASED;
- hardclock(&frame);
- setdelayed();
- }
- break;
- }
-#if NMCA > 0
- /* Reset clock interrupt by asserting bit 7 of port 0x61 */
- if (MCA_system)
- outb(0x61, inb(0x61) | 0x80);
-#endif
-}
-
-/*
- * The acquire and release functions must be called at ipl >= splclock().
- */
-int
-acquire_timer0(int rate, void (*function) __P((struct clockframe *frame)))
-{
- static int old_rate;
-
- if (rate <= 0 || rate > TIMER0_MAX_FREQ)
- return (-1);
- switch (timer0_state) {
-
- case RELEASED:
- timer0_state = ACQUIRE_PENDING;
- break;
-
- case RELEASE_PENDING:
- if (rate != old_rate)
- return (-1);
- /*
- * The timer has been released recently, but is being
- * re-acquired before the release completed. In this
- * case, we simply reclaim it as if it had not been
- * released at all.
- */
- timer0_state = ACQUIRED;
- break;
-
- default:
- return (-1); /* busy */
- }
- new_function = function;
- old_rate = new_rate = rate;
- return (0);
-}
-
-#ifdef PC98
-int
-acquire_timer1(int mode)
-{
-
- if (timer1_state != RELEASED)
- return (-1);
- timer1_state = ACQUIRED;
-
- /*
- * This access to the timer registers is as atomic as possible
- * because it is a single instruction. We could do better if we
- * knew the rate. Use of splclock() limits glitches to 10-100us,
- * and this is probably good enough for timer2, so we aren't as
- * careful with it as with timer0.
- */
- outb(TIMER_MODE, TIMER_SEL1 | (mode & 0x3f));
-
- return (0);
-}
-#endif
-
-int
-acquire_timer2(int mode)
-{
-
- if (timer2_state != RELEASED)
- return (-1);
- timer2_state = ACQUIRED;
-
- /*
- * This access to the timer registers is as atomic as possible
- * because it is a single instruction. We could do better if we
- * knew the rate. Use of splclock() limits glitches to 10-100us,
- * and this is probably good enough for timer2, so we aren't as
- * careful with it as with timer0.
- */
- outb(TIMER_MODE, TIMER_SEL2 | (mode & 0x3f));
-
- return (0);
-}
-
-int
-release_timer0()
-{
- switch (timer0_state) {
-
- case ACQUIRED:
- timer0_state = RELEASE_PENDING;
- break;
-
- case ACQUIRE_PENDING:
- /* Nothing happened yet, release quickly. */
- timer0_state = RELEASED;
- break;
-
- default:
- return (-1);
- }
- return (0);
-}
-
-#ifdef PC98
-int
-release_timer1()
-{
-
- if (timer1_state != ACQUIRED)
- return (-1);
- timer1_state = RELEASED;
- outb(TIMER_MODE, TIMER_SEL1 | TIMER_SQWAVE | TIMER_16BIT);
- return (0);
-}
-#endif
-
-int
-release_timer2()
-{
-
- if (timer2_state != ACQUIRED)
- return (-1);
- timer2_state = RELEASED;
- outb(TIMER_MODE, TIMER_SEL2 | TIMER_SQWAVE | TIMER_16BIT);
- return (0);
-}
-
-#ifndef PC98
-/*
- * This routine receives statistical clock interrupts from the RTC.
- * As explained above, these occur at 128 interrupts per second.
- * When profiling, we receive interrupts at a rate of 1024 Hz.
- *
- * This does not actually add as much overhead as it sounds, because
- * when the statistical clock is active, the hardclock driver no longer
- * needs to keep (inaccurate) statistics on its own. This decouples
- * statistics gathering from scheduling interrupts.
- *
- * The RTC chip requires that we read status register C (RTC_INTR)
- * to acknowledge an interrupt, before it will generate the next one.
- * Under high interrupt load, rtcintr() can be indefinitely delayed and
- * the clock can tick immediately after the read from RTC_INTR. In this
- * case, the mc146818A interrupt signal will not drop for long enough
- * to register with the 8259 PIC. If an interrupt is missed, the stat
- * clock will halt, considerably degrading system performance. This is
- * why we use 'while' rather than a more straightforward 'if' below.
- * Stat clock ticks can still be lost, causing minor loss of accuracy
- * in the statistics, but the stat clock will no longer stop.
- */
-static void
-rtcintr(struct clockframe frame)
-{
- while (rtcin(RTC_INTR) & RTCIR_PERIOD)
- statclock(&frame);
-}
-
-#include "opt_ddb.h"
-#ifdef DDB
-#include <ddb/ddb.h>
-
-DB_SHOW_COMMAND(rtc, rtc)
-{
- printf("%02x/%02x/%02x %02x:%02x:%02x, A = %02x, B = %02x, C = %02x\n",
- rtcin(RTC_YEAR), rtcin(RTC_MONTH), rtcin(RTC_DAY),
- rtcin(RTC_HRS), rtcin(RTC_MIN), rtcin(RTC_SEC),
- rtcin(RTC_STATUSA), rtcin(RTC_STATUSB), rtcin(RTC_INTR));
-}
-#endif /* DDB */
-#endif /* for PC98 */
-
-static int
-getit(void)
-{
- u_long ef;
- int high, low;
-
- ef = read_eflags();
- disable_intr();
-
- /* Select timer0 and latch counter value. */
- outb(TIMER_MODE, TIMER_SEL0 | TIMER_LATCH);
-
- low = inb(TIMER_CNTR0);
- high = inb(TIMER_CNTR0);
-
- CLOCK_UNLOCK();
- write_eflags(ef);
- return ((high << 8) | low);
-}
-
-/*
- * Wait "n" microseconds.
- * Relies on timer 1 counting down from (timer_freq / hz)
- * Note: timer had better have been programmed before this is first used!
- */
-void
-DELAY(int n)
-{
- int delta, prev_tick, tick, ticks_left;
-
-#ifdef DELAYDEBUG
- int getit_calls = 1;
- int n1;
- static int state = 0;
-
- if (state == 0) {
- state = 1;
- for (n1 = 1; n1 <= 10000000; n1 *= 10)
- DELAY(n1);
- state = 2;
- }
- if (state == 1)
- printf("DELAY(%d)...", n);
-#endif
- /*
- * Guard against the timer being uninitialized if we are called
- * early for console i/o.
- */
- if (timer0_max_count == 0)
- set_timer_freq(timer_freq, hz);
-
- /*
- * Read the counter first, so that the rest of the setup overhead is
- * counted. Guess the initial overhead is 20 usec (on most systems it
- * takes about 1.5 usec for each of the i/o's in getit(). The loop
- * takes about 6 usec on a 486/33 and 13 usec on a 386/20. The
- * multiplications and divisions to scale the count take a while).
- */
- prev_tick = getit();
- n -= 0; /* XXX actually guess no initial overhead */
- /*
- * Calculate (n * (timer_freq / 1e6)) without using floating point
- * and without any avoidable overflows.
- */
- if (n <= 0)
- ticks_left = 0;
- else if (n < 256)
- /*
- * Use fixed point to avoid a slow division by 1000000.
- * 39099 = 1193182 * 2^15 / 10^6 rounded to nearest.
- * 2^15 is the first power of 2 that gives exact results
- * for n between 0 and 256.
- */
- ticks_left = ((u_int)n * 39099 + (1 << 15) - 1) >> 15;
- else
- /*
- * Don't bother using fixed point, although gcc-2.7.2
- * generates particularly poor code for the long long
- * division, since even the slow way will complete long
- * before the delay is up (unless we're interrupted).
- */
- ticks_left = ((u_int)n * (long long)timer_freq + 999999)
- / 1000000;
-
- while (ticks_left > 0) {
- tick = getit();
-#ifdef DELAYDEBUG
- ++getit_calls;
-#endif
- delta = prev_tick - tick;
- prev_tick = tick;
- if (delta < 0) {
- delta += timer0_max_count;
- /*
- * Guard against timer0_max_count being wrong.
- * This shouldn't happen in normal operation,
- * but it may happen if set_timer_freq() is
- * traced.
- */
- if (delta < 0)
- delta = 0;
- }
- ticks_left -= delta;
- }
-#ifdef DELAYDEBUG
- if (state == 1)
- printf(" %d calls to getit() at %d usec each\n",
- getit_calls, (n + 5) / getit_calls);
-#endif
-}
-
-static void
-sysbeepstop(void *chan)
-{
-#ifdef PC98 /* PC98 */
- outb(IO_PPI, inb(IO_PPI)|0x08); /* disable counter1 output to speaker */
- release_timer1();
-#else
- outb(IO_PPI, inb(IO_PPI)&0xFC); /* disable counter2 output to speaker */
- release_timer2();
-#endif
- beeping = 0;
-}
-
-int
-sysbeep(int pitch, int period)
-{
- int x = splclock();
-
-#ifdef PC98
- if (acquire_timer1(TIMER_SQWAVE|TIMER_16BIT))
- if (!beeping) {
- /* Something else owns it. */
- splx(x);
- return (-1); /* XXX Should be EBUSY, but nobody cares anyway. */
- }
- disable_intr();
- outb(0x3fdb, pitch);
- outb(0x3fdb, (pitch>>8));
- enable_intr();
- if (!beeping) {
- /* enable counter1 output to speaker */
- outb(IO_PPI, (inb(IO_PPI) & 0xf7));
- beeping = period;
- timeout(sysbeepstop, (void *)NULL, period);
- }
-#else
- if (acquire_timer2(TIMER_SQWAVE|TIMER_16BIT))
- if (!beeping) {
- /* Something else owns it. */
- splx(x);
- return (-1); /* XXX Should be EBUSY, but nobody cares anyway. */
- }
- disable_intr();
- outb(TIMER_CNTR2, pitch);
- outb(TIMER_CNTR2, (pitch>>8));
- enable_intr();
- if (!beeping) {
- /* enable counter2 output to speaker */
- outb(IO_PPI, inb(IO_PPI) | 3);
- beeping = period;
- timeout(sysbeepstop, (void *)NULL, period);
- }
-#endif
- splx(x);
- return (0);
-}
-
-#ifndef PC98
-/*
- * RTC support routines
- */
-
-int
-rtcin(reg)
- int reg;
-{
- int s;
- u_char val;
-
- s = splhigh();
- outb(IO_RTC, reg);
- inb(0x84);
- val = inb(IO_RTC + 1);
- inb(0x84);
- splx(s);
- return (val);
-}
-
-static __inline void
-writertc(u_char reg, u_char val)
-{
- int s;
-
- s = splhigh();
- inb(0x84);
- outb(IO_RTC, reg);
- inb(0x84);
- outb(IO_RTC + 1, val);
- inb(0x84); /* XXX work around wrong order in rtcin() */
- splx(s);
-}
-
-static __inline int
-readrtc(int port)
-{
- return(bcd2bin(rtcin(port)));
-}
-#endif
-
-#ifdef PC98
-unsigned int delaycount;
-#define FIRST_GUESS 0x2000
-static void findcpuspeed(void)
-{
- int i;
- int remainder;
-
- /* Put counter in count down mode */
- outb(TIMER_MODE, TIMER_SEL0 | TIMER_16BIT | TIMER_RATEGEN);
- outb(TIMER_CNTR0, 0xff);
- outb(TIMER_CNTR0, 0xff);
- for (i = FIRST_GUESS; i; i--)
- ;
- remainder = getit();
- delaycount = (FIRST_GUESS * TIMER_DIV(1000)) / (0xffff - remainder);
-}
-#endif
-
-#ifdef PC98
-static u_int
-calibrate_clocks(void)
-{
- int timeout;
- u_int count, prev_count, tot_count;
- u_short sec, start_sec;
-
- if (bootverbose)
- printf("Calibrating clock(s) ... ");
- /* Check ARTIC. */
- if (!(PC98_SYSTEM_PARAMETER(0x458) & 0x80) &&
- !(PC98_SYSTEM_PARAMETER(0x45b) & 0x04))
- goto fail;
- timeout = 100000000;
-
- /* Read the ARTIC. */
- sec = inw(0x5e);
-
- /* Wait for the ARTIC to changes. */
- start_sec = sec;
- for (;;) {
- sec = inw(0x5e);
- if (sec != start_sec)
- break;
- if (--timeout == 0)
- goto fail;
- }
- prev_count = getit();
- if (prev_count == 0 || prev_count > timer0_max_count)
- goto fail;
- tot_count = 0;
-
- if (tsc_present)
- wrmsr(0x10, 0LL); /* XXX 0x10 is the MSR for the TSC */
- start_sec = sec;
- for (;;) {
- sec = inw(0x5e);
- count = getit();
- if (count == 0 || count > timer0_max_count)
- goto fail;
- if (count > prev_count)
- tot_count += prev_count - (count - timer0_max_count);
- else
- tot_count += prev_count - count;
- prev_count = count;
- if ((sec == start_sec + 1200) ||
- (sec < start_sec &&
- (u_int)sec + 0x10000 == (u_int)start_sec + 1200))
- break;
- if (--timeout == 0)
- goto fail;
- }
- /*
- * Read the cpu cycle counter. The timing considerations are
- * similar to those for the i8254 clock.
- */
- if (tsc_present)
- tsc_freq = rdtsc();
-
- if (bootverbose) {
- if (tsc_present)
- printf("TSC clock: %u Hz, ", tsc_freq);
- printf("i8254 clock: %u Hz\n", tot_count);
- }
- return (tot_count);
-
-fail:
- if (bootverbose)
- printf("failed, using default i8254 clock of %u Hz\n",
- timer_freq);
- return (timer_freq);
-}
-#else
-static u_int
-calibrate_clocks(void)
-{
- u_int64_t old_tsc;
- u_int count, prev_count, tot_count;
- int sec, start_sec, timeout;
-
- if (bootverbose)
- printf("Calibrating clock(s) ... ");
- if (!(rtcin(RTC_STATUSD) & RTCSD_PWR))
- goto fail;
- timeout = 100000000;
-
- /* Read the mc146818A seconds counter. */
- for (;;) {
- if (!(rtcin(RTC_STATUSA) & RTCSA_TUP)) {
- sec = rtcin(RTC_SEC);
- break;
- }
- if (--timeout == 0)
- goto fail;
- }
-
- /* Wait for the mC146818A seconds counter to change. */
- start_sec = sec;
- for (;;) {
- if (!(rtcin(RTC_STATUSA) & RTCSA_TUP)) {
- sec = rtcin(RTC_SEC);
- if (sec != start_sec)
- break;
- }
- if (--timeout == 0)
- goto fail;
- }
-
- /* Start keeping track of the i8254 counter. */
- prev_count = getit();
- if (prev_count == 0 || prev_count > timer0_max_count)
- goto fail;
- tot_count = 0;
-
- if (tsc_present)
- old_tsc = rdtsc();
- else
- old_tsc = 0; /* shut up gcc */
-
- /*
- * Wait for the mc146818A seconds counter to change. Read the i8254
- * counter for each iteration since this is convenient and only
- * costs a few usec of inaccuracy. The timing of the final reads
- * of the counters almost matches the timing of the initial reads,
- * so the main cause of inaccuracy is the varying latency from
- * inside getit() or rtcin(RTC_STATUSA) to the beginning of the
- * rtcin(RTC_SEC) that returns a changed seconds count. The
- * maximum inaccuracy from this cause is < 10 usec on 486's.
- */
- start_sec = sec;
- for (;;) {
- if (!(rtcin(RTC_STATUSA) & RTCSA_TUP))
- sec = rtcin(RTC_SEC);
- count = getit();
- if (count == 0 || count > timer0_max_count)
- goto fail;
- if (count > prev_count)
- tot_count += prev_count - (count - timer0_max_count);
- else
- tot_count += prev_count - count;
- prev_count = count;
- if (sec != start_sec)
- break;
- if (--timeout == 0)
- goto fail;
- }
-
- /*
- * Read the cpu cycle counter. The timing considerations are
- * similar to those for the i8254 clock.
- */
- if (tsc_present)
- tsc_freq = rdtsc() - old_tsc;
-
- if (bootverbose) {
- if (tsc_present)
- printf("TSC clock: %u Hz, ", tsc_freq);
- printf("i8254 clock: %u Hz\n", tot_count);
- }
- return (tot_count);
-
-fail:
- if (bootverbose)
- printf("failed, using default i8254 clock of %u Hz\n",
- timer_freq);
- return (timer_freq);
-}
-#endif /* !PC98 */
-
-static void
-set_timer_freq(u_int freq, int intr_freq)
-{
- u_long ef;
- int new_timer0_max_count;
-
- ef = read_eflags();
- disable_intr();
- timer_freq = freq;
- new_timer0_max_count = hardclock_max_count = TIMER_DIV(intr_freq);
- if (new_timer0_max_count != timer0_max_count) {
- timer0_max_count = new_timer0_max_count;
- outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
- outb(TIMER_CNTR0, timer0_max_count & 0xff);
- outb(TIMER_CNTR0, timer0_max_count >> 8);
- }
- CLOCK_UNLOCK();
- write_eflags(ef);
-}
-
-/*
- * i8254_restore is called from apm_default_resume() to reload
- * the countdown register.
- * this should not be necessary but there are broken laptops that
- * do not restore the countdown register on resume.
- * when it happnes, it messes up the hardclock interval and system clock,
- * which leads to the infamous "calcru: negative time" problem.
- */
-void
-i8254_restore(void)
-{
- u_long ef;
-
- ef = read_eflags();
- disable_intr();
- outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
- outb(TIMER_CNTR0, timer0_max_count & 0xff);
- outb(TIMER_CNTR0, timer0_max_count >> 8);
- CLOCK_UNLOCK();
- write_eflags(ef);
-}
-
-/*
- * Initialize 8254 timer 0 early so that it can be used in DELAY().
- * XXX initialization of other timers is unintentionally left blank.
- */
-void
-startrtclock()
-{
- u_int delta, freq;
-
-#ifdef PC98
- findcpuspeed();
- if (pc98_machine_type & M_8M)
- timer_freq = 1996800L; /* 1.9968 MHz */
- else
- timer_freq = 2457600L; /* 2.4576 MHz */
-#endif /* PC98 */
-
- if (cpu_feature & CPUID_TSC)
- tsc_present = 1;
- else
- tsc_present = 0;
-
-#ifndef PC98
- writertc(RTC_STATUSA, rtc_statusa);
- writertc(RTC_STATUSB, RTCSB_24HR);
-#endif
-
- set_timer_freq(timer_freq, hz);
- freq = calibrate_clocks();
-#ifdef CLK_CALIBRATION_LOOP
- if (bootverbose) {
- printf(
- "Press a key on the console to abort clock calibration\n");
- while (cncheckc() == -1)
- calibrate_clocks();
- }
-#endif
-
- /*
- * Use the calibrated i8254 frequency if it seems reasonable.
- * Otherwise use the default, and don't use the calibrated i586
- * frequency.
- */
- delta = freq > timer_freq ? freq - timer_freq : timer_freq - freq;
- if (delta < timer_freq / 100) {
-#ifndef CLK_USE_I8254_CALIBRATION
- if (bootverbose)
- printf(
-"CLK_USE_I8254_CALIBRATION not specified - using default frequency\n");
- freq = timer_freq;
-#endif
- timer_freq = freq;
- } else {
- if (bootverbose)
- printf(
- "%d Hz differs from default of %d Hz by more than 1%%\n",
- freq, timer_freq);
- tsc_freq = 0;
- }
-
- set_timer_freq(timer_freq, hz);
- i8254_timecounter.tc_frequency = timer_freq;
- init_timecounter(&i8254_timecounter);
-
-#ifndef CLK_USE_TSC_CALIBRATION
- if (tsc_freq != 0) {
- if (bootverbose)
- printf(
-"CLK_USE_TSC_CALIBRATION not specified - using old calibration method\n");
- tsc_freq = 0;
- }
-#endif
- if (tsc_present && tsc_freq == 0) {
- /*
- * Calibration of the i586 clock relative to the mc146818A
- * clock failed. Do a less accurate calibration relative
- * to the i8254 clock.
- */
- u_int64_t old_tsc = rdtsc();
-
- DELAY(1000000);
- tsc_freq = rdtsc() - old_tsc;
-#ifdef CLK_USE_TSC_CALIBRATION
- if (bootverbose)
- printf("TSC clock: %u Hz (Method B)\n", tsc_freq);
-#endif
- }
-
-#if !defined(SMP)
- /*
- * We can not use the TSC in SMP mode, until we figure out a
- * cheap (impossible), reliable and precise (yeah right!) way
- * to synchronize the TSCs of all the CPUs.
- * Curse Intel for leaving the counter out of the I/O APIC.
- */
-
-#if NAPM > 0
- /*
- * We can not use the TSC if we support APM. Precise timekeeping
- * on an APM'ed machine is at best a fools pursuit, since
- * any and all of the time spent in various SMM code can't
- * be reliably accounted for. Reading the RTC is your only
- * source of reliable time info. The i8254 looses too of course
- * but we need to have some kind of time...
- * We don't know at this point whether APM is going to be used
- * or not, nor when it might be activated. Play it safe.
- */
- return;
-#endif /* NAPM > 0 */
-
- if (tsc_present && tsc_freq != 0 && !tsc_is_broken) {
- tsc_timecounter.tc_frequency = tsc_freq;
- init_timecounter(&tsc_timecounter);
- }
-
-#endif /* !defined(SMP) */
-}
-
-#ifdef PC98
-static void
-rtc_serialcombit(int i)
-{
- outb(IO_RTC, ((i&0x01)<<5)|0x07);
- DELAY(1);
- outb(IO_RTC, ((i&0x01)<<5)|0x17);
- DELAY(1);
- outb(IO_RTC, ((i&0x01)<<5)|0x07);
- DELAY(1);
-}
-
-static void
-rtc_serialcom(int i)
-{
- rtc_serialcombit(i&0x01);
- rtc_serialcombit((i&0x02)>>1);
- rtc_serialcombit((i&0x04)>>2);
- rtc_serialcombit((i&0x08)>>3);
- outb(IO_RTC, 0x07);
- DELAY(1);
- outb(IO_RTC, 0x0f);
- DELAY(1);
- outb(IO_RTC, 0x07);
- DELAY(1);
-}
-
-static void
-rtc_outb(int val)
-{
- int s;
- int sa = 0;
-
- for (s=0;s<8;s++) {
- sa = ((val >> s) & 0x01) ? 0x27 : 0x07;
- outb(IO_RTC, sa); /* set DI & CLK 0 */
- DELAY(1);
- outb(IO_RTC, sa | 0x10); /* CLK 1 */
- DELAY(1);
- }
- outb(IO_RTC, sa & 0xef); /* CLK 0 */
-}
-
-static int
-rtc_inb(void)
-{
- int s;
- int sa = 0;
-
- for (s=0;s<8;s++) {
- sa |= ((inb(0x33) & 0x01) << s);
- outb(IO_RTC, 0x17); /* CLK 1 */
- DELAY(1);
- outb(IO_RTC, 0x07); /* CLK 0 */
- DELAY(2);
- }
- return sa;
-}
-#endif /* PC-98 */
-
-/*
- * Initialize the time of day register, based on the time base which is, e.g.
- * from a filesystem.
- */
-void
-inittodr(time_t base)
-{
- unsigned long sec, days;
-#ifndef PC98
- int yd;
-#endif
- int year, month;
- int y, m, s;
- struct timespec ts;
-#ifdef PC98
- int second, min, hour;
-#endif
-
- if (base) {
- s = splclock();
- ts.tv_sec = base;
- ts.tv_nsec = 0;
- set_timecounter(&ts);
- splx(s);
- }
-
-#ifdef PC98
- rtc_serialcom(0x03); /* Time Read */
- rtc_serialcom(0x01); /* Register shift command. */
- DELAY(20);
-
- second = bcd2bin(rtc_inb() & 0xff); /* sec */
- min = bcd2bin(rtc_inb() & 0xff); /* min */
- hour = bcd2bin(rtc_inb() & 0xff); /* hour */
- days = bcd2bin(rtc_inb() & 0xff) - 1; /* date */
-
- month = (rtc_inb() >> 4) & 0x0f; /* month */
- for (m = 1; m < month; m++)
- days += daysinmonth[m-1];
- year = bcd2bin(rtc_inb() & 0xff) + 1900; /* year */
- /* 2000 year problem */
- if (year < 1995)
- year += 100;
- if (year < 1970)
- goto wrong_time;
- for (y = 1970; y < year; y++)
- days += DAYSPERYEAR + LEAPYEAR(y);
- if ((month > 2) && LEAPYEAR(year))
- days ++;
- sec = ((( days * 24 +
- hour) * 60 +
- min) * 60 +
- second);
- /* sec now contains the number of seconds, since Jan 1 1970,
- in the local time zone */
-#else /* IBM-PC */
- /* Look if we have a RTC present and the time is valid */
- if (!(rtcin(RTC_STATUSD) & RTCSD_PWR))
- goto wrong_time;
-
- /* wait for time update to complete */
- /* If RTCSA_TUP is zero, we have at least 244us before next update */
- s = splhigh();
- while (rtcin(RTC_STATUSA) & RTCSA_TUP) {
- splx(s);
- s = splhigh();
- }
-
- days = 0;
-#ifdef USE_RTC_CENTURY
- year = readrtc(RTC_YEAR) + readrtc(RTC_CENTURY) * 100;
-#else
- year = readrtc(RTC_YEAR) + 1900;
- if (year < 1970)
- year += 100;
-#endif
- if (year < 1970) {
- splx(s);
- goto wrong_time;
- }
- month = readrtc(RTC_MONTH);
- for (m = 1; m < month; m++)
- days += daysinmonth[m-1];
- if ((month > 2) && LEAPYEAR(year))
- days ++;
- days += readrtc(RTC_DAY) - 1;
- yd = days;
- for (y = 1970; y < year; y++)
- days += DAYSPERYEAR + LEAPYEAR(y);
- sec = ((( days * 24 +
- readrtc(RTC_HRS)) * 60 +
- readrtc(RTC_MIN)) * 60 +
- readrtc(RTC_SEC));
- /* sec now contains the number of seconds, since Jan 1 1970,
- in the local time zone */
-#endif
-
- sec += tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
-
- y = time_second - sec;
- if (y <= -2 || y >= 2) {
- /* badly off, adjust it */
- ts.tv_sec = sec;
- ts.tv_nsec = 0;
- set_timecounter(&ts);
- }
- splx(s);
- return;
-
-wrong_time:
- printf("Invalid time in real time clock.\n");
- printf("Check and reset the date immediately!\n");
-}
-
-/*
- * Write system time back to RTC
- */
-void
-resettodr()
-{
- unsigned long tm;
- int y, m, s;
-#ifdef PC98
- int wd;
-#endif
-
- if (disable_rtc_set)
- return;
-
- s = splclock();
- tm = time_second;
- splx(s);
-
-#ifdef PC98
- rtc_serialcom(0x01); /* Register shift command. */
-
- /* Calculate local time to put in RTC */
-
- tm -= tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
-
- rtc_outb(bin2bcd(tm%60)); tm /= 60; /* Write back Seconds */
- rtc_outb(bin2bcd(tm%60)); tm /= 60; /* Write back Minutes */
- rtc_outb(bin2bcd(tm%24)); tm /= 24; /* Write back Hours */
-
- /* We have now the days since 01-01-1970 in tm */
- wd = (tm+4)%7;
- for (y = 1970, m = DAYSPERYEAR + LEAPYEAR(y);
- tm >= m;
- y++, m = DAYSPERYEAR + LEAPYEAR(y))
- tm -= m;
-
- /* Now we have the years in y and the day-of-the-year in tm */
- for (m = 0; ; m++) {
- int ml;
-
- ml = daysinmonth[m];
- if (m == 1 && LEAPYEAR(y))
- ml++;
- if (tm < ml)
- break;
- tm -= ml;
- }
-
- m++;
- rtc_outb(bin2bcd(tm+1)); /* Write back Day */
- rtc_outb((m << 4) | wd); /* Write back Month & Weekday */
- rtc_outb(bin2bcd(y%100)); /* Write back Year */
-
- rtc_serialcom(0x02); /* Time set & Counter hold command. */
- rtc_serialcom(0x00); /* Register hold command. */
-#else
- /* Disable RTC updates and interrupts. */
- writertc(RTC_STATUSB, RTCSB_HALT | RTCSB_24HR);
-
- /* Calculate local time to put in RTC */
-
- tm -= tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
-
- writertc(RTC_SEC, bin2bcd(tm%60)); tm /= 60; /* Write back Seconds */
- writertc(RTC_MIN, bin2bcd(tm%60)); tm /= 60; /* Write back Minutes */
- writertc(RTC_HRS, bin2bcd(tm%24)); tm /= 24; /* Write back Hours */
-
- /* We have now the days since 01-01-1970 in tm */
- writertc(RTC_WDAY, (tm+4)%7); /* Write back Weekday */
- for (y = 1970, m = DAYSPERYEAR + LEAPYEAR(y);
- tm >= m;
- y++, m = DAYSPERYEAR + LEAPYEAR(y))
- tm -= m;
-
- /* Now we have the years in y and the day-of-the-year in tm */
- writertc(RTC_YEAR, bin2bcd(y%100)); /* Write back Year */
-#ifdef USE_RTC_CENTURY
- writertc(RTC_CENTURY, bin2bcd(y/100)); /* ... and Century */
-#endif
- for (m = 0; ; m++) {
- int ml;
-
- ml = daysinmonth[m];
- if (m == 1 && LEAPYEAR(y))
- ml++;
- if (tm < ml)
- break;
- tm -= ml;
- }
-
- writertc(RTC_MONTH, bin2bcd(m + 1)); /* Write back Month */
- writertc(RTC_DAY, bin2bcd(tm + 1)); /* Write back Month Day */
-
- /* Reenable RTC updates and interrupts. */
- writertc(RTC_STATUSB, rtc_statusb);
-#endif
-}
-
-
-/*
- * Start both clocks running.
- */
-void
-cpu_initclocks()
-{
-#ifdef APIC_IO
- int apic_8254_trial;
- struct intrec *clkdesc;
-#endif /* APIC_IO */
-#ifndef PC98
- int diag;
-
- if (statclock_disable) {
- /*
- * The stat interrupt mask is different without the
- * statistics clock. Also, don't set the interrupt
- * flag which would normally cause the RTC to generate
- * interrupts.
- */
- stat_imask = HWI_MASK | SWI_MASK;
- rtc_statusb = RTCSB_24HR;
- } else {
- /* Setting stathz to nonzero early helps avoid races. */
- stathz = RTC_NOPROFRATE;
- profhz = RTC_PROFRATE;
- }
-#endif
-
- /* Finish initializing 8253 timer 0. */
-#ifdef APIC_IO
-
- apic_8254_intr = isa_apic_irq(0);
- apic_8254_trial = 0;
- if (apic_8254_intr >= 0 ) {
- if (apic_int_type(0, 0) == 3)
- apic_8254_trial = 1;
- } else {
- /* look for ExtInt on pin 0 */
- if (apic_int_type(0, 0) == 3) {
- apic_8254_intr = apic_irq(0, 0);
- setup_8254_mixed_mode();
- } else
- panic("APIC_IO: Cannot route 8254 interrupt to CPU");
- }
-
- clkdesc = inthand_add("clk", apic_8254_intr, (inthand2_t *)clkintr,
- NULL, &clk_imask, INTR_EXCL);
- INTREN(1 << apic_8254_intr);
-
-#else /* APIC_IO */
-
- inthand_add("clk", 0, (inthand2_t *)clkintr, NULL, &clk_imask,
- INTR_EXCL);
- INTREN(IRQ0);
-
-#endif /* APIC_IO */
-
-#ifndef PC98
- /* Initialize RTC. */
- writertc(RTC_STATUSA, rtc_statusa);
- writertc(RTC_STATUSB, RTCSB_24HR);
-
- /* Don't bother enabling the statistics clock. */
- if (statclock_disable)
- return;
- diag = rtcin(RTC_DIAG);
- if (diag != 0)
- printf("RTC BIOS diagnostic error %b\n", diag, RTCDG_BITS);
-
-#ifdef APIC_IO
- if (isa_apic_irq(8) != 8)
- panic("APIC RTC != 8");
-#endif /* APIC_IO */
-
- inthand_add("rtc", 8, (inthand2_t *)rtcintr, NULL, &stat_imask,
- INTR_EXCL);
-
-#ifdef APIC_IO
- INTREN(APIC_IRQ8);
-#else
- INTREN(IRQ8);
-#endif /* APIC_IO */
-
- writertc(RTC_STATUSB, rtc_statusb);
-#endif /* !PC98 */
-
-#ifdef APIC_IO
- if (apic_8254_trial) {
-
- printf("APIC_IO: Testing 8254 interrupt delivery\n");
- while (read_intr_count(8) < 6)
- ; /* nothing */
- if (read_intr_count(apic_8254_intr) < 3) {
- /*
- * The MP table is broken.
- * The 8254 was not connected to the specified pin
- * on the IO APIC.
- * Workaround: Limited variant of mixed mode.
- */
- INTRDIS(1 << apic_8254_intr);
- inthand_remove(clkdesc);
- printf("APIC_IO: Broken MP table detected: "
- "8254 is not connected to "
- "IOAPIC #%d intpin %d\n",
- int_to_apicintpin[apic_8254_intr].ioapic,
- int_to_apicintpin[apic_8254_intr].int_pin);
- /*
- * Revoke current ISA IRQ 0 assignment and
- * configure a fallback interrupt routing from
- * the 8254 Timer via the 8259 PIC to the
- * an ExtInt interrupt line on IOAPIC #0 intpin 0.
- * We reuse the low level interrupt handler number.
- */
- if (apic_irq(0, 0) < 0) {
- revoke_apic_irq(apic_8254_intr);
- assign_apic_irq(0, 0, apic_8254_intr);
- }
- apic_8254_intr = apic_irq(0, 0);
- setup_8254_mixed_mode();
- inthand_add("clk", apic_8254_intr,
- (inthand2_t *)clkintr,
- NULL, &clk_imask, INTR_EXCL);
- INTREN(1 << apic_8254_intr);
- }
-
- }
- if (apic_int_type(0, 0) != 3 ||
- int_to_apicintpin[apic_8254_intr].ioapic != 0 ||
- int_to_apicintpin[apic_8254_intr].int_pin != 0)
- printf("APIC_IO: routing 8254 via IOAPIC #%d intpin %d\n",
- int_to_apicintpin[apic_8254_intr].ioapic,
- int_to_apicintpin[apic_8254_intr].int_pin);
- else
- printf("APIC_IO: "
- "routing 8254 via 8259 and IOAPIC #0 intpin 0\n");
-#endif
-
-}
-
-#ifdef APIC_IO
-static u_long
-read_intr_count(int vec)
-{
- u_long *up;
- up = intr_countp[vec];
- if (up)
- return *up;
- return 0UL;
-}
-
-static void
-setup_8254_mixed_mode()
-{
- /*
- * Allow 8254 timer to INTerrupt 8259:
- * re-initialize master 8259:
- * reset; prog 4 bytes, single ICU, edge triggered
- */
- outb(IO_ICU1, 0x13);
-#ifdef PC98
- outb(IO_ICU1 + 2, NRSVIDT); /* start vector (unused) */
- outb(IO_ICU1 + 2, 0x00); /* ignore slave */
- outb(IO_ICU1 + 2, 0x03); /* auto EOI, 8086 */
- outb(IO_ICU1 + 2, 0xfe); /* unmask INT0 */
-#else
- outb(IO_ICU1 + 1, NRSVIDT); /* start vector (unused) */
- outb(IO_ICU1 + 1, 0x00); /* ignore slave */
- outb(IO_ICU1 + 1, 0x03); /* auto EOI, 8086 */
- outb(IO_ICU1 + 1, 0xfe); /* unmask INT0 */
-#endif
- /* program IO APIC for type 3 INT on INT0 */
- if (ext_int_setup(0, 0) < 0)
- panic("8254 redirect via APIC pin0 impossible!");
-}
-#endif
-
-void
-setstatclockrate(int newhz)
-{
-#ifndef PC98
- if (newhz == RTC_PROFRATE)
- rtc_statusa = RTCSA_DIVIDER | RTCSA_PROF;
- else
- rtc_statusa = RTCSA_DIVIDER | RTCSA_NOPROF;
- writertc(RTC_STATUSA, rtc_statusa);
-#endif
-}
-
-static int
-sysctl_machdep_i8254_freq SYSCTL_HANDLER_ARGS
-{
- int error;
- u_int freq;
-
- /*
- * Use `i8254' instead of `timer' in external names because `timer'
- * is is too generic. Should use it everywhere.
- */
- freq = timer_freq;
- error = sysctl_handle_int(oidp, &freq, sizeof(freq), req);
- if (error == 0 && req->newptr != NULL) {
- if (timer0_state != RELEASED)
- return (EBUSY); /* too much trouble to handle */
- set_timer_freq(freq, hz);
- i8254_timecounter.tc_frequency = freq;
- update_timecounter(&i8254_timecounter);
- }
- return (error);
-}
-
-SYSCTL_PROC(_machdep, OID_AUTO, i8254_freq, CTLTYPE_INT | CTLFLAG_RW,
- 0, sizeof(u_int), sysctl_machdep_i8254_freq, "I", "");
-
-static int
-sysctl_machdep_tsc_freq SYSCTL_HANDLER_ARGS
-{
- int error;
- u_int freq;
-
- if (tsc_timecounter.tc_frequency == 0)
- return (EOPNOTSUPP);
- freq = tsc_freq;
- error = sysctl_handle_int(oidp, &freq, sizeof(freq), req);
- if (error == 0 && req->newptr != NULL) {
- tsc_freq = freq;
- tsc_timecounter.tc_frequency = tsc_freq;
- update_timecounter(&tsc_timecounter);
- }
- return (error);
-}
-
-SYSCTL_PROC(_machdep, OID_AUTO, tsc_freq, CTLTYPE_INT | CTLFLAG_RW,
- 0, sizeof(u_int), sysctl_machdep_tsc_freq, "I", "");
-
-static unsigned
-i8254_get_timecount(struct timecounter *tc)
-{
- u_int count;
- u_long ef;
- u_int high, low;
-
- ef = read_eflags();
- disable_intr();
-
- /* Select timer0 and latch counter value. */
- outb(TIMER_MODE, TIMER_SEL0 | TIMER_LATCH);
-
- low = inb(TIMER_CNTR0);
- high = inb(TIMER_CNTR0);
- count = timer0_max_count - ((high << 8) | low);
- if (count < i8254_lastcount ||
- (!i8254_ticked && (clkintr_pending ||
- ((count < 20 || (!(ef & PSL_I) && count < timer0_max_count / 2u)) &&
-#ifdef APIC_IO
-#define lapic_irr1 ((volatile u_int *)&lapic)[0x210 / 4] /* XXX XXX */
- /* XXX this assumes that apic_8254_intr is < 24. */
- (lapic_irr1 & (1 << apic_8254_intr))))
-#else
- (inb(IO_ICU1) & 1)))
-#endif
- )) {
- i8254_ticked = 1;
- i8254_offset += timer0_max_count;
- }
- i8254_lastcount = count;
- count += i8254_offset;
- CLOCK_UNLOCK();
- write_eflags(ef);
- return (count);
-}
-
-static unsigned
-tsc_get_timecount(struct timecounter *tc)
-{
- return (rdtsc());
-}
diff --git a/sys/pc98/cbus/fdc.c b/sys/pc98/cbus/fdc.c
deleted file mode 100644
index f0bc9114928c..000000000000
--- a/sys/pc98/cbus/fdc.c
+++ /dev/null
@@ -1,2814 +0,0 @@
-/*
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Don Ahn.
- *
- * Libretto PCMCIA floppy support by David Horwitt (dhorwitt@ucsd.edu)
- * aided by the Linux floppy driver modifications from David Bateman
- * (dbateman@eng.uts.edu.au).
- *
- * Copyright (c) 1993, 1994 by
- * jc@irbs.UUCP (John Capo)
- * vak@zebub.msk.su (Serge Vakulenko)
- * ache@astral.msk.su (Andrew A. Chernov)
- *
- * Copyright (c) 1993, 1994, 1995 by
- * joerg_wunsch@uriah.sax.de (Joerg Wunsch)
- * dufault@hda.com (Peter Dufault)
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)fd.c 7.4 (Berkeley) 5/25/91
- * $FreeBSD$
- *
- */
-
-#include "opt_fdc.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/buf.h>
-#include <sys/bus.h>
-#include <sys/conf.h>
-#include <sys/disklabel.h>
-#include <sys/devicestat.h>
-#include <sys/fcntl.h>
-#include <sys/malloc.h>
-#include <sys/module.h>
-#include <sys/proc.h>
-#include <sys/syslog.h>
-
-#include <sys/bus.h>
-#include <machine/bus.h>
-#include <sys/rman.h>
-
-#include <machine/clock.h>
-#include <machine/ioctl_fd.h>
-#include <machine/resource.h>
-#include <machine/stdarg.h>
-
-#include <isa/isavar.h>
-#ifdef PC98
-#include <pc98/pc98/pc98.h>
-#include <pc98/pc98/pc98_machdep.h>
-#include <pc98/pc98/epsonio.h>
-#include <pc98/pc98/fdreg.h>
-#include <isa/fdc.h>
-#else
-#include <isa/isareg.h>
-#include <isa/fdreg.h>
-#include <isa/fdc.h>
-#include <isa/rtc.h>
-#endif
-
-/* misuse a flag to identify format operation */
-#define B_FORMAT B_XXX
-
-/* configuration flags */
-#define FDC_PRETEND_D0 (1 << 0) /* pretend drive 0 to be there */
-#define FDC_NO_FIFO (1 << 2) /* do not enable FIFO */
-
-/* internally used only, not really from CMOS: */
-#define RTCFDT_144M_PRETENDED 0x1000
-
-/* error returns for fd_cmd() */
-#define FD_FAILED -1
-#define FD_NOT_VALID -2
-#define FDC_ERRMAX 100 /* do not log more */
-
-#ifdef PC98
-#define NUMTYPES 12
-#define NUMDENS NUMTYPES
-#else
-#define NUMTYPES 17
-#define NUMDENS (NUMTYPES - 7)
-#endif
-
-/* These defines (-1) must match index for fd_types */
-#define F_TAPE_TYPE 0x020 /* bit for fd_types to indicate tape */
-#define NO_TYPE 0 /* must match NO_TYPE in ft.c */
-#define FD_1720 1
-#define FD_1480 2
-#define FD_1440 3
-#define FD_1200 4
-#define FD_820 5
-#define FD_800 6
-#define FD_720 7
-#define FD_360 8
-#define FD_640 9
-#define FD_1232 10
-
-#ifdef PC98
-#define FD_1280 11
-#define FD_1476 12
-
-#define FDT_NONE 0 /* none present */
-#define FDT_12M 1 /* 1M/640K FDD */
-#define FDT_144M 2 /* 1.44M/1M/640K FDD */
-#else
-#define FD_1480in5_25 11
-#define FD_1440in5_25 12
-#define FD_820in5_25 13
-#define FD_800in5_25 14
-#define FD_720in5_25 15
-#define FD_360in5_25 16
-#define FD_640in5_25 17
-#endif
-
-
-static struct fd_type fd_types[NUMTYPES] =
-{
-#ifdef PC98
-{ 21,2,0xFF,0x04,82,3444,1,2,2,0x0C,2 }, /* 1.72M in 3mode */
-{ 18,2,0xFF,0x1B,82,2952,1,2,2,0x54,1 }, /* 1.48M in 3mode */
-{ 18,2,0xFF,0x1B,80,2880,1,2,2,0x54,1 }, /* 1.44M in 3mode */
-{ 15,2,0xFF,0x1B,80,2400,1,0,2,0x54,1 }, /* 1.2M */
-{ 10,2,0xFF,0x10,82,1640,1,1,2,0x30,1 }, /* 820K */
-{ 10,2,0xFF,0x10,80,1600,1,1,2,0x30,1 }, /* 800K */
-{ 9,2,0xFF,0x20,80,1440,1,1,2,0x50,1 }, /* 720K */
-{ 9,2,0xFF,0x20,40, 720,2,1,2,0x50,1 }, /* 360K */
-{ 8,2,0xFF,0x2A,80,1280,1,1,2,0x50,1 }, /* 640K */
-{ 8,3,0xFF,0x35,77,1232,1,0,2,0x74,1 }, /* 1.23M 1024/sec */
-
-{ 8,3,0xFF,0x35,80,1280,1,0,2,0x74,1 }, /* 1.28M 1024/sec */
-{ 9,3,0xFF,0x35,82,1476,1,0,2,0x47,1 }, /* 1.48M 1024/sec 9sec */
-#if 0
-{ 10,3,0xFF,0x1B,82,1640,1,2,2,0x54,1 }, /* 1.64M in 3mode - Reserve */
-#endif
-#else
-{ 21,2,0xFF,0x04,82,3444,1,FDC_500KBPS,2,0x0C,2 }, /* 1.72M in HD 3.5in */
-{ 18,2,0xFF,0x1B,82,2952,1,FDC_500KBPS,2,0x6C,1 }, /* 1.48M in HD 3.5in */
-{ 18,2,0xFF,0x1B,80,2880,1,FDC_500KBPS,2,0x6C,1 }, /* 1.44M in HD 3.5in */
-{ 15,2,0xFF,0x1B,80,2400,1,FDC_500KBPS,2,0x54,1 }, /* 1.2M in HD 5.25/3.5 */
-{ 10,2,0xFF,0x10,82,1640,1,FDC_250KBPS,2,0x2E,1 }, /* 820K in HD 3.5in */
-{ 10,2,0xFF,0x10,80,1600,1,FDC_250KBPS,2,0x2E,1 }, /* 800K in HD 3.5in */
-{ 9,2,0xFF,0x20,80,1440,1,FDC_250KBPS,2,0x50,1 }, /* 720K in HD 3.5in */
-{ 9,2,0xFF,0x2A,40, 720,1,FDC_250KBPS,2,0x50,1 }, /* 360K in DD 5.25in */
-{ 8,2,0xFF,0x2A,80,1280,1,FDC_250KBPS,2,0x50,1 }, /* 640K in DD 5.25in */
-{ 8,3,0xFF,0x35,77,1232,1,FDC_500KBPS,2,0x74,1 }, /* 1.23M in HD 5.25in */
-
-{ 18,2,0xFF,0x02,82,2952,1,FDC_500KBPS,2,0x02,2 }, /* 1.48M in HD 5.25in */
-{ 18,2,0xFF,0x02,80,2880,1,FDC_500KBPS,2,0x02,2 }, /* 1.44M in HD 5.25in */
-{ 10,2,0xFF,0x10,82,1640,1,FDC_300KBPS,2,0x2E,1 }, /* 820K in HD 5.25in */
-{ 10,2,0xFF,0x10,80,1600,1,FDC_300KBPS,2,0x2E,1 }, /* 800K in HD 5.25in */
-{ 9,2,0xFF,0x20,80,1440,1,FDC_300KBPS,2,0x50,1 }, /* 720K in HD 5.25in */
-{ 9,2,0xFF,0x23,40, 720,2,FDC_300KBPS,2,0x50,1 }, /* 360K in HD 5.25in */
-{ 8,2,0xFF,0x2A,80,1280,1,FDC_300KBPS,2,0x50,1 }, /* 640K in HD 5.25in */
-#endif
-};
-
-#ifdef PC98
-#define DRVS_PER_CTLR 4 /* 4 floppies */
-#else
-#define DRVS_PER_CTLR 2 /* 2 floppies */
-#endif
-
-/***********************************************************************\
-* Per controller structure. *
-\***********************************************************************/
-static devclass_t fdc_devclass;
-
-/***********************************************************************\
-* Per drive structure. *
-* N per controller (DRVS_PER_CTLR) *
-\***********************************************************************/
-struct fd_data {
- struct fdc_data *fdc; /* pointer to controller structure */
- int fdsu; /* this units number on this controller */
- int type; /* Drive type (FD_1440...) */
- struct fd_type *ft; /* pointer to the type descriptor */
- int flags;
-#define FD_OPEN 0x01 /* it's open */
-#define FD_ACTIVE 0x02 /* it's active */
-#define FD_MOTOR 0x04 /* motor should be on */
-#define FD_MOTOR_WAIT 0x08 /* motor coming up */
- int skip;
- int hddrv;
-#define FD_NO_TRACK -2
- int track; /* where we think the head is */
- int options; /* user configurable options, see ioctl_fd.h */
- struct callout_handle toffhandle;
- struct callout_handle tohandle;
- struct devstat device_stats;
-#ifdef PC98
- int pc98_trans;
-#endif
- device_t dev;
- fdu_t fdu;
-};
-
-struct fdc_ivars {
- int fdunit;
-};
-static devclass_t fd_devclass;
-
-#ifdef EPSON_NRDISK
-typedef unsigned int nrd_t;
-
-#define P_NRD_ADDRH 0xc24
-#define P_NRD_ADDRM 0xc22
-#define P_NRD_ADDRL 0xc20
-#define P_NRD_CHECK 0xc20
-#define P_NRD_DATA 0xc26
-#define P_NRD_LED 0xc36
-#define B_NRD_CHK 0x80
-#define B_NRD_LED 0x40
-#define A_NRD_INFO 0x2
-#define A_NRD_BASE 0x400
-#define NRD_STATUS 0x0
-#define NRD_ST0_HD 0x04
-
-static fdu_t nrdu=-1;
-static int nrdsec=0;
-static nrd_t nrdblkn=0;
-static nrd_t nrdaddr=0x0;
-
-#define nrd_check_ready() ({ \
- (epson_inb(P_NRD_CHECK) & B_NRD_CHK) ? 0 : 1; \
- })
-#define nrd_LED_on() epson_outb(P_NRD_LED, B_NRD_LED)
-#define nrd_LED_off() epson_outb(P_NRD_LED, ~B_NRD_LED)
-#define nrd_trac() ((int)(nrd_info(nrdaddr) & 0xff))
-#define nrd_head() ((int)((nrd_info(nrdaddr) >> 8) & 0xff))
-#define nrd_sec() ((int)(nrd_info(nrdaddr + 2) & 0xff))
-#define nrd_secsize() ((int)((nrd_info(A_NRD_INFO) >> 8) & 0xff))
-#define nrd_addrset(p) nrd_addr((nrd_t)((nrd_t)p+A_NRD_BASE))
-
-static inline void
-nrd_addr(addr)
- nrd_t addr;
-{
- epson_outb(P_NRD_ADDRH, (u_char)((addr >> 16) & 0x1f));
- epson_outb(P_NRD_ADDRM, (u_char)((addr >> 8) & 0xff));
- epson_outb(P_NRD_ADDRL, (u_char)(addr & 0xff));
-}
-
-static inline u_short
-nrd_info(addr)
- nrd_t addr;
-{
- u_short tmp;
-
- nrd_addr(addr);
- outb(0x43f, 0x42);
- tmp = (short)inw(P_NRD_DATA);
- outb(0x43f, 0x40);
- return ((u_short)tmp);
-}
-#endif /* EPSON_NRDISK */
-
-/***********************************************************************\
-* Throughout this file the following conventions will be used: *
-* fd is a pointer to the fd_data struct for the drive in question *
-* fdc is a pointer to the fdc_data struct for the controller *
-* fdu is the floppy drive unit number *
-* fdcu is the floppy controller unit number *
-* fdsu is the floppy drive unit number on that controller. (sub-unit) *
-\***********************************************************************/
-
-/* needed for ft driver, thus exported */
-int in_fdc(struct fdc_data *);
-int out_fdc(struct fdc_data *, int);
-
-/* internal functions */
-static void fdc_intr(void *);
-static void set_motor(struct fdc_data *, int, int);
-# define TURNON 1
-# define TURNOFF 0
-static timeout_t fd_turnoff;
-static timeout_t fd_motor_on;
-static void fd_turnon(struct fd_data *);
-static void fdc_reset(fdc_p);
-static int fd_in(struct fdc_data *, int *);
-static void fdstart(struct fdc_data *);
-static timeout_t fd_iotimeout;
-static timeout_t fd_pseudointr;
-static int fdstate(struct fdc_data *);
-static int retrier(struct fdc_data *);
-static int fdformat(dev_t, struct fd_formb *, struct proc *);
-
-static int enable_fifo(fdc_p fdc);
-
-static int fifo_threshold = 8; /* XXX: should be accessible via sysctl */
-
-
-#define DEVIDLE 0
-#define FINDWORK 1
-#define DOSEEK 2
-#define SEEKCOMPLETE 3
-#define IOCOMPLETE 4
-#define RECALCOMPLETE 5
-#define STARTRECAL 6
-#define RESETCTLR 7
-#define SEEKWAIT 8
-#define RECALWAIT 9
-#define MOTORWAIT 10
-#define IOTIMEDOUT 11
-#define RESETCOMPLETE 12
-#define PIOREAD 13
-
-#ifdef FDC_DEBUG
-static char const * const fdstates[] =
-{
-"DEVIDLE",
-"FINDWORK",
-"DOSEEK",
-"SEEKCOMPLETE",
-"IOCOMPLETE",
-"RECALCOMPLETE",
-"STARTRECAL",
-"RESETCTLR",
-"SEEKWAIT",
-"RECALWAIT",
-"MOTORWAIT",
-"IOTIMEDOUT",
-"RESETCOMPLETE",
-"PIOREAD",
-};
-
-/* CAUTION: fd_debug causes huge amounts of logging output */
-static int volatile fd_debug = 0;
-#define TRACE0(arg) if(fd_debug) printf(arg)
-#define TRACE1(arg1, arg2) if(fd_debug) printf(arg1, arg2)
-#else /* FDC_DEBUG */
-#define TRACE0(arg)
-#define TRACE1(arg1, arg2)
-#endif /* FDC_DEBUG */
-
-static void
-fdout_wr(fdc_p fdc, u_int8_t v)
-{
- bus_space_write_1(fdc->portt, fdc->porth, FDOUT+fdc->port_off, v);
-}
-
-static u_int8_t
-fdsts_rd(fdc_p fdc)
-{
- return bus_space_read_1(fdc->portt, fdc->porth, FDSTS+fdc->port_off);
-}
-
-static void
-fddata_wr(fdc_p fdc, u_int8_t v)
-{
- bus_space_write_1(fdc->portt, fdc->porth, FDDATA+fdc->port_off, v);
-}
-
-static u_int8_t
-fddata_rd(fdc_p fdc)
-{
- return bus_space_read_1(fdc->portt, fdc->porth, FDDATA+fdc->port_off);
-}
-
-#ifndef PC98
-static void
-fdctl_wr(fdc_p fdc, u_int8_t v)
-{
- bus_space_write_1(fdc->ctlt, fdc->ctlh, 0, v);
-}
-#endif
-
-#if 0
-
-static u_int8_t
-fdin_rd(fdc_p fdc)
-{
- return bus_space_read_1(fdc->portt, fdc->porth, FDIN);
-}
-
-#endif
-
-#ifdef FDC_YE
-#if NCARD > 0
-#include <sys/select.h>
-#include <sys/module.h>
-#include <pccard/cardinfo.h>
-#include <pccard/driver.h>
-#include <pccard/slot.h>
-
-/*
- * PC-Card (PCMCIA) specific code.
- */
-static int yeinit(struct pccard_devinfo *); /* init device */
-static void yeunload(struct pccard_devinfo *); /* Disable driver */
-static int yeintr(struct pccard_devinfo *); /* Interrupt handler */
-
-PCCARD_MODULE(fdc, yeinit, yeunload, yeintr, 0, bio_imask);
-
-/*
- * Initialize the device - called from Slot manager.
- */
-static int yeinit(struct pccard_devinfo *devi)
-{
- fdc_p fdc = &fdc_data[devi->isahd.id_unit];
-
- fdc->baseport = devi->isahd.id_iobase;
- /*
- * reset controller
- */
- fdout_wr(fdc, 0);
- DELAY(100);
- fdout_wr(fdc, FDO_FRST);
-
- /*
- * wire into system
- */
- if (yeattach(&devi->isahd) == 0)
- return(ENXIO);
-
- return(0);
-}
-
-/*
- * yeunload - unload the driver and clear the table.
- * XXX TODO:
- * This is usually called when the card is ejected, but
- * can be caused by a modunload of a controller driver.
- * The idea is to reset the driver's view of the device
- * and ensure that any driver entry points such as
- * read and write do not hang.
- */
-static void yeunload(struct pccard_devinfo *devi)
-{
- if (fd_data[devi->isahd.id_unit].type == NO_TYPE)
- return;
-
- /*
- * this prevents Fdopen() and fdstrategy() from attempting
- * to access unloaded controller
- */
- fd_data[devi->isahd.id_unit].type = NO_TYPE;
-
- printf("fdc%d: unload\n", devi->isahd.id_unit);
-}
-
-/*
- * yeintr - Shared interrupt called from
- * front end of PC-Card handler.
- */
-static int yeintr(struct pccard_devinfo *devi)
-{
- fdintr((fdcu_t)devi->isahd.id_unit);
- return(1);
-}
-#endif /* NCARD > 0 */
-#endif /* FDC_YE */
-
-static d_open_t Fdopen; /* NOTE, not fdopen */
-static d_close_t fdclose;
-static d_ioctl_t fdioctl;
-static d_strategy_t fdstrategy;
-
-#define CDEV_MAJOR 9
-#define BDEV_MAJOR 2
-
-static struct cdevsw fd_cdevsw = {
- /* open */ Fdopen,
- /* close */ fdclose,
- /* read */ physread,
- /* write */ physwrite,
- /* ioctl */ fdioctl,
- /* poll */ nopoll,
- /* mmap */ nommap,
- /* strategy */ fdstrategy,
- /* name */ "fd",
- /* maj */ CDEV_MAJOR,
- /* dump */ nodump,
- /* psize */ nopsize,
- /* flags */ D_DISK,
- /* bmaj */ BDEV_MAJOR
-};
-
-static int
-fdc_err(struct fdc_data *fdc, const char *s)
-{
- fdc->fdc_errs++;
- if (s) {
- if (fdc->fdc_errs < FDC_ERRMAX)
- device_printf(fdc->fdc_dev, "%s", s);
- else if (fdc->fdc_errs == FDC_ERRMAX)
- device_printf(fdc->fdc_dev, "too many errors, not "
- "logging any more\n");
- }
-
- return FD_FAILED;
-}
-
-/*
- * fd_cmd: Send a command to the chip. Takes a varargs with this structure:
- * Unit number,
- * # of output bytes, output bytes as ints ...,
- * # of input bytes, input bytes as ints ...
- */
-static int
-fd_cmd(struct fdc_data *fdc, int n_out, ...)
-{
- u_char cmd;
- int n_in;
- int n;
- va_list ap;
-
- va_start(ap, n_out);
- cmd = (u_char)(va_arg(ap, int));
- va_end(ap);
- va_start(ap, n_out);
- for (n = 0; n < n_out; n++)
- {
- if (out_fdc(fdc, va_arg(ap, int)) < 0)
- {
- char msg[50];
- snprintf(msg, sizeof(msg),
- "cmd %x failed at out byte %d of %d\n",
- cmd, n + 1, n_out);
- return fdc_err(fdc, msg);
- }
- }
- n_in = va_arg(ap, int);
- for (n = 0; n < n_in; n++)
- {
- int *ptr = va_arg(ap, int *);
- if (fd_in(fdc, ptr) < 0)
- {
- char msg[50];
- snprintf(msg, sizeof(msg),
- "cmd %02x failed at in byte %d of %d\n",
- cmd, n + 1, n_in);
- return fdc_err(fdc, msg);
- }
- }
-
- return 0;
-}
-
-static int
-enable_fifo(fdc_p fdc)
-{
- int i, j;
-
- if ((fdc->flags & FDC_HAS_FIFO) == 0) {
-
- /*
- * XXX:
- * Cannot use fd_cmd the normal way here, since
- * this might be an invalid command. Thus we send the
- * first byte, and check for an early turn of data directon.
- */
-
- if (out_fdc(fdc, I8207X_CONFIGURE) < 0)
- return fdc_err(fdc, "Enable FIFO failed\n");
-
- /* If command is invalid, return */
- j = 100000;
- while ((i = fdsts_rd(fdc) & (NE7_DIO | NE7_RQM))
- != NE7_RQM && j-- > 0)
- if (i == (NE7_DIO | NE7_RQM)) {
- fdc_reset(fdc);
- return FD_FAILED;
- }
- if (j<0 ||
- fd_cmd(fdc, 3,
- 0, (fifo_threshold - 1) & 0xf, 0, 0) < 0) {
- fdc_reset(fdc);
- return fdc_err(fdc, "Enable FIFO failed\n");
- }
- fdc->flags |= FDC_HAS_FIFO;
- return 0;
- }
- if (fd_cmd(fdc, 4,
- I8207X_CONFIGURE, 0, (fifo_threshold - 1) & 0xf, 0, 0) < 0)
- return fdc_err(fdc, "Re-enable FIFO failed\n");
- return 0;
-}
-
-static int
-fd_sense_drive_status(fdc_p fdc, int *st3p)
-{
- int st3;
-
- if (fd_cmd(fdc, 2, NE7CMD_SENSED, fdc->fdu, 1, &st3))
- {
- return fdc_err(fdc, "Sense Drive Status failed\n");
- }
- if (st3p)
- *st3p = st3;
-
- return 0;
-}
-
-static int
-fd_sense_int(fdc_p fdc, int *st0p, int *cylp)
-{
- int cyl, st0, ret;
-
-#ifdef EPSON_NRDISK
- if (fdc->fdu == nrdu) {
- if (fdc->fd->track >= 0) nrdaddr = (fdc->fd->track + 1) * 8;
- else nrdaddr = 0x0;
- *st0p = nrd_head() ? NRD_ST0_HD : NRD_STATUS;
- *cylp = nrd_trac();
- }
- else {
-#endif /* EPSON_NRDISK */
- ret = fd_cmd(fdc, 1, NE7CMD_SENSEI, 1, &st0);
- if (ret) {
- (void)fdc_err(fdc,
- "sense intr err reading stat reg 0\n");
- return ret;
- }
-
- if (st0p)
- *st0p = st0;
-
- if ((st0 & NE7_ST0_IC) == NE7_ST0_IC_IV) {
- /*
- * There doesn't seem to have been an interrupt.
- */
- return FD_NOT_VALID;
- }
-
- if (fd_in(fdc, &cyl) < 0) {
- return fdc_err(fdc, "can't get cyl num\n");
- }
-
- if (cylp)
- *cylp = cyl;
-
-#ifdef EPSON_NRDISK
- }
-#endif /* EPSON_NRDISK */
- return 0;
-}
-
-
-static int
-fd_read_status(fdc_p fdc, int fdsu)
-{
- int i, ret;
-
- for (i = 0; i < 7; i++) {
- /*
- * XXX types are poorly chosen. Only bytes can by read
- * from the hardware, but fdc->status[] wants u_ints and
- * fd_in() gives ints.
- */
- int status;
-
-#ifdef EPSON_NRDISK
- if (fdc->fdu == nrdu) {
- switch (i) {
- case 0: fdc->status[i] = nrd_head()
- ? NRD_ST0_HD : NRD_STATUS; break;
- case 1: fdc->status[i] = NRD_STATUS; break;
- case 2: fdc->status[i] = NRD_STATUS; break;
- case 3: fdc->status[i] = nrd_trac(); break;
- case 4: fdc->status[i] = nrd_head(); break;
- case 5: fdc->status[i] = nrdsec; break;
- case 6: fdc->status[i] = nrd_secsize(); break;
- }
- ret = 0;
- }
- else {
-#endif /* EPSON_NRDISK */
- ret = fd_in(fdc, &status);
- fdc->status[i] = status;
- if (ret != 0)
- break;
-#ifdef EPSON_NRDISK
- }
-#endif /* EPSON_NRDISK */
- }
-
- if (ret == 0)
- fdc->flags |= FDC_STAT_VALID;
- else
- fdc->flags &= ~FDC_STAT_VALID;
-
- return ret;
-}
-
-/****************************************************************************/
-/* autoconfiguration stuff */
-/****************************************************************************/
-#ifdef PC98
-static int pc98_trans = 0; /* 0 : HD , 1 : DD , 2 : 1.44 */
-static int pc98_trans_prev = 0;
-
-static void set_density(fdc_p fdc)
-{
- /* always motor on */
- outb(IO_FDPORT, (pc98_trans != 1 ? FDP_FDDEXC : 0) | FDP_PORTEXC);
- DELAY(100);
- fdout_wr(fdc, FDO_RST | FDO_DMAE);
- /* in the case of note W, always inhibit 100ms timer */
-}
-
-static int pc98_fd_check_ready(fdu_t fdu)
-{
- fd_p fd = devclass_get_softc(fd_devclass, fdu);
- struct fdc_data *fdc = fd->fdc;
- int retry = 0;
-
-#ifdef EPSON_NRDISK
- if (fdu == nrdu) {
- if (nrd_check_ready()) return 0;
- else return -1;
- }
-#endif
- while (retry++ < 30000) {
- set_motor(fdc, fd->fdsu, TURNON);
- out_fdc(fdc, NE7CMD_SENSED); /* Sense Drive Status */
- DELAY(100);
- out_fdc(fdc, fdu); /* Drive number */
- DELAY(100);
- if ((in_fdc(fdc) & NE7_ST3_RD)){
- fdout_wr(fdc, FDO_DMAE | FDO_MTON);
- DELAY(10);
- return 0;
- }
- }
- return -1;
-}
-#endif
-
-static int
-fdc_alloc_resources(struct fdc_data *fdc)
-{
- device_t dev;
- int ispnp;
-
- dev = fdc->fdc_dev;
- ispnp = fdc->fdc_ispnp;
- fdc->rid_ioport = fdc->rid_irq = fdc->rid_drq = 0;
- fdc->res_ioport = fdc->res_irq = fdc->res_drq = 0;
-
-#ifdef PC98
- fdc->res_ioport = bus_alloc_resource(dev, SYS_RES_IOPORT,
- &fdc->rid_ioport, 0ul, ~0ul,
- ispnp ? 1 : IO_FDCSIZE,
- RF_ACTIVE);
-#else
- /*
- * We don't just use an 8 port range (e.g. 0x3f0-0x3f7) since that
- * covers an IDE control register at 0x3f6.
- * Isn't PC hardware wonderful.
- */
- fdc->res_ioport = bus_alloc_resource(dev, SYS_RES_IOPORT,
- &fdc->rid_ioport, 0ul, ~0ul,
- ispnp ? 1 : 6, RF_ACTIVE);
-#endif
- if (fdc->res_ioport == 0) {
- device_printf(dev, "cannot reserve I/O port range\n");
- return ENXIO;
- }
- fdc->portt = rman_get_bustag(fdc->res_ioport);
- fdc->porth = rman_get_bushandle(fdc->res_ioport);
-
-#ifndef PC98
- /*
- * Some BIOSen report the device at 0x3f2-0x3f5,0x3f7 and some at
- * 0x3f0-0x3f5,0x3f7. We detect the former by checking the size
- * and adjust the port address accordingly.
- */
- if (bus_get_resource_count(dev, SYS_RES_IOPORT, 0) == 4)
- fdc->port_off = -2;
-
- /*
- * Register the control port range as rid 1 if it isn't there
- * already. Most PnP BIOSen will have already done this but
- * non-PnP configurations don't.
- *
- * And some (!!) report 0x3f2-0x3f5 and completely leave out the
- * control register! It seems that some non-antique controller chips
- * have a different method of programming the transfer speed which
- * doesn't require the control register, but it's mighty bogus as the
- * chip still responds to the address for the control register.
- */
- if (bus_get_resource_count(dev, SYS_RES_IOPORT, 1) == 0) {
- u_long ctlstart;
-
- /* Find the control port, usually 0x3f7 */
- ctlstart = rman_get_start(fdc->res_ioport) + fdc->port_off + 7;
-
- bus_set_resource(dev, SYS_RES_IOPORT, 1, ctlstart, 1);
- }
-
- /*
- * Now (finally!) allocate the control port.
- */
- fdc->rid_ctl = 1;
- fdc->res_ctl = bus_alloc_resource(dev, SYS_RES_IOPORT, &fdc->rid_ctl,
- 0ul, ~0ul, 1, RF_ACTIVE);
- if (fdc->res_ctl == 0) {
- device_printf(dev, "cannot reserve control I/O port range\n");
- return ENXIO;
- }
- fdc->ctlt = rman_get_bustag(fdc->res_ctl);
- fdc->ctlh = rman_get_bushandle(fdc->res_ctl);
-#endif
-
- fdc->res_irq = bus_alloc_resource(dev, SYS_RES_IRQ,
- &fdc->rid_irq, 0ul, ~0ul, 1,
- RF_ACTIVE);
- if (fdc->res_irq == 0) {
- device_printf(dev, "cannot reserve interrupt line\n");
- return ENXIO;
- }
- fdc->res_drq = bus_alloc_resource(dev, SYS_RES_DRQ,
- &fdc->rid_drq, 0ul, ~0ul, 1,
- RF_ACTIVE);
- if (fdc->res_drq == 0) {
- device_printf(dev, "cannot reserve DMA request line\n");
- return ENXIO;
- }
- fdc->dmachan = fdc->res_drq->r_start;
-
- return 0;
-}
-
-static void
-fdc_release_resources(struct fdc_data *fdc)
-{
- device_t dev;
-
- dev = fdc->fdc_dev;
- if (fdc->res_irq != 0) {
- bus_deactivate_resource(dev, SYS_RES_IRQ, fdc->rid_irq,
- fdc->res_irq);
- bus_release_resource(dev, SYS_RES_IRQ, fdc->rid_irq,
- fdc->res_irq);
- }
-#ifndef PC98
- if (fdc->res_ctl != 0) {
- bus_deactivate_resource(dev, SYS_RES_IOPORT, fdc->rid_ctl,
- fdc->res_ctl);
- bus_release_resource(dev, SYS_RES_IOPORT, fdc->rid_ctl,
- fdc->res_ctl);
- }
-#endif
- if (fdc->res_ioport != 0) {
- bus_deactivate_resource(dev, SYS_RES_IOPORT, fdc->rid_ioport,
- fdc->res_ioport);
- bus_release_resource(dev, SYS_RES_IOPORT, fdc->rid_ioport,
- fdc->res_ioport);
- }
- if (fdc->res_drq != 0) {
- bus_deactivate_resource(dev, SYS_RES_DRQ, fdc->rid_drq,
- fdc->res_drq);
- bus_release_resource(dev, SYS_RES_DRQ, fdc->rid_drq,
- fdc->res_drq);
- }
-}
-
-/****************************************************************************/
-/* autoconfiguration stuff */
-/****************************************************************************/
-
-static struct isa_pnp_id fdc_ids[] = {
- {0x0007d041, "PC standard floppy disk controller"}, /* PNP0700 */
- {0x0107d041, "Standard floppy controller supporting MS Device Bay Spec"}, /* PNP0701 */
- {0}
-};
-
-static int
-fdc_read_ivar(device_t dev, device_t child, int which, u_long *result)
-{
- struct fdc_ivars *ivars = device_get_ivars(child);
-
- switch (which) {
- case FDC_IVAR_FDUNIT:
- *result = ivars->fdunit;
- break;
- default:
- return ENOENT;
- }
- return 0;
-}
-
-/*
- * fdc controller section.
- */
-static int
-fdc_probe(device_t dev)
-{
- int error, ic_type;
- struct fdc_data *fdc;
-
- fdc = device_get_softc(dev);
- bzero(fdc, sizeof *fdc);
- fdc->fdc_dev = dev;
-
- /* Check pnp ids */
- error = ISA_PNP_PROBE(device_get_parent(dev), dev, fdc_ids);
- if (error == ENXIO)
- return ENXIO;
- fdc->fdc_ispnp = (error == 0);
-
- /* Attempt to allocate our resources for the duration of the probe */
- error = fdc_alloc_resources(fdc);
- if (error)
- goto out;
-
-#ifndef PC98
- /* First - lets reset the floppy controller */
- fdout_wr(fdc, 0);
- DELAY(100);
- fdout_wr(fdc, FDO_FRST);
-#endif
-
- /* see if it can handle a command */
-#ifdef PC98
- if (fd_cmd(fdc, 3, NE7CMD_SPECIFY, NE7_SPEC_1(4, 240),
- NE7_SPEC_2(2, 0), 0)) {
- error = ENXIO;
- goto out;
- }
-#else
- if (fd_cmd(fdc, 3, NE7CMD_SPECIFY, NE7_SPEC_1(3, 240),
- NE7_SPEC_2(2, 0), 0)) {
- error = ENXIO;
- goto out;
- }
-#endif
-
-#ifndef PC98
- if (fd_cmd(fdc, 1, NE7CMD_VERSION, 1, &ic_type) == 0) {
- ic_type = (u_char)ic_type;
- switch (ic_type) {
- case 0x80:
- device_set_desc(dev, "NEC 765 or clone");
- fdc->fdct = FDC_NE765;
- break;
- case 0x81:
- device_set_desc(dev, "Intel 82077 or clone");
- fdc->fdct = FDC_I82077;
- break;
- case 0x90:
- device_set_desc(dev, "NEC 72065B or clone");
- fdc->fdct = FDC_NE72065;
- break;
- default:
- device_set_desc(dev, "generic floppy controller");
- fdc->fdct = FDC_UNKNOWN;
- break;
- }
- }
-#endif
-
-out:
- fdc_release_resources(fdc);
- return (error);
-}
-
-/*
- * Add a child device to the fdc controller. It will then be probed etc.
- */
-static void
-fdc_add_child(device_t dev, const char *name, int unit)
-{
- int disabled;
- struct fdc_ivars *ivar;
- device_t child;
-
- ivar = malloc(sizeof *ivar, M_DEVBUF /* XXX */, M_NOWAIT);
- if (ivar == NULL)
- return;
- bzero(ivar, sizeof *ivar);
- if (resource_int_value(name, unit, "drive", &ivar->fdunit) != 0)
- ivar->fdunit = 0;
- child = device_add_child(dev, name, unit);
- if (child == NULL)
- return;
- device_set_ivars(child, ivar);
- if (resource_int_value(name, unit, "disabled", &disabled) == 0
- && disabled != 0)
- device_disable(child);
-}
-
-static int
-fdc_attach(device_t dev)
-{
- struct fdc_data *fdc;
- int i, error;
-
- fdc = device_get_softc(dev);
- error = fdc_alloc_resources(fdc);
- if (error) {
- device_printf(dev, "cannot re-aquire resources\n");
- return error;
- }
- error = BUS_SETUP_INTR(device_get_parent(dev), dev, fdc->res_irq,
- INTR_TYPE_BIO, fdc_intr, fdc, &fdc->fdc_intr);
- if (error) {
- device_printf(dev, "cannot setup interrupt\n");
- return error;
- }
- fdc->fdcu = device_get_unit(dev);
- fdc->flags |= FDC_ATTACHED;
-
- /* Acquire the DMA channel forever, The driver will do the rest */
- /* XXX should integrate with rman */
- isa_dma_acquire(fdc->dmachan);
- isa_dmainit(fdc->dmachan, 128 << 3 /* XXX max secsize */);
- fdc->state = DEVIDLE;
-
-#ifdef PC98
- /* reset controller, turn motor off, clear fdout mirror reg */
- fdc_reset(fdc);
-#else
- /* reset controller, turn motor off, clear fdout mirror reg */
- fdout_wr(fdc, ((fdc->fdout = 0)));
-#endif
- bufq_init(&fdc->head);
-
- /*
- * Probe and attach any children. We should probably detect
- * devices from the BIOS unless overridden.
- */
- for (i = resource_query_string(-1, "at", device_get_nameunit(dev));
- i != -1;
- i = resource_query_string(i, "at", device_get_nameunit(dev)))
- fdc_add_child(dev, resource_query_name(i),
- resource_query_unit(i));
-
- return (bus_generic_attach(dev));
-}
-
-static int
-fdc_print_child(device_t me, device_t child)
-{
- int retval = 0;
-
- retval += bus_print_child_header(me, child);
- retval += printf(" on %s drive %d\n", device_get_nameunit(me),
- fdc_get_fdunit(child));
-
- return (retval);
-}
-
-static device_method_t fdc_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, fdc_probe),
- DEVMETHOD(device_attach, fdc_attach),
- DEVMETHOD(device_detach, bus_generic_detach),
- DEVMETHOD(device_shutdown, bus_generic_shutdown),
- DEVMETHOD(device_suspend, bus_generic_suspend),
- DEVMETHOD(device_resume, bus_generic_resume),
-
- /* Bus interface */
- DEVMETHOD(bus_print_child, fdc_print_child),
- DEVMETHOD(bus_read_ivar, fdc_read_ivar),
- /* Our children never use any other bus interface methods. */
-
- { 0, 0 }
-};
-
-static driver_t fdc_driver = {
- "fdc",
- fdc_methods,
- sizeof(struct fdc_data)
-};
-
-DRIVER_MODULE(fdc, isa, fdc_driver, fdc_devclass, 0, 0);
-
-/******************************************************************/
-/*
- * devices attached to the controller section.
- */
-static int
-fd_probe(device_t dev)
-{
- int i;
- u_int fdt, st0, st3;
- struct fd_data *fd;
- struct fdc_data *fdc;
- fdsu_t fdsu;
- static int fd_fifo = 0;
-
- fdsu = *(int *)device_get_ivars(dev); /* xxx cheat a bit... */
- fd = device_get_softc(dev);
- fdc = device_get_softc(device_get_parent(dev));
-
- bzero(fd, sizeof *fd);
- fd->dev = dev;
- fd->fdc = fdc;
- fd->fdsu = fdsu;
- fd->fdu = device_get_unit(dev);
-
-#ifdef PC98
- /* look up what bios thinks we have */
- switch (fd->fdu) {
- case 0: case 1: case 2: case 3:
- if ((PC98_SYSTEM_PARAMETER(0x5ae) >> fd->fdu) & 0x01)
- fdt = FDT_144M;
-#ifdef EPSON_NRDISK
- else if ((PC98_SYSTEM_PARAMETER(0x55c) >> fd->fdu) & 0x01) {
- fdt = FDT_12M;
- switch (epson_machine_id) {
- case 0x20: case 0x27:
- if ((PC98_SYSTEM_PARAMETER(0x488) >> fd->fdu) & 0x01) {
- if (nrd_check_ready()) {
- nrd_LED_on();
- nrdu = fd->fdu;
- } else {
- fdt = FDT_NONE;
- }
- }
- }
- }
-#else /* !EPSON_NRDISK */
- else if ((PC98_SYSTEM_PARAMETER(0x55c) >> fd->fdu) & 0x01) {
- fdt = FDT_12M;
- switch (epson_machine_id) {
- case 0x20: case 0x27:
- if ((PC98_SYSTEM_PARAMETER(0x488) >> fd->fdu) & 0x01)
- fdt = FDT_NONE;
- }
- }
-#endif /* EPSON_NRDISK */
- else
- fdt = FDT_NONE;
- break;
- default:
- fdt = FDT_NONE;
- break;
- }
-#else
-#ifdef __i386__
- /* look up what bios thinks we have */
- switch (fd->fdu) {
- case 0:
- if (device_get_flags(fdc->fdc_dev) & FDC_PRETEND_D0)
- fdt = RTCFDT_144M | RTCFDT_144M_PRETENDED;
- else
- fdt = (rtcin(RTC_FDISKETTE) & 0xf0);
- break;
- case 1:
- fdt = ((rtcin(RTC_FDISKETTE) << 4) & 0xf0);
- break;
- default:
- fdt = RTCFDT_NONE;
- break;
- }
-#else
- fdt = RTCFDT_144M; /* XXX probably */
-#endif
-#endif
-
- /* is there a unit? */
-#ifdef PC98
- if (fdt == FDT_NONE)
- return (ENXIO);
-#else
- if (fdt == RTCFDT_NONE)
- return (ENXIO);
-#endif
-
-#ifndef PC98
- /* select it */
- set_motor(fdc, fdsu, TURNON);
- DELAY(1000000); /* 1 sec */
-
- /* XXX This doesn't work before the first set_motor() */
- if (fd_fifo == 0 && fdc->fdct != FDC_NE765 && fdc->fdct != FDC_UNKNOWN
- && (device_get_flags(fdc->fdc_dev) & FDC_NO_FIFO) == 0
- && enable_fifo(fdc) == 0) {
- device_printf(device_get_parent(dev),
- "FIFO enabled, %d bytes threshold\n", fifo_threshold);
- }
- fd_fifo = 1;
-
- if ((fd_cmd(fdc, 2, NE7CMD_SENSED, fdsu, 1, &st3) == 0)
- && (st3 & NE7_ST3_T0)) {
- /* if at track 0, first seek inwards */
- /* seek some steps: */
- fd_cmd(fdc, 3, NE7CMD_SEEK, fdsu, 10, 0);
- DELAY(300000); /* ...wait a moment... */
- fd_sense_int(fdc, 0, 0); /* make ctrlr happy */
- }
-
- /* If we're at track 0 first seek inwards. */
- if ((fd_sense_drive_status(fdc, &st3) == 0) && (st3 & NE7_ST3_T0)) {
- /* Seek some steps... */
- if (fd_cmd(fdc, 3, NE7CMD_SEEK, fdsu, 10, 0) == 0) {
- /* ...wait a moment... */
- DELAY(300000);
- /* make ctrlr happy: */
- fd_sense_int(fdc, 0, 0);
- }
- }
-
- for (i = 0; i < 2; i++) {
- /*
- * we must recalibrate twice, just in case the
- * heads have been beyond cylinder 76, since most
- * FDCs still barf when attempting to recalibrate
- * more than 77 steps
- */
- /* go back to 0: */
- if (fd_cmd(fdc, 2, NE7CMD_RECAL, fdsu, 0) == 0) {
- /* a second being enough for full stroke seek*/
- DELAY(i == 0 ? 1000000 : 300000);
-
- /* anything responding? */
- if (fd_sense_int(fdc, &st0, 0) == 0 &&
- (st0 & NE7_ST0_EC) == 0)
- break; /* already probed succesfully */
- }
- }
-
- set_motor(fdc, fdsu, TURNOFF);
-
- if (st0 & NE7_ST0_EC) /* no track 0 -> no drive present */
- return (ENXIO);
-#endif /* PC98 */
-
- fd->track = FD_NO_TRACK;
- fd->fdc = fdc;
- fd->fdsu = fdsu;
- fd->options = 0;
- callout_handle_init(&fd->toffhandle);
- callout_handle_init(&fd->tohandle);
-
-#ifdef PC98
- switch (fdt) {
- case FDT_144M:
- /* Check 3mode I/F */
- fd->pc98_trans = 0;
- outb(0x4be, (fd->fdu << 5) | 0x10);
- if (!(inb(0x4be) & 0x01)) {
- device_set_desc(dev, "1.44M FDD");
- fd->type = FD_1440;
- break;
- }
-
- printf("Warning: can't control 3mode I/F, "
- "fallback to 2mode.\n"
- "fd%d: ", fd->fdu);
- /* FALLTHROUGH */
- case FDT_12M:
-#ifdef EPSON_NRDISK
- if (fd->fdu == nrdu) {
- device_set_desc(dev, "EPSON RAM DRIVE");
- nrd_LED_off();
- } else
-#endif
- device_set_desc(dev, "1M/640K FDD");
- fd->type = FD_1200;
- fd->pc98_trans = 0;
- break;
- default:
- return (ENXIO);
- }
-#else
- switch (fdt) {
- case RTCFDT_12M:
- device_set_desc(dev, "1200-KB 5.25\" drive");
- fd->type = FD_1200;
- break;
- case RTCFDT_144M | RTCFDT_144M_PRETENDED:
- device_set_desc(dev, "config-pretended 1440-MB 3.5\" drive");
- fdt = RTCFDT_144M;
- fd->type = FD_1440;
- case RTCFDT_144M:
- device_set_desc(dev, "1440-KB 3.5\" drive");
- fd->type = FD_1440;
- break;
- case RTCFDT_288M:
- case RTCFDT_288M_1:
- device_set_desc(dev, "2880-KB 3.5\" drive (in 1440-KB mode)");
- fd->type = FD_1440;
- break;
- case RTCFDT_360K:
- device_set_desc(dev, "360-KB 5.25\" drive");
- fd->type = FD_360;
- break;
- case RTCFDT_720K:
- printf("720-KB 3.5\" drive");
- fd->type = FD_720;
- break;
- default:
- return (ENXIO);
- }
-#endif
- return (0);
-}
-
-static int
-fd_attach(device_t dev)
-{
- struct fd_data *fd;
-#if 0
- int i;
- int mynor;
- int typemynor;
- int typesize;
-#endif
-
- fd = device_get_softc(dev);
-
- cdevsw_add(&fd_cdevsw); /* XXX */
- make_dev(&fd_cdevsw, (fd->fdu << 6),
- UID_ROOT, GID_OPERATOR, 0640, "rfd%d", fd->fdu);
-
-#if 0
- /* Other make_dev() go here. */
-#endif
-
- /*
- * Export the drive to the devstat interface.
- */
- devstat_add_entry(&fd->device_stats, device_get_name(dev),
- device_get_unit(dev), 512, DEVSTAT_NO_ORDERED_TAGS,
- DEVSTAT_TYPE_FLOPPY | DEVSTAT_TYPE_IF_OTHER,
- DEVSTAT_PRIORITY_FD);
- return (0);
-}
-
-static device_method_t fd_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, fd_probe),
- DEVMETHOD(device_attach, fd_attach),
- DEVMETHOD(device_detach, bus_generic_detach),
- DEVMETHOD(device_shutdown, bus_generic_shutdown),
- DEVMETHOD(device_suspend, bus_generic_suspend), /* XXX */
- DEVMETHOD(device_resume, bus_generic_resume), /* XXX */
-
- { 0, 0 }
-};
-
-static driver_t fd_driver = {
- "fd",
- fd_methods,
- sizeof(struct fd_data)
-};
-
-DRIVER_MODULE(fd, fdc, fd_driver, fd_devclass, 0, 0);
-
-/******************************************************************/
-
-#ifdef FDC_YE
-/*
- * this is a subset of fdattach() optimized for the Y-E Data
- * PCMCIA floppy drive.
- */
-static int yeattach(struct isa_device *dev)
-{
- fdcu_t fdcu = dev->id_unit;
- fdc_p fdc = fdc_data + fdcu;
- fdsu_t fdsu = 0; /* assume 1 drive per YE controller */
- fdu_t fdu;
- fd_p fd;
- int st0, st3, i;
- fdc->fdcu = fdcu;
- /*
- * the FDC_NODMA flag is used to to indicate special PIO is used
- * instead of DMA
- */
- fdc->flags = FDC_ATTACHED|FDC_NODMA;
- fdc->state = DEVIDLE;
- /* reset controller, turn motor off, clear fdout mirror reg */
- fdout_wr(fdc, ((fdc->fdout = 0)));
- bufq_init(&fdc->head);
- /*
- * assume 2 drives/ "normal" controller
- */
- fdu = fdcu * 2;
- if (fdu >= NFD) {
- printf("fdu %d >= NFD\n",fdu);
- return(0);
- };
- fd = &fd_data[fdu];
-
- set_motor(fdcu, fdsu, TURNON);
- DELAY(1000000); /* 1 sec */
- fdc->fdct = FDC_NE765;
-
- if ((fd_cmd(fdcu, 2, NE7CMD_SENSED, fdsu, 1, &st3) == 0) &&
- (st3 & NE7_ST3_T0)) {
- /* if at track 0, first seek inwards */
- /* seek some steps: */
- (void)fd_cmd(fdcu, 3, NE7CMD_SEEK, fdsu, 10, 0);
- DELAY(300000); /* ...wait a moment... */
- (void)fd_sense_int(fdc, 0, 0); /* make ctrlr happy */
- }
-
- /* If we're at track 0 first seek inwards. */
- if ((fd_sense_drive_status(fdc, &st3) == 0) && (st3 & NE7_ST3_T0)) {
- /* Seek some steps... */
- if (fd_cmd(fdcu, 3, NE7CMD_SEEK, fdsu, 10, 0) == 0) {
- /* ...wait a moment... */
- DELAY(300000);
- /* make ctrlr happy: */
- (void)fd_sense_int(fdc, 0, 0);
- }
- }
-
- for(i = 0; i < 2; i++) {
- /*
- * we must recalibrate twice, just in case the
- * heads have been beyond cylinder 76, since most
- * FDCs still barf when attempting to recalibrate
- * more than 77 steps
- */
- /* go back to 0: */
- if (fd_cmd(fdcu, 2, NE7CMD_RECAL, fdsu, 0) == 0) {
- /* a second being enough for full stroke seek*/
- DELAY(i == 0? 1000000: 300000);
-
- /* anything responding? */
- if (fd_sense_int(fdc, &st0, 0) == 0 &&
- (st0 & NE7_ST0_EC) == 0)
- break; /* already probed succesfully */
- }
- }
-
- set_motor(fdcu, fdsu, TURNOFF);
-
- if (st0 & NE7_ST0_EC) /* no track 0 -> no drive present */
- return(0);
-
- fd->track = FD_NO_TRACK;
- fd->fdc = fdc;
- fd->fdsu = fdsu;
- fd->options = 0;
- printf("fdc%d: 1.44MB 3.5in PCMCIA\n", fdcu);
- fd->type = FD_1440;
-
- return (1);
-}
-#endif
-
-/****************************************************************************/
-/* motor control stuff */
-/* remember to not deselect the drive we're working on */
-/****************************************************************************/
-static void
-set_motor(struct fdc_data *fdc, int fdsu, int turnon)
-{
- int fdout = fdc->fdout;
- int needspecify = 0;
-
-#ifdef PC98
- outb(IO_FDPORT, (pc98_trans != 1 ? FDP_FDDEXC : 0)|FDP_PORTEXC);
- DELAY(10);
- fdout = FDO_DMAE|FDO_MTON;
-#else
- if(turnon) {
- fdout &= ~FDO_FDSEL;
- fdout |= (FDO_MOEN0 << fdsu) + fdsu;
- } else
- fdout &= ~(FDO_MOEN0 << fdsu);
-
- if(!turnon
- && (fdout & (FDO_MOEN0+FDO_MOEN1+FDO_MOEN2+FDO_MOEN3)) == 0)
- /* gonna turn off the last drive, put FDC to bed */
- fdout &= ~ (FDO_FRST|FDO_FDMAEN);
- else {
- /* make sure controller is selected and specified */
- if((fdout & (FDO_FRST|FDO_FDMAEN)) == 0)
- needspecify = 1;
- fdout |= (FDO_FRST|FDO_FDMAEN);
- }
-#endif
-
- fdout_wr(fdc, fdout);
- fdc->fdout = fdout;
- TRACE1("[0x%x->FDOUT]", fdout);
-
- if (needspecify) {
- /*
- * XXX
- * special case: since we have just woken up the FDC
- * from its sleep, we silently assume the command will
- * be accepted, and do not test for a timeout
- */
-#ifdef PC98
- (void)fd_cmd(fdc, 3, NE7CMD_SPECIFY,
- NE7_SPEC_1(4, 240), NE7_SPEC_2(2, 0),
- 0);
-#else
- (void)fd_cmd(fdc, 3, NE7CMD_SPECIFY,
- NE7_SPEC_1(3, 240), NE7_SPEC_2(2, 0),
- 0);
-#endif
- if (fdc->flags & FDC_HAS_FIFO)
- (void) enable_fifo(fdc);
- }
-}
-
-static void
-fd_turnoff(void *xfd)
-{
- int s;
- fd_p fd = xfd;
-
- TRACE1("[fd%d: turnoff]", fd->fdu);
-
- /*
- * Don't turn off the motor yet if the drive is active.
- * XXX shouldn't even schedule turnoff until drive is inactive
- * and nothing is queued on it.
- */
- if (fd->fdc->state != DEVIDLE && fd->fdc->fdu == fd->fdu) {
- fd->toffhandle = timeout(fd_turnoff, fd, 4 * hz);
- return;
- }
-
- s = splbio();
- fd->flags &= ~FD_MOTOR;
- set_motor(fd->fdc, fd->fdsu, TURNOFF);
- splx(s);
-}
-
-static void
-fd_motor_on(void *xfd)
-{
- int s;
- fd_p fd = xfd;
-
- s = splbio();
- fd->flags &= ~FD_MOTOR_WAIT;
- if((fd->fdc->fd == fd) && (fd->fdc->state == MOTORWAIT))
- {
- fdc_intr(fd->fdc);
- }
- splx(s);
-}
-
-static void
-fd_turnon(fd_p fd)
-{
- if(!(fd->flags & FD_MOTOR))
- {
- fd->flags |= (FD_MOTOR + FD_MOTOR_WAIT);
- set_motor(fd->fdc, fd->fdsu, TURNON);
- timeout(fd_motor_on, fd, hz); /* in 1 sec its ok */
- }
-}
-
-static void
-fdc_reset(fdc_p fdc)
-{
- /* Try a reset, keep motor on */
-#ifdef PC98
- set_density(fdc);
- if (pc98_machine_type & M_EPSON_PC98)
- fdout_wr(fdc, 0xe8);
- else
- fdout_wr(fdc, 0xd8);
- DELAY(200);
- fdout_wr(fdc, 0x18);
- DELAY(10);
-#else
- fdout_wr(fdc, fdc->fdout & ~(FDO_FRST|FDO_FDMAEN));
- TRACE1("[0x%x->FDOUT]", fdc->fdout & ~(FDO_FRST|FDO_FDMAEN));
- DELAY(100);
- /* enable FDC, but defer interrupts a moment */
- fdout_wr(fdc, fdc->fdout & ~FDO_FDMAEN);
- TRACE1("[0x%x->FDOUT]", fdc->fdout & ~FDO_FDMAEN);
- DELAY(100);
- fdout_wr(fdc, fdc->fdout);
- TRACE1("[0x%x->FDOUT]", fdc->fdout);
-#endif
-
- /* XXX after a reset, silently believe the FDC will accept commands */
-#ifdef PC98
- (void)fd_cmd(fdc, 3, NE7CMD_SPECIFY,
- NE7_SPEC_1(4, 240), NE7_SPEC_2(2, 0),
- 0);
-#else
- (void)fd_cmd(fdc, 3, NE7CMD_SPECIFY,
- NE7_SPEC_1(3, 240), NE7_SPEC_2(2, 0),
- 0);
-#endif
- if (fdc->flags & FDC_HAS_FIFO)
- (void) enable_fifo(fdc);
-}
-
-/****************************************************************************/
-/* fdc in/out */
-/****************************************************************************/
-int
-in_fdc(struct fdc_data *fdc)
-{
- int i, j = 100000;
- while ((i = fdsts_rd(fdc) & (NE7_DIO|NE7_RQM))
- != (NE7_DIO|NE7_RQM) && j-- > 0)
- if (i == NE7_RQM)
- return fdc_err(fdc, "ready for output in input\n");
- if (j <= 0)
- return fdc_err(fdc, bootverbose? "input ready timeout\n": 0);
-#ifdef FDC_DEBUG
- i = fddata_rd(fdc);
- TRACE1("[FDDATA->0x%x]", (unsigned char)i);
- return(i);
-#else /* !FDC_DEBUG */
- return fddata_rd(fdc);
-#endif /* FDC_DEBUG */
-}
-
-/*
- * fd_in: Like in_fdc, but allows you to see if it worked.
- */
-static int
-fd_in(struct fdc_data *fdc, int *ptr)
-{
- int i, j = 100000;
- while ((i = fdsts_rd(fdc) & (NE7_DIO|NE7_RQM))
- != (NE7_DIO|NE7_RQM) && j-- > 0)
- if (i == NE7_RQM)
- return fdc_err(fdc, "ready for output in input\n");
- if (j <= 0)
- return fdc_err(fdc, bootverbose? "input ready timeout\n": 0);
-#ifdef FDC_DEBUG
- i = fddata_rd(fdc);
- TRACE1("[FDDATA->0x%x]", (unsigned char)i);
- *ptr = i;
- return 0;
-#else /* !FDC_DEBUG */
- i = fddata_rd(fdc);
- if (ptr)
- *ptr = i;
- return 0;
-#endif /* FDC_DEBUG */
-}
-
-int
-out_fdc(struct fdc_data *fdc, int x)
-{
- int i;
-
- /* Check that the direction bit is set */
- i = 100000;
- while ((fdsts_rd(fdc) & NE7_DIO) && i-- > 0);
- if (i <= 0) return fdc_err(fdc, "direction bit not set\n");
-
- /* Check that the floppy controller is ready for a command */
- i = 100000;
- while ((fdsts_rd(fdc) & NE7_RQM) == 0 && i-- > 0);
- if (i <= 0)
- return fdc_err(fdc, bootverbose? "output ready timeout\n": 0);
-
- /* Send the command and return */
- fddata_wr(fdc, x);
- TRACE1("[0x%x->FDDATA]", x);
- return (0);
-}
-
-/****************************************************************************/
-/* fdopen/fdclose */
-/****************************************************************************/
-int
-Fdopen(dev_t dev, int flags, int mode, struct proc *p)
-{
- fdu_t fdu = FDUNIT(minor(dev));
- int type = FDTYPE(minor(dev));
- fd_p fd;
- fdc_p fdc;
-
- /* check bounds */
- if ((fd = devclass_get_softc(fd_devclass, fdu)) == 0)
- return (ENXIO);
- fdc = fd->fdc;
- if ((fdc == NULL) || (fd->type == NO_TYPE))
- return (ENXIO);
- if (type > NUMDENS)
- return (ENXIO);
-#ifdef PC98
- if (type == 0)
- type = FD_1200; /* XXX backward compatibility */
- else
- ; /* XXX any types are OK for PC-98 */
-
- if (pc98_fd_check_ready(fdu) == -1)
- return(EIO);
-#else
- if (type == 0)
- type = fd->type;
- else {
- /*
- * For each type of basic drive, make sure we are trying
- * to open a type it can do,
- */
- if (type != fd->type) {
- switch (fd->type) {
- case FD_360:
- return (ENXIO);
- case FD_720:
- if ( type != FD_820
- && type != FD_800
- && type != FD_640
- )
- return (ENXIO);
- break;
- case FD_1200:
- switch (type) {
- case FD_1480:
- type = FD_1480in5_25;
- break;
- case FD_1440:
- type = FD_1440in5_25;
- break;
- case FD_1232:
- break;
- case FD_820:
- type = FD_820in5_25;
- break;
- case FD_800:
- type = FD_800in5_25;
- break;
- case FD_720:
- type = FD_720in5_25;
- break;
- case FD_640:
- type = FD_640in5_25;
- break;
- case FD_360:
- type = FD_360in5_25;
- break;
- default:
- return(ENXIO);
- }
- break;
- case FD_1440:
- if ( type != FD_1720
- && type != FD_1480
- && type != FD_1200
- && type != FD_820
- && type != FD_800
- && type != FD_720
- && type != FD_640
- )
- return(ENXIO);
- break;
- }
- }
- }
-#endif
- fd->ft = fd_types + type - 1;
- fd->flags |= FD_OPEN;
- device_busy(fd->dev);
- device_busy(fd->fdc->fdc_dev);
- return 0;
-}
-
-int
-fdclose(dev_t dev, int flags, int mode, struct proc *p)
-{
- fdu_t fdu = FDUNIT(minor(dev));
- struct fd_data *fd;
-
- fd = devclass_get_softc(fd_devclass, fdu);
- fd->flags &= ~FD_OPEN;
- fd->options &= ~FDOPT_NORETRY;
-
- return (0);
-}
-
-/****************************************************************************/
-/* fdstrategy */
-/****************************************************************************/
-void
-fdstrategy(struct buf *bp)
-{
- unsigned nblocks, blknum, cando;
- int s;
- fdu_t fdu;
- fdc_p fdc;
- fd_p fd;
- size_t fdblk;
-
- fdu = FDUNIT(minor(bp->b_dev));
- fd = devclass_get_softc(fd_devclass, fdu);
- if (fd == 0)
- panic("fdstrategy: buf for nonexistent device (%#lx, %#lx)",
- (u_long)major(bp->b_dev), (u_long)minor(bp->b_dev));
- fdc = fd->fdc;
- if (fd->type == NO_TYPE) {
- bp->b_error = ENXIO;
- bp->b_flags |= B_ERROR;
- goto bad;
- };
-
- fdblk = 128 << (fd->ft->secsize);
- if (!(bp->b_flags & B_FORMAT)) {
- if (bp->b_blkno < 0) {
- printf(
- "fd%d: fdstrat: bad request blkno = %lu, bcount = %ld\n",
- fdu, (u_long)bp->b_blkno, bp->b_bcount);
- bp->b_error = EINVAL;
- bp->b_flags |= B_ERROR;
- goto bad;
- }
- if ((bp->b_bcount % fdblk) != 0) {
- bp->b_error = EINVAL;
- bp->b_flags |= B_ERROR;
- goto bad;
- }
- }
-
- /*
- * Set up block calculations.
- */
- if (bp->b_blkno > 20000000) {
- /*
- * Reject unreasonably high block number, prevent the
- * multiplication below from overflowing.
- */
- bp->b_error = EINVAL;
- bp->b_flags |= B_ERROR;
- goto bad;
- }
- blknum = (unsigned) bp->b_blkno * DEV_BSIZE/fdblk;
- nblocks = fd->ft->size;
- bp->b_resid = 0;
- if (blknum + (bp->b_bcount / fdblk) > nblocks) {
- if (blknum <= nblocks) {
- cando = (nblocks - blknum) * fdblk;
- bp->b_resid = bp->b_bcount - cando;
- if (cando == 0)
- goto bad; /* not actually bad but EOF */
- } else {
- bp->b_error = EINVAL;
- bp->b_flags |= B_ERROR;
- goto bad;
- }
- }
- bp->b_pblkno = bp->b_blkno;
- s = splbio();
- bufqdisksort(&fdc->head, bp);
- untimeout(fd_turnoff, fd, fd->toffhandle); /* a good idea */
-
- /* Tell devstat we are starting on the transaction */
- devstat_start_transaction(&fd->device_stats);
-
- fdstart(fdc);
- splx(s);
- return;
-
-bad:
- biodone(bp);
-}
-
-/***************************************************************\
-* fdstart *
-* We have just queued something.. if the controller is not busy *
-* then simulate the case where it has just finished a command *
-* So that it (the interrupt routine) looks on the queue for more*
-* work to do and picks up what we just added. *
-* If the controller is already busy, we need do nothing, as it *
-* will pick up our work when the present work completes *
-\***************************************************************/
-static void
-fdstart(struct fdc_data *fdc)
-{
- int s;
-
- s = splbio();
- if(fdc->state == DEVIDLE)
- {
- fdc_intr(fdc);
- }
- splx(s);
-}
-
-static void
-fd_iotimeout(void *xfdc)
-{
- fdc_p fdc;
- int s;
-
- fdc = xfdc;
- TRACE1("fd%d[fd_iotimeout()]", fdc->fdu);
-
- /*
- * Due to IBM's brain-dead design, the FDC has a faked ready
- * signal, hardwired to ready == true. Thus, any command
- * issued if there's no diskette in the drive will _never_
- * complete, and must be aborted by resetting the FDC.
- * Many thanks, Big Blue!
- * The FDC must not be reset directly, since that would
- * interfere with the state machine. Instead, pretend that
- * the command completed but was invalid. The state machine
- * will reset the FDC and retry once.
- */
- s = splbio();
- fdc->status[0] = NE7_ST0_IC_IV;
- fdc->flags &= ~FDC_STAT_VALID;
- fdc->state = IOTIMEDOUT;
- fdc_intr(fdc);
- splx(s);
-}
-
-/* just ensure it has the right spl */
-static void
-fd_pseudointr(void *xfdc)
-{
- int s;
-
- s = splbio();
- fdc_intr(xfdc);
- splx(s);
-}
-
-/***********************************************************************\
-* fdintr *
-* keep calling the state machine until it returns a 0 *
-* ALWAYS called at SPLBIO *
-\***********************************************************************/
-static void
-fdc_intr(void *xfdc)
-{
- fdc_p fdc = xfdc;
- while(fdstate(fdc))
- ;
-}
-
-/*
- * magic pseudo-DMA initialization for YE FDC. Sets count and
- * direction
- */
-#define SET_BCDR(fdc,wr,cnt,port) \
- bus_space_write_1(fdc->portt, fdc->porth, fdc->port_off + port, \
- ((cnt)-1) & 0xff); \
- bus_space_write_1(fdc->portt, fdc->porth, fdc->port_off + port + 1, \
- ((wr ? 0x80 : 0) | ((((cnt)-1) >> 8) & 0x7f)));
-
-/*
- * fdcpio(): perform programmed IO read/write for YE PCMCIA floppy
- */
-static int fdcpio(fdc_p fdc, long flags, caddr_t addr, u_int count)
-{
- u_char *cptr = (u_char *)addr;
-
- if (flags & B_READ) {
- if (fdc->state != PIOREAD) {
- fdc->state = PIOREAD;
- return(0);
- };
- SET_BCDR(fdc, 0, count, 0);
- bus_space_read_multi_1(fdc->portt, fdc->porth, fdc->port_off +
- FDC_YE_DATAPORT, cptr, count);
- } else {
- bus_space_write_multi_1(fdc->portt, fdc->porth, fdc->port_off +
- FDC_YE_DATAPORT, cptr, count);
- SET_BCDR(fdc, 0, count, 0);
- };
- return(1);
-}
-
-/***********************************************************************\
-* The controller state machine. *
-* if it returns a non zero value, it should be called again immediatly *
-\***********************************************************************/
-static int
-fdstate(fdc_p fdc)
-{
- int read, format, head, i, sec = 0, sectrac, st0, cyl, st3;
- unsigned blknum = 0, b_cylinder = 0;
- fdu_t fdu = fdc->fdu;
- fd_p fd;
- register struct buf *bp;
- struct fd_formb *finfo = NULL;
- size_t fdblk;
-
- bp = fdc->bp;
- if (bp == NULL) {
- bp = bufq_first(&fdc->head);
- if (bp != NULL) {
- bufq_remove(&fdc->head, bp);
- fdc->bp = bp;
- }
- }
- if (bp == NULL) {
- /***********************************************\
- * nothing left for this controller to do *
- * Force into the IDLE state, *
- \***********************************************/
- fdc->state = DEVIDLE;
- if (fdc->fd) {
- device_printf(fdc->fdc_dev,
- "unexpected valid fd pointer\n");
- fdc->fd = (fd_p) 0;
- fdc->fdu = -1;
- }
- TRACE1("[fdc%d IDLE]", fdc->fdcu);
- return (0);
- }
- fdu = FDUNIT(minor(bp->b_dev));
- fd = devclass_get_softc(fd_devclass, fdu);
- fdblk = 128 << fd->ft->secsize;
- if (fdc->fd && (fd != fdc->fd))
- device_printf(fd->dev, "confused fd pointers\n");
- read = bp->b_flags & B_READ;
- format = bp->b_flags & B_FORMAT;
- if (format) {
- finfo = (struct fd_formb *)bp->b_data;
- fd->skip = (char *)&(finfo->fd_formb_cylno(0))
- - (char *)finfo;
- }
- if (fdc->state == DOSEEK || fdc->state == SEEKCOMPLETE) {
- blknum = (unsigned) bp->b_pblkno * DEV_BSIZE/fdblk +
- fd->skip/fdblk;
- b_cylinder = blknum / (fd->ft->sectrac * fd->ft->heads);
- }
- TRACE1("fd%d", fdu);
- TRACE1("[%s]", fdstates[fdc->state]);
- TRACE1("(0x%x)", fd->flags);
- untimeout(fd_turnoff, fd, fd->toffhandle);
- fd->toffhandle = timeout(fd_turnoff, fd, 4 * hz);
- switch (fdc->state)
- {
- case DEVIDLE:
- case FINDWORK: /* we have found new work */
- fdc->retry = 0;
- fd->skip = 0;
- fdc->fd = fd;
- fdc->fdu = fdu;
-#ifdef PC98
- pc98_trans = fd->ft->trans;
- if (pc98_trans_prev != pc98_trans) {
- int i;
- set_density(fdc);
- for (i = 0; i < 10; i++) {
- outb(0x5f, 0);
- outb(0x5f, 0);
- }
- pc98_trans_prev = pc98_trans;
- }
- if (pc98_trans != fd->pc98_trans) {
- if (fd->type == FD_1440) {
- outb(0x4be, (fdu << 5) | 0x10 | (pc98_trans >> 1));
- outb(0x5f, 0);
- outb(0x5f, 0);
- }
- fd->pc98_trans = pc98_trans;
- }
-#else
- fdctl_wr(fdc, fd->ft->trans);
-#endif
- TRACE1("[0x%x->FDCTL]", fd->ft->trans);
- /*******************************************************\
- * If the next drive has a motor startup pending, then *
- * it will start up in its own good time *
- \*******************************************************/
- if(fd->flags & FD_MOTOR_WAIT) {
- fdc->state = MOTORWAIT;
- return (0); /* come back later */
- }
- /*******************************************************\
- * Maybe if it's not starting, it SHOULD be starting *
- \*******************************************************/
-#ifdef EPSON_NRDISK
- if (fdu != nrdu) {
- if (!(fd->flags & FD_MOTOR))
- {
- fdc->state = MOTORWAIT;
- fd_turnon(fdu);
- return(0);
- }
- else /* at least make sure we are selected */
- {
- set_motor(fdcu, fd->fdsu, TURNON);
- }
- }
-#else /* !EPSON_NRDISK */
- if (!(fd->flags & FD_MOTOR))
- {
- fdc->state = MOTORWAIT;
- fd_turnon(fd);
- return (0);
- }
- else /* at least make sure we are selected */
- {
- set_motor(fdc, fd->fdsu, TURNON);
- }
-#endif
- if (fdc->flags & FDC_NEEDS_RESET) {
- fdc->state = RESETCTLR;
- fdc->flags &= ~FDC_NEEDS_RESET;
- } else
- fdc->state = DOSEEK;
- break;
- case DOSEEK:
- if (b_cylinder == (unsigned)fd->track)
- {
- fdc->state = SEEKCOMPLETE;
- break;
- }
-#ifdef PC98
- pc98_fd_check_ready(fdu);
-#endif
- if (fd_cmd(fdc, 3, NE7CMD_SEEK,
- fd->fdsu, b_cylinder * fd->ft->steptrac,
- 0))
- {
- /*
- * seek command not accepted, looks like
- * the FDC went off to the Saints...
- */
- fdc->retry = 6; /* try a reset */
- return(retrier(fdc));
- }
- fd->track = FD_NO_TRACK;
- fdc->state = SEEKWAIT;
- return(0); /* will return later */
- case SEEKWAIT:
- /* allow heads to settle */
- timeout(fd_pseudointr, fdc, hz / 16);
- fdc->state = SEEKCOMPLETE;
- return(0); /* will return later */
- case SEEKCOMPLETE : /* SEEK DONE, START DMA */
- /* Make sure seek really happened*/
- if(fd->track == FD_NO_TRACK) {
- int descyl = b_cylinder * fd->ft->steptrac;
- do {
- /*
- * This might be a "ready changed" interrupt,
- * which cannot really happen since the
- * RDY pin is hardwired to + 5 volts. This
- * generally indicates a "bouncing" intr
- * line, so do one of the following:
- *
- * When running on an enhanced FDC that is
- * known to not go stuck after responding
- * with INVALID, fetch all interrupt states
- * until seeing either an INVALID or a
- * real interrupt condition.
- *
- * When running on a dumb old NE765, give
- * up immediately. The controller will
- * provide up to four dummy RC interrupt
- * conditions right after reset (for the
- * corresponding four drives), so this is
- * our only chance to get notice that it
- * was not the FDC that caused the interrupt.
- */
- if (fd_sense_int(fdc, &st0, &cyl)
- == FD_NOT_VALID)
- return 0;
- if(fdc->fdct == FDC_NE765
- && (st0 & NE7_ST0_IC) == NE7_ST0_IC_RC)
- return 0; /* hope for a real intr */
- } while ((st0 & NE7_ST0_IC) == NE7_ST0_IC_RC);
-
- if (0 == descyl) {
- int failed = 0;
- /*
- * seek to cyl 0 requested; make sure we are
- * really there
- */
- if (fd_sense_drive_status(fdc, &st3))
- failed = 1;
-#ifdef EPSON_NRDISK
- if (fdu == nrdu) st3 = NE7_ST3_T0;
-#endif /* EPSON_NRDISK */
- if ((st3 & NE7_ST3_T0) == 0) {
- printf(
- "fd%d: Seek to cyl 0, but not really there (ST3 = %b)\n",
- fdu, st3, NE7_ST3BITS);
- failed = 1;
- }
-
- if (failed) {
- if(fdc->retry < 3)
- fdc->retry = 3;
- return (retrier(fdc));
- }
- }
-#ifdef EPSON_NRDISK
- if (fdu == nrdu) cyl = descyl;
-#endif
-
- if (cyl != descyl) {
- printf(
- "fd%d: Seek to cyl %d failed; am at cyl %d (ST0 = 0x%x)\n",
- fdu, descyl, cyl, st0);
- if (fdc->retry < 3)
- fdc->retry = 3;
- return (retrier(fdc));
- }
- }
-
- fd->track = b_cylinder;
-#ifdef EPSON_NRDISK
- if (fdu != nrdu) {
-#endif /* EPSON_NRDISK */
- if (!(fdc->flags & FDC_NODMA))
- isa_dmastart(bp->b_flags, bp->b_data+fd->skip,
- format ? bp->b_bcount : fdblk, fdc->dmachan);
- sectrac = fd->ft->sectrac;
- sec = blknum % (sectrac * fd->ft->heads);
- head = sec / sectrac;
- sec = sec % sectrac + 1;
- fd->hddrv = ((head&1)<<2)+fdu;
-
- if(format || !read)
- {
- /* make sure the drive is writable */
- if(fd_sense_drive_status(fdc, &st3) != 0)
- {
- /* stuck controller? */
- isa_dmadone(bp->b_flags, bp->b_data + fd->skip,
- format ? bp->b_bcount : fdblk,
- fdc->dmachan);
- fdc->retry = 6; /* reset the beast */
- return (retrier(fdc));
- }
- if(st3 & NE7_ST3_WP)
- {
- /*
- * XXX YES! this is ugly.
- * in order to force the current operation
- * to fail, we will have to fake an FDC
- * error - all error handling is done
- * by the retrier()
- */
- fdc->status[0] = NE7_ST0_IC_AT;
- fdc->status[1] = NE7_ST1_NW;
- fdc->status[2] = 0;
- fdc->status[3] = fd->track;
- fdc->status[4] = head;
- fdc->status[5] = sec;
- fdc->retry = 8; /* break out immediately */
- fdc->state = IOTIMEDOUT; /* not really... */
- return (1);
- }
- }
-
- if (format) {
- if (fdc->flags & FDC_NODMA)
- (void)fdcpio(fdc,bp->b_flags,
- bp->b_data+fd->skip,
- bp->b_bcount);
- /* formatting */
- if(fd_cmd(fdc, 6, NE7CMD_FORMAT, head << 2 | fdu,
- finfo->fd_formb_secshift,
- finfo->fd_formb_nsecs,
- finfo->fd_formb_gaplen,
- finfo->fd_formb_fillbyte, 0)) {
- /* controller fell over */
- isa_dmadone(bp->b_flags, bp->b_data + fd->skip,
- format ? bp->b_bcount : fdblk,
- fdc->dmachan);
- fdc->retry = 6;
- return (retrier(fdc));
- }
- } else {
- if (fdc->flags & FDC_NODMA) {
- /*
- * this seems to be necessary even when
- * reading data
- */
- SET_BCDR(fdc, 1, fdblk, 0);
-
- /*
- * perform the write pseudo-DMA before
- * the WRITE command is sent
- */
- if (!read)
- (void)fdcpio(fdc,bp->b_flags,
- bp->b_data+fd->skip,
- fdblk);
- }
- if (fd_cmd(fdc, 9,
- (read ? NE7CMD_READ : NE7CMD_WRITE),
- head << 2 | fdu, /* head & unit */
- fd->track, /* track */
- head,
- sec, /* sector + 1 */
- fd->ft->secsize, /* sector size */
- sectrac, /* sectors/track */
- fd->ft->gap, /* gap size */
- fd->ft->datalen, /* data length */
- 0)) {
- /* the beast is sleeping again */
- isa_dmadone(bp->b_flags, bp->b_data + fd->skip,
- format ? bp->b_bcount : fdblk,
- fdc->dmachan);
- fdc->retry = 6;
- return (retrier(fdc));
- }
- }
- if (fdc->flags & FDC_NODMA)
- /*
- * if this is a read, then simply await interrupt
- * before performing PIO
- */
- if (read && !fdcpio(fdc,bp->b_flags,
- bp->b_data+fd->skip,fdblk)) {
- fd->tohandle = timeout(fd_iotimeout, fdc, hz);
- return(0); /* will return later */
- };
-
- /*
- * write (or format) operation will fall through and
- * await completion interrupt
- */
- fdc->state = IOCOMPLETE;
- fd->tohandle = timeout(fd_iotimeout, fdc, hz);
- return (0); /* will return later */
-#ifdef EPSON_NRDISK
- }
- else {
- nrdblkn = (nrd_t)((unsigned long)bp->b_blkno*DEV_BSIZE/fdblk
- + fd->skip/fdblk);
- nrd_LED_on();
- nrd_addrset(fdblk * nrdblkn);
- while (!nrd_check_ready()) DELAY(1);
- if (read) epson_insw(P_NRD_DATA,
- bp->b_data + fd->skip,
- fdblk / sizeof(short));
- else epson_outsw(P_NRD_DATA,
- bp->b_data + fd->skip,
- (format ? bp->b_bcount : fdblk)
- / sizeof(short));
-
- blknum = (unsigned long)bp->b_blkno*DEV_BSIZE/fdblk
- + fd->skip/fdblk;
- sectrac = fd->ft->sectrac;
- sec = blknum % (sectrac * fd->ft->heads);
- head = sec / sectrac;
- sec = sec % sectrac + 1;
- fd->hddrv = ((head&1)<<2)+fdu;
-
- if (nrdsec++ >= nrd_sec())
- nrdaddr = (nrd_t)(fd->track * 8 + head * 4);
- nrdsec = sec;
- fdc->state = IOCOMPLETE;
- }
-#endif
- case PIOREAD:
- /*
- * actually perform the PIO read. The IOCOMPLETE case
- * removes the timeout for us.
- */
- (void)fdcpio(fdc,bp->b_flags,bp->b_data+fd->skip,fdblk);
- fdc->state = IOCOMPLETE;
- /* FALLTHROUGH */
- case IOCOMPLETE: /* IO DONE, post-analyze */
-#ifdef EPSON_NRDISK
- if (fdu != nrdu)
- untimeout(fd_iotimeout, fdc, fd->tohandle);
-#else
- untimeout(fd_iotimeout, fdc, fd->tohandle);
-#endif
-
- if (fd_read_status(fdc, fd->fdsu)) {
- isa_dmadone(bp->b_flags, bp->b_data + fd->skip,
- format ? bp->b_bcount : fdblk,
- fdc->dmachan);
- if (fdc->retry < 6)
- fdc->retry = 6; /* force a reset */
- return (retrier(fdc));
- }
-
- fdc->state = IOTIMEDOUT;
-
- /* FALLTHROUGH */
-
- case IOTIMEDOUT:
-#ifdef EPSON_NRDISK
- if (fdu != nrdu) {
-#endif /* EPSON_NRDISK */
- if (!(fdc->flags & FDC_NODMA))
- isa_dmadone(bp->b_flags, bp->b_data + fd->skip,
- format ? bp->b_bcount : fdblk, fdc->dmachan);
-#ifdef EPSON_NRDISK
- }
- else nrd_LED_off();
-#endif /* EPSON_NRDISK */
- if (fdc->status[0] & NE7_ST0_IC) {
- if ((fdc->status[0] & NE7_ST0_IC) == NE7_ST0_IC_AT
- && fdc->status[1] & NE7_ST1_OR) {
- /*
- * DMA overrun. Someone hogged the bus
- * and didn't release it in time for the
- * next FDC transfer.
- * Just restart it, don't increment retry
- * count. (vak)
- */
- fdc->state = SEEKCOMPLETE;
- return (1);
- }
- else if((fdc->status[0] & NE7_ST0_IC) == NE7_ST0_IC_IV
- && fdc->retry < 6)
- fdc->retry = 6; /* force a reset */
- else if((fdc->status[0] & NE7_ST0_IC) == NE7_ST0_IC_AT
- && fdc->status[2] & NE7_ST2_WC
- && fdc->retry < 3)
- fdc->retry = 3; /* force recalibrate */
- return (retrier(fdc));
- }
- /* All OK */
- fd->skip += fdblk;
- if (!format && fd->skip < bp->b_bcount - bp->b_resid) {
- /* set up next transfer */
- fdc->state = DOSEEK;
- } else {
- /* ALL DONE */
- fd->skip = 0;
- fdc->bp = NULL;
- devstat_end_transaction_buf(&fd->device_stats, bp);
- biodone(bp);
- fdc->fd = (fd_p) 0;
- fdc->fdu = -1;
- fdc->state = FINDWORK;
- }
- return (1);
- case RESETCTLR:
- fdc_reset(fdc);
- fdc->retry++;
- fdc->state = RESETCOMPLETE;
- return (0);
- case RESETCOMPLETE:
- /*
- * Discard all the results from the reset so that they
- * can't cause an unexpected interrupt later.
- */
- for (i = 0; i < 4; i++)
- (void)fd_sense_int(fdc, &st0, &cyl);
- fdc->state = STARTRECAL;
- /* Fall through. */
- case STARTRECAL:
-#ifdef PC98
- pc98_fd_check_ready(fdu);
-#endif
- if(fd_cmd(fdc, 2, NE7CMD_RECAL, fdu, 0)) {
- /* arrgl */
- fdc->retry = 6;
- return (retrier(fdc));
- }
- fdc->state = RECALWAIT;
- return (0); /* will return later */
- case RECALWAIT:
- /* allow heads to settle */
- timeout(fd_pseudointr, fdc, hz / 8);
- fdc->state = RECALCOMPLETE;
- return (0); /* will return later */
- case RECALCOMPLETE:
- do {
- /*
- * See SEEKCOMPLETE for a comment on this:
- */
- if (fd_sense_int(fdc, &st0, &cyl) == FD_NOT_VALID)
- return 0;
- if(fdc->fdct == FDC_NE765
- && (st0 & NE7_ST0_IC) == NE7_ST0_IC_RC)
- return 0; /* hope for a real intr */
- } while ((st0 & NE7_ST0_IC) == NE7_ST0_IC_RC);
-#ifdef EPSON_NRDISK
- if (fdu == nrdu) {
- st0 = NE7_ST0_IC_NT;
- cyl = 0;
- }
-#endif
- if ((st0 & NE7_ST0_IC) != NE7_ST0_IC_NT || cyl != 0)
- {
- if(fdc->retry > 3)
- /*
- * a recalibrate from beyond cylinder 77
- * will "fail" due to the FDC limitations;
- * since people used to complain much about
- * the failure message, try not logging
- * this one if it seems to be the first
- * time in a line
- */
- printf("fd%d: recal failed ST0 %b cyl %d\n",
- fdu, st0, NE7_ST0BITS, cyl);
- if(fdc->retry < 3) fdc->retry = 3;
- return (retrier(fdc));
- }
- fd->track = 0;
- /* Seek (probably) necessary */
- fdc->state = DOSEEK;
- return (1); /* will return immediatly */
- case MOTORWAIT:
- if(fd->flags & FD_MOTOR_WAIT)
- {
- return (0); /* time's not up yet */
- }
- if (fdc->flags & FDC_NEEDS_RESET) {
- fdc->state = RESETCTLR;
- fdc->flags &= ~FDC_NEEDS_RESET;
- } else {
- /*
- * If all motors were off, then the controller was
- * reset, so it has lost track of the current
- * cylinder. Recalibrate to handle this case.
- * But first, discard the results of the reset.
- */
- fdc->state = RESETCOMPLETE;
- }
- return (1); /* will return immediatly */
- default:
- device_printf(fdc->fdc_dev, "unexpected FD int->");
- if (fd_read_status(fdc, fd->fdsu) == 0)
- printf("FDC status :%x %x %x %x %x %x %x ",
- fdc->status[0],
- fdc->status[1],
- fdc->status[2],
- fdc->status[3],
- fdc->status[4],
- fdc->status[5],
- fdc->status[6] );
- else
- printf("No status available ");
- if (fd_sense_int(fdc, &st0, &cyl) != 0)
- {
- printf("[controller is dead now]\n");
- return (0);
- }
- printf("ST0 = %x, PCN = %x\n", st0, cyl);
- return (0);
- }
- /*XXX confusing: some branches return immediately, others end up here*/
- return (1); /* Come back immediatly to new state */
-}
-
-static int
-retrier(struct fdc_data *fdc)
-{
- register struct buf *bp;
- struct fd_data *fd;
- int fdu;
-
- bp = fdc->bp;
-
- /* XXX shouldn't this be cached somewhere? */
- fdu = FDUNIT(minor(bp->b_dev));
- fd = devclass_get_softc(fd_devclass, fdu);
- if (fd->options & FDOPT_NORETRY)
- goto fail;
-
- switch (fdc->retry) {
- case 0: case 1: case 2:
- fdc->state = SEEKCOMPLETE;
- break;
- case 3: case 4: case 5:
- fdc->state = STARTRECAL;
- break;
- case 6:
- fdc->state = RESETCTLR;
- break;
- case 7:
- break;
- default:
- fail:
- {
- dev_t sav_b_dev = bp->b_dev;
- /* Trick diskerr */
- bp->b_dev = makedev(major(bp->b_dev),
- (FDUNIT(minor(bp->b_dev))<<3)|RAW_PART);
- diskerr(bp, "hard error", LOG_PRINTF,
- fdc->fd->skip / DEV_BSIZE,
- (struct disklabel *)NULL);
- bp->b_dev = sav_b_dev;
- if (fdc->flags & FDC_STAT_VALID)
- {
- printf(
- " (ST0 %b ST1 %b ST2 %b cyl %u hd %u sec %u)\n",
- fdc->status[0], NE7_ST0BITS,
- fdc->status[1], NE7_ST1BITS,
- fdc->status[2], NE7_ST2BITS,
- fdc->status[3], fdc->status[4],
- fdc->status[5]);
- }
- else
- printf(" (No status)\n");
- }
- bp->b_flags |= B_ERROR;
- bp->b_error = EIO;
- bp->b_resid += bp->b_bcount - fdc->fd->skip;
- fdc->bp = NULL;
- fdc->fd->skip = 0;
- devstat_end_transaction_buf(&fdc->fd->device_stats, bp);
- biodone(bp);
- fdc->state = FINDWORK;
- fdc->flags |= FDC_NEEDS_RESET;
- fdc->fd = (fd_p) 0;
- fdc->fdu = -1;
- return (1);
- }
- fdc->retry++;
- return (1);
-}
-
-static int
-fdformat(dev, finfo, p)
- dev_t dev;
- struct fd_formb *finfo;
- struct proc *p;
-{
- fdu_t fdu;
- fd_p fd;
-
- struct buf *bp;
- int rv = 0, s;
- size_t fdblk;
-
- fdu = FDUNIT(minor(dev));
- fd = devclass_get_softc(fd_devclass, fdu);
- fdblk = 128 << fd->ft->secsize;
-
- /* set up a buffer header for fdstrategy() */
- bp = (struct buf *)malloc(sizeof(struct buf), M_TEMP, M_NOWAIT);
- if(bp == 0)
- return ENOBUFS;
- /*
- * keep the process from being swapped
- */
- PHOLD(p);
- bzero((void *)bp, sizeof(struct buf));
- BUF_LOCKINIT(bp);
- BUF_LOCK(bp, LK_EXCLUSIVE);
- bp->b_flags = B_PHYS | B_FORMAT;
-
- /*
- * calculate a fake blkno, so fdstrategy() would initiate a
- * seek to the requested cylinder
- */
- bp->b_blkno = (finfo->cyl * (fd->ft->sectrac * fd->ft->heads)
- + finfo->head * fd->ft->sectrac) * fdblk / DEV_BSIZE;
-
- bp->b_bcount = sizeof(struct fd_idfield_data) * finfo->fd_formb_nsecs;
- bp->b_data = (caddr_t)finfo;
-
- /* now do the format */
- bp->b_dev = dev;
- BUF_STRATEGY(bp, 0);
-
- /* ...and wait for it to complete */
- s = splbio();
- while(!(bp->b_flags & B_DONE)) {
- rv = tsleep((caddr_t)bp, PRIBIO, "fdform", 20 * hz);
- if (rv == EWOULDBLOCK)
- break;
- }
- splx(s);
-
- if (rv == EWOULDBLOCK) {
- /* timed out */
- rv = EIO;
- biodone(bp);
- }
- if (bp->b_flags & B_ERROR)
- rv = bp->b_error;
- /*
- * allow the process to be swapped
- */
- PRELE(p);
- BUF_UNLOCK(bp);
- BUF_LOCKFREE(bp);
- free(bp, M_TEMP);
- return rv;
-}
-
-/*
- * TODO: don't allocate buffer on stack.
- */
-
-static int
-fdioctl(dev, cmd, addr, flag, p)
- dev_t dev;
- u_long cmd;
- caddr_t addr;
- int flag;
- struct proc *p;
-{
- fdu_t fdu = FDUNIT(minor(dev));
- fd_p fd = devclass_get_softc(fd_devclass, fdu);
- size_t fdblk;
-
- struct fd_type *fdt;
- struct disklabel *dl;
- char buffer[DEV_BSIZE];
- int error = 0;
-
- fdblk = 128 << fd->ft->secsize;
-
-#ifdef PC98
- pc98_fd_check_ready(fdu);
-#endif
- switch (cmd) {
- case DIOCGDINFO:
- bzero(buffer, sizeof (buffer));
- dl = (struct disklabel *)buffer;
- dl->d_secsize = fdblk;
- fdt = fd->ft;
- dl->d_secpercyl = fdt->size / fdt->tracks;
- dl->d_type = DTYPE_FLOPPY;
-
- if (readdisklabel(dkmodpart(dev, RAW_PART), dl)
- == NULL)
- error = 0;
- else
- error = EINVAL;
-
- *(struct disklabel *)addr = *dl;
- break;
-
- case DIOCSDINFO:
- if ((flag & FWRITE) == 0)
- error = EBADF;
- break;
-
- case DIOCWLABEL:
- if ((flag & FWRITE) == 0)
- error = EBADF;
- break;
-
- case DIOCWDINFO:
- if ((flag & FWRITE) == 0) {
- error = EBADF;
- break;
- }
-
- dl = (struct disklabel *)addr;
-
- if ((error = setdisklabel((struct disklabel *)buffer, dl,
- (u_long)0)) != 0)
- break;
-
- error = writedisklabel(dev, (struct disklabel *)buffer);
- break;
- case FD_FORM:
- if ((flag & FWRITE) == 0)
- error = EBADF; /* must be opened for writing */
- else if (((struct fd_formb *)addr)->format_version !=
- FD_FORMAT_VERSION)
- error = EINVAL; /* wrong version of formatting prog */
- else
- error = fdformat(dev, (struct fd_formb *)addr, p);
- break;
-
- case FD_GTYPE: /* get drive type */
- *(struct fd_type *)addr = *fd->ft;
- break;
-
- case FD_STYPE: /* set drive type */
- /* this is considered harmful; only allow for superuser */
- if (suser(p) != 0)
- return EPERM;
- *fd->ft = *(struct fd_type *)addr;
- break;
-
- case FD_GOPTS: /* get drive options */
- *(int *)addr = fd->options;
- break;
-
- case FD_SOPTS: /* set drive options */
- fd->options = *(int *)addr;
- break;
-
- default:
- error = ENOTTY;
- break;
- }
- return (error);
-}
-
-/*
- * Hello emacs, these are the
- * Local Variables:
- * c-indent-level: 8
- * c-continued-statement-offset: 8
- * c-continued-brace-offset: 0
- * c-brace-offset: -8
- * c-brace-imaginary-offset: 0
- * c-argdecl-indent: 8
- * c-label-offset: -8
- * c++-hanging-braces: 1
- * c++-access-specifier-offset: -8
- * c++-empty-arglist-indent: 8
- * c++-friend-offset: 0
- * End:
- */
diff --git a/sys/pc98/cbus/fdcreg.h b/sys/pc98/cbus/fdcreg.h
deleted file mode 100644
index 1a8d2b0d2868..000000000000
--- a/sys/pc98/cbus/fdcreg.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/*-
- * 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. 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, Berkeley and its contributors.
- * 4. 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: @(#)fdreg.h 7.1 (Berkeley) 5/9/91
- * $FreeBSD$
- */
-
-/*
- * AT floppy controller registers and bitfields
- */
-
-/* uses NEC765 controller */
-#include <isa/ic/nec765.h>
-
-#ifdef PC98
-/* registers */
-#define FDSTS 0 /* NEC 765 Main Status Register (R) */
-#define FDDATA 2 /* NEC 765 Data Register (R/W) */
-#define FDOUT 4 /* Digital Output Register (W) */
-#define FDO_RST 0x80 /* FDC RESET */
-#define FDO_FRY 0x40 /* force READY */
-#define FDO_AIE 0x20 /* Attention Interrupt Enable */
-#define FDO_DD 0x20 /* FDD Mode Exchange 0:1M 1:640K */
-#define FDO_DMAE 0x10 /* enable floppy DMA */
-#define FDO_MTON 0x08 /* MOTOR ON (when EMTON=1)*/
-#define FDO_TMSK 0x04 /* TIMER MASK */
-#define FDO_TTRG 0x01 /* TIMER TRIGER */
-
-#define FDIN 4 /* Digital Input Register (R) */
-#define FDI_TYP0 0x04 /* FDD #1/#2 TYPE */
-#define FDI_TYP1 0x08 /* FDD #3/#4 TYPE */
-#define FDI_RDY 0x10 /* Ready */
-#define FDI_DMACH 0x20 /* DMA Channel */
-#define FDI_FINT0 0x40 /* Interrupt */
-#define FDI_FINT1 0x80 /* Interrupt */
-
-#define FDP_EMTON 0x04 /* enable MTON */
-#define FDP_FDDEXC 0x02 /* FDD Mode Exchange 1:1M 0:640K */
-#define FDP_PORTEXC 0x01 /* PORT Exchane 1:1M 0:640K */
-
-#else
-/* registers */
-#define FDOUT 2 /* Digital Output Register (W) */
-#define FDO_FDSEL 0x03 /* floppy device select */
-#define FDO_FRST 0x04 /* floppy controller reset */
-#define FDO_FDMAEN 0x08 /* enable floppy DMA and Interrupt */
-#define FDO_MOEN0 0x10 /* motor enable drive 0 */
-#define FDO_MOEN1 0x20 /* motor enable drive 1 */
-#define FDO_MOEN2 0x40 /* motor enable drive 2 */
-#define FDO_MOEN3 0x80 /* motor enable drive 3 */
-
-#define FDSTS 4 /* NEC 765 Main Status Register (R) */
-#define FDDATA 5 /* NEC 765 Data Register (R/W) */
-#define FDCTL 7 /* Control Register (W) */
-
-#ifndef FDC_500KBPS
-# define FDC_500KBPS 0x00 /* 500KBPS MFM drive transfer rate */
-# define FDC_300KBPS 0x01 /* 300KBPS MFM drive transfer rate */
-# define FDC_250KBPS 0x02 /* 250KBPS MFM drive transfer rate */
-# define FDC_125KBPS 0x03 /* 125KBPS FM drive transfer rate */
- /* for some controllers 1MPBS instead */
-#endif /* FDC_500KBPS */
-#endif /* PC98 */
-
-/*
- * this is the secret PIO data port (offset from base)
- */
-#define FDC_YE_DATAPORT 6
-
-#ifndef PC98
-#define FDIN 7 /* Digital Input Register (R) */
-#define FDI_DCHG 0x80 /* diskette has been changed */
- /* requires drive and motor being selected */
- /* is cleared by any step pulse to drive */
-#endif
diff --git a/sys/pc98/cbus/gdc.c b/sys/pc98/cbus/gdc.c
deleted file mode 100644
index d3f6d921a271..000000000000
--- a/sys/pc98/cbus/gdc.c
+++ /dev/null
@@ -1,1081 +0,0 @@
-/*
- * Copyright (c) 1999 FreeBSD(98) port team.
- * 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 as
- * the first lines of this file unmodified.
- * 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.
- *
- * $FreeBSD$
- */
-
-#include "gdc.h"
-#include "opt_gdc.h"
-#include "opt_fb.h"
-#include "opt_syscons.h"
-
-#if NGDC > 0
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/bus.h>
-
-#include <vm/vm.h>
-#include <vm/pmap.h>
-
-#include <machine/console.h>
-#include <machine/md_var.h>
-#include <machine/pc/bios.h>
-
-#include <dev/fb/fbreg.h>
-
-#include <pc98/pc98/pc98.h>
-#include <pc98/pc98/pc98_machdep.h>
-#include <isa/isavar.h>
-
-#define TEXT_GDC IO_GDC1 /* 0x60 */
-#define ROW 25
-#define COL 80
-
-#define DRIVER_NAME "gdc"
-
-/* cdev driver declaration */
-
-#define GDC_UNIT(dev) minor(dev)
-#define GDC_MKMINOR(unit) (unit)
-
-typedef struct gdc_softc {
- video_adapter_t *adp;
-} gdc_softc_t;
-
-#define GDC_SOFTC(unit) \
- ((gdc_softc_t *)devclass_get_softc(gdc_devclass, unit))
-
-static devclass_t gdc_devclass;
-
-static int gdcprobe(device_t dev);
-static int gdc_attach(device_t dev);
-
-static device_method_t gdc_methods[] = {
- DEVMETHOD(device_probe, gdcprobe),
- DEVMETHOD(device_attach, gdc_attach),
- { 0, 0 }
-};
-
-static driver_t gdcdriver = {
- DRIVER_NAME,
- gdc_methods,
- sizeof(gdc_softc_t),
-};
-
-DRIVER_MODULE(gdc, isa, gdcdriver, gdc_devclass, 0, 0);
-
-static int gdc_probe_unit(int unit, gdc_softc_t *sc, int flags);
-static int gdc_attach_unit(int unit, gdc_softc_t *sc, int flags);
-
-#if FB_INSTALL_CDEV
-
-static d_open_t gdcopen;
-static d_close_t gdcclose;
-static d_read_t gdcread;
-static d_write_t gdcwrite;
-static d_ioctl_t gdcioctl;
-static d_mmap_t gdcmmap;
-
-static struct cdevsw vga_cdevsw = {
- /* open */ gdcopen,
- /* close */ gdcclose,
- /* read */ gdcread,
- /* write */ gdcwrite,
- /* ioctl */ gdcioctl,
- /* poll */ nopoll,
- /* mmap */ nommap,
- /* strategy */ nostrategy,
- /* name */ DRIVER_NAME,
- /* maj */ -1,
- /* dump */ nodump,
- /* psize */ nopsize,
- /* flags */ 0,
- /* bmaj */ -1
-};
-
-#endif /* FB_INSTALL_CDEV */
-
-static int
-gdcprobe(device_t dev)
-{
- gdc_softc_t *sc;
-
- /* Check isapnp ids */
- if (isa_get_vendorid(dev))
- return (ENXIO);
-
- device_set_desc(dev, "Generic GDC");
- sc = device_get_softc(dev);
- return gdc_probe_unit(device_get_unit(dev), sc, device_get_flags(dev));
-}
-
-static int
-gdc_attach(device_t dev)
-{
- gdc_softc_t *sc;
- int error;
-
- sc = device_get_softc(dev);
- error = gdc_attach_unit(device_get_unit(dev), sc, device_get_flags(dev));
- if (error)
- return error;
-
-#ifdef FB_INSTALL_CDEV
- /* attach a virtual frame buffer device */
- error = fb_attach(makedev(0, GDC_MKMINOR(unit)), sc->adp, &gdc_cdevsw);
- if (error)
- return error;
-#endif /* FB_INSTALL_CDEV */
-
- if (bootverbose)
- (*vidsw[sc->adp->va_index]->diag)(sc->adp, bootverbose);
-
- return 0;
-}
-
-static int
-gdc_probe_unit(int unit, gdc_softc_t *sc, int flags)
-{
- video_switch_t *sw;
-
- bzero(sc, sizeof(*sc));
- sw = vid_get_switch(DRIVER_NAME);
- if (sw == NULL)
- return ENXIO;
- return (*sw->probe)(unit, &sc->adp, NULL, flags);
-}
-
-static int
-gdc_attach_unit(int unit, gdc_softc_t *sc, int flags)
-{
- video_switch_t *sw;
-
- sw = vid_get_switch(DRIVER_NAME);
- if (sw == NULL)
- return ENXIO;
- return (*sw->init)(unit, sc->adp, flags);
-}
-
-/* cdev driver functions */
-
-#ifdef FB_INSTALL_CDEV
-
-static int
-gdcopen(dev_t dev, int flag, int mode, struct proc *p)
-{
- gdc_softc_t *sc;
-
- sc = GDC_SOFTC(GDC_UNIT(dev));
- if (sc == NULL)
- return ENXIO;
- if (mode & (O_CREAT | O_APPEND | O_TRUNC))
- return ENODEV;
-
- return genfbopen(&sc->gensc, sc->adp, flag, mode, p);
-}
-
-static int
-gdcclose(dev_t dev, int flag, int mode, struct proc *p)
-{
- gdc_softc_t *sc;
-
- sc = GDC_SOFTC(GDC_UNIT(dev));
- return genfbclose(&sc->gensc, sc->adp, flag, mode, p);
-}
-
-static int
-gdcread(dev_t dev, struct uio *uio, int flag)
-{
- gdc_softc_t *sc;
-
- sc = GDC_SOFTC(GDC_UNIT(dev));
- return genfbread(&sc->gensc, sc->adp, uio, flag);
-}
-
-static int
-gdcwrite(dev_t dev, struct uio *uio, int flag)
-{
- gdc_softc_t *sc;
-
- sc = GDC_SOFTC(GDC_UNIT(dev));
- return genfbread(&sc->gensc, sc->adp, uio, flag);
-}
-
-static int
-gdcioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct proc *p)
-{
- gdc_softc_t *sc;
-
- sc = GDC_SOFTC(GDC_UNIT(dev));
- return genfbioctl(&sc->gensc, sc->adp, cmd, arg, flag, p);
-}
-
-static int
-gdcmmap(dev_t dev, vm_offset_t offset, int prot)
-{
- gdc_softc_t *sc;
-
- sc = GDC_SOFTC(GDC_UNIT(dev));
- return genfbmmap(&sc->gensc, sc->adp, offset, prot);
-}
-
-#endif /* FB_INSTALL_CDEV */
-
-/* LOW-LEVEL */
-
-#include <machine/clock.h>
-
-#include <pc98/pc98/30line.h>
-
-#define TEXT_BUF_BASE 0x000a0000
-#define TEXT_BUF_SIZE 0x00008000
-#define GRAPHICS_BUF_BASE 0x000a8000
-#define GRAPHICS_BUF_SIZE 0x00040000
-#define VIDEO_BUF_BASE 0x000a0000
-#define VIDEO_BUF_SIZE 0x00048000
-
-#define probe_done(adp) ((adp)->va_flags & V_ADP_PROBED)
-#define init_done(adp) ((adp)->va_flags & V_ADP_INITIALIZED)
-#define config_done(adp) ((adp)->va_flags & V_ADP_REGISTERED)
-
-/*
- * NOTE: `va_window' should have a virtual address, but is initialized
- * with a physical address in the following table, they will be
- * converted at run-time.
- */
-static video_adapter_t adapter_init_value[] = {
- { 0,
- KD_PC98, "gdc", /* va_type, va_name */
- 0, 0, /* va_unit, va_minor */
- V_ADP_COLOR | V_ADP_MODECHANGE | V_ADP_BORDER,
- IO_GDC1, 16, TEXT_GDC, /* va_io*, XXX */
- VIDEO_BUF_BASE, VIDEO_BUF_SIZE, /* va_mem* */
- TEXT_BUF_BASE, TEXT_BUF_SIZE, TEXT_BUF_SIZE, 0, /* va_window* */
- 0, 0, /* va_buffer, va_buffer_size */
- 0, M_PC98_80x25, 0, /* va_*mode* */
- },
-};
-
-static video_adapter_t biosadapter[1];
-
-/* video driver declarations */
-static int gdc_configure(int flags);
-static int gdc_nop(void);
-static int gdc_err(video_adapter_t *adp, ...);
-static vi_probe_t gdc_probe;
-static vi_init_t gdc_init;
-static vi_get_info_t gdc_get_info;
-static vi_query_mode_t gdc_query_mode;
-static vi_set_mode_t gdc_set_mode;
-static vi_set_border_t gdc_set_border;
-static vi_save_state_t gdc_save_state;
-static vi_load_state_t gdc_load_state;
-static vi_read_hw_cursor_t gdc_read_hw_cursor;
-static vi_set_hw_cursor_t gdc_set_hw_cursor;
-static vi_set_hw_cursor_shape_t gdc_set_hw_cursor_shape;
-static vi_blank_display_t gdc_blank_display;
-static vi_mmap_t gdc_mmap_buf;
-static vi_ioctl_t gdc_dev_ioctl;
-static vi_diag_t gdc_diag;
-
-static video_switch_t gdcvidsw = {
- gdc_probe,
- gdc_init,
- gdc_get_info,
- gdc_query_mode,
- gdc_set_mode,
- (vi_save_font_t *)gdc_err,
- (vi_load_font_t *)gdc_err,
- (vi_show_font_t *)gdc_err,
- (vi_save_palette_t *)gdc_err,
- (vi_load_palette_t *)gdc_err,
- gdc_set_border,
- gdc_save_state,
- gdc_load_state,
- (vi_set_win_org_t *)gdc_err,
- gdc_read_hw_cursor,
- gdc_set_hw_cursor,
- gdc_set_hw_cursor_shape,
- gdc_blank_display,
- gdc_mmap_buf,
- gdc_dev_ioctl,
- (vi_clear_t *)gdc_err,
- (vi_fill_rect_t *)gdc_err,
- (vi_bitblt_t *)gdc_err,
- (int (*)(void))gdc_err,
- (int (*)(void))gdc_err,
- gdc_diag,
-};
-
-VIDEO_DRIVER(gdc, gdcvidsw, gdc_configure);
-
-/* GDC BIOS standard video modes */
-#define EOT (-1)
-#define NA (-2)
-
-static video_info_t bios_vmode[] = {
- { M_PC98_80x25, V_INFO_COLOR, 80, 25, 8, 16, 4, 1,
- TEXT_BUF_BASE, TEXT_BUF_SIZE, TEXT_BUF_SIZE, 0, 0, V_INFO_MM_TEXT },
-#ifdef LINE30
- { M_PC98_80x30, V_INFO_COLOR, 80, 30, 8, 16, 4, 1,
- TEXT_BUF_BASE, TEXT_BUF_SIZE, TEXT_BUF_SIZE, 0, 0, V_INFO_MM_TEXT },
-#endif
- { EOT },
-};
-
-static int gdc_init_done = FALSE;
-
-/* local functions */
-static int map_gen_mode_num(int type, int color, int mode);
-static int probe_adapters(void);
-static void dump_buffer(u_char *buf, size_t len);
-
-#define prologue(adp, flag, err) \
- if (!gdc_init_done || !((adp)->va_flags & (flag))) \
- return (err)
-
-/* a backdoor for the console driver */
-static int
-gdc_configure(int flags)
-{
- probe_adapters();
- biosadapter[0].va_flags |= V_ADP_INITIALIZED;
- if (!config_done(&biosadapter[0])) {
- if (vid_register(&biosadapter[0]) < 0)
- return 1;
- biosadapter[0].va_flags |= V_ADP_REGISTERED;
- }
-
- return 1;
-}
-
-/* local subroutines */
-
-/* map a generic video mode to a known mode number */
-static int
-map_gen_mode_num(int type, int color, int mode)
-{
- static struct {
- int from;
- int to;
- } mode_map[] = {
- { M_TEXT_80x25, M_PC98_80x25, },
-#ifdef LINE30
- { M_TEXT_80x30, M_PC98_80x30, },
-#endif
- };
- int i;
-
- for (i = 0; i < sizeof(mode_map)/sizeof(mode_map[0]); ++i) {
- if (mode_map[i].from == mode)
- return mode_map[i].to;
- }
- return mode;
-}
-
-/* probe video adapters and return the number of detected adapters */
-static int
-probe_adapters(void)
-{
- video_info_t info;
-
- /* do this test only once */
- if (gdc_init_done)
- return 1;
- gdc_init_done = TRUE;
-
- biosadapter[0] = adapter_init_value[0];
- biosadapter[0].va_flags |= V_ADP_PROBED;
- biosadapter[0].va_mode =
- biosadapter[0].va_initial_mode = biosadapter[0].va_initial_bios_mode;
-
- master_gdc_wait_vsync();
- master_gdc_cmd(_GDC_START); /* text ON */
- gdc_wait_vsync();
- gdc_cmd(_GDC_STOP); /* graphics OFF */
-
- gdc_get_info(&biosadapter[0], biosadapter[0].va_initial_mode, &info);
- biosadapter[0].va_window = BIOS_PADDRTOVADDR(info.vi_window);
- biosadapter[0].va_window_size = info.vi_window_size;
- biosadapter[0].va_window_gran = info.vi_window_gran;
- biosadapter[0].va_buffer = 0;
- biosadapter[0].va_buffer_size = 0;
- if (info.vi_flags & V_INFO_GRAPHICS) {
- switch (info.vi_depth/info.vi_planes) {
- case 1:
- biosadapter[0].va_line_width = info.vi_width/8;
- break;
- case 2:
- biosadapter[0].va_line_width = info.vi_width/4;
- break;
- case 4:
- biosadapter[0].va_line_width = info.vi_width/2;
- break;
- case 8:
- default: /* shouldn't happen */
- biosadapter[0].va_line_width = info.vi_width;
- break;
- }
- } else {
- biosadapter[0].va_line_width = info.vi_width;
- }
- bcopy(&info, &biosadapter[0].va_info, sizeof(info));
-
- return 1;
-}
-
-static void master_gdc_cmd(unsigned int cmd)
-{
- while ( (inb(IO_GDC1) & 2) != 0);
- outb(IO_GDC1+2, cmd);
-}
-
-static void master_gdc_prm(unsigned int pmtr)
-{
- while ( (inb(IO_GDC1) & 2) != 0);
- outb(IO_GDC1, pmtr);
-}
-
-static void master_gdc_word_prm(unsigned int wpmtr)
-{
- master_gdc_prm(wpmtr & 0x00ff);
- master_gdc_prm((wpmtr >> 8) & 0x00ff);
-}
-
-static void master_gdc_fifo_empty(void)
-{
- while ( (inb(IO_GDC1) & 4) == 0);
-}
-
-static void master_gdc_wait_vsync(void)
-{
- while ( (inb(IO_GDC1) & 0x20) != 0);
- while ( (inb(IO_GDC1) & 0x20) == 0);
-}
-
-static void gdc_cmd(unsigned int cmd)
-{
- while ( (inb(IO_GDC2) & 2) != 0);
- outb( IO_GDC2+2, cmd);
-}
-
-static void gdc_prm(unsigned int pmtr)
-{
- while ( (inb(IO_GDC2) & 2) != 0);
- outb( IO_GDC2, pmtr);
-}
-
-static void gdc_word_prm(unsigned int wpmtr)
-{
- gdc_prm(wpmtr & 0x00ff);
- gdc_prm((wpmtr >> 8) & 0x00ff);
-}
-
-static void gdc_fifo_empty(void)
-{
- while ( (inb(IO_GDC2) & 0x04) == 0);
-}
-
-static void gdc_wait_vsync(void)
-{
- while ( (inb(IO_GDC2) & 0x20) != 0);
- while ( (inb(IO_GDC2) & 0x20) == 0);
-}
-
-static int check_gdc_clock(void)
-{
- if ((inb(IO_SYSPORT) & 0x80) == 0){
- return _5MHZ;
- } else {
- return _2_5MHZ;
- }
-}
-
-static void initialize_gdc(unsigned int mode)
-{
- /* start 30line initialize */
- int m_mode,s_mode,gdc_clock;
- gdc_clock = check_gdc_clock();
-
- if (mode == T25_G400){
- m_mode = _25L;
- }else{
- m_mode = _30L;
- }
-
- s_mode = 2*mode+gdc_clock;
-
- gdc_INFO = m_mode;
-
- master_gdc_cmd(_GDC_RESET);
- master_gdc_cmd(_GDC_MASTER);
- gdc_cmd(_GDC_RESET);
- gdc_cmd(_GDC_SLAVE);
-
- /* GDC Master */
- master_gdc_cmd(_GDC_SYNC);
- master_gdc_prm(0x00); /* flush less */ /* text & graph */
- master_gdc_prm(master_param[m_mode][GDC_CR]);
- master_gdc_word_prm(((master_param[m_mode][GDC_HFP] << 10)
- + (master_param[m_mode][GDC_VS] << 5)
- + master_param[m_mode][GDC_HS]));
- master_gdc_prm(master_param[m_mode][GDC_HBP]);
- master_gdc_prm(master_param[m_mode][GDC_VFP]);
- master_gdc_word_prm(((master_param[m_mode][GDC_VBP] << 10)
- + (master_param[m_mode][GDC_LF])));
- master_gdc_fifo_empty();
- master_gdc_cmd(_GDC_PITCH);
- master_gdc_prm(MasterPCH);
- master_gdc_fifo_empty();
-
- /* GDC slave */
- gdc_cmd(_GDC_SYNC);
- gdc_prm(0x06);
- gdc_prm(slave_param[s_mode][GDC_CR]);
- gdc_word_prm((slave_param[s_mode][GDC_HFP] << 10)
- + (slave_param[s_mode][GDC_VS] << 5)
- + (slave_param[s_mode][GDC_HS]));
- gdc_prm(slave_param[s_mode][GDC_HBP]);
- gdc_prm(slave_param[s_mode][GDC_VFP]);
- gdc_word_prm((slave_param[s_mode][GDC_VBP] << 10)
- + (slave_param[s_mode][GDC_LF]));
- gdc_fifo_empty();
- gdc_cmd(_GDC_PITCH);
- gdc_prm(SlavePCH[gdc_clock]);
- gdc_fifo_empty();
-
- /* set Master GDC scroll param */
- master_gdc_wait_vsync();
- master_gdc_wait_vsync();
- master_gdc_wait_vsync();
- master_gdc_cmd(_GDC_SCROLL);
- master_gdc_word_prm(0);
- master_gdc_word_prm((master_param[m_mode][GDC_LF] << 4) | 0x0000);
- master_gdc_fifo_empty();
-
- /* set Slave GDC scroll param */
- gdc_wait_vsync();
- gdc_cmd(_GDC_SCROLL);
- gdc_word_prm(0);
- if (gdc_clock == _5MHZ){
- gdc_word_prm((SlaveScrlLF[mode] << 4) | 0x4000);
- }else{
- gdc_word_prm(SlaveScrlLF[mode] << 4);
- }
- gdc_fifo_empty();
-
- gdc_word_prm(0);
- if (gdc_clock == _5MHZ){
- gdc_word_prm((SlaveScrlLF[mode] << 4) | 0x4000);
- }else{
- gdc_word_prm(SlaveScrlLF[mode] << 4);
- }
- gdc_fifo_empty();
-
- /* sync start */
- gdc_cmd(_GDC_STOP);
-
- gdc_wait_vsync();
- gdc_wait_vsync();
- gdc_wait_vsync();
-
- master_gdc_cmd(_GDC_START);
-}
-
-/* entry points */
-
-static int
-gdc_nop(void)
-{
- return 0;
-}
-
-static int
-gdc_err(video_adapter_t *adp, ...)
-{
- return ENODEV;
-}
-
-static int
-gdc_probe(int unit, video_adapter_t **adpp, void *arg, int flags)
-{
- probe_adapters();
- if (unit >= 1)
- return ENXIO;
-
- *adpp = &biosadapter[unit];
-
- return 0;
-}
-
-static int
-gdc_init(int unit, video_adapter_t *adp, int flags)
-{
- if ((unit >= 1) || (adp == NULL) || !probe_done(adp))
- return ENXIO;
-
- if (!init_done(adp)) {
- /* nothing to do really... */
- adp->va_flags |= V_ADP_INITIALIZED;
- }
-
- if (!config_done(adp)) {
- if (vid_register(adp) < 0)
- return ENXIO;
- adp->va_flags |= V_ADP_REGISTERED;
- }
-
- return 0;
-}
-
-/*
- * get_info():
- * Return the video_info structure of the requested video mode.
- */
-static int
-gdc_get_info(video_adapter_t *adp, int mode, video_info_t *info)
-{
- int i;
-
- if (!gdc_init_done)
- return ENXIO;
-
- mode = map_gen_mode_num(adp->va_type, adp->va_flags & V_ADP_COLOR, mode);
- for (i = 0; bios_vmode[i].vi_mode != EOT; ++i) {
- if (bios_vmode[i].vi_mode == NA)
- continue;
- if (mode == bios_vmode[i].vi_mode) {
- *info = bios_vmode[i];
- info->vi_buffer_size = info->vi_window_size*info->vi_planes;
- return 0;
- }
- }
- return EINVAL;
-}
-
-/*
- * query_mode():
- * Find a video mode matching the requested parameters.
- * Fields filled with 0 are considered "don't care" fields and
- * match any modes.
- */
-static int
-gdc_query_mode(video_adapter_t *adp, video_info_t *info)
-{
- int i;
-
- if (!gdc_init_done)
- return ENXIO;
-
- for (i = 0; bios_vmode[i].vi_mode != EOT; ++i) {
- if (bios_vmode[i].vi_mode == NA)
- continue;
-
- if ((info->vi_width != 0)
- && (info->vi_width != bios_vmode[i].vi_width))
- continue;
- if ((info->vi_height != 0)
- && (info->vi_height != bios_vmode[i].vi_height))
- continue;
- if ((info->vi_cwidth != 0)
- && (info->vi_cwidth != bios_vmode[i].vi_cwidth))
- continue;
- if ((info->vi_cheight != 0)
- && (info->vi_cheight != bios_vmode[i].vi_cheight))
- continue;
- if ((info->vi_depth != 0)
- && (info->vi_depth != bios_vmode[i].vi_depth))
- continue;
- if ((info->vi_planes != 0)
- && (info->vi_planes != bios_vmode[i].vi_planes))
- continue;
- /* XXX: should check pixel format, memory model */
- if ((info->vi_flags != 0)
- && (info->vi_flags != bios_vmode[i].vi_flags))
- continue;
-
- /* verify if this mode is supported on this adapter */
- if (gdc_get_info(adp, bios_vmode[i].vi_mode, info))
- continue;
- return 0;
- }
- return ENODEV;
-}
-
-/*
- * set_mode():
- * Change the video mode.
- */
-static int
-gdc_set_mode(video_adapter_t *adp, int mode)
-{
- video_info_t info;
-
- prologue(adp, V_ADP_MODECHANGE, ENODEV);
-
- mode = map_gen_mode_num(adp->va_type,
- adp->va_flags & V_ADP_COLOR, mode);
- if (gdc_get_info(adp, mode, &info))
- return EINVAL;
-
-#ifdef LINE30
- switch (info.vi_mode) {
- case M_PC98_80x25: /* GDC TEXT MODES */
- initialize_gdc(T25_G400);
- break;
- case M_PC98_80x30:
- initialize_gdc(T30_G400);
- break;
- default:
- break;
- }
-#endif
-
- adp->va_mode = mode;
- adp->va_flags &= ~V_ADP_COLOR;
- adp->va_flags |=
- (info.vi_flags & V_INFO_COLOR) ? V_ADP_COLOR : 0;
-#if 0
- adp->va_crtc_addr =
- (adp->va_flags & V_ADP_COLOR) ? COLOR_CRTC : MONO_CRTC;
-#endif
- adp->va_window = BIOS_PADDRTOVADDR(info.vi_window);
- adp->va_window_size = info.vi_window_size;
- adp->va_window_gran = info.vi_window_gran;
- if (info.vi_buffer_size == 0) {
- adp->va_buffer = 0;
- adp->va_buffer_size = 0;
- } else {
- adp->va_buffer = BIOS_PADDRTOVADDR(info.vi_buffer);
- adp->va_buffer_size = info.vi_buffer_size;
- }
- if (info.vi_flags & V_INFO_GRAPHICS) {
- switch (info.vi_depth/info.vi_planes) {
- case 1:
- adp->va_line_width = info.vi_width/8;
- break;
- case 2:
- adp->va_line_width = info.vi_width/4;
- break;
- case 4:
- adp->va_line_width = info.vi_width/2;
- break;
- case 8:
- default: /* shouldn't happen */
- adp->va_line_width = info.vi_width;
- break;
- }
- } else {
- adp->va_line_width = info.vi_width;
- }
- bcopy(&info, &adp->va_info, sizeof(info));
-
- /* move hardware cursor out of the way */
- (*vidsw[adp->va_index]->set_hw_cursor)(adp, -1, -1);
-
- return 0;
-}
-
-/*
- * set_border():
- * Change the border color.
- */
-static int
-gdc_set_border(video_adapter_t *adp, int color)
-{
- outb(0x6c, color << 4);
- return 0;
-}
-
-/*
- * save_state():
- * Read video card register values.
- */
-static int
-gdc_save_state(video_adapter_t *adp, void *p, size_t size)
-{
- return ENODEV;
-}
-
-/*
- * load_state():
- * Set video card registers at once.
- */
-static int
-gdc_load_state(video_adapter_t *adp, void *p)
-{
- return ENODEV;
-}
-
-/*
- * read_hw_cursor():
- * Read the position of the hardware text cursor.
- */
-static int
-gdc_read_hw_cursor(video_adapter_t *adp, int *col, int *row)
-{
- u_int16_t off;
- int s;
-
- if (!gdc_init_done)
- return ENXIO;
-
- if (adp->va_info.vi_flags & V_INFO_GRAPHICS)
- return ENODEV;
-
- s = spltty();
- master_gdc_cmd(0xe0); /* _GDC_CSRR */
- while((inb(TEXT_GDC + 0) & 0x1) == 0) {} /* GDC wait */
- off = inb(TEXT_GDC + 2); /* EADl */
- off |= (inb(TEXT_GDC + 2) << 8); /* EADh */
- inb(TEXT_GDC + 2); /* dummy */
- inb(TEXT_GDC + 2); /* dummy */
- inb(TEXT_GDC + 2); /* dummy */
- splx(s);
-
- if (off >= ROW*COL)
- off = 0;
- *row = off / adp->va_info.vi_width;
- *col = off % adp->va_info.vi_width;
-
- return 0;
-}
-
-/*
- * set_hw_cursor():
- * Move the hardware text cursor. If col and row are both -1,
- * the cursor won't be shown.
- */
-static int
-gdc_set_hw_cursor(video_adapter_t *adp, int col, int row)
-{
- u_int16_t off;
- int s;
-
- if (!gdc_init_done)
- return ENXIO;
-
- if ((col == -1) && (row == -1)) {
- off = -1;
- } else {
- if (adp->va_info.vi_flags & V_INFO_GRAPHICS)
- return ENODEV;
- off = row*adp->va_info.vi_width + col;
- }
-
- s = spltty();
- master_gdc_cmd(0x49); /* _GDC_CSRW */
- master_gdc_word_prm(off);
- splx(s);
-
- return 0;
-}
-
-/*
- * set_hw_cursor_shape():
- * Change the shape of the hardware text cursor. If the height is zero
- * or negative, the cursor won't be shown.
- */
-static int
-gdc_set_hw_cursor_shape(video_adapter_t *adp, int base, int height,
- int celsize, int blink)
-{
- int start;
- int end;
- int s;
-
- if (!gdc_init_done)
- return ENXIO;
-
- start = celsize - (base + height);
- end = celsize - base - 1;
- /*
- * muPD7220 GDC has anomaly that if end == celsize - 1 then start
- * must be 0, otherwise the cursor won't be correctly shown
- * in the first row in the screen. We shall set end to celsize - 2;
- * if end == celsize -1 && start > 0. XXX
- */
- if ((end == celsize - 1) && (start > 0))
- --end;
-
- s = spltty();
- master_gdc_cmd(0x4b); /* _GDC_CSRFORM */
- master_gdc_prm(((height > 0) ? 0x80 : 0) /* cursor on/off */
- | ((celsize - 1) & 0x1f)); /* cel size */
- master_gdc_word_prm(((end & 0x1f) << 11) /* end line */
- | (12 << 6) /* blink rate */
- | (blink ? 0x20 : 0) /* blink on/off */
- | (start & 0x1f)); /* start line */
- splx(s);
-
- return 0;
-}
-
-/*
- * blank_display()
- * Put the display in power save/power off mode.
- */
-static int
-gdc_blank_display(video_adapter_t *adp, int mode)
-{
- int s;
-
- if (!gdc_init_done)
- return ENXIO;
-
- s = splhigh();
- switch (mode) {
- case V_DISPLAY_SUSPEND:
- case V_DISPLAY_STAND_BY:
- /*
- * FIXME: I don't know how to put the display into `suspend'
- * or `stand-by' mode via GDC...
- */
- /* FALL THROUGH */
-
- case V_DISPLAY_BLANK:
- if (epson_machine_id == 0x20) {
- outb(0x43f, 0x42);
- outb(0xc17, inb(0xc17) & ~0x08); /* turn off side light */
- outb(0xc16, inb(0xc16) & ~0x02); /* turn off back light */
- outb(0x43f, 0x40);
- } else {
- while (!(inb(TEXT_GDC) & 0x20)) /* V-SYNC wait */
- ;
- outb(TEXT_GDC + 2, 0xc); /* text off */
- }
- break;
-
- case V_DISPLAY_ON:
- if (epson_machine_id == 0x20) {
- outb(0x43f, 0x42);
- outb(0xc17, inb(0xc17) | 0x08);
- outb(0xc16, inb(0xc16) | 0x02);
- outb(0x43f, 0x40);
- } else {
- while (!(inb(TEXT_GDC) & 0x20)) /* V-SYNC wait */
- ;
- outb(TEXT_GDC + 2, 0xd); /* text on */
- }
- break;
- }
- splx(s);
- return 0;
-}
-
-/*
- * mmap():
- * Mmap frame buffer.
- */
-static int
-gdc_mmap_buf(video_adapter_t *adp, vm_offset_t offset, int prot)
-{
- /* FIXME: is this correct? XXX */
- if (offset > VIDEO_BUF_SIZE - PAGE_SIZE)
- return -1;
- return i386_btop(adp->va_info.vi_window + offset);
-}
-
-static int
-gdc_dev_ioctl(video_adapter_t *adp, u_long cmd, caddr_t arg)
-{
- switch (cmd) {
- case FBIO_GETWINORG: /* get frame buffer window origin */
- *(u_int *)arg = 0;
- return 0;
-
- case FBIO_SETWINORG: /* set frame buffer window origin */
- case FBIO_SETDISPSTART: /* set display start address */
- case FBIO_SETLINEWIDTH: /* set scan line length in pixel */
- case FBIO_GETPALETTE: /* get color palette */
- case FBIO_SETPALETTE: /* set color palette */
- case FBIOGETCMAP: /* get color palette */
- case FBIOPUTCMAP: /* set color palette */
- return ENODEV;
-
- case FBIOGTYPE: /* get frame buffer type info. */
- ((struct fbtype *)arg)->fb_type = fb_type(adp->va_type);
- ((struct fbtype *)arg)->fb_height = adp->va_info.vi_height;
- ((struct fbtype *)arg)->fb_width = adp->va_info.vi_width;
- ((struct fbtype *)arg)->fb_depth = adp->va_info.vi_depth;
- if ((adp->va_info.vi_depth <= 1) || (adp->va_info.vi_depth > 8))
- ((struct fbtype *)arg)->fb_cmsize = 0;
- else
- ((struct fbtype *)arg)->fb_cmsize = 1 << adp->va_info.vi_depth;
- ((struct fbtype *)arg)->fb_size = adp->va_buffer_size;
- return 0;
-
- default:
- return fb_commonioctl(adp, cmd, arg);
- }
-}
-
-static void
-dump_buffer(u_char *buf, size_t len)
-{
- int i;
-
- for(i = 0; i < len;) {
- printf("%02x ", buf[i]);
- if ((++i % 16) == 0)
- printf("\n");
- }
-}
-
-/*
- * diag():
- * Print some information about the video adapter and video modes,
- * with requested level of details.
- */
-static int
-gdc_diag(video_adapter_t *adp, int level)
-{
-#if FB_DEBUG > 1
- int i;
-#endif
-
- if (!gdc_init_done)
- return ENXIO;
-
- fb_dump_adp_info(DRIVER_NAME, adp, level);
-
-#if FB_DEBUG > 1
- for (i = 0; bios_vmode[i].vi_mode != EOT; ++i) {
- if (bios_vmode[i].vi_mode == NA)
- continue;
- if (get_mode_param(bios_vmode[i].vi_mode) == NULL)
- continue;
- fb_dump_mode_info(DRIVER_NAME, adp, &bios_vmode[i], level);
- }
-#endif
-
- return 0;
-}
-
-#endif /* NGDC > 0 */
diff --git a/sys/pc98/cbus/olpt.c b/sys/pc98/cbus/olpt.c
deleted file mode 100644
index 43ce7183ab6d..000000000000
--- a/sys/pc98/cbus/olpt.c
+++ /dev/null
@@ -1,1438 +0,0 @@
-/*
- * 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.
- *
- * from: unknown origin, 386BSD 0.1
- * $FreeBSD$
- */
-
-/*
- * Device Driver for AT parallel printer port
- * Written by William Jolitz 12/18/90
- */
-
-/*
- * Parallel port TCP/IP interfaces added. I looked at the driver from
- * MACH but this is a complete rewrite, and btw. incompatible, and it
- * should perform better too. I have never run the MACH driver though.
- *
- * This driver sends two bytes (0x08, 0x00) in front of each packet,
- * to allow us to distinguish another format later.
- *
- * Now added an Linux/Crynwr compatibility mode which is enabled using
- * IF_LINK0 - Tim Wilkinson.
- *
- * TODO:
- * Make HDLC/PPP mode, use IF_LLC1 to enable.
- *
- * Connect the two computers using a Laplink parallel cable to use this
- * feature:
- *
- * +----------------------------------------+
- * |A-name A-End B-End Descr. Port/Bit |
- * +----------------------------------------+
- * |DATA0 2 15 Data 0/0x01 |
- * |-ERROR 15 2 1/0x08 |
- * +----------------------------------------+
- * |DATA1 3 13 Data 0/0x02 |
- * |+SLCT 13 3 1/0x10 |
- * +----------------------------------------+
- * |DATA2 4 12 Data 0/0x04 |
- * |+PE 12 4 1/0x20 |
- * +----------------------------------------+
- * |DATA3 5 10 Strobe 0/0x08 |
- * |-ACK 10 5 1/0x40 |
- * +----------------------------------------+
- * |DATA4 6 11 Data 0/0x10 |
- * |BUSY 11 6 1/~0x80 |
- * +----------------------------------------+
- * |GND 18-25 18-25 GND - |
- * +----------------------------------------+
- *
- * Expect transfer-rates up to 75 kbyte/sec.
- *
- * If GCC could correctly grok
- * register int port asm("edx")
- * the code would be cleaner
- *
- * Poul-Henning Kamp <phk@freebsd.org>
- */
-
-#include "olpt.h"
-#include "opt_inet.h"
-#ifdef PC98
-#undef INET /* PLIP is not supported for old PC-98 */
-#endif
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/conf.h>
-#include <sys/buf.h>
-#include <sys/kernel.h>
-#include <sys/uio.h>
-#include <sys/syslog.h>
-#include <machine/clock.h>
-#include <machine/lpt.h>
-
-#include <i386/isa/isa_device.h>
-#include <i386/isa/lptreg.h>
-
-#ifdef INET
-#include <sys/malloc.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <sys/sockio.h>
-
-#include <net/if.h>
-#include <net/if_types.h>
-#include <net/netisr.h>
-#include <netinet/in.h>
-#include <netinet/in_var.h>
-#include <net/bpf.h>
-#endif /* INET */
-
-
-#define LPINITRDY 4 /* wait up to 4 seconds for a ready */
-#define LPTOUTINITIAL 10 /* initial timeout to wait for ready 1/10 s */
-#define LPTOUTMAX 1 /* maximal timeout 1 s */
-#define LPPRI (PZERO+8)
-#define BUFSIZE 1024
-
-#ifdef INET
-#ifndef LPMTU /* MTU for the lp# interfaces */
-#define LPMTU 1500
-#endif
-
-#ifndef LPMAXSPIN1 /* DELAY factor for the lp# interfaces */
-#define LPMAXSPIN1 8000 /* Spinning for remote intr to happen */
-#endif
-
-#ifndef LPMAXSPIN2 /* DELAY factor for the lp# interfaces */
-#define LPMAXSPIN2 500 /* Spinning for remote handshake to happen */
-#endif
-
-#ifndef LPMAXERRS /* Max errors before !RUNNING */
-#define LPMAXERRS 100
-#endif
-
-#define CLPIPHDRLEN 14 /* We send dummy ethernet addresses (two) + packet type in front of packet */
-#define CLPIP_SHAKE 0x80 /* This bit toggles between nibble reception */
-#define MLPIPHDRLEN CLPIPHDRLEN
-
-#define LPIPHDRLEN 2 /* We send 0x08, 0x00 in front of packet */
-#define LPIP_SHAKE 0x40 /* This bit toggles between nibble reception */
-#if !defined(MLPIPHDRLEN) || LPIPHDRLEN > MLPIPHDRLEN
-#define MLPIPHDRLEN LPIPHDRLEN
-#endif
-
-#define LPIPTBLSIZE 256 /* Size of octet translation table */
-
-#endif /* INET */
-
-#ifndef PC98
-/* BIOS printer list - used by BIOS probe*/
-#define BIOS_LPT_PORTS 0x408
-#define BIOS_PORTS (short *)(KERNBASE+BIOS_LPT_PORTS)
-#define BIOS_MAX_LPT 4
-#endif
-
-
-#ifndef DEBUG
-#define lprintf(args)
-#else
-#define lprintf(args) do { \
- if (lptflag) \
- printf args; \
- } while (0)
-static int volatile lptflag = 1;
-#endif
-
-#define LPTUNIT(s) ((s)&0x03)
-#define LPTFLAGS(s) ((s)&0xfc)
-
-static struct lpt_softc {
- int sc_port;
- short sc_state;
- /* default case: negative prime, negative ack, handshake strobe,
- prime once */
- u_char sc_control;
- char sc_flags;
-#define LP_POS_INIT 0x04 /* if we are a postive init signal */
-#define LP_POS_ACK 0x08 /* if we are a positive going ack */
-#define LP_NO_PRIME 0x10 /* don't prime the printer at all */
-#define LP_PRIMEOPEN 0x20 /* prime on every open */
-#define LP_AUTOLF 0x40 /* tell printer to do an automatic lf */
-#define LP_BYPASS 0x80 /* bypass printer ready checks */
- struct buf *sc_inbuf;
- short sc_xfercnt ;
- char sc_primed;
- char *sc_cp ;
- u_char sc_irq ; /* IRQ status of port */
-#define LP_HAS_IRQ 0x01 /* we have an irq available */
-#define LP_USE_IRQ 0x02 /* we are using our irq */
-#define LP_ENABLE_IRQ 0x04 /* enable IRQ on open */
- u_char sc_backoff ; /* time to call lptout() again */
-
-#ifdef INET
- struct ifnet sc_if;
- u_char *sc_ifbuf;
- int sc_iferrs;
-#endif
-} lpt_sc[NOLPT] ;
-
-/* bits for state */
-#define OPEN (1<<0) /* device is open */
-#define ASLP (1<<1) /* awaiting draining of printer */
-#define ERROR (1<<2) /* error was received from printer */
-#define OBUSY (1<<3) /* printer is busy doing output */
-#define LPTOUT (1<<4) /* timeout while not selected */
-#define TOUT (1<<5) /* timeout while not selected */
-#define INIT (1<<6) /* waiting to initialize for open */
-#define INTERRUPTED (1<<7) /* write call was interrupted */
-
-
-/* status masks to interrogate printer status */
-#define RDY_MASK (LPS_SEL|LPS_OUT|LPS_NBSY|LPS_NERR) /* ready ? */
-#define LP_READY (LPS_SEL|LPS_NBSY|LPS_NERR)
-
-/* Printer Ready condition - from lpa.c */
-/* Only used in polling code */
-#ifdef PC98
-#define NOT_READY(x) ((inb(x) & LPS_NBSY) != LPS_NBSY)
-#else /* IBM-PC */
-#define LPS_INVERT (LPS_NBSY | LPS_NACK | LPS_SEL | LPS_NERR)
-#define LPS_MASK (LPS_NBSY | LPS_NACK | LPS_OUT | LPS_SEL | LPS_NERR)
-#define NOT_READY(x) ((inb(x)^LPS_INVERT)&LPS_MASK)
-#endif
-
-#define MAX_SLEEP (hz*5) /* Timeout while waiting for device ready */
-#define MAX_SPIN 20 /* Max delay for device ready in usecs */
-
-static timeout_t lptout;
-static int lptprobe (struct isa_device *dvp);
-static int lptattach (struct isa_device *isdp);
-static ointhand2_t lptintr;
-
-#ifdef INET
-
-/* Tables for the lp# interface */
-static u_char *txmith;
-#define txmitl (txmith+(1*LPIPTBLSIZE))
-#define trecvh (txmith+(2*LPIPTBLSIZE))
-#define trecvl (txmith+(3*LPIPTBLSIZE))
-
-static u_char *ctxmith;
-#define ctxmitl (ctxmith+(1*LPIPTBLSIZE))
-#define ctrecvh (ctxmith+(2*LPIPTBLSIZE))
-#define ctrecvl (ctxmith+(3*LPIPTBLSIZE))
-
-/* Functions for the lp# interface */
-static void lpattach(struct lpt_softc *,int);
-#ifndef PC98
-static int lpinittables(void);
-#endif
-static int lpioctl(struct ifnet *, u_long, caddr_t);
-static int lpoutput(struct ifnet *, struct mbuf *, struct sockaddr *,
- struct rtentry *);
-static void lpintr(int);
-#endif /* INET */
-
-struct isa_driver olptdriver = {
- lptprobe, lptattach, "olpt"
-};
-
-static d_open_t lptopen;
-static d_close_t lptclose;
-static d_write_t lptwrite;
-static d_ioctl_t lptioctl;
-
-#define CDEV_MAJOR 16
-static struct cdevsw lpt_cdevsw = {
- /* open */ lptopen,
- /* close */ lptclose,
- /* read */ noread,
- /* write */ lptwrite,
- /* ioctl */ lptioctl,
- /* poll */ nopoll,
- /* mmap */ nommap,
- /* strategy */ nostrategy,
- /* name */ "lpt",
- /* maj */ CDEV_MAJOR,
- /* dump */ nodump,
- /* psize */ nopsize,
- /* flags */ 0,
- /* bmaj */ -1
-};
-
-#ifndef PC98
-/*
- * Internal routine to lptprobe to do port tests of one byte value
- */
-static int
-lpt_port_test (int port, u_char data, u_char mask)
-{
- int temp, timeout;
-
- data = data & mask;
- outb(port, data);
- timeout = 10000;
- do {
- DELAY(10);
- temp = inb(port) & mask;
- }
- while (temp != data && --timeout);
- lprintf(("Port 0x%x\tout=%x\tin=%x\ttout=%d\n",
- port, data, temp, timeout));
- return (temp == data);
-}
-#endif /* PC98 */
-
-/*
- * New lpt port probe Geoff Rehmet - Rhodes University - 14/2/94
- * Based partially on Rod Grimes' printer probe
- *
- * Logic:
- * 1) If no port address was given, use the bios detected ports
- * and autodetect what ports the printers are on.
- * 2) Otherwise, probe the data port at the address given,
- * using the method in Rod Grimes' port probe.
- * (Much code ripped off directly from Rod's probe.)
- *
- * Comments from Rod's probe:
- * 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 manauls 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.
- *
- * We are finally left with a mask of 0x14, due to some printers
- * being adamant about holding other bits high ........
- *
- * Before probing the control port, we write a 0 to the data port -
- * If not, some printers chuck out garbage when the strobe line
- * gets toggled.
- *
- * 3) Set the data and control ports to a value of 0
- *
- * This probe routine has been tested on Epson Lx-800, HP LJ3P,
- * Epson FX-1170 and C.Itoh 8510RM
- * printers.
- * Quick exit on fail added.
- */
-
-int
-lptprobe(struct isa_device *dvp)
-{
-#ifdef PC98
-#define PC98_OLD_LPT 0x40
-#define PC98_IEEE_1284_FUNCTION 0x149
- unsigned int pc98_ieee_mode, tmp;
-
- if (dvp->id_iobase == PC98_OLD_LPT) {
- tmp = inb(PC98_IEEE_1284_FUNCTION);
- pc98_ieee_mode = tmp;
- if ((tmp & 0x10) == 0x10) {
- outb(PC98_IEEE_1284_FUNCTION, tmp & ~0x10);
- tmp = inb(PC98_IEEE_1284_FUNCTION);
- if ((tmp & 0x10) != 0x10) {
- outb(PC98_IEEE_1284_FUNCTION, pc98_ieee_mode);
- return 0;
- }
- }
- }
- return 8;
-#else
- int port;
- static short next_bios_lpt = 0;
- int status;
- static u_char testbyte[18] = {
- 0x55, /* alternating zeros */
- 0xaa, /* alternating ones */
- 0xfe, 0xfd, 0xfb, 0xf7,
- 0xef, 0xdf, 0xbf, 0x7f, /* walking zero */
- 0x01, 0x02, 0x04, 0x08,
- 0x10, 0x20, 0x40, 0x80 /* walking one */
- };
- int i;
-
- /*
- * Make sure there is some way for lptopen to see that
- * the port is not configured
- * This 0 will remain if the port isn't attached
- */
- (lpt_sc + dvp->id_unit)->sc_port = 0;
-
- status = IO_LPTSIZE;
- /* If port not specified, use bios list */
- if(dvp->id_iobase < 0) { /* port? */
- if((next_bios_lpt < BIOS_MAX_LPT) &&
- (*(BIOS_PORTS+next_bios_lpt) != 0) ) {
- dvp->id_iobase = *(BIOS_PORTS+next_bios_lpt++);
- goto end_probe;
- } else
- return (0);
- }
-
- /* Port was explicitly specified */
- /* This allows probing of ports unknown to the BIOS */
- port = dvp->id_iobase + lpt_data;
- for (i = 0; i < 18; i++) {
- if (!lpt_port_test(port, testbyte[i], 0xff)) {
- status = 0;
- goto end_probe;
- }
- }
-
-end_probe:
- /* write 0's to control and data ports */
- outb(dvp->id_iobase+lpt_data, 0);
- outb(dvp->id_iobase+lpt_control, 0);
-
- return (status);
-#endif
-}
-
-/* XXX Todo - try and detect if interrupt is working */
-int
-lptattach(struct isa_device *isdp)
-{
- struct lpt_softc *sc;
- int unit;
-
- isdp->id_ointr = lptintr;
- unit = isdp->id_unit;
- sc = lpt_sc + unit;
- sc->sc_port = isdp->id_iobase;
- sc->sc_primed = 0; /* not primed yet */
-#ifdef PC98
- outb(sc->sc_port+lpt_pstb_ctrl, LPC_DIS_PSTB); /* PSTB disable */
- outb(sc->sc_port+lpt_control, LPC_MODE8255); /* 8255 mode set */
- outb(sc->sc_port+lpt_control, LPC_NIRQ8); /* IRQ8 inactive */
- outb(sc->sc_port+lpt_control, LPC_NPSTB); /* PSTB inactive */
- outb(sc->sc_port+lpt_pstb_ctrl, LPC_EN_PSTB); /* PSTB enable */
-#else
- outb(sc->sc_port+lpt_control, LPC_NINIT);
-#endif
-
- /* check if we can use interrupt */
- lprintf(("oldirq %x\n", sc->sc_irq));
- if (isdp->id_irq) {
- sc->sc_irq = LP_HAS_IRQ | LP_USE_IRQ | LP_ENABLE_IRQ;
- printf("lpt%d: Interrupt-driven port\n", unit);
-#ifdef INET
- lpattach(sc, unit);
-#endif
- } else {
- sc->sc_irq = 0;
- lprintf(("lpt%d: Polled port\n", unit));
- }
- lprintf(("irq %x\n", sc->sc_irq));
-
- /* XXX what to do about the flags in the minor number? */
- make_dev(&lpt_cdevsw, unit, UID_ROOT, GID_WHEEL, 0600, "lpt%d", unit);
- make_dev(&lpt_cdevsw, unit | LP_BYPASS,
- UID_ROOT, GID_WHEEL, 0600, "lpctl%d", unit);
- return (1);
-}
-
-/*
- * lptopen -- reset the printer, then wait until it's selected and not busy.
- * If LP_BYPASS flag is selected, then we do not try to select the
- * printer -- this is just used for passing ioctls.
- */
-
-static int
-lptopen (dev_t dev, int flags, int fmt, struct proc *p)
-{
- struct lpt_softc *sc;
- int s;
-#ifdef PC98
- int port;
-#else
- int trys, port;
-#endif
- u_int unit = LPTUNIT(minor(dev));
-
- sc = lpt_sc + unit;
- if ((unit >= NOLPT) || (sc->sc_port == 0))
- return (ENXIO);
-
-#ifdef INET
- if (sc->sc_if.if_flags & IFF_UP)
- return(EBUSY);
-#endif
-
- if (sc->sc_state) {
- lprintf(("lp: still open %x\n", sc->sc_state));
- return(EBUSY);
- } else
- sc->sc_state |= INIT;
-
- sc->sc_flags = LPTFLAGS(minor(dev));
-
- /* Check for open with BYPASS flag set. */
- if (sc->sc_flags & LP_BYPASS) {
- sc->sc_state = OPEN;
- return(0);
- }
-
- s = spltty();
- lprintf(("lp flags 0x%x\n", sc->sc_flags));
- port = sc->sc_port;
-
- /* set IRQ status according to ENABLE_IRQ flag */
- if (sc->sc_irq & LP_ENABLE_IRQ)
- sc->sc_irq |= LP_USE_IRQ;
- else
- sc->sc_irq &= ~LP_USE_IRQ;
-
- /* init printer */
-#ifndef PC98
- if ((sc->sc_flags & LP_NO_PRIME) == 0) {
- if((sc->sc_flags & LP_PRIMEOPEN) || sc->sc_primed == 0) {
- outb(port+lpt_control, 0);
- sc->sc_primed++;
- DELAY(500);
- }
- }
-
- outb (port+lpt_control, LPC_SEL|LPC_NINIT);
-
- /* wait till ready (printer running diagnostics) */
- trys = 0;
- do {
- /* ran out of waiting for the printer */
- if (trys++ >= LPINITRDY*4) {
- splx(s);
- sc->sc_state = 0;
- lprintf(("status %x\n", inb(port+lpt_status)));
- return (EBUSY);
- }
-
- /* wait 1/4 second, give up if we get a signal */
- if (tsleep ((caddr_t)sc, LPPRI|PCATCH, "lptinit", hz/4) !=
- EWOULDBLOCK) {
- sc->sc_state = 0;
- splx(s);
- return (EBUSY);
- }
-
- /* is printer online and ready for output */
- } while ((inb(port+lpt_status) & (LPS_SEL|LPS_OUT|LPS_NBSY|LPS_NERR)) !=
- (LPS_SEL|LPS_NBSY|LPS_NERR));
-
- sc->sc_control = LPC_SEL|LPC_NINIT;
- if (sc->sc_flags & LP_AUTOLF)
- sc->sc_control |= LPC_AUTOL;
-
- /* enable interrupt if interrupt-driven */
- if (sc->sc_irq & LP_USE_IRQ)
- sc->sc_control |= LPC_ENA;
-
- outb(port+lpt_control, sc->sc_control);
-#endif
-
- sc->sc_state = OPEN;
- sc->sc_inbuf = geteblk(BUFSIZE);
- sc->sc_xfercnt = 0;
- splx(s);
-
- /* only use timeout if using interrupt */
- lprintf(("irq %x\n", sc->sc_irq));
- if (sc->sc_irq & LP_USE_IRQ) {
- sc->sc_state |= TOUT;
- timeout (lptout, (caddr_t)sc,
- (sc->sc_backoff = hz/LPTOUTINITIAL));
- }
-
- lprintf(("opened.\n"));
- return(0);
-}
-
-static void
-lptout (void *arg)
-{
- struct lpt_softc *sc = arg;
- int pl;
-
- lprintf(("T %x ", inb(sc->sc_port+lpt_status)));
- if (sc->sc_state & OPEN) {
- sc->sc_backoff++;
- if (sc->sc_backoff > hz/LPTOUTMAX)
- sc->sc_backoff = sc->sc_backoff > hz/LPTOUTMAX;
- timeout (lptout, (caddr_t)sc, sc->sc_backoff);
- } else
- sc->sc_state &= ~TOUT;
-
- if (sc->sc_state & ERROR)
- sc->sc_state &= ~ERROR;
-
- /*
- * Avoid possible hangs do to missed interrupts
- */
- if (sc->sc_xfercnt) {
- pl = spltty();
- lptintr(sc - lpt_sc);
- splx(pl);
- } else {
- sc->sc_state &= ~OBUSY;
- wakeup((caddr_t)sc);
- }
-}
-
-/*
- * lptclose -- close the device, free the local line buffer.
- *
- * Check for interrupted write call added.
- */
-
-static int
-lptclose(dev_t dev, int flags, int fmt, struct proc *p)
-{
- struct lpt_softc *sc = lpt_sc + LPTUNIT(minor(dev));
-#ifndef PC98
- int port = sc->sc_port;
-#endif
-
- if(sc->sc_flags & LP_BYPASS)
- goto end_close;
-
- sc->sc_state &= ~OPEN;
-
-#ifndef PC98
- /* if the last write was interrupted, don't complete it */
- if((!(sc->sc_state & INTERRUPTED)) && (sc->sc_irq & LP_USE_IRQ))
- while ((inb(port+lpt_status) & (LPS_SEL|LPS_OUT|LPS_NBSY|LPS_NERR)) !=
- (LPS_SEL|LPS_NBSY|LPS_NERR) || sc->sc_xfercnt)
- /* wait 1/4 second, give up if we get a signal */
- if (tsleep ((caddr_t)sc, LPPRI|PCATCH,
- "lpclose", hz) != EWOULDBLOCK)
- break;
-
- outb(sc->sc_port+lpt_control, LPC_NINIT);
-#endif
- brelse(sc->sc_inbuf);
-
-end_close:
- sc->sc_state = 0;
- sc->sc_xfercnt = 0;
- lprintf(("closed.\n"));
- return(0);
-}
-
-/*
- * pushbytes()
- * Workhorse for actually spinning and writing bytes to printer
- * Derived from lpa.c
- * Originally by ?
- *
- * This code is only used when we are polling the port
- */
-static int
-pushbytes(struct lpt_softc * sc)
-{
- int spin, err, tic;
- char ch;
- int port = sc->sc_port;
-
- lprintf(("p"));
- /* loop for every character .. */
- while (sc->sc_xfercnt > 0) {
- /* printer data */
- ch = *(sc->sc_cp);
- sc->sc_cp++;
- sc->sc_xfercnt--;
-
- /*
- * Wait for printer ready.
- * Loop 20 usecs testing BUSY bit, then sleep
- * for exponentially increasing timeout. (vak)
- */
- for (spin=0; NOT_READY(port+lpt_status) && spin<MAX_SPIN; ++spin)
- DELAY(1); /* XXX delay is NOT this accurate! */
- if (spin >= MAX_SPIN) {
- tic = 0;
- while (NOT_READY(port+lpt_status)) {
- /*
- * Now sleep, every cycle a
- * little longer ..
- */
- tic = tic + tic + 1;
- /*
- * But no more than 10 seconds. (vak)
- */
- if (tic > MAX_SLEEP)
- tic = MAX_SLEEP;
- err = tsleep((caddr_t)sc, LPPRI,
- "lptpoll", tic);
- if (err != EWOULDBLOCK) {
- return (err);
- }
- }
- }
-
- /* output data */
- outb(port+lpt_data, ch);
-#ifdef PC98
- DELAY(1);
- outb(port+lpt_control, LPC_PSTB);
- DELAY(1);
- outb(port+lpt_control, LPC_NPSTB);
-#else
- /* strobe */
- outb(port+lpt_control, sc->sc_control|LPC_STB);
- outb(port+lpt_control, sc->sc_control);
-#endif
-
- }
- return(0);
-}
-
-/*
- * lptwrite --copy a line from user space to a local buffer, then call
- * putc to get the chars moved to the output queue.
- *
- * Flagging of interrupted write added.
- */
-
-static int
-lptwrite(dev_t dev, struct uio * uio, int ioflag)
-{
- register unsigned n;
- int pl, err;
- struct lpt_softc *sc = lpt_sc + LPTUNIT(minor(dev));
-
- if(sc->sc_flags & LP_BYPASS) {
- /* we can't do writes in bypass mode */
- return(EPERM);
- }
-
- sc->sc_state &= ~INTERRUPTED;
- while ((n = min(BUFSIZE, uio->uio_resid)) != 0) {
- sc->sc_cp = sc->sc_inbuf->b_data ;
- uiomove(sc->sc_cp, n, uio);
- sc->sc_xfercnt = n ;
- while ((sc->sc_xfercnt > 0)&&(sc->sc_irq & LP_USE_IRQ)) {
- lprintf(("i"));
- /* if the printer is ready for a char, */
- /* give it one */
- if ((sc->sc_state & OBUSY) == 0){
- lprintf(("\nC %d. ", sc->sc_xfercnt));
- pl = spltty();
- lptintr(sc - lpt_sc);
- (void) splx(pl);
- }
- lprintf(("W "));
- if (sc->sc_state & OBUSY)
- if ((err = tsleep ((caddr_t)sc,
- LPPRI|PCATCH, "lpwrite", 0))) {
- sc->sc_state |= INTERRUPTED;
- return(err);
- }
- }
- /* check to see if we must do a polled write */
- if(!(sc->sc_irq & LP_USE_IRQ) && (sc->sc_xfercnt)) {
- lprintf(("p"));
- if((err = pushbytes(sc)))
- return(err);
- }
- }
- return(0);
-}
-
-/*
- * lptintr -- handle printer interrupts which occur when the printer is
- * ready to accept another char.
- *
- * do checking for interrupted write call.
- */
-
-static void
-lptintr(int unit)
-{
-#if defined(INET) || !defined(PC98)
- struct lpt_softc *sc = lpt_sc + unit;
-#endif
-#ifndef PC98
- int port = sc->sc_port, sts;
- int i;
-#endif
-
-#ifdef INET
- if(sc->sc_if.if_flags & IFF_UP) {
- lpintr(unit);
- return;
- }
-#endif /* INET */
-
-#ifndef PC98
- /*
- * Is printer online and ready for output?
- *
- * Avoid falling back to lptout() too quickly. First spin-loop
- * to see if the printer will become ready ``really soon now''.
- */
- for (i = 0;
- i < 100 &&
- ((sts=inb(port+lpt_status)) & RDY_MASK) != LP_READY;
- i++) ;
- if ((sts & RDY_MASK) == LP_READY) {
- sc->sc_state = (sc->sc_state | OBUSY) & ~ERROR;
- sc->sc_backoff = hz/LPTOUTINITIAL;
-
- if (sc->sc_xfercnt) {
- /* send char */
- /*lprintf(("%x ", *sc->sc_cp)); */
- outb(port+lpt_data, *sc->sc_cp++) ;
- outb(port+lpt_control, sc->sc_control|LPC_STB);
- /* DELAY(X) */
- outb(port+lpt_control, sc->sc_control);
-
- /* any more data for printer */
- if(--(sc->sc_xfercnt) > 0) return;
- }
-
- /*
- * No more data waiting for printer.
- * Wakeup is not done if write call was interrupted.
- */
- sc->sc_state &= ~OBUSY;
- if(!(sc->sc_state & INTERRUPTED))
- wakeup((caddr_t)sc);
- lprintf(("w "));
- return;
- } else { /* check for error */
- if(((sts & (LPS_NERR | LPS_OUT) ) != LPS_NERR) &&
- (sc->sc_state & OPEN))
- sc->sc_state |= ERROR;
- /* lptout() will jump in and try to restart. */
- }
-#endif
- lprintf(("sts %x ", sts));
-}
-
-static int
-lptioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p)
-{
- int error = 0;
- struct lpt_softc *sc;
- u_int unit = LPTUNIT(minor(dev));
- u_char old_sc_irq; /* old printer IRQ status */
-
- sc = lpt_sc + unit;
-
- switch (cmd) {
- case LPT_IRQ :
- if(sc->sc_irq & LP_HAS_IRQ) {
- /*
- * NOTE:
- * If the IRQ status is changed,
- * this will only be visible on the
- * next open.
- *
- * If interrupt status changes,
- * this gets syslog'd.
- */
- old_sc_irq = sc->sc_irq;
- if(*(int*)data == 0)
- sc->sc_irq &= (~LP_ENABLE_IRQ);
- else
- sc->sc_irq |= LP_ENABLE_IRQ;
- if (old_sc_irq != sc->sc_irq )
- log(LOG_NOTICE, "lpt%c switched to %s mode\n",
- (char)unit+'0',
- (sc->sc_irq & LP_ENABLE_IRQ)?
- "interrupt-driven":"polled");
- } else /* polled port */
- error = EOPNOTSUPP;
- break;
- default:
- error = ENODEV;
- }
-
- return(error);
-}
-
-#ifdef INET
-
-static void
-lpattach (struct lpt_softc *sc, int unit)
-{
- struct ifnet *ifp = &sc->sc_if;
-
- ifp->if_softc = sc;
- ifp->if_name = "lp";
- ifp->if_unit = unit;
- ifp->if_mtu = LPMTU;
- ifp->if_flags = IFF_SIMPLEX | IFF_POINTOPOINT | IFF_MULTICAST;
- ifp->if_ioctl = lpioctl;
- ifp->if_output = lpoutput;
- ifp->if_type = IFT_PARA;
- ifp->if_hdrlen = 0;
- ifp->if_addrlen = 0;
- ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
- if_attach(ifp);
- printf("lp%d: TCP/IP capable interface\n", unit);
-
- bpfattach(ifp, DLT_NULL, LPIPHDRLEN);
-}
-
-#ifndef PC98
-/*
- * Build the translation tables for the LPIP (BSD unix) protocol.
- * We don't want to calculate these nasties in our tight loop, so we
- * precalculate them when we initialize.
- */
-static int
-lpinittables (void)
-{
- int i;
-
- if (!txmith)
- txmith = malloc(4*LPIPTBLSIZE, M_DEVBUF, M_NOWAIT);
-
- if (!txmith)
- return 1;
-
- if (!ctxmith)
- ctxmith = malloc(4*LPIPTBLSIZE, M_DEVBUF, M_NOWAIT);
-
- if (!ctxmith)
- return 1;
-
- for (i=0; i < LPIPTBLSIZE; i++) {
- ctxmith[i] = (i & 0xF0) >> 4;
- ctxmitl[i] = 0x10 | (i & 0x0F);
- ctrecvh[i] = (i & 0x78) << 1;
- ctrecvl[i] = (i & 0x78) >> 3;
- }
-
- for (i=0; i < LPIPTBLSIZE; i++) {
- txmith[i] = ((i & 0x80) >> 3) | ((i & 0x70) >> 4) | 0x08;
- txmitl[i] = ((i & 0x08) << 1) | (i & 0x07);
- trecvh[i] = ((~i) & 0x80) | ((i & 0x38) << 1);
- trecvl[i] = (((~i) & 0x80) >> 4) | ((i & 0x38) >> 3);
- }
-
- return 0;
-}
-#endif /* PC98 */
-
-/*
- * Process an ioctl request.
- */
-
-static int
-lpioctl (struct ifnet *ifp, u_long cmd, caddr_t data)
-{
- struct lpt_softc *sc = lpt_sc + ifp->if_unit;
- struct ifaddr *ifa = (struct ifaddr *)data;
- struct ifreq *ifr = (struct ifreq *)data;
- u_char *ptr;
-
- switch (cmd) {
-
- case SIOCSIFDSTADDR:
- case SIOCAIFADDR:
- case SIOCSIFADDR:
- if (ifa->ifa_addr->sa_family != AF_INET)
- return EAFNOSUPPORT;
- ifp->if_flags |= IFF_UP;
- /* FALLTHROUGH */
- case SIOCSIFFLAGS:
- if ((!(ifp->if_flags & IFF_UP)) && (ifp->if_flags & IFF_RUNNING)) {
- outb(sc->sc_port + lpt_control, 0x00);
- ifp->if_flags &= ~IFF_RUNNING;
- break;
- }
-#ifdef PC98
- /* XXX */
- return ENOBUFS;
-#else
- if (((ifp->if_flags & IFF_UP)) && (!(ifp->if_flags & IFF_RUNNING))) {
- if (lpinittables())
- return ENOBUFS;
- sc->sc_ifbuf = malloc(sc->sc_if.if_mtu + MLPIPHDRLEN,
- M_DEVBUF, M_WAITOK);
- if (!sc->sc_ifbuf)
- return ENOBUFS;
-
- outb(sc->sc_port + lpt_control, LPC_ENA);
- ifp->if_flags |= IFF_RUNNING;
- }
- break;
-#endif
- case SIOCSIFMTU:
- ptr = sc->sc_ifbuf;
- sc->sc_ifbuf = malloc(ifr->ifr_mtu+MLPIPHDRLEN, M_DEVBUF, M_NOWAIT);
- if (!sc->sc_ifbuf) {
- sc->sc_ifbuf = ptr;
- return ENOBUFS;
- }
- if (ptr)
- free(ptr,M_DEVBUF);
- sc->sc_if.if_mtu = ifr->ifr_mtu;
- break;
-
- case SIOCGIFMTU:
- ifr->ifr_mtu = sc->sc_if.if_mtu;
- break;
-
- case SIOCADDMULTI:
- case SIOCDELMULTI:
- if (ifr == 0) {
- return EAFNOSUPPORT; /* XXX */
- }
- switch (ifr->ifr_addr.sa_family) {
-
-#ifdef INET
- case AF_INET:
- break;
-#endif
-
- default:
- return EAFNOSUPPORT;
- }
- break;
-
- default:
- lprintf(("LP:ioctl(0x%lx)\n", cmd));
- return EINVAL;
- }
- return 0;
-}
-
-static __inline int
-clpoutbyte (u_char byte, int spin, int data_port, int status_port)
-{
- outb(data_port, ctxmitl[byte]);
- while (inb(status_port) & CLPIP_SHAKE)
- if (--spin == 0) {
- return 1;
- }
- outb(data_port, ctxmith[byte]);
- while (!(inb(status_port) & CLPIP_SHAKE))
- if (--spin == 0) {
- return 1;
- }
- return 0;
-}
-
-static __inline int
-clpinbyte (int spin, int data_port, int status_port)
-{
- int c, cl;
-
- while((inb(status_port) & CLPIP_SHAKE))
- if(!--spin) {
- return -1;
- }
- cl = inb(status_port);
- outb(data_port, 0x10);
-
- while(!(inb(status_port) & CLPIP_SHAKE))
- if(!--spin) {
- return -1;
- }
- c = inb(status_port);
- outb(data_port, 0x00);
-
- return (ctrecvl[cl] | ctrecvh[c]);
-}
-
-static void
-lpintr (int unit)
-{
- struct lpt_softc *sc = lpt_sc + unit;
- register int lpt_data_port = sc->sc_port + lpt_data;
- register int lpt_stat_port = sc->sc_port + lpt_status;
- int lpt_ctrl_port = sc->sc_port + lpt_control;
- int len, s, j;
- u_char *bp;
- u_char c, cl;
- struct mbuf *top;
-
- s = splhigh();
-
- if (sc->sc_if.if_flags & IFF_LINK0) {
-
- /* Ack. the request */
- outb(lpt_data_port, 0x01);
-
- /* Get the packet length */
- j = clpinbyte(LPMAXSPIN2, lpt_data_port, lpt_stat_port);
- if (j == -1)
- goto err;
- len = j;
- j = clpinbyte(LPMAXSPIN2, lpt_data_port, lpt_stat_port);
- if (j == -1)
- goto err;
- len = len + (j << 8);
- if (len > sc->sc_if.if_mtu + MLPIPHDRLEN)
- goto err;
-
- bp = sc->sc_ifbuf;
-
- while (len--) {
- j = clpinbyte(LPMAXSPIN2, lpt_data_port, lpt_stat_port);
- if (j == -1) {
- goto err;
- }
- *bp++ = j;
- }
- /* Get and ignore checksum */
- j = clpinbyte(LPMAXSPIN2, lpt_data_port, lpt_stat_port);
- if (j == -1) {
- goto err;
- }
-
- len = bp - sc->sc_ifbuf;
- if (len <= CLPIPHDRLEN)
- goto err;
-
- sc->sc_iferrs = 0;
-
- if (IF_QFULL(&ipintrq)) {
- lprintf(("DROP"));
- IF_DROP(&ipintrq);
- goto done;
- }
- len -= CLPIPHDRLEN;
- sc->sc_if.if_ipackets++;
- sc->sc_if.if_ibytes += len;
- top = m_devget(sc->sc_ifbuf + CLPIPHDRLEN, len, 0, &sc->sc_if, 0);
- if (top) {
- IF_ENQUEUE(&ipintrq, top);
- schednetisr(NETISR_IP);
- }
- goto done;
- }
- while ((inb(lpt_stat_port) & LPIP_SHAKE)) {
- len = sc->sc_if.if_mtu + LPIPHDRLEN;
- bp = sc->sc_ifbuf;
- while (len--) {
-
- cl = inb(lpt_stat_port);
- outb(lpt_data_port, 8);
-
- j = LPMAXSPIN2;
- while((inb(lpt_stat_port) & LPIP_SHAKE))
- if(!--j) goto err;
-
- c = inb(lpt_stat_port);
- outb(lpt_data_port, 0);
-
- *bp++= trecvh[cl] | trecvl[c];
-
- j = LPMAXSPIN2;
- while (!((cl=inb(lpt_stat_port)) & LPIP_SHAKE)) {
- if (cl != c &&
- (((cl = inb(lpt_stat_port)) ^ 0xb8) & 0xf8) ==
- (c & 0xf8))
- goto end;
- if (!--j) goto err;
- }
- }
-
- end:
- len = bp - sc->sc_ifbuf;
- if (len <= LPIPHDRLEN)
- goto err;
-
- sc->sc_iferrs = 0;
-
- if (IF_QFULL(&ipintrq)) {
- lprintf(("DROP"));
- IF_DROP(&ipintrq);
- goto done;
- }
- if (sc->sc_if.if_bpf) {
- bpf_tap(&sc->sc_if, sc->sc_ifbuf, len);
- }
- len -= LPIPHDRLEN;
- sc->sc_if.if_ipackets++;
- sc->sc_if.if_ibytes += len;
- top = m_devget(sc->sc_ifbuf + LPIPHDRLEN, len, 0, &sc->sc_if, 0);
- if (top) {
- IF_ENQUEUE(&ipintrq, top);
- schednetisr(NETISR_IP);
- }
- }
- goto done;
-
- err:
- outb(lpt_data_port, 0);
- lprintf(("R"));
- sc->sc_if.if_ierrors++;
- sc->sc_iferrs++;
-
- /*
- * We are not able to send receive anything for now,
- * so stop wasting our time
- */
- if (sc->sc_iferrs > LPMAXERRS) {
- printf("lp%d: Too many errors, Going off-line.\n", unit);
- outb(lpt_ctrl_port, 0x00);
- sc->sc_if.if_flags &= ~IFF_RUNNING;
- sc->sc_iferrs=0;
- }
-
- done:
- splx(s);
- return;
-}
-
-static __inline int
-lpoutbyte (u_char byte, int spin, int data_port, int status_port)
-{
- outb(data_port, txmith[byte]);
- while (!(inb(status_port) & LPIP_SHAKE))
- if (--spin == 0)
- return 1;
- outb(data_port, txmitl[byte]);
- while (inb(status_port) & LPIP_SHAKE)
- if (--spin == 0)
- return 1;
- return 0;
-}
-
-static int
-lpoutput (struct ifnet *ifp, struct mbuf *m,
- struct sockaddr *dst, struct rtentry *rt)
-{
- register int lpt_data_port = lpt_sc[ifp->if_unit].sc_port + lpt_data;
- register int lpt_stat_port = lpt_sc[ifp->if_unit].sc_port + lpt_status;
-#ifndef PC98
- int lpt_ctrl_port = lpt_sc[ifp->if_unit].sc_port + lpt_control;
-#endif
-
- int s, err;
- struct mbuf *mm;
- u_char *cp = "\0\0";
- u_char chksum = 0;
- int count = 0;
- int i;
- int spin;
-
- /* We need a sensible value if we abort */
- cp++;
- ifp->if_flags |= IFF_RUNNING;
-
- err = 1; /* assume we're aborting because of an error */
-
- s = splhigh();
-
-#ifndef PC98
- /* Suspend (on laptops) or receive-errors might have taken us offline */
- outb(lpt_ctrl_port, LPC_ENA);
-#endif
-
- if (ifp->if_flags & IFF_LINK0) {
-
- if (!(inb(lpt_stat_port) & CLPIP_SHAKE)) {
- lprintf(("&"));
- lptintr(ifp->if_unit);
- }
-
- /* Alert other end to pending packet */
- spin = LPMAXSPIN1;
- outb(lpt_data_port, 0x08);
- while ((inb(lpt_stat_port) & 0x08) == 0)
- if (--spin == 0) {
- goto nend;
- }
-
- /* Calculate length of packet, then send that */
-
- count += 14; /* Ethernet header len */
-
- mm = m;
- for (mm = m; mm; mm = mm->m_next) {
- count += mm->m_len;
- }
- if (clpoutbyte(count & 0xFF, LPMAXSPIN1, lpt_data_port, lpt_stat_port))
- goto nend;
- if (clpoutbyte((count >> 8) & 0xFF, LPMAXSPIN1, lpt_data_port, lpt_stat_port))
- goto nend;
-
- /* Send dummy ethernet header */
- for (i = 0; i < 12; i++) {
- if (clpoutbyte(i, LPMAXSPIN1, lpt_data_port, lpt_stat_port))
- goto nend;
- chksum += i;
- }
-
- if (clpoutbyte(0x08, LPMAXSPIN1, lpt_data_port, lpt_stat_port))
- goto nend;
- if (clpoutbyte(0x00, LPMAXSPIN1, lpt_data_port, lpt_stat_port))
- goto nend;
- chksum += 0x08 + 0x00; /* Add into checksum */
-
- mm = m;
- do {
- cp = mtod(mm, u_char *);
- while (mm->m_len--) {
- chksum += *cp;
- if (clpoutbyte(*cp++, LPMAXSPIN2, lpt_data_port, lpt_stat_port))
- goto nend;
- }
- } while ((mm = mm->m_next));
-
- /* Send checksum */
- if (clpoutbyte(chksum, LPMAXSPIN2, lpt_data_port, lpt_stat_port))
- goto nend;
-
- /* Go quiescent */
- outb(lpt_data_port, 0);
-
- err = 0; /* No errors */
-
- nend:
- if (err) { /* if we didn't timeout... */
- ifp->if_oerrors++;
- lprintf(("X"));
- } else {
- ifp->if_opackets++;
- ifp->if_obytes += m->m_pkthdr.len;
- }
-
- m_freem(m);
-
- if (!(inb(lpt_stat_port) & CLPIP_SHAKE)) {
- lprintf(("^"));
- lptintr(ifp->if_unit);
- }
- (void) splx(s);
- return 0;
- }
-
- if (inb(lpt_stat_port) & LPIP_SHAKE) {
- lprintf(("&"));
- lptintr(ifp->if_unit);
- }
-
- if (lpoutbyte(0x08, LPMAXSPIN1, lpt_data_port, lpt_stat_port))
- goto end;
- if (lpoutbyte(0x00, LPMAXSPIN2, lpt_data_port, lpt_stat_port))
- goto end;
-
- mm = m;
- do {
- cp = mtod(mm,u_char *);
- while (mm->m_len--)
- if (lpoutbyte(*cp++, LPMAXSPIN2, lpt_data_port, lpt_stat_port))
- goto end;
- } while ((mm = mm->m_next));
-
- err = 0; /* no errors were encountered */
-
- end:
- --cp;
- outb(lpt_data_port, txmitl[*cp] ^ 0x17);
-
- if (err) { /* if we didn't timeout... */
- ifp->if_oerrors++;
- lprintf(("X"));
- } else {
- ifp->if_opackets++;
- ifp->if_obytes += m->m_pkthdr.len;
- if (ifp->if_bpf) {
- /*
- * We need to prepend the packet type as
- * a two byte field. Cons up a dummy header
- * to pacify bpf. This is safe because bpf
- * will only read from the mbuf (i.e., it won't
- * try to free it or keep a pointer to it).
- */
- struct mbuf m0;
- u_short hdr = 0x800;
-
- m0.m_next = m;
- m0.m_len = 2;
- m0.m_data = (char *)&hdr;
-
- bpf_mtap(ifp, &m0);
- }
- }
-
- m_freem(m);
-
- if (inb(lpt_stat_port) & LPIP_SHAKE) {
- lprintf(("^"));
- lptintr(ifp->if_unit);
- }
-
- (void) splx(s);
- return 0;
-}
-
-#endif /* INET */
-
-static int lpt_devsw_installed;
-
-static void lpt_drvinit(void *unused)
-{
-
- if( ! lpt_devsw_installed ) {
- cdevsw_add(&lpt_cdevsw);
- lpt_devsw_installed = 1;
- }
-}
-
-SYSINIT(lptdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,lpt_drvinit,NULL)
-
diff --git a/sys/pc98/cbus/pckbd.c b/sys/pc98/cbus/pckbd.c
deleted file mode 100644
index b4eb1487232f..000000000000
--- a/sys/pc98/cbus/pckbd.c
+++ /dev/null
@@ -1,931 +0,0 @@
-/*
- * Copyright (c) 1999 FreeBSD(98) port team.
- * 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 as
- * the first lines of this file unmodified.
- * 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.
- *
- * $FreeBSD$
- */
-
-#include "pckbd.h"
-#include "opt_kbd.h"
-
-#if NPCKBD > 0
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/bus.h>
-#include <machine/bus.h>
-#include <sys/rman.h>
-
-#include <machine/resource.h>
-
-#include <dev/kbd/kbdreg.h>
-
-#include <pc98/pc98/pc98.h>
-
-#include <isa/isavar.h>
-#include <machine/lock.h>
-
-#define DRIVER_NAME "pckbd"
-
-/* device configuration flags */
-#define KB_CONF_FAIL_IF_NO_KBD (1 << 0) /* don't install if no kbd is found */
-
-static devclass_t pckbd_devclass;
-
-static int pckbdprobe(device_t dev);
-static int pckbdattach(device_t dev);
-static void pckbd_isa_intr(void *arg);
-
-static device_method_t pckbd_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, pckbdprobe),
- DEVMETHOD(device_attach, pckbdattach),
- { 0, 0 }
-};
-
-static driver_t pckbd_driver = {
- DRIVER_NAME,
- pckbd_methods,
- 1,
-};
-
-DRIVER_MODULE(pckbd, isa, pckbd_driver, pckbd_devclass, 0, 0);
-
-static int pckbd_probe_unit(int unit, int port, int irq,
- int flags);
-static int pckbd_attach_unit(int unit, keyboard_t **kbd,
- int port, int irq, int flags);
-static timeout_t pckbd_timeout;
-
-
-static int
-pckbdprobe(device_t dev)
-{
- /* Check isapnp ids */
- if (isa_get_vendorid(dev))
- return (ENXIO);
-
- device_set_desc(dev, "PC-98 Keyboard");
-
- return pckbd_probe_unit(device_get_unit(dev), isa_get_port(dev),
- (1 << isa_get_irq(dev)), device_get_flags(dev));
-}
-
-static int
-pckbdattach(device_t dev)
-{
- keyboard_t *kbd;
- void *ih;
- struct resource *res;
- int zero = 0;
-
- pckbd_attach_unit(device_get_unit(dev), &kbd, isa_get_port(dev),
- (1 << isa_get_irq(dev)), device_get_flags(dev));
-
- res = bus_alloc_resource(dev, SYS_RES_IRQ, &zero, 0ul, ~0ul, 1,
- RF_SHAREABLE | RF_ACTIVE);
- BUS_SETUP_INTR(device_get_parent(dev), dev, res, INTR_TYPE_TTY,
- pckbd_isa_intr, kbd, &ih);
-
- return (0);
-}
-
-static void
-pckbd_isa_intr(void *arg)
-{
- keyboard_t *kbd = arg;
-
- (*kbdsw[kbd->kb_index]->intr)(kbd, NULL);
-}
-
-static int
-pckbd_probe_unit(int unit, int port, int irq, int flags)
-{
- keyboard_switch_t *sw;
- int args[2];
- int error;
-
- sw = kbd_get_switch(DRIVER_NAME);
- if (sw == NULL)
- return ENXIO;
-
- args[0] = port;
- args[1] = irq;
- error = (*sw->probe)(unit, args, flags);
- if (error)
- return error;
- return 0;
-}
-
-static int
-pckbd_attach_unit(int unit, keyboard_t **kbd, int port, int irq, int flags)
-{
- keyboard_switch_t *sw;
- int args[2];
- int error;
-
- sw = kbd_get_switch(DRIVER_NAME);
- if (sw == NULL)
- return ENXIO;
-
- /* reset, initialize and enable the device */
- args[0] = port;
- args[1] = irq;
- *kbd = NULL;
- error = (*sw->probe)(unit, args, flags);
- if (error)
- return error;
- error = (*sw->init)(unit, kbd, args, flags);
- if (error)
- return error;
- (*sw->enable)(*kbd);
-
-#ifdef KBD_INSTALL_CDEV
- /* attach a virtual keyboard cdev */
- error = kbd_attach(*kbd);
- if (error)
- return error;
-#endif /* KBD_INSTALL_CDEV */
-
- /*
- * This is a kludge to compensate for lost keyboard interrupts.
- * A similar code used to be in syscons. See below. XXX
- */
- pckbd_timeout(*kbd);
-
- if (bootverbose)
- (*sw->diag)(*kbd, bootverbose);
-
- return 0;
-}
-
-static void
-pckbd_timeout(void *arg)
-{
- keyboard_t *kbd;
- int s;
-
- /* The following comments are extracted from syscons.c (1.287) */
- /*
- * With release 2.1 of the Xaccel server, the keyboard is left
- * hanging pretty often. Apparently an interrupt from the
- * keyboard is lost, and I don't know why (yet).
- * This ugly hack calls scintr if input is ready for the keyboard
- * and conveniently hides the problem. XXX
- */
- /*
- * Try removing anything stuck in the keyboard controller; whether
- * it's a keyboard scan code or mouse data. `scintr()' doesn't
- * read the mouse data directly, but `kbdio' routines will, as a
- * side effect.
- */
- s = spltty();
- kbd = (keyboard_t *)arg;
- if ((*kbdsw[kbd->kb_index]->lock)(kbd, TRUE)) {
- /*
- * We have seen the lock flag is not set. Let's reset
- * the flag early, otherwise the LED update routine fails
- * which may want the lock during the interrupt routine.
- */
- (*kbdsw[kbd->kb_index]->lock)(kbd, FALSE);
- if ((*kbdsw[kbd->kb_index]->check_char)(kbd))
- (*kbdsw[kbd->kb_index]->intr)(kbd, NULL);
- }
- splx(s);
- timeout(pckbd_timeout, arg, hz/10);
-}
-
-/* LOW-LEVEL */
-
-#include <machine/limits.h>
-#include <machine/console.h>
-#include <machine/clock.h>
-
-#define PC98KBD_DEFAULT 0
-
-typedef caddr_t KBDC;
-
-typedef struct pckbd_state {
- KBDC kbdc; /* keyboard controller */
- int ks_mode; /* input mode (K_XLATE,K_RAW,K_CODE) */
- int ks_flags; /* flags */
-#define COMPOSE (1 << 0)
- int ks_state; /* shift/lock key state */
- int ks_accents; /* accent key index (> 0) */
- u_int ks_composed_char; /* composed char code (> 0) */
-} pckbd_state_t;
-
-/* keyboard driver declaration */
-static int pckbd_configure(int flags);
-static kbd_probe_t pckbd_probe;
-static kbd_init_t pckbd_init;
-static kbd_term_t pckbd_term;
-static kbd_intr_t pckbd_intr;
-static kbd_test_if_t pckbd_test_if;
-static kbd_enable_t pckbd_enable;
-static kbd_disable_t pckbd_disable;
-static kbd_read_t pckbd_read;
-static kbd_check_t pckbd_check;
-static kbd_read_char_t pckbd_read_char;
-static kbd_check_char_t pckbd_check_char;
-static kbd_ioctl_t pckbd_ioctl;
-static kbd_lock_t pckbd_lock;
-static kbd_clear_state_t pckbd_clear_state;
-static kbd_get_state_t pckbd_get_state;
-static kbd_set_state_t pckbd_set_state;
-static kbd_poll_mode_t pckbd_poll;
-
-keyboard_switch_t pckbdsw = {
- pckbd_probe,
- pckbd_init,
- pckbd_term,
- pckbd_intr,
- pckbd_test_if,
- pckbd_enable,
- pckbd_disable,
- pckbd_read,
- pckbd_check,
- pckbd_read_char,
- pckbd_check_char,
- pckbd_ioctl,
- pckbd_lock,
- pckbd_clear_state,
- pckbd_get_state,
- pckbd_set_state,
- genkbd_get_fkeystr,
- pckbd_poll,
- genkbd_diag,
-};
-
-KEYBOARD_DRIVER(pckbd, pckbdsw, pckbd_configure);
-
-struct kbdc_softc {
- int port; /* base port address */
- int lock; /* FIXME: XXX not quite a semaphore... */
-};
-
-/* local functions */
-static int probe_keyboard(KBDC kbdc, int flags);
-static int init_keyboard(KBDC kbdc, int *type, int flags);
-static KBDC kbdc_open(int port);
-static int kbdc_lock(KBDC kbdc, int lock);
-static int kbdc_data_ready(KBDC kbdc);
-static int read_kbd_data(KBDC kbdc);
-static int read_kbd_data_no_wait(KBDC kbdc);
-static int wait_for_kbd_data(struct kbdc_softc *kbdc);
-
-/* local variables */
-
-/* the initial key map, accent map and fkey strings */
-#include <dev/kbd/kbdtables.h>
-
-/* structures for the default keyboard */
-static keyboard_t default_kbd;
-static pckbd_state_t default_kbd_state;
-static keymap_t default_keymap;
-static accentmap_t default_accentmap;
-static fkeytab_t default_fkeytab[NUM_FKEYS];
-
-/*
- * The back door to the keyboard driver!
- * This function is called by the console driver, via the kbdio module,
- * to tickle keyboard drivers when the low-level console is being initialized.
- * Almost nothing in the kernel has been initialied yet. Try to probe
- * keyboards if possible.
- * NOTE: because of the way the low-level conole is initialized, this routine
- * may be called more than once!!
- */
-static int
-pckbd_configure(int flags)
-{
- keyboard_t *kbd;
- int arg[2];
- int i;
-
- /* XXX: a kludge to obtain the device configuration flags */
- if (resource_int_value(DRIVER_NAME, 0, "flags", &i) == 0) {
- flags |= i;
- /* if the driver is disabled, unregister the keyboard if any */
- if (resource_int_value(DRIVER_NAME, 0, "disabled", &i) == 0
- && i != 0) {
- i = kbd_find_keyboard(DRIVER_NAME, PC98KBD_DEFAULT);
- if (i >= 0) {
- kbd = kbd_get_keyboard(i);
- kbd_unregister(kbd);
- kbd->kb_flags &= ~KB_REGISTERED;
- return 0;
- }
- }
- }
-
- /* probe the default keyboard */
- arg[0] = -1;
- arg[1] = -1;
- kbd = NULL;
- if (pckbd_probe(PC98KBD_DEFAULT, arg, flags))
- return 0;
- if (pckbd_init(PC98KBD_DEFAULT, &kbd, arg, flags))
- return 0;
-
- /* return the number of found keyboards */
- return 1;
-}
-
-/* low-level functions */
-
-/* detect a keyboard */
-static int
-pckbd_probe(int unit, void *arg, int flags)
-{
- KBDC kbdc;
- int *data = (int *)arg;
-
- if (unit != PC98KBD_DEFAULT)
- return ENXIO;
- if (KBD_IS_PROBED(&default_kbd))
- return 0;
-
- kbdc = kbdc_open(data[0]);
- if (kbdc == NULL)
- return ENXIO;
- if (probe_keyboard(kbdc, flags)) {
- if (flags & KB_CONF_FAIL_IF_NO_KBD)
- return ENXIO;
- }
- return 0;
-}
-
-/* reset and initialize the device */
-static int
-pckbd_init(int unit, keyboard_t **kbdp, void *arg, int flags)
-{
- keyboard_t *kbd;
- pckbd_state_t *state;
- keymap_t *keymap;
- accentmap_t *accmap;
- fkeytab_t *fkeymap;
- int fkeymap_size;
- int *data = (int *)arg;
-
- if (unit != PC98KBD_DEFAULT) /* shouldn't happen */
- return ENXIO;
-
- *kbdp = kbd = &default_kbd;
- state = &default_kbd_state;
- if (!KBD_IS_PROBED(kbd)) {
- keymap = &default_keymap;
- accmap = &default_accentmap;
- fkeymap = default_fkeytab;
- fkeymap_size =
- sizeof(default_fkeytab)/sizeof(default_fkeytab[0]);
-
- state->kbdc = kbdc_open(data[0]);
- if (state->kbdc == NULL)
- return ENXIO;
- kbd_init_struct(kbd, DRIVER_NAME, KB_OTHER, unit, flags,
- data[0], IO_KBDSIZE);
- bcopy(&key_map, keymap, sizeof(key_map));
- bcopy(&accent_map, accmap, sizeof(accent_map));
- bcopy(fkey_tab, fkeymap,
- imin(fkeymap_size*sizeof(fkeymap[0]), sizeof(fkey_tab)));
- kbd_set_maps(kbd, keymap, accmap, fkeymap, fkeymap_size);
- kbd->kb_data = (void *)state;
-
- if (probe_keyboard(state->kbdc, flags)) {/* shouldn't happen */
- if (flags & KB_CONF_FAIL_IF_NO_KBD)
- return ENXIO;
- } else {
- KBD_FOUND_DEVICE(kbd);
- }
- pckbd_clear_state(kbd);
- state->ks_mode = K_XLATE;
- KBD_PROBE_DONE(kbd);
- }
- if (!KBD_IS_INITIALIZED(kbd) && !(flags & KB_CONF_PROBE_ONLY)) {
- if (KBD_HAS_DEVICE(kbd)
- && init_keyboard(state->kbdc, &kbd->kb_type, kbd->kb_config)
- && (kbd->kb_config & KB_CONF_FAIL_IF_NO_KBD))
- return ENXIO;
- pckbd_ioctl(kbd, KDSETLED, (caddr_t)&state->ks_state);
- KBD_INIT_DONE(kbd);
- }
- if (!KBD_IS_CONFIGURED(kbd)) {
- if (kbd_register(kbd) < 0)
- return ENXIO;
- KBD_CONFIG_DONE(kbd);
- }
-
- return 0;
-}
-
-/* finish using this keyboard */
-static int
-pckbd_term(keyboard_t *kbd)
-{
- kbd_unregister(kbd);
- return 0;
-}
-
-/* keyboard interrupt routine */
-static int
-pckbd_intr(keyboard_t *kbd, void *arg)
-{
- int c;
-
- if (KBD_IS_ACTIVE(kbd) && KBD_IS_BUSY(kbd)) {
- /* let the callback function to process the input */
- (*kbd->kb_callback.kc_func)(kbd, KBDIO_KEYINPUT,
- kbd->kb_callback.kc_arg);
- } else {
- /* read and discard the input; no one is waiting for input */
- do {
- c = pckbd_read_char(kbd, FALSE);
- } while (c != NOKEY);
- }
- return 0;
-}
-
-/* test the interface to the device */
-static int
-pckbd_test_if(keyboard_t *kbd)
-{
- return 0;
-}
-
-/*
- * Enable the access to the device; until this function is called,
- * the client cannot read from the keyboard.
- */
-static int
-pckbd_enable(keyboard_t *kbd)
-{
- int s;
-
- s = spltty();
- KBD_ACTIVATE(kbd);
- splx(s);
- return 0;
-}
-
-/* disallow the access to the device */
-static int
-pckbd_disable(keyboard_t *kbd)
-{
- int s;
-
- s = spltty();
- KBD_DEACTIVATE(kbd);
- splx(s);
- return 0;
-}
-
-/* read one byte from the keyboard if it's allowed */
-static int
-pckbd_read(keyboard_t *kbd, int wait)
-{
- int c;
-
- if (wait)
- c = read_kbd_data(((pckbd_state_t *)kbd->kb_data)->kbdc);
- else
- c = read_kbd_data_no_wait(((pckbd_state_t *)kbd->kb_data)->kbdc);
- if (c != -1)
- ++kbd->kb_count;
- return (KBD_IS_ACTIVE(kbd) ? c : -1);
-}
-
-/* check if data is waiting */
-static int
-pckbd_check(keyboard_t *kbd)
-{
- if (!KBD_IS_ACTIVE(kbd))
- return FALSE;
- return kbdc_data_ready(((pckbd_state_t *)kbd->kb_data)->kbdc);
-}
-
-/* read char from the keyboard */
-static u_int
-pckbd_read_char(keyboard_t *kbd, int wait)
-{
- pckbd_state_t *state;
- u_int action;
- int scancode;
- int keycode;
-
- state = (pckbd_state_t *)kbd->kb_data;
-next_code:
- /* do we have a composed char to return? */
- if (!(state->ks_flags & COMPOSE) && (state->ks_composed_char > 0)) {
- action = state->ks_composed_char;
- state->ks_composed_char = 0;
- if (action > UCHAR_MAX)
- return ERRKEY;
- return action;
- }
-
- /* see if there is something in the keyboard port */
- if (wait) {
- do {
- scancode = read_kbd_data(state->kbdc);
- } while (scancode == -1);
- } else {
- scancode = read_kbd_data_no_wait(state->kbdc);
- if (scancode == -1)
- return NOKEY;
- }
- ++kbd->kb_count;
-
-#if 0
- printf("pckbd_read_char(): scancode:0x%x\n", scancode);
-#endif
-
- /* return the byte as is for the K_RAW mode */
- if (state->ks_mode == K_RAW)
- return scancode;
-
- /* translate the scan code into a keycode */
- keycode = scancode & 0x7F;
- switch(scancode) {
- case 0xF3: /* GRPH (compose key) released */
- if (state->ks_flags & COMPOSE) {
- state->ks_flags &= ~COMPOSE;
- if (state->ks_composed_char > UCHAR_MAX)
- state->ks_composed_char = 0;
- }
- break;
- case 0x73: /* GRPH (compose key) pressed */
- if (!(state->ks_flags & COMPOSE)) {
- state->ks_flags |= COMPOSE;
- state->ks_composed_char = 0;
- }
- break;
- }
-
- /* return the key code in the K_CODE mode */
- if (state->ks_mode == K_CODE)
- return (keycode | (scancode & 0x80));
-
- /* compose a character code */
- if (state->ks_flags & COMPOSE) {
- switch (scancode) {
- /* key pressed, process it */
- case 0x42: case 0x43: case 0x44: /* keypad 7,8,9 */
- state->ks_composed_char *= 10;
- state->ks_composed_char += scancode - 0x3B;
- if (state->ks_composed_char > UCHAR_MAX)
- return ERRKEY;
- goto next_code;
- case 0x46: case 0x47: case 0x48: /* keypad 4,5,6 */
- state->ks_composed_char *= 10;
- state->ks_composed_char += scancode - 0x42;
- if (state->ks_composed_char > UCHAR_MAX)
- return ERRKEY;
- goto next_code;
- case 0x4A: case 0x4B: case 0x4C: /* keypad 1,2,3 */
- state->ks_composed_char *= 10;
- state->ks_composed_char += scancode - 0x49;
- if (state->ks_composed_char > UCHAR_MAX)
- return ERRKEY;
- goto next_code;
- case 0x4E: /* keypad 0 */
- state->ks_composed_char *= 10;
- if (state->ks_composed_char > UCHAR_MAX)
- return ERRKEY;
- goto next_code;
-
- /* key released, no interest here */
- case 0xC2: case 0xC3: case 0xC4: /* keypad 7,8,9 */
- case 0xC6: case 0xC7: case 0xC8: /* keypad 4,5,6 */
- case 0xCA: case 0xCB: case 0xCC: /* keypad 1,2,3 */
- case 0xCE: /* keypad 0 */
- goto next_code;
-
- case 0x73: /* GRPH key */
- break;
-
- default:
- if (state->ks_composed_char > 0) {
- state->ks_flags &= ~COMPOSE;
- state->ks_composed_char = 0;
- return ERRKEY;
- }
- break;
- }
- }
-
- /* keycode to key action */
- action = genkbd_keyaction(kbd, keycode, scancode & 0x80,
- &state->ks_state, &state->ks_accents);
- if (action == NOKEY)
- goto next_code;
- else
- return action;
-}
-
-/* check if char is waiting */
-static int
-pckbd_check_char(keyboard_t *kbd)
-{
- pckbd_state_t *state;
-
- if (!KBD_IS_ACTIVE(kbd))
- return FALSE;
- state = (pckbd_state_t *)kbd->kb_data;
- if (!(state->ks_flags & COMPOSE) && (state->ks_composed_char > 0))
- return TRUE;
- return kbdc_data_ready(state->kbdc);
-}
-
-/* some useful control functions */
-static int
-pckbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
-{
- pckbd_state_t *state = kbd->kb_data;
- int s;
- int i;
-
- s = spltty();
- switch (cmd) {
-
- case KDGKBMODE: /* get keyboard mode */
- *(int *)arg = state->ks_mode;
- break;
- case KDSKBMODE: /* set keyboard mode */
- switch (*(int *)arg) {
- case K_XLATE:
- if (state->ks_mode != K_XLATE) {
- /* make lock key state and LED state match */
- state->ks_state &= ~LOCK_MASK;
- state->ks_state |= KBD_LED_VAL(kbd);
- }
- /* FALL THROUGH */
- case K_RAW:
- case K_CODE:
- if (state->ks_mode != *(int *)arg) {
- pckbd_clear_state(kbd);
- state->ks_mode = *(int *)arg;
- }
- break;
- default:
- splx(s);
- return EINVAL;
- }
- break;
-
- case KDGETLED: /* get keyboard LED */
- *(int *)arg = KBD_LED_VAL(kbd);
- break;
- case KDSETLED: /* set keyboard LED */
- /* NOTE: lock key state in ks_state won't be changed */
- if (*(int *)arg & ~LOCK_MASK) {
- splx(s);
- return EINVAL;
- }
- i = *(int *)arg;
- /* replace CAPS LED with ALTGR LED for ALTGR keyboards */
- if (kbd->kb_keymap->n_keys > ALTGR_OFFSET) {
- if (i & ALKED)
- i |= CLKED;
- else
- i &= ~CLKED;
- }
- KBD_LED_VAL(kbd) = *(int *)arg;
- break;
-
- case KDGKBSTATE: /* get lock key state */
- *(int *)arg = state->ks_state & LOCK_MASK;
- break;
- case KDSKBSTATE: /* set lock key state */
- if (*(int *)arg & ~LOCK_MASK) {
- splx(s);
- return EINVAL;
- }
- state->ks_state &= ~LOCK_MASK;
- state->ks_state |= *(int *)arg;
- splx(s);
- /* set LEDs and quit */
- return pckbd_ioctl(kbd, KDSETLED, arg);
-
- case KDSETRAD: /* set keyboard repeat rate (old interface)*/
- break;
- case KDSETREPEAT: /* set keyboard repeat rate (new interface) */
- break;
-
- case PIO_KEYMAP: /* set keyboard translation table */
- case PIO_KEYMAPENT: /* set keyboard translation table entry */
- case PIO_DEADKEYMAP: /* set accent key translation table */
- state->ks_accents = 0;
- /* FALL THROUGH */
- default:
- splx(s);
- return genkbd_commonioctl(kbd, cmd, arg);
- }
-
- splx(s);
- return 0;
-}
-
-/* lock the access to the keyboard */
-static int
-pckbd_lock(keyboard_t *kbd, int lock)
-{
- return kbdc_lock(((pckbd_state_t *)kbd->kb_data)->kbdc, lock);
-}
-
-/* clear the internal state of the keyboard */
-static void
-pckbd_clear_state(keyboard_t *kbd)
-{
- pckbd_state_t *state;
-
- state = (pckbd_state_t *)kbd->kb_data;
- state->ks_flags = 0;
- state->ks_state &= LOCK_MASK; /* preserve locking key state */
- state->ks_accents = 0;
- state->ks_composed_char = 0;
-}
-
-/* save the internal state */
-static int
-pckbd_get_state(keyboard_t *kbd, void *buf, size_t len)
-{
- if (len == 0)
- return sizeof(pckbd_state_t);
- if (len < sizeof(pckbd_state_t))
- return -1;
- bcopy(kbd->kb_data, buf, sizeof(pckbd_state_t));
- return 0;
-}
-
-/* set the internal state */
-static int
-pckbd_set_state(keyboard_t *kbd, void *buf, size_t len)
-{
- if (len < sizeof(pckbd_state_t))
- return ENOMEM;
- if (((pckbd_state_t *)kbd->kb_data)->kbdc
- != ((pckbd_state_t *)buf)->kbdc)
- return ENOMEM;
- bcopy(buf, kbd->kb_data, sizeof(pckbd_state_t));
- return 0;
-}
-
-/* set polling mode */
-static int
-pckbd_poll(keyboard_t *kbd, int on)
-{
- return 0;
-}
-
-/* local functions */
-
-static int
-probe_keyboard(KBDC kbdc, int flags)
-{
- return 0;
-}
-
-static int
-init_keyboard(KBDC kbdc, int *type, int flags)
-{
- *type = KB_OTHER;
- return 0;
-}
-
-/* keyboard I/O routines */
-
-/* retry count */
-#ifndef KBD_MAXRETRY
-#define KBD_MAXRETRY 3
-#endif
-
-/* timing parameters */
-#ifndef KBD_RESETDELAY
-#define KBD_RESETDELAY 200 /* wait 200msec after kbd/mouse reset */
-#endif
-#ifndef KBD_MAXWAIT
-#define KBD_MAXWAIT 5 /* wait 5 times at most after reset */
-#endif
-
-/* I/O recovery time */
-#define KBDC_DELAYTIME 37
-#define KBDD_DELAYTIME 37
-
-/* I/O ports */
-#define KBD_STATUS_PORT 2 /* status port, read */
-#define KBD_DATA_PORT 0 /* data port, read */
-
-/* status bits (KBD_STATUS_PORT) */
-#define KBDS_BUFFER_FULL 0x0002
-
-/* macros */
-
-#define kbdcp(p) ((struct kbdc_softc *)(p))
-
-/* local variables */
-
-static struct kbdc_softc kbdc_softc[NPCKBD] = { { 0 }, };
-
-/* associate a port number with a KBDC */
-
-static KBDC
-kbdc_open(int port)
-{
- if (port <= 0)
- port = IO_KBD;
-
- if (NPCKBD) {
- /* PC-98 has only one keyboard I/F */
- kbdc_softc[0].port = port;
- kbdc_softc[0].lock = FALSE;
- return (KBDC)&kbdc_softc[0];
- }
- return NULL; /* You didn't include sc driver in your config file */
-}
-
-/* set/reset polling lock */
-static int
-kbdc_lock(KBDC p, int lock)
-{
- int prevlock;
-
- prevlock = kbdcp(p)->lock;
- kbdcp(p)->lock = lock;
-
- return (prevlock != lock);
-}
-
-/* check if any data is waiting to be processed */
-static int
-kbdc_data_ready(KBDC p)
-{
- return (inb(kbdcp(p)->port + KBD_STATUS_PORT) & KBDS_BUFFER_FULL);
-}
-
-/* wait for data from the keyboard */
-static int
-wait_for_kbd_data(struct kbdc_softc *kbdc)
-{
- /* CPU will stay inside the loop for 200msec at most */
- int retry = 10000;
- int port = kbdc->port;
-
- while (!(inb(port + KBD_STATUS_PORT) & KBDS_BUFFER_FULL)) {
- DELAY(KBDD_DELAYTIME);
- DELAY(KBDC_DELAYTIME);
- if (--retry < 0)
- return 0;
- }
- DELAY(KBDD_DELAYTIME);
- return 1;
-}
-
-/* read one byte from the keyboard */
-static int
-read_kbd_data(KBDC p)
-{
- if (!wait_for_kbd_data(kbdcp(p)))
- return -1; /* timeout */
- DELAY(KBDC_DELAYTIME);
- return inb(kbdcp(p)->port + KBD_DATA_PORT);
-}
-
-/* read one byte from the keyboard, but return immediately if
- * no data is waiting
- */
-static int
-read_kbd_data_no_wait(KBDC p)
-{
- if (inb(kbdcp(p)->port + KBD_STATUS_PORT) & KBDS_BUFFER_FULL) {
- DELAY(KBDD_DELAYTIME);
- return inb(kbdcp(p)->port + KBD_DATA_PORT);
- }
- return -1; /* no data */
-}
-
-#endif /* NPCKBD > 0 */
diff --git a/sys/pc98/cbus/pcrtc.c b/sys/pc98/cbus/pcrtc.c
deleted file mode 100644
index bd29e52a5a27..000000000000
--- a/sys/pc98/cbus/pcrtc.c
+++ /dev/null
@@ -1,1572 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz and Don Ahn.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)clock.c 7.2 (Berkeley) 5/12/91
- * $FreeBSD$
- */
-
-/*
- * Routines to handle clock hardware.
- */
-
-/*
- * inittodr, settodr and support routines written
- * by Christoph Robitschko <chmr@edvz.tu-graz.ac.at>
- *
- * reintroduced and updated by Chris Stenton <chris@gnome.co.uk> 8/10/94
- */
-
-/*
- * modified for PC98 by Kakefuda
- */
-
-#include "opt_clock.h"
-#include "apm.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/time.h>
-#include <sys/kernel.h>
-#ifndef SMP
-#include <sys/lock.h>
-#endif
-#include <sys/sysctl.h>
-#include <sys/cons.h>
-
-#include <machine/clock.h>
-#ifdef CLK_CALIBRATION_LOOP
-#endif
-#include <machine/cputypes.h>
-#include <machine/frame.h>
-#include <machine/ipl.h>
-#include <machine/limits.h>
-#include <machine/md_var.h>
-#include <machine/psl.h>
-#ifdef APIC_IO
-#include <machine/segments.h>
-#endif
-#if defined(SMP) || defined(APIC_IO)
-#include <machine/smp.h>
-#endif /* SMP || APIC_IO */
-#include <machine/specialreg.h>
-
-#include <i386/isa/icu.h>
-#ifdef PC98
-#include <pc98/pc98/pc98.h>
-#include <pc98/pc98/pc98_machdep.h>
-#include <i386/isa/isa_device.h>
-#else
-#include <i386/isa/isa.h>
-#include <isa/rtc.h>
-#endif
-#include <i386/isa/timerreg.h>
-
-#include <i386/isa/intr_machdep.h>
-
-#include "mca.h"
-#if NMCA > 0
-#include <i386/isa/mca_machdep.h>
-#endif
-
-#ifdef SMP
-#define disable_intr() CLOCK_DISABLE_INTR()
-#define enable_intr() CLOCK_ENABLE_INTR()
-
-#ifdef APIC_IO
-#include <i386/isa/intr_machdep.h>
-/* The interrupt triggered by the 8254 (timer) chip */
-int apic_8254_intr;
-static u_long read_intr_count __P((int vec));
-static void setup_8254_mixed_mode __P((void));
-#endif
-#endif /* SMP */
-
-/*
- * 32-bit time_t's can't reach leap years before 1904 or after 2036, so we
- * can use a simple formula for leap years.
- */
-#define LEAPYEAR(y) ((u_int)(y) % 4 == 0)
-#define DAYSPERYEAR (31+28+31+30+31+30+31+31+30+31+30+31)
-
-#define TIMER_DIV(x) ((timer_freq + (x) / 2) / (x))
-
-/*
- * Time in timer cycles that it takes for microtime() to disable interrupts
- * and latch the count. microtime() currently uses "cli; outb ..." so it
- * normally takes less than 2 timer cycles. Add a few for cache misses.
- * Add a few more to allow for latency in bogus calls to microtime() with
- * interrupts already disabled.
- */
-#define TIMER0_LATCH_COUNT 20
-
-/*
- * Maximum frequency that we are willing to allow for timer0. Must be
- * low enough to guarantee that the timer interrupt handler returns
- * before the next timer interrupt.
- */
-#define TIMER0_MAX_FREQ 20000
-
-int adjkerntz; /* local offset from GMT in seconds */
-int clkintr_pending;
-int disable_rtc_set; /* disable resettodr() if != 0 */
-volatile u_int idelayed;
-int statclock_disable;
-u_int stat_imask = SWI_CLOCK_MASK;
-#ifndef TIMER_FREQ
-#ifdef PC98
-#define TIMER_FREQ 2457600;
-#else /* IBM-PC */
-#define TIMER_FREQ 1193182;
-#endif /* PC98 */
-#endif
-u_int timer_freq = TIMER_FREQ;
-int timer0_max_count;
-u_int tsc_freq;
-int tsc_is_broken;
-int wall_cmos_clock; /* wall CMOS clock assumed if != 0 */
-
-static int beeping = 0;
-static u_int clk_imask = HWI_MASK | SWI_MASK;
-static const u_char daysinmonth[] = {31,28,31,30,31,30,31,31,30,31,30,31};
-static u_int hardclock_max_count;
-static u_int32_t i8254_lastcount;
-static u_int32_t i8254_offset;
-static int i8254_ticked;
-/*
- * XXX new_function and timer_func should not handle clockframes, but
- * timer_func currently needs to hold hardclock to handle the
- * timer0_state == 0 case. We should use inthand_add()/inthand_remove()
- * to switch between clkintr() and a slightly different timerintr().
- */
-static void (*new_function) __P((struct clockframe *frame));
-static u_int new_rate;
-#ifndef PC98
-static u_char rtc_statusa = RTCSA_DIVIDER | RTCSA_NOPROF;
-static u_char rtc_statusb = RTCSB_24HR | RTCSB_PINTR;
-#endif
-static u_int timer0_prescaler_count;
-
-/* Values for timerX_state: */
-#define RELEASED 0
-#define RELEASE_PENDING 1
-#define ACQUIRED 2
-#define ACQUIRE_PENDING 3
-
-static u_char timer0_state;
-#ifdef PC98
-static u_char timer1_state;
-#endif
-static u_char timer2_state;
-static void (*timer_func) __P((struct clockframe *frame)) = hardclock;
-#ifdef PC98
-static void rtc_serialcombit __P((int));
-static void rtc_serialcom __P((int));
-static int rtc_inb __P((void));
-static void rtc_outb __P((int));
-#endif
-static u_int tsc_present;
-
-static unsigned i8254_get_timecount __P((struct timecounter *tc));
-static unsigned tsc_get_timecount __P((struct timecounter *tc));
-static void set_timer_freq(u_int freq, int intr_freq);
-
-static struct timecounter tsc_timecounter = {
- tsc_get_timecount, /* get_timecount */
- 0, /* no poll_pps */
- ~0u, /* counter_mask */
- 0, /* frequency */
- "TSC" /* name */
-};
-
-SYSCTL_OPAQUE(_debug, OID_AUTO, tsc_timecounter, CTLFLAG_RD,
- &tsc_timecounter, sizeof(tsc_timecounter), "S,timecounter", "");
-
-static struct timecounter i8254_timecounter = {
- i8254_get_timecount, /* get_timecount */
- 0, /* no poll_pps */
- ~0u, /* counter_mask */
- 0, /* frequency */
- "i8254" /* name */
-};
-
-SYSCTL_OPAQUE(_debug, OID_AUTO, i8254_timecounter, CTLFLAG_RD,
- &i8254_timecounter, sizeof(i8254_timecounter), "S,timecounter", "");
-
-static void
-clkintr(struct clockframe frame)
-{
- if (timecounter->tc_get_timecount == i8254_get_timecount) {
- disable_intr();
- if (i8254_ticked)
- i8254_ticked = 0;
- else {
- i8254_offset += timer0_max_count;
- i8254_lastcount = 0;
- }
- clkintr_pending = 0;
- enable_intr();
- }
- timer_func(&frame);
- switch (timer0_state) {
-
- case RELEASED:
- setdelayed();
- break;
-
- case ACQUIRED:
- if ((timer0_prescaler_count += timer0_max_count)
- >= hardclock_max_count) {
- timer0_prescaler_count -= hardclock_max_count;
- hardclock(&frame);
- setdelayed();
- }
- break;
-
- case ACQUIRE_PENDING:
- disable_intr();
- i8254_offset = i8254_get_timecount(NULL);
- i8254_lastcount = 0;
- timer0_max_count = TIMER_DIV(new_rate);
- outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
- outb(TIMER_CNTR0, timer0_max_count & 0xff);
- outb(TIMER_CNTR0, timer0_max_count >> 8);
- enable_intr();
- timer_func = new_function;
- timer0_state = ACQUIRED;
- setdelayed();
- break;
-
- case RELEASE_PENDING:
- if ((timer0_prescaler_count += timer0_max_count)
- >= hardclock_max_count) {
- disable_intr();
- i8254_offset = i8254_get_timecount(NULL);
- i8254_lastcount = 0;
- timer0_max_count = hardclock_max_count;
- outb(TIMER_MODE,
- TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
- outb(TIMER_CNTR0, timer0_max_count & 0xff);
- outb(TIMER_CNTR0, timer0_max_count >> 8);
- enable_intr();
- timer0_prescaler_count = 0;
- timer_func = hardclock;
- timer0_state = RELEASED;
- hardclock(&frame);
- setdelayed();
- }
- break;
- }
-#if NMCA > 0
- /* Reset clock interrupt by asserting bit 7 of port 0x61 */
- if (MCA_system)
- outb(0x61, inb(0x61) | 0x80);
-#endif
-}
-
-/*
- * The acquire and release functions must be called at ipl >= splclock().
- */
-int
-acquire_timer0(int rate, void (*function) __P((struct clockframe *frame)))
-{
- static int old_rate;
-
- if (rate <= 0 || rate > TIMER0_MAX_FREQ)
- return (-1);
- switch (timer0_state) {
-
- case RELEASED:
- timer0_state = ACQUIRE_PENDING;
- break;
-
- case RELEASE_PENDING:
- if (rate != old_rate)
- return (-1);
- /*
- * The timer has been released recently, but is being
- * re-acquired before the release completed. In this
- * case, we simply reclaim it as if it had not been
- * released at all.
- */
- timer0_state = ACQUIRED;
- break;
-
- default:
- return (-1); /* busy */
- }
- new_function = function;
- old_rate = new_rate = rate;
- return (0);
-}
-
-#ifdef PC98
-int
-acquire_timer1(int mode)
-{
-
- if (timer1_state != RELEASED)
- return (-1);
- timer1_state = ACQUIRED;
-
- /*
- * This access to the timer registers is as atomic as possible
- * because it is a single instruction. We could do better if we
- * knew the rate. Use of splclock() limits glitches to 10-100us,
- * and this is probably good enough for timer2, so we aren't as
- * careful with it as with timer0.
- */
- outb(TIMER_MODE, TIMER_SEL1 | (mode & 0x3f));
-
- return (0);
-}
-#endif
-
-int
-acquire_timer2(int mode)
-{
-
- if (timer2_state != RELEASED)
- return (-1);
- timer2_state = ACQUIRED;
-
- /*
- * This access to the timer registers is as atomic as possible
- * because it is a single instruction. We could do better if we
- * knew the rate. Use of splclock() limits glitches to 10-100us,
- * and this is probably good enough for timer2, so we aren't as
- * careful with it as with timer0.
- */
- outb(TIMER_MODE, TIMER_SEL2 | (mode & 0x3f));
-
- return (0);
-}
-
-int
-release_timer0()
-{
- switch (timer0_state) {
-
- case ACQUIRED:
- timer0_state = RELEASE_PENDING;
- break;
-
- case ACQUIRE_PENDING:
- /* Nothing happened yet, release quickly. */
- timer0_state = RELEASED;
- break;
-
- default:
- return (-1);
- }
- return (0);
-}
-
-#ifdef PC98
-int
-release_timer1()
-{
-
- if (timer1_state != ACQUIRED)
- return (-1);
- timer1_state = RELEASED;
- outb(TIMER_MODE, TIMER_SEL1 | TIMER_SQWAVE | TIMER_16BIT);
- return (0);
-}
-#endif
-
-int
-release_timer2()
-{
-
- if (timer2_state != ACQUIRED)
- return (-1);
- timer2_state = RELEASED;
- outb(TIMER_MODE, TIMER_SEL2 | TIMER_SQWAVE | TIMER_16BIT);
- return (0);
-}
-
-#ifndef PC98
-/*
- * This routine receives statistical clock interrupts from the RTC.
- * As explained above, these occur at 128 interrupts per second.
- * When profiling, we receive interrupts at a rate of 1024 Hz.
- *
- * This does not actually add as much overhead as it sounds, because
- * when the statistical clock is active, the hardclock driver no longer
- * needs to keep (inaccurate) statistics on its own. This decouples
- * statistics gathering from scheduling interrupts.
- *
- * The RTC chip requires that we read status register C (RTC_INTR)
- * to acknowledge an interrupt, before it will generate the next one.
- * Under high interrupt load, rtcintr() can be indefinitely delayed and
- * the clock can tick immediately after the read from RTC_INTR. In this
- * case, the mc146818A interrupt signal will not drop for long enough
- * to register with the 8259 PIC. If an interrupt is missed, the stat
- * clock will halt, considerably degrading system performance. This is
- * why we use 'while' rather than a more straightforward 'if' below.
- * Stat clock ticks can still be lost, causing minor loss of accuracy
- * in the statistics, but the stat clock will no longer stop.
- */
-static void
-rtcintr(struct clockframe frame)
-{
- while (rtcin(RTC_INTR) & RTCIR_PERIOD)
- statclock(&frame);
-}
-
-#include "opt_ddb.h"
-#ifdef DDB
-#include <ddb/ddb.h>
-
-DB_SHOW_COMMAND(rtc, rtc)
-{
- printf("%02x/%02x/%02x %02x:%02x:%02x, A = %02x, B = %02x, C = %02x\n",
- rtcin(RTC_YEAR), rtcin(RTC_MONTH), rtcin(RTC_DAY),
- rtcin(RTC_HRS), rtcin(RTC_MIN), rtcin(RTC_SEC),
- rtcin(RTC_STATUSA), rtcin(RTC_STATUSB), rtcin(RTC_INTR));
-}
-#endif /* DDB */
-#endif /* for PC98 */
-
-static int
-getit(void)
-{
- u_long ef;
- int high, low;
-
- ef = read_eflags();
- disable_intr();
-
- /* Select timer0 and latch counter value. */
- outb(TIMER_MODE, TIMER_SEL0 | TIMER_LATCH);
-
- low = inb(TIMER_CNTR0);
- high = inb(TIMER_CNTR0);
-
- CLOCK_UNLOCK();
- write_eflags(ef);
- return ((high << 8) | low);
-}
-
-/*
- * Wait "n" microseconds.
- * Relies on timer 1 counting down from (timer_freq / hz)
- * Note: timer had better have been programmed before this is first used!
- */
-void
-DELAY(int n)
-{
- int delta, prev_tick, tick, ticks_left;
-
-#ifdef DELAYDEBUG
- int getit_calls = 1;
- int n1;
- static int state = 0;
-
- if (state == 0) {
- state = 1;
- for (n1 = 1; n1 <= 10000000; n1 *= 10)
- DELAY(n1);
- state = 2;
- }
- if (state == 1)
- printf("DELAY(%d)...", n);
-#endif
- /*
- * Guard against the timer being uninitialized if we are called
- * early for console i/o.
- */
- if (timer0_max_count == 0)
- set_timer_freq(timer_freq, hz);
-
- /*
- * Read the counter first, so that the rest of the setup overhead is
- * counted. Guess the initial overhead is 20 usec (on most systems it
- * takes about 1.5 usec for each of the i/o's in getit(). The loop
- * takes about 6 usec on a 486/33 and 13 usec on a 386/20. The
- * multiplications and divisions to scale the count take a while).
- */
- prev_tick = getit();
- n -= 0; /* XXX actually guess no initial overhead */
- /*
- * Calculate (n * (timer_freq / 1e6)) without using floating point
- * and without any avoidable overflows.
- */
- if (n <= 0)
- ticks_left = 0;
- else if (n < 256)
- /*
- * Use fixed point to avoid a slow division by 1000000.
- * 39099 = 1193182 * 2^15 / 10^6 rounded to nearest.
- * 2^15 is the first power of 2 that gives exact results
- * for n between 0 and 256.
- */
- ticks_left = ((u_int)n * 39099 + (1 << 15) - 1) >> 15;
- else
- /*
- * Don't bother using fixed point, although gcc-2.7.2
- * generates particularly poor code for the long long
- * division, since even the slow way will complete long
- * before the delay is up (unless we're interrupted).
- */
- ticks_left = ((u_int)n * (long long)timer_freq + 999999)
- / 1000000;
-
- while (ticks_left > 0) {
- tick = getit();
-#ifdef DELAYDEBUG
- ++getit_calls;
-#endif
- delta = prev_tick - tick;
- prev_tick = tick;
- if (delta < 0) {
- delta += timer0_max_count;
- /*
- * Guard against timer0_max_count being wrong.
- * This shouldn't happen in normal operation,
- * but it may happen if set_timer_freq() is
- * traced.
- */
- if (delta < 0)
- delta = 0;
- }
- ticks_left -= delta;
- }
-#ifdef DELAYDEBUG
- if (state == 1)
- printf(" %d calls to getit() at %d usec each\n",
- getit_calls, (n + 5) / getit_calls);
-#endif
-}
-
-static void
-sysbeepstop(void *chan)
-{
-#ifdef PC98 /* PC98 */
- outb(IO_PPI, inb(IO_PPI)|0x08); /* disable counter1 output to speaker */
- release_timer1();
-#else
- outb(IO_PPI, inb(IO_PPI)&0xFC); /* disable counter2 output to speaker */
- release_timer2();
-#endif
- beeping = 0;
-}
-
-int
-sysbeep(int pitch, int period)
-{
- int x = splclock();
-
-#ifdef PC98
- if (acquire_timer1(TIMER_SQWAVE|TIMER_16BIT))
- if (!beeping) {
- /* Something else owns it. */
- splx(x);
- return (-1); /* XXX Should be EBUSY, but nobody cares anyway. */
- }
- disable_intr();
- outb(0x3fdb, pitch);
- outb(0x3fdb, (pitch>>8));
- enable_intr();
- if (!beeping) {
- /* enable counter1 output to speaker */
- outb(IO_PPI, (inb(IO_PPI) & 0xf7));
- beeping = period;
- timeout(sysbeepstop, (void *)NULL, period);
- }
-#else
- if (acquire_timer2(TIMER_SQWAVE|TIMER_16BIT))
- if (!beeping) {
- /* Something else owns it. */
- splx(x);
- return (-1); /* XXX Should be EBUSY, but nobody cares anyway. */
- }
- disable_intr();
- outb(TIMER_CNTR2, pitch);
- outb(TIMER_CNTR2, (pitch>>8));
- enable_intr();
- if (!beeping) {
- /* enable counter2 output to speaker */
- outb(IO_PPI, inb(IO_PPI) | 3);
- beeping = period;
- timeout(sysbeepstop, (void *)NULL, period);
- }
-#endif
- splx(x);
- return (0);
-}
-
-#ifndef PC98
-/*
- * RTC support routines
- */
-
-int
-rtcin(reg)
- int reg;
-{
- int s;
- u_char val;
-
- s = splhigh();
- outb(IO_RTC, reg);
- inb(0x84);
- val = inb(IO_RTC + 1);
- inb(0x84);
- splx(s);
- return (val);
-}
-
-static __inline void
-writertc(u_char reg, u_char val)
-{
- int s;
-
- s = splhigh();
- inb(0x84);
- outb(IO_RTC, reg);
- inb(0x84);
- outb(IO_RTC + 1, val);
- inb(0x84); /* XXX work around wrong order in rtcin() */
- splx(s);
-}
-
-static __inline int
-readrtc(int port)
-{
- return(bcd2bin(rtcin(port)));
-}
-#endif
-
-#ifdef PC98
-unsigned int delaycount;
-#define FIRST_GUESS 0x2000
-static void findcpuspeed(void)
-{
- int i;
- int remainder;
-
- /* Put counter in count down mode */
- outb(TIMER_MODE, TIMER_SEL0 | TIMER_16BIT | TIMER_RATEGEN);
- outb(TIMER_CNTR0, 0xff);
- outb(TIMER_CNTR0, 0xff);
- for (i = FIRST_GUESS; i; i--)
- ;
- remainder = getit();
- delaycount = (FIRST_GUESS * TIMER_DIV(1000)) / (0xffff - remainder);
-}
-#endif
-
-#ifdef PC98
-static u_int
-calibrate_clocks(void)
-{
- int timeout;
- u_int count, prev_count, tot_count;
- u_short sec, start_sec;
-
- if (bootverbose)
- printf("Calibrating clock(s) ... ");
- /* Check ARTIC. */
- if (!(PC98_SYSTEM_PARAMETER(0x458) & 0x80) &&
- !(PC98_SYSTEM_PARAMETER(0x45b) & 0x04))
- goto fail;
- timeout = 100000000;
-
- /* Read the ARTIC. */
- sec = inw(0x5e);
-
- /* Wait for the ARTIC to changes. */
- start_sec = sec;
- for (;;) {
- sec = inw(0x5e);
- if (sec != start_sec)
- break;
- if (--timeout == 0)
- goto fail;
- }
- prev_count = getit();
- if (prev_count == 0 || prev_count > timer0_max_count)
- goto fail;
- tot_count = 0;
-
- if (tsc_present)
- wrmsr(0x10, 0LL); /* XXX 0x10 is the MSR for the TSC */
- start_sec = sec;
- for (;;) {
- sec = inw(0x5e);
- count = getit();
- if (count == 0 || count > timer0_max_count)
- goto fail;
- if (count > prev_count)
- tot_count += prev_count - (count - timer0_max_count);
- else
- tot_count += prev_count - count;
- prev_count = count;
- if ((sec == start_sec + 1200) ||
- (sec < start_sec &&
- (u_int)sec + 0x10000 == (u_int)start_sec + 1200))
- break;
- if (--timeout == 0)
- goto fail;
- }
- /*
- * Read the cpu cycle counter. The timing considerations are
- * similar to those for the i8254 clock.
- */
- if (tsc_present)
- tsc_freq = rdtsc();
-
- if (bootverbose) {
- if (tsc_present)
- printf("TSC clock: %u Hz, ", tsc_freq);
- printf("i8254 clock: %u Hz\n", tot_count);
- }
- return (tot_count);
-
-fail:
- if (bootverbose)
- printf("failed, using default i8254 clock of %u Hz\n",
- timer_freq);
- return (timer_freq);
-}
-#else
-static u_int
-calibrate_clocks(void)
-{
- u_int64_t old_tsc;
- u_int count, prev_count, tot_count;
- int sec, start_sec, timeout;
-
- if (bootverbose)
- printf("Calibrating clock(s) ... ");
- if (!(rtcin(RTC_STATUSD) & RTCSD_PWR))
- goto fail;
- timeout = 100000000;
-
- /* Read the mc146818A seconds counter. */
- for (;;) {
- if (!(rtcin(RTC_STATUSA) & RTCSA_TUP)) {
- sec = rtcin(RTC_SEC);
- break;
- }
- if (--timeout == 0)
- goto fail;
- }
-
- /* Wait for the mC146818A seconds counter to change. */
- start_sec = sec;
- for (;;) {
- if (!(rtcin(RTC_STATUSA) & RTCSA_TUP)) {
- sec = rtcin(RTC_SEC);
- if (sec != start_sec)
- break;
- }
- if (--timeout == 0)
- goto fail;
- }
-
- /* Start keeping track of the i8254 counter. */
- prev_count = getit();
- if (prev_count == 0 || prev_count > timer0_max_count)
- goto fail;
- tot_count = 0;
-
- if (tsc_present)
- old_tsc = rdtsc();
- else
- old_tsc = 0; /* shut up gcc */
-
- /*
- * Wait for the mc146818A seconds counter to change. Read the i8254
- * counter for each iteration since this is convenient and only
- * costs a few usec of inaccuracy. The timing of the final reads
- * of the counters almost matches the timing of the initial reads,
- * so the main cause of inaccuracy is the varying latency from
- * inside getit() or rtcin(RTC_STATUSA) to the beginning of the
- * rtcin(RTC_SEC) that returns a changed seconds count. The
- * maximum inaccuracy from this cause is < 10 usec on 486's.
- */
- start_sec = sec;
- for (;;) {
- if (!(rtcin(RTC_STATUSA) & RTCSA_TUP))
- sec = rtcin(RTC_SEC);
- count = getit();
- if (count == 0 || count > timer0_max_count)
- goto fail;
- if (count > prev_count)
- tot_count += prev_count - (count - timer0_max_count);
- else
- tot_count += prev_count - count;
- prev_count = count;
- if (sec != start_sec)
- break;
- if (--timeout == 0)
- goto fail;
- }
-
- /*
- * Read the cpu cycle counter. The timing considerations are
- * similar to those for the i8254 clock.
- */
- if (tsc_present)
- tsc_freq = rdtsc() - old_tsc;
-
- if (bootverbose) {
- if (tsc_present)
- printf("TSC clock: %u Hz, ", tsc_freq);
- printf("i8254 clock: %u Hz\n", tot_count);
- }
- return (tot_count);
-
-fail:
- if (bootverbose)
- printf("failed, using default i8254 clock of %u Hz\n",
- timer_freq);
- return (timer_freq);
-}
-#endif /* !PC98 */
-
-static void
-set_timer_freq(u_int freq, int intr_freq)
-{
- u_long ef;
- int new_timer0_max_count;
-
- ef = read_eflags();
- disable_intr();
- timer_freq = freq;
- new_timer0_max_count = hardclock_max_count = TIMER_DIV(intr_freq);
- if (new_timer0_max_count != timer0_max_count) {
- timer0_max_count = new_timer0_max_count;
- outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
- outb(TIMER_CNTR0, timer0_max_count & 0xff);
- outb(TIMER_CNTR0, timer0_max_count >> 8);
- }
- CLOCK_UNLOCK();
- write_eflags(ef);
-}
-
-/*
- * i8254_restore is called from apm_default_resume() to reload
- * the countdown register.
- * this should not be necessary but there are broken laptops that
- * do not restore the countdown register on resume.
- * when it happnes, it messes up the hardclock interval and system clock,
- * which leads to the infamous "calcru: negative time" problem.
- */
-void
-i8254_restore(void)
-{
- u_long ef;
-
- ef = read_eflags();
- disable_intr();
- outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
- outb(TIMER_CNTR0, timer0_max_count & 0xff);
- outb(TIMER_CNTR0, timer0_max_count >> 8);
- CLOCK_UNLOCK();
- write_eflags(ef);
-}
-
-/*
- * Initialize 8254 timer 0 early so that it can be used in DELAY().
- * XXX initialization of other timers is unintentionally left blank.
- */
-void
-startrtclock()
-{
- u_int delta, freq;
-
-#ifdef PC98
- findcpuspeed();
- if (pc98_machine_type & M_8M)
- timer_freq = 1996800L; /* 1.9968 MHz */
- else
- timer_freq = 2457600L; /* 2.4576 MHz */
-#endif /* PC98 */
-
- if (cpu_feature & CPUID_TSC)
- tsc_present = 1;
- else
- tsc_present = 0;
-
-#ifndef PC98
- writertc(RTC_STATUSA, rtc_statusa);
- writertc(RTC_STATUSB, RTCSB_24HR);
-#endif
-
- set_timer_freq(timer_freq, hz);
- freq = calibrate_clocks();
-#ifdef CLK_CALIBRATION_LOOP
- if (bootverbose) {
- printf(
- "Press a key on the console to abort clock calibration\n");
- while (cncheckc() == -1)
- calibrate_clocks();
- }
-#endif
-
- /*
- * Use the calibrated i8254 frequency if it seems reasonable.
- * Otherwise use the default, and don't use the calibrated i586
- * frequency.
- */
- delta = freq > timer_freq ? freq - timer_freq : timer_freq - freq;
- if (delta < timer_freq / 100) {
-#ifndef CLK_USE_I8254_CALIBRATION
- if (bootverbose)
- printf(
-"CLK_USE_I8254_CALIBRATION not specified - using default frequency\n");
- freq = timer_freq;
-#endif
- timer_freq = freq;
- } else {
- if (bootverbose)
- printf(
- "%d Hz differs from default of %d Hz by more than 1%%\n",
- freq, timer_freq);
- tsc_freq = 0;
- }
-
- set_timer_freq(timer_freq, hz);
- i8254_timecounter.tc_frequency = timer_freq;
- init_timecounter(&i8254_timecounter);
-
-#ifndef CLK_USE_TSC_CALIBRATION
- if (tsc_freq != 0) {
- if (bootverbose)
- printf(
-"CLK_USE_TSC_CALIBRATION not specified - using old calibration method\n");
- tsc_freq = 0;
- }
-#endif
- if (tsc_present && tsc_freq == 0) {
- /*
- * Calibration of the i586 clock relative to the mc146818A
- * clock failed. Do a less accurate calibration relative
- * to the i8254 clock.
- */
- u_int64_t old_tsc = rdtsc();
-
- DELAY(1000000);
- tsc_freq = rdtsc() - old_tsc;
-#ifdef CLK_USE_TSC_CALIBRATION
- if (bootverbose)
- printf("TSC clock: %u Hz (Method B)\n", tsc_freq);
-#endif
- }
-
-#if !defined(SMP)
- /*
- * We can not use the TSC in SMP mode, until we figure out a
- * cheap (impossible), reliable and precise (yeah right!) way
- * to synchronize the TSCs of all the CPUs.
- * Curse Intel for leaving the counter out of the I/O APIC.
- */
-
-#if NAPM > 0
- /*
- * We can not use the TSC if we support APM. Precise timekeeping
- * on an APM'ed machine is at best a fools pursuit, since
- * any and all of the time spent in various SMM code can't
- * be reliably accounted for. Reading the RTC is your only
- * source of reliable time info. The i8254 looses too of course
- * but we need to have some kind of time...
- * We don't know at this point whether APM is going to be used
- * or not, nor when it might be activated. Play it safe.
- */
- return;
-#endif /* NAPM > 0 */
-
- if (tsc_present && tsc_freq != 0 && !tsc_is_broken) {
- tsc_timecounter.tc_frequency = tsc_freq;
- init_timecounter(&tsc_timecounter);
- }
-
-#endif /* !defined(SMP) */
-}
-
-#ifdef PC98
-static void
-rtc_serialcombit(int i)
-{
- outb(IO_RTC, ((i&0x01)<<5)|0x07);
- DELAY(1);
- outb(IO_RTC, ((i&0x01)<<5)|0x17);
- DELAY(1);
- outb(IO_RTC, ((i&0x01)<<5)|0x07);
- DELAY(1);
-}
-
-static void
-rtc_serialcom(int i)
-{
- rtc_serialcombit(i&0x01);
- rtc_serialcombit((i&0x02)>>1);
- rtc_serialcombit((i&0x04)>>2);
- rtc_serialcombit((i&0x08)>>3);
- outb(IO_RTC, 0x07);
- DELAY(1);
- outb(IO_RTC, 0x0f);
- DELAY(1);
- outb(IO_RTC, 0x07);
- DELAY(1);
-}
-
-static void
-rtc_outb(int val)
-{
- int s;
- int sa = 0;
-
- for (s=0;s<8;s++) {
- sa = ((val >> s) & 0x01) ? 0x27 : 0x07;
- outb(IO_RTC, sa); /* set DI & CLK 0 */
- DELAY(1);
- outb(IO_RTC, sa | 0x10); /* CLK 1 */
- DELAY(1);
- }
- outb(IO_RTC, sa & 0xef); /* CLK 0 */
-}
-
-static int
-rtc_inb(void)
-{
- int s;
- int sa = 0;
-
- for (s=0;s<8;s++) {
- sa |= ((inb(0x33) & 0x01) << s);
- outb(IO_RTC, 0x17); /* CLK 1 */
- DELAY(1);
- outb(IO_RTC, 0x07); /* CLK 0 */
- DELAY(2);
- }
- return sa;
-}
-#endif /* PC-98 */
-
-/*
- * Initialize the time of day register, based on the time base which is, e.g.
- * from a filesystem.
- */
-void
-inittodr(time_t base)
-{
- unsigned long sec, days;
-#ifndef PC98
- int yd;
-#endif
- int year, month;
- int y, m, s;
- struct timespec ts;
-#ifdef PC98
- int second, min, hour;
-#endif
-
- if (base) {
- s = splclock();
- ts.tv_sec = base;
- ts.tv_nsec = 0;
- set_timecounter(&ts);
- splx(s);
- }
-
-#ifdef PC98
- rtc_serialcom(0x03); /* Time Read */
- rtc_serialcom(0x01); /* Register shift command. */
- DELAY(20);
-
- second = bcd2bin(rtc_inb() & 0xff); /* sec */
- min = bcd2bin(rtc_inb() & 0xff); /* min */
- hour = bcd2bin(rtc_inb() & 0xff); /* hour */
- days = bcd2bin(rtc_inb() & 0xff) - 1; /* date */
-
- month = (rtc_inb() >> 4) & 0x0f; /* month */
- for (m = 1; m < month; m++)
- days += daysinmonth[m-1];
- year = bcd2bin(rtc_inb() & 0xff) + 1900; /* year */
- /* 2000 year problem */
- if (year < 1995)
- year += 100;
- if (year < 1970)
- goto wrong_time;
- for (y = 1970; y < year; y++)
- days += DAYSPERYEAR + LEAPYEAR(y);
- if ((month > 2) && LEAPYEAR(year))
- days ++;
- sec = ((( days * 24 +
- hour) * 60 +
- min) * 60 +
- second);
- /* sec now contains the number of seconds, since Jan 1 1970,
- in the local time zone */
-#else /* IBM-PC */
- /* Look if we have a RTC present and the time is valid */
- if (!(rtcin(RTC_STATUSD) & RTCSD_PWR))
- goto wrong_time;
-
- /* wait for time update to complete */
- /* If RTCSA_TUP is zero, we have at least 244us before next update */
- s = splhigh();
- while (rtcin(RTC_STATUSA) & RTCSA_TUP) {
- splx(s);
- s = splhigh();
- }
-
- days = 0;
-#ifdef USE_RTC_CENTURY
- year = readrtc(RTC_YEAR) + readrtc(RTC_CENTURY) * 100;
-#else
- year = readrtc(RTC_YEAR) + 1900;
- if (year < 1970)
- year += 100;
-#endif
- if (year < 1970) {
- splx(s);
- goto wrong_time;
- }
- month = readrtc(RTC_MONTH);
- for (m = 1; m < month; m++)
- days += daysinmonth[m-1];
- if ((month > 2) && LEAPYEAR(year))
- days ++;
- days += readrtc(RTC_DAY) - 1;
- yd = days;
- for (y = 1970; y < year; y++)
- days += DAYSPERYEAR + LEAPYEAR(y);
- sec = ((( days * 24 +
- readrtc(RTC_HRS)) * 60 +
- readrtc(RTC_MIN)) * 60 +
- readrtc(RTC_SEC));
- /* sec now contains the number of seconds, since Jan 1 1970,
- in the local time zone */
-#endif
-
- sec += tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
-
- y = time_second - sec;
- if (y <= -2 || y >= 2) {
- /* badly off, adjust it */
- ts.tv_sec = sec;
- ts.tv_nsec = 0;
- set_timecounter(&ts);
- }
- splx(s);
- return;
-
-wrong_time:
- printf("Invalid time in real time clock.\n");
- printf("Check and reset the date immediately!\n");
-}
-
-/*
- * Write system time back to RTC
- */
-void
-resettodr()
-{
- unsigned long tm;
- int y, m, s;
-#ifdef PC98
- int wd;
-#endif
-
- if (disable_rtc_set)
- return;
-
- s = splclock();
- tm = time_second;
- splx(s);
-
-#ifdef PC98
- rtc_serialcom(0x01); /* Register shift command. */
-
- /* Calculate local time to put in RTC */
-
- tm -= tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
-
- rtc_outb(bin2bcd(tm%60)); tm /= 60; /* Write back Seconds */
- rtc_outb(bin2bcd(tm%60)); tm /= 60; /* Write back Minutes */
- rtc_outb(bin2bcd(tm%24)); tm /= 24; /* Write back Hours */
-
- /* We have now the days since 01-01-1970 in tm */
- wd = (tm+4)%7;
- for (y = 1970, m = DAYSPERYEAR + LEAPYEAR(y);
- tm >= m;
- y++, m = DAYSPERYEAR + LEAPYEAR(y))
- tm -= m;
-
- /* Now we have the years in y and the day-of-the-year in tm */
- for (m = 0; ; m++) {
- int ml;
-
- ml = daysinmonth[m];
- if (m == 1 && LEAPYEAR(y))
- ml++;
- if (tm < ml)
- break;
- tm -= ml;
- }
-
- m++;
- rtc_outb(bin2bcd(tm+1)); /* Write back Day */
- rtc_outb((m << 4) | wd); /* Write back Month & Weekday */
- rtc_outb(bin2bcd(y%100)); /* Write back Year */
-
- rtc_serialcom(0x02); /* Time set & Counter hold command. */
- rtc_serialcom(0x00); /* Register hold command. */
-#else
- /* Disable RTC updates and interrupts. */
- writertc(RTC_STATUSB, RTCSB_HALT | RTCSB_24HR);
-
- /* Calculate local time to put in RTC */
-
- tm -= tz.tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
-
- writertc(RTC_SEC, bin2bcd(tm%60)); tm /= 60; /* Write back Seconds */
- writertc(RTC_MIN, bin2bcd(tm%60)); tm /= 60; /* Write back Minutes */
- writertc(RTC_HRS, bin2bcd(tm%24)); tm /= 24; /* Write back Hours */
-
- /* We have now the days since 01-01-1970 in tm */
- writertc(RTC_WDAY, (tm+4)%7); /* Write back Weekday */
- for (y = 1970, m = DAYSPERYEAR + LEAPYEAR(y);
- tm >= m;
- y++, m = DAYSPERYEAR + LEAPYEAR(y))
- tm -= m;
-
- /* Now we have the years in y and the day-of-the-year in tm */
- writertc(RTC_YEAR, bin2bcd(y%100)); /* Write back Year */
-#ifdef USE_RTC_CENTURY
- writertc(RTC_CENTURY, bin2bcd(y/100)); /* ... and Century */
-#endif
- for (m = 0; ; m++) {
- int ml;
-
- ml = daysinmonth[m];
- if (m == 1 && LEAPYEAR(y))
- ml++;
- if (tm < ml)
- break;
- tm -= ml;
- }
-
- writertc(RTC_MONTH, bin2bcd(m + 1)); /* Write back Month */
- writertc(RTC_DAY, bin2bcd(tm + 1)); /* Write back Month Day */
-
- /* Reenable RTC updates and interrupts. */
- writertc(RTC_STATUSB, rtc_statusb);
-#endif
-}
-
-
-/*
- * Start both clocks running.
- */
-void
-cpu_initclocks()
-{
-#ifdef APIC_IO
- int apic_8254_trial;
- struct intrec *clkdesc;
-#endif /* APIC_IO */
-#ifndef PC98
- int diag;
-
- if (statclock_disable) {
- /*
- * The stat interrupt mask is different without the
- * statistics clock. Also, don't set the interrupt
- * flag which would normally cause the RTC to generate
- * interrupts.
- */
- stat_imask = HWI_MASK | SWI_MASK;
- rtc_statusb = RTCSB_24HR;
- } else {
- /* Setting stathz to nonzero early helps avoid races. */
- stathz = RTC_NOPROFRATE;
- profhz = RTC_PROFRATE;
- }
-#endif
-
- /* Finish initializing 8253 timer 0. */
-#ifdef APIC_IO
-
- apic_8254_intr = isa_apic_irq(0);
- apic_8254_trial = 0;
- if (apic_8254_intr >= 0 ) {
- if (apic_int_type(0, 0) == 3)
- apic_8254_trial = 1;
- } else {
- /* look for ExtInt on pin 0 */
- if (apic_int_type(0, 0) == 3) {
- apic_8254_intr = apic_irq(0, 0);
- setup_8254_mixed_mode();
- } else
- panic("APIC_IO: Cannot route 8254 interrupt to CPU");
- }
-
- clkdesc = inthand_add("clk", apic_8254_intr, (inthand2_t *)clkintr,
- NULL, &clk_imask, INTR_EXCL);
- INTREN(1 << apic_8254_intr);
-
-#else /* APIC_IO */
-
- inthand_add("clk", 0, (inthand2_t *)clkintr, NULL, &clk_imask,
- INTR_EXCL);
- INTREN(IRQ0);
-
-#endif /* APIC_IO */
-
-#ifndef PC98
- /* Initialize RTC. */
- writertc(RTC_STATUSA, rtc_statusa);
- writertc(RTC_STATUSB, RTCSB_24HR);
-
- /* Don't bother enabling the statistics clock. */
- if (statclock_disable)
- return;
- diag = rtcin(RTC_DIAG);
- if (diag != 0)
- printf("RTC BIOS diagnostic error %b\n", diag, RTCDG_BITS);
-
-#ifdef APIC_IO
- if (isa_apic_irq(8) != 8)
- panic("APIC RTC != 8");
-#endif /* APIC_IO */
-
- inthand_add("rtc", 8, (inthand2_t *)rtcintr, NULL, &stat_imask,
- INTR_EXCL);
-
-#ifdef APIC_IO
- INTREN(APIC_IRQ8);
-#else
- INTREN(IRQ8);
-#endif /* APIC_IO */
-
- writertc(RTC_STATUSB, rtc_statusb);
-#endif /* !PC98 */
-
-#ifdef APIC_IO
- if (apic_8254_trial) {
-
- printf("APIC_IO: Testing 8254 interrupt delivery\n");
- while (read_intr_count(8) < 6)
- ; /* nothing */
- if (read_intr_count(apic_8254_intr) < 3) {
- /*
- * The MP table is broken.
- * The 8254 was not connected to the specified pin
- * on the IO APIC.
- * Workaround: Limited variant of mixed mode.
- */
- INTRDIS(1 << apic_8254_intr);
- inthand_remove(clkdesc);
- printf("APIC_IO: Broken MP table detected: "
- "8254 is not connected to "
- "IOAPIC #%d intpin %d\n",
- int_to_apicintpin[apic_8254_intr].ioapic,
- int_to_apicintpin[apic_8254_intr].int_pin);
- /*
- * Revoke current ISA IRQ 0 assignment and
- * configure a fallback interrupt routing from
- * the 8254 Timer via the 8259 PIC to the
- * an ExtInt interrupt line on IOAPIC #0 intpin 0.
- * We reuse the low level interrupt handler number.
- */
- if (apic_irq(0, 0) < 0) {
- revoke_apic_irq(apic_8254_intr);
- assign_apic_irq(0, 0, apic_8254_intr);
- }
- apic_8254_intr = apic_irq(0, 0);
- setup_8254_mixed_mode();
- inthand_add("clk", apic_8254_intr,
- (inthand2_t *)clkintr,
- NULL, &clk_imask, INTR_EXCL);
- INTREN(1 << apic_8254_intr);
- }
-
- }
- if (apic_int_type(0, 0) != 3 ||
- int_to_apicintpin[apic_8254_intr].ioapic != 0 ||
- int_to_apicintpin[apic_8254_intr].int_pin != 0)
- printf("APIC_IO: routing 8254 via IOAPIC #%d intpin %d\n",
- int_to_apicintpin[apic_8254_intr].ioapic,
- int_to_apicintpin[apic_8254_intr].int_pin);
- else
- printf("APIC_IO: "
- "routing 8254 via 8259 and IOAPIC #0 intpin 0\n");
-#endif
-
-}
-
-#ifdef APIC_IO
-static u_long
-read_intr_count(int vec)
-{
- u_long *up;
- up = intr_countp[vec];
- if (up)
- return *up;
- return 0UL;
-}
-
-static void
-setup_8254_mixed_mode()
-{
- /*
- * Allow 8254 timer to INTerrupt 8259:
- * re-initialize master 8259:
- * reset; prog 4 bytes, single ICU, edge triggered
- */
- outb(IO_ICU1, 0x13);
-#ifdef PC98
- outb(IO_ICU1 + 2, NRSVIDT); /* start vector (unused) */
- outb(IO_ICU1 + 2, 0x00); /* ignore slave */
- outb(IO_ICU1 + 2, 0x03); /* auto EOI, 8086 */
- outb(IO_ICU1 + 2, 0xfe); /* unmask INT0 */
-#else
- outb(IO_ICU1 + 1, NRSVIDT); /* start vector (unused) */
- outb(IO_ICU1 + 1, 0x00); /* ignore slave */
- outb(IO_ICU1 + 1, 0x03); /* auto EOI, 8086 */
- outb(IO_ICU1 + 1, 0xfe); /* unmask INT0 */
-#endif
- /* program IO APIC for type 3 INT on INT0 */
- if (ext_int_setup(0, 0) < 0)
- panic("8254 redirect via APIC pin0 impossible!");
-}
-#endif
-
-void
-setstatclockrate(int newhz)
-{
-#ifndef PC98
- if (newhz == RTC_PROFRATE)
- rtc_statusa = RTCSA_DIVIDER | RTCSA_PROF;
- else
- rtc_statusa = RTCSA_DIVIDER | RTCSA_NOPROF;
- writertc(RTC_STATUSA, rtc_statusa);
-#endif
-}
-
-static int
-sysctl_machdep_i8254_freq SYSCTL_HANDLER_ARGS
-{
- int error;
- u_int freq;
-
- /*
- * Use `i8254' instead of `timer' in external names because `timer'
- * is is too generic. Should use it everywhere.
- */
- freq = timer_freq;
- error = sysctl_handle_int(oidp, &freq, sizeof(freq), req);
- if (error == 0 && req->newptr != NULL) {
- if (timer0_state != RELEASED)
- return (EBUSY); /* too much trouble to handle */
- set_timer_freq(freq, hz);
- i8254_timecounter.tc_frequency = freq;
- update_timecounter(&i8254_timecounter);
- }
- return (error);
-}
-
-SYSCTL_PROC(_machdep, OID_AUTO, i8254_freq, CTLTYPE_INT | CTLFLAG_RW,
- 0, sizeof(u_int), sysctl_machdep_i8254_freq, "I", "");
-
-static int
-sysctl_machdep_tsc_freq SYSCTL_HANDLER_ARGS
-{
- int error;
- u_int freq;
-
- if (tsc_timecounter.tc_frequency == 0)
- return (EOPNOTSUPP);
- freq = tsc_freq;
- error = sysctl_handle_int(oidp, &freq, sizeof(freq), req);
- if (error == 0 && req->newptr != NULL) {
- tsc_freq = freq;
- tsc_timecounter.tc_frequency = tsc_freq;
- update_timecounter(&tsc_timecounter);
- }
- return (error);
-}
-
-SYSCTL_PROC(_machdep, OID_AUTO, tsc_freq, CTLTYPE_INT | CTLFLAG_RW,
- 0, sizeof(u_int), sysctl_machdep_tsc_freq, "I", "");
-
-static unsigned
-i8254_get_timecount(struct timecounter *tc)
-{
- u_int count;
- u_long ef;
- u_int high, low;
-
- ef = read_eflags();
- disable_intr();
-
- /* Select timer0 and latch counter value. */
- outb(TIMER_MODE, TIMER_SEL0 | TIMER_LATCH);
-
- low = inb(TIMER_CNTR0);
- high = inb(TIMER_CNTR0);
- count = timer0_max_count - ((high << 8) | low);
- if (count < i8254_lastcount ||
- (!i8254_ticked && (clkintr_pending ||
- ((count < 20 || (!(ef & PSL_I) && count < timer0_max_count / 2u)) &&
-#ifdef APIC_IO
-#define lapic_irr1 ((volatile u_int *)&lapic)[0x210 / 4] /* XXX XXX */
- /* XXX this assumes that apic_8254_intr is < 24. */
- (lapic_irr1 & (1 << apic_8254_intr))))
-#else
- (inb(IO_ICU1) & 1)))
-#endif
- )) {
- i8254_ticked = 1;
- i8254_offset += timer0_max_count;
- }
- i8254_lastcount = count;
- count += i8254_offset;
- CLOCK_UNLOCK();
- write_eflags(ef);
- return (count);
-}
-
-static unsigned
-tsc_get_timecount(struct timecounter *tc)
-{
- return (rdtsc());
-}
diff --git a/sys/pc98/cbus/ppc.c b/sys/pc98/cbus/ppc.c
deleted file mode 100644
index c5b824e5ad38..000000000000
--- a/sys/pc98/cbus/ppc.c
+++ /dev/null
@@ -1,2065 +0,0 @@
-/*-
- * Copyright (c) 1997-2000 Nicolas Souchu
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- *
- */
-
-#include "opt_ppc.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/bus.h>
-#include <sys/malloc.h>
-
-#include <vm/vm.h>
-#include <vm/pmap.h>
-#include <machine/clock.h>
-#include <machine/bus.h>
-#include <machine/resource.h>
-#include <machine/vmparam.h>
-#include <sys/rman.h>
-
-#ifdef PC98
-#include <pc98/pc98/pc98.h>
-#else
-#include <isa/isareg.h>
-#endif
-#include <isa/isavar.h>
-
-#include <dev/ppbus/ppbconf.h>
-#include <dev/ppbus/ppb_msq.h>
-
-#ifdef PC98
-#include <pc98/pc98/ppcreg.h>
-#else
-#include <isa/ppcreg.h>
-#endif
-
-#include "ppbus_if.h"
-
-#define LOG_PPC(function, ppc, string) \
- if (bootverbose) printf("%s: %s\n", function, string)
-
-
-#define DEVTOSOFTC(dev) ((struct ppc_data *)device_get_softc(dev))
-
-devclass_t ppc_devclass;
-
-static int ppc_probe(device_t dev);
-static int ppc_attach(device_t dev);
-static int ppc_read_ivar(device_t bus, device_t dev, int index, uintptr_t *val);
-
-static void ppc_reset_epp(device_t);
-static void ppc_ecp_sync(device_t);
-static void ppcintr(void *arg);
-
-static int ppc_exec_microseq(device_t, struct ppb_microseq **);
-static int ppc_setmode(device_t, int);
-
-static int ppc_read(device_t, char *, int, int);
-static int ppc_write(device_t, char *, int, int);
-
-static u_char ppc_io(device_t, int, u_char *, int, u_char);
-
-static int ppc_setup_intr(device_t, device_t, struct resource *, int,
- void (*)(void *), void *, void **);
-static int ppc_teardown_intr(device_t, device_t, struct resource *, void *);
-
-static device_method_t ppc_methods[] = {
- /* device interface */
- DEVMETHOD(device_probe, ppc_probe),
- DEVMETHOD(device_attach, ppc_attach),
-
- /* bus interface */
- DEVMETHOD(bus_read_ivar, ppc_read_ivar),
- DEVMETHOD(bus_setup_intr, ppc_setup_intr),
- DEVMETHOD(bus_teardown_intr, ppc_teardown_intr),
- DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
-
- /* ppbus interface */
- DEVMETHOD(ppbus_io, ppc_io),
- DEVMETHOD(ppbus_exec_microseq, ppc_exec_microseq),
- DEVMETHOD(ppbus_reset_epp, ppc_reset_epp),
- DEVMETHOD(ppbus_setmode, ppc_setmode),
- DEVMETHOD(ppbus_ecp_sync, ppc_ecp_sync),
- DEVMETHOD(ppbus_read, ppc_read),
- DEVMETHOD(ppbus_write, ppc_write),
-
- { 0, 0 }
- };
-
-static driver_t ppc_driver = {
- "ppc",
- ppc_methods,
- sizeof(struct ppc_data),
-};
-
-static char *ppc_models[] = {
- "SMC-like", "SMC FDC37C665GT", "SMC FDC37C666GT", "PC87332", "PC87306",
- "82091AA", "Generic", "W83877F", "W83877AF", "Winbond", "PC87334", 0
-};
-
-/* list of available modes */
-static char *ppc_avms[] = {
- "COMPATIBLE", "NIBBLE-only", "PS2-only", "PS2/NIBBLE", "EPP-only",
- "EPP/NIBBLE", "EPP/PS2", "EPP/PS2/NIBBLE", "ECP-only",
- "ECP/NIBBLE", "ECP/PS2", "ECP/PS2/NIBBLE", "ECP/EPP",
- "ECP/EPP/NIBBLE", "ECP/EPP/PS2", "ECP/EPP/PS2/NIBBLE", 0
-};
-
-/* list of current executing modes
- * Note that few modes do not actually exist.
- */
-static char *ppc_modes[] = {
- "COMPATIBLE", "NIBBLE", "PS/2", "PS/2", "EPP",
- "EPP", "EPP", "EPP", "ECP",
- "ECP", "ECP+PS2", "ECP+PS2", "ECP+EPP",
- "ECP+EPP", "ECP+EPP", "ECP+EPP", 0
-};
-
-static char *ppc_epp_protocol[] = { " (EPP 1.9)", " (EPP 1.7)", 0 };
-
-#ifdef __i386__
-/*
- * BIOS printer list - used by BIOS probe.
- */
-#define BIOS_PPC_PORTS 0x408
-#define BIOS_PORTS (short *)(KERNBASE+BIOS_PPC_PORTS)
-#define BIOS_MAX_PPC 4
-#endif
-
-/*
- * ppc_ecp_sync() XXX
- */
-static void
-ppc_ecp_sync(device_t dev) {
-
- int i, r;
- struct ppc_data *ppc = DEVTOSOFTC(dev);
-
- if (!(ppc->ppc_avm & PPB_ECP))
- return;
-
- r = r_ecr(ppc);
- if ((r & 0xe0) != PPC_ECR_EPP)
- return;
-
- for (i = 0; i < 100; i++) {
- r = r_ecr(ppc);
- if (r & 0x1)
- return;
- DELAY(100);
- }
-
- printf("ppc%d: ECP sync failed as data still " \
- "present in FIFO.\n", ppc->ppc_unit);
-
- return;
-}
-
-/*
- * ppc_detect_fifo()
- *
- * Detect parallel port FIFO
- */
-static int
-ppc_detect_fifo(struct ppc_data *ppc)
-{
- char ecr_sav;
- char ctr_sav, ctr, cc;
- short i;
-
- /* save registers */
- ecr_sav = r_ecr(ppc);
- ctr_sav = r_ctr(ppc);
-
- /* enter ECP configuration mode, no interrupt, no DMA */
- w_ecr(ppc, 0xf4);
-
- /* read PWord size - transfers in FIFO mode must be PWord aligned */
- ppc->ppc_pword = (r_cnfgA(ppc) & PPC_PWORD_MASK);
-
- /* XXX 16 and 32 bits implementations not supported */
- if (ppc->ppc_pword != PPC_PWORD_8) {
- LOG_PPC(__FUNCTION__, ppc, "PWord not supported");
- goto error;
- }
-
- w_ecr(ppc, 0x34); /* byte mode, no interrupt, no DMA */
- ctr = r_ctr(ppc);
- w_ctr(ppc, ctr | PCD); /* set direction to 1 */
-
- /* enter ECP test mode, no interrupt, no DMA */
- w_ecr(ppc, 0xd4);
-
- /* flush the FIFO */
- for (i=0; i<1024; i++) {
- if (r_ecr(ppc) & PPC_FIFO_EMPTY)
- break;
- cc = r_fifo(ppc);
- }
-
- if (i >= 1024) {
- LOG_PPC(__FUNCTION__, ppc, "can't flush FIFO");
- goto error;
- }
-
- /* enable interrupts, no DMA */
- w_ecr(ppc, 0xd0);
-
- /* determine readIntrThreshold
- * fill the FIFO until serviceIntr is set
- */
- for (i=0; i<1024; i++) {
- w_fifo(ppc, (char)i);
- if (!ppc->ppc_rthr && (r_ecr(ppc) & PPC_SERVICE_INTR)) {
- /* readThreshold reached */
- ppc->ppc_rthr = i+1;
- }
- if (r_ecr(ppc) & PPC_FIFO_FULL) {
- ppc->ppc_fifo = i+1;
- break;
- }
- }
-
- if (i >= 1024) {
- LOG_PPC(__FUNCTION__, ppc, "can't fill FIFO");
- goto error;
- }
-
- w_ecr(ppc, 0xd4); /* test mode, no interrupt, no DMA */
- w_ctr(ppc, ctr & ~PCD); /* set direction to 0 */
- w_ecr(ppc, 0xd0); /* enable interrupts */
-
- /* determine writeIntrThreshold
- * empty the FIFO until serviceIntr is set
- */
- for (i=ppc->ppc_fifo; i>0; i--) {
- if (r_fifo(ppc) != (char)(ppc->ppc_fifo-i)) {
- LOG_PPC(__FUNCTION__, ppc, "invalid data in FIFO");
- goto error;
- }
- if (r_ecr(ppc) & PPC_SERVICE_INTR) {
- /* writeIntrThreshold reached */
- ppc->ppc_wthr = ppc->ppc_fifo - i+1;
- }
- /* if FIFO empty before the last byte, error */
- if (i>1 && (r_ecr(ppc) & PPC_FIFO_EMPTY)) {
- LOG_PPC(__FUNCTION__, ppc, "data lost in FIFO");
- goto error;
- }
- }
-
- /* FIFO must be empty after the last byte */
- if (!(r_ecr(ppc) & PPC_FIFO_EMPTY)) {
- LOG_PPC(__FUNCTION__, ppc, "can't empty the FIFO");
- goto error;
- }
-
- w_ctr(ppc, ctr_sav);
- w_ecr(ppc, ecr_sav);
-
- return (0);
-
-error:
- w_ctr(ppc, ctr_sav);
- w_ecr(ppc, ecr_sav);
-
- return (EINVAL);
-}
-
-static int
-ppc_detect_port(struct ppc_data *ppc)
-{
-
- w_ctr(ppc, 0x0c); /* To avoid missing PS2 ports */
- w_dtr(ppc, 0xaa);
- if (r_dtr(ppc) != 0xaa)
- return (0);
-
- return (1);
-}
-
-/*
- * EPP timeout, according to the PC87332 manual
- * Semantics of clearing EPP timeout bit.
- * PC87332 - reading SPP_STR does it...
- * SMC - write 1 to EPP timeout bit XXX
- * Others - (?) write 0 to EPP timeout bit
- */
-static void
-ppc_reset_epp_timeout(struct ppc_data *ppc)
-{
- register char r;
-
- r = r_str(ppc);
- w_str(ppc, r | 0x1);
- w_str(ppc, r & 0xfe);
-
- return;
-}
-
-static int
-ppc_check_epp_timeout(struct ppc_data *ppc)
-{
- ppc_reset_epp_timeout(ppc);
-
- return (!(r_str(ppc) & TIMEOUT));
-}
-
-/*
- * Configure current operating mode
- */
-static int
-ppc_generic_setmode(struct ppc_data *ppc, int mode)
-{
- u_char ecr = 0;
-
- /* check if mode is available */
- if (mode && !(ppc->ppc_avm & mode))
- return (EINVAL);
-
- /* if ECP mode, configure ecr register */
- if (ppc->ppc_avm & PPB_ECP) {
- /* return to byte mode (keeping direction bit),
- * no interrupt, no DMA to be able to change to
- * ECP
- */
- w_ecr(ppc, PPC_ECR_RESET);
- ecr = PPC_DISABLE_INTR;
-
- if (mode & PPB_EPP)
- return (EINVAL);
- else if (mode & PPB_ECP)
- /* select ECP mode */
- ecr |= PPC_ECR_ECP;
- else if (mode & PPB_PS2)
- /* select PS2 mode with ECP */
- ecr |= PPC_ECR_PS2;
- else
- /* select COMPATIBLE/NIBBLE mode */
- ecr |= PPC_ECR_STD;
-
- w_ecr(ppc, ecr);
- }
-
- ppc->ppc_mode = mode;
-
- return (0);
-}
-
-/*
- * The ppc driver is free to choose options like FIFO or DMA
- * if ECP mode is available.
- *
- * The 'RAW' option allows the upper drivers to force the ppc mode
- * even with FIFO, DMA available.
- */
-static int
-ppc_smclike_setmode(struct ppc_data *ppc, int mode)
-{
- u_char ecr = 0;
-
- /* check if mode is available */
- if (mode && !(ppc->ppc_avm & mode))
- return (EINVAL);
-
- /* if ECP mode, configure ecr register */
- if (ppc->ppc_avm & PPB_ECP) {
- /* return to byte mode (keeping direction bit),
- * no interrupt, no DMA to be able to change to
- * ECP or EPP mode
- */
- w_ecr(ppc, PPC_ECR_RESET);
- ecr = PPC_DISABLE_INTR;
-
- if (mode & PPB_EPP)
- /* select EPP mode */
- ecr |= PPC_ECR_EPP;
- else if (mode & PPB_ECP)
- /* select ECP mode */
- ecr |= PPC_ECR_ECP;
- else if (mode & PPB_PS2)
- /* select PS2 mode with ECP */
- ecr |= PPC_ECR_PS2;
- else
- /* select COMPATIBLE/NIBBLE mode */
- ecr |= PPC_ECR_STD;
-
- w_ecr(ppc, ecr);
- }
-
- ppc->ppc_mode = mode;
-
- return (0);
-}
-
-#ifdef PPC_PROBE_CHIPSET
-/*
- * ppc_pc873xx_detect
- *
- * Probe for a Natsemi PC873xx-family part.
- *
- * References in this function are to the National Semiconductor
- * PC87332 datasheet TL/C/11930, May 1995 revision.
- */
-static int pc873xx_basetab[] = {0x0398, 0x026e, 0x015c, 0x002e, 0};
-static int pc873xx_porttab[] = {0x0378, 0x03bc, 0x0278, 0};
-static int pc873xx_irqtab[] = {5, 7, 5, 0};
-
-static int pc873xx_regstab[] = {
- PC873_FER, PC873_FAR, PC873_PTR,
- PC873_FCR, PC873_PCR, PC873_PMC,
- PC873_TUP, PC873_SID, PC873_PNP0,
- PC873_PNP1, PC873_LPTBA, -1
-};
-
-static char *pc873xx_rnametab[] = {
- "FER", "FAR", "PTR", "FCR", "PCR",
- "PMC", "TUP", "SID", "PNP0", "PNP1",
- "LPTBA", NULL
-};
-
-static int
-ppc_pc873xx_detect(struct ppc_data *ppc, int chipset_mode) /* XXX mode never forced */
-{
- static int index = 0;
- int idport, irq;
- int ptr, pcr, val, i;
-
- while ((idport = pc873xx_basetab[index++])) {
-
- /* XXX should check first to see if this location is already claimed */
-
- /*
- * Pull the 873xx through the power-on ID cycle (2.2,1.).
- * We can't use this to locate the chip as it may already have
- * been used by the BIOS.
- */
- (void)inb(idport); (void)inb(idport);
- (void)inb(idport); (void)inb(idport);
-
- /*
- * Read the SID byte. Possible values are :
- *
- * 01010xxx PC87334
- * 0001xxxx PC87332
- * 01110xxx PC87306
- */
- outb(idport, PC873_SID);
- val = inb(idport + 1);
- if ((val & 0xf0) == 0x10) {
- ppc->ppc_model = NS_PC87332;
- } else if ((val & 0xf8) == 0x70) {
- ppc->ppc_model = NS_PC87306;
- } else if ((val & 0xf8) == 0x50) {
- ppc->ppc_model = NS_PC87334;
- } else {
- if (bootverbose && (val != 0xff))
- printf("PC873xx probe at 0x%x got unknown ID 0x%x\n", idport, val);
- continue ; /* not recognised */
- }
-
- /* print registers */
- if (bootverbose) {
- printf("PC873xx");
- for (i=0; pc873xx_regstab[i] != -1; i++) {
- outb(idport, pc873xx_regstab[i]);
- printf(" %s=0x%x", pc873xx_rnametab[i],
- inb(idport + 1) & 0xff);
- }
- printf("\n");
- }
-
- /*
- * We think we have one. Is it enabled and where we want it to be?
- */
- outb(idport, PC873_FER);
- val = inb(idport + 1);
- if (!(val & PC873_PPENABLE)) {
- if (bootverbose)
- printf("PC873xx parallel port disabled\n");
- continue;
- }
- outb(idport, PC873_FAR);
- val = inb(idport + 1) & 0x3;
- /* XXX we should create a driver instance for every port found */
- if (pc873xx_porttab[val] != ppc->ppc_base) {
- if (bootverbose)
- printf("PC873xx at 0x%x not for driver at port 0x%x\n",
- pc873xx_porttab[val], ppc->ppc_base);
- continue;
- }
-
- outb(idport, PC873_PTR);
- ptr = inb(idport + 1);
-
- /* get irq settings */
- if (ppc->ppc_base == 0x378)
- irq = (ptr & PC873_LPTBIRQ7) ? 7 : 5;
- else
- irq = pc873xx_irqtab[val];
-
- if (bootverbose)
- printf("PC873xx irq %d at 0x%x\n", irq, ppc->ppc_base);
-
- /*
- * Check if irq settings are correct
- */
- if (irq != ppc->ppc_irq) {
- /*
- * If the chipset is not locked and base address is 0x378,
- * we have another chance
- */
- if (ppc->ppc_base == 0x378 && !(ptr & PC873_CFGLOCK)) {
- if (ppc->ppc_irq == 7) {
- outb(idport + 1, (ptr | PC873_LPTBIRQ7));
- outb(idport + 1, (ptr | PC873_LPTBIRQ7));
- } else {
- outb(idport + 1, (ptr & ~PC873_LPTBIRQ7));
- outb(idport + 1, (ptr & ~PC873_LPTBIRQ7));
- }
- if (bootverbose)
- printf("PC873xx irq set to %d\n", ppc->ppc_irq);
- } else {
- if (bootverbose)
- printf("PC873xx sorry, can't change irq setting\n");
- }
- } else {
- if (bootverbose)
- printf("PC873xx irq settings are correct\n");
- }
-
- outb(idport, PC873_PCR);
- pcr = inb(idport + 1);
-
- if ((ptr & PC873_CFGLOCK) || !chipset_mode) {
- if (bootverbose)
- printf("PC873xx %s", (ptr & PC873_CFGLOCK)?"locked":"unlocked");
-
- ppc->ppc_avm |= PPB_NIBBLE;
- if (bootverbose)
- printf(", NIBBLE");
-
- if (pcr & PC873_EPPEN) {
- ppc->ppc_avm |= PPB_EPP;
-
- if (bootverbose)
- printf(", EPP");
-
- if (pcr & PC873_EPP19)
- ppc->ppc_epp = EPP_1_9;
- else
- ppc->ppc_epp = EPP_1_7;
-
- if ((ppc->ppc_model == NS_PC87332) && bootverbose) {
- outb(idport, PC873_PTR);
- ptr = inb(idport + 1);
- if (ptr & PC873_EPPRDIR)
- printf(", Regular mode");
- else
- printf(", Automatic mode");
- }
- } else if (pcr & PC873_ECPEN) {
- ppc->ppc_avm |= PPB_ECP;
- if (bootverbose)
- printf(", ECP");
-
- if (pcr & PC873_ECPCLK) { /* XXX */
- ppc->ppc_avm |= PPB_PS2;
- if (bootverbose)
- printf(", PS/2");
- }
- } else {
- outb(idport, PC873_PTR);
- ptr = inb(idport + 1);
- if (ptr & PC873_EXTENDED) {
- ppc->ppc_avm |= PPB_SPP;
- if (bootverbose)
- printf(", SPP");
- }
- }
- } else {
- if (bootverbose)
- printf("PC873xx unlocked");
-
- if (chipset_mode & PPB_ECP) {
- if ((chipset_mode & PPB_EPP) && bootverbose)
- printf(", ECP+EPP not supported");
-
- pcr &= ~PC873_EPPEN;
- pcr |= (PC873_ECPEN | PC873_ECPCLK); /* XXX */
- outb(idport + 1, pcr);
- outb(idport + 1, pcr);
-
- if (bootverbose)
- printf(", ECP");
-
- } else if (chipset_mode & PPB_EPP) {
- pcr &= ~(PC873_ECPEN | PC873_ECPCLK);
- pcr |= (PC873_EPPEN | PC873_EPP19);
- outb(idport + 1, pcr);
- outb(idport + 1, pcr);
-
- ppc->ppc_epp = EPP_1_9; /* XXX */
-
- if (bootverbose)
- printf(", EPP1.9");
-
- /* enable automatic direction turnover */
- if (ppc->ppc_model == NS_PC87332) {
- outb(idport, PC873_PTR);
- ptr = inb(idport + 1);
- ptr &= ~PC873_EPPRDIR;
- outb(idport + 1, ptr);
- outb(idport + 1, ptr);
-
- if (bootverbose)
- printf(", Automatic mode");
- }
- } else {
- pcr &= ~(PC873_ECPEN | PC873_ECPCLK | PC873_EPPEN);
- outb(idport + 1, pcr);
- outb(idport + 1, pcr);
-
- /* configure extended bit in PTR */
- outb(idport, PC873_PTR);
- ptr = inb(idport + 1);
-
- if (chipset_mode & PPB_PS2) {
- ptr |= PC873_EXTENDED;
-
- if (bootverbose)
- printf(", PS/2");
-
- } else {
- /* default to NIBBLE mode */
- ptr &= ~PC873_EXTENDED;
-
- if (bootverbose)
- printf(", NIBBLE");
- }
- outb(idport + 1, ptr);
- outb(idport + 1, ptr);
- }
-
- ppc->ppc_avm = chipset_mode;
- }
-
- if (bootverbose)
- printf("\n");
-
- ppc->ppc_type = PPC_TYPE_GENERIC;
- ppc_generic_setmode(ppc, chipset_mode);
-
- return(chipset_mode);
- }
- return(-1);
-}
-
-/*
- * ppc_smc37c66xgt_detect
- *
- * SMC FDC37C66xGT configuration.
- */
-static int
-ppc_smc37c66xgt_detect(struct ppc_data *ppc, int chipset_mode)
-{
- int s, i;
- u_char r;
- int type = -1;
- int csr = SMC66x_CSR; /* initial value is 0x3F0 */
-
- int port_address[] = { -1 /* disabled */ , 0x3bc, 0x378, 0x278 };
-
-
-#define cio csr+1 /* config IO port is either 0x3F1 or 0x371 */
-
- /*
- * Detection: enter configuration mode and read CRD register.
- */
-
- s = splhigh();
- outb(csr, SMC665_iCODE);
- outb(csr, SMC665_iCODE);
- splx(s);
-
- outb(csr, 0xd);
- if (inb(cio) == 0x65) {
- type = SMC_37C665GT;
- goto config;
- }
-
- for (i = 0; i < 2; i++) {
- s = splhigh();
- outb(csr, SMC666_iCODE);
- outb(csr, SMC666_iCODE);
- splx(s);
-
- outb(csr, 0xd);
- if (inb(cio) == 0x66) {
- type = SMC_37C666GT;
- break;
- }
-
- /* Another chance, CSR may be hard-configured to be at 0x370 */
- csr = SMC666_CSR;
- }
-
-config:
- /*
- * If chipset not found, do not continue.
- */
- if (type == -1)
- return (-1);
-
- /* select CR1 */
- outb(csr, 0x1);
-
- /* read the port's address: bits 0 and 1 of CR1 */
- r = inb(cio) & SMC_CR1_ADDR;
- if (port_address[(int)r] != ppc->ppc_base)
- return (-1);
-
- ppc->ppc_model = type;
-
- /*
- * CR1 and CR4 registers bits 3 and 0/1 for mode configuration
- * If SPP mode is detected, try to set ECP+EPP mode
- */
-
- if (bootverbose) {
- outb(csr, 0x1);
- printf("ppc%d: SMC registers CR1=0x%x", ppc->ppc_unit,
- inb(cio) & 0xff);
-
- outb(csr, 0x4);
- printf(" CR4=0x%x", inb(cio) & 0xff);
- }
-
- /* select CR1 */
- outb(csr, 0x1);
-
- if (!chipset_mode) {
- /* autodetect mode */
-
- /* 666GT is ~certainly~ hardwired to an extended ECP+EPP mode */
- if (type == SMC_37C666GT) {
- ppc->ppc_avm |= PPB_ECP | PPB_EPP | PPB_SPP;
- if (bootverbose)
- printf(" configuration hardwired, supposing " \
- "ECP+EPP SPP");
-
- } else
- if ((inb(cio) & SMC_CR1_MODE) == 0) {
- /* already in extended parallel port mode, read CR4 */
- outb(csr, 0x4);
- r = (inb(cio) & SMC_CR4_EMODE);
-
- switch (r) {
- case SMC_SPP:
- ppc->ppc_avm |= PPB_SPP;
- if (bootverbose)
- printf(" SPP");
- break;
-
- case SMC_EPPSPP:
- ppc->ppc_avm |= PPB_EPP | PPB_SPP;
- if (bootverbose)
- printf(" EPP SPP");
- break;
-
- case SMC_ECP:
- ppc->ppc_avm |= PPB_ECP | PPB_SPP;
- if (bootverbose)
- printf(" ECP SPP");
- break;
-
- case SMC_ECPEPP:
- ppc->ppc_avm |= PPB_ECP | PPB_EPP | PPB_SPP;
- if (bootverbose)
- printf(" ECP+EPP SPP");
- break;
- }
- } else {
- /* not an extended port mode */
- ppc->ppc_avm |= PPB_SPP;
- if (bootverbose)
- printf(" SPP");
- }
-
- } else {
- /* mode forced */
- ppc->ppc_avm = chipset_mode;
-
- /* 666GT is ~certainly~ hardwired to an extended ECP+EPP mode */
- if (type == SMC_37C666GT)
- goto end_detect;
-
- r = inb(cio);
- if ((chipset_mode & (PPB_ECP | PPB_EPP)) == 0) {
- /* do not use ECP when the mode is not forced to */
- outb(cio, r | SMC_CR1_MODE);
- if (bootverbose)
- printf(" SPP");
- } else {
- /* an extended mode is selected */
- outb(cio, r & ~SMC_CR1_MODE);
-
- /* read CR4 register and reset mode field */
- outb(csr, 0x4);
- r = inb(cio) & ~SMC_CR4_EMODE;
-
- if (chipset_mode & PPB_ECP) {
- if (chipset_mode & PPB_EPP) {
- outb(cio, r | SMC_ECPEPP);
- if (bootverbose)
- printf(" ECP+EPP");
- } else {
- outb(cio, r | SMC_ECP);
- if (bootverbose)
- printf(" ECP");
- }
- } else {
- /* PPB_EPP is set */
- outb(cio, r | SMC_EPPSPP);
- if (bootverbose)
- printf(" EPP SPP");
- }
- }
- ppc->ppc_avm = chipset_mode;
- }
-
- /* set FIFO threshold to 16 */
- if (ppc->ppc_avm & PPB_ECP) {
- /* select CRA */
- outb(csr, 0xa);
- outb(cio, 16);
- }
-
-end_detect:
-
- if (bootverbose)
- printf ("\n");
-
- if (ppc->ppc_avm & PPB_EPP) {
- /* select CR4 */
- outb(csr, 0x4);
- r = inb(cio);
-
- /*
- * Set the EPP protocol...
- * Low=EPP 1.9 (1284 standard) and High=EPP 1.7
- */
- if (ppc->ppc_epp == EPP_1_9)
- outb(cio, (r & ~SMC_CR4_EPPTYPE));
- else
- outb(cio, (r | SMC_CR4_EPPTYPE));
- }
-
- /* end config mode */
- outb(csr, 0xaa);
-
- ppc->ppc_type = PPC_TYPE_SMCLIKE;
- ppc_smclike_setmode(ppc, chipset_mode);
-
- return (chipset_mode);
-}
-
-/*
- * Winbond W83877F stuff
- *
- * EFER: extended function enable register
- * EFIR: extended function index register
- * EFDR: extended function data register
- */
-#define efir ((efer == 0x250) ? 0x251 : 0x3f0)
-#define efdr ((efer == 0x250) ? 0x252 : 0x3f1)
-
-static int w83877f_efers[] = { 0x250, 0x3f0, 0x3f0, 0x250 };
-static int w83877f_keys[] = { 0x89, 0x86, 0x87, 0x88 };
-static int w83877f_keyiter[] = { 1, 2, 2, 1 };
-static int w83877f_hefs[] = { WINB_HEFERE, WINB_HEFRAS, WINB_HEFERE | WINB_HEFRAS, 0 };
-
-static int
-ppc_w83877f_detect(struct ppc_data *ppc, int chipset_mode)
-{
- int i, j, efer;
- unsigned char r, hefere, hefras;
-
- for (i = 0; i < 4; i ++) {
- /* first try to enable configuration registers */
- efer = w83877f_efers[i];
-
- /* write the key to the EFER */
- for (j = 0; j < w83877f_keyiter[i]; j ++)
- outb (efer, w83877f_keys[i]);
-
- /* then check HEFERE and HEFRAS bits */
- outb (efir, 0x0c);
- hefere = inb(efdr) & WINB_HEFERE;
-
- outb (efir, 0x16);
- hefras = inb(efdr) & WINB_HEFRAS;
-
- /*
- * HEFRAS HEFERE
- * 0 1 write 89h to 250h (power-on default)
- * 1 0 write 86h twice to 3f0h
- * 1 1 write 87h twice to 3f0h
- * 0 0 write 88h to 250h
- */
- if ((hefere | hefras) == w83877f_hefs[i])
- goto found;
- }
-
- return (-1); /* failed */
-
-found:
- /* check base port address - read from CR23 */
- outb(efir, 0x23);
- if (ppc->ppc_base != inb(efdr) * 4) /* 4 bytes boundaries */
- return (-1);
-
- /* read CHIP ID from CR9/bits0-3 */
- outb(efir, 0x9);
-
- switch (inb(efdr) & WINB_CHIPID) {
- case WINB_W83877F_ID:
- ppc->ppc_model = WINB_W83877F;
- break;
-
- case WINB_W83877AF_ID:
- ppc->ppc_model = WINB_W83877AF;
- break;
-
- default:
- ppc->ppc_model = WINB_UNKNOWN;
- }
-
- if (bootverbose) {
- /* dump of registers */
- printf("ppc%d: 0x%x - ", ppc->ppc_unit, w83877f_keys[i]);
- for (i = 0; i <= 0xd; i ++) {
- outb(efir, i);
- printf("0x%x ", inb(efdr));
- }
- for (i = 0x10; i <= 0x17; i ++) {
- outb(efir, i);
- printf("0x%x ", inb(efdr));
- }
- outb(efir, 0x1e);
- printf("0x%x ", inb(efdr));
- for (i = 0x20; i <= 0x29; i ++) {
- outb(efir, i);
- printf("0x%x ", inb(efdr));
- }
- printf("\n");
- printf("ppc%d:", ppc->ppc_unit);
- }
-
- ppc->ppc_type = PPC_TYPE_GENERIC;
-
- if (!chipset_mode) {
- /* autodetect mode */
-
- /* select CR0 */
- outb(efir, 0x0);
- r = inb(efdr) & (WINB_PRTMODS0 | WINB_PRTMODS1);
-
- /* select CR9 */
- outb(efir, 0x9);
- r |= (inb(efdr) & WINB_PRTMODS2);
-
- switch (r) {
- case WINB_W83757:
- if (bootverbose)
- printf("ppc%d: W83757 compatible mode\n",
- ppc->ppc_unit);
- return (-1); /* generic or SMC-like */
-
- case WINB_EXTFDC:
- case WINB_EXTADP:
- case WINB_EXT2FDD:
- case WINB_JOYSTICK:
- if (bootverbose)
- printf(" not in parallel port mode\n");
- return (-1);
-
- case (WINB_PARALLEL | WINB_EPP_SPP):
- ppc->ppc_avm |= PPB_EPP | PPB_SPP;
- if (bootverbose)
- printf(" EPP SPP");
- break;
-
- case (WINB_PARALLEL | WINB_ECP):
- ppc->ppc_avm |= PPB_ECP | PPB_SPP;
- if (bootverbose)
- printf(" ECP SPP");
- break;
-
- case (WINB_PARALLEL | WINB_ECP_EPP):
- ppc->ppc_avm |= PPB_ECP | PPB_EPP | PPB_SPP;
- ppc->ppc_type = PPC_TYPE_SMCLIKE;
-
- if (bootverbose)
- printf(" ECP+EPP SPP");
- break;
- default:
- printf("%s: unknown case (0x%x)!\n", __FUNCTION__, r);
- }
-
- } else {
- /* mode forced */
-
- /* select CR9 and set PRTMODS2 bit */
- outb(efir, 0x9);
- outb(efdr, inb(efdr) & ~WINB_PRTMODS2);
-
- /* select CR0 and reset PRTMODSx bits */
- outb(efir, 0x0);
- outb(efdr, inb(efdr) & ~(WINB_PRTMODS0 | WINB_PRTMODS1));
-
- if (chipset_mode & PPB_ECP) {
- if (chipset_mode & PPB_EPP) {
- outb(efdr, inb(efdr) | WINB_ECP_EPP);
- if (bootverbose)
- printf(" ECP+EPP");
-
- ppc->ppc_type = PPC_TYPE_SMCLIKE;
-
- } else {
- outb(efdr, inb(efdr) | WINB_ECP);
- if (bootverbose)
- printf(" ECP");
- }
- } else {
- /* select EPP_SPP otherwise */
- outb(efdr, inb(efdr) | WINB_EPP_SPP);
- if (bootverbose)
- printf(" EPP SPP");
- }
- ppc->ppc_avm = chipset_mode;
- }
-
- if (bootverbose)
- printf("\n");
-
- /* exit configuration mode */
- outb(efer, 0xaa);
-
- switch (ppc->ppc_type) {
- case PPC_TYPE_SMCLIKE:
- ppc_smclike_setmode(ppc, chipset_mode);
- break;
- default:
- ppc_generic_setmode(ppc, chipset_mode);
- break;
- }
-
- return (chipset_mode);
-}
-#endif
-
-/*
- * ppc_generic_detect
- */
-static int
-ppc_generic_detect(struct ppc_data *ppc, int chipset_mode)
-{
- /* default to generic */
- ppc->ppc_type = PPC_TYPE_GENERIC;
-
- if (bootverbose)
- printf("ppc%d:", ppc->ppc_unit);
-
- if (!chipset_mode) {
- /* first, check for ECP */
- w_ecr(ppc, PPC_ECR_PS2);
- if ((r_ecr(ppc) & 0xe0) == PPC_ECR_PS2) {
- ppc->ppc_avm |= PPB_ECP | PPB_SPP;
- if (bootverbose)
- printf(" ECP SPP");
-
- /* search for SMC style ECP+EPP mode */
- w_ecr(ppc, PPC_ECR_EPP);
- }
-
- /* try to reset EPP timeout bit */
- if (ppc_check_epp_timeout(ppc)) {
- ppc->ppc_avm |= PPB_EPP;
-
- if (ppc->ppc_avm & PPB_ECP) {
- /* SMC like chipset found */
- ppc->ppc_model = SMC_LIKE;
- ppc->ppc_type = PPC_TYPE_SMCLIKE;
-
- if (bootverbose)
- printf(" ECP+EPP");
- } else {
- if (bootverbose)
- printf(" EPP");
- }
- } else {
- /* restore to standard mode */
- w_ecr(ppc, PPC_ECR_STD);
- }
-
- /* XXX try to detect NIBBLE and PS2 modes */
- ppc->ppc_avm |= PPB_NIBBLE;
-
- if (bootverbose)
- printf(" SPP");
-
- } else {
- ppc->ppc_avm = chipset_mode;
- }
-
- if (bootverbose)
- printf("\n");
-
- switch (ppc->ppc_type) {
- case PPC_TYPE_SMCLIKE:
- ppc_smclike_setmode(ppc, chipset_mode);
- break;
- default:
- ppc_generic_setmode(ppc, chipset_mode);
- break;
- }
-
- return (chipset_mode);
-}
-
-/*
- * ppc_detect()
- *
- * mode is the mode suggested at boot
- */
-static int
-ppc_detect(struct ppc_data *ppc, int chipset_mode) {
-
-#ifdef PPC_PROBE_CHIPSET
- int i, mode;
-
- /* list of supported chipsets */
- int (*chipset_detect[])(struct ppc_data *, int) = {
- ppc_pc873xx_detect,
- ppc_smc37c66xgt_detect,
- ppc_w83877f_detect,
- ppc_generic_detect,
- NULL
- };
-#endif
-
- /* if can't find the port and mode not forced return error */
- if (!ppc_detect_port(ppc) && chipset_mode == 0)
- return (EIO); /* failed, port not present */
-
- /* assume centronics compatible mode is supported */
- ppc->ppc_avm = PPB_COMPATIBLE;
-
-#ifdef PPC_PROBE_CHIPSET
- /* we have to differenciate available chipset modes,
- * chipset running modes and IEEE-1284 operating modes
- *
- * after detection, the port must support running in compatible mode
- */
- if (ppc->ppc_flags & 0x40) {
- if (bootverbose)
- printf("ppc: chipset forced to generic\n");
-#endif
-
- ppc->ppc_mode = ppc_generic_detect(ppc, chipset_mode);
-
-#ifdef PPC_PROBE_CHIPSET
- } else {
- for (i=0; chipset_detect[i] != NULL; i++) {
- if ((mode = chipset_detect[i](ppc, chipset_mode)) != -1) {
- ppc->ppc_mode = mode;
- break;
- }
- }
- }
-#endif
-
- /* configure/detect ECP FIFO */
- if ((ppc->ppc_avm & PPB_ECP) && !(ppc->ppc_flags & 0x80))
- ppc_detect_fifo(ppc);
-
- return (0);
-}
-
-/*
- * ppc_exec_microseq()
- *
- * Execute a microsequence.
- * Microsequence mechanism is supposed to handle fast I/O operations.
- */
-static int
-ppc_exec_microseq(device_t dev, struct ppb_microseq **p_msq)
-{
- struct ppc_data *ppc = DEVTOSOFTC(dev);
- struct ppb_microseq *mi;
- char cc, *p;
- int i, iter, len;
- int error;
-
- register int reg;
- register char mask;
- register int accum = 0;
- register char *ptr = 0;
-
- struct ppb_microseq *stack = 0;
-
-/* microsequence registers are equivalent to PC-like port registers */
-#define r_reg(register,ppc) (inb((ppc)->ppc_base + register))
-#define w_reg(register,ppc,byte) outb((ppc)->ppc_base + register, byte)
-
-#define INCR_PC (mi ++) /* increment program counter */
-
- mi = *p_msq;
- for (;;) {
- switch (mi->opcode) {
- case MS_OP_RSET:
- cc = r_reg(mi->arg[0].i, ppc);
- cc &= (char)mi->arg[2].i; /* clear mask */
- cc |= (char)mi->arg[1].i; /* assert mask */
- w_reg(mi->arg[0].i, ppc, cc);
- INCR_PC;
- break;
-
- case MS_OP_RASSERT_P:
- reg = mi->arg[1].i;
- ptr = ppc->ppc_ptr;
-
- if ((len = mi->arg[0].i) == MS_ACCUM) {
- accum = ppc->ppc_accum;
- for (; accum; accum--)
- w_reg(reg, ppc, *ptr++);
- ppc->ppc_accum = accum;
- } else
- for (i=0; i<len; i++)
- w_reg(reg, ppc, *ptr++);
- ppc->ppc_ptr = ptr;
-
- INCR_PC;
- break;
-
- case MS_OP_RFETCH_P:
- reg = mi->arg[1].i;
- mask = (char)mi->arg[2].i;
- ptr = ppc->ppc_ptr;
-
- if ((len = mi->arg[0].i) == MS_ACCUM) {
- accum = ppc->ppc_accum;
- for (; accum; accum--)
- *ptr++ = r_reg(reg, ppc) & mask;
- ppc->ppc_accum = accum;
- } else
- for (i=0; i<len; i++)
- *ptr++ = r_reg(reg, ppc) & mask;
- ppc->ppc_ptr = ptr;
-
- INCR_PC;
- break;
-
- case MS_OP_RFETCH:
- *((char *) mi->arg[2].p) = r_reg(mi->arg[0].i, ppc) &
- (char)mi->arg[1].i;
- INCR_PC;
- break;
-
- case MS_OP_RASSERT:
- case MS_OP_DELAY:
-
- /* let's suppose the next instr. is the same */
- prefetch:
- for (;mi->opcode == MS_OP_RASSERT; INCR_PC)
- w_reg(mi->arg[0].i, ppc, (char)mi->arg[1].i);
-
- if (mi->opcode == MS_OP_DELAY) {
- DELAY(mi->arg[0].i);
- INCR_PC;
- goto prefetch;
- }
- break;
-
- case MS_OP_ADELAY:
- if (mi->arg[0].i)
- tsleep(NULL, PPBPRI, "ppbdelay",
- mi->arg[0].i * (hz/1000));
- INCR_PC;
- break;
-
- case MS_OP_TRIG:
- reg = mi->arg[0].i;
- iter = mi->arg[1].i;
- p = (char *)mi->arg[2].p;
-
- /* XXX delay limited to 255 us */
- for (i=0; i<iter; i++) {
- w_reg(reg, ppc, *p++);
- DELAY((unsigned char)*p++);
- }
- INCR_PC;
- break;
-
- case MS_OP_SET:
- ppc->ppc_accum = mi->arg[0].i;
- INCR_PC;
- break;
-
- case MS_OP_DBRA:
- if (--ppc->ppc_accum > 0)
- mi += mi->arg[0].i;
- INCR_PC;
- break;
-
- case MS_OP_BRSET:
- cc = r_str(ppc);
- if ((cc & (char)mi->arg[0].i) == (char)mi->arg[0].i)
- mi += mi->arg[1].i;
- INCR_PC;
- break;
-
- case MS_OP_BRCLEAR:
- cc = r_str(ppc);
- if ((cc & (char)mi->arg[0].i) == 0)
- mi += mi->arg[1].i;
- INCR_PC;
- break;
-
- case MS_OP_BRSTAT:
- cc = r_str(ppc);
- if ((cc & ((char)mi->arg[0].i | (char)mi->arg[1].i)) ==
- (char)mi->arg[0].i)
- mi += mi->arg[2].i;
- INCR_PC;
- break;
-
- case MS_OP_C_CALL:
- /*
- * If the C call returns !0 then end the microseq.
- * The current state of ptr is passed to the C function
- */
- if ((error = mi->arg[0].f(mi->arg[1].p, ppc->ppc_ptr)))
- return (error);
-
- INCR_PC;
- break;
-
- case MS_OP_PTR:
- ppc->ppc_ptr = (char *)mi->arg[0].p;
- INCR_PC;
- break;
-
- case MS_OP_CALL:
- if (stack)
- panic("%s: too much calls", __FUNCTION__);
-
- if (mi->arg[0].p) {
- /* store the state of the actual
- * microsequence
- */
- stack = mi;
-
- /* jump to the new microsequence */
- mi = (struct ppb_microseq *)mi->arg[0].p;
- } else
- INCR_PC;
-
- break;
-
- case MS_OP_SUBRET:
- /* retrieve microseq and pc state before the call */
- mi = stack;
-
- /* reset the stack */
- stack = 0;
-
- /* XXX return code */
-
- INCR_PC;
- break;
-
- case MS_OP_PUT:
- case MS_OP_GET:
- case MS_OP_RET:
- /* can't return to ppb level during the execution
- * of a submicrosequence */
- if (stack)
- panic("%s: can't return to ppb level",
- __FUNCTION__);
-
- /* update pc for ppb level of execution */
- *p_msq = mi;
-
- /* return to ppb level of execution */
- return (0);
-
- default:
- panic("%s: unknown microsequence opcode 0x%x",
- __FUNCTION__, mi->opcode);
- }
- }
-
- /* unreached */
-}
-
-static void
-ppcintr(void *arg)
-{
- device_t dev = (device_t)arg;
- struct ppc_data *ppc = (struct ppc_data *)device_get_softc(dev);
- u_char ctr, ecr, str;
-
- str = r_str(ppc);
- ctr = r_ctr(ppc);
- ecr = r_ecr(ppc);
-
-#if PPC_DEBUG > 1
- printf("![%x/%x/%x]", ctr, ecr, str);
-#endif
-
- /* don't use ecp mode with IRQENABLE set */
- if (ctr & IRQENABLE) {
- return;
- }
-
- /* interrupts are generated by nFault signal
- * only in ECP mode */
- if ((str & nFAULT) && (ppc->ppc_mode & PPB_ECP)) {
- /* check if ppc driver has programmed the
- * nFault interrupt */
- if (ppc->ppc_irqstat & PPC_IRQ_nFAULT) {
-
- w_ecr(ppc, ecr | PPC_nFAULT_INTR);
- ppc->ppc_irqstat &= ~PPC_IRQ_nFAULT;
- } else {
- /* shall be handled by underlying layers XXX */
- return;
- }
- }
-
- if (ppc->ppc_irqstat & PPC_IRQ_DMA) {
- /* disable interrupts (should be done by hardware though) */
- w_ecr(ppc, ecr | PPC_SERVICE_INTR);
- ppc->ppc_irqstat &= ~PPC_IRQ_DMA;
- ecr = r_ecr(ppc);
-
- /* check if DMA completed */
- if ((ppc->ppc_avm & PPB_ECP) && (ecr & PPC_ENABLE_DMA)) {
-#ifdef PPC_DEBUG
- printf("a");
-#endif
- /* stop DMA */
- w_ecr(ppc, ecr & ~PPC_ENABLE_DMA);
- ecr = r_ecr(ppc);
-
- if (ppc->ppc_dmastat == PPC_DMA_STARTED) {
-#ifdef PPC_DEBUG
- printf("d");
-#endif
- isa_dmadone(
- ppc->ppc_dmaflags,
- ppc->ppc_dmaddr,
- ppc->ppc_dmacnt,
- ppc->ppc_dmachan);
-
- ppc->ppc_dmastat = PPC_DMA_COMPLETE;
-
- /* wakeup the waiting process */
- wakeup((caddr_t)ppc);
- }
- }
- } else if (ppc->ppc_irqstat & PPC_IRQ_FIFO) {
-
- /* classic interrupt I/O */
- ppc->ppc_irqstat &= ~PPC_IRQ_FIFO;
- }
-
- return;
-}
-
-static int
-ppc_read(device_t dev, char *buf, int len, int mode)
-{
- return (EINVAL);
-}
-
-/*
- * Call this function if you want to send data in any advanced mode
- * of your parallel port: FIFO, DMA
- *
- * If what you want is not possible (no ECP, no DMA...),
- * EINVAL is returned
- */
-static int
-ppc_write(device_t dev, char *buf, int len, int how)
-{
- struct ppc_data *ppc = DEVTOSOFTC(dev);
- char ecr, ecr_sav, ctr, ctr_sav;
- int s, error = 0;
- int spin;
-
-#ifdef PPC_DEBUG
- printf("w");
-#endif
-
- ecr_sav = r_ecr(ppc);
- ctr_sav = r_ctr(ppc);
-
- /*
- * Send buffer with DMA, FIFO and interrupts
- */
- if ((ppc->ppc_avm & PPB_ECP) && (ppc->ppc_registered)) {
-
- if (ppc->ppc_dmachan >= 0) {
-
- /* byte mode, no intr, no DMA, dir=0, flush fifo
- */
- ecr = PPC_ECR_STD | PPC_DISABLE_INTR;
- w_ecr(ppc, ecr);
-
- /* disable nAck interrupts */
- ctr = r_ctr(ppc);
- ctr &= ~IRQENABLE;
- w_ctr(ppc, ctr);
-
- ppc->ppc_dmaflags = 0;
- ppc->ppc_dmaddr = (caddr_t)buf;
- ppc->ppc_dmacnt = (u_int)len;
-
- switch (ppc->ppc_mode) {
- case PPB_COMPATIBLE:
- /* compatible mode with FIFO, no intr, DMA, dir=0 */
- ecr = PPC_ECR_FIFO | PPC_DISABLE_INTR | PPC_ENABLE_DMA;
- break;
- case PPB_ECP:
- ecr = PPC_ECR_ECP | PPC_DISABLE_INTR | PPC_ENABLE_DMA;
- break;
- default:
- error = EINVAL;
- goto error;
- }
-
- w_ecr(ppc, ecr);
- ecr = r_ecr(ppc);
-
- /* enter splhigh() not to be preempted
- * by the dma interrupt, we may miss
- * the wakeup otherwise
- */
- s = splhigh();
-
- ppc->ppc_dmastat = PPC_DMA_INIT;
-
- /* enable interrupts */
- ecr &= ~PPC_SERVICE_INTR;
- ppc->ppc_irqstat = PPC_IRQ_DMA;
- w_ecr(ppc, ecr);
-
- isa_dmastart(
- ppc->ppc_dmaflags,
- ppc->ppc_dmaddr,
- ppc->ppc_dmacnt,
- ppc->ppc_dmachan);
-#ifdef PPC_DEBUG
- printf("s%d", ppc->ppc_dmacnt);
-#endif
- ppc->ppc_dmastat = PPC_DMA_STARTED;
-
- /* Wait for the DMA completed interrupt. We hope we won't
- * miss it, otherwise a signal will be necessary to unlock the
- * process.
- */
- do {
- /* release CPU */
- error = tsleep((caddr_t)ppc,
- PPBPRI | PCATCH, "ppcdma", 0);
-
- } while (error == EWOULDBLOCK);
-
- splx(s);
-
- if (error) {
-#ifdef PPC_DEBUG
- printf("i");
-#endif
- /* stop DMA */
- isa_dmadone(
- ppc->ppc_dmaflags, ppc->ppc_dmaddr,
- ppc->ppc_dmacnt, ppc->ppc_dmachan);
-
- /* no dma, no interrupt, flush the fifo */
- w_ecr(ppc, PPC_ECR_RESET);
-
- ppc->ppc_dmastat = PPC_DMA_INTERRUPTED;
- goto error;
- }
-
- /* wait for an empty fifo */
- while (!(r_ecr(ppc) & PPC_FIFO_EMPTY)) {
-
- for (spin=100; spin; spin--)
- if (r_ecr(ppc) & PPC_FIFO_EMPTY)
- goto fifo_empty;
-#ifdef PPC_DEBUG
- printf("Z");
-#endif
- error = tsleep((caddr_t)ppc, PPBPRI | PCATCH, "ppcfifo", hz/100);
- if (error != EWOULDBLOCK) {
-#ifdef PPC_DEBUG
- printf("I");
-#endif
- /* no dma, no interrupt, flush the fifo */
- w_ecr(ppc, PPC_ECR_RESET);
-
- ppc->ppc_dmastat = PPC_DMA_INTERRUPTED;
- error = EINTR;
- goto error;
- }
- }
-
-fifo_empty:
- /* no dma, no interrupt, flush the fifo */
- w_ecr(ppc, PPC_ECR_RESET);
-
- } else
- error = EINVAL; /* XXX we should FIFO and
- * interrupts */
- } else
- error = EINVAL;
-
-error:
-
- /* PDRQ must be kept unasserted until nPDACK is
- * deasserted for a minimum of 350ns (SMC datasheet)
- *
- * Consequence may be a FIFO that never empty
- */
- DELAY(1);
-
- w_ecr(ppc, ecr_sav);
- w_ctr(ppc, ctr_sav);
-
- return (error);
-}
-
-static void
-ppc_reset_epp(device_t dev)
-{
- struct ppc_data *ppc = DEVTOSOFTC(dev);
-
- ppc_reset_epp_timeout(ppc);
-
- return;
-}
-
-static int
-ppc_setmode(device_t dev, int mode)
-{
- struct ppc_data *ppc = DEVTOSOFTC(dev);
-
- switch (ppc->ppc_type) {
- case PPC_TYPE_SMCLIKE:
- return (ppc_smclike_setmode(ppc, mode));
- break;
-
- case PPC_TYPE_GENERIC:
- default:
- return (ppc_generic_setmode(ppc, mode));
- break;
- }
-
- /* not reached */
- return (ENXIO);
-}
-
-static int
-ppc_probe(device_t dev)
-{
-#ifdef __i386__
- static short next_bios_ppc = 0;
-#endif
- struct ppc_data *ppc;
- device_t parent;
- int error;
- u_long port;
-#ifdef PC98
-#define PC98_IEEE_1284_DISABLE 0x100
-#define PC98_IEEE_1284_PORT 0x140
-
- unsigned int pc98_ieee_mode = 0x00;
- unsigned int tmp;
-#endif
-
- /* If we are a PNP device, abort. Otherwise we attach to *everthing* */
- if (isa_get_logicalid(dev))
- return ENXIO;
-
- parent = device_get_parent(dev);
-
- /* XXX shall be set after detection */
- device_set_desc(dev, "Parallel port");
-
- /*
- * Allocate the ppc_data structure.
- */
- ppc = DEVTOSOFTC(dev);
- bzero(ppc, sizeof(struct ppc_data));
-
- ppc->rid_irq = ppc->rid_drq = ppc->rid_ioport = 0;
- ppc->res_irq = ppc->res_drq = ppc->res_ioport = 0;
-
- /* retrieve ISA parameters */
- error = bus_get_resource(dev, SYS_RES_IOPORT, 0, &port, NULL);
-
-#ifdef __i386__
- /*
- * If port not specified, use bios list.
- */
- if (error) {
-#ifndef PC98
- if((next_bios_ppc < BIOS_MAX_PPC) &&
- (*(BIOS_PORTS+next_bios_ppc) != 0) ) {
- port = *(BIOS_PORTS+next_bios_ppc++);
- if (bootverbose)
- device_printf(dev, "parallel port found at 0x%x\n",
- (int) port);
- } else {
- device_printf(dev, "parallel port not found.\n");
- return ENXIO;
- }
-#else
- if (next_bios_ppc == 0) {
- /* Use default IEEE-1284 port of NEC PC-98x1 */
- port = PC98_IEEE_1284_PORT;
- next_bios_ppc += 1;
- if (bootverbose)
- device_printf(dev, "parallel port found at 0x%x\n",
- (int) port);
- }
-#endif
- bus_set_resource(dev, SYS_RES_IOPORT, 0, port, IO_LPTSIZE);
- }
-#endif
-#ifdef __alpha__
- /*
- * There isn't a bios list on alpha. Put it in the usual place.
- */
- if (error) {
- bus_set_resource(dev, SYS_RES_IOPORT, 0, 0x3bc, IO_LPTSIZE);
- }
-#endif
-
- /* IO port is mandatory */
- ppc->res_ioport = bus_alloc_resource(dev, SYS_RES_IOPORT,
- &ppc->rid_ioport, 0, ~0,
- IO_LPTSIZE, RF_ACTIVE);
- if (ppc->res_ioport == 0) {
- device_printf(dev, "cannot reserve I/O port range\n");
- goto error;
- }
- ppc->ppc_base = rman_get_start(ppc->res_ioport);
-
- ppc->ppc_flags = device_get_flags(dev);
-
- if (!(ppc->ppc_flags & 0x20)) {
- ppc->res_irq = bus_alloc_resource(dev, SYS_RES_IRQ, &ppc->rid_irq,
- 0ul, ~0ul, 1, RF_SHAREABLE);
- ppc->res_drq = bus_alloc_resource(dev, SYS_RES_DRQ, &ppc->rid_drq,
- 0ul, ~0ul, 1, RF_ACTIVE);
- }
-
- if (ppc->res_irq)
- ppc->ppc_irq = rman_get_start(ppc->res_irq);
- if (ppc->res_drq)
- ppc->ppc_dmachan = rman_get_start(ppc->res_drq);
-
- ppc->ppc_unit = device_get_unit(dev);
- ppc->ppc_model = GENERIC;
-
- ppc->ppc_mode = PPB_COMPATIBLE;
- ppc->ppc_epp = (ppc->ppc_flags & 0x10) >> 4;
-
- ppc->ppc_type = PPC_TYPE_GENERIC;
-
-#ifdef PC98
- /*
- * IEEE STD 1284 Function Check and Enable
- * for default IEEE-1284 port of NEC PC-98x1
- */
- if ((ppc->ppc_base == PC98_IEEE_1284_PORT) &&
- !(ppc->ppc_flags & PC98_IEEE_1284_DISABLE)) {
- tmp = inb(ppc->ppc_base + PPC_1284_ENABLE);
- pc98_ieee_mode = tmp;
- if ((tmp & 0x10) == 0x10) {
- outb(ppc->ppc_base + PPC_1284_ENABLE, tmp & ~0x10);
- tmp = inb(ppc->ppc_base + PPC_1284_ENABLE);
- if ((tmp & 0x10) == 0x10)
- goto error;
- } else {
- outb(ppc->ppc_base + PPC_1284_ENABLE, tmp | 0x10);
- tmp = inb(ppc->ppc_base + PPC_1284_ENABLE);
- if ((tmp & 0x10) != 0x10)
- goto error;
- }
- outb(ppc->ppc_base + PPC_1284_ENABLE, pc98_ieee_mode | 0x10);
- }
-#endif
-
- /*
- * Try to detect the chipset and its mode.
- */
- if (ppc_detect(ppc, ppc->ppc_flags & 0xf))
- goto error;
-
- return (0);
-
-error:
-#ifdef PC98
- if ((ppc->ppc_base == PC98_IEEE_1284_PORT) &&
- !(ppc->ppc_flags & PC98_IEEE_1284_DISABLE)) {
- outb(ppc->ppc_base + PPC_1284_ENABLE, pc98_ieee_mode);
- }
-#endif
- if (ppc->res_irq != 0) {
- bus_release_resource(dev, SYS_RES_IRQ, ppc->rid_irq,
- ppc->res_irq);
- }
- if (ppc->res_ioport != 0) {
- bus_deactivate_resource(dev, SYS_RES_IOPORT, ppc->rid_ioport,
- ppc->res_ioport);
- bus_release_resource(dev, SYS_RES_IOPORT, ppc->rid_ioport,
- ppc->res_ioport);
- }
- if (ppc->res_drq != 0) {
- bus_deactivate_resource(dev, SYS_RES_DRQ, ppc->rid_drq,
- ppc->res_drq);
- bus_release_resource(dev, SYS_RES_DRQ, ppc->rid_drq,
- ppc->res_drq);
- }
- return (ENXIO);
-}
-
-static int
-ppc_attach(device_t dev)
-{
- struct ppc_data *ppc = DEVTOSOFTC(dev);
-
- device_t ppbus;
- device_t parent = device_get_parent(dev);
-
- device_printf(dev, "%s chipset (%s) in %s mode%s\n",
- ppc_models[ppc->ppc_model], ppc_avms[ppc->ppc_avm],
- ppc_modes[ppc->ppc_mode], (PPB_IS_EPP(ppc->ppc_mode)) ?
- ppc_epp_protocol[ppc->ppc_epp] : "");
-
- if (ppc->ppc_fifo)
- device_printf(dev, "FIFO with %d/%d/%d bytes threshold\n",
- ppc->ppc_fifo, ppc->ppc_wthr, ppc->ppc_rthr);
-
- if ((ppc->ppc_avm & PPB_ECP) && (ppc->ppc_dmachan > 0)) {
- /* acquire the DMA channel forever */ /* XXX */
- isa_dma_acquire(ppc->ppc_dmachan);
- isa_dmainit(ppc->ppc_dmachan, 1024); /* nlpt.BUFSIZE */
- }
-
- /* add ppbus as a child of this isa to parallel bridge */
- ppbus = device_add_child(dev, "ppbus", -1);
-
- /*
- * Probe the ppbus and attach devices found.
- */
- device_probe_and_attach(ppbus);
-
- /* register the ppc interrupt handler as default */
- if (ppc->res_irq) {
- /* default to the tty mask for registration */ /* XXX */
- if (BUS_SETUP_INTR(parent, dev, ppc->res_irq, INTR_TYPE_TTY,
- ppcintr, dev, &ppc->intr_cookie) == 0) {
-
- /* remember the ppcintr is registered */
- ppc->ppc_registered = 1;
- }
- }
-
- return (0);
-}
-
-static u_char
-ppc_io(device_t ppcdev, int iop, u_char *addr, int cnt, u_char byte)
-{
- struct ppc_data *ppc = DEVTOSOFTC(ppcdev);
- switch (iop) {
- case PPB_OUTSB_EPP:
- outsb(ppc->ppc_base + PPC_EPP_DATA, addr, cnt);
- break;
- case PPB_OUTSW_EPP:
- outsw(ppc->ppc_base + PPC_EPP_DATA, addr, cnt);
- break;
- case PPB_OUTSL_EPP:
- outsl(ppc->ppc_base + PPC_EPP_DATA, addr, cnt);
- break;
- case PPB_INSB_EPP:
- insb(ppc->ppc_base + PPC_EPP_DATA, addr, cnt);
- break;
- case PPB_INSW_EPP:
- insw(ppc->ppc_base + PPC_EPP_DATA, addr, cnt);
- break;
- case PPB_INSL_EPP:
- insl(ppc->ppc_base + PPC_EPP_DATA, addr, cnt);
- break;
- case PPB_RDTR:
- return (r_dtr(ppc));
- break;
- case PPB_RSTR:
- return (r_str(ppc));
- break;
- case PPB_RCTR:
- return (r_ctr(ppc));
- break;
- case PPB_REPP_A:
- return (r_epp_A(ppc));
- break;
- case PPB_REPP_D:
- return (r_epp_D(ppc));
- break;
- case PPB_RECR:
- return (r_ecr(ppc));
- break;
- case PPB_RFIFO:
- return (r_fifo(ppc));
- break;
- case PPB_WDTR:
- w_dtr(ppc, byte);
- break;
- case PPB_WSTR:
- w_str(ppc, byte);
- break;
- case PPB_WCTR:
- w_ctr(ppc, byte);
- break;
- case PPB_WEPP_A:
- w_epp_A(ppc, byte);
- break;
- case PPB_WEPP_D:
- w_epp_D(ppc, byte);
- break;
- case PPB_WECR:
- w_ecr(ppc, byte);
- break;
- case PPB_WFIFO:
- w_fifo(ppc, byte);
- break;
- default:
- panic("%s: unknown I/O operation", __FUNCTION__);
- break;
- }
-
- return (0); /* not significative */
-}
-
-static int
-ppc_read_ivar(device_t bus, device_t dev, int index, uintptr_t *val)
-{
- struct ppc_data *ppc = (struct ppc_data *)device_get_softc(bus);
-
- switch (index) {
- case PPC_IVAR_EPP_PROTO:
- *val = (u_long)ppc->ppc_epp;
- break;
- case PPC_IVAR_IRQ:
- *val = (u_long)ppc->ppc_irq;
- break;
- default:
- return (ENOENT);
- }
-
- return (0);
-}
-
-/*
- * Resource is useless here since ppbus devices' interrupt handlers are
- * multiplexed to the same resource initially allocated by ppc
- */
-static int
-ppc_setup_intr(device_t bus, device_t child, struct resource *r, int flags,
- void (*ihand)(void *), void *arg, void **cookiep)
-{
- int error;
- struct ppc_data *ppc = DEVTOSOFTC(bus);
-
- if (ppc->ppc_registered) {
- /* XXX refuse registration if DMA is in progress */
-
- /* first, unregister the default interrupt handler */
- if ((error = BUS_TEARDOWN_INTR(device_get_parent(bus),
- bus, ppc->res_irq, ppc->intr_cookie)))
- return (error);
-
-/* bus_deactivate_resource(bus, SYS_RES_IRQ, ppc->rid_irq, */
-/* ppc->res_irq); */
-
- /* DMA/FIFO operation won't be possible anymore */
- ppc->ppc_registered = 0;
- }
-
- /* pass registration to the upper layer, ignore the incoming resource */
- return (BUS_SETUP_INTR(device_get_parent(bus), child,
- r, flags, ihand, arg, cookiep));
-}
-
-/*
- * When no underlying device has a registered interrupt, register the ppc
- * layer one
- */
-static int
-ppc_teardown_intr(device_t bus, device_t child, struct resource *r, void *ih)
-{
- int error;
- struct ppc_data *ppc = DEVTOSOFTC(bus);
- device_t parent = device_get_parent(bus);
-
- /* pass unregistration to the upper layer */
- if ((error = BUS_TEARDOWN_INTR(parent, child, r, ih)))
- return (error);
-
- /* default to the tty mask for registration */ /* XXX */
- if (ppc->ppc_irq &&
- !(error = BUS_SETUP_INTR(parent, bus, ppc->res_irq,
- INTR_TYPE_TTY, ppcintr, bus, &ppc->intr_cookie))) {
-
- /* remember the ppcintr is registered */
- ppc->ppc_registered = 1;
- }
-
- return (error);
-}
-
-DRIVER_MODULE(ppc, isa, ppc_driver, ppc_devclass, 0, 0);
diff --git a/sys/pc98/cbus/ppcreg.h b/sys/pc98/cbus/ppcreg.h
deleted file mode 100644
index 96e93b7f5ba5..000000000000
--- a/sys/pc98/cbus/ppcreg.h
+++ /dev/null
@@ -1,246 +0,0 @@
-/*-
- * Copyright (c) 1997 Nicolas Souchu
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- *
- */
-#ifndef __PPCREG_H
-#define __PPCREG_H
-
-/*
- * Parallel Port Chipset type.
- */
-#define SMC_LIKE 0
-#define SMC_37C665GT 1
-#define SMC_37C666GT 2
-#define NS_PC87332 3
-#define NS_PC87306 4
-#define INTEL_820191AA 5 /* XXX not implemented */
-#define GENERIC 6
-#define WINB_W83877F 7
-#define WINB_W83877AF 8
-#define WINB_UNKNOWN 9
-#define NS_PC87334 10
-
-/*
- * Parallel Port Chipset Type. SMC versus GENERIC (others)
- */
-#define PPC_TYPE_SMCLIKE 0
-#define PPC_TYPE_GENERIC 1
-
-/*
- * Generic structure to hold parallel port chipset info.
- */
-struct ppc_data {
-
- int ppc_unit;
- int ppc_model; /* chipset model if detected */
- int ppc_type; /* generic or smclike chipset type */
-
- int ppc_mode; /* chipset current mode */
- int ppc_avm; /* chipset available modes */
-
-#define PPC_IRQ_NONE 0x0
-#define PPC_IRQ_nACK 0x1
-#define PPC_IRQ_DMA 0x2
-#define PPC_IRQ_FIFO 0x4
-#define PPC_IRQ_nFAULT 0x8
- int ppc_irqstat; /* remind irq settings */
-
-#define PPC_DMA_INIT 0x01
-#define PPC_DMA_STARTED 0x02
-#define PPC_DMA_COMPLETE 0x03
-#define PPC_DMA_INTERRUPTED 0x04
-#define PPC_DMA_ERROR 0x05
- int ppc_dmastat; /* dma state */
- int ppc_dmachan; /* dma channel */
- int ppc_dmaflags; /* dma transfer flags */
- caddr_t ppc_dmaddr; /* buffer address */
- u_int ppc_dmacnt; /* count of bytes sent with dma */
-
-#define PPC_PWORD_MASK 0x30
-#define PPC_PWORD_16 0x00
-#define PPC_PWORD_8 0x10
-#define PPC_PWORD_32 0x20
- char ppc_pword; /* PWord size */
- short ppc_fifo; /* FIFO threshold */
-
- short ppc_wthr; /* writeIntrThresold */
- short ppc_rthr; /* readIntrThresold */
-
- char *ppc_ptr; /* microseq current pointer */
- int ppc_accum; /* microseq accumulator */
- int ppc_base; /* parallel port base address */
- int ppc_epp; /* EPP mode (1.7 or 1.9) */
- int ppc_irq;
-
- unsigned char ppc_flags;
-
- device_t ppbus; /* parallel port chipset corresponding ppbus */
-
- int rid_irq, rid_drq, rid_ioport;
- struct resource *res_irq, *res_drq, *res_ioport;
-
- void *intr_cookie;
-
- int ppc_registered; /* 1 if ppcintr() is the registered interrupt */
-};
-
-/*
- * Parallel Port Chipset registers.
- */
-#define PPC_SPP_DTR 0 /* SPP data register */
-#define PPC_ECP_A_FIFO 0 /* ECP Address fifo register */
-#define PPC_SPP_STR 1 /* SPP status register */
-#define PPC_SPP_CTR 2 /* SPP control register */
-#define PPC_EPP_ADDR 3 /* EPP address register (8 bit) */
-#define PPC_EPP_DATA 4 /* EPP data register (8, 16 or 32 bit) */
-#ifdef PC98
-#define PPC_1284_ENABLE 0x09 /* IEEE STD 1284 Enable register */
-#define PPC_ECP_D_FIFO 0x0c /* ECP Data fifo register */
-#define PPC_ECP_CNFGA 0x0c /* Configuration register A */
-#define PPC_ECP_CNFGB 0x0d /* Configuration register B */
-#define PPC_ECP_ECR 0x0e /* ECP extended control register */
-#else
-#define PPC_ECP_D_FIFO 0x400 /* ECP Data fifo register */
-#define PPC_ECP_CNFGA 0x400 /* Configuration register A */
-#define PPC_ECP_CNFGB 0x401 /* Configuration register B */
-#define PPC_ECP_ECR 0x402 /* ECP extended control register */
-#endif
-
-#define PPC_FIFO_EMPTY 0x1 /* ecr register - bit 0 */
-#define PPC_FIFO_FULL 0x2 /* ecr register - bit 1 */
-#define PPC_SERVICE_INTR 0x4 /* ecr register - bit 2 */
-#define PPC_ENABLE_DMA 0x8 /* ecr register - bit 3 */
-#define PPC_nFAULT_INTR 0x10 /* ecr register - bit 4 */
-#define PPC_ECR_STD 0x0
-#define PPC_ECR_PS2 0x20
-#define PPC_ECR_FIFO 0x40
-#define PPC_ECR_ECP 0x60
-#define PPC_ECR_EPP 0x80
-
-#define PPC_DISABLE_INTR (PPC_SERVICE_INTR | PPC_nFAULT_INTR)
-#define PPC_ECR_RESET (PPC_ECR_PS2 | PPC_DISABLE_INTR)
-
-#define r_dtr(ppc) (inb((ppc)->ppc_base + PPC_SPP_DTR))
-#define r_str(ppc) (inb((ppc)->ppc_base + PPC_SPP_STR))
-#define r_ctr(ppc) (inb((ppc)->ppc_base + PPC_SPP_CTR))
-#define r_epp_A(ppc) (inb((ppc)->ppc_base + PPC_EPP_ADDR))
-#define r_epp_D(ppc) (inb((ppc)->ppc_base + PPC_EPP_DATA))
-#define r_cnfgA(ppc) (inb((ppc)->ppc_base + PPC_ECP_CNFGA))
-#define r_cnfgB(ppc) (inb((ppc)->ppc_base + PPC_ECP_CNFGB))
-#define r_ecr(ppc) (inb((ppc)->ppc_base + PPC_ECP_ECR))
-#define r_fifo(ppc) (inb((ppc)->ppc_base + PPC_ECP_D_FIFO))
-
-#define w_dtr(ppc,byte) outb((ppc)->ppc_base + PPC_SPP_DTR, byte)
-#define w_str(ppc,byte) outb((ppc)->ppc_base + PPC_SPP_STR, byte)
-#define w_ctr(ppc,byte) outb((ppc)->ppc_base + PPC_SPP_CTR, byte)
-#define w_epp_A(ppc,byte) outb((ppc)->ppc_base + PPC_EPP_ADDR, byte)
-#define w_epp_D(ppc,byte) outb((ppc)->ppc_base + PPC_EPP_DATA, byte)
-#define w_ecr(ppc,byte) outb((ppc)->ppc_base + PPC_ECP_ECR, byte)
-#define w_fifo(ppc,byte) outb((ppc)->ppc_base + PPC_ECP_D_FIFO, byte)
-
-/*
- * Register defines for the PC873xx parts
- */
-
-#define PC873_FER 0x00
-#define PC873_PPENABLE (1<<0)
-#define PC873_FAR 0x01
-#define PC873_PTR 0x02
-#define PC873_CFGLOCK (1<<6)
-#define PC873_EPPRDIR (1<<7)
-#define PC873_EXTENDED (1<<7)
-#define PC873_LPTBIRQ7 (1<<3)
-#define PC873_FCR 0x03
-#define PC873_ZWS (1<<5)
-#define PC873_ZWSPWDN (1<<6)
-#define PC873_PCR 0x04
-#define PC873_EPPEN (1<<0)
-#define PC873_EPP19 (1<<1)
-#define PC873_ECPEN (1<<2)
-#define PC873_ECPCLK (1<<3)
-#define PC873_PMC 0x06
-#define PC873_TUP 0x07
-#define PC873_SID 0x08
-#define PC873_PNP0 0x1b
-#define PC873_PNP1 0x1c
-#define PC873_LPTBA 0x19
-
-/*
- * Register defines for the SMC FDC37C66xGT parts
- */
-
-/* Init codes */
-#define SMC665_iCODE 0x55
-#define SMC666_iCODE 0x44
-
-/* Base configuration ports */
-#define SMC66x_CSR 0x3F0
-#define SMC666_CSR 0x370 /* hard-configured value for 666 */
-
-/* Bits */
-#define SMC_CR1_ADDR 0x3 /* bit 0 and 1 */
-#define SMC_CR1_MODE (1<<3) /* bit 3 */
-#define SMC_CR4_EMODE 0x3 /* bits 0 and 1 */
-#define SMC_CR4_EPPTYPE (1<<6) /* bit 6 */
-
-/* Extended modes */
-#define SMC_SPP 0x0 /* SPP */
-#define SMC_EPPSPP 0x1 /* EPP and SPP */
-#define SMC_ECP 0x2 /* ECP */
-#define SMC_ECPEPP 0x3 /* ECP and EPP */
-
-/*
- * Register defines for the Winbond W83877F parts
- */
-
-#define WINB_W83877F_ID 0xa
-#define WINB_W83877AF_ID 0xb
-
-/* Configuration bits */
-#define WINB_HEFERE (1<<5) /* CROC bit 5 */
-#define WINB_HEFRAS (1<<0) /* CR16 bit 0 */
-
-#define WINB_PNPCVS (1<<2) /* CR16 bit 2 */
-#define WINB_CHIPID 0xf /* CR9 bits 0-3 */
-
-#define WINB_PRTMODS0 (1<<2) /* CR0 bit 2 */
-#define WINB_PRTMODS1 (1<<3) /* CR0 bit 3 */
-#define WINB_PRTMODS2 (1<<7) /* CR9 bit 7 */
-
-/* W83877F modes: CR9/bit7 | CR0/bit3 | CR0/bit2 */
-#define WINB_W83757 0x0
-#define WINB_EXTFDC 0x4
-#define WINB_EXTADP 0x8
-#define WINB_EXT2FDD 0xc
-#define WINB_JOYSTICK 0x80
-
-#define WINB_PARALLEL 0x80
-#define WINB_EPP_SPP 0x4
-#define WINB_ECP 0x8
-#define WINB_ECP_EPP 0xc
-
-#endif
diff --git a/sys/pc98/cbus/sc_machdep.h b/sys/pc98/cbus/sc_machdep.h
deleted file mode 100644
index 038f018f6840..000000000000
--- a/sys/pc98/cbus/sc_machdep.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*-
- * Copyright (c) 1999 FreeBSD(98) Porting Team.
- * 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 as
- * the first lines of this file unmodified.
- * 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 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _PC98_PC98_SC_MACHDEP_H_
-#define _PC98_PC98_SC_MACHDEP_H_
-
-#undef SC_ALT_MOUSE_IMAGE
-#undef SC_DFLT_FONT
-#undef SC_MOUSE_CHAR
-#undef SC_PIXEL_MODE
-#undef SC_NO_FONT_LOADING
-#define SC_NO_FONT_LOADING 1
-#undef SC_NO_PALETTE_LOADING
-#define SC_NO_PALETTE_LOADING 1
-
-#ifndef SC_KERNEL_CONS_ATTR
-#define SC_KERNEL_CONS_ATTR (FG_LIGHTGREY | BG_BLACK)
-#endif
-
-#define KANJI 1
-
-#define BELL_DURATION 5
-#define BELL_PITCH_8M 1339
-#define BELL_PITCH_5M 1678
-
-#define UJIS 0
-#define SJIS 1
-
-#define PRINTABLE(c) ((c) > 0x1b || ((c) > 0x0f && (c) < 0x1b) \
- || (c) < 0x07)
-
-#define ISMOUSEAVAIL(af) (1)
-#define ISFONTAVAIL(af) ((af) & V_ADP_FONT)
-#define ISPALAVAIL(af) ((af) & V_ADP_PALETTE)
-
-#endif /* !_PC98_PC98_SC_MACHDEP_H_ */
diff --git a/sys/pc98/cbus/scgdcrndr.c b/sys/pc98/cbus/scgdcrndr.c
deleted file mode 100644
index 22a6d5d672c0..000000000000
--- a/sys/pc98/cbus/scgdcrndr.c
+++ /dev/null
@@ -1,203 +0,0 @@
-/*-
- * Copyright (c) 1999 FreeBSD(98) Porting Team.
- * 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 as
- * the first lines of this file unmodified.
- * 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 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.
- *
- * $FreeBSD$
- */
-
-#include "sc.h"
-#include "gdc.h"
-#include "opt_syscons.h"
-#include "opt_gdc.h"
-
-#if NSC > 0 && NGDC > 0
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-
-#include <machine/console.h>
-
-#include <dev/fb/fbreg.h>
-#include <dev/syscons/syscons.h>
-
-#ifndef SC_RENDER_DEBUG
-#define SC_RENDER_DEBUG 0
-#endif
-
-static vr_clear_t gdc_txtclear;
-static vr_draw_border_t gdc_txtborder;
-static vr_draw_t gdc_txtdraw;
-static vr_set_cursor_t gdc_txtcursor_shape;
-static vr_draw_cursor_t gdc_txtcursor;
-#ifndef SC_NO_CUTPASTE
-static vr_draw_mouse_t gdc_txtmouse;
-#else
-#define gdc_txtmouse (vr_draw_mouse_t *)gdc_nop
-#endif
-
-#ifndef SC_NO_MODE_CHANGE
-static vr_draw_border_t gdc_grborder;
-#endif
-
-static void gdc_nop(scr_stat *scp, ...);
-
-static struct linker_set gdc_set;
-
-static sc_rndr_sw_t txtrndrsw = {
- gdc_txtclear,
- gdc_txtborder,
- gdc_txtdraw,
- gdc_txtcursor_shape,
- gdc_txtcursor,
- (vr_blink_cursor_t *)gdc_nop,
- (vr_set_mouse_t *)gdc_nop,
- gdc_txtmouse,
-};
-RENDERER(gdc, 0, txtrndrsw, gdc_set);
-
-#ifndef SC_NO_MODE_CHANGE
-static sc_rndr_sw_t grrndrsw = {
- (vr_clear_t *)gdc_nop,
- gdc_grborder,
- (vr_draw_t *)gdc_nop,
- (vr_set_cursor_t *)gdc_nop,
- (vr_draw_cursor_t *)gdc_nop,
- (vr_blink_cursor_t *)gdc_nop,
- (vr_set_mouse_t *)gdc_nop,
- (vr_draw_mouse_t *)gdc_nop,
-};
-RENDERER(gdc, GRAPHICS_MODE, grrndrsw, gdc_set);
-#endif /* SC_NO_MODE_CHANGE */
-
-RENDERER_MODULE(gdc, gdc_set);
-
-static void
-gdc_nop(scr_stat *scp, ...)
-{
-}
-
-/* text mode renderer */
-
-static void
-gdc_txtclear(scr_stat *scp, int c, int attr)
-{
- sc_vtb_clear(&scp->scr, c, attr);
-}
-
-static void
-gdc_txtborder(scr_stat *scp, int color)
-{
- (*vidsw[scp->sc->adapter]->set_border)(scp->sc->adp, color);
-}
-
-static void
-gdc_txtdraw(scr_stat *scp, int from, int count, int flip)
-{
- vm_offset_t p;
- int c;
- int a;
-
- if (from + count > scp->xsize*scp->ysize)
- count = scp->xsize*scp->ysize - from;
-
- if (flip) {
- p = sc_vtb_pointer(&scp->scr, from);
- for (; count-- > 0; ++from) {
- c = sc_vtb_getc(&scp->vtb, from);
- a = sc_vtb_geta(&scp->vtb, from) ^ 0x4;
- sc_vtb_putchar(&scp->scr, p, c, a);
- }
- } else {
- sc_vtb_copy(&scp->vtb, from, &scp->scr, from, count);
- }
-}
-
-static void
-gdc_txtcursor_shape(scr_stat *scp, int base, int height, int blink)
-{
- if (base < 0 || base >= scp->font_size)
- return;
- /* the caller may set height <= 0 in order to disable the cursor */
- (*vidsw[scp->sc->adapter]->set_hw_cursor_shape)(scp->sc->adp,
- base, height,
- scp->font_size, blink);
-}
-
-static void
-gdc_txtcursor(scr_stat *scp, int at, int blink, int on, int flip)
-{
- if (on) {
- scp->status |= VR_CURSOR_ON;
- (*vidsw[scp->sc->adapter]->set_hw_cursor)(scp->sc->adp,
- at%scp->xsize, at/scp->xsize);
- } else {
- if (scp->status & VR_CURSOR_ON)
- (*vidsw[scp->sc->adapter]->set_hw_cursor)(scp->sc->adp,
- -1, -1);
- scp->status &= ~VR_CURSOR_ON;
- }
-}
-
-#ifndef SC_NO_CUTPASTE
-
-static void
-draw_txtmouse(scr_stat *scp, int x, int y)
-{
- int at;
-
- at = (y/scp->font_size - scp->yoff)*scp->xsize + x/8 - scp->xoff;
- sc_vtb_putc(&scp->scr, at,
- sc_vtb_getc(&scp->scr, at),
- sc_vtb_geta(&scp->scr, at) ^ 0x4);
-}
-
-static void
-remove_txtmouse(scr_stat *scp, int x, int y)
-{
-}
-
-static void
-gdc_txtmouse(scr_stat *scp, int x, int y, int on)
-{
- if (on)
- draw_txtmouse(scp, x, y);
- else
- remove_txtmouse(scp, x, y);
-}
-
-#endif /* SC_NO_CUTPASTE */
-
-#ifndef SC_NO_MODE_CHANGE
-
-/* graphics mode renderer */
-
-static void
-gdc_grborder(scr_stat *scp, int color)
-{
- (*vidsw[scp->sc->adapter]->set_border)(scp->sc->adp, color);
-}
-
-#endif /* SC_NO_MODE_CHANGE */
-
-#endif /* NSC > 0 && NGDC > 0 */
diff --git a/sys/pc98/cbus/scterm-sck.c b/sys/pc98/cbus/scterm-sck.c
deleted file mode 100644
index f00250b0cd67..000000000000
--- a/sys/pc98/cbus/scterm-sck.c
+++ /dev/null
@@ -1,1095 +0,0 @@
-/*-
- * Copyright (c) 1999 FreeBSD(98) Porting Team.
- * 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 as
- * the first lines of this file unmodified.
- * 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 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.
- *
- * $FreeBSD$
- */
-
-#include "sc.h"
-#include "opt_syscons.h"
-
-#if NSC > 0
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/consio.h>
-
-#include <machine/pc/display.h>
-
-#include <dev/syscons/syscons.h>
-#include <dev/syscons/sctermvar.h>
-
-#ifndef SC_DUMB_TERMINAL
-
-#define MAX_ESC_PAR 5
-
-#ifdef KANJI
-#define IS_KTYPE_ASCII_or_HANKAKU(A) (!((A) & 0xee))
-#define IS_KTYPE_KANA(A) ((A) & 0x11)
-#define KTYPE_MASK_CTRL(A) ((A) &= 0xF0)
-#endif /* KANJI */
-
-/* attribute flags */
-typedef struct {
- u_short fg; /* foreground color */
- u_short bg; /* background color */
-} color_t;
-
-typedef struct {
- int flags;
-#define SCTERM_BUSY (1 << 0)
- int esc;
- int num_param;
- int last_param;
- int param[MAX_ESC_PAR];
- int saved_xpos;
- int saved_ypos;
-
-#ifdef KANJI
- u_char kanji_1st_char;
- u_char kanji_type;
-#define KTYPE_ASCII 0 /* ASCII */
-#define KTYPE_KANA 1 /* HANKAKU */
-#define KTYPE_JKANA 0x10 /* JIS HANKAKU */
-#define KTYPE_7JIS 0x20 /* JIS */
-#define KTYPE_SJIS 2 /* Shift JIS */
-#define KTYPE_UJIS 4 /* UJIS */
-#define KTYPE_SUKANA 3 /* Shift JIS or UJIS HANKAKU */
-#define KTYPE_SUJIS 6 /* SHift JIS or UJIS */
-#define KTYPE_KANIN 0x80 /* Kanji Invoke sequence */
-#define KTYPE_ASCIN 0x40 /* ASCII Invoke sequence */
-#endif /* KANJI */
-
- int attr_mask; /* current logical attr mask */
-#define NORMAL_ATTR 0x00
-#define BLINK_ATTR 0x01
-#define BOLD_ATTR 0x02
-#define UNDERLINE_ATTR 0x04
-#define REVERSE_ATTR 0x08
-#define FG_CHANGED 0x10
-#define BG_CHANGED 0x20
- int cur_attr; /* current hardware attr word */
- color_t cur_color; /* current hardware color */
- color_t std_color; /* normal hardware color */
- color_t rev_color; /* reverse hardware color */
- color_t dflt_std_color; /* default normal color */
- color_t dflt_rev_color; /* default reverse color */
-} term_stat;
-
-static sc_term_init_t scterm_init;
-static sc_term_term_t scterm_term;
-static sc_term_puts_t scterm_puts;
-static sc_term_ioctl_t scterm_ioctl;
-static sc_term_reset_t scterm_reset;
-static sc_term_default_attr_t scterm_default_attr;
-static sc_term_clear_t scterm_clear;
-static sc_term_notify_t scterm_notify;
-static sc_term_input_t scterm_input;
-
-static sc_term_sw_t sc_term_sc = {
- { NULL, NULL },
- "sck", /* emulator name */
- "syscons kanji terminal", /* description */
- "*", /* matching renderer, any :-) */
- sizeof(term_stat), /* softc size */
- 0,
- scterm_init,
- scterm_term,
- scterm_puts,
- scterm_ioctl,
- scterm_reset,
- scterm_default_attr,
- scterm_clear,
- scterm_notify,
- scterm_input,
-};
-
-SCTERM_MODULE(sc, sc_term_sc);
-
-static term_stat reserved_term_stat;
-static int default_kanji = UJIS;
-static void scterm_scan_esc(scr_stat *scp, term_stat *tcp,
- u_char c);
-static int mask2attr(term_stat *tcp);
-static u_char iskanji1(u_char mode, u_char c);
-static u_char iskanji2(u_char mode, u_char c);
-static u_short kanji_convert(u_char mode, u_char h, u_char l);
-
-static int
-scterm_init(scr_stat *scp, void **softc, int code)
-{
- term_stat *tcp;
-
- if (*softc == NULL) {
- if (reserved_term_stat.flags & SCTERM_BUSY)
- return EINVAL;
- *softc = &reserved_term_stat;
- }
- tcp = *softc;
-
- switch (code) {
- case SC_TE_COLD_INIT:
- bzero(tcp, sizeof(*tcp));
- tcp->flags = SCTERM_BUSY;
- tcp->esc = 0;
- tcp->saved_xpos = -1;
- tcp->saved_ypos = -1;
-
-#ifdef KANJI
- tcp->kanji_1st_char = 0;
- tcp->kanji_type = KTYPE_ASCII;
-#endif
-
- tcp->attr_mask = NORMAL_ATTR;
- /* XXX */
- tcp->dflt_std_color.fg = SC_NORM_ATTR & 0x0f;
- tcp->dflt_std_color.bg = (SC_NORM_ATTR >> 4) & 0x0f;
- tcp->dflt_rev_color.fg = SC_NORM_REV_ATTR & 0x0f;
- tcp->dflt_rev_color.bg = (SC_NORM_REV_ATTR >> 4) & 0x0f;
- tcp->std_color = tcp->dflt_std_color;
- tcp->rev_color = tcp->dflt_rev_color;
- tcp->cur_color = tcp->std_color;
- tcp->cur_attr = mask2attr(tcp);
- ++sc_term_sc.te_refcount;
- break;
-
- case SC_TE_WARM_INIT:
- tcp->esc = 0;
- tcp->saved_xpos = -1;
- tcp->saved_ypos = -1;
-#if 0
- tcp->std_color = tcp->dflt_std_color;
- tcp->rev_color = tcp->dflt_rev_color;
-#endif
- tcp->cur_color = tcp->std_color;
- tcp->cur_attr = mask2attr(tcp);
- break;
- }
-
- return 0;
-}
-
-static int
-scterm_term(scr_stat *scp, void **softc)
-{
- if (*softc == &reserved_term_stat) {
- *softc = NULL;
- bzero(&reserved_term_stat, sizeof(reserved_term_stat));
- }
- --sc_term_sc.te_refcount;
- return 0;
-}
-
-static void
-scterm_scan_esc(scr_stat *scp, term_stat *tcp, u_char c)
-{
- static u_char ansi_col[16] = {
- FG_BLACK, FG_RED, FG_GREEN, FG_BROWN,
- FG_BLUE, FG_MAGENTA, FG_CYAN, FG_LIGHTGREY,
- FG_DARKGREY, FG_LIGHTRED, FG_LIGHTGREEN, FG_YELLOW,
- FG_LIGHTBLUE, FG_LIGHTMAGENTA, FG_LIGHTCYAN, FG_WHITE
- };
- sc_softc_t *sc;
- int i, n;
-
- i = n = 0;
- sc = scp->sc;
- if (tcp->esc == 1) { /* seen ESC */
- switch (c) {
-
- case '7': /* Save cursor position */
- tcp->saved_xpos = scp->xpos;
- tcp->saved_ypos = scp->ypos;
- break;
-
- case '8': /* Restore saved cursor position */
- if (tcp->saved_xpos >= 0 && tcp->saved_ypos >= 0)
- sc_move_cursor(scp, tcp->saved_xpos, tcp->saved_ypos);
- break;
-
- case '[': /* Start ESC [ sequence */
- tcp->esc = 2;
- tcp->last_param = -1;
- for (i = tcp->num_param; i < MAX_ESC_PAR; i++)
- tcp->param[i] = 1;
- tcp->num_param = 0;
- return;
-
-#ifdef KANJI
- case '$': /* Kanji Invoke sequence */
- tcp->kanji_type = KTYPE_KANIN;
- return;
-#endif
-
- case 'M': /* Move cursor up 1 line, scroll if at top */
- sc_term_up_scroll(scp, 1, sc->scr_map[0x20], tcp->cur_attr, 0, 0);
- break;
-#if notyet
- case 'Q':
- tcp->esc = 4;
- return;
-#endif
- case 'c': /* Clear screen & home */
- sc_clear_screen(scp);
- break;
-
- case '(': /* iso-2022: designate 94 character set to G0 */
-#ifdef KANJI
- tcp->kanji_type = KTYPE_ASCIN;
-#else
- tcp->esc = 5;
-#endif
- return;
- }
- }
- else if (tcp->esc == 2) { /* seen ESC [ */
- if (c >= '0' && c <= '9') {
- if (tcp->num_param < MAX_ESC_PAR) {
- if (tcp->last_param != tcp->num_param) {
- tcp->last_param = tcp->num_param;
- tcp->param[tcp->num_param] = 0;
- } else {
- tcp->param[tcp->num_param] *= 10;
- }
- tcp->param[tcp->num_param] += c - '0';
- return;
- }
- }
- tcp->num_param = tcp->last_param + 1;
- switch (c) {
-
- case ';':
- if (tcp->num_param < MAX_ESC_PAR)
- return;
- break;
-
- case '=':
- tcp->esc = 3;
- tcp->last_param = -1;
- for (i = tcp->num_param; i < MAX_ESC_PAR; i++)
- tcp->param[i] = 1;
- tcp->num_param = 0;
- return;
-
- case 'A': /* up n rows */
- sc_term_up(scp, tcp->param[0], 0);
- break;
-
- case 'B': /* down n rows */
- sc_term_down(scp, tcp->param[0], 0);
- break;
-
- case 'C': /* right n columns */
- sc_term_right(scp, tcp->param[0]);
- break;
-
- case 'D': /* left n columns */
- sc_term_left(scp, tcp->param[0]);
- break;
-
- case 'E': /* cursor to start of line n lines down */
- n = tcp->param[0]; if (n < 1) n = 1;
- sc_move_cursor(scp, 0, scp->ypos + n);
- break;
-
- case 'F': /* cursor to start of line n lines up */
- n = tcp->param[0]; if (n < 1) n = 1;
- sc_move_cursor(scp, 0, scp->ypos - n);
- break;
-
- case 'f': /* Cursor move */
- case 'H':
- if (tcp->num_param == 0)
- sc_move_cursor(scp, 0, 0);
- else if (tcp->num_param == 2)
- sc_move_cursor(scp, tcp->param[1] - 1, tcp->param[0] - 1);
- break;
-
- case 'J': /* Clear all or part of display */
- if (tcp->num_param == 0)
- n = 0;
- else
- n = tcp->param[0];
- sc_term_clr_eos(scp, n, sc->scr_map[0x20], tcp->cur_attr);
- break;
-
- case 'K': /* Clear all or part of line */
- if (tcp->num_param == 0)
- n = 0;
- else
- n = tcp->param[0];
- sc_term_clr_eol(scp, n, sc->scr_map[0x20], tcp->cur_attr);
- break;
-
- case 'L': /* Insert n lines */
- sc_term_ins_line(scp, scp->ypos, tcp->param[0],
- sc->scr_map[0x20], tcp->cur_attr, 0);
- break;
-
- case 'M': /* Delete n lines */
- sc_term_del_line(scp, scp->ypos, tcp->param[0],
- sc->scr_map[0x20], tcp->cur_attr, 0);
- break;
-
- case 'P': /* Delete n chars */
- sc_term_del_char(scp, tcp->param[0],
- sc->scr_map[0x20], tcp->cur_attr);
- break;
-
- case '@': /* Insert n chars */
- sc_term_ins_char(scp, tcp->param[0],
- sc->scr_map[0x20], tcp->cur_attr);
- break;
-
- case 'S': /* scroll up n lines */
- sc_term_del_line(scp, 0, tcp->param[0],
- sc->scr_map[0x20], tcp->cur_attr, 0);
- break;
-
- case 'T': /* scroll down n lines */
- sc_term_ins_line(scp, 0, tcp->param[0],
- sc->scr_map[0x20], tcp->cur_attr, 0);
- break;
-
- case 'X': /* erase n characters in line */
- n = tcp->param[0]; if (n < 1) n = 1;
- if (n > scp->xsize - scp->xpos)
- n = scp->xsize - scp->xpos;
- sc_vtb_erase(&scp->vtb, scp->cursor_pos, n,
- sc->scr_map[0x20], tcp->cur_attr);
- mark_for_update(scp, scp->cursor_pos);
- mark_for_update(scp, scp->cursor_pos + n - 1);
- break;
-
- case 'Z': /* move n tabs backwards */
- sc_term_backtab(scp, tcp->param[0]);
- break;
-
- case '`': /* move cursor to column n */
- sc_term_col(scp, tcp->param[0]);
- break;
-
- case 'a': /* move cursor n columns to the right */
- sc_term_right(scp, tcp->param[0]);
- break;
-
- case 'd': /* move cursor to row n */
- sc_term_row(scp, tcp->param[0]);
- break;
-
- case 'e': /* move cursor n rows down */
- sc_term_down(scp, tcp->param[0], 0);
- break;
-
- case 'm': /* change attribute */
- if (tcp->num_param == 0) {
- tcp->attr_mask = NORMAL_ATTR;
- tcp->cur_color = tcp->std_color;
- tcp->cur_attr = mask2attr(tcp);
- break;
- }
- for (i = 0; i < tcp->num_param; i++) {
- switch (n = tcp->param[i]) {
- case 0: /* back to normal */
- tcp->attr_mask = NORMAL_ATTR;
- tcp->cur_color = tcp->std_color;
- tcp->cur_attr = mask2attr(tcp);
- break;
- case 1: /* bold */
- tcp->attr_mask |= BOLD_ATTR;
- tcp->cur_attr = mask2attr(tcp);
- break;
- case 4: /* underline */
- tcp->attr_mask |= UNDERLINE_ATTR;
- tcp->cur_attr = mask2attr(tcp);
- break;
- case 5: /* blink */
- tcp->attr_mask |= BLINK_ATTR;
- tcp->cur_attr = mask2attr(tcp);
- break;
- case 7: /* reverse video */
- tcp->attr_mask |= REVERSE_ATTR;
- tcp->cur_attr = mask2attr(tcp);
- break;
- case 30: case 31: /* set fg color */
- case 32: case 33: case 34:
- case 35: case 36: case 37:
- tcp->attr_mask |= FG_CHANGED;
- tcp->cur_color.fg = ansi_col[n - 30];
- tcp->cur_attr = mask2attr(tcp);
- break;
- case 40: case 41: /* set bg color */
- case 42: case 43: case 44:
- case 45: case 46: case 47:
- tcp->attr_mask |= BG_CHANGED;
- tcp->cur_color.bg = ansi_col[n - 40];
- tcp->cur_attr = mask2attr(tcp);
- break;
- }
- }
- break;
-
- case 's': /* Save cursor position */
- tcp->saved_xpos = scp->xpos;
- tcp->saved_ypos = scp->ypos;
- break;
-
- case 'u': /* Restore saved cursor position */
- if (tcp->saved_xpos >= 0 && tcp->saved_ypos >= 0)
- sc_move_cursor(scp, tcp->saved_xpos, tcp->saved_ypos);
- break;
-
- case 'x':
- if (tcp->num_param == 0)
- n = 0;
- else
- n = tcp->param[0];
- switch (n) {
- case 0: /* reset attributes */
- tcp->attr_mask = NORMAL_ATTR;
- tcp->cur_color = tcp->std_color = tcp->dflt_std_color;
- tcp->rev_color = tcp->dflt_rev_color;
- tcp->cur_attr = mask2attr(tcp);
- break;
- case 1: /* set ansi background */
- tcp->attr_mask &= ~BG_CHANGED;
- tcp->cur_color.bg = tcp->std_color.bg =
- ansi_col[tcp->param[1] & 0x0f];
- tcp->cur_attr = mask2attr(tcp);
- break;
- case 2: /* set ansi foreground */
- tcp->attr_mask &= ~FG_CHANGED;
- tcp->cur_color.fg = tcp->std_color.fg =
- ansi_col[tcp->param[1] & 0x0f];
- tcp->cur_attr = mask2attr(tcp);
- break;
- case 3: /* set ansi attribute directly */
- tcp->attr_mask &= ~(FG_CHANGED | BG_CHANGED);
- tcp->cur_color.fg = tcp->std_color.fg =
- tcp->param[1] & 0x0f;
- tcp->cur_color.bg = tcp->std_color.bg =
- (tcp->param[1] >> 4) & 0x0f;
- tcp->cur_attr = mask2attr(tcp);
- break;
- case 5: /* set ansi reverse video background */
- tcp->rev_color.bg = ansi_col[tcp->param[1] & 0x0f];
- tcp->cur_attr = mask2attr(tcp);
- break;
- case 6: /* set ansi reverse video foreground */
- tcp->rev_color.fg = ansi_col[tcp->param[1] & 0x0f];
- tcp->cur_attr = mask2attr(tcp);
- break;
- case 7: /* set ansi reverse video directly */
- tcp->rev_color.fg = tcp->param[1] & 0x0f;
- tcp->rev_color.bg = (tcp->param[1] >> 4) & 0x0f;
- tcp->cur_attr = mask2attr(tcp);
- break;
- }
- break;
-
- case 'z': /* switch to (virtual) console n */
- if (tcp->num_param == 1)
- sc_switch_scr(sc, tcp->param[0]);
- break;
- }
- }
- else if (tcp->esc == 3) { /* seen ESC [0-9]+ = */
- if (c >= '0' && c <= '9') {
- if (tcp->num_param < MAX_ESC_PAR) {
- if (tcp->last_param != tcp->num_param) {
- tcp->last_param = tcp->num_param;
- tcp->param[tcp->num_param] = 0;
- } else {
- tcp->param[tcp->num_param] *= 10;
- }
- tcp->param[tcp->num_param] += c - '0';
- return;
- }
- }
- tcp->num_param = tcp->last_param + 1;
- switch (c) {
-
- case ';':
- if (tcp->num_param < MAX_ESC_PAR)
- return;
- break;
-
- case 'A': /* set display border color */
- if (tcp->num_param == 1) {
- scp->border=tcp->param[0] & 0xff;
- if (scp == sc->cur_scp)
- sc_set_border(scp, scp->border);
- }
- break;
-
- case 'B': /* set bell pitch and duration */
- if (tcp->num_param == 2) {
- scp->bell_pitch = tcp->param[0];
- scp->bell_duration = tcp->param[1];
- }
- break;
-
- case 'C': /* set cursor type & shape */
- i = spltty();
- if (!ISGRAPHSC(sc->cur_scp))
- sc_remove_cursor_image(sc->cur_scp);
- if (tcp->num_param == 1) {
- if (tcp->param[0] & 0x01)
- sc->flags |= SC_BLINK_CURSOR;
- else
- sc->flags &= ~SC_BLINK_CURSOR;
- if (tcp->param[0] & 0x02)
- sc->flags |= SC_CHAR_CURSOR;
- else
- sc->flags &= ~SC_CHAR_CURSOR;
- } else if (tcp->num_param == 2) {
- sc->cursor_base = scp->font_size
- - (tcp->param[1] & 0x1F) - 1;
- sc->cursor_height = (tcp->param[1] & 0x1F)
- - (tcp->param[0] & 0x1F) + 1;
- }
- /*
- * The cursor shape is global property; all virtual consoles
- * are affected. Update the cursor in the current console...
- */
- if (!ISGRAPHSC(sc->cur_scp)) {
- sc_set_cursor_image(sc->cur_scp);
- sc_draw_cursor_image(sc->cur_scp);
- }
- splx(i);
- break;
-
- case 'F': /* set ansi foreground */
- if (tcp->num_param == 1) {
- tcp->attr_mask &= ~FG_CHANGED;
- tcp->cur_color.fg = tcp->std_color.fg = tcp->param[0] & 0x0f;
- tcp->cur_attr = mask2attr(tcp);
- }
- break;
-
- case 'G': /* set ansi background */
- if (tcp->num_param == 1) {
- tcp->attr_mask &= ~BG_CHANGED;
- tcp->cur_color.bg = tcp->std_color.bg = tcp->param[0] & 0x0f;
- tcp->cur_attr = mask2attr(tcp);
- }
- break;
-
- case 'H': /* set ansi reverse video foreground */
- if (tcp->num_param == 1) {
- tcp->rev_color.fg = tcp->param[0] & 0x0f;
- tcp->cur_attr = mask2attr(tcp);
- }
- break;
-
- case 'I': /* set ansi reverse video background */
- if (tcp->num_param == 1) {
- tcp->rev_color.bg = tcp->param[0] & 0x0f;
- tcp->cur_attr = mask2attr(tcp);
- }
- break;
- }
- }
-#if notyet
- else if (tcp->esc == 4) { /* seen ESC Q */
- /* to be filled */
- }
-#endif
- else if (tcp->esc == 5) { /* seen ESC ( */
- switch (c) {
- case 'B': /* iso-2022: desginate ASCII into G0 */
- break;
- /* other items to be filled */
- default:
- break;
- }
- }
- tcp->esc = 0;
-}
-
-static void
-scterm_puts(scr_stat *scp, u_char *buf, int len)
-{
- term_stat *tcp = scp->ts;
- u_char *ptr = buf;
-#ifdef KANJI
- u_short kanji_code;
-#endif
-
-outloop:
- scp->sc->write_in_progress++;
-
- if (tcp->esc) {
- scterm_scan_esc(scp, tcp, *ptr++);
- len--;
- }
- else if (PRINTABLE(*ptr)) { /* Print only printables */
- vm_offset_t p;
- u_char *map;
- int attr;
- int i;
-#ifdef KANJI
- u_char c;
-#else
- int cnt;
-#endif
-
- p = sc_vtb_pointer(&scp->vtb, scp->cursor_pos);
- map = scp->sc->scr_map;
- attr = tcp->cur_attr;
-
-#ifdef KANJI
- c = *ptr;
- if (tcp->kanji_1st_char == 0) {
- tcp->kanji_type = iskanji1(tcp->kanji_type, c);
- if (!IS_KTYPE_ASCII_or_HANKAKU(tcp->kanji_type)) {
- /* not Ascii & not HANKAKU */
- tcp->kanji_1st_char = c;
- goto kanji_end;
- } else {
- tcp->kanji_1st_char = 0;
- }
- } else {
- if ((tcp->kanji_type = iskanji2(tcp->kanji_type, c)) & 0xee) {
- /* print kanji on TEXT VRAM */
- kanji_code = kanji_convert(tcp->kanji_type, c, tcp->kanji_1st_char);
- mark_for_update(scp, scp->cursor_pos);
- for (i=0; i<2; i++){
- /* *cursor_pos = (kanji_code | (i*0x80)); */
- p = sc_vtb_putchar(&scp->vtb, p,
- kanji_code | ((i == 0) ? 0x00 : 0x80),
- attr);
- ++scp->cursor_pos;
- if (++scp->xpos >= scp->xsize) {
- scp->xpos = 0;
- scp->ypos++;
- }
- }
- mark_for_update(scp, scp->cursor_pos - 1);
- KTYPE_MASK_CTRL(tcp->kanji_type);
- tcp->kanji_1st_char = 0;
- goto kanji_end;
- } else {
- tcp->kanji_1st_char = 0;
- }
- }
- if (IS_KTYPE_KANA(tcp->kanji_type))
- c |= 0x80;
- KTYPE_MASK_CTRL(tcp->kanji_type);
- sc_vtb_putchar(&scp->vtb, p, map[c], attr);
- mark_for_update(scp, scp->cursor_pos);
- mark_for_update(scp, scp->cursor_pos);
- ++scp->cursor_pos;
- ++scp->xpos;
-kanji_end:
- ++ptr;
- --len;
-#else /* !KANJI */
- cnt = imin(len, scp->xsize - scp->xpos);
- i = cnt;
- do {
- /*
- * gcc-2.6.3 generates poor (un)sign extension code. Casting the
- * pointers in the following to volatile should have no effect,
- * but in fact speeds up this inner loop from 26 to 18 cycles
- * (+ cache misses) on i486's.
- */
-#define UCVP(ucp) ((u_char volatile *)(ucp))
- p = sc_vtb_putchar(&scp->vtb, p, UCVP(map)[*UCVP(ptr)], attr);
- ++ptr;
- --i;
- } while (i > 0 && PRINTABLE(*ptr));
-
- len -= cnt - i;
- mark_for_update(scp, scp->cursor_pos);
- scp->cursor_pos += cnt - i;
- mark_for_update(scp, scp->cursor_pos - 1);
- scp->xpos += cnt - i;
-#endif /* !KANJI */
-
- if (scp->xpos >= scp->xsize) {
- scp->xpos = 0;
- scp->ypos++;
- }
- }
- else {
- switch (*ptr) {
- case 0x07:
- sc_bell(scp, scp->bell_pitch, scp->bell_duration);
- break;
-
- case 0x08: /* non-destructive backspace */
- if (scp->cursor_pos > 0) {
- mark_for_update(scp, scp->cursor_pos);
- scp->cursor_pos--;
- mark_for_update(scp, scp->cursor_pos);
- if (scp->xpos > 0)
- scp->xpos--;
- else {
- scp->xpos += scp->xsize - 1;
- scp->ypos--;
- }
- }
- break;
-
- case 0x09: /* non-destructive tab */
- mark_for_update(scp, scp->cursor_pos);
- scp->cursor_pos += (8 - scp->xpos % 8u);
- scp->xpos += (8 - scp->xpos % 8u);
- if (scp->xpos >= scp->xsize) {
- scp->xpos = 0;
- scp->ypos++;
- scp->cursor_pos = scp->xsize * scp->ypos;
- }
- mark_for_update(scp, scp->cursor_pos);
- break;
-
- case 0x0a: /* newline, same pos */
- mark_for_update(scp, scp->cursor_pos);
- scp->cursor_pos += scp->xsize;
- mark_for_update(scp, scp->cursor_pos);
- scp->ypos++;
- break;
-
- case 0x0c: /* form feed, clears screen */
- sc_clear_screen(scp);
- break;
-
- case 0x0d: /* return, return to pos 0 */
- mark_for_update(scp, scp->cursor_pos);
- scp->cursor_pos -= scp->xpos;
- mark_for_update(scp, scp->cursor_pos);
- scp->xpos = 0;
- break;
-
-#ifdef PC98
- case 0x0e: /* ^N */
- tcp->kanji_type = KTYPE_JKANA;
- tcp->esc = 0;
- tcp->kanji_1st_char = 0;
- break;
-
- case 0x0f: /* ^O */
- tcp->kanji_type = KTYPE_ASCII;
- tcp->esc = 0;
- tcp->kanji_1st_char = 0;
- break;
-#endif /* PC98 */
-
- case 0x1b: /* start escape sequence */
- tcp->esc = 1;
- tcp->num_param = 0;
- break;
- }
- ptr++; len--;
- }
-
- sc_term_gen_scroll(scp, scp->sc->scr_map[0x20], tcp->cur_attr);
-
- scp->sc->write_in_progress--;
- if (len)
- goto outloop;
-}
-
-static int
-scterm_ioctl(scr_stat *scp, struct tty *tp, u_long cmd, caddr_t data,
- int flag, struct proc *p)
-{
- term_stat *tcp = scp->ts;
- vid_info_t *vi;
-
- switch (cmd) {
- case GIO_ATTR: /* get current attributes */
- /* FIXME: */
- *(int*)data = (tcp->cur_attr >> 8) & 0xff;
- return 0;
- case CONS_GETINFO: /* get current (virtual) console info */
- vi = (vid_info_t *)data;
- if (vi->size != sizeof(struct vid_info))
- return EINVAL;
- vi->mv_norm.fore = tcp->std_color.fg;
- vi->mv_norm.back = tcp->std_color.bg;
- vi->mv_rev.fore = tcp->rev_color.fg;
- vi->mv_rev.back = tcp->rev_color.bg;
- /*
- * The other fields are filled by the upper routine. XXX
- */
- return ENOIOCTL;
- }
- return ENOIOCTL;
-}
-
-static int
-scterm_reset(scr_stat *scp, int code)
-{
- /* FIXME */
- return 0;
-}
-
-static void
-scterm_default_attr(scr_stat *scp, int color, int rev_color)
-{
- term_stat *tcp = scp->ts;
-
- tcp->dflt_std_color.fg = color & 0x0f;
- tcp->dflt_std_color.bg = (color >> 4) & 0x0f;
- tcp->dflt_rev_color.fg = rev_color & 0x0f;
- tcp->dflt_rev_color.bg = (rev_color >> 4) & 0x0f;
- tcp->std_color = tcp->dflt_std_color;
- tcp->rev_color = tcp->dflt_rev_color;
- tcp->cur_color = tcp->std_color;
- tcp->cur_attr = mask2attr(tcp);
-}
-
-static void
-scterm_clear(scr_stat *scp)
-{
- term_stat *tcp = scp->ts;
-
- sc_move_cursor(scp, 0, 0);
- sc_vtb_clear(&scp->vtb, scp->sc->scr_map[0x20], tcp->cur_attr);
- mark_all(scp);
-}
-
-static void
-scterm_notify(scr_stat *scp, int event)
-{
- switch (event) {
- case SC_TE_NOTIFY_VTSWITCH_IN:
- break;
- case SC_TE_NOTIFY_VTSWITCH_OUT:
- break;
- }
-}
-
-static int
-scterm_input(scr_stat *scp, int c, struct tty *tp)
-{
- return FALSE;
-}
-
-/*
- * Calculate hardware attributes word using logical attributes mask and
- * hardware colors
- */
-
-/* FIXME */
-static int
-mask2attr(term_stat *tcp)
-{
- int attr, mask = tcp->attr_mask;
-
- if (mask & REVERSE_ATTR) {
- attr = ((mask & FG_CHANGED) ?
- tcp->cur_color.bg : tcp->rev_color.fg) |
- (((mask & BG_CHANGED) ?
- tcp->cur_color.fg : tcp->rev_color.bg) << 4);
- } else
- attr = tcp->cur_color.fg | (tcp->cur_color.bg << 4);
-
- /* XXX: underline mapping for Hercules adapter can be better */
- if (mask & (BOLD_ATTR | UNDERLINE_ATTR))
- attr ^= 0x08;
- if (mask & BLINK_ATTR)
- attr ^= 0x80;
-
- return (attr << 8);
-}
-
-#ifdef KANJI
-static u_char
-iskanji1(u_char mode, u_char c)
-{
- if ((mode == KTYPE_7JIS) && (c >= 0x21) && (c <= 0x7e)) {
- /* JIS */
- default_kanji = UJIS;
- return KTYPE_7JIS;
- }
-
- if ((mode == KTYPE_JKANA) && (c >= 0x21) && (c <= 0x5f)) {
- /* JIS HANKAKU */
- default_kanji = UJIS;
- return KTYPE_JKANA;
- }
-
-#if 1
- if ((c >= 0xa1) && (c <= 0xdf) && (default_kanji == UJIS)) {
- /* UJIS */
- return KTYPE_UJIS;
- }
-#endif
-
- if ((c >= 0x81) && (c <= 0x9f) && (c != 0x8e)) {
- /* SJIS */
- default_kanji = SJIS;
- return KTYPE_SJIS;
- }
-
- if ((c >= 0xa1) && (c <= 0xdf) && (default_kanji == SJIS)) {
- /* SJIS HANKAKU */
- return KTYPE_KANA;
- }
-
-#if 0
- if ((c >= 0xa1) && (c <= 0xdf) && (default_kanji == UJIS)) {
- /* UJIS */
- return KTYPE_UJIS;
- }
-#endif
-
- if ((c >= 0xf0) && (c <= 0xfe)) {
- /* UJIS */
- default_kanji = UJIS;
- return KTYPE_UJIS;
- }
-
- if ((c >= 0xe0) && (c <= 0xef)) {
- /* SJIS or UJIS */
- return KTYPE_SUJIS;
- }
-
- if (c == 0x8e) {
- /* SJIS or UJIS HANKAKU */
- return KTYPE_SUKANA;
- }
-
- return KTYPE_ASCII;
-}
-
-static u_char
-iskanji2(u_char mode, u_char c)
-{
- switch (mode) {
- case KTYPE_7JIS:
- if ((c >= 0x21) && (c <= 0x7e)) {
- /* JIS */
- return KTYPE_7JIS;
- }
- break;
- case KTYPE_SJIS:
- if ((c >= 0x40) && (c <= 0xfc) && (c != 0x7f)) {
- /* SJIS */
- return KTYPE_SJIS;
- }
- break;
- case KTYPE_UJIS:
- if ((c >= 0xa1) && (c <= 0xfe)) {
- /* UJIS */
- return KTYPE_UJIS;
- }
- break;
- case KTYPE_SUKANA:
- if ((c >= 0xa1) && (c <= 0xdf) && (default_kanji == UJIS)) {
- /* UJIS HANKAKU */
- return KTYPE_KANA;
- }
- if ((c >= 0x40) && (c <= 0xfc) && (c != 0x7f)) {
- /* SJIS */
- default_kanji = SJIS;
- return KTYPE_SJIS;
- }
- break;
- case KTYPE_SUJIS:
- if ((c >= 0x40) && (c <= 0xa0) && (c != 0x7f)) {
- /* SJIS */
- default_kanji = SJIS;
- return KTYPE_SJIS;
- }
- if ((c == 0xfd) || (c == 0xfe)) {
- /* UJIS */
- default_kanji = UJIS;
- return KTYPE_UJIS;
- }
- if ((c >= 0xa1) && (c <= 0xfc)) {
- if (default_kanji == SJIS)
- return KTYPE_SJIS;
- if (default_kanji == UJIS)
- return KTYPE_UJIS;
- }
- break;
- }
- return KTYPE_ASCII;
-}
-
-/*
- * JIS X0208-83 keisen conversion table
- */
-static u_short keiConv[32] = {
- 0x240c, 0x260c, 0x300c, 0x340c, 0x3c0c, 0x380c, 0x400c, 0x500c,
- 0x480c, 0x580c, 0x600c, 0x250c, 0x270c, 0x330c, 0x370c, 0x3f0c,
- 0x3b0c, 0x470c, 0x570c, 0x4f0c, 0x5f0c, 0x6f0c, 0x440c, 0x530c,
- 0x4c0c, 0x5b0c, 0x630c, 0x410c, 0x540c, 0x490c, 0x5c0c, 0x660c
-};
-
-static u_short
-kanji_convert(u_char mode, u_char h, u_char l)
-{
- u_short tmp, high, low, c;
- high = (u_short) h;
- low = (u_short) l;
-
- switch (mode) {
- case KTYPE_SJIS: /* SHIFT JIS */
- if (low >= 0xe0) {
- low -= 0x40;
- }
- low = (low - 0x81) * 2 + 0x21;
- if (high > 0x7f) {
- high--;
- }
- if (high > 0x9d) {
- low++;
- high -= 0x9e - 0x21;
- } else {
- high -= 0x40 - 0x21;
- }
- high &= 0x7F;
- low &= 0x7F;
- tmp = ((high << 8) | low) - 0x20;
- break;
- case KTYPE_7JIS: /* JIS */
- case KTYPE_UJIS: /* UJIS */
- high &= 0x7F;
- low &= 0x7F;
- tmp = ((high << 8) | low) - 0x20;
- break;
- default:
- tmp = 0;
- break;
- }
-
- /* keisen */
- c = ((tmp & 0xff) << 8) | (tmp >> 8);
- /* 0x2821 .. 0x2840 */
- if (0x0821 <= c && c <= 0x0840)
- tmp = keiConv[c - 0x0821];
-
- return (tmp);
-}
-#endif /* KANJI */
-
-#endif /* SC_DUMB_TERMINAL */
-
-#endif /* NSC > 0 */
diff --git a/sys/pc98/cbus/scvtb.c b/sys/pc98/cbus/scvtb.c
deleted file mode 100644
index 1c0be2c81146..000000000000
--- a/sys/pc98/cbus/scvtb.c
+++ /dev/null
@@ -1,409 +0,0 @@
-/*-
- * Copyright (c) 1999 FreeBSD(98) Porting Team.
- * 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 as
- * the first lines of this file unmodified.
- * 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 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.
- *
- * $FreeBSD$
- */
-
-#include "sc.h"
-#include "opt_syscons.h"
-
-#if NSC > 0
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/malloc.h>
-
-#include <machine/console.h>
-#include <machine/md_var.h>
-
-#include <dev/fb/fbreg.h>
-#include <dev/syscons/syscons.h>
-
-#define ATTR_OFFSET 0x2000
-
-#define vtb_wrap(vtb, at, offset) \
- (((at) + (offset) + (vtb)->vtb_size)%(vtb)->vtb_size)
-
-static u_int16_t at2pc98(u_int16_t attr);
-static vm_offset_t sc_vtb_attr_pointer(sc_vtb_t *vtb, int at);
-
-static u_int16_t
-at2pc98(u_int16_t attr)
-{
- static u_char ibmpc_to_pc98[16] = {
- 0x01, 0x21, 0x81, 0xa1, 0x41, 0x61, 0xc1, 0xe1,
- 0x09, 0x29, 0x89, 0xa9, 0x49, 0x69, 0xc9, 0xe9
- };
- static u_char ibmpc_to_pc98rev[16] = {
- 0x05, 0x25, 0x85, 0xa5, 0x45, 0x65, 0xc5, 0xe5,
- 0x0d, 0x2d, 0x8d, 0xad, 0x4d, 0x6d, 0xcd, 0xed
- };
- u_char fg_at, bg_at;
- u_int16_t at;
-
- if (attr & 0x00FF)
- return (attr);
-
- fg_at = ((attr >> 8) & 0x0F);
- bg_at = ((attr >> 12) & 0x0F);
-
- if (bg_at) {
- if (bg_at & 0x08) {
- if (bg_at & 0x07) {
- /* reverse & blink */
- at = ibmpc_to_pc98rev[bg_at] | 0x02;
- } else {
- /* normal & blink */
- at = ibmpc_to_pc98[fg_at] | 0x02;
- }
- } else {
- /* reverse */
- at = ibmpc_to_pc98rev[bg_at];
- }
- } else {
- /* normal */
- at = ibmpc_to_pc98[fg_at];
- }
- at |= attr;
- return (at);
-}
-
-void
-sc_vtb_init(sc_vtb_t *vtb, int type, int cols, int rows, void *buf, int wait)
-{
- vtb->vtb_flags = 0;
- vtb->vtb_type = type;
- vtb->vtb_cols = cols;
- vtb->vtb_rows = rows;
- vtb->vtb_size = cols*rows;
- vtb->vtb_buffer = NULL;
- vtb->vtb_tail = 0;
-
- switch (type) {
- case VTB_MEMORY:
- case VTB_RINGBUFFER:
- if ((buf == NULL) && (cols*rows != 0)) {
- vtb->vtb_buffer =
- (vm_offset_t)malloc(cols*rows*sizeof(u_int16_t)*2,
- M_DEVBUF,
- (wait) ? M_WAITOK : M_NOWAIT);
- if (vtb->vtb_buffer != NULL) {
- bzero((void *)sc_vtb_pointer(vtb, 0),
- cols*rows*sizeof(u_int16_t)*2);
- }
- } else {
- vtb->vtb_buffer = (vm_offset_t)buf;
- }
- vtb->vtb_flags |= VTB_VALID;
- break;
- case VTB_FRAMEBUFFER:
- vtb->vtb_buffer = (vm_offset_t)buf;
- vtb->vtb_flags |= VTB_VALID;
- break;
- default:
- break;
- }
-}
-
-void
-sc_vtb_destroy(sc_vtb_t *vtb)
-{
- vm_offset_t p;
-
- vtb->vtb_flags = 0;
- vtb->vtb_cols = 0;
- vtb->vtb_rows = 0;
- vtb->vtb_size = 0;
- vtb->vtb_tail = 0;
-
- p = vtb->vtb_buffer;
- vtb->vtb_buffer = NULL;
- switch (vtb->vtb_type) {
- case VTB_MEMORY:
- case VTB_RINGBUFFER:
- if (p != NULL)
- free((void *)p, M_DEVBUF);
- break;
- default:
- break;
- }
- vtb->vtb_type = VTB_INVALID;
-}
-
-size_t
-sc_vtb_size(int cols, int rows)
-{
- return (size_t)(cols*rows*sizeof(u_int16_t)*2);
-}
-
-int
-sc_vtb_getc(sc_vtb_t *vtb, int at)
-{
- if (vtb->vtb_type == VTB_FRAMEBUFFER)
- return (readw(sc_vtb_pointer(vtb, at)) & 0x00ff);
- else
- return (*(u_int16_t *)sc_vtb_pointer(vtb, at) & 0x00ff);
-}
-
-int
-sc_vtb_geta(sc_vtb_t *vtb, int at)
-{
- if (vtb->vtb_type == VTB_FRAMEBUFFER)
- return (readw(sc_vtb_attr_pointer(vtb, at)) & 0x00ff);
- else
- return (*(u_int16_t *)sc_vtb_attr_pointer(vtb, at) & 0x00ff);
-}
-
-void
-sc_vtb_putc(sc_vtb_t *vtb, int at, int c, int a)
-{
- if (vtb->vtb_type == VTB_FRAMEBUFFER) {
- writew(sc_vtb_pointer(vtb, at), c);
- writew(sc_vtb_attr_pointer(vtb, at), at2pc98(a));
- } else {
- *(u_int16_t *)sc_vtb_pointer(vtb, at) = c;
- *(u_int16_t *)sc_vtb_attr_pointer(vtb, at) = at2pc98(a);
- }
-}
-
-vm_offset_t
-sc_vtb_putchar(sc_vtb_t *vtb, vm_offset_t p, int c, int a)
-{
- if (vtb->vtb_type == VTB_FRAMEBUFFER) {
- writew(p, c);
- writew(p + ATTR_OFFSET, at2pc98(a));
- } else {
- *(u_int16_t *)p = c;
- *(u_int16_t *)(p + vtb->vtb_size*sizeof(u_int16_t)) = at2pc98(a);
- }
- return (p + sizeof(u_int16_t));
-}
-
-vm_offset_t
-sc_vtb_pointer(sc_vtb_t *vtb, int at)
-{
- return (vtb->vtb_buffer + sizeof(u_int16_t)*(at));
-}
-
-static vm_offset_t
-sc_vtb_attr_pointer(sc_vtb_t *vtb, int at)
-{
- return (vtb->vtb_buffer + sizeof(u_int16_t)*(at)
- + ((vtb->vtb_type == VTB_FRAMEBUFFER) ?
- ATTR_OFFSET : vtb->vtb_size*sizeof(u_int16_t)));
-}
-
-int
-sc_vtb_pos(sc_vtb_t *vtb, int pos, int offset)
-{
- return ((pos + offset + vtb->vtb_size)%vtb->vtb_size);
-}
-
-void
-sc_vtb_clear(sc_vtb_t *vtb, int c, int attr)
-{
- if (vtb->vtb_type == VTB_FRAMEBUFFER) {
- fillw_io(c, sc_vtb_pointer(vtb, 0), vtb->vtb_size);
- fillw_io(at2pc98(attr), sc_vtb_attr_pointer(vtb, 0), vtb->vtb_size);
- } else {
- fillw(c, (void *)sc_vtb_pointer(vtb, 0), vtb->vtb_size);
- fillw(at2pc98(attr), (void *)sc_vtb_attr_pointer(vtb, 0), vtb->vtb_size);
- }
-}
-
-void
-sc_vtb_copy(sc_vtb_t *vtb1, int from, sc_vtb_t *vtb2, int to, int count)
-{
- if (vtb2->vtb_type == VTB_FRAMEBUFFER) {
- bcopy_toio(sc_vtb_pointer(vtb1, from),
- sc_vtb_pointer(vtb2, to),
- count*sizeof(u_int16_t));
- bcopy_toio(sc_vtb_attr_pointer(vtb1, from),
- sc_vtb_attr_pointer(vtb2, to),
- count*sizeof(u_int16_t));
- } else if (vtb1->vtb_type == VTB_FRAMEBUFFER) {
- bcopy_fromio(sc_vtb_pointer(vtb1, from),
- sc_vtb_pointer(vtb2, to),
- count*sizeof(u_int16_t));
- bcopy_fromio(sc_vtb_attr_pointer(vtb1, from),
- sc_vtb_attr_pointer(vtb2, to),
- count*sizeof(u_int16_t));
- } else {
- bcopy((void *)sc_vtb_pointer(vtb1, from),
- (void *)sc_vtb_pointer(vtb2, to),
- count*sizeof(u_int16_t));
- bcopy((void *)sc_vtb_attr_pointer(vtb1, from),
- (void *)sc_vtb_attr_pointer(vtb2, to),
- count*sizeof(u_int16_t));
- }
-}
-
-void
-sc_vtb_append(sc_vtb_t *vtb1, int from, sc_vtb_t *vtb2, int count)
-{
- int len;
-
- if (vtb2->vtb_type != VTB_RINGBUFFER)
- return;
-
- while (count > 0) {
- len = imin(count, vtb2->vtb_size - vtb2->vtb_tail);
- if (vtb1->vtb_type == VTB_FRAMEBUFFER) {
- bcopy_fromio(sc_vtb_pointer(vtb1, from),
- sc_vtb_pointer(vtb2, vtb2->vtb_tail),
- len*sizeof(u_int16_t));
- bcopy_fromio(sc_vtb_attr_pointer(vtb1, from),
- sc_vtb_attr_pointer(vtb2, vtb2->vtb_tail),
- len*sizeof(u_int16_t));
- } else {
- bcopy((void *)sc_vtb_pointer(vtb1, from),
- (void *)sc_vtb_pointer(vtb2, vtb2->vtb_tail),
- len*sizeof(u_int16_t));
- bcopy((void *)sc_vtb_attr_pointer(vtb1, from),
- (void *)sc_vtb_attr_pointer(vtb2, vtb2->vtb_tail),
- len*sizeof(u_int16_t));
- }
- from += len;
- count -= len;
- vtb2->vtb_tail = vtb_wrap(vtb2, vtb2->vtb_tail, len);
- }
-}
-
-void
-sc_vtb_seek(sc_vtb_t *vtb, int pos)
-{
- vtb->vtb_tail = pos%vtb->vtb_size;
-}
-
-void
-sc_vtb_erase(sc_vtb_t *vtb, int at, int count, int c, int attr)
-{
- if (at + count > vtb->vtb_size)
- count = vtb->vtb_size - at;
- if (vtb->vtb_type == VTB_FRAMEBUFFER) {
- fillw_io(c, sc_vtb_pointer(vtb, at), count);
- fillw_io(at2pc98(attr), sc_vtb_attr_pointer(vtb, at), count);
- } else {
- fillw(c, (void *)sc_vtb_pointer(vtb, at), count);
- fillw(at2pc98(attr), (void *)sc_vtb_attr_pointer(vtb, at), count);
- }
-}
-
-void
-sc_vtb_move(sc_vtb_t *vtb, int from, int to, int count)
-{
- if (from + count > vtb->vtb_size)
- count = vtb->vtb_size - from;
- if (to + count > vtb->vtb_size)
- count = vtb->vtb_size - to;
- if (count <= 0)
- return;
- if (vtb->vtb_type == VTB_FRAMEBUFFER) {
- bcopy_io(sc_vtb_pointer(vtb, from),
- sc_vtb_pointer(vtb, to), count*sizeof(u_int16_t));
- bcopy_io(sc_vtb_attr_pointer(vtb, from),
- sc_vtb_attr_pointer(vtb, to), count*sizeof(u_int16_t));
- } else {
- bcopy((void *)sc_vtb_pointer(vtb, from),
- (void *)sc_vtb_pointer(vtb, to), count*sizeof(u_int16_t));
- bcopy((void *)sc_vtb_attr_pointer(vtb, from),
- (void *)sc_vtb_attr_pointer(vtb, to), count*sizeof(u_int16_t));
- }
-}
-
-void
-sc_vtb_delete(sc_vtb_t *vtb, int at, int count, int c, int attr)
-{
- int len;
-
- if (at + count > vtb->vtb_size)
- count = vtb->vtb_size - at;
- len = vtb->vtb_size - at - count;
- if (len > 0) {
- if (vtb->vtb_type == VTB_FRAMEBUFFER) {
- bcopy_io(sc_vtb_pointer(vtb, at + count),
- sc_vtb_pointer(vtb, at),
- len*sizeof(u_int16_t));
- bcopy_io(sc_vtb_attr_pointer(vtb, at + count),
- sc_vtb_attr_pointer(vtb, at),
- len*sizeof(u_int16_t));
- } else {
- bcopy((void *)sc_vtb_pointer(vtb, at + count),
- (void *)sc_vtb_pointer(vtb, at),
- len*sizeof(u_int16_t));
- bcopy((void *)sc_vtb_attr_pointer(vtb, at + count),
- (void *)sc_vtb_attr_pointer(vtb, at),
- len*sizeof(u_int16_t));
- }
- }
- if (vtb->vtb_type == VTB_FRAMEBUFFER) {
- fillw_io(c, sc_vtb_pointer(vtb, at + len),
- vtb->vtb_size - at - len);
- fillw_io(at2pc98(attr),
- sc_vtb_attr_pointer(vtb, at + len),
- vtb->vtb_size - at - len);
- } else {
- fillw(c, (void *)sc_vtb_pointer(vtb, at + len),
- vtb->vtb_size - at - len);
- fillw(at2pc98(attr),
- (void *)sc_vtb_attr_pointer(vtb, at + len),
- vtb->vtb_size - at - len);
- }
-}
-
-void
-sc_vtb_ins(sc_vtb_t *vtb, int at, int count, int c, int attr)
-{
- if (at + count > vtb->vtb_size) {
- count = vtb->vtb_size - at;
- } else {
- if (vtb->vtb_type == VTB_FRAMEBUFFER) {
- bcopy_io(sc_vtb_pointer(vtb, at),
- sc_vtb_pointer(vtb, at + count),
- (vtb->vtb_size - at - count)*sizeof(u_int16_t));
- bcopy_io(sc_vtb_attr_pointer(vtb, at),
- sc_vtb_attr_pointer(vtb, at + count),
- (vtb->vtb_size - at - count)*sizeof(u_int16_t));
- } else {
- bcopy((void *)sc_vtb_pointer(vtb, at),
- (void *)sc_vtb_pointer(vtb, at + count),
- (vtb->vtb_size - at - count)*sizeof(u_int16_t));
- bcopy((void *)sc_vtb_attr_pointer(vtb, at),
- (void *)sc_vtb_attr_pointer(vtb, at + count),
- (vtb->vtb_size - at - count)*sizeof(u_int16_t));
- }
- }
- if (vtb->vtb_type == VTB_FRAMEBUFFER) {
- fillw_io(c, sc_vtb_pointer(vtb, at), count);
- fillw_io(at2pc98(attr),
- sc_vtb_attr_pointer(vtb, at), count);
- } else {
- fillw(c, (void *)sc_vtb_pointer(vtb, at), count);
- fillw(at2pc98(attr),
- (void *)sc_vtb_attr_pointer(vtb, at), count);
- }
-}
-
-#endif /* NSC */
diff --git a/sys/pc98/cbus/sio.c b/sys/pc98/cbus/sio.c
deleted file mode 100644
index 58380f14d078..000000000000
--- a/sys/pc98/cbus/sio.c
+++ /dev/null
@@ -1,5162 +0,0 @@
-/*-
- * 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * $FreeBSD$
- * from: @(#)com.c 7.5 (Berkeley) 5/16/91
- * from: i386/isa sio.c,v 1.234
- */
-
-#include "opt_comconsole.h"
-#include "opt_compat.h"
-#include "opt_ddb.h"
-#include "opt_sio.h"
-#include "card.h"
-#include "sio.h"
-
-/*
- * Serial driver, based on 386BSD-0.1 com driver.
- * Mostly rewritten to use pseudo-DMA.
- * Works for National Semiconductor NS8250-NS16550AF UARTs.
- * COM driver, based on HP dca driver.
- *
- * Changes for PC-Card integration:
- * - Added PC-Card driver table and handlers
- */
-/*===============================================================
- * 386BSD(98),FreeBSD-1.1x(98) com driver.
- * -----
- * modified for PC9801 by M.Ishii
- * Kyoto University Microcomputer Club (KMC)
- * Chou "TEFUTEFU" Hirotomi
- * Kyoto Univ. the faculty of medicine
- *===============================================================
- * FreeBSD-2.0.1(98) sio driver.
- * -----
- * modified for pc98 Internal i8251 and MICRO CORE MC16550II
- * T.Koike(hfc01340@niftyserve.or.jp)
- * implement kernel device configuration
- * aizu@orient.center.nitech.ac.jp
- *
- * Notes.
- * -----
- * PC98 localization based on 386BSD(98) com driver. Using its PC98 local
- * functions.
- * This driver is under debugging,has bugs.
- *
- * 1) config
- * options COM_MULTIPORT #if using MC16550II
- * device sio0 at nec? port 0x30 tty irq 4 #internal
- * device sio1 at nec? port 0xd2 tty irq 5 flags 0x101 #mc1
- * device sio2 at nec? port 0x8d2 tty flags 0x101 #mc2
- * # ~~~~~iobase ~~multi port flag
- * # ~ master device is sio1
- * 2) device
- * cd /dev; MAKEDEV ttyd0 ttyd1 ..
- * 3) /etc/rc.serial
- * 57600bps is too fast for sio0(internal8251)
- * my ex.
- * #set default speed 9600
- * modem()
- * :
- * stty </dev/ttyid$i crtscts 9600
- * : # ~~~~ default speed(can change after init.)
- * modem 0 1 2
- * 4) COMCONSOLE
- * not changed.
- * 5) PC9861K,PIO9032B,B98_01
- * not tested.
- */
-/*
- * modified for AIWA B98-01
- * by T.Hatanou <hatanou@yasuda.comm.waseda.ac.jp> last update: 15 Sep.1995
- *
- * How to configure...
- * # options COM_MULTIPORT # support for MICROCORE MC16550II
- * ... comment-out this line, which will conflict with B98_01.
- * options "B98_01" # support for AIWA B98-01
- * device sio1 at nec? port 0x00d1 tty irq ?
- * device sio2 at nec? port 0x00d5 tty irq ?
- * ... you can leave these lines `irq ?', irq will be autodetected.
- */
-/*
- * Modified by Y.Takahashi of Kogakuin University.
- */
-/*
- * modified for 8251(FIFO) by Seigo TANIMURA <tanimura@FreeBSD.org>
- */
-
-#ifdef PC98
-#define COM_IF_INTERNAL 0x00
-#define COM_IF_PC9861K_1 0x01
-#define COM_IF_PC9861K_2 0x02
-#define COM_IF_IND_SS_1 0x03
-#define COM_IF_IND_SS_2 0x04
-#define COM_IF_PIO9032B_1 0x05
-#define COM_IF_PIO9032B_2 0x06
-#define COM_IF_B98_01_1 0x07
-#define COM_IF_B98_01_2 0x08
-#define COM_IF_END1 COM_IF_B98_01_2
-#define COM_IF_RSA98 0x10 /* same as COM_IF_NS16550 */
-#define COM_IF_NS16550 0x11
-#define COM_IF_SECOND_CCU 0x12 /* same as COM_IF_NS16550 */
-#define COM_IF_MC16550II 0x13
-#define COM_IF_MCRS98 0x14 /* same as COM_IF_MC16550II */
-#define COM_IF_RSB3000 0x15
-#define COM_IF_RSB384 0x16
-#define COM_IF_MODEM_CARD 0x17 /* same as COM_IF_NS16550 */
-#define COM_IF_RSA98III 0x18
-#define COM_IF_ESP98 0x19
-#define COM_IF_END2 COM_IF_ESP98
-#endif /* PC98 */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/reboot.h>
-#include <sys/malloc.h>
-#include <sys/tty.h>
-#include <sys/proc.h>
-#include <sys/module.h>
-#include <sys/conf.h>
-#include <sys/dkstat.h>
-#include <sys/fcntl.h>
-#include <sys/interrupt.h>
-#include <sys/kernel.h>
-#include <sys/syslog.h>
-#include <sys/sysctl.h>
-#include <sys/bus.h>
-#include <machine/bus.h>
-#include <sys/rman.h>
-#include <sys/timepps.h>
-
-#ifdef PC98
-#include <pc98/pc98/pc98.h>
-#include <pc98/pc98/pc98_machdep.h>
-#include <i386/isa/ic/i8251.h>
-#else
-#include <isa/isareg.h>
-#endif
-#include <isa/isavar.h>
-#include <machine/lock.h>
-
-#include <machine/clock.h>
-#include <machine/ipl.h>
-#ifndef SMP
-#include <machine/lock.h>
-#endif
-#include <machine/resource.h>
-
-#include <isa/sioreg.h>
-
-#ifdef COM_ESP
-#include <i386/isa/ic/esp.h>
-#endif
-#include <i386/isa/ic/ns16550.h>
-#ifdef PC98
-#include <i386/isa/ic/rsa.h>
-#endif
-
-#ifndef __i386__
-#define disable_intr()
-#define enable_intr()
-#endif
-
-#ifdef SMP
-#define disable_intr() COM_DISABLE_INTR()
-#define enable_intr() COM_ENABLE_INTR()
-#endif /* SMP */
-
-#define LOTS_OF_EVENTS 64 /* helps separate urgent events from input */
-
-#define CALLOUT_MASK 0x80
-#define CONTROL_MASK 0x60
-#define CONTROL_INIT_STATE 0x20
-#define CONTROL_LOCK_STATE 0x40
-#define DEV_TO_UNIT(dev) (MINOR_TO_UNIT(minor(dev)))
-#define MINOR_MAGIC_MASK (CALLOUT_MASK | CONTROL_MASK)
-#define MINOR_TO_UNIT(mynor) ((mynor) & ~MINOR_MAGIC_MASK)
-
-#ifdef COM_MULTIPORT
-/* checks in flags for multiport and which is multiport "master chip"
- * for a given card
- */
-#define COM_ISMULTIPORT(flags) ((flags) & 0x01)
-#define COM_MPMASTER(flags) (((flags) >> 8) & 0x0ff)
-#define COM_NOTAST4(flags) ((flags) & 0x04)
-#endif /* COM_MULTIPORT */
-
-#define COM_CONSOLE(flags) ((flags) & 0x10)
-#define COM_FORCECONSOLE(flags) ((flags) & 0x20)
-#define COM_LLCONSOLE(flags) ((flags) & 0x40)
-#define COM_DEBUGGER(flags) ((flags) & 0x80)
-#define COM_LOSESOUTINTS(flags) ((flags) & 0x08)
-#define COM_NOFIFO(flags) ((flags) & 0x02)
-#define COM_ST16650A(flags) ((flags) & 0x20000)
-#define COM_C_NOPROBE (0x40000)
-#define COM_NOPROBE(flags) ((flags) & COM_C_NOPROBE)
-#define COM_C_IIR_TXRDYBUG (0x80000)
-#define COM_IIR_TXRDYBUG(flags) ((flags) & COM_C_IIR_TXRDYBUG)
-#define COM_FIFOSIZE(flags) (((flags) & 0xff000000) >> 24)
-
-#ifdef PC98
-#define com_emr com_msr /* Extension mode register for RSB-2000/3000 */
-#else
-#define com_scr 7 /* scratch register for 16450-16550 (R/W) */
-#endif
-
-/*
- * com state bits.
- * (CS_BUSY | CS_TTGO) and (CS_BUSY | CS_TTGO | CS_ODEVREADY) must be higher
- * than the other bits so that they can be tested as a group without masking
- * off the low bits.
- *
- * The following com and tty flags correspond closely:
- * CS_BUSY = TS_BUSY (maintained by comstart(), siopoll() and
- * comstop())
- * CS_TTGO = ~TS_TTSTOP (maintained by comparam() and comstart())
- * CS_CTS_OFLOW = CCTS_OFLOW (maintained by comparam())
- * CS_RTS_IFLOW = CRTS_IFLOW (maintained by comparam())
- * TS_FLUSH is not used.
- * XXX I think TIOCSETA doesn't clear TS_TTSTOP when it clears IXON.
- * XXX CS_*FLOW should be CF_*FLOW in com->flags (control flags not state).
- */
-#define CS_BUSY 0x80 /* output in progress */
-#define CS_TTGO 0x40 /* output not stopped by XOFF */
-#define CS_ODEVREADY 0x20 /* external device h/w ready (CTS) */
-#define CS_CHECKMSR 1 /* check of MSR scheduled */
-#define CS_CTS_OFLOW 2 /* use CTS output flow control */
-#define CS_DTR_OFF 0x10 /* DTR held off */
-#define CS_ODONE 4 /* output completed */
-#define CS_RTS_IFLOW 8 /* use RTS input flow control */
-#define CSE_BUSYCHECK 1 /* siobusycheck() scheduled */
-
-static char const * const error_desc[] = {
-#define CE_OVERRUN 0
- "silo overflow",
-#define CE_INTERRUPT_BUF_OVERFLOW 1
- "interrupt-level buffer overflow",
-#define CE_TTY_BUF_OVERFLOW 2
- "tty-level buffer overflow",
-};
-
-#define CE_NTYPES 3
-#define CE_RECORD(com, errnum) (++(com)->delta_error_counts[errnum])
-
-/* types. XXX - should be elsewhere */
-typedef u_int Port_t; /* hardware port */
-typedef u_char bool_t; /* boolean */
-
-/* queue of linear buffers */
-struct lbq {
- u_char *l_head; /* next char to process */
- u_char *l_tail; /* one past the last char to process */
- struct lbq *l_next; /* next in queue */
- bool_t l_queued; /* nonzero if queued */
-};
-
-/* com device structure */
-struct com_s {
- u_int flags; /* Copy isa device flags */
- u_char state; /* miscellaneous flag bits */
- bool_t active_out; /* nonzero if the callout device is open */
- u_char cfcr_image; /* copy of value written to CFCR */
-#ifdef COM_ESP
- bool_t esp; /* is this unit a hayes esp board? */
-#endif
- u_char extra_state; /* more flag bits, separate for order trick */
- u_char fifo_image; /* copy of value written to FIFO */
- bool_t hasfifo; /* nonzero for 16550 UARTs */
- bool_t st16650a; /* Is a Startech 16650A or RTS/CTS compat */
- bool_t loses_outints; /* nonzero if device loses output interrupts */
- u_char mcr_image; /* copy of value written to MCR */
-#ifdef COM_MULTIPORT
- bool_t multiport; /* is this unit part of a multiport device? */
-#endif /* COM_MULTIPORT */
- bool_t no_irq; /* nonzero if irq is not attached */
- bool_t gone; /* hardware disappeared */
- bool_t poll; /* nonzero if polling is required */
- bool_t poll_output; /* nonzero if polling for output is required */
- int unit; /* unit number */
- int dtr_wait; /* time to hold DTR down on close (* 1/hz) */
- u_int tx_fifo_size;
- u_int wopeners; /* # processes waiting for DCD in open() */
-
- /*
- * The high level of the driver never reads status registers directly
- * because there would be too many side effects to handle conveniently.
- * Instead, it reads copies of the registers stored here by the
- * interrupt handler.
- */
- u_char last_modem_status; /* last MSR read by intr handler */
- u_char prev_modem_status; /* last MSR handled by high level */
-
- u_char hotchar; /* ldisc-specific char to be handled ASAP */
- u_char *ibuf; /* start of input buffer */
- u_char *ibufend; /* end of input buffer */
- u_char *ibufold; /* old input buffer, to be freed */
- u_char *ihighwater; /* threshold in input buffer */
- u_char *iptr; /* next free spot in input buffer */
- int ibufsize; /* size of ibuf (not include error bytes) */
- int ierroff; /* offset of error bytes in ibuf */
-
- struct lbq obufq; /* head of queue of output buffers */
- struct lbq obufs[2]; /* output buffers */
-
-#ifdef PC98
- Port_t cmd_port;
- Port_t sts_port;
- Port_t in_modem_port;
- Port_t intr_ctrl_port;
- int intr_enable;
- int pc98_prev_modem_status;
- int pc98_modem_delta;
- int modem_car_chg_timer;
- int pc98_prev_siocmd;
- int pc98_prev_siomod;
- int modem_checking;
- int pc98_if_type;
-
- bool_t pc98_8251fifo;
- bool_t pc98_8251fifo_enable;
-#endif /* PC98 */
- Port_t data_port; /* i/o ports */
-#ifdef COM_ESP
- Port_t esp_port;
-#endif
- Port_t int_id_port;
- Port_t iobase;
-#ifdef PC98
- Port_t rsabase; /* iobase address of a I/O-DATA RSA board */
-#endif
- Port_t modem_ctl_port;
- Port_t line_status_port;
- Port_t modem_status_port;
- Port_t intr_ctl_port; /* Ports of IIR register */
-
- struct tty *tp; /* cross reference */
-
- /* Initial state. */
- struct termios it_in; /* should be in struct tty */
- struct termios it_out;
-
- /* Lock state. */
- struct termios lt_in; /* should be in struct tty */
- struct termios lt_out;
-
- bool_t do_timestamp;
- bool_t do_dcd_timestamp;
- struct timeval timestamp;
- struct timeval dcd_timestamp;
- struct pps_state pps;
-
- u_long bytes_in; /* statistics */
- u_long bytes_out;
- u_int delta_error_counts[CE_NTYPES];
- u_long error_counts[CE_NTYPES];
-
- struct resource *irqres;
- struct resource *ioportres;
- void *cookie;
-
- /*
- * Data area for output buffers. Someday we should build the output
- * buffer queue without copying data.
- */
-#ifdef PC98
- int obufsize;
- u_char *obuf1;
- u_char *obuf2;
-#else
- u_char obuf1[256];
- u_char obuf2[256];
-#endif
-};
-
-#ifdef COM_ESP
-static int espattach __P((struct com_s *com, Port_t esp_port));
-#endif
-static int sioattach __P((device_t dev));
-static int sio_isa_attach __P((device_t dev));
-
-static timeout_t siobusycheck;
-static timeout_t siodtrwakeup;
-static void comhardclose __P((struct com_s *com));
-static void sioinput __P((struct com_s *com));
-static void siointr1 __P((struct com_s *com));
-static void siointr __P((void *arg));
-static int commctl __P((struct com_s *com, int bits, int how));
-static int comparam __P((struct tty *tp, struct termios *t));
-static swihand_t siopoll;
-static int sioprobe __P((device_t dev));
-static int sio_isa_probe __P((device_t dev));
-static void siosettimeout __P((void));
-static int siosetwater __P((struct com_s *com, speed_t speed));
-static void comstart __P((struct tty *tp));
-static void comstop __P((struct tty *tp, int rw));
-static timeout_t comwakeup;
-static void disc_optim __P((struct tty *tp, struct termios *t,
- struct com_s *com));
-
-#if NCARD > 0
-static int sio_pccard_attach __P((device_t dev));
-static int sio_pccard_detach __P((device_t dev));
-static int sio_pccard_probe __P((device_t dev));
-#endif /* NCARD > 0 */
-
-static char driver_name[] = "sio";
-
-/* table and macro for fast conversion from a unit number to its com struct */
-static devclass_t sio_devclass;
-#define com_addr(unit) ((struct com_s *) \
- devclass_get_softc(sio_devclass, unit))
-
-static device_method_t sio_isa_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, sio_isa_probe),
- DEVMETHOD(device_attach, sio_isa_attach),
-
- { 0, 0 }
-};
-
-static driver_t sio_isa_driver = {
- driver_name,
- sio_isa_methods,
- sizeof(struct com_s),
-};
-
-#if NCARD > 0
-static device_method_t sio_pccard_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, sio_pccard_probe),
- DEVMETHOD(device_attach, sio_pccard_attach),
- DEVMETHOD(device_detach, sio_pccard_detach),
-
- { 0, 0 }
-};
-
-static driver_t sio_pccard_driver = {
- driver_name,
- sio_pccard_methods,
- sizeof(struct com_s),
-};
-#endif (NCARD > 0)
-
-static d_open_t sioopen;
-static d_close_t sioclose;
-static d_read_t sioread;
-static d_write_t siowrite;
-static d_ioctl_t sioioctl;
-
-#define CDEV_MAJOR 28
-static struct cdevsw sio_cdevsw = {
- /* open */ sioopen,
- /* close */ sioclose,
- /* read */ sioread,
- /* write */ siowrite,
- /* ioctl */ sioioctl,
- /* poll */ ttypoll,
- /* mmap */ nommap,
- /* strategy */ nostrategy,
- /* name */ driver_name,
- /* maj */ CDEV_MAJOR,
- /* dump */ nodump,
- /* psize */ nopsize,
- /* flags */ D_TTY,
- /* bmaj */ -1
-};
-
-int comconsole = -1;
-static volatile speed_t comdefaultrate = CONSPEED;
-#ifdef __alpha__
-static volatile speed_t gdbdefaultrate = CONSPEED;
-#endif
-static u_int com_events; /* input chars + weighted output completions */
-static Port_t siocniobase;
-static int siocnunit;
-static Port_t siogdbiobase;
-static int siogdbunit = -1;
-static bool_t sio_registered;
-static int sio_timeout;
-static int sio_timeouts_until_log;
-static struct callout_handle sio_timeout_handle
- = CALLOUT_HANDLE_INITIALIZER(&sio_timeout_handle);
-static int sio_numunits;
-
-#ifdef PC98
-struct siodev {
- short if_type;
- short irq;
- Port_t cmd, sts, ctrl, mod;
-};
-static int sysclock;
-
-#define COM_INT_DISABLE {int previpri; previpri=spltty();
-#define COM_INT_ENABLE splx(previpri);}
-#define IEN_TxFLAG IEN_Tx
-
-#define COM_CARRIER_DETECT_EMULATE 0
-#define PC98_CHECK_MODEM_INTERVAL (hz/10)
-#define DCD_OFF_TOLERANCE 2
-#define DCD_ON_RECOGNITION 2
-#define GET_IFTYPE(flags) ((flags >> 24) & 0x1f)
-#define IS_8251(if_type) (!(if_type & 0x10))
-#define COM1_EXT_CLOCK 0x40000
-
-static void commint __P((dev_t dev));
-static void com_tiocm_set __P((struct com_s *com, int msr));
-static void com_tiocm_bis __P((struct com_s *com, int msr));
-static void com_tiocm_bic __P((struct com_s *com, int msr));
-static int com_tiocm_get __P((struct com_s *com));
-static int com_tiocm_get_delta __P((struct com_s *com));
-static void pc98_msrint_start __P((dev_t dev));
-static void com_cflag_and_speed_set __P((struct com_s *com, int cflag, int speed));
-static int pc98_ttspeedtab __P((struct com_s *com, int speed));
-static int pc98_get_modem_status __P((struct com_s *com));
-static timeout_t pc98_check_msr;
-static void pc98_set_baud_rate __P((struct com_s *com, int count));
-static void pc98_i8251_reset __P((struct com_s *com, int mode, int command));
-static void pc98_disable_i8251_interrupt __P((struct com_s *com, int mod));
-static void pc98_enable_i8251_interrupt __P((struct com_s *com, int mod));
-static int pc98_check_i8251_interrupt __P((struct com_s *com));
-static int pc98_i8251_get_cmd __P((struct com_s *com));
-static int pc98_i8251_get_mod __P((struct com_s *com));
-static void pc98_i8251_set_cmd __P((struct com_s *com, int x));
-static void pc98_i8251_or_cmd __P((struct com_s *com, int x));
-static void pc98_i8251_clear_cmd __P((struct com_s *com, int x));
-static void pc98_i8251_clear_or_cmd __P((struct com_s *com, int clr, int x));
-static int pc98_check_if_type __P((device_t dev, struct siodev *iod));
-static int pc98_check_8251vfast __P((void));
-static int pc98_check_8251fifo __P((void));
-static void pc98_check_sysclock __P((void));
-static int pc98_set_ioport __P((struct com_s *com));
-
-#define com_int_Tx_disable(com) \
- pc98_disable_i8251_interrupt(com,IEN_Tx|IEN_TxEMP)
-#define com_int_Tx_enable(com) \
- pc98_enable_i8251_interrupt(com,IEN_TxFLAG)
-#define com_int_Rx_disable(com) \
- pc98_disable_i8251_interrupt(com,IEN_Rx)
-#define com_int_Rx_enable(com) \
- pc98_enable_i8251_interrupt(com,IEN_Rx)
-#define com_int_TxRx_disable(com) \
- pc98_disable_i8251_interrupt(com,IEN_Tx|IEN_TxEMP|IEN_Rx)
-#define com_int_TxRx_enable(com) \
- pc98_enable_i8251_interrupt(com,IEN_TxFLAG|IEN_Rx)
-#define com_send_break_on(com) \
- pc98_i8251_or_cmd(com,CMD8251_SBRK)
-#define com_send_break_off(com) \
- pc98_i8251_clear_cmd(com,CMD8251_SBRK)
-
-static struct speedtab pc98speedtab[] = { /* internal RS232C interface */
- { 0, 0, },
- { 50, 50, },
- { 75, 75, },
- { 150, 150, },
- { 200, 200, },
- { 300, 300, },
- { 600, 600, },
- { 1200, 1200, },
- { 2400, 2400, },
- { 4800, 4800, },
- { 9600, 9600, },
- { 19200, 19200, },
- { 38400, 38400, },
- { 51200, 51200, },
- { 76800, 76800, },
- { 20800, 20800, },
- { 31200, 31200, },
- { 41600, 41600, },
- { 62400, 62400, },
- { -1, -1 }
-};
-static struct speedtab pc98fast_speedtab[] = {
- { 9600, 0x80 | COMBRD(9600), },
- { 19200, 0x80 | COMBRD(19200), },
- { 38400, 0x80 | COMBRD(38400), },
- { 57600, 0x80 | COMBRD(57600), },
- { 115200, 0x80 | COMBRD(115200), },
- { -1, -1 }
-};
-static struct speedtab comspeedtab_pio9032b[] = {
- { 300, 6, },
- { 600, 5, },
- { 1200, 4, },
- { 2400, 3, },
- { 4800, 2, },
- { 9600, 1, },
- { 19200, 0, },
- { 38400, 7, },
- { -1, -1 }
-};
-static struct speedtab comspeedtab_b98_01[] = {
- { 75, 11, },
- { 150, 10, },
- { 300, 9, },
- { 600, 8, },
- { 1200, 7, },
- { 2400, 6, },
- { 4800, 5, },
- { 9600, 4, },
- { 19200, 3, },
- { 38400, 2, },
- { 76800, 1, },
- { 153600, 0, },
- { -1, -1 }
-};
-static struct speedtab comspeedtab_mc16550[] = {
- { 300, 1536, },
- { 600, 768, },
- { 1200, 384, },
- { 2400, 192, },
- { 4800, 96, },
- { 9600, 48, },
- { 19200, 24, },
- { 38400, 12, },
- { 57600, 8, },
- { 115200, 4, },
- { 153600, 3, },
- { 230400, 2, },
- { 460800, 1, },
- { -1, -1 }
-};
-static struct speedtab comspeedtab_rsb384[] = {
- { 300, 3840, },
- { 600, 1920, },
- { 1200, 960, },
- { 2400, 480, },
- { 4800, 240, },
- { 9600, 120, },
- { 19200, 60, },
- { 38400, 30, },
- { 57600, 20, },
- { 115200, 10, },
- { 128000, 9, },
- { 144000, 8, },
- { 192000, 6, },
- { 230400, 5, },
- { 288000, 4, },
- { 384000, 3, },
- { 576000, 2, },
- { 1152000, 1, },
- { -1, -1 }
-};
-static struct speedtab comspeedtab_rsa[] = {
- { 0, 0 },
- { 50, COMBRD_RSA(50) },
- { 75, COMBRD_RSA(75) },
- { 110, COMBRD_RSA(110) },
- { 134, COMBRD_RSA(134) },
- { 150, COMBRD_RSA(150) },
- { 200, COMBRD_RSA(200) },
- { 300, COMBRD_RSA(300) },
- { 600, COMBRD_RSA(600) },
- { 1200, COMBRD_RSA(1200) },
- { 1800, COMBRD_RSA(1800) },
- { 2400, COMBRD_RSA(2400) },
- { 4800, COMBRD_RSA(4800) },
- { 9600, COMBRD_RSA(9600) },
- { 19200, COMBRD_RSA(19200) },
- { 38400, COMBRD_RSA(38400) },
- { 57600, COMBRD_RSA(57600) },
- { 115200, COMBRD_RSA(115200) },
- { 230400, COMBRD_RSA(230400) },
- { 460800, COMBRD_RSA(460800) },
- { 921600, COMBRD_RSA(921600) },
- { -1, -1 }
-};
-#endif /* PC98 */
-
-static struct speedtab comspeedtab[] = {
- { 0, 0 },
- { 50, COMBRD(50) },
- { 75, COMBRD(75) },
- { 110, COMBRD(110) },
- { 134, COMBRD(134) },
- { 150, COMBRD(150) },
- { 200, COMBRD(200) },
- { 300, COMBRD(300) },
- { 600, COMBRD(600) },
- { 1200, COMBRD(1200) },
- { 1800, COMBRD(1800) },
- { 2400, COMBRD(2400) },
- { 4800, COMBRD(4800) },
- { 9600, COMBRD(9600) },
- { 19200, COMBRD(19200) },
- { 38400, COMBRD(38400) },
- { 57600, COMBRD(57600) },
- { 115200, COMBRD(115200) },
- { -1, -1 }
-};
-
-#ifdef PC98
-struct {
- char *name;
- short port_table[7];
- short irr_mask;
- struct speedtab *speedtab;
- short check_irq;
-} if_8251_type[] = {
- /* COM_IF_INTERNAL */
- { " (internal)", {0x30, 0x32, 0x32, 0x33, 0x35, -1, -1},
- -1, pc98speedtab, 1 },
- /* COM_IF_PC9861K_1 */
- { " (PC9861K)", {0xb1, 0xb3, 0xb3, 0xb0, 0xb0, -1, -1},
- 3, NULL, 1 },
- /* COM_IF_PC9861K_2 */
- { " (PC9861K)", {0xb9, 0xbb, 0xbb, 0xb2, 0xb2, -1, -1},
- 3, NULL, 1 },
- /* COM_IF_IND_SS_1 */
- { " (IND-SS)", {0xb1, 0xb3, 0xb3, 0xb0, 0xb0, 0xb3, -1},
- 3, comspeedtab_mc16550, 1 },
- /* COM_IF_IND_SS_2 */
- { " (IND-SS)", {0xb9, 0xbb, 0xbb, 0xb2, 0xb2, 0xbb, -1},
- 3, comspeedtab_mc16550, 1 },
- /* COM_IF_PIO9032B_1 */
- { " (PIO9032B)", {0xb1, 0xb3, 0xb3, 0xb0, 0xb0, 0xb8, -1},
- 7, comspeedtab_pio9032b, 1 },
- /* COM_IF_PIO9032B_2 */
- { " (PIO9032B)", {0xb9, 0xbb, 0xbb, 0xb2, 0xb2, 0xba, -1},
- 7, comspeedtab_pio9032b, 1 },
- /* COM_IF_B98_01_1 */
- { " (B98-01)", {0xb1, 0xb3, 0xb3, 0xb0, 0xb0, 0xd1, 0xd3},
- 7, comspeedtab_b98_01, 0 },
- /* COM_IF_B98_01_2 */
- { " (B98-01)", {0xb9, 0xbb, 0xbb, 0xb2, 0xb2, 0xd5, 0xd7},
- 7, comspeedtab_b98_01, 0 },
-};
-#define PC98SIO_data_port(type) (if_8251_type[type].port_table[0])
-#define PC98SIO_cmd_port(type) (if_8251_type[type].port_table[1])
-#define PC98SIO_sts_port(type) (if_8251_type[type].port_table[2])
-#define PC98SIO_in_modem_port(type) (if_8251_type[type].port_table[3])
-#define PC98SIO_intr_ctrl_port(type) (if_8251_type[type].port_table[4])
-#define PC98SIO_baud_rate_port(type) (if_8251_type[type].port_table[5])
-#define PC98SIO_func_port(type) (if_8251_type[type].port_table[6])
-
-#define I8251F_data 0x130
-#define I8251F_lsr 0x132
-#define I8251F_msr 0x134
-#define I8251F_iir 0x136
-#define I8251F_fcr 0x138
-#define I8251F_div 0x13a
-
-
-struct {
- char *name;
- short irr_read;
- short irr_write;
- short port_shift;
- short io_size;
- struct speedtab *speedtab;
-} if_16550a_type[] = {
- /* COM_IF_RSA98 */
- { " (RSA-98)", -1, -1, 0, IO_COMSIZE, comspeedtab },
- /* COM_IF_NS16550 */
- { "", -1, -1, 0, IO_COMSIZE, comspeedtab },
- /* COM_IF_SECOND_CCU */
- { "", -1, -1, 0, IO_COMSIZE, comspeedtab },
- /* COM_IF_MC16550II */
- { " (MC16550II)", -1, 0x1000, 8, 1, comspeedtab_mc16550 },
- /* COM_IF_MCRS98 */
- { " (MC-RS98)", -1, 0x1000, 8, 1, comspeedtab_mc16550 },
- /* COM_IF_RSB3000 */
- { " (RSB-3000)", 0xbf, -1, 1, 1, comspeedtab_rsb384 },
- /* COM_IF_RSB384 */
- { " (RSB-384)", 0xbf, -1, 1, 1, comspeedtab_rsb384 },
- /* COM_IF_MODEM_CARD */
- { "", -1, -1, 0, IO_COMSIZE, comspeedtab },
- /* COM_IF_RSA98III */
- { " (RSA-98III)", -1, -1, 0, 16, comspeedtab_rsa },
- /* COM_IF_ESP98 */
- { " (ESP98)", -1, -1, 1, 1, comspeedtab_mc16550 },
-};
-#endif /* PC98 */
-
-#ifdef COM_ESP
-#ifdef PC98
-
-/* XXX configure this properly. */
-static Port_t likely_com_ports[] = { 0, 0xb0, 0xb1, 0 };
-static Port_t likely_esp_ports[] = { 0xc0d0, 0 };
-
-#define ESP98_CMD1 (ESP_CMD1 * 0x100)
-#define ESP98_CMD2 (ESP_CMD2 * 0x100)
-#define ESP98_STATUS1 (ESP_STATUS1 * 0x100)
-#define ESP98_STATUS2 (ESP_STATUS2 * 0x100)
-
-#else /* PC98 */
-
-/* XXX configure this properly. */
-static Port_t likely_com_ports[] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, };
-static Port_t likely_esp_ports[] = { 0x140, 0x180, 0x280, 0 };
-
-#endif /* PC98 */
-#endif
-
-/*
- * handle sysctl read/write requests for console speed
- *
- * In addition to setting comdefaultrate for I/O through /dev/console,
- * also set the initial and lock values for the /dev/ttyXX device
- * if there is one associated with the console. Finally, if the /dev/tty
- * device has already been open, change the speed on the open running port
- * itself.
- */
-
-static int
-sysctl_machdep_comdefaultrate SYSCTL_HANDLER_ARGS
-{
- int error, s;
- speed_t newspeed;
- struct com_s *com;
- struct tty *tp;
-
- newspeed = comdefaultrate;
-
- error = sysctl_handle_opaque(oidp, &newspeed, sizeof newspeed, req);
- if (error || !req->newptr)
- return (error);
-
- comdefaultrate = newspeed;
-
- if (comconsole < 0) /* serial console not selected? */
- return (0);
-
- com = com_addr(comconsole);
- if (com == NULL)
- return (ENXIO);
-
- /*
- * set the initial and lock rates for /dev/ttydXX and /dev/cuaXX
- * (note, the lock rates really are boolean -- if non-zero, disallow
- * speed changes)
- */
- com->it_in.c_ispeed = com->it_in.c_ospeed =
- com->lt_in.c_ispeed = com->lt_in.c_ospeed =
- com->it_out.c_ispeed = com->it_out.c_ospeed =
- com->lt_out.c_ispeed = com->lt_out.c_ospeed = comdefaultrate;
-
- /*
- * if we're open, change the running rate too
- */
- tp = com->tp;
- if (tp && (tp->t_state & TS_ISOPEN)) {
- tp->t_termios.c_ispeed =
- tp->t_termios.c_ospeed = comdefaultrate;
- s = spltty();
- error = comparam(tp, &tp->t_termios);
- splx(s);
- }
- return error;
-}
-
-SYSCTL_PROC(_machdep, OID_AUTO, conspeed, CTLTYPE_INT | CTLFLAG_RW,
- 0, 0, sysctl_machdep_comdefaultrate, "I", "");
-
-#define SET_FLAG(dev, bit) device_set_flags(dev, device_get_flags(dev) | (bit))
-#define CLR_FLAG(dev, bit) device_set_flags(dev, device_get_flags(dev) & ~(bit))
-
-#if NCARD > 0
-static int
-sio_pccard_probe(dev)
- device_t dev;
-{
- /* Do not probe IRQ - pccard doesn't turn on the interrupt line */
- /* until bus_setup_intr */
- SET_FLAG(dev, COM_C_NOPROBE);
-
- return (sioprobe(dev));
-}
-
-static int
-sio_pccard_attach(dev)
- device_t dev;
-{
- return (sioattach(dev));
-}
-
-/*
- * sio_detach - unload the driver and clear the table.
- * XXX TODO:
- * This is usually called when the card is ejected, but
- * can be caused by a modunload of a controller driver.
- * The idea is to reset the driver's view of the device
- * and ensure that any driver entry points such as
- * read and write do not hang.
- */
-static int
-sio_pccard_detach(dev)
- device_t dev;
-{
- struct com_s *com;
-
- com = (struct com_s *) device_get_softc(dev);
- if (com == NULL) {
- device_printf(dev, "NULL com in siounload\n");
- return (0);
- }
- if (com->iobase == 0) {
- device_printf(dev, "already unloaded!\n");
- return (0);
- }
- com->gone = 1;
- if (com->irqres) {
- bus_teardown_intr(dev, com->irqres, com->cookie);
- bus_release_resource(dev, SYS_RES_IRQ, 0, com->irqres);
- }
- if (com->ioportres)
- bus_release_resource(dev, SYS_RES_IOPORT, 0, com->ioportres);
- if (com->tp && (com->tp->t_state & TS_ISOPEN)) {
- device_printf(dev, "still open, forcing close\n");
- com->tp->t_gen++;
- ttyclose(com->tp);
- ttwakeup(com->tp);
- ttwwakeup(com->tp);
- } else {
- if (com->ibuf != NULL)
- free(com->ibuf, M_DEVBUF);
- }
- device_printf(dev, "unloaded\n");
- return (0);
-}
-#endif /* NCARD > 0 */
-
-
-static struct isa_pnp_id sio_ids[] = {
- {0x0005d041, "Standard PC COM port"}, /* PNP0500 */
- {0x0105d041, "16550A-compatible COM port"}, /* PNP0501 */
- {0x0205d041, "Multiport serial device (non-intelligent 16550)"}, /* PNP0502 */
- {0x1005d041, "Generic IRDA-compatible device"}, /* PNP0510 */
- {0x1105d041, "Generic IRDA-compatible device"}, /* PNP0511 */
- /* Devices that do not have a compatid */
- {0x7602a904, NULL}, /* AEI0276 - 56K v.90 Fax Modem (LKT) */
- {0x00007905, NULL}, /* AKY0000 - 56K Plug&Play Modem */
- {0x01405407, NULL}, /* AZT4001 - AZT3000 PnP SOUND DEVICE, MODEM */
- {0x56039008, NULL}, /* BDP0356 - Best Data 56x2 */
- {0x36339008, NULL}, /* BDP3336 - Best Data Prods. 336F */
- {0x0014490a, NULL}, /* BRI1400 - Boca 33.6 PnP */
- {0x0015490a, NULL}, /* BRI1500 - Internal Fax Data */
- {0x0034490a, NULL}, /* BRI3400 - Internal ACF Modem */
- {0x00b4490a, NULL}, /* BRIB400 - Boca 56k PnP */
- {0x0030320d, NULL}, /* CIR3000 - Cirrus Logic V43 */
- {0x0100440e, NULL}, /* CRD0001 - Cardinal MVP288IV ? */
- {0x1200c31e, NULL}, /* GVC0012 - VF1128HV-R9 (win modem?) */
- {0x0303c31e, NULL}, /* GVC0303 - MaxTech 33.6 PnP D/F/V */
- {0x0505c31e, NULL}, /* GVC0505 - GVC 56k Faxmodem */
- {0x0050c31e, NULL}, /* GVC5000 - some GVC modem */
- {0x3800f91e, NULL}, /* GWY0038 - Telepath with v.90 */
- {0x9062f91e, NULL}, /* GWY6290 - Telepath with x2 Technology */
- {0x0000f435, NULL}, /* MOT0000 - Motorola ModemSURFR 33.6 Intern */
- {0x5015f435, NULL}, /* MOT1550 - Motorola ModemSURFR 56K Modem */
- {0xf015f435, NULL}, /* MOT15F0 - Motorola VoiceSURFR 56K Modem */
- {0x6045f435, NULL}, /* MOT4560 - Motorola ? */
- {0x61e7a338, NULL}, /* NECE761 - 33.6Modem */
- {0x39804f3f, NULL}, /* OZO8039 - Zoom 56k flex */
- {0x3024a341, NULL}, /* PMC2430 - Pace 56 Voice Internal Modem */
- {0x1000eb49, NULL}, /* ROK0010 - Rockwell ? */
- {0x5002734a, NULL}, /* RSS0250 - 5614Jx3(G) Internal Modem */
- {0xc100ad4d, NULL}, /* SMM00C1 - Leopard 56k PnP */
- {0x9012b04e, NULL}, /* SUP1290 - Supra ? */
- {0x1013b04e, NULL}, /* SUP1310 - SupraExpress 336i PnP */
- {0x8013b04e, NULL}, /* SUP1380 - SupraExpress 288i PnP Voice */
- {0x8113b04e, NULL}, /* SUP1381 - SupraExpress 336i PnP Voice */
- {0x5016b04e, NULL}, /* SUP1650 - Supra 336i Sp Intl */
- {0x7420b04e, NULL}, /* SUP2070 - Supra ? */
- {0x8020b04e, NULL}, /* SUP2080 - Supra ? */
- {0x8420b04e, NULL}, /* SUP2084 - SupraExpress 56i PnP */
- {0x7121b04e, NULL}, /* SUP2171 - SupraExpress 56i Sp? */
- {0x8024b04e, NULL}, /* SUP2480 - Supra ? */
- {0x01007256, NULL}, /* USR0001 - U.S. Robotics Inc., Sportster W */
- {0x02007256, NULL}, /* USR0002 - U.S. Robotics Inc. Sportster 33. */
- {0x04007256, NULL}, /* USR0004 - USR Sportster 14.4k */
- {0x06007256, NULL}, /* USR0006 - USR Sportster 33.6k */
- {0x11007256, NULL}, /* USR0011 - USR ? */
- {0x01017256, NULL}, /* USR0101 - USR ? */
- {0x30207256, NULL}, /* USR2030 - U.S.Robotics Inc. Sportster 560 */
- {0x50207256, NULL}, /* USR2050 - U.S.Robotics Inc. Sportster 33. */
- {0x70207256, NULL}, /* USR2070 - U.S.Robotics Inc. Sportster 560 */
- {0x30307256, NULL}, /* USR3030 - U.S. Robotics 56K FAX INT */
- {0x31307256, NULL}, /* USR3031 - U.S. Robotics 56K FAX INT */
- {0x70307256, NULL}, /* USR3070 - U.S. Robotics 56K Voice INT */
- {0x90307256, NULL}, /* USR3090 - USR ? */
- {0x90917256, NULL}, /* USR9190 - USR 56k Voice INT */
- {0x0300695c, NULL}, /* WCI0003 - Fax/Voice/Modem/Speakphone/Asvd */
- {0x61f7896a, NULL}, /* ZTIF761 - Zoom ComStar 33.6 */
-#ifdef PC98
- {0x0100e4a5, "RSA-98III"},
-#endif
- {0}
-};
-
-
-
-static int
-sio_isa_probe(dev)
- device_t dev;
-{
-#ifdef PC98
- int logical_id;
-#endif
- /* Check isapnp ids */
- if (ISA_PNP_PROBE(device_get_parent(dev), dev, sio_ids) == ENXIO)
- return (ENXIO);
-#ifdef PC98
- logical_id = isa_get_logicalid(dev);
- if (logical_id == 0x0100e4a5) /* RSA-98III */
- device_set_flags(dev, COM_IF_RSA98III << 24);
-#endif
- return (sioprobe(dev));
-}
-
-static int
-sioprobe(dev)
- device_t dev;
-{
-#if 0
- static bool_t already_init;
- device_t xdev;
-#endif
- bool_t failures[10];
- int fn;
- device_t idev;
- Port_t iobase;
- intrmask_t irqmap[4];
- intrmask_t irqs;
- u_char mcr_image;
- int result;
- u_long xirq;
- u_int flags = device_get_flags(dev);
- int rid;
- struct resource *port;
-#ifdef PC98
- int irqout=0;
- int tmp;
- int port_shift = 0;
- struct siodev iod;
- Port_t rsabase;
-#endif
-
- rid = 0;
-#ifdef PC98
- port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
- 0, ~0, 1, RF_ACTIVE); /* XXX */
-#else
- port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
- 0, ~0, IO_COMSIZE, RF_ACTIVE);
-#endif
- if (!port)
- return (ENXIO);
-
-#if 0
- /*
- * XXX this is broken - when we are first called, there are no
- * previously configured IO ports. We could hard code
- * 0x3f8, 0x2f8, 0x3e8, 0x2e8 etc but that's probably worse.
- * This code has been doing nothing since the conversion since
- * "count" is zero the first time around.
- */
- if (!already_init) {
- /*
- * Turn off MCR_IENABLE for all likely serial ports. An unused
- * port with its MCR_IENABLE gate open will inhibit interrupts
- * from any used port that shares the interrupt vector.
- * XXX the gate enable is elsewhere for some multiports.
- */
- device_t *devs;
- int count, i, xioport;
-#ifdef PC98
- int xiftype;
-#endif
-
- devclass_get_devices(sio_devclass, &devs, &count);
-#ifdef PC98
- for (i = 0; i < count; i++) {
- xdev = devs[i];
- xioport = bus_get_resource_start(xdev, SYS_RES_IOPORT, 0);
- xiftype = GET_IFTYPE(device_get_flags(xdev));
- if (device_is_enabled(xdev) && xioport > 0) {
- if (IS_8251(xiftype))
- outb(xioport & 0xff00) | PC98SIO_cmd_port(xiftype & 0x0f), 0xf2);
- else {
- if (xiftype == COM_IF_RSA98III)
- xioport += 8;
- outb(xioport + (com_mcr << if_16550a_type[xiftype & 0x0f].port_shift), 0);
- }
- }
- }
-#else
- for (i = 0; i < count; i++) {
- xdev = devs[i];
- if (device_is_enabled(xdev) &&
- bus_get_resource(xdev, SYS_RES_IOPORT, 0, &xioport,
- NULL) == 0)
- outb(xioport + com_mcr, 0);
- }
-#endif
- free(devs, M_TEMP);
- already_init = TRUE;
- }
-#endif
-
- if (COM_LLCONSOLE(flags)) {
- printf("sio%d: reserved for low-level i/o\n",
- device_get_unit(dev));
- bus_release_resource(dev, SYS_RES_IOPORT, rid, port);
- return (ENXIO);
- }
-
-#ifdef PC98
- DELAY(10);
-
- /*
- * If the port is i8251 UART (internal, B98_01)
- */
- if (pc98_check_if_type(dev, &iod) == -1)
- return (ENXIO);
- if (iod.irq > 0)
- bus_set_resource(dev, SYS_RES_IRQ, 0, iod.irq, 1);
- if (IS_8251(iod.if_type)) {
- outb(iod.cmd, 0);
- DELAY(10);
- outb(iod.cmd, 0);
- DELAY(10);
- outb(iod.cmd, 0);
- DELAY(10);
- outb(iod.cmd, CMD8251_RESET);
- DELAY(1000); /* for a while...*/
- outb(iod.cmd, 0xf2); /* MODE (dummy) */
- DELAY(10);
- outb(iod.cmd, 0x01); /* CMD (dummy) */
- DELAY(1000); /* for a while...*/
- if (( inb(iod.sts) & STS8251_TxEMP ) == 0 ) {
- result = (ENXIO);
- }
- if (if_8251_type[iod.if_type & 0x0f].check_irq) {
- COM_INT_DISABLE
- tmp = ( inb( iod.ctrl ) & ~(IEN_Rx|IEN_TxEMP|IEN_Tx));
- outb( iod.ctrl, tmp|IEN_TxEMP );
- DELAY(10);
- result = isa_irq_pending() ? 0 : ENXIO;
- outb( iod.ctrl, tmp );
- COM_INT_ENABLE
- } else {
- /*
- * B98_01 doesn't activate TxEMP interrupt line
- * when being reset, so we can't check irq pending.
- */
- result = 0;
- }
- if (epson_machine_id==0x20) { /* XXX */
- result = 0;
- }
- bus_release_resource(dev, SYS_RES_IOPORT, rid, port);
- return result;
- }
-#endif /* PC98 */
- /*
- * If the device is on a multiport card and has an AST/4
- * compatible interrupt control register, initialize this
- * register and prepare to leave MCR_IENABLE clear in the mcr.
- * Otherwise, prepare to set MCR_IENABLE in the mcr.
- * Point idev to the device struct giving the correct id_irq.
- * This is the struct for the master device if there is one.
- */
- idev = dev;
- mcr_image = MCR_IENABLE;
-#ifdef COM_MULTIPORT
- if (COM_ISMULTIPORT(flags)) {
- Port_t xiobase;
- u_long io;
-
- idev = devclass_get_device(sio_devclass, COM_MPMASTER(flags));
- if (idev == NULL) {
- printf("sio%d: master device %d not configured\n",
- device_get_unit(dev), COM_MPMASTER(flags));
- idev = dev;
- }
-#ifndef PC98
- if (!COM_NOTAST4(flags)) {
- if (bus_get_resource(idev, SYS_RES_IOPORT, 0, &io,
- NULL) == 0) {
- xiobase = io;
- if (bus_get_resource(idev, SYS_RES_IRQ, 0,
- NULL, NULL) == 0)
- outb(xiobase + com_scr, 0x80);
- else
- outb(xiobase + com_scr, 0);
- }
- mcr_image = 0;
- }
-#endif
- }
-#endif /* COM_MULTIPORT */
- if (bus_get_resource(idev, SYS_RES_IRQ, 0, NULL, NULL) != 0)
- mcr_image = 0;
-
- bzero(failures, sizeof failures);
- iobase = rman_get_start(port);
-
-#ifdef PC98
- if (iod.if_type == COM_IF_RSA98III) {
- mcr_image = 0;
-
- rsabase = iobase & 0xfff0;
- if (rsabase != iobase)
- return(0);
- iobase += 8;
-
- outb(rsabase + rsa_msr, 0x04);
- outb(rsabase + rsa_frr, 0x00);
- if ((inb(rsabase + rsa_srr) & 0x36) != 0x36)
- return (0);
- outb(rsabase + rsa_ier, 0x00);
- outb(rsabase + rsa_frr, 0x00);
- outb(rsabase + rsa_tivsr, 0x00);
- outb(rsabase + rsa_tcr, 0x00);
- }
-
- tmp = if_16550a_type[iod.if_type & 0x0f].irr_write;
- if (tmp != -1) {
- /* MC16550II */
- switch (isa_get_irq(idev)) {
- case 3: irqout = 4; break;
- case 5: irqout = 5; break;
- case 6: irqout = 6; break;
- case 12: irqout = 7; break;
- default:
- printf("sio%d: irq configuration error\n",
- device_get_unit(dev));
- return (0);
- }
- outb((isa_get_port(dev) & 0x00ff) | tmp, irqout);
- }
- port_shift = if_16550a_type[iod.if_type & 0x0f].port_shift;
-#endif
-
- /*
- * We don't want to get actual interrupts, just masked ones.
- * Interrupts from this line should already be masked in the ICU,
- * but mask them in the processor as well in case there are some
- * (misconfigured) shared interrupts.
- */
- disable_intr();
-/* EXTRA DELAY? */
-
- /*
- * Initialize the speed and the word size and wait long enough to
- * drain the maximum of 16 bytes of junk in device output queues.
- * The speed is undefined after a master reset and must be set
- * before relying on anything related to output. There may be
- * junk after a (very fast) soft reboot and (apparently) after
- * master reset.
- * XXX what about the UART bug avoided by waiting in comparam()?
- * We don't want to to wait long enough to drain at 2 bps.
- */
- if (iobase == siocniobase)
- DELAY((16 + 1) * 1000000 / (comdefaultrate / 10));
- else {
-#ifdef PC98
- tmp = ttspeedtab(SIO_TEST_SPEED,
- if_16550a_type[iod.if_type & 0x0f].speedtab);
- outb(iobase + (com_cfcr << port_shift), CFCR_DLAB|CFCR_8BITS);
- outb(iobase + (com_dlbl << port_shift), tmp & 0xff);
- outb(iobase + (com_dlbh << port_shift), (tmp >> 8) & 0xff);
- outb(iobase + (com_cfcr << port_shift), CFCR_8BITS);
-#else
- outb(iobase + com_cfcr, CFCR_DLAB | CFCR_8BITS);
- outb(iobase + com_dlbl, COMBRD(SIO_TEST_SPEED) & 0xff);
- outb(iobase + com_dlbh, (u_int) COMBRD(SIO_TEST_SPEED) >> 8);
- outb(iobase + com_cfcr, CFCR_8BITS);
-#endif
- DELAY((16 + 1) * 1000000 / (SIO_TEST_SPEED / 10));
- }
-
- /*
- * Enable the interrupt gate and disable device interupts. This
- * should leave the device driving the interrupt line low and
- * guarantee an edge trigger if an interrupt can be generated.
- */
-/* EXTRA DELAY? */
-#ifdef PC98
- outb(iobase + (com_mcr << port_shift), mcr_image);
- outb(iobase + (com_ier << port_shift), 0);
-#else
- outb(iobase + com_mcr, mcr_image);
- outb(iobase + com_ier, 0);
-#endif
- DELAY(1000); /* XXX */
- irqmap[0] = isa_irq_pending();
-
- /*
- * Attempt to set loopback mode so that we can send a null byte
- * without annoying any external device.
- */
-/* EXTRA DELAY? */
-#ifdef PC98
- outb(iobase + (com_mcr << port_shift), mcr_image | MCR_LOOPBACK);
-#else
- outb(iobase + com_mcr, mcr_image | MCR_LOOPBACK);
-#endif
-
- /*
- * Attempt to generate an output interrupt. On 8250's, setting
- * IER_ETXRDY generates an interrupt independent of the current
- * setting and independent of whether the THR is empty. On 16450's,
- * setting IER_ETXRDY generates an interrupt independent of the
- * current setting. On 16550A's, setting IER_ETXRDY only
- * generates an interrupt when IER_ETXRDY is not already set.
- */
-#ifdef PC98
- outb(iobase + (com_ier << port_shift), IER_ETXRDY);
- if (iod.if_type == COM_IF_RSA98III)
- outb(rsabase + rsa_ier, 0x04);
-#else
- outb(iobase + com_ier, IER_ETXRDY);
-#endif /* PC98 */
-
- /*
- * On some 16x50 incompatibles, setting IER_ETXRDY doesn't generate
- * an interrupt. They'd better generate one for actually doing
- * output. Loopback may be broken on the same incompatibles but
- * it's unlikely to do more than allow the null byte out.
- */
-#ifdef PC98
- outb(iobase + (com_data << port_shift), 0);
-#else
- outb(iobase + com_data, 0);
-#endif
- DELAY((1 + 2) * 1000000 / (SIO_TEST_SPEED / 10));
-
- /*
- * Turn off loopback mode so that the interrupt gate works again
- * (MCR_IENABLE was hidden). This should leave the device driving
- * an interrupt line high. It doesn't matter if the interrupt
- * line oscillates while we are not looking at it, since interrupts
- * are disabled.
- */
-/* EXTRA DELAY? */
-#ifdef PC98
- outb(iobase + (com_mcr << port_shift), mcr_image);
-#else
- outb(iobase + com_mcr, mcr_image);
-#endif /* PC98 */
-
- /*
- * Some pcmcia cards have the "TXRDY bug", so we check everyone
- * for IIR_TXRDY implementation ( Palido 321s, DC-1S... )
- */
- if (COM_NOPROBE(flags)) {
- /* Reading IIR register twice */
- for (fn = 0; fn < 2; fn ++) {
- DELAY(10000);
-#ifdef PC98
- failures[6] = inb(iobase + (com_iir << port_shift));
-#else
- failures[6] = inb(iobase + com_iir);
-#endif
- }
- /* Check IIR_TXRDY clear ? */
- result = 0;
- if (failures[6] & IIR_TXRDY) {
- /* Nop, Double check with clearing IER */
-#ifdef PC98
- outb(iobase + (com_ier << port_shift), 0);
- if (inb(iobase + (com_iir << port_shift))
- & IIR_NOPEND) {
-#else
- outb(iobase + com_ier, 0);
- if (inb(iobase + com_iir) & IIR_NOPEND) {
-#endif
- /* Ok. we're familia this gang */
- SET_FLAG(dev, COM_C_IIR_TXRDYBUG);
- } else {
- /* Unknown, Just omit this chip.. XXX */
- result = ENXIO;
- }
- } else {
- /* OK. this is well-known guys */
- CLR_FLAG(dev, COM_C_IIR_TXRDYBUG);
- }
-#ifdef PC98
- outb(iobase + (com_cfcr << port_shift), CFCR_8BITS);
-#else
- outb(iobase + com_cfcr, CFCR_8BITS);
-#endif
- enable_intr();
- bus_release_resource(dev, SYS_RES_IOPORT, rid, port);
- return (iobase == siocniobase ? 0 : result);
- }
-
- /*
- * Check that
- * o the CFCR, IER and MCR in UART hold the values written to them
- * (the values happen to be all distinct - this is good for
- * avoiding false positive tests from bus echoes).
- * o an output interrupt is generated and its vector is correct.
- * o the interrupt goes away when the IIR in the UART is read.
- */
-/* EXTRA DELAY? */
-#ifdef PC98
- failures[0] = inb(iobase + (com_cfcr << port_shift)) - CFCR_8BITS;
- failures[1] = inb(iobase + (com_ier << port_shift)) - IER_ETXRDY;
- failures[2] = inb(iobase + (com_mcr << port_shift)) - mcr_image;
-#else
- failures[0] = inb(iobase + com_cfcr) - CFCR_8BITS;
- failures[1] = inb(iobase + com_ier) - IER_ETXRDY;
- failures[2] = inb(iobase + com_mcr) - mcr_image;
-#endif
- DELAY(10000); /* Some internal modems need this time */
- irqmap[1] = isa_irq_pending();
-#ifdef PC98
- failures[4] = (inb(iobase + (com_iir << port_shift)) & IIR_IMASK)
- - IIR_TXRDY;
- if (iod.if_type == COM_IF_RSA98III)
- inb(rsabase + rsa_srr);
-#else
- failures[4] = (inb(iobase + com_iir) & IIR_IMASK) - IIR_TXRDY;
-#endif
- DELAY(1000); /* XXX */
- irqmap[2] = isa_irq_pending();
-#ifdef PC98
- failures[6] = (inb(iobase + (com_iir << port_shift)) & IIR_IMASK)
- - IIR_NOPEND;
- if (iod.if_type == COM_IF_RSA98III)
- inb(rsabase + rsa_srr);
-#else
- failures[6] = (inb(iobase + com_iir) & IIR_IMASK) - IIR_NOPEND;
-#endif
-
- /*
- * Turn off all device interrupts and check that they go off properly.
- * Leave MCR_IENABLE alone. For ports without a master port, it gates
- * the OUT2 output of the UART to
- * the ICU input. Closing the gate would give a floating ICU input
- * (unless there is another device driving it) and spurious interrupts.
- * (On the system that this was first tested on, the input floats high
- * and gives a (masked) interrupt as soon as the gate is closed.)
- */
-#ifdef PC98
- outb(iobase + (com_ier << port_shift), 0);
- outb(iobase + (com_cfcr << port_shift), CFCR_8BITS);
- failures[7] = inb(iobase + (com_ier << port_shift));
- if (iod.if_type == COM_IF_RSA98III)
- outb(rsabase + rsa_ier, 0x00);
-#else
- outb(iobase + com_ier, 0);
- outb(iobase + com_cfcr, CFCR_8BITS); /* dummy to avoid bus echo */
- failures[7] = inb(iobase + com_ier);
-#endif
- DELAY(1000); /* XXX */
- irqmap[3] = isa_irq_pending();
-#ifdef PC98
- failures[9] = (inb(iobase + (com_iir << port_shift)) & IIR_IMASK)
- - IIR_NOPEND;
- if (iod.if_type == COM_IF_RSA98III) {
- inb(rsabase + rsa_srr);
- outb(rsabase + rsa_frr, 0x00);
- }
-#else
- failures[9] = (inb(iobase + com_iir) & IIR_IMASK) - IIR_NOPEND;
-#endif
-
- enable_intr();
-
- irqs = irqmap[1] & ~irqmap[0];
- if (bus_get_resource(idev, SYS_RES_IRQ, 0, &xirq, NULL) == 0 &&
- ((1 << xirq) & irqs) == 0)
- printf(
- "sio%d: configured irq %ld not in bitmap of probed irqs %#x\n",
- device_get_unit(dev), xirq, irqs);
- if (bootverbose)
- printf("sio%d: irq maps: %#x %#x %#x %#x\n",
- device_get_unit(dev),
- irqmap[0], irqmap[1], irqmap[2], irqmap[3]);
-
- result = 0;
- for (fn = 0; fn < sizeof failures; ++fn)
- if (failures[fn]) {
-#ifdef PC98
- outb(iobase + (com_mcr << port_shift), 0);
-#else
- outb(iobase + com_mcr, 0);
-#endif
- result = ENXIO;
- if (bootverbose) {
- printf("sio%d: probe failed test(s):",
- device_get_unit(dev));
- for (fn = 0; fn < sizeof failures; ++fn)
- if (failures[fn])
- printf(" %d", fn);
- printf("\n");
- }
- break;
- }
- bus_release_resource(dev, SYS_RES_IOPORT, rid, port);
- return (iobase == siocniobase ? 0 : result);
-}
-
-#ifdef COM_ESP
-static int
-espattach(com, esp_port)
- struct com_s *com;
- Port_t esp_port;
-{
- u_char dips;
- u_char val;
-
- /*
- * Check the ESP-specific I/O port to see if we're an ESP
- * card. If not, return failure immediately.
- */
- if ((inb(esp_port) & 0xf3) == 0) {
- printf(" port 0x%x is not an ESP board?\n", esp_port);
- return (0);
- }
-
- /*
- * We've got something that claims to be a Hayes ESP card.
- * Let's hope so.
- */
-
- /* Get the dip-switch configuration */
-#ifdef PC98
- outb(esp_port + ESP98_CMD1, ESP_GETDIPS);
- dips = inb(esp_port + ESP98_STATUS1);
-#else
- outb(esp_port + ESP_CMD1, ESP_GETDIPS);
- dips = inb(esp_port + ESP_STATUS1);
-#endif
-
- /*
- * Bits 0,1 of dips say which COM port we are.
- */
-#ifdef PC98
- if ((com->iobase & 0xff) == likely_com_ports[dips & 0x03])
-#else
- if (com->iobase == likely_com_ports[dips & 0x03])
-#endif
- printf(" : ESP");
- else {
- printf(" esp_port has com %d\n", dips & 0x03);
- return (0);
- }
-
- /*
- * Check for ESP version 2.0 or later: bits 4,5,6 = 010.
- */
-#ifdef PC98
- outb(esp_port + ESP98_CMD1, ESP_GETTEST);
- val = inb(esp_port + ESP98_STATUS1); /* clear reg 1 */
- val = inb(esp_port + ESP98_STATUS2);
-#else
- outb(esp_port + ESP_CMD1, ESP_GETTEST);
- val = inb(esp_port + ESP_STATUS1); /* clear reg 1 */
- val = inb(esp_port + ESP_STATUS2);
-#endif
- if ((val & 0x70) < 0x20) {
- printf("-old (%o)", val & 0x70);
- return (0);
- }
-
- /*
- * Check for ability to emulate 16550: bit 7 == 1
- */
- if ((dips & 0x80) == 0) {
- printf(" slave");
- return (0);
- }
-
- /*
- * Okay, we seem to be a Hayes ESP card. Whee.
- */
- com->esp = TRUE;
- com->esp_port = esp_port;
- return (1);
-}
-#endif /* COM_ESP */
-
-static int
-sio_isa_attach(dev)
- device_t dev;
-{
- return (sioattach(dev));
-}
-
-static int
-sioattach(dev)
- device_t dev;
-{
- struct com_s *com;
-#ifdef COM_ESP
- Port_t *espp;
-#endif
- Port_t iobase;
- int unit;
- u_int flags;
- int rid;
- struct resource *port;
- int ret;
-#ifdef PC98
- int port_shift = 0;
- u_char *obuf;
- u_long obufsize;
-#endif
-
- rid = 0;
-#ifdef PC98
- port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
- 0, ~0, 1, RF_ACTIVE); /* XXX */
-#else
- port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
- 0, ~0, IO_COMSIZE, RF_ACTIVE);
-#endif
- if (!port)
- return (ENXIO);
-
- iobase = rman_get_start(port);
- unit = device_get_unit(dev);
- com = device_get_softc(dev);
- flags = device_get_flags(dev);
-
- if (unit >= sio_numunits)
- sio_numunits = unit + 1;
-
-#ifdef PC98
- obufsize = 256;
- if (GET_IFTYPE(flags) == COM_IF_RSA98III) {
- iobase += 8;
- obufsize = 2048;
- }
- if ((obuf = malloc(obufsize * 2, M_DEVBUF, M_NOWAIT)) == NULL)
- return ENXIO;
- bzero(obuf, obufsize * 2);
-#endif
-
- /*
- * sioprobe() has initialized the device registers as follows:
- * o cfcr = CFCR_8BITS.
- * It is most important that CFCR_DLAB is off, so that the
- * data port is not hidden when we enable interrupts.
- * o ier = 0.
- * Interrupts are only enabled when the line is open.
- * o mcr = MCR_IENABLE, or 0 if the port has AST/4 compatible
- * interrupt control register or the config specifies no irq.
- * Keeping MCR_DTR and MCR_RTS off might stop the external
- * device from sending before we are ready.
- */
- bzero(com, sizeof *com);
-#ifdef PC98
- com->obufsize = obufsize;
- com->obuf1 = obuf;
- com->obuf2 = obuf + obufsize;
-#endif
- com->unit = unit;
- com->ioportres = port;
- com->cfcr_image = CFCR_8BITS;
- com->dtr_wait = 3 * hz;
- com->loses_outints = COM_LOSESOUTINTS(flags) != 0;
- com->no_irq = bus_get_resource(dev, SYS_RES_IRQ, 0, NULL, NULL) != 0;
- com->tx_fifo_size = 1;
- com->obufs[0].l_head = com->obuf1;
- com->obufs[1].l_head = com->obuf2;
-
- com->iobase = iobase;
-#ifdef PC98
- com->pc98_if_type = GET_IFTYPE(flags);
-
- if (pc98_set_ioport(com) == -1) {
- port_shift = if_16550a_type[com->pc98_if_type & 0x0f].port_shift;
-
- com->data_port = iobase + (com_data << port_shift);
- com->int_id_port = iobase + (com_iir << port_shift);
- com->modem_ctl_port = iobase + (com_mcr << port_shift);
- com->mcr_image = inb(com->modem_ctl_port);
- com->line_status_port = iobase + (com_lsr << port_shift);
- com->modem_status_port = iobase + (com_msr << port_shift);
- com->intr_ctl_port = iobase + (com_ier << port_shift);
- }
- if (com->pc98_if_type == COM_IF_INTERNAL && pc98_check_8251fifo()) {
- com->pc98_8251fifo = 1;
- com->pc98_8251fifo_enable = 0;
- }
-#else /* not PC98 */
- com->data_port = iobase + com_data;
- com->int_id_port = iobase + com_iir;
- com->modem_ctl_port = iobase + com_mcr;
- com->mcr_image = inb(com->modem_ctl_port);
- com->line_status_port = iobase + com_lsr;
- com->modem_status_port = iobase + com_msr;
- com->intr_ctl_port = iobase + com_ier;
-#endif
-
- /*
- * We don't use all the flags from <sys/ttydefaults.h> since they
- * are only relevant for logins. It's important to have echo off
- * initially so that the line doesn't start blathering before the
- * echo flag can be turned off.
- */
- com->it_in.c_iflag = 0;
- com->it_in.c_oflag = 0;
- com->it_in.c_cflag = TTYDEF_CFLAG;
- com->it_in.c_lflag = 0;
- if (unit == comconsole) {
-#ifdef PC98
- if (IS_8251(com->pc98_if_type))
- DELAY(100000);
-#endif
- com->it_in.c_iflag = TTYDEF_IFLAG;
- com->it_in.c_oflag = TTYDEF_OFLAG;
- com->it_in.c_cflag = TTYDEF_CFLAG | CLOCAL;
- com->it_in.c_lflag = TTYDEF_LFLAG;
- com->lt_out.c_cflag = com->lt_in.c_cflag = CLOCAL;
- com->lt_out.c_ispeed = com->lt_out.c_ospeed =
- com->lt_in.c_ispeed = com->lt_in.c_ospeed =
- com->it_in.c_ispeed = com->it_in.c_ospeed = comdefaultrate;
- } else
- com->it_in.c_ispeed = com->it_in.c_ospeed = TTYDEF_SPEED;
- if (siosetwater(com, com->it_in.c_ispeed) != 0) {
- enable_intr();
- /*
- * Leave i/o resources allocated if this is a `cn'-level
- * console, so that other devices can't snarf them.
- */
- if (iobase != siocniobase)
- bus_release_resource(dev, SYS_RES_IOPORT, rid, port);
- return (ENOMEM);
- }
- enable_intr();
- termioschars(&com->it_in);
- com->it_out = com->it_in;
-
- /* attempt to determine UART type */
- printf("sio%d: type", unit);
-
-
-#ifndef PC98
-#ifdef COM_MULTIPORT
- if (!COM_ISMULTIPORT(flags) && !COM_IIR_TXRDYBUG(flags))
-#else
- if (!COM_IIR_TXRDYBUG(flags))
-#endif
- {
- u_char scr;
- u_char scr1;
- u_char scr2;
-
- scr = inb(iobase + com_scr);
- outb(iobase + com_scr, 0xa5);
- scr1 = inb(iobase + com_scr);
- outb(iobase + com_scr, 0x5a);
- scr2 = inb(iobase + com_scr);
- outb(iobase + com_scr, scr);
- if (scr1 != 0xa5 || scr2 != 0x5a) {
- printf(" 8250");
- goto determined_type;
- }
- }
-#endif /* !PC98 */
-#ifdef PC98
- if (IS_8251(com->pc98_if_type)) {
- if (com->pc98_8251fifo && !COM_NOFIFO(flags))
- com->tx_fifo_size = 16;
- com_int_TxRx_disable( com );
- com_cflag_and_speed_set( com, com->it_in.c_cflag, comdefaultrate );
- com_tiocm_bic( com, TIOCM_DTR|TIOCM_RTS|TIOCM_LE );
- com_send_break_off( com );
-
- if (com->pc98_if_type == COM_IF_INTERNAL) {
- printf(" (internal%s%s)",
- com->pc98_8251fifo ? " fifo" : "",
- PC98SIO_baud_rate_port(com->pc98_if_type) != -1 ?
- " v-fast" : "");
- } else {
- printf(" 8251%s", if_8251_type[com->pc98_if_type & 0x0f].name);
- }
- } else {
- outb(iobase + (com_fifo << port_shift), FIFO_ENABLE | FIFO_RX_HIGH);
-#else
- outb(iobase + com_fifo, FIFO_ENABLE | FIFO_RX_HIGH);
-#endif /* PC98 */
- DELAY(100);
- com->st16650a = 0;
- switch (inb(com->int_id_port) & IIR_FIFO_MASK) {
- case FIFO_RX_LOW:
- printf(" 16450");
- break;
- case FIFO_RX_MEDL:
- printf(" 16450?");
- break;
- case FIFO_RX_MEDH:
- printf(" 16550?");
- break;
- case FIFO_RX_HIGH:
- if (COM_NOFIFO(flags)) {
- printf(" 16550A fifo disabled");
- } else {
- com->hasfifo = TRUE;
-#ifdef PC98
- com->tx_fifo_size = 0; /* XXX flag conflicts. */
- printf(" 16550A");
-#else
- if (COM_ST16650A(flags)) {
- com->st16650a = 1;
- com->tx_fifo_size = 32;
- printf(" ST16650A");
- } else {
- com->tx_fifo_size = COM_FIFOSIZE(flags);
- printf(" 16550A");
- }
-#endif
- }
-#ifdef PC98
- if (com->pc98_if_type == COM_IF_RSA98III) {
- com->tx_fifo_size = 2048;
- com->rsabase = isa_get_port(dev);
- outb(com->rsabase + rsa_ier, 0x00);
- outb(com->rsabase + rsa_frr, 0x00);
- }
-#endif
-
-#ifdef COM_ESP
-#ifdef PC98
- if (com->pc98_if_type == COM_IF_ESP98)
-#endif
- for (espp = likely_esp_ports; *espp != 0; espp++)
- if (espattach(com, *espp)) {
- com->tx_fifo_size = 1024;
- break;
- }
-#endif
- if (!com->st16650a) {
- if (!com->tx_fifo_size)
- com->tx_fifo_size = 16;
- else
- printf(" lookalike with %d bytes FIFO",
- com->tx_fifo_size);
- }
-
- break;
- }
-
-#ifdef PC98
- if (com->pc98_if_type == COM_IF_RSB3000) {
- /* Set RSB-2000/3000 Extended Buffer mode. */
- u_char lcr;
- lcr = inb(iobase + (com_cfcr << port_shift));
- outb(iobase + (com_cfcr << port_shift), lcr | CFCR_DLAB);
- outb(iobase + (com_emr << port_shift), EMR_EXBUFF | EMR_EFMODE);
- outb(iobase + (com_cfcr << port_shift), lcr);
- }
-#endif
-
-#ifdef COM_ESP
- if (com->esp) {
- /*
- * Set 16550 compatibility mode.
- * We don't use the ESP_MODE_SCALE bit to increase the
- * fifo trigger levels because we can't handle large
- * bursts of input.
- * XXX flow control should be set in comparam(), not here.
- */
-#ifdef PC98
- outb(com->esp_port + ESP98_CMD1, ESP_SETMODE);
- outb(com->esp_port + ESP98_CMD2, ESP_MODE_RTS | ESP_MODE_FIFO);
-#else
- outb(com->esp_port + ESP_CMD1, ESP_SETMODE);
- outb(com->esp_port + ESP_CMD2, ESP_MODE_RTS | ESP_MODE_FIFO);
-#endif
-
- /* Set RTS/CTS flow control. */
-#ifdef PC98
- outb(com->esp_port + ESP98_CMD1, ESP_SETFLOWTYPE);
- outb(com->esp_port + ESP98_CMD2, ESP_FLOW_RTS);
- outb(com->esp_port + ESP98_CMD2, ESP_FLOW_CTS);
-#else
- outb(com->esp_port + ESP_CMD1, ESP_SETFLOWTYPE);
- outb(com->esp_port + ESP_CMD2, ESP_FLOW_RTS);
- outb(com->esp_port + ESP_CMD2, ESP_FLOW_CTS);
-#endif
-
- /* Set flow-control levels. */
-#ifdef PC98
- outb(com->esp_port + ESP98_CMD1, ESP_SETRXFLOW);
- outb(com->esp_port + ESP98_CMD2, HIBYTE(768));
- outb(com->esp_port + ESP98_CMD2, LOBYTE(768));
- outb(com->esp_port + ESP98_CMD2, HIBYTE(512));
- outb(com->esp_port + ESP98_CMD2, LOBYTE(512));
-#else
- outb(com->esp_port + ESP_CMD1, ESP_SETRXFLOW);
- outb(com->esp_port + ESP_CMD2, HIBYTE(768));
- outb(com->esp_port + ESP_CMD2, LOBYTE(768));
- outb(com->esp_port + ESP_CMD2, HIBYTE(512));
- outb(com->esp_port + ESP_CMD2, LOBYTE(512));
-#endif
-
-#ifdef PC98
- /* Set UART clock prescaler. */
- outb(com->esp_port + ESP98_CMD1, ESP_SETCLOCK);
- outb(com->esp_port + ESP98_CMD2, 2); /* 4 times */
-#endif
- }
-#endif /* COM_ESP */
-#ifdef PC98
- printf("%s", if_16550a_type[com->pc98_if_type & 0x0f].name);
- outb(iobase + (com_fifo << port_shift), 0);
-#else
- outb(iobase + com_fifo, 0);
-determined_type: ;
-#endif
-
-#ifdef COM_MULTIPORT
- if (COM_ISMULTIPORT(flags)) {
- device_t masterdev;
-
- com->multiport = TRUE;
- printf(" (multiport");
- if (unit == COM_MPMASTER(flags))
- printf(" master");
- printf(")");
- masterdev = devclass_get_device(sio_devclass,
- COM_MPMASTER(flags));
- com->no_irq = (masterdev == NULL || bus_get_resource(masterdev,
- SYS_RES_IRQ, 0, NULL, NULL) != 0);
- }
-#endif /* COM_MULTIPORT */
-#ifdef PC98
- }
-#endif
- if (unit == comconsole)
- printf(", console");
- if (COM_IIR_TXRDYBUG(flags))
- printf(" with a bogus IIR_TXRDY register");
- printf("\n");
-
- if (!sio_registered) {
- register_swi(SWI_TTY, siopoll);
- sio_registered = TRUE;
- }
- make_dev(&sio_cdevsw, unit,
- UID_ROOT, GID_WHEEL, 0600, "ttyd%r", unit);
- make_dev(&sio_cdevsw, unit | CONTROL_INIT_STATE,
- UID_ROOT, GID_WHEEL, 0600, "ttyid%r", unit);
- make_dev(&sio_cdevsw, unit | CONTROL_LOCK_STATE,
- UID_ROOT, GID_WHEEL, 0600, "ttyld%r", unit);
- make_dev(&sio_cdevsw, unit | CALLOUT_MASK,
- UID_UUCP, GID_DIALER, 0660, "cuaa%r", unit);
- make_dev(&sio_cdevsw, unit | CALLOUT_MASK | CONTROL_INIT_STATE,
- UID_UUCP, GID_DIALER, 0660, "cuaia%r", unit);
- make_dev(&sio_cdevsw, unit | CALLOUT_MASK | CONTROL_LOCK_STATE,
- UID_UUCP, GID_DIALER, 0660, "cuala%r", unit);
- com->flags = flags;
- com->pps.ppscap = PPS_CAPTUREASSERT | PPS_CAPTURECLEAR;
- pps_init(&com->pps);
-
- rid = 0;
- com->irqres = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0ul, ~0ul, 1,
- RF_ACTIVE);
- if (com->irqres) {
- ret = BUS_SETUP_INTR(device_get_parent(dev), dev, com->irqres,
- INTR_TYPE_TTY | INTR_TYPE_FAST,
- siointr, com, &com->cookie);
- if (ret) {
- ret = BUS_SETUP_INTR(device_get_parent(dev), dev,
- com->irqres, INTR_TYPE_TTY,
- siointr, com, &com->cookie);
- if (ret == 0)
- device_printf(dev, "unable to activate interrupt in fast mode - using normal mode");
- }
- if (ret)
- device_printf(dev, "could not activate interrupt\n");
- }
-
- return (0);
-}
-
-static int
-sioopen(dev, flag, mode, p)
- dev_t dev;
- int flag;
- int mode;
- struct proc *p;
-{
- struct com_s *com;
- int error;
- Port_t iobase;
- int mynor;
- int s;
- struct tty *tp;
- int unit;
-#ifdef PC98
- int port_shift = 0;
-#endif
-
- mynor = minor(dev);
- unit = MINOR_TO_UNIT(mynor);
- com = com_addr(unit);
- if (com == NULL)
- return (ENXIO);
- if (com->gone)
- return (ENXIO);
- if (mynor & CONTROL_MASK)
- return (0);
- tp = dev->si_tty = com->tp = ttymalloc(com->tp);
- s = spltty();
-
-#ifdef PC98
- if (!IS_8251(com->pc98_if_type))
- port_shift = if_16550a_type[com->pc98_if_type & 0x0f].port_shift;
-#endif
- /*
- * We jump to this label after all non-interrupted sleeps to pick
- * up any changes of the device state.
- */
-open_top:
- while (com->state & CS_DTR_OFF) {
- error = tsleep(&com->dtr_wait, TTIPRI | PCATCH, "siodtr", 0);
- if (com_addr(unit) == NULL)
- return (ENXIO);
- if (error != 0 || com->gone)
- goto out;
- }
- if (tp->t_state & TS_ISOPEN) {
- /*
- * The device is open, so everything has been initialized.
- * Handle conflicts.
- */
- if (mynor & CALLOUT_MASK) {
- if (!com->active_out) {
- error = EBUSY;
- goto out;
- }
- } else {
- if (com->active_out) {
- if (flag & O_NONBLOCK) {
- error = EBUSY;
- goto out;
- }
- error = tsleep(&com->active_out,
- TTIPRI | PCATCH, "siobi", 0);
- if (com_addr(unit) == NULL)
- return (ENXIO);
- if (error != 0 || com->gone)
- goto out;
- goto open_top;
- }
- }
- if (tp->t_state & TS_XCLUDE &&
- suser(p)) {
- error = EBUSY;
- goto out;
- }
- } else {
- /*
- * The device isn't open, so there are no conflicts.
- * Initialize it. Initialization is done twice in many
- * cases: to preempt sleeping callin opens if we are
- * callout, and to complete a callin open after DCD rises.
- */
- tp->t_oproc = comstart;
- tp->t_param = comparam;
- tp->t_stop = comstop;
- tp->t_dev = dev;
- tp->t_termios = mynor & CALLOUT_MASK
- ? com->it_out : com->it_in;
-#ifdef PC98
- if (!IS_8251(com->pc98_if_type))
-#endif
- (void)commctl(com, TIOCM_DTR | TIOCM_RTS, DMSET);
- com->poll = com->no_irq;
- com->poll_output = com->loses_outints;
- ++com->wopeners;
- error = comparam(tp, &tp->t_termios);
- --com->wopeners;
- if (error != 0)
- goto out;
-#ifdef PC98
- if (IS_8251(com->pc98_if_type)) {
- com_tiocm_bis(com, TIOCM_DTR|TIOCM_RTS);
- pc98_msrint_start(dev);
- if (com->pc98_8251fifo) {
- com->pc98_8251fifo_enable = 1;
- outb(I8251F_fcr, CTRL8251F_ENABLE |
- CTRL8251F_XMT_RST | CTRL8251F_RCV_RST);
- }
- }
-#endif
- /*
- * XXX we should goto open_top if comparam() slept.
- */
- iobase = com->iobase;
- if (com->hasfifo) {
- /*
- * (Re)enable and drain fifos.
- *
- * Certain SMC chips cause problems if the fifos
- * are enabled while input is ready. Turn off the
- * fifo if necessary to clear the input. We test
- * the input ready bit after enabling the fifos
- * since we've already enabled them in comparam()
- * and to handle races between enabling and fresh
- * input.
- */
- while (TRUE) {
-#ifdef PC98
- outb(iobase + (com_fifo << port_shift),
- FIFO_RCV_RST | FIFO_XMT_RST
- | com->fifo_image);
- if (com->pc98_if_type == COM_IF_RSA98III)
- outb(com->rsabase + rsa_frr , 0x00);
-#else
- outb(iobase + com_fifo,
- FIFO_RCV_RST | FIFO_XMT_RST
- | com->fifo_image);
-#endif
- /*
- * XXX the delays are for superstitious
- * historical reasons. It must be less than
- * the character time at the maximum
- * supported speed (87 usec at 115200 bps
- * 8N1). Otherwise we might loop endlessly
- * if data is streaming in. We used to use
- * delays of 100. That usually worked
- * because DELAY(100) used to usually delay
- * for about 85 usec instead of 100.
- */
- DELAY(50);
-#ifndef PC98
- if (!(inb(com->line_status_port) & LSR_RXRDY))
-#else
- if (com->pc98_if_type == COM_IF_RSA98III
- ? !(inb(com->rsabase + rsa_srr) & 0x08)
- : !(inb(com->line_status_port) & LSR_RXRDY))
-#endif
- break;
-#ifdef PC98
- outb(iobase + (com_fifo << port_shift), 0);
-#else
- outb(iobase + com_fifo, 0);
-#endif
- DELAY(50);
- (void) inb(com->data_port);
- }
- }
-
- disable_intr();
-#ifdef PC98
- if (IS_8251(com->pc98_if_type)) {
- com_tiocm_bis(com, TIOCM_LE);
- com->pc98_prev_modem_status = pc98_get_modem_status(com);
- com_int_Rx_enable(com);
- } else {
-#endif
- (void) inb(com->line_status_port);
- (void) inb(com->data_port);
- com->prev_modem_status = com->last_modem_status
- = inb(com->modem_status_port);
- if (COM_IIR_TXRDYBUG(com->flags)) {
- outb(com->intr_ctl_port, IER_ERXRDY | IER_ERLS
- | IER_EMSC);
- } else {
- outb(com->intr_ctl_port, IER_ERXRDY | IER_ETXRDY
- | IER_ERLS | IER_EMSC);
- }
-#ifdef PC98
- if (com->pc98_if_type == COM_IF_RSA98III) {
- outb(com->rsabase + rsa_ier, 0x1d);
- outb(com->intr_ctl_port, IER_ERLS | IER_EMSC);
- }
-#endif
-#ifdef PC98
- }
-#endif
- enable_intr();
- /*
- * Handle initial DCD. Callout devices get a fake initial
- * DCD (trapdoor DCD). If we are callout, then any sleeping
- * callin opens get woken up and resume sleeping on "siobi"
- * instead of "siodcd".
- */
- /*
- * XXX `mynor & CALLOUT_MASK' should be
- * `tp->t_cflag & (SOFT_CARRIER | TRAPDOOR_CARRIER) where
- * TRAPDOOR_CARRIER is the default initial state for callout
- * devices and SOFT_CARRIER is like CLOCAL except it hides
- * the true carrier.
- */
-#ifdef PC98
- if ((IS_8251(com->pc98_if_type) &&
- (pc98_get_modem_status(com) & TIOCM_CAR)) ||
- (!IS_8251(com->pc98_if_type) &&
- (com->prev_modem_status & MSR_DCD)) ||
- mynor & CALLOUT_MASK)
-#else
- if (com->prev_modem_status & MSR_DCD || mynor & CALLOUT_MASK)
-#endif
- (*linesw[tp->t_line].l_modem)(tp, 1);
- }
- /*
- * Wait for DCD if necessary.
- */
- if (!(tp->t_state & TS_CARR_ON) && !(mynor & CALLOUT_MASK)
- && !(tp->t_cflag & CLOCAL) && !(flag & O_NONBLOCK)) {
- ++com->wopeners;
- error = tsleep(TSA_CARR_ON(tp), TTIPRI | PCATCH, "siodcd", 0);
- if (com_addr(unit) == NULL)
- return (ENXIO);
- --com->wopeners;
- if (error != 0 || com->gone)
- goto out;
- goto open_top;
- }
- error = (*linesw[tp->t_line].l_open)(dev, tp);
- disc_optim(tp, &tp->t_termios, com);
- if (tp->t_state & TS_ISOPEN && mynor & CALLOUT_MASK)
- com->active_out = TRUE;
- siosettimeout();
-out:
- splx(s);
- if (!(tp->t_state & TS_ISOPEN) && com->wopeners == 0)
- comhardclose(com);
- return (error);
-}
-
-static int
-sioclose(dev, flag, mode, p)
- dev_t dev;
- int flag;
- int mode;
- struct proc *p;
-{
- struct com_s *com;
- int mynor;
- int s;
- struct tty *tp;
-
- mynor = minor(dev);
- if (mynor & CONTROL_MASK)
- return (0);
- com = com_addr(MINOR_TO_UNIT(mynor));
- if (com == NULL)
- return (ENODEV);
- tp = com->tp;
- s = spltty();
- (*linesw[tp->t_line].l_close)(tp, flag);
-#ifdef PC98
- com->modem_checking = 0;
-#endif
- disc_optim(tp, &tp->t_termios, com);
- comstop(tp, FREAD | FWRITE);
- comhardclose(com);
- ttyclose(tp);
- siosettimeout();
- splx(s);
- if (com->gone) {
- printf("sio%d: gone\n", com->unit);
- s = spltty();
- if (com->ibuf != NULL)
- free(com->ibuf, M_DEVBUF);
- bzero(tp, sizeof *tp);
- splx(s);
- }
- return (0);
-}
-
-static void
-comhardclose(com)
- struct com_s *com;
-{
- Port_t iobase;
- int s;
- struct tty *tp;
- int unit;
-#ifdef PC98
- int port_shift = 0;
-#endif
-
- unit = com->unit;
- iobase = com->iobase;
- s = spltty();
- com->poll = FALSE;
- com->poll_output = FALSE;
- com->do_timestamp = FALSE;
- com->do_dcd_timestamp = FALSE;
- com->pps.ppsparam.mode = 0;
-#ifdef PC98
- if (IS_8251(com->pc98_if_type))
- com_send_break_off(com);
- else {
- port_shift = if_16550a_type[com->pc98_if_type & 0x0f].port_shift;
- outb(iobase + (com_cfcr << port_shift),
- com->cfcr_image &= ~CFCR_SBREAK);
- }
-#else
- outb(iobase + com_cfcr, com->cfcr_image &= ~CFCR_SBREAK);
-#endif
- {
-#ifdef PC98
- int tmp;
- if (IS_8251(com->pc98_if_type))
- com_int_TxRx_disable(com);
- else
- outb(iobase + (com_ier << port_shift), 0);
- if (com->pc98_if_type == COM_IF_RSA98III) {
- outb(com->rsabase + rsa_ier, 0x00);
- }
-#else
- outb(iobase + com_ier, 0);
-#endif
- tp = com->tp;
-#ifdef PC98
- if (IS_8251(com->pc98_if_type))
- tmp = pc98_get_modem_status(com) & TIOCM_CAR;
- else
- tmp = com->prev_modem_status & MSR_DCD;
-#endif
- if (tp->t_cflag & HUPCL
- /*
- * XXX we will miss any carrier drop between here and the
- * next open. Perhaps we should watch DCD even when the
- * port is closed; it is not sufficient to check it at
- * the next open because it might go up and down while
- * we're not watching.
- */
- || (!com->active_out
-#ifdef PC98
- && !(tmp)
-#else
- && !(com->prev_modem_status & MSR_DCD)
-#endif
- && !(com->it_in.c_cflag & CLOCAL))
- || !(tp->t_state & TS_ISOPEN)) {
-#ifdef PC98
- if (IS_8251(com->pc98_if_type))
- com_tiocm_bic(com, TIOCM_DTR|TIOCM_RTS|TIOCM_LE);
- else
-#endif
- (void)commctl(com, TIOCM_DTR, DMBIC);
- if (com->dtr_wait != 0 && !(com->state & CS_DTR_OFF)) {
- timeout(siodtrwakeup, com, com->dtr_wait);
- com->state |= CS_DTR_OFF;
- }
- }
-#ifdef PC98
- else {
- if (IS_8251(com->pc98_if_type))
- com_tiocm_bic(com, TIOCM_LE );
- }
-#endif
- }
-#ifdef PC98
- if (com->pc98_8251fifo) {
- if (com->pc98_8251fifo_enable)
- outb(I8251F_fcr, CTRL8251F_XMT_RST | CTRL8251F_RCV_RST);
- com->pc98_8251fifo_enable = 0;
- }
-#endif
- if (com->hasfifo) {
- /*
- * Disable fifos so that they are off after controlled
- * reboots. Some BIOSes fail to detect 16550s when the
- * fifos are enabled.
- */
-#ifdef PC98
- outb(iobase + (com_fifo << port_shift), 0);
-#else
- outb(iobase + com_fifo, 0);
-#endif
- }
- com->active_out = FALSE;
- wakeup(&com->active_out);
- wakeup(TSA_CARR_ON(tp)); /* restart any wopeners */
- splx(s);
-}
-
-static int
-sioread(dev, uio, flag)
- dev_t dev;
- struct uio *uio;
- int flag;
-{
- int mynor;
- struct com_s *com;
-
- mynor = minor(dev);
- if (mynor & CONTROL_MASK)
- return (ENODEV);
- com = com_addr(MINOR_TO_UNIT(mynor));
- if (com == NULL || com->gone)
- return (ENODEV);
- return ((*linesw[com->tp->t_line].l_read)(com->tp, uio, flag));
-}
-
-static int
-siowrite(dev, uio, flag)
- dev_t dev;
- struct uio *uio;
- int flag;
-{
- int mynor;
- struct com_s *com;
- int unit;
-
- mynor = minor(dev);
- if (mynor & CONTROL_MASK)
- return (ENODEV);
-
- unit = MINOR_TO_UNIT(mynor);
- com = com_addr(unit);
- if (com == NULL || com->gone)
- return (ENODEV);
- /*
- * (XXX) We disallow virtual consoles if the physical console is
- * a serial port. This is in case there is a display attached that
- * is not the console. In that situation we don't need/want the X
- * server taking over the console.
- */
- if (constty != NULL && unit == comconsole)
- constty = NULL;
- return ((*linesw[com->tp->t_line].l_write)(com->tp, uio, flag));
-}
-
-static void
-siobusycheck(chan)
- void *chan;
-{
- struct com_s *com;
- int s;
-
- com = (struct com_s *)chan;
-
- /*
- * Clear TS_BUSY if low-level output is complete.
- * spl locking is sufficient because siointr1() does not set CS_BUSY.
- * If siointr1() clears CS_BUSY after we look at it, then we'll get
- * called again. Reading the line status port outside of siointr1()
- * is safe because CS_BUSY is clear so there are no output interrupts
- * to lose.
- */
- s = spltty();
- if (com->state & CS_BUSY)
- com->extra_state &= ~CSE_BUSYCHECK; /* False alarm. */
-#ifdef PC98
- else if ((IS_8251(com->pc98_if_type) &&
- ((com->pc98_8251fifo_enable &&
- (inb(I8251F_lsr) & (STS8251F_TxRDY | STS8251F_TxEMP))
- == (STS8251F_TxRDY | STS8251F_TxEMP)) ||
- (!com->pc98_8251fifo_enable &&
- (inb(com->sts_port) & (STS8251_TxRDY | STS8251_TxEMP))
- == (STS8251_TxRDY | STS8251_TxEMP)))) ||
- ((inb(com->line_status_port) & (LSR_TSRE | LSR_TXRDY))
- == (LSR_TSRE | LSR_TXRDY))) {
-#else
- else if ((inb(com->line_status_port) & (LSR_TSRE | LSR_TXRDY))
- == (LSR_TSRE | LSR_TXRDY)) {
-#endif
- com->tp->t_state &= ~TS_BUSY;
- ttwwakeup(com->tp);
- com->extra_state &= ~CSE_BUSYCHECK;
- } else
- timeout(siobusycheck, com, hz / 100);
- splx(s);
-}
-
-static void
-siodtrwakeup(chan)
- void *chan;
-{
- struct com_s *com;
-
- com = (struct com_s *)chan;
- com->state &= ~CS_DTR_OFF;
- wakeup(&com->dtr_wait);
-}
-
-static void
-sioinput(com)
- struct com_s *com;
-{
- u_char *buf;
- int incc;
- u_char line_status;
- int recv_data;
- struct tty *tp;
-
- buf = com->ibuf;
- tp = com->tp;
- if (!(tp->t_state & TS_ISOPEN) || !(tp->t_cflag & CREAD)) {
- com_events -= (com->iptr - com->ibuf);
- com->iptr = com->ibuf;
- return;
- }
- if (tp->t_state & TS_CAN_BYPASS_L_RINT) {
- /*
- * Avoid the grotesquely inefficient lineswitch routine
- * (ttyinput) in "raw" mode. It usually takes about 450
- * instructions (that's without canonical processing or echo!).
- * slinput is reasonably fast (usually 40 instructions plus
- * call overhead).
- */
- do {
- enable_intr();
- incc = com->iptr - buf;
- if (tp->t_rawq.c_cc + incc > tp->t_ihiwat
- && (com->state & CS_RTS_IFLOW
- || tp->t_iflag & IXOFF)
- && !(tp->t_state & TS_TBLOCK))
- ttyblock(tp);
- com->delta_error_counts[CE_TTY_BUF_OVERFLOW]
- += b_to_q((char *)buf, incc, &tp->t_rawq);
- buf += incc;
- tk_nin += incc;
- tk_rawcc += incc;
- tp->t_rawcc += incc;
- ttwakeup(tp);
- if (tp->t_state & TS_TTSTOP
- && (tp->t_iflag & IXANY
- || tp->t_cc[VSTART] == tp->t_cc[VSTOP])) {
- tp->t_state &= ~TS_TTSTOP;
- tp->t_lflag &= ~FLUSHO;
- comstart(tp);
- }
- disable_intr();
- } while (buf < com->iptr);
- } else {
- do {
- enable_intr();
- line_status = buf[com->ierroff];
- recv_data = *buf++;
- if (line_status
- & (LSR_BI | LSR_FE | LSR_OE | LSR_PE)) {
- if (line_status & LSR_BI)
- recv_data |= TTY_BI;
- if (line_status & LSR_FE)
- recv_data |= TTY_FE;
- if (line_status & LSR_OE)
- recv_data |= TTY_OE;
- if (line_status & LSR_PE)
- recv_data |= TTY_PE;
- }
- (*linesw[tp->t_line].l_rint)(recv_data, tp);
- disable_intr();
- } while (buf < com->iptr);
- }
- com_events -= (com->iptr - com->ibuf);
- com->iptr = com->ibuf;
-
- /*
- * There is now room for another low-level buffer full of input,
- * so enable RTS if it is now disabled and there is room in the
- * high-level buffer.
- */
-#ifdef PC98
- if (IS_8251(com->pc98_if_type)) {
- if ((com->state & CS_RTS_IFLOW) &&
- !(com_tiocm_get(com) & TIOCM_RTS) &&
- !(tp->t_state & TS_TBLOCK))
- com_tiocm_bis(com, TIOCM_RTS);
- } else {
- if ((com->state & CS_RTS_IFLOW) &&
- !(com->mcr_image & MCR_RTS) &&
- !(tp->t_state & TS_TBLOCK))
- outb(com->modem_ctl_port, com->mcr_image |= MCR_RTS);
- }
-#else
- if ((com->state & CS_RTS_IFLOW) && !(com->mcr_image & MCR_RTS) &&
- !(tp->t_state & TS_TBLOCK))
- outb(com->modem_ctl_port, com->mcr_image |= MCR_RTS);
-#endif
-}
-
-void
-siointr(arg)
- void *arg;
-{
-#ifndef COM_MULTIPORT
- COM_LOCK();
- siointr1((struct com_s *) arg);
- COM_UNLOCK();
-#else /* COM_MULTIPORT */
- bool_t possibly_more_intrs;
- int unit;
- struct com_s *com;
-#ifdef PC98
- u_char rsa_buf_status;
-#endif
-
- /*
- * Loop until there is no activity on any port. This is necessary
- * to get an interrupt edge more than to avoid another interrupt.
- * If the IRQ signal is just an OR of the IRQ signals from several
- * devices, then the edge from one may be lost because another is
- * on.
- */
- COM_LOCK();
- do {
- possibly_more_intrs = FALSE;
- for (unit = 0; unit < sio_numunits; ++unit) {
- com = com_addr(unit);
- /*
- * XXX COM_LOCK();
- * would it work here, or be counter-productive?
- */
-#ifdef PC98
- if (com != NULL
- && !com->gone
- && IS_8251(com->pc98_if_type)){
- siointr1(com);
- } else
-#endif /* PC98 */
-#ifdef PC98
- if (com != NULL
- && !com->gone
- && com->pc98_if_type == COM_IF_RSA98III) {
- rsa_buf_status = inb(com->rsabase + rsa_srr) & 0xc9;
- if ((rsa_buf_status & 0xc8)
- || !(rsa_buf_status & 0x01)) {
- siointr1(com);
- if(rsa_buf_status
- != (inb(com->rsabase + rsa_srr) & 0xc9))
- possibly_more_intrs = TRUE;
- }
- } else
-#endif
- if (com != NULL
- && !com->gone
- && (inb(com->int_id_port) & IIR_IMASK)
- != IIR_NOPEND) {
- siointr1(com);
- possibly_more_intrs = TRUE;
- }
- /* XXX COM_UNLOCK(); */
- }
- } while (possibly_more_intrs);
- COM_UNLOCK();
-#endif /* COM_MULTIPORT */
-}
-
-static void
-siointr1(com)
- struct com_s *com;
-{
- u_char line_status;
- u_char modem_status;
- u_char *ioptr;
- u_char recv_data;
- u_char int_ctl;
- u_char int_ctl_new;
- struct timecounter *tc;
- u_int count;
-
-#ifdef PC98
- u_char tmp=0;
- u_char rsa_buf_status = 0;
- int rsa_tx_fifo_size=0;
- recv_data=0;
-#endif /* PC98 */
-
- int_ctl = inb(com->intr_ctl_port);
- int_ctl_new = int_ctl;
-
- while (!com->gone) {
-#ifdef PC98
-status_read:;
- if (IS_8251(com->pc98_if_type)) {
- if (com->pc98_8251fifo_enable)
- tmp = inb(I8251F_lsr);
- else
- tmp = inb(com->sts_port);
-more_intr:
- line_status = 0;
- if (com->pc98_8251fifo_enable) {
- if (tmp & STS8251F_TxRDY) line_status |= LSR_TXRDY;
- if (tmp & STS8251F_RxRDY) line_status |= LSR_RXRDY;
- if (tmp & STS8251F_TxEMP) line_status |= LSR_TSRE;
- if (tmp & STS8251F_PE) line_status |= LSR_PE;
- if (tmp & STS8251F_OE) line_status |= LSR_OE;
- if (tmp & STS8251F_BD_SD) line_status |= LSR_BI;
- } else {
- if (tmp & STS8251_TxRDY) line_status |= LSR_TXRDY;
- if (tmp & STS8251_RxRDY) line_status |= LSR_RXRDY;
- if (tmp & STS8251_TxEMP) line_status |= LSR_TSRE;
- if (tmp & STS8251_PE) line_status |= LSR_PE;
- if (tmp & STS8251_OE) line_status |= LSR_OE;
- if (tmp & STS8251_FE) line_status |= LSR_FE;
- if (tmp & STS8251_BD_SD) line_status |= LSR_BI;
- }
- } else {
-#endif /* PC98 */
- if (com->pps.ppsparam.mode & PPS_CAPTUREBOTH) {
- modem_status = inb(com->modem_status_port);
- if ((modem_status ^ com->last_modem_status) & MSR_DCD) {
- tc = timecounter;
- count = tc->tc_get_timecount(tc);
- pps_event(&com->pps, tc, count,
- (modem_status & MSR_DCD) ?
- PPS_CAPTUREASSERT : PPS_CAPTURECLEAR);
- }
- }
- line_status = inb(com->line_status_port);
-#ifdef PC98
- }
- if (com->pc98_if_type == COM_IF_RSA98III)
- rsa_buf_status = inb(com->rsabase + rsa_srr);
-#endif /* PC98 */
-
- /* input event? (check first to help avoid overruns) */
-#ifndef PC98
- while (line_status & LSR_RCV_MASK) {
-#else
- while ((line_status & LSR_RCV_MASK)
- || (com->pc98_if_type == COM_IF_RSA98III
- && (rsa_buf_status & 0x08))) {
-#endif /* PC98 */
- /* break/unnattached error bits or real input? */
-#ifdef PC98
- if (IS_8251(com->pc98_if_type)) {
- if (com->pc98_8251fifo_enable) {
- recv_data = inb(I8251F_data);
- if (tmp & (STS8251F_PE | STS8251F_OE |
- STS8251F_BD_SD)) {
- pc98_i8251_or_cmd(com, CMD8251_ER);
- recv_data = 0;
- }
- } else {
- recv_data = inb(com->data_port);
- if (tmp & (STS8251_PE | STS8251_OE |
- STS8251_FE | STS8251_BD_SD)) {
- pc98_i8251_or_cmd(com, CMD8251_ER);
- recv_data = 0;
- }
- }
- } else {
-#endif /* PC98 */
-#ifdef PC98
- if (com->pc98_if_type == COM_IF_RSA98III) {
- if (!(rsa_buf_status & 0x08))
- recv_data = 0;
- else
- recv_data = inb(com->data_port);
- } else
-#endif
- if (!(line_status & LSR_RXRDY))
- recv_data = 0;
- else
- recv_data = inb(com->data_port);
-#ifdef PC98
- }
-#endif
- if (line_status & (LSR_BI | LSR_FE | LSR_PE)) {
- /*
- * Don't store BI if IGNBRK or FE/PE if IGNPAR.
- * Otherwise, push the work to a higher level
- * (to handle PARMRK) if we're bypassing.
- * Otherwise, convert BI/FE and PE+INPCK to 0.
- *
- * This makes bypassing work right in the
- * usual "raw" case (IGNBRK set, and IGNPAR
- * and INPCK clear).
- *
- * Note: BI together with FE/PE means just BI.
- */
- if (line_status & LSR_BI) {
-#if defined(DDB) && defined(BREAK_TO_DEBUGGER)
- if (com->unit == comconsole) {
- breakpoint();
- goto cont;
- }
-#endif
- if (com->tp == NULL
- || com->tp->t_iflag & IGNBRK)
- goto cont;
- } else {
- if (com->tp == NULL
- || com->tp->t_iflag & IGNPAR)
- goto cont;
- }
- if (com->tp->t_state & TS_CAN_BYPASS_L_RINT
- && (line_status & (LSR_BI | LSR_FE)
- || com->tp->t_iflag & INPCK))
- recv_data = 0;
- }
- ++com->bytes_in;
- if (com->hotchar != 0 && recv_data == com->hotchar)
- setsofttty();
- ioptr = com->iptr;
- if (ioptr >= com->ibufend)
- CE_RECORD(com, CE_INTERRUPT_BUF_OVERFLOW);
- else {
- if (com->do_timestamp)
- microtime(&com->timestamp);
- ++com_events;
- schedsofttty();
-#if 0 /* for testing input latency vs efficiency */
-if (com->iptr - com->ibuf == 8)
- setsofttty();
-#endif
- ioptr[0] = recv_data;
- ioptr[com->ierroff] = line_status;
- com->iptr = ++ioptr;
- if (ioptr == com->ihighwater
- && com->state & CS_RTS_IFLOW)
-#ifdef PC98
- IS_8251(com->pc98_if_type) ?
- com_tiocm_bic(com, TIOCM_RTS) :
-#endif
- outb(com->modem_ctl_port,
- com->mcr_image &= ~MCR_RTS);
- if (line_status & LSR_OE)
- CE_RECORD(com, CE_OVERRUN);
- }
-cont:
- /*
- * "& 0x7F" is to avoid the gcc-1.40 generating a slow
- * jump from the top of the loop to here
- */
-#ifdef PC98
- if (IS_8251(com->pc98_if_type))
- goto status_read;
- else
-#endif
- line_status = inb(com->line_status_port) & 0x7F;
-#ifdef PC98
- if (com->pc98_if_type == COM_IF_RSA98III)
- rsa_buf_status = inb(com->rsabase + rsa_srr);
-#endif /* PC98 */
- }
-
- /* modem status change? (always check before doing output) */
-#ifdef PC98
- if (!IS_8251(com->pc98_if_type)) {
-#endif
- modem_status = inb(com->modem_status_port);
- if (modem_status != com->last_modem_status) {
- if (com->do_dcd_timestamp
- && !(com->last_modem_status & MSR_DCD)
- && modem_status & MSR_DCD)
- microtime(&com->dcd_timestamp);
-
- /*
- * Schedule high level to handle DCD changes. Note
- * that we don't use the delta bits anywhere. Some
- * UARTs mess them up, and it's easy to remember the
- * previous bits and calculate the delta.
- */
- com->last_modem_status = modem_status;
- if (!(com->state & CS_CHECKMSR)) {
- com_events += LOTS_OF_EVENTS;
- com->state |= CS_CHECKMSR;
- setsofttty();
- }
-
- /* handle CTS change immediately for crisp flow ctl */
- if (com->state & CS_CTS_OFLOW) {
- if (modem_status & MSR_CTS)
- com->state |= CS_ODEVREADY;
- else
- com->state &= ~CS_ODEVREADY;
- }
- }
-#ifdef PC98
- }
-#endif
-
- /* output queued and everything ready? */
-#ifndef PC98
- if (line_status & LSR_TXRDY
- && com->state >= (CS_BUSY | CS_TTGO | CS_ODEVREADY)) {
-#else
- if (((com->pc98_if_type == COM_IF_RSA98III)
- ? (rsa_buf_status & 0x02)
- : (line_status & LSR_TXRDY))
- && com->state >= (CS_BUSY | CS_TTGO | CS_ODEVREADY)) {
-#endif
-#ifdef PC98
- Port_t tmp_data_port;
-
- if (IS_8251(com->pc98_if_type) &&
- com->pc98_8251fifo_enable)
- tmp_data_port = I8251F_data;
- else
- tmp_data_port = com->data_port;
-#endif
-
- ioptr = com->obufq.l_head;
- if (com->tx_fifo_size > 1) {
- u_int ocount;
-
- ocount = com->obufq.l_tail - ioptr;
-#ifdef PC98
- if (com->pc98_if_type == COM_IF_RSA98III) {
- rsa_buf_status = inb(com->rsabase + rsa_srr);
- rsa_tx_fifo_size = 1024;
- if (!(rsa_buf_status & 0x01))
- rsa_tx_fifo_size = 2048;
- if (ocount > rsa_tx_fifo_size)
- ocount = rsa_tx_fifo_size;
- } else
-#endif
- if (ocount > com->tx_fifo_size)
- ocount = com->tx_fifo_size;
- com->bytes_out += ocount;
- do
-#ifdef PC98
- outb(tmp_data_port, *ioptr++);
-#else
- outb(com->data_port, *ioptr++);
-#endif
- while (--ocount != 0);
- } else {
-#ifdef PC98
- outb(tmp_data_port, *ioptr++);
-#else
- outb(com->data_port, *ioptr++);
-#endif
- ++com->bytes_out;
- }
-#ifdef PC98
- if (IS_8251(com->pc98_if_type))
- if (!(pc98_check_i8251_interrupt(com) & IEN_TxFLAG))
- com_int_Tx_enable(com);
-#endif
- com->obufq.l_head = ioptr;
- if (COM_IIR_TXRDYBUG(com->flags)) {
- int_ctl_new = int_ctl | IER_ETXRDY;
- }
- if (ioptr >= com->obufq.l_tail) {
- struct lbq *qp;
-
- qp = com->obufq.l_next;
- qp->l_queued = FALSE;
- qp = qp->l_next;
- if (qp != NULL) {
- com->obufq.l_head = qp->l_head;
- com->obufq.l_tail = qp->l_tail;
- com->obufq.l_next = qp;
- } else {
- /* output just completed */
- if (COM_IIR_TXRDYBUG(com->flags)) {
- int_ctl_new = int_ctl & ~IER_ETXRDY;
- }
- com->state &= ~CS_BUSY;
-#if defined(PC98)
- if (IS_8251(com->pc98_if_type))
- if ( pc98_check_i8251_interrupt(com) & IEN_TxFLAG )
- com_int_Tx_disable(com);
-#endif
- }
- if (!(com->state & CS_ODONE)) {
- com_events += LOTS_OF_EVENTS;
- com->state |= CS_ODONE;
- setsofttty(); /* handle at high level ASAP */
- }
- }
- if (COM_IIR_TXRDYBUG(com->flags) && (int_ctl != int_ctl_new)) {
-#ifdef PC98
- if (com->pc98_if_type == COM_IF_RSA98III) {
- int_ctl_new &= ~(IER_ETXRDY | IER_ERXRDY);
- outb(com->intr_ctl_port, int_ctl_new);
- outb(com->rsabase + rsa_ier, 0x1d);
- } else
-#endif
- outb(com->intr_ctl_port, int_ctl_new);
- }
- }
-#ifdef PC98
- else if (line_status & LSR_TXRDY) {
- if (IS_8251(com->pc98_if_type))
- if ( pc98_check_i8251_interrupt(com) & IEN_TxFLAG )
- com_int_Tx_disable(com);
- }
- if (IS_8251(com->pc98_if_type)) {
- if (com->pc98_8251fifo_enable) {
- if ((tmp = inb(I8251F_lsr)) & STS8251F_RxRDY)
- goto more_intr;
- } else {
- if ((tmp = inb(com->sts_port)) & STS8251_RxRDY)
- goto more_intr;
- }
- }
-#endif
-
- /* finished? */
-#ifndef COM_MULTIPORT
-#ifdef PC98
- if (IS_8251(com->pc98_if_type))
- return;
-#endif
- if ((inb(com->int_id_port) & IIR_IMASK) == IIR_NOPEND)
-#endif /* COM_MULTIPORT */
- return;
- }
-}
-
-static int
-sioioctl(dev, cmd, data, flag, p)
- dev_t dev;
- u_long cmd;
- caddr_t data;
- int flag;
- struct proc *p;
-{
- struct com_s *com;
- int error;
- Port_t iobase;
- int mynor;
- int s;
- struct tty *tp;
-#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
- u_long oldcmd;
- struct termios term;
-#endif
-
- mynor = minor(dev);
- com = com_addr(MINOR_TO_UNIT(mynor));
- if (com == NULL || com->gone)
- return (ENODEV);
- iobase = com->iobase;
- if (mynor & CONTROL_MASK) {
- struct termios *ct;
-
- switch (mynor & CONTROL_MASK) {
- case CONTROL_INIT_STATE:
- ct = mynor & CALLOUT_MASK ? &com->it_out : &com->it_in;
- break;
- case CONTROL_LOCK_STATE:
- ct = mynor & CALLOUT_MASK ? &com->lt_out : &com->lt_in;
- break;
- default:
- return (ENODEV); /* /dev/nodev */
- }
- switch (cmd) {
- case TIOCSETA:
- error = suser(p);
- if (error != 0)
- return (error);
- *ct = *(struct termios *)data;
- return (0);
- case TIOCGETA:
- *(struct termios *)data = *ct;
- return (0);
- case TIOCGETD:
- *(int *)data = TTYDISC;
- return (0);
- case TIOCGWINSZ:
- bzero(data, sizeof(struct winsize));
- return (0);
- default:
- return (ENOTTY);
- }
- }
- tp = com->tp;
-#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
- term = tp->t_termios;
- oldcmd = cmd;
- error = ttsetcompat(tp, &cmd, data, &term);
- if (error != 0)
- return (error);
- if (cmd != oldcmd)
- data = (caddr_t)&term;
-#endif
- if (cmd == TIOCSETA || cmd == TIOCSETAW || cmd == TIOCSETAF) {
- int cc;
- struct termios *dt = (struct termios *)data;
- struct termios *lt = mynor & CALLOUT_MASK
- ? &com->lt_out : &com->lt_in;
-
- dt->c_iflag = (tp->t_iflag & lt->c_iflag)
- | (dt->c_iflag & ~lt->c_iflag);
- dt->c_oflag = (tp->t_oflag & lt->c_oflag)
- | (dt->c_oflag & ~lt->c_oflag);
- dt->c_cflag = (tp->t_cflag & lt->c_cflag)
- | (dt->c_cflag & ~lt->c_cflag);
- dt->c_lflag = (tp->t_lflag & lt->c_lflag)
- | (dt->c_lflag & ~lt->c_lflag);
- for (cc = 0; cc < NCCS; ++cc)
- if (lt->c_cc[cc] != 0)
- dt->c_cc[cc] = tp->t_cc[cc];
- if (lt->c_ispeed != 0)
- dt->c_ispeed = tp->t_ispeed;
- if (lt->c_ospeed != 0)
- dt->c_ospeed = tp->t_ospeed;
- }
- error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p);
- if (error != ENOIOCTL)
- return (error);
- s = spltty();
- error = ttioctl(tp, cmd, data, flag);
- disc_optim(tp, &tp->t_termios, com);
- if (error != ENOIOCTL) {
- splx(s);
- return (error);
- }
-#ifdef PC98
- if (IS_8251(com->pc98_if_type)) {
- switch (cmd) {
- case TIOCSBRK:
- com_send_break_on( com );
- break;
- case TIOCCBRK:
- com_send_break_off( com );
- break;
- case TIOCSDTR:
- com_tiocm_bis(com, TIOCM_DTR | TIOCM_RTS );
- break;
- case TIOCCDTR:
- com_tiocm_bic(com, TIOCM_DTR);
- break;
- /*
- * XXX should disallow changing MCR_RTS if CS_RTS_IFLOW is set. The
- * changes get undone on the next call to comparam().
- */
- case TIOCMSET:
- com_tiocm_set( com, *(int *)data );
- break;
- case TIOCMBIS:
- com_tiocm_bis( com, *(int *)data );
- break;
- case TIOCMBIC:
- com_tiocm_bic( com, *(int *)data );
- break;
- case TIOCMGET:
- *(int *)data = com_tiocm_get(com);
- break;
- case TIOCMSDTRWAIT:
- /* must be root since the wait applies to following logins */
- error = suser(p);
- if (error != 0) {
- splx(s);
- return (error);
- }
- com->dtr_wait = *(int *)data * hz / 100;
- break;
- case TIOCMGDTRWAIT:
- *(int *)data = com->dtr_wait * 100 / hz;
- break;
- case TIOCTIMESTAMP:
- com->do_timestamp = TRUE;
- *(struct timeval *)data = com->timestamp;
- break;
- case TIOCDCDTIMESTAMP:
- com->do_dcd_timestamp = TRUE;
- *(struct timeval *)data = com->dcd_timestamp;
- break;
- default:
- splx(s);
- return (ENOTTY);
- }
- } else {
- int port_shift;
- port_shift = if_16550a_type[com->pc98_if_type & 0x0f].port_shift;
-#endif
- switch (cmd) {
- case TIOCSBRK:
-#ifdef PC98
- outb(iobase + (com_cfcr << port_shift),
- com->cfcr_image |= CFCR_SBREAK);
-#else
- outb(iobase + com_cfcr, com->cfcr_image |= CFCR_SBREAK);
-#endif
- break;
- case TIOCCBRK:
-#ifdef PC98
- outb(iobase + (com_cfcr << port_shift),
- com->cfcr_image &= ~CFCR_SBREAK);
-#else
- outb(iobase + com_cfcr, com->cfcr_image &= ~CFCR_SBREAK);
-#endif
- break;
- case TIOCSDTR:
- (void)commctl(com, TIOCM_DTR, DMBIS);
- break;
- case TIOCCDTR:
- (void)commctl(com, TIOCM_DTR, DMBIC);
- break;
- /*
- * XXX should disallow changing MCR_RTS if CS_RTS_IFLOW is set. The
- * changes get undone on the next call to comparam().
- */
- case TIOCMSET:
- (void)commctl(com, *(int *)data, DMSET);
- break;
- case TIOCMBIS:
- (void)commctl(com, *(int *)data, DMBIS);
- break;
- case TIOCMBIC:
- (void)commctl(com, *(int *)data, DMBIC);
- break;
- case TIOCMGET:
- *(int *)data = commctl(com, 0, DMGET);
- break;
- case TIOCMSDTRWAIT:
- /* must be root since the wait applies to following logins */
- error = suser(p);
- if (error != 0) {
- splx(s);
- return (error);
- }
- com->dtr_wait = *(int *)data * hz / 100;
- break;
- case TIOCMGDTRWAIT:
- *(int *)data = com->dtr_wait * 100 / hz;
- break;
- case TIOCTIMESTAMP:
- com->do_timestamp = TRUE;
- *(struct timeval *)data = com->timestamp;
- break;
- case TIOCDCDTIMESTAMP:
- com->do_dcd_timestamp = TRUE;
- *(struct timeval *)data = com->dcd_timestamp;
- break;
- default:
- splx(s);
- error = pps_ioctl(cmd, data, &com->pps);
- if (error == ENODEV)
- error = ENOTTY;
- return (error);
- }
-#ifdef PC98
- }
-#endif
- splx(s);
- return (0);
-}
-
-static void
-siopoll()
-{
- int unit;
-
- if (com_events == 0)
- return;
-repeat:
- for (unit = 0; unit < sio_numunits; ++unit) {
- struct com_s *com;
- int incc;
- struct tty *tp;
-
- com = com_addr(unit);
- if (com == NULL)
- continue;
- tp = com->tp;
- if (tp == NULL || com->gone) {
- /*
- * Discard any events related to never-opened or
- * going-away devices.
- */
- disable_intr();
- incc = com->iptr - com->ibuf;
- com->iptr = com->ibuf;
- if (com->state & CS_CHECKMSR) {
- incc += LOTS_OF_EVENTS;
- com->state &= ~CS_CHECKMSR;
- }
- com_events -= incc;
- enable_intr();
- continue;
- }
- if (com->iptr != com->ibuf) {
- disable_intr();
- sioinput(com);
- enable_intr();
- }
- if (com->state & CS_CHECKMSR) {
- u_char delta_modem_status;
-
-#ifdef PC98
- if (!IS_8251(com->pc98_if_type)) {
-#endif
- disable_intr();
- delta_modem_status = com->last_modem_status
- ^ com->prev_modem_status;
- com->prev_modem_status = com->last_modem_status;
- com_events -= LOTS_OF_EVENTS;
- com->state &= ~CS_CHECKMSR;
- enable_intr();
- if (delta_modem_status & MSR_DCD)
- (*linesw[tp->t_line].l_modem)
- (tp, com->prev_modem_status & MSR_DCD);
-#ifdef PC98
- }
-#endif
- }
- if (com->state & CS_ODONE) {
- disable_intr();
- com_events -= LOTS_OF_EVENTS;
- com->state &= ~CS_ODONE;
- enable_intr();
- if (!(com->state & CS_BUSY)
- && !(com->extra_state & CSE_BUSYCHECK)) {
- timeout(siobusycheck, com, hz / 100);
- com->extra_state |= CSE_BUSYCHECK;
- }
- (*linesw[tp->t_line].l_start)(tp);
- }
- if (com_events == 0)
- break;
- }
- if (com_events >= LOTS_OF_EVENTS)
- goto repeat;
-}
-
-static int
-comparam(tp, t)
- struct tty *tp;
- struct termios *t;
-{
- u_int cfcr;
- int cflag;
- struct com_s *com;
- int divisor;
- u_char dlbh;
- u_char dlbl;
- Port_t iobase;
- int s;
- int unit;
-#ifdef PC98
- int port_shift = 0;
- u_char param = 0;
-#endif
-
-#ifdef PC98
- cfcr = 0;
- unit = DEV_TO_UNIT(tp->t_dev);
- com = com_addr(unit);
- iobase = com->iobase;
- if (IS_8251(com->pc98_if_type)) {
- divisor = pc98_ttspeedtab(com, t->c_ospeed);
- } else {
- port_shift = if_16550a_type[com->pc98_if_type & 0x0f].port_shift;
-
- /* do historical conversions */
- if (t->c_ispeed == 0)
- t->c_ispeed = t->c_ospeed;
-
- /* check requested parameters */
- divisor = ttspeedtab(t->c_ospeed,
- if_16550a_type[com->pc98_if_type & 0x0f].speedtab);
- }
-#else
- /* do historical conversions */
- if (t->c_ispeed == 0)
- t->c_ispeed = t->c_ospeed;
-
- /* check requested parameters */
- divisor = ttspeedtab(t->c_ospeed, comspeedtab);
-#endif
- if (divisor < 0 || (divisor > 0 && t->c_ispeed != t->c_ospeed))
- return (EINVAL);
-
- /* parameters are OK, convert them to the com struct and the device */
-#ifndef PC98
- unit = DEV_TO_UNIT(tp->t_dev);
- com = com_addr(unit);
- if (com == NULL)
- return (ENODEV);
- iobase = com->iobase;
-#endif
- s = spltty();
-#ifdef PC98
- if (IS_8251(com->pc98_if_type)) {
- if (divisor == 0)
- com_tiocm_bic( com, TIOCM_DTR|TIOCM_RTS|TIOCM_LE );
- else
- com_tiocm_bis( com, TIOCM_DTR|TIOCM_RTS|TIOCM_LE );
- } else {
-#endif
- if (divisor == 0)
- (void)commctl(com, TIOCM_DTR, DMBIC); /* hang up line */
- else
- (void)commctl(com, TIOCM_DTR, DMBIS);
-#ifdef PC98
- }
-#endif
- cflag = t->c_cflag;
-#ifdef PC98
- if (!IS_8251(com->pc98_if_type)) {
-#endif
- switch (cflag & CSIZE) {
- case CS5:
- cfcr = CFCR_5BITS;
- break;
- case CS6:
- cfcr = CFCR_6BITS;
- break;
- case CS7:
- cfcr = CFCR_7BITS;
- break;
- default:
- cfcr = CFCR_8BITS;
- break;
- }
- if (cflag & PARENB) {
- cfcr |= CFCR_PENAB;
- if (!(cflag & PARODD))
- cfcr |= CFCR_PEVEN;
- }
- if (cflag & CSTOPB)
- cfcr |= CFCR_STOPB;
-
- if (com->hasfifo && divisor != 0) {
- /*
- * Use a fifo trigger level low enough so that the input
- * latency from the fifo is less than about 16 msec and
- * the total latency is less than about 30 msec. These
- * latencies are reasonable for humans. Serial comms
- * protocols shouldn't expect anything better since modem
- * latencies are larger.
- */
- com->fifo_image = t->c_ospeed <= 4800
- ? FIFO_ENABLE : FIFO_ENABLE | FIFO_RX_HIGH;
-#ifdef COM_ESP
- /*
- * The Hayes ESP card needs the fifo DMA mode bit set
- * in compatibility mode. If not, it will interrupt
- * for each character received.
- */
- if (com->esp)
- com->fifo_image |= FIFO_DMA_MODE;
-#endif
-#ifdef PC98
- outb(iobase + (com_fifo << port_shift), com->fifo_image);
-#else
- outb(iobase + com_fifo, com->fifo_image);
-#endif
- }
-#ifdef PC98
- }
-#endif
-
- /*
- * This returns with interrupts disabled so that we can complete
- * the speed change atomically. Keeping interrupts disabled is
- * especially important while com_data is hidden.
- */
- (void) siosetwater(com, t->c_ispeed);
-
-#ifdef PC98
- if (IS_8251(com->pc98_if_type))
- com_cflag_and_speed_set(com, cflag, t->c_ospeed);
- else {
-#endif
- if (divisor != 0) {
-#ifdef PC98
- outb(iobase + (com_cfcr << port_shift), cfcr | CFCR_DLAB);
-#else
- outb(iobase + com_cfcr, cfcr | CFCR_DLAB);
-#endif
- /*
- * Only set the divisor registers if they would change,
- * since on some 16550 incompatibles (UMC8669F), setting
- * them while input is arriving them loses sync until
- * data stops arriving.
- */
- dlbl = divisor & 0xFF;
-#ifdef PC98
- if (inb(iobase + (com_dlbl << port_shift)) != dlbl)
- outb(iobase + (com_dlbl << port_shift), dlbl);
- dlbh = (u_int) divisor >> 8;
- if (inb(iobase + (com_dlbh << port_shift)) != dlbh)
- outb(iobase + (com_dlbh << port_shift), dlbh);
-#else
- if (inb(iobase + com_dlbl) != dlbl)
- outb(iobase + com_dlbl, dlbl);
- dlbh = (u_int) divisor >> 8;
- if (inb(iobase + com_dlbh) != dlbh)
- outb(iobase + com_dlbh, dlbh);
-#endif
- }
-
-
-#ifdef PC98
- }
- outb(iobase + (com_cfcr << port_shift), com->cfcr_image = cfcr);
-#else
- outb(iobase + com_cfcr, com->cfcr_image = cfcr);
-#endif
-
- if (!(tp->t_state & TS_TTSTOP))
- com->state |= CS_TTGO;
-
- if (cflag & CRTS_IFLOW) {
- if (com->st16650a) {
- outb(iobase + com_cfcr, 0xbf);
- outb(iobase + com_fifo, inb(iobase + com_fifo) | 0x40);
- }
- com->state |= CS_RTS_IFLOW;
- /*
- * If CS_RTS_IFLOW just changed from off to on, the change
- * needs to be propagated to MCR_RTS. This isn't urgent,
- * so do it later by calling comstart() instead of repeating
- * a lot of code from comstart() here.
- */
- } else if (com->state & CS_RTS_IFLOW) {
- com->state &= ~CS_RTS_IFLOW;
- /*
- * CS_RTS_IFLOW just changed from on to off. Force MCR_RTS
- * on here, since comstart() won't do it later.
- */
-#ifdef PC98
- if (IS_8251(com->pc98_if_type))
- com_tiocm_bis(com, TIOCM_RTS);
- else
-#endif
- outb(com->modem_ctl_port, com->mcr_image |= MCR_RTS);
- if (com->st16650a) {
- outb(iobase + com_cfcr, 0xbf);
- outb(iobase + com_fifo, inb(iobase + com_fifo) & ~0x40);
- }
- }
-
-
- /*
- * Set up state to handle output flow control.
- * XXX - worth handling MDMBUF (DCD) flow control at the lowest level?
- * Now has 10+ msec latency, while CTS flow has 50- usec latency.
- */
- com->state |= CS_ODEVREADY;
- com->state &= ~CS_CTS_OFLOW;
-#ifdef PC98
- if (com->pc98_if_type == COM_IF_RSA98III) {
- param = inb(com->rsabase + rsa_msr);
- outb(com->rsabase + rsa_msr, param & 0x14);
- }
-#endif
- if (cflag & CCTS_OFLOW) {
- com->state |= CS_CTS_OFLOW;
-#ifdef PC98
- if (IS_8251(com->pc98_if_type)) {
- if (!(pc98_get_modem_status(com) & TIOCM_CTS))
- com->state &= ~CS_ODEVREADY;
- } else {
-#endif
-#ifdef PC98
- if (com->pc98_if_type == COM_IF_RSA98III) {
- /* Set automatic flow control mode */
- outb(com->rsabase + rsa_msr, param | 0x08);
- } else
-#endif
- if (!(com->last_modem_status & MSR_CTS))
- com->state &= ~CS_ODEVREADY;
- if (com->st16650a) {
- outb(iobase + com_cfcr, 0xbf);
- outb(iobase + com_fifo, inb(iobase + com_fifo) | 0x80);
- }
-#ifdef PC98
- }
-#endif
- } else {
- if (com->st16650a) {
- outb(iobase + com_cfcr, 0xbf);
- outb(iobase + com_fifo, inb(iobase + com_fifo) & ~0x80);
- }
- }
-
-
-#ifdef PC98
- outb(iobase + (com_cfcr << port_shift), com->cfcr_image);
-#else
- outb(iobase + com_cfcr, com->cfcr_image);
-#endif
-
-
- /* XXX shouldn't call functions while intrs are disabled. */
- disc_optim(tp, t, com);
- /*
- * Recover from fiddling with CS_TTGO. We used to call siointr1()
- * unconditionally, but that defeated the careful discarding of
- * stale input in sioopen().
- */
- if (com->state >= (CS_BUSY | CS_TTGO))
- siointr1(com);
-
- enable_intr();
- splx(s);
- comstart(tp);
- if (com->ibufold != NULL) {
- free(com->ibufold, M_DEVBUF);
- com->ibufold = NULL;
- }
- return (0);
-}
-
-static int
-siosetwater(com, speed)
- struct com_s *com;
- speed_t speed;
-{
- int cp4ticks;
- u_char *ibuf;
- int ibufsize;
- struct tty *tp;
-
- /*
- * Make the buffer size large enough to handle a softtty interrupt
- * latency of about 2 ticks without loss of throughput or data
- * (about 3 ticks if input flow control is not used or not honoured,
- * but a bit less for CS5-CS7 modes).
- */
- cp4ticks = speed / 10 / hz * 4;
- for (ibufsize = 128; ibufsize < cp4ticks;)
- ibufsize <<= 1;
-#ifdef PC98
- if (com->pc98_if_type == COM_IF_RSA98III)
- ibufsize = 2048;
-#endif
- if (ibufsize == com->ibufsize) {
- disable_intr();
- return (0);
- }
-
- /*
- * Allocate input buffer. The extra factor of 2 in the size is
- * to allow for an error byte for each input byte.
- */
- ibuf = malloc(2 * ibufsize, M_DEVBUF, M_NOWAIT);
- if (ibuf == NULL) {
- disable_intr();
- return (ENOMEM);
- }
-
- /* Initialize non-critical variables. */
- com->ibufold = com->ibuf;
- com->ibufsize = ibufsize;
- tp = com->tp;
- if (tp != NULL) {
- tp->t_ififosize = 2 * ibufsize;
- tp->t_ispeedwat = (speed_t)-1;
- tp->t_ospeedwat = (speed_t)-1;
- }
-
- /*
- * Read current input buffer, if any. Continue with interrupts
- * disabled.
- */
- disable_intr();
- if (com->iptr != com->ibuf)
- sioinput(com);
-
- /*-
- * Initialize critical variables, including input buffer watermarks.
- * The external device is asked to stop sending when the buffer
- * exactly reaches high water, or when the high level requests it.
- * The high level is notified immediately (rather than at a later
- * clock tick) when this watermark is reached.
- * The buffer size is chosen so the watermark should almost never
- * be reached.
- * The low watermark is invisibly 0 since the buffer is always
- * emptied all at once.
- */
- com->iptr = com->ibuf = ibuf;
- com->ibufend = ibuf + ibufsize;
- com->ierroff = ibufsize;
- com->ihighwater = ibuf + 3 * ibufsize / 4;
- return (0);
-}
-
-static void
-comstart(tp)
- struct tty *tp;
-{
- struct com_s *com;
- int s;
- int unit;
-
- unit = DEV_TO_UNIT(tp->t_dev);
- com = com_addr(unit);
- if (com == NULL)
- return;
- s = spltty();
- disable_intr();
- if (tp->t_state & TS_TTSTOP)
- com->state &= ~CS_TTGO;
- else
- com->state |= CS_TTGO;
- if (tp->t_state & TS_TBLOCK) {
-#ifdef PC98
- if (IS_8251(com->pc98_if_type)) {
- if ((com_tiocm_get(com) & TIOCM_RTS) &&
- (com->state & CS_RTS_IFLOW))
- com_tiocm_bic(com, TIOCM_RTS);
- } else {
- if ((com->mcr_image & MCR_RTS) &&
- (com->state & CS_RTS_IFLOW))
- outb(com->modem_ctl_port, com->mcr_image &= ~MCR_RTS);
- }
-#else
- if (com->mcr_image & MCR_RTS && com->state & CS_RTS_IFLOW)
- outb(com->modem_ctl_port, com->mcr_image &= ~MCR_RTS);
-#endif
- } else {
-#ifdef PC98
- if (IS_8251(com->pc98_if_type)) {
- if (!(com_tiocm_get(com) & TIOCM_RTS) &&
- com->iptr < com->ihighwater &&
- com->state & CS_RTS_IFLOW)
- com_tiocm_bis(com, TIOCM_RTS);
- } else {
- if (!(com->mcr_image & MCR_RTS) &&
- com->iptr < com->ihighwater &&
- com->state & CS_RTS_IFLOW)
- outb(com->modem_ctl_port, com->mcr_image |= MCR_RTS);
- }
-#else
- if (!(com->mcr_image & MCR_RTS) && com->iptr < com->ihighwater
- && com->state & CS_RTS_IFLOW)
- outb(com->modem_ctl_port, com->mcr_image |= MCR_RTS);
-#endif
- }
- enable_intr();
- if (tp->t_state & (TS_TIMEOUT | TS_TTSTOP)) {
- ttwwakeup(tp);
-#ifdef PC98
-/* if(IS_8251(com->pc98_if_type))
- com_int_Tx_enable(com); */
-#endif
- splx(s);
- return;
- }
- if (tp->t_outq.c_cc != 0) {
- struct lbq *qp;
- struct lbq *next;
-
- if (!com->obufs[0].l_queued) {
- com->obufs[0].l_tail
- = com->obuf1 + q_to_b(&tp->t_outq, com->obuf1,
-#ifndef PC98
- sizeof com->obuf1);
-#else
- com->obufsize);
-#endif
- com->obufs[0].l_next = NULL;
- com->obufs[0].l_queued = TRUE;
- disable_intr();
- if (com->state & CS_BUSY) {
- qp = com->obufq.l_next;
- while ((next = qp->l_next) != NULL)
- qp = next;
- qp->l_next = &com->obufs[0];
- } else {
- com->obufq.l_head = com->obufs[0].l_head;
- com->obufq.l_tail = com->obufs[0].l_tail;
- com->obufq.l_next = &com->obufs[0];
- com->state |= CS_BUSY;
- }
- enable_intr();
- }
- if (tp->t_outq.c_cc != 0 && !com->obufs[1].l_queued) {
- com->obufs[1].l_tail
- = com->obuf2 + q_to_b(&tp->t_outq, com->obuf2,
-#ifndef PC98
- sizeof com->obuf2);
-#else
- com->obufsize);
-#endif
- com->obufs[1].l_next = NULL;
- com->obufs[1].l_queued = TRUE;
- disable_intr();
- if (com->state & CS_BUSY) {
- qp = com->obufq.l_next;
- while ((next = qp->l_next) != NULL)
- qp = next;
- qp->l_next = &com->obufs[1];
- } else {
- com->obufq.l_head = com->obufs[1].l_head;
- com->obufq.l_tail = com->obufs[1].l_tail;
- com->obufq.l_next = &com->obufs[1];
- com->state |= CS_BUSY;
- }
- enable_intr();
- }
- tp->t_state |= TS_BUSY;
- }
- disable_intr();
- if (com->state >= (CS_BUSY | CS_TTGO))
- siointr1(com); /* fake interrupt to start output */
- enable_intr();
-#ifdef PC98
-/* if(IS_8251(com->pc98_if_type))
- com_int_Tx_enable(com); */
-#endif
- ttwwakeup(tp);
- splx(s);
-}
-
-static void
-comstop(tp, rw)
- struct tty *tp;
- int rw;
-{
- struct com_s *com;
-#ifdef PC98
- int port_shift = 0;
- int rsa98_tmp = 0;
-#endif
-
- com = com_addr(DEV_TO_UNIT(tp->t_dev));
- if (com == NULL || com->gone)
- return;
-#ifdef PC98
- if (!IS_8251(com->pc98_if_type))
- port_shift = if_16550a_type[com->pc98_if_type & 0x0f].port_shift;
-#endif
- disable_intr();
- if (rw & FWRITE) {
- if (com->hasfifo)
-#ifdef COM_ESP
- /* XXX avoid h/w bug. */
- if (!com->esp)
-#endif
-#ifdef PC98
- outb(com->iobase + (com_fifo << port_shift),
- FIFO_XMT_RST | com->fifo_image);
- if (com->pc98_if_type == COM_IF_RSA98III)
- for(rsa98_tmp = 0; rsa98_tmp < 2048; rsa98_tmp++)
- outb(com->iobase + (com_fifo << port_shift),
- FIFO_XMT_RST | com->fifo_image);
-#else
- outb(com->iobase + com_fifo,
- FIFO_XMT_RST | com->fifo_image);
-#endif
- com->obufs[0].l_queued = FALSE;
- com->obufs[1].l_queued = FALSE;
- if (com->state & CS_ODONE)
- com_events -= LOTS_OF_EVENTS;
- com->state &= ~(CS_ODONE | CS_BUSY);
- com->tp->t_state &= ~TS_BUSY;
- }
- if (rw & FREAD) {
- if (com->hasfifo)
-#ifdef COM_ESP
- /* XXX avoid h/w bug. */
- if (!com->esp)
-#endif
-#ifdef PC98
- if (com->pc98_if_type == COM_IF_RSA98III) {
- for(rsa98_tmp = 0; rsa98_tmp < 2048; rsa98_tmp++)
- inb(com->data_port);
- }
- outb(com->iobase + (com_fifo << port_shift),
- FIFO_RCV_RST | com->fifo_image);
-#else
- outb(com->iobase + com_fifo,
- FIFO_RCV_RST | com->fifo_image);
-#endif
- com_events -= (com->iptr - com->ibuf);
- com->iptr = com->ibuf;
- }
- enable_intr();
- comstart(tp);
-}
-
-static int
-commctl(com, bits, how)
- struct com_s *com;
- int bits;
- int how;
-{
- int mcr;
- int msr;
-
- if (how == DMGET) {
- bits = TIOCM_LE; /* XXX - always enabled while open */
- mcr = com->mcr_image;
- if (mcr & MCR_DTR)
- bits |= TIOCM_DTR;
- if (mcr & MCR_RTS)
- bits |= TIOCM_RTS;
- msr = com->prev_modem_status;
- if (msr & MSR_CTS)
- bits |= TIOCM_CTS;
- if (msr & MSR_DCD)
- bits |= TIOCM_CD;
- if (msr & MSR_DSR)
- bits |= TIOCM_DSR;
- /*
- * XXX - MSR_RI is naturally volatile, and we make MSR_TERI
- * more volatile by reading the modem status a lot. Perhaps
- * we should latch both bits until the status is read here.
- */
- if (msr & (MSR_RI | MSR_TERI))
- bits |= TIOCM_RI;
- return (bits);
- }
- mcr = 0;
- if (bits & TIOCM_DTR)
- mcr |= MCR_DTR;
- if (bits & TIOCM_RTS)
- mcr |= MCR_RTS;
- if (com->gone)
- return(0);
- disable_intr();
- switch (how) {
- case DMSET:
- outb(com->modem_ctl_port,
- com->mcr_image = mcr | (com->mcr_image & MCR_IENABLE));
- break;
- case DMBIS:
- outb(com->modem_ctl_port, com->mcr_image |= mcr);
- break;
- case DMBIC:
- outb(com->modem_ctl_port, com->mcr_image &= ~mcr);
- break;
- }
- enable_intr();
- return (0);
-}
-
-static void
-siosettimeout()
-{
- struct com_s *com;
- bool_t someopen;
- int unit;
-
- /*
- * Set our timeout period to 1 second if no polled devices are open.
- * Otherwise set it to max(1/200, 1/hz).
- * Enable timeouts iff some device is open.
- */
- untimeout(comwakeup, (void *)NULL, sio_timeout_handle);
- sio_timeout = hz;
- someopen = FALSE;
- for (unit = 0; unit < sio_numunits; ++unit) {
- com = com_addr(unit);
- if (com != NULL && com->tp != NULL
- && com->tp->t_state & TS_ISOPEN && !com->gone) {
- someopen = TRUE;
- if (com->poll || com->poll_output) {
- sio_timeout = hz > 200 ? hz / 200 : 1;
- break;
- }
- }
- }
- if (someopen) {
- sio_timeouts_until_log = hz / sio_timeout;
- sio_timeout_handle = timeout(comwakeup, (void *)NULL,
- sio_timeout);
- } else {
- /* Flush error messages, if any. */
- sio_timeouts_until_log = 1;
- comwakeup((void *)NULL);
- untimeout(comwakeup, (void *)NULL, sio_timeout_handle);
- }
-}
-
-static void
-comwakeup(chan)
- void *chan;
-{
- struct com_s *com;
- int unit;
-
- sio_timeout_handle = timeout(comwakeup, (void *)NULL, sio_timeout);
-
- /*
- * Recover from lost output interrupts.
- * Poll any lines that don't use interrupts.
- */
- for (unit = 0; unit < sio_numunits; ++unit) {
- com = com_addr(unit);
- if (com != NULL && !com->gone
- && (com->state >= (CS_BUSY | CS_TTGO) || com->poll)) {
- disable_intr();
- siointr1(com);
- enable_intr();
- }
- }
-
- /*
- * Check for and log errors, but not too often.
- */
- if (--sio_timeouts_until_log > 0)
- return;
- sio_timeouts_until_log = hz / sio_timeout;
- for (unit = 0; unit < sio_numunits; ++unit) {
- int errnum;
-
- com = com_addr(unit);
- if (com == NULL)
- continue;
- if (com->gone)
- continue;
- for (errnum = 0; errnum < CE_NTYPES; ++errnum) {
- u_int delta;
- u_long total;
-
- disable_intr();
- delta = com->delta_error_counts[errnum];
- com->delta_error_counts[errnum] = 0;
- enable_intr();
- if (delta == 0)
- continue;
- total = com->error_counts[errnum] += delta;
- log(LOG_ERR, "sio%d: %u more %s%s (total %lu)\n",
- unit, delta, error_desc[errnum],
- delta == 1 ? "" : "s", total);
- }
- }
-}
-
-#ifdef PC98
-/* commint is called when modem control line changes */
-static void
-commint(dev_t dev)
-{
- register struct tty *tp;
- int stat,delta;
- struct com_s *com;
- int mynor,unit;
-
- mynor = minor(dev);
- unit = MINOR_TO_UNIT(mynor);
- com = com_addr(unit);
- tp = com->tp;
-
- stat = com_tiocm_get(com);
- delta = com_tiocm_get_delta(com);
-
- if (com->state & CS_CTS_OFLOW) {
- if (stat & TIOCM_CTS)
- com->state |= CS_ODEVREADY;
- else
- com->state &= ~CS_ODEVREADY;
- }
- if ((delta & TIOCM_CAR) && (mynor & CALLOUT_MASK) == 0) {
- if (stat & TIOCM_CAR )
- (void)(*linesw[tp->t_line].l_modem)(tp, 1);
- else if ((*linesw[tp->t_line].l_modem)(tp, 0) == 0) {
- /* negate DTR, RTS */
- com_tiocm_bic(com, (tp->t_cflag & HUPCL) ?
- TIOCM_DTR|TIOCM_RTS|TIOCM_LE : TIOCM_LE );
- /* disable IENABLE */
- com_int_TxRx_disable( com );
- }
- }
-}
-#endif
-
-static void
-disc_optim(tp, t, com)
- struct tty *tp;
- struct termios *t;
- struct com_s *com;
-{
- if (!(t->c_iflag & (ICRNL | IGNCR | IMAXBEL | INLCR | ISTRIP | IXON))
- && (!(t->c_iflag & BRKINT) || (t->c_iflag & IGNBRK))
- && (!(t->c_iflag & PARMRK)
- || (t->c_iflag & (IGNPAR | IGNBRK)) == (IGNPAR | IGNBRK))
- && !(t->c_lflag & (ECHO | ICANON | IEXTEN | ISIG | PENDIN))
- && linesw[tp->t_line].l_rint == ttyinput)
- tp->t_state |= TS_CAN_BYPASS_L_RINT;
- else
- tp->t_state &= ~TS_CAN_BYPASS_L_RINT;
- com->hotchar = linesw[tp->t_line].l_hotchar;
-}
-
-/*
- * Following are all routines needed for SIO to act as console
- */
-#include <sys/cons.h>
-
-struct siocnstate {
- u_char dlbl;
- u_char dlbh;
- u_char ier;
- u_char cfcr;
- u_char mcr;
-};
-
-static speed_t siocngetspeed __P((Port_t, struct speedtab *));
-static void siocnclose __P((struct siocnstate *sp, Port_t iobase));
-static void siocnopen __P((struct siocnstate *sp, Port_t iobase, int speed));
-static void siocntxwait __P((Port_t iobase));
-
-static cn_probe_t siocnprobe;
-static cn_init_t siocninit;
-static cn_checkc_t siocncheckc;
-static cn_getc_t siocngetc;
-static cn_putc_t siocnputc;
-
-#ifdef __i386__
-CONS_DRIVER(sio, siocnprobe, siocninit, NULL, siocngetc, siocncheckc,
- siocnputc, NULL);
-#endif
-
-/* To get the GDB related variables */
-#if DDB > 0
-#include <ddb/ddb.h>
-#endif
-
-static void
-siocntxwait(iobase)
- Port_t iobase;
-{
- int timo;
-
- /*
- * Wait for any pending transmission to finish. Required to avoid
- * the UART lockup bug when the speed is changed, and for normal
- * transmits.
- */
- timo = 100000;
- while ((inb(iobase + com_lsr) & (LSR_TSRE | LSR_TXRDY))
- != (LSR_TSRE | LSR_TXRDY) && --timo != 0)
- ;
-}
-
-/*
- * Read the serial port specified and try to figure out what speed
- * it's currently running at. We're assuming the serial port has
- * been initialized and is basicly idle. This routine is only intended
- * to be run at system startup.
- *
- * If the value read from the serial port doesn't make sense, return 0.
- */
-
-static speed_t
-siocngetspeed(iobase, table)
- Port_t iobase;
- struct speedtab *table;
-{
- int code;
- u_char dlbh;
- u_char dlbl;
- u_char cfcr;
-
- cfcr = inb(iobase + com_cfcr);
- outb(iobase + com_cfcr, CFCR_DLAB | cfcr);
-
- dlbl = inb(iobase + com_dlbl);
- dlbh = inb(iobase + com_dlbh);
-
- outb(iobase + com_cfcr, cfcr);
-
- code = dlbh << 8 | dlbl;
-
- for (; table->sp_speed != -1; table++)
- if (table->sp_code == code)
- return (table->sp_speed);
-
- return 0; /* didn't match anything sane */
-}
-
-static void
-siocnopen(sp, iobase, speed)
- struct siocnstate *sp;
- Port_t iobase;
- int speed;
-{
- int divisor;
- u_char dlbh;
- u_char dlbl;
-
- /*
- * Save all the device control registers except the fifo register
- * and set our default ones (cs8 -parenb speed=comdefaultrate).
- * We can't save the fifo register since it is read-only.
- */
- sp->ier = inb(iobase + com_ier);
- outb(iobase + com_ier, 0); /* spltty() doesn't stop siointr() */
- siocntxwait(iobase);
- sp->cfcr = inb(iobase + com_cfcr);
- outb(iobase + com_cfcr, CFCR_DLAB | CFCR_8BITS);
- sp->dlbl = inb(iobase + com_dlbl);
- sp->dlbh = inb(iobase + com_dlbh);
- /*
- * Only set the divisor registers if they would change, since on
- * some 16550 incompatibles (Startech), setting them clears the
- * data input register. This also reduces the effects of the
- * UMC8669F bug.
- */
- divisor = ttspeedtab(speed, comspeedtab);
- dlbl = divisor & 0xFF;
- if (sp->dlbl != dlbl)
- outb(iobase + com_dlbl, dlbl);
- dlbh = (u_int) divisor >> 8;
- if (sp->dlbh != dlbh)
- outb(iobase + com_dlbh, dlbh);
- outb(iobase + com_cfcr, CFCR_8BITS);
- sp->mcr = inb(iobase + com_mcr);
- /*
- * We don't want interrupts, but must be careful not to "disable"
- * them by clearing the MCR_IENABLE bit, since that might cause
- * an interrupt by floating the IRQ line.
- */
- outb(iobase + com_mcr, (sp->mcr & MCR_IENABLE) | MCR_DTR | MCR_RTS);
-}
-
-static void
-siocnclose(sp, iobase)
- struct siocnstate *sp;
- Port_t iobase;
-{
- /*
- * Restore the device control registers.
- */
- siocntxwait(iobase);
- outb(iobase + com_cfcr, CFCR_DLAB | CFCR_8BITS);
- if (sp->dlbl != inb(iobase + com_dlbl))
- outb(iobase + com_dlbl, sp->dlbl);
- if (sp->dlbh != inb(iobase + com_dlbh))
- outb(iobase + com_dlbh, sp->dlbh);
- outb(iobase + com_cfcr, sp->cfcr);
- /*
- * XXX damp oscillations of MCR_DTR and MCR_RTS by not restoring them.
- */
- outb(iobase + com_mcr, sp->mcr | MCR_DTR | MCR_RTS);
- outb(iobase + com_ier, sp->ier);
-}
-
-static void
-siocnprobe(cp)
- struct consdev *cp;
-{
- speed_t boot_speed;
- u_char cfcr;
- int s, unit;
- struct siocnstate sp;
-
- /*
- * Find our first enabled console, if any. If it is a high-level
- * console device, then initialize it and return successfully.
- * If it is a low-level console device, then initialize it and
- * return unsuccessfully. It must be initialized in both cases
- * for early use by console drivers and debuggers. Initializing
- * the hardware is not necessary in all cases, since the i/o
- * routines initialize it on the fly, but it is necessary if
- * input might arrive while the hardware is switched back to an
- * uninitialized state. We can't handle multiple console devices
- * yet because our low-level routines don't take a device arg.
- * We trust the user to set the console flags properly so that we
- * don't need to probe.
- */
- cp->cn_pri = CN_DEAD;
-
- for (unit = 0; unit < 16; unit++) { /* XXX need to know how many */
- int flags;
- int disabled;
- if (resource_int_value("sio", unit, "disabled", &disabled) == 0) {
- if (disabled)
- continue;
- }
- if (resource_int_value("sio", unit, "flags", &flags))
- continue;
- if (COM_CONSOLE(flags) || COM_DEBUGGER(flags)) {
- int port;
- Port_t iobase;
-
- if (resource_int_value("sio", unit, "port", &port))
- continue;
- iobase = port;
- s = spltty();
- if (boothowto & RB_SERIAL) {
- boot_speed = siocngetspeed(iobase, comspeedtab);
- if (boot_speed)
- comdefaultrate = boot_speed;
- }
-
- /*
- * Initialize the divisor latch. We can't rely on
- * siocnopen() to do this the first time, since it
- * avoids writing to the latch if the latch appears
- * to have the correct value. Also, if we didn't
- * just read the speed from the hardware, then we
- * need to set the speed in hardware so that
- * switching it later is null.
- */
- cfcr = inb(iobase + com_cfcr);
- outb(iobase + com_cfcr, CFCR_DLAB | cfcr);
- outb(iobase + com_dlbl,
- COMBRD(comdefaultrate) & 0xff);
- outb(iobase + com_dlbh,
- (u_int) COMBRD(comdefaultrate) >> 8);
- outb(iobase + com_cfcr, cfcr);
-
- siocnopen(&sp, iobase, comdefaultrate);
-
- splx(s);
- if (COM_CONSOLE(flags) && !COM_LLCONSOLE(flags)) {
- cp->cn_dev = makedev(CDEV_MAJOR, unit);
- cp->cn_pri = COM_FORCECONSOLE(flags)
- || boothowto & RB_SERIAL
- ? CN_REMOTE : CN_NORMAL;
- siocniobase = iobase;
- siocnunit = unit;
- }
- if (COM_DEBUGGER(flags)) {
- printf("sio%d: gdb debugging port\n", unit);
- siogdbiobase = iobase;
- siogdbunit = unit;
-#if DDB > 0
- gdbdev = makedev(CDEV_MAJOR, unit);
- gdb_getc = siocngetc;
- gdb_putc = siocnputc;
-#endif
- }
- }
- }
-#ifdef __i386__
-#if DDB > 0
- /*
- * XXX Ugly Compatability.
- * If no gdb port has been specified, set it to be the console
- * as some configuration files don't specify the gdb port.
- */
- if (gdbdev == NODEV && (boothowto & RB_GDB)) {
- printf("Warning: no GDB port specified. Defaulting to sio%d.\n",
- siocnunit);
- printf("Set flag 0x80 on desired GDB port in your\n");
- printf("configuration file (currently sio only).\n");
- siogdbiobase = siocniobase;
- siogdbunit = siocnunit;
- gdbdev = makedev(CDEV_MAJOR, siocnunit);
- gdb_getc = siocngetc;
- gdb_putc = siocnputc;
- }
-#endif
-#endif
-}
-
-#ifdef __alpha__
-
-CONS_DRIVER(sio, NULL, NULL, NULL, siocngetc, siocncheckc, siocnputc, NULL);
-
-int
-siocnattach(port, speed)
- int port;
- int speed;
-{
- int s;
- u_char cfcr;
- struct siocnstate sp;
-
- siocniobase = port;
- comdefaultrate = speed;
- sio_consdev.cn_pri = CN_NORMAL;
- sio_consdev.cn_dev = makedev(CDEV_MAJOR, 0);
-
- s = spltty();
-
- /*
- * Initialize the divisor latch. We can't rely on
- * siocnopen() to do this the first time, since it
- * avoids writing to the latch if the latch appears
- * to have the correct value. Also, if we didn't
- * just read the speed from the hardware, then we
- * need to set the speed in hardware so that
- * switching it later is null.
- */
- cfcr = inb(siocniobase + com_cfcr);
- outb(siocniobase + com_cfcr, CFCR_DLAB | cfcr);
- outb(siocniobase + com_dlbl,
- COMBRD(comdefaultrate) & 0xff);
- outb(siocniobase + com_dlbh,
- (u_int) COMBRD(comdefaultrate) >> 8);
- outb(siocniobase + com_cfcr, cfcr);
-
- siocnopen(&sp, siocniobase, comdefaultrate);
- splx(s);
-
- cn_tab = &sio_consdev;
- return 0;
-}
-
-int
-siogdbattach(port, speed)
- int port;
- int speed;
-{
- int s;
- u_char cfcr;
- struct siocnstate sp;
-
- siogdbiobase = port;
- gdbdefaultrate = speed;
-
- s = spltty();
-
- /*
- * Initialize the divisor latch. We can't rely on
- * siocnopen() to do this the first time, since it
- * avoids writing to the latch if the latch appears
- * to have the correct value. Also, if we didn't
- * just read the speed from the hardware, then we
- * need to set the speed in hardware so that
- * switching it later is null.
- */
- cfcr = inb(siogdbiobase + com_cfcr);
- outb(siogdbiobase + com_cfcr, CFCR_DLAB | cfcr);
- outb(siogdbiobase + com_dlbl,
- COMBRD(gdbdefaultrate) & 0xff);
- outb(siogdbiobase + com_dlbh,
- (u_int) COMBRD(gdbdefaultrate) >> 8);
- outb(siogdbiobase + com_cfcr, cfcr);
-
- siocnopen(&sp, siogdbiobase, gdbdefaultrate);
- splx(s);
-
- return 0;
-}
-
-#endif
-
-static void
-siocninit(cp)
- struct consdev *cp;
-{
- comconsole = DEV_TO_UNIT(cp->cn_dev);
-}
-
-static int
-siocncheckc(dev)
- dev_t dev;
-{
- int c;
- Port_t iobase;
- int s;
- struct siocnstate sp;
-
- if (minor(dev) == siogdbunit)
- iobase = siogdbiobase;
- else
- iobase = siocniobase;
- s = spltty();
- siocnopen(&sp, iobase, comdefaultrate);
- if (inb(iobase + com_lsr) & LSR_RXRDY)
- c = inb(iobase + com_data);
- else
- c = -1;
- siocnclose(&sp, iobase);
- splx(s);
- return (c);
-}
-
-
-int
-siocngetc(dev)
- dev_t dev;
-{
- int c;
- Port_t iobase;
- int s;
- struct siocnstate sp;
-
- if (minor(dev) == siogdbunit)
- iobase = siogdbiobase;
- else
- iobase = siocniobase;
- s = spltty();
- siocnopen(&sp, iobase, comdefaultrate);
- while (!(inb(iobase + com_lsr) & LSR_RXRDY))
- ;
- c = inb(iobase + com_data);
- siocnclose(&sp, iobase);
- splx(s);
- return (c);
-}
-
-void
-siocnputc(dev, c)
- dev_t dev;
- int c;
-{
- int s;
- struct siocnstate sp;
- Port_t iobase;
-
- if (minor(dev) == siogdbunit)
- iobase = siogdbiobase;
- else
- iobase = siocniobase;
- s = spltty();
- siocnopen(&sp, iobase, comdefaultrate);
- siocntxwait(iobase);
- outb(iobase + com_data, c);
- siocnclose(&sp, iobase);
- splx(s);
-}
-
-#ifdef __alpha__
-int
-siogdbgetc()
-{
- int c;
- Port_t iobase;
- int s;
- struct siocnstate sp;
-
- iobase = siogdbiobase;
- s = spltty();
- siocnopen(&sp, iobase, gdbdefaultrate);
- while (!(inb(iobase + com_lsr) & LSR_RXRDY))
- ;
- c = inb(iobase + com_data);
- siocnclose(&sp, iobase);
- splx(s);
- return (c);
-}
-
-void
-siogdbputc(c)
- int c;
-{
- int s;
- struct siocnstate sp;
-
- s = spltty();
- siocnopen(&sp, siogdbiobase, gdbdefaultrate);
- siocntxwait(siogdbiobase);
- outb(siogdbiobase + com_data, c);
- siocnclose(&sp, siogdbiobase);
- splx(s);
-}
-#endif
-
-DRIVER_MODULE(sio, isa, sio_isa_driver, sio_devclass, 0, 0);
-#if NCARD > 0
-DRIVER_MODULE(sio, pccard, sio_pccard_driver, sio_devclass, 0, 0);
-#endif
-
-#ifdef PC98
-/*
- * pc98 local function
- */
-
-static void
-com_tiocm_set(struct com_s *com, int msr)
-{
- int s;
- int tmp = 0;
- int mask = CMD8251_TxEN|CMD8251_RxEN|CMD8251_DTR|CMD8251_RTS;
-
- s=spltty();
- com->pc98_prev_modem_status = ( msr & (TIOCM_LE|TIOCM_DTR|TIOCM_RTS) )
- | ( com->pc98_prev_modem_status & ~(TIOCM_LE|TIOCM_DTR|TIOCM_RTS) );
- tmp |= (CMD8251_TxEN|CMD8251_RxEN);
- if ( msr & TIOCM_DTR ) tmp |= CMD8251_DTR;
- if ( msr & TIOCM_RTS ) tmp |= CMD8251_RTS;
- pc98_i8251_clear_or_cmd( com, mask, tmp );
- splx(s);
-}
-
-static void
-com_tiocm_bis(struct com_s *com, int msr)
-{
- int s;
- int tmp = 0;
-
- s=spltty();
- com->pc98_prev_modem_status |= ( msr & (TIOCM_LE|TIOCM_DTR|TIOCM_RTS) );
- tmp |= CMD8251_TxEN|CMD8251_RxEN;
- if ( msr & TIOCM_DTR ) tmp |= CMD8251_DTR;
- if ( msr & TIOCM_RTS ) tmp |= CMD8251_RTS;
-
- pc98_i8251_or_cmd( com, tmp );
- splx(s);
-}
-
-static void
-com_tiocm_bic(struct com_s *com, int msr)
-{
- int s;
- int tmp = msr;
-
- s=spltty();
- com->pc98_prev_modem_status &= ~( msr & (TIOCM_LE|TIOCM_DTR|TIOCM_RTS) );
- if ( msr & TIOCM_DTR ) tmp |= CMD8251_DTR;
- if ( msr & TIOCM_RTS ) tmp |= CMD8251_RTS;
-
- pc98_i8251_clear_cmd( com, tmp );
- splx(s);
-}
-
-static int
-com_tiocm_get(struct com_s *com)
-{
- return( com->pc98_prev_modem_status );
-}
-
-static int
-com_tiocm_get_delta(struct com_s *com)
-{
- int tmp;
-
- tmp = com->pc98_modem_delta;
- com->pc98_modem_delta = 0;
- return( tmp );
-}
-
-/* convert to TIOCM_?? ( ioctl.h ) */
-static int
-pc98_get_modem_status(struct com_s *com)
-{
- register int msr;
-
- msr = com->pc98_prev_modem_status
- & ~(TIOCM_CAR|TIOCM_RI|TIOCM_DSR|TIOCM_CTS);
- if (com->pc98_8251fifo_enable) {
- int stat2;
-
- stat2 = inb(I8251F_msr);
- if ( stat2 & CICSCDF_CD ) msr |= TIOCM_CAR;
- if ( stat2 & CICSCDF_CI ) msr |= TIOCM_RI;
- if ( stat2 & CICSCDF_DR ) msr |= TIOCM_DSR;
- if ( stat2 & CICSCDF_CS ) msr |= TIOCM_CTS;
-#if COM_CARRIER_DETECT_EMULATE
- if ( msr & (TIOCM_DSR|TIOCM_CTS) ) {
- msr |= TIOCM_CAR;
- }
-#endif
- } else {
- int stat, stat2;
-
- stat = inb(com->sts_port);
- stat2 = inb(com->in_modem_port);
- if ( !(stat2 & CICSCD_CD) ) msr |= TIOCM_CAR;
- if ( !(stat2 & CICSCD_CI) ) msr |= TIOCM_RI;
- if ( stat & STS8251_DSR ) msr |= TIOCM_DSR;
- if ( !(stat2 & CICSCD_CS) ) msr |= TIOCM_CTS;
-#if COM_CARRIER_DETECT_EMULATE
- if ( msr & (TIOCM_DSR|TIOCM_CTS) ) {
- msr |= TIOCM_CAR;
- }
-#endif
- }
- return(msr);
-}
-
-static void
-pc98_check_msr(void* chan)
-{
- int msr, delta;
- int s;
- register struct tty *tp;
- struct com_s *com;
- int mynor;
- int unit;
- dev_t dev;
-
- dev=(dev_t)chan;
- mynor = minor(dev);
- unit = MINOR_TO_UNIT(mynor);
- com = com_addr(unit);
- tp = com->tp;
-
- s = spltty();
- msr = pc98_get_modem_status(com);
- /* make change flag */
- delta = msr ^ com->pc98_prev_modem_status;
- if ( delta & TIOCM_CAR ) {
- if ( com->modem_car_chg_timer ) {
- if ( -- com->modem_car_chg_timer )
- msr ^= TIOCM_CAR;
- } else {
- if ((com->modem_car_chg_timer = (msr & TIOCM_CAR) ?
- DCD_ON_RECOGNITION : DCD_OFF_TOLERANCE) != 0)
- msr ^= TIOCM_CAR;
- }
- } else
- com->modem_car_chg_timer = 0;
- delta = ( msr ^ com->pc98_prev_modem_status ) &
- (TIOCM_CAR|TIOCM_RI|TIOCM_DSR|TIOCM_CTS);
- com->pc98_prev_modem_status = msr;
- delta = ( com->pc98_modem_delta |= delta );
- splx(s);
- if ( com->modem_checking || (tp->t_state & (TS_ISOPEN)) ) {
- if ( delta ) {
- commint(dev);
- }
- timeout(pc98_check_msr, (caddr_t)dev,
- PC98_CHECK_MODEM_INTERVAL);
- } else {
- com->modem_checking = 0;
- }
-}
-
-static void
-pc98_msrint_start(dev_t dev)
-{
- struct com_s *com;
- int mynor;
- int unit;
- int s = spltty();
-
- mynor = minor(dev);
- unit = MINOR_TO_UNIT(mynor);
- com = com_addr(unit);
- /* modem control line check routine envoke interval is 1/10 sec */
- if ( com->modem_checking == 0 ) {
- com->pc98_prev_modem_status = pc98_get_modem_status(com);
- com->pc98_modem_delta = 0;
- timeout(pc98_check_msr, (caddr_t)dev,
- PC98_CHECK_MODEM_INTERVAL);
- com->modem_checking = 1;
- }
- splx(s);
-}
-
-static void
-pc98_disable_i8251_interrupt(struct com_s *com, int mod)
-{
- /* disable interrupt */
- register int tmp;
-
- mod |= ~(IEN_Tx|IEN_TxEMP|IEN_Rx);
- COM_INT_DISABLE
- tmp = inb( com->intr_ctrl_port ) & ~(IEN_Tx|IEN_TxEMP|IEN_Rx);
- outb( com->intr_ctrl_port, (com->intr_enable&=~mod) | tmp );
- COM_INT_ENABLE
-}
-
-static void
-pc98_enable_i8251_interrupt(struct com_s *com, int mod)
-{
- register int tmp;
-
- COM_INT_DISABLE
- tmp = inb( com->intr_ctrl_port ) & ~(IEN_Tx|IEN_TxEMP|IEN_Rx);
- outb( com->intr_ctrl_port, (com->intr_enable|=mod) | tmp );
- COM_INT_ENABLE
-}
-
-static int
-pc98_check_i8251_interrupt(struct com_s *com)
-{
- return ( com->intr_enable & 0x07 );
-}
-
-static void
-pc98_i8251_clear_cmd(struct com_s *com, int x)
-{
- int tmp;
-
- COM_INT_DISABLE
- tmp = com->pc98_prev_siocmd & ~(x);
- if (com->pc98_8251fifo_enable)
- outb(I8251F_fcr, 0);
- outb(com->cmd_port, tmp);
- com->pc98_prev_siocmd = tmp & ~(CMD8251_ER|CMD8251_RESET|CMD8251_EH);
- if (com->pc98_8251fifo_enable)
- outb(I8251F_fcr, CTRL8251F_ENABLE);
- COM_INT_ENABLE
-}
-
-static void
-pc98_i8251_or_cmd(struct com_s *com, int x)
-{
- int tmp;
-
- COM_INT_DISABLE
- if (com->pc98_8251fifo_enable)
- outb(I8251F_fcr, 0);
- tmp = com->pc98_prev_siocmd | (x);
- outb(com->cmd_port, tmp);
- com->pc98_prev_siocmd = tmp & ~(CMD8251_ER|CMD8251_RESET|CMD8251_EH);
- if (com->pc98_8251fifo_enable)
- outb(I8251F_fcr, CTRL8251F_ENABLE);
- COM_INT_ENABLE
-}
-
-static void
-pc98_i8251_set_cmd(struct com_s *com, int x)
-{
- int tmp;
-
- COM_INT_DISABLE
- if (com->pc98_8251fifo_enable)
- outb(I8251F_fcr, 0);
- tmp = (x);
- outb(com->cmd_port, tmp);
- com->pc98_prev_siocmd = tmp & ~(CMD8251_ER|CMD8251_RESET|CMD8251_EH);
- if (com->pc98_8251fifo_enable)
- outb(I8251F_fcr, CTRL8251F_ENABLE);
- COM_INT_ENABLE
-}
-
-static void
-pc98_i8251_clear_or_cmd(struct com_s *com, int clr, int x)
-{
- int tmp;
- COM_INT_DISABLE
- if (com->pc98_8251fifo_enable)
- outb(I8251F_fcr, 0);
- tmp = com->pc98_prev_siocmd & ~(clr);
- tmp |= (x);
- outb(com->cmd_port, tmp);
- com->pc98_prev_siocmd = tmp & ~(CMD8251_ER|CMD8251_RESET|CMD8251_EH);
- if (com->pc98_8251fifo_enable)
- outb(I8251F_fcr, CTRL8251F_ENABLE);
- COM_INT_ENABLE
-}
-
-static int
-pc98_i8251_get_cmd(struct com_s *com)
-{
- return com->pc98_prev_siocmd;
-}
-
-static int
-pc98_i8251_get_mod(struct com_s *com)
-{
- return com->pc98_prev_siomod;
-}
-
-static void
-pc98_i8251_reset(struct com_s *com, int mode, int command)
-{
- if (com->pc98_8251fifo_enable)
- outb(I8251F_fcr, 0);
- outb(com->cmd_port, 0); /* dummy */
- DELAY(2);
- outb(com->cmd_port, 0); /* dummy */
- DELAY(2);
- outb(com->cmd_port, 0); /* dummy */
- DELAY(2);
- outb(com->cmd_port, CMD8251_RESET); /* internal reset */
- DELAY(2);
- outb(com->cmd_port, mode ); /* mode register */
- com->pc98_prev_siomod = mode;
- DELAY(2);
- pc98_i8251_set_cmd( com, (command|CMD8251_ER) );
- DELAY(10);
- if (com->pc98_8251fifo_enable)
- outb(I8251F_fcr, CTRL8251F_ENABLE |
- CTRL8251F_XMT_RST | CTRL8251F_RCV_RST);
-}
-
-static void
-pc98_check_sysclock(void)
-{
- /* get system clock from port */
- if ( pc98_machine_type & M_8M ) {
- /* 8 MHz system & H98 */
- sysclock = 8;
- } else {
- /* 5 MHz system */
- sysclock = 5;
- }
-}
-
-static void
-com_cflag_and_speed_set( struct com_s *com, int cflag, int speed)
-{
- int cfcr=0, count;
- int previnterrupt;
-
- count = pc98_ttspeedtab( com, speed );
- if ( count < 0 ) return;
-
- previnterrupt = pc98_check_i8251_interrupt(com);
- pc98_disable_i8251_interrupt( com, IEN_Tx|IEN_TxEMP|IEN_Rx );
-
- switch ( cflag&CSIZE ) {
- case CS5:
- cfcr = MOD8251_5BITS; break;
- case CS6:
- cfcr = MOD8251_6BITS; break;
- case CS7:
- cfcr = MOD8251_7BITS; break;
- case CS8:
- cfcr = MOD8251_8BITS; break;
- }
- if ( cflag&PARENB ) {
- if ( cflag&PARODD )
- cfcr |= MOD8251_PODD;
- else
- cfcr |= MOD8251_PEVEN;
- } else
- cfcr |= MOD8251_PDISAB;
-
- if ( cflag&CSTOPB )
- cfcr |= MOD8251_STOP2;
- else
- cfcr |= MOD8251_STOP1;
-
- if ( count & 0x10000 )
- cfcr |= MOD8251_CLKX1;
- else
- cfcr |= MOD8251_CLKX16;
-
- if (epson_machine_id != 0x20) { /* XXX */
- int tmp;
- while (!((tmp = inb(com->sts_port)) & STS8251_TxEMP))
- ;
- }
- /* set baud rate from ospeed */
- pc98_set_baud_rate( com, count );
-
- if ( cfcr != pc98_i8251_get_mod(com) )
- pc98_i8251_reset(com, cfcr, pc98_i8251_get_cmd(com) );
-
- pc98_enable_i8251_interrupt( com, previnterrupt );
-}
-
-static int
-pc98_ttspeedtab(struct com_s *com, int speed)
-{
- int if_type, effect_sp, count = -1, mod;
-
- if_type = com->pc98_if_type & 0x0f;
-
- switch (com->pc98_if_type) {
- case COM_IF_INTERNAL:
- if (PC98SIO_baud_rate_port(if_type) != -1) {
- count = ttspeedtab(speed, if_8251_type[if_type].speedtab);
- if (count > 0) {
- count |= COM1_EXT_CLOCK;
- break;
- }
- }
-
- /* for *1CLK asynchronous! mode, TEFUTEFU */
- mod = (sysclock == 5) ? 2457600 : 1996800;
- effect_sp = ttspeedtab( speed, pc98speedtab );
- if ( effect_sp < 0 ) /* XXX */
- effect_sp = ttspeedtab( (speed - 1), pc98speedtab );
- if ( effect_sp <= 0 )
- return effect_sp;
- if ( effect_sp == speed )
- mod /= 16;
- if ( mod % effect_sp )
- return(-1);
- count = mod / effect_sp;
- if ( count > 65535 )
- return(-1);
- if ( effect_sp != speed )
- count |= 0x10000;
- break;
- case COM_IF_PC9861K_1:
- case COM_IF_PC9861K_2:
- count = 1;
- break;
- case COM_IF_IND_SS_1:
- case COM_IF_IND_SS_2:
- case COM_IF_PIO9032B_1:
- case COM_IF_PIO9032B_2:
- if ( speed == 0 ) return 0;
- count = ttspeedtab( speed, if_8251_type[if_type].speedtab );
- break;
- case COM_IF_B98_01_1:
- case COM_IF_B98_01_2:
- if ( speed == 0 ) return 0;
- count = ttspeedtab( speed, if_8251_type[if_type].speedtab );
-#ifdef B98_01_OLD
- if (count == 0 || count == 1) {
- count += 4;
- count |= 0x20000; /* x1 mode for 76800 and 153600 */
- }
-#endif
- break;
- }
-
- return count;
-}
-
-static void
-pc98_set_baud_rate( struct com_s *com, int count )
-{
- int if_type, io, s;
-
- if_type = com->pc98_if_type & 0x0f;
- io = com->iobase & 0xff00;
-
- switch (com->pc98_if_type) {
- case COM_IF_INTERNAL:
- if (PC98SIO_baud_rate_port(if_type) != -1) {
- if (count & COM1_EXT_CLOCK) {
- outb((Port_t)PC98SIO_baud_rate_port(if_type), count & 0xff);
- break;
- } else {
- outb((Port_t)PC98SIO_baud_rate_port(if_type), 0x09);
- }
- }
-
- if ( count < 0 ) {
- printf( "[ Illegal count : %d ]", count );
- return;
- } else if ( count == 0 )
- return;
- /* set i8253 */
- s = splclock();
- if (count != 3)
- outb( 0x77, 0xb6 );
- else
- outb( 0x77, 0xb4 );
- outb( 0x5f, 0);
- outb( 0x75, count & 0xff );
- outb( 0x5f, 0);
- outb( 0x75, (count >> 8) & 0xff );
- splx(s);
- break;
- case COM_IF_IND_SS_1:
- case COM_IF_IND_SS_2:
- outb(io | PC98SIO_intr_ctrl_port(if_type), 0);
- outb(io | PC98SIO_baud_rate_port(if_type), 0);
- outb(io | PC98SIO_baud_rate_port(if_type), 0xc0);
- outb(io | PC98SIO_baud_rate_port(if_type), (count >> 8) | 0x80);
- outb(io | PC98SIO_baud_rate_port(if_type), count & 0xff);
- break;
- case COM_IF_PIO9032B_1:
- case COM_IF_PIO9032B_2:
- outb(io | PC98SIO_baud_rate_port(if_type), count);
- break;
- case COM_IF_B98_01_1:
- case COM_IF_B98_01_2:
- outb(io | PC98SIO_baud_rate_port(if_type), count & 0x0f);
-#ifdef B98_01_OLD
- /*
- * Some old B98_01 board should be controlled
- * in different way, but this hasn't been tested yet.
- */
- outb(io | PC98SIO_func_port(if_type),
- (count & 0x20000) ? 0xf0 : 0xf2);
-#endif
- break;
- }
-}
-static int
-pc98_check_if_type(device_t dev, struct siodev *iod)
-{
- int irr, io, if_type, tmp;
- static short irq_tab[2][8] = {
- { 3, 5, 6, 9, 10, 12, 13, -1},
- { 3, 10, 12, 13, 5, 6, 9, -1}
- };
-
- iod->if_type = if_type = GET_IFTYPE(device_get_flags(dev));
- if ((if_type < 0 || if_type > COM_IF_END1) &&
- (if_type < 0x10 || if_type > COM_IF_END2))
- return(-1);
- if_type &= 0x0f;
- iod->irq = 0;
- io = isa_get_port(dev) & 0xff00;
-
- if (IS_8251(iod->if_type)) {
- if (PC98SIO_func_port(if_type) != -1) {
- outb(io | PC98SIO_func_port(if_type), 0xf2);
- tmp = ttspeedtab(9600, if_8251_type[if_type].speedtab);
- if (tmp != -1 && PC98SIO_baud_rate_port(if_type) != -1)
- outb(io | PC98SIO_baud_rate_port(if_type), tmp);
- }
-
- iod->cmd = io | PC98SIO_cmd_port(if_type);
- iod->sts = io | PC98SIO_sts_port(if_type);
- iod->mod = io | PC98SIO_in_modem_port(if_type);
- iod->ctrl = io | PC98SIO_intr_ctrl_port(if_type);
-
- if (iod->if_type == COM_IF_INTERNAL) {
- iod->irq = 4;
-
- if (pc98_check_8251vfast()) {
- PC98SIO_baud_rate_port(if_type) = I8251F_div;
- if_8251_type[if_type].speedtab = pc98fast_speedtab;
- }
- } else {
- tmp = inb( iod->mod ) & if_8251_type[if_type].irr_mask;
- if ((isa_get_port(dev) & 0xff) == IO_COM2)
- iod->irq = irq_tab[0][tmp];
- else
- iod->irq = irq_tab[1][tmp];
- }
- } else {
- irr = if_16550a_type[if_type].irr_read;
-#ifdef COM_MULTIPORT
- if (!COM_ISMULTIPORT(device_get_flags(dev)) ||
- device_get_unit(dev) == COM_MPMASTER(device_get_flags(dev)))
-#endif
- if (irr != -1) {
- tmp = inb(io | irr);
- if (isa_get_port(dev) & 0x01) /* XXX depend on RSB-384 */
- iod->irq = irq_tab[1][tmp >> 3];
- else
- iod->irq = irq_tab[0][tmp & 0x07];
- }
- }
- if ( iod->irq == -1 ) return -1;
-
- return 0;
-}
-static int
-pc98_set_ioport(struct com_s *com)
-{
- int if_type = com->pc98_if_type & 0x0f;
- int io = com->iobase & 0xff00;
-
- if (IS_8251(com->pc98_if_type)) {
- pc98_check_sysclock();
- com->data_port = io | PC98SIO_data_port(if_type);
- com->cmd_port = io | PC98SIO_cmd_port(if_type);
- com->sts_port = io | PC98SIO_sts_port(if_type);
- com->in_modem_port = io | PC98SIO_in_modem_port(if_type);
- com->intr_ctrl_port = io | PC98SIO_intr_ctrl_port(if_type);
-
- return 0;
- }
-
- return -1;
-}
-static int
-pc98_check_8251vfast(void)
-{
- int i;
-
- outb(I8251F_div, 0x8c);
- DELAY(10);
- for (i = 0; i < 100; i++) {
- if ((inb(I8251F_div) & 0x80) != 0) {
- i = 0;
- break;
- }
- DELAY(1);
- }
- outb(I8251F_div, 0);
- DELAY(10);
- for (; i < 100; i++) {
- if ((inb(I8251F_div) & 0x80) == 0)
- return 1;
- DELAY(1);
- }
-
- return 0;
-}
-static int
-pc98_check_8251fifo(void)
-{
- u_char tmp1, tmp2;
-
- tmp1 = inb(I8251F_iir);
- DELAY(10);
- tmp2 = inb(I8251F_iir);
- if (((tmp1 ^ tmp2) & 0x40) != 0 && ((tmp1 | tmp2) & 0x20) == 0)
- return 1;
-
- return 0;
-}
-#endif /* PC98 defined */
diff --git a/sys/pc98/cbus/syscons_cbus.c b/sys/pc98/cbus/syscons_cbus.c
deleted file mode 100644
index d4f5bd1541d4..000000000000
--- a/sys/pc98/cbus/syscons_cbus.c
+++ /dev/null
@@ -1,217 +0,0 @@
-/*-
- * Copyright (c) 1999 FreeBSD(98) Porting Team.
- * 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 as
- * the first lines of this file unmodified.
- * 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 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.
- *
- * $FreeBSD$
- */
-
-#include "sc.h"
-#include "opt_syscons.h"
-
-#if NSC > 0
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/bus.h>
-
-#include <sys/cons.h>
-#include <machine/console.h>
-#include <machine/clock.h>
-
-#include <pc98/pc98/pc98.h>
-#include <pc98/pc98/pc98_machdep.h>
-
-#include <dev/syscons/syscons.h>
-
-#include <i386/isa/timerreg.h>
-
-#include <isa/isavar.h>
-
-static devclass_t sc_devclass;
-
-static int scprobe(device_t dev);
-static int scattach(device_t dev);
-static int scresume(device_t dev);
-
-static device_method_t sc_methods[] = {
- DEVMETHOD(device_probe, scprobe),
- DEVMETHOD(device_attach, scattach),
- DEVMETHOD(device_resume, scresume),
- { 0, 0 }
-};
-
-static driver_t sc_driver = {
- SC_DRIVER_NAME,
- sc_methods,
- sizeof(sc_softc_t),
-};
-
-static sc_softc_t main_softc;
-
-static int
-scprobe(device_t dev)
-{
- /* No pnp support */
- if (isa_get_vendorid(dev))
- return (ENXIO);
-
- device_set_desc(dev, "System console");
- return sc_probe_unit(device_get_unit(dev), device_get_flags(dev));
-}
-
-static int
-scattach(device_t dev)
-{
- return sc_attach_unit(device_get_unit(dev), device_get_flags(dev));
-}
-
-static int
-scresume(device_t dev)
-{
- return sc_resume_unit(device_get_unit(dev));
-}
-
-int
-sc_max_unit(void)
-{
- return devclass_get_maxunit(sc_devclass);
-}
-
-sc_softc_t
-*sc_get_softc(int unit, int flags)
-{
- sc_softc_t *sc;
-
- if ((unit < 0) || (unit >= NSC))
- return NULL;
- if (flags & SC_KERNEL_CONSOLE) {
- /* FIXME: clear if it is wired to another unit! */
- sc = &main_softc;
- } else {
- sc = (sc_softc_t *)device_get_softc(devclass_get_device(sc_devclass, unit));
- }
- sc->unit = unit;
- if (!(sc->flags & SC_INIT_DONE)) {
- sc->keyboard = -1;
- sc->adapter = -1;
- sc->mouse_char = SC_MOUSE_CHAR;
- }
- return sc;
-}
-
-sc_softc_t
-*sc_find_softc(struct video_adapter *adp, struct keyboard *kbd)
-{
- sc_softc_t *sc;
- int units;
- int i;
-
- sc = &main_softc;
- if (((adp == NULL) || (adp == sc->adp))
- && ((kbd == NULL) || (kbd == sc->kbd)))
- return sc;
- units = devclass_get_maxunit(sc_devclass);
- for (i = 0; i < units; ++i) {
- sc = (sc_softc_t *)device_get_softc(devclass_get_device(sc_devclass, i));
- if (sc == NULL)
- continue;
- if (((adp == NULL) || (adp == sc->adp))
- && ((kbd == NULL) || (kbd == sc->kbd)))
- return sc;
- }
- return NULL;
-}
-
-int
-sc_get_cons_priority(int *unit, int *flags)
-{
- int disabled;
- int u, f;
- int i;
-
- *unit = -1;
- for (i = -1; (i = resource_locate(i, SC_DRIVER_NAME)) >= 0;) {
- u = resource_query_unit(i);
- if ((resource_int_value(SC_DRIVER_NAME, u, "disabled",
- &disabled) == 0) && disabled)
- continue;
- if (resource_int_value(SC_DRIVER_NAME, u, "flags", &f) != 0)
- f = 0;
- if (f & SC_KERNEL_CONSOLE) {
- /* the user designates this unit to be the console */
- *unit = u;
- *flags = f;
- break;
- }
- if (*unit < 0) {
- /* ...otherwise remember the first found unit */
- *unit = u;
- *flags = f;
- }
- }
- if ((i < 0) && (*unit < 0))
- return CN_DEAD;
- return CN_INTERNAL;
-}
-
-void
-sc_get_bios_values(bios_values_t *values)
-{
- values->cursor_start = 0;
- values->cursor_end = 16;
- values->shift_state = 0;
- if (pc98_machine_type & M_8M)
- values->bell_pitch = BELL_PITCH_8M;
- else
- values->bell_pitch = BELL_PITCH_5M;
-}
-
-int
-sc_tone(int herz)
-{
- int pitch;
-
- if (herz) {
- /* enable counter 1 */
- outb(0x35, inb(0x35) & 0xf7);
- /* set command for counter 1, 2 byte write */
- if (acquire_timer1(TIMER_16BIT | TIMER_SQWAVE))
- return EBUSY;
- /* set pitch */
- pitch = timer_freq/herz;
- outb(TIMER_CNTR1, pitch);
- outb(TIMER_CNTR1, pitch >> 8);
- } else {
- /* disable counter 1 */
- outb(0x35, inb(0x35) | 0x08);
- release_timer1();
- }
- return 0;
-}
-
-DRIVER_MODULE(sc, isa, sc_driver, sc_devclass, 0, 0);
-
-#endif /* NSC > 0 */
diff --git a/sys/pc98/conf/GENERIC b/sys/pc98/conf/GENERIC
deleted file mode 100644
index e8b98a3b67e5..000000000000
--- a/sys/pc98/conf/GENERIC
+++ /dev/null
@@ -1,313 +0,0 @@
-#
-# GENERIC -- Generic kernel configuration file for FreeBSD/pc98
-#
-# For more information on this file, please read the handbook section on
-# Kernel Configuration Files:
-#
-# http://www.freebsd.org/handbook/kernelconfig-config.html
-#
-# The handbook is also available locally in /usr/share/doc/handbook
-# if you've installed the doc distribution, otherwise always see the
-# FreeBSD World Wide Web server (http://www.FreeBSD.ORG/) for the
-# latest information.
-#
-# An exhaustive list of options and more detailed explanations of the
-# device lines is also present in the ./LINT configuration file. If you are
-# in doubt as to the purpose or necessity of a line, check first in LINT.
-#
-# $FreeBSD$
-
-machine pc98
-cpu I386_CPU
-cpu I486_CPU
-cpu I586_CPU
-cpu I686_CPU
-ident GENERIC98
-maxusers 32
-
-#makeoptions DEBUG=-g #Build kernel with gdb(1) debug symbols
-
-options PC98 #PC98
-options MATH_EMULATE #Support for x87 emulation
-options INET #InterNETworking
-options INET6 #IPv6 communications protocols
-options FFS #Berkeley Fast Filesystem
-options FFS_ROOT #FFS usable as root device [keep this!]
-options MFS #Memory Filesystem
-options MD_ROOT #MD is a potential root device
-options NFS #Network Filesystem
-options NFS_ROOT #NFS usable as root device, NFS required
-options MSDOSFS #MSDOS Filesystem
-options CD9660 #ISO 9660 Filesystem
-options CD9660_ROOT #CD-ROM usable as root, CD9660 required
-options PROCFS #Process filesystem
-options COMPAT_43 #Compatible with BSD 4.3 [KEEP THIS!]
-options SCSI_DELAY=15000 #Delay (in ms) before probing SCSI
-options EPSON_BOUNCEDMA #use bounce buufer for 15-16M
-#options EPSON_MEMWIN #EPSON memory window support
-options UCONSOLE #Allow users to grab the console
-#options LINE30
-options USERCONFIG #boot -c editor
-options VISUAL_USERCONFIG #visual boot -c editor
-options KTRACE #ktrace(1) support
-options SYSVSHM #SYSV-style shared memory
-options SYSVMSG #SYSV-style message queues
-options SYSVSEM #SYSV-style semaphores
-options P1003_1B #Posix P1003_1B real-time extentions
-options _KPOSIX_PRIORITY_SCHEDULING
-options ICMP_BANDLIM #Rate limit bad replies
-
-# To make an SMP kernel, the next two are needed
-#options SMP # Symmetric MultiProcessor Kernel
-#options APIC_IO # Symmetric (APIC) I/O
-# Optionally these may need tweaked, (defaults shown):
-#options NCPU=2 # number of CPUs
-#options NBUS=4 # number of busses
-#options NAPIC=1 # number of IO APICs
-#options NINTR=24 # number of INTs
-
-device isa
-device pci
-
-# Floppy drives
-device fdc0 at isa? port IO_FD1 irq 11 drq 2
-device fd0 at fdc0 drive 0
-device fd1 at fdc0 drive 1
-device fd2 at fdc0 drive 2
-device fd3 at fdc0 drive 3
-
-# IDE controller and disks
-device wdc0 at isa? port IO_WD1 irq 9
-device wd0 at wdc0 drive 0
-#device wd1 at wdc0 drive 1
-#device wd2 at wdc0 drive 2
-#device wd3 at wdc0 drive 3
-
-# ATAPI devices on wdc
-device wcd #IDE CD-ROM
-#device wfd #IDE Floppy (e.g. LS-120)
-#device wst #IDE Tape (e.g. Travan)
-
-# SCSI Controllers
-device adv
-device ahc # AHA2940 and onboard AIC7xxx devices
-device amd # AMD 53C974 (Teckram DC-390(T))
-device isp # Qlogic family
-device ncr # NCR/Symbios Logic
-device sym # NCR/Symbios Logic (newer chipsets)
-
-#
-# WD33C93 SCSI card (55/92 like board)
-#
-
-options BS_TARG_SAFEMODE
-
-# PC-9801-92
-device bs0 at isa? port IO_SCSI irq 5 drq 3 flags 0
-# SC-98
-# device bs0 at isa? port IO_SCSI irq 5 drq 3 flags 0x10000
-# HA-55BS2 and later
-#device bs0 at isa? port IO_SCSI irq 5 drq 3 flags 0x20000
-# ELECOM type
-#device bs0 at isa? port IO_SCSI irq 5 drq 3 flags 0x30000
-# SMIT
-#device bs0 at isa? port IO_SCSI irq 5 drq 3 iomem 0xdd000 iosiz 0x1000 flags 0x40000
-# Logitec LHA-20x
-#device bs0 at isa? port IO_SCSI irq 5 drq 3 flags 0x50000
-
-# SCSI peripherals
-device scbus # SCSI bus (required)
-device da # Direct Access (disks)
-device sa # Sequential Access (tape etc)
-device cd # CD
-device pass # Passthrough device (direct SCSI access)
-
-# RAID controllers
-device amr # AMI MegaRAID
-device mlx # Mylex DAC960 family
-
-# keyboard driver
-device pckbd0 at isa? port IO_KBD irq 1
-#options KBD_INSTALL_CDEV
-
-device gdc0 at isa?
-
-# splash screen/screen saver
-pseudo-device splash
-
-# syscons is the default console driver, resembling an SCO console
-device sc0 at isa?
-
-# Floating point support - do not disable.
-device npx0 at nexus? port IO_NPX irq 8
-
-# Power management support (see LINT for more options)
-device apm0 at nexus? disable flags 0x20 # Advanced Power Management
-
-# PCCARD (PCMCIA) support
-device card
-device pcic0 at isa? irq 6 port 0x3e0
-
-# Serial (COM) ports
-#
-options COM_MULTIPORT
-#
-# COM1
-device sio0 at isa? port IO_COM1 irq 4
-# COM2 (2nd CCU)
-device sio1 at isa? port 0x238 irq 5 flags 0x12000000
-# PC-9861K, PC-9801-101, MDC-926Rs
-#device sio1 at isa? port IO_COM2 irq 5 flags 0x01000000
-#device sio2 at isa? port IO_COM3 irq 6 flags 0x02000000
-# PC-9801-120 (PnP off)
-#device sio1 at isa? port 0x8b0 irq 5 flags 0x11000000
-# MC-16550II, MC-RS98
-#device sio1 at isa? port 0xd2 irq 5 flags 0x14000101
-#device sio2 at isa? port 0x8d2 flags 0x14000101
-# RSB-2000, RSB-3000, B98-02
-#device sio1 at isa? port 0xb0 flags 0x15000101
-#device sio2 at isa? port 0xb1 flags 0x15000101
-# RSB-384
-#device sio1 at isa? port 0xb0 flags 0x16000000
-#device sio2 at isa? port 0xb1 flags 0x16000000
-# RSA-98III
-#device sio1 at isa? port 0x50e0 irq 5 flags 0x18000101
-#device sio2 at isa? port 0x51e0 flags 0x18000101
-# ESP98
-#options COM_ESP
-#device sio1 at isa? port 0x18b0 irq 5 flags 0x19000000
-
-device mse0 at isa? port IO_MSE irq 13
-
-# NEW Parallel port
-device ppc0 at isa? irq 14
-device ppbus # Parallel port bus (required)
-device lpt # Printer
-device plip # TCP/IP over parallel
-device ppi # Parallel port interface device
-#device vpo # Requires scbus and da
-# OLD Parallel port
-# Please stay olpt driver after ppc driver
-device olpt0 at isa? port IO_LPT
-
-
-# PCI Ethernet NICs.
-device de # DEC/Intel DC21x4x (``Tulip'')
-device fxp # Intel EtherExpress PRO/100B (82557, 82558)
-device tx # SMC 9432TX (83c170 ``EPIC'')
-device vx # 3Com 3c590, 3c595 (``Vortex'')
-device wx # Intel Gigabit Ethernet Card (``Wiseman'')
-
-# PCI Ethernet NICs that use the common MII bus controller code.
-device miibus # MII bus support
-device dc # DEC/Intel 21143 and various workalikes
-device rl # RealTek 8129/8139
-device sf # Adaptec AIC-6915 (``Starfire'')
-device sis # Silicon Integrated Systems SiS 900/SiS 7016
-device ste # Sundance ST201 (D-Link DFE-550TX)
-device tl # Texas Instruments ThunderLAN
-device vr # VIA Rhine, Rhine II
-device wb # Winbond W89C840F
-device xl # 3Com 3c90x (``Boomerang'', ``Cyclone'')
-
-# ISA Ethernet NICs.
-#
-# DP8390 NIC
-#
-# ed0: generic driver/EtherEZ98
-# ed1: LANEED LD-BDN
-# ed2: EGY-98
-# ed3: LGY-98
-# ed4: ICM-IF-2766/EN-2298-T
-# ed5: SIC-98
-# ed6: PC-9801-108
-# ed7: LA-98
-# ed8: C-NET(98)
-# ed9: C-NET(98)E/L
-# ed10: EC/EP-98X
-# ed11: SIU-98-D
-#
-#device ed0 at isa? port 0x00d0 irq 6
-##device ed0 at isa? port 0x10d0 irq 6 iomem 0xc8000 # SMC EtherEZ98
-#device ed5 at isa? port 0x00d0 irq 6 iomem 0xd0000 iosiz 16384 flags 0x600000
-#device ed1 at isa? port 0x00d8 irq 6 flags 0x200000
-#device ed3 at isa? port 0x00d0 irq 6 flags 0x400000
-#device ed4 at isa? port 0x56d0 irq 5 flags 0x500000
-#device ed2 at isa? port 0x00d8 irq 6 flags 0x300000
-#device ed7 at isa? port 0x00d0 irq 6 flags 0x900000
-#device ed6 at isa? port 0x0770 irq 6 flags 0x800000
-#device ed9 at isa? port 0x03d0 irq 6 flags 0xb00000
-#device ed8 at isa? port 0xa3d0 irq 6 iomem 0xd0000 iosiz 16384 flags 0xa00000
-#device ed10 at isa? port 0x00d0 irq 3 flags 0xd10000
-#device ed11 at isa? port 0x00d0 irq 6 iomem 0xd0000 iosiz 32768 flags 0x610000
-#
-# MB86960A NIC
-#
-# fe0: RE1000/1000Plus/AccessPC N98C+/LAC-98
-# fe1: C-NET(98)P2/C-NET(9N)E
-#
-# FE_8BIT_SUPPORT is needed to support LAC-98
-#
-options FE_8BIT_SUPPORT # LAC-98 support
-device fe0 at isa? port 0x00d0 irq 3
-device fe1 at isa? port 0x73d0 irq 5
-
-device ep0 at isa? port 0x40d0 irq 3
-device lnc0 at isa? port 0x03d0 irq 6
-
-# WaveLAN/IEEE 802.11 wireless NICs. Note: the WaveLAN/IEEE really
-# exists only as a PCMCIA device, so there is no ISA attatement needed
-# and resources will always be dynamically assigned by the pccard code.
-device wi
-
-# Aironet 4500/4800 802.11 wireless NICs. Note: the declaration below will
-# work for PCMCIA and PCI cards, as well as ISA cards set to ISA PnP
-# mode (the factory default). If you set the switches on your ISA
-# card for a manually chosen I/O address and IRQ, you must specify
-# those paremeters here.
-device an
-
-# requires PCCARD (PCMCIA) support to be activated
-device sn
-#device xe0 at isa?
-
-#device snd
-#device sb0 at isa? port 0x20d2 irq 10 drq 3
-#device sbxvi0 at isa? drq 3
-#device sbmidi0 at isa? port 0x80d2
-#device opl0 at isa? port 0x28d2
-#device nss0 at isa? port 0xa460 irq 12
-#device mss0 at isa? port 0xf40 irq 12 drq 1
-#device mpu0 at isa? port 0xe0d0 irq 6
-
-# Pseudo devices - the number indicates how many units to allocated.
-pseudo-device loop # Network loopback
-pseudo-device ether # Ethernet support
-pseudo-device sl 1 # Kernel SLIP
-pseudo-device ppp 1 # Kernel PPP
-pseudo-device tun # Packet tunnel.
-pseudo-device pty # Pseudo-ttys (telnet etc)
-pseudo-device md # Memory "disks"
-pseudo-device gif 4 # IPv6 and IPv4 tunneling
-pseudo-device faith 1 # IPv6-to-IPv4 relaying (translation)
-
-# The `bpf' pseudo-device enables the Berkeley Packet Filter.
-# Be aware of the administrative consequences of enabling this!
-pseudo-device bpf #Berkeley packet filter
-
-#pseudo-device compat_atdisk #IBM-PC HDD support
-
-# USB support
-#device uhci # UHCI PCI->USB interface
-#device ohci # OHCI PCI->USB interface
-#device usb # USB Bus (required)
-#device ugen # Generic
-#device uhid # "Human Interface Devices"
-#device ukbd # Keyboard
-#device ulpt # Printer
-#device umass # Disks/Mass storage - Requires scbus and da
-#device ums # Mouse
-# USB Ethernet, requires mii
-#device aue # ADMtek USB ethernet
-#device cue # CATC USB ethernet
-#device kue # Kawasaki LSI USB ethernet
diff --git a/sys/pc98/pc98/atapi.h b/sys/pc98/pc98/atapi.h
deleted file mode 100644
index 66989a46e694..000000000000
--- a/sys/pc98/pc98/atapi.h
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * Device-independent level for ATAPI drivers.
- *
- * Copyright (C) 1995 Cronyx Ltd.
- * Author Serge Vakulenko, <vak@cronyx.ru>
- *
- * This software is distributed with NO WARRANTIES, not even the implied
- * warranties for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Authors grant any other persons or organizations permission to use
- * or modify this software as long as this message is kept with the software,
- * all derivative works or modified versions.
- *
- * Version 1.9, Thu Oct 12 15:53:50 MSK 1995
- * $FreeBSD$
- */
-
-#define atapi_attach wdc_atapi_attach
-#define acdattach wdc_acdattach
-
-/*
- * Disk Controller ATAPI register definitions.
- */
-#ifdef PC98
-#define AR_DATA 0x0 /* RW - data register (16 bits) */
-#define AR_ERROR 0x2 /* R - error register */
-#define AR_FEATURES 0x2 /* W - features */
-#define AR_IREASON 0x4 /* RW - interrupt reason */
-#define AR_TAG 0x6 /* - reserved for SAM TAG byte */
-#define AR_CNTLO 0x8 /* RW - byte count, low byte */
-#define AR_CNTHI 0xa /* RW - byte count, high byte */
-#define AR_DRIVE 0xc /* RW - drive select */
-#define AR_COMMAND 0xe /* W - command register */
-#define AR_STATUS 0xe /* R - immediate status */
-#else
-#define AR_DATA 0x0 /* RW - data register (16 bits) */
-#define AR_ERROR 0x1 /* R - error register */
-#define AR_FEATURES 0x1 /* W - features */
-#define AR_IREASON 0x2 /* RW - interrupt reason */
-#define AR_TAG 0x3 /* - reserved for SAM TAG byte */
-#define AR_CNTLO 0x4 /* RW - byte count, low byte */
-#define AR_CNTHI 0x5 /* RW - byte count, high byte */
-#define AR_DRIVE 0x6 /* RW - drive select */
-#define AR_COMMAND 0x7 /* W - command register */
-#define AR_STATUS 0x7 /* R - immediate status */
-#endif
-
-/*
- * Status register bits
- */
-#define ARS_CHECK 0x01 /* error occured, see sense key/code */
- /* bit 0x02 reserved */
-#define ARS_CORR 0x04 /* correctable error occured */
-#define ARS_DRQ 0x08 /* data request / ireason valid */
-#define ARS_DSC 0x10 /* immediate operation completed */
-#define ARS_DF 0x20 /* drive fault */
-#define ARS_DRDY 0x40 /* ready to get command */
-#define ARS_BSY 0x80 /* registers busy */
- /* for overlap mode only: */
-#define ARS_SERVICE 0x10 /* service is requested */
-#define ARS_DMARDY 0x20 /* ready to start a DMA transfer */
-#define ARS_BITS "\20\010busy\7ready\6fault\5opdone\4drq\3corr\1check"
-
-/*
- * Error register bits
- */
-#define AER_ILI 0x01 /* illegal length indication */
-#define AER_EOM 0x02 /* end of media detected */
-#define AER_ABRT 0x04 /* command aborted */
-#define AER_MCR 0x08 /* media change requested */
-#define AER_SKEY 0xf0 /* sense key mask */
-#define AER_SK_NO_SENSE 0x00 /* no specific sense key info */
-#define AER_SK_RECOVERED_ERROR 0x10 /* command succeeded, data recovered */
-#define AER_SK_NOT_READY 0x20 /* no access to drive */
-#define AER_SK_MEDIUM_ERROR 0x30 /* non-recovered data error */
-#define AER_SK_HARDWARE_ERROR 0x40 /* non-recoverable hardware failure */
-#define AER_SK_ILLEGAL_REQUEST 0x50 /* invalid command parameter(s) */
-#define AER_SK_UNIT_ATTENTION 0x60 /* media changed */
-#define AER_SK_DATA_PROTECT 0x70 /* reading read-protected sector */
-#define AER_SK_BLANK_CHECK 0x80 /* blank check */
-#define AER_SK_VENDOR_SPECIFIC 0x90 /* vendor specific skey */
-#define AER_SK_COPY_ABORTED 0xa0 /* copy aborted */
-#define AER_SK_ABORTED_COMMAND 0xb0 /* command aborted, try again */
-#define AER_SK_EQUAL 0xc0 /* equal */
-#define AER_SK_VOLUME_OVERFLOW 0xd0 /* volume overflow */
-#define AER_SK_MISCOMPARE 0xe0 /* data did not match the medium */
-#define AER_SK_RESERVED 0xf0
-#define AER_BITS "\20\4mchg\3abort\2eom\1ili"
-
-/*
- * Feature register bits
- */
-#define ARF_DMA 0x01 /* transfer data via DMA */
-#define ARF_OVERLAP 0x02 /* release the bus until completion */
-
-/*
- * Interrupt reason register bits
- */
-#define ARI_CMD 0x01 /* command(1) or data(0) */
-#define ARI_IN 0x02 /* transfer to(1) or from(0) the host */
-#define ARI_RELEASE 0x04 /* bus released until completion */
-
-/*
- * Drive register values
- */
-#define ARD_DRIVE0 0xa0 /* drive 0 selected */
-#define ARD_DRIVE1 0xb0 /* drive 1 selected */
-
-/*
- * ATA commands
- */
-#define ATAPIC_IDENTIFY 0xa1 /* get drive parameters */
-#define ATAPIC_PACKET 0xa0 /* execute packet command */
-
-/*
- * Mandatory packet commands
- */
-#define ATAPI_TEST_UNIT_READY 0x00 /* check if the device is ready */
-#define ATAPI_REZERO_UNIT 0x01 /* reinit device */
-#define ATAPI_REQUEST_SENSE 0x03 /* get sense data */
-#define ATAPI_START_STOP 0x1b /* start/stop the media */
-#define ATAPI_PREVENT_ALLOW 0x1e /* prevent/allow media removal */
-#define ATAPI_READ_CAPACITY 0x25 /* get volume capacity */
-#define ATAPI_READ_BIG 0x28 /* read data */
-#define ATAPI_WRITE_BIG 0x2a /* write data */
-#define ATAPI_SYNCHRONIZE_CACHE 0x35 /* flush write buf, close write chan */
-#define ATAPI_READ_SUBCHANNEL 0x42 /* get subchannel info */
-#define ATAPI_READ_TOC 0x43 /* get table of contents */
-#define ATAPI_READ_TRACK_INFO 0x52 /* get track information structure */
-#define ATAPI_MODE_SELECT 0x55 /* set device parameters */
-#define ATAPI_MODE_SENSE 0x5a /* get device parameters */
-#define ATAPI_CLOSE_TRACK 0x5b /* close track/session */
-#define ATAPI_LOAD_UNLOAD 0xa6 /* changer control command */
-#define ATAPI_PLAY_CD 0xb4 /* universal play command */
-#define ATAPI_MECH_STATUS 0xbd /* get changer mechanism status */
-#define ATAPI_READ_CD 0xbe /* read data */
-/*
- * Optional packet commands
- */
-#define ATAPI_PLAY_MSF 0x47 /* play by MSF address */
-#define ATAPI_PAUSE 0x4b /* stop/start audio operation */
-
-/*
- * Nonstandard packet commands
- */
-#define ATAPI_PLAY_TRACK 0x48 /* play by track number */
-#define ATAPI_PLAY_BIG 0xa5 /* play by logical block address */
-
-#define DSC_POLL_INTERVAL 10
-
-/*
- * Drive parameter information
- */
-struct atapi_params {
- unsigned cmdsz : 2; /* packet command size */
-#define AT_PSIZE_12 0 /* 12 bytes */
-#define AT_PSIZE_16 1 /* 16 bytes */
- unsigned : 3;
- unsigned drqtype : 2; /* DRQ type */
-#define AT_DRQT_MPROC 0 /* microprocessor DRQ - 3 msec delay */
-#define AT_DRQT_INTR 1 /* interrupt DRQ - 10 msec delay */
-#define AT_DRQT_ACCEL 2 /* accelerated DRQ - 50 usec delay */
- unsigned removable : 1; /* device is removable */
- unsigned devtype : 5; /* device type */
-#define AT_TYPE_DIRECT 0 /* direct-access (magnetic disk) */
-#define AT_TYPE_TAPE 1 /* streaming tape (QIC-121 model) */
-#define AT_TYPE_CDROM 5 /* CD-ROM device */
-#define AT_TYPE_OPTICAL 7 /* optical disk */
- unsigned : 1;
- unsigned proto : 2; /* command protocol */
-#define AT_PROTO_ATAPI 2
- short reserved1[9];
- char serial[20]; /* serial number - optional */
- short reserved2[3];
- char revision[8]; /* firmware revision */
- char model[40]; /* model name */
- short reserved3[2];
- u_char vendor_cap; /* vendor unique capabilities */
- unsigned dmaflag : 1; /* DMA supported */
- unsigned lbaflag : 1; /* LBA supported - always 1 */
- unsigned iordydis : 1; /* IORDY can be disabled */
- unsigned iordyflag : 1; /* IORDY supported */
- unsigned : 1;
- unsigned ovlapflag : 1; /* overlap operation supported */
- unsigned : 1;
- unsigned idmaflag : 1; /* interleaved DMA supported */
- short reserved4;
- u_short pio_timing; /* PIO cycle timing */
- u_short dma_timing; /* DMA cycle timing */
- u_short flags;
-#define AT_FLAG_54_58 1 /* words 54-58 valid */
-#define AT_FLAG_64_70 2 /* words 64-70 valid */
- short reserved5[8];
- u_char swdma_flag; /* singleword DMA mode supported */
- u_char swdma_active; /* singleword DMA mode active */
- u_char mwdma_flag; /* multiword DMA mode supported */
- u_char mwdma_active; /* multiword DMA mode active */
- u_char apio_flag; /* advanced PIO mode supported */
- u_char reserved6;
- u_short mwdma_min; /* min. M/W DMA time per word (ns) */
- u_short mwdma_dflt; /* recommended M/W DMA time (ns) - optional */
- u_short pio_nfctl_min; /* min. PIO cycle time w/o flow ctl - optional */
- u_short pio_iordy_min; /* min. PIO c/t with IORDY flow ctl - optional */
- short reserved7[2];
- u_short rls_ovlap; /* release time (us) for overlap cmd - optional */
- u_short rls_service; /* release time (us) for service cmd - optional */
-};
-
-/*
- * ATAPI operation result structure
- */
-struct atapires {
- u_char code; /* result code */
-#define RES_OK 0 /* i/o done */
-#define RES_ERR 1 /* i/o finished with error */
-#define RES_NOTRDY 2 /* controller not ready */
-#define RES_NODRQ 3 /* no data request */
-#define RES_INVDIR 4 /* invalid bus phase direction */
-#define RES_OVERRUN 5 /* data overrun */
-#define RES_UNDERRUN 6 /* data underrun */
- u_char status; /* status register contents */
- u_char error; /* error register contents */
-};
-
-struct atapidrv { /* delayed attach info */
- int ctlr; /* IDE controller, 0/1 */
- int unit; /* drive unit, 0/1 */
- int port; /* controller base port */
- int attached; /* the drive is attached */
-};
-
-struct buf;
-struct dmy;
-typedef void atapi_callback_t(struct dmy *, struct buf *, int, struct atapires);
-
-struct atapicmd { /* ATAPI command block */
- struct atapicmd *next; /* next command in queue */
- int busy; /* busy flag */
- u_char cmd[16]; /* command and args */
- int unit; /* drive unit number */
- int count; /* byte count, >0 - read, <0 - write */
- char *addr; /* data to transfer */
- atapi_callback_t *callback; /* call when done */
- void *cbarg1; /* callback arg 1 */
- void *cbarg2; /* callback arg 1 */
- struct atapires result; /* resulting error code */
-};
-
-struct atapi { /* ATAPI controller data */
- u_short port; /* i/o port base */
- u_char ctrlr; /* physical controller number */
- u_char debug : 1; /* trace enable flag */
- u_char cmd16 : 1; /* 16-byte command flag */
- u_char intrcmd : 1; /* interrupt before cmd flag */
- u_char slow : 1; /* slow reaction device */
- u_char accel : 1; /* accelerated reaction device */
- u_char use_dsc : 1; /* use DSC completition handeling */
- u_char wait_for_dsc : 1;
- u_int dsc_timeout;
- u_char attached[2]; /* units are attached to subdrivers */
- struct atapi_params *params[2]; /* params for units 0,1 */
- struct atapicmd *queue; /* queue of commands to perform */
- struct atapicmd *tail; /* tail of queue */
- struct atapicmd *free; /* queue of free command blocks */
- struct atapicmd cmdrq[16]; /* pool of command requests */
-};
-
-#ifdef _KERNEL
-struct atapi;
-
-extern struct atapidrv atapi_drvtab[4]; /* delayed attach info */
-extern int atapi_ndrv; /* the number of potential drives */
-extern struct atapi *atapi_tab; /* the table of atapi controllers */
-
-int atapi_attach (int ctlr, int unit, int port);
-int atapi_start (int ctrlr);
-int atapi_intr (int ctrlr);
-void atapi_debug (struct atapi *ata, int on);
-struct atapires atapi_request_wait (struct atapi *ata, int unit,
- u_char cmd, u_char a1, u_char a2, u_char a3, u_char a4,
- u_char a5, u_char a6, u_char a7, u_char a8, u_char a9,
- u_char a10, u_char a11, u_char a12, u_char a13, u_char a14, u_char a15,
- char *addr, int count);
-void atapi_request_callback (struct atapi *ata, int unit,
- u_char cmd, u_char a1, u_char a2, u_char a3, u_char a4,
- u_char a5, u_char a6, u_char a7, u_char a8, u_char a9,
- u_char a10, u_char a11, u_char a12, u_char a13, u_char a14, u_char a15,
- char *addr, int count, atapi_callback_t *done, void *x, void *y);
-struct atapires atapi_request_immediate (struct atapi *ata, int unit,
- u_char cmd, u_char a1, u_char a2, u_char a3, u_char a4,
- u_char a5, u_char a6, u_char a7, u_char a8, u_char a9,
- u_char a10, u_char a11, u_char a12, u_char a13, u_char a14, u_char a15,
- char *addr, int count);
-#endif
diff --git a/sys/pc98/pc98/machdep.c b/sys/pc98/pc98/machdep.c
deleted file mode 100644
index e377848d4776..000000000000
--- a/sys/pc98/pc98/machdep.c
+++ /dev/null
@@ -1,2676 +0,0 @@
-/*-
- * Copyright (c) 1992 Terrence R. Lambert.
- * Copyright (c) 1982, 1987, 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)machdep.c 7.4 (Berkeley) 6/3/91
- * $FreeBSD$
- */
-
-#include "apm.h"
-#include "ether.h"
-#include "npx.h"
-#include "opt_atalk.h"
-#include "opt_compat.h"
-#include "opt_cpu.h"
-#include "opt_ddb.h"
-#include "opt_inet.h"
-#include "opt_ipx.h"
-#include "opt_maxmem.h"
-#include "opt_msgbuf.h"
-#include "opt_perfmon.h"
-#include "opt_smp.h"
-#include "opt_sysvipc.h"
-#include "opt_user_ldt.h"
-#include "opt_userconfig.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/sysproto.h>
-#include <sys/signalvar.h>
-#include <sys/kernel.h>
-#include <sys/linker.h>
-#include <sys/malloc.h>
-#include <sys/proc.h>
-#include <sys/buf.h>
-#include <sys/reboot.h>
-#include <sys/callout.h>
-#include <sys/mbuf.h>
-#include <sys/msgbuf.h>
-#include <sys/sysent.h>
-#include <sys/sysctl.h>
-#include <sys/vmmeter.h>
-#include <sys/bus.h>
-
-#ifdef SYSVSHM
-#include <sys/shm.h>
-#endif
-
-#ifdef SYSVMSG
-#include <sys/msg.h>
-#endif
-
-#ifdef SYSVSEM
-#include <sys/sem.h>
-#endif
-
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <sys/lock.h>
-#include <vm/vm_kern.h>
-#include <vm/vm_object.h>
-#include <vm/vm_page.h>
-#include <vm/vm_map.h>
-#include <vm/vm_pager.h>
-#include <vm/vm_extern.h>
-
-#include <sys/user.h>
-#include <sys/exec.h>
-#include <sys/cons.h>
-
-#include <ddb/ddb.h>
-
-#include <net/netisr.h>
-
-#include <machine/cpu.h>
-#include <machine/reg.h>
-#include <machine/clock.h>
-#include <machine/specialreg.h>
-#include <machine/bootinfo.h>
-#include <machine/ipl.h>
-#include <machine/md_var.h>
-#include <machine/pcb_ext.h> /* pcb.h included via sys/user.h */
-#ifdef SMP
-#include <machine/smp.h>
-#include <machine/globaldata.h>
-#endif
-#ifdef PERFMON
-#include <machine/perfmon.h>
-#endif
-
-#ifdef OLD_BUS_ARCH
-#include <i386/isa/isa_device.h>
-#endif
-#include <i386/isa/intr_machdep.h>
-#ifdef PC98
-#include <pc98/pc98/pc98_machdep.h>
-#include <pc98/pc98/pc98.h>
-#else
-#include <isa/rtc.h>
-#endif
-#include <machine/vm86.h>
-#include <machine/random.h>
-#include <sys/ptrace.h>
-#include <machine/sigframe.h>
-
-extern void init386 __P((int first));
-extern void dblfault_handler __P((void));
-
-extern void printcpuinfo(void); /* XXX header file */
-extern void earlysetcpuclass(void); /* same header file */
-extern void finishidentcpu(void);
-extern void panicifcpuunsupported(void);
-extern void initializecpu(void);
-
-static void cpu_startup __P((void *));
-SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, NULL)
-
-static MALLOC_DEFINE(M_MBUF, "mbuf", "mbuf");
-
-#ifdef PC98
-int need_pre_dma_flush; /* If 1, use wbinvd befor DMA transfer. */
-int need_post_dma_flush; /* If 1, use invd after DMA transfer. */
-#endif
-
-int _udatasel, _ucodesel;
-u_int atdevbase;
-
-#if defined(SWTCH_OPTIM_STATS)
-extern int swtch_optim_stats;
-SYSCTL_INT(_debug, OID_AUTO, swtch_optim_stats,
- CTLFLAG_RD, &swtch_optim_stats, 0, "");
-SYSCTL_INT(_debug, OID_AUTO, tlb_flush_count,
- CTLFLAG_RD, &tlb_flush_count, 0, "");
-#endif
-
-#ifdef PC98
-static int ispc98 = 1;
-#else
-static int ispc98 = 0;
-#endif
-SYSCTL_INT(_machdep, OID_AUTO, ispc98, CTLFLAG_RD, &ispc98, 0, "");
-
-int physmem = 0;
-int cold = 1;
-
-static int
-sysctl_hw_physmem SYSCTL_HANDLER_ARGS
-{
- int error = sysctl_handle_int(oidp, 0, ctob(physmem), req);
- return (error);
-}
-
-SYSCTL_PROC(_hw, HW_PHYSMEM, physmem, CTLTYPE_INT|CTLFLAG_RD,
- 0, 0, sysctl_hw_physmem, "I", "");
-
-static int
-sysctl_hw_usermem SYSCTL_HANDLER_ARGS
-{
- int error = sysctl_handle_int(oidp, 0,
- ctob(physmem - cnt.v_wire_count), req);
- return (error);
-}
-
-SYSCTL_PROC(_hw, HW_USERMEM, usermem, CTLTYPE_INT|CTLFLAG_RD,
- 0, 0, sysctl_hw_usermem, "I", "");
-
-static int
-sysctl_hw_availpages SYSCTL_HANDLER_ARGS
-{
- int error = sysctl_handle_int(oidp, 0,
- i386_btop(avail_end - avail_start), req);
- return (error);
-}
-
-SYSCTL_PROC(_hw, OID_AUTO, availpages, CTLTYPE_INT|CTLFLAG_RD,
- 0, 0, sysctl_hw_availpages, "I", "");
-
-static int
-sysctl_machdep_msgbuf SYSCTL_HANDLER_ARGS
-{
- int error;
-
- /* Unwind the buffer, so that it's linear (possibly starting with
- * some initial nulls).
- */
- error=sysctl_handle_opaque(oidp,msgbufp->msg_ptr+msgbufp->msg_bufr,
- msgbufp->msg_size-msgbufp->msg_bufr,req);
- if(error) return(error);
- if(msgbufp->msg_bufr>0) {
- error=sysctl_handle_opaque(oidp,msgbufp->msg_ptr,
- msgbufp->msg_bufr,req);
- }
- return(error);
-}
-
-SYSCTL_PROC(_machdep, OID_AUTO, msgbuf, CTLTYPE_STRING|CTLFLAG_RD,
- 0, 0, sysctl_machdep_msgbuf, "A","Contents of kernel message buffer");
-
-static int msgbuf_clear;
-
-static int
-sysctl_machdep_msgbuf_clear SYSCTL_HANDLER_ARGS
-{
- int error;
- error = sysctl_handle_int(oidp, oidp->oid_arg1, oidp->oid_arg2,
- req);
- if (!error && req->newptr) {
- /* Clear the buffer and reset write pointer */
- bzero(msgbufp->msg_ptr,msgbufp->msg_size);
- msgbufp->msg_bufr=msgbufp->msg_bufx=0;
- msgbuf_clear=0;
- }
- return (error);
-}
-
-SYSCTL_PROC(_machdep, OID_AUTO, msgbuf_clear, CTLTYPE_INT|CTLFLAG_RW,
- &msgbuf_clear, 0, sysctl_machdep_msgbuf_clear, "I",
- "Clear kernel message buffer");
-
-int bootverbose = 0, Maxmem = 0;
-#ifdef PC98
-int Maxmem_under16M = 0;
-#endif
-long dumplo;
-
-vm_offset_t phys_avail[10];
-
-/* must be 2 less so 0 0 can signal end of chunks */
-#define PHYS_AVAIL_ARRAY_END ((sizeof(phys_avail) / sizeof(vm_offset_t)) - 2)
-
-static vm_offset_t buffer_sva, buffer_eva;
-vm_offset_t clean_sva, clean_eva;
-static vm_offset_t pager_sva, pager_eva;
-
-#define offsetof(type, member) ((size_t)(&((type *)0)->member))
-
-static void
-cpu_startup(dummy)
- void *dummy;
-{
- register unsigned i;
- register caddr_t v;
- vm_offset_t maxaddr;
- vm_size_t size = 0;
- int firstaddr;
- vm_offset_t minaddr;
-
- if (boothowto & RB_VERBOSE)
- bootverbose++;
-
- /*
- * Good {morning,afternoon,evening,night}.
- */
- printf(version);
- earlysetcpuclass();
- startrtclock();
- printcpuinfo();
- panicifcpuunsupported();
-#ifdef PERFMON
- perfmon_init();
-#endif
- printf("real memory = %u (%uK bytes)\n", ptoa(Maxmem), ptoa(Maxmem) / 1024);
- /*
- * Display any holes after the first chunk of extended memory.
- */
- if (bootverbose) {
- int indx;
-
- printf("Physical memory chunk(s):\n");
- for (indx = 0; phys_avail[indx + 1] != 0; indx += 2) {
- int size1 = phys_avail[indx + 1] - phys_avail[indx];
-
- printf("0x%08x - 0x%08x, %u bytes (%u pages)\n",
- phys_avail[indx], phys_avail[indx + 1] - 1, size1,
- size1 / PAGE_SIZE);
- }
- }
-
- /*
- * Calculate callout wheel size
- */
- for (callwheelsize = 1, callwheelbits = 0;
- callwheelsize < ncallout;
- callwheelsize <<= 1, ++callwheelbits)
- ;
- callwheelmask = callwheelsize - 1;
-
- /*
- * Allocate space for system data structures.
- * The first available kernel virtual address is in "v".
- * As pages of kernel virtual memory are allocated, "v" is incremented.
- * As pages of memory are allocated and cleared,
- * "firstaddr" is incremented.
- * An index into the kernel page table corresponding to the
- * virtual memory address maintained in "v" is kept in "mapaddr".
- */
-
- /*
- * Make two passes. The first pass calculates how much memory is
- * needed and allocates it. The second pass assigns virtual
- * addresses to the various data structures.
- */
- firstaddr = 0;
-again:
- v = (caddr_t)firstaddr;
-
-#define valloc(name, type, num) \
- (name) = (type *)v; v = (caddr_t)((name)+(num))
-#define valloclim(name, type, num, lim) \
- (name) = (type *)v; v = (caddr_t)((lim) = ((name)+(num)))
-
- valloc(callout, struct callout, ncallout);
- valloc(callwheel, struct callout_tailq, callwheelsize);
-#ifdef SYSVSHM
- valloc(shmsegs, struct shmid_ds, shminfo.shmmni);
-#endif
-#ifdef SYSVSEM
- valloc(sema, struct semid_ds, seminfo.semmni);
- valloc(sem, struct sem, seminfo.semmns);
- /* This is pretty disgusting! */
- valloc(semu, int, (seminfo.semmnu * seminfo.semusz) / sizeof(int));
-#endif
-#ifdef SYSVMSG
- valloc(msgpool, char, msginfo.msgmax);
- valloc(msgmaps, struct msgmap, msginfo.msgseg);
- valloc(msghdrs, struct msg, msginfo.msgtql);
- valloc(msqids, struct msqid_ds, msginfo.msgmni);
-#endif
-
- if (nbuf == 0) {
- nbuf = 50;
- if (physmem > 1024)
- nbuf += min((physmem - 1024) / 8, 2048);
- if (physmem > 16384)
- nbuf += (physmem - 16384) / 20;
- }
- nswbuf = max(min(nbuf/4, 256), 16);
-
- valloc(swbuf, struct buf, nswbuf);
- valloc(buf, struct buf, nbuf);
- v = bufhashinit(v);
-
- /*
- * End of first pass, size has been calculated so allocate memory
- */
- if (firstaddr == 0) {
- size = (vm_size_t)(v - firstaddr);
- firstaddr = (int)kmem_alloc(kernel_map, round_page(size));
- if (firstaddr == 0)
- panic("startup: no room for tables");
- goto again;
- }
-
- /*
- * End of second pass, addresses have been assigned
- */
- if ((vm_size_t)(v - firstaddr) != size)
- panic("startup: table size inconsistency");
-
- clean_map = kmem_suballoc(kernel_map, &clean_sva, &clean_eva,
- (nbuf*BKVASIZE) + (nswbuf*MAXPHYS) + pager_map_size);
- buffer_map = kmem_suballoc(clean_map, &buffer_sva, &buffer_eva,
- (nbuf*BKVASIZE));
- pager_map = kmem_suballoc(clean_map, &pager_sva, &pager_eva,
- (nswbuf*MAXPHYS) + pager_map_size);
- pager_map->system_map = 1;
- exec_map = kmem_suballoc(kernel_map, &minaddr, &maxaddr,
- (16*(ARG_MAX+(PAGE_SIZE*3))));
-
- /*
- * Finally, allocate mbuf pool. Since mclrefcnt is an off-size
- * we use the more space efficient malloc in place of kmem_alloc.
- */
- {
- vm_offset_t mb_map_size;
-
- mb_map_size = nmbufs * MSIZE + nmbclusters * MCLBYTES;
- mb_map_size = roundup2(mb_map_size, max(MCLBYTES, PAGE_SIZE));
- mclrefcnt = malloc(mb_map_size / MCLBYTES, M_MBUF, M_NOWAIT);
- bzero(mclrefcnt, mb_map_size / MCLBYTES);
- mb_map = kmem_suballoc(kmem_map, (vm_offset_t *)&mbutl, &maxaddr,
- mb_map_size);
- mb_map->system_map = 1;
- }
-
- /*
- * Initialize callouts
- */
- SLIST_INIT(&callfree);
- for (i = 0; i < ncallout; i++) {
- callout_init(&callout[i]);
- callout[i].c_flags = CALLOUT_LOCAL_ALLOC;
- SLIST_INSERT_HEAD(&callfree, &callout[i], c_links.sle);
- }
-
- for (i = 0; i < callwheelsize; i++) {
- TAILQ_INIT(&callwheel[i]);
- }
-
-#if defined(USERCONFIG)
- userconfig();
- cninit(); /* the preferred console may have changed */
-#endif
-
- printf("avail memory = %u (%uK bytes)\n", ptoa(cnt.v_free_count),
- ptoa(cnt.v_free_count) / 1024);
-
- /*
- * Set up buffers, so they can be used to read disk labels.
- */
- bufinit();
- vm_pager_bufferinit();
-
-#ifdef SMP
- /*
- * OK, enough kmem_alloc/malloc state should be up, lets get on with it!
- */
- mp_start(); /* fire up the APs and APICs */
- mp_announce();
-#endif /* SMP */
-}
-
-int
-register_netisr(num, handler)
- int num;
- netisr_t *handler;
-{
-
- if (num < 0 || num >= (sizeof(netisrs)/sizeof(*netisrs)) ) {
- printf("register_netisr: bad isr number: %d\n", num);
- return (EINVAL);
- }
- netisrs[num] = handler;
- return (0);
-}
-
-/*
- * Send an interrupt to process.
- *
- * Stack is set up to allow sigcode stored
- * at top to call routine, followed by kcall
- * to sigreturn routine below. After sigreturn
- * resets the signal mask, the stack, and the
- * frame pointer, it returns to the user
- * specified pc, psl.
- */
-static void
-osendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
-{
- register struct proc *p = curproc;
- register struct trapframe *regs;
- register struct osigframe *fp;
- struct osigframe sf;
- struct sigacts *psp = p->p_sigacts;
- int oonstack;
-
- regs = p->p_md.md_regs;
- oonstack = (p->p_sigstk.ss_flags & SS_ONSTACK) ? 1 : 0;
-
- /* Allocate and validate space for the signal handler context. */
- if ((p->p_flag & P_ALTSTACK) && !oonstack &&
- SIGISMEMBER(psp->ps_sigonstack, sig)) {
- fp = (struct osigframe *)(p->p_sigstk.ss_sp +
- p->p_sigstk.ss_size - sizeof(struct osigframe));
- p->p_sigstk.ss_flags |= SS_ONSTACK;
- }
- else
- fp = (struct osigframe *)regs->tf_esp - 1;
-
- /*
- * grow() will return FALSE if the fp will not fit inside the stack
- * and the stack can not be grown. useracc will return FALSE
- * if access is denied.
- */
- if (grow_stack(p, (int)fp) == FALSE ||
- !useracc((caddr_t)fp, sizeof(struct osigframe), VM_PROT_WRITE)) {
- /*
- * Process has trashed its stack; give it an illegal
- * instruction to halt it in its tracks.
- */
- SIGACTION(p, SIGILL) = SIG_DFL;
- SIGDELSET(p->p_sigignore, SIGILL);
- SIGDELSET(p->p_sigcatch, SIGILL);
- SIGDELSET(p->p_sigmask, SIGILL);
- psignal(p, SIGILL);
- return;
- }
-
- /* Translate the signal if appropriate */
- if (p->p_sysent->sv_sigtbl) {
- if (sig <= p->p_sysent->sv_sigsize)
- sig = p->p_sysent->sv_sigtbl[_SIG_IDX(sig)];
- }
-
- /* Build the argument list for the signal handler. */
- sf.sf_signum = sig;
- sf.sf_scp = (register_t)&fp->sf_siginfo.si_sc;
- if (SIGISMEMBER(p->p_sigacts->ps_siginfo, sig)) {
- /* Signal handler installed with SA_SIGINFO. */
- sf.sf_arg2 = (register_t)&fp->sf_siginfo;
- sf.sf_siginfo.si_signo = sig;
- sf.sf_siginfo.si_code = code;
- sf.sf_ahu.sf_action = (__osiginfohandler_t *)catcher;
- }
- else {
- /* Old FreeBSD-style arguments. */
- sf.sf_arg2 = code;
- sf.sf_addr = regs->tf_err;
- sf.sf_ahu.sf_handler = catcher;
- }
-
- /* save scratch registers */
- sf.sf_siginfo.si_sc.sc_eax = regs->tf_eax;
- sf.sf_siginfo.si_sc.sc_ebx = regs->tf_ebx;
- sf.sf_siginfo.si_sc.sc_ecx = regs->tf_ecx;
- sf.sf_siginfo.si_sc.sc_edx = regs->tf_edx;
- sf.sf_siginfo.si_sc.sc_esi = regs->tf_esi;
- sf.sf_siginfo.si_sc.sc_edi = regs->tf_edi;
- sf.sf_siginfo.si_sc.sc_cs = regs->tf_cs;
- sf.sf_siginfo.si_sc.sc_ds = regs->tf_ds;
- sf.sf_siginfo.si_sc.sc_ss = regs->tf_ss;
- sf.sf_siginfo.si_sc.sc_es = regs->tf_es;
- sf.sf_siginfo.si_sc.sc_fs = regs->tf_fs;
- sf.sf_siginfo.si_sc.sc_gs = rgs();
- sf.sf_siginfo.si_sc.sc_isp = regs->tf_isp;
-
- /* Build the signal context to be used by sigreturn. */
- sf.sf_siginfo.si_sc.sc_onstack = oonstack;
- SIG2OSIG(*mask, sf.sf_siginfo.si_sc.sc_mask);
- sf.sf_siginfo.si_sc.sc_sp = regs->tf_esp;
- sf.sf_siginfo.si_sc.sc_fp = regs->tf_ebp;
- sf.sf_siginfo.si_sc.sc_pc = regs->tf_eip;
- sf.sf_siginfo.si_sc.sc_ps = regs->tf_eflags;
- sf.sf_siginfo.si_sc.sc_trapno = regs->tf_trapno;
- sf.sf_siginfo.si_sc.sc_err = regs->tf_err;
-
- /*
- * If we're a vm86 process, we want to save the segment registers.
- * We also change eflags to be our emulated eflags, not the actual
- * eflags.
- */
- if (regs->tf_eflags & PSL_VM) {
- struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs;
- struct vm86_kernel *vm86 = &p->p_addr->u_pcb.pcb_ext->ext_vm86;
-
- sf.sf_siginfo.si_sc.sc_gs = tf->tf_vm86_gs;
- sf.sf_siginfo.si_sc.sc_fs = tf->tf_vm86_fs;
- sf.sf_siginfo.si_sc.sc_es = tf->tf_vm86_es;
- sf.sf_siginfo.si_sc.sc_ds = tf->tf_vm86_ds;
-
- if (vm86->vm86_has_vme == 0)
- sf.sf_siginfo.si_sc.sc_ps =
- (tf->tf_eflags & ~(PSL_VIF | PSL_VIP))
- | (vm86->vm86_eflags & (PSL_VIF | PSL_VIP));
- /* see sendsig for comment */
- tf->tf_eflags &= ~(PSL_VM|PSL_NT|PSL_T|PSL_VIF|PSL_VIP);
- }
-
- /* Copy the sigframe out to the user's stack. */
- if (copyout(&sf, fp, sizeof(struct osigframe)) != 0) {
- /*
- * Something is wrong with the stack pointer.
- * ...Kill the process.
- */
- sigexit(p, SIGILL);
- }
-
- regs->tf_esp = (int)fp;
- regs->tf_eip = PS_STRINGS - szosigcode;
- regs->tf_cs = _ucodesel;
- regs->tf_ds = _udatasel;
- regs->tf_es = _udatasel;
- regs->tf_fs = _udatasel;
- load_gs(_udatasel);
- regs->tf_ss = _udatasel;
-}
-
-void
-sendsig(catcher, sig, mask, code)
- sig_t catcher;
- int sig;
- sigset_t *mask;
- u_long code;
-{
- struct proc *p = curproc;
- struct trapframe *regs;
- struct sigacts *psp = p->p_sigacts;
- struct sigframe sf, *sfp;
- int oonstack;
-
- if (SIGISMEMBER(psp->ps_osigset, sig)) {
- osendsig(catcher, sig, mask, code);
- return;
- }
-
- regs = p->p_md.md_regs;
- oonstack = (p->p_sigstk.ss_flags & SS_ONSTACK) ? 1 : 0;
-
- /* save user context */
- bzero(&sf, sizeof(struct sigframe));
- sf.sf_uc.uc_sigmask = *mask;
- sf.sf_uc.uc_stack = p->p_sigstk;
- sf.sf_uc.uc_mcontext.mc_onstack = oonstack;
- sf.sf_uc.uc_mcontext.mc_gs = rgs();
- bcopy(regs, &sf.sf_uc.uc_mcontext.mc_fs, sizeof(struct trapframe));
-
- /* Allocate and validate space for the signal handler context. */
- if ((p->p_flag & P_ALTSTACK) != 0 && !oonstack &&
- SIGISMEMBER(psp->ps_sigonstack, sig)) {
- sfp = (struct sigframe *)(p->p_sigstk.ss_sp +
- p->p_sigstk.ss_size - sizeof(struct sigframe));
- p->p_sigstk.ss_flags |= SS_ONSTACK;
- }
- else
- sfp = (struct sigframe *)regs->tf_esp - 1;
-
- /*
- * grow() will return FALSE if the sfp will not fit inside the stack
- * and the stack can not be grown. useracc will return FALSE if
- * access is denied.
- */
- if (grow_stack(p, (int)sfp) == FALSE ||
- !useracc((caddr_t)sfp, sizeof(struct sigframe), VM_PROT_WRITE)) {
- /*
- * Process has trashed its stack; give it an illegal
- * instruction to halt it in its tracks.
- */
-#ifdef DEBUG
- printf("process %d has trashed its stack\n", p->p_pid);
-#endif
- SIGACTION(p, SIGILL) = SIG_DFL;
- SIGDELSET(p->p_sigignore, SIGILL);
- SIGDELSET(p->p_sigcatch, SIGILL);
- SIGDELSET(p->p_sigmask, SIGILL);
- psignal(p, SIGILL);
- return;
- }
-
- /* Translate the signal is appropriate */
- if (p->p_sysent->sv_sigtbl) {
- if (sig <= p->p_sysent->sv_sigsize)
- sig = p->p_sysent->sv_sigtbl[_SIG_IDX(sig)];
- }
-
- /* Build the argument list for the signal handler. */
- sf.sf_signum = sig;
- sf.sf_ucontext = (register_t)&sfp->sf_uc;
- if (SIGISMEMBER(p->p_sigacts->ps_siginfo, sig)) {
- /* Signal handler installed with SA_SIGINFO. */
- sf.sf_siginfo = (register_t)&sfp->sf_si;
- sf.sf_ahu.sf_action = (__siginfohandler_t *)catcher;
-
- /* fill siginfo structure */
- sf.sf_si.si_signo = sig;
- sf.sf_si.si_code = code;
- sf.sf_si.si_addr = (void*)regs->tf_err;
- }
- else {
- /* Old FreeBSD-style arguments. */
- sf.sf_siginfo = code;
- sf.sf_addr = regs->tf_err;
- sf.sf_ahu.sf_handler = catcher;
- }
-
- /*
- * If we're a vm86 process, we want to save the segment registers.
- * We also change eflags to be our emulated eflags, not the actual
- * eflags.
- */
- if (regs->tf_eflags & PSL_VM) {
- struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs;
- struct vm86_kernel *vm86 = &p->p_addr->u_pcb.pcb_ext->ext_vm86;
-
- sf.sf_uc.uc_mcontext.mc_gs = tf->tf_vm86_gs;
- sf.sf_uc.uc_mcontext.mc_fs = tf->tf_vm86_fs;
- sf.sf_uc.uc_mcontext.mc_es = tf->tf_vm86_es;
- sf.sf_uc.uc_mcontext.mc_ds = tf->tf_vm86_ds;
-
- if (vm86->vm86_has_vme == 0)
- sf.sf_uc.uc_mcontext.mc_eflags =
- (tf->tf_eflags & ~(PSL_VIF | PSL_VIP)) |
- (vm86->vm86_eflags & (PSL_VIF | PSL_VIP));
-
- /*
- * We should never have PSL_T set when returning from vm86
- * mode. It may be set here if we deliver a signal before
- * getting to vm86 mode, so turn it off.
- *
- * Clear PSL_NT to inhibit T_TSSFLT faults on return from
- * syscalls made by the signal handler. This just avoids
- * wasting time for our lazy fixup of such faults. PSL_NT
- * does nothing in vm86 mode, but vm86 programs can set it
- * almost legitimately in probes for old cpu types.
- */
- tf->tf_eflags &= ~(PSL_VM|PSL_NT|PSL_T|PSL_VIF|PSL_VIP);
- }
-
- /*
- * Copy the sigframe out to the user's stack.
- */
- if (copyout(&sf, sfp, sizeof(struct sigframe)) != 0) {
- /*
- * Something is wrong with the stack pointer.
- * ...Kill the process.
- */
- sigexit(p, SIGILL);
- }
-
- regs->tf_esp = (int)sfp;
- regs->tf_eip = PS_STRINGS - *(p->p_sysent->sv_szsigcode);
- regs->tf_cs = _ucodesel;
- regs->tf_ds = _udatasel;
- regs->tf_es = _udatasel;
- regs->tf_fs = _udatasel;
- load_gs(_udatasel);
- regs->tf_ss = _udatasel;
-}
-
-/*
- * System call to cleanup state after a signal
- * has been taken. Reset signal mask and
- * stack state from context left by sendsig (above).
- * Return to previous pc and psl as specified by
- * context left by sendsig. Check carefully to
- * make sure that the user has not modified the
- * state to gain improper privileges.
- */
-#define EFL_SECURE(ef, oef) ((((ef) ^ (oef)) & ~PSL_USERCHANGE) == 0)
-#define CS_SECURE(cs) (ISPL(cs) == SEL_UPL)
-
-int
-osigreturn(p, uap)
- struct proc *p;
- struct osigreturn_args /* {
- struct osigcontext *sigcntxp;
- } */ *uap;
-{
- register struct osigcontext *scp;
- register struct trapframe *regs = p->p_md.md_regs;
- int eflags;
-
- scp = uap->sigcntxp;
-
- if (!useracc((caddr_t)scp, sizeof (struct osigcontext), VM_PROT_READ))
- return(EFAULT);
-
- eflags = scp->sc_ps;
- if (eflags & PSL_VM) {
- struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs;
- struct vm86_kernel *vm86;
-
- /*
- * if pcb_ext == 0 or vm86_inited == 0, the user hasn't
- * set up the vm86 area, and we can't enter vm86 mode.
- */
- if (p->p_addr->u_pcb.pcb_ext == 0)
- return (EINVAL);
- vm86 = &p->p_addr->u_pcb.pcb_ext->ext_vm86;
- if (vm86->vm86_inited == 0)
- return (EINVAL);
-
- /* go back to user mode if both flags are set */
- if ((eflags & PSL_VIP) && (eflags & PSL_VIF))
- trapsignal(p, SIGBUS, 0);
-
- if (vm86->vm86_has_vme) {
- eflags = (tf->tf_eflags & ~VME_USERCHANGE) |
- (eflags & VME_USERCHANGE) | PSL_VM;
- } else {
- vm86->vm86_eflags = eflags; /* save VIF, VIP */
- eflags = (tf->tf_eflags & ~VM_USERCHANGE) | (eflags & VM_USERCHANGE) | PSL_VM;
- }
- tf->tf_vm86_ds = scp->sc_ds;
- tf->tf_vm86_es = scp->sc_es;
- tf->tf_vm86_fs = scp->sc_fs;
- tf->tf_vm86_gs = scp->sc_gs;
- tf->tf_ds = _udatasel;
- tf->tf_es = _udatasel;
- tf->tf_fs = _udatasel;
- } else {
- /*
- * Don't allow users to change privileged or reserved flags.
- */
- /*
- * XXX do allow users to change the privileged flag PSL_RF.
- * The cpu sets PSL_RF in tf_eflags for faults. Debuggers
- * should sometimes set it there too. tf_eflags is kept in
- * the signal context during signal handling and there is no
- * other place to remember it, so the PSL_RF bit may be
- * corrupted by the signal handler without us knowing.
- * Corruption of the PSL_RF bit at worst causes one more or
- * one less debugger trap, so allowing it is fairly harmless.
- */
- if (!EFL_SECURE(eflags & ~PSL_RF, regs->tf_eflags & ~PSL_RF)) {
- return(EINVAL);
- }
-
- /*
- * Don't allow users to load a valid privileged %cs. Let the
- * hardware check for invalid selectors, excess privilege in
- * other selectors, invalid %eip's and invalid %esp's.
- */
- if (!CS_SECURE(scp->sc_cs)) {
- trapsignal(p, SIGBUS, T_PROTFLT);
- return(EINVAL);
- }
- regs->tf_ds = scp->sc_ds;
- regs->tf_es = scp->sc_es;
- regs->tf_fs = scp->sc_fs;
- }
-
- /* restore scratch registers */
- regs->tf_eax = scp->sc_eax;
- regs->tf_ebx = scp->sc_ebx;
- regs->tf_ecx = scp->sc_ecx;
- regs->tf_edx = scp->sc_edx;
- regs->tf_esi = scp->sc_esi;
- regs->tf_edi = scp->sc_edi;
- regs->tf_cs = scp->sc_cs;
- regs->tf_ss = scp->sc_ss;
- regs->tf_isp = scp->sc_isp;
-
- if (scp->sc_onstack & 01)
- p->p_sigstk.ss_flags |= SS_ONSTACK;
- else
- p->p_sigstk.ss_flags &= ~SS_ONSTACK;
-
- SIGSETOLD(p->p_sigmask, scp->sc_mask);
- SIG_CANTMASK(p->p_sigmask);
- regs->tf_ebp = scp->sc_fp;
- regs->tf_esp = scp->sc_sp;
- regs->tf_eip = scp->sc_pc;
- regs->tf_eflags = eflags;
- return(EJUSTRETURN);
-}
-
-int
-sigreturn(p, uap)
- struct proc *p;
- struct sigreturn_args /* {
- ucontext_t *sigcntxp;
- } */ *uap;
-{
- struct trapframe *regs;
- ucontext_t *ucp;
- int cs, eflags;
-
- ucp = uap->sigcntxp;
-
- if (!useracc((caddr_t)ucp, sizeof(struct osigcontext), VM_PROT_READ))
- return (EFAULT);
- if (((struct osigcontext *)ucp)->sc_trapno == 0x01d516)
- return (osigreturn(p, (struct osigreturn_args *)uap));
-
- /*
- * Since ucp is not an osigcontext but a ucontext_t, we have to
- * check again if all of it is accessible. A ucontext_t is
- * much larger, so instead of just checking for the pointer
- * being valid for the size of an osigcontext, now check for
- * it being valid for a whole, new-style ucontext_t.
- */
- if (!useracc((caddr_t)ucp, sizeof(ucontext_t), VM_PROT_READ))
- return (EFAULT);
-
- regs = p->p_md.md_regs;
- eflags = ucp->uc_mcontext.mc_eflags;
-
- if (eflags & PSL_VM) {
- struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs;
- struct vm86_kernel *vm86;
-
- /*
- * if pcb_ext == 0 or vm86_inited == 0, the user hasn't
- * set up the vm86 area, and we can't enter vm86 mode.
- */
- if (p->p_addr->u_pcb.pcb_ext == 0)
- return (EINVAL);
- vm86 = &p->p_addr->u_pcb.pcb_ext->ext_vm86;
- if (vm86->vm86_inited == 0)
- return (EINVAL);
-
- /* go back to user mode if both flags are set */
- if ((eflags & PSL_VIP) && (eflags & PSL_VIF))
- trapsignal(p, SIGBUS, 0);
-
- if (vm86->vm86_has_vme) {
- eflags = (tf->tf_eflags & ~VME_USERCHANGE) |
- (eflags & VME_USERCHANGE) | PSL_VM;
- } else {
- vm86->vm86_eflags = eflags; /* save VIF, VIP */
- eflags = (tf->tf_eflags & ~VM_USERCHANGE) | (eflags & VM_USERCHANGE) | PSL_VM;
- }
- bcopy(&ucp->uc_mcontext.mc_fs, tf, sizeof(struct trapframe));
- tf->tf_eflags = eflags;
- tf->tf_vm86_ds = tf->tf_ds;
- tf->tf_vm86_es = tf->tf_es;
- tf->tf_vm86_fs = tf->tf_fs;
- tf->tf_vm86_gs = ucp->uc_mcontext.mc_gs;
- tf->tf_ds = _udatasel;
- tf->tf_es = _udatasel;
- tf->tf_fs = _udatasel;
- } else {
- /*
- * Don't allow users to change privileged or reserved flags.
- */
- /*
- * XXX do allow users to change the privileged flag PSL_RF.
- * The cpu sets PSL_RF in tf_eflags for faults. Debuggers
- * should sometimes set it there too. tf_eflags is kept in
- * the signal context during signal handling and there is no
- * other place to remember it, so the PSL_RF bit may be
- * corrupted by the signal handler without us knowing.
- * Corruption of the PSL_RF bit at worst causes one more or
- * one less debugger trap, so allowing it is fairly harmless.
- */
- if (!EFL_SECURE(eflags & ~PSL_RF, regs->tf_eflags & ~PSL_RF)) {
- printf("sigreturn: eflags = 0x%x\n", eflags);
- return(EINVAL);
- }
-
- /*
- * Don't allow users to load a valid privileged %cs. Let the
- * hardware check for invalid selectors, excess privilege in
- * other selectors, invalid %eip's and invalid %esp's.
- */
- cs = ucp->uc_mcontext.mc_cs;
- if (!CS_SECURE(cs)) {
- printf("sigreturn: cs = 0x%x\n", cs);
- trapsignal(p, SIGBUS, T_PROTFLT);
- return(EINVAL);
- }
- bcopy(&ucp->uc_mcontext.mc_fs, regs, sizeof(struct trapframe));
- }
-
- if (ucp->uc_mcontext.mc_onstack & 1)
- p->p_sigstk.ss_flags |= SS_ONSTACK;
- else
- p->p_sigstk.ss_flags &= ~SS_ONSTACK;
-
- p->p_sigmask = ucp->uc_sigmask;
- SIG_CANTMASK(p->p_sigmask);
- return(EJUSTRETURN);
-}
-
-/*
- * Machine dependent boot() routine
- *
- * I haven't seen anything to put here yet
- * Possibly some stuff might be grafted back here from boot()
- */
-void
-cpu_boot(int howto)
-{
-}
-
-/*
- * Shutdown the CPU as much as possible
- */
-void
-cpu_halt(void)
-{
- for (;;)
- __asm__ ("hlt");
-}
-
-/*
- * Clear registers on exec
- */
-void
-setregs(p, entry, stack, ps_strings)
- struct proc *p;
- u_long entry;
- u_long stack;
- u_long ps_strings;
-{
- struct trapframe *regs = p->p_md.md_regs;
- struct pcb *pcb = &p->p_addr->u_pcb;
-
-#ifdef USER_LDT
- /* was i386_user_cleanup() in NetBSD */
- user_ldt_free(pcb);
-#endif
-
- bzero((char *)regs, sizeof(struct trapframe));
- regs->tf_eip = entry;
- regs->tf_esp = stack;
- regs->tf_eflags = PSL_USER | (regs->tf_eflags & PSL_T);
- regs->tf_ss = _udatasel;
- regs->tf_ds = _udatasel;
- regs->tf_es = _udatasel;
- regs->tf_fs = _udatasel;
- regs->tf_cs = _ucodesel;
-
- /* PS_STRINGS value for BSD/OS binaries. It is 0 for non-BSD/OS. */
- regs->tf_ebx = ps_strings;
-
- /* reset %gs as well */
- if (pcb == curpcb)
- load_gs(_udatasel);
- else
- pcb->pcb_gs = _udatasel;
-
- /*
- * Reset the hardware debug registers if they were in use.
- * They won't have any meaning for the newly exec'd process.
- */
- if (pcb->pcb_flags & PCB_DBREGS) {
- pcb->pcb_dr0 = 0;
- pcb->pcb_dr1 = 0;
- pcb->pcb_dr2 = 0;
- pcb->pcb_dr3 = 0;
- pcb->pcb_dr6 = 0;
- pcb->pcb_dr7 = 0;
- if (pcb == curpcb) {
- /*
- * Clear the debug registers on the running
- * CPU, otherwise they will end up affecting
- * the next process we switch to.
- */
- reset_dbregs();
- }
- pcb->pcb_flags &= ~PCB_DBREGS;
- }
-
- /*
- * Initialize the math emulator (if any) for the current process.
- * Actually, just clear the bit that says that the emulator has
- * been initialized. Initialization is delayed until the process
- * traps to the emulator (if it is done at all) mainly because
- * emulators don't provide an entry point for initialization.
- */
- p->p_addr->u_pcb.pcb_flags &= ~FP_SOFTFP;
-
- /*
- * Arrange to trap the next npx or `fwait' instruction (see npx.c
- * for why fwait must be trapped at least if there is an npx or an
- * emulator). This is mainly to handle the case where npx0 is not
- * configured, since the npx routines normally set up the trap
- * otherwise. It should be done only at boot time, but doing it
- * here allows modifying `npx_exists' for testing the emulator on
- * systems with an npx.
- */
- load_cr0(rcr0() | CR0_MP | CR0_TS);
-
-#if NNPX > 0
- /* Initialize the npx (if any) for the current process. */
- npxinit(__INITIAL_NPXCW__);
-#endif
-
- /*
- * XXX - Linux emulator
- * Make sure sure edx is 0x0 on entry. Linux binaries depend
- * on it.
- */
- p->p_retval[1] = 0;
-}
-
-static int
-sysctl_machdep_adjkerntz SYSCTL_HANDLER_ARGS
-{
- int error;
- error = sysctl_handle_int(oidp, oidp->oid_arg1, oidp->oid_arg2,
- req);
- if (!error && req->newptr)
- resettodr();
- return (error);
-}
-
-SYSCTL_PROC(_machdep, CPU_ADJKERNTZ, adjkerntz, CTLTYPE_INT|CTLFLAG_RW,
- &adjkerntz, 0, sysctl_machdep_adjkerntz, "I", "");
-
-SYSCTL_INT(_machdep, CPU_DISRTCSET, disable_rtc_set,
- CTLFLAG_RW, &disable_rtc_set, 0, "");
-
-SYSCTL_STRUCT(_machdep, CPU_BOOTINFO, bootinfo,
- CTLFLAG_RD, &bootinfo, bootinfo, "");
-
-SYSCTL_INT(_machdep, CPU_WALLCLOCK, wall_cmos_clock,
- CTLFLAG_RW, &wall_cmos_clock, 0, "");
-
-/*
- * Initialize 386 and configure to run kernel
- */
-
-/*
- * Initialize segments & interrupt table
- */
-
-int _default_ldt;
-#ifdef SMP
-union descriptor gdt[NGDT * NCPU]; /* global descriptor table */
-#else
-union descriptor gdt[NGDT]; /* global descriptor table */
-#endif
-static struct gate_descriptor idt0[NIDT];
-struct gate_descriptor *idt = &idt0[0]; /* interrupt descriptor table */
-union descriptor ldt[NLDT]; /* local descriptor table */
-#ifdef SMP
-/* table descriptors - used to load tables by microp */
-struct region_descriptor r_gdt, r_idt;
-#endif
-
-#ifndef SMP
-extern struct segment_descriptor common_tssd, *tss_gdt;
-#endif
-int private_tss; /* flag indicating private tss */
-
-#if defined(I586_CPU) && !defined(NO_F00F_HACK)
-extern int has_f00f_bug;
-#endif
-
-static struct i386tss dblfault_tss;
-static char dblfault_stack[PAGE_SIZE];
-
-extern struct user *proc0paddr;
-
-
-/* software prototypes -- in more palatable form */
-struct soft_segment_descriptor gdt_segs[] = {
-/* GNULL_SEL 0 Null Descriptor */
-{ 0x0, /* segment base address */
- 0x0, /* length */
- 0, /* segment type */
- 0, /* segment descriptor priority level */
- 0, /* segment descriptor present */
- 0, 0,
- 0, /* default 32 vs 16 bit size */
- 0 /* limit granularity (byte/page units)*/ },
-/* GCODE_SEL 1 Code Descriptor for kernel */
-{ 0x0, /* segment base address */
- 0xfffff, /* length - all address space */
- SDT_MEMERA, /* segment type */
- 0, /* segment descriptor priority level */
- 1, /* segment descriptor present */
- 0, 0,
- 1, /* default 32 vs 16 bit size */
- 1 /* limit granularity (byte/page units)*/ },
-/* GDATA_SEL 2 Data Descriptor for kernel */
-{ 0x0, /* segment base address */
- 0xfffff, /* length - all address space */
- SDT_MEMRWA, /* segment type */
- 0, /* segment descriptor priority level */
- 1, /* segment descriptor present */
- 0, 0,
- 1, /* default 32 vs 16 bit size */
- 1 /* limit granularity (byte/page units)*/ },
-/* GPRIV_SEL 3 SMP Per-Processor Private Data Descriptor */
-{ 0x0, /* segment base address */
- 0xfffff, /* length - all address space */
- SDT_MEMRWA, /* segment type */
- 0, /* segment descriptor priority level */
- 1, /* segment descriptor present */
- 0, 0,
- 1, /* default 32 vs 16 bit size */
- 1 /* limit granularity (byte/page units)*/ },
-/* GPROC0_SEL 4 Proc 0 Tss Descriptor */
-{
- 0x0, /* segment base address */
- sizeof(struct i386tss)-1,/* length - all address space */
- SDT_SYS386TSS, /* segment type */
- 0, /* segment descriptor priority level */
- 1, /* segment descriptor present */
- 0, 0,
- 0, /* unused - default 32 vs 16 bit size */
- 0 /* limit granularity (byte/page units)*/ },
-/* GLDT_SEL 5 LDT Descriptor */
-{ (int) ldt, /* segment base address */
- sizeof(ldt)-1, /* length - all address space */
- SDT_SYSLDT, /* segment type */
- SEL_UPL, /* segment descriptor priority level */
- 1, /* segment descriptor present */
- 0, 0,
- 0, /* unused - default 32 vs 16 bit size */
- 0 /* limit granularity (byte/page units)*/ },
-/* GUSERLDT_SEL 6 User LDT Descriptor per process */
-{ (int) ldt, /* segment base address */
- (512 * sizeof(union descriptor)-1), /* length */
- SDT_SYSLDT, /* segment type */
- 0, /* segment descriptor priority level */
- 1, /* segment descriptor present */
- 0, 0,
- 0, /* unused - default 32 vs 16 bit size */
- 0 /* limit granularity (byte/page units)*/ },
-/* GTGATE_SEL 7 Null Descriptor - Placeholder */
-{ 0x0, /* segment base address */
- 0x0, /* length - all address space */
- 0, /* segment type */
- 0, /* segment descriptor priority level */
- 0, /* segment descriptor present */
- 0, 0,
- 0, /* default 32 vs 16 bit size */
- 0 /* limit granularity (byte/page units)*/ },
-/* GBIOSLOWMEM_SEL 8 BIOS access to realmode segment 0x40, must be #8 in GDT */
-{ 0x400, /* segment base address */
- 0xfffff, /* length */
- SDT_MEMRWA, /* segment type */
- 0, /* segment descriptor priority level */
- 1, /* segment descriptor present */
- 0, 0,
- 1, /* default 32 vs 16 bit size */
- 1 /* limit granularity (byte/page units)*/ },
-/* GPANIC_SEL 9 Panic Tss Descriptor */
-{ (int) &dblfault_tss, /* segment base address */
- sizeof(struct i386tss)-1,/* length - all address space */
- SDT_SYS386TSS, /* segment type */
- 0, /* segment descriptor priority level */
- 1, /* segment descriptor present */
- 0, 0,
- 0, /* unused - default 32 vs 16 bit size */
- 0 /* limit granularity (byte/page units)*/ },
-/* GBIOSCODE32_SEL 10 BIOS 32-bit interface (32bit Code) */
-{ 0, /* segment base address (overwritten) */
- 0xfffff, /* length */
- SDT_MEMERA, /* segment type */
- 0, /* segment descriptor priority level */
- 1, /* segment descriptor present */
- 0, 0,
- 0, /* default 32 vs 16 bit size */
- 1 /* limit granularity (byte/page units)*/ },
-/* GBIOSCODE16_SEL 11 BIOS 32-bit interface (16bit Code) */
-{ 0, /* segment base address (overwritten) */
- 0xfffff, /* length */
- SDT_MEMERA, /* segment type */
- 0, /* segment descriptor priority level */
- 1, /* segment descriptor present */
- 0, 0,
- 0, /* default 32 vs 16 bit size */
- 1 /* limit granularity (byte/page units)*/ },
-/* GBIOSDATA_SEL 12 BIOS 32-bit interface (Data) */
-{ 0, /* segment base address (overwritten) */
- 0xfffff, /* length */
- SDT_MEMRWA, /* segment type */
- 0, /* segment descriptor priority level */
- 1, /* segment descriptor present */
- 0, 0,
- 1, /* default 32 vs 16 bit size */
- 1 /* limit granularity (byte/page units)*/ },
-/* GBIOSUTIL_SEL 13 BIOS 16-bit interface (Utility) */
-{ 0, /* segment base address (overwritten) */
- 0xfffff, /* length */
- SDT_MEMRWA, /* segment type */
- 0, /* segment descriptor priority level */
- 1, /* segment descriptor present */
- 0, 0,
- 0, /* default 32 vs 16 bit size */
- 1 /* limit granularity (byte/page units)*/ },
-/* GBIOSARGS_SEL 14 BIOS 16-bit interface (Arguments) */
-{ 0, /* segment base address (overwritten) */
- 0xfffff, /* length */
- SDT_MEMRWA, /* segment type */
- 0, /* segment descriptor priority level */
- 1, /* segment descriptor present */
- 0, 0,
- 0, /* default 32 vs 16 bit size */
- 1 /* limit granularity (byte/page units)*/ },
-};
-
-static struct soft_segment_descriptor ldt_segs[] = {
- /* Null Descriptor - overwritten by call gate */
-{ 0x0, /* segment base address */
- 0x0, /* length - all address space */
- 0, /* segment type */
- 0, /* segment descriptor priority level */
- 0, /* segment descriptor present */
- 0, 0,
- 0, /* default 32 vs 16 bit size */
- 0 /* limit granularity (byte/page units)*/ },
- /* Null Descriptor - overwritten by call gate */
-{ 0x0, /* segment base address */
- 0x0, /* length - all address space */
- 0, /* segment type */
- 0, /* segment descriptor priority level */
- 0, /* segment descriptor present */
- 0, 0,
- 0, /* default 32 vs 16 bit size */
- 0 /* limit granularity (byte/page units)*/ },
- /* Null Descriptor - overwritten by call gate */
-{ 0x0, /* segment base address */
- 0x0, /* length - all address space */
- 0, /* segment type */
- 0, /* segment descriptor priority level */
- 0, /* segment descriptor present */
- 0, 0,
- 0, /* default 32 vs 16 bit size */
- 0 /* limit granularity (byte/page units)*/ },
- /* Code Descriptor for user */
-{ 0x0, /* segment base address */
- 0xfffff, /* length - all address space */
- SDT_MEMERA, /* segment type */
- SEL_UPL, /* segment descriptor priority level */
- 1, /* segment descriptor present */
- 0, 0,
- 1, /* default 32 vs 16 bit size */
- 1 /* limit granularity (byte/page units)*/ },
- /* Null Descriptor - overwritten by call gate */
-{ 0x0, /* segment base address */
- 0x0, /* length - all address space */
- 0, /* segment type */
- 0, /* segment descriptor priority level */
- 0, /* segment descriptor present */
- 0, 0,
- 0, /* default 32 vs 16 bit size */
- 0 /* limit granularity (byte/page units)*/ },
- /* Data Descriptor for user */
-{ 0x0, /* segment base address */
- 0xfffff, /* length - all address space */
- SDT_MEMRWA, /* segment type */
- SEL_UPL, /* segment descriptor priority level */
- 1, /* segment descriptor present */
- 0, 0,
- 1, /* default 32 vs 16 bit size */
- 1 /* limit granularity (byte/page units)*/ },
-};
-
-void
-setidt(idx, func, typ, dpl, selec)
- int idx;
- inthand_t *func;
- int typ;
- int dpl;
- int selec;
-{
- struct gate_descriptor *ip;
-
- ip = idt + idx;
- ip->gd_looffset = (int)func;
- ip->gd_selector = selec;
- ip->gd_stkcpy = 0;
- ip->gd_xx = 0;
- ip->gd_type = typ;
- ip->gd_dpl = dpl;
- ip->gd_p = 1;
- ip->gd_hioffset = ((int)func)>>16 ;
-}
-
-#define IDTVEC(name) __CONCAT(X,name)
-
-extern inthand_t
- IDTVEC(div), IDTVEC(dbg), IDTVEC(nmi), IDTVEC(bpt), IDTVEC(ofl),
- IDTVEC(bnd), IDTVEC(ill), IDTVEC(dna), IDTVEC(fpusegm),
- IDTVEC(tss), IDTVEC(missing), IDTVEC(stk), IDTVEC(prot),
- IDTVEC(page), IDTVEC(mchk), IDTVEC(rsvd), IDTVEC(fpu), IDTVEC(align),
- IDTVEC(syscall), IDTVEC(int0x80_syscall);
-
-void
-sdtossd(sd, ssd)
- struct segment_descriptor *sd;
- struct soft_segment_descriptor *ssd;
-{
- ssd->ssd_base = (sd->sd_hibase << 24) | sd->sd_lobase;
- ssd->ssd_limit = (sd->sd_hilimit << 16) | sd->sd_lolimit;
- ssd->ssd_type = sd->sd_type;
- ssd->ssd_dpl = sd->sd_dpl;
- ssd->ssd_p = sd->sd_p;
- ssd->ssd_def32 = sd->sd_def32;
- ssd->ssd_gran = sd->sd_gran;
-}
-
-#define PHYSMAP_SIZE (2 * 8)
-
-/*
- * Populate the (physmap) array with base/bound pairs describing the
- * available physical memory in the system, then test this memory and
- * build the phys_avail array describing the actually-available memory.
- *
- * If we cannot accurately determine the physical memory map, then use
- * value from the 0xE801 call, and failing that, the RTC.
- *
- * Total memory size may be set by the kernel environment variable
- * hw.physmem or the compile-time define MAXMEM.
- */
-static void
-getmemsize_pc98(int first)
-{
- u_int biosbasemem, biosextmem;
- u_int pagesinbase, pagesinext;
- int pa_indx;
- int speculative_mprobe;
-#if NNPX > 0
- int msize;
-#endif
- vm_offset_t target_page;
-
- pc98_getmemsize();
- biosbasemem = 640; /* 640KB */
- biosextmem = (Maxmem * PAGE_SIZE - 0x100000)/1024; /* extent memory */
-
-#ifdef SMP
- /* make hole for AP bootstrap code */
- pagesinbase = mp_bootaddress(biosbasemem) / PAGE_SIZE;
-#else
- pagesinbase = biosbasemem * 1024 / PAGE_SIZE;
-#endif
-
- pagesinext = biosextmem * 1024 / PAGE_SIZE;
-
- /*
- * Maxmem isn't the "maximum memory", it's one larger than the
- * highest page of the physical address space. It should be
- * called something like "Maxphyspage".
- */
- Maxmem = pagesinext + 0x100000/PAGE_SIZE;
- /*
- * Indicate that we wish to do a speculative search for memory beyond
- * the end of the reported size if the indicated amount is 64MB (0x4000
- * pages) - which is the largest amount that the BIOS/bootblocks can
- * currently report. If a specific amount of memory is indicated via
- * the MAXMEM option or the npx0 "msize", then don't do the speculative
- * memory probe.
- */
- if (Maxmem >= 0x4000)
-#ifdef PC98
- {
- Maxmem = 0x4000; /* XXX */
- speculative_mprobe = TRUE;
- }
-#else
- speculative_mprobe = TRUE;
-#endif
- else
- speculative_mprobe = FALSE;
-
-#ifdef MAXMEM
- Maxmem = MAXMEM/4;
- speculative_mprobe = FALSE;
-#endif
-
-#if NNPX > 0
- if (resource_int_value("npx", 0, "msize", &msize) == 0) {
- if (msize != 0) {
- Maxmem = msize / 4;
- speculative_mprobe = FALSE;
- }
- }
-#endif
-
-#ifdef SMP
- /* look for the MP hardware - needed for apic addresses */
- mp_probe();
-#endif
-
- /* call pmap initialization to make new kernel address space */
- pmap_bootstrap (first, 0);
-
- /*
- * Size up each available chunk of physical memory.
- */
-
- /*
- * We currently don't bother testing base memory.
- * XXX ...but we probably should.
- */
- pa_indx = 0;
- if (pagesinbase > 1) {
- phys_avail[pa_indx++] = PAGE_SIZE; /* skip first page of memory */
- phys_avail[pa_indx] = ptoa(pagesinbase);/* memory up to the ISA hole */
- physmem = pagesinbase - 1;
- } else {
- /* point at first chunk end */
- pa_indx++;
- }
-
- for (target_page = avail_start; target_page < ptoa(Maxmem); target_page += PAGE_SIZE) {
- int tmp, page_bad;
-
- page_bad = FALSE;
- /* skip system area */
- if (target_page>=ptoa(Maxmem_under16M) &&
- target_page < ptoa(4096))
- continue;
-
- /*
- * map page into kernel: valid, read/write, non-cacheable
- */
- if (pc98_machine_type & M_EPSON_PC98) {
- switch (epson_machine_id) {
- case 0x34: /* PC-486HX */
- case 0x35: /* PC-486HG */
- case 0x3B: /* PC-486HA */
- *(int *)CMAP1 = PG_V | PG_RW | target_page;
- break;
- default:
-#ifdef WB_CACHE
- *(int *)CMAP1 = PG_V | PG_RW | target_page;
-#else
- *(int *)CMAP1 = PG_V | PG_RW | PG_N | target_page;
-#endif
- break;
- }
- } else {
- *(int *)CMAP1 = PG_V | PG_RW | PG_N | target_page;
- }
- invltlb();
-
- tmp = *(int *)CADDR1;
- /*
- * Test for alternating 1's and 0's
- */
- *(volatile int *)CADDR1 = 0xaaaaaaaa;
- if (*(volatile int *)CADDR1 != 0xaaaaaaaa) {
- page_bad = TRUE;
- }
- /*
- * Test for alternating 0's and 1's
- */
- *(volatile int *)CADDR1 = 0x55555555;
- if (*(volatile int *)CADDR1 != 0x55555555) {
- page_bad = TRUE;
- }
- /*
- * Test for all 1's
- */
- *(volatile int *)CADDR1 = 0xffffffff;
- if (*(volatile int *)CADDR1 != 0xffffffff) {
- page_bad = TRUE;
- }
- /*
- * Test for all 0's
- */
- *(volatile int *)CADDR1 = 0x0;
- if (*(volatile int *)CADDR1 != 0x0) {
- /*
- * test of page failed
- */
- page_bad = TRUE;
- }
- /*
- * Restore original value.
- */
- *(int *)CADDR1 = tmp;
-
- /*
- * Adjust array of valid/good pages.
- */
- if (page_bad == FALSE) {
- /*
- * If this good page is a continuation of the
- * previous set of good pages, then just increase
- * the end pointer. Otherwise start a new chunk.
- * Note that "end" points one higher than end,
- * making the range >= start and < end.
- * If we're also doing a speculative memory
- * test and we at or past the end, bump up Maxmem
- * so that we keep going. The first bad page
- * will terminate the loop.
- */
- if (phys_avail[pa_indx] == target_page) {
- phys_avail[pa_indx] += PAGE_SIZE;
- if (speculative_mprobe == TRUE &&
- phys_avail[pa_indx] >= (64*1024*1024))
- Maxmem++;
- } else {
- pa_indx++;
- if (pa_indx == PHYS_AVAIL_ARRAY_END) {
- printf("Too many holes in the physical address space, giving up\n");
- pa_indx--;
- break;
- }
- phys_avail[pa_indx++] = target_page; /* start */
- phys_avail[pa_indx] = target_page + PAGE_SIZE; /* end */
- }
- physmem++;
- }
- }
-
- *(int *)CMAP1 = 0;
- invltlb();
-
- /*
- * XXX
- * The last chunk must contain at least one page plus the message
- * buffer to avoid complicating other code (message buffer address
- * calculation, etc.).
- */
- while (phys_avail[pa_indx - 1] + PAGE_SIZE +
- round_page(MSGBUF_SIZE) >= phys_avail[pa_indx]) {
- physmem -= atop(phys_avail[pa_indx] - phys_avail[pa_indx - 1]);
- phys_avail[pa_indx--] = 0;
- phys_avail[pa_indx--] = 0;
- }
-
- Maxmem = atop(phys_avail[pa_indx]);
-
- /* Trim off space for the message buffer. */
- phys_avail[pa_indx] -= round_page(MSGBUF_SIZE);
-
- avail_end = phys_avail[pa_indx];
-}
-
-#ifndef PC98
-static void
-getmemsize(int first)
-{
- int i, physmap_idx, pa_indx;
- u_int basemem, extmem;
- struct vm86frame vmf;
- struct vm86context vmc;
- vm_offset_t pa, physmap[PHYSMAP_SIZE];
- pt_entry_t pte;
- const char *cp;
- struct {
- u_int64_t base;
- u_int64_t length;
- u_int32_t type;
- } *smap;
-
- bzero(&vmf, sizeof(struct vm86frame));
- bzero(physmap, sizeof(physmap));
-
- /*
- * Perform "base memory" related probes & setup
- */
- vm86_intcall(0x12, &vmf);
- basemem = vmf.vmf_ax;
- if (basemem > 640) {
- printf("Preposterous BIOS basemem of %uK, truncating to 640K\n",
- basemem);
- basemem = 640;
- }
-
- /*
- * XXX if biosbasemem is now < 640, there is a `hole'
- * between the end of base memory and the start of
- * ISA memory. The hole may be empty or it may
- * contain BIOS code or data. Map it read/write so
- * that the BIOS can write to it. (Memory from 0 to
- * the physical end of the kernel is mapped read-only
- * to begin with and then parts of it are remapped.
- * The parts that aren't remapped form holes that
- * remain read-only and are unused by the kernel.
- * The base memory area is below the physical end of
- * the kernel and right now forms a read-only hole.
- * The part of it from PAGE_SIZE to
- * (trunc_page(biosbasemem * 1024) - 1) will be
- * remapped and used by the kernel later.)
- *
- * This code is similar to the code used in
- * pmap_mapdev, but since no memory needs to be
- * allocated we simply change the mapping.
- */
- for (pa = trunc_page(basemem * 1024);
- pa < ISA_HOLE_START; pa += PAGE_SIZE) {
- pte = (pt_entry_t)vtopte(pa + KERNBASE);
- *pte = pa | PG_RW | PG_V;
- }
-
- /*
- * if basemem != 640, map pages r/w into vm86 page table so
- * that the bios can scribble on it.
- */
- pte = (pt_entry_t)vm86paddr;
- for (i = basemem / 4; i < 160; i++)
- pte[i] = (i << PAGE_SHIFT) | PG_V | PG_RW | PG_U;
-
- /*
- * map page 1 R/W into the kernel page table so we can use it
- * as a buffer. The kernel will unmap this page later.
- */
- pte = (pt_entry_t)vtopte(KERNBASE + (1 << PAGE_SHIFT));
- *pte = (1 << PAGE_SHIFT) | PG_RW | PG_V;
-
- extmem = (Maxmem * PAGE_SIZE - 0x100000)/1024; /* extent memory */
- /*
- * get memory map with INT 15:E820
- */
-#define SMAPSIZ sizeof(*smap)
-#define SMAP_SIG 0x534D4150 /* 'SMAP' */
-
- vmc.npages = 0;
- smap = (void *)vm86_addpage(&vmc, 1, KERNBASE + (1 << PAGE_SHIFT));
- vm86_getptr(&vmc, (vm_offset_t)smap, &vmf.vmf_es, &vmf.vmf_di);
-
- physmap_idx = 0;
- vmf.vmf_ebx = 0;
- do {
- vmf.vmf_eax = 0xE820;
- vmf.vmf_edx = SMAP_SIG;
- vmf.vmf_ecx = SMAPSIZ;
- i = vm86_datacall(0x15, &vmf, &vmc);
- if (i || vmf.vmf_eax != SMAP_SIG)
- break;
- if (boothowto & RB_VERBOSE)
- printf("SMAP type=%02x base=%08x %08x len=%08x %08x\n",
- smap->type,
- *(u_int32_t *)((char *)&smap->base + 4),
- (u_int32_t)smap->base,
- *(u_int32_t *)((char *)&smap->length + 4),
- (u_int32_t)smap->length);
-
- if (smap->type != 0x01)
- goto next_run;
-
- if (smap->length == 0)
- goto next_run;
-
- if (smap->base >= 0xffffffff) {
- printf("%uK of memory above 4GB ignored\n",
- (u_int)(smap->length / 1024));
- goto next_run;
- }
-
- for (i = 0; i <= physmap_idx; i += 2) {
- if (smap->base < physmap[i + 1]) {
- if (boothowto & RB_VERBOSE)
- printf(
- "Overlapping or non-montonic memory region, ignoring second region\n");
- goto next_run;
- }
- }
-
- if (smap->base == physmap[physmap_idx + 1]) {
- physmap[physmap_idx + 1] += smap->length;
- goto next_run;
- }
-
- physmap_idx += 2;
- if (physmap_idx == PHYSMAP_SIZE) {
- printf(
- "Too many segments in the physical address map, giving up\n");
- break;
- }
- physmap[physmap_idx] = smap->base;
- physmap[physmap_idx + 1] = smap->base + smap->length;
-next_run:
- } while (vmf.vmf_ebx != 0);
-
- if (physmap[1] != 0)
- goto physmap_done;
-
- /*
- * If we failed above, try memory map with INT 15:E801
- */
- vmf.vmf_ax = 0xE801;
- if (vm86_intcall(0x15, &vmf) == 0) {
- extmem = vmf.vmf_cx + vmf.vmf_dx * 64;
- } else {
-#if 0
- vmf.vmf_ah = 0x88;
- vm86_intcall(0x15, &vmf);
- extmem = vmf.vmf_ax;
-#else
- /*
- * Prefer the RTC value for extended memory.
- */
- extmem = rtcin(RTC_EXTLO) + (rtcin(RTC_EXTHI) << 8);
-#endif
- }
-
- /*
- * Special hack for chipsets that still remap the 384k hole when
- * there's 16MB of memory - this really confuses people that
- * are trying to use bus mastering ISA controllers with the
- * "16MB limit"; they only have 16MB, but the remapping puts
- * them beyond the limit.
- *
- * If extended memory is between 15-16MB (16-17MB phys address range),
- * chop it to 15MB.
- */
- if ((extmem > 15 * 1024) && (extmem < 16 * 1024))
- extmem = 15 * 1024;
-
- physmap[0] = 0;
- physmap[1] = basemem * 1024;
- physmap_idx = 2;
- physmap[physmap_idx] = 0x100000;
- physmap[physmap_idx + 1] = physmap[physmap_idx] + extmem * 1024;
-
-physmap_done:
- /*
- * Now, physmap contains a map of physical memory.
- */
-
-#ifdef SMP
- /* make hole for AP bootstrap code */
- physmap[1] = mp_bootaddress(physmap[1] / 1024);
-
- /* look for the MP hardware - needed for apic addresses */
- mp_probe();
-#endif
-
- /*
- * Maxmem isn't the "maximum memory", it's one larger than the
- * highest page of the physical address space. It should be
- * called something like "Maxphyspage". We may adjust this
- * based on ``hw.physmem'' and the results of the memory test.
- */
- Maxmem = atop(physmap[physmap_idx + 1]);
-
-#ifdef MAXMEM
- Maxmem = MAXMEM / 4;
-#endif
-
- /*
- * hw.maxmem is a size in bytes; we also allow k, m, and g suffixes
- * for the appropriate modifiers. This overrides MAXMEM.
- */
- if ((cp = getenv("hw.physmem")) != NULL) {
- u_int64_t AllowMem, sanity;
- char *ep;
-
- sanity = AllowMem = strtouq(cp, &ep, 0);
- if ((ep != cp) && (*ep != 0)) {
- switch(*ep) {
- case 'g':
- case 'G':
- AllowMem <<= 10;
- case 'm':
- case 'M':
- AllowMem <<= 10;
- case 'k':
- case 'K':
- AllowMem <<= 10;
- break;
- default:
- AllowMem = sanity = 0;
- }
- if (AllowMem < sanity)
- AllowMem = 0;
- }
- if (AllowMem == 0)
- printf("Ignoring invalid memory size of '%s'\n", cp);
- else
- Maxmem = atop(AllowMem);
- }
-
- if (atop(physmap[physmap_idx + 1]) != Maxmem &&
- (boothowto & RB_VERBOSE))
- printf("Physical memory use set to %uK\n", Maxmem * 4);
-
- /*
- * If Maxmem has been increased beyond what the system has detected,
- * extend the last memory segment to the new limit.
- */
- if (atop(physmap[physmap_idx + 1]) < Maxmem)
- physmap[physmap_idx + 1] = ptoa(Maxmem);
-
- /* call pmap initialization to make new kernel address space */
- pmap_bootstrap(first, 0);
-
- /*
- * Size up each available chunk of physical memory.
- */
- physmap[0] = PAGE_SIZE; /* mask off page 0 */
- pa_indx = 0;
- phys_avail[pa_indx++] = physmap[0];
- phys_avail[pa_indx] = physmap[0];
-#if 0
- pte = (pt_entry_t)vtopte(KERNBASE);
-#else
- pte = (pt_entry_t)CMAP1;
-#endif
-
- /*
- * physmap is in bytes, so when converting to page boundaries,
- * round up the start address and round down the end address.
- */
- for (i = 0; i <= physmap_idx; i += 2) {
- vm_offset_t end;
-
- end = ptoa(Maxmem);
- if (physmap[i + 1] < end)
- end = trunc_page(physmap[i + 1]);
- for (pa = round_page(physmap[i]); pa < end; pa += PAGE_SIZE) {
- int tmp, page_bad;
-#if 0
- int *ptr = 0;
-#else
- int *ptr = (int *)CADDR1;
-#endif
-
- /*
- * block out kernel memory as not available.
- */
- if (pa >= 0x100000 && pa < first)
- continue;
-
- page_bad = FALSE;
-
- /*
- * map page into kernel: valid, read/write,non-cacheable
- */
- *pte = pa | PG_V | PG_RW | PG_N;
- invltlb();
-
- tmp = *(int *)ptr;
- /*
- * Test for alternating 1's and 0's
- */
- *(volatile int *)ptr = 0xaaaaaaaa;
- if (*(volatile int *)ptr != 0xaaaaaaaa) {
- page_bad = TRUE;
- }
- /*
- * Test for alternating 0's and 1's
- */
- *(volatile int *)ptr = 0x55555555;
- if (*(volatile int *)ptr != 0x55555555) {
- page_bad = TRUE;
- }
- /*
- * Test for all 1's
- */
- *(volatile int *)ptr = 0xffffffff;
- if (*(volatile int *)ptr != 0xffffffff) {
- page_bad = TRUE;
- }
- /*
- * Test for all 0's
- */
- *(volatile int *)ptr = 0x0;
- if (*(volatile int *)ptr != 0x0) {
- page_bad = TRUE;
- }
- /*
- * Restore original value.
- */
- *(int *)ptr = tmp;
-
- /*
- * Adjust array of valid/good pages.
- */
- if (page_bad == TRUE) {
- continue;
- }
- /*
- * If this good page is a continuation of the
- * previous set of good pages, then just increase
- * the end pointer. Otherwise start a new chunk.
- * Note that "end" points one higher than end,
- * making the range >= start and < end.
- * If we're also doing a speculative memory
- * test and we at or past the end, bump up Maxmem
- * so that we keep going. The first bad page
- * will terminate the loop.
- */
- if (phys_avail[pa_indx] == pa) {
- phys_avail[pa_indx] += PAGE_SIZE;
- } else {
- pa_indx++;
- if (pa_indx == PHYS_AVAIL_ARRAY_END) {
- printf("Too many holes in the physical address space, giving up\n");
- pa_indx--;
- break;
- }
- phys_avail[pa_indx++] = pa; /* start */
- phys_avail[pa_indx] = pa + PAGE_SIZE; /* end */
- }
- physmem++;
- }
- }
- *pte = 0;
- invltlb();
-
- /*
- * XXX
- * The last chunk must contain at least one page plus the message
- * buffer to avoid complicating other code (message buffer address
- * calculation, etc.).
- */
- while (phys_avail[pa_indx - 1] + PAGE_SIZE +
- round_page(MSGBUF_SIZE) >= phys_avail[pa_indx]) {
- physmem -= atop(phys_avail[pa_indx] - phys_avail[pa_indx - 1]);
- phys_avail[pa_indx--] = 0;
- phys_avail[pa_indx--] = 0;
- }
-
- Maxmem = atop(phys_avail[pa_indx]);
-
- /* Trim off space for the message buffer. */
- phys_avail[pa_indx] -= round_page(MSGBUF_SIZE);
-
- avail_end = phys_avail[pa_indx];
-}
-#endif
-
-void
-init386(first)
- int first;
-{
- int x;
- struct gate_descriptor *gdp;
- int gsel_tss;
-#ifndef SMP
- /* table descriptors - used to load tables by microp */
- struct region_descriptor r_gdt, r_idt;
-#endif
- int off;
-
- /*
- * Prevent lowering of the ipl if we call tsleep() early.
- */
- safepri = cpl;
-
- proc0.p_addr = proc0paddr;
-
- atdevbase = ISA_HOLE_START + KERNBASE;
-
-#ifdef PC98
- /*
- * Initialize DMAC
- */
- pc98_init_dmac();
-#endif
-
- if (bootinfo.bi_modulep) {
- preload_metadata = (caddr_t)bootinfo.bi_modulep + KERNBASE;
- preload_bootstrap_relocate(KERNBASE);
- }
- if (bootinfo.bi_envp)
- kern_envp = (caddr_t)bootinfo.bi_envp + KERNBASE;
-
- /*
- * make gdt memory segments, the code segment goes up to end of the
- * page with etext in it, the data segment goes to the end of
- * the address space
- */
- /*
- * XXX text protection is temporarily (?) disabled. The limit was
- * i386_btop(round_page(etext)) - 1.
- */
- gdt_segs[GCODE_SEL].ssd_limit = i386_btop(0) - 1;
- gdt_segs[GDATA_SEL].ssd_limit = i386_btop(0) - 1;
-#ifdef SMP
- gdt_segs[GPRIV_SEL].ssd_limit =
- i386_btop(sizeof(struct privatespace)) - 1;
- gdt_segs[GPRIV_SEL].ssd_base = (int) &SMP_prvspace[0];
- gdt_segs[GPROC0_SEL].ssd_base =
- (int) &SMP_prvspace[0].globaldata.gd_common_tss;
- SMP_prvspace[0].globaldata.gd_prvspace = &SMP_prvspace[0];
-#else
- gdt_segs[GPRIV_SEL].ssd_limit = i386_btop(0) - 1;
- gdt_segs[GPROC0_SEL].ssd_base = (int) &common_tss;
-#endif
-
- for (x = 0; x < NGDT; x++) {
-#ifdef BDE_DEBUGGER
- /* avoid overwriting db entries with APM ones */
- if (x >= GAPMCODE32_SEL && x <= GAPMDATA_SEL)
- continue;
-#endif
- ssdtosd(&gdt_segs[x], &gdt[x].sd);
- }
-
- r_gdt.rd_limit = NGDT * sizeof(gdt[0]) - 1;
- r_gdt.rd_base = (int) gdt;
- lgdt(&r_gdt);
-
- /* make ldt memory segments */
- /*
- * The data segment limit must not cover the user area because we
- * don't want the user area to be writable in copyout() etc. (page
- * level protection is lost in kernel mode on 386's). Also, we
- * don't want the user area to be writable directly (page level
- * protection of the user area is not available on 486's with
- * CR0_WP set, because there is no user-read/kernel-write mode).
- *
- * XXX - VM_MAXUSER_ADDRESS is an end address, not a max. And it
- * should be spelled ...MAX_USER...
- */
-#define VM_END_USER_RW_ADDRESS VM_MAXUSER_ADDRESS
- /*
- * The code segment limit has to cover the user area until we move
- * the signal trampoline out of the user area. This is safe because
- * the code segment cannot be written to directly.
- */
-#define VM_END_USER_R_ADDRESS (VM_END_USER_RW_ADDRESS + UPAGES * PAGE_SIZE)
- ldt_segs[LUCODE_SEL].ssd_limit = i386_btop(VM_END_USER_R_ADDRESS) - 1;
- ldt_segs[LUDATA_SEL].ssd_limit = i386_btop(VM_END_USER_RW_ADDRESS) - 1;
- for (x = 0; x < sizeof ldt_segs / sizeof ldt_segs[0]; x++)
- ssdtosd(&ldt_segs[x], &ldt[x].sd);
-
- _default_ldt = GSEL(GLDT_SEL, SEL_KPL);
- lldt(_default_ldt);
-#ifdef USER_LDT
- currentldt = _default_ldt;
-#endif
-
- /* exceptions */
- for (x = 0; x < NIDT; x++)
- setidt(x, &IDTVEC(rsvd), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(0, &IDTVEC(div), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(1, &IDTVEC(dbg), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(2, &IDTVEC(nmi), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(3, &IDTVEC(bpt), SDT_SYS386TGT, SEL_UPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(4, &IDTVEC(ofl), SDT_SYS386TGT, SEL_UPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(5, &IDTVEC(bnd), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(6, &IDTVEC(ill), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(7, &IDTVEC(dna), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(8, 0, SDT_SYSTASKGT, SEL_KPL, GSEL(GPANIC_SEL, SEL_KPL));
- setidt(9, &IDTVEC(fpusegm), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(10, &IDTVEC(tss), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(11, &IDTVEC(missing), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(12, &IDTVEC(stk), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(13, &IDTVEC(prot), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(14, &IDTVEC(page), SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(15, &IDTVEC(rsvd), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(16, &IDTVEC(fpu), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(17, &IDTVEC(align), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(18, &IDTVEC(mchk), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(0x80, &IDTVEC(int0x80_syscall),
- SDT_SYS386TGT, SEL_UPL, GSEL(GCODE_SEL, SEL_KPL));
-
- r_idt.rd_limit = sizeof(idt0) - 1;
- r_idt.rd_base = (int) idt;
- lidt(&r_idt);
-
- /*
- * Initialize the console before we print anything out.
- */
- cninit();
-
-#include "isa.h"
-#if NISA >0
- isa_defaultirq();
-#endif
- rand_initialize();
-
-#ifdef DDB
- kdb_init();
- if (boothowto & RB_KDB)
- Debugger("Boot flags requested debugger");
-#endif
-
- finishidentcpu(); /* Final stage of CPU initialization */
- setidt(6, &IDTVEC(ill), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- setidt(13, &IDTVEC(prot), SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
- initializecpu(); /* Initialize CPU registers */
-
- /* make an initial tss so cpu can get interrupt stack on syscall! */
- common_tss.tss_esp0 = (int) proc0.p_addr + UPAGES*PAGE_SIZE - 16;
- common_tss.tss_ss0 = GSEL(GDATA_SEL, SEL_KPL) ;
- gsel_tss = GSEL(GPROC0_SEL, SEL_KPL);
- private_tss = 0;
- tss_gdt = &gdt[GPROC0_SEL].sd;
- common_tssd = *tss_gdt;
- common_tss.tss_ioopt = (sizeof common_tss) << 16;
- ltr(gsel_tss);
-
- dblfault_tss.tss_esp = dblfault_tss.tss_esp0 = dblfault_tss.tss_esp1 =
- dblfault_tss.tss_esp2 = (int) &dblfault_stack[sizeof(dblfault_stack)];
- dblfault_tss.tss_ss = dblfault_tss.tss_ss0 = dblfault_tss.tss_ss1 =
- dblfault_tss.tss_ss2 = GSEL(GDATA_SEL, SEL_KPL);
- dblfault_tss.tss_cr3 = (int)IdlePTD;
- dblfault_tss.tss_eip = (int) dblfault_handler;
- dblfault_tss.tss_eflags = PSL_KERNEL;
- dblfault_tss.tss_ds = dblfault_tss.tss_es =
- dblfault_tss.tss_gs = GSEL(GDATA_SEL, SEL_KPL);
- dblfault_tss.tss_fs = GSEL(GPRIV_SEL, SEL_KPL);
- dblfault_tss.tss_cs = GSEL(GCODE_SEL, SEL_KPL);
- dblfault_tss.tss_ldt = GSEL(GLDT_SEL, SEL_KPL);
-
- vm86_initialize();
-#ifdef PC98
- getmemsize_pc98(first);
-#else
- getmemsize(first);
-#endif
- /* now running on new page tables, configured,and u/iom is accessible */
-
- /* Map the message buffer. */
- for (off = 0; off < round_page(MSGBUF_SIZE); off += PAGE_SIZE)
- pmap_kenter((vm_offset_t)msgbufp + off, avail_end + off);
-
- msgbufinit(msgbufp, MSGBUF_SIZE);
-
- /* make a call gate to reenter kernel with */
- gdp = &ldt[LSYS5CALLS_SEL].gd;
-
- x = (int) &IDTVEC(syscall);
- gdp->gd_looffset = x++;
- gdp->gd_selector = GSEL(GCODE_SEL,SEL_KPL);
- gdp->gd_stkcpy = 1;
- gdp->gd_type = SDT_SYS386CGT;
- gdp->gd_dpl = SEL_UPL;
- gdp->gd_p = 1;
- gdp->gd_hioffset = ((int) &IDTVEC(syscall)) >>16;
-
- /* XXX does this work? */
- ldt[LBSDICALLS_SEL] = ldt[LSYS5CALLS_SEL];
- ldt[LSOL26CALLS_SEL] = ldt[LSYS5CALLS_SEL];
-
- /* transfer to user mode */
-
- _ucodesel = LSEL(LUCODE_SEL, SEL_UPL);
- _udatasel = LSEL(LUDATA_SEL, SEL_UPL);
-
- /* setup proc 0's pcb */
- proc0.p_addr->u_pcb.pcb_flags = 0;
- proc0.p_addr->u_pcb.pcb_cr3 = (int)IdlePTD;
-#ifdef SMP
- proc0.p_addr->u_pcb.pcb_mpnest = 1;
-#endif
- proc0.p_addr->u_pcb.pcb_ext = 0;
-}
-
-#if defined(I586_CPU) && !defined(NO_F00F_HACK)
-static void f00f_hack(void *unused);
-SYSINIT(f00f_hack, SI_SUB_INTRINSIC, SI_ORDER_FIRST, f00f_hack, NULL);
-
-static void
-f00f_hack(void *unused) {
- struct gate_descriptor *new_idt;
-#ifndef SMP
- struct region_descriptor r_idt;
-#endif
- vm_offset_t tmp;
-
- if (!has_f00f_bug)
- return;
-
- printf("Intel Pentium detected, installing workaround for F00F bug\n");
-
- r_idt.rd_limit = sizeof(idt0) - 1;
-
- tmp = kmem_alloc(kernel_map, PAGE_SIZE * 2);
- if (tmp == 0)
- panic("kmem_alloc returned 0");
- if (((unsigned int)tmp & (PAGE_SIZE-1)) != 0)
- panic("kmem_alloc returned non-page-aligned memory");
- /* Put the first seven entries in the lower page */
- new_idt = (struct gate_descriptor*)(tmp + PAGE_SIZE - (7*8));
- bcopy(idt, new_idt, sizeof(idt0));
- r_idt.rd_base = (int)new_idt;
- lidt(&r_idt);
- idt = new_idt;
- if (vm_map_protect(kernel_map, tmp, tmp + PAGE_SIZE,
- VM_PROT_READ, FALSE) != KERN_SUCCESS)
- panic("vm_map_protect failed");
- return;
-}
-#endif /* defined(I586_CPU) && !NO_F00F_HACK */
-
-int
-ptrace_set_pc(p, addr)
- struct proc *p;
- unsigned long addr;
-{
- p->p_md.md_regs->tf_eip = addr;
- return (0);
-}
-
-int
-ptrace_single_step(p)
- struct proc *p;
-{
- p->p_md.md_regs->tf_eflags |= PSL_T;
- return (0);
-}
-
-int ptrace_read_u_check(p, addr, len)
- struct proc *p;
- vm_offset_t addr;
- size_t len;
-{
- vm_offset_t gap;
-
- if ((vm_offset_t) (addr + len) < addr)
- return EPERM;
- if ((vm_offset_t) (addr + len) <= sizeof(struct user))
- return 0;
-
- gap = (char *) p->p_md.md_regs - (char *) p->p_addr;
-
- if ((vm_offset_t) addr < gap)
- return EPERM;
- if ((vm_offset_t) (addr + len) <=
- (vm_offset_t) (gap + sizeof(struct trapframe)))
- return 0;
- return EPERM;
-}
-
-int ptrace_write_u(p, off, data)
- struct proc *p;
- vm_offset_t off;
- long data;
-{
- struct trapframe frame_copy;
- vm_offset_t min;
- struct trapframe *tp;
-
- /*
- * Privileged kernel state is scattered all over the user area.
- * Only allow write access to parts of regs and to fpregs.
- */
- min = (char *)p->p_md.md_regs - (char *)p->p_addr;
- if (off >= min && off <= min + sizeof(struct trapframe) - sizeof(int)) {
- tp = p->p_md.md_regs;
- frame_copy = *tp;
- *(int *)((char *)&frame_copy + (off - min)) = data;
- if (!EFL_SECURE(frame_copy.tf_eflags, tp->tf_eflags) ||
- !CS_SECURE(frame_copy.tf_cs))
- return (EINVAL);
- *(int*)((char *)p->p_addr + off) = data;
- return (0);
- }
- min = offsetof(struct user, u_pcb) + offsetof(struct pcb, pcb_savefpu);
- if (off >= min && off <= min + sizeof(struct save87) - sizeof(int)) {
- *(int*)((char *)p->p_addr + off) = data;
- return (0);
- }
- return (EFAULT);
-}
-
-int
-fill_regs(p, regs)
- struct proc *p;
- struct reg *regs;
-{
- struct pcb *pcb;
- struct trapframe *tp;
-
- tp = p->p_md.md_regs;
- regs->r_fs = tp->tf_fs;
- regs->r_es = tp->tf_es;
- regs->r_ds = tp->tf_ds;
- regs->r_edi = tp->tf_edi;
- regs->r_esi = tp->tf_esi;
- regs->r_ebp = tp->tf_ebp;
- regs->r_ebx = tp->tf_ebx;
- regs->r_edx = tp->tf_edx;
- regs->r_ecx = tp->tf_ecx;
- regs->r_eax = tp->tf_eax;
- regs->r_eip = tp->tf_eip;
- regs->r_cs = tp->tf_cs;
- regs->r_eflags = tp->tf_eflags;
- regs->r_esp = tp->tf_esp;
- regs->r_ss = tp->tf_ss;
- pcb = &p->p_addr->u_pcb;
- regs->r_gs = pcb->pcb_gs;
- return (0);
-}
-
-int
-set_regs(p, regs)
- struct proc *p;
- struct reg *regs;
-{
- struct pcb *pcb;
- struct trapframe *tp;
-
- tp = p->p_md.md_regs;
- if (!EFL_SECURE(regs->r_eflags, tp->tf_eflags) ||
- !CS_SECURE(regs->r_cs))
- return (EINVAL);
- tp->tf_fs = regs->r_fs;
- tp->tf_es = regs->r_es;
- tp->tf_ds = regs->r_ds;
- tp->tf_edi = regs->r_edi;
- tp->tf_esi = regs->r_esi;
- tp->tf_ebp = regs->r_ebp;
- tp->tf_ebx = regs->r_ebx;
- tp->tf_edx = regs->r_edx;
- tp->tf_ecx = regs->r_ecx;
- tp->tf_eax = regs->r_eax;
- tp->tf_eip = regs->r_eip;
- tp->tf_cs = regs->r_cs;
- tp->tf_eflags = regs->r_eflags;
- tp->tf_esp = regs->r_esp;
- tp->tf_ss = regs->r_ss;
- pcb = &p->p_addr->u_pcb;
- pcb->pcb_gs = regs->r_gs;
- return (0);
-}
-
-int
-fill_fpregs(p, fpregs)
- struct proc *p;
- struct fpreg *fpregs;
-{
- bcopy(&p->p_addr->u_pcb.pcb_savefpu, fpregs, sizeof *fpregs);
- return (0);
-}
-
-int
-set_fpregs(p, fpregs)
- struct proc *p;
- struct fpreg *fpregs;
-{
- bcopy(fpregs, &p->p_addr->u_pcb.pcb_savefpu, sizeof *fpregs);
- return (0);
-}
-
-int
-fill_dbregs(p, dbregs)
- struct proc *p;
- struct dbreg *dbregs;
-{
- struct pcb *pcb;
-
- pcb = &p->p_addr->u_pcb;
- dbregs->dr0 = pcb->pcb_dr0;
- dbregs->dr1 = pcb->pcb_dr1;
- dbregs->dr2 = pcb->pcb_dr2;
- dbregs->dr3 = pcb->pcb_dr3;
- dbregs->dr4 = 0;
- dbregs->dr5 = 0;
- dbregs->dr6 = pcb->pcb_dr6;
- dbregs->dr7 = pcb->pcb_dr7;
- return (0);
-}
-
-int
-set_dbregs(p, dbregs)
- struct proc *p;
- struct dbreg *dbregs;
-{
- struct pcb *pcb;
-
- pcb = &p->p_addr->u_pcb;
-
- /*
- * Don't let a process set a breakpoint that is not within the
- * process's address space. If a process could do this, it
- * could halt the system by setting a breakpoint in the kernel
- * (if ddb was enabled). Thus, we need to check to make sure
- * that no breakpoints are being enabled for addresses outside
- * process's address space, unless, perhaps, we were called by
- * uid 0.
- *
- * XXX - what about when the watched area of the user's
- * address space is written into from within the kernel
- * ... wouldn't that still cause a breakpoint to be generated
- * from within kernel mode?
- */
-
- if (p->p_ucred->cr_uid != 0) {
- if (dbregs->dr7 & 0x3) {
- /* dr0 is enabled */
- if (dbregs->dr0 >= VM_MAXUSER_ADDRESS)
- return (EINVAL);
- }
-
- if (dbregs->dr7 & (0x3<<2)) {
- /* dr1 is enabled */
- if (dbregs->dr1 >= VM_MAXUSER_ADDRESS)
- return (EINVAL);
- }
-
- if (dbregs->dr7 & (0x3<<4)) {
- /* dr2 is enabled */
- if (dbregs->dr2 >= VM_MAXUSER_ADDRESS)
- return (EINVAL);
- }
-
- if (dbregs->dr7 & (0x3<<6)) {
- /* dr3 is enabled */
- if (dbregs->dr3 >= VM_MAXUSER_ADDRESS)
- return (EINVAL);
- }
- }
-
- pcb->pcb_dr0 = dbregs->dr0;
- pcb->pcb_dr1 = dbregs->dr1;
- pcb->pcb_dr2 = dbregs->dr2;
- pcb->pcb_dr3 = dbregs->dr3;
- pcb->pcb_dr6 = dbregs->dr6;
- pcb->pcb_dr7 = dbregs->dr7;
-
- pcb->pcb_flags |= PCB_DBREGS;
-
- return (0);
-}
-
-/*
- * Return > 0 if a hardware breakpoint has been hit, and the
- * breakpoint was in user space. Return 0, otherwise.
- */
-int
-user_dbreg_trap(void)
-{
- u_int32_t dr7, dr6; /* debug registers dr6 and dr7 */
- u_int32_t bp; /* breakpoint bits extracted from dr6 */
- int nbp; /* number of breakpoints that triggered */
- caddr_t addr[4]; /* breakpoint addresses */
- int i;
-
- dr7 = rdr7();
- if ((dr7 & 0x000000ff) == 0) {
- /*
- * all GE and LE bits in the dr7 register are zero,
- * thus the trap couldn't have been caused by the
- * hardware debug registers
- */
- return 0;
- }
-
- nbp = 0;
- dr6 = rdr6();
- bp = dr6 & 0x0000000f;
-
- if (!bp) {
- /*
- * None of the breakpoint bits are set meaning this
- * trap was not caused by any of the debug registers
- */
- return 0;
- }
-
- /*
- * at least one of the breakpoints were hit, check to see
- * which ones and if any of them are user space addresses
- */
-
- if (bp & 0x01) {
- addr[nbp++] = (caddr_t)rdr0();
- }
- if (bp & 0x02) {
- addr[nbp++] = (caddr_t)rdr1();
- }
- if (bp & 0x04) {
- addr[nbp++] = (caddr_t)rdr2();
- }
- if (bp & 0x08) {
- addr[nbp++] = (caddr_t)rdr3();
- }
-
- for (i=0; i<nbp; i++) {
- if (addr[i] <
- (caddr_t)VM_MAXUSER_ADDRESS) {
- /*
- * addr[i] is in user space
- */
- return nbp;
- }
- }
-
- /*
- * None of the breakpoints are in user space.
- */
- return 0;
-}
-
-
-#ifndef DDB
-void
-Debugger(const char *msg)
-{
- printf("Debugger(\"%s\") called.\n", msg);
-}
-#endif /* no DDB */
-
-#include <sys/disklabel.h>
-
-/*
- * Determine the size of the transfer, and make sure it is
- * within the boundaries of the partition. Adjust transfer
- * if needed, and signal errors or early completion.
- */
-int
-bounds_check_with_label(struct buf *bp, struct disklabel *lp, int wlabel)
-{
- struct partition *p = lp->d_partitions + dkpart(bp->b_dev);
- int labelsect = lp->d_partitions[0].p_offset;
- int maxsz = p->p_size,
- sz = (bp->b_bcount + DEV_BSIZE - 1) >> DEV_BSHIFT;
-
- /* overwriting disk label ? */
- /* XXX should also protect bootstrap in first 8K */
- if (bp->b_blkno + p->p_offset <= LABELSECTOR + labelsect &&
-#if LABELSECTOR != 0
- bp->b_blkno + p->p_offset + sz > LABELSECTOR + labelsect &&
-#endif
- (bp->b_flags & B_READ) == 0 && wlabel == 0) {
- bp->b_error = EROFS;
- goto bad;
- }
-
-#if defined(DOSBBSECTOR) && defined(notyet)
- /* overwriting master boot record? */
- if (bp->b_blkno + p->p_offset <= DOSBBSECTOR &&
- (bp->b_flags & B_READ) == 0 && wlabel == 0) {
- bp->b_error = EROFS;
- goto bad;
- }
-#endif
-
- /* beyond partition? */
- if (bp->b_blkno < 0 || bp->b_blkno + sz > maxsz) {
- /* if exactly at end of disk, return an EOF */
- if (bp->b_blkno == maxsz) {
- bp->b_resid = bp->b_bcount;
- return(0);
- }
- /* or truncate if part of it fits */
- sz = maxsz - bp->b_blkno;
- if (sz <= 0) {
- bp->b_error = EINVAL;
- goto bad;
- }
- bp->b_bcount = sz << DEV_BSHIFT;
- }
-
- bp->b_pblkno = bp->b_blkno + p->p_offset;
- return(1);
-
-bad:
- bp->b_flags |= B_ERROR;
- return(-1);
-}
-
-#ifdef DDB
-
-/*
- * Provide inb() and outb() as functions. They are normally only
- * available as macros calling inlined functions, thus cannot be
- * called inside DDB.
- *
- * The actual code is stolen from <machine/cpufunc.h>, and de-inlined.
- */
-
-#undef inb
-#undef outb
-
-/* silence compiler warnings */
-u_char inb(u_int);
-void outb(u_int, u_char);
-
-u_char
-inb(u_int port)
-{
- u_char data;
- /*
- * We use %%dx and not %1 here because i/o is done at %dx and not at
- * %edx, while gcc generates inferior code (movw instead of movl)
- * if we tell it to load (u_short) port.
- */
- __asm __volatile("inb %%dx,%0" : "=a" (data) : "d" (port));
- return (data);
-}
-
-void
-outb(u_int port, u_char data)
-{
- u_char al;
- /*
- * Use an unnecessary assignment to help gcc's register allocator.
- * This make a large difference for gcc-1.40 and a tiny difference
- * for gcc-2.6.0. For gcc-1.40, al had to be ``asm("ax")'' for
- * best results. gcc-2.6.0 can't handle this.
- */
- al = data;
- __asm __volatile("outb %0,%%dx" : : "a" (al), "d" (port));
-}
-
-#endif /* DDB */
diff --git a/sys/pc98/pc98/wd_cd.c b/sys/pc98/pc98/wd_cd.c
deleted file mode 100644
index d8f5aa376368..000000000000
--- a/sys/pc98/pc98/wd_cd.c
+++ /dev/null
@@ -1,1479 +0,0 @@
-/*-
- * Copyright (c) 1998, 1999 Søren Schmidt
- * 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,
- * without modification, immediately at the beginning of the file.
- * 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/proc.h>
-#include <sys/malloc.h>
-#include <sys/buf.h>
-#include <sys/disklabel.h>
-#include <sys/devicestat.h>
-#include <sys/cdio.h>
-#include <sys/wormio.h>
-#include <sys/fcntl.h>
-#include <sys/conf.h>
-#include <sys/stat.h>
-#include <i386/isa/atapi.h>
-#include <i386/isa/wd_cd.h>
-
-static d_open_t acdopen;
-static d_close_t acdclose;
-static d_ioctl_t acdioctl;
-static d_strategy_t acdstrategy;
-
-#define CDEV_MAJOR 69
-#define BDEV_MAJOR 19
-static struct cdevsw acd_cdevsw = {
- /* open */ acdopen,
- /* close */ acdclose,
- /* read */ physread,
- /* write */ physwrite,
- /* ioctl */ acdioctl,
- /* poll */ nopoll,
- /* mmap */ nommap,
- /* strategy */ acdstrategy,
- /* name */ "wcd",
- /* maj */ CDEV_MAJOR,
- /* dump */ nodump,
- /* psize */ nopsize,
- /* flags */ D_DISK,
- /* bmaj */ BDEV_MAJOR
-};
-
-#define NUNIT 16 /* Max # of devices */
-
-#define F_BOPEN 0x0001 /* The block device is opened */
-#define F_MEDIA_CHANGED 0x0002 /* The media have changed since open */
-#define F_DEBUG 0x0004 /* Print debug info */
-#define F_LOCKED 0x0008 /* This unit is locked (or should be) */
-#define F_TRACK_PREP 0x0010 /* Track should be prep'ed */
-#define F_TRACK_PREPED 0x0020 /* Track has been prep'ed */
-#define F_DISK_PREPED 0x0040 /* Disk has been prep'ed */
-#define F_WRITTEN 0x0080 /* The medium has been written to */
-
-static struct acd *acdtab[NUNIT];
-static int acdnlun = 0; /* Number of configured drives */
-
-int acdattach(struct atapi *, int, struct atapi_params *, int);
-static struct acd *acd_init_lun(struct atapi *, int, struct atapi_params *, int,
-struct devstat *);
-static void acd_start(struct acd *);
-static void acd_done(struct acd *, struct buf *, int, struct atapires);
-static int acd_read_toc(struct acd *);
-static int acd_request_wait(struct acd *, u_char, u_char, u_char, u_char, u_char, u_char, u_char, u_char, u_char, u_char, char *, int);
-static void acd_describe(struct acd *);
-static int acd_setchan(struct acd *, u_char, u_char, u_char, u_char);
-static int acd_eject(struct acd *, int);
-static void acd_select_slot(struct acd *);
-static int acd_open_disk(struct acd *, int);
-static int acd_open_track(struct acd *, struct wormio_prepare_track *);
-static int acd_close_track(struct acd *);
-static int acd_close_disk(struct acd *);
-static int acd_read_track_info(struct acd *cdp, int lba, struct acd_track_info *info);
-static int acd_blank_disk(struct acd *);
-static void atapi_dump(int ctrlr, int lun, char *label, void *data, int len);
-static void atapi_error(struct atapi *ata, int unit, struct atapires result);
-
-struct acd *
-acd_init_lun(struct atapi *ata, int unit, struct atapi_params *ap, int lun,
- struct devstat *device_stats)
-{
- struct acd *ptr;
-
- if (!(ptr = malloc(sizeof(struct acd), M_TEMP, M_NOWAIT)))
- return NULL;
- bzero(ptr, sizeof(struct acd));
- bufq_init(&ptr->buf_queue);
- ptr->ata = ata;
- ptr->unit = unit;
- ptr->lun = lun;
- ptr->param = ap;
- ptr->flags = F_MEDIA_CHANGED;
- ptr->flags &= ~(F_WRITTEN|F_TRACK_PREP|F_TRACK_PREPED);
- ptr->block_size = 2048;
- ptr->refcnt = 0;
- ptr->slot = -1;
- ptr->changer_info = NULL;
- if (device_stats == NULL) {
- if (!(ptr->device_stats = malloc(sizeof(struct devstat),
- M_TEMP, M_NOWAIT)))
- return NULL;
- bzero(ptr->device_stats, sizeof(struct devstat));
- }
- else
- ptr->device_stats = device_stats;
- make_dev(&acd_cdevsw, dkmakeminor(lun, 0, 0),
- UID_ROOT, GID_OPERATOR, 0640, "rwcd%da", lun);
- make_dev(&acd_cdevsw, dkmakeminor(lun, 0, RAW_PART),
- UID_ROOT, GID_OPERATOR, 0640, "rwcd%dc", lun);
- make_dev(&acd_cdevsw, dkmakeminor(lun, 0, 0),
- UID_ROOT, GID_OPERATOR, 0640, "wcd%da", lun);
- make_dev(&acd_cdevsw, dkmakeminor(lun, 0, RAW_PART),
- UID_ROOT, GID_OPERATOR, 0640, "wcd%dc", lun);
- return ptr;
-}
-
-int
-acdattach(struct atapi *ata, int unit, struct atapi_params *ap, int debug)
-{
- struct acd *cdp;
- struct atapires result;
- struct changer *chp;
- int i, count;
-
- if (acdnlun >= NUNIT) {
- printf("wcd: too many units\n");
- return 0;
- }
- if (!atapi_request_immediate) {
- printf("wcd: configuration error, ATAPI code not present!\n");
- return 0;
- }
- if ((cdp = acd_init_lun(ata, unit, ap, acdnlun, NULL)) == NULL) {
- printf("wcd: out of memory\n");
- return 0;
- }
- acdtab[acdnlun] = cdp;
-
- if (debug) {
- cdp->flags |= F_DEBUG;
- atapi_dump(cdp->ata->ctrlr, cdp->lun, "info", ap, sizeof(*ap));
- }
-
- /* Get drive capabilities, some drives needs this repeated */
- for (count = 0 ; count < 5 ; count++) {
- result = atapi_request_immediate(ata, unit,
- ATAPI_MODE_SENSE,
- 0, ATAPI_CDROM_CAP_PAGE,
- 0, 0, 0, 0,
- sizeof(cdp->cap)>>8, sizeof(cdp->cap),
- 0, 0, 0, 0, 0, 0, 0,
- (char *)&cdp->cap, sizeof(cdp->cap));
- if (result.code == 0 || result.code == RES_UNDERRUN)
- break;
- }
-
- /* Some drives have shorter capabilities page. */
- if (result.code == RES_UNDERRUN)
- result.code = 0;
-
- if (result.code == 0) {
- cdp->cap.max_speed = ntohs(cdp->cap.max_speed);
- cdp->cap.max_vol_levels = ntohs(cdp->cap.max_vol_levels);
- cdp->cap.buf_size = ntohs(cdp->cap.buf_size);
- cdp->cap.cur_speed = ntohs(cdp->cap.cur_speed);
- acd_describe(cdp);
- if (cdp->flags & F_DEBUG)
- atapi_dump(cdp->ata->ctrlr, cdp->lun, "cap", &cdp->cap,
- sizeof(cdp->cap));
- }
- /* If this is a changer device, allocate the neeeded lun's */
- if (cdp->cap.mech == MST_MECH_CHANGER) {
- char string[16];
- struct acd *tmpcdp = cdp;
-
- chp = malloc(sizeof(struct changer), M_TEMP, M_NOWAIT);
- if (chp == NULL) {
- printf("wcd: out of memory\n");
- return 0;
- }
- bzero(chp, sizeof(struct changer));
- result = atapi_request_immediate(ata, unit, ATAPI_MECH_STATUS,
- 0, 0, 0, 0, 0, 0, 0,
- sizeof(struct changer)>>8,
- sizeof(struct changer),
- 0, 0, 0, 0, 0, 0,
- (char *)chp, sizeof(struct changer));
- if (cdp->flags & F_DEBUG) {
- printf("result.code=%d curr=%02x slots=%d len=%d\n",
- result.code, chp->current_slot, chp->slots,
- htons(chp->table_length));
- }
- if (result.code == RES_UNDERRUN)
- result.code = 0;
-
- if (result.code == 0) {
- chp->table_length = htons(chp->table_length);
- for (i = 0; i < chp->slots && acdnlun < NUNIT; i++) {
- if (i > 0) {
- tmpcdp = acd_init_lun(ata, unit, ap, acdnlun,
- cdp->device_stats);
- if (!tmpcdp) {
- printf("wcd: out of memory\n");
- return 0;
- }
- }
- tmpcdp->slot = i;
- tmpcdp->changer_info = chp;
- printf("wcd%d: changer slot %d %s\n", acdnlun, i,
- (chp->slot[i].present ? "disk present" : "no disk"));
- acdtab[acdnlun++] = tmpcdp;
- }
- if (acdnlun >= NUNIT) {
- printf("wcd: too many units\n");
- return 0;
- }
- }
- sprintf(string, "wcd%d-", cdp->lun);
- devstat_add_entry(cdp->device_stats, string, tmpcdp->lun, DEV_BSIZE,
- DEVSTAT_NO_ORDERED_TAGS,
- DEVSTAT_TYPE_CDROM | DEVSTAT_TYPE_IF_IDE,
- DEVSTAT_PRIORITY_CD);
- }
- else {
- acdnlun++;
- devstat_add_entry(cdp->device_stats, "wcd", cdp->lun, DEV_BSIZE,
- DEVSTAT_NO_ORDERED_TAGS,
- DEVSTAT_TYPE_CDROM | DEVSTAT_TYPE_IF_IDE,
- DEVSTAT_PRIORITY_CD);
- }
- return 1;
-}
-
-void
-acd_describe(struct acd *cdp)
-{
- int comma;
- char *mechanism;
-
- printf("wcd%d: drive speed ", cdp->lun);
- if (cdp->cap.cur_speed != cdp->cap.max_speed)
- printf("%d - ", cdp->cap.cur_speed * 1000 / 1024);
- printf("%dKB/sec", cdp->cap.max_speed * 1000 / 1024);
- if (cdp->cap.buf_size)
- printf(", %dKB cache\n", cdp->cap.buf_size);
-
- printf("wcd%d: supported read types:", cdp->lun);
- comma = 0;
- if (cdp->cap.read_cdr) {
- printf(" CD-R"); comma = 1;
- }
- if (cdp->cap.read_cdrw) {
- printf("%s CD-RW", comma ? "," : ""); comma = 1;
- }
- if (cdp->cap.cd_da) {
- printf("%s CD-DA", comma ? "," : ""); comma = 1;
- }
- if (cdp->cap.method2)
- printf("%s packet track", comma ? "," : "");
- if (cdp->cap.write_cdr || cdp->cap.write_cdrw) {
- printf("\nwcd%d: supported write types:", cdp->lun);
- comma = 0;
- if (cdp->cap.write_cdr) {
- printf(" CD-R" ); comma = 1;
- }
- if (cdp->cap.write_cdrw) {
- printf("%s CD-RW", comma ? "," : ""); comma = 1;
- }
- if (cdp->cap.test_write) {
- printf("%s test write", comma ? "," : ""); comma = 1;
- }
- }
- if (cdp->cap.audio_play) {
- printf("\nwcd%d: Audio: ", cdp->lun);
- if (cdp->cap.audio_play)
- printf("play");
- if (cdp->cap.max_vol_levels)
- printf(", %d volume levels", cdp->cap.max_vol_levels);
- }
- printf("\nwcd%d: Mechanism: ", cdp->lun);
- switch (cdp->cap.mech) {
- case MST_MECH_CADDY:
- mechanism = "caddy"; break;
- case MST_MECH_TRAY:
- mechanism = "tray"; break;
- case MST_MECH_POPUP:
- mechanism = "popup"; break;
- case MST_MECH_CHANGER:
- mechanism = "changer"; break;
- case MST_MECH_CARTRIDGE:
- mechanism = "cartridge"; break;
- default:
- mechanism = 0; break;
- }
- if (mechanism)
- printf("%s%s", cdp->cap.eject ? "ejectable " : "", mechanism);
- else if (cdp->cap.eject)
- printf("ejectable");
-
- if (cdp->cap.mech != MST_MECH_CHANGER) {
- printf("\nwcd%d: Medium: ", cdp->lun);
- switch (cdp->cap.medium_type & MST_TYPE_MASK_HIGH) {
- case MST_CDROM:
- printf("CD-ROM "); break;
- case MST_CDR:
- printf("CD-R "); break;
- case MST_CDRW:
- printf("CD-RW "); break;
- case MST_DOOR_OPEN:
- printf("door open"); break;
- case MST_NO_DISC:
- printf("no/blank disc inside"); break;
- case MST_FMT_ERROR:
- printf("medium format error"); break;
- }
- if ((cdp->cap.medium_type & MST_TYPE_MASK_HIGH) < MST_TYPE_MASK_HIGH) {
- switch (cdp->cap.medium_type & MST_TYPE_MASK_LOW) {
- case MST_DATA_120:
- printf("120mm data disc loaded"); break;
- case MST_AUDIO_120:
- printf("120mm audio disc loaded"); break;
- case MST_COMB_120:
- printf("120mm data/audio disc loaded"); break;
- case MST_PHOTO_120:
- printf("120mm photo disc loaded"); break;
- case MST_DATA_80:
- printf("80mm data disc loaded"); break;
- case MST_AUDIO_80:
- printf("80mm audio disc loaded"); break;
- case MST_COMB_80:
- printf("80mm data/audio disc loaded"); break;
- case MST_PHOTO_80:
- printf("80mm photo disc loaded"); break;
- case MST_FMT_NONE:
- switch (cdp->cap.medium_type & MST_TYPE_MASK_HIGH) {
- case MST_CDROM:
- printf("unknown medium"); break;
- case MST_CDR:
- case MST_CDRW:
- printf("blank medium"); break;
- }
- break;
- default:
- printf("unknown type=0x%x", cdp->cap.medium_type); break;
- }
- }
- }
- if (cdp->cap.lock)
- printf(cdp->cap.locked ? ", locked" : ", unlocked");
- if (cdp->cap.prevent)
- printf(", lock protected");
- printf("\n");
-}
-
-static int
-acdopen(dev_t dev, int flags, int fmt, struct proc *p)
-{
- int lun = dkunit(dev);
- struct acd *cdp;
-
- if (lun >= acdnlun || !atapi_request_immediate)
- return ENXIO;
- cdp = acdtab[lun];
-
- if (!(cdp->flags & F_BOPEN) && !cdp->refcnt) {
- /* Prevent user eject */
- acd_request_wait(cdp, ATAPI_PREVENT_ALLOW,
- 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0);
- cdp->flags |= F_LOCKED;
- }
- if (fmt == S_IFBLK)
- cdp->flags |= F_BOPEN;
- else
- ++cdp->refcnt;
- dev->si_bsize_phys = cdp->block_size;
- if (!(flags & O_NONBLOCK) && acd_read_toc(cdp) && !(flags & FWRITE))
- printf("acd%d: read_toc failed\n", lun);
- return 0;
-}
-
-int
-acdclose(dev_t dev, int flags, int fmt, struct proc *p)
-{
- struct acd *cdp = acdtab[dkunit(dev)];
-
- if (fmt == S_IFBLK)
- cdp->flags &= ~F_BOPEN;
- else
- --cdp->refcnt;
-
- /* Are we the last open ?? */
- if (!(cdp->flags & F_BOPEN) && !cdp->refcnt) {
- /* Yup, do we need to close any written tracks */
- if ((flags & FWRITE) != 0) {
- if ((cdp->flags & F_TRACK_PREPED) != 0) {
- acd_close_track(cdp);
- cdp->flags &= ~(F_TRACK_PREPED | F_TRACK_PREP);
- }
- }
- /* Allow the user eject */
- acd_request_wait(cdp, ATAPI_PREVENT_ALLOW,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
- }
- cdp->flags &= ~F_LOCKED;
- return 0;
-}
-
-void
-acdstrategy(struct buf *bp)
-{
- int lun = dkunit(bp->b_dev);
- struct acd *cdp = acdtab[lun];
- int x;
-
-#ifdef NOTYET
- /* allow write only on CD-R/RW media */ /* all for now SOS */
- if (!(bp->b_flags & B_READ) && !(writeable_media)) {
- bp->b_error = EROFS;
- bp->b_flags |= B_ERROR;
- biodone(bp);
- return;
- }
-#endif
-
- if (bp->b_bcount == 0) {
- bp->b_resid = 0;
- biodone(bp);
- return;
- }
-
- bp->b_pblkno = bp->b_blkno;
- bp->b_resid = bp->b_bcount;
-
- x = splbio();
- bufqdisksort(&cdp->buf_queue, bp);
- acd_start(cdp);
- splx(x);
-}
-
-static void
-acd_start(struct acd *cdp)
-{
- struct buf *bp = bufq_first(&cdp->buf_queue);
- u_long lba, blocks;
- int cmd;
- int count;
-
- if (!bp)
- return;
-
- bufq_remove(&cdp->buf_queue, bp);
-
- /* Should reject all queued entries if media have changed. */
- if (cdp->flags & F_MEDIA_CHANGED) {
- bp->b_error = EIO;
- bp->b_flags |= B_ERROR;
- biodone(bp);
- return;
- }
-
- acd_select_slot(cdp);
-
- if ((bp->b_flags & B_READ) == B_WRITE) {
- if ((cdp->flags & F_TRACK_PREPED) == 0) {
- if ((cdp->flags & F_TRACK_PREP) == 0) {
- printf("wcd%d: sequence error\n", cdp->lun);
- bp->b_error = EIO;
- bp->b_flags |= B_ERROR;
- biodone(bp);
- return;
- } else {
- if (acd_open_track(cdp, &cdp->preptrack) != 0) {
- biodone(bp);
- return;
- }
- cdp->flags |= F_TRACK_PREPED;
- }
- }
- }
-
- if (bp->b_flags & B_READ)
-#ifdef NOTYET
- lba = bp->b_offset / cdp->block_size;
-#else
- lba = bp->b_blkno / (cdp->block_size / DEV_BSIZE);
-#endif
- else
- lba = cdp->next_writeable_lba + (bp->b_offset / cdp->block_size);
- blocks = (bp->b_bcount + (cdp->block_size - 1)) / cdp->block_size;
-
- if ((bp->b_flags & B_READ) == B_WRITE) {
- cmd = ATAPI_WRITE_BIG;
- count = -bp->b_bcount;
- } else {
- cmd = ATAPI_READ_BIG;
- count = bp->b_bcount;
- }
-
- devstat_start_transaction(cdp->device_stats);
-
- atapi_request_callback(cdp->ata, cdp->unit, cmd, 0,
- lba>>24, lba>>16, lba>>8, lba, 0,
- blocks>>8, blocks, 0, 0, 0, 0, 0, 0, 0,
- (u_char *)bp->b_data, count,
- (atapi_callback_t *)acd_done, cdp, bp);
-}
-
-static void
-acd_done(struct acd *cdp, struct buf *bp, int resid, struct atapires result)
-{
-
- if (result.code) {
- atapi_error(cdp->ata, cdp->unit, result);
- bp->b_error = EIO;
- bp->b_flags |= B_ERROR;
- } else {
- bp->b_resid = resid;
- if ((bp->b_flags & B_READ) == B_WRITE)
- cdp->flags |= F_WRITTEN;
- }
- devstat_end_transaction_buf(cdp->device_stats, bp);
- biodone(bp);
- acd_start(cdp);
-}
-
-static int
-acd_request_wait(struct acd *cdp, u_char cmd, u_char a1, u_char a2,
- u_char a3, u_char a4, u_char a5, u_char a6, u_char a7, u_char a8,
- u_char a9, char *addr, int count)
-{
- struct atapires result;
-
- result = atapi_request_wait(cdp->ata, cdp->unit, cmd, a1, a2, a3, a4, a5,
- a6, a7, a8, a9, 0, 0, 0, 0, 0, 0, addr, count);
- if (result.code) {
- atapi_error(cdp->ata, cdp->unit, result);
- return EIO;
- }
- return 0;
-}
-
-static __inline void
-lba2msf(int lba, u_char *m, u_char *s, u_char *f)
-{
- lba += 150;
- lba &= 0xffffff;
- *m = lba / (60 * 75);
- lba %= (60 * 75);
- *s = lba / 75;
- *f = lba % 75;
-}
-
-static __inline int
-msf2lba(u_char m, u_char s, u_char f)
-{
- return (m * 60 + s) * 75 + f - 150;
-}
-
-int
-acdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
-{
- int lun = dkunit(dev);
- struct acd *cdp = acdtab[lun];
- int error = 0;
-
- if (cdp->flags & F_MEDIA_CHANGED)
- switch (cmd) {
- case CDIOCRESET:
- break;
- default:
- acd_read_toc(cdp);
- acd_request_wait(cdp, ATAPI_PREVENT_ALLOW,
- 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0);
- cdp->flags |= F_LOCKED;
- break;
- }
- switch (cmd) {
-/*
- case CDIOCRESUME:
- bzero(cdb);
- cdb->cmd = ATAPI_PAUSE;
- cdb->b8 = 0x01;
- return atapi_cmd_wait(cdp->ata, cdp->unit, cdb, 0, 0, timout, 0);
-*/
- case CDIOCRESUME:
- return acd_request_wait(cdp, ATAPI_PAUSE,
- 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0);
-
- case CDIOCPAUSE:
- return acd_request_wait(cdp, ATAPI_PAUSE,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
-
- case CDIOCSTART:
- return acd_request_wait(cdp, ATAPI_START_STOP,
- 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0);
-
- case CDIOCSTOP:
- return acd_request_wait(cdp, ATAPI_START_STOP,
- 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
-
- case CDIOCALLOW:
- acd_select_slot(cdp);
- cdp->flags &= ~F_LOCKED;
- return acd_request_wait(cdp, ATAPI_PREVENT_ALLOW,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
-
- case CDIOCPREVENT:
- acd_select_slot(cdp);
- cdp->flags |= F_LOCKED;
- return acd_request_wait(cdp, ATAPI_PREVENT_ALLOW,
- 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0);
-
- case CDIOCRESET:
- error = suser(p);
- if (error)
- return (error);
- return acd_request_wait(cdp, ATAPI_TEST_UNIT_READY,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
-
- case CDIOCEJECT:
- if ((cdp->flags & F_BOPEN) && cdp->refcnt)
- return EBUSY;
- return acd_eject(cdp, 0);
-
- case CDIOCCLOSE:
- if ((cdp->flags & F_BOPEN) && cdp->refcnt)
- return 0;
- return acd_eject(cdp, 1);
-
- case CDIOREADTOCHEADER:
- if (!cdp->toc.hdr.ending_track)
- return EIO;
- bcopy(&cdp->toc.hdr, addr, sizeof(cdp->toc.hdr));
- break;
-
- case CDIOREADTOCENTRYS:
- {
- struct ioc_read_toc_entry *te = (struct ioc_read_toc_entry *)addr;
- struct toc *toc = &cdp->toc;
- struct toc buf;
- u_long len;
- u_char starting_track = te->starting_track;
-
- if (!cdp->toc.hdr.ending_track)
- return EIO;
-
- if (te->data_len < sizeof(toc->tab[0]) ||
- (te->data_len % sizeof(toc->tab[0])) != 0 ||
- (te->address_format != CD_MSF_FORMAT &&
- te->address_format != CD_LBA_FORMAT))
- return EINVAL;
-
- if (!starting_track)
- starting_track = toc->hdr.starting_track;
- else if (starting_track == 170)
- starting_track = toc->hdr.ending_track + 1;
- else if (starting_track < toc->hdr.starting_track ||
- starting_track > toc->hdr.ending_track + 1)
- return EINVAL;
-
- len = ((toc->hdr.ending_track + 1 - starting_track) + 1) *
- sizeof(toc->tab[0]);
- if (te->data_len < len)
- len = te->data_len;
- if (len > sizeof(toc->tab))
- return EINVAL;
-
- if (te->address_format == CD_MSF_FORMAT) {
- struct cd_toc_entry *entry;
-
- buf = cdp->toc;
- toc = &buf;
- entry = toc->tab + (toc->hdr.ending_track + 1 -
- toc->hdr.starting_track) + 1;
- while (--entry >= toc->tab)
- lba2msf(ntohl(entry->addr.lba), &entry->addr.msf.minute,
- &entry->addr.msf.second, &entry->addr.msf.frame);
- }
- return copyout(toc->tab + starting_track - toc->hdr.starting_track,
- te->data, len);
- }
-
- case CDIOREADTOCENTRY:
- {
- struct ioc_read_toc_single_entry *te =
- (struct ioc_read_toc_single_entry *)addr;
- struct toc *toc = &cdp->toc;
- struct toc buf;
- u_char track = te->track;
-
- if (!cdp->toc.hdr.ending_track)
- return EIO;
-
- if (te->address_format != CD_MSF_FORMAT &&
- te->address_format != CD_LBA_FORMAT)
- return EINVAL;
-
- if (!track)
- track = toc->hdr.starting_track;
- else if (track == 170)
- track = toc->hdr.ending_track + 1;
- else if (track < toc->hdr.starting_track ||
- track > toc->hdr.ending_track + 1)
- return EINVAL;
-
- if (te->address_format == CD_MSF_FORMAT) {
- struct cd_toc_entry *entry;
-
- buf = cdp->toc;
- toc = &buf;
- entry = toc->tab + (track - toc->hdr.starting_track);
- lba2msf(ntohl(entry->addr.lba), &entry->addr.msf.minute,
- &entry->addr.msf.second, &entry->addr.msf.frame);
- }
- bcopy(toc->tab + track - toc->hdr.starting_track,
- &te->entry, sizeof(struct cd_toc_entry));
- }
- break;
-
- case CDIOCREADSUBCHANNEL:
- {
- struct ioc_read_subchannel *args =
- (struct ioc_read_subchannel *)addr;
- struct cd_sub_channel_info data;
- u_long len = args->data_len;
- int abslba, rellba;
-
- if (len > sizeof(data) ||
- len < sizeof(struct cd_sub_channel_header))
- return EINVAL;
-
- if (acd_request_wait(cdp, ATAPI_READ_SUBCHANNEL,
- 0, 0x40, 1, 0, 0, 0,
- sizeof(cdp->subchan)>>8, sizeof(cdp->subchan),
- 0,
- (char *)&cdp->subchan,
- sizeof(cdp->subchan)) != 0)
- return EIO;
- if (cdp->flags & F_DEBUG)
- atapi_dump(cdp->ata->ctrlr, cdp->lun, "subchan", &cdp->subchan,
- sizeof(cdp->subchan));
-
- abslba = cdp->subchan.abslba;
- rellba = cdp->subchan.rellba;
- if (args->address_format == CD_MSF_FORMAT) {
- lba2msf(ntohl(abslba),
- &data.what.position.absaddr.msf.minute,
- &data.what.position.absaddr.msf.second,
- &data.what.position.absaddr.msf.frame);
- lba2msf(ntohl(rellba),
- &data.what.position.reladdr.msf.minute,
- &data.what.position.reladdr.msf.second,
- &data.what.position.reladdr.msf.frame);
- } else {
- data.what.position.absaddr.lba = abslba;
- data.what.position.reladdr.lba = rellba;
- }
- data.header.audio_status = cdp->subchan.audio_status;
- data.what.position.control = cdp->subchan.control & 0xf;
- data.what.position.addr_type = cdp->subchan.control >> 4;
- data.what.position.track_number = cdp->subchan.track;
- data.what.position.index_number = cdp->subchan.indx;
- return copyout(&data, args->data, len);
- }
-
- case CDIOCPLAYMSF:
- {
- struct ioc_play_msf *args = (struct ioc_play_msf *)addr;
-
- return acd_request_wait(cdp, ATAPI_PLAY_MSF, 0, 0,
- args->start_m, args->start_s, args->start_f,
- args->end_m, args->end_s, args->end_f,
- 0, 0, 0);
- }
-
- case CDIOCPLAYBLOCKS:
- {
- struct ioc_play_blocks *args = (struct ioc_play_blocks *)addr;
-
- return acd_request_wait(cdp, ATAPI_PLAY_BIG, 0,
- args->blk>>24 & 0xff, args->blk>>16 & 0xff,
- args->blk>>8 & 0xff, args->blk & 0xff,
- args->len>>24 & 0xff, args->len>>16 & 0xff,
- args->len>>8 & 0xff, args->len & 0xff,
- 0, 0);
- }
-
- case CDIOCPLAYTRACKS:
- {
- struct ioc_play_track *args = (struct ioc_play_track *)addr;
- u_long start, len;
- int t1, t2;
-
- if (!cdp->toc.hdr.ending_track)
- return EIO;
-
- if (args->end_track < cdp->toc.hdr.ending_track + 1)
- ++args->end_track;
- if (args->end_track > cdp->toc.hdr.ending_track + 1)
- args->end_track = cdp->toc.hdr.ending_track + 1;
- t1 = args->start_track - cdp->toc.hdr.starting_track;
- t2 = args->end_track - cdp->toc.hdr.starting_track;
- if (t1 < 0 || t2 < 0)
- return EINVAL;
- start = ntohl(cdp->toc.tab[t1].addr.lba);
- len = ntohl(cdp->toc.tab[t2].addr.lba) - start;
-
- return acd_request_wait(cdp, ATAPI_PLAY_BIG, 0,
- start>>24 & 0xff, start>>16 & 0xff,
- start>>8 & 0xff, start & 0xff,
- len>>24 & 0xff, len>>16 & 0xff,
- len>>8 & 0xff, len & 0xff, 0, 0);
- }
-
- case CDIOCREADAUDIO:
- {
- struct ioc_read_audio* args = (struct ioc_read_audio*) addr;
- int lba, frames, result = 0;
- u_char *buffer, *ubuf = args->buffer;
-
- if (!cdp->toc.hdr.ending_track)
- return EIO;
-
- if ((frames = args->nframes) < 0)
- return EINVAL;
-
- if (args->address_format == CD_LBA_FORMAT)
- lba = args->address.lba;
- else if (args->address_format == CD_MSF_FORMAT)
- lba = msf2lba(args->address.msf.minute,
- args->address.msf.second,
- args->address.msf.frame);
- else
- return EINVAL;
-#ifndef CD_BUFFER_BLOCKS
-#define CD_BUFFER_BLOCKS 8
-#endif
- if (!(buffer = malloc(CD_BUFFER_BLOCKS * 2352, M_TEMP, M_NOWAIT)))
- return ENOMEM;
-
- while (frames > 0) {
- u_char blocks;
- int size;
-
- blocks = (frames>CD_BUFFER_BLOCKS) ? CD_BUFFER_BLOCKS : frames;
- size = blocks * 2352;
-
- result = acd_request_wait(cdp, ATAPI_READ_CD, 4,
- lba>>24, (lba>>16)&0xff,
- (lba>>8)&0xff, lba&0xff, 0, 0,
- blocks, 0xf0, buffer, size);
- if (result != 0)
- break;
-
- result = copyout(buffer, ubuf, size);
- if (result != 0)
- break;
-
- ubuf += size;
- frames -= blocks;
- lba += blocks;
- }
-
- free(buffer, M_TEMP);
- return result;
- }
-
- case CDIOCGETVOL:
- {
- struct ioc_vol *arg = (struct ioc_vol *)addr;
-
- error = acd_request_wait(cdp, ATAPI_MODE_SENSE, 0, CDROM_AUDIO_PAGE,
- 0, 0, 0, 0,
- sizeof(cdp->au)>>8, sizeof(cdp->au), 0,
- (char *)&cdp->au, sizeof(cdp->au));
- if (error)
- return error;
- if (cdp->flags & F_DEBUG)
- atapi_dump(cdp->ata->ctrlr, cdp->lun, "au", &cdp->au,
- sizeof(cdp->au));
- if (cdp->au.page_code != CDROM_AUDIO_PAGE)
- return EIO;
- arg->vol[0] = cdp->au.port[0].volume;
- arg->vol[1] = cdp->au.port[1].volume;
- arg->vol[2] = cdp->au.port[2].volume;
- arg->vol[3] = cdp->au.port[3].volume;
- }
- break;
-
- case CDIOCSETVOL:
- {
- struct ioc_vol *arg = (struct ioc_vol *)addr;
-
- error = acd_request_wait(cdp, ATAPI_MODE_SENSE, 0, CDROM_AUDIO_PAGE,
- 0, 0, 0, 0,
- sizeof(cdp->au)>>8, sizeof(cdp->au), 0,
- (char *)&cdp->au, sizeof(cdp->au));
- if (error)
- return error;
- if (cdp->flags & F_DEBUG)
- atapi_dump(cdp->ata->ctrlr, cdp->lun, "au", &cdp->au,
- sizeof(cdp->au));
- if (cdp->au.page_code != CDROM_AUDIO_PAGE)
- return EIO;
-
- error = acd_request_wait(cdp, ATAPI_MODE_SENSE, 0,
- CDROM_AUDIO_PAGE_MASK, 0, 0, 0, 0,
- sizeof(cdp->aumask)>>8,sizeof(cdp->aumask),
- 0,
- (char *)&cdp->aumask, sizeof(cdp->aumask));
- if (error)
- return error;
- if (cdp->flags & F_DEBUG)
- atapi_dump(cdp->ata->ctrlr, cdp->lun, "mask", &cdp->aumask,
- sizeof(cdp->aumask));
-
- cdp->au.data_length = 0;
- cdp->au.port[0].channels = CHANNEL_0;
- cdp->au.port[1].channels = CHANNEL_1;
- cdp->au.port[0].volume = arg->vol[0] & cdp->aumask.port[0].volume;
- cdp->au.port[1].volume = arg->vol[1] & cdp->aumask.port[1].volume;
- cdp->au.port[2].volume = arg->vol[2] & cdp->aumask.port[2].volume;
- cdp->au.port[3].volume = arg->vol[3] & cdp->aumask.port[3].volume;
- return acd_request_wait(cdp, ATAPI_MODE_SELECT, 0x10,
- 0, 0, 0, 0, 0,
- sizeof(cdp->au)>>8, sizeof(cdp->au),
- 0, (char *)&cdp->au, -sizeof(cdp->au));
- }
-
- case CDIOCSETPATCH:
- {
- struct ioc_patch *arg = (struct ioc_patch *)addr;
-
- return acd_setchan(cdp, arg->patch[0], arg->patch[1],
- arg->patch[2], arg->patch[3]);
- }
-
- case CDIOCSETMONO:
- return acd_setchan(cdp, CHANNEL_0|CHANNEL_1, CHANNEL_0|CHANNEL_1, 0, 0);
-
- case CDIOCSETSTEREO:
- return acd_setchan(cdp, CHANNEL_0, CHANNEL_1, 0, 0);
-
- case CDIOCSETMUTE:
- return acd_setchan(cdp, 0, 0, 0, 0);
-
- case CDIOCSETLEFT:
- return acd_setchan(cdp, CHANNEL_0, CHANNEL_0, 0, 0);
-
- case CDIOCSETRIGHT:
- return acd_setchan(cdp, CHANNEL_1, CHANNEL_1, 0, 0);
-
- case CDRIOCNEXTWRITEABLEADDR:
- {
- struct acd_track_info track_info;
-
- if ((error = acd_read_track_info(cdp, 0xff, &track_info)))
- break;
- if (!track_info.nwa_valid)
- return EINVAL;
- cdp->next_writeable_lba = track_info.next_writeable_addr;
- *(int*)addr = track_info.next_writeable_addr;
- }
- break;
-
- case WORMIOCPREPDISK:
- {
- struct wormio_prepare_disk *w = (struct wormio_prepare_disk *)addr;
-
- if (w->dummy != 0 && w->dummy != 1)
- error = EINVAL;
- else {
- error = acd_open_disk(cdp, w->dummy);
- if (error == 0) {
- cdp->flags |= F_DISK_PREPED;
- cdp->dummy = w->dummy;
- cdp->speed = w->speed;
- }
- }
- }
- break;
-
- case WORMIOCPREPTRACK:
- {
- struct wormio_prepare_track *w =(struct wormio_prepare_track *)addr;
-
- if (w->audio != 0 && w->audio != 1)
- error = EINVAL;
- else if (w->audio == 0 && w->preemp)
- error = EINVAL;
- else if ((cdp->flags & F_DISK_PREPED) == 0) {
- error = EINVAL;
- printf("wcd%d: sequence error (PREP_TRACK)\n", cdp->lun);
- } else {
- cdp->flags |= F_TRACK_PREP;
- cdp->preptrack = *w;
- }
- }
- break;
-
- case WORMIOCFINISHTRACK:
- if ((cdp->flags & F_TRACK_PREPED) != 0)
- error = acd_close_track(cdp);
- cdp->flags &= ~(F_TRACK_PREPED | F_TRACK_PREP);
- break;
-
- case WORMIOCFIXATION:
- {
- struct wormio_fixation *w =
- (struct wormio_fixation *)addr;
-
- if ((cdp->flags & F_WRITTEN) == 0)
- error = EINVAL;
- else if (w->toc_type < 0 /* WORM_TOC_TYPE_AUDIO */ ||
- w->toc_type > 4 /* WORM_TOC_TYPE_CDI */ )
- error = EINVAL;
- else if (w->onp != 0 && w->onp != 1)
- error = EINVAL;
- else {
- /* no fixation needed if dummy write */
- if (cdp->dummy == 0)
- error = acd_close_disk(cdp);
- cdp->flags &=
- ~(F_WRITTEN|F_DISK_PREPED|F_TRACK_PREP|F_TRACK_PREPED);
- }
- }
- break;
-
- case CDRIOCBLANK:
- return acd_blank_disk(cdp);
-
- default:
- return ENOTTY;
- }
- return error;
-}
-
-static int
-acd_read_toc(struct acd *cdp)
-{
- int ntracks, len;
- struct atapires result;
-
- bzero(&cdp->toc, sizeof(cdp->toc));
- bzero(&cdp->info, sizeof(cdp->info));
-
- acd_select_slot(cdp);
-
- result = atapi_request_wait(cdp->ata, cdp->unit, ATAPI_TEST_UNIT_READY,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0);
-
- if (result.code == RES_ERR &&
- (result.error & AER_SKEY) == AER_SK_UNIT_ATTENTION) {
- cdp->flags |= F_MEDIA_CHANGED;
- cdp->flags &= ~(F_WRITTEN|F_TRACK_PREP|F_TRACK_PREPED);
- result = atapi_request_wait(cdp->ata, cdp->unit, ATAPI_TEST_UNIT_READY,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0);
- }
-
- if (result.code) {
- atapi_error(cdp->ata, cdp->unit, result);
- return EIO;
- }
-
- cdp->flags &= ~F_MEDIA_CHANGED;
-
- len = sizeof(struct ioc_toc_header) + sizeof(struct cd_toc_entry);
- if (acd_request_wait(cdp, ATAPI_READ_TOC, 0, 0, 0, 0, 0, 0,
- len>>8, len & 0xff, 0, (char *)&cdp->toc, len) != 0) {
- bzero(&cdp->toc, sizeof(cdp->toc));
- return 0;
- }
- ntracks = cdp->toc.hdr.ending_track - cdp->toc.hdr.starting_track + 1;
- if (ntracks <= 0 || ntracks > MAXTRK) {
- bzero(&cdp->toc, sizeof(cdp->toc));
- return 0;
- }
-
- len = sizeof(struct ioc_toc_header) + ntracks * sizeof(struct cd_toc_entry);
- if (acd_request_wait(cdp, ATAPI_READ_TOC, 0, 0, 0, 0, 0, 0,
- len>>8, len & 0xff, 0, (char *)&cdp->toc, len) & 0xff){
- bzero(&cdp->toc, sizeof(cdp->toc));
- return 0;
- }
-
- cdp->toc.hdr.len = ntohs(cdp->toc.hdr.len);
-
- if (acd_request_wait(cdp, ATAPI_READ_CAPACITY, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- (char *)&cdp->info, sizeof(cdp->info)) != 0)
- bzero(&cdp->info, sizeof(cdp->info));
-
- cdp->toc.tab[ntracks].control = cdp->toc.tab[ntracks - 1].control;
- cdp->toc.tab[ntracks].addr_type = cdp->toc.tab[ntracks - 1].addr_type;
- cdp->toc.tab[ntracks].track = 170;
- cdp->toc.tab[ntracks].addr.lba = cdp->info.volsize;
-
- cdp->info.volsize = ntohl(cdp->info.volsize);
- cdp->info.blksize = ntohl(cdp->info.blksize);
-
- if (cdp->info.volsize && cdp->toc.hdr.ending_track
- && (cdp->flags & F_DEBUG)) {
- printf("wcd%d: ", cdp->lun);
- if (cdp->toc.tab[0].control & 4)
- printf("%ldMB ", cdp->info.volsize / 512);
- else
- printf("%ld:%ld audio ", cdp->info.volsize / 75 / 60,
- cdp->info.volsize / 75 % 60);
- printf("(%ld sectors (%ld bytes)), %d tracks\n",
- cdp->info.volsize, cdp->info.blksize,
- cdp->toc.hdr.ending_track - cdp->toc.hdr.starting_track + 1);
- }
- return 0;
-}
-
-/*
- * Set up the audio channel masks.
- */
-static int
-acd_setchan(struct acd *cdp, u_char c0, u_char c1, u_char c2, u_char c3)
-{
- int error;
-
- error = acd_request_wait(cdp, ATAPI_MODE_SENSE, 0, CDROM_AUDIO_PAGE,
- 0, 0, 0, 0,
- sizeof(cdp->au)>>8, sizeof(cdp->au), 0,
- (char *)&cdp->au, sizeof(cdp->au));
- if (error)
- return error;
- if (cdp->flags & F_DEBUG)
- atapi_dump(cdp->ata->ctrlr, cdp->lun, "au", &cdp->au, sizeof(cdp->au));
- if (cdp->au.page_code != CDROM_AUDIO_PAGE)
- return EIO;
-
- cdp->au.data_length = 0;
- cdp->au.port[0].channels = c0;
- cdp->au.port[1].channels = c1;
- cdp->au.port[2].channels = c2;
- cdp->au.port[3].channels = c3;
- return acd_request_wait(cdp, ATAPI_MODE_SELECT, 0x10,
- 0, 0, 0, 0, 0,
- sizeof(cdp->au)>>8, sizeof(cdp->au), 0,
- (char *)&cdp->au, -sizeof(cdp->au));
-}
-
-static int
-acd_eject(struct acd *cdp, int close)
-{
- struct atapires result;
-
- acd_select_slot(cdp);
-
- result = atapi_request_wait(cdp->ata, cdp->unit, ATAPI_START_STOP, 1,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
-
- if (result.code == RES_ERR &&
- ((result.error & AER_SKEY) == AER_SK_NOT_READY ||
- (result.error & AER_SKEY) == AER_SK_UNIT_ATTENTION)) {
- int err;
-
- if (!close)
- return 0;
- err = acd_request_wait(cdp, ATAPI_START_STOP, 0, 0, 0, 3,
- 0, 0, 0, 0, 0, 0, 0);
- if (err)
- return err;
-
- acd_read_toc(cdp);
-
- acd_request_wait(cdp, ATAPI_PREVENT_ALLOW, 0, 0, 0, 1,
- 0, 0, 0, 0, 0, 0, 0);
- cdp->flags |= F_LOCKED;
- return 0;
- }
- if (result.code) {
- atapi_error(cdp->ata, cdp->unit, result);
- return EIO;
- }
- if (close)
- return 0;
-
- tsleep((caddr_t) &lbolt, PRIBIO, "wcdej1", 0);
- tsleep((caddr_t) &lbolt, PRIBIO, "wcdej2", 0);
-
- acd_request_wait(cdp, ATAPI_PREVENT_ALLOW, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
- cdp->flags &= ~F_LOCKED;
-
- cdp->flags |= F_MEDIA_CHANGED;
- cdp->flags &= ~(F_WRITTEN|F_TRACK_PREP|F_TRACK_PREPED);
- return acd_request_wait(cdp, ATAPI_START_STOP, 0, 0, 0, 2,
- 0, 0, 0, 0, 0, 0, 0);
-}
-
-static void
-acd_select_slot(struct acd *cdp)
-{
- if (cdp->slot < 0 || cdp->changer_info->current_slot == cdp->slot)
- return;
-
- /* Unlock (might not be needed but its cheaper than asking) */
- acd_request_wait(cdp, ATAPI_PREVENT_ALLOW, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
-
- /* Unload the current media from player */
- acd_request_wait(cdp, ATAPI_LOAD_UNLOAD, 0, 0, 0, 2,
- 0, 0, 0, cdp->changer_info->current_slot, 0, 0, 0);
-
- /* load the wanted slot */
- acd_request_wait(cdp, ATAPI_LOAD_UNLOAD, 0, 0, 0, 3,
- 0, 0, 0, cdp->slot, 0, 0, 0);
-
- cdp->changer_info->current_slot = cdp->slot;
-
- /* Lock the media if needed */
- if (cdp->flags & F_LOCKED) {
- acd_request_wait(cdp, ATAPI_PREVENT_ALLOW, 0, 0, 0, 1,
- 0, 0, 0, 0, 0, 0, 0);
- }
-}
-
-static int
-acd_open_disk(struct acd *cdp, int test)
-{
- cdp->next_writeable_lba = 0;
- return 0;
-}
-
-static int
-acd_close_disk(struct acd *cdp)
-{
- return acd_request_wait(cdp, ATAPI_CLOSE_TRACK, 0x00,
- 0x02, 0, 0, 0/*track*/, 0, 0, 0, 0, 0, 0);
-}
-
-static int
-acd_open_track(struct acd *cdp, struct wormio_prepare_track *ptp)
-{
- struct write_param param;
- struct atapires result;
-
- result = atapi_request_wait(cdp->ata, cdp->unit, ATAPI_MODE_SENSE,
- 0, 0x05, 0, 0, 0, 0,
- sizeof(param)>>8, sizeof(param),
- 0, 0, 0, 0, 0, 0, 0,
- (char *)&param, sizeof(param));
-
- if (cdp->flags & F_DEBUG)
- atapi_dump(cdp->ata->ctrlr, cdp->lun, "0x05", &param, sizeof(param));
-
- if (result.code == RES_UNDERRUN)
- result.code = 0;
-
- if (result.code) {
- atapi_error(cdp->ata, cdp->unit, result);
- return EIO;
- }
- param.page_code = 0x05;
- param.page_length = 0x32;
- param.test_write = cdp->dummy ? 1 : 0;
- param.write_type = CDR_WTYPE_TRACK;
-
- switch (ptp->audio) {
-/* switch (data_type) { */
-
- case 0:
-/* case CDR_DATA: */
- cdp->block_size = 2048;
- param.track_mode = CDR_TMODE_DATA;
- param.data_block_type = CDR_DB_ROM_MODE1;
- param.session_format = CDR_SESS_CDROM;
- break;
-
- default:
-/* case CDR_AUDIO: */
- cdp->block_size = 2352;
- if (ptp->preemp)
- param.track_mode = CDR_TMODE_AUDIO;
- else
- param.track_mode = 0;
- param.data_block_type = CDR_DB_RAW;
- param.session_format = CDR_SESS_CDROM;
- break;
-
-/*
- case CDR_MODE2:
- param.track_mode = CDR_TMODE_DATA;
- param.data_block_type = CDR_DB_ROM_MODE2;
- param.session_format = CDR_SESS_CDROM;
- break;
-
- case CDR_XA1:
- param.track_mode = CDR_TMODE_DATA;
- param.data_block_type = CDR_DB_XA_MODE1;
- param.session_format = CDR_SESS_CDROM_XA;
- break;
-
- case CDR_XA2:
- param.track_mode = CDR_TMODE_DATA;
- param.data_block_type = CDR_DB_XA_MODE2_F1;
- param.session_format = CDR_SESS_CDROM_XA;
- break;
-
- case CDR_CDI:
- param.track_mode = CDR_TMODE_DATA;
- param.data_block_type = CDR_DB_XA_MODE2_F1;
- param.session_format = CDR_SESS_CDI;
- break;
-*/
- }
-
- param.multi_session = CDR_MSES_NONE;
- param.fp = 0;
- param.packet_size = 0;
-
- if (cdp->flags & F_DEBUG)
- atapi_dump(cdp->ata->ctrlr, cdp->lun, "0x05", &param, sizeof(param));
-
- result = atapi_request_wait(cdp->ata, cdp->unit, ATAPI_MODE_SELECT,
- 0x10, 0, 0, 0, 0, 0,
- sizeof(param)>>8, sizeof(param),
- 0, 0, 0, 0, 0, 0, 0,
- (char *)&param, -sizeof(param));
-
- if (result.code == RES_UNDERRUN)
- result.code = 0;
-
- if (result.code) {
- atapi_error(cdp->ata, cdp->unit, result);
- return EIO;
- }
- return 0;
-}
-
-static int
-acd_close_track(struct acd *cdp)
-{
- return acd_request_wait(cdp, ATAPI_SYNCHRONIZE_CACHE, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
-}
-
-static int
-acd_read_track_info(struct acd *cdp, int lba, struct acd_track_info *info)
-{
- int error;
-
- error = acd_request_wait(cdp, ATAPI_READ_TRACK_INFO, 0x01,
- lba>>24, (lba>>16)&0xff,
- (lba>>8)&0xff, lba&0xff,
- 0,
- sizeof(*info)>>8, sizeof(*info), 0,
- (char *)info, sizeof(*info));
- if (error)
- return error;
- info->track_start_addr = ntohl(info->track_start_addr);
- info->next_writeable_addr = ntohl(info->next_writeable_addr);
- info->free_blocks = ntohl(info->free_blocks);
- info->fixed_packet_size = ntohl(info->fixed_packet_size);
- info->track_length = ntohl(info->track_length);
- return 0;
-}
-
-static int
-acd_blank_disk(struct acd *cdp)
-{
- int error;
-
- error = acd_request_wait(cdp, 0xa1, 0x01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
- cdp->flags |= F_MEDIA_CHANGED;
- cdp->flags &= ~(F_WRITTEN|F_TRACK_PREP|F_TRACK_PREPED);
- return error;
-}
-
-static void
-atapi_error(struct atapi *ata, int unit, struct atapires result)
-{
- if (result.code != RES_ERR) {
- printf("atapi%d:%d: ERROR %d, status=%b, error=%b\n",
- ata->ctrlr, unit, result.code, result.status,
- ARS_BITS, result.error, AER_BITS);
- return;
- }
- switch (result.error & AER_SKEY) {
- case AER_SK_NOT_READY:
- if (ata->debug)
- printf("atapi%d:%d: not ready\n", ata->ctrlr, unit);
- break;
-
- case AER_SK_BLANK_CHECK:
- if (ata->debug)
- printf("atapi%d:%d: blank check\n", ata->ctrlr, unit);
- break;
-
- case AER_SK_MEDIUM_ERROR:
- if (ata->debug)
- printf("atapi%d:%d: medium error\n", ata->ctrlr, unit);
- break;
-
- case AER_SK_HARDWARE_ERROR:
- if (ata->debug)
- printf("atapi%d:%d: hardware error\n", ata->ctrlr, unit);
- break;
-
- case AER_SK_ILLEGAL_REQUEST:
- if (ata->debug)
- printf("atapi%d:%d: illegal request\n", ata->ctrlr, unit);
- break;
-
- case AER_SK_UNIT_ATTENTION:
- if (ata->debug)
- printf("atapi%d:%d: unit attention\n", ata->ctrlr, unit);
- break;
-
- case AER_SK_DATA_PROTECT:
- if (ata->debug)
- printf("atapi%d:%d: reading protected data\n", ata->ctrlr, unit);
- break;
-
- case AER_SK_ABORTED_COMMAND:
- if (ata->debug)
- printf("atapi%d:%d: command aborted\n", ata->ctrlr, unit);
- break;
-
- case AER_SK_MISCOMPARE:
- if (ata->debug)
- printf("atapi%d:%d: data don't match medium\n", ata->ctrlr, unit);
- break;
-
- default:
- if (ata->debug)
- printf("atapi%d:%d: unknown error, status=%b, error=%b\n",
- ata->ctrlr, unit, result.status, ARS_BITS,
- result.error, AER_BITS);
- }
-}
-
-static void
-atapi_dump(int ctrlr, int lun, char *label, void *data, int len)
-{
- u_char *p = data;
-
- printf ("atapi%d%d: %s %x", ctrlr, lun, label, *p++);
- while (--len > 0) printf ("-%x", *p++);
- printf ("\n");
-}
-
-static void
-acd_drvinit(void *unused)
-{
- cdevsw_add(&acd_cdevsw);
-}
-
-SYSINIT(acddev, SI_SUB_DRIVERS, SI_ORDER_MIDDLE + CDEV_MAJOR, acd_drvinit, NULL)
diff --git a/sys/pc98/pc98/wfd.c b/sys/pc98/pc98/wfd.c
deleted file mode 100644
index f8d9e604b065..000000000000
--- a/sys/pc98/pc98/wfd.c
+++ /dev/null
@@ -1,727 +0,0 @@
-/*
- * Copyright (c) 1997,1998 Junichi Satoh <junichi@astec.co.jp>
- * 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 as
- * the first lines of this file unmodified.
- * 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 Junichi Satoh ``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 Junichi Satoh 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.
- *
- * $FreeBSD$
- */
-
-/*
- * ATAPI Floppy, LS-120 driver
- */
-
-#include "wdc.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/conf.h>
-#include <sys/proc.h>
-#include <sys/malloc.h>
-#include <sys/buf.h>
-#include <sys/devicestat.h>
-#include <sys/disklabel.h>
-#include <sys/diskslice.h>
-#include <sys/cdio.h>
-
-#include <i386/isa/atapi.h>
-
-static d_open_t wfdopen;
-static d_close_t wfdclose;
-static d_ioctl_t wfdioctl;
-static d_strategy_t wfdstrategy;
-
-#define CDEV_MAJOR 87
-#define BDEV_MAJOR 1
-
-static struct cdevsw wfd_cdevsw = {
- /* open */ wfdopen,
- /* close */ wfdclose,
- /* read */ physread,
- /* write */ physwrite,
- /* ioctl */ wfdioctl,
- /* poll */ nopoll,
- /* mmap */ nommap,
- /* strategy */ wfdstrategy,
- /* name */ "wfd",
- /* maj */ CDEV_MAJOR,
- /* dump */ nodump,
- /* psize */ nopsize,
- /* flags */ D_DISK,
- /* bmaj */ BDEV_MAJOR
-};
-
-int wfdattach(struct atapi*, int, struct atapi_params*, int);
-
-#define NUNIT (NWDC*2) /* Max. number of devices */
-#define UNIT(d) ((minor(d) >> 3) & 3) /* Unit part of minor device number */
-
-#define F_BOPEN 0x0001 /* The block device is opened */
-#define F_MEDIA_CHANGED 0x0002 /* The media have changed since open */
-#define F_DEBUG 0x0004 /* Print debug info */
-
-/*
- * LS-120 Capabilities and Mechanical Status Page
- */
-struct cappage {
- /* Mode data header */
- u_short data_length;
- u_char medium_type;
-#define MDT_UNKNOWN 0x00
-#define MDT_NO_DISC 0x70
-#define MDT_DOOR_OPEN 0x71
-#define MDT_FMT_ERROR 0x72
-
-#define MDT_2DD_UN 0x10
-#define MDT_2DD 0x11
-#define MDT_2HD_UN 0x20
-#define MDT_2HD_12_98 0x22
-#define MDT_2HD_12 0x23
-#define MDT_2HD_144 0x24
-#define MDT_LS120 0x31
-
- unsigned reserved0 :7;
- unsigned wp :1; /* Write protect */
- u_char reserved1[4];
-
- /* Capabilities page */
- unsigned page_code :6; /* Page code - Should be 0x5 */
-#define CAP_PAGE 0x05
- unsigned reserved1_6 :1; /* Reserved */
- unsigned ps :1; /* The device is capable of saving the page */
- u_char page_length; /* Page Length - Should be 0x1e */
- u_short transfer_rate; /* In kilobits per second */
- u_char heads, sectors; /* Number of heads, Number of sectors per track */
- u_short sector_size; /* Byes per sector */
- u_short cyls; /* Number of cylinders */
- u_char reserved10[10];
- u_char motor_delay; /* Motor off delay */
- u_char reserved21[7];
- u_short rpm; /* Rotations per minute */
- u_char reserved30[2];
-};
-
-struct wfd {
- struct atapi *ata; /* Controller structure */
- int unit; /* IDE bus drive unit */
- int lun; /* Logical device unit */
- int flags; /* Device state flags */
- int refcnt; /* The number of raw opens */
- int maxblks; /* transfer size limit */
- struct buf_queue_head buf_queue; /* Queue of i/o requests */
- struct atapi_params *param; /* Drive parameters table */
- struct cappage cap; /* Capabilities page info */
- char description[80]; /* Device description */
- struct diskslices *dk_slices; /* virtual drives */
-
- struct devstat device_stats;
-};
-
-static struct wfd *wfdtab[NUNIT]; /* Drive info by unit number */
-static int wfdnlun = 0; /* Number of configured drives */
-
-static void wfd_start (struct wfd *t);
-static void wfd_done (struct wfd *t, struct buf *bp, int resid,
- struct atapires result);
-static void wfd_error (struct wfd *t, struct atapires result);
-static int wfd_request_wait (struct wfd *t, u_char cmd, u_char a1, u_char a2,
- u_char a3, u_char a4, u_char a5, u_char a6, u_char a7, u_char a8,
- u_char a9, char *addr, int count);
-static void wfd_describe (struct wfd *t);
-static int wfd_eject (struct wfd *t, int closeit);
-
-/*
- * Dump the array in hexadecimal format for debugging purposes.
- */
-static void wfd_dump (int lun, char *label, void *data, int len)
-{
- u_char *p = data;
-
- printf ("wfd%d: %s %x", lun, label, *p++);
- while (--len > 0)
- printf ("-%x", *p++);
- printf ("\n");
-}
-
-int
-wfdattach (struct atapi *ata, int unit, struct atapi_params *ap, int debug)
-{
- struct wfd *t;
- struct atapires result;
- int lun, i;
-
- if (wfdnlun >= NUNIT) {
- printf ("wfd: too many units\n");
- return (0);
- }
- if (!atapi_request_immediate) {
- printf("wfd: configuration error, ATAPI core code not present!\n");
- printf("wfd: check `options ATAPI_STATIC' in your kernel config file!\n");
- return (0);
- }
- t = malloc (sizeof (struct wfd), M_TEMP, M_NOWAIT);
- if (! t) {
- printf ("wfd: out of memory\n");
- return (0);
- }
- wfdtab[wfdnlun] = t;
- bzero (t, sizeof (struct wfd));
- bufq_init(&t->buf_queue);
- t->ata = ata;
- t->unit = unit;
- lun = t->lun = wfdnlun;
- t->param = ap;
- t->flags = F_MEDIA_CHANGED;
- t->refcnt = 0;
- if (debug) {
- t->flags |= F_DEBUG;
- /* Print params. */
- wfd_dump (t->lun, "info", ap, sizeof *ap);
- }
-
- /* Get drive capabilities. */
- /* Do it twice to avoid the stale media changed state. */
- for (i = 0; i < 2; i++) {
- result = atapi_request_immediate (ata, unit, ATAPI_MODE_SENSE,
- 0, CAP_PAGE, 0, 0, 0, 0,
- sizeof (t->cap) >> 8, sizeof (t->cap),
- 0, 0, 0, 0, 0, 0, 0, (char*) &t->cap, sizeof (t->cap));
- }
-
- if (result.code == RES_ERR &&
- (result.error & AER_SKEY) == AER_SK_UNIT_ATTENTION)
- result = atapi_request_immediate (ata, unit, ATAPI_MODE_SENSE,
- 0, CAP_PAGE, 0, 0, 0, 0, sizeof (t->cap) >> 8,
- sizeof (t->cap), 0, 0, 0, 0, 0, 0, 0,
- (char*) &t->cap, sizeof (t->cap));
-
- /* Some drives have shorter capabilities page. */
- if (result.code == RES_UNDERRUN)
- result.code = 0;
-
- if (result.code == 0) {
- wfd_describe (t);
- if (t->flags & F_DEBUG)
- wfd_dump (t->lun, "cap", &t->cap, sizeof t->cap);
- } else
- return -1;
-
- /*
- * The IOMEGA ZIP 100, at firmware 21.* and 23.* at least
- * is known to lock up if transfers > 64 blocks are
- * requested.
- */
- if (!strcmp(ap->model, "IOMEGA ZIP 100 ATAPI")) {
- printf("wfd%d: buggy Zip drive, 64-block transfer limit set\n",
- t->lun);
- t->maxblks = 64;
- } else {
- t->maxblks = 0; /* no limit */
- }
-
-
-
- make_dev(&wfd_cdevsw, dkmakeminor(t->lun, WHOLE_DISK_SLICE, RAW_PART),
- UID_ROOT, GID_OPERATOR, 0640, "rwfd%d", t->lun);
-
- /*
- * Export the drive to the devstat interface.
- */
- devstat_add_entry(&t->device_stats, "wfd",
- t->lun, t->cap.sector_size,
- DEVSTAT_NO_ORDERED_TAGS,
- DEVSTAT_TYPE_FLOPPY | DEVSTAT_TYPE_IF_IDE,
- DEVSTAT_PRIORITY_WFD);
- wfdnlun++;
- return (1);
-}
-
-void wfd_describe (struct wfd *t)
-{
- int no_print = 0;
-
- t->cap.cyls = ntohs (t->cap.cyls);
- t->cap.sector_size = ntohs (t->cap.sector_size);
-
- printf ("wfd%d: ", t->lun);
- switch (t->cap.medium_type) {
- case MDT_UNKNOWN:
- printf ("medium type unknown (no disk)");
- no_print = 1;
- break;
- case MDT_2DD_UN:
- printf ("2DD(capacity unknown) floppy disk loaded");
- no_print = 1;
- break;
- case MDT_2DD:
- printf ("720KB floppy disk loaded");
- break;
- case MDT_2HD_UN:
- printf ("2HD(capacity unknown) floppy disk loaded");
- no_print = 1;
- break;
- case MDT_2HD_12_98:
- printf ("1.25MB(PC-9801 format) floppy disk loaded");
- break;
- case MDT_2HD_12:
- printf ("1.2MB floppy disk loaded");
- break;
- case MDT_2HD_144:
- printf ("1.44MB floppy disk loaded");
- break;
- case MDT_LS120:
- printf ("120MB floppy disk loaded");
- break;
- case MDT_NO_DISC:
- printf ("no disc inside");
- no_print = 1;
- break;
- case MDT_DOOR_OPEN:
- printf ("door open");
- no_print = 1;
- break;
- case MDT_FMT_ERROR:
- printf ("medium format error");
- no_print = 1;
- break;
- default:
- printf ("medium type=0x%x", t->cap.medium_type);
- break;
- }
- if (t->cap.wp)
- printf(", write protected");
- printf ("\n");
-
- if (!no_print) {
- printf ("wfd%d: ", t->lun);
- printf ("%u cyls", t->cap.cyls);
- printf (", %u heads, %u S/T", t->cap.heads, t->cap.sectors);
- printf (", %u B/S", t->cap.sector_size);
- printf ("\n");
- }
-}
-
-int wfdopen (dev_t dev, int flags, int fmt, struct proc *p)
-{
- int lun = UNIT(dev);
- struct wfd *t;
- struct atapires result;
- int errcode = 0;
- struct disklabel label;
-
- /* Check that the device number is legal
- * and the ATAPI driver is loaded. */
- if (lun >= wfdnlun || ! atapi_request_immediate)
- return (ENXIO);
- t = wfdtab[lun];
-
- t->flags &= ~F_MEDIA_CHANGED;
- /* Lock the media. */
- wfd_request_wait (t, ATAPI_PREVENT_ALLOW,
- 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0);
-
- /* Sense the media type */
- result = atapi_request_wait (t->ata, t->unit, ATAPI_MODE_SENSE,
- 0, CAP_PAGE, 0, 0, 0, 0,
- sizeof (t->cap) >> 8, sizeof (t->cap),
- 0, 0, 0, 0, 0, 0, 0,
- (char*) &t->cap, sizeof (t->cap));
- if (result.code)
- printf ("wfd%d: Sense the media type is failed.\n", t->lun);
- else {
- t->cap.cyls = ntohs (t->cap.cyls);
- t->cap.sector_size = ntohs (t->cap.sector_size);
- }
-
- /* Build label for whole disk. */
- bzero(&label, sizeof label);
- label.d_secsize = t->cap.sector_size;
- label.d_nsectors = t->cap.sectors;
- label.d_ntracks = t->cap.heads;
- label.d_ncylinders = t->cap.cyls;
- label.d_secpercyl = t->cap.heads * t->cap.sectors;
- label.d_rpm = 720;
- label.d_secperunit = label.d_secpercyl * t->cap.cyls;
-
- /* Initialize slice tables. */
- errcode = dsopen(dev, fmt, 0, &t->dk_slices, &label);
- if (errcode != 0)
- return errcode;
-
- t->flags |= F_BOPEN;
- return (0);
-}
-
-/*
- * Close the device. Only called if we are the LAST
- * occurence of an open device.
- */
-int wfdclose (dev_t dev, int flags, int fmt, struct proc *p)
-{
- int lun = UNIT(dev);
- struct wfd *t = wfdtab[lun];
-
- dsclose(dev, fmt, t->dk_slices);
- if(!dsisopen(t->dk_slices)) {
- /* If we were the last open of the entire device, release it. */
- if (! t->refcnt)
- wfd_request_wait (t, ATAPI_PREVENT_ALLOW,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
- t->flags &= ~F_BOPEN;
- }
- return (0);
-}
-
-/*
- * Actually translate the requested transfer into one the physical driver can
- * understand. The transfer is described by a buf and will include only one
- * physical transfer.
- */
-void wfdstrategy (struct buf *bp)
-{
- int lun = UNIT(bp->b_dev);
- struct wfd *t = wfdtab[lun];
- int x;
-
- /* If it's a null transfer, return immediatly. */
- if (bp->b_bcount == 0) {
- bp->b_resid = 0;
- biodone (bp);
- return;
- }
-
- /*
- * Do bounds checking, adjust transfer, and set b_pblkno.
- */
- if (dscheck(bp, t->dk_slices) <= 0) {
- biodone(bp);
- return;
- }
-
- x = splbio();
-
- /* Place it in the queue of disk activities for this disk. */
- bufqdisksort (&t->buf_queue, bp);
-
- /* Tell the device to get going on the transfer if it's
- * not doing anything, otherwise just wait for completion. */
- wfd_start (t);
- splx(x);
-}
-
-/*
- * Look to see if there is a buf waiting for the device
- * and that the device is not already busy. If both are true,
- * It dequeues the buf and creates an ATAPI command to perform the
- * transfer in the buf.
- * The bufs are queued by the strategy routine (wfdstrategy).
- * Must be called at the correct (splbio) level.
- */
-static void wfd_start (struct wfd *t)
-{
- struct buf *bp = bufq_first(&t->buf_queue);
- u_long blkno, nblk;
- u_char op_code;
- long count;
- int pxcount, pxnblk;
- u_char *pxdest;
-
-
- /* See if there is a buf to do and we are not already doing one. */
- if (! bp)
- return;
-
- /* Unqueue the request. */
- bufq_remove(&t->buf_queue, bp);
-
- /* Tell devstat we are starting on the transaction */
- devstat_start_transaction(&t->device_stats);
-
- /* We have a buf, now we should make a command
- * First, translate the block to absolute and put it in terms of the
- * logical blocksize of the device. */
- blkno = bp->b_pblkno / (t->cap.sector_size / 512);
- nblk = (bp->b_bcount + (t->cap.sector_size - 1)) / t->cap.sector_size;
-
- if ((t->maxblks == 0) || (nblk <= t->maxblks)) {
-
- if(bp->b_flags & B_READ) {
- op_code = ATAPI_READ_BIG;
- count = bp->b_bcount;
- } else {
- op_code = ATAPI_WRITE_BIG;
- count = -bp->b_bcount;
- }
-
- /* only one transfer */
- (int)bp->b_driver1 = 0;
- (int)bp->b_driver2 = 0;
- atapi_request_callback (t->ata, t->unit, op_code, 0,
- blkno>>24, blkno>>16, blkno>>8, blkno,
- 0, nblk>>8, nblk, 0, 0,
- 0, 0, 0, 0, 0,
- (u_char*) bp->b_data, count,
- (void*)wfd_done, t, bp);
- } else {
-
- /*
- * We can't handle this request in a single
- * read/write operation. Instead, queue a set of
- * transfers, and record the number of transfers
- * and the running residual in the b_driver
- * fields of the bp.
- */
-
- if(bp->b_flags & B_READ) {
- op_code = ATAPI_READ_BIG;
- } else {
- op_code = ATAPI_WRITE_BIG;
- }
-
- /* calculate number of transfers */
- (int)bp->b_driver1 = (nblk - 1) / t->maxblks;
- (int)bp->b_driver2 = 0;
-
- pxdest = (u_char *)bp->b_data;
- pxcount = bp->b_bcount;
-
- /* construct partial transfer requests */
- while (nblk > 0) {
- pxnblk = min(nblk, t->maxblks);
- count = min(pxcount, t->maxblks * t->cap.sector_size);
-
- atapi_request_callback(t->ata, t->unit, op_code, 0,
- blkno>>24, blkno>>16, blkno>>8,
- blkno, 0, pxnblk>>8, pxnblk,
- 0, 0, 0, 0, 0, 0, 0,
- pxdest,
- (bp->b_flags & B_READ) ?
- count : -count,
- (void*)wfd_done, t, bp);
- nblk -= pxnblk;
- pxcount -= count;
- pxdest += count;
- blkno += pxnblk;
- }
- }
-}
-
-static void wfd_done (struct wfd *t, struct buf *bp, int resid,
- struct atapires result)
-{
-
- if (result.code) {
- wfd_error (t, result);
- bp->b_error = EIO;
- bp->b_flags |= B_ERROR;
- } else
- (int)bp->b_driver2 += resid;
- /*
- * We can't call biodone until all outstanding
- * transfer fragments are handled. If one hits
- * an error, we will be returning an error, but
- * only when all are complete.
- */
- if (((int)bp->b_driver1)-- <= 0) {
- bp->b_resid = (int)bp->b_driver2;
- devstat_end_transaction_buf(&t->device_stats, bp);
- biodone (bp);
- }
-
- wfd_start (t);
-}
-
-static void wfd_error (struct wfd *t, struct atapires result)
-{
- if (result.code != RES_ERR)
- return;
- switch (result.error & AER_SKEY) {
- case AER_SK_NOT_READY:
- if (result.error & ~AER_SKEY) {
- /* Not Ready */
- printf ("wfd%d: not ready\n", t->lun);
- return;
- }
- /* Tray open. */
- if (! (t->flags & F_MEDIA_CHANGED))
- printf ("wfd%d: tray open\n", t->lun);
- t->flags |= F_MEDIA_CHANGED;
- return;
-
- case AER_SK_UNIT_ATTENTION:
- /* Media changed. */
- if (! (t->flags & F_MEDIA_CHANGED))
- printf ("wfd%d: media changed\n", t->lun);
- t->flags |= F_MEDIA_CHANGED;
- return;
-
- case AER_SK_ILLEGAL_REQUEST:
- /* Unknown command or invalid command arguments. */
- if (t->flags & F_DEBUG)
- printf ("wfd%d: invalid command\n", t->lun);
- return;
- }
- printf ("wfd%d: i/o error, status=%b, error=%b\n", t->lun,
- result.status, ARS_BITS, result.error, AER_BITS);
-}
-
-static int wfd_request_wait (struct wfd *t, u_char cmd, u_char a1, u_char a2,
- u_char a3, u_char a4, u_char a5, u_char a6, u_char a7, u_char a8,
- u_char a9, char *addr, int count)
-{
- struct atapires result;
-
- result = atapi_request_wait (t->ata, t->unit, cmd,
- a1, a2, a3, a4, a5, a6, a7, a8, a9, 0, 0, 0, 0, 0, 0,
- addr, count);
- if (result.code) {
- wfd_error (t, result);
- return (EIO);
- }
- return (0);
-}
-
-/*
- * Perform special action on behalf of the user.
- * Knows about the internals of this device
- */
-int wfdioctl (dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
-{
- int lun = UNIT(dev);
- struct wfd *t = wfdtab[lun];
- int error = 0;
-
- error = dsioctl(dev, cmd, addr, flag, &t->dk_slices);
- if (error != ENOIOCTL)
- return (error);
-
- if (t->flags & F_MEDIA_CHANGED)
- switch (cmd) {
- case CDIOCSETDEBUG:
- case CDIOCCLRDEBUG:
- case CDIOCRESET:
- /* These ops are media change transparent. */
- break;
- default:
- /* Lock the media. */
- wfd_request_wait (t, ATAPI_PREVENT_ALLOW,
- 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0);
- break;
- }
- switch (cmd) {
- case CDIOCSETDEBUG:
- error = suser(p);
- if (error)
- return (error);
- t->flags |= F_DEBUG;
- atapi_debug (t->ata, 1);
- return 0;
- case CDIOCCLRDEBUG:
- error = suser(p);
- if (error)
- return (error);
- t->flags &= ~F_DEBUG;
- atapi_debug (t->ata, 0);
- return 0;
- case CDIOCRESET:
- error = suser(p);
- if (error)
- return (error);
- return wfd_request_wait (t, ATAPI_TEST_UNIT_READY,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
- case CDIOCEJECT:
- /* Don't allow eject if the device is opened
- * by somebody (not us) in block mode. */
- if ((t->flags & F_BOPEN) && t->refcnt)
- return (EBUSY);
- return wfd_eject (t, 0);
- case CDIOCCLOSE:
- if ((t->flags & F_BOPEN) && t->refcnt)
- return (0);
- return wfd_eject (t, 1);
- default:
- return (ENOTTY);
- }
- return (error);
-}
-
-static int wfd_eject (struct wfd *t, int closeit)
-{
- struct atapires result;
-
- /* Try to stop the disc. */
- result = atapi_request_wait (t->ata, t->unit, ATAPI_START_STOP,
- 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
-
- if (result.code == RES_ERR &&
- ((result.error & AER_SKEY) == AER_SK_NOT_READY ||
- (result.error & AER_SKEY) == AER_SK_UNIT_ATTENTION)) {
- int err;
-
- if (!closeit)
- return (0);
- /*
- * The disc was unloaded.
- * Load it (close tray).
- * Read the table of contents.
- */
- err = wfd_request_wait (t, ATAPI_START_STOP,
- 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0);
- if (err)
- return (err);
-
- /* Lock the media. */
- wfd_request_wait (t, ATAPI_PREVENT_ALLOW,
- 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0);
-
- return (0);
- }
-
- if (result.code) {
- wfd_error (t, result);
- return (EIO);
- }
-
- if (closeit)
- return (0);
-
- /* Give it some time to stop spinning. */
- tsleep ((caddr_t)&lbolt, PRIBIO, "wfdej1", 0);
- tsleep ((caddr_t)&lbolt, PRIBIO, "wfdej2", 0);
-
- /* Unlock. */
- wfd_request_wait (t, ATAPI_PREVENT_ALLOW,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
-
- /* Eject. */
- t->flags |= F_MEDIA_CHANGED;
- return wfd_request_wait (t, ATAPI_START_STOP,
- 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0);
-}
-
-static void wfd_drvinit(void *unused)
-{
- cdevsw_add(&wfd_cdevsw);
-}
-
-SYSINIT(wfddev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,wfd_drvinit,NULL)
diff --git a/sys/pc98/pc98/wst.c b/sys/pc98/pc98/wst.c
deleted file mode 100644
index 6ba3762f7c31..000000000000
--- a/sys/pc98/pc98/wst.c
+++ /dev/null
@@ -1,774 +0,0 @@
-/*-
- * Copyright (c) 1998 Søren Schmidt
- * 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,
- * without modification, immediately at the beginning of the file.
- * 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.
- *
- * $FreeBSD$
- */
-
-#include "wdc.h"
-#include "opt_ddb.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/conf.h>
-#include <sys/malloc.h>
-#include <sys/buf.h>
-#include <sys/mtio.h>
-#include <machine/clock.h>
-#include <i386/isa/atapi.h>
-
-static d_open_t wstopen;
-static d_close_t wstclose;
-static d_ioctl_t wstioctl;
-static d_strategy_t wststrategy;
-
-#define CDEV_MAJOR 90
-
-static struct cdevsw wst_cdevsw = {
- /* open */ wstopen,
- /* close */ wstclose,
- /* read */ physread,
- /* write */ physwrite,
- /* ioctl */ wstioctl,
- /* poll */ nopoll,
- /* mmap */ nommap,
- /* strategy */ wststrategy,
- /* name */ "wst",
- /* maj */ CDEV_MAJOR,
- /* dump */ nodump,
- /* psize */ nopsize,
- /* flags */ 0,
- /* bmaj */ -1
-};
-
-static unsigned int wst_total = 0;
-
-#define NUNIT (NWDC*2)
-#define UNIT(d) ((minor(d) >> 3) & 3)
-
-#define WST_OPEN 0x0001 /* The device is opened */
-#define WST_MEDIA_CHANGED 0x0002 /* The media have changed */
-#define WST_DATA_WRITTEN 0x0004 /* Data has been written */
-#define WST_FM_WRITTEN 0x0008 /* Filemark has been written */
-#define WST_DEBUG 0x0010 /* Print debug info */
-#define WST_CTL_WARN 0x0020 /* Have we warned about CTL wrong? */
-
-/* ATAPI tape commands not in std ATAPI command set */
-#define ATAPI_TAPE_REWIND 0x01
-#define ATAPI_TAPE_REQUEST_SENSE 0x03
-#define ATAPI_TAPE_READ_CMD 0x08
-#define ATAPI_TAPE_WRITE_CMD 0x0a
-#define ATAPI_TAPE_WEOF 0x10
-#define WEOF_WRITE_MASK 0x01
-#define ATAPI_TAPE_SPACE_CMD 0x11
-#define SP_FM 0x01
-#define SP_EOD 0x03
-#define ATAPI_TAPE_ERASE 0x19
-#define ATAPI_TAPE_MODE_SENSE 0x1a
-#define ATAPI_TAPE_LOAD_UNLOAD 0x1b
-#define LU_LOAD_MASK 0x01
-#define LU_RETENSION_MASK 0x02
-#define LU_EOT_MASK 0x04
-
-#define DSC_POLL_INTERVAL 10
-
-/*
- * MODE SENSE parameter header
- */
-struct wst_header {
- u_char data_length; /* Total length of data */
- u_char medium_type; /* Medium type (if any) */
- u_char dsp; /* Device specific parameter */
- u_char bdl; /* Block Descriptor Length */
-};
-
-/*
- * ATAPI tape drive Capabilities and Mechanical Status Page
- */
-#define ATAPI_TAPE_CAP_PAGE 0x2a
-
-struct wst_cappage {
- u_int page_code :6; /* Page code == 0x2a */
- u_int reserved1_67 :2;
- u_char page_length; /* Page Length == 0x12 */
- u_char reserved2;
- u_char reserved3;
- u_int readonly :1; /* Read Only Mode */
- u_int reserved4_1234 :4;
- u_int reverse :1; /* Supports reverse direction */
- u_int reserved4_67 :2;
- u_int reserved5_012 :3;
- u_int eformat :1; /* Supports ERASE formatting */
- u_int reserved5_4 :1;
- u_int qfa :1; /* Supports QFA formats */
- u_int reserved5_67 :2;
- u_int lock :1; /* Supports locking media */
- u_int locked :1; /* The media is locked */
- u_int prevent :1; /* Defaults to prevent state */
- u_int eject :1; /* Supports eject */
- u_int disconnect :1; /* Can break request > ctl */
- u_int reserved6_5 :1;
- u_int ecc :1; /* Supports error correction */
- u_int compress :1; /* Supports data compression */
- u_int reserved7_0 :1;
- u_int blk512 :1; /* Supports 512b block size */
- u_int blk1024 :1; /* Supports 1024b block size */
- u_int reserved7_3456 :4;
- u_int slowb :1; /* Restricts byte count */
- u_short max_speed; /* Supported speed in KBps */
- u_short max_defects; /* Max stored defect entries */
- u_short ctl; /* Continuous Transfer Limit */
- u_short speed; /* Current Speed, in KBps */
- u_short buffer_size; /* Buffer Size, in 512 bytes */
- u_char reserved18;
- u_char reserved19;
-};
-
-/*
- * REQUEST SENSE structure
- */
-struct wst_reqsense {
- u_int error_code :7; /* Current or deferred errors */
- u_int valid :1; /* Follows QIC-157C */
- u_char reserved1; /* Segment Number - Reserved */
- u_int sense_key :4; /* Sense Key */
- u_int reserved2_4 :1; /* Reserved */
- u_int ili :1; /* Incorrect Length Indicator */
- u_int eom :1; /* End Of Medium */
- u_int filemark :1; /* Filemark */
- u_int info __attribute__((packed)); /* Cmd specific info */
- u_char asl; /* Additional sense length (n-7) */
- u_int command_specific; /* Additional cmd specific info */
- u_char asc; /* Additional Sense Code */
- u_char ascq; /* Additional Sense Code Qualifier */
- u_char replaceable_unit_code; /* Field Replaceable Unit Code */
- u_int sk_specific1 :7; /* Sense Key Specific */
- u_int sksv :1; /* Sense Key Specific info valid */
- u_char sk_specific2; /* Sense Key Specific */
- u_char sk_specific3; /* Sense Key Specific */
- u_char pad[2]; /* Padding */
-};
-
-struct wst {
- struct atapi *ata; /* Controller structure */
- int unit; /* IDE bus drive unit */
- int lun; /* Logical device unit */
- int flags; /* Device state flags */
- int blksize; /* Block size (512 | 1024) */
- struct buf_queue_head buf_queue; /* Queue of i/o requests */
- struct atapi_params *param; /* Drive parameters table */
- struct wst_header header; /* MODE SENSE param header */
- struct wst_cappage cap; /* Capabilities page info */
-};
-
-static struct wst *wsttab[NUNIT]; /* Drive info by unit number */
-static int wstnlun = 0; /* Number of config'd drives */
-
-int wstattach(struct atapi *ata, int unit, struct atapi_params *ap, int debug);
-static int wst_sense(struct wst *t);
-static void wst_describe(struct wst *t);
-static void wst_poll_dsc(struct wst *t);
-static void wst_start(struct wst *t);
-static void wst_done(struct wst *t, struct buf *bp, int resid, struct atapires result);
-static int wst_error(struct wst *t, struct atapires result);
-static void wst_drvinit(void *unused);
-static int wst_space_cmd(struct wst *t, u_char function, u_int count);
-static int wst_write_filemark(struct wst *t, u_char function);
-static int wst_erase(struct wst *t);
-static int wst_load_unload(struct wst *t, u_char finction);
-static int wst_rewind(struct wst *t);
-static void wst_reset(struct wst *t);
-
-#ifdef DDB
-void wst_dump(int lun, char *label, void *data, int len);
-
-void
-wst_dump(int lun, char *label, void *data, int len)
-{
- u_char *p = data;
-
- printf("wst%d: %s %x", lun, label, *p++);
- while(--len > 0)
- printf("-%x", *p++);
- printf("\n");
-}
-#endif
-
-int
-wstattach(struct atapi *ata, int unit, struct atapi_params *ap, int debug)
-{
- struct wst *t;
- int lun;
-
- if (wstnlun >= NUNIT) {
- printf("wst: too many units\n");
- return(-1);
- }
- if (!atapi_request_immediate) {
- printf("wst: configuration error, ATAPI core code not present!\n");
- printf(
- "wst: check `options ATAPI_STATIC' in your kernel config file!\n");
- return(-1);
- }
- t = malloc(sizeof(struct wst), M_TEMP, M_NOWAIT);
- if (!t) {
- printf("wst: out of memory\n");
- return(-1);
- }
- wsttab[wstnlun] = t;
- bzero(t, sizeof(struct wst));
- bufq_init(&t->buf_queue);
- t->ata = ata;
- t->unit = unit;
- t->ata->use_dsc = 1;
- lun = t->lun = wstnlun;
- t->param = ap;
- t->flags = WST_MEDIA_CHANGED | WST_DEBUG;
-
- if (wst_sense(t))
- return -1;
-
- wst_describe(t);
- wstnlun++;
-
- make_dev(&wst_cdevsw, 0, UID_ROOT, GID_OPERATOR, 0640, "rwst%d", t->lun);
- return(1);
-}
-
-static int
-wst_sense(struct wst *t)
-{
- struct atapires result;
- int count;
- char buffer[255];
-
- /* Get drive capabilities, some drives needs this repeated */
- for (count = 0 ; count < 5 ; count++) {
- result = atapi_request_immediate(t->ata, t->unit,
- ATAPI_TAPE_MODE_SENSE,
- 8, /* DBD = 1 no block descr */
- ATAPI_TAPE_CAP_PAGE,
- sizeof(buffer)>>8, sizeof(buffer),
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, buffer, sizeof(buffer));
- if (result.code == 0 || result.code == RES_UNDERRUN)
- break;
- }
-
- /* Some drives have shorter capabilities page. */
- if (result.code == RES_UNDERRUN)
- result.code = 0;
-
- if (result.code == 0) {
- bcopy(buffer, &t->header, sizeof(struct wst_header));
- bcopy(buffer+sizeof(struct wst_header),
- &t->cap, sizeof(struct wst_cappage));
- if (t->cap.page_code != ATAPI_TAPE_CAP_PAGE)
- return 1;
- t->cap.max_speed = ntohs(t->cap.max_speed);
- t->cap.max_defects = ntohs(t->cap.max_defects);
- t->cap.ctl = ntohs(t->cap.ctl);
- t->cap.speed = ntohs(t->cap.speed);
- t->cap.buffer_size = ntohs(t->cap.buffer_size);
- t->blksize = (t->cap.blk512 ? 512 : (t->cap.blk1024 ? 1024 : 0));
- return 0;
- }
- return 1;
-}
-
-static void
-wst_describe(struct wst *t)
-{
- printf("wst%d: ", t->lun);
- switch (t->header.medium_type) {
- case 0x00: printf("Drive empty"); break;
- case 0x17: printf("Travan 1 (400 Mbyte) media"); break;
- case 0xb6: printf("Travan 4 (4 Gbyte) media"); break;
- default: printf("Unknown media (0x%x)", t->header.medium_type);
- }
- if (t->cap.readonly) printf(", readonly");
- if (t->cap.reverse) printf(", reverse");
- if (t->cap.eformat) printf(", eformat");
- if (t->cap.qfa) printf(", qfa");
- if (t->cap.lock) printf(", lock");
- if (t->cap.locked) printf(", locked");
- if (t->cap.prevent) printf(", prevent");
- if (t->cap.eject) printf(", eject");
- if (t->cap.disconnect) printf(", disconnect");
- if (t->cap.ecc) printf(", ecc");
- if (t->cap.compress) printf(", compress");
- if (t->cap.blk512) printf(", 512b");
- if (t->cap.blk1024) printf(", 1024b");
- if (t->cap.slowb) printf(", slowb");
- printf("\nwst%d: ", t->lun);
- printf("Max speed=%dKb/s, ", t->cap.max_speed);
- printf("Transfer limit=%d blocks, ", t->cap.ctl);
- printf("Buffer size=%d blocks", t->cap.buffer_size);
- printf("\n");
-}
-
-int
-wstopen(dev_t dev, int flags, int fmt, struct proc *p)
-{
- int lun = UNIT(dev);
- struct wst *t;
-
- /* Check that the device number and that the ATAPI driver is loaded. */
- if (lun >= wstnlun || !atapi_request_immediate) {
- printf("ENXIO lun=%d, wstnlun=%d, im=%p\n",
- lun, wstnlun, (void *)atapi_request_immediate);
- return(ENXIO);
- }
- t = wsttab[lun];
- if (t->flags == WST_OPEN)
- return EBUSY;
- if (wst_sense(t))
- printf("wst%d: Sense media type failed\n", t->lun);
- t->flags &= ~WST_MEDIA_CHANGED;
- t->flags &= ~(WST_DATA_WRITTEN | WST_FM_WRITTEN);
- t->flags |= WST_OPEN;
- return(0);
-}
-
-int
-wstclose(dev_t dev, int flags, int fmt, struct proc *p)
-{
- int lun = UNIT(dev);
- struct wst *t = wsttab[lun];
-
- /* Flush buffers, some drives fail here, but they should report ctl = 0 */
- if (t->cap.ctl && (t->flags & WST_DATA_WRITTEN))
- wst_write_filemark(t, 0);
-
- /* Write filemark if data written to tape */
- if ((t->flags & (WST_DATA_WRITTEN | WST_FM_WRITTEN)) == WST_DATA_WRITTEN)
- wst_write_filemark(t, WEOF_WRITE_MASK);
-
- /* If minor is even rewind on close */
- if (!(minor(dev) & 0x01))
- wst_rewind(t);
-
- t->flags &= ~WST_OPEN;
- if (t->flags & WST_DEBUG)
- printf("wst%d: %ud total bytes transferred\n", t->lun, wst_total);
- t->flags &= ~WST_CTL_WARN;
- return(0);
-}
-
-void
-wststrategy(struct buf *bp)
-{
- int lun = UNIT(bp->b_dev);
- struct wst *t = wsttab[lun];
- int x;
-
- /* If it's a null transfer, return immediatly. */
- if (bp->b_bcount == 0) {
- bp->b_resid = 0;
- biodone(bp);
- return;
- }
-
- /* Check for != blocksize requests */
- if (bp->b_bcount % t->blksize) {
- printf("wst%d: bad request, must be multiple of %d\n", lun, t->blksize);
- bp->b_error = EIO;
- bp->b_flags |= B_ERROR;
- biodone(bp);
- return;
- }
-
- if (bp->b_bcount > t->blksize*t->cap.ctl) {
- if ((t->flags & WST_CTL_WARN) == 0) {
- printf("wst%d: WARNING: CTL exceeded %ld>%d\n",
- lun, bp->b_bcount, t->blksize*t->cap.ctl);
- t->flags |= WST_CTL_WARN;
- }
- }
-
- x = splbio();
- wst_total += bp->b_bcount;
- bufq_insert_tail(&t->buf_queue, bp);
- wst_start(t);
- splx(x);
-}
-
-static void
-wst_poll_dsc(struct wst *t)
-{
- /* We should use a final timeout here SOS XXX */
- if (!(inb(t->ata->port + AR_STATUS) & ARS_DSC)) {
- timeout((timeout_t*)wst_poll_dsc, t, DSC_POLL_INTERVAL);
- return;
- }
- t->ata->wait_for_dsc = 0;
- wakeup((caddr_t)t);
-}
-
-static void
-wst_start(struct wst *t)
-{
- struct buf *bp = bufq_first(&t->buf_queue);
- u_long blk_count;
- u_char op_code;
- long byte_count;
-
- if (!bp)
- return;
-
- if (t->ata->wait_for_dsc)
- printf("wst%d: ERROR! allready waiting for DSC\n", t->lun);
-
- /* Sleep waiting for a ready drive (DSC) */
- if (t->ata->use_dsc && !(inb(t->ata->port + AR_STATUS) & ARS_DSC)) {
- t->ata->wait_for_dsc = 1;
- timeout((timeout_t*)wst_poll_dsc, t, DSC_POLL_INTERVAL);
- tsleep((caddr_t) t, 0, "wstdsc", 0);
- }
-
- bufq_remove(&t->buf_queue, bp);
- blk_count = bp->b_bcount / t->blksize;
-
- if (bp->b_flags & B_READ) {
- op_code = ATAPI_TAPE_READ_CMD;
- byte_count = bp->b_bcount;
- } else {
- op_code = ATAPI_TAPE_WRITE_CMD;
- t->flags |= WST_DATA_WRITTEN;
- byte_count = -bp->b_bcount;
- }
-
- atapi_request_callback(t->ata, t->unit, op_code, 1,
- blk_count>>16, blk_count>>8, blk_count,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- (u_char*) bp->b_data, byte_count,
- (void*)wst_done, t, bp);
-}
-
-static void
-wst_done(struct wst *t, struct buf *bp, int resid,
- struct atapires result)
-{
- if (result.code) {
- printf("wst_done: ");
- wst_error(t, result);
- bp->b_error = EIO;
- bp->b_flags |= B_ERROR;
- }
- else
- bp->b_resid = resid;
-
- biodone(bp);
- /*wst_start(t);*/
-}
-
-static int
-wst_error(struct wst *t, struct atapires result)
-{
- struct wst_reqsense sense;
-
- if (result.code != RES_ERR) {
- printf("wst%d: ERROR code=%d, status=%b, error=%b\n", t->lun,
- result.code, result.status, ARS_BITS, result.error, AER_BITS);
- return 1;
- }
-
- if ((result.error & AER_SKEY) && (result.status & ARS_CHECK)) {
- atapi_request_immediate(t->ata, t->unit,
- ATAPI_TAPE_REQUEST_SENSE,
- 0, 0, 0, sizeof(sense),
- 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, (char*) &sense, sizeof(struct wst_reqsense));
- /*wst_dump(t->lun, "req_sense", &sense, sizeof(struct wst_reqsense));*/
- }
- switch (result.error & AER_SKEY) {
- case AER_SK_NOT_READY:
- if (result.error & ~AER_SKEY) {
- if (t->flags & WST_DEBUG)
- printf("wst%d: not ready\n", t->lun);
- break;
- }
- if (!(t->flags & WST_MEDIA_CHANGED))
- if (t->flags & WST_DEBUG)
- printf("wst%d: no media\n", t->lun);
- t->flags |= WST_MEDIA_CHANGED;
- break;
-
- case AER_SK_BLANK_CHECK:
- if (t->flags & WST_DEBUG)
- printf("wst%d: EOD encountered\n", t->lun);
- break;
-
- case AER_SK_MEDIUM_ERROR:
- if (t->flags & WST_DEBUG)
- printf("wst%d: nonrecovered data error\n", t->lun);
- break;
-
- case AER_SK_HARDWARE_ERROR:
- if (t->flags & WST_DEBUG)
- printf("wst%d: nonrecovered hardware error\n", t->lun);
- break;
-
- case AER_SK_ILLEGAL_REQUEST:
- if (t->flags & WST_DEBUG)
- printf("wst%d: invalid command\n", t->lun);
- break;
-
- case AER_SK_UNIT_ATTENTION:
- if (!(t->flags & WST_MEDIA_CHANGED))
- printf("wst%d: media changed\n", t->lun);
- t->flags |= WST_MEDIA_CHANGED;
- break;
-
- case AER_SK_DATA_PROTECT:
- if (t->flags & WST_DEBUG)
- printf("wst%d: reading read protected data\n", t->lun);
- break;
-
- case AER_SK_ABORTED_COMMAND:
- if (t->flags & WST_DEBUG)
- printf("wst%d: command aborted\n", t->lun);
- break;
-
- case AER_SK_MISCOMPARE:
- if (t->flags & WST_DEBUG)
- printf("wst%d: data don't match medium\n", t->lun);
- break;
-
- default:
- printf("wst%d: i/o error, status=%b, error=%b\n", t->lun,
- result.status, ARS_BITS, result.error, AER_BITS);
- }
- printf("total=%u ERR=%x len=%ld ASC=%x ASCQ=%x\n",
- wst_total, sense.error_code, (long)ntohl(sense.info),
- sense.asc, sense.ascq);
- return 1;
-}
-
-int
-wstioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
-{
- int lun = UNIT(dev);
- int error = 0;
- struct wst *t = wsttab[lun];
-
- switch (cmd) {
- case MTIOCGET:
- {
- struct mtget *g = (struct mtget *) addr;
-
- bzero(g, sizeof(struct mtget));
- g->mt_type = 7;
- g->mt_density = 1;
- g->mt_blksiz = t->blksize;
- g->mt_comp = t->cap.compress;
- g->mt_density0 = 0; g->mt_density1 = 0;
- g->mt_density2 = 0; g->mt_density3 = 0;
- g->mt_blksiz0 = 0; g->mt_blksiz1 = 0;
- g->mt_blksiz2 = 0; g->mt_blksiz3 = 0;
- g->mt_comp0 = 0; g->mt_comp1 = 0;
- g->mt_comp2 = 0; g->mt_comp3 = 0;
- break;
- }
- case MTIOCTOP:
- {
- int i;
- struct mtop *mt = (struct mtop *)addr;
-
- switch ((short) (mt->mt_op)) {
- case MTWEOF:
- for (i=0; i < mt->mt_count && !error; i++)
- error = wst_write_filemark(t, WEOF_WRITE_MASK);
- break;
- case MTFSF:
- if (mt->mt_count)
- error = wst_space_cmd(t, SP_FM, mt->mt_count);
- break;
- case MTBSF:
- if (mt->mt_count)
- error = wst_space_cmd(t, SP_FM, -(mt->mt_count));
- break;
- case MTFSR:
- error = EINVAL; break;
- case MTBSR:
- error = EINVAL; break;
- case MTREW:
- error = wst_rewind(t);
- break;
- case MTOFFL:
-#if 1 /* Misuse as a reset func for now */
- wst_reset(t);
- wst_sense(t);
- wst_describe(t);
-#else
- if (error = wst_rewind(t))
- break;
- error = wst_load_unload(t, !LU_LOAD_MASK);
-#endif
- break;
- case MTNOP:
- error = wst_write_filemark(t, 0);
- break;
- case MTCACHE:
- error = EINVAL; break;
- case MTNOCACHE:
- error = EINVAL; break;
- case MTSETBSIZ:
- error = EINVAL; break;
- case MTSETDNSTY:
- error = EINVAL; break;
- case MTERASE:
- error = wst_erase(t);
- break;
- case MTEOD:
- error = wst_space_cmd(t, SP_EOD, 0);
- break;
- case MTCOMP:
- error = EINVAL; break;
- case MTRETENS:
- error = wst_load_unload(t, LU_RETENSION_MASK|LU_LOAD_MASK);
- break;
- default:
- error = EINVAL;
- }
- return error;
- }
- default:
- return(ENOTTY);
- }
- return(error);
-}
-
-static int
-wst_space_cmd(struct wst *t, u_char function, u_int count)
-{
- struct atapires result;
-
- result = atapi_request_wait(t->ata, t->unit,
- ATAPI_TAPE_SPACE_CMD, function,
- count>>16, count>>8, count,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, 0);
- if (result.code) {
- printf("wst_space_cmd: ");
- wst_error(t, result);
- return EIO;
- }
- return 0;
-}
-
-static int
-wst_write_filemark(struct wst *t, u_char function)
-{
- struct atapires result;
-
- if (function) {
- if (t->flags & WST_FM_WRITTEN)
- t->flags &= ~WST_DATA_WRITTEN;
- else
- t->flags |= WST_FM_WRITTEN;
- }
- result = atapi_request_wait(t->ata, t->unit,
- ATAPI_TAPE_WEOF, 0, 0, 0, function,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, 0);
- if (result.code) {
- printf("wst_write_filemark: ");
- wst_error(t, result);
- return EIO;
- }
- return 0;
-}
-
-static int
-wst_load_unload(struct wst *t, u_char function)
-{
- struct atapires result;
-
- result = atapi_request_wait(t->ata, t->unit,
- ATAPI_TAPE_LOAD_UNLOAD, 0, 0, 0, function,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, 0);
- if (result.code) {
- printf("wst_load_unload: ");
- wst_error(t, result);
- return EIO;
- }
- return 0;
-}
-
-static int
-wst_erase(struct wst *t)
-{
- int error;
- struct atapires result;
-
- error = wst_rewind(t);
- if (error)
- return error;
- result = atapi_request_wait(t->ata, t->unit,
- ATAPI_TAPE_ERASE, 3, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- NULL, 0);
- if (result.code) {
- printf("wst_erase: ");
- wst_error(t, result);
- return EIO;
- }
- return 0;
-}
-
-static int
-wst_rewind(struct wst *t)
-{
- struct atapires result;
-
- result = atapi_request_wait(t->ata, t->unit,
- ATAPI_TAPE_REWIND, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- NULL, 0);
- if (result.code) {
- printf("wst_rewind: ");
- wst_error(t, result);
- return EIO;
- }
- return 0;
-}
-
-static void
-wst_reset(struct wst *t)
-{
- outb(t->ata->port + AR_DRIVE, ARD_DRIVE1);
- DELAY(30);
- outb(t->ata->port + AR_COMMAND, 0x08);
- DELAY(30);
-}
-
-static void
-wst_drvinit(void *unused)
-{
- cdevsw_add(&wst_cdevsw);
-}
-
-SYSINIT(wstdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,wst_drvinit,NULL)
diff --git a/sys/pccard/pcic_pci.c b/sys/pccard/pcic_pci.c
deleted file mode 100644
index edb19e2f4bfe..000000000000
--- a/sys/pccard/pcic_pci.c
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
- * Copyright (c) 1997 Ted Faber
- * 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 immediately at the beginning of the file, without modification,
- * 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. Absolutely no warranty of function or purpose is made by the author
- * Ted Faber.
- *
- * 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <pci/pcireg.h>
-#include <pci/pcivar.h>
-#include <pci/pcic_p.h>
-#include <pccard/i82365.h>
-#include <vm/vm.h>
-#include <vm/pmap.h>
-
-/*
- * Set up the CL-PD6832 to look like a ISA based PCMCIA chip (a
- * PD672X). This routine is called once per PCMCIA socket.
- */
-static void
-pd6832_legacy_init(device_t self)
-{
- u_long bcr; /* to set interrupts */
- u_short io_port; /* the io_port to map this slot on */
- static int num6832; /* The number of 6832s initialized */
- int unit;
-
- num6832 = 0;
- unit = device_get_unit(self);
- /*
- * Some BIOS leave the legacy address uninitialized. This
- * insures that the PD6832 puts itself where the driver will
- * look. We assume that multiple 6832's should be laid out
- * sequentially. We only initialize the first socket's legacy port,
- * the other is a dummy.
- */
- io_port = PCIC_INDEX_0 + num6832 * CLPD6832_NUM_REGS;
- if (unit == 0)
- pci_write_config(self, CLPD6832_LEGACY_16BIT_IOADDR,
- io_port & ~PCI_MAP_IO, 4);
-
- /*
- * I think this should be a call to pci_map_port, but that
- * routine won't map regiaters above 0x28, and the register we
- * need to map is 0x44.
- */
- io_port = pci_read_config(self, CLPD6832_LEGACY_16BIT_IOADDR, 4) &
- ~PCI_MAP_IO;
-
- /*
- * Configure the first I/O window to contain CLPD6832_NUM_REGS
- * words and deactivate the second by setting the limit lower
- * than the base.
- */
- pci_write_config(self, CLPD6832_IO_BASE0, io_port | 1, 4);
- pci_write_config(self, CLPD6832_IO_LIMIT0,
- (io_port + CLPD6832_NUM_REGS) | 1, 4);
-
- pci_write_config(self, CLPD6832_IO_BASE1, (io_port + 0x20) | 1, 4);
- pci_write_config(self, CLPD6832_IO_LIMIT1, io_port | 1, 4);
-
- /*
- * Set default operating mode (I/O port space) and allocate
- * this socket to the current unit.
- */
- pci_write_config(self, PCI_COMMAND_STATUS_REG,
- CLPD6832_COMMAND_DEFAULTS, 4);
- pci_write_config(self, CLPD6832_SOCKET, unit, 4);
-
- /*
- * Set up the card inserted/card removed interrupts to come
- * through the isa IRQ.
- */
- bcr = pci_read_config(self, CLPD6832_BRIDGE_CONTROL, 4);
- bcr |= (CLPD6832_BCR_ISA_IRQ|CLPD6832_BCR_MGMT_IRQ_ENA);
- pci_write_config(self, CLPD6832_BRIDGE_CONTROL, bcr, 4);
-
- /* After initializing 2 sockets, the chip is fully configured */
- if (unit == 1)
- num6832++;
-
- if (bootverbose)
- printf("CardBus: Legacy PC-card 16bit I/O address [0x%x]\n",
- io_port);
-}
-
-/*
- * Return the ID string for the controller if the vendor/product id
- * matches, NULL otherwise.
- */
-static int
-pcic_pci_probe(device_t self)
-{
- u_int32_t device_id;
- char *desc;
-
- device_id = pci_get_devid(self);
- desc = NULL;
-
- switch (device_id) {
- case PCI_DEVICE_ID_PCIC_CLPD6832:
- desc = "Cirrus Logic PD6832 PCI/CardBus Bridge";
- break;
- case PCI_DEVICE_ID_PCIC_TI1130:
- desc = "TI PCI-1130 PCI-CardBus Bridge";
- break;
- case PCI_DEVICE_ID_PCIC_TI1131:
- desc = "TI PCI-1131 PCI-CardBus Bridge";
- break;
- case PCI_DEVICE_ID_PCIC_TI1220:
- desc = "TI PCI-1220 PCI-CardBus Bridge";
- break;
- case PCI_DEVICE_ID_PCIC_TI1221:
- desc = "TI PCI-1221 PCI-CardBus Bridge";
- break;
- case PCI_DEVICE_ID_PCIC_TI1225:
- desc = "TI PCI-1225 PCI-CardBus Bridge";
- break;
- case PCI_DEVICE_ID_PCIC_TI1250:
- desc = "TI PCI-1250 PCI-CardBus Bridge";
- break;
- case PCI_DEVICE_ID_PCIC_TI1251:
- desc = "TI PCI-1251 PCI-CardBus Bridge";
- break;
- case PCI_DEVICE_ID_PCIC_TI1251B:
- desc = "TI PCI-1251B PCI-CardBus Bridge";
- break;
- case PCI_DEVICE_ID_PCIC_TI1410:
- desc = "TI PCI-1410 PCI-CardBus Bridge";
- break;
- case PCI_DEVICE_ID_PCIC_TI1420:
- desc = "TI PCI-1420 PCI-CardBus Bridge";
- break;
- case PCI_DEVICE_ID_PCIC_TI1450:
- desc = "TI PCI-1450 PCI-CardBus Bridge";
- break;
- case PCI_DEVICE_ID_PCIC_TI1451:
- desc = "TI PCI-1451 PCI-CardBus Bridge";
- break;
- case PCI_DEVICE_ID_TOSHIBA_TOPIC95:
- desc = "Toshiba ToPIC95 PCI-CardBus Bridge";
- break;
- case PCI_DEVICE_ID_TOSHIBA_TOPIC97:
- desc = "Toshiba ToPIC97 PCI-CardBus Bridge";
- break;
- case PCI_DEVICE_ID_RICOH_RL5C465:
- desc = "Ricoh RL5C465 PCI-CardBus Bridge";
- break;
- case PCI_DEVICE_ID_RICOH_RL5C475:
- desc = "Ricoh RL5C475 PCI-CardBus Bridge";
- break;
- case PCI_DEVICE_ID_RICOH_RL5C476:
- desc = "Ricoh RL5C476 PCI-CardBus Bridge";
- break;
- case PCI_DEVICE_ID_RICOH_RL5C478:
- desc = "Ricoh RL5C478 PCI-CardBus Bridge";
- break;
- /* 16bit PC-card bridges */
- case PCI_DEVICE_ID_PCIC_CLPD6729:
- desc = "Cirrus Logic PD6729/6730 PC-Card Controller";
- break;
- case PCI_DEVICE_ID_PCIC_OZ6729:
- desc = "O2micro OZ6729 PC-Card Bridge";
- break;
- case PCI_DEVICE_ID_PCIC_OZ6730:
- desc = "O2micro OZ6730 PC-Card Bridge";
- break;
-
- default:
- break;
- }
-
- if (desc == NULL)
- return (ENXIO);
-
- device_set_desc(self, desc);
- return 0; /* exact match */
-}
-
-
-/*
- * General PCI based card dispatch routine. Right now
- * it only understands the CL-PD6832.
- */
-static int
-pcic_pci_attach(device_t self)
-{
- u_int32_t device_id = pci_get_devid(self);
-
- switch (device_id) {
- case PCI_DEVICE_ID_PCIC_CLPD6832:
- pd6832_legacy_init(self);
- break;
- }
-
- if (bootverbose) {
- int i, j;
- u_char *p;
- u_long *pl;
-
- printf("PCI Config space:\n");
- for (j = 0; j < 0x98; j += 16) {
- printf("%02x: ", j);
- for (i = 0; i < 16; i += 4)
- printf(" %08x", pci_read_config(self, i+j, 4));
- printf("\n");
- }
- p = (u_char *)pmap_mapdev(pci_read_config(self, 0x10, 4),
- 0x1000);
- pl = (u_long *)p;
- printf("Cardbus Socket registers:\n");
- printf("00: ");
- for (i = 0; i < 4; i += 1)
- printf(" %08lx:", pl[i]);
- printf("\n10: ");
- for (i = 4; i < 8; i += 1)
- printf(" %08lx:", pl[i]);
- printf("\nExCa registers:\n");
- for (i = 0; i < 0x40; i += 16)
- printf("%02x: %16D\n", i, p + 0x800 + i, " ");
- }
-
- return 0; /* no error */
-}
-
-
-static device_method_t pcic_pci_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, pcic_pci_probe),
- DEVMETHOD(device_attach, pcic_pci_attach),
- DEVMETHOD(device_suspend, bus_generic_suspend),
- DEVMETHOD(device_resume, bus_generic_resume),
- DEVMETHOD(device_shutdown, bus_generic_shutdown),
-
- {0, 0}
-};
-
-static driver_t pcic_pci_driver = {
- "pcic-pci",
- pcic_pci_methods,
- 0 /* no softc */
-};
-
-static devclass_t pcic_pci_devclass;
-
-DRIVER_MODULE(pcic_pci, pci, pcic_pci_driver, pcic_pci_devclass, 0, 0);
diff --git a/sys/pccard/pcic_pci.h b/sys/pccard/pcic_pci.h
deleted file mode 100644
index 0193a11ab17c..000000000000
--- a/sys/pccard/pcic_pci.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 1997 Ted Faber
- * 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 immediately at the beginning of the file, without modification,
- * 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. Absolutely no warranty of function or purpose is made by the author
- * Ted Faber.
- *
- * 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.
- *
- * $FreeBSD$
- */
-
-/* PCI/CardBus Device IDs */
-#define PCI_DEVICE_ID_PCIC_OZ6729 0x67291217ul
-#define PCI_DEVICE_ID_PCIC_OZ6730 0x673A1217ul
-#define PCI_DEVICE_ID_PCIC_CLPD6729 0x11001013ul
-#define PCI_DEVICE_ID_PCIC_CLPD6832 0x11101013ul
-#define PCI_DEVICE_ID_PCIC_TI1130 0xac12104cul
-#define PCI_DEVICE_ID_PCIC_TI1131 0xac15104cul
-#define PCI_DEVICE_ID_PCIC_TI1220 0xac17104cul
-#define PCI_DEVICE_ID_PCIC_TI1221 0xac19104cul
-#define PCI_DEVICE_ID_PCIC_TI1250 0xac16104cul
-#define PCI_DEVICE_ID_PCIC_TI1251 0xac1d104cul
-#define PCI_DEVICE_ID_PCIC_TI1251B 0xac1f104cul
-#define PCI_DEVICE_ID_PCIC_TI1225 0xac1c104cul
-#define PCI_DEVICE_ID_PCIC_TI1410 0xac50104cul
-#define PCI_DEVICE_ID_PCIC_TI1420 0xac51104cul
-#define PCI_DEVICE_ID_PCIC_TI1450 0xac1b104cul
-#define PCI_DEVICE_ID_PCIC_TI1451 0xac52104cul
-#define PCI_DEVICE_ID_TOSHIBA_TOPIC95 0x060a1179ul
-#define PCI_DEVICE_ID_TOSHIBA_TOPIC97 0x060f1179ul
-#define PCI_DEVICE_ID_RICOH_RL5C465 0x04651180ul
-#define PCI_DEVICE_ID_RICOH_RL5C475 0x04751180ul
-#define PCI_DEVICE_ID_RICOH_RL5C476 0x04761180ul
-#define PCI_DEVICE_ID_RICOH_RL5C478 0x04781180ul
-
-/* CL-PD6832 CardBus defines */
-#define CLPD6832_IO_BASE0 0x002c
-#define CLPD6832_IO_LIMIT0 0x0030
-#define CLPD6832_IO_BASE1 0x0034
-#define CLPD6832_IO_LIMIT1 0x0038
-#define CLPD6832_BRIDGE_CONTROL 0x003c
-#define CLPD6832_LEGACY_16BIT_IOADDR 0x0044
-#define CLPD6832_SOCKET 0x004c
-
-/* Configuration constants */
-#define CLPD6832_BCR_MGMT_IRQ_ENA 0x08000000
-#define CLPD6832_BCR_ISA_IRQ 0x00800000
-#define CLPD6832_COMMAND_DEFAULTS 0x00000045
-#define CLPD6832_NUM_REGS 2
-
-/* End of CL-PD6832 defines */
diff --git a/sys/powerpc/aim/vm_machdep.c b/sys/powerpc/aim/vm_machdep.c
deleted file mode 100644
index bb2bbfdd0c9a..000000000000
--- a/sys/powerpc/aim/vm_machdep.c
+++ /dev/null
@@ -1,489 +0,0 @@
-/*-
- * Copyright (c) 1982, 1986 The Regents of the University of California.
- * Copyright (c) 1989, 1990 William Jolitz
- * Copyright (c) 1994 John Dyson
- * 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, and William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91
- * Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$
- * $FreeBSD$
- */
-/*
- * Copyright (c) 1994, 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.
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/proc.h>
-#include <sys/malloc.h>
-#include <sys/buf.h>
-#include <sys/vnode.h>
-#include <sys/vmmeter.h>
-#include <sys/kernel.h>
-#include <sys/sysctl.h>
-#include <sys/unistd.h>
-
-#include <machine/clock.h>
-#include <machine/cpu.h>
-#include <machine/fpu.h>
-#include <machine/md_var.h>
-#include <machine/prom.h>
-
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <sys/lock.h>
-#include <vm/vm_kern.h>
-#include <vm/vm_page.h>
-#include <vm/vm_map.h>
-#include <vm/vm_extern.h>
-
-#include <sys/user.h>
-
-/*
- * quick version of vm_fault
- */
-int
-vm_fault_quick(v, prot)
- caddr_t v;
- int prot;
-{
- int r;
- if (prot & VM_PROT_WRITE)
- r = subyte(v, fubyte(v));
- else
- r = fubyte(v);
- return(r);
-}
-
-/*
- * Finish a fork operation, with process p2 nearly set up.
- * Copy and update the pcb, set up the stack so that the child
- * ready to run and return to user mode.
- */
-void
-cpu_fork(p1, p2, flags)
- register struct proc *p1, *p2;
- int flags;
-{
- struct user *up = p2->p_addr;
-
- if ((flags & RFPROC) == 0)
- return;
-
- p2->p_md.md_tf = p1->p_md.md_tf;
- p2->p_md.md_flags = p1->p_md.md_flags & (MDP_FPUSED | MDP_UAC_MASK);
-
- /*
- * Cache the physical address of the pcb, so we can
- * swap to it easily.
- */
- p2->p_md.md_pcbpaddr = (void*) vtophys((vm_offset_t) &up->u_pcb);
-
- /*
- * Copy floating point state from the FP chip to the PCB
- * if this process has state stored there.
- */
- alpha_fpstate_save(p1, 0);
-
- /*
- * Copy pcb and stack from proc p1 to p2. We do this as
- * cheaply as possible, copying only the active part of the
- * stack. The stack and pcb need to agree. Make sure that the
- * new process has FEN disabled.
- */
- p2->p_addr->u_pcb = p1->p_addr->u_pcb;
- p2->p_addr->u_pcb.pcb_hw.apcb_usp = alpha_pal_rdusp();
- p2->p_addr->u_pcb.pcb_hw.apcb_flags &= ~ALPHA_PCB_FLAGS_FEN;
-
- /*
- * Set the floating point state.
- */
- if ((p2->p_addr->u_pcb.pcb_fp_control & IEEE_INHERIT) == 0) {
- p2->p_addr->u_pcb.pcb_fp_control = 0;
- p2->p_addr->u_pcb.pcb_fp.fpr_cr = (FPCR_DYN_NORMAL
- | FPCR_INVD | FPCR_DZED
- | FPCR_OVFD | FPCR_INED
- | FPCR_UNFD);
- }
-
- /*
- * Arrange for a non-local goto when the new process
- * is started, to resume here, returning nonzero from setjmp.
- */
-#ifdef DIAGNOSTIC
- if (p1 != curproc)
- panic("cpu_fork: curproc");
- alpha_fpstate_check(p1);
-#endif
-
- /*
- * create the child's kernel stack, from scratch.
- */
- {
- struct trapframe *p2tf;
-
- /*
- * Pick a stack pointer, leaving room for a trapframe;
- * copy trapframe from parent so return to user mode
- * will be to right address, with correct registers.
- */
- p2tf = p2->p_md.md_tf = (struct trapframe *)
- ((char *)p2->p_addr + USPACE - sizeof(struct trapframe));
- bcopy(p1->p_md.md_tf, p2->p_md.md_tf,
- sizeof(struct trapframe));
-
- /*
- * Set up return-value registers as fork() libc stub expects.
- */
- p2tf->tf_regs[FRAME_V0] = 0; /* child's pid (linux) */
- p2tf->tf_regs[FRAME_A3] = 0; /* no error */
- p2tf->tf_regs[FRAME_A4] = 1; /* is child (FreeBSD) */
-
- /*
- * Arrange for continuation at child_return(), which
- * will return to exception_return(). Note that the child
- * process doesn't stay in the kernel for long!
- *
- * This is an inlined version of cpu_set_kpc.
- */
- up->u_pcb.pcb_hw.apcb_ksp = (u_int64_t)p2tf;
- up->u_pcb.pcb_context[0] =
- (u_int64_t)child_return; /* s0: pc */
- up->u_pcb.pcb_context[1] =
- (u_int64_t)exception_return; /* s1: ra */
- up->u_pcb.pcb_context[2] = (u_long) p2; /* s2: a0 */
- up->u_pcb.pcb_context[7] =
- (u_int64_t)switch_trampoline; /* ra: assembly magic */
- }
-}
-
-/*
- * Intercept the return address from a freshly forked process that has NOT
- * been scheduled yet.
- *
- * This is needed to make kernel threads stay in kernel mode.
- */
-void
-cpu_set_fork_handler(p, func, arg)
- struct proc *p;
- void (*func) __P((void *));
- void *arg;
-{
- /*
- * Note that the trap frame follows the args, so the function
- * is really called like this: func(arg, frame);
- */
- p->p_addr->u_pcb.pcb_context[0] = (u_long) func;
- p->p_addr->u_pcb.pcb_context[2] = (u_long) arg;
-}
-
-/*
- * cpu_exit is called as the last action during exit.
- * We release the address space of the process, block interrupts,
- * and call switch_exit. switch_exit switches to proc0's PCB and stack,
- * then jumps into the middle of cpu_switch, as if it were switching
- * from proc0.
- */
-void
-cpu_exit(p)
- register struct proc *p;
-{
- alpha_fpstate_drop(p);
-
- (void) splhigh();
- cnt.v_swtch++;
- cpu_switch(p);
- panic("cpu_exit");
-}
-
-void
-cpu_wait(p)
- struct proc *p;
-{
- /* drop per-process resources */
- pmap_dispose_proc(p);
-
- /* and clean-out the vmspace */
- vmspace_free(p->p_vmspace);
-}
-
-/*
- * Dump the machine specific header information at the start of a core dump.
- */
-int
-cpu_coredump(p, vp, cred)
- struct proc *p;
- struct vnode *vp;
- struct ucred *cred;
-{
-
- return (vn_rdwr(UIO_WRITE, vp, (caddr_t) p->p_addr, ctob(UPAGES),
- (off_t)0, UIO_SYSSPACE, IO_NODELOCKED|IO_UNIT, cred, (int *)NULL,
- p));
-}
-
-#ifdef notyet
-static void
-setredzone(pte, vaddr)
- u_short *pte;
- caddr_t vaddr;
-{
-/* eventually do this by setting up an expand-down stack segment
- for ss0: selector, allowing stack access down to top of u.
- this means though that protection violations need to be handled
- thru a double fault exception that must do an integral task
- switch to a known good context, within which a dump can be
- taken. a sensible scheme might be to save the initial context
- used by sched (that has physical memory mapped 1:1 at bottom)
- and take the dump while still in mapped mode */
-}
-#endif
-
-/*
- * Map an IO request into kernel virtual address space.
- *
- * All requests are (re)mapped into kernel VA space.
- * Notice that we use b_bufsize for the size of the buffer
- * to be mapped. b_bcount might be modified by the driver.
- */
-void
-vmapbuf(bp)
- register struct buf *bp;
-{
- register caddr_t addr, v, kva;
- vm_offset_t pa;
-
- if ((bp->b_flags & B_PHYS) == 0)
- panic("vmapbuf");
-
- for (v = bp->b_saveaddr, addr = (caddr_t)trunc_page(bp->b_data);
- addr < bp->b_data + bp->b_bufsize;
- addr += PAGE_SIZE, v += PAGE_SIZE) {
- /*
- * Do the vm_fault if needed; do the copy-on-write thing
- * when reading stuff off device into memory.
- */
- vm_fault_quick(addr,
- (bp->b_flags&B_READ)?(VM_PROT_READ|VM_PROT_WRITE):VM_PROT_READ);
- pa = trunc_page(pmap_kextract((vm_offset_t) addr));
- if (pa == 0)
- panic("vmapbuf: page not present");
- vm_page_hold(PHYS_TO_VM_PAGE(pa));
- pmap_kenter((vm_offset_t) v, pa);
- }
-
- kva = bp->b_saveaddr;
- bp->b_saveaddr = bp->b_data;
- bp->b_data = kva + (((vm_offset_t) bp->b_data) & PAGE_MASK);
-}
-
-/*
- * Free the io map PTEs associated with this IO operation.
- * We also invalidate the TLB entries and restore the original b_addr.
- */
-void
-vunmapbuf(bp)
- register struct buf *bp;
-{
- register caddr_t addr;
- vm_offset_t pa;
-
- if ((bp->b_flags & B_PHYS) == 0)
- panic("vunmapbuf");
-
- for (addr = (caddr_t)trunc_page(bp->b_data);
- addr < bp->b_data + bp->b_bufsize;
- addr += PAGE_SIZE) {
- pa = trunc_page(pmap_kextract((vm_offset_t) addr));
- pmap_kremove((vm_offset_t) addr);
- vm_page_unhold(PHYS_TO_VM_PAGE(pa));
- }
-
- bp->b_data = bp->b_saveaddr;
-}
-
-/*
- * Force reset the processor by invalidating the entire address space!
- */
-void
-cpu_reset()
-{
- prom_halt(0);
-}
-
-int
-grow_stack(p, sp)
- struct proc *p;
- size_t sp;
-{
- int rv;
-
- rv = vm_map_growstack (p, sp);
- if (rv != KERN_SUCCESS)
- return (0);
-
- return (1);
-}
-
-
-static int cnt_prezero;
-
-SYSCTL_INT(_machdep, OID_AUTO, cnt_prezero, CTLFLAG_RD, &cnt_prezero, 0, "");
-
-/*
- * Implement the pre-zeroed page mechanism.
- * This routine is called from the idle loop.
- */
-
-#define ZIDLE_LO(v) ((v) * 2 / 3)
-#define ZIDLE_HI(v) ((v) * 4 / 5)
-
-int
-vm_page_zero_idle()
-{
- static int free_rover;
- static int zero_state;
- vm_page_t m;
- int s;
-
- /*
- * Attempt to maintain approximately 1/2 of our free pages in a
- * PG_ZERO'd state. Add some hysteresis to (attempt to) avoid
- * generally zeroing a page when the system is near steady-state.
- * Otherwise we might get 'flutter' during disk I/O / IPC or
- * fast sleeps. We also do not want to be continuously zeroing
- * pages because doing so may flush our L1 and L2 caches too much.
- */
-
- if (zero_state && vm_page_zero_count >= ZIDLE_LO(cnt.v_free_count))
- return(0);
- if (vm_page_zero_count >= ZIDLE_HI(cnt.v_free_count))
- return(0);
-
-#ifdef SMP
- if (try_mplock()) {
-#endif
- s = splvm();
- m = vm_page_list_find(PQ_FREE, free_rover, FALSE);
- zero_state = 0;
- if (m != NULL && (m->flags & PG_ZERO) == 0) {
- vm_page_queues[m->queue].lcnt--;
- TAILQ_REMOVE(&vm_page_queues[m->queue].pl, m, pageq);
- m->queue = PQ_NONE;
- splx(s);
-#if 0
- rel_mplock();
-#endif
- pmap_zero_page(VM_PAGE_TO_PHYS(m));
-#if 0
- get_mplock();
-#endif
- (void)splvm();
- vm_page_flag_set(m, PG_ZERO);
- m->queue = PQ_FREE + m->pc;
- vm_page_queues[m->queue].lcnt++;
- TAILQ_INSERT_TAIL(&vm_page_queues[m->queue].pl, m,
- pageq);
- ++vm_page_zero_count;
- ++cnt_prezero;
- if (vm_page_zero_count >= ZIDLE_HI(cnt.v_free_count))
- zero_state = 1;
- }
- free_rover = (free_rover + PQ_PRIME2) & PQ_L2_MASK;
- splx(s);
-#ifdef SMP
- rel_mplock();
-#endif
- return (1);
-#ifdef SMP
- }
-#endif
- return (0);
-}
-
-/*
- * Software interrupt handler for queued VM system processing.
- */
-void
-swi_vm()
-{
-#if 0
- if (busdma_swi_pending != 0)
- busdma_swi();
-#endif
-}
-
-/*
- * Tell whether this address is in some physical memory region.
- * Currently used by the kernel coredump code in order to avoid
- * dumping the ``ISA memory hole'' which could cause indefinite hangs,
- * or other unpredictable behaviour.
- */
-
-
-int
-is_physical_memory(addr)
- vm_offset_t addr;
-{
- /*
- * stuff other tests for known memory-mapped devices (PCI?)
- * here
- */
-
- return 1;
-}
diff --git a/sys/powerpc/include/_limits.h b/sys/powerpc/include/_limits.h
deleted file mode 100644
index 0d258ff9d94c..000000000000
--- a/sys/powerpc/include/_limits.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * 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. 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, Berkeley and its contributors.
- * 4. 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
- * $FreeBSD$
- */
-
-#ifndef _MACHINE_LIMITS_H_
-#define _MACHINE_LIMITS_H_
-
-#define CHAR_BIT 8 /* number of bits in a char */
-#define MB_LEN_MAX 6 /* Allow 31 bit UTF2 */
-
-/*
- * According to ANSI (section 2.2.4.2), the values below must be usable by
- * #if preprocessing directives. Additionally, the expression must have the
- * same type as would an expression that is an object of the corresponding
- * type converted according to the integral promotions. The subtraction for
- * INT_MIN and LONG_MIN is so the value is not unsigned; 2147483648 is an
- * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2).
- * These numbers work for pcc as well. The UINT_MAX and ULONG_MAX values
- * are written as hex so that GCC will be quiet about large integer constants.
- */
-#define SCHAR_MAX 127 /* min value for a signed char */
-#define SCHAR_MIN (-128) /* max value for a signed char */
-
-#define UCHAR_MAX 255 /* max value for an unsigned char */
-
-#ifdef __CHAR_UNSIGNED__
-#define CHAR_MAX UCHAR_MAX /* max value for a char */
-#define CHAR_MIN 0 /* min value for a char */
-#else
-#define CHAR_MAX SCHAR_MAX /* max value for a char */
-#define CHAR_MIN SCHAR_MIN /* min value for a char */
-#endif
-
-#define USHRT_MAX 65535 /* max value for an unsigned short */
-#define SHRT_MAX 32767 /* max value for a short */
-#define SHRT_MIN (-32768) /* min value for a short */
-
-#define UINT_MAX 0xffffffff /* max value for an unsigned int */
-#define INT_MAX 2147483647 /* max value for an int */
-#define INT_MIN (-2147483647-1) /* min value for an int */
-
-#define ULONG_MAX 0xffffffff /* max value for an unsigned long */
-#define LONG_MAX 2147483647 /* max value for a long */
-#define LONG_MIN (-2147483647-1) /* min value for a long */
-
-#if !defined(_ANSI_SOURCE)
-#define SSIZE_MAX INT_MAX /* max value for a ssize_t */
-
-#if !defined(_POSIX_SOURCE)
-#define SIZE_T_MAX UINT_MAX /* max value for a size_t */
-
-/* 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 /* !_POSIX_SOURCE */
-#endif /* !_ANSI_SOURCE */
-
-#endif /* !_MACHINE_LIMITS_H_ */
diff --git a/sys/powerpc/include/bootinfo.h b/sys/powerpc/include/bootinfo.h
deleted file mode 100644
index 86b7e7a729bb..000000000000
--- a/sys/powerpc/include/bootinfo.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/* $FreeBSD$ */
-/*
- * Copyright (c) 1994, 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.
- */
-
-/*
- * The boot program passes a pointer (in the boot environment virtual
- * address address space; "BEVA") to a bootinfo to the kernel using
- * the following convention:
- *
- * a0 contains first free page frame number
- * a1 contains page number of current level 1 page table
- * if a2 contains BOOTINFO_MAGIC and a4 is nonzero:
- * a3 contains pointer (BEVA) to bootinfo
- * a4 contains bootinfo version number
- * if a2 contains BOOTINFO_MAGIC and a4 contains 0 (backward compat):
- * a3 contains pointer (BEVA) to bootinfo version
- * (u_long), then the bootinfo
- */
-
-#define BOOTINFO_MAGIC 0xdeadbeeffeedface
-
-struct bootinfo_v1 {
- u_long ssym; /* 0: start of kernel sym table */
- u_long esym; /* 8: end of kernel sym table */
- char boot_flags[64]; /* 16: boot flags */
- char booted_kernel[64]; /* 80: name of booted kernel */
- void *hwrpb; /* 144: hwrpb pointer (BEVA) */
- u_long hwrpbsize; /* 152: size of hwrpb data */
- int (*cngetc) __P((void)); /* 160: console getc pointer */
- void (*cnputc) __P((int)); /* 168: console putc pointer */
- void (*cnpollc) __P((int)); /* 176: console pollc pointer */
- u_long pad[6]; /* 184: rsvd for future use */
- char *envp; /* 232: start of environment */
- u_long kernend; /* 240: end of kernel */
- u_long modptr; /* 248: FreeBSD module base */
- /* 256: total size */
-};
-
-/*
- * Kernel-internal structure used to hold important bits of boot
- * information. NOT to be used by boot blocks.
- *
- * Note that not all of the fields from the bootinfo struct(s)
- * passed by the boot blocks aren't here (because they're not currently
- * used by the kernel!). Fields here which aren't supplied by the
- * bootinfo structure passed by the boot blocks are supposed to be
- * filled in at startup with sane contents.
- */
-struct bootinfo_kernel {
- u_long ssym; /* start of syms */
- u_long esym; /* end of syms */
- u_long modptr; /* FreeBSD module pointer */
- u_long kernend; /* "end of kernel" from boot code */
- char *envp; /* "end of kernel" from boot code */
- u_long hwrpb_phys; /* hwrpb physical address */
- u_long hwrpb_size; /* size of hwrpb data */
- char boot_flags[64]; /* boot flags */
- char booted_kernel[64]; /* name of booted kernel */
- char booted_dev[64]; /* name of booted device */
-};
-
-extern struct bootinfo_kernel bootinfo;
diff --git a/sys/powerpc/include/clock.h b/sys/powerpc/include/clock.h
deleted file mode 100644
index a5f1b62430a1..000000000000
--- a/sys/powerpc/include/clock.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Kernel interface to machine-dependent clock driver.
- * Garrett Wollman, September 1994.
- * This file is in the public domain.
- *
- * $FreeBSD$
- */
-
-#ifndef _MACHINE_CLOCK_H_
-#define _MACHINE_CLOCK_H_
-
-#ifdef _KERNEL
-
-extern int disable_rtc_set;
-extern int wall_cmos_clock;
-extern int adjkerntz;
-
-void DELAY __P((int usec));
-int sysbeep __P((int pitch, int period));
-int acquire_timer2 __P((int mode));
-int release_timer2 __P((void));
-
-#endif
-
-#endif /* !_MACHINE_CLOCK_H_ */
diff --git a/sys/powerpc/include/limits.h b/sys/powerpc/include/limits.h
deleted file mode 100644
index 0d258ff9d94c..000000000000
--- a/sys/powerpc/include/limits.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * 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. 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, Berkeley and its contributors.
- * 4. 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
- * $FreeBSD$
- */
-
-#ifndef _MACHINE_LIMITS_H_
-#define _MACHINE_LIMITS_H_
-
-#define CHAR_BIT 8 /* number of bits in a char */
-#define MB_LEN_MAX 6 /* Allow 31 bit UTF2 */
-
-/*
- * According to ANSI (section 2.2.4.2), the values below must be usable by
- * #if preprocessing directives. Additionally, the expression must have the
- * same type as would an expression that is an object of the corresponding
- * type converted according to the integral promotions. The subtraction for
- * INT_MIN and LONG_MIN is so the value is not unsigned; 2147483648 is an
- * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2).
- * These numbers work for pcc as well. The UINT_MAX and ULONG_MAX values
- * are written as hex so that GCC will be quiet about large integer constants.
- */
-#define SCHAR_MAX 127 /* min value for a signed char */
-#define SCHAR_MIN (-128) /* max value for a signed char */
-
-#define UCHAR_MAX 255 /* max value for an unsigned char */
-
-#ifdef __CHAR_UNSIGNED__
-#define CHAR_MAX UCHAR_MAX /* max value for a char */
-#define CHAR_MIN 0 /* min value for a char */
-#else
-#define CHAR_MAX SCHAR_MAX /* max value for a char */
-#define CHAR_MIN SCHAR_MIN /* min value for a char */
-#endif
-
-#define USHRT_MAX 65535 /* max value for an unsigned short */
-#define SHRT_MAX 32767 /* max value for a short */
-#define SHRT_MIN (-32768) /* min value for a short */
-
-#define UINT_MAX 0xffffffff /* max value for an unsigned int */
-#define INT_MAX 2147483647 /* max value for an int */
-#define INT_MIN (-2147483647-1) /* min value for an int */
-
-#define ULONG_MAX 0xffffffff /* max value for an unsigned long */
-#define LONG_MAX 2147483647 /* max value for a long */
-#define LONG_MIN (-2147483647-1) /* min value for a long */
-
-#if !defined(_ANSI_SOURCE)
-#define SSIZE_MAX INT_MAX /* max value for a ssize_t */
-
-#if !defined(_POSIX_SOURCE)
-#define SIZE_T_MAX UINT_MAX /* max value for a size_t */
-
-/* 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 /* !_POSIX_SOURCE */
-#endif /* !_ANSI_SOURCE */
-
-#endif /* !_MACHINE_LIMITS_H_ */
diff --git a/sys/powerpc/include/md_var.h b/sys/powerpc/include/md_var.h
deleted file mode 100644
index bdcba94fa95d..000000000000
--- a/sys/powerpc/include/md_var.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*-
- * Copyright (c) 1998 Doug Rabson
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _MACHINE_MD_VAR_H_
-#define _MACHINE_MD_VAR_H_
-
-/*
- * Miscellaneous machine-dependent declarations.
- */
-
-extern char sigcode[];
-extern char esigcode[];
-extern int szsigcode;
-extern int Maxmem;
-extern void (*netisrs[32]) __P((void));
-
-struct fpreg;
-struct proc;
-struct reg;
-struct cam_sim;
-struct pcicfg;
-
-void busdma_swi __P((void));
-void cpu_halt __P((void));
-void cpu_reset __P((void));
-int is_physical_memory __P((vm_offset_t addr));
-void swi_vm __P((void));
-int vm_page_zero_idle __P((void));
-int fill_regs __P((struct proc *, struct reg *));
-int set_regs __P((struct proc *, struct reg *));
-int fill_fpregs __P((struct proc *, struct fpreg *));
-int set_fpregs __P((struct proc *, struct fpreg *));
-void alpha_register_pci_scsi __P((int bus, int slot, struct cam_sim *sim));
-#ifdef _SYS_BUS_H_
-struct resource *alpha_platform_alloc_ide_intr(int chan);
-int alpha_platform_release_ide_intr(int chan, struct resource *res);
-int alpha_platform_setup_ide_intr(struct resource *res,
- driver_intr_t *fn, void *arg,
- void **cookiep);
-int alpha_platform_teardown_ide_intr(struct resource *res, void *cookie);
-#endif
-void alpha_platform_assign_pciintr(struct pcicfg *cfg);
-
-#endif /* !_MACHINE_MD_VAR_H_ */
diff --git a/sys/powerpc/include/ptrace.h b/sys/powerpc/include/ptrace.h
deleted file mode 100644
index d59a38f3409b..000000000000
--- a/sys/powerpc/include/ptrace.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)ptrace.h 8.1 (Berkeley) 6/11/93
- * $FreeBSD$
- */
-
-#ifndef _MACHINE_PTRACE_H_
-#define _MACHINE_PTRACE_H_
-
-/*
- * Machine dependent trace commands.
- */
-#define PT_GETREGS (PT_FIRSTMACH + 1)
-#define PT_SETREGS (PT_FIRSTMACH + 2)
-#define PT_GETFPREGS (PT_FIRSTMACH + 3)
-#define PT_SETFPREGS (PT_FIRSTMACH + 4)
-#define PT_GETDBREGS (PT_FIRSTMACH + 5)
-#define PT_SETDBREGS (PT_FIRSTMACH + 6)
-
-#ifdef _KERNEL
-int ptrace_read_u_check __P((struct proc *p, vm_offset_t off, size_t len));
-#endif
-
-#endif
-
diff --git a/sys/powerpc/include/resource.h b/sys/powerpc/include/resource.h
deleted file mode 100644
index 28fcc98ea1be..000000000000
--- a/sys/powerpc/include/resource.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* $FreeBSD$ */
-/*
- * Copyright 1998 Massachusetts Institute of Technology
- *
- * Permission to use, copy, modify, and distribute this software and
- * its documentation for any purpose and without fee is hereby
- * granted, provided that both the above copyright notice and this
- * permission notice appear in all copies, that both the above
- * copyright notice and this permission notice appear in all
- * supporting documentation, and that the name of M.I.T. not be used
- * in advertising or publicity pertaining to distribution of the
- * software without specific, written prior permission. M.I.T. makes
- * no representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied
- * warranty.
- *
- * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS
- * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
- * SHALL M.I.T. 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_RESOURCE_H_
-#define _MACHINE_RESOURCE_H_ 1
-
-/*
- * Definitions of resource types for Intel Architecture machines
- * with support for legacy ISA devices and drivers.
- */
-
-#define SYS_RES_IRQ 1 /* interrupt lines */
-#define SYS_RES_DRQ 2 /* isa dma lines */
-#define SYS_RES_MEMORY 3 /* i/o memory */
-#define SYS_RES_IOPORT 4 /* i/o ports */
-
-#endif /* !_MACHINE_RESOURCE_H_ */
diff --git a/sys/powerpc/include/sigframe.h b/sys/powerpc/include/sigframe.h
deleted file mode 100644
index bc445a938a64..000000000000
--- a/sys/powerpc/include/sigframe.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*-
- * Copyright (c) 1999 Marcel Moolenaar
- * 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
- * in this position and unchanged.
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _MACHINE_SIGFRAME_H_
-#define _MACHINE_SIGFRAME_H_ 1
-
-struct osigframe {
- struct osigcontext sf_sc;
- osiginfo_t sf_si;
-};
-
-struct sigframe {
- unsigned long __spare__;
- ucontext_t sf_uc;
- siginfo_t sf_si;
-};
-
-#endif /* _MACHINE_SIGFRAME_H_ */
diff --git a/sys/powerpc/powerpc/elf_machdep.c b/sys/powerpc/powerpc/elf_machdep.c
deleted file mode 100644
index 5582fcb1337d..000000000000
--- a/sys/powerpc/powerpc/elf_machdep.c
+++ /dev/null
@@ -1,123 +0,0 @@
-/*-
- * Copyright 1996-1998 John D. Polstra.
- * 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/malloc.h>
-#include <sys/proc.h>
-#include <sys/namei.h>
-#include <sys/fcntl.h>
-#include <sys/vnode.h>
-#include <sys/linker.h>
-#include <machine/elf.h>
-
-/* Process one elf relocation with addend. */
-int
-elf_reloc(linker_file_t lf, const void *data, int type, const char *sym)
-{
- Elf_Addr relocbase = (Elf_Addr) lf->address;
- Elf_Addr *where;
- Elf_Addr addr;
- Elf_Addr addend;
- Elf_Word rtype;
- const Elf_Rel *rel;
- const Elf_Rela *rela;
-
- switch (type) {
- case ELF_RELOC_REL:
- rel = (const Elf_Rel *)data;
- where = (Elf_Addr *) (relocbase + rel->r_offset);
- addend = *where;
- rtype = ELF_R_TYPE(rel->r_info);
- break;
- case ELF_RELOC_RELA:
- rela = (const Elf_Rela *)data;
- where = (Elf_Addr *) (relocbase + rela->r_offset);
- addend = rela->r_addend;
- rtype = ELF_R_TYPE(rela->r_info);
- break;
- default:
- panic("elf_reloc: unknown relocation mode %d\n", type);
- }
-
- switch (rtype) {
-
- case R_ALPHA_NONE:
- break;
-
- case R_ALPHA_REFQUAD:
- addr = (Elf_Addr)
- linker_file_lookup_symbol(lf, sym, 1);
- if (addr == NULL)
- return -1;
- addr += addend;
- if (*where != addr)
- *where = addr;
- break;
-
- case R_ALPHA_GLOB_DAT:
- addr = (Elf_Addr)
- linker_file_lookup_symbol(lf, sym, 1);
- if (addr == NULL)
- return -1;
- addr += addend;
- if (*where != addr)
- *where = addr;
- break;
-
- case R_ALPHA_JMP_SLOT:
- /* No point in lazy binding for kernel modules. */
- addr = (Elf_Addr)
- linker_file_lookup_symbol(lf, sym, 1);
- if (addr == NULL)
- return -1;
- if (*where != addr)
- *where = addr;
- break;
-
- case R_ALPHA_RELATIVE:
- addr = relocbase + addend + *where;
- if (*where != addr)
- *where = addr;
- break;
-
- case R_ALPHA_COPY:
- /*
- * There shouldn't be copy relocations in kernel
- * objects.
- */
- printf("kldload: unexpected R_COPY relocation\n");
- return -1;
-
- default:
- printf("kldload: unexpected relocation type %d\n",
- (int) rtype);
- return -1;
- }
- return(0);
-}
diff --git a/sys/powerpc/powerpc/genassym.c b/sys/powerpc/powerpc/genassym.c
deleted file mode 100644
index e3c5028e9e69..000000000000
--- a/sys/powerpc/powerpc/genassym.c
+++ /dev/null
@@ -1,156 +0,0 @@
-/*-
- * Copyright (c) 1982, 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)genassym.c 5.11 (Berkeley) 5/10/91
- * $FreeBSD$
- */
-
-#include <stddef.h>
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/assym.h>
-#include <sys/proc.h>
-#include <sys/buf.h>
-#include <sys/errno.h>
-#include <sys/proc.h>
-#include <sys/mount.h>
-#include <sys/socket.h>
-#include <sys/resource.h>
-#include <sys/resourcevar.h>
-#include <machine/frame.h>
-#include <machine/chipset.h>
-#include <sys/vmmeter.h>
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <vm/pmap.h>
-#include <vm/vm_map.h>
-#include <sys/user.h>
-#include <net/if.h>
-#include <netinet/in.h>
-#include <nfs/nfsv2.h>
-#include <nfs/rpcv2.h>
-#include <nfs/nfs.h>
-#include <nfs/nfsdiskless.h>
-
-ASSYM(P_ADDR, offsetof(struct proc, p_addr));
-ASSYM(P_MD_FLAGS, offsetof(struct proc, p_md.md_flags));
-ASSYM(P_MD_PCBPADDR, offsetof(struct proc, p_md.md_pcbpaddr));
-ASSYM(P_MD_HAE, offsetof(struct proc, p_md.md_hae));
-ASSYM(MDP_HAEUSED, MDP_HAEUSED);
-
-ASSYM(CHIPSET_WRITE_HAE, offsetof(struct alpha_chipset, write_hae));
-
-ASSYM(VM_MAXUSER_ADDRESS, VM_MAXUSER_ADDRESS);
-ASSYM(PTLEV1I, PTLEV1I);
-ASSYM(PTESIZE, PTESIZE);
-
-ASSYM(U_PCB_ONFAULT, offsetof(struct user, u_pcb.pcb_onfault));
-ASSYM(U_PCB_HWPCB_KSP, offsetof(struct user, u_pcb.pcb_hw.apcb_ksp));
-ASSYM(U_PCB_CONTEXT, offsetof(struct user, u_pcb.pcb_context));
-
-ASSYM(PCB_HW, offsetof(struct pcb, pcb_hw));
-
-ASSYM(FPREG_FPR_REGS, offsetof(struct fpreg, fpr_regs));
-ASSYM(FPREG_FPR_CR, offsetof(struct fpreg, fpr_cr));
-
-ASSYM(EFAULT, EFAULT);
-ASSYM(ENAMETOOLONG, ENAMETOOLONG);
-
-/* Register offsets, for stack frames. */
-ASSYM(FRAME_V0, FRAME_V0);
-ASSYM(FRAME_T0, FRAME_T0);
-ASSYM(FRAME_T1, FRAME_T1);
-ASSYM(FRAME_T2, FRAME_T2);
-ASSYM(FRAME_T3, FRAME_T3);
-ASSYM(FRAME_T4, FRAME_T4);
-ASSYM(FRAME_T5, FRAME_T5);
-ASSYM(FRAME_T6, FRAME_T6);
-ASSYM(FRAME_T7, FRAME_T7);
-ASSYM(FRAME_S0, FRAME_S0);
-ASSYM(FRAME_S1, FRAME_S1);
-ASSYM(FRAME_S2, FRAME_S2);
-ASSYM(FRAME_S3, FRAME_S3);
-ASSYM(FRAME_S4, FRAME_S4);
-ASSYM(FRAME_S5, FRAME_S5);
-ASSYM(FRAME_S6, FRAME_S6);
-ASSYM(FRAME_A3, FRAME_A3);
-ASSYM(FRAME_A4, FRAME_A4);
-ASSYM(FRAME_A5, FRAME_A5);
-ASSYM(FRAME_T8, FRAME_T8);
-ASSYM(FRAME_T9, FRAME_T9);
-ASSYM(FRAME_T10, FRAME_T10);
-ASSYM(FRAME_T11, FRAME_T11);
-ASSYM(FRAME_RA, FRAME_RA);
-ASSYM(FRAME_T12, FRAME_T12);
-ASSYM(FRAME_AT, FRAME_AT);
-ASSYM(FRAME_SP, FRAME_SP);
-
-ASSYM(FRAME_SW_SIZE, FRAME_SW_SIZE);
-
-ASSYM(FRAME_PS, FRAME_PS);
-ASSYM(FRAME_PC, FRAME_PC);
-ASSYM(FRAME_GP, FRAME_GP);
-ASSYM(FRAME_A0, FRAME_A0);
-ASSYM(FRAME_A1, FRAME_A1);
-ASSYM(FRAME_A2, FRAME_A2);
-
-ASSYM(FRAME_SIZE, FRAME_SIZE);
-
-/* bits of the PS register */
-ASSYM(ALPHA_PSL_USERMODE, ALPHA_PSL_USERMODE);
-ASSYM(ALPHA_PSL_IPL_MASK, ALPHA_PSL_IPL_MASK);
-ASSYM(ALPHA_PSL_IPL_0, ALPHA_PSL_IPL_0);
-ASSYM(ALPHA_PSL_IPL_SOFT, ALPHA_PSL_IPL_SOFT);
-ASSYM(ALPHA_PSL_IPL_HIGH, ALPHA_PSL_IPL_HIGH);
-
-/* pte bits */
-ASSYM(ALPHA_L1SHIFT, ALPHA_L1SHIFT);
-ASSYM(ALPHA_L2SHIFT, ALPHA_L2SHIFT);
-ASSYM(ALPHA_L3SHIFT, ALPHA_L3SHIFT);
-ASSYM(ALPHA_K1SEG_BASE, ALPHA_K1SEG_BASE);
-ASSYM(ALPHA_PTE_VALID, ALPHA_PTE_VALID);
-ASSYM(ALPHA_PTE_ASM, ALPHA_PTE_ASM);
-ASSYM(ALPHA_PTE_KR, ALPHA_PTE_KR);
-ASSYM(ALPHA_PTE_KW, ALPHA_PTE_KW);
-
-/* Kernel entries */
-ASSYM(ALPHA_KENTRY_ARITH, ALPHA_KENTRY_ARITH);
-ASSYM(ALPHA_KENTRY_MM, ALPHA_KENTRY_MM);
-
-ASSYM(ALPHA_KENTRY_IF, ALPHA_KENTRY_IF);
-ASSYM(ALPHA_KENTRY_UNA, ALPHA_KENTRY_UNA);
-
-ASSYM(VPTBASE, VPTBASE);
diff --git a/sys/powerpc/powerpc/procfs_machdep.c b/sys/powerpc/powerpc/procfs_machdep.c
deleted file mode 100644
index 000eb02a0a7f..000000000000
--- a/sys/powerpc/powerpc/procfs_machdep.c
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright (c) 1993
- * The Regents of the University of California. All rights reserved.
- * Copyright (c) 1993 Jan-Simon Pendry
- *
- * This code is derived from software contributed to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)procfs_machdep.c 8.3 (Berkeley) 1/27/94
- *
- * From:
- * $FreeBSD$
- */
-
-/*
- * Functions to be implemented here are:
- *
- * procfs_read_regs(proc, regs)
- * Get the current user-visible register set from the process
- * and copy it into the regs structure (<machine/reg.h>).
- * The process is stopped at the time read_regs is called.
- *
- * procfs_write_regs(proc, regs)
- * Update the current register set from the passed in regs
- * structure. Take care to avoid clobbering special CPU
- * registers or privileged bits in the PSL.
- * Depending on the architecture this may have fix-up work to do,
- * especially if the IAR or PCW are modified.
- * The process is stopped at the time write_regs is called.
- *
- * procfs_read_fpregs, procfs_write_fpregs
- * deal with the floating point register set, otherwise as above.
- *
- * procfs_sstep(proc)
- * Arrange for the process to trap after executing a single instruction.
- *
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/proc.h>
-#include <sys/ptrace.h>
-#include <sys/vnode.h>
-#include <machine/reg.h>
-#include <machine/md_var.h>
-#include <miscfs/procfs/procfs.h>
-
-#include <vm/vm.h>
-#include <sys/lock.h>
-#include <vm/pmap.h>
-#include <vm/vm_map.h>
-
-#include <sys/user.h>
-
-int
-procfs_read_regs(p, regs)
- struct proc *p;
- struct reg *regs;
-{
- if ((p->p_flag & P_INMEM) == 0)
- return (EIO);
- return (fill_regs(p, regs));
-}
-
-int
-procfs_write_regs(p, regs)
- struct proc *p;
- struct reg *regs;
-{
- if ((p->p_flag & P_INMEM) == 0)
- return (EIO);
- return (set_regs(p, regs));
-}
-
-/*
- * Ptrace doesn't support fpregs at all, and there are no security holes
- * or translations for fpregs, so we can just copy them.
- */
-
-int
-procfs_read_fpregs(p, fpregs)
- struct proc *p;
- struct fpreg *fpregs;
-{
- if ((p->p_flag & P_INMEM) == 0)
- return (EIO);
- return (fill_fpregs(p, fpregs));
-}
-
-int
-procfs_write_fpregs(p, fpregs)
- struct proc *p;
- struct fpreg *fpregs;
-{
- if ((p->p_flag & P_INMEM) == 0)
- return (EIO);
- return (set_fpregs(p, fpregs));
-}
-
-int
-procfs_sstep(p)
- struct proc *p;
-{
- return (EINVAL);
-}
-
-/*
- * Placeholders
- */
-int
-procfs_read_dbregs(p, dbregs)
- struct proc *p;
- struct dbreg *dbregs;
-{
- return (EIO);
-}
-
-int
-procfs_write_dbregs(p, dbregs)
- struct proc *p;
- struct dbreg *dbregs;
-{
- return (EIO);
-}
diff --git a/sys/powerpc/powerpc/vm_machdep.c b/sys/powerpc/powerpc/vm_machdep.c
deleted file mode 100644
index bb2bbfdd0c9a..000000000000
--- a/sys/powerpc/powerpc/vm_machdep.c
+++ /dev/null
@@ -1,489 +0,0 @@
-/*-
- * Copyright (c) 1982, 1986 The Regents of the University of California.
- * Copyright (c) 1989, 1990 William Jolitz
- * Copyright (c) 1994 John Dyson
- * 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, and William Jolitz.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91
- * Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$
- * $FreeBSD$
- */
-/*
- * Copyright (c) 1994, 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.
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/proc.h>
-#include <sys/malloc.h>
-#include <sys/buf.h>
-#include <sys/vnode.h>
-#include <sys/vmmeter.h>
-#include <sys/kernel.h>
-#include <sys/sysctl.h>
-#include <sys/unistd.h>
-
-#include <machine/clock.h>
-#include <machine/cpu.h>
-#include <machine/fpu.h>
-#include <machine/md_var.h>
-#include <machine/prom.h>
-
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <sys/lock.h>
-#include <vm/vm_kern.h>
-#include <vm/vm_page.h>
-#include <vm/vm_map.h>
-#include <vm/vm_extern.h>
-
-#include <sys/user.h>
-
-/*
- * quick version of vm_fault
- */
-int
-vm_fault_quick(v, prot)
- caddr_t v;
- int prot;
-{
- int r;
- if (prot & VM_PROT_WRITE)
- r = subyte(v, fubyte(v));
- else
- r = fubyte(v);
- return(r);
-}
-
-/*
- * Finish a fork operation, with process p2 nearly set up.
- * Copy and update the pcb, set up the stack so that the child
- * ready to run and return to user mode.
- */
-void
-cpu_fork(p1, p2, flags)
- register struct proc *p1, *p2;
- int flags;
-{
- struct user *up = p2->p_addr;
-
- if ((flags & RFPROC) == 0)
- return;
-
- p2->p_md.md_tf = p1->p_md.md_tf;
- p2->p_md.md_flags = p1->p_md.md_flags & (MDP_FPUSED | MDP_UAC_MASK);
-
- /*
- * Cache the physical address of the pcb, so we can
- * swap to it easily.
- */
- p2->p_md.md_pcbpaddr = (void*) vtophys((vm_offset_t) &up->u_pcb);
-
- /*
- * Copy floating point state from the FP chip to the PCB
- * if this process has state stored there.
- */
- alpha_fpstate_save(p1, 0);
-
- /*
- * Copy pcb and stack from proc p1 to p2. We do this as
- * cheaply as possible, copying only the active part of the
- * stack. The stack and pcb need to agree. Make sure that the
- * new process has FEN disabled.
- */
- p2->p_addr->u_pcb = p1->p_addr->u_pcb;
- p2->p_addr->u_pcb.pcb_hw.apcb_usp = alpha_pal_rdusp();
- p2->p_addr->u_pcb.pcb_hw.apcb_flags &= ~ALPHA_PCB_FLAGS_FEN;
-
- /*
- * Set the floating point state.
- */
- if ((p2->p_addr->u_pcb.pcb_fp_control & IEEE_INHERIT) == 0) {
- p2->p_addr->u_pcb.pcb_fp_control = 0;
- p2->p_addr->u_pcb.pcb_fp.fpr_cr = (FPCR_DYN_NORMAL
- | FPCR_INVD | FPCR_DZED
- | FPCR_OVFD | FPCR_INED
- | FPCR_UNFD);
- }
-
- /*
- * Arrange for a non-local goto when the new process
- * is started, to resume here, returning nonzero from setjmp.
- */
-#ifdef DIAGNOSTIC
- if (p1 != curproc)
- panic("cpu_fork: curproc");
- alpha_fpstate_check(p1);
-#endif
-
- /*
- * create the child's kernel stack, from scratch.
- */
- {
- struct trapframe *p2tf;
-
- /*
- * Pick a stack pointer, leaving room for a trapframe;
- * copy trapframe from parent so return to user mode
- * will be to right address, with correct registers.
- */
- p2tf = p2->p_md.md_tf = (struct trapframe *)
- ((char *)p2->p_addr + USPACE - sizeof(struct trapframe));
- bcopy(p1->p_md.md_tf, p2->p_md.md_tf,
- sizeof(struct trapframe));
-
- /*
- * Set up return-value registers as fork() libc stub expects.
- */
- p2tf->tf_regs[FRAME_V0] = 0; /* child's pid (linux) */
- p2tf->tf_regs[FRAME_A3] = 0; /* no error */
- p2tf->tf_regs[FRAME_A4] = 1; /* is child (FreeBSD) */
-
- /*
- * Arrange for continuation at child_return(), which
- * will return to exception_return(). Note that the child
- * process doesn't stay in the kernel for long!
- *
- * This is an inlined version of cpu_set_kpc.
- */
- up->u_pcb.pcb_hw.apcb_ksp = (u_int64_t)p2tf;
- up->u_pcb.pcb_context[0] =
- (u_int64_t)child_return; /* s0: pc */
- up->u_pcb.pcb_context[1] =
- (u_int64_t)exception_return; /* s1: ra */
- up->u_pcb.pcb_context[2] = (u_long) p2; /* s2: a0 */
- up->u_pcb.pcb_context[7] =
- (u_int64_t)switch_trampoline; /* ra: assembly magic */
- }
-}
-
-/*
- * Intercept the return address from a freshly forked process that has NOT
- * been scheduled yet.
- *
- * This is needed to make kernel threads stay in kernel mode.
- */
-void
-cpu_set_fork_handler(p, func, arg)
- struct proc *p;
- void (*func) __P((void *));
- void *arg;
-{
- /*
- * Note that the trap frame follows the args, so the function
- * is really called like this: func(arg, frame);
- */
- p->p_addr->u_pcb.pcb_context[0] = (u_long) func;
- p->p_addr->u_pcb.pcb_context[2] = (u_long) arg;
-}
-
-/*
- * cpu_exit is called as the last action during exit.
- * We release the address space of the process, block interrupts,
- * and call switch_exit. switch_exit switches to proc0's PCB and stack,
- * then jumps into the middle of cpu_switch, as if it were switching
- * from proc0.
- */
-void
-cpu_exit(p)
- register struct proc *p;
-{
- alpha_fpstate_drop(p);
-
- (void) splhigh();
- cnt.v_swtch++;
- cpu_switch(p);
- panic("cpu_exit");
-}
-
-void
-cpu_wait(p)
- struct proc *p;
-{
- /* drop per-process resources */
- pmap_dispose_proc(p);
-
- /* and clean-out the vmspace */
- vmspace_free(p->p_vmspace);
-}
-
-/*
- * Dump the machine specific header information at the start of a core dump.
- */
-int
-cpu_coredump(p, vp, cred)
- struct proc *p;
- struct vnode *vp;
- struct ucred *cred;
-{
-
- return (vn_rdwr(UIO_WRITE, vp, (caddr_t) p->p_addr, ctob(UPAGES),
- (off_t)0, UIO_SYSSPACE, IO_NODELOCKED|IO_UNIT, cred, (int *)NULL,
- p));
-}
-
-#ifdef notyet
-static void
-setredzone(pte, vaddr)
- u_short *pte;
- caddr_t vaddr;
-{
-/* eventually do this by setting up an expand-down stack segment
- for ss0: selector, allowing stack access down to top of u.
- this means though that protection violations need to be handled
- thru a double fault exception that must do an integral task
- switch to a known good context, within which a dump can be
- taken. a sensible scheme might be to save the initial context
- used by sched (that has physical memory mapped 1:1 at bottom)
- and take the dump while still in mapped mode */
-}
-#endif
-
-/*
- * Map an IO request into kernel virtual address space.
- *
- * All requests are (re)mapped into kernel VA space.
- * Notice that we use b_bufsize for the size of the buffer
- * to be mapped. b_bcount might be modified by the driver.
- */
-void
-vmapbuf(bp)
- register struct buf *bp;
-{
- register caddr_t addr, v, kva;
- vm_offset_t pa;
-
- if ((bp->b_flags & B_PHYS) == 0)
- panic("vmapbuf");
-
- for (v = bp->b_saveaddr, addr = (caddr_t)trunc_page(bp->b_data);
- addr < bp->b_data + bp->b_bufsize;
- addr += PAGE_SIZE, v += PAGE_SIZE) {
- /*
- * Do the vm_fault if needed; do the copy-on-write thing
- * when reading stuff off device into memory.
- */
- vm_fault_quick(addr,
- (bp->b_flags&B_READ)?(VM_PROT_READ|VM_PROT_WRITE):VM_PROT_READ);
- pa = trunc_page(pmap_kextract((vm_offset_t) addr));
- if (pa == 0)
- panic("vmapbuf: page not present");
- vm_page_hold(PHYS_TO_VM_PAGE(pa));
- pmap_kenter((vm_offset_t) v, pa);
- }
-
- kva = bp->b_saveaddr;
- bp->b_saveaddr = bp->b_data;
- bp->b_data = kva + (((vm_offset_t) bp->b_data) & PAGE_MASK);
-}
-
-/*
- * Free the io map PTEs associated with this IO operation.
- * We also invalidate the TLB entries and restore the original b_addr.
- */
-void
-vunmapbuf(bp)
- register struct buf *bp;
-{
- register caddr_t addr;
- vm_offset_t pa;
-
- if ((bp->b_flags & B_PHYS) == 0)
- panic("vunmapbuf");
-
- for (addr = (caddr_t)trunc_page(bp->b_data);
- addr < bp->b_data + bp->b_bufsize;
- addr += PAGE_SIZE) {
- pa = trunc_page(pmap_kextract((vm_offset_t) addr));
- pmap_kremove((vm_offset_t) addr);
- vm_page_unhold(PHYS_TO_VM_PAGE(pa));
- }
-
- bp->b_data = bp->b_saveaddr;
-}
-
-/*
- * Force reset the processor by invalidating the entire address space!
- */
-void
-cpu_reset()
-{
- prom_halt(0);
-}
-
-int
-grow_stack(p, sp)
- struct proc *p;
- size_t sp;
-{
- int rv;
-
- rv = vm_map_growstack (p, sp);
- if (rv != KERN_SUCCESS)
- return (0);
-
- return (1);
-}
-
-
-static int cnt_prezero;
-
-SYSCTL_INT(_machdep, OID_AUTO, cnt_prezero, CTLFLAG_RD, &cnt_prezero, 0, "");
-
-/*
- * Implement the pre-zeroed page mechanism.
- * This routine is called from the idle loop.
- */
-
-#define ZIDLE_LO(v) ((v) * 2 / 3)
-#define ZIDLE_HI(v) ((v) * 4 / 5)
-
-int
-vm_page_zero_idle()
-{
- static int free_rover;
- static int zero_state;
- vm_page_t m;
- int s;
-
- /*
- * Attempt to maintain approximately 1/2 of our free pages in a
- * PG_ZERO'd state. Add some hysteresis to (attempt to) avoid
- * generally zeroing a page when the system is near steady-state.
- * Otherwise we might get 'flutter' during disk I/O / IPC or
- * fast sleeps. We also do not want to be continuously zeroing
- * pages because doing so may flush our L1 and L2 caches too much.
- */
-
- if (zero_state && vm_page_zero_count >= ZIDLE_LO(cnt.v_free_count))
- return(0);
- if (vm_page_zero_count >= ZIDLE_HI(cnt.v_free_count))
- return(0);
-
-#ifdef SMP
- if (try_mplock()) {
-#endif
- s = splvm();
- m = vm_page_list_find(PQ_FREE, free_rover, FALSE);
- zero_state = 0;
- if (m != NULL && (m->flags & PG_ZERO) == 0) {
- vm_page_queues[m->queue].lcnt--;
- TAILQ_REMOVE(&vm_page_queues[m->queue].pl, m, pageq);
- m->queue = PQ_NONE;
- splx(s);
-#if 0
- rel_mplock();
-#endif
- pmap_zero_page(VM_PAGE_TO_PHYS(m));
-#if 0
- get_mplock();
-#endif
- (void)splvm();
- vm_page_flag_set(m, PG_ZERO);
- m->queue = PQ_FREE + m->pc;
- vm_page_queues[m->queue].lcnt++;
- TAILQ_INSERT_TAIL(&vm_page_queues[m->queue].pl, m,
- pageq);
- ++vm_page_zero_count;
- ++cnt_prezero;
- if (vm_page_zero_count >= ZIDLE_HI(cnt.v_free_count))
- zero_state = 1;
- }
- free_rover = (free_rover + PQ_PRIME2) & PQ_L2_MASK;
- splx(s);
-#ifdef SMP
- rel_mplock();
-#endif
- return (1);
-#ifdef SMP
- }
-#endif
- return (0);
-}
-
-/*
- * Software interrupt handler for queued VM system processing.
- */
-void
-swi_vm()
-{
-#if 0
- if (busdma_swi_pending != 0)
- busdma_swi();
-#endif
-}
-
-/*
- * Tell whether this address is in some physical memory region.
- * Currently used by the kernel coredump code in order to avoid
- * dumping the ``ISA memory hole'' which could cause indefinite hangs,
- * or other unpredictable behaviour.
- */
-
-
-int
-is_physical_memory(addr)
- vm_offset_t addr;
-{
- /*
- * stuff other tests for known memory-mapped devices (PCI?)
- * here
- */
-
- return 1;
-}
diff --git a/sys/rpc/types.h b/sys/rpc/types.h
deleted file mode 100644
index e2ceec5b3df7..000000000000
--- a/sys/rpc/types.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
- *
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
- *
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
- *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
- *
- * from: @(#)types.h 1.18 87/07/24 SMI
- * from: @(#)types.h 2.3 88/08/15 4.0 RPCSRC
- * $FreeBSD$
- */
-
-/*
- * Rpc additions to <sys/types.h>
- */
-#ifndef _RPC_TYPES_H
-#define _RPC_TYPES_H
-
-#define bool_t int32_t
-#define enum_t int32_t
-#define __dontcare__ -1
-
-#ifndef FALSE
-# define FALSE (0)
-#endif
-#ifndef TRUE
-# define TRUE (1)
-#endif
-#ifndef NULL
-# define NULL 0
-#endif
-
-#define mem_alloc(bsize) malloc(bsize)
-#define mem_free(ptr, bsize) free(ptr)
-
-#ifndef makedev /* ie, we haven't already included it */
-#include <sys/types.h>
-#endif
-#include <sys/time.h>
-
-#endif /* !_RPC_TYPES_H */
diff --git a/sys/sys/_sigset.h b/sys/sys/_sigset.h
deleted file mode 100644
index 2e405a2d03cc..000000000000
--- a/sys/sys/_sigset.h
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * Copyright (c) 1982, 1986, 1989, 1991, 1993
- * The Regents of the University of California. All rights reserved.
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)signal.h 8.4 (Berkeley) 5/4/95
- * $FreeBSD$
- */
-
-#ifndef _SYS_SIGNAL_H_
-#define _SYS_SIGNAL_H_
-
-#include <sys/cdefs.h>
-#include <sys/_posix.h>
-
-/*
- * sigset_t macros.
- */
-#define _SIG_WORDS 4
-#define _SIG_MAXSIG 128
-#define _SIG_IDX(sig) ((sig) - 1)
-#define _SIG_WORD(sig) (_SIG_IDX(sig) >> 5)
-#define _SIG_BIT(sig) (1 << (_SIG_IDX(sig) & 31))
-
-/*
- * System defined signals.
- */
-#define SIGHUP 1 /* hangup */
-#define SIGINT 2 /* interrupt */
-#define SIGQUIT 3 /* quit */
-#define SIGILL 4 /* illegal instr. (not reset when caught) */
-#ifndef _POSIX_SOURCE
-#define SIGTRAP 5 /* trace trap (not reset when caught) */
-#endif
-#define SIGABRT 6 /* abort() */
-#ifndef _POSIX_SOURCE
-#define SIGIOT SIGABRT /* compatibility */
-#define SIGEMT 7 /* EMT instruction */
-#endif
-#define SIGFPE 8 /* floating point exception */
-#define SIGKILL 9 /* kill (cannot be caught or ignored) */
-#ifndef _POSIX_SOURCE
-#define SIGBUS 10 /* bus error */
-#endif
-#define SIGSEGV 11 /* segmentation violation */
-#ifndef _POSIX_SOURCE
-#define SIGSYS 12 /* non-existent system call invoked */
-#endif
-#define SIGPIPE 13 /* write on a pipe with no one to read it */
-#define SIGALRM 14 /* alarm clock */
-#define SIGTERM 15 /* software termination signal from kill */
-#ifndef _POSIX_SOURCE
-#define SIGURG 16 /* urgent condition on IO channel */
-#endif
-#define SIGSTOP 17 /* sendable stop signal not from tty */
-#define SIGTSTP 18 /* stop signal from tty */
-#define SIGCONT 19 /* continue a stopped process */
-#define SIGCHLD 20 /* to parent on child stop or exit */
-#define SIGTTIN 21 /* to readers pgrp upon background tty read */
-#define SIGTTOU 22 /* like TTIN if (tp->t_local&LTOSTOP) */
-#ifndef _POSIX_SOURCE
-#define SIGIO 23 /* input/output possible signal */
-#define SIGXCPU 24 /* exceeded CPU time limit */
-#define SIGXFSZ 25 /* exceeded file size limit */
-#define SIGVTALRM 26 /* virtual time alarm */
-#define SIGPROF 27 /* profiling time alarm */
-#define SIGWINCH 28 /* window size changes */
-#define SIGINFO 29 /* information request */
-#endif
-#define SIGUSR1 30 /* user defined signal 1 */
-#define SIGUSR2 31 /* user defined signal 2 */
-
-/*-
- * Type of a signal handling function.
- *
- * Language spec sez signal handlers take exactly one arg, even though we
- * actually supply three. Ugh!
- *
- * We don't try to hide the difference by leaving out the args because
- * that would cause warnings about conformant programs. Nonconformant
- * programs can avoid the warnings by casting to (__sighandler_t *) or
- * sig_t before calling signal() or assigning to sa_handler or sv_handler.
- *
- * The kernel should reverse the cast before calling the function. It
- * has no way to do this, but on most machines 1-arg and 3-arg functions
- * have the same calling protocol so there is no problem in practice.
- * A bit in sa_flags could be used to specify the number of args.
- */
-typedef void __sighandler_t __P((int));
-
-#define SIG_DFL ((__sighandler_t *)0)
-#define SIG_IGN ((__sighandler_t *)1)
-#define SIG_ERR ((__sighandler_t *)-1)
-
-#if defined(_P1003_1B_VISIBLE) || defined(_KERNEL)
-union sigval {
- /* Members as suggested by Annex C of POSIX 1003.1b. */
- int sigval_int;
- void *sigval_ptr;
-};
-
-struct sigevent {
- int sigev_notify; /* Notification type */
- int sigev_signo; /* Signal number */
- union sigval sigev_value; /* Signal value */
-};
-
-#define SIGEV_NONE 0 /* No async notification */
-#define SIGEV_SIGNAL 1 /* Generate a queued signal */
-
-typedef struct __siginfo {
- int si_signo; /* signal number */
- int si_errno; /* errno association */
- /*
- * Cause of signal, one of the SI_ macros or signal-specific
- * values, i.e. one of the FPE_... values for SIGFPE. This
- * value is equivalent to the second argument to an old-style
- * FreeBSD signal handler.
- */
- int si_code; /* signal code */
- int si_pid; /* sending process */
- unsigned int si_uid; /* sender's ruid */
- int si_status; /* exit value */
- void *si_addr; /* faulting instruction */
- union sigval si_value; /* signal value */
- long si_band; /* band event for SIGPOLL */
- int __spare__[7]; /* gimme some slack */
-} siginfo_t;
-#endif /* _P1003_1B_VISIBLE */
-
-typedef struct __sigset {
- unsigned int __bits[_SIG_WORDS];
-} sigset_t;
-
-/*
- * XXX - there are some nasty dependencies on include file order. Now that
- * sigset_t has been defined we can include the MD header.
- */
-#include <machine/signal.h> /* sig_atomic_t; trap codes; sigcontext */
-
-#if !defined(_ANSI_SOURCE)
-
-struct __siginfo;
-
-/*
- * Signal vector "template" used in sigaction call.
- */
-struct sigaction {
- union {
- void (*__sa_handler) __P((int));
- void (*__sa_sigaction) __P((int, struct __siginfo *,
- void *));
- } __sigaction_u; /* signal handler */
- int sa_flags; /* see signal options below */
- sigset_t sa_mask; /* signal mask to apply */
-};
-
-/* if SA_SIGINFO is set, sa_sigaction is to be used instead of sa_handler. */
-#define sa_handler __sigaction_u.__sa_handler
-
-#define SA_NOCLDSTOP 0x0008 /* do not generate SIGCHLD on child stop */
-
-#if !defined(_POSIX_SOURCE)
-
-#define sa_sigaction __sigaction_u.__sa_sigaction
-
-#define SA_ONSTACK 0x0001 /* take signal on signal stack */
-#define SA_RESTART 0x0002 /* restart system call on signal return */
-#define SA_RESETHAND 0x0004 /* reset to SIG_DFL when taking signal */
-#define SA_NODEFER 0x0010 /* don't mask the signal we're delivering */
-#define SA_NOCLDWAIT 0x0020 /* don't keep zombies around */
-#define SA_SIGINFO 0x0040 /* signal handler with SA_SIGINFO args */
-#ifdef COMPAT_SUNOS
-#define SA_USERTRAMP 0x0100 /* do not bounce off kernel's sigtramp */
-#endif
-
-#define NSIG 32 /* number of old signals (counting 0) */
-
-/* POSIX 1003.1b required values. */
-#define SI_USER 0x10001
-#define SI_QUEUE 0x10002
-#define SI_TIMER 0x10003
-#define SI_ASYNCIO 0x10004
-#define SI_MESGQ 0x10005
-
-/* Additional FreeBSD values. */
-#define SI_UNDEFINED 0
-
-typedef void __siginfohandler_t __P((int, struct __siginfo *, void *));
-
-typedef __sighandler_t *sig_t; /* type of pointer to a signal function */
-
-#ifdef _BSD_SIZE_T_
-typedef _BSD_SIZE_T_ size_t;
-#undef _BSD_SIZE_T_
-#endif
-
-/*
- * Structure used in sigaltstack call.
- */
-typedef struct sigaltstack {
- char *ss_sp; /* signal stack base */
- size_t ss_size; /* signal stack length */
- int ss_flags; /* SS_DISABLE and/or SS_ONSTACK */
-} stack_t;
-
-#define SS_ONSTACK 0x0001 /* take signal on alternate stack */
-#define SS_DISABLE 0x0004 /* disable taking signals on alternate stack */
-#define MINSIGSTKSZ 8192 /* minimum allowable stack */
-#define SIGSTKSZ (MINSIGSTKSZ + 32768) /* recommended stack size */
-
-/* Have enough typedefs for this now. XXX */
-#include <sys/ucontext.h>
-
-/*
- * 4.3 compatibility:
- * Signal vector "template" used in sigvec call.
- */
-struct sigvec {
- __sighandler_t *sv_handler; /* signal handler */
- int sv_mask; /* signal mask to apply */
- int sv_flags; /* see signal options below */
-};
-
-#define SV_ONSTACK SA_ONSTACK
-#define SV_INTERRUPT SA_RESTART /* same bit, opposite sense */
-#define SV_RESETHAND SA_RESETHAND
-#define SV_NODEFER SA_NODEFER
-#define SV_NOCLDSTOP SA_NOCLDSTOP
-#define SV_SIGINFO SA_SIGINFO
-#define sv_onstack sv_flags /* isn't compatibility wonderful! */
-
-/*
- * Structure used in sigstack call.
- */
-struct sigstack {
- char *ss_sp; /* signal stack pointer */
- int ss_onstack; /* current status */
-};
-
-/*
- * Macro for converting signal number to a mask suitable for
- * sigblock().
- */
-#define sigmask(m) (1 << ((m)-1))
-
-#define BADSIG SIG_ERR
-
-#endif /* !_POSIX_SOURCE */
-
-/*
- * Flags for sigprocmask:
- */
-#define SIG_BLOCK 1 /* block specified signal set */
-#define SIG_UNBLOCK 2 /* unblock specified signal set */
-#define SIG_SETMASK 3 /* set specified signal set */
-
-#endif /* !_ANSI_SOURCE */
-
-/*
- * For historical reasons; programs expect signal's return value to be
- * defined by <sys/signal.h>.
- */
-__BEGIN_DECLS
-__sighandler_t *signal __P((int, __sighandler_t *));
-__END_DECLS
-
-#endif /* !_SYS_SIGNAL_H_ */
diff --git a/sys/sys/bio.h b/sys/sys/bio.h
deleted file mode 100644
index f38bf4510138..000000000000
--- a/sys/sys/bio.h
+++ /dev/null
@@ -1,517 +0,0 @@
-/*
- * Copyright (c) 1982, 1986, 1989, 1993
- * The Regents of the University of California. All rights reserved.
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)buf.h 8.9 (Berkeley) 3/30/95
- * $FreeBSD$
- */
-
-#ifndef _SYS_BUF_H_
-#define _SYS_BUF_H_
-
-#include <sys/queue.h>
-#include <sys/lock.h>
-
-struct buf;
-struct mount;
-struct vnode;
-
-/*
- * To avoid including <ufs/ffs/softdep.h>
- */
-LIST_HEAD(workhead, worklist);
-/*
- * These are currently used only by the soft dependency code, hence
- * are stored once in a global variable. If other subsystems wanted
- * to use these hooks, a pointer to a set of bio_ops could be added
- * to each buffer.
- */
-extern struct bio_ops {
- void (*io_start) __P((struct buf *));
- void (*io_complete) __P((struct buf *));
- void (*io_deallocate) __P((struct buf *));
- int (*io_fsync) __P((struct vnode *));
- int (*io_sync) __P((struct mount *));
- void (*io_movedeps) __P((struct buf *, struct buf *));
- int (*io_countdeps) __P((struct buf *, int));
-} bioops;
-
-struct iodone_chain {
- long ic_prev_flags;
- void (*ic_prev_iodone) __P((struct buf *));
- void *ic_prev_iodone_chain;
- struct {
- long ia_long;
- void *ia_ptr;
- } ic_args[5];
-};
-
-/*
- * The buffer header describes an I/O operation in the kernel.
- *
- * NOTES:
- * b_bufsize, b_bcount. b_bufsize is the allocation size of the
- * buffer, either DEV_BSIZE or PAGE_SIZE aligned. b_bcount is the
- * originally requested buffer size and can serve as a bounds check
- * against EOF. For most, but not all uses, b_bcount == b_bufsize.
- *
- * b_dirtyoff, b_dirtyend. Buffers support piecemeal, unaligned
- * ranges of dirty data that need to be written to backing store.
- * The range is typically clipped at b_bcount ( not b_bufsize ).
- *
- * b_resid. Number of bytes remaining in I/O. After an I/O operation
- * completes, b_resid is usually 0 indicating 100% success.
- */
-struct buf {
- LIST_ENTRY(buf) b_hash; /* Hash chain. */
- TAILQ_ENTRY(buf) b_vnbufs; /* Buffer's associated vnode. */
- TAILQ_ENTRY(buf) b_freelist; /* Free list position if not active. */
- TAILQ_ENTRY(buf) b_act; /* Device driver queue when active. *new* */
- long b_flags; /* B_* flags. */
- unsigned short b_qindex; /* buffer queue index */
- unsigned char b_xflags; /* extra flags */
- struct lock b_lock; /* Buffer lock */
- int b_error; /* Errno value. */
- long b_bufsize; /* Allocated buffer size. */
- long b_bcount; /* Valid bytes in buffer. */
- long b_resid; /* Remaining I/O. */
- dev_t b_dev; /* Device associated with buffer. */
- caddr_t b_data; /* Memory, superblocks, indirect etc. */
- caddr_t b_kvabase; /* base kva for buffer */
- int b_kvasize; /* size of kva for buffer */
- daddr_t b_lblkno; /* Logical block number. */
- daddr_t b_blkno; /* Underlying physical block number. */
- off_t b_offset; /* Offset into file */
- /* Function to call upon completion. */
- void (*b_iodone) __P((struct buf *));
- /* For nested b_iodone's. */
- struct iodone_chain *b_iodone_chain;
- struct vnode *b_vp; /* Device vnode. */
- int b_dirtyoff; /* Offset in buffer of dirty region. */
- int b_dirtyend; /* Offset of end of dirty region. */
- struct ucred *b_rcred; /* Read credentials reference. */
- struct ucred *b_wcred; /* Write credentials reference. */
- daddr_t b_pblkno; /* physical block number */
- void *b_saveaddr; /* Original b_addr for physio. */
- void *b_driver1; /* for private use by the driver */
- void *b_driver2; /* for private use by the driver */
- void *b_caller1; /* for private use by the caller */
- void *b_caller2; /* for private use by the caller */
- union pager_info {
- void *pg_spc;
- int pg_reqpage;
- } b_pager;
- union cluster_info {
- TAILQ_HEAD(cluster_list_head, buf) cluster_head;
- TAILQ_ENTRY(buf) cluster_entry;
- } b_cluster;
- struct vm_page *b_pages[btoc(MAXPHYS)];
- int b_npages;
- struct workhead b_dep; /* List of filesystem dependencies. */
- struct chain_info { /* buffer chaining */
- struct buf *parent;
- int count;
- } b_chain;
-};
-
-#define b_spc b_pager.pg_spc
-
-/*
- * These flags are kept in b_flags.
- *
- * Notes:
- *
- * B_ASYNC VOP calls on bp's are usually async whether or not
- * B_ASYNC is set, but some subsystems, such as NFS, like
- * to know what is best for the caller so they can
- * optimize the I/O.
- *
- * B_PAGING Indicates that bp is being used by the paging system or
- * some paging system and that the bp is not linked into
- * the b_vp's clean/dirty linked lists or ref counts.
- * Buffer vp reassignments are illegal in this case.
- *
- * B_CACHE This may only be set if the buffer is entirely valid.
- * The situation where B_DELWRI is set and B_CACHE is
- * clear MUST be committed to disk by getblk() so
- * B_DELWRI can also be cleared. See the comments for
- * getblk() in kern/vfs_bio.c. If B_CACHE is clear,
- * the caller is expected to clear B_ERROR|B_INVAL,
- * set B_READ, and initiate an I/O.
- *
- * The 'entire buffer' is defined to be the range from
- * 0 through b_bcount.
- *
- * B_MALLOC Request that the buffer be allocated from the malloc
- * pool, DEV_BSIZE aligned instead of PAGE_SIZE aligned.
- *
- * B_CLUSTEROK This flag is typically set for B_DELWRI buffers
- * by filesystems that allow clustering when the buffer
- * is fully dirty and indicates that it may be clustered
- * with other adjacent dirty buffers. Note the clustering
- * may not be used with the stage 1 data write under NFS
- * but may be used for the commit rpc portion.
- *
- * B_VMIO Indicates that the buffer is tied into an VM object.
- * The buffer's data is always PAGE_SIZE aligned even
- * if b_bufsize and b_bcount are not. ( b_bufsize is
- * always at least DEV_BSIZE aligned, though ).
- *
- */
-
-#define B_AGE 0x00000001 /* Move to age queue when I/O done. */
-#define B_NEEDCOMMIT 0x00000002 /* Append-write in progress. */
-#define B_ASYNC 0x00000004 /* Start I/O, do not wait. */
-#define B_UNUSED0 0x00000008 /* Old B_BAD */
-#define B_DEFERRED 0x00000010 /* Skipped over for cleaning */
-#define B_CACHE 0x00000020 /* Bread found us in the cache. */
-#define B_CALL 0x00000040 /* Call b_iodone from biodone. */
-#define B_DELWRI 0x00000080 /* Delay I/O until buffer reused. */
-#define B_FREEBUF 0x00000100 /* Instruct driver: free blocks */
-#define B_DONE 0x00000200 /* I/O completed. */
-#define B_EINTR 0x00000400 /* I/O was interrupted */
-#define B_ERROR 0x00000800 /* I/O error occurred. */
-#define B_SCANNED 0x00001000 /* VOP_FSYNC funcs mark written bufs */
-#define B_INVAL 0x00002000 /* Does not contain valid info. */
-#define B_LOCKED 0x00004000 /* Locked in core (not reusable). */
-#define B_NOCACHE 0x00008000 /* Do not cache block after use. */
-#define B_MALLOC 0x00010000 /* malloced b_data */
-#define B_CLUSTEROK 0x00020000 /* Pagein op, so swap() can count it. */
-#define B_PHYS 0x00040000 /* I/O to user memory. */
-#define B_RAW 0x00080000 /* Set by physio for raw transfers. */
-#define B_READ 0x00100000 /* Read buffer. */
-#define B_DIRTY 0x00200000 /* Needs writing later. */
-#define B_RELBUF 0x00400000 /* Release VMIO buffer. */
-#define B_WANT 0x00800000 /* Used by vm_pager.c */
-#define B_WRITE 0x00000000 /* Write buffer (pseudo flag). */
-#define B_WRITEINPROG 0x01000000 /* Write in progress. */
-#define B_XXX 0x02000000 /* Debugging flag. */
-#define B_PAGING 0x04000000 /* volatile paging I/O -- bypass VMIO */
-#define B_ORDERED 0x08000000 /* Must guarantee I/O ordering */
-#define B_RAM 0x10000000 /* Read ahead mark (flag) */
-#define B_VMIO 0x20000000 /* VMIO flag */
-#define B_CLUSTER 0x40000000 /* pagein op, so swap() can count it */
-#define B_AUTOCHAINDONE 0x80000000 /* Available flag */
-
-#define PRINT_BUF_FLAGS "\20\40autochain\37cluster\36vmio\35ram\34ordered" \
- "\33paging\32xxx\31writeinprog\30want\27relbuf\26dirty" \
- "\25read\24raw\23phys\22clusterok\21malloc\20nocache" \
- "\17locked\16inval\15scanned\14error\13eintr\12done\11freebuf" \
- "\10delwri\7call\6cache\4bad\3async\2needcommit\1age"
-
-/*
- * These flags are kept in b_xflags.
- */
-#define BX_VNDIRTY 0x00000001 /* On vnode dirty list */
-#define BX_VNCLEAN 0x00000002 /* On vnode clean list */
-#define BX_BKGRDWRITE 0x00000004 /* Do writes in background */
-#define BX_BKGRDINPROG 0x00000008 /* Background write in progress */
-#define BX_BKGRDWAIT 0x00000010 /* Background write waiting */
-
-#define NOOFFSET (-1LL) /* No buffer offset calculated yet */
-
-#ifdef _KERNEL
-/*
- * Buffer locking
- */
-struct simplelock buftimelock; /* Interlock on setting prio and timo */
-extern char *buf_wmesg; /* Default buffer lock message */
-#define BUF_WMESG "bufwait"
-#include <sys/proc.h> /* XXX for curproc */
-/*
- * Initialize a lock.
- */
-#define BUF_LOCKINIT(bp) \
- lockinit(&(bp)->b_lock, PRIBIO + 4, buf_wmesg, 0, 0)
-/*
- *
- * Get a lock sleeping non-interruptably until it becomes available.
- */
-static __inline int BUF_LOCK __P((struct buf *, int));
-static __inline int
-BUF_LOCK(struct buf *bp, int locktype)
-{
- int s, ret;
-
- s = splbio();
- simple_lock(&buftimelock);
- locktype |= LK_INTERLOCK;
- bp->b_lock.lk_wmesg = buf_wmesg;
- bp->b_lock.lk_prio = PRIBIO + 4;
- bp->b_lock.lk_timo = 0;
- ret = lockmgr(&(bp)->b_lock, locktype, &buftimelock, curproc);
- splx(s);
- return ret;
-}
-/*
- * Get a lock sleeping with specified interruptably and timeout.
- */
-static __inline int BUF_TIMELOCK __P((struct buf *, int, char *, int, int));
-static __inline int
-BUF_TIMELOCK(struct buf *bp, int locktype, char *wmesg, int catch, int timo)
-{
- int s, ret;
-
- s = splbio();
- simple_lock(&buftimelock);
- locktype |= LK_INTERLOCK;
- bp->b_lock.lk_wmesg = wmesg;
- bp->b_lock.lk_prio = (PRIBIO + 4) | catch;
- bp->b_lock.lk_timo = timo;
- ret = lockmgr(&(bp)->b_lock, (locktype), &buftimelock, curproc);
- splx(s);
- return ret;
-}
-/*
- * Release a lock. Only the acquiring process may free the lock unless
- * it has been handed off to biodone.
- */
-static __inline void BUF_UNLOCK __P((struct buf *));
-static __inline void
-BUF_UNLOCK(struct buf *bp)
-{
- int s;
-
- s = splbio();
- lockmgr(&(bp)->b_lock, LK_RELEASE, NULL, curproc);
- splx(s);
-}
-
-/*
- * Free a buffer lock.
- */
-#define BUF_LOCKFREE(bp) \
- if (BUF_REFCNT(bp) > 0) \
- panic("free locked buf")
-/*
- * When initiating asynchronous I/O, change ownership of the lock to the
- * kernel. Once done, the lock may legally released by biodone. The
- * original owning process can no longer acquire it recursively, but must
- * wait until the I/O is completed and the lock has been freed by biodone.
- */
-static __inline void BUF_KERNPROC __P((struct buf *));
-static __inline void
-BUF_KERNPROC(struct buf *bp)
-{
- struct proc *p = curproc;
-
- if (p != NULL && bp->b_lock.lk_lockholder == p->p_pid)
- p->p_locks--;
- bp->b_lock.lk_lockholder = LK_KERNPROC;
-}
-/*
- * Find out the number of references to a lock.
- */
-static __inline int BUF_REFCNT __P((struct buf *));
-static __inline int
-BUF_REFCNT(struct buf *bp)
-{
- int s, ret;
-
- s = splbio();
- ret = lockcount(&(bp)->b_lock);
- splx(s);
- return ret;
-}
-
-#endif /* _KERNEL */
-
-struct buf_queue_head {
- TAILQ_HEAD(buf_queue, buf) queue;
- daddr_t last_pblkno;
- struct buf *insert_point;
- struct buf *switch_point;
-};
-
-/*
- * This structure describes a clustered I/O. It is stored in the b_saveaddr
- * field of the buffer on which I/O is done. At I/O completion, cluster
- * callback uses the structure to parcel I/O's to individual buffers, and
- * then free's this structure.
- */
-struct cluster_save {
- long bs_bcount; /* Saved b_bcount. */
- long bs_bufsize; /* Saved b_bufsize. */
- void *bs_saveaddr; /* Saved b_addr. */
- int bs_nchildren; /* Number of associated buffers. */
- struct buf **bs_children; /* List of associated buffers. */
-};
-
-#ifdef _KERNEL
-static __inline void bufq_init __P((struct buf_queue_head *head));
-
-static __inline void bufq_insert_tail __P((struct buf_queue_head *head,
- struct buf *bp));
-
-static __inline void bufq_remove __P((struct buf_queue_head *head,
- struct buf *bp));
-
-static __inline struct buf *bufq_first __P((struct buf_queue_head *head));
-
-static __inline void
-bufq_init(struct buf_queue_head *head)
-{
- TAILQ_INIT(&head->queue);
- head->last_pblkno = 0;
- head->insert_point = NULL;
- head->switch_point = NULL;
-}
-
-static __inline void
-bufq_insert_tail(struct buf_queue_head *head, struct buf *bp)
-{
- if ((bp->b_flags & B_ORDERED) != 0) {
- head->insert_point = bp;
- head->switch_point = NULL;
- }
- TAILQ_INSERT_TAIL(&head->queue, bp, b_act);
-}
-
-static __inline void
-bufq_remove(struct buf_queue_head *head, struct buf *bp)
-{
- if (bp == head->switch_point)
- head->switch_point = TAILQ_NEXT(bp, b_act);
- if (bp == head->insert_point) {
- head->insert_point = TAILQ_PREV(bp, buf_queue, b_act);
- if (head->insert_point == NULL)
- head->last_pblkno = 0;
- } else if (bp == TAILQ_FIRST(&head->queue))
- head->last_pblkno = bp->b_pblkno;
- TAILQ_REMOVE(&head->queue, bp, b_act);
- if (TAILQ_FIRST(&head->queue) == head->switch_point)
- head->switch_point = NULL;
-}
-
-static __inline struct buf *
-bufq_first(struct buf_queue_head *head)
-{
- return (TAILQ_FIRST(&head->queue));
-}
-
-#endif /* _KERNEL */
-
-/*
- * Definitions for the buffer free lists.
- */
-#define BUFFER_QUEUES 6 /* number of free buffer queues */
-
-#define QUEUE_NONE 0 /* on no queue */
-#define QUEUE_LOCKED 1 /* locked buffers */
-#define QUEUE_CLEAN 2 /* non-B_DELWRI buffers */
-#define QUEUE_DIRTY 3 /* B_DELWRI buffers */
-#define QUEUE_EMPTYKVA 4 /* empty buffer headers w/KVA assignment */
-#define QUEUE_EMPTY 5 /* empty buffer headers */
-
-/*
- * Zero out the buffer's data area.
- */
-#define clrbuf(bp) { \
- bzero((bp)->b_data, (u_int)(bp)->b_bcount); \
- (bp)->b_resid = 0; \
-}
-
-/* Flags to low-level allocation routines. */
-#define B_CLRBUF 0x01 /* Request allocated buffer be cleared. */
-#define B_SYNC 0x02 /* Do all allocations synchronously. */
-
-#ifdef _KERNEL
-extern int nbuf; /* The number of buffer headers */
-extern int buf_maxio; /* nominal maximum I/O for buffer */
-extern struct buf *buf; /* The buffer headers. */
-extern char *buffers; /* The buffer contents. */
-extern int bufpages; /* Number of memory pages in the buffer pool. */
-extern struct buf *swbuf; /* Swap I/O buffer headers. */
-extern int nswbuf; /* Number of swap I/O buffer headers. */
-extern TAILQ_HEAD(swqueue, buf) bswlist;
-extern TAILQ_HEAD(bqueues, buf) bufqueues[BUFFER_QUEUES];
-
-struct uio;
-
-caddr_t bufhashinit __P((caddr_t));
-void bufinit __P((void));
-void bwillwrite __P((void));
-void bremfree __P((struct buf *));
-int bread __P((struct vnode *, daddr_t, int,
- struct ucred *, struct buf **));
-int breadn __P((struct vnode *, daddr_t, int, daddr_t *, int *, int,
- struct ucred *, struct buf **));
-int bwrite __P((struct buf *));
-void bdwrite __P((struct buf *));
-void bawrite __P((struct buf *));
-void bdirty __P((struct buf *));
-void bundirty __P((struct buf *));
-int bowrite __P((struct buf *));
-void brelse __P((struct buf *));
-void bqrelse __P((struct buf *));
-int vfs_bio_awrite __P((struct buf *));
-struct buf * getpbuf __P((int *));
-struct buf *incore __P((struct vnode *, daddr_t));
-struct buf *gbincore __P((struct vnode *, daddr_t));
-int inmem __P((struct vnode *, daddr_t));
-struct buf *getblk __P((struct vnode *, daddr_t, int, int, int));
-struct buf *geteblk __P((int));
-int biowait __P((struct buf *));
-void biodone __P((struct buf *));
-
-void cluster_callback __P((struct buf *));
-int cluster_read __P((struct vnode *, u_quad_t, daddr_t, long,
- struct ucred *, long, int, struct buf **));
-int cluster_wbuild __P((struct vnode *, long, daddr_t, int));
-void cluster_write __P((struct buf *, u_quad_t));
-int physio __P((dev_t dev, struct uio *uio, int ioflag));
-#define physread physio
-#define physwrite physio
-void vfs_bio_set_validclean __P((struct buf *, int base, int size));
-void vfs_bio_clrbuf __P((struct buf *));
-void vfs_busy_pages __P((struct buf *, int clear_modify));
-void vfs_unbusy_pages __P((struct buf *));
-void vwakeup __P((struct buf *));
-void vmapbuf __P((struct buf *));
-void vunmapbuf __P((struct buf *));
-void relpbuf __P((struct buf *, int *));
-void brelvp __P((struct buf *));
-void bgetvp __P((struct vnode *, struct buf *));
-void pbgetvp __P((struct vnode *, struct buf *));
-void pbrelvp __P((struct buf *));
-int allocbuf __P((struct buf *bp, int size));
-void reassignbuf __P((struct buf *, struct vnode *));
-void pbreassignbuf __P((struct buf *, struct vnode *));
-struct buf *trypbuf __P((int *));
-
-#endif /* _KERNEL */
-
-#endif /* !_SYS_BUF_H_ */
diff --git a/sys/sys/bitstring.h b/sys/sys/bitstring.h
deleted file mode 100644
index 88437e7fb9f7..000000000000
--- a/sys/sys/bitstring.h
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Paul Vixie.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)bitstring.h 8.1 (Berkeley) 7/19/93
- */
-
-#ifndef _BITSTRING_H_
-#define _BITSTRING_H_
-
-typedef unsigned char bitstr_t;
-
-/* internal macros */
- /* byte of the bitstring bit is in */
-#define _bit_byte(bit) \
- ((bit) >> 3)
-
- /* mask for the bit within its byte */
-#define _bit_mask(bit) \
- (1 << ((bit)&0x7))
-
-/* external macros */
- /* bytes in a bitstring of nbits bits */
-#define bitstr_size(nbits) \
- ((((nbits) - 1) >> 3) + 1)
-
- /* allocate a bitstring */
-#define bit_alloc(nbits) \
- (bitstr_t *)calloc(1, \
- (unsigned int)bitstr_size(nbits) * sizeof(bitstr_t))
-
- /* allocate a bitstring on the stack */
-#define bit_decl(name, nbits) \
- (name)[bitstr_size(nbits)]
-
- /* is bit N of bitstring name set? */
-#define bit_test(name, bit) \
- ((name)[_bit_byte(bit)] & _bit_mask(bit))
-
- /* set bit N of bitstring name */
-#define bit_set(name, bit) \
- (name)[_bit_byte(bit)] |= _bit_mask(bit)
-
- /* clear bit N of bitstring name */
-#define bit_clear(name, bit) \
- (name)[_bit_byte(bit)] &= ~_bit_mask(bit)
-
- /* clear bits start ... stop in bitstring */
-#define bit_nclear(name, start, stop) { \
- register bitstr_t *_name = name; \
- register int _start = start, _stop = stop; \
- register int _startbyte = _bit_byte(_start); \
- register int _stopbyte = _bit_byte(_stop); \
- if (_startbyte == _stopbyte) { \
- _name[_startbyte] &= ((0xff >> (8 - (_start&0x7))) | \
- (0xff << ((_stop&0x7) + 1))); \
- } else { \
- _name[_startbyte] &= 0xff >> (8 - (_start&0x7)); \
- while (++_startbyte < _stopbyte) \
- _name[_startbyte] = 0; \
- _name[_stopbyte] &= 0xff << ((_stop&0x7) + 1); \
- } \
-}
-
- /* set bits start ... stop in bitstring */
-#define bit_nset(name, start, stop) { \
- register bitstr_t *_name = name; \
- register int _start = start, _stop = stop; \
- register int _startbyte = _bit_byte(_start); \
- register int _stopbyte = _bit_byte(_stop); \
- if (_startbyte == _stopbyte) { \
- _name[_startbyte] |= ((0xff << (_start&0x7)) & \
- (0xff >> (7 - (_stop&0x7)))); \
- } else { \
- _name[_startbyte] |= 0xff << ((_start)&0x7); \
- while (++_startbyte < _stopbyte) \
- _name[_startbyte] = 0xff; \
- _name[_stopbyte] |= 0xff >> (7 - (_stop&0x7)); \
- } \
-}
-
- /* find first bit clear in name */
-#define bit_ffc(name, nbits, value) { \
- register bitstr_t *_name = name; \
- register int _byte, _nbits = nbits; \
- register int _stopbyte = _bit_byte(_nbits), _value = -1; \
- for (_byte = 0; _byte <= _stopbyte; ++_byte) \
- if (_name[_byte] != 0xff) { \
- _value = _byte << 3; \
- for (_stopbyte = _name[_byte]; (_stopbyte&0x1); \
- ++_value, _stopbyte >>= 1); \
- break; \
- } \
- *(value) = _value; \
-}
-
- /* find first bit set in name */
-#define bit_ffs(name, nbits, value) { \
- register bitstr_t *_name = name; \
- register int _byte, _nbits = nbits; \
- register int _stopbyte = _bit_byte(_nbits), _value = -1; \
- for (_byte = 0; _byte <= _stopbyte; ++_byte) \
- if (_name[_byte]) { \
- _value = _byte << 3; \
- for (_stopbyte = _name[_byte]; !(_stopbyte&0x1); \
- ++_value, _stopbyte >>= 1); \
- break; \
- } \
- *(value) = _value; \
-}
-
-#endif /* !_BITSTRING_H_ */
diff --git a/sys/sys/bus_dma.h b/sys/sys/bus_dma.h
deleted file mode 100644
index 661761271085..000000000000
--- a/sys/sys/bus_dma.h
+++ /dev/null
@@ -1,1291 +0,0 @@
-/* $NetBSD: bus.h,v 1.12 1997/10/01 08:25:15 fvdl Exp $ */
-
-/*-
- * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
- * NASA Ames Research Center.
- *
- * 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 the NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Copyright (c) 1996 Charles M. Hannum. All rights reserved.
- * Copyright (c) 1996 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
- * for the NetBSD Project.
- * 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.
- */
-/* $FreeBSD$ */
-
-#ifndef _I386_BUS_H_
-#define _I386_BUS_H_
-
-#include <machine/cpufunc.h>
-
-/*
- * To remain compatible with NetBSD's interface, default to both memio and
- * pio when neither of them is defined.
- */
-#if !defined(_I386_BUS_PIO_H_) && !defined(_I386_BUS_MEMIO_H_)
-#define _I386_BUS_PIO_H_
-#define _I386_BUS_MEMIO_H_
-#endif
-
-/*
- * Values for the i386 bus space tag, not to be used directly by MI code.
- */
-#define I386_BUS_SPACE_IO 0 /* space is i/o space */
-#define I386_BUS_SPACE_MEM 1 /* space is mem space */
-
-/*
- * Bus address and size types
- */
-typedef u_int bus_addr_t;
-typedef u_int bus_size_t;
-
-#define BUS_SPACE_MAXSIZE_24BIT 0xFFFFFF
-#define BUS_SPACE_MAXSIZE_32BIT 0xFFFFFFFF
-#define BUS_SPACE_MAXSIZE (64 * 1024) /* Maximum supported size */
-#define BUS_SPACE_MAXADDR_24BIT 0xFFFFFF
-#define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFF
-#define BUS_SPACE_MAXADDR 0xFFFFFFFF
-
-#define BUS_SPACE_UNRESTRICTED (~0)
-
-/*
- * Access methods for bus resources and address space.
- */
-typedef int bus_space_tag_t;
-typedef u_int bus_space_handle_t;
-
-/*
- * Map a region of device bus space into CPU virtual address space.
- */
-
-#define BUS_SPACE_MAP_CACHEABLE 0x01
-#define BUS_SPACE_MAP_LINEAR 0x02
-
-int bus_space_map(bus_space_tag_t t, bus_addr_t addr, bus_size_t size,
- int flags, bus_space_handle_t *bshp);
-
-/*
- * Unmap a region of device bus space.
- */
-
-void bus_space_unmap(bus_space_tag_t t, bus_space_handle_t bsh,
- bus_size_t size);
-
-/*
- * Get a new handle for a subregion of an already-mapped area of bus space.
- */
-
-int bus_space_subregion(bus_space_tag_t t, bus_space_handle_t bsh,
- bus_size_t offset, bus_size_t size,
- bus_space_handle_t *nbshp);
-
-/*
- * Allocate a region of memory that is accessible to devices in bus space.
- */
-
-int bus_space_alloc(bus_space_tag_t t, 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);
-
-/*
- * Free a region of bus space accessible memory.
- */
-
-void bus_space_free(bus_space_tag_t t, bus_space_handle_t bsh,
- bus_size_t size);
-
-#if defined(_I386_BUS_PIO_H_) || defined(_I386_BUS_MEMIO_H_)
-
-/*
- * Read a 1, 2, 4, or 8 byte quantity from bus space
- * described by tag/handle/offset.
- */
-static __inline u_int8_t bus_space_read_1(bus_space_tag_t tag,
- bus_space_handle_t handle,
- bus_size_t offset);
-
-static __inline u_int16_t bus_space_read_2(bus_space_tag_t tag,
- bus_space_handle_t handle,
- bus_size_t offset);
-
-static __inline u_int32_t bus_space_read_4(bus_space_tag_t tag,
- bus_space_handle_t handle,
- bus_size_t offset);
-
-static __inline u_int8_t
-bus_space_read_1(bus_space_tag_t tag, bus_space_handle_t handle,
- bus_size_t offset)
-{
-#if defined (_I386_BUS_PIO_H_)
-#if defined (_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- return (inb(handle + offset));
-#endif
-#if defined (_I386_BUS_MEMIO_H_)
- return (*(volatile u_int8_t *)(handle + offset));
-#endif
-}
-
-static __inline u_int16_t
-bus_space_read_2(bus_space_tag_t tag, bus_space_handle_t handle,
- bus_size_t offset)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- return (inw(handle + offset));
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
- return (*(volatile u_int16_t *)(handle + offset));
-#endif
-}
-
-static __inline u_int32_t
-bus_space_read_4(bus_space_tag_t tag, bus_space_handle_t handle,
- bus_size_t offset)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- return (inl(handle + offset));
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
- return (*(volatile u_int32_t *)(handle + offset));
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_read_8 */
-#define bus_space_read_8(t, h, o) !!! bus_space_read_8 unimplemented !!!
-#endif
-
-/*
- * Read `count' 1, 2, 4, or 8 byte quantities from bus space
- * described by tag/handle/offset and copy into buffer provided.
- */
-static __inline void bus_space_read_multi_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t *addr,
- size_t count);
-
-static __inline void bus_space_read_multi_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t *addr,
- size_t count);
-
-static __inline void bus_space_read_multi_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t *addr,
- size_t count);
-
-static __inline void
-bus_space_read_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- insb(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: movb (%2),%%al \n\
- stosb \n\
- loop 1b" :
- "=D" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory");
- }
-#endif
-}
-
-static __inline void
-bus_space_read_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- insw(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: movw (%2),%%ax \n\
- stosw \n\
- loop 1b" :
- "=D" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory");
- }
-#endif
-}
-
-static __inline void
-bus_space_read_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- insl(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: movl (%2),%%eax \n\
- stosl \n\
- loop 1b" :
- "=D" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory");
- }
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_read_multi_8 */
-#define bus_space_read_multi_8 !!! bus_space_read_multi_8 unimplemented !!!
-#endif
-
-/*
- * Read `count' 1, 2, 4, or 8 byte quantities from bus space
- * described by tag/handle and starting at `offset' and copy into
- * buffer provided.
- */
-static __inline void bus_space_read_region_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t *addr,
- size_t count);
-
-static __inline void bus_space_read_region_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t *addr,
- size_t count);
-
-static __inline void bus_space_read_region_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t *addr,
- size_t count);
-
-
-static __inline void
-bus_space_read_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: inb %w2,%%al \n\
- stosb \n\
- incl %2 \n\
- loop 1b" :
- "=D" (addr), "=c" (count), "=d" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsb" :
- "=D" (addr), "=c" (count), "=S" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_read_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: inw %w2,%%ax \n\
- stosw \n\
- addl $2,%2 \n\
- loop 1b" :
- "=D" (addr), "=c" (count), "=d" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsw" :
- "=D" (addr), "=c" (count), "=S" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_read_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: inl %w2,%%eax \n\
- stosl \n\
- addl $4,%2 \n\
- loop 1b" :
- "=D" (addr), "=c" (count), "=d" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsl" :
- "=D" (addr), "=c" (count), "=S" (_port_) :
- "0" (addr), "1" (count), "2" (_port_) :
- "memory", "cc");
- }
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_read_region_8 */
-#define bus_space_read_region_8 !!! bus_space_read_region_8 unimplemented !!!
-#endif
-
-/*
- * Write the 1, 2, 4, or 8 byte value `value' to bus space
- * described by tag/handle/offset.
- */
-
-static __inline void bus_space_write_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t value);
-
-static __inline void bus_space_write_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t value);
-
-static __inline void bus_space_write_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t value);
-
-static __inline void
-bus_space_write_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t value)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outb(bsh + offset, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- *(volatile u_int8_t *)(bsh + offset) = value;
-#endif
-}
-
-static __inline void
-bus_space_write_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t value)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outw(bsh + offset, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- *(volatile u_int16_t *)(bsh + offset) = value;
-#endif
-}
-
-static __inline void
-bus_space_write_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t value)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outl(bsh + offset, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- *(volatile u_int32_t *)(bsh + offset) = value;
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_write_8 */
-#define bus_space_write_8 !!! bus_space_write_8 not implemented !!!
-#endif
-
-/*
- * Write `count' 1, 2, 4, or 8 byte quantities from the buffer
- * provided to bus space described by tag/handle/offset.
- */
-
-static __inline void bus_space_write_multi_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int8_t *addr,
- size_t count);
-static __inline void bus_space_write_multi_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int16_t *addr,
- size_t count);
-
-static __inline void bus_space_write_multi_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int32_t *addr,
- size_t count);
-
-static __inline void
-bus_space_write_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int8_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outsb(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: lodsb \n\
- movb %%al,(%2) \n\
- loop 1b" :
- "=S" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_write_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int16_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outsw(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: lodsw \n\
- movw %%ax,(%1) \n\
- movw %%ax,(%2) \n\
- loop 1b" :
- "=S" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_write_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int32_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- outsl(bsh + offset, addr, count);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- __asm __volatile(" \n\
- cld \n\
- 1: lodsl \n\
- movl %%eax,(%2) \n\
- loop 1b" :
- "=S" (addr), "=c" (count) :
- "r" (bsh + offset), "0" (addr), "1" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_write_multi_8 */
-#define bus_space_write_multi_8(t, h, o, a, c) \
- !!! bus_space_write_multi_8 unimplemented !!!
-#endif
-
-/*
- * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided
- * to bus space described by tag/handle starting at `offset'.
- */
-
-static __inline void bus_space_write_region_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int8_t *addr,
- size_t count);
-static __inline void bus_space_write_region_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int16_t *addr,
- size_t count);
-static __inline void bus_space_write_region_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- const u_int32_t *addr,
- size_t count);
-
-static __inline void
-bus_space_write_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int8_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: lodsb \n\
- outb %%al,%w0 \n\
- incl %0 \n\
- loop 1b" :
- "=d" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsb" :
- "=D" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_write_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int16_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: lodsw \n\
- outw %%ax,%w0 \n\
- addl $2,%0 \n\
- loop 1b" :
- "=d" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsw" :
- "=D" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "memory", "cc");
- }
-#endif
-}
-
-static __inline void
-bus_space_write_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, const u_int32_t *addr, size_t count)
-{
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- 1: lodsl \n\
- outl %%eax,%w0 \n\
- addl $4,%0 \n\
- loop 1b" :
- "=d" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "%eax", "memory", "cc");
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- int _port_ = bsh + offset; \
- __asm __volatile(" \n\
- cld \n\
- repne \n\
- movsl" :
- "=D" (_port_), "=S" (addr), "=c" (count) :
- "0" (_port_), "1" (addr), "2" (count) :
- "memory", "cc");
- }
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_write_region_8 */
-#define bus_space_write_region_8 \
- !!! bus_space_write_region_8 unimplemented !!!
-#endif
-
-/*
- * Write the 1, 2, 4, or 8 byte value `val' to bus space described
- * by tag/handle/offset `count' times.
- */
-
-static __inline void bus_space_set_multi_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- u_int8_t value, size_t count);
-static __inline void bus_space_set_multi_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- u_int16_t value, size_t count);
-static __inline void bus_space_set_multi_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset,
- u_int32_t value, size_t count);
-
-static __inline void
-bus_space_set_multi_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- while (count--)
- outb(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- while (count--)
- *(volatile u_int8_t *)(addr) = value;
-#endif
-}
-
-static __inline void
-bus_space_set_multi_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- while (count--)
- outw(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- while (count--)
- *(volatile u_int16_t *)(addr) = value;
-#endif
-}
-
-static __inline void
-bus_space_set_multi_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- while (count--)
- outl(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- while (count--)
- *(volatile u_int32_t *)(addr) = value;
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_set_multi_8 */
-#define bus_space_set_multi_8 !!! bus_space_set_multi_8 unimplemented !!!
-#endif
-
-/*
- * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described
- * by tag/handle starting at `offset'.
- */
-
-static __inline void bus_space_set_region_1(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t value,
- size_t count);
-static __inline void bus_space_set_region_2(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t value,
- size_t count);
-static __inline void bus_space_set_region_4(bus_space_tag_t tag,
- bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t value,
- size_t count);
-
-static __inline void
-bus_space_set_region_1(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int8_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- for (; count != 0; count--, addr++)
- outb(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- for (; count != 0; count--, addr++)
- *(volatile u_int8_t *)(addr) = value;
-#endif
-}
-
-static __inline void
-bus_space_set_region_2(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int16_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- for (; count != 0; count--, addr += 2)
- outw(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- for (; count != 0; count--, addr += 2)
- *(volatile u_int16_t *)(addr) = value;
-#endif
-}
-
-static __inline void
-bus_space_set_region_4(bus_space_tag_t tag, bus_space_handle_t bsh,
- bus_size_t offset, u_int32_t value, size_t count)
-{
- bus_addr_t addr = bsh + offset;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- for (; count != 0; count--, addr += 4)
- outl(addr, value);
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- for (; count != 0; count--, addr += 4)
- *(volatile u_int32_t *)(addr) = value;
-#endif
-}
-
-#if 0 /* Cause a link error for bus_space_set_region_8 */
-#define bus_space_set_region_8 !!! bus_space_set_region_8 unimplemented !!!
-#endif
-
-/*
- * Copy `count' 1, 2, 4, or 8 byte values from bus space starting
- * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2.
- */
-
-static __inline void bus_space_copy_region_1(bus_space_tag_t tag,
- bus_space_handle_t bsh1,
- bus_size_t off1,
- bus_space_handle_t bsh2,
- bus_size_t off2, size_t count);
-
-static __inline void bus_space_copy_region_2(bus_space_tag_t tag,
- bus_space_handle_t bsh1,
- bus_size_t off1,
- bus_space_handle_t bsh2,
- bus_size_t off2, size_t count);
-
-static __inline void bus_space_copy_region_4(bus_space_tag_t tag,
- bus_space_handle_t bsh1,
- bus_size_t off1,
- bus_space_handle_t bsh2,
- bus_size_t off2, size_t count);
-
-static __inline void
-bus_space_copy_region_1(bus_space_tag_t tag, bus_space_handle_t bsh1,
- bus_size_t off1, bus_space_handle_t bsh2,
- bus_size_t off2, size_t count)
-{
- bus_addr_t addr1 = bsh1 + off1;
- bus_addr_t addr2 = bsh2 + off2;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1++, addr2++)
- outb(addr2, inb(addr1));
- } else {
- /* dest after src: copy backwards */
- for (addr1 += (count - 1), addr2 += (count - 1);
- count != 0; count--, addr1--, addr2--)
- outb(addr2, inb(addr1));
- }
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1++, addr2++)
- *(volatile u_int8_t *)(addr2) =
- *(volatile u_int8_t *)(addr1);
- } else {
- /* dest after src: copy backwards */
- for (addr1 += (count - 1), addr2 += (count - 1);
- count != 0; count--, addr1--, addr2--)
- *(volatile u_int8_t *)(addr2) =
- *(volatile u_int8_t *)(addr1);
- }
- }
-#endif
-}
-
-static __inline void
-bus_space_copy_region_2(bus_space_tag_t tag, bus_space_handle_t bsh1,
- bus_size_t off1, bus_space_handle_t bsh2,
- bus_size_t off2, size_t count)
-{
- bus_addr_t addr1 = bsh1 + off1;
- bus_addr_t addr2 = bsh2 + off2;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1 += 2, addr2 += 2)
- outw(addr2, inw(addr1));
- } else {
- /* dest after src: copy backwards */
- for (addr1 += 2 * (count - 1), addr2 += 2 * (count - 1);
- count != 0; count--, addr1 -= 2, addr2 -= 2)
- outw(addr2, inw(addr1));
- }
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1 += 2, addr2 += 2)
- *(volatile u_int16_t *)(addr2) =
- *(volatile u_int16_t *)(addr1);
- } else {
- /* dest after src: copy backwards */
- for (addr1 += 2 * (count - 1), addr2 += 2 * (count - 1);
- count != 0; count--, addr1 -= 2, addr2 -= 2)
- *(volatile u_int16_t *)(addr2) =
- *(volatile u_int16_t *)(addr1);
- }
- }
-#endif
-}
-
-static __inline void
-bus_space_copy_region_4(bus_space_tag_t tag, bus_space_handle_t bsh1,
- bus_size_t off1, bus_space_handle_t bsh2,
- bus_size_t off2, size_t count)
-{
- bus_addr_t addr1 = bsh1 + off1;
- bus_addr_t addr2 = bsh2 + off2;
-
-#if defined(_I386_BUS_PIO_H_)
-#if defined(_I386_BUS_MEMIO_H_)
- if (tag == I386_BUS_SPACE_IO)
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1 += 4, addr2 += 4)
- outl(addr2, inl(addr1));
- } else {
- /* dest after src: copy backwards */
- for (addr1 += 4 * (count - 1), addr2 += 4 * (count - 1);
- count != 0; count--, addr1 -= 4, addr2 -= 4)
- outl(addr2, inl(addr1));
- }
- }
-#endif
-#if defined(_I386_BUS_MEMIO_H_)
-#if defined(_I386_BUS_PIO_H_)
- else
-#endif
- {
- if (addr1 >= addr2) {
- /* src after dest: copy forward */
- for (; count != 0; count--, addr1 += 4, addr2 += 4)
- *(volatile u_int32_t *)(addr2) =
- *(volatile u_int32_t *)(addr1);
- } else {
- /* dest after src: copy backwards */
- for (addr1 += 4 * (count - 1), addr2 += 4 * (count - 1);
- count != 0; count--, addr1 -= 4, addr2 -= 4)
- *(volatile u_int32_t *)(addr2) =
- *(volatile u_int32_t *)(addr1);
- }
- }
-#endif
-}
-
-#endif /* defined(_I386_BUS_PIO_H_) || defined(_I386_MEM_IO_H_) */
-
-#if 0 /* Cause a link error for bus_space_copy_8 */
-#define bus_space_copy_region_8 !!! bus_space_copy_region_8 unimplemented !!!
-#endif
-
-/*
- * Bus read/write barrier methods.
- *
- * void bus_space_barrier(bus_space_tag_t tag, bus_space_handle_t bsh,
- * bus_size_t offset, bus_size_t len, int flags);
- *
- * Note: the i386 does not currently require barriers, but we must
- * provide the flags to MI code.
- */
-#define bus_space_barrier(t, h, o, l, f) \
- ((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f)))
-#define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */
-#define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */
-
-/*
- * Flags used in various bus DMA methods.
- */
-#define BUS_DMA_WAITOK 0x00 /* safe to sleep (pseudo-flag) */
-#define BUS_DMA_NOWAIT 0x01 /* not safe to sleep */
-#define BUS_DMA_ALLOCNOW 0x02 /* perform resource allocation now */
-#define BUS_DMAMEM_NOSYNC 0x04 /* map memory to not require sync */
-#define BUS_DMA_BUS1 0x10 /* placeholders for bus functions... */
-#define BUS_DMA_BUS2 0x20
-#define BUS_DMA_BUS3 0x40
-#define BUS_DMA_BUS4 0x80
-
-/* Forwards needed by prototypes below. */
-struct mbuf;
-struct uio;
-
-/*
- * bus_dmasync_op_t
- *
- * Operations performed by bus_dmamap_sync().
- */
-typedef enum {
- BUS_DMASYNC_PREREAD,
- BUS_DMASYNC_POSTREAD,
- BUS_DMASYNC_PREWRITE,
- BUS_DMASYNC_POSTWRITE
-} bus_dmasync_op_t;
-
-/*
- * bus_dma_tag_t
- *
- * A machine-dependent opaque type describing the characteristics
- * of how to perform DMA mappings. This structure encapsultes
- * information concerning address and alignment restrictions, number
- * of S/G segments, amount of data per S/G segment, etc.
- */
-typedef struct bus_dma_tag *bus_dma_tag_t;
-
-/*
- * bus_dmamap_t
- *
- * DMA mapping instance information.
- */
-typedef struct bus_dmamap *bus_dmamap_t;
-
-/*
- * bus_dma_segment_t
- *
- * Describes a single contiguous DMA transaction. Values
- * are suitable for programming into DMA registers.
- */
-typedef struct bus_dma_segment {
- bus_addr_t ds_addr; /* DMA address */
- bus_size_t ds_len; /* length of transfer */
-} bus_dma_segment_t;
-
-/*
- * A function that returns 1 if the address cannot be accessed by
- * a device and 0 if it can be.
- */
-typedef int bus_dma_filter_t(void *, bus_addr_t);
-
-/*
- * Allocate a device specific dma_tag encapsulating the constraints of
- * the parent tag in addition to other restrictions specified:
- *
- * alignment: alignment for segments.
- * boundary: Boundary that segments cannot cross.
- * lowaddr: Low restricted address that cannot appear in a mapping.
- * highaddr: High restricted address that cannot appear in a mapping.
- * filtfunc: An optional function to further test if an address
- * within the range of lowaddr and highaddr cannot appear
- * in a mapping.
- * filtfuncarg: An argument that will be passed to filtfunc in addition
- * to the address to test.
- * maxsize: Maximum mapping size supported by this tag.
- * nsegments: Number of discontinuities allowed in maps.
- * maxsegsz: Maximum size of a segment in the map.
- * flags: Bus DMA flags.
- * dmat: A pointer to set to a valid dma tag should the return
- * value of this function indicate success.
- */
-/* XXX Should probably allow specification of alignment */
-int bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignemnt,
- bus_size_t boundary, bus_addr_t lowaddr,
- bus_addr_t highaddr, bus_dma_filter_t *filtfunc,
- void *filtfuncarg, bus_size_t maxsize, int nsegments,
- bus_size_t maxsegsz, int flags, bus_dma_tag_t *dmat);
-
-int bus_dma_tag_destroy(bus_dma_tag_t dmat);
-
-/*
- * Allocate a handle for mapping from kva/uva/physical
- * address space into bus device space.
- */
-int bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp);
-
-/*
- * Destroy a handle for mapping from kva/uva/physical
- * address space into bus device space.
- */
-int bus_dmamap_destroy(bus_dma_tag_t dmat, bus_dmamap_t map);
-
-/*
- * Allocate a piece of memory that can be efficiently mapped into
- * bus device space based on the constraints lited in the dma tag.
- * A dmamap to for use with dmamap_load is also allocated.
- */
-int bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
- bus_dmamap_t *mapp);
-
-/*
- * Free a piece of memory and it's allociated dmamap, that was allocated
- * via bus_dmamem_alloc.
- */
-void bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map);
-
-/*
- * A function that processes a successfully loaded dma map or an error
- * from a delayed load map.
- */
-typedef void bus_dmamap_callback_t(void *, bus_dma_segment_t *, int, int);
-
-/*
- * Map the buffer buf into bus space using the dmamap map.
- */
-int bus_dmamap_load(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf,
- bus_size_t buflen, bus_dmamap_callback_t *callback,
- void *callback_arg, int flags);
-
-/*
- * Perform a syncronization operation on the given map.
- */
-void _bus_dmamap_sync(bus_dma_tag_t, bus_dmamap_t, bus_dmasync_op_t);
-#define bus_dmamap_sync(dmat, dmamap, op) \
- if ((dmamap) != NULL) \
- _bus_dmamap_sync(dmat, dmamap, op)
-
-/*
- * Release the mapping held by map.
- */
-void _bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map);
-#define bus_dmamap_unload(dmat, dmamap) \
- if ((dmamap) != NULL) \
- _bus_dmamap_unload(dmat, dmamap)
-
-#endif /* _I386_BUS_H_ */
diff --git a/sys/sys/diskmbr.h b/sys/sys/diskmbr.h
deleted file mode 100644
index 5c5d7463b29b..000000000000
--- a/sys/sys/diskmbr.h
+++ /dev/null
@@ -1,467 +0,0 @@
-/*
- * Copyright (c) 1987, 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)disklabel.h 8.2 (Berkeley) 7/10/94
- * $FreeBSD$
- */
-
-#ifndef _SYS_DISKLABEL_H_
-#define _SYS_DISKLABEL_H_
-
-#ifndef _KERNEL
-#include <sys/types.h>
-#endif
-#include <sys/ioccom.h>
-
-/*
- * Disk description table, see disktab(5)
- */
-#define _PATH_DISKTAB "/etc/disktab"
-#define DISKTAB "/etc/disktab" /* deprecated */
-
-/*
- * Each disk has a label which includes information about the hardware
- * disk geometry, filesystem partitions, and drive specific information.
- * The label is in block 0 or 1, possibly offset from the beginning
- * to leave room for a bootstrap, etc.
- */
-
-/* XXX these should be defined per controller (or drive) elsewhere, not here! */
-#ifdef __i386__
-#define LABELSECTOR 1 /* sector containing label */
-#define LABELOFFSET 0 /* offset of label in sector */
-#endif
-
-#ifdef __alpha__
-#define LABELSECTOR 0
-#define LABELOFFSET 64
-#endif
-
-#ifndef LABELSECTOR
-#define LABELSECTOR 0 /* sector containing label */
-#endif
-
-#ifndef LABELOFFSET
-#define LABELOFFSET 64 /* offset of label in sector */
-#endif
-
-#define DISKMAGIC ((u_int32_t)0x82564557) /* The disk magic number */
-#ifndef MAXPARTITIONS
-#define MAXPARTITIONS 8
-#endif
-
-#define LABEL_PART 2 /* partition containing label */
-#define RAW_PART 2 /* partition containing whole disk */
-#define SWAP_PART 1 /* partition normally containing swap */
-
-#ifndef LOCORE
-struct disklabel {
- u_int32_t d_magic; /* the magic number */
- u_int16_t d_type; /* drive type */
- u_int16_t d_subtype; /* controller/d_type specific */
- char d_typename[16]; /* type name, e.g. "eagle" */
-
- /*
- * d_packname contains the pack identifier and is returned when
- * the disklabel is read off the disk or in-core copy.
- * d_boot0 and d_boot1 are the (optional) names of the
- * primary (block 0) and secondary (block 1-15) bootstraps
- * as found in /boot. These are returned when using
- * getdiskbyname(3) to retrieve the values from /etc/disktab.
- */
- union {
- char un_d_packname[16]; /* pack identifier */
- struct {
- char *un_d_boot0; /* primary bootstrap name */
- char *un_d_boot1; /* secondary bootstrap name */
- } un_b;
- } d_un;
-#define d_packname d_un.un_d_packname
-#define d_boot0 d_un.un_b.un_d_boot0
-#define d_boot1 d_un.un_b.un_d_boot1
-
- /* disk geometry: */
- u_int32_t d_secsize; /* # of bytes per sector */
- u_int32_t d_nsectors; /* # of data sectors per track */
- u_int32_t d_ntracks; /* # of tracks per cylinder */
- u_int32_t d_ncylinders; /* # of data cylinders per unit */
- u_int32_t d_secpercyl; /* # of data sectors per cylinder */
- u_int32_t d_secperunit; /* # of data sectors per unit */
-
- /*
- * Spares (bad sector replacements) below are not counted in
- * d_nsectors or d_secpercyl. Spare sectors are assumed to
- * be physical sectors which occupy space at the end of each
- * track and/or cylinder.
- */
- u_int16_t d_sparespertrack; /* # of spare sectors per track */
- u_int16_t d_sparespercyl; /* # of spare sectors per cylinder */
- /*
- * Alternate cylinders include maintenance, replacement, configuration
- * description areas, etc.
- */
- u_int32_t d_acylinders; /* # of alt. cylinders per unit */
-
- /* hardware characteristics: */
- /*
- * d_interleave, d_trackskew and d_cylskew describe perturbations
- * in the media format used to compensate for a slow controller.
- * Interleave is physical sector interleave, set up by the
- * formatter or controller when formatting. When interleaving is
- * in use, logically adjacent sectors are not physically
- * contiguous, but instead are separated by some number of
- * sectors. It is specified as the ratio of physical sectors
- * traversed per logical sector. Thus an interleave of 1:1
- * implies contiguous layout, while 2:1 implies that logical
- * sector 0 is separated by one sector from logical sector 1.
- * d_trackskew is the offset of sector 0 on track N relative to
- * sector 0 on track N-1 on the same cylinder. Finally, d_cylskew
- * is the offset of sector 0 on cylinder N relative to sector 0
- * on cylinder N-1.
- */
- u_int16_t d_rpm; /* rotational speed */
- u_int16_t d_interleave; /* hardware sector interleave */
- u_int16_t d_trackskew; /* sector 0 skew, per track */
- u_int16_t d_cylskew; /* sector 0 skew, per cylinder */
- u_int32_t d_headswitch; /* head switch time, usec */
- u_int32_t d_trkseek; /* track-to-track seek, usec */
- u_int32_t d_flags; /* generic flags */
-#define NDDATA 5
- u_int32_t d_drivedata[NDDATA]; /* drive-type specific information */
-#define NSPARE 5
- u_int32_t d_spare[NSPARE]; /* reserved for future use */
- u_int32_t d_magic2; /* the magic number (again) */
- u_int16_t d_checksum; /* xor of data incl. partitions */
-
- /* filesystem and partition information: */
- u_int16_t d_npartitions; /* number of partitions in following */
- u_int32_t d_bbsize; /* size of boot area at sn0, bytes */
- u_int32_t d_sbsize; /* max size of fs superblock, bytes */
- struct partition { /* the partition table */
- u_int32_t p_size; /* number of sectors in partition */
- u_int32_t p_offset; /* starting sector */
- u_int32_t p_fsize; /* filesystem basic fragment size */
- u_int8_t p_fstype; /* filesystem type, see below */
- u_int8_t p_frag; /* filesystem fragments per block */
- union {
- u_int16_t cpg; /* UFS: FS cylinders per group */
- u_int16_t sgs; /* LFS: FS segment shift */
- } __partition_u1;
-#define p_cpg __partition_u1.cpg
-#define p_sgs __partition_u1.sgs
- } d_partitions[MAXPARTITIONS]; /* actually may be more */
-};
-#else /* LOCORE */
- /*
- * offsets for asm boot files.
- */
- .set d_secsize,40
- .set d_nsectors,44
- .set d_ntracks,48
- .set d_ncylinders,52
- .set d_secpercyl,56
- .set d_secperunit,60
- .set d_end_,276 /* size of disk label */
-#endif /* LOCORE */
-
-/* d_type values: */
-#define DTYPE_SMD 1 /* SMD, XSMD; VAX hp/up */
-#define DTYPE_MSCP 2 /* MSCP */
-#define DTYPE_DEC 3 /* other DEC (rk, rl) */
-#define DTYPE_SCSI 4 /* SCSI */
-#define DTYPE_ESDI 5 /* ESDI interface */
-#define DTYPE_ST506 6 /* ST506 etc. */
-#define DTYPE_HPIB 7 /* CS/80 on HP-IB */
-#define DTYPE_HPFL 8 /* HP Fiber-link */
-#define DTYPE_FLOPPY 10 /* floppy */
-#define DTYPE_CCD 11 /* concatenated disk */
-#define DTYPE_VINUM 12 /* vinum volume */
-#define DTYPE_DOC2K 13 /* Msys DiskOnChip */
-
-#if defined(PC98) && !defined(PC98_ATCOMPAT)
-#define DSTYPE_SEC256 0x80 /* physical sector size=256 */
-#endif
-
-#ifdef DKTYPENAMES
-static char *dktypenames[] = {
- "unknown",
- "SMD",
- "MSCP",
- "old DEC",
- "SCSI",
- "ESDI",
- "ST506",
- "HP-IB",
- "HP-FL",
- "type 9",
- "floppy",
- "CCD",
- "Vinum",
- "DOC2K",
- NULL
-};
-#define DKMAXTYPES (sizeof(dktypenames) / sizeof(dktypenames[0]) - 1)
-#endif
-
-/*
- * Filesystem type and version.
- * Used to interpret other filesystem-specific
- * per-partition information.
- */
-#define FS_UNUSED 0 /* unused */
-#define FS_SWAP 1 /* swap */
-#define FS_V6 2 /* Sixth Edition */
-#define FS_V7 3 /* Seventh Edition */
-#define FS_SYSV 4 /* System V */
-#define FS_V71K 5 /* V7 with 1K blocks (4.1, 2.9) */
-#define FS_V8 6 /* Eighth Edition, 4K blocks */
-#define FS_BSDFFS 7 /* 4.2BSD fast file system */
-#define FS_MSDOS 8 /* MSDOS file system */
-#define FS_BSDLFS 9 /* 4.4BSD log-structured file system */
-#define FS_OTHER 10 /* in use, but unknown/unsupported */
-#define FS_HPFS 11 /* OS/2 high-performance file system */
-#define FS_ISO9660 12 /* ISO 9660, normally CD-ROM */
-#define FS_BOOT 13 /* partition contains bootstrap */
-#define FS_VINUM 14 /* Vinum drive */
-
-#ifdef DKTYPENAMES
-static char *fstypenames[] = {
- "unused",
- "swap",
- "Version 6",
- "Version 7",
- "System V",
- "4.1BSD",
- "Eighth Edition",
- "4.2BSD",
- "MSDOS",
- "4.4LFS",
- "unknown",
- "HPFS",
- "ISO9660",
- "boot",
- "vinum",
- NULL
-};
-#define FSMAXTYPES (sizeof(fstypenames) / sizeof(fstypenames[0]) - 1)
-#endif
-
-/*
- * flags shared by various drives:
- */
-#define D_REMOVABLE 0x01 /* removable media */
-#define D_ECC 0x02 /* supports ECC */
-#define D_BADSECT 0x04 /* supports bad sector forw. */
-#define D_RAMDISK 0x08 /* disk emulator */
-#define D_CHAIN 0x10 /* can do back-back transfers */
-
-/*
- * Drive data for SMD.
- */
-#define d_smdflags d_drivedata[0]
-#define D_SSE 0x1 /* supports skip sectoring */
-#define d_mindist d_drivedata[1]
-#define d_maxdist d_drivedata[2]
-#define d_sdist d_drivedata[3]
-
-/*
- * Drive data for ST506.
- */
-#define d_precompcyl d_drivedata[0]
-#define d_gap3 d_drivedata[1] /* used only when formatting */
-
-/*
- * Drive data for SCSI.
- */
-#define d_blind d_drivedata[0]
-
-#ifndef LOCORE
-/*
- * Structure used to perform a format or other raw operation, returning
- * data and/or register values. Register identification and format
- * are device- and driver-dependent.
- */
-struct format_op {
- char *df_buf;
- int df_count; /* value-result */
- daddr_t df_startblk;
- int df_reg[8]; /* result */
-};
-
-/*
- * Structure used internally to retrieve information about a partition
- * on a disk.
- */
-struct partinfo {
- struct disklabel *disklab;
- struct partition *part;
-};
-
-/* DOS partition table -- located in boot block */
-
-#if defined(PC98) && !defined(PC98_ATCOMPAT)
-#define DOSBBSECTOR 0 /* DOS boot block relative sector number */
-#define DOSLABELSECTOR 1 /* 0: 256b/s, 1: 512b/s */
-#define DOSPARTOFF 0
-#define NDOSPART 16
-#define DOSPTYP_386BSD 0x94 /* 386BSD partition type */
-#define MBR_PTYPE_FreeBSD 0x94 /* FreeBSD partition type */
-
-struct dos_partition {
- unsigned char dp_mid;
-#define DOSMID_386BSD (0x14|0x80) /* 386bsd|bootable */
- unsigned char dp_sid;
-#define DOSSID_386BSD (0x44|0x80) /* 386bsd|active */
- unsigned char dp_dum1;
- unsigned char dp_dum2;
- unsigned char dp_ipl_sct;
- unsigned char dp_ipl_head;
- unsigned short dp_ipl_cyl;
- unsigned char dp_ssect; /* starting sector */
- unsigned char dp_shd; /* starting head */
- unsigned short dp_scyl; /* starting cylinder */
- unsigned char dp_esect; /* end sector */
- unsigned char dp_ehd; /* end head */
- unsigned short dp_ecyl; /* end cylinder */
- unsigned char dp_name[16];
-};
-
-#else /* IBMPC */
-#define DOSBBSECTOR 0 /* DOS boot block relative sector number */
-#define DOSPARTOFF 446
-#define NDOSPART 4
-#define DOSPTYP_386BSD 0xa5 /* 386BSD partition type */
-
-struct dos_partition {
- unsigned char dp_flag; /* bootstrap flags */
- unsigned char dp_shd; /* starting head */
- unsigned char dp_ssect; /* starting sector */
- unsigned char dp_scyl; /* starting cylinder */
- unsigned char dp_typ; /* partition type */
- unsigned char dp_ehd; /* end head */
- unsigned char dp_esect; /* end sector */
- unsigned char dp_ecyl; /* end cylinder */
- u_int32_t dp_start; /* absolute starting sector number */
- u_int32_t dp_size; /* partition size in sectors */
-};
-#endif
-
-#define DPSECT(s) ((s) & 0x3f) /* isolate relevant bits of sector */
-#define DPCYL(c, s) ((c) + (((s) & 0xc0)<<2)) /* and those that are cylinder */
-
-/*
- * Disk-specific ioctls.
- */
- /* get and set disklabel; DIOCGPART used internally */
-#define DIOCGDINFO _IOR('d', 101, struct disklabel)/* get */
-#define DIOCSDINFO _IOW('d', 102, struct disklabel)/* set */
-#define DIOCWDINFO _IOW('d', 103, struct disklabel)/* set, update disk */
-#define DIOCGPART _IOW('d', 104, struct partinfo) /* get partition */
-
-#define DIOCWLABEL _IOW('d', 109, int) /* write en/disable label */
-
-#ifdef _KERNEL
-
-/*
- * XXX encoding of disk minor numbers, should be elsewhere.
- *
- * See <sys/reboot.h> for a possibly better encoding.
- *
- * "cpio -H newc" can be used to back up device files with large minor
- * numbers (but not ones >= 2^31). Old cpio formats and all tar formats
- * don't have enough bits, and cpio and tar don't notice the lossage.
- * There are also some sign extension bugs.
- */
-
-/*
- 3 2 1 0
- 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
- _________________________________________________________________
- | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
- -----------------------------------------------------------------
- | TYPE |UNIT_2 | SLICE | MAJOR? | UNIT |PART |
- -----------------------------------------------------------------
-*/
-#define dkmakeminor(unit, slice, part) \
- (((slice) << 16) | (((unit) & 0x1e0) << 16) | \
- (((unit) & 0x1f) << 3) | (part))
-static __inline dev_t
-dkmodpart(dev_t dev, int part)
-{
- return (makedev(major(dev), (minor(dev) & ~7) | part));
-}
-
-static __inline dev_t
-dkmodslice(dev_t dev, int slice)
-{
- return (makedev(major(dev), (minor(dev) & ~0x1f0000) | (slice << 16)));
-}
-
-#define dkpart(dev) (minor(dev) & 7)
-#define dkslice(dev) ((minor(dev) >> 16) & 0x1f)
-#define dktype(dev) ((minor(dev) >> 25) & 0x7f)
-
-static __inline u_int
-dkunit(dev_t dev)
-{
- return (((minor(dev) >> 16) & 0x1e0) | ((minor(dev) >> 3) & 0x1f));
-}
-
-struct buf;
-struct buf_queue_head;
-
-int bounds_check_with_label __P((struct buf *bp, struct disklabel *lp,
- int wlabel));
-void diskerr __P((struct buf *bp, char *what, int pri, int blkdone,
- struct disklabel *lp));
-void disksort __P((struct buf *ap, struct buf *bp));
-u_int dkcksum __P((struct disklabel *lp));
-char *readdisklabel __P((dev_t dev, struct disklabel *lp));
-void bufqdisksort __P((struct buf_queue_head *ap, struct buf *bp));
-int setdisklabel __P((struct disklabel *olp, struct disklabel *nlp,
- u_long openmask));
-int writedisklabel __P((dev_t dev, struct disklabel *lp));
-#ifdef __alpha__
-void alpha_fix_srm_checksum __P((struct buf *bp));
-#endif
-
-#endif /* _KERNEL */
-
-#endif /* LOCORE */
-
-#ifndef _KERNEL
-__BEGIN_DECLS
-struct disklabel *getdiskbyname __P((const char *));
-__END_DECLS
-#endif
-
-#endif /* !_SYS_DISKLABEL_H_ */
diff --git a/sys/sys/diskpc98.h b/sys/sys/diskpc98.h
deleted file mode 100644
index 5c5d7463b29b..000000000000
--- a/sys/sys/diskpc98.h
+++ /dev/null
@@ -1,467 +0,0 @@
-/*
- * Copyright (c) 1987, 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)disklabel.h 8.2 (Berkeley) 7/10/94
- * $FreeBSD$
- */
-
-#ifndef _SYS_DISKLABEL_H_
-#define _SYS_DISKLABEL_H_
-
-#ifndef _KERNEL
-#include <sys/types.h>
-#endif
-#include <sys/ioccom.h>
-
-/*
- * Disk description table, see disktab(5)
- */
-#define _PATH_DISKTAB "/etc/disktab"
-#define DISKTAB "/etc/disktab" /* deprecated */
-
-/*
- * Each disk has a label which includes information about the hardware
- * disk geometry, filesystem partitions, and drive specific information.
- * The label is in block 0 or 1, possibly offset from the beginning
- * to leave room for a bootstrap, etc.
- */
-
-/* XXX these should be defined per controller (or drive) elsewhere, not here! */
-#ifdef __i386__
-#define LABELSECTOR 1 /* sector containing label */
-#define LABELOFFSET 0 /* offset of label in sector */
-#endif
-
-#ifdef __alpha__
-#define LABELSECTOR 0
-#define LABELOFFSET 64
-#endif
-
-#ifndef LABELSECTOR
-#define LABELSECTOR 0 /* sector containing label */
-#endif
-
-#ifndef LABELOFFSET
-#define LABELOFFSET 64 /* offset of label in sector */
-#endif
-
-#define DISKMAGIC ((u_int32_t)0x82564557) /* The disk magic number */
-#ifndef MAXPARTITIONS
-#define MAXPARTITIONS 8
-#endif
-
-#define LABEL_PART 2 /* partition containing label */
-#define RAW_PART 2 /* partition containing whole disk */
-#define SWAP_PART 1 /* partition normally containing swap */
-
-#ifndef LOCORE
-struct disklabel {
- u_int32_t d_magic; /* the magic number */
- u_int16_t d_type; /* drive type */
- u_int16_t d_subtype; /* controller/d_type specific */
- char d_typename[16]; /* type name, e.g. "eagle" */
-
- /*
- * d_packname contains the pack identifier and is returned when
- * the disklabel is read off the disk or in-core copy.
- * d_boot0 and d_boot1 are the (optional) names of the
- * primary (block 0) and secondary (block 1-15) bootstraps
- * as found in /boot. These are returned when using
- * getdiskbyname(3) to retrieve the values from /etc/disktab.
- */
- union {
- char un_d_packname[16]; /* pack identifier */
- struct {
- char *un_d_boot0; /* primary bootstrap name */
- char *un_d_boot1; /* secondary bootstrap name */
- } un_b;
- } d_un;
-#define d_packname d_un.un_d_packname
-#define d_boot0 d_un.un_b.un_d_boot0
-#define d_boot1 d_un.un_b.un_d_boot1
-
- /* disk geometry: */
- u_int32_t d_secsize; /* # of bytes per sector */
- u_int32_t d_nsectors; /* # of data sectors per track */
- u_int32_t d_ntracks; /* # of tracks per cylinder */
- u_int32_t d_ncylinders; /* # of data cylinders per unit */
- u_int32_t d_secpercyl; /* # of data sectors per cylinder */
- u_int32_t d_secperunit; /* # of data sectors per unit */
-
- /*
- * Spares (bad sector replacements) below are not counted in
- * d_nsectors or d_secpercyl. Spare sectors are assumed to
- * be physical sectors which occupy space at the end of each
- * track and/or cylinder.
- */
- u_int16_t d_sparespertrack; /* # of spare sectors per track */
- u_int16_t d_sparespercyl; /* # of spare sectors per cylinder */
- /*
- * Alternate cylinders include maintenance, replacement, configuration
- * description areas, etc.
- */
- u_int32_t d_acylinders; /* # of alt. cylinders per unit */
-
- /* hardware characteristics: */
- /*
- * d_interleave, d_trackskew and d_cylskew describe perturbations
- * in the media format used to compensate for a slow controller.
- * Interleave is physical sector interleave, set up by the
- * formatter or controller when formatting. When interleaving is
- * in use, logically adjacent sectors are not physically
- * contiguous, but instead are separated by some number of
- * sectors. It is specified as the ratio of physical sectors
- * traversed per logical sector. Thus an interleave of 1:1
- * implies contiguous layout, while 2:1 implies that logical
- * sector 0 is separated by one sector from logical sector 1.
- * d_trackskew is the offset of sector 0 on track N relative to
- * sector 0 on track N-1 on the same cylinder. Finally, d_cylskew
- * is the offset of sector 0 on cylinder N relative to sector 0
- * on cylinder N-1.
- */
- u_int16_t d_rpm; /* rotational speed */
- u_int16_t d_interleave; /* hardware sector interleave */
- u_int16_t d_trackskew; /* sector 0 skew, per track */
- u_int16_t d_cylskew; /* sector 0 skew, per cylinder */
- u_int32_t d_headswitch; /* head switch time, usec */
- u_int32_t d_trkseek; /* track-to-track seek, usec */
- u_int32_t d_flags; /* generic flags */
-#define NDDATA 5
- u_int32_t d_drivedata[NDDATA]; /* drive-type specific information */
-#define NSPARE 5
- u_int32_t d_spare[NSPARE]; /* reserved for future use */
- u_int32_t d_magic2; /* the magic number (again) */
- u_int16_t d_checksum; /* xor of data incl. partitions */
-
- /* filesystem and partition information: */
- u_int16_t d_npartitions; /* number of partitions in following */
- u_int32_t d_bbsize; /* size of boot area at sn0, bytes */
- u_int32_t d_sbsize; /* max size of fs superblock, bytes */
- struct partition { /* the partition table */
- u_int32_t p_size; /* number of sectors in partition */
- u_int32_t p_offset; /* starting sector */
- u_int32_t p_fsize; /* filesystem basic fragment size */
- u_int8_t p_fstype; /* filesystem type, see below */
- u_int8_t p_frag; /* filesystem fragments per block */
- union {
- u_int16_t cpg; /* UFS: FS cylinders per group */
- u_int16_t sgs; /* LFS: FS segment shift */
- } __partition_u1;
-#define p_cpg __partition_u1.cpg
-#define p_sgs __partition_u1.sgs
- } d_partitions[MAXPARTITIONS]; /* actually may be more */
-};
-#else /* LOCORE */
- /*
- * offsets for asm boot files.
- */
- .set d_secsize,40
- .set d_nsectors,44
- .set d_ntracks,48
- .set d_ncylinders,52
- .set d_secpercyl,56
- .set d_secperunit,60
- .set d_end_,276 /* size of disk label */
-#endif /* LOCORE */
-
-/* d_type values: */
-#define DTYPE_SMD 1 /* SMD, XSMD; VAX hp/up */
-#define DTYPE_MSCP 2 /* MSCP */
-#define DTYPE_DEC 3 /* other DEC (rk, rl) */
-#define DTYPE_SCSI 4 /* SCSI */
-#define DTYPE_ESDI 5 /* ESDI interface */
-#define DTYPE_ST506 6 /* ST506 etc. */
-#define DTYPE_HPIB 7 /* CS/80 on HP-IB */
-#define DTYPE_HPFL 8 /* HP Fiber-link */
-#define DTYPE_FLOPPY 10 /* floppy */
-#define DTYPE_CCD 11 /* concatenated disk */
-#define DTYPE_VINUM 12 /* vinum volume */
-#define DTYPE_DOC2K 13 /* Msys DiskOnChip */
-
-#if defined(PC98) && !defined(PC98_ATCOMPAT)
-#define DSTYPE_SEC256 0x80 /* physical sector size=256 */
-#endif
-
-#ifdef DKTYPENAMES
-static char *dktypenames[] = {
- "unknown",
- "SMD",
- "MSCP",
- "old DEC",
- "SCSI",
- "ESDI",
- "ST506",
- "HP-IB",
- "HP-FL",
- "type 9",
- "floppy",
- "CCD",
- "Vinum",
- "DOC2K",
- NULL
-};
-#define DKMAXTYPES (sizeof(dktypenames) / sizeof(dktypenames[0]) - 1)
-#endif
-
-/*
- * Filesystem type and version.
- * Used to interpret other filesystem-specific
- * per-partition information.
- */
-#define FS_UNUSED 0 /* unused */
-#define FS_SWAP 1 /* swap */
-#define FS_V6 2 /* Sixth Edition */
-#define FS_V7 3 /* Seventh Edition */
-#define FS_SYSV 4 /* System V */
-#define FS_V71K 5 /* V7 with 1K blocks (4.1, 2.9) */
-#define FS_V8 6 /* Eighth Edition, 4K blocks */
-#define FS_BSDFFS 7 /* 4.2BSD fast file system */
-#define FS_MSDOS 8 /* MSDOS file system */
-#define FS_BSDLFS 9 /* 4.4BSD log-structured file system */
-#define FS_OTHER 10 /* in use, but unknown/unsupported */
-#define FS_HPFS 11 /* OS/2 high-performance file system */
-#define FS_ISO9660 12 /* ISO 9660, normally CD-ROM */
-#define FS_BOOT 13 /* partition contains bootstrap */
-#define FS_VINUM 14 /* Vinum drive */
-
-#ifdef DKTYPENAMES
-static char *fstypenames[] = {
- "unused",
- "swap",
- "Version 6",
- "Version 7",
- "System V",
- "4.1BSD",
- "Eighth Edition",
- "4.2BSD",
- "MSDOS",
- "4.4LFS",
- "unknown",
- "HPFS",
- "ISO9660",
- "boot",
- "vinum",
- NULL
-};
-#define FSMAXTYPES (sizeof(fstypenames) / sizeof(fstypenames[0]) - 1)
-#endif
-
-/*
- * flags shared by various drives:
- */
-#define D_REMOVABLE 0x01 /* removable media */
-#define D_ECC 0x02 /* supports ECC */
-#define D_BADSECT 0x04 /* supports bad sector forw. */
-#define D_RAMDISK 0x08 /* disk emulator */
-#define D_CHAIN 0x10 /* can do back-back transfers */
-
-/*
- * Drive data for SMD.
- */
-#define d_smdflags d_drivedata[0]
-#define D_SSE 0x1 /* supports skip sectoring */
-#define d_mindist d_drivedata[1]
-#define d_maxdist d_drivedata[2]
-#define d_sdist d_drivedata[3]
-
-/*
- * Drive data for ST506.
- */
-#define d_precompcyl d_drivedata[0]
-#define d_gap3 d_drivedata[1] /* used only when formatting */
-
-/*
- * Drive data for SCSI.
- */
-#define d_blind d_drivedata[0]
-
-#ifndef LOCORE
-/*
- * Structure used to perform a format or other raw operation, returning
- * data and/or register values. Register identification and format
- * are device- and driver-dependent.
- */
-struct format_op {
- char *df_buf;
- int df_count; /* value-result */
- daddr_t df_startblk;
- int df_reg[8]; /* result */
-};
-
-/*
- * Structure used internally to retrieve information about a partition
- * on a disk.
- */
-struct partinfo {
- struct disklabel *disklab;
- struct partition *part;
-};
-
-/* DOS partition table -- located in boot block */
-
-#if defined(PC98) && !defined(PC98_ATCOMPAT)
-#define DOSBBSECTOR 0 /* DOS boot block relative sector number */
-#define DOSLABELSECTOR 1 /* 0: 256b/s, 1: 512b/s */
-#define DOSPARTOFF 0
-#define NDOSPART 16
-#define DOSPTYP_386BSD 0x94 /* 386BSD partition type */
-#define MBR_PTYPE_FreeBSD 0x94 /* FreeBSD partition type */
-
-struct dos_partition {
- unsigned char dp_mid;
-#define DOSMID_386BSD (0x14|0x80) /* 386bsd|bootable */
- unsigned char dp_sid;
-#define DOSSID_386BSD (0x44|0x80) /* 386bsd|active */
- unsigned char dp_dum1;
- unsigned char dp_dum2;
- unsigned char dp_ipl_sct;
- unsigned char dp_ipl_head;
- unsigned short dp_ipl_cyl;
- unsigned char dp_ssect; /* starting sector */
- unsigned char dp_shd; /* starting head */
- unsigned short dp_scyl; /* starting cylinder */
- unsigned char dp_esect; /* end sector */
- unsigned char dp_ehd; /* end head */
- unsigned short dp_ecyl; /* end cylinder */
- unsigned char dp_name[16];
-};
-
-#else /* IBMPC */
-#define DOSBBSECTOR 0 /* DOS boot block relative sector number */
-#define DOSPARTOFF 446
-#define NDOSPART 4
-#define DOSPTYP_386BSD 0xa5 /* 386BSD partition type */
-
-struct dos_partition {
- unsigned char dp_flag; /* bootstrap flags */
- unsigned char dp_shd; /* starting head */
- unsigned char dp_ssect; /* starting sector */
- unsigned char dp_scyl; /* starting cylinder */
- unsigned char dp_typ; /* partition type */
- unsigned char dp_ehd; /* end head */
- unsigned char dp_esect; /* end sector */
- unsigned char dp_ecyl; /* end cylinder */
- u_int32_t dp_start; /* absolute starting sector number */
- u_int32_t dp_size; /* partition size in sectors */
-};
-#endif
-
-#define DPSECT(s) ((s) & 0x3f) /* isolate relevant bits of sector */
-#define DPCYL(c, s) ((c) + (((s) & 0xc0)<<2)) /* and those that are cylinder */
-
-/*
- * Disk-specific ioctls.
- */
- /* get and set disklabel; DIOCGPART used internally */
-#define DIOCGDINFO _IOR('d', 101, struct disklabel)/* get */
-#define DIOCSDINFO _IOW('d', 102, struct disklabel)/* set */
-#define DIOCWDINFO _IOW('d', 103, struct disklabel)/* set, update disk */
-#define DIOCGPART _IOW('d', 104, struct partinfo) /* get partition */
-
-#define DIOCWLABEL _IOW('d', 109, int) /* write en/disable label */
-
-#ifdef _KERNEL
-
-/*
- * XXX encoding of disk minor numbers, should be elsewhere.
- *
- * See <sys/reboot.h> for a possibly better encoding.
- *
- * "cpio -H newc" can be used to back up device files with large minor
- * numbers (but not ones >= 2^31). Old cpio formats and all tar formats
- * don't have enough bits, and cpio and tar don't notice the lossage.
- * There are also some sign extension bugs.
- */
-
-/*
- 3 2 1 0
- 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
- _________________________________________________________________
- | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
- -----------------------------------------------------------------
- | TYPE |UNIT_2 | SLICE | MAJOR? | UNIT |PART |
- -----------------------------------------------------------------
-*/
-#define dkmakeminor(unit, slice, part) \
- (((slice) << 16) | (((unit) & 0x1e0) << 16) | \
- (((unit) & 0x1f) << 3) | (part))
-static __inline dev_t
-dkmodpart(dev_t dev, int part)
-{
- return (makedev(major(dev), (minor(dev) & ~7) | part));
-}
-
-static __inline dev_t
-dkmodslice(dev_t dev, int slice)
-{
- return (makedev(major(dev), (minor(dev) & ~0x1f0000) | (slice << 16)));
-}
-
-#define dkpart(dev) (minor(dev) & 7)
-#define dkslice(dev) ((minor(dev) >> 16) & 0x1f)
-#define dktype(dev) ((minor(dev) >> 25) & 0x7f)
-
-static __inline u_int
-dkunit(dev_t dev)
-{
- return (((minor(dev) >> 16) & 0x1e0) | ((minor(dev) >> 3) & 0x1f));
-}
-
-struct buf;
-struct buf_queue_head;
-
-int bounds_check_with_label __P((struct buf *bp, struct disklabel *lp,
- int wlabel));
-void diskerr __P((struct buf *bp, char *what, int pri, int blkdone,
- struct disklabel *lp));
-void disksort __P((struct buf *ap, struct buf *bp));
-u_int dkcksum __P((struct disklabel *lp));
-char *readdisklabel __P((dev_t dev, struct disklabel *lp));
-void bufqdisksort __P((struct buf_queue_head *ap, struct buf *bp));
-int setdisklabel __P((struct disklabel *olp, struct disklabel *nlp,
- u_long openmask));
-int writedisklabel __P((dev_t dev, struct disklabel *lp));
-#ifdef __alpha__
-void alpha_fix_srm_checksum __P((struct buf *bp));
-#endif
-
-#endif /* _KERNEL */
-
-#endif /* LOCORE */
-
-#ifndef _KERNEL
-__BEGIN_DECLS
-struct disklabel *getdiskbyname __P((const char *));
-__END_DECLS
-#endif
-
-#endif /* !_SYS_DISKLABEL_H_ */
diff --git a/sys/sys/fdcio.h b/sys/sys/fdcio.h
deleted file mode 100644
index 92724df1356e..000000000000
--- a/sys/sys/fdcio.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (C) 1992-1994 by Joerg Wunsch, Dresden
- * 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(S) ``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(S) 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _MACHINE_IOCTL_FD_H_
-#define _MACHINE_IOCTL_FD_H_
-
-#ifndef _KERNEL
-#include <sys/types.h>
-#endif
-#include <sys/ioccom.h>
-
-#define FD_FORMAT_VERSION 110 /* used to validate before formatting */
-#define FD_MAX_NSEC 36 /* highest known number of spt - allow for */
- /* 2.88 MB drives */
-
-struct fd_formb {
- int format_version; /* == FD_FORMAT_VERSION */
- int cyl, head;
- int transfer_rate; /* fdreg.h: FDC_???KBPS */
-
- union {
- struct fd_form_data {
- /*
- * DO NOT CHANGE THE LAYOUT OF THIS STRUCTS
- * it is hardware-dependent since it exactly
- * matches the byte sequence to write to FDC
- * during its `format track' operation
- */
- u_char secshift; /* 0 -> 128, ...; usually 2 -> 512 */
- u_char nsecs; /* must be <= FD_MAX_NSEC */
- u_char gaplen; /* GAP 3 length; usually 84 */
- u_char fillbyte; /* usually 0xf6 */
- struct fd_idfield_data {
- /*
- * data to write into id fields;
- * for obscure formats, they mustn't match
- * the real values (but mostly do)
- */
- u_char cylno; /* 0 thru 79 (or 39) */
- u_char headno; /* 0, or 1 */
- u_char secno; /* starting at 1! */
- u_char secsize; /* usually 2 */
- } idfields[FD_MAX_NSEC]; /* 0 <= idx < nsecs used */
- } structured;
- u_char raw[1]; /* to have continuous indexed access */
- } format_info;
-};
-
-/* make life easier */
-# define fd_formb_secshift format_info.structured.secshift
-# define fd_formb_nsecs format_info.structured.nsecs
-# define fd_formb_gaplen format_info.structured.gaplen
-# define fd_formb_fillbyte format_info.structured.fillbyte
-/* these data must be filled in for(i = 0; i < fd_formb_nsecs; i++) */
-# define fd_formb_cylno(i) format_info.structured.idfields[i].cylno
-# define fd_formb_headno(i) format_info.structured.idfields[i].headno
-# define fd_formb_secno(i) format_info.structured.idfields[i].secno
-# define fd_formb_secsize(i) format_info.structured.idfields[i].secsize
-
-struct fd_type {
- int sectrac; /* sectors per track */
- int secsize; /* size code for sectors */
- int datalen; /* data len when secsize = 0 */
- int gap; /* gap len between sectors */
- int tracks; /* total num of tracks */
- int size; /* size of disk in sectors */
- int steptrac; /* steps per cylinder */
- int trans; /* transfer speed code */
- int heads; /* number of heads */
- int f_gap; /* format gap len */
- int f_inter; /* format interleave factor */
-};
-
-#define FD_FORM _IOW('F', 61, struct fd_formb) /* format a track */
-#define FD_GTYPE _IOR('F', 62, struct fd_type) /* get drive type */
-#define FD_STYPE _IOW('F', 63, struct fd_type) /* set drive type */
-
-#define FD_GOPTS _IOR('F', 64, int) /* drive options, see below */
-#define FD_SOPTS _IOW('F', 65, int)
-
-#define FD_DEBUG _IOW('F', 66, int)
-
-#define FDOPT_NORETRY 0x0001 /* no retries on failure (cleared on close) */
-
-/*
- * The following definitions duplicate those in sys/i386/isa/fdreg.h
- * They are here since their values are to be used in the above
- * structure when formatting a floppy. For very obvious reasons, both
- * definitions must match ;-)
- */
-#ifndef FDC_500KBPS
-#define FDC_500KBPS 0x00 /* 500KBPS MFM drive transfer rate */
-#define FDC_300KBPS 0x01 /* 300KBPS MFM drive transfer rate */
-#define FDC_250KBPS 0x02 /* 250KBPS MFM drive transfer rate */
-#define FDC_125KBPS 0x03 /* 125KBPS FM drive transfer rate */
- /* for some controllers 1MPBS instead */
-#endif /* FDC_500KBPS */
-
-#endif /* !_MACHINE_IOCTL_FD_H_ */
diff --git a/sys/sys/ioctl_bt848.h b/sys/sys/ioctl_bt848.h
deleted file mode 100644
index 95538f9ac86f..000000000000
--- a/sys/sys/ioctl_bt848.h
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
- * extensions to ioctl_meteor.h for the bt848 cards
- *
- * $FreeBSD$
- */
-
-/*
- * frequency sets
- */
-#define CHNLSET_NABCST 1
-#define CHNLSET_CABLEIRC 2
-#define CHNLSET_CABLEHRC 3
-#define CHNLSET_WEUROPE 4
-#define CHNLSET_JPNBCST 5
-#define CHNLSET_JPNCABLE 6
-#define CHNLSET_XUSSR 7
-#define CHNLSET_AUSTRALIA 8
-#define CHNLSET_FRANCE 9
-#define CHNLSET_MIN CHNLSET_NABCST
-#define CHNLSET_MAX CHNLSET_FRANCE
-
-
-/*
- * constants for various tuner registers
- */
-#define BT848_HUEMIN (-90)
-#define BT848_HUEMAX 90
-#define BT848_HUECENTER 0
-#define BT848_HUERANGE 179.3
-#define BT848_HUEREGMIN (-128)
-#define BT848_HUEREGMAX 127
-#define BT848_HUESTEPS 256
-
-#define BT848_BRIGHTMIN (-50)
-#define BT848_BRIGHTMAX 50
-#define BT848_BRIGHTCENTER 0
-#define BT848_BRIGHTRANGE 99.6
-#define BT848_BRIGHTREGMIN (-128)
-#define BT848_BRIGHTREGMAX 127
-#define BT848_BRIGHTSTEPS 256
-
-#define BT848_CONTRASTMIN 0
-#define BT848_CONTRASTMAX 237
-#define BT848_CONTRASTCENTER 100
-#define BT848_CONTRASTRANGE 236.57
-#define BT848_CONTRASTREGMIN 0
-#define BT848_CONTRASTREGMAX 511
-#define BT848_CONTRASTSTEPS 512
-
-#define BT848_CHROMAMIN 0
-#define BT848_CHROMAMAX 284
-#define BT848_CHROMACENTER 100
-#define BT848_CHROMARANGE 283.89
-#define BT848_CHROMAREGMIN 0
-#define BT848_CHROMAREGMAX 511
-#define BT848_CHROMASTEPS 512
-
-#define BT848_SATUMIN 0
-#define BT848_SATUMAX 202
-#define BT848_SATUCENTER 100
-#define BT848_SATURANGE 201.18
-#define BT848_SATUREGMIN 0
-#define BT848_SATUREGMAX 511
-#define BT848_SATUSTEPS 512
-
-#define BT848_SATVMIN 0
-#define BT848_SATVMAX 284
-#define BT848_SATVCENTER 100
-#define BT848_SATVRANGE 283.89
-#define BT848_SATVREGMIN 0
-#define BT848_SATVREGMAX 511
-#define BT848_SATVSTEPS 512
-
-
-/*
- * audio stuff
- */
-#define AUDIO_TUNER 0x00 /* command for the audio routine */
-#define AUDIO_EXTERN 0x01 /* don't confuse them with bit */
-#define AUDIO_INTERN 0x02 /* settings */
-#define AUDIO_MUTE 0x80
-#define AUDIO_UNMUTE 0x81
-
-
-/*
- * EEProm stuff
- */
-struct eeProm {
- short offset;
- short count;
- u_char bytes[ 256 ];
-};
-
-
-/*
- * XXX: this is a hack, should be in ioctl_meteor.h
- * here to avoid touching that file for now...
- */
-#define TVTUNER_SETCHNL _IOW('x', 32, unsigned int) /* set channel */
-#define TVTUNER_GETCHNL _IOR('x', 32, unsigned int) /* get channel */
-#define TVTUNER_SETTYPE _IOW('x', 33, unsigned int) /* set tuner type */
-#define TVTUNER_GETTYPE _IOR('x', 33, unsigned int) /* get tuner type */
-#define TVTUNER_GETSTATUS _IOR('x', 34, unsigned int) /* get tuner status */
-#define TVTUNER_SETFREQ _IOW('x', 35, unsigned int) /* set frequency */
-#define TVTUNER_GETFREQ _IOR('x', 36, unsigned int) /* get frequency */
-
-
-#define BT848_SHUE _IOW('x', 37, int) /* set hue */
-#define BT848_GHUE _IOR('x', 37, int) /* get hue */
-#define BT848_SBRIG _IOW('x', 38, int) /* set brightness */
-#define BT848_GBRIG _IOR('x', 38, int) /* get brightness */
-#define BT848_SCSAT _IOW('x', 39, int) /* set chroma sat */
-#define BT848_GCSAT _IOR('x', 39, int) /* get UV saturation */
-#define BT848_SCONT _IOW('x', 40, int) /* set contrast */
-#define BT848_GCONT _IOR('x', 40, int) /* get contrast */
-#define BT848_SVSAT _IOW('x', 41, int) /* set chroma V sat */
-#define BT848_GVSAT _IOR('x', 41, int) /* get V saturation */
-#define BT848_SUSAT _IOW('x', 42, int) /* set chroma U sat */
-#define BT848_GUSAT _IOR('x', 42, int) /* get U saturation */
-
-#define BT848_SCBARS _IOR('x', 43, int) /* set colorbar */
-#define BT848_CCBARS _IOR('x', 44, int) /* clear colorbar */
-
-
-#define BT848_SAUDIO _IOW('x', 46, int) /* set audio channel */
-#define BT848_GAUDIO _IOR('x', 47, int) /* get audio channel */
-#define BT848_SBTSC _IOW('x', 48, int) /* set audio channel */
-
-#define BT848_GSTATUS _IOR('x', 49, unsigned int) /* reap status */
-
-#define BT848_WEEPROM _IOWR('x', 50, struct eeProm) /* write to EEProm */
-#define BT848_REEPROM _IOWR('x', 51, struct eeProm) /* read from EEProm */
-
-#define BT848_SIGNATURE _IOWR('x', 52, struct eeProm) /* read card sig */
-
-#define TVTUNER_SETAFC _IOW('x', 53, int) /* turn AFC on/off */
-#define TVTUNER_GETAFC _IOR('x', 54, int) /* query AFC on/off */
-#define BT848_SLNOTCH _IOW('x', 55, int) /* set luma notch */
-#define BT848_GLNOTCH _IOR('x', 56, int) /* get luma notch */
-
-/* Read/Write the BT848's I2C bus directly
- * b7-b0: data (read/write)
- * b15-b8: internal peripheral register (write)
- * b23-b16: i2c addr (write)
- * b31-b24: 1 = write, 0 = read
- */
-#define BT848_I2CWR _IOWR('x', 57, u_long) /* i2c read-write */
-
-/* Support for radio tuner */
-#define RADIO_SETMODE _IOW('x', 58, unsigned int) /* set radio modes */
-#define RADIO_GETMODE _IOR('x', 58, unsigned char) /* get radio modes */
-#define RADIO_AFC 0x01 /* These modes will probably not */
-#define RADIO_MONO 0x02 /* work on the FRxxxx. It does */
-#define RADIO_MUTE 0x08 /* work on the FMxxxx. */
-#define RADIO_SETFREQ _IOW('x', 59, unsigned int) /* set frequency */
-#define RADIO_GETFREQ _IOR('x', 59, unsigned int) /* set frequency */
- /* Argument is frequency*100MHz */
-
-/*
- * XXX: more bad magic,
- * we need to fix the METEORGINPUT to return something public
- * duplicate them here for now...
- */
-#define METEOR_DEV0 0x00001000
-#define METEOR_DEV1 0x00002000
-#define METEOR_DEV2 0x00004000
-#define METEOR_DEV3 0x00008000
-#define METEOR_DEV_SVIDEO 0x00006000
-/*
- * right now I don't know were to put these, but as they are suppose to be
- * a part of a common video capture interface, these should be relocated to
- * another place. Probably most of the METEOR_xxx defines need to be
- * renamed and moved to a common header
- */
-
-typedef enum { METEOR_PIXTYPE_RGB, METEOR_PIXTYPE_YUV,
- METEOR_PIXTYPE_YUV_PACKED,
- METEOR_PIXTYPE_YUV_12 } METEOR_PIXTYPE;
-
-
-struct meteor_pixfmt {
- u_int index; /* Index in supported pixfmt list */
- METEOR_PIXTYPE type; /* What's the board gonna feed us */
- u_int Bpp; /* Bytes per pixel */
- u_long masks[3]; /* R,G,B or Y,U,V masks, respectively */
- unsigned swap_bytes :1; /* Bytes swapped within shorts */
- unsigned swap_shorts:1; /* Shorts swapped within longs */
-};
-
-
-struct bktr_clip {
- int x_min;
- int x_max;
- int y_min;
- int y_max;
-};
-
-#define BT848_MAX_CLIP_NODE 100
-struct _bktr_clip {
- struct bktr_clip x[BT848_MAX_CLIP_NODE];
-};
-
-/*
- * I'm using METEOR_xxx just because that will be common to other interface
- * and less of a surprise
- */
-#define METEORSACTPIXFMT _IOW('x', 64, int )
-#define METEORGACTPIXFMT _IOR('x', 64, int )
-#define METEORGSUPPIXFMT _IOWR('x', 65, struct meteor_pixfmt)
-
-/* set clip list */
-#define BT848SCLIP _IOW('x', 66, struct _bktr_clip )
-#define BT848GCLIP _IOR('x', 66, struct _bktr_clip )
-
-
-/* set input format */
-#define BT848SFMT _IOW('x', 67, unsigned long )
-#define BT848GFMT _IOR('x', 67, unsigned long )
-
-/* set clear-buffer-on-start */
-#define BT848SCBUF _IOW('x', 68, int)
-#define BT848GCBUF _IOR('x', 68, int)
-
-/* set capture area */
-/* The capture area is the area of the video image which is grabbed */
-/* Usually the capture area is 640x480 (768x576 PAL) pixels */
-/* This area is then scaled to the dimensions the user requires */
-/* using the METEORGEO ioctl */
-/* However, the capture area could be 400x300 pixels from the top right */
-/* corner of the video image */
-struct bktr_capture_area {
- int x_offset;
- int y_offset;
- int x_size;
- int y_size;
-};
-#define BT848_SCAPAREA _IOW('x', 69, struct bktr_capture_area)
-#define BT848_GCAPAREA _IOR('x', 69, struct bktr_capture_area)
-
-
-/* Get channel Set */
-#define BT848_MAX_CHNLSET_NAME_LEN 16
-struct bktr_chnlset {
- short index;
- short max_channel;
- char name[BT848_MAX_CHNLSET_NAME_LEN];
-};
-#define TVTUNER_GETCHNLSET _IOWR('x', 70, struct bktr_chnlset)
-
-
-
-/* Infra Red Remote Control */
-struct bktr_remote {
- unsigned char data[3];
-};
-#define REMOTE_GETKEY _IOR('x', 71, struct bktr_remote)/*read the remote */
- /*control receiver*/
- /*returns raw data*/
-
-
-/*
- * Direct access to GPIO pins. You must add BKTR_GPIO_ACCESS to your kernel
- * configuration file to use these
- */
-#define BT848_GPIO_SET_EN _IOW('x', 72, int) /* set gpio_out_en */
-#define BT848_GPIO_GET_EN _IOR('x', 73, int) /* get gpio_out_en */
-#define BT848_GPIO_SET_DATA _IOW('x', 74, int) /* set gpio_data */
-#define BT848_GPIO_GET_DATA _IOR('x', 75, int) /* get gpio_data */
-
-
-
-/* XXX - Copied from /sys/pci/brktree_reg.h */
-#define BT848_IFORM_FORMAT (0x7<<0)
-# define BT848_IFORM_F_RSVD (0x7)
-# define BT848_IFORM_F_SECAM (0x6)
-# define BT848_IFORM_F_PALN (0x5)
-# define BT848_IFORM_F_PALM (0x4)
-# define BT848_IFORM_F_PALBDGHI (0x3)
-# define BT848_IFORM_F_NTSCJ (0x2)
-# define BT848_IFORM_F_NTSCM (0x1)
-# define BT848_IFORM_F_AUTO (0x0)
-
diff --git a/sys/sys/ioctl_meteor.h b/sys/sys/ioctl_meteor.h
deleted file mode 100644
index f62d392ea0ae..000000000000
--- a/sys/sys/ioctl_meteor.h
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Copyright (c) 1995 Mark Tinguely and Jim Lowe
- * 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 Mark Tinguely and Jim Lowe
- * 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.
- *
- * $FreeBSD$
- */
-/*
- * ioctl constants for Matrox Meteor Capture card.
- */
-
-#ifndef _MACHINE_IOCTL_METEOR_H_
-#define _MACHINE_IOCTL_METEOR_H_
-
-#ifndef _KERNEL
-#include <sys/types.h>
-#endif
-#include <sys/ioccom.h>
-
-struct meteor_capframe {
- short command; /* see below for valid METEORCAPFRM commands */
- short lowat; /* start transfer if < this number */
- short hiwat; /* stop transfer if > this number */
-} ;
-
-/* structure for METEOR[GS]ETGEO - get/set geometry */
-struct meteor_geomet {
- u_short rows;
- u_short columns;
- u_short frames;
- u_long oformat;
-} ;
-
-/* structure for METEORGCOUNT-get count of frames, fifo errors and dma errors */
-struct meteor_counts {
- u_long fifo_errors; /* count of fifo errors since open */
- u_long dma_errors; /* count of dma errors since open */
- u_long frames_captured; /* count of frames captured since open */
- u_long even_fields_captured; /* count of even fields captured */
- u_long odd_fields_captured; /* count of odd fields captured */
-} ;
-
-/* structure for getting and setting direct transfers to vram */
-struct meteor_video {
- u_long addr; /* Address of location to dma to */
- u_long width; /* Width of memory area */
- u_long banksize; /* Size of Vram bank */
- u_long ramsize; /* Size of Vram */
-};
-
-#define METEORCAPTUR _IOW('x', 1, int) /* capture a frame */
-#define METEORCAPFRM _IOW('x', 2, struct meteor_capframe) /* sync capture */
-#define METEORSETGEO _IOW('x', 3, struct meteor_geomet) /* set geometry */
-#define METEORGETGEO _IOR('x', 4, struct meteor_geomet) /* get geometry */
-#define METEORSTATUS _IOR('x', 5, unsigned short) /* get status */
-#define METEORSHUE _IOW('x', 6, signed char) /* set hue */
-#define METEORGHUE _IOR('x', 6, signed char) /* get hue */
-#define METEORSFMT _IOW('x', 7, unsigned long) /* set format */
-#define METEORGFMT _IOR('x', 7, unsigned long) /* get format */
-#define METEORSINPUT _IOW('x', 8, unsigned long) /* set input dev */
-#define METEORGINPUT _IOR('x', 8, unsigned long) /* get input dev */
-#define METEORSCHCV _IOW('x', 9, unsigned char) /* set uv gain */
-#define METEORGCHCV _IOR('x', 9, unsigned char) /* get uv gain */
-#define METEORSCOUNT _IOW('x',10, struct meteor_counts)
-#define METEORGCOUNT _IOR('x',10, struct meteor_counts)
-#define METEORSFPS _IOW('x',11, unsigned short) /* set fps */
-#define METEORGFPS _IOR('x',11, unsigned short) /* get fps */
-#define METEORSSIGNAL _IOW('x', 12, unsigned int) /* set signal */
-#define METEORGSIGNAL _IOR('x', 12, unsigned int) /* get signal */
-#define METEORSVIDEO _IOW('x', 13, struct meteor_video) /* set video */
-#define METEORGVIDEO _IOR('x', 13, struct meteor_video) /* get video */
-#define METEORSBRIG _IOW('x', 14, unsigned char) /* set brightness */
-#define METEORGBRIG _IOR('x', 14, unsigned char) /* get brightness */
-#define METEORSCSAT _IOW('x', 15, unsigned char) /* set chroma sat */
-#define METEORGCSAT _IOR('x', 15, unsigned char) /* get uv saturation */
-#define METEORSCONT _IOW('x', 16, unsigned char) /* set contrast */
-#define METEORGCONT _IOR('x', 16, unsigned char) /* get contrast */
-#define METEORSBT254 _IOW('x', 17, unsigned short) /* set Bt254 reg */
-#define METEORGBT254 _IOR('x', 17, unsigned short) /* get Bt254 reg */
-#define METEORSHWS _IOW('x', 18, unsigned char) /* set hor start reg */
-#define METEORGHWS _IOR('x', 18, unsigned char) /* get hor start reg */
-#define METEORSVWS _IOW('x', 19, unsigned char) /* set vert start reg */
-#define METEORGVWS _IOR('x', 19, unsigned char) /* get vert start reg */
-#define METEORSTS _IOW('x', 20, unsigned char) /* set time stamp */
-#define METEORGTS _IOR('x', 20, unsigned char) /* get time stamp */
-
-#define METEOR_STATUS_ID_MASK 0xf000 /* ID of 7196 */
-#define METEOR_STATUS_DIR 0x0800 /* Direction of Expansion port YUV */
-#define METEOR_STATUS_OEF 0x0200 /* Field detected: Even/Odd */
-#define METEOR_STATUS_SVP 0x0100 /* State of VRAM Port:inactive/active */
-#define METEOR_STATUS_STTC 0x0080 /* Time Constant: TV/VCR */
-#define METEOR_STATUS_HCLK 0x0040 /* Horiz PLL: locked/unlocked */
-#define METEOR_STATUS_FIDT 0x0020 /* Field detect: 50/60hz */
-#define METEOR_STATUS_ALTD 0x0002 /* Line alt: no line alt/line alt */
-#define METEOR_STATUS_CODE 0x0001 /* Colour info: no colour/colour */
-
- /* METEORCAPTUR capture options */
-#define METEOR_CAP_SINGLE 0x0001 /* capture one frame */
-#define METEOR_CAP_CONTINOUS 0x0002 /* continuously capture */
-#define METEOR_CAP_STOP_CONT 0x0004 /* stop the continuous capture */
-
- /* METEORCAPFRM capture commands */
-#define METEOR_CAP_N_FRAMES 0x0001 /* capture N frames */
-#define METEOR_CAP_STOP_FRAMES 0x0002 /* stop capture N frames */
-#define METEOR_HALT_N_FRAMES 0x0003 /* halt of capture N frames */
-#define METEOR_CONT_N_FRAMES 0x0004 /* continue after above halt */
-
- /* valid video input formats: */
-#define METEOR_FMT_NTSC 0x00100 /* NTSC -- initialized default */
-#define METEOR_FMT_PAL 0x00200 /* PAL */
-#define METEOR_FMT_SECAM 0x00400 /* SECAM */
-#define METEOR_FMT_AUTOMODE 0x00800 /* auto-mode */
-#define METEOR_INPUT_DEV0 0x01000 /* camera input 0 -- default */
-#define METEOR_INPUT_DEV_RCA METEOR_INPUT_DEV0
-#define METEOR_INPUT_DEV1 0x02000 /* camera input 1 */
-#define METEOR_INPUT_DEV2 0x04000 /* camera input 2 */
-#define METEOR_INPUT_DEV3 0x08000 /* camera input 3 */
-#define METEOR_INPUT_DEV_RGB 0x0a000 /* for rgb version of meteor */
-#define METEOR_INPUT_DEV_SVIDEO 0x06000 /* S-video input port */
-
- /* valid video output formats: */
-#define METEOR_GEO_RGB16 0x0010000 /* packed -- initialized default */
-#define METEOR_GEO_RGB24 0x0020000 /* RBG 24 bits packed */
- /* internally stored in 32 bits */
-#define METEOR_GEO_YUV_PACKED 0x0040000 /* 4-2-2 YUV 16 bits packed */
-#define METEOR_GEO_YUV_PLANAR 0x0080000 /* 4-2-2 YUV 16 bits planer */
-#define METEOR_GEO_YUV_PLANER METEOR_GEO_YUV_PLANAR
-#define METEOR_GEO_UNSIGNED 0x0400000 /* unsigned uv outputs */
-#define METEOR_GEO_EVEN_ONLY 0x1000000 /* set for even only field capture */
-#define METEOR_GEO_ODD_ONLY 0x2000000 /* set for odd only field capture */
-#define METEOR_GEO_FIELD_MASK 0x3000000
-#define METEOR_GEO_YUV_422 0x4000000 /* 4-2-2 YUV in Y-U-V combined */
-#define METEOR_GEO_OUTPUT_MASK 0x40f0000
-#define METEOR_GEO_YUV_12 0x10000000 /* YUV 12 format */
-#define METEOR_GEO_YUV_9 0x40000000 /* YUV 9 format */
-
-#define METEOR_FIELD_MODE 0x80000000 /* Field cap or Frame cap */
-
-#define METEOR_SIG_MODE_MASK 0xffff0000
-#define METEOR_SIG_FRAME 0x00000000 /* signal every frame */
-#define METEOR_SIG_FIELD 0x00010000 /* signal every field */
-
- /* following structure is used to coordinate the synchronous */
-
-struct meteor_mem {
- /* kernel write only */
- int frame_size; /* row*columns*depth */
- unsigned num_bufs; /* number of frames in buffer (1-32) */
- /* user and kernel change these */
- int lowat; /* kernel starts capture if < this number */
- int hiwat; /* kernel stops capture if > this number.
- hiwat <= numbufs */
- unsigned active; /* bit mask of active frame buffers
- kernel sets, user clears */
- int num_active_bufs; /* count of active frame buffer
- kernel increments, user decrements */
-
- /* reference to mmapped data */
- caddr_t buf; /* The real space (virtual addr) */
-} ;
-
-#endif /* !_MACHINE_IOCTL_METEOR_H_ */
diff --git a/sys/sys/linedisc.h b/sys/sys/linedisc.h
deleted file mode 100644
index 263613c4a23b..000000000000
--- a/sys/sys/linedisc.h
+++ /dev/null
@@ -1,291 +0,0 @@
-/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.h 8.5 (Berkeley) 1/9/95
- * $FreeBSD$
- */
-
-#ifndef _SYS_CONF_H_
-#define _SYS_CONF_H_
-
-#include <sys/queue.h>
-
-#define SPECNAMELEN 15
-
-struct tty;
-struct disk;
-struct vnode;
-
-struct specinfo {
- u_int si_flags;
-#define SI_STASHED 0x0001 /* created in stashed storage */
- udev_t si_udev;
- LIST_ENTRY(specinfo) si_hash;
- SLIST_HEAD(, vnode) si_hlist;
- char si_name[SPECNAMELEN + 1];
- void *si_drv1, *si_drv2;
- struct cdevsw *si_devsw;
- void *si_devfs; /* save cookie for devfs operations */
- void *si_bdevfs; /* XXX block device (should go away) */
- int si_iosize_max; /* maximum I/O size (for physio &al) */
- union {
- struct {
- struct tty *__sit_tty;
- } __si_tty;
- struct {
- struct disk *__sid_disk;
- struct mount *__sid_mountpoint;
- int __sid_bsize_phys; /* min physical block size */
- int __sid_bsize_best; /* optimal block size */
- } __si_disk;
- } __si_u;
-};
-
-#define si_tty __si_u.__si_tty.__sit_tty
-#define si_disk __si_u.__si_disk.__sid_disk
-#define si_mountpoint __si_u.__si_disk.__sid_mountpoint
-#define si_bsize_phys __si_u.__si_disk.__sid_bsize_phys
-#define si_bsize_best __si_u.__si_disk.__sid_bsize_best
-
-/*
- * Exported shorthand
- */
-#define v_hashchain v_rdev->si_hlist
-#define v_specmountpoint v_rdev->si_mountpoint
-
-/*
- * Special device management
- */
-#define SPECHSZ 64
-#define SPECHASH(rdev) (((unsigned)(minor(rdev)))%SPECHSZ)
-
-/*
- * Definitions of device driver entry switches
- */
-
-struct buf;
-struct proc;
-struct uio;
-
-typedef int d_open_t __P((dev_t dev, int oflags, int devtype, struct proc *p));
-typedef int d_close_t __P((dev_t dev, int fflag, int devtype, struct proc *p));
-typedef void d_strategy_t __P((struct buf *bp));
-typedef int d_parms_t __P((dev_t dev, struct specinfo *sinfo, int ctl));
-typedef int d_ioctl_t __P((dev_t dev, u_long cmd, caddr_t data,
- int fflag, struct proc *p));
-typedef int d_dump_t __P((dev_t dev));
-typedef int d_psize_t __P((dev_t dev));
-
-typedef int d_read_t __P((dev_t dev, struct uio *uio, int ioflag));
-typedef int d_write_t __P((dev_t dev, struct uio *uio, int ioflag));
-typedef int d_poll_t __P((dev_t dev, int events, struct proc *p));
-typedef int d_mmap_t __P((dev_t dev, vm_offset_t offset, int nprot));
-
-typedef int l_open_t __P((dev_t dev, struct tty *tp));
-typedef int l_close_t __P((struct tty *tp, int flag));
-typedef int l_read_t __P((struct tty *tp, struct uio *uio, int flag));
-typedef int l_write_t __P((struct tty *tp, struct uio *uio, int flag));
-typedef int l_ioctl_t __P((struct tty *tp, u_long cmd, caddr_t data,
- int flag, struct proc *p));
-typedef int l_rint_t __P((int c, struct tty *tp));
-typedef int l_start_t __P((struct tty *tp));
-typedef int l_modem_t __P((struct tty *tp, int flag));
-
-/* This is type of the function DEVFS uses to hook into the kernel with */
-typedef void devfs_create_t __P((dev_t dev, uid_t uid, gid_t gid, int perms));
-typedef void devfs_remove_t __P((dev_t dev));
-
-/*
- * XXX: The dummy argument can be used to do what strategy1() never
- * did anywhere: Create a per device flag to lock the device during
- * label/slice surgery, all calls with a dummy == 0 gets stalled on
- * a queue somewhere, whereas dummy == 1 are let through. Once out
- * of surgery, reset the flag and restart all the stuff on the stall
- * queue.
- */
-#define BUF_STRATEGY(bp, dummy) (*devsw((bp)->b_dev)->d_strategy)(bp)
-/*
- * Types for d_flags.
- */
-#define D_TAPE 0x0001
-#define D_DISK 0x0002
-#define D_TTY 0x0004
-#define D_MEM 0x0008
-
-#define D_TYPEMASK 0xffff
-
-/*
- * Flags for d_flags.
- */
-#define D_MEMDISK 0x10000 /* memory type disk */
-#define D_NAGGED 0x20000 /* nagged about missing make_dev() */
-#define D_CANFREE 0x40000 /* can free blocks */
-#define D_TRACKCLOSE 0x80000 /* track all closes */
-
-/*
- * Character device switch table
- */
-struct cdevsw {
- d_open_t *d_open;
- d_close_t *d_close;
- d_read_t *d_read;
- d_write_t *d_write;
- d_ioctl_t *d_ioctl;
- d_poll_t *d_poll;
- d_mmap_t *d_mmap;
- d_strategy_t *d_strategy;
- const char *d_name; /* base device name, e.g. 'vn' */
- int d_maj;
- d_dump_t *d_dump;
- d_psize_t *d_psize;
- u_int d_flags;
- int d_bmaj;
-};
-
-/*
- * Line discipline switch table
- */
-struct linesw {
- l_open_t *l_open;
- l_close_t *l_close;
- l_read_t *l_read;
- l_write_t *l_write;
- l_ioctl_t *l_ioctl;
- l_rint_t *l_rint;
- l_start_t *l_start;
- l_modem_t *l_modem;
- u_char l_hotchar;
-};
-
-#ifdef _KERNEL
-extern struct linesw linesw[];
-extern int nlinesw;
-
-int ldisc_register __P((int , struct linesw *));
-void ldisc_deregister __P((int));
-#define LDISC_LOAD -1 /* Loadable line discipline */
-#endif
-
-/*
- * Swap device table
- */
-struct swdevt {
- udev_t sw_dev; /* For quasibogus swapdev reporting */
- int sw_flags;
- int sw_nblks;
- struct vnode *sw_vp;
- dev_t sw_device;
-};
-#define SW_FREED 0x01
-#define SW_SEQUENTIAL 0x02
-#define sw_freed sw_flags /* XXX compat */
-
-#ifdef _KERNEL
-d_open_t noopen;
-d_close_t noclose;
-d_read_t noread;
-d_write_t nowrite;
-d_ioctl_t noioctl;
-d_mmap_t nommap;
-#define nostrategy ((d_strategy_t *)NULL)
-#define nopoll seltrue
-
-d_dump_t nodump;
-
-#define NUMCDEVSW 256
-
-/*
- * nopsize is little used, so not worth having dummy functions for.
- */
-#define nopsize ((d_psize_t *)NULL)
-
-d_open_t nullopen;
-d_close_t nullclose;
-
-l_read_t l_noread;
-l_write_t l_nowrite;
-
-struct module;
-
-struct devsw_module_data {
- int (*chainevh)(struct module *, int, void *); /* next handler */
- void *chainarg; /* arg for next event handler */
- /* Do not initialize fields hereafter */
-};
-
-#define DEV_MODULE(name, evh, arg) \
-static moduledata_t name##_mod = { \
- #name, \
- evh, \
- arg \
-}; \
-DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE)
-
-
-int cdevsw_add __P((struct cdevsw *new));
-int cdevsw_remove __P((struct cdevsw *old));
-int count_dev __P((dev_t dev));
-void destroy_dev __P((dev_t dev));
-struct cdevsw *devsw __P((dev_t dev));
-const char *devtoname __P((dev_t dev));
-void freedev __P((dev_t dev));
-int iszerodev __P((dev_t dev));
-dev_t makebdev __P((int maj, int min));
-dev_t make_dev __P((struct cdevsw *devsw, int minor, uid_t uid, gid_t gid, int perms, char *fmt, ...)) __printflike(6, 7);
-int lminor __P((dev_t dev));
-void setconf __P((void));
-
-extern devfs_create_t *devfs_create_hook;
-
-/*
- * XXX: This included for when DEVFS resurfaces
- */
-
-#define UID_ROOT 0
-#define UID_BIN 3
-#define UID_UUCP 66
-
-#define GID_WHEEL 0
-#define GID_KMEM 2
-#define GID_OPERATOR 5
-#define GID_BIN 7
-#define GID_GAMES 13
-#define GID_DIALER 68
-
-#endif /* _KERNEL */
-
-#endif /* !_SYS_CONF_H_ */
diff --git a/sys/sys/lockmgr.h b/sys/sys/lockmgr.h
deleted file mode 100644
index 57b8b05aae77..000000000000
--- a/sys/sys/lockmgr.h
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Copyright (c) 1995
- * The Regents of the University of California. All rights reserved.
- *
- * This code contains ideas from software contributed to Berkeley by
- * Avadis Tevanian, Jr., Michael Wayne Young, and the Mach Operating
- * System project at Carnegie-Mellon University.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)lock.h 8.12 (Berkeley) 5/19/95
- * $FreeBSD$
- */
-
-#ifndef _LOCK_H_
-#define _LOCK_H_
-
-
-#include <machine/lock.h>
-
-/*
- * The general lock structure. Provides for multiple shared locks,
- * upgrading from shared to exclusive, and sleeping until the lock
- * can be gained. The simple locks are defined in <machine/param.h>.
- */
-struct lock {
- struct simplelock lk_interlock; /* lock on remaining fields */
- u_int lk_flags; /* see below */
- int lk_sharecount; /* # of accepted shared locks */
- int lk_waitcount; /* # of processes sleeping for lock */
- short lk_exclusivecount; /* # of recursive exclusive locks */
- short lk_prio; /* priority at which to sleep */
- char *lk_wmesg; /* resource sleeping (for tsleep) */
- int lk_timo; /* maximum sleep time (for tsleep) */
- pid_t lk_lockholder; /* pid of exclusive lock holder */
-#ifdef DEBUG_LOCKS
- const char *lk_filename;
- const char *lk_lockername;
- int lk_lineno;
-#endif
-};
-/*
- * Lock request types:
- * LK_SHARED - get one of many possible shared locks. If a process
- * holding an exclusive lock requests a shared lock, the exclusive
- * lock(s) will be downgraded to shared locks.
- * LK_EXCLUSIVE - stop further shared locks, when they are cleared,
- * grant a pending upgrade if it exists, then grant an exclusive
- * lock. Only one exclusive lock may exist at a time, except that
- * a process holding an exclusive lock may get additional exclusive
- * locks if it explicitly sets the LK_CANRECURSE flag in the lock
- * request, or if the LK_CANRECUSE flag was set when the lock was
- * initialized.
- * LK_UPGRADE - the process must hold a shared lock that it wants to
- * have upgraded to an exclusive lock. Other processes may get
- * exclusive access to the resource between the time that the upgrade
- * is requested and the time that it is granted.
- * LK_EXCLUPGRADE - the process must hold a shared lock that it wants to
- * have upgraded to an exclusive lock. If the request succeeds, no
- * other processes will have gotten exclusive access to the resource
- * between the time that the upgrade is requested and the time that
- * it is granted. However, if another process has already requested
- * an upgrade, the request will fail (see error returns below).
- * LK_DOWNGRADE - the process must hold an exclusive lock that it wants
- * to have downgraded to a shared lock. If the process holds multiple
- * (recursive) exclusive locks, they will all be downgraded to shared
- * locks.
- * LK_RELEASE - release one instance of a lock.
- * LK_DRAIN - wait for all activity on the lock to end, then mark it
- * decommissioned. This feature is used before freeing a lock that
- * is part of a piece of memory that is about to be freed.
- * LK_EXCLOTHER - return for lockstatus(). Used when another process
- * holds the lock exclusively.
- *
- * These are flags that are passed to the lockmgr routine.
- */
-#define LK_TYPE_MASK 0x0000000f /* type of lock sought */
-#define LK_SHARED 0x00000001 /* shared lock */
-#define LK_EXCLUSIVE 0x00000002 /* exclusive lock */
-#define LK_UPGRADE 0x00000003 /* shared-to-exclusive upgrade */
-#define LK_EXCLUPGRADE 0x00000004 /* first shared-to-exclusive upgrade */
-#define LK_DOWNGRADE 0x00000005 /* exclusive-to-shared downgrade */
-#define LK_RELEASE 0x00000006 /* release any type of lock */
-#define LK_DRAIN 0x00000007 /* wait for all lock activity to end */
-#define LK_EXCLOTHER 0x00000008 /* other process holds lock */
-/*
- * External lock flags.
- *
- * The first three flags may be set in lock_init to set their mode permanently,
- * or passed in as arguments to the lock manager. The LK_REENABLE flag may be
- * set only at the release of a lock obtained by drain.
- */
-#define LK_EXTFLG_MASK 0x01000070 /* mask of external flags */
-#define LK_NOWAIT 0x00000010 /* do not sleep to await lock */
-#define LK_SLEEPFAIL 0x00000020 /* sleep, then return failure */
-#define LK_CANRECURSE 0x00000040 /* allow recursive exclusive lock */
-#define LK_REENABLE 0x00000080 /* lock is be reenabled after drain */
-#define LK_NOPAUSE 0x01000000 /* no spinloop */
-/*
- * Internal lock flags.
- *
- * These flags are used internally to the lock manager.
- */
-#define LK_WANT_UPGRADE 0x00000100 /* waiting for share-to-excl upgrade */
-#define LK_WANT_EXCL 0x00000200 /* exclusive lock sought */
-#define LK_HAVE_EXCL 0x00000400 /* exclusive lock obtained */
-#define LK_WAITDRAIN 0x00000800 /* process waiting for lock to drain */
-#define LK_DRAINING 0x00004000 /* lock is being drained */
-/*
- * Control flags
- *
- * Non-persistent external flags.
- */
-#define LK_INTERLOCK 0x00010000 /* unlock passed simple lock after
- getting lk_interlock */
-#define LK_RETRY 0x00020000 /* vn_lock: retry until locked */
-#define LK_NOOBJ 0x00040000 /* vget: don't create object */
-
-/*
- * Internal state flags corresponding to lk_sharecount, and lk_waitcount
- */
-#define LK_SHARE_NONZERO 0x00100000
-#define LK_WAIT_NONZERO 0x00200000
-
-/*
- * Lock return status.
- *
- * Successfully obtained locks return 0. Locks will always succeed
- * unless one of the following is true:
- * LK_FORCEUPGRADE is requested and some other process has already
- * requested a lock upgrade (returns EBUSY).
- * LK_WAIT is set and a sleep would be required (returns EBUSY).
- * LK_SLEEPFAIL is set and a sleep was done (returns ENOLCK).
- * PCATCH is set in lock priority and a signal arrives (returns
- * either EINTR or ERESTART if system calls is to be restarted).
- * Non-null lock timeout and timeout expires (returns EWOULDBLOCK).
- * A failed lock attempt always returns a non-zero error value. No lock
- * is held after an error return (in particular, a failed LK_UPGRADE
- * or LK_FORCEUPGRADE will have released its shared access lock).
- */
-
-/*
- * Indicator that no process holds exclusive lock
- */
-#define LK_KERNPROC ((pid_t) -2)
-#define LK_NOPROC ((pid_t) -1)
-
-void dumplockinfo(struct lock *lkp);
-struct proc;
-
-void lockinit __P((struct lock *, int prio, char *wmesg, int timo,
- int flags));
-#ifdef DEBUG_LOCKS
-int debuglockmgr __P((struct lock *, u_int flags,
- struct simplelock *, struct proc *p,
- const char *,
- const char *,
- int));
-#define lockmgr(lockp, flags, slockp, proc) \
- debuglockmgr((lockp), (flags), (slockp), (proc), \
- "lockmgr", __FILE__, __LINE__)
-#else
-int lockmgr __P((struct lock *, u_int flags,
- struct simplelock *, struct proc *p));
-#endif
-void lockmgr_printinfo __P((struct lock *));
-int lockstatus __P((struct lock *, struct proc *));
-int lockcount __P((struct lock *));
-
-#ifdef SIMPLELOCK_DEBUG
-void _simple_unlock __P((struct simplelock *alp, const char *, int));
-#define simple_unlock(alp) _simple_unlock(alp, __FILE__, __LINE__)
-int _simple_lock_try __P((struct simplelock *alp, const char *, int));
-#define simple_lock_try(alp) _simple_lock_try(alp, __FILE__, __LINE__)
-void _simple_lock __P((struct simplelock *alp, const char *, int));
-#define simple_lock(alp) _simple_lock(alp, __FILE__, __LINE__)
-void simple_lock_init __P((struct simplelock *alp));
-#else /* !SIMPLELOCK_DEBUG */
-#if NCPUS == 1 /* no multiprocessor locking is necessary */
-#define NULL_SIMPLELOCKS
-#define simple_lock_init(alp)
-#define simple_lock(alp)
-#define simple_lock_try(alp) (1) /* always succeeds */
-#define simple_unlock(alp)
-#endif /* NCPUS == 1 */
-#endif /* !SIMPLELOCK_DEBUG */
-
-#endif /* !_LOCK_H_ */
diff --git a/sys/sys/mdioctl.h b/sys/sys/mdioctl.h
deleted file mode 100644
index b28374182821..000000000000
--- a/sys/sys/mdioctl.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * 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. 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, Berkeley and its contributors.
- * 4. 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: fdioctl.h 1.1 90/07/09$
- *
- * @(#)vnioctl.h 8.1 (Berkeley) 6/10/93
- *
- * $FreeBSD$
- */
-
-#ifndef _SYS_VNIOCTL_H_
-#define _SYS_VNIOCTL_H_
-
-/*
- * Ioctl definitions for file (vnode) disk pseudo-device.
- */
-
-#define _PATH_VNTAB "/etc/vntab" /* default config file */
-
-struct vn_ioctl {
- char *vn_file; /* pathname of file to mount */
- int vn_size; /* (returned) size of disk */
-};
-
-/*
- * Before you can use a unit, it must be configured with VNIOCSET.
- * The configuration persists across opens and closes of the device;
- * an VNIOCCLR must be used to reset a configuration. An attempt to
- * VNIOCSET an already active unit will return EBUSY.
- */
-#define VNIOCATTACH _IOWR('F', 0, struct vn_ioctl) /* attach file */
-#define VNIOCDETACH _IOWR('F', 1, struct vn_ioctl) /* detach disk */
-#define VNIOCGSET _IOWR('F', 2, u_long ) /* set global option */
-#define VNIOCGCLEAR _IOWR('F', 3, u_long ) /* reset --//-- */
-#define VNIOCUSET _IOWR('F', 4, u_long ) /* set unit option */
-#define VNIOCUCLEAR _IOWR('F', 5, u_long ) /* reset --//-- */
-
-#define VN_LABELS 0x1 /* Use disk(/slice) labels */
-#define VN_FOLLOW 0x2 /* Debug flow in vn driver */
-#define VN_DEBUG 0x4 /* Debug data in vn driver */
-#define VN_IO 0x8 /* Debug I/O in vn driver */
-#define VN_DONTCLUSTER 0x10 /* Don't cluster */
-#define VN_RESERVE 0x20 /* Pre-reserve swap */
-
-#endif /* _SYS_VNIOCTL_H_*/
diff --git a/sys/sys/mouse.h b/sys/sys/mouse.h
deleted file mode 100644
index 12d49a2a5d75..000000000000
--- a/sys/sys/mouse.h
+++ /dev/null
@@ -1,295 +0,0 @@
-/*-
- * Copyright (c) 1992, 1993 Erik Forsberg.
- * Copyright (c) 1996, 1997 Kazutaka YOKOTA
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY ``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 I 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.
- *
- * $FreeBSD$
- */
-
-#ifndef _MACHINE_MOUSE_H_
-#define _MACHINE_MOUSE_H_
-
-#include <sys/types.h>
-#include <sys/ioccom.h>
-
-/* ioctls */
-#define MOUSE_GETSTATUS _IOR('M', 0, mousestatus_t)
-#define MOUSE_GETHWINFO _IOR('M', 1, mousehw_t)
-#define MOUSE_GETMODE _IOR('M', 2, mousemode_t)
-#define MOUSE_SETMODE _IOW('M', 3, mousemode_t)
-#define MOUSE_GETLEVEL _IOR('M', 4, int)
-#define MOUSE_SETLEVEL _IOW('M', 5, int)
-#define MOUSE_GETVARS _IOR('M', 6, mousevar_t)
-#define MOUSE_SETVARS _IOW('M', 7, mousevar_t)
-#define MOUSE_READSTATE _IOWR('M', 8, mousedata_t)
-#define MOUSE_READDATA _IOWR('M', 9, mousedata_t)
-
-#if notyet
-#define MOUSE_SETRESOLUTION _IOW('M', 10, int)
-#define MOUSE_SETSCALING _IOW('M', 11, int)
-#define MOUSE_SETRATE _IOW('M', 12, int)
-#define MOUSE_GETHWID _IOR('M', 13, int)
-#endif
-
-/* mouse status block */
-typedef struct mousestatus {
- int flags; /* state change flags */
- int button; /* button status */
- int obutton; /* previous button status */
- int dx; /* x movement */
- int dy; /* y movement */
- int dz; /* z movement */
-} mousestatus_t;
-
-/* button */
-#define MOUSE_BUTTON1DOWN 0x0001 /* left */
-#define MOUSE_BUTTON2DOWN 0x0002 /* middle */
-#define MOUSE_BUTTON3DOWN 0x0004 /* right */
-#define MOUSE_BUTTON4DOWN 0x0008
-#define MOUSE_BUTTON5DOWN 0x0010
-#define MOUSE_BUTTON6DOWN 0x0020
-#define MOUSE_BUTTON7DOWN 0x0040
-#define MOUSE_BUTTON8DOWN 0x0080
-#define MOUSE_MAXBUTTON 31
-#define MOUSE_STDBUTTONS 0x0007 /* buttons 1-3 */
-#define MOUSE_EXTBUTTONS 0x7ffffff8 /* the others (28 of them!) */
-#define MOUSE_BUTTONS (MOUSE_STDBUTTONS | MOUSE_EXTBUTTONS)
-
-/* flags */
-#define MOUSE_STDBUTTONSCHANGED MOUSE_STDBUTTONS
-#define MOUSE_EXTBUTTONSCHANGED MOUSE_EXTBUTTONS
-#define MOUSE_BUTTONSCHANGED MOUSE_BUTTONS
-#define MOUSE_POSCHANGED 0x80000000
-
-typedef struct mousehw {
- int buttons; /* -1 if unknown */
- int iftype; /* MOUSE_IF_XXX */
- int type; /* mouse/track ball/pad... */
- int model; /* I/F dependent model ID: MOUSE_MODEL_XXX */
- int hwid; /* I/F dependent hardware ID
- * for the PS/2 mouse, it will be PSM_XXX_ID
- */
-} mousehw_t;
-
-/* iftype */
-#define MOUSE_IF_UNKNOWN (-1)
-#define MOUSE_IF_SERIAL 0
-#define MOUSE_IF_BUS 1
-#define MOUSE_IF_INPORT 2
-#define MOUSE_IF_PS2 3
-#define MOUSE_IF_SYSMOUSE 4
-#define MOUSE_IF_USB 5
-
-/* type */
-#define MOUSE_UNKNOWN (-1) /* should be treated as a mouse */
-#define MOUSE_MOUSE 0
-#define MOUSE_TRACKBALL 1
-#define MOUSE_STICK 2
-#define MOUSE_PAD 3
-
-/* model */
-#define MOUSE_MODEL_UNKNOWN (-1)
-#define MOUSE_MODEL_GENERIC 0
-#define MOUSE_MODEL_GLIDEPOINT 1
-#define MOUSE_MODEL_NETSCROLL 2
-#define MOUSE_MODEL_NET 3
-#define MOUSE_MODEL_INTELLI 4
-#define MOUSE_MODEL_THINK 5
-#define MOUSE_MODEL_EASYSCROLL 6
-#define MOUSE_MODEL_MOUSEMANPLUS 7
-#define MOUSE_MODEL_KIDSPAD 8
-#define MOUSE_MODEL_VERSAPAD 9
-
-typedef struct mousemode {
- int protocol; /* MOUSE_PROTO_XXX */
- int rate; /* report rate (per sec), -1 if unknown */
- int resolution; /* MOUSE_RES_XXX, -1 if unknown */
- int accelfactor; /* accelation factor (must be 1 or greater) */
- int level; /* driver operation level */
- int packetsize; /* the length of the data packet */
- unsigned char syncmask[2]; /* sync. data bits in the header byte */
-} mousemode_t;
-
-/* protocol */
-#define MOUSE_PROTO_UNKNOWN (-1)
-#define MOUSE_PROTO_MS 0 /* Microsoft Serial, 3 bytes */
-#define MOUSE_PROTO_MSC 1 /* Mouse Systems, 5 bytes */
-#define MOUSE_PROTO_LOGI 2 /* Logitech, 3 bytes */
-#define MOUSE_PROTO_MM 3 /* MM series, 3 bytes */
-#define MOUSE_PROTO_LOGIMOUSEMAN 4 /* Logitech MouseMan 3/4 bytes */
-#define MOUSE_PROTO_BUS 5 /* MS/Logitech bus mouse */
-#define MOUSE_PROTO_INPORT 6 /* MS/ATI InPort mouse */
-#define MOUSE_PROTO_PS2 7 /* PS/2 mouse, 3 bytes */
-#define MOUSE_PROTO_HITTAB 8 /* Hitachi Tablet 3 bytes */
-#define MOUSE_PROTO_GLIDEPOINT 9 /* ALPS GlidePoint, 3/4 bytes */
-#define MOUSE_PROTO_INTELLI 10 /* MS IntelliMouse, 4 bytes */
-#define MOUSE_PROTO_THINK 11 /* Kensignton Thinking Mouse, 3/4 bytes */
-#define MOUSE_PROTO_SYSMOUSE 12 /* /dev/sysmouse */
-#define MOUSE_PROTO_X10MOUSEREM 13 /* X10 MouseRemote, 3 bytes */
-#define MOUSE_PROTO_KIDSPAD 14 /* Genius Kidspad */
-#define MOUSE_PROTO_VERSAPAD 15 /* Interlink VersaPad, 6 bytes */
-
-#define MOUSE_RES_UNKNOWN (-1)
-#define MOUSE_RES_DEFAULT 0
-#define MOUSE_RES_LOW (-2)
-#define MOUSE_RES_MEDIUMLOW (-3)
-#define MOUSE_RES_MEDIUMHIGH (-4)
-#define MOUSE_RES_HIGH (-5)
-
-typedef struct mousedata {
- int len; /* # of data in the buffer */
- int buf[16]; /* data buffer */
-} mousedata_t;
-
-#if (defined(MOUSE_GETVARS))
-
-typedef struct mousevar {
- int var[16];
-} mousevar_t;
-
-/* magic numbers in var[0] */
-#define MOUSE_VARS_PS2_SIG 0x00325350 /* 'PS2' */
-#define MOUSE_VARS_BUS_SIG 0x00535542 /* 'BUS' */
-#define MOUSE_VARS_INPORT_SIG 0x00504e49 /* 'INP' */
-
-#endif /* MOUSE_GETVARS */
-
-/* Microsoft Serial mouse data packet */
-#define MOUSE_MSS_PACKETSIZE 3
-#define MOUSE_MSS_SYNCMASK 0x40
-#define MOUSE_MSS_SYNC 0x40
-#define MOUSE_MSS_BUTTONS 0x30
-#define MOUSE_MSS_BUTTON1DOWN 0x20 /* left */
-#define MOUSE_MSS_BUTTON2DOWN 0x00 /* no middle button */
-#define MOUSE_MSS_BUTTON3DOWN 0x10 /* right */
-
-/* Logitech MouseMan data packet (M+ protocol) */
-#define MOUSE_LMAN_BUTTON2DOWN 0x20 /* middle button, the 4th byte */
-
-/* ALPS GlidePoint extention (variant of M+ protocol) */
-#define MOUSE_ALPS_BUTTON2DOWN 0x20 /* middle button, the 4th byte */
-#define MOUSE_ALPS_TAP 0x10 /* `tapping' action, the 4th byte */
-
-/* Kinsington Thinking Mouse extention (variant of M+ protocol) */
-#define MOUSE_THINK_BUTTON2DOWN 0x20 /* lower-left button, the 4th byte */
-#define MOUSE_THINK_BUTTON4DOWN 0x10 /* lower-right button, the 4th byte */
-
-/* MS IntelliMouse (variant of MS Serial) */
-#define MOUSE_INTELLI_PACKETSIZE 4
-#define MOUSE_INTELLI_BUTTON2DOWN 0x10 /* middle button the 4th byte */
-
-/* Mouse Systems Corp. mouse data packet */
-#define MOUSE_MSC_PACKETSIZE 5
-#define MOUSE_MSC_SYNCMASK 0xf8
-#define MOUSE_MSC_SYNC 0x80
-#define MOUSE_MSC_BUTTONS 0x07
-#define MOUSE_MSC_BUTTON1UP 0x04 /* left */
-#define MOUSE_MSC_BUTTON2UP 0x02 /* middle */
-#define MOUSE_MSC_BUTTON3UP 0x01 /* right */
-#define MOUSE_MSC_MAXBUTTON 3
-
-/* MM series mouse data packet */
-#define MOUSE_MM_PACKETSIZE 3
-#define MOUSE_MM_SYNCMASK 0xe0
-#define MOUSE_MM_SYNC 0x80
-#define MOUSE_MM_BUTTONS 0x07
-#define MOUSE_MM_BUTTON1DOWN 0x04 /* left */
-#define MOUSE_MM_BUTTON2DOWN 0x02 /* middle */
-#define MOUSE_MM_BUTTON3DOWN 0x01 /* right */
-#define MOUSE_MM_XPOSITIVE 0x10
-#define MOUSE_MM_YPOSITIVE 0x08
-
-/* PS/2 mouse data packet */
-#define MOUSE_PS2_PACKETSIZE 3
-#define MOUSE_PS2_SYNCMASK 0xc8
-#define MOUSE_PS2_SYNC 0x08
-#define MOUSE_PS2_BUTTONS 0x07 /* 0x03 for 2 button mouse */
-#define MOUSE_PS2_BUTTON1DOWN 0x01 /* left */
-#define MOUSE_PS2_BUTTON2DOWN 0x04 /* middle */
-#define MOUSE_PS2_BUTTON3DOWN 0x02 /* right */
-#define MOUSE_PS2_TAP MOUSE_PS2_SYNC /* GlidePoint (PS/2) `tapping'
- * Yes! this is the same bit
- * as SYNC!
- */
-#define MOUSE_PS2PLUS_BUTTON4DOWN 0x10 /* 4th button on MouseMan+ */
-#define MOUSE_PS2PLUS_BUTTON5DOWN 0x20
-
-#define MOUSE_PS2_XNEG 0x10
-#define MOUSE_PS2_YNEG 0x20
-#define MOUSE_PS2_XOVERFLOW 0x40
-#define MOUSE_PS2_YOVERFLOW 0x80
-#define MOUSE_PS2PLUS_ZNEG 0x08 /* MouseMan+ negative wheel movement */
-#define MOUSE_PS2PLUS_SYNCMASK 0x48
-#define MOUSE_PS2PLUS_SYNC 0x48
-
-/* Interlink VersaPad (serial I/F) data packet */
-#define MOUSE_VERSA_PACKETSIZE 6
-#define MOUSE_VERSA_IN_USE 0x04
-#define MOUSE_VERSA_SYNCMASK 0xc3
-#define MOUSE_VERSA_SYNC 0xc0
-#define MOUSE_VERSA_BUTTONS 0x30
-#define MOUSE_VERSA_BUTTON1DOWN 0x20 /* left */
-#define MOUSE_VERSA_BUTTON2DOWN 0x00 /* middle */
-#define MOUSE_VERSA_BUTTON3DOWN 0x10 /* right */
-#define MOUSE_VERSA_TAP 0x08
-
-/* Interlink VersaPad (PS/2 I/F) data packet */
-#define MOUSE_PS2VERSA_PACKETSIZE 6
-#define MOUSE_PS2VERSA_IN_USE 0x10
-#define MOUSE_PS2VERSA_SYNCMASK 0xe8
-#define MOUSE_PS2VERSA_SYNC 0xc8
-#define MOUSE_PS2VERSA_BUTTONS 0x05
-#define MOUSE_PS2VERSA_BUTTON1DOWN 0x04 /* left */
-#define MOUSE_PS2VERSA_BUTTON2DOWN 0x00 /* middle */
-#define MOUSE_PS2VERSA_BUTTON3DOWN 0x01 /* right */
-#define MOUSE_PS2VERSA_TAP 0x02
-
-/* sysmouse extended data packet */
-/*
- * /dev/sysmouse sends data in two formats, depending on the protocol
- * level. At the level 0, format is exactly the same as MousSystems'
- * five byte packet. At the level 1, the first five bytes are the same
- * as at the level 0. There are additional three bytes which shows
- * `dz' and the states of additional buttons. `dz' is expressed as the
- * sum of the byte 5 and 6 which contain signed seven bit values.
- * The states of the button 4 though 10 are in the bit 0 though 6 in
- * the byte 7 respectively: 1 indicates the button is up.
- */
-#define MOUSE_SYS_PACKETSIZE 8
-#define MOUSE_SYS_SYNCMASK 0xf8
-#define MOUSE_SYS_SYNC 0x80
-#define MOUSE_SYS_BUTTON1UP 0x04 /* left, 1st byte */
-#define MOUSE_SYS_BUTTON2UP 0x02 /* middle, 1st byte */
-#define MOUSE_SYS_BUTTON3UP 0x01 /* right, 1st byte */
-#define MOUSE_SYS_BUTTON4UP 0x0001 /* 7th byte */
-#define MOUSE_SYS_BUTTON5UP 0x0002
-#define MOUSE_SYS_BUTTON6UP 0x0004
-#define MOUSE_SYS_BUTTON7UP 0x0008
-#define MOUSE_SYS_BUTTON8UP 0x0010
-#define MOUSE_SYS_BUTTON9UP 0x0020
-#define MOUSE_SYS_BUTTON10UP 0x0040
-#define MOUSE_SYS_MAXBUTTON 10
-#define MOUSE_SYS_STDBUTTONS 0x07
-#define MOUSE_SYS_EXTBUTTONS 0x7f /* the others */
-
-/* Mouse remote socket */
-#define _PATH_MOUSEREMOTE "/var/run/MouseRemote"
-
-#endif /* _MACHINE_MOUSE_H_ */
diff --git a/sys/sys/posix4.h b/sys/sys/posix4.h
deleted file mode 100644
index 232435a4922a..000000000000
--- a/sys/sys/posix4.h
+++ /dev/null
@@ -1,116 +0,0 @@
-#ifndef _P1003_1B_P1003_1B_H_
-#define _P1003_1B_P1003_1B_H_
-/*-
- * Copyright (c) 1996, 1997, 1998
- * HD Associates, Inc. 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 HD Associates, Inc
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES 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 HD ASSOCIATES 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.
- *
- * $FreeBSD$
- */
-
-#include "opt_posix.h"
-
-#include <sys/param.h>
-#include <sys/ioccom.h>
-#include <sys/malloc.h>
-#include <posix4/sched.h>
-
-/* Generate syscall stubs for when something is optionally
- * loadable as a module. References "syscall_not_present".
- * XXX Good candidate for sys/syscall.h
- */
-struct proc;
-struct nosys_args;
-extern int syscall_not_present(struct proc *, const char *, struct nosys_args *);
-
-#define SYSCALL_NOT_PRESENT_GEN(SC) \
-int SC (struct proc *p, struct SC##_args *uap) \
-{ \
- return syscall_not_present(p, #SC , (struct nosys_args *)uap); \
-}
-
-
-MALLOC_DECLARE(M_P31B);
-
-#define p31b_malloc(SIZE) malloc((SIZE), M_P31B, M_WAITOK)
-#define p31b_free(P) free((P), M_P31B)
-
-int p31b_proc __P((struct proc *, pid_t, struct proc **));
-
-void p31b_setcfg __P((int, int));
-
-#ifdef _KPOSIX_PRIORITY_SCHEDULING
-
-/*
- * KSCHED_OP_RW is a vector of read/write flags for each entry indexed
- * by the enum ksched_op.
- *
- * 1 means you need write access, 0 means read is sufficient.
- */
-
-enum ksched_op {
-
-#define KSCHED_OP_RW { 1, 0, 1, 0, 0, 0, 0, 0 }
-
- SCHED_SETPARAM,
- SCHED_GETPARAM,
- SCHED_SETSCHEDULER,
- SCHED_GETSCHEDULER,
- SCHED_YIELD,
- SCHED_GET_PRIORITY_MAX,
- SCHED_GET_PRIORITY_MIN,
- SCHED_RR_GET_INTERVAL,
- SCHED_OP_MAX
-};
-
-struct ksched;
-
-int ksched_attach(struct ksched **);
-int ksched_detach(struct ksched *);
-
-int ksched_setparam(register_t *, struct ksched *,
- struct proc *, const struct sched_param *);
-int ksched_getparam(register_t *, struct ksched *,
- struct proc *, struct sched_param *);
-
-int ksched_setscheduler(register_t *, struct ksched *,
- struct proc *, int, const struct sched_param *);
-int ksched_getscheduler(register_t *, struct ksched *, struct proc *);
-
-int ksched_yield(register_t *, struct ksched *);
-
-int ksched_get_priority_max(register_t *, struct ksched *, int);
-int ksched_get_priority_min(register_t *, struct ksched *, int);
-
-int ksched_rr_get_interval(register_t *, struct ksched *,
- struct proc *, struct timespec *);
-
-#endif /* _KPOSIX_PRIORITY_SCHEDULING */
-
-#endif /* _P1003_1B_P1003_1B_H_ */
diff --git a/sys/sys/random.h b/sys/sys/random.h
deleted file mode 100644
index 5a3cbe247f23..000000000000
--- a/sys/sys/random.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * random.h -- A strong random number generator
- *
- * $FreeBSD$
- *
- * Version 0.95, last modified 18-Oct-95
- *
- * Copyright Theodore Ts'o, 1994, 1995. 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, and the entire permission notice in its entirety,
- * including the disclaimer of warranties.
- * 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.
- *
- * ALTERNATIVELY, this product may be distributed under the terms of
- * the GNU Public License, in which case the provisions of the GPL are
- * required INSTEAD OF the above restrictions. (This clause is
- * necessary due to a potential bad interaction between the GPL and
- * the restrictions contained in a BSD-style copyright.)
- *
- * 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.
- *
- */
-
-/*
- * Many kernel routines will have a use for good random numbers,
- * for example, for truely random TCP sequence numbers, which prevent
- * certain forms of TCP spoofing attacks.
- *
- */
-
-#ifndef _MACHINE_RANDOM_H_
-#define _MACHINE_RANDOM_H_
-
-#include <sys/ioccom.h>
-
-#define MEM_SETIRQ _IOW('r', 1, u_int16_t) /* set interrupt */
-#define MEM_CLEARIRQ _IOW('r', 2, u_int16_t) /* clear interrupt */
-#define MEM_RETURNIRQ _IOR('r', 3, u_int16_t) /* return interrupt */
-
-#ifdef _KERNEL
-
-/* Type of the cookie passed to add_interrupt_randomness. */
-
-struct random_softc {
- inthand2_t *sc_handler;
- void *sc_arg;
- int sc_intr;
-};
-
-/* Exported functions */
-
-void rand_initialize(void);
-void add_keyboard_randomness(u_char scancode);
-inthand2_t add_interrupt_randomness;
-#ifdef notused
-void add_blkdev_randomness(int major);
-#endif
-
-#ifdef notused
-void get_random_bytes(void *buf, u_int nbytes);
-#endif
-u_int read_random(void *buf, u_int size);
-u_int read_random_unlimited(void *buf, u_int size);
-#ifdef notused
-u_int write_random(const char *buf, u_int nbytes);
-#endif
-int random_poll(dev_t dev, int events, struct proc *p);
-
-#endif /* _KERNEL */
-
-#endif /* !_MACHINE_RANDOM_H_ */
diff --git a/sys/sys/selinfo.h b/sys/sys/selinfo.h
deleted file mode 100644
index 8f58d858ba07..000000000000
--- a/sys/sys/selinfo.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*-
- * 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)select.h 8.2 (Berkeley) 1/4/94
- * $FreeBSD$
- */
-
-#ifndef _SYS_SELECT_H_
-#define _SYS_SELECT_H_
-
-/*
- * Used to maintain information about processes that wish to be
- * notified when I/O becomes possible.
- */
-struct selinfo {
- pid_t si_pid; /* process to be notified */
- short si_flags; /* see below */
-};
-#define SI_COLL 0x0001 /* collision occurred */
-
-#ifdef _KERNEL
-struct proc;
-
-void selrecord __P((struct proc *selector, struct selinfo *));
-void selwakeup __P((struct selinfo *));
-#endif
-
-#endif /* !_SYS_SELECT_H_ */
diff --git a/sys/sys/semaphore.h b/sys/sys/semaphore.h
deleted file mode 100644
index 9741b068add4..000000000000
--- a/sys/sys/semaphore.h
+++ /dev/null
@@ -1,72 +0,0 @@
-#ifndef _SEMAPHORE_H_
-#define _SEMAPHORE_H_
-
-/* semaphore.h: POSIX 1003.1b semaphores */
-
-/*-
- * Copyright (c) 1996, 1997
- * HD Associates, Inc. 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 HD Associates, Inc
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY HD ASSOCIATES 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 HD ASSOCIATES 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/_posix.h>
-#include <machine/limits.h>
-
-#ifdef _P1003_1B_INCLUDE_MAYBES
-#include <sys/types.h>
-#include <fcntl.h>
-#endif
-
-/* Opaque type definition. */
-struct sem;
-typedef struct sem *sem_t;
-
-#define SEM_FAILED ((sem_t *)0)
-#define SEM_VALUE_MAX UINT_MAX
-
-#ifndef _KERNEL
-#include <sys/cdefs.h>
-
-__BEGIN_DECLS
-int sem_init __P((sem_t *, int, unsigned int));
-int sem_destroy __P((sem_t *));
-sem_t *sem_open __P((const char *, int, ...));
-int sem_close __P((sem_t *));
-int sem_unlink __P((const char *));
-int sem_wait __P((sem_t *));
-int sem_trywait __P((sem_t *));
-int sem_post __P((sem_t *));
-int sem_getvalue __P((sem_t *, int *));
-__END_DECLS
-
-#endif
-
-#endif /* _SEMAPHORE_H_ */
diff --git a/sys/sys/smp.h b/sys/sys/smp.h
deleted file mode 100644
index c2340aef71d0..000000000000
--- a/sys/sys/smp.h
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * ----------------------------------------------------------------------------
- * "THE BEER-WARE LICENSE" (Revision 42):
- * <phk@FreeBSD.org> wrote this file. As long as you retain this notice you
- * can do whatever you want with this stuff. If we meet some day, and you think
- * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
- * ----------------------------------------------------------------------------
- *
- * $FreeBSD$
- *
- */
-
-#ifndef _MACHINE_SMP_H_
-#define _MACHINE_SMP_H_
-
-#ifdef _KERNEL
-
-#if defined(SMP) && !defined(APIC_IO)
-# error APIC_IO required for SMP, add "options APIC_IO" to your config file.
-#endif /* SMP && !APIC_IO */
-
-/* Number of CPUs. */
-#if defined(SMP) && !defined(NCPU)
-# define NCPU 2
-#endif /* SMP && NCPU */
-
-/* Number of IO APICs. */
-#if defined(APIC_IO) && !defined(NAPIC)
-# define NAPIC 1
-#endif /* SMP && NAPIC */
-
-
-#if defined(SMP) || defined(APIC_IO)
-
-#ifndef LOCORE
-
-/*
- * For sending values to POST displays.
- * XXX FIXME: where does this really belong, isa.h/isa.c perhaps?
- */
-extern int current_postcode; /** XXX currently in mp_machdep.c */
-#define POSTCODE(X) current_postcode = (X), \
- outb(0x80, current_postcode)
-#define POSTCODE_LO(X) current_postcode &= 0xf0, \
- current_postcode |= ((X) & 0x0f), \
- outb(0x80, current_postcode)
-#define POSTCODE_HI(X) current_postcode &= 0x0f, \
- current_postcode |= (((X) << 4) & 0xf0), \
- outb(0x80, current_postcode)
-
-
-#include <machine/apic.h>
-
-/* global data in mpboot.s */
-extern int bootMP_size;
-
-/* functions in mpboot.s */
-void bootMP __P((void));
-
-/* global data in mplock.s */
-extern u_int mp_lock;
-extern u_int isr_lock;
-#ifdef RECURSIVE_MPINTRLOCK
-extern u_int mpintr_lock;
-#endif /* RECURSIVE_MPINTRLOCK */
-
-/* functions in mplock.s */
-void get_mplock __P((void));
-void rel_mplock __P((void));
-int try_mplock __P((void));
-#ifdef RECURSIVE_MPINTRLOCK
-void get_mpintrlock __P((void));
-void rel_mpintrlock __P((void));
-int try_mpintrlock __P((void));
-#endif /* RECURSIVE_MPINTRLOCK */
-
-/* global data in apic_vector.s */
-extern volatile u_int stopped_cpus;
-extern volatile u_int started_cpus;
-
-extern volatile u_int checkstate_probed_cpus;
-extern volatile u_int checkstate_need_ast;
-extern volatile u_int resched_cpus;
-extern void (*cpustop_restartfunc) __P((void));
-
-/* functions in apic_ipl.s */
-void apic_eoi __P((void));
-u_int io_apic_read __P((int, int));
-void io_apic_write __P((int, int, u_int));
-
-/* global data in mp_machdep.c */
-extern int bsp_apic_ready;
-extern int mp_ncpus;
-extern int mp_naps;
-extern int mp_nbusses;
-extern int mp_napics;
-extern int mp_picmode;
-extern int boot_cpu_id;
-extern vm_offset_t cpu_apic_address;
-extern vm_offset_t io_apic_address[];
-extern u_int32_t cpu_apic_versions[];
-extern u_int32_t io_apic_versions[];
-extern int cpu_num_to_apic_id[];
-extern int io_num_to_apic_id[];
-extern int apic_id_to_logical[];
-#define APIC_INTMAPSIZE 24
-struct apic_intmapinfo {
- int ioapic;
- int int_pin;
- volatile void *apic_address;
- int redirindex;
-};
-extern struct apic_intmapinfo int_to_apicintpin[];
-extern u_int all_cpus;
-extern struct pcb stoppcbs[];
-
-/* functions in mp_machdep.c */
-u_int mp_bootaddress __P((u_int));
-int mp_probe __P((void));
-void mp_start __P((void));
-void mp_announce __P((void));
-u_int isa_apic_mask __P((u_int));
-int isa_apic_irq __P((int));
-int pci_apic_irq __P((int, int, int));
-int apic_irq __P((int, int));
-int next_apic_irq __P((int));
-int undirect_isa_irq __P((int));
-int undirect_pci_irq __P((int));
-int apic_bus_type __P((int));
-int apic_src_bus_id __P((int, int));
-int apic_src_bus_irq __P((int, int));
-int apic_int_type __P((int, int));
-int apic_trigger __P((int, int));
-int apic_polarity __P((int, int));
-void assign_apic_irq __P((int apic, int intpin, int irq));
-void revoke_apic_irq __P((int irq));
-void bsp_apic_configure __P((void));
-void init_secondary __P((void));
-void smp_invltlb __P((void));
-int stop_cpus __P((u_int));
-int restart_cpus __P((u_int));
-#ifdef BETTER_CLOCK
-void forward_statclock __P((int pscnt));
-void forward_hardclock __P((int pscnt));
-#endif /* BETTER_CLOCK */
-void forward_signal __P((struct proc *));
-void forward_roundrobin __P((void));
-#ifdef APIC_INTR_REORDER
-void set_lapic_isrloc __P((int, int));
-#endif /* APIC_INTR_REORDER */
-void smp_rendezvous_action __P((void));
-void smp_rendezvous __P((void (*)(void *),
- void (*)(void *),
- void (*)(void *),
- void *arg));
-
-/* global data in mpapic.c */
-extern volatile lapic_t lapic;
-extern volatile ioapic_t *ioapic[];
-
-/* functions in mpapic.c */
-void apic_dump __P((char*));
-void apic_initialize __P((void));
-void imen_dump __P((void));
-int apic_ipi __P((int, int, int));
-int selected_apic_ipi __P((u_int, int, int));
-int io_apic_setup __P((int));
-int ext_int_setup __P((int, int));
-
-#if defined(READY)
-void clr_io_apic_mask24 __P((int, u_int32_t));
-void set_io_apic_mask24 __P((int, u_int32_t));
-#endif /* READY */
-
-void set_apic_timer __P((int));
-int read_apic_timer __P((void));
-void u_sleep __P((int));
-
-/* global data in init_smp.c */
-extern int invltlb_ok;
-extern int smp_active;
-extern int smp_started;
-extern volatile int smp_idle_loops;
-
-#endif /* !LOCORE */
-#endif /* SMP || APIC_IO */
-#endif /* _KERNEL */
-#endif /* _MACHINE_SMP_H_ */
diff --git a/sys/sys/timetc.h b/sys/sys/timetc.h
deleted file mode 100644
index d7bbc839e0af..000000000000
--- a/sys/sys/timetc.h
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
- * 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)time.h 8.5 (Berkeley) 5/4/95
- * $FreeBSD$
- */
-
-#ifndef _SYS_TIME_H_
-#define _SYS_TIME_H_
-
-#include <sys/types.h>
-
-/*
- * Structure returned by gettimeofday(2) system call,
- * and used in other calls.
- */
-struct timeval {
- long tv_sec; /* seconds */
- long tv_usec; /* and microseconds */
-};
-
-#ifndef _TIMESPEC_DECLARED
-#define _TIMESPEC_DECLARED
-struct timespec {
- time_t tv_sec; /* seconds */
- long tv_nsec; /* and nanoseconds */
-};
-#endif
-
-#define TIMEVAL_TO_TIMESPEC(tv, ts) \
- do { \
- (ts)->tv_sec = (tv)->tv_sec; \
- (ts)->tv_nsec = (tv)->tv_usec * 1000; \
- } while (0)
-#define TIMESPEC_TO_TIMEVAL(tv, ts) \
- do { \
- (tv)->tv_sec = (ts)->tv_sec; \
- (tv)->tv_usec = (ts)->tv_nsec / 1000; \
- } while (0)
-
-struct timezone {
- int tz_minuteswest; /* minutes west of Greenwich */
- int tz_dsttime; /* type of dst correction */
-};
-#define DST_NONE 0 /* not on dst */
-#define DST_USA 1 /* USA style dst */
-#define DST_AUST 2 /* Australian style dst */
-#define DST_WET 3 /* Western European dst */
-#define DST_MET 4 /* Middle European dst */
-#define DST_EET 5 /* Eastern European dst */
-#define DST_CAN 6 /* Canada */
-
-/*
- * Structure used to interface to the machine dependent hardware support
- * for timekeeping.
- *
- * A timecounter is a (hard or soft) binary counter which has two properties:
- * * it runs at a fixed, known frequency.
- * * it must not roll over in less than (1 + delta)/HZ seconds. "delta"
- * is expected to be less than 20 msec, but no hard data has been
- * collected on this. 16 bit at 5 MHz (31 msec) is known to work.
- *
- * get_timecount() reads the counter.
- *
- * counter_mask removes unimplemented bits from the count value.
- *
- * frequency is the counter frequency in hz.
- *
- * name is a short mnemonic name for this counter.
- *
- * cost is a measure of how long time it takes to read the counter.
- *
- * adjustment [PPM << 16] which means that the smallest unit of correction
- * you can apply amounts to 481.5 usec/year.
- *
- * scale_micro [2^32 * usec/tick].
- * scale_nano_i [ns/tick].
- * scale_nano_f [(ns/2^32)/tick].
- *
- * offset_count is the contents of the counter which corresponds to the
- * rest of the offset_* values.
- *
- * offset_sec [s].
- * offset_micro [usec].
- * offset_nano [ns/2^32] is misnamed, the real unit is .23283064365...
- * attoseconds (10E-18) and before you ask: yes, they are in fact
- * called attoseconds, it comes from "atten" for 18 in Danish/Swedish.
- *
- * Each timecounter must supply an array of three timecounters, this is needed
- * to guarantee atomicity in the code. Index zero is used to transport
- * modifications, for instance done with sysctl, into the timecounter being
- * used in a safe way. Such changes may be adopted with a delay of up to 1/HZ,
- * index one & two are used alternately for the actual timekeeping.
- *
- * 'tc_avail' points to the next available (external) timecounter in a
- * circular queue. This is only valid for index 0.
- *
- * `tc_other' points to the next "work" timecounter in a circular queue,
- * i.e., for index i > 0 it points to index 1 + (i - 1) % NTIMECOUNTER.
- * We also use it to point from index 0 to index 1.
- *
- * `tc_tweak' points to index 0.
- */
-
-struct timecounter;
-typedef unsigned timecounter_get_t __P((struct timecounter *));
-typedef void timecounter_pps_t __P((struct timecounter *));
-
-struct timecounter {
- /* These fields must be initialized by the driver. */
- timecounter_get_t *tc_get_timecount;
- timecounter_pps_t *tc_poll_pps;
- unsigned tc_counter_mask;
- u_int32_t tc_frequency;
- char *tc_name;
- void *tc_priv;
- /* These fields will be managed by the generic code. */
- int64_t tc_adjustment;
- u_int32_t tc_scale_micro;
- u_int32_t tc_scale_nano_i;
- u_int32_t tc_scale_nano_f;
- unsigned tc_offset_count;
- u_int32_t tc_offset_sec;
- u_int32_t tc_offset_micro;
- u_int64_t tc_offset_nano;
- struct timeval tc_microtime;
- struct timespec tc_nanotime;
- struct timecounter *tc_avail;
- struct timecounter *tc_other;
- struct timecounter *tc_tweak;
-};
-
-#ifdef _KERNEL
-
-/* Operations on timespecs */
-#define timespecclear(tvp) ((tvp)->tv_sec = (tvp)->tv_nsec = 0)
-#define timespecisset(tvp) ((tvp)->tv_sec || (tvp)->tv_nsec)
-#define timespeccmp(tvp, uvp, cmp) \
- (((tvp)->tv_sec == (uvp)->tv_sec) ? \
- ((tvp)->tv_nsec cmp (uvp)->tv_nsec) : \
- ((tvp)->tv_sec cmp (uvp)->tv_sec))
-#define timespecadd(vvp, uvp) \
- do { \
- (vvp)->tv_sec += (uvp)->tv_sec; \
- (vvp)->tv_nsec += (uvp)->tv_nsec; \
- if ((vvp)->tv_nsec >= 1000000000) { \
- (vvp)->tv_sec++; \
- (vvp)->tv_nsec -= 1000000000; \
- } \
- } while (0)
-#define timespecsub(vvp, uvp) \
- do { \
- (vvp)->tv_sec -= (uvp)->tv_sec; \
- (vvp)->tv_nsec -= (uvp)->tv_nsec; \
- if ((vvp)->tv_nsec < 0) { \
- (vvp)->tv_sec--; \
- (vvp)->tv_nsec += 1000000000; \
- } \
- } while (0)
-
-/* Operations on timevals. */
-
-#define timevalclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
-#define timevalisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
-#define timevalcmp(tvp, uvp, cmp) \
- (((tvp)->tv_sec == (uvp)->tv_sec) ? \
- ((tvp)->tv_usec cmp (uvp)->tv_usec) : \
- ((tvp)->tv_sec cmp (uvp)->tv_sec))
-
-/* timevaladd and timevalsub are not inlined */
-
-#endif /* _KERNEL */
-
-#ifndef _KERNEL /* NetBSD/OpenBSD compatable interfaces */
-
-#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
-#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
-#define timercmp(tvp, uvp, cmp) \
- (((tvp)->tv_sec == (uvp)->tv_sec) ? \
- ((tvp)->tv_usec cmp (uvp)->tv_usec) : \
- ((tvp)->tv_sec cmp (uvp)->tv_sec))
-#define timeradd(tvp, uvp, vvp) \
- do { \
- (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \
- (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \
- if ((vvp)->tv_usec >= 1000000) { \
- (vvp)->tv_sec++; \
- (vvp)->tv_usec -= 1000000; \
- } \
- } while (0)
-#define timersub(tvp, uvp, vvp) \
- do { \
- (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
- (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
- if ((vvp)->tv_usec < 0) { \
- (vvp)->tv_sec--; \
- (vvp)->tv_usec += 1000000; \
- } \
- } while (0)
-#endif
-
-/*
- * Names of the interval timers, and structure
- * defining a timer setting.
- */
-#define ITIMER_REAL 0
-#define ITIMER_VIRTUAL 1
-#define ITIMER_PROF 2
-
-struct itimerval {
- struct timeval it_interval; /* timer interval */
- struct timeval it_value; /* current value */
-};
-
-/*
- * Getkerninfo clock information structure
- */
-struct clockinfo {
- int hz; /* clock frequency */
- int tick; /* micro-seconds per hz tick */
- int tickadj; /* clock skew rate for adjtime() */
- int stathz; /* statistics clock frequency */
- int profhz; /* profiling clock frequency */
-};
-
-/* CLOCK_REALTIME and TIMER_ABSTIME are supposed to be in time.h */
-
-#ifndef CLOCK_REALTIME
-#define CLOCK_REALTIME 0
-#endif
-#define CLOCK_VIRTUAL 1
-#define CLOCK_PROF 2
-
-#define TIMER_RELTIME 0x0 /* relative timer */
-#ifndef TIMER_ABSTIME
-#define TIMER_ABSTIME 0x1 /* absolute timer */
-#endif
-
-#ifdef _KERNEL
-extern struct timecounter *timecounter;
-extern time_t time_second;
-
-void getmicrouptime __P((struct timeval *tv));
-void getmicrotime __P((struct timeval *tv));
-void getnanouptime __P((struct timespec *tv));
-void getnanotime __P((struct timespec *tv));
-void init_timecounter __P((struct timecounter *tc));
-int itimerdecr __P((struct itimerval *itp, int usec));
-int itimerfix __P((struct timeval *tv));
-void microuptime __P((struct timeval *tv));
-void microtime __P((struct timeval *tv));
-void nanouptime __P((struct timespec *ts));
-void nanotime __P((struct timespec *ts));
-void set_timecounter __P((struct timespec *ts));
-void timevaladd __P((struct timeval *, struct timeval *));
-void timevalsub __P((struct timeval *, struct timeval *));
-int tvtohz __P((struct timeval *));
-void update_timecounter __P((struct timecounter *tc));
-#else /* !_KERNEL */
-#include <time.h>
-
-#include <sys/cdefs.h>
-
-__BEGIN_DECLS
-int adjtime __P((const struct timeval *, struct timeval *));
-int futimes __P((int, const struct timeval *));
-int getitimer __P((int, struct itimerval *));
-int gettimeofday __P((struct timeval *, struct timezone *));
-int lutimes __P((const char *, const struct timeval *));
-int setitimer __P((int, const struct itimerval *, struct itimerval *));
-int settimeofday __P((const struct timeval *, const struct timezone *));
-int utimes __P((const char *, const struct timeval *));
-__END_DECLS
-
-#endif /* !_KERNEL */
-
-#endif /* !_SYS_TIME_H_ */
diff --git a/sys/tools/devlist2h.awk b/sys/tools/devlist2h.awk
deleted file mode 100644
index 6c76b17a4ab8..000000000000
--- a/sys/tools/devlist2h.awk
+++ /dev/null
@@ -1,147 +0,0 @@
-#! /usr/bin/awk -f
-# $NetBSD: devlist2h.awk,v 1.2 1998/09/05 14:42:06 christos Exp $
-#
-# Copyright (c) 1998 The NetBSD Foundation, Inc.
-# All rights reserved.
-#
-# This code is derived from software contributed to The NetBSD Foundation
-# by Christos Zoulas.
-#
-# 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 the NetBSD
-# Foundation, Inc. and its contributors.
-# 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
-# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
-# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-#
-# Copyright (c) 1995, 1996 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 model includes software developed by Christopher G. Demetriou.
-# This model includes software developed by Christos Zoulas
-# 4. The name of the author(s) may not be used to endorse or promote models
-# 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.
-#
-# $FreeBSD$
-#
-function collectline(f, line) {
- oparen = 0
- line = ""
- while (f <= NF) {
- if ($f == "#") {
- line = line "("
- oparen = 1
- f++
- continue
- }
- if (oparen) {
- line = line $f
- if (f < NF)
- line = line " "
- f++
- continue
- }
- line = line $f
- if (f < NF)
- line = line " "
- f++
- }
- if (oparen)
- line = line ")"
- return line
-}
-BEGIN {
- nmodels = nouis = 0
- hfile="miidevs.h"
-}
-NR == 1 {
- VERSION = $0
- gsub("\\$", "", VERSION)
-
- printf("/*\t\$FreeBSD\$\t*/\n\n") > hfile
- printf("/*\n") > hfile
- printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
- > hfile
- printf(" *\n") > hfile
- printf(" * generated from:\n") > hfile
- printf(" *\t%s\n", VERSION) > hfile
- printf(" */\n") > hfile
-
- next
-}
-$1 == "oui" {
- nuios++
-
- ouiindex[$2] = nouis; # record index for this name, for later.
-
- ouis[nouis, 1] = $2; # name
- ouis[nouis, 2] = $3; # id
- printf("#define\tMII_OUI_%s\t%s\t", ouis[nouis, 1],
- ouis[nouis, 2]) > hfile
- ouis[nouis, 3] = collectline(4, line)
- printf("/* %s */\n", ouis[nouis, 3]) > hfile
- next
-}
-$1 == "model" {
- nmodels++
-
- models[nmodels, 1] = $2; # oui name
- models[nmodels, 2] = $3; # model id
- models[nmodels, 3] = $4; # id
-
- printf("#define\tMII_MODEL_%s_%s\t%s\n", models[nmodels, 1],
- models[nmodels, 2], models[nmodels, 3]) > hfile
-
- models[nmodels, 4] = collectline(5, line)
-
- printf("#define\tMII_STR_%s_%s\t\"%s\"\n",
- models[nmodels, 1], models[nmodels, 2],
- models[nmodels, 4]) > hfile
-
- next
-}
-{
- print $0 > hfile
-}
diff --git a/sys/tools/miidevs2h.awk b/sys/tools/miidevs2h.awk
deleted file mode 100644
index 6c76b17a4ab8..000000000000
--- a/sys/tools/miidevs2h.awk
+++ /dev/null
@@ -1,147 +0,0 @@
-#! /usr/bin/awk -f
-# $NetBSD: devlist2h.awk,v 1.2 1998/09/05 14:42:06 christos Exp $
-#
-# Copyright (c) 1998 The NetBSD Foundation, Inc.
-# All rights reserved.
-#
-# This code is derived from software contributed to The NetBSD Foundation
-# by Christos Zoulas.
-#
-# 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 the NetBSD
-# Foundation, Inc. and its contributors.
-# 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
-# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
-# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-#
-# Copyright (c) 1995, 1996 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 model includes software developed by Christopher G. Demetriou.
-# This model includes software developed by Christos Zoulas
-# 4. The name of the author(s) may not be used to endorse or promote models
-# 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.
-#
-# $FreeBSD$
-#
-function collectline(f, line) {
- oparen = 0
- line = ""
- while (f <= NF) {
- if ($f == "#") {
- line = line "("
- oparen = 1
- f++
- continue
- }
- if (oparen) {
- line = line $f
- if (f < NF)
- line = line " "
- f++
- continue
- }
- line = line $f
- if (f < NF)
- line = line " "
- f++
- }
- if (oparen)
- line = line ")"
- return line
-}
-BEGIN {
- nmodels = nouis = 0
- hfile="miidevs.h"
-}
-NR == 1 {
- VERSION = $0
- gsub("\\$", "", VERSION)
-
- printf("/*\t\$FreeBSD\$\t*/\n\n") > hfile
- printf("/*\n") > hfile
- printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
- > hfile
- printf(" *\n") > hfile
- printf(" * generated from:\n") > hfile
- printf(" *\t%s\n", VERSION) > hfile
- printf(" */\n") > hfile
-
- next
-}
-$1 == "oui" {
- nuios++
-
- ouiindex[$2] = nouis; # record index for this name, for later.
-
- ouis[nouis, 1] = $2; # name
- ouis[nouis, 2] = $3; # id
- printf("#define\tMII_OUI_%s\t%s\t", ouis[nouis, 1],
- ouis[nouis, 2]) > hfile
- ouis[nouis, 3] = collectline(4, line)
- printf("/* %s */\n", ouis[nouis, 3]) > hfile
- next
-}
-$1 == "model" {
- nmodels++
-
- models[nmodels, 1] = $2; # oui name
- models[nmodels, 2] = $3; # model id
- models[nmodels, 3] = $4; # id
-
- printf("#define\tMII_MODEL_%s_%s\t%s\n", models[nmodels, 1],
- models[nmodels, 2], models[nmodels, 3]) > hfile
-
- models[nmodels, 4] = collectline(5, line)
-
- printf("#define\tMII_STR_%s_%s\t\"%s\"\n",
- models[nmodels, 1], models[nmodels, 2],
- models[nmodels, 4]) > hfile
-
- next
-}
-{
- print $0 > hfile
-}
diff --git a/sys/tools/pccarddevs2h.awk b/sys/tools/pccarddevs2h.awk
deleted file mode 100644
index f5863977751b..000000000000
--- a/sys/tools/pccarddevs2h.awk
+++ /dev/null
@@ -1,226 +0,0 @@
-#! /usr/bin/awk -f
-# $NetBSD: devlist2h.awk,v 1.3 1998/09/05 14:42:06 christos Exp $
-# $FreeBSD$
-#
-# Copyright (c) 1998 The NetBSD Foundation, Inc.
-# All rights reserved.
-#
-# This code is derived from software contributed to The NetBSD Foundation
-# by Christos Zoulas.
-#
-# 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 the NetBSD
-# Foundation, Inc. and its contributors.
-# 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
-# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
-# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-#
-# Copyright (c) 1995, 1996 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.
-# This product includes software developed by Christos Zoulas
-# 4. The name of the author(s) 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.
-#
-function collectline(f, line) {
- oparen = 0
- line = ""
- while (f <= NF) {
- if ($f == "#") {
- line = line "("
- oparen = 1
- f++
- continue
- }
- if (oparen) {
- line = line $f
- if (f < NF)
- line = line " "
- f++
- continue
- }
- line = line $f
- if (f < NF)
- line = line " "
- f++
- }
- if (oparen)
- line = line ")"
- return line
-}
-BEGIN {
- nproducts = nvendors = 0
- dfile="pccarddevs_data.h"
- hfile="pccarddevs.h"
-}
-NR == 1 {
- VERSION = $0
- gsub("\\$", "", VERSION)
-
- printf("/*\t\$FreeBSD\$\t*/\n\n") > dfile
- printf("/*\n") > dfile
- printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
- > dfile
- printf(" *\n") > dfile
- printf(" * generated from:\n") > dfile
- printf(" *\t%s\n", VERSION) > dfile
- printf(" */\n") > dfile
-
- printf("/*\t\$FreeBSD\$\t*/\n\n") > hfile
- printf("/*\n") > hfile
- printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
- > hfile
- printf(" *\n") > hfile
- printf(" * generated from:\n") > hfile
- printf(" *\t%s\n", VERSION) > hfile
- printf(" */\n") > hfile
-
- next
-}
-$1 == "vendor" {
- nvendors++
-
- vendorindex[$2] = nvendors; # record index for this name, for later.
- vendors[nvendors, 1] = $2; # name
- vendors[nvendors, 2] = $3; # id
- printf("#define\tPCCARD_VENDOR_%s\t%s\t", vendors[nvendors, 1],
- vendors[nvendors, 2]) > hfile
- vendors[nvendors, 3] = collectline(4, line)
- printf("/* %s */\n", vendors[nvendors, 3]) > hfile
- next
-}
-$1 == "product" {
- nproducts++
-
- products[nproducts, 1] = $2; # vendor name
- products[nproducts, 2] = $3; # product id
- products[nproducts, 3] = $4; # id
-
- f = 5;
-
- if ($4 == "{") {
- products[nproducts, 3] = -1
- z = "{ "
- for (i = 0; i < 4; i++) {
- if (f <= NF) {
- gsub("&sp", " ", $f)
- gsub("&tab", "\t", $f)
- gsub("&nl", "\n", $f)
- z = z $f " "
- f++
- }
- else {
- if (i == 3)
- z = z "NULL "
- else
- z = z "NULL, "
- }
- }
- products[nproducts, 4] = z $f
- f++
- }
- else {
- products[nproducts, 4] = "{ NULL, NULL, NULL, NULL }"
- }
- printf("#define\tPCCARD_CIS_%s_%s\t%s\n",
- products[nproducts, 1], products[nproducts, 2],
- products[nproducts, 4]) > hfile
- printf("#define\tPCCARD_PRODUCT_%s_%s\t%s\n", products[nproducts, 1],
- products[nproducts, 2], products[nproducts, 3]) > hfile
-
- products[nproducts, 5] = collectline(f, line)
-
- printf("#define\tPCCARD_STR_%s_%s\t\"%s\"\n",
- products[nproducts, 1], products[nproducts, 2],
- products[nproducts, 5]) > hfile
-
- next
-}
-{
- if ($0 == "")
- blanklines++
- print $0 > hfile
- if (blanklines < 2)
- print $0 > dfile
-}
-END {
- # print out the match tables
-
- printf("\n") > dfile
-
- printf("struct pccard_knowndev pccard_knowndevs[] = {\n") > dfile
- for (i = 1; i <= nproducts; i++) {
- printf("\t{\n") > dfile
- if (products[i, 3] == -1) {
- printf("\t PCCARD_VENDOR_UNKNOWN, PCCARD_PRODUCT_%s_%s,\n",
- products[i, 1], products[i, 2]) > dfile
- } else {
- printf("\t PCCARD_VENDOR_%s, PCCARD_PRODUCT_%s_%s,\n",
- products[i, 1], products[i, 1], products[i, 2]) > dfile
- }
- printf("\t PCCARD_CIS_%s_%s,\n",
- products[i, 1], products[i, 2]) > dfile
- printf("\t ") > dfile
- printf("0") > dfile
- printf(",\n") > dfile
-
- vendi = vendorindex[products[i, 1]];
- printf("\t \"%s\",\n", vendors[vendi, 3]) > dfile
- printf("\t \"%s\"\t},\n", products[i, 5]) > dfile
- printf("\t},\n") > dfile
- }
- for (i = 1; i <= nvendors; i++) {
- printf("\t{\n") > dfile
- printf("\t PCCARD_VENDOR_%s, 0,\n", vendors[i, 1]) > dfile
- printf("\t PCCARD_KNOWNDEV_NOPROD,\n") > dfile
- printf("\t PCCARD_CIS_INVALID,\n") > dfile
- printf("\t \"%s\",\n", vendors[i, 3]) > dfile
- printf("\t NULL,\n") > dfile
- printf("\t},\n") > dfile
- }
- printf("\t{ 0, 0, { NULL, NULL, NULL, NULL }, 0, NULL, NULL, }\n") > dfile
- printf("};\n") > dfile
-}
diff --git a/sys/tools/usbdevs2h.awk b/sys/tools/usbdevs2h.awk
deleted file mode 100644
index 6b99b3d0df89..000000000000
--- a/sys/tools/usbdevs2h.awk
+++ /dev/null
@@ -1,236 +0,0 @@
-#! /usr/bin/awk -f
-# $NetBSD: devlist2h.awk,v 1.6 1999/08/17 16:06:20 augustss Exp $
-# $FreeBSD$
-#
-# Copyright (c) 1995, 1996 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.
-#
-BEGIN {
- nproducts = nvendors = 0
- dfile="usbdevs_data.h"
- hfile="usbdevs.h"
-}
-NR == 1 {
- VERSION = $0
- gsub("\\$", "", VERSION)
-
- if (os == "NetBSD")
- printf("/*\t\$NetBSD\$\t*/\n\n") > dfile
- else if (os == "FreeBSD")
- printf("/*\t\$FreeBSD\$\t*/\n\n") > dfile
- else if (os == "OpenBSD")
- printf("/*\t\$OpenBSD\$\t*/\n\n") > dfile
- else
- printf("/* ??? */\n\n") > dfile
- printf("/*\n") > dfile
- printf(" * THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
- > dfile
- printf(" *\n") > dfile
- printf(" * generated from:\n") > dfile
- printf(" *\t%s\n", VERSION) > dfile
- printf(" */\n") > dfile
-
- if (os == "NetBSD")
- printf("/*\t\$NetBSD\$\t*/\n\n") > hfile
- else if (os == "FreeBSD")
- printf("/*\t\$FreeBSD\$\t*/\n\n") > hfile
- else if (os == "OpenBSD")
- printf("/*\t\$OpenBSD\$\t*/\n\n") > hfile
- else
- printf("/* ??? */\n\n") > hfile
- printf("/*\n") > hfile
- printf(" * THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \
- > hfile
- printf(" *\n") > hfile
- printf(" * generated from:\n") > hfile
- printf(" *\t%s\n", VERSION) > hfile
- printf(" */\n") > hfile
-
- next
-}
-$1 == "vendor" {
- nvendors++
-
- vendorindex[$2] = nvendors; # record index for this name, for later.
- vendors[nvendors, 1] = $2; # name
- vendors[nvendors, 2] = $3; # id
- printf("#define\tUSB_VENDOR_%s\t%s\t", vendors[nvendors, 1],
- vendors[nvendors, 2]) > hfile
-
- i = 3; f = 4;
-
- # comments
- ocomment = oparen = 0
- if (f <= NF) {
- printf("\t/* ") > hfile
- ocomment = 1;
- }
- while (f <= NF) {
- if ($f == "#") {
- printf("(") > hfile
- oparen = 1
- f++
- continue
- }
- if (oparen) {
- printf("%s", $f) > hfile
- if (f < NF)
- printf(" ") > hfile
- f++
- continue
- }
- vendors[nvendors, i] = $f
- printf("%s", vendors[nvendors, i]) > hfile
- if (f < NF)
- printf(" ") > hfile
- i++; f++;
- }
- if (oparen)
- printf(")") > hfile
- if (ocomment)
- printf(" */") > hfile
- printf("\n") > hfile
-
- next
-}
-$1 == "product" {
- nproducts++
-
- products[nproducts, 1] = $2; # vendor name
- products[nproducts, 2] = $3; # product id
- products[nproducts, 3] = $4; # id
- printf("#define\tUSB_PRODUCT_%s_%s\t%s\t", products[nproducts, 1],
- products[nproducts, 2], products[nproducts, 3]) > hfile
-
- i=4; f = 5;
-
- # comments
- ocomment = oparen = 0
- if (f <= NF) {
- printf("\t/* ") > hfile
- ocomment = 1;
- }
- while (f <= NF) {
- if ($f == "#") {
- printf("(") > hfile
- oparen = 1
- f++
- continue
- }
- if (oparen) {
- printf("%s", $f) > hfile
- if (f < NF)
- printf(" ") > hfile
- f++
- continue
- }
- products[nproducts, i] = $f
- printf("%s", products[nproducts, i]) > hfile
- if (f < NF)
- printf(" ") > hfile
- i++; f++;
- }
- if (oparen)
- printf(")") > hfile
- if (ocomment)
- printf(" */") > hfile
- printf("\n") > hfile
-
- next
-}
-{
- if ($0 == "")
- blanklines++
- print $0 > hfile
- if (blanklines < 2)
- print $0 > dfile
-}
-END {
- # print out the match tables
-
- printf("\n") > dfile
-
- printf("struct usb_knowndev usb_knowndevs[] = {\n") > dfile
- for (i = 1; i <= nproducts; i++) {
- printf("\t{\n") > dfile
- printf("\t USB_VENDOR_%s, USB_PRODUCT_%s_%s,\n",
- products[i, 1], products[i, 1], products[i, 2]) \
- > dfile
- printf("\t ") > dfile
- printf("0") > dfile
- printf(",\n") > dfile
-
- vendi = vendorindex[products[i, 1]];
- printf("\t \"") > dfile
- j = 3;
- needspace = 0;
- while (vendors[vendi, j] != "") {
- if (needspace)
- printf(" ") > dfile
- printf("%s", vendors[vendi, j]) > dfile
- needspace = 1
- j++
- }
- printf("\",\n") > dfile
-
- printf("\t \"") > dfile
- j = 4;
- needspace = 0;
- while (products[i, j] != "") {
- if (needspace)
- printf(" ") > dfile
- printf("%s", products[i, j]) > dfile
- needspace = 1
- j++
- }
- printf("\",\n") > dfile
- printf("\t},\n") > dfile
- }
- for (i = 1; i <= nvendors; i++) {
- printf("\t{\n") > dfile
- printf("\t USB_VENDOR_%s, 0,\n", vendors[i, 1]) \
- > dfile
- printf("\t USB_KNOWNDEV_NOPROD,\n") \
- > dfile
- printf("\t \"") > dfile
- j = 3;
- needspace = 0;
- while (vendors[i, j] != "") {
- if (needspace)
- printf(" ") > dfile
- printf("%s", vendors[i, j]) > dfile
- needspace = 1
- j++
- }
- printf("\",\n") > dfile
- printf("\t NULL,\n") > dfile
- printf("\t},\n") > dfile
- }
- printf("\t{ 0, 0, 0, NULL, NULL, }\n") > dfile
- printf("};\n") > dfile
-}
diff --git a/sys/tools/vnode_if.awk b/sys/tools/vnode_if.awk
deleted file mode 100644
index f8675cd1d71d..000000000000
--- a/sys/tools/vnode_if.awk
+++ /dev/null
@@ -1,354 +0,0 @@
-#!/usr/bin/perl
-eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
- if $running_under_some_shell;
-
-#
-# 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. 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, Berkeley and its contributors.
-# 4. 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.
-#
-# @(#)vnode_if.sh 8.1 (Berkeley) 6/10/93
-# $FreeBSD$
-#
-# Script to produce VFS front-end sugar.
-#
-# usage: vnode_if.sh srcfile
-# (where srcfile is currently /sys/kern/vnode_if.src)
-#
-
-my %lockdata;
-
-$cfile = 0;
-$hfile = 0;
-
-# Process the command line
-#
-while ($arg = shift @ARGV) {
- if ($arg eq '-c') {
- $cfile = 1;
- } elsif ($arg eq '-h') {
- $hfile = 1;
- } elsif ($arg eq '-ch' || $arg eq '-hc') {
- $cfile = 1;
- $hfile = 1;
- } elsif ($arg =~ m/\.src$/) {
- $SRC = $arg;
- } else {
- print "usage: vnode_if.sh [-c] [-h] srcfile\n";
- exit(1);
- }
-}
-if (!$cfile and !$hfile) {
- exit(0); # nothing asked for..
-}
-
-# Names of the created files.
-$CFILE='vnode_if.c';
-$HEADER='vnode_if.h';
-
-open(SRC, "<$SRC") || die "Unable to open input file";
-
-if ($hfile) {
- open(HEADER, ">$HEADER") || die "Unable to create $HEADER";
- # Print out header information for vnode_if.h.
- print HEADER <<END_OF_LEADING_COMMENT
-/*
- * This file is produced automatically.
- * Do not modify anything in here by hand.
- *
- * Created from @(#)vnode_if.sh 8.1 (Berkeley) 6/10/93
- */
-
-extern struct vnodeop_desc vop_default_desc;
-END_OF_LEADING_COMMENT
- ;
-}
-
-if ($cfile) {
- open(CFILE, ">$CFILE") || die "Unable to create $CFILE";
- # Print out header information for vnode_if.c.
- print CFILE <<END_OF_LEADING_COMMENT
-/*
- * This file is produced automatically.
- * Do not modify anything in here by hand.
- *
- * Created from @(#)vnode_if.sh 8.1 (Berkeley) 6/10/93
- */
-
-#include <sys/param.h>
-#include <sys/vnode.h>
-
-struct vnodeop_desc vop_default_desc = {
- 1, /* special case, vop_default => 1 */
- "default",
- 0,
- NULL,
- VDESC_NO_OFFSET,
- VDESC_NO_OFFSET,
- VDESC_NO_OFFSET,
- VDESC_NO_OFFSET,
- NULL,
-};
-
-END_OF_LEADING_COMMENT
- ;
-}
-
-line: while (<SRC>) {
- chop; # strip record separator
- @Fld = split ' ';
- if (@Fld == 0) {
- next line;
- }
- if (/^#/) {
- if (!/^#%\s+([a-z]+)\s+([a-z]+)\s+(.)\s(.)\s(.)/) {
- next;
- }
- if (!defined($lockdata{"vop_$1"})) {
- $lockdata{"vop_$1"} = {};
- }
- $lockdata{"vop_$1"}->{$2} = {
- 'Entry' => $3,
- 'OK' => $4,
- 'Error' => $5,
- };
- next;
- }
-
- # Get the function name.
- $name = $Fld[0];
- $uname = uc($name);
-
- # Get the function arguments.
- for ($numargs = 0; ; ++$numargs) {
- if ($ln = <SRC>) {
- chomp;
- } else {
- die "Unable to read through the arguments for \"$name\"";
- }
- if ($ln =~ /^\};/) {
- last;
- }
- # For the header file
- $a{$numargs} = $ln;
-
- # The rest of this loop is for the C file
- # Delete comments, if any.
- $ln =~ s/\/\*.*\*\///g;
-
- # Delete leading/trailing space.
- $ln =~ s/^\s*(.*?)\s*$/$1/;
-
- # Pick off direction.
- if ($ln =~ s/^INOUT\s+//) {
- $dir = 'INOUT';
- } elsif ($ln =~ s/^IN\s+//) {
- $dir = 'IN';
- } elsif ($ln =~ s/^OUT\s+//) {
- $dir = 'OUT';
- } else {
- die "No IN/OUT direction for \"$ln\".";
- }
- if ($ln =~ s/^WILLRELE\s+//) {
- $rele = 'WILLRELE';
- } else {
- $rele = 'WONTRELE';
- }
-
- # kill trailing ;
- if ($ln !~ s/;$//) {
- &bail("Missing end-of-line ; in \"$ln\".");
- }
-
- # pick off variable name
- if ($ln !~ s/([A-Za-z0-9_]+)$//) {
- &bail("Missing var name \"a_foo\" in \"$ln\".");
- }
- $arg = $1;
-
- # what is left must be type
- # (put clean it up some)
- $type = $ln;
- # condense whitespace
- $type =~ s/\s+/ /g;
- $type =~ s/^\s*(.*?)\s*$/$1/;
-
- $dirs{$numargs} = $dir;
- $reles{$numargs} = $rele;
- $types{$numargs} = $type;
- $args{$numargs} = $arg;
- }
-
- if ($hfile) {
- # Print out the vop_F_args structure.
- print HEADER "struct ${name}_args {\n\tstruct vnodeop_desc *a_desc;\n";
- for ($c2 = 0; $c2 < $numargs; ++$c2) {
- $a{$c2} =~ /^\s*(INOUT|OUT|IN)(\s+WILLRELE)?\s+(.*?)\s+(\**)(\S*\;)/;
- print HEADER "\t$3 $4a_$5\n",
- }
- print HEADER "};\n";
-
- # Print out extern declaration.
- print HEADER "extern struct vnodeop_desc ${name}_desc;\n";
-
- # Print out prototype.
- print HEADER "static __inline int ${uname} __P((\n";
- for ($c2 = 0; $c2 < $numargs; ++$c2) {
- $a{$c2} =~ /^\s*(INOUT|OUT|IN)(\s+WILLRELE)?\s+(.*?)\s+(\**\S*)\;/;
- print HEADER "\t$3 $4" .
- ($c2 < $numargs-1 ? "," : "));") . "\n";
- }
-
- # Print out function.
- print HEADER "static __inline int ${uname}(";
- for ($c2 = 0; $c2 < $numargs; ++$c2) {
- $a{$c2} =~ /\**([^;\s]*)\;[^\s]*$/;
- print HEADER "$1" . ($c2 < $numargs - 1 ? ', ' : ")\n");
- }
- for ($c2 = 0; $c2 < $numargs; ++$c2) {
- $a{$c2} =~ /^\s*(INOUT|OUT|IN)(\s+WILLRELE)?\s+(.*?)\s+(\**\S*\;)/;
- print HEADER "\t$3 $4\n";
- }
- print HEADER "{\n\tstruct ${name}_args a;\n";
- print HEADER "\tint rc;\n";
- print HEADER "\ta.a_desc = VDESC(${name});\n";
- for ($c2 = 0; $c2 < $numargs; ++$c2) {
- $a{$c2} =~ /(\**)([^;\s]*)([^\s]*)$/;
- print HEADER "\ta.a_$2 = $2$3\n",
- }
- for ($c2 = 0; $c2 < $numargs; ++$c2) {
- if (!exists($args{$c2})) {
- die "Internal error";
- }
- if (exists($lockdata{$name}) &&
- exists($lockdata{$name}->{$args{$c2}})) {
- if ($ENV{'DEBUG_ALL_VFS_LOCKS'} =~ /yes/i) {
- # Add assertions for locking
- if ($lockdata{$name}->{$args{$c2}}->{Entry} eq "L") {
- print HEADER
- "\tASSERT_VOP_LOCKED($args{$c2}, \"$uname\");\n";
- } elsif ($lockdata{$name}->{$args{$c2}}->{Entry} eq "U") {
- print HEADER
- "\tASSERT_VOP_UNLOCKED($args{$c2}, \"$uname\");\n";
- } elsif (0) {
- # XXX More checks!
- }
- }
- }
- }
- $a{0} =~ /\s\**([^;\s]*);/;
- print HEADER "\trc = VCALL($1, VOFFSET(${name}), &a);\n";
- print HEADER "\treturn (rc);\n";
- print HEADER "}\n";
- }
-
-
- if ($cfile) {
- # Print out the vop_F_vp_offsets structure. This all depends
- # on naming conventions and nothing else.
- printf CFILE "static int %s_vp_offsets[] = {\n", $name;
- # as a side effect, figure out the releflags
- $releflags = '';
- $vpnum = 0;
- for ($i = 0; $i < $numargs; $i++) {
- if ($types{$i} eq 'struct vnode *') {
- printf CFILE "\tVOPARG_OFFSETOF(struct %s_args,a_%s),\n",
- $name, $args{$i};
- if ($reles{$i} eq 'WILLRELE') {
- $releflags = $releflags . '|VDESC_VP' . $vpnum . '_WILLRELE';
- }
-
- $vpnum++;
- }
- }
-
- $releflags =~ s/^\|//;
- print CFILE "\tVDESC_NO_OFFSET\n";
- print CFILE "};\n";
-
- # Print out the vnodeop_desc structure.
- print CFILE "struct vnodeop_desc ${name}_desc = {\n";
- # offset
- print CFILE "\t0,\n";
- # printable name
- printf CFILE "\t\"%s\",\n", $name;
- # flags
- $vppwillrele = '';
- for ($i = 0; $i < $numargs; $i++) {
- if ($types{$i} eq 'struct vnode **' &&
- ($reles{$i} eq 'WILLRELE')) {
- $vppwillrele = '|VDESC_VPP_WILLRELE';
- }
- }
-
- if ($releflags eq '') {
- printf CFILE "\t0%s,\n", $vppwillrele;
- }
- else {
- printf CFILE "\t%s%s,\n", $releflags, $vppwillrele;
- }
-
- # vp offsets
- printf CFILE "\t%s_vp_offsets,\n", $name;
- # vpp (if any)
- printf CFILE "\t%s,\n", &find_arg_with_type('struct vnode **');
- # cred (if any)
- printf CFILE "\t%s,\n", &find_arg_with_type('struct ucred *');
- # proc (if any)
- printf CFILE "\t%s,\n", &find_arg_with_type('struct proc *');
- # componentname
- printf CFILE "\t%s,\n", &find_arg_with_type('struct componentname *');
- # transport layer information
- print CFILE "\tNULL,\n};\n\n";
- }
-}
-
-if ($hfile) {
- close(HEADER) || die "Unable to close $HEADER";
-}
-if ($cfile) {
- close(CFILE) || die "Unable to close $CFILE";
-}
-close(SRC) || die;
-
-exit 0;
-
-sub find_arg_with_type {
- my $type = shift;
- my $i;
-
- for ($i=0; $i < $numargs; $i++) {
- if ($types{$i} eq $type) {
- return "VOPARG_OFFSETOF(struct ${name}_args,a_" . $args{$i} . ")";
- }
- }
-
- return "VDESC_NO_OFFSET";
-}
diff --git a/tools/regression/usr.bin/sed/hanoi.sed b/tools/regression/usr.bin/sed/hanoi.sed
deleted file mode 100644
index d29c64836b33..000000000000
--- a/tools/regression/usr.bin/sed/hanoi.sed
+++ /dev/null
@@ -1,102 +0,0 @@
-# Towers of Hanoi in sed.
-#
-# @(#)hanoi.sed 8.1 (Berkeley) 6/6/93
-#
-#
-# Ex:
-# Run "sed -f hanoi.sed", and enter:
-#
-# :abcd: : :<CR><CR>
-#
-# note -- TWO carriage returns, a peculiarity of sed), this will output the
-# sequence of states involved in moving 4 rings, the largest called "a" and
-# the smallest called "d", from the first to the second of three towers, so
-# that the rings on any tower at any time are in descending order of size.
-# You can start with a different arrangement and a different number of rings,
-# say :ce:b:ax: and it will give the shortest procedure for moving them all
-# to the middle tower. The rules are: the names of the rings must all be
-# lower-case letters, they must be input within 3 fields (representing the
-# towers) and delimited by 4 colons, such that the letters within each field
-# are in alphabetical order (i.e. rings are in descending order of size).
-#
-# For the benefit of anyone who wants to figure out the script, an "internal"
-# line of the form
-# b:0abx:1a2b3 :2 :3x2
-# has the following meaning: the material after the three markers :1, :2,
-# and :3 represents the three towers; in this case the current set-up is
-# ":ab : :x :". The numbers after a, b and x in these fields indicate
-# that the next time it gets a chance, it will move a to tower 2, move b
-# to tower 3, and move x to tower 2. The string after :0 just keeps track
-# of the alphabetical order of the names of the rings. The b at the
-# beginning means that it is now dealing with ring b (either about to move
-# it, or re-evaluating where it should next be moved to).
-#
-# Although this version is "limited" to 26 rings because of the size of the
-# alphabet, one could write a script using the same idea in which the rings
-# were represented by arbitrary [strings][within][brackets], and in place of
-# the built-in line of the script giving the order of the letters of the
-# alphabet, it would accept from the user a line giving the ordering to be
-# assumed, e.g. [ucbvax][decvax][hplabs][foo][bar].
-#
-# George Bergman
-# Math, UC Berkeley 94720 USA
-
-# cleaning, diagnostics
-s/ *//g
-/^$/d
-/[^a-z:]/{a\
-Illegal characters: use only a-z and ":". Try again.
-d
-}
-/^:[a-z]*:[a-z]*:[a-z]*:$/!{a\
-Incorrect format: use\
-\ : string1 : string2 : string3 :<CR><CR>\
-Try again.
-d
-}
-/\([a-z]\).*\1/{a\
-Repeated letters not allowed. Try again.
-d
-}
-# initial formatting
-h
-s/[a-z]/ /g
-G
-s/^:\( *\):\( *\):\( *\):\n:\([a-z]*\):\([a-z]*\):\([a-z]*\):$/:1\4\2\3:2\5\1\3:3\6\1\2:0/
-s/[a-z]/&2/g
-s/^/abcdefghijklmnopqrstuvwxyz/
-:a
-s/^\(.\).*\1.*/&\1/
-s/.//
-/^[^:]/ba
-s/\([^0]*\)\(:0.*\)/\2\1:/
-s/^[^0]*0\(.\)/\1&/
-:b
-# outputting current state without markers
-h
-s/.*:1/:/
-s/[123]//gp
-g
-:c
-# establishing destinations
-/^\(.\).*\1:1/td
-/^\(.\).*:1[^:]*\11/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\31/
-/^\(.\).*:1[^:]*\12/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\33/
-/^\(.\).*:1[^:]*\13/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\32/
-/^\(.\).*:2[^:]*\11/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\33/
-/^\(.\).*:2[^:]*\12/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\32/
-/^\(.\).*:2[^:]*\13/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\31/
-/^\(.\).*:3[^:]*\11/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\32/
-/^\(.\).*:3[^:]*\12/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\31/
-/^\(.\).*:3[^:]*\13/s/^\(.\)\(.*\1\([a-z]\).*\)\3./\3\2\33/
-bc
-# iterate back to find smallest out-of-place ring
-:d
-s/^\(.\)\(:0[^:]*\([^:]\)\1.*:\([123]\)[^:]*\1\)\4/\3\2\4/
-td
-# move said ring (right, resp. left)
-s/^\(.\)\(.*\)\1\([23]\)\(.*:\3[^ ]*\) /\1\2 \4\1\3/
-s/^\(.\)\(.*:\([12]\)[^ ]*\) \(.*\)\1\3/\1\2\1\3\4 /
-tb
-s/.*/Done! Try another, or end with ^D./p
-d
diff --git a/tools/regression/usr.bin/sed/math.sed b/tools/regression/usr.bin/sed/math.sed
deleted file mode 100644
index 8e7bf51fbca7..000000000000
--- a/tools/regression/usr.bin/sed/math.sed
+++ /dev/null
@@ -1,163 +0,0 @@
-#
-# @(#)math.sed 8.1 (Berkeley) 6/6/93
-#
-# Addition and multiplication in sed.
-# ++ for a limited time only do (expr) too!!!
-#
-# Kevin S Braunsdorf, PUCC UNIX Group, ksb@cc.purdue.edu.
-#
-# Ex:
-# echo "4+7*3" | sed -f %f
-
-# make sure the expression is well formed
-s/[ ]//g
-/[+*\/-]$/{
- a\
- poorly formed expression, operator on the end
- q
-}
-/^[+*\/]/{
- a\
- poorly formed expression, leading operator
- q
-}
-
-# fill hold space with done token
-x
-s/^.*/done/
-x
-
-# main loop, process operators (*, + and () )
-: loop
-/^\+/{
- s///
- b loop
-}
-/^\(.*\)(\([^)]*\))\(.*\)$/{
- H
- s//\2/
- x
- s/^\(.*\)\n\(.*\)(\([^()]*\))\(.*\)$/()\2@\4@\1/
- x
- b loop
-}
-/^[0-9]*\*/b mul
-/^\([0-9]*\)\+\([0-9+*]*\*[0-9]*\)$/{
- s//\2+\1/
- b loop
-}
-/^[0-9]*\+/{
- s/$/=/
- b add
-}
-x
-/^done$/{
- x
- p
- d
-}
-/^()/{
- s///
- x
- G
- s/\(.*\)\n\([^@]*\)@\([^@]*\)@\(.*\)/\2\1\3/
- x
- s/[^@]*@[^@]*@\(.*\)/\1/
- x
- b loop
-}
-i\
-help, stack problem
-p
-x
-p
-q
-
-# turn mul into add until 1*x -> x
-: mul
-/^0*1\*/{
- s///
- b loop
-}
-/^\([0-9]*\)0\*/{
- s/^\([0-9]*\)0\*\([0-9]*\)/\1*\20/
- b mul
-}
-s/^\([0-9]*\)1\*/\10*/
-s/^\([0-9]*\)2\*/\11*/
-s/^\([0-9]*\)3\*/\12*/
-s/^\([0-9]*\)4\*/\13*/
-s/^\([0-9]*\)5\*/\14*/
-s/^\([0-9]*\)6\*/\15*/
-s/^\([0-9]*\)7\*/\16*/
-s/^\([0-9]*\)8\*/\17*/
-s/^\([0-9]*\)9\*/\18*/
-s/\*\([0-9*]*\)/*\1+\1/
-b mul
-
-# get rid of a plus term until 0+x -> x
-: add
-/^\+\([0-9+*]*\)=/{
- s//\1/
- b loop
-}
-/^\([0-9*]*\)\+=/{
- s//\1/
- b loop
-}
-/^\([0-9]*\)\+\([0-9*+]*\)\+=/{
- s//\2+\1/
- b loop
-}
-/^\([0-9]*\)0\+\([0-9]*\)\([0-9]\)=/{
- s//\1+\2=\3/
- b add
-}
-/^\([0-9]*\)\([0-9]\)\+\([0-9]*\)0=/{
- s//\1+\3=\2/
- b add
-}
-/^\([0-9]*\)0\+\([0-9*+]*\)\+\([0-9]*\)\([0-9]\)=/{
- s//\1+\2+\3=\4/
- b add
-}
-/^\([0-9]*\)\([0-9]\)\+\([0-9*+]*\)\+\([0-9]*\)0=/{
- s//\1+\3+\4=\2/
- b add
-}
-s/^\([0-9]*\)1\+/\10+/
-s/^\([0-9]*\)2\+/\11+/
-s/^\([0-9]*\)3\+/\12+/
-s/^\([0-9]*\)4\+/\13+/
-s/^\([0-9]*\)5\+/\14+/
-s/^\([0-9]*\)6\+/\15+/
-s/^\([0-9]*\)7\+/\16+/
-s/^\([0-9]*\)8\+/\17+/
-s/^\([0-9]*\)9\+/\18+/
-
-s/9=\([0-9]*\)$/_=\1/
-s/8=\([0-9]*\)$/9=\1/
-s/7=\([0-9]*\)$/8=\1/
-s/6=\([0-9]*\)$/7=\1/
-s/5=\([0-9]*\)$/6=\1/
-s/4=\([0-9]*\)$/5=\1/
-s/3=\([0-9]*\)$/4=\1/
-s/2=\([0-9]*\)$/3=\1/
-s/1=\([0-9]*\)$/2=\1/
-/_/{
- s//_0/
- : inc
- s/9_/_0/
- s/8_/9/
- s/7_/8/
- s/6_/7/
- s/5_/6/
- s/4_/5/
- s/3_/4/
- s/2_/3/
- s/1_/2/
- s/0_/1/
- s/\+_/+1/
- /_/b inc
-}
-b add
diff --git a/tools/regression/usr.bin/sed/multitest.t b/tools/regression/usr.bin/sed/multitest.t
deleted file mode 100644
index 71c7f20b52c5..000000000000
--- a/tools/regression/usr.bin/sed/multitest.t
+++ /dev/null
@@ -1,552 +0,0 @@
-#!/bin/sh -
-#
-# Copyright (c) 1992 Diomidis Spinellis.
-# 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. 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, Berkeley and its contributors.
-# 4. 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.
-#
-# @(#)sed.test 8.1 (Berkeley) 6/6/93
-#
-
-# sed Regression Tests
-#
-# The following files are created:
-# lines[1-4], script1, script2
-# Two directories *.out contain the test results
-
-main()
-{
- BASE=/usr/bin/sed
- BASELOG=sed.out
- TEST=`cd ..; make whereobj`/sed
- TESTLOG=nsed.out
- DICT=/usr/share/dict/words
-
- test_error | more
-
- awk 'END { for (i = 1; i < 15; i++) print "l1_" i}' </dev/null >lines1
- awk 'END { for (i = 1; i < 10; i++) print "l2_" i}' </dev/null >lines2
-
- exec 4>&1 5>&2
-
- # Set these flags to get messages about known problems
- BSD=1
- GNU=0
- SUN=0
- tests $BASE $BASELOG
-
- BSD=0
- GNU=0
- SUN=0
- tests $TEST $TESTLOG
- exec 1>&4 2>&5
- diff -c $BASELOG $TESTLOG | more
-}
-
-tests()
-{
- SED=$1
- DIR=$2
- rm -rf $DIR
- mkdir $DIR
- MARK=100
-
- test_args
- test_addr
- echo Testing commands
- test_group
- test_acid
- test_branch
- test_pattern
- test_print
- test_subst
-}
-
-mark()
-{
- MARK=`expr $MARK + 1`
- exec 1>&4 2>&5
- exec >"$DIR/${MARK}_$1"
- echo "Test $1:$MARK"
- # Uncomment this line to match tests with sed error messages
- echo "Test $1:$MARK" >&5
-}
-
-test_args()
-{
- mark '1.1'
- echo Testing argument parsing
- echo First type
- if [ $SUN -eq 1 ] ; then
- echo SunOS sed prints only with -n
- else
- $SED 's/^/e1_/p' lines1
- fi
- mark '1.2' ; $SED -n 's/^/e1_/p' lines1
- mark '1.3'
- if [ $SUN -eq 1 ] ; then
- echo SunOS sed prints only with -n
- else
- $SED 's/^/e1_/p' <lines1
- fi
- mark '1.4' ; $SED -n 's/^/e1_/p' <lines1
- echo Second type
- mark '1.4.1'
- if [ $SUN -eq 1 ] ; then
- echo SunOS sed fails this
- fi
- $SED -e '' <lines1
- echo 's/^/s1_/p' >script1
- echo 's/^/s2_/p' >script2
- mark '1.5'
- if [ $SUN -eq 1 ] ; then
- echo SunOS sed prints only with -n
- else
- $SED -f script1 lines1
- fi
- mark '1.6'
- if [ $SUN -eq 1 ] ; then
- echo SunOS sed prints only with -n
- else
- $SED -f script1 <lines1
- fi
- mark '1.7'
- if [ $SUN -eq 1 ] ; then
- echo SunOS sed prints only with -n
- else
- $SED -e 's/^/e1_/p' lines1
- fi
- mark '1.8'
- if [ $SUN -eq 1 ] ; then
- echo SunOS sed prints only with -n
- else
- $SED -e 's/^/e1_/p' <lines1
- fi
- mark '1.9' ; $SED -n -f script1 lines1
- mark '1.10' ; $SED -n -f script1 <lines1
- mark '1.11' ; $SED -n -e 's/^/e1_/p' lines1
- mark '1.12'
- if [ $SUN -eq 1 ] ; then
- echo SunOS sed prints only with -n
- else
- $SED -n -e 's/^/e1_/p' <lines1
- fi
- mark '1.13'
- if [ $SUN -eq 1 ] ; then
- echo SunOS sed prints only with -n
- else
- $SED -e 's/^/e1_/p' -e 's/^/e2_/p' lines1
- fi
- mark '1.14'
- if [ $SUN -eq 1 ] ; then
- echo SunOS sed prints only with -n
- else
- $SED -f script1 -f script2 lines1
- fi
- mark '1.15'
- if [ $GNU -eq 1 -o $SUN -eq 1 ] ; then
- echo GNU and SunOS sed fail this following older POSIX draft
- else
- $SED -e 's/^/e1_/p' -f script1 lines1
- fi
- mark '1.16'
- if [ $SUN -eq 1 ] ; then
- echo SunOS sed prints only with -n
- else
- $SED -e 's/^/e1_/p' lines1 lines1
- fi
- # POSIX D11.2:11251
- mark '1.17' ; $SED p <lines1 lines1
-cat >script1 <<EOF
-#n
-# A comment
-
-p
-EOF
- mark '1.18' ; $SED -f script1 <lines1 lines1
-}
-
-test_addr()
-{
- echo Testing address ranges
- mark '2.1' ; $SED -n -e '4p' lines1
- mark '2.2' ; $SED -n -e '20p' lines1 lines2
- mark '2.3' ; $SED -n -e '$p' lines1
- mark '2.4' ; $SED -n -e '$p' lines1 lines2
- mark '2.5' ; $SED -n -e '$a\
-hello' /dev/null
- mark '2.6' ; $SED -n -e '$p' lines1 /dev/null lines2
- # Should not print anything
- mark '2.7' ; $SED -n -e '20p' lines1
- mark '2.8' ; $SED -n -e '0p' lines1
- mark '2.9' ; $SED -n '/l1_7/p' lines1
- mark '2.10' ; $SED -n ' /l1_7/ p' lines1
- mark '2.11'
- if [ $BSD -eq 1 ] ; then
- echo BSD sed fails this test
- fi
- if [ $GNU -eq 1 ] ; then
- echo GNU sed fails this
- fi
- $SED -n '\_l1\_7_p' lines1
- mark '2.12' ; $SED -n '1,4p' lines1
- mark '2.13' ; $SED -n '1,$p' lines1 lines2
- mark '2.14' ; $SED -n '1,/l2_9/p' lines1 lines2
- mark '2.15' ; $SED -n '/4/,$p' lines1 lines2
- mark '2.16' ; $SED -n '/4/,20p' lines1 lines2
- mark '2.17' ; $SED -n '/4/,/10/p' lines1 lines2
- mark '2.18' ; $SED -n '/l2_3/,/l1_8/p' lines1 lines2
- mark '2.19'
- if [ $GNU -eq 1 ] ; then
- echo GNU sed fails this
- fi
- $SED -n '12,3p' lines1 lines2
- mark '2.20'
- if [ $GNU -eq 1 ] ; then
- echo GNU sed fails this
- fi
- $SED -n '/l1_7/,3p' lines1 lines2
-}
-
-test_group()
-{
- echo Brace and other grouping
- mark '3.1' ; $SED -e '
-4,12 {
- s/^/^/
- s/$/$/
- s/_/T/
-}' lines1
- mark '3.2' ; $SED -e '
-4,12 {
- s/^/^/
- /6/,/10/ {
- s/$/$/
- /8/ s/_/T/
- }
-}' lines1
- mark '3.3' ; $SED -e '
-4,12 !{
- s/^/^/
- /6/,/10/ !{
- s/$/$/
- /8/ !s/_/T/
- }
-}' lines1
- mark '3.4' ; $SED -e '4,12!s/^/^/' lines1
-}
-
-test_acid()
-{
- echo Testing a c d and i commands
- mark '4.1' ; $SED -n -e '
-s/^/before_i/p
-20i\
-inserted
-s/^/after_i/p
-' lines1 lines2
- mark '4.2' ; $SED -n -e '
-5,12s/^/5-12/
-s/^/before_a/p
-/5-12/a\
-appended
-s/^/after_a/p
-' lines1 lines2
- mark '4.3'
- if [ $GNU -eq 1 ] ; then
- echo GNU sed fails this
- fi
- $SED -n -e '
-s/^/^/p
-/l1_/a\
-appended
-8,10N
-s/$/$/p
-' lines1 lines2
- mark '4.4' ; $SED -n -e '
-c\
-hello
-' lines1
- mark '4.5' ; $SED -n -e '
-8c\
-hello
-' lines1
- mark '4.6' ; $SED -n -e '
-3,14c\
-hello
-' lines1
-# SunOS and GNU sed behave differently. We follow POSIX
-# mark '4.7' ; $SED -n -e '
-#8,3c\
-#hello
-#' lines1
- mark '4.8' ; $SED d <lines1
-}
-
-test_branch()
-{
- echo Testing labels and branching
- mark '5.1' ; $SED -n -e '
-b label4
-:label3
-s/^/label3_/p
-b end
-:label4
-2,12b label1
-b label2
-:label1
-s/^/label1_/p
-b
-:label2
-s/^/label2_/p
-b label3
-:end
-' lines1
- mark '5.2'
- if [ $BSD -eq 1 ] ; then
- echo BSD sed fails this test
- fi
- $SED -n -e '
-s/l1_/l2_/
-t ok
-b
-:ok
-s/^/tested /p
-' lines1 lines2
-# SunOS sed behaves differently here. Clarification needed.
-# mark '5.3' ; $SED -n -e '
-#5,8b inside
-#1,5 {
-# s/^/^/p
-# :inside
-# s/$/$/p
-#}
-#' lines1
-# Check that t clears the substitution done flag
- mark '5.4' ; $SED -n -e '
-1,8s/^/^/
-t l1
-:l1
-t l2
-s/$/$/p
-b
-:l2
-s/^/ERROR/
-' lines1
-# Check that reading a line clears the substitution done flag
- mark '5.5'
- if [ $BSD -eq 1 ] ; then
- echo BSD sed fails this test
- fi
- $SED -n -e '
-t l2
-1,8s/^/^/p
-2,7N
-b
-:l2
-s/^/ERROR/p
-' lines1
- mark '5.6' ; $SED 5q lines1
- mark '5.7' ; $SED -e '
-5i\
-hello
-5q' lines1
-# Branch across block boundary
- mark '5.8' ; $SED -e '
-{
-:b
-}
-s/l/m/
-tb' lines1
-}
-
-test_pattern()
-{
-echo Pattern space commands
-# Check that the pattern space is deleted
- mark '6.1' ; $SED -n -e '
-c\
-changed
-p
-' lines1
- mark '6.2' ; $SED -n -e '
-4d
-p
-' lines1
-# SunOS sed refused to print here
-# mark '6.3' ; $SED -e '
-#N
-#N
-#N
-#D
-#P
-#4p
-#' lines1
- mark '6.4' ; $SED -e '
-2h
-3H
-4g
-5G
-6x
-6p
-6x
-6p
-' lines1
- mark '6.5' ; $SED -e '4n' lines1
- mark '6.6' ; $SED -n -e '4n' lines1
-}
-
-test_print()
-{
- echo Testing print and file routines
- awk 'END {for (i = 1; i < 256; i++) printf("%c", i);print "\n"}' \
- </dev/null >lines3
- # GNU and SunOS sed behave differently here
- mark '7.1'
- if [ $BSD -eq 1 ] ; then
- echo 'BSD sed drops core on this one; TEST SKIPPED'
- else
- $SED -n l lines3
- fi
- mark '7.2' ; $SED -e '/l2_/=' lines1 lines2
- rm -f lines4
- mark '7.3' ; $SED -e '3,12w lines4' lines1
- echo w results
- cat lines4
- mark '7.4' ; $SED -e '4r lines2' lines1
- mark '7.5' ; $SED -e '5r /dev/dds' lines1
- mark '7.6' ; $SED -e '6r /dev/null' lines1
- mark '7.7'
- if [ $BSD -eq 1 -o $GNU -eq 1 -o $SUN -eq 1 ] ; then
- echo BSD, GNU and SunOS cannot pass this one
- else
- sed '200q' $DICT | sed 's$.*$s/^/&/w tmpdir/&$' >script1
- rm -rf tmpdir
- mkdir tmpdir
- $SED -f script1 lines1
- cat tmpdir/*
- rm -rf tmpdir
- fi
- mark '7.8'
- if [ $BSD -eq 1 ] ; then
- echo BSD sed cannot pass 7.7
- else
- echo line1 > lines3
- echo "" >> lines3
- $SED -n -e '$p' lines3 /dev/null
- fi
-
-}
-
-test_subst()
-{
- echo Testing substitution commands
- mark '8.1' ; $SED -e 's/./X/g' lines1
- mark '8.2' ; $SED -e 's,.,X,g' lines1
-# GNU and SunOS sed thinks we are escaping . as wildcard, not as separator
-# mark '8.3' ; $SED -e 's.\..X.g' lines1
-# POSIX does not say that this should work
-# mark '8.4' ; $SED -e 's/[/]/Q/' lines1
- mark '8.4' ; $SED -e 's/[\/]/Q/' lines1
- mark '8.5' ; $SED -e 's_\__X_' lines1
- mark '8.6' ; $SED -e 's/./(&)/g' lines1
- mark '8.7' ; $SED -e 's/./(\&)/g' lines1
- mark '8.8' ; $SED -e 's/\(.\)\(.\)\(.\)/x\3x\2x\1/g' lines1
- mark '8.9' ; $SED -e 's/_/u0\
-u1\
-u2/g' lines1
- mark '8.10'
- if [ $BSD -eq 1 -o $GNU -eq 1 ] ; then
- echo 'BSD/GNU sed do not understand digit flags on s commands'
- fi
- $SED -e 's/./X/4' lines1
- rm -f lines4
- mark '8.11' ; $SED -e 's/1/X/w lines4' lines1
- echo s wfile results
- cat lines4
- mark '8.12' ; $SED -e 's/[123]/X/g' lines1
- mark '8.13' ; $SED -e 'y/0123456789/9876543210/' lines1
- mark '8.14' ;
- if [ $BSD -eq 1 -o $GNU -eq 1 -o $SUN -eq 1 ] ; then
- echo BSD/GNU/SUN sed fail this test
- else
- $SED -e 'y10\123456789198765432\101' lines1
- fi
- mark '8.15' ; $SED -e '1N;2y/\n/X/' lines1
- mark '8.16'
- if [ $BSD -eq 1 ] ; then
- echo 'BSD sed does not handle branch defined REs'
- else
- echo 'eeefff' | $SED -e 'p' -e 's/e/X/p' -e ':x' \
- -e 's//Y/p' -e '/f/bx'
- fi
-}
-
-test_error()
-{
- exec 0>&3 4>&1 5>&2
- exec 0</dev/null
- exec 2>&1
- set -x
- $TEST -x && exit 1
- $TEST -f && exit 1
- $TEST -e && exit 1
- $TEST -f /dev/dds && exit 1
- $TEST p /dev/dds && exit 1
- $TEST -f /bin/sh && exit 1
- $TEST '{' && exit 1
- $TEST '{' && exit 1
- $TEST '/hello/' && exit 1
- $TEST '1,/hello/' && exit 1
- $TEST -e '-5p' && exit 1
- $TEST '/jj' && exit 1
- $TEST 'a hello' && exit 1
- $TEST 'a \ hello' && exit 1
- $TEST 'b foo' && exit 1
- $TEST 'd hello' && exit 1
- $TEST 's/aa' && exit 1
- $TEST 's/aa/' && exit 1
- $TEST 's/a/b' && exit 1
- $TEST 's/a/b/c/d' && exit 1
- $TEST 's/a/b/ 1 2' && exit 1
- $TEST 's/a/b/ 1 g' && exit 1
- $TEST 's/a/b/w' && exit 1
- $TEST 'y/aa' && exit 1
- $TEST 'y/aa/b/' && exit 1
- $TEST 'y/aa/' && exit 1
- $TEST 'y/a/b' && exit 1
- $TEST 'y/a/b/c/d' && exit 1
- $TEST '!' && exit 1
- $TEST supercalifrangolisticexprialidociussupercalifrangolisticexcius
- set +x
- exec 0>&3 1>&4 2>&5
-}
-
-main
diff --git a/tools/regression/usr.bin/sed/sed.test b/tools/regression/usr.bin/sed/sed.test
deleted file mode 100644
index 71c7f20b52c5..000000000000
--- a/tools/regression/usr.bin/sed/sed.test
+++ /dev/null
@@ -1,552 +0,0 @@
-#!/bin/sh -
-#
-# Copyright (c) 1992 Diomidis Spinellis.
-# 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. 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, Berkeley and its contributors.
-# 4. 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.
-#
-# @(#)sed.test 8.1 (Berkeley) 6/6/93
-#
-
-# sed Regression Tests
-#
-# The following files are created:
-# lines[1-4], script1, script2
-# Two directories *.out contain the test results
-
-main()
-{
- BASE=/usr/bin/sed
- BASELOG=sed.out
- TEST=`cd ..; make whereobj`/sed
- TESTLOG=nsed.out
- DICT=/usr/share/dict/words
-
- test_error | more
-
- awk 'END { for (i = 1; i < 15; i++) print "l1_" i}' </dev/null >lines1
- awk 'END { for (i = 1; i < 10; i++) print "l2_" i}' </dev/null >lines2
-
- exec 4>&1 5>&2
-
- # Set these flags to get messages about known problems
- BSD=1
- GNU=0
- SUN=0
- tests $BASE $BASELOG
-
- BSD=0
- GNU=0
- SUN=0
- tests $TEST $TESTLOG
- exec 1>&4 2>&5
- diff -c $BASELOG $TESTLOG | more
-}
-
-tests()
-{
- SED=$1
- DIR=$2
- rm -rf $DIR
- mkdir $DIR
- MARK=100
-
- test_args
- test_addr
- echo Testing commands
- test_group
- test_acid
- test_branch
- test_pattern
- test_print
- test_subst
-}
-
-mark()
-{
- MARK=`expr $MARK + 1`
- exec 1>&4 2>&5
- exec >"$DIR/${MARK}_$1"
- echo "Test $1:$MARK"
- # Uncomment this line to match tests with sed error messages
- echo "Test $1:$MARK" >&5
-}
-
-test_args()
-{
- mark '1.1'
- echo Testing argument parsing
- echo First type
- if [ $SUN -eq 1 ] ; then
- echo SunOS sed prints only with -n
- else
- $SED 's/^/e1_/p' lines1
- fi
- mark '1.2' ; $SED -n 's/^/e1_/p' lines1
- mark '1.3'
- if [ $SUN -eq 1 ] ; then
- echo SunOS sed prints only with -n
- else
- $SED 's/^/e1_/p' <lines1
- fi
- mark '1.4' ; $SED -n 's/^/e1_/p' <lines1
- echo Second type
- mark '1.4.1'
- if [ $SUN -eq 1 ] ; then
- echo SunOS sed fails this
- fi
- $SED -e '' <lines1
- echo 's/^/s1_/p' >script1
- echo 's/^/s2_/p' >script2
- mark '1.5'
- if [ $SUN -eq 1 ] ; then
- echo SunOS sed prints only with -n
- else
- $SED -f script1 lines1
- fi
- mark '1.6'
- if [ $SUN -eq 1 ] ; then
- echo SunOS sed prints only with -n
- else
- $SED -f script1 <lines1
- fi
- mark '1.7'
- if [ $SUN -eq 1 ] ; then
- echo SunOS sed prints only with -n
- else
- $SED -e 's/^/e1_/p' lines1
- fi
- mark '1.8'
- if [ $SUN -eq 1 ] ; then
- echo SunOS sed prints only with -n
- else
- $SED -e 's/^/e1_/p' <lines1
- fi
- mark '1.9' ; $SED -n -f script1 lines1
- mark '1.10' ; $SED -n -f script1 <lines1
- mark '1.11' ; $SED -n -e 's/^/e1_/p' lines1
- mark '1.12'
- if [ $SUN -eq 1 ] ; then
- echo SunOS sed prints only with -n
- else
- $SED -n -e 's/^/e1_/p' <lines1
- fi
- mark '1.13'
- if [ $SUN -eq 1 ] ; then
- echo SunOS sed prints only with -n
- else
- $SED -e 's/^/e1_/p' -e 's/^/e2_/p' lines1
- fi
- mark '1.14'
- if [ $SUN -eq 1 ] ; then
- echo SunOS sed prints only with -n
- else
- $SED -f script1 -f script2 lines1
- fi
- mark '1.15'
- if [ $GNU -eq 1 -o $SUN -eq 1 ] ; then
- echo GNU and SunOS sed fail this following older POSIX draft
- else
- $SED -e 's/^/e1_/p' -f script1 lines1
- fi
- mark '1.16'
- if [ $SUN -eq 1 ] ; then
- echo SunOS sed prints only with -n
- else
- $SED -e 's/^/e1_/p' lines1 lines1
- fi
- # POSIX D11.2:11251
- mark '1.17' ; $SED p <lines1 lines1
-cat >script1 <<EOF
-#n
-# A comment
-
-p
-EOF
- mark '1.18' ; $SED -f script1 <lines1 lines1
-}
-
-test_addr()
-{
- echo Testing address ranges
- mark '2.1' ; $SED -n -e '4p' lines1
- mark '2.2' ; $SED -n -e '20p' lines1 lines2
- mark '2.3' ; $SED -n -e '$p' lines1
- mark '2.4' ; $SED -n -e '$p' lines1 lines2
- mark '2.5' ; $SED -n -e '$a\
-hello' /dev/null
- mark '2.6' ; $SED -n -e '$p' lines1 /dev/null lines2
- # Should not print anything
- mark '2.7' ; $SED -n -e '20p' lines1
- mark '2.8' ; $SED -n -e '0p' lines1
- mark '2.9' ; $SED -n '/l1_7/p' lines1
- mark '2.10' ; $SED -n ' /l1_7/ p' lines1
- mark '2.11'
- if [ $BSD -eq 1 ] ; then
- echo BSD sed fails this test
- fi
- if [ $GNU -eq 1 ] ; then
- echo GNU sed fails this
- fi
- $SED -n '\_l1\_7_p' lines1
- mark '2.12' ; $SED -n '1,4p' lines1
- mark '2.13' ; $SED -n '1,$p' lines1 lines2
- mark '2.14' ; $SED -n '1,/l2_9/p' lines1 lines2
- mark '2.15' ; $SED -n '/4/,$p' lines1 lines2
- mark '2.16' ; $SED -n '/4/,20p' lines1 lines2
- mark '2.17' ; $SED -n '/4/,/10/p' lines1 lines2
- mark '2.18' ; $SED -n '/l2_3/,/l1_8/p' lines1 lines2
- mark '2.19'
- if [ $GNU -eq 1 ] ; then
- echo GNU sed fails this
- fi
- $SED -n '12,3p' lines1 lines2
- mark '2.20'
- if [ $GNU -eq 1 ] ; then
- echo GNU sed fails this
- fi
- $SED -n '/l1_7/,3p' lines1 lines2
-}
-
-test_group()
-{
- echo Brace and other grouping
- mark '3.1' ; $SED -e '
-4,12 {
- s/^/^/
- s/$/$/
- s/_/T/
-}' lines1
- mark '3.2' ; $SED -e '
-4,12 {
- s/^/^/
- /6/,/10/ {
- s/$/$/
- /8/ s/_/T/
- }
-}' lines1
- mark '3.3' ; $SED -e '
-4,12 !{
- s/^/^/
- /6/,/10/ !{
- s/$/$/
- /8/ !s/_/T/
- }
-}' lines1
- mark '3.4' ; $SED -e '4,12!s/^/^/' lines1
-}
-
-test_acid()
-{
- echo Testing a c d and i commands
- mark '4.1' ; $SED -n -e '
-s/^/before_i/p
-20i\
-inserted
-s/^/after_i/p
-' lines1 lines2
- mark '4.2' ; $SED -n -e '
-5,12s/^/5-12/
-s/^/before_a/p
-/5-12/a\
-appended
-s/^/after_a/p
-' lines1 lines2
- mark '4.3'
- if [ $GNU -eq 1 ] ; then
- echo GNU sed fails this
- fi
- $SED -n -e '
-s/^/^/p
-/l1_/a\
-appended
-8,10N
-s/$/$/p
-' lines1 lines2
- mark '4.4' ; $SED -n -e '
-c\
-hello
-' lines1
- mark '4.5' ; $SED -n -e '
-8c\
-hello
-' lines1
- mark '4.6' ; $SED -n -e '
-3,14c\
-hello
-' lines1
-# SunOS and GNU sed behave differently. We follow POSIX
-# mark '4.7' ; $SED -n -e '
-#8,3c\
-#hello
-#' lines1
- mark '4.8' ; $SED d <lines1
-}
-
-test_branch()
-{
- echo Testing labels and branching
- mark '5.1' ; $SED -n -e '
-b label4
-:label3
-s/^/label3_/p
-b end
-:label4
-2,12b label1
-b label2
-:label1
-s/^/label1_/p
-b
-:label2
-s/^/label2_/p
-b label3
-:end
-' lines1
- mark '5.2'
- if [ $BSD -eq 1 ] ; then
- echo BSD sed fails this test
- fi
- $SED -n -e '
-s/l1_/l2_/
-t ok
-b
-:ok
-s/^/tested /p
-' lines1 lines2
-# SunOS sed behaves differently here. Clarification needed.
-# mark '5.3' ; $SED -n -e '
-#5,8b inside
-#1,5 {
-# s/^/^/p
-# :inside
-# s/$/$/p
-#}
-#' lines1
-# Check that t clears the substitution done flag
- mark '5.4' ; $SED -n -e '
-1,8s/^/^/
-t l1
-:l1
-t l2
-s/$/$/p
-b
-:l2
-s/^/ERROR/
-' lines1
-# Check that reading a line clears the substitution done flag
- mark '5.5'
- if [ $BSD -eq 1 ] ; then
- echo BSD sed fails this test
- fi
- $SED -n -e '
-t l2
-1,8s/^/^/p
-2,7N
-b
-:l2
-s/^/ERROR/p
-' lines1
- mark '5.6' ; $SED 5q lines1
- mark '5.7' ; $SED -e '
-5i\
-hello
-5q' lines1
-# Branch across block boundary
- mark '5.8' ; $SED -e '
-{
-:b
-}
-s/l/m/
-tb' lines1
-}
-
-test_pattern()
-{
-echo Pattern space commands
-# Check that the pattern space is deleted
- mark '6.1' ; $SED -n -e '
-c\
-changed
-p
-' lines1
- mark '6.2' ; $SED -n -e '
-4d
-p
-' lines1
-# SunOS sed refused to print here
-# mark '6.3' ; $SED -e '
-#N
-#N
-#N
-#D
-#P
-#4p
-#' lines1
- mark '6.4' ; $SED -e '
-2h
-3H
-4g
-5G
-6x
-6p
-6x
-6p
-' lines1
- mark '6.5' ; $SED -e '4n' lines1
- mark '6.6' ; $SED -n -e '4n' lines1
-}
-
-test_print()
-{
- echo Testing print and file routines
- awk 'END {for (i = 1; i < 256; i++) printf("%c", i);print "\n"}' \
- </dev/null >lines3
- # GNU and SunOS sed behave differently here
- mark '7.1'
- if [ $BSD -eq 1 ] ; then
- echo 'BSD sed drops core on this one; TEST SKIPPED'
- else
- $SED -n l lines3
- fi
- mark '7.2' ; $SED -e '/l2_/=' lines1 lines2
- rm -f lines4
- mark '7.3' ; $SED -e '3,12w lines4' lines1
- echo w results
- cat lines4
- mark '7.4' ; $SED -e '4r lines2' lines1
- mark '7.5' ; $SED -e '5r /dev/dds' lines1
- mark '7.6' ; $SED -e '6r /dev/null' lines1
- mark '7.7'
- if [ $BSD -eq 1 -o $GNU -eq 1 -o $SUN -eq 1 ] ; then
- echo BSD, GNU and SunOS cannot pass this one
- else
- sed '200q' $DICT | sed 's$.*$s/^/&/w tmpdir/&$' >script1
- rm -rf tmpdir
- mkdir tmpdir
- $SED -f script1 lines1
- cat tmpdir/*
- rm -rf tmpdir
- fi
- mark '7.8'
- if [ $BSD -eq 1 ] ; then
- echo BSD sed cannot pass 7.7
- else
- echo line1 > lines3
- echo "" >> lines3
- $SED -n -e '$p' lines3 /dev/null
- fi
-
-}
-
-test_subst()
-{
- echo Testing substitution commands
- mark '8.1' ; $SED -e 's/./X/g' lines1
- mark '8.2' ; $SED -e 's,.,X,g' lines1
-# GNU and SunOS sed thinks we are escaping . as wildcard, not as separator
-# mark '8.3' ; $SED -e 's.\..X.g' lines1
-# POSIX does not say that this should work
-# mark '8.4' ; $SED -e 's/[/]/Q/' lines1
- mark '8.4' ; $SED -e 's/[\/]/Q/' lines1
- mark '8.5' ; $SED -e 's_\__X_' lines1
- mark '8.6' ; $SED -e 's/./(&)/g' lines1
- mark '8.7' ; $SED -e 's/./(\&)/g' lines1
- mark '8.8' ; $SED -e 's/\(.\)\(.\)\(.\)/x\3x\2x\1/g' lines1
- mark '8.9' ; $SED -e 's/_/u0\
-u1\
-u2/g' lines1
- mark '8.10'
- if [ $BSD -eq 1 -o $GNU -eq 1 ] ; then
- echo 'BSD/GNU sed do not understand digit flags on s commands'
- fi
- $SED -e 's/./X/4' lines1
- rm -f lines4
- mark '8.11' ; $SED -e 's/1/X/w lines4' lines1
- echo s wfile results
- cat lines4
- mark '8.12' ; $SED -e 's/[123]/X/g' lines1
- mark '8.13' ; $SED -e 'y/0123456789/9876543210/' lines1
- mark '8.14' ;
- if [ $BSD -eq 1 -o $GNU -eq 1 -o $SUN -eq 1 ] ; then
- echo BSD/GNU/SUN sed fail this test
- else
- $SED -e 'y10\123456789198765432\101' lines1
- fi
- mark '8.15' ; $SED -e '1N;2y/\n/X/' lines1
- mark '8.16'
- if [ $BSD -eq 1 ] ; then
- echo 'BSD sed does not handle branch defined REs'
- else
- echo 'eeefff' | $SED -e 'p' -e 's/e/X/p' -e ':x' \
- -e 's//Y/p' -e '/f/bx'
- fi
-}
-
-test_error()
-{
- exec 0>&3 4>&1 5>&2
- exec 0</dev/null
- exec 2>&1
- set -x
- $TEST -x && exit 1
- $TEST -f && exit 1
- $TEST -e && exit 1
- $TEST -f /dev/dds && exit 1
- $TEST p /dev/dds && exit 1
- $TEST -f /bin/sh && exit 1
- $TEST '{' && exit 1
- $TEST '{' && exit 1
- $TEST '/hello/' && exit 1
- $TEST '1,/hello/' && exit 1
- $TEST -e '-5p' && exit 1
- $TEST '/jj' && exit 1
- $TEST 'a hello' && exit 1
- $TEST 'a \ hello' && exit 1
- $TEST 'b foo' && exit 1
- $TEST 'd hello' && exit 1
- $TEST 's/aa' && exit 1
- $TEST 's/aa/' && exit 1
- $TEST 's/a/b' && exit 1
- $TEST 's/a/b/c/d' && exit 1
- $TEST 's/a/b/ 1 2' && exit 1
- $TEST 's/a/b/ 1 g' && exit 1
- $TEST 's/a/b/w' && exit 1
- $TEST 'y/aa' && exit 1
- $TEST 'y/aa/b/' && exit 1
- $TEST 'y/aa/' && exit 1
- $TEST 'y/a/b' && exit 1
- $TEST 'y/a/b/c/d' && exit 1
- $TEST '!' && exit 1
- $TEST supercalifrangolisticexprialidociussupercalifrangolisticexcius
- set +x
- exec 0>&3 1>&4 2>&5
-}
-
-main
diff --git a/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.all b/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.all
deleted file mode 100644
index 92c0e51ff73e..000000000000
--- a/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.all
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * deutscher Kalender
- *
- * $FreeBSD$
- */
-
-#ifndef _de_DE_ISO_8859_1_all_
-#define _de_DE_ISO_8859_1_all_
-
-#include <de_DE.ISO_8859-1/calendar.feiertag>
-#include <de_DE.ISO_8859-1/calendar.geschichte>
-#include <de_DE.ISO_8859-1/calendar.kirche>
-#include <de_DE.ISO_8859-1/calendar.literatur>
-#include <de_DE.ISO_8859-1/calendar.musik>
-#include <de_DE.ISO_8859-1/calendar.wissenschaft>
-
-#endif /* !_de_DE.ISO_8859-1_all_ */
diff --git a/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.feiertag b/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.feiertag
deleted file mode 100644
index 4969fc7b7d2d..000000000000
--- a/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.feiertag
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Feiertage
- *
- * $FreeBSD$
- */
-
-#ifndef _de_DE_ISO_8859_1_feiertag_
-#define _de_DE_ISO_8859_1_feiertag_
-
-LANG=de_DE.ISO_8859-1
-
-/* arbeitsfreie staatliche Feiertage */
-01/01 Neujahr
-05/01 Maifeiertag
-10/03 Tag der deutschen Einheit
-
-/* arbeitsfreie christliche Feiertage */
-Easter-2 Karfreitag
-Easter Ostersonntag
-Easter+1 Ostermontag
-Easter+49 Pfingstsonntag
-Easter+50 Pfingstmontag
-Easter+39 Christi Himmelfahrt
-
-/* Gedenktage - nicht arbeitsfreie Feiertage :-( */
-06/17 Arbeiteraufstand am 17. Juni 1953
-/* ??/?? Befreiung des KZs Auschwitz */
-
-/* Jahreszeiten */
-03/21* Frühlingsanfang
-06/21* Sommeranfang
-09/21* Herbstanfang
-12/21* Winteranfang
-
-/* Sommer- und Winterzeit */
-03/SundayLast Anfang der Sommerzeit
-10/SundayLast Ende der Sommerzeit
-
-/* Blumenverkäufer */
-May Sun+2 Muttertag
-
-#endif /*! _de_DE_ISO_8859_1_feiertag_ */
diff --git a/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.geschichte b/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.geschichte
deleted file mode 100644
index 24d51f61fe57..000000000000
--- a/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.geschichte
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * deutsche Geschichte
- *
- *
- * Die Angaben wurden überwiegend entnommen aus dem Buch:
- *
- * Fragen an die deutsch Geschichte, Ideen, Kräfte, Entscheidungen von
- * 1800 bis zur Gegenwart; historische Ausstellung im Reichstagsgebäude
- * in Berlin; Katalog, 16. Auflage, Sonderausgabe - Bonn: Deutscher
- * Bundestag, Referat Öffentlichkeitsarbeit, 1990
- *
- * English Title: Question on German history
- *
- * ISBN 3-924521-59-X
- *
- * $FreeBSD$
- */
-
-#ifndef _de_DE_ISO_8859_1_geschichte_
-#define _de_DE_ISO_8859_1_geschichte_
-
-LANG=de_DE.ISO_8859-1
-
-/* 1800-1933 */
-07/11 Gründung der Rheinbundes, 1806
-10/14 Doppelschlacht bei Jena und Auerstedt, 1806
-10/16 Völkerschlacht bei Leipzig, 1813
-06/18 Niederlage Napoleons bei Waterloo, 1815
-10/18 Wartburgfest der Deutschen Burschenschaften, 1817
-01/01 Inkrafttreten des Vertrages über den deutschen. Zollverein, 1834
-12/07 erste deutsche Eisenbahn zwischen Nürnberg und Fürth, 1835
-06 Aufstand der schlesischen Weber, 1844
-12/21 Verabschiedung des Gesetzes über die Grundrechte des deutschen
- Volkes durch die Frankfurter Nationalversammlung, 1848
-03/27 Annahme der deutschen Reichsverfassung in der Frankfurter
- Paulskirche, Wahl von Friedrich Wilhelm IV von Preußen zum
- deutschen Kaiser, 1849
-04/28 Ablehnung der deutschen Kaiserkrone durch den preußichen König, 1849
-07/03 Schlacht von Königgrätz
-07/13 Emser Depesche, 1870
-07/18 Verkündung des Dogmas von der päpstlichen Unfehlbarkeit
- durch das I. Vatikanische Konzil
-01/18 Proklamation des deutschen Kaiserreiches in Versailles, 1871
-10/18 Verabschiedung des Sozialistengesetzes durch den Reichstag, 1878
-03/20 Entlassung von Bismarck als Reichskanzler und
- preußischer Ministerpräsident, 1890
-06/21 Eröffnung des Nord-Ostsee-Kanals, 1895
-01/07 Billigung des Bürgerlichen Gesetzbuches (BGB) durch den Reichstag, 1896
-01/01 Bürgerliches Gesetzbuches tritt in Kraft, 1900
-06/28 Ermordung des österreichischen Thronfolgers Erzherzog Franz
- Ferdinand durch serbische Nationalisten in Sarajewo, 1914
-07/28 Kriegserklärung Österreich-Ungarns an Serbien, 1914
-08/01 Deutsche Mobilmachung und Kriegserklärung an Rußland, 1914
-08/03 Deutsche Kriegserklärung an Frankreich, 1914
-08/04 Kriegserklärung Großbritaniens an Deutschland, 1914
-08/04 Bewilligung der Kriegskredite im Reichstag, 1914
-08/26 Schlacht bei Tannenberg, 1914
-02/21 Schlacht um Verdun, 1916
-03/08 Ausbruch der Revolution in Rußland, Abdankung von Zar Nikolaus II, 1917
-04/06 Kriegserklärung der USA an Deutschland
-12/15 Waffenstillstand zwisch Rußland und Deutschland, 1917
-03/03 Frieden von Brest-Litowsk, 1918
-11/03 Matrosenaufstand in Kiel, 1918
-11/09 Ausrufung der Republik durch Scheidemann (SPD), 1918
-02/11 Friedrich Ebert wird Reichspräsident, Weimar 1919
-06/28 Unterzeichnung des Versailler Vertrages, 1919
-03/21 Volksabstimmung in Oberschlesien, 1921
-04/16 Vertrag von Rapallo, 1922
-06/24 Ermordung von Reichsaußenminister Rathenau, 1922
-01/11 Besetzung des Ruhrgebietes durch Frankreich+Belgien, 1923
-09/10 Eintritt Deutschlands in den Völkerbund, 1926
-10/25 Schwarzer Freitag in New York, Beginn der Weltwirtschaftskrise, 1929
-
-
-/* II. Weltkrieg */
-10/14 Austritt auf dem Völkerbund, 1933
-03/16 Wiedereinführung der allgemeinen Wehrpflicht, 1935
-10/25 Deutsch-italienischer Vertrag, Achse Berlin-Rom, 1936
-11/25 Antikominternpakt zwischen Deutschland und Japan, 1936
-01/13 Volksabstimmung im Saargebiet über die Rückführung ins Reich, 1935
-03/12 Einmarsch deutscher Truppen in Österreich, 1938
-09/29 Münchner Abkommen, 1938
-03/15 Einmarsch deutscher Truppen in die Tschechoslowakei, 1939
-03/23 Rückgabe des Memelgebietes an Deutschland, 1939
-08/23 Abschluß des Hitler-Stalin-Paktes, 1939
-09/03 Kriegserklärung Großbritaniens und Frankreichs an Deutschland, 1939
-04/09 Besetzung Dänemarks, Invasion in Norwegen, 1940
-05/10 Deutscher Angriff auf Belgien, die Niederlande, Luxemburg
- und Frankreich, 1940
-06/22 Angriff gegen die Sowjetunion, 1941
-12/11 Kriegserklärung Deutschlands an die USA, 1941
-01/14 Konferenz von Casablanca, 1943
-01/31 Kapitulation der 6. deutschen Armee in Stalingrad, 1943
-06/06 Alliierte Landung in Nordwestfrankreich, 1944
-02/04 Konferenz von Jalta, 4.-11.2. 1945
-04/25 Zusammentreffen von amerikanischen und sowjetischer Truppen
- bei Torgau an der Elbe, 1945
-05/08 Bedingungslose Kapitulation von Deutschland, 1945
-07/01 Rückzug der britischen und amerikanischen Truppen aus
- Sachsen, Thüringen und Mecklenburg, Einmarsch westlicher
- Truppen in Berlin, 1945
-07/17 Potsdammer Konferenz, 1945
-09/01 Überfall auf Polen, Beginn des 2. Weltkrieges, 1939
-10/01 Verkündigung der Urteile im Nürnberger
- Hauptkriegsverbrecherprozeß, 1946
-02/25 Auflösung der Landes Preußen durch den Kontrollrat, 1947
-08/06 erster Atombombenabwurf auf Hiroshima, 1945
-08/08 Atombombenabwurf auf Nagasaki, 1945
-04/19 Warschauer Ghetto Aufstand, 1943
-12/07 Japan bombardiert Pearl Harbor, 1941
-
-/* Deutschland nach dem 2. Weltkrieg */
-04/11 Attentat auf Dutschke, Studentenunruhen, 1958
-04/26 GAU in Tschernobyl
-05/05 Natobeitritt, Wiederbewaffnung, Souveränität der Bundesrepublik, 1955
-05/06 Rücktritt von Brandt, 1974
-05/16 Wahl von Schmidt (SPD) zum Bundeskanzler, 1974
-05/23 Verkündung des Grundgesetzes
-05/23 Wahl von Richard von Weizäcker zum Bundespräsidenten, 1984
-06/05 Marshallplan, 1947
-06/20 Währungsreform in den Westzonen, 1948
-06/24 Beginn der Berliner Blockade, 1948
-07/01 Wahl von Heinrich Lübke zum Bundespräsidenten, 1959
-07/01 Währungs- und Währungsunion, 1990
-08/12 deutsch-sowjetischer Gewaltverzichtsvertrag, Moskau 1970
-08/14 Wahl zum ersten deutschen Bundestag, 1949
-09/03 Vier-Mächte-Abkommen über Berlin, 1971
-09/05 Entführung und Ermordung von Arbeitgeberpräsident Schleyer, Entführung einer Lufthansa-Maschine nach Mogadischu, 1977
-09/07 DDR-Staatsratsvorsitzender Honecker in der Bundesrepublik, 1987
-09/12 Wahl von Theodor Heuss (FDP) zum Bundespräsidenten, 1949
-09/15 Wahl von Konrad Adenauer (CDU) zum Bundeskanzler, 1949
-09/17 Bruch der Sozialliberalen Koalition, 1982
-09/18 Aufnahme von Bundesrepublik und DDR in die UNO, 1993
-10/01 Ablösung von Bundeskanzler Schmidt durch Kohl, 1982
-10/23 Volksabstimmung im Saargebiet, 1955
-12/02 Washingtoner Abkommen über Bi-Zone, 1946
-12/07 deutsch-polnischer Vertrag, Warschau 1970
-12/10 Friedensnobelpreis für Brandt, 1971
-12/12 Nachrüstungsbeschluß des NATO-Ministerates, 1979
-12/21 Grundlagenvertrag zwischen DDR und Bundesrepublik, 1972
-
-
-/* Nationalsozialismus */
-11/09 Hitler-Putsch in München/Marsch auf die Feldherrenhalle, 1923
-11/09 Reichskristallnacht, 1938
-09/14 Reichstagswahl: Erdrutsch zugunsten der NSDAP, 1930
-07/31 Reichstagswahl: NSDAP wird stärkste Fraktion, 1932
-11/06 Reichstagswahl: Rückgang der NSDAP, 1932
-01/30 Ernennung von Hitler zum Reichskanzler, 1933
-02/27 Reichstagsbrand, 1933
-03/05 Reichstagswahl: Mehrheit für NSDAP+DNVP, 1933
-03/23 Annahme des Ermächtigungsgesetzes, 1933
-03/31 Erstes Gesetz zur Gleichschaltung der Länder, 1933
-04/01 Organisierter Boykott jüdischer Geschäfte, 1933
-04/07 Zweites Gesetz zur Gleichschaltung der Länder, 1933
-05/02 Auflösung der Gewerkschaften, 1933
-06 Auflösung aller Parteien außer NSDAP, 1933
-07/20 Konkordat zwischen Deutschland und dem Vatikan, 1933
-06/30 Röhm-Putsch, Ausschaltung der SA-Führung, 1934
-09/15 Nürnberger Gesetze, 1935
-01/08 Eröffnung der olympischen Spiele in Berlin, 1936
-01/20 Wannseekonferenz, 1942
-04/30 Selbstmord Hitlers, 1945
-07/29 Mussolini geboren, 1883
-
-/* Sozialismus */
-01/21 Lenin gestorben, 1924
-06 Gründung des Bundes der Kommunisten in London durch Marx+Engels, 1847
-05/23 Gründung des Allgemeinen Deutschen Arbeitervereins in Leipzig
- unter Führung von Ferdinand Lassalles, 1863
-08/07 Gründung der Sozialdemokratischen Arbeiterpartei in Eisenach
- unter der Führung von August Begel und Wilhelm Liebknecht, 1869
-04/06 Gründung der Unabhängigen Sozialdemokratischen Partei, Gotha 1917
-11/07 Oktoberrevolution in Rußland, Putsch der Bolschewisten, 1917
-12/31 Gründung der KPD, 1918
-01/15 Ermordung von Rosa Luxemburg und Karl Liebknecht, 1919
-03/05 Tod Stalins, 1953
-03/18 Erste demokratische Volkskammerwahl, 1990
-04/21 Zwangsvereinigung von KPD und SPD zur SED, 1946
-05/14 Gründung der Warschauer Paktes, 1955
-06/17 Arbeiteraufstand am 17. Juni 1953
-06/25 Begin der Korea-Krieges, 1950
-08/13 Bau der Berliner Mauer, 1961
-08/21 Einmarsch des Warschauer Pakts in die Tschechoslowakei, 1968
-10/03 Offizielles Ende der DDR :-)
-10/07 Gründung der DDR 1949
-10/09 Massendemonstration in Leipzig, 1989
-10/14 Kuba-Krise, 1962
-10/18 Ablösung von Erich Honecker als SED-Generalsekretär, 1989
-11/09 Fall der Berliner Mauer, 1989
-09/09 Mao Tse-Tung gestorben im Alter von 82 Jahren, 1976
-11/10 Sowjetischer Präsident Leonid Breschnew gestorben, Alter 75, 1982
-03/27 Chruschtschow wird sowjetischer Präsident, 1958
-10/12 Chruschtschow schlägt während einer Rede in der UNO mit den
- Schuhen auf den Tisch, 1960
-
-#endif /* _de_DE_ISO_8859_1_geschichte_ */
diff --git a/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.kirche b/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.kirche
deleted file mode 100644
index aa4ef195e74d..000000000000
--- a/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.kirche
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Kirche in Deutschland
- *
- * $FreeBSD$
- */
-
-#ifndef _de_DE_ISO_8859_1_kirche_
-#define _de_DE_ISO_8859_1_kirche_
-
-LANG=de_DE.ISO_8859-1
-
-Easter-46 Aschermittwoch
-Easter-48 Rosenmontag
-Easter-7 Palmsonntag
-
-11/Sun-3 Volkstrauertag (maybe)
-11/Sun-2 Volkstrauertag oder Totensonntag
-11/Sun-1 1. Advent oder Totensonntag
-12/Sun+1 1. oder 2. Advent
-12/Sun+2 2. oder 3. Advent
-12/Sun+3 3. oder 4. Advent
-12/Sun+4 4. Advent (maybe)
-
-12/06 Nikolaus
-12/25 1. Weihnachtstag
-12/26 2. Weihnachtstag
-
-/* Evangelische Kirche */
-11/10 Martin Luther geboren in Eisleben, 1483
-10/31 95 Thesen von Luther, Wittenberg, 1517
-
-#endif /* !_de_DE_ISO_8859_1_kirche_ */
diff --git a/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.literatur b/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.literatur
deleted file mode 100644
index 62acab9011a8..000000000000
--- a/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.literatur
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Literatur
- *
- * $FreeBSD$
- */
-
-#ifndef _de_DE_ISO_8859_1_literatur_
-#define _de_DE_ISO_8859_1_literatur_
-
-LANG=de_DE.ISO_8859-1
-
-/* Schriftsteller
-
- Fontane
- Goethe
- Grass
- Hegel
- Heine
- Schiller
- */
-
-01/04 Jakob Grimm geboren, 1785
-04/22 Kant geboren, 1724
-07/03 Franz Kafka geboren, 1883
-08/12 Thomas Mann gestorben, 1955
-
-
-/* Verlage */
-03/09 "die tageszeitung" als erste täglich aktualisierte deutsche
- Tageszeitung im WWW, 1995, Betatest, vollständige Ausgabe
-05/05 Schweriner Volkszeitung als erste deutsche Tageszeitung im WWW, 1995
-05/12 "die tageszeitung" offiziell im WWW, 1995
-08/31 Hitler stellt Frankfurter Zeitung ein, 1943
-11/01 Frankfurter Allgemeine Zeitung in Leben gerufen, 1949
-
-#endif /* !_de_DE_ISO_8859_1_literatur_ */
diff --git a/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.musik b/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.musik
deleted file mode 100644
index ad63646271f6..000000000000
--- a/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.musik
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Musik
- *
- * $FreeBSD$
- */
-
-#ifndef _de_DE_ISO_8859_1_musik_
-#define _de_DE_ISO_8859_1_musik_
-
-LANG=de_DE.ISO_8859-1
-
-/* Klassik */
-02/23 Händel geboren, 1685
-03/21 J.S. Bach geboren, 1685
-05/07 Johannes Brahms geboren in Hamburg, 1833
-05/22 Johann Sebastian Bach geboren in Eisenach, 1665
-07/28 Bach gestorben, 1750
-10/22 Franz Liszt geboren, 1811
-12/05 Mozart gestorben, 1791
-12/16 Beethoven gestorben, 1770
-
-/* Pop */
-09/18 Jimi Hendrix gestorben
-
-#endif /* !_de_DE_ISO_8859_1_musik_ */
diff --git a/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.wissenschaft b/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.wissenschaft
deleted file mode 100644
index 175fe0fa4207..000000000000
--- a/usr.bin/calendar/calendars/de_DE.ISO8859-1/calendar.wissenschaft
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Wissenschaft
- *
- * $FreeBSD$
- */
-
-#ifndef _de_DE_ISO_8859_1_wissenschaft_
-#define _de_DE_ISO_8859_1_wissenschaft_
-
-LANG=de_DE.ISO_8859-1
-
-04/12 erster Mann im All, Juri Gagarin, 1961
-04/18 Einstein gestorben, 1955
-06/22 Konrad Zuse geboren, 1919, Berlin
-10/04 Sputnik 1, erster Satellit im Weltraum, 1957
-12/18 Konrad Zuse gestorben, 1995, Hünfeld
-
-
-#endif /* ! _de_DE_ISO_8859_1_wissenschaft_ */
diff --git a/usr.bin/calendar/calendars/hr_HR.ISO8859-2/calendar.all b/usr.bin/calendar/calendars/hr_HR.ISO8859-2/calendar.all
deleted file mode 100644
index 11be34324383..000000000000
--- a/usr.bin/calendar/calendars/hr_HR.ISO8859-2/calendar.all
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * hrvatski calendar
- *
- * $FreeBSD$
- */
-
-#ifndef _hr_HR_ISO_8859_2_all
-#define _hr_HR_ISO_8859_2_all
-
-#include <hr_HR.ISO_8859-2/calendar.praznici>
-
-#endif /* !_hr_HR_ISO_8859_2_all */
diff --git a/usr.bin/calendar/calendars/hr_HR.ISO8859-2/calendar.praznici b/usr.bin/calendar/calendars/hr_HR.ISO8859-2/calendar.praznici
deleted file mode 100644
index b78ea99533f8..000000000000
--- a/usr.bin/calendar/calendars/hr_HR.ISO8859-2/calendar.praznici
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * hrvatski praznici
- *
- * $FreeBSD$
- */
-
-#ifndef _hr_HR_ISO_8859_2_praznici
-#define _hr_HR_ISO_8859_2_praznici
-
-LANG=hr_HR.ISO_8859-2
-
-/* slobodni dr¾avni praznici */
-01/01 Nova godina
-05/01 Prvi maj
-
-
-/* slobodni kr¹æanski praznici */
-Easter-2 Veliki petak
-Easter Uskrs
-Easter+1 Uskrsni ponedjeljak
-Easter+49 Duhovi
-Easter+50 Duhovni ponedjeljak
-Easter+39 Uza¹a¹æe
-12/25 Bo¾iæ
-12/26 Stjepandan
-
-/* godi¹nja doba */
-03/21* Poèetak proljeæa
-06/21* Poèetak ljeta
-09/21* Poèetak jesena
-12/21* Poèetak zime
-
-/* ljetno vrijeme */
-03/NedjeljaLast Poèetak ljetnog vremena
-10/NedjeljaLast Kraj ljetnog vremena
-
-#endif /* !_hr_HR_ISO_8859_2_praznici */
diff --git a/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.all b/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.all
deleted file mode 100644
index fcdc5e7f8f5e..000000000000
--- a/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.all
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * òÕÓÓËÉÊ ËÁÌÅÎÄÁÒØ
- *
- * $FreeBSD$
- */
-
-#ifndef _ru_SU_KOI8_R_all
-#define _ru_SU_KOI8_R_all
-
-#include <ru_SU.KOI8-R/calendar.common>
-#include <ru_SU.KOI8-R/calendar.msk>
-#include <ru_SU.KOI8-R/calendar.pagan>
-#include <ru_SU.KOI8-R/calendar.orthodox>
-
-#endif /* !_ru_SU_KOI8_R_all */
diff --git a/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.common b/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.common
deleted file mode 100644
index 2a45b1d2650f..000000000000
--- a/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.common
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * òÕÓÓËÉÅ ÐÒÁÚÄÎÉËÉ
- *
- * $FreeBSD$
- */
-
-#ifndef _ru_SU_KOI8_R_common_
-#define _ru_SU_KOI8_R_common_
-
-LANG=ru_SU.KOI8-R
-
- 1 ÑÎ× îÏ×ÙÊ çÏÄ
-14 ÑÎ× óÔÁÒÙÊ îÏ×ÙÊ çÏÄ
-23 ÆÅ× äÅÎØ úÁÝÉÔÎÉËÁ ïÔÅÞÅÓÔ×Á
- 8 ÍÁÒ íÅÖÄÕÎÁÒÏÄÎÙÊ öÅÎÓËÉÊ äÅÎØ
- 1 ÁÐÒ äÅÎØ óÍÅÈÁ
- 1 ÍÁÊ ðÒÁÚÄÎÉË ×ÅÓÎÙ É ÔÒÕÄÁ
- 9 ÍÁÊ äÅÎØ ðÏÂÅÄÙ
- 1 ÉÀÎ äÅÎØ úÁÝÉÔÙ äÅÔÅÊ
-12 ÉÀÎ äÅÎØ îÅÚÁ×ÉÓÉÍÏÓÔÉ òÏÓÓÉÉ
- 1 ÓÅÎ äÅÎØ úÎÁÎÉÊ
-
-#endif /* !_ru_SU_KOI8_R_common_ */
-
diff --git a/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.msk b/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.msk
deleted file mode 100644
index 22de9d3588b7..000000000000
--- a/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.msk
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * ðÅÒÅ×ÏÄ ÞÁÓÏ× ÄÌÑ ÍÏÓËÏ×ÓËÏÊ ×ÒÅÍÅÎÎÏÊ ÚÏÎÙ
- *
- * $FreeBSD$
- */
-
-#ifndef _ru_SU_KOI8_R_msk_
-#define _ru_SU_KOI8_R_msk_
-
-LANG=ru_SU.KOI8-R
-
-03/SunLast îÁÞÁÌÏ ÍÏÓËÏ×ÓËÏÇÏ ÌÅÔÎÅÇÏ ×ÒÅÍÅÎÉ; ÞÁÓÙ ÐÅÒÅ×ÏÄÑÔÓÑ ×ÐÅÒÅÄ
-10/SunLast ëÏÎÅà ÍÏÓËÏ×ÓËÏÇÏ ÌÅÔÎÅÇÏ ×ÒÅÍÅÎÉ; ÞÁÓÙ ÐÅÒÅ×ÏÄÑÔÓÑ ÎÁÚÁÄ
-
-#endif /* !_ru_SU_KOI8_R_msk_ */
-
diff --git a/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.orthodox b/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.orthodox
deleted file mode 100644
index 0105343eae8a..000000000000
--- a/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.orthodox
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * ðÒÁ×ÏÓÌÁ×ÎÙÅ ÐÒÁÚÄÎÉËÉ
- *
- * $FreeBSD$
- */
-
-#ifndef _ru_SU_KOI8_R_orthodox_
-#define _ru_SU_KOI8_R_orthodox_
-
-LANG=ru_SU.KOI8-R
-Paskha=ðÁÓÈÁ
-
-21 ÓÅÎ òÏÖÄÅÓÔ×Ï ðÒÅÓ×ÑÔÏÊ âÏÇÏÒÏÄÉÃÙ
-28 ÓÅÎ ÷ÏÚÄ×ÉÖÅÎÉÅ ëÒÅÓÔÁ çÏÓÐÏÄÎÑ
-14 ÏËÔ ðÏËÒÏ× ðÒÅÓ×ÑÔÏÊ âÏÇÏÒÏÄÉÃÙ
- 4 ÄÅË ÷×ÅÄÅÎÉÅ ×Ï ÈÒÁÍ ðÒÅÓ×ÑÔÏÊ âÏÇÏÒÏÄÉÃÙ
- 7 ÑÎ× òÏÖÄÅÓÔ×Ï èÒÉÓÔÏ×Ï
-19 ÑÎ× âÏÇÏÑ×ÌÅÎÉÅ ÉÌÉ ëÒÅÝÅÎÉÅ çÏÓÐÏÄÎÅ
-15 ÆÅ× óÒÅÔÅÎÉÅ çÏÓÐÏÄÎÅ
-ðÁÓÈÁ-46 ÷ÅÌÉËÉÊ ðÏÓÔ
-ðÁÓÈÁ-7 ÷ÅÒÂÎÏÅ ÷ÏÓËÒÅÓÅÎØÅ
-ðÁÓÈÁ-3 ÷ÅÌÉËÉÊ þÅÔ×ÅÒÇ
-ðÁÓÈÁ-2 óÔÒÁÓÔÎÁÑ ðÑÔÎÉÃÁ
-ðÁÓÈÁ ÷ÏÓËÒÅÓÅÎÉÅ èÒÉÓÔÏ×Ï
-ðÁÓÈÁ+39 ÷ÏÚÎÅÓÅÎÉÅ
-ðÁÓÈÁ+49 ðÑÔÉÄÅÓÑÔÎÉÃÁ
-ðÁÓÈÁ+56 ôÒÏÉÃÉÎ äÅÎØ
-ðÁÓÈÁ+60 ðÒÁÚÄÎÉË ôÅÌÁ èÒÉÓÔÏ×Á
- 7 ÁÐÒ âÌÁÇÏ×ÅÝÅÎÉÅ ðÒÅÓ×ÑÔÏÊ âÏÇÏÒÏÄÉÃÙ
-19 Á×Ç ðÒÅÏÂÒÁÖÅÎÉÅ çÏÓÐÏÄÎÅ
-28 Á×Ç õÓÐÅÎÉÅ ðÒÅÓ×ÑÔÏÊ âÏÇÏÒÏÄÉÃÙ
-
-#endif /* !_ru_SU_KOI8_R_orthodox_ */
-
diff --git a/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.pagan b/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.pagan
deleted file mode 100644
index c37c993680e9..000000000000
--- a/usr.bin/calendar/calendars/ru_RU.KOI8-R/calendar.pagan
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * ñÚÙÞÅÓËÉÅ ÐÒÁÚÄÎÉËÉ
- *
- * $FreeBSD$
- */
-
-#ifndef _ru_SU_KOI8_R_pagan_
-#define _ru_SU_KOI8_R_pagan_
-
-LANG=ru_SU.KOI8-R
-Paskha=ðÁÓÈÁ
-
-21 ÄÅË* úÉÍÎÅÅ ÓÏÌÎÃÅÓÔÏÑÎÉÅ
-25 ÄÅË ëÏÌÑÄÁ (ÓÄ×ÉÎÕÔÏÅ ÚÉÍÎÅÅ ÓÏÌÎÃÅÓÔÏÑÎÉÅ)
-31 ÄÅË îÅÄÅÌÑ ðÒÁÏÔÃÏ×
- 6 ÑÎ× äÅÎØ ëÁÝÅÑ É ÷ÅÌÅÓÁ, ÐÏÓÔ
-24 ÆÅ× äÅÎØ ÷ÅÌÅÓÁ
-29 ÆÅ× äÅÎØ ëÁÝÅÑ
- 1 ÍÁÒ äÅÎØ íÁÒÅÎÙ
-14 ÍÁÒ îÏ×ÙÊ çÏÄ, ï×ÓÅÎØ ÍÁÌÙÊ
-ðÁÓÈÁ-47 íÁÓÌÅÎÉÃÁ
-ðÁÓÈÁ+7 ëÒÁÓÎÁÑ çÏÒËÁ
-ðÁÓÈÁ+16 òÁÄÕÎÉÃÁ
-20 ÍÁÒ* ÷ÅÓÅÎÎÉÅ ÒÁ×ÎÏÄÅÎÓÔ×ÉÅ
- 7 ÁÐÒ äÅÎØ íÁÒÅÎÙ (ÓÄ×ÉÎÕÔÏÅ ×ÅÓÅÎÎÅÅ ÒÁ×ÎÏÄÅÎÓÔ×ÉÅ)
- 6 ÍÁÊ äÅÎØ äÁÖØÂÏÇÁ, ï×ÓÅÎØ ÂÏÌØÛÏÊ
-22 ÍÁÊ ñÒÉÌÉÎ äÅÎØ
-21 ÉÀÎ* ìÅÔÎÅÅ ÓÏÌÎÃÅÓÔÏÑÎÉÅ
- 1 ÉÀÌ òÕÓÁÌØÎÁÑ îÅÄÅÌÑ
- 7 ÉÀÌ ëÕÐÁÌÁ (ÓÄ×ÉÎÕÔÏÅ ÌÅÔÎÅÅ ÓÏÌÎÃÅÓÔÏÑÎÉÅ)
-27 ÉÀÌ ïÔÂÏÒ ÖÅÒÔ× ðÅÒÕÎÕ, ÒÕÓÁÌÉÉ
- 2 Á×Ç ðÅÒÕÎÏ× äÅÎØ
-21 Á×Ç äÅÎØ óÔÒÉÂÏÇÁ
-28 Á×Ç õÓÐÅÎÉÅ úÌÁÔÏÇÏÒËÉ
-14 ÓÅÎ äÅÎØ ÷ÏÌÈÁ úÍÅÅ×ÉÞÁ
-22 ÓÅÎ* ðÏ×ÏÒÏÔ Ë ÚÉÍÅ (ÏÓÅÎÎÅÅ ÒÁ×ÎÏÄÅÎÓÔ×ÉÅ)
-10 ÎÏÑ äÅÎØ íÁËÏÛÉ
-21 ÎÏÑ äÅÎØ ó×ÁÒÏÇÁ É óÅÍÁÒÇÌÁ
- 9 ÄÅË äÅÎØ äÁÖØÂÏÇÁ É íÁÒÅÎÙ
-
-#endif /* !_ru_SU_KOI8_R_pagan_ */
-
diff --git a/usr.bin/ee/nls/de_DE.ISO8859-1/ee.msg b/usr.bin/ee/nls/de_DE.ISO8859-1/ee.msg
deleted file mode 100644
index ef2ce2230d3e..000000000000
--- a/usr.bin/ee/nls/de_DE.ISO8859-1/ee.msg
+++ /dev/null
@@ -1,182 +0,0 @@
-$ This file contains the messages for ee ("easy editor"). See the file
-$ ee.i18n.guide for more information
-$
-$ For ee patchlevel 3
-$
-$ $FreeBSD$
-$
-$set 1
-$quote "
-1 "Modus-Menü"
-2 "Tab -> Leerzeichen "
-3 "Suche ohne Groß/Klein"
-4 "Ränder beachten "
-5 "Automatische Absätze "
-6 "8-Bit Zeichen (Uml.) "
-7 "Hilfefenster "
-8 "rechter Rand "
-9 "Ende-Menü"
-10 "Speichern"
-11 "Verwerfen"
-12 "Dateimenü"
-13 "Öffnen"
-14 "Schreiben in Datei"
-15 "Speichern"
-16 "Aktuellen Inhalt drucken"
-17 "Textsuche"
-18 "Suche nach ..."
-19 "Suchen"
-20 "Rechtschreibung"
-21 "'spell' benutzen"
-22 "'ispell' benutzen"
-23 "Verschiedenes"
-24 "Absatz formatieren"
-25 "Unix-Kommando"
-26 "Rechtschreibung prüfen"
-27 "Hauptmenü"
-28 "Editor beenden"
-29 "Hilfe"
-30 "Dateioperationen"
-31 "Bildschirm regenerieren"
-32 "Einstellungen"
-33 "Suche"
-34 "Verschiedenes"
-35 "Steuertasten: "
-36 "^a ASCII-Code direkt ^i Tabulator ^r nach rechts "
-37 "^b Ende des Textes ^j neue Zeile ^t Anfang des Textes "
-38 "^c Befehl ^k Zeichen löschen ^u hoch "
-39 "^d runter ^l nach links ^v Wort zurückholen "
-40 "^e Textsuche (Menü) ^m neue Zeile ^w Wort löschen "
-41 "^f Zeichen zurückholen ^n nächste Seite ^x Weitersuchen "
-42 "^g zum Zeilenanfang ^o zum Zeilenende ^y Zeile löschen "
-43 "^h Rückschritt ^p vorige Seite ^z Zeile zurückholen "
-44 "^[ (Escape) Menü ESC-Enter: ee beenden "
-45 " "
-46 "Befehle: "
-47 "hilfe : diese Hilfe anzeigen datei : Dateinamen anzeigen "
-48 "lesen : Datei öffnen zeichen : ASCII-Code anzeigen "
-49 "schreiben:Datei schreiben grosskl : Suche mit Groß/Kleinschr."
-50 "ende : Sichern und Beenden klein : Suche ohne Groß/Klein. "
-51 "abbruch : Abbruch ohne Sichern !bef : Unix-Befehl \"bef\" ausf. "
-52 "zeile : Zeilennummer anzeigen 0-9 : Zur angegebenen Zeile "
-53 "leer : Tabulat. in Leerz. wandeln tabs : Tabulatoren belassen "
-54 " "
-55 " ee [-i] [-e] [-h] [datei(en)] "
-56 " -i : ohne Hilfefenster -e : Tabulatoren lassen -h : k. Hervorheb."
-57 "^[ (Escape) Menü ^e Textsuche ^y Zeile löschen ^u hoch ^p Seite zur. "
-58 "^a ASCII-Code ^x Weitersuchen ^z Zeile rückhl. ^d runter ^n Seite vor "
-59 "^b Textende ^g Zeilenanfang ^w Wort löschen ^l links "
-60 "^t Textanfang ^o Zeilenende ^v Wort rückhol. ^r rechts "
-61 "^c Befehl ^k Zeichen lösch. ^f Zeichen rückholen ESC-Enter: Ende ee "
-62 "hilfe: Hilfe |datei : Dateiname anzeigen |zeile: Zeilennumer "
-63 "lesen: Datei lesen |zeichen:ASCII-Code des Zeichens |0-9 : zur Zeile "
-64 "schre: Datei schreib. |grosskl:Suche mit Groß/Klein |ende : Speichern,Ende "
-65 "!bef : Unix-\"bef\" |klein: Suche ohne Groß/Klein |abbr : Abbruch "
-66 "leer : Tab -> Leerz. |tabs : Tabulatoren belassen "
-67 " Escape (^[) drücken für Menü"
-68 "Keine Datei"
-69 "ASCII-Code: "
-70 "Pufferinhalt nach \"%s\" schreiben "
-71 "Befehl: "
-72 "Dateiname zum Schreiben: "
-73 "Dateiname zum Lesen: "
-74 "Zeichen = %d"
-75 "Unbekannter Befehl \"%s\""
-76 "Angegebener Befehl ist nicht eindeutig"
-77 "Zeile %d "
-78 "Länge = %d"
-79 "Aktuelle Datei ist \"%s\" "
-80 "Benutzung: %s [-i] [-e] [-h] [+zeilennummer] [dateien]\n"
-81 " -i Hilfefenster ausschalten\n"
-82 " -e Tabulatoren nicht in Leerzeichen wandeln\n"
-83 " -h keine Hervorhebungen\n"
-84 "Datei \"%s\" ist ein Verzeichnis"
-85 "Neue Datei \"%s\""
-86 "Datei \"%s\" kann nicht geöffnet werden"
-87 "Datei \"%s\", %d Zeilen"
-88 "Lesen der Datei \"%s\" beendet"
-89 "Lese die Datei \"%s\""
-90 ", schreibgeschützt"
-91 "Datei \"%s\", %d Zeilen"
-92 "Dateinamen eingeben: "
-93 "Kein Name angegeben; Datei nicht gespeichert"
-94 "Pufferinhalt geändert, wirklich verlassen? (j/n [n]) "
-95 "j"
-96 "Datei existiert bereits, überschreiben? (j/n) [n] "
-97 "Datei \"%s\" kann nicht erzeugt werden"
-98 "Schreibe Datei \"%s\""
-99 "\"%s\" %d Zeilen, %d Zeichen"
-100 " ...Suche läuft"
-101 "Zeichenfolge \"%s\" nicht gefunden"
-102 "Suchen nach: "
-103 "Kann %s nicht ausführen"
-104 "Bitte die Eingabetaste drücken "
-105 "Escape zum Beenden"
-106 "Menü ist zu groß für das Fenster"
-107 "eine beliebige Taste drücken "
-108 "Unix-Befehl: "
-109 "...formatiere Absatz..."
-110 "<!echo 'Liste der nicht gefundenen Wörter'; echo -=-=-=-=-=-"
-111 "Sende den Pufferinhalt an 'spell'"
-112 "Rechter Rand: "
-113 "Eingeschränkter Modus: gewünschte Operation unzulässig"
-114 "EIN"
-115 "AUS"
-116 "HILFE"
-117 "SCHREIBEN"
-118 "LESEN"
-119 "ZEILE"
-120 "DATEI"
-121 "ZEICHEN"
-122 "REGENERIEREN"
-123 "UMNUMERIEREN"
-124 "AUTOR"
-125 "VERSION"
-126 "GROSSKL"
-127 "KLEIN"
-128 "LEER"
-129 "TABS"
-130 "ENDE"
-131 "ABBRUCH"
-132 "INFO"
-133 "[INFO]"
-134 "RAND"
-135 "[RAND]"
-136 "FORMAT."
-137 "[FORMAT.]"
-138 "ECHO"
-139 "DRUCKBEFEHL"
-140 "RECHTERRAND"
-141 "HERVORHEB."
-142 "[HERVORHEB.]"
-143 "8-BIT"
-144 "[8-BIT]"
-145 "Emacs-Tastenbelegung "
-146 "^a Zeilenanfang ^i Tabulator ^r Wort zurückholen "
-147 "^b ein Zeichen zurück ^j Zeichen zurückholen ^t Textanfang "
-148 "^c Befehl ^k Zeile löschen ^u Textende "
-149 "^d Zeichen löschen ^l Zeile zurückholen ^v nächste Seite "
-150 "^e Zeilenendee ^m neue Zeile ^w Wort löschen "
-151 "^f ein Zeichen vorwärts ^n neue Zeile ^x Weitersuchen "
-152 "^g vorige Seite ^o ASCII-Zeichen einfü. ^y Textsuche "
-153 "^h Rückschritt ^p vorige Zeile ^z nächstes Wort "
-154 "^[ (Escape) Menü ^y Suchtext eing. ^k Zeile löschen ^p vor.Zeile ^g vor.Seite"
-155 "^o ASCII-Zeichen ^x Weitersuchen ^l Zeile rückhol ^n nä. Zeile ^v nä. Seite"
-156 "^u Textende ^a Zeilenanfang ^w Wort löschen ^b ein Zeichen zurück "
-157 "^t Textanfang ^e Zeilenende ^r Wort rückhol. ^f ein Zeichen vor "
-158 "^c Befehl ^d Zeichen lösch. ^j Zeich. rückh. ^z nächstes Wort "
-159 "EMACS"
-160 "[EMACS]"
-161 " +<zahl> Zeiger auf Zeile <zahl> setzen"
-162 "Kann die Datei .init.ee nicht schreiben, Konfiguration nicht gespeichert!"
-163 "ee-Konfiguration in Datei %s gespeichert"
-164 "speichere Editor-Konfiguration"
-165 "speichere ee-Konfiguration"
-166 "speichern im aktuellen Verzeichnis"
-167 "speichern im Home-Verzeichnis"
-168 "ee-Konfiguration nicht gespeichert"
-169 "beim Aufruf von ree muß ein Dateiname angegeben werden"
-170 "Esc zum Verlassen"
-180 "Menü zu groß für den Bildschirm"
-181 "^^weiter^^"
-182 "VVweiterVV"
diff --git a/usr.bin/ee/nls/en_US.US-ASCII/ee.msg b/usr.bin/ee/nls/en_US.US-ASCII/ee.msg
deleted file mode 100644
index 1e71ddd1e56f..000000000000
--- a/usr.bin/ee/nls/en_US.US-ASCII/ee.msg
+++ /dev/null
@@ -1,182 +0,0 @@
-$ This file contains the messages for ee ("easy editor"). See the file
-$ ee.i18n.guide for more information
-$
-$ For ee patchlevel 3
-$
-$ $FreeBSD$
-$
-$set 1
-$quote "
-1 "modes menu"
-2 "tabs to spaces "
-3 "case sensitive search"
-4 "margins observed "
-5 "auto-paragraph format"
-6 "eightbit characters "
-7 "info window "
-8 "right margin "
-9 "leave menu"
-10 "save changes"
-11 "no save"
-12 "file menu"
-13 "read a file"
-14 "write a file"
-15 "save file"
-16 "print editor contents"
-17 "search menu"
-18 "search for ..."
-19 "search"
-20 "spell menu"
-21 "use 'spell'"
-22 "use 'ispell'"
-23 "miscellaneous menu"
-24 "format paragraph"
-25 "shell command"
-26 "check spelling"
-27 "main menu"
-28 "leave editor"
-29 "help"
-30 "file operations"
-31 "redraw screen"
-32 "settings"
-33 "search"
-34 "miscellaneous"
-35 "Control keys: "
-36 "^a ascii code ^i tab ^r right "
-37 "^b bottom of text ^j newline ^t top of text "
-38 "^c command ^k delete char ^u up "
-39 "^d down ^l left ^v undelete word "
-40 "^e search prompt ^m newline ^w delete word "
-41 "^f undelete char ^n next page ^x search "
-42 "^g begin of line ^o end of line ^y delete line "
-43 "^h backspace ^p prev page ^z undelete line "
-44 "^[ (escape) menu ESC-Enter: exit ee "
-45 " "
-46 "Commands: "
-47 "help : get this info file : print file name "
-48 "read : read a file char : ascii code of char "
-49 "write : write a file case : case sensitive search "
-50 "exit : leave and save nocase : case insensitive search "
-51 "quit : leave, no save !cmd : execute \"cmd\" in shell "
-52 "line : display line # 0-9 : go to line \"#\" "
-53 "expand : expand tabs noexpand: do not expand tabs "
-54 " "
-55 " ee [-i] [-e] [-h] [file(s)] "
-56 " -i : no information window -e : do not expand tabs -h : no highlight "
-57 "^[ (escape) menu ^e search prompt ^y delete line ^u up ^p prev page "
-58 "^a ascii code ^x search ^z undelete line ^d down ^n next page "
-59 "^b bottom of text ^g begin of line ^w delete word ^l left "
-60 "^t top of text ^o end of line ^v undelete word ^r right "
-61 "^c command ^k delete char ^f undelete char ESC-Enter: exit ee "
-62 "help : get help info |file : print file name |line : print line # "
-63 "read : read a file |char : ascii code of char |0-9 : go to line \"#\""
-64 "write: write a file |case : case sensitive search |exit : leave and save "
-65 "!cmd : shell \"cmd\" |nocase: ignore case in search |quit : leave, no save"
-66 "expand: expand tabs |noexpand: do not expand tabs "
-67 " press Escape (^[) for menu"
-68 "no file"
-69 "ascii code: "
-70 "sending contents of buffer to \"%s\" "
-71 "command: "
-72 "name of file to write: "
-73 "name of file to read: "
-74 "character = %d"
-75 "unknown command \"%s\""
-76 "entered command is not unique"
-77 "line %d "
-78 "length = %d"
-79 "current file is \"%s\" "
-80 "usage: %s [-i] [-e] [-h] [+line_number] [file(s)]\n"
-81 " -i turn off info window\n"
-82 " -e do not convert tabs to spaces\n"
-83 " -h do not use highlighting\n"
-84 "file \"%s\" is a directory"
-85 "new file \"%s\""
-86 "can't open \"%s\""
-87 "file \"%s\", %d lines"
-88 "finished reading file \"%s\""
-89 "reading file \"%s\""
-90 ", read only"
-91 "file \"%s\", %d lines"
-92 "enter name of file: "
-93 "no filename entered: file not saved"
-94 "changes have been made, are you sure? (y/n [n]) "
-95 "y"
-96 "file already exists, overwrite? (y/n) [n] "
-97 "unable to create file \"%s\""
-98 "writing file \"%s\""
-99 "\"%s\" %d lines, %d characters"
-100 " ...searching"
-101 "string \"%s\" not found"
-102 "search for: "
-103 "could not exec %s"
-104 "press return to continue "
-105 "press Esc to cancel"
-106 "menu too large for window"
-107 "press any key to continue "
-108 "shell command: "
-109 "...formatting paragraph..."
-110 "<!echo 'list of unrecognized words'; echo -=-=-=-=-=-"
-111 "sending contents of edit buffer to 'spell'"
-112 "right margin is: "
-113 "restricted mode: unable to perform requested operation"
-114 "ON"
-115 "OFF"
-116 "HELP"
-117 "WRITE"
-118 "READ"
-119 "LINE"
-120 "FILE"
-121 "CHARACTER"
-122 "REDRAW"
-123 "RESEQUENCE"
-124 "AUTHOR"
-125 "VERSION"
-126 "CASE"
-127 "NOCASE"
-128 "EXPAND"
-129 "NOEXPAND"
-130 "EXIT"
-131 "QUIT"
-132 "INFO"
-133 "NOINFO"
-134 "MARGINS"
-135 "NOMARGINS"
-136 "AUTOFORMAT"
-137 "NOAUTOFORMAT"
-138 "ECHO"
-139 "PRINTCOMMAND"
-140 "RIGHTMARGIN"
-141 "HIGHLIGHT"
-142 "NOHIGHLIGHT"
-143 "EIGHTBIT"
-144 "NOEIGHTBIT"
-145 "emacs key bindings "
-146 "^a beginning of line ^i tab ^r restore word "
-147 "^b back 1 char ^j undel char ^t begin of file "
-148 "^c command ^k delete line ^u end of file "
-149 "^d delete char ^l undelete line ^v next page "
-150 "^e end of line ^m newline ^w delete word "
-151 "^f forward 1 char ^n next line ^x search "
-152 "^g go back 1 page ^o ascii char insert ^y search prompt "
-153 "^h backspace ^p prev line ^z next word "
-154 "^[ (escape) menu ^y search prompt ^k delete line ^p prev li ^g prev page"
-155 "^o ascii code ^x search ^l undelete line ^n next li ^v next page"
-156 "^u end of file ^a begin of line ^w delete word ^b back 1 char "
-157 "^t begin of file ^e end of line ^r restore word ^f forward 1 char "
-158 "^c command ^d delete char ^j undelete char ^z next word "
-159 "EMACS"
-160 "NOEMACS"
-161 " +# put cursor at line #\n"
-162 "unable to open .init.ee for writing, no configuration saved!"
-163 "ee configuration saved in file %s"
-164 "save editor configuration"
-165 "save ee configuration"
-166 "save in current directory"
-167 "save in home directory"
-168 "ee configuration not saved"
-169 "must specify a file when invoking ree"
-170 "press Esc to cancel"
-180 "menu too large for window"
-181 "^^more^^"
-182 "VVmoreVV"
diff --git a/usr.bin/ee/nls/fr_FR.ISO8859-1/ee.msg b/usr.bin/ee/nls/fr_FR.ISO8859-1/ee.msg
deleted file mode 100644
index e4c2c9567b35..000000000000
--- a/usr.bin/ee/nls/fr_FR.ISO8859-1/ee.msg
+++ /dev/null
@@ -1,182 +0,0 @@
-$ This file contains the messages for ee ("easy editor"). See the file
-$ ee.i18n.guide for more information
-$
-$ For ee patchlevel 3
-$
-$ $FreeBSD$
-$
-$set 1
-$quote "
-1 "menu de configuration "
-2 "tabulation -> espaces "
-3 "recherche sensible aux maj/min "
-4 "respect des marges "
-5 "formattage automatique des paragraphes"
-6 "caractères 8 bits "
-7 "fenêtre d'informations "
-8 "marge de droite "
-9 "menu de sortie"
-10 "enregistrer les modifications"
-11 "ne pas enregistrer"
-12 "menu fichiers"
-13 "lire un fichier"
-14 "écrire un fichier"
-15 "enregistrer un fichier"
-16 "imprimer le contenu de l'éditeur"
-17 "menu recherche"
-18 "recherche de..."
-19 "rechercher"
-20 "menu correcteur orthographique"
-21 "utiliser 'spell'"
-22 "utiliser 'ispell'"
-23 "menu divers"
-24 "formatter le paragraphe"
-25 "commande du shell"
-26 "vérifier l'orthographe"
-27 "menu principal"
-28 "quitter l'éditeur"
-29 "aide"
-30 "opérations sur les fichiers"
-31 "rafraîchir l'écran"
-32 "configuration"
-33 "recherche"
-34 "divers"
-35 "Contrôle + touche: "
-36 "^a code ascii ^i tabulation ^r droite "
-37 "^b fin du texte ^j nouvelle ligne ^t début du texte "
-38 "^c commande ^k effacer caractère ^u haut "
-39 "^d bas ^l gauche ^v annuler effacement mot "
-40 "^e entrer recherche ^m nouvelle ligne ^w effacer un mot "
-41 "^f annuler eff. caract. ^n page suivante ^x recherche "
-42 "^g début de ligne ^o fin de ligne ^y effacer ligne "
-43 "^h arrière ^p page précédente ^z annuler effacement ligne"
-44 "^[ (échappement) menu ESC-Enter: quitter ee "
-45 " "
-46 "Commandes: "
-47 "aide : pour cet écran d'info fichier: donne le nom du fichier "
-48 "lire : lire un fichier caract : code ascii d'un caractère"
-49 "écrire : créer un fichier minmaj : recherche sensible aux maj/min"
-50 "fin : quitter et enregistrer pasmin : recherche insensible aux maj/min"
-51 "quitter: quitter, ne pas enregistrer !cmd : exécute \"cmd\" par le shell"
-52 "ligne : indique le numéro de ligne 0-9 : aller à la ligne \"#\" "
-53 "tabs : étendre les tabulations pastabs: ne pas étendre les tabulations"
-54 " "
-55 " ee [-i] [-e] [-h] [fichier(s)] "
-56 " -i : pas de fenêtre d'info -e : ne pas étendre les tabs -h : pas de surbrillance"
-57 "^[ (échap.) menu ^e rechercher... ^y efface ligne ^u haut ^p page préc."
-58 "^a code ascii ^x rechercher ^z annul. eff. ligne ^d bas ^n page suiv."
-59 "^b fin du texte ^g début de ligne ^w efface mot ^l gauche "
-60 "^t début du texte ^o fin de ligne ^v annul. eff. mot ^r droite "
-61 "^c commande ^k efface caract. ^f annul. eff. caract. ESC-Enter: quitter "
-62 "aide: fenêtre d'aide |fichier: nom du fichier |ligne: numéro de ligne"
-63 "lire: lecture fichier|caract : code ascii du car. |0-9: aller ligne \"#\""
-64 "écrire: crée un fich. |minmaj: rech. sensible min/maj|fin: quitte et sauve"
-65 "!cmd: shell \"cmd\" |pasmin: rech. insens. min/maj |quitte: quitte sans sauver"
-66 "tabs: étend les tabs |pastabs: n'étend pas les tabulations"
-67 " pressez sur échap. (^[) pour le menu"
-68 "pas de fichier"
-69 "code ascii : "
-70 "le contenu du buffer est imprimé sur \"%s\" "
-71 "commande : "
-72 "nom du fichier à créer : "
-73 "nom du fichier à lire : "
-74 "caractère = %d"
-75 "commande inconnue : \"%s\""
-76 "la commande tapée est ambiguë"
-77 "ligne %d "
-78 "longueur = %d"
-79 "le fichier courant est \"%s\" "
-80 "utilisation : %s [-i] [-e] [-h] [+numéro_de_ligne] [fichier(s)]\n"
-81 " -i supprime la fenêtre d'informations\n"
-82 " -e ne convertit pas les tabs en espaces\n"
-83 " -h n'utilise pas de surbrillance\n"
-84 "le fichier \"%s\" est un répertoire"
-85 "nouveau fichier \"%s\""
-86 "impossible de d'ouvrir \"%s\""
-87 "fichier \"%s\", %d lignes"
-88 "le fichier \"%s\" a été lu"
-89 "lecture du fichier \"%s\""
-90 ", lecture seule"
-91 "fichier \"%s\", %d lignes"
-92 "entrez un nom de fichier : "
-93 "pas de nom de fichier donné : fichier non enregistré"
-94 "des changements ont été effectués, êtes vous sûr ? (o/n [n]) "
-95 "o"
-96 "le fichier existe déjà, réécrire ? (o/n) [n] "
-97 "impossible de créer le fichier \"%s\""
-98 "écriture du fichier \"%s\""
-99 "\"%s\" %d lignes, %d caractères"
-100 " ...recherche"
-101 "chaîne \"%s\" non trouvée"
-102 "rechercher : "
-103 "impossible d'exécuter %s"
-104 "tapez entrée pour continuer "
-105 "pressez sur échap. pour annuler"
-106 "menu trop grand pour la fenêtre"
-107 "appuyez sur une touche pour continuer "
-108 "commande du shell : "
-109 "...formattage du paragraphe..."
-110 "<!echo 'liste des mots non reconnus'; echo -=-=-=-=-=-"
-111 "envoi du contenu du buffer à 'spell'"
-112 "colonne de la marge de droite : "
-113 "mode restreint : impossible d'effectuer l'opération demandée"
-114 "OUI"
-115 "NON"
-116 "AIDE"
-117 "ECRIRE"
-118 "LIRE"
-119 "LIGNE"
-120 "FICHIER"
-121 "CARACTERE"
-122 "RAFRAICHIR"
-123 "RENUMEROTER"
-124 "AUTEUR"
-125 "VERSION"
-126 "MINMAJ"
-127 "PASMINMAJ"
-128 "TABS"
-129 "PASTABS"
-130 "FIN"
-131 "QUITTE"
-132 "INFO"
-133 "PASINFO"
-134 "MARGES"
-135 "PASMARGES"
-136 "AUTOFORMAT"
-137 "PASAUTOFORMAT"
-138 "ECHO"
-139 "COMMANDEIMPRESSION"
-140 "MARGEDROITE"
-141 "SURBRILLANT"
-142 "PASSURBRILLANT"
-143 "8BIT"
-144 "PAS8BIT"
-145 "caractères de contrôle comme emacs "
-146 "^a début de ligne ^i tabulation ^r annule effacement mot "
-147 "^b arrière ^j annule eff. caract. ^t début du texte "
-148 "^c commande ^k efface ligne ^u fin du texte "
-149 "^d efface caractère ^l annule eff. ligne ^v page suivante "
-150 "^e fin de ligne ^m nouvelle ligne ^w effacer un mot "
-151 "^f caractère suivant ^n ligne suivante ^x recherche "
-152 "^g page précédente ^o insère caract. ascii ^y rechercher... "
-153 "^h efface en arrière ^p ligne précédente ^z mot suivant "
-154 "^[ (échap.) menu ^y rechercher... ^k efface ligne ^p ligne préc ^g page préc"
-155 "^o code ascii ^x recherche ^l annul. eff.li ^n ligne suiv ^v page suiv"
-156 "^u fin du fichier ^a début de ligne ^w efface mot ^b arrière "
-157 "^t début du texte ^e fin de ligne ^r annul.eff.mot ^f avance 1 caractère "
-158 "^c commande ^d efface caract. ^j annul.eff.car ^z mot suivant "
-159 "EMACS"
-160 "PASEMACS"
-161 " +# positionne le curseur sur la ligne #\n"
-162 "impossible d'écrire .init.ee, configuration non sauvée !"
-163 "configuration de ee sauvée en %s"
-164 "sauvegarde configuration de l'éditeur"
-165 "sauvegarde configuration de ee"
-166 "sauvegarde dans le répertoire courant"
-167 "sauvegarde dans le répertoire d'accueil"
-168 "configuration de ee non sauvée"
-169 "nom de fichier manquant pour ree"
-170 "appuyez sur échap. pour annuler"
-180 "menu trop large pour la fenêtre"
-181 "^^encore^^"
-182 "VVencoreVV"
diff --git a/usr.bin/ee/nls/pl_PL.ISO8859-2/ee.msg b/usr.bin/ee/nls/pl_PL.ISO8859-2/ee.msg
deleted file mode 100644
index d5dfd4b3572e..000000000000
--- a/usr.bin/ee/nls/pl_PL.ISO8859-2/ee.msg
+++ /dev/null
@@ -1,184 +0,0 @@
-$ This file contains the messages for ee ("easy editor"). See the file
-$ ee.i18n.guide for more information
-$
-$ For ee patchlevel 3
-$
-$ $FreeBSD$
-$
-$set 1
-$quote "
-1 "menu Tryb pracy"
-2 "tabulacje na spacje "
-3 "szukaj (ma³e!=du¿e) "
-4 "ustawiony margines "
-5 "auto-formatuj akapit "
-6 "znaki o¶miobitowe "
-7 "okno informacyjne "
-8 "prawy margines "
-9 "wyjd¼ z menu"
-10 "zachowaj zmiany"
-11 "brak zachowania"
-12 "menu Plik"
-13 "wczytaj plik"
-14 "zapisz do pliku"
-15 "zachowaj plik"
-16 "drukuj zawarto¶æ edytora"
-17 "menu Szukanie"
-18 "szukaj ..."
-19 "szukanie"
-20 "menu Pisownia"
-21 "u¿yj 'spell'"
-22 "u¿yj 'ispell'"
-23 "menu Inne"
-24 "formatuj akapit"
-25 "polecenie shell"
-26 "sprawd¼ pisowniê"
-27 "menu g³ówne"
-28 "wyjd¼ z edytora"
-29 "pomoc"
-30 "operacje na plikach"
-31 "od¶wie¿ ekran"
-32 "ustawienia"
-33 "szukanie"
-34 "inne"
-35 "Klawisze kontrolne: "
-36 "^a kod ASCII ^i tabulator ^r w prawo "
-37 "^b na dó³ tekstu ^j nowy wiersz ^t do góry tekstu "
-38 "^c polecenie ^k usuñ znak ^u do góry "
-39 "^d do do³u ^l w lewo ^v przywróæ s³owo "
-40 "^e szukanie ^m nowy wiersz ^w usuñ s³owo "
-41 "^f przywróæ znak ^n nastêpna strona ^x szukaj "
-42 "^g na pocz±tek wiersza ^o na koniec wiersza ^y usuñ wiersz "
-43 "^h backspace ^p poprzednia strona ^z przywróæ wiersz "
-44 "^[ (escape) menu ESC-Enter: wyj¶cie z ee "
-45 " "
-46 "Polecenia: "
-47 "help : wy¶wietl tê informacjê file : wy¶wietl nazwê pliku "
-48 "read : wczytaj plik char : kod ASCII znaku "
-49 "write : zapisz do pliku case : szukaj (ma³e!=du¿e) "
-50 "exit : zachowaj i wyjd¼ nocase : szukaj (ma³e==du¿e) "
-51 "quit : wyjd¼ bez zachowania !cmd : wykonaj \"cmd\" w shellu
- "
-52 "line : wy¶wietl numer wiersza 0-9 : id¼ do wiersza \"#\" "
-53 "expand : rozwiñ tabulacje na spacje noexpand: nie rozwijaj tabulacji "
-54 " "
-55 " ee [-i] [-e] [-h] [plik(i)] "
-56 " -i : bez okna inform. -e : nie rozwijaj tab. -h : bez pod¶wietl."
-57 "^[ (escape) menu ^e szukanie ^y usuñ wiersz ^u do góry ^p poprz. str "
-58 "^a kod ASCII ^x szukaj ^z przywróæ wiersz ^d do do³u ^n nast. str. "
-59 "^b na dó³ tekstu ^g na pocz. wiersza ^w usuñ s³owo ^l w lewo "
-60 "^t do góry tekstu ^o na koniec wiersza ^v przywróæ s³owo ^r w prawo "
-61 "^c polecenie ^k usuñ znak ^f przywróæ znak ESC-Enter: wyj¶cie "
-62 "help : pomoc |file : podaj nazwê pliku |line : numer wiersza"
-63 "read : wczytaj plik |char : kod ASCII znaku |0-9 : id¼ do wr \"#\""
-64 "write: zapisz plik |case : szukaj (ma³e!=du¿e) |exit : zpisz i wyjd¼"
-65 "!cmd : \"cmd\" w shellu |nocase: ma³e==du¿e w szukaniu |quit : wyjd¼, nie
-zapisuj"
-66 "expand: rozwiñ tabulacje na spacje |noexpand: nie rozwijaj tabulacji "
-67 " naci¶nij Escape (^[) do menu"
-68 "brak pliku"
-69 "kod ASCII: "
-70 "wysy³am zawarto¶æ bufora do \"%s\" "
-71 "polecenie: "
-72 "nazwa pliku do zapisania: "
-73 "nazwa pliku do wczytania: "
-74 "znak = %d"
-75 "nieznane polecenie \"%s\""
-76 "podane polecenie nie jest jednoznaczne"
-77 "wiersz %d "
-78 "d³ugo¶æ = %d"
-79 "aktualny plik to \"%s\" "
-80 "sposób u¿ycia: %s [-i] [-e] [-h] [+numer_wiersza] [plik(i)]\n"
-81 " -i zamknij okno informacyjne\n"
-82 " -e nie rozwijaj tabulacji na spacje\n"
-83 " -h nie u¿ywaj pod¶wietleñ\n"
-84 "plik \"%s\" jest katalogiem"
-85 "nowy plik \"%s\""
-86 "nie mogê otworzyæ \"%s\""
-87 "plik \"%s\", %d wierszy"
-88 "koniec wczytywania pliku \"%s\""
-89 "wczytywanie pliku \"%s\""
-90 ", tylko do odczytu"
-91 "plik \"%s\", %d wierszy"
-92 "podaj nazwê pliku: "
-93 "nie podano nazwy pliku: plik nie zosta³ zachowany"
-94 "plik zosta³ zmieniony, jeste¶ pewien? (t/n [n]) "
-95 "t"
-96 "plik ju¿ istnieje, zast±piæ? (t/n) [n] "
-97 "nie mo¿na utworzyæ pliku \"%s\""
-98 "zapisywanie pliku \"%s\""
-99 "\"%s\" %d wierszy, %d znaków"
-100 " ...szukam"
-101 "napis \"%s\" nie zosta³ znaleziony"
-102 "szukaj: "
-103 "nie mo¿na wykonaæ %s"
-104 "naci¶nij Enter ¿eby kontynuowaæ "
-105 "naci¶nij Esc ¿eby anulowaæ"
-106 "menu zbyt du¿e dla tego okna"
-107 "naci¶nij dowolny klawisz "
-108 "polecenie shella: "
-109 "...formatowanie akapitu..."
-110 "<!echo 'lista nieznalezionych s³ów'; echo -=-=-=-=-=-"
-111 "wysy³am zawarto¶æ edytora do programu 'spell'"
-112 "prawy margines: "
-113 "tryb ograniczony: nie mo¿na przeprowadziæ tej operacji"
-114 "ON"
-115 "OFF"
-116 "HELP"
-117 "WRITE"
-118 "READ"
-119 "LINE"
-120 "FILE"
-121 "CHARACTER"
-122 "REDRAW"
-123 "RESEQUENCE"
-124 "AUTHOR"
-125 "VERSION"
-126 "CASE"
-127 "NOCASE"
-128 "EXPAND"
-129 "NOEXPAND"
-130 "EXIT"
-131 "QUIT"
-132 "INFO"
-133 "NOINFO"
-134 "MARGINS"
-135 "NOMARGINS"
-136 "AUTOFORMAT"
-137 "NOAUTOFORMAT"
-138 "ECHO"
-139 "PRINTCOMMAND"
-140 "RIGHTMARGIN"
-141 "HIGHLIGHT"
-142 "NOHIGHLIGHT"
-143 "EIGHTBIT"
-144 "NOEIGHTBIT"
-145 "klawisze emacs "
-146 "^a pocz±tek wiersza ^i tabulacja ^r przywróæ s³owo "
-147 "^b jeden znak wstecz ^j przywróæ znak ^t do góry tekstu "
-148 "^c polecenie ^k usuñ wiersz ^u na dó³ tekstu "
-149 "^d usuñ znak ^l przywróæ wiersz ^v nastêpna strona "
-150 "^e na koniec wiersza ^m nowy wiersz ^w usuñ s³owo "
-151 "^f 1 znak do przodu ^n nastêpny wiersz ^x szukaj "
-152 "^g 1 strona wstecz ^o wstaw znak ASCII ^y szukanie "
-153 "^h backspace ^p poprzedni wiersz ^z nastêpne s³owo "
-154 "^[ (escape) menu ^y szukanie ^k usuñ wiersz ^p <-wiersz ^g <-strona "
-155 "^o kod ASCII ^x szukaj ^l przywr wiersz ^n wiersz-> ^v strona-> "
-156 "^u koniec pliku ^a pocz. wiersza ^w usuñ s³owo ^b 1 znak wstecz "
-157 "^t pocz. tekstu ^e koniec wiersza ^r przywr s³owo ^f 1 znak do przodu "
-158 "^c polecenie ^d usuñ znak ^j przywróæ znak ^z nastêpne s³owo "
-159 "EMACS"
-160 "NIE-EMACS"
-161 " +# umie¶æ kursor w wierszu #\n"
-162 "nie mo¿na otworzyæ .init.ee do zapisu, nie zachowano konfiguracji!"
-163 "konfiguracja ee zachowana do pliku %s"
-164 "zachowaj konfiguracjê edytora"
-165 "zachowaj konfiguracjê ee"
-166 "zachowaj w bie¿±cym katalogu"
-167 "zachowaj w katalogu home"
-168 "nie zachowano konfiguracji ee"
-169 "musisz podaæ nazwê pliku przy wywo³aniu ree"
-170 "naci¶nij Esc ¿eby anulowaæ"
-180 "menu zbyt du¿e dla tego okna"
-181 "^^dalej^^"
-182 "VVdalejVV"
diff --git a/usr.bin/gcore/aoutcore.c b/usr.bin/gcore/aoutcore.c
deleted file mode 100644
index 6ad9568ede3f..000000000000
--- a/usr.bin/gcore/aoutcore.c
+++ /dev/null
@@ -1,342 +0,0 @@
-/*-
- * 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. 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, Berkeley and its contributors.
- * 4. 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 lint
-static const char copyright[] =
-"@(#) Copyright (c) 1992, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)gcore.c 8.2 (Berkeley) 9/23/93";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-/*
- * Originally written by Eric Cooper in Fall 1981.
- * Inspired by a version 6 program by Len Levin, 1978.
- * Several pieces of code lifted from Bill Joy's 4BSD ps.
- * Most recently, hacked beyond recognition for 4.4BSD by Steven McCanne,
- * Lawrence Berkeley Laboratory.
- *
- * Portions of this software were developed by the Computer Systems
- * Engineering group at Lawrence Berkeley Laboratory under DARPA
- * contract BG 91-66 and contributed to Berkeley.
- */
-#include <sys/param.h>
-#include <sys/time.h>
-#include <sys/stat.h>
-#include <sys/proc.h>
-#include <sys/user.h>
-#include <sys/sysctl.h>
-
-#include <machine/vmparam.h>
-
-#include <a.out.h>
-#include <elf.h>
-#include <err.h>
-#include <fcntl.h>
-#include <kvm.h>
-#include <limits.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "extern.h"
-
-static void core __P((int, int, struct kinfo_proc *));
-static void datadump __P((int, int, struct proc *, u_long, int));
-static void killed __P((int));
-static void restart_target __P((void));
-static void usage __P((void)) __dead2;
-static void userdump __P((int, struct proc *, u_long, int));
-
-kvm_t *kd;
-/* XXX undocumented routine, should be in kvm.h? */
-ssize_t kvm_uread __P((kvm_t *, const struct proc *, u_long, char *, size_t));
-
-static int data_offset;
-static pid_t pid;
-
-int
-main(argc, argv)
- int argc;
- char *argv[];
-{
- register struct proc *p;
- struct kinfo_proc *ki = NULL;
- struct exec exec;
- int ch, cnt, efd, fd, sflag, uid;
- char *binfile, *corefile;
- char errbuf[_POSIX2_LINE_MAX], fname[MAXPATHLEN + 1];
- int is_aout;
-
- sflag = 0;
- corefile = NULL;
- while ((ch = getopt(argc, argv, "c:s")) != -1) {
- switch (ch) {
- case 'c':
- corefile = optarg;
- break;
- case 's':
- sflag = 1;
- break;
- default:
- usage();
- break;
- }
- }
- argv += optind;
- argc -= optind;
-
- /* XXX we should check that the pid argument is really a number */
- switch (argc) {
- case 1:
- pid = atoi(argv[0]);
- asprintf(&binfile, "/proc/%d/file", pid);
- if (binfile == NULL)
- errx(1, "allocation failure");
- break;
- case 2:
- pid = atoi(argv[1]);
- binfile = argv[0];
- break;
- default:
- usage();
- }
-
- efd = open(binfile, O_RDONLY, 0);
- if (efd < 0)
- err(1, "%s", binfile);
-
- cnt = read(efd, &exec, sizeof(exec));
- if (cnt != sizeof(exec))
- errx(1, "%s exec header: %s",
- binfile, cnt > 0 ? strerror(EIO) : strerror(errno));
- if (!N_BADMAG(exec)) {
- is_aout = 1;
- /*
- * This legacy a.out support uses the kvm interface instead
- * of procfs.
- */
- kd = kvm_openfiles(0, 0, 0, O_RDONLY, errbuf);
- if (kd == NULL)
- errx(1, "%s", errbuf);
-
- uid = getuid();
-
- ki = kvm_getprocs(kd, KERN_PROC_PID, pid, &cnt);
- if (ki == NULL || cnt != 1)
- errx(1, "%d: not found", pid);
-
- p = &ki->kp_proc;
- if (ki->kp_eproc.e_pcred.p_ruid != uid && uid != 0)
- errx(1, "%d: not owner", pid);
-
- if (p->p_stat == SZOMB)
- errx(1, "%d: zombie", pid);
-
- if (p->p_flag & P_WEXIT)
- errx(1, "%d: process exiting", pid);
- if (p->p_flag & P_SYSTEM) /* Swapper or pagedaemon. */
- errx(1, "%d: system process", pid);
- if (exec.a_text != ptoa(ki->kp_eproc.e_vm.vm_tsize))
- errx(1, "The executable %s does not belong to"
- " process %d!\n"
- "Text segment size (in bytes): executable %ld,"
- " process %d", binfile, pid, exec.a_text,
- ptoa(ki->kp_eproc.e_vm.vm_tsize));
- data_offset = N_DATOFF(exec);
- } else if (IS_ELF(*(Elf_Ehdr *)&exec)) {
- is_aout = 0;
- close(efd);
- } else
- errx(1, "Invalid executable file");
-
- if (corefile == NULL) {
- (void)snprintf(fname, sizeof(fname), "core.%d", pid);
- corefile = fname;
- }
- fd = open(corefile, O_RDWR|O_CREAT|O_TRUNC, DEFFILEMODE);
- if (fd < 0)
- err(1, "%s", corefile);
-
- if (sflag) {
- signal(SIGHUP, killed);
- signal(SIGINT, killed);
- signal(SIGTERM, killed);
- if (kill(pid, SIGSTOP) == -1)
- err(1, "%d: stop signal", pid);
- atexit(restart_target);
- }
-
- if (is_aout)
- core(efd, fd, ki);
- else
- elf_coredump(fd, pid);
-
- (void)close(fd);
- exit(0);
-}
-
-/*
- * core --
- * Build the core file.
- */
-void
-core(efd, fd, ki)
- int efd;
- int fd;
- struct kinfo_proc *ki;
-{
- union {
- struct user user;
- char ubytes[ctob(UPAGES)];
- } uarea;
- struct proc *p = &ki->kp_proc;
- int tsize = ki->kp_eproc.e_vm.vm_tsize;
- int dsize = ki->kp_eproc.e_vm.vm_dsize;
- int ssize = ki->kp_eproc.e_vm.vm_ssize;
- int cnt;
-
- /* Read in user struct */
- cnt = kvm_read(kd, (u_long)p->p_addr, &uarea, sizeof(uarea));
- if (cnt != sizeof(uarea))
- errx(1, "read user structure: %s",
- cnt > 0 ? strerror(EIO) : strerror(errno));
-
- /*
- * Fill in the eproc vm parameters, since these are garbage unless
- * the kernel is dumping core or something.
- */
- uarea.user.u_kproc = *ki;
-
- /* Dump user area */
- cnt = write(fd, &uarea, sizeof(uarea));
- if (cnt != sizeof(uarea))
- errx(1, "write user structure: %s",
- cnt > 0 ? strerror(EIO) : strerror(errno));
-
- /* Dump data segment */
- datadump(efd, fd, p, USRTEXT + ctob(tsize), dsize);
-
- /* Dump stack segment */
- userdump(fd, p, USRSTACK - ctob(ssize), ssize);
-
- /* Dump machine dependent portions of the core. */
- md_core(kd, fd, ki);
-}
-
-void
-datadump(efd, fd, p, addr, npage)
- register int efd;
- register int fd;
- struct proc *p;
- register u_long addr;
- register int npage;
-{
- register int cc, delta;
- char buffer[PAGE_SIZE];
-
- delta = data_offset - addr;
- while (--npage >= 0) {
- cc = kvm_uread(kd, p, addr, buffer, PAGE_SIZE);
- if (cc != PAGE_SIZE) {
- /* Try to read the page from the executable. */
- if (lseek(efd, (off_t)addr + delta, SEEK_SET) == -1)
- err(1, "seek executable: %s", strerror(errno));
- cc = read(efd, buffer, sizeof(buffer));
- if (cc != sizeof(buffer)) {
- if (cc < 0)
- err(1, "read executable");
- else /* Assume untouched bss page. */
- bzero(buffer, sizeof(buffer));
- }
- }
- cc = write(fd, buffer, PAGE_SIZE);
- if (cc != PAGE_SIZE)
- errx(1, "write data segment: %s",
- cc > 0 ? strerror(EIO) : strerror(errno));
- addr += PAGE_SIZE;
- }
-}
-
-static void
-killed(sig)
- int sig;
-{
- restart_target();
- signal(sig, SIG_DFL);
- kill(getpid(), sig);
-}
-
-static void
-restart_target()
-{
- kill(pid, SIGCONT);
-}
-
-void
-userdump(fd, p, addr, npage)
- register int fd;
- struct proc *p;
- register u_long addr;
- register int npage;
-{
- register int cc;
- char buffer[PAGE_SIZE];
-
- while (--npage >= 0) {
- cc = kvm_uread(kd, p, addr, buffer, PAGE_SIZE);
- if (cc != PAGE_SIZE)
- /* Could be an untouched fill-with-zero page. */
- bzero(buffer, PAGE_SIZE);
- cc = write(fd, buffer, PAGE_SIZE);
- if (cc != PAGE_SIZE)
- errx(1, "write stack segment: %s",
- cc > 0 ? strerror(EIO) : strerror(errno));
- addr += PAGE_SIZE;
- }
-}
-
-void
-usage()
-{
- (void)fprintf(stderr, "usage: gcore [-s] [-c core] executable pid\n");
- exit(1);
-}
diff --git a/usr.bin/gprof/amd64.c b/usr.bin/gprof/amd64.c
deleted file mode 100644
index 6a474086a312..000000000000
--- a/usr.bin/gprof/amd64.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include "gprof.h"
-
-/*
- * gprof -c isn't currently supported...
- */
-findcall( parentp , p_lowpc , p_highpc )
- nltype *parentp;
- unsigned long p_lowpc;
- unsigned long p_highpc;
-{
-}
diff --git a/usr.bin/gprof/amd64.h b/usr.bin/gprof/amd64.h
deleted file mode 100644
index 067e019be34c..000000000000
--- a/usr.bin/gprof/amd64.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*-
- * Copyright (c) 1991, 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)i386.h 8.1 (Berkeley) 6/6/93
- */
-
- /*
- * offset (in bytes) of the code from the entry address of a routine.
- * (see asgnsamples for use and explanation.)
- */
-#define OFFSET_OF_CODE 0
-#define UNITS_TO_CODE (OFFSET_OF_CODE / sizeof(UNIT))
-
-enum opermodes { dummy };
-typedef enum opermodes operandenum;
diff --git a/usr.bin/m4/TEST/ack.m4 b/usr.bin/m4/TEST/ack.m4
index ef0b5ef51593..de914bdcb469 100644
--- a/usr.bin/m4/TEST/ack.m4
+++ b/usr.bin/m4/TEST/ack.m4
@@ -1,5 +1,3 @@
-# $OpenBSD: ack.m4,v 1.2 1996/06/26 05:36:18 deraadt Exp $
-# $NetBSD: ack.m4,v 1.4 1995/09/28 05:37:54 tls Exp $
#
# Copyright (c) 1989, 1993
# The Regents of the University of California. All rights reserved.
diff --git a/usr.bin/m4/TEST/hanoi.m4 b/usr.bin/m4/TEST/hanoi.m4
index d16f922ad0d2..9371b3477535 100644
--- a/usr.bin/m4/TEST/hanoi.m4
+++ b/usr.bin/m4/TEST/hanoi.m4
@@ -1,5 +1,3 @@
-# $OpenBSD: hanoi.m4,v 1.2 1996/06/26 05:36:19 deraadt Exp $
-# $NetBSD: hanoi.m4,v 1.4 1995/09/28 05:37:56 tls Exp $
#
# Copyright (c) 1989, 1993
# The Regents of the University of California. All rights reserved.
diff --git a/usr.bin/m4/TEST/hash.m4 b/usr.bin/m4/TEST/hash.m4
index 21b40e140c2f..85d5aa844638 100644
--- a/usr.bin/m4/TEST/hash.m4
+++ b/usr.bin/m4/TEST/hash.m4
@@ -1,5 +1,3 @@
-# $OpenBSD: hash.m4,v 1.2 1996/06/26 05:36:19 deraadt Exp $
-# $NetBSD: hash.m4,v 1.4 1995/09/28 05:37:58 tls Exp $
#
# Copyright (c) 1989, 1993
# The Regents of the University of California. All rights reserved.
diff --git a/usr.bin/m4/TEST/sqroot.m4 b/usr.bin/m4/TEST/sqroot.m4
index d01789bb4d0d..3c7501fa796d 100644
--- a/usr.bin/m4/TEST/sqroot.m4
+++ b/usr.bin/m4/TEST/sqroot.m4
@@ -1,5 +1,3 @@
-# $OpenBSD: sqroot.m4,v 1.2 1996/06/26 05:36:20 deraadt Exp $
-# $NetBSD: sqroot.m4,v 1.4 1995/09/28 05:38:01 tls Exp $
#
# Copyright (c) 1989, 1993
# The Regents of the University of California. All rights reserved.
diff --git a/usr.bin/m4/TEST/string.m4 b/usr.bin/m4/TEST/string.m4
index bb0bba4d1b67..bff741a07fb7 100644
--- a/usr.bin/m4/TEST/string.m4
+++ b/usr.bin/m4/TEST/string.m4
@@ -1,5 +1,3 @@
-# $OpenBSD: string.m4,v 1.2 1996/06/26 05:36:20 deraadt Exp $
-# $NetBSD: string.m4,v 1.4 1995/09/28 05:38:03 tls Exp $
#
# Copyright (c) 1989, 1993
# The Regents of the University of California. All rights reserved.
diff --git a/usr.bin/m4/TEST/test.m4 b/usr.bin/m4/TEST/test.m4
index 1c77b9bdef9d..df8b78c45f75 100644
--- a/usr.bin/m4/TEST/test.m4
+++ b/usr.bin/m4/TEST/test.m4
@@ -1,5 +1,3 @@
-# $OpenBSD: test.m4,v 1.2 1996/06/26 05:36:21 deraadt Exp $
-# $NetBSD: test.m4,v 1.4 1995/09/28 05:38:05 tls Exp $
#
# Copyright (c) 1989, 1993
# The Regents of the University of California. All rights reserved.
diff --git a/usr.bin/m4/pathnames.h b/usr.bin/m4/pathnames.h
index dc7f0d3dff54..72f66d37ea67 100644
--- a/usr.bin/m4/pathnames.h
+++ b/usr.bin/m4/pathnames.h
@@ -1,6 +1,3 @@
-/* $OpenBSD: pathnames.h,v 1.4 1997/04/04 18:41:29 deraadt Exp $ */
-/* $NetBSD: pathnames.h,v 1.6 1995/09/29 00:27:55 cgd Exp $ */
-
/*
* Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -49,8 +46,8 @@
#define UNIQUE 3 /* unique char location */
#endif
-#if defined(unix) || defined(__NetBSD__) || defined(__OpenBSD__)
-#define _PATH_DIVNAME "/tmp/m4.0XXXXXXXXXX" /* unix diversion files */
+#ifdef unix
+#define _PATH_DIVNAME "/tmp/m4.0XXXXXX" /* unix diversion files */
#define UNIQUE 8 /* unique char location */
#endif
diff --git a/usr.bin/makewhatis/makewhatis.local.8 b/usr.bin/makewhatis/makewhatis.local.8
deleted file mode 100644
index 81a6e1fb66b3..000000000000
--- a/usr.bin/makewhatis/makewhatis.local.8
+++ /dev/null
@@ -1,80 +0,0 @@
-.\" Copyright (c) April 1996 Wolfram Schneider <wosch@FreeBSD.org>. Berlin.
-.\" 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 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 AUTHOR 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.
-.\"
-.\" $FreeBSD$
-.Dd April 26, 1996
-.Dt MAKEWHATIS.LOCAL 8
-.Os FreeBSD 2.2
-.Sh NAME
-.Nm makewhatis.local , catman.local
-.Nd start makewhatis or catman for local file systems
-.Sh SYNOPSIS
-.Nm /usr/libexec/makewhatis.local
-.Op options
-.Ar directories ...
-.Nm /usr/libexec/catman.local
-.Op options
-.Ar directories ...
-.Sh DESCRIPTION
-.Nm
-start
-.Xr makewhatis 1
-only for file systems physically mounted on the system
-where the
-.Nm
-is being executed. Running makewhatis
-by
-.Pa periodic weekly
-for rw nfs-mounted /usr may kill
-your NFS server -- all NFS clients start makewhatis at the same time!
-So use this wrapper for
-.Xr cron 8
-instead of calling makewhatis directly.
-.Nm catman.local
-is using for same purposes as
-.Nm makewhatis.local
-but for
-.Xr catman 1 .
-.Sh FILES
-.Bl -tag -width /etc/periodic/weekly/320.whatis.XXX -compact
-.It Pa /etc/periodic/weekly/320.whatis
-run
-.Nm makewhatis.local
-every week
-.It Pa /etc/periodic/weekly/330.catman
-run
-.Nm catman.local
-every week
-.El
-.Sh SEE ALSO
-.Xr catman 1 ,
-.Xr find 1 ,
-.Xr makewhatis 1 ,
-.Xr cron 8 ,
-.Xr periodic 8 .
-.Sh HISTORY
-The
-.Nm
-command appeared in
-.Fx 2.2 .
diff --git a/usr.bin/truss/amd64-fbsd32.c b/usr.bin/truss/amd64-fbsd32.c
deleted file mode 100644
index 463f475cefaf..000000000000
--- a/usr.bin/truss/amd64-fbsd32.c
+++ /dev/null
@@ -1,311 +0,0 @@
-/*
- * Copryight 1997 Sean Eric Fagan
- *
- * 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 Sean Eric Fagan
- * 4. Neither the name of the author may be used to endorse or promote
- * products derived from this software without specific prior written
- * permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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 lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-/*
- * FreeBSD/386-specific system call handling. This is probably the most
- * complex part of the entire truss program, although I've got lots of
- * it handled relatively cleanly now. The system call names are generated
- * automatically, thanks to /usr/src/sys/kern/syscalls.master. The
- * names used for the various structures are confusing, I sadly admit.
- */
-
-#include <errno.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/ioctl.h>
-#include <sys/pioctl.h>
-#include <machine/reg.h>
-#include <machine/psl.h>
-#include <sys/syscall.h>
-
-#include "syscall.h"
-
-static int fd = -1;
-static int cpid = -1;
-extern int Procfd;
-
-extern FILE *outfile;
-#include "syscalls.h"
-
-static int nsyscalls = sizeof(syscallnames) / sizeof(syscallnames[0]);
-
-/*
- * This is what this particular file uses to keep track of a system call.
- * It is probably not quite sufficient -- I can probably use the same
- * structure for the various syscall personalities, and I also probably
- * need to nest system calls (for signal handlers).
- *
- * 'struct syscall' describes the system call; it may be NULL, however,
- * if we don't know about this particular system call yet.
- */
-static struct freebsd_syscall {
- struct syscall *sc;
- char *name;
- int number;
- unsigned long *args;
- int nargs; /* number of arguments -- *not* number of words! */
- char **s_args; /* the printable arguments */
-} fsc;
-
-/* Clear up and free parts of the fsc structure. */
-static inline void
-clear_fsc() {
- if (fsc.args) {
- free(fsc.args);
- }
- if (fsc.s_args) {
- int i;
- for (i = 0; i < fsc.nargs; i++)
- if (fsc.s_args[i])
- free(fsc.s_args[i]);
- free(fsc.s_args);
- }
- memset(&fsc, 0, sizeof(fsc));
-}
-
-/*
- * Called when a process has entered a system call. nargs is the
- * number of words, not number of arguments (a necessary distinction
- * in some cases). Note that if the STOPEVENT() code in i386/i386/trap.c
- * is ever changed these functions need to keep up.
- */
-
-void
-i386_syscall_entry(int pid, int nargs) {
- char buf[32];
- struct reg regs = { 0 };
- int syscall;
- int i;
- unsigned int parm_offset;
- struct syscall *sc;
-
- if (fd == -1 || pid != cpid) {
- sprintf(buf, "/proc/%d/regs", pid);
- fd = open(buf, O_RDWR);
- if (fd == -1) {
- fprintf(outfile, "-- CANNOT READ REGISTERS --\n");
- return;
- }
- cpid = pid;
- }
-
- clear_fsc();
- lseek(fd, 0L, 0);
- i = read(fd, &regs, sizeof(regs));
- parm_offset = regs.r_esp + sizeof(int);
-
- /*
- * FreeBSD has two special kinds of system call redirctions --
- * SYS_syscall, and SYS___syscall. The former is the old syscall()
- * routine, basicly; the latter is for quad-aligned arguments.
- */
- syscall = regs.r_eax;
- switch (syscall) {
- case SYS_syscall:
- lseek(Procfd, parm_offset, SEEK_SET);
- read(Procfd, &syscall, sizeof(int));
- parm_offset += sizeof(int);
- break;
- case SYS___syscall:
- lseek(Procfd, parm_offset, SEEK_SET);
- read(Procfd, &syscall, sizeof(int));
- parm_offset += sizeof(quad_t);
- break;
- }
-
- fsc.number = syscall;
- fsc.name =
- (syscall < 0 || syscall > nsyscalls) ? NULL : syscallnames[syscall];
- if (!fsc.name) {
- fprintf(outfile, "-- UNKNOWN SYSCALL %d --\n", syscall);
- }
-
- if (nargs == 0)
- return;
-
- fsc.args = malloc((1+nargs) * sizeof(unsigned long));
- lseek(Procfd, parm_offset, SEEK_SET);
- if (read(Procfd, fsc.args, nargs * sizeof(unsigned long)) == -1)
- return;
-
- sc = get_syscall(fsc.name);
- if (sc) {
- fsc.nargs = sc->nargs;
- } else {
-#if DEBUG
- fprintf(outfile, "unknown syscall %s -- setting args to %d\n",
- fsc.name, nargs);
-#endif
- fsc.nargs = nargs;
- }
-
- fsc.s_args = malloc((1+fsc.nargs) * sizeof(char*));
- memset(fsc.s_args, 0, fsc.nargs * sizeof(char*));
- fsc.sc = sc;
-
- /*
- * At this point, we set up the system call arguments.
- * We ignore any OUT ones, however -- those are arguments that
- * are set by the system call, and so are probably meaningless
- * now. This doesn't currently support arguments that are
- * passed in *and* out, however.
- */
-
- if (fsc.name) {
-
-#if DEBUG
- fprintf(stderr, "syscall %s(", fsc.name);
-#endif
- for (i = 0; i < fsc.nargs; i++) {
-#if DEBUG
- fprintf(stderr, "0x%x%s",
- sc
- ? fsc.args[sc->args[i].offset]
- : fsc.args[i],
- i < (fsc.nargs -1) ? "," : "");
-#endif
- if (sc && !(sc->args[i].type & OUT)) {
- fsc.s_args[i] = print_arg(Procfd, &sc->args[i], fsc.args);
- }
- }
-#if DEBUG
- fprintf(stderr, ")\n");
-#endif
- }
-
-#if DEBUG
- fprintf(outfile, "\n");
-#endif
-
- /*
- * Some system calls should be printed out before they are done --
- * execve() and exit(), for example, never return. Possibly change
- * this to work for any system call that doesn't have an OUT
- * parameter?
- */
-
- if (!strcmp(fsc.name, "execve") || !strcmp(fsc.name, "exit")) {
- print_syscall(outfile, fsc.name, fsc.nargs, fsc.s_args);
- }
-
- return;
-}
-
-/*
- * And when the system call is done, we handle it here.
- * Currently, no attempt is made to ensure that the system calls
- * match -- this needs to be fixed (and is, in fact, why S_SCX includes
- * the sytem call number instead of, say, an error status).
- */
-
-void
-i386_syscall_exit(int pid, int syscall) {
- char buf[32];
- struct reg regs;
- int retval;
- int i;
- int errorp;
- struct syscall *sc;
-
- if (fd == -1 || pid != cpid) {
- sprintf(buf, "/proc/%d/regs", pid);
- fd = open(buf, O_RDONLY);
- if (fd == -1) {
- fprintf(outfile, "-- CANNOT READ REGISTERS --\n");
- return;
- }
- cpid = pid;
- }
-
- lseek(fd, 0L, 0);
- if (read(fd, &regs, sizeof(regs)) != sizeof(regs))
- return;
- retval = regs.r_eax;
- errorp = !!(regs.r_eflags & PSL_C);
-
- /*
- * This code, while simpler than the initial versions I used, could
- * stand some significant cleaning.
- */
-
- sc = fsc.sc;
- if (!sc) {
- for (i = 0; i < fsc.nargs; i++) {
- fsc.s_args[i] = malloc(12);
- sprintf(fsc.s_args[i], "0x%lx", fsc.args[i]);
- }
- } else {
- /*
- * Here, we only look for arguments that have OUT masked in --
- * otherwise, they were handled in the syscall_entry function.
- */
- for (i = 0; i < sc->nargs; i++) {
- char *temp;
- if (sc->args[i].type & OUT) {
- /*
- * If an error occurred, than don't bothe getting the data;
- * it may not be valid.
- */
- if (errorp) {
- temp = malloc(12);
- sprintf(temp, "0x%lx", fsc.args[sc->args[i].offset]);
- } else {
- temp = print_arg(Procfd, &sc->args[i], fsc.args);
- }
- fsc.s_args[i] = temp;
- }
- }
- }
-
- /*
- * It would probably be a good idea to merge the error handling,
- * but that complicates things considerably.
- */
-
- print_syscall(outfile, fsc.name, fsc.nargs, fsc.s_args);
- if (errorp) {
- fprintf(outfile, "errno %d '%s'\n", retval, strerror(retval));
- } else {
- fprintf(outfile, "returns %d (0x%x)\n", retval, retval);
- }
- clear_fsc();
-
- return;
-}
diff --git a/usr.bin/truss/amd64-linux32.c b/usr.bin/truss/amd64-linux32.c
deleted file mode 100644
index ec7632b83e0d..000000000000
--- a/usr.bin/truss/amd64-linux32.c
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * Copryight 1997 Sean Eric Fagan
- *
- * 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 Sean Eric Fagan
- * 4. Neither the name of the author may be used to endorse or promote
- * products derived from this software without specific prior written
- * permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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 lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-/*
- * Linux/i386-specific system call handling. Given how much of this code
- * is taken from the freebsd equivalent, I can probably put even more of
- * it in support routines that can be used by any personality support.
- */
-
-#include <errno.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/ioctl.h>
-#include <sys/pioctl.h>
-#include <machine/reg.h>
-#include <machine/psl.h>
-
-#include "syscall.h"
-
-static int fd = -1;
-static int cpid = -1;
-extern int Procfd;
-
-extern FILE *outfile;
-#include "linux_syscalls.h"
-
-static int nsyscalls =
- sizeof(linux_syscallnames) / sizeof(linux_syscallnames[0]);
-
-/* See the comment in i386-fbsd.c about this structure. */
-static struct linux_syscall {
- struct syscall *sc;
- char *name;
- int number;
- unsigned long args[5];
- int nargs; /* number of arguments -- *not* number of words! */
- char **s_args; /* the printable arguments */
-} lsc;
-
-static inline void
-clear_lsc() {
- if (lsc.s_args) {
- int i;
- for (i = 0; i < lsc.nargs; i++)
- if (lsc.s_args[i])
- free(lsc.s_args[i]);
- free(lsc.s_args);
- }
- memset(&lsc, 0, sizeof(lsc));
-}
-
-void
-i386_linux_syscall_entry(int pid, int nargs) {
- char buf[32];
- struct reg regs = { 0 };
- int syscall;
- int i;
- struct syscall *sc;
-
- if (fd == -1 || pid != cpid) {
- sprintf(buf, "/proc/%d/regs", pid);
- fd = open(buf, O_RDWR);
- if (fd == -1) {
- fprintf(outfile, "-- CANNOT READ REGISTERS --\n");
- return;
- }
- cpid = pid;
- }
-
- clear_lsc();
- lseek(fd, 0L, 0);
- i = read(fd, &regs, sizeof(regs));
- syscall = regs.r_eax;
-
- lsc.number = syscall;
- lsc.name =
- (syscall < 0 || syscall > nsyscalls) ? NULL : linux_syscallnames[syscall];
- if (!lsc.name) {
- fprintf (outfile, "-- UNKNOWN SYSCALL %d\n", syscall);
- }
-
- if (nargs == 0)
- return;
-
- /*
- * Linux passes syscall arguments in registers, not
- * on the stack. Fortunately, we've got access to the
- * register set. Note that we don't bother checking the
- * number of arguments. And what does linux do for syscalls
- * that have more than five arguments?
- */
-
- lsc.args[0] = regs.r_ebx;
- lsc.args[1] = regs.r_ecx;
- lsc.args[2] = regs.r_edx;
- lsc.args[3] = regs.r_esi;
- lsc.args[4] = regs.r_edi;
-
- sc = get_syscall(lsc.name);
- if (sc) {
- lsc.nargs = sc->nargs;
- } else {
-#ifdef DEBUG
- fprintf(outfile, "unknown syscall %s -- setting args to %d\n",
- lsc.name, nargs);
-#endif
- lsc.nargs = nargs;
- }
-
- lsc.s_args = malloc((1+lsc.nargs) * sizeof(char*));
- memset(lsc.s_args, 0, lsc.nargs * sizeof(char*));
- lsc.sc = sc;
-
- if (lsc.name) {
-
-#ifdef DEBUG
- fprintf(stderr, "syscall %s(", lsc.name);
-#endif
- for (i = 0; i < lsc.nargs ; i++) {
-#ifdef DEBUG
- fprintf(stderr, "0x%x%s",
- sc ?
- lsc.args[sc->args[i].offset]
- : lsc.args[i],
- i < (lsc.nargs - 1) ? "," : "");
-#endif
- if (sc && !(sc->args[i].type & OUT)) {
- lsc.s_args[i] = print_arg(Procfd, &sc->args[i], lsc.args);
- }
- }
-#ifdef DEBUG
- fprintf(stderr, ")\n");
-#endif
- }
-
- if (!strcmp(lsc.name, "linux_execve") || !strcmp(lsc.name, "exit")) {
- print_syscall(outfile, lsc.name, lsc.nargs, lsc.s_args);
- }
-
- return;
-}
-
-/*
- * Linux syscalls return negative errno's, we do positive and map them
- */
-int bsd_to_linux_errno[] = {
- -0, -1, -2, -3, -4, -5, -6, -7, -8, -9,
- -10, -35, -12, -13, -14, -15, -16, -17, -18, -19,
- -20, -21, -22, -23, -24, -25, -26, -27, -28, -29,
- -30, -31, -32, -33, -34, -11,-115,-114, -88, -89,
- -90, -91, -92, -93, -94, -95, -96, -97, -98, -99,
- -100,-101,-102,-103,-104,-105,-106,-107,-108,-109,
- -110,-111, -40, -36,-112,-113, -39, -11, -87,-122,
- -116, -66, -6, -6, -6, -6, -6, -37, -38, -9,
- -6,
-};
-
-void
-i386_linux_syscall_exit(int pid, int syscall) {
- char buf[32];
- struct reg regs;
- int retval;
- int i;
- int errorp;
- struct syscall *sc;
-
- if (fd == -1 || pid != cpid) {
- sprintf(buf, "/proc/%d/regs", pid);
- fd = open(buf, O_RDONLY);
- if (fd == -1) {
- fprintf(outfile, "-- CANNOT READ REGISTERS --\n");
- return;
- }
- cpid = pid;
- }
-
- lseek(fd, 0L, 0);
- if (read(fd, &regs, sizeof(regs)) != sizeof(regs))
- return;
-
- retval = regs.r_eax;
- errorp = !!(regs.r_eflags & PSL_C);
-
- sc = lsc.sc;
- if (!sc) {
- for (i = 0; i < lsc.nargs; i++) {
- lsc.s_args[i] = malloc(12);
- sprintf(lsc.s_args[i], "0x%lx", lsc.args[i]);
- }
- } else {
- for (i = 0; i < sc->nargs; i++) {
- char *temp;
- if (sc->args[i].type & OUT) {
- if (errorp) {
- temp = malloc(12);
- sprintf(temp, "0x%lx", lsc.args[sc->args[i].offset]);
- } else {
- temp = print_arg(Procfd, &sc->args[i], lsc.args);
- }
- lsc.s_args[i] = temp;
- }
- }
- }
- print_syscall(outfile, lsc.name, lsc.nargs, lsc.s_args);
- if (errorp) {
- for (i = 0; i < sizeof(bsd_to_linux_errno) / sizeof(int); i++)
- if (retval == bsd_to_linux_errno[i])
- break;
- fprintf(outfile, "errno %d '%s'\n", retval, strerror(i));
- } else {
- fprintf(outfile, "returns %d (0x%x)\n", retval, retval);
- }
- clear_lsc();
- return;
-}
diff --git a/usr.bin/window/mystring.h b/usr.bin/window/mystring.h
deleted file mode 100644
index 08cae5677b63..000000000000
--- a/usr.bin/window/mystring.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 1983, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Edward Wang at The University of California, Berkeley.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)string.h 8.1 (Berkeley) 6/6/93
- */
-
-#define STR_DEBUG
-
-char *str_cpy();
-char *str_ncpy();
-char *str_cat();
-char *str_itoa();
-
-#define str_cmp(a, b) strcmp(a, b)
-
-#ifdef STR_DEBUG
-struct string {
- struct string *s_forw;
- struct string *s_back;
- char s_data[1];
-};
-
-struct string str_head;
-
-#define str_offset ((unsigned)str_head.s_data - (unsigned)&str_head)
-#define str_stos(s) ((struct string *)((unsigned)(s) - str_offset))
-
-char *str_alloc();
-int str_free();
-#else
-#define str_free(s) free(s)
-#define str_alloc(s) malloc(s)
-#endif
diff --git a/usr.sbin/mount_nwfs/Makefile b/usr.sbin/mount_nwfs/Makefile
deleted file mode 100644
index 53405963beb7..000000000000
--- a/usr.sbin/mount_nwfs/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-# $FreeBSD$
-
-PROG= mount_nwfs
-SRCS= mount_nwfs.c getmntopts.c
-MAN8= mount_nwfs.8
-
-MOUNT= ${.CURDIR}/../mount
-CFLAGS+= -DNWFS -I${MOUNT}
-
-.PATH: ${MOUNT}
-
-LDADD+= -lncp -lipx
-DPADD+= ${LIBIPX} ${LIBNCP}
-
-.include <bsd.prog.mk>
diff --git a/usr.sbin/mount_nwfs/mount_nwfs.8 b/usr.sbin/mount_nwfs/mount_nwfs.8
deleted file mode 100644
index b56d26c8e301..000000000000
--- a/usr.sbin/mount_nwfs/mount_nwfs.8
+++ /dev/null
@@ -1,224 +0,0 @@
-.\" $FreeBSD$
-.Dd Oct 14, 1999
-.Dt MOUNT_NWFS 8
-.Os FreeBSD 4.0
-.Sh NAME
-.Nm mount_nwfs
-.Nd mount NetWare volume from a NetWare file server
-.Sh SYNOPSIS
-.Nm mount_nwfs
-.Op Fl Chv
-.Fl S Ar server
-.Fl U Ar user
-.Op Fl connection\ options
-.Fl V Ar volume
-.Op Fl M Ar mode
-.Op Fl c Ar case
-.Op Fl d Ar mode
-.Op Fl f Ar mode
-.Op Fl g Ar gid
-.Op Fl l Ar locale
-.Op Fl n Ar os2
-.Op Fl u Ar uid
-.Op Fl w Ar scheme
-.Ar node
-.Nm mount_nwfs
-.Op Fl options
-.Ar /server:user/volume[/path]
-.Ar node
-.Sh DESCRIPTION
-The
-.Nm
-command allows to mount volume from a NetWare server.
-It may use either
-existing connection or create new: if no usable connection was found
-it will try to establish a new one.
-Connection has count of references to it,
-so when last mount will be dismounted connection will be closed.
-It is
-possible to create connection without any mounts (but use it for them) with
-.Xr ncplogin 1 .
-.Pp
-Note two forms of command line.
-In the first form, server and user specified
-via
-.Fl S
-and
-.Fl U
-options respectively.
-In the second form server and user specified in
-.Ar special
-part of
-.Xr mount 8
-command line arguments (the
-.Fl S ,
-.Fl U
-and
-.Fl V
-options aren't used in this case). This allows use of
-.Xr fstab 5
-file (see
-.Sx EXAMPLES
-below).
-.Pp
-The options are:
-.Bl -tag -width indent
-.It Fl S Ar server
-Name of NetWare server to connect.
-For native IP you will need also
-.Fl A
-option.
-.It Fl U Ar user
-Name of user used in login sequence.
-.It Fl "[connection options]"
-See
-.Xr ncplogin 1
-for details.
-.It Fl V Ar volume
-Volume name to mount.
-Volume name can also be specified after all options and
-before
-.Ar mount-point .
-.It Ar node
-Path to mount volume.
-.It Fl c Ar case
-Select a
-.Ar case
-option which affects on name representation.
-.Ar Case
-can be one of the following:
-.Bl -tag -width "ValueXX"
-.It Em Value
-.Em Meaning
-.It l
-All existing file names converted to lower case.
-Newly created file gets a lower case under OS2 name space.
-This is the default when mounting volumes with DOS name space.
-.It L
-Same as 'l' but file system tries to be case insensitive.
-May not work well.
-.It n
-No case conversion is performed.
-.Em Warning!
-Use this option with DOS name space only as a last resort,
-because creating a lower case name in the DOS name space
-can lead to unpredictable results.
-This is the default when mounting volumes with OS2 name space.
-.It u
-All existing file names converted to upper case.
-Newly created file gets an upper case under OS2 name space.
-.It U
-Same as 'u' but file system tries to be case insensitive.
-May not work well.
-.El
-.It Fl f Ar mode , Fl d Ar mode
-Specify permissions that should be assigned to files and directories.
-The values must be specified as octal numbers.
-Default value for the file mode
-is taken from mount point, default value for the dir mode adds execute
-permission where the file mode gives read permission.
-
-Note that these permissions can differ from the rights granted by NetWare
-server.
-.It Fl n Ar namespace
-Don't use
-.Ar namespace .
-Currently only
-.Ar OS2
-can be here.
-.It Fl v
-Print version number.
-.It Fl u Ar uid , Fl g Ar gid
-User id and group id assigned to files.
-The default is owner and group id from
-directory where volume is mounted.
-.It Fl l Ar locale
-Set the locale for case conversion.
-By default
-.Nm
-tries to use an environment variable
-.Ev LC_* .
-.It Fl w Ar scheme
-Select a
-.Ar scheme
-used to convert file names between NetWare and
-.Fx .
-Currently only
-.Ar koi2cp866
-and
-.Ar asis
-can be here.
-Please note, that scheme should be enabled at compile
-time in
-.Pa config.mk
-file.
-.It Fl M Ar mode
-See
-.Xr ncplogin 1
-for details.
-If this option is omitted, connection permissions
-assumed the same as directory mode
-.Pf ( Fl d Ns ) option.
-.El
-.Sh FILES
-.Bl -tag -width /var/log/wtmp -compact
-.It Pa ~/.nwfsrc
-keeps static parameters for connections and other information.
-See
-.Pa /usr/share/examples/nwclient/dot.nwfsrc
-for details.
-.El
-.Sh NOTES
-Before any NCP connection can be established kernel must be configured
-for IPX support, IPXrouted and KLD nwfs.ko should be loaded.
-.Sh EXAMPLES
-Next examples illustrates how to connect to NetWare server
-.Em nwserv
-as user
-.Em GUEST
-and mount volumes
-.Em SYS
-and
-.Em VOL1 :
-.Bd -literal -offset indent
-mount_nwfs -S nwserv -U guest -V sys /nw/s1/sys
-mount_nwfs /nwserv:guest/sys /nw/s1/sys
-mount -t nwfs /nwserv:guest/vol1 /nw/s1/vol1
-mount -t nwfs /nwserv:boris/sys/home/boris /home/boris/nw/home
-.Ed
-.Pp
-The last example mounts only subdirectory on a volume and equivalent
-to NetWare 'map root' command.
-.Pp
-It is possible to use
-.Xr fstab 5
-for nwfs mounts:
-.Bd -literal -offset indent
-/nwserv:guest/sys /nw/s1/sys nwfs rw,noauto 0 0
-/nwserv:guest/vol1 /nw/s1/vol2 nwfs rw,noauto 0 0
-.Ed
-
-.Sh BUGS
-to number a few
-
-.Sh CREDITS
-In development of NetWare client for
-.Fx ,
-the following sources were used:
-.Pp
-Documentation from NetWare NDK.
-.Pp
-Ncpfs for Linux - written by
-.An Volker Lendecke Aq lendecke@math.uni-goettingen.de .
-He granted me permission to publish parts of his code under BSD-style license,
-.Pp
-"Interrupt List" from
-.An Ralf Brown ,
-.Pp
-Many files from
-.Pa /sys
-directory.
-
-.Sh AUTHORS
-.An Boris Popov Aq bp@butya.kz ,
-.Aq rbp@chat.ru
diff --git a/usr.sbin/mount_nwfs/mount_nwfs.c b/usr.sbin/mount_nwfs/mount_nwfs.c
deleted file mode 100644
index 7fb1ba9c58d7..000000000000
--- a/usr.sbin/mount_nwfs/mount_nwfs.c
+++ /dev/null
@@ -1,358 +0,0 @@
-/*
- * Copyright (c) 1999, Boris Popov
- * 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 Boris Popov.
- * 4. Neither the name of the author nor the names of any co-contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <sys/errno.h>
-#include <sys/mount.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <pwd.h>
-#include <grp.h>
-#include <unistd.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include <err.h>
-#include <sysexits.h>
-
-#include <netncp/ncp_lib.h>
-#include <netncp/ncp_rcfile.h>
-#include <nwfs/nwfs_mount.h>
-#include "mntopts.h"
-
-#define NWFS_VFSNAME "nwfs"
-
-static char mount_point[MAXPATHLEN + 1];
-static void usage(void);
-static int parsercfile(struct ncp_conn_loginfo *li, struct nwfs_args *mdata);
-
-static struct mntopt mopts[] = {
- MOPT_STDOPTS,
- { NULL }
-};
-
-static int
-parsercfile(struct ncp_conn_loginfo *li, struct nwfs_args *mdata) {
- return 0;
-}
-
-int
-main(int argc, char *argv[]) {
- int opt, error, mntflags, nlsopt;
- char *p, *p1, tmp[1024];
- u_char *pv;
- NWCONN_HANDLE connHandle;
- struct nwfs_args mdata;
- struct ncp_conn_loginfo li;
- struct stat st;
- struct vfsconf vfc;
- struct nw_entry_info einfo;
-
- if (argc < 2)
- usage();
- if (argc == 2) {
- if (strcmp(argv[1], "-h") == 0) {
- usage();
- } else if (strcmp(argv[1], "-v") == 0) {
- errx(EX_OK, "version %d.%d.%d", NWFS_VERSION / 100000,
- (NWFS_VERSION % 10000) / 1000,
- (NWFS_VERSION % 1000) / 100);
- }
- }
-
- error = getvfsbyname(NWFS_VFSNAME, &vfc);
- if (error && vfsisloadable(NWFS_VFSNAME)) {
- if(vfsload(NWFS_VFSNAME))
- err(EX_OSERR, "vfsload("NWFS_VFSNAME")");
- endvfsent();
- error = getvfsbyname(NWFS_VFSNAME, &vfc);
- }
- if (error)
- errx(EX_OSERR, "NetWare filesystem is not available");
-
- if(ncp_initlib()) exit(1);
-
- mntflags = error = 0;
- bzero(&mdata,sizeof(mdata));
- mdata.uid = mdata.gid = -1;
- nlsopt = 0;
-
- if (ncp_li_init(&li, argc, argv)) return 1;
- /*
- * A little bit weird, but I should figure out which server/user to use
- * _before_ reading .rc file
- */
- if (argc >= 3 && argv[argc-1][0] != '-' && argv[argc-2][0] != '-' &&
- argv[argc-2][0] == '/') {
- p = argv[argc-2];
- error = 1;
- do {
- if (*p++ != '/') break;
- p1 = tmp;
- while (*p != ':' && *p != 0) *p1++ = *p++;
- if (*p++ == 0) break;
- *p1 = 0;
- if (ncp_li_setserver(&li, tmp)) break;
- p1 = tmp;
- while (*p != '/' && *p != 0) *p1++ = *p++;
- if (*p++ == 0) break;
- *p1 = 0;
- if (ncp_li_setuser(&li, tmp)) break;
- p1 = tmp;
- while (*p != '/' && *p != 0) *p1++ = *p++;
- *p1 = 0;
- if (strlen(tmp) > NCP_VOLNAME_LEN) {
- warnx("volume name too long: %s", tmp);
- break;
- }
- ncp_str_upper(strcpy(mdata.mounted_vol,tmp));
- if (*p == '/')
- p++;
- p1 = mdata.root_path + 2;
- pv = mdata.root_path + 1;
- for(;*p;) {
- *pv = 0;
- while (*p != '/' && *p) {
- *p1++ = *p++;
- (*pv)++;
- }
- if (*pv) {
- ncp_nls_mem_u2n(pv + 1, pv + 1, *pv);
- pv += (*pv) + 1;
- mdata.root_path[0]++;
- }
- if (*p++ == 0) break;
- p1++;
- }
- error = 0;
- } while(0);
- if (error)
- errx(EX_DATAERR,
- "an error occurred while parsing '%s'",
- argv[argc - 2]);
- }
- if (ncp_li_readrc(&li)) return 1;
- if (ncp_rc) {
- parsercfile(&li,&mdata);
- rc_close(ncp_rc);
- }
- while ((opt = getopt(argc, argv, STDPARAM_OPT"V:c:d:f:g:l:n:o:u:w:")) != -1) {
- switch (opt) {
- case STDPARAM_ARGS:
- if (ncp_li_arg(&li, opt, optarg)) {
- return 1;
- }
- break;
- case 'V':
- if (strlen(optarg) > NCP_VOLNAME_LEN)
- errx(EX_DATAERR, "volume too long: %s", optarg);
- ncp_str_upper(strcpy(mdata.mounted_vol,optarg));
- break;
- case 'u': {
- struct passwd *pwd;
-
- pwd = isdigit(optarg[0]) ?
- getpwuid(atoi(optarg)) : getpwnam(optarg);
- if (pwd == NULL)
- errx(EX_NOUSER, "unknown user '%s'", optarg);
- mdata.uid = pwd->pw_uid;
- break;
- }
- case 'g': {
- struct group *grp;
-
- grp = isdigit(optarg[0]) ?
- getgrgid(atoi(optarg)) : getgrnam(optarg);
- if (grp == NULL)
- errx(EX_NOUSER, "unknown group '%s'", optarg);
- mdata.gid = grp->gr_gid;
- break;
- }
- case 'd':
- errno = 0;
- mdata.dir_mode = strtol(optarg, &p, 8);
- if (errno || *p != 0)
- errx(EX_DATAERR, "invalid value for directory mode");
- break;
- case 'f':
- errno = 0;
- mdata.file_mode = strtol(optarg, &p, 8);
- if (errno || *p != 0)
- errx(EX_DATAERR, "invalid value for file mode");
- break;
- case '?':
- usage();
- /*NOTREACHED*/
- case 'n': {
- char *inp, *nsp;
-
- nsp = inp = optarg;
- while ((nsp = strsep(&inp, ",;:")) != NULL) {
- if (strcasecmp(nsp, "OS2") == 0)
- mdata.flags |= NWFS_MOUNT_NO_OS2;
- else if (strcasecmp(nsp, "LONG") == 0)
- mdata.flags |= NWFS_MOUNT_NO_LONG;
- else if (strcasecmp(nsp, "NFS") == 0)
- mdata.flags |= NWFS_MOUNT_NO_NFS;
- else
- errx(EX_DATAERR, "unknown namespace '%s'", nsp);
- }
- break;
- };
- case 'l':
- if (ncp_nls_setlocale(optarg) != 0) return 1;
- mdata.flags |= NWFS_MOUNT_HAVE_NLS;
- break;
- case 'o':
- getmntopts(optarg, mopts, &mntflags, 0);
- break;
- case 'c':
- switch (optarg[0]) {
- case 'l':
- nlsopt |= NWHP_LOWER;
- break;
- case 'u':
- nlsopt |= NWHP_UPPER;
- break;
- case 'n':
- nlsopt |= NWHP_LOWER | NWHP_UPPER;
- break;
- case 'L':
- nlsopt |= NWHP_LOWER | NWHP_NOSTRICT;
- break;
- case 'U':
- nlsopt |= NWHP_UPPER | NWHP_NOSTRICT;
- break;
- default:
- errx(EX_DATAERR, "invalid suboption '%c' for -c",
- optarg[0]);
- }
- break;
- case 'w':
- if (ncp_nls_setrecodebyname(optarg) != 0)
- return 1;
- mdata.flags |= NWFS_MOUNT_HAVE_NLS;
- break;
- default:
- usage();
- }
- }
-
- if (optind == argc - 2) {
- optind++;
- } else if (mdata.mounted_vol[0] == 0)
- errx(EX_USAGE, "volume name should be specified");
-
- if (optind != argc - 1)
- usage();
- realpath(argv[optind], mount_point);
-
- if (stat(mount_point, &st) == -1)
- err(EX_OSERR, "could not find mount point %s", mount_point);
- if (!S_ISDIR(st.st_mode)) {
- errno = ENOTDIR;
- err(EX_OSERR, "can't mount on %s", mount_point);
- }
- if (ncp_geteinfo(mount_point, &einfo) == 0)
- errx(EX_OSERR, "can't mount on %s twice", mount_point);
-
- if (mdata.uid == -1) {
- mdata.uid = st.st_uid;
- }
- if (mdata.gid == -1) {
- mdata.gid = st.st_gid;
- }
- if (mdata.file_mode == 0 ) {
- mdata.file_mode = st.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
- }
- if (mdata.dir_mode == 0) {
- mdata.dir_mode = mdata.file_mode;
- if ((mdata.dir_mode & S_IRUSR) != 0)
- mdata.dir_mode |= S_IXUSR;
- if ((mdata.dir_mode & S_IRGRP) != 0)
- mdata.dir_mode |= S_IXGRP;
- if ((mdata.dir_mode & S_IROTH) != 0)
- mdata.dir_mode |= S_IXOTH;
- }
- if (li.access_mode == 0) {
- li.access_mode = mdata.dir_mode;
- }
-/* if (mdata.flags & NWFS_MOUNT_HAVE_NLS) {*/
- mdata.nls = ncp_nls;
-/* }*/
- mdata.nls.opt = nlsopt;
- error = ncp_li_check(&li);
- if (error)
- return 1;
- li.opt |= NCP_OPT_WDOG;
- /* well, now we can try to login, or use already established connection */
- error = ncp_li_login(&li, &connHandle);
- if (error) {
- ncp_error("cannot login to server %s", error, li.server);
- exit(1);
- }
- error = ncp_conn2ref(connHandle, &mdata.connRef);
- if (error) {
- ncp_error("could not convert handle to reference", error);
- ncp_disconnect(connHandle);
- exit(1);
- }
- strcpy(mdata.mount_point,mount_point);
- mdata.version = NWFS_VERSION;
- error = mount(NWFS_VFSNAME, mdata.mount_point, mntflags, (void*)&mdata);
- if (error) {
- ncp_error("mount error: %s", error, mdata.mount_point);
- ncp_disconnect(connHandle);
- exit(1);
- }
- /*
- * I'm leave along my handle, but kernel should keep own ...
- */
- ncp_disconnect(connHandle);
- /* we are done ?, impossible ... */
- return 0;
-}
-
-static void
-usage(void)
-{
- fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n",
- "usage: mount_nwfs [-Chv] -S server -U user [-connection options]",
- " -V volume [-M mode] [-c case] [-d mode] [-f mode]",
- " [-g gid] [-l locale] [-n os2] [-u uid] [-w scheme]",
- " node",
- " mount_nwfs [-options] /server:user/volume[/path] node");
-
- exit (1);
-}
diff --git a/usr.sbin/mount_portalfs/Makefile b/usr.sbin/mount_portalfs/Makefile
deleted file mode 100644
index 23a5bd771be8..000000000000
--- a/usr.sbin/mount_portalfs/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-# From: @(#)Makefile 8.3 (Berkeley) 3/27/94
-# $FreeBSD$
-
-PROG= mount_portal
-SRCS= mount_portal.c activate.c conf.c getmntopts.c pt_conf.c \
- pt_exec.c pt_file.c pt_tcp.c pt_tcplisten.c
-MAN8= mount_portal.8
-
-MOUNT= ${.CURDIR}/../mount
-CFLAGS+= -I${.CURDIR}/../../sys -I${MOUNT}
-.PATH: ${MOUNT}
-
-.include <bsd.prog.mk>
diff --git a/usr.sbin/mount_portalfs/activate.c b/usr.sbin/mount_portalfs/activate.c
deleted file mode 100644
index 56464981471c..000000000000
--- a/usr.sbin/mount_portalfs/activate.c
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- * All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)activate.c 8.3 (Berkeley) 4/28/95
- */
-
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <errno.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/socket.h>
-#include <sys/syslog.h>
-#include <sys/uio.h>
-
-#include "portald.h"
-
-/*
- * Scan the providers list and call the
- * appropriate function.
- */
-static int activate_argv(pcr, key, v, so, fdp)
-struct portal_cred *pcr;
-char *key;
-char **v;
-int so;
-int *fdp;
-{
- provider *pr;
-
- for (pr = providers; pr->pr_match; pr++)
- if (strcmp(v[0], pr->pr_match) == 0)
- return ((*pr->pr_func)(pcr, key, v, so, fdp));
-
- return (ENOENT);
-}
-
-static int get_request(so, pcr, key, klen)
-int so;
-struct portal_cred *pcr;
-char *key;
-int klen;
-{
- struct iovec iov[2];
- struct msghdr msg;
- int n;
-
- iov[0].iov_base = (caddr_t) pcr;
- iov[0].iov_len = sizeof(*pcr);
- iov[1].iov_base = key;
- iov[1].iov_len = klen;
-
- memset(&msg, 0, sizeof(msg));
- msg.msg_iov = iov;
- msg.msg_iovlen = 2;
-
- n = recvmsg(so, &msg, 0);
- if (n < 0)
- return (errno);
-
- if (n <= sizeof(*pcr))
- return (EINVAL);
-
- n -= sizeof(*pcr);
- key[n] = '\0';
-
- return (0);
-}
-
-static void send_reply(so, fd, error)
-int so;
-int fd;
-int error;
-{
- int n;
- struct iovec iov;
- struct msghdr msg;
- struct {
- struct cmsghdr cmsg;
- int fd;
- } ctl;
-
- /*
- * Line up error code. Don't worry about byte ordering
- * because we must be sending to the local machine.
- */
- iov.iov_base = (caddr_t) &error;
- iov.iov_len = sizeof(error);
-
- /*
- * Build a msghdr
- */
- memset(&msg, 0, sizeof(msg));
- msg.msg_iov = &iov;
- msg.msg_iovlen = 1;
-
- /*
- * If there is a file descriptor to send then
- * construct a suitable rights control message.
- */
- if (fd >= 0) {
- ctl.fd = fd;
- ctl.cmsg.cmsg_len = sizeof(ctl);
- ctl.cmsg.cmsg_level = SOL_SOCKET;
- ctl.cmsg.cmsg_type = SCM_RIGHTS;
- msg.msg_control = (caddr_t) &ctl;
- msg.msg_controllen = ctl.cmsg.cmsg_len;
- }
-
- /*
- * Send to kernel...
- */
- if ((n = sendmsg(so, &msg, 0)) < 0)
- syslog(LOG_ERR, "send: %s", strerror(errno));
-#ifdef DEBUG
- fprintf(stderr, "sent %d bytes\n", n);
-#endif
- sleep(1); /*XXX*/
-#ifdef notdef
- if (shutdown(so, 2) < 0)
- syslog(LOG_ERR, "shutdown: %s", strerror(errno));
-#endif
- /*
- * Throw away the open file descriptor
- */
- (void) close(fd);
-}
-
-void activate(q, so)
-qelem *q;
-int so;
-{
- struct portal_cred pcred;
- char key[MAXPATHLEN+1];
- int error;
- char **v;
- int fd = -1;
-
- /*
- * Read the key from the socket
- */
- error = get_request(so, &pcred, key, sizeof(key));
- if (error) {
- syslog(LOG_ERR, "activate: recvmsg: %s", strerror(error));
- goto drop;
- }
-
-#ifdef DEBUG
- fprintf(stderr, "lookup key %s\n", key);
-#endif
-
- /*
- * Find a match in the configuration file
- */
- v = conf_match(q, key);
-
- /*
- * If a match existed, then find an appropriate portal
- * otherwise simply return ENOENT.
- */
- if (v) {
- error = activate_argv(&pcred, key, v, so, &fd);
- if (error)
- fd = -1;
- else if (fd < 0)
- error = -1;
- } else {
- error = ENOENT;
- }
-
- if (error >= 0)
- send_reply(so, fd, error);
-
-drop:;
- close(so);
-}
diff --git a/usr.sbin/mount_portalfs/conf.c b/usr.sbin/mount_portalfs/conf.c
deleted file mode 100644
index d5833e4b2136..000000000000
--- a/usr.sbin/mount_portalfs/conf.c
+++ /dev/null
@@ -1,340 +0,0 @@
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- * All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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 8.2 (Berkeley) 3/27/94
- */
-
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <errno.h>
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <regex.h>
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/syslog.h>
-
-#include "portald.h"
-
-#define ALLOC(ty) (xmalloc(sizeof(ty)))
-
-typedef struct path path;
-struct path {
- qelem p_q; /* 2-way linked list */
- int p_lno; /* Line number of this record */
- char *p_args; /* copy of arg string (malloc) */
- char *p_key; /* Pathname to match (also p_argv[0]) */
- regex_t p_rx; /* RE to match against pathname () */
- int p_rxvalid; /* non-zero if valid regular expression */
- int p_argc; /* number of elements in arg string */
- char **p_argv; /* argv[] pointers into arg string (malloc) */
-};
-
-static char *conf_file; /* XXX for regerror */
-static path *curp; /* XXX for regerror */
-
-/*
- * Add an element to a 2-way list,
- * just after (pred)
- */
-static void ins_que(elem, pred)
-qelem *elem, *pred;
-{
- qelem *p = pred->q_forw;
- elem->q_back = pred;
- elem->q_forw = p;
- pred->q_forw = elem;
- p->q_back = elem;
-}
-
-/*
- * Remove an element from a 2-way list
- */
-static void rem_que(elem)
-qelem *elem;
-{
- qelem *p = elem->q_forw;
- qelem *p2 = elem->q_back;
- p2->q_forw = p;
- p->q_back = p2;
-}
-
-/*
- * Error checking malloc
- */
-static void *xmalloc(siz)
-unsigned siz;
-{
- void *p = malloc(siz);
- if (p)
- return (p);
- syslog(LOG_ALERT, "malloc: failed to get %d bytes", siz);
- exit(1);
-}
-
-/*
- * Insert the path in the list.
- * If there is already an element with the same key then
- * the *second* one is ignored (return 0). If the key is
- * not found then the path is added to the end of the list
- * and 1 is returned.
- */
-static int pinsert(p0, q0)
-path *p0;
-qelem *q0;
-{
- qelem *q;
-
- if (p0->p_argc == 0)
- return (0);
-
- for (q = q0->q_forw; q != q0; q = q->q_forw) {
- path *p = (path *) q;
- if (strcmp(p->p_key, p0->p_key) == 0)
- return (0);
- }
- ins_que(&p0->p_q, q0->q_back);
- return (1);
-
-}
-
-static path *palloc(cline, lno)
-char *cline;
-int lno;
-{
- int c;
- char *s;
- char *key;
- path *p;
- char **ap;
-
- /*
- * Implement comment chars
- */
- s = strchr(cline, '#');
- if (s)
- *s = 0;
-
- /*
- * Do a pass through the string to count the number
- * of arguments
- */
- c = 0;
- key = strdup(cline);
- for (s = key; s != NULL; ) {
- char *val;
- while ((val = strsep(&s, " \t\n")) != NULL && *val == '\0')
- ;
- if (val)
- c++;
- }
- c++;
- free(key);
-
- if (c <= 1)
- return (0);
-
- /*
- * Now do another pass and generate a new path structure
- */
- p = ALLOC(path);
- p->p_argc = 0;
- p->p_argv = xmalloc(c * sizeof(char *));
- p->p_args = strdup(cline);
- ap = p->p_argv;
- for (s = p->p_args; s != NULL; ) {
- char *val;
- while ((val = strsep(&s, " \t\n")) != NULL && *val == '\0')
- ;
- if (val) {
- *ap++ = val;
- p->p_argc++;
- }
- }
- *ap = 0;
-
-#ifdef DEBUG
- for (c = 0; c < p->p_argc; c++)
- printf("%sv[%d] = %s\n", c?"\t":"", c, p->p_argv[c]);
-#endif
-
- p->p_key = p->p_argv[0];
- if (strpbrk(p->p_key, RE_CHARS)) {
- int val;
-
- curp = p; /* XXX */
- val = regcomp(&p->p_rx, p->p_key, REG_EXTENDED | REG_NOSUB);
- if (val) {
- char errbuf[_POSIX2_LINE_MAX];
- regerror(val, &p->p_rx, errbuf, sizeof errbuf);
- syslog(LOG_ERR, "%s:%d: regcomp %s: %s",
- conf_file, curp->p_lno, curp->p_key, errbuf);
- regfree(&p->p_rx);
- p->p_rxvalid = 0;
- } else {
- p->p_rxvalid = 1;
- }
- curp = 0; /* XXX */
- } else {
- p->p_rxvalid = 0;
- }
- p->p_lno = lno;
-
- return (p);
-}
-
-/*
- * Free a path structure
- */
-static void pfree(p)
-path *p;
-{
- free(p->p_args);
- if (p->p_rxvalid) {
- regfree(&p->p_rx);
- }
- free((char *) p->p_argv);
- free((char *) p);
-}
-
-/*
- * Discard all currently held path structures on q0.
- * and add all the ones on xq.
- */
-static void preplace(q0, xq)
-qelem *q0;
-qelem *xq;
-{
- /*
- * While the list is not empty,
- * take the first element off the list
- * and free it.
- */
- while (q0->q_forw != q0) {
- qelem *q = q0->q_forw;
- rem_que(q);
- pfree((path *) q);
- }
- while (xq->q_forw != xq) {
- qelem *q = xq->q_forw;
- rem_que(q);
- ins_que(q, q0);
- }
-}
-
-/*
- * Read the lines from the configuration file and
- * add them to the list of paths.
- */
-static void readfp(q0, fp)
-qelem *q0;
-FILE *fp;
-{
- char cline[LINE_MAX];
- int nread = 0;
- qelem q;
-
- /*
- * Make a new empty list.
- */
- q.q_forw = q.q_back = &q;
-
- /*
- * Read the lines from the configuration file.
- */
- while (fgets(cline, sizeof(cline), fp)) {
- path *p = palloc(cline, nread+1);
- if (p && !pinsert(p, &q))
- pfree(p);
- nread++;
- }
-
- /*
- * If some records were read, then throw
- * away the old list and replace with the
- * new one.
- */
- if (nread)
- preplace(q0, &q);
-}
-
-/*
- * Read the configuration file (conf) and replace
- * the existing path list with the new version.
- * If the file is not readable, then no changes take place
- */
-void conf_read(q, conf)
-qelem *q;
-char *conf;
-{
- FILE *fp = fopen(conf, "r");
- if (fp) {
- conf_file = conf; /* XXX */
- readfp(q, fp);
- conf_file = 0; /* XXX */
- (void) fclose(fp);
- } else {
- syslog(LOG_ERR, "open config file \"%s\": %s", conf, strerror(errno));
- }
-}
-
-
-char **conf_match(q0, key)
-qelem *q0;
-char *key;
-{
- qelem *q;
-
- for (q = q0->q_forw; q != q0; q = q->q_forw) {
- path *p = (path *) q;
- if (p->p_rxvalid) {
- if (!regexec(&p->p_rx, key, 0, 0, 0)) {
- return p->p_argv + 1;
- }
- } else {
- if (strncmp(p->p_key, key, strlen(p->p_key)) == 0)
- return (p->p_argv+1);
- }
- }
-
- return (0);
-}
diff --git a/usr.sbin/mount_portalfs/mount_portalfs.8 b/usr.sbin/mount_portalfs/mount_portalfs.8
deleted file mode 100644
index 306a220c8aff..000000000000
--- a/usr.sbin/mount_portalfs/mount_portalfs.8
+++ /dev/null
@@ -1,152 +0,0 @@
-.\"
-.\" Copyright (c) 1993, 1994
-.\" The Regents of the University of California. All rights reserved.
-.\" All rights reserved.
-.\"
-.\" This code is derived from software donated to Berkeley by
-.\" Jan-Simon Pendry.
-.\"
-.\" 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 the University of
-.\" California, Berkeley and its contributors.
-.\" 4. 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.
-.\"
-.\" @(#)mount_portal.8 8.3 (Berkeley) 3/27/94
-.\" $FreeBSD$
-.\"
-.Dd March 27, 1994
-.Dt MOUNT_PORTAL 8
-.Os BSD 4.4
-.Sh NAME
-.Nm mount_portal
-.Nd mount the portal daemon
-.Sh SYNOPSIS
-.Nm mount_portal
-.Op Fl o Ar options
-.Ar /etc/portal.conf
-.Ar mount_point
-.Sh DESCRIPTION
-The
-.Nm
-command attaches an instance of the portal daemon
-to the global filesystem namespace.
-The conventional mount point is
-.Pa /p .
-.\" .PA /dev .
-This command is normally executed by
-.Xr mount 8
-at boot time.
-.Pp
-The options are as follows:
-.Bl -tag -width indent
-.It Fl o
-Options are specified with a
-.Fl o
-flag followed by a comma separated string of options.
-See the
-.Xr mount 8
-man page for possible options and their meanings.
-.El
-.Pp
-The portal daemon provides an
-.Em open
-service.
-Objects opened under the portal mount point are
-dynamically created by the portal daemon according
-to rules specified in the named configuration file.
-Using this mechanism allows descriptors such as sockets
-to be made available in the filesystem namespace.
-.Pp
-The portal daemon works by being passed the full pathname
-of the object being opened.
-The daemon creates an appropriate descriptor according
-to the rules in the configuration file, and then passes the descriptor back
-to the calling process as the result of the open system call.
-.Sh NAMESPACE
-By convention, the portal daemon divides the namespace into sub-namespaces,
-each of which handles objects of a particular type.
-.Pp
-The following sub-namespaces are currently implemented:
-.Pa tcplisten ,
-.Pa tcp
-and
-.Pa fs .
-The
-.Pa tcplisten
-namespace takes a slash separated hostname and port and creates a TCP/IP
-socket bound to the given hostname-port pair.
-The hostname may be
-specified as "ANY" to allow any other host to connect to the socket.
-A
-port number of 0 will dynamically allocate a port, this can be
-discovered by calling
-.Xr getsockname 2
-with the returned file descriptor.
-Privileged ports can only be bound to
-by the super-user.
-The
-.Pa tcp
-namespace takes a hostname and a port (slash separated) and
-creates an open TCP/IP connection.
-The
-.Pa fs
-namespace opens the named file, starting back at the root directory.
-This can be used to provide a controlled escape path from
-a chrooted environment.
-.Sh "CONFIGURATION FILE"
-The configuration file contains a list of rules.
-Each rule takes one line and consists of two or more
-whitespace separated fields.
-A hash (``#'') character causes the remainder of a line to
-be ignored. Blank lines are ignored.
-.Pp
-The first field is a pathname prefix to match
-against the requested pathname.
-If a match is found, the second field
-tells the daemon what type of object to create.
-Subsequent fields are passed to the creation function.
-.Bd -literal
-# @(#)portal.conf 5.1 (Berkeley) 7/13/92
-tcplisten/ tcplisten tcplisten/
-tcp/ tcp tcp/
-fs/ file fs/
-.Ed
-.Sh FILES
-.Bl -tag -width /p/* -compact
-.It Pa /p/*
-.El
-.Sh SEE ALSO
-.Xr mount 2 ,
-.Xr unmount 2 ,
-.Xr fstab 5 ,
-.Xr mount 8
-.Sh CAVEATS
-This filesystem may not be NFS-exported.
-.Sh HISTORY
-The
-.Nm
-utility first appeared in
-.Bx 4.4 .
diff --git a/usr.sbin/mount_portalfs/mount_portalfs.c b/usr.sbin/mount_portalfs/mount_portalfs.c
deleted file mode 100644
index 48cf609df74e..000000000000
--- a/usr.sbin/mount_portalfs/mount_portalfs.c
+++ /dev/null
@@ -1,295 +0,0 @@
-/*
- * Copyright (c) 1992, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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 lint
-char copyright[] =
-"@(#) Copyright (c) 1992, 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)mount_portal.c 8.6 (Berkeley) 4/26/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <sys/param.h>
-#include <sys/wait.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <sys/stat.h>
-#include <sys/syslog.h>
-#include <sys/mount.h>
-
-#include <err.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sysexits.h>
-#include <unistd.h>
-
-#include "mntopts.h"
-#include "pathnames.h"
-#include "portald.h"
-
-struct mntopt mopts[] = {
- MOPT_STDOPTS,
- { NULL }
-};
-
-static void usage __P((void)) __dead2;
-
-static sig_atomic_t readcf; /* Set when SIGHUP received */
-
-static void sighup(sig)
-int sig;
-{
- readcf ++;
-}
-
-static void sigchld(sig)
-int sig;
-{
- pid_t pid;
-
- while ((pid = waitpid((pid_t) -1, (int *) 0, WNOHANG)) > 0)
- ;
- /* wrtp - waitpid _doesn't_ return 0 when no children! */
-#ifdef notdef
- if (pid < 0 && errno != ECHILD)
- syslog(LOG_WARNING, "waitpid: %s", strerror(errno));
-#endif
-}
-
-int
-main(argc, argv)
- int argc;
- char *argv[];
-{
- struct portal_args args;
- struct sockaddr_un un;
- char *conf;
- char mountpt[MAXPATHLEN];
- int mntflags = 0;
- char tag[32];
- struct vfsconf vfc;
- mode_t um;
-
- qelem q;
- int rc;
- int so;
- int error = 0;
-
- /*
- * Crack command line args
- */
- int ch;
-
- while ((ch = getopt(argc, argv, "o:")) != -1) {
- switch (ch) {
- case 'o':
- getmntopts(optarg, mopts, &mntflags, 0);
- break;
- default:
- error = 1;
- break;
- }
- }
-
- if (optind != (argc - 2))
- error = 1;
-
- if (error)
- usage();
-
- /*
- * Get config file and mount point
- */
- conf = argv[optind];
-
- /* resolve the mountpoint with realpath(3) */
- (void)checkpath(argv[optind+1], mountpt);
-
- /*
- * Construct the listening socket
- */
- un.sun_family = AF_UNIX;
- if (sizeof(_PATH_TMPPORTAL) >= sizeof(un.sun_path)) {
- errx(EX_SOFTWARE, "portal socket name too long");
- }
- strcpy(un.sun_path, _PATH_TMPPORTAL);
- mktemp(un.sun_path);
- un.sun_len = strlen(un.sun_path);
-
- so = socket(AF_UNIX, SOCK_STREAM, 0);
- if (so < 0) {
- err(EX_OSERR, "socket");
- }
- um = umask(077);
- (void) unlink(un.sun_path);
- if (bind(so, (struct sockaddr *) &un, sizeof(un)) < 0)
- err(1, NULL);
-
- (void) unlink(un.sun_path);
- (void) umask(um);
-
- (void) listen(so, 5);
-
- args.pa_socket = so;
- sprintf(tag, "portal:%d", getpid());
- args.pa_config = tag;
-
- error = getvfsbyname("portal", &vfc);
- if (error && vfsisloadable("portal")) {
- if (vfsload("portal"))
- err(EX_OSERR, "vfsload(portal)");
- endvfsent();
- error = getvfsbyname("portal", &vfc);
- }
- if (error)
- errx(EX_OSERR, "portal filesystem is not available");
-
- rc = mount(vfc.vfc_name, mountpt, mntflags, &args);
- if (rc < 0)
- err(1, NULL);
-
- /*
- * Everything is ready to go - now is a good time to fork
- */
-#ifndef DEBUG
- daemon(0, 0);
-#endif
-
- /*
- * Start logging (and change name)
- */
- openlog("portald", LOG_CONS|LOG_PID, LOG_DAEMON);
-
- q.q_forw = q.q_back = &q;
- readcf = 1;
-
- signal(SIGCHLD, sigchld);
- signal(SIGHUP, sighup);
-
- /*
- * Just loop waiting for new connections and activating them
- */
- for (;;) {
- struct sockaddr_un un2;
- int len2 = sizeof(un2);
- int so2;
- pid_t pid;
- fd_set fdset;
- int rc;
-
- /*
- * Check whether we need to re-read the configuration file
- */
- if (readcf) {
-#ifdef DEBUG
- printf ("re-reading configuration file\n");
-#endif
- readcf = 0;
- conf_read(&q, conf);
- continue;
- }
-
- /*
- * Accept a new connection
- * Will get EINTR if a signal has arrived, so just
- * ignore that error code
- */
- FD_ZERO(&fdset);
- FD_SET(so, &fdset);
- rc = select(so+1, &fdset, (fd_set *) 0, (fd_set *) 0, (struct timeval *) 0);
- if (rc < 0) {
- if (errno == EINTR)
- continue;
- syslog(LOG_ERR, "select: %s", strerror(errno));
- exit(EX_OSERR);
- }
- if (rc == 0)
- break;
- so2 = accept(so, (struct sockaddr *) &un2, &len2);
- if (so2 < 0) {
- /*
- * The unmount function does a shutdown on the socket
- * which will generated ECONNABORTED on the accept.
- */
- if (errno == ECONNABORTED)
- break;
- if (errno != EINTR) {
- syslog(LOG_ERR, "accept: %s", strerror(errno));
- exit(EX_OSERR);
- }
- continue;
- }
-
- /*
- * Now fork a new child to deal with the connection
- */
- eagain:;
- switch (pid = fork()) {
- case -1:
- if (errno == EAGAIN) {
- sleep(1);
- goto eagain;
- }
- syslog(LOG_ERR, "fork: %s", strerror(errno));
- break;
- case 0:
- (void) close(so);
- activate(&q, so2);
- exit(0);
- default:
- (void) close(so2);
- break;
- }
- }
- syslog(LOG_INFO, "%s unmounted", mountpt);
- exit(0);
-}
-
-static void
-usage()
-{
- (void)fprintf(stderr,
- "usage: mount_portal [-o options] config mount-point\n");
- exit(EX_USAGE);
-}
diff --git a/usr.sbin/mount_portalfs/pathnames.h b/usr.sbin/mount_portalfs/pathnames.h
deleted file mode 100644
index 16720853c70a..000000000000
--- a/usr.sbin/mount_portalfs/pathnames.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- * All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)pathnames.h 8.1 (Berkeley) 6/5/93
- *
- * $FreeBSD$
- */
-
-#include <paths.h>
-
-#define _PATH_TMPPORTAL "/tmp/portalXXXXXXXXXX" /* Scratch socket name */
diff --git a/usr.sbin/mount_portalfs/portal.conf b/usr.sbin/mount_portalfs/portal.conf
deleted file mode 100644
index 53a07a92231c..000000000000
--- a/usr.sbin/mount_portalfs/portal.conf
+++ /dev/null
@@ -1,7 +0,0 @@
-# @(#)portal.conf 8.1 (Berkeley) 6/5/93
-# $FreeBSD$
-tcplisten/ tcplisten tcplisten/
-tcp/ tcp tcp/
-fs/ file fs/
-pipe/ pipe
-foo/ exec ./bar bar baz
diff --git a/usr.sbin/mount_portalfs/portald.h b/usr.sbin/mount_portalfs/portald.h
deleted file mode 100644
index 4131834c5575..000000000000
--- a/usr.sbin/mount_portalfs/portald.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- * All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)portald.h 8.1 (Berkeley) 6/5/93
- *
- * $FreeBSD$
- */
-
-#include <sys/cdefs.h>
-#include <miscfs/portal/portal.h>
-
-/*
- * Meta-chars in an RE. Paths in the config file containing
- * any of these characters will be matched using regexec, other
- * paths will be prefix-matched.
- */
-#define RE_CHARS ".|()[]*+?\\^$"
-
-typedef struct qelem qelem;
-
-struct qelem {
- qelem *q_forw;
- qelem *q_back;
-};
-
-typedef struct provider provider;
-struct provider {
- char *pr_match;
- int (*pr_func) __P((struct portal_cred *,
- char *key, char **v, int so, int *fdp));
-};
-extern provider providers[];
-
-/*
- * Portal providers
- */
-extern int portal_exec __P((struct portal_cred *,
- char *key, char **v, int so, int *fdp));
-extern int portal_file __P((struct portal_cred *,
- char *key, char **v, int so, int *fdp));
-extern int portal_tcp __P((struct portal_cred *,
- char *key, char **v, int so, int *fdp));
-extern int portal_tcplisten __P((struct portal_cred *,
- char *key, char **v, int so, int *fdp));
-
-/*
- * Global functions
- */
-extern void activate __P((qelem *q, int so));
-extern char **conf_match __P((qelem *q, char *key));
-extern void conf_read __P((qelem *q, char *conf));
diff --git a/usr.sbin/mount_portalfs/pt_conf.c b/usr.sbin/mount_portalfs/pt_conf.c
deleted file mode 100644
index f158a73dd03d..000000000000
--- a/usr.sbin/mount_portalfs/pt_conf.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- * All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)pt_conf.c 8.1 (Berkeley) 6/5/93
- */
-
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include "portald.h"
-
-provider providers[] = {
- { "exec", portal_exec },
- { "file", portal_file },
- { "tcp", portal_tcp },
- { "tcplisten", portal_tcplisten },
- { 0, 0 }
-};
diff --git a/usr.sbin/mount_portalfs/pt_exec.c b/usr.sbin/mount_portalfs/pt_exec.c
deleted file mode 100644
index 359c78e92164..000000000000
--- a/usr.sbin/mount_portalfs/pt_exec.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- * All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)pt_exec.c 8.1 (Berkeley) 6/5/93
- */
-
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/param.h>
-
-#include "portald.h"
-
-int portal_exec(pcr, key, v, so, fdp)
-struct portal_cred *pcr;
-char *key;
-char **v;
-int so;
-int *fdp;
-{
- return (ENOEXEC);
-}
-
diff --git a/usr.sbin/mount_portalfs/pt_file.c b/usr.sbin/mount_portalfs/pt_file.c
deleted file mode 100644
index f22ebd7d2b51..000000000000
--- a/usr.sbin/mount_portalfs/pt_file.c
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- * All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)pt_file.c 8.3 (Berkeley) 7/3/94
- */
-
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <errno.h>
-#include <fcntl.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/syslog.h>
-
-#include "portald.h"
-
-int portal_file(pcr, key, v, so, fdp)
-struct portal_cred *pcr;
-char *key;
-char **v;
-int so;
-int *fdp;
-{
- int fd;
- char pbuf[MAXPATHLEN];
- int error;
- gid_t gidset[NGROUPS];
- int i;
-
- pbuf[0] = '/';
- strcpy(pbuf+1, key + (v[1] ? strlen(v[1]) : 0));
-
-#ifdef DEBUG
- printf("path = %s, uid = %d, gid = %d\n", pbuf, pcr->pcr_uid, pcr->pcr_groups[0]);
- printf ("fflag = %x, oflag = %x\n", pcr->pcr_flag, (pcr->pcr_flag)-1);
-#endif
-
- for (i = 0; i < pcr->pcr_ngroups; i++)
- gidset[i] = pcr->pcr_groups[i];
-
- if (setgroups(pcr->pcr_ngroups, gidset) < 0)
- return (errno);
-
- if (seteuid(pcr->pcr_uid) < 0)
- return (errno);
-
- /* dmb convert kernel flags to oflags, see <fcntl.h> */
- fd = open(pbuf, (pcr->pcr_flag)-1, 0777);
- if (fd < 0)
- error = errno;
- else
- error = 0;
-
- if (seteuid((uid_t) 0) < 0) { /* XXX - should reset gidset too */
- error = errno;
- syslog(LOG_ERR, "setcred: %s", strerror(error));
- if (fd >= 0) {
- (void) close(fd);
- fd = -1;
- }
- }
-
- if (error == 0)
- *fdp = fd;
-
-#ifdef DEBUG
- fprintf(stderr, "pt_file returns *fdp = %d, error = %d\n", *fdp, error);
-#endif
-
- return (error);
-}
diff --git a/usr.sbin/mount_portalfs/pt_tcp.c b/usr.sbin/mount_portalfs/pt_tcp.c
deleted file mode 100644
index 49056163aae3..000000000000
--- a/usr.sbin/mount_portalfs/pt_tcp.c
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright (c) 1992, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- * All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)pt_tcp.c 8.5 (Berkeley) 4/28/95
- */
-
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
-#include <errno.h>
-#include <stdlib.h>
-#include <strings.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/syslog.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-
-#include "portald.h"
-
-/*
- * Key will be tcp/host/port[/"priv"]
- * Create a TCP socket connected to the
- * requested host and port.
- * Some trailing suffix values have special meanings.
- * An unrecognized suffix is an error.
- */
-int portal_tcp(pcr, key, v, kso, fdp)
- struct portal_cred *pcr;
- char *key;
- char **v;
- int kso;
- int *fdp;
-{
- char host[MAXHOSTNAMELEN];
- char port[MAXHOSTNAMELEN];
- char *p = key + (v[1] ? strlen(v[1]) : 0);
- char *q;
- struct hostent *hp;
- struct servent *sp;
- struct in_addr **ipp;
- struct in_addr *ip[2];
- struct in_addr ina;
- u_short s_port;
- int priv = 0;
- struct sockaddr_in sain;
-
- q = strchr(p, '/');
- if (q == 0 || q - p >= sizeof(host))
- return (EINVAL);
- *q = '\0';
- strcpy(host, p);
- p = q + 1;
-
- q = strchr(p, '/');
- if (q)
- *q = '\0';
- if (strlen(p) >= sizeof(port))
- return (EINVAL);
- strcpy(port, p);
- if (q) {
- p = q + 1;
- if (strcmp(p, "priv") == 0) {
- if (pcr->pcr_uid == 0)
- priv = 1;
- else
- return (EPERM);
- } else {
- return (EINVAL);
- }
- }
-
- hp = gethostbyname(host);
- if (hp != 0) {
- ipp = (struct in_addr **) hp->h_addr_list;
- } else {
- ina.s_addr = inet_addr(host);
- if (ina.s_addr == INADDR_NONE)
- return (EINVAL);
- ip[0] = &ina;
- ip[1] = 0;
- ipp = ip;
- }
-#ifdef DEBUG
- printf ("inet address for %s is %s\n", host, inet_ntoa(*ipp[0]));
-#endif
-
- sp = getservbyname(port, "tcp");
- if (sp != NULL) {
- s_port = (u_short)sp->s_port;
- } else {
- s_port = strtoul(port, &p, 0);
- if (s_port == 0 || *p != '\0')
- return (EINVAL);
- s_port = htons(s_port);
- }
-#ifdef DEBUG
- printf ("port number for %s is %d\n", port, (int)ntohs(s_port));
-#endif
-
- memset(&sain, 0, sizeof(sain));
- sain.sin_len = sizeof(sain);
- sain.sin_family = AF_INET;
- sain.sin_port = s_port;
-
- while (ipp[0]) {
- int so;
-
- if (priv)
- so = rresvport((int *) 0);
- else
- so = socket(AF_INET, SOCK_STREAM, 0);
- if (so < 0) {
- syslog(LOG_ERR, "socket: %m");
- return (errno);
- }
-
- sain.sin_addr = *ipp[0];
- if (connect(so, (struct sockaddr *) &sain, sizeof(sain)) == 0) {
- *fdp = so;
- return (0);
- }
- (void) close(so);
-
- ipp++;
- }
-
- return (errno);
-}
diff --git a/usr.sbin/mount_portalfs/pt_tcplisten.c b/usr.sbin/mount_portalfs/pt_tcplisten.c
deleted file mode 100644
index 43a20c5aa92c..000000000000
--- a/usr.sbin/mount_portalfs/pt_tcplisten.c
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- * All rights reserved.
- *
- * This code is derived from software donated to Berkeley by
- * Jan-Simon Pendry.
- *
- * Modified by Duncan Barclay.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)pt_tcp.c 8.3 (Berkeley) 3/27/94
- *
- * pt_tcp.c,v 1.1.1.1 1994/05/26 06:34:34 rgrimes Exp
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <strings.h>
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/syslog.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-
-#include "portald.h"
-
-/*
- * Key will be tcplisten/host/port
- *
- * Create a TCP socket bound to the requested host and port.
- * If the host is "ANY" the receving address will be set to INADDR_ANY.
- * If the port is 0 the caller must find out the returned port number
- * using a call to getsockname.
- *
- * XXX! The owner of the socket will be root rather then the user. This
- * may cause remote auth (identd) to return unexpected results.
- *
- */
-int portal_tcplisten(pcr, key, v, kso, fdp)
- struct portal_cred *pcr;
- char *key;
- char **v;
- int kso;
- int *fdp;
-{
- char host[MAXHOSTNAMELEN];
- char port[MAXHOSTNAMELEN];
- char *p = key + (v[1] ? strlen(v[1]) : 0);
- char *q;
- struct hostent *hp;
- struct servent *sp;
- struct in_addr **ipp;
- struct in_addr *ip[2];
- struct in_addr ina;
- u_short s_port;
- int any = 0;
- struct sockaddr_in sain;
-
- q = strchr(p, '/');
- if (q == 0 || q - p >= sizeof(host))
- return (EINVAL);
- *q = '\0';
- snprintf(host, sizeof(host), "%s", p);
- p = q + 1;
-
- q = strchr(p, '/');
- if (q)
- *q = '\0';
- if (strlen(p) >= sizeof(port))
- return (EINVAL);
- snprintf(port, sizeof(port), "%s", p);
-
- if (strcmp(host, "ANY") == 0) {
- any = 1;
- } else {
- hp = gethostbyname(host);
- if (hp != 0) {
- ipp = (struct in_addr **) hp->h_addr_list;
- } else {
- ina.s_addr = inet_addr(host);
- if (ina.s_addr == INADDR_NONE)
- return (EINVAL);
- ip[0] = &ina;
- ip[1] = 0;
- ipp = ip;
- }
- }
-#ifdef DEBUG
- if (any)
- printf("INADDR_ANY to be used for hostname\n");
- else
- printf("inet address for %s is %s\n", host, inet_ntoa(*ipp[0]));
-#endif
-
- sp = getservbyname(port, "tcp");
- if (sp != NULL) {
- s_port = (u_short) sp->s_port;
- } else {
- s_port = strtoul(port, &p, 0);
- if (*p != '\0')
- return (EINVAL);
- s_port = htons(s_port);
- }
- if ((ntohs(s_port) != 0) &&
- (ntohs(s_port) <= IPPORT_RESERVED) &&
- (pcr->pcr_uid != 0))
- return (EPERM);
-#ifdef DEBUG
- printf("port number for %s is %d\n", port, ntohs(s_port));
-#endif
-
- memset(&sain, 0, sizeof(sain));
- sain.sin_len = sizeof(sain);
- sain.sin_family = AF_INET;
- sain.sin_port = s_port;
-
- if (any) {
- int so;
- int sock;
-
- so = socket(AF_INET, SOCK_STREAM, 0);
- if (so < 0) {
- syslog(LOG_ERR, "socket: %m");
- return (errno);
- }
-
- sain.sin_addr.s_addr = INADDR_ANY;
- if (bind(so, (struct sockaddr *) &sain, sizeof(sain)) == 0) {
- listen(so, 1);
- if ((sock = accept(so, (struct sockaddr *)0, (int *)0)) == -1) {
- syslog(LOG_ERR, "accept: %m");
- (void) close(so);
- return (errno);
- }
- *fdp = sock;
- (void) close(so);
- return (0);
- }
- syslog(LOG_ERR, "bind: %m");
- (void) close(so);
- return (errno);
- }
-
- while (ipp[0]) {
- int so;
- int sock;
-
- so = socket(AF_INET, SOCK_STREAM, 0);
- if (so < 0) {
- syslog(LOG_ERR, "socket: %m");
- return (errno);
- }
-
- sain.sin_addr = *ipp[0];
- if (bind(so, (struct sockaddr *) &sain, sizeof(sain)) == 0) {
- listen(so, 1);
- if ((sock = accept(so, (struct sockaddr *)0, (int *)0)) == -1) {
- syslog(LOG_ERR, "accept: %m");
- (void) close(so);
- return (errno);
- }
- *fdp = sock;
- (void) close(so);
- return (0);
- }
- (void) close(so);
-
- ipp++;
- }
-
- syslog(LOG_ERR, "bind: %m");
- return (errno);
-
-}
diff --git a/usr.sbin/mountd/Makefile b/usr.sbin/mountd/Makefile
deleted file mode 100644
index 0312e9b657e2..000000000000
--- a/usr.sbin/mountd/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-# From: @(#)Makefile 8.3 (Berkeley) 1/25/94
-# $FreeBSD$
-
-PROG= mountd
-CFLAGS+=-DNFS -DMFS -DCD9660 -DMSDOSFS
-MAN5= exports.5 netgroup.5
-MAN8= mountd.8
-
-.include <bsd.prog.mk>
diff --git a/usr.sbin/mountd/exports.5 b/usr.sbin/mountd/exports.5
deleted file mode 100644
index 6506b5b38eab..000000000000
--- a/usr.sbin/mountd/exports.5
+++ /dev/null
@@ -1,297 +0,0 @@
-.\" Copyright (c) 1989, 1991, 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. 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, Berkeley and its contributors.
-.\" 4. 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.
-.\"
-.\" @(#)exports.5 8.3 (Berkeley) 3/29/95
-.\" $FreeBSD$
-.\"
-.Dd March 29, 1995
-.Dt EXPORTS 5
-.Os
-.Sh NAME
-.Nm exports
-.Nd define remote mount points for
-.Tn NFS
-mount requests
-.Sh SYNOPSIS
-.Nm exports
-.Sh DESCRIPTION
-The
-.Nm
-file specifies remote mount points for the
-.Tn NFS
-mount protocol per the
-.Tn NFS
-server specification; see
-.%T "Network File System Protocol Specification \\*(tNRFC\\*(sP 1094, Appendix A"
-and
-.%T "NFS: Network File System Version 3 Specification, Appendix I" .
-.Pp
-Each line in the file
-(other than comment lines that begin with a #)
-specifies the mount point(s) and export flags within one local server
-filesystem for one or more hosts.
-A host may be specified only once for each local filesystem on the
-server and there may be only one default entry for each server
-filesystem that applies to all other hosts.
-The latter exports the filesystem to the ``world'' and should
-be used only when the filesystem contains public information.
-.Pp
-In a mount entry,
-the first field(s) specify the directory path(s) within a server filesystem
-that can be mounted on by the corresponding client(s).
-There are two forms of this specification.
-The first is to list all mount points as absolute
-directory paths separated by whitespace.
-The second is to specify the pathname of the root of the filesystem
-followed by the
-.Fl alldirs
-flag;
-this form allows the host(s) to mount at any point within the filesystem,
-including regular files if the
-.Fl r
-option is used on
-.Xr mountd 8 .
-The pathnames must not have any symbolic links in them and should not have
-any "." or ".." components.
-Mount points for a filesystem may appear on multiple lines each with
-different sets of hosts and export options.
-.Pp
-The second component of a line specifies how the filesystem is to be
-exported to the host set.
-The option flags specify whether the filesystem
-is exported read-only or read-write and how the client uid is mapped to
-user credentials on the server.
-.Pp
-Export options are specified as follows:
-.Pp
-.Sm off
-.Fl maproot No = Sy user
-.Sm on
-The credential of the specified user is used for remote access by root.
-The credential includes all the groups to which the user is a member
-on the local machine (see
-.Xr id 1 ).
-The user may be specified by name or number.
-.Pp
-.Sm off
-.Fl maproot No = Sy user:group1:group2:...
-.Sm on
-The colon separated list is used to specify the precise credential
-to be used for remote access by root.
-The elements of the list may be either names or numbers.
-Note that user: should be used to distinguish a credential containing
-no groups from a complete credential for that user.
-.Pp
-.Sm off
-.Fl mapall No = Sy user
-.Sm on
-or
-.Sm off
-.Fl mapall No = Sy user:group1:group2:...
-.Sm on
-specifies a mapping for all client uids (including root)
-using the same semantics as
-.Fl maproot .
-.Pp
-The option
-.Fl r
-is a synonym for
-.Fl maproot
-in an effort to be backward compatible with older export file formats.
-.Pp
-In the absence of
-.Fl maproot
-and
-.Fl mapall
-options, remote accesses by root will result in using a credential of -2:-2.
-All other users will be mapped to their remote credential.
-If a
-.Fl maproot
-option is given,
-remote access by root will be mapped to that credential instead of -2:-2.
-If a
-.Fl mapall
-option is given,
-all users (including root) will be mapped to that credential in
-place of their own.
-.Pp
-The
-.Fl kerb
-option specifies that the Kerberos authentication server should be
-used to authenticate and map client credentials.
-This option requires that the kernel be built with the NFSKERB option.
-.Pp
-The
-.Fl ro
-option specifies that the filesystem should be exported read-only
-(default read/write).
-The option
-.Fl o
-is a synonym for
-.Fl ro
-in an effort to be backward compatible with older export file formats.
-.Pp
-.Tn WebNFS
-exports strictly according to the spec (RFC 2054 and RFC 2055) can
-be done with the
-.Fl public
-flag.
-However, this flag in itself allows r/w access to all files in
-the filesystem, not requiring reserved ports and not remapping uids.
-It
-is only provided to conform to the spec, and should normally not be used.
-For a
-.Tn WebNFS
-export,
-use the
-.Fl webnfs
-flag, which implies
-.Fl public ,
-.Sm off
-.Fl mapall No = Sy nobody
-.Sm on
-and
-.Fl ro .
-.Pp
-A
-.Sm off
-.Fl index No = Sy file
-.Sm on
-option can be used to specify a file whose handle will be returned if
-a directory is looked up using the public filehandle (
-.Tn WebNFS Ns ).
-This is to mimic the behavior of URLs.
-If no
-.Fl index
-option is specified, a directory filehandle will be returned as usual.
-The
-.Fl index
-option only makes sense in combination with the
-.Fl public
-or
-.Fl webnfs
-flags.
-.Pp
-The third component of a line specifies the host set to which the line applies.
-The set may be specified in three ways.
-The first way is to list the host name(s) separated by white space.
-(Standard Internet ``dot'' addresses may be used in place of names.)
-The second way is to specify a ``netgroup'' as defined in the netgroup file (see
-.Xr netgroup 5 ).
-The third way is to specify an Internet subnetwork using a network and
-network mask that is defined as the set of all hosts with addresses within
-the subnetwork.
-This latter approach requires less overhead within the
-kernel and is recommended for cases where the export line refers to a
-large number of clients within an administrative subnet.
-.Pp
-The first two cases are specified by simply listing the name(s) separated
-by whitespace.
-All names are checked to see if they are ``netgroup'' names
-first and are assumed to be hostnames otherwise.
-Using the full domain specification for a hostname can normally
-circumvent the problem of a host that has the same name as a netgroup.
-The third case is specified by the flag
-.Sm off
-.Fl network No = Sy netname
-.Sm on
-and optionally
-.Sm off
-.Fl mask No = Sy netmask .
-.Sm on
-If the mask is not specified, it will default to the mask for that network
-class (A, B or C; see
-.Xr inet 4 ).
-.Pp
-For example:
-.Bd -literal -offset indent
-/usr /usr/local -maproot=0:10 friends
-/usr -maproot=daemon grumpy.cis.uoguelph.ca 131.104.48.16
-/usr -ro -mapall=nobody
-/u -maproot=bin: -network 131.104.48 -mask 255.255.255.0
-/u2 -maproot=root friends
-/u2 -alldirs -kerb -network cis-net -mask cis-mask
-.Ed
-.Pp
-Given that
-.Sy /usr ,
-.Sy /u
-and
-.Sy /u2
-are
-local filesystem mount points, the above example specifies the following:
-.Sy /usr
-is exported to hosts
-.Em friends
-where friends is specified in the netgroup file
-with users mapped to their remote credentials and
-root mapped to uid 0 and group 10.
-It is exported read-write and the hosts in ``friends'' can mount either /usr
-or /usr/local.
-It is exported to
-.Em 131.104.48.16
-and
-.Em grumpy.cis.uoguelph.ca
-with users mapped to their remote credentials and
-root mapped to the user and groups associated with ``daemon'';
-it is exported to the rest of the world as read-only with
-all users mapped to the user and groups associated with ``nobody''.
-.Pp
-.Sy /u
-is exported to all hosts on the subnetwork
-.Em 131.104.48
-with root mapped to the uid for ``bin'' and with no group access.
-.Pp
-.Sy /u2
-is exported to the hosts in ``friends'' with root mapped to uid and groups
-associated with ``root'';
-it is exported to all hosts on network ``cis-net'' allowing mounts at any
-directory within /u2 and mapping all uids to credentials for the principal
-that is authenticated by a Kerberos ticket.
-.Sh FILES
-.Bl -tag -width /etc/exports -compact
-.It Pa /etc/exports
-the default remote mount-point file
-.El
-.Sh SEE ALSO
-.Xr netgroup 5 ,
-.Xr mountd 8 ,
-.Xr nfsd 8 ,
-.Xr showmount 8
-.Sh BUGS
-The export options are tied to the local mount points in the kernel and
-must be non-contradictory for any exported subdirectory of the local
-server mount point.
-It is recommended that all exported directories within the same server
-filesystem be specified on adjacent lines going down the tree.
-You cannot specify a hostname that is also the name of a netgroup.
-Specifying the full domain specification for a hostname can normally
-circumvent the problem.
diff --git a/usr.sbin/mountd/mountd.8 b/usr.sbin/mountd/mountd.8
deleted file mode 100644
index 98397f5a33f0..000000000000
--- a/usr.sbin/mountd/mountd.8
+++ /dev/null
@@ -1,147 +0,0 @@
-.\" Copyright (c) 1989, 1991, 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. 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, Berkeley and its contributors.
-.\" 4. 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.
-.\"
-.\" @(#)mountd.8 8.4 (Berkeley) 4/28/95
-.\" $FreeBSD$
-.\"
-.Dd April 28, 1995
-.Dt MOUNTD 8
-.Os
-.Sh NAME
-.Nm mountd
-.Nd service remote
-.Tn NFS
-mount requests
-.Sh SYNOPSIS
-.Nm mountd
-.Op Fl 2dlnr
-.Op Ar exportsfile
-.Sh DESCRIPTION
-.Nm Mountd
-is the server for
-.Tn NFS
-mount requests from other client machines.
-It listens for service requests at the port indicated in the
-.Tn NFS
-server specification; see
-.%T "Network File System Protocol Specification" ,
-RFC1094, Appendix A and
-.%T "NFS: Network File System Version 3 Protocol Specification" ,
-Appendix I.
-.Pp
-The following options are available:
-.Bl -tag -width indent
-.It Fl 2
-Allow the administrator to force clients to use only the
-version 2
-.Tn NFS
-protocol to mount filesystems from this server.
-.It Fl d
-Output debugging information.
-.It Fl l
-Cause all succeeded
-.Nm
-requests to be logged.
-.It Fl n
-Allow non-root mount requests to be served.
-This should only be specified if there are clients such as PC's,
-that require it.
-It will automatically clear the vfs.nfs.nfs_privport sysctl flag, which
-controls if the kernel will accept NFS requests from reserved ports only.
-.It Fl r
-Allow mount RPCs requests for regular files to be served.
-Although this seems to violate the mount protocol specification,
-some diskless workstations do mount requests for
-their swapfiles and expect them to be regular files.
-Since a regular file cannot be specified in
-.Pa /etc/exports ,
-the entire file system in which the swapfiles resides
-will have to be exported with the
-.Fl alldirs
-flag.
-.It Ar exportsfile
-Specify an alternate location
-for the exports file.
-.El
-.Pp
-When
-.Nm
-is started,
-it loads the export host addresses and options into the kernel
-using the mount(2) system call.
-After changing the exports file,
-a hangup signal should be sent to the
-.Nm
-daemon
-to get it to reload the export information.
-After sending the SIGHUP
-(kill \-s HUP `cat /var/run/mountd.pid`),
-check the syslog output to see if
-.Nm
-logged any parsing
-errors in the exports file.
-.Pp
-If
-.Nm
-detects that the running kernel does not include
-.Tn NFS
-support, it will attempt to load a loadable kernel module containing
-.Tn NFS
-code, using
-.Xr kldload 8
-by way of
-.Xr vfsload 3 .
-If this fails, or no
-.Tn NFS
-KLD was available,
-.Nm
-exits with an error.
-.Sh FILES
-.Bl -tag -width /var/run/mountd.pid -compact
-.It Pa /etc/exports
-the list of exported filesystems
-.It Pa /var/run/mountd.pid
-the pid of the currently running mountd
-.It Pa /var/db/mountdtab
-the current list of remote mounted filesystems
-.El
-.Sh SEE ALSO
-.Xr nfsstat 1 ,
-.Xr exports 5 ,
-.Xr kldload 8 ,
-.Xr nfsd 8 ,
-.Xr portmap 8 ,
-.Xr showmount 8
-.Sh HISTORY
-The
-.Nm
-utility first appeared in
-.Bx 4.4 .
diff --git a/usr.sbin/mountd/mountd.c b/usr.sbin/mountd/mountd.c
deleted file mode 100644
index ffb1b6ebb525..000000000000
--- a/usr.sbin/mountd/mountd.c
+++ /dev/null
@@ -1,2136 +0,0 @@
-/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Herb Hasler and Rick Macklem at The University of Guelph.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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 lint
-static const char copyright[] =
-"@(#) Copyright (c) 1989, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /*not lint*/
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)mountd.c 8.15 (Berkeley) 5/1/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /*not lint*/
-
-#include <sys/param.h>
-#include <sys/mount.h>
-#include <sys/stat.h>
-#include <sys/syslog.h>
-#include <sys/sysctl.h>
-
-#include <rpc/rpc.h>
-#include <rpc/pmap_clnt.h>
-#include <nfs/rpcv2.h>
-#include <nfs/nfsproto.h>
-#include <nfs/nfs.h>
-#include <ufs/ufs/ufsmount.h>
-#include <msdosfs/msdosfsmount.h>
-#include <ntfs/ntfsmount.h>
-#include <isofs/cd9660/cd9660_mount.h> /* XXX need isofs in include */
-
-#include <arpa/inet.h>
-
-#include <ctype.h>
-#include <err.h>
-#include <errno.h>
-#include <grp.h>
-#include <netdb.h>
-#include <pwd.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include "pathnames.h"
-
-#ifdef DEBUG
-#include <stdarg.h>
-#endif
-
-/*
- * Structures for keeping the mount list and export list
- */
-struct mountlist {
- struct mountlist *ml_next;
- char ml_host[RPCMNT_NAMELEN+1];
- char ml_dirp[RPCMNT_PATHLEN+1];
-};
-
-struct dirlist {
- struct dirlist *dp_left;
- struct dirlist *dp_right;
- int dp_flag;
- struct hostlist *dp_hosts; /* List of hosts this dir exported to */
- char dp_dirp[1]; /* Actually malloc'd to size of dir */
-};
-/* dp_flag bits */
-#define DP_DEFSET 0x1
-#define DP_HOSTSET 0x2
-#define DP_KERB 0x4
-
-struct exportlist {
- struct exportlist *ex_next;
- struct dirlist *ex_dirl;
- struct dirlist *ex_defdir;
- int ex_flag;
- fsid_t ex_fs;
- char *ex_fsdir;
- char *ex_indexfile;
-};
-/* ex_flag bits */
-#define EX_LINKED 0x1
-
-struct netmsk {
- u_int32_t nt_net;
- u_int32_t nt_mask;
- char *nt_name;
-};
-
-union grouptypes {
- struct hostent *gt_hostent;
- struct netmsk gt_net;
-};
-
-struct grouplist {
- int gr_type;
- union grouptypes gr_ptr;
- struct grouplist *gr_next;
-};
-/* Group types */
-#define GT_NULL 0x0
-#define GT_HOST 0x1
-#define GT_NET 0x2
-#define GT_IGNORE 0x5
-
-struct hostlist {
- int ht_flag; /* Uses DP_xx bits */
- struct grouplist *ht_grp;
- struct hostlist *ht_next;
-};
-
-struct fhreturn {
- int fhr_flag;
- int fhr_vers;
- nfsfh_t fhr_fh;
-};
-
-/* Global defs */
-char *add_expdir __P((struct dirlist **, char *, int));
-void add_dlist __P((struct dirlist **, struct dirlist *,
- struct grouplist *, int));
-void add_mlist __P((char *, char *));
-int check_dirpath __P((char *));
-int check_options __P((struct dirlist *));
-int chk_host __P((struct dirlist *, u_int32_t, int *, int *));
-void del_mlist __P((char *, char *));
-struct dirlist *dirp_search __P((struct dirlist *, char *));
-int do_mount __P((struct exportlist *, struct grouplist *, int,
- struct ucred *, char *, int, struct statfs *));
-int do_opt __P((char **, char **, struct exportlist *, struct grouplist *,
- int *, int *, struct ucred *));
-struct exportlist *ex_search __P((fsid_t *));
-struct exportlist *get_exp __P((void));
-void free_dir __P((struct dirlist *));
-void free_exp __P((struct exportlist *));
-void free_grp __P((struct grouplist *));
-void free_host __P((struct hostlist *));
-void get_exportlist __P((void));
-int get_host __P((char *, struct grouplist *, struct grouplist *));
-int get_num __P((char *));
-struct hostlist *get_ht __P((void));
-int get_line __P((void));
-void get_mountlist __P((void));
-int get_net __P((char *, struct netmsk *, int));
-void getexp_err __P((struct exportlist *, struct grouplist *));
-struct grouplist *get_grp __P((void));
-void hang_dirp __P((struct dirlist *, struct grouplist *,
- struct exportlist *, int));
-void mntsrv __P((struct svc_req *, SVCXPRT *));
-void nextfield __P((char **, char **));
-void out_of_mem __P((void));
-void parsecred __P((char *, struct ucred *));
-int put_exlist __P((struct dirlist *, XDR *, struct dirlist *, int *));
-int scan_tree __P((struct dirlist *, u_int32_t));
-static void usage __P((void));
-int xdr_dir __P((XDR *, char *));
-int xdr_explist __P((XDR *, caddr_t));
-int xdr_fhs __P((XDR *, caddr_t));
-int xdr_mlist __P((XDR *, caddr_t));
-
-/* C library */
-int getnetgrent();
-void endnetgrent();
-void setnetgrent();
-
-struct exportlist *exphead;
-struct mountlist *mlhead;
-struct grouplist *grphead;
-char exname[MAXPATHLEN];
-struct ucred def_anon = {
- 1,
- (uid_t) -2,
- 1,
- { (gid_t) -2 }
-};
-int force_v2 = 0;
-int resvport_only = 1;
-int dir_only = 1;
-int log = 0;
-int opt_flags;
-/* Bits for above */
-#define OP_MAPROOT 0x01
-#define OP_MAPALL 0x02
-#define OP_KERB 0x04
-#define OP_MASK 0x08
-#define OP_NET 0x10
-#define OP_ALLDIRS 0x40
-
-#ifdef DEBUG
-int debug = 1;
-void SYSLOG __P((int, const char *, ...));
-#define syslog SYSLOG
-#else
-int debug = 0;
-#endif
-
-/*
- * Mountd server for NFS mount protocol as described in:
- * NFS: Network File System Protocol Specification, RFC1094, Appendix A
- * The optional arguments are the exports file name
- * default: _PATH_EXPORTS
- * and "-n" to allow nonroot mount.
- */
-int
-main(argc, argv)
- int argc;
- char **argv;
-{
- SVCXPRT *udptransp, *tcptransp;
- int c, error, mib[3];
- struct vfsconf vfc;
-
- error = getvfsbyname("nfs", &vfc);
- if (error && vfsisloadable("nfs")) {
- if(vfsload("nfs"))
- err(1, "vfsload(nfs)");
- endvfsent(); /* flush cache */
- error = getvfsbyname("nfs", &vfc);
- }
- if (error)
- errx(1, "NFS support is not available in the running kernel");
-
- while ((c = getopt(argc, argv, "2dlnr")) != -1)
- switch (c) {
- case '2':
- force_v2 = 1;
- break;
- case 'n':
- resvport_only = 0;
- break;
- case 'r':
- dir_only = 0;
- break;
- case 'd':
- debug = debug ? 0 : 1;
- break;
- case 'l':
- log = 1;
- break;
- default:
- usage();
- };
- argc -= optind;
- argv += optind;
- grphead = (struct grouplist *)NULL;
- exphead = (struct exportlist *)NULL;
- mlhead = (struct mountlist *)NULL;
- if (argc == 1) {
- strncpy(exname, *argv, MAXPATHLEN-1);
- exname[MAXPATHLEN-1] = '\0';
- } else
- strcpy(exname, _PATH_EXPORTS);
- openlog("mountd", LOG_PID, LOG_DAEMON);
- if (debug)
- warnx("getting export list");
- get_exportlist();
- if (debug)
- warnx("getting mount list");
- get_mountlist();
- if (debug)
- warnx("here we go");
- if (debug == 0) {
- daemon(0, 0);
- signal(SIGINT, SIG_IGN);
- signal(SIGQUIT, SIG_IGN);
- }
- signal(SIGHUP, (void (*) __P((int))) get_exportlist);
- { FILE *pidfile = fopen(_PATH_MOUNTDPID, "w");
- if (pidfile != NULL) {
- fprintf(pidfile, "%d\n", getpid());
- fclose(pidfile);
- }
- }
- if (!resvport_only) {
- mib[0] = CTL_VFS;
- mib[1] = vfc.vfc_typenum;
- mib[2] = NFS_NFSPRIVPORT;
- if (sysctl(mib, 3, NULL, NULL, &resvport_only,
- sizeof(resvport_only)) != 0 && errno != ENOENT) {
- syslog(LOG_ERR, "sysctl: %m");
- exit(1);
- }
- }
- if ((udptransp = svcudp_create(RPC_ANYSOCK)) == NULL ||
- (tcptransp = svctcp_create(RPC_ANYSOCK, 0, 0)) == NULL) {
- syslog(LOG_ERR, "can't create socket");
- exit(1);
- }
- pmap_unset(RPCPROG_MNT, 1);
- pmap_unset(RPCPROG_MNT, 3);
- if (!force_v2)
- if (!svc_register(udptransp, RPCPROG_MNT, 3, mntsrv, IPPROTO_UDP) ||
- !svc_register(tcptransp, RPCPROG_MNT, 3, mntsrv, IPPROTO_TCP)) {
- syslog(LOG_ERR, "can't register mount");
- exit(1);
- }
- if (!svc_register(udptransp, RPCPROG_MNT, 1, mntsrv, IPPROTO_UDP) ||
- !svc_register(tcptransp, RPCPROG_MNT, 1, mntsrv, IPPROTO_TCP)) {
- syslog(LOG_ERR, "can't register mount");
- exit(1);
- }
- svc_run();
- syslog(LOG_ERR, "mountd died");
- exit(1);
-}
-
-static void
-usage()
-{
- fprintf(stderr,
- "usage: mountd [-2] [-d] [-l] [-n] [-r] [export_file]\n");
- exit(1);
-}
-
-/*
- * The mount rpc service
- */
-void
-mntsrv(rqstp, transp)
- struct svc_req *rqstp;
- SVCXPRT *transp;
-{
- struct exportlist *ep;
- struct dirlist *dp;
- struct fhreturn fhr;
- struct stat stb;
- struct statfs fsb;
- struct hostent *hp;
- struct in_addr saddrin;
- u_int32_t saddr;
- u_short sport;
- char rpcpath[RPCMNT_PATHLEN + 1], dirpath[MAXPATHLEN];
- int bad = 0, defset, hostset;
- sigset_t sighup_mask;
-
- sigemptyset(&sighup_mask);
- sigaddset(&sighup_mask, SIGHUP);
- saddr = transp->xp_raddr.sin_addr.s_addr;
- saddrin = transp->xp_raddr.sin_addr;
- sport = ntohs(transp->xp_raddr.sin_port);
- hp = (struct hostent *)NULL;
- switch (rqstp->rq_proc) {
- case NULLPROC:
- if (!svc_sendreply(transp, xdr_void, (caddr_t)NULL))
- syslog(LOG_ERR, "can't send reply");
- return;
- case RPCMNT_MOUNT:
- if (sport >= IPPORT_RESERVED && resvport_only) {
- syslog(LOG_NOTICE,
- "mount request from %s from unprivileged port",
- inet_ntoa(saddrin));
- svcerr_weakauth(transp);
- return;
- }
- if (!svc_getargs(transp, xdr_dir, rpcpath)) {
- syslog(LOG_NOTICE, "undecodable mount request from %s",
- inet_ntoa(saddrin));
- svcerr_decode(transp);
- return;
- }
-
- /*
- * Get the real pathname and make sure it is a directory
- * or a regular file if the -r option was specified
- * and it exists.
- */
- if (realpath(rpcpath, dirpath) == NULL ||
- stat(dirpath, &stb) < 0 ||
- (!S_ISDIR(stb.st_mode) &&
- (dir_only || !S_ISREG(stb.st_mode))) ||
- statfs(dirpath, &fsb) < 0) {
- chdir("/"); /* Just in case realpath doesn't */
- syslog(LOG_NOTICE,
- "mount request from %s for non existent path %s",
- inet_ntoa(saddrin), dirpath);
- if (debug)
- warnx("stat failed on %s", dirpath);
- bad = ENOENT; /* We will send error reply later */
- }
-
- /* Check in the exports list */
- sigprocmask(SIG_BLOCK, &sighup_mask, NULL);
- ep = ex_search(&fsb.f_fsid);
- hostset = defset = 0;
- if (ep && (chk_host(ep->ex_defdir, saddr, &defset, &hostset) ||
- ((dp = dirp_search(ep->ex_dirl, dirpath)) &&
- chk_host(dp, saddr, &defset, &hostset)) ||
- (defset && scan_tree(ep->ex_defdir, saddr) == 0 &&
- scan_tree(ep->ex_dirl, saddr) == 0))) {
- if (bad) {
- if (!svc_sendreply(transp, xdr_long,
- (caddr_t)&bad))
- syslog(LOG_ERR, "can't send reply");
- sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL);
- return;
- }
- if (hostset & DP_HOSTSET)
- fhr.fhr_flag = hostset;
- else
- fhr.fhr_flag = defset;
- fhr.fhr_vers = rqstp->rq_vers;
- /* Get the file handle */
- memset(&fhr.fhr_fh, 0, sizeof(nfsfh_t));
- if (getfh(dirpath, (fhandle_t *)&fhr.fhr_fh) < 0) {
- bad = errno;
- syslog(LOG_ERR, "can't get fh for %s", dirpath);
- if (!svc_sendreply(transp, xdr_long,
- (caddr_t)&bad))
- syslog(LOG_ERR, "can't send reply");
- sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL);
- return;
- }
- if (!svc_sendreply(transp, xdr_fhs, (caddr_t)&fhr))
- syslog(LOG_ERR, "can't send reply");
- if (hp == NULL)
- hp = gethostbyaddr((caddr_t)&saddr,
- sizeof(saddr), AF_INET);
- if (hp)
- add_mlist(hp->h_name, dirpath);
- else
- add_mlist(inet_ntoa(saddrin),
- dirpath);
- if (debug)
- warnx("mount successful");
- if (log)
- syslog(LOG_NOTICE,
- "mount request succeeded from %s for %s",
- inet_ntoa(saddrin), dirpath);
- } else {
- bad = EACCES;
- syslog(LOG_NOTICE,
- "mount request denied from %s for %s",
- inet_ntoa(saddrin), dirpath);
- }
-
- if (bad && !svc_sendreply(transp, xdr_long, (caddr_t)&bad))
- syslog(LOG_ERR, "can't send reply");
- sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL);
- return;
- case RPCMNT_DUMP:
- if (!svc_sendreply(transp, xdr_mlist, (caddr_t)NULL))
- syslog(LOG_ERR, "can't send reply");
- else if (log)
- syslog(LOG_NOTICE,
- "dump request succeeded from %s",
- inet_ntoa(saddrin));
- return;
- case RPCMNT_UMOUNT:
- if (sport >= IPPORT_RESERVED && resvport_only) {
- syslog(LOG_NOTICE,
- "umount request from %s from unprivileged port",
- inet_ntoa(saddrin));
- svcerr_weakauth(transp);
- return;
- }
- if (!svc_getargs(transp, xdr_dir, rpcpath)) {
- syslog(LOG_NOTICE, "undecodable umount request from %s",
- inet_ntoa(saddrin));
- svcerr_decode(transp);
- return;
- }
- if (realpath(rpcpath, dirpath) == NULL) {
- syslog(LOG_NOTICE, "umount request from %s "
- "for non existent path %s",
- inet_ntoa(saddrin), dirpath);
- }
- if (!svc_sendreply(transp, xdr_void, (caddr_t)NULL))
- syslog(LOG_ERR, "can't send reply");
- hp = gethostbyaddr((caddr_t)&saddr, sizeof(saddr), AF_INET);
- if (hp)
- del_mlist(hp->h_name, dirpath);
- del_mlist(inet_ntoa(saddrin), dirpath);
- if (log)
- syslog(LOG_NOTICE,
- "umount request succeeded from %s for %s",
- inet_ntoa(saddrin), dirpath);
- return;
- case RPCMNT_UMNTALL:
- if (sport >= IPPORT_RESERVED && resvport_only) {
- syslog(LOG_NOTICE,
- "umountall request from %s from unprivileged port",
- inet_ntoa(saddrin));
- svcerr_weakauth(transp);
- return;
- }
- if (!svc_sendreply(transp, xdr_void, (caddr_t)NULL))
- syslog(LOG_ERR, "can't send reply");
- hp = gethostbyaddr((caddr_t)&saddr, sizeof(saddr), AF_INET);
- if (hp)
- del_mlist(hp->h_name, (char *)NULL);
- del_mlist(inet_ntoa(saddrin), (char *)NULL);
- if (log)
- syslog(LOG_NOTICE,
- "umountall request succeeded from %s",
- inet_ntoa(saddrin));
- return;
- case RPCMNT_EXPORT:
- if (!svc_sendreply(transp, xdr_explist, (caddr_t)NULL))
- syslog(LOG_ERR, "can't send reply");
- if (log)
- syslog(LOG_NOTICE,
- "export request succeeded from %s",
- inet_ntoa(saddrin));
- return;
- default:
- svcerr_noproc(transp);
- return;
- }
-}
-
-/*
- * Xdr conversion for a dirpath string
- */
-int
-xdr_dir(xdrsp, dirp)
- XDR *xdrsp;
- char *dirp;
-{
- return (xdr_string(xdrsp, &dirp, RPCMNT_PATHLEN));
-}
-
-/*
- * Xdr routine to generate file handle reply
- */
-int
-xdr_fhs(xdrsp, cp)
- XDR *xdrsp;
- caddr_t cp;
-{
- register struct fhreturn *fhrp = (struct fhreturn *)cp;
- u_long ok = 0, len, auth;
-
- if (!xdr_long(xdrsp, &ok))
- return (0);
- switch (fhrp->fhr_vers) {
- case 1:
- return (xdr_opaque(xdrsp, (caddr_t)&fhrp->fhr_fh, NFSX_V2FH));
- case 3:
- len = NFSX_V3FH;
- if (!xdr_long(xdrsp, &len))
- return (0);
- if (!xdr_opaque(xdrsp, (caddr_t)&fhrp->fhr_fh, len))
- return (0);
- if (fhrp->fhr_flag & DP_KERB)
- auth = RPCAUTH_KERB4;
- else
- auth = RPCAUTH_UNIX;
- len = 1;
- if (!xdr_long(xdrsp, &len))
- return (0);
- return (xdr_long(xdrsp, &auth));
- };
- return (0);
-}
-
-int
-xdr_mlist(xdrsp, cp)
- XDR *xdrsp;
- caddr_t cp;
-{
- struct mountlist *mlp;
- int true = 1;
- int false = 0;
- char *strp;
-
- mlp = mlhead;
- while (mlp) {
- if (!xdr_bool(xdrsp, &true))
- return (0);
- strp = &mlp->ml_host[0];
- if (!xdr_string(xdrsp, &strp, RPCMNT_NAMELEN))
- return (0);
- strp = &mlp->ml_dirp[0];
- if (!xdr_string(xdrsp, &strp, RPCMNT_PATHLEN))
- return (0);
- mlp = mlp->ml_next;
- }
- if (!xdr_bool(xdrsp, &false))
- return (0);
- return (1);
-}
-
-/*
- * Xdr conversion for export list
- */
-int
-xdr_explist(xdrsp, cp)
- XDR *xdrsp;
- caddr_t cp;
-{
- struct exportlist *ep;
- int false = 0;
- int putdef;
- sigset_t sighup_mask;
-
- sigemptyset(&sighup_mask);
- sigaddset(&sighup_mask, SIGHUP);
- sigprocmask(SIG_BLOCK, &sighup_mask, NULL);
- ep = exphead;
- while (ep) {
- putdef = 0;
- if (put_exlist(ep->ex_dirl, xdrsp, ep->ex_defdir, &putdef))
- goto errout;
- if (ep->ex_defdir && putdef == 0 &&
- put_exlist(ep->ex_defdir, xdrsp, (struct dirlist *)NULL,
- &putdef))
- goto errout;
- ep = ep->ex_next;
- }
- sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL);
- if (!xdr_bool(xdrsp, &false))
- return (0);
- return (1);
-errout:
- sigprocmask(SIG_UNBLOCK, &sighup_mask, NULL);
- return (0);
-}
-
-/*
- * Called from xdr_explist() to traverse the tree and export the
- * directory paths.
- */
-int
-put_exlist(dp, xdrsp, adp, putdefp)
- struct dirlist *dp;
- XDR *xdrsp;
- struct dirlist *adp;
- int *putdefp;
-{
- struct grouplist *grp;
- struct hostlist *hp;
- int true = 1;
- int false = 0;
- int gotalldir = 0;
- char *strp;
-
- if (dp) {
- if (put_exlist(dp->dp_left, xdrsp, adp, putdefp))
- return (1);
- if (!xdr_bool(xdrsp, &true))
- return (1);
- strp = dp->dp_dirp;
- if (!xdr_string(xdrsp, &strp, RPCMNT_PATHLEN))
- return (1);
- if (adp && !strcmp(dp->dp_dirp, adp->dp_dirp)) {
- gotalldir = 1;
- *putdefp = 1;
- }
- if ((dp->dp_flag & DP_DEFSET) == 0 &&
- (gotalldir == 0 || (adp->dp_flag & DP_DEFSET) == 0)) {
- hp = dp->dp_hosts;
- while (hp) {
- grp = hp->ht_grp;
- if (grp->gr_type == GT_HOST) {
- if (!xdr_bool(xdrsp, &true))
- return (1);
- strp = grp->gr_ptr.gt_hostent->h_name;
- if (!xdr_string(xdrsp, &strp,
- RPCMNT_NAMELEN))
- return (1);
- } else if (grp->gr_type == GT_NET) {
- if (!xdr_bool(xdrsp, &true))
- return (1);
- strp = grp->gr_ptr.gt_net.nt_name;
- if (!xdr_string(xdrsp, &strp,
- RPCMNT_NAMELEN))
- return (1);
- }
- hp = hp->ht_next;
- if (gotalldir && hp == (struct hostlist *)NULL) {
- hp = adp->dp_hosts;
- gotalldir = 0;
- }
- }
- }
- if (!xdr_bool(xdrsp, &false))
- return (1);
- if (put_exlist(dp->dp_right, xdrsp, adp, putdefp))
- return (1);
- }
- return (0);
-}
-
-#define LINESIZ 10240
-char line[LINESIZ];
-FILE *exp_file;
-
-/*
- * Get the export list
- */
-void
-get_exportlist()
-{
- struct exportlist *ep, *ep2;
- struct grouplist *grp, *tgrp;
- struct exportlist **epp;
- struct dirlist *dirhead;
- struct statfs fsb, *fsp;
- struct hostent *hpe;
- struct ucred anon;
- char *cp, *endcp, *dirp, *hst, *usr, *dom, savedc;
- int len, has_host, exflags, got_nondir, dirplen, num, i, netgrp;
-
- dirp = NULL;
- dirplen = 0;
-
- /*
- * First, get rid of the old list
- */
- ep = exphead;
- while (ep) {
- ep2 = ep;
- ep = ep->ex_next;
- free_exp(ep2);
- }
- exphead = (struct exportlist *)NULL;
-
- grp = grphead;
- while (grp) {
- tgrp = grp;
- grp = grp->gr_next;
- free_grp(tgrp);
- }
- grphead = (struct grouplist *)NULL;
-
- /*
- * And delete exports that are in the kernel for all local
- * file systems.
- * XXX: Should know how to handle all local exportable file systems
- * instead of just "ufs".
- */
- num = getmntinfo(&fsp, MNT_NOWAIT);
- for (i = 0; i < num; i++) {
- union {
- struct ufs_args ua;
- struct iso_args ia;
- struct mfs_args ma;
- struct msdosfs_args da;
- struct ntfs_args na;
- } targs;
-
- if (!strcmp(fsp->f_fstypename, "mfs") ||
- !strcmp(fsp->f_fstypename, "ufs") ||
- !strcmp(fsp->f_fstypename, "msdos") ||
- !strcmp(fsp->f_fstypename, "ntfs") ||
- !strcmp(fsp->f_fstypename, "cd9660")) {
- targs.ua.fspec = NULL;
- targs.ua.export.ex_flags = MNT_DELEXPORT;
- if (mount(fsp->f_fstypename, fsp->f_mntonname,
- fsp->f_flags | MNT_UPDATE,
- (caddr_t)&targs) < 0)
- syslog(LOG_ERR, "can't delete exports for %s",
- fsp->f_mntonname);
- }
- fsp++;
- }
-
- /*
- * Read in the exports file and build the list, calling
- * mount() as we go along to push the export rules into the kernel.
- */
- if ((exp_file = fopen(exname, "r")) == NULL) {
- syslog(LOG_ERR, "can't open %s", exname);
- exit(2);
- }
- dirhead = (struct dirlist *)NULL;
- while (get_line()) {
- if (debug)
- warnx("got line %s", line);
- cp = line;
- nextfield(&cp, &endcp);
- if (*cp == '#')
- goto nextline;
-
- /*
- * Set defaults.
- */
- has_host = FALSE;
- anon = def_anon;
- exflags = MNT_EXPORTED;
- got_nondir = 0;
- opt_flags = 0;
- ep = (struct exportlist *)NULL;
-
- /*
- * Create new exports list entry
- */
- len = endcp-cp;
- tgrp = grp = get_grp();
- while (len > 0) {
- if (len > RPCMNT_NAMELEN) {
- getexp_err(ep, tgrp);
- goto nextline;
- }
- if (*cp == '-') {
- if (ep == (struct exportlist *)NULL) {
- getexp_err(ep, tgrp);
- goto nextline;
- }
- if (debug)
- warnx("doing opt %s", cp);
- got_nondir = 1;
- if (do_opt(&cp, &endcp, ep, grp, &has_host,
- &exflags, &anon)) {
- getexp_err(ep, tgrp);
- goto nextline;
- }
- } else if (*cp == '/') {
- savedc = *endcp;
- *endcp = '\0';
- if (check_dirpath(cp) &&
- statfs(cp, &fsb) >= 0) {
- if (got_nondir) {
- syslog(LOG_ERR, "dirs must be first");
- getexp_err(ep, tgrp);
- goto nextline;
- }
- if (ep) {
- if (ep->ex_fs.val[0] != fsb.f_fsid.val[0] ||
- ep->ex_fs.val[1] != fsb.f_fsid.val[1]) {
- getexp_err(ep, tgrp);
- goto nextline;
- }
- } else {
- /*
- * See if this directory is already
- * in the list.
- */
- ep = ex_search(&fsb.f_fsid);
- if (ep == (struct exportlist *)NULL) {
- ep = get_exp();
- ep->ex_fs = fsb.f_fsid;
- ep->ex_fsdir = (char *)
- malloc(strlen(fsb.f_mntonname) + 1);
- if (ep->ex_fsdir)
- strcpy(ep->ex_fsdir,
- fsb.f_mntonname);
- else
- out_of_mem();
- if (debug)
- warnx("making new ep fs=0x%x,0x%x",
- fsb.f_fsid.val[0],
- fsb.f_fsid.val[1]);
- } else if (debug)
- warnx("found ep fs=0x%x,0x%x",
- fsb.f_fsid.val[0],
- fsb.f_fsid.val[1]);
- }
-
- /*
- * Add dirpath to export mount point.
- */
- dirp = add_expdir(&dirhead, cp, len);
- dirplen = len;
- } else {
- getexp_err(ep, tgrp);
- goto nextline;
- }
- *endcp = savedc;
- } else {
- savedc = *endcp;
- *endcp = '\0';
- got_nondir = 1;
- if (ep == (struct exportlist *)NULL) {
- getexp_err(ep, tgrp);
- goto nextline;
- }
-
- /*
- * Get the host or netgroup.
- */
- setnetgrent(cp);
- netgrp = getnetgrent(&hst, &usr, &dom);
- do {
- if (has_host) {
- grp->gr_next = get_grp();
- grp = grp->gr_next;
- }
- if (netgrp) {
- if (hst == 0) {
- syslog(LOG_ERR,
- "null hostname in netgroup %s, skipping", cp);
- grp->gr_type = GT_IGNORE;
- } else if (get_host(hst, grp, tgrp)) {
- syslog(LOG_ERR,
- "bad host %s in netgroup %s, skipping", hst, cp);
- grp->gr_type = GT_IGNORE;
- }
- } else if (get_host(cp, grp, tgrp)) {
- syslog(LOG_ERR, "bad host %s, skipping", cp);
- grp->gr_type = GT_IGNORE;
- }
- has_host = TRUE;
- } while (netgrp && getnetgrent(&hst, &usr, &dom));
- endnetgrent();
- *endcp = savedc;
- }
- cp = endcp;
- nextfield(&cp, &endcp);
- len = endcp - cp;
- }
- if (check_options(dirhead)) {
- getexp_err(ep, tgrp);
- goto nextline;
- }
- if (!has_host) {
- grp->gr_type = GT_HOST;
- if (debug)
- warnx("adding a default entry");
- /* add a default group and make the grp list NULL */
- hpe = (struct hostent *)malloc(sizeof(struct hostent));
- if (hpe == (struct hostent *)NULL)
- out_of_mem();
- hpe->h_name = strdup("Default");
- hpe->h_addrtype = AF_INET;
- hpe->h_length = sizeof (u_int32_t);
- hpe->h_addr_list = (char **)NULL;
- grp->gr_ptr.gt_hostent = hpe;
-
- /*
- * Don't allow a network export coincide with a list of
- * host(s) on the same line.
- */
- } else if ((opt_flags & OP_NET) && tgrp->gr_next) {
- getexp_err(ep, tgrp);
- goto nextline;
-
- /*
- * If an export list was specified on this line, make sure
- * that we have at least one valid entry, otherwise skip it.
- */
- } else {
- grp = tgrp;
- while (grp && grp->gr_type == GT_IGNORE)
- grp = grp->gr_next;
- if (! grp) {
- getexp_err(ep, tgrp);
- goto nextline;
- }
- }
-
- /*
- * Loop through hosts, pushing the exports into the kernel.
- * After loop, tgrp points to the start of the list and
- * grp points to the last entry in the list.
- */
- grp = tgrp;
- do {
- if (do_mount(ep, grp, exflags, &anon, dirp,
- dirplen, &fsb)) {
- getexp_err(ep, tgrp);
- goto nextline;
- }
- } while (grp->gr_next && (grp = grp->gr_next));
-
- /*
- * Success. Update the data structures.
- */
- if (has_host) {
- hang_dirp(dirhead, tgrp, ep, opt_flags);
- grp->gr_next = grphead;
- grphead = tgrp;
- } else {
- hang_dirp(dirhead, (struct grouplist *)NULL, ep,
- opt_flags);
- free_grp(grp);
- }
- dirhead = (struct dirlist *)NULL;
- if ((ep->ex_flag & EX_LINKED) == 0) {
- ep2 = exphead;
- epp = &exphead;
-
- /*
- * Insert in the list in alphabetical order.
- */
- while (ep2 && strcmp(ep2->ex_fsdir, ep->ex_fsdir) < 0) {
- epp = &ep2->ex_next;
- ep2 = ep2->ex_next;
- }
- if (ep2)
- ep->ex_next = ep2;
- *epp = ep;
- ep->ex_flag |= EX_LINKED;
- }
-nextline:
- if (dirhead) {
- free_dir(dirhead);
- dirhead = (struct dirlist *)NULL;
- }
- }
- fclose(exp_file);
-}
-
-/*
- * Allocate an export list element
- */
-struct exportlist *
-get_exp()
-{
- struct exportlist *ep;
-
- ep = (struct exportlist *)malloc(sizeof (struct exportlist));
- if (ep == (struct exportlist *)NULL)
- out_of_mem();
- memset(ep, 0, sizeof(struct exportlist));
- return (ep);
-}
-
-/*
- * Allocate a group list element
- */
-struct grouplist *
-get_grp()
-{
- struct grouplist *gp;
-
- gp = (struct grouplist *)malloc(sizeof (struct grouplist));
- if (gp == (struct grouplist *)NULL)
- out_of_mem();
- memset(gp, 0, sizeof(struct grouplist));
- return (gp);
-}
-
-/*
- * Clean up upon an error in get_exportlist().
- */
-void
-getexp_err(ep, grp)
- struct exportlist *ep;
- struct grouplist *grp;
-{
- struct grouplist *tgrp;
-
- syslog(LOG_ERR, "bad exports list line %s", line);
- if (ep && (ep->ex_flag & EX_LINKED) == 0)
- free_exp(ep);
- while (grp) {
- tgrp = grp;
- grp = grp->gr_next;
- free_grp(tgrp);
- }
-}
-
-/*
- * Search the export list for a matching fs.
- */
-struct exportlist *
-ex_search(fsid)
- fsid_t *fsid;
-{
- struct exportlist *ep;
-
- ep = exphead;
- while (ep) {
- if (ep->ex_fs.val[0] == fsid->val[0] &&
- ep->ex_fs.val[1] == fsid->val[1])
- return (ep);
- ep = ep->ex_next;
- }
- return (ep);
-}
-
-/*
- * Add a directory path to the list.
- */
-char *
-add_expdir(dpp, cp, len)
- struct dirlist **dpp;
- char *cp;
- int len;
-{
- struct dirlist *dp;
-
- dp = (struct dirlist *)malloc(sizeof (struct dirlist) + len);
- if (dp == (struct dirlist *)NULL)
- out_of_mem();
- dp->dp_left = *dpp;
- dp->dp_right = (struct dirlist *)NULL;
- dp->dp_flag = 0;
- dp->dp_hosts = (struct hostlist *)NULL;
- strcpy(dp->dp_dirp, cp);
- *dpp = dp;
- return (dp->dp_dirp);
-}
-
-/*
- * Hang the dir list element off the dirpath binary tree as required
- * and update the entry for host.
- */
-void
-hang_dirp(dp, grp, ep, flags)
- struct dirlist *dp;
- struct grouplist *grp;
- struct exportlist *ep;
- int flags;
-{
- struct hostlist *hp;
- struct dirlist *dp2;
-
- if (flags & OP_ALLDIRS) {
- if (ep->ex_defdir)
- free((caddr_t)dp);
- else
- ep->ex_defdir = dp;
- if (grp == (struct grouplist *)NULL) {
- ep->ex_defdir->dp_flag |= DP_DEFSET;
- if (flags & OP_KERB)
- ep->ex_defdir->dp_flag |= DP_KERB;
- } else while (grp) {
- hp = get_ht();
- if (flags & OP_KERB)
- hp->ht_flag |= DP_KERB;
- hp->ht_grp = grp;
- hp->ht_next = ep->ex_defdir->dp_hosts;
- ep->ex_defdir->dp_hosts = hp;
- grp = grp->gr_next;
- }
- } else {
-
- /*
- * Loop through the directories adding them to the tree.
- */
- while (dp) {
- dp2 = dp->dp_left;
- add_dlist(&ep->ex_dirl, dp, grp, flags);
- dp = dp2;
- }
- }
-}
-
-/*
- * Traverse the binary tree either updating a node that is already there
- * for the new directory or adding the new node.
- */
-void
-add_dlist(dpp, newdp, grp, flags)
- struct dirlist **dpp;
- struct dirlist *newdp;
- struct grouplist *grp;
- int flags;
-{
- struct dirlist *dp;
- struct hostlist *hp;
- int cmp;
-
- dp = *dpp;
- if (dp) {
- cmp = strcmp(dp->dp_dirp, newdp->dp_dirp);
- if (cmp > 0) {
- add_dlist(&dp->dp_left, newdp, grp, flags);
- return;
- } else if (cmp < 0) {
- add_dlist(&dp->dp_right, newdp, grp, flags);
- return;
- } else
- free((caddr_t)newdp);
- } else {
- dp = newdp;
- dp->dp_left = (struct dirlist *)NULL;
- *dpp = dp;
- }
- if (grp) {
-
- /*
- * Hang all of the host(s) off of the directory point.
- */
- do {
- hp = get_ht();
- if (flags & OP_KERB)
- hp->ht_flag |= DP_KERB;
- hp->ht_grp = grp;
- hp->ht_next = dp->dp_hosts;
- dp->dp_hosts = hp;
- grp = grp->gr_next;
- } while (grp);
- } else {
- dp->dp_flag |= DP_DEFSET;
- if (flags & OP_KERB)
- dp->dp_flag |= DP_KERB;
- }
-}
-
-/*
- * Search for a dirpath on the export point.
- */
-struct dirlist *
-dirp_search(dp, dirpath)
- struct dirlist *dp;
- char *dirpath;
-{
- int cmp;
-
- if (dp) {
- cmp = strcmp(dp->dp_dirp, dirpath);
- if (cmp > 0)
- return (dirp_search(dp->dp_left, dirpath));
- else if (cmp < 0)
- return (dirp_search(dp->dp_right, dirpath));
- else
- return (dp);
- }
- return (dp);
-}
-
-/*
- * Scan for a host match in a directory tree.
- */
-int
-chk_host(dp, saddr, defsetp, hostsetp)
- struct dirlist *dp;
- u_int32_t saddr;
- int *defsetp;
- int *hostsetp;
-{
- struct hostlist *hp;
- struct grouplist *grp;
- u_int32_t **addrp;
-
- if (dp) {
- if (dp->dp_flag & DP_DEFSET)
- *defsetp = dp->dp_flag;
- hp = dp->dp_hosts;
- while (hp) {
- grp = hp->ht_grp;
- switch (grp->gr_type) {
- case GT_HOST:
- addrp = (u_int32_t **)
- grp->gr_ptr.gt_hostent->h_addr_list;
- while (*addrp) {
- if (**addrp == saddr) {
- *hostsetp = (hp->ht_flag | DP_HOSTSET);
- return (1);
- }
- addrp++;
- }
- break;
- case GT_NET:
- if ((saddr & grp->gr_ptr.gt_net.nt_mask) ==
- grp->gr_ptr.gt_net.nt_net) {
- *hostsetp = (hp->ht_flag | DP_HOSTSET);
- return (1);
- }
- break;
- };
- hp = hp->ht_next;
- }
- }
- return (0);
-}
-
-/*
- * Scan tree for a host that matches the address.
- */
-int
-scan_tree(dp, saddr)
- struct dirlist *dp;
- u_int32_t saddr;
-{
- int defset, hostset;
-
- if (dp) {
- if (scan_tree(dp->dp_left, saddr))
- return (1);
- if (chk_host(dp, saddr, &defset, &hostset))
- return (1);
- if (scan_tree(dp->dp_right, saddr))
- return (1);
- }
- return (0);
-}
-
-/*
- * Traverse the dirlist tree and free it up.
- */
-void
-free_dir(dp)
- struct dirlist *dp;
-{
-
- if (dp) {
- free_dir(dp->dp_left);
- free_dir(dp->dp_right);
- free_host(dp->dp_hosts);
- free((caddr_t)dp);
- }
-}
-
-/*
- * Parse the option string and update fields.
- * Option arguments may either be -<option>=<value> or
- * -<option> <value>
- */
-int
-do_opt(cpp, endcpp, ep, grp, has_hostp, exflagsp, cr)
- char **cpp, **endcpp;
- struct exportlist *ep;
- struct grouplist *grp;
- int *has_hostp;
- int *exflagsp;
- struct ucred *cr;
-{
- char *cpoptarg, *cpoptend;
- char *cp, *endcp, *cpopt, savedc, savedc2;
- int allflag, usedarg;
-
- savedc2 = '\0';
- cpopt = *cpp;
- cpopt++;
- cp = *endcpp;
- savedc = *cp;
- *cp = '\0';
- while (cpopt && *cpopt) {
- allflag = 1;
- usedarg = -2;
- if ((cpoptend = strchr(cpopt, ','))) {
- *cpoptend++ = '\0';
- if ((cpoptarg = strchr(cpopt, '=')))
- *cpoptarg++ = '\0';
- } else {
- if ((cpoptarg = strchr(cpopt, '=')))
- *cpoptarg++ = '\0';
- else {
- *cp = savedc;
- nextfield(&cp, &endcp);
- **endcpp = '\0';
- if (endcp > cp && *cp != '-') {
- cpoptarg = cp;
- savedc2 = *endcp;
- *endcp = '\0';
- usedarg = 0;
- }
- }
- }
- if (!strcmp(cpopt, "ro") || !strcmp(cpopt, "o")) {
- *exflagsp |= MNT_EXRDONLY;
- } else if (cpoptarg && (!strcmp(cpopt, "maproot") ||
- !(allflag = strcmp(cpopt, "mapall")) ||
- !strcmp(cpopt, "root") || !strcmp(cpopt, "r"))) {
- usedarg++;
- parsecred(cpoptarg, cr);
- if (allflag == 0) {
- *exflagsp |= MNT_EXPORTANON;
- opt_flags |= OP_MAPALL;
- } else
- opt_flags |= OP_MAPROOT;
- } else if (!strcmp(cpopt, "kerb") || !strcmp(cpopt, "k")) {
- *exflagsp |= MNT_EXKERB;
- opt_flags |= OP_KERB;
- } else if (cpoptarg && (!strcmp(cpopt, "mask") ||
- !strcmp(cpopt, "m"))) {
- if (get_net(cpoptarg, &grp->gr_ptr.gt_net, 1)) {
- syslog(LOG_ERR, "bad mask: %s", cpoptarg);
- return (1);
- }
- usedarg++;
- opt_flags |= OP_MASK;
- } else if (cpoptarg && (!strcmp(cpopt, "network") ||
- !strcmp(cpopt, "n"))) {
- if (grp->gr_type != GT_NULL) {
- syslog(LOG_ERR, "network/host conflict");
- return (1);
- } else if (get_net(cpoptarg, &grp->gr_ptr.gt_net, 0)) {
- syslog(LOG_ERR, "bad net: %s", cpoptarg);
- return (1);
- }
- grp->gr_type = GT_NET;
- *has_hostp = 1;
- usedarg++;
- opt_flags |= OP_NET;
- } else if (!strcmp(cpopt, "alldirs")) {
- opt_flags |= OP_ALLDIRS;
- } else if (!strcmp(cpopt, "public")) {
- *exflagsp |= MNT_EXPUBLIC;
- } else if (!strcmp(cpopt, "webnfs")) {
- *exflagsp |= (MNT_EXPUBLIC|MNT_EXRDONLY|MNT_EXPORTANON);
- opt_flags |= OP_MAPALL;
- } else if (cpoptarg && !strcmp(cpopt, "index")) {
- ep->ex_indexfile = strdup(cpoptarg);
- } else {
- syslog(LOG_ERR, "bad opt %s", cpopt);
- return (1);
- }
- if (usedarg >= 0) {
- *endcp = savedc2;
- **endcpp = savedc;
- if (usedarg > 0) {
- *cpp = cp;
- *endcpp = endcp;
- }
- return (0);
- }
- cpopt = cpoptend;
- }
- **endcpp = savedc;
- return (0);
-}
-
-/*
- * Translate a character string to the corresponding list of network
- * addresses for a hostname.
- */
-int
-get_host(cp, grp, tgrp)
- char *cp;
- struct grouplist *grp;
- struct grouplist *tgrp;
-{
- struct grouplist *checkgrp;
- struct hostent *hp, *nhp;
- char **addrp, **naddrp;
- struct hostent t_host;
- int i;
- u_int32_t saddr;
- char *aptr[2];
-
- if (grp->gr_type != GT_NULL)
- return (1);
- if ((hp = gethostbyname(cp)) == NULL) {
- if (isdigit(*cp)) {
- saddr = inet_addr(cp);
- if (saddr == -1) {
- syslog(LOG_ERR, "inet_addr failed for %s", cp);
- return (1);
- }
- if ((hp = gethostbyaddr((caddr_t)&saddr, sizeof (saddr),
- AF_INET)) == NULL) {
- hp = &t_host;
- hp->h_name = cp;
- hp->h_addrtype = AF_INET;
- hp->h_length = sizeof (u_int32_t);
- hp->h_addr_list = aptr;
- aptr[0] = (char *)&saddr;
- aptr[1] = (char *)NULL;
- }
- } else {
- syslog(LOG_ERR, "gethostbyname failed for %s", cp);
- return (1);
- }
- }
- /*
- * Sanity check: make sure we don't already have an entry
- * for this host in the grouplist.
- */
- checkgrp = tgrp;
- while (checkgrp != NULL) {
- if (checkgrp->gr_type == GT_HOST &&
- checkgrp->gr_ptr.gt_hostent != NULL &&
- (!strcmp(checkgrp->gr_ptr.gt_hostent->h_name, hp->h_name)
- || *(u_int32_t *)checkgrp->gr_ptr.gt_hostent->h_addr ==
- *(u_int32_t *)hp->h_addr)) {
- grp->gr_type = GT_IGNORE;
- return(0);
- }
- checkgrp = checkgrp->gr_next;
- }
-
- grp->gr_type = GT_HOST;
- nhp = grp->gr_ptr.gt_hostent = (struct hostent *)
- malloc(sizeof(struct hostent));
- if (nhp == (struct hostent *)NULL)
- out_of_mem();
- memmove(nhp, hp, sizeof(struct hostent));
- i = strlen(hp->h_name)+1;
- nhp->h_name = (char *)malloc(i);
- if (nhp->h_name == (char *)NULL)
- out_of_mem();
- memmove(nhp->h_name, hp->h_name, i);
- addrp = hp->h_addr_list;
- i = 1;
- while (*addrp++)
- i++;
- naddrp = nhp->h_addr_list = (char **)malloc(i*sizeof(char *));
- if (naddrp == (char **)NULL)
- out_of_mem();
- addrp = hp->h_addr_list;
- while (*addrp) {
- *naddrp = (char *)malloc(hp->h_length);
- if (*naddrp == (char *)NULL)
- out_of_mem();
- memmove(*naddrp, *addrp, hp->h_length);
- addrp++;
- naddrp++;
- }
- *naddrp = (char *)NULL;
- if (debug)
- warnx("got host %s", hp->h_name);
- return (0);
-}
-
-/*
- * Free up an exports list component
- */
-void
-free_exp(ep)
- struct exportlist *ep;
-{
-
- if (ep->ex_defdir) {
- free_host(ep->ex_defdir->dp_hosts);
- free((caddr_t)ep->ex_defdir);
- }
- if (ep->ex_fsdir)
- free(ep->ex_fsdir);
- if (ep->ex_indexfile)
- free(ep->ex_indexfile);
- free_dir(ep->ex_dirl);
- free((caddr_t)ep);
-}
-
-/*
- * Free hosts.
- */
-void
-free_host(hp)
- struct hostlist *hp;
-{
- struct hostlist *hp2;
-
- while (hp) {
- hp2 = hp;
- hp = hp->ht_next;
- free((caddr_t)hp2);
- }
-}
-
-struct hostlist *
-get_ht()
-{
- struct hostlist *hp;
-
- hp = (struct hostlist *)malloc(sizeof (struct hostlist));
- if (hp == (struct hostlist *)NULL)
- out_of_mem();
- hp->ht_next = (struct hostlist *)NULL;
- hp->ht_flag = 0;
- return (hp);
-}
-
-/*
- * Out of memory, fatal
- */
-void
-out_of_mem()
-{
-
- syslog(LOG_ERR, "out of memory");
- exit(2);
-}
-
-/*
- * Do the mount syscall with the update flag to push the export info into
- * the kernel.
- */
-int
-do_mount(ep, grp, exflags, anoncrp, dirp, dirplen, fsb)
- struct exportlist *ep;
- struct grouplist *grp;
- int exflags;
- struct ucred *anoncrp;
- char *dirp;
- int dirplen;
- struct statfs *fsb;
-{
- char *cp = (char *)NULL;
- u_int32_t **addrp;
- int done;
- char savedc = '\0';
- struct sockaddr_in sin, imask;
- union {
- struct ufs_args ua;
- struct iso_args ia;
- struct mfs_args ma;
-#ifdef __NetBSD__
- struct msdosfs_args da;
-#endif
- struct ntfs_args na;
- } args;
- u_int32_t net;
-
- args.ua.fspec = 0;
- args.ua.export.ex_flags = exflags;
- args.ua.export.ex_anon = *anoncrp;
- args.ua.export.ex_indexfile = ep->ex_indexfile;
- memset(&sin, 0, sizeof(sin));
- memset(&imask, 0, sizeof(imask));
- sin.sin_family = AF_INET;
- sin.sin_len = sizeof(sin);
- imask.sin_family = AF_INET;
- imask.sin_len = sizeof(sin);
- if (grp->gr_type == GT_HOST)
- addrp = (u_int32_t **)grp->gr_ptr.gt_hostent->h_addr_list;
- else
- addrp = (u_int32_t **)NULL;
- done = FALSE;
- while (!done) {
- switch (grp->gr_type) {
- case GT_HOST:
- if (addrp) {
- sin.sin_addr.s_addr = **addrp;
- args.ua.export.ex_addrlen = sizeof(sin);
- } else
- args.ua.export.ex_addrlen = 0;
- args.ua.export.ex_addr = (struct sockaddr *)&sin;
- args.ua.export.ex_masklen = 0;
- break;
- case GT_NET:
- if (grp->gr_ptr.gt_net.nt_mask)
- imask.sin_addr.s_addr = grp->gr_ptr.gt_net.nt_mask;
- else {
- net = ntohl(grp->gr_ptr.gt_net.nt_net);
- if (IN_CLASSA(net))
- imask.sin_addr.s_addr = inet_addr("255.0.0.0");
- else if (IN_CLASSB(net))
- imask.sin_addr.s_addr =
- inet_addr("255.255.0.0");
- else
- imask.sin_addr.s_addr =
- inet_addr("255.255.255.0");
- grp->gr_ptr.gt_net.nt_mask = imask.sin_addr.s_addr;
- }
- sin.sin_addr.s_addr = grp->gr_ptr.gt_net.nt_net;
- args.ua.export.ex_addr = (struct sockaddr *)&sin;
- args.ua.export.ex_addrlen = sizeof (sin);
- args.ua.export.ex_mask = (struct sockaddr *)&imask;
- args.ua.export.ex_masklen = sizeof (imask);
- break;
- case GT_IGNORE:
- return(0);
- break;
- default:
- syslog(LOG_ERR, "bad grouptype");
- if (cp)
- *cp = savedc;
- return (1);
- };
-
- /*
- * XXX:
- * Maybe I should just use the fsb->f_mntonname path instead
- * of looping back up the dirp to the mount point??
- * Also, needs to know how to export all types of local
- * exportable file systems and not just "ufs".
- */
- while (mount(fsb->f_fstypename, dirp,
- fsb->f_flags | MNT_UPDATE, (caddr_t)&args) < 0) {
- if (cp)
- *cp-- = savedc;
- else
- cp = dirp + dirplen - 1;
- if (errno == EPERM) {
- syslog(LOG_ERR,
- "can't change attributes for %s", dirp);
- return (1);
- }
- if (opt_flags & OP_ALLDIRS) {
- syslog(LOG_ERR, "could not remount %s: %m",
- dirp);
- return (1);
- }
- /* back up over the last component */
- while (*cp == '/' && cp > dirp)
- cp--;
- while (*(cp - 1) != '/' && cp > dirp)
- cp--;
- if (cp == dirp) {
- if (debug)
- warnx("mnt unsucc");
- syslog(LOG_ERR, "can't export %s", dirp);
- return (1);
- }
- savedc = *cp;
- *cp = '\0';
- }
- if (addrp) {
- ++addrp;
- if (*addrp == (u_int32_t *)NULL)
- done = TRUE;
- } else
- done = TRUE;
- }
- if (cp)
- *cp = savedc;
- return (0);
-}
-
-/*
- * Translate a net address.
- */
-int
-get_net(cp, net, maskflg)
- char *cp;
- struct netmsk *net;
- int maskflg;
-{
- struct netent *np;
- long netaddr;
- struct in_addr inetaddr, inetaddr2;
- char *name;
-
- if (isdigit(*cp) && ((netaddr = inet_network(cp)) != -1)) {
- inetaddr = inet_makeaddr(netaddr, 0);
- /*
- * Due to arbitrary subnet masks, you don't know how many
- * bits to shift the address to make it into a network,
- * however you do know how to make a network address into
- * a host with host == 0 and then compare them.
- * (What a pest)
- */
- if (!maskflg) {
- setnetent(0);
- while ((np = getnetent())) {
- inetaddr2 = inet_makeaddr(np->n_net, 0);
- if (inetaddr2.s_addr == inetaddr.s_addr)
- break;
- }
- endnetent();
- }
- } else if ((np = getnetbyname(cp)) != NULL) {
- inetaddr = inet_makeaddr(np->n_net, 0);
- } else
- return (1);
-
- if (maskflg)
- net->nt_mask = inetaddr.s_addr;
- else {
- if (np)
- name = np->n_name;
- else
- name = inet_ntoa(inetaddr);
- net->nt_name = (char *)malloc(strlen(name) + 1);
- if (net->nt_name == (char *)NULL)
- out_of_mem();
- strcpy(net->nt_name, name);
- net->nt_net = inetaddr.s_addr;
- }
- return (0);
-}
-
-/*
- * Parse out the next white space separated field
- */
-void
-nextfield(cp, endcp)
- char **cp;
- char **endcp;
-{
- char *p;
-
- p = *cp;
- while (*p == ' ' || *p == '\t')
- p++;
- if (*p == '\n' || *p == '\0')
- *cp = *endcp = p;
- else {
- *cp = p++;
- while (*p != ' ' && *p != '\t' && *p != '\n' && *p != '\0')
- p++;
- *endcp = p;
- }
-}
-
-/*
- * Get an exports file line. Skip over blank lines and handle line
- * continuations.
- */
-int
-get_line()
-{
- char *p, *cp;
- int len;
- int totlen, cont_line;
-
- /*
- * Loop around ignoring blank lines and getting all continuation lines.
- */
- p = line;
- totlen = 0;
- do {
- if (fgets(p, LINESIZ - totlen, exp_file) == NULL)
- return (0);
- len = strlen(p);
- cp = p + len - 1;
- cont_line = 0;
- while (cp >= p &&
- (*cp == ' ' || *cp == '\t' || *cp == '\n' || *cp == '\\')) {
- if (*cp == '\\')
- cont_line = 1;
- cp--;
- len--;
- }
- *++cp = '\0';
- if (len > 0) {
- totlen += len;
- if (totlen >= LINESIZ) {
- syslog(LOG_ERR, "exports line too long");
- exit(2);
- }
- p = cp;
- }
- } while (totlen == 0 || cont_line);
- return (1);
-}
-
-/*
- * Parse a description of a credential.
- */
-void
-parsecred(namelist, cr)
- char *namelist;
- struct ucred *cr;
-{
- char *name;
- int cnt;
- char *names;
- struct passwd *pw;
- struct group *gr;
- int ngroups, groups[NGROUPS + 1];
-
- /*
- * Set up the unprivileged user.
- */
- cr->cr_ref = 1;
- cr->cr_uid = -2;
- cr->cr_groups[0] = -2;
- cr->cr_ngroups = 1;
- /*
- * Get the user's password table entry.
- */
- names = strsep(&namelist, " \t\n");
- name = strsep(&names, ":");
- if (isdigit(*name) || *name == '-')
- pw = getpwuid(atoi(name));
- else
- pw = getpwnam(name);
- /*
- * Credentials specified as those of a user.
- */
- if (names == NULL) {
- if (pw == NULL) {
- syslog(LOG_ERR, "unknown user: %s", name);
- return;
- }
- cr->cr_uid = pw->pw_uid;
- ngroups = NGROUPS + 1;
- if (getgrouplist(pw->pw_name, pw->pw_gid, groups, &ngroups))
- syslog(LOG_ERR, "too many groups");
- /*
- * Convert from int's to gid_t's and compress out duplicate
- */
- cr->cr_ngroups = ngroups - 1;
- cr->cr_groups[0] = groups[0];
- for (cnt = 2; cnt < ngroups; cnt++)
- cr->cr_groups[cnt - 1] = groups[cnt];
- return;
- }
- /*
- * Explicit credential specified as a colon separated list:
- * uid:gid:gid:...
- */
- if (pw != NULL)
- cr->cr_uid = pw->pw_uid;
- else if (isdigit(*name) || *name == '-')
- cr->cr_uid = atoi(name);
- else {
- syslog(LOG_ERR, "unknown user: %s", name);
- return;
- }
- cr->cr_ngroups = 0;
- while (names != NULL && *names != '\0' && cr->cr_ngroups < NGROUPS) {
- name = strsep(&names, ":");
- if (isdigit(*name) || *name == '-') {
- cr->cr_groups[cr->cr_ngroups++] = atoi(name);
- } else {
- if ((gr = getgrnam(name)) == NULL) {
- syslog(LOG_ERR, "unknown group: %s", name);
- continue;
- }
- cr->cr_groups[cr->cr_ngroups++] = gr->gr_gid;
- }
- }
- if (names != NULL && *names != '\0' && cr->cr_ngroups == NGROUPS)
- syslog(LOG_ERR, "too many groups");
-}
-
-#define STRSIZ (RPCMNT_NAMELEN+RPCMNT_PATHLEN+50)
-/*
- * Routines that maintain the remote mounttab
- */
-void
-get_mountlist()
-{
- struct mountlist *mlp, **mlpp;
- char *host, *dirp, *cp;
- char str[STRSIZ];
- FILE *mlfile;
-
- if ((mlfile = fopen(_PATH_RMOUNTLIST, "r")) == NULL) {
- if (errno == ENOENT)
- return;
- else {
- syslog(LOG_ERR, "can't open %s", _PATH_RMOUNTLIST);
- return;
- }
- }
- mlpp = &mlhead;
- while (fgets(str, STRSIZ, mlfile) != NULL) {
- cp = str;
- host = strsep(&cp, " \t\n");
- dirp = strsep(&cp, " \t\n");
- if (host == NULL || dirp == NULL)
- continue;
- mlp = (struct mountlist *)malloc(sizeof (*mlp));
- if (mlp == (struct mountlist *)NULL)
- out_of_mem();
- strncpy(mlp->ml_host, host, RPCMNT_NAMELEN);
- mlp->ml_host[RPCMNT_NAMELEN] = '\0';
- strncpy(mlp->ml_dirp, dirp, RPCMNT_PATHLEN);
- mlp->ml_dirp[RPCMNT_PATHLEN] = '\0';
- mlp->ml_next = (struct mountlist *)NULL;
- *mlpp = mlp;
- mlpp = &mlp->ml_next;
- }
- fclose(mlfile);
-}
-
-void
-del_mlist(hostp, dirp)
- char *hostp, *dirp;
-{
- struct mountlist *mlp, **mlpp;
- struct mountlist *mlp2;
- FILE *mlfile;
- int fnd = 0;
-
- mlpp = &mlhead;
- mlp = mlhead;
- while (mlp) {
- if (!strcmp(mlp->ml_host, hostp) &&
- (!dirp || !strcmp(mlp->ml_dirp, dirp))) {
- fnd = 1;
- mlp2 = mlp;
- *mlpp = mlp = mlp->ml_next;
- free((caddr_t)mlp2);
- } else {
- mlpp = &mlp->ml_next;
- mlp = mlp->ml_next;
- }
- }
- if (fnd) {
- if ((mlfile = fopen(_PATH_RMOUNTLIST, "w")) == NULL) {
- syslog(LOG_ERR,"can't update %s", _PATH_RMOUNTLIST);
- return;
- }
- mlp = mlhead;
- while (mlp) {
- fprintf(mlfile, "%s %s\n", mlp->ml_host, mlp->ml_dirp);
- mlp = mlp->ml_next;
- }
- fclose(mlfile);
- }
-}
-
-void
-add_mlist(hostp, dirp)
- char *hostp, *dirp;
-{
- struct mountlist *mlp, **mlpp;
- FILE *mlfile;
-
- mlpp = &mlhead;
- mlp = mlhead;
- while (mlp) {
- if (!strcmp(mlp->ml_host, hostp) && !strcmp(mlp->ml_dirp, dirp))
- return;
- mlpp = &mlp->ml_next;
- mlp = mlp->ml_next;
- }
- mlp = (struct mountlist *)malloc(sizeof (*mlp));
- if (mlp == (struct mountlist *)NULL)
- out_of_mem();
- strncpy(mlp->ml_host, hostp, RPCMNT_NAMELEN);
- mlp->ml_host[RPCMNT_NAMELEN] = '\0';
- strncpy(mlp->ml_dirp, dirp, RPCMNT_PATHLEN);
- mlp->ml_dirp[RPCMNT_PATHLEN] = '\0';
- mlp->ml_next = (struct mountlist *)NULL;
- *mlpp = mlp;
- if ((mlfile = fopen(_PATH_RMOUNTLIST, "a")) == NULL) {
- syslog(LOG_ERR, "can't update %s", _PATH_RMOUNTLIST);
- return;
- }
- fprintf(mlfile, "%s %s\n", mlp->ml_host, mlp->ml_dirp);
- fclose(mlfile);
-}
-
-/*
- * Free up a group list.
- */
-void
-free_grp(grp)
- struct grouplist *grp;
-{
- char **addrp;
-
- if (grp->gr_type == GT_HOST) {
- if (grp->gr_ptr.gt_hostent->h_name) {
- addrp = grp->gr_ptr.gt_hostent->h_addr_list;
- while (addrp && *addrp)
- free(*addrp++);
- free((caddr_t)grp->gr_ptr.gt_hostent->h_addr_list);
- free(grp->gr_ptr.gt_hostent->h_name);
- }
- free((caddr_t)grp->gr_ptr.gt_hostent);
- } else if (grp->gr_type == GT_NET) {
- if (grp->gr_ptr.gt_net.nt_name)
- free(grp->gr_ptr.gt_net.nt_name);
- }
- free((caddr_t)grp);
-}
-
-#ifdef DEBUG
-void
-SYSLOG(int pri, const char *fmt, ...)
-{
- va_list ap;
-
- va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
- va_end(ap);
-}
-#endif /* DEBUG */
-
-/*
- * Check options for consistency.
- */
-int
-check_options(dp)
- struct dirlist *dp;
-{
-
- if (dp == (struct dirlist *)NULL)
- return (1);
- if ((opt_flags & (OP_MAPROOT | OP_MAPALL)) == (OP_MAPROOT | OP_MAPALL) ||
- (opt_flags & (OP_MAPROOT | OP_KERB)) == (OP_MAPROOT | OP_KERB) ||
- (opt_flags & (OP_MAPALL | OP_KERB)) == (OP_MAPALL | OP_KERB)) {
- syslog(LOG_ERR, "-mapall, -maproot and -kerb mutually exclusive");
- return (1);
- }
- if ((opt_flags & OP_MASK) && (opt_flags & OP_NET) == 0) {
- syslog(LOG_ERR, "-mask requires -net");
- return (1);
- }
- if ((opt_flags & OP_ALLDIRS) && dp->dp_left) {
- syslog(LOG_ERR, "-alldirs has multiple directories");
- return (1);
- }
- return (0);
-}
-
-/*
- * Check an absolute directory path for any symbolic links. Return true
- * if no symbolic links are found.
- */
-int
-check_dirpath(dirp)
- char *dirp;
-{
- char *cp;
- int ret = 1;
- struct stat sb;
-
- cp = dirp + 1;
- while (*cp && ret) {
- if (*cp == '/') {
- *cp = '\0';
- if (lstat(dirp, &sb) < 0 || !S_ISDIR(sb.st_mode))
- ret = 0;
- *cp = '/';
- }
- cp++;
- }
- if (lstat(dirp, &sb) < 0 || !S_ISDIR(sb.st_mode))
- ret = 0;
- return (ret);
-}
-
-/*
- * Just translate an ascii string to an integer.
- */
-int
-get_num(cp)
- register char *cp;
-{
- register int res = 0;
-
- while (*cp) {
- if (*cp < '0' || *cp > '9')
- return (-1);
- res = res * 10 + (*cp++ - '0');
- }
- return (res);
-}
diff --git a/usr.sbin/mountd/netgroup.5 b/usr.sbin/mountd/netgroup.5
deleted file mode 100644
index fb1a8bcd2a57..000000000000
--- a/usr.sbin/mountd/netgroup.5
+++ /dev/null
@@ -1,194 +0,0 @@
-.\" 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. 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, Berkeley and its contributors.
-.\" 4. 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.
-.\"
-.\" @(#)netgroup.5 8.2 (Berkeley) 12/11/93
-.\" $FreeBSD$
-.\"
-.Dd December 11, 1993
-.Dt NETGROUP 5
-.Os
-.Sh NAME
-.Nm netgroup
-.Nd defines network groups
-.Sh SYNOPSIS
-.Nm netgroup
-.Sh DESCRIPTION
-The
-.Nm
-file
-specifies ``netgroups'', which are sets of
-.Sy (host, user, domain)
-tuples that are to be given similar network access.
-.Pp
-Each line in the file
-consists of a netgroup name followed by a list of the members of the
-netgroup.
-Each member can be either the name of another netgroup or a specification
-of a tuple as follows:
-.Bd -literal -offset indent
-(host, user, domain)
-.Ed
-.Pp
-where the
-.Sy host ,
-.Sy user ,
-and
-.Sy domain
-are character string names for the corresponding component.
-Any of the comma separated fields may be empty to specify a ``wildcard'' value
-or may consist of the string ``-'' to specify ``no valid value''.
-The members of the list may be separated by whitespace and/or commas;
-the ``\e'' character may be used at the end of a line to specify
-line continuation.
-Lines are limited to 1024 characters.
-The functions specified in
-.Xr getnetgrent 3
-should normally be used to access the
-.Nm
-database.
-.Pp
-Lines that begin with a # are treated as comments.
-.Sh NIS/YP INTERACTION
-On most other platforms,
-.Nm Ns s
-are only used in conjunction with
-.Tn NIS
-and local
-.Pa /etc/netgroup
-files are ignored.
-With
-.Fx ,
-.Nm Ns s
-can be used with either
-.Tn NIS
-or local files, but there are certain
-caveats to consider.
-The existing
-.Nm
-system is extremely inefficient where
-.Fn innetgr 3
-lookups are concerned since
-.Nm
-memberships are computed on the fly.
-By contrast, the
-.Tn NIS
-.Nm
-database consists of three separate maps (netgroup, netgroup.byuser
-and netgroup.byhost) that are keyed to allow
-.Fn innetgr 3
-lookups to be done quickly.
-The
-.Fx
-.Nm
-system can interact with the
-.Tn NIS
-.Nm
-maps in the following ways:
-.Bl -bullet -offset indent
-.It
-If the
-.Pa /etc/netgroup
-file does not exist, or it exists and is empty, or
-it exists and contains only a
-.Sq + ,
-and
-.Tn NIS
-is running,
-.Nm
-lookups will be done exclusively through
-.Tn NIS ,
-with
-.Fn innetgr 3
-taking advantage of the netgroup.byuser and
-netgroup.byhost maps to speed up searches.
-(This
-is more or less compatible with the behavior of SunOS and
-similar platforms.)
-.It
-If the
-.Pa /etc/netgroup
-exists and contains only local
-.Nm
-information (with no
-.Tn NIS
-.Sq +
-token), then only the local
-.Nm
-information will be processed (and
-.Tn NIS
-will be ignored).
-.It
-If
-.Pa /etc/netgroup
-exists and contains both local netgroup data
-.Pa and
-the
-.Tn NIS
-.Sq +
-token, the local data and the
-.Tn NIS
-netgroup
-map will be processed as a single combined
-.Nm
-database.
-While this configuration is the most flexible, it
-is also the least efficient: in particular,
-.Fn innetgr 3
-lookups will be especially slow if the
-database is large.
-.El
-.Sh FILES
-.Bl -tag -width /etc/netgroup -compact
-.It Pa /etc/netgroup
-the netgroup database
-.El
-.Sh SEE ALSO
-.Xr getnetgrent 3 ,
-.Xr exports 5
-.Sh COMPATIBILITY
-The file format is compatible with that of various vendors, however it
-appears that not all vendors use an identical format.
-.Sh BUGS
-The interpretation of access restrictions based on the member tuples of a
-netgroup is left up to the various network applications.
-Also, it is not obvious how the domain specification
-applies to the
-.Bx
-environment.
-.Pp
-The
-.Nm
-database should be stored in the form of a
-hashed
-.Xr db 3
-database just like the
-.Xr passwd 5
-database to speed up reverse lookups.
diff --git a/usr.sbin/mountd/pathnames.h b/usr.sbin/mountd/pathnames.h
deleted file mode 100644
index aa1c55523103..000000000000
--- a/usr.sbin/mountd/pathnames.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 1989, 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. 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, Berkeley and its contributors.
- * 4. 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.
- *
- * @(#)pathnames.h 8.1 (Berkeley) 6/5/93
- */
-#include <paths.h>
-
-#define _PATH_EXPORTS "/etc/exports"
-#define _PATH_RMOUNTLIST "/var/db/mountdtab"
-#define _PATH_MOUNTDPID "/var/run/mountd.pid"
diff --git a/usr.sbin/nfsd/Makefile b/usr.sbin/nfsd/Makefile
deleted file mode 100644
index a18aad017aa8..000000000000
--- a/usr.sbin/nfsd/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-# @(#)Makefile 8.1 (Berkeley) 6/5/93
-# $FreeBSD$
-
-PROG= nfsd
-CFLAGS+=-DNFS
-MAN8= nfsd.8
-DPADD+= ${LIBUTIL}
-LDADD+= -lutil
-
-.if exists(${DESTDIR}/usr/lib/libkrb.a) && defined(MAKE_KERBEROS4)
-CFLAGS+=-DKERBEROS
-DPADD+= ${LIBKRB} ${LIBCRYPTO}
-LDADD+= -lkrb -lcrypto
-DISTRIBUTION= krb4
-.endif
-
-.include <bsd.prog.mk>
diff --git a/usr.sbin/nfsd/nfsd.8 b/usr.sbin/nfsd/nfsd.8
deleted file mode 100644
index f5d0efbff063..000000000000
--- a/usr.sbin/nfsd/nfsd.8
+++ /dev/null
@@ -1,165 +0,0 @@
-.\" Copyright (c) 1989, 1991, 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. 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, Berkeley and its contributors.
-.\" 4. 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.
-.\"
-.\" @(#)nfsd.8 8.4 (Berkeley) 3/29/95
-.\" $FreeBSD$
-.\"
-.Dd March 29, 1995
-.Dt NFSD 8
-.Os
-.Sh NAME
-.Nm nfsd
-.Nd remote
-.Tn NFS
-server
-.Sh SYNOPSIS
-.Nm nfsd
-.Op Fl arut
-.Op Fl n Ar num_servers
-.Op Fl h Ar bindip
-.Sh DESCRIPTION
-.Nm Nfsd
-runs on a server machine to service
-.Tn NFS
-requests from client machines.
-At least one
-.Nm nfsd
-must be running for a machine to operate as a server.
-.Pp
-Unless otherwise specified, four servers for
-.Tn UDP
-transport are started.
-.Pp
-The following options are available:
-.Bl -tag -width Ds
-.It Fl r
-Register the
-.Tn NFS
-service with
-.Xr portmap 8
-without creating any servers.
-This option can be used along with the
-.Fl u
-or
-.Fl t
-options to re-register NFS if the portmap server is restarted.
-.It Fl n
-Specifies how many servers to create.
-.It Fl h Ar bindip
-Specifies which IP address or hostname to bind to on the local host.
-This option is recommended when a host has multiple interfaces.
-Multiple
-.Fl h
-options may be specified.
-.It Fl a
-Specifies that nfsd should bind to the wildcard IP address.
-This is the default if no
-.Fl h
-options are given. It may also be specified in addition to any
-.Fl h
-options given. Note that NFS/UDP does not operate properly when
-bound to the wildcard IP address whether you use -a or do not use -h.
-.It Fl t
-Serve
-.Tn TCP NFS
-clients.
-.It Fl u
-Serve
-.Tn UDP NFS
-clients.
-.El
-.Pp
-For example,
-.Dq Li "nfsd -u -t -n 6"
-serves
-.Tn UDP
-and
-.Tn TCP
-transports using six daemons.
-.Pp
-A server should run enough daemons to handle
-the maximum level of concurrency from its clients,
-typically four to six.
-.Pp
-.Nm Nfsd
-listens for service requests at the port indicated in the
-.Tn NFS
-server specification; see
-.%T "Network File System Protocol Specification" ,
-RFC1094 and
-.%T "NFS: Network File System Version 3 Protocol Specification" .
-.Pp
-If
-.Nm nfsd
-detects that
-.Tn NFS
-is not loaded in the running kernel, it will attempt
-to load a loadable kernel module containing
-.Tn NFS
-support using
-.Xr kldload 8
-by way of
-.Xr vfsload 3 .
-If this fails, or no
-.Tn NFS
-KLD is available,
-.Nm nfsd
-will exit with an error.
-.Pp
-If
-.Nm nfsd
-is to be run on a host with multiple interfaces or interface aliases, use
-of the
-.Fl h
-option is recommended. If you do not use the option NFS may not respond to
-UDP packets from the same IP address they were sent to. Use of this option
-is also recommended when securing NFS exports on a firewalling machine such
-that the NFS sockets can only be accessed by the inside interface.
-.Nm Ipfw
-would then be used to block nfs-related packets that come in on the outside
-interface.
-.Pp
-The
-.Nm nfsd
-utility exits 0 on success, and >0 if an error occurs.
-.Sh SEE ALSO
-.Xr nfsstat 1 ,
-.Xr nfssvc 2 ,
-.Xr kldload 8 ,
-.Xr mountd 8 ,
-.Xr nfsiod 8 ,
-.Xr portmap 8 ,
-.Xr ipfw 8
-.Sh HISTORY
-The
-.Nm nfsd
-utility first appeared in
-.Bx 4.4 .
diff --git a/usr.sbin/nfsd/nfsd.c b/usr.sbin/nfsd/nfsd.c
deleted file mode 100644
index 9ff9d987cffe..000000000000
--- a/usr.sbin/nfsd/nfsd.c
+++ /dev/null
@@ -1,713 +0,0 @@
-/*
- * Copyright (c) 1989, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Rick Macklem at The University of Guelph.
- *
- * 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 the University of
- * California, Berkeley and its contributors.
- * 4. 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 lint
-static const char copyright[] =
-"@(#) Copyright (c) 1989, 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif not lint
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)nfsd.c 8.9 (Berkeley) 3/29/95";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif not lint
-
-#include <sys/param.h>
-#include <sys/syslog.h>
-#include <sys/wait.h>
-#include <sys/mount.h>
-
-#include <rpc/rpc.h>
-#include <rpc/pmap_clnt.h>
-
-#include <netdb.h>
-#include <arpa/inet.h>
-#ifdef ISO
-#include <netiso/iso.h>
-#endif
-#include <nfs/rpcv2.h>
-#include <nfs/nfsproto.h>
-#include <nfs/nfs.h>
-
-#ifdef NFSKERB
-#include <kerberosIV/des.h>
-#include <kerberosIV/krb.h>
-#endif
-
-#include <err.h>
-#include <errno.h>
-#include <libutil.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <strings.h>
-#include <unistd.h>
-
-/* Global defs */
-#ifdef DEBUG
-#define syslog(e, s) fprintf(stderr,(s))
-int debug = 1;
-#else
-int debug = 0;
-#endif
-
-struct nfsd_srvargs nsd;
-#ifdef OLD_SETPROCTITLE
-char **Argv = NULL; /* pointer to argument vector */
-char *LastArg = NULL; /* end of argv */
-#endif
-
-#ifdef NFSKERB
-char lnam[ANAME_SZ];
-KTEXT_ST kt;
-AUTH_DAT kauth;
-char inst[INST_SZ];
-struct nfsrpc_fullblock kin, kout;
-struct nfsrpc_fullverf kverf;
-NFSKERBKEY_T kivec;
-struct timeval ktv;
-NFSKERBKEYSCHED_T kerb_keysched;
-#endif
-
-void nonfs __P((int));
-void reapchild __P((int));
-void setbindhost __P((struct sockaddr_in *ia, const char *bindhost));
-#ifdef OLD_SETPROCTITLE
-#ifdef __FreeBSD__
-void setproctitle __P((char *));
-#endif
-#endif
-void usage __P((void));
-
-/*
- * Nfs server daemon mostly just a user context for nfssvc()
- *
- * 1 - do file descriptor and signal cleanup
- * 2 - fork the nfsd(s)
- * 3 - create server socket(s)
- * 4 - register socket with portmap
- *
- * For connectionless protocols, just pass the socket into the kernel via.
- * nfssvc().
- * For connection based sockets, loop doing accepts. When you get a new
- * socket from accept, pass the msgsock into the kernel via. nfssvc().
- * The arguments are:
- * -c - support iso cltp clients
- * -r - reregister with portmapper
- * -t - support tcp nfs clients
- * -u - support udp nfs clients
- * followed by "n" which is the number of nfsds' to fork off
- */
-int
-main(argc, argv, envp)
- int argc;
- char *argv[], *envp[];
-{
- struct nfsd_args nfsdargs;
- struct sockaddr_in inetaddr, inetpeer;
-#ifdef ISO
- struct sockaddr_iso isoaddr, isopeer;
- char *cp;
-#endif
- fd_set ready, sockbits;
- int ch, cltpflag, connect_type_cnt, i, len, maxsock, msgsock;
- int nfsdcnt, nfssvc_flag, on, reregister, sock, tcpflag, tcpsock;
- int tp4cnt, tp4flag, tpipcnt, tpipflag, udpflag;
- int bindhostc = 0, bindanyflag;
- char **bindhost = NULL;
-#ifdef notyet
- int tp4sock, tpipsock;
-#endif
-#ifdef NFSKERB
- struct group *grp;
- struct passwd *pwd;
- struct ucred *cr;
- struct timeval ktv;
- char **cpp;
-#endif
-#ifdef __FreeBSD__
- struct vfsconf vfc;
- int error;
-
- error = getvfsbyname("nfs", &vfc);
- if (error && vfsisloadable("nfs")) {
- if (vfsload("nfs"))
- err(1, "vfsload(nfs)");
- endvfsent(); /* flush cache */
- error = getvfsbyname("nfs", &vfc);
- }
- if (error)
- errx(1, "NFS is not available in the running kernel");
-#endif
-
-#ifdef OLD_SETPROCTITLE
- /* Save start and extent of argv for setproctitle. */
- Argv = argv;
- if (envp == 0 || *envp == 0)
- envp = argv;
- while (*envp)
- envp++;
- LastArg = envp[-1] + strlen(envp[-1]);
-#endif
-
-#define MAXNFSDCNT 20
-#define DEFNFSDCNT 4
- nfsdcnt = DEFNFSDCNT;
- cltpflag = reregister = tcpflag = tp4cnt = tp4flag = tpipcnt = 0;
- bindanyflag = tpipflag = udpflag = 0;
-#ifdef ISO
-#define GETOPT "ach:n:rtu"
-#define USAGE "[-acrtu] [-n num_servers] [-h bindip]"
-#else
-#define GETOPT "ah:n:rtu"
-#define USAGE "[-artu] [-n num_servers] [-h bindip]"
-#endif
- while ((ch = getopt(argc, argv, GETOPT)) != -1)
- switch (ch) {
- case 'a':
- bindanyflag = 1;
- break;
- case 'n':
- nfsdcnt = atoi(optarg);
- if (nfsdcnt < 1 || nfsdcnt > MAXNFSDCNT) {
- warnx("nfsd count %d; reset to %d", nfsdcnt,
- DEFNFSDCNT);
- nfsdcnt = DEFNFSDCNT;
- }
- break;
- case 'h':
- bindhostc++;
- bindhost = realloc(bindhost,sizeof(char *)*bindhostc);
- if (bindhost == NULL)
- errx(1, "Out of memory");
- bindhost[bindhostc-1] = strdup(optarg);
- if (bindhost[bindhostc-1] == NULL)
- errx(1, "Out of memory");
- break;
- case 'r':
- reregister = 1;
- break;
- case 't':
- tcpflag = 1;
- break;
- case 'u':
- udpflag = 1;
- break;
-#ifdef ISO
- case 'c':
- cltpflag = 1;
- break;
-#ifdef notyet
- case 'i':
- tp4cnt = 1;
- break;
- case 'p':
- tpipcnt = 1;
- break;
-#endif /* notyet */
-#endif /* ISO */
- default:
- case '?':
- usage();
- };
- if (!tcpflag && !udpflag)
- udpflag = 1;
- argv += optind;
- argc -= optind;
-
- /*
- * XXX
- * Backward compatibility, trailing number is the count of daemons.
- */
- if (argc > 1)
- usage();
- if (argc == 1) {
- nfsdcnt = atoi(argv[0]);
- if (nfsdcnt < 1 || nfsdcnt > MAXNFSDCNT) {
- warnx("nfsd count %d; reset to %d", nfsdcnt,
- DEFNFSDCNT);
- nfsdcnt = DEFNFSDCNT;
- }
- }
-
- if (bindhostc == 0 || bindanyflag) {
- bindhostc++;
- bindhost = realloc(bindhost,sizeof(char *)*bindhostc);
- if (bindhost == NULL)
- errx(1, "Out of memory");
- bindhost[bindhostc-1] = strdup("*");
- if (bindhost[bindhostc-1] == NULL)
- errx(1, "Out of memory");
- }
-
- if (debug == 0) {
- daemon(0, 0);
- (void)signal(SIGHUP, SIG_IGN);
- (void)signal(SIGINT, SIG_IGN);
- (void)signal(SIGQUIT, SIG_IGN);
- (void)signal(SIGSYS, nonfs);
- (void)signal(SIGTERM, SIG_IGN);
- }
- (void)signal(SIGCHLD, reapchild);
-
- if (reregister) {
- if (udpflag &&
- (!pmap_set(RPCPROG_NFS, 2, IPPROTO_UDP, NFS_PORT) ||
- !pmap_set(RPCPROG_NFS, 3, IPPROTO_UDP, NFS_PORT)))
- err(1, "can't register with portmap for UDP");
- if (tcpflag &&
- (!pmap_set(RPCPROG_NFS, 2, IPPROTO_TCP, NFS_PORT) ||
- !pmap_set(RPCPROG_NFS, 3, IPPROTO_TCP, NFS_PORT)))
- err(1, "can't register with portmap for TCP");
- exit(0);
- }
- openlog("nfsd:", LOG_PID, LOG_DAEMON);
-
- for (i = 0; i < nfsdcnt; i++) {
- switch (fork()) {
- case -1:
- syslog(LOG_ERR, "fork: %m");
- exit (1);
- case 0:
- break;
- default:
- continue;
- }
-
- setproctitle("server");
- nfssvc_flag = NFSSVC_NFSD;
- nsd.nsd_nfsd = NULL;
-#ifdef NFSKERB
- if (sizeof (struct nfsrpc_fullverf) != RPCX_FULLVERF ||
- sizeof (struct nfsrpc_fullblock) != RPCX_FULLBLOCK)
- syslog(LOG_ERR, "Yikes NFSKERB structs not packed!");
- nsd.nsd_authstr = (u_char *)&kt;
- nsd.nsd_authlen = sizeof (kt);
- nsd.nsd_verfstr = (u_char *)&kverf;
- nsd.nsd_verflen = sizeof (kverf);
-#endif
- while (nfssvc(nfssvc_flag, &nsd) < 0) {
- if (errno != ENEEDAUTH) {
- syslog(LOG_ERR, "nfssvc: %m");
- exit(1);
- }
- nfssvc_flag = NFSSVC_NFSD | NFSSVC_AUTHINFAIL;
-#ifdef NFSKERB
- /*
- * Get the Kerberos ticket out of the authenticator
- * verify it and convert the principal name to a user
- * name. The user name is then converted to a set of
- * user credentials via the password and group file.
- * Finally, decrypt the timestamp and validate it.
- * For more info see the IETF Draft "Authentication
- * in ONC RPC".
- */
- kt.length = ntohl(kt.length);
- if (gettimeofday(&ktv, (struct timezone *)0) == 0 &&
- kt.length > 0 && kt.length <=
- (RPCAUTH_MAXSIZ - 3 * NFSX_UNSIGNED)) {
- kin.w1 = NFS_KERBW1(kt);
- kt.mbz = 0;
- (void)strcpy(inst, "*");
- if (krb_rd_req(&kt, NFS_KERBSRV,
- inst, nsd.nsd_haddr, &kauth, "") == RD_AP_OK &&
- krb_kntoln(&kauth, lnam) == KSUCCESS &&
- (pwd = getpwnam(lnam)) != NULL) {
- cr = &nsd.nsd_cr;
- cr->cr_uid = pwd->pw_uid;
- cr->cr_groups[0] = pwd->pw_gid;
- cr->cr_ngroups = 1;
- setgrent();
- while ((grp = getgrent()) != NULL) {
- if (grp->gr_gid == cr->cr_groups[0])
- continue;
- for (cpp = grp->gr_mem;
- *cpp != NULL; ++cpp)
- if (!strcmp(*cpp, lnam))
- break;
- if (*cpp == NULL)
- continue;
- cr->cr_groups[cr->cr_ngroups++]
- = grp->gr_gid;
- if (cr->cr_ngroups == NGROUPS)
- break;
- }
- endgrent();
-
- /*
- * Get the timestamp verifier out of the
- * authenticator and verifier strings.
- */
- kin.t1 = kverf.t1;
- kin.t2 = kverf.t2;
- kin.w2 = kverf.w2;
- bzero((caddr_t)kivec, sizeof (kivec));
- bcopy((caddr_t)kauth.session,
- (caddr_t)nsd.nsd_key,sizeof(kauth.session));
-
- /*
- * Decrypt the timestamp verifier in CBC mode.
- */
- XXX
-
- /*
- * Validate the timestamp verifier, to
- * check that the session key is ok.
- */
- nsd.nsd_timestamp.tv_sec = ntohl(kout.t1);
- nsd.nsd_timestamp.tv_usec = ntohl(kout.t2);
- nsd.nsd_ttl = ntohl(kout.w1);
- if ((nsd.nsd_ttl - 1) == ntohl(kout.w2))
- nfssvc_flag = NFSSVC_NFSD | NFSSVC_AUTHIN;
- }
-#endif /* NFSKERB */
- }
- exit(0);
- }
-
- /* If we are serving udp, set up the socket. */
- for (i = 0; udpflag && i < bindhostc; i++) {
- if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
- syslog(LOG_ERR, "can't create udp socket");
- exit(1);
- }
- setbindhost(&inetaddr, bindhost[i]);
- if (bind(sock,
- (struct sockaddr *)&inetaddr, sizeof(inetaddr)) < 0) {
- syslog(LOG_ERR, "can't bind udp addr %s: %m", bindhost[i]);
- exit(1);
- }
- if (!pmap_set(RPCPROG_NFS, 2, IPPROTO_UDP, NFS_PORT) ||
- !pmap_set(RPCPROG_NFS, 3, IPPROTO_UDP, NFS_PORT)) {
- syslog(LOG_ERR, "can't register with udp portmap");
- exit(1);
- }
- nfsdargs.sock = sock;
- nfsdargs.name = NULL;
- nfsdargs.namelen = 0;
- if (nfssvc(NFSSVC_ADDSOCK, &nfsdargs) < 0) {
- syslog(LOG_ERR, "can't Add UDP socket");
- exit(1);
- }
- (void)close(sock);
- }
-
-#ifdef ISO
- /* If we are serving cltp, set up the socket. */
- if (cltpflag) {
- if ((sock = socket(AF_ISO, SOCK_DGRAM, 0)) < 0) {
- syslog(LOG_ERR, "can't create cltp socket");
- exit(1);
- }
- memset(&isoaddr, 0, sizeof(isoaddr));
- isoaddr.siso_family = AF_ISO;
- isoaddr.siso_tlen = 2;
- cp = TSEL(&isoaddr);
- *cp++ = (NFS_PORT >> 8);
- *cp = (NFS_PORT & 0xff);
- isoaddr.siso_len = sizeof(isoaddr);
- if (bind(sock,
- (struct sockaddr *)&isoaddr, sizeof(isoaddr)) < 0) {
- syslog(LOG_ERR, "can't bind cltp addr");
- exit(1);
- }
-#ifdef notyet
- /*
- * XXX
- * Someday this should probably use "rpcbind", the son of
- * portmap.
- */
- if (!pmap_set(RPCPROG_NFS, NFS_VER2, IPPROTO_UDP, NFS_PORT)) {
- syslog(LOG_ERR, "can't register with udp portmap");
- exit(1);
- }
-#endif /* notyet */
- nfsdargs.sock = sock;
- nfsdargs.name = NULL;
- nfsdargs.namelen = 0;
- if (nfssvc(NFSSVC_ADDSOCK, &nfsdargs) < 0) {
- syslog(LOG_ERR, "can't add UDP socket");
- exit(1);
- }
- close(sock);
- }
-#endif /* ISO */
-
- /* Now set up the master server socket waiting for tcp connections. */
- on = 1;
- FD_ZERO(&sockbits);
- connect_type_cnt = 0;
- for (i = 0; tcpflag && i < bindhostc; i++) {
- if ((tcpsock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
- syslog(LOG_ERR, "can't create tcp socket");
- exit(1);
- }
- if (setsockopt(tcpsock,
- SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)) < 0)
- syslog(LOG_ERR, "setsockopt SO_REUSEADDR: %m");
- setbindhost(&inetaddr, bindhost[i]);
- if (bind(tcpsock,
- (struct sockaddr *)&inetaddr, sizeof (inetaddr)) < 0) {
- syslog(LOG_ERR, "can't bind tcp addr %s: %m", bindhost[i]);
- exit(1);
- }
- if (listen(tcpsock, 5) < 0) {
- syslog(LOG_ERR, "listen failed");
- exit(1);
- }
- if (!pmap_set(RPCPROG_NFS, 2, IPPROTO_TCP, NFS_PORT) ||
- !pmap_set(RPCPROG_NFS, 3, IPPROTO_TCP, NFS_PORT)) {
- syslog(LOG_ERR, "can't register tcp with portmap");
- exit(1);
- }
- FD_SET(tcpsock, &sockbits);
- maxsock = tcpsock;
- connect_type_cnt++;
- }
-
-#ifdef notyet
- /* Now set up the master server socket waiting for tp4 connections. */
- if (tp4flag) {
- if ((tp4sock = socket(AF_ISO, SOCK_SEQPACKET, 0)) < 0) {
- syslog(LOG_ERR, "can't create tp4 socket");
- exit(1);
- }
- if (setsockopt(tp4sock,
- SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)) < 0)
- syslog(LOG_ERR, "setsockopt SO_REUSEADDR: %m");
- memset(&isoaddr, 0, sizeof(isoaddr));
- isoaddr.siso_family = AF_ISO;
- isoaddr.siso_tlen = 2;
- cp = TSEL(&isoaddr);
- *cp++ = (NFS_PORT >> 8);
- *cp = (NFS_PORT & 0xff);
- isoaddr.siso_len = sizeof(isoaddr);
- if (bind(tp4sock,
- (struct sockaddr *)&isoaddr, sizeof (isoaddr)) < 0) {
- syslog(LOG_ERR, "can't bind tp4 addr");
- exit(1);
- }
- if (listen(tp4sock, 5) < 0) {
- syslog(LOG_ERR, "listen failed");
- exit(1);
- }
- /*
- * XXX
- * Someday this should probably use "rpcbind", the son of
- * portmap.
- */
- if (!pmap_set(RPCPROG_NFS, NFS_VER2, IPPROTO_TCP, NFS_PORT)) {
- syslog(LOG_ERR, "can't register tcp with portmap");
- exit(1);
- }
- FD_SET(tp4sock, &sockbits);
- maxsock = tp4sock;
- connect_type_cnt++;
- }
-
- /* Now set up the master server socket waiting for tpip connections. */
- for (i = 0; tpipflag && i < bindhostc; i++) {
- if ((tpipsock = socket(AF_INET, SOCK_SEQPACKET, 0)) < 0) {
- syslog(LOG_ERR, "can't create tpip socket");
- exit(1);
- }
- if (setsockopt(tpipsock,
- SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)) < 0)
- syslog(LOG_ERR, "setsockopt SO_REUSEADDR: %m");
- setbindhost(&inetaddr, bindhost[i]);
- if (bind(tpipsock,
- (struct sockaddr *)&inetaddr, sizeof (inetaddr)) < 0) {
- syslog(LOG_ERR, "can't bind tcp addr %s: %m", bindhost[i]);
- exit(1);
- }
- if (listen(tpipsock, 5) < 0) {
- syslog(LOG_ERR, "listen failed");
- exit(1);
- }
- /*
- * XXX
- * Someday this should probably use "rpcbind", the son of
- * portmap.
- */
- if (!pmap_set(RPCPROG_NFS, NFS_VER2, IPPROTO_TCP, NFS_PORT)) {
- syslog(LOG_ERR, "can't register tcp with portmap");
- exit(1);
- }
- FD_SET(tpipsock, &sockbits);
- maxsock = tpipsock;
- connect_type_cnt++;
- }
-#endif /* notyet */
-
- if (connect_type_cnt == 0)
- exit(0);
-
- setproctitle("master");
-
- /*
- * Loop forever accepting connections and passing the sockets
- * into the kernel for the mounts.
- */
- for (;;) {
- ready = sockbits;
- if (connect_type_cnt > 1) {
- if (select(maxsock + 1,
- &ready, NULL, NULL, NULL) < 1) {
- syslog(LOG_ERR, "select failed: %m");
- exit(1);
- }
- }
- if (tcpflag && FD_ISSET(tcpsock, &ready)) {
- len = sizeof(inetpeer);
- if ((msgsock = accept(tcpsock,
- (struct sockaddr *)&inetpeer, &len)) < 0) {
- syslog(LOG_ERR, "accept failed: %m");
- exit(1);
- }
- memset(inetpeer.sin_zero, 0, sizeof(inetpeer.sin_zero));
- if (setsockopt(msgsock, SOL_SOCKET,
- SO_KEEPALIVE, (char *)&on, sizeof(on)) < 0)
- syslog(LOG_ERR,
- "setsockopt SO_KEEPALIVE: %m");
- nfsdargs.sock = msgsock;
- nfsdargs.name = (caddr_t)&inetpeer;
- nfsdargs.namelen = sizeof(inetpeer);
- nfssvc(NFSSVC_ADDSOCK, &nfsdargs);
- (void)close(msgsock);
- }
-#ifdef notyet
- if (tp4flag && FD_ISSET(tp4sock, &ready)) {
- len = sizeof(isopeer);
- if ((msgsock = accept(tp4sock,
- (struct sockaddr *)&isopeer, &len)) < 0) {
- syslog(LOG_ERR, "accept failed: %m");
- exit(1);
- }
- if (setsockopt(msgsock, SOL_SOCKET,
- SO_KEEPALIVE, (char *)&on, sizeof(on)) < 0)
- syslog(LOG_ERR,
- "setsockopt SO_KEEPALIVE: %m");
- nfsdargs.sock = msgsock;
- nfsdargs.name = (caddr_t)&isopeer;
- nfsdargs.namelen = len;
- nfssvc(NFSSVC_ADDSOCK, &nfsdargs);
- (void)close(msgsock);
- }
- if (tpipflag && FD_ISSET(tpipsock, &ready)) {
- len = sizeof(inetpeer);
- if ((msgsock = accept(tpipsock,
- (struct sockaddr *)&inetpeer, &len)) < 0) {
- syslog(LOG_ERR, "accept failed: %m");
- exit(1);
- }
- if (setsockopt(msgsock, SOL_SOCKET,
- SO_KEEPALIVE, (char *)&on, sizeof(on)) < 0)
- syslog(LOG_ERR, "setsockopt SO_KEEPALIVE: %m");
- nfsdargs.sock = msgsock;
- nfsdargs.name = (caddr_t)&inetpeer;
- nfsdargs.namelen = len;
- nfssvc(NFSSVC_ADDSOCK, &nfsdargs);
- (void)close(msgsock);
- }
-#endif /* notyet */
- }
-}
-
-void
-setbindhost(struct sockaddr_in *ia, const char *bindhost)
-{
- ia->sin_family = AF_INET;
- ia->sin_port = htons(NFS_PORT);
- ia->sin_len = sizeof(*ia);
- if (bindhost == NULL || strcmp(bindhost,"*") == 0) {
- ia->sin_addr.s_addr = INADDR_ANY;
- } else {
- if (inet_aton(bindhost, &ia->sin_addr) == 0) {
- struct hostent *he;
-
- he = gethostbyname2(bindhost, ia->sin_family);
- if (he == NULL) {
- syslog(LOG_ERR, "gethostbyname of %s failed", bindhost);
- exit(1);
- }
- bcopy(he->h_addr, &ia->sin_addr, he->h_length);
- }
- }
-}
-
-void
-usage()
-{
- (void)fprintf(stderr, "usage: nfsd %s\n", USAGE);
- exit(1);
-}
-
-void
-nonfs(signo)
- int signo;
-{
- syslog(LOG_ERR, "missing system call: NFS not available");
-}
-
-void
-reapchild(signo)
- int signo;
-{
-
- while (wait3(NULL, WNOHANG, NULL) > 0);
-}
-
-#ifdef OLD_SETPROCTITLE
-#ifdef __FreeBSD__
-void
-setproctitle(a)
- char *a;
-{
- register char *cp;
- char buf[80];
-
- cp = Argv[0];
- (void)snprintf(buf, sizeof(buf), "nfsd-%s", a);
- (void)strncpy(cp, buf, LastArg - cp);
- cp += strlen(cp);
- while (cp < LastArg)
- *cp++ = '\0';
- Argv[1] = NULL;
-}
-#endif /* __FreeBSD__ */
-#endif
diff --git a/usr.sbin/nologin/Makefile b/usr.sbin/nologin/Makefile
deleted file mode 100644
index e30ea0886d23..000000000000
--- a/usr.sbin/nologin/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-# @(#)Makefile 8.2 (Berkeley) 4/22/94
-
-MAN8= nologin.8
-MAN5= nologin.5
-
-nologin depend lint tags:
-
-beforeinstall:
- ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
- ${.CURDIR}/nologin.sh ${DESTDIR}${BINDIR}/nologin
-
-.include <bsd.prog.mk>
diff --git a/usr.sbin/nologin/nologin.5 b/usr.sbin/nologin/nologin.5
deleted file mode 100644
index 8ce22a264715..000000000000
--- a/usr.sbin/nologin/nologin.5
+++ /dev/null
@@ -1,66 +0,0 @@
-.\" Copyright (c) 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. 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, Berkeley and its contributors.
-.\" 4. 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.
-.\"
-.\" @(#)nologin.8 8.1 (Berkeley) 6/19/93
-.\" $FreeBSD$
-.\"
-.Dd June 19, 1993
-.Dt NOLOGIN 5
-.Os FreeBSD 2.1
-.Sh NAME
-.Nm nologin
-.Nd disallow logins
-.Sh DESCRIPTION
-.Nm Nologin
-disallows logins if the file
-.Pa /var/run/nologin
-exists.
-Programs display the contents of
-.Pa /var/run/nologin
-to the user and exit.
-.Sh SECURITY
-Ignored by
-.Xr login 1
-for user root.
-.Sh FILES
-.Bl -tag -width /var/run/nologinxxx -compact
-.It Pa /var/run/nologin
-The
-.Nm
-file resides in
-.Pa /var/run .
-.El
-.Sh SEE ALSO
-.Xr login 1 ,
-.Xr rlogin 1 ,
-.Xr telnet 1 ,
-.Xr nologin 8 ,
-.Xr shutdown 8
diff --git a/usr.sbin/nologin/nologin.8 b/usr.sbin/nologin/nologin.8
deleted file mode 100644
index d5f4cb7a5f0b..000000000000
--- a/usr.sbin/nologin/nologin.8
+++ /dev/null
@@ -1,56 +0,0 @@
-.\" Copyright (c) 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. 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, Berkeley and its contributors.
-.\" 4. 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.
-.\"
-.\" @(#)nologin.8 8.1 (Berkeley) 6/19/93
-.\" $FreeBSD$
-.\"
-.Dd June 19, 1993
-.Dt NOLOGIN 8
-.Os BSD 4.4
-.Sh NAME
-.Nm nologin
-.Nd politely refuse a login
-.Sh SYNOPSIS
-.Nm nologin
-.Sh DESCRIPTION
-.Nm Nologin
-displays a message that an account is not available and
-exits non-zero.
-It is intended as a replacement shell field for accounts that
-have been disabled.
-.Sh SEE ALSO
-.Xr login 1 ,
-.Xr nologin 5 .
-.Sh HISTORY
-The
-.Nm
-command appeared in
-.Bx 4.4 .
diff --git a/usr.sbin/nologin/nologin.sh b/usr.sbin/nologin/nologin.sh
deleted file mode 100644
index 52279c19ea9a..000000000000
--- a/usr.sbin/nologin/nologin.sh
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/bin/sh -p
-#
-# 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. 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, Berkeley and its contributors.
-# 4. 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.
-#
-# @(#)nologin.sh 8.1 (Berkeley) 6/5/93
-# $FreeBSD$
-#
-
-echo 'This account is currently not available.'
-exit 1
diff --git a/usr.sbin/ppp/README.nat b/usr.sbin/ppp/README.nat
deleted file mode 100644
index 5d297738b2f4..000000000000
--- a/usr.sbin/ppp/README.nat
+++ /dev/null
@@ -1,352 +0,0 @@
-User PPP Packet Aliasing
-
-
-
-0. Contents
- 1. Background
- 2. Setup
- 3. New commands in ppp
- 4. Future Work
- 5. Authors / Acknowledgements
- 6. Revision History for Aliasing Code
-
-
-
-1. Background
-
-User mode ppp has embedded packet aliasing (IP masquerading) code.
-Enabling this, either by the "-alias" command line option or the
-"alias enable yes" command in a ppp.conf file, makes the ppp host
-automatically alias IP packets forwarded from a local network, making
-them appear to come from the ppp host machine. Incoming packets
-from the outside world are then appropriately de-aliased.
-
-The process of aliasing involves both the IP address and the TCP or UDP
-port numbers. ICMP echo and timestamp packets are aliased by their id
-numbers. ICMP error messages can be properly directed by examining the
-fragment of the offending packet which is contained in the body of the
-message.
-
-This software was specifically meant to support users who have
-unregistered, private address IP networks (e.g. 192.168.0.x or 10.0.0.x
-addresses). The ppp host can act as a gateway for these networks, and
-computers on the local area net will have some degree of Internet access
-without the need for a registered IP address. Additionally, there will
-be no need for an Internet service provider to maintain routing tables
-for the local area network.
-
-A disadvantage of packet aliasing is that machines on the local network,
-behind the ppp host, are not visible from the outside world. They can
-establish TCP connections and make UDP inquiries (such as domain name
-service requests) but the connections seem to come from the ppp host
-itself. There is, in effect, a partial firewall. Of course, if this is
-what you want, the disadvantage becomes an advantage.
-
-A second disadvantage is that "IP encoding" protocols, which send IP
-address or port information within the data stream, are not supported
-for the cases where exception code exists. This implementation has
-workarounds for FTP and IRC DCC, the most well known of the IP encoding
-protocols. This frees users from depending on using the ftp passive
-mode and avoiding IRC DCC sends, as is sometimes the case with other
-masquerading solutions.
-
-The implementation supports all standard, non-encoding TCP and UDP protocols.
-Examples of these protocols are http, gopher and telnet. The standard UDP
-mode of Real-Audio is not presently supported, but the TCP mode does work
-correctly.
-
-The packet aliasing code also handle many ICMP messages. In particular,
-ping and traceroute are supported.
-
-
-
-2. Packet Aliasing Setup
-
-It is recommended that users first verify correct ppp operation without
-packet aliasing enabled. This will confirm that the ppp.conf file is
-properly set up and that there are no ppp problems. Then start ppp with
-the "-alias" option on the command line. The user should verify that
-the ppp host can correctly connect to the Internet in packet aliasing
-mode. Finally, check that machines on the private network can access
-the Internet.
-
-The masquerading software aliases all packets, whether they come from
-the host or another computer on the local area network. Thus, a correctly
-operating ppp host indicates that the software should work properly for
-other computers on the private network.
-
-If the ppp host can access the Internet, but other computers on the local
-network cannot, check that IP forwarding is enabled on the ppp host. Also,
-verify that the other computers use this machine as a gateway. Of course,
-you should also verify that machines within the local area network
-communicate properly. A common error is inconsistent subnet addresses
-and masks.
-
-
-
-3. New commands in ppp
-
-In order to control aliasing behaviour in a simple manner (no need for
-recompilation), a new command has been added to ppp: alias. This
-is in addition to the -alias command line option. System managers and
-more experienced users may prefer to use the ppp command syntax
-within the ppp.conf file. The alias command also allows packet aliasing
-behaviour to be more precisely specified.
-
-The decision to add a command instead of extending 'set' or 'option' was
-to make obvious that these options only work when aliasing is enabled.
-
-The syntax for 'alias' is
-
- ppp> alias option [yes|no]
-
-where option is given by one of the following templates.
-
-
- - alias enable [yes|no] (default no)
-
-Enable packet aliasing functionality. If disabled, no other alias
-options will have any effect. You should usually enable aliasing
-before routing any packets over the link; good points are in the
-initial script or right before adding a route. If you do not always
-want aliasing, consider using the -alias option to ppp instead of this
-command.
-
-
- - alias deny_incoming [yes|no] (default yes)
-
-Set to "yes" to disable all incoming connections. This just drops
-connections to, for example, ftp, telnet or web servers. The aliasing
-mechanism prevents these connections. Technically, this option denies
-all incoming TCP and UDP requests, making the aliasing software a
-fairly efficient one-way firewall. The default is no, which will allow
-all incoming connections to telnetd, ftpd, etc.
-
-
- - alias log [yes|no]
-
-Controls logging of alias link creation to "/var/log/alias.log" - this
-is usually only useful if debugging a setup, to see if the bug is in
-the PPP aliasing. The debugging information is fairly limited, listing
-the number of aliasing links open for different protocols.
-
-
- - alias same_ports [yes|no] (default yes)
-
-When a connection is being established going through the aliasing
-routines, it will normally have its port number changed to allow the
-aliasing code to track it. If same_ports is enabled, the alias
-software attempts to keep the connection's source port unchanged.
-This will allow rsh, RPC and other specialised protocols to work
-_most of the time_, at least on the host machine. Please, do not
-report this being unstable as a bug - it is a result of the way
-aliasing has to work. TCP/IP was intended to have one IP address
-per machine.
-
-
- - alias use_sockets [yes|no] (default yes)
-
-This is a fairly obscure option. For the most part, the packet aliasing
-software does not have to allocate system sockets when it chooses an
-aliasing port number. Under very specific circumstances, FTP data
-connections (which don't know the remote port number, though it is
-usually 20) and IRC DCC send (which doesn't know either the address or
-the port from which the connection will come), there can potentially be
-some interference with an open server socket having the same port number
-on the ppp host machine. This possibility for interference only exists
-until the TCP connection has been acknowledged on both sides. The safe
-option is yes, though fewer system resources are consumed by specifying
-no.
-
-
- - alias unregistered_only [yes|no] (default no)
-
-Packet aliasing normally remaps all packets coming from the local area
-network to the ppp host machine address. Set this option to only map
-addresses from the following standard ranges for private, unregistered
-addresses:
-
- 10.0.0.0 -> 10.255.255.255
- 172.16.0.0 -> 172.31.255.255
- 192.168.0.0 -> 192.168.255.255 */
-
-In the instance that there is a subnet of public addresses and another
-subnet of private addresses being routed by the ppp host, then only the
-packets on the private subnet will be aliased.
-
-
-- alias port <proto> <local addr>:<port> <alias port>
-
-This command allows incoming traffic to <alias port> on the host
-machine to be redirected to a specific machine and port on the
-local area network. One example of this would be:
-
- alias port tcp 192.168.0.4:telnet 8066
-
-All traffic to port 8066 of the ppp host would then be sent to
-the telnet port (23) of machine 192.168.0.4. Port numbers
-can either be designated numerically or by symbolic names
-listed in /etc/services. Similarly, addresses can be either
-in dotted quad notation or in /etc/hosts.
-
-
-- alias addr <local addr> <public addr>
-
-This command allows traffic for a public IP address to be
-redirected to a machine on the local network. This function
-is known as "static NAT". An address assignment of 0 refers
-to the default address of the ppp host. Normally static
-NAT is useful if your ISP has allocated a small block of
-IP addresses to the user, but it can even be used in the
-case of a single, dynamically allocated IP address:
-
- alias addr 10.0.0.8 0
-
-The above command would redirect all incoming traffic to
-machine 10.0.0.8.
-
-If several address aliases specify the same public address
-as follows
-
- alias addr 192.168.0.2 public_addr
- alias addr 192.168.0.3 public_addr
- alias addr 192.168.0.4 public_addr
-
-then incoming traffic will be directed to the last
-translated local address (192.168.0.4), but outgoing
-traffic to the first two addresses will still be aliased
-to the specified public address.
-
-
-
-4. Future Work
-
-What is called packet aliasing here has been variously called masquerading,
-network address translation (NAT) and transparent proxying by others. It
-is an extremely useful function to many users, but it is also necessarily
-imperfect. The occasional IP-encoding protocols always need workarounds
-(hacks). Users who are interested in supporting new IP-encoding protocols
-can follow the examples of alias_ftp.c and alias_irc.c.
-
-ICMP error messages are currently handled only in the incoming direction.
-A handler needs to be added to correctly alias outgoing error messages.
-
-IRC and FTP exception handling make reasonable, though not strictly correct
-assumptions, about how IP encoded messages will appear in the control
-stream. Programmers may wish to consider how to make this process more
-robust.
-
-The packet aliasing engine (alias.c, alias_db.c, alias_ftp.c, alias_irc.c
-and alias_util.c) runs in user space, and is intended to be both portable
-and reusable for interfaces other than ppp. To access the basic engine
-only requires four simple function calls (initialisation, communication of
-host address, outgoing aliasing and incoming de-aliasing).
-
-
-
-5. Authors / Acknowledgements
-
-Charles Mott (cmott@srv.net) <versions 1.0 - 1.8, 2.0, 2.1>
-Eivind Eklund (perhaps@yes.no) <versions 1.8b - 1.9, new ppp commands>
-
-Listed below, in chronological order, are individuals who have provided
-valuable comments and/or debugging assistance.
-
- Gary Roberts
- Tom Torrance
- Reto Burkhalter
- Martin Renters
- Brian Somers
- Paul Traina
- Ari Suutari
- J. Fortes
- Andrzej Bialeki
-
-
-
-6. Revision History for Aliasing Code
-
-Version 1.0: August 11, 1996 (cjm)
-
-Version 1.1: August 20, 1996 (cjm)
- PPP host accepts incoming connections for ports 0 to 1023.
-
-Version 1.2: September 7, 1996 (cjm)
- Fragment handling error in alias_db.c corrected.
-
-Version 1.3: September 15, 1996 (cjm)
- - Generalised mechanism for handling incoming connections
- (no more 0 to 1023 restriction).
- - Increased ICMP support (will handle traceroute now).
- - Improved TCP close connection logic.
-
-Version 1.4: September 16, 1996
- Can't remember (this version only lasted a day -- cjm).
-
-Version 1.5: September 17, 1996 (cjm)
- Corrected error in handling incoming UDP packets
- with zero checksum.
-
-Version 1.6: September 18, 1996
- Simplified ICMP data storage. Will now handle
- tracert from Win95 as well as FreeBSD traceroute.
-
-Version 1.7: January 9, 1997 (cjm)
- - Reduced malloc() activity for ICMP echo and
- timestamp requests.
- - Added handling for out-of-order IP fragments.
- - Switched to differential checksum computation
- for IP headers (TCP, UDP and ICMP checksums
- were already differential).
- - Accepts FTP data connections from other than
- port 20. This allows one ftp connections
- from two hosts which are both running packet
- aliasing.
-
-Version 1.8: January 14, 1997 (cjm)
- - Fixed data type error in function StartPoint()
- in alias_db.c (this bug did not exist before v1.7)
-
-Version 1.8b: January 16, 1997 (Eivind Eklund <perhaps@yes.no>)
- - Upgraded base PPP version to be the source code from
- FreeBSD 2.1.6, with additional security patches. This
- version should still be possible to run on 2.1.5, though -
- I've run it with a 2.1.5 kernel without problems.
- (Update done with the permission of cjm)
-
-Version 1.9: February 1, 1997 (Eivind Eklund <perhaps@yes.no>)
- - Added support for IRC DCC (ee)
- - Changed the aliasing routines to use ANSI style throughout -
- minor API changes for integration with other programs than PPP (ee)
- - Changed the build process, making all options switchable
- from the Makefile (ee)
- - Fixed minor security hole in alias_ftp.c for other applications
- of the aliasing software. Hole could _not_ manifest in
- PPP+pktAlias, but could potentially manifest in other
- applications of the aliasing. (ee)
- - Connections initiated from packet aliasing host machine will
- not have their port number aliased unless it conflicts with
- an aliasing port already being used. (There is an option to
- disable this for debugging) (cjm)
- - Sockets will be allocated in cases where there might be
- port interference with the host machine. This can be disabled
- in cases where the ppp host will be acting purely as a
- masquerading router and not generate any traffic of its own.
- (cjm)
-
-Version 2.0: March, 1997 (cjm)
- - Incoming packets which are not recognised by the packet
- aliasing engine are now completely dropped in ip.c.
- - Aliasing links are cleared when a host interface address
- changes (due to re-dial and dynamic address allocation).
- - PacketAliasPermanentLink() API added.
- - Option for only aliasing private, unregistered IP addresses
- added.
- - Substantial rework to the aliasing lookup engine.
-
-Version 2.1: May, 1997 (cjm)
- - Continuing rework to the aliasing lookup engine to support
- multiple incoming addresses and static NAT.
- - Now supports outgoing as well as incoming ICMP error messages/
- - PPP commands to support address and port redirection.
-
diff --git a/usr.sbin/ppp/ppp.8.m4 b/usr.sbin/ppp/ppp.8.m4
deleted file mode 100644
index b14363167aac..000000000000
--- a/usr.sbin/ppp/ppp.8.m4
+++ /dev/null
@@ -1,4886 +0,0 @@
-.\" $FreeBSD$
-.Dd 20 September 1995
-.nr XX \w'\fC00'
-.Os FreeBSD
-.Dt PPP 8
-.Sh NAME
-.Nm ppp
-.Nd Point to Point Protocol (a.k.a. user-ppp)
-.Sh SYNOPSIS
-.Nm
-.Op Fl Va mode
-.Op Fl nat
-.Op Fl quiet
-.Op Fl unit Ns Ar N
-.Op Ar system Ns
-.No ...
-.Sh DESCRIPTION
-This is a user process
-.Em PPP
-software package. Normally,
-.Em PPP
-is implemented as a part of the kernel (e.g. as managed by
-.Xr pppd 8 )
-and it's thus somewhat hard to debug and/or modify its behaviour.
-However, in this implementation
-.Em PPP
-is done as a user process with the help of the
-tunnel device driver (tun).
-.Pp
-The
-.Fl nat
-flag (or
-.Fl alias
-flag for backwards compatability) does the equivalent of a
-.Dq nat enable yes ,
-enabling
-.Nm ppp Ns No s
-network address translation features. This allows
-.Nm ppp
-to act as a NAT or masquerading engine for all machines on an internal
-LAN. Refer to
-.Xr libalias 3
-for details.
-.Pp
-The
-.Fl quiet
-flag tells
-.Nm
-to be silent at startup rather than displaying the mode and interface
-to standard output.
-.Pp
-The
-.Fl unit
-flag tells
-.Nm
-to only attempt to open
-.Pa /dev/tun Ns Ar N .
-Normally,
-.Nm
-will start with a value of 0 for
-.Ar N ,
-and keep trying to open a tunnel device by incrementing the value of
-.Ar N
-by one each time until it succeeds. If it fails three times in a row
-because the device file is missing, it gives up.
-.Pp
-The following
-.Va mode Ns No s
-are understood by
-.Nm ppp :
-.Bl -tag -width XXX -offset XXX
-.It Fl auto
-.Nm
-opens the tun interface, configures it then goes into the background.
-The link isn't brought up until outgoing data is detected on the tun
-interface at which point
-.Nm
-attempts to bring up the link. Packets received (including the first one)
-while
-.Nm
-is trying to bring the link up will remain queued for a default of
-2 minutes. See the
-.Dq set choked
-command below.
-.Pp
-In
-.Fl auto
-mode, at least one
-.Dq system
-must be given on the command line (see below) and a
-.Dq set ifaddr
-must be done in the system profile that specifies a peer IP address to
-use when configuring the interface. Something like
-.Dq 10.0.0.1/0
-is usually appropriate. See the
-.Dq pmdemand
-system in
-.Pa /usr/share/examples/ppp/ppp.conf.sample
-for an example.
-.It Fl background
-Here,
-.Nm
-attempts to establish a connection with the peer immediately. If it
-succeeds,
-.Nm
-goes into the background and the parent process returns an exit code
-of 0. If it fails,
-.Nm
-exits with a non-zero result.
-.It Fl foreground
-In foreground mode,
-.Nm
-attempts to establish a connection with the peer immediately, but never
-becomes a daemon. The link is created in background mode. This is useful
-if you wish to control
-.Nm ppp Ns No s
-invocation from another process.
-.It Fl direct
-This is used for receiving incoming connections.
-.Nm
-ignores the
-.Dq set device
-line and uses descriptor 0 as the link.
-.Pp
-If callback is configured,
-.Nm
-will use the
-.Dq set device
-information when dialing back.
-.It Fl dedicated
-This option is designed for machines connected with a dedicated
-wire.
-.Nm
-will always keep the device open and will never use any configured
-chat scripts.
-.It Fl ddial
-This mode is equivalent to
-.Fl auto
-mode except that
-.Nm
-will bring the link back up any time it's dropped for any reason.
-.It Fl interactive
-This is a no-op, and gives the same behaviour as if none of the above
-modes have been specified.
-.Nm
-loads any sections specified on the command line then provides an
-interactive prompt.
-.El
-.Pp
-One or more configuration entries or systems
-.Pq as specified in Pa /etc/ppp/ppp.conf
-may also be specified on the command line.
-.Nm
-will read the
-.Dq default
-system from
-.Pa /etc/ppp/ppp.conf
-at startup, followed by each of the systems specified on the command line.
-.Sh Major Features
-.Bl -diag
-.It Provides an interactive user interface.
-Using its command mode, the user can
-easily enter commands to establish the connection with the remote end, check
-the status of connection and close the connection. All functions can
-also be optionally password protected for security.
-.It Supports both manual and automatic dialing.
-Interactive mode has a
-.Dq term
-command which enables you to talk to the device directly. When you
-are connected to the remote peer and it starts to talk
-.Em PPP ,
-.Nm
-detects it and switches to packet mode automatically. Once you have
-determined the proper sequence for connecting with the remote host, you
-can write a chat script to define the necessary dialing and login
-procedure for later convenience.
-.It Supports on-demand dialup capability.
-By using
-.Fl auto
-mode,
-.Nm
-will act as a daemon and wait for a packet to be sent over the
-.Em PPP
-link. When this happens, the daemon automatically dials and establishes the
-connection.
-In almost the same manner
-.Fl ddial
-mode (direct-dial mode) also automatically dials and establishes the
-connection. However, it differs in that it will dial the remote site
-any time it detects the link is down, even if there are no packets to be
-sent. This mode is useful for full-time connections where we worry less
-about line charges and more about being connected full time.
-A third
-.Fl dedicated
-mode is also available. This mode is targeted at a dedicated link
-between two machines.
-.Nm
-will never voluntarily quit from dedicated mode - you must send it the
-.Dq quit all
-command via its diagnostic socket. A
-.Dv SIGHUP
-will force an LCP renegotiation, and a
-.Dv SIGTERM
-will force it to exit.
-.It Supports client callback.
-.Nm
-can use either the standard LCP callback protocol or the Microsoft
-CallBack Control Protocol (ftp://ftp.microsoft.com/developr/rfc/cbcp.txt).
-.It Supports NAT or packet aliasing.
-Packet aliasing (a.k.a. IP masquerading) allows computers on a
-private, unregistered network to access the Internet. The
-.Em PPP
-host acts as a masquerading gateway. IP addresses as well as TCP and
-UDP port numbers are aliased for outgoing packets and de-aliased for
-returning packets.
-.It Supports background PPP connections.
-In background mode, if
-.Nm
-successfully establishes the connection, it will become a daemon.
-Otherwise, it will exit with an error. This allows the setup of
-scripts that wish to execute certain commands only if the connection
-is successfully established.
-.It Supports server-side PPP connections.
-In direct mode,
-.Nm
-acts as server which accepts incoming
-.Em PPP
-connections on stdin/stdout.
-.It Supports PAP and CHAP (rfc 1994) authentication.
-With PAP or CHAP, it is possible to skip the Unix style
-.Xr login 1
-procedure, and use the
-.Em PPP
-protocol for authentication instead. If the peer requests Microsoft
-CHAP authentication and
-.Nm
-is compiled with DES support, an appropriate MD4/DES response will be
-made.
-.It Supports RADIUS (rfc 2138) authentication.
-An extension to PAP and CHAP,
-.Em \&R Ns No emote
-.Em \&A Ns No ccess
-.Em \&D Ns No ial
-.Em \&I Ns No n
-.Em \&U Ns No ser
-.Em \&S Ns No ervice
-allows authentication information to be stored in a central or
-distributed database along with various per-user framed connection
-characteristics. If
-.Pa libradius
-is available at compile time,
-.Nm
-will use it to make
-.Em RADIUS
-requests when configured to do so.
-.It Supports Proxy Arp.
-.Nm
-can be configured to make one or more proxy arp entries on behalf of
-the peer. This allows routing from the peer to the LAN without
-configuring each machine on that LAN.
-.It Supports packet filtering.
-User can define four kinds of filters: the
-.Em in
-filter for incoming packets, the
-.Em out
-filter for outgoing packets, the
-.Em dial
-filter to define a dialing trigger packet and the
-.Em alive
-filter for keeping a connection alive with the trigger packet.
-.It Tunnel driver supports bpf.
-The user can use
-.Xr tcpdump 1
-to check the packet flow over the
-.Em PPP
-link.
-.It Supports PPP over TCP and PPP over UDP.
-If a device name is specified as
-.Em host Ns No : Ns Em port Ns
-.Xo
-.Op / Ns tcp|udp ,
-.Xc
-.Nm
-will open a TCP or UDP connection for transporting data rather than using a
-conventional serial device. UDP connections force
-.Nm
-into synchronous mode.
-.It Supports PPP over ISDN.
-If
-.Nm
-is given a raw B-channel i4b device to open as a link, it's able to talk
-to the
-.Xr isdnd 8
-daemon to establish an ISDN connection.
-.It Supports PPP over Ethernet (rfc 2516).
-If
-.Nm
-is given a device specification of the format
-.No PPPoE: Ns Ar iface Ns Xo
-.Op \&: Ns Ar provider Ns
-.Xc
-and if
-.Xr netgraph 4
-is available,
-.Nm
-will attempt talk
-.Em PPP
-over Ethernet to
-.Ar provider
-using the
-.Ar iface
-network interface.
-.It "Supports IETF draft Predictor-1 (rfc 1978) and DEFLATE (rfc 1979) compression."
-.Nm
-supports not only VJ-compression but also Predictor-1 and DEFLATE compression.
-Normally, a modem has built-in compression (e.g. v42.bis) and the system
-may receive higher data rates from it as a result of such compression.
-While this is generally a good thing in most other situations, this
-higher speed data imposes a penalty on the system by increasing the
-number of serial interrupts the system has to process in talking to the
-modem and also increases latency. Unlike VJ-compression, Predictor-1 and
-DEFLATE compression pre-compresses
-.Em all
-network traffic flowing through the link, thus reducing overheads to a
-minimum.
-.It Supports Microsoft's IPCP extensions (rfc 1877).
-Name Server Addresses and NetBIOS Name Server Addresses can be negotiated
-with clients using the Microsoft
-.Em PPP
-stack (ie. Win95, WinNT)
-.It Supports Multi-link PPP (rfc 1990)
-It is possible to configure
-.Nm
-to open more than one physical connection to the peer, combining the
-bandwidth of all links for better throughput.
-.El
-.Sh PERMISSIONS
-.Nm
-is installed as user
-.Dv root
-and group
-.Dv network ,
-with permissions
-.Dv 04554 .
-By default,
-.Nm
-will not run if the invoking user id is not zero. This may be overridden
-by using the
-.Dq allow users
-command in
-.Pa /etc/ppp/ppp.conf .
-When running as a normal user,
-.Nm
-switches to user id 0 in order to alter the system routing table, set up
-system lock files and read the ppp configuration files. All
-external commands (executed via the "shell" or "!bg" commands) are executed
-as the user id that invoked
-.Nm ppp .
-Refer to the
-.Sq ID0
-logging facility if you're interested in what exactly is done as user id
-zero.
-.Sh GETTING STARTED
-When you first run
-.Nm
-you may need to deal with some initial configuration details.
-.Bl -bullet
-.It
-Your kernel must include a tunnel device (the GENERIC kernel includes
-one by default). If it doesn't, or if you require more than one tun
-interface, you'll need to rebuild your kernel with the following line in
-your kernel configuration file:
-.Pp
-.Dl pseudo-device tun N
-.Pp
-where
-.Ar N
-is the maximum number of
-.Em PPP
-connections you wish to support.
-.It
-Check your
-.Pa /dev
-directory for the tunnel device entries
-.Pa /dev/tunN ,
-where
-.Sq N
-represents the number of the tun device, starting at zero.
-If they don't exist, you can create them by running "sh ./MAKEDEV tunN".
-This will create tun devices 0 through
-.Ar N .
-.It
-Make sure that your system has a group named
-.Dq network
-in the
-.Pa /etc/group
-file and that that group contains the names of all users expected to use
-.Nm ppp .
-Refer to the
-.Xr group 5
-manual page for details. Each of these users must also be given access
-using the
-.Dq allow users
-command in
-.Pa /etc/ppp/ppp.conf .
-.It
-Create a log file.
-.Nm
-uses
-.Xr syslog 3
-to log information. A common log file name is
-.Pa /var/log/ppp.log .
-To make output go to this file, put the following lines in the
-.Pa /etc/syslog.conf
-file:
-.Bd -literal -offset indent
-!ppp
-*.*<TAB>/var/log/ppp.log
-.Ed
-.Pp
-It is possible to have more than one
-.Em PPP
-log file by creating a link to the
-.Nm
-executable:
-.Pp
-.Dl # cd /usr/sbin
-.Dl # ln ppp ppp0
-.Pp
-and using
-.Bd -literal -offset indent
-!ppp0
-*.*<TAB>/var/log/ppp0.log
-.Ed
-.Pp
-in
-.Pa /etc/syslog.conf .
-Don't forget to send a
-.Dv HUP
-signal to
-.Xr syslogd 8
-after altering
-.Pa /etc/syslog.conf .
-.It
-Although not strictly relevant to
-.Nm ppp Ns No s
-operation, you should configure your resolver so that it works correctly.
-This can be done by configuring a local DNS
-.Pq using Xr named 8
-or by adding the correct
-.Sq name-server
-lines to the file
-.Pa /etc/resolv.conf .
-Refer to the
-.Xr resolv.conf 5
-manual page for details.
-.Pp
-Alternatively, if the peer supports it,
-.Nm
-can be configured to ask the peer for the nameserver address(es) and to
-update
-.Pa /etc/resolv.conf
-automatically. Refer to the
-.Dq enable dns
-command below for details.
-.El
-.Sh MANUAL DIALING
-In the following examples, we assume that your machine name is
-.Dv awfulhak .
-when you invoke
-.Nm
-(see
-.Sx PERMISSIONS
-above) with no arguments, you are presented with a prompt:
-.Bd -literal -offset indent
-ppp ON awfulhak>
-.Ed
-.Pp
-The
-.Sq ON
-part of your prompt should always be in upper case. If it is in lower
-case, it means that you must supply a password using the
-.Dq passwd
-command. This only ever happens if you connect to a running version of
-.Nm
-and have not authenticated yourself using the correct password.
-.Pp
-You can start by specifying the device name and speed:
-.Bd -literal -offset indent
-ppp ON awfulhak> set device /dev/cuaa0
-ppp ON awfulhak> set speed 38400
-.Ed
-.Pp
-Normally, hardware flow control (CTS/RTS) is used. However, under
-certain circumstances (as may happen when you are connected directly
-to certain PPP-capable terminal servers), this may result in
-.Nm
-hanging as soon as it tries to write data to your communications link
-as it is waiting for the CTS (clear to send) signal - which will never
-come. Thus, if you have a direct line and can't seem to make a
-connection, try turning CTS/RTS off with
-.Dq set ctsrts off .
-If you need to do this, check the
-.Dq set accmap
-description below too - you'll probably need to
-.Dq set accmap 000a0000 .
-.Pp
-Usually, parity is set to
-.Dq none ,
-and this is
-.Nm ppp Ns No s
-default. Parity is a rather archaic error checking mechanism that is no
-longer used because modern modems do their own error checking, and most
-link-layer protocols (that's what
-.Nm
-is) use much more reliable checking mechanisms. Parity has a relatively
-huge overhead (a 12.5% increase in traffic) and as a result, it is always
-disabled
-.Pq set to Dq none
-when
-.Dv PPP
-is opened. However, some ISPs (Internet Service Providers) may use
-specific parity settings at connection time (before
-.Dv PPP
-is opened). Notably, Compuserve insist
-on even parity when logging in:
-.Bd -literal -offset indent
-ppp ON awfulhak> set parity even
-.Ed
-.Pp
-You can now see what your current device settings look like:
-.Bd -literal -offset indent
-ppp ON awfulhak> show physical
-Name: deflink
- State: closed
- Device: N/A
- Link Type: interactive
- Connect Count: 0
- Queued Packets: 0
- Phone Number: N/A
-
-Defaults:
- Device List: /dev/cuaa0
- Characteristics: 38400bps, cs8, even parity, CTS/RTS on
-
-Connect time: 0 secs
-0 octets in, 0 octets out
-Overall 0 bytes/sec
-ppp ON awfulhak>
-.Ed
-.Pp
-The term command can now be used to talk directly to the device:
-.Bd -literal -offset indent
-ppp ON awfulhak> term
-at
-OK
-atdt123456
-CONNECT
-login: myispusername
-Password: myisppassword
-Protocol: ppp
-.Ed
-.Pp
-When the peer starts to talk in
-.Em PPP ,
-.Nm
-detects this automatically and returns to command mode.
-.Bd -literal -offset indent
-ppp ON awfulhak> # No link has been established
-Ppp ON awfulhak> # We've connected & finished LCP
-PPp ON awfulhak> # We've authenticated
-PPP ON awfulhak> # We've agreed IP numbers
-.Ed
-.Pp
-If it does not, it's probable that the peer is waiting for your end to
-start negotiating. To force
-.Nm
-to start sending
-.Em PPP
-configuration packets to the peer, use the
-.Dq ~p
-command to drop out of terminal mode and enter packet mode.
-.Pp
-If you never even receive a login prompt, it is quite likely that the
-peer wants to use PAP or CHAP authentication instead of using Unix-style
-login/password authentication. To set things up properly, drop back to
-the prompt and set your authentication name and key, then reconnect:
-.Bd -literal -offset indent
-~.
-ppp ON awfulhak> set authname myispusername
-ppp ON awfulhak> set authkey myisppassword
-ppp ON awfulhak> term
-at
-OK
-atdt123456
-CONNECT
-.Ed
-.Pp
-You may need to tell ppp to initiate negotiations with the peer here too:
-.Bd -literal -offset indent
-~p
-ppp ON awfulhak> # No link has been established
-Ppp ON awfulhak> # We've connected & finished LCP
-PPp ON awfulhak> # We've authenticated
-PPP ON awfulhak> # We've agreed IP numbers
-.Ed
-.Pp
-You are now connected! Note that
-.Sq PPP
-in the prompt has changed to capital letters to indicate that you have
-a peer connection. If only some of the three Ps go uppercase, wait until
-either everything is uppercase or lowercase. If they revert to lowercase,
-it means that
-.Nm
-couldn't successfully negotiate with the peer. A good first step
-for troubleshooting at this point would be to
-.Bd -literal -offset indent
-ppp ON awfulhak> set log local phase lcp ipcp
-.Ed
-.Pp
-and try again. Refer to the
-.Dq set log
-command description below for further details. If things fail at this point,
-it is quite important that you turn logging on and try again. It is also
-important that you note any prompt changes and report them to anyone trying
-to help you.
-.Pp
-When the link is established, the show command can be used to see how
-things are going:
-.Bd -literal -offset indent
-PPP ON awfulhak> show physical
-* Modem related information is shown here *
-PPP ON awfulhak> show ccp
-* CCP (compression) related information is shown here *
-PPP ON awfulhak> show lcp
-* LCP (line control) related information is shown here *
-PPP ON awfulhak> show ipcp
-* IPCP (IP) related information is shown here *
-PPP ON awfulhak> show link
-* Link (high level) related information is shown here *
-PPP ON awfulhak> show bundle
-* Logical (high level) connection related information is shown here *
-.Ed
-.Pp
-At this point, your machine has a host route to the peer. This means
-that you can only make a connection with the host on the other side
-of the link. If you want to add a default route entry (telling your
-machine to send all packets without another routing entry to the other
-side of the
-.Em PPP
-link), enter the following command:
-.Bd -literal -offset indent
-PPP ON awfulhak> add default HISADDR
-.Ed
-.Pp
-The string
-.Sq HISADDR
-represents the IP address of the connected peer.
-If the
-.Dq add
-command fails due to an existing route, you can overwrite the existing
-route using
-.Bd -literal -offset indent
-PPP ON awfulhak> add! default HISADDR
-.Ed
-.Pp
-This command can also be executed before actually making the connection.
-If a new IP address is negotiated at connection time,
-.Nm
-will update your default route accordingly.
-.Pp
-You can now use your network applications (ping, telnet, ftp etc.)
-in other windows or terminals on your machine. If you wish to reuse
-the current terminal, you can put
-.Nm
-into the background using your standard shell suspend and background
-commands (usually
-.Dq ^Z
-followed by
-.Dq bg ) .
-.Pp
-Refer to the
-.Sx PPP COMMAND LIST
-section for details on all available commands.
-.Sh AUTOMATIC DIALING
-To use automatic dialing, you must prepare some Dial and Login chat scripts.
-See the example definitions in
-.Pa /usr/share/examples/ppp/ppp.conf.sample
-(the format of
-.Pa /etc/ppp/ppp.conf
-is pretty simple).
-Each line contains one comment, inclusion, label or command:
-.Bl -bullet
-.It
-A line starting with a
-.Pq Dq #
-character is treated as a comment line. Leading whitespace are ignored
-when identifying comment lines.
-.It
-An inclusion is a line beginning with the word
-.Sq !include .
-It must have one argument - the file to include. You may wish to
-.Dq !include ~/.ppp.conf
-for compatibility with older versions of
-.Nm ppp .
-.It
-A label name starts in the first column and is followed by
-a colon
-.Pq Dq \&: .
-.It
-A command line must contain a space or tab in the first column.
-.El
-.Pp
-The
-.Pa /etc/ppp/ppp.conf
-file should consist of at least a
-.Dq default
-section. This section is always executed. It should also contain
-one or more sections, named according to their purpose, for example,
-.Dq MyISP
-would represent your ISP, and
-.Dq ppp-in
-would represent an incoming
-.Nm
-configuration.
-You can now specify the destination label name when you invoke
-.Nm ppp .
-Commands associated with the
-.Dq default
-label are executed, followed by those associated with the destination
-label provided. When
-.Nm
-is started with no arguments, the
-.Dq default
-section is still executed. The load command can be used to manually
-load a section from the
-.Pa /etc/ppp/ppp.conf
-file:
-.Bd -literal -offset indent
-ppp ON awfulhak> load MyISP
-.Ed
-.Pp
-Note, no action is taken by
-.Nm
-after a section is loaded, whether it's the result of passing a label on
-the command line or using the
-.Dq load
-command. Only the commands specified for that label in the configuration
-file are executed. However, when invoking
-.Nm
-with the
-.Fl background ,
-.Fl ddial ,
-or
-.Fl dedicated
-switches, the link mode tells
-.Nm
-to establish a connection. Refer to the
-.Dq set mode
-command below for further details.
-.Pp
-Once the connection is made, the
-.Sq ppp
-portion of the prompt will change to
-.Sq PPP :
-.Bd -literal -offset indent
-# ppp MyISP
-\&...
-ppp ON awfulhak> dial
-Ppp ON awfulhak>
-PPp ON awfulhak>
-PPP ON awfulhak>
-.Ed
-.Pp
-The Ppp prompt indicates that
-.Nm
-has entered the authentication phase. The PPp prompt indicates that
-.Nm
-has entered the network phase. The PPP prompt indicates that
-.Nm
-has successfully negotiated a network layer protocol and is in
-a usable state.
-.Pp
-If the
-.Pa /etc/ppp/ppp.linkup
-file is available, its contents are executed
-when the
-.Em PPP
-connection is established. See the provided
-.Dq pmdemand
-example in
-.Pa /usr/share/examples/ppp/ppp.conf.sample
-which runs a script in the background after the connection is established
-(refer to the
-.Dq shell
-and
-.Dq bg
-commands below for a description of possible substitution strings). Similarly,
-when a connection is closed, the contents of the
-.Pa /etc/ppp/ppp.linkdown
-file are executed. Both of these files have the same format as
-.Pa /etc/ppp/ppp.conf .
-.Pp
-In previous versions of
-.Nm ppp ,
-it was necessary to re-add routes such as the default route in the
-.Pa ppp.linkup
-file.
-.Nm
-now supports
-.Sq sticky routes ,
-where all routes that contain the
-.Dv HISADDR
-or
-.Dv MYADDR
-literals will automatically be updated when the values of
-.Dv HISADDR
-and/or
-.Dv MYADDR
-change.
-.Sh BACKGROUND DIALING
-If you want to establish a connection using
-.Nm
-non-interactively (such as from a
-.Xr crontab 5
-entry or an
-.Xr at 1
-job) you should use the
-.Fl background
-option.
-When
-.Fl background
-is specified,
-.Nm
-attempts to establish the connection immediately. If multiple phone
-numbers are specified, each phone number will be tried once. If the
-attempt fails,
-.Nm
-exits immediately with a non-zero exit code.
-If it succeeds, then
-.Nm
-becomes a daemon, and returns an exit status of zero to its caller.
-The daemon exits automatically if the connection is dropped by the
-remote system, or it receives a
-.Dv TERM
-signal.
-.Sh DIAL ON DEMAND
-Demand dialing is enabled with the
-.Fl auto
-or
-.Fl ddial
-options. You must also specify the destination label in
-.Pa /etc/ppp/ppp.conf
-to use. It must contain the
-.Dq set ifaddr
-command to define the remote peers IP address.
-(refer to
-.Pa /usr/share/examples/ppp/ppp.conf.sample )
-.Bd -literal -offset indent
-# ppp -auto pmdemand
-.Ed
-.Pp
-When
-.Fl auto
-or
-.Fl ddial
-is specified,
-.Nm
-runs as a daemon but you can still configure or examine its
-configuration by using the
-.Dq set server
-command in
-.Pa /etc/ppp/ppp.conf ,
-.Pq for example, Dq set server +3000 mypasswd
-and connecting to the diagnostic port as follows:
-.Bd -literal -offset indent
-# pppctl 3000 (assuming tun0)
-Password:
-PPP ON awfulhak> show who
-tcp (127.0.0.1:1028) *
-.Ed
-.Pp
-The
-.Dq show who
-command lists users that are currently connected to
-.Nm
-itself. If the diagnostic socket is closed or changed to a different
-socket, all connections are immediately dropped.
-.Pp
-In
-.Fl auto
-mode, when an outgoing packet is detected,
-.Nm
-will perform the dialing action (chat script) and try to connect
-with the peer. In
-.Fl ddial
-mode, the dialing action is performed any time the line is found
-to be down.
-If the connect fails, the default behaviour is to wait 30 seconds
-and then attempt to connect when another outgoing packet is detected.
-This behaviour can be changed using the
-.Dq set redial
-command:
-.Pp
-.No set redial Ar secs Ns Xo
-.Oo + Ns Ar inc Ns
-.Op - Ns Ar max Ns
-.Oc Op . Ns Ar next
-.Op Ar attempts
-.Xc
-.Pp
-.Bl -tag -width attempts -compact
-.It Ar secs
-is the number of seconds to wait before attempting
-to connect again.
-If the argument is the literal string
-.Sq Li random ,
-the delay period is a random value between 1 and 30 seconds inclusive.
-.It Ar inc
-is the number of seconds that
-.Ar secs
-should be incremented each time a new dial attempt is made. The timeout
-reverts to
-.Ar secs
-only after a successful connection is established. The default value for
-.Ar inc
-is zero.
-.It Ar max
-is the maximum number of times
-.Nm
-should increment
-.Ar secs .
-The default value for
-.Ar max
-is 10.
-.It Ar next
-is the number of seconds to wait before attempting
-to dial the next number in a list of numbers (see the
-.Dq set phone
-command). The default is 3 seconds. Again, if the argument is the literal
-string
-.Sq Li random ,
-the delay period is a random value between 1 and 30 seconds.
-.It Ar attempts
-is the maximum number of times to try to connect for each outgoing packet
-that triggers a dial. The previous value is unchanged if this parameter
-is omitted. If a value of zero is specified for
-.Ar attempts ,
-.Nm
-will keep trying until a connection is made.
-.El
-.Pp
-So, for example;
-.Bd -literal -offset indent
-set redial 10.3 4
-.Ed
-.Pp
-will attempt to connect 4 times for each outgoing packet that causes
-a dial attempt with a 3 second delay between each number and a 10 second
-delay after all numbers have been tried. If multiple phone numbers
-are specified, the total number of attempts is still 4 (it does not
-attempt each number 4 times).
-.Pp
-Alternatively,
-.Pp
-.Bd -literal -offset indent
-set redial 10+10-5.3 20
-.Ed
-.Pp
-tells
-.Nm
-to attempt to connect 20 times. After the first attempt,
-.Nm
-pauses for 10 seconds. After the next attempt it pauses for 20 seconds
-and so on until after the sixth attempt it pauses for 1 minute. The next
-14 pauses will also have a duration of one minute. If
-.Nm
-connects, disconnects and fails to connect again, the timeout starts again
-at 10 seconds.
-.Pp
-Modifying the dial delay is very useful when running
-.Nm
-in
-.Fl auto
-mode on both ends of the link.
-If each end has the same timeout,
-both ends wind up calling each other at the same time if the link
-drops and both ends have packets queued.
-At some locations, the serial link may not be reliable, and carrier
-may be lost at inappropriate times. It is possible to have
-.Nm
-redial should carrier be unexpectedly lost during a session.
-.Bd -literal -offset indent
-set reconnect timeout ntries
-.Ed
-.Pp
-This command tells
-.Nm
-to re-establish the connection
-.Ar ntries
-times on loss of carrier with a pause of
-.Ar timeout
-seconds before each try. For example,
-.Bd -literal -offset indent
-set reconnect 3 5
-.Ed
-.Pp
-tells
-.Nm
-that on an unexpected loss of carrier, it should wait
-.Ar 3
-seconds before attempting to reconnect. This may happen up to
-.Ar 5
-times before
-.Nm
-gives up. The default value of ntries is zero (no reconnect). Care
-should be taken with this option. If the local timeout is slightly
-longer than the remote timeout, the reconnect feature will always be
-triggered (up to the given number of times) after the remote side
-times out and hangs up.
-NOTE: In this context, losing too many LQRs constitutes a loss of
-carrier and will trigger a reconnect.
-If the
-.Fl background
-flag is specified, all phone numbers are dialed at most once until
-a connection is made. The next number redial period specified with
-the
-.Dq set redial
-command is honoured, as is the reconnect tries value. If your redial
-value is less than the number of phone numbers specified, not all
-the specified numbers will be tried.
-To terminate the program, type
-.Bd -literal -offset indent
-PPP ON awfulhak> close
-ppp ON awfulhak> quit all
-.Ed
-.Pp
-A simple
-.Dq quit
-command will terminate the
-.Xr pppctl 8
-or
-.Xr telnet 1
-connection but not the
-.Nm
-program itself.
-You must use
-.Dq quit all
-to terminate
-.Nm
-as well.
-.Sh RECEIVING INCOMING PPP CONNECTIONS (Method 1)
-To handle an incoming
-.Em PPP
-connection request, follow these steps:
-.Bl -enum
-.It
-Make sure the modem and (optionally)
-.Pa /etc/rc.serial
-is configured correctly.
-.Bl -bullet -compact
-.It
-Use Hardware Handshake (CTS/RTS) for flow control.
-.It
-Modem should be set to NO echo back (ATE0) and NO results string (ATQ1).
-.El
-.Pp
-.It
-Edit
-.Pa /etc/ttys
-to enable a
-.Xr getty 8
-on the port where the modem is attached.
-For example:
-.Pp
-.Dl ttyd1 "/usr/libexec/getty std.38400" dialup on secure
-.Pp
-Don't forget to send a
-.Dv HUP
-signal to the
-.Xr init 8
-process to start the
-.Xr getty 8 :
-.Pp
-.Dl # kill -HUP 1
-.It
-Create a
-.Pa /usr/local/bin/ppplogin
-file with the following contents:
-.Bd -literal -offset indent
-#! /bin/sh
-exec /usr/sbin/ppp -direct incoming
-.Ed
-.Pp
-Direct mode
-.Pq Fl direct
-lets
-.Nm
-work with stdin and stdout. You can also use
-.Xr pppctl 8
-to connect to a configured diagnostic port, in the same manner as with
-client-side
-.Nm ppp .
-.Pp
-Here, the
-.Ar incoming
-section must be set up in
-.Pa /etc/ppp/ppp.conf .
-.Pp
-Make sure that the
-.Ar incoming
-section contains the
-.Dq allow users
-command as appropriate.
-.It
-Prepare an account for the incoming user.
-.Bd -literal
-ppp:xxxx:66:66:PPP Login User:/home/ppp:/usr/local/bin/ppplogin
-.Ed
-.Pp
-Refer to the manual entries for
-.Xr adduser 8
-and
-.Xr vipw 8
-for details.
-.It
-Support for IPCP Domain Name Server and NetBIOS Name Server negotiation
-can be enabled using the
-.Dq accept dns
-and
-.Dq set nbns
-commands. Refer to their descriptions below.
-.El
-.Pp
-.Sh RECEIVING INCOMING PPP CONNECTIONS (Method 2)
-This method differs in that we use
-.Nm ppp
-to authenticate the connection rather than
-.Xr login 1 :
-.Bl -enum
-.It
-Configure your default section in
-.Pa /etc/gettytab
-with automatic ppp recognition by specifying the
-.Dq pp
-capability:
-.Bd -literal
-default:\\
- :pp=/usr/local/bin/ppplogin:\\
- .....
-.Ed
-.It
-Configure your serial device(s), enable a
-.Xr getty 8
-and create
-.Pa /usr/local/bin/ppplogin
-as in the first three steps for method 1 above.
-.It
-Add either
-.Dq enable chap
-or
-.Dq enable pap
-.Pq or both
-to
-.Pa /etc/ppp/ppp.conf
-under the
-.Sq incoming
-label (or whatever label
-.Pa ppplogin
-uses).
-.It
-Create an entry in
-.Pa /etc/ppp/ppp.secret
-for each incoming user:
-.Bd -literal
-Pfred<TAB>xxxx
-Pgeorge<TAB>yyyy
-.Ed
-.El
-.Pp
-Now, as soon as
-.Xr getty 8
-detects a ppp connection (by recognising the HDLC frame headers), it runs
-.Dq /usr/local/bin/ppplogin .
-.Pp
-It is
-.Em VITAL
-that either PAP or CHAP are enabled as above. If they are not, you are
-allowing anybody to establish ppp session with your machine
-.Em without
-a password, opening yourself up to all sorts of potential attacks.
-.Sh AUTHENTICATING INCOMING CONNECTIONS
-Normally, the receiver of a connection requires that the peer
-authenticates itself. This may be done using
-.Xr login 1 ,
-but alternatively, you can use PAP or CHAP. CHAP is the more secure
-of the two, but some clients may not support it. Once you decide which
-you wish to use, add the command
-.Sq enable chap
-or
-.Sq enable pap
-to the relevant section of
-.Pa ppp.conf .
-.Pp
-You must then configure the
-.Pa /etc/ppp/ppp.secret
-file. This file contains one line per possible client, each line
-containing up to five fields:
-.Pp
-.Ar name Ar key Oo
-.Ar hisaddr Op Ar label Op Ar callback-number
-.Oc
-.Pp
-The
-.Ar name
-and
-.Ar key
-specify the client username and password. If
-.Ar key
-is
-.Dq \&*
-and PAP is being used,
-.Nm
-will look up the password database
-.Pq Xr passwd 5
-when authenticating. If the client does not offer a suitable
-response based on any
-.Ar name Ns No / Ns Ar key
-combination in
-.Pa ppp.secret ,
-authentication fails.
-.Pp
-If authentication is successful,
-.Ar hisaddr
-.Pq if specified
-is used when negotiating IP numbers. See the
-.Dq set ifaddr
-command for details.
-.Pp
-If authentication is successful and
-.Ar label
-is specified, the current system label is changed to match the given
-.Ar label .
-This will change the subsequent parsing of the
-.Pa ppp.linkup
-and
-.Pa ppp.linkdown
-files.
-.Pp
-If authentication is successful and
-.Ar callback-number
-is specified and
-.Dq set callback
-has been used in
-.Pa ppp.conf ,
-the client will be called back on the given number. If CBCP is being used,
-.Ar callback-number
-may also contain a list of numbers or a
-.Dq \&* ,
-as if passed to the
-.Dq set cbcp
-command. The value will be used in
-.Nm ppp Ns No s
-subsequent CBCP phase.
-.Sh PPP OVER TCP and UDP (a.k.a Tunnelling)
-Instead of running
-.Nm
-over a serial link, it is possible to
-use a TCP connection instead by specifying the host, port and protocol as the
-device:
-.Pp
-.Dl set device ui-gate:6669/tcp
-.Pp
-Instead of opening a serial device,
-.Nm
-will open a TCP connection to the given machine on the given
-socket. It should be noted however that
-.Nm
-doesn't use the telnet protocol and will be unable to negotiate
-with a telnet server. You should set up a port for receiving this
-.Em PPP
-connection on the receiving machine (ui-gate). This is
-done by first updating
-.Pa /etc/services
-to name the service:
-.Pp
-.Dl ppp-in 6669/tcp # Incoming PPP connections over TCP
-.Pp
-and updating
-.Pa /etc/inetd.conf
-to tell
-.Xr inetd 8
-how to deal with incoming connections on that port:
-.Pp
-.Dl ppp-in stream tcp nowait root /usr/sbin/ppp ppp -direct ppp-in
-.Pp
-Don't forget to send a
-.Dv HUP
-signal to
-.Xr inetd 8
-after you've updated
-.Pa /etc/inetd.conf .
-Here, we use a label named
-.Dq ppp-in .
-The entry in
-.Pa /etc/ppp/ppp.conf
-on ui-gate (the receiver) should contain the following:
-.Bd -literal -offset indent
-ppp-in:
- set timeout 0
- set ifaddr 10.0.4.1 10.0.4.2
- add 10.0.1.0/24 10.0.4.2
-.Ed
-.Pp
-You may also want to enable PAP or CHAP for security. To enable PAP, add
-the following line:
-.Bd -literal -offset indent
- enable PAP
-.Ed
-.Pp
-You'll also need to create the following entry in
-.Pa /etc/ppp/ppp.secret :
-.Bd -literal -offset indent
-MyAuthName MyAuthPasswd
-.Ed
-.Pp
-If
-.Ar MyAuthPasswd
-is a
-.Pq Dq * ,
-the password is looked up in the
-.Xr passwd 5
-database.
-.Pp
-The entry in
-.Pa /etc/ppp/ppp.conf
-on awfulhak (the initiator) should contain the following:
-.Bd -literal -offset indent
-ui-gate:
- set escape 0xff
- set device ui-gate:ppp-in/tcp
- set dial
- set timeout 30
- set log Phase Chat Connect hdlc LCP IPCP CCP tun
- set ifaddr 10.0.4.2 10.0.4.1
- add 10.0.2.0/24 10.0.4.1
-.Ed
-.Pp
-Again, if you're enabling PAP, you'll also need:
-.Bd -literal -offset indent
- set authname MyAuthName
- set authkey MyAuthKey
-.Ed
-.Pp
-We're assigning the address of 10.0.4.1 to ui-gate, and the address
-10.0.4.2 to awfulhak.
-To open the connection, just type
-.Pp
-.Dl awfulhak # ppp -background ui-gate
-.Pp
-The result will be an additional "route" on awfulhak to the
-10.0.2.0/24 network via the TCP connection, and an additional
-"route" on ui-gate to the 10.0.1.0/24 network.
-The networks are effectively bridged - the underlying TCP
-connection may be across a public network (such as the
-Internet), and the
-.Em PPP
-traffic is conceptually encapsulated
-(although not packet by packet) inside the TCP stream between
-the two gateways.
-.Pp
-The major disadvantage of this mechanism is that there are two
-"guaranteed delivery" mechanisms in place - the underlying TCP
-stream and whatever protocol is used over the
-.Em PPP
-link - probably TCP again. If packets are lost, both levels will
-get in each others way trying to negotiate sending of the missing
-packet.
-.Pp
-To avoid this overhead, it is also possible to do all this using
-UDP instead of TCP as the transport by simply changing the protocol
-from "tcp" to "udp". When using UDP as a transport,
-.Nm
-will operate in synchronous mode. This is another gain as the incoming
-data does not have to be rearranged into packets.
-.Pp
-.Sh NETWORK ADDRESS TRANSLATION (PACKET ALIASING)
-The
-.Fl nat
-.Pq \&or Fl alias
-command line option enables network address translation (a.k.a. packet
-aliasing). This allows the
-.Nm
-host to act as a masquerading gateway for other computers over
-a local area network. Outgoing IP packets are aliased so that
-they appear to come from the
-.Nm
-host, and incoming packets are de-aliased so that they are routed
-to the correct machine on the local area network.
-Packet aliasing allows computers on private, unregistered
-subnets to have Internet access, although they are invisible
-from the outside world.
-In general, correct
-.Nm
-operation should first be verified with network address translation disabled.
-Then, the
-.Fl nat
-option should be switched on, and network applications (web browser,
-.Xr telnet 1 ,
-.Xr ftp 1 ,
-.Xr ping 8 ,
-.Xr traceroute 8 )
-should be checked on the
-.Nm
-host. Finally, the same or similar applications should be checked on other
-computers in the LAN.
-If network applications work correctly on the
-.Nm
-host, but not on other machines in the LAN, then the masquerading
-software is working properly, but the host is either not forwarding
-or possibly receiving IP packets. Check that IP forwarding is enabled in
-.Pa /etc/rc.conf
-and that other machines have designated the
-.Nm
-host as the gateway for the LAN.
-.Sh PACKET FILTERING
-This implementation supports packet filtering.
-There are four kinds of
-filters; the
-.Em in
-filter, the
-.Em out
-filter, the
-.Em dial
-filter and the
-.Em alive
-filter. Here are the basics:
-.Bl -bullet
-.It
-A filter definition has the following syntax:
-.Pp
-set filter
-.Ar name
-.Ar rule-no
-.Ar action
-.Op \&!
-.Oo
-.Op host
-.Ar src_addr Ns Op / Ns Ar width
-.Op Ar dst_addr Ns Op / Ns Ar width
-.Oc
-.Oo Ar proto Op src Ar cmp port
-.Op dst Ar cmp port
-.Op estab
-.Op syn
-.Op finrst
-.Oc
-.Bl -enum
-.It
-.Ar Name
-should be one of
-.Sq in ,
-.Sq out ,
-.Sq dial
-or
-.Sq alive .
-.It
-.Ar Rule-no
-is a numeric value between
-.Sq 0
-and
-.Sq 39
-specifying the rule number. Rules are specified in numeric order according to
-.Ar rule-no ,
-but only if rule
-.Sq 0
-is defined.
-.It
-.Ar Action
-may be specified as
-.Sq permit
-or
-.Sq deny ,
-in which case, if a given packet matches the rule, the associated action
-is taken immediately.
-.Ar Action
-can also be specified as
-.Sq clear
-to clear the action associated with that particular rule, or as a new
-rule number greater than the current rule. In this case, if a given
-packet matches the current rule, the packet will next be matched against
-the new rule number (rather than the next rule number).
-.Pp
-The
-.Ar action
-may optionally be followed with an exclamation mark
-.Pq Dq ! ,
-telling
-.Nm
-to reverse the sense of the following match.
-.It
-.Op Ar src_addr Ns Op / Ns Ar width
-and
-.Op Ar dst_addr Ns Op / Ns Ar width
-are the source and destination IP number specifications. If
-.Op / Ns Ar width
-is specified, it gives the number of relevant netmask bits,
-allowing the specification of an address range.
-.Pp
-Either
-.Ar src_addr
-or
-.Ar dst_addr
-may be given the values
-.Dv MYADDR
-or
-.Dv HISADDR
-(refer to the description of the
-.Dq bg
-command for a description of these values). When these values are used,
-the filters will be updated any time the values change. This is similar
-to the behaviour of the
-.Dq add
-command below.
-.It
-.Ar Proto
-must be one of
-.Sq icmp ,
-.Sq igmp ,
-.Sq ospf ,
-.Sq udp
-or
-.Sq tcp .
-.It
-.Ar Cmp
-is one of
-.Sq \&lt ,
-.Sq \&eq
-or
-.Sq \&gt ,
-meaning less-than, equal and greater-than respectively.
-.Ar Port
-can be specified as a numeric port or by service name from
-.Pa /etc/services .
-.It
-The
-.Sq estab ,
-.Sq syn ,
-and
-.Sq finrst
-flags are only allowed when
-.Ar proto
-is set to
-.Sq tcp ,
-and represent the TH_ACK, TH_SYN and TH_FIN or TH_RST TCP flags respectively.
-.El
-.Pp
-.It
-Each filter can hold up to 40 rules, starting from rule 0.
-The entire rule set is not effective until rule 0 is defined,
-ie. the default is to allow everything through.
-.It
-If no rule is matched to a packet, that packet will be discarded
-(blocked).
-.It
-Use
-.Dq set filter Ar name No -1
-to flush all rules.
-.El
-.Pp
-See
-.Pa /usr/share/examples/ppp/ppp.conf.sample .
-.Sh SETTING THE IDLE TIMER
-To check/set the idle timer, use the
-.Dq show bundle
-and
-.Dq set timeout
-commands:
-.Bd -literal -offset indent
-ppp ON awfulhak> set timeout 600
-.Ed
-.Pp
-The timeout period is measured in seconds, the default value for which
-is 180 seconds
-.Pq or 3 min .
-To disable the idle timer function, use the command
-.Bd -literal -offset indent
-ppp ON awfulhak> set timeout 0
-.Ed
-.Pp
-In
-.Fl ddial
-and
-.Fl dedicated
-modes, the idle timeout is ignored. In
-.Fl auto
-mode, when the idle timeout causes the
-.Em PPP
-session to be
-closed, the
-.Nm
-program itself remains running. Another trigger packet will cause it to
-attempt to re-establish the link.
-.Sh PREDICTOR-1 and DEFLATE COMPRESSION
-.Nm
-supports both Predictor type 1 and deflate compression.
-By default,
-.Nm
-will attempt to use (or be willing to accept) both compression protocols
-when the peer agrees
-.Pq or requests them .
-The deflate protocol is preferred by
-.Nm ppp .
-Refer to the
-.Dq disable
-and
-.Dq deny
-commands if you wish to disable this functionality.
-.Pp
-It is possible to use a different compression algorithm in each direction
-by using only one of
-.Dq disable deflate
-and
-.Dq deny deflate
-.Pq assuming that the peer supports both algorithms .
-.Pp
-By default, when negotiating DEFLATE,
-.Nm
-will use a window size of 15. Refer to the
-.Dq set deflate
-command if you wish to change this behaviour.
-.Pp
-A special algorithm called DEFLATE24 is also available, and is disabled
-and denied by default. This is exactly the same as DEFLATE except that
-it uses CCP ID 24 to negotiate. This allows
-.Nm
-to successfully negotiate DEFLATE with
-.Nm pppd
-version 2.3.*.
-.Sh CONTROLLING IP ADDRESS
-.Nm
-uses IPCP to negotiate IP addresses.
-Each side of the connection
-specifies the IP address that it's willing to use, and if the requested
-IP address is acceptable then
-.Nm
-returns ACK to the requester. Otherwise,
-.Nm
-returns NAK to suggest that the peer use a different IP address.
-When
-both sides of the connection agree to accept the received request (and
-send ACK), IPCP is set to the open state and a network level connection
-is established.
-To control this IPCP behaviour, this implementation has the
-.Dq set ifaddr
-command for defining the local and remote IP address:
-.Bd -literal -offset indent
-.No set ifaddr Oo Ar src_addr Ns
-.Op / Ns Ar \&nn
-.Oo Ar dst_addr Ns Op / Ns Ar \&nn
-.Oo Ar netmask
-.Op Ar trigger_addr
-.Oc
-.Oc
-.Oc
-.Ed
-.Pp
-where,
-.Sq src_addr
-is the IP address that the local side is willing to use,
-.Sq dst_addr
-is the IP address which the remote side should use and
-.Sq netmask
-is the netmask that should be used.
-.Sq Src_addr
-defaults to the current
-.Xr hostname 1 ,
-.Sq dst_addr
-defaults to 0.0.0.0, and
-.Sq netmask
-defaults to whatever mask is appropriate for
-.Sq src_addr .
-It is only possible to make
-.Sq netmask
-smaller than the default. The usual value is 255.255.255.255, as
-most kernels ignore the netmask of a POINTOPOINT interface.
-.Pp
-Some incorrect
-.Em PPP
-implementations require that the peer negotiates a specific IP
-address instead of
-.Sq src_addr .
-If this is the case,
-.Sq trigger_addr
-may be used to specify this IP number. This will not affect the
-routing table unless the other side agrees with this proposed number.
-.Bd -literal -offset indent
-set ifaddr 192.244.177.38 192.244.177.2 255.255.255.255 0.0.0.0
-.Ed
-.Pp
-The above specification means:
-.Pp
-.Bl -bullet -compact
-.It
-I will first suggest that my IP address should be 0.0.0.0, but I
-will only accept an address of 192.244.177.38.
-.It
-I strongly insist that the peer uses 192.244.177.2 as his own
-address and won't permit the use of any IP address but 192.244.177.2.
-When the peer requests another IP address, I will always suggest that
-it uses 192.244.177.2.
-.It
-The routing table entry will have a netmask of 0xffffffff.
-.El
-.Pp
-This is all fine when each side has a pre-determined IP address, however
-it is often the case that one side is acting as a server which controls
-all IP addresses and the other side should go along with it. In order
-to allow more flexible behaviour, the
-.Dq set ifaddr
-command allows the user to specify IP addresses more loosely:
-.Pp
-.Dl set ifaddr 192.244.177.38/24 192.244.177.2/20
-.Pp
-A number followed by a slash
-.Pq Dq /
-represents the number of bits significant in the IP address. The above
-example means:
-.Pp
-.Bl -bullet -compact
-.It
-I'd like to use 192.244.177.38 as my address if it is possible, but I'll
-also accept any IP address between 192.244.177.0 and 192.244.177.255.
-.It
-I'd like to make him use 192.244.177.2 as his own address, but I'll also
-permit him to use any IP address between 192.244.176.0 and
-192.244.191.255.
-.It
-As you may have already noticed, 192.244.177.2 is equivalent to saying
-192.244.177.2/32.
-.It
-As an exception, 0 is equivalent to 0.0.0.0/0, meaning that I have no
-preferred IP address and will obey the remote peers selection. When
-using zero, no routing table entries will be made until a connection
-is established.
-.It
-192.244.177.2/0 means that I'll accept/permit any IP address but I'll
-try to insist that 192.244.177.2 be used first.
-.El
-.Pp
-.Sh CONNECTING WITH YOUR INTERNET SERVICE PROVIDER
-The following steps should be taken when connecting to your ISP:
-.Bl -enum
-.It
-Describe your providers phone number(s) in the dial script using the
-.Dq set phone
-command. This command allows you to set multiple phone numbers for
-dialing and redialing separated by either a pipe
-.Pq Dq \&|
-or a colon
-.Pq Dq \&: :
-.Bd -literal -offset indent
-.No set phone Ar telno Ns Xo
-.Oo \&| Ns Ar backupnumber
-.Oc Ns ... Ns Oo : Ns Ar nextnumber
-.Oc Ns ...
-.Xc
-.Ed
-.Pp
-Numbers after the first in a pipe-separated list are only used if the
-previous number was used in a failed dial or login script. Numbers
-separated by a colon are used sequentially, irrespective of what happened
-as a result of using the previous number. For example:
-.Bd -literal -offset indent
-set phone "1234567|2345678:3456789|4567890"
-.Ed
-.Pp
-Here, the 1234567 number is attempted. If the dial or login script fails,
-the 2345678 number is used next time, but *only* if the dial or login script
-fails. On the dial after this, the 3456789 number is used. The 4567890
-number is only used if the dial or login script using the 3456789 fails. If
-the login script of the 2345678 number fails, the next number is still the
-3456789 number. As many pipes and colons can be used as are necessary
-(although a given site would usually prefer to use either the pipe or the
-colon, but not both). The next number redial timeout is used between all
-numbers. When the end of the list is reached, the normal redial period is
-used before starting at the beginning again.
-The selected phone number is substituted for the \\\\T string in the
-.Dq set dial
-command (see below).
-.It
-Set up your redial requirements using
-.Dq set redial .
-For example, if you have a bad telephone line or your provider is
-usually engaged (not so common these days), you may want to specify
-the following:
-.Bd -literal -offset indent
-set redial 10 4
-.Ed
-.Pp
-This says that up to 4 phone calls should be attempted with a pause of 10
-seconds before dialing the first number again.
-.It
-Describe your login procedure using the
-.Dq set dial
-and
-.Dq set login
-commands. The
-.Dq set dial
-command is used to talk to your modem and establish a link with your
-ISP, for example:
-.Bd -literal -offset indent
-set dial "ABORT BUSY ABORT NO\\\\sCARRIER TIMEOUT 4 \\"\\" \e
- ATZ OK-ATZ-OK ATDT\\\\T TIMEOUT 60 CONNECT"
-.Ed
-.Pp
-This modem "chat" string means:
-.Bl -bullet
-.It
-Abort if the string "BUSY" or "NO CARRIER" are received.
-.It
-Set the timeout to 4 seconds.
-.It
-Expect nothing.
-.It
-Send ATZ.
-.It
-Expect OK. If that's not received within the 4 second timeout, send ATZ
-and expect OK.
-.It
-Send ATDTxxxxxxx where xxxxxxx is the next number in the phone list from
-above.
-.It
-Set the timeout to 60.
-.It
-Wait for the CONNECT string.
-.El
-.Pp
-Once the connection is established, the login script is executed. This
-script is written in the same style as the dial script, but care should
-be taken to avoid having your password logged:
-.Bd -literal -offset indent
-set authkey MySecret
-set login "TIMEOUT 15 login:-\\\\r-login: awfulhak \e
- word: \\\\P ocol: PPP HELLO"
-.Ed
-.Pp
-This login "chat" string means:
-.Bl -bullet
-.It
-Set the timeout to 15 seconds.
-.It
-Expect "login:". If it's not received, send a carriage return and expect
-"login:" again.
-.It
-Send "awfulhak"
-.It
-Expect "word:" (the tail end of a "Password:" prompt).
-.It
-Send whatever our current
-.Ar authkey
-value is set to.
-.It
-Expect "ocol:" (the tail end of a "Protocol:" prompt).
-.It
-Send "PPP".
-.It
-Expect "HELLO".
-.El
-.Pp
-The
-.Dq set authkey
-command is logged specially. When
-.Ar command
-or
-.Ar chat
-logging is enabled, the actual password is not logged;
-.Sq ******** Ns
-is logged instead.
-.Pp
-Login scripts vary greatly between ISPs. If you're setting one up
-for the first time,
-.Em ENABLE CHAT LOGGING
-so that you can see if your script is behaving as you expect.
-.It
-Use
-.Dq set device
-and
-.Dq set speed
-to specify your serial line and speed, for example:
-.Bd -literal -offset indent
-set device /dev/cuaa0
-set speed 115200
-.Ed
-.Pp
-Cuaa0 is the first serial port on FreeBSD. If you're running
-.Nm
-on OpenBSD, cua00 is the first. A speed of 115200 should be specified
-if you have a modem capable of bit rates of 28800 or more. In general,
-the serial speed should be about four times the modem speed.
-.It
-Use the
-.Dq set ifaddr
-command to define the IP address.
-.Bl -bullet
-.It
-If you know what IP address your provider uses, then use it as the remote
-address (dst_addr), otherwise choose something like 10.0.0.2/0 (see below).
-.It
-If your provider has assigned a particular IP address to you, then use
-it as your address (src_addr).
-.It
-If your provider assigns your address dynamically, choose a suitably
-unobtrusive and unspecific IP number as your address. 10.0.0.1/0 would
-be appropriate. The bit after the / specifies how many bits of the
-address you consider to be important, so if you wanted to insist on
-something in the class C network 1.2.3.0, you could specify 1.2.3.1/24.
-.It
-If you find that your ISP accepts the first IP number that you suggest,
-specify third and forth arguments of
-.Dq 0.0.0.0 .
-This will force your ISP to assign a number. (The third argument will
-be ignored as it is less restrictive than the default mask for your
-.Sq src_addr .
-.El
-.Pp
-An example for a connection where you don't know your IP number or your
-ISPs IP number would be:
-.Bd -literal -offset indent
-set ifaddr 10.0.0.1/0 10.0.0.2/0 0.0.0.0 0.0.0.0
-.Ed
-.Pp
-.It
-In most cases, your ISP will also be your default router. If this is
-the case, add the line
-.Bd -literal -offset indent
-add default HISADDR
-.Ed
-.Pp
-to
-.Pa /etc/ppp/ppp.conf .
-.Pp
-This tells
-.Nm
-to add a default route to whatever the peer address is
-.Pq 10.0.0.2 in this example .
-This route is
-.Sq sticky ,
-meaning that should the value of
-.Dv HISADDR
-change, the route will be updated accordingly.
-.Pp
-Previous versions of
-.Nm
-required a similar entry in the
-.Pa /etc/ppp/ppp.linkup
-file. Since the advent of
-.Sq sticky routes ,
-this is no longer required.
-.It
-If your provider requests that you use PAP/CHAP authentication methods, add
-the next lines to your
-.Pa /etc/ppp/ppp.conf
-file:
-.Bd -literal -offset indent
-set authname MyName
-set authkey MyPassword
-.Ed
-.Pp
-Both are accepted by default, so
-.Nm
-will provide whatever your ISP requires.
-.Pp
-It should be noted that a login script is rarely (if ever) required
-when PAP or CHAP are in use.
-.It
-Ask your ISP to authenticate your nameserver address(es) with the line
-.Bd -literal -offset indent
-enable dns
-.Ed
-Do
-.Em NOT
-do this if you are running an local DNS, as
-.Nm
-will simply circumvent its use by entering some nameserver lines in
-.Pa /etc/resolv.conf .
-.El
-.Pp
-Please refer to
-.Pa /usr/share/examples/ppp/ppp.conf.sample
-and
-.Pa /usr/share/examples/ppp/ppp.linkup.sample
-for some real examples. The pmdemand label should be appropriate for most
-ISPs.
-.Sh LOGGING FACILITY
-.Nm
-is able to generate the following log info either via
-.Xr syslog 3
-or directly to the screen:
-.Pp
-.Bl -tag -width XXXXXXXXX -offset XXX -compact
-.It Li Async
-Dump async level packet in hex.
-.It Li CBCP
-Generate CBCP (CallBack Control Protocol) logs.
-.It Li CCP
-Generate a CCP packet trace.
-.It Li Chat
-Generate
-.Sq dial ,
-.Sq login ,
-.Sq logout
-and
-.Sq hangup
-chat script trace logs.
-.It Li Command
-Log commands executed either from the command line or any of the configuration
-files.
-.It Li Connect
-Log Chat lines containing the string "CONNECT".
-.It Li Debug
-Log debug information.
-.It Li HDLC
-Dump HDLC packet in hex.
-.It Li ID0
-Log all function calls specifically made as user id 0.
-.It Li IPCP
-Generate an IPCP packet trace.
-.It Li LCP
-Generate an LCP packet trace.
-.It Li LQM
-Generate LQR reports.
-.It Li Phase
-Phase transition log output.
-.It Li Physical
-Dump physical level packet in hex.
-.It Li Sync
-Dump sync level packet in hex.
-.It Li TCP/IP
-Dump all TCP/IP packets.
-.It Li Timer
-Log timer manipulation.
-.It Li TUN
-Include the tun device on each log line.
-.It Li Warning
-Output to the terminal device. If there is currently no terminal,
-output is sent to the log file using syslogs
-.Dv LOG_WARNING .
-.It Li Error
-Output to both the terminal device
-and the log file using syslogs
-.Dv LOG_ERROR .
-.It Li Alert
-Output to the log file using
-.Dv LOG_ALERT .
-.El
-.Pp
-The
-.Dq set log
-command allows you to set the logging output level. Multiple levels
-can be specified on a single command line. The default is equivalent to
-.Dq set log Phase .
-.Pp
-It is also possible to log directly to the screen. The syntax is
-the same except that the word
-.Dq local
-should immediately follow
-.Dq set log .
-The default is
-.Dq set log local
-(ie. only the un-maskable warning, error and alert output).
-.Pp
-If The first argument to
-.Dq set log Op local
-begins with a
-.Sq +
-or a
-.Sq -
-character, the current log levels are
-not cleared, for example:
-.Bd -literal -offset indent
-PPP ON awfulhak> set log phase
-PPP ON awfulhak> show log
-Log: Phase Warning Error Alert
-Local: Warning Error Alert
-PPP ON awfulhak> set log +tcp/ip -warning
-PPP ON awfulhak> set log local +command
-PPP ON awfulhak> show log
-Log: Phase TCP/IP Warning Error Alert
-Local: Command Warning Error Alert
-.Ed
-.Pp
-Log messages of level Warning, Error and Alert are not controllable
-using
-.Dq set log Op local .
-.Pp
-The
-.Ar Warning
-level is special in that it will not be logged if it can be displayed
-locally.
-.Sh SIGNAL HANDLING
-.Nm
-deals with the following signals:
-.Bl -tag -width XX
-.It INT
-Receipt of this signal causes the termination of the current connection
-(if any). This will cause
-.Nm
-to exit unless it is in
-.Fl auto
-or
-.Fl ddial
-mode.
-.It HUP, TERM & QUIT
-These signals tell
-.Nm
-to exit.
-.It USR2
-This signal, tells
-.Nm
-to close any existing server socket, dropping all existing diagnostic
-connections.
-.El
-.Pp
-.Sh MULTI-LINK PPP
-If you wish to use more than one physical link to connect to a
-.Em PPP
-peer, that peer must also understand the
-.Em MULTI-LINK PPP
-protocol. Refer to RFC 1990 for specification details.
-.Pp
-The peer is identified using a combination of his
-.Dq endpoint discriminator
-and his
-.Dq authentication id .
-Either or both of these may be specified. It is recommended that
-at least one is specified, otherwise there is no way of ensuring that
-all links are actually connected to the same peer program, and some
-confusing lock-ups may result. Locally, these identification variables
-are specified using the
-.Dq set enddisc
-and
-.Dq set authname
-commands. The
-.Sq authname
-.Pq and Sq authkey
-must be agreed in advance with the peer.
-.Pp
-Multi-link capabilities are enabled using the
-.Dq set mrru
-command (set maximum reconstructed receive unit). Once multi-link
-is enabled,
-.Nm
-will attempt to negotiate a multi-link connection with the peer.
-.Pp
-By default, only one
-.Sq link
-is available
-.Pq called Sq deflink .
-To create more links, the
-.Dq clone
-command is used. This command will clone existing links, where all
-characteristics are the same except:
-.Bl -enum
-.It
-The new link has its own name as specified on the
-.Dq clone
-command line.
-.It
-The new link is an
-.Sq interactive
-link. It's mode may subsequently be changed using the
-.Dq set mode
-command.
-.It
-The new link is in a
-.Sq closed
-state.
-.El
-.Pp
-A summary of all available links can be seen using the
-.Dq show links
-command.
-.Pp
-Once a new link has been created, command usage varies. All link
-specific commands must be prefixed with the
-.Dq link Ar name
-command, specifying on which link the command is to be applied. When
-only a single link is available,
-.Nm
-is smart enough not to require the
-.Dq link Ar name
-prefix.
-.Pp
-Some commands can still be used without specifying a link - resulting
-in an operation at the
-.Sq bundle
-level. For example, once two or more links are available, the command
-.Dq show ccp
-will show CCP configuration and statistics at the multi-link level, and
-.Dq link deflink show ccp
-will show the same information at the
-.Dq deflink
-link level.
-.Pp
-Armed with this information, the following configuration might be used:
-.Pp
-.Bd -literal -offset indent
-mp:
- set timeout 0
- set log phase chat
- set device /dev/cuaa0 /dev/cuaa1 /dev/cuaa2
- set phone "123456789"
- set dial "ABORT BUSY ABORT NO\\sCARRIER TIMEOUT 5 \\"\\" ATZ \e
- OK-AT-OK \\\\dATDT\\\\T TIMEOUT 45 CONNECT"
- set login
- set ifaddr 10.0.0.1/0 10.0.0.2/0
- set authname ppp
- set authkey ppppassword
-
- set mrru 1500
- clone 1,2,3
- link deflink remove
-.Ed
-.Pp
-Note how all cloning is done at the end of the configuration. Usually,
-the link will be configured first, then cloned. If you wish all links
-to be up all the time, you can add the following line to the end of your
-configuration.
-.Pp
-.Bd -literal -offset indent
- link 1,2,3 set mode ddial
-.Ed
-.Pp
-If you want the links to dial on demand, this command could be used:
-.Pp
-.Bd -literal -offset indent
- link * set mode auto
-.Ed
-.Pp
-Links may be tied to specific names by removing the
-.Dq set device
-line above, and specifying the following after the
-.Dq clone
-command:
-.Pp
-.Bd -literal -offset indent
- link 1 set device /dev/cuaa0
- link 2 set device /dev/cuaa1
- link 3 set device /dev/cuaa2
-.Ed
-.Pp
-Use the
-.Dq help
-command to see which commands require context (using the
-.Dq link
-command), which have optional
-context and which should not have any context.
-.Pp
-When
-.Nm
-has negotiated
-.Em MULTI-LINK
-mode with the peer, it creates a local domain socket in the
-.Pa /var/run
-directory. This socket is used to pass link information (including
-the actual link file descriptor) between different
-.Nm
-invocations. This facilitates
-.Nm ppp Ns No s
-ability to be run from a
-.Xr getty 8
-or directly from
-.Pa /etc/gettydefs
-(using the
-.Sq pp=
-capability), without needing to have initial control of the serial
-line. Once
-.Nm
-negotiates multi-link mode, it will pass its open link to any
-already running process. If there is no already running process,
-.Nm
-will act as the master, creating the socket and listening for new
-connections.
-.Sh PPP COMMAND LIST
-This section lists the available commands and their effect. They are
-usable either from an interactive
-.Nm
-session, from a configuration file or from a
-.Xr pppctl 8
-or
-.Xr telnet 1
-session.
-.Bl -tag -width XX
-.It accept|deny|enable|disable Ar option....
-These directives tell
-.Nm
-how to negotiate the initial connection with the peer. Each
-.Dq option
-has a default of either accept or deny and enable or disable.
-.Dq Accept
-means that the option will be ACK'd if the peer asks for it.
-.Dq Deny
-means that the option will be NAK'd if the peer asks for it.
-.Dq Enable
-means that the option will be requested by us.
-.Dq Disable
-means that the option will not be requested by us.
-.Pp
-.Dq Option
-may be one of the following:
-.Bl -tag -width XX
-.It acfcomp
-Default: Enabled and Accepted. ACFComp stands for Address and Control
-Field Compression. Non LCP packets will usually have an address
-field of 0xff (the All-Stations address) and a control field of
-0x03 (the Unnumbered Information command). If this option is
-negotiated, these two bytes are simply not sent, thus minimising
-traffic.
-.Pp
-See
-.Pa rfc1662
-for details.
-.It chap Ns Op \&05
-Default: Disabled and Accepted. CHAP stands for Challenge Handshake
-Authentication Protocol. Only one of CHAP and PAP (below) may be
-negotiated. With CHAP, the authenticator sends a "challenge" message
-to its peer. The peer uses a one-way hash function to encrypt the
-challenge and sends the result back. The authenticator does the same,
-and compares the results. The advantage of this mechanism is that no
-passwords are sent across the connection.
-A challenge is made when the connection is first made. Subsequent
-challenges may occur. If you want to have your peer authenticate
-itself, you must
-.Dq enable chap .
-in
-.Pa /etc/ppp/ppp.conf ,
-and have an entry in
-.Pa /etc/ppp/ppp.secret
-for the peer.
-.Pp
-When using CHAP as the client, you need only specify
-.Dq AuthName
-and
-.Dq AuthKey
-in
-.Pa /etc/ppp/ppp.conf .
-CHAP is accepted by default.
-Some
-.Em PPP
-implementations use "MS-CHAP" rather than MD5 when encrypting the
-challenge. MS-CHAP is a combination of MD4 and DES. If
-.Nm
-was built on a machine with DES libraries available, it will respond
-to MS-CHAP authentication requests, but will never request them.
-.It deflate
-Default: Enabled and Accepted. This option decides if deflate
-compression will be used by the Compression Control Protocol (CCP).
-This is the same algorithm as used by the
-.Xr gzip 1
-program.
-Note: There is a problem negotiating
-.Ar deflate
-capabilities with
-.Xr pppd 8
-- a
-.Em PPP
-implementation available under many operating systems.
-.Nm pppd
-(version 2.3.1) incorrectly attempts to negotiate
-.Ar deflate
-compression using type
-.Em 24
-as the CCP configuration type rather than type
-.Em 26
-as specified in
-.Pa rfc1979 .
-Type
-.Ar 24
-is actually specified as
-.Dq PPP Magna-link Variable Resource Compression
-in
-.Pa rfc1975 Ns No !
-.Nm
-is capable of negotiating with
-.Nm pppd ,
-but only if
-.Dq deflate24
-is
-.Ar enable Ns No d
-and
-.Ar accept Ns No ed .
-.It deflate24
-Default: Disabled and Denied. This is a variance of the
-.Ar deflate
-option, allowing negotiation with the
-.Xr pppd 8
-program. Refer to the
-.Ar deflate
-section above for details. It is disabled by default as it violates
-.Pa rfc1975 .
-.It dns
-Default: Disabled and Denied. This option allows DNS negotiation.
-.Pp
-If
-.Dq enable Ns No d,
-.Nm
-will request that the peer confirms the entries in
-.Pa /etc/resolv.conf .
-If the peer NAKs our request (suggesting new IP numbers),
-.Pa /etc/resolv.conf
-is updated and another request is sent to confirm the new entries.
-.Pp
-If
-.Dq accept Ns No ed,
-.Nm
-will answer any DNS queries requested by the peer rather than rejecting
-them. The answer is taken from
-.Pa /etc/resolv.conf
-unless the
-.Dq set dns
-command is used as an override.
-.It enddisc
-Default: Enabled and Accepted. This option allows control over whether we
-negotiate an endpoint discriminator. We only send our discriminator if
-.Dq set enddisc
-is used and
-.Ar enddisc
-is enabled. We reject the peers discriminator if
-.Ar enddisc
-is denied.
-.It LANMan|chap80lm
-Default: Disabled and Accepted. The use of this authentication protocol
-is discouraged as it partially violates the authentication protocol by
-implementing two different mechanisms (LANMan & NT) under the guise of
-a single CHAP type (0x80).
-.Dq LANMan
-uses a simple DES encryption mechanism and is the least secure of the
-CHAP alternatives (although is still more secure than PAP).
-.Pp
-Refer to the
-.Dq MSChap
-description below for more details.
-.It lqr
-Default: Disabled and Accepted. This option decides if Link Quality
-Requests will be sent or accepted. LQR is a protocol that allows
-.Nm
-to determine that the link is down without relying on the modems
-carrier detect. When LQR is enabled,
-.Nm
-sends the
-.Em QUALPROTO
-option (see
-.Dq set lqrperiod
-below) as part of the LCP request. If the peer agrees, both sides will
-exchange LQR packets at the agreed frequency, allowing detailed link
-quality monitoring by enabling LQM logging. If the peer doesn't agree,
-ppp will send ECHO LQR requests instead. These packets pass no
-information of interest, but they
-.Em MUST
-be replied to by the peer.
-.Pp
-Whether using LQR or ECHO LQR,
-.Nm
-will abruptly drop the connection if 5 unacknowledged packets have been
-sent rather than sending a 6th. A message is logged at the
-.Em PHASE
-level, and any appropriate
-.Dq reconnect
-values are honoured as if the peer were responsible for dropping the
-connection.
-.It MSChap|chap80nt
-Default: Disabled and Accepted. The use of this authentication protocol
-is discouraged as it partially violates the authentication protocol by
-implementing two different mechanisms (LANMan & NT) under the guise of
-a single CHAP type (0x80). It is very similar to standard CHAP (type 0x05)
-except that it issues challenges of a fixed 8 bytes in length and uses a
-combination of MD4 and DES to encrypt the challenge rather than using the
-standard MD5 mechanism. CHAP type 0x80 for LANMan is also supported - see
-.Dq enable LANMan
-for details.
-.Pp
-Because both
-.Dq LANMan
-and
-.Dq NT
-use CHAP type 0x80, when acting as authenticator with both
-.Dq enable Ns No d ,
-.Nm
-will rechallenge the peer up to three times if it responds using the wrong
-one of the two protocols. This gives the peer a chance to attempt using
-both protocols.
-.Pp
-Conversely, when
-.Nm
-acts as the authenticatee with both protocols
-.Dq accept Ns No ed ,
-the protocols are used alternately in response to challenges.
-.Pp
-Note: If only LANMan is enabled,
-.Xr pppd 8
-(version 2.3.5) misbehaves when acting as authenticatee. It provides both
-the NT and the LANMan answers, but also suggests that only the NT answer
-should be used.
-.It pap
-Default: Disabled and Accepted. PAP stands for Password Authentication
-Protocol. Only one of PAP and CHAP (above) may be negotiated. With
-PAP, the ID and Password are sent repeatedly to the peer until
-authentication is acknowledged or the connection is terminated. This
-is a rather poor security mechanism. It is only performed when the
-connection is first established.
-If you want to have your peer authenticate itself, you must
-.Dq enable pap .
-in
-.Pa /etc/ppp/ppp.conf ,
-and have an entry in
-.Pa /etc/ppp/ppp.secret
-for the peer (although see the
-.Dq passwdauth
-and
-.Dq set radius
-options below).
-.Pp
-When using PAP as the client, you need only specify
-.Dq AuthName
-and
-.Dq AuthKey
-in
-.Pa /etc/ppp/ppp.conf .
-PAP is accepted by default.
-.It pred1
-Default: Enabled and Accepted. This option decides if Predictor 1
-compression will be used by the Compression Control Protocol (CCP).
-.It protocomp
-Default: Enabled and Accepted. This option is used to negotiate
-PFC (Protocol Field Compression), a mechanism where the protocol
-field number is reduced to one octet rather than two.
-.It shortseq
-Default: Enabled and Accepted. This option determines if
-.Nm
-will request and accept requests for short
-.Pq 12 bit
-sequence numbers when negotiating multi-link mode. This is only
-applicable if our MRRU is set (thus enabling multi-link).
-.It vjcomp
-Default: Enabled and Accepted. This option determines if Van Jacobson
-header compression will be used.
-.El
-.Pp
-The following options are not actually negotiated with the peer.
-Therefore, accepting or denying them makes no sense.
-.Bl -tag -width XX
-.It idcheck
-Default: Enabled. When
-.Nm
-exchanges low-level LCP, CCP and IPCP configuration traffic, the
-.Em Identifier
-field of any replies is expected to be the same as that of the request.
-By default,
-.Nm
-drops any reply packets that do not contain the expected identifier
-field, reporting the fact at the respective log level. If
-.Ar idcheck
-is disabled,
-.Nm
-will ignore the identifier field.
-.It keep-session
-Default: Disabled. When
-.Nm
-runs as a Multi-link server, a different
-.Nm
-instance initially receives each connection. After determining that
-the link belongs to an already existing bundle (controlled by another
-.Nm
-invocation),
-.Nm
-will transfer the link to that process.
-.Pp
-If the link is a tty device or if this option is enabled,
-.Nm
-will not exit, but will change its process name to
-.Dq session owner
-and wait for the controlling
-.Nm
-to finish with the link and deliver a signal back to the idle process.
-This prevents the confusion that results from
-.Nm ppp Ns No 's
-parent considering the link resource available again.
-.Pp
-For tty devices that have entries in
-.Pa /etc/ttys ,
-this is necessary to prevent another
-.Xr getty 8
-from being started, and for program links such as
-.Xr sshd 8 ,
-it prevents
-.Xr sshd 8
-from exiting due to the death of its child. As
-.Nm
-cannot determine its parents requirements (except for the tty case), this
-option must be enabled manually depending on the circumstances.
-.It loopback
-Default: Enabled. When
-.Ar loopback
-is enabled,
-.Nm
-will automatically loop back packets being sent
-out with a destination address equal to that of the
-.Em PPP
-interface. If disabled,
-.Nm
-will send the packet, probably resulting in an ICMP redirect from
-the other end. It is convenient to have this option enabled when
-the interface is also the default route as it avoids the necessity
-of a loopback route.
-.It passwdauth
-Default: Disabled. Enabling this option will tell the PAP authentication
-code to use the password database (see
-.Xr passwd 5 )
-to authenticate the caller if they cannot be found in the
-.Pa /etc/ppp/ppp.secret
-file.
-.Pa /etc/ppp/ppp.secret
-is always checked first. If you wish to use passwords from
-.Xr passwd 5 ,
-but also to specify an IP number or label for a given client, use
-.Dq \&*
-as the client password in
-.Pa /etc/ppp/ppp.secret .
-.It proxy
-Default: Disabled. Enabling this option will tell
-.Nm
-to proxy ARP for the peer. This means that
-.Nm
-will make an entry in the ARP table using
-.Dv HISADDR
-and the
-.Dv MAC
-address of the local network in which
-.Dv HISADDR
-appears. The proxy entry cannot be made unless
-.Dv HISADDR
-is an address from a LAN.
-.It proxyall
-Default: Disabled. Enabling this will tell
-.Nm
-to add proxy arp entries for every IP address in all class C or
-smaller subnets routed via the tun interface.
-.Pp
-Proxy arp entries are only made for sticky routes that are added
-using the
-.Dq add
-command. No proxy arp entries are made for the interface address itself
-(as created by the
-.Dq set ifaddr
-command).
-.It sroutes
-Default: Enabled. When the
-.Dq add
-command is used with the
-.Dv HISADDR
-or
-.Dv MYADDR
-values, entries are stored in the
-.Sq stick route
-list. Each time
-.Dv HISADDR
-or
-.Dv MYADDR
-change, this list is re-applied to the routing table.
-.Pp
-Disabling this option will prevent the re-application of sticky routes,
-although the
-.Sq stick route
-list will still be maintained.
-.It throughput
-Default: Enabled. This option tells
-.Nm
-to gather throughput statistics. Input and output is sampled over
-a rolling 5 second window, and current, best and total figures are
-retained. This data is output when the relevant
-.Em PPP
-layer shuts down, and is also available using the
-.Dq show
-command. Throughput statistics are available at the
-.Dq IPCP
-and
-.Dq physical
-levels.
-.It utmp
-Default: Enabled. Normally, when a user is authenticated using PAP or
-CHAP, and when
-.Nm
-is running in
-.Fl direct
-mode, an entry is made in the utmp and wtmp files for that user. Disabling
-this option will tell
-.Nm
-not to make any utmp or wtmp entries. This is usually only necessary if
-you require the user to both login and authenticate themselves.
-.It iface-alias
-Default: Enabled if
-.Fl nat
-is specified. This option simply tells
-.Nm
-to add new interface addresses to the interface rather than replacing them.
-The option can only be enabled if network address translation is enabled
-.Pq Dq nat enable yes .
-.Pp
-With this option enabled,
-.Nm
-will pass traffic for old interface addresses through the NAT engine
-.Pq see Xr libalias 3 ,
-resulting in the ability (in
-.Fl auto
-mode) to properly connect the process that caused the PPP link to
-come up in the first place.
-.Pp
-Disabling NAT with
-.Dq nat enable no
-will also disable
-.Sq iface-alias .
-.El
-.Pp
-.It add Ns Xo
-.Op \&!
-.Ar dest Ns Op / Ns Ar nn
-.Op Ar mask
-.Op Ar gateway
-.Xc
-.Ar Dest
-is the destination IP address. The netmask is specified either as a
-number of bits with
-.Ar /nn
-or as an IP number using
-.Ar mask .
-.Ar 0 0
-or simply
-.Ar 0
-with no mask refers to the default route. It is also possible to use the
-literal name
-.Sq default
-instead of
-.Ar 0 .
-.Ar Gateway
-is the next hop gateway to get to the given
-.Ar dest
-machine/network. Refer to the
-.Xr route 8
-command for further details.
-.Pp
-It is possible to use the symbolic names
-.Sq MYADDR
-or
-.Sq HISADDR
-as the destination, and
-.Sq HISADDR
-as the
-.Ar gateway .
-.Sq MYADDR
-is replaced with the interface address and
-.Sq HISADDR
-is replaced with the interface destination (peer) address.
-.Pp
-If the
-.Ar add!
-command is used
-.Pq note the trailing Dq \&! ,
-then if the route already exists, it will be updated as with the
-.Sq route change
-command (see
-.Xr route 8
-for further details).
-.Pp
-Routes that contain the
-.Dq HISADDR
-or
-.Dq MYADDR
-constants are considered
-.Sq sticky .
-They are stored in a list (use
-.Dq show ipcp
-to see the list), and each time the value of
-.Dv HISADDR
-or
-.Dv MYADDR
-changes, the appropriate routing table entries are updated. This facility
-may be disabled using
-.Dq disable sroutes .
-.It allow Ar command Op Ar args
-This command controls access to
-.Nm
-and its configuration files. It is possible to allow user-level access,
-depending on the configuration file label and on the mode that
-.Nm
-is being run in. For example, you may wish to configure
-.Nm
-so that only user
-.Sq fred
-may access label
-.Sq fredlabel
-in
-.Fl background
-mode.
-.Pp
-User id 0 is immune to these commands.
-.Bl -tag -width XX
-.It allow user Ns Xo
-.Op s
-.Ar logname Ns No ...
-.Xc
-By default, only user id 0 is allowed access to
-.Nm ppp .
-If this command is used, all of the listed users are allowed access to
-the section in which the
-.Dq allow users
-command is found. The
-.Sq default
-section is always checked first (even though it is only ever automatically
-loaded at startup). Each successive
-.Dq allow users
-command overrides the previous one, so it's possible to allow users access
-to everything except a given label by specifying default users in the
-.Sq default
-section, and then specifying a new user list for that label.
-.Pp
-If user
-.Sq *
-is specified, access is allowed to all users.
-.It allow mode Ns Xo
-.Op s
-.Ar mode Ns No ...
-.Xc
-By default, access using any
-.Nm
-mode is possible. If this command is used, it restricts the access
-.Ar modes
-allowed to load the label under which this command is specified.
-Again, as with the
-.Dq allow users
-command, each
-.Dq allow modes
-command overrides any previous settings, and the
-.Sq default
-section is always checked first.
-.Pp
-Possible modes are:
-.Sq interactive ,
-.Sq auto ,
-.Sq direct ,
-.Sq dedicated ,
-.Sq ddial ,
-.Sq background
-and
-.Sq * .
-.Pp
-When running in multi-link mode, a section can be loaded if it allows
-.Em any
-of the currently existing line modes.
-.El
-.Pp
-.It nat Ar command Op Ar args
-This command allows the control of the network address translation (also
-known as masquerading or IP aliasing) facilities that are built into
-.Nm ppp .
-NAT is done on the external interface only, and is unlikely to make sense
-if used with the
-.Fl direct
-flag.
-.Pp
-For backwards compatibility, the word
-.Dq alias
-may be used in place of
-.Dq nat .
-If nat is enabled on your system (it may be omitted at compile time),
-the following commands are possible:
-.Bl -tag -width XX
-.It nat enable yes|no
-This command either switches network address translation on or turns it off.
-The
-.Fl nat
-command line flag is synonymous with
-.Dq nat enable yes .
-.It nat addr Op Ar addr_local addr_alias
-This command allows data for
-.Ar addr_alias
-to be redirected to
-.Ar addr_local .
-It is useful if you own a small number of real IP numbers that
-you wish to map to specific machines behind your gateway.
-.It nat deny_incoming yes|no
-If set to yes, this command will refuse all incoming connections
-by dropping the packets in much the same way as a firewall would.
-.It nat help|?
-This command gives a summary of available nat commands.
-.It nat log yes|no
-This option causes various NAT statistics and information to
-be logged to the file
-.Pa /var/log/alias.log .
-This file name is likely to change in the near future.
-.It nat port Ar proto Ar targetIP Ns Xo
-.No : Ns Ar targetPort Ns
-.Oo
-.No - Ns Ar targetPort
-.Oc Ar aliasPort Ns
-.Oo
-.No - Ns Ar aliasPort
-.Oc Oo Ar remoteIP : Ns
-.Ar remotePort Ns
-.Oo
-.No - Ns Ar remotePort
-.Oc Oc
-.Xc
-This command causes incoming
-.Ar proto
-connections to
-.Ar aliasPort
-to be redirected to
-.Ar targetPort
-on
-.Ar targetIP .
-.Ar proto
-is either
-.Dq tcp
-or
-.Dq udp .
-.Pp
-A range of port numbers may be specified as shown above. The ranges
-must be of the same size.
-.Pp
-If
-.Ar remoteIP
-is specified, only data coming from that IP number is redirected.
-.Ar remotePort
-must either be
-.Dq 0
-.Pq indicating any source port
-or a range of ports the same size as the other ranges.
-.Pp
-This option is useful if you wish to run things like Internet phone on
-machines behind your gateway, but is limited in that connections to only
-one interior machine per source machine and target port are possible.
-.It nat pptp Op Ar addr
-This tells
-.Nm
-to translate any
-.Em G Ns No eneral
-.Em R Ns No outing
-.Em E Ns No encapsulated
-.Pq Dv IPPROTO_GRE
-packets using
-.Ar addr
-rather than the local interface address. This allows the uses of the
-.Em P Ns No oint
-to
-.Em P Ns No oint
-.Em T Ns No unneling
-.Em P Ns No rotocol
-on a machine on the internal network.
-.Pp
-If
-.Ar addr
-is not specified,
-.Dv PPTP
-address translation is disabled.
-.It "nat proxy cmd" Ar arg Ns No ...
-This command tells
-.Nm
-to proxy certain connections, redirecting them to a given server. Refer
-to the description of
-.Fn PacketAliasProxyRule
-in
-.Xr libalias 3
-for details of the available commands.
-.It nat same_ports yes|no
-When enabled, this command will tell the network address translation engine to
- attempt to avoid changing the port number on outgoing packets. This is useful
-if you want to support protocols such as RPC and LPD which require
-connections to come from a well known port.
-.It nat use_sockets yes|no
-When enabled, this option tells the network address translation engine to
-create a socket so that it can guarantee a correct incoming ftp data or
-IRC connection.
-.It nat unregistered_only yes|no
-Only alter outgoing packets with an unregistered source ad-
-dress. According to RFC 1918, unregistered source addresses
-are 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16.
-.El
-.Pp
-These commands are also discussed in the file
-.Pa README.alias
-which comes with the source distribution.
-.Pp
-.It Op \&! Ns Xo
-.No bg Ar command
-.Xc
-The given
-.Ar command
-is executed in the background with the following words replaced:
-.Bl -tag -width PEER_ENDDISC
-.It Li AUTHNAME
-This is replaced with the local
-.Ar authname
-value. See the
-.Dq set authname
-command below.
-.It Li ENDDISC
-This is replaced with the local endpoint discriminator value. See the
-.Dq set enddisc
-command below.
-.It Li HISADDR
-This is replaced with the peers IP number.
-.It Li INTERFACE
-This is replaced with the name of the interface that's in use.
-.It Li LABEL
-This is replaced with the last label name used. A label may be specified
-on the
-.Nm
-command line, via the
-.Dq load
-or
-.Dq dial
-commands and in the
-.Pa ppp.secret
-file.
-.It Li MYADDR
-This is replaced with the IP number assigned to the local interface.
-.It Li PEER_ENDDISC
-This is replaced with the value of the peers endpoint discriminator.
-.It Li PROCESSID
-This is replaced with the current process id.
-.It Li USER
-This is replaced with the username that has been authenticated with PAP or
-CHAP. Normally, this variable is assigned only in -direct mode. This value
-is available irrespective of whether utmp logging is enabled.
-.El
-.Pp
-These substitutions are also done by the
-.Dq set proctitle
-command.
-.Pp
-If you wish to pause
-.Nm
-while the command executes, use the
-.Dq shell
-command instead.
-.It clear physical|ipcp Op current|overall|peak...
-Clear the specified throughput values at either the
-.Dq physical
-or
-.Dq ipcp
-level. If
-.Dq physical
-is specified, context must be given (see the
-.Dq link
-command below). If no second argument is given, all values are
-cleared.
-.It clone Ar name Ns Xo
-.Op \&, Ns Ar name Ns
-.No ...
-.Xc
-Clone the specified link, creating one or more new links according to the
-.Ar name
-argument(s). This command must be used from the
-.Dq link
-command below unless you've only got a single link (in which case that
-link becomes the default). Links may be removed using the
-.Dq remove
-command below.
-.Pp
-The default link name is
-.Dq deflink .
-.It close Op lcp|ccp Ns Op \&!
-If no arguments are given, the relevant protocol layers will be brought
-down and the link will be closed. If
-.Dq lcp
-is specified, the LCP layer is brought down, but
-.Nm
-will not bring the link offline. It is subsequently possible to use
-.Dq term
-.Pq see below
-to talk to the peer machine if, for example, something like
-.Dq slirp
-is being used. If
-.Dq ccp
-is specified, only the relevant compression layer is closed. If the
-.Dq \&!
-is used, the compression layer will remain in the closed state, otherwise
-it will re-enter the STOPPED state, waiting for the peer to initiate
-further CCP negotiation. In any event, this command does not disconnect
-the user from
-.Nm
-or exit
-.Nm ppp .
-See the
-.Dq quit
-command below.
-.It delete Ns Xo
-.Op \&!
-.Ar dest
-.Xc
-This command deletes the route with the given
-.Ar dest
-IP address. If
-.Ar dest
-is specified as
-.Sq ALL ,
-all non-direct entries in the routing table for the current interface,
-and all
-.Sq sticky route
-entries are deleted. If
-.Ar dest
-is specified as
-.Sq default ,
-the default route is deleted.
-.Pp
-If the
-.Ar delete!
-command is used
-.Pq note the trailing Dq \&! ,
-.Nm
-will not complain if the route does not already exist.
-.It dial|call Op Ar label Ns Xo
-.No ...
-.Xc
-This command is the equivalent of
-.Dq load label
-followed by
-.Dq open ,
-and is provided for backwards compatibility.
-.It down Op Ar lcp|ccp
-Bring the relevant layer down ungracefully, as if the underlying layer
-had become unavailable. It's not considered polite to use this command on
-a Finite State Machine that's in the OPEN state. If no arguments are
-supplied, the entire link is closed (or if no context is given, all links
-are terminated). If
-.Sq lcp
-is specified, the
-.Em LCP
-layer is terminated but the device is not brought offline and the link
-is not closed. If
-.Sq ccp
-is specified, only the relevant compression layer(s) are terminated.
-.It help|? Op Ar command
-Show a list of available commands. If
-.Ar command
-is specified, show the usage string for that command.
-.It iface Ar command Op args
-This command is used to control the interface used by
-.Nm ppp .
-.Ar Command
-may be one of the following:
-.Bl -tag -width XX
-.It iface add Ns Xo
-.Op \&!
-.Ar addr Ns Op / Ns Ar bits
-.Op Ar peer
-.Xc
-.It iface add Ns Xo
-.Op \&!
-.Ar addr
-.Ar mask
-.Ar peer
-.Xc
-Add the given
-.Ar addr mask peer
-combination to the interface. Instead of specifying
-.Ar mask ,
-.Ar /bits
-can be used
-.Pq with no space between \&it and Ar addr .
-If the given address already exists, the command fails unless the
-.Dq \&!
-is used - in which case the previous interface address entry is overwritten
-with the new one, allowing a change of netmask or peer address.
-.Pp
-If only
-.Ar addr
-is specified,
-.Ar bits
-defaults to
-.Dq 32
-and
-.Ar peer
-defaults to
-.Dq 255.255.255.255 .
-This address (the broadcast address) is the only duplicate peer address that
-.Nm
-allows.
-.It iface clear
-If this command is used while
-.Nm
-is in the OPENED state or while in
-.Fl auto
-mode, all addresses except for the IPCP negotiated address are deleted
-from the interface. If
-.Nm
-is not in the OPENED state and is not in
-.Fl auto
-mode, all interface addresses are deleted.
-.Pp
-.It iface delete Ns Xo
-.Op \&! Ns
-.No |rm Ns Op \&!
-.Ar addr
-.Xc
-This command deletes the given
-.Ar addr
-from the interface. If the
-.Dq \&!
-is used, no error is given if the address isn't currently assigned to
-the interface (and no deletion takes place).
-.It iface show
-Shows the current state and current addresses for the interface. It is
-much the same as running
-.Dq ifconfig INTERFACE .
-.It iface help Op Ar sub-command
-This command, when invoked without
-.Ar sub-command ,
-will show a list of possible
-.Dq iface
-sub-commands and a brief synopsis for each. When invoked with
-.Ar sub-command ,
-only the synopsis for the given sub-command is shown.
-.El
-.It Op data Ns Xo
-.No link
-.Ar name Ns Op , Ns Ar name Ns
-.No ... Ar command Op Ar args
-.Xc
-This command may prefix any other command if the user wishes to
-specify which link the command should affect. This is only
-applicable after multiple links have been created in Multi-link
-mode using the
-.Dq clone
-command.
-.Pp
-.Ar Name
-specifies the name of an existing link. If
-.Ar name
-is a comma separated list,
-.Ar command
-is executed on each link. If
-.Ar name
-is
-.Dq * ,
-.Ar command
-is executed on all links.
-.It load Op Ar label Ns Xo
-.No ...
-.Xc
-Load the given
-.Ar label Ns No (s)
-from the
-.Pa ppp.conf
-file. If
-.Ar label
-is not given, the
-.Ar default
-label is used.
-.Pp
-Unless the
-.Ar label
-section uses the
-.Dq set mode ,
-.Dq open
-or
-.Dq dial
-commands,
-.Nm
-will not attempt to make an immediate connection.
-.It open Op lcp|ccp|ipcp
-This is the opposite of the
-.Dq close
-command. All closed links are immediately brought up apart from second
-and subsequent
-.Ar demand-dial
-links - these will come up based on the
-.Dq set autoload
-command that has been used.
-.Pp
-If the
-.Dq lcp
-argument is used while the LCP layer is already open, LCP will be
-renegotiated. This allows various LCP options to be changed, after which
-.Dq open lcp
-can be used to put them into effect. After renegotiating LCP,
-any agreed authentication will also take place.
-.Pp
-If the
-.Dq ccp
-argument is used, the relevant compression layer is opened. Again,
-if it is already open, it will be renegotiated.
-.Pp
-If the
-.Dq ipcp
-argument is used, the link will be brought up as normal, but if
-IPCP is already open, it will be renegotiated and the network
-interface will be reconfigured.
-.Pp
-It is probably not good practice to re-open the PPP state machines
-like this as it's possible that the peer will not behave correctly.
-It
-.Em is
-however useful as a way of forcing the CCP or VJ dictionaries to be reset.
-.It passwd Ar pass
-Specify the password required for access to the full
-.Nm
-command set. This password is required when connecting to the diagnostic
-port (see the
-.Dq set server
-command).
-.Ar Pass
-is specified on the
-.Dq set server
-command line. The value of
-.Ar pass
-is not logged when
-.Ar command
-logging is active, instead, the literal string
-.Sq ********
-is logged.
-.It quit|bye Op all
-If
-.Dq quit
-is executed from the controlling connection or from a command file,
-ppp will exit after closing all connections. Otherwise, if the user
-is connected to a diagnostic socket, the connection is simply dropped.
-.Pp
-If the
-.Ar all
-argument is given,
-.Nm
-will exit despite the source of the command after closing all existing
-connections.
-.It remove|rm
-This command removes the given link. It is only really useful in
-multi-link mode. A link must be
-in the
-.Dv CLOSED
-state before it is removed.
-.It rename|mv Ar name
-This command renames the given link to
-.Ar name .
-It will fail if
-.Ar name
-is already used by another link.
-.Pp
-The default link name is
-.Sq deflink .
-Renaming it to
-.Sq modem ,
-.Sq cuaa0
-or
-.Sq USR
-may make the log file more readable.
-.It save
-This option is not (yet) implemented.
-.It set Ns Xo
-.No Op up
-.Ar var value
-.Xc
-This option allows the setting of any of the following variables:
-.Bl -tag -width XX
-.It set accmap Ar hex-value
-ACCMap stands for Asynchronous Control Character Map. This is always
-negotiated with the peer, and defaults to a value of 00000000 in hex.
-This protocol is required to defeat hardware that depends on passing
-certain characters from end to end (such as XON/XOFF etc).
-.Pp
-For the XON/XOFF scenario, use
-.Dq set accmap 000a0000 .
-.It set Op auth Ns Xo
-.No key Ar value
-.Xc
-This sets the authentication key (or password) used in client mode
-PAP or CHAP negotiation to the given value. It also specifies the
-password to be used in the dial or login scripts in place of the
-.Sq \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\P
-sequence, preventing the actual password from being logged. If
-.Ar command
-or
-.Ar chat
-logging is in effect,
-.Ar value
-is logged as
-.Sq ********
-for security reasons.
-.Pp
-If the first character of
-.Ar value
-is an exclaimation mark
-.Pq Dq \&! ,
-.Nm
-treats the remainder of the string as a program that must be executed
-to determine the
-.Dq authname
-and
-.Dq authkey
-values.
-.Pp
-Ignoring the
-.Dq \&! ,
-.Ar value
-is parsed as a program to execute in the same was as the
-.Dq !bg
-command above, substituting special names in the same manner. Once executed,
-.Nm
-will feed the program three lines of input, each terminated by a newline
-character:
-.Bl -bullet
-.It
-The host name as sent in the CHAP challenge.
-.It
-The challenge string as sent in the CHAP challenge.
-.It
-The locally defined
-.Dq authname .
-.El
-.Pp
-Two lines of output are expected:
-.Bl -bullet
-.It
-The
-.Dq authname
-to be sent with the CHAP response.
-.It
-The
-.Dq authkey ,
-which is encrypted with the challenge and request id, the answer being sent
-in the CHAP response packet.
-.El
-.Pp
-When configuring
-.Nm
-in this manner, it's expected that the host challenge is a series of ASCII
-digits or characters. An encryption device or Secure ID card is usually
-required to calculate the secret appropriate for the given challenge.
-.It set authname Ar id
-This sets the authentication id used in client mode PAP or CHAP negotiation.
-.Pp
-If used in
-.Fl direct
-mode with CHAP enabled,
-.Ar id
-is used in the initial authentication challenge and should normally be set to
-the local machine name.
-.It set autoload Xo
-.Ar min-percent max-percent period
-.Xc
-These settings apply only in multi-link mode and default to zero, zero and
-five respectively.
-When more than one
-.Ar demand-dial
-.Pq also known as Fl auto
-mode link is available, only the first link is made active when
-.Nm
-first reads data from the tun device. The next
-.Ar demand-dial
-link will be opened only when the current bundle throughput is at least
-.Ar max-percent
-percent of the total bundle bandwidth for
-.Ar period
-seconds. When the current bundle throughput decreases to
-.Ar min-percent
-percent or less of the total bundle bandwidth for
-.Ar period
-seconds, a
-.Ar demand-dial
-link will be brought down as long as it's not the last active
-.Ar demand-dial
-link.
-.Pp
-The default values cause
-.Ar demand-dial
-links to simply come up one at a time.
-.Pp
-Certain devices cannot determine their physical bandwidth, so it
-is sometimes necessary to use the
-.Dq set bandwidth
-command (described below) to make
-.Dq set autoload
-work correctly.
-.It set bandwidth Ar value
-This command sets the connection bandwidth in bits per second.
-.Ar value
-must be greater than zero. It is currently only used by the
-.Dq set autoload
-command above.
-.It set callback Ar option Ns No ...
-If no arguments are given, callback is disabled, otherwise,
-.Nm
-will request (or in
-.Fl direct
-mode, will accept) one of the given
-.Ar option Ns No s .
-In client mode, if an
-.Ar option
-is NAK'd
-.Nm
-will request a different
-.Ar option ,
-until no options remain at which point
-.Nm
-will terminate negotiations (unless
-.Dq none
-is one of the specified
-.Ar option Ns No ).
-In server mode,
-.Nm
-will accept any of the given protocols - but the client
-.Em must
-request one of them. If you wish callback to be optional, you must include
-.Ar none
-as an option.
-.Pp
-The
-.Ar option Ns No s
-are as follows (in this order of preference):
-.Pp
-.Bl -tag -width Ds
-.It auth
-The callee is expected to decide the callback number based on
-authentication. If
-.Nm
-is the callee, the number should be specified as the fifth field of
-the peers entry in
-.Pa /etc/ppp/ppp.secret .
-.It cbcp
-Microsofts callback control protocol is used. See
-.Dq set cbcp
-below.
-.Pp
-If you wish to negotiate
-.Ar cbcp
-in client mode but also wish to allow the server to request no callback at
-CBCP negotiation time, you must specify both
-.Ar cbcp
-and
-.Ar none
-as callback options.
-.It E.164 *| Ns Xo
-.Ar number Ns Op , Ns Ar number Ns
-.No ...
-.Xc
-The caller specifies the
-.Ar number .
-If
-.Nm
-is the callee,
-.Ar number
-should be either a comma separated list of allowable numbers or a
-.Dq \&* ,
-meaning any number is permitted. If
-.Nm
-is the caller, only a single number should be specified.
-.Pp
-Note, this option is very unsafe when used with a
-.Dq \&*
-as a malicious caller can tell
-.Nm
-to call any (possibly international) number without first authenticating
-themselves.
-.It none
-If the peer does not wish to do callback at all,
-.Nm
-will accept the fact and continue without callback rather than terminating
-the connection. This is required (in addition to one or more other callback
-options) if you wish callback to be optional.
-.El
-.Pp
-.It set cbcp Oo Xo
-.No *| Ns Ar number Ns No
-.Oo
-.No , Ns Ar number Ns
-.Oc
-.No ...
-.Op Ar delay Op Ar retry
-.Oc
-.Xc
-If no arguments are given, CBCP (Microsofts CallBack Control Protocol)
-is disabled - ie, configuring CBCP in the
-.Dq set callback
-command will result in
-.Nm
-requesting no callback in the CBCP phase.
-Otherwise,
-.Nm
-attempts to use the given phone
-.Ar number Ns No (s).
-.Pp
-In server mode
-.Pq Fl direct ,
-.Nm
-will insist that the client uses one of these numbers, unless
-.Dq \&*
-is used in which case the client is expected to specify the number.
-.Pp
-In client mode,
-.Nm
-will attempt to use one of the given numbers (whichever it finds to
-be agreeable with the peer), or if
-.Dq \&*
-is specified,
-.Nm
-will expect the peer to specify the number.
-.It set cd Oo
-.No off| Ns Ar seconds Ns Op \&!
-.Oc
-Normally,
-.Nm
-checks for the existence of carrier depending on the type of device
-that has been opened:
-.Bl -tag -width XXX -offset XXX
-.It Terminal Devices
-Carrier is checked one second after the login script is complete. If it's
-not set,
-.Nm
-assumes that this is because the device doesn't support carrier (which
-is true for most
-.Dq laplink
-NULL-modem cables), logs the fact and stops checking
-for carrier.
-.Pp
-As ptys don't support the TIOCMGET ioctl, the tty device will switch all
-carrier detection off when it detects that the device is a pty.
-.It ISDN (i4b) Devices
-Carrier is checked once per second for 6 seconds. If it's not set after
-the sixth second, the connection attempt is considered to have failed and
-the device is closed. Carrier is always required for i4b devices.
-.It PPPoE (netgraph) Devices
-Carrier is checked once per second for 5 seconds. If it's not set after
-the fifth second, the connection attempt is considered to have failed and
-the device is closed. Carrier is always required for PPPoE devices.
-.El
-.Pp
-All other device types don't support carrier. Setting a carrier value will
-result in a warning when the device is opened.
-.Pp
-Some modems take more than one second after connecting to assert the carrier
-signal. If this delay isn't increased, this will result in
-.Nm ppp Ns No s
-inability to detect when the link is dropped, as
-.Nm
-assumes that the device isn't asserting carrier.
-.Pp
-The
-.Dq set cd
-command overrides the default carrier behaviour.
-.Ar seconds
-specifies the maximum number of seconds that
-.Nm
-should wait after the dial script has finished before deciding if
-carrier is available or not.
-.Pp
-If
-.Dq off
-is specified,
-.Nm
-will not check for carrier on the device, otherwise
-.Nm
-will not proceed to the login script until either carrier is detected
-or until
-.Ar seconds
-has elapsed, at which point
-.Nm
-assumes that the device will not set carrier.
-.Pp
-If no arguments are given, carrier settings will go back to their default
-values.
-.Pp
-If
-.Ar seconds
-is followed immediately by an exclaimation mark
-.Pq Dq \&! ,
-.Nm
-will
-.Em require
-carrier. If carrier is not detected after
-.Ar seconds
-seconds, the link will be disconnected.
-.It set choked Op Ar timeout
-This sets the number of seconds that
-.Nm
-will keep a choked output queue before dropping all pending output packets.
-If
-.Ar timeout
-is less than or equal to zero or if
-.Ar timeout
-isn't specified, it is set to the default value of
-.Em 120 seconds .
-.Pp
-A choked output queue occurs when
-.Nm
-has read a certain number of packets from the local network for transmission,
-but cannot send the data due to link failure (the peer is busy etc.).
-.Nm
-will not read packets indefinitely. Instead, it reads up to
-.Em 30
-packets (or
-.Em 30 No +
-.Em nlinks No *
-.Em 2
-packets in multi-link mode), then stops reading the network interface
-until either
-.Ar timeout
-seconds have passed or at least one packet has been sent.
-.Pp
-If
-.Ar timeout
-seconds pass, all pending output packets are dropped.
-.It set ctsrts|crtscts on|off
-This sets hardware flow control. Hardware flow control is
-.Ar on
-by default.
-.It set deflate Ar out-winsize Op Ar in-winsize
-This sets the DEFLATE algorithms default outgoing and incoming window
-sizes. Both
-.Ar out-winsize
-and
-.Ar in-winsize
-must be values between
-.Em 8
-and
-.Em 15 .
-If
-.Ar in-winsize
-is specified,
-.Nm
-will insist that this window size is used and will not accept any other
-values from the peer.
-.It set dns Op Ar primary Op Ar secondary
-This command specifies DNS overrides for the
-.Dq accept dns
-command. Refer to the
-.Dq accept
-command description above for details. This command does not affect the
-IP numbers requested using
-.Dq enable dns .
-.It set device|line Xo
-.Ar value Ns No ...
-.Xc
-This sets the device(s) to which
-.Nm
-will talk to the given
-.Dq value .
-.Pp
-All ISDN and serial device names are expected to begin with
-.Pa /dev/ .
-ISDN devices are usually called
-.Pa i4brbchX
-and serial devices are usually called
-.Pa cuaXX .
-.Pp
-If
-.Dq value
-does not begin with
-.Pa /dev/ ,
-it must either begin with an exclamation mark
-.Pq Dq \&! ,
-be of the format
-.No PPPoE: Ns Ar iface Ns Xo
-.Op \&: Ns Ar provider Ns
-.Xc
-or be of the format
-.Ar host Ns No : Ns Ar port Ns Oo
-.No /tcp|udp
-.Oc .
-.Pp
-If it begins with an exclamation mark, the rest of the device name is
-treated as a program name, and that program is executed when the device
-is opened. Standard input, output and error are fed back to
-.Nm
-and are read and written as if they were a regular device.
-.Pp
-If a
-.No PPPoE: Ns Ar iface Ns Xo
-.Op \&: Ns Ar provider Ns
-.Xc
-specification is given,
-.Nm
-will attempt to create a
-.Em PPP
-over Ethernet connection using the given
-.Ar iface
-interface. The given
-.Ar provider
-is passed as the service name in the PPPoE Discovery Initiation (PADI)
-packet. If no provider is given, an empty value will be used. Refer to
-.Xr netgraph 4
-and
-.Xr ng_pppoe 8
-for further details.
-.Pp
-If a
-.Ar host Ns No : Ns Ar port Ns Oo
-.No /tcp|udp
-.Oc
-specification is given,
-.Nm
-will attempt to connect to the given
-.Ar host
-on the given
-.Ar port .
-If a
-.Dq /tcp
-or
-.Dq /udp
-suffix is not provided, the default is
-.Dq /tcp .
-Refer to the section on
-.Em PPP OVER TCP and UDP
-above for further details.
-.Pp
-If multiple
-.Dq values
-are specified,
-.Nm
-will attempt to open each one in turn until it succeeds or runs out of
-devices.
-.It set dial Ar chat-script
-This specifies the chat script that will be used to dial the other
-side. See also the
-.Dq set login
-command below. Refer to
-.Xr chat 8
-and to the example configuration files for details of the chat script
-format.
-It is possible to specify some special
-.Sq values
-in your chat script as follows:
-.Bd -unfilled -offset indent
-.It Li \\\\\\\\\\\\\\\\c
-When used as the last character in a
-.Sq send
-string, this indicates that a newline should not be appended.
-.It Li \\\\\\\\\\\\\\\\d
-When the chat script encounters this sequence, it delays two seconds.
-.It Li \\\\\\\\\\\\\\\\p
-When the chat script encounters this sequence, it delays for one quarter of
-a second.
-.It Li \\\\\\\\\\\\\\\\n
-This is replaced with a newline character.
-.It Li \\\\\\\\\\\\\\\\r
-This is replaced with a carriage return character.
-.It Li \\\\\\\\\\\\\\\\s
-This is replaced with a space character.
-.It Li \\\\\\\\\\\\\\\\t
-This is replaced with a tab character.
-.It Li \\\\\\\\\\\\\\\\T
-This is replaced by the current phone number (see
-.Dq set phone
-below).
-.It Li \\\\\\\\\\\\\\\\P
-This is replaced by the current
-.Ar authkey
-value (see
-.Dq set authkey
-above).
-.It Li \\\\\\\\\\\\\\\\U
-This is replaced by the current
-.Ar authname
-value (see
-.Dq set authname
-above).
-.Ed
-.Pp
-Note that two parsers will examine these escape sequences, so in order to
-have the
-.Sq chat parser
-see the escape character, it is necessary to escape it from the
-.Sq command parser .
-This means that in practice you should use two escapes, for example:
-.Bd -literal -offset indent
-set dial "... ATDT\\\\T CONNECT"
-.Ed
-.Pp
-It is also possible to execute external commands from the chat script.
-To do this, the first character of the expect or send string is an
-exclamation mark
-.Pq Dq \&! .
-When the command is executed, standard input and standard output are
-directed to the open device (see the
-.Dq set device
-command), and standard error is read by
-.Nm
-and substituted as the expect or send string. If
-.Nm
-is running in interactive mode, file descriptor 3 is attached to
-.Pa /dev/tty .
-.Pp
-For example (wrapped for readability);
-.Bd -literal -offset indent
-set login "TIMEOUT 5 \\"\\" \\"\\" login:--login: ppp \e
-word: ppp \\"!sh \\\\-c \\\\\\"echo \\\\-n label: >&2\\\\\\"\\" \e
-\\"!/bin/echo in\\" HELLO"
-.Ed
-.Pp
-would result in the following chat sequence (output using the
-.Sq set log local chat
-command before dialing):
-.Bd -literal -offset indent
-Dial attempt 1 of 1
-dial OK!
-Chat: Expecting:
-Chat: Sending:
-Chat: Expecting: login:--login:
-Chat: Wait for (5): login:
-Chat: Sending: ppp
-Chat: Expecting: word:
-Chat: Wait for (5): word:
-Chat: Sending: ppp
-Chat: Expecting: !sh \\-c "echo \\-n label: >&2"
-Chat: Exec: sh -c "echo -n label: >&2"
-Chat: Wait for (5): !sh \\-c "echo \\-n label: >&2" --> label:
-Chat: Exec: /bin/echo in
-Chat: Sending:
-Chat: Expecting: HELLO
-Chat: Wait for (5): HELLO
-login OK!
-.Ed
-.Pp
-Note (again) the use of the escape character, allowing many levels of
-nesting. Here, there are four parsers at work. The first parses the
-original line, reading it as three arguments. The second parses the
-third argument, reading it as 11 arguments. At this point, it is
-important that the
-.Dq \&-
-signs are escaped, otherwise this parser will see them as constituting
-an expect-send-expect sequence. When the
-.Dq \&!
-character is seen, the execution parser reads the first command as three
-arguments, and then
-.Xr sh 1
-itself expands the argument after the
-.Fl c .
-As we wish to send the output back to the modem, in the first example
-we redirect our output to file descriptor 2 (stderr) so that
-.Nm
-itself sends and logs it, and in the second example, we just output to stdout,
-which is attached directly to the modem.
-.Pp
-This, of course means that it is possible to execute an entirely external
-.Dq chat
-command rather than using the internal one. See
-.Xr chat 8
-for a good alternative.
-.Pp
-The external command that is executed is subjected to the same special
-word expansions as the
-.Dq !bg
-command.
-.It set enddisc Op label|IP|MAC|magic|psn value
-This command sets our local endpoint discriminator. If set prior to
-LCP negotiation, and if no
-.Dq disable enddisc
-command has been used,
-.Nm
-will send the information to the peer using the LCP endpoint discriminator
-option. The following discriminators may be set:
-.Bd -unfilled -offset indent
-.It Li label
-The current label is used.
-.It Li IP
-Our local IP number is used. As LCP is negotiated prior to IPCP, it is
-possible that the IPCP layer will subsequently change this value. If
-it does, the endpoint discriminator stays at the old value unless manually
-reset.
-.It Li MAC
-This is similar to the
-.Ar IP
-option above, except that the MAC address associated with the local IP
-number is used. If the local IP number is not resident on any Ethernet
-interface, the command will fail.
-.Pp
-As the local IP number defaults to whatever the machine host name is,
-.Dq set enddisc mac
-is usually done prior to any
-.Dq set ifaddr
-commands.
-.It Li magic
-A 20 digit random number is used. Care should be taken when using magic
-numbers as restarting
-.Nm
-or creating a link using a different
-.Nm
-invocation will also use a different magic number and will therefore not
-be recognised by the peer as belonging to the same bundle. This makes it
-unsuitable for
-.Fl direct
-connections.
-.It Li psn Ar value
-The given
-.Ar value
-is used.
-.Ar Value
-should be set to an absolute public switched network number with the
-country code first.
-.Ed
-.Pp
-If no arguments are given, the endpoint discriminator is reset.
-.It set escape Ar value...
-This option is similar to the
-.Dq set accmap
-option above. It allows the user to specify a set of characters that
-will be
-.Sq escaped
-as they travel across the link.
-.It set filter dial|alive|in|out Ar rule-no Xo
-.No permit|deny|clear| Ns Ar rule-no
-.Op \&!
-.Oo Op host
-.Ar src_addr Ns Op / Ns Ar width
-.Op Ar dst_addr Ns Op / Ns Ar width
-.Oc Oo tcp|udp|ospf|igmp|icmp Op src lt|eq|gt Ar port
-.Op dst lt|eq|gt Ar port
-.Op estab
-.Op syn
-.Op finrst
-.Oc
-.Xc
-.Nm
-supports four filter sets. The
-.Em alive
-filter specifies packets that keep the connection alive - resetting the
-idle timer. The
-.Em dial
-filter specifies packets that cause
-.Nm
-to dial when in
-.Fl auto
-mode. The
-.Em in
-filter specifies packets that are allowed to travel
-into the machine and the
-.Em out
-filter specifies packets that are allowed out of the machine.
-.Pp
-Filtering is done prior to any IP alterations that might be done by the
-NAT engine on outgoing packets and after any IP alterations that might
-be done by the NAT engine on incoming packets. By default all filter
-sets allow all packets to pass. Rules are processed in order according to
-.Ar rule-no
-(unless skipped by specifying a rule number as the
-.Ar action ) .
-Up to 40 rules may be given for each set. If a packet doesn't match
-any of the rules in a given set, it is discarded. In the case of
-.Em in
-and
-.Em out
-filters, this means that the packet is dropped. In the case of
-.Em alive
-filters it means that the packet will not reset the idle timer and in
-the case of
-.Em dial
-filters it means that the packet will not trigger a dial. A packet failing
-to trigger a dial will be dropped rather than queued. Refer to the
-section on
-.Sx PACKET FILTERING
-above for further details.
-.It set hangup Ar chat-script
-This specifies the chat script that will be used to reset the device
-before it is closed. It should not normally be necessary, but can
-be used for devices that fail to reset themselves properly on close.
-.It set help|? Op Ar command
-This command gives a summary of available set commands, or if
-.Ar command
-is specified, the command usage is shown.
-.It set ifaddr Oo Ar myaddr Ns
-.Op / Ns Ar \&nn
-.Oo Ar hisaddr Ns Op / Ns Ar \&nn
-.Oo Ar netmask
-.Op Ar triggeraddr
-.Oc Oc
-.Oc
-This command specifies the IP addresses that will be used during
-IPCP negotiation. Addresses are specified using the format
-.Pp
-.Dl a.b.c.d/nn
-.Pp
-Where
-.Dq a.b.c.d
-is the preferred IP, but
-.Ar nn
-specifies how many bits of the address we will insist on. If
-.No / Ns Ar nn
-is omitted, it defaults to
-.Dq /32
-unless the IP address is 0.0.0.0 in which case it defaults to
-.Dq /0 .
-.Pp
-If you wish to assign a dynamic IP number to the peer,
-.Ar hisaddr
-may also be specified as a range of IP numbers in the format
-.Bd -literal -offset indent
-.Ar \&IP Ns Oo \&- Ns Ar \&IP Ns Xo
-.Oc Oo , Ns Ar \&IP Ns
-.Op \&- Ns Ar \&IP Ns
-.Oc No ...
-.Xc
-.Ed
-.Pp
-for example:
-.Pp
-.Dl set ifaddr 10.0.0.1 10.0.1.2-10.0.1.10,10.0.1.20
-.Pp
-will only negotiate
-.Dq 10.0.0.1
-as the local IP number, but may assign any of the given 10 IP
-numbers to the peer. If the peer requests one of these numbers,
-and that number is not already in use,
-.Nm
-will grant the peers request. This is useful if the peer wants
-to re-establish a link using the same IP number as was previously
-allocated (thus maintaining any existing tcp or udp connections).
-.Pp
-If the peer requests an IP number that's either outside
-of this range or is already in use,
-.Nm
-will suggest a random unused IP number from the range.
-.Pp
-If
-.Ar triggeraddr
-is specified, it is used in place of
-.Ar myaddr
-in the initial IPCP negotiation. However, only an address in the
-.Ar myaddr
-range will be accepted. This is useful when negotiating with some
-.Dv PPP
-implementations that will not assign an IP number unless their peer
-requests
-.Dq 0.0.0.0 .
-.Pp
-It should be noted that in
-.Fl auto
-mode,
-.Nm
-will configure the interface immediately upon reading the
-.Dq set ifaddr
-line in the config file. In any other mode, these values are just
-used for IPCP negotiations, and the interface isn't configured
-until the IPCP layer is up.
-.Pp
-Note that the
-.Ar HISADDR
-argument may be overridden by the third field in the
-.Pa ppp.secret
-file once the client has authenticated itself
-.Pq if PAP or CHAP are Dq enabled .
-Refer to the
-.Sx AUTHENTICATING INCOMING CONNECTIONS
-section for details.
-.Pp
-In all cases, if the interface is already configured,
-.Nm
-will try to maintain the interface IP numbers so that any existing
-bound sockets will remain valid.
-.It set ccpretry|ccpretries Oo Ar timeout
-.Op Ar reqtries Op Ar trmtries
-.Oc
-.It set chapretry|chapretries Oo Ar timeout
-.Op Ar reqtries
-.Oc
-.It set ipcpretry|ipcpretries Oo Ar timeout
-.Op Ar reqtries Op Ar trmtries
-.Oc
-.It set lcpretry|lcpretries Oo Ar timeout
-.Op Ar reqtries Op Ar trmtries
-.Oc
-.It set papretry|papretries Oo Ar timeout
-.Op Ar reqtries
-.Oc
-These commands set the number of seconds that
-.Nm
-will wait before resending Finite State Machine (FSM) Request packets.
-The default
-.Ar timeout
-for all FSMs is 3 seconds (which should suffice in most cases).
-.Pp
-If
-.Ar reqtries
-is specified, it tells
-.Nm
-how many configuration request attempts it should make while receiving
-no reply from the peer before giving up. The default is 5 attempts for
-CCP, LCP and IPCP and 3 attempts for PAP and CHAP.
-.Pp
-If
-.Ar trmtries
-is specified, it tells
-.Nm
-how many terminate requests should be sent before giving up waiting for the
-peers response. The default is 3 attempts. Authentication protocols are
-not terminated and it is therefore invalid to specify
-.Ar trmtries
-for PAP or CHAP.
-.Pp
-In order to avoid negotiations with the peer that will never converge,
-.Nm
-will only send at most 3 times the configured number of
-.Ar reqtries
-in any given negotiation session before giving up and closing that layer.
-.It set log Xo
-.Op local
-.Op +|- Ns
-.Ar value Ns No ...
-.Xc
-This command allows the adjustment of the current log level. Refer
-to the Logging Facility section for further details.
-.It set login Ar chat-script
-This
-.Ar chat-script
-compliments the dial-script. If both are specified, the login
-script will be executed after the dial script. Escape sequences
-available in the dial script are also available here.
-.It set logout Ar chat-script
-This specifies the chat script that will be used to logout
-before the hangup script is called. It should not normally be necessary.
-.It set lqrperiod Ar frequency
-This command sets the
-.Ar frequency
-in seconds at which
-.Em LQR
-or
-.Em ECHO LQR
-packets are sent. The default is 30 seconds. You must also use the
-.Dq enable lqr
-command if you wish to send LQR requests to the peer.
-.It set mode Ar interactive|auto|ddial|background
-This command allows you to change the
-.Sq mode
-of the specified link. This is normally only useful in multi-link mode,
-but may also be used in uni-link mode.
-.Pp
-It is not possible to change a link that is
-.Sq direct
-or
-.Sq dedicated .
-.Pp
-Note: If you issue the command
-.Dq set mode auto ,
-and have network address translation enabled, it may be useful to
-.Dq enable iface-alias
-afterwards. This will allow
-.Nm
-to do the necessary address translations to enable the process that
-triggers the connection to connect once the link is up despite the
-peer assigning us a new (dynamic) IP address.
-.It set mrru Op Ar value
-Setting this option enables Multi-link PPP negotiations, also known as
-Multi-link Protocol or MP. There is no default MRRU (Maximum
-Reconstructed Receive Unit) value. If no argument is given, multi-link
-mode is disabled.
-.It set mru Op Ar value
-The default MRU (Maximum Receive Unit) is 1500. If it is increased, the
-other side *may* increase its mtu. There is no point in decreasing the
-MRU to below the default as the
-.Em PPP
-protocol *must* be able to accept packets of at least 1500 octets. If
-no argument is given, 1500 is assumed.
-.It set mtu Op Ar value
-The default MTU is 1500. At negotiation time,
-.Nm
-will accept whatever MRU or MRRU that the peer wants (assuming it's
-not less than 296 bytes). If the MTU is set,
-.Nm
-will not accept MRU/MRRU values less than
-.Ar value .
-When negotiations are complete, the MTU is assigned to the interface, even
-if the peer requested a higher value MRU/MRRU. This can be useful for
-limiting your packet size (giving better bandwidth sharing at the expense
-of more header data).
-.Pp
-If no
-.Ar value
-is given, 1500, or whatever the peer asks for is used.
-.It set nbns Op Ar x.x.x.x Op Ar y.y.y.y
-This option allows the setting of the Microsoft NetBIOS name server
-values to be returned at the peers request. If no values are given,
-.Nm
-will reject any such requests.
-.It set openmode active|passive Op Ar delay
-By default,
-.Ar openmode
-is always
-.Ar active
-with a one second
-.Ar delay .
-That is,
-.Nm
-will always initiate LCP/IPCP/CCP negotiation one second after the line
-comes up. If you want to wait for the peer to initiate negotiations, you
-can use the value
-.Ar passive .
-If you want to initiate negotiations immediately or after more than one
-second, the appropriate
-.Ar delay
-may be specified here in seconds.
-.It set parity odd|even|none|mark
-This allows the line parity to be set. The default value is
-.Ar none .
-.It set phone Ar telno Ns Xo
-.Oo \&| Ns Ar backupnumber
-.Oc Ns ... Ns Oo : Ns Ar nextnumber
-.Oc Ns ...
-.Xc
-This allows the specification of the phone number to be used in
-place of the \\\\T string in the dial and login chat scripts.
-Multiple phone numbers may be given separated either by a pipe
-.Pq Dq \&|
-or a colon
-.Pq Dq \&: .
-.Pp
-Numbers after the pipe are only dialed if the dial or login
-script for the previous number failed.
-.Pp
-Numbers after the colon are tried sequentially, irrespective of
-the reason the line was dropped.
-.Pp
-If multiple numbers are given,
-.Nm
-will dial them according to these rules until a connection is made, retrying
-the maximum number of times specified by
-.Dq set redial
-below. In
-.Fl background
-mode, each number is attempted at most once.
-.It set Op proc Ns Xo
-.No title Op Ar value
-.Xc
-The current process title as displayed by
-.Xr ps 1
-is changed according to
-.Ar value .
-If
-.Ar value
-is not specified, the original process title is restored. All the
-word replacements done by the shell commands (see the
-.Dq bg
-command above) are done here too.
-.Pp
-Note, if USER is required in the process title, the
-.Dq set proctitle
-command must appear in
-.Pa ppp.linkup ,
-as it is not known when the commands in
-.Pa ppp.conf
-are executed.
-.It set radius Op Ar config-file
-This command enables RADIUS support (if it's compiled in).
-.Ar config-file
-refers to the radius client configuration file as described in
-.Xr radius.conf 5 .
-If PAP or CHAP are
-.Dq enable Ns No d ,
-.Nm
-behaves as a
-.Em \&N Ns No etwork
-.Em \&A Ns No ccess
-.Em \&S Ns No erver
-and uses the configured RADIUS server to authenticate rather than
-authenticating from the
-.Pa ppp.secret
-file or from the passwd database.
-.Pp
-If neither PAP or CHAP are enabled,
-.Dq set radius
-will do nothing.
-.Pp
-.Nm
-uses the following attributes from the RADIUS reply:
-.Bl -tag -width XXX -offset XXX
-.It RAD_FRAMED_IP_ADDRESS
-The peer IP address is set to the given value.
-.It RAD_FRAMED_IP_NETMASK
-The tun interface netmask is set to the given value.
-.It RAD_FRAMED_MTU
-If the given MTU is less than the peers MRU as agreed during LCP
-negotiation, *and* it is less that any configured MTU (see the
-.Dq set mru
-command), the tun interface MTU is set to the given value.
-.It RAD_FRAMED_COMPRESSION
-If the received compression type is
-.Dq 1 ,
-.Nm
-will request VJ compression during IPCP negotiations despite any
-.Dq disable vj
-configuration command.
-.It RAD_FRAMED_ROUTE
-The received string is expected to be in the format
-.Ar dest Ns Op / Ns Ar bits
-.Ar gw
-.Op Ar metrics .
-Any specified metrics are ignored.
-.Dv MYADDR
-and
-.Dv HISADDR
-are understood as valid values for
-.Ar dest
-and
-.Ar gw ,
-.Dq default
-can be used for
-.Ar dest
-to sepcify the default route, and
-.Dq 0.0.0.0
-is understood to be the same as
-.Dq default
-for
-.Ar dest
-and
-.Dv HISADDR
-for
-.Ar gw .
-.Pp
-For example, a returned value of
-.Dq 1.2.3.4/24 0.0.0.0 1 2 -1 3 400
-would result in a routing table entry to the 1.2.3.0/24 network via
-.Dv HISADDR
-and a returned value of
-.Dq 0.0.0.0 0.0.0.0
-or
-.Dq default HISADDR
-would result in a default route to
-.Dv HISADDR .
-.Pp
-All RADIUS routes are applied after any sticky routes are applied, making
-RADIUS routes override configured routes. This also applies for RADIUS
-routes that don't include the
-.Dv MYADDR
-or
-.Dv HISADDR
-keywords.
-.Pp
-.El
-Values received from the RADIUS server may be viewed using
-.Dq show bundle .
-.It set reconnect Ar timeout ntries
-Should the line drop unexpectedly (due to loss of CD or LQR
-failure), a connection will be re-established after the given
-.Ar timeout .
-The line will be re-connected at most
-.Ar ntries
-times.
-.Ar Ntries
-defaults to zero. A value of
-.Ar random
-for
-.Ar timeout
-will result in a variable pause, somewhere between 1 and 30 seconds.
-.It set recvpipe Op Ar value
-This sets the routing table RECVPIPE value. The optimum value is
-just over twice the MTU value. If
-.Ar value
-is unspecified or zero, the default kernel controlled value is used.
-.It set redial Ar secs Ns Xo
-.Oo + Ns Ar inc Ns
-.Op - Ns Ar max Ns
-.Oc Op . Ns Ar next
-.Op Ar attempts
-.Xc
-.Nm
-can be instructed to attempt to redial
-.Ar attempts
-times. If more than one phone number is specified (see
-.Dq set phone
-above), a pause of
-.Ar next
-is taken before dialing each number. A pause of
-.Ar secs
-is taken before starting at the first number again. A literal value of
-.Dq Li random
-may be used here in place of
-.Ar secs
-and
-.Ar next ,
-causing a random delay of between 1 and 30 seconds.
-.Pp
-If
-.Ar inc
-is specified, its value is added onto
-.Ar secs
-each time
-.Nm
-tries a new number.
-.Ar secs
-will only be incremented at most
-.Ar max
-times.
-.Ar max
-defaults to 10.
-.Pp
-Note, the
-.Ar secs
-delay will be effective, even after
-.Ar attempts
-has been exceeded, so an immediate manual dial may appear to have
-done nothing. If an immediate dial is required, a
-.Dq \&!
-should immediately follow the
-.Dq open
-keyword. See the
-.Dq open
-description above for further details.
-.It set sendpipe Op Ar value
-This sets the routing table SENDPIPE value. The optimum value is
-just over twice the MTU value. If
-.Ar value
-is unspecified or zero, the default kernel controlled value is used.
-.It set server|socket Ar TcpPort|LocalName|none password Op Ar mask
-This command tells
-.Nm
-to listen on the given socket or
-.Sq diagnostic port
-for incoming command connections.
-.Pp
-The word
-.Ar none
-instructs
-.Nm
-to close any existing socket.
-.Pp
-If you wish to specify a local domain socket,
-.Ar LocalName
-must be specified as an absolute file name, otherwise it is assumed
-to be the name or number of a TCP port. You must specify the octal umask
-to be used with a local domain socket. Refer to
-.Xr umask 2
-for umask details. Refer to
-.Xr services 5
-for details of how to translate TCP port names.
-.Pp
-You must also specify the password that must be entered by the client
-(using the
-.Dq passwd
-command above) when connecting to this socket. If the password is
-specified as an empty string, no password is required for connecting clients.
-.Pp
-When specifying a local domain socket, the first
-.Dq %d
-sequence found in the socket name will be replaced with the current
-interface unit number. This is useful when you wish to use the same
-profile for more than one connection.
-.Pp
-In a similar manner TCP sockets may be prefixed with the
-.Dq +
-character, in which case the current interface unit number is added to
-the port number.
-.Pp
-When using
-.Nm
-with a server socket, the
-.Xr pppctl 8
-command is the preferred mechanism of communications. Currently,
-.Xr telnet 1
-can also be used, but link encryption may be implemented in the future, so
-.Xr telnet 1
-should not be relied upon.
-.It set speed Ar value
-This sets the speed of the serial device. If speed is specified as
-.Dq sync ,
-.Nm
-treats the device as a synchronous device.
-.Pp
-Certain device types will know whether they should be specified as
-synchronous or asynchronous. These devices will override incorrect
-settings and log a warning to this effect.
-.It set stopped Op Ar LCPseconds Op Ar CCPseconds
-If this option is set,
-.Nm
-will time out after the given FSM (Finite State Machine) has been in
-the stopped state for the given number of
-.Dq seconds .
-This option may be useful if the peer sends a terminate request,
-but never actually closes the connection despite our sending a terminate
-acknowledgement. This is also useful if you wish to
-.Dq set openmode passive
-and time out if the peer doesn't send a Configure Request within the
-given time. Use
-.Dq set log +lcp +ccp
-to make
-.Nm
-log the appropriate state transitions.
-.Pp
-The default value is zero, where
-.Nm
-doesn't time out in the stopped state.
-.Pp
-This value should not be set to less than the openmode delay (see
-.Dq set openmode
-above).
-.It set timeout Ar idleseconds Op Ar mintimeout
-This command allows the setting of the idle timer. Refer to the
-section titled
-.Sx SETTING THE IDLE TIMER
-for further details.
-.Pp
-If
-.Ar mintimeout
-is specified,
-.Nm
-will never idle out before the link has been up for at least that number
-of seconds.
-.It set urgent Xo
-.Op tcp|udp
-.Oo Op +|- Ns
-.Ar port
-.Oc No ...
-.Xc
-This command controls the ports that
-.Nm
-prioritizes when transmitting data. The default priority TCP ports
-are ports 21 (ftp control), 22 (ssh), 23 (telnet), 513 (login), 514 (shell),
-543 (klogin) and 544 (kshell). There are no priority UDP ports by default.
-See
-.Xr services 5
-for details.
-.Pp
-If neither
-.Dq tcp
-or
-.Dq udp
-are specified,
-.Dq tcp
-is assumed.
-.Pp
-If no
-.Ar port Ns No s
-are given, the priority port lists are cleared (although if
-.Dq tcp
-or
-.Dq udp
-is specified, only that list is cleared). If the first
-.Ar port
-argument is prefixed with a plus
-.Pq Dq \&+
-or a minus
-.Pq Dq \&- ,
-the current list is adjusted, otherwise the list is reassigned.
-.Ar port Ns No s
-prefixed with a plus or not prefixed at all are added to the list and
-.Ar port Ns No s
-prefixed with a minus are removed from the list.
-.It set vj slotcomp on|off
-This command tells
-.Nm
-whether it should attempt to negotiate VJ slot compression. By default,
-slot compression is turned
-.Ar on .
-.It set vj slots Ar nslots
-This command sets the initial number of slots that
-.Nm
-will try to negotiate with the peer when VJ compression is enabled (see the
-.Sq enable
-command above). It defaults to a value of 16.
-.Ar Nslots
-must be between
-.Ar 4
-and
-.Ar 16
-inclusive.
-.El
-.Pp
-.It shell|! Op Ar command
-If
-.Ar command
-is not specified a shell is invoked according to the
-.Dv SHELL
-environment variable. Otherwise, the given
-.Ar command
-is executed. Word replacement is done in the same way as for the
-.Dq !bg
-command as described above.
-.Pp
-Use of the ! character
-requires a following space as with any of the other commands. You should
-note that this command is executed in the foreground -
-.Nm
-will not continue running until this process has exited. Use the
-.Dv bg
-command if you wish processing to happen in the background.
-.It show Ar var
-This command allows the user to examine the following:
-.Bl -tag -width XX
-.It show bundle
-Show the current bundle settings.
-.It show ccp
-Show the current CCP compression statistics.
-.It show compress
-Show the current VJ compression statistics.
-.It show escape
-Show the current escape characters.
-.It show filter Op Ar name
-List the current rules for the given filter. If
-.Ar name
-is not specified, all filters are shown.
-.It show hdlc
-Show the current HDLC statistics.
-.It show help|?
-Give a summary of available show commands.
-.It show iface
-Show the current interface information
-.Pq the same \&as Dq iface show .
-.It show ipcp
-Show the current IPCP statistics.
-.It show layers
-Show the protocol layers currently in use.
-.It show lcp
-Show the current LCP statistics.
-.It show Op data Ns Xo
-.No link
-.Xc
-Show high level link information.
-.It show links
-Show a list of available logical links.
-.It show log
-Show the current log values.
-.It show mem
-Show current memory statistics.
-.It show physical
-Show low level link information.
-.It show mp
-Show Multi-link information.
-.It show proto
-Show current protocol totals.
-.It show route
-Show the current routing tables.
-.It show stopped
-Show the current stopped timeouts.
-.It show timer
-Show the active alarm timers.
-.It show version
-Show the current version number of
-.Nm ppp .
-.El
-.Pp
-.It term
-Go into terminal mode. Characters typed at the keyboard are sent to
-the device. Characters read from the device are displayed on the
-screen. When a remote
-.Em PPP
-peer is detected,
-.Nm
-automatically enables Packet Mode and goes back into command mode.
-.El
-.Pp
-.Sh MORE DETAILS
-.Bl -bullet
-.It
-Read the example configuration files. They are a good source of information.
-.It
-Use
-.Dq help ,
-.Dq nat ? ,
-.Dq enable ? ,
-.Dq set ?
-and
-.Dq show ?
-to get online information about what's available.
-.It
-The following URLs contain useful information:
-.Bl -bullet -compact
-.It
-http://www.FreeBSD.org/FAQ/userppp.html
-.It
-http://www.FreeBSD.org/handbook/userppp.html
-.El
-.Pp
-.El
-.Pp
-.Sh FILES
-.Nm
-refers to four files:
-.Pa ppp.conf ,
-.Pa ppp.linkup ,
-.Pa ppp.linkdown
-and
-.Pa ppp.secret .
-These files are placed in the
-.Pa /etc/ppp
-directory.
-.Bl -tag -width XX
-.It Pa /etc/ppp/ppp.conf
-System default configuration file.
-.It Pa /etc/ppp/ppp.secret
-An authorisation file for each system.
-.It Pa /etc/ppp/ppp.linkup
-A file to check when
-.Nm
-establishes a network level connection.
-.It Pa /etc/ppp/ppp.linkdown
-A file to check when
-.Nm
-closes a network level connection.
-.It Pa /var/log/ppp.log
-Logging and debugging information file. Note, this name is specified in
-.Pa /etc/syslogd.conf .
-See
-.Xr syslog.conf 5
-for further details.
-.It Pa /var/spool/lock/LCK..*
-tty port locking file. Refer to
-.Xr uucplock 3
-for further details.
-.It Pa /var/run/tunN.pid
-The process id (pid) of the
-.Nm
-program connected to the tunN device, where
-.Sq N
-is the number of the device.
-.It Pa /var/run/ttyXX.if
-The tun interface used by this port. Again, this file is only created in
-.Fl background ,
-.Fl auto
-and
-.Fl ddial
-modes.
-.It Pa /etc/services
-Get port number if port number is using service name.
-.It Pa /var/run/ppp-authname-class-value
-In multi-link mode, local domain sockets are created using the peer
-authentication name
-.Pq Sq authname ,
-the peer endpoint discriminator class
-.Pq Sq class
-and the peer endpoint discriminator value
-.Pq Sq value .
-As the endpoint discriminator value may be a binary value, it is turned
-to HEX to determine the actual file name.
-.Pp
-This socket is used to pass links between different instances of
-.Nm ppp .
-.El
-.Pp
-.Sh SEE ALSO
-.Xr at 1 ,
-.Xr ftp 1 ,
-.Xr gzip 1 ,
-.Xr hostname 1 ,
-.Xr login 1 ,
-.Xr tcpdump 1 ,
-.Xr telnet 1 ,
-.Xr libalias 3 ,
-.Xr syslog 3 ,
-.Xr uucplock 3 ,
-.Xr netgraph 4 ,
-.Xr crontab 5 ,
-.Xr group 5 ,
-.Xr passwd 5 ,
-.Xr radius.conf 5 ,
-.Xr resolv.conf 5 ,
-.Xr syslog.conf 5 ,
-.Xr adduser 8 ,
-.Xr chat 8 ,
-.Xr getty 8 ,
-.Xr inetd 8 ,
-.Xr init 8 ,
-.Xr isdn 8 ,
-.Xr named 8 ,
-.Xr ng_pppoe 8 ,
-.Xr ping 8 ,
-.Xr pppctl 8 ,
-.Xr pppd 8 ,
-.Xr route 8 ,
-.Xr sshd 8 ,
-.Xr syslogd 8 ,
-.Xr traceroute 8 ,
-.Xr vipw 8
-.Sh HISTORY
-This program was originally written by
-.An Toshiharu OHNO Aq tony-o@iij.ad.jp ,
-and was submitted to
-.Fx 2.0.5
-by
-.An Atsushi Murai Aq amurai@spec.co.jp .
-.Pp
-It was substantially modified during 1997 by
-.An Brian Somers Aq brian@Awfulhak.org ,
-and was ported to
-.Ox
-in November that year
-(just after the 2.2 release).
-.Pp
-Most of the code was rewritten by
-.An Brian Somers
-in early 1998 when multi-link ppp support was added.
diff --git a/usr.sbin/sade/Makefile b/usr.sbin/sade/Makefile
deleted file mode 100644
index a433558389af..000000000000
--- a/usr.sbin/sade/Makefile
+++ /dev/null
@@ -1,87 +0,0 @@
-PROG= sysinstall
-MAN8= sysinstall.8
-
-BINDIR=/stand
-NOSHARED=YES
-
-CLEANFILES+= makedevs.c rtermcap rtermcap.tmp dumpnlist
-CLEANFILES+= keymap.tmp keymap.h
-
-.PATH: ${.CURDIR}/../disklabel ${.CURDIR}/../../usr.bin/cksum
-
-SRCS= anonFTP.c cdrom.c command.c config.c devices.c dhcp.c kget.c \
- disks.c dispatch.c dist.c dmenu.c doc.c dos.c floppy.c \
- ftp.c globals.c http.c index.c install.c installUpgrade.c keymap.c \
- label.c lndir.c main.c makedevs.c media.c menus.c misc.c mouse.c \
- msg.c network.c nfs.c options.c package.c pccard.c \
- system.c tape.c tcpip.c termcap.c ufs.c user.c variable.c wizard.c \
- keymap.h
-
-CFLAGS+= -Wall -I${.CURDIR}/../../gnu/lib/libdialog -I${.OBJDIR}
-CFLAGS+= -I${.CURDIR}/../../sys
-.if ${MACHINE_ARCH} != "i386" || defined(X_AS_PKG)
-CFLAGS+= -DX_AS_PKG
-.endif
-
-DPADD= ${LIBDIALOG} ${LIBNCURSES} ${LIBMYTINFO} ${LIBUTIL} ${LIBDISK} ${LIBFTPIO}
-LDADD= -ldialog -lncurses -lmytinfo -lutil -ldisk -lftpio
-
-makedevs.c: Makefile rtermcap keymap.h
- rm -f makedevs.tmp
- echo '#include <sys/types.h>' > makedevs.tmp
- ./rtermcap ansi | \
- file2c 'const char termcap_ansi[] = {' ',0};' \
- >> makedevs.tmp
- ./rtermcap cons25 | \
- file2c 'const char termcap_cons25[] = {' ',0};' \
- >> makedevs.tmp
- ./rtermcap cons25-m | \
- file2c 'const char termcap_cons25_m[] = {' ',0};' \
- >> makedevs.tmp
- ./rtermcap cons25r | \
- file2c 'const char termcap_cons25r[] = {' ',0};' \
- >> makedevs.tmp
- ./rtermcap cons25r-m | \
- file2c 'const char termcap_cons25r_m[] = {' ',0};' \
- >> makedevs.tmp
- ./rtermcap cons25l1 | \
- file2c 'const char termcap_cons25l1[] = {' ',0};' \
- >> makedevs.tmp
- ./rtermcap cons25l1-m | \
- file2c 'const char termcap_cons25l1_m[] = {' ',0};' \
- >> makedevs.tmp
- ./rtermcap vt100 | \
- file2c 'const char termcap_vt100[] = {' ',0};' \
- >> makedevs.tmp
-.if ${MACHINE_ARCH} != "alpha"
- file2c 'u_char boot0[] = {' '};' < /boot/boot0 >> makedevs.tmp
- file2c 'u_char mbr[] = {' '};' < /boot/mbr >> makedevs.tmp
-.endif
- mv makedevs.tmp makedevs.c
-
-rtermcap: ${.CURDIR}/rtermcap.c
- ${CC} -o rtermcap ${.CURDIR}/rtermcap.c -ltermcap
-
-
-KEYMAPS= be.iso br275.iso danish.iso finnish.iso fr.iso \
- german.iso hr.iso hu.iso2.101keys it.iso icelandic.iso jp.106 \
- norwegian.iso pl_PL.ISO_8859-2 pt.iso ru.koi8-r si.iso \
- spanish.iso swedish.iso swissfrench.iso swissgerman.iso uk.iso \
- us.dvorak us.iso
-
-
-keymap.h:
- rm -f keymap.tmp
- for map in ${KEYMAPS} ; do \
- kbdcontrol -L $$map | \
- sed -e '/^static accentmap_t/,$$d' >> keymap.tmp ; \
- done
- echo "static struct keymapInfo keymapInfos[] = {" >> keymap.tmp
- for map in ${KEYMAPS} ; do \
- echo -n ' { "'$$map'", ' >> keymap.tmp ; \
- echo "&keymap_$$map }," | tr '[-.]' '_' >> keymap.tmp ; \
- done
- ( echo " { 0 }"; echo "};" ; echo "" ) >> keymap.tmp
- mv keymap.tmp keymap.h
-
-.include <bsd.prog.mk>
diff --git a/usr.sbin/sade/command.c b/usr.sbin/sade/command.c
deleted file mode 100644
index 3e3d5c97187d..000000000000
--- a/usr.sbin/sade/command.c
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last program in the `sysinstall' line - the next
- * generation being essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 "sysinstall.h"
-
-#define MAX_NUM_COMMANDS 10
-
-typedef struct {
- char key[FILENAME_MAX];
- struct {
- enum { CMD_SHELL, CMD_FUNCTION } type;
- void *ptr, *data;
- } cmds[MAX_NUM_COMMANDS];
- int ncmds;
-} Command;
-
-#define MAX_CMDS 200
-static Command *commandStack[MAX_CMDS];
-int numCommands;
-
-/* Nuke the command stack */
-void
-command_clear(void)
-{
- int i, j;
-
- for (i = 0; i < numCommands; i++)
- for (j = 0; j < commandStack[i]->ncmds; j++)
- if (commandStack[i]->cmds[j].type == CMD_SHELL)
- free(commandStack[i]->cmds[j].ptr);
- free(commandStack[i]);
- numCommands = 0;
-}
-
-static void
-addit(char *key, int type, void *cmd, void *data)
-{
- int i;
-
- /* First, look for the key already present and add a command to it if found */
- for (i = 0; i < numCommands; i++) {
- if (!strcmp(commandStack[i]->key, key)) {
- if (commandStack[i]->ncmds == MAX_NUM_COMMANDS)
- msgFatal("More than %d commands stacked up behind %s??", MAX_NUM_COMMANDS, key);
- commandStack[i]->cmds[commandStack[i]->ncmds].type = type;
- commandStack[i]->cmds[commandStack[i]->ncmds].ptr = cmd;
- commandStack[i]->cmds[commandStack[i]->ncmds].data = data;
- ++(commandStack[i]->ncmds);
- return;
- }
- }
- if (numCommands == MAX_CMDS)
- msgFatal("More than %d commands accumulated??", MAX_CMDS);
-
- /* If we fell to here, it's a new key */
- commandStack[numCommands] = safe_malloc(sizeof(Command));
- strcpy(commandStack[numCommands]->key, key);
- commandStack[numCommands]->ncmds = 1;
- commandStack[numCommands]->cmds[0].type = type;
- commandStack[numCommands]->cmds[0].ptr = cmd;
- commandStack[numCommands]->cmds[0].data = data;
- ++numCommands;
-}
-
-/* Add a shell command under a given key */
-void
-command_shell_add(char *key, char *fmt, ...)
-{
- va_list args;
- char *cmd;
-
- cmd = (char *)safe_malloc(256);
- va_start(args, fmt);
- vsnprintf(cmd, 256, fmt, args);
- va_end(args);
-
- addit(key, CMD_SHELL, cmd, NULL);
-}
-
-/* Add a shell command under a given key */
-void
-command_func_add(char *key, commandFunc func, void *data)
-{
- addit(key, CMD_FUNCTION, func, data);
-}
-
-static int
-sort_compare(Command *p1, Command *p2)
-{
- if (!p1 && !p2)
- return 0;
- else if (!p1 && p2) /* NULL has a "greater" value for commands */
- return 1;
- else if (p1 && !p2)
- return -1;
- else
- return strcmp(p1->key, p2->key);
-}
-
-void
-command_sort(void)
-{
- int i, j;
-
- commandStack[numCommands] = NULL;
- /* Just do a crude bubble sort since the list is small */
- for (i = 0; i < numCommands; i++) {
- for (j = 0; j < numCommands; j++) {
- if (sort_compare(commandStack[j], commandStack[j + 1]) > 0) {
- Command *tmp = commandStack[j];
-
- commandStack[j] = commandStack[j + 1];
- commandStack[j + 1] = tmp;
- }
- }
- }
-}
-
-/* Run all accumulated commands in sorted order */
-void
-command_execute(void)
-{
- int i, j, ret;
- commandFunc func;
-
- for (i = 0; i < numCommands; i++) {
- for (j = 0; j < commandStack[i]->ncmds; j++) {
- /* If it's a shell command, run system on it */
- if (commandStack[i]->cmds[j].type == CMD_SHELL) {
- msgNotify("Doing %s", commandStack[i]->cmds[j].ptr);
- ret = vsystem((char *)commandStack[i]->cmds[j].ptr);
- if (isDebug())
- msgDebug("Command `%s' returns status %d\n", commandStack[i]->cmds[j].ptr, ret);
- }
- else {
- /* It's a function pointer - call it with the key and the data */
- func = (commandFunc)commandStack[i]->cmds[j].ptr;
- if (isDebug())
- msgDebug("%x: Execute(%s, %s)", func, commandStack[i]->key, commandStack[i]->cmds[j].data);
- ret = (*func)(commandStack[i]->key, commandStack[i]->cmds[j].data);
- if (isDebug())
- msgDebug("Function @ %x returns status %d\n", commandStack[i]->cmds[j].ptr, ret);
- }
- }
- }
-}
diff --git a/usr.sbin/sade/config.c b/usr.sbin/sade/config.c
deleted file mode 100644
index cc4cbd2e3102..000000000000
--- a/usr.sbin/sade/config.c
+++ /dev/null
@@ -1,880 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last program in the `sysinstall' line - the next
- * generation being essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 "sysinstall.h"
-#include <sys/disklabel.h>
-#include <sys/wait.h>
-#include <sys/errno.h>
-#include <sys/ioctl.h>
-#include <sys/fcntl.h>
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <sys/mount.h>
-
-static Chunk *chunk_list[MAX_CHUNKS];
-static int nchunks;
-static int rootdev_is_od;
-
-/* arg to sort */
-static int
-chunk_compare(Chunk *c1, Chunk *c2)
-{
- if (!c1 && !c2)
- return 0;
- else if (!c1 && c2)
- return 1;
- else if (c1 && !c2)
- return -1;
- else if (!c1->private_data && !c2->private_data)
- return 0;
- else if (c1->private_data && !c2->private_data)
- return 1;
- else if (!c1->private_data && c2->private_data)
- return -1;
- else
- return strcmp(((PartInfo *)(c1->private_data))->mountpoint, ((PartInfo *)(c2->private_data))->mountpoint);
-}
-
-static void
-chunk_sort(void)
-{
- int i, j;
-
- for (i = 0; i < nchunks; i++) {
- for (j = 0; j < nchunks; j++) {
- if (chunk_compare(chunk_list[j], chunk_list[j + 1]) > 0) {
- Chunk *tmp = chunk_list[j];
-
- chunk_list[j] = chunk_list[j + 1];
- chunk_list[j + 1] = tmp;
- }
- }
- }
-}
-
-static void
-check_rootdev(Chunk **list, int n)
-{
- int i;
- Chunk *c;
-
- rootdev_is_od = 0;
- for (i = 0; i < n; i++) {
- c = *list++;
- if (c->type == part && (c->flags & CHUNK_IS_ROOT)
- && strncmp(c->disk->name, "od", 2) == 0)
- rootdev_is_od = 1;
- }
-}
-
-static char *
-name_of(Chunk *c1)
-{
- return c1->name;
-}
-
-static char *
-mount_point(Chunk *c1)
-{
- if (c1->type == part && c1->subtype == FS_SWAP)
- return "none";
- else if (c1->type == part || c1->type == fat)
- return ((PartInfo *)c1->private_data)->mountpoint;
- return "/bogus";
-}
-
-static char *
-fstype(Chunk *c1)
-{
- if (c1->type == fat)
- return "msdos";
- else if (c1->type == part) {
- if (c1->subtype != FS_SWAP)
- return "ufs";
- else
- return "swap";
- }
- return "bogus";
-}
-
-static char *
-fstype_short(Chunk *c1)
-{
- if (c1->type == part) {
- if (c1->subtype != FS_SWAP) {
- if (rootdev_is_od == 0 && strncmp(c1->name, "od", 2) == 0)
- return "rw,noauto";
- else
- return "rw";
- }
- else
- return "sw";
- }
- else if (c1->type == fat) {
- if (strncmp(c1->name, "od", 2) == 0)
- return "ro,noauto";
- else
- return "ro";
- }
- return "bog";
-}
-
-static int
-seq_num(Chunk *c1)
-{
- if (c1->type == part && c1->subtype != FS_SWAP) {
- if (rootdev_is_od == 0 && strncmp(c1->name, "od", 2) == 0)
- return 0;
- else if (c1->flags & CHUNK_IS_ROOT)
- return 1;
- else
- return 2;
- }
- return 0;
-}
-
-int
-configFstab(dialogMenuItem *self)
-{
- Device **devs;
- Disk *disk;
- FILE *fstab;
- int i, cnt;
- Chunk *c1, *c2;
-
- if (!RunningAsInit) {
- if (file_readable("/etc/fstab"))
- return DITEM_SUCCESS;
- else {
- msgConfirm("Attempting to rebuild your /etc/fstab file. Warning: If you had\n"
- "any CD devices in use before running sysinstall then they may NOT\n"
- "be found by this run!");
- }
- }
-
- devs = deviceFind(NULL, DEVICE_TYPE_DISK);
- if (!devs) {
- msgConfirm("No disks found!");
- return DITEM_FAILURE;
- }
-
- /* Record all the chunks */
- nchunks = 0;
- for (i = 0; devs[i]; i++) {
- if (!devs[i]->enabled)
- continue;
- disk = (Disk *)devs[i]->private;
- if (!disk->chunks)
- msgFatal("No chunk list found for %s!", disk->name);
- for (c1 = disk->chunks->part; c1; c1 = c1->next) {
- if (c1->type == freebsd) {
- for (c2 = c1->part; c2; c2 = c2->next) {
- if (c2->type == part && (c2->subtype == FS_SWAP || c2->private_data))
- chunk_list[nchunks++] = c2;
- }
- }
- else if (c1->type == fat && c1->private_data)
- chunk_list[nchunks++] = c1;
- }
- }
- chunk_list[nchunks] = 0;
- chunk_sort();
-
- fstab = fopen("/etc/fstab", "w");
- if (!fstab) {
- msgConfirm("Unable to create a new /etc/fstab file! Manual intervention\n"
- "will be required.");
- return DITEM_FAILURE;
- }
-
- check_rootdev(chunk_list, nchunks);
-
- /* Go for the burn */
- msgDebug("Generating /etc/fstab file\n");
- fprintf(fstab, "# Device\t\tMountpoint\tFStype\tOptions\t\tDump\tPass#\n");
- for (i = 0; i < nchunks; i++)
- fprintf(fstab, "/dev/%s\t\t%s\t\t%s\t%s\t\t%d\t%d\n", name_of(chunk_list[i]), mount_point(chunk_list[i]),
- fstype(chunk_list[i]), fstype_short(chunk_list[i]), seq_num(chunk_list[i]), seq_num(chunk_list[i]));
-
- /* Now look for the CDROMs */
- devs = deviceFind(NULL, DEVICE_TYPE_CDROM);
- cnt = deviceCount(devs);
-
- /* Write out the CDROM entries */
- for (i = 0; i < cnt; i++) {
- char cdname[10];
-
- sprintf(cdname, "/cdrom%s", i ? itoa(i) : "");
- if (Mkdir(cdname))
- msgConfirm("Unable to make mount point for: %s", cdname);
- else
- fprintf(fstab, "/dev/%s\t\t%s\tcd9660\tro,noauto\t0\t0\n", devs[i]->name, cdname);
- }
-
- /* And finally, a /proc. */
- fprintf(fstab, "proc\t\t\t/proc\t\tprocfs\trw\t\t0\t0\n");
- Mkdir("/proc");
-
- fclose(fstab);
- if (isDebug())
- msgDebug("Wrote out /etc/fstab file\n");
- return DITEM_SUCCESS;
-}
-
-/* Do the work of sucking in a config file.
- * config is the filename to read in.
- * lines is a fixed (max) sized array of char*
- * returns number of lines read. line contents
- * are malloc'd and must be freed by the caller.
- */
-int
-readConfig(char *config, char **lines, int max)
-{
- FILE *fp;
- char line[256];
- int i, nlines;
-
- fp = fopen(config, "r");
- if (!fp)
- return -1;
-
- nlines = 0;
- /* Read in the entire file */
- for (i = 0; i < max; i++) {
- if (!fgets(line, sizeof line, fp))
- break;
- lines[nlines++] = strdup(line);
- }
- fclose(fp);
- if (isDebug())
- msgDebug("readConfig: Read %d lines from %s.\n", nlines, config);
- return nlines;
-}
-
-#define MAX_LINES 2000 /* Some big number we're not likely to ever reach - I'm being really lazy here, I know */
-
-static void
-readConfigFile(char *config, int marked)
-{
- char *lines[MAX_LINES], *cp, *cp2;
- int i, nlines;
-
- nlines = readConfig(config, lines, MAX_LINES);
- if (nlines == -1)
- return;
-
- for (i = 0; i < nlines; i++) {
- /* Skip the comments & non-variable settings */
- if (lines[i][0] == '#' || !(cp = index(lines[i], '='))) {
- free(lines[i]);
- continue;
- }
- *cp++ = '\0';
- /* Find quotes */
- if ((cp2 = index(cp, '"')) || (cp2 = index(cp, '\047'))) {
- cp = cp2 + 1;
- cp2 = index(cp, *cp2);
- }
- /* If valid quotes, use it */
- if (cp2) {
- *cp2 = '\0';
- /* If we have a legit value, set it */
- if (strlen(cp))
- variable_set2(lines[i], cp, marked);
- }
- free(lines[i]);
- }
-}
-
-/* Load the environment from rc.conf file(s) */
-void
-configEnvironmentRC_conf(void)
-{
- static struct {
- char *fname;
- int marked;
- } configs[] = {
- { "/etc/defaults/rc.conf", 0 },
- { "/etc/rc.conf", 0 },
- { "/etc/rc.conf.local", 0 },
- { NULL, 0 },
- };
- int i;
-
- for (i = 0; configs[i].fname; i++) {
- if (file_readable(configs[i].fname))
- readConfigFile(configs[i].fname, configs[i].marked);
- }
-}
-
-/* Load the environment from a resolv.conf file */
-void
-configEnvironmentResolv(char *config)
-{
- char *lines[MAX_LINES];
- int i, nlines;
-
- nlines = readConfig(config, lines, MAX_LINES);
- if (nlines == -1)
- return;
- for (i = 0; i < nlines; i++) {
- Boolean name_set = (Boolean)variable_get(VAR_NAMESERVER);
-
- if (!strncmp(lines[i], "domain", 6) && !variable_get(VAR_DOMAINNAME))
- variable_set2(VAR_DOMAINNAME, string_skipwhite(string_prune(lines[i] + 6)), 0);
- else if (!name_set && !strncmp(lines[i], "nameserver", 10)) {
- /* Only take the first nameserver setting - we're lame */
- variable_set2(VAR_NAMESERVER, string_skipwhite(string_prune(lines[i] + 10)), 0);
- }
- free(lines[i]);
- }
-}
-
-/* Set up the make.conf file */
-void
-configMake_conf(char *config)
-{
- char *lines[MAX_LINES];
- int i, nlines;
- FILE *fp;
-
- if (!file_readable(config)) {
- char *line = malloc(21);
- sprintf(line, "USA_RESIDENT=%s\n", USAResident ? "YES" : "NO");
- lines[0] = line;
- nlines = 1;
- }
- else {
- nlines = readConfig(config, lines, MAX_LINES);
- if (nlines == -1)
- return;
- for (i = 0; i < nlines; i++) {
- if (!strncmp(lines[i], "USA_RESIDENT", 12)) {
- free(lines[i]);
- lines[i] = malloc(21); /* big enough */
- sprintf(lines[i], "USA_RESIDENT=%s\n", USAResident ? "YES" : "NO");
- }
- }
- }
- if ((fp = fopen(config, "w")) != NULL) {
- for (i = 0; i < nlines; i++) {
- fprintf(fp, "%s", lines[i]);
- free(lines[i]);
- }
- fclose(fp);
- }
-}
-
-/* Version of below for dispatch routines */
-int
-configRC(dialogMenuItem *unused)
-{
- configRC_conf();
- return DITEM_SUCCESS;
-}
-
-void
-configRC_conf(void)
-{
- FILE *rcSite;
- Variable *v;
- int write_header;
- static int did_marker = 0;
-
- write_header = !file_readable("/etc/rc.conf");
- rcSite = fopen("/etc/rc.conf", "a");
- if (!rcSite)
- return;
- if (write_header) {
- fprintf(rcSite, "# This file now contains just the overrides from /etc/defaults/rc.conf\n");
- fprintf(rcSite, "# please make all changes to this file.\n\n");
- }
-
- /* Now do variable substitutions */
- for (v = VarHead; v; v = v->next) {
- if (v->dirty) {
- if (!did_marker) {
- fprintf(rcSite, "# -- sysinstall generated deltas -- #\n");
- did_marker = 1;
- }
- fprintf(rcSite, "%s=\"%s\"\n", v->name, v->value);
- v->dirty = 0;
- }
- }
- fclose(rcSite);
-}
-
-int
-configSaver(dialogMenuItem *self)
-{
- variable_set((char *)self->data, 1);
- if (!variable_get(VAR_BLANKTIME))
- variable_set2(VAR_BLANKTIME, "300", 1);
- return DITEM_SUCCESS;
-}
-
-int
-configSaverTimeout(dialogMenuItem *self)
-{
- return (variable_get_value(VAR_BLANKTIME,
- "Enter time-out period in seconds for screen saver", 1) ?
- DITEM_SUCCESS : DITEM_FAILURE);
-}
-
-int
-configNTP(dialogMenuItem *self)
-{
- int status;
-
- status = variable_get_value(VAR_NTPDATE_FLAGS,
- "Enter the name of an NTP server", 1)
- ? DITEM_SUCCESS : DITEM_FAILURE;
- if (status == DITEM_SUCCESS) {
- static char tmp[255];
-
- snprintf(tmp, sizeof(tmp), "ntpdate_enable=YES,ntpdate_flags=%s",
- variable_get(VAR_NTPDATE_FLAGS));
- self->data = tmp;
- dmenuSetVariables(self);
- }
- return status;
-}
-
-int
-configUsers(dialogMenuItem *self)
-{
- WINDOW *w = savescr();
-
- dialog_clear_norefresh();
- dmenuOpenSimple(&MenuUsermgmt, FALSE);
- restorescr(w);
- return DITEM_SUCCESS;
-}
-
-int
-configLinux(dialogMenuItem *self)
-{
- WINDOW *w = savescr();
- int i;
-
- dialog_clear_norefresh();
- variable_set2(VAR_LINUX_ENABLE, "YES", 1);
- Mkdir("/compat/linux");
- msgNotify("Installing Linux compatibility library...");
- i = package_add("linux_base");
- restorescr(w);
- return i;
-}
-
-static void
-write_root_xprofile(char *str)
-{
- FILE *fp;
- int len;
- char **cp;
- static char *flist[] = { /* take care of both xdm and startx */
- "/root/.xinitrc",
- "/root/.xsession",
- "/usr/share/skel/dot.xinitrc",
- "/usr/share/skel/dot.xsession",
- NULL,
- };
-
- len = strlen(str);
- for (cp = flist; *cp; cp++) {
- fp = fopen(*cp, "w");
- if (fp) {
- fwrite(str, 1, len, fp);
- fchmod(fileno(fp), 0755);
- fclose(fp);
- }
- }
-}
-
-static int
-gotit(char *fname)
-{
- char tmp[FILENAME_MAX];
-
- snprintf(tmp, sizeof tmp, "/usr/X11R6/bin/%s", fname);
- if (file_executable(tmp))
- return TRUE;
- snprintf(tmp, sizeof tmp, "/usr/local/bin/%s", fname);
- return file_executable(tmp);
-}
-
-int
-configXDesktop(dialogMenuItem *self)
-{
- char *desk;
- int ret = DITEM_SUCCESS;
- WINDOW *w = savescr();
-
- dialog_clear_norefresh();
- if (!dmenuOpenSimple(&MenuXDesktops, FALSE) || !(desk = variable_get(VAR_DESKSTYLE))) {
- restorescr(w);
- return DITEM_FAILURE;
- }
- if (!strcmp(desk, "kde")) {
- ret = package_add("kde");
- if (DITEM_STATUS(ret) != DITEM_FAILURE && gotit("startkde"))
- write_root_xprofile("exec startkde\n");
- }
- else if (!strcmp(desk, "gnome")) {
- ret = package_add("gnomecore");
- if (DITEM_STATUS(ret) != DITEM_FAILURE && gotit("gnome-session")) {
- ret = package_add("afterstep");
- if (DITEM_STATUS(ret) != DITEM_FAILURE && gotit("afterstep"))
- write_root_xprofile("gnome-session &\nexec afterstep");
- }
- }
- else if (!strcmp(desk, "enlightenment")) {
- ret = package_add("gnomecore");
- if (DITEM_STATUS(ret) != DITEM_FAILURE && gotit("gnome-session")) {
- ret = package_add("enlightenment");
- if (DITEM_STATUS(ret) != DITEM_FAILURE && gotit("enlightenment"))
- write_root_xprofile("exec gnome-session\n");
- }
- }
- else if (!strcmp(desk, "afterstep")) {
- ret = package_add("afterstep");
- if (DITEM_STATUS(ret) != DITEM_FAILURE && gotit("afterstep"))
- write_root_xprofile("xterm &\nexec afterstep\n");
- }
- else if (!strcmp(desk, "windowmaker")) {
- ret = package_add("windowmaker");
- if (DITEM_STATUS(ret) != DITEM_FAILURE && gotit("wmaker.inst")) {
- write_root_xprofile("xterm &\n[ ! -d $HOME/GNUstep/Library/WindowMaker ] && /usr/X11R6/bin/wmaker.inst\nexec /usr/X11R6/bin/wmaker\n");
- }
- }
- else if (!strcmp(desk, "fvwm2")) {
- ret = package_add("fvwm");
- if (DITEM_STATUS(ret) != DITEM_FAILURE && gotit("fvwm2"))
- write_root_xprofile("xterm &\nexec fvwm2\n");
- }
- if (DITEM_STATUS(ret) == DITEM_FAILURE)
- msgConfirm("An error occurred while adding the package(s) required\n"
- "by this desktop type. Please change installation media\n"
- "and/or select a different, perhaps simpler, desktop\n"
- "environment and try again.");
- restorescr(w);
- return ret;
-}
-
-int
-configXSetup(dialogMenuItem *self)
-{
- char *config, *execfile, *style;
- char *moused;
- WINDOW *w = savescr();
-
- setenv("XWINHOME", "/usr/X11R6", 1);
-tryagain:
- variable_unset(VAR_DESKSTYLE);
- variable_unset(VAR_XF86_CONFIG);
- dialog_clear_norefresh();
- if (!dmenuOpenSimple(&MenuXF86Config, FALSE)) {
- restorescr(w);
- return DITEM_FAILURE;
- }
- config = variable_get(VAR_XF86_CONFIG);
- style = variable_get(VAR_DESKSTYLE);
- if (!config) {
- if (style)
- goto config_desktop;
- else {
- restorescr(w);
- return DITEM_FAILURE;
- }
- }
-
- if (file_readable("/var/run/ld.so.hints"))
- vsystem("/sbin/ldconfig -m /usr/lib /usr/X11R6/lib /usr/local/lib /usr/lib/compat");
- else
- vsystem("/sbin/ldconfig /usr/lib /usr/X11R6/lib /usr/local/lib /usr/lib/compat");
- vsystem("/sbin/ifconfig lo0 127.0.0.1");
- execfile = string_concat("/usr/X11R6/bin/", config);
- if (file_executable(execfile)) {
- moused = variable_get(VAR_MOUSED);
- while (!moused || strcmp(moused, "YES")) {
- if (msgYesNo("The X server may access the mouse in two ways: direct access\n"
- "or indirect access via the mouse daemon. You have not\n"
- "configured the mouse daemon. Would you like to configure it\n"
- "now? If you intend to let the X server access the mouse\n"
- "directly, choose \"No\" at this time."))
- break;
- dialog_clear_norefresh();
- dmenuOpenSimple(&MenuMouse, FALSE);
- moused = variable_get(VAR_MOUSED);
- }
- if (moused && !strcmp(moused, "YES"))
- msgConfirm("You have configured and are now running the mouse daemon.\n"
- "Choose \"/dev/sysmouse\" as the mouse port and \"SysMouse\" or\n"
- "\"MouseSystems\" as the mouse protocol in the X configuration\n"
- "utility.");
- systemExecute(execfile);
- if (!file_readable("/etc/XF86Config")) {
- if (!msgYesNo("The XFree86 configuration process seems to have\nfailed. Would you like to try again?"))
- goto tryagain;
- else {
- restorescr(w);
- return DITEM_FAILURE;
- }
- }
-config_desktop:
- configXDesktop(self);
- restorescr(w);
- return DITEM_SUCCESS;
- }
- else {
- msgConfirm("The XFree86 setup utility you chose does not appear to be installed!\n"
- "Please install this before attempting to configure XFree86.");
- restorescr(w);
- return DITEM_FAILURE;
- }
-}
-
-int
-configResolv(dialogMenuItem *ditem)
-{
- FILE *fp;
- char *cp, *dp, *hp;
-
- cp = variable_get(VAR_NAMESERVER);
- if (!cp || !*cp)
- goto skip;
- Mkdir("/etc");
- fp = fopen("/etc/resolv.conf", "w");
- if (!fp)
- return DITEM_FAILURE;
- if (variable_get(VAR_DOMAINNAME))
- fprintf(fp, "domain\t%s\n", variable_get(VAR_DOMAINNAME));
- fprintf(fp, "nameserver\t%s\n", cp);
- fclose(fp);
- if (isDebug())
- msgDebug("Wrote out /etc/resolv.conf\n");
-
-skip:
- dp = variable_get(VAR_DOMAINNAME);
- cp = variable_get(VAR_IPADDR);
- hp = variable_get(VAR_HOSTNAME);
- /* Tack ourselves into /etc/hosts */
- fp = fopen("/etc/hosts", "w");
- if (!fp)
- return DITEM_FAILURE;
- /* Add an entry for localhost */
- if (dp)
- fprintf(fp, "127.0.0.1\t\tlocalhost.%s localhost\n", dp);
- else
- fprintf(fp, "127.0.0.1\t\tlocalhost\n");
- /* Now the host entries, if applicable */
- if (cp && cp[0] != '0' && hp) {
- char cp2[255];
-
- if (!index(hp, '.'))
- cp2[0] = '\0';
- else {
- SAFE_STRCPY(cp2, hp);
- *(index(cp2, '.')) = '\0';
- }
- fprintf(fp, "%s\t\t%s %s\n", cp, hp, cp2);
- fprintf(fp, "%s\t\t%s.\n", cp, hp);
- }
- fclose(fp);
- if (isDebug())
- msgDebug("Wrote out /etc/hosts\n");
- return DITEM_SUCCESS;
-}
-
-int
-configRouter(dialogMenuItem *self)
-{
- int ret;
-
- ret = variable_get_value(VAR_ROUTER,
- "Please specify the router you wish to use. Routed is\n"
- "provided with the stock system and gated is provided\n"
- "as an optional package which this installation system\n"
- "will attempt to load if you select gated. Any other\n"
- "choice of routing daemon will be assumed to be something\n"
- "the user intends to install themselves before rebooting\n"
- "the system. If you don't want any routing daemon, choose NO", 1)
- ? DITEM_SUCCESS : DITEM_FAILURE;
-
- if (ret == DITEM_SUCCESS) {
- char *cp = variable_get(VAR_ROUTER);
-
- if (cp && strcmp(cp, "NO")) {
- variable_set2(VAR_ROUTER_ENABLE, "YES", 1);
- if (!strcmp(cp, "gated")) {
- if (package_add("gated") != DITEM_SUCCESS) {
- msgConfirm("Unable to load gated package. Falling back to no router.");
- variable_unset(VAR_ROUTER);
- variable_unset(VAR_ROUTERFLAGS);
- variable_set2(VAR_ROUTER_ENABLE, "NO", 1);
- cp = NULL;
- }
- }
- if (cp) {
- /* Now get the flags, if they chose a router */
- ret = variable_get_value(VAR_ROUTERFLAGS,
- "Please Specify the routing daemon flags; if you're running routed\n"
- "then -q is the right choice for nodes and -s for gateway hosts.\n", 1)
- ? DITEM_SUCCESS : DITEM_FAILURE;
- if (ret != DITEM_SUCCESS)
- variable_unset(VAR_ROUTERFLAGS);
- }
- }
- else {
- /* No router case */
- variable_set2(VAR_ROUTER_ENABLE, "NO", 1);
- variable_unset(VAR_ROUTERFLAGS);
- variable_unset(VAR_ROUTER);
- }
- }
- else {
- variable_set2(VAR_ROUTER_ENABLE, "NO", 1);
- variable_unset(VAR_ROUTERFLAGS);
- variable_unset(VAR_ROUTER);
- }
- return ret;
-}
-
-/* Shared between us and index_initialize() */
-extern PkgNode Top, Plist;
-
-int
-configPackages(dialogMenuItem *self)
-{
- int i, restoreflag = 0;
- PkgNodePtr tmp;
-
- /* Did we get an INDEX? */
- i = index_initialize("packages/INDEX");
- if (DITEM_STATUS(i) == DITEM_FAILURE)
- return i;
-
- while (1) {
- int ret, pos, scroll;
-
- /* Bring up the packages menu */
- pos = scroll = 0;
- index_menu(&Top, &Top, &Plist, &pos, &scroll);
-
- if (Plist.kids && Plist.kids->name) {
- /* Now show the packing list menu */
- pos = scroll = 0;
- ret = index_menu(&Plist, &Plist, NULL, &pos, &scroll);
- if (ret & DITEM_LEAVE_MENU)
- break;
- else if (DITEM_STATUS(ret) != DITEM_FAILURE) {
- dialog_clear();
- restoreflag = 1;
- for (tmp = Plist.kids; tmp && tmp->name; tmp = tmp->next)
- (void)index_extract(mediaDevice, &Top, tmp, FALSE);
- break;
- }
- }
- else {
- msgConfirm("No packages were selected for extraction.");
- break;
- }
- }
- tmp = Plist.kids;
- while (tmp) {
- PkgNodePtr tmp2 = tmp->next;
-
- safe_free(tmp);
- tmp = tmp2;
- }
- index_init(NULL, &Plist);
- return DITEM_SUCCESS | (restoreflag ? DITEM_RESTORE : 0);
-}
-
-/* Load pcnfsd package */
-int
-configPCNFSD(dialogMenuItem *self)
-{
- int ret;
-
- ret = package_add("pcnfsd");
- if (DITEM_STATUS(ret) == DITEM_SUCCESS) {
- variable_set2(VAR_PCNFSD, "YES", 0);
- variable_set2("mountd_flags", "-n", 1);
- }
- return ret;
-}
-
-int
-configNFSServer(dialogMenuItem *self)
-{
- char cmd[256];
-
- /* If we're an NFS server, we need an exports file */
- if (!file_readable("/etc/exports")) {
- WINDOW *w = savescr();
-
- if (file_readable("/etc/exports.disabled"))
- vsystem("mv /etc/exports.disabled /etc/exports");
- else {
- dialog_clear_norefresh();
- msgConfirm("Operating as an NFS server means that you must first configure\n"
- "an /etc/exports file to indicate which hosts are allowed certain\n"
- "kinds of access to your local file systems.\n"
- "Press [ENTER] now to invoke an editor on /etc/exports\n");
- vsystem("echo '#The following examples export /usr to 3 machines named after ducks,' > /etc/exports");
- vsystem("echo '#/home and all directories under it to machines named after dead rock stars' >> /etc/exports");
- vsystem("echo '#and, finally, /a to 2 privileged machines allowed to write on it as root.' >> /etc/exports");
- vsystem("echo '#/usr huey louie dewie' >> /etc/exports");
- vsystem("echo '#/home -alldirs janice jimmy frank' >> /etc/exports");
- vsystem("echo '#/a -maproot=0 bill albert' >> /etc/exports");
- vsystem("echo '#' >> /etc/exports");
- vsystem("echo '# You should replace these lines with your actual exported filesystems.' >> /etc/exports");
- vsystem("echo >> /etc/exports");
- sprintf(cmd, "%s /etc/exports", variable_get(VAR_EDITOR));
- dialog_clear();
- systemExecute(cmd);
- }
- variable_set2(VAR_NFS_SERVER, "YES", 1);
- restorescr(w);
- }
- else if (variable_get(VAR_NFS_SERVER)) { /* We want to turn it off again? */
- vsystem("mv -f /etc/exports /etc/exports.disabled");
- variable_unset(VAR_NFS_SERVER);
- }
- return DITEM_SUCCESS;
-}
diff --git a/usr.sbin/sade/devices.c b/usr.sbin/sade/devices.c
deleted file mode 100644
index f51d55575be8..000000000000
--- a/usr.sbin/sade/devices.c
+++ /dev/null
@@ -1,560 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last program in the `sysinstall' line - the next
- * generation being essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 "sysinstall.h"
-#include <sys/fcntl.h>
-#include <sys/param.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/errno.h>
-#include <sys/time.h>
-#include <net/if.h>
-#include <net/if_var.h>
-#include <net/if_dl.h>
-#include <netinet/in.h>
-#include <netinet/in_var.h>
-#include <arpa/inet.h>
-#include <ctype.h>
-
-/* how much to bias minor number for a given /dev/<ct#><un#>s<s#> slice */
-#define SLICE_DELTA (0x10000)
-
-static Device *Devices[DEV_MAX];
-static int numDevs;
-
-static struct _devname {
- DeviceType type;
- char *name;
- char *description;
- int major, minor, delta, max;
- char dev_type;
-} device_names[] = {
- { DEVICE_TYPE_CDROM, "cd%dc", "SCSI CDROM drive", 6, 2, 8, 4, 'b' },
- { DEVICE_TYPE_CDROM, "mcd%da", "Mitsumi (old model) CDROM drive", 7, 0, 8, 4, 'b' },
- { DEVICE_TYPE_CDROM, "scd%da", "Sony CDROM drive - CDU31/33A type", 16, 0, 8, 4, 'b' },
-#ifdef notdef
- { DEVICE_TYPE_CDROM, "matcd%da", "Matsushita CDROM ('sound blaster' type)", 17, 0, 8, 4, 'b' },
-#endif
- { DEVICE_TYPE_CDROM, "acd%dc", "ATAPI/IDE CDROM", 31, 2, 8, 4, 'b' },
- { DEVICE_TYPE_TAPE, "rsa%d", "SCSI tape drive", 14, 0, 16, 4, 'c' },
- { DEVICE_TYPE_TAPE, "rwt%d", "Wangtek tape drive", 10, 0, 1, 4, 'c' },
- { DEVICE_TYPE_DISK, "da%d", "SCSI disk device", 4, 65538, 8, 16, 'b' },
- { DEVICE_TYPE_DISK, "rda%d", "SCSI disk device", 13, 65538, 8, 16, 'c' },
- { DEVICE_TYPE_DISK, "ad%d", "ATA/IDE disk device", 30, 65538, 8, 16, 'b' },
- { DEVICE_TYPE_DISK, "rad%d", "ATA/IDE disk device", 116, 65538, 8, 16, 'c' },
- { DEVICE_TYPE_DISK, "fla%d", "M-Systems DiskOnChip Flash device", 28, 65538, 8, 16, 'b' },
- { DEVICE_TYPE_DISK, "rfla%d", "M-Systems DiskOnChip Flash devicee", 102, 65538, 8, 16, 'c' },
- { DEVICE_TYPE_DISK, "afd%d", "ATAPI/IDE floppy device", 32, 65538, 8, 4, 'b' },
- { DEVICE_TYPE_DISK, "rafd%d", "ATAPI/IDE floppy device", 118, 65538, 8, 4, 'c' },
- { DEVICE_TYPE_DISK, "mlxd%d", "Mylex RAID disk", 27, 65538, 8, 4, 'b' },
- { DEVICE_TYPE_DISK, "rmlxd%d", "Mylex RAID disk", 131, 65538, 8, 4, 'c' },
- { DEVICE_TYPE_DISK, "amrd%d", "AMI MegaRAID drive", 35, 65538, 8, 4, 'b' },
- { DEVICE_TYPE_DISK, "ramrd%d", "AMI MegaRAID drive", 133, 65538, 8, 4, 'c' },
- { DEVICE_TYPE_DISK, "idad%d", "Compaq RAID array", 29, 65538, 8, 4, 'b' },
- { DEVICE_TYPE_DISK, "ridad%d", "Compaq RAID array", 109, 65538, 8, 4, 'c' },
- { DEVICE_TYPE_FLOPPY, "fd%d", "floppy drive unit A", 2, 0, 64, 4, 'b' },
- { DEVICE_TYPE_FLOPPY, "worm%d", "SCSI optical disk / CDR", 23, 0, 1, 4, 'b' },
- { DEVICE_TYPE_NETWORK, "aue", "ADMtek USB ethernet adapter" },
- { DEVICE_TYPE_NETWORK, "cue", "CATC USB ethernet adapter" },
- { DEVICE_TYPE_NETWORK, "fpa", "DEC DEFPA PCI FDDI card" },
- { DEVICE_TYPE_NETWORK, "sr", "SDL T1/E1 sync serial PCI card" },
- { DEVICE_TYPE_NETWORK, "cc3i", "SDL HSSI sync serial PCI card" },
- { DEVICE_TYPE_NETWORK, "en", "Efficient Networks ATM PCI card" },
- { DEVICE_TYPE_NETWORK, "dc", "DEC/Intel 21143 (and clones) PCI fast ethernet card" },
- { DEVICE_TYPE_NETWORK, "de", "DEC DE435 PCI NIC or other DC21040-AA based card" },
- { DEVICE_TYPE_NETWORK, "fxp", "Intel EtherExpress Pro/100B PCI Fast Ethernet card" },
- { DEVICE_TYPE_NETWORK, "ed", "Novell NE1000/2000; 3C503; NE2000-compatible PCMCIA" },
- { DEVICE_TYPE_NETWORK, "ep", "3Com 3C509 ethernet card/3C589 PCMCIA" },
- { DEVICE_TYPE_NETWORK, "el", "3Com 3C501 ethernet card" },
- { DEVICE_TYPE_NETWORK, "ex", "Intel EtherExpress Pro/10 ethernet card" },
- { DEVICE_TYPE_NETWORK, "fe", "Fujitsu MB86960A/MB86965A ethernet card" },
- { DEVICE_TYPE_NETWORK, "ie", "AT&T StarLAN 10 and EN100; 3Com 3C507; NI5210" },
- { DEVICE_TYPE_NETWORK, "ix", "Intel Etherexpress ethernet card" },
- { DEVICE_TYPE_NETWORK, "kue", "Kawasaki LSI USB ethernet adapter" },
- { DEVICE_TYPE_NETWORK, "le", "DEC EtherWorks 2 or 3 ethernet card" },
- { DEVICE_TYPE_NETWORK, "lnc", "Lance/PCnet (Isolan/Novell NE2100/NE32-VL) ethernet" },
- { DEVICE_TYPE_NETWORK, "rl", "RealTek 8129/8139 PCI ethernet card" },
- { DEVICE_TYPE_NETWORK, "sf", "Adaptec AIC-6915 PCI ethernet card" },
- { DEVICE_TYPE_NETWORK, "sis", "SiS 900/SiS 7016 PCI ethernet card" },
- { DEVICE_TYPE_NETWORK, "sn", "SMC/Megahertz ethernet card" },
- { DEVICE_TYPE_NETWORK, "ste", "Sundance ST201 PCI ethernet card" },
- { DEVICE_TYPE_NETWORK, "sk", "SysKonnect PCI gigabit ethernet card" },
- { DEVICE_TYPE_NETWORK, "tx", "SMC 9432TX ethernet card" },
- { DEVICE_TYPE_NETWORK, "ti", "Alteon Networks PCI gigabit ethernet card" },
- { DEVICE_TYPE_NETWORK, "tl", "Texas Instruments ThunderLAN PCI ethernet card" },
- { DEVICE_TYPE_NETWORK, "vr", "VIA VT3043/VT86C100A Rhine PCI ethernet card" },
- { DEVICE_TYPE_NETWORK, "vx", "3COM 3c590 / 3c595 ethernet card" },
- { DEVICE_TYPE_NETWORK, "wb", "Winbond W89C840F PCI ethernet card" },
- { DEVICE_TYPE_NETWORK, "xl", "3COM 3c90x / 3c90xB PCI ethernet card" },
- { DEVICE_TYPE_NETWORK, "cuaa%d", "%s on device %s (COM%d)", 28, 128, 1, 16, 'c' },
- { DEVICE_TYPE_NETWORK, "lp", "Parallel Port IP (PLIP) peer connection" },
- { DEVICE_TYPE_NETWORK, "lo", "Loop-back (local) network interface" },
- { 0 },
-};
-
-Device *
-new_device(char *name)
-{
- Device *dev;
-
- dev = safe_malloc(sizeof(Device));
- bzero(dev, sizeof(Device));
- if (name)
- SAFE_STRCPY(dev->name, name);
- return dev;
-}
-
-/* Stubs for unimplemented strategy routines */
-Boolean
-dummyInit(Device *dev)
-{
- return TRUE;
-}
-
-FILE *
-dummyGet(Device *dev, char *dist, Boolean probe)
-{
- return NULL;
-}
-
-void
-dummyShutdown(Device *dev)
-{
- return;
-}
-
-static int
-deviceTry(struct _devname dev, char *try, int i)
-{
- int fd;
- char unit[80];
- mode_t m;
- dev_t d;
- int fail;
-
- snprintf(unit, sizeof unit, dev.name, i);
- snprintf(try, FILENAME_MAX, "/dev/%s", unit);
- if (isDebug())
- msgDebug("deviceTry: attempting to open %s\n", try);
- fd = open(try, O_RDONLY);
- if (fd >= 0) {
- if (isDebug())
- msgDebug("deviceTry: open of %s succeeded on first try.\n", try);
- return fd;
- }
- m = 0640;
- if (dev.dev_type == 'c')
- m |= S_IFCHR;
- else
- m |= S_IFBLK;
- d = makedev(dev.major, dev.minor + (i * dev.delta));
- if (isDebug())
- msgDebug("deviceTry: Making %s device for %s [%d, %d]\n", m & S_IFCHR ? "raw" : "block", try, dev.major, dev.minor + (i * dev.delta));
- fail = mknod(try, m, d);
- fd = open(try, O_RDONLY);
- if (fd >= 0) {
- if (isDebug())
- msgDebug("deviceTry: open of %s succeeded on second try.\n", try);
- return fd;
- }
- else if (!fail)
- (void)unlink(try);
- /* Don't try a "make-under" here since we're using a fixit floppy in this case */
- snprintf(try, FILENAME_MAX, "/mnt/dev/%s", unit);
- fd = open(try, O_RDONLY);
- if (isDebug())
- msgDebug("deviceTry: final attempt for %s returns %d\n", try, fd);
- return fd;
-}
-
-/* Register a new device in the devices array */
-Device *
-deviceRegister(char *name, char *desc, char *devname, DeviceType type, Boolean enabled,
- Boolean (*init)(Device *), FILE * (*get)(Device *, char *, Boolean),
- void (*shutdown)(Device *), void *private)
-{
- Device *newdev = NULL;
-
- if (numDevs == DEV_MAX)
- msgFatal("Too many devices found!");
- else {
- newdev = new_device(name);
- newdev->description = desc;
- newdev->devname = devname;
- newdev->type = type;
- newdev->enabled = enabled;
- newdev->init = init ? init : dummyInit;
- newdev->get = get ? get : dummyGet;
- newdev->shutdown = shutdown ? shutdown : dummyShutdown;
- newdev->private = private;
- Devices[numDevs] = newdev;
- Devices[++numDevs] = NULL;
- }
- return newdev;
-}
-
-/* Reset the registered device chain */
-void
-deviceReset(void)
-{
- int i;
-
- for (i = 0; i < numDevs; i++) {
- Devices[i]->shutdown(Devices[i]);
-
- /* XXX this potentially leaks Devices[i]->private if it's being
- * used to point to something dynamic, but you're not supposed
- * to call this routine at such times that some open instance
- * has its private ptr pointing somewhere anyway. XXX
- */
- free(Devices[i]);
- }
- Devices[numDevs = 0] = NULL;
-}
-
-/* Get all device information for devices we have attached */
-void
-deviceGetAll(void)
-{
- int i, j, fd, s;
- struct ifconf ifc;
- struct ifreq *ifptr, *end;
- int ifflags;
- char buffer[INTERFACE_MAX * sizeof(struct ifreq)];
- char **names;
-
- msgNotify("Probing devices, please wait (this can take a while)...");
- /* First go for the network interfaces. Stolen shamelessly from ifconfig! */
- ifc.ifc_len = sizeof(buffer);
- ifc.ifc_buf = buffer;
-
- s = socket(AF_INET, SOCK_DGRAM, 0);
- if (s < 0)
- goto skipif; /* Jump over network iface probing */
-
- if (ioctl(s, SIOCGIFCONF, (char *) &ifc) < 0)
- goto skipif; /* Jump over network iface probing */
-
- ifflags = ifc.ifc_req->ifr_flags;
- end = (struct ifreq *) (ifc.ifc_buf + ifc.ifc_len);
- for (ifptr = ifc.ifc_req; ifptr < end; ifptr++) {
- char *descr;
-
- /* If it's not a link entry, forget it */
- if (ifptr->ifr_ifru.ifru_addr.sa_family != AF_LINK)
- goto loopend;
-
- /* Eliminate network devices that don't make sense */
- if (!strncmp(ifptr->ifr_name, "lo", 2))
- goto loopend;
-
- /* If we have a slip device, don't register it */
- if (!strncmp(ifptr->ifr_name, "sl", 2)) {
- goto loopend;
- }
- /* And the same for ppp */
- if (!strncmp(ifptr->ifr_name, "tun", 3) || !strncmp(ifptr->ifr_name, "ppp", 3)) {
- goto loopend;
- }
- /* Try and find its description */
- for (i = 0, descr = NULL; device_names[i].name; i++) {
- int len = strlen(device_names[i].name);
-
- if (!ifptr->ifr_name || !ifptr->ifr_name[0])
- continue;
- else if (!strncmp(ifptr->ifr_name, device_names[i].name, len)) {
- descr = device_names[i].description;
- break;
- }
- }
- if (!descr)
- descr = "<unknown network interface type>";
-
- deviceRegister(ifptr->ifr_name, descr, strdup(ifptr->ifr_name), DEVICE_TYPE_NETWORK, TRUE,
- mediaInitNetwork, NULL, mediaShutdownNetwork, NULL);
- if (isDebug())
- msgDebug("Found a network device named %s\n", ifptr->ifr_name);
- close(s);
- if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
- continue;
-
-loopend:
- if (ifptr->ifr_addr.sa_len) /* I'm not sure why this is here - it's inherited */
- ifptr = (struct ifreq *)((caddr_t)ifptr + ifptr->ifr_addr.sa_len - sizeof(struct sockaddr));
- }
-
-skipif:
- /* Next, try to find all the types of devices one might need
- * during the second stage of the installation.
- */
- for (i = 0; device_names[i].name; i++) {
- for (j = 0; j < device_names[i].max; j++) {
- char try[FILENAME_MAX];
-
- switch(device_names[i].type) {
- case DEVICE_TYPE_CDROM:
- fd = deviceTry(device_names[i], try, j);
- if (fd >= 0 || errno == EBUSY) { /* EBUSY if already mounted */
- char n[BUFSIZ];
-
- if (fd >= 0) close(fd);
- snprintf(n, sizeof n, device_names[i].name, j);
- deviceRegister(strdup(n), device_names[i].description, strdup(try),
- DEVICE_TYPE_CDROM, TRUE, mediaInitCDROM, mediaGetCDROM,
- mediaShutdownCDROM, NULL);
- if (isDebug())
- msgDebug("Found a CDROM device for %s\n", try);
- }
- break;
-
- case DEVICE_TYPE_TAPE:
- fd = deviceTry(device_names[i], try, j);
- if (fd >= 0) {
- char n[BUFSIZ];
-
- close(fd);
- snprintf(n, sizeof n, device_names[i].name, j);
- deviceRegister(strdup(n), device_names[i].description, strdup(try),
- DEVICE_TYPE_TAPE, TRUE, mediaInitTape, mediaGetTape, mediaShutdownTape, NULL);
- if (isDebug())
- msgDebug("Found a TAPE device for %s\n", try);
- }
- break;
-
- case DEVICE_TYPE_DISK:
- fd = deviceTry(device_names[i], try, j);
- if (fd >= 0 && RunningAsInit) {
- dev_t d;
- mode_t m;
- int s, fail;
- char unit[80], slice[80];
-
- close(fd);
- /* Make associated slice entries */
- for (s = 1; s < 8; s++) {
- snprintf(unit, sizeof unit, device_names[i].name, j);
- snprintf(slice, sizeof slice, "/dev/%ss%d", unit, s);
- d = makedev(device_names[i].major, device_names[i].minor +
- (j * device_names[i].delta) + (s * SLICE_DELTA));
- m = 0640;
- if (device_names[i].dev_type == 'c')
- m |= S_IFCHR;
- else
- m |= S_IFBLK;
- fail = mknod(slice, m, d);
- fd = open(slice, O_RDONLY);
- if (fd >= 0)
- close(fd);
- else if (!fail)
- (void)unlink(slice);
- }
- }
- break;
-
- case DEVICE_TYPE_FLOPPY:
- fd = deviceTry(device_names[i], try, j);
- if (fd >= 0) {
- char n[BUFSIZ];
-
- close(fd);
- snprintf(n, sizeof n, device_names[i].name, j);
- deviceRegister(strdup(n), device_names[i].description, strdup(try),
- DEVICE_TYPE_FLOPPY, TRUE, mediaInitFloppy, mediaGetFloppy,
- mediaShutdownFloppy, NULL);
- if (isDebug())
- msgDebug("Found a floppy device for %s\n", try);
- }
- break;
-
- case DEVICE_TYPE_NETWORK:
- fd = deviceTry(device_names[i], try, j);
- /* The only network devices that you can open this way are serial ones */
- if (fd >= 0) {
- char *newdesc, *cp;
-
- close(fd);
- cp = device_names[i].description;
- /* Serial devices get a slip and ppp device each, if supported */
- newdesc = safe_malloc(strlen(cp) + 40);
- sprintf(newdesc, cp, "SLIP interface", try, j + 1);
- deviceRegister("sl0", newdesc, strdup(try), DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork,
- NULL, mediaShutdownNetwork, NULL);
- msgDebug("Add mapping for %s to sl0\n", try);
- newdesc = safe_malloc(strlen(cp) + 50);
- sprintf(newdesc, cp, "PPP interface", try, j + 1);
- deviceRegister("ppp0", newdesc, strdup(try), DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork,
- NULL, mediaShutdownNetwork, NULL);
- if (isDebug())
- msgDebug("Add mapping for %s to ppp0\n", try);
- }
- break;
-
- default:
- break;
- }
- }
- }
-
- /* Finally, go get the disks and look for DOS partitions to register */
- if ((names = Disk_Names()) != NULL) {
- int i;
-
- for (i = 0; names[i]; i++) {
- Chunk *c1;
- Disk *d;
-
- d = Open_Disk(names[i]);
- if (!d)
- msgFatal("Unable to open disk %s", names[i]);
-
- deviceRegister(names[i], names[i], d->name, DEVICE_TYPE_DISK, FALSE,
- dummyInit, dummyGet, dummyShutdown, d);
- if (isDebug())
- msgDebug("Found a disk device named %s\n", names[i]);
-
- /* Look for existing DOS partitions to register as "DOS media devices" */
- for (c1 = d->chunks->part; c1; c1 = c1->next) {
- if (c1->type == fat || c1->type == extended) {
- Device *dev;
- char devname[80];
-
- /* Got one! */
- snprintf(devname, sizeof devname, "/dev/%s", c1->name);
- dev = deviceRegister(c1->name, c1->name, strdup(devname), DEVICE_TYPE_DOS, TRUE,
- mediaInitDOS, mediaGetDOS, mediaShutdownDOS, NULL);
- dev->private = c1;
- if (isDebug())
- msgDebug("Found a DOS partition %s on drive %s\n", c1->name, d->name);
- }
- }
- }
- free(names);
- }
- dialog_clear_norefresh();
-}
-
-/* Rescan all devices, after closing previous set - convenience function */
-void
-deviceRescan(void)
-{
- deviceReset();
- deviceGetAll();
-}
-
-/*
- * Find all devices that match the criteria, allowing "wildcarding" as well
- * by allowing NULL or ANY values to match all. The array returned is static
- * and may be used until the next invocation of deviceFind().
- */
-Device **
-deviceFind(char *name, DeviceType class)
-{
- static Device *found[DEV_MAX];
- int i, j;
-
- j = 0;
- for (i = 0; i < numDevs; i++) {
- if ((!name || !strcmp(Devices[i]->name, name))
- && (class == DEVICE_TYPE_ANY || class == Devices[i]->type))
- found[j++] = Devices[i];
- }
- found[j] = NULL;
- return j ? found : NULL;
-}
-
-Device **
-deviceFindDescr(char *name, char *desc, DeviceType class)
-{
- static Device *found[DEV_MAX];
- int i, j;
-
- j = 0;
- for (i = 0; i < numDevs; i++) {
- if ((!name || !strcmp(Devices[i]->name, name)) &&
- (!desc || !strcmp(Devices[i]->description, desc)) &&
- (class == DEVICE_TYPE_ANY || class == Devices[i]->type))
- found[j++] = Devices[i];
- }
- found[j] = NULL;
- return j ? found : NULL;
-}
-
-int
-deviceCount(Device **devs)
-{
- int i;
-
- if (!devs)
- return 0;
- for (i = 0; devs[i]; i++);
- return i;
-}
-
-/*
- * Create a menu listing all the devices of a certain type in the system.
- * The passed-in menu is expected to be a "prototype" from which the new
- * menu is cloned.
- */
-DMenu *
-deviceCreateMenu(DMenu *menu, DeviceType type, int (*hook)(dialogMenuItem *d), int (*check)(dialogMenuItem *d))
-{
- Device **devs;
- int numdevs;
- DMenu *tmp = NULL;
- int i, j;
-
- devs = deviceFind(NULL, type);
- numdevs = deviceCount(devs);
- if (!numdevs)
- return NULL;
- tmp = (DMenu *)safe_malloc(sizeof(DMenu) + (sizeof(dialogMenuItem) * (numdevs + 1)));
- bcopy(menu, tmp, sizeof(DMenu));
- for (i = 0; devs[i]; i++) {
- tmp->items[i].prompt = devs[i]->name;
- for (j = 0; j < numDevs; j++) {
- if (devs[i] == Devices[j]) {
- tmp->items[i].title = Devices[j]->description;
- break;
- }
- }
- if (j == numDevs)
- tmp->items[i].title = "<unknown device type>";
- tmp->items[i].fire = hook;
- tmp->items[i].checked = check;
- }
- tmp->items[i].title = NULL;
- return tmp;
-}
diff --git a/usr.sbin/sade/disks.c b/usr.sbin/sade/disks.c
deleted file mode 100644
index 16be5e2f13f5..000000000000
--- a/usr.sbin/sade/disks.c
+++ /dev/null
@@ -1,774 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last program in the `sysinstall' line - the next
- * generation being essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 "sysinstall.h"
-#include <ctype.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/disklabel.h>
-
-/* Where we start displaying chunk information on the screen */
-#define CHUNK_START_ROW 5
-
-/* Where we keep track of MBR chunks */
-static struct chunk *chunk_info[16];
-static int current_chunk;
-
-static void diskPartitionNonInteractive(Device *dev);
-
-static void
-record_chunks(Disk *d)
-{
- struct chunk *c1 = NULL;
- int i = 0;
- int last_free = 0;
-
- if (!d->chunks)
- msgFatal("No chunk list found for %s!", d->name);
-
- for (c1 = d->chunks->part; c1; c1 = c1->next) {
- if (c1->type == unused && c1->size > last_free) {
- last_free = c1->size;
- current_chunk = i;
- }
- chunk_info[i++] = c1;
- }
- chunk_info[i] = NULL;
- if (current_chunk >= i)
- current_chunk = i - 1;
-}
-
-static int Total;
-
-static void
-print_chunks(Disk *d)
-{
- int row;
- int i;
-
- for (i = Total = 0; chunk_info[i]; i++)
- Total += chunk_info[i]->size;
- if (d->bios_cyl > 65536 || d->bios_hd > 256 || d->bios_sect >= 64) {
- dialog_clear_norefresh();
- msgConfirm("WARNING: A geometry of %d/%d/%d for %s is incorrect. Using\n"
- "a more likely geometry. If this geometry is incorrect or you\n"
- "are unsure as to whether or not it's correct, please consult\n"
- "the Hardware Guide in the Documentation submenu or use the\n"
- "(G)eometry command to change it now.\n\n"
- "Remember: you need to enter whatever your BIOS thinks the\n"
- "geometry is! For IDE, it's what you were told in the BIOS\n"
- "setup. For SCSI, it's the translation mode your controller is\n"
- "using. Do NOT use a ``physical geometry''.",
- d->bios_cyl, d->bios_hd, d->bios_sect, d->name);
- Sanitize_Bios_Geom(d);
- }
- attrset(A_NORMAL);
- mvaddstr(0, 0, "Disk name:\t");
- clrtobot();
- attrset(A_REVERSE); addstr(d->name); attrset(A_NORMAL);
- attrset(A_REVERSE); mvaddstr(0, 55, "FDISK Partition Editor"); attrset(A_NORMAL);
- mvprintw(1, 0,
- "DISK Geometry:\t%lu cyls/%lu heads/%lu sectors = %lu sectors",
- d->bios_cyl, d->bios_hd, d->bios_sect,
- d->bios_cyl * d->bios_hd * d->bios_sect);
- mvprintw(3, 0, "%10s %10s %10s %8s %6s %10s %8s %8s",
- "Offset", "Size", "End", "Name", "PType", "Desc",
- "Subtype", "Flags");
- for (i = 0, row = CHUNK_START_ROW; chunk_info[i]; i++, row++) {
- if (i == current_chunk)
- attrset(ATTR_SELECTED);
- mvprintw(row, 0, "%10ld %10lu %10lu %8s %6d %10s %8d\t%-6s",
- chunk_info[i]->offset, chunk_info[i]->size,
- chunk_info[i]->end, chunk_info[i]->name,
- chunk_info[i]->type,
- slice_type_name(chunk_info[i]->type, chunk_info[i]->subtype),
- chunk_info[i]->subtype, ShowChunkFlags(chunk_info[i]));
- if (i == current_chunk)
- attrset(A_NORMAL);
- }
-}
-
-static void
-print_command_summary()
-{
- mvprintw(14, 0, "The following commands are supported (in upper or lower case):");
- mvprintw(16, 0, "A = Use Entire Disk C = Create Slice");
- mvprintw(17, 0, "D = Delete Slice G = Set Drive Geometry S = Set Bootable");
- mvprintw(18, 0, "T = Change Type U = Undo All Changes Q = Finish");
- if (!RunningAsInit)
- mvprintw(18, 48, "W = Write Changes");
- mvprintw(21, 0, "Use F1 or ? to get more help, arrow keys to select.");
- move(0, 0);
-}
-
-static u_char *
-getBootMgr(char *dname)
-{
-#ifndef __alpha__ /* only meaningful on x86 */
- extern u_char mbr[], boot0[];
- char str[80];
- char *cp;
- int i = 0;
-
- cp = variable_get(VAR_BOOTMGR);
- if (!cp) {
- /* Figure out what kind of MBR the user wants */
- sprintf(str, "Install Boot Manager for drive %s?", dname);
- MenuMBRType.title = str;
- i = dmenuOpenSimple(&MenuMBRType, FALSE);
- }
- else {
- if (!strncmp(cp, "boot", 4))
- BootMgr = 0;
- else if (!strcmp(cp, "standard"))
- BootMgr = 1;
- else
- BootMgr = 2;
- }
- if (cp || i) {
- switch (BootMgr) {
- case 0:
- return boot0;
-
- case 1:
- return mbr;
-
- case 2:
- default:
- break;
- }
- }
-#endif
- return NULL;
-}
-
-int
-diskGetSelectCount(Device ***devs)
-{
- int i, cnt, enabled;
- char *cp;
- Device **dp;
-
- cp = variable_get(VAR_DISK);
- dp = *devs = deviceFind(cp, DEVICE_TYPE_DISK);
- cnt = deviceCount(dp);
- if (!cnt)
- return -1;
- for (i = 0, enabled = 0; i < cnt; i++) {
- if (dp[i]->enabled)
- ++enabled;
- }
- return enabled;
-}
-
-void
-diskPartition(Device *dev)
-{
- char *cp, *p;
- int rv, key = 0;
- Boolean chunking;
- char *msg = NULL;
- u_char *mbrContents;
- WINDOW *w = savescr();
- Disk *d = (Disk *)dev->private;
-
- chunking = TRUE;
- keypad(stdscr, TRUE);
-
- /* Flush both the dialog and curses library views of the screen
- since we don't always know who called us */
- dialog_clear_norefresh(), clear();
- current_chunk = 0;
-
- /* Set up the chunk array */
- record_chunks(d);
-
- while (chunking) {
- char *val, geometry[80];
-
- /* Now print our overall state */
- if (d)
- print_chunks(d);
- print_command_summary();
- if (msg) {
- attrset(title_attr); mvprintw(23, 0, msg); attrset(A_NORMAL);
- beep();
- msg = NULL;
- }
- else {
- move(23, 0);
- clrtoeol();
- }
-
- /* Get command character */
- key = getch();
- switch (toupper(key)) {
- case '\014': /* ^L (redraw) */
- clear();
- msg = NULL;
- break;
-
- case '\020': /* ^P */
- case KEY_UP:
- case '-':
- if (current_chunk != 0)
- --current_chunk;
- break;
-
- case '\016': /* ^N */
- case KEY_DOWN:
- case '+':
- case '\r':
- case '\n':
- if (chunk_info[current_chunk + 1])
- ++current_chunk;
- break;
-
- case KEY_HOME:
- current_chunk = 0;
- break;
-
- case KEY_END:
- while (chunk_info[current_chunk + 1])
- ++current_chunk;
- break;
-
- case KEY_F(1):
- case '?':
- systemDisplayHelp("slice");
- clear();
- break;
-
- case 'A':
-#ifdef __alpha__
- rv = 1;
-#else /* The rest is only relevant on x86 */
- cp = variable_get(VAR_DEDICATE_DISK);
- if (cp && !strcasecmp(cp, "always"))
- rv = 1;
- else {
- rv = msgYesNo("Do you want to do this with a true partition entry\n"
- "so as to remain cooperative with any future possible\n"
- "operating systems on the drive(s)?\n"
- "(See also the section about ``dangerously dedicated''\n"
- "disks in the FreeBSD FAQ.)");
- if (rv == -1)
- rv = 0;
- }
-#endif
- All_FreeBSD(d, rv);
- variable_set2(DISK_PARTITIONED, "yes", 0);
- record_chunks(d);
- clear();
- break;
-
- case 'C':
- if (chunk_info[current_chunk]->type != unused)
- msg = "Slice in use, delete it first or move to an unused one.";
- else {
- char *val, tmp[20], *cp;
- int size, subtype;
- chunk_e partitiontype;
-
- snprintf(tmp, 20, "%lu", chunk_info[current_chunk]->size);
- val = msgGetInput(tmp, "Please specify the size for new FreeBSD slice in blocks\n"
- "or append a trailing `M' for megabytes (e.g. 20M).");
- if (val && (size = strtol(val, &cp, 0)) > 0) {
- if (*cp && toupper(*cp) == 'M')
- size *= ONE_MEG;
- else if (*cp && toupper(*cp) == 'G')
- size *= ONE_GIG;
- strcpy(tmp, "165");
- val = msgGetInput(tmp, "Enter type of partition to create:\n\n"
- "Pressing Enter will choose the default, a native FreeBSD\n"
- "slice (type 165). You can choose other types, 6 for a\n"
- "DOS partition or 131 for a Linux partition, for example.\n\n"
- "Note: If you choose a non-FreeBSD partition type, it will not\n"
- "be formatted or otherwise prepared, it will simply reserve space\n"
- "for you to use another tool, such as DOS FORMAT, to later format\n"
- "and use the partition.");
- if (val && (subtype = strtol(val, NULL, 0)) > 0) {
- if (subtype == 165)
- partitiontype = freebsd;
- else if (subtype == 6)
- partitiontype = fat;
- else
- partitiontype = unknown;
-#ifdef __alpha__
- if (partitiontype == freebsd && size == chunk_info[current_chunk]->size)
- All_FreeBSD(d, 1);
- else
-#endif
- Create_Chunk(d, chunk_info[current_chunk]->offset, size, partitiontype, subtype,
- (chunk_info[current_chunk]->flags & CHUNK_ALIGN));
- variable_set2(DISK_PARTITIONED, "yes", 0);
- record_chunks(d);
- }
- }
- clear();
- }
- break;
-
- case KEY_DC:
- case 'D':
- if (chunk_info[current_chunk]->type == unused)
- msg = "Slice is already unused!";
- else {
- Delete_Chunk(d, chunk_info[current_chunk]);
- variable_set2(DISK_PARTITIONED, "yes", 0);
- record_chunks(d);
- }
- break;
-
- case 'T':
- if (chunk_info[current_chunk]->type == unused)
- msg = "Slice is currently unused (use create instead)";
- else {
- char *val, tmp[20];
- int subtype;
- chunk_e partitiontype;
-
- strcpy(tmp, "165");
- val = msgGetInput(tmp, "New partition type:\n\n"
- "Pressing Enter will choose the default, a native FreeBSD\n"
- "slice (type 165). Other popular values are 6 for\n"
- "DOS FAT partition, 131 for a Linux ext2fs partition or\n"
- "130 for a Linux swap partition.\n\n"
- "Note: If you choose a non-FreeBSD partition type, it will not\n"
- "be formatted or otherwise prepared, it will simply reserve space\n"
- "for you to use another tool, such as DOS format, to later format\n"
- "and actually use the partition.");
- if (val && (subtype = strtol(val, NULL, 0)) > 0) {
- if (subtype == 165)
- partitiontype = freebsd;
- else if (subtype == 6)
- partitiontype = fat;
- else
- partitiontype = unknown;
- chunk_info[current_chunk]->type = partitiontype;
- chunk_info[current_chunk]->subtype = subtype;
- }
- }
- break;
-
- case 'G':
- snprintf(geometry, 80, "%lu/%lu/%lu", d->bios_cyl, d->bios_hd, d->bios_sect);
- val = msgGetInput(geometry, "Please specify the new geometry in cyl/hd/sect format.\n"
- "Don't forget to use the two slash (/) separator characters!\n"
- "It's not possible to parse the field without them.");
- if (val) {
- long nc, nh, ns;
- nc = strtol(val, &val, 0);
- nh = strtol(val + 1, &val, 0);
- ns = strtol(val + 1, 0, 0);
- Set_Bios_Geom(d, nc, nh, ns);
- }
- clear();
- break;
-
- case 'S':
- /* Set Bootable */
- chunk_info[current_chunk]->flags |= CHUNK_ACTIVE;
- break;
-
- case 'U':
- if ((cp = variable_get(DISK_LABELLED)) && !strcmp(cp, "written")) {
- msgConfirm("You've already written this information out - you\n"
- "can't undo it.");
- }
- else if (!msgYesNo("Are you SURE you want to Undo everything?")) {
- char cp[BUFSIZ];
-
- sstrncpy(cp, d->name, sizeof cp);
- Free_Disk(dev->private);
- d = Open_Disk(cp);
- if (!d)
- msgConfirm("Can't reopen disk %s! Internal state is probably corrupted", cp);
- dev->private = d;
- variable_unset(DISK_PARTITIONED);
- variable_unset(DISK_LABELLED);
- if (d)
- record_chunks(d);
- }
- clear();
- break;
-
- case 'W':
- if (!msgYesNo("WARNING: This should only be used when modifying an EXISTING\n"
- "installation. If you are installing FreeBSD for the first time\n"
- "then you should simply type Q when you're finished here and your\n"
- "changes will be committed in one batch automatically at the end of\n"
- "these questions. If you're adding a disk, you should NOT write\n"
- "from this screen, you should do it from the label editor.\n\n"
- "Are you absolutely sure you want to do this now?")) {
- variable_set2(DISK_PARTITIONED, "yes", 0);
-
- /* Don't trash the MBR if the first (and therefore only) chunk is marked for a truly dedicated
- * disk (i.e., the disklabel starts at sector 0), even in cases where the user has requested
- * booteasy or a "standard" MBR -- both would be fatal in this case.
- */
- /*
- * Don't offer to update the MBR on this disk if the first "real" chunk looks like
- * a FreeBSD "all disk" partition, or the disk is entirely FreeBSD.
- */
- if (((d->chunks->part->type != freebsd) || (d->chunks->part->offset > 1)))
- mbrContents = getBootMgr(d->name);
- else
- mbrContents = NULL;
- Set_Boot_Mgr(d, mbrContents);
-
- if (DITEM_STATUS(diskPartitionWrite(NULL)) != DITEM_SUCCESS)
- msgConfirm("Disk partition write returned an error status!");
- else
- msgConfirm("Wrote FDISK partition information out successfully.");
- }
- clear();
- break;
-
- case '|':
- if (!msgYesNo("Are you SURE you want to go into Wizard mode?\n"
- "No seat belts whatsoever are provided!")) {
- clear();
- refresh();
- slice_wizard(d);
- variable_set2(DISK_PARTITIONED, "yes", 0);
- record_chunks(d);
- }
- else
- msg = "Wise choice!";
- clear();
- break;
-
- case '\033': /* ESC */
- case 'Q':
- chunking = FALSE;
- /* Don't trash the MBR if the first (and therefore only) chunk is marked for a truly dedicated
- * disk (i.e., the disklabel starts at sector 0), even in cases where the user has requested
- * booteasy or a "standard" MBR -- both would be fatal in this case.
- */
-#if 0
- if ((d->chunks->part->flags & CHUNK_FORCE_ALL) != CHUNK_FORCE_ALL
- && (mbrContents = getBootMgr(d->name)) != NULL)
- Set_Boot_Mgr(d, mbrContents);
-#else
- /*
- * Don't offer to update the MBR on this disk if the first "real" chunk looks like
- * a FreeBSD "all disk" partition, or the disk is entirely FreeBSD.
- */
- if (((d->chunks->part->type != freebsd) || (d->chunks->part->offset > 1)) &&
- (mbrContents = getBootMgr(d->name)) != NULL)
- Set_Boot_Mgr(d, mbrContents);
-#endif
- break;
-
- default:
- beep();
- msg = "Type F1 or ? for help";
- break;
- }
- }
- p = CheckRules(d);
- if (p) {
- char buf[FILENAME_MAX];
-
- use_helpline("Press F1 to read more about disk slices.");
- use_helpfile(systemHelpFile("partition", buf));
- if (!variable_get(VAR_NO_WARN))
- dialog_mesgbox("Disk slicing warning:", p, -1, -1);
- free(p);
- }
- restorescr(w);
-}
-
-static u_char *
-bootalloc(char *name)
-{
- char buf[FILENAME_MAX];
- struct stat sb;
-
- snprintf(buf, sizeof buf, "/boot/%s", name);
- if (stat(buf, &sb) != -1) {
- int fd;
-
- fd = open(buf, O_RDONLY);
- if (fd != -1) {
- u_char *cp;
-
- cp = malloc(sb.st_size);
- if (read(fd, cp, sb.st_size) != sb.st_size) {
- free(cp);
- close(fd);
- msgDebug("bootalloc: couldn't read %d bytes from %s\n", sb.st_size, buf);
- return NULL;
- }
- close(fd);
- return cp;
- }
- msgDebug("bootalloc: couldn't open %s\n", buf);
- }
- else
- msgDebug("bootalloc: can't stat %s\n", buf);
- return NULL;
-}
-
-static int
-partitionHook(dialogMenuItem *selected)
-{
- Device **devs = NULL;
-
- devs = deviceFind(selected->prompt, DEVICE_TYPE_DISK);
- if (!devs) {
- msgConfirm("Unable to find disk %s!", selected->prompt);
- return DITEM_FAILURE;
- }
- /* Toggle enabled status? */
- if (!devs[0]->enabled) {
- devs[0]->enabled = TRUE;
- diskPartition(devs[0]);
- }
- else
- devs[0]->enabled = FALSE;
- return DITEM_SUCCESS;
-}
-
-static int
-partitionCheck(dialogMenuItem *selected)
-{
- Device **devs = NULL;
-
- devs = deviceFind(selected->prompt, DEVICE_TYPE_DISK);
- if (!devs || devs[0]->enabled == FALSE)
- return FALSE;
- return TRUE;
-}
-
-int
-diskPartitionEditor(dialogMenuItem *self)
-{
- DMenu *menu;
- Device **devs;
- int i, cnt, devcnt;
-
- cnt = diskGetSelectCount(&devs);
- devcnt = deviceCount(devs);
- if (cnt == -1) {
- msgConfirm("No disks found! Please verify that your disk controller is being\n"
- "properly probed at boot time. See the Hardware Guide on the\n"
- "Documentation menu for clues on diagnosing this type of problem.");
- return DITEM_FAILURE;
- }
- else if (cnt) {
- /* Some are already selected */
- for (i = 0; i < devcnt; i++) {
- if (devs[i]->enabled) {
- if (variable_get(VAR_NONINTERACTIVE))
- diskPartitionNonInteractive(devs[i]);
- else
- diskPartition(devs[i]);
- }
- }
- }
- else {
- /* No disks are selected, fall-back case now */
- if (devcnt == 1) {
- devs[0]->enabled = TRUE;
- if (variable_get(VAR_NONINTERACTIVE))
- diskPartitionNonInteractive(devs[0]);
- else
- diskPartition(devs[0]);
- return DITEM_SUCCESS;
- }
- else {
- menu = deviceCreateMenu(&MenuDiskDevices, DEVICE_TYPE_DISK, partitionHook, partitionCheck);
- if (!menu) {
- msgConfirm("No devices suitable for installation found!\n\n"
- "Please verify that your disk controller (and attached drives)\n"
- "were detected properly. This can be done by pressing the\n"
- "[Scroll Lock] key and using the Arrow keys to move back to\n"
- "the boot messages. Press [Scroll Lock] again to return.");
- return DITEM_FAILURE;
- }
- else {
- i = dmenuOpenSimple(menu, FALSE) ? DITEM_SUCCESS : DITEM_FAILURE;
- free(menu);
- }
- return i;
- }
- }
- return DITEM_SUCCESS;
-}
-
-int
-diskPartitionWrite(dialogMenuItem *self)
-{
- Device **devs;
- int i;
- char *cp;
-
- devs = deviceFind(NULL, DEVICE_TYPE_DISK);
- if (!devs) {
- msgConfirm("Unable to find any disks to write to??");
- return DITEM_FAILURE;
- }
- if (isDebug())
- msgDebug("diskPartitionWrite: Examining %d devices\n", deviceCount(devs));
- cp = variable_get(DISK_PARTITIONED);
- if (cp && !strcmp(cp, "written"))
- return DITEM_SUCCESS;
-
- for (i = 0; devs[i]; i++) {
- Disk *d = (Disk *)devs[i]->private;
- static u_char *boot1;
-#ifndef __alpha__
- static u_char *boot2;
-#endif
-
- if (!devs[i]->enabled)
- continue;
-
-#ifdef __alpha__
- if (!boot1) boot1 = bootalloc("boot1");
- Set_Boot_Blocks(d, boot1, NULL);
-#else
- if (!boot1) boot1 = bootalloc("boot1");
- if (!boot2) boot2 = bootalloc("boot2");
- Set_Boot_Blocks(d, boot1, boot2);
-#endif
-
- msgNotify("Writing partition information to drive %s", d->name);
- if (!Fake && Write_Disk(d)) {
- msgConfirm("ERROR: Unable to write data to disk %s!", d->name);
- return DITEM_FAILURE;
- }
-
- /* If we've been through here before, we don't need to do the rest */
- if (cp && !strcmp(cp, "written"))
- return DITEM_SUCCESS;
- }
- /* Now it's not "yes", but "written" */
- variable_set2(DISK_PARTITIONED, "written", 0);
- return DITEM_SUCCESS | DITEM_RESTORE;
-}
-
-/* Partition a disk based wholly on which variables are set */
-static void
-diskPartitionNonInteractive(Device *dev)
-{
- char *cp;
- int i, sz, all_disk = 0;
- u_char *mbrContents;
- Disk *d = (Disk *)dev->private;
-
- record_chunks(d);
- cp = variable_get(VAR_GEOMETRY);
- if (cp) {
- msgDebug("Setting geometry from script to: %s\n", cp);
- d->bios_cyl = strtol(cp, &cp, 0);
- d->bios_hd = strtol(cp + 1, &cp, 0);
- d->bios_sect = strtol(cp + 1, 0, 0);
- }
-
- cp = variable_get(VAR_PARTITION);
- if (cp) {
- if (!strcmp(cp, "free")) {
- /* Do free disk space case */
- for (i = 0; chunk_info[i]; i++) {
- /* If a chunk is at least 10MB in size, use it. */
- if (chunk_info[i]->type == unused && chunk_info[i]->size > (10 * ONE_MEG)) {
- Create_Chunk(d, chunk_info[i]->offset, chunk_info[i]->size, freebsd, 3,
- (chunk_info[i]->flags & CHUNK_ALIGN));
- variable_set2(DISK_PARTITIONED, "yes", 0);
- break;
- }
- }
- if (!chunk_info[i]) {
- msgConfirm("Unable to find any free space on this disk!");
- return;
- }
- }
- else if (!strcmp(cp, "all")) {
- /* Do all disk space case */
- msgDebug("Warning: Devoting all of disk %s to FreeBSD.\n", d->name);
-
- All_FreeBSD(d, FALSE);
- }
- else if (!strcmp(cp, "exclusive")) {
- /* Do really-all-the-disk-space case */
- msgDebug("Warning: Devoting all of disk %s to FreeBSD.\n", d->name);
-
- All_FreeBSD(d, all_disk = TRUE);
- }
- else if ((sz = strtol(cp, &cp, 0))) {
- /* Look for sz bytes free */
- if (*cp && toupper(*cp) == 'M')
- sz *= ONE_MEG;
- else if (*cp && toupper(*cp) == 'G')
- sz *= ONE_GIG;
- for (i = 0; chunk_info[i]; i++) {
- /* If a chunk is at least sz MB, use it. */
- if (chunk_info[i]->type == unused && chunk_info[i]->size >= sz) {
- Create_Chunk(d, chunk_info[i]->offset, sz, freebsd, 3, (chunk_info[i]->flags & CHUNK_ALIGN));
- variable_set2(DISK_PARTITIONED, "yes", 0);
- break;
- }
- }
- if (!chunk_info[i]) {
- msgConfirm("Unable to find %d free blocks on this disk!", sz);
- return;
- }
- }
- else if (!strcmp(cp, "existing")) {
- /* Do existing FreeBSD case */
- for (i = 0; chunk_info[i]; i++) {
- if (chunk_info[i]->type == freebsd)
- break;
- }
- if (!chunk_info[i]) {
- msgConfirm("Unable to find any existing FreeBSD partitions on this disk!");
- return;
- }
- }
- else {
- msgConfirm("`%s' is an invalid value for %s - is config file valid?", cp, VAR_PARTITION);
- return;
- }
- if (!all_disk) {
- mbrContents = getBootMgr(d->name);
- Set_Boot_Mgr(d, mbrContents);
- }
- variable_set2(DISK_PARTITIONED, "yes", 0);
- }
-}
diff --git a/usr.sbin/sade/dispatch.c b/usr.sbin/sade/dispatch.c
deleted file mode 100644
index 0b388b4873cd..000000000000
--- a/usr.sbin/sade/dispatch.c
+++ /dev/null
@@ -1,434 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last program in the `sysinstall' line - the next
- * generation being essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 "sysinstall.h"
-#include <ctype.h>
-#include <errno.h>
-#include <sys/signal.h>
-#include <sys/fcntl.h>
-
-#include "list.h"
-
-static int dispatch_shutdown(dialogMenuItem *unused);
-static int dispatch_systemExecute(dialogMenuItem *unused);
-static int dispatch_msgConfirm(dialogMenuItem *unused);
-
-static struct _word {
- char *name;
- int (*handler)(dialogMenuItem *self);
-} resWords[] = {
- { "configAnonFTP", configAnonFTP },
- { "configRouter", configRouter },
- { "configNFSServer", configNFSServer },
- { "configNTP", configNTP },
- { "configPCNFSD", configPCNFSD },
- { "configPackages", configPackages },
- { "configUsers", configUsers },
- { "configXSetup", configXSetup },
- { "configXDesktop", configXDesktop },
- { "diskPartitionEditor", diskPartitionEditor },
- { "diskPartitionWrite", diskPartitionWrite },
- { "diskLabelEditor", diskLabelEditor },
- { "diskLabelCommit", diskLabelCommit },
- { "distReset", distReset },
- { "distSetCustom", distSetCustom },
- { "distUnsetCustom", distUnsetCustom },
- { "distSetDeveloper", distSetDeveloper },
- { "distSetXDeveloper", distSetXDeveloper },
- { "distSetKernDeveloper", distSetKernDeveloper },
- { "distSetUser", distSetUser },
- { "distSetXUser", distSetXUser },
- { "distSetMinimum", distSetMinimum },
- { "distSetEverything", distSetEverything },
- { "distSetCRYPTO", distSetCRYPTO },
- { "distSetSrc", distSetSrc },
- { "distSetXF86", distSetXF86 },
- { "distExtractAll", distExtractAll },
- { "docBrowser", docBrowser },
- { "docShowDocument", docShowDocument },
- { "installCommit", installCommit },
- { "installExpress", installExpress },
- { "installStandard", installStandard },
- { "installUpgrade", installUpgrade },
- { "installFixupBin", installFixupBin },
- { "installFixupXFree", installFixupXFree },
- { "installFixitHoloShell", installFixitHoloShell },
- { "installFixitCDROM", installFixitCDROM },
- { "installFixitFloppy", installFixitFloppy },
- { "installFilesystems", installFilesystems },
- { "installVarDefaults", installVarDefaults },
- { "loadConfig", dispatch_load_file },
- { "loadFloppyConfig", dispatch_load_floppy },
- { "mediaSetCDROM", mediaSetCDROM },
- { "mediaSetFloppy", mediaSetFloppy },
- { "mediaSetDOS", mediaSetDOS },
- { "mediaSetTape", mediaSetTape },
- { "mediaSetFTP", mediaSetFTP },
- { "mediaSetFTPActive", mediaSetFTPActive },
- { "mediaSetFTPPassive", mediaSetFTPPassive },
- { "mediaSetHTTP", mediaSetHTTP },
- { "mediaSetUFS", mediaSetUFS },
- { "mediaSetNFS", mediaSetNFS },
- { "mediaSetFTPUserPass", mediaSetFTPUserPass },
- { "mediaSetCPIOVerbosity", mediaSetCPIOVerbosity },
- { "mediaGetType", mediaGetType },
- { "msgConfirm", dispatch_msgConfirm },
- { "optionsEditor", optionsEditor },
- { "packageAdd", packageAdd },
- { "addGroup", userAddGroup },
- { "addUser", userAddUser },
- { "shutdown", dispatch_shutdown },
- { "system", dispatch_systemExecute },
- { "dumpVariables", dump_variables },
- { "tcpMenuSelect", tcpMenuSelect },
- { NULL, NULL },
-};
-
-/*
- * Helper routines for buffering data.
- *
- * We read an entire configuration into memory before executing it
- * so that we are truely standalone and can do things like nuke the
- * file or disk we're working on.
- */
-
-typedef struct command_buffer_ {
- qelement queue;
- char * string;
-} command_buffer;
-
-static void
-dispatch_free_command(command_buffer *item)
-{
- REMQUE(item);
- free(item->string);
- free(item);
-}
-
-static void
-dispatch_free_all(qelement *head)
-{
- command_buffer *item;
-
- while (!EMPTYQUE(*head)) {
- item = (command_buffer *) head->q_forw;
- dispatch_free_command(item);
- }
-}
-
-static command_buffer *
-dispatch_add_command(qelement *head, char *string)
-{
- command_buffer *new;
-
- new = malloc(sizeof(command_buffer));
-
- if (!new)
- return NULL;
-
- new->string = strdup(string);
- INSQUEUE(new, head->q_back);
-
- return new;
-}
-
-/*
- * Command processing
- */
-
-/* Just convenience */
-static int
-dispatch_shutdown(dialogMenuItem *unused)
-{
- systemShutdown(0);
- return DITEM_FAILURE;
-}
-
-static int
-dispatch_systemExecute(dialogMenuItem *unused)
-{
- char *cmd = variable_get(VAR_COMMAND);
-
- if (cmd)
- return systemExecute(cmd) ? DITEM_FAILURE : DITEM_SUCCESS;
- else
- msgDebug("_systemExecute: No command passed in `command' variable.\n");
- return DITEM_FAILURE;
-}
-
-static int
-dispatch_msgConfirm(dialogMenuItem *unused)
-{
- char *msg = variable_get(VAR_COMMAND);
-
- if (msg) {
- msgConfirm(msg);
- return DITEM_SUCCESS;
- }
-
- msgDebug("_msgConfirm: No message passed in `command' variable.\n");
- return DITEM_FAILURE;
-}
-
-static int
-call_possible_resword(char *name, dialogMenuItem *value, int *status)
-{
- int i, rval;
-
- rval = 0;
- for (i = 0; resWords[i].name; i++) {
- if (!strcmp(name, resWords[i].name)) {
- *status = resWords[i].handler(value);
- rval = 1;
- break;
- }
- }
- return rval;
-}
-
-/* For a given string, call it or spit out an undefined command diagnostic */
-int
-dispatchCommand(char *str)
-{
- int i;
- char *cp;
-
- if (!str || !*str) {
- msgConfirm("Null or zero-length string passed to dispatchCommand");
- return DITEM_FAILURE;
- }
- /* If it's got a newline, trim it */
- if ((cp = index(str, '\n')) != NULL)
- *cp = '\0';
-
- /* If it's got a `=' sign in there, assume it's a variable setting */
- if (index(str, '=')) {
- if (isDebug())
- msgDebug("dispatch: setting variable `%s'\n", str);
- variable_set(str, 0);
- i = DITEM_SUCCESS;
- }
- else {
- /* A command might be a pathname if it's encoded in argv[0], which
- we also support */
- if ((cp = rindex(str, '/')) != NULL)
- str = cp + 1;
- if (isDebug())
- msgDebug("dispatch: calling resword `%s'\n", str);
- if (!call_possible_resword(str, NULL, &i)) {
- msgNotify("Warning: No such command ``%s''", str);
- i = DITEM_FAILURE;
- }
- }
- return i;
-}
-
-
-/*
- * File processing
- */
-
-static qelement *
-dispatch_load_fp(FILE *fp)
-{
- qelement *head;
- char buf[BUFSIZ], *cp;
-
- head = malloc(sizeof(qelement));
-
- if (!head)
- return NULL;
-
- INITQUE(*head);
-
- while (fgets(buf, sizeof buf, fp)) {
-
- if ((cp = strchr(buf, '\n')) != NULL)
- *cp = '\0';
- if (*buf == '\0' || *buf == '#')
- continue;
-
- if (!dispatch_add_command(head, buf))
- return NULL;
- }
-
- return head;
-}
-
-static int
-dispatch_execute(qelement *head)
-{
- int result = DITEM_SUCCESS;
- command_buffer *item;
- char *old_interactive;
-
- if (!head)
- return result | DITEM_FAILURE;
-
- old_interactive = variable_get(VAR_NONINTERACTIVE);
- if (old_interactive)
- old_interactive = strdup(old_interactive); /* save copy */
-
- /* Hint to others that we're running from a script, should they care */
- variable_set2(VAR_NONINTERACTIVE, "yes", 0);
-
- while (!EMPTYQUE(*head)) {
- item = (command_buffer *) head->q_forw;
-
- if (DITEM_STATUS(dispatchCommand(item->string)) != DITEM_SUCCESS) {
- /*
- * Allow a user to prefix a command with "noError" to cause
- * us to ignore any errors for that one command.
- */
- if (variable_get(VAR_NO_ERROR))
- variable_unset(VAR_NO_ERROR);
- else {
- msgConfirm("Command `%s' failed - rest of script aborted.\n",
- item->string);
- result |= DITEM_FAILURE;
- break;
- }
- }
- dispatch_free_command(item);
- }
-
- dispatch_free_all(head);
-
- if (!old_interactive)
- variable_unset(VAR_NONINTERACTIVE);
- else {
- variable_set2(VAR_NONINTERACTIVE, old_interactive, 0);
- free(old_interactive);
- }
-
- return result;
-}
-
-int
-dispatch_load_file_int(int quiet)
-{
- FILE *fp;
- char *cp;
- int i;
- qelement *list;
-
- static const char *names[] = {
- "install.cfg",
- "/stand/install.cfg",
- "/tmp/install.cfg",
- NULL
- };
-
- fp = NULL;
- cp = variable_get(VAR_CONFIG_FILE);
- if (!cp) {
- for (i = 0; names[i]; i++)
- if ((fp = fopen(names[i], "r")) != NULL)
- break;
- } else
- fp = fopen(cp, "r");
-
- if (!fp) {
- if (!quiet)
- msgConfirm("Unable to open %s: %s", cp, strerror(errno));
- return DITEM_FAILURE;
- }
-
- list = dispatch_load_fp(fp);
- fclose(fp);
-
- return dispatch_execute(list);
-}
-
-int
-dispatch_load_file(dialogMenuItem *self)
-{
- return dispatch_load_file_int(FALSE);
-}
-
-int
-dispatch_load_floppy(dialogMenuItem *self)
-{
- int what = DITEM_SUCCESS;
- extern char *distWanted;
- char *cp;
- FILE *fp;
- qelement *list;
-
- mediaClose();
- cp = variable_get_value(VAR_INSTALL_CFG,
- "Specify the name of a configuration file\n"
- "residing on a MSDOS or UFS floppy.", 0);
- if (!cp || !*cp) {
- variable_unset(VAR_INSTALL_CFG);
- what |= DITEM_FAILURE;
- return what;
- }
-
- distWanted = cp;
- /* Try to open the floppy drive */
- if (DITEM_STATUS(mediaSetFloppy(NULL)) == DITEM_FAILURE) {
- msgConfirm("Unable to set media device to floppy.");
- what |= DITEM_FAILURE;
- mediaClose();
- return what;
- }
-
- if (!mediaDevice->init(mediaDevice)) {
- msgConfirm("Unable to mount floppy filesystem.");
- what |= DITEM_FAILURE;
- mediaClose();
- return what;
- }
-
- fp = mediaDevice->get(mediaDevice, cp, TRUE);
- if (fp) {
- list = dispatch_load_fp(fp);
- fclose(fp);
- mediaClose();
-
- what |= dispatch_execute(list);
- }
- else {
- if (!variable_get(VAR_NO_ERROR))
- msgConfirm("Configuration file '%s' not found.", cp);
- variable_unset(VAR_INSTALL_CFG);
- what |= DITEM_FAILURE;
- mediaClose();
- }
- return what;
-}
-
diff --git a/usr.sbin/sade/dmenu.c b/usr.sbin/sade/dmenu.c
deleted file mode 100644
index 7f113fc132b3..000000000000
--- a/usr.sbin/sade/dmenu.c
+++ /dev/null
@@ -1,316 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last attempt in the `sysinstall' line, the next
- * generation being slated for what's essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 "sysinstall.h"
-#include <errno.h>
-
-#define MAX_MENU 15
-
-static Boolean exited;
-
-int
-dmenuDisplayFile(dialogMenuItem *tmp)
-{
- systemDisplayHelp((char *)tmp->data);
- return DITEM_SUCCESS;
-}
-
-int
-dmenuSubmenu(dialogMenuItem *tmp)
-{
- return (dmenuOpenSimple((DMenu *)(tmp->data), FALSE) ? DITEM_SUCCESS : DITEM_FAILURE);
-}
-
-int
-dmenuSystemCommand(dialogMenuItem *self)
-{
- WINDOW *w = NULL; /* Keep lint happy */
-
- /* If aux is set, the command is known not to produce any screen-spoiling output */
- if (!self->aux)
- w = savescr();
- systemExecute((char *)self->data);
- if (!self->aux)
- restorescr(w);
- return DITEM_SUCCESS;
-}
-
-int
-dmenuSystemCommandBox(dialogMenuItem *tmp)
-{
- WINDOW *w = savescr();
-
- use_helpfile(NULL);
- use_helpline("Select OK to dismiss this dialog");
- dialog_prgbox(tmp->title, (char *)tmp->data, 22, 76, 1, 1);
- restorescr(w);
- return DITEM_SUCCESS;
-}
-
-int
-dmenuExit(dialogMenuItem *tmp)
-{
- exited = TRUE;
- return DITEM_LEAVE_MENU;
-}
-
-int
-dmenuSetVariable(dialogMenuItem *tmp)
-{
- variable_set((char *)tmp->data, *((char *)tmp->data) != '_');
- return DITEM_SUCCESS;
-}
-
-int
-dmenuSetVariables(dialogMenuItem *tmp)
-{
- char *cp1, *cp2;
- char *copy = strdup((char *)tmp->data);
-
- for (cp1 = copy; cp1 != NULL;) {
- cp2 = index(cp1, ',');
- if (cp2 != NULL) *cp2++ = '\0';
- variable_set(cp1, *cp1 != '_');
- cp1 = cp2;
- }
- free(copy);
- return DITEM_SUCCESS;
-}
-
-int
-dmenuSetKmapVariable(dialogMenuItem *tmp)
-{
- char *lang;
- int err;
-
- variable_set((char *)tmp->data, TRUE);
- lang = variable_get(VAR_KEYMAP);
- if (lang != NULL)
- {
- err = loadKeymap(lang);
- if (err == -1)
- msgConfirm("No appropriate keyboard map found, sorry.");
- else if (err == -2)
- msgConfirm("Error installing keyboard map, errno = %d.", errno);
- }
- return DITEM_SUCCESS;
-}
-
-int
-dmenuToggleVariable(dialogMenuItem *tmp)
-{
- char *var, *cp;
- int status;
-
- if (!(var = strdup((char *)tmp->data))) {
- msgConfirm("Incorrect data field for `%s'!", tmp->title);
- return DITEM_FAILURE;
- }
- if (!(cp = index(var, '='))) {
- msgConfirm("Data field for %s is not in var=value format!", tmp->title);
- return DITEM_FAILURE;
- }
- status = variable_check(var);
- *cp = '\0';
- variable_set2(var, status ? "NO" : "YES", *var != '_');
- free(var);
- return DITEM_SUCCESS;
-}
-
-int
-dmenuISetVariable(dialogMenuItem *tmp)
-{
- char *ans, *var;
-
- if (!(var = (char *)tmp->data)) {
- msgConfirm("Incorrect data field for `%s'!", tmp->title);
- return DITEM_FAILURE;
- }
- ans = msgGetInput(variable_get(var), tmp->title, 1);
- if (!ans)
- return DITEM_FAILURE;
- else if (!*ans)
- variable_unset(var);
- else
- variable_set2(var, ans, *var != '_');
- return DITEM_SUCCESS;
-}
-
-int
-dmenuSetFlag(dialogMenuItem *tmp)
-{
- if (*((unsigned int *)tmp->data) & tmp->aux)
- *((unsigned int *)tmp->data) &= ~tmp->aux;
- else
- *((unsigned int *)tmp->data) |= tmp->aux;
- return DITEM_SUCCESS;
-}
-
-int
-dmenuSetValue(dialogMenuItem *tmp)
-{
- *((unsigned int *)tmp->data) = tmp->aux;
- return DITEM_SUCCESS;
-}
-
-/* Traverse menu but give user no control over positioning */
-Boolean
-dmenuOpenSimple(DMenu *menu, Boolean buttons)
-{
- int choice, scroll, curr, max;
-
- choice = scroll = curr = max = 0;
- return dmenuOpen(menu, &choice, &scroll, &curr, &max, buttons);
-}
-
-/* Work functions for the state hook */
-int
-dmenuFlagCheck(dialogMenuItem *item)
-{
- return (*((unsigned int *)item->data) & item->aux);
-}
-
-int
-dmenuVarCheck(dialogMenuItem *item)
-{
- char *w;
-
- w = (char *)item->aux;
- if (!w)
- w = (char *)item->data;
- return variable_check(w);
-}
-
-int
-dmenuVarsCheck(dialogMenuItem *item)
-{
- int res, init;
- char *w, *cp1, *cp2;
- char *copy;
-
- w = (char *)item->aux;
- if (!w)
- w = (char *)item->data;
- if (!w)
- return FALSE;
-
- copy = strdup(w);
- res = TRUE;
- init = FALSE;
- for (cp1 = copy; cp1 != NULL;) {
- init = TRUE;
- cp2 = index(cp1, ',');
- if (cp2 != NULL)
- *cp2++ = '\0';
- res = res && variable_check(cp1);
- cp1 = cp2;
- }
- free(copy);
- return res && init;
-}
-
-int
-dmenuRadioCheck(dialogMenuItem *item)
-{
- return (*((unsigned int *)item->data) == item->aux);
-}
-
-static int
-menu_height(DMenu *menu, int n)
-{
- int max;
- char *t;
-
- max = MAX_MENU;
- if (StatusLine > 24)
- max += StatusLine - 24;
- for (t = menu->prompt; *t; t++) {
- if (*t == '\n')
- --max;
- }
- return n > max ? max : n;
-}
-
-/* Traverse over an internal menu */
-Boolean
-dmenuOpen(DMenu *menu, int *choice, int *scroll, int *curr, int *max, Boolean buttons)
-{
- int n, rval = 0;
- dialogMenuItem *items;
-
- items = menu->items;
- if (buttons)
- items += 2;
- /* Count up all the items */
- for (n = 0; items[n].title; n++);
-
- while (1) {
- char buf[FILENAME_MAX];
- WINDOW *w = savescr();
-
- /* Any helpful hints, put 'em up! */
- use_helpline(menu->helpline);
- use_helpfile(systemHelpFile(menu->helpfile, buf));
- dialog_clear_norefresh();
- /* Pop up that dialog! */
- if (menu->type & DMENU_NORMAL_TYPE)
- rval = dialog_menu((u_char *)menu->title, (u_char *)menu->prompt, -1, -1,
- menu_height(menu, n), -n, items, (char *)buttons, choice, scroll);
-
- else if (menu->type & DMENU_RADIO_TYPE)
- rval = dialog_radiolist((u_char *)menu->title, (u_char *)menu->prompt, -1, -1,
- menu_height(menu, n), -n, items, (char *)buttons);
-
- else if (menu->type & DMENU_CHECKLIST_TYPE)
- rval = dialog_checklist((u_char *)menu->title, (u_char *)menu->prompt, -1, -1,
- menu_height(menu, n), -n, items, (char *)buttons);
- else
- msgFatal("Menu: `%s' is of an unknown type\n", menu->title);
- if (exited) {
- exited = FALSE;
- restorescr(w);
- return TRUE;
- }
- else if (rval) {
- restorescr(w);
- return FALSE;
- }
- else if (menu->type & DMENU_SELECTION_RETURNS) {
- restorescr(w);
- return TRUE;
- }
- }
-}
diff --git a/usr.sbin/sade/globals.c b/usr.sbin/sade/globals.c
deleted file mode 100644
index 2dccef2ab6fc..000000000000
--- a/usr.sbin/sade/globals.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last program in the `sysinstall' line - the next
- * generation being essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 "sysinstall.h"
-
-/*
- * Various global variables and an initialization hook to set them to
- * whatever values we feel are appropriate.
- */
-
-int DebugFD; /* Where diagnostic output goes */
-Boolean Fake; /* Only pretend to be useful */
-Boolean RunningAsInit; /* Are we running as init? */
-Boolean DialogActive; /* Is libdialog initialized? */
-Boolean ColorDisplay; /* Are we on a color display? */
-Boolean OnVTY; /* Are we on a VTY? */
-Boolean USAResident; /* Are we cryptographically challenged? */
-Variable *VarHead; /* The head of the variable chain */
-Device *mediaDevice; /* Where we're installing from */
-int BootMgr; /* Which boot manager we're using */
-int StatusLine; /* Where to stick our status messages */
-jmp_buf BailOut; /* Beam me up, scotty! The natives are pissed! */
-
-/*
- * Yes, I know some of these are already automatically initialized as
- * globals. I simply find it clearer to set everything explicitly.
- */
-void
-globalsInit(void)
-{
- DebugFD = -1;
- ColorDisplay = FALSE;
- Fake = FALSE;
- OnVTY = FALSE;
- DialogActive = FALSE;
- VarHead = NULL;
- mediaDevice = NULL;
- RunningAsInit = FALSE;
- USAResident = FALSE;
-}
diff --git a/usr.sbin/sade/help/partition.hlp b/usr.sbin/sade/help/partition.hlp
deleted file mode 100644
index 6004d751b451..000000000000
--- a/usr.sbin/sade/help/partition.hlp
+++ /dev/null
@@ -1,118 +0,0 @@
-This is the FreeBSD DiskLabel Editor.
-
-NOTE: If you're entering this editor from the update procedure then
-you probably shouldn't (C)reate anything at all but rather use only
-the (M)ount command to check and mount existing partitions for
-upgrading.
-
-If you would like the label editor to do most of the following for
-you, simply type `A' for automatic partitioning of the disk.
-
-If you wish to create partitions manually you may do so by moving the
-highlighted selection bar with the arrow keys over the FreeBSD
-partition(s) displayed at the top of the screen. Typing (C)reate
-while a partition with available free space is selected will allow you
-to create a BSD partition inside of it using some or all of its
-available space.
-
-Typing (M)ount over an existing partition entry (displayed in the
-middle of the screen) will allow you to set a mount point for it
-without initializing it. If you want it initialized, use the (T)oggle
-command to flip the Newfs flag. When Newfs is set to "Y", the
-filesystem in question will be ERASED and rebuilt from scratch!
-
-
-You should use this editor to create at least the following
-filesystems:
-
- Name Purpose Min Size? Optional?
- ---- ------- --------- ---------
- / Root filesystem 20MB No
- swap Swap space 2 * MEM No
- /usr System & user files 80MB or more Yes
-
-Note: If you do not create a /usr filesystem then your / filesystem
-will need to be bigger - at least 100MB. This is not recommended as
-any media errors that may occur during disk I/O to user files will
-corrupt the filesystem containing vital system files as well. It is
-for this reason that / is generally kept on its own filesystem, where
-it should be considered essentially "read only" in your administration
-of it.
-
-Swap space is a little tricker, and the rule of "2 * MEM" is simply a
-best-guess approximation and not necessarily accurate for your
-intended usage of the system. If you intend to use the system heavily
-in a server or multi-user application, you may be well advised to
-increase this size. You may also create swap space on multiple drives
-for a larger "total" swap and this is, in fact, recommended if you
-have multiple, fast drives for which such load-balancing can only help
-overall I/O performance.
-
-The /usr filesystem should be sized according to what kind of
-distributions you're trying to load and how many packages you intend
-to install in locations like /usr/local. You can also make /usr/local
-a separate filesystem if you don't want to risk filling up your /usr
-by mistake.
-
-Another useful filesystem to create is /var, which contains mail, news
-printer spool files and other temporary items. It is a popular
-candidate for a separate partition and should be sized according to
-your estimates of the amount of mail, news or spooled print jobs that
-may be stored there.
-
-WARNING: If you do not create a separate filesystem for /var, space
-for such files will be allocated out of the root (/) filesystem
-instead. You may therefore wish to make the / partition bigger if you
-expect a lot of mail or news and do not want to make /var its own
-partition.
-
-If you're new to this installation, you might also want to read the
-following explanation of how FreeBSD's new "slice" paradigm for
-looking at disk storage works:
-
-
-In FreeBSD's new system, a device name can be broken up into up to 3
-parts. Take a typical name like ``/dev/da0s1a'':
-
- The first three characters represent the drive name. If we had
- a system with two SCSI drives on it then we'd see /dev/da0 and
- /dev/da1 as the device entries representing the entire drives.
-
- Next you have the "slice" (or "FDISK Partition") number,
- as seen in the Partition Editor. Assuming that our da0
- contained two slices, a FreeBSD slice and a DOS slice, that
- would give us /dev/da0s1 and /dev/da0s2 as device entries pointing
- to the entire slices.
-
- Next, if a slice is a FreeBSD slice, you can have a number of
- (confusingly named) "partitions" inside of it.
-
- These partitions are where various filesystems or swap areas live,
- and using our hypothetical two-SCSI-disk machine again, we might
- have something like the following layout on da0:
-
- Name Mountpoint
- ---- ----------
- da0s1a /
- da0s1b <swap space>
- da0s1e /usr
-
-Once you understand all this, then the purpose of the label editor
-becomes fairly clear: You're carving up the FreeBSD slices displayed
-at the top of the screen into smaller pieces, which are displayed in
-the middle of the screen, and then assigning FreeBSD file system names
-(mount points) to them.
-
-You can also use the label editor to mount existing partitions/slices
-into your filesystem hierarchy, as is frequently done for DOS FAT
-slices. For FreeBSD partitions, you can also toggle the "newfs" state
-so that the partitions are either (re)created from scratch or simply
-checked and mounted (the contents are preserved).
-
-When you're done, type `Q' to exit.
-
-No actual changes will be made to the disk until you (C)ommit from the
-Install menu or (W)rite directly from this one. You're working with
-what is essentially a copy of the disk label(s), both here and in the
-FDISK Partition Editor, and the actual on-disk labels won't be
-affected by any changes you make until you explicitly say so.
diff --git a/usr.sbin/sade/help/slice.hlp b/usr.sbin/sade/help/slice.hlp
deleted file mode 100644
index 33280a4349b9..000000000000
--- a/usr.sbin/sade/help/slice.hlp
+++ /dev/null
@@ -1,59 +0,0 @@
-This is the Main Slice (``FDISK'' or PC-style Partition) Editor.
-
-Possible commands are printed at the bottom and the Master Boot Record
-contents are shown at the top. You can move up and down with the
-arrow keys and (C)reate a new slice whenever the highlighted
-selection bar is over a slice whose type is marked as "unused."
-
-You are expected to leave this screen with at least one slice
-marked "FreeBSD." Note that unlike Linux, you don't need to create
-multiple FreeBSD FDISK partition entries for different things like
-swap, file systems, etc. The usual convention is to create ONE
-FreeBSD slice (FDISK partition) per drive and then subsection this slice
-into swap and file systems with the Label editor.
-
-No actual changes will be made to the disk until you (C)ommit from the
-Install menu or use the (W)rite option here! You're working with what
-is essentially a copy of the disk label(s), both here and in the Label
-Editor.
-
-If you want to use the entire disk for FreeBSD, type `A'. You'll be
-asked whether or not you wish to keep the disk (potentially) compatible
-with other operating systems, i.e. the information in the FDISK table
-should be kept valid. If you select the default of `Yes', slices will be
-aligned to fictitious cylinder boundaries and space will be reserved
-in front of the FreeBSD slice for a [future] possible boot manager.
-
-For the truly dedicated disk case, you can select `No' at the
-compatibility prompt. In that case, all BIOS geometry considerations
-will no longer be in effect and you can safely ignore any
-``The detected geometry is invalid'' warning messages you may later
-see. It is also not necessary in this case to set a slice bootable
-or install an MBR boot manager as both things are then irrelevant.
-
-The FreeBSD slice will start at absolute sector 0 of the disk (so that
-FreeBSD's disk label is identical to the Master Boot Record) and
-extend to the very last sector of the disk medium. Needless to say,
-such a disk cannot have any sort of a boot manager, `disk manager',
-or anything else that has to interact with the BIOS. This option is
-therefore only considered safe for SCSI disks and most IDE disks and
-is primarily intended for people who are going to set up a dedicated
-FreeBSD server or workstation, not a typical `home PC'.
-
-The flags field has the following legend:
-
- '=' -- This slice is properly aligned.
- '>' -- This slice doesn't end before cylinder 1024
- 'R' -- This slice contains the root (/) filesystem
- 'B' -- Slice employs BAD144 bad-spot handling
- 'C' -- This is the FreeBSD 2.0-compatibility slice (default)
- 'A' -- This slice is marked active.
-
-If you select a slice for Bad144 handling, it will be scanned
-for bad blocks before any new filesystems are made on it.
-
-If no slice is marked Active, you will need to either install
-a Boot Manager (the option for which will be presented later in the
-installation) or set one Active before leaving this screen.
-
-To leave the slice editor, type `Q'.
diff --git a/usr.sbin/sade/install.c b/usr.sbin/sade/install.c
deleted file mode 100644
index 6e1294530f5d..000000000000
--- a/usr.sbin/sade/install.c
+++ /dev/null
@@ -1,1140 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last program in the `sysinstall' line - the next
- * generation being essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 "sysinstall.h"
-#include <ctype.h>
-#include <sys/disklabel.h>
-#include <sys/errno.h>
-#include <sys/ioctl.h>
-#include <sys/fcntl.h>
-#include <sys/wait.h>
-#include <sys/param.h>
-#define MSDOSFS
-#include <sys/mount.h>
-#include <ufs/ufs/ufsmount.h>
-#include <msdosfs/msdosfsmount.h>
-#undef MSDOSFS
-#include <sys/stat.h>
-#include <sys/sysctl.h>
-#include <unistd.h>
-#include <termios.h>
-
-static void create_termcap(void);
-static void fixit_common(void);
-
-#define TERMCAP_FILE "/usr/share/misc/termcap"
-
-static void installConfigure(void);
-
-Boolean
-checkLabels(Boolean whinge, Chunk **rdev, Chunk **sdev, Chunk **udev, Chunk **vdev)
-{
- Device **devs;
- Boolean status;
- Disk *disk;
- Chunk *c1, *c2, *rootdev, *swapdev, *usrdev, *vardev;
- int i;
-
- /* Don't allow whinging if noWarn is set */
- if (variable_get(VAR_NO_WARN))
- whinge = FALSE;
-
- status = TRUE;
- *rdev = *sdev = *udev = *vdev = rootdev = swapdev = usrdev = vardev = NULL;
-
- /* We don't need to worry about root/usr/swap if we're already multiuser */
- if (!RunningAsInit)
- return status;
-
- devs = deviceFind(NULL, DEVICE_TYPE_DISK);
- /* First verify that we have a root device */
- for (i = 0; devs[i]; i++) {
- if (!devs[i]->enabled)
- continue;
- disk = (Disk *)devs[i]->private;
- msgDebug("Scanning disk %s for root filesystem\n", disk->name);
- if (!disk->chunks)
- msgFatal("No chunk list found for %s!", disk->name);
- for (c1 = disk->chunks->part; c1; c1 = c1->next) {
- if (c1->type == freebsd) {
- for (c2 = c1->part; c2; c2 = c2->next) {
- if (c2->type == part && c2->subtype != FS_SWAP && c2->private_data) {
- if (!strcmp(((PartInfo *)c2->private_data)->mountpoint, "/")) {
- if (rootdev) {
- if (whinge)
- msgConfirm("WARNING: You have more than one root device set?!\n"
- "Using the first one found.");
- continue;
- }
- else {
- rootdev = c2;
- if (isDebug())
- msgDebug("Found rootdev at %s!\n", rootdev->name);
- }
- }
- else if (!strcmp(((PartInfo *)c2->private_data)->mountpoint, "/usr")) {
- if (usrdev) {
- if (whinge)
- msgConfirm("WARNING: You have more than one /usr filesystem.\n"
- "Using the first one found.");
- continue;
- }
- else {
- usrdev = c2;
- if (isDebug())
- msgDebug("Found usrdev at %s!\n", usrdev->name);
- }
- }
- else if (!strcmp(((PartInfo *)c2->private_data)->mountpoint, "/var")) {
- if (vardev) {
- if (whinge)
- msgConfirm("WARNING: You have more than one /var filesystem.\n"
- "Using the first one found.");
- continue;
- }
- else {
- vardev = c2;
- if (isDebug())
- msgDebug("Found vardev at %s!\n", vardev->name);
- }
- }
- }
- }
- }
- }
- }
-
- /* Now check for swap devices */
- for (i = 0; devs[i]; i++) {
- if (!devs[i]->enabled)
- continue;
- disk = (Disk *)devs[i]->private;
- msgDebug("Scanning disk %s for swap partitions\n", disk->name);
- if (!disk->chunks)
- msgFatal("No chunk list found for %s!", disk->name);
- for (c1 = disk->chunks->part; c1; c1 = c1->next) {
- if (c1->type == freebsd) {
- for (c2 = c1->part; c2; c2 = c2->next) {
- if (c2->type == part && c2->subtype == FS_SWAP && !swapdev) {
- swapdev = c2;
- if (isDebug())
- msgDebug("Found swapdev at %s!\n", swapdev->name);
- break;
- }
- }
- }
- }
- }
-
- /* Copy our values over */
- *rdev = rootdev;
- *sdev = swapdev;
- *udev = usrdev;
- *vdev = vardev;
-
- if (!rootdev && whinge) {
- msgConfirm("No root device found - you must label a partition as /\n"
- "in the label editor.");
- status = FALSE;
- }
- if (!swapdev && whinge) {
- msgConfirm("No swap devices found - you must create at least one\n"
- "swap partition.");
- status = FALSE;
- }
- return status;
-}
-
-static int
-installInitial(void)
-{
- static Boolean alreadyDone = FALSE;
- int status = DITEM_SUCCESS;
-
- if (alreadyDone)
- return DITEM_SUCCESS;
-
- if (!variable_get(DISK_LABELLED)) {
- msgConfirm("You need to assign disk labels before you can proceed with\n"
- "the installation.");
- return DITEM_FAILURE;
- }
- /* If it's labelled, assume it's also partitioned */
- if (!variable_get(DISK_PARTITIONED))
- variable_set2(DISK_PARTITIONED, "yes", 0);
-
- /* If we refuse to proceed, bail. */
- dialog_clear_norefresh();
- if (!variable_get(VAR_NO_WARN))
- if (msgYesNo(
- "Last Chance! Are you SURE you want continue the installation?\n\n"
- "If you're running this on a disk with data you wish to save\n"
- "then WE STRONGLY ENCOURAGE YOU TO MAKE PROPER BACKUPS before\n"
- "proceeding!\n\n"
- "We can take no responsibility for lost disk contents!") != 0)
- return DITEM_FAILURE;
-
- if (DITEM_STATUS(diskLabelCommit(NULL)) != DITEM_SUCCESS) {
- msgConfirm("Couldn't make filesystems properly. Aborting.");
- return DITEM_FAILURE;
- }
-
- if (!copySelf()) {
- msgConfirm("installInitial: Couldn't clone the boot floppy onto the\n"
- "root file system. Aborting!");
- return DITEM_FAILURE;
- }
-
- if (chroot("/mnt") == -1) {
- msgConfirm("installInitial: Unable to chroot to %s - this is bad!",
- "/mnt");
- return DITEM_FAILURE;
- }
-
- chdir("/");
- variable_set2(RUNNING_ON_ROOT, "yes", 0);
-
- /* Configure various files in /etc */
- if (DITEM_STATUS(configResolv(NULL)) == DITEM_FAILURE)
- status = DITEM_FAILURE;
- if (DITEM_STATUS(configFstab(NULL)) == DITEM_FAILURE)
- status = DITEM_FAILURE;
-
- /* stick a helpful shell over on the 4th VTY */
- systemCreateHoloshell();
-
- alreadyDone = TRUE;
- return status;
-}
-
-int
-installFixitHoloShell(dialogMenuItem *self)
-{
- systemCreateHoloshell();
- return DITEM_SUCCESS;
-}
-
-int
-installFixitCDROM(dialogMenuItem *self)
-{
- struct stat sb;
-
- if (!RunningAsInit)
- return DITEM_SUCCESS;
-
- variable_set2(SYSTEM_STATE, "fixit", 0);
- (void)unlink("/mnt2");
- (void)rmdir("/mnt2");
-
- while (1) {
- msgConfirm("Please insert a FreeBSD live filesystem CDROM and press return");
- if (DITEM_STATUS(mediaSetCDROM(NULL)) != DITEM_SUCCESS || !mediaDevice || !mediaDevice->init(mediaDevice)) {
- /* If we can't initialize it, it's probably not a FreeBSD CDROM so punt on it */
- mediaClose();
- if (msgYesNo("Unable to mount the CDROM - do you want to try again?") != 0)
- return DITEM_FAILURE;
- }
- else
- break;
- }
-
- /* Since the fixit code expects everything to be in /mnt2, and the CDROM mounting stuff /dist, do
- * a little kludge dance here..
- */
- if (symlink("/dist", "/mnt2")) {
- msgConfirm("Unable to symlink /mnt2 to the CDROM mount point. Please report this\n"
- "unexpected failure to freebsd-bugs@FreeBSD.org.");
- return DITEM_FAILURE;
- }
-
- /*
- * If /tmp points to /mnt2/tmp from a previous fixit floppy session, it's
- * not very good for us if we point it to the CDROM now. Rather make it
- * a directory in the root MFS then. Experienced admins will still be
- * able to mount their disk's /tmp over this if they need.
- */
- if (lstat("/tmp", &sb) == 0 && (sb.st_mode & S_IFMT) == S_IFLNK)
- (void)unlink("/tmp");
- Mkdir("/tmp");
-
- /*
- * Since setuid binaries ignore LD_LIBRARY_PATH, we indeed need the
- * ld.so.hints file. Fortunately, it's fairly small (~ 3 KB).
- */
- if (!file_readable("/var/run/ld.so.hints")) {
- Mkdir("/var/run");
- if (vsystem("/mnt2/sbin/ldconfig -s /mnt2/usr/lib")) {
- msgConfirm("Warning: ldconfig could not create the ld.so hints file.\n"
- "Dynamic executables from the CDROM likely won't work.");
- }
- }
-
- /* Yet more iggly hardcoded pathnames. */
- Mkdir("/usr/libexec");
- if (!file_readable("/usr/libexec/ld.so") && file_readable("/mnt2/usr/libexec/ld.so")) {
- if (symlink("/mnt2/usr/libexec/ld.so", "/usr/libexec/ld.so"))
- msgDebug("Couldn't link to ld.so - not necessarily a problem for ELF\n");
- }
- if (!file_readable("/usr/libexec/ld-elf.so.1")) {
- if (symlink("/mnt2/usr/libexec/ld-elf.so.1", "/usr/libexec/ld-elf.so.1")) {
- msgConfirm("Warning: could not create the symlink for ld-elf.so.1\n"
- "Dynamic executables from the CDROM likely won't work.");
- }
- }
- /* optional nicety */
- if (!file_readable("/usr/bin/vi"))
- symlink("/mnt2/usr/bin/vi", "/usr/bin/vi");
- fixit_common();
- mediaClose();
- msgConfirm("Please remove the FreeBSD fixit CDROM now.");
- return DITEM_SUCCESS;
-}
-
-int
-installFixitFloppy(dialogMenuItem *self)
-{
- struct ufs_args args;
- extern char *distWanted;
-
- if (!RunningAsInit)
- return DITEM_SUCCESS;
-
- /* Try to open the floppy drive */
- if (DITEM_STATUS(mediaSetFloppy(NULL)) == DITEM_FAILURE || !mediaDevice) {
- msgConfirm("Unable to set media device to floppy.");
- mediaClose();
- return DITEM_FAILURE;
- }
-
- memset(&args, 0, sizeof(args));
- args.fspec = mediaDevice->devname;
- mediaDevice->private = "/mnt2";
- distWanted = NULL;
- Mkdir("/mnt2");
-
- variable_set2(SYSTEM_STATE, "fixit", 0);
-
- while (1) {
- if (!mediaDevice->init(mediaDevice)) {
- if (msgYesNo("The attempt to mount the fixit floppy failed, bad floppy\n"
- "or unclean filesystem. Do you want to try again?"))
- return DITEM_FAILURE;
- }
- else
- break;
- }
- if (!directory_exists("/tmp"))
- (void)symlink("/mnt2/tmp", "/tmp");
- fixit_common();
- mediaClose();
- msgConfirm("Please remove the fixit floppy now.");
- return DITEM_SUCCESS;
-}
-
-/*
- * The common code for both fixit variants.
- */
-static void
-fixit_common(void)
-{
- pid_t child;
- int waitstatus;
-
- if (!directory_exists("/var/tmp/vi.recover")) {
- if (DITEM_STATUS(Mkdir("/var/tmp/vi.recover")) != DITEM_SUCCESS) {
- msgConfirm("Warning: Was unable to create a /var/tmp/vi.recover directory.\n"
- "vi will kvetch and moan about it as a result but should still\n"
- "be essentially usable.");
- }
- }
- if (!directory_exists("/bin"))
- (void)Mkdir("/bin");
- (void)symlink("/stand/sh", "/bin/sh");
- /* Link the /etc/ files */
- if (DITEM_STATUS(Mkdir("/etc")) != DITEM_SUCCESS)
- msgConfirm("Unable to create an /etc directory! Things are weird on this floppy..");
- else if ((symlink("/mnt2/etc/spwd.db", "/etc/spwd.db") == -1 && errno != EEXIST) ||
- (symlink("/mnt2/etc/protocols", "/etc/protocols") == -1 && errno != EEXIST) ||
- (symlink("/mnt2/etc/services", "/etc/services") == -1 && errno != EEXIST))
- msgConfirm("Couldn't symlink the /etc/ files! I'm not sure I like this..");
- if (!file_readable(TERMCAP_FILE))
- create_termcap();
- if (!(child = fork())) {
- int i, fd;
- struct termios foo;
- extern int login_tty(int);
-
- ioctl(0, TIOCNOTTY, NULL);
- for (i = getdtablesize(); i >= 0; --i)
- close(i);
- fd = open("/dev/ttyv3", O_RDWR);
- ioctl(0, TIOCSCTTY, &fd);
- dup2(0, 1);
- dup2(0, 2);
- DebugFD = 2;
- if (login_tty(fd) == -1)
- msgDebug("fixit: I can't set the controlling terminal.\n");
-
- signal(SIGTTOU, SIG_IGN);
- if (tcgetattr(0, &foo) != -1) {
- foo.c_cc[VERASE] = '\010';
- if (tcsetattr(0, TCSANOW, &foo) == -1)
- msgDebug("fixit shell: Unable to set erase character.\n");
- }
- else
- msgDebug("fixit shell: Unable to get terminal attributes!\n");
- setenv("PATH", "/bin:/sbin:/usr/bin:/usr/sbin:/stand:"
- "/mnt2/stand:/mnt2/bin:/mnt2/sbin:/mnt2/usr/bin:/mnt2/usr/sbin", 1);
- /* use the .profile from the fixit medium */
- setenv("HOME", "/mnt2", 1);
- chdir("/mnt2");
- execlp("sh", "-sh", 0);
- msgDebug("fixit shell: Failed to execute shell!\n");
- _exit(1);;
- }
- else {
- dialog_clear_norefresh();
- msgNotify("Waiting for fixit shell to exit. Go to VTY4 now by\n"
- "typing ALT-F4. When you are done, type ``exit'' to exit\n"
- "the fixit shell and be returned here.");
- (void)waitpid(child, &waitstatus, 0);
- }
- dialog_clear();
-}
-
-
-int
-installExpress(dialogMenuItem *self)
-{
- int i;
-
- dialog_clear_norefresh();
- variable_set2(SYSTEM_STATE, "express", 0);
-#ifndef __alpha__
- if (DITEM_STATUS((i = diskPartitionEditor(self))) == DITEM_FAILURE)
- return i;
-#endif
-
- if (DITEM_STATUS((i = diskLabelEditor(self))) == DITEM_FAILURE)
- return i;
-
- if (DITEM_STATUS((i = installCommit(self))) == DITEM_SUCCESS) {
- i |= DITEM_LEAVE_MENU;
- /* Give user the option of one last configuration spree */
- installConfigure();
- }
- return i;
-}
-
-/* Standard mode installation */
-int
-installStandard(dialogMenuItem *self)
-{
- int i, tries = 0;
- Device **devs;
-
- variable_set2(SYSTEM_STATE, "standard", 0);
- dialog_clear_norefresh();
-#ifndef __alpha__
- msgConfirm("In the next menu, you will need to set up a DOS-style (\"fdisk\") partitioning\n"
- "scheme for your hard disk. If you simply wish to devote all disk space\n"
- "to FreeBSD (overwriting anything else that might be on the disk(s) selected)\n"
- "then use the (A)ll command to select the default partitioning scheme followed\n"
- "by a (Q)uit. If you wish to allocate only free space to FreeBSD, move to a\n"
- "partition marked \"unused\" and use the (C)reate command.");
-
-nodisks:
- if (DITEM_STATUS(diskPartitionEditor(self)) == DITEM_FAILURE)
- return DITEM_FAILURE;
-
- if (diskGetSelectCount(&devs) <= 0 && tries < 3) {
- msgConfirm("You need to select some disks to operate on! Be sure to use SPACE\n"
- "instead of RETURN in the disk selection menu when selecting a disk.");
- ++tries;
- goto nodisks;
- }
-#endif
-
-#ifdef __alpha__
- msgConfirm("Now you need to create BSD partitions on the disk which you are\n"
- "installing to. If you have a reasonable amount of disk space (200MB or more)\n"
- "and don't have any special requirements, simply use the (A)uto command to\n"
- "allocate space automatically. If you have more specific needs or just don't\n"
- "care for the layout chosen by (A)uto, press F1 for more information on\n"
- "manual layout.");
-#else
- msgConfirm("Now you need to create BSD partitions inside of the fdisk partition(s)\n"
- "just created. If you have a reasonable amount of disk space (200MB or more)\n"
- "and don't have any special requirements, simply use the (A)uto command to\n"
- "allocate space automatically. If you have more specific needs or just don't\n"
- "care for the layout chosen by (A)uto, press F1 for more information on\n"
- "manual layout.");
-#endif
-
- if (DITEM_STATUS(diskLabelEditor(self)) == DITEM_FAILURE)
- return DITEM_FAILURE;
-
- if (DITEM_STATUS((i = installCommit(self))) == DITEM_FAILURE) {
- dialog_clear();
- msgConfirm("Installation completed with some errors. You may wish to\n"
- "scroll through the debugging messages on VTY1 with the\n"
- "scroll-lock feature. You can also choose \"No\" at the next\n"
- "prompt and go back into the installation menus to try and retry\n"
- "whichever operations have failed.");
- return i;
-
- }
- else {
- dialog_clear();
- msgConfirm("Congratulations! You now have FreeBSD installed on your system.\n\n"
- "We will now move on to the final configuration questions.\n"
- "For any option you do not wish to configure, simply select\n"
- "No.\n\n"
- "If you wish to re-enter this utility after the system is up, you\n"
- "may do so by typing: /stand/sysinstall.");
- }
- if (mediaDevice->type != DEVICE_TYPE_FTP && mediaDevice->type != DEVICE_TYPE_NFS) {
- if (!msgYesNo("Would you like to configure any Ethernet or SLIP/PPP network devices?")) {
- Device *tmp = tcpDeviceSelect();
-
- if (tmp && !((DevInfo *)tmp->private)->use_dhcp && !msgYesNo("Would you like to bring the %s interface up right now?", tmp->name))
- if (!tmp->init(tmp))
- msgConfirm("Initialization of %s device failed.", tmp->name);
- }
- dialog_clear_norefresh();
- }
-
- if (msgYesNo("Will this machine be a leaf node (e.g. will not forward packets)\n"
- "between interfaces)?"))
- variable_set2("gateway_enable", "YES", 1);
-
- if (msgYesNo("Do you want to grant only normal users FTP access to this\n"
- "host (e.g. no anonymous FTP connections)?"))
- configAnonFTP(self);
-
- if (!msgYesNo("Do you want to configure this machine as an NFS server?"))
- configNFSServer(self);
-
- dialog_clear_norefresh();
- if (!msgYesNo("Do you want to configure this machine as an NFS client?"))
- variable_set2("nfs_client_enable", "YES", 1);
-
- if (!msgYesNo("Would you like to customize your system console settings?"))
- dmenuOpenSimple(&MenuSyscons, FALSE);
-
- dialog_clear_norefresh();
- if (!msgYesNo("Would you like to set this machine's time zone now?"))
- systemExecute("tzsetup");
-
-#ifdef __i386__
- dialog_clear_norefresh();
- if (!msgYesNo("Would you like to enable Linux binary compatibility?"))
- (void)configLinux(self);
-#endif
-
- dialog_clear();
- if (USAResident) {
- if (!msgYesNo("I see that you are \"USA_RESIDENT\" according to your earlier\n"
- "response to the CRYPTO distribution dialog. Do you want to try and\n"
- "load the rsaref package from the current media? Some restrictions on\n"
- "usage may apply, so be sure to read the package installation output!")) {
- dialog_clear();
- if (DITEM_STATUS(package_add("rsaref")) != DITEM_SUCCESS) {
- msgConfirm("Unable to find an rsaref package on the current intallation media.\n"
- "You may wish to switch media types and try again, perhaps\n"
- "from an FTP server which carries this package.");
- }
- dialog_clear();
- }
- }
- else {
- if (!msgYesNo("I see that you are not \"USA_RESIDENT\" according to your earlier\n"
- "response to the CRYPTO distribution dialog. Do you want to try and\n"
- "load the rsaintl package from the current media?")) {
- if (DITEM_STATUS(package_add("rsaintl")) != DITEM_SUCCESS) {
- msgConfirm("Unable to find an rsaintl package on the current intallation media.\n"
- "You may wish to switch media types and try again, perhaps\n"
- "from an FTP server which carries this package.");
- }
- }
- }
-
- dialog_clear_norefresh();
- if (!msgYesNo("Does this system have a mouse attached to it?"))
- dmenuOpenSimple(&MenuMouse, FALSE);
-
- /* Now would be a good time to checkpoint the configuration data */
- configRC_conf();
- sync();
-
- if (directory_exists("/usr/X11R6")) {
- dialog_clear_norefresh();
- if (!msgYesNo("Would you like to configure your X server at this time?"))
- (void)configXSetup(self);
- }
-
- dialog_clear_norefresh();
- if (!msgYesNo("The FreeBSD package collection is a collection of thousands of ready-to-run\n"
- "applications, from text editors to games to WEB servers and more. Would you\n"
- "like to browse the collection now?")) {
- (void)configPackages(self);
- }
-
- if (!msgYesNo("Would you like to add any initial user accounts to the system?\n"
- "Adding at least one account for yourself at this stage is suggested\n"
- "since working as the \"root\" user is dangerous (it is easy to do\n"
- "things which adversely affect the entire system)."))
- (void)configUsers(self);
-
- msgConfirm("Now you must set the system manager's password.\n"
- "This is the password you'll use to log in as \"root\".");
- if (!systemExecute("passwd root"))
- variable_set2("root_password", "YES", 0);
-
- /* XXX Put whatever other nice configuration questions you'd like to ask the user here XXX */
-
- /* Give user the option of one last configuration spree */
- dialog_clear_norefresh();
- installConfigure();
- return DITEM_LEAVE_MENU;
-}
-
-/* The version of commit we call from the Install Custom menu */
-int
-installCustomCommit(dialogMenuItem *self)
-{
- int i;
-
- i = installCommit(self);
- if (DITEM_STATUS(i) == DITEM_SUCCESS) {
- /* Give user the option of one last configuration spree */
- installConfigure();
- return i;
- }
- else
- msgConfirm("The commit operation completed with errors. Not\n"
- "updating /etc files.");
- return i;
-}
-
-/*
- * What happens when we finally decide to going ahead with the installation.
- *
- * This is broken into multiple stages so that the user can do a full
- * installation but come back here again to load more distributions,
- * perhaps from a different media type. This would allow, for
- * example, the user to load the majority of the system from CDROM and
- * then use ftp to load just the CRYPTO dist.
- */
-int
-installCommit(dialogMenuItem *self)
-{
- int i;
- char *str;
-
- dialog_clear_norefresh();
- if (!Dists)
- distConfig(NULL);
-
- if (!Dists)
- if (!dmenuOpenSimple(&MenuDistributions, FALSE) && !Dists)
- return DITEM_FAILURE;
-
- if (!mediaVerify())
- return DITEM_FAILURE;
-
- str = variable_get(SYSTEM_STATE);
- if (isDebug())
- msgDebug("installCommit: System state is `%s'\n", str);
-
- /* Installation stuff we wouldn't do to a running system */
- if (RunningAsInit && DITEM_STATUS((i = installInitial())) == DITEM_FAILURE)
- return i;
-
-try_media:
- if (!mediaDevice->init(mediaDevice)) {
- if (!msgYesNo("Unable to initialize selected media. Would you like to\n"
- "adjust your media configuration and try again?")) {
- mediaDevice = NULL;
- if (!mediaVerify())
- return DITEM_FAILURE;
- else
- goto try_media;
- }
- else
- return DITEM_FAILURE;
- }
-
- /* Now go get it all */
- i = distExtractAll(self);
-
- /* When running as init, *now* it's safe to grab the rc.foo vars */
- installEnvironment();
-
- variable_set2(SYSTEM_STATE, DITEM_STATUS(i) == DITEM_FAILURE ? "error-install" : "full-install", 0);
-
- return i;
-}
-
-static void
-installConfigure(void)
-{
- /* Final menu of last resort */
- if (!msgYesNo("Visit the general configuration menu for a chance to set\n"
- "any last options?"))
- dmenuOpenSimple(&MenuConfigure, FALSE);
- configRC_conf();
- sync();
-}
-
-int
-installFixupBin(dialogMenuItem *self)
-{
- Device **devs;
- char *cp;
- int i;
- FILE *fp;
- int kstat = 1;
-
- /* All of this is done only as init, just to be safe */
- if (RunningAsInit) {
- /* Fix up kernel first */
- if (!file_readable("/kernel")) {
- char *generic_kernel = "/kernel.GENERIC";
- if (file_readable(generic_kernel)) {
- if (vsystem("cp -p %s /kernel", generic_kernel)) {
- msgConfirm("Unable to copy /kernel into place!");
- return DITEM_FAILURE;
- }
-#ifndef __alpha__
- /* Snapshot any boot -c changes back to the new kernel */
- cp = variable_get(VAR_KGET);
- if (cp && (*cp == 'Y' || *cp == 'y')) {
- if ((kstat = kget("/boot/kernel.conf")) != NULL) {
- msgConfirm("Kernel copied OK, but unable to save boot -c changes\n"
- "to it. See the debug screen (ALT-F2) for details.");
- }
- }
- if ((fp = fopen("/boot/loader.conf", "a")) != NULL) {
- fprintf(fp, "# -- sysinstall generated deltas -- #\n");
- if (!kstat)
- fprintf(fp, "userconfig_script_load=\"YES\"\n");
- if (!OnVTY)
- fprintf(fp, "console=\"comconsole\"\n");
- fclose(fp);
- }
-#endif
- }
- else {
- msgConfirm("Can't find a kernel image to link to on the root file system!\n"
- "You're going to have a hard time getting this system to\n"
- "boot from the hard disk, I'm afraid!");
- return DITEM_FAILURE;
- }
- }
-
- /* BOGON #1: Resurrect /dev after bin distribution screws it up */
- dialog_clear_norefresh();
- msgNotify("Remaking all devices.. Please wait!");
- if (vsystem("cd /dev; sh MAKEDEV all")) {
- msgConfirm("MAKEDEV returned non-zero status");
- return DITEM_FAILURE | DITEM_RESTORE;
- }
-
- dialog_clear_norefresh();
- msgNotify("Resurrecting /dev entries for slices..");
- devs = deviceFind(NULL, DEVICE_TYPE_DISK);
- if (!devs)
- msgFatal("Couldn't get a disk device list!");
-
- /* Resurrect the slices that the former clobbered */
- for (i = 0; devs[i]; i++) {
- Disk *disk = (Disk *)devs[i]->private;
- Chunk *c1;
-
- if (!devs[i]->enabled)
- continue;
- if (!disk->chunks)
- msgFatal("No chunk list found for %s!", disk->name);
- for (c1 = disk->chunks->part; c1; c1 = c1->next) {
- if (c1->type == freebsd) {
- dialog_clear_norefresh();
- msgNotify("Making slice entries for %s", c1->name);
- if (vsystem("cd /dev; sh MAKEDEV %sh", c1->name)) {
- msgConfirm("Unable to make slice entries for %s!", c1->name);
- return DITEM_FAILURE | DITEM_RESTORE;
- }
- }
- }
- }
-
- /* BOGON #2: We leave /etc in a bad state */
- chmod("/etc", 0755);
-
- /* BOGON #3: No /var/db/mountdtab complains */
- Mkdir("/var/db");
- creat("/var/db/mountdtab", 0644);
-
- /* BOGON #4: /compat created by default in root fs */
- Mkdir("/usr/compat");
- vsystem("ln -s /usr/compat /compat");
-
- /* BOGON #5: aliases database not build for bin */
- vsystem("newaliases");
-
- /* Now run all the mtree stuff to fix things up */
- vsystem("mtree -deU -f /etc/mtree/BSD.root.dist -p /");
- vsystem("mtree -deU -f /etc/mtree/BSD.var.dist -p /var");
- vsystem("mtree -deU -f /etc/mtree/BSD.usr.dist -p /usr");
-
- /* Do all the last ugly work-arounds here */
- }
- return DITEM_SUCCESS | DITEM_RESTORE;
-}
-
-#ifdef X_AS_PKG
-int
-installX11package(dialogMenuItem *self)
-{
- WINDOW *w = savescr();
- int i;
-
- dialog_clear_norefresh();
- msgNotify("Installing XFree86 package...");
- i = package_add("XFree86");
- restorescr(w);
- return i;
-}
-#endif
-
-/* Fix side-effects from the the XFree86 installation */
-int
-installFixupXFree(dialogMenuItem *self)
-{
- /* BOGON #1: XFree86 requires various specialized fixups */
- if (directory_exists("/usr/X11R6")) {
- dialog_clear_norefresh();
- msgNotify("Fixing permissions in XFree86 tree..");
- vsystem("chmod -R a+r /usr/X11R6");
- vsystem("find /usr/X11R6 -type d | xargs chmod a+x");
-
-#ifndef X_AS_PKG
- /* Also do bogus minimal package registration so ports don't whine */
- if (file_readable("/usr/X11R6/lib/X11/pkgreg.tar.gz")) {
- dialog_clear_norefresh();
- msgNotify("Installing package metainfo..");
- vsystem("tar xpzf /usr/X11R6/lib/X11/pkgreg.tar.gz -C / && rm /usr/X11R6/lib/X11/pkgreg.tar.gz");
- }
-#endif
- }
- return DITEM_SUCCESS | DITEM_RESTORE;
-}
-
-/* Go newfs and/or mount all the filesystems we've been asked to */
-int
-installFilesystems(dialogMenuItem *self)
-{
- int i;
- Disk *disk;
- Chunk *c1, *c2, *rootdev, *swapdev, *usrdev, *vardev;
- Device **devs;
- PartInfo *root;
- char dname[80];
- extern int MakeDevChunk(Chunk *c, char *n);
- Boolean upgrade = FALSE;
-
- /* If we've already done this, bail out */
- if (!variable_cmp(DISK_LABELLED, "written"))
- return DITEM_SUCCESS;
-
- upgrade = !variable_cmp(SYSTEM_STATE, "upgrade");
- if (!checkLabels(TRUE, &rootdev, &swapdev, &usrdev, &vardev))
- return DITEM_FAILURE;
-
- if (rootdev)
- root = (PartInfo *)rootdev->private_data;
- else
- root = NULL;
-
- command_clear();
- if (swapdev && RunningAsInit) {
- /* As the very first thing, try to get ourselves some swap space */
- sprintf(dname, "/dev/%s", swapdev->name);
- if (!Fake && (!MakeDevChunk(swapdev, "/dev") || !file_readable(dname))) {
- msgConfirm("Unable to make device node for %s in /dev!\n"
- "The creation of filesystems will be aborted.", dname);
- return DITEM_FAILURE;
- }
-
- if (!Fake) {
- if (!swapon(dname)) {
- dialog_clear_norefresh();
- msgNotify("Added %s as initial swap device", dname);
- }
- else {
- msgConfirm("WARNING! Unable to swap to %s: %s\n"
- "This may cause the installation to fail at some point\n"
- "if you don't have a lot of memory.", dname, strerror(errno));
- }
- }
- }
-
- if (rootdev && RunningAsInit) {
- /* Next, create and/or mount the root device */
- sprintf(dname, "/dev/r%s", rootdev->name);
- if (!Fake && (!MakeDevChunk(rootdev, "/dev") || !file_readable(dname))) {
- msgConfirm("Unable to make device node for %s in /dev!\n"
- "The creation of filesystems will be aborted.", dname);
- return DITEM_FAILURE | DITEM_RESTORE;
- }
- if (strcmp(root->mountpoint, "/"))
- msgConfirm("Warning: %s is marked as a root partition but is mounted on %s", rootdev->name, root->mountpoint);
-
- if (root->newfs && (!upgrade || !msgYesNo("You are upgrading - are you SURE you want to newfs the root partition?"))) {
- int i;
-
- dialog_clear_norefresh();
- msgNotify("Making a new root filesystem on %s", dname);
- i = vsystem("%s %s", root->newfs_cmd, dname);
- if (i) {
- msgConfirm("Unable to make new root filesystem on %s!\n"
- "Command returned status %d", dname, i);
- return DITEM_FAILURE | DITEM_RESTORE;
- }
- }
- else {
- if (!upgrade) {
- msgConfirm("Warning: Using existing root partition. It will be assumed\n"
- "that you have the appropriate device entries already in /dev.");
- }
- dialog_clear_norefresh();
- msgNotify("Checking integrity of existing %s filesystem.", dname);
- i = vsystem("fsck -y %s", dname);
- if (i)
- msgConfirm("Warning: fsck returned status of %d for %s.\n"
- "This partition may be unsafe to use.", i, dname);
- }
-
- /* Switch to block device */
- sprintf(dname, "/dev/%s", rootdev->name);
- if (Mount("/mnt", dname)) {
- msgConfirm("Unable to mount the root file system on %s! Giving up.", dname);
- return DITEM_FAILURE | DITEM_RESTORE;
- }
- }
-
- /* Now buzz through the rest of the partitions and mount them too */
- devs = deviceFind(NULL, DEVICE_TYPE_DISK);
- for (i = 0; devs[i]; i++) {
- if (!devs[i]->enabled)
- continue;
-
- disk = (Disk *)devs[i]->private;
- if (!disk->chunks) {
- msgConfirm("No chunk list found for %s!", disk->name);
- return DITEM_FAILURE | DITEM_RESTORE;
- }
- if (RunningAsInit && root && (root->newfs || upgrade)) {
- Mkdir("/mnt/dev");
- if (!Fake)
- MakeDevDisk(disk, "/mnt/dev");
- }
- else if (!RunningAsInit && !Fake)
- MakeDevDisk(disk, "/dev");
-
- for (c1 = disk->chunks->part; c1; c1 = c1->next) {
- if (c1->type == freebsd) {
- for (c2 = c1->part; c2; c2 = c2->next) {
- if (c2->type == part && c2->subtype != FS_SWAP && c2->private_data) {
- PartInfo *tmp = (PartInfo *)c2->private_data;
-
- /* Already did root */
- if (c2 == rootdev)
- continue;
-
- if (tmp->newfs && (!upgrade || !msgYesNo("You are upgrading - are you SURE you want to newfs /dev/%s?", c2->name)))
- command_shell_add(tmp->mountpoint, "%s %s/dev/r%s", tmp->newfs_cmd, RunningAsInit ? "/mnt" : "", c2->name);
- else
- command_shell_add(tmp->mountpoint, "fsck -y %s/dev/r%s", RunningAsInit ? "/mnt" : "", c2->name);
- command_func_add(tmp->mountpoint, Mount, c2->name);
- }
- else if (c2->type == part && c2->subtype == FS_SWAP) {
- char fname[80];
- int i;
-
- if (c2 == swapdev)
- continue;
- sprintf(fname, "%s/dev/%s", RunningAsInit ? "/mnt" : "", c2->name);
- i = (Fake || swapon(fname));
- if (!i) {
- dialog_clear_norefresh();
- msgNotify("Added %s as an additional swap device", fname);
- }
- else {
- msgConfirm("Unable to add %s as a swap device: %s", fname, strerror(errno));
- }
- }
- }
- }
- else if (c1->type == fat && c1->private_data && (root->newfs || upgrade)) {
- char name[FILENAME_MAX];
-
- sprintf(name, "%s/%s", RunningAsInit ? "/mnt" : "", ((PartInfo *)c1->private_data)->mountpoint);
- Mkdir(name);
- }
- }
- }
-
- if (RunningAsInit) {
- dialog_clear_norefresh();
- msgNotify("Copying initial device files..");
- /* Copy the boot floppy's dev files */
- if ((root->newfs || upgrade) && vsystem("find -x /dev | cpio %s -pdum /mnt", cpioVerbosity())) {
- msgConfirm("Couldn't clone the /dev files!");
- return DITEM_FAILURE | DITEM_RESTORE;
- }
- }
-
- command_sort();
- command_execute();
- dialog_clear_norefresh();
- return DITEM_SUCCESS | DITEM_RESTORE;
-}
-
-static char *
-getRelname(void)
-{
- static char buf[64];
- int sz = (sizeof buf) - 1;
-
- if (sysctlbyname("kern.osrelease", buf, &sz, NULL, 0) != -1) {
- buf[sz] = '\0';
- return buf;
- }
- else
- return "<unknown>";
-}
-
-/* Initialize various user-settable values to their defaults */
-int
-installVarDefaults(dialogMenuItem *self)
-{
- char *cp;
-
- /* Set default startup options */
- variable_set2(VAR_RELNAME, getRelname(), 0);
- variable_set2(VAR_CPIO_VERBOSITY, "high", 0);
- variable_set2(VAR_KGET, "YES", 0);
- variable_set2(VAR_TAPE_BLOCKSIZE, DEFAULT_TAPE_BLOCKSIZE, 0);
- variable_set2(VAR_INSTALL_ROOT, "/", 0);
- variable_set2(VAR_INSTALL_CFG, "install.cfg", 0);
- variable_set2(VAR_TRY_DHCP, "NO", 0); /* For now */
- cp = getenv("EDITOR");
- if (!cp)
- cp = "/usr/bin/ee";
- variable_set2(VAR_EDITOR, cp, 0);
- variable_set2(VAR_FTP_USER, "ftp", 0);
- variable_set2(VAR_BROWSER_PACKAGE, "lynx", 0);
- variable_set2(VAR_BROWSER_BINARY, "/usr/local/bin/lynx", 0);
- variable_set2(VAR_FTP_STATE, "passive", 0);
- variable_set2(VAR_NFS_SECURE, "NO", -1);
- variable_set2(VAR_PKG_TMPDIR, "/usr/tmp", 0);
- variable_set2(VAR_MEDIA_TIMEOUT, itoa(MEDIA_TIMEOUT), 0);
- if (getpid() != 1)
- variable_set2(SYSTEM_STATE, "update", 0);
- else
- variable_set2(SYSTEM_STATE, "init", 0);
- variable_set2(VAR_NEWFS_ARGS, "-b 8192 -f 1024", 0);
- return DITEM_SUCCESS;
-}
-
-/* Load the environment up from various system configuration files */
-void
-installEnvironment(void)
-{
- configEnvironmentRC_conf();
- if (file_readable("/etc/resolv.conf"))
- configEnvironmentResolv("/etc/resolv.conf");
- configMake_conf("/etc/make.conf");
-}
-
-/* Copy the boot floppy contents into /stand */
-Boolean
-copySelf(void)
-{
- int i;
-
- if (file_readable("/boot.help"))
- vsystem("cp /boot.help /mnt");
- msgWeHaveOutput("Copying the boot floppy to /stand on root filesystem");
- i = vsystem("find -x /stand | cpio %s -pdum /mnt", cpioVerbosity());
- if (i) {
- msgConfirm("Copy returned error status of %d!", i);
- return FALSE;
- }
-
- /* Copy the /etc files into their rightful place */
- if (vsystem("cd /mnt/stand; find etc | cpio %s -pdum /mnt", cpioVerbosity())) {
- msgConfirm("Couldn't copy up the /etc files!");
- return TRUE;
- }
- return TRUE;
-}
-
-static void
-create_termcap(void)
-{
- FILE *fp;
-
- const char *caps[] = {
- termcap_vt100, termcap_cons25, termcap_cons25_m, termcap_cons25r,
- termcap_cons25r_m, termcap_cons25l1, termcap_cons25l1_m, NULL,
- };
- const char **cp;
-
- if (!file_readable(TERMCAP_FILE)) {
- Mkdir("/usr/share/misc");
- fp = fopen(TERMCAP_FILE, "w");
- if (!fp) {
- msgConfirm("Unable to initialize termcap file. Some screen-oriented\nutilities may not work.");
- return;
- }
- cp = caps;
- while (*cp)
- fprintf(fp, "%s\n", *(cp++));
- fclose(fp);
- }
-}
diff --git a/usr.sbin/sade/keymap.c b/usr.sbin/sade/keymap.c
deleted file mode 100644
index 53b076180ebe..000000000000
--- a/usr.sbin/sade/keymap.c
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 1996 Joerg Wunsch
- *
- * 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 DEVELOPERS ``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 DEVELOPERS 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.
- *
- * $FreeBSD$
- *
- */
-
-#include "sysinstall.h"
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <machine/console.h>
-
-struct keymapInfo {
- const char *name;
- const struct keymap *map;
-};
-
-#include "keymap.h"
-
-/*
- * keymap.h is being automatically generated by the Makefile. It
- * contains definitions for all desired keymaps. Note that since we
- * don't support font loading nor screen mapping during installation,
- * we simply don't care for any other keys than the ASCII subset.
- *
- * Therefore, if no keymap with the exact name has been found in the
- * first pass, we make a second pass over the table looking just for
- * the language name only.
- */
-
-/*
- * Return values:
- *
- * 0: OK
- * -1: no appropriate keymap found
- * -2: error installing map (other than ENXIO which means we're not on syscons)
- */
-
-int
-loadKeymap(const char *lang)
-{
- int passno, err;
- char *llang;
- size_t l;
- struct keymapInfo *kip;
-
- llang = strdup(lang);
- if (llang == NULL)
- abort();
-
- for (passno = 0; passno < 2; passno++)
- {
- if (passno > 0)
- {
- /* make the match more fuzzy */
- l = strspn(llang, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
- llang[l] = '\0';
- }
-
- l = strlen(llang);
-
- for (kip = keymapInfos; kip->name; kip++)
- if (strncmp(kip->name, llang, l) == 0)
- {
- /* Yep, got it! */
- err = ioctl(0, PIO_KEYMAP, kip->map);
- free(llang);
- return (err == -1 && errno != ENOTTY)? -2: 0;
- }
- }
- free(llang);
- return -1;
-}
diff --git a/usr.sbin/sade/label.c b/usr.sbin/sade/label.c
deleted file mode 100644
index 460f19404d2a..000000000000
--- a/usr.sbin/sade/label.c
+++ /dev/null
@@ -1,1298 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last program in the `sysinstall' line - the next
- * generation being essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 "sysinstall.h"
-#include <ctype.h>
-#include <sys/disklabel.h>
-#include <sys/param.h>
-#include <sys/sysctl.h>
-
-/*
- * Everything to do with editing the contents of disk labels.
- */
-
-/* A nice message we use a lot in the disklabel editor */
-#define MSG_NOT_APPLICABLE "That option is not applicable here"
-
-/* Where to start printing the freebsd slices */
-#define CHUNK_SLICE_START_ROW 2
-#define CHUNK_PART_START_ROW 11
-
-/* The smallest filesystem we're willing to create */
-#define FS_MIN_SIZE ONE_MEG
-
-/* The smallest root filesystem we're willing to create */
-#ifdef __alpha__
-#define ROOT_MIN_SIZE 40
-#else
-#define ROOT_MIN_SIZE 30
-#endif
-
-/* The default root filesystem size */
-#ifdef __alpha__
-#define ROOT_DEFAULT_SIZE 70
-#else
-#define ROOT_DEFAULT_SIZE 50
-#endif
-
-/* The smallest swap partition we want to create by default */
-#define SWAP_MIN_SIZE 32
-
-/* The smallest /usr partition we're willing to create by default */
-#define USR_MIN_SIZE 80
-
-/* The smallest /var partition we're willing to create by default */
-#define VAR_MIN_SIZE 20
-
-/* The bottom-most row we're allowed to scribble on */
-#define CHUNK_ROW_MAX 16
-
-
-/* All the chunks currently displayed on the screen */
-static struct {
- struct chunk *c;
- PartType type;
-} label_chunk_info[MAX_CHUNKS + 1];
-static int here;
-
-/*** with this value we try to track the most recently added label ***/
-static int label_focus = 0, pslice_focus = 0;
-
-static int diskLabel(Device *dev);
-static int diskLabelNonInteractive(Device *dev);
-
-static int
-labelHook(dialogMenuItem *selected)
-{
- Device **devs = NULL;
-
- devs = deviceFind(selected->prompt, DEVICE_TYPE_DISK);
- if (!devs) {
- msgConfirm("Unable to find disk %s!", selected->prompt);
- return DITEM_FAILURE;
- }
- /* Toggle enabled status? */
- if (!devs[0]->enabled) {
- devs[0]->enabled = TRUE;
- diskLabel(devs[0]);
- }
- else
- devs[0]->enabled = FALSE;
- return DITEM_SUCCESS;
-}
-
-static int
-labelCheck(dialogMenuItem *selected)
-{
- Device **devs = NULL;
-
- devs = deviceFind(selected->prompt, DEVICE_TYPE_DISK);
- if (!devs || devs[0]->enabled == FALSE)
- return FALSE;
- return TRUE;
-}
-
-int
-diskLabelEditor(dialogMenuItem *self)
-{
- DMenu *menu;
- Device **devs;
- int i, cnt;
-
- i = 0;
- cnt = diskGetSelectCount(&devs);
- if (cnt == -1) {
- msgConfirm("No disks found! Please verify that your disk controller is being\n"
- "properly probed at boot time. See the Hardware Guide on the\n"
- "Documentation menu for clues on diagnosing this type of problem.");
- return DITEM_FAILURE;
- }
- else if (cnt) {
- /* Some are already selected */
- if (variable_get(VAR_NONINTERACTIVE))
- i = diskLabelNonInteractive(NULL);
- else
- i = diskLabel(NULL);
- }
- else {
- /* No disks are selected, fall-back case now */
- cnt = deviceCount(devs);
- if (cnt == 1) {
- devs[0]->enabled = TRUE;
- if (variable_get(VAR_NONINTERACTIVE))
- i = diskLabelNonInteractive(devs[0]);
- else
- i = diskLabel(devs[0]);
- }
- else {
- menu = deviceCreateMenu(&MenuDiskDevices, DEVICE_TYPE_DISK, labelHook, labelCheck);
- if (!menu) {
- msgConfirm("No devices suitable for installation found!\n\n"
- "Please verify that your disk controller (and attached drives)\n"
- "were detected properly. This can be done by pressing the\n"
- "[Scroll Lock] key and using the Arrow keys to move back to\n"
- "the boot messages. Press [Scroll Lock] again to return.");
- i = DITEM_FAILURE;
- }
- else {
- i = dmenuOpenSimple(menu, FALSE) ? DITEM_SUCCESS : DITEM_FAILURE;
- free(menu);
- }
- }
- }
- if (DITEM_STATUS(i) != DITEM_FAILURE) {
- char *cp;
-
- if (((cp = variable_get(DISK_LABELLED)) == NULL) || (strcmp(cp, "written")))
- variable_set2(DISK_LABELLED, "yes", 0);
- }
- return i;
-}
-
-int
-diskLabelCommit(dialogMenuItem *self)
-{
- char *cp;
- int i;
-
- /* Already done? */
- if ((cp = variable_get(DISK_LABELLED)) && strcmp(cp, "yes"))
- i = DITEM_SUCCESS;
- else if (!cp) {
- msgConfirm("You must assign disk labels before this option can be used.");
- i = DITEM_FAILURE;
- }
- /* The routine will guard against redundant writes, just as this one does */
- else if (DITEM_STATUS(diskPartitionWrite(self)) != DITEM_SUCCESS)
- i = DITEM_FAILURE;
- else if (DITEM_STATUS(installFilesystems(self)) != DITEM_SUCCESS)
- i = DITEM_FAILURE;
- else {
- msgInfo("All filesystem information written successfully.");
- variable_set2(DISK_LABELLED, "written", 0);
- i = DITEM_SUCCESS;
- }
- return i;
-}
-
-/* See if we're already using a desired partition name */
-static Boolean
-check_conflict(char *name)
-{
- int i;
-
- for (i = 0; label_chunk_info[i].c; i++)
- if ((label_chunk_info[i].type == PART_FILESYSTEM || label_chunk_info[i].type == PART_FAT)
- && label_chunk_info[i].c->private_data
- && !strcmp(((PartInfo *)label_chunk_info[i].c->private_data)->mountpoint, name))
- return TRUE;
- return FALSE;
-}
-
-/* How much space is in this FreeBSD slice? */
-static int
-space_free(struct chunk *c)
-{
- struct chunk *c1;
- int sz = c->size;
-
- for (c1 = c->part; c1; c1 = c1->next) {
- if (c1->type != unused)
- sz -= c1->size;
- }
- if (sz < 0)
- msgFatal("Partitions are larger than actual chunk??");
- return sz;
-}
-
-/* Snapshot the current situation into the displayed chunks structure */
-static void
-record_label_chunks(Device **devs, Device *dev)
-{
- int i, j, p;
- struct chunk *c1, *c2;
- Disk *d;
-
- j = p = 0;
- /* First buzz through and pick up the FreeBSD slices */
- for (i = 0; devs[i]; i++) {
- if ((dev && devs[i] != dev) || !devs[i]->enabled)
- continue;
- d = (Disk *)devs[i]->private;
- if (!d->chunks)
- msgFatal("No chunk list found for %s!", d->name);
-
- /* Put the slice entries first */
- for (c1 = d->chunks->part; c1; c1 = c1->next) {
- if (c1->type == freebsd) {
- label_chunk_info[j].type = PART_SLICE;
- label_chunk_info[j].c = c1;
- ++j;
- }
- }
- }
-
- /* Now run through again and get the FreeBSD partition entries */
- for (i = 0; devs[i]; i++) {
- if (!devs[i]->enabled)
- continue;
- d = (Disk *)devs[i]->private;
- /* Then buzz through and pick up the partitions */
- for (c1 = d->chunks->part; c1; c1 = c1->next) {
- if (c1->type == freebsd) {
- for (c2 = c1->part; c2; c2 = c2->next) {
- if (c2->type == part) {
- if (c2->subtype == FS_SWAP)
- label_chunk_info[j].type = PART_SWAP;
- else
- label_chunk_info[j].type = PART_FILESYSTEM;
- label_chunk_info[j].c = c2;
- ++j;
- }
- }
- }
- else if (c1->type == fat) {
- label_chunk_info[j].type = PART_FAT;
- label_chunk_info[j].c = c1;
- ++j;
- }
- }
- }
- label_chunk_info[j].c = NULL;
- if (here >= j) {
- here = j ? j - 1 : 0;
- }
-}
-
-/* A new partition entry */
-static PartInfo *
-new_part(char *mpoint, Boolean newfs, u_long size)
-{
- PartInfo *ret;
-
- if (!mpoint)
- mpoint = "/change_me";
-
- ret = (PartInfo *)safe_malloc(sizeof(PartInfo));
- sstrncpy(ret->mountpoint, mpoint, FILENAME_MAX);
- strcpy(ret->newfs_cmd, "newfs ");
- strcat(ret->newfs_cmd, variable_get(VAR_NEWFS_ARGS));
- ret->newfs = newfs;
- if (!size)
- return ret;
- return ret;
-}
-
-/* Get the mountpoint for a partition and save it away */
-static PartInfo *
-get_mountpoint(struct chunk *old)
-{
- char *val;
- PartInfo *tmp;
-
- if (old && old->private_data)
- tmp = old->private_data;
- else
- tmp = NULL;
- val = msgGetInput(tmp ? tmp->mountpoint : NULL, "Please specify a mount point for the partition");
- if (!val || !*val) {
- if (!old)
- return NULL;
- else {
- free(old->private_data);
- old->private_data = NULL;
- }
- return NULL;
- }
-
- /* Is it just the same value? */
- if (tmp && !strcmp(tmp->mountpoint, val))
- return NULL;
-
- /* Did we use it already? */
- if (check_conflict(val)) {
- msgConfirm("You already have a mount point for %s assigned!", val);
- return NULL;
- }
-
- /* Is it bogus? */
- if (*val != '/') {
- msgConfirm("Mount point must start with a / character");
- return NULL;
- }
-
- /* Is it going to be mounted on root? */
- if (!strcmp(val, "/")) {
- if (old)
- old->flags |= CHUNK_IS_ROOT;
- }
- else if (old)
- old->flags &= ~CHUNK_IS_ROOT;
-
- safe_free(tmp);
- val = string_skipwhite(string_prune(val));
- tmp = new_part(val, TRUE, 0);
- if (old) {
- old->private_data = tmp;
- old->private_free = safe_free;
- }
- return tmp;
-}
-
-/* Get the type of the new partiton */
-static PartType
-get_partition_type(void)
-{
- char selection[20];
- int i;
- static unsigned char *fs_types[] = {
- "FS",
- "A file system",
- "Swap",
- "A swap partition.",
- };
- WINDOW *w = savescr();
-
- i = dialog_menu("Please choose a partition type",
- "If you want to use this partition for swap space, select Swap.\n"
- "If you want to put a filesystem on it, choose FS.",
- -1, -1, 2, 2, fs_types, selection, NULL, NULL);
- restorescr(w);
- if (!i) {
- if (!strcmp(selection, "FS"))
- return PART_FILESYSTEM;
- else if (!strcmp(selection, "Swap"))
- return PART_SWAP;
- }
- return PART_NONE;
-}
-
-/* If the user wants a special newfs command for this, set it */
-static void
-getNewfsCmd(PartInfo *p)
-{
- char *val;
-
- val = msgGetInput(p->newfs_cmd,
- "Please enter the newfs command and options you'd like to use in\n"
- "creating this file system.");
- if (val)
- sstrncpy(p->newfs_cmd, val, NEWFS_CMD_MAX);
-}
-
-#define MAX_MOUNT_NAME 10
-
-#define PART_PART_COL 0
-#define PART_MOUNT_COL 10
-#define PART_SIZE_COL (PART_MOUNT_COL + MAX_MOUNT_NAME + 3)
-#define PART_NEWFS_COL (PART_SIZE_COL + 8)
-#define PART_OFF 38
-
-#define TOTAL_AVAIL_LINES (10)
-#define PSLICE_SHOWABLE (4)
-
-
-/* stick this all up on the screen */
-static void
-print_label_chunks(void)
-{
- int i, j, srow, prow, pcol;
- int sz;
- char clrmsg[80];
- int ChunkPartStartRow;
- WINDOW *ChunkWin;
-
- /********************************************************/
- /*** These values are for controling screen resources ***/
- /*** Each label line holds up to 2 labels, so beware! ***/
- /*** strategy will be to try to always make sure the ***/
- /*** highlighted label is in the active display area. ***/
- /********************************************************/
- int pslice_max, label_max;
- int pslice_count, label_count, label_focus_found, pslice_focus_found;
-
- attrset(A_REVERSE);
- mvaddstr(0, 25, "FreeBSD Disklabel Editor");
- attrset(A_NORMAL);
-
- /*** Count the number of parition slices ***/
- pslice_count = 0;
- for (i = 0; label_chunk_info[i].c ; i++) {
- if (label_chunk_info[i].type == PART_SLICE)
- ++pslice_count;
- }
- pslice_max = pslice_count;
-
- /*** 4 line max for partition slices ***/
- if (pslice_max > PSLICE_SHOWABLE) {
- pslice_max = PSLICE_SHOWABLE;
- }
- ChunkPartStartRow = CHUNK_SLICE_START_ROW + 3 + pslice_max;
-
- /*** View partition slices modulo pslice_max ***/
- label_max = TOTAL_AVAIL_LINES - pslice_max;
-
- for (i = 0; i < 2; i++) {
- mvaddstr(ChunkPartStartRow - 2, PART_PART_COL + (i * PART_OFF), "Part");
- mvaddstr(ChunkPartStartRow - 1, PART_PART_COL + (i * PART_OFF), "----");
-
- mvaddstr(ChunkPartStartRow - 2, PART_MOUNT_COL + (i * PART_OFF), "Mount");
- mvaddstr(ChunkPartStartRow - 1, PART_MOUNT_COL + (i * PART_OFF), "-----");
-
- mvaddstr(ChunkPartStartRow - 2, PART_SIZE_COL + (i * PART_OFF) + 3, "Size");
- mvaddstr(ChunkPartStartRow - 1, PART_SIZE_COL + (i * PART_OFF) + 3, "----");
-
- mvaddstr(ChunkPartStartRow - 2, PART_NEWFS_COL + (i * PART_OFF), "Newfs");
- mvaddstr(ChunkPartStartRow - 1, PART_NEWFS_COL + (i * PART_OFF), "-----");
- }
- srow = CHUNK_SLICE_START_ROW;
- prow = 0;
- pcol = 0;
-
- /*** these variables indicate that the focused item is shown currently ***/
- label_focus_found = 0;
- pslice_focus_found = 0;
-
- label_count = 0;
- pslice_count = 0;
- mvprintw(CHUNK_SLICE_START_ROW - 1, 0, " ");
- mvprintw(CHUNK_SLICE_START_ROW + pslice_max, 0, " ");
-
- ChunkWin = newwin(CHUNK_ROW_MAX - ChunkPartStartRow, 76, ChunkPartStartRow, 0);
-
- wclear(ChunkWin);
- /*** wrefresh(ChunkWin); ***/
-
- for (i = 0; label_chunk_info[i].c; i++) {
- /* Is it a slice entry displayed at the top? */
- if (label_chunk_info[i].type == PART_SLICE) {
- /*** This causes the new pslice to replace the previous display ***/
- /*** focus must remain on the most recently active pslice ***/
- if (pslice_count == pslice_max) {
- if (pslice_focus_found) {
- /*** This is where we can mark the more following ***/
- attrset(A_BOLD);
- mvprintw(CHUNK_SLICE_START_ROW + pslice_max, 0, "***MORE***");
- attrset(A_NORMAL);
- continue;
- }
- else {
- /*** this is where we set the more previous ***/
- attrset(A_BOLD);
- mvprintw(CHUNK_SLICE_START_ROW - 1, 0, "***MORE***");
- attrset(A_NORMAL);
- pslice_count = 0;
- srow = CHUNK_SLICE_START_ROW;
- }
- }
-
- sz = space_free(label_chunk_info[i].c);
- if (i == here)
- attrset(ATTR_SELECTED);
- if (i == pslice_focus)
- pslice_focus_found = -1;
-
- mvprintw(srow++, 0,
- "Disk: %s\tPartition name: %s\tFree: %d blocks (%dMB)",
- label_chunk_info[i].c->disk->name, label_chunk_info[i].c->name,
- sz, (sz / ONE_MEG));
- attrset(A_NORMAL);
- clrtoeol();
- move(0, 0);
- /*** refresh(); ***/
- ++pslice_count;
- }
- /* Otherwise it's a DOS, swap or filesystem entry in the Chunk window */
- else {
- char onestr[PART_OFF], num[10], *mountpoint, *newfs;
-
- /*
- * We copy this into a blank-padded string so that it looks like
- * a solid bar in reverse-video
- */
- memset(onestr, ' ', PART_OFF - 1);
- onestr[PART_OFF - 1] = '\0';
-
- /*** Track how many labels have been displayed ***/
- if (label_count == ((label_max - 1 ) * 2)) {
- if (label_focus_found) {
- continue;
- }
- else {
- label_count = 0;
- prow = 0;
- pcol = 0;
- }
- }
-
- /* Go for two columns if we've written one full columns worth */
- /*** if (prow == (CHUNK_ROW_MAX - ChunkPartStartRow)) ***/
- if (label_count == label_max - 1) {
- pcol = PART_OFF;
- prow = 0;
- }
- memcpy(onestr + PART_PART_COL, label_chunk_info[i].c->name, strlen(label_chunk_info[i].c->name));
- /* If it's a filesystem, display the mountpoint */
- if (label_chunk_info[i].c->private_data
- && (label_chunk_info[i].type == PART_FILESYSTEM || label_chunk_info[i].type == PART_FAT))
- mountpoint = ((PartInfo *)label_chunk_info[i].c->private_data)->mountpoint;
- else if (label_chunk_info[i].type == PART_SWAP)
- mountpoint = "swap";
- else
- mountpoint = "<none>";
-
- /* Now display the newfs field */
- if (label_chunk_info[i].type == PART_FAT)
- newfs = "DOS";
- else if (label_chunk_info[i].c->private_data && label_chunk_info[i].type == PART_FILESYSTEM)
- newfs = ((PartInfo *)label_chunk_info[i].c->private_data)->newfs ? "UFS Y" : "UFS N";
- else if (label_chunk_info[i].type == PART_SWAP)
- newfs = "SWAP";
- else
- newfs = "*";
- for (j = 0; j < MAX_MOUNT_NAME && mountpoint[j]; j++)
- onestr[PART_MOUNT_COL + j] = mountpoint[j];
- snprintf(num, 10, "%5ldMB", label_chunk_info[i].c->size ? label_chunk_info[i].c->size / ONE_MEG : 0);
- memcpy(onestr + PART_SIZE_COL, num, strlen(num));
- memcpy(onestr + PART_NEWFS_COL, newfs, strlen(newfs));
- onestr[PART_NEWFS_COL + strlen(newfs)] = '\0';
- if (i == label_focus) {
- label_focus_found = -1;
- wattrset(ChunkWin, A_BOLD);
- }
- if (i == here)
- wattrset(ChunkWin, ATTR_SELECTED);
-
- /*** lazy man's way of padding this string ***/
- while (strlen( onestr ) < 37)
- strcat(onestr, " ");
-
- mvwaddstr(ChunkWin, prow, pcol, onestr);
- wattrset(ChunkWin, A_NORMAL);
- move(0, 0);
- ++prow;
- ++label_count;
- }
- }
-
- /*** this will erase all the extra stuff ***/
- memset(clrmsg, ' ', 37);
- clrmsg[37] = '\0';
-
- while (pslice_count < pslice_max) {
- mvprintw(srow++, 0, clrmsg);
- clrtoeol();
- ++pslice_count;
- }
- while (label_count < (2 * (label_max - 1))) {
- mvwaddstr(ChunkWin, prow++, pcol, clrmsg);
- ++label_count;
- if (prow == (label_max - 1)) {
- prow = 0;
- pcol = PART_OFF;
- }
- }
- refresh();
- wrefresh(ChunkWin);
-}
-
-static void
-print_command_summary(void)
-{
- mvprintw(17, 0, "The following commands are valid here (upper or lower case):");
- mvprintw(18, 0, "C = Create D = Delete M = Mount pt.");
- if (!RunningAsInit)
- mvprintw(18, 49, "W = Write");
- mvprintw(19, 0, "N = Newfs Opts T = Newfs Toggle U = Undo Q = Finish");
- mvprintw(20, 0, "A = Auto Defaults for all!");
- mvprintw(22, 0, "Use F1 or ? to get more help, arrow keys to select.");
- move(0, 0);
-}
-
-static void
-clear_wins(void)
-{
- extern void print_label_chunks();
- clear();
- print_label_chunks();
-}
-
-#ifdef __alpha__
-
-/*
- * If there isn't a freebsd chunk already (i.e. there is no label),
- * dedicate the disk.
- */
-static void
-maybe_dedicate(Disk* d)
-{
- struct chunk *c;
-
- for (c = d->chunks->part; c; c = c->next) {
- if (c->type == freebsd)
- break;
- }
-
- if (!c) {
- msgDebug("dedicating disk");
- All_FreeBSD(d, 1);
- }
-}
-
-#endif
-
-static int
-diskLabel(Device *dev)
-{
- int sz, key = 0;
- Boolean labeling;
- char *msg = NULL;
- PartInfo *p, *oldp;
- PartType type;
- Device **devs;
-#ifdef __alpha__
- int i;
-#endif
- WINDOW *w = savescr();
-
- label_focus = 0;
- pslice_focus = 0;
- here = 0;
-
- devs = deviceFind(NULL, DEVICE_TYPE_DISK);
- if (!devs) {
- msgConfirm("No disks found!");
- restorescr(w);
- return DITEM_FAILURE;
- }
- labeling = TRUE;
- keypad(stdscr, TRUE);
-#ifdef __alpha__
- for (i = 0; devs[i]; i++) {
- maybe_dedicate((Disk*) devs[i]->private);
- }
-#endif
- record_label_chunks(devs, dev);
-
- clear();
- while (labeling) {
- char *cp;
-
- print_label_chunks();
- print_command_summary();
- if (msg) {
- attrset(title_attr); mvprintw(23, 0, msg); attrset(A_NORMAL);
- clrtoeol();
- beep();
- msg = NULL;
- }
- else {
- move(23, 0);
- clrtoeol();
- }
-
- refresh();
- key = getch();
- switch (toupper(key)) {
- int i;
- static char _msg[40];
-
- case '\014': /* ^L */
- clear_wins();
- break;
-
- case '\020': /* ^P */
- case KEY_UP:
- case '-':
- if (here != 0)
- --here;
- else
- while (label_chunk_info[here + 1].c)
- ++here;
- break;
-
- case '\016': /* ^N */
- case KEY_DOWN:
- case '+':
- case '\r':
- case '\n':
- if (label_chunk_info[here + 1].c)
- ++here;
- else
- here = 0;
- break;
-
- case KEY_HOME:
- here = 0;
- break;
-
- case KEY_END:
- while (label_chunk_info[here + 1].c)
- ++here;
- break;
-
- case KEY_F(1):
- case '?':
- systemDisplayHelp("partition");
- clear_wins();
- break;
-
- case 'A':
- if (label_chunk_info[here].type != PART_SLICE) {
- msg = "You can only do this in a disk slice (at top of screen)";
- break;
- }
- sz = space_free(label_chunk_info[here].c);
- if (sz <= FS_MIN_SIZE)
- msg = "Not enough free space to create a new partition in the slice";
- else {
- struct chunk *tmp;
- int mib[2];
- int physmem;
- size_t size, swsize;
- char *cp;
- Chunk *rootdev, *swapdev, *usrdev, *vardev;
-
- (void)checkLabels(FALSE, &rootdev, &swapdev, &usrdev, &vardev);
- if (!rootdev) {
- cp = variable_get(VAR_ROOT_SIZE);
- tmp = Create_Chunk_DWIM(label_chunk_info[here].c->disk, label_chunk_info[here].c,
- (cp ? atoi(cp) : ROOT_DEFAULT_SIZE) * ONE_MEG, part, FS_BSDFFS, CHUNK_IS_ROOT);
- if (!tmp) {
- msgConfirm("Unable to create the root partition. Too big?");
- clear_wins();
- break;
- }
- tmp->private_data = new_part("/", TRUE, tmp->size);
- tmp->private_free = safe_free;
- record_label_chunks(devs, dev);
- }
-
- if (!swapdev) {
- cp = variable_get(VAR_SWAP_SIZE);
- if (cp)
- swsize = atoi(cp) * ONE_MEG;
- else {
- mib[0] = CTL_HW;
- mib[1] = HW_PHYSMEM;
- size = sizeof physmem;
- sysctl(mib, 2, &physmem, &size, (void *)0, (size_t)0);
- swsize = 16 * ONE_MEG + (physmem * 2 / 512);
- }
- tmp = Create_Chunk_DWIM(label_chunk_info[here].c->disk, label_chunk_info[here].c,
- swsize, part, FS_SWAP, 0);
- if (!tmp) {
- msgConfirm("Unable to create the swap partition. Too big?");
- clear_wins();
- break;
- }
- tmp->private_data = 0;
- tmp->private_free = safe_free;
- record_label_chunks(devs, dev);
- }
-
- if (!vardev) {
- cp = variable_get(VAR_VAR_SIZE);
- if (cp)
- sz = atoi(cp) * ONE_MEG;
- else
- sz = variable_get(VAR_NO_USR)
- ? space_free(label_chunk_info[here].c)
- : VAR_MIN_SIZE * ONE_MEG;
-
- tmp = Create_Chunk_DWIM(label_chunk_info[here].c->disk, label_chunk_info[here].c,
- sz, part, FS_BSDFFS, 0);
- if (!tmp) {
- msgConfirm("Less than %dMB free for /var - you will need to\n"
- "partition your disk manually with a custom install!",
- (cp ? atoi(cp) : VAR_MIN_SIZE));
- clear_wins();
- break;
- }
- tmp->private_data = new_part("/var", TRUE, tmp->size);
- tmp->private_free = safe_free;
- record_label_chunks(devs, dev);
- }
-
- if (!usrdev && !variable_get(VAR_NO_USR)) {
- cp = variable_get(VAR_USR_SIZE);
- if (cp)
- sz = atoi(cp) * ONE_MEG;
- else
- sz = space_free(label_chunk_info[here].c);
- if (sz) {
- if (sz < (USR_MIN_SIZE * ONE_MEG)) {
- msgConfirm("Less than %dMB free for /usr - you will need to\n"
- "partition your disk manually with a custom install!", USR_MIN_SIZE);
- clear_wins();
- break;
- }
-
- tmp = Create_Chunk_DWIM(label_chunk_info[here].c->disk,
- label_chunk_info[here].c,
- sz, part, FS_BSDFFS, 0);
- if (!tmp) {
- msgConfirm("Unable to create the /usr partition. Not enough space?\n"
- "You will need to partition your disk manually with a custom install!");
- clear_wins();
- break;
- }
- tmp->private_data = new_part("/usr", TRUE, tmp->size);
- tmp->private_free = safe_free;
- record_label_chunks(devs, dev);
- }
- }
-
- /* At this point, we're reasonably "labelled" */
- if (((cp = variable_get(DISK_LABELLED)) == NULL) || (strcmp(cp, "written")))
- variable_set2(DISK_LABELLED, "yes", 0);
- }
- break;
-
- case 'C':
- if (label_chunk_info[here].type != PART_SLICE) {
- msg = "You can only do this in a master partition (see top of screen)";
- break;
- }
- sz = space_free(label_chunk_info[here].c);
- if (sz <= FS_MIN_SIZE) {
- msg = "Not enough space to create an additional FreeBSD partition";
- break;
- }
- else {
- char *val;
- int size;
- struct chunk *tmp;
- char osize[80];
- u_long flags = 0;
-
- sprintf(osize, "%d", sz);
- val = msgGetInput(osize,
- "Please specify the partition size in blocks or append a trailing G for\n"
- "gigabytes, M for megabytes, or C for cylinders.\n"
- "%d blocks (%dMB) are free.",
- sz, sz / ONE_MEG);
- if (!val || (size = strtol(val, &cp, 0)) <= 0) {
- clear_wins();
- break;
- }
-
- if (*cp) {
- if (toupper(*cp) == 'M')
- size *= ONE_MEG;
- else if (toupper(*cp) == 'G')
- size *= ONE_GIG;
- else if (toupper(*cp) == 'C')
- size *= (label_chunk_info[here].c->disk->bios_hd * label_chunk_info[here].c->disk->bios_sect);
- }
- if (size <= FS_MIN_SIZE) {
- msgConfirm("The minimum filesystem size is %dMB", FS_MIN_SIZE / ONE_MEG);
- clear_wins();
- break;
- }
- type = get_partition_type();
- if (type == PART_NONE) {
- clear_wins();
- beep();
- break;
- }
-
- if (type == PART_FILESYSTEM) {
- if ((p = get_mountpoint(NULL)) == NULL) {
- clear_wins();
- beep();
- break;
- }
- else if (!strcmp(p->mountpoint, "/"))
- flags |= CHUNK_IS_ROOT;
- else
- flags &= ~CHUNK_IS_ROOT;
- }
- else
- p = NULL;
-
- if ((flags & CHUNK_IS_ROOT)) {
- if (!(label_chunk_info[here].c->flags & CHUNK_BSD_COMPAT)) {
- msgConfirm("This region cannot be used for your root partition as the\n"
- "FreeBSD boot code cannot deal with a root partition created\n"
- "in that location. Please choose another location or smaller\n"
- "size for your root partition and try again!");
- clear_wins();
- break;
- }
- if (size < (ROOT_MIN_SIZE * ONE_MEG)) {
- msgConfirm("Warning: This is smaller than the recommended size for a\n"
- "root partition. For a variety of reasons, root\n"
- "partitions should usually be at least %dMB in size", ROOT_MIN_SIZE);
- }
- }
- tmp = Create_Chunk_DWIM(label_chunk_info[here].c->disk,
- label_chunk_info[here].c,
- size, part,
- (type == PART_SWAP) ? FS_SWAP : FS_BSDFFS,
- flags);
- if (!tmp) {
- msgConfirm("Unable to create the partition. Too big?");
- clear_wins();
- break;
- }
- if ((flags & CHUNK_IS_ROOT) && (tmp->flags & CHUNK_PAST_1024)) {
- msgConfirm("This region cannot be used for your root partition as it starts\n"
- "or extends past the 1024'th cylinder mark and is thus a\n"
- "poor location to boot from. Please choose another\n"
- "location (or smaller size) for your root partition and try again!");
- Delete_Chunk(label_chunk_info[here].c->disk, tmp);
- clear_wins();
- break;
- }
- if (type != PART_SWAP) {
- /* This is needed to tell the newfs -u about the size */
- tmp->private_data = new_part(p->mountpoint, p->newfs, tmp->size);
- safe_free(p);
- }
- else
- tmp->private_data = p;
- tmp->private_free = safe_free;
- if (((cp = variable_get(DISK_LABELLED)) == NULL) || (strcmp(cp, "written")))
- variable_set2(DISK_LABELLED, "yes", 0);
- record_label_chunks(devs, dev);
- clear_wins();
- /*** This is where we assign focus to new label so it shows ***/
- {
- int i;
- label_focus = -1;
- for (i = 0; label_chunk_info[i].c; ++i) {
- if (label_chunk_info[i].c == tmp) {
- label_focus = i;
- break;
- }
- }
- if (label_focus == -1)
- label_focus = i - 1;
- }
- }
- break;
-
- case KEY_DC:
- case 'D': /* delete */
- if (label_chunk_info[here].type == PART_SLICE) {
- msg = MSG_NOT_APPLICABLE;
- break;
- }
- else if (label_chunk_info[here].type == PART_FAT) {
- msg = "Use the Disk Partition Editor to delete DOS partitions";
- break;
- }
- Delete_Chunk(label_chunk_info[here].c->disk, label_chunk_info[here].c);
- if (((cp = variable_get(DISK_LABELLED)) == NULL) || (strcmp(cp, "written")))
- variable_set2(DISK_LABELLED, "yes", 0);
- record_label_chunks(devs, dev);
- break;
-
- case 'M': /* mount */
- switch(label_chunk_info[here].type) {
- case PART_SLICE:
- msg = MSG_NOT_APPLICABLE;
- break;
-
- case PART_SWAP:
- msg = "You don't need to specify a mountpoint for a swap partition.";
- break;
-
- case PART_FAT:
- case PART_FILESYSTEM:
- oldp = label_chunk_info[here].c->private_data;
- p = get_mountpoint(label_chunk_info[here].c);
- if (p) {
- if (!oldp)
- p->newfs = FALSE;
- if (label_chunk_info[here].type == PART_FAT
- && (!strcmp(p->mountpoint, "/") || !strcmp(p->mountpoint, "/usr")
- || !strcmp(p->mountpoint, "/var"))) {
- msgConfirm("%s is an invalid mount point for a DOS partition!", p->mountpoint);
- strcpy(p->mountpoint, "/bogus");
- }
- }
- if (((cp = variable_get(DISK_LABELLED)) == NULL) || (strcmp(cp, "written")))
- variable_set2(DISK_LABELLED, "yes", 0);
- record_label_chunks(devs, dev);
- clear_wins();
- break;
-
- default:
- msgFatal("Bogus partition under cursor???");
- break;
- }
- break;
-
- case 'N': /* Set newfs options */
- if (label_chunk_info[here].c->private_data &&
- ((PartInfo *)label_chunk_info[here].c->private_data)->newfs)
- getNewfsCmd(label_chunk_info[here].c->private_data);
- else
- msg = MSG_NOT_APPLICABLE;
- clear_wins();
- break;
-
- case 'T': /* Toggle newfs state */
- if (label_chunk_info[here].type == PART_FILESYSTEM) {
- PartInfo *pi = ((PartInfo *)label_chunk_info[here].c->private_data);
- label_chunk_info[here].c->private_data =
- new_part(pi ? pi->mountpoint : NULL, pi ? !pi->newfs : TRUE, label_chunk_info[here].c->size);
- safe_free(pi);
- label_chunk_info[here].c->private_free = safe_free;
- if (((cp = variable_get(DISK_LABELLED)) == NULL) || (strcmp(cp, "written")))
- variable_set2(DISK_LABELLED, "yes", 0);
- }
- else
- msg = MSG_NOT_APPLICABLE;
- break;
-
- case 'U':
- clear();
- if ((cp = variable_get(DISK_LABELLED)) && !strcmp(cp, "written")) {
- msgConfirm("You've already written out your changes -\n"
- "it's too late to undo!");
- }
- else if (!msgYesNo("Are you SURE you want to Undo everything?")) {
- variable_unset(DISK_PARTITIONED);
- variable_unset(DISK_LABELLED);
- for (i = 0; devs[i]; i++) {
- Disk *d;
-
- if (!devs[i]->enabled)
- continue;
- else if ((d = Open_Disk(devs[i]->name)) != NULL) {
- Free_Disk(devs[i]->private);
- devs[i]->private = d;
- diskPartition(devs[i]);
- }
- }
- record_label_chunks(devs, dev);
- }
- clear_wins();
- break;
-
- case 'W':
- if ((cp = variable_get(DISK_LABELLED)) && !strcmp(cp, "written")) {
- msgConfirm("You've already written out your changes - if you\n"
- "wish to overwrite them, you'll have to start this\n"
- "procedure again from the beginning.");
- }
- else if (!msgYesNo("WARNING: This should only be used when modifying an EXISTING\n"
- "installation. If you are installing FreeBSD for the first time\n"
- "then you should simply type Q when you're finished here and your\n"
- "changes will be committed in one batch automatically at the end of\n"
- "these questions.\n\n"
- "Are you absolutely sure you want to do this now?")) {
- variable_set2(DISK_LABELLED, "yes", 0);
- diskLabelCommit(NULL);
- }
- clear_wins();
- break;
-
- case '|':
- if (!msgYesNo("Are you sure you want to go into Wizard mode?\n\n"
- "This is an entirely undocumented feature which you are not\n"
- "expected to understand!")) {
- int i;
- Device **devs;
-
- dialog_clear();
- end_dialog();
- DialogActive = FALSE;
- devs = deviceFind(NULL, DEVICE_TYPE_DISK);
- if (!devs) {
- msgConfirm("Can't find any disk devices!");
- break;
- }
- for (i = 0; devs[i] && ((Disk *)devs[i]->private); i++) {
- if (devs[i]->enabled)
- slice_wizard(((Disk *)devs[i]->private));
- }
- if (((cp = variable_get(DISK_LABELLED)) == NULL) || (strcmp(cp, "written")))
- variable_set2(DISK_LABELLED, "yes", 0);
- DialogActive = TRUE;
- record_label_chunks(devs, dev);
- clear_wins();
- }
- else
- msg = "A most prudent choice!";
- break;
-
- case '\033': /* ESC */
- case 'Q':
- labeling = FALSE;
- break;
-
- default:
- beep();
- sprintf(_msg, "Invalid key %d - Type F1 or ? for help", key);
- msg = _msg;
- break;
- }
- if (label_chunk_info[here].type == PART_SLICE)
- pslice_focus = here;
- else
- label_focus = here;
- }
- restorescr(w);
- return DITEM_SUCCESS;
-}
-
-static int
-diskLabelNonInteractive(Device *dev)
-{
- char *cp;
- PartType type;
- PartInfo *p;
- u_long flags = 0;
- int i, status;
- Device **devs;
- Disk *d;
-
- status = DITEM_SUCCESS;
- cp = variable_get(VAR_DISK);
- if (!cp) {
- msgConfirm("diskLabel: No disk selected - can't label automatically.");
- return DITEM_FAILURE;
- }
- devs = deviceFind(cp, DEVICE_TYPE_DISK);
- if (!devs) {
- msgConfirm("diskLabel: No disk device %s found!", cp);
- return DITEM_FAILURE;
- }
- if (dev)
- d = dev->private;
- else
- d = devs[0]->private;
-#ifdef __alpha__
- maybe_dedicate(d);
-#endif
- record_label_chunks(devs, dev);
- for (i = 0; label_chunk_info[i].c; i++) {
- Chunk *c1 = label_chunk_info[i].c;
-
- if (label_chunk_info[i].type == PART_SLICE) {
- char name[512];
- int entries = 1;
-
- while (entries) {
- snprintf(name, sizeof name, "%s-%d", c1->name, entries);
- if ((cp = variable_get(name)) != NULL) {
- int sz;
- char typ[10], mpoint[50];
-
- if (sscanf(cp, "%s %d %s", typ, &sz, mpoint) != 3) {
- msgConfirm("For slice entry %s, got an invalid detail entry of: %s", c1->name, cp);
- status = DITEM_FAILURE;
- continue;
- }
- else {
- Chunk *tmp;
-
- if (!strcmp(typ, "swap")) {
- type = PART_SWAP;
- strcpy(mpoint, "SWAP");
- }
- else {
- type = PART_FILESYSTEM;
- if (!strcmp(mpoint, "/"))
- flags |= CHUNK_IS_ROOT;
- else
- flags &= ~CHUNK_IS_ROOT;
- }
- if (!sz)
- sz = space_free(c1);
- if (sz > space_free(c1)) {
- msgConfirm("Not enough free space to create partition: %s", mpoint);
- status = DITEM_FAILURE;
- continue;
- }
- if (!(tmp = Create_Chunk_DWIM(d, c1, sz, part,
- (type == PART_SWAP) ? FS_SWAP : FS_BSDFFS, flags))) {
- msgConfirm("Unable to create from partition spec: %s. Too big?", cp);
- status = DITEM_FAILURE;
- break;
- }
- else {
- tmp->private_data = new_part(mpoint, TRUE, sz);
- tmp->private_free = safe_free;
- status = DITEM_SUCCESS;
- }
- }
- entries++;
- }
- else {
- /* No more matches, leave the loop */
- entries = 0;
- }
- }
- }
- else {
- /* Must be something we can set a mountpoint for */
- cp = variable_get(c1->name);
- if (cp) {
- char mpoint[50], do_newfs[8];
- Boolean newfs = FALSE;
-
- do_newfs[0] = '\0';
- if (sscanf(cp, "%s %s", mpoint, do_newfs) != 2) {
- msgConfirm("For slice entry %s, got an invalid detail entry of: %s", c1->name, cp);
- status = DITEM_FAILURE;
- continue;
- }
- newfs = toupper(do_newfs[0]) == 'Y' ? TRUE : FALSE;
- if (c1->private_data) {
- p = c1->private_data;
- p->newfs = newfs;
- strcpy(p->mountpoint, mpoint);
- }
- else {
- c1->private_data = new_part(mpoint, newfs, 0);
- c1->private_free = safe_free;
- }
- if (!strcmp(mpoint, "/"))
- c1->flags |= CHUNK_IS_ROOT;
- else
- c1->flags &= ~CHUNK_IS_ROOT;
- }
- }
- }
- if (status == DITEM_SUCCESS)
- variable_set2(DISK_LABELLED, "yes", 0);
- return status;
-}
diff --git a/usr.sbin/sade/list.h b/usr.sbin/sade/list.h
deleted file mode 100644
index 8300173e0660..000000000000
--- a/usr.sbin/sade/list.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last attempt in the `sysinstall' line, the next
- * generation being slated for what's essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1997 FreeBSD, Inc.
- * 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 PAUL TRAINA ``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 PAUL TRAINA OR HIS KILLER RATS 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, LIFE 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.
- *
- */
-
-/* The structure */
-typedef struct _qelement {
- struct _qelement *q_forw;
- struct _qelement *q_back;
-} qelement;
-
-#define INITQUE(Xhead) { \
- (Xhead).q_forw = &(Xhead); \
- (Xhead).q_back = &(Xhead); \
-}
-
-#define EMPTYQUE(Xhead) \
- ((Xhead).q_forw == &(Xhead))
-
-#define INSQUEUE(elem, pred) { \
- register qelement *Xe = (qelement *) (elem); \
- register qelement *Xp = (qelement *) (pred); \
- Xp->q_forw = (Xe->q_forw = (Xe->q_back = Xp)->q_forw)->q_back = Xe; \
-}
-
-#define REMQUE(elem) { \
- register qelement *Xe = (qelement *) (elem); \
- (Xe->q_back->q_forw = Xe->q_forw)->q_back = Xe->q_back; \
-}
diff --git a/usr.sbin/sade/main.c b/usr.sbin/sade/main.c
deleted file mode 100644
index 885b6cb1b453..000000000000
--- a/usr.sbin/sade/main.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last attempt in the `sysinstall' line, the next
- * generation being slated for what's essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 "sysinstall.h"
-#include <sys/signal.h>
-#include <sys/fcntl.h>
-
-static void
-screech(int sig)
-{
- msgDebug("\007Signal %d caught! That's bad!\n", sig);
- longjmp(BailOut, sig);
-}
-
-int
-main(int argc, char **argv)
-{
- int choice, scroll, curr, max, status;
-
- /* Catch fatal signals and complain about them if running as init */
- if (getpid() == 1) {
- signal(SIGBUS, screech);
- signal(SIGSEGV, screech);
- }
- signal(SIGPIPE, SIG_IGN);
-
- /* We don't work too well when running as non-root anymore */
- if (geteuid() != 0) {
- fprintf(stderr, "Error: This utility should only be run as root.\n");
- return 1;
- }
-
- /* Set up whatever things need setting up */
- systemInitialize(argc, argv);
-
- /* Set default flag and variable values */
- installVarDefaults(NULL);
- /* only when multi-user is it reasonable to do this here */
- if (!RunningAsInit)
- installEnvironment();
-
- if (argc > 1 && !strcmp(argv[1], "-fake")) {
- variable_set2(VAR_DEBUG, "YES", 0);
- Fake = TRUE;
- msgConfirm("I'll be just faking it from here on out, OK?");
- }
-
- /* Try to preserve our scroll-back buffer */
- if (OnVTY) {
- for (curr = 0; curr < 25; curr++)
- putchar('\n');
- }
- /* Move stderr aside */
- if (DebugFD)
- dup2(DebugFD, 2);
-
- /* Initialize PC-card */
- pccardInitialize();
-
- /* Probe for all relevant devices on the system */
- deviceGetAll();
-
- /* First, see if we have any arguments to process (and argv[0] counts if it's not "sysinstall") */
- if (!RunningAsInit) {
- int i, start_arg;
-
- if (!strstr(argv[0], "sysinstall"))
- start_arg = 0;
- else if (Fake)
- start_arg = 2;
- else
- start_arg = 1;
- for (i = start_arg; i < argc; i++) {
- if (DITEM_STATUS(dispatchCommand(argv[i])) != DITEM_SUCCESS)
- systemShutdown(1);
- }
- if (argc > start_arg)
- systemShutdown(0);
- }
- else
- dispatch_load_file_int(TRUE);
-
- status = setjmp(BailOut);
- if (status) {
- msgConfirm("A signal %d was caught - I'm saving what I can and shutting\n"
- "If you can reproduce the problem, please turn Debug on in\n"
- "the Options menu for the extra information it provides in\n"
- "debugging problems like this.", status);
- systemShutdown(status);
- }
-
- /* Begin user dialog at outer menu */
- dialog_clear();
- while (1) {
- choice = scroll = curr = max = 0;
- dmenuOpen(&MenuInitial, &choice, &scroll, &curr, &max, TRUE);
- if (getpid() != 1
-#ifdef __alpha__
- || !msgYesNo("Are you sure you wish to exit? The system will halt.")
-#else
- || !msgYesNo("Are you sure you wish to exit? The system will reboot\n"
- "(be sure to remove any floppies/CDROMs from the drives).")
-#endif
- )
- break;
- }
-
- /* Say goodnight, Gracie */
- systemShutdown(0);
-
- return 0; /* We should never get here */
-}
diff --git a/usr.sbin/sade/menus.c b/usr.sbin/sade/menus.c
deleted file mode 100644
index 8bc27bab4261..000000000000
--- a/usr.sbin/sade/menus.c
+++ /dev/null
@@ -1,1630 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last program in the `sysinstall' line - the next
- * generation being essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 "sysinstall.h"
-
-#ifdef __alpha__
-#define _AS(str) str "alpha/"
-#else /* i386 */
-#define _AS(str) str "i386/"
-#endif
-#define _AP(str) _AS(str "/pub/FreeBSD/releases/")
-
-/* Miscellaneous work routines for menus */
-static int
-setSrc(dialogMenuItem *self)
-{
- Dists |= DIST_SRC;
- SrcDists = DIST_SRC_ALL;
- return DITEM_SUCCESS | DITEM_REDRAW;
-}
-
-static int
-clearSrc(dialogMenuItem *self)
-{
- Dists &= ~DIST_SRC;
- SrcDists = 0;
- return DITEM_SUCCESS | DITEM_REDRAW;
-}
-
-static int
-setCRYPTO(dialogMenuItem *self)
-{
- Dists |= DIST_CRYPTO;
- CRYPTODists = DIST_CRYPTO_ALL;
- return DITEM_SUCCESS | DITEM_REDRAW;
-}
-
-static int
-clearCRYPTO(dialogMenuItem *self)
-{
- Dists &= ~DIST_CRYPTO;
- CRYPTODists = 0;
- return DITEM_SUCCESS | DITEM_REDRAW;
-}
-
-static int
-setX11Misc(dialogMenuItem *self)
-{
- XF86Dists |= DIST_XF86_MISC_ALL;
- Dists |= DIST_XF86;
- return DITEM_SUCCESS | DITEM_REDRAW;
-}
-
-static int
-clearX11Misc(dialogMenuItem *self)
-{
- XF86Dists &= ~DIST_XF86_MISC_ALL;
- if (!XF86ServerDists && !XF86FontDists)
- Dists &= ~DIST_XF86;
- return DITEM_SUCCESS | DITEM_REDRAW;
-}
-
-static int
-setX11Servers(dialogMenuItem *self)
-{
- XF86Dists |= DIST_XF86_SERVER;
- XF86ServerDists = DIST_XF86_SERVER_ALL;
- return DITEM_SUCCESS | DITEM_REDRAW;
-}
-
-static int
-clearX11Servers(dialogMenuItem *self)
-{
- XF86Dists &= ~DIST_XF86_SERVER;
- XF86ServerDists = 0;
- return DITEM_SUCCESS | DITEM_REDRAW;
-}
-
-static int
-setX11Fonts(dialogMenuItem *self)
-{
- XF86Dists |= DIST_XF86_FONTS;
- XF86FontDists = DIST_XF86_FONTS_ALL;
- return DITEM_SUCCESS | DITEM_REDRAW;
-}
-
-static int
-clearX11Fonts(dialogMenuItem *self)
-{
- XF86Dists &= ~DIST_XF86_FONTS;
- XF86FontDists = 0;
- return DITEM_SUCCESS | DITEM_REDRAW;
-}
-
-#define _IS_SET(dist, set) (((dist) & (set)) == (set))
-
-#define IS_DEVELOPER(dist, extra) (_IS_SET(dist, _DIST_DEVELOPER | extra) || \
- _IS_SET(dist, _DIST_DEVELOPER | DIST_CRYPTO | extra))
-
-#define IS_USER(dist, extra) (_IS_SET(dist, _DIST_USER | extra) || \
- _IS_SET(dist, _DIST_USER | DIST_CRYPTO | extra))
-
-static int
-checkDistDeveloper(dialogMenuItem *self)
-{
- return IS_DEVELOPER(Dists, 0) && _IS_SET(SrcDists, DIST_SRC_ALL);
-}
-
-static int
-checkDistXDeveloper(dialogMenuItem *self)
-{
- return IS_DEVELOPER(Dists, DIST_XF86) && _IS_SET(SrcDists, DIST_SRC_ALL);
-}
-
-static int
-checkDistKernDeveloper(dialogMenuItem *self)
-{
- return IS_DEVELOPER(Dists, 0) && _IS_SET(SrcDists, DIST_SRC_SYS);
-}
-
-static int
-checkDistXKernDeveloper(dialogMenuItem *self)
-{
- return IS_DEVELOPER(Dists, DIST_XF86) && _IS_SET(SrcDists, DIST_SRC_SYS);
-}
-
-static int
-checkDistUser(dialogMenuItem *self)
-{
- return IS_USER(Dists, 0);
-}
-
-static int
-checkDistXUser(dialogMenuItem *self)
-{
- return IS_USER(Dists, DIST_XF86);
-}
-
-static int
-checkDistMinimum(dialogMenuItem *self)
-{
- return Dists == DIST_BIN;
-}
-
-static int
-checkDistEverything(dialogMenuItem *self)
-{
- return Dists == DIST_ALL && _IS_SET(SrcDists, DIST_SRC_ALL) && \
- _IS_SET(XF86Dists, DIST_XF86_ALL) && \
- _IS_SET(XF86ServerDists, DIST_XF86_SERVER_ALL) && \
- _IS_SET(XF86FontDists, DIST_XF86_FONTS_ALL);
-}
-
-static int
-CRYPTOFlagCheck(dialogMenuItem *item)
-{
- return CRYPTODists;
-}
-
-static int
-srcFlagCheck(dialogMenuItem *item)
-{
- return SrcDists;
-}
-
-static int
-x11FlagCheck(dialogMenuItem *item)
-{
- return Dists & DIST_XF86;
-}
-
-static int
-checkTrue(dialogMenuItem *item)
-{
- return TRUE;
-}
-
-/* All the system menus go here.
- *
- * Hardcoded things like version number strings will disappear from
- * these menus just as soon as I add the code for doing inline variable
- * expansion.
- */
-
-DMenu MenuIndex = {
- DMENU_NORMAL_TYPE,
- "Glossary of functions",
- "This menu contains an alphabetized index of the top level functions in\n"
- "this program (sysinstall). Invoke an option by pressing [ENTER].\n"
- "Leave the index page by selecting Cancel [TAB-ENTER].",
- "Use PageUp or PageDown to move through this menu faster!",
- NULL,
- { { " Anon FTP", "Configure anonymous FTP logins.", dmenuVarCheck, configAnonFTP, NULL, "anon_ftp" },
- { " Commit", "Commit any pending actions (dangerous!)", NULL, installCustomCommit },
- { " Console settings", "Customize system console behavior.", NULL, dmenuSubmenu, NULL, &MenuSyscons },
- { " Configure", "The system configuration menu.", NULL, dmenuSubmenu, NULL, &MenuConfigure },
- { " Defaults, Load", "Load default settings.", NULL, dispatch_load_floppy },
- { " Device, Mouse", "The mouse configuration menu.", NULL, dmenuSubmenu, NULL, &MenuMouse },
- { " Disklabel", "The disk Label editor", NULL, diskLabelEditor },
- { " Dists, All", "Root of the distribution tree.", NULL, dmenuSubmenu, NULL, &MenuDistributions },
- { " Dists, Basic", "Basic FreeBSD distribution menu.", NULL, dmenuSubmenu, NULL, &MenuSubDistributions },
- { " Dists, CRYPTO", "Encryption distribution menu.", NULL, dmenuSubmenu, NULL, &MenuCRYPTODistributions },
- { " Dists, Developer", "Select developer's distribution.", checkDistDeveloper, distSetDeveloper },
- { " Dists, Src", "Src distribution menu.", NULL, dmenuSubmenu, NULL, &MenuSrcDistributions },
- { " Dists, X Developer", "Select X developer's distribution.", checkDistXDeveloper, distSetXDeveloper },
- { " Dists, Kern Developer", "Select kernel developer's distribution.", checkDistKernDeveloper, distSetKernDeveloper },
- { " Dists, User", "Select average user distribution.", checkDistUser, distSetUser },
- { " Dists, X User", "Select average X user distribution.", checkDistXUser, distSetXUser },
- { " Distributions, Adding", "Installing additional distribution sets", NULL, distExtractAll },
- { " Distributions, XFree86","XFree86 distribution menu.", NULL, distSetXF86 },
- { " Documentation", "Installation instructions, README, etc.", NULL, dmenuSubmenu, NULL, &MenuDocumentation },
- { " Doc, README", "The distribution README file.", NULL, dmenuDisplayFile, NULL, "README" },
- { " Doc, Hardware", "The distribution hardware guide.", NULL, dmenuDisplayFile, NULL, "HARDWARE" },
- { " Doc, Install", "The distribution installation guide.", NULL, dmenuDisplayFile, NULL, "INSTALL" },
- { " Doc, Copyright", "The distribution copyright notices.", NULL, dmenuDisplayFile, NULL, "COPYRIGHT" },
- { " Doc, Release", "The distribution release notes.", NULL, dmenuDisplayFile, NULL, "RELNOTES" },
- { " Doc, HTML", "The HTML documentation menu.", NULL, docBrowser },
- { " Dump Vars", "(debugging) dump out internal variables.", NULL, dump_variables },
- { " Emergency shell", "Start an Emergency Holographic shell.", NULL, installFixitHoloShell },
-#ifdef __i386__
- { " Fdisk", "The disk Partition Editor", NULL, diskPartitionEditor },
-#endif
- { " Fixit", "Repair mode with CDROM or fixit floppy.", NULL, dmenuSubmenu, NULL, &MenuFixit },
- { " FTP sites", "The FTP mirror site listing.", NULL, dmenuSubmenu, NULL, &MenuMediaFTP },
- { " Gateway", "Set flag to route packets between interfaces.", dmenuVarCheck, dmenuToggleVariable, NULL, "gateway=YES" },
- { " HTML Docs", "The HTML documentation menu", NULL, docBrowser },
- { " Install, Standard", "A standard system installation.", NULL, installStandard },
- { " Install, Express", "An express system installation.", NULL, installExpress },
- { " Install, Custom", "The custom installation menu", NULL, dmenuSubmenu, NULL, &MenuInstallCustom },
- { " Label", "The disk Label editor", NULL, diskLabelEditor },
- { " Media", "Top level media selection menu.", NULL, dmenuSubmenu, NULL, &MenuMedia },
- { " Media, Tape", "Select tape installation media.", NULL, mediaSetTape },
- { " Media, NFS", "Select NFS installation media.", NULL, mediaSetNFS },
- { " Media, Floppy", "Select floppy installation media.", NULL, mediaSetFloppy },
- { " Media, CDROM", "Select CDROM installation media.", NULL, mediaSetCDROM },
- { " Media, DOS", "Select DOS installation media.", NULL, mediaSetDOS },
- { " Media, UFS", "Select UFS installation media.", NULL, mediaSetUFS },
- { " Media, FTP", "Select FTP installation media.", NULL, mediaSetFTP },
- { " Media, FTP Passive", "Select passive FTP installation media.", NULL, mediaSetFTPPassive },
- { " Media, HTTP", "Select FTP via HTTP proxy installation media.", NULL, mediaSetHTTP },
- { " Network Interfaces", "Configure network interfaces", NULL, tcpMenuSelect },
- { " Networking Services", "The network services menu.", NULL, dmenuSubmenu, NULL, &MenuNetworking },
- { " NFS, client", "Set NFS client flag.", dmenuVarCheck, dmenuToggleVariable, NULL, "nfs_client_enable=YES" },
- { " NFS, server", "Set NFS server flag.", dmenuVarCheck, configNFSServer, NULL, "nfs_server_enable=YES" },
- { " NTP Menu", "The NTP configuration menu.", NULL, dmenuSubmenu, NULL, &MenuNTP },
- { " Options", "The options editor.", NULL, optionsEditor },
- { " Packages", "The packages collection", NULL, configPackages },
- { " Partition", "The disk Slice (PC-style partition) Editor", NULL, diskPartitionEditor },
- { " PCNFSD", "Run authentication server for PC-NFS.", dmenuVarCheck, configPCNFSD, NULL, "pcnfsd" },
- { " Root Password", "Set the system manager's password.", NULL, dmenuSystemCommand, NULL, "passwd root" },
- { " Router", "Select routing daemon (default: routed)", NULL, configRouter, NULL, "router_enable" },
- { " Syscons", "The system console configuration menu.", NULL, dmenuSubmenu, NULL, &MenuSyscons },
- { " Syscons, Font", "The console screen font.", NULL, dmenuSubmenu, NULL, &MenuSysconsFont },
- { " Syscons, Keymap", "The console keymap configuration menu.", NULL, dmenuSubmenu, NULL, &MenuSysconsKeymap },
- { " Syscons, Keyrate", "The console key rate configuration menu.", NULL, dmenuSubmenu, NULL, &MenuSysconsKeyrate },
- { " Syscons, Saver", "The console screen saver configuration menu.", NULL, dmenuSubmenu, NULL, &MenuSysconsSaver },
- { " Syscons, Screenmap", "The console screenmap configuration menu.", NULL, dmenuSubmenu, NULL, &MenuSysconsScrnmap },
- { " Time Zone", "Set the system's time zone.", NULL, dmenuSystemCommand, NULL, "tzsetup" },
- { " Upgrade", "Upgrade an existing system.", NULL, installUpgrade },
- { " Usage", "Quick start - How to use this menu system.", NULL, dmenuDisplayFile, NULL, "usage" },
- { " User Management", "Add user and group information.", NULL, dmenuSubmenu, NULL, &MenuUsermgmt },
- { " XFree86, Fonts", "XFree86 Font selection menu.", NULL, dmenuSubmenu, NULL, &MenuXF86SelectFonts },
- { " XFree86, Server", "XFree86 Server selection menu.", NULL, dmenuSubmenu, NULL, &MenuXF86SelectServer },
-#ifdef __i386__
- { " XFree86, PC98 Server", "XFree86 PC98 Server selection menu.", NULL, dmenuSubmenu, NULL, &MenuXF86SelectPC98Server },
-#endif
- { NULL } },
-};
-
-/* The initial installation menu */
-DMenu MenuInitial = {
- DMENU_NORMAL_TYPE,
- "/stand/sysinstall Main Menu", /* title */
- "Welcome to the FreeBSD installation and configuration tool. Please\n" /* prompt */
- "select one of the options below by using the arrow keys or typing the\n"
- "first character of the option name you're interested in. Invoke an\n"
- "option by pressing [ENTER] or [TAB-ENTER] to exit the installation.",
- "Press F1 for Installation Guide", /* help line */
- "install", /* help file */
- { { "Select" },
- { "X Exit Install", NULL, NULL, dmenuExit },
- { " Usage", "Quick start - How to use this menu system", NULL, dmenuDisplayFile, NULL, "usage" },
- { "Standard", "Begin a standard installation (recommended)", NULL, installStandard },
- { "Express", "Begin a quick installation (for the impatient)", NULL, installExpress },
- { " Custom", "Begin a custom installation (for experts)", NULL, dmenuSubmenu, NULL, &MenuInstallCustom },
- { "Configure", "Do post-install configuration of FreeBSD", NULL, dmenuSubmenu, NULL, &MenuConfigure },
- { "Doc", "Installation instructions, README, etc.", NULL, dmenuSubmenu, NULL, &MenuDocumentation },
- { "Keymap", "Select keyboard type", NULL, dmenuSubmenu, NULL, &MenuSysconsKeymap },
- { "Options", "View/Set various installation options", NULL, optionsEditor },
- { "Fixit", "Enter repair mode with CDROM/floppy or start shell", NULL, dmenuSubmenu, NULL, &MenuFixit },
- { "Upgrade", "Upgrade an existing system", NULL, installUpgrade },
- { "Load Config","Load default install configuration", NULL, dispatch_load_floppy },
- { "Index", "Glossary of functions", NULL, dmenuSubmenu, NULL, &MenuIndex },
- { NULL } },
-};
-
-/* The main documentation menu */
-DMenu MenuDocumentation = {
- DMENU_NORMAL_TYPE,
- "FreeBSD Documentation Menu",
- "If you are at all unsure about the configuration of your hardware\n"
- "or are looking to build a system specifically for FreeBSD, read the\n"
- "Hardware guide! New users should also read the Install document for\n"
- "a step-by-step tutorial on installing FreeBSD. For general information,\n"
- "consult the README file.",
- "Confused? Press F1 for help.",
- "usage",
- { { "X Exit", "Exit this menu (returning to previous)", NULL, dmenuExit },
- { "2 README", "A general description of FreeBSD. Read this!", NULL, dmenuDisplayFile, NULL, "README" },
- { "3 Hardware", "The FreeBSD survival guide for PC hardware.", NULL, dmenuDisplayFile, NULL, "HARDWARE" },
- { "4 Install", "A step-by-step guide to installing FreeBSD.", NULL, dmenuDisplayFile, NULL, "INSTALL" },
- { "5 Copyright", "The FreeBSD Copyright notices.", NULL, dmenuDisplayFile, NULL, "COPYRIGHT" },
- { "6 Release" ,"The release notes for this version of FreeBSD.", NULL, dmenuDisplayFile, NULL, "RELNOTES" },
- { "7 Shortcuts", "Creating shortcuts to sysinstall.", NULL, dmenuDisplayFile, NULL, "shortcuts" },
- { "8 HTML Docs", "Go to the HTML documentation menu (post-install).", NULL, docBrowser },
- { NULL } },
-};
-
-DMenu MenuMouseType = {
- DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS,
- "Select a protocol type for your mouse",
- "If your mouse is attached to the PS/2 mouse port or the bus mouse port,\n"
- "you should always choose \"Auto\", regardless of the model and the brand\n"
- "of the mouse. All other protocol types are for serial mice and should\n"
- "not be used with the PS/2 port mouse or the bus mouse. If you have\n"
- "a serial mouse and are not sure about its protocol, you should also try\n"
- "\"Auto\". It may not work for the serial mouse if the mouse does not\n"
- "support the PnP standard. But, it won't hurt. Many 2-button serial mice\n"
- "are compatible with \"Microsoft\" or \"MouseMan\". 3-button serial mice\n"
- "may be compatible with \"MouseSystems\" or \"MouseMan\". If the serial\n"
- "mouse has a wheel, it may be compatible with \"IntelliMouse\".",
- NULL,
- NULL,
- { { "1 Auto", "Bus mouse, PS/2 style mouse or PnP serial mouse",
- dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_TYPE "=auto" },
- { "2 GlidePoint", "ALPS GlidePoint pad (serial)",
- dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_TYPE "=glidepoint" },
- { "3 Hitachi","Hitachi tablet (serial)",
- dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_TYPE "=mmhittab" },
- { "4 IntelliMouse", "Microsoft IntelliMouse (serial)",
- dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_TYPE "=intellimouse" },
- { "5 Logitech", "Logitech protocol (old models) (serial)",
- dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_TYPE "=logitech" },
- { "6 Microsoft", "Microsoft protocol (serial)",
- dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_TYPE "=microsoft" },
- { "7 MM Series","MM Series protocol (serial)",
- dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_TYPE "=mmseries" },
- { "8 MouseMan", "Logitech MouseMan/TrackMan models (serial)",
- dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_TYPE "=mouseman" },
- { "9 MouseSystems", "MouseSystems protocol (serial)",
- dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_TYPE "=mousesystems" },
- { "A ThinkingMouse","Kensington ThinkingMouse (serial)",
- dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_TYPE "=thinkingmouse" },
- { NULL } },
-};
-
-DMenu MenuMousePort = {
- DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS,
- "Select your mouse port from the following menu",
- "The built-in pointing device of laptop/notebook computers is usually\n"
- "a PS/2 style device.",
- NULL,
- NULL,
- { { "1 PS/2", "PS/2 style mouse (/dev/psm0)",
- dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_PORT "=/dev/psm0" },
- { "2 COM1", "Serial mouse on COM1 (/dev/cuaa0)",
- dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_PORT "=/dev/cuaa0" },
- { "3 COM2", "Serial mouse on COM2 (/dev/cuaa1)",
- dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_PORT "=/dev/cuaa1" },
- { "4 COM3", "Serial mouse on COM3 (/dev/cuaa2)",
- dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_PORT "=/dev/cuaa2" },
- { "5 COM4", "Serial mouse on COM4 (/dev/cuaa3)",
- dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_PORT "=/dev/cuaa3" },
- { "6 BusMouse", "Logitech, ATI or MS bus mouse (/dev/mse0)",
- dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_PORT "=/dev/mse0" },
- { NULL } },
-};
-
-DMenu MenuMouse = {
- DMENU_NORMAL_TYPE,
- "Please configure your mouse",
- "You can cut and paste text in the text console by running the mouse\n"
- "daemon. Specify a port and a protocol type of your mouse and enable\n"
- "the mouse daemon. If you don't want this feature, select 4 to disable\n"
- "the daemon.\n"
- "Once you've enabled the mouse daemon, you can specify \"/dev/sysmouse\"\n"
- "as your mouse device and \"SysMouse\" or \"MouseSystems\" as mouse\n"
- "protocol when running the X configuration utility (see Configuration\n"
- "menu).",
- NULL,
- NULL,
- { { "X Exit", "Exit this menu (returning to previous)", NULL, dmenuExit },
- { "2 Enable", "Test and run the mouse daemon", NULL, mousedTest, NULL, NULL },
- { "3 Type", "Select mouse protocol type", NULL, dmenuSubmenu, NULL, &MenuMouseType },
- { "4 Port", "Select mouse port", NULL, dmenuSubmenu, NULL, &MenuMousePort },
- { "5 Disable", "Disable the mouse daemon", NULL, mousedDisable, NULL, NULL },
- { NULL } },
-};
-
-DMenu MenuXF86Config = {
- DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS,
- "Please select the XFree86 configuration tool you want to use.",
-#ifdef __alpha__
- "Due to problems with the VGA16 server right now, only the\n"
- "text-mode configuration tool (xf86config) is currently supported.",
-#else
- "The first tool, XF86Setup, is fully graphical and requires the\n"
- "VGA16 server in order to work (should have been selected by\n"
- "default, but if you de-selected it then you won't be able to\n"
- "use this fancy setup tool). The second tool, xf86config, is\n"
- "a more simplistic shell-script based tool and less friendly to\n"
- "new users, but it may work in situations where the fancier one\n"
- "does not.",
-#endif
- NULL,
- NULL,
- { { "X Exit", "Exit this menu (returning to previous)",
- NULL, dmenuExit },
-#ifdef __alpha__
- { "2 xf86config", "Shell-script based XFree86 configuration tool.",
- NULL, dmenuSetVariable, NULL, VAR_XF86_CONFIG "=xf86config" },
-#else
- { "2 XF86Setup", "Fully graphical XFree86 configuration tool.",
- NULL, dmenuSetVariable, NULL, VAR_XF86_CONFIG "=XF86Setup" },
- { "3 xf86config", "Shell-script based XFree86 configuration tool.",
- NULL, dmenuSetVariable, NULL, VAR_XF86_CONFIG "=xf86config" },
- { "4 XF98Setup", "Fully graphical XFree86 configuration tool (PC98).",
- NULL, dmenuSetVariable, NULL, VAR_XF86_CONFIG "=XF98Setup" },
-#endif
- { "D XDesktop", "X already set up, just do desktop configuration.",
- NULL, dmenuSubmenu, NULL, &MenuXDesktops },
- { NULL } },
-};
-
-DMenu MenuXDesktops = {
- DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS,
- "Please select the default X desktop to use.",
- "By default, XFree86 comes with a fairly vanilla desktop which\n"
- "is based around the twm(1) window manager and does not offer\n"
- "much in the way of features. It does have the advantage of\n"
- "being a standard part of X so you don't need to load anything\n"
- "extra in order to use it. If, however, you have access to a\n"
- "reasonably full packages collection on your installation media,\n"
- "you can choose any one of the following desktops as alternatives.",
- NULL,
- NULL,
- { { "X Exit", "Exit this menu (returning to previous)",
- NULL, dmenuExit },
- { "2 KDE", "The K Desktop Environment.",
- NULL, dmenuSetVariable, NULL, VAR_DESKSTYLE "=kde" },
- { "3 GNOME + Afterstep", "GNOME + Afterstep window manager.",
- NULL, dmenuSetVariable, NULL, VAR_DESKSTYLE "=gnome" },
- { "4 GNOME + Enlightenment","GNOME + The E window manager",
- NULL, dmenuSetVariable, NULL, VAR_DESKSTYLE "=enlightenment" },
- { "5 Afterstep", "The Afterstep window manager",
- NULL, dmenuSetVariable, NULL, VAR_DESKSTYLE "=afterstep" },
- { "6 Windowmaker", "The Windowmaker window manager",
- NULL, dmenuSetVariable, NULL, VAR_DESKSTYLE "=windowmaker" },
- { "7 fvwm2", "The fvwm2 window manager",
- NULL, dmenuSetVariable, NULL, VAR_DESKSTYLE "=fvwm2" },
- { NULL } },
-};
-
-DMenu MenuMediaCDROM = {
- DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS,
- "Choose a CDROM type",
- "FreeBSD can be installed directly from a CDROM containing a valid\n"
- "FreeBSD distribution. If you are seeing this menu it is because\n"
- "more than one CDROM drive was found on your system. Please select one\n"
- "of the following CDROM drives as your installation drive.",
- "Press F1 to read the installation guide",
- "install",
- { { NULL } },
-};
-
-DMenu MenuMediaFloppy = {
- DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS,
- "Choose a Floppy drive",
- "You have more than one floppy drive. Please choose which drive\n"
- "you would like to use.",
- NULL,
- NULL,
- { { NULL } },
-};
-
-DMenu MenuMediaDOS = {
- DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS,
- "Choose a DOS partition",
- "FreeBSD can be installed directly from a DOS partition\n"
- "assuming, of course, that you have copied the relevant\n"
- "distributions into your DOS partition before starting this\n"
- "installation. If this is not the case then you should reboot\n"
- "DOS at this time and copy the distributions you wish to install\n"
- "into a \"FREEBSD\" subdirectory on one of your DOS partitions.\n"
- "Otherwise, please select the DOS partition containing the FreeBSD\n"
- "distribution files.",
- "Press F1 to read the installation guide",
- "install",
- { { NULL } },
-};
-
-DMenu MenuMediaFTP = {
- DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS,
- "Please select a FreeBSD FTP distribution site",
- "Please select the site closest to you or \"other\" if you'd like to\n"
- "specify a different choice. Also note that not every site listed here\n"
- "carries more than the base distribution kits. Only the Primary site is\n"
- "guaranteed to carry the full range of possible distributions.",
- "Select a site that's close!",
- "install",
- { { "Primary Site", "ftp.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AS("=ftp://ftp.freebsd.org/pub/FreeBSD/releases/") },
- { "URL", "Specify some other ftp site by URL", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH "=other" },
- { " 4.0 SNAP Server", "current.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AS("=ftp://current.freebsd.org/pub/FreeBSD/snapshots/") },
- { " 3.0 SNAP Server", "releng3.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AS("=ftp://releng3.freebsd.org/pub/FreeBSD/snapshots/") },
- { "Argentina", "ftp.ar.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.ar.freebsd.org") },
- { " Australia", "ftp.au.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.au.freebsd.org") },
- { " Australia #2","ftp2.au.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp2.au.freebsd.org") },
- { " Australia #3","ftp3.au.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp3.au.freebsd.org") },
- { " Australia #4","ftp4.au.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp4.au.freebsd.org") },
- { " Australia #5","ftp5.au.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp5.au.freebsd.org") },
- { "Brazil", "ftp.br.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.br.freebsd.org") },
- { " Brazil #2", "ftp2.br.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp2.br.freebsd.org") },
- { " Brazil #3", "ftp3.br.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp3.br.freebsd.org") },
- { " Brazil #4", "ftp4.br.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp4.br.freebsd.org") },
- { " Brazil #5", "ftp5.br.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp5.br.freebsd.org") },
- { " Brazil #6", "ftp6.br.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp6.br.freebsd.org") },
- { " Brazil #7", "ftp7.br.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp7.br.freebsd.org") },
- { " Canada", "ftp.ca.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.ca.freebsd.org") },
- { " Czech Republic", "ftp.cz.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.cz.freebsd.org") },
- { "Denmark", "ftp.dk.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.dk.freebsd.org") },
- { " Denmark #2", "ftp2.dk.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp2.dk.freebsd.org") },
- { "Estonia", "ftp.ee.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.ee.freebsd.org") },
- { "Finland", "ftp.fi.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.fi.freebsd.org") },
- { " France", "ftp.fr.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.fr.freebsd.org") },
- { " France #2", "ftp2.fr.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp2.fr.freebsd.org") },
- { " France #3", "ftp3.fr.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp3.fr.freebsd.org") },
- { "Germany", "ftp.de.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.de.freebsd.org") },
- { " Germany #2", "ftp2.de.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp2.de.freebsd.org") },
- { " Germany #3", "ftp3.de.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp3.de.freebsd.org") },
- { " Germany #4", "ftp4.de.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp4.de.freebsd.org") },
- { " Germany #5", "ftp5.de.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp5.de.freebsd.org") },
- { " Germany #6", "ftp6.de.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp6.de.freebsd.org") },
- { " Germany #7", "ftp7.de.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp7.de.freebsd.org") },
- { "Holland", "ftp.nl.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.nl.freebsd.org") },
- { " Hong Kong", "ftp.hk.super.net", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.hk.super.net") },
- { "Iceland", "ftp.is.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.is.freebsd.org") },
- { " Ireland", "ftp.ie.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.ie.freebsd.org") },
- { " Israel", "ftp.il.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.il.freebsd.org") },
- { " Israel #2", "ftp2.il.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp2.il.freebsd.org") },
- { "Japan", "ftp.jp.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.jp.freebsd.org") },
- { " Japan #2", "ftp2.jp.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp2.jp.freebsd.org") },
- { " Japan #3", "ftp3.jp.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp3.jp.freebsd.org") },
- { " Japan #4", "ftp4.jp.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp4.jp.freebsd.org") },
- { " Japan #5", "ftp5.jp.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp5.jp.freebsd.org") },
- { " Japan #6", "ftp6.jp.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp6.jp.freebsd.org") },
- { "Korea", "ftp.kr.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.kr.freebsd.org") },
- { " Korea #2", "ftp2.kr.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp2.kr.freebsd.org") },
- { " Korea #3", "ftp3.kr.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp3.kr.freebsd.org") },
- { " Korea #4", "ftp4.kr.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp4.kr.freebsd.org") },
- { " Korea #5", "ftp5.kr.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp5.kr.freebsd.org") },
- { "New Zealand", "ftp.nz.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.nz.freebsd.org") },
- { "Poland", "ftp.pl.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.pl.freebsd.org") },
- { " Portugal", "ftp.pt.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.pt.freebsd.org") },
- { " Portugal #2", "ftp2.pt.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp2.pt.freebsd.org") },
- { "Russia", "ftp.ru.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.ru.freebsd.org") },
- { " Russia #2", "ftp2.ru.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp2.ru.freebsd.org") },
- { " Russia #3", "ftp3.ru.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp3.ru.freebsd.org") },
- { " Russia #4", "ftp4.ru.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp4.ru.freebsd.org") },
- { "Slovak Republic", "ftp.sk.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.sk.freebsd.org") },
- { " South Africa", "ftp.za.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.za.freebsd.org") },
- { " South Africa #2", "ftp2.za.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp2.za.freebsd.org") },
- { " South Africa #3", "ftp3.za.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp3.za.freebsd.org") },
- { " South Africa #4", "ftp4.za.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp4.za.freebsd.org") },
- { " Spain", "ftp.es.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.es.freebsd.org") },
- { " Spain #2", "ftp2.es.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp2.es.freebsd.org") },
- { " Sweden", "ftp.se.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.se.freebsd.org") },
- { " Sweden #2", "ftp2.se.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp2.se.freebsd.org") },
- { " Sweden #3", "ftp3.se.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp3.se.freebsd.org") },
- { "Taiwan", "ftp.tw.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.tw.freebsd.org") },
- { " Taiwan #2", "ftp2.tw.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp2.tw.freebsd.org") },
- { " Taiwan #3", "ftp3.tw.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp3.tw.freebsd.org") },
- { " Thailand", "ftp.nectec.or.th", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AS("=ftp://ftp.nectec.or.th/pub/mirrors/FreeBSD/") },
- { "UK", "ftp.uk.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.uk.freebsd.org") },
- { " UK #2", "ftp2.uk.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp2.uk.freebsd.org") },
- { " UK #3", "ftp3.uk.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp3.uk.freebsd.org") },
- { " UK #4", "ftp4.uk.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp4.uk.freebsd.org") },
- { " UK #5", "ftp5.uk.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp5.uk.freebsd.org") },
- { " USA", "ftp.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.freebsd.org") },
- { " USA #2", "ftp2.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp2.freebsd.org") },
- { " USA #3", "ftp3.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp3.freebsd.org") },
- { " USA #4", "ftp4.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp4.freebsd.org") },
- { " USA #5", "ftp5.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp5.freebsd.org") },
- { " USA #6", "ftp6.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp6.freebsd.org") },
- { NULL } }
-};
-
-DMenu MenuMediaTape = {
- DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS,
- "Choose a tape drive type",
- "FreeBSD can be installed from tape drive, though this installation\n"
- "method requires a certain amount of temporary storage in addition\n"
- "to the space required by the distribution itself (tape drives make\n"
- "poor random-access devices, so we extract _everything_ on the tape\n"
- "in one pass). If you have sufficient space for this, then you should\n"
- "select one of the following tape devices detected on your system.",
- "Press F1 to read the installation guide",
- "install",
- { { NULL } },
-};
-
-DMenu MenuNetworkDevice = {
- DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS,
- "Network interface information required",
- "If you are using PPP over a serial device, as opposed to a direct\n"
- "ethernet connection, then you may first need to dial your Internet\n"
- "Service Provider using the ppp utility we provide for that purpose.\n"
- "If you're using SLIP over a serial device then the expectation is\n"
- "that you have a HARDWIRED connection.\n\n"
- "You can also install over a parallel port using a special \"laplink\"\n"
- "cable to another machine running a fairly recent (2.0R or later)\n"
- "version of FreeBSD.",
- "Press F1 to read network configuration manual",
- "network_device",
- { { NULL } },
-};
-
-/* The media selection menu */
-DMenu MenuMedia = {
- DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS,
- "Choose Installation Media",
- "FreeBSD can be installed from a variety of different installation\n"
- "media, ranging from floppies to an Internet FTP server. If you're\n"
- "installing FreeBSD from a supported CDROM drive then this is generally\n"
- "the best media to use if you have no overriding reason for using other\n"
- "media.",
- "Press F1 for more information on the various media types",
- "media",
- { { "1 CDROM", "Install from a FreeBSD CDROM", NULL, mediaSetCDROM },
- { "2 FTP", "Install from an FTP server", NULL, mediaSetFTPActive },
- { "3 FTP Passive", "Install from an FTP server through a firewall", NULL, mediaSetFTPPassive },
- { "3b HTTP", "Install from an FTP server through a http proxy", NULL, mediaSetHTTP },
- { "4 DOS", "Install from a DOS partition", NULL, mediaSetDOS },
- { "5 NFS", "Install over NFS", NULL, mediaSetNFS },
- { "6 File System", "Install from an existing filesystem", NULL, mediaSetUFS },
- { "7 Floppy", "Install from a floppy disk set", NULL, mediaSetFloppy },
- { "8 Tape", "Install from SCSI or QIC tape", NULL, mediaSetTape },
- { "9 Options", "Go to the Options screen", NULL, optionsEditor },
- { NULL } },
-};
-
-/* The distributions menu */
-DMenu MenuDistributions = {
- DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS,
- "Choose Distributions",
- "As a convenience, we provide several \"canned\" distribution sets.\n"
- "These select what we consider to be the most reasonable defaults for the\n"
- "type of system in question. If you would prefer to pick and choose the\n"
- "list of distributions yourself, simply select \"Custom\". You can also\n"
- "pick a canned distribution set and then fine-tune it with the Custom item.\n\n"
- "Choose an item by pressing [SPACE]. When you are finished, choose the Exit\n"
- "item or press [ENTER].",
- "Press F1 for more information on these options.",
- "distributions",
- { { "X Exit", "Exit this menu (returning to previous)",
- checkTrue, dmenuExit, NULL, NULL, '<', '<', '<' },
- { "All", "All system sources, binaries and X Window System)",
- checkDistEverything, distSetEverything, NULL, NULL, ' ', ' ', ' ' },
- { "Reset", "Reset selected distribution list to nothing",
- NULL, distReset, NULL, NULL, ' ', ' ', ' ' },
- { "4 Developer", "Full sources, binaries and doc but no games",
- checkDistDeveloper, distSetDeveloper },
- { "5 X-Developer", "Same as above + X Window System",
- checkDistXDeveloper, distSetXDeveloper },
- { "6 Kern-Developer", "Full binaries and doc, kernel sources only",
- checkDistKernDeveloper, distSetKernDeveloper },
- { "7 X-Kern-Developer", "Same as above + X Window System",
- checkDistXKernDeveloper, distSetXKernDeveloper },
- { "8 User", "Average user - binaries and doc only",
- checkDistUser, distSetUser },
- { "9 X-User", "Same as above + X Window System",
- checkDistXUser, distSetXUser },
- { "A Minimal", "The smallest configuration possible",
- checkDistMinimum, distSetMinimum },
- { "B Custom", "Specify your own distribution set",
- NULL, dmenuSubmenu, NULL, &MenuSubDistributions, '>', '>', '>' },
- { NULL } },
-};
-
-DMenu MenuSubDistributions = {
- DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS,
- "Select the distributions you wish to install.",
- "Please check off the distributions you wish to install. At the\n"
- "very minimum, this should be \"bin\". WARNING: Do not export the\n"
- "Encryption distribution out of the U.S.!\n"
- "It is for U.S. customers only.",
- NULL,
- NULL,
- { { "X Exit", "Exit this menu (returning to previous)",
- checkTrue, dmenuExit, NULL, NULL, '<', '<', '<' },
- { "All", "All system sources, binaries and X Window System",
- NULL, distSetEverything, NULL, NULL, ' ', ' ', ' ' },
- { "Reset", "Reset all of the below",
- NULL, distReset, NULL, NULL, ' ', ' ', ' ' },
- { " bin", "Binary base distribution (required)",
- dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_BIN },
-#ifdef __i386__
- { " compat1x", "FreeBSD 1.x binary compatibility",
- dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_COMPAT1X },
- { " compat20", "FreeBSD 2.0 binary compatibility",
- dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_COMPAT20 },
- { " compat21", "FreeBSD 2.1 binary compatibility",
- dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_COMPAT21 },
- { " compat22", "FreeBSD 2.2.x and 3.0 a.out binary compatibility",
- dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_COMPAT22 },
-#if __FreeBSD__ > 3
- { " compat3x", "FreeBSD 3.x binary compatibility",
- dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_COMPAT3X },
-#endif
-#endif
- { " CRYPTO", "Encryption code - NOT FOR EXPORT!",
- CRYPTOFlagCheck,distSetCRYPTO },
- { " dict", "Spelling checker dictionary files",
- dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_DICT },
- { " doc", "Miscellaneous FreeBSD online docs",
- dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_DOC },
- { " games", "Games (non-commercial)",
- dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_GAMES },
- { " info", "GNU info files",
- dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_INFO },
- { " man", "System manual pages - recommended",
- dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_MANPAGES },
- { " catman", "Preformatted system manual pages",
- dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_CATPAGES },
- { " proflibs", "Profiled versions of the libraries",
- dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_PROFLIBS },
- { " src", "Sources for everything but encryption",
- srcFlagCheck, distSetSrc },
- { " ports", "The FreeBSD Ports collection",
- dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_PORTS },
- { " local", "Local additions collection",
- dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_LOCAL},
- { " XFree86", "The XFree86 3.3.6 distribution",
-#ifdef X_AS_PKG
- dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_XF86 },
-#else
- x11FlagCheck, distSetXF86 },
-#endif
- { NULL } },
-};
-
-DMenu MenuCRYPTODistributions = {
- DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS,
- "Select the encryption facilities you wish to install.",
- "Please check off any special encryption distributions\n"
- "you would like to install. Please note that these services are NOT FOR\n"
- "EXPORT from the United States. For information on non-U.S. FTP\n"
- "distributions of this software, please consult the release notes.",
- NULL,
- NULL,
- { { "X Exit", "Exit this menu (returning to previous)",
- checkTrue, dmenuExit, NULL, NULL, '<', '<', '<' },
- { "All", "Select all of the below",
- NULL, setCRYPTO, NULL, NULL, ' ', ' ', ' ' },
- { "Reset", "Reset all of the below",
- NULL, clearCRYPTO, NULL, NULL, ' ', ' ', ' ' },
- { " crypto", "Basic encryption services",
- dmenuFlagCheck, dmenuSetFlag, NULL, &CRYPTODists, '[', 'X', ']', DIST_CRYPTO_CRYPTO, },
-#if __FreeBSD__ <= 3
- { " krb", "KerberosIV authentication services",
- dmenuFlagCheck, dmenuSetFlag, NULL, &CRYPTODists, '[', 'X', ']', DIST_CRYPTO_KERBEROS },
-#else
- { " krb4", "KerberosIV authentication services",
- dmenuFlagCheck, dmenuSetFlag, NULL, &CRYPTODists, '[', 'X', ']', DIST_CRYPTO_KERBEROS4 },
- { " krb5", "Kerberos5 authentication services",
- dmenuFlagCheck, dmenuSetFlag, NULL, &CRYPTODists, '[', 'X', ']', DIST_CRYPTO_KERBEROS5 },
-#endif
- { " skrb4", "Sources for KerberosIV",
- dmenuFlagCheck, dmenuSetFlag, NULL, &CRYPTODists, '[', 'X', ']', DIST_CRYPTO_SKERBEROS4 },
- { " skrb5", "Sources for Kerberos5",
- dmenuFlagCheck, dmenuSetFlag, NULL, &CRYPTODists, '[', 'X', ']', DIST_CRYPTO_SKERBEROS5 },
- { " ssecure", "BSD encryption sources",
- dmenuFlagCheck, dmenuSetFlag, NULL, &CRYPTODists, '[', 'X', ']', DIST_CRYPTO_SSECURE },
- { " scrypto", "Contributed encryption sources",
- dmenuFlagCheck, dmenuSetFlag, NULL, &CRYPTODists, '[', 'X', ']', DIST_CRYPTO_SCRYPTO },
- { NULL } },
-};
-
-DMenu MenuSrcDistributions = {
- DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS,
- "Select the sub-components of src you wish to install.",
- "Please check off those portions of the FreeBSD source tree\n"
- "you wish to install (remember to use SPACE, not ENTER!).",
- NULL,
- NULL,
- { { "X Exit", "Exit this menu (returning to previous)",
- checkTrue, dmenuExit, NULL, NULL, '<', '<', '<' },
- { "All", "Select all of the below",
- NULL, setSrc, NULL, NULL, ' ', ' ', ' ' },
- { "Reset", "Reset all of the below",
- NULL, clearSrc, NULL, NULL, ' ', ' ', ' ' },
- { " base", "top-level files in /usr/src",
- dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_BASE },
- { " contrib", "/usr/src/contrib (contributed software)",
- dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_CONTRIB },
- { " gnu", "/usr/src/gnu (software from the GNU Project)",
- dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_GNU },
- { " etc", "/usr/src/etc (miscellaneous system files)",
- dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_ETC },
- { " games", "/usr/src/games (the obvious!)",
- dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_GAMES },
- { " include", "/usr/src/include (header files)",
- dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_INCLUDE },
- { " lib", "/usr/src/lib (system libraries)",
- dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_LIB },
- { " libexec", "/usr/src/libexec (system programs)",
- dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_LIBEXEC },
- { " release", "/usr/src/release (release-generation tools)",
- dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_RELEASE },
- { " bin", "/usr/src/bin (system binaries)",
- dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_BIN },
- { " sbin", "/usr/src/sbin (system binaries)",
- dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_SBIN },
- { " share", "/usr/src/share (documents and shared files)",
- dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_SHARE },
- { " sys", "/usr/src/sys (FreeBSD kernel)",
- dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_SYS },
- { " tools", "/usr/src/tools (miscellaneous tools)",
- dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_TOOLS },
- { " ubin", "/usr/src/usr.bin (user binaries)",
- dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_UBIN },
- { " usbin", "/usr/src/usr.sbin (aux system binaries)",
- dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_USBIN },
- { NULL } },
-};
-
-DMenu MenuXF86Select = {
- DMENU_NORMAL_TYPE,
- "XFree86 3.3.6 Distribution",
- "Please select the components you need from the XFree86 3.3.6\n"
- "distribution sets.",
- NULL,
- NULL,
- { { "X Exit", "Exit this menu (returning to previous)", NULL, dmenuExit },
- { "Basic", "Basic component menu (required)", NULL, dmenuSubmenu, NULL, &MenuXF86SelectCore },
- { "Server", "X server menu", NULL, dmenuSubmenu, NULL, &MenuXF86SelectServer },
- { "Fonts", "Font set menu", NULL, dmenuSubmenu, NULL, &MenuXF86SelectFonts },
- { NULL } },
-};
-
-DMenu MenuXF86SelectCore = {
- DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS,
- "XFree86 3.3.6 base distribution types",
- "Please check off the basic XFree86 components you wish to install.\n"
- "Bin, lib, and set are recommended for a minimum installaion.",
- NULL,
- NULL,
- { { "X Exit", "Exit this menu (returning to previous)",
- checkTrue, dmenuExit, NULL, NULL, '<', '<', '<' },
- { "All", "Select all below",
- NULL, setX11Misc, NULL, NULL, ' ', ' ', ' ' },
- { "Reset", "Reset all below",
- NULL, clearX11Misc, NULL, NULL, ' ', ' ', ' ' },
- { " bin", "Client applications and shared libs",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_BIN },
- { " cfg", "Configuration files",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_CFG },
- { " doc", "READMEs and release notes",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_DOC },
- { " html", "HTML documentation files",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_HTML },
- { " lib", "Data files needed at runtime",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_LIB },
- { " lkit", "Server link kit for all other machines",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_LKIT },
- { " man", "Manual pages",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_MAN },
- { " prog", "Programmer's header and library files",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_PROG },
- { " set", "XFree86 Setup Utility",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_SET },
-#ifdef __i386__
- { " 9set", "XFree86 Setup Utility for PC98 machines",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_9SET },
- { " lk98", "Server link kit for PC98 machines",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_LKIT98 },
-#endif
- { NULL } },
-};
-
-DMenu MenuXF86SelectFonts = {
- DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS,
- "Font distribution selection.",
- "Please check off the individual font distributions you wish to\n\
-install. At the minimum, you should install the standard\n\
-75 DPI and misc fonts if you're also installing a server\n\
-(these are selected by default).",
- NULL,
- NULL,
- { { "X Exit", "Exit this menu (returning to previous)",
- checkTrue, dmenuExit, NULL, NULL, '<', '<', '<' },
- { "All", "All fonts",
- NULL, setX11Fonts, NULL, NULL, ' ', ' ', ' ' },
- { "Reset", "Reset font selections",
- NULL, clearX11Fonts, NULL, NULL, ' ', ' ', ' ' },
- { " fnts", "Standard 75 DPI and miscellaneous fonts",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86FontDists, '[', 'X', ']', DIST_XF86_FONTS_MISC },
- { " f100", "100 DPI fonts",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86FontDists, '[', 'X', ']', DIST_XF86_FONTS_100 },
- { " fcyr", "Cyrillic Fonts",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86FontDists, '[', 'X', ']', DIST_XF86_FONTS_CYR },
- { " fscl", "Speedo and Type scalable fonts",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86FontDists, '[', 'X', ']', DIST_XF86_FONTS_SCALE },
- { " non", "Japanese, Chinese and other non-english fonts",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86FontDists, '[', 'X', ']', DIST_XF86_FONTS_NON },
- { " server", "Font server",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86FontDists, '[', 'X', ']', DIST_XF86_FONTS_SERVER },
- { NULL } },
-};
-
-DMenu MenuXF86SelectServer = {
- DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS,
- "X Server selection.",
- "Please check off the types of X servers you wish to install.\n"
- "If you are unsure as to which server will work for your graphics card,\n"
- "it is recommended that try the SVGA or VGA16 servers or, for PC98\n"
- "machines, the 9EGC or 9840 servers.",
- NULL,
- NULL,
- { { "X Exit", "Exit this menu (returning to previous)",
- checkTrue, dmenuExit, NULL, NULL, '<', '<', '<' },
- { "All", "Select all of the above",
- NULL, setX11Servers, NULL, NULL, ' ', ' ', ' ' },
- { "Reset", "Reset all of the above",
- NULL, clearX11Servers, NULL, NULL, ' ', ' ', ' ' },
- { " SVGA", "Standard VGA or Super VGA card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_SVGA },
- { " VGA16", "Standard 16 color VGA card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_VGA16 },
- { " Mono", "Standard Monochrome card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_MONO },
- { " 3DL", "8, 16 and 24 bit color 3D Labs boards",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_3DL },
- { " 8514", "8-bit (256 color) IBM 8514 or compatible card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_8514 },
- { " AGX", "8-bit AGX card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_AGX },
- { " I128", "8, 16 and 24-bit #9 Imagine I128 card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_I128 },
- { " Ma8", "8-bit ATI Mach8 card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_MACH8 },
- { " Ma32", "8 and 16-bit (65K color) ATI Mach32 card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_MACH32 },
- { " Ma64", "8 and 16-bit (65K color) ATI Mach64 card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_MACH64 },
- { " P9K", "8, 16, and 24-bit color Weitek P9000 based boards",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_P9000 },
- { " S3", "8, 16 and 24-bit color S3 based boards",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_S3 },
- { " S3V", "8, 16 and 24-bit color S3 Virge based boards",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_S3V },
- { " W32", "8-bit ET4000/W32, /W32i and /W32p cards",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_W32 },
-#ifdef __i386__
- { " PC98", "Select an X server for a NEC PC98 [Submenu]",
- NULL, dmenuSubmenu, NULL, &MenuXF86SelectPC98Server, '>', ' ', '>', 0 },
-#elif __alpha__
- { " TGA", "TGA cards (alpha architecture only)",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_TGA },
-#endif
- { NULL } },
-};
-
-#ifdef __i386__
-DMenu MenuXF86SelectPC98Server = {
- DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS,
- "PC98 X Server selection.",
- "Please check off the types of NEC PC98 X servers you wish to install.\n\
-If you are unsure as to which server will work for your graphics card,\n\
-it is recommended that try the SVGA or VGA16 servers (the VGA16 and\n\
-Mono servers are particularly well-suited to most LCD displays).",
- NULL,
- NULL,
- { { " 9480", "PC98 8-bit (256 color) PEGC-480 card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9480 },
- { " 9EGC", "PC98 4-bit (16 color) EGC card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9EGC },
- { " 9GA9", "PC98 GA-968V4/PCI (S3 968) card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9GA9 },
- { " 9GAN", "PC98 GANB-WAP (cirrus) card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9GAN },
- { " 9LPW", "PC98 PowerWindowLB (S3) card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9LPW },
- { " 9MGA", "PC98 MGA (Matrox) card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9MGA },
- { " 9NKV", "PC98 NKV-NEC (cirrus) card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9NKV },
- { " 9NS3", "PC98 NEC (S3) card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9NS3 },
- { " 9SPW", "PC98 SKB-PowerWindow (S3) card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9SPW },
- { " 9SVG", "PC98 generic SVGA card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9SVG },
- { " 9TGU", "PC98 Cyber9320 and TGUI9680 cards",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9TGU },
- { " 9WEP", "PC98 WAB-EP (cirrus) card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9WEP },
- { " 9WS", "PC98 WABS (cirrus) card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9WS },
- { " 9WSN", "PC98 WSN-A2F (cirrus) card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9WSN },
- { NULL } }
-};
-#endif
-
-DMenu MenuDiskDevices = {
- DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS,
- "Select Drive(s)",
- "Please select the drive, or drives, on which you wish to perform\n"
- "this operation. If you are attempting to install a boot partition\n"
- "on a drive other than the first one or have multiple operating\n"
- "systems on your machine, you will have the option to install a boot\n"
- "manager later. To select a drive, use the arrow keys to move to it\n"
- "and press [SPACE]. To de-select it, press [SPACE] again.\n\n"
- "Select OK or Cancel to leave this menu.",
- "Press F1 for important information regarding disk geometry!",
- "drives",
- { { NULL } },
-};
-
-DMenu MenuHTMLDoc = {
- DMENU_NORMAL_TYPE,
- "Select HTML Documentation pointer",
- "Please select the body of documentation you're interested in, the main\n"
- "ones right now being the FAQ and the Handbook. You can also choose \"other\"\n"
- "to enter an arbitrary URL for browsing.",
- "Press F1 for more help on what you see here.",
- "html",
- { { "X Exit", "Exit this menu (returning to previous)", NULL, dmenuExit },
- { "2 Handbook", "The FreeBSD Handbook.", NULL, docShowDocument },
- { "3 FAQ", "The Frequently Asked Questions guide.", NULL, docShowDocument },
- { "4 Home", "The Home Pages for the FreeBSD Project (requires net)", NULL, docShowDocument },
- { "5 Other", "Enter a URL.", NULL, docShowDocument },
- { NULL } },
-};
-
-/* The main installation menu */
-DMenu MenuInstallCustom = {
- DMENU_NORMAL_TYPE,
- "Choose Custom Installation Options",
- "This is the custom installation menu. You may use this menu to specify\n"
- "details on the type of distribution you wish to have, where you wish\n"
- "to install it from and how you wish to allocate disk storage to FreeBSD.",
- "Press F1 to read the installation guide",
- "install",
- { { "X Exit", "Exit this menu (returning to previous)", NULL, dmenuExit },
- { "2 Options", "View/Set various installation options", NULL, optionsEditor },
-#ifdef __alpha__
- { "3 Label", "Label disk partitions", NULL, diskLabelEditor },
- { "4 Distributions", "Select distribution(s) to extract", NULL, dmenuSubmenu, NULL, &MenuDistributions },
- { "5 Media", "Choose the installation media type", NULL, dmenuSubmenu, NULL, &MenuMedia },
- { "6 Commit", "Perform any pending Partition/Label/Extract actions", NULL, installCustomCommit },
-#else
- { "3 Partition", "Allocate disk space for FreeBSD", NULL, diskPartitionEditor },
- { "4 Label", "Label allocated disk partitions", NULL, diskLabelEditor },
- { "5 Distributions", "Select distribution(s) to extract", NULL, dmenuSubmenu, NULL, &MenuDistributions },
- { "6 Media", "Choose the installation media type", NULL, dmenuSubmenu, NULL, &MenuMedia },
- { "7 Commit", "Perform any pending Partition/Label/Extract actions", NULL, installCustomCommit },
-#endif
- { NULL } },
-};
-
-/* MBR type menu */
-DMenu MenuMBRType = {
- DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS,
- "overwrite me", /* will be disk specific label */
- "FreeBSD comes with a boot selector that allows you to easily\n"
- "select between FreeBSD and any other operating systems on your machine\n"
- "at boot time. If you have more than one drive and want to boot\n"
- "from the second one, the boot selector will also make it possible\n"
- "to do so (limitations in the PC BIOS usually prevent this otherwise).\n"
- "If you do not want a boot selector, or wish to replace an existing\n"
- "one, select \"standard\". If you would prefer your Master Boot\n"
- "Record to remain untouched then select \"None\".\n\n"
- " NOTE: PC-DOS users will almost certainly require \"None\"!",
- "Press F1 to read about drive setup",
- "drives",
- { { "BootMgr", "Install the FreeBSD Boot Manager",
- dmenuRadioCheck, dmenuSetValue, NULL, &BootMgr },
- { "Standard", "Install a standard MBR (no boot manager)",
- dmenuRadioCheck, dmenuSetValue, NULL, &BootMgr, '(', '*', ')', 1 },
- { "None", "Leave the Master Boot Record untouched",
- dmenuRadioCheck, dmenuSetValue, NULL, &BootMgr, '(', '*', ')', 2 },
- { NULL } },
-};
-
-/* Final configuration menu */
-DMenu MenuConfigure = {
- DMENU_NORMAL_TYPE,
- "FreeBSD Configuration Menu", /* title */
- "If you've already installed FreeBSD, you may use this menu to customize\n"
- "it somewhat to suit your particular configuration. Most importantly,\n"
- "you can use the Packages utility to load extra \"3rd party\"\n"
- "software not provided in the base distributions.",
- "Press F1 for more information on these options",
- "configure",
- { { "X Exit", "Exit this menu (returning to previous)",
- NULL, dmenuExit },
- { " Distributions", "Install additional distribution sets",
- NULL, distExtractAll },
- { " Packages", "Install pre-packaged software for FreeBSD",
- NULL, configPackages },
- { " Root Password", "Set the system manager's password",
- NULL, dmenuSystemCommand, NULL, "passwd root" },
-#ifdef __i386__
- { " Fdisk", "The disk Slice (PC-style partition) Editor",
- NULL, diskPartitionEditor },
-#endif
- { " Label", "The disk Label editor",
- NULL, diskLabelEditor },
- { " User Management", "Add user and group information",
- NULL, dmenuSubmenu, NULL, &MenuUsermgmt },
- { " Console", "Customize system console behavior",
- NULL, dmenuSubmenu, NULL, &MenuSyscons },
- { " Time Zone", "Set which time zone you're in",
- NULL, dmenuSystemCommand, NULL, "tzsetup" },
- { " Media", "Change the installation media type",
- NULL, dmenuSubmenu, NULL, &MenuMedia },
- { " Mouse", "Configure your mouse",
- NULL, dmenuSubmenu, NULL, &MenuMouse, NULL },
- { " Networking", "Configure additional network services",
- NULL, dmenuSubmenu, NULL, &MenuNetworking },
- { " Startup", "Configure system startup options",
- NULL, dmenuSubmenu, NULL, &MenuStartup },
- { " Options", "View/Set various installation options",
- NULL, optionsEditor },
- { " XFree86", "Configure XFree86 Server",
- NULL, configXSetup },
- { " Desktop", "Configure XFree86 Desktop",
- NULL, configXDesktop },
- { " HTML Docs", "Go to the HTML documentation menu (post-install)",
- NULL, docBrowser },
- { NULL } },
-};
-
-DMenu MenuStartup = {
- DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS,
- "Startup Services Menu",
- "This menu allows you to configure various aspects of your system's\n"
- "startup configuration. Remember to use SPACE to select items! The\n"
- "RETURN key will leave this menu (as with all checkbox menus).",
- NULL,
- NULL,
- { { "X Exit", "Exit this menu (returning to previous)",
- checkTrue, dmenuExit, NULL, NULL, '<', '<', '<' },
- { " APM", "Auto-power management services (typically laptops)",
- dmenuVarCheck, dmenuToggleVariable, NULL, "apm_enable=YES" },
- { " pccard", "Enable PCCARD (AKA PCMCIA) services (also laptops)",
- dmenuVarCheck, dmenuToggleVariable, NULL, "pccard_enable=YES" },
- { " pccard mem", "Set PCCARD memory address (if enabled)",
- dmenuVarCheck, dmenuISetVariable, NULL, "pccard_mem" },
- { " pccard ifconfig", "List of PCCARD ethernet devices to configure",
- dmenuVarCheck, dmenuISetVariable, NULL, "pccard_ifconfig" },
- { " ", " -- ", NULL, NULL, NULL, NULL, ' ', ' ', ' ' },
- { " startup dirs", "Set the list of dirs to look for startup scripts",
- dmenuVarCheck, dmenuISetVariable, NULL, "local_startup" },
- { " named", "Run a local name server on this host",
- dmenuVarCheck, dmenuToggleVariable, NULL, "named_enable=YES" },
- { " named flags", "Set default flags to named (if enabled)",
- dmenuVarCheck, dmenuISetVariable, NULL, "named_flags" },
- { " nis client", "This host wishes to be an NIS client.",
- dmenuVarCheck, dmenuToggleVariable, NULL, "nis_client_enable=YES" },
- { " nis domainname", "Set NIS domainname (if enabled)",
- dmenuVarCheck, dmenuISetVariable, NULL, "nisdomainname" },
- { " nis server", "This host wishes to be an NIS server.",
- dmenuVarCheck, dmenuToggleVariable, NULL, "nis_server_enable=YES" },
- { " ", " -- ", NULL, NULL, NULL, NULL, ' ', ' ', ' ' },
- { " accounting", "This host wishes to run process accounting.",
- dmenuVarCheck, dmenuToggleVariable, NULL, "accounting_enable=YES" },
- { " lpd", "This host has a printer and wants to run lpd.",
- dmenuVarCheck, dmenuToggleVariable, NULL, "lpd_enable=YES" },
-#ifdef __i386__
- { " linux", "This host wants to be able to run linux binaries.",
- dmenuVarCheck, configLinux, NULL, VAR_LINUX_ENABLE "=YES" },
- { " SVR4", "This host wants to be able to run SVR4 binaries.",
- dmenuVarCheck, dmenuToggleVariable, NULL, "svr4_enable=YES" },
- { " SCO", "This host wants to be able to run IBCS2 binaries.",
- dmenuVarCheck, dmenuToggleVariable, NULL, "ibcs2_enable=YES" },
-#elif __alpha__
- { " OSF/1", "This host wants to be able to run DEC OSF/1 binaries.",
- dmenuVarCheck, dmenuToggleVariable, NULL, "osf1_enable=YES" },
-#endif
- { " quotas", "This host wishes to check quotas on startup.",
- dmenuVarCheck, dmenuToggleVariable, NULL, "check_quotas=YES" },
- { NULL } },
-};
-
-DMenu MenuNetworking = {
- DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS,
- "Network Services Menu",
- "You may have already configured one network device (and the other\n"
- "various hostname/gateway/name server parameters) in the process\n"
- "of installing FreeBSD. This menu allows you to configure other\n"
- "aspects of your system's network configuration.",
- NULL,
- NULL,
- { { "X Exit", "Exit this menu (returning to previous)",
- checkTrue, dmenuExit, NULL, NULL, '<', '<', '<' },
- { " Interfaces", "Configure additional network interfaces",
- NULL, tcpMenuSelect },
- { " AMD", "This machine wants to run the auto-mounter service",
- dmenuVarCheck, dmenuToggleVariable, NULL, "amd_enable=YES" },
- { " AMD Flags", "Set flags to AMD service (if enabled)",
- dmenuVarCheck, dmenuISetVariable, NULL, "amd_flags" },
- { " Anon FTP", "This machine wishes to allow anonymous FTP.",
- dmenuVarCheck, configAnonFTP, NULL, "anon_ftp" },
- { " Gateway", "This machine will route packets between interfaces",
- dmenuVarCheck, dmenuToggleVariable, NULL, "gateway_enable=YES" },
- { " NFS client", "This machine will be an NFS client",
- dmenuVarCheck, dmenuToggleVariable, NULL, "nfs_client_enable=YES" },
- { " NFS server", "This machine will be an NFS server",
- dmenuVarCheck, configNFSServer, NULL, "nfs_server_enable=YES" },
- { " Ntpdate", "Select a clock-synchronization server",
- dmenuVarCheck, dmenuSubmenu, NULL, &MenuNTP, '[', 'X', ']', "ntpdate_enable=YES" },
- { " PCNFSD", "Run authentication server for clients with PC-NFS.",
- dmenuVarCheck, configPCNFSD, NULL, "pcnfsd" },
- { " Routed", "Select routing daemon (default: routed)",
- dmenuVarCheck, configRouter, NULL, "router_enable=YES" },
- { " Rwhod", "This machine wants to run the rwho daemon",
- dmenuVarCheck, dmenuToggleVariable, NULL, "rwhod_enable=YES" },
- { " Sendmail", "This machine wants to run the sendmail daemon",
- dmenuVarCheck, dmenuToggleVariable, NULL, "sendmail_enable=YES" },
- { " Sshd", "This machine wants to run the ssh daemon",
- dmenuVarCheck, dmenuToggleVariable, NULL, "sshd_enable=YES" },
- { " TCP Extensions", "Allow RFC1323 and RFC1644 TCP extensions?",
- dmenuVarCheck, dmenuToggleVariable, NULL, "tcp_extensions=YES" },
- { NULL } },
-};
-
-DMenu MenuNTP = {
- DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS,
- "NTPDATE Server Selection",
- "There are a number of time synchronization servers available\n"
- "for public use around the Internet. Please select one reasonably\n"
- "close to you to have your system time synchronized accordingly.",
- "These are the primary open-access NTP servers",
- NULL,
- { { "None", "No ntp server",
- dmenuVarsCheck, dmenuSetVariables, NULL,
- "ntpdate_enable=NO,ntpdate_flags=none" },
- { "Other", "Select a site not on this list",
- dmenuVarsCheck, configNTP, NULL, NULL },
- { "Australia", "ntp.syd.dms.csiro.au (HP 5061 Cesium Beam)",
- dmenuVarsCheck, dmenuSetVariables, NULL,
- "ntpdate_enable=YES,ntpdate_flags=ntp.syd.dms.csiro.au" },
- { " Canada", "tick.usask.ca (GOES clock)",
- dmenuVarsCheck, dmenuSetVariables, NULL,
- "ntpdate_enable=YES,ntpdate_flags=tick.usask.ca" },
- { "France", "canon.inria.fr (TDF clock)",
- dmenuVarsCheck, dmenuSetVariables, NULL,
- "ntpdate_enable=YES,ntpdate_flags=canon.inria.fr" },
- { "Germany", "ntps1-{0,1,2}.uni-erlangen.de (GPS)",
- dmenuVarsCheck, dmenuSetVariables, NULL,
- "ntpdate_enable=YES,ntpdate_flags=ntps1-0.uni-erlangen.de" },
- { " Germany #2", "ntps1-0.cs.tu-berlin.de (GPS)",
- dmenuVarsCheck, dmenuSetVariables, NULL,
- "ntpdate_enable=YES,ntpdate_flags=ntps1-0.cs.tu-berlin.de" },
- { "Japan", "clock.nc.fukuoka-u.ac.jp (GPS clock)",
- dmenuVarsCheck, dmenuSetVariables, NULL,
- "ntpdate_enable=YES,ntpdate_flags=clock.nc.fukuoka-u.ac.jp" },
- { " Japan #2", "clock.tl.fukuoka-u.ac.jp (GPS clock)",
- dmenuVarsCheck, dmenuSetVariables, NULL,
- "ntpdate_enable=YES,ntpdate_flags=clock.tl.fukuoka-u.ac.jp" },
- { "Netherlands", "ntp0.nl.net (GPS clock)",
- dmenuVarsCheck, dmenuSetVariables, NULL,
- "ntpdate_enable=YES,ntpdate_flags=ntp0.nl.net" },
- { " Norway", "timehost.ifi.uio.no (NTP clock)",
- dmenuVarsCheck, dmenuSetVariables, NULL,
- "ntpdate_enable=YES,ntpdate_flags=timehost.ifi.uio.no" },
- { "Sweden", "Time1.Stupi.SE (Cesium/GPS)",
- dmenuVarsCheck, dmenuSetVariables, NULL,
- "ntpdate_enable=YES,ntpdate_flags=Time1.Stupi.SE" },
- { " Switzerland", "swisstime.ethz.ch (DCF77 clock)",
- dmenuVarsCheck, dmenuSetVariables, NULL,
- "ntpdate_enable=YES,ntpdate_flags=swisstime.ethz.ch" },
- { "U.S. East Coast", "bitsy.mit.edu (WWV clock)",
- dmenuVarsCheck, dmenuSetVariables, NULL,
- "ntpdate_enable=YES,ntpdate_flags=bitsy.mit.edu" },
- { " U.S. East Coast #2", "otc1.psu.edu (WWV clock)",
- dmenuVarsCheck, dmenuSetVariables, NULL,
- "ntpdate_enable=YES,ntpdate_flags=otc1.psu.edu" },
- { " U.S. West Coast #1", "clepsydra.dec.com (GOES clock)",
- dmenuVarsCheck, dmenuSetVariables, NULL,
- "ntpdate_enable=YES,ntpdate_flags=clepsydra.dec.com" },
- { " U.S. West Coast #2", "clock.llnl.gov (WWVB clock)",
- dmenuVarsCheck, dmenuSetVariables, NULL,
- "ntpdate_enable=YES,ntpdate_flags=clock.llnl.gov" },
- { " U.S. Midwest", "ncar.ucar.edu (WWVB clock)",
- dmenuVarsCheck, dmenuSetVariables, NULL,
- "ntpdate_enable=YES,ntpdate_flags=ncar.ucar.edu" },
- { NULL } },
-};
-
-DMenu MenuSyscons = {
- DMENU_NORMAL_TYPE,
- "System Console Configuration",
- "The default system console driver for FreeBSD (syscons) has a\n"
- "number of configuration options which may be set according to\n"
- "your preference.\n\n"
- "When you are done setting configuration options, select Cancel.",
- "Configure your system console settings",
- NULL,
- { { "X Exit", "Exit this menu (returning to previous)", NULL, dmenuExit },
- { "2 Font", "Choose an alternate screen font", NULL, dmenuSubmenu, NULL, &MenuSysconsFont },
- { "3 Keymap", "Choose an alternate keyboard map", NULL, dmenuSubmenu, NULL, &MenuSysconsKeymap },
- { "4 Repeat", "Set the rate at which keys repeat", NULL, dmenuSubmenu, NULL, &MenuSysconsKeyrate },
- { "5 Saver", "Configure the screen saver", NULL, dmenuSubmenu, NULL, &MenuSysconsSaver },
- { "6 Screenmap", "Choose an alternate screenmap", NULL, dmenuSubmenu, NULL, &MenuSysconsScrnmap },
- { NULL } },
-};
-
-DMenu MenuSysconsKeymap = {
- DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS,
- "System Console Keymap",
- "The default system console driver for FreeBSD (syscons) defaults\n"
- "to a standard \"American\" keyboard map. Users in other countries\n"
- "(or with different keyboard preferences) may wish to choose one of\n"
- "the other keymaps below.\n"
- "Note that sysinstall itself only uses the part of the keyboard map\n"
- "which is required to generate the ANSI character subset, but your\n"
- "choice of keymap will also be saved for later (fuller) use.",
- "Choose a keyboard map",
- NULL,
- { { "Belgian", "Belgian ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=be.iso" },
- { " Brazil CP850", "Brazil CP850 keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=br275.cp850" },
- { " Brazil ISO (accent)", "Brazil ISO keymap (accent keys)", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=br275.iso.acc" },
- { " Brazil ISO", "Brazil ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=br275.iso" },
- { " Croatian ISO", "Croatian ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=hr.iso" },
- { "Danish CP865", "Danish Code Page 865 keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=danish.cp865" },
- { " Danish ISO", "Danish ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=danish.iso" },
- { "Estonian ISO", "Estonian ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=estonian.iso" },
- { " Estonian ISO 15", "Estonian ISO 8859-15 keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=estonian.iso15" },
- { " Estonian CP850", "Estonian Code Page 850 keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=estonian.cp850" },
- { " Finnish CP850","Finnish Code Page 850 keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=finnish.cp850" },
- { " Finnish ISO", "Finnish ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=finnish.iso" },
- { " French ISO (accent)", "French ISO keymap (accent keys)", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=fr.iso.acc" },
- { " French ISO", "French ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=fr.iso" },
- { "German CP850", "German Code Page 850 keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=german.cp850" },
- { " German ISO", "German ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=german.iso" },
- { "Hungarian 101", "Hungarian ISO keymap (101 key)", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=hu.iso2.101keys" },
- { " Hungarian 102", "Hungarian ISO keymap (102 key)", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=hu.iso2.102keys" },
- { "Icelandic (accent)", "Icelandic ISO keymap (accent keys)", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=icelandic.iso.acc" },
- { " Icelandic", "Icelandic ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=icelandic.iso" },
- { " Italian", "Italian ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=it.iso" },
- { "Latin American", "Latin American ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=lat-amer" },
- { "Japanese 106", "Japanese 106 keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=jp.106" },
- { "Norway ISO", "Norwegian ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=norwegian.iso" },
- { "Polish ISO", "Polish ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=pl_PL.ISO_8859-2" },
- { " Portuguese (accent)", "Portuguese ISO keymap (accent keys)", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=pt.iso.acc" },
- { " Portuguese", "Portuguese ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=pt.iso" },
- { "Russia CP866", "Russian CP866 keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=ru.cp866" },
- { " Russia KOI8-R", "Russian KOI8-R keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=ru.koi8-r" },
- { "Slovenian", "Slovenian ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=si.iso" },
- { " Spanish (accent)", "Spanish ISO keymap (accent keys)", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=spanish.iso.acc" },
- { " Spanish", "Spanish ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=spanish.iso" },
- { " Swedish CP850", "Swedish Code Page 850 keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=swedish.cp850" },
- { " Swedish ISO", "Swedish ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=swedish.iso" },
- { " Swiss French ISO (accent)", "Swiss French ISO keymap (accent keys)", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=swissfrench.iso.acc" },
- { " Swiss French ISO", "Swiss French ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=swissfrench.iso" },
- { " Swiss French CP850", "Swiss French Code Page 850 keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=swissfrench.cp850" },
- { " Swiss German ISO (accent)", "Swiss German ISO keymap (accent keys)", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=swissgerman.iso.acc" },
- { " Swiss German ISO", "Swiss German ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=swissgerman.iso" },
- { " Swiss German CP850", "Swiss German Code Page 850 keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=swissgerman.cp850" },
- { "U.K. CP850", "United Kingdom Code Page 850 keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=uk.cp850" },
- { " U.K. ISO", "United Kingdom ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=uk.iso" },
- { " U.S. Dvorak", "United States Dvorak keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=us.dvorak" },
- { " U.S. ISO", "United States ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=us.iso" },
- { NULL } },
-};
-
-DMenu MenuSysconsKeyrate = {
- DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS,
- "System Console Keyboard Repeat Rate",
- "This menu allows you to set the speed at which keys repeat\n"
- "when held down.",
- "Choose a keyboard repeat rate",
- NULL,
- { { "Slow", "Slow keyboard repeat rate", dmenuVarCheck, dmenuSetVariable, NULL, "keyrate=slow" },
- { "Normal", "\"Normal\" keyboard repeat rate", dmenuVarCheck, dmenuSetVariable, NULL, "keyrate=normal" },
- { "Fast", "Fast keyboard repeat rate", dmenuVarCheck, dmenuSetVariable, NULL, "keyrate=fast" },
- { "Default", "Use default keyboard repeat rate", dmenuVarCheck, dmenuSetVariable, NULL, "keyrate=NO" },
- { NULL } },
-};
-
-DMenu MenuSysconsSaver = {
- DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS,
- "System Console Screen Saver",
- "By default, the console driver will not attempt to do anything\n"
- "special with your screen when it's idle. If you expect to leave your\n"
- "monitor switched on and idle for long periods of time then you should\n"
- "probably enable one of these screen savers to prevent phosphor burn-in.",
- "Choose a nifty-looking screen saver",
- NULL,
- { { "1 Blank", "Simply blank the screen",
- dmenuVarCheck, configSaver, NULL, "saver=blank" },
- { "2 Daemon", "\"BSD Daemon\" animated screen saver (text)",
- dmenuVarCheck, configSaver, NULL, "saver=daemon" },
- { "3 Fade", "Fade out effect screen saver",
- dmenuVarCheck, configSaver, NULL, "saver=fade" },
- { "4 Fire", "Flames effect screen saver",
- dmenuVarCheck, configSaver, NULL, "saver=fire" },
- { "5 Green", "\"Green\" power saving mode (if supported by monitor)",
- dmenuVarCheck, configSaver, NULL, "saver=green" },
- { "6 Logo", "\"BSD Daemon\" animated screen saver (graphics)",
- dmenuVarCheck, configSaver, NULL, "saver=logo" },
- { "7 Rain", "Rain drops screen saver",
- dmenuVarCheck, configSaver, NULL, "saver=rain" },
- { "8 Snake", "Draw a FreeBSD \"snake\" on your screen",
- dmenuVarCheck, configSaver, NULL, "saver=snake" },
- { "9 Star", "A \"twinkling stars\" effect",
- dmenuVarCheck, configSaver, NULL, "saver=star" },
- { "Warp", "A \"stars warping\" effect",
- dmenuVarCheck, configSaver, NULL, "saver=warp" },
- { "Timeout", "Set the screen saver timeout interval",
- NULL, configSaverTimeout, NULL, NULL, ' ', ' ', ' ' },
- { NULL } },
-};
-
-DMenu MenuSysconsScrnmap = {
- DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS,
- "System Console Screenmap",
- "Unless you load a specific font, most PC hardware defaults to\n"
- "displaying characters in the IBM 437 character set. However,\n"
- "in the Unix world, this character set is very rarely used. Most\n"
- "Western European countries, for example, prefer ISO 8859-1.\n"
- "American users won't notice the difference since the bottom half\n"
- "of all these character sets is ANSI anyway.\n"
- "If your hardware is capable of downloading a new display font,\n"
- "you should probably choose that option. However, for hardware\n"
- "where this is not possible (e.g. monochrome adapters), a screen\n"
- "map will give you the best approximation that your hardware can\n"
- "display at all.",
- "Choose a screen map",
- NULL,
- { { "None", "No screenmap, use default font", dmenuVarCheck, dmenuSetVariable, NULL, "scrnmap=NO" },
- { "KOI8-R to IBM866", "Russian KOI8-R to IBM 866 screenmap", dmenuVarCheck, dmenuSetVariable, NULL, "scrnmap=koi8-r2cp866" },
- { "ISO 8859-1 to IBM437", "W-Europe ISO 8859-1 to IBM 437 screenmap", dmenuVarCheck, dmenuSetVariable, NULL, "scrnmap=iso-8859-1_to_cp437" },
- { NULL } },
-};
-
-DMenu MenuSysconsFont = {
- DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS,
- "System Console Font",
- "Most PC hardware defaults to displaying characters in the\n"
- "IBM 437 character set. However, in the Unix world, this\n"
- "character set is very rarely used. Most Western European\n"
- "countries, for example, prefer ISO 8859-1.\n"
- "American users won't notice the difference since the bottom half\n"
- "of all these charactersets is ANSI anyway. However, they might\n"
- "want to load a font anyway to use the 30- or 50-line displays.\n"
- "If your hardware is capable of downloading a new display font,\n"
- "you can select the appropriate font below.",
- "Choose a font",
- NULL,
- { { "1 None", "Use default font", dmenuVarCheck, dmenuSetVariables, NULL,
- "font8x8=NO,font8x14=NO,font8x16=NO" },
- { "2 IBM 437", "English", dmenuVarCheck, dmenuSetVariables, NULL,
- "font8x8=cp437-8x8,font8x14=cp437-8x14,font8x16=cp437-8x16" },
- { "3 IBM 850", "Western Europe, IBM encoding", dmenuVarCheck, dmenuSetVariables, NULL,
- "font8x8=cp850-8x8,font8x14=cp850-8x14,font8x16=cp850-8x16" },
- { "4 IBM 865", "Norwegian, IBM encoding", dmenuVarCheck, dmenuSetVariables, NULL,
- "font8x8=cp865-8x8,font8x14=cp865-8x14,font8x16=cp865-8x16" },
- { "5 IBM 866", "Russian, IBM encoding", dmenuVarCheck, dmenuSetVariables, NULL,
- "font8x8=cp866-8x8,font8x14=cp866-8x14,font8x16=cp866-8x16" },
- { "6 ISO 8859-1", "Western Europe, ISO encoding", dmenuVarCheck, dmenuSetVariables, NULL,
- "font8x8=iso-8x8,font8x14=iso-8x14,font8x16=iso-8x16" },
- { "7 ISO 8859-2", "Eastern Europe, ISO encoding", dmenuVarCheck, dmenuSetVariables, NULL,
- "font8x8=iso02-8x8,font8x14=iso02-8x14,font8x16=iso02-8x16" },
- { "8 KOI8-R", "Russian, KOI8-R encoding", dmenuVarCheck, dmenuSetVariables, NULL,
- "font8x8=koi8-r-8x8,font8x14=koi8-r-8x14,font8x16=koi8-r-8x16" },
- { "9 SWISS", "English, better resolution", dmenuVarCheck, dmenuSetVariables, NULL,
- "font8x8=swiss-8x8,font8x14=NO,font8x16=swiss-8x16" },
- { NULL } },
-};
-
-DMenu MenuUsermgmt = {
- DMENU_NORMAL_TYPE,
- "User and group management",
- "The submenus here allow to manipulate user groups and\n"
- "login accounts.\n",
- "Configure your user groups and users",
- NULL,
- { { "X Exit", "Exit this menu (returning to previous)", NULL, dmenuExit },
- { "User", "Add a new user to the system.", NULL, userAddUser },
- { "Group", "Add a new user group to the system.", NULL, userAddGroup },
- { NULL } },
-};
-
-DMenu MenuFixit = {
- DMENU_NORMAL_TYPE,
- "Please choose a fixit option",
- "There are three ways of going into \"fixit\" mode:\n"
- "- you can use the 2nd FreeBSD CDROM, in which case there will be\n"
- " full access to the complete set of FreeBSD commands and utilities,\n"
- "- you can use the more limited (but perhaps customized) fixit floppy,\n"
- "- or you can start an Emergency Holographic Shell now, which is\n"
- " limited to the subset of commands that is already available right now.",
- "Press F1 for more detailed repair instructions",
- "fixit",
-{ { "X Exit", "Exit this menu (returning to previous)", NULL, dmenuExit },
- { "2 CDROM", "Use the 2nd \"live\" CDROM from the distribution", NULL, installFixitCDROM },
- { "3 Floppy", "Use a floppy generated from the fixit image", NULL, installFixitFloppy },
- { "4 Shell", "Start an Emergency Holographic Shell", NULL, installFixitHoloShell },
- { NULL } },
-};
diff --git a/usr.sbin/sade/misc.c b/usr.sbin/sade/misc.c
deleted file mode 100644
index 4bba7e513dcb..000000000000
--- a/usr.sbin/sade/misc.c
+++ /dev/null
@@ -1,484 +0,0 @@
-/*
- * Miscellaneous support routines..
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 "sysinstall.h"
-#include <ctype.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/errno.h>
-#include <sys/file.h>
-#include <sys/types.h>
-#include <dirent.h>
-#include <sys/wait.h>
-#include <sys/param.h>
-#include <sys/mount.h>
-#include <ufs/ufs/ufsmount.h>
-#include <sys/reboot.h>
-#include <sys/disklabel.h>
-
-/* Quick check to see if a file is readable */
-Boolean
-file_readable(char *fname)
-{
- if (!access(fname, F_OK))
- return TRUE;
- return FALSE;
-}
-
-/* Quick check to see if a file is executable */
-Boolean
-file_executable(char *fname)
-{
- if (!access(fname, X_OK))
- return TRUE;
- return FALSE;
-}
-
-/* Concatenate two strings into static storage */
-char *
-string_concat(char *one, char *two)
-{
- static char tmp[FILENAME_MAX];
-
- /* Yes, we're deliberately cavalier about not checking for overflow */
- strcpy(tmp, one);
- strcat(tmp, two);
- return tmp;
-}
-
-/* sane strncpy() function */
-char *
-sstrncpy(char *dst, const char *src, int size)
-{
- dst[size] = '\0';
- return strncpy(dst, src, size);
-}
-
-/* Concatenate three strings into static storage */
-char *
-string_concat3(char *one, char *two, char *three)
-{
- static char tmp[FILENAME_MAX];
-
- /* Yes, we're deliberately cavalier about not checking for overflow */
- strcpy(tmp, one);
- strcat(tmp, two);
- strcat(tmp, three);
- return tmp;
-}
-
-/* Clip the whitespace off the end of a string */
-char *
-string_prune(char *str)
-{
- int len = str ? strlen(str) : 0;
-
- while (len && isspace(str[len - 1]))
- str[--len] = '\0';
- return str;
-}
-
-/* run the whitespace off the front of a string */
-char *
-string_skipwhite(char *str)
-{
- while (*str && isspace(*str))
- ++str;
- return str;
-}
-
-/* copy optionally and allow second arg to be null */
-char *
-string_copy(char *s1, char *s2)
-{
- if (!s1)
- return NULL;
- if (!s2)
- s1[0] = '\0';
- else
- strcpy(s1, s2);
- return s1;
-}
-
-/* convert an integer to a string, using a static buffer */
-char *
-itoa(int value)
-{
- static char buf[13];
-
- snprintf(buf, 12, "%d", value);
- return buf;
-}
-
-Boolean
-directory_exists(const char *dirname)
-{
- DIR *tptr;
-
- if (!dirname)
- return FALSE;
- if (!strlen(dirname))
- return FALSE;
-
- tptr = opendir(dirname);
- if (!tptr)
- return (FALSE);
-
- closedir(tptr);
- return (TRUE);
-}
-
-char *
-pathBaseName(const char *path)
-{
- char *pt;
- char *ret = (char *)path;
-
- pt = strrchr(path,(int)'/');
-
- if (pt != 0) /* if there is a slash */
- {
- ret = ++pt; /* start the file after it */
- }
-
- return(ret);
-}
-
-/* A free guaranteed to take NULL ptrs */
-void
-safe_free(void *ptr)
-{
- if (ptr)
- free(ptr);
-}
-
-/* A malloc that checks errors */
-void *
-safe_malloc(size_t size)
-{
- void *ptr;
-
- if (size <= 0)
- msgFatal("Invalid malloc size of %d!", size);
- ptr = malloc(size);
- if (!ptr)
- msgFatal("Out of memory!");
- bzero(ptr, size);
- return ptr;
-}
-
-/* A realloc that checks errors */
-void *
-safe_realloc(void *orig, size_t size)
-{
- void *ptr;
-
- if (size <= 0)
- msgFatal("Invalid realloc size of %d!", size);
- ptr = realloc(orig, size);
- if (!ptr)
- msgFatal("Out of memory!");
- return ptr;
-}
-
-/* Create a path biased from the VAR_INSTALL_ROOT variable (if not /) */
-char *
-root_bias(char *path)
-{
- static char tmp[FILENAME_MAX];
- char *cp = variable_get(VAR_INSTALL_ROOT);
-
- if (!strcmp(cp, "/"))
- return path;
- strcpy(tmp, variable_get(VAR_INSTALL_ROOT));
- strcat(tmp, path);
- return tmp;
-}
-
-/*
- * These next routines are kind of specialized just for building item lists
- * for dialog_menu().
- */
-
-/* Add an item to an item list */
-dialogMenuItem *
-item_add(dialogMenuItem *list, char *prompt, char *title,
- int (*checked)(dialogMenuItem *self),
- int (*fire)(dialogMenuItem *self),
- void (*selected)(dialogMenuItem *self, int is_selected),
- void *data, int aux, int *curr, int *max)
-{
- dialogMenuItem *d;
-
- if (*curr == *max) {
- *max += 20;
- list = (dialogMenuItem *)realloc(list, sizeof(dialogMenuItem) * *max);
- }
- d = &list[(*curr)++];
- bzero(d, sizeof(*d));
- d->prompt = prompt ? strdup(prompt) : NULL;
- d->title = title ? strdup(title) : NULL;
- d->checked = checked;
- d->fire = fire;
- d->selected = selected;
- d->data = data;
- d->aux = aux;
- return list;
-}
-
-/* Toss the items out */
-void
-items_free(dialogMenuItem *list, int *curr, int *max)
-{
- int i;
-
- for (i = 0; list[i].prompt; i++) {
- safe_free(list[i].prompt);
- safe_free(list[i].title);
- }
- safe_free(list);
- *curr = *max = 0;
-}
-
-int
-Mkdir(char *ipath)
-{
- struct stat sb;
- int final;
- char *p, *path;
-
- if (file_readable(ipath) || Fake)
- return DITEM_SUCCESS;
-
- path = strcpy(alloca(strlen(ipath) + 1), ipath);
- if (isDebug())
- msgDebug("mkdir(%s)\n", path);
- p = path;
- if (p[0] == '/') /* Skip leading '/'. */
- ++p;
- for (final = FALSE; !final; ++p) {
- if (p[0] == '\0' || (p[0] == '/' && p[1] == '\0'))
- final = TRUE;
- else if (p[0] != '/')
- continue;
- *p = '\0';
- if (stat(path, &sb)) {
- if (errno != ENOENT) {
- msgConfirm("Couldn't stat directory %s: %s", path, strerror(errno));
- return DITEM_FAILURE;
- }
- if (isDebug())
- msgDebug("mkdir(%s..)\n", path);
- if (mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
- msgConfirm("Couldn't create directory %s: %s", path,strerror(errno));
- return DITEM_FAILURE;
- }
- }
- *p = '/';
- }
- return DITEM_SUCCESS;
-}
-
-int
-Mount(char *mountp, void *dev)
-{
- struct ufs_args ufsargs;
- char device[80];
- char mountpoint[FILENAME_MAX];
-
- if (Fake)
- return DITEM_SUCCESS;
-
- if (*((char *)dev) != '/') {
- sprintf(device, "%s/dev/%s", RunningAsInit ? "/mnt" : "", (char *)dev);
- sprintf(mountpoint, "%s%s", RunningAsInit ? "/mnt" : "", mountp);
- }
- else {
- strcpy(device, dev);
- strcpy(mountpoint, mountp);
- }
- memset(&ufsargs,0,sizeof ufsargs);
-
- if (Mkdir(mountpoint)) {
- msgConfirm("Unable to make directory mountpoint for %s!", mountpoint);
- return DITEM_FAILURE;
- }
- if (isDebug())
- msgDebug("mount %s %s\n", device, mountpoint);
-
- ufsargs.fspec = device;
- if (mount("ufs", mountpoint, RunningAsInit ? MNT_ASYNC | MNT_NOATIME : 0,
- (caddr_t)&ufsargs) == -1) {
- msgConfirm("Error mounting %s on %s : %s", device, mountpoint, strerror(errno));
- return DITEM_FAILURE;
- }
- return DITEM_SUCCESS;
-}
-
-WINDOW *
-openLayoutDialog(char *helpfile, char *title, int x, int y, int width, int height)
-{
- WINDOW *win;
- static char help[FILENAME_MAX];
-
- /* We need a curses window */
- win = newwin(LINES, COLS, 0, 0);
- if (win) {
- /* Say where our help comes from */
- if (helpfile) {
- use_helpline("Press F1 for more information on this screen.");
- use_helpfile(systemHelpFile(helpfile, help));
- }
- /* Setup a nice screen for us to splat stuff onto */
- draw_box(win, y, x, height, width, dialog_attr, border_attr);
- wattrset(win, dialog_attr);
- mvwaddstr(win, y, x + (COLS - strlen(title)) / 2, title);
- }
- return win;
-}
-
-ComposeObj *
-initLayoutDialog(WINDOW *win, Layout *layout, int x, int y, int *max)
-{
- ComposeObj *obj = NULL, *first;
- int n;
-
- /* Loop over the layout list, create the objects, and add them
- onto the chain of objects that dialog uses for traversal*/
-
- n = 0;
- while (layout[n].help != NULL) {
- int t = TYPE_OF_OBJ(layout[n].type);
-
- switch (t) {
- case STRINGOBJ:
- layout[n].obj = NewStringObj(win, layout[n].prompt, layout[n].var,
- layout[n].y + y, layout[n].x + x, layout[n].len, layout[n].maxlen);
- ((StringObj *)layout[n].obj)->attr_mask = ATTR_OF_OBJ(layout[n].type);
- break;
-
- case BUTTONOBJ:
- layout[n].obj = NewButtonObj(win, layout[n].prompt, layout[n].var, layout[n].y + y, layout[n].x + x);
- break;
-
- default:
- msgFatal("Don't support this object yet!");
- }
- AddObj(&obj, t, (void *) layout[n].obj);
- n++;
- }
- *max = n - 1;
- /* Find the first object in the list */
- for (first = obj; first->prev; first = first->prev);
- return first;
-}
-
-int
-layoutDialogLoop(WINDOW *win, Layout *layout, ComposeObj **obj, int *n, int max, int *cbutton, int *cancel)
-{
- char help_line[80];
- int ret, i, len = strlen(layout[*n].help);
-
- /* Display the help line at the bottom of the screen */
- for (i = 0; i < 79; i++)
- help_line[i] = (i < len) ? layout[*n].help[i] : ' ';
- help_line[i] = '\0';
- use_helpline(help_line);
- display_helpline(win, LINES - 1, COLS - 1);
- wrefresh(win);
-
- /* Ask for libdialog to do its stuff */
- ret = PollObj(obj);
- /* Handle special case stuff that libdialog misses. Sigh */
- switch (ret) {
- case SEL_ESC: /* Bail out */
- *cancel = TRUE;
- return FALSE;
-
- /* This doesn't work for list dialogs. Oh well. Perhaps
- should special case the move from the OK button ``up''
- to make it go to the interface list, but then it gets
- awkward for the user to go back and correct screw up's
- in the per-interface section */
- case KEY_DOWN:
- case SEL_CR:
- case SEL_TAB:
- if (*n < max)
- ++*n;
- else
- *n = 0;
- break;
-
- /* The user has pressed enter over a button object */
- case SEL_BUTTON:
- if (cbutton && *cbutton)
- *cancel = TRUE;
- else
- *cancel = FALSE;
- return FALSE;
-
- case KEY_UP:
- case SEL_BACKTAB:
- if (*n)
- --*n;
- else
- *n = max;
- break;
-
- case KEY_F(1):
- display_helpfile();
-
- /* They tried some key combination we don't support - tootle them forcefully! */
- default:
- beep();
- }
- return TRUE;
-}
-
-WINDOW *
-savescr(void)
-{
- WINDOW *w;
-
- w = dupwin(newscr);
- return w;
-}
-
-void
-restorescr(WINDOW *w)
-{
- touchwin(w);
- wrefresh(w);
- delwin(w);
-}
-
diff --git a/usr.sbin/sade/msg.c b/usr.sbin/sade/msg.c
deleted file mode 100644
index 499d70501a37..000000000000
--- a/usr.sbin/sade/msg.c
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last program in the `sysinstall' line - the next
- * generation being essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 "sysinstall.h"
-#include <stdarg.h>
-#include <sys/ioctl.h>
-#include <machine/console.h>
-
-Boolean
-isDebug(void)
-{
- char *cp;
-
- return (cp = variable_get(VAR_DEBUG)) && strcmp(cp, "no");
-}
-
-/* Whack up an informational message on the status line, in stand-out */
-void
-msgYap(char *fmt, ...)
-{
- va_list args;
- char *errstr;
- int attrs;
-
- errstr = (char *)alloca(FILENAME_MAX);
- va_start(args, fmt);
- vsnprintf(errstr, FILENAME_MAX, fmt, args);
- va_end(args);
- attrs = getattrs(stdscr);
- attrset(A_REVERSE);
- mvaddstr(StatusLine, 0, errstr);
- attrset(attrs);
- refresh();
-}
-
-/* Whack up an informational message on the status line */
-void
-msgInfo(char *fmt, ...)
-{
- va_list args;
- char *errstr;
- int i, attrs;
- char line[81];
-
- attrs = getattrs(stdscr);
- /* NULL is a special convention meaning "erase the old stuff" */
- if (!fmt) {
- move(StatusLine, 0);
- clrtoeol();
- return;
- }
- errstr = (char *)alloca(FILENAME_MAX);
- va_start(args, fmt);
- vsnprintf(errstr, FILENAME_MAX, fmt, args);
- va_end(args);
- memset(line, ' ', 80);
- for (i = 0; i < 80; i++) {
- if (errstr[i])
- line[i] = errstr[i];
- else
- break;
- }
- line[80] = '\0';
- attrset(ATTR_TITLE);
- mvaddstr(StatusLine, 0, line);
- attrset(attrs);
- move(StatusLine, 79);
- refresh();
-}
-
-/* Whack up a warning on the status line */
-void
-msgWarn(char *fmt, ...)
-{
- va_list args;
- char *errstr;
- int attrs;
-
- errstr = (char *)alloca(FILENAME_MAX);
- strcpy(errstr, "Warning: ");
- va_start(args, fmt);
- vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args);
- va_end(args);
- attrs = getattrs(stdscr);
- beep();
- attrset(ATTR_TITLE);
- mvaddstr(StatusLine, 0, errstr);
- attrset(attrs);
- refresh();
- if (OnVTY && isDebug())
- msgDebug("Warning message `%s'\n", errstr);
-}
-
-/* Whack up an error on the status line */
-void
-msgError(char *fmt, ...)
-{
- va_list args;
- char *errstr;
- int attrs;
-
- errstr = (char *)alloca(FILENAME_MAX);
- strcpy(errstr, "Error: ");
- va_start(args, fmt);
- vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args);
- va_end(args);
- beep();
- attrs = getattrs(stdscr);
- attrset(ATTR_TITLE);
- mvaddstr(StatusLine, 0, errstr);
- attrset(attrs);
- refresh();
- if (OnVTY && isDebug())
- msgDebug("Error message `%s'\n", errstr);
-}
-
-/* Whack up a fatal error on the status line */
-void
-msgFatal(char *fmt, ...)
-{
- va_list args;
- char *errstr;
- int attrs;
-
- errstr = (char *)alloca(FILENAME_MAX);
- strcpy(errstr, "Fatal Error: ");
- va_start(args, fmt);
- vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args);
- va_end(args);
- beep();
- attrs = getattrs(stdscr);
- attrset(ATTR_TITLE);
- mvaddstr(StatusLine, 0, errstr);
- addstr(" - ");
- addstr("PRESS ANY KEY TO ");
- if (getpid() == 1)
- addstr("REBOOT");
- else
- addstr("QUIT");
- attrset(attrs);
- refresh();
- if (OnVTY)
- msgDebug("Fatal error `%s'!\n", errstr);
- getch();
- systemShutdown(1);
-}
-
-/* Put up a message in a popup confirmation box */
-void
-msgConfirm(char *fmt, ...)
-{
- va_list args;
- char *errstr;
- WINDOW *w = savescr();
-
- errstr = (char *)alloca(FILENAME_MAX);
- va_start(args, fmt);
- vsnprintf(errstr, FILENAME_MAX, fmt, args);
- va_end(args);
- use_helpline(NULL);
- use_helpfile(NULL);
- if (OnVTY) {
- ioctl(0, VT_ACTIVATE, 1);
- msgInfo(NULL);
- }
- dialog_notify(errstr);
- restorescr(w);
-}
-
-/* Put up a message in a popup information box */
-void
-msgNotify(char *fmt, ...)
-{
- va_list args;
- char *errstr;
-
- errstr = (char *)alloca(FILENAME_MAX);
- va_start(args, fmt);
- vsnprintf(errstr, FILENAME_MAX, fmt, args);
- va_end(args);
- use_helpline(NULL);
- use_helpfile(NULL);
- if (isDebug())
- msgDebug("Notify: %s\n", errstr);
- dialog_msgbox(NULL, errstr, -1, -1, 0);
-}
-
-/* Put up a message in a popup yes/no box and return 1 for YES, 0 for NO */
-int
-msgYesNo(char *fmt, ...)
-{
- va_list args;
- char *errstr;
- int ret;
- WINDOW *w = savescr();
-
- errstr = (char *)alloca(FILENAME_MAX);
- va_start(args, fmt);
- vsnprintf(errstr, FILENAME_MAX, fmt, args);
- va_end(args);
- use_helpline(NULL);
- use_helpfile(NULL);
- if (OnVTY) {
- ioctl(0, VT_ACTIVATE, 1); /* Switch back */
- msgInfo(NULL);
- }
- ret = dialog_yesno("User Confirmation Requested", errstr, -1, -1);
- restorescr(w);
- return ret;
-}
-
-/* Put up a message in an input box and return the value */
-char *
-msgGetInput(char *buf, char *fmt, ...)
-{
- va_list args;
- char *errstr;
- static char input_buffer[256];
- int rval;
- WINDOW *w = savescr();
-
- errstr = (char *)alloca(FILENAME_MAX);
- va_start(args, fmt);
- vsnprintf(errstr, FILENAME_MAX, fmt, args);
- va_end(args);
- use_helpline(NULL);
- use_helpfile(NULL);
- if (buf)
- SAFE_STRCPY(input_buffer, buf);
- else
- input_buffer[0] = '\0';
- if (OnVTY) {
- ioctl(0, VT_ACTIVATE, 1); /* Switch back */
- msgInfo(NULL);
- }
- rval = dialog_inputbox("Value Required", errstr, -1, -1, input_buffer);
- restorescr(w);
- if (!rval)
- return input_buffer;
- else
- return NULL;
-}
-
-/* Write something to the debugging port */
-void
-msgDebug(char *fmt, ...)
-{
- va_list args;
- char *dbg;
-
- if (DebugFD == -1)
- return;
- dbg = (char *)alloca(FILENAME_MAX);
- strcpy(dbg, "DEBUG: ");
- va_start(args, fmt);
- vsnprintf((char *)(dbg + strlen(dbg)), FILENAME_MAX, fmt, args);
- va_end(args);
- write(DebugFD, dbg, strlen(dbg));
-}
-
-/* Tell the user there's some output to go look at */
-void
-msgWeHaveOutput(char *fmt, ...)
-{
- va_list args;
- char *errstr;
- WINDOW *w = savescr();
-
- errstr = (char *)alloca(FILENAME_MAX);
- va_start(args, fmt);
- vsnprintf(errstr, FILENAME_MAX, fmt, args);
- va_end(args);
- use_helpline(NULL);
- use_helpfile(NULL);
- msgDebug("Notify: %s\n", errstr);
- dialog_clear_norefresh();
- sleep(2);
- dialog_msgbox(NULL, errstr, -1, -1, 0);
- restorescr(w);
-}
-
-/* Simple versions of msgConfirm() and msgNotify() for calling from scripts */
-int
-msgSimpleConfirm(char *str)
-{
- msgConfirm(str);
- return DITEM_SUCCESS;
-}
-
-int
-msgSimpleNotify(char *str)
-{
- msgNotify(str);
- return DITEM_SUCCESS;
-}
diff --git a/usr.sbin/sade/rtermcap.c b/usr.sbin/sade/rtermcap.c
deleted file mode 100644
index 84b3feb49ead..000000000000
--- a/usr.sbin/sade/rtermcap.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <stdio.h>
-#include <termcap.h>
-
-int
-main(int argc, char **argv)
-{
- char buf[4096];
- int i;
-
- if (argc < 2)
- return 1;
- i = tgetent(buf, argv[1]);
- printf("%s",buf);
- return 0;
-}
diff --git a/usr.sbin/sade/sade.8 b/usr.sbin/sade/sade.8
deleted file mode 100644
index 7c46a83ea377..000000000000
--- a/usr.sbin/sade/sade.8
+++ /dev/null
@@ -1,861 +0,0 @@
-.\" Copyright (c) 1997
-.\" Jordan Hubbard <jkh@FreeBSD.org>. 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 Jordan Hubbard 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 Jordan Hubbard 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd August 9, 1997
-.Dt SYSINSTALL 8
-.Os FreeBSD
-.Sh NAME
-.Nm sysinstall
-.Nd system installation and configuration tool
-.Sh SYNOPSIS
-.Nm
-.Op Ar var=value
-.Op Ar function
-.Op Ar ...
-.Sh DESCRIPTION
-.Nm
-is a utility for installing and configuring
-.Fx
-systems.
-It is the first utility invoked by the
-.Fx
-installation boot
-floppy and is also copied into
-.Pa /stand/sysinstall
-on newly installed
-.Fx
-systems for use in later configuring the system.
-.Pp
-The
-.Nm
-program is generally invoked without arguments for the default
-behavior, where the main installation/configuration menu is presented.
-
-On those occasions where it is deemed necessary to invoke a subsystem
-of sysinstall directly, however, it is also possible to do so by
-naming the appropriate function entry points on the command line.
-Since this action is essentially identical to running an installation
-script, each command-line argument corresponding to a line of script,
-the reader is encouraged to read the section on scripting for more
-information on this feature.
-.Pp
-.Sh NOTES
-.Nm
-is essentially nothing more than a monolithic C program with
-the ability to write MBRs and disk labels (through the services
-of the
-.Xr libdisk 3
-library) and install distributions or packages onto new and
-existing
-.Fx
-systems. It also contains some extra intelligence
-for running as a replacement for
-.Xr init 8
-when it's invoked by the
-.Fx
-installation boot procedure. It
-assumes very little in the way of additional utility support and
-performs most file system operations by calling the relevant syscalls
-(such as
-.Xr mount 2 )
-directly.
-.Pp
-.Nm
-currently uses the
-.Xr dialog 3
-library to do user interaction with simple ANSI line graphics, color
-support for which is enabled by either running on a syscons VTY or some
-other color-capable terminal emulator (newer versions of xterm will support
-color when using the
-.Dq xterm-color
-termcap entry).
-.Pp
-This product is currently at the end of its life cycle and will
-eventually be replaced.
-.Sh RUNNING SCRIPTS
-.Nm
-may be either driven interactively through its various internal menus
-or run in batch mode, driven by an external script. Such a script may
-be loaded and executed in one of 3 ways:
-
-.Bl -tag -width Ds -compact
-.It Sy "LOAD_CONFIG_FILE"
-If
-.Nm
-is compiled with LOAD_CONFIG_FILE set in the environment
-(or in the Makefile) to some value, then that value will
-be used as the filename to automatically look for and load
-when
-.Nm
-starts up and with no user interaction required.
-This option is aimed primarily at large sites who wish to create a
-single prototype install for multiple machines with largely identical
-configurations and/or installation options.
-
-.It Sy "MAIN MENU"
-If
-.Nm
-is run interactively, that is to say in the default manner, it will
-bring up a main menu which contains a "load config file" option.
-Selecting this option will prompt for the name of a script file which
-it then will attempt to load from a DOS or UFS formatted floppy.
-
-.It Sy "COMMAND LINE"
-Each command line argument is treated as a script directive
-when
-.Nm
-is run in multi-user mode. Execution ends either by explicit request
-(e.g. calling the
-.Ar shutdown
-directive), upon reaching the end of the argument list or on error.
-.Pp
-For example:
-.nf
-
-/stand/sysinstall _ftpPath=ftp://ziggy/pub/ mediaSetFTP configPackages
-
-.fi
-Would initialize
-.Nm
-for FTP installation media (using the server `ziggy') and then
-bring up the package installation editor, exiting when finished.
-.El
-.Pp
-.Sh SCRIPT SYNTAX
-A script is a list of one or more directives, each directive taking
-the form of:
-
-.Ar var=value
-.Pp
-.Ar function
-.Pp
-or
-.Ar #somecomment
-
-Where
-.Ar var=value
-is the assignment of some internal
-.Nm
-variable, e.g. "ftpPass=FuNkYChiKn", and
-.Ar function
-is the name of an internal
-.Nm
-function, e.g. "mediaSetFTP", and
-.Ar #comment
-is a single-line comment for documentation purposes (ignored by
-sysinstall). Each directive must be by itself on a single line,
-functions taking their arguments by examining known variable names.
-This requires that you be sure to assign the relevant variables before
-calling a function which requires them. When and where a function
-depends on the settings of one or more variables will be noted in the
-following table:
-
-.Pp
-\fBFunction Glossary:\fR
-.Pp
-.Bl -tag -width indent
-.It configAnonFTP
-Invoke the Anonymous FTP configuration menu.
-.Pp
-\fBVariables:\fR None
-.It configRouter
-Select which routing daemon you wish to use, potentially
-loading any required 3rd-party routing daemons as necessary.
-.Pp
-\fBVariables:\fR
-.Bl -tag -width indent
-.It router
-can be set to the name of the desired routing daemon,
-e.g.
-.Dq routed
-or
-.Dq gated ,
-otherwise it is prompted for.
-.El
-.It configNFSServer
-Configure host as an NFS server.
-.Pp
-\fBVariables:\fR None
-.It configNTP
-Configure host as a user of the Network Time Protocol.
-.Pp
-\fBVariables:\fR
-.Bl -tag -width indent
-.It ntpdate_flags
-The flags to
-.Xr ntpdate 8 ,
-that is to say the name of the server to sync from.
-.El
-.It configPCNFSD
-Configure host to support PC NFS.
-.Pp
-\fBVariables:\fR
-.Bl -tag -width indent
-.It pcnfsd_pkg
-The name of the PCNFSD package to load if necessary (defaults to hard coded
-version).
-.El
-.It configPackages
-Bring up the interactive package management menu.
-.Pp
-\fBVariables:\fR None
-.It configUsers
-Add users and/or groups to the system.
-.Pp
-\fBVariables:\fR None
-.It configXEnvironment
-Configure the X display subsystem.
-.Pp
-\fBVariables:\fR None
-.It diskPartitionEditor
-Invokes the disk partition (MBR) editor.
-.Pp
-\fBVariables:\fR
-.Bl -tag -width findx
-.It geometry
-The disk geometry, as a cyls/heads/sectors formatted string. Default: no
-change to geometry.
-.It partition
-Set to disk partitioning type or size, its value being
-.Ar free
-in order to use only remaining free space for
-.Fx ,
-.Ar all
-to use the entire disk for
-.Fx
-but maintain a proper partition
-table,
-.Ar existing
-to use an existing
-.Fx
-partition (first found),
-.Ar exclusive
-to use the disk in
-.Dq dangerously dedicated
-mode or, finally,
-.Ar somenumber
-to allocate
-.Ar somenumber
-blocks of available free space to a new
-.Fx
-partition.
-Default: Interactive mode.
-.It bootManager
-is set to one of
-.Ar boot
-to signify the installation of a boot manager,
-.Ar standard
-to signify installation of a "standard" non-boot MGR DOS
-MBR or
-.Ar none
-to indicate that no change to the boot manager is desired.
-Default: none.
-.El
-.Pp
-Note: Nothing is actually written to disk by this function, a explicit call to
-.Ar diskPartitionWrite
-being required for that to happen.
-.It diskPartitionWrite
-Causes any pending MBR changes (typically from the
-.Ar diskPartitionEditor
-function) to be written out.
-.Pp
-\fBVariables:\fR None
-.It diskLabelEditor
-Invokes the disk label editor. This is a bit trickier from a script
-since you need to essentially label everything inside each
-.Fx
-(type 0xA5) partition created by the
-.Ar diskPartitionEditor
-function, and that requires knowing a few rules about how things are
-laid out. When creating a script to automatically allocate disk space
-and partition it up, it is suggested that you first perform the
-installation interactively at least once and take careful notes as to
-what the slice names will be, then and only then hardwiring them into
-the script.
-.Pp
-For example, let's say you have a SCSI disk on which you've created a new
-.Fx
-partition in slice 2 (your DOS partition residing in slice 1).
-The slice name would be
-.Ar da0s2
-for the whole
-.Fx
-partition
-.Ar ( da0s1
-being your DOS primary
-partition). Now let's further assume that you have 500MB in this
-partition and you want to sub-partition that space into root, swap,
-var and usr file systems for
-.Fx .
-Your invocation of the
-.Ar diskLabelEditor
-function might involve setting the following variables:
-.Bl -tag -width findx
-.It Li "da0s2-1=ufs 40960 /"
-A 20MB root file system (all sizes are in 512 byte blocks).
-.It Li "da0s2-2=swap 131072 /"
-A 64MB swap partition.
-.It Li "da0s2-3=ufs 204800 /var"
-A 100MB /var file system.
-.It Li "da0s2-4=ufs 0 /usr"
-With the balance of free space (around 316MB) going to the /usr
-file system.
-.El
-
-One can also use the
-.Ar diskLabelEditor
-for mounting or erasing existing partitions as well as creating new
-ones. Using the previous example again, let's say that we also wanted
-to mount our DOS partition and make sure that an
-.Pa /etc/fstab
-entry is created for it in the new installation. Before calling the
-.Ar diskLabelEditor
-function, we simply add an additional line:
-.nf
- da0s1=/dos_c N
-
-.fi
-before the call. This tells the label editor that you want to mount
-the first slice on
-.Pa /dos_c
-and not to attempt to newfs it (not that
-.Nm
-would attempt this for a DOS partition in any case, but it could just
-as easily be an existing UFS partition being named here and the 2nd
-field is non-optional).
-.Pp
-Note: No file system data is actually written to disk until an
-explicit call to
-.Ar diskLabelCommit
-is made.
-.It diskLabelCommit
-Writes out all pending disklabel information and creates and/or mounts any
-file systems which have requests pending from the
-.Ar diskLabelEditor
-function.
-.Pp
-\fBVariables:\fR None
-.It distReset
-Resets all selected distributions to the empty set (no distributions selected).
-.Pp
-\fBVariables:\fR None
-.It distSetCustom
-Allows the selection of a custom distribution set (e.g. not just on of the
-existing "canned" sets) with no user interaction.
-
-\fBVariables:\fR
-.Bl -tag -width indent
-.It dists
-List of distributions to load. Possible distribution values are:
-.Bl -tag -width indentxx
-.It Li bin
-The base binary distribution.
-.It Li doc
-Miscellaneous documentation
-.It Li games
-Games
-.It Li manpages
-Manual pages (unformatted)
-.It Li catpages
-Pre-formatted manual pages
-.It Li proflibs
-Profiled libraries for developers.
-.It Li dict
-Dictionary information (for tools like spell).
-.It Li info
-GNU info files and other extra docs.
-.It Li crypto
-Encryption binaries and libraries.
-.It Li compat1x
-Compatibility with
-.It Li 1.x
-.It Li compat20
-Compatibility with
-.Fx 2.0
-.It Li compat21
-Compatibility with
-.Fx 2.1
-.It Li compat22
-.Fx 2.2
-and
-.Fx 3.0
-a.out binary compatibility
-.It Li compat3x
-Compatibility with
-.It Li 3.x
-(available for
-.Fx 4.0
-systems only)
-.It Li ports
-The ports collection.
-.It Li krb4
-KerberosIV binaries.
-.It Li ssecure
-/usr/src/secure
-.It Li sbase
-/usr/src/[top level files]
-.It Li scontrib
-/usr/src/contrib
-.It Li sgnu
-/usr/src/gnu
-.It Li setc
-/usr/src/etc
-.It Li sgames
-/usr/src/games
-.It Li sinclude
-/usr/src/include
-.It Li slib
-/usr/src/lib
-.It Li slibexec
-/usr/src/libexec
-.It Li srelease
-/usr/src/release
-.It Li sbin
-/usr/src/bin
-.It Li ssbin
-/usr/src/sbin
-.It Li sshare
-/usr/src/share
-.It Li ssys
-/usr/src/sys
-.It Li subin
-/usr/src/usr.bin
-.It Li susbin
-/usr/src/usr.sbin
-.It Li ssmailcf
-/usr/src/usr.sbin/sendmail/cf
-.It Li XF86-xc
-XFree86 official sources.
-.It Li XF86-co
-XFree86 contributed sources.
-.It Li Xbin
-XFree86 3.3.6 binaries.
-.It Li Xcfg
-XFree86 3.3.6 configuration files.
-.It Li Xdoc
-XFree86 3.3.6 documentation.
-.It Li Xhtml
-XFree86 3.3.6 HTML documentation.
-.It Li Xlib
-XFree86 3.3.6 libraries.
-.It Li Xlk98
-XFree86 3.3.6 server link-kit for PC98 machines.
-.It Li Xlkit
-XFree86 3.3.6 server link-kit for standard machines.
-.It Li Xman
-XFree86 3.3.6 manual pages.
-.It Li Xprog
-XFree86 3.3.6 programmer's distribution.
-.It Li Xps
-XFree86 3.3.6 postscript documentation.
-.It Li Xset
-XFree86 3.3.6 graphical setup tool.
-.It Li X8514
-XFree86 3.3.6 8514 server.
-.It Li X9480
-XFree86 3.3.6 PC98 8-bit (256 color) PEGC-480 server.
-.It Li X9EGC
-XFree86 3.3.6 PC98 4-bit (16 color) EGC server.
-.It Li X9GA9
-XFree86 3.3.6 PC98 GA-968V4/PCI (S3 968) server.
-.It Li X9GAN
-XFree86 3.3.6 PC98 GANB-WAP (cirrus) server.
-.It Li X9LPW
-XFree86 3.3.6 PC98 PowerWindowLB (S3) server.
-.It Li X9NKV
-XFree86 3.3.6 PC98 NKV-NEC (cirrus) server.
-.It Li X9NS3
-XFree86 3.3.6 PC98 NEC (S3) server.
-.It Li X9SPW
-XFree86 3.3.6 PC98 SKB-PowerWindow (S3) server.
-.It Li X9TGU
-XFree86 3.3.6 PC98 Cyber9320 and TGUI9680 server.
-.It Li X9WEP
-XFree86 3.3.6 PC98 WAB-EP (cirrus) server.
-.It Li X9WS
-XFree86 3.3.6 PC98 WABS (cirrus) server.
-.It Li X9WSN
-XFree86 3.3.6 PC98 WSN-A2F (cirrus) server.
-.It Li XAGX
-XFree86 3.3.6 8 bit AGX server.
-.It Li XI128
-XFree86 3.3.6 #9 Imagine I128 server.
-.It Li XMa8
-XFree86 3.3.6 ATI Mach8 server.
-.It Li XMa32
-XFree86 3.3.6 ATI Mach32 server.
-.It Li XMa64
-XFree86 3.3.6 ATI Mach64 server.
-.It Li XMono
-XFree86 3.3.6 monochrome server.
-.It Li XP9K
-XFree86 3.3.6 P9000 server.
-.It Li XS3
-XFree86 3.3.6 S3 server.
-.It Li XS3V
-XFree86 3.3.6 S3 Virge server.
-.It Li XSVGA
-XFree86 3.3.6 SVGA server.
-.It Li XVG16
-XFree86 3.3.6 VGA16 server.
-.It Li XW32
-XFree86 3.3.6 ET4000/W32, /W32i and /W32p server.
-.It Li XTGA
-Server for TGA cards (alpha architecture only).
-.It Li Xnest
-XFree86 3.3.6 nested X server.
-.It Li Xvfb
-XFree86 3.3.6 virtual frame-buffer X server.
-.It Li Xfnts
-XFree86 3.3.6 base font set.
-.It Li Xf100
-XFree86 3.3.6 100DPI font set.
-.It Li Xfcyr
-XFree86 3.3.6 Cyrillic font set.
-.It Li Xfscl
-XFree86 3.3.6 scalable font set.
-.It Li Xfnon
-XFree86 3.3.6 non-english font set.
-.It Li Xfsrv
-XFree86 3.3.6 font server.
-.El
-.It distSetDeveloper
-Selects the standard Developer's distribution set.
-.Pp
-\fBVariables:\fR None
-.It distSetXDeveloper
-Selects the standard X Developer's distribution set.
-.Pp
-\fBVariables:\fR None
-.It distSetKernDeveloper
-Selects the standard kernel Developer's distribution set.
-.Pp
-\fBVariables:\fR None
-.It distSetUser
-Selects the standard user distribution set.
-.Pp
-\fBVariables:\fR None
-.It distSetXUser
-Selects the standard X user's distribution set.
-.Pp
-\fBVariables:\fR None
-.It distSetMinimum
-Selects the very minimum distribution set.
-.Pp
-\fBVariables:\fR None
-.It distSetEverything
-Selects the full whack - all available distributions.
-.Pp
-\fBVariables:\fR None
-.It distSetCRYPTO
-Interactively select encryption subcomponents.
-.Pp
-\fBVariables:\fR None
-.It distSetSrc
-Interactively select source subcomponents.
-.Pp
-\fBVariables:\fR None
-.It distSetXF86
-Interactively select XFree86 3.3.6 subcomponents.
-.Pp
-\fBVariables:\fR None
-.It distExtractAll
-Install all currently selected distributions (requires that
-media device also be selected).
-.Pp
-\fBVariables:\fR None
-.It docBrowser
-Install (if necessary) an HTML documentation browser and go to the
-HTML documentation submenu.
-.Pp
-\fBVariables:\fR
-.Bl -tag -width indent
-.It browserPackage
-The name of the browser package to try and install as necessary.
-Defaults to latest lynx package.
-.It browserBinary
-The name of the browser binary itself (if overriding the
-.Ar browserPackage
-variable). Defaults to lynx.
-.El
-.It installCommit
-.Pp
-Commit any and all pending changes to disk. This function
-is essentially shorthand for a number of more granular "commit"
-functions.
-.Pp
-\fBVariables:\fR None
-.It installExpress
-Start an "express" installation, asking few questions of
-the user.
-.Pp
-\fBVariables:\fR None
-.It installStandard
-Start a "standard" installation, the most user-friendly
-installation type available.
-.Pp
-\fBVariables:\fR None
-.It installUpgrade
-Start an upgrade installation.
-.Pp
-\fBVariables:\fR None
-.It installFixitHoloShell
-Start up the "emergency holographic shell" over on VTY4
-if running as init.
-.Pp
-\fBVariables:\fR None
-.It installFixitCDROM
-Go into "fixit" mode, assuming a live file system CDROM
-currently in the drive.
-.Pp
-\fBVariables:\fR None
-.It installFixitFloppy
-Go into "fixit" mode, assuming an available fixit floppy
-disk (user will be prompted for it).
-.Pp
-\fBVariables:\fR None
-.It installFilesystems
-Do just the file system initialization part of an install.
-.Pp
-\fBVariables:\fR None
-.It installVarDefaults
-Initialize all variables to their defaults, overriding any
-previous settings.
-.Pp
-\fBVariables:\fR None
-.It loadConfig
-Sort of like an #include statement, it allows you to load one
-configuration file from another.
-.Pp
-\fBVariables:\fR
-.Bl -tag -width indent
-.It file
-The fully pathname of the file to load.
-.El
-.It mediaSetCDROM
-Select a
-.Fx
-CDROM as the installation media.
-.Pp
-\fBVariables:\fR None
-.It mediaSetFloppy
-Select a pre-made floppy installation set as the installation media.
-.Pp
-\fBVariables:\fR None
-.It mediaSetDOS
-Select an existing DOS primary partition as the installation media.
-The first primary partition found is used (e.g. C:).
-.Pp
-\fBVariables:\fR None
-.It mediaSetTape
-Select a tape device as the installation media.
-.Pp
-\fBVariables:\fR None
-
-.\" XXX
-
-.It mediaSetFTP
-Select an FTP site as the installation media.
-.Pp
-\fBVariables:\fR
-.Bl -tag -width indent
-.It hostname
-The name of the host being installed (non-optional).
-.It domainname
-The domain name of the host being installed (optional).
-.It defaultrouter
-The default router for this host (non-optional).
-.It netDev
-Which host interface to use
-.Ar ( ed0
-or
-.Ar ep0 ,
-for example. Non-optional).
-.It netInteractive
-If set, bring up the interactive network setup form even
-if all relevant configuration variables are already set (optional).
-.It ipaddr
-The IP address for the selected host interface (non-optional).
-.It netmask
-The netmask for the selected host interface (non-optional).
-.It _ftpPath
-The fully qualified URL of the FTP site containing the
-.Fx
-distribution you're interested in, e.g.
-.Ar ftp://ftp.FreeBSD.org/pub/FreeBSD/ .
-.El
-.It mediaSetFTPActive
-Alias for
-.Ar mediaSetFTP
-using "active" FTP transfer mode.
-.Pp
-\fBVariables:\fR Same as for
-.Ar mediaSetFTP .
-.It mediaSetFTPPassive
-Alias for
-.Ar mediaSetFTP
-using "passive" FTP transfer mode.
-.Pp
-\fBVariables:\fR Same as for
-.Ar mediaSetFTP .
-.It mediaSetHTTP
-Alias for
-.Ar mediaSetFTP
-using an HTTP proxy.
-.Pp
-\fBVariables:\fR See
-.Ar mediaSetFTP ,
-plus
-.Bl -tag -width indent
-.It _httpPath
-The proxy to use (host:port) (non-optional).
-.El
-.It mediaSetUFS
-Select an existing UFS partition (mounted with the label editor) as
-the installation media.
-.Pp
-\fBVariables:\fR
-.Bl -tag -width indent
-.It ufs
-full /path to directory containing the
-.Fx
-distribution you're
-interested in.
-.El
-.It mediaSetNFS
-.Pp
-\fBVariables:\fR
-.Bl -tag -width indent
-.It hostname
-The name of the host being installed (non-optional).
-.It domainname
-The domain name of the host being installed (optional).
-.It defaultrouter
-The default router for this host (non-optional).
-.It netDev
-Which host interface to use
-.Ar ( ed0
-or
-.Ar ep0 ,
-for example. Non-optional).
-.It netInteractive
-If set, bring up the interactive network setup form even
-if all relevant configuration variables are already set (optional).
-.It ipaddr
-The IP address for the selected host interface (non-optional).
-.It netmask
-The netmask for the selected host interface (non-optional).
-.It nfs
-full hostname:/path specification for directory containing
-the
-.Fx
-distribution you're interested in.
-.El
-.It mediaSetFTPUserPass
-.Pp
-\fBVariables:\fR
-.Bl -tag -width indent
-.It ftpUser
-The username to log in as on the ftp server site.
-Default: ftp
-.It ftpPass
-The password to use for this username on the ftp
-server site.
-Default: user@host
-.El
-.It mediaSetCPIOVerbosity
-.Pp
-\fBVariables:\fR
-.Bl -tag -width indent
-.It cpioVerbose
-Can be used to set the verbosity of cpio extractions to low, medium or
-high.
-.El
-.It mediaGetType
-Interactively get the user to specify some type of media.
-.Pp
-\fBVariables:\fR None
-.It optionsEditor
-Invoke the interactive options editor.
-.Pp
-\fBVariables:\fR None
-.It packageAdd
-Try to fetch and add a package to the system (requires
-that a media type be set),
-.Pp
-\fBVariables:\fR
-.Bl -tag -width indent
-.It package
-The name of the package to add, e.g. bash-1.14.7 or ncftp-2.4.2.
-.El
-.It addGroup
-Invoke the interactive group editor.
-.Pp
-\fBVariables:\fR None
-.It addUser
-Invoke the interactive user editor.
-.Pp
-\fBVariables:\fR None
-.It shutdown
-Stop the script and terminate sysinstall.
-.Pp
-\fBVariables:\fR None
-.It system
-Execute an arbitrary command with
-.Xr system 3
-.Pp
-\fBVariables:\fR
-.Bl -tag -width indent
-.It command
-The name of the command to execute. When running
-from a boot floppy, very minimal expectations should
-be made as to what's available until/unless a relatively
-full system installation has just been done.
-.El
-.El
-.Sh FILES
-This utility may edit the contents of
-.Pa /etc/rc.conf ,
-.Pa /etc/hosts ,
-and
-.Pa /etc/resolv.conf
-as necessary to reflect changes in the network configuration.
-.Sh SEE ALSO
-If you have a reasonably complete source tree online, take
-a look at
-.Pa /usr/src/release/sysinstall/install.cfg
-for a sample installation script.
-.Sh BUGS
-This utility is a prototype which lasted several years past
-its expiration date and is greatly in need of death.
-.Sh AUTHORS
-.An Jordan K. Hubbard Aq jkh@FreeBSD.org
-.Sh HISTORY
-This version of
-.Nm
-first appeared in
-.Fx 2.0 .
diff --git a/usr.sbin/sade/sade.h b/usr.sbin/sade/sade.h
deleted file mode 100644
index e4a3fc1261ec..000000000000
--- a/usr.sbin/sade/sade.h
+++ /dev/null
@@ -1,752 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last attempt in the `sysinstall' line, the next
- * generation being slated to essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 _SYSINSTALL_H_INCLUDE
-#define _SYSINSTALL_H_INCLUDE
-
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <errno.h>
-#include <setjmp.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <dialog.h>
-#include "ui_objects.h"
-#include "dir.h"
-#include "colors.h"
-#include "libdisk.h"
-#include "dist.h"
-
-/*** Defines ***/
-
-/* device limits */
-#define DEV_NAME_MAX 64 /* The maximum length of a device name */
-#define DEV_MAX 100 /* The maximum number of devices we'll deal with */
-#define INTERFACE_MAX 50 /* Maximum number of network interfaces we'll deal with */
-#define IO_ERROR -2 /* Status code for I/O error rather than normal EOF */
-
-/* Number of seconds to wait for data to come off even the slowest media */
-#define MEDIA_TIMEOUT 300
-
-/*
- * I make some pretty gross assumptions about having a max of 50 chunks
- * total - 8 slices and 42 partitions. I can't easily display many more
- * than that on the screen at once!
- *
- * For 2.1 I'll revisit this and try to make it more dynamic, but since
- * this will catch 99.99% of all possible cases, I'm not too worried.
- */
-#define MAX_CHUNKS 40
-
-/* Internal environment variable names */
-#define DISK_PARTITIONED "_diskPartitioned"
-#define DISK_LABELLED "_diskLabelled"
-#define DISK_SELECTED "_diskSelected"
-#define SYSTEM_STATE "_systemState"
-#define RUNNING_ON_ROOT "_runningOnRoot"
-#define TCP_CONFIGURED "_tcpConfigured"
-
-/* Ones that can be tweaked from config files */
-#define VAR_BLANKTIME "blanktime"
-#define VAR_BOOTMGR "bootManager"
-#define VAR_BROWSER_BINARY "browserBinary"
-#define VAR_BROWSER_PACKAGE "browserPackage"
-#define VAR_CPIO_VERBOSITY "cpioVerbose"
-#define VAR_DEBUG "debug"
-#define VAR_DESKSTYLE "_deskStyle"
-#define VAR_DISK "disk"
-#define VAR_DISTS "dists"
-#define VAR_DIST_MAIN "distMain"
-#define VAR_DIST_CRYPTO "distCRYPTO"
-#define VAR_DIST_SRC "distSRC"
-#define VAR_DIST_X11 "distX11"
-#define VAR_DIST_XSERVER "distXserver"
-#define VAR_DIST_XFONTS "distXfonts"
-#define VAR_DEDICATE_DISK "dedicateDisk"
-#define VAR_DOMAINNAME "domainname"
-#define VAR_EDITOR "editor"
-#define VAR_EXTRAS "ifconfig_"
-#define VAR_COMMAND "command"
-#define VAR_CONFIG_FILE "configFile"
-#define VAR_FTP_DIR "ftpDirectory"
-#define VAR_FTP_PASS "ftpPass"
-#define VAR_FTP_PATH "_ftpPath"
-#define VAR_FTP_PORT "ftpPort"
-#define VAR_FTP_STATE "ftpState"
-#define VAR_FTP_USER "ftpUser"
-#define VAR_FTP_HOST "ftpHost"
-#define VAR_HTTP_PATH "_httpPath"
-#define VAR_HTTP_PORT "httpPort"
-#define VAR_HTTP_HOST "httpHost"
-#define VAR_HTTP_FTP_MODE "httpFtpMode"
-#define VAR_GATEWAY "defaultrouter"
-#define VAR_GEOMETRY "geometry"
-#define VAR_HOSTNAME "hostname"
-#define VAR_IFCONFIG "ifconfig_"
-#define VAR_INTERFACES "network_interfaces"
-#define VAR_INSTALL_CFG "installConfig"
-#define VAR_INSTALL_ROOT "installRoot"
-#define VAR_IPADDR "ipaddr"
-#define VAR_KEYMAP "keymap"
-#define VAR_KGET "kget"
-#define VAR_LABEL "label"
-#define VAR_LABEL_COUNT "labelCount"
-#define VAR_LINUX_ENABLE "linux_enable"
-#define VAR_MEDIA_TYPE "mediaType"
-#define VAR_MEDIA_TIMEOUT "MEDIA_TIMEOUT"
-#define VAR_MOUSED "moused_enable"
-#define VAR_MOUSED_PORT "moused_port"
-#define VAR_MOUSED_TYPE "moused_type"
-#define VAR_NAMESERVER "nameserver"
-#define VAR_NETINTERACTIVE "netInteractive"
-#define VAR_NETMASK "netmask"
-#define VAR_NETWORK_DEVICE "netDev"
-#define VAR_NEWFS_ARGS "newfsArgs"
-#define VAR_NFS_PATH "nfs"
-#define VAR_NFS_HOST "nfsHost"
-#define VAR_NFS_SECURE "nfs_reserved_port_only"
-#define VAR_NFS_SERVER "nfs_server_enable"
-#define VAR_NO_CONFIRM "noConfirm"
-#define VAR_NO_ERROR "noError"
-#define VAR_NO_WARN "noWarn"
-#define VAR_NO_USR "noUsr"
-#define VAR_NONINTERACTIVE "nonInteractive"
-#define VAR_NOVELL "novell"
-#define VAR_NTPDATE_FLAGS "ntpdate_flags"
-#define VAR_PACKAGE "package"
-#define VAR_PARTITION "partition"
-#define VAR_PCNFSD "pcnfsd"
-#define VAR_PKG_TMPDIR "PKG_TMPDIR"
-#define VAR_PORTS_PATH "ports"
-#define VAR_PPP_ENABLE "ppp_enable"
-#define VAR_PPP_PROFILE "ppp_profile"
-#define VAR_RELNAME "releaseName"
-#define VAR_ROOT_SIZE "rootSize"
-#define VAR_ROUTER "router"
-#define VAR_ROUTER_ENABLE "router_enable"
-#define VAR_ROUTERFLAGS "router_flags"
-#define VAR_SERIAL_SPEED "serialSpeed"
-#define VAR_SLOW_ETHER "slowEthernetCard"
-#define VAR_SWAP_SIZE "swapSize"
-#define VAR_TAPE_BLOCKSIZE "tapeBlocksize"
-#define VAR_TRY_DHCP "tryDHCP"
-#define VAR_UFS_PATH "ufs"
-#define VAR_USR_SIZE "usrSize"
-#define VAR_VAR_SIZE "varSize"
-#define VAR_XF86_CONFIG "_xf86config"
-
-#define DEFAULT_TAPE_BLOCKSIZE "20"
-
-/* One MB worth of blocks */
-#define ONE_MEG 2048
-#define ONE_GIG (ONE_MEG * 1024)
-
-/* Which selection attributes to use */
-#define ATTR_SELECTED (ColorDisplay ? item_selected_attr : item_attr)
-#define ATTR_TITLE button_active_attr
-
-/* Handy strncpy() macro */
-#define SAFE_STRCPY(to, from) sstrncpy((to), (from), sizeof (to) - 1)
-
-/*** Types ***/
-typedef unsigned int Boolean;
-typedef struct disk Disk;
-typedef struct chunk Chunk;
-
-/* Bitfields for menu options */
-#define DMENU_NORMAL_TYPE 0x1 /* Normal dialog menu */
-#define DMENU_RADIO_TYPE 0x2 /* Radio dialog menu */
-#define DMENU_CHECKLIST_TYPE 0x4 /* Multiple choice menu */
-#define DMENU_SELECTION_RETURNS 0x8 /* Immediate return on item selection */
-
-typedef struct _dmenu {
- int type; /* What sort of menu we are */
- char *title; /* Our title */
- char *prompt; /* Our prompt */
- char *helpline; /* Line of help at bottom */
- char *helpfile; /* Help file for "F1" */
- dialogMenuItem items[0]; /* Array of menu items */
-} DMenu;
-
-/* An rc.conf variable */
-typedef struct _variable {
- struct _variable *next;
- char *name;
- char *value;
- int dirty;
-} Variable;
-
-#define NO_ECHO_OBJ(type) ((type) | (DITEM_NO_ECHO << 16))
-#define TYPE_OF_OBJ(type) ((type) & 0xff)
-#define ATTR_OF_OBJ(type) ((type) >> 16)
-
-/* A screen layout structure */
-typedef struct _layout {
- int y; /* x & Y co-ordinates */
- int x;
- int len; /* The size of the dialog on the screen */
- int maxlen; /* How much the user can type in ... */
- char *prompt; /* The string for the prompt */
- char *help; /* The display for the help line */
- void *var; /* The var to set when this changes */
- int type; /* The type of the dialog to create */
- void *obj; /* The obj pointer returned by libdialog */
-} Layout;
-
-typedef enum {
- DEVICE_TYPE_NONE,
- DEVICE_TYPE_DISK,
- DEVICE_TYPE_FLOPPY,
- DEVICE_TYPE_FTP,
- DEVICE_TYPE_NETWORK,
- DEVICE_TYPE_CDROM,
- DEVICE_TYPE_TAPE,
- DEVICE_TYPE_DOS,
- DEVICE_TYPE_UFS,
- DEVICE_TYPE_NFS,
- DEVICE_TYPE_ANY,
- DEVICE_TYPE_HTTP,
-} DeviceType;
-
-/* CDROM mount codes */
-#define CD_UNMOUNTED 0
-#define CD_ALREADY_MOUNTED 1
-#define CD_WE_MOUNTED_IT 2
-
-/* A "device" from sysinstall's point of view */
-typedef struct _device {
- char name[DEV_NAME_MAX];
- char *description;
- char *devname;
- DeviceType type;
- Boolean enabled;
- Boolean (*init)(struct _device *dev);
- FILE * (*get)(struct _device *dev, char *file, Boolean probe);
- void (*shutdown)(struct _device *dev);
- void *private;
- unsigned int flags;
-} Device;
-
-/* Some internal representations of partitions */
-typedef enum {
- PART_NONE,
- PART_SLICE,
- PART_SWAP,
- PART_FILESYSTEM,
- PART_FAT,
-} PartType;
-
-/* The longest newfs command we'll hand to system() */
-#define NEWFS_CMD_MAX 256
-
-typedef struct _part_info {
- Boolean newfs;
- char mountpoint[FILENAME_MAX];
- char newfs_cmd[NEWFS_CMD_MAX];
-} PartInfo;
-
-/* An option */
-typedef struct _opt {
- char *name;
- char *desc;
- enum { OPT_IS_STRING, OPT_IS_INT, OPT_IS_FUNC, OPT_IS_VAR } type;
- void *data;
- void *aux;
- char *(*check)();
-} Option;
-
-/* Weird index nodey things we use for keeping track of package information */
-typedef enum { PACKAGE, PLACE } node_type; /* Types of nodes */
-
-typedef struct _pkgnode { /* A node in the reconstructed hierarchy */
- struct _pkgnode *next; /* My next sibling */
- node_type type; /* What am I? */
- char *name; /* My name */
- char *desc; /* My description (Hook) */
- struct _pkgnode *kids; /* My little children */
- void *data; /* A place to hang my data */
-} PkgNode;
-typedef PkgNode *PkgNodePtr;
-
-/* A single package */
-typedef struct _indexEntry { /* A single entry in an INDEX file */
- char *name; /* name */
- char *path; /* full path to port */
- char *prefix; /* port prefix */
- char *comment; /* one line description */
- char *descrfile; /* path to description file */
- char *deps; /* packages this depends on */
- int depc; /* how many depend on me */
- int installed; /* indicates if it is installed */
- char *maintainer; /* maintainer */
-} IndexEntry;
-typedef IndexEntry *IndexEntryPtr;
-
-typedef int (*commandFunc)(char *key, void *data);
-
-#define HOSTNAME_FIELD_LEN 128
-#define IPADDR_FIELD_LEN 16
-#define EXTRAS_FIELD_LEN 128
-
-/* This is the structure that Network devices carry around in their private, erm, structures */
-typedef struct _devPriv {
- int use_dhcp;
- char ipaddr[IPADDR_FIELD_LEN];
- char netmask[IPADDR_FIELD_LEN];
- char extras[EXTRAS_FIELD_LEN];
-} DevInfo;
-
-
-/*** Externs ***/
-extern jmp_buf BailOut; /* Used to get the heck out */
-extern int DebugFD; /* Where diagnostic output goes */
-extern Boolean Fake; /* Don't actually modify anything - testing */
-extern Boolean SystemWasInstalled; /* Did we install it? */
-extern Boolean RunningAsInit; /* Are we running stand-alone? */
-extern Boolean DialogActive; /* Is the dialog() stuff up? */
-extern Boolean ColorDisplay; /* Are we on a color display? */
-extern Boolean OnVTY; /* On a syscons VTY? */
-Boolean USAResident; /* Are we cryptographically challenged? */
-extern Variable *VarHead; /* The head of the variable chain */
-extern Device *mediaDevice; /* Where we're getting our distribution from */
-extern unsigned int Dists; /* Which distributions we want */
-extern unsigned int CRYPTODists; /* Which naughty distributions we want */
-extern unsigned int SrcDists; /* Which src distributions we want */
-extern unsigned int XF86Dists; /* Which XFree86 dists we want */
-extern unsigned int XF86ServerDists; /* The XFree86 servers we want */
-extern unsigned int XF86FontDists; /* The XFree86 fonts we want */
-extern int BootMgr; /* Which boot manager to use */
-extern int StatusLine; /* Where to print our status messages */
-extern DMenu MenuInitial; /* Initial installation menu */
-extern DMenu MenuFixit; /* Fixit repair menu */
-extern DMenu MenuMBRType; /* Type of MBR to write on the disk */
-extern DMenu MenuConfigure; /* Final configuration menu */
-extern DMenu MenuDocumentation; /* Documentation menu */
-extern DMenu MenuFTPOptions; /* FTP Installation options */
-extern DMenu MenuIndex; /* Index menu */
-extern DMenu MenuOptions; /* Installation options */
-extern DMenu MenuOptionsLanguage; /* Language options menu */
-extern DMenu MenuMedia; /* Media type menu */
-extern DMenu MenuMouse; /* Mouse type menu */
-extern DMenu MenuMediaCDROM; /* CDROM media menu */
-extern DMenu MenuMediaDOS; /* DOS media menu */
-extern DMenu MenuMediaFloppy; /* Floppy media menu */
-extern DMenu MenuMediaFTP; /* FTP media menu */
-extern DMenu MenuMediaTape; /* Tape media menu */
-extern DMenu MenuNetworkDevice; /* Network device menu */
-extern DMenu MenuNTP; /* NTP time server menu */
-extern DMenu MenuStartup; /* Startup services menu */
-extern DMenu MenuSyscons; /* System console configuration menu */
-extern DMenu MenuSysconsFont; /* System console font configuration menu */
-extern DMenu MenuSysconsKeymap; /* System console keymap configuration menu */
-extern DMenu MenuSysconsKeyrate; /* System console keyrate configuration menu */
-extern DMenu MenuSysconsSaver; /* System console saver configuration menu */
-extern DMenu MenuSysconsScrnmap; /* System console screenmap configuration menu */
-extern DMenu MenuNetworking; /* Network configuration menu */
-extern DMenu MenuInstallCustom; /* Custom Installation menu */
-extern DMenu MenuDistributions; /* Distribution menu */
-extern DMenu MenuDiskDevices; /* Disk type devices */
-extern DMenu MenuSubDistributions; /* Custom distribution menu */
-extern DMenu MenuCRYPTODistributions;/* Encryption distribution menu */
-extern DMenu MenuSrcDistributions; /* Source distribution menu */
-extern DMenu MenuXF86; /* XFree86 main menu */
-extern DMenu MenuXF86Select; /* XFree86 distribution selection menu */
-extern DMenu MenuXF86SelectCore; /* XFree86 core distribution menu */
-extern DMenu MenuXF86SelectServer; /* XFree86 server distribution menu */
-extern DMenu MenuXF86SelectPC98Server; /* XFree86 server distribution menu */
-extern DMenu MenuXF86SelectFonts; /* XFree86 font selection menu */
-extern DMenu MenuXF86SelectFonts; /* XFree86 font selection menu */
-extern DMenu MenuXDesktops; /* Disk devices menu */
-extern DMenu MenuHTMLDoc; /* HTML Documentation menu */
-extern DMenu MenuUsermgmt; /* User management menu */
-extern DMenu MenuFixit; /* Fixit floppy/CDROM/shell menu */
-extern DMenu MenuXF86Config; /* Select XFree86 configuration type */
-
-/* Stuff from libdialog which isn't properly declared outside */
-extern void display_helpfile(void);
-extern void display_helpline(WINDOW *w, int y, int width);
-
-/*** Prototypes ***/
-
-/* anonFTP.c */
-extern int configAnonFTP(dialogMenuItem *self);
-
-/* cdrom.c */
-extern Boolean mediaInitCDROM(Device *dev);
-extern FILE *mediaGetCDROM(Device *dev, char *file, Boolean probe);
-extern void mediaShutdownCDROM(Device *dev);
-
-/* command.c */
-extern void command_clear(void);
-extern void command_sort(void);
-extern void command_execute(void);
-extern void command_shell_add(char *key, char *fmt, ...);
-extern void command_func_add(char *key, commandFunc func, void *data);
-
-/* config.c */
-extern void configEnvironmentRC_conf(void);
-extern void configEnvironmentResolv(char *config);
-extern void configRC_conf(void);
-extern void configMake_conf(char *config);
-extern int configFstab(dialogMenuItem *self);
-extern int configRC(dialogMenuItem *self);
-extern int configResolv(dialogMenuItem *self);
-extern int configPackages(dialogMenuItem *self);
-extern int configSaver(dialogMenuItem *self);
-extern int configSaverTimeout(dialogMenuItem *self);
-extern int configLinux(dialogMenuItem *self);
-extern int configNTP(dialogMenuItem *self);
-extern int configUsers(dialogMenuItem *self);
-extern int configXSetup(dialogMenuItem *self);
-extern int configXDesktop(dialogMenuItem *self);
-extern int configRouter(dialogMenuItem *self);
-extern int configPCNFSD(dialogMenuItem *self);
-extern int configNFSServer(dialogMenuItem *self);
-extern int configWriteRC_conf(dialogMenuItem *self);
-
-/* crc.c */
-extern int crc(int, unsigned long *, unsigned long *);
-
-/* devices.c */
-extern DMenu *deviceCreateMenu(DMenu *menu, DeviceType type, int (*hook)(dialogMenuItem *d),
- int (*check)(dialogMenuItem *d));
-extern void deviceGetAll(void);
-extern void deviceReset(void);
-extern void deviceRescan(void);
-extern Device **deviceFind(char *name, DeviceType type);
-extern Device **deviceFindDescr(char *name, char *desc, DeviceType class);
-extern int deviceCount(Device **devs);
-extern Device *new_device(char *name);
-extern Device *deviceRegister(char *name, char *desc, char *devname, DeviceType type, Boolean enabled,
- Boolean (*init)(Device *mediadev),
- FILE * (*get)(Device *dev, char *file, Boolean probe),
- void (*shutDown)(Device *mediadev),
- void *private);
-extern Boolean dummyInit(Device *dev);
-extern FILE *dummyGet(Device *dev, char *dist, Boolean probe);
-extern void dummyShutdown(Device *dev);
-
-/* dhcp.c */
-extern int dhcpParseLeases(char *file, char *hostname, char *domain, char *nameserver,
- char *ipaddr, char *gateway, char *netmask);
-
-/* disks.c */
-extern int diskPartitionEditor(dialogMenuItem *self);
-extern int diskPartitionWrite(dialogMenuItem *self);
-extern int diskGetSelectCount(Device ***devs);
-extern void diskPartition(Device *dev);
-
-/* dispatch.c */
-extern int dispatchCommand(char *command);
-extern int dispatch_load_floppy(dialogMenuItem *self);
-extern int dispatch_load_file_int(int);
-extern int dispatch_load_file(dialogMenuItem *self);
-
-
-/* dist.c */
-extern int distReset(dialogMenuItem *self);
-extern int distConfig(dialogMenuItem *self);
-extern int distSetCustom(dialogMenuItem *self);
-extern int distUnsetCustom(dialogMenuItem *self);
-extern int distSetDeveloper(dialogMenuItem *self);
-extern int distSetXDeveloper(dialogMenuItem *self);
-extern int distSetKernDeveloper(dialogMenuItem *self);
-extern int distSetXKernDeveloper(dialogMenuItem *self);
-extern int distSetUser(dialogMenuItem *self);
-extern int distSetXUser(dialogMenuItem *self);
-extern int distSetMinimum(dialogMenuItem *self);
-extern int distSetEverything(dialogMenuItem *self);
-extern int distSetCRYPTO(dialogMenuItem *self);
-extern int distSetSrc(dialogMenuItem *self);
-extern int distSetXF86(dialogMenuItem *self);
-extern int distExtractAll(dialogMenuItem *self);
-
-/* dmenu.c */
-extern int dmenuDisplayFile(dialogMenuItem *tmp);
-extern int dmenuSubmenu(dialogMenuItem *tmp);
-extern int dmenuSystemCommand(dialogMenuItem *tmp);
-extern int dmenuSystemCommandBox(dialogMenuItem *tmp);
-extern int dmenuExit(dialogMenuItem *tmp);
-extern int dmenuISetVariable(dialogMenuItem *tmp);
-extern int dmenuSetVariable(dialogMenuItem *tmp);
-extern int dmenuSetKmapVariable(dialogMenuItem *tmp);
-extern int dmenuSetVariables(dialogMenuItem *tmp);
-extern int dmenuToggleVariable(dialogMenuItem *tmp);
-extern int dmenuSetFlag(dialogMenuItem *tmp);
-extern int dmenuSetValue(dialogMenuItem *tmp);
-extern Boolean dmenuOpen(DMenu *menu, int *choice, int *scroll, int *curr, int *max, Boolean buttons);
-extern Boolean dmenuOpenSimple(DMenu *menu, Boolean buttons);
-extern int dmenuVarCheck(dialogMenuItem *item);
-extern int dmenuVarsCheck(dialogMenuItem *item);
-extern int dmenuFlagCheck(dialogMenuItem *item);
-extern int dmenuRadioCheck(dialogMenuItem *item);
-
-/* doc.c */
-extern int docBrowser(dialogMenuItem *self);
-extern int docShowDocument(dialogMenuItem *self);
-
-/* dos.c */
-extern Boolean mediaCloseDOS(Device *dev, FILE *fp);
-extern Boolean mediaInitDOS(Device *dev);
-extern FILE *mediaGetDOS(Device *dev, char *file, Boolean probe);
-extern void mediaShutdownDOS(Device *dev);
-
-/* floppy.c */
-extern int getRootFloppy(void);
-extern Boolean mediaInitFloppy(Device *dev);
-extern FILE *mediaGetFloppy(Device *dev, char *file, Boolean probe);
-extern void mediaShutdownFloppy(Device *dev);
-
-/* ftp_strat.c */
-extern Boolean mediaCloseFTP(Device *dev, FILE *fp);
-extern Boolean mediaInitFTP(Device *dev);
-extern FILE *mediaGetFTP(Device *dev, char *file, Boolean probe);
-extern void mediaShutdownFTP(Device *dev);
-
-/* http.c */
-extern Boolean mediaInitHTTP(Device *dev);
-extern FILE *mediaGetHTTP(Device *dev, char *file, Boolean probe);
-
-/* globals.c */
-extern void globalsInit(void);
-
-/* index.c */
-int index_read(FILE *fp, PkgNodePtr papa);
-int index_menu(PkgNodePtr root, PkgNodePtr top, PkgNodePtr plist, int *pos, int *scroll);
-void index_init(PkgNodePtr top, PkgNodePtr plist);
-void index_node_free(PkgNodePtr top, PkgNodePtr plist);
-void index_sort(PkgNodePtr top);
-void index_print(PkgNodePtr top, int level);
-int index_extract(Device *dev, PkgNodePtr top, PkgNodePtr who, Boolean depended);
-int index_initialize(char *path);
-PkgNodePtr index_search(PkgNodePtr top, char *str, PkgNodePtr *tp);
-
-/* install.c */
-extern Boolean checkLabels(Boolean whinge, Chunk **rdev, Chunk **sdev, Chunk **udev, Chunk **vdev);
-extern int installCommit(dialogMenuItem *self);
-extern int installCustomCommit(dialogMenuItem *self);
-extern int installExpress(dialogMenuItem *self);
-extern int installStandard(dialogMenuItem *self);
-extern int installFixitHoloShell(dialogMenuItem *self);
-extern int installFixitCDROM(dialogMenuItem *self);
-extern int installFixitFloppy(dialogMenuItem *self);
-extern int installFixupBin(dialogMenuItem *self);
-extern int installFixupXFree(dialogMenuItem *self);
-extern int installUpgrade(dialogMenuItem *self);
-extern int installFilesystems(dialogMenuItem *self);
-extern int installVarDefaults(dialogMenuItem *self);
-extern void installEnvironment(void);
-extern int installX11package(dialogMenuItem *self);
-extern Boolean copySelf(void);
-
-/* kget.c */
-extern int kget(char *out);
-
-/* keymap.c */
-extern int loadKeymap(const char *lang);
-
-/* label.c */
-extern int diskLabelEditor(dialogMenuItem *self);
-extern int diskLabelCommit(dialogMenuItem *self);
-
-/* lndir.c */
-extern int lndir(char *from, char *to);
-
-/* makedevs.c (auto-generated) */
-extern const char termcap_ansi[];
-extern const char termcap_vt100[];
-extern const char termcap_cons25[];
-extern const char termcap_cons25_m[];
-extern const char termcap_cons25r[];
-extern const char termcap_cons25r_m[];
-extern const char termcap_cons25l1[];
-extern const char termcap_cons25l1_m[];
-extern const u_char font_iso_8x16[];
-extern const u_char font_cp850_8x16[];
-extern const u_char font_cp866_8x16[];
-extern const u_char koi8_r2cp866[];
-extern u_char default_scrnmap[];
-
-/* media.c */
-extern char *cpioVerbosity(void);
-extern void mediaClose(void);
-extern int mediaTimeout(void);
-extern int mediaSetCDROM(dialogMenuItem *self);
-extern int mediaSetFloppy(dialogMenuItem *self);
-extern int mediaSetDOS(dialogMenuItem *self);
-extern int mediaSetTape(dialogMenuItem *self);
-extern int mediaSetFTP(dialogMenuItem *self);
-extern int mediaSetFTPActive(dialogMenuItem *self);
-extern int mediaSetFTPPassive(dialogMenuItem *self);
-extern int mediaSetHTTP(dialogMenuItem *self);
-extern int mediaSetUFS(dialogMenuItem *self);
-extern int mediaSetNFS(dialogMenuItem *self);
-extern int mediaSetFTPUserPass(dialogMenuItem *self);
-extern int mediaSetCPIOVerbosity(dialogMenuItem *self);
-extern int mediaGetType(dialogMenuItem *self);
-extern Boolean mediaExtractDist(char *dir, char *dist, FILE *fp);
-extern Boolean mediaExtractDistBegin(char *dir, int *fd, int *zpid, int *cpic);
-extern Boolean mediaExtractDistEnd(int zpid, int cpid);
-extern Boolean mediaVerify(void);
-extern FILE *mediaGenericGet(char *base, const char *file);
-
-/* misc.c */
-extern Boolean file_readable(char *fname);
-extern Boolean file_executable(char *fname);
-extern Boolean directory_exists(const char *dirname);
-extern char *root_bias(char *path);
-extern char *itoa(int value);
-extern char *string_concat(char *p1, char *p2);
-extern char *string_concat3(char *p1, char *p2, char *p3);
-extern char *string_prune(char *str);
-extern char *string_skipwhite(char *str);
-extern char *string_copy(char *s1, char *s2);
-extern char *pathBaseName(const char *path);
-extern void safe_free(void *ptr);
-extern void *safe_malloc(size_t size);
-extern void *safe_realloc(void *orig, size_t size);
-extern dialogMenuItem *item_add(dialogMenuItem *list, char *prompt, char *title,
- int (*checked)(dialogMenuItem *self),
- int (*fire)(dialogMenuItem *self),
- void (*selected)(dialogMenuItem *self, int is_selected),
- void *data, int aux, int *curr, int *max);
-extern void items_free(dialogMenuItem *list, int *curr, int *max);
-extern int Mkdir(char *);
-extern int Mount(char *, void *data);
-extern WINDOW *openLayoutDialog(char *helpfile, char *title, int x, int y, int width, int height);
-extern ComposeObj *initLayoutDialog(WINDOW *win, Layout *layout, int x, int y, int *max);
-extern int layoutDialogLoop(WINDOW *win, Layout *layout, ComposeObj **obj,
- int *n, int max, int *cbutton, int *cancel);
-
-extern WINDOW *savescr(void);
-extern void restorescr(WINDOW *w);
-extern char *sstrncpy(char *dst, const char *src, int size);
-
-/* mouse.c */
-extern int mousedTest(dialogMenuItem *self);
-extern int mousedDisable(dialogMenuItem *self);
-
-/* msg.c */
-extern Boolean isDebug(void);
-extern void msgInfo(char *fmt, ...);
-extern void msgYap(char *fmt, ...);
-extern void msgWarn(char *fmt, ...);
-extern void msgDebug(char *fmt, ...);
-extern void msgError(char *fmt, ...);
-extern void msgFatal(char *fmt, ...);
-extern void msgConfirm(char *fmt, ...);
-extern void msgNotify(char *fmt, ...);
-extern void msgWeHaveOutput(char *fmt, ...);
-extern int msgYesNo(char *fmt, ...);
-extern char *msgGetInput(char *buf, char *fmt, ...);
-extern int msgSimpleConfirm(char *);
-extern int msgSimpleNotify(char *);
-
-/* network.c */
-extern Boolean mediaInitNetwork(Device *dev);
-extern void mediaShutdownNetwork(Device *dev);
-
-/* nfs.c */
-extern Boolean mediaInitNFS(Device *dev);
-extern FILE *mediaGetNFS(Device *dev, char *file, Boolean probe);
-extern void mediaShutdownNFS(Device *dev);
-
-/* options.c */
-extern int optionsEditor(dialogMenuItem *self);
-
-/* package.c */
-extern int packageAdd(dialogMenuItem *self);
-extern int package_add(char *name);
-extern int package_extract(Device *dev, char *name, Boolean depended);
-extern Boolean package_exists(char *name);
-
-/* pccard.c */
-extern void pccardInitialize(void);
-
-/* system.c */
-extern void systemInitialize(int argc, char **argv);
-extern void systemShutdown(int status);
-extern int execExecute(char *cmd, char *name);
-extern int systemExecute(char *cmd);
-extern int systemDisplayHelp(char *file);
-extern char *systemHelpFile(char *file, char *buf);
-extern void systemChangeFont(const u_char font[]);
-extern void systemChangeLang(char *lang);
-extern void systemChangeTerminal(char *color, const u_char c_termcap[], char *mono, const u_char m_termcap[]);
-extern void systemChangeScreenmap(const u_char newmap[]);
-extern void systemCreateHoloshell(void);
-extern int vsystem(char *fmt, ...);
-
-/* tape.c */
-extern char *mediaTapeBlocksize(void);
-extern Boolean mediaInitTape(Device *dev);
-extern FILE *mediaGetTape(Device *dev, char *file, Boolean probe);
-extern void mediaShutdownTape(Device *dev);
-
-/* tcpip.c */
-extern int tcpOpenDialog(Device *dev);
-extern int tcpMenuSelect(dialogMenuItem *self);
-extern Device *tcpDeviceSelect(void);
-
-/* termcap.c */
-extern int set_termcap(void);
-
-/* ufs.c */
-extern void mediaShutdownUFS(Device *dev);
-extern Boolean mediaInitUFS(Device *dev);
-extern FILE *mediaGetUFS(Device *dev, char *file, Boolean probe);
-
-/* user.c */
-extern int userAddGroup(dialogMenuItem *self);
-extern int userAddUser(dialogMenuItem *self);
-
-/* variable.c */
-extern void variable_set(char *var, int dirty);
-extern void variable_set2(char *name, char *value, int dirty);
-extern char *variable_get(char *var);
-extern int variable_cmp(char *var, char *value);
-extern void variable_unset(char *var);
-extern char *variable_get_value(char *var, char *prompt, int dirty);
-extern int variable_check(char *data);
-extern int dump_variables(dialogMenuItem *self);
-
-/* wizard.c */
-extern void slice_wizard(Disk *d);
-
-#endif
-/* _SYSINSTALL_H_INCLUDE */
diff --git a/usr.sbin/sade/system.c b/usr.sbin/sade/system.c
deleted file mode 100644
index aaca07796441..000000000000
--- a/usr.sbin/sade/system.c
+++ /dev/null
@@ -1,413 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last program in the `sysinstall' line - the next
- * generation being essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Jordan Hubbard
- *
- * My contributions are in the public domain.
- *
- * Parts of this file are also blatently stolen from Poul-Henning Kamp's
- * previous version of sysinstall, and as such fall under his "BEERWARE license"
- * so buy him a beer if you like it! Buy him a beer for me, too!
- * Heck, get him completely drunk and send me pictures! :-)
- */
-
-#include "sysinstall.h"
-#include <signal.h>
-#include <termios.h>
-#include <sys/reboot.h>
-#include <machine/console.h>
-#include <sys/fcntl.h>
-#include <sys/ioctl.h>
-#include <sys/stat.h>
-
-
-/* Where we stick our temporary expanded doc file */
-#define DOC_TMP_DIR "/tmp/.doc"
-#define DOC_TMP_FILE "/tmp/.doc/doc.tmp"
-
-static pid_t ehs_pid;
-
-/*
- * Handle interrupt signals - this probably won't work in all cases
- * due to our having bogotified the internal state of dialog or curses,
- * but we'll give it a try.
- */
-static void
-handle_intr(int sig)
-{
- WINDOW *save = savescr();
-
- if (!msgYesNo("Are you sure you want to abort the installation?"))
- systemShutdown(-1);
- else
- restorescr(save);
-}
-
-/* Expand a file into a convenient location, nuking it each time */
-static char *
-expand(char *fname)
-{
- char *gunzip = RunningAsInit ? "/stand/gunzip" : "/usr/bin/gunzip";
-
- if (!directory_exists(DOC_TMP_DIR)) {
- Mkdir(DOC_TMP_DIR);
- if (chown(DOC_TMP_DIR, 0, 0) < 0)
- return NULL;
- if (chmod(DOC_TMP_DIR, S_IRWXU) < 0)
- return NULL;
- }
- else
- unlink(DOC_TMP_FILE);
- if (!file_readable(fname) || vsystem("%s < %s > %s", gunzip, fname, DOC_TMP_FILE))
- return NULL;
- return DOC_TMP_FILE;
-}
-
-/* Initialize system defaults */
-void
-systemInitialize(int argc, char **argv)
-{
- int i, boothowto;
-
- signal(SIGINT, SIG_IGN);
- globalsInit();
-
- i = sizeof(boothowto);
- if (!sysctlbyname("debug.boothowto", &boothowto, &i, NULL, NULL) &&
- (i == sizeof(boothowto)) && (boothowto & RB_VERBOSE))
- variable_set2(VAR_DEBUG, "YES", 0);
-
- /* Are we running as init? */
- if (getpid() == 1) {
- int fd, type;
-
- RunningAsInit = 1;
- setsid();
- close(0);
- fd = open("/dev/ttyv0", O_RDWR);
- if (fd == -1)
- fd = open("/dev/console", O_RDWR); /* fallback */
- else
- OnVTY = TRUE;
- /*
- * To make _sure_ we're on a VTY and don't have /dev/console switched
- * away to a serial port or something, attempt to set the cursor appearance.
- */
- type = 0; /* normal */
- if (OnVTY) {
- int fd2;
-
- if ((fd2 = open("/dev/console", O_RDWR)) != -1) {
- if (ioctl(fd2, CONS_CURSORTYPE, &type) == -1) {
- OnVTY = FALSE;
- close(fd); close(fd2);
- open("/dev/console", O_RDWR);
- }
- else
- close(fd2);
- }
- }
- close(1); dup(0);
- close(2); dup(0);
- printf("%s running as init on %s\n", argv[0], OnVTY ? "vty0" : "serial console");
- ioctl(0, TIOCSCTTY, (char *)NULL);
- setlogin("root");
- setenv("PATH", "/stand:/bin:/sbin:/usr/sbin:/usr/bin:/mnt/bin:/mnt/sbin:/mnt/usr/sbin:/mnt/usr/bin:/usr/X11R6/bin", 1);
- setbuf(stdin, 0);
- setbuf(stderr, 0);
-#ifdef __alpha__
- i = 0;
- sysctlbyname("machdep.unaligned_print", NULL, 0, &i, sizeof(i));
-#endif
- }
- else {
- char hname[256];
-
- /* Initalize various things for a multi-user environment */
- if (!gethostname(hname, sizeof hname))
- variable_set2(VAR_HOSTNAME, hname, 0);
- }
-
- if (set_termcap() == -1) {
- printf("Can't find terminal entry\n");
- exit(-1);
- }
-
- /* XXX - libdialog has particularly bad return value checking */
- init_dialog();
-
- /* If we haven't crashed I guess dialog is running ! */
- DialogActive = TRUE;
-
- /* Make sure HOME is set for those utilities that need it */
- if (!getenv("HOME"))
- setenv("HOME", "/", 1);
- signal(SIGINT, handle_intr);
- (void)vsystem("rm -rf %s", DOC_TMP_DIR);
-}
-
-/* Close down and prepare to exit */
-void
-systemShutdown(int status)
-{
- /* If some media is open, close it down */
- if (status >=0)
- mediaClose();
-
- /* write out any changes to rc.conf .. */
- configRC_conf();
-
- /* Shut down the dialog library */
- if (DialogActive) {
- end_dialog();
- DialogActive = FALSE;
- }
-
- /* Shut down curses */
- endwin();
-
- /* If we have a temporary doc dir lying around, nuke it */
- (void)vsystem("rm -rf %s", DOC_TMP_DIR);
-
- /* REALLY exit! */
- if (RunningAsInit) {
- /* Put the console back */
- ioctl(0, VT_ACTIVATE, 2);
-#ifdef __alpha__
- reboot(RB_HALT);
-#else
- reboot(0);
-#endif
- }
- else
- exit(status);
-}
-
-/* Run some general command */
-int
-systemExecute(char *command)
-{
- int status;
- struct termios foo;
- WINDOW *w = savescr();
-
- dialog_clear();
- dialog_update();
- end_dialog();
- DialogActive = FALSE;
- if (tcgetattr(0, &foo) != -1) {
- foo.c_cc[VERASE] = '\010';
- tcsetattr(0, TCSANOW, &foo);
- }
- if (!Fake)
- status = system(command);
- else {
- status = 0;
- msgDebug("systemExecute: Faked execution of `%s'\n", command);
- }
- DialogActive = TRUE;
- restorescr(w);
- return status;
-}
-
-/* Display a help file in a filebox */
-int
-systemDisplayHelp(char *file)
-{
- char *fname = NULL;
- char buf[FILENAME_MAX];
- int ret = 0;
- WINDOW *w = savescr();
-
- fname = systemHelpFile(file, buf);
- if (!fname) {
- snprintf(buf, FILENAME_MAX, "The %s file is not provided on this particular floppy image.", file);
- use_helpfile(NULL);
- use_helpline(NULL);
- dialog_mesgbox("Sorry!", buf, -1, -1);
- ret = 1;
- }
- else {
- use_helpfile(NULL);
- use_helpline(NULL);
- dialog_textbox(file, fname, LINES, COLS);
- }
- restorescr(w);
- return ret;
-}
-
-char *
-systemHelpFile(char *file, char *buf)
-{
- if (!file)
- return NULL;
- if (file[0] == '/')
- return file;
- snprintf(buf, FILENAME_MAX, "/stand/help/%s.hlp.gz", file);
- if (file_readable(buf))
- return expand(buf);
- snprintf(buf, FILENAME_MAX, "/stand/help/%s.TXT.gz", file);
- if (file_readable(buf))
- return expand(buf);
- snprintf(buf, FILENAME_MAX, "/usr/src/release/sysinstall/help/%s.hlp", file);
- if (file_readable(buf))
- return buf;
- snprintf(buf, FILENAME_MAX, "/usr/src/release/sysinstall/help/%s.TXT", file);
- if (file_readable(buf))
- return buf;
- return NULL;
-}
-
-void
-systemChangeTerminal(char *color, const u_char c_term[],
- char *mono, const u_char m_term[])
-{
- if (OnVTY) {
- int setupterm(char *color, int, int *);
-
- if (ColorDisplay) {
- setenv("TERM", color, 1);
- setenv("TERMCAP", c_term, 1);
- reset_shell_mode();
- setterm(color);
- cbreak(); noecho();
- }
- else {
- setenv("TERM", mono, 1);
- setenv("TERMCAP", m_term, 1);
- reset_shell_mode();
- setterm(mono);
- cbreak(); noecho();
- }
- }
- clear();
- refresh();
- dialog_clear();
-}
-
-int
-vsystem(char *fmt, ...)
-{
- va_list args;
- int pstat;
- pid_t pid;
- int omask;
- sig_t intsave, quitsave;
- char *cmd;
- int i;
-
- cmd = (char *)alloca(FILENAME_MAX);
- cmd[0] = '\0';
- va_start(args, fmt);
- vsnprintf(cmd, FILENAME_MAX, fmt, args);
- va_end(args);
-
- omask = sigblock(sigmask(SIGCHLD));
- if (Fake) {
- msgDebug("vsystem: Faked execution of `%s'\n", cmd);
- return 0;
- }
- if (isDebug())
- msgDebug("Executing command `%s'\n", cmd);
- pid = fork();
- if (pid == -1) {
- (void)sigsetmask(omask);
- i = 127;
- }
- else if (!pid) { /* Junior */
- (void)sigsetmask(omask);
- if (DebugFD != -1) {
- dup2(DebugFD, 0);
- dup2(DebugFD, 1);
- dup2(DebugFD, 2);
- }
- else {
- close(1); open("/dev/null", O_WRONLY);
- dup2(1, 2);
- }
- if (!RunningAsInit)
- execl("/bin/sh", "/bin/sh", "-c", cmd, (char *)NULL);
- else
- execl("/stand/sh", "/stand/sh", "-c", cmd, (char *)NULL);
- exit(1);
- }
- else {
- intsave = signal(SIGINT, SIG_IGN);
- quitsave = signal(SIGQUIT, SIG_IGN);
- pid = waitpid(pid, &pstat, 0);
- (void)sigsetmask(omask);
- (void)signal(SIGINT, intsave);
- (void)signal(SIGQUIT, quitsave);
- i = (pid == -1) ? -1 : WEXITSTATUS(pstat);
- if (isDebug())
- msgDebug("Command `%s' returns status of %d\n", cmd, i);
- }
- return i;
-}
-
-void
-systemCreateHoloshell(void)
-{
- if (OnVTY && RunningAsInit) {
-
- if (ehs_pid != 0) {
- int pstat;
-
- if (kill(ehs_pid, 0) == 0) {
-
- if (msgYesNo("There seems to be an emergency holographic shell\n"
- "already running on VTY 4.\n\n"
- "Kill it and start a new one?"))
- return;
-
- /* try cleaning up as much as possible */
- (void) kill(ehs_pid, SIGHUP);
- sleep(1);
- (void) kill(ehs_pid, SIGKILL);
- }
-
- /* avoid too many zombies */
- (void) waitpid(ehs_pid, &pstat, WNOHANG);
- }
-
- if ((ehs_pid = fork()) == 0) {
- int i, fd;
- struct termios foo;
- extern int login_tty(int);
-
- ioctl(0, TIOCNOTTY, NULL);
- for (i = getdtablesize(); i >= 0; --i)
- close(i);
- fd = open("/dev/ttyv3", O_RDWR);
- ioctl(0, TIOCSCTTY, &fd);
- dup2(0, 1);
- dup2(0, 2);
- DebugFD = 2;
- if (login_tty(fd) == -1)
- msgDebug("Doctor: I can't set the controlling terminal.\n");
- signal(SIGTTOU, SIG_IGN);
- if (tcgetattr(fd, &foo) != -1) {
- foo.c_cc[VERASE] = '\010';
- if (tcsetattr(fd, TCSANOW, &foo) == -1)
- msgDebug("Doctor: I'm unable to set the erase character.\n");
- }
- else
- msgDebug("Doctor: I'm unable to get the terminal attributes!\n");
- execlp("sh", "-sh", 0);
- msgDebug("Was unable to execute sh for Holographic shell!\n");
- exit(1);
- }
- else {
- WINDOW *w = savescr();
-
- msgNotify("Starting an emergency holographic shell on VTY4");
- sleep(2);
- restorescr(w);
- }
- }
-}
diff --git a/usr.sbin/sade/termcap.c b/usr.sbin/sade/termcap.c
deleted file mode 100644
index 15694790c91d..000000000000
--- a/usr.sbin/sade/termcap.c
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (c) 1994, Paul Richards.
- *
- * All rights reserved.
- *
- * This software may be used, modified, copied, distributed, and sold, in both
- * source and binary form provided that the above copyright and these terms
- * are retained, verbatim, as the first lines of this file. Under no
- * circumstances is the author responsible for the proper functioning of this
- * software, nor does the author assume any responsibility for damages
- * incurred with its use.
- */
-
-#include "sysinstall.h"
-#include <stdarg.h>
-#include <fcntl.h>
-#include <sys/errno.h>
-#include <sys/ioctl.h>
-#include <machine/console.h>
-
-#define VTY_STATUS_LINE 24
-#define TTY_STATUS_LINE 23
-
-static void
-prompt_term(char **termp, char **termcapp)
-{
- char str[80];
- static struct {
- const char *term, *termcap;
- } lookup[] = { { "ansi", termcap_ansi },
- { "vt100", termcap_vt100 },
- { "cons25", termcap_cons25 },
- { "cons25-m", termcap_cons25_m } };
-
- if (RunningAsInit) {
- while (1) {
- int i;
-
- printf("\nThese are the predefined terminal types available to\n");
- printf("sysinstall when running stand-alone. Please choose the\n");
- printf("closest match for your particular terminal.\n\n");
- printf("1 ...................... Standard ANSI terminal.\n");
- printf("2 ...................... VT100 or compatible terminal.\n");
- printf("3 ...................... FreeBSD system console (color).\n");
- printf("4 ...................... FreeBSD system console (monochrome).\n\n");
- printf("Your choice: (1-4) ");
- fflush(stdout);
- fgets(str, 80, stdin);
- i = str[0] - '0';
- if (i > 0 && i < 5) {
- *termp = (char *)lookup[i - 1].term;
- *termcapp = (char *)lookup[i - 1].termcap;
- break;
- }
- else
- printf("\007Invalid choice, please try again.\n\n");
- }
- }
- else {
- printf("\nPlease set your TERM variable before running this program.\n");
- printf("Defaulting to an ANSI compatible terminal - please press RETURN\n");
- fgets(str, 80, stdin); /* Just to make it interactive */
- *termp = (char *)"ansi";
- *termcapp = (char *)termcap_ansi;
- }
-}
-
-int
-set_termcap(void)
-{
- char *term;
- int stat;
- struct ttysize ts;
-
- term = getenv("TERM");
- stat = ioctl(STDERR_FILENO, GIO_COLOR, &ColorDisplay);
-
- if (!RunningAsInit) {
- if (getenv("SYSINSTALL_DEBUG"))
- DebugFD = open("sysinstall.debug", O_WRONLY|O_CREAT|O_TRUNC, 0644);
- else
- DebugFD = -1;
- if (DebugFD < 0)
- DebugFD = open("/dev/null", O_RDWR, 0);
- }
-
- if (!OnVTY || (stat < 0)) {
- if (!term) {
- char *term, *termcap;
-
- prompt_term(&term, &termcap);
- if (setenv("TERM", term, 1) < 0)
- return -1;
- if (setenv("TERMCAP", termcap, 1) < 0)
- return -1;
- }
- if (DebugFD < 0)
- DebugFD = open("/dev/null", O_RDWR, 0);
- }
- else {
- int i, on;
-
- if (getpid() == 1) {
- DebugFD = open("/dev/ttyv1", O_WRONLY);
- if (DebugFD != -1) {
- on = 1;
- i = ioctl(DebugFD, TIOCCONS, (char *)&on);
- msgDebug("ioctl(%d, TIOCCONS, NULL) = %d (%s)\n",
- DebugFD, i, !i ? "success" : strerror(errno));
- }
- }
- if (ColorDisplay) {
- if (!term) {
- if (setenv("TERM", "cons25", 1) < 0)
- return -1;
- if (setenv("TERMCAP", termcap_cons25, 1) < 0)
- return -1;
- }
- }
- else {
- if (!term) {
- if (setenv("TERM", "cons25-m", 1) < 0)
- return -1;
- if (setenv("TERMCAP", termcap_cons25_m, 1) < 0)
- return -1;
- }
- }
- }
- if (ioctl(0, TIOCGSIZE, &ts) == -1) {
- msgDebug("Unable to get terminal size - errno %d\n", errno);
- ts.ts_lines = 0;
- }
- StatusLine = ts.ts_lines ? ts.ts_lines - 1: (OnVTY ? VTY_STATUS_LINE : TTY_STATUS_LINE);
- return 0;
-}
diff --git a/usr.sbin/sade/variable.c b/usr.sbin/sade/variable.c
deleted file mode 100644
index bae7bc2e4103..000000000000
--- a/usr.sbin/sade/variable.c
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last program in the `sysinstall' line - the next
- * generation being essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 "sysinstall.h"
-
-/* Routines for dealing with variable lists */
-
-static void
-make_variable(char *var, char *value, int dirty)
-{
- Variable *vp;
-
- /* Trim leading and trailing whitespace */
- var = string_skipwhite(string_prune(var));
-
- if (!var || !*var)
- return;
-
-
- /* Now search to see if it's already in the list */
- for (vp = VarHead; vp; vp = vp->next) {
- if (!strcmp(vp->name, var)) {
- if (vp->dirty && !dirty)
- return;
- setenv(var, value, 1);
- free(vp->value);
- vp->value = strdup(value);
- if (dirty != -1)
- vp->dirty = dirty;
- return;
- }
- }
-
- setenv(var, value, 1);
- /* No? Create a new one */
- vp = (Variable *)safe_malloc(sizeof(Variable));
- vp->name = strdup(var);
- vp->value = strdup(value);
- if (dirty == -1)
- dirty = 0;
- vp->dirty = dirty;
- vp->next = VarHead;
- VarHead = vp;
-}
-
-void
-variable_set(char *var, int dirty)
-{
- char tmp[1024], *cp;
-
- if (!var)
- msgFatal("NULL variable name & value passed.");
- else if (!*var)
- msgDebug("Warning: Zero length name & value passed to variable_set()\n");
- SAFE_STRCPY(tmp, var);
- if ((cp = index(tmp, '=')) == NULL)
- msgFatal("Invalid variable format: %s", var);
- *(cp++) = '\0';
- make_variable(tmp, string_skipwhite(cp), dirty);
-}
-
-void
-variable_set2(char *var, char *value, int dirty)
-{
- if (!var || !value)
- msgFatal("Null name or value passed to set_variable2!");
- else if (!*var || !*value)
- msgDebug("Warning: Zero length name or value passed to variable_set2()\n");
- make_variable(var, value, dirty);
-}
-
-char *
-variable_get(char *var)
-{
- return getenv(var);
-}
-
-int
-variable_cmp(char *var, char *value)
-{
- char *val;
-
- if ((val = variable_get(var)))
- return strcmp(val, value);
- return -1;
-}
-
-void
-variable_unset(char *var)
-{
- Variable *vp;
- char name[512], *cp;
-
- if ((cp = index(var, '=')) != NULL)
- sstrncpy(name, var, cp - var);
- else
- SAFE_STRCPY(name, var);
- unsetenv(name);
- /* Now search to see if it's in our list, if we have one.. */
- if (!VarHead)
- return;
- else if (!VarHead->next && !strcmp(VarHead->name, name)) {
- safe_free(VarHead->name);
- safe_free(VarHead->value);
- free(VarHead);
- VarHead = NULL;
- }
- else {
- for (vp = VarHead; vp; vp = vp->next) {
- if (!strcmp(vp->name, name)) {
- Variable *save = vp->next;
-
- safe_free(vp->name);
- safe_free(vp->value);
- *vp = *save;
- safe_free(save);
- break;
- }
- }
- }
-}
-
-/* Prompt user for the name of a variable */
-char *
-variable_get_value(char *var, char *prompt, int dirty)
-{
- char *cp;
-
- cp = variable_get(var);
- if (cp && variable_get(VAR_NONINTERACTIVE))
- return cp;
- else if ((cp = msgGetInput(cp, prompt)) != NULL)
- variable_set2(var, cp, dirty);
- else
- cp = NULL;
- return cp;
-}
-
-/* Check if value passed in data (in the form "variable=value") is equal to value of
- variable stored in env */
-int
-variable_check(char *data)
-{
- char *cp, *cp2, *cp3, tmp[256];
-
- if (!data)
- return FALSE;
- SAFE_STRCPY(tmp, data);
- if ((cp = index(tmp, '=')) != NULL) {
- *(cp++) = '\0';
- if (*cp == '"') { /* smash quotes if present */
- ++cp;
- if ((cp3 = index(cp, '"')) != NULL)
- *cp3 = '\0';
- }
- else if ((cp3 = index(cp, ',')) != NULL)
- *cp3 = '\0';
- cp2 = variable_get(tmp);
- if (cp2) {
- if (!*cp)
- return TRUE;
- else
- return !strcmp(cp, cp2);
- }
- else
- return FALSE;
- }
- else
- return variable_get(tmp) ? TRUE : FALSE;
-}
-
-int
-dump_variables(dialogMenuItem *unused)
-{
- FILE *fp;
- Variable *vp;
-
- if (isDebug())
- msgDebug("Writing sysinstall variables to file..");
-
- fp = fopen("/etc/sysinstall.vars", "w");
- if (!fp) {
- msgConfirm("Unable to write to /etc/sysinstall.vars: %s",
- strerror(errno));
- return DITEM_FAILURE;
- }
-
- for (vp = VarHead; vp; vp = vp->next)
- fprintf(fp, "%s=\"%s\" (%d)\n", vp->name, vp->value, vp->dirty);
-
- fclose(fp);
-
- return DITEM_SUCCESS;
-}
diff --git a/usr.sbin/sade/wizard.c b/usr.sbin/sade/wizard.c
deleted file mode 100644
index 9fa1449e33f9..000000000000
--- a/usr.sbin/sade/wizard.c
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * ----------------------------------------------------------------------------
- * "THE BEER-WARE LICENSE" (Revision 42):
- * <phk@login.dknet.dk> wrote this file. As long as you retain this notice you
- * can do whatever you want with this stuff. If we meet some day, and you think
- * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
- * ----------------------------------------------------------------------------
- *
- * $FreeBSD$
- *
- */
-
-#include "sysinstall.h"
-#include <fcntl.h>
-#include <err.h>
-
-int
-scan_block(int fd, daddr_t block)
-{
- u_char foo[512];
-
- if (-1 == lseek(fd,block * 512,SEEK_SET))
- err(1,"lseek");
- if (512 != read(fd,foo, 512))
- return 1;
- return 0;
-}
-
-void
-Scan_Disk(Disk *d)
-{
- char device[64];
- u_long l;
- int i,j,fd;
-
- strcpy(device,"/dev/r");
- strcat(device,d->name);
-
- fd = open(device,O_RDWR);
- if (fd < 0) {
- msgWarn("open(%s) failed", device);
- return;
- }
- for(i=-1,l=0;;l++) {
- j = scan_block(fd,l);
- if (j != i) {
- if (i == -1) {
- printf("%c: %lu.",j ? 'B' : 'G', l);
- fflush(stdout);
- } else if (i == 0) {
- printf(".%lu\nB: %lu.",l-1,l);
- fflush(stdout);
- } else {
- printf(".%lu\nG: %lu.",l-1,l);
- fflush(stdout);
- }
- i = j;
- }
- }
- close(fd);
-}
-
-void
-slice_wizard(Disk *d)
-{
- Disk *db;
- char myprompt[BUFSIZ];
- char input[BUFSIZ];
- char *p,*q=0;
- char **cp,*cmds[200];
- int ncmd,i;
-
- sprintf(myprompt,"%s> ", d->name);
- while(1) {
- printf("--==##==--\n");
- Debug_Disk(d);
- p = CheckRules(d);
- if (p) {
- printf("%s",p);
- free(p);
- }
- printf(myprompt);
- fflush(stdout);
- q = p = fgets(input,sizeof(input),stdin);
- if(!p)
- break;
- for(cp = cmds; (*cp = strsep(&p, " \t\n")) != NULL;)
- if (**cp != '\0')
- cp++;
- ncmd = cp - cmds;
- if(!ncmd)
- continue;
- if (!strcasecmp(*cmds,"quit")) { break; }
- if (!strcasecmp(*cmds,"exit")) { break; }
- if (!strcasecmp(*cmds,"q")) { break; }
- if (!strcasecmp(*cmds,"x")) { break; }
- if (!strcasecmp(*cmds,"delete") && ncmd == 2) {
- printf("delete = %d\n",
- Delete_Chunk(d,
- (struct chunk *)strtol(cmds[1],0,0)));
- continue;
- }
- if (!strcasecmp(*cmds,"allfreebsd")) {
- All_FreeBSD(d, 0);
- continue;
- }
- if (!strcasecmp(*cmds,"dedicate")) {
- All_FreeBSD(d, 1);
- continue;
- }
- if (!strcasecmp(*cmds,"bios") && ncmd == 4) {
- Set_Bios_Geom(d,
- strtol(cmds[1],0,0),
- strtol(cmds[2],0,0),
- strtol(cmds[3],0,0));
- continue;
- }
- if (!strcasecmp(*cmds,"list")) {
- cp = Disk_Names();
- printf("Disks:");
- for(i=0;cp[i];i++) {
- printf(" %s",cp[i]);
- free(cp[i]);
- }
- free(cp);
- continue;
- }
- if (!strcasecmp(*cmds,"create") && ncmd == 6) {
-
- printf("Create=%d\n",
- Create_Chunk(d,
- strtol(cmds[1],0,0),
- strtol(cmds[2],0,0),
- strtol(cmds[3],0,0),
- strtol(cmds[4],0,0),
- strtol(cmds[5],0,0)));
- continue;
- }
- if (!strcasecmp(*cmds,"read")) {
- db = d;
- if (ncmd > 1)
- d = Open_Disk(cmds[1]);
- else
- d = Open_Disk(d->name);
- if (d)
- Free_Disk(db);
- else
- d = db;
- continue;
- }
- if (!strcasecmp(*cmds,"scan")) {
- Scan_Disk(d);
- continue;
- }
- if (!strcasecmp(*cmds,"write")) {
- printf("Write=%d\n",
- Fake ? 0 : Write_Disk(d));
- Free_Disk(d);
- d = Open_Disk(d->name);
- continue;
- }
- if (strcasecmp(*cmds,"help"))
- printf("\007ERROR\n");
- printf("CMDS:\n");
- printf("allfreebsd\t\t");
- printf("dedicate\t\t");
- printf("bios cyl hd sect\n");
- printf("collapse [pointer]\t\t");
- printf("create offset size enum subtype flags\n");
- printf("subtype(part): swap=1, ffs=7\t\t");
- printf("delete pointer\n");
- printf("list\t\t");
- printf("quit\n");
- printf("read [disk]\t\t");
- printf("scan\n");
- printf("write\t\t");
- printf("ENUM:\n\t");
- for(i=0;chunk_n[i];i++)
- printf("%d = %s%s",i,chunk_n[i],i == 4 ? "\n\t" : " ");
- printf("\n");
-
- }
-}
diff --git a/usr.sbin/sysinstall/Makefile b/usr.sbin/sysinstall/Makefile
deleted file mode 100644
index a433558389af..000000000000
--- a/usr.sbin/sysinstall/Makefile
+++ /dev/null
@@ -1,87 +0,0 @@
-PROG= sysinstall
-MAN8= sysinstall.8
-
-BINDIR=/stand
-NOSHARED=YES
-
-CLEANFILES+= makedevs.c rtermcap rtermcap.tmp dumpnlist
-CLEANFILES+= keymap.tmp keymap.h
-
-.PATH: ${.CURDIR}/../disklabel ${.CURDIR}/../../usr.bin/cksum
-
-SRCS= anonFTP.c cdrom.c command.c config.c devices.c dhcp.c kget.c \
- disks.c dispatch.c dist.c dmenu.c doc.c dos.c floppy.c \
- ftp.c globals.c http.c index.c install.c installUpgrade.c keymap.c \
- label.c lndir.c main.c makedevs.c media.c menus.c misc.c mouse.c \
- msg.c network.c nfs.c options.c package.c pccard.c \
- system.c tape.c tcpip.c termcap.c ufs.c user.c variable.c wizard.c \
- keymap.h
-
-CFLAGS+= -Wall -I${.CURDIR}/../../gnu/lib/libdialog -I${.OBJDIR}
-CFLAGS+= -I${.CURDIR}/../../sys
-.if ${MACHINE_ARCH} != "i386" || defined(X_AS_PKG)
-CFLAGS+= -DX_AS_PKG
-.endif
-
-DPADD= ${LIBDIALOG} ${LIBNCURSES} ${LIBMYTINFO} ${LIBUTIL} ${LIBDISK} ${LIBFTPIO}
-LDADD= -ldialog -lncurses -lmytinfo -lutil -ldisk -lftpio
-
-makedevs.c: Makefile rtermcap keymap.h
- rm -f makedevs.tmp
- echo '#include <sys/types.h>' > makedevs.tmp
- ./rtermcap ansi | \
- file2c 'const char termcap_ansi[] = {' ',0};' \
- >> makedevs.tmp
- ./rtermcap cons25 | \
- file2c 'const char termcap_cons25[] = {' ',0};' \
- >> makedevs.tmp
- ./rtermcap cons25-m | \
- file2c 'const char termcap_cons25_m[] = {' ',0};' \
- >> makedevs.tmp
- ./rtermcap cons25r | \
- file2c 'const char termcap_cons25r[] = {' ',0};' \
- >> makedevs.tmp
- ./rtermcap cons25r-m | \
- file2c 'const char termcap_cons25r_m[] = {' ',0};' \
- >> makedevs.tmp
- ./rtermcap cons25l1 | \
- file2c 'const char termcap_cons25l1[] = {' ',0};' \
- >> makedevs.tmp
- ./rtermcap cons25l1-m | \
- file2c 'const char termcap_cons25l1_m[] = {' ',0};' \
- >> makedevs.tmp
- ./rtermcap vt100 | \
- file2c 'const char termcap_vt100[] = {' ',0};' \
- >> makedevs.tmp
-.if ${MACHINE_ARCH} != "alpha"
- file2c 'u_char boot0[] = {' '};' < /boot/boot0 >> makedevs.tmp
- file2c 'u_char mbr[] = {' '};' < /boot/mbr >> makedevs.tmp
-.endif
- mv makedevs.tmp makedevs.c
-
-rtermcap: ${.CURDIR}/rtermcap.c
- ${CC} -o rtermcap ${.CURDIR}/rtermcap.c -ltermcap
-
-
-KEYMAPS= be.iso br275.iso danish.iso finnish.iso fr.iso \
- german.iso hr.iso hu.iso2.101keys it.iso icelandic.iso jp.106 \
- norwegian.iso pl_PL.ISO_8859-2 pt.iso ru.koi8-r si.iso \
- spanish.iso swedish.iso swissfrench.iso swissgerman.iso uk.iso \
- us.dvorak us.iso
-
-
-keymap.h:
- rm -f keymap.tmp
- for map in ${KEYMAPS} ; do \
- kbdcontrol -L $$map | \
- sed -e '/^static accentmap_t/,$$d' >> keymap.tmp ; \
- done
- echo "static struct keymapInfo keymapInfos[] = {" >> keymap.tmp
- for map in ${KEYMAPS} ; do \
- echo -n ' { "'$$map'", ' >> keymap.tmp ; \
- echo "&keymap_$$map }," | tr '[-.]' '_' >> keymap.tmp ; \
- done
- ( echo " { 0 }"; echo "};" ; echo "" ) >> keymap.tmp
- mv keymap.tmp keymap.h
-
-.include <bsd.prog.mk>
diff --git a/usr.sbin/sysinstall/anonFTP.c b/usr.sbin/sysinstall/anonFTP.c
deleted file mode 100644
index 70a07358212b..000000000000
--- a/usr.sbin/sysinstall/anonFTP.c
+++ /dev/null
@@ -1,314 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last program in the `sysinstall' line - the next
- * generation being essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Coranth Gryphon. All rights reserved.
- * Copyright (c) 1996
- * Jordan K. Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 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 OR THEIR PETS 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, LIFE 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 "sysinstall.h"
-#include <sys/param.h>
-#include <pwd.h>
-#include <grp.h>
-
-/* This doesn't change until FTP itself changes */
-
-#define FTP_NAME "ftp"
-#define MOTD_FILE "ftpmotd"
-
-/* These change if we want to use different defaults */
-
-#define FTP_UID 14
-#define FTP_GID 5
-#define FTP_GROUP "operator"
-#define FTP_UPLOAD "incoming"
-#define FTP_COMMENT "Anonymous FTP Admin"
-#define FTP_HOMEDIR "/var/ftp"
-
-#define ANONFTP_HELPFILE "anonftp"
-
-/* Set up the structure to hold configuration information */
-/* Note that this is only what we could fit onto the one screen */
-
-typedef struct
-{
- char homedir[64]; /* Home Dir for Anon FTP */
- char group[32]; /* Group */
- char uid[8]; /* UID */
- char comment[64]; /* PWD Comment */
- char upload[32]; /* Upload Dir */
-} FTPConf;
-
-static FTPConf tconf;
-
-#define ANONFTP_HOMEDIR_LEN 64
-#define ANONFTP_COMMENT_LEN 64
-#define ANONFTP_UPLOAD_LEN 32
-#define ANONFTP_GROUP_LEN 32
-#define ANONFTP_UID_LEN 8
-
-static int okbutton, cancelbutton;
-
-/* What the screen size is meant to be */
-#define ANONFTP_DIALOG_Y 0
-#define ANONFTP_DIALOG_X 8
-#define ANONFTP_DIALOG_WIDTH COLS - 16
-#define ANONFTP_DIALOG_HEIGHT LINES - 2
-
-static Layout layout[] = {
-#define LAYOUT_UID 0
- { 2, 3, 8, ANONFTP_UID_LEN - 1,
- "UID:", "What user ID to assign to FTP Admin",
- tconf.uid, STRINGOBJ, NULL },
-#define LAYOUT_GROUP 1
- { 2, 15, 15, ANONFTP_GROUP_LEN - 1,
- "Group:", "Group name that ftp process belongs to",
- tconf.group, STRINGOBJ, NULL },
-#define LAYOUT_COMMENT 2
- { 2, 35, 24, ANONFTP_COMMENT_LEN - 1,
- "Comment:", "Password file comment for FTP Admin",
- tconf.comment, STRINGOBJ, NULL },
-#define LAYOUT_HOMEDIR 3
- { 9, 10, 43, ANONFTP_HOMEDIR_LEN - 1,
- "FTP Root Directory:",
- "The top directory to chroot to when doing anonymous ftp",
- tconf.homedir, STRINGOBJ, NULL },
-#define LAYOUT_UPLOAD 4
- { 14, 20, 22, ANONFTP_UPLOAD_LEN - 1,
- "Upload Subdirectory:", "Designated sub-directory that holds uploads",
- tconf.upload, STRINGOBJ, NULL },
-#define LAYOUT_OKBUTTON 5
- { 19, 15, 0, 0,
- "OK", "Select this if you are happy with these settings",
- &okbutton, BUTTONOBJ, NULL },
-#define LAYOUT_CANCELBUTTON 6
- { 19, 35, 0, 0,
- "CANCEL", "Select this if you wish to cancel this screen",
- &cancelbutton, BUTTONOBJ, NULL },
- { NULL },
-};
-
-int
-createFtpUser(void)
-{
- struct passwd *tpw;
- struct group *tgrp;
- char pwline[256];
- char *tptr;
- int gid;
- FILE *fptr;
-
- if ((gid = atoi(tconf.group)) <= 0) {
- if (!(tgrp = getgrnam(tconf.group))) {
- /* group does not exist, create it by name */
-
- tptr = msgGetInput("14", "What group ID to use for group %s ?", tconf.group);
- if (tptr && *tptr && ((gid = atoi(tptr)) > 0)) {
- if ((fptr = fopen(_PATH_GROUP,"a"))) {
- fprintf(fptr,"%s:*:%d:%s\n",tconf.group,gid,FTP_NAME);
- fclose(fptr);
- }
- }
- else
- gid = FTP_GID;
- }
- else
- gid = tgrp->gr_gid;
- }
- else if (!getgrgid(gid)) {
- /* group does not exist, create it by number */
-
- tptr = msgGetInput("14", "What group name to use for gid %d ?", gid);
- if (tptr && *tptr) {
- SAFE_STRCPY(tconf.group, tptr);
- if ((tgrp = getgrnam(tconf.group))) {
- gid = tgrp->gr_gid;
- }
- else if ((fptr = fopen(_PATH_GROUP,"a"))) {
- fprintf(fptr,"%s:*:%d:%s\n",tconf.group,gid,FTP_NAME);
- fclose(fptr);
- }
- }
- }
-
- if ((tpw = getpwnam(FTP_NAME))) {
- if (tpw->pw_uid != FTP_UID)
- msgConfirm("FTP user already exists with a different uid.");
-
- return DITEM_SUCCESS; /* succeeds if already exists */
- }
-
- sprintf(pwline, "%s:*:%s:%d::0:0:%s:%s:/nonexistent\n", FTP_NAME, tconf.uid, gid, tconf.comment, tconf.homedir);
-
- fptr = fopen(_PATH_MASTERPASSWD,"a");
- if (! fptr) {
- msgConfirm("Could not open master password file.");
- return DITEM_FAILURE;
- }
- fprintf(fptr, pwline);
- fclose(fptr);
- msgNotify("Remaking password file: %s", _PATH_MASTERPASSWD);
- vsystem("pwd_mkdb -p %s", _PATH_MASTERPASSWD);
- return DITEM_SUCCESS | DITEM_RESTORE;
-}
-
-/* This is it - how to get the setup values */
-static int
-anonftpOpenDialog(void)
-{
- WINDOW *ds_win;
- ComposeObj *obj = NULL;
- int n = 0, cancel = FALSE;
- int max;
- char title[80];
- WINDOW *w = savescr();
-
- /* We need a curses window */
- if (!(ds_win = openLayoutDialog(ANONFTP_HELPFILE, " Anonymous FTP Configuration ",
- ANONFTP_DIALOG_X, ANONFTP_DIALOG_Y, ANONFTP_DIALOG_WIDTH, ANONFTP_DIALOG_HEIGHT))) {
- beep();
- msgConfirm("Cannot open anonymous ftp dialog window!!");
- restorescr(w);
- return DITEM_FAILURE;
- }
-
- /* Draw a sub-box for the path configuration */
- draw_box(ds_win, ANONFTP_DIALOG_Y + 7, ANONFTP_DIALOG_X + 8,
- ANONFTP_DIALOG_HEIGHT - 11, ANONFTP_DIALOG_WIDTH - 17,
- dialog_attr, border_attr);
- wattrset(ds_win, dialog_attr);
- sprintf(title, " Path Configuration ");
- mvwaddstr(ds_win, ANONFTP_DIALOG_Y + 7, ANONFTP_DIALOG_X + 22, title);
-
- /** Initialize the config Data Structure **/
- bzero(&tconf, sizeof(tconf));
-
- SAFE_STRCPY(tconf.group, FTP_GROUP);
- SAFE_STRCPY(tconf.upload, FTP_UPLOAD);
- SAFE_STRCPY(tconf.comment, FTP_COMMENT);
- SAFE_STRCPY(tconf.homedir, FTP_HOMEDIR);
- sprintf(tconf.uid, "%d", FTP_UID);
-
- /* Some more initialisation before we go into the main input loop */
- obj = initLayoutDialog(ds_win, layout, ANONFTP_DIALOG_X, ANONFTP_DIALOG_Y, &max);
-
- cancelbutton = okbutton = 0;
- while (layoutDialogLoop(ds_win, layout, &obj, &n, max, &cancelbutton, &cancel));
-
- /* Clear this crap off the screen */
- delwin(ds_win);
- use_helpfile(NULL);
- restorescr(w);
- if (cancel)
- return DITEM_FAILURE;
- return DITEM_SUCCESS;
-}
-
-int
-configAnonFTP(dialogMenuItem *self)
-{
- int i;
-
- /* Be optimistic */
- i = DITEM_SUCCESS;
-
- i = anonftpOpenDialog();
- if (DITEM_STATUS(i) != DITEM_SUCCESS) {
- msgConfirm("Configuration of Anonymous FTP cancelled per user request.");
- return i;
- }
-
- /*** Use defaults for any invalid values ***/
- if (atoi(tconf.uid) <= 0)
- sprintf(tconf.uid, "%d", FTP_UID);
-
- if (!tconf.group[0])
- SAFE_STRCPY(tconf.group, FTP_GROUP);
-
- if (!tconf.upload[0])
- SAFE_STRCPY(tconf.upload, FTP_UPLOAD);
-
- /*** If the user did not specify a directory, use default ***/
-
- if (tconf.homedir[strlen(tconf.homedir) - 1] == '/')
- tconf.homedir[strlen(tconf.homedir) - 1] = '\0';
-
- if (!tconf.homedir[0])
- SAFE_STRCPY(tconf.homedir, FTP_HOMEDIR);
-
- /*** If HomeDir does not exist, create it ***/
-
- if (!directory_exists(tconf.homedir))
- vsystem("mkdir -p %s", tconf.homedir);
-
- if (directory_exists(tconf.homedir)) {
- msgNotify("Configuring %s for use by anon FTP.", tconf.homedir);
- vsystem("chmod 555 %s && chown root.%s %s", tconf.homedir, tconf.group, tconf.homedir);
- vsystem("mkdir %s/bin && chmod 555 %s/bin", tconf.homedir, tconf.homedir);
- vsystem("cp /bin/ls %s/bin && chmod 111 %s/bin/ls", tconf.homedir, tconf.homedir);
- vsystem("cp /bin/date %s/bin && chmod 111 %s/bin/date", tconf.homedir, tconf.homedir);
- vsystem("mkdir %s/etc && chmod 555 %s/etc", tconf.homedir, tconf.homedir);
- vsystem("mkdir -p %s/pub", tconf.homedir);
- vsystem("mkdir -p %s/%s", tconf.homedir, tconf.upload);
- vsystem("chmod 1777 %s/%s", tconf.homedir, tconf.upload);
-
- if (DITEM_STATUS(createFtpUser()) == DITEM_SUCCESS) {
- msgNotify("Copying password information for anon FTP.");
- vsystem("awk -F: '{if ($3 < 10 || $1 == \"ftp\") print $0}' /etc/passwd > %s/etc/passwd && chmod 444 %s/etc/passwd", tconf.homedir, tconf.homedir);
- vsystem("awk -F: '{if ($3 < 100) print $0}' /etc/group > %s/etc/group && chmod 444 %s/etc/group", tconf.homedir, tconf.homedir);
- vsystem("chown -R root.%s %s/pub", tconf.group, tconf.homedir);
- }
- else {
- msgConfirm("Unable to create FTP user! Anonymous FTP setup failed.");
- i = DITEM_FAILURE;
- }
-
- if (!msgYesNo("Create a welcome message file for anonymous FTP users?")) {
- char cmd[256];
- vsystem("echo Your welcome message here. > %s/etc/%s", tconf.homedir, MOTD_FILE);
- sprintf(cmd, "%s %s/etc/%s", variable_get(VAR_EDITOR), tconf.homedir, MOTD_FILE);
- if (!systemExecute(cmd))
- i = DITEM_SUCCESS;
- else
- i = DITEM_FAILURE;
- }
- }
- else {
- msgConfirm("Invalid Directory: %s\n"
- "Anonymous FTP will not be set up.", tconf.homedir);
- i = DITEM_FAILURE;
- }
- if (DITEM_STATUS(i) == DITEM_SUCCESS)
- variable_set2("anon_ftp", "YES", 0);
- return i | DITEM_RESTORE;
-}
diff --git a/usr.sbin/sysinstall/cdrom.c b/usr.sbin/sysinstall/cdrom.c
deleted file mode 100644
index 0b8829dc5497..000000000000
--- a/usr.sbin/sysinstall/cdrom.c
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last attempt in the `sysinstall' line, the next
- * generation being slated to essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. All rights reserved.
- * Copyright (c) 1995
- * Gary J Palmer. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 routines deal with getting things off of CDROM media */
-
-#include "sysinstall.h"
-#include <sys/stat.h>
-#include <sys/errno.h>
-#include <sys/param.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <grp.h>
-#include <fcntl.h>
-#include <libutil.h>
-
-#define CD9660
-#include <sys/mount.h>
-#include <isofs/cd9660/cd9660_mount.h>
-#undef CD9660
-
-static Boolean cdromMounted;
-static char mountpoint[] = "/dist";
-
-static properties
-read_props(char *name)
-{
- int fd;
- properties n;
-
- fd = open(name, O_RDONLY);
- if (fd == -1)
- return NULL;
- n = properties_read(fd);
- close(fd);
- return n;
-}
-
-Boolean
-mediaInitCDROM(Device *dev)
-{
- struct iso_args args;
- properties cd_attr = NULL;
- char *cp = NULL;
- Boolean readInfo = TRUE;
- static Boolean bogusCDOK = FALSE;
-
- if (cdromMounted)
- return TRUE;
-
- Mkdir(mountpoint);
- bzero(&args, sizeof(args));
- args.fspec = dev->devname;
- args.flags = 0;
- if (mount("cd9660", mountpoint, MNT_RDONLY, (caddr_t) &args) == -1) {
- if (errno == EINVAL) {
- msgConfirm("The CD in your drive looks more like an Audio CD than a FreeBSD release.");
- return FALSE;
- }
- else if (errno != EBUSY) {
- msgConfirm("Error mounting %s on %s: %s (%u)", dev->devname, mountpoint, strerror(errno), errno);
- return FALSE;
- }
- }
- cdromMounted = TRUE;
-
- if (!file_readable(string_concat(mountpoint, "/cdrom.inf")) && !bogusCDOK) {
- if (msgYesNo("Warning: The CD currently in the drive is either not a FreeBSD\n"
- "CD or it is an older (pre 2.1.5) FreeBSD CD which does not\n"
- "have a version number on it. Do you wish to use this CD anyway?") != 0) {
- unmount(mountpoint, MNT_FORCE);
- cdromMounted = FALSE;
- return FALSE;
- }
- else {
- readInfo = FALSE;
- bogusCDOK = TRUE;
- }
- }
-
- if (readInfo) {
- if (!(cd_attr = read_props(string_concat(mountpoint, "/cdrom.inf")))
- || !(cp = property_find(cd_attr, "CD_VERSION"))) {
- msgConfirm("Unable to find a %s/cdrom.inf file.\n"
- "Either this is not a FreeBSD CDROM, there is a problem with\n"
- "the CDROM driver or something is wrong with your hardware.\n"
- "Please fix this problem (check the console logs on VTY2) and\n"
- "try again.", mountpoint);
- }
- else {
- if (variable_cmp(VAR_RELNAME, cp)
- && variable_cmp(VAR_RELNAME, "none")
- && variable_cmp(VAR_RELNAME, "any") && !bogusCDOK) {
- msgConfirm("Warning: The version of the FreeBSD CD currently in the drive\n"
- "(%s) does not match the version of the boot floppy\n"
- "(%s).\n\n"
- "If this is intentional, to avoid this message in the future\n"
- "please visit the Options editor to set the boot floppy version\n"
- "string to match that of the CD before selecting it as your\n"
- "installation media.", cp, variable_get(VAR_RELNAME));
-
- if (msgYesNo("Would you like to try and use this CDROM anyway?") != 0) {
- unmount(mountpoint, MNT_FORCE);
- cdromMounted = FALSE;
- properties_free(cd_attr);
- return FALSE;
- }
- else
- bogusCDOK = TRUE;
- }
- if ((cp = property_find(cd_attr, "CD_MACHINE_ARCH")) != NULL) {
-#ifdef __alpha__
- if (strcmp(cp, "alpha")) {
-#else
- if (strcmp(cp, "x86")) {
-#endif
- msgConfirm("Fatal: The FreeBSD install CD currently in the drive\n"
- "is for the %s architecture, not the machine you're using.\n\n"
-
- "Please use the correct installation CD for your machine type.", cp);
-
- unmount(mountpoint, MNT_FORCE);
- cdromMounted = FALSE;
- properties_free(cd_attr);
- return FALSE;
- }
- }
- }
- }
- if (cd_attr)
- properties_free(cd_attr);
- return TRUE;
-}
-
-FILE *
-mediaGetCDROM(Device *dev, char *file, Boolean probe)
-{
- return mediaGenericGet(mountpoint, file);
-}
-
-void
-mediaShutdownCDROM(Device *dev)
-{
- if (!cdromMounted)
- return;
-
- if (unmount(mountpoint, MNT_FORCE) != 0)
- msgConfirm("Could not unmount the CDROM from %s: %s", mountpoint, strerror(errno));
- else
- cdromMounted = FALSE;
-}
diff --git a/usr.sbin/sysinstall/command.c b/usr.sbin/sysinstall/command.c
deleted file mode 100644
index 3e3d5c97187d..000000000000
--- a/usr.sbin/sysinstall/command.c
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last program in the `sysinstall' line - the next
- * generation being essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 "sysinstall.h"
-
-#define MAX_NUM_COMMANDS 10
-
-typedef struct {
- char key[FILENAME_MAX];
- struct {
- enum { CMD_SHELL, CMD_FUNCTION } type;
- void *ptr, *data;
- } cmds[MAX_NUM_COMMANDS];
- int ncmds;
-} Command;
-
-#define MAX_CMDS 200
-static Command *commandStack[MAX_CMDS];
-int numCommands;
-
-/* Nuke the command stack */
-void
-command_clear(void)
-{
- int i, j;
-
- for (i = 0; i < numCommands; i++)
- for (j = 0; j < commandStack[i]->ncmds; j++)
- if (commandStack[i]->cmds[j].type == CMD_SHELL)
- free(commandStack[i]->cmds[j].ptr);
- free(commandStack[i]);
- numCommands = 0;
-}
-
-static void
-addit(char *key, int type, void *cmd, void *data)
-{
- int i;
-
- /* First, look for the key already present and add a command to it if found */
- for (i = 0; i < numCommands; i++) {
- if (!strcmp(commandStack[i]->key, key)) {
- if (commandStack[i]->ncmds == MAX_NUM_COMMANDS)
- msgFatal("More than %d commands stacked up behind %s??", MAX_NUM_COMMANDS, key);
- commandStack[i]->cmds[commandStack[i]->ncmds].type = type;
- commandStack[i]->cmds[commandStack[i]->ncmds].ptr = cmd;
- commandStack[i]->cmds[commandStack[i]->ncmds].data = data;
- ++(commandStack[i]->ncmds);
- return;
- }
- }
- if (numCommands == MAX_CMDS)
- msgFatal("More than %d commands accumulated??", MAX_CMDS);
-
- /* If we fell to here, it's a new key */
- commandStack[numCommands] = safe_malloc(sizeof(Command));
- strcpy(commandStack[numCommands]->key, key);
- commandStack[numCommands]->ncmds = 1;
- commandStack[numCommands]->cmds[0].type = type;
- commandStack[numCommands]->cmds[0].ptr = cmd;
- commandStack[numCommands]->cmds[0].data = data;
- ++numCommands;
-}
-
-/* Add a shell command under a given key */
-void
-command_shell_add(char *key, char *fmt, ...)
-{
- va_list args;
- char *cmd;
-
- cmd = (char *)safe_malloc(256);
- va_start(args, fmt);
- vsnprintf(cmd, 256, fmt, args);
- va_end(args);
-
- addit(key, CMD_SHELL, cmd, NULL);
-}
-
-/* Add a shell command under a given key */
-void
-command_func_add(char *key, commandFunc func, void *data)
-{
- addit(key, CMD_FUNCTION, func, data);
-}
-
-static int
-sort_compare(Command *p1, Command *p2)
-{
- if (!p1 && !p2)
- return 0;
- else if (!p1 && p2) /* NULL has a "greater" value for commands */
- return 1;
- else if (p1 && !p2)
- return -1;
- else
- return strcmp(p1->key, p2->key);
-}
-
-void
-command_sort(void)
-{
- int i, j;
-
- commandStack[numCommands] = NULL;
- /* Just do a crude bubble sort since the list is small */
- for (i = 0; i < numCommands; i++) {
- for (j = 0; j < numCommands; j++) {
- if (sort_compare(commandStack[j], commandStack[j + 1]) > 0) {
- Command *tmp = commandStack[j];
-
- commandStack[j] = commandStack[j + 1];
- commandStack[j + 1] = tmp;
- }
- }
- }
-}
-
-/* Run all accumulated commands in sorted order */
-void
-command_execute(void)
-{
- int i, j, ret;
- commandFunc func;
-
- for (i = 0; i < numCommands; i++) {
- for (j = 0; j < commandStack[i]->ncmds; j++) {
- /* If it's a shell command, run system on it */
- if (commandStack[i]->cmds[j].type == CMD_SHELL) {
- msgNotify("Doing %s", commandStack[i]->cmds[j].ptr);
- ret = vsystem((char *)commandStack[i]->cmds[j].ptr);
- if (isDebug())
- msgDebug("Command `%s' returns status %d\n", commandStack[i]->cmds[j].ptr, ret);
- }
- else {
- /* It's a function pointer - call it with the key and the data */
- func = (commandFunc)commandStack[i]->cmds[j].ptr;
- if (isDebug())
- msgDebug("%x: Execute(%s, %s)", func, commandStack[i]->key, commandStack[i]->cmds[j].data);
- ret = (*func)(commandStack[i]->key, commandStack[i]->cmds[j].data);
- if (isDebug())
- msgDebug("Function @ %x returns status %d\n", commandStack[i]->cmds[j].ptr, ret);
- }
- }
- }
-}
diff --git a/usr.sbin/sysinstall/config.c b/usr.sbin/sysinstall/config.c
deleted file mode 100644
index cc4cbd2e3102..000000000000
--- a/usr.sbin/sysinstall/config.c
+++ /dev/null
@@ -1,880 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last program in the `sysinstall' line - the next
- * generation being essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 "sysinstall.h"
-#include <sys/disklabel.h>
-#include <sys/wait.h>
-#include <sys/errno.h>
-#include <sys/ioctl.h>
-#include <sys/fcntl.h>
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <sys/mount.h>
-
-static Chunk *chunk_list[MAX_CHUNKS];
-static int nchunks;
-static int rootdev_is_od;
-
-/* arg to sort */
-static int
-chunk_compare(Chunk *c1, Chunk *c2)
-{
- if (!c1 && !c2)
- return 0;
- else if (!c1 && c2)
- return 1;
- else if (c1 && !c2)
- return -1;
- else if (!c1->private_data && !c2->private_data)
- return 0;
- else if (c1->private_data && !c2->private_data)
- return 1;
- else if (!c1->private_data && c2->private_data)
- return -1;
- else
- return strcmp(((PartInfo *)(c1->private_data))->mountpoint, ((PartInfo *)(c2->private_data))->mountpoint);
-}
-
-static void
-chunk_sort(void)
-{
- int i, j;
-
- for (i = 0; i < nchunks; i++) {
- for (j = 0; j < nchunks; j++) {
- if (chunk_compare(chunk_list[j], chunk_list[j + 1]) > 0) {
- Chunk *tmp = chunk_list[j];
-
- chunk_list[j] = chunk_list[j + 1];
- chunk_list[j + 1] = tmp;
- }
- }
- }
-}
-
-static void
-check_rootdev(Chunk **list, int n)
-{
- int i;
- Chunk *c;
-
- rootdev_is_od = 0;
- for (i = 0; i < n; i++) {
- c = *list++;
- if (c->type == part && (c->flags & CHUNK_IS_ROOT)
- && strncmp(c->disk->name, "od", 2) == 0)
- rootdev_is_od = 1;
- }
-}
-
-static char *
-name_of(Chunk *c1)
-{
- return c1->name;
-}
-
-static char *
-mount_point(Chunk *c1)
-{
- if (c1->type == part && c1->subtype == FS_SWAP)
- return "none";
- else if (c1->type == part || c1->type == fat)
- return ((PartInfo *)c1->private_data)->mountpoint;
- return "/bogus";
-}
-
-static char *
-fstype(Chunk *c1)
-{
- if (c1->type == fat)
- return "msdos";
- else if (c1->type == part) {
- if (c1->subtype != FS_SWAP)
- return "ufs";
- else
- return "swap";
- }
- return "bogus";
-}
-
-static char *
-fstype_short(Chunk *c1)
-{
- if (c1->type == part) {
- if (c1->subtype != FS_SWAP) {
- if (rootdev_is_od == 0 && strncmp(c1->name, "od", 2) == 0)
- return "rw,noauto";
- else
- return "rw";
- }
- else
- return "sw";
- }
- else if (c1->type == fat) {
- if (strncmp(c1->name, "od", 2) == 0)
- return "ro,noauto";
- else
- return "ro";
- }
- return "bog";
-}
-
-static int
-seq_num(Chunk *c1)
-{
- if (c1->type == part && c1->subtype != FS_SWAP) {
- if (rootdev_is_od == 0 && strncmp(c1->name, "od", 2) == 0)
- return 0;
- else if (c1->flags & CHUNK_IS_ROOT)
- return 1;
- else
- return 2;
- }
- return 0;
-}
-
-int
-configFstab(dialogMenuItem *self)
-{
- Device **devs;
- Disk *disk;
- FILE *fstab;
- int i, cnt;
- Chunk *c1, *c2;
-
- if (!RunningAsInit) {
- if (file_readable("/etc/fstab"))
- return DITEM_SUCCESS;
- else {
- msgConfirm("Attempting to rebuild your /etc/fstab file. Warning: If you had\n"
- "any CD devices in use before running sysinstall then they may NOT\n"
- "be found by this run!");
- }
- }
-
- devs = deviceFind(NULL, DEVICE_TYPE_DISK);
- if (!devs) {
- msgConfirm("No disks found!");
- return DITEM_FAILURE;
- }
-
- /* Record all the chunks */
- nchunks = 0;
- for (i = 0; devs[i]; i++) {
- if (!devs[i]->enabled)
- continue;
- disk = (Disk *)devs[i]->private;
- if (!disk->chunks)
- msgFatal("No chunk list found for %s!", disk->name);
- for (c1 = disk->chunks->part; c1; c1 = c1->next) {
- if (c1->type == freebsd) {
- for (c2 = c1->part; c2; c2 = c2->next) {
- if (c2->type == part && (c2->subtype == FS_SWAP || c2->private_data))
- chunk_list[nchunks++] = c2;
- }
- }
- else if (c1->type == fat && c1->private_data)
- chunk_list[nchunks++] = c1;
- }
- }
- chunk_list[nchunks] = 0;
- chunk_sort();
-
- fstab = fopen("/etc/fstab", "w");
- if (!fstab) {
- msgConfirm("Unable to create a new /etc/fstab file! Manual intervention\n"
- "will be required.");
- return DITEM_FAILURE;
- }
-
- check_rootdev(chunk_list, nchunks);
-
- /* Go for the burn */
- msgDebug("Generating /etc/fstab file\n");
- fprintf(fstab, "# Device\t\tMountpoint\tFStype\tOptions\t\tDump\tPass#\n");
- for (i = 0; i < nchunks; i++)
- fprintf(fstab, "/dev/%s\t\t%s\t\t%s\t%s\t\t%d\t%d\n", name_of(chunk_list[i]), mount_point(chunk_list[i]),
- fstype(chunk_list[i]), fstype_short(chunk_list[i]), seq_num(chunk_list[i]), seq_num(chunk_list[i]));
-
- /* Now look for the CDROMs */
- devs = deviceFind(NULL, DEVICE_TYPE_CDROM);
- cnt = deviceCount(devs);
-
- /* Write out the CDROM entries */
- for (i = 0; i < cnt; i++) {
- char cdname[10];
-
- sprintf(cdname, "/cdrom%s", i ? itoa(i) : "");
- if (Mkdir(cdname))
- msgConfirm("Unable to make mount point for: %s", cdname);
- else
- fprintf(fstab, "/dev/%s\t\t%s\tcd9660\tro,noauto\t0\t0\n", devs[i]->name, cdname);
- }
-
- /* And finally, a /proc. */
- fprintf(fstab, "proc\t\t\t/proc\t\tprocfs\trw\t\t0\t0\n");
- Mkdir("/proc");
-
- fclose(fstab);
- if (isDebug())
- msgDebug("Wrote out /etc/fstab file\n");
- return DITEM_SUCCESS;
-}
-
-/* Do the work of sucking in a config file.
- * config is the filename to read in.
- * lines is a fixed (max) sized array of char*
- * returns number of lines read. line contents
- * are malloc'd and must be freed by the caller.
- */
-int
-readConfig(char *config, char **lines, int max)
-{
- FILE *fp;
- char line[256];
- int i, nlines;
-
- fp = fopen(config, "r");
- if (!fp)
- return -1;
-
- nlines = 0;
- /* Read in the entire file */
- for (i = 0; i < max; i++) {
- if (!fgets(line, sizeof line, fp))
- break;
- lines[nlines++] = strdup(line);
- }
- fclose(fp);
- if (isDebug())
- msgDebug("readConfig: Read %d lines from %s.\n", nlines, config);
- return nlines;
-}
-
-#define MAX_LINES 2000 /* Some big number we're not likely to ever reach - I'm being really lazy here, I know */
-
-static void
-readConfigFile(char *config, int marked)
-{
- char *lines[MAX_LINES], *cp, *cp2;
- int i, nlines;
-
- nlines = readConfig(config, lines, MAX_LINES);
- if (nlines == -1)
- return;
-
- for (i = 0; i < nlines; i++) {
- /* Skip the comments & non-variable settings */
- if (lines[i][0] == '#' || !(cp = index(lines[i], '='))) {
- free(lines[i]);
- continue;
- }
- *cp++ = '\0';
- /* Find quotes */
- if ((cp2 = index(cp, '"')) || (cp2 = index(cp, '\047'))) {
- cp = cp2 + 1;
- cp2 = index(cp, *cp2);
- }
- /* If valid quotes, use it */
- if (cp2) {
- *cp2 = '\0';
- /* If we have a legit value, set it */
- if (strlen(cp))
- variable_set2(lines[i], cp, marked);
- }
- free(lines[i]);
- }
-}
-
-/* Load the environment from rc.conf file(s) */
-void
-configEnvironmentRC_conf(void)
-{
- static struct {
- char *fname;
- int marked;
- } configs[] = {
- { "/etc/defaults/rc.conf", 0 },
- { "/etc/rc.conf", 0 },
- { "/etc/rc.conf.local", 0 },
- { NULL, 0 },
- };
- int i;
-
- for (i = 0; configs[i].fname; i++) {
- if (file_readable(configs[i].fname))
- readConfigFile(configs[i].fname, configs[i].marked);
- }
-}
-
-/* Load the environment from a resolv.conf file */
-void
-configEnvironmentResolv(char *config)
-{
- char *lines[MAX_LINES];
- int i, nlines;
-
- nlines = readConfig(config, lines, MAX_LINES);
- if (nlines == -1)
- return;
- for (i = 0; i < nlines; i++) {
- Boolean name_set = (Boolean)variable_get(VAR_NAMESERVER);
-
- if (!strncmp(lines[i], "domain", 6) && !variable_get(VAR_DOMAINNAME))
- variable_set2(VAR_DOMAINNAME, string_skipwhite(string_prune(lines[i] + 6)), 0);
- else if (!name_set && !strncmp(lines[i], "nameserver", 10)) {
- /* Only take the first nameserver setting - we're lame */
- variable_set2(VAR_NAMESERVER, string_skipwhite(string_prune(lines[i] + 10)), 0);
- }
- free(lines[i]);
- }
-}
-
-/* Set up the make.conf file */
-void
-configMake_conf(char *config)
-{
- char *lines[MAX_LINES];
- int i, nlines;
- FILE *fp;
-
- if (!file_readable(config)) {
- char *line = malloc(21);
- sprintf(line, "USA_RESIDENT=%s\n", USAResident ? "YES" : "NO");
- lines[0] = line;
- nlines = 1;
- }
- else {
- nlines = readConfig(config, lines, MAX_LINES);
- if (nlines == -1)
- return;
- for (i = 0; i < nlines; i++) {
- if (!strncmp(lines[i], "USA_RESIDENT", 12)) {
- free(lines[i]);
- lines[i] = malloc(21); /* big enough */
- sprintf(lines[i], "USA_RESIDENT=%s\n", USAResident ? "YES" : "NO");
- }
- }
- }
- if ((fp = fopen(config, "w")) != NULL) {
- for (i = 0; i < nlines; i++) {
- fprintf(fp, "%s", lines[i]);
- free(lines[i]);
- }
- fclose(fp);
- }
-}
-
-/* Version of below for dispatch routines */
-int
-configRC(dialogMenuItem *unused)
-{
- configRC_conf();
- return DITEM_SUCCESS;
-}
-
-void
-configRC_conf(void)
-{
- FILE *rcSite;
- Variable *v;
- int write_header;
- static int did_marker = 0;
-
- write_header = !file_readable("/etc/rc.conf");
- rcSite = fopen("/etc/rc.conf", "a");
- if (!rcSite)
- return;
- if (write_header) {
- fprintf(rcSite, "# This file now contains just the overrides from /etc/defaults/rc.conf\n");
- fprintf(rcSite, "# please make all changes to this file.\n\n");
- }
-
- /* Now do variable substitutions */
- for (v = VarHead; v; v = v->next) {
- if (v->dirty) {
- if (!did_marker) {
- fprintf(rcSite, "# -- sysinstall generated deltas -- #\n");
- did_marker = 1;
- }
- fprintf(rcSite, "%s=\"%s\"\n", v->name, v->value);
- v->dirty = 0;
- }
- }
- fclose(rcSite);
-}
-
-int
-configSaver(dialogMenuItem *self)
-{
- variable_set((char *)self->data, 1);
- if (!variable_get(VAR_BLANKTIME))
- variable_set2(VAR_BLANKTIME, "300", 1);
- return DITEM_SUCCESS;
-}
-
-int
-configSaverTimeout(dialogMenuItem *self)
-{
- return (variable_get_value(VAR_BLANKTIME,
- "Enter time-out period in seconds for screen saver", 1) ?
- DITEM_SUCCESS : DITEM_FAILURE);
-}
-
-int
-configNTP(dialogMenuItem *self)
-{
- int status;
-
- status = variable_get_value(VAR_NTPDATE_FLAGS,
- "Enter the name of an NTP server", 1)
- ? DITEM_SUCCESS : DITEM_FAILURE;
- if (status == DITEM_SUCCESS) {
- static char tmp[255];
-
- snprintf(tmp, sizeof(tmp), "ntpdate_enable=YES,ntpdate_flags=%s",
- variable_get(VAR_NTPDATE_FLAGS));
- self->data = tmp;
- dmenuSetVariables(self);
- }
- return status;
-}
-
-int
-configUsers(dialogMenuItem *self)
-{
- WINDOW *w = savescr();
-
- dialog_clear_norefresh();
- dmenuOpenSimple(&MenuUsermgmt, FALSE);
- restorescr(w);
- return DITEM_SUCCESS;
-}
-
-int
-configLinux(dialogMenuItem *self)
-{
- WINDOW *w = savescr();
- int i;
-
- dialog_clear_norefresh();
- variable_set2(VAR_LINUX_ENABLE, "YES", 1);
- Mkdir("/compat/linux");
- msgNotify("Installing Linux compatibility library...");
- i = package_add("linux_base");
- restorescr(w);
- return i;
-}
-
-static void
-write_root_xprofile(char *str)
-{
- FILE *fp;
- int len;
- char **cp;
- static char *flist[] = { /* take care of both xdm and startx */
- "/root/.xinitrc",
- "/root/.xsession",
- "/usr/share/skel/dot.xinitrc",
- "/usr/share/skel/dot.xsession",
- NULL,
- };
-
- len = strlen(str);
- for (cp = flist; *cp; cp++) {
- fp = fopen(*cp, "w");
- if (fp) {
- fwrite(str, 1, len, fp);
- fchmod(fileno(fp), 0755);
- fclose(fp);
- }
- }
-}
-
-static int
-gotit(char *fname)
-{
- char tmp[FILENAME_MAX];
-
- snprintf(tmp, sizeof tmp, "/usr/X11R6/bin/%s", fname);
- if (file_executable(tmp))
- return TRUE;
- snprintf(tmp, sizeof tmp, "/usr/local/bin/%s", fname);
- return file_executable(tmp);
-}
-
-int
-configXDesktop(dialogMenuItem *self)
-{
- char *desk;
- int ret = DITEM_SUCCESS;
- WINDOW *w = savescr();
-
- dialog_clear_norefresh();
- if (!dmenuOpenSimple(&MenuXDesktops, FALSE) || !(desk = variable_get(VAR_DESKSTYLE))) {
- restorescr(w);
- return DITEM_FAILURE;
- }
- if (!strcmp(desk, "kde")) {
- ret = package_add("kde");
- if (DITEM_STATUS(ret) != DITEM_FAILURE && gotit("startkde"))
- write_root_xprofile("exec startkde\n");
- }
- else if (!strcmp(desk, "gnome")) {
- ret = package_add("gnomecore");
- if (DITEM_STATUS(ret) != DITEM_FAILURE && gotit("gnome-session")) {
- ret = package_add("afterstep");
- if (DITEM_STATUS(ret) != DITEM_FAILURE && gotit("afterstep"))
- write_root_xprofile("gnome-session &\nexec afterstep");
- }
- }
- else if (!strcmp(desk, "enlightenment")) {
- ret = package_add("gnomecore");
- if (DITEM_STATUS(ret) != DITEM_FAILURE && gotit("gnome-session")) {
- ret = package_add("enlightenment");
- if (DITEM_STATUS(ret) != DITEM_FAILURE && gotit("enlightenment"))
- write_root_xprofile("exec gnome-session\n");
- }
- }
- else if (!strcmp(desk, "afterstep")) {
- ret = package_add("afterstep");
- if (DITEM_STATUS(ret) != DITEM_FAILURE && gotit("afterstep"))
- write_root_xprofile("xterm &\nexec afterstep\n");
- }
- else if (!strcmp(desk, "windowmaker")) {
- ret = package_add("windowmaker");
- if (DITEM_STATUS(ret) != DITEM_FAILURE && gotit("wmaker.inst")) {
- write_root_xprofile("xterm &\n[ ! -d $HOME/GNUstep/Library/WindowMaker ] && /usr/X11R6/bin/wmaker.inst\nexec /usr/X11R6/bin/wmaker\n");
- }
- }
- else if (!strcmp(desk, "fvwm2")) {
- ret = package_add("fvwm");
- if (DITEM_STATUS(ret) != DITEM_FAILURE && gotit("fvwm2"))
- write_root_xprofile("xterm &\nexec fvwm2\n");
- }
- if (DITEM_STATUS(ret) == DITEM_FAILURE)
- msgConfirm("An error occurred while adding the package(s) required\n"
- "by this desktop type. Please change installation media\n"
- "and/or select a different, perhaps simpler, desktop\n"
- "environment and try again.");
- restorescr(w);
- return ret;
-}
-
-int
-configXSetup(dialogMenuItem *self)
-{
- char *config, *execfile, *style;
- char *moused;
- WINDOW *w = savescr();
-
- setenv("XWINHOME", "/usr/X11R6", 1);
-tryagain:
- variable_unset(VAR_DESKSTYLE);
- variable_unset(VAR_XF86_CONFIG);
- dialog_clear_norefresh();
- if (!dmenuOpenSimple(&MenuXF86Config, FALSE)) {
- restorescr(w);
- return DITEM_FAILURE;
- }
- config = variable_get(VAR_XF86_CONFIG);
- style = variable_get(VAR_DESKSTYLE);
- if (!config) {
- if (style)
- goto config_desktop;
- else {
- restorescr(w);
- return DITEM_FAILURE;
- }
- }
-
- if (file_readable("/var/run/ld.so.hints"))
- vsystem("/sbin/ldconfig -m /usr/lib /usr/X11R6/lib /usr/local/lib /usr/lib/compat");
- else
- vsystem("/sbin/ldconfig /usr/lib /usr/X11R6/lib /usr/local/lib /usr/lib/compat");
- vsystem("/sbin/ifconfig lo0 127.0.0.1");
- execfile = string_concat("/usr/X11R6/bin/", config);
- if (file_executable(execfile)) {
- moused = variable_get(VAR_MOUSED);
- while (!moused || strcmp(moused, "YES")) {
- if (msgYesNo("The X server may access the mouse in two ways: direct access\n"
- "or indirect access via the mouse daemon. You have not\n"
- "configured the mouse daemon. Would you like to configure it\n"
- "now? If you intend to let the X server access the mouse\n"
- "directly, choose \"No\" at this time."))
- break;
- dialog_clear_norefresh();
- dmenuOpenSimple(&MenuMouse, FALSE);
- moused = variable_get(VAR_MOUSED);
- }
- if (moused && !strcmp(moused, "YES"))
- msgConfirm("You have configured and are now running the mouse daemon.\n"
- "Choose \"/dev/sysmouse\" as the mouse port and \"SysMouse\" or\n"
- "\"MouseSystems\" as the mouse protocol in the X configuration\n"
- "utility.");
- systemExecute(execfile);
- if (!file_readable("/etc/XF86Config")) {
- if (!msgYesNo("The XFree86 configuration process seems to have\nfailed. Would you like to try again?"))
- goto tryagain;
- else {
- restorescr(w);
- return DITEM_FAILURE;
- }
- }
-config_desktop:
- configXDesktop(self);
- restorescr(w);
- return DITEM_SUCCESS;
- }
- else {
- msgConfirm("The XFree86 setup utility you chose does not appear to be installed!\n"
- "Please install this before attempting to configure XFree86.");
- restorescr(w);
- return DITEM_FAILURE;
- }
-}
-
-int
-configResolv(dialogMenuItem *ditem)
-{
- FILE *fp;
- char *cp, *dp, *hp;
-
- cp = variable_get(VAR_NAMESERVER);
- if (!cp || !*cp)
- goto skip;
- Mkdir("/etc");
- fp = fopen("/etc/resolv.conf", "w");
- if (!fp)
- return DITEM_FAILURE;
- if (variable_get(VAR_DOMAINNAME))
- fprintf(fp, "domain\t%s\n", variable_get(VAR_DOMAINNAME));
- fprintf(fp, "nameserver\t%s\n", cp);
- fclose(fp);
- if (isDebug())
- msgDebug("Wrote out /etc/resolv.conf\n");
-
-skip:
- dp = variable_get(VAR_DOMAINNAME);
- cp = variable_get(VAR_IPADDR);
- hp = variable_get(VAR_HOSTNAME);
- /* Tack ourselves into /etc/hosts */
- fp = fopen("/etc/hosts", "w");
- if (!fp)
- return DITEM_FAILURE;
- /* Add an entry for localhost */
- if (dp)
- fprintf(fp, "127.0.0.1\t\tlocalhost.%s localhost\n", dp);
- else
- fprintf(fp, "127.0.0.1\t\tlocalhost\n");
- /* Now the host entries, if applicable */
- if (cp && cp[0] != '0' && hp) {
- char cp2[255];
-
- if (!index(hp, '.'))
- cp2[0] = '\0';
- else {
- SAFE_STRCPY(cp2, hp);
- *(index(cp2, '.')) = '\0';
- }
- fprintf(fp, "%s\t\t%s %s\n", cp, hp, cp2);
- fprintf(fp, "%s\t\t%s.\n", cp, hp);
- }
- fclose(fp);
- if (isDebug())
- msgDebug("Wrote out /etc/hosts\n");
- return DITEM_SUCCESS;
-}
-
-int
-configRouter(dialogMenuItem *self)
-{
- int ret;
-
- ret = variable_get_value(VAR_ROUTER,
- "Please specify the router you wish to use. Routed is\n"
- "provided with the stock system and gated is provided\n"
- "as an optional package which this installation system\n"
- "will attempt to load if you select gated. Any other\n"
- "choice of routing daemon will be assumed to be something\n"
- "the user intends to install themselves before rebooting\n"
- "the system. If you don't want any routing daemon, choose NO", 1)
- ? DITEM_SUCCESS : DITEM_FAILURE;
-
- if (ret == DITEM_SUCCESS) {
- char *cp = variable_get(VAR_ROUTER);
-
- if (cp && strcmp(cp, "NO")) {
- variable_set2(VAR_ROUTER_ENABLE, "YES", 1);
- if (!strcmp(cp, "gated")) {
- if (package_add("gated") != DITEM_SUCCESS) {
- msgConfirm("Unable to load gated package. Falling back to no router.");
- variable_unset(VAR_ROUTER);
- variable_unset(VAR_ROUTERFLAGS);
- variable_set2(VAR_ROUTER_ENABLE, "NO", 1);
- cp = NULL;
- }
- }
- if (cp) {
- /* Now get the flags, if they chose a router */
- ret = variable_get_value(VAR_ROUTERFLAGS,
- "Please Specify the routing daemon flags; if you're running routed\n"
- "then -q is the right choice for nodes and -s for gateway hosts.\n", 1)
- ? DITEM_SUCCESS : DITEM_FAILURE;
- if (ret != DITEM_SUCCESS)
- variable_unset(VAR_ROUTERFLAGS);
- }
- }
- else {
- /* No router case */
- variable_set2(VAR_ROUTER_ENABLE, "NO", 1);
- variable_unset(VAR_ROUTERFLAGS);
- variable_unset(VAR_ROUTER);
- }
- }
- else {
- variable_set2(VAR_ROUTER_ENABLE, "NO", 1);
- variable_unset(VAR_ROUTERFLAGS);
- variable_unset(VAR_ROUTER);
- }
- return ret;
-}
-
-/* Shared between us and index_initialize() */
-extern PkgNode Top, Plist;
-
-int
-configPackages(dialogMenuItem *self)
-{
- int i, restoreflag = 0;
- PkgNodePtr tmp;
-
- /* Did we get an INDEX? */
- i = index_initialize("packages/INDEX");
- if (DITEM_STATUS(i) == DITEM_FAILURE)
- return i;
-
- while (1) {
- int ret, pos, scroll;
-
- /* Bring up the packages menu */
- pos = scroll = 0;
- index_menu(&Top, &Top, &Plist, &pos, &scroll);
-
- if (Plist.kids && Plist.kids->name) {
- /* Now show the packing list menu */
- pos = scroll = 0;
- ret = index_menu(&Plist, &Plist, NULL, &pos, &scroll);
- if (ret & DITEM_LEAVE_MENU)
- break;
- else if (DITEM_STATUS(ret) != DITEM_FAILURE) {
- dialog_clear();
- restoreflag = 1;
- for (tmp = Plist.kids; tmp && tmp->name; tmp = tmp->next)
- (void)index_extract(mediaDevice, &Top, tmp, FALSE);
- break;
- }
- }
- else {
- msgConfirm("No packages were selected for extraction.");
- break;
- }
- }
- tmp = Plist.kids;
- while (tmp) {
- PkgNodePtr tmp2 = tmp->next;
-
- safe_free(tmp);
- tmp = tmp2;
- }
- index_init(NULL, &Plist);
- return DITEM_SUCCESS | (restoreflag ? DITEM_RESTORE : 0);
-}
-
-/* Load pcnfsd package */
-int
-configPCNFSD(dialogMenuItem *self)
-{
- int ret;
-
- ret = package_add("pcnfsd");
- if (DITEM_STATUS(ret) == DITEM_SUCCESS) {
- variable_set2(VAR_PCNFSD, "YES", 0);
- variable_set2("mountd_flags", "-n", 1);
- }
- return ret;
-}
-
-int
-configNFSServer(dialogMenuItem *self)
-{
- char cmd[256];
-
- /* If we're an NFS server, we need an exports file */
- if (!file_readable("/etc/exports")) {
- WINDOW *w = savescr();
-
- if (file_readable("/etc/exports.disabled"))
- vsystem("mv /etc/exports.disabled /etc/exports");
- else {
- dialog_clear_norefresh();
- msgConfirm("Operating as an NFS server means that you must first configure\n"
- "an /etc/exports file to indicate which hosts are allowed certain\n"
- "kinds of access to your local file systems.\n"
- "Press [ENTER] now to invoke an editor on /etc/exports\n");
- vsystem("echo '#The following examples export /usr to 3 machines named after ducks,' > /etc/exports");
- vsystem("echo '#/home and all directories under it to machines named after dead rock stars' >> /etc/exports");
- vsystem("echo '#and, finally, /a to 2 privileged machines allowed to write on it as root.' >> /etc/exports");
- vsystem("echo '#/usr huey louie dewie' >> /etc/exports");
- vsystem("echo '#/home -alldirs janice jimmy frank' >> /etc/exports");
- vsystem("echo '#/a -maproot=0 bill albert' >> /etc/exports");
- vsystem("echo '#' >> /etc/exports");
- vsystem("echo '# You should replace these lines with your actual exported filesystems.' >> /etc/exports");
- vsystem("echo >> /etc/exports");
- sprintf(cmd, "%s /etc/exports", variable_get(VAR_EDITOR));
- dialog_clear();
- systemExecute(cmd);
- }
- variable_set2(VAR_NFS_SERVER, "YES", 1);
- restorescr(w);
- }
- else if (variable_get(VAR_NFS_SERVER)) { /* We want to turn it off again? */
- vsystem("mv -f /etc/exports /etc/exports.disabled");
- variable_unset(VAR_NFS_SERVER);
- }
- return DITEM_SUCCESS;
-}
diff --git a/usr.sbin/sysinstall/dev2c.sh b/usr.sbin/sysinstall/dev2c.sh
deleted file mode 100644
index b828355cf279..000000000000
--- a/usr.sbin/sysinstall/dev2c.sh
+++ /dev/null
@@ -1,80 +0,0 @@
-:
-#
-# ----------------------------------------------------------------------------
-# "THE BEER-WARE LICENSE" (Revision 42):
-# <phk@login.dknet.dk> wrote this file. As long as you retain this notice you
-# can do whatever you want with this stuff. If we meet some day, and you think
-# this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
-# ----------------------------------------------------------------------------
-#
-# $FreeBSD$
-#
-# During installation, we suffer badly of we have to run MAKEDEV. MAKEDEV
-# need sh, ln, chown, mknod, awk, rm, test and probably emacs too when
-# we come down to it. So instead this script will make a C-procedure which
-# makes all the B & C nodes of a specified directory.
-#
-# Poul-Henning
-
-(cd $1; ls -li ) | sed 's/,//' | awk '
-BEGIN {
- while (getline < "/etc/passwd") {
- split($0,a,":")
- uid[a[1]] = a[3]
- }
- while (getline < "/etc/group") {
- split($0,a,":")
- gid[a[1]] = a[3]
- }
- printf("/*\n");
- printf(" * This file is generated from the contents of /dev\n");
- printf(" */\n");
- printf("#define CHK(foo) {i = foo;}\n");
- printf("#include <unistd.h>\n");
- printf("#include <sys/types.h>\n");
- printf("#include <sys/stat.h>\n");
- printf("int makedevs()\n{\n\tint i=0;\n");
- }
- {
- printf ("/* %s */\n",$0)
- $4 = uid[$4]
- $5 = gid[$5]
- if (substr($2,1,1) == "b") {
- k="S_IFBLK"
- } else if (substr($2,1,1) == "c") {
- k="S_IFCHR"
- } else if (substr($2,1,1) == "d") {
- next
- } else if (substr($2,1,1) == "-") {
- next
- } else {
- next
- }
- m = 0;
- if (substr($2,2,1) == "r") m += 400;
- if (substr($2,3,1) == "w") m += 200;
- if (substr($2,4,1) == "x") m += 100;
- if (substr($2,5,1) == "r") m += 40;
- if (substr($2,6,1) == "w") m += 20;
- if (substr($2,7,1) == "x") m += 10;
- if (substr($2,8,1) == "r") m += 4;
- if (substr($2,9,1) == "w") m += 2;
- if (substr($2,10,1) == "x") m += 1;
-
- if (a[$1] != 0) {
- printf ("\tCHK(link(\"%s\",\"%s\"));\n", \
- a[$1],$11)
- } else {
- printf ("\tCHK(mknod(\"%s\",%s,makedev(%d,%d)));\n", \
- $11, k, $6, $7)
- printf ("\tCHK(chmod(\"%s\",0%d));\n", \
- $11, m)
- printf ("\tCHK(chown(\"%s\",%d,%d));\n", \
- $11, $4,$5)
- a[$1] = $11
- }
- }
-END {
- printf("\treturn i;\n}\n");
- }
-'
diff --git a/usr.sbin/sysinstall/devices.c b/usr.sbin/sysinstall/devices.c
deleted file mode 100644
index f51d55575be8..000000000000
--- a/usr.sbin/sysinstall/devices.c
+++ /dev/null
@@ -1,560 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last program in the `sysinstall' line - the next
- * generation being essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 "sysinstall.h"
-#include <sys/fcntl.h>
-#include <sys/param.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/errno.h>
-#include <sys/time.h>
-#include <net/if.h>
-#include <net/if_var.h>
-#include <net/if_dl.h>
-#include <netinet/in.h>
-#include <netinet/in_var.h>
-#include <arpa/inet.h>
-#include <ctype.h>
-
-/* how much to bias minor number for a given /dev/<ct#><un#>s<s#> slice */
-#define SLICE_DELTA (0x10000)
-
-static Device *Devices[DEV_MAX];
-static int numDevs;
-
-static struct _devname {
- DeviceType type;
- char *name;
- char *description;
- int major, minor, delta, max;
- char dev_type;
-} device_names[] = {
- { DEVICE_TYPE_CDROM, "cd%dc", "SCSI CDROM drive", 6, 2, 8, 4, 'b' },
- { DEVICE_TYPE_CDROM, "mcd%da", "Mitsumi (old model) CDROM drive", 7, 0, 8, 4, 'b' },
- { DEVICE_TYPE_CDROM, "scd%da", "Sony CDROM drive - CDU31/33A type", 16, 0, 8, 4, 'b' },
-#ifdef notdef
- { DEVICE_TYPE_CDROM, "matcd%da", "Matsushita CDROM ('sound blaster' type)", 17, 0, 8, 4, 'b' },
-#endif
- { DEVICE_TYPE_CDROM, "acd%dc", "ATAPI/IDE CDROM", 31, 2, 8, 4, 'b' },
- { DEVICE_TYPE_TAPE, "rsa%d", "SCSI tape drive", 14, 0, 16, 4, 'c' },
- { DEVICE_TYPE_TAPE, "rwt%d", "Wangtek tape drive", 10, 0, 1, 4, 'c' },
- { DEVICE_TYPE_DISK, "da%d", "SCSI disk device", 4, 65538, 8, 16, 'b' },
- { DEVICE_TYPE_DISK, "rda%d", "SCSI disk device", 13, 65538, 8, 16, 'c' },
- { DEVICE_TYPE_DISK, "ad%d", "ATA/IDE disk device", 30, 65538, 8, 16, 'b' },
- { DEVICE_TYPE_DISK, "rad%d", "ATA/IDE disk device", 116, 65538, 8, 16, 'c' },
- { DEVICE_TYPE_DISK, "fla%d", "M-Systems DiskOnChip Flash device", 28, 65538, 8, 16, 'b' },
- { DEVICE_TYPE_DISK, "rfla%d", "M-Systems DiskOnChip Flash devicee", 102, 65538, 8, 16, 'c' },
- { DEVICE_TYPE_DISK, "afd%d", "ATAPI/IDE floppy device", 32, 65538, 8, 4, 'b' },
- { DEVICE_TYPE_DISK, "rafd%d", "ATAPI/IDE floppy device", 118, 65538, 8, 4, 'c' },
- { DEVICE_TYPE_DISK, "mlxd%d", "Mylex RAID disk", 27, 65538, 8, 4, 'b' },
- { DEVICE_TYPE_DISK, "rmlxd%d", "Mylex RAID disk", 131, 65538, 8, 4, 'c' },
- { DEVICE_TYPE_DISK, "amrd%d", "AMI MegaRAID drive", 35, 65538, 8, 4, 'b' },
- { DEVICE_TYPE_DISK, "ramrd%d", "AMI MegaRAID drive", 133, 65538, 8, 4, 'c' },
- { DEVICE_TYPE_DISK, "idad%d", "Compaq RAID array", 29, 65538, 8, 4, 'b' },
- { DEVICE_TYPE_DISK, "ridad%d", "Compaq RAID array", 109, 65538, 8, 4, 'c' },
- { DEVICE_TYPE_FLOPPY, "fd%d", "floppy drive unit A", 2, 0, 64, 4, 'b' },
- { DEVICE_TYPE_FLOPPY, "worm%d", "SCSI optical disk / CDR", 23, 0, 1, 4, 'b' },
- { DEVICE_TYPE_NETWORK, "aue", "ADMtek USB ethernet adapter" },
- { DEVICE_TYPE_NETWORK, "cue", "CATC USB ethernet adapter" },
- { DEVICE_TYPE_NETWORK, "fpa", "DEC DEFPA PCI FDDI card" },
- { DEVICE_TYPE_NETWORK, "sr", "SDL T1/E1 sync serial PCI card" },
- { DEVICE_TYPE_NETWORK, "cc3i", "SDL HSSI sync serial PCI card" },
- { DEVICE_TYPE_NETWORK, "en", "Efficient Networks ATM PCI card" },
- { DEVICE_TYPE_NETWORK, "dc", "DEC/Intel 21143 (and clones) PCI fast ethernet card" },
- { DEVICE_TYPE_NETWORK, "de", "DEC DE435 PCI NIC or other DC21040-AA based card" },
- { DEVICE_TYPE_NETWORK, "fxp", "Intel EtherExpress Pro/100B PCI Fast Ethernet card" },
- { DEVICE_TYPE_NETWORK, "ed", "Novell NE1000/2000; 3C503; NE2000-compatible PCMCIA" },
- { DEVICE_TYPE_NETWORK, "ep", "3Com 3C509 ethernet card/3C589 PCMCIA" },
- { DEVICE_TYPE_NETWORK, "el", "3Com 3C501 ethernet card" },
- { DEVICE_TYPE_NETWORK, "ex", "Intel EtherExpress Pro/10 ethernet card" },
- { DEVICE_TYPE_NETWORK, "fe", "Fujitsu MB86960A/MB86965A ethernet card" },
- { DEVICE_TYPE_NETWORK, "ie", "AT&T StarLAN 10 and EN100; 3Com 3C507; NI5210" },
- { DEVICE_TYPE_NETWORK, "ix", "Intel Etherexpress ethernet card" },
- { DEVICE_TYPE_NETWORK, "kue", "Kawasaki LSI USB ethernet adapter" },
- { DEVICE_TYPE_NETWORK, "le", "DEC EtherWorks 2 or 3 ethernet card" },
- { DEVICE_TYPE_NETWORK, "lnc", "Lance/PCnet (Isolan/Novell NE2100/NE32-VL) ethernet" },
- { DEVICE_TYPE_NETWORK, "rl", "RealTek 8129/8139 PCI ethernet card" },
- { DEVICE_TYPE_NETWORK, "sf", "Adaptec AIC-6915 PCI ethernet card" },
- { DEVICE_TYPE_NETWORK, "sis", "SiS 900/SiS 7016 PCI ethernet card" },
- { DEVICE_TYPE_NETWORK, "sn", "SMC/Megahertz ethernet card" },
- { DEVICE_TYPE_NETWORK, "ste", "Sundance ST201 PCI ethernet card" },
- { DEVICE_TYPE_NETWORK, "sk", "SysKonnect PCI gigabit ethernet card" },
- { DEVICE_TYPE_NETWORK, "tx", "SMC 9432TX ethernet card" },
- { DEVICE_TYPE_NETWORK, "ti", "Alteon Networks PCI gigabit ethernet card" },
- { DEVICE_TYPE_NETWORK, "tl", "Texas Instruments ThunderLAN PCI ethernet card" },
- { DEVICE_TYPE_NETWORK, "vr", "VIA VT3043/VT86C100A Rhine PCI ethernet card" },
- { DEVICE_TYPE_NETWORK, "vx", "3COM 3c590 / 3c595 ethernet card" },
- { DEVICE_TYPE_NETWORK, "wb", "Winbond W89C840F PCI ethernet card" },
- { DEVICE_TYPE_NETWORK, "xl", "3COM 3c90x / 3c90xB PCI ethernet card" },
- { DEVICE_TYPE_NETWORK, "cuaa%d", "%s on device %s (COM%d)", 28, 128, 1, 16, 'c' },
- { DEVICE_TYPE_NETWORK, "lp", "Parallel Port IP (PLIP) peer connection" },
- { DEVICE_TYPE_NETWORK, "lo", "Loop-back (local) network interface" },
- { 0 },
-};
-
-Device *
-new_device(char *name)
-{
- Device *dev;
-
- dev = safe_malloc(sizeof(Device));
- bzero(dev, sizeof(Device));
- if (name)
- SAFE_STRCPY(dev->name, name);
- return dev;
-}
-
-/* Stubs for unimplemented strategy routines */
-Boolean
-dummyInit(Device *dev)
-{
- return TRUE;
-}
-
-FILE *
-dummyGet(Device *dev, char *dist, Boolean probe)
-{
- return NULL;
-}
-
-void
-dummyShutdown(Device *dev)
-{
- return;
-}
-
-static int
-deviceTry(struct _devname dev, char *try, int i)
-{
- int fd;
- char unit[80];
- mode_t m;
- dev_t d;
- int fail;
-
- snprintf(unit, sizeof unit, dev.name, i);
- snprintf(try, FILENAME_MAX, "/dev/%s", unit);
- if (isDebug())
- msgDebug("deviceTry: attempting to open %s\n", try);
- fd = open(try, O_RDONLY);
- if (fd >= 0) {
- if (isDebug())
- msgDebug("deviceTry: open of %s succeeded on first try.\n", try);
- return fd;
- }
- m = 0640;
- if (dev.dev_type == 'c')
- m |= S_IFCHR;
- else
- m |= S_IFBLK;
- d = makedev(dev.major, dev.minor + (i * dev.delta));
- if (isDebug())
- msgDebug("deviceTry: Making %s device for %s [%d, %d]\n", m & S_IFCHR ? "raw" : "block", try, dev.major, dev.minor + (i * dev.delta));
- fail = mknod(try, m, d);
- fd = open(try, O_RDONLY);
- if (fd >= 0) {
- if (isDebug())
- msgDebug("deviceTry: open of %s succeeded on second try.\n", try);
- return fd;
- }
- else if (!fail)
- (void)unlink(try);
- /* Don't try a "make-under" here since we're using a fixit floppy in this case */
- snprintf(try, FILENAME_MAX, "/mnt/dev/%s", unit);
- fd = open(try, O_RDONLY);
- if (isDebug())
- msgDebug("deviceTry: final attempt for %s returns %d\n", try, fd);
- return fd;
-}
-
-/* Register a new device in the devices array */
-Device *
-deviceRegister(char *name, char *desc, char *devname, DeviceType type, Boolean enabled,
- Boolean (*init)(Device *), FILE * (*get)(Device *, char *, Boolean),
- void (*shutdown)(Device *), void *private)
-{
- Device *newdev = NULL;
-
- if (numDevs == DEV_MAX)
- msgFatal("Too many devices found!");
- else {
- newdev = new_device(name);
- newdev->description = desc;
- newdev->devname = devname;
- newdev->type = type;
- newdev->enabled = enabled;
- newdev->init = init ? init : dummyInit;
- newdev->get = get ? get : dummyGet;
- newdev->shutdown = shutdown ? shutdown : dummyShutdown;
- newdev->private = private;
- Devices[numDevs] = newdev;
- Devices[++numDevs] = NULL;
- }
- return newdev;
-}
-
-/* Reset the registered device chain */
-void
-deviceReset(void)
-{
- int i;
-
- for (i = 0; i < numDevs; i++) {
- Devices[i]->shutdown(Devices[i]);
-
- /* XXX this potentially leaks Devices[i]->private if it's being
- * used to point to something dynamic, but you're not supposed
- * to call this routine at such times that some open instance
- * has its private ptr pointing somewhere anyway. XXX
- */
- free(Devices[i]);
- }
- Devices[numDevs = 0] = NULL;
-}
-
-/* Get all device information for devices we have attached */
-void
-deviceGetAll(void)
-{
- int i, j, fd, s;
- struct ifconf ifc;
- struct ifreq *ifptr, *end;
- int ifflags;
- char buffer[INTERFACE_MAX * sizeof(struct ifreq)];
- char **names;
-
- msgNotify("Probing devices, please wait (this can take a while)...");
- /* First go for the network interfaces. Stolen shamelessly from ifconfig! */
- ifc.ifc_len = sizeof(buffer);
- ifc.ifc_buf = buffer;
-
- s = socket(AF_INET, SOCK_DGRAM, 0);
- if (s < 0)
- goto skipif; /* Jump over network iface probing */
-
- if (ioctl(s, SIOCGIFCONF, (char *) &ifc) < 0)
- goto skipif; /* Jump over network iface probing */
-
- ifflags = ifc.ifc_req->ifr_flags;
- end = (struct ifreq *) (ifc.ifc_buf + ifc.ifc_len);
- for (ifptr = ifc.ifc_req; ifptr < end; ifptr++) {
- char *descr;
-
- /* If it's not a link entry, forget it */
- if (ifptr->ifr_ifru.ifru_addr.sa_family != AF_LINK)
- goto loopend;
-
- /* Eliminate network devices that don't make sense */
- if (!strncmp(ifptr->ifr_name, "lo", 2))
- goto loopend;
-
- /* If we have a slip device, don't register it */
- if (!strncmp(ifptr->ifr_name, "sl", 2)) {
- goto loopend;
- }
- /* And the same for ppp */
- if (!strncmp(ifptr->ifr_name, "tun", 3) || !strncmp(ifptr->ifr_name, "ppp", 3)) {
- goto loopend;
- }
- /* Try and find its description */
- for (i = 0, descr = NULL; device_names[i].name; i++) {
- int len = strlen(device_names[i].name);
-
- if (!ifptr->ifr_name || !ifptr->ifr_name[0])
- continue;
- else if (!strncmp(ifptr->ifr_name, device_names[i].name, len)) {
- descr = device_names[i].description;
- break;
- }
- }
- if (!descr)
- descr = "<unknown network interface type>";
-
- deviceRegister(ifptr->ifr_name, descr, strdup(ifptr->ifr_name), DEVICE_TYPE_NETWORK, TRUE,
- mediaInitNetwork, NULL, mediaShutdownNetwork, NULL);
- if (isDebug())
- msgDebug("Found a network device named %s\n", ifptr->ifr_name);
- close(s);
- if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
- continue;
-
-loopend:
- if (ifptr->ifr_addr.sa_len) /* I'm not sure why this is here - it's inherited */
- ifptr = (struct ifreq *)((caddr_t)ifptr + ifptr->ifr_addr.sa_len - sizeof(struct sockaddr));
- }
-
-skipif:
- /* Next, try to find all the types of devices one might need
- * during the second stage of the installation.
- */
- for (i = 0; device_names[i].name; i++) {
- for (j = 0; j < device_names[i].max; j++) {
- char try[FILENAME_MAX];
-
- switch(device_names[i].type) {
- case DEVICE_TYPE_CDROM:
- fd = deviceTry(device_names[i], try, j);
- if (fd >= 0 || errno == EBUSY) { /* EBUSY if already mounted */
- char n[BUFSIZ];
-
- if (fd >= 0) close(fd);
- snprintf(n, sizeof n, device_names[i].name, j);
- deviceRegister(strdup(n), device_names[i].description, strdup(try),
- DEVICE_TYPE_CDROM, TRUE, mediaInitCDROM, mediaGetCDROM,
- mediaShutdownCDROM, NULL);
- if (isDebug())
- msgDebug("Found a CDROM device for %s\n", try);
- }
- break;
-
- case DEVICE_TYPE_TAPE:
- fd = deviceTry(device_names[i], try, j);
- if (fd >= 0) {
- char n[BUFSIZ];
-
- close(fd);
- snprintf(n, sizeof n, device_names[i].name, j);
- deviceRegister(strdup(n), device_names[i].description, strdup(try),
- DEVICE_TYPE_TAPE, TRUE, mediaInitTape, mediaGetTape, mediaShutdownTape, NULL);
- if (isDebug())
- msgDebug("Found a TAPE device for %s\n", try);
- }
- break;
-
- case DEVICE_TYPE_DISK:
- fd = deviceTry(device_names[i], try, j);
- if (fd >= 0 && RunningAsInit) {
- dev_t d;
- mode_t m;
- int s, fail;
- char unit[80], slice[80];
-
- close(fd);
- /* Make associated slice entries */
- for (s = 1; s < 8; s++) {
- snprintf(unit, sizeof unit, device_names[i].name, j);
- snprintf(slice, sizeof slice, "/dev/%ss%d", unit, s);
- d = makedev(device_names[i].major, device_names[i].minor +
- (j * device_names[i].delta) + (s * SLICE_DELTA));
- m = 0640;
- if (device_names[i].dev_type == 'c')
- m |= S_IFCHR;
- else
- m |= S_IFBLK;
- fail = mknod(slice, m, d);
- fd = open(slice, O_RDONLY);
- if (fd >= 0)
- close(fd);
- else if (!fail)
- (void)unlink(slice);
- }
- }
- break;
-
- case DEVICE_TYPE_FLOPPY:
- fd = deviceTry(device_names[i], try, j);
- if (fd >= 0) {
- char n[BUFSIZ];
-
- close(fd);
- snprintf(n, sizeof n, device_names[i].name, j);
- deviceRegister(strdup(n), device_names[i].description, strdup(try),
- DEVICE_TYPE_FLOPPY, TRUE, mediaInitFloppy, mediaGetFloppy,
- mediaShutdownFloppy, NULL);
- if (isDebug())
- msgDebug("Found a floppy device for %s\n", try);
- }
- break;
-
- case DEVICE_TYPE_NETWORK:
- fd = deviceTry(device_names[i], try, j);
- /* The only network devices that you can open this way are serial ones */
- if (fd >= 0) {
- char *newdesc, *cp;
-
- close(fd);
- cp = device_names[i].description;
- /* Serial devices get a slip and ppp device each, if supported */
- newdesc = safe_malloc(strlen(cp) + 40);
- sprintf(newdesc, cp, "SLIP interface", try, j + 1);
- deviceRegister("sl0", newdesc, strdup(try), DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork,
- NULL, mediaShutdownNetwork, NULL);
- msgDebug("Add mapping for %s to sl0\n", try);
- newdesc = safe_malloc(strlen(cp) + 50);
- sprintf(newdesc, cp, "PPP interface", try, j + 1);
- deviceRegister("ppp0", newdesc, strdup(try), DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork,
- NULL, mediaShutdownNetwork, NULL);
- if (isDebug())
- msgDebug("Add mapping for %s to ppp0\n", try);
- }
- break;
-
- default:
- break;
- }
- }
- }
-
- /* Finally, go get the disks and look for DOS partitions to register */
- if ((names = Disk_Names()) != NULL) {
- int i;
-
- for (i = 0; names[i]; i++) {
- Chunk *c1;
- Disk *d;
-
- d = Open_Disk(names[i]);
- if (!d)
- msgFatal("Unable to open disk %s", names[i]);
-
- deviceRegister(names[i], names[i], d->name, DEVICE_TYPE_DISK, FALSE,
- dummyInit, dummyGet, dummyShutdown, d);
- if (isDebug())
- msgDebug("Found a disk device named %s\n", names[i]);
-
- /* Look for existing DOS partitions to register as "DOS media devices" */
- for (c1 = d->chunks->part; c1; c1 = c1->next) {
- if (c1->type == fat || c1->type == extended) {
- Device *dev;
- char devname[80];
-
- /* Got one! */
- snprintf(devname, sizeof devname, "/dev/%s", c1->name);
- dev = deviceRegister(c1->name, c1->name, strdup(devname), DEVICE_TYPE_DOS, TRUE,
- mediaInitDOS, mediaGetDOS, mediaShutdownDOS, NULL);
- dev->private = c1;
- if (isDebug())
- msgDebug("Found a DOS partition %s on drive %s\n", c1->name, d->name);
- }
- }
- }
- free(names);
- }
- dialog_clear_norefresh();
-}
-
-/* Rescan all devices, after closing previous set - convenience function */
-void
-deviceRescan(void)
-{
- deviceReset();
- deviceGetAll();
-}
-
-/*
- * Find all devices that match the criteria, allowing "wildcarding" as well
- * by allowing NULL or ANY values to match all. The array returned is static
- * and may be used until the next invocation of deviceFind().
- */
-Device **
-deviceFind(char *name, DeviceType class)
-{
- static Device *found[DEV_MAX];
- int i, j;
-
- j = 0;
- for (i = 0; i < numDevs; i++) {
- if ((!name || !strcmp(Devices[i]->name, name))
- && (class == DEVICE_TYPE_ANY || class == Devices[i]->type))
- found[j++] = Devices[i];
- }
- found[j] = NULL;
- return j ? found : NULL;
-}
-
-Device **
-deviceFindDescr(char *name, char *desc, DeviceType class)
-{
- static Device *found[DEV_MAX];
- int i, j;
-
- j = 0;
- for (i = 0; i < numDevs; i++) {
- if ((!name || !strcmp(Devices[i]->name, name)) &&
- (!desc || !strcmp(Devices[i]->description, desc)) &&
- (class == DEVICE_TYPE_ANY || class == Devices[i]->type))
- found[j++] = Devices[i];
- }
- found[j] = NULL;
- return j ? found : NULL;
-}
-
-int
-deviceCount(Device **devs)
-{
- int i;
-
- if (!devs)
- return 0;
- for (i = 0; devs[i]; i++);
- return i;
-}
-
-/*
- * Create a menu listing all the devices of a certain type in the system.
- * The passed-in menu is expected to be a "prototype" from which the new
- * menu is cloned.
- */
-DMenu *
-deviceCreateMenu(DMenu *menu, DeviceType type, int (*hook)(dialogMenuItem *d), int (*check)(dialogMenuItem *d))
-{
- Device **devs;
- int numdevs;
- DMenu *tmp = NULL;
- int i, j;
-
- devs = deviceFind(NULL, type);
- numdevs = deviceCount(devs);
- if (!numdevs)
- return NULL;
- tmp = (DMenu *)safe_malloc(sizeof(DMenu) + (sizeof(dialogMenuItem) * (numdevs + 1)));
- bcopy(menu, tmp, sizeof(DMenu));
- for (i = 0; devs[i]; i++) {
- tmp->items[i].prompt = devs[i]->name;
- for (j = 0; j < numDevs; j++) {
- if (devs[i] == Devices[j]) {
- tmp->items[i].title = Devices[j]->description;
- break;
- }
- }
- if (j == numDevs)
- tmp->items[i].title = "<unknown device type>";
- tmp->items[i].fire = hook;
- tmp->items[i].checked = check;
- }
- tmp->items[i].title = NULL;
- return tmp;
-}
diff --git a/usr.sbin/sysinstall/dhcp.c b/usr.sbin/sysinstall/dhcp.c
deleted file mode 100644
index 22eeeeb72e0f..000000000000
--- a/usr.sbin/sysinstall/dhcp.c
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * $FreeBSD$
- *
- * Copyright (c) 1999
- * C. Stone. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 C. STONE ``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 C STONE OR HIS BODILY PARASITES 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, LIFE 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 BY THE VOICES IN YOUR HEAD BEFOREHAND.
- *
- */
-
-#include "sysinstall.h"
-
-#include <ctype.h>
-
-int
-dhcpParseLeases(char *file, char *hostname, char *domain, char *nameserver,
- char *ipaddr, char *gateway, char *netmask)
-{
- char tempbuf[1024];
- char optbuf[1024], *optname = NULL;
- char *tptr;
- int endedflag = 0;
- int leaseflag = 0;
- FILE *fp;
- enum { P_NOSTMT, P_NOSTMT1, P_STMT, P_STMTLINE } state;
-
- if ((fp = fopen(file, "r")) == NULL) {
- msgDebug("error opening file %s: %s\n", file, strerror(errno));
- return -1;
- }
-
- state = P_NOSTMT;
- while (fscanf(fp, "%1023s", tempbuf) > 0) {
- switch (state) {
- case P_NOSTMT:
- state = P_NOSTMT1;
- if (!strncasecmp(tempbuf, "lease", 5)) {
- if (!leaseflag)
- leaseflag = 1;
- else {
- fclose(fp);
- return 0;
- }
- }
- break;
-
- case P_NOSTMT1:
- if (tempbuf[0] != '{') {
- msgWarn("dhcpParseLeases: '{' expected");
- fclose(fp);
- return -1;
- }
- state = P_STMT;
- break;
-
- case P_STMT:
- if (!strncasecmp("option", tempbuf, 6))
- continue;
- if (tempbuf[0] == '}') {
- state = P_NOSTMT;
- leaseflag = 0;
- continue;
- }
- if (!leaseflag)
- break;
- if (tempbuf[0] == ';') { /* play it safe */
- state = P_STMT;
- continue;
- }
- if ((tptr = (char *)strchr(tempbuf, ';')) && (*(tptr + 1) == 0)) {
- *tptr = NULL;
- endedflag = 1;
- }
- if (!isalnum(tempbuf[0])) {
- msgWarn("dhcpParseLeases: bad option");
- fclose(fp);
- return -1;
- }
- if (optname)
- free(optname);
- optname = strdup(tempbuf);
- if (endedflag) {
- state = P_STMT;
- endedflag = 0;
- continue;
- }
- state = P_STMTLINE;
- break;
-
- case P_STMTLINE:
- if (tempbuf[0] == ';') {
- state = P_STMT;
- continue;
- }
- if ((tptr = (char *)strchr(tempbuf, ';')) && (*(tptr + 1) == 0)) {
- *tptr = NULL;
- endedflag = 1;
- }
- if (tempbuf[0] == '"') {
- if (sscanf(tempbuf, "\"%[^\" ]\"", optbuf) < 1) {
- msgWarn("dhcpParseLeases: bad option value");
- fclose(fp);
- return -1;
- }
- }
- else
- strcpy(optbuf, tempbuf);
-
- if (!strcasecmp("host-name", optname)) {
- strcpy(hostname, optbuf);
- } else if (!strcasecmp("domain-name", optname)) {
- strcpy(domain, optbuf);
- } else if (!strcasecmp("fixed-address", optname)) {
- strcpy(ipaddr, optbuf);
- } else if (!strcasecmp("routers", optname)) {
- strcpy(gateway, optbuf);
- } else if (!strcasecmp("subnet-mask", optname)) {
- strcpy(netmask, optbuf);
- } else if (!strcasecmp("domain-name-servers", optname)) {
- /* <jkh> ...one value per property */
- if((tptr = (char *)strchr(optbuf, ',')))
- *tptr = NULL;
- strcpy(nameserver, optbuf);
- }
- if (endedflag) {
- state = P_STMT;
- endedflag = 0;
- continue;
- }
- break;
- }
- }
- fclose(fp);
- return 0;
-}
diff --git a/usr.sbin/sysinstall/disks.c b/usr.sbin/sysinstall/disks.c
deleted file mode 100644
index 16be5e2f13f5..000000000000
--- a/usr.sbin/sysinstall/disks.c
+++ /dev/null
@@ -1,774 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last program in the `sysinstall' line - the next
- * generation being essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 "sysinstall.h"
-#include <ctype.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/disklabel.h>
-
-/* Where we start displaying chunk information on the screen */
-#define CHUNK_START_ROW 5
-
-/* Where we keep track of MBR chunks */
-static struct chunk *chunk_info[16];
-static int current_chunk;
-
-static void diskPartitionNonInteractive(Device *dev);
-
-static void
-record_chunks(Disk *d)
-{
- struct chunk *c1 = NULL;
- int i = 0;
- int last_free = 0;
-
- if (!d->chunks)
- msgFatal("No chunk list found for %s!", d->name);
-
- for (c1 = d->chunks->part; c1; c1 = c1->next) {
- if (c1->type == unused && c1->size > last_free) {
- last_free = c1->size;
- current_chunk = i;
- }
- chunk_info[i++] = c1;
- }
- chunk_info[i] = NULL;
- if (current_chunk >= i)
- current_chunk = i - 1;
-}
-
-static int Total;
-
-static void
-print_chunks(Disk *d)
-{
- int row;
- int i;
-
- for (i = Total = 0; chunk_info[i]; i++)
- Total += chunk_info[i]->size;
- if (d->bios_cyl > 65536 || d->bios_hd > 256 || d->bios_sect >= 64) {
- dialog_clear_norefresh();
- msgConfirm("WARNING: A geometry of %d/%d/%d for %s is incorrect. Using\n"
- "a more likely geometry. If this geometry is incorrect or you\n"
- "are unsure as to whether or not it's correct, please consult\n"
- "the Hardware Guide in the Documentation submenu or use the\n"
- "(G)eometry command to change it now.\n\n"
- "Remember: you need to enter whatever your BIOS thinks the\n"
- "geometry is! For IDE, it's what you were told in the BIOS\n"
- "setup. For SCSI, it's the translation mode your controller is\n"
- "using. Do NOT use a ``physical geometry''.",
- d->bios_cyl, d->bios_hd, d->bios_sect, d->name);
- Sanitize_Bios_Geom(d);
- }
- attrset(A_NORMAL);
- mvaddstr(0, 0, "Disk name:\t");
- clrtobot();
- attrset(A_REVERSE); addstr(d->name); attrset(A_NORMAL);
- attrset(A_REVERSE); mvaddstr(0, 55, "FDISK Partition Editor"); attrset(A_NORMAL);
- mvprintw(1, 0,
- "DISK Geometry:\t%lu cyls/%lu heads/%lu sectors = %lu sectors",
- d->bios_cyl, d->bios_hd, d->bios_sect,
- d->bios_cyl * d->bios_hd * d->bios_sect);
- mvprintw(3, 0, "%10s %10s %10s %8s %6s %10s %8s %8s",
- "Offset", "Size", "End", "Name", "PType", "Desc",
- "Subtype", "Flags");
- for (i = 0, row = CHUNK_START_ROW; chunk_info[i]; i++, row++) {
- if (i == current_chunk)
- attrset(ATTR_SELECTED);
- mvprintw(row, 0, "%10ld %10lu %10lu %8s %6d %10s %8d\t%-6s",
- chunk_info[i]->offset, chunk_info[i]->size,
- chunk_info[i]->end, chunk_info[i]->name,
- chunk_info[i]->type,
- slice_type_name(chunk_info[i]->type, chunk_info[i]->subtype),
- chunk_info[i]->subtype, ShowChunkFlags(chunk_info[i]));
- if (i == current_chunk)
- attrset(A_NORMAL);
- }
-}
-
-static void
-print_command_summary()
-{
- mvprintw(14, 0, "The following commands are supported (in upper or lower case):");
- mvprintw(16, 0, "A = Use Entire Disk C = Create Slice");
- mvprintw(17, 0, "D = Delete Slice G = Set Drive Geometry S = Set Bootable");
- mvprintw(18, 0, "T = Change Type U = Undo All Changes Q = Finish");
- if (!RunningAsInit)
- mvprintw(18, 48, "W = Write Changes");
- mvprintw(21, 0, "Use F1 or ? to get more help, arrow keys to select.");
- move(0, 0);
-}
-
-static u_char *
-getBootMgr(char *dname)
-{
-#ifndef __alpha__ /* only meaningful on x86 */
- extern u_char mbr[], boot0[];
- char str[80];
- char *cp;
- int i = 0;
-
- cp = variable_get(VAR_BOOTMGR);
- if (!cp) {
- /* Figure out what kind of MBR the user wants */
- sprintf(str, "Install Boot Manager for drive %s?", dname);
- MenuMBRType.title = str;
- i = dmenuOpenSimple(&MenuMBRType, FALSE);
- }
- else {
- if (!strncmp(cp, "boot", 4))
- BootMgr = 0;
- else if (!strcmp(cp, "standard"))
- BootMgr = 1;
- else
- BootMgr = 2;
- }
- if (cp || i) {
- switch (BootMgr) {
- case 0:
- return boot0;
-
- case 1:
- return mbr;
-
- case 2:
- default:
- break;
- }
- }
-#endif
- return NULL;
-}
-
-int
-diskGetSelectCount(Device ***devs)
-{
- int i, cnt, enabled;
- char *cp;
- Device **dp;
-
- cp = variable_get(VAR_DISK);
- dp = *devs = deviceFind(cp, DEVICE_TYPE_DISK);
- cnt = deviceCount(dp);
- if (!cnt)
- return -1;
- for (i = 0, enabled = 0; i < cnt; i++) {
- if (dp[i]->enabled)
- ++enabled;
- }
- return enabled;
-}
-
-void
-diskPartition(Device *dev)
-{
- char *cp, *p;
- int rv, key = 0;
- Boolean chunking;
- char *msg = NULL;
- u_char *mbrContents;
- WINDOW *w = savescr();
- Disk *d = (Disk *)dev->private;
-
- chunking = TRUE;
- keypad(stdscr, TRUE);
-
- /* Flush both the dialog and curses library views of the screen
- since we don't always know who called us */
- dialog_clear_norefresh(), clear();
- current_chunk = 0;
-
- /* Set up the chunk array */
- record_chunks(d);
-
- while (chunking) {
- char *val, geometry[80];
-
- /* Now print our overall state */
- if (d)
- print_chunks(d);
- print_command_summary();
- if (msg) {
- attrset(title_attr); mvprintw(23, 0, msg); attrset(A_NORMAL);
- beep();
- msg = NULL;
- }
- else {
- move(23, 0);
- clrtoeol();
- }
-
- /* Get command character */
- key = getch();
- switch (toupper(key)) {
- case '\014': /* ^L (redraw) */
- clear();
- msg = NULL;
- break;
-
- case '\020': /* ^P */
- case KEY_UP:
- case '-':
- if (current_chunk != 0)
- --current_chunk;
- break;
-
- case '\016': /* ^N */
- case KEY_DOWN:
- case '+':
- case '\r':
- case '\n':
- if (chunk_info[current_chunk + 1])
- ++current_chunk;
- break;
-
- case KEY_HOME:
- current_chunk = 0;
- break;
-
- case KEY_END:
- while (chunk_info[current_chunk + 1])
- ++current_chunk;
- break;
-
- case KEY_F(1):
- case '?':
- systemDisplayHelp("slice");
- clear();
- break;
-
- case 'A':
-#ifdef __alpha__
- rv = 1;
-#else /* The rest is only relevant on x86 */
- cp = variable_get(VAR_DEDICATE_DISK);
- if (cp && !strcasecmp(cp, "always"))
- rv = 1;
- else {
- rv = msgYesNo("Do you want to do this with a true partition entry\n"
- "so as to remain cooperative with any future possible\n"
- "operating systems on the drive(s)?\n"
- "(See also the section about ``dangerously dedicated''\n"
- "disks in the FreeBSD FAQ.)");
- if (rv == -1)
- rv = 0;
- }
-#endif
- All_FreeBSD(d, rv);
- variable_set2(DISK_PARTITIONED, "yes", 0);
- record_chunks(d);
- clear();
- break;
-
- case 'C':
- if (chunk_info[current_chunk]->type != unused)
- msg = "Slice in use, delete it first or move to an unused one.";
- else {
- char *val, tmp[20], *cp;
- int size, subtype;
- chunk_e partitiontype;
-
- snprintf(tmp, 20, "%lu", chunk_info[current_chunk]->size);
- val = msgGetInput(tmp, "Please specify the size for new FreeBSD slice in blocks\n"
- "or append a trailing `M' for megabytes (e.g. 20M).");
- if (val && (size = strtol(val, &cp, 0)) > 0) {
- if (*cp && toupper(*cp) == 'M')
- size *= ONE_MEG;
- else if (*cp && toupper(*cp) == 'G')
- size *= ONE_GIG;
- strcpy(tmp, "165");
- val = msgGetInput(tmp, "Enter type of partition to create:\n\n"
- "Pressing Enter will choose the default, a native FreeBSD\n"
- "slice (type 165). You can choose other types, 6 for a\n"
- "DOS partition or 131 for a Linux partition, for example.\n\n"
- "Note: If you choose a non-FreeBSD partition type, it will not\n"
- "be formatted or otherwise prepared, it will simply reserve space\n"
- "for you to use another tool, such as DOS FORMAT, to later format\n"
- "and use the partition.");
- if (val && (subtype = strtol(val, NULL, 0)) > 0) {
- if (subtype == 165)
- partitiontype = freebsd;
- else if (subtype == 6)
- partitiontype = fat;
- else
- partitiontype = unknown;
-#ifdef __alpha__
- if (partitiontype == freebsd && size == chunk_info[current_chunk]->size)
- All_FreeBSD(d, 1);
- else
-#endif
- Create_Chunk(d, chunk_info[current_chunk]->offset, size, partitiontype, subtype,
- (chunk_info[current_chunk]->flags & CHUNK_ALIGN));
- variable_set2(DISK_PARTITIONED, "yes", 0);
- record_chunks(d);
- }
- }
- clear();
- }
- break;
-
- case KEY_DC:
- case 'D':
- if (chunk_info[current_chunk]->type == unused)
- msg = "Slice is already unused!";
- else {
- Delete_Chunk(d, chunk_info[current_chunk]);
- variable_set2(DISK_PARTITIONED, "yes", 0);
- record_chunks(d);
- }
- break;
-
- case 'T':
- if (chunk_info[current_chunk]->type == unused)
- msg = "Slice is currently unused (use create instead)";
- else {
- char *val, tmp[20];
- int subtype;
- chunk_e partitiontype;
-
- strcpy(tmp, "165");
- val = msgGetInput(tmp, "New partition type:\n\n"
- "Pressing Enter will choose the default, a native FreeBSD\n"
- "slice (type 165). Other popular values are 6 for\n"
- "DOS FAT partition, 131 for a Linux ext2fs partition or\n"
- "130 for a Linux swap partition.\n\n"
- "Note: If you choose a non-FreeBSD partition type, it will not\n"
- "be formatted or otherwise prepared, it will simply reserve space\n"
- "for you to use another tool, such as DOS format, to later format\n"
- "and actually use the partition.");
- if (val && (subtype = strtol(val, NULL, 0)) > 0) {
- if (subtype == 165)
- partitiontype = freebsd;
- else if (subtype == 6)
- partitiontype = fat;
- else
- partitiontype = unknown;
- chunk_info[current_chunk]->type = partitiontype;
- chunk_info[current_chunk]->subtype = subtype;
- }
- }
- break;
-
- case 'G':
- snprintf(geometry, 80, "%lu/%lu/%lu", d->bios_cyl, d->bios_hd, d->bios_sect);
- val = msgGetInput(geometry, "Please specify the new geometry in cyl/hd/sect format.\n"
- "Don't forget to use the two slash (/) separator characters!\n"
- "It's not possible to parse the field without them.");
- if (val) {
- long nc, nh, ns;
- nc = strtol(val, &val, 0);
- nh = strtol(val + 1, &val, 0);
- ns = strtol(val + 1, 0, 0);
- Set_Bios_Geom(d, nc, nh, ns);
- }
- clear();
- break;
-
- case 'S':
- /* Set Bootable */
- chunk_info[current_chunk]->flags |= CHUNK_ACTIVE;
- break;
-
- case 'U':
- if ((cp = variable_get(DISK_LABELLED)) && !strcmp(cp, "written")) {
- msgConfirm("You've already written this information out - you\n"
- "can't undo it.");
- }
- else if (!msgYesNo("Are you SURE you want to Undo everything?")) {
- char cp[BUFSIZ];
-
- sstrncpy(cp, d->name, sizeof cp);
- Free_Disk(dev->private);
- d = Open_Disk(cp);
- if (!d)
- msgConfirm("Can't reopen disk %s! Internal state is probably corrupted", cp);
- dev->private = d;
- variable_unset(DISK_PARTITIONED);
- variable_unset(DISK_LABELLED);
- if (d)
- record_chunks(d);
- }
- clear();
- break;
-
- case 'W':
- if (!msgYesNo("WARNING: This should only be used when modifying an EXISTING\n"
- "installation. If you are installing FreeBSD for the first time\n"
- "then you should simply type Q when you're finished here and your\n"
- "changes will be committed in one batch automatically at the end of\n"
- "these questions. If you're adding a disk, you should NOT write\n"
- "from this screen, you should do it from the label editor.\n\n"
- "Are you absolutely sure you want to do this now?")) {
- variable_set2(DISK_PARTITIONED, "yes", 0);
-
- /* Don't trash the MBR if the first (and therefore only) chunk is marked for a truly dedicated
- * disk (i.e., the disklabel starts at sector 0), even in cases where the user has requested
- * booteasy or a "standard" MBR -- both would be fatal in this case.
- */
- /*
- * Don't offer to update the MBR on this disk if the first "real" chunk looks like
- * a FreeBSD "all disk" partition, or the disk is entirely FreeBSD.
- */
- if (((d->chunks->part->type != freebsd) || (d->chunks->part->offset > 1)))
- mbrContents = getBootMgr(d->name);
- else
- mbrContents = NULL;
- Set_Boot_Mgr(d, mbrContents);
-
- if (DITEM_STATUS(diskPartitionWrite(NULL)) != DITEM_SUCCESS)
- msgConfirm("Disk partition write returned an error status!");
- else
- msgConfirm("Wrote FDISK partition information out successfully.");
- }
- clear();
- break;
-
- case '|':
- if (!msgYesNo("Are you SURE you want to go into Wizard mode?\n"
- "No seat belts whatsoever are provided!")) {
- clear();
- refresh();
- slice_wizard(d);
- variable_set2(DISK_PARTITIONED, "yes", 0);
- record_chunks(d);
- }
- else
- msg = "Wise choice!";
- clear();
- break;
-
- case '\033': /* ESC */
- case 'Q':
- chunking = FALSE;
- /* Don't trash the MBR if the first (and therefore only) chunk is marked for a truly dedicated
- * disk (i.e., the disklabel starts at sector 0), even in cases where the user has requested
- * booteasy or a "standard" MBR -- both would be fatal in this case.
- */
-#if 0
- if ((d->chunks->part->flags & CHUNK_FORCE_ALL) != CHUNK_FORCE_ALL
- && (mbrContents = getBootMgr(d->name)) != NULL)
- Set_Boot_Mgr(d, mbrContents);
-#else
- /*
- * Don't offer to update the MBR on this disk if the first "real" chunk looks like
- * a FreeBSD "all disk" partition, or the disk is entirely FreeBSD.
- */
- if (((d->chunks->part->type != freebsd) || (d->chunks->part->offset > 1)) &&
- (mbrContents = getBootMgr(d->name)) != NULL)
- Set_Boot_Mgr(d, mbrContents);
-#endif
- break;
-
- default:
- beep();
- msg = "Type F1 or ? for help";
- break;
- }
- }
- p = CheckRules(d);
- if (p) {
- char buf[FILENAME_MAX];
-
- use_helpline("Press F1 to read more about disk slices.");
- use_helpfile(systemHelpFile("partition", buf));
- if (!variable_get(VAR_NO_WARN))
- dialog_mesgbox("Disk slicing warning:", p, -1, -1);
- free(p);
- }
- restorescr(w);
-}
-
-static u_char *
-bootalloc(char *name)
-{
- char buf[FILENAME_MAX];
- struct stat sb;
-
- snprintf(buf, sizeof buf, "/boot/%s", name);
- if (stat(buf, &sb) != -1) {
- int fd;
-
- fd = open(buf, O_RDONLY);
- if (fd != -1) {
- u_char *cp;
-
- cp = malloc(sb.st_size);
- if (read(fd, cp, sb.st_size) != sb.st_size) {
- free(cp);
- close(fd);
- msgDebug("bootalloc: couldn't read %d bytes from %s\n", sb.st_size, buf);
- return NULL;
- }
- close(fd);
- return cp;
- }
- msgDebug("bootalloc: couldn't open %s\n", buf);
- }
- else
- msgDebug("bootalloc: can't stat %s\n", buf);
- return NULL;
-}
-
-static int
-partitionHook(dialogMenuItem *selected)
-{
- Device **devs = NULL;
-
- devs = deviceFind(selected->prompt, DEVICE_TYPE_DISK);
- if (!devs) {
- msgConfirm("Unable to find disk %s!", selected->prompt);
- return DITEM_FAILURE;
- }
- /* Toggle enabled status? */
- if (!devs[0]->enabled) {
- devs[0]->enabled = TRUE;
- diskPartition(devs[0]);
- }
- else
- devs[0]->enabled = FALSE;
- return DITEM_SUCCESS;
-}
-
-static int
-partitionCheck(dialogMenuItem *selected)
-{
- Device **devs = NULL;
-
- devs = deviceFind(selected->prompt, DEVICE_TYPE_DISK);
- if (!devs || devs[0]->enabled == FALSE)
- return FALSE;
- return TRUE;
-}
-
-int
-diskPartitionEditor(dialogMenuItem *self)
-{
- DMenu *menu;
- Device **devs;
- int i, cnt, devcnt;
-
- cnt = diskGetSelectCount(&devs);
- devcnt = deviceCount(devs);
- if (cnt == -1) {
- msgConfirm("No disks found! Please verify that your disk controller is being\n"
- "properly probed at boot time. See the Hardware Guide on the\n"
- "Documentation menu for clues on diagnosing this type of problem.");
- return DITEM_FAILURE;
- }
- else if (cnt) {
- /* Some are already selected */
- for (i = 0; i < devcnt; i++) {
- if (devs[i]->enabled) {
- if (variable_get(VAR_NONINTERACTIVE))
- diskPartitionNonInteractive(devs[i]);
- else
- diskPartition(devs[i]);
- }
- }
- }
- else {
- /* No disks are selected, fall-back case now */
- if (devcnt == 1) {
- devs[0]->enabled = TRUE;
- if (variable_get(VAR_NONINTERACTIVE))
- diskPartitionNonInteractive(devs[0]);
- else
- diskPartition(devs[0]);
- return DITEM_SUCCESS;
- }
- else {
- menu = deviceCreateMenu(&MenuDiskDevices, DEVICE_TYPE_DISK, partitionHook, partitionCheck);
- if (!menu) {
- msgConfirm("No devices suitable for installation found!\n\n"
- "Please verify that your disk controller (and attached drives)\n"
- "were detected properly. This can be done by pressing the\n"
- "[Scroll Lock] key and using the Arrow keys to move back to\n"
- "the boot messages. Press [Scroll Lock] again to return.");
- return DITEM_FAILURE;
- }
- else {
- i = dmenuOpenSimple(menu, FALSE) ? DITEM_SUCCESS : DITEM_FAILURE;
- free(menu);
- }
- return i;
- }
- }
- return DITEM_SUCCESS;
-}
-
-int
-diskPartitionWrite(dialogMenuItem *self)
-{
- Device **devs;
- int i;
- char *cp;
-
- devs = deviceFind(NULL, DEVICE_TYPE_DISK);
- if (!devs) {
- msgConfirm("Unable to find any disks to write to??");
- return DITEM_FAILURE;
- }
- if (isDebug())
- msgDebug("diskPartitionWrite: Examining %d devices\n", deviceCount(devs));
- cp = variable_get(DISK_PARTITIONED);
- if (cp && !strcmp(cp, "written"))
- return DITEM_SUCCESS;
-
- for (i = 0; devs[i]; i++) {
- Disk *d = (Disk *)devs[i]->private;
- static u_char *boot1;
-#ifndef __alpha__
- static u_char *boot2;
-#endif
-
- if (!devs[i]->enabled)
- continue;
-
-#ifdef __alpha__
- if (!boot1) boot1 = bootalloc("boot1");
- Set_Boot_Blocks(d, boot1, NULL);
-#else
- if (!boot1) boot1 = bootalloc("boot1");
- if (!boot2) boot2 = bootalloc("boot2");
- Set_Boot_Blocks(d, boot1, boot2);
-#endif
-
- msgNotify("Writing partition information to drive %s", d->name);
- if (!Fake && Write_Disk(d)) {
- msgConfirm("ERROR: Unable to write data to disk %s!", d->name);
- return DITEM_FAILURE;
- }
-
- /* If we've been through here before, we don't need to do the rest */
- if (cp && !strcmp(cp, "written"))
- return DITEM_SUCCESS;
- }
- /* Now it's not "yes", but "written" */
- variable_set2(DISK_PARTITIONED, "written", 0);
- return DITEM_SUCCESS | DITEM_RESTORE;
-}
-
-/* Partition a disk based wholly on which variables are set */
-static void
-diskPartitionNonInteractive(Device *dev)
-{
- char *cp;
- int i, sz, all_disk = 0;
- u_char *mbrContents;
- Disk *d = (Disk *)dev->private;
-
- record_chunks(d);
- cp = variable_get(VAR_GEOMETRY);
- if (cp) {
- msgDebug("Setting geometry from script to: %s\n", cp);
- d->bios_cyl = strtol(cp, &cp, 0);
- d->bios_hd = strtol(cp + 1, &cp, 0);
- d->bios_sect = strtol(cp + 1, 0, 0);
- }
-
- cp = variable_get(VAR_PARTITION);
- if (cp) {
- if (!strcmp(cp, "free")) {
- /* Do free disk space case */
- for (i = 0; chunk_info[i]; i++) {
- /* If a chunk is at least 10MB in size, use it. */
- if (chunk_info[i]->type == unused && chunk_info[i]->size > (10 * ONE_MEG)) {
- Create_Chunk(d, chunk_info[i]->offset, chunk_info[i]->size, freebsd, 3,
- (chunk_info[i]->flags & CHUNK_ALIGN));
- variable_set2(DISK_PARTITIONED, "yes", 0);
- break;
- }
- }
- if (!chunk_info[i]) {
- msgConfirm("Unable to find any free space on this disk!");
- return;
- }
- }
- else if (!strcmp(cp, "all")) {
- /* Do all disk space case */
- msgDebug("Warning: Devoting all of disk %s to FreeBSD.\n", d->name);
-
- All_FreeBSD(d, FALSE);
- }
- else if (!strcmp(cp, "exclusive")) {
- /* Do really-all-the-disk-space case */
- msgDebug("Warning: Devoting all of disk %s to FreeBSD.\n", d->name);
-
- All_FreeBSD(d, all_disk = TRUE);
- }
- else if ((sz = strtol(cp, &cp, 0))) {
- /* Look for sz bytes free */
- if (*cp && toupper(*cp) == 'M')
- sz *= ONE_MEG;
- else if (*cp && toupper(*cp) == 'G')
- sz *= ONE_GIG;
- for (i = 0; chunk_info[i]; i++) {
- /* If a chunk is at least sz MB, use it. */
- if (chunk_info[i]->type == unused && chunk_info[i]->size >= sz) {
- Create_Chunk(d, chunk_info[i]->offset, sz, freebsd, 3, (chunk_info[i]->flags & CHUNK_ALIGN));
- variable_set2(DISK_PARTITIONED, "yes", 0);
- break;
- }
- }
- if (!chunk_info[i]) {
- msgConfirm("Unable to find %d free blocks on this disk!", sz);
- return;
- }
- }
- else if (!strcmp(cp, "existing")) {
- /* Do existing FreeBSD case */
- for (i = 0; chunk_info[i]; i++) {
- if (chunk_info[i]->type == freebsd)
- break;
- }
- if (!chunk_info[i]) {
- msgConfirm("Unable to find any existing FreeBSD partitions on this disk!");
- return;
- }
- }
- else {
- msgConfirm("`%s' is an invalid value for %s - is config file valid?", cp, VAR_PARTITION);
- return;
- }
- if (!all_disk) {
- mbrContents = getBootMgr(d->name);
- Set_Boot_Mgr(d, mbrContents);
- }
- variable_set2(DISK_PARTITIONED, "yes", 0);
- }
-}
diff --git a/usr.sbin/sysinstall/dispatch.c b/usr.sbin/sysinstall/dispatch.c
deleted file mode 100644
index 0b388b4873cd..000000000000
--- a/usr.sbin/sysinstall/dispatch.c
+++ /dev/null
@@ -1,434 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last program in the `sysinstall' line - the next
- * generation being essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 "sysinstall.h"
-#include <ctype.h>
-#include <errno.h>
-#include <sys/signal.h>
-#include <sys/fcntl.h>
-
-#include "list.h"
-
-static int dispatch_shutdown(dialogMenuItem *unused);
-static int dispatch_systemExecute(dialogMenuItem *unused);
-static int dispatch_msgConfirm(dialogMenuItem *unused);
-
-static struct _word {
- char *name;
- int (*handler)(dialogMenuItem *self);
-} resWords[] = {
- { "configAnonFTP", configAnonFTP },
- { "configRouter", configRouter },
- { "configNFSServer", configNFSServer },
- { "configNTP", configNTP },
- { "configPCNFSD", configPCNFSD },
- { "configPackages", configPackages },
- { "configUsers", configUsers },
- { "configXSetup", configXSetup },
- { "configXDesktop", configXDesktop },
- { "diskPartitionEditor", diskPartitionEditor },
- { "diskPartitionWrite", diskPartitionWrite },
- { "diskLabelEditor", diskLabelEditor },
- { "diskLabelCommit", diskLabelCommit },
- { "distReset", distReset },
- { "distSetCustom", distSetCustom },
- { "distUnsetCustom", distUnsetCustom },
- { "distSetDeveloper", distSetDeveloper },
- { "distSetXDeveloper", distSetXDeveloper },
- { "distSetKernDeveloper", distSetKernDeveloper },
- { "distSetUser", distSetUser },
- { "distSetXUser", distSetXUser },
- { "distSetMinimum", distSetMinimum },
- { "distSetEverything", distSetEverything },
- { "distSetCRYPTO", distSetCRYPTO },
- { "distSetSrc", distSetSrc },
- { "distSetXF86", distSetXF86 },
- { "distExtractAll", distExtractAll },
- { "docBrowser", docBrowser },
- { "docShowDocument", docShowDocument },
- { "installCommit", installCommit },
- { "installExpress", installExpress },
- { "installStandard", installStandard },
- { "installUpgrade", installUpgrade },
- { "installFixupBin", installFixupBin },
- { "installFixupXFree", installFixupXFree },
- { "installFixitHoloShell", installFixitHoloShell },
- { "installFixitCDROM", installFixitCDROM },
- { "installFixitFloppy", installFixitFloppy },
- { "installFilesystems", installFilesystems },
- { "installVarDefaults", installVarDefaults },
- { "loadConfig", dispatch_load_file },
- { "loadFloppyConfig", dispatch_load_floppy },
- { "mediaSetCDROM", mediaSetCDROM },
- { "mediaSetFloppy", mediaSetFloppy },
- { "mediaSetDOS", mediaSetDOS },
- { "mediaSetTape", mediaSetTape },
- { "mediaSetFTP", mediaSetFTP },
- { "mediaSetFTPActive", mediaSetFTPActive },
- { "mediaSetFTPPassive", mediaSetFTPPassive },
- { "mediaSetHTTP", mediaSetHTTP },
- { "mediaSetUFS", mediaSetUFS },
- { "mediaSetNFS", mediaSetNFS },
- { "mediaSetFTPUserPass", mediaSetFTPUserPass },
- { "mediaSetCPIOVerbosity", mediaSetCPIOVerbosity },
- { "mediaGetType", mediaGetType },
- { "msgConfirm", dispatch_msgConfirm },
- { "optionsEditor", optionsEditor },
- { "packageAdd", packageAdd },
- { "addGroup", userAddGroup },
- { "addUser", userAddUser },
- { "shutdown", dispatch_shutdown },
- { "system", dispatch_systemExecute },
- { "dumpVariables", dump_variables },
- { "tcpMenuSelect", tcpMenuSelect },
- { NULL, NULL },
-};
-
-/*
- * Helper routines for buffering data.
- *
- * We read an entire configuration into memory before executing it
- * so that we are truely standalone and can do things like nuke the
- * file or disk we're working on.
- */
-
-typedef struct command_buffer_ {
- qelement queue;
- char * string;
-} command_buffer;
-
-static void
-dispatch_free_command(command_buffer *item)
-{
- REMQUE(item);
- free(item->string);
- free(item);
-}
-
-static void
-dispatch_free_all(qelement *head)
-{
- command_buffer *item;
-
- while (!EMPTYQUE(*head)) {
- item = (command_buffer *) head->q_forw;
- dispatch_free_command(item);
- }
-}
-
-static command_buffer *
-dispatch_add_command(qelement *head, char *string)
-{
- command_buffer *new;
-
- new = malloc(sizeof(command_buffer));
-
- if (!new)
- return NULL;
-
- new->string = strdup(string);
- INSQUEUE(new, head->q_back);
-
- return new;
-}
-
-/*
- * Command processing
- */
-
-/* Just convenience */
-static int
-dispatch_shutdown(dialogMenuItem *unused)
-{
- systemShutdown(0);
- return DITEM_FAILURE;
-}
-
-static int
-dispatch_systemExecute(dialogMenuItem *unused)
-{
- char *cmd = variable_get(VAR_COMMAND);
-
- if (cmd)
- return systemExecute(cmd) ? DITEM_FAILURE : DITEM_SUCCESS;
- else
- msgDebug("_systemExecute: No command passed in `command' variable.\n");
- return DITEM_FAILURE;
-}
-
-static int
-dispatch_msgConfirm(dialogMenuItem *unused)
-{
- char *msg = variable_get(VAR_COMMAND);
-
- if (msg) {
- msgConfirm(msg);
- return DITEM_SUCCESS;
- }
-
- msgDebug("_msgConfirm: No message passed in `command' variable.\n");
- return DITEM_FAILURE;
-}
-
-static int
-call_possible_resword(char *name, dialogMenuItem *value, int *status)
-{
- int i, rval;
-
- rval = 0;
- for (i = 0; resWords[i].name; i++) {
- if (!strcmp(name, resWords[i].name)) {
- *status = resWords[i].handler(value);
- rval = 1;
- break;
- }
- }
- return rval;
-}
-
-/* For a given string, call it or spit out an undefined command diagnostic */
-int
-dispatchCommand(char *str)
-{
- int i;
- char *cp;
-
- if (!str || !*str) {
- msgConfirm("Null or zero-length string passed to dispatchCommand");
- return DITEM_FAILURE;
- }
- /* If it's got a newline, trim it */
- if ((cp = index(str, '\n')) != NULL)
- *cp = '\0';
-
- /* If it's got a `=' sign in there, assume it's a variable setting */
- if (index(str, '=')) {
- if (isDebug())
- msgDebug("dispatch: setting variable `%s'\n", str);
- variable_set(str, 0);
- i = DITEM_SUCCESS;
- }
- else {
- /* A command might be a pathname if it's encoded in argv[0], which
- we also support */
- if ((cp = rindex(str, '/')) != NULL)
- str = cp + 1;
- if (isDebug())
- msgDebug("dispatch: calling resword `%s'\n", str);
- if (!call_possible_resword(str, NULL, &i)) {
- msgNotify("Warning: No such command ``%s''", str);
- i = DITEM_FAILURE;
- }
- }
- return i;
-}
-
-
-/*
- * File processing
- */
-
-static qelement *
-dispatch_load_fp(FILE *fp)
-{
- qelement *head;
- char buf[BUFSIZ], *cp;
-
- head = malloc(sizeof(qelement));
-
- if (!head)
- return NULL;
-
- INITQUE(*head);
-
- while (fgets(buf, sizeof buf, fp)) {
-
- if ((cp = strchr(buf, '\n')) != NULL)
- *cp = '\0';
- if (*buf == '\0' || *buf == '#')
- continue;
-
- if (!dispatch_add_command(head, buf))
- return NULL;
- }
-
- return head;
-}
-
-static int
-dispatch_execute(qelement *head)
-{
- int result = DITEM_SUCCESS;
- command_buffer *item;
- char *old_interactive;
-
- if (!head)
- return result | DITEM_FAILURE;
-
- old_interactive = variable_get(VAR_NONINTERACTIVE);
- if (old_interactive)
- old_interactive = strdup(old_interactive); /* save copy */
-
- /* Hint to others that we're running from a script, should they care */
- variable_set2(VAR_NONINTERACTIVE, "yes", 0);
-
- while (!EMPTYQUE(*head)) {
- item = (command_buffer *) head->q_forw;
-
- if (DITEM_STATUS(dispatchCommand(item->string)) != DITEM_SUCCESS) {
- /*
- * Allow a user to prefix a command with "noError" to cause
- * us to ignore any errors for that one command.
- */
- if (variable_get(VAR_NO_ERROR))
- variable_unset(VAR_NO_ERROR);
- else {
- msgConfirm("Command `%s' failed - rest of script aborted.\n",
- item->string);
- result |= DITEM_FAILURE;
- break;
- }
- }
- dispatch_free_command(item);
- }
-
- dispatch_free_all(head);
-
- if (!old_interactive)
- variable_unset(VAR_NONINTERACTIVE);
- else {
- variable_set2(VAR_NONINTERACTIVE, old_interactive, 0);
- free(old_interactive);
- }
-
- return result;
-}
-
-int
-dispatch_load_file_int(int quiet)
-{
- FILE *fp;
- char *cp;
- int i;
- qelement *list;
-
- static const char *names[] = {
- "install.cfg",
- "/stand/install.cfg",
- "/tmp/install.cfg",
- NULL
- };
-
- fp = NULL;
- cp = variable_get(VAR_CONFIG_FILE);
- if (!cp) {
- for (i = 0; names[i]; i++)
- if ((fp = fopen(names[i], "r")) != NULL)
- break;
- } else
- fp = fopen(cp, "r");
-
- if (!fp) {
- if (!quiet)
- msgConfirm("Unable to open %s: %s", cp, strerror(errno));
- return DITEM_FAILURE;
- }
-
- list = dispatch_load_fp(fp);
- fclose(fp);
-
- return dispatch_execute(list);
-}
-
-int
-dispatch_load_file(dialogMenuItem *self)
-{
- return dispatch_load_file_int(FALSE);
-}
-
-int
-dispatch_load_floppy(dialogMenuItem *self)
-{
- int what = DITEM_SUCCESS;
- extern char *distWanted;
- char *cp;
- FILE *fp;
- qelement *list;
-
- mediaClose();
- cp = variable_get_value(VAR_INSTALL_CFG,
- "Specify the name of a configuration file\n"
- "residing on a MSDOS or UFS floppy.", 0);
- if (!cp || !*cp) {
- variable_unset(VAR_INSTALL_CFG);
- what |= DITEM_FAILURE;
- return what;
- }
-
- distWanted = cp;
- /* Try to open the floppy drive */
- if (DITEM_STATUS(mediaSetFloppy(NULL)) == DITEM_FAILURE) {
- msgConfirm("Unable to set media device to floppy.");
- what |= DITEM_FAILURE;
- mediaClose();
- return what;
- }
-
- if (!mediaDevice->init(mediaDevice)) {
- msgConfirm("Unable to mount floppy filesystem.");
- what |= DITEM_FAILURE;
- mediaClose();
- return what;
- }
-
- fp = mediaDevice->get(mediaDevice, cp, TRUE);
- if (fp) {
- list = dispatch_load_fp(fp);
- fclose(fp);
- mediaClose();
-
- what |= dispatch_execute(list);
- }
- else {
- if (!variable_get(VAR_NO_ERROR))
- msgConfirm("Configuration file '%s' not found.", cp);
- variable_unset(VAR_INSTALL_CFG);
- what |= DITEM_FAILURE;
- mediaClose();
- }
- return what;
-}
-
diff --git a/usr.sbin/sysinstall/dist.c b/usr.sbin/sysinstall/dist.c
deleted file mode 100644
index 3c2ae940714e..000000000000
--- a/usr.sbin/sysinstall/dist.c
+++ /dev/null
@@ -1,947 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last program in the `sysinstall' line - the next
- * generation being essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 "sysinstall.h"
-#include <sys/time.h>
-#include <signal.h>
-#include <libutil.h>
-
-unsigned int Dists;
-unsigned int CRYPTODists;
-unsigned int SrcDists;
-unsigned int XF86Dists;
-unsigned int XF86ServerDists;
-unsigned int XF86FontDists;
-
-typedef struct _dist {
- char *my_name;
- char *my_dir;
- unsigned int *my_mask;
- unsigned int my_bit;
- struct _dist *my_dist;
-} Distribution;
-
-extern Distribution DistTable[];
-extern Distribution CRYPTODistTable[];
-extern Distribution SrcDistTable[];
-extern Distribution XF86DistTable[];
-extern Distribution XF86FontDistTable[];
-extern Distribution XF86ServerDistTable[];
-
-/* The top-level distribution categories */
-static Distribution DistTable[] = {
-{ "bin", "/", &Dists, DIST_BIN, NULL },
-{ "doc", "/", &Dists, DIST_DOC, NULL },
-{ "games", "/", &Dists, DIST_GAMES, NULL },
-{ "manpages", "/", &Dists, DIST_MANPAGES, NULL },
-{ "catpages", "/", &Dists, DIST_CATPAGES, NULL },
-{ "proflibs", "/", &Dists, DIST_PROFLIBS, NULL },
-{ "dict", "/", &Dists, DIST_DICT, NULL },
-{ "info", "/", &Dists, DIST_INFO, NULL },
-{ "src", "/", &Dists, DIST_SRC, SrcDistTable },
-{ "crypto", "/", &Dists, DIST_CRYPTO, CRYPTODistTable },
-#ifdef __i386__
-{ "compat1x", "/", &Dists, DIST_COMPAT1X, NULL },
-{ "compat20", "/", &Dists, DIST_COMPAT20, NULL },
-{ "compat21", "/", &Dists, DIST_COMPAT21, NULL },
-{ "compat22", "/", &Dists, DIST_COMPAT22, NULL },
-{ "compat3x", "/", &Dists, DIST_COMPAT3X, NULL },
-#endif
-{ "ports", "/usr", &Dists, DIST_PORTS, NULL },
-{ "local", "/", &Dists, DIST_LOCAL, NULL },
-{ "XF86336", "/usr", &Dists, DIST_XF86, XF86DistTable },
-{ NULL },
-};
-
-/* The CRYPTO distribution */
-static Distribution CRYPTODistTable[] = {
-{ "crypto", "/", &CRYPTODists, DIST_CRYPTO_CRYPTO, NULL },
-{ "krb4", "/", &CRYPTODists, DIST_CRYPTO_KERBEROS4, NULL },
-{ "krb5", "/", &CRYPTODists, DIST_CRYPTO_KERBEROS5, NULL },
-{ "ssecure", "/usr/src", &CRYPTODists, DIST_CRYPTO_SSECURE, NULL },
-{ "scrypto", "/usr/src", &CRYPTODists, DIST_CRYPTO_SCRYPTO, NULL },
-{ "skrb4", "/usr/src", &CRYPTODists, DIST_CRYPTO_SKERBEROS4, NULL },
-{ "skrb5", "/usr/src", &CRYPTODists, DIST_CRYPTO_SKERBEROS5, NULL },
-{ NULL },
-};
-
-/* The /usr/src distribution */
-static Distribution SrcDistTable[] = {
-{ "sbase", "/usr/src", &SrcDists, DIST_SRC_BASE, NULL },
-{ "scontrib", "/usr/src", &SrcDists, DIST_SRC_CONTRIB, NULL },
-{ "sgnu", "/usr/src", &SrcDists, DIST_SRC_GNU, NULL },
-{ "setc", "/usr/src", &SrcDists, DIST_SRC_ETC, NULL },
-{ "sgames", "/usr/src", &SrcDists, DIST_SRC_GAMES, NULL },
-{ "sinclude", "/usr/src", &SrcDists, DIST_SRC_INCLUDE, NULL },
-{ "slib", "/usr/src", &SrcDists, DIST_SRC_LIB, NULL },
-{ "slibexec", "/usr/src", &SrcDists, DIST_SRC_LIBEXEC, NULL },
-{ "srelease", "/usr/src", &SrcDists, DIST_SRC_RELEASE, NULL },
-{ "sbin", "/usr/src", &SrcDists, DIST_SRC_BIN, NULL },
-{ "ssbin", "/usr/src", &SrcDists, DIST_SRC_SBIN, NULL },
-{ "sshare", "/usr/src", &SrcDists, DIST_SRC_SHARE, NULL },
-{ "ssys", "/usr/src", &SrcDists, DIST_SRC_SYS, NULL },
-{ "subin", "/usr/src", &SrcDists, DIST_SRC_UBIN, NULL },
-{ "susbin", "/usr/src", &SrcDists, DIST_SRC_USBIN, NULL },
-{ "stools", "/usr/src", &SrcDists, DIST_SRC_TOOLS, NULL },
-{ NULL },
-};
-
-/* The XFree86 distribution */
-static Distribution XF86DistTable[] = {
-{ "XF86336", "/usr/X11R6", &XF86Dists, DIST_XF86_FONTS, XF86FontDistTable },
-{ "XF86336", "/usr/X11R6", &XF86Dists, DIST_XF86_SERVER, XF86ServerDistTable },
-{ "Xbin", "/usr/X11R6", &XF86Dists, DIST_XF86_BIN, NULL },
-{ "Xcfg", "/usr/X11R6", &XF86Dists, DIST_XF86_CFG, NULL },
-{ "Xdoc", "/usr/X11R6", &XF86Dists, DIST_XF86_DOC, NULL },
-{ "Xhtml", "/usr/X11R6", &XF86Dists, DIST_XF86_HTML, NULL },
-{ "Xlib", "/usr/X11R6", &XF86Dists, DIST_XF86_LIB, NULL },
-{ "Xlk98", "/usr/X11R6", &XF86Dists, DIST_XF86_LKIT98, NULL },
-{ "Xlkit", "/usr/X11R6", &XF86Dists, DIST_XF86_LKIT, NULL },
-{ "Xman", "/usr/X11R6", &XF86Dists, DIST_XF86_MAN, NULL },
-{ "Xprog", "/usr/X11R6", &XF86Dists, DIST_XF86_PROG, NULL },
-{ "Xps", "/usr/X11R6", &XF86Dists, DIST_XF86_PS, NULL },
-{ "Xset", "/usr/X11R6", &XF86Dists, DIST_XF86_SET, NULL },
-{ "X9set", "/usr/X11R6", &XF86Dists, DIST_XF86_9SET, NULL },
-{ NULL },
-};
-
-/* The XFree86 server distribution */
-static Distribution XF86ServerDistTable[] = {
-#ifdef __i386__
-{ "PC98-Servers/X9480", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_9480, NULL },
-{ "PC98-Servers/X9EGC", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_9EGC, NULL },
-{ "PC98-Servers/X9GA9", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_9GA9, NULL },
-{ "PC98-Servers/X9GAN", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_9GAN, NULL },
-{ "PC98-Servers/X9LPW", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_9LPW, NULL },
-{ "PC98-Servers/X9MGA", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_9MGA, NULL },
-{ "PC98-Servers/X9NKV", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_9NKV, NULL },
-{ "PC98-Servers/X9NS3", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_9NS3, NULL },
-{ "PC98-Servers/X9SPW", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_9SPW, NULL },
-{ "PC98-Servers/X9SVG", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_9SVG, NULL },
-{ "PC98-Servers/X9TGU", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_9TGU, NULL },
-{ "PC98-Servers/X9WEP", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_9WEP, NULL },
-{ "PC98-Servers/X9WS", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_9WS, NULL },
-{ "PC98-Servers/X9WSN", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_9WSN, NULL },
-#endif
-{ "Servers/X3DL", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_3DL, NULL },
-{ "Servers/X8514", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_8514, NULL },
-{ "Servers/XAGX", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_AGX, NULL },
-{ "Servers/XI128", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_I128, NULL },
-{ "Servers/XMa8", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_MACH8, NULL },
-{ "Servers/XMa32", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_MACH32,NULL },
-{ "Servers/XMa64", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_MACH64,NULL },
-{ "Servers/XMono", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_MONO, NULL },
-{ "Servers/XP9K", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_P9000, NULL },
-{ "Servers/XS3", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_S3, NULL },
-{ "Servers/XS3V", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_S3V, NULL },
-{ "Servers/XSVGA", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_SVGA, NULL },
-{ "Servers/XVG16", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_VGA16, NULL },
-{ "Servers/XW32", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_W32, NULL },
-#ifdef __alpha__
-{ "Servers/XTGA", "/usr/X11R6", &XF86ServerDists, DIST_XF86_SERVER_TGA, NULL },
-#endif
-{ NULL },
-};
-
-/* The XFree86 font distribution */
-static Distribution XF86FontDistTable[] = {
-{ "Xfnts", "/usr/X11R6", &XF86FontDists, DIST_XF86_FONTS_MISC, NULL },
-{ "Xf100", "/usr/X11R6", &XF86FontDists, DIST_XF86_FONTS_100, NULL },
-{ "Xfcyr", "/usr/X11R6", &XF86FontDists, DIST_XF86_FONTS_CYR, NULL },
-{ "Xfscl", "/usr/X11R6", &XF86FontDists, DIST_XF86_FONTS_SCALE, NULL },
-{ "Xfnon", "/usr/X11R6", &XF86FontDists, DIST_XF86_FONTS_NON, NULL },
-{ "Xfsrv", "/usr/X11R6", &XF86FontDists, DIST_XF86_FONTS_SERVER, NULL },
-{ NULL },
-};
-
-static int distMaybeSetCRYPTO(dialogMenuItem *self);
-static int distMaybeSetPorts(dialogMenuItem *self);
-
-static void
-distVerifyFlags(void)
-{
- if (SrcDists)
- Dists |= DIST_SRC;
- if (CRYPTODists) {
- if (CRYPTODists & (DIST_CRYPTO_KERBEROS4 | DIST_CRYPTO_KERBEROS5))
- CRYPTODists |= DIST_CRYPTO_CRYPTO;
- Dists |= DIST_CRYPTO;
- }
- if (XF86Dists & DIST_XF86_SET)
- XF86ServerDists |= DIST_XF86_SERVER_VGA16;
- if (XF86ServerDists)
- XF86Dists |= DIST_XF86_SERVER;
- if (XF86FontDists)
- XF86Dists |= DIST_XF86_FONTS;
- if (XF86Dists || XF86ServerDists || XF86FontDists) {
- Dists |= DIST_XF86;
-#ifdef __i386__
- Dists |= DIST_COMPAT22; /* For certain old X applications */
-#if __FreeBSD__ > 3
- Dists |= DIST_COMPAT3X;
-#endif
-#endif
- }
- if (isDebug())
- msgDebug("Dist Masks: Dists: %0x, CRYPTO: %0x, Srcs: %0x\nXServer: %0x, XFonts: %0x, XDists: %0x\n",
- Dists, CRYPTODists, SrcDists, XF86ServerDists, XF86FontDists, XF86Dists);
-}
-
-int
-distReset(dialogMenuItem *self)
-{
- Dists = 0;
- CRYPTODists = 0;
- SrcDists = 0;
- XF86Dists = 0;
- XF86ServerDists = 0;
- XF86FontDists = 0;
- return DITEM_SUCCESS | DITEM_REDRAW;
-}
-
-int
-distConfig(dialogMenuItem *self)
-{
- char *cp;
-
- distReset(NULL);
-
- if ((cp = variable_get(VAR_DIST_MAIN)) != NULL)
- Dists = atoi(cp);
-
- if ((cp = variable_get(VAR_DIST_CRYPTO)) != NULL)
- CRYPTODists = atoi(cp);
-
- if ((cp = variable_get(VAR_DIST_SRC)) != NULL)
- SrcDists = atoi(cp);
-
- if ((cp = variable_get(VAR_DIST_X11)) != NULL)
- XF86Dists = atoi(cp);
-
- if ((cp = variable_get(VAR_DIST_XSERVER)) != NULL)
- XF86ServerDists = atoi(cp);
-
- if ((cp = variable_get(VAR_DIST_XFONTS)) != NULL)
- XF86FontDists = atoi(cp);
- distVerifyFlags();
- return DITEM_SUCCESS | DITEM_REDRAW;
-}
-
-static int
-distSetX(void)
-{
- Dists |= DIST_XF86;
- XF86Dists = DIST_XF86_BIN | DIST_XF86_SET | DIST_XF86_CFG | DIST_XF86_LIB | DIST_XF86_PROG | DIST_XF86_MAN | DIST_XF86_SERVER | DIST_XF86_FONTS;
- XF86ServerDists = DIST_XF86_SERVER_SVGA | DIST_XF86_SERVER_VGA16;
- XF86FontDists = DIST_XF86_FONTS_MISC;
-#ifndef X_AS_PKG
- return distSetXF86(NULL);
-#endif
- return DITEM_SUCCESS;
-}
-
-int
-distSetDeveloper(dialogMenuItem *self)
-{
- int i;
-
- distReset(NULL);
- Dists = _DIST_DEVELOPER;
- SrcDists = DIST_SRC_ALL;
- i = distMaybeSetCRYPTO(self) | distMaybeSetPorts(self);
- distVerifyFlags();
- return i;
-}
-
-int
-distSetXDeveloper(dialogMenuItem *self)
-{
- int i;
-
- i = distSetDeveloper(self);
- i |= distSetX();
- distVerifyFlags();
- return i;
-}
-
-int
-distSetKernDeveloper(dialogMenuItem *self)
-{
- int i;
-
- distReset(NULL);
- Dists = _DIST_DEVELOPER;
- SrcDists = DIST_SRC_SYS;
- i = distMaybeSetCRYPTO(self) | distMaybeSetPorts(self);
- distVerifyFlags();
- return i;
-}
-
-int
-distSetXKernDeveloper(dialogMenuItem *self)
-{
- int i;
-
- i = distSetKernDeveloper(self);
- i |= distSetX();
- distVerifyFlags();
- return i;
-}
-
-int
-distSetUser(dialogMenuItem *self)
-{
- int i;
-
- distReset(NULL);
- Dists = _DIST_USER;
- i = distMaybeSetCRYPTO(self) | distMaybeSetPorts(self);
- distVerifyFlags();
- return i;
-}
-
-int
-distSetXUser(dialogMenuItem *self)
-{
- int i;
-
- i = distSetUser(self);
- i |= distSetX();
- distVerifyFlags();
- return i;
-}
-
-int
-distSetMinimum(dialogMenuItem *self)
-{
- distReset(NULL);
- Dists = DIST_BIN;
- return DITEM_SUCCESS | DITEM_REDRAW;
-}
-
-int
-distSetEverything(dialogMenuItem *self)
-{
- int i;
-
- Dists = DIST_ALL | DIST_XF86;
- SrcDists = DIST_SRC_ALL;
- XF86Dists = DIST_XF86_ALL;
- XF86ServerDists = DIST_XF86_SERVER_ALL;
- XF86FontDists = DIST_XF86_FONTS_ALL;
- i = distMaybeSetCRYPTO(self) | distMaybeSetPorts(self);
- distVerifyFlags();
- return i;
-}
-
-int
-distSetCRYPTO(dialogMenuItem *self)
-{
- int i;
-
- dialog_clear_norefresh();
- if (!dmenuOpenSimple(&MenuCRYPTODistributions, FALSE))
- i = DITEM_FAILURE;
- else
- i = DITEM_SUCCESS;
- distVerifyFlags();
- return i | DITEM_REDRAW | DITEM_RESTORE;
-}
-
-static int
-distMaybeSetCRYPTO(dialogMenuItem *self)
-{
- int i = DITEM_SUCCESS | DITEM_REDRAW;
-
- dialog_clear_norefresh();
- if (!msgYesNo("Do you wish to install cryptographic software?\n\n"
- "If you choose No, FreeBSD will use an MD5 based password scheme which,\n"
- "while perhaps more secure, is not interoperable with the traditional\n"
- "DES-based passwords on other Unix systems. There will also be some\n"
- "differences in the type of RSA code you use.\n\n"
- "Please do NOT choose Yes at this point if you are outside the\n"
- "United States and Canada and are installing from a U.S. FTP server.\n"
- "Instead, install everything but the crypto bits from the U.S. site\n"
- "and then switch to an international FTP server to install crypto on\n"
- "a second pass with the Custom Installation option.")) {
- if (!dmenuOpenSimple(&MenuCRYPTODistributions, FALSE))
- i = DITEM_FAILURE;
- }
-
- dialog_clear_norefresh();
- USAResident = !msgYesNo("Are you actually resident in the United States?");
-
- distVerifyFlags();
- return i | DITEM_REDRAW | DITEM_RESTORE;
-}
-
-static int
-distMaybeSetPorts(dialogMenuItem *self)
-{
- dialog_clear_norefresh();
- if (!msgYesNo("Would you like to install the FreeBSD ports collection?\n\n"
- "This will give you ready access to over 3000 ported software packages,\n"
- "at a cost of around 70MB of disk space when \"clean\" and possibly\n"
- "much more than that when a lot of the distribution tarballs are loaded\n"
- "(unless you have the extra CDs available from a FreeBSD CDROM distribution\n"
- "and can mount them on /cdrom, in which case this is far less of a problem).\n\n"
- "The ports collection is a very valuable resource and well worth having\n"
- "on your /usr partition, so it is advisable to say Yes to this option.\n\n"
- "For more information on the ports collection & the latest ports, visit:\n"
- " http://www.freebsd.org/ports\n"))
- Dists |= DIST_PORTS;
- else
- Dists &= ~DIST_PORTS;
- return DITEM_SUCCESS | DITEM_RESTORE;
-}
-
-static Boolean
-distSetByName(Distribution *dist, char *name)
-{
- int i, status = FALSE;
-
- /* Loop through current set */
- for (i = 0; dist[i].my_name; i++) {
- /* This is shorthand for "dist currently disabled" */
- if (!dist[i].my_dir)
- continue;
- if (!strcmp(dist[i].my_name, name)) {
- *(dist[i].my_mask) |= dist[i].my_bit;
- status = TRUE;
- }
- if (dist[i].my_dist) {
- if (distSetByName(dist[i].my_dist, name)) {
- status = TRUE;
- }
- }
- }
- distVerifyFlags();
- return status;
-}
-
-static Boolean
-distUnsetByName(Distribution *dist, char *name)
-{
- int i, status = FALSE;
-
- /* Loop through current set */
- for (i = 0; dist[i].my_name; i++) {
- /* This is shorthand for "dist currently disabled" */
- if (!dist[i].my_dir)
- continue;
- if (!strcmp(dist[i].my_name, name)) {
- *(dist[i].my_mask) &= ~(dist[i].my_bit);
- status = TRUE;
- }
- if (dist[i].my_dist) {
- if (distUnsetByName(dist[i].my_dist, name)) {
- status = TRUE;
- }
- }
- }
- return status;
-}
-
-/* Just for the dispatch stuff */
-int
-distSetCustom(dialogMenuItem *self)
-{
- char *cp, *cp2, *tmp;
-
- if (!(tmp = variable_get(VAR_DISTS))) {
- msgDebug("distSetCustom() called without %s variable set.\n", VAR_DISTS);
- return DITEM_FAILURE;
- }
-
- cp = alloca(strlen(tmp) + 1);
- if (!cp)
- msgFatal("Couldn't alloca() %d bytes!\n", strlen(tmp) + 1);
- strcpy(cp, tmp);
- while (cp) {
- if ((cp2 = index(cp, ' ')) != NULL)
- *(cp2++) = '\0';
- if (!distSetByName(DistTable, cp))
- msgDebug("distSetCustom: Warning, no such release \"%s\"\n", cp);
- cp = cp2;
- }
- distVerifyFlags();
- return DITEM_SUCCESS;
-}
-
-/* Just for the dispatch stuff */
-int
-distUnsetCustom(dialogMenuItem *self)
-{
- char *cp, *cp2, *tmp;
-
- if (!(tmp = variable_get(VAR_DISTS))) {
- msgDebug("distUnsetCustom() called without %s variable set.\n", VAR_DISTS);
- return DITEM_FAILURE;
- }
-
- cp = alloca(strlen(tmp) + 1);
- if (!cp)
- msgFatal("Couldn't alloca() %d bytes!\n", strlen(tmp) + 1);
- strcpy(cp, tmp);
- while (cp) {
- if ((cp2 = index(cp, ' ')) != NULL)
- *(cp2++) = '\0';
- if (!distUnsetByName(DistTable, cp))
- msgDebug("distUnsetCustom: Warning, no such release \"%s\"\n", cp);
- cp = cp2;
- }
- return DITEM_SUCCESS;
-}
-
-int
-distSetSrc(dialogMenuItem *self)
-{
- int i;
-
- dialog_clear_norefresh();
- if (!dmenuOpenSimple(&MenuSrcDistributions, FALSE))
- i = DITEM_FAILURE;
- else
- i = DITEM_SUCCESS;
- distVerifyFlags();
- return i | DITEM_RESTORE;
-}
-
-int
-distSetXF86(dialogMenuItem *self)
-{
- int i = DITEM_SUCCESS;
-
- dialog_clear_norefresh();
- if (!dmenuOpenSimple(&MenuXF86Select, FALSE))
- i = DITEM_FAILURE;
- distVerifyFlags();
- return i | DITEM_RESTORE;
-}
-
-static Boolean got_intr = FALSE;
-
-/* timeout handler */
-static void
-handle_intr(int sig)
-{
- msgDebug("User generated interrupt.\n");
- got_intr = TRUE;
-}
-
-static int
-check_for_interrupt(void)
-{
- if (got_intr) {
- got_intr = FALSE;
- return TRUE;
- }
- return FALSE;
-}
-
-static Boolean
-distExtract(char *parent, Distribution *me)
-{
- int i,j, status, total, intr;
- int cpid, zpid, fd2, chunk, numchunks;
- char *path, *dist, buf[300000];
- const char *tmp;
- FILE *fp;
- WINDOW *w = savescr();
- struct timeval start, stop;
- struct sigaction old, new;
- properties dist_attr = NULL;
-
- status = TRUE;
- if (isDebug())
- msgDebug("distExtract: parent: %s, me: %s\n", parent ? parent : "(none)", me->my_name);
-
- /* Make ^C fake a sudden timeout */
- new.sa_handler = handle_intr;
- new.sa_flags = 0;
- (void)sigemptyset(&new.sa_mask);
- dialog_clear_norefresh();
- dialog_msgbox("Please Wait", "Extracting all requested distributions...", -1, -1, 0);
- sigaction(SIGINT, &new, &old);
-
- /* Loop through to see if we're in our parent's plans */
- for (i = 0; me[i].my_name; i++) {
- dist = me[i].my_name;
- path = parent ? parent : dist;
-
- /* If our bit isn't set, go to the next */
- if (!(me[i].my_bit & *(me[i].my_mask)))
- continue;
-
- /* This is shorthand for "dist currently disabled" */
- if (!me[i].my_dir) {
- *(me[i].my_mask) &= ~(me[i].my_bit);
- continue;
- }
-
- /* Recurse if we actually have a sub-distribution */
- if (me[i].my_dist) {
- if ((status = distExtract(dist, me[i].my_dist)) == TRUE)
- *(me[i].my_mask) &= ~(me[i].my_bit);
- goto done;
- }
-
- /*
- * Try to get distribution as multiple pieces, locating and parsing an
- * info file which tells us how many we need for this distribution.
- */
- numchunks = 0;
- snprintf(buf, sizeof buf, "%s/%s.inf", path, dist);
-
- getinfo:
- fp = mediaDevice->get(mediaDevice, buf, TRUE);
- intr = check_for_interrupt();
- if (fp == (FILE *)IO_ERROR || intr || !mediaDevice) {
- /* Hard error, can't continue */
- if (!msgYesNo("Unable to open %s: %s.\nReinitialize media?",
- buf, !intr ? "I/O error." : "User interrupt.")) {
- mediaDevice->shutdown(mediaDevice);
- if (!mediaDevice->init(mediaDevice)) {
- status = FALSE;
- goto done;
- }
- else
- goto getinfo;
- }
- else {
- status = FALSE;
- goto done;
- }
- }
- else if (fp > 0) {
- if (isDebug())
- msgDebug("Parsing attributes file for distribution %s\n", dist);
-
- dist_attr = properties_read(fileno(fp));
- intr = check_for_interrupt();
- if (intr || !dist_attr) {
- msgConfirm("Cannot parse information file for the %s distribution: %s\n"
- "Please verify that your media is valid and try again.",
- dist, !intr ? "I/O error" : "User interrupt");
- }
- else {
- tmp = property_find(dist_attr, "Pieces");
- if (tmp)
- numchunks = strtol(tmp, 0, 0);
- }
- fclose(fp);
- if (!numchunks)
- continue;
- }
- else {
- /* Try to get the distribution as a single file */
- snprintf(buf, sizeof buf, "%s/%s.tgz", path, dist);
- /*
- * Passing TRUE as 3rd parm to get routine makes this a "probing" get, for which errors
- * are not considered too significant.
- */
- getsingle:
- fp = mediaDevice->get(mediaDevice, buf, TRUE);
- intr = check_for_interrupt();
- if (fp == (FILE *)IO_ERROR || intr || !mediaDevice) {
- /* Hard error, can't continue */
- if (intr) /* result of an interrupt */
- msgConfirm("Unable to open %s: User interrupt", buf);
- else
- msgConfirm("Unable to open %s: I/O error", buf);
- mediaDevice->shutdown(mediaDevice);
- if (!mediaDevice->init(mediaDevice)) {
- status = FALSE;
- goto done;
- }
- else
- goto getsingle;
- }
- else if (fp > 0) {
- char *dir = root_bias(me[i].my_dir);
-
- dialog_clear_norefresh();
- msgNotify("Extracting %s into %s directory...", dist, dir);
- status = mediaExtractDist(dir, dist, fp);
- fclose(fp);
- goto done;
- }
- else {
- status = FALSE;
- goto done;
- }
- }
-
- /* Fall through from "we got the attribute file, now get the pieces" step */
- if (!numchunks)
- continue;
-
- if (isDebug())
- msgDebug("Attempting to extract distribution from %u chunks.\n", numchunks);
-
- total = 0;
- (void)gettimeofday(&start, (struct timezone *)0);
-
- /* We have one or more chunks, initialize unpackers... */
- mediaExtractDistBegin(root_bias(me[i].my_dir), &fd2, &zpid, &cpid);
-
- /* And go for all the chunks */
- dialog_clear_norefresh();
- for (chunk = 0; chunk < numchunks; chunk++) {
- int n, retval, last_msg, chunksize, realsize;
- char prompt[80];
-
- last_msg = 0;
-
- getchunk:
- snprintf(buf, sizeof buf, "cksum.%c%c", (chunk / 26) + 'a', (chunk % 26) + 'a');
- tmp = property_find(dist_attr, buf);
- chunksize = 0;
- if (tmp) {
- tmp=index(tmp, ' ');
- chunksize = strtol(tmp, 0, 0);
- }
- snprintf(buf, sizeof buf, "%s/%s.%c%c", path, dist, (chunk / 26) + 'a', (chunk % 26) + 'a');
- if (isDebug())
- msgDebug("trying for piece %d of %d: %s\n", chunk + 1, numchunks, buf);
- fp = mediaDevice->get(mediaDevice, buf, FALSE);
- intr = check_for_interrupt();
- if (fp <= (FILE *)0 || intr) {
- if (fp == (FILE *)0)
- msgConfirm("Failed to find %s on this media. Reinitializing media.", buf);
- else
- msgConfirm("failed to retreive piece file %s.\n"
- "%s: Reinitializing media.", buf, !intr ? "I/O error" : "User interrupt");
- mediaDevice->shutdown(mediaDevice);
- if (!mediaDevice->init(mediaDevice))
- goto punt;
- else
- goto getchunk;
- }
-
- snprintf(prompt, sizeof prompt, "Extracting %s into %s directory...", dist, root_bias(me[i].my_dir));
- dialog_gauge("Progress", prompt, 8, 15, 6, 50, (int)((float)(chunk + 1) / numchunks * 100));
-
- realsize = 0;
- while (1) {
- int seconds;
-
- n = fread(buf + realsize, 1, BUFSIZ, fp);
- if (check_for_interrupt()) {
- msgConfirm("Media read error: User interrupt.");
- fclose(fp);
- goto punt;
- }
- else if (n <= 0)
- break;
- total += n;
- realsize += n;
-
- /* Print statistics about how we're doing */
- (void) gettimeofday(&stop, (struct timezone *)0);
- stop.tv_sec = stop.tv_sec - start.tv_sec;
- stop.tv_usec = stop.tv_usec - start.tv_usec;
- if (stop.tv_usec < 0)
- stop.tv_sec--, stop.tv_usec += 1000000;
- seconds = stop.tv_sec + (stop.tv_usec / 1000000.0);
- if (!seconds)
- seconds = 1;
-
- if (seconds != last_msg) {
- last_msg = seconds;
- msgInfo("%10d bytes read from %s dist, chunk %2d of %2d @ %.1f KB/sec.",
- total, dist, chunk + 1, numchunks, (total / seconds) / 1024.0);
- }
- }
- fclose(fp);
-
- if (!chunksize || (realsize == chunksize)) {
- /* No substitution necessary */
- retval = write(fd2, buf, realsize);
- if (retval != realsize) {
- fclose(fp);
- dialog_clear_norefresh();
- msgConfirm("Write failure on transfer! (wrote %d bytes of %d bytes)", retval, realsize);
- goto punt;
- }
- } else {
- for (j = 0; j < realsize; j++) {
- /* On finding CRLF, skip the CR; don't exceed end of buffer. */
- if ((buf[j] != 0x0d) || (j == total - 1) || (buf[j + 1] != 0x0a)) {
- retval = write(fd2, buf + j, 1);
- if (retval != 1) {
- fclose(fp);
- dialog_clear_norefresh();
- msgConfirm("Write failure on transfer! (wrote %d bytes of %d bytes)", j, chunksize);
- goto punt;
- }
- }
- }
- }
- }
- close(fd2);
- status = mediaExtractDistEnd(zpid, cpid);
- goto done;
-
- punt:
- close(fd2);
- mediaExtractDistEnd(zpid, cpid);
- status = FALSE;
-
- done:
- if (!status) {
- dialog_clear_norefresh();
- if (me[i].my_dist) {
- msgConfirm("Unable to transfer all components of the %s distribution.\n"
- "You may wish to switch media types and try again.\n", me[i].my_name);
- }
- else {
- status = msgYesNo("Unable to transfer the %s distribution from\n%s.\n\n"
- "Do you want to try to retrieve it again?",
- me[i].my_name, mediaDevice->name);
- if (!status)
- --i;
- }
- }
- /* If extract was successful, remove ourselves from further consideration */
- if (status)
- *(me[i].my_mask) &= ~(me[i].my_bit);
- else
- continue;
- }
- properties_free(dist_attr);
- sigaction(SIGINT, &old, NULL); /* Restore signal handler */
- restorescr(w);
- return status;
-}
-
-static void
-printSelected(char *buf, int selected, Distribution *me, int *col)
-{
- int i;
-
- /* Loop through to see if we're in our parent's plans */
- for (i = 0; me[i].my_name; i++) {
-
- /* If our bit isn't set, go to the next */
- if (!(me[i].my_bit & selected))
- continue;
-
- /* This is shorthand for "dist currently disabled" */
- if (!me[i].my_dir)
- continue;
-
- *col += strlen(me[i].my_name);
- if (*col > 50) {
- *col = 0;
- strcat(buf, "\n");
- }
- sprintf(&buf[strlen(buf)], " %s", me[i].my_name);
- /* Recurse if have a sub-distribution */
- if (me[i].my_dist)
- printSelected(buf, *(me[i].my_mask), me[i].my_dist, col);
- }
-}
-
-int
-distExtractAll(dialogMenuItem *self)
-{
- int old_dists, retries = 0, status = DITEM_SUCCESS;
- char buf[512];
- WINDOW *w;
-#ifdef X_AS_PKG
- int want_x_package = 0;
-#endif
-
- /* paranoia */
- if (!Dists) {
- if (!dmenuOpenSimple(&MenuSubDistributions, FALSE) || !Dists)
- return DITEM_FAILURE;
- }
-
- if (!mediaVerify() || !mediaDevice->init(mediaDevice))
- return DITEM_FAILURE;
-
- old_dists = Dists;
- distVerifyFlags();
-
- dialog_clear_norefresh();
- w = savescr();
- msgNotify("Attempting to install all selected distributions..");
-
-#ifdef X_AS_PKG
- /* Clear any XFree86 dist flags, but remember they were present. */
- if(Dists & DIST_XF86)
- want_x_package = 1;
- Dists &= ~DIST_XF86;
- /*Dists &= ~(DIST_XF86 | XF86Dists | XF86ServerDists | XF86FontDists);*/
-#endif
-
- /* Try for 3 times around the loop, then give up. */
- while (Dists && ++retries < 3)
- distExtract(NULL, DistTable);
-
-#ifdef X_AS_PKG
- if (want_x_package)
- status |= installX11package(NULL);
-#endif
-
- dialog_clear_norefresh();
- /* Only do bin fixup if bin dist was successfully extracted */
- if ((old_dists & DIST_BIN) && !(Dists & DIST_BIN))
- status |= installFixupBin(self);
- if (old_dists & DIST_XF86)
- status |= installFixupXFree(self);
-
- /* Clear any local dist flags now */
- Dists &= ~DIST_LOCAL;
-
- if (Dists) {
- int col = 0;
-
- buf[0] = '\0';
- dialog_clear_norefresh();
- printSelected(buf, Dists, DistTable, &col);
- dialog_clear_norefresh();
- if (col) {
- msgConfirm("Couldn't extract the following distributions. This may\n"
- "be because they were not available on the installation\n"
- "media you've chosen:\n\n\t%s", buf);
- }
- }
- restorescr(w);
- return status;
-}
diff --git a/usr.sbin/sysinstall/dist.h b/usr.sbin/sysinstall/dist.h
deleted file mode 100644
index c873c388a79e..000000000000
--- a/usr.sbin/sysinstall/dist.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/* $FreeBSD$ */
-
-#ifndef _DIST_H_INCLUDE
-#define _DIST_H_INCLUDE
-
-/* Bitfields for distributions - hope we never have more than 32! :-) */
-#define DIST_BIN 0x00001
-#define DIST_GAMES 0x00002
-#define DIST_MANPAGES 0x00004
-#define DIST_PROFLIBS 0x00008
-#define DIST_DICT 0x00010
-#define DIST_SRC 0x00020
-#define DIST_DOC 0x00040
-#define DIST_INFO 0x00080
-#ifdef __i386__ /* only applicable on x86 */
-#define DIST_COMPAT1X 0x00100
-#define DIST_COMPAT20 0x00200
-#define DIST_COMPAT21 0x00400
-#define DIST_COMPAT22 0x00800
-#define DIST_COMPAT3X 0x01000
-#endif
-#define DIST_XF86 0x02000
-#define DIST_CRYPTO 0x04000
-#define DIST_CATPAGES 0x08000
-#define DIST_PORTS 0x10000
-#define DIST_LOCAL 0x20000
-#define DIST_ALL 0x3FFFF
-
-/* Canned distribution sets */
-#define _DIST_DEVELOPER \
- (DIST_BIN | DIST_DOC | DIST_MANPAGES | DIST_DICT | DIST_PROFLIBS | DIST_INFO | DIST_SRC )
-
-#define _DIST_USER \
- (DIST_BIN | DIST_DOC | DIST_MANPAGES | DIST_DICT )
-
-/* Subtypes for CRYPTO distribution */
-#define DIST_CRYPTO_CRYPTO 0x0001
-#define DIST_CRYPTO_SCRYPTO 0x0002
-#define DIST_CRYPTO_SSECURE 0x0004
-#if __FreeBSD__ <= 3
-#define DIST_CRYPTO_KERBEROS 0x0008
-#else
-#define DIST_CRYPTO_KERBEROS4 0x0008
-#define DIST_CRYPTO_KERBEROS5 0x0010
-#define DIST_CRYPTO_SKERBEROS4 0x0020
-#define DIST_CRYPTO_SKERBEROS5 0x0040
-#endif
-#define DIST_CRYPTO_ALL 0x007F
-
-/* Subtypes for SRC distribution */
-#define DIST_SRC_BASE 0x00001
-#define DIST_SRC_CONTRIB 0x00002
-#define DIST_SRC_GNU 0x00004
-#define DIST_SRC_ETC 0x00008
-#define DIST_SRC_GAMES 0x00010
-#define DIST_SRC_INCLUDE 0x00020
-#define DIST_SRC_LIB 0x00040
-#define DIST_SRC_LIBEXEC 0x00080
-#define DIST_SRC_TOOLS 0x00100
-#define DIST_SRC_RELEASE 0x00200
-#define DIST_SRC_SBIN 0x00400
-#define DIST_SRC_SHARE 0x00800
-#define DIST_SRC_SYS 0x01000
-#define DIST_SRC_UBIN 0x02000
-#define DIST_SRC_USBIN 0x04000
-#define DIST_SRC_BIN 0x08000
-#define DIST_SRC_ALL 0x0FFFF
-
-/* Subtypes for XFree86 distribution */
-#define DIST_XF86_BIN 0x0001
-#define DIST_XF86_CFG 0x0002
-#define DIST_XF86_DOC 0x0004
-#define DIST_XF86_HTML 0x0008
-#define DIST_XF86_LIB 0x0010
-#define DIST_XF86_LKIT98 0x0020
-#define DIST_XF86_LKIT 0x0040
-#define DIST_XF86_MAN 0x0080
-#define DIST_XF86_PROG 0x0100
-#define DIST_XF86_PS 0x0200
-#define DIST_XF86_SET 0x0400
-#define DIST_XF86_9SET 0x0800
-#define DIST_XF86_MISC_ALL 0x0FFF
-#define DIST_XF86_SERVER 0x8000
-#ifdef __i386__
-#define DIST_XF86_SERVER_9MGA 0x0000001
-#define DIST_XF86_SERVER_9480 0x0000002
-#define DIST_XF86_SERVER_9EGC 0x0000004
-#define DIST_XF86_SERVER_9GA9 0x0000008
-#define DIST_XF86_SERVER_9GAN 0x0000010
-#define DIST_XF86_SERVER_9LPW 0x0000020
-#define DIST_XF86_SERVER_9NKV 0x0000040
-#define DIST_XF86_SERVER_9NS3 0x0000080
-#define DIST_XF86_SERVER_9SVG 0x0000100
-#define DIST_XF86_SERVER_9SPW 0x0000200
-#define DIST_XF86_SERVER_9TGU 0x0000400
-#define DIST_XF86_SERVER_9WEP 0x0000800
-#define DIST_XF86_SERVER_9WS 0x0001000
-#define DIST_XF86_SERVER_9WSN 0x0002000
-#elif __alpha__
-#define DIST_XF86_SERVER_TGA 0x0000001
-#endif
-#define DIST_XF86_SERVER_8514 0x0004000
-#define DIST_XF86_SERVER_AGX 0x0008000
-#define DIST_XF86_SERVER_I128 0x0010000
-#define DIST_XF86_SERVER_MACH8 0x0020000
-#define DIST_XF86_SERVER_MACH32 0x0040000
-#define DIST_XF86_SERVER_MACH64 0x0080000
-#define DIST_XF86_SERVER_MONO 0x0100000
-#define DIST_XF86_SERVER_P9000 0x0200000
-#define DIST_XF86_SERVER_S3 0x0400000
-#define DIST_XF86_SERVER_S3V 0x0800000
-#define DIST_XF86_SERVER_SVGA 0x1000000
-#define DIST_XF86_SERVER_VGA16 0x2000000
-#define DIST_XF86_SERVER_W32 0x4000000
-#define DIST_XF86_SERVER_3DL 0x8000000
-#define DIST_XF86_SERVER_ALL 0xFFFFFFF
-#define DIST_XF86_FONTS 0x10000
-#define DIST_XF86_FONTS_MISC 0x0001
-#define DIST_XF86_FONTS_100 0x0002
-#define DIST_XF86_FONTS_CYR 0x0004
-#define DIST_XF86_FONTS_SCALE 0x0008
-#define DIST_XF86_FONTS_NON 0x0010
-#define DIST_XF86_FONTS_SERVER 0x0020
-#define DIST_XF86_FONTS_ALL 0x003F
-#define DIST_XF86_ALL 0x1FFFF
-
-#endif /* _DIST_H_INCLUDE */
diff --git a/usr.sbin/sysinstall/dmenu.c b/usr.sbin/sysinstall/dmenu.c
deleted file mode 100644
index 7f113fc132b3..000000000000
--- a/usr.sbin/sysinstall/dmenu.c
+++ /dev/null
@@ -1,316 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last attempt in the `sysinstall' line, the next
- * generation being slated for what's essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 "sysinstall.h"
-#include <errno.h>
-
-#define MAX_MENU 15
-
-static Boolean exited;
-
-int
-dmenuDisplayFile(dialogMenuItem *tmp)
-{
- systemDisplayHelp((char *)tmp->data);
- return DITEM_SUCCESS;
-}
-
-int
-dmenuSubmenu(dialogMenuItem *tmp)
-{
- return (dmenuOpenSimple((DMenu *)(tmp->data), FALSE) ? DITEM_SUCCESS : DITEM_FAILURE);
-}
-
-int
-dmenuSystemCommand(dialogMenuItem *self)
-{
- WINDOW *w = NULL; /* Keep lint happy */
-
- /* If aux is set, the command is known not to produce any screen-spoiling output */
- if (!self->aux)
- w = savescr();
- systemExecute((char *)self->data);
- if (!self->aux)
- restorescr(w);
- return DITEM_SUCCESS;
-}
-
-int
-dmenuSystemCommandBox(dialogMenuItem *tmp)
-{
- WINDOW *w = savescr();
-
- use_helpfile(NULL);
- use_helpline("Select OK to dismiss this dialog");
- dialog_prgbox(tmp->title, (char *)tmp->data, 22, 76, 1, 1);
- restorescr(w);
- return DITEM_SUCCESS;
-}
-
-int
-dmenuExit(dialogMenuItem *tmp)
-{
- exited = TRUE;
- return DITEM_LEAVE_MENU;
-}
-
-int
-dmenuSetVariable(dialogMenuItem *tmp)
-{
- variable_set((char *)tmp->data, *((char *)tmp->data) != '_');
- return DITEM_SUCCESS;
-}
-
-int
-dmenuSetVariables(dialogMenuItem *tmp)
-{
- char *cp1, *cp2;
- char *copy = strdup((char *)tmp->data);
-
- for (cp1 = copy; cp1 != NULL;) {
- cp2 = index(cp1, ',');
- if (cp2 != NULL) *cp2++ = '\0';
- variable_set(cp1, *cp1 != '_');
- cp1 = cp2;
- }
- free(copy);
- return DITEM_SUCCESS;
-}
-
-int
-dmenuSetKmapVariable(dialogMenuItem *tmp)
-{
- char *lang;
- int err;
-
- variable_set((char *)tmp->data, TRUE);
- lang = variable_get(VAR_KEYMAP);
- if (lang != NULL)
- {
- err = loadKeymap(lang);
- if (err == -1)
- msgConfirm("No appropriate keyboard map found, sorry.");
- else if (err == -2)
- msgConfirm("Error installing keyboard map, errno = %d.", errno);
- }
- return DITEM_SUCCESS;
-}
-
-int
-dmenuToggleVariable(dialogMenuItem *tmp)
-{
- char *var, *cp;
- int status;
-
- if (!(var = strdup((char *)tmp->data))) {
- msgConfirm("Incorrect data field for `%s'!", tmp->title);
- return DITEM_FAILURE;
- }
- if (!(cp = index(var, '='))) {
- msgConfirm("Data field for %s is not in var=value format!", tmp->title);
- return DITEM_FAILURE;
- }
- status = variable_check(var);
- *cp = '\0';
- variable_set2(var, status ? "NO" : "YES", *var != '_');
- free(var);
- return DITEM_SUCCESS;
-}
-
-int
-dmenuISetVariable(dialogMenuItem *tmp)
-{
- char *ans, *var;
-
- if (!(var = (char *)tmp->data)) {
- msgConfirm("Incorrect data field for `%s'!", tmp->title);
- return DITEM_FAILURE;
- }
- ans = msgGetInput(variable_get(var), tmp->title, 1);
- if (!ans)
- return DITEM_FAILURE;
- else if (!*ans)
- variable_unset(var);
- else
- variable_set2(var, ans, *var != '_');
- return DITEM_SUCCESS;
-}
-
-int
-dmenuSetFlag(dialogMenuItem *tmp)
-{
- if (*((unsigned int *)tmp->data) & tmp->aux)
- *((unsigned int *)tmp->data) &= ~tmp->aux;
- else
- *((unsigned int *)tmp->data) |= tmp->aux;
- return DITEM_SUCCESS;
-}
-
-int
-dmenuSetValue(dialogMenuItem *tmp)
-{
- *((unsigned int *)tmp->data) = tmp->aux;
- return DITEM_SUCCESS;
-}
-
-/* Traverse menu but give user no control over positioning */
-Boolean
-dmenuOpenSimple(DMenu *menu, Boolean buttons)
-{
- int choice, scroll, curr, max;
-
- choice = scroll = curr = max = 0;
- return dmenuOpen(menu, &choice, &scroll, &curr, &max, buttons);
-}
-
-/* Work functions for the state hook */
-int
-dmenuFlagCheck(dialogMenuItem *item)
-{
- return (*((unsigned int *)item->data) & item->aux);
-}
-
-int
-dmenuVarCheck(dialogMenuItem *item)
-{
- char *w;
-
- w = (char *)item->aux;
- if (!w)
- w = (char *)item->data;
- return variable_check(w);
-}
-
-int
-dmenuVarsCheck(dialogMenuItem *item)
-{
- int res, init;
- char *w, *cp1, *cp2;
- char *copy;
-
- w = (char *)item->aux;
- if (!w)
- w = (char *)item->data;
- if (!w)
- return FALSE;
-
- copy = strdup(w);
- res = TRUE;
- init = FALSE;
- for (cp1 = copy; cp1 != NULL;) {
- init = TRUE;
- cp2 = index(cp1, ',');
- if (cp2 != NULL)
- *cp2++ = '\0';
- res = res && variable_check(cp1);
- cp1 = cp2;
- }
- free(copy);
- return res && init;
-}
-
-int
-dmenuRadioCheck(dialogMenuItem *item)
-{
- return (*((unsigned int *)item->data) == item->aux);
-}
-
-static int
-menu_height(DMenu *menu, int n)
-{
- int max;
- char *t;
-
- max = MAX_MENU;
- if (StatusLine > 24)
- max += StatusLine - 24;
- for (t = menu->prompt; *t; t++) {
- if (*t == '\n')
- --max;
- }
- return n > max ? max : n;
-}
-
-/* Traverse over an internal menu */
-Boolean
-dmenuOpen(DMenu *menu, int *choice, int *scroll, int *curr, int *max, Boolean buttons)
-{
- int n, rval = 0;
- dialogMenuItem *items;
-
- items = menu->items;
- if (buttons)
- items += 2;
- /* Count up all the items */
- for (n = 0; items[n].title; n++);
-
- while (1) {
- char buf[FILENAME_MAX];
- WINDOW *w = savescr();
-
- /* Any helpful hints, put 'em up! */
- use_helpline(menu->helpline);
- use_helpfile(systemHelpFile(menu->helpfile, buf));
- dialog_clear_norefresh();
- /* Pop up that dialog! */
- if (menu->type & DMENU_NORMAL_TYPE)
- rval = dialog_menu((u_char *)menu->title, (u_char *)menu->prompt, -1, -1,
- menu_height(menu, n), -n, items, (char *)buttons, choice, scroll);
-
- else if (menu->type & DMENU_RADIO_TYPE)
- rval = dialog_radiolist((u_char *)menu->title, (u_char *)menu->prompt, -1, -1,
- menu_height(menu, n), -n, items, (char *)buttons);
-
- else if (menu->type & DMENU_CHECKLIST_TYPE)
- rval = dialog_checklist((u_char *)menu->title, (u_char *)menu->prompt, -1, -1,
- menu_height(menu, n), -n, items, (char *)buttons);
- else
- msgFatal("Menu: `%s' is of an unknown type\n", menu->title);
- if (exited) {
- exited = FALSE;
- restorescr(w);
- return TRUE;
- }
- else if (rval) {
- restorescr(w);
- return FALSE;
- }
- else if (menu->type & DMENU_SELECTION_RETURNS) {
- restorescr(w);
- return TRUE;
- }
- }
-}
diff --git a/usr.sbin/sysinstall/doc.c b/usr.sbin/sysinstall/doc.c
deleted file mode 100644
index 9a16d094ecc8..000000000000
--- a/usr.sbin/sysinstall/doc.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last attempt in the `sysinstall' line, the next
- * generation being slated for what's essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 "sysinstall.h"
-
-/*
- * This is called from the main menu. Try to find a copy of Lynx from somewhere
- * and fire it up on the first copy of the handbook we can find.
- */
-int
-docBrowser(dialogMenuItem *self)
-{
- int ret;
- char *browser = variable_get(VAR_BROWSER_PACKAGE);
-
- if (RunningAsInit && !strstr(variable_get(SYSTEM_STATE), "install")) {
- msgConfirm("This option may only be used after the system is installed, sorry!");
- return DITEM_FAILURE;
- }
-
- /* First, make sure we have whatever browser we've chosen is here */
- if (!package_exists(browser)) {
- ret = package_add(browser);
- if (DITEM_STATUS(ret) != DITEM_SUCCESS) {
- msgConfirm("Unable to install the %s HTML browser package. You may\n"
- "wish to verify that your media is configured correctly and\n"
- "try again.", browser);
- return ret;
- }
- }
-
- if (!file_executable(variable_get(VAR_BROWSER_BINARY))) {
- if (!msgYesNo("Hmmm. The %s package claims to have installed, but I can't\n"
- "find its binary in %s! You may wish to try a different\n"
- "location to load the package from (go to Media menu) and see if that\n"
- "makes a difference.\n\n"
- "I suggest that we remove the version that was extracted since it does\n"
- "not appear to be correct. Would you like me to do that now?",
- browser, variable_get(VAR_BROWSER_BINARY)))
- vsystem("pkg_delete %s %s", !strcmp(variable_get(VAR_CPIO_VERBOSITY), "high") ? "-v" : "", browser);
- return DITEM_FAILURE;
- }
-
- /* Run browser on the appropriate doc */
- if (dmenuOpenSimple(&MenuHTMLDoc, FALSE))
- return DITEM_SUCCESS;
- else
- return DITEM_FAILURE;
-}
-
-/* Try to show one of the documents requested from the HTML doc menu */
-int
-docShowDocument(dialogMenuItem *self)
-{
- char tmp[512], target[512];
- char *where, *browser = variable_get(VAR_BROWSER_BINARY);
- char *str = self->prompt;
-
- if (!file_executable(browser)) {
- msgConfirm("Can't find the browser in %s! Please ensure that it's\n"
- "properly set in the Options editor.", browser);
- return DITEM_FAILURE;
- }
- /* Default to Home */
- where = strcpy(target, "http://www.freebsd.org");
- if (strstr(str, "Other")) {
- where = msgGetInput("http://www.freebsd.org", "Please enter the URL of the location you wish to visit.");
- if (where)
- strcpy(target, where);
- }
- else if (strstr(str, "FAQ")) {
- where = strcpy(target, "/usr/share/doc/faq/index.html");
- if (!file_readable(target))
- where = strcpy(target, "http://www.freebsd.org/FAQ");
- }
- else if (strstr(str, "Handbook")) {
- where = strcpy(target, "/usr/share/doc/handbook/index.html");
- if (!file_readable(target))
- where = strcpy(target, "http://www.freebsd.org/handbook");
- }
- if (where) {
- sprintf(tmp, "%s %s", browser, target);
- systemExecute(tmp);
- return DITEM_SUCCESS;
- }
- else {
- msgConfirm("Hmmmmm! I can't seem to access the documentation you selected!\n"
- "Have you loaded the bin distribution? Is your network connected?");
- return DITEM_FAILURE;
- }
-}
diff --git a/usr.sbin/sysinstall/dos.c b/usr.sbin/sysinstall/dos.c
deleted file mode 100644
index ae6eb1e015c9..000000000000
--- a/usr.sbin/sysinstall/dos.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last attempt in the `sysinstall' line, the next
- * generation being slated to essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. All rights reserved.
- * Copyright (c) 1995
- * Gary J Palmer. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 "sysinstall.h"
-#include <sys/stat.h>
-#include <sys/errno.h>
-#include <sys/param.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <grp.h>
-#define MSDOSFS
-#include <sys/mount.h>
-#include <msdosfs/msdosfsmount.h>
-#undef MSDOSFS
-
-static Boolean DOSMounted;
-static char mountpoint[] = "/dist";
-
-Boolean
-mediaInitDOS(Device *dev)
-{
- struct msdosfs_args args;
-
- if (DOSMounted)
- return TRUE;
-
- Mkdir(mountpoint);
- memset(&args, 0, sizeof(args));
- args.fspec = dev->devname;
- args.uid = args.gid = 0;
- args.mask = 0777;
-
- if (mount("msdos", mountpoint, MNT_RDONLY, (caddr_t)&args) == -1) {
- msgConfirm("Error mounting %s on %s: %s (%u)", args.fspec, mountpoint, strerror(errno), errno);
- return FALSE;
- }
- DOSMounted = TRUE;
- return TRUE;
-}
-
-FILE *
-mediaGetDOS(Device *dev, char *file, Boolean probe)
-{
- return mediaGenericGet(mountpoint, file);
-}
-
-void
-mediaShutdownDOS(Device *dev)
-{
- if (!DOSMounted)
- return;
- if (unmount(mountpoint, MNT_FORCE) != 0)
- msgConfirm("Could not unmount the DOS partition from %s: %s",
- mountpoint, strerror(errno));
- else
- DOSMounted = FALSE;
- return;
-}
diff --git a/usr.sbin/sysinstall/floppy.c b/usr.sbin/sysinstall/floppy.c
deleted file mode 100644
index 576361e6199f..000000000000
--- a/usr.sbin/sysinstall/floppy.c
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last attempt in the `sysinstall' line, the next
- * generation being slated to essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. All rights reserved.
- * Copyright (c) 1995
- * Gary J Palmer. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 routines deal with getting things off of floppy media */
-
-#include "sysinstall.h"
-#include <sys/fcntl.h>
-#include <sys/stat.h>
-#include <sys/errno.h>
-#include <sys/param.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <grp.h>
-
-#define MSDOSFS
-#include <sys/mount.h>
-#include <msdosfs/msdosfsmount.h>
-#undef MSDOSFS
-
-#include <ufs/ufs/ufsmount.h>
-static Boolean floppyMounted;
-
-char *distWanted;
-static char mountpoint[] = "/dist";
-
-Boolean
-mediaInitFloppy(Device *dev)
-{
- struct msdosfs_args dosargs;
- struct ufs_args u_args;
- char *mp;
-
- if (floppyMounted)
- return TRUE;
-
- mp = dev->private ? (char *)dev->private : mountpoint;
- if (Mkdir(mp)) {
- msgConfirm("Unable to make %s directory mountpoint for %s!", mp, dev->devname);
- return FALSE;
- }
-
- msgDebug("Init floppy called for %s distribution.\n", distWanted ? distWanted : "some");
-
- if (!variable_get(VAR_NONINTERACTIVE)) {
- if (!distWanted)
- msgConfirm("Please insert floppy in %s", dev->description);
- else
- msgConfirm("Please insert floppy containing %s in %s",
- distWanted, dev->description);
- }
-
- memset(&dosargs, 0, sizeof dosargs);
- dosargs.fspec = dev->devname;
- dosargs.uid = dosargs.gid = 0;
- dosargs.mask = 0777;
-
- memset(&u_args, 0, sizeof(u_args));
- u_args.fspec = dev->devname;
-
- if (mount("msdos", mp, MNT_RDONLY, (caddr_t)&dosargs) == -1) {
- if (mount("ufs", mp, MNT_RDONLY, (caddr_t)&u_args) == -1) {
- msgConfirm("Error mounting floppy %s (%s) on %s : %s",
- dev->name, dev->devname, mp, strerror(errno));
- return FALSE;
- }
- }
- floppyMounted = TRUE;
- distWanted = NULL;
- return TRUE;
-}
-
-FILE *
-mediaGetFloppy(Device *dev, char *file, Boolean probe)
-{
- char buf[PATH_MAX], *mp;
- FILE *fp;
- int nretries = 5;
-
- /*
- * floppies don't use mediaGenericGet() because it's too expensive
- * to speculatively open files on a floppy disk. Make user get it
- * right or give up with floppies.
- */
- mp = dev->private ? (char *)dev->private : mountpoint;
- snprintf(buf, PATH_MAX, "%s/%s", mp, file);
- if (!file_readable(buf)) {
- if (probe)
- return NULL;
- else {
- while (!file_readable(buf)) {
- if (!--nretries) {
- msgConfirm("GetFloppy: Failed to get %s after retries;\ngiving up.", buf);
- return NULL;
- }
- distWanted = buf;
- mediaShutdownFloppy(dev);
- if (!mediaInitFloppy(dev))
- return NULL;
- }
- }
- }
- fp = fopen(buf, "r");
- return fp;
-}
-
-void
-mediaShutdownFloppy(Device *dev)
-{
- if (floppyMounted) {
- char *mp = dev->private ? (char *)dev->private : mountpoint;
-
- if (unmount(mp, MNT_FORCE) != 0)
- msgDebug("Umount of floppy on %s failed: %s (%d)\n", mp, strerror(errno), errno);
- else {
- floppyMounted = FALSE;
- if (!variable_get(VAR_NONINTERACTIVE) && variable_cmp(SYSTEM_STATE, "fixit"))
- msgConfirm("You may remove the floppy from %s", dev->description);
- }
- }
-}
diff --git a/usr.sbin/sysinstall/ftp.c b/usr.sbin/sysinstall/ftp.c
deleted file mode 100644
index b32f80ab60a1..000000000000
--- a/usr.sbin/sysinstall/ftp.c
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last attempt in the `sysinstall' line, the next
- * generation being slated to essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 "sysinstall.h"
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <sys/param.h>
-#include <sys/wait.h>
-#include <netdb.h>
-#include <pwd.h>
-#include <ftpio.h>
-
-Boolean ftpInitted = FALSE;
-static FILE *OpenConn;
-int FtpPort;
-
-/* Brings up attached network device, if any - takes FTP device as arg */
-static Boolean
-netUp(Device *dev)
-{
- Device *netdev = (Device *)dev->private;
-
- if (netdev)
- return netdev->init(netdev);
- else
- return TRUE; /* No net == happy net */
-}
-
-/* Brings down attached network device, if any - takes FTP device as arg */
-static void
-netDown(Device *dev)
-{
- Device *netdev = (Device *)dev->private;
-
- if (netdev)
- netdev->shutdown(netdev);
-}
-
-Boolean
-mediaInitFTP(Device *dev)
-{
- int i, code;
- char *cp, *rel, *hostname, *dir;
- char *user, *login_name, password[80];
-
- if (ftpInitted)
- return TRUE;
-
- if (OpenConn) {
- fclose(OpenConn);
- OpenConn = NULL;
- }
-
- /* If we can't initialize the network, bag it! */
- if (!netUp(dev))
- return FALSE;
-
-try:
- cp = variable_get(VAR_FTP_PATH);
- if (!cp) {
- if (DITEM_STATUS(mediaSetFTP(NULL)) == DITEM_FAILURE || (cp = variable_get(VAR_FTP_PATH)) == NULL) {
- msgConfirm("Unable to get proper FTP path. FTP media not initialized.");
- netDown(dev);
- return FALSE;
- }
- }
-
- hostname = variable_get(VAR_FTP_HOST);
- dir = variable_get(VAR_FTP_DIR);
- if (!hostname || !dir) {
- msgConfirm("Missing FTP host or directory specification. FTP media not initialized,");
- netDown(dev);
- return FALSE;
- }
- user = variable_get(VAR_FTP_USER);
- login_name = (!user || !*user) ? "anonymous" : user;
-
- if (variable_get(VAR_FTP_PASS))
- SAFE_STRCPY(password, variable_get(VAR_FTP_PASS));
- else if (RunningAsInit)
- sprintf(password, "installer@%s", variable_get(VAR_HOSTNAME));
- else {
- struct passwd *pw;
- char *user;
-
- pw = getpwuid(getuid());
- user = pw ? pw->pw_name : "ftp";
- sprintf(password, "%s@%s", user, variable_get(VAR_HOSTNAME));
- }
- msgNotify("Logging in to %s@%s..", login_name, hostname);
- if ((OpenConn = ftpLogin(hostname, login_name, password, FtpPort, isDebug(), &code)) == NULL) {
- msgConfirm("Couldn't open FTP connection to %s:\n %s.", hostname, ftpErrString(code));
- goto punt;
- }
-
- ftpPassive(OpenConn, !strcmp(variable_get(VAR_FTP_STATE), "passive"));
- ftpBinary(OpenConn);
- if (dir && *dir != '\0') {
- if ((i = ftpChdir(OpenConn, dir)) != 0) {
- if (i == 550)
- msgConfirm("No such directory ftp://%s/%s\n"
- "please check your URL and try again.", hostname, dir);
- else
- msgConfirm("FTP chdir to ftp://%s/%s returned error status:\n %s.", hostname, dir, ftpErrString(i));
- goto punt;
- }
- }
-
- /* Give it a shot - can't hurt to try and zoom in if we can, unless the release is set to
- __RELEASE or "none" which signifies that it's not set */
- rel = variable_get(VAR_RELNAME);
- if (strcmp(rel, "__RELEASE") && strcmp(rel, "none"))
- i = ftpChdir(OpenConn, rel);
- else
- i = 0;
- if (i) {
- if (!msgYesNo("Warning: Can't CD to `%s' distribution on this\n"
- "FTP server. You may need to visit a different server for\n"
- "the release you're trying to fetch or go to the Options\n"
- "menu and to set the release name to explicitly match what's\n"
- "available on %s (or set to \"none\").\n\n"
- "Would you like to select another FTP server?",
- rel, hostname)) {
- variable_unset(VAR_FTP_PATH);
- if (DITEM_STATUS(mediaSetFTP(NULL)) == DITEM_FAILURE)
- goto punt;
- else
- goto try;
- }
- else
- goto punt;
- }
- ftpInitted = TRUE;
- return TRUE;
-
-punt:
- ftpInitted = FALSE;
- if (OpenConn != NULL) {
- fclose(OpenConn);
- OpenConn = NULL;
- }
- netDown(dev);
- variable_unset(VAR_FTP_PATH);
- return FALSE;
-}
-
-FILE *
-mediaGetFTP(Device *dev, char *file, Boolean probe)
-{
- int nretries = 1;
- FILE *fp;
- char *try, buf[PATH_MAX];
-
- if (!OpenConn) {
- msgDebug("No FTP connection open, can't get file %s\n", file);
- return NULL;
- }
-
- try = file;
- while ((fp = ftpGet(OpenConn, try, 0)) == NULL) {
- int ftperr = ftpErrno(OpenConn);
-
- /* If a hard fail, try to "bounce" the ftp server to clear it */
- if (ftperr != 550) {
- if (ftperr != 421) /* Timeout? */
- variable_unset(VAR_FTP_PATH);
- /* If we can't re-initialize, just forget it */
- dev->shutdown(dev);
- if (!dev->init(dev)) {
- netDown(dev);
- if (OpenConn) {
- fclose(OpenConn);
- OpenConn = NULL;
- }
- variable_unset(VAR_FTP_PATH);
- return NULL;
- }
- }
- else if (probe)
- return NULL;
- else {
- /* Try some alternatives */
- switch (nretries++) {
- case 1:
- sprintf(buf, "releases/%s", file);
- try = buf;
- break;
-
- case 2:
- sprintf(buf, "%s/%s", variable_get(VAR_RELNAME), file);
- try = buf;
- break;
-
- case 3:
- sprintf(buf, "%s/releases/%s", variable_get(VAR_RELNAME), file);
- try = buf;
- break;
-
- case 4:
- try = file;
- break;
- }
- }
- }
- return fp;
-}
-
-void
-mediaShutdownFTP(Device *dev)
-{
- if (!ftpInitted)
- return;
-
- if (OpenConn != NULL) {
- fclose(OpenConn);
- OpenConn = NULL;
- }
- ftpInitted = FALSE;
-}
diff --git a/usr.sbin/sysinstall/globals.c b/usr.sbin/sysinstall/globals.c
deleted file mode 100644
index 2dccef2ab6fc..000000000000
--- a/usr.sbin/sysinstall/globals.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last program in the `sysinstall' line - the next
- * generation being essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 "sysinstall.h"
-
-/*
- * Various global variables and an initialization hook to set them to
- * whatever values we feel are appropriate.
- */
-
-int DebugFD; /* Where diagnostic output goes */
-Boolean Fake; /* Only pretend to be useful */
-Boolean RunningAsInit; /* Are we running as init? */
-Boolean DialogActive; /* Is libdialog initialized? */
-Boolean ColorDisplay; /* Are we on a color display? */
-Boolean OnVTY; /* Are we on a VTY? */
-Boolean USAResident; /* Are we cryptographically challenged? */
-Variable *VarHead; /* The head of the variable chain */
-Device *mediaDevice; /* Where we're installing from */
-int BootMgr; /* Which boot manager we're using */
-int StatusLine; /* Where to stick our status messages */
-jmp_buf BailOut; /* Beam me up, scotty! The natives are pissed! */
-
-/*
- * Yes, I know some of these are already automatically initialized as
- * globals. I simply find it clearer to set everything explicitly.
- */
-void
-globalsInit(void)
-{
- DebugFD = -1;
- ColorDisplay = FALSE;
- Fake = FALSE;
- OnVTY = FALSE;
- DialogActive = FALSE;
- VarHead = NULL;
- mediaDevice = NULL;
- RunningAsInit = FALSE;
- USAResident = FALSE;
-}
diff --git a/usr.sbin/sysinstall/help/anonftp.hlp b/usr.sbin/sysinstall/help/anonftp.hlp
deleted file mode 100644
index e90985e235fe..000000000000
--- a/usr.sbin/sysinstall/help/anonftp.hlp
+++ /dev/null
@@ -1,19 +0,0 @@
-This screen allows you to configure the anonymous FTP user.
-
-The following configuration values are editable:
-
-UID: The user ID you wish to assign to the anonymous FTP user.
- All files uploaded will be owned by this ID.
-
-Group: Which group you wish the anonymous FTP user to be in.
-
-Comment: String describing this user in /etc/passwd
-
-
-FTP Root Directory:
-
- Where files available for anonymous FTP will be kept.
-
-Upload subdirectory:
-
- Where files uploaded by anonymous FTP users will go.
diff --git a/usr.sbin/sysinstall/help/configure.hlp b/usr.sbin/sysinstall/help/configure.hlp
deleted file mode 100644
index 65be877a3252..000000000000
--- a/usr.sbin/sysinstall/help/configure.hlp
+++ /dev/null
@@ -1,10 +0,0 @@
-This menu allows you to configure your system after the installation
-process is complete. At the minimum, you should probably set the
-system manager's password and the system time zone.
-
-For extra goodies like bash, emacs, Pascal, etc., you should look at
-the Packages item in this menu.
-
-For setting the timezone after the system is installed, type
-``tzsetup''. For more information on the overall general system
-configuration, see the ``/etc/defaults/rc.conf'' file.
diff --git a/usr.sbin/sysinstall/help/distributions.hlp b/usr.sbin/sysinstall/help/distributions.hlp
deleted file mode 100644
index e0c91dc33ad2..000000000000
--- a/usr.sbin/sysinstall/help/distributions.hlp
+++ /dev/null
@@ -1,63 +0,0 @@
-DISTRIBUTION INFORMATION
-------------------------
-
-An ``X-'' prefixed before a distribution set means that the XFree86
-3.3.3.1 base distribution, libraries, manual pages, SVGA server and a
-set of default fonts will be selected in addition to the set itself.
-If you select such a set, you will also be presented with a set of
-menus for customizing the selections to your desired X Window System
-setup.
-
-Any distribution may be further customized by selecting the `Custom'
-item before leaving the menu.
-
-N.B. All references in this document to `complete source' mean the
-complete source tree minus any legally encumbered cryptography code.
-
-The current "canned" installations are provided:
-
-Developer: Base ("bin") distribution, man pages, dictionary
- files, profiling libraries and the complete source tree.
-
-Kern-Developer: As above, but with only kernel sources instead of
- the complete source tree.
-
-User: The base distribution, man pages, dictionary files and
- the FreeBSD 1.x, 2.0, 2.1.x and 2.2.x compatibility sets.
-
-Minimal: Only the base distribution.
-
-Everything: The base distribution, man pages, dictionary files,
- profiling libraries, the FreeBSD compatibility libraries,
- the complete source tree, games and your choice of XFree86
- distribution components.
-
- Note that the cryptography source code is NOT included
- in this collection. You will need to select that by
- hand if you're inside the United States.
-
-Custom: Allows you to create or modify your distribution set on
- a piece-by-piece basis.
-
-Reset: Clear all currently selected distributions.
-
----
-
-ENCRYPTION SOFTWARE:
---------------------
-You may notice that certain distributions, like "des" and "krb",
-are marked "NOT FOR EXPORT!" This is because it's illegal to export
-them from the United States (or any other country which considers
-encryption technology to be on its restricted export list). Since
-breaking this law only gets the _originating_ site (US!) in trouble,
-please do not load these distributions from U.S. servers! We don't
-like these restrictions any more than you do, but can't do much about
-it (write your U.S. congress person!).
-
-A number of "foreign" servers do exist for the benefit of
-non-U.S. sites, the official site being:
-
- ftp://ftp.internat.freebsd.org/pub/FreeBSD
-
-Please get all such export restricted software from there
-if you are outside the U.S., thanks!
diff --git a/usr.sbin/sysinstall/help/drives.hlp b/usr.sbin/sysinstall/help/drives.hlp
deleted file mode 100644
index 946a1b211b7f..000000000000
--- a/usr.sbin/sysinstall/help/drives.hlp
+++ /dev/null
@@ -1,92 +0,0 @@
-Boot Manager Selection:
------------------------
-
-If you wish to switch between multiple operating systems on your
-machine, or if you are trying to install FreeBSD on a drive other than
-your 1st drive, then you must install a boot manager. In the case
-where you wish to boot off an alternate drive, it should also be noted
-that you still need to install a boot manager on the FIRST drive!
-Even if you do not intend to create a FreeBSD partition on that drive
-(e.g. it's being wholly used by something else), the boot manager
-still needs to reside on the first disk in order to function as a
-"redirector" for the boot process.
-
-To do this, simply select your 1st drive in the drive selection menu
-and when the partition editor comes up, don't make any changes - just
-(Q)uit. At the boot manager menu which follows, select the first
-option (install a boot manager) and then proceed to setup the other
-drive(s) for FreeBSD as normal.
-
-It should also be noted that "operating systems" such as Windows 95
-will completely overwrite your boot manager without so much as a
-polite "may I please destroy your boot manager?" prompt if you make
-the mistake of installing them second. If this happens to you after
-FreeBSD is already installed, all is not lost! Simply revisit your
-FreeBSD distribution directory and look for a tools/ subdirectory, in
-which you'll find "bootinst.exe" and "boot.bin". To reinstall, simply
-say "bootinst boot.bin" while in the tools/ subdirectory.
-
-
-If you see the boot manager displaying ``F?'' when you try to come up
-for the first time and it refuses to change, no matter how often you
-whap on the function key assigned to FreeBSD, then you have a geometry
-mismatch problem and you should read the next section for important
-information on how to prevent that exact problem from happening!
-
-
-Geometry Translation / Sharing the disk(s) with another OS:
-----------------------------------------------------------
-
-If you are going to actually install some portion of FreeBSD on a
-drive then PLEASE BE VERY CERTAIN that the Geometry reported in the
-Partition Editor is the correct one for your drive and controller
-combination!
-
-IDE drives often have a certain geometry set during the PC BIOS setup,
-or (in the case of larger IDE drives) have their geometry "translated"
-by either the IDE controller or a special boot-sector translation
-utility such as that by OnTrack Systems. In these cases, knowing the
-correct geometry gets even more complicated as it's not something you
-can easily tell by looking at the drive or the PC BIOS setup. The
-best way of verifying that your geometry is being correctly calculated
-in such situations is to boot DOS (from the hard disk, not a floppy!)
-and run the ``pfdisk'' utility provided in the tools/ subdirectory of
-the FreeBSD CDROM or FTP site. It will report the geometry that DOS
-sees, which is generally the correct one.
-
-If you have no DOS partition sharing the disk at all, then you may
-find that you have better luck with Geometry detection if you create a
-very small DOS partition first, before installing FreeBSD. Once
-FreeBSD is installed you can always delete it again if you need the
-space.
-
-It's actually not a bad idea (believe it or not) to have a small
-bootable DOS partition on your FreeBSD machine anyway: Should the
-machine become unstable or exhibit strange behavior at some point in
-the future (which is not uncommon behavior for PC hardware!) you can
-then at least use DOS for installing and running one of the
-commercially available system diagnostic utilities.
-
-IMPORTANT NOTE:
-
-Any root partition you try to boot from must also reside below the
-1024th cylinder. If you're using a translated geometry then this is
-probably not a problem, but if you are using a native disk geometry
-which exceeds 1024 cylinders then you could have a failure to boot if
-you end up installing a root partition (or even just the kernel file
-in a root partition) out past cylinder 1024. If you are trying to
-share your first disk with FreeBSD and another OS which was installed
-previously, you are particularly susceptible to this problem and should
-check your disk addresses very carefully.
-
-If you find that you have insufficient space below cylinder 1024 to
-make a root partition for FreeBSD (and again, this ONLY applies to the
-root partition - once FreeBSD's kernel is loaded, it doesn't care
-about the geometry issues) then you will probably need to install on a
-completely different disk (see the boot manager section above) or
-resize your existing partitions so that both operating systems can
-have boot partitions below cylinder 1024.
-
-You may blame IBM for the limitations of a 10 bit cylinder address.
-"No one will have a disk with more than 1024 cylinders." I'm sure
-someone said.
diff --git a/usr.sbin/sysinstall/help/fixit.hlp b/usr.sbin/sysinstall/help/fixit.hlp
deleted file mode 100644
index e47394ecb08c..000000000000
--- a/usr.sbin/sysinstall/help/fixit.hlp
+++ /dev/null
@@ -1,7 +0,0 @@
-A special shell will be launched by this option with a fixit floppy
-(or 2nd CDROM) mounted as /mnt2. This provides access to extra
-commands under /mnt2 as well as a more complete set of device files in
-/mnt2/dev. Some device operations, like fsck and disklabel, may
-therefore require you to go to /mnt2/dev and use the entries there
-rather than assuming that they will be present in the default /dev
-(which came from the boot floppy and is very minimal).
diff --git a/usr.sbin/sysinstall/help/html.hlp b/usr.sbin/sysinstall/help/html.hlp
deleted file mode 100644
index f63dd30ed071..000000000000
--- a/usr.sbin/sysinstall/help/html.hlp
+++ /dev/null
@@ -1,19 +0,0 @@
-In this screen, you can jump to remote or local HTML
-resources such as the FreeBSD Handbook & FreeBSD FAQ
-(Frequently Asked Questions) documents located in:
-
- file:/usr/share/doc/
-
-If you've loaded the doc distribution.
-
-The default browser package used is lynx (a text based
-browser), which will be automatically loaded from the
-installation media if it is available. You may change
-the selection of browser & browser package to auto-load
-by visiting the Options editor.
-
-In order to visit remote URLs, you naturally must have
-some sort of working Internet connection. If you have not
-yet brought up any network interfaces, please visit
-the ``Networking'' item in the Configuration menu
-before attempting to reference any http://.. style URLs.
diff --git a/usr.sbin/sysinstall/help/media.hlp b/usr.sbin/sysinstall/help/media.hlp
deleted file mode 100644
index d65993ccc4e0..000000000000
--- a/usr.sbin/sysinstall/help/media.hlp
+++ /dev/null
@@ -1,51 +0,0 @@
-You can install from the following types of media:
-
- CDROM requires one of the following supported CDROM drives:
- ATAPI - Any standard ATAPI CDROM driver hooked to
- a supported controller <see Hardware Guide).
- SCSI - Any standard SCSI CDROM drive hooked to
- a supported controller (see Hardware Guide).
-
-
- DOS A DOS primary partition with the required FreeBSD
- distribution files copied onto it (e.g. C:\FREEBSD\)
-
-
- FS Assuming a disk or partition with an existing
- FreeBSD file system and distribution set on it,
- get the distribution files from there.
-
-
- Floppy Get distribution files from one or more DOS or UFS
- formatted floppies. Such floppies are assumed to
- contain the appropriate distribution pieces - see
- ABOUT.TXT for more information about making floppy
- distribution media.
-
-
- FTP Get the distribution files from an anonymous ftp server
- (you will be presented with a list). Please note that
- there are also two ways of invoking FTP in either
- "Active" and "Passive" mode.
-
- Active mode is the standard way of fetching files and
- Passive mode is for use when you're behind a firewall or
- some other security mechanism that blocks active FTP
- connections. If you chose "other" in the FTP menu, please
- also note that all paths are *relative* to the home
- directory of the user being logged in as. By default, this
- is the user "ftp" (anonymous ftp) but you may change this
- in the Options screen.
-
-
- NFS Get the distribution files from an NFS server somewhere
- (make sure that permissions on the server allow this!).
- If this install method hangs on you or refuses to work
- properly, you may need to set some special options for
- your NFS server. See the Options screen for more details.
-
-
- Tape Extract distribution files from tape into a temporary
- directory and install from there. If the tape was created
- with blocksize other than 20, you may wish to change this
- in the Options screen.
diff --git a/usr.sbin/sysinstall/help/network_device.hlp b/usr.sbin/sysinstall/help/network_device.hlp
deleted file mode 100644
index a65467bf6394..000000000000
--- a/usr.sbin/sysinstall/help/network_device.hlp
+++ /dev/null
@@ -1,58 +0,0 @@
-You can do network installations over 3 types of communications links:
-
- Serial port: SLIP / PPP
- Parallel port: PLIP (laplink cable)
- Ethernet: A standard Ethernet controller (includes some
- PCMCIA networking cards).
-
-SLIP support is rather primitive and limited primarily to directly
-connected links, such as a serial cable running between a laptop
-computer and another PC. The link must be hard-wired as the SLIP
-installation doesn't currently offer a dialing capability (that
-facility is offered by the PPP utility, which should be used in
-preference to SLIP whenever possible). When you choose the SLIP
-option, you'll be given the option of later editing the slattach
-command before it's run on the serial line. It is expected that
-you'll run slattach (or some equivalent command) on the other end of
-the link at that time and bring up the line. FreeBSD will then
-install itself at serial speeds of up to 115.2K/baud (the recommended
-speed for a hardwired cable).
-
-If you're using a modem then PPP is almost certainly your only choice.
-Make sure that you have your service provider's information handy as
-you'll need to know it fairly early in the installation process. You
-will need to know your service provider's IP address, the IP address
-of your provider's DNS server, and possibly your own IP address unless
-your ISP supports dynamic negotiation, most do. If you do not choose
-a PAP or CHAP login you will also need to know how to use the various
-"AT commands" to dial the ISP with your particular brand of modem as
-the PPP dialer provides only a very simple terminal emulator and has no
-"modem capabilities database". If you choose a PAP or CHAP login you
-can simply enter `dial' (without the quotes) at the ppp prompt if your
-modem uses the Hayes compatible AT command set.
-
-If a hard-wired connection to another FreeBSD (2.0R or later) machine
-is available, you might also consider installing over a "laplink"
-parallel port cable. The data rate over the parallel port is much
-higher than what is typically possible over a serial line, and speeds
-of over 50KB/sec are not uncommon.
-
-Finally, for the fastest possible network installation, an Ethernet
-adaptor is always a good choice! FreeBSD supports most common PC
-Ethernet cards, a table of which is provided in the FreeBSD Hardware
-Guide (see the Documentation menu on the boot floppy). If you are
-using one of the supported PCMCIA Ethernet cards, also be sure that
-it's plugged in _before_ the laptop is powered on! FreeBSD does not,
-unfortunately, currently support "hot insertion" of PCMCIA cards.
-
-You will also need to know your IP address on the network, the
-"netmask" value for your address class, and the name of your machine.
-Your system administrator can tell you which values to use for your
-particular network setup. If you will be referring to other hosts by
-name rather than IP address, you'll also need a name server and
-possibly the address of a gateway (if you're using PPP, it's your
-provider's IP address) to use in talking to it. If you do not know
-the answers to all or most of these questions then you should really
-probably talk to your system administrator FIRST before trying this
-type of installation! Choosing the wrong IP address on a busy network
-will NOT make you popular with your systems administrator! :-)
diff --git a/usr.sbin/sysinstall/help/options.hlp b/usr.sbin/sysinstall/help/options.hlp
deleted file mode 100644
index dced21657b05..000000000000
--- a/usr.sbin/sysinstall/help/options.hlp
+++ /dev/null
@@ -1,124 +0,0 @@
-The following options may be set from this screen. Use the SPACE key
-to toggle an option's value, Q to leave when you're done.
-
-NFS Secure: NFS server talks only on a secure port
-
- This is most commonly used when talking to Sun workstations, which
- will not talk NFS over "non privileged" ports.
-
-
-NFS Slow: User is using a slow PC or Ethernet card
-
- Use this option if you have a slow PC (386) or an Ethernet card
- with poor performance being "fed" by NFS on a higher-performance
- workstation. This will throttle the workstation back to prevent
- the PC from becoming swamped with data.
-
-
-Debugging: Turn on the extra debugging flag
-
- This turns on a lot of extra noise over on the second screen
- (ALT-F2 to see it, ALT-F1 to switch back). If your installation
- should fail for any reason, PLEASE turn this flag on when
- attempting to reproduce the problem. It will provide a lot of
- extra debugging at the failure point and may be very helpful to
- the developers in tracking such problems down!
-
-
-Yes To All: Assume "Yes" answers to all non-critical dialogs
-
- This flag should be used with caution. It will essentially
- decide NOT to ask the user about any "boundary" conditions that
- might not constitute actual errors but may be warnings indicative
- of other problems. It's most useful to those who are doing unattended
- installs.
-
-
-FTP username: Specify username and password instead of anonymous.
-
- By default, the installation attempts to log in as the
- anonymous user. If you wish to log in as someone else,
- specify the username and password with this option.
-
-
-Install Root: Specify some directory other than / as your "root".
-
- This should be left as / unless you have a really good reason to
- change it. One good reason might be if you were installing to a
- disk other than your own, as might happen if you needed to prepare a
- disk for another machine which couldn't load FreeBSD directly
- for some reason.
-
- Note: If you set this option, you will only be able to install
- packages if the bin distribution is also installed (usually
- the case anyway) since /usr/sbin/pkg_add will otherwise not be
- found after the chroot() call.
-
-
-Editor: Specify which screen editor to use.
-
- At various points during the installation it may be necessary
- to customize some text file, at which point the user will be
- thrown unceremoniously into a screen editor. A relatively
- simplistic editor which shows its command set on-screen is
- selected by default, but UNIX purists may wish to change this
- setting to /usr/bin/vi
-
-
-Tape Blocksize: Specify block size in 512 byte blocks of tape.
-
- This defaults to 20 blocks, which should work with most
- tape drive + tar combinations. It may not allow your particular
- drive to win any records for speed, however, and the more
- adventurous among you might try experimenting with larger sizes.
-
-
-Extract Detail: How to show filenames on debug screen as they're extracted.
-
- While a distribution is being extracted, the default detail level
- of "high" will show the full file names as they're extracted.
- If you would prefer a more terse form for this, namely dots, select
- the "medium" detail level. If you want nothing to be printed
- on the debugging screen during extraction, select "low".
-
-
-Release Name: Which release to attempt to load from installation media.
-
- You should only change this option if you're really sure you know
- what you are doing! This will change the release name used by
- sysinstall when fetching components of any distributions, and
- is a useful way of using a more recent installation boot floppy
- with an older release (say, on CDROM).
-
-
-Browser Package: Which package to load for an HTML browser.
-
- By default, this is set to lynx but may also be set to any other
- text capable HTML browser for which a package exists. If you set this
- to an X based browser, you will not be able to use it if you're running
- in text mode! :)
-
-
-Browser Exec: Which binary to run for the HTML browser.
-
- The full pathname to the main executable in Browser Package
-
-
-Media Type: Which media type is being used.
-
- This is mostly informational and indicates which media type (if any)
- was last selected in the Media menu. It's also a convenient short-cut
- to the media menu itself.
-
-
-Package Temp: Where package temporary files should go
-
- Some packages, like emacs, can use a LOT of temporary space - up to
- 20 or 30MB. If you are going to configure a small / directory (and
- hence a small /tmp) then you may wish to set this to point at another
- location (say, /usr/tmp).
-
-
-Use Defaults: Use default values.
-
- Reset all options back to their default values.
diff --git a/usr.sbin/sysinstall/help/partition.hlp b/usr.sbin/sysinstall/help/partition.hlp
deleted file mode 100644
index 6004d751b451..000000000000
--- a/usr.sbin/sysinstall/help/partition.hlp
+++ /dev/null
@@ -1,118 +0,0 @@
-This is the FreeBSD DiskLabel Editor.
-
-NOTE: If you're entering this editor from the update procedure then
-you probably shouldn't (C)reate anything at all but rather use only
-the (M)ount command to check and mount existing partitions for
-upgrading.
-
-If you would like the label editor to do most of the following for
-you, simply type `A' for automatic partitioning of the disk.
-
-If you wish to create partitions manually you may do so by moving the
-highlighted selection bar with the arrow keys over the FreeBSD
-partition(s) displayed at the top of the screen. Typing (C)reate
-while a partition with available free space is selected will allow you
-to create a BSD partition inside of it using some or all of its
-available space.
-
-Typing (M)ount over an existing partition entry (displayed in the
-middle of the screen) will allow you to set a mount point for it
-without initializing it. If you want it initialized, use the (T)oggle
-command to flip the Newfs flag. When Newfs is set to "Y", the
-filesystem in question will be ERASED and rebuilt from scratch!
-
-
-You should use this editor to create at least the following
-filesystems:
-
- Name Purpose Min Size? Optional?
- ---- ------- --------- ---------
- / Root filesystem 20MB No
- swap Swap space 2 * MEM No
- /usr System & user files 80MB or more Yes
-
-Note: If you do not create a /usr filesystem then your / filesystem
-will need to be bigger - at least 100MB. This is not recommended as
-any media errors that may occur during disk I/O to user files will
-corrupt the filesystem containing vital system files as well. It is
-for this reason that / is generally kept on its own filesystem, where
-it should be considered essentially "read only" in your administration
-of it.
-
-Swap space is a little tricker, and the rule of "2 * MEM" is simply a
-best-guess approximation and not necessarily accurate for your
-intended usage of the system. If you intend to use the system heavily
-in a server or multi-user application, you may be well advised to
-increase this size. You may also create swap space on multiple drives
-for a larger "total" swap and this is, in fact, recommended if you
-have multiple, fast drives for which such load-balancing can only help
-overall I/O performance.
-
-The /usr filesystem should be sized according to what kind of
-distributions you're trying to load and how many packages you intend
-to install in locations like /usr/local. You can also make /usr/local
-a separate filesystem if you don't want to risk filling up your /usr
-by mistake.
-
-Another useful filesystem to create is /var, which contains mail, news
-printer spool files and other temporary items. It is a popular
-candidate for a separate partition and should be sized according to
-your estimates of the amount of mail, news or spooled print jobs that
-may be stored there.
-
-WARNING: If you do not create a separate filesystem for /var, space
-for such files will be allocated out of the root (/) filesystem
-instead. You may therefore wish to make the / partition bigger if you
-expect a lot of mail or news and do not want to make /var its own
-partition.
-
-If you're new to this installation, you might also want to read the
-following explanation of how FreeBSD's new "slice" paradigm for
-looking at disk storage works:
-
-
-In FreeBSD's new system, a device name can be broken up into up to 3
-parts. Take a typical name like ``/dev/da0s1a'':
-
- The first three characters represent the drive name. If we had
- a system with two SCSI drives on it then we'd see /dev/da0 and
- /dev/da1 as the device entries representing the entire drives.
-
- Next you have the "slice" (or "FDISK Partition") number,
- as seen in the Partition Editor. Assuming that our da0
- contained two slices, a FreeBSD slice and a DOS slice, that
- would give us /dev/da0s1 and /dev/da0s2 as device entries pointing
- to the entire slices.
-
- Next, if a slice is a FreeBSD slice, you can have a number of
- (confusingly named) "partitions" inside of it.
-
- These partitions are where various filesystems or swap areas live,
- and using our hypothetical two-SCSI-disk machine again, we might
- have something like the following layout on da0:
-
- Name Mountpoint
- ---- ----------
- da0s1a /
- da0s1b <swap space>
- da0s1e /usr
-
-Once you understand all this, then the purpose of the label editor
-becomes fairly clear: You're carving up the FreeBSD slices displayed
-at the top of the screen into smaller pieces, which are displayed in
-the middle of the screen, and then assigning FreeBSD file system names
-(mount points) to them.
-
-You can also use the label editor to mount existing partitions/slices
-into your filesystem hierarchy, as is frequently done for DOS FAT
-slices. For FreeBSD partitions, you can also toggle the "newfs" state
-so that the partitions are either (re)created from scratch or simply
-checked and mounted (the contents are preserved).
-
-When you're done, type `Q' to exit.
-
-No actual changes will be made to the disk until you (C)ommit from the
-Install menu or (W)rite directly from this one. You're working with
-what is essentially a copy of the disk label(s), both here and in the
-FDISK Partition Editor, and the actual on-disk labels won't be
-affected by any changes you make until you explicitly say so.
diff --git a/usr.sbin/sysinstall/help/register.hlp b/usr.sbin/sysinstall/help/register.hlp
deleted file mode 100644
index 811f71d7394d..000000000000
--- a/usr.sbin/sysinstall/help/register.hlp
+++ /dev/null
@@ -1,76 +0,0 @@
-This screen allows you to register yourself with the FreeBSD Project's
-user counter & statistics database.
-
-** IT IS VERY IMPORTANT THAT YOU DO THIS! **
-
-Believe me, I hate filling out forms as much as anyone, and most
-people's understandable reaction to a registration form is to say "Eh,
-what's this? They want to send me junk mail and then on top of that
-they expect me to go to *extra* trouble in order to make it easy for
-them?! Forget it!"
-
-This is not that kind of registration, and I strongly urge you to take
-just a few minutes to read this and find out how much the simple act
-of registering can help both you and FreeBSD.
-
-1. It is very much in your best interest, as a FreeBSD user, to stand
- up and be counted so that various software vendors will begin to
- take you and your operating system seriously. There are numerous
- ISVs (Independent Software Vendors) who would be only too happy
- to port the kinds of applications that many FreeBSD users are
- currently screaming for (everything from spreadsheets and word
- processing packages to games) if they only had some idea that it
- might be worth the trouble. The only way to convince the ISVs that
- FreeBSD is worth their trouble is to show them how many users
- we have, and to do that we need your registration! At this time
- we literally do not know how many users FreeBSD has, and that's
- hardly helpful when you're trying to convince someone to port
- software to it.
-
-
-2. We will not send you *anything* you do not ask for. Some people
- are genuinely interested in new product announcements for FreeBSD
- or want to hear about security issues & other important advisories
- as they come up, and for such people we've added registration
- options for selecting various types of additional material they
- might be interested in receiving as a side-effect of registration.
-
- The default behavior is to NOT put the user on any special mailing
- lists or provide their names in mailing list data sent to
- (carefully screened) FreeBSD product advertisers - all of that must
- be specifically requested during the registration.
-
-Most fields in the form are fairly self-explanatory. At the minimum,
-you should enter your first and last name as well as your email
-address so that we can weed obvious duplicates from the counter. You
-will NOT be sent any mail at this address unless you also sign up for
-one of the additional notification services, and it's only used to
-provide us with a way of differentiating "John Smith <smith@foo.org>"
-from "John Smith <jsm@bar.com>" in the simple, no-frills registration
-case. If you do not have an email address, some sort of postal
-address will serve the same purpose.
-
-If you also wish to receive the FreeBSD Newsletter, published and
-distributed free of charge by Walnut Creek CDROM in printed form,
-then you must specify some sort of postal address. Likewise, if you
-elect to receive notification on the email version then you should
-specify a valid Email address. Back-issues of the FreeBSD newsletter
-are available at ftp://ftp.freebsd.org/pub/FreeBSD/doc/newsletter/ .
-
-Should you wish to unsubscribe to the FreeBSD Newsletter or otherwise
-de-register yourself at a later time, you can simply send mail to
-register-request@freebsd.org. If you subscribe to the announce
-mailing list (and it's a good idea) then you can modify your
-subscription at any time by sending mail to majordomo@freebsd.org
-
-
-Your cooperation with this new registration service is greatly
-appreciated, and by taking just 5 minutes to fill this out now you
-will be helping us to gather data which will greatly assist FreeBSD in
-firmly establishing a position as a serious UN*X operating system
-contender.
-
-Regards,
-
- Jordan Hubbard,
- FreeBSD PR Officer
diff --git a/usr.sbin/sysinstall/help/shortcuts.hlp b/usr.sbin/sysinstall/help/shortcuts.hlp
deleted file mode 100644
index b40d29a669d3..000000000000
--- a/usr.sbin/sysinstall/help/shortcuts.hlp
+++ /dev/null
@@ -1,114 +0,0 @@
-/stand/sysinstall now supports command-line "shortcuts" which can
-often replace outdated commands, like pkg_manage. Multiple commands
-can be invoked in sequence, and variables may be set on-the-fly to
-customize the installation program's behavior in various ways.
-
-Syntax:
-
-/stand/sysinstall [var=value ..] [command ..]
-
-Where "var" can be one or more of:
-
-blanktime Screen blank time setting in seconds
-bootManager Select boot manager: booteasy, standard or none
-browserBinary Which doc browser to use (default: lynx)
-browserPackage Which package to get browser from (default: lynx)
-cpioVerbose How verbose to be with cpio: high, medium or low
-debug Extra debugging?
-disk Which disk to operate on (wd0, da0, etc).
-domainname Domain name
-editor Which screen editor to use
-ifconfig_<iface> For each <iface> in network_devices
-ftpDirectory Root of the FreeBSD distribution tree on FTP server
-ftpOnError Set to retry or abort
-ftpPass Which password to use when logging into FTP server
-ftp Which FTP site/dir to use (URL ftp://site/dir/..)
-ftpPort Which FTP port to use (default: 21)
-ftpRetryCount How many times to retry a fetch operation
-ftpUser Which username to use when logging into FTP server
-ftpHost Which FTP hostname to use (overrides ftp variable)
-gated Use gated instead of routed
-defaultrouter IP address of default route
-geometry Geometry to use for selected disk ("cyl/hd/sec")
-hostname Fully qualified domain name for host.
-network_interfaces Which network interfaces to configure
-ipaddr IP address for this host's primary interface
-nameserver IP address of name server
-netmask Netmask for this host's primary interface
-nfs Full host:/path/ specification to NFS media
-nfsHost Host portion of nfs path
-nfsSecure Use NFS secure mount (-P flag)
-nfs_server Configure this machine as an NFS server
-noConfirm Don't ask for confirmation on non-fatal errors
-ntpDate Which ntp clock synchronization server to use
-pcnfsd Install the PCNFSD package
-ports Path to the ports collection
-releaseName Which FreeBSD release to install
-rootSize Size of the root partition to create for Auto
-routedflags Which flags to pass to routed, if enabled
-serialSpeed How fast to run a SLIP/PPP connection
-slowEthernetCard PC ethernet card is uncommonly slow
-swapSize Size of the swap partition to create for Auto
-tapeBlocksize Tape size in blocks
-ufs Full path to UFS media directory
-usrSize Size of the /usr partition to create for Auto
-varSize Size of the /var partition to create for Auto
-
-And "command" can be one or more of:
-
-addUser Add a new user to the system
-addGroup Add a new group to the system
-configAnonFTP Configure system for anonymous FTP
-configGated Configure and install gated
-configNFSServer Configure host as an NFS server
-configPackages Browse / install packages
-diskPartitionEditor Partition a new or existing disk
-diskPartitionWrite Write out any changed partition information
-diskLabelEditor Label/Newfs/Mount new or existing filesystems
-diskLabelCommit Write out any changed label information
-distReset Reset distribution information
-distSetDeveloper Select developer distribution
-distSetXDeveloper Select X developer distribution
-distSetKernDeveloper Select kernel developer distribution
-distSetUser Select user distribution
-distSetXUser Select X user distribution
-distSetMinimum Select minimal distribution
-distSetEverything Select all distributions
-distSetDES Select DES sub-distributions
-distSetSrc Select source sub-distributions
-distSetXF86 Select XFree86 sub-distributions
-distExtractAll Extract all selected distributions
-docBrowser Browse documentation
-installCommit Commit any pending installation operations
-installExpress Express installation
-installUpgrade Upgrade installation
-installFixup Go into "fixit" mode
-mediaSetCDROM Select CDROM media
-mediaSetFloppy Select floppy media
-mediaSetDOS Select DOS media
-mediaSetTape Select tape media
-mediaSetFTP Select FTP media
-mediaSetFTPPassive Select FTP media in passive mode
-mediaSetUFS Select UFS media
-mediaSetNFS Select NFS media
-mediaSetFtpUserPass Prompt for FTP username and password
-mediaSetCPIOVerbosity Prompt for CPIO verbosity
-mediaGetType Prompt for media type
-optionsEditor Go to options editor
-register Go to registration editor.
-
-Examples:
-
-/stand/sysinstall mediaSetFTP configPackages
-
-Selects an FTP site and then goes to the package configuration menu.
-
-
-/stand/sysinstall disk=da0 diskPartitionEditor
-
-Invokes the disk partition editor on disk da0.
-
-
-If /stand/sysinstall is linked to another filename, say
-`/usr/local/bin/configPackages', then the basename will be used
-as an implicit command name.
diff --git a/usr.sbin/sysinstall/help/slice.hlp b/usr.sbin/sysinstall/help/slice.hlp
deleted file mode 100644
index 33280a4349b9..000000000000
--- a/usr.sbin/sysinstall/help/slice.hlp
+++ /dev/null
@@ -1,59 +0,0 @@
-This is the Main Slice (``FDISK'' or PC-style Partition) Editor.
-
-Possible commands are printed at the bottom and the Master Boot Record
-contents are shown at the top. You can move up and down with the
-arrow keys and (C)reate a new slice whenever the highlighted
-selection bar is over a slice whose type is marked as "unused."
-
-You are expected to leave this screen with at least one slice
-marked "FreeBSD." Note that unlike Linux, you don't need to create
-multiple FreeBSD FDISK partition entries for different things like
-swap, file systems, etc. The usual convention is to create ONE
-FreeBSD slice (FDISK partition) per drive and then subsection this slice
-into swap and file systems with the Label editor.
-
-No actual changes will be made to the disk until you (C)ommit from the
-Install menu or use the (W)rite option here! You're working with what
-is essentially a copy of the disk label(s), both here and in the Label
-Editor.
-
-If you want to use the entire disk for FreeBSD, type `A'. You'll be
-asked whether or not you wish to keep the disk (potentially) compatible
-with other operating systems, i.e. the information in the FDISK table
-should be kept valid. If you select the default of `Yes', slices will be
-aligned to fictitious cylinder boundaries and space will be reserved
-in front of the FreeBSD slice for a [future] possible boot manager.
-
-For the truly dedicated disk case, you can select `No' at the
-compatibility prompt. In that case, all BIOS geometry considerations
-will no longer be in effect and you can safely ignore any
-``The detected geometry is invalid'' warning messages you may later
-see. It is also not necessary in this case to set a slice bootable
-or install an MBR boot manager as both things are then irrelevant.
-
-The FreeBSD slice will start at absolute sector 0 of the disk (so that
-FreeBSD's disk label is identical to the Master Boot Record) and
-extend to the very last sector of the disk medium. Needless to say,
-such a disk cannot have any sort of a boot manager, `disk manager',
-or anything else that has to interact with the BIOS. This option is
-therefore only considered safe for SCSI disks and most IDE disks and
-is primarily intended for people who are going to set up a dedicated
-FreeBSD server or workstation, not a typical `home PC'.
-
-The flags field has the following legend:
-
- '=' -- This slice is properly aligned.
- '>' -- This slice doesn't end before cylinder 1024
- 'R' -- This slice contains the root (/) filesystem
- 'B' -- Slice employs BAD144 bad-spot handling
- 'C' -- This is the FreeBSD 2.0-compatibility slice (default)
- 'A' -- This slice is marked active.
-
-If you select a slice for Bad144 handling, it will be scanned
-for bad blocks before any new filesystems are made on it.
-
-If no slice is marked Active, you will need to either install
-a Boot Manager (the option for which will be presented later in the
-installation) or set one Active before leaving this screen.
-
-To leave the slice editor, type `Q'.
diff --git a/usr.sbin/sysinstall/help/tcp.hlp b/usr.sbin/sysinstall/help/tcp.hlp
deleted file mode 100644
index d79cf2732bc1..000000000000
--- a/usr.sbin/sysinstall/help/tcp.hlp
+++ /dev/null
@@ -1,34 +0,0 @@
-This screen allows you to set up your general network parameters
-(hostname, domain name, DNS server, etc) as well as the settings for a
-given interface (which was selected from the menu before this screen).
-
-PLIP/SLIP users - please read through to the end of this doc!
-
-You can move through the fields with the TAB, BACK-TAB and ENTER
-keys. To edit a field, use DELETE or BACKSPACE. You may also use ^A
-(control-A) to go to the beginning of the line, ^E (control-E) to go
-to the end, ^F (control-F) to go forward a character, ^B (control-B)
-to go backward one character, ^D (control-D) to delete the character
-under the cursor and ^K (control-K) to delete to the end of the line.
-Basically, the standard EMACS motion sequences.
-
-The "Extra options to ifconfig" field is kind of special (read: a
-hack :-):
-
-If you're running SLIP or PLIP, you also need to use it for specifying
-the remote end of the link (simply type the foreign IP address in).
-In the specific case where you're running PLIP with a Linux host peer
-rather than a FreeBSD one, you also must add the "-link0" flag after the
-foreign address.
-
-
-If you're dealing with an ethernet adaptor with multiple media
-connectors (e.g. AUI, 10BT, 10B2, etc), you can use this field to
-specify which one to use. The following strings are recognized:
-
- "media 10base5/AUI" - Select the AUI port.
- "media 10baseT/UTP" - Select the twisted pair port.
- "media 10base2/BNC" - Select the BNC connector.
- "media 100baseTX" - Select 100BaseT on a 100/10 dual adaptor.
-
-When you're done with this form, select OK.
diff --git a/usr.sbin/sysinstall/help/usage.hlp b/usr.sbin/sysinstall/help/usage.hlp
deleted file mode 100644
index 4d9452031e0a..000000000000
--- a/usr.sbin/sysinstall/help/usage.hlp
+++ /dev/null
@@ -1,68 +0,0 @@
-HOW TO USE THIS SYSTEM
-======================
-
-[press the PageDown key to go to the next screen when you finish
- reading this one]
-
-The following keys are recognized in most of the dialogs you'll
-encounter during this installation:
-
-KEY ACTION
---- ------
-SPACE Select or toggle the current item.
-ENTER Finish with a menu or item.
-UP ARROW Move to previous item (or up, in a text display box).
-DOWN ARROW Move to next item (or down, in a text display box).
-TAB Move to next item or group.
-RIGHT ARROW Move to next item or group (same as TAB).
-SHIFT-TAB Move to previous item or group.
-LEFT ARROW Move to previous item or group (same as SHIFT-TAB).
-PAGE UP In text display boxes, scrolls up one page.
-PAGE DOWN In text display boxes, scrolls down one page.
-F1 Display associated help text.
-
-If you see small "^(-)" or "v(+)" symbols at the edges of a menu, it
-means that there are more items above or below the current one that
-aren't being shown (due to insufficient screen space). In text
-display boxes, the amount of text above the current point will be
-displayed as a percentage in the lower right corner. Using the
-Up/Down arrow keys will cause the object to scroll by line. The
-PageUp and PageDown keys will scroll by entire screens.
-
-Selecting OK in a menu will confirm whatever action it's controlling.
-Selecting Cancel will cancel the operation and generally return you to
-the previous menu. Note also that "checkbox" menus use SPACE to select
-their items, not ENTER! Pressing ENTER will leave the menu with either
-an OK or Cancel status, depending on which button at the bottom is
-selected, and is probably not what you wanted to do if still selecting
-options. Remember the spacebar!
-
-Most screens obey the Help key (F1) - USE IT! It generally offers useful
-context-specific hints on what to do at each stage of the installation,
-and if you're at all unsure about what to do at a given stage in the
-installation, hit F1!
-
-
-SPECIAL FEATURES:
-=================
-
-It is possible to select a menu item by typing the first character of
-its name, if unique. This will generally be an item number.
-
-The console driver contains a scroll-back buffer for reviewing things
-that may have scrolled off the screen. To use scroll-back, press the
-"Scroll Lock" key on your keyboard and use the arrow or Page Up/Page
-Down keys to move through the saved text. To leave scroll-back mode,
-press the Scroll Lock key again. This feature is most useful for
-reading back through your boot messages (go ahead, try it now!) though
-it's also useful when dealing with sub-shells or other "wizard modes"
-that don't use menus and tend to scroll their output off the top of
-the screen.
-
-FreeBSD also supports multiple "virtual consoles" which you can use to
-in order to have several active sessions at once. Use ALT-F<n> to
-switch between screens, where `F<n>' is the function key corresponding
-to the screen you wish to see. By default, the system comes with 3
-virtual consoles enabled - you can enable more by editing the
-/etc/ttys file and turning the "off" field to "on" in the relevant vty
-entries (up to 12).
diff --git a/usr.sbin/sysinstall/help/usermgmt.hlp b/usr.sbin/sysinstall/help/usermgmt.hlp
deleted file mode 100644
index d0819fe1df33..000000000000
--- a/usr.sbin/sysinstall/help/usermgmt.hlp
+++ /dev/null
@@ -1,89 +0,0 @@
-These screens allow you to add groups and users to your system.
-
-You can move through the fields with the TAB, BACK-TAB and ENTER
-keys. To edit a field, use DELETE or BACKSPACE. You may also use ^A
-(control-A) to go to the beginning of the line, ^E (control-E) to go
-to the end, ^F (control-F) to go forward a character, ^B (control-B)
-to go backward one character, ^D (control-D) to delete the character
-under the cursor and ^K (control-K) to delete to the end of the line.
-Basically, the standard EMACS motion sequences.
-
-When you're done with this form, select OK.
-
-Many of the settings get reasonable defaults if you leave them blank.
-The first time you have entered the name of the new group or user, the
-system will show you what it would chose for most of these fields.
-You are free to change them, of course.
-
-
-User groups
-===========
-
-It's certainly almost generally a good idea to first create a new
-group for your users. Common names for such a group are "users", or
-even simply "other". Group names are used to control file access
-permissions for users that belong to the same group. Several group
-names are already used for system files.
-
-The numerical user or group IDs are often nothing you want to care for
-explicitly. If you don't fill in these fields, the system will chose
-reasonable defaults. However, these numbers (rather than the
-associated names) are what the operating system actually uses to
-distinguish users and groups -- hence they should normally be unique
-to each person or group, respectively.
-
-(The initial membership list for a new group is currently
-unimplemented, sorry.)
-
-
-Users
-=====
-
-The user's login ID is a short (up to 15 characters) alphanumeric ID
-the user must enter when logging into the system. It's often the
-initial letters of the user's name, and commonly used in lower case.
-It's also the local mail name for this user (though it's possible to
-also setup more descriptive mail alias names later).
-
-The user's login group determines which group access rights the user
-will initially get when logging in. If an additional list of groups is
-provided where the user will become a member of, (s)he will also be
-able to access files of those groups later without providing any
-additional password etc. Except for the "wheel" case mentioned below,
-the additional group membership list should normally not contain the
-login group again.
-
-The user's password can also be set here, and should be chosen with
-care - 6 or more characters, intermixing punctuation and numerics, and
-*not* a word from the dictionary or related to the username is a good
-password choice.
-
-Some of the system's groups have a special meaning. In particular,
-members of group "wheel" are the only people who are later allowed to
-become superuser using the command su(1). So if you're going to add a
-new user who should later perform administrative tasks, don't forget
-to add him to this group! (Well, ``he'' will most likely be yourself
-in the very first place. :)
-
-Also, members of group "operator" will by default get permissions for
-minor administrative operations, like performing system backups, or
-shutting down the system -- without first becoming superuser! So,
-take care with adding people to this group.
-
-The ``full name'' field serves as a comment only. It is also used by
-mail front ends to determine the real name of the user, hence you
-should actually fill in the first and last name of this user. By
-convention, this field can be divided into comma-separated subfields,
-where the office location, the work phone number, and the home phone
-number follow the full name of the user.
-
-The home directory is the directory in the filesystem where the user
-is being logged into, and where his personalized setup files (``dot
-files'', since they usually begin with a `.' and are not displayed by
-the ls(1) command by default) will be looked up. It is often created
-under /usr/home/ or /home/.
-
-Finally, the shell is the user's initial command interpreter. The
-default shell is /bin/sh, some users prefer the more historic
-/bin/csh. Other, often more user-friendly and comfortable shells can
-be found in the ports and packages collection.
diff --git a/usr.sbin/sysinstall/http.c b/usr.sbin/sysinstall/http.c
deleted file mode 100644
index 14220bbe01e1..000000000000
--- a/usr.sbin/sysinstall/http.c
+++ /dev/null
@@ -1,180 +0,0 @@
-#include "sysinstall.h"
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <sys/param.h>
-#include <netdb.h>
-
-int HttpPort;
-
-Boolean
-mediaInitHTTP(Device *dev)
-{
-/*
- * Some proxies fetch files with certain extensions in "ascii mode" instead
- * of "binary mode" for FTP. The FTP server then translates all LF to CRLF.
- *
- * You can force Squid to use binary mode by appending ";type=i" to the URL,
- * which is what I do here. For other proxies, the LF->CRLF substitution
- * is reverted in distExtract().
- */
-
- extern int h_errno;
- int rv,s;
- bool el; /* end of header line */
- char *cp, buf[PATH_MAX], req[BUFSIZ];
- struct sockaddr_in peer;
- struct hostent *peer_in;
-
- s=socket(PF_INET, SOCK_STREAM, 6); /* tcp */
- if (s == -1) {
- msgConfirm("Network error");
- return FALSE;
- }
-
- peer_in=gethostbyname(variable_get(VAR_HTTP_HOST));
- if (peer_in == NULL) {
- msgConfirm("%s",hstrerror(h_errno));
- return FALSE;
- }
-
- peer.sin_len=peer_in->h_length;
- peer.sin_family=peer_in->h_addrtype;
- peer.sin_port=htons((u_short) HttpPort);
- bcopy(peer_in->h_addr_list[0], &peer.sin_addr, peer_in->h_length);
-
- rv=connect(s,(struct sockaddr *)&peer,sizeof(peer));
- if (rv == -1) {
- msgConfirm("Couldn't connect to proxy %s:%s",
- variable_get(VAR_HTTP_HOST),variable_get(VAR_HTTP_PORT));
- return FALSE;
- }
-
- sprintf(req,"GET / HTTP/1.0\r\n\r\n");
- write(s,req,strlen(req));
-/*
- * scan the headers of the response
- * this is extremely quick'n dirty
- *
- */
- cp=buf;
- el=FALSE;
- rv=read(s,cp,1);
- variable_set2(VAR_HTTP_FTP_MODE,"",0);
- while (rv>0) {
- if ((*cp == '\012') && el) {
- /* reached end of a header line */
- if (!strncmp(buf,"Server: ",8)) {
- if (!strncmp(buf,"Server: Squid",13)) {
- variable_set2(VAR_HTTP_FTP_MODE,";type=i",0);
- } else {
- variable_set2(VAR_HTTP_FTP_MODE,"",0);
- }
- }
- /* ignore other headers */
- /* check for "\015\012" at beginning of line, i.e. end of headers */
- if ((cp-buf) == 1)
- break;
- cp=buf;
- rv=read(s,cp,1);
- } else {
- el=FALSE;
- if (*cp == '\015')
- el=TRUE;
- cp++;
- rv=read(s,cp,1);
- }
- }
- close(s);
- return TRUE;
-}
-
-
-FILE *
-mediaGetHTTP(Device *dev, char *file, Boolean probe)
-{
- FILE *fp;
- int rv,s;
- bool el; /* end of header line */
- char *cp, buf[PATH_MAX], req[BUFSIZ];
- struct sockaddr_in peer;
- struct hostent *peer_in;
-
- s=socket(PF_INET, SOCK_STREAM, 6); /* tcp */
- if (s == -1) {
- msgConfirm("Network error");
- return NULL;
- }
-
- peer_in=gethostbyname(variable_get(VAR_HTTP_HOST));
- peer.sin_len=peer_in->h_length;
- peer.sin_family=peer_in->h_addrtype;
- peer.sin_port=htons((u_short) HttpPort);
- bcopy(peer_in->h_addr_list[0], &peer.sin_addr, peer_in->h_length);
-
- rv=connect(s,(struct sockaddr *)&peer,sizeof(peer));
- if (rv == -1) {
- msgConfirm("Couldn't connect to proxy %s:%s",
- variable_get(VAR_HTTP_HOST),variable_get(VAR_FTP_PORT));
- return NULL;
- }
-
- sprintf(req,"GET %s/%s/%s%s HTTP/1.0\r\n\r\n",
- variable_get(VAR_FTP_PATH), variable_get(VAR_RELNAME),
- file, variable_get(VAR_HTTP_FTP_MODE));
-
- if (isDebug()) {
- msgDebug("sending http request: %s",req);
- }
- write(s,req,strlen(req));
-
-/*
- * scan the headers of the response
- * this is extremely quick'n dirty
- *
- */
- cp=buf;
- el=FALSE;
- rv=read(s,cp,1);
- while (rv>0) {
- if ((*cp == '\012') && el) {
- /* reached end of a header line */
- if (!strncmp(buf,"HTTP",4)) {
- rv=strtol((char *)(buf+9),0,0);
- *(cp-1)='\0'; /* chop the CRLF off */
- if (probe && (rv != 200)) {
- return NULL;
- } else if (rv >= 500) {
- msgConfirm("Server error %s when sending %s, you could try an other server",buf, req);
- return NULL;
- } else if (rv == 404) {
- msgConfirm("%s was not found, maybe directory or release-version are wrong?",req);
- return NULL;
- } else if (rv >= 400) {
- msgConfirm("Client error %s, you could try an other server",buf);
- return NULL;
- } else if (rv >= 300) {
- msgConfirm("Error %s,",buf);
- return NULL;
- } else if (rv != 200) {
- msgConfirm("Error %s when sending %s, you could try an other server",buf, req);
- return NULL;
- }
- }
- /* ignore other headers */
- /* check for "\015\012" at beginning of line, i.e. end of headers */
- if ((cp-buf) == 1)
- break;
- cp=buf;
- rv=read(s,cp,1);
- } else {
- el=FALSE;
- if (*cp == '\015')
- el=TRUE;
- cp++;
- rv=read(s,cp,1);
- }
- }
- fp=fdopen(s,"r");
- return fp;
-}
diff --git a/usr.sbin/sysinstall/index.c b/usr.sbin/sysinstall/index.c
deleted file mode 100644
index 2f29cc2b18ce..000000000000
--- a/usr.sbin/sysinstall/index.c
+++ /dev/null
@@ -1,756 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last program in the `sysinstall' line - the next
- * generation being essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 <fcntl.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <ncurses.h>
-#include <dialog.h>
-#include "sysinstall.h"
-
-/* Macros and magic values */
-#define MAX_MENU 12
-#define _MAX_DESC 55
-
-/* A structure holding the root, top and plist pointer at once */
-struct ListPtrs
-{
- PkgNodePtr root; /* root of tree */
- PkgNodePtr top; /* part of tree we handle */
- PkgNodePtr plist; /* list of selected packages */
-};
-typedef struct ListPtrs* ListPtrsPtr;
-
-static void index_recorddeps(Boolean add, PkgNodePtr root, IndexEntryPtr ie);
-
-/* Shared between index_initialize() and the various clients of it */
-PkgNode Top, Plist;
-
-/* Smarter strdup */
-inline char *
-_strdup(char *ptr)
-{
- return ptr ? strdup(ptr) : NULL;
-}
-
-static char *descrs[] = {
- "Package Selection", "To mark a package, move to it and press SPACE. If the package is\n"
- "already marked, it will be unmarked or deleted (if installed).\n"
- "Items marked with a `D' are dependencies which will be auto-loaded.\n"
- "To search for a package by name, press ESC. To select a category,\n"
- "press RETURN. NOTE: The All category selection creates a very large\n"
- "submenu! If you select it, please be patient while it comes up.",
- "Package Targets", "These are the packages you've selected for extraction.\n\n"
- "If you're sure of these choices, select OK.\n"
- "If not, select Cancel to go back to the package selection menu.\n",
- "All", "All available packages in all categories.",
- "afterstep", "Ports to support the AfterStep window manager.",
- "applications", "User application software.",
- "archivers", "Utilities for archiving and unarchiving data.",
- "astro", "Applications related to astronomy.",
- "audio", "Audio utilities - most require a supported sound card.",
- "benchmarks", "Utilities for measuring system performance.",
- "biology", "Software related to biology.",
- "cad", "Computer Aided Design utilities.",
- "chinese", "Ported software for the Chinese market.",
- "comms", "Communications utilities.",
- "converters", "Format conversion utilities.",
- "databases", "Database software.",
- "deskutils", "Various Desktop utilities.",
- "devel", "Software development utilities and libraries.",
- "documentation", "Document preparation utilities.",
- "editors", "Common text editors.",
- "elisp", "Things related to Emacs Lisp.",
- "emulators", "Utilities for emulating other OS types.",
- "ftp", "FTP client and server utilities.",
- "games", "Various and sundry amusements.",
- "german", "Ported software for Germanic countries.",
- "gnome", "Components of the Gnome Desktop environment.",
- "graphics", "Graphics libraries and utilities.",
- "ipv6", "IPv6 related software.",
- "irc", "Internet Relay Chat utilities.",
- "japanese", "Ported software for the Japanese market.",
- "java", "Java language support.",
- "kde", "Software for the K Desktop Environment.",
- "korean", "Ported software for the Korean market.",
- "lang", "Computer languages.",
- "languages", "Computer languages.",
- "libraries", "Software development libraries.",
- "mail", "Electronic mail packages and utilities.",
- "math", "Mathematical computation software.",
- "mbone", "Applications and utilities for the MBONE.",
- "misc", "Miscellaneous utilities.",
- "net", "Networking utilities.",
- "news", "USENET News support software.",
- "numeric", "Mathematical computation software.",
- "offix", "An office automation suite of sorts.",
- "orphans", "Packages without a home elsewhere.",
- "palm", "Software support for the 3Com Palm Pilot(tm) series.",
- "perl5", "Utilities/modules for the PERL5 language.",
- "pilot", "Software support for the 3Com Palm Pilot(tm) series.",
- "plan9", "Software from the Plan9 operating system.",
- "print", "Utilities for dealing with printing.",
- "printing", "Utilities for dealing with printing.",
- "programming", "Software development utilities and libraries.",
- "python", "Software related to the Python language.",
- "russian", "Ported software for the Russian market.",
- "security", "System security software.",
- "shells", "Various shells (tcsh, bash, etc).",
- "sysutils", "Various system utilities.",
- "tcl75", "TCL v7.5 and packages that depend on it.",
- "tcl76", "TCL v7.6 and packages that depend on it.",
- "tcl80", "TCL v8.0 and packages that depend on it.",
- "tcl82", "TCL v8.2 and packages that depend on it.",
- "textproc", "Text processing/search utilities.",
- "tk41", "Tk4.1 and packages that depend on it.",
- "tk42", "Tk4.2 and packages that depend on it.",
- "tk80", "Tk8.0 and packages that depend on it.",
- "tk81", "Tk8.1 and packages that depend on it.",
- "tk82", "Tk8.2 and packages that depend on it.",
- "tkstep80", "tkstep wm and packages that depend on it.",
- "troff", "TROFF text formatting utilities.",
- "vietnamese", "Ported software for the Vietnamese market.",
- "windowmaker", "Ports to support the WindowMaker window manager.",
- "www", "WEB utilities (browers, HTTP servers, etc).",
- "x11", "X Window System based utilities.",
- "x11-clocks", "X Window System based clocks.",
- "x11-fm", "X Window System based file managers.",
- "x11-fonts", "X Window System fonts and font utilities.",
- "x11-servers", "X Window System servers.",
- "x11-toolkits", "X Window System based development toolkits.",
- "x11-wm", "X Window System window managers.",
- NULL, NULL,
-};
-
-static char *
-fetch_desc(char *name)
-{
- int i;
-
- for (i = 0; descrs[i]; i += 2) {
- if (!strcmp(descrs[i], name))
- return descrs[i + 1];
- }
- return "No description provided";
-}
-
-static PkgNodePtr
-new_pkg_node(char *name, node_type type)
-{
- PkgNodePtr tmp = safe_malloc(sizeof(PkgNode));
-
- tmp->name = _strdup(name);
- tmp->type = type;
- return tmp;
-}
-
-static char *
-strip(char *buf)
-{
- int i;
-
- for (i = 0; buf[i]; i++)
- if (buf[i] == '\t' || buf[i] == '\n')
- buf[i] = ' ';
- return buf;
-}
-
-static IndexEntryPtr
-new_index(char *name, char *pathto, char *prefix, char *comment, char *descr, char *maint, char *deps)
-{
- IndexEntryPtr tmp = safe_malloc(sizeof(IndexEntry));
-
- tmp->name = _strdup(name);
- tmp->path = _strdup(pathto);
- tmp->prefix = _strdup(prefix);
- tmp->comment = _strdup(comment);
- tmp->descrfile = strip(_strdup(descr));
- tmp->maintainer = _strdup(maint);
- tmp->deps = _strdup(deps);
- tmp->depc = 0;
- tmp->installed = package_exists(name);
- return tmp;
-}
-
-static void
-index_register(PkgNodePtr top, char *where, IndexEntryPtr ptr)
-{
- PkgNodePtr p, q;
-
- for (q = NULL, p = top->kids; p; p = p->next) {
- if (!strcmp(p->name, where)) {
- q = p;
- break;
- }
- }
- if (!p) {
- /* Add new category */
- q = new_pkg_node(where, PLACE);
- q->desc = fetch_desc(where);
- q->next = top->kids;
- top->kids = q;
- }
- p = new_pkg_node(ptr->name, PACKAGE);
- p->desc = ptr->comment;
- p->data = ptr;
- p->next = q->kids;
- q->kids = p;
-}
-
-static int
-copy_to_sep(char *to, char *from, int sep)
-{
- char *tok;
-
- tok = strchr(from, sep);
- if (!tok) {
- *to = '\0';
- return 0;
- }
- *tok = '\0';
- strcpy(to, from);
- return tok + 1 - from;
-}
-
-static int
-readline(FILE *fp, char *buf, int max)
-{
- int rv, i = 0;
- char ch;
-
- while ((rv = fread(&ch, 1, 1, fp)) == 1 && ch != '\n' && i < max)
- buf[i++] = ch;
- if (i < max)
- buf[i] = '\0';
- return rv;
-}
-
-int
-index_parse(FILE *fp, char *name, char *pathto, char *prefix, char *comment, char *descr, char *maint, char *cats, char *rdeps)
-{
- char line[2048];
- char junk[511];
- char *cp;
- int i;
-
- i = readline(fp, line, sizeof line);
- if (i <= 0)
- return EOF;
- cp = line;
- cp += copy_to_sep(name, cp, '|');
- cp += copy_to_sep(pathto, cp, '|');
- cp += copy_to_sep(prefix, cp, '|');
- cp += copy_to_sep(comment, cp, '|');
- cp += copy_to_sep(descr, cp, '|');
- cp += copy_to_sep(maint, cp, '|');
- cp += copy_to_sep(cats, cp, '|');
- cp += copy_to_sep(junk, cp, '|'); /* build deps - not used */
- if (index(cp, '|'))
- copy_to_sep(rdeps, cp, '|');
- else
- strncpy(rdeps, cp, 1023);
- return 0;
-}
-
-int
-index_read(FILE *fp, PkgNodePtr papa)
-{
- char name[127], pathto[255], prefix[255], comment[255], descr[127], maint[127], cats[511], deps[1024];
- PkgNodePtr i;
-
- while (index_parse(fp, name, pathto, prefix, comment, descr, maint, cats, deps) != EOF) {
- char *cp, *cp2, tmp[1024];
- IndexEntryPtr idx;
-
- idx = new_index(name, pathto, prefix, comment, descr, maint, deps);
- /* For now, we only add things to menus if they're in categories. Keywords are ignored */
- for (cp = strcpy(tmp, cats); (cp2 = strchr(cp, ' ')) != NULL; cp = cp2 + 1) {
- *cp2 = '\0';
- index_register(papa, cp, idx);
- }
- index_register(papa, cp, idx);
-
- /* Add to special "All" category */
- index_register(papa, "All", idx);
- }
-
- /* Adjust dependency counts */
- for (i = papa->kids; i != NULL; i = i->next)
- if (strcmp(i->name, "All") == 0)
- break;
- for (i = i->kids; i != NULL; i = i->next)
- if (((IndexEntryPtr)i->data)->installed)
- index_recorddeps(TRUE, papa, i->data);
-
- return 0;
-}
-
-void
-index_init(PkgNodePtr top, PkgNodePtr plist)
-{
- if (top) {
- top->next = top->kids = NULL;
- top->name = "Package Selection";
- top->type = PLACE;
- top->desc = fetch_desc(top->name);
- top->data = NULL;
- }
- if (plist) {
- plist->next = plist->kids = NULL;
- plist->name = "Package Targets";
- plist->type = PLACE;
- plist->desc = fetch_desc(plist->name);
- plist->data = NULL;
- }
-}
-
-void
-index_print(PkgNodePtr top, int level)
-{
- int i;
-
- while (top) {
- for (i = 0; i < level; i++) putchar('\t');
- printf("name [%s]: %s\n", top->type == PLACE ? "place" : "package", top->name);
- for (i = 0; i < level; i++) putchar('\t');
- printf("desc: %s\n", top->desc);
- if (top->kids)
- index_print(top->kids, level + 1);
- top = top->next;
- }
-}
-
-/* Swap one node for another */
-static void
-swap_nodes(PkgNodePtr a, PkgNodePtr b)
-{
- PkgNode tmp;
-
- tmp = *a;
- *a = *b;
- a->next = tmp.next;
- tmp.next = b->next;
- *b = tmp;
-}
-
-/* Use a disgustingly simplistic bubble sort to put our lists in order */
-void
-index_sort(PkgNodePtr top)
-{
- PkgNodePtr p, q;
-
- /* Sort everything at the top level */
- for (p = top->kids; p; p = p->next) {
- for (q = top->kids; q; q = q->next) {
- if (q->next && strcmp(q->name, q->next->name) > 0)
- swap_nodes(q, q->next);
- }
- }
-
- /* Now sub-sort everything n levels down */
- for (p = top->kids; p; p = p->next) {
- if (p->kids)
- index_sort(p);
- }
-}
-
-/* Delete an entry out of the list it's in (only the plist, at present) */
-void
-index_delete(PkgNodePtr n)
-{
- if (n->next) {
- PkgNodePtr p = n->next;
-
- *n = *(n->next);
- safe_free(p);
- }
- else /* Kludgy end sentinal */
- n->name = NULL;
-}
-
-/*
- * Search for a given node by name, returning the category in if
- * tp is non-NULL.
- */
-PkgNodePtr
-index_search(PkgNodePtr top, char *str, PkgNodePtr *tp)
-{
- PkgNodePtr p, sp;
-
- for (p = top->kids; p && p->name; p = p->next) {
- if (p->type == PACKAGE) {
- /* If tp == NULL, we're looking for an exact package match */
- if (!tp && !strcmp(p->name, str))
- return p;
-
- /* If tp, we're looking for both a package and a pointer to the place it's in */
- if (tp && !strncmp(p->name, str, strlen(str))) {
- *tp = top;
- return p;
- }
- }
- else if (p->kids) {
- /* The usual recursion-out-of-laziness ploy */
- if ((sp = index_search(p, str, tp)) != NULL)
- return sp;
- }
- }
- if (p && !p->name)
- p = NULL;
- return p;
-}
-
-int
-pkg_checked(dialogMenuItem *self)
-{
- ListPtrsPtr lists = (ListPtrsPtr)self->aux;
- PkgNodePtr kp = self->data, plist = lists->plist;
- int i;
-
- i = index_search(plist, kp->name, NULL) ? TRUE : FALSE;
- if (kp->type == PACKAGE && plist) {
- IndexEntryPtr ie = kp->data;
- int markD, markX;
-
- markD = ie->depc > 0; /* needed as dependency */
- markX = i || ie->installed; /* selected or installed */
- self->mark = markX ? 'X' : 'D';
- return markD || markX;
- } else
- return FALSE;
-}
-
-int
-pkg_fire(dialogMenuItem *self)
-{
- int ret;
- ListPtrsPtr lists = (ListPtrsPtr)self->aux;
- PkgNodePtr sp, kp = self->data, plist = lists->plist;
-
- if (!plist)
- ret = DITEM_FAILURE;
- else if (kp->type == PACKAGE) {
- IndexEntryPtr ie = kp->data;
-
- sp = index_search(plist, kp->name, NULL);
- /* Not already selected? */
- if (!sp) {
- if (!ie->installed) {
- PkgNodePtr np = (PkgNodePtr)safe_malloc(sizeof(PkgNode));
-
- *np = *kp;
- np->next = plist->kids;
- plist->kids = np;
- index_recorddeps(TRUE, lists->root, ie);
- msgInfo("Added %s to selection list", kp->name);
- }
- else if (ie->depc == 0) {
- if (!msgYesNo("Do you really want to delete %s from the system?", kp->name)) {
- if (vsystem("pkg_delete %s %s", isDebug() ? "-v" : "", kp->name)) {
- msgConfirm("Warning: pkg_delete of %s failed.\n Check debug output for details.", kp->name);
- }
- else {
- ie->installed = 0;
- index_recorddeps(FALSE, lists->root, ie);
- }
- }
- }
- else
- msgConfirm("Warning: Package %s is needed by\n %d other installed package%s.",
- kp->name, ie->depc, (ie->depc != 1) ? "s" : "");
- }
- else {
- index_recorddeps(FALSE, lists->root, ie);
- msgInfo("Removed %s from selection list", kp->name);
- index_delete(sp);
- }
- ret = DITEM_SUCCESS;
- /* Mark menu for redraw if we had dependencies */
- if (strlen(ie->deps) > 0)
- ret |= DITEM_REDRAW;
- }
- else { /* Not a package, must be a directory */
- int p, s;
-
- p = s = 0;
- index_menu(lists->root, kp, plist, &p, &s);
- ret = DITEM_SUCCESS | DITEM_CONTINUE;
- }
- return ret;
-}
-
-void
-pkg_selected(dialogMenuItem *self, int is_selected)
-{
- PkgNodePtr kp = self->data;
-
- if (!is_selected || kp->type != PACKAGE)
- return;
- msgInfo(kp->desc);
-}
-
-int
-index_menu(PkgNodePtr root, PkgNodePtr top, PkgNodePtr plist, int *pos, int *scroll)
-{
- struct ListPtrs lists;
- int n, rval, maxname;
- int curr, max;
- PkgNodePtr kp;
- dialogMenuItem *nitems;
- Boolean hasPackages;
- WINDOW *w;
-
- lists.root = root;
- lists.top = top;
- lists.plist = plist;
-
- hasPackages = FALSE;
- nitems = NULL;
- n = maxname = 0;
-
- /* Figure out if this menu is full of "leaves" or "branches" */
- for (kp = top->kids; kp && kp->name; kp = kp->next) {
- int len;
-
- ++n;
- if (kp->type == PACKAGE && plist) {
- hasPackages = TRUE;
- if ((len = strlen(kp->name)) > maxname)
- maxname = len;
- }
- }
- if (!n && plist) {
- msgConfirm("The %s menu is empty.", top->name);
- return DITEM_LEAVE_MENU;
- }
-
- w = savescr();
- while (1) {
- n = 0;
- curr = max = 0;
- use_helpline(NULL);
- use_helpfile(NULL);
- kp = top->kids;
- if (!hasPackages && plist) {
- nitems = item_add(nitems, "OK", NULL, NULL, NULL, NULL, NULL, 0, &curr, &max);
- nitems = item_add(nitems, "Install", NULL, NULL, NULL, NULL, NULL, 0, &curr, &max);
- }
- while (kp && kp->name) {
- char buf[256];
- IndexEntryPtr ie = kp->data;
-
- /* Brutally adjust description to fit in menu */
- if (kp->type == PACKAGE)
- snprintf(buf, sizeof buf, "[%s]", ie->path ? ie->path : "External vendor");
- else
- SAFE_STRCPY(buf, kp->desc);
- if (strlen(buf) > (_MAX_DESC - maxname))
- buf[_MAX_DESC - maxname] = '\0';
- nitems = item_add(nitems, kp->name, buf, pkg_checked, pkg_fire, pkg_selected, kp, (int)&lists, &curr, &max);
- ++n;
- kp = kp->next;
- }
- /* NULL delimiter so item_free() knows when to stop later */
- nitems = item_add(nitems, NULL, NULL, NULL, NULL, NULL, NULL, 0, &curr, &max);
-
-recycle:
- dialog_clear_norefresh();
- if (hasPackages)
- rval = dialog_checklist(top->name, top->desc, -1, -1, n > MAX_MENU ? MAX_MENU : n, -n, nitems, NULL);
- else
- rval = dialog_menu(top->name, top->desc, -1, -1, n > MAX_MENU ? MAX_MENU : n, -n, nitems + (plist ? 2 : 0), (char *)plist, pos, scroll);
- if (rval == -1 && plist) {
- static char *cp;
- PkgNodePtr menu;
-
- /* Search */
- if ((cp = msgGetInput(cp, "Search by package name. Please enter search string:")) != NULL) {
- PkgNodePtr p = index_search(top, cp, &menu);
-
- if (p) {
- int pos, scroll;
-
- /* These need to be set to point at the found item, actually. Hmmm! */
- pos = scroll = 0;
- index_menu(root, menu, plist, &pos, &scroll);
- }
- else
- msgConfirm("Search string: %s yielded no hits.", cp);
- }
- goto recycle;
- }
- items_free(nitems, &curr, &max);
- restorescr(w);
- return rval ? DITEM_FAILURE : DITEM_SUCCESS;
- }
-}
-
-int
-index_extract(Device *dev, PkgNodePtr top, PkgNodePtr who, Boolean depended)
-{
- int status = DITEM_SUCCESS;
- PkgNodePtr tmp2;
- IndexEntryPtr id = who->data;
- WINDOW *w = savescr();
-
- if (id && id->deps && strlen(id->deps)) {
- char t[1024], *cp, *cp2;
-
- SAFE_STRCPY(t, id->deps);
- cp = t;
- while (cp && DITEM_STATUS(status) == DITEM_SUCCESS) {
- if ((cp2 = index(cp, ' ')) != NULL)
- *cp2 = '\0';
- if ((tmp2 = index_search(top, cp, NULL)) != NULL) {
- status = index_extract(dev, top, tmp2, TRUE);
- if (DITEM_STATUS(status) != DITEM_SUCCESS) {
- if (variable_get(VAR_NO_CONFIRM))
- msgNotify("Loading of dependant package %s failed", cp);
- else
- msgConfirm("Loading of dependant package %s failed", cp);
- }
- }
- else if (!package_exists(cp)) {
- if (variable_get(VAR_NO_CONFIRM))
- msgNotify("Warning: %s is a required package but was not found.", cp);
- else
- msgConfirm("Warning: %s is a required package but was not found.", cp);
- }
- if (cp2)
- cp = cp2 + 1;
- else
- cp = NULL;
- }
- }
- /* Done with the deps? Load the real m'coy */
- if (DITEM_STATUS(status) == DITEM_SUCCESS) {
- status = package_extract(dev, who->name, depended);
- if (DITEM_STATUS(status) == DITEM_SUCCESS)
- id->installed = 1;
- }
- restorescr(w);
- return status;
-}
-
-static void
-index_recorddeps(Boolean add, PkgNodePtr root, IndexEntryPtr ie)
-{
- char depends[1024], *space, *todo;
- PkgNodePtr found;
- IndexEntryPtr found_ie;
-
- SAFE_STRCPY(depends, ie->deps);
- for (todo = depends; todo != NULL; ) {
- space = index(todo, ' ');
- if (space != NULL)
- *space = '\0';
-
- if (strlen(todo) > 0) { /* only non-empty dependencies */
- found = index_search(root, todo, NULL);
- if (found != NULL) {
- found_ie = found->data;
- if (add)
- ++found_ie->depc;
- else
- --found_ie->depc;
- }
- }
-
- if (space != NULL)
- todo = space + 1;
- else
- todo = NULL;
- }
-}
-
-static Boolean index_initted;
-
-/* Read and initialize global index */
-int
-index_initialize(char *path)
-{
- FILE *fp;
- WINDOW *w = NULL;
-
- if (!index_initted) {
- w = savescr();
- dialog_clear_norefresh();
-
- /* Got any media? */
- if (!mediaVerify()) {
- restorescr(w);
- return DITEM_FAILURE;
- }
-
- /* Does it move when you kick it? */
- if (!mediaDevice->init(mediaDevice)) {
- restorescr(w);
- return DITEM_FAILURE;
- }
-
- dialog_clear_norefresh();
- msgNotify("Attempting to fetch %s file from selected media.", path);
- fp = mediaDevice->get(mediaDevice, path, TRUE);
- if (!fp) {
- msgConfirm("Unable to get packages/INDEX file from selected media.\n"
- "This may be because the packages collection is not available at\n"
- "on the distribution media you've chosen (most likely an FTP site\n"
- "without the packages collection mirrored). Please verify media\n"
- "(or path to media) and try again. If your local site does not\n"
- "carry the packages collection, then we recommend either a CD\n"
- "distribution or the master distribution on ftp.freebsd.org.");
- mediaDevice->shutdown(mediaDevice);
- restorescr(w);
- return DITEM_FAILURE;
- }
- dialog_clear_norefresh();
- msgNotify("Located INDEX, now reading package data from it...");
- index_init(&Top, &Plist);
- if (index_read(fp, &Top)) {
- msgConfirm("I/O or format error on packages/INDEX file.\n"
- "Please verify media (or path to media) and try again.");
- fclose(fp);
- restorescr(w);
- return DITEM_FAILURE;
- }
- fclose(fp);
- index_sort(&Top);
- index_initted = TRUE;
- restorescr(w);
- }
- return DITEM_SUCCESS;
-}
diff --git a/usr.sbin/sysinstall/install.c b/usr.sbin/sysinstall/install.c
deleted file mode 100644
index 6e1294530f5d..000000000000
--- a/usr.sbin/sysinstall/install.c
+++ /dev/null
@@ -1,1140 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last program in the `sysinstall' line - the next
- * generation being essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 "sysinstall.h"
-#include <ctype.h>
-#include <sys/disklabel.h>
-#include <sys/errno.h>
-#include <sys/ioctl.h>
-#include <sys/fcntl.h>
-#include <sys/wait.h>
-#include <sys/param.h>
-#define MSDOSFS
-#include <sys/mount.h>
-#include <ufs/ufs/ufsmount.h>
-#include <msdosfs/msdosfsmount.h>
-#undef MSDOSFS
-#include <sys/stat.h>
-#include <sys/sysctl.h>
-#include <unistd.h>
-#include <termios.h>
-
-static void create_termcap(void);
-static void fixit_common(void);
-
-#define TERMCAP_FILE "/usr/share/misc/termcap"
-
-static void installConfigure(void);
-
-Boolean
-checkLabels(Boolean whinge, Chunk **rdev, Chunk **sdev, Chunk **udev, Chunk **vdev)
-{
- Device **devs;
- Boolean status;
- Disk *disk;
- Chunk *c1, *c2, *rootdev, *swapdev, *usrdev, *vardev;
- int i;
-
- /* Don't allow whinging if noWarn is set */
- if (variable_get(VAR_NO_WARN))
- whinge = FALSE;
-
- status = TRUE;
- *rdev = *sdev = *udev = *vdev = rootdev = swapdev = usrdev = vardev = NULL;
-
- /* We don't need to worry about root/usr/swap if we're already multiuser */
- if (!RunningAsInit)
- return status;
-
- devs = deviceFind(NULL, DEVICE_TYPE_DISK);
- /* First verify that we have a root device */
- for (i = 0; devs[i]; i++) {
- if (!devs[i]->enabled)
- continue;
- disk = (Disk *)devs[i]->private;
- msgDebug("Scanning disk %s for root filesystem\n", disk->name);
- if (!disk->chunks)
- msgFatal("No chunk list found for %s!", disk->name);
- for (c1 = disk->chunks->part; c1; c1 = c1->next) {
- if (c1->type == freebsd) {
- for (c2 = c1->part; c2; c2 = c2->next) {
- if (c2->type == part && c2->subtype != FS_SWAP && c2->private_data) {
- if (!strcmp(((PartInfo *)c2->private_data)->mountpoint, "/")) {
- if (rootdev) {
- if (whinge)
- msgConfirm("WARNING: You have more than one root device set?!\n"
- "Using the first one found.");
- continue;
- }
- else {
- rootdev = c2;
- if (isDebug())
- msgDebug("Found rootdev at %s!\n", rootdev->name);
- }
- }
- else if (!strcmp(((PartInfo *)c2->private_data)->mountpoint, "/usr")) {
- if (usrdev) {
- if (whinge)
- msgConfirm("WARNING: You have more than one /usr filesystem.\n"
- "Using the first one found.");
- continue;
- }
- else {
- usrdev = c2;
- if (isDebug())
- msgDebug("Found usrdev at %s!\n", usrdev->name);
- }
- }
- else if (!strcmp(((PartInfo *)c2->private_data)->mountpoint, "/var")) {
- if (vardev) {
- if (whinge)
- msgConfirm("WARNING: You have more than one /var filesystem.\n"
- "Using the first one found.");
- continue;
- }
- else {
- vardev = c2;
- if (isDebug())
- msgDebug("Found vardev at %s!\n", vardev->name);
- }
- }
- }
- }
- }
- }
- }
-
- /* Now check for swap devices */
- for (i = 0; devs[i]; i++) {
- if (!devs[i]->enabled)
- continue;
- disk = (Disk *)devs[i]->private;
- msgDebug("Scanning disk %s for swap partitions\n", disk->name);
- if (!disk->chunks)
- msgFatal("No chunk list found for %s!", disk->name);
- for (c1 = disk->chunks->part; c1; c1 = c1->next) {
- if (c1->type == freebsd) {
- for (c2 = c1->part; c2; c2 = c2->next) {
- if (c2->type == part && c2->subtype == FS_SWAP && !swapdev) {
- swapdev = c2;
- if (isDebug())
- msgDebug("Found swapdev at %s!\n", swapdev->name);
- break;
- }
- }
- }
- }
- }
-
- /* Copy our values over */
- *rdev = rootdev;
- *sdev = swapdev;
- *udev = usrdev;
- *vdev = vardev;
-
- if (!rootdev && whinge) {
- msgConfirm("No root device found - you must label a partition as /\n"
- "in the label editor.");
- status = FALSE;
- }
- if (!swapdev && whinge) {
- msgConfirm("No swap devices found - you must create at least one\n"
- "swap partition.");
- status = FALSE;
- }
- return status;
-}
-
-static int
-installInitial(void)
-{
- static Boolean alreadyDone = FALSE;
- int status = DITEM_SUCCESS;
-
- if (alreadyDone)
- return DITEM_SUCCESS;
-
- if (!variable_get(DISK_LABELLED)) {
- msgConfirm("You need to assign disk labels before you can proceed with\n"
- "the installation.");
- return DITEM_FAILURE;
- }
- /* If it's labelled, assume it's also partitioned */
- if (!variable_get(DISK_PARTITIONED))
- variable_set2(DISK_PARTITIONED, "yes", 0);
-
- /* If we refuse to proceed, bail. */
- dialog_clear_norefresh();
- if (!variable_get(VAR_NO_WARN))
- if (msgYesNo(
- "Last Chance! Are you SURE you want continue the installation?\n\n"
- "If you're running this on a disk with data you wish to save\n"
- "then WE STRONGLY ENCOURAGE YOU TO MAKE PROPER BACKUPS before\n"
- "proceeding!\n\n"
- "We can take no responsibility for lost disk contents!") != 0)
- return DITEM_FAILURE;
-
- if (DITEM_STATUS(diskLabelCommit(NULL)) != DITEM_SUCCESS) {
- msgConfirm("Couldn't make filesystems properly. Aborting.");
- return DITEM_FAILURE;
- }
-
- if (!copySelf()) {
- msgConfirm("installInitial: Couldn't clone the boot floppy onto the\n"
- "root file system. Aborting!");
- return DITEM_FAILURE;
- }
-
- if (chroot("/mnt") == -1) {
- msgConfirm("installInitial: Unable to chroot to %s - this is bad!",
- "/mnt");
- return DITEM_FAILURE;
- }
-
- chdir("/");
- variable_set2(RUNNING_ON_ROOT, "yes", 0);
-
- /* Configure various files in /etc */
- if (DITEM_STATUS(configResolv(NULL)) == DITEM_FAILURE)
- status = DITEM_FAILURE;
- if (DITEM_STATUS(configFstab(NULL)) == DITEM_FAILURE)
- status = DITEM_FAILURE;
-
- /* stick a helpful shell over on the 4th VTY */
- systemCreateHoloshell();
-
- alreadyDone = TRUE;
- return status;
-}
-
-int
-installFixitHoloShell(dialogMenuItem *self)
-{
- systemCreateHoloshell();
- return DITEM_SUCCESS;
-}
-
-int
-installFixitCDROM(dialogMenuItem *self)
-{
- struct stat sb;
-
- if (!RunningAsInit)
- return DITEM_SUCCESS;
-
- variable_set2(SYSTEM_STATE, "fixit", 0);
- (void)unlink("/mnt2");
- (void)rmdir("/mnt2");
-
- while (1) {
- msgConfirm("Please insert a FreeBSD live filesystem CDROM and press return");
- if (DITEM_STATUS(mediaSetCDROM(NULL)) != DITEM_SUCCESS || !mediaDevice || !mediaDevice->init(mediaDevice)) {
- /* If we can't initialize it, it's probably not a FreeBSD CDROM so punt on it */
- mediaClose();
- if (msgYesNo("Unable to mount the CDROM - do you want to try again?") != 0)
- return DITEM_FAILURE;
- }
- else
- break;
- }
-
- /* Since the fixit code expects everything to be in /mnt2, and the CDROM mounting stuff /dist, do
- * a little kludge dance here..
- */
- if (symlink("/dist", "/mnt2")) {
- msgConfirm("Unable to symlink /mnt2 to the CDROM mount point. Please report this\n"
- "unexpected failure to freebsd-bugs@FreeBSD.org.");
- return DITEM_FAILURE;
- }
-
- /*
- * If /tmp points to /mnt2/tmp from a previous fixit floppy session, it's
- * not very good for us if we point it to the CDROM now. Rather make it
- * a directory in the root MFS then. Experienced admins will still be
- * able to mount their disk's /tmp over this if they need.
- */
- if (lstat("/tmp", &sb) == 0 && (sb.st_mode & S_IFMT) == S_IFLNK)
- (void)unlink("/tmp");
- Mkdir("/tmp");
-
- /*
- * Since setuid binaries ignore LD_LIBRARY_PATH, we indeed need the
- * ld.so.hints file. Fortunately, it's fairly small (~ 3 KB).
- */
- if (!file_readable("/var/run/ld.so.hints")) {
- Mkdir("/var/run");
- if (vsystem("/mnt2/sbin/ldconfig -s /mnt2/usr/lib")) {
- msgConfirm("Warning: ldconfig could not create the ld.so hints file.\n"
- "Dynamic executables from the CDROM likely won't work.");
- }
- }
-
- /* Yet more iggly hardcoded pathnames. */
- Mkdir("/usr/libexec");
- if (!file_readable("/usr/libexec/ld.so") && file_readable("/mnt2/usr/libexec/ld.so")) {
- if (symlink("/mnt2/usr/libexec/ld.so", "/usr/libexec/ld.so"))
- msgDebug("Couldn't link to ld.so - not necessarily a problem for ELF\n");
- }
- if (!file_readable("/usr/libexec/ld-elf.so.1")) {
- if (symlink("/mnt2/usr/libexec/ld-elf.so.1", "/usr/libexec/ld-elf.so.1")) {
- msgConfirm("Warning: could not create the symlink for ld-elf.so.1\n"
- "Dynamic executables from the CDROM likely won't work.");
- }
- }
- /* optional nicety */
- if (!file_readable("/usr/bin/vi"))
- symlink("/mnt2/usr/bin/vi", "/usr/bin/vi");
- fixit_common();
- mediaClose();
- msgConfirm("Please remove the FreeBSD fixit CDROM now.");
- return DITEM_SUCCESS;
-}
-
-int
-installFixitFloppy(dialogMenuItem *self)
-{
- struct ufs_args args;
- extern char *distWanted;
-
- if (!RunningAsInit)
- return DITEM_SUCCESS;
-
- /* Try to open the floppy drive */
- if (DITEM_STATUS(mediaSetFloppy(NULL)) == DITEM_FAILURE || !mediaDevice) {
- msgConfirm("Unable to set media device to floppy.");
- mediaClose();
- return DITEM_FAILURE;
- }
-
- memset(&args, 0, sizeof(args));
- args.fspec = mediaDevice->devname;
- mediaDevice->private = "/mnt2";
- distWanted = NULL;
- Mkdir("/mnt2");
-
- variable_set2(SYSTEM_STATE, "fixit", 0);
-
- while (1) {
- if (!mediaDevice->init(mediaDevice)) {
- if (msgYesNo("The attempt to mount the fixit floppy failed, bad floppy\n"
- "or unclean filesystem. Do you want to try again?"))
- return DITEM_FAILURE;
- }
- else
- break;
- }
- if (!directory_exists("/tmp"))
- (void)symlink("/mnt2/tmp", "/tmp");
- fixit_common();
- mediaClose();
- msgConfirm("Please remove the fixit floppy now.");
- return DITEM_SUCCESS;
-}
-
-/*
- * The common code for both fixit variants.
- */
-static void
-fixit_common(void)
-{
- pid_t child;
- int waitstatus;
-
- if (!directory_exists("/var/tmp/vi.recover")) {
- if (DITEM_STATUS(Mkdir("/var/tmp/vi.recover")) != DITEM_SUCCESS) {
- msgConfirm("Warning: Was unable to create a /var/tmp/vi.recover directory.\n"
- "vi will kvetch and moan about it as a result but should still\n"
- "be essentially usable.");
- }
- }
- if (!directory_exists("/bin"))
- (void)Mkdir("/bin");
- (void)symlink("/stand/sh", "/bin/sh");
- /* Link the /etc/ files */
- if (DITEM_STATUS(Mkdir("/etc")) != DITEM_SUCCESS)
- msgConfirm("Unable to create an /etc directory! Things are weird on this floppy..");
- else if ((symlink("/mnt2/etc/spwd.db", "/etc/spwd.db") == -1 && errno != EEXIST) ||
- (symlink("/mnt2/etc/protocols", "/etc/protocols") == -1 && errno != EEXIST) ||
- (symlink("/mnt2/etc/services", "/etc/services") == -1 && errno != EEXIST))
- msgConfirm("Couldn't symlink the /etc/ files! I'm not sure I like this..");
- if (!file_readable(TERMCAP_FILE))
- create_termcap();
- if (!(child = fork())) {
- int i, fd;
- struct termios foo;
- extern int login_tty(int);
-
- ioctl(0, TIOCNOTTY, NULL);
- for (i = getdtablesize(); i >= 0; --i)
- close(i);
- fd = open("/dev/ttyv3", O_RDWR);
- ioctl(0, TIOCSCTTY, &fd);
- dup2(0, 1);
- dup2(0, 2);
- DebugFD = 2;
- if (login_tty(fd) == -1)
- msgDebug("fixit: I can't set the controlling terminal.\n");
-
- signal(SIGTTOU, SIG_IGN);
- if (tcgetattr(0, &foo) != -1) {
- foo.c_cc[VERASE] = '\010';
- if (tcsetattr(0, TCSANOW, &foo) == -1)
- msgDebug("fixit shell: Unable to set erase character.\n");
- }
- else
- msgDebug("fixit shell: Unable to get terminal attributes!\n");
- setenv("PATH", "/bin:/sbin:/usr/bin:/usr/sbin:/stand:"
- "/mnt2/stand:/mnt2/bin:/mnt2/sbin:/mnt2/usr/bin:/mnt2/usr/sbin", 1);
- /* use the .profile from the fixit medium */
- setenv("HOME", "/mnt2", 1);
- chdir("/mnt2");
- execlp("sh", "-sh", 0);
- msgDebug("fixit shell: Failed to execute shell!\n");
- _exit(1);;
- }
- else {
- dialog_clear_norefresh();
- msgNotify("Waiting for fixit shell to exit. Go to VTY4 now by\n"
- "typing ALT-F4. When you are done, type ``exit'' to exit\n"
- "the fixit shell and be returned here.");
- (void)waitpid(child, &waitstatus, 0);
- }
- dialog_clear();
-}
-
-
-int
-installExpress(dialogMenuItem *self)
-{
- int i;
-
- dialog_clear_norefresh();
- variable_set2(SYSTEM_STATE, "express", 0);
-#ifndef __alpha__
- if (DITEM_STATUS((i = diskPartitionEditor(self))) == DITEM_FAILURE)
- return i;
-#endif
-
- if (DITEM_STATUS((i = diskLabelEditor(self))) == DITEM_FAILURE)
- return i;
-
- if (DITEM_STATUS((i = installCommit(self))) == DITEM_SUCCESS) {
- i |= DITEM_LEAVE_MENU;
- /* Give user the option of one last configuration spree */
- installConfigure();
- }
- return i;
-}
-
-/* Standard mode installation */
-int
-installStandard(dialogMenuItem *self)
-{
- int i, tries = 0;
- Device **devs;
-
- variable_set2(SYSTEM_STATE, "standard", 0);
- dialog_clear_norefresh();
-#ifndef __alpha__
- msgConfirm("In the next menu, you will need to set up a DOS-style (\"fdisk\") partitioning\n"
- "scheme for your hard disk. If you simply wish to devote all disk space\n"
- "to FreeBSD (overwriting anything else that might be on the disk(s) selected)\n"
- "then use the (A)ll command to select the default partitioning scheme followed\n"
- "by a (Q)uit. If you wish to allocate only free space to FreeBSD, move to a\n"
- "partition marked \"unused\" and use the (C)reate command.");
-
-nodisks:
- if (DITEM_STATUS(diskPartitionEditor(self)) == DITEM_FAILURE)
- return DITEM_FAILURE;
-
- if (diskGetSelectCount(&devs) <= 0 && tries < 3) {
- msgConfirm("You need to select some disks to operate on! Be sure to use SPACE\n"
- "instead of RETURN in the disk selection menu when selecting a disk.");
- ++tries;
- goto nodisks;
- }
-#endif
-
-#ifdef __alpha__
- msgConfirm("Now you need to create BSD partitions on the disk which you are\n"
- "installing to. If you have a reasonable amount of disk space (200MB or more)\n"
- "and don't have any special requirements, simply use the (A)uto command to\n"
- "allocate space automatically. If you have more specific needs or just don't\n"
- "care for the layout chosen by (A)uto, press F1 for more information on\n"
- "manual layout.");
-#else
- msgConfirm("Now you need to create BSD partitions inside of the fdisk partition(s)\n"
- "just created. If you have a reasonable amount of disk space (200MB or more)\n"
- "and don't have any special requirements, simply use the (A)uto command to\n"
- "allocate space automatically. If you have more specific needs or just don't\n"
- "care for the layout chosen by (A)uto, press F1 for more information on\n"
- "manual layout.");
-#endif
-
- if (DITEM_STATUS(diskLabelEditor(self)) == DITEM_FAILURE)
- return DITEM_FAILURE;
-
- if (DITEM_STATUS((i = installCommit(self))) == DITEM_FAILURE) {
- dialog_clear();
- msgConfirm("Installation completed with some errors. You may wish to\n"
- "scroll through the debugging messages on VTY1 with the\n"
- "scroll-lock feature. You can also choose \"No\" at the next\n"
- "prompt and go back into the installation menus to try and retry\n"
- "whichever operations have failed.");
- return i;
-
- }
- else {
- dialog_clear();
- msgConfirm("Congratulations! You now have FreeBSD installed on your system.\n\n"
- "We will now move on to the final configuration questions.\n"
- "For any option you do not wish to configure, simply select\n"
- "No.\n\n"
- "If you wish to re-enter this utility after the system is up, you\n"
- "may do so by typing: /stand/sysinstall.");
- }
- if (mediaDevice->type != DEVICE_TYPE_FTP && mediaDevice->type != DEVICE_TYPE_NFS) {
- if (!msgYesNo("Would you like to configure any Ethernet or SLIP/PPP network devices?")) {
- Device *tmp = tcpDeviceSelect();
-
- if (tmp && !((DevInfo *)tmp->private)->use_dhcp && !msgYesNo("Would you like to bring the %s interface up right now?", tmp->name))
- if (!tmp->init(tmp))
- msgConfirm("Initialization of %s device failed.", tmp->name);
- }
- dialog_clear_norefresh();
- }
-
- if (msgYesNo("Will this machine be a leaf node (e.g. will not forward packets)\n"
- "between interfaces)?"))
- variable_set2("gateway_enable", "YES", 1);
-
- if (msgYesNo("Do you want to grant only normal users FTP access to this\n"
- "host (e.g. no anonymous FTP connections)?"))
- configAnonFTP(self);
-
- if (!msgYesNo("Do you want to configure this machine as an NFS server?"))
- configNFSServer(self);
-
- dialog_clear_norefresh();
- if (!msgYesNo("Do you want to configure this machine as an NFS client?"))
- variable_set2("nfs_client_enable", "YES", 1);
-
- if (!msgYesNo("Would you like to customize your system console settings?"))
- dmenuOpenSimple(&MenuSyscons, FALSE);
-
- dialog_clear_norefresh();
- if (!msgYesNo("Would you like to set this machine's time zone now?"))
- systemExecute("tzsetup");
-
-#ifdef __i386__
- dialog_clear_norefresh();
- if (!msgYesNo("Would you like to enable Linux binary compatibility?"))
- (void)configLinux(self);
-#endif
-
- dialog_clear();
- if (USAResident) {
- if (!msgYesNo("I see that you are \"USA_RESIDENT\" according to your earlier\n"
- "response to the CRYPTO distribution dialog. Do you want to try and\n"
- "load the rsaref package from the current media? Some restrictions on\n"
- "usage may apply, so be sure to read the package installation output!")) {
- dialog_clear();
- if (DITEM_STATUS(package_add("rsaref")) != DITEM_SUCCESS) {
- msgConfirm("Unable to find an rsaref package on the current intallation media.\n"
- "You may wish to switch media types and try again, perhaps\n"
- "from an FTP server which carries this package.");
- }
- dialog_clear();
- }
- }
- else {
- if (!msgYesNo("I see that you are not \"USA_RESIDENT\" according to your earlier\n"
- "response to the CRYPTO distribution dialog. Do you want to try and\n"
- "load the rsaintl package from the current media?")) {
- if (DITEM_STATUS(package_add("rsaintl")) != DITEM_SUCCESS) {
- msgConfirm("Unable to find an rsaintl package on the current intallation media.\n"
- "You may wish to switch media types and try again, perhaps\n"
- "from an FTP server which carries this package.");
- }
- }
- }
-
- dialog_clear_norefresh();
- if (!msgYesNo("Does this system have a mouse attached to it?"))
- dmenuOpenSimple(&MenuMouse, FALSE);
-
- /* Now would be a good time to checkpoint the configuration data */
- configRC_conf();
- sync();
-
- if (directory_exists("/usr/X11R6")) {
- dialog_clear_norefresh();
- if (!msgYesNo("Would you like to configure your X server at this time?"))
- (void)configXSetup(self);
- }
-
- dialog_clear_norefresh();
- if (!msgYesNo("The FreeBSD package collection is a collection of thousands of ready-to-run\n"
- "applications, from text editors to games to WEB servers and more. Would you\n"
- "like to browse the collection now?")) {
- (void)configPackages(self);
- }
-
- if (!msgYesNo("Would you like to add any initial user accounts to the system?\n"
- "Adding at least one account for yourself at this stage is suggested\n"
- "since working as the \"root\" user is dangerous (it is easy to do\n"
- "things which adversely affect the entire system)."))
- (void)configUsers(self);
-
- msgConfirm("Now you must set the system manager's password.\n"
- "This is the password you'll use to log in as \"root\".");
- if (!systemExecute("passwd root"))
- variable_set2("root_password", "YES", 0);
-
- /* XXX Put whatever other nice configuration questions you'd like to ask the user here XXX */
-
- /* Give user the option of one last configuration spree */
- dialog_clear_norefresh();
- installConfigure();
- return DITEM_LEAVE_MENU;
-}
-
-/* The version of commit we call from the Install Custom menu */
-int
-installCustomCommit(dialogMenuItem *self)
-{
- int i;
-
- i = installCommit(self);
- if (DITEM_STATUS(i) == DITEM_SUCCESS) {
- /* Give user the option of one last configuration spree */
- installConfigure();
- return i;
- }
- else
- msgConfirm("The commit operation completed with errors. Not\n"
- "updating /etc files.");
- return i;
-}
-
-/*
- * What happens when we finally decide to going ahead with the installation.
- *
- * This is broken into multiple stages so that the user can do a full
- * installation but come back here again to load more distributions,
- * perhaps from a different media type. This would allow, for
- * example, the user to load the majority of the system from CDROM and
- * then use ftp to load just the CRYPTO dist.
- */
-int
-installCommit(dialogMenuItem *self)
-{
- int i;
- char *str;
-
- dialog_clear_norefresh();
- if (!Dists)
- distConfig(NULL);
-
- if (!Dists)
- if (!dmenuOpenSimple(&MenuDistributions, FALSE) && !Dists)
- return DITEM_FAILURE;
-
- if (!mediaVerify())
- return DITEM_FAILURE;
-
- str = variable_get(SYSTEM_STATE);
- if (isDebug())
- msgDebug("installCommit: System state is `%s'\n", str);
-
- /* Installation stuff we wouldn't do to a running system */
- if (RunningAsInit && DITEM_STATUS((i = installInitial())) == DITEM_FAILURE)
- return i;
-
-try_media:
- if (!mediaDevice->init(mediaDevice)) {
- if (!msgYesNo("Unable to initialize selected media. Would you like to\n"
- "adjust your media configuration and try again?")) {
- mediaDevice = NULL;
- if (!mediaVerify())
- return DITEM_FAILURE;
- else
- goto try_media;
- }
- else
- return DITEM_FAILURE;
- }
-
- /* Now go get it all */
- i = distExtractAll(self);
-
- /* When running as init, *now* it's safe to grab the rc.foo vars */
- installEnvironment();
-
- variable_set2(SYSTEM_STATE, DITEM_STATUS(i) == DITEM_FAILURE ? "error-install" : "full-install", 0);
-
- return i;
-}
-
-static void
-installConfigure(void)
-{
- /* Final menu of last resort */
- if (!msgYesNo("Visit the general configuration menu for a chance to set\n"
- "any last options?"))
- dmenuOpenSimple(&MenuConfigure, FALSE);
- configRC_conf();
- sync();
-}
-
-int
-installFixupBin(dialogMenuItem *self)
-{
- Device **devs;
- char *cp;
- int i;
- FILE *fp;
- int kstat = 1;
-
- /* All of this is done only as init, just to be safe */
- if (RunningAsInit) {
- /* Fix up kernel first */
- if (!file_readable("/kernel")) {
- char *generic_kernel = "/kernel.GENERIC";
- if (file_readable(generic_kernel)) {
- if (vsystem("cp -p %s /kernel", generic_kernel)) {
- msgConfirm("Unable to copy /kernel into place!");
- return DITEM_FAILURE;
- }
-#ifndef __alpha__
- /* Snapshot any boot -c changes back to the new kernel */
- cp = variable_get(VAR_KGET);
- if (cp && (*cp == 'Y' || *cp == 'y')) {
- if ((kstat = kget("/boot/kernel.conf")) != NULL) {
- msgConfirm("Kernel copied OK, but unable to save boot -c changes\n"
- "to it. See the debug screen (ALT-F2) for details.");
- }
- }
- if ((fp = fopen("/boot/loader.conf", "a")) != NULL) {
- fprintf(fp, "# -- sysinstall generated deltas -- #\n");
- if (!kstat)
- fprintf(fp, "userconfig_script_load=\"YES\"\n");
- if (!OnVTY)
- fprintf(fp, "console=\"comconsole\"\n");
- fclose(fp);
- }
-#endif
- }
- else {
- msgConfirm("Can't find a kernel image to link to on the root file system!\n"
- "You're going to have a hard time getting this system to\n"
- "boot from the hard disk, I'm afraid!");
- return DITEM_FAILURE;
- }
- }
-
- /* BOGON #1: Resurrect /dev after bin distribution screws it up */
- dialog_clear_norefresh();
- msgNotify("Remaking all devices.. Please wait!");
- if (vsystem("cd /dev; sh MAKEDEV all")) {
- msgConfirm("MAKEDEV returned non-zero status");
- return DITEM_FAILURE | DITEM_RESTORE;
- }
-
- dialog_clear_norefresh();
- msgNotify("Resurrecting /dev entries for slices..");
- devs = deviceFind(NULL, DEVICE_TYPE_DISK);
- if (!devs)
- msgFatal("Couldn't get a disk device list!");
-
- /* Resurrect the slices that the former clobbered */
- for (i = 0; devs[i]; i++) {
- Disk *disk = (Disk *)devs[i]->private;
- Chunk *c1;
-
- if (!devs[i]->enabled)
- continue;
- if (!disk->chunks)
- msgFatal("No chunk list found for %s!", disk->name);
- for (c1 = disk->chunks->part; c1; c1 = c1->next) {
- if (c1->type == freebsd) {
- dialog_clear_norefresh();
- msgNotify("Making slice entries for %s", c1->name);
- if (vsystem("cd /dev; sh MAKEDEV %sh", c1->name)) {
- msgConfirm("Unable to make slice entries for %s!", c1->name);
- return DITEM_FAILURE | DITEM_RESTORE;
- }
- }
- }
- }
-
- /* BOGON #2: We leave /etc in a bad state */
- chmod("/etc", 0755);
-
- /* BOGON #3: No /var/db/mountdtab complains */
- Mkdir("/var/db");
- creat("/var/db/mountdtab", 0644);
-
- /* BOGON #4: /compat created by default in root fs */
- Mkdir("/usr/compat");
- vsystem("ln -s /usr/compat /compat");
-
- /* BOGON #5: aliases database not build for bin */
- vsystem("newaliases");
-
- /* Now run all the mtree stuff to fix things up */
- vsystem("mtree -deU -f /etc/mtree/BSD.root.dist -p /");
- vsystem("mtree -deU -f /etc/mtree/BSD.var.dist -p /var");
- vsystem("mtree -deU -f /etc/mtree/BSD.usr.dist -p /usr");
-
- /* Do all the last ugly work-arounds here */
- }
- return DITEM_SUCCESS | DITEM_RESTORE;
-}
-
-#ifdef X_AS_PKG
-int
-installX11package(dialogMenuItem *self)
-{
- WINDOW *w = savescr();
- int i;
-
- dialog_clear_norefresh();
- msgNotify("Installing XFree86 package...");
- i = package_add("XFree86");
- restorescr(w);
- return i;
-}
-#endif
-
-/* Fix side-effects from the the XFree86 installation */
-int
-installFixupXFree(dialogMenuItem *self)
-{
- /* BOGON #1: XFree86 requires various specialized fixups */
- if (directory_exists("/usr/X11R6")) {
- dialog_clear_norefresh();
- msgNotify("Fixing permissions in XFree86 tree..");
- vsystem("chmod -R a+r /usr/X11R6");
- vsystem("find /usr/X11R6 -type d | xargs chmod a+x");
-
-#ifndef X_AS_PKG
- /* Also do bogus minimal package registration so ports don't whine */
- if (file_readable("/usr/X11R6/lib/X11/pkgreg.tar.gz")) {
- dialog_clear_norefresh();
- msgNotify("Installing package metainfo..");
- vsystem("tar xpzf /usr/X11R6/lib/X11/pkgreg.tar.gz -C / && rm /usr/X11R6/lib/X11/pkgreg.tar.gz");
- }
-#endif
- }
- return DITEM_SUCCESS | DITEM_RESTORE;
-}
-
-/* Go newfs and/or mount all the filesystems we've been asked to */
-int
-installFilesystems(dialogMenuItem *self)
-{
- int i;
- Disk *disk;
- Chunk *c1, *c2, *rootdev, *swapdev, *usrdev, *vardev;
- Device **devs;
- PartInfo *root;
- char dname[80];
- extern int MakeDevChunk(Chunk *c, char *n);
- Boolean upgrade = FALSE;
-
- /* If we've already done this, bail out */
- if (!variable_cmp(DISK_LABELLED, "written"))
- return DITEM_SUCCESS;
-
- upgrade = !variable_cmp(SYSTEM_STATE, "upgrade");
- if (!checkLabels(TRUE, &rootdev, &swapdev, &usrdev, &vardev))
- return DITEM_FAILURE;
-
- if (rootdev)
- root = (PartInfo *)rootdev->private_data;
- else
- root = NULL;
-
- command_clear();
- if (swapdev && RunningAsInit) {
- /* As the very first thing, try to get ourselves some swap space */
- sprintf(dname, "/dev/%s", swapdev->name);
- if (!Fake && (!MakeDevChunk(swapdev, "/dev") || !file_readable(dname))) {
- msgConfirm("Unable to make device node for %s in /dev!\n"
- "The creation of filesystems will be aborted.", dname);
- return DITEM_FAILURE;
- }
-
- if (!Fake) {
- if (!swapon(dname)) {
- dialog_clear_norefresh();
- msgNotify("Added %s as initial swap device", dname);
- }
- else {
- msgConfirm("WARNING! Unable to swap to %s: %s\n"
- "This may cause the installation to fail at some point\n"
- "if you don't have a lot of memory.", dname, strerror(errno));
- }
- }
- }
-
- if (rootdev && RunningAsInit) {
- /* Next, create and/or mount the root device */
- sprintf(dname, "/dev/r%s", rootdev->name);
- if (!Fake && (!MakeDevChunk(rootdev, "/dev") || !file_readable(dname))) {
- msgConfirm("Unable to make device node for %s in /dev!\n"
- "The creation of filesystems will be aborted.", dname);
- return DITEM_FAILURE | DITEM_RESTORE;
- }
- if (strcmp(root->mountpoint, "/"))
- msgConfirm("Warning: %s is marked as a root partition but is mounted on %s", rootdev->name, root->mountpoint);
-
- if (root->newfs && (!upgrade || !msgYesNo("You are upgrading - are you SURE you want to newfs the root partition?"))) {
- int i;
-
- dialog_clear_norefresh();
- msgNotify("Making a new root filesystem on %s", dname);
- i = vsystem("%s %s", root->newfs_cmd, dname);
- if (i) {
- msgConfirm("Unable to make new root filesystem on %s!\n"
- "Command returned status %d", dname, i);
- return DITEM_FAILURE | DITEM_RESTORE;
- }
- }
- else {
- if (!upgrade) {
- msgConfirm("Warning: Using existing root partition. It will be assumed\n"
- "that you have the appropriate device entries already in /dev.");
- }
- dialog_clear_norefresh();
- msgNotify("Checking integrity of existing %s filesystem.", dname);
- i = vsystem("fsck -y %s", dname);
- if (i)
- msgConfirm("Warning: fsck returned status of %d for %s.\n"
- "This partition may be unsafe to use.", i, dname);
- }
-
- /* Switch to block device */
- sprintf(dname, "/dev/%s", rootdev->name);
- if (Mount("/mnt", dname)) {
- msgConfirm("Unable to mount the root file system on %s! Giving up.", dname);
- return DITEM_FAILURE | DITEM_RESTORE;
- }
- }
-
- /* Now buzz through the rest of the partitions and mount them too */
- devs = deviceFind(NULL, DEVICE_TYPE_DISK);
- for (i = 0; devs[i]; i++) {
- if (!devs[i]->enabled)
- continue;
-
- disk = (Disk *)devs[i]->private;
- if (!disk->chunks) {
- msgConfirm("No chunk list found for %s!", disk->name);
- return DITEM_FAILURE | DITEM_RESTORE;
- }
- if (RunningAsInit && root && (root->newfs || upgrade)) {
- Mkdir("/mnt/dev");
- if (!Fake)
- MakeDevDisk(disk, "/mnt/dev");
- }
- else if (!RunningAsInit && !Fake)
- MakeDevDisk(disk, "/dev");
-
- for (c1 = disk->chunks->part; c1; c1 = c1->next) {
- if (c1->type == freebsd) {
- for (c2 = c1->part; c2; c2 = c2->next) {
- if (c2->type == part && c2->subtype != FS_SWAP && c2->private_data) {
- PartInfo *tmp = (PartInfo *)c2->private_data;
-
- /* Already did root */
- if (c2 == rootdev)
- continue;
-
- if (tmp->newfs && (!upgrade || !msgYesNo("You are upgrading - are you SURE you want to newfs /dev/%s?", c2->name)))
- command_shell_add(tmp->mountpoint, "%s %s/dev/r%s", tmp->newfs_cmd, RunningAsInit ? "/mnt" : "", c2->name);
- else
- command_shell_add(tmp->mountpoint, "fsck -y %s/dev/r%s", RunningAsInit ? "/mnt" : "", c2->name);
- command_func_add(tmp->mountpoint, Mount, c2->name);
- }
- else if (c2->type == part && c2->subtype == FS_SWAP) {
- char fname[80];
- int i;
-
- if (c2 == swapdev)
- continue;
- sprintf(fname, "%s/dev/%s", RunningAsInit ? "/mnt" : "", c2->name);
- i = (Fake || swapon(fname));
- if (!i) {
- dialog_clear_norefresh();
- msgNotify("Added %s as an additional swap device", fname);
- }
- else {
- msgConfirm("Unable to add %s as a swap device: %s", fname, strerror(errno));
- }
- }
- }
- }
- else if (c1->type == fat && c1->private_data && (root->newfs || upgrade)) {
- char name[FILENAME_MAX];
-
- sprintf(name, "%s/%s", RunningAsInit ? "/mnt" : "", ((PartInfo *)c1->private_data)->mountpoint);
- Mkdir(name);
- }
- }
- }
-
- if (RunningAsInit) {
- dialog_clear_norefresh();
- msgNotify("Copying initial device files..");
- /* Copy the boot floppy's dev files */
- if ((root->newfs || upgrade) && vsystem("find -x /dev | cpio %s -pdum /mnt", cpioVerbosity())) {
- msgConfirm("Couldn't clone the /dev files!");
- return DITEM_FAILURE | DITEM_RESTORE;
- }
- }
-
- command_sort();
- command_execute();
- dialog_clear_norefresh();
- return DITEM_SUCCESS | DITEM_RESTORE;
-}
-
-static char *
-getRelname(void)
-{
- static char buf[64];
- int sz = (sizeof buf) - 1;
-
- if (sysctlbyname("kern.osrelease", buf, &sz, NULL, 0) != -1) {
- buf[sz] = '\0';
- return buf;
- }
- else
- return "<unknown>";
-}
-
-/* Initialize various user-settable values to their defaults */
-int
-installVarDefaults(dialogMenuItem *self)
-{
- char *cp;
-
- /* Set default startup options */
- variable_set2(VAR_RELNAME, getRelname(), 0);
- variable_set2(VAR_CPIO_VERBOSITY, "high", 0);
- variable_set2(VAR_KGET, "YES", 0);
- variable_set2(VAR_TAPE_BLOCKSIZE, DEFAULT_TAPE_BLOCKSIZE, 0);
- variable_set2(VAR_INSTALL_ROOT, "/", 0);
- variable_set2(VAR_INSTALL_CFG, "install.cfg", 0);
- variable_set2(VAR_TRY_DHCP, "NO", 0); /* For now */
- cp = getenv("EDITOR");
- if (!cp)
- cp = "/usr/bin/ee";
- variable_set2(VAR_EDITOR, cp, 0);
- variable_set2(VAR_FTP_USER, "ftp", 0);
- variable_set2(VAR_BROWSER_PACKAGE, "lynx", 0);
- variable_set2(VAR_BROWSER_BINARY, "/usr/local/bin/lynx", 0);
- variable_set2(VAR_FTP_STATE, "passive", 0);
- variable_set2(VAR_NFS_SECURE, "NO", -1);
- variable_set2(VAR_PKG_TMPDIR, "/usr/tmp", 0);
- variable_set2(VAR_MEDIA_TIMEOUT, itoa(MEDIA_TIMEOUT), 0);
- if (getpid() != 1)
- variable_set2(SYSTEM_STATE, "update", 0);
- else
- variable_set2(SYSTEM_STATE, "init", 0);
- variable_set2(VAR_NEWFS_ARGS, "-b 8192 -f 1024", 0);
- return DITEM_SUCCESS;
-}
-
-/* Load the environment up from various system configuration files */
-void
-installEnvironment(void)
-{
- configEnvironmentRC_conf();
- if (file_readable("/etc/resolv.conf"))
- configEnvironmentResolv("/etc/resolv.conf");
- configMake_conf("/etc/make.conf");
-}
-
-/* Copy the boot floppy contents into /stand */
-Boolean
-copySelf(void)
-{
- int i;
-
- if (file_readable("/boot.help"))
- vsystem("cp /boot.help /mnt");
- msgWeHaveOutput("Copying the boot floppy to /stand on root filesystem");
- i = vsystem("find -x /stand | cpio %s -pdum /mnt", cpioVerbosity());
- if (i) {
- msgConfirm("Copy returned error status of %d!", i);
- return FALSE;
- }
-
- /* Copy the /etc files into their rightful place */
- if (vsystem("cd /mnt/stand; find etc | cpio %s -pdum /mnt", cpioVerbosity())) {
- msgConfirm("Couldn't copy up the /etc files!");
- return TRUE;
- }
- return TRUE;
-}
-
-static void
-create_termcap(void)
-{
- FILE *fp;
-
- const char *caps[] = {
- termcap_vt100, termcap_cons25, termcap_cons25_m, termcap_cons25r,
- termcap_cons25r_m, termcap_cons25l1, termcap_cons25l1_m, NULL,
- };
- const char **cp;
-
- if (!file_readable(TERMCAP_FILE)) {
- Mkdir("/usr/share/misc");
- fp = fopen(TERMCAP_FILE, "w");
- if (!fp) {
- msgConfirm("Unable to initialize termcap file. Some screen-oriented\nutilities may not work.");
- return;
- }
- cp = caps;
- while (*cp)
- fprintf(fp, "%s\n", *(cp++));
- fclose(fp);
- }
-}
diff --git a/usr.sbin/sysinstall/install.cfg b/usr.sbin/sysinstall/install.cfg
deleted file mode 100644
index 26605477dc2d..000000000000
--- a/usr.sbin/sysinstall/install.cfg
+++ /dev/null
@@ -1,96 +0,0 @@
-# This is the installation configuration file for my test machine,
-# crate.cdrom.com.
-# It is included here merely as a sort-of-documented example.
-
-# Turn on extra debugging.
-debug=yes
-
-################################
-# My host specific data
-hostname=crate.cdrom.com
-domainname=cdrom.com
-nameserver=204.216.27.3
-defaultrouter=204.216.27.228
-ipaddr=204.216.27.230
-netmask=255.255.255.240
-################################
-
-################################
-# Which installation device to use - ftp is pointed directly at my local
-# machine and the installation device is my WD8013 ethernet interface.
-ftp=ftp://time.cdrom.com/pub
-netDev=ed0
-mediaSetFTP
-################################
-
-################################
-# Select which distributions we want.
-dists=bin doc manpages info compat21 des src sbase ssys
-distSetCustom
-################################
-
-################################
-# Now set the parameters for the partition editor on ad0. Set to use the
-# disk exclusively (could also be "all" to use the whole disk but
-# respecting the MBR or "free" to use only unallocated space for FreeBSD).
-disk=ad0
-partition=exclusive
-diskPartitionEditor
-
-# Uncomment this instead to use only the free space and install boot manager.
-#partition=free
-#bootManager=booteasy
-#diskPartitionEditor
-################################
-
-################################
-
-# This assumes that slice 1 is a DOS partition and mounts it as /dos,
-# which is the case on my laptop.
-#
-# All sizes are expressed in 512 byte blocks!
-
-# A 20MB root partition
-ad0s1-1=ufs 40960 /
-# And a 20MB swap partition
-ad0s1-2=swap 40960 none
-# Followed by a /usr partition using all remaining space (size 0 = free space)
-ad0s1-3=ufs 0 /usr
-# Let's do it!
-diskLabelEditor
-
-################################
-
-################################
-# Now partition the 2nd disk.
-disk=ad1
-partition=exclusive
-diskPartitionEditor
-
-ad1s1-1=ufs 40960 /var
-ad1s1-2=ufs 0 /usr/src
-diskLabelEditor
-################################
-
-################################
-# And the 3rd.
-disk=da0
-partition=exclusive
-diskPartitionEditor
-
-da0s1-1=swap 40960 none
-da0s1-2=ufs 0 /tmp
-diskLabelEditor
-################################
-
-
-# OK, everything is set. Do it!
-installCommit
-
-# Install some packages at the end.
-package=bash-1.14.7
-packageAdd
-package=ncftp-2.4.2
-packageAdd
-package=tcsh-6.07.02
-packageAdd
diff --git a/usr.sbin/sysinstall/installUpgrade.c b/usr.sbin/sysinstall/installUpgrade.c
deleted file mode 100644
index 1c70020ee811..000000000000
--- a/usr.sbin/sysinstall/installUpgrade.c
+++ /dev/null
@@ -1,492 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last program in the `sysinstall' line - the next
- * generation being essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 "sysinstall.h"
-#include <sys/disklabel.h>
-#include <sys/errno.h>
-#include <sys/ioctl.h>
-#include <sys/fcntl.h>
-#include <sys/wait.h>
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <sys/mount.h>
-
-static int installUpgradeNonInteractive(dialogMenuItem *self);
-
-typedef struct _hitList {
- enum { JUST_COPY, CALL_HANDLER } action ;
- char *name;
- Boolean optional;
- void (*handler)(struct _hitList *self);
-} HitList;
-
-/* These are the only meaningful files I know about */
-static HitList etc_files [] = {
- { JUST_COPY, "Xaccel.ini", TRUE, NULL },
- { JUST_COPY, "XF86Config", TRUE, NULL },
- { JUST_COPY, "adduser.conf", TRUE, NULL },
- { JUST_COPY, "aliases", TRUE, NULL },
- { JUST_COPY, "aliases.db", TRUE, NULL },
- { JUST_COPY, "amd.map", TRUE, NULL },
- { JUST_COPY, "auth.conf", TRUE, NULL },
- { JUST_COPY, "crontab", TRUE, NULL },
- { JUST_COPY, "csh.cshrc", TRUE, NULL },
- { JUST_COPY, "csh.login", TRUE, NULL },
- { JUST_COPY, "csh.logout", TRUE, NULL },
- { JUST_COPY, "cvsupfile", TRUE, NULL },
- { JUST_COPY, "disktab", TRUE, NULL },
- { JUST_COPY, "dm.conf", TRUE, NULL },
- { JUST_COPY, "dumpdates", TRUE, NULL },
- { JUST_COPY, "exports", TRUE, NULL },
- { JUST_COPY, "fbtab", TRUE, NULL },
- { JUST_COPY, "fstab", FALSE, NULL },
- { JUST_COPY, "ftpusers", TRUE, NULL },
- { JUST_COPY, "gettytab", TRUE, NULL },
- { JUST_COPY, "gnats", TRUE, NULL },
- { JUST_COPY, "group", FALSE, NULL },
- { JUST_COPY, "host.conf", TRUE, NULL },
- { JUST_COPY, "hosts", TRUE, NULL },
- { JUST_COPY, "hosts.equiv", TRUE, NULL },
- { JUST_COPY, "hosts.lpd", TRUE, NULL },
- { JUST_COPY, "inetd.conf", TRUE, NULL },
- { JUST_COPY, "kerberosIV", TRUE, NULL },
- { JUST_COPY, "localtime", TRUE, NULL },
- { JUST_COPY, "login.access", TRUE, NULL },
- { JUST_COPY, "login.conf", TRUE, NULL },
- { JUST_COPY, "mail.rc", TRUE, NULL },
- { JUST_COPY, "make.conf", TRUE, NULL },
- { JUST_COPY, "manpath.config", TRUE, NULL },
- { JUST_COPY, "master.passwd", FALSE, NULL },
- { JUST_COPY, "modems", TRUE, NULL },
- { JUST_COPY, "motd", TRUE, NULL },
- { JUST_COPY, "namedb", TRUE, NULL },
- { JUST_COPY, "networks", TRUE, NULL },
- { JUST_COPY, "newsyslog.conf", TRUE, NULL },
- { JUST_COPY, "pam.conf", TRUE, NULL },
- { JUST_COPY, "passwd", TRUE, NULL },
- { JUST_COPY, "periodic", TRUE, NULL },
- { JUST_COPY, "ppp", TRUE, NULL },
- { JUST_COPY, "printcap", TRUE, NULL },
- { JUST_COPY, "profile", TRUE, NULL },
- { JUST_COPY, "pwd.db", TRUE, NULL },
- { JUST_COPY, "rc.local", TRUE, NULL },
- { JUST_COPY, "rc.firewall", TRUE, NULL },
- { JUST_COPY, "rc.conf.local", TRUE, NULL },
- { JUST_COPY, "remote", TRUE, NULL },
- { JUST_COPY, "resolv.conf", TRUE, NULL },
- { JUST_COPY, "rmt", TRUE, NULL },
- { JUST_COPY, "sendmail.cf", TRUE, NULL },
- { JUST_COPY, "sendmail.cw", TRUE, NULL },
- { JUST_COPY, "services", TRUE, NULL },
- { JUST_COPY, "shells", TRUE, NULL },
- { JUST_COPY, "skeykeys", TRUE, NULL },
- { JUST_COPY, "spwd.db", TRUE, NULL },
- { JUST_COPY, "syslog.conf", TRUE, NULL },
- { JUST_COPY, "ttys", TRUE, NULL },
- { JUST_COPY, "uucp", TRUE, NULL },
- { 0 },
-};
-
-void
-traverseHitlist(HitList *h)
-{
- system("rm -rf /etc/upgrade");
- Mkdir("/etc/upgrade");
- while (h->name) {
- if (!file_readable(h->name)) {
- if (!h->optional)
- msgConfirm("Unable to find an old /etc/%s file! That is decidedly non-standard and\n"
- "your upgraded system may function a little strangely as a result.", h->name);
- }
- else {
- if (h->action == JUST_COPY) {
- /* Move the just-loaded copy aside */
- vsystem("mv /etc/%s /etc/upgrade/%s", h->name, h->name);
-
- /* Copy the old one into its place */
- msgNotify("Resurrecting %s..", h->name);
- /* Do this with tar so that symlinks and such are preserved */
- if (vsystem("tar cf - %s | tar xpf - -C /etc", h->name))
- msgConfirm("Unable to resurrect your old /etc/%s! Hmmmm.", h->name);
- }
- else /* call handler */
- h->handler(h);
- }
- ++h;
- }
-}
-
-int
-installUpgrade(dialogMenuItem *self)
-{
- char saved_etc[FILENAME_MAX];
- Boolean extractingBin = TRUE;
-
- if (variable_get(VAR_NONINTERACTIVE))
- return installUpgradeNonInteractive(self);
-
- variable_set2(SYSTEM_STATE, "upgrade", 0);
- dialog_clear();
- systemDisplayHelp("UPGRADE");
-
- if (msgYesNo("Given all that scary stuff you just read, are you sure you want to\n"
- "risk it all and proceed with this upgrade?") != 0)
- return DITEM_FAILURE;
-
- if (!Dists) {
- msgConfirm("First, you must select some distribution components. The upgrade procedure\n"
- "will only upgrade the distributions you select in the next set of menus.");
- if (!dmenuOpenSimple(&MenuDistributions, FALSE) || !Dists)
- return DITEM_FAILURE;
- }
- else if (!(Dists & DIST_BIN)) { /* No bin selected? Not much of an upgrade.. */
- if (msgYesNo("You didn't select the bin distribution as one of the distributons to load.\n"
- "This one is pretty vital to a successful upgrade. Are you SURE you don't\n"
- "want to select the bin distribution? Chose No to bring up the Distributions\n"
- "menu again.") != 0) {
- if (!dmenuOpenSimple(&MenuDistributions, FALSE))
- return DITEM_FAILURE;
- }
- }
-
- /* Still?! OK! They must know what they're doing.. */
- if (!(Dists & DIST_BIN))
- extractingBin = FALSE;
-
- if (RunningAsInit) {
- Device **devs;
- int i, cnt;
- char *cp;
-
- cp = variable_get(VAR_DISK);
- devs = deviceFind(cp, DEVICE_TYPE_DISK);
- cnt = deviceCount(devs);
- if (!cnt) {
- msgConfirm("No disks found! Please verify that your disk controller is being\n"
- "properly probed at boot time. See the Hardware Guide on the\n"
- "Documentation menu for clues on diagnosing this type of problem.");
- return DITEM_FAILURE | DITEM_RESTORE;
- }
- else {
- /* Enable all the drives before we start */
- for (i = 0; i < cnt; i++)
- devs[i]->enabled = TRUE;
- }
-
- msgConfirm("OK. First, we're going to go to the disk label editor. In this editor\n"
- "you will be expected to Mount any partitions you're interested in\n"
- "upgrading. DO NOT set the Newfs flag to Y on anything in the label editor\n"
- "unless you're absolutely sure you know what you're doing! In this\n"
- "instance, you'll be using the label editor as little more than a fancy\n"
- "screen-oriented partition mounting tool.\n\n"
- "Once you're done in the label editor, press Q to return here for the next\n"
- "step.");
-
- if (DITEM_STATUS(diskLabelEditor(self)) == DITEM_FAILURE) {
- msgConfirm("The disk label editor returned an error status. Upgrade operation\n"
- "aborted.");
- return DITEM_FAILURE | DITEM_RESTORE;
- }
-
- /* Don't write out MBR info */
- variable_set2(DISK_PARTITIONED, "written", 0);
- if (DITEM_STATUS(diskLabelCommit(self)) == DITEM_FAILURE) {
- msgConfirm("Not all file systems were properly mounted. Upgrade operation\n"
- "aborted.");
- variable_unset(DISK_PARTITIONED);
- return DITEM_FAILURE | DITEM_RESTORE;
- }
-
- msgNotify("Updating /stand on root filesystem");
- (void)vsystem("find -x /stand | cpio %s -pdum /mnt", cpioVerbosity());
-
- if (DITEM_STATUS(chroot("/mnt")) == DITEM_FAILURE) {
- msgConfirm("Unable to chroot to /mnt - something is wrong with the\n"
- "root partition or the way it's mounted if this doesn't work.");
- variable_unset(DISK_PARTITIONED);
- return DITEM_FAILURE | DITEM_RESTORE;
- }
- chdir("/");
- installEnvironment();
- systemCreateHoloshell();
- }
-
- saved_etc[0] = '\0';
-
- /* Don't allow sources to be upgraded unless if we have src already */
- if (directory_exists("/usr/src/") && (Dists & DIST_SRC)) {
- Dists &= ~DIST_SRC;
- msgConfirm("Warning: /usr/src exists and sources were selected as upgrade\n"
- "targets. Unfortunately, this is not the way to upgrade your\n"
- "sources - please use CTM or CVSup or some other method which\n"
- "handles ``deletion events'', unlike this particular feature.\n\n"
- "Your existing /usr/src will not be affected by this upgrade.\n");
- }
-
- if (extractingBin) {
- while (!*saved_etc) {
- char *cp = msgGetInput("/usr/tmp/etc", "Under which directory do you wish to save your current /etc?");
-
- if (!cp || !*cp || Mkdir(cp)) {
- if (msgYesNo("Directory was not specified, was invalid or user selected Cancel.\n\n"
- "Doing an upgrade without first backing up your /etc directory is a very\n"
- "bad idea! Do you want to go back and specify the save directory again?") != 0)
- break;
- }
- else {
- SAFE_STRCPY(saved_etc, cp);
- }
- }
-
- if (saved_etc[0]) {
- msgNotify("Preserving /etc directory..");
- if (vsystem("tar -cBpf - -C /etc . | tar --unlink -xBpf - -C %s", saved_etc))
- if (msgYesNo("Unable to backup your /etc into %s.\n"
- "Do you want to continue anyway?", saved_etc) != 0)
- return DITEM_FAILURE;
- msgNotify("Preserving /root directory..");
- vsystem("tar -cBpf - -C / root | tar --unlink -xBpf - -C %s", saved_etc);
- }
-
- msgNotify("chflags'ing old binaries - please wait.");
- (void)vsystem("chflags -R noschg /bin /sbin /usr/sbin /usr/bin /usr/lib /usr/libexec /kernel*");
-
- if (file_readable("/kernel")) {
- msgNotify("Moving old kernel to /kernel.prev");
- if (system("mv /kernel /kernel.prev")) {
- if (!msgYesNo("Hmmm! I couldn't move the old kernel over! Do you want to\n"
- "treat this as a big problem and abort the upgrade? Due to the\n"
- "way that this upgrade process works, you will have to reboot\n"
- "and start over from the beginning. Select Yes to reboot now"))
- systemShutdown(1);
- }
- else
- msgConfirm("NOTICE: Your old kernel is in /kernel.prev should this upgrade\n"
- "fail for any reason and you need to boot your old kernel");
- }
- }
-
-media:
- /* We do this very late, but we unfortunately need to back up /etc first */
- if (!mediaVerify())
- return DITEM_FAILURE;
-
- if (!mediaDevice->init(mediaDevice)) {
- if (!msgYesNo("Couldn't initialize the media. Would you like\n"
- "to adjust your media selection and try again?")) {
- mediaDevice = NULL;
- goto media;
- }
- else
- return DITEM_FAILURE | DITEM_REDRAW | DITEM_RESTORE;
- }
-
- msgNotify("Beginning extraction of distributions..");
- if (DITEM_STATUS(distExtractAll(self)) == DITEM_FAILURE) {
- msgConfirm("Hmmmm. We couldn't even extract the bin distribution. This upgrade\n"
- "should be considered a failure and started from the beginning, sorry!\n"
- "The system will reboot now.");
- dialog_clear();
- systemShutdown(1);
- }
- else if (Dists) {
- if (!extractingBin || !(Dists & DIST_BIN)) {
- msgNotify("The extraction process seems to have had some problems, but we got most\n"
- "of the essentials. We'll treat this as a warning since it may have been\n"
- "only non-essential distributions which failed to load.");
- }
- else {
- msgConfirm("Hmmmm. We couldn't even extract the bin distribution. This upgrade\n"
- "should be considered a failure and started from the beginning, sorry!\n"
- "The system will reboot now.");
- dialog_clear();
- systemShutdown(1);
- }
- }
-
- if (extractingBin)
- vsystem("disklabel -B `awk '$2~/\\/$/ {print substr($1, 6, 3)}' /etc/fstab`");
- msgNotify("First stage of upgrade completed successfully!\n\n"
- "Next comes stage 2, where we attempt to resurrect your /etc\n"
- "directory!");
-
- if (saved_etc && chdir(saved_etc)) {
- msgConfirm("Unable to go to your saved /etc directory in %s?! Argh!\n"
- "Something went seriously wrong! It's quite possible that\n"
- "your former /etc is toast. I hope you didn't have any\n"
- "important customizations you wanted to keep in there.. :(", saved_etc);
- }
- else {
- /* Now try to resurrect the /etc files */
- traverseHitlist(etc_files);
- /* Resurrect the root dotfiles */
- vsystem("tar -cBpf - root | tar -xBpf - -C / && rm -rf root");
- }
-
- msgConfirm("Upgrade completed! All of your old /etc files have been restored.\n"
- "For your reference, the new /etc files are in /etc/upgrade/ in case\n"
- "you wish to upgrade these files by hand (though that should not be\n"
- "strictly necessary). If your root partition is specified in /etc/fstab\n"
- "using the old \"compatibility\" slice, you may also wish to update it to\n"
- "use a fully qualified slice name in order to avoid warnings on startup.\n\n"
- "When you're ready to reboot into the new system, simply exit the installation.");
- return DITEM_SUCCESS | DITEM_REDRAW | DITEM_RESTORE;
-}
-
-static int
-installUpgradeNonInteractive(dialogMenuItem *self)
-{
- char *saved_etc;
- Boolean extractingBin = TRUE;
-
- variable_set2(SYSTEM_STATE, "upgrade", 0);
-
- /* Make sure at least BIN is selected */
- Dists |= DIST_BIN;
-
- if (RunningAsInit) {
- Device **devs;
- int i, cnt;
- char *cp;
-
- cp = variable_get(VAR_DISK);
- devs = deviceFind(cp, DEVICE_TYPE_DISK);
- cnt = deviceCount(devs);
- if (!cnt) {
- msgConfirm("No disks found! Please verify that your disk controller is being\n"
- "properly probed at boot time. See the Hardware Guide on the\n"
- "Documentation menu for clues on diagnosing this type of problem.");
- return DITEM_FAILURE;
- }
- else {
- /* Enable all the drives befor we start */
- for (i = 0; i < cnt; i++)
- devs[i]->enabled = TRUE;
- }
-
- msgConfirm("OK. First, we're going to go to the disk label editor. In this editor\n"
- "you will be expected to Mount any partitions you're interested in\n"
- "upgrading. DO NOT set the Newfs flag to Y on anything in the label editor\n"
- "unless you're absolutely sure you know what you're doing! In this\n"
- "instance, you'll be using the label editor as little more than a fancy\n"
- "screen-oriented partition mounting tool.\n\n"
- "Once you're done in the label editor, press Q to return here for the next\n"
- "step.");
-
- if (DITEM_STATUS(diskLabelEditor(self)) == DITEM_FAILURE) {
- msgConfirm("The disk label editor returned an error status. Upgrade operation\n"
- "aborted.");
- return DITEM_FAILURE;
- }
-
- /* Don't write out MBR info */
- variable_set2(DISK_PARTITIONED, "written", 0);
- if (DITEM_STATUS(diskLabelCommit(self)) == DITEM_FAILURE) {
- msgConfirm("Not all file systems were properly mounted. Upgrade operation\n"
- "aborted.");
- variable_unset(DISK_PARTITIONED);
- return DITEM_FAILURE;
- }
-
- if (extractingBin) {
- msgNotify("chflags'ing old binaries - please wait.");
- (void)vsystem("chflags -R noschg /mnt/");
- }
- msgNotify("Updating /stand on root filesystem");
- (void)vsystem("find -x /stand | cpio %s -pdum /mnt", cpioVerbosity());
-
- if (DITEM_STATUS(chroot("/mnt")) == DITEM_FAILURE) {
- msgConfirm("Unable to chroot to /mnt - something is wrong with the\n"
- "root partition or the way it's mounted if this doesn't work.");
- variable_unset(DISK_PARTITIONED);
- return DITEM_FAILURE;
- }
- chdir("/");
- systemCreateHoloshell();
- }
-
- if (!mediaVerify() || !mediaDevice->init(mediaDevice)) {
- msgNotify("Upgrade: Couldn't initialize media.");
- return DITEM_FAILURE;
- }
-
- saved_etc = "/usr/tmp/etc";
- Mkdir(saved_etc);
- msgNotify("Preserving /etc directory..");
- if (vsystem("tar -cpBf - -C /etc . | tar -xpBf - -C %s", saved_etc)) {
- msgNotify("Unable to backup your /etc into %s.", saved_etc);
- return DITEM_FAILURE;
- }
-
- if (file_readable("/kernel")) {
- msgNotify("Moving old kernel to /kernel.prev");
- if (!system("chflags noschg /kernel && mv /kernel /kernel.prev")) {
- /* Give us a working kernel in case we crash and reboot */
- system("cp /kernel.prev /kernel");
- }
- }
-
- msgNotify("Beginning extraction of distributions..");
- if (DITEM_STATUS(distExtractAll(self)) == DITEM_FAILURE) {
- msgConfirm("Hmmmm. We couldn't even extract the bin distribution. This upgrade\n"
- "should be considered a failure and started from the beginning, sorry!\n"
- "The system will reboot now.");
- dialog_clear();
- systemShutdown(1);
- }
- else if (Dists) {
- if (!(Dists & DIST_BIN)) {
- msgNotify("The extraction process seems to have had some problems, but we got most\n"
- "of the essentials. We'll treat this as a warning since it may have been\n"
- "only non-essential distributions which failed to upgrade.");
- }
- else {
- msgConfirm("Hmmmm. We couldn't even extract the bin distribution. This upgrade\n"
- "should be considered a failure and started from the beginning, sorry!\n"
- "The system will reboot now.");
- dialog_clear();
- systemShutdown(1);
- }
- }
-
- msgNotify("First stage of upgrade completed successfully.");
- if (vsystem("tar -cpBf - -C %s . | tar --unlink -xpBf - -C /etc", saved_etc)) {
- msgNotify("Unable to resurrect your old /etc!");
- return DITEM_FAILURE;
- }
- return DITEM_SUCCESS | DITEM_REDRAW;
-}
diff --git a/usr.sbin/sysinstall/keymap.c b/usr.sbin/sysinstall/keymap.c
deleted file mode 100644
index 53b076180ebe..000000000000
--- a/usr.sbin/sysinstall/keymap.c
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 1996 Joerg Wunsch
- *
- * 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 DEVELOPERS ``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 DEVELOPERS 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.
- *
- * $FreeBSD$
- *
- */
-
-#include "sysinstall.h"
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <machine/console.h>
-
-struct keymapInfo {
- const char *name;
- const struct keymap *map;
-};
-
-#include "keymap.h"
-
-/*
- * keymap.h is being automatically generated by the Makefile. It
- * contains definitions for all desired keymaps. Note that since we
- * don't support font loading nor screen mapping during installation,
- * we simply don't care for any other keys than the ASCII subset.
- *
- * Therefore, if no keymap with the exact name has been found in the
- * first pass, we make a second pass over the table looking just for
- * the language name only.
- */
-
-/*
- * Return values:
- *
- * 0: OK
- * -1: no appropriate keymap found
- * -2: error installing map (other than ENXIO which means we're not on syscons)
- */
-
-int
-loadKeymap(const char *lang)
-{
- int passno, err;
- char *llang;
- size_t l;
- struct keymapInfo *kip;
-
- llang = strdup(lang);
- if (llang == NULL)
- abort();
-
- for (passno = 0; passno < 2; passno++)
- {
- if (passno > 0)
- {
- /* make the match more fuzzy */
- l = strspn(llang, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
- llang[l] = '\0';
- }
-
- l = strlen(llang);
-
- for (kip = keymapInfos; kip->name; kip++)
- if (strncmp(kip->name, llang, l) == 0)
- {
- /* Yep, got it! */
- err = ioctl(0, PIO_KEYMAP, kip->map);
- free(llang);
- return (err == -1 && errno != ENOTTY)? -2: 0;
- }
- }
- free(llang);
- return -1;
-}
diff --git a/usr.sbin/sysinstall/kget.c b/usr.sbin/sysinstall/kget.c
deleted file mode 100644
index 20bf4b58c86f..000000000000
--- a/usr.sbin/sysinstall/kget.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/*-
- * Copyright (c) 1999 Andrzej Bialecki <abial@freebsd.org>
- * 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 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#ifdef __alpha__
-int
-kget(char *out)
-{
- return -1;
-}
-
-#else
-
-#include "sysinstall.h"
-#include <sys/sysctl.h>
-#include <i386/isa/isa_device.h>
-
-int
-kget(char *out)
-{
- int len, i, bytes_written = 0;
- char *buf;
- char *mib1 = "machdep.uc_devlist";
- char name[9];
- FILE *fout = NULL;
- struct isa_device *id;
- char *p;
-
- /* create the output file; if we end up not writing to it, we'll
- unlink() it later. */
- fout = fopen(out, "w");
- if (fout == NULL) {
- msgDebug("kget: Unable to open %s for writing.\n", out);
- return -1;
- }
-
- /* We use sysctlbyname, because the oid is unknown (OID_AUTO) */
- /* get the buffer size */
- i = sysctlbyname(mib1, NULL, &len, NULL, NULL);
- if (i) {
- msgDebug("kget: error buffer sizing\n");
- goto bail;
- }
- if (len <= 0) {
- msgDebug("kget: mib1 has length of %d\n", len);
- goto bail;
- }
- buf = (char *)alloca(len * sizeof(char));
- i = sysctlbyname(mib1, buf, &len, NULL, NULL);
- if (i) {
- msgDebug("kget: error retrieving data\n");
- goto bail;
- }
-
-
- i = 0;
- while (i < len) {
- id = (struct isa_device *)(buf + i);
- p = (buf + i + sizeof(struct isa_device));
- strncpy(name, p, 8);
- if (!id->id_enabled) {
- bytes_written += fprintf(fout, "di %s%d\n", name, id->id_unit);
- }
- else {
- bytes_written += fprintf(fout, "en %s%d\n", name, id->id_unit);
- if (id->id_iobase > 0) {
- bytes_written += fprintf(fout, "po %s%d %#x\n",
- name, id->id_unit, id->id_iobase);
- }
- if (id->id_irq > 0) {
- bytes_written += fprintf(fout, "ir %s%d %d\n", name,
- id->id_unit, ffs(id->id_irq) - 1);
- }
- if (id->id_drq > 0) {
- bytes_written += fprintf(fout, "dr %s%d %d\n", name,
- id->id_unit, id->id_drq);
- }
- if (id->id_maddr > 0) {
- bytes_written += fprintf(fout, "iom %s%d %#x\n", name,
- id->id_unit, (u_int)id->id_maddr);
- }
- if (id->id_msize > 0) {
- bytes_written += fprintf(fout, "ios %s%d %d\n", name,
- id->id_unit, id->id_msize);
- }
- bytes_written += fprintf(fout, "f %s%d %#x\n", name,
- id->id_unit, id->id_flags);
- }
- i += sizeof(struct isa_device) + 8;
- }
-
-bail:
- if (bytes_written)
- fprintf(fout, "q\n");
- else
- unlink(out);
- fclose(fout);
- return 0;
-}
-
-#endif /* !alpha */
diff --git a/usr.sbin/sysinstall/label.c b/usr.sbin/sysinstall/label.c
deleted file mode 100644
index 460f19404d2a..000000000000
--- a/usr.sbin/sysinstall/label.c
+++ /dev/null
@@ -1,1298 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last program in the `sysinstall' line - the next
- * generation being essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 "sysinstall.h"
-#include <ctype.h>
-#include <sys/disklabel.h>
-#include <sys/param.h>
-#include <sys/sysctl.h>
-
-/*
- * Everything to do with editing the contents of disk labels.
- */
-
-/* A nice message we use a lot in the disklabel editor */
-#define MSG_NOT_APPLICABLE "That option is not applicable here"
-
-/* Where to start printing the freebsd slices */
-#define CHUNK_SLICE_START_ROW 2
-#define CHUNK_PART_START_ROW 11
-
-/* The smallest filesystem we're willing to create */
-#define FS_MIN_SIZE ONE_MEG
-
-/* The smallest root filesystem we're willing to create */
-#ifdef __alpha__
-#define ROOT_MIN_SIZE 40
-#else
-#define ROOT_MIN_SIZE 30
-#endif
-
-/* The default root filesystem size */
-#ifdef __alpha__
-#define ROOT_DEFAULT_SIZE 70
-#else
-#define ROOT_DEFAULT_SIZE 50
-#endif
-
-/* The smallest swap partition we want to create by default */
-#define SWAP_MIN_SIZE 32
-
-/* The smallest /usr partition we're willing to create by default */
-#define USR_MIN_SIZE 80
-
-/* The smallest /var partition we're willing to create by default */
-#define VAR_MIN_SIZE 20
-
-/* The bottom-most row we're allowed to scribble on */
-#define CHUNK_ROW_MAX 16
-
-
-/* All the chunks currently displayed on the screen */
-static struct {
- struct chunk *c;
- PartType type;
-} label_chunk_info[MAX_CHUNKS + 1];
-static int here;
-
-/*** with this value we try to track the most recently added label ***/
-static int label_focus = 0, pslice_focus = 0;
-
-static int diskLabel(Device *dev);
-static int diskLabelNonInteractive(Device *dev);
-
-static int
-labelHook(dialogMenuItem *selected)
-{
- Device **devs = NULL;
-
- devs = deviceFind(selected->prompt, DEVICE_TYPE_DISK);
- if (!devs) {
- msgConfirm("Unable to find disk %s!", selected->prompt);
- return DITEM_FAILURE;
- }
- /* Toggle enabled status? */
- if (!devs[0]->enabled) {
- devs[0]->enabled = TRUE;
- diskLabel(devs[0]);
- }
- else
- devs[0]->enabled = FALSE;
- return DITEM_SUCCESS;
-}
-
-static int
-labelCheck(dialogMenuItem *selected)
-{
- Device **devs = NULL;
-
- devs = deviceFind(selected->prompt, DEVICE_TYPE_DISK);
- if (!devs || devs[0]->enabled == FALSE)
- return FALSE;
- return TRUE;
-}
-
-int
-diskLabelEditor(dialogMenuItem *self)
-{
- DMenu *menu;
- Device **devs;
- int i, cnt;
-
- i = 0;
- cnt = diskGetSelectCount(&devs);
- if (cnt == -1) {
- msgConfirm("No disks found! Please verify that your disk controller is being\n"
- "properly probed at boot time. See the Hardware Guide on the\n"
- "Documentation menu for clues on diagnosing this type of problem.");
- return DITEM_FAILURE;
- }
- else if (cnt) {
- /* Some are already selected */
- if (variable_get(VAR_NONINTERACTIVE))
- i = diskLabelNonInteractive(NULL);
- else
- i = diskLabel(NULL);
- }
- else {
- /* No disks are selected, fall-back case now */
- cnt = deviceCount(devs);
- if (cnt == 1) {
- devs[0]->enabled = TRUE;
- if (variable_get(VAR_NONINTERACTIVE))
- i = diskLabelNonInteractive(devs[0]);
- else
- i = diskLabel(devs[0]);
- }
- else {
- menu = deviceCreateMenu(&MenuDiskDevices, DEVICE_TYPE_DISK, labelHook, labelCheck);
- if (!menu) {
- msgConfirm("No devices suitable for installation found!\n\n"
- "Please verify that your disk controller (and attached drives)\n"
- "were detected properly. This can be done by pressing the\n"
- "[Scroll Lock] key and using the Arrow keys to move back to\n"
- "the boot messages. Press [Scroll Lock] again to return.");
- i = DITEM_FAILURE;
- }
- else {
- i = dmenuOpenSimple(menu, FALSE) ? DITEM_SUCCESS : DITEM_FAILURE;
- free(menu);
- }
- }
- }
- if (DITEM_STATUS(i) != DITEM_FAILURE) {
- char *cp;
-
- if (((cp = variable_get(DISK_LABELLED)) == NULL) || (strcmp(cp, "written")))
- variable_set2(DISK_LABELLED, "yes", 0);
- }
- return i;
-}
-
-int
-diskLabelCommit(dialogMenuItem *self)
-{
- char *cp;
- int i;
-
- /* Already done? */
- if ((cp = variable_get(DISK_LABELLED)) && strcmp(cp, "yes"))
- i = DITEM_SUCCESS;
- else if (!cp) {
- msgConfirm("You must assign disk labels before this option can be used.");
- i = DITEM_FAILURE;
- }
- /* The routine will guard against redundant writes, just as this one does */
- else if (DITEM_STATUS(diskPartitionWrite(self)) != DITEM_SUCCESS)
- i = DITEM_FAILURE;
- else if (DITEM_STATUS(installFilesystems(self)) != DITEM_SUCCESS)
- i = DITEM_FAILURE;
- else {
- msgInfo("All filesystem information written successfully.");
- variable_set2(DISK_LABELLED, "written", 0);
- i = DITEM_SUCCESS;
- }
- return i;
-}
-
-/* See if we're already using a desired partition name */
-static Boolean
-check_conflict(char *name)
-{
- int i;
-
- for (i = 0; label_chunk_info[i].c; i++)
- if ((label_chunk_info[i].type == PART_FILESYSTEM || label_chunk_info[i].type == PART_FAT)
- && label_chunk_info[i].c->private_data
- && !strcmp(((PartInfo *)label_chunk_info[i].c->private_data)->mountpoint, name))
- return TRUE;
- return FALSE;
-}
-
-/* How much space is in this FreeBSD slice? */
-static int
-space_free(struct chunk *c)
-{
- struct chunk *c1;
- int sz = c->size;
-
- for (c1 = c->part; c1; c1 = c1->next) {
- if (c1->type != unused)
- sz -= c1->size;
- }
- if (sz < 0)
- msgFatal("Partitions are larger than actual chunk??");
- return sz;
-}
-
-/* Snapshot the current situation into the displayed chunks structure */
-static void
-record_label_chunks(Device **devs, Device *dev)
-{
- int i, j, p;
- struct chunk *c1, *c2;
- Disk *d;
-
- j = p = 0;
- /* First buzz through and pick up the FreeBSD slices */
- for (i = 0; devs[i]; i++) {
- if ((dev && devs[i] != dev) || !devs[i]->enabled)
- continue;
- d = (Disk *)devs[i]->private;
- if (!d->chunks)
- msgFatal("No chunk list found for %s!", d->name);
-
- /* Put the slice entries first */
- for (c1 = d->chunks->part; c1; c1 = c1->next) {
- if (c1->type == freebsd) {
- label_chunk_info[j].type = PART_SLICE;
- label_chunk_info[j].c = c1;
- ++j;
- }
- }
- }
-
- /* Now run through again and get the FreeBSD partition entries */
- for (i = 0; devs[i]; i++) {
- if (!devs[i]->enabled)
- continue;
- d = (Disk *)devs[i]->private;
- /* Then buzz through and pick up the partitions */
- for (c1 = d->chunks->part; c1; c1 = c1->next) {
- if (c1->type == freebsd) {
- for (c2 = c1->part; c2; c2 = c2->next) {
- if (c2->type == part) {
- if (c2->subtype == FS_SWAP)
- label_chunk_info[j].type = PART_SWAP;
- else
- label_chunk_info[j].type = PART_FILESYSTEM;
- label_chunk_info[j].c = c2;
- ++j;
- }
- }
- }
- else if (c1->type == fat) {
- label_chunk_info[j].type = PART_FAT;
- label_chunk_info[j].c = c1;
- ++j;
- }
- }
- }
- label_chunk_info[j].c = NULL;
- if (here >= j) {
- here = j ? j - 1 : 0;
- }
-}
-
-/* A new partition entry */
-static PartInfo *
-new_part(char *mpoint, Boolean newfs, u_long size)
-{
- PartInfo *ret;
-
- if (!mpoint)
- mpoint = "/change_me";
-
- ret = (PartInfo *)safe_malloc(sizeof(PartInfo));
- sstrncpy(ret->mountpoint, mpoint, FILENAME_MAX);
- strcpy(ret->newfs_cmd, "newfs ");
- strcat(ret->newfs_cmd, variable_get(VAR_NEWFS_ARGS));
- ret->newfs = newfs;
- if (!size)
- return ret;
- return ret;
-}
-
-/* Get the mountpoint for a partition and save it away */
-static PartInfo *
-get_mountpoint(struct chunk *old)
-{
- char *val;
- PartInfo *tmp;
-
- if (old && old->private_data)
- tmp = old->private_data;
- else
- tmp = NULL;
- val = msgGetInput(tmp ? tmp->mountpoint : NULL, "Please specify a mount point for the partition");
- if (!val || !*val) {
- if (!old)
- return NULL;
- else {
- free(old->private_data);
- old->private_data = NULL;
- }
- return NULL;
- }
-
- /* Is it just the same value? */
- if (tmp && !strcmp(tmp->mountpoint, val))
- return NULL;
-
- /* Did we use it already? */
- if (check_conflict(val)) {
- msgConfirm("You already have a mount point for %s assigned!", val);
- return NULL;
- }
-
- /* Is it bogus? */
- if (*val != '/') {
- msgConfirm("Mount point must start with a / character");
- return NULL;
- }
-
- /* Is it going to be mounted on root? */
- if (!strcmp(val, "/")) {
- if (old)
- old->flags |= CHUNK_IS_ROOT;
- }
- else if (old)
- old->flags &= ~CHUNK_IS_ROOT;
-
- safe_free(tmp);
- val = string_skipwhite(string_prune(val));
- tmp = new_part(val, TRUE, 0);
- if (old) {
- old->private_data = tmp;
- old->private_free = safe_free;
- }
- return tmp;
-}
-
-/* Get the type of the new partiton */
-static PartType
-get_partition_type(void)
-{
- char selection[20];
- int i;
- static unsigned char *fs_types[] = {
- "FS",
- "A file system",
- "Swap",
- "A swap partition.",
- };
- WINDOW *w = savescr();
-
- i = dialog_menu("Please choose a partition type",
- "If you want to use this partition for swap space, select Swap.\n"
- "If you want to put a filesystem on it, choose FS.",
- -1, -1, 2, 2, fs_types, selection, NULL, NULL);
- restorescr(w);
- if (!i) {
- if (!strcmp(selection, "FS"))
- return PART_FILESYSTEM;
- else if (!strcmp(selection, "Swap"))
- return PART_SWAP;
- }
- return PART_NONE;
-}
-
-/* If the user wants a special newfs command for this, set it */
-static void
-getNewfsCmd(PartInfo *p)
-{
- char *val;
-
- val = msgGetInput(p->newfs_cmd,
- "Please enter the newfs command and options you'd like to use in\n"
- "creating this file system.");
- if (val)
- sstrncpy(p->newfs_cmd, val, NEWFS_CMD_MAX);
-}
-
-#define MAX_MOUNT_NAME 10
-
-#define PART_PART_COL 0
-#define PART_MOUNT_COL 10
-#define PART_SIZE_COL (PART_MOUNT_COL + MAX_MOUNT_NAME + 3)
-#define PART_NEWFS_COL (PART_SIZE_COL + 8)
-#define PART_OFF 38
-
-#define TOTAL_AVAIL_LINES (10)
-#define PSLICE_SHOWABLE (4)
-
-
-/* stick this all up on the screen */
-static void
-print_label_chunks(void)
-{
- int i, j, srow, prow, pcol;
- int sz;
- char clrmsg[80];
- int ChunkPartStartRow;
- WINDOW *ChunkWin;
-
- /********************************************************/
- /*** These values are for controling screen resources ***/
- /*** Each label line holds up to 2 labels, so beware! ***/
- /*** strategy will be to try to always make sure the ***/
- /*** highlighted label is in the active display area. ***/
- /********************************************************/
- int pslice_max, label_max;
- int pslice_count, label_count, label_focus_found, pslice_focus_found;
-
- attrset(A_REVERSE);
- mvaddstr(0, 25, "FreeBSD Disklabel Editor");
- attrset(A_NORMAL);
-
- /*** Count the number of parition slices ***/
- pslice_count = 0;
- for (i = 0; label_chunk_info[i].c ; i++) {
- if (label_chunk_info[i].type == PART_SLICE)
- ++pslice_count;
- }
- pslice_max = pslice_count;
-
- /*** 4 line max for partition slices ***/
- if (pslice_max > PSLICE_SHOWABLE) {
- pslice_max = PSLICE_SHOWABLE;
- }
- ChunkPartStartRow = CHUNK_SLICE_START_ROW + 3 + pslice_max;
-
- /*** View partition slices modulo pslice_max ***/
- label_max = TOTAL_AVAIL_LINES - pslice_max;
-
- for (i = 0; i < 2; i++) {
- mvaddstr(ChunkPartStartRow - 2, PART_PART_COL + (i * PART_OFF), "Part");
- mvaddstr(ChunkPartStartRow - 1, PART_PART_COL + (i * PART_OFF), "----");
-
- mvaddstr(ChunkPartStartRow - 2, PART_MOUNT_COL + (i * PART_OFF), "Mount");
- mvaddstr(ChunkPartStartRow - 1, PART_MOUNT_COL + (i * PART_OFF), "-----");
-
- mvaddstr(ChunkPartStartRow - 2, PART_SIZE_COL + (i * PART_OFF) + 3, "Size");
- mvaddstr(ChunkPartStartRow - 1, PART_SIZE_COL + (i * PART_OFF) + 3, "----");
-
- mvaddstr(ChunkPartStartRow - 2, PART_NEWFS_COL + (i * PART_OFF), "Newfs");
- mvaddstr(ChunkPartStartRow - 1, PART_NEWFS_COL + (i * PART_OFF), "-----");
- }
- srow = CHUNK_SLICE_START_ROW;
- prow = 0;
- pcol = 0;
-
- /*** these variables indicate that the focused item is shown currently ***/
- label_focus_found = 0;
- pslice_focus_found = 0;
-
- label_count = 0;
- pslice_count = 0;
- mvprintw(CHUNK_SLICE_START_ROW - 1, 0, " ");
- mvprintw(CHUNK_SLICE_START_ROW + pslice_max, 0, " ");
-
- ChunkWin = newwin(CHUNK_ROW_MAX - ChunkPartStartRow, 76, ChunkPartStartRow, 0);
-
- wclear(ChunkWin);
- /*** wrefresh(ChunkWin); ***/
-
- for (i = 0; label_chunk_info[i].c; i++) {
- /* Is it a slice entry displayed at the top? */
- if (label_chunk_info[i].type == PART_SLICE) {
- /*** This causes the new pslice to replace the previous display ***/
- /*** focus must remain on the most recently active pslice ***/
- if (pslice_count == pslice_max) {
- if (pslice_focus_found) {
- /*** This is where we can mark the more following ***/
- attrset(A_BOLD);
- mvprintw(CHUNK_SLICE_START_ROW + pslice_max, 0, "***MORE***");
- attrset(A_NORMAL);
- continue;
- }
- else {
- /*** this is where we set the more previous ***/
- attrset(A_BOLD);
- mvprintw(CHUNK_SLICE_START_ROW - 1, 0, "***MORE***");
- attrset(A_NORMAL);
- pslice_count = 0;
- srow = CHUNK_SLICE_START_ROW;
- }
- }
-
- sz = space_free(label_chunk_info[i].c);
- if (i == here)
- attrset(ATTR_SELECTED);
- if (i == pslice_focus)
- pslice_focus_found = -1;
-
- mvprintw(srow++, 0,
- "Disk: %s\tPartition name: %s\tFree: %d blocks (%dMB)",
- label_chunk_info[i].c->disk->name, label_chunk_info[i].c->name,
- sz, (sz / ONE_MEG));
- attrset(A_NORMAL);
- clrtoeol();
- move(0, 0);
- /*** refresh(); ***/
- ++pslice_count;
- }
- /* Otherwise it's a DOS, swap or filesystem entry in the Chunk window */
- else {
- char onestr[PART_OFF], num[10], *mountpoint, *newfs;
-
- /*
- * We copy this into a blank-padded string so that it looks like
- * a solid bar in reverse-video
- */
- memset(onestr, ' ', PART_OFF - 1);
- onestr[PART_OFF - 1] = '\0';
-
- /*** Track how many labels have been displayed ***/
- if (label_count == ((label_max - 1 ) * 2)) {
- if (label_focus_found) {
- continue;
- }
- else {
- label_count = 0;
- prow = 0;
- pcol = 0;
- }
- }
-
- /* Go for two columns if we've written one full columns worth */
- /*** if (prow == (CHUNK_ROW_MAX - ChunkPartStartRow)) ***/
- if (label_count == label_max - 1) {
- pcol = PART_OFF;
- prow = 0;
- }
- memcpy(onestr + PART_PART_COL, label_chunk_info[i].c->name, strlen(label_chunk_info[i].c->name));
- /* If it's a filesystem, display the mountpoint */
- if (label_chunk_info[i].c->private_data
- && (label_chunk_info[i].type == PART_FILESYSTEM || label_chunk_info[i].type == PART_FAT))
- mountpoint = ((PartInfo *)label_chunk_info[i].c->private_data)->mountpoint;
- else if (label_chunk_info[i].type == PART_SWAP)
- mountpoint = "swap";
- else
- mountpoint = "<none>";
-
- /* Now display the newfs field */
- if (label_chunk_info[i].type == PART_FAT)
- newfs = "DOS";
- else if (label_chunk_info[i].c->private_data && label_chunk_info[i].type == PART_FILESYSTEM)
- newfs = ((PartInfo *)label_chunk_info[i].c->private_data)->newfs ? "UFS Y" : "UFS N";
- else if (label_chunk_info[i].type == PART_SWAP)
- newfs = "SWAP";
- else
- newfs = "*";
- for (j = 0; j < MAX_MOUNT_NAME && mountpoint[j]; j++)
- onestr[PART_MOUNT_COL + j] = mountpoint[j];
- snprintf(num, 10, "%5ldMB", label_chunk_info[i].c->size ? label_chunk_info[i].c->size / ONE_MEG : 0);
- memcpy(onestr + PART_SIZE_COL, num, strlen(num));
- memcpy(onestr + PART_NEWFS_COL, newfs, strlen(newfs));
- onestr[PART_NEWFS_COL + strlen(newfs)] = '\0';
- if (i == label_focus) {
- label_focus_found = -1;
- wattrset(ChunkWin, A_BOLD);
- }
- if (i == here)
- wattrset(ChunkWin, ATTR_SELECTED);
-
- /*** lazy man's way of padding this string ***/
- while (strlen( onestr ) < 37)
- strcat(onestr, " ");
-
- mvwaddstr(ChunkWin, prow, pcol, onestr);
- wattrset(ChunkWin, A_NORMAL);
- move(0, 0);
- ++prow;
- ++label_count;
- }
- }
-
- /*** this will erase all the extra stuff ***/
- memset(clrmsg, ' ', 37);
- clrmsg[37] = '\0';
-
- while (pslice_count < pslice_max) {
- mvprintw(srow++, 0, clrmsg);
- clrtoeol();
- ++pslice_count;
- }
- while (label_count < (2 * (label_max - 1))) {
- mvwaddstr(ChunkWin, prow++, pcol, clrmsg);
- ++label_count;
- if (prow == (label_max - 1)) {
- prow = 0;
- pcol = PART_OFF;
- }
- }
- refresh();
- wrefresh(ChunkWin);
-}
-
-static void
-print_command_summary(void)
-{
- mvprintw(17, 0, "The following commands are valid here (upper or lower case):");
- mvprintw(18, 0, "C = Create D = Delete M = Mount pt.");
- if (!RunningAsInit)
- mvprintw(18, 49, "W = Write");
- mvprintw(19, 0, "N = Newfs Opts T = Newfs Toggle U = Undo Q = Finish");
- mvprintw(20, 0, "A = Auto Defaults for all!");
- mvprintw(22, 0, "Use F1 or ? to get more help, arrow keys to select.");
- move(0, 0);
-}
-
-static void
-clear_wins(void)
-{
- extern void print_label_chunks();
- clear();
- print_label_chunks();
-}
-
-#ifdef __alpha__
-
-/*
- * If there isn't a freebsd chunk already (i.e. there is no label),
- * dedicate the disk.
- */
-static void
-maybe_dedicate(Disk* d)
-{
- struct chunk *c;
-
- for (c = d->chunks->part; c; c = c->next) {
- if (c->type == freebsd)
- break;
- }
-
- if (!c) {
- msgDebug("dedicating disk");
- All_FreeBSD(d, 1);
- }
-}
-
-#endif
-
-static int
-diskLabel(Device *dev)
-{
- int sz, key = 0;
- Boolean labeling;
- char *msg = NULL;
- PartInfo *p, *oldp;
- PartType type;
- Device **devs;
-#ifdef __alpha__
- int i;
-#endif
- WINDOW *w = savescr();
-
- label_focus = 0;
- pslice_focus = 0;
- here = 0;
-
- devs = deviceFind(NULL, DEVICE_TYPE_DISK);
- if (!devs) {
- msgConfirm("No disks found!");
- restorescr(w);
- return DITEM_FAILURE;
- }
- labeling = TRUE;
- keypad(stdscr, TRUE);
-#ifdef __alpha__
- for (i = 0; devs[i]; i++) {
- maybe_dedicate((Disk*) devs[i]->private);
- }
-#endif
- record_label_chunks(devs, dev);
-
- clear();
- while (labeling) {
- char *cp;
-
- print_label_chunks();
- print_command_summary();
- if (msg) {
- attrset(title_attr); mvprintw(23, 0, msg); attrset(A_NORMAL);
- clrtoeol();
- beep();
- msg = NULL;
- }
- else {
- move(23, 0);
- clrtoeol();
- }
-
- refresh();
- key = getch();
- switch (toupper(key)) {
- int i;
- static char _msg[40];
-
- case '\014': /* ^L */
- clear_wins();
- break;
-
- case '\020': /* ^P */
- case KEY_UP:
- case '-':
- if (here != 0)
- --here;
- else
- while (label_chunk_info[here + 1].c)
- ++here;
- break;
-
- case '\016': /* ^N */
- case KEY_DOWN:
- case '+':
- case '\r':
- case '\n':
- if (label_chunk_info[here + 1].c)
- ++here;
- else
- here = 0;
- break;
-
- case KEY_HOME:
- here = 0;
- break;
-
- case KEY_END:
- while (label_chunk_info[here + 1].c)
- ++here;
- break;
-
- case KEY_F(1):
- case '?':
- systemDisplayHelp("partition");
- clear_wins();
- break;
-
- case 'A':
- if (label_chunk_info[here].type != PART_SLICE) {
- msg = "You can only do this in a disk slice (at top of screen)";
- break;
- }
- sz = space_free(label_chunk_info[here].c);
- if (sz <= FS_MIN_SIZE)
- msg = "Not enough free space to create a new partition in the slice";
- else {
- struct chunk *tmp;
- int mib[2];
- int physmem;
- size_t size, swsize;
- char *cp;
- Chunk *rootdev, *swapdev, *usrdev, *vardev;
-
- (void)checkLabels(FALSE, &rootdev, &swapdev, &usrdev, &vardev);
- if (!rootdev) {
- cp = variable_get(VAR_ROOT_SIZE);
- tmp = Create_Chunk_DWIM(label_chunk_info[here].c->disk, label_chunk_info[here].c,
- (cp ? atoi(cp) : ROOT_DEFAULT_SIZE) * ONE_MEG, part, FS_BSDFFS, CHUNK_IS_ROOT);
- if (!tmp) {
- msgConfirm("Unable to create the root partition. Too big?");
- clear_wins();
- break;
- }
- tmp->private_data = new_part("/", TRUE, tmp->size);
- tmp->private_free = safe_free;
- record_label_chunks(devs, dev);
- }
-
- if (!swapdev) {
- cp = variable_get(VAR_SWAP_SIZE);
- if (cp)
- swsize = atoi(cp) * ONE_MEG;
- else {
- mib[0] = CTL_HW;
- mib[1] = HW_PHYSMEM;
- size = sizeof physmem;
- sysctl(mib, 2, &physmem, &size, (void *)0, (size_t)0);
- swsize = 16 * ONE_MEG + (physmem * 2 / 512);
- }
- tmp = Create_Chunk_DWIM(label_chunk_info[here].c->disk, label_chunk_info[here].c,
- swsize, part, FS_SWAP, 0);
- if (!tmp) {
- msgConfirm("Unable to create the swap partition. Too big?");
- clear_wins();
- break;
- }
- tmp->private_data = 0;
- tmp->private_free = safe_free;
- record_label_chunks(devs, dev);
- }
-
- if (!vardev) {
- cp = variable_get(VAR_VAR_SIZE);
- if (cp)
- sz = atoi(cp) * ONE_MEG;
- else
- sz = variable_get(VAR_NO_USR)
- ? space_free(label_chunk_info[here].c)
- : VAR_MIN_SIZE * ONE_MEG;
-
- tmp = Create_Chunk_DWIM(label_chunk_info[here].c->disk, label_chunk_info[here].c,
- sz, part, FS_BSDFFS, 0);
- if (!tmp) {
- msgConfirm("Less than %dMB free for /var - you will need to\n"
- "partition your disk manually with a custom install!",
- (cp ? atoi(cp) : VAR_MIN_SIZE));
- clear_wins();
- break;
- }
- tmp->private_data = new_part("/var", TRUE, tmp->size);
- tmp->private_free = safe_free;
- record_label_chunks(devs, dev);
- }
-
- if (!usrdev && !variable_get(VAR_NO_USR)) {
- cp = variable_get(VAR_USR_SIZE);
- if (cp)
- sz = atoi(cp) * ONE_MEG;
- else
- sz = space_free(label_chunk_info[here].c);
- if (sz) {
- if (sz < (USR_MIN_SIZE * ONE_MEG)) {
- msgConfirm("Less than %dMB free for /usr - you will need to\n"
- "partition your disk manually with a custom install!", USR_MIN_SIZE);
- clear_wins();
- break;
- }
-
- tmp = Create_Chunk_DWIM(label_chunk_info[here].c->disk,
- label_chunk_info[here].c,
- sz, part, FS_BSDFFS, 0);
- if (!tmp) {
- msgConfirm("Unable to create the /usr partition. Not enough space?\n"
- "You will need to partition your disk manually with a custom install!");
- clear_wins();
- break;
- }
- tmp->private_data = new_part("/usr", TRUE, tmp->size);
- tmp->private_free = safe_free;
- record_label_chunks(devs, dev);
- }
- }
-
- /* At this point, we're reasonably "labelled" */
- if (((cp = variable_get(DISK_LABELLED)) == NULL) || (strcmp(cp, "written")))
- variable_set2(DISK_LABELLED, "yes", 0);
- }
- break;
-
- case 'C':
- if (label_chunk_info[here].type != PART_SLICE) {
- msg = "You can only do this in a master partition (see top of screen)";
- break;
- }
- sz = space_free(label_chunk_info[here].c);
- if (sz <= FS_MIN_SIZE) {
- msg = "Not enough space to create an additional FreeBSD partition";
- break;
- }
- else {
- char *val;
- int size;
- struct chunk *tmp;
- char osize[80];
- u_long flags = 0;
-
- sprintf(osize, "%d", sz);
- val = msgGetInput(osize,
- "Please specify the partition size in blocks or append a trailing G for\n"
- "gigabytes, M for megabytes, or C for cylinders.\n"
- "%d blocks (%dMB) are free.",
- sz, sz / ONE_MEG);
- if (!val || (size = strtol(val, &cp, 0)) <= 0) {
- clear_wins();
- break;
- }
-
- if (*cp) {
- if (toupper(*cp) == 'M')
- size *= ONE_MEG;
- else if (toupper(*cp) == 'G')
- size *= ONE_GIG;
- else if (toupper(*cp) == 'C')
- size *= (label_chunk_info[here].c->disk->bios_hd * label_chunk_info[here].c->disk->bios_sect);
- }
- if (size <= FS_MIN_SIZE) {
- msgConfirm("The minimum filesystem size is %dMB", FS_MIN_SIZE / ONE_MEG);
- clear_wins();
- break;
- }
- type = get_partition_type();
- if (type == PART_NONE) {
- clear_wins();
- beep();
- break;
- }
-
- if (type == PART_FILESYSTEM) {
- if ((p = get_mountpoint(NULL)) == NULL) {
- clear_wins();
- beep();
- break;
- }
- else if (!strcmp(p->mountpoint, "/"))
- flags |= CHUNK_IS_ROOT;
- else
- flags &= ~CHUNK_IS_ROOT;
- }
- else
- p = NULL;
-
- if ((flags & CHUNK_IS_ROOT)) {
- if (!(label_chunk_info[here].c->flags & CHUNK_BSD_COMPAT)) {
- msgConfirm("This region cannot be used for your root partition as the\n"
- "FreeBSD boot code cannot deal with a root partition created\n"
- "in that location. Please choose another location or smaller\n"
- "size for your root partition and try again!");
- clear_wins();
- break;
- }
- if (size < (ROOT_MIN_SIZE * ONE_MEG)) {
- msgConfirm("Warning: This is smaller than the recommended size for a\n"
- "root partition. For a variety of reasons, root\n"
- "partitions should usually be at least %dMB in size", ROOT_MIN_SIZE);
- }
- }
- tmp = Create_Chunk_DWIM(label_chunk_info[here].c->disk,
- label_chunk_info[here].c,
- size, part,
- (type == PART_SWAP) ? FS_SWAP : FS_BSDFFS,
- flags);
- if (!tmp) {
- msgConfirm("Unable to create the partition. Too big?");
- clear_wins();
- break;
- }
- if ((flags & CHUNK_IS_ROOT) && (tmp->flags & CHUNK_PAST_1024)) {
- msgConfirm("This region cannot be used for your root partition as it starts\n"
- "or extends past the 1024'th cylinder mark and is thus a\n"
- "poor location to boot from. Please choose another\n"
- "location (or smaller size) for your root partition and try again!");
- Delete_Chunk(label_chunk_info[here].c->disk, tmp);
- clear_wins();
- break;
- }
- if (type != PART_SWAP) {
- /* This is needed to tell the newfs -u about the size */
- tmp->private_data = new_part(p->mountpoint, p->newfs, tmp->size);
- safe_free(p);
- }
- else
- tmp->private_data = p;
- tmp->private_free = safe_free;
- if (((cp = variable_get(DISK_LABELLED)) == NULL) || (strcmp(cp, "written")))
- variable_set2(DISK_LABELLED, "yes", 0);
- record_label_chunks(devs, dev);
- clear_wins();
- /*** This is where we assign focus to new label so it shows ***/
- {
- int i;
- label_focus = -1;
- for (i = 0; label_chunk_info[i].c; ++i) {
- if (label_chunk_info[i].c == tmp) {
- label_focus = i;
- break;
- }
- }
- if (label_focus == -1)
- label_focus = i - 1;
- }
- }
- break;
-
- case KEY_DC:
- case 'D': /* delete */
- if (label_chunk_info[here].type == PART_SLICE) {
- msg = MSG_NOT_APPLICABLE;
- break;
- }
- else if (label_chunk_info[here].type == PART_FAT) {
- msg = "Use the Disk Partition Editor to delete DOS partitions";
- break;
- }
- Delete_Chunk(label_chunk_info[here].c->disk, label_chunk_info[here].c);
- if (((cp = variable_get(DISK_LABELLED)) == NULL) || (strcmp(cp, "written")))
- variable_set2(DISK_LABELLED, "yes", 0);
- record_label_chunks(devs, dev);
- break;
-
- case 'M': /* mount */
- switch(label_chunk_info[here].type) {
- case PART_SLICE:
- msg = MSG_NOT_APPLICABLE;
- break;
-
- case PART_SWAP:
- msg = "You don't need to specify a mountpoint for a swap partition.";
- break;
-
- case PART_FAT:
- case PART_FILESYSTEM:
- oldp = label_chunk_info[here].c->private_data;
- p = get_mountpoint(label_chunk_info[here].c);
- if (p) {
- if (!oldp)
- p->newfs = FALSE;
- if (label_chunk_info[here].type == PART_FAT
- && (!strcmp(p->mountpoint, "/") || !strcmp(p->mountpoint, "/usr")
- || !strcmp(p->mountpoint, "/var"))) {
- msgConfirm("%s is an invalid mount point for a DOS partition!", p->mountpoint);
- strcpy(p->mountpoint, "/bogus");
- }
- }
- if (((cp = variable_get(DISK_LABELLED)) == NULL) || (strcmp(cp, "written")))
- variable_set2(DISK_LABELLED, "yes", 0);
- record_label_chunks(devs, dev);
- clear_wins();
- break;
-
- default:
- msgFatal("Bogus partition under cursor???");
- break;
- }
- break;
-
- case 'N': /* Set newfs options */
- if (label_chunk_info[here].c->private_data &&
- ((PartInfo *)label_chunk_info[here].c->private_data)->newfs)
- getNewfsCmd(label_chunk_info[here].c->private_data);
- else
- msg = MSG_NOT_APPLICABLE;
- clear_wins();
- break;
-
- case 'T': /* Toggle newfs state */
- if (label_chunk_info[here].type == PART_FILESYSTEM) {
- PartInfo *pi = ((PartInfo *)label_chunk_info[here].c->private_data);
- label_chunk_info[here].c->private_data =
- new_part(pi ? pi->mountpoint : NULL, pi ? !pi->newfs : TRUE, label_chunk_info[here].c->size);
- safe_free(pi);
- label_chunk_info[here].c->private_free = safe_free;
- if (((cp = variable_get(DISK_LABELLED)) == NULL) || (strcmp(cp, "written")))
- variable_set2(DISK_LABELLED, "yes", 0);
- }
- else
- msg = MSG_NOT_APPLICABLE;
- break;
-
- case 'U':
- clear();
- if ((cp = variable_get(DISK_LABELLED)) && !strcmp(cp, "written")) {
- msgConfirm("You've already written out your changes -\n"
- "it's too late to undo!");
- }
- else if (!msgYesNo("Are you SURE you want to Undo everything?")) {
- variable_unset(DISK_PARTITIONED);
- variable_unset(DISK_LABELLED);
- for (i = 0; devs[i]; i++) {
- Disk *d;
-
- if (!devs[i]->enabled)
- continue;
- else if ((d = Open_Disk(devs[i]->name)) != NULL) {
- Free_Disk(devs[i]->private);
- devs[i]->private = d;
- diskPartition(devs[i]);
- }
- }
- record_label_chunks(devs, dev);
- }
- clear_wins();
- break;
-
- case 'W':
- if ((cp = variable_get(DISK_LABELLED)) && !strcmp(cp, "written")) {
- msgConfirm("You've already written out your changes - if you\n"
- "wish to overwrite them, you'll have to start this\n"
- "procedure again from the beginning.");
- }
- else if (!msgYesNo("WARNING: This should only be used when modifying an EXISTING\n"
- "installation. If you are installing FreeBSD for the first time\n"
- "then you should simply type Q when you're finished here and your\n"
- "changes will be committed in one batch automatically at the end of\n"
- "these questions.\n\n"
- "Are you absolutely sure you want to do this now?")) {
- variable_set2(DISK_LABELLED, "yes", 0);
- diskLabelCommit(NULL);
- }
- clear_wins();
- break;
-
- case '|':
- if (!msgYesNo("Are you sure you want to go into Wizard mode?\n\n"
- "This is an entirely undocumented feature which you are not\n"
- "expected to understand!")) {
- int i;
- Device **devs;
-
- dialog_clear();
- end_dialog();
- DialogActive = FALSE;
- devs = deviceFind(NULL, DEVICE_TYPE_DISK);
- if (!devs) {
- msgConfirm("Can't find any disk devices!");
- break;
- }
- for (i = 0; devs[i] && ((Disk *)devs[i]->private); i++) {
- if (devs[i]->enabled)
- slice_wizard(((Disk *)devs[i]->private));
- }
- if (((cp = variable_get(DISK_LABELLED)) == NULL) || (strcmp(cp, "written")))
- variable_set2(DISK_LABELLED, "yes", 0);
- DialogActive = TRUE;
- record_label_chunks(devs, dev);
- clear_wins();
- }
- else
- msg = "A most prudent choice!";
- break;
-
- case '\033': /* ESC */
- case 'Q':
- labeling = FALSE;
- break;
-
- default:
- beep();
- sprintf(_msg, "Invalid key %d - Type F1 or ? for help", key);
- msg = _msg;
- break;
- }
- if (label_chunk_info[here].type == PART_SLICE)
- pslice_focus = here;
- else
- label_focus = here;
- }
- restorescr(w);
- return DITEM_SUCCESS;
-}
-
-static int
-diskLabelNonInteractive(Device *dev)
-{
- char *cp;
- PartType type;
- PartInfo *p;
- u_long flags = 0;
- int i, status;
- Device **devs;
- Disk *d;
-
- status = DITEM_SUCCESS;
- cp = variable_get(VAR_DISK);
- if (!cp) {
- msgConfirm("diskLabel: No disk selected - can't label automatically.");
- return DITEM_FAILURE;
- }
- devs = deviceFind(cp, DEVICE_TYPE_DISK);
- if (!devs) {
- msgConfirm("diskLabel: No disk device %s found!", cp);
- return DITEM_FAILURE;
- }
- if (dev)
- d = dev->private;
- else
- d = devs[0]->private;
-#ifdef __alpha__
- maybe_dedicate(d);
-#endif
- record_label_chunks(devs, dev);
- for (i = 0; label_chunk_info[i].c; i++) {
- Chunk *c1 = label_chunk_info[i].c;
-
- if (label_chunk_info[i].type == PART_SLICE) {
- char name[512];
- int entries = 1;
-
- while (entries) {
- snprintf(name, sizeof name, "%s-%d", c1->name, entries);
- if ((cp = variable_get(name)) != NULL) {
- int sz;
- char typ[10], mpoint[50];
-
- if (sscanf(cp, "%s %d %s", typ, &sz, mpoint) != 3) {
- msgConfirm("For slice entry %s, got an invalid detail entry of: %s", c1->name, cp);
- status = DITEM_FAILURE;
- continue;
- }
- else {
- Chunk *tmp;
-
- if (!strcmp(typ, "swap")) {
- type = PART_SWAP;
- strcpy(mpoint, "SWAP");
- }
- else {
- type = PART_FILESYSTEM;
- if (!strcmp(mpoint, "/"))
- flags |= CHUNK_IS_ROOT;
- else
- flags &= ~CHUNK_IS_ROOT;
- }
- if (!sz)
- sz = space_free(c1);
- if (sz > space_free(c1)) {
- msgConfirm("Not enough free space to create partition: %s", mpoint);
- status = DITEM_FAILURE;
- continue;
- }
- if (!(tmp = Create_Chunk_DWIM(d, c1, sz, part,
- (type == PART_SWAP) ? FS_SWAP : FS_BSDFFS, flags))) {
- msgConfirm("Unable to create from partition spec: %s. Too big?", cp);
- status = DITEM_FAILURE;
- break;
- }
- else {
- tmp->private_data = new_part(mpoint, TRUE, sz);
- tmp->private_free = safe_free;
- status = DITEM_SUCCESS;
- }
- }
- entries++;
- }
- else {
- /* No more matches, leave the loop */
- entries = 0;
- }
- }
- }
- else {
- /* Must be something we can set a mountpoint for */
- cp = variable_get(c1->name);
- if (cp) {
- char mpoint[50], do_newfs[8];
- Boolean newfs = FALSE;
-
- do_newfs[0] = '\0';
- if (sscanf(cp, "%s %s", mpoint, do_newfs) != 2) {
- msgConfirm("For slice entry %s, got an invalid detail entry of: %s", c1->name, cp);
- status = DITEM_FAILURE;
- continue;
- }
- newfs = toupper(do_newfs[0]) == 'Y' ? TRUE : FALSE;
- if (c1->private_data) {
- p = c1->private_data;
- p->newfs = newfs;
- strcpy(p->mountpoint, mpoint);
- }
- else {
- c1->private_data = new_part(mpoint, newfs, 0);
- c1->private_free = safe_free;
- }
- if (!strcmp(mpoint, "/"))
- c1->flags |= CHUNK_IS_ROOT;
- else
- c1->flags &= ~CHUNK_IS_ROOT;
- }
- }
- }
- if (status == DITEM_SUCCESS)
- variable_set2(DISK_LABELLED, "yes", 0);
- return status;
-}
diff --git a/usr.sbin/sysinstall/list.h b/usr.sbin/sysinstall/list.h
deleted file mode 100644
index 8300173e0660..000000000000
--- a/usr.sbin/sysinstall/list.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last attempt in the `sysinstall' line, the next
- * generation being slated for what's essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1997 FreeBSD, Inc.
- * 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 PAUL TRAINA ``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 PAUL TRAINA OR HIS KILLER RATS 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, LIFE 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.
- *
- */
-
-/* The structure */
-typedef struct _qelement {
- struct _qelement *q_forw;
- struct _qelement *q_back;
-} qelement;
-
-#define INITQUE(Xhead) { \
- (Xhead).q_forw = &(Xhead); \
- (Xhead).q_back = &(Xhead); \
-}
-
-#define EMPTYQUE(Xhead) \
- ((Xhead).q_forw == &(Xhead))
-
-#define INSQUEUE(elem, pred) { \
- register qelement *Xe = (qelement *) (elem); \
- register qelement *Xp = (qelement *) (pred); \
- Xp->q_forw = (Xe->q_forw = (Xe->q_back = Xp)->q_forw)->q_back = Xe; \
-}
-
-#define REMQUE(elem) { \
- register qelement *Xe = (qelement *) (elem); \
- (Xe->q_back->q_forw = Xe->q_forw)->q_back = Xe->q_back; \
-}
diff --git a/usr.sbin/sysinstall/main.c b/usr.sbin/sysinstall/main.c
deleted file mode 100644
index 885b6cb1b453..000000000000
--- a/usr.sbin/sysinstall/main.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last attempt in the `sysinstall' line, the next
- * generation being slated for what's essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 "sysinstall.h"
-#include <sys/signal.h>
-#include <sys/fcntl.h>
-
-static void
-screech(int sig)
-{
- msgDebug("\007Signal %d caught! That's bad!\n", sig);
- longjmp(BailOut, sig);
-}
-
-int
-main(int argc, char **argv)
-{
- int choice, scroll, curr, max, status;
-
- /* Catch fatal signals and complain about them if running as init */
- if (getpid() == 1) {
- signal(SIGBUS, screech);
- signal(SIGSEGV, screech);
- }
- signal(SIGPIPE, SIG_IGN);
-
- /* We don't work too well when running as non-root anymore */
- if (geteuid() != 0) {
- fprintf(stderr, "Error: This utility should only be run as root.\n");
- return 1;
- }
-
- /* Set up whatever things need setting up */
- systemInitialize(argc, argv);
-
- /* Set default flag and variable values */
- installVarDefaults(NULL);
- /* only when multi-user is it reasonable to do this here */
- if (!RunningAsInit)
- installEnvironment();
-
- if (argc > 1 && !strcmp(argv[1], "-fake")) {
- variable_set2(VAR_DEBUG, "YES", 0);
- Fake = TRUE;
- msgConfirm("I'll be just faking it from here on out, OK?");
- }
-
- /* Try to preserve our scroll-back buffer */
- if (OnVTY) {
- for (curr = 0; curr < 25; curr++)
- putchar('\n');
- }
- /* Move stderr aside */
- if (DebugFD)
- dup2(DebugFD, 2);
-
- /* Initialize PC-card */
- pccardInitialize();
-
- /* Probe for all relevant devices on the system */
- deviceGetAll();
-
- /* First, see if we have any arguments to process (and argv[0] counts if it's not "sysinstall") */
- if (!RunningAsInit) {
- int i, start_arg;
-
- if (!strstr(argv[0], "sysinstall"))
- start_arg = 0;
- else if (Fake)
- start_arg = 2;
- else
- start_arg = 1;
- for (i = start_arg; i < argc; i++) {
- if (DITEM_STATUS(dispatchCommand(argv[i])) != DITEM_SUCCESS)
- systemShutdown(1);
- }
- if (argc > start_arg)
- systemShutdown(0);
- }
- else
- dispatch_load_file_int(TRUE);
-
- status = setjmp(BailOut);
- if (status) {
- msgConfirm("A signal %d was caught - I'm saving what I can and shutting\n"
- "If you can reproduce the problem, please turn Debug on in\n"
- "the Options menu for the extra information it provides in\n"
- "debugging problems like this.", status);
- systemShutdown(status);
- }
-
- /* Begin user dialog at outer menu */
- dialog_clear();
- while (1) {
- choice = scroll = curr = max = 0;
- dmenuOpen(&MenuInitial, &choice, &scroll, &curr, &max, TRUE);
- if (getpid() != 1
-#ifdef __alpha__
- || !msgYesNo("Are you sure you wish to exit? The system will halt.")
-#else
- || !msgYesNo("Are you sure you wish to exit? The system will reboot\n"
- "(be sure to remove any floppies/CDROMs from the drives).")
-#endif
- )
- break;
- }
-
- /* Say goodnight, Gracie */
- systemShutdown(0);
-
- return 0; /* We should never get here */
-}
diff --git a/usr.sbin/sysinstall/media.c b/usr.sbin/sysinstall/media.c
deleted file mode 100644
index 806cb4c53a22..000000000000
--- a/usr.sbin/sysinstall/media.c
+++ /dev/null
@@ -1,834 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last attempt in the `sysinstall' line, the next
- * generation being slated to essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 "sysinstall.h"
-#include <signal.h>
-#include <netdb.h>
-#include <sys/socket.h>
-#include <sys/param.h>
-#include <sys/mount.h>
-#include <sys/errno.h>
-#include <sys/fcntl.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <sys/wait.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <resolv.h>
-
-static Boolean got_intr = FALSE;
-
-/* timeout handler */
-static void
-handle_intr(int sig)
-{
- msgDebug("User generated interrupt.\n");
- got_intr = TRUE;
-}
-
-static int
-check_for_interrupt(void)
-{
- if (got_intr) {
- got_intr = FALSE;
- return TRUE;
- }
- return FALSE;
-}
-
-static int
-genericHook(dialogMenuItem *self, DeviceType type)
-{
- Device **devs;
-
- devs = deviceFind(self->prompt, type);
- if (devs)
- mediaDevice = devs[0];
- return (devs ? DITEM_LEAVE_MENU : DITEM_FAILURE);
-}
-
-static int
-cdromHook(dialogMenuItem *self)
-{
- return genericHook(self, DEVICE_TYPE_CDROM);
-}
-
-static void
-kickstart_dns(void)
-{
- static Boolean initted = FALSE;
- int time;
- char *cp;
-
- cp = variable_get(VAR_MEDIA_TIMEOUT);
- if (!cp)
- time = MEDIA_TIMEOUT;
- else
- time = atoi(cp);
- if (!time)
- time = 100;
- if (!initted) {
- res_init();
- _res.retry = 2; /* 2 times seems a reasonable number to me */
- _res.retrans = time / 2; /* so spend half our alloted time on each try */
- initted = TRUE;
- }
-}
-
-char *
-cpioVerbosity()
-{
- char *cp = variable_get(VAR_CPIO_VERBOSITY);
-
- if (cp && !strcmp(cp, "high"))
- return "-v";
- else if (cp && !strcmp(cp, "medium"))
- return "-V";
- return "";
-}
-
-void
-mediaClose(void)
-{
- if (mediaDevice)
- mediaDevice->shutdown(mediaDevice);
- mediaDevice = NULL;
-}
-
-/*
- * Return 1 if we successfully found and set the installation type to
- * be a CD.
- */
-int
-mediaSetCDROM(dialogMenuItem *self)
-{
- Device **devs;
- int cnt;
-
- mediaClose();
- devs = deviceFind(NULL, DEVICE_TYPE_CDROM);
- cnt = deviceCount(devs);
- if (!cnt) {
- if (self) /* Interactive? */
- msgConfirm("No CDROM devices found! Please check that your system's\n"
- "configuration is correct and that the CDROM drive is of a supported\n"
- "type. For more information, consult the hardware guide\n"
- "in the Doc menu.");
- return DITEM_FAILURE | DITEM_CONTINUE;
- }
- else if (cnt > 1) {
- DMenu *menu;
- int status;
-
- menu = deviceCreateMenu(&MenuMediaCDROM, DEVICE_TYPE_CDROM, cdromHook, NULL);
- if (!menu)
- msgFatal("Unable to create CDROM menu! Something is seriously wrong.");
- status = dmenuOpenSimple(menu, FALSE);
- free(menu);
- if (!status)
- return DITEM_FAILURE;
- }
- else
- mediaDevice = devs[0];
- return (mediaDevice ? DITEM_SUCCESS | DITEM_LEAVE_MENU : DITEM_FAILURE);
-}
-
-static int
-floppyHook(dialogMenuItem *self)
-{
- return genericHook(self, DEVICE_TYPE_FLOPPY);
-}
-
-/*
- * Return 1 if we successfully found and set the installation type to
- * be a floppy
- */
-int
-mediaSetFloppy(dialogMenuItem *self)
-{
- Device **devs;
- int cnt;
-
- mediaClose();
- devs = deviceFind(NULL, DEVICE_TYPE_FLOPPY);
- cnt = deviceCount(devs);
- if (!cnt) {
- msgConfirm("No floppy devices found! Please check that your system's configuration\n"
- "is correct. For more information, consult the hardware guide in the Doc\n"
- "menu.");
- return DITEM_FAILURE | DITEM_CONTINUE;
- }
- else if (cnt > 1) {
- DMenu *menu;
- int status;
-
- menu = deviceCreateMenu(&MenuMediaFloppy, DEVICE_TYPE_FLOPPY, floppyHook, NULL);
- if (!menu)
- msgFatal("Unable to create Floppy menu! Something is seriously wrong.");
- status = dmenuOpenSimple(menu, FALSE);
- free(menu);
- if (!status)
- return DITEM_FAILURE;
- }
- else
- mediaDevice = devs[0];
- if (mediaDevice)
- mediaDevice->private = NULL;
- return (mediaDevice ? DITEM_LEAVE_MENU : DITEM_FAILURE);
-}
-
-static int
-DOSHook(dialogMenuItem *self)
-{
- return genericHook(self, DEVICE_TYPE_DOS);
-}
-
-/*
- * Return 1 if we successfully found and set the installation type to
- * be a DOS partition.
- */
-int
-mediaSetDOS(dialogMenuItem *self)
-{
- Device **devs;
- int cnt;
-
- mediaClose();
- devs = deviceFind(NULL, DEVICE_TYPE_DOS);
- cnt = deviceCount(devs);
- if (!cnt) {
- msgConfirm("No DOS primary partitions found! This installation method is unavailable");
- return DITEM_FAILURE | DITEM_CONTINUE;
- }
- else if (cnt > 1) {
- DMenu *menu;
- int status;
-
- menu = deviceCreateMenu(&MenuMediaDOS, DEVICE_TYPE_DOS, DOSHook, NULL);
- if (!menu)
- msgFatal("Unable to create DOS menu! Something is seriously wrong.");
- status = dmenuOpenSimple(menu, FALSE);
- free(menu);
- if (!status)
- return DITEM_FAILURE;
- }
- else
- mediaDevice = devs[0];
- return (mediaDevice ? DITEM_LEAVE_MENU : DITEM_FAILURE);
-}
-
-static int
-tapeHook(dialogMenuItem *self)
-{
- return genericHook(self, DEVICE_TYPE_TAPE);
-}
-
-/*
- * Return 1 if we successfully found and set the installation type to
- * be a tape drive.
- */
-int
-mediaSetTape(dialogMenuItem *self)
-{
- Device **devs;
- int cnt;
-
- mediaClose();
- devs = deviceFind(NULL, DEVICE_TYPE_TAPE);
- cnt = deviceCount(devs);
- if (!cnt) {
- msgConfirm("No tape drive devices found! Please check that your system's configuration\n"
- "is correct. For more information, consult the hardware guide in the Doc\n"
- "menu.");
- return DITEM_FAILURE | DITEM_CONTINUE;
- }
- else if (cnt > 1) {
- DMenu *menu;
- int status;
-
- menu = deviceCreateMenu(&MenuMediaTape, DEVICE_TYPE_TAPE, tapeHook, NULL);
- if (!menu)
- msgFatal("Unable to create tape drive menu! Something is seriously wrong.");
- status = dmenuOpenSimple(menu, FALSE);
- free(menu);
- if (!status)
- return DITEM_FAILURE;
- }
- else
- mediaDevice = devs[0];
- if (mediaDevice) {
- char *val;
-
- val = msgGetInput("/usr/tmp", "Please enter the name of a temporary directory containing\n"
- "sufficient space for holding the contents of this tape (or\n"
- "tapes). The contents of this directory will be removed\n"
- "after installation, so be sure to specify a directory that\n"
- "can be erased afterwards!\n");
- if (!val)
- mediaDevice = NULL;
- else
- mediaDevice->private = strdup(val);
- }
- return (mediaDevice ? DITEM_LEAVE_MENU : DITEM_FAILURE);
-}
-
-/*
- * Return 0 if we successfully found and set the installation type to
- * be an ftp server
- */
-int
-mediaSetFTP(dialogMenuItem *self)
-{
- static Device ftpDevice;
- char *cp, hostname[MAXHOSTNAMELEN], *dir;
- extern int FtpPort;
- static Device *networkDev = NULL;
-
- mediaClose();
- cp = variable_get(VAR_FTP_PATH);
- /* If we've been through here before ... */
- if (!variable_get(VAR_NONINTERACTIVE))
- if (networkDev && cp && msgYesNo("Re-use old FTP site selection values?"))
- cp = NULL;
-
- if (!cp) {
- if (!dmenuOpenSimple(&MenuMediaFTP, FALSE))
- return DITEM_FAILURE;
- else
- cp = variable_get(VAR_FTP_PATH);
- }
- if (!cp)
- return DITEM_FAILURE;
- else if (!strcmp(cp, "other")) {
- variable_set2(VAR_FTP_PATH, "ftp://", 0);
- cp = variable_get_value(VAR_FTP_PATH, "Please specify the URL of a FreeBSD distribution on a\n"
- "remote ftp site. This site must accept either anonymous\n"
- "ftp or you should have set an ftp username and password\n"
- "in the Options screen.\n\n"
- "A URL looks like this: ftp://<hostname>/<path>\n"
- "Where <path> is relative to the anonymous ftp directory or the\n"
- "home directory of the user being logged in as.", 0);
- if (!cp || !*cp || !strcmp(cp, "ftp://")) {
- variable_unset(VAR_FTP_PATH);
- return DITEM_FAILURE;
- }
- }
- if (strncmp("ftp://", cp, 6)) {
- msgConfirm("Sorry, %s is an invalid URL!", cp);
- variable_unset(VAR_FTP_PATH);
- return DITEM_FAILURE;
- }
- SAFE_STRCPY(ftpDevice.name, cp);
- SAFE_STRCPY(hostname, cp + 6);
-
- if (!networkDev || msgYesNo("You've already done the network configuration once,\n"
- "would you like to skip over it now?") != 0) {
- if (networkDev)
- networkDev->shutdown(networkDev);
- if (!(networkDev = tcpDeviceSelect())) {
- variable_unset(VAR_FTP_PATH);
- return DITEM_FAILURE;
- }
- }
- if (!networkDev->init(networkDev)) {
- if (isDebug())
- msgDebug("mediaSetFTP: Net device init failed.\n");
- variable_unset(VAR_FTP_PATH);
- return DITEM_FAILURE;
- }
- if ((cp = index(hostname, ':')) != NULL) {
- *(cp++) = '\0';
- FtpPort = strtol(cp, 0, 0);
- }
- else
- FtpPort = 21;
- if ((dir = index(cp ? cp : hostname, '/')) != NULL)
- *(dir++) = '\0';
- if (isDebug()) {
- msgDebug("hostname = `%s'\n", hostname);
- msgDebug("dir = `%s'\n", dir ? dir : "/");
- msgDebug("port # = `%d'\n", FtpPort);
- }
- if (variable_get(VAR_NAMESERVER)) {
- msgNotify("Looking up host %s.", hostname);
- if (isDebug())
- msgDebug("Starting DNS.\n");
- kickstart_dns();
- if (isDebug())
- msgDebug("Looking up hostname, %s, using inet_addr().\n", hostname);
- if (inet_addr(hostname) == INADDR_NONE) {
- if (isDebug())
- msgDebug("Looking up hostname, %s, using gethostbyname().\n",
- hostname);
- if (gethostbyname(hostname) == NULL) {
- msgConfirm("Cannot resolve hostname `%s'! Are you sure that"
- " your\nname server, gateway and network interface are"
- " correctly configured?", hostname);
- if (networkDev)
- networkDev->shutdown(networkDev);
- networkDev = NULL;
- variable_unset(VAR_FTP_PATH);
- return DITEM_FAILURE;
- }
- }
- if (isDebug())
- msgDebug("Found DNS entry for %s successfully..\n", hostname);
- }
- variable_set2(VAR_FTP_HOST, hostname, 0);
- variable_set2(VAR_FTP_DIR, dir ? dir : "/", 0);
- variable_set2(VAR_FTP_PORT, itoa(FtpPort), 0);
- ftpDevice.type = DEVICE_TYPE_FTP;
- ftpDevice.init = mediaInitFTP;
- ftpDevice.get = mediaGetFTP;
- ftpDevice.shutdown = mediaShutdownFTP;
- ftpDevice.private = networkDev;
- mediaDevice = &ftpDevice;
- return DITEM_SUCCESS | DITEM_LEAVE_MENU | DITEM_RESTORE;
-}
-
-int
-mediaSetFTPActive(dialogMenuItem *self)
-{
- variable_set2(VAR_FTP_STATE, "active", 0);
- return mediaSetFTP(self);
-}
-
-int
-mediaSetFTPPassive(dialogMenuItem *self)
-{
- variable_set2(VAR_FTP_STATE, "passive", 0);
- return mediaSetFTP(self);
-}
-
-int mediaSetHTTP(dialogMenuItem *self)
-{
- int result;
- char *cp, *idx, hostname[MAXHOSTNAMELEN];
- extern int HttpPort;
- int what = DITEM_RESTORE;
-
-
- result = mediaSetFTP(self);
- if (DITEM_STATUS(result) != DITEM_SUCCESS)
- return result;
-
- cp = variable_get_value(VAR_HTTP_PATH,
- "Please enter the address of the HTTP proxy in this format:\n"
- " hostname:port (the ':port' is optional, default is 3128)",0);
- if (!cp)
- return DITEM_FAILURE;
- SAFE_STRCPY(hostname, cp);
- if (!(idx = index(hostname, ':')))
- HttpPort = 3128; /* try this as default */
- else {
- *(idx++) = '\0';
- HttpPort = strtol(idx, 0, 0);
- }
-
- variable_set2(VAR_HTTP_HOST, hostname, 0);
- variable_set2(VAR_HTTP_PORT, itoa(HttpPort), 0);
- if (isDebug()) {
- msgDebug("VAR_FTP_PATH : %s",variable_get(VAR_FTP_PATH));
- msgDebug("VAR_HTTP_HOST, _PORT: %s:%s",variable_get(VAR_HTTP_HOST),
- variable_get(VAR_HTTP_PORT));
- }
-
- /* mediaDevice has been set by mediaSetFTP(), overwrite partly: */
- mediaDevice->type = DEVICE_TYPE_HTTP;
- mediaDevice->init = mediaInitHTTP;
- mediaDevice->get = mediaGetHTTP;
- mediaDevice->shutdown = dummyShutdown;
- return DITEM_SUCCESS | DITEM_LEAVE_MENU | what;
-}
-
-
-int
-mediaSetUFS(dialogMenuItem *self)
-{
- static Device ufsDevice;
- struct statfs st;
- char *cp;
-
- mediaClose();
- cp = variable_get_value(VAR_UFS_PATH, "Enter a fully qualified pathname for the directory\n"
- "containing the FreeBSD distribution files:", 0);
- if (!cp)
- return DITEM_FAILURE;
-
- /* If they gave us a CDROM or something, try and pick a better name */
- if (statfs(cp, &st))
- strcpy(ufsDevice.name, "ufs");
- else
- strcpy(ufsDevice.name, st.f_fstypename);
-
- ufsDevice.type = DEVICE_TYPE_UFS;
- ufsDevice.init = dummyInit;
- ufsDevice.get = mediaGetUFS;
- ufsDevice.shutdown = dummyShutdown;
- ufsDevice.private = strdup(cp);
- mediaDevice = &ufsDevice;
- return DITEM_LEAVE_MENU;
-}
-
-int
-mediaSetNFS(dialogMenuItem *self)
-{
- static Device nfsDevice;
- static Device *networkDev = NULL;
- char *cp, *idx;
- char hostname[MAXPATHLEN];
-
- mediaClose();
- cp = variable_get_value(VAR_NFS_PATH, "Please enter the full NFS file specification for the remote\n"
- "host and directory containing the FreeBSD distribution files.\n"
- "This should be in the format: hostname:/some/freebsd/dir", 0);
- if (!cp)
- return DITEM_FAILURE;
- SAFE_STRCPY(hostname, cp);
- if (!(idx = index(hostname, ':'))) {
- msgConfirm("Invalid NFS path specification. Must be of the form:\n"
- "host:/full/pathname/to/FreeBSD/distdir");
- return DITEM_FAILURE;
- }
- SAFE_STRCPY(nfsDevice.name, hostname);
- *idx = '\0';
- if (!networkDev || msgYesNo("You've already done the network configuration once,\n"
- "would you like to skip over it now?") != 0) {
- if (networkDev)
- networkDev->shutdown(networkDev);
- if (!(networkDev = tcpDeviceSelect()))
- return DITEM_FAILURE;
- }
- if (!networkDev->init(networkDev)) {
- if (isDebug())
- msgDebug("mediaSetNFS: Net device init failed\n");
- }
- if (variable_get(VAR_NAMESERVER)) {
- kickstart_dns();
- if ((inet_addr(hostname) == INADDR_NONE) && (gethostbyname(hostname) == NULL)) {
- msgConfirm("Cannot resolve hostname `%s'! Are you sure that your\n"
- "name server, gateway and network interface are correctly configured?", hostname);
- if (networkDev)
- networkDev->shutdown(networkDev);
- networkDev = NULL;
- variable_unset(VAR_NFS_PATH);
- return DITEM_FAILURE;
- }
- else {
- if (isDebug())
- msgDebug("Found DNS entry for %s successfully..", hostname);
- }
- }
- variable_set2(VAR_NFS_HOST, hostname, 0);
- nfsDevice.type = DEVICE_TYPE_NFS;
- nfsDevice.init = mediaInitNFS;
- nfsDevice.get = mediaGetNFS;
- nfsDevice.shutdown = mediaShutdownNFS;
- nfsDevice.private = networkDev;
- mediaDevice = &nfsDevice;
- return DITEM_LEAVE_MENU;
-}
-
-Boolean
-mediaExtractDistBegin(char *dir, int *fd, int *zpid, int *cpid)
-{
- int i, pfd[2],qfd[2];
-
- if (!dir)
- dir = "/";
- Mkdir(dir);
- chdir(dir);
- pipe(pfd);
- pipe(qfd);
- *zpid = fork();
- if (!*zpid) {
- char *gunzip = RunningAsInit ? "/stand/gunzip" : "/usr/bin/gunzip";
-
- dup2(qfd[0], 0); close(qfd[0]);
- dup2(pfd[1], 1); close(pfd[1]);
- if (DebugFD != -1)
- dup2(DebugFD, 2);
- else {
- close(2);
- open("/dev/null", O_WRONLY);
- }
- close(qfd[1]);
- close(pfd[0]);
- i = execl(gunzip, gunzip, 0);
- if (isDebug())
- msgDebug("%s command returns %d status\n", gunzip, i);
- exit(i);
- }
- *fd = qfd[1];
- close(qfd[0]);
- *cpid = fork();
- if (!*cpid) {
- char *cpio = RunningAsInit ? "/stand/cpio" : "/usr/bin/cpio";
-
- dup2(pfd[0], 0); close(pfd[0]);
- close(pfd[1]);
- close(qfd[1]);
- if (DebugFD != -1) {
- dup2(DebugFD, 1);
- dup2(DebugFD, 2);
- }
- else {
- close(1); open("/dev/null", O_WRONLY);
- dup2(1, 2);
- }
- if (strlen(cpioVerbosity()))
- i = execl(cpio, cpio, "-idum", cpioVerbosity(), "--block-size", mediaTapeBlocksize(), 0);
- else
- i = execl(cpio, cpio, "-idum", "--block-size", mediaTapeBlocksize(), 0);
- if (isDebug())
- msgDebug("%s command returns %d status\n", cpio, i);
- exit(i);
- }
- close(pfd[0]);
- close(pfd[1]);
- return TRUE;
-}
-
-Boolean
-mediaExtractDistEnd(int zpid, int cpid)
-{
- int i,j;
-
- i = waitpid(zpid, &j, 0);
- /* Don't check exit status - gunzip seems to return a bogus one! */
- if (i < 0) {
- if (isDebug())
- msgDebug("wait for gunzip returned status of %d!\n", i);
- return FALSE;
- }
- i = waitpid(cpid, &j, 0);
- if (i < 0 || WEXITSTATUS(j)) {
- if (isDebug())
- msgDebug("cpio returned error status of %d!\n", WEXITSTATUS(j));
- return FALSE;
- }
- return TRUE;
-}
-
-Boolean
-mediaExtractDist(char *dir, char *dist, FILE *fp)
-{
- int i, j, total, seconds, zpid, cpid, pfd[2], qfd[2];
- char buf[BUFSIZ];
- struct timeval start, stop;
- struct sigaction new, old;
-
- if (!dir)
- dir = "/";
-
- Mkdir(dir);
- chdir(dir);
- pipe(pfd); /* read end */
- pipe(qfd); /* write end */
- zpid = fork();
- if (!zpid) {
- char *gunzip = RunningAsInit ? "/stand/gunzip" : "/usr/bin/gunzip";
-
- fclose(fp);
- close(qfd[1]);
- dup2(qfd[0], 0); close(qfd[0]);
-
- close(pfd[0]);
- dup2(pfd[1], 1); close(pfd[1]);
-
- if (DebugFD != -1)
- dup2(DebugFD, 2);
- else {
- close(2);
- open("/dev/null", O_WRONLY);
- }
- i = execl(gunzip, gunzip, 0);
- if (isDebug())
- msgDebug("%s command returns %d status\n", gunzip, i);
- exit(i);
- }
- cpid = fork();
- if (!cpid) {
- char *cpio = RunningAsInit ? "/stand/cpio" : "/usr/bin/cpio";
-
- close(pfd[1]);
- dup2(pfd[0], 0); close(pfd[0]);
- close (qfd[0]); close(qfd[1]);
- fclose(fp);
- if (DebugFD != -1) {
- dup2(DebugFD, 1);
- dup2(DebugFD, 2);
- }
- else {
- dup2(open("/dev/null", O_WRONLY), 1);
- dup2(1, 2);
- }
- if (strlen(cpioVerbosity()))
- i = execl(cpio, cpio, "-idum", cpioVerbosity(), "--block-size", mediaTapeBlocksize(), 0);
- else
- i = execl(cpio, cpio, "-idum", "--block-size", mediaTapeBlocksize(), 0);
- if (isDebug())
- msgDebug("%s command returns %d status\n", cpio, i);
- exit(i);
- }
- close(pfd[0]); close(pfd[1]);
- close(qfd[0]);
-
- total = 0;
- (void)gettimeofday(&start, (struct timezone *)0);
-
- /* Make ^C abort the current transfer rather than the whole show */
- new.sa_handler = handle_intr;
- new.sa_flags = 0;
- (void)sigemptyset(&new.sa_mask);
- sigaction(SIGINT, &new, &old);
-
- while ((i = fread(buf, 1, BUFSIZ, fp)) > 0) {
- if (check_for_interrupt()) {
- msgConfirm("Failure to read from media: User interrupt.");
- break;
- }
- if (write(qfd[1], buf, i) != i) {
- msgConfirm("Write error on transfer to cpio process, try of %d bytes.", i);
- break;
- }
- else {
- (void)gettimeofday(&stop, (struct timezone *)0);
- stop.tv_sec = stop.tv_sec - start.tv_sec;
- stop.tv_usec = stop.tv_usec - start.tv_usec;
- if (stop.tv_usec < 0)
- stop.tv_sec--, stop.tv_usec += 1000000;
- seconds = stop.tv_sec + (stop.tv_usec / 1000000.0);
- if (!seconds)
- seconds = 1;
- total += i;
- msgInfo("%10d bytes read from %s dist @ %.1f KB/sec.",
- total, dist, (total / seconds) / 1024.0);
- }
- }
- sigaction(SIGINT, &old, NULL); /* restore sigint */
- close(qfd[1]);
-
- i = waitpid(zpid, &j, 0);
- /* Don't check exit status - gunzip seems to return a bogus one! */
- if (i < 0) {
- if (isDebug())
- msgDebug("wait for gunzip returned status of %d!\n", i);
- return FALSE;
- }
- i = waitpid(cpid, &j, 0);
- if (i < 0 || WEXITSTATUS(j)) {
- if (isDebug())
- msgDebug("cpio returned error status of %d!\n", WEXITSTATUS(j));
- return FALSE;
- }
- return TRUE;
-}
-
-int
-mediaGetType(dialogMenuItem *self)
-{
- return ((dmenuOpenSimple(&MenuMedia, FALSE) && mediaDevice) ? DITEM_SUCCESS : DITEM_FAILURE);
-}
-
-/* Return TRUE if all the media variables are set up correctly */
-Boolean
-mediaVerify(void)
-{
- if (!mediaDevice)
- return (DITEM_STATUS(mediaGetType(NULL)) == DITEM_SUCCESS);
- return TRUE;
-}
-
-/* Set the FTP username and password fields */
-int
-mediaSetFTPUserPass(dialogMenuItem *self)
-{
- char *pass;
-
- if (variable_get_value(VAR_FTP_USER, "Please enter the username you wish to login as:", 0)) {
- DialogInputAttrs |= DITEM_NO_ECHO;
- pass = variable_get_value(VAR_FTP_PASS, "Please enter the password for this user:", 0);
- DialogInputAttrs &= ~DITEM_NO_ECHO;
- }
- else
- pass = NULL;
- return (pass ? DITEM_SUCCESS : DITEM_FAILURE);
-}
-
-/* Set CPIO verbosity level */
-int
-mediaSetCPIOVerbosity(dialogMenuItem *self)
-{
- char *cp = variable_get(VAR_CPIO_VERBOSITY);
-
- if (!cp) {
- msgConfirm("CPIO Verbosity is not set to anything!");
- return DITEM_FAILURE;
- }
- else {
- if (!strcmp(cp, "low"))
- variable_set2(VAR_CPIO_VERBOSITY, "medium", 0);
- else if (!strcmp(cp, "medium"))
- variable_set2(VAR_CPIO_VERBOSITY, "high", 0);
- else /* must be "high" - wrap around */
- variable_set2(VAR_CPIO_VERBOSITY, "low", 0);
- }
- return DITEM_SUCCESS;
-}
-
-/* A generic open which follows a well-known "path" of places to look */
-FILE *
-mediaGenericGet(char *base, const char *file)
-{
- char buf[PATH_MAX];
-
- snprintf(buf, PATH_MAX, "%s/%s", base, file);
- if (file_readable(buf))
- return fopen(buf, "r");
- snprintf(buf, PATH_MAX, "%s/FreeBSD/%s", base, file);
- if (file_readable(buf))
- return fopen(buf, "r");
- snprintf(buf, PATH_MAX, "%s/releases/%s", base, file);
- if (file_readable(buf))
- return fopen(buf, "r");
- snprintf(buf, PATH_MAX, "%s/%s/%s", base, variable_get(VAR_RELNAME), file);
- if (file_readable(buf))
- return fopen(buf, "r");
- snprintf(buf, PATH_MAX, "%s/releases/%s/%s", base, variable_get(VAR_RELNAME), file);
- return fopen(buf, "r");
-}
-
diff --git a/usr.sbin/sysinstall/menus.c b/usr.sbin/sysinstall/menus.c
deleted file mode 100644
index 8bc27bab4261..000000000000
--- a/usr.sbin/sysinstall/menus.c
+++ /dev/null
@@ -1,1630 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last program in the `sysinstall' line - the next
- * generation being essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 "sysinstall.h"
-
-#ifdef __alpha__
-#define _AS(str) str "alpha/"
-#else /* i386 */
-#define _AS(str) str "i386/"
-#endif
-#define _AP(str) _AS(str "/pub/FreeBSD/releases/")
-
-/* Miscellaneous work routines for menus */
-static int
-setSrc(dialogMenuItem *self)
-{
- Dists |= DIST_SRC;
- SrcDists = DIST_SRC_ALL;
- return DITEM_SUCCESS | DITEM_REDRAW;
-}
-
-static int
-clearSrc(dialogMenuItem *self)
-{
- Dists &= ~DIST_SRC;
- SrcDists = 0;
- return DITEM_SUCCESS | DITEM_REDRAW;
-}
-
-static int
-setCRYPTO(dialogMenuItem *self)
-{
- Dists |= DIST_CRYPTO;
- CRYPTODists = DIST_CRYPTO_ALL;
- return DITEM_SUCCESS | DITEM_REDRAW;
-}
-
-static int
-clearCRYPTO(dialogMenuItem *self)
-{
- Dists &= ~DIST_CRYPTO;
- CRYPTODists = 0;
- return DITEM_SUCCESS | DITEM_REDRAW;
-}
-
-static int
-setX11Misc(dialogMenuItem *self)
-{
- XF86Dists |= DIST_XF86_MISC_ALL;
- Dists |= DIST_XF86;
- return DITEM_SUCCESS | DITEM_REDRAW;
-}
-
-static int
-clearX11Misc(dialogMenuItem *self)
-{
- XF86Dists &= ~DIST_XF86_MISC_ALL;
- if (!XF86ServerDists && !XF86FontDists)
- Dists &= ~DIST_XF86;
- return DITEM_SUCCESS | DITEM_REDRAW;
-}
-
-static int
-setX11Servers(dialogMenuItem *self)
-{
- XF86Dists |= DIST_XF86_SERVER;
- XF86ServerDists = DIST_XF86_SERVER_ALL;
- return DITEM_SUCCESS | DITEM_REDRAW;
-}
-
-static int
-clearX11Servers(dialogMenuItem *self)
-{
- XF86Dists &= ~DIST_XF86_SERVER;
- XF86ServerDists = 0;
- return DITEM_SUCCESS | DITEM_REDRAW;
-}
-
-static int
-setX11Fonts(dialogMenuItem *self)
-{
- XF86Dists |= DIST_XF86_FONTS;
- XF86FontDists = DIST_XF86_FONTS_ALL;
- return DITEM_SUCCESS | DITEM_REDRAW;
-}
-
-static int
-clearX11Fonts(dialogMenuItem *self)
-{
- XF86Dists &= ~DIST_XF86_FONTS;
- XF86FontDists = 0;
- return DITEM_SUCCESS | DITEM_REDRAW;
-}
-
-#define _IS_SET(dist, set) (((dist) & (set)) == (set))
-
-#define IS_DEVELOPER(dist, extra) (_IS_SET(dist, _DIST_DEVELOPER | extra) || \
- _IS_SET(dist, _DIST_DEVELOPER | DIST_CRYPTO | extra))
-
-#define IS_USER(dist, extra) (_IS_SET(dist, _DIST_USER | extra) || \
- _IS_SET(dist, _DIST_USER | DIST_CRYPTO | extra))
-
-static int
-checkDistDeveloper(dialogMenuItem *self)
-{
- return IS_DEVELOPER(Dists, 0) && _IS_SET(SrcDists, DIST_SRC_ALL);
-}
-
-static int
-checkDistXDeveloper(dialogMenuItem *self)
-{
- return IS_DEVELOPER(Dists, DIST_XF86) && _IS_SET(SrcDists, DIST_SRC_ALL);
-}
-
-static int
-checkDistKernDeveloper(dialogMenuItem *self)
-{
- return IS_DEVELOPER(Dists, 0) && _IS_SET(SrcDists, DIST_SRC_SYS);
-}
-
-static int
-checkDistXKernDeveloper(dialogMenuItem *self)
-{
- return IS_DEVELOPER(Dists, DIST_XF86) && _IS_SET(SrcDists, DIST_SRC_SYS);
-}
-
-static int
-checkDistUser(dialogMenuItem *self)
-{
- return IS_USER(Dists, 0);
-}
-
-static int
-checkDistXUser(dialogMenuItem *self)
-{
- return IS_USER(Dists, DIST_XF86);
-}
-
-static int
-checkDistMinimum(dialogMenuItem *self)
-{
- return Dists == DIST_BIN;
-}
-
-static int
-checkDistEverything(dialogMenuItem *self)
-{
- return Dists == DIST_ALL && _IS_SET(SrcDists, DIST_SRC_ALL) && \
- _IS_SET(XF86Dists, DIST_XF86_ALL) && \
- _IS_SET(XF86ServerDists, DIST_XF86_SERVER_ALL) && \
- _IS_SET(XF86FontDists, DIST_XF86_FONTS_ALL);
-}
-
-static int
-CRYPTOFlagCheck(dialogMenuItem *item)
-{
- return CRYPTODists;
-}
-
-static int
-srcFlagCheck(dialogMenuItem *item)
-{
- return SrcDists;
-}
-
-static int
-x11FlagCheck(dialogMenuItem *item)
-{
- return Dists & DIST_XF86;
-}
-
-static int
-checkTrue(dialogMenuItem *item)
-{
- return TRUE;
-}
-
-/* All the system menus go here.
- *
- * Hardcoded things like version number strings will disappear from
- * these menus just as soon as I add the code for doing inline variable
- * expansion.
- */
-
-DMenu MenuIndex = {
- DMENU_NORMAL_TYPE,
- "Glossary of functions",
- "This menu contains an alphabetized index of the top level functions in\n"
- "this program (sysinstall). Invoke an option by pressing [ENTER].\n"
- "Leave the index page by selecting Cancel [TAB-ENTER].",
- "Use PageUp or PageDown to move through this menu faster!",
- NULL,
- { { " Anon FTP", "Configure anonymous FTP logins.", dmenuVarCheck, configAnonFTP, NULL, "anon_ftp" },
- { " Commit", "Commit any pending actions (dangerous!)", NULL, installCustomCommit },
- { " Console settings", "Customize system console behavior.", NULL, dmenuSubmenu, NULL, &MenuSyscons },
- { " Configure", "The system configuration menu.", NULL, dmenuSubmenu, NULL, &MenuConfigure },
- { " Defaults, Load", "Load default settings.", NULL, dispatch_load_floppy },
- { " Device, Mouse", "The mouse configuration menu.", NULL, dmenuSubmenu, NULL, &MenuMouse },
- { " Disklabel", "The disk Label editor", NULL, diskLabelEditor },
- { " Dists, All", "Root of the distribution tree.", NULL, dmenuSubmenu, NULL, &MenuDistributions },
- { " Dists, Basic", "Basic FreeBSD distribution menu.", NULL, dmenuSubmenu, NULL, &MenuSubDistributions },
- { " Dists, CRYPTO", "Encryption distribution menu.", NULL, dmenuSubmenu, NULL, &MenuCRYPTODistributions },
- { " Dists, Developer", "Select developer's distribution.", checkDistDeveloper, distSetDeveloper },
- { " Dists, Src", "Src distribution menu.", NULL, dmenuSubmenu, NULL, &MenuSrcDistributions },
- { " Dists, X Developer", "Select X developer's distribution.", checkDistXDeveloper, distSetXDeveloper },
- { " Dists, Kern Developer", "Select kernel developer's distribution.", checkDistKernDeveloper, distSetKernDeveloper },
- { " Dists, User", "Select average user distribution.", checkDistUser, distSetUser },
- { " Dists, X User", "Select average X user distribution.", checkDistXUser, distSetXUser },
- { " Distributions, Adding", "Installing additional distribution sets", NULL, distExtractAll },
- { " Distributions, XFree86","XFree86 distribution menu.", NULL, distSetXF86 },
- { " Documentation", "Installation instructions, README, etc.", NULL, dmenuSubmenu, NULL, &MenuDocumentation },
- { " Doc, README", "The distribution README file.", NULL, dmenuDisplayFile, NULL, "README" },
- { " Doc, Hardware", "The distribution hardware guide.", NULL, dmenuDisplayFile, NULL, "HARDWARE" },
- { " Doc, Install", "The distribution installation guide.", NULL, dmenuDisplayFile, NULL, "INSTALL" },
- { " Doc, Copyright", "The distribution copyright notices.", NULL, dmenuDisplayFile, NULL, "COPYRIGHT" },
- { " Doc, Release", "The distribution release notes.", NULL, dmenuDisplayFile, NULL, "RELNOTES" },
- { " Doc, HTML", "The HTML documentation menu.", NULL, docBrowser },
- { " Dump Vars", "(debugging) dump out internal variables.", NULL, dump_variables },
- { " Emergency shell", "Start an Emergency Holographic shell.", NULL, installFixitHoloShell },
-#ifdef __i386__
- { " Fdisk", "The disk Partition Editor", NULL, diskPartitionEditor },
-#endif
- { " Fixit", "Repair mode with CDROM or fixit floppy.", NULL, dmenuSubmenu, NULL, &MenuFixit },
- { " FTP sites", "The FTP mirror site listing.", NULL, dmenuSubmenu, NULL, &MenuMediaFTP },
- { " Gateway", "Set flag to route packets between interfaces.", dmenuVarCheck, dmenuToggleVariable, NULL, "gateway=YES" },
- { " HTML Docs", "The HTML documentation menu", NULL, docBrowser },
- { " Install, Standard", "A standard system installation.", NULL, installStandard },
- { " Install, Express", "An express system installation.", NULL, installExpress },
- { " Install, Custom", "The custom installation menu", NULL, dmenuSubmenu, NULL, &MenuInstallCustom },
- { " Label", "The disk Label editor", NULL, diskLabelEditor },
- { " Media", "Top level media selection menu.", NULL, dmenuSubmenu, NULL, &MenuMedia },
- { " Media, Tape", "Select tape installation media.", NULL, mediaSetTape },
- { " Media, NFS", "Select NFS installation media.", NULL, mediaSetNFS },
- { " Media, Floppy", "Select floppy installation media.", NULL, mediaSetFloppy },
- { " Media, CDROM", "Select CDROM installation media.", NULL, mediaSetCDROM },
- { " Media, DOS", "Select DOS installation media.", NULL, mediaSetDOS },
- { " Media, UFS", "Select UFS installation media.", NULL, mediaSetUFS },
- { " Media, FTP", "Select FTP installation media.", NULL, mediaSetFTP },
- { " Media, FTP Passive", "Select passive FTP installation media.", NULL, mediaSetFTPPassive },
- { " Media, HTTP", "Select FTP via HTTP proxy installation media.", NULL, mediaSetHTTP },
- { " Network Interfaces", "Configure network interfaces", NULL, tcpMenuSelect },
- { " Networking Services", "The network services menu.", NULL, dmenuSubmenu, NULL, &MenuNetworking },
- { " NFS, client", "Set NFS client flag.", dmenuVarCheck, dmenuToggleVariable, NULL, "nfs_client_enable=YES" },
- { " NFS, server", "Set NFS server flag.", dmenuVarCheck, configNFSServer, NULL, "nfs_server_enable=YES" },
- { " NTP Menu", "The NTP configuration menu.", NULL, dmenuSubmenu, NULL, &MenuNTP },
- { " Options", "The options editor.", NULL, optionsEditor },
- { " Packages", "The packages collection", NULL, configPackages },
- { " Partition", "The disk Slice (PC-style partition) Editor", NULL, diskPartitionEditor },
- { " PCNFSD", "Run authentication server for PC-NFS.", dmenuVarCheck, configPCNFSD, NULL, "pcnfsd" },
- { " Root Password", "Set the system manager's password.", NULL, dmenuSystemCommand, NULL, "passwd root" },
- { " Router", "Select routing daemon (default: routed)", NULL, configRouter, NULL, "router_enable" },
- { " Syscons", "The system console configuration menu.", NULL, dmenuSubmenu, NULL, &MenuSyscons },
- { " Syscons, Font", "The console screen font.", NULL, dmenuSubmenu, NULL, &MenuSysconsFont },
- { " Syscons, Keymap", "The console keymap configuration menu.", NULL, dmenuSubmenu, NULL, &MenuSysconsKeymap },
- { " Syscons, Keyrate", "The console key rate configuration menu.", NULL, dmenuSubmenu, NULL, &MenuSysconsKeyrate },
- { " Syscons, Saver", "The console screen saver configuration menu.", NULL, dmenuSubmenu, NULL, &MenuSysconsSaver },
- { " Syscons, Screenmap", "The console screenmap configuration menu.", NULL, dmenuSubmenu, NULL, &MenuSysconsScrnmap },
- { " Time Zone", "Set the system's time zone.", NULL, dmenuSystemCommand, NULL, "tzsetup" },
- { " Upgrade", "Upgrade an existing system.", NULL, installUpgrade },
- { " Usage", "Quick start - How to use this menu system.", NULL, dmenuDisplayFile, NULL, "usage" },
- { " User Management", "Add user and group information.", NULL, dmenuSubmenu, NULL, &MenuUsermgmt },
- { " XFree86, Fonts", "XFree86 Font selection menu.", NULL, dmenuSubmenu, NULL, &MenuXF86SelectFonts },
- { " XFree86, Server", "XFree86 Server selection menu.", NULL, dmenuSubmenu, NULL, &MenuXF86SelectServer },
-#ifdef __i386__
- { " XFree86, PC98 Server", "XFree86 PC98 Server selection menu.", NULL, dmenuSubmenu, NULL, &MenuXF86SelectPC98Server },
-#endif
- { NULL } },
-};
-
-/* The initial installation menu */
-DMenu MenuInitial = {
- DMENU_NORMAL_TYPE,
- "/stand/sysinstall Main Menu", /* title */
- "Welcome to the FreeBSD installation and configuration tool. Please\n" /* prompt */
- "select one of the options below by using the arrow keys or typing the\n"
- "first character of the option name you're interested in. Invoke an\n"
- "option by pressing [ENTER] or [TAB-ENTER] to exit the installation.",
- "Press F1 for Installation Guide", /* help line */
- "install", /* help file */
- { { "Select" },
- { "X Exit Install", NULL, NULL, dmenuExit },
- { " Usage", "Quick start - How to use this menu system", NULL, dmenuDisplayFile, NULL, "usage" },
- { "Standard", "Begin a standard installation (recommended)", NULL, installStandard },
- { "Express", "Begin a quick installation (for the impatient)", NULL, installExpress },
- { " Custom", "Begin a custom installation (for experts)", NULL, dmenuSubmenu, NULL, &MenuInstallCustom },
- { "Configure", "Do post-install configuration of FreeBSD", NULL, dmenuSubmenu, NULL, &MenuConfigure },
- { "Doc", "Installation instructions, README, etc.", NULL, dmenuSubmenu, NULL, &MenuDocumentation },
- { "Keymap", "Select keyboard type", NULL, dmenuSubmenu, NULL, &MenuSysconsKeymap },
- { "Options", "View/Set various installation options", NULL, optionsEditor },
- { "Fixit", "Enter repair mode with CDROM/floppy or start shell", NULL, dmenuSubmenu, NULL, &MenuFixit },
- { "Upgrade", "Upgrade an existing system", NULL, installUpgrade },
- { "Load Config","Load default install configuration", NULL, dispatch_load_floppy },
- { "Index", "Glossary of functions", NULL, dmenuSubmenu, NULL, &MenuIndex },
- { NULL } },
-};
-
-/* The main documentation menu */
-DMenu MenuDocumentation = {
- DMENU_NORMAL_TYPE,
- "FreeBSD Documentation Menu",
- "If you are at all unsure about the configuration of your hardware\n"
- "or are looking to build a system specifically for FreeBSD, read the\n"
- "Hardware guide! New users should also read the Install document for\n"
- "a step-by-step tutorial on installing FreeBSD. For general information,\n"
- "consult the README file.",
- "Confused? Press F1 for help.",
- "usage",
- { { "X Exit", "Exit this menu (returning to previous)", NULL, dmenuExit },
- { "2 README", "A general description of FreeBSD. Read this!", NULL, dmenuDisplayFile, NULL, "README" },
- { "3 Hardware", "The FreeBSD survival guide for PC hardware.", NULL, dmenuDisplayFile, NULL, "HARDWARE" },
- { "4 Install", "A step-by-step guide to installing FreeBSD.", NULL, dmenuDisplayFile, NULL, "INSTALL" },
- { "5 Copyright", "The FreeBSD Copyright notices.", NULL, dmenuDisplayFile, NULL, "COPYRIGHT" },
- { "6 Release" ,"The release notes for this version of FreeBSD.", NULL, dmenuDisplayFile, NULL, "RELNOTES" },
- { "7 Shortcuts", "Creating shortcuts to sysinstall.", NULL, dmenuDisplayFile, NULL, "shortcuts" },
- { "8 HTML Docs", "Go to the HTML documentation menu (post-install).", NULL, docBrowser },
- { NULL } },
-};
-
-DMenu MenuMouseType = {
- DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS,
- "Select a protocol type for your mouse",
- "If your mouse is attached to the PS/2 mouse port or the bus mouse port,\n"
- "you should always choose \"Auto\", regardless of the model and the brand\n"
- "of the mouse. All other protocol types are for serial mice and should\n"
- "not be used with the PS/2 port mouse or the bus mouse. If you have\n"
- "a serial mouse and are not sure about its protocol, you should also try\n"
- "\"Auto\". It may not work for the serial mouse if the mouse does not\n"
- "support the PnP standard. But, it won't hurt. Many 2-button serial mice\n"
- "are compatible with \"Microsoft\" or \"MouseMan\". 3-button serial mice\n"
- "may be compatible with \"MouseSystems\" or \"MouseMan\". If the serial\n"
- "mouse has a wheel, it may be compatible with \"IntelliMouse\".",
- NULL,
- NULL,
- { { "1 Auto", "Bus mouse, PS/2 style mouse or PnP serial mouse",
- dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_TYPE "=auto" },
- { "2 GlidePoint", "ALPS GlidePoint pad (serial)",
- dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_TYPE "=glidepoint" },
- { "3 Hitachi","Hitachi tablet (serial)",
- dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_TYPE "=mmhittab" },
- { "4 IntelliMouse", "Microsoft IntelliMouse (serial)",
- dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_TYPE "=intellimouse" },
- { "5 Logitech", "Logitech protocol (old models) (serial)",
- dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_TYPE "=logitech" },
- { "6 Microsoft", "Microsoft protocol (serial)",
- dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_TYPE "=microsoft" },
- { "7 MM Series","MM Series protocol (serial)",
- dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_TYPE "=mmseries" },
- { "8 MouseMan", "Logitech MouseMan/TrackMan models (serial)",
- dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_TYPE "=mouseman" },
- { "9 MouseSystems", "MouseSystems protocol (serial)",
- dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_TYPE "=mousesystems" },
- { "A ThinkingMouse","Kensington ThinkingMouse (serial)",
- dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_TYPE "=thinkingmouse" },
- { NULL } },
-};
-
-DMenu MenuMousePort = {
- DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS,
- "Select your mouse port from the following menu",
- "The built-in pointing device of laptop/notebook computers is usually\n"
- "a PS/2 style device.",
- NULL,
- NULL,
- { { "1 PS/2", "PS/2 style mouse (/dev/psm0)",
- dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_PORT "=/dev/psm0" },
- { "2 COM1", "Serial mouse on COM1 (/dev/cuaa0)",
- dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_PORT "=/dev/cuaa0" },
- { "3 COM2", "Serial mouse on COM2 (/dev/cuaa1)",
- dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_PORT "=/dev/cuaa1" },
- { "4 COM3", "Serial mouse on COM3 (/dev/cuaa2)",
- dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_PORT "=/dev/cuaa2" },
- { "5 COM4", "Serial mouse on COM4 (/dev/cuaa3)",
- dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_PORT "=/dev/cuaa3" },
- { "6 BusMouse", "Logitech, ATI or MS bus mouse (/dev/mse0)",
- dmenuVarCheck, dmenuSetVariable, NULL, VAR_MOUSED_PORT "=/dev/mse0" },
- { NULL } },
-};
-
-DMenu MenuMouse = {
- DMENU_NORMAL_TYPE,
- "Please configure your mouse",
- "You can cut and paste text in the text console by running the mouse\n"
- "daemon. Specify a port and a protocol type of your mouse and enable\n"
- "the mouse daemon. If you don't want this feature, select 4 to disable\n"
- "the daemon.\n"
- "Once you've enabled the mouse daemon, you can specify \"/dev/sysmouse\"\n"
- "as your mouse device and \"SysMouse\" or \"MouseSystems\" as mouse\n"
- "protocol when running the X configuration utility (see Configuration\n"
- "menu).",
- NULL,
- NULL,
- { { "X Exit", "Exit this menu (returning to previous)", NULL, dmenuExit },
- { "2 Enable", "Test and run the mouse daemon", NULL, mousedTest, NULL, NULL },
- { "3 Type", "Select mouse protocol type", NULL, dmenuSubmenu, NULL, &MenuMouseType },
- { "4 Port", "Select mouse port", NULL, dmenuSubmenu, NULL, &MenuMousePort },
- { "5 Disable", "Disable the mouse daemon", NULL, mousedDisable, NULL, NULL },
- { NULL } },
-};
-
-DMenu MenuXF86Config = {
- DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS,
- "Please select the XFree86 configuration tool you want to use.",
-#ifdef __alpha__
- "Due to problems with the VGA16 server right now, only the\n"
- "text-mode configuration tool (xf86config) is currently supported.",
-#else
- "The first tool, XF86Setup, is fully graphical and requires the\n"
- "VGA16 server in order to work (should have been selected by\n"
- "default, but if you de-selected it then you won't be able to\n"
- "use this fancy setup tool). The second tool, xf86config, is\n"
- "a more simplistic shell-script based tool and less friendly to\n"
- "new users, but it may work in situations where the fancier one\n"
- "does not.",
-#endif
- NULL,
- NULL,
- { { "X Exit", "Exit this menu (returning to previous)",
- NULL, dmenuExit },
-#ifdef __alpha__
- { "2 xf86config", "Shell-script based XFree86 configuration tool.",
- NULL, dmenuSetVariable, NULL, VAR_XF86_CONFIG "=xf86config" },
-#else
- { "2 XF86Setup", "Fully graphical XFree86 configuration tool.",
- NULL, dmenuSetVariable, NULL, VAR_XF86_CONFIG "=XF86Setup" },
- { "3 xf86config", "Shell-script based XFree86 configuration tool.",
- NULL, dmenuSetVariable, NULL, VAR_XF86_CONFIG "=xf86config" },
- { "4 XF98Setup", "Fully graphical XFree86 configuration tool (PC98).",
- NULL, dmenuSetVariable, NULL, VAR_XF86_CONFIG "=XF98Setup" },
-#endif
- { "D XDesktop", "X already set up, just do desktop configuration.",
- NULL, dmenuSubmenu, NULL, &MenuXDesktops },
- { NULL } },
-};
-
-DMenu MenuXDesktops = {
- DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS,
- "Please select the default X desktop to use.",
- "By default, XFree86 comes with a fairly vanilla desktop which\n"
- "is based around the twm(1) window manager and does not offer\n"
- "much in the way of features. It does have the advantage of\n"
- "being a standard part of X so you don't need to load anything\n"
- "extra in order to use it. If, however, you have access to a\n"
- "reasonably full packages collection on your installation media,\n"
- "you can choose any one of the following desktops as alternatives.",
- NULL,
- NULL,
- { { "X Exit", "Exit this menu (returning to previous)",
- NULL, dmenuExit },
- { "2 KDE", "The K Desktop Environment.",
- NULL, dmenuSetVariable, NULL, VAR_DESKSTYLE "=kde" },
- { "3 GNOME + Afterstep", "GNOME + Afterstep window manager.",
- NULL, dmenuSetVariable, NULL, VAR_DESKSTYLE "=gnome" },
- { "4 GNOME + Enlightenment","GNOME + The E window manager",
- NULL, dmenuSetVariable, NULL, VAR_DESKSTYLE "=enlightenment" },
- { "5 Afterstep", "The Afterstep window manager",
- NULL, dmenuSetVariable, NULL, VAR_DESKSTYLE "=afterstep" },
- { "6 Windowmaker", "The Windowmaker window manager",
- NULL, dmenuSetVariable, NULL, VAR_DESKSTYLE "=windowmaker" },
- { "7 fvwm2", "The fvwm2 window manager",
- NULL, dmenuSetVariable, NULL, VAR_DESKSTYLE "=fvwm2" },
- { NULL } },
-};
-
-DMenu MenuMediaCDROM = {
- DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS,
- "Choose a CDROM type",
- "FreeBSD can be installed directly from a CDROM containing a valid\n"
- "FreeBSD distribution. If you are seeing this menu it is because\n"
- "more than one CDROM drive was found on your system. Please select one\n"
- "of the following CDROM drives as your installation drive.",
- "Press F1 to read the installation guide",
- "install",
- { { NULL } },
-};
-
-DMenu MenuMediaFloppy = {
- DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS,
- "Choose a Floppy drive",
- "You have more than one floppy drive. Please choose which drive\n"
- "you would like to use.",
- NULL,
- NULL,
- { { NULL } },
-};
-
-DMenu MenuMediaDOS = {
- DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS,
- "Choose a DOS partition",
- "FreeBSD can be installed directly from a DOS partition\n"
- "assuming, of course, that you have copied the relevant\n"
- "distributions into your DOS partition before starting this\n"
- "installation. If this is not the case then you should reboot\n"
- "DOS at this time and copy the distributions you wish to install\n"
- "into a \"FREEBSD\" subdirectory on one of your DOS partitions.\n"
- "Otherwise, please select the DOS partition containing the FreeBSD\n"
- "distribution files.",
- "Press F1 to read the installation guide",
- "install",
- { { NULL } },
-};
-
-DMenu MenuMediaFTP = {
- DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS,
- "Please select a FreeBSD FTP distribution site",
- "Please select the site closest to you or \"other\" if you'd like to\n"
- "specify a different choice. Also note that not every site listed here\n"
- "carries more than the base distribution kits. Only the Primary site is\n"
- "guaranteed to carry the full range of possible distributions.",
- "Select a site that's close!",
- "install",
- { { "Primary Site", "ftp.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AS("=ftp://ftp.freebsd.org/pub/FreeBSD/releases/") },
- { "URL", "Specify some other ftp site by URL", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH "=other" },
- { " 4.0 SNAP Server", "current.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AS("=ftp://current.freebsd.org/pub/FreeBSD/snapshots/") },
- { " 3.0 SNAP Server", "releng3.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AS("=ftp://releng3.freebsd.org/pub/FreeBSD/snapshots/") },
- { "Argentina", "ftp.ar.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.ar.freebsd.org") },
- { " Australia", "ftp.au.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.au.freebsd.org") },
- { " Australia #2","ftp2.au.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp2.au.freebsd.org") },
- { " Australia #3","ftp3.au.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp3.au.freebsd.org") },
- { " Australia #4","ftp4.au.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp4.au.freebsd.org") },
- { " Australia #5","ftp5.au.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp5.au.freebsd.org") },
- { "Brazil", "ftp.br.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.br.freebsd.org") },
- { " Brazil #2", "ftp2.br.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp2.br.freebsd.org") },
- { " Brazil #3", "ftp3.br.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp3.br.freebsd.org") },
- { " Brazil #4", "ftp4.br.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp4.br.freebsd.org") },
- { " Brazil #5", "ftp5.br.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp5.br.freebsd.org") },
- { " Brazil #6", "ftp6.br.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp6.br.freebsd.org") },
- { " Brazil #7", "ftp7.br.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp7.br.freebsd.org") },
- { " Canada", "ftp.ca.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.ca.freebsd.org") },
- { " Czech Republic", "ftp.cz.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.cz.freebsd.org") },
- { "Denmark", "ftp.dk.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.dk.freebsd.org") },
- { " Denmark #2", "ftp2.dk.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp2.dk.freebsd.org") },
- { "Estonia", "ftp.ee.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.ee.freebsd.org") },
- { "Finland", "ftp.fi.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.fi.freebsd.org") },
- { " France", "ftp.fr.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.fr.freebsd.org") },
- { " France #2", "ftp2.fr.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp2.fr.freebsd.org") },
- { " France #3", "ftp3.fr.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp3.fr.freebsd.org") },
- { "Germany", "ftp.de.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.de.freebsd.org") },
- { " Germany #2", "ftp2.de.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp2.de.freebsd.org") },
- { " Germany #3", "ftp3.de.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp3.de.freebsd.org") },
- { " Germany #4", "ftp4.de.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp4.de.freebsd.org") },
- { " Germany #5", "ftp5.de.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp5.de.freebsd.org") },
- { " Germany #6", "ftp6.de.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp6.de.freebsd.org") },
- { " Germany #7", "ftp7.de.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp7.de.freebsd.org") },
- { "Holland", "ftp.nl.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.nl.freebsd.org") },
- { " Hong Kong", "ftp.hk.super.net", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.hk.super.net") },
- { "Iceland", "ftp.is.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.is.freebsd.org") },
- { " Ireland", "ftp.ie.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.ie.freebsd.org") },
- { " Israel", "ftp.il.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.il.freebsd.org") },
- { " Israel #2", "ftp2.il.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp2.il.freebsd.org") },
- { "Japan", "ftp.jp.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.jp.freebsd.org") },
- { " Japan #2", "ftp2.jp.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp2.jp.freebsd.org") },
- { " Japan #3", "ftp3.jp.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp3.jp.freebsd.org") },
- { " Japan #4", "ftp4.jp.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp4.jp.freebsd.org") },
- { " Japan #5", "ftp5.jp.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp5.jp.freebsd.org") },
- { " Japan #6", "ftp6.jp.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp6.jp.freebsd.org") },
- { "Korea", "ftp.kr.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.kr.freebsd.org") },
- { " Korea #2", "ftp2.kr.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp2.kr.freebsd.org") },
- { " Korea #3", "ftp3.kr.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp3.kr.freebsd.org") },
- { " Korea #4", "ftp4.kr.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp4.kr.freebsd.org") },
- { " Korea #5", "ftp5.kr.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp5.kr.freebsd.org") },
- { "New Zealand", "ftp.nz.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.nz.freebsd.org") },
- { "Poland", "ftp.pl.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.pl.freebsd.org") },
- { " Portugal", "ftp.pt.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.pt.freebsd.org") },
- { " Portugal #2", "ftp2.pt.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp2.pt.freebsd.org") },
- { "Russia", "ftp.ru.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.ru.freebsd.org") },
- { " Russia #2", "ftp2.ru.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp2.ru.freebsd.org") },
- { " Russia #3", "ftp3.ru.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp3.ru.freebsd.org") },
- { " Russia #4", "ftp4.ru.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp4.ru.freebsd.org") },
- { "Slovak Republic", "ftp.sk.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.sk.freebsd.org") },
- { " South Africa", "ftp.za.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.za.freebsd.org") },
- { " South Africa #2", "ftp2.za.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp2.za.freebsd.org") },
- { " South Africa #3", "ftp3.za.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp3.za.freebsd.org") },
- { " South Africa #4", "ftp4.za.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp4.za.freebsd.org") },
- { " Spain", "ftp.es.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.es.freebsd.org") },
- { " Spain #2", "ftp2.es.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp2.es.freebsd.org") },
- { " Sweden", "ftp.se.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.se.freebsd.org") },
- { " Sweden #2", "ftp2.se.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp2.se.freebsd.org") },
- { " Sweden #3", "ftp3.se.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp3.se.freebsd.org") },
- { "Taiwan", "ftp.tw.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.tw.freebsd.org") },
- { " Taiwan #2", "ftp2.tw.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp2.tw.freebsd.org") },
- { " Taiwan #3", "ftp3.tw.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp3.tw.freebsd.org") },
- { " Thailand", "ftp.nectec.or.th", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AS("=ftp://ftp.nectec.or.th/pub/mirrors/FreeBSD/") },
- { "UK", "ftp.uk.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.uk.freebsd.org") },
- { " UK #2", "ftp2.uk.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp2.uk.freebsd.org") },
- { " UK #3", "ftp3.uk.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp3.uk.freebsd.org") },
- { " UK #4", "ftp4.uk.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp4.uk.freebsd.org") },
- { " UK #5", "ftp5.uk.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp5.uk.freebsd.org") },
- { " USA", "ftp.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp.freebsd.org") },
- { " USA #2", "ftp2.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp2.freebsd.org") },
- { " USA #3", "ftp3.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp3.freebsd.org") },
- { " USA #4", "ftp4.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp4.freebsd.org") },
- { " USA #5", "ftp5.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp5.freebsd.org") },
- { " USA #6", "ftp6.freebsd.org", NULL, dmenuSetVariable, NULL,
- VAR_FTP_PATH _AP("=ftp://ftp6.freebsd.org") },
- { NULL } }
-};
-
-DMenu MenuMediaTape = {
- DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS,
- "Choose a tape drive type",
- "FreeBSD can be installed from tape drive, though this installation\n"
- "method requires a certain amount of temporary storage in addition\n"
- "to the space required by the distribution itself (tape drives make\n"
- "poor random-access devices, so we extract _everything_ on the tape\n"
- "in one pass). If you have sufficient space for this, then you should\n"
- "select one of the following tape devices detected on your system.",
- "Press F1 to read the installation guide",
- "install",
- { { NULL } },
-};
-
-DMenu MenuNetworkDevice = {
- DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS,
- "Network interface information required",
- "If you are using PPP over a serial device, as opposed to a direct\n"
- "ethernet connection, then you may first need to dial your Internet\n"
- "Service Provider using the ppp utility we provide for that purpose.\n"
- "If you're using SLIP over a serial device then the expectation is\n"
- "that you have a HARDWIRED connection.\n\n"
- "You can also install over a parallel port using a special \"laplink\"\n"
- "cable to another machine running a fairly recent (2.0R or later)\n"
- "version of FreeBSD.",
- "Press F1 to read network configuration manual",
- "network_device",
- { { NULL } },
-};
-
-/* The media selection menu */
-DMenu MenuMedia = {
- DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS,
- "Choose Installation Media",
- "FreeBSD can be installed from a variety of different installation\n"
- "media, ranging from floppies to an Internet FTP server. If you're\n"
- "installing FreeBSD from a supported CDROM drive then this is generally\n"
- "the best media to use if you have no overriding reason for using other\n"
- "media.",
- "Press F1 for more information on the various media types",
- "media",
- { { "1 CDROM", "Install from a FreeBSD CDROM", NULL, mediaSetCDROM },
- { "2 FTP", "Install from an FTP server", NULL, mediaSetFTPActive },
- { "3 FTP Passive", "Install from an FTP server through a firewall", NULL, mediaSetFTPPassive },
- { "3b HTTP", "Install from an FTP server through a http proxy", NULL, mediaSetHTTP },
- { "4 DOS", "Install from a DOS partition", NULL, mediaSetDOS },
- { "5 NFS", "Install over NFS", NULL, mediaSetNFS },
- { "6 File System", "Install from an existing filesystem", NULL, mediaSetUFS },
- { "7 Floppy", "Install from a floppy disk set", NULL, mediaSetFloppy },
- { "8 Tape", "Install from SCSI or QIC tape", NULL, mediaSetTape },
- { "9 Options", "Go to the Options screen", NULL, optionsEditor },
- { NULL } },
-};
-
-/* The distributions menu */
-DMenu MenuDistributions = {
- DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS,
- "Choose Distributions",
- "As a convenience, we provide several \"canned\" distribution sets.\n"
- "These select what we consider to be the most reasonable defaults for the\n"
- "type of system in question. If you would prefer to pick and choose the\n"
- "list of distributions yourself, simply select \"Custom\". You can also\n"
- "pick a canned distribution set and then fine-tune it with the Custom item.\n\n"
- "Choose an item by pressing [SPACE]. When you are finished, choose the Exit\n"
- "item or press [ENTER].",
- "Press F1 for more information on these options.",
- "distributions",
- { { "X Exit", "Exit this menu (returning to previous)",
- checkTrue, dmenuExit, NULL, NULL, '<', '<', '<' },
- { "All", "All system sources, binaries and X Window System)",
- checkDistEverything, distSetEverything, NULL, NULL, ' ', ' ', ' ' },
- { "Reset", "Reset selected distribution list to nothing",
- NULL, distReset, NULL, NULL, ' ', ' ', ' ' },
- { "4 Developer", "Full sources, binaries and doc but no games",
- checkDistDeveloper, distSetDeveloper },
- { "5 X-Developer", "Same as above + X Window System",
- checkDistXDeveloper, distSetXDeveloper },
- { "6 Kern-Developer", "Full binaries and doc, kernel sources only",
- checkDistKernDeveloper, distSetKernDeveloper },
- { "7 X-Kern-Developer", "Same as above + X Window System",
- checkDistXKernDeveloper, distSetXKernDeveloper },
- { "8 User", "Average user - binaries and doc only",
- checkDistUser, distSetUser },
- { "9 X-User", "Same as above + X Window System",
- checkDistXUser, distSetXUser },
- { "A Minimal", "The smallest configuration possible",
- checkDistMinimum, distSetMinimum },
- { "B Custom", "Specify your own distribution set",
- NULL, dmenuSubmenu, NULL, &MenuSubDistributions, '>', '>', '>' },
- { NULL } },
-};
-
-DMenu MenuSubDistributions = {
- DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS,
- "Select the distributions you wish to install.",
- "Please check off the distributions you wish to install. At the\n"
- "very minimum, this should be \"bin\". WARNING: Do not export the\n"
- "Encryption distribution out of the U.S.!\n"
- "It is for U.S. customers only.",
- NULL,
- NULL,
- { { "X Exit", "Exit this menu (returning to previous)",
- checkTrue, dmenuExit, NULL, NULL, '<', '<', '<' },
- { "All", "All system sources, binaries and X Window System",
- NULL, distSetEverything, NULL, NULL, ' ', ' ', ' ' },
- { "Reset", "Reset all of the below",
- NULL, distReset, NULL, NULL, ' ', ' ', ' ' },
- { " bin", "Binary base distribution (required)",
- dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_BIN },
-#ifdef __i386__
- { " compat1x", "FreeBSD 1.x binary compatibility",
- dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_COMPAT1X },
- { " compat20", "FreeBSD 2.0 binary compatibility",
- dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_COMPAT20 },
- { " compat21", "FreeBSD 2.1 binary compatibility",
- dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_COMPAT21 },
- { " compat22", "FreeBSD 2.2.x and 3.0 a.out binary compatibility",
- dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_COMPAT22 },
-#if __FreeBSD__ > 3
- { " compat3x", "FreeBSD 3.x binary compatibility",
- dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_COMPAT3X },
-#endif
-#endif
- { " CRYPTO", "Encryption code - NOT FOR EXPORT!",
- CRYPTOFlagCheck,distSetCRYPTO },
- { " dict", "Spelling checker dictionary files",
- dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_DICT },
- { " doc", "Miscellaneous FreeBSD online docs",
- dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_DOC },
- { " games", "Games (non-commercial)",
- dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_GAMES },
- { " info", "GNU info files",
- dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_INFO },
- { " man", "System manual pages - recommended",
- dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_MANPAGES },
- { " catman", "Preformatted system manual pages",
- dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_CATPAGES },
- { " proflibs", "Profiled versions of the libraries",
- dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_PROFLIBS },
- { " src", "Sources for everything but encryption",
- srcFlagCheck, distSetSrc },
- { " ports", "The FreeBSD Ports collection",
- dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_PORTS },
- { " local", "Local additions collection",
- dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_LOCAL},
- { " XFree86", "The XFree86 3.3.6 distribution",
-#ifdef X_AS_PKG
- dmenuFlagCheck, dmenuSetFlag, NULL, &Dists, '[', 'X', ']', DIST_XF86 },
-#else
- x11FlagCheck, distSetXF86 },
-#endif
- { NULL } },
-};
-
-DMenu MenuCRYPTODistributions = {
- DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS,
- "Select the encryption facilities you wish to install.",
- "Please check off any special encryption distributions\n"
- "you would like to install. Please note that these services are NOT FOR\n"
- "EXPORT from the United States. For information on non-U.S. FTP\n"
- "distributions of this software, please consult the release notes.",
- NULL,
- NULL,
- { { "X Exit", "Exit this menu (returning to previous)",
- checkTrue, dmenuExit, NULL, NULL, '<', '<', '<' },
- { "All", "Select all of the below",
- NULL, setCRYPTO, NULL, NULL, ' ', ' ', ' ' },
- { "Reset", "Reset all of the below",
- NULL, clearCRYPTO, NULL, NULL, ' ', ' ', ' ' },
- { " crypto", "Basic encryption services",
- dmenuFlagCheck, dmenuSetFlag, NULL, &CRYPTODists, '[', 'X', ']', DIST_CRYPTO_CRYPTO, },
-#if __FreeBSD__ <= 3
- { " krb", "KerberosIV authentication services",
- dmenuFlagCheck, dmenuSetFlag, NULL, &CRYPTODists, '[', 'X', ']', DIST_CRYPTO_KERBEROS },
-#else
- { " krb4", "KerberosIV authentication services",
- dmenuFlagCheck, dmenuSetFlag, NULL, &CRYPTODists, '[', 'X', ']', DIST_CRYPTO_KERBEROS4 },
- { " krb5", "Kerberos5 authentication services",
- dmenuFlagCheck, dmenuSetFlag, NULL, &CRYPTODists, '[', 'X', ']', DIST_CRYPTO_KERBEROS5 },
-#endif
- { " skrb4", "Sources for KerberosIV",
- dmenuFlagCheck, dmenuSetFlag, NULL, &CRYPTODists, '[', 'X', ']', DIST_CRYPTO_SKERBEROS4 },
- { " skrb5", "Sources for Kerberos5",
- dmenuFlagCheck, dmenuSetFlag, NULL, &CRYPTODists, '[', 'X', ']', DIST_CRYPTO_SKERBEROS5 },
- { " ssecure", "BSD encryption sources",
- dmenuFlagCheck, dmenuSetFlag, NULL, &CRYPTODists, '[', 'X', ']', DIST_CRYPTO_SSECURE },
- { " scrypto", "Contributed encryption sources",
- dmenuFlagCheck, dmenuSetFlag, NULL, &CRYPTODists, '[', 'X', ']', DIST_CRYPTO_SCRYPTO },
- { NULL } },
-};
-
-DMenu MenuSrcDistributions = {
- DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS,
- "Select the sub-components of src you wish to install.",
- "Please check off those portions of the FreeBSD source tree\n"
- "you wish to install (remember to use SPACE, not ENTER!).",
- NULL,
- NULL,
- { { "X Exit", "Exit this menu (returning to previous)",
- checkTrue, dmenuExit, NULL, NULL, '<', '<', '<' },
- { "All", "Select all of the below",
- NULL, setSrc, NULL, NULL, ' ', ' ', ' ' },
- { "Reset", "Reset all of the below",
- NULL, clearSrc, NULL, NULL, ' ', ' ', ' ' },
- { " base", "top-level files in /usr/src",
- dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_BASE },
- { " contrib", "/usr/src/contrib (contributed software)",
- dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_CONTRIB },
- { " gnu", "/usr/src/gnu (software from the GNU Project)",
- dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_GNU },
- { " etc", "/usr/src/etc (miscellaneous system files)",
- dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_ETC },
- { " games", "/usr/src/games (the obvious!)",
- dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_GAMES },
- { " include", "/usr/src/include (header files)",
- dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_INCLUDE },
- { " lib", "/usr/src/lib (system libraries)",
- dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_LIB },
- { " libexec", "/usr/src/libexec (system programs)",
- dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_LIBEXEC },
- { " release", "/usr/src/release (release-generation tools)",
- dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_RELEASE },
- { " bin", "/usr/src/bin (system binaries)",
- dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_BIN },
- { " sbin", "/usr/src/sbin (system binaries)",
- dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_SBIN },
- { " share", "/usr/src/share (documents and shared files)",
- dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_SHARE },
- { " sys", "/usr/src/sys (FreeBSD kernel)",
- dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_SYS },
- { " tools", "/usr/src/tools (miscellaneous tools)",
- dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_TOOLS },
- { " ubin", "/usr/src/usr.bin (user binaries)",
- dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_UBIN },
- { " usbin", "/usr/src/usr.sbin (aux system binaries)",
- dmenuFlagCheck, dmenuSetFlag, NULL, &SrcDists, '[', 'X', ']', DIST_SRC_USBIN },
- { NULL } },
-};
-
-DMenu MenuXF86Select = {
- DMENU_NORMAL_TYPE,
- "XFree86 3.3.6 Distribution",
- "Please select the components you need from the XFree86 3.3.6\n"
- "distribution sets.",
- NULL,
- NULL,
- { { "X Exit", "Exit this menu (returning to previous)", NULL, dmenuExit },
- { "Basic", "Basic component menu (required)", NULL, dmenuSubmenu, NULL, &MenuXF86SelectCore },
- { "Server", "X server menu", NULL, dmenuSubmenu, NULL, &MenuXF86SelectServer },
- { "Fonts", "Font set menu", NULL, dmenuSubmenu, NULL, &MenuXF86SelectFonts },
- { NULL } },
-};
-
-DMenu MenuXF86SelectCore = {
- DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS,
- "XFree86 3.3.6 base distribution types",
- "Please check off the basic XFree86 components you wish to install.\n"
- "Bin, lib, and set are recommended for a minimum installaion.",
- NULL,
- NULL,
- { { "X Exit", "Exit this menu (returning to previous)",
- checkTrue, dmenuExit, NULL, NULL, '<', '<', '<' },
- { "All", "Select all below",
- NULL, setX11Misc, NULL, NULL, ' ', ' ', ' ' },
- { "Reset", "Reset all below",
- NULL, clearX11Misc, NULL, NULL, ' ', ' ', ' ' },
- { " bin", "Client applications and shared libs",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_BIN },
- { " cfg", "Configuration files",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_CFG },
- { " doc", "READMEs and release notes",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_DOC },
- { " html", "HTML documentation files",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_HTML },
- { " lib", "Data files needed at runtime",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_LIB },
- { " lkit", "Server link kit for all other machines",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_LKIT },
- { " man", "Manual pages",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_MAN },
- { " prog", "Programmer's header and library files",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_PROG },
- { " set", "XFree86 Setup Utility",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_SET },
-#ifdef __i386__
- { " 9set", "XFree86 Setup Utility for PC98 machines",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_9SET },
- { " lk98", "Server link kit for PC98 machines",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86Dists, '[', 'X', ']', DIST_XF86_LKIT98 },
-#endif
- { NULL } },
-};
-
-DMenu MenuXF86SelectFonts = {
- DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS,
- "Font distribution selection.",
- "Please check off the individual font distributions you wish to\n\
-install. At the minimum, you should install the standard\n\
-75 DPI and misc fonts if you're also installing a server\n\
-(these are selected by default).",
- NULL,
- NULL,
- { { "X Exit", "Exit this menu (returning to previous)",
- checkTrue, dmenuExit, NULL, NULL, '<', '<', '<' },
- { "All", "All fonts",
- NULL, setX11Fonts, NULL, NULL, ' ', ' ', ' ' },
- { "Reset", "Reset font selections",
- NULL, clearX11Fonts, NULL, NULL, ' ', ' ', ' ' },
- { " fnts", "Standard 75 DPI and miscellaneous fonts",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86FontDists, '[', 'X', ']', DIST_XF86_FONTS_MISC },
- { " f100", "100 DPI fonts",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86FontDists, '[', 'X', ']', DIST_XF86_FONTS_100 },
- { " fcyr", "Cyrillic Fonts",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86FontDists, '[', 'X', ']', DIST_XF86_FONTS_CYR },
- { " fscl", "Speedo and Type scalable fonts",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86FontDists, '[', 'X', ']', DIST_XF86_FONTS_SCALE },
- { " non", "Japanese, Chinese and other non-english fonts",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86FontDists, '[', 'X', ']', DIST_XF86_FONTS_NON },
- { " server", "Font server",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86FontDists, '[', 'X', ']', DIST_XF86_FONTS_SERVER },
- { NULL } },
-};
-
-DMenu MenuXF86SelectServer = {
- DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS,
- "X Server selection.",
- "Please check off the types of X servers you wish to install.\n"
- "If you are unsure as to which server will work for your graphics card,\n"
- "it is recommended that try the SVGA or VGA16 servers or, for PC98\n"
- "machines, the 9EGC or 9840 servers.",
- NULL,
- NULL,
- { { "X Exit", "Exit this menu (returning to previous)",
- checkTrue, dmenuExit, NULL, NULL, '<', '<', '<' },
- { "All", "Select all of the above",
- NULL, setX11Servers, NULL, NULL, ' ', ' ', ' ' },
- { "Reset", "Reset all of the above",
- NULL, clearX11Servers, NULL, NULL, ' ', ' ', ' ' },
- { " SVGA", "Standard VGA or Super VGA card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_SVGA },
- { " VGA16", "Standard 16 color VGA card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_VGA16 },
- { " Mono", "Standard Monochrome card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_MONO },
- { " 3DL", "8, 16 and 24 bit color 3D Labs boards",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_3DL },
- { " 8514", "8-bit (256 color) IBM 8514 or compatible card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_8514 },
- { " AGX", "8-bit AGX card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_AGX },
- { " I128", "8, 16 and 24-bit #9 Imagine I128 card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_I128 },
- { " Ma8", "8-bit ATI Mach8 card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_MACH8 },
- { " Ma32", "8 and 16-bit (65K color) ATI Mach32 card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_MACH32 },
- { " Ma64", "8 and 16-bit (65K color) ATI Mach64 card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_MACH64 },
- { " P9K", "8, 16, and 24-bit color Weitek P9000 based boards",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_P9000 },
- { " S3", "8, 16 and 24-bit color S3 based boards",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_S3 },
- { " S3V", "8, 16 and 24-bit color S3 Virge based boards",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_S3V },
- { " W32", "8-bit ET4000/W32, /W32i and /W32p cards",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_W32 },
-#ifdef __i386__
- { " PC98", "Select an X server for a NEC PC98 [Submenu]",
- NULL, dmenuSubmenu, NULL, &MenuXF86SelectPC98Server, '>', ' ', '>', 0 },
-#elif __alpha__
- { " TGA", "TGA cards (alpha architecture only)",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_TGA },
-#endif
- { NULL } },
-};
-
-#ifdef __i386__
-DMenu MenuXF86SelectPC98Server = {
- DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS,
- "PC98 X Server selection.",
- "Please check off the types of NEC PC98 X servers you wish to install.\n\
-If you are unsure as to which server will work for your graphics card,\n\
-it is recommended that try the SVGA or VGA16 servers (the VGA16 and\n\
-Mono servers are particularly well-suited to most LCD displays).",
- NULL,
- NULL,
- { { " 9480", "PC98 8-bit (256 color) PEGC-480 card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9480 },
- { " 9EGC", "PC98 4-bit (16 color) EGC card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9EGC },
- { " 9GA9", "PC98 GA-968V4/PCI (S3 968) card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9GA9 },
- { " 9GAN", "PC98 GANB-WAP (cirrus) card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9GAN },
- { " 9LPW", "PC98 PowerWindowLB (S3) card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9LPW },
- { " 9MGA", "PC98 MGA (Matrox) card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9MGA },
- { " 9NKV", "PC98 NKV-NEC (cirrus) card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9NKV },
- { " 9NS3", "PC98 NEC (S3) card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9NS3 },
- { " 9SPW", "PC98 SKB-PowerWindow (S3) card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9SPW },
- { " 9SVG", "PC98 generic SVGA card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9SVG },
- { " 9TGU", "PC98 Cyber9320 and TGUI9680 cards",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9TGU },
- { " 9WEP", "PC98 WAB-EP (cirrus) card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9WEP },
- { " 9WS", "PC98 WABS (cirrus) card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9WS },
- { " 9WSN", "PC98 WSN-A2F (cirrus) card",
- dmenuFlagCheck, dmenuSetFlag, NULL, &XF86ServerDists, '[', 'X', ']', DIST_XF86_SERVER_9WSN },
- { NULL } }
-};
-#endif
-
-DMenu MenuDiskDevices = {
- DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS,
- "Select Drive(s)",
- "Please select the drive, or drives, on which you wish to perform\n"
- "this operation. If you are attempting to install a boot partition\n"
- "on a drive other than the first one or have multiple operating\n"
- "systems on your machine, you will have the option to install a boot\n"
- "manager later. To select a drive, use the arrow keys to move to it\n"
- "and press [SPACE]. To de-select it, press [SPACE] again.\n\n"
- "Select OK or Cancel to leave this menu.",
- "Press F1 for important information regarding disk geometry!",
- "drives",
- { { NULL } },
-};
-
-DMenu MenuHTMLDoc = {
- DMENU_NORMAL_TYPE,
- "Select HTML Documentation pointer",
- "Please select the body of documentation you're interested in, the main\n"
- "ones right now being the FAQ and the Handbook. You can also choose \"other\"\n"
- "to enter an arbitrary URL for browsing.",
- "Press F1 for more help on what you see here.",
- "html",
- { { "X Exit", "Exit this menu (returning to previous)", NULL, dmenuExit },
- { "2 Handbook", "The FreeBSD Handbook.", NULL, docShowDocument },
- { "3 FAQ", "The Frequently Asked Questions guide.", NULL, docShowDocument },
- { "4 Home", "The Home Pages for the FreeBSD Project (requires net)", NULL, docShowDocument },
- { "5 Other", "Enter a URL.", NULL, docShowDocument },
- { NULL } },
-};
-
-/* The main installation menu */
-DMenu MenuInstallCustom = {
- DMENU_NORMAL_TYPE,
- "Choose Custom Installation Options",
- "This is the custom installation menu. You may use this menu to specify\n"
- "details on the type of distribution you wish to have, where you wish\n"
- "to install it from and how you wish to allocate disk storage to FreeBSD.",
- "Press F1 to read the installation guide",
- "install",
- { { "X Exit", "Exit this menu (returning to previous)", NULL, dmenuExit },
- { "2 Options", "View/Set various installation options", NULL, optionsEditor },
-#ifdef __alpha__
- { "3 Label", "Label disk partitions", NULL, diskLabelEditor },
- { "4 Distributions", "Select distribution(s) to extract", NULL, dmenuSubmenu, NULL, &MenuDistributions },
- { "5 Media", "Choose the installation media type", NULL, dmenuSubmenu, NULL, &MenuMedia },
- { "6 Commit", "Perform any pending Partition/Label/Extract actions", NULL, installCustomCommit },
-#else
- { "3 Partition", "Allocate disk space for FreeBSD", NULL, diskPartitionEditor },
- { "4 Label", "Label allocated disk partitions", NULL, diskLabelEditor },
- { "5 Distributions", "Select distribution(s) to extract", NULL, dmenuSubmenu, NULL, &MenuDistributions },
- { "6 Media", "Choose the installation media type", NULL, dmenuSubmenu, NULL, &MenuMedia },
- { "7 Commit", "Perform any pending Partition/Label/Extract actions", NULL, installCustomCommit },
-#endif
- { NULL } },
-};
-
-/* MBR type menu */
-DMenu MenuMBRType = {
- DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS,
- "overwrite me", /* will be disk specific label */
- "FreeBSD comes with a boot selector that allows you to easily\n"
- "select between FreeBSD and any other operating systems on your machine\n"
- "at boot time. If you have more than one drive and want to boot\n"
- "from the second one, the boot selector will also make it possible\n"
- "to do so (limitations in the PC BIOS usually prevent this otherwise).\n"
- "If you do not want a boot selector, or wish to replace an existing\n"
- "one, select \"standard\". If you would prefer your Master Boot\n"
- "Record to remain untouched then select \"None\".\n\n"
- " NOTE: PC-DOS users will almost certainly require \"None\"!",
- "Press F1 to read about drive setup",
- "drives",
- { { "BootMgr", "Install the FreeBSD Boot Manager",
- dmenuRadioCheck, dmenuSetValue, NULL, &BootMgr },
- { "Standard", "Install a standard MBR (no boot manager)",
- dmenuRadioCheck, dmenuSetValue, NULL, &BootMgr, '(', '*', ')', 1 },
- { "None", "Leave the Master Boot Record untouched",
- dmenuRadioCheck, dmenuSetValue, NULL, &BootMgr, '(', '*', ')', 2 },
- { NULL } },
-};
-
-/* Final configuration menu */
-DMenu MenuConfigure = {
- DMENU_NORMAL_TYPE,
- "FreeBSD Configuration Menu", /* title */
- "If you've already installed FreeBSD, you may use this menu to customize\n"
- "it somewhat to suit your particular configuration. Most importantly,\n"
- "you can use the Packages utility to load extra \"3rd party\"\n"
- "software not provided in the base distributions.",
- "Press F1 for more information on these options",
- "configure",
- { { "X Exit", "Exit this menu (returning to previous)",
- NULL, dmenuExit },
- { " Distributions", "Install additional distribution sets",
- NULL, distExtractAll },
- { " Packages", "Install pre-packaged software for FreeBSD",
- NULL, configPackages },
- { " Root Password", "Set the system manager's password",
- NULL, dmenuSystemCommand, NULL, "passwd root" },
-#ifdef __i386__
- { " Fdisk", "The disk Slice (PC-style partition) Editor",
- NULL, diskPartitionEditor },
-#endif
- { " Label", "The disk Label editor",
- NULL, diskLabelEditor },
- { " User Management", "Add user and group information",
- NULL, dmenuSubmenu, NULL, &MenuUsermgmt },
- { " Console", "Customize system console behavior",
- NULL, dmenuSubmenu, NULL, &MenuSyscons },
- { " Time Zone", "Set which time zone you're in",
- NULL, dmenuSystemCommand, NULL, "tzsetup" },
- { " Media", "Change the installation media type",
- NULL, dmenuSubmenu, NULL, &MenuMedia },
- { " Mouse", "Configure your mouse",
- NULL, dmenuSubmenu, NULL, &MenuMouse, NULL },
- { " Networking", "Configure additional network services",
- NULL, dmenuSubmenu, NULL, &MenuNetworking },
- { " Startup", "Configure system startup options",
- NULL, dmenuSubmenu, NULL, &MenuStartup },
- { " Options", "View/Set various installation options",
- NULL, optionsEditor },
- { " XFree86", "Configure XFree86 Server",
- NULL, configXSetup },
- { " Desktop", "Configure XFree86 Desktop",
- NULL, configXDesktop },
- { " HTML Docs", "Go to the HTML documentation menu (post-install)",
- NULL, docBrowser },
- { NULL } },
-};
-
-DMenu MenuStartup = {
- DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS,
- "Startup Services Menu",
- "This menu allows you to configure various aspects of your system's\n"
- "startup configuration. Remember to use SPACE to select items! The\n"
- "RETURN key will leave this menu (as with all checkbox menus).",
- NULL,
- NULL,
- { { "X Exit", "Exit this menu (returning to previous)",
- checkTrue, dmenuExit, NULL, NULL, '<', '<', '<' },
- { " APM", "Auto-power management services (typically laptops)",
- dmenuVarCheck, dmenuToggleVariable, NULL, "apm_enable=YES" },
- { " pccard", "Enable PCCARD (AKA PCMCIA) services (also laptops)",
- dmenuVarCheck, dmenuToggleVariable, NULL, "pccard_enable=YES" },
- { " pccard mem", "Set PCCARD memory address (if enabled)",
- dmenuVarCheck, dmenuISetVariable, NULL, "pccard_mem" },
- { " pccard ifconfig", "List of PCCARD ethernet devices to configure",
- dmenuVarCheck, dmenuISetVariable, NULL, "pccard_ifconfig" },
- { " ", " -- ", NULL, NULL, NULL, NULL, ' ', ' ', ' ' },
- { " startup dirs", "Set the list of dirs to look for startup scripts",
- dmenuVarCheck, dmenuISetVariable, NULL, "local_startup" },
- { " named", "Run a local name server on this host",
- dmenuVarCheck, dmenuToggleVariable, NULL, "named_enable=YES" },
- { " named flags", "Set default flags to named (if enabled)",
- dmenuVarCheck, dmenuISetVariable, NULL, "named_flags" },
- { " nis client", "This host wishes to be an NIS client.",
- dmenuVarCheck, dmenuToggleVariable, NULL, "nis_client_enable=YES" },
- { " nis domainname", "Set NIS domainname (if enabled)",
- dmenuVarCheck, dmenuISetVariable, NULL, "nisdomainname" },
- { " nis server", "This host wishes to be an NIS server.",
- dmenuVarCheck, dmenuToggleVariable, NULL, "nis_server_enable=YES" },
- { " ", " -- ", NULL, NULL, NULL, NULL, ' ', ' ', ' ' },
- { " accounting", "This host wishes to run process accounting.",
- dmenuVarCheck, dmenuToggleVariable, NULL, "accounting_enable=YES" },
- { " lpd", "This host has a printer and wants to run lpd.",
- dmenuVarCheck, dmenuToggleVariable, NULL, "lpd_enable=YES" },
-#ifdef __i386__
- { " linux", "This host wants to be able to run linux binaries.",
- dmenuVarCheck, configLinux, NULL, VAR_LINUX_ENABLE "=YES" },
- { " SVR4", "This host wants to be able to run SVR4 binaries.",
- dmenuVarCheck, dmenuToggleVariable, NULL, "svr4_enable=YES" },
- { " SCO", "This host wants to be able to run IBCS2 binaries.",
- dmenuVarCheck, dmenuToggleVariable, NULL, "ibcs2_enable=YES" },
-#elif __alpha__
- { " OSF/1", "This host wants to be able to run DEC OSF/1 binaries.",
- dmenuVarCheck, dmenuToggleVariable, NULL, "osf1_enable=YES" },
-#endif
- { " quotas", "This host wishes to check quotas on startup.",
- dmenuVarCheck, dmenuToggleVariable, NULL, "check_quotas=YES" },
- { NULL } },
-};
-
-DMenu MenuNetworking = {
- DMENU_CHECKLIST_TYPE | DMENU_SELECTION_RETURNS,
- "Network Services Menu",
- "You may have already configured one network device (and the other\n"
- "various hostname/gateway/name server parameters) in the process\n"
- "of installing FreeBSD. This menu allows you to configure other\n"
- "aspects of your system's network configuration.",
- NULL,
- NULL,
- { { "X Exit", "Exit this menu (returning to previous)",
- checkTrue, dmenuExit, NULL, NULL, '<', '<', '<' },
- { " Interfaces", "Configure additional network interfaces",
- NULL, tcpMenuSelect },
- { " AMD", "This machine wants to run the auto-mounter service",
- dmenuVarCheck, dmenuToggleVariable, NULL, "amd_enable=YES" },
- { " AMD Flags", "Set flags to AMD service (if enabled)",
- dmenuVarCheck, dmenuISetVariable, NULL, "amd_flags" },
- { " Anon FTP", "This machine wishes to allow anonymous FTP.",
- dmenuVarCheck, configAnonFTP, NULL, "anon_ftp" },
- { " Gateway", "This machine will route packets between interfaces",
- dmenuVarCheck, dmenuToggleVariable, NULL, "gateway_enable=YES" },
- { " NFS client", "This machine will be an NFS client",
- dmenuVarCheck, dmenuToggleVariable, NULL, "nfs_client_enable=YES" },
- { " NFS server", "This machine will be an NFS server",
- dmenuVarCheck, configNFSServer, NULL, "nfs_server_enable=YES" },
- { " Ntpdate", "Select a clock-synchronization server",
- dmenuVarCheck, dmenuSubmenu, NULL, &MenuNTP, '[', 'X', ']', "ntpdate_enable=YES" },
- { " PCNFSD", "Run authentication server for clients with PC-NFS.",
- dmenuVarCheck, configPCNFSD, NULL, "pcnfsd" },
- { " Routed", "Select routing daemon (default: routed)",
- dmenuVarCheck, configRouter, NULL, "router_enable=YES" },
- { " Rwhod", "This machine wants to run the rwho daemon",
- dmenuVarCheck, dmenuToggleVariable, NULL, "rwhod_enable=YES" },
- { " Sendmail", "This machine wants to run the sendmail daemon",
- dmenuVarCheck, dmenuToggleVariable, NULL, "sendmail_enable=YES" },
- { " Sshd", "This machine wants to run the ssh daemon",
- dmenuVarCheck, dmenuToggleVariable, NULL, "sshd_enable=YES" },
- { " TCP Extensions", "Allow RFC1323 and RFC1644 TCP extensions?",
- dmenuVarCheck, dmenuToggleVariable, NULL, "tcp_extensions=YES" },
- { NULL } },
-};
-
-DMenu MenuNTP = {
- DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS,
- "NTPDATE Server Selection",
- "There are a number of time synchronization servers available\n"
- "for public use around the Internet. Please select one reasonably\n"
- "close to you to have your system time synchronized accordingly.",
- "These are the primary open-access NTP servers",
- NULL,
- { { "None", "No ntp server",
- dmenuVarsCheck, dmenuSetVariables, NULL,
- "ntpdate_enable=NO,ntpdate_flags=none" },
- { "Other", "Select a site not on this list",
- dmenuVarsCheck, configNTP, NULL, NULL },
- { "Australia", "ntp.syd.dms.csiro.au (HP 5061 Cesium Beam)",
- dmenuVarsCheck, dmenuSetVariables, NULL,
- "ntpdate_enable=YES,ntpdate_flags=ntp.syd.dms.csiro.au" },
- { " Canada", "tick.usask.ca (GOES clock)",
- dmenuVarsCheck, dmenuSetVariables, NULL,
- "ntpdate_enable=YES,ntpdate_flags=tick.usask.ca" },
- { "France", "canon.inria.fr (TDF clock)",
- dmenuVarsCheck, dmenuSetVariables, NULL,
- "ntpdate_enable=YES,ntpdate_flags=canon.inria.fr" },
- { "Germany", "ntps1-{0,1,2}.uni-erlangen.de (GPS)",
- dmenuVarsCheck, dmenuSetVariables, NULL,
- "ntpdate_enable=YES,ntpdate_flags=ntps1-0.uni-erlangen.de" },
- { " Germany #2", "ntps1-0.cs.tu-berlin.de (GPS)",
- dmenuVarsCheck, dmenuSetVariables, NULL,
- "ntpdate_enable=YES,ntpdate_flags=ntps1-0.cs.tu-berlin.de" },
- { "Japan", "clock.nc.fukuoka-u.ac.jp (GPS clock)",
- dmenuVarsCheck, dmenuSetVariables, NULL,
- "ntpdate_enable=YES,ntpdate_flags=clock.nc.fukuoka-u.ac.jp" },
- { " Japan #2", "clock.tl.fukuoka-u.ac.jp (GPS clock)",
- dmenuVarsCheck, dmenuSetVariables, NULL,
- "ntpdate_enable=YES,ntpdate_flags=clock.tl.fukuoka-u.ac.jp" },
- { "Netherlands", "ntp0.nl.net (GPS clock)",
- dmenuVarsCheck, dmenuSetVariables, NULL,
- "ntpdate_enable=YES,ntpdate_flags=ntp0.nl.net" },
- { " Norway", "timehost.ifi.uio.no (NTP clock)",
- dmenuVarsCheck, dmenuSetVariables, NULL,
- "ntpdate_enable=YES,ntpdate_flags=timehost.ifi.uio.no" },
- { "Sweden", "Time1.Stupi.SE (Cesium/GPS)",
- dmenuVarsCheck, dmenuSetVariables, NULL,
- "ntpdate_enable=YES,ntpdate_flags=Time1.Stupi.SE" },
- { " Switzerland", "swisstime.ethz.ch (DCF77 clock)",
- dmenuVarsCheck, dmenuSetVariables, NULL,
- "ntpdate_enable=YES,ntpdate_flags=swisstime.ethz.ch" },
- { "U.S. East Coast", "bitsy.mit.edu (WWV clock)",
- dmenuVarsCheck, dmenuSetVariables, NULL,
- "ntpdate_enable=YES,ntpdate_flags=bitsy.mit.edu" },
- { " U.S. East Coast #2", "otc1.psu.edu (WWV clock)",
- dmenuVarsCheck, dmenuSetVariables, NULL,
- "ntpdate_enable=YES,ntpdate_flags=otc1.psu.edu" },
- { " U.S. West Coast #1", "clepsydra.dec.com (GOES clock)",
- dmenuVarsCheck, dmenuSetVariables, NULL,
- "ntpdate_enable=YES,ntpdate_flags=clepsydra.dec.com" },
- { " U.S. West Coast #2", "clock.llnl.gov (WWVB clock)",
- dmenuVarsCheck, dmenuSetVariables, NULL,
- "ntpdate_enable=YES,ntpdate_flags=clock.llnl.gov" },
- { " U.S. Midwest", "ncar.ucar.edu (WWVB clock)",
- dmenuVarsCheck, dmenuSetVariables, NULL,
- "ntpdate_enable=YES,ntpdate_flags=ncar.ucar.edu" },
- { NULL } },
-};
-
-DMenu MenuSyscons = {
- DMENU_NORMAL_TYPE,
- "System Console Configuration",
- "The default system console driver for FreeBSD (syscons) has a\n"
- "number of configuration options which may be set according to\n"
- "your preference.\n\n"
- "When you are done setting configuration options, select Cancel.",
- "Configure your system console settings",
- NULL,
- { { "X Exit", "Exit this menu (returning to previous)", NULL, dmenuExit },
- { "2 Font", "Choose an alternate screen font", NULL, dmenuSubmenu, NULL, &MenuSysconsFont },
- { "3 Keymap", "Choose an alternate keyboard map", NULL, dmenuSubmenu, NULL, &MenuSysconsKeymap },
- { "4 Repeat", "Set the rate at which keys repeat", NULL, dmenuSubmenu, NULL, &MenuSysconsKeyrate },
- { "5 Saver", "Configure the screen saver", NULL, dmenuSubmenu, NULL, &MenuSysconsSaver },
- { "6 Screenmap", "Choose an alternate screenmap", NULL, dmenuSubmenu, NULL, &MenuSysconsScrnmap },
- { NULL } },
-};
-
-DMenu MenuSysconsKeymap = {
- DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS,
- "System Console Keymap",
- "The default system console driver for FreeBSD (syscons) defaults\n"
- "to a standard \"American\" keyboard map. Users in other countries\n"
- "(or with different keyboard preferences) may wish to choose one of\n"
- "the other keymaps below.\n"
- "Note that sysinstall itself only uses the part of the keyboard map\n"
- "which is required to generate the ANSI character subset, but your\n"
- "choice of keymap will also be saved for later (fuller) use.",
- "Choose a keyboard map",
- NULL,
- { { "Belgian", "Belgian ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=be.iso" },
- { " Brazil CP850", "Brazil CP850 keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=br275.cp850" },
- { " Brazil ISO (accent)", "Brazil ISO keymap (accent keys)", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=br275.iso.acc" },
- { " Brazil ISO", "Brazil ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=br275.iso" },
- { " Croatian ISO", "Croatian ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=hr.iso" },
- { "Danish CP865", "Danish Code Page 865 keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=danish.cp865" },
- { " Danish ISO", "Danish ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=danish.iso" },
- { "Estonian ISO", "Estonian ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=estonian.iso" },
- { " Estonian ISO 15", "Estonian ISO 8859-15 keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=estonian.iso15" },
- { " Estonian CP850", "Estonian Code Page 850 keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=estonian.cp850" },
- { " Finnish CP850","Finnish Code Page 850 keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=finnish.cp850" },
- { " Finnish ISO", "Finnish ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=finnish.iso" },
- { " French ISO (accent)", "French ISO keymap (accent keys)", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=fr.iso.acc" },
- { " French ISO", "French ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=fr.iso" },
- { "German CP850", "German Code Page 850 keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=german.cp850" },
- { " German ISO", "German ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=german.iso" },
- { "Hungarian 101", "Hungarian ISO keymap (101 key)", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=hu.iso2.101keys" },
- { " Hungarian 102", "Hungarian ISO keymap (102 key)", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=hu.iso2.102keys" },
- { "Icelandic (accent)", "Icelandic ISO keymap (accent keys)", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=icelandic.iso.acc" },
- { " Icelandic", "Icelandic ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=icelandic.iso" },
- { " Italian", "Italian ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=it.iso" },
- { "Latin American", "Latin American ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=lat-amer" },
- { "Japanese 106", "Japanese 106 keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=jp.106" },
- { "Norway ISO", "Norwegian ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=norwegian.iso" },
- { "Polish ISO", "Polish ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=pl_PL.ISO_8859-2" },
- { " Portuguese (accent)", "Portuguese ISO keymap (accent keys)", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=pt.iso.acc" },
- { " Portuguese", "Portuguese ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=pt.iso" },
- { "Russia CP866", "Russian CP866 keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=ru.cp866" },
- { " Russia KOI8-R", "Russian KOI8-R keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=ru.koi8-r" },
- { "Slovenian", "Slovenian ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=si.iso" },
- { " Spanish (accent)", "Spanish ISO keymap (accent keys)", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=spanish.iso.acc" },
- { " Spanish", "Spanish ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=spanish.iso" },
- { " Swedish CP850", "Swedish Code Page 850 keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=swedish.cp850" },
- { " Swedish ISO", "Swedish ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=swedish.iso" },
- { " Swiss French ISO (accent)", "Swiss French ISO keymap (accent keys)", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=swissfrench.iso.acc" },
- { " Swiss French ISO", "Swiss French ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=swissfrench.iso" },
- { " Swiss French CP850", "Swiss French Code Page 850 keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=swissfrench.cp850" },
- { " Swiss German ISO (accent)", "Swiss German ISO keymap (accent keys)", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=swissgerman.iso.acc" },
- { " Swiss German ISO", "Swiss German ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=swissgerman.iso" },
- { " Swiss German CP850", "Swiss German Code Page 850 keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=swissgerman.cp850" },
- { "U.K. CP850", "United Kingdom Code Page 850 keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=uk.cp850" },
- { " U.K. ISO", "United Kingdom ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=uk.iso" },
- { " U.S. Dvorak", "United States Dvorak keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=us.dvorak" },
- { " U.S. ISO", "United States ISO keymap", dmenuVarCheck, dmenuSetKmapVariable, NULL, "keymap=us.iso" },
- { NULL } },
-};
-
-DMenu MenuSysconsKeyrate = {
- DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS,
- "System Console Keyboard Repeat Rate",
- "This menu allows you to set the speed at which keys repeat\n"
- "when held down.",
- "Choose a keyboard repeat rate",
- NULL,
- { { "Slow", "Slow keyboard repeat rate", dmenuVarCheck, dmenuSetVariable, NULL, "keyrate=slow" },
- { "Normal", "\"Normal\" keyboard repeat rate", dmenuVarCheck, dmenuSetVariable, NULL, "keyrate=normal" },
- { "Fast", "Fast keyboard repeat rate", dmenuVarCheck, dmenuSetVariable, NULL, "keyrate=fast" },
- { "Default", "Use default keyboard repeat rate", dmenuVarCheck, dmenuSetVariable, NULL, "keyrate=NO" },
- { NULL } },
-};
-
-DMenu MenuSysconsSaver = {
- DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS,
- "System Console Screen Saver",
- "By default, the console driver will not attempt to do anything\n"
- "special with your screen when it's idle. If you expect to leave your\n"
- "monitor switched on and idle for long periods of time then you should\n"
- "probably enable one of these screen savers to prevent phosphor burn-in.",
- "Choose a nifty-looking screen saver",
- NULL,
- { { "1 Blank", "Simply blank the screen",
- dmenuVarCheck, configSaver, NULL, "saver=blank" },
- { "2 Daemon", "\"BSD Daemon\" animated screen saver (text)",
- dmenuVarCheck, configSaver, NULL, "saver=daemon" },
- { "3 Fade", "Fade out effect screen saver",
- dmenuVarCheck, configSaver, NULL, "saver=fade" },
- { "4 Fire", "Flames effect screen saver",
- dmenuVarCheck, configSaver, NULL, "saver=fire" },
- { "5 Green", "\"Green\" power saving mode (if supported by monitor)",
- dmenuVarCheck, configSaver, NULL, "saver=green" },
- { "6 Logo", "\"BSD Daemon\" animated screen saver (graphics)",
- dmenuVarCheck, configSaver, NULL, "saver=logo" },
- { "7 Rain", "Rain drops screen saver",
- dmenuVarCheck, configSaver, NULL, "saver=rain" },
- { "8 Snake", "Draw a FreeBSD \"snake\" on your screen",
- dmenuVarCheck, configSaver, NULL, "saver=snake" },
- { "9 Star", "A \"twinkling stars\" effect",
- dmenuVarCheck, configSaver, NULL, "saver=star" },
- { "Warp", "A \"stars warping\" effect",
- dmenuVarCheck, configSaver, NULL, "saver=warp" },
- { "Timeout", "Set the screen saver timeout interval",
- NULL, configSaverTimeout, NULL, NULL, ' ', ' ', ' ' },
- { NULL } },
-};
-
-DMenu MenuSysconsScrnmap = {
- DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS,
- "System Console Screenmap",
- "Unless you load a specific font, most PC hardware defaults to\n"
- "displaying characters in the IBM 437 character set. However,\n"
- "in the Unix world, this character set is very rarely used. Most\n"
- "Western European countries, for example, prefer ISO 8859-1.\n"
- "American users won't notice the difference since the bottom half\n"
- "of all these character sets is ANSI anyway.\n"
- "If your hardware is capable of downloading a new display font,\n"
- "you should probably choose that option. However, for hardware\n"
- "where this is not possible (e.g. monochrome adapters), a screen\n"
- "map will give you the best approximation that your hardware can\n"
- "display at all.",
- "Choose a screen map",
- NULL,
- { { "None", "No screenmap, use default font", dmenuVarCheck, dmenuSetVariable, NULL, "scrnmap=NO" },
- { "KOI8-R to IBM866", "Russian KOI8-R to IBM 866 screenmap", dmenuVarCheck, dmenuSetVariable, NULL, "scrnmap=koi8-r2cp866" },
- { "ISO 8859-1 to IBM437", "W-Europe ISO 8859-1 to IBM 437 screenmap", dmenuVarCheck, dmenuSetVariable, NULL, "scrnmap=iso-8859-1_to_cp437" },
- { NULL } },
-};
-
-DMenu MenuSysconsFont = {
- DMENU_RADIO_TYPE | DMENU_SELECTION_RETURNS,
- "System Console Font",
- "Most PC hardware defaults to displaying characters in the\n"
- "IBM 437 character set. However, in the Unix world, this\n"
- "character set is very rarely used. Most Western European\n"
- "countries, for example, prefer ISO 8859-1.\n"
- "American users won't notice the difference since the bottom half\n"
- "of all these charactersets is ANSI anyway. However, they might\n"
- "want to load a font anyway to use the 30- or 50-line displays.\n"
- "If your hardware is capable of downloading a new display font,\n"
- "you can select the appropriate font below.",
- "Choose a font",
- NULL,
- { { "1 None", "Use default font", dmenuVarCheck, dmenuSetVariables, NULL,
- "font8x8=NO,font8x14=NO,font8x16=NO" },
- { "2 IBM 437", "English", dmenuVarCheck, dmenuSetVariables, NULL,
- "font8x8=cp437-8x8,font8x14=cp437-8x14,font8x16=cp437-8x16" },
- { "3 IBM 850", "Western Europe, IBM encoding", dmenuVarCheck, dmenuSetVariables, NULL,
- "font8x8=cp850-8x8,font8x14=cp850-8x14,font8x16=cp850-8x16" },
- { "4 IBM 865", "Norwegian, IBM encoding", dmenuVarCheck, dmenuSetVariables, NULL,
- "font8x8=cp865-8x8,font8x14=cp865-8x14,font8x16=cp865-8x16" },
- { "5 IBM 866", "Russian, IBM encoding", dmenuVarCheck, dmenuSetVariables, NULL,
- "font8x8=cp866-8x8,font8x14=cp866-8x14,font8x16=cp866-8x16" },
- { "6 ISO 8859-1", "Western Europe, ISO encoding", dmenuVarCheck, dmenuSetVariables, NULL,
- "font8x8=iso-8x8,font8x14=iso-8x14,font8x16=iso-8x16" },
- { "7 ISO 8859-2", "Eastern Europe, ISO encoding", dmenuVarCheck, dmenuSetVariables, NULL,
- "font8x8=iso02-8x8,font8x14=iso02-8x14,font8x16=iso02-8x16" },
- { "8 KOI8-R", "Russian, KOI8-R encoding", dmenuVarCheck, dmenuSetVariables, NULL,
- "font8x8=koi8-r-8x8,font8x14=koi8-r-8x14,font8x16=koi8-r-8x16" },
- { "9 SWISS", "English, better resolution", dmenuVarCheck, dmenuSetVariables, NULL,
- "font8x8=swiss-8x8,font8x14=NO,font8x16=swiss-8x16" },
- { NULL } },
-};
-
-DMenu MenuUsermgmt = {
- DMENU_NORMAL_TYPE,
- "User and group management",
- "The submenus here allow to manipulate user groups and\n"
- "login accounts.\n",
- "Configure your user groups and users",
- NULL,
- { { "X Exit", "Exit this menu (returning to previous)", NULL, dmenuExit },
- { "User", "Add a new user to the system.", NULL, userAddUser },
- { "Group", "Add a new user group to the system.", NULL, userAddGroup },
- { NULL } },
-};
-
-DMenu MenuFixit = {
- DMENU_NORMAL_TYPE,
- "Please choose a fixit option",
- "There are three ways of going into \"fixit\" mode:\n"
- "- you can use the 2nd FreeBSD CDROM, in which case there will be\n"
- " full access to the complete set of FreeBSD commands and utilities,\n"
- "- you can use the more limited (but perhaps customized) fixit floppy,\n"
- "- or you can start an Emergency Holographic Shell now, which is\n"
- " limited to the subset of commands that is already available right now.",
- "Press F1 for more detailed repair instructions",
- "fixit",
-{ { "X Exit", "Exit this menu (returning to previous)", NULL, dmenuExit },
- { "2 CDROM", "Use the 2nd \"live\" CDROM from the distribution", NULL, installFixitCDROM },
- { "3 Floppy", "Use a floppy generated from the fixit image", NULL, installFixitFloppy },
- { "4 Shell", "Start an Emergency Holographic Shell", NULL, installFixitHoloShell },
- { NULL } },
-};
diff --git a/usr.sbin/sysinstall/misc.c b/usr.sbin/sysinstall/misc.c
deleted file mode 100644
index 4bba7e513dcb..000000000000
--- a/usr.sbin/sysinstall/misc.c
+++ /dev/null
@@ -1,484 +0,0 @@
-/*
- * Miscellaneous support routines..
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 "sysinstall.h"
-#include <ctype.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/errno.h>
-#include <sys/file.h>
-#include <sys/types.h>
-#include <dirent.h>
-#include <sys/wait.h>
-#include <sys/param.h>
-#include <sys/mount.h>
-#include <ufs/ufs/ufsmount.h>
-#include <sys/reboot.h>
-#include <sys/disklabel.h>
-
-/* Quick check to see if a file is readable */
-Boolean
-file_readable(char *fname)
-{
- if (!access(fname, F_OK))
- return TRUE;
- return FALSE;
-}
-
-/* Quick check to see if a file is executable */
-Boolean
-file_executable(char *fname)
-{
- if (!access(fname, X_OK))
- return TRUE;
- return FALSE;
-}
-
-/* Concatenate two strings into static storage */
-char *
-string_concat(char *one, char *two)
-{
- static char tmp[FILENAME_MAX];
-
- /* Yes, we're deliberately cavalier about not checking for overflow */
- strcpy(tmp, one);
- strcat(tmp, two);
- return tmp;
-}
-
-/* sane strncpy() function */
-char *
-sstrncpy(char *dst, const char *src, int size)
-{
- dst[size] = '\0';
- return strncpy(dst, src, size);
-}
-
-/* Concatenate three strings into static storage */
-char *
-string_concat3(char *one, char *two, char *three)
-{
- static char tmp[FILENAME_MAX];
-
- /* Yes, we're deliberately cavalier about not checking for overflow */
- strcpy(tmp, one);
- strcat(tmp, two);
- strcat(tmp, three);
- return tmp;
-}
-
-/* Clip the whitespace off the end of a string */
-char *
-string_prune(char *str)
-{
- int len = str ? strlen(str) : 0;
-
- while (len && isspace(str[len - 1]))
- str[--len] = '\0';
- return str;
-}
-
-/* run the whitespace off the front of a string */
-char *
-string_skipwhite(char *str)
-{
- while (*str && isspace(*str))
- ++str;
- return str;
-}
-
-/* copy optionally and allow second arg to be null */
-char *
-string_copy(char *s1, char *s2)
-{
- if (!s1)
- return NULL;
- if (!s2)
- s1[0] = '\0';
- else
- strcpy(s1, s2);
- return s1;
-}
-
-/* convert an integer to a string, using a static buffer */
-char *
-itoa(int value)
-{
- static char buf[13];
-
- snprintf(buf, 12, "%d", value);
- return buf;
-}
-
-Boolean
-directory_exists(const char *dirname)
-{
- DIR *tptr;
-
- if (!dirname)
- return FALSE;
- if (!strlen(dirname))
- return FALSE;
-
- tptr = opendir(dirname);
- if (!tptr)
- return (FALSE);
-
- closedir(tptr);
- return (TRUE);
-}
-
-char *
-pathBaseName(const char *path)
-{
- char *pt;
- char *ret = (char *)path;
-
- pt = strrchr(path,(int)'/');
-
- if (pt != 0) /* if there is a slash */
- {
- ret = ++pt; /* start the file after it */
- }
-
- return(ret);
-}
-
-/* A free guaranteed to take NULL ptrs */
-void
-safe_free(void *ptr)
-{
- if (ptr)
- free(ptr);
-}
-
-/* A malloc that checks errors */
-void *
-safe_malloc(size_t size)
-{
- void *ptr;
-
- if (size <= 0)
- msgFatal("Invalid malloc size of %d!", size);
- ptr = malloc(size);
- if (!ptr)
- msgFatal("Out of memory!");
- bzero(ptr, size);
- return ptr;
-}
-
-/* A realloc that checks errors */
-void *
-safe_realloc(void *orig, size_t size)
-{
- void *ptr;
-
- if (size <= 0)
- msgFatal("Invalid realloc size of %d!", size);
- ptr = realloc(orig, size);
- if (!ptr)
- msgFatal("Out of memory!");
- return ptr;
-}
-
-/* Create a path biased from the VAR_INSTALL_ROOT variable (if not /) */
-char *
-root_bias(char *path)
-{
- static char tmp[FILENAME_MAX];
- char *cp = variable_get(VAR_INSTALL_ROOT);
-
- if (!strcmp(cp, "/"))
- return path;
- strcpy(tmp, variable_get(VAR_INSTALL_ROOT));
- strcat(tmp, path);
- return tmp;
-}
-
-/*
- * These next routines are kind of specialized just for building item lists
- * for dialog_menu().
- */
-
-/* Add an item to an item list */
-dialogMenuItem *
-item_add(dialogMenuItem *list, char *prompt, char *title,
- int (*checked)(dialogMenuItem *self),
- int (*fire)(dialogMenuItem *self),
- void (*selected)(dialogMenuItem *self, int is_selected),
- void *data, int aux, int *curr, int *max)
-{
- dialogMenuItem *d;
-
- if (*curr == *max) {
- *max += 20;
- list = (dialogMenuItem *)realloc(list, sizeof(dialogMenuItem) * *max);
- }
- d = &list[(*curr)++];
- bzero(d, sizeof(*d));
- d->prompt = prompt ? strdup(prompt) : NULL;
- d->title = title ? strdup(title) : NULL;
- d->checked = checked;
- d->fire = fire;
- d->selected = selected;
- d->data = data;
- d->aux = aux;
- return list;
-}
-
-/* Toss the items out */
-void
-items_free(dialogMenuItem *list, int *curr, int *max)
-{
- int i;
-
- for (i = 0; list[i].prompt; i++) {
- safe_free(list[i].prompt);
- safe_free(list[i].title);
- }
- safe_free(list);
- *curr = *max = 0;
-}
-
-int
-Mkdir(char *ipath)
-{
- struct stat sb;
- int final;
- char *p, *path;
-
- if (file_readable(ipath) || Fake)
- return DITEM_SUCCESS;
-
- path = strcpy(alloca(strlen(ipath) + 1), ipath);
- if (isDebug())
- msgDebug("mkdir(%s)\n", path);
- p = path;
- if (p[0] == '/') /* Skip leading '/'. */
- ++p;
- for (final = FALSE; !final; ++p) {
- if (p[0] == '\0' || (p[0] == '/' && p[1] == '\0'))
- final = TRUE;
- else if (p[0] != '/')
- continue;
- *p = '\0';
- if (stat(path, &sb)) {
- if (errno != ENOENT) {
- msgConfirm("Couldn't stat directory %s: %s", path, strerror(errno));
- return DITEM_FAILURE;
- }
- if (isDebug())
- msgDebug("mkdir(%s..)\n", path);
- if (mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
- msgConfirm("Couldn't create directory %s: %s", path,strerror(errno));
- return DITEM_FAILURE;
- }
- }
- *p = '/';
- }
- return DITEM_SUCCESS;
-}
-
-int
-Mount(char *mountp, void *dev)
-{
- struct ufs_args ufsargs;
- char device[80];
- char mountpoint[FILENAME_MAX];
-
- if (Fake)
- return DITEM_SUCCESS;
-
- if (*((char *)dev) != '/') {
- sprintf(device, "%s/dev/%s", RunningAsInit ? "/mnt" : "", (char *)dev);
- sprintf(mountpoint, "%s%s", RunningAsInit ? "/mnt" : "", mountp);
- }
- else {
- strcpy(device, dev);
- strcpy(mountpoint, mountp);
- }
- memset(&ufsargs,0,sizeof ufsargs);
-
- if (Mkdir(mountpoint)) {
- msgConfirm("Unable to make directory mountpoint for %s!", mountpoint);
- return DITEM_FAILURE;
- }
- if (isDebug())
- msgDebug("mount %s %s\n", device, mountpoint);
-
- ufsargs.fspec = device;
- if (mount("ufs", mountpoint, RunningAsInit ? MNT_ASYNC | MNT_NOATIME : 0,
- (caddr_t)&ufsargs) == -1) {
- msgConfirm("Error mounting %s on %s : %s", device, mountpoint, strerror(errno));
- return DITEM_FAILURE;
- }
- return DITEM_SUCCESS;
-}
-
-WINDOW *
-openLayoutDialog(char *helpfile, char *title, int x, int y, int width, int height)
-{
- WINDOW *win;
- static char help[FILENAME_MAX];
-
- /* We need a curses window */
- win = newwin(LINES, COLS, 0, 0);
- if (win) {
- /* Say where our help comes from */
- if (helpfile) {
- use_helpline("Press F1 for more information on this screen.");
- use_helpfile(systemHelpFile(helpfile, help));
- }
- /* Setup a nice screen for us to splat stuff onto */
- draw_box(win, y, x, height, width, dialog_attr, border_attr);
- wattrset(win, dialog_attr);
- mvwaddstr(win, y, x + (COLS - strlen(title)) / 2, title);
- }
- return win;
-}
-
-ComposeObj *
-initLayoutDialog(WINDOW *win, Layout *layout, int x, int y, int *max)
-{
- ComposeObj *obj = NULL, *first;
- int n;
-
- /* Loop over the layout list, create the objects, and add them
- onto the chain of objects that dialog uses for traversal*/
-
- n = 0;
- while (layout[n].help != NULL) {
- int t = TYPE_OF_OBJ(layout[n].type);
-
- switch (t) {
- case STRINGOBJ:
- layout[n].obj = NewStringObj(win, layout[n].prompt, layout[n].var,
- layout[n].y + y, layout[n].x + x, layout[n].len, layout[n].maxlen);
- ((StringObj *)layout[n].obj)->attr_mask = ATTR_OF_OBJ(layout[n].type);
- break;
-
- case BUTTONOBJ:
- layout[n].obj = NewButtonObj(win, layout[n].prompt, layout[n].var, layout[n].y + y, layout[n].x + x);
- break;
-
- default:
- msgFatal("Don't support this object yet!");
- }
- AddObj(&obj, t, (void *) layout[n].obj);
- n++;
- }
- *max = n - 1;
- /* Find the first object in the list */
- for (first = obj; first->prev; first = first->prev);
- return first;
-}
-
-int
-layoutDialogLoop(WINDOW *win, Layout *layout, ComposeObj **obj, int *n, int max, int *cbutton, int *cancel)
-{
- char help_line[80];
- int ret, i, len = strlen(layout[*n].help);
-
- /* Display the help line at the bottom of the screen */
- for (i = 0; i < 79; i++)
- help_line[i] = (i < len) ? layout[*n].help[i] : ' ';
- help_line[i] = '\0';
- use_helpline(help_line);
- display_helpline(win, LINES - 1, COLS - 1);
- wrefresh(win);
-
- /* Ask for libdialog to do its stuff */
- ret = PollObj(obj);
- /* Handle special case stuff that libdialog misses. Sigh */
- switch (ret) {
- case SEL_ESC: /* Bail out */
- *cancel = TRUE;
- return FALSE;
-
- /* This doesn't work for list dialogs. Oh well. Perhaps
- should special case the move from the OK button ``up''
- to make it go to the interface list, but then it gets
- awkward for the user to go back and correct screw up's
- in the per-interface section */
- case KEY_DOWN:
- case SEL_CR:
- case SEL_TAB:
- if (*n < max)
- ++*n;
- else
- *n = 0;
- break;
-
- /* The user has pressed enter over a button object */
- case SEL_BUTTON:
- if (cbutton && *cbutton)
- *cancel = TRUE;
- else
- *cancel = FALSE;
- return FALSE;
-
- case KEY_UP:
- case SEL_BACKTAB:
- if (*n)
- --*n;
- else
- *n = max;
- break;
-
- case KEY_F(1):
- display_helpfile();
-
- /* They tried some key combination we don't support - tootle them forcefully! */
- default:
- beep();
- }
- return TRUE;
-}
-
-WINDOW *
-savescr(void)
-{
- WINDOW *w;
-
- w = dupwin(newscr);
- return w;
-}
-
-void
-restorescr(WINDOW *w)
-{
- touchwin(w);
- wrefresh(w);
- delwin(w);
-}
-
diff --git a/usr.sbin/sysinstall/mouse.c b/usr.sbin/sysinstall/mouse.c
deleted file mode 100644
index 2eec6be8e954..000000000000
--- a/usr.sbin/sysinstall/mouse.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/*-
- * Copyright (c) 1998 Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
- * 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 AUTHRO 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 AUTHRO 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.
- *
- * $FreeBSD$
- */
-
-#include "sysinstall.h"
-#include <string.h>
-
-int
-mousedTest(dialogMenuItem *self)
-{
- char *type;
- char *port;
- int ret;
-
- type = variable_get(VAR_MOUSED_TYPE);
- port = variable_get(VAR_MOUSED_PORT);
- if ((type == NULL) || (port == NULL)
- || (strlen(type) <= 0) || (strlen(port) <= 0)
- || (strcmp(type, "NO") == 0)) {
- msgConfirm("Please select a mouse protocol and a port first.");
- return DITEM_FAILURE;
- }
-
- msgNotify("Trying to start the mouse daemon...");
- if (file_readable("/var/run/moused.pid"))
- vsystem("kill `cat /var/run/moused.pid`");
- systemExecute("vidcontrol -m on");
- vsystem("moused -t %s -p %s", type, port);
-
- ret = msgYesNo("Now move the mouse and see if it works.\n"
- "(Note that buttons don't have any effect for now.)\n\n"
- " Is the mouse cursor moving?\n");
- systemExecute("vidcontrol -m off");
- if (ret) {
- if (file_readable("/var/run/moused.pid"))
- vsystem("kill `cat /var/run/moused.pid`");
- variable_set2(VAR_MOUSED, "NO", 1);
- } else {
- variable_set2(VAR_MOUSED, "YES", 1);
- vsystem("ln -fs /dev/sysmouse /dev/mouse"); /* backwards compat */
- }
-
- return DITEM_SUCCESS | DITEM_RESTORE;
-}
-
-int
-mousedDisable(dialogMenuItem *self)
-{
- if (file_readable("/var/run/moused.pid"))
- vsystem("kill `cat /var/run/moused.pid`");
- variable_set2(VAR_MOUSED, "NO", 1);
- variable_set2(VAR_MOUSED_TYPE, "NO", 1);
- variable_unset(VAR_MOUSED_PORT);
- msgConfirm("The mouse daemon is disabled.");
- return DITEM_SUCCESS;
-}
diff --git a/usr.sbin/sysinstall/msg.c b/usr.sbin/sysinstall/msg.c
deleted file mode 100644
index 499d70501a37..000000000000
--- a/usr.sbin/sysinstall/msg.c
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last program in the `sysinstall' line - the next
- * generation being essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 "sysinstall.h"
-#include <stdarg.h>
-#include <sys/ioctl.h>
-#include <machine/console.h>
-
-Boolean
-isDebug(void)
-{
- char *cp;
-
- return (cp = variable_get(VAR_DEBUG)) && strcmp(cp, "no");
-}
-
-/* Whack up an informational message on the status line, in stand-out */
-void
-msgYap(char *fmt, ...)
-{
- va_list args;
- char *errstr;
- int attrs;
-
- errstr = (char *)alloca(FILENAME_MAX);
- va_start(args, fmt);
- vsnprintf(errstr, FILENAME_MAX, fmt, args);
- va_end(args);
- attrs = getattrs(stdscr);
- attrset(A_REVERSE);
- mvaddstr(StatusLine, 0, errstr);
- attrset(attrs);
- refresh();
-}
-
-/* Whack up an informational message on the status line */
-void
-msgInfo(char *fmt, ...)
-{
- va_list args;
- char *errstr;
- int i, attrs;
- char line[81];
-
- attrs = getattrs(stdscr);
- /* NULL is a special convention meaning "erase the old stuff" */
- if (!fmt) {
- move(StatusLine, 0);
- clrtoeol();
- return;
- }
- errstr = (char *)alloca(FILENAME_MAX);
- va_start(args, fmt);
- vsnprintf(errstr, FILENAME_MAX, fmt, args);
- va_end(args);
- memset(line, ' ', 80);
- for (i = 0; i < 80; i++) {
- if (errstr[i])
- line[i] = errstr[i];
- else
- break;
- }
- line[80] = '\0';
- attrset(ATTR_TITLE);
- mvaddstr(StatusLine, 0, line);
- attrset(attrs);
- move(StatusLine, 79);
- refresh();
-}
-
-/* Whack up a warning on the status line */
-void
-msgWarn(char *fmt, ...)
-{
- va_list args;
- char *errstr;
- int attrs;
-
- errstr = (char *)alloca(FILENAME_MAX);
- strcpy(errstr, "Warning: ");
- va_start(args, fmt);
- vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args);
- va_end(args);
- attrs = getattrs(stdscr);
- beep();
- attrset(ATTR_TITLE);
- mvaddstr(StatusLine, 0, errstr);
- attrset(attrs);
- refresh();
- if (OnVTY && isDebug())
- msgDebug("Warning message `%s'\n", errstr);
-}
-
-/* Whack up an error on the status line */
-void
-msgError(char *fmt, ...)
-{
- va_list args;
- char *errstr;
- int attrs;
-
- errstr = (char *)alloca(FILENAME_MAX);
- strcpy(errstr, "Error: ");
- va_start(args, fmt);
- vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args);
- va_end(args);
- beep();
- attrs = getattrs(stdscr);
- attrset(ATTR_TITLE);
- mvaddstr(StatusLine, 0, errstr);
- attrset(attrs);
- refresh();
- if (OnVTY && isDebug())
- msgDebug("Error message `%s'\n", errstr);
-}
-
-/* Whack up a fatal error on the status line */
-void
-msgFatal(char *fmt, ...)
-{
- va_list args;
- char *errstr;
- int attrs;
-
- errstr = (char *)alloca(FILENAME_MAX);
- strcpy(errstr, "Fatal Error: ");
- va_start(args, fmt);
- vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args);
- va_end(args);
- beep();
- attrs = getattrs(stdscr);
- attrset(ATTR_TITLE);
- mvaddstr(StatusLine, 0, errstr);
- addstr(" - ");
- addstr("PRESS ANY KEY TO ");
- if (getpid() == 1)
- addstr("REBOOT");
- else
- addstr("QUIT");
- attrset(attrs);
- refresh();
- if (OnVTY)
- msgDebug("Fatal error `%s'!\n", errstr);
- getch();
- systemShutdown(1);
-}
-
-/* Put up a message in a popup confirmation box */
-void
-msgConfirm(char *fmt, ...)
-{
- va_list args;
- char *errstr;
- WINDOW *w = savescr();
-
- errstr = (char *)alloca(FILENAME_MAX);
- va_start(args, fmt);
- vsnprintf(errstr, FILENAME_MAX, fmt, args);
- va_end(args);
- use_helpline(NULL);
- use_helpfile(NULL);
- if (OnVTY) {
- ioctl(0, VT_ACTIVATE, 1);
- msgInfo(NULL);
- }
- dialog_notify(errstr);
- restorescr(w);
-}
-
-/* Put up a message in a popup information box */
-void
-msgNotify(char *fmt, ...)
-{
- va_list args;
- char *errstr;
-
- errstr = (char *)alloca(FILENAME_MAX);
- va_start(args, fmt);
- vsnprintf(errstr, FILENAME_MAX, fmt, args);
- va_end(args);
- use_helpline(NULL);
- use_helpfile(NULL);
- if (isDebug())
- msgDebug("Notify: %s\n", errstr);
- dialog_msgbox(NULL, errstr, -1, -1, 0);
-}
-
-/* Put up a message in a popup yes/no box and return 1 for YES, 0 for NO */
-int
-msgYesNo(char *fmt, ...)
-{
- va_list args;
- char *errstr;
- int ret;
- WINDOW *w = savescr();
-
- errstr = (char *)alloca(FILENAME_MAX);
- va_start(args, fmt);
- vsnprintf(errstr, FILENAME_MAX, fmt, args);
- va_end(args);
- use_helpline(NULL);
- use_helpfile(NULL);
- if (OnVTY) {
- ioctl(0, VT_ACTIVATE, 1); /* Switch back */
- msgInfo(NULL);
- }
- ret = dialog_yesno("User Confirmation Requested", errstr, -1, -1);
- restorescr(w);
- return ret;
-}
-
-/* Put up a message in an input box and return the value */
-char *
-msgGetInput(char *buf, char *fmt, ...)
-{
- va_list args;
- char *errstr;
- static char input_buffer[256];
- int rval;
- WINDOW *w = savescr();
-
- errstr = (char *)alloca(FILENAME_MAX);
- va_start(args, fmt);
- vsnprintf(errstr, FILENAME_MAX, fmt, args);
- va_end(args);
- use_helpline(NULL);
- use_helpfile(NULL);
- if (buf)
- SAFE_STRCPY(input_buffer, buf);
- else
- input_buffer[0] = '\0';
- if (OnVTY) {
- ioctl(0, VT_ACTIVATE, 1); /* Switch back */
- msgInfo(NULL);
- }
- rval = dialog_inputbox("Value Required", errstr, -1, -1, input_buffer);
- restorescr(w);
- if (!rval)
- return input_buffer;
- else
- return NULL;
-}
-
-/* Write something to the debugging port */
-void
-msgDebug(char *fmt, ...)
-{
- va_list args;
- char *dbg;
-
- if (DebugFD == -1)
- return;
- dbg = (char *)alloca(FILENAME_MAX);
- strcpy(dbg, "DEBUG: ");
- va_start(args, fmt);
- vsnprintf((char *)(dbg + strlen(dbg)), FILENAME_MAX, fmt, args);
- va_end(args);
- write(DebugFD, dbg, strlen(dbg));
-}
-
-/* Tell the user there's some output to go look at */
-void
-msgWeHaveOutput(char *fmt, ...)
-{
- va_list args;
- char *errstr;
- WINDOW *w = savescr();
-
- errstr = (char *)alloca(FILENAME_MAX);
- va_start(args, fmt);
- vsnprintf(errstr, FILENAME_MAX, fmt, args);
- va_end(args);
- use_helpline(NULL);
- use_helpfile(NULL);
- msgDebug("Notify: %s\n", errstr);
- dialog_clear_norefresh();
- sleep(2);
- dialog_msgbox(NULL, errstr, -1, -1, 0);
- restorescr(w);
-}
-
-/* Simple versions of msgConfirm() and msgNotify() for calling from scripts */
-int
-msgSimpleConfirm(char *str)
-{
- msgConfirm(str);
- return DITEM_SUCCESS;
-}
-
-int
-msgSimpleNotify(char *str)
-{
- msgNotify(str);
- return DITEM_SUCCESS;
-}
diff --git a/usr.sbin/sysinstall/network.c b/usr.sbin/sysinstall/network.c
deleted file mode 100644
index 5e064a7ae070..000000000000
--- a/usr.sbin/sysinstall/network.c
+++ /dev/null
@@ -1,353 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last attempt in the `sysinstall' line, the next
- * generation being slated to essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- *
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 routines deal with getting things off of network media */
-
-#include "sysinstall.h"
-#include <signal.h>
-#include <termios.h>
-#include <sys/fcntl.h>
-#include <sys/ioctl.h>
-#include <sys/stat.h>
-
-static Boolean networkInitialized;
-static pid_t startPPP(Device *devp);
-
-static pid_t pppPID;
-
-Boolean
-mediaInitNetwork(Device *dev)
-{
- int i;
- char *rp;
- char *cp, ifconfig[255];
- WINDOW *w;
-
- if (!RunningAsInit || networkInitialized)
- return TRUE;
-
- if (isDebug())
- msgDebug("Init routine called for network device %s.\n", dev->name);
-
- if (!file_readable("/etc/resolv.conf")) {
- if (DITEM_STATUS(configResolv(NULL)) == DITEM_FAILURE) {
- msgConfirm("Can't seem to write out /etc/resolv.conf. Net cannot be used.");
- return FALSE;
- }
- }
-
- w = savescr();
- dialog_clear_norefresh();
-
- /* Old PPP process lying around? */
- if (pppPID) {
- msgConfirm("Killing previous PPP process %d.", pppPID);
- kill(pppPID, SIGTERM);
- pppPID = 0;
- }
- if (!strncmp("ppp", dev->name, 3)) { /* PPP? */
- if (!(pppPID = startPPP(dev))) {
- msgConfirm("Unable to start PPP! This installation method cannot be used.");
- return FALSE;
- }
- networkInitialized = TRUE;
- return TRUE;
- }
- else if (!strncmp("sl", dev->name, 2)) { /* SLIP? */
- char *val;
- char attach[256];
-
- /* Cheesy slip attach */
- snprintf(attach, 256, "slattach -a -h -l -s 9600 %s", dev->devname);
- val = msgGetInput(attach,
- "Warning: SLIP is rather poorly supported in this revision\n"
- "of the installation due to the lack of a dialing utility.\n"
- "If you can use PPP for this instead then you're much better\n"
- "off doing so, otherwise SLIP works fairly well for *hardwired*\n"
- "links. Please edit the following slattach command for\n"
- "correctness (default here is: VJ compression, Hardware flow-\n"
- "control, ignore carrier and 9600 baud data rate). When you're\n"
- "ready, press [ENTER] to execute it.");
- if (!val) {
- msgConfirm("slattach command was empty. Try again!");
- restorescr(w);
- return FALSE;
- }
- else
- SAFE_STRCPY(attach, val);
- /*
- * Doing this with vsystem() is actually bogus since we should be storing the pid of slattach
- * for later killing. It's just too convenient to call vsystem(), however, rather than
- * constructing a proper argument for exec() so we punt on doing slip right for now.
- */
- if (vsystem(attach)) {
- msgConfirm("slattach returned a bad status! Please verify that\n"
- "the command is correct and try this operation again.");
- restorescr(w);
- return FALSE;
- }
- restorescr(w);
- }
-
- snprintf(ifconfig, 255, "%s%s", VAR_IFCONFIG, dev->name);
- cp = variable_get(ifconfig);
- if (!cp) {
- msgConfirm("The %s device is not configured. You will need to do so\n"
- "in the Networking configuration menu before proceeding.", dev->name);
- return FALSE;
- }
- else if (!strcmp(cp, "DHCP"))
- goto bail;
- msgDebug("ifconfig %s %s", dev->name, cp);
- i = vsystem("ifconfig %s %s", dev->name, cp);
- if (i) {
- msgConfirm("Unable to configure the %s interface!\n"
- "This installation method cannot be used.", dev->name);
- return FALSE;
- }
-
- rp = variable_get(VAR_GATEWAY);
- if (!rp || *rp == '0') {
- msgConfirm("No gateway has been set. You may be unable to access hosts\n"
- "not on your local network");
- }
- else {
- msgDebug("Adding default route to %s.", rp);
- vsystem("route -n add default %s", rp);
- }
-bail:
- if (isDebug())
- msgDebug("Network initialized successfully.\n");
- networkInitialized = TRUE;
- return TRUE;
-}
-
-void
-mediaShutdownNetwork(Device *dev)
-{
- char *cp;
-
- if (!RunningAsInit || !networkInitialized)
- return;
-
- msgDebug("Shutdown called for network device %s\n", dev->name);
- /* Not a serial device? */
- if (strncmp("sl", dev->name, 2) && strncmp("ppp", dev->name, 3)) {
- int i;
- char ifconfig[255];
-
- snprintf(ifconfig, 255, "%s%s", VAR_IFCONFIG, dev->name);
- cp = variable_get(ifconfig);
- if (!cp)
- return;
- msgDebug("ifconfig %s down", dev->name);
- i = vsystem("ifconfig %s down", dev->name);
- if (i)
- msgConfirm("Warning: Unable to down the %s interface properly", dev->name);
- cp = variable_get(VAR_GATEWAY);
- if (cp) {
- msgDebug("Deleting default route.");
- vsystem("route -n delete default");
- }
- }
- else if (pppPID) {
- msgConfirm("Killing previous PPP process %d.", pppPID);
- kill(pppPID, SIGTERM);
- pppPID = 0;
- }
- networkInitialized = FALSE;
-}
-
-/* Start PPP on the 3rd screen */
-static pid_t
-startPPP(Device *devp)
-{
- int fd2, pulse;
- FILE *fp;
- char *val;
- pid_t pid = 0;
- char myaddr[16], provider[16], speed[16], authname[32], authkey[16];
- char phone[16];
- WINDOW *w = savescr();
-
- /* These are needed to make ppp work */
- Mkdir("/var/log");
- Mkdir("/var/run");
- Mkdir("/var/spool/lock");
- Mkdir("/etc/ppp");
-
- dialog_clear_norefresh();
- if (!variable_get(VAR_SERIAL_SPEED))
- variable_set2(VAR_SERIAL_SPEED, "115200", 0);
- /* Get any important user values */
- val = variable_get_value(VAR_SERIAL_SPEED,
- "Enter the baud rate for your modem - this can be higher than the actual\n"
- "maximum data rate since most modems can talk at one speed to the\n"
- "computer and at another speed to the remote end.\n\n"
- "If you're not sure what to put here, just select the default.", 0);
- SAFE_STRCPY(speed, (val && *val) ? val : "115200");
-
- val = variable_get(VAR_GATEWAY);
- SAFE_STRCPY(provider, (val && *val) ? val : "0");
-
- dialog_clear_norefresh();
- val = msgGetInput(provider, "Enter the IP address of your service provider or 0 if you\n"
- "don't know it and would prefer to negotiate it dynamically.");
- SAFE_STRCPY(provider, (val && *val) ? val : "0");
-
- if (devp->private && ((DevInfo *)devp->private)->ipaddr[0])
- SAFE_STRCPY(myaddr, ((DevInfo *)devp->private)->ipaddr);
- else
- strcpy(myaddr, "0");
-
- if (!Fake)
- fp = fopen("/etc/ppp/ppp.linkup", "w");
- else
- fp = fopen("/dev/stderr", "w");
- if (fp != NULL) {
- fprintf(fp, "MYADDR:\n");
- fprintf(fp, " delete ALL\n");
- fprintf(fp, " add 0 0 HISADDR\n");
- fchmod(fileno(fp), 0755);
- fclose(fp);
- }
- if (!Fake)
- fd2 = open("/etc/ppp/ppp.secret", O_CREAT);
- else
- fd2 = -1;
- if (fd2 != -1) {
- fchmod(fd2, 0700);
- close(fd2);
- }
- if (!Fake)
- fp = fopen("/etc/ppp/ppp.conf", "a");
- else
- fp = fopen("/dev/stderr", "w");
- if (!fp) {
- msgConfirm("Couldn't open /etc/ppp/ppp.conf file! This isn't going to work");
- restorescr(w);
- return 0;
- }
- authname[0] = '\0';
- pulse = 0;
- dialog_clear_norefresh();
- if (!dialog_yesno("", "Does your ISP support PAP or CHAP ppp logins?", -1, -1)) {
- val = msgGetInput(NULL, "Enter the name you use to login to your provider.");
- SAFE_STRCPY(authname, val);
- dialog_clear_norefresh();
- val = msgGetInput(NULL, "Enter the password you use to login to your provider.");
- SAFE_STRCPY(authkey, val);
- dialog_clear_norefresh();
- val = msgGetInput(NULL, "Enter the your provider's login phone number.");
- SAFE_STRCPY(phone, val);
- dialog_clear_norefresh();
- pulse = dialog_yesno("", "Does your telephone line support tone dialing?", -1, -1);
- }
- fprintf(fp, "\ninstall:\n");
- fprintf(fp, " set speed %s\n", speed);
- fprintf(fp, " set device %s\n", devp->devname);
- fprintf(fp, " set ifaddr %s %s\n", myaddr, provider);
- fprintf(fp, " set timeout 0\n");
- fprintf(fp, " enable dns\n");
- fprintf(fp, " set log local phase\n");
- if(authname[0] != '\0'){
- fprintf(fp, " set dial \"ABORT BUSY ABORT NO\\\\sCARRIER TIMEOUT 5 \\\"\\\" AT OK-AT-OK ATE1Q0 OK \\\\dATD%c\\\\T TIMEOUT 40 CONNECT\"\n", pulse ? 'P' : 'T');
- fprintf(fp, " set login\n");
- fprintf(fp, " set authname %s\n", authname);
- fprintf(fp, " set authkey %s\n", authkey);
- fprintf(fp, " set phone %s\n", phone);
- }
- if (fchmod(fileno(fp), 0600) != 0)
- msgConfirm("Warning: Failed to fix permissions on /etc/ppp/ppp.conf !");
- fclose(fp);
-
- /* Make the ppp config persistent */
- variable_set2(VAR_PPP_ENABLE, "YES", 0);
- variable_set2(VAR_PPP_PROFILE, "install", 0);
-
- if (!Fake && !file_readable("/dev/tun0") && mknod("/dev/tun0", 0600 | S_IFCHR, makedev(52, 0))) {
- msgConfirm("Warning: No /dev/tun0 device. PPP will not work!");
- restorescr(w);
- return 0;
- }
-
- if (isDebug())
- msgDebug("About to start PPP on device %s @ %s baud. Provider = %s\n", devp->devname, speed, provider);
-
- if (!Fake && !(pid = fork())) {
- int i, fd;
- struct termios foo;
- extern int login_tty(int);
-
- for (i = getdtablesize(); i >= 0; i--)
- close(i);
-
- /* We're going over to VTY2 */
- fd = open("/dev/ttyv2", O_RDWR);
- ioctl(0, TIOCSCTTY, &fd);
- dup2(0, 1);
- dup2(0, 2);
- DebugFD = 2;
- if (login_tty(fd) == -1)
- msgDebug("ppp: Can't set the controlling terminal.\n");
- signal(SIGTTOU, SIG_IGN);
- if (tcgetattr(fd, &foo) != -1) {
- foo.c_cc[VERASE] = '\010';
- if (tcsetattr(fd, TCSANOW, &foo) == -1)
- msgDebug("ppp: Unable to set the erase character.\n");
- }
- else
- msgDebug("ppp: Unable to get the terminal attributes!\n");
- execlp("ppp", "ppp", "install", (char *)NULL);
- msgDebug("PPP process failed to exec!\n");
- exit(1);
- }
- else {
- dialog_clear_norefresh();
- msgConfirm("NOTICE: The PPP command is now started on VTY3 (type ALT-F3 to\n"
- "interact with it, ALT-F1 to switch back here). If you are using\n"
- "a PAP or CHAP login simply enter \"dial\", otherwise you'll need\n"
- "to use the \"term\" command which starts a terminal emulator\n"
- "which you can use to talk to your modem and dial the service\n"
- "provider. Once you're connected, come back to this screen and\n"
- "press return.\n\n"
- "DO NOT PRESS [ENTER] HERE UNTIL THE CONNECTION IS FULLY\n"
- "ESTABLISHED!");
- }
- restorescr(w);
- return pid;
-}
diff --git a/usr.sbin/sysinstall/nfs.c b/usr.sbin/sysinstall/nfs.c
deleted file mode 100644
index f9a557239a92..000000000000
--- a/usr.sbin/sysinstall/nfs.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last attempt in the `sysinstall' line, the next
- * generation being slated to essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 "sysinstall.h"
-#include <sys/errno.h>
-#include <sys/fcntl.h>
-#include <sys/syslimits.h>
-#include <sys/param.h>
-#include <sys/mount.h>
-
-Boolean NFSMounted;
-static char mountpoint[] = "/dist";
-
-Boolean
-mediaInitNFS(Device *dev)
-{
- Device *netDevice = (Device *)dev->private;
- WINDOW *w = savescr();
-
- if (NFSMounted)
- return TRUE;
-
- if (netDevice && !netDevice->init(netDevice))
- return FALSE;
-
- if (Mkdir(mountpoint))
- return FALSE;
-
- msgNotify("Mounting %s over NFS on %s", dev->name, mountpoint);
- if (vsystem("mount_nfs %s %s %s %s",
- variable_get(VAR_SLOW_ETHER) ? "-r 1024 -w 1024" : "",
- variable_get(VAR_NFS_SECURE) ? "-P" : "", dev->name, mountpoint)) {
- msgConfirm("Error mounting %s on %s: %s.", dev->name, mountpoint, strerror(errno));
- if (netDevice)
- netDevice->shutdown(netDevice);
- restorescr(w);
- return FALSE;
- }
- NFSMounted = TRUE;
- if (isDebug())
- msgDebug("Mounted NFS device %s onto %s\n", dev->name, mountpoint);
- restorescr(w);
- return TRUE;
-}
-
-FILE *
-mediaGetNFS(Device *dev, char *file, Boolean probe)
-{
- return mediaGenericGet(mountpoint, file);
-}
-
-void
-mediaShutdownNFS(Device *dev)
-{
- if (!NFSMounted)
- return;
-
- msgDebug("Unmounting NFS partition on %s", mountpoint);
- if (unmount(mountpoint, MNT_FORCE) != 0)
- msgConfirm("Could not unmount the NFS partition: %s", strerror(errno));
- NFSMounted = FALSE;
- return;
-}
diff --git a/usr.sbin/sysinstall/options.c b/usr.sbin/sysinstall/options.c
deleted file mode 100644
index 2d2b98b720de..000000000000
--- a/usr.sbin/sysinstall/options.c
+++ /dev/null
@@ -1,312 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last attempt in the `sysinstall' line, the next
- * generation being slated for what's essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 "sysinstall.h"
-#include <ctype.h>
-
-static char *
-varCheck(Option opt)
-{
- char *cp = NULL;
-
- if (opt.aux)
- cp = variable_get((char *)opt.aux);
- if (!cp)
- return "NO";
- return cp;
-}
-
-/* Show our little logo */
-static char *
-resetLogo(char *str)
-{
- return "[RESET!]";
-}
-
-static char *
-mediaCheck(Option opt)
-{
- if (mediaDevice) {
- switch(mediaDevice->type) {
- case DEVICE_TYPE_UFS:
- case DEVICE_TYPE_DISK:
- return "File system";
-
- case DEVICE_TYPE_FLOPPY:
- return "Floppy";
-
- case DEVICE_TYPE_FTP:
- return "FTP";
-
- case DEVICE_TYPE_CDROM:
- return "CDROM";
-
- case DEVICE_TYPE_TAPE:
- return "Tape";
-
- case DEVICE_TYPE_DOS:
- return "DOS";
-
- case DEVICE_TYPE_NFS:
- return "NFS";
-
- case DEVICE_TYPE_NONE:
- case DEVICE_TYPE_NETWORK:
- case DEVICE_TYPE_ANY:
- default:
- return "<unknown>";
- }
- }
- return "<not yet set>";
-}
-
-#define TAPE_PROMPT "Please enter the tape block size in 512 byte blocks:"
-#define NEWFS_PROMPT "Please enter newfs(8) parameters:"
-#define RELNAME_PROMPT "Please specify the release you wish to load or\n\"none\" for a generic release install:"
-#define BPKG_PROMPT "Please specify the name of the HTML browser package:"
-#define BBIN_PROMPT "Please specify a full pathname to the HTML browser binary:"
-#define EDITOR_PROMPT "Please specify the name of the text editor you wish to use:"
-#define PKG_PROMPT "Please specify a temporary directory with lots of free space:"
-#define INSTROOT_PROMPT "Please specify a root directory if installing somewhere other than /"
-#define TIMEOUT_PROMPT "Please specify the number of seconds to wait for slow media:"
-
-static Option Options[] = {
-{ "NFS Secure", "NFS server talks only on a secure port",
- OPT_IS_VAR, NULL, VAR_NFS_SECURE, varCheck },
-{ "NFS Slow", "User is using a slow PC or ethernet card",
- OPT_IS_VAR, NULL, VAR_SLOW_ETHER, varCheck },
-{ "Debugging", "Emit extra debugging output on VTY2 (ALT-F2)",
- OPT_IS_VAR, NULL, VAR_DEBUG, varCheck },
-{ "No Warnings", "Don't Warn the user when a setting seems incorrect",
- OPT_IS_VAR, NULL, VAR_NO_WARN, varCheck },
-{ "Yes to All", "Assume \"Yes\" answers to all non-critical dialogs",
- OPT_IS_VAR, NULL, VAR_NO_CONFIRM, varCheck },
-{ "DHCP", "Attempt automatic DHCP configuration of interfaces",
- OPT_IS_VAR, NULL, VAR_TRY_DHCP, varCheck },
-{ "FTP username", "Username and password to use instead of anonymous",
- OPT_IS_FUNC, mediaSetFTPUserPass, VAR_FTP_USER, varCheck },
-{ "Editor", "Which text editor to use during installation",
- OPT_IS_VAR, EDITOR_PROMPT, VAR_EDITOR, varCheck },
-{ "Tape Blocksize", "Tape media block size in 512 byte blocks",
- OPT_IS_VAR, TAPE_PROMPT, VAR_TAPE_BLOCKSIZE, varCheck },
-{ "Extract Detail", "How verbosely to display file name information during extractions",
- OPT_IS_FUNC, mediaSetCPIOVerbosity, VAR_CPIO_VERBOSITY, varCheck },
-{ "Release Name", "Which release to attempt to load from installation media",
- OPT_IS_VAR, RELNAME_PROMPT, VAR_RELNAME, varCheck },
-{ "Install Root", "Which directory to unpack distributions or packages relative to",
- OPT_IS_VAR, INSTROOT_PROMPT, VAR_INSTALL_ROOT, varCheck },
-{ "Browser package", "This is the browser package that will be used for viewing HTML docs",
- OPT_IS_VAR, BPKG_PROMPT, VAR_BROWSER_PACKAGE, varCheck },
-{ "Browser Exec", "This is the path to the main binary of the browser package",
- OPT_IS_VAR, BBIN_PROMPT, VAR_BROWSER_BINARY, varCheck },
-{ "Media Type", "The current installation media type.",
- OPT_IS_FUNC, mediaGetType, VAR_MEDIA_TYPE, mediaCheck },
-{ "Media Timeout", "Timeout value in seconds for slow media.",
- OPT_IS_VAR, TIMEOUT_PROMPT, VAR_MEDIA_TIMEOUT, varCheck },
-{ "Package Temp", "The directory where package temporary files should go",
- OPT_IS_VAR, PKG_PROMPT, VAR_PKG_TMPDIR, varCheck },
-{ "Newfs Args", "Default parameters for newfs(8)",
- OPT_IS_VAR, NEWFS_PROMPT, VAR_NEWFS_ARGS, varCheck },
-{ "Config save", "Whether or not to save installation kernel config changes",
- OPT_IS_VAR, NULL, VAR_KGET, varCheck },
-{ "Re-scan Devices", "Re-run sysinstall's initial device probe",
- OPT_IS_FUNC, deviceRescan },
-{ "Use Defaults", "Reset all values to startup defaults",
- OPT_IS_FUNC, installVarDefaults, 0, resetLogo },
-{ NULL },
-};
-
-#define OPT_START_ROW 4
-#define OPT_END_ROW 19
-#define OPT_NAME_COL 0
-#define OPT_VALUE_COL 16
-#define GROUP_OFFSET 40
-
-static char *
-value_of(Option opt)
-{
- static char ival[40];
-
- switch (opt.type) {
- case OPT_IS_STRING:
- return (char *)opt.data;
-
- case OPT_IS_INT:
- sprintf(ival, "%d", (int)opt.data);
- return ival;
-
- case OPT_IS_FUNC:
- case OPT_IS_VAR:
- if (opt.check)
- return opt.check(opt);
- else
- return "<*>";
- }
- return "<unknown>";
-}
-
-static int
-fire(Option opt)
-{
- int status = 0;
-
- if (opt.type == OPT_IS_FUNC) {
- int (*cp)(char *) = opt.data, rcode;
-
- rcode = cp(NULL);
- status = 1;
- }
- else if (opt.type == OPT_IS_VAR) {
- if (opt.data) {
- (void)variable_get_value(opt.aux, opt.data, -1);
- status = 1;
- }
- else if (variable_get(opt.aux)) {
- if (!variable_cmp(opt.aux, "YES"))
- variable_set2(opt.aux, "NO", -1);
- else
- variable_set2(opt.aux, "YES", -1);
- }
- else
- variable_set2(opt.aux, "YES", 0);
- }
- if (opt.check)
- opt.check(opt);
- refresh();
- return status;
-}
-
-int
-optionsEditor(dialogMenuItem *self)
-{
- int i, optcol, optrow, key;
- static int currOpt = 0;
- WINDOW *w = savescr();
-
- dialog_clear();
- clear();
-
- while (1) {
- /* Whap up the header */
- attrset(A_REVERSE); mvaddstr(0, 0, "Options Editor"); attrset(A_NORMAL);
- for (i = 0; i < 2; i++) {
- mvaddstr(OPT_START_ROW - 2, OPT_NAME_COL + (i * GROUP_OFFSET), "Name");
- mvaddstr(OPT_START_ROW - 1, OPT_NAME_COL + (i * GROUP_OFFSET), "----");
-
- mvaddstr(OPT_START_ROW - 2, OPT_VALUE_COL + (i * GROUP_OFFSET), "Value");
- mvaddstr(OPT_START_ROW - 1, OPT_VALUE_COL + (i * GROUP_OFFSET), "-----");
- }
- /* And the footer */
- mvprintw(OPT_END_ROW + 1, 0, "Use SPACE to select/toggle an option, arrow keys to move,");
- mvprintw(OPT_END_ROW + 2, 0, "? or F1 for more help. When you're done, type Q to Quit.");
-
- optrow = OPT_START_ROW;
- optcol = OPT_NAME_COL;
- for (i = 0; Options[i].name; i++) {
- /* Names are painted somewhat gratuitously each time, but it's easier this way */
- mvprintw(optrow, OPT_NAME_COL + optcol, Options[i].name);
- if (currOpt == i)
- attrset(ATTR_SELECTED);
- mvprintw(optrow++, OPT_VALUE_COL + optcol, value_of(Options[i]));
- if (currOpt == i)
- attrset(A_NORMAL);
- if (optrow == OPT_END_ROW) {
- optrow = OPT_START_ROW;
- optcol += GROUP_OFFSET;
- }
- clrtoeol();
- }
- attrset(ATTR_TITLE);
- mvaddstr(OPT_END_ROW + 4, 0, Options[currOpt].desc);
- attrset(A_NORMAL);
- clrtoeol();
- move(0, 14);
- refresh();
-
- /* Start the edit loop */
- key = toupper(getch());
- switch (key) {
- case KEY_F(1):
- case '?':
- systemDisplayHelp("options");
- clear();
- break;
-
- case '\020': /* ^P */
- case KEY_UP:
- if (currOpt)
- --currOpt;
- else
- for (currOpt = 0; Options[currOpt + 1].name; currOpt++);
- continue;
-
- case '\016': /* ^N */
- case KEY_DOWN:
- if (Options[currOpt + 1].name)
- ++currOpt;
- else
- currOpt = 0;
- continue;
-
- case KEY_HOME:
- currOpt = 0;
- continue;
-
- case KEY_END:
- while (Options[currOpt + 1].name)
- ++currOpt;
- continue;
-
- case ' ':
- if (fire(Options[currOpt]))
- clear();
- continue;
-
- case '\033': /* ESC */
- case 'Q':
- clear();
- dialog_clear();
- restorescr(w);
- return DITEM_SUCCESS;
-
- default:
- beep();
- }
- }
- /* NOTREACHED */
- return DITEM_SUCCESS;
-}
-
diff --git a/usr.sbin/sysinstall/package.c b/usr.sbin/sysinstall/package.c
deleted file mode 100644
index 8901d08b998a..000000000000
--- a/usr.sbin/sysinstall/package.c
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last program in the `sysinstall' line - the next
- * generation being essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 "sysinstall.h"
-#include <sys/errno.h>
-#include <sys/time.h>
-#include <sys/param.h>
-#include <sys/mount.h>
-#include <sys/stat.h>
-
-static Boolean sigpipe_caught;
-
-static void
-catch_pipe(int sig)
-{
- sigpipe_caught = TRUE;
-}
-
-extern PkgNode Top;
-
-/* Like package_extract, but assumes current media device and chases deps */
-int
-package_add(char *name)
-{
- PkgNodePtr tmp, tmp2, *tmp3;
- int i;
-
- if (!mediaVerify())
- return DITEM_FAILURE;
-
- if (!mediaDevice->init(mediaDevice))
- return DITEM_FAILURE;
-
- i = index_initialize("packages/INDEX");
- if (DITEM_STATUS(i) != DITEM_SUCCESS)
- return i;
-
- tmp3 = strpbrk(name, "-") ? NULL : &tmp2;
- tmp = index_search(&Top, name, tmp3);
- if (tmp)
- return index_extract(mediaDevice, &Top, tmp, FALSE);
- else {
- msgConfirm("Sorry, package %s was not found in the INDEX.", name);
- return DITEM_FAILURE;
- }
-}
-
-/* For use by dispatch */
-int
-packageAdd(dialogMenuItem *self)
-{
- char *cp;
-
- cp = variable_get(VAR_PACKAGE);
- if (!cp) {
- msgDebug("packageAdd: No package name passed in package variable\n");
- return DITEM_FAILURE;
- }
- else
- return package_add(cp);
-}
-
-Boolean
-package_exists(char *name)
-{
- char fname[FILENAME_MAX];
- int status /* = vsystem("pkg_info -e %s", name) */;
-
- /* XXX KLUDGE ALERT! This makes evil assumptions about how XXX
- * packages register themselves and should *really be done with
- * `pkg_info -e <name>' except that this it's too slow for an
- * item check routine.. :-(
- */
- snprintf(fname, FILENAME_MAX, "/var/db/pkg/%s", name);
- status = access(fname, R_OK);
- if (isDebug())
- msgDebug("package check for %s returns %s.\n", name, status ? "failure" : "success");
- return !status;
-}
-
-/* Extract a package based on a namespec and a media device */
-int
-package_extract(Device *dev, char *name, Boolean depended)
-{
- char path[511];
- int ret, last_msg = 0;
- FILE *fp;
-
- /* Check to make sure it's not already there */
- if (package_exists(name))
- return DITEM_SUCCESS;
-
- if (!dev->init(dev)) {
- msgConfirm("Unable to initialize media type for package extract.");
- return DITEM_FAILURE;
- }
-
- /* If necessary, initialize the ldconfig hints */
- if (!file_readable("/var/run/ld.so.hints"))
- vsystem("ldconfig /usr/lib /usr/lib/compat /usr/local/lib /usr/X11R6/lib");
-
- /* Be initially optimistic */
- ret = DITEM_SUCCESS;
- /* Make a couple of paranoid locations for temp files to live if user specified none */
- if (!variable_get(VAR_PKG_TMPDIR)) {
- /* Set it to a location with as much space as possible */
- variable_set2(VAR_PKG_TMPDIR, "/usr/tmp", 0);
- }
- Mkdir(variable_get(VAR_PKG_TMPDIR));
- vsystem("chmod 1777 %s", variable_get(VAR_PKG_TMPDIR));
-
- if (!index(name, '/')) {
- if (!strpbrk(name, "-_"))
- sprintf(path, "packages/Latest/%s.tgz", name);
- else
- sprintf(path, "packages/All/%s%s", name, strstr(name, ".tgz") ? "" : ".tgz");
- }
- else
- sprintf(path, "%s%s", name, strstr(name, ".tgz") ? "" : ".tgz");
-
- /* We have a path, call the device strategy routine to get the file */
- fp = dev->get(dev, path, TRUE);
- if (fp) {
- int i = 0, tot, pfd[2];
- pid_t pid;
- WINDOW *w = savescr();
-
- sigpipe_caught = FALSE;
- signal(SIGPIPE, catch_pipe);
-
- dialog_clear_norefresh();
- msgNotify("Adding %s%s\nfrom %s", path, depended ? " (as a dependency)" : "", dev->name);
- pipe(pfd);
- pid = fork();
- if (!pid) {
- dup2(pfd[0], 0); close(pfd[0]);
- dup2(DebugFD, 1);
- close(2);
- close(pfd[1]);
- if (isDebug())
- i = execl("/usr/sbin/pkg_add", "/usr/sbin/pkg_add", "-v", "-", 0);
- else
- i = execl("/usr/sbin/pkg_add", "/usr/sbin/pkg_add", "-", 0);
- }
- else {
- char buf[BUFSIZ];
- struct timeval start, stop;
-
- close(pfd[0]);
- tot = 0;
- (void)gettimeofday(&start, (struct timezone *)0);
-
- while (!sigpipe_caught && (i = fread(buf, 1, BUFSIZ, fp)) > 0) {
- int seconds;
-
- tot += i;
- /* Print statistics about how we're doing */
- (void) gettimeofday(&stop, (struct timezone *)0);
- stop.tv_sec = stop.tv_sec - start.tv_sec;
- stop.tv_usec = stop.tv_usec - start.tv_usec;
- if (stop.tv_usec < 0)
- stop.tv_sec--, stop.tv_usec += 1000000;
- seconds = stop.tv_sec + (stop.tv_usec / 1000000.0);
- if (!seconds)
- seconds = 1;
- if (seconds != last_msg) {
- last_msg = seconds;
- msgInfo("%10d bytes read from package %s @ %4.1f KBytes/second", tot, name, (tot / seconds) / 1024.0);
- }
- /* Write it out */
- if (sigpipe_caught || write(pfd[1], buf, i) != i) {
- msgInfo("Write failure to pkg_add! Package may be corrupt.");
- break;
- }
- }
- close(pfd[1]);
- fclose(fp);
- if (sigpipe_caught)
- msgInfo("pkg_add(1) apparently did not like the %s package.", name);
- else if (i == -1)
- msgInfo("I/O error while reading in the %s package.", name);
- else
- msgInfo("Package %s read successfully - waiting for pkg_add(1)", name);
- refresh();
- i = waitpid(pid, &tot, 0);
- dialog_clear_norefresh();
- if (sigpipe_caught || i < 0 || WEXITSTATUS(tot)) {
- ret = DITEM_FAILURE;
- if (variable_get(VAR_NO_CONFIRM))
- msgNotify("Add of package %s aborted, error code %d -\n"
- "Please check the debug screen for more info.", name, WEXITSTATUS(tot));
- else
- msgConfirm("Add of package %s aborted, error code %d -\n"
- "Please check the debug screen for more info.", name, WEXITSTATUS(tot));
- }
- else
- msgNotify("Package %s was added successfully", name);
-
- /* Now catch any stragglers */
- while (wait3(&tot, WNOHANG, NULL) > 0);
-
- sleep(1);
- restorescr(w);
- }
- }
- else {
- dialog_clear_norefresh();
- if (variable_get(VAR_NO_CONFIRM))
- msgNotify("Unable to fetch package %s from selected media.\n"
- "No package add will be done.", name);
- else
- msgConfirm("Unable to fetch package %s from selected media.\n"
- "No package add will be done.", name);
- ret = DITEM_FAILURE;
- }
- signal(SIGPIPE, SIG_IGN);
- return ret;
-}
diff --git a/usr.sbin/sysinstall/pccard.c b/usr.sbin/sysinstall/pccard.c
deleted file mode 100644
index 375c58e309f5..000000000000
--- a/usr.sbin/sysinstall/pccard.c
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * PC-card support for sysinstall
- *
- * $FreeBSD$
- *
- * Copyright (c) 1997-1999
- * Tatsumi Hosokawa <hosokawa@jp.FreeBSD.org>. All rights reserved.
- *
- * This software may be used, modified, copied, and distributed, in
- * both source and binary form provided that the above copyright and
- * these terms are retained. Under no circumstances is the author
- * responsible for the proper functioning of this software, nor does
- * the author assume any responsibility for damages incurred with its
- * use.
- */
-
-#include "sysinstall.h"
-#include <sys/fcntl.h>
-#include <sys/time.h>
-#include <pccard/cardinfo.h>
-
-int pccard_mode = 0;
-
-DMenu MenuPCICMem = {
- DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS,
- "Please select free address area used by PC-card controller",
- "PC-card controller uses memory area to get card information.\n"
- "Please specify an address that is not used by other devices.\n"
- "If you're uncertain of detailed specification of your hardware,\n"
- "leave it untouched (default == 0xd0000).",
- "Press F1 for more HELP",
- "pccard",
- { { "Default", "I/O address 0xd0000 - 0xd3fff",
- NULL, dmenuSetVariable, NULL, "_pcicmem=0"},
- { "D4", "I/O address 0xd4000 - 0xd7fff",
- NULL, dmenuSetVariable, NULL, "_pcicmem=1"},
- { "D8", "I/O address 0xd8000 - 0xdbfff",
- NULL, dmenuSetVariable, NULL, "_pcicmem=2"},
- { "DC", "I/O address 0xdc000 - 0xdffff",
- NULL, dmenuSetVariable, NULL, "_pcicmem=3"},
- { NULL } },
-};
-
-DMenu MenuCardIRQ = {
- DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS,
- "Please select IRQs that can be used by PC-cards",
- "Please specify an IRQs that CANNOT be used by PC-card.\n"
- "For example, if you have a sound card that can't be probed by\n"
- "this installation floppy and it uses IRQ 10, you have to \n"
- "choose \"Option 1\" or \"Option 2\" at this menu.\n",
- "Press F1 for more HELP",
- "pccard",
- { { "Default", "IRQ 10, 11",
- NULL, dmenuSetVariable, NULL, "_cardirq=0"},
- { "Option 1", "IRQ 5, 11 (ex. soundcard on IRQ 10)",
- NULL, dmenuSetVariable, NULL, "_cardirq=1"},
- { "Option 2", "IRQ 11 (ex. something on IRQ 5 and 10)",
- NULL, dmenuSetVariable, NULL, "_cardirq=2"},
- { NULL } },
-};
-
-void
-pccardInitialize(void)
-{
- int fd;
- int t;
- int pcic_mem = 0xd0000;
- char card_device[16];
- char *card_irq = "";
- char *spcic_mem;
- char *scard_irq;
- char pccardd_cmd[256];
- WINDOW *w;
-
- pccard_mode = 1;
-
- if (!RunningAsInit && !Fake) {
- /* It's not my job... */
- return;
- }
-
- sprintf(card_device, CARD_DEVICE, 0);
-
- if ((fd = open(card_device, O_RDWR)) < 0) {
- msgDebug("Can't open PC-card controller %s.\n",
- card_device);
- return;
- }
- else if (msgYesNo("Found PC-card slot(s).\n"
- "Use PC-card device as installation media?\n")) {
- return;
- }
- close(fd);
-
- variable_set2("_pccard_install", "YES", 0);
-
- dmenuOpenSimple(&MenuPCICMem, FALSE);
- spcic_mem = variable_get("_pcicmem");
- dmenuOpenSimple(&MenuCardIRQ, FALSE);
- scard_irq = variable_get("_cardirq");
-
- sscanf(spcic_mem, "%d", &t);
- switch (t) {
- case 0:
- pcic_mem = 0xd0000;
- variable_set2("pccard_mem", "DEFAULT", 1);
- break;
- case 1:
- pcic_mem = 0xd4000;
- variable_set2("pccard_mem", "0xd4000", 1);
- break;
- case 2:
- pcic_mem = 0xd8000;
- variable_set2("pccard_mem", "0xd8000", 1);
- break;
- case 3:
- pcic_mem = 0xdc000;
- variable_set2("pccard_mem", "0xdc000", 1);
- break;
- }
-
- sscanf(scard_irq, "%d", &t);
-
- switch (t) {
- case 0:
- card_irq = "-i 10 -i 11";
- break;
- case 1:
- card_irq = "-i 5 -i 11";
- break;
- case 2:
- card_irq = "-i 11";
- break;
- }
-
- w = savescr();
- dialog_clear_norefresh();
- msgConfirm("Now we start initializing PC-card controller and cards.\n"
- "If you've executed this installer from a PC-card floppy\n"
- "drive, this is the last chance to replace it with\n"
- "installation media (PC-card Ethernet, CDROM, etc.).\n"
- "Please insert installation media and press [Enter].\n"
- "If you've not plugged the PC-card installation media\n"
- "in yet, please plug it in now and press [Enter].\n"
- "Otherwise, just press [Enter] to proceed.");
-
- dialog_clear();
- msgNotify("Initializing PC-card controller....");
-
- if (!Fake) {
- if ((fd = open(card_device, O_RDWR)) < 1) {
- msgNotify("Can't open PC-card controller %s.\n",
- card_device);
- restorescr(w);
- return;
- }
-
- if (ioctl(fd, PIOCRWMEM, &pcic_mem) < 0){
- msgNotify("ioctl %s failed.\n", card_device);
- restorescr(w);
- return;
- }
- }
-
- strcpy(pccardd_cmd, "/stand/pccardd ");
- strcat(pccardd_cmd, card_irq);
- strcat(pccardd_cmd, " -z");
-
- variable_set2("pccardd_flags", card_irq, 1);
- variable_set2("pccard_enable", "YES", 1);
-
- vsystem(pccardd_cmd);
- restorescr(w);
-}
diff --git a/usr.sbin/sysinstall/rtermcap.c b/usr.sbin/sysinstall/rtermcap.c
deleted file mode 100644
index 84b3feb49ead..000000000000
--- a/usr.sbin/sysinstall/rtermcap.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <stdio.h>
-#include <termcap.h>
-
-int
-main(int argc, char **argv)
-{
- char buf[4096];
- int i;
-
- if (argc < 2)
- return 1;
- i = tgetent(buf, argv[1]);
- printf("%s",buf);
- return 0;
-}
diff --git a/usr.sbin/sysinstall/sysinstall.8 b/usr.sbin/sysinstall/sysinstall.8
deleted file mode 100644
index 7c46a83ea377..000000000000
--- a/usr.sbin/sysinstall/sysinstall.8
+++ /dev/null
@@ -1,861 +0,0 @@
-.\" Copyright (c) 1997
-.\" Jordan Hubbard <jkh@FreeBSD.org>. 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 Jordan Hubbard 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 Jordan Hubbard 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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd August 9, 1997
-.Dt SYSINSTALL 8
-.Os FreeBSD
-.Sh NAME
-.Nm sysinstall
-.Nd system installation and configuration tool
-.Sh SYNOPSIS
-.Nm
-.Op Ar var=value
-.Op Ar function
-.Op Ar ...
-.Sh DESCRIPTION
-.Nm
-is a utility for installing and configuring
-.Fx
-systems.
-It is the first utility invoked by the
-.Fx
-installation boot
-floppy and is also copied into
-.Pa /stand/sysinstall
-on newly installed
-.Fx
-systems for use in later configuring the system.
-.Pp
-The
-.Nm
-program is generally invoked without arguments for the default
-behavior, where the main installation/configuration menu is presented.
-
-On those occasions where it is deemed necessary to invoke a subsystem
-of sysinstall directly, however, it is also possible to do so by
-naming the appropriate function entry points on the command line.
-Since this action is essentially identical to running an installation
-script, each command-line argument corresponding to a line of script,
-the reader is encouraged to read the section on scripting for more
-information on this feature.
-.Pp
-.Sh NOTES
-.Nm
-is essentially nothing more than a monolithic C program with
-the ability to write MBRs and disk labels (through the services
-of the
-.Xr libdisk 3
-library) and install distributions or packages onto new and
-existing
-.Fx
-systems. It also contains some extra intelligence
-for running as a replacement for
-.Xr init 8
-when it's invoked by the
-.Fx
-installation boot procedure. It
-assumes very little in the way of additional utility support and
-performs most file system operations by calling the relevant syscalls
-(such as
-.Xr mount 2 )
-directly.
-.Pp
-.Nm
-currently uses the
-.Xr dialog 3
-library to do user interaction with simple ANSI line graphics, color
-support for which is enabled by either running on a syscons VTY or some
-other color-capable terminal emulator (newer versions of xterm will support
-color when using the
-.Dq xterm-color
-termcap entry).
-.Pp
-This product is currently at the end of its life cycle and will
-eventually be replaced.
-.Sh RUNNING SCRIPTS
-.Nm
-may be either driven interactively through its various internal menus
-or run in batch mode, driven by an external script. Such a script may
-be loaded and executed in one of 3 ways:
-
-.Bl -tag -width Ds -compact
-.It Sy "LOAD_CONFIG_FILE"
-If
-.Nm
-is compiled with LOAD_CONFIG_FILE set in the environment
-(or in the Makefile) to some value, then that value will
-be used as the filename to automatically look for and load
-when
-.Nm
-starts up and with no user interaction required.
-This option is aimed primarily at large sites who wish to create a
-single prototype install for multiple machines with largely identical
-configurations and/or installation options.
-
-.It Sy "MAIN MENU"
-If
-.Nm
-is run interactively, that is to say in the default manner, it will
-bring up a main menu which contains a "load config file" option.
-Selecting this option will prompt for the name of a script file which
-it then will attempt to load from a DOS or UFS formatted floppy.
-
-.It Sy "COMMAND LINE"
-Each command line argument is treated as a script directive
-when
-.Nm
-is run in multi-user mode. Execution ends either by explicit request
-(e.g. calling the
-.Ar shutdown
-directive), upon reaching the end of the argument list or on error.
-.Pp
-For example:
-.nf
-
-/stand/sysinstall _ftpPath=ftp://ziggy/pub/ mediaSetFTP configPackages
-
-.fi
-Would initialize
-.Nm
-for FTP installation media (using the server `ziggy') and then
-bring up the package installation editor, exiting when finished.
-.El
-.Pp
-.Sh SCRIPT SYNTAX
-A script is a list of one or more directives, each directive taking
-the form of:
-
-.Ar var=value
-.Pp
-.Ar function
-.Pp
-or
-.Ar #somecomment
-
-Where
-.Ar var=value
-is the assignment of some internal
-.Nm
-variable, e.g. "ftpPass=FuNkYChiKn", and
-.Ar function
-is the name of an internal
-.Nm
-function, e.g. "mediaSetFTP", and
-.Ar #comment
-is a single-line comment for documentation purposes (ignored by
-sysinstall). Each directive must be by itself on a single line,
-functions taking their arguments by examining known variable names.
-This requires that you be sure to assign the relevant variables before
-calling a function which requires them. When and where a function
-depends on the settings of one or more variables will be noted in the
-following table:
-
-.Pp
-\fBFunction Glossary:\fR
-.Pp
-.Bl -tag -width indent
-.It configAnonFTP
-Invoke the Anonymous FTP configuration menu.
-.Pp
-\fBVariables:\fR None
-.It configRouter
-Select which routing daemon you wish to use, potentially
-loading any required 3rd-party routing daemons as necessary.
-.Pp
-\fBVariables:\fR
-.Bl -tag -width indent
-.It router
-can be set to the name of the desired routing daemon,
-e.g.
-.Dq routed
-or
-.Dq gated ,
-otherwise it is prompted for.
-.El
-.It configNFSServer
-Configure host as an NFS server.
-.Pp
-\fBVariables:\fR None
-.It configNTP
-Configure host as a user of the Network Time Protocol.
-.Pp
-\fBVariables:\fR
-.Bl -tag -width indent
-.It ntpdate_flags
-The flags to
-.Xr ntpdate 8 ,
-that is to say the name of the server to sync from.
-.El
-.It configPCNFSD
-Configure host to support PC NFS.
-.Pp
-\fBVariables:\fR
-.Bl -tag -width indent
-.It pcnfsd_pkg
-The name of the PCNFSD package to load if necessary (defaults to hard coded
-version).
-.El
-.It configPackages
-Bring up the interactive package management menu.
-.Pp
-\fBVariables:\fR None
-.It configUsers
-Add users and/or groups to the system.
-.Pp
-\fBVariables:\fR None
-.It configXEnvironment
-Configure the X display subsystem.
-.Pp
-\fBVariables:\fR None
-.It diskPartitionEditor
-Invokes the disk partition (MBR) editor.
-.Pp
-\fBVariables:\fR
-.Bl -tag -width findx
-.It geometry
-The disk geometry, as a cyls/heads/sectors formatted string. Default: no
-change to geometry.
-.It partition
-Set to disk partitioning type or size, its value being
-.Ar free
-in order to use only remaining free space for
-.Fx ,
-.Ar all
-to use the entire disk for
-.Fx
-but maintain a proper partition
-table,
-.Ar existing
-to use an existing
-.Fx
-partition (first found),
-.Ar exclusive
-to use the disk in
-.Dq dangerously dedicated
-mode or, finally,
-.Ar somenumber
-to allocate
-.Ar somenumber
-blocks of available free space to a new
-.Fx
-partition.
-Default: Interactive mode.
-.It bootManager
-is set to one of
-.Ar boot
-to signify the installation of a boot manager,
-.Ar standard
-to signify installation of a "standard" non-boot MGR DOS
-MBR or
-.Ar none
-to indicate that no change to the boot manager is desired.
-Default: none.
-.El
-.Pp
-Note: Nothing is actually written to disk by this function, a explicit call to
-.Ar diskPartitionWrite
-being required for that to happen.
-.It diskPartitionWrite
-Causes any pending MBR changes (typically from the
-.Ar diskPartitionEditor
-function) to be written out.
-.Pp
-\fBVariables:\fR None
-.It diskLabelEditor
-Invokes the disk label editor. This is a bit trickier from a script
-since you need to essentially label everything inside each
-.Fx
-(type 0xA5) partition created by the
-.Ar diskPartitionEditor
-function, and that requires knowing a few rules about how things are
-laid out. When creating a script to automatically allocate disk space
-and partition it up, it is suggested that you first perform the
-installation interactively at least once and take careful notes as to
-what the slice names will be, then and only then hardwiring them into
-the script.
-.Pp
-For example, let's say you have a SCSI disk on which you've created a new
-.Fx
-partition in slice 2 (your DOS partition residing in slice 1).
-The slice name would be
-.Ar da0s2
-for the whole
-.Fx
-partition
-.Ar ( da0s1
-being your DOS primary
-partition). Now let's further assume that you have 500MB in this
-partition and you want to sub-partition that space into root, swap,
-var and usr file systems for
-.Fx .
-Your invocation of the
-.Ar diskLabelEditor
-function might involve setting the following variables:
-.Bl -tag -width findx
-.It Li "da0s2-1=ufs 40960 /"
-A 20MB root file system (all sizes are in 512 byte blocks).
-.It Li "da0s2-2=swap 131072 /"
-A 64MB swap partition.
-.It Li "da0s2-3=ufs 204800 /var"
-A 100MB /var file system.
-.It Li "da0s2-4=ufs 0 /usr"
-With the balance of free space (around 316MB) going to the /usr
-file system.
-.El
-
-One can also use the
-.Ar diskLabelEditor
-for mounting or erasing existing partitions as well as creating new
-ones. Using the previous example again, let's say that we also wanted
-to mount our DOS partition and make sure that an
-.Pa /etc/fstab
-entry is created for it in the new installation. Before calling the
-.Ar diskLabelEditor
-function, we simply add an additional line:
-.nf
- da0s1=/dos_c N
-
-.fi
-before the call. This tells the label editor that you want to mount
-the first slice on
-.Pa /dos_c
-and not to attempt to newfs it (not that
-.Nm
-would attempt this for a DOS partition in any case, but it could just
-as easily be an existing UFS partition being named here and the 2nd
-field is non-optional).
-.Pp
-Note: No file system data is actually written to disk until an
-explicit call to
-.Ar diskLabelCommit
-is made.
-.It diskLabelCommit
-Writes out all pending disklabel information and creates and/or mounts any
-file systems which have requests pending from the
-.Ar diskLabelEditor
-function.
-.Pp
-\fBVariables:\fR None
-.It distReset
-Resets all selected distributions to the empty set (no distributions selected).
-.Pp
-\fBVariables:\fR None
-.It distSetCustom
-Allows the selection of a custom distribution set (e.g. not just on of the
-existing "canned" sets) with no user interaction.
-
-\fBVariables:\fR
-.Bl -tag -width indent
-.It dists
-List of distributions to load. Possible distribution values are:
-.Bl -tag -width indentxx
-.It Li bin
-The base binary distribution.
-.It Li doc
-Miscellaneous documentation
-.It Li games
-Games
-.It Li manpages
-Manual pages (unformatted)
-.It Li catpages
-Pre-formatted manual pages
-.It Li proflibs
-Profiled libraries for developers.
-.It Li dict
-Dictionary information (for tools like spell).
-.It Li info
-GNU info files and other extra docs.
-.It Li crypto
-Encryption binaries and libraries.
-.It Li compat1x
-Compatibility with
-.It Li 1.x
-.It Li compat20
-Compatibility with
-.Fx 2.0
-.It Li compat21
-Compatibility with
-.Fx 2.1
-.It Li compat22
-.Fx 2.2
-and
-.Fx 3.0
-a.out binary compatibility
-.It Li compat3x
-Compatibility with
-.It Li 3.x
-(available for
-.Fx 4.0
-systems only)
-.It Li ports
-The ports collection.
-.It Li krb4
-KerberosIV binaries.
-.It Li ssecure
-/usr/src/secure
-.It Li sbase
-/usr/src/[top level files]
-.It Li scontrib
-/usr/src/contrib
-.It Li sgnu
-/usr/src/gnu
-.It Li setc
-/usr/src/etc
-.It Li sgames
-/usr/src/games
-.It Li sinclude
-/usr/src/include
-.It Li slib
-/usr/src/lib
-.It Li slibexec
-/usr/src/libexec
-.It Li srelease
-/usr/src/release
-.It Li sbin
-/usr/src/bin
-.It Li ssbin
-/usr/src/sbin
-.It Li sshare
-/usr/src/share
-.It Li ssys
-/usr/src/sys
-.It Li subin
-/usr/src/usr.bin
-.It Li susbin
-/usr/src/usr.sbin
-.It Li ssmailcf
-/usr/src/usr.sbin/sendmail/cf
-.It Li XF86-xc
-XFree86 official sources.
-.It Li XF86-co
-XFree86 contributed sources.
-.It Li Xbin
-XFree86 3.3.6 binaries.
-.It Li Xcfg
-XFree86 3.3.6 configuration files.
-.It Li Xdoc
-XFree86 3.3.6 documentation.
-.It Li Xhtml
-XFree86 3.3.6 HTML documentation.
-.It Li Xlib
-XFree86 3.3.6 libraries.
-.It Li Xlk98
-XFree86 3.3.6 server link-kit for PC98 machines.
-.It Li Xlkit
-XFree86 3.3.6 server link-kit for standard machines.
-.It Li Xman
-XFree86 3.3.6 manual pages.
-.It Li Xprog
-XFree86 3.3.6 programmer's distribution.
-.It Li Xps
-XFree86 3.3.6 postscript documentation.
-.It Li Xset
-XFree86 3.3.6 graphical setup tool.
-.It Li X8514
-XFree86 3.3.6 8514 server.
-.It Li X9480
-XFree86 3.3.6 PC98 8-bit (256 color) PEGC-480 server.
-.It Li X9EGC
-XFree86 3.3.6 PC98 4-bit (16 color) EGC server.
-.It Li X9GA9
-XFree86 3.3.6 PC98 GA-968V4/PCI (S3 968) server.
-.It Li X9GAN
-XFree86 3.3.6 PC98 GANB-WAP (cirrus) server.
-.It Li X9LPW
-XFree86 3.3.6 PC98 PowerWindowLB (S3) server.
-.It Li X9NKV
-XFree86 3.3.6 PC98 NKV-NEC (cirrus) server.
-.It Li X9NS3
-XFree86 3.3.6 PC98 NEC (S3) server.
-.It Li X9SPW
-XFree86 3.3.6 PC98 SKB-PowerWindow (S3) server.
-.It Li X9TGU
-XFree86 3.3.6 PC98 Cyber9320 and TGUI9680 server.
-.It Li X9WEP
-XFree86 3.3.6 PC98 WAB-EP (cirrus) server.
-.It Li X9WS
-XFree86 3.3.6 PC98 WABS (cirrus) server.
-.It Li X9WSN
-XFree86 3.3.6 PC98 WSN-A2F (cirrus) server.
-.It Li XAGX
-XFree86 3.3.6 8 bit AGX server.
-.It Li XI128
-XFree86 3.3.6 #9 Imagine I128 server.
-.It Li XMa8
-XFree86 3.3.6 ATI Mach8 server.
-.It Li XMa32
-XFree86 3.3.6 ATI Mach32 server.
-.It Li XMa64
-XFree86 3.3.6 ATI Mach64 server.
-.It Li XMono
-XFree86 3.3.6 monochrome server.
-.It Li XP9K
-XFree86 3.3.6 P9000 server.
-.It Li XS3
-XFree86 3.3.6 S3 server.
-.It Li XS3V
-XFree86 3.3.6 S3 Virge server.
-.It Li XSVGA
-XFree86 3.3.6 SVGA server.
-.It Li XVG16
-XFree86 3.3.6 VGA16 server.
-.It Li XW32
-XFree86 3.3.6 ET4000/W32, /W32i and /W32p server.
-.It Li XTGA
-Server for TGA cards (alpha architecture only).
-.It Li Xnest
-XFree86 3.3.6 nested X server.
-.It Li Xvfb
-XFree86 3.3.6 virtual frame-buffer X server.
-.It Li Xfnts
-XFree86 3.3.6 base font set.
-.It Li Xf100
-XFree86 3.3.6 100DPI font set.
-.It Li Xfcyr
-XFree86 3.3.6 Cyrillic font set.
-.It Li Xfscl
-XFree86 3.3.6 scalable font set.
-.It Li Xfnon
-XFree86 3.3.6 non-english font set.
-.It Li Xfsrv
-XFree86 3.3.6 font server.
-.El
-.It distSetDeveloper
-Selects the standard Developer's distribution set.
-.Pp
-\fBVariables:\fR None
-.It distSetXDeveloper
-Selects the standard X Developer's distribution set.
-.Pp
-\fBVariables:\fR None
-.It distSetKernDeveloper
-Selects the standard kernel Developer's distribution set.
-.Pp
-\fBVariables:\fR None
-.It distSetUser
-Selects the standard user distribution set.
-.Pp
-\fBVariables:\fR None
-.It distSetXUser
-Selects the standard X user's distribution set.
-.Pp
-\fBVariables:\fR None
-.It distSetMinimum
-Selects the very minimum distribution set.
-.Pp
-\fBVariables:\fR None
-.It distSetEverything
-Selects the full whack - all available distributions.
-.Pp
-\fBVariables:\fR None
-.It distSetCRYPTO
-Interactively select encryption subcomponents.
-.Pp
-\fBVariables:\fR None
-.It distSetSrc
-Interactively select source subcomponents.
-.Pp
-\fBVariables:\fR None
-.It distSetXF86
-Interactively select XFree86 3.3.6 subcomponents.
-.Pp
-\fBVariables:\fR None
-.It distExtractAll
-Install all currently selected distributions (requires that
-media device also be selected).
-.Pp
-\fBVariables:\fR None
-.It docBrowser
-Install (if necessary) an HTML documentation browser and go to the
-HTML documentation submenu.
-.Pp
-\fBVariables:\fR
-.Bl -tag -width indent
-.It browserPackage
-The name of the browser package to try and install as necessary.
-Defaults to latest lynx package.
-.It browserBinary
-The name of the browser binary itself (if overriding the
-.Ar browserPackage
-variable). Defaults to lynx.
-.El
-.It installCommit
-.Pp
-Commit any and all pending changes to disk. This function
-is essentially shorthand for a number of more granular "commit"
-functions.
-.Pp
-\fBVariables:\fR None
-.It installExpress
-Start an "express" installation, asking few questions of
-the user.
-.Pp
-\fBVariables:\fR None
-.It installStandard
-Start a "standard" installation, the most user-friendly
-installation type available.
-.Pp
-\fBVariables:\fR None
-.It installUpgrade
-Start an upgrade installation.
-.Pp
-\fBVariables:\fR None
-.It installFixitHoloShell
-Start up the "emergency holographic shell" over on VTY4
-if running as init.
-.Pp
-\fBVariables:\fR None
-.It installFixitCDROM
-Go into "fixit" mode, assuming a live file system CDROM
-currently in the drive.
-.Pp
-\fBVariables:\fR None
-.It installFixitFloppy
-Go into "fixit" mode, assuming an available fixit floppy
-disk (user will be prompted for it).
-.Pp
-\fBVariables:\fR None
-.It installFilesystems
-Do just the file system initialization part of an install.
-.Pp
-\fBVariables:\fR None
-.It installVarDefaults
-Initialize all variables to their defaults, overriding any
-previous settings.
-.Pp
-\fBVariables:\fR None
-.It loadConfig
-Sort of like an #include statement, it allows you to load one
-configuration file from another.
-.Pp
-\fBVariables:\fR
-.Bl -tag -width indent
-.It file
-The fully pathname of the file to load.
-.El
-.It mediaSetCDROM
-Select a
-.Fx
-CDROM as the installation media.
-.Pp
-\fBVariables:\fR None
-.It mediaSetFloppy
-Select a pre-made floppy installation set as the installation media.
-.Pp
-\fBVariables:\fR None
-.It mediaSetDOS
-Select an existing DOS primary partition as the installation media.
-The first primary partition found is used (e.g. C:).
-.Pp
-\fBVariables:\fR None
-.It mediaSetTape
-Select a tape device as the installation media.
-.Pp
-\fBVariables:\fR None
-
-.\" XXX
-
-.It mediaSetFTP
-Select an FTP site as the installation media.
-.Pp
-\fBVariables:\fR
-.Bl -tag -width indent
-.It hostname
-The name of the host being installed (non-optional).
-.It domainname
-The domain name of the host being installed (optional).
-.It defaultrouter
-The default router for this host (non-optional).
-.It netDev
-Which host interface to use
-.Ar ( ed0
-or
-.Ar ep0 ,
-for example. Non-optional).
-.It netInteractive
-If set, bring up the interactive network setup form even
-if all relevant configuration variables are already set (optional).
-.It ipaddr
-The IP address for the selected host interface (non-optional).
-.It netmask
-The netmask for the selected host interface (non-optional).
-.It _ftpPath
-The fully qualified URL of the FTP site containing the
-.Fx
-distribution you're interested in, e.g.
-.Ar ftp://ftp.FreeBSD.org/pub/FreeBSD/ .
-.El
-.It mediaSetFTPActive
-Alias for
-.Ar mediaSetFTP
-using "active" FTP transfer mode.
-.Pp
-\fBVariables:\fR Same as for
-.Ar mediaSetFTP .
-.It mediaSetFTPPassive
-Alias for
-.Ar mediaSetFTP
-using "passive" FTP transfer mode.
-.Pp
-\fBVariables:\fR Same as for
-.Ar mediaSetFTP .
-.It mediaSetHTTP
-Alias for
-.Ar mediaSetFTP
-using an HTTP proxy.
-.Pp
-\fBVariables:\fR See
-.Ar mediaSetFTP ,
-plus
-.Bl -tag -width indent
-.It _httpPath
-The proxy to use (host:port) (non-optional).
-.El
-.It mediaSetUFS
-Select an existing UFS partition (mounted with the label editor) as
-the installation media.
-.Pp
-\fBVariables:\fR
-.Bl -tag -width indent
-.It ufs
-full /path to directory containing the
-.Fx
-distribution you're
-interested in.
-.El
-.It mediaSetNFS
-.Pp
-\fBVariables:\fR
-.Bl -tag -width indent
-.It hostname
-The name of the host being installed (non-optional).
-.It domainname
-The domain name of the host being installed (optional).
-.It defaultrouter
-The default router for this host (non-optional).
-.It netDev
-Which host interface to use
-.Ar ( ed0
-or
-.Ar ep0 ,
-for example. Non-optional).
-.It netInteractive
-If set, bring up the interactive network setup form even
-if all relevant configuration variables are already set (optional).
-.It ipaddr
-The IP address for the selected host interface (non-optional).
-.It netmask
-The netmask for the selected host interface (non-optional).
-.It nfs
-full hostname:/path specification for directory containing
-the
-.Fx
-distribution you're interested in.
-.El
-.It mediaSetFTPUserPass
-.Pp
-\fBVariables:\fR
-.Bl -tag -width indent
-.It ftpUser
-The username to log in as on the ftp server site.
-Default: ftp
-.It ftpPass
-The password to use for this username on the ftp
-server site.
-Default: user@host
-.El
-.It mediaSetCPIOVerbosity
-.Pp
-\fBVariables:\fR
-.Bl -tag -width indent
-.It cpioVerbose
-Can be used to set the verbosity of cpio extractions to low, medium or
-high.
-.El
-.It mediaGetType
-Interactively get the user to specify some type of media.
-.Pp
-\fBVariables:\fR None
-.It optionsEditor
-Invoke the interactive options editor.
-.Pp
-\fBVariables:\fR None
-.It packageAdd
-Try to fetch and add a package to the system (requires
-that a media type be set),
-.Pp
-\fBVariables:\fR
-.Bl -tag -width indent
-.It package
-The name of the package to add, e.g. bash-1.14.7 or ncftp-2.4.2.
-.El
-.It addGroup
-Invoke the interactive group editor.
-.Pp
-\fBVariables:\fR None
-.It addUser
-Invoke the interactive user editor.
-.Pp
-\fBVariables:\fR None
-.It shutdown
-Stop the script and terminate sysinstall.
-.Pp
-\fBVariables:\fR None
-.It system
-Execute an arbitrary command with
-.Xr system 3
-.Pp
-\fBVariables:\fR
-.Bl -tag -width indent
-.It command
-The name of the command to execute. When running
-from a boot floppy, very minimal expectations should
-be made as to what's available until/unless a relatively
-full system installation has just been done.
-.El
-.El
-.Sh FILES
-This utility may edit the contents of
-.Pa /etc/rc.conf ,
-.Pa /etc/hosts ,
-and
-.Pa /etc/resolv.conf
-as necessary to reflect changes in the network configuration.
-.Sh SEE ALSO
-If you have a reasonably complete source tree online, take
-a look at
-.Pa /usr/src/release/sysinstall/install.cfg
-for a sample installation script.
-.Sh BUGS
-This utility is a prototype which lasted several years past
-its expiration date and is greatly in need of death.
-.Sh AUTHORS
-.An Jordan K. Hubbard Aq jkh@FreeBSD.org
-.Sh HISTORY
-This version of
-.Nm
-first appeared in
-.Fx 2.0 .
diff --git a/usr.sbin/sysinstall/sysinstall.h b/usr.sbin/sysinstall/sysinstall.h
deleted file mode 100644
index e4a3fc1261ec..000000000000
--- a/usr.sbin/sysinstall/sysinstall.h
+++ /dev/null
@@ -1,752 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last attempt in the `sysinstall' line, the next
- * generation being slated to essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 _SYSINSTALL_H_INCLUDE
-#define _SYSINSTALL_H_INCLUDE
-
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <errno.h>
-#include <setjmp.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <dialog.h>
-#include "ui_objects.h"
-#include "dir.h"
-#include "colors.h"
-#include "libdisk.h"
-#include "dist.h"
-
-/*** Defines ***/
-
-/* device limits */
-#define DEV_NAME_MAX 64 /* The maximum length of a device name */
-#define DEV_MAX 100 /* The maximum number of devices we'll deal with */
-#define INTERFACE_MAX 50 /* Maximum number of network interfaces we'll deal with */
-#define IO_ERROR -2 /* Status code for I/O error rather than normal EOF */
-
-/* Number of seconds to wait for data to come off even the slowest media */
-#define MEDIA_TIMEOUT 300
-
-/*
- * I make some pretty gross assumptions about having a max of 50 chunks
- * total - 8 slices and 42 partitions. I can't easily display many more
- * than that on the screen at once!
- *
- * For 2.1 I'll revisit this and try to make it more dynamic, but since
- * this will catch 99.99% of all possible cases, I'm not too worried.
- */
-#define MAX_CHUNKS 40
-
-/* Internal environment variable names */
-#define DISK_PARTITIONED "_diskPartitioned"
-#define DISK_LABELLED "_diskLabelled"
-#define DISK_SELECTED "_diskSelected"
-#define SYSTEM_STATE "_systemState"
-#define RUNNING_ON_ROOT "_runningOnRoot"
-#define TCP_CONFIGURED "_tcpConfigured"
-
-/* Ones that can be tweaked from config files */
-#define VAR_BLANKTIME "blanktime"
-#define VAR_BOOTMGR "bootManager"
-#define VAR_BROWSER_BINARY "browserBinary"
-#define VAR_BROWSER_PACKAGE "browserPackage"
-#define VAR_CPIO_VERBOSITY "cpioVerbose"
-#define VAR_DEBUG "debug"
-#define VAR_DESKSTYLE "_deskStyle"
-#define VAR_DISK "disk"
-#define VAR_DISTS "dists"
-#define VAR_DIST_MAIN "distMain"
-#define VAR_DIST_CRYPTO "distCRYPTO"
-#define VAR_DIST_SRC "distSRC"
-#define VAR_DIST_X11 "distX11"
-#define VAR_DIST_XSERVER "distXserver"
-#define VAR_DIST_XFONTS "distXfonts"
-#define VAR_DEDICATE_DISK "dedicateDisk"
-#define VAR_DOMAINNAME "domainname"
-#define VAR_EDITOR "editor"
-#define VAR_EXTRAS "ifconfig_"
-#define VAR_COMMAND "command"
-#define VAR_CONFIG_FILE "configFile"
-#define VAR_FTP_DIR "ftpDirectory"
-#define VAR_FTP_PASS "ftpPass"
-#define VAR_FTP_PATH "_ftpPath"
-#define VAR_FTP_PORT "ftpPort"
-#define VAR_FTP_STATE "ftpState"
-#define VAR_FTP_USER "ftpUser"
-#define VAR_FTP_HOST "ftpHost"
-#define VAR_HTTP_PATH "_httpPath"
-#define VAR_HTTP_PORT "httpPort"
-#define VAR_HTTP_HOST "httpHost"
-#define VAR_HTTP_FTP_MODE "httpFtpMode"
-#define VAR_GATEWAY "defaultrouter"
-#define VAR_GEOMETRY "geometry"
-#define VAR_HOSTNAME "hostname"
-#define VAR_IFCONFIG "ifconfig_"
-#define VAR_INTERFACES "network_interfaces"
-#define VAR_INSTALL_CFG "installConfig"
-#define VAR_INSTALL_ROOT "installRoot"
-#define VAR_IPADDR "ipaddr"
-#define VAR_KEYMAP "keymap"
-#define VAR_KGET "kget"
-#define VAR_LABEL "label"
-#define VAR_LABEL_COUNT "labelCount"
-#define VAR_LINUX_ENABLE "linux_enable"
-#define VAR_MEDIA_TYPE "mediaType"
-#define VAR_MEDIA_TIMEOUT "MEDIA_TIMEOUT"
-#define VAR_MOUSED "moused_enable"
-#define VAR_MOUSED_PORT "moused_port"
-#define VAR_MOUSED_TYPE "moused_type"
-#define VAR_NAMESERVER "nameserver"
-#define VAR_NETINTERACTIVE "netInteractive"
-#define VAR_NETMASK "netmask"
-#define VAR_NETWORK_DEVICE "netDev"
-#define VAR_NEWFS_ARGS "newfsArgs"
-#define VAR_NFS_PATH "nfs"
-#define VAR_NFS_HOST "nfsHost"
-#define VAR_NFS_SECURE "nfs_reserved_port_only"
-#define VAR_NFS_SERVER "nfs_server_enable"
-#define VAR_NO_CONFIRM "noConfirm"
-#define VAR_NO_ERROR "noError"
-#define VAR_NO_WARN "noWarn"
-#define VAR_NO_USR "noUsr"
-#define VAR_NONINTERACTIVE "nonInteractive"
-#define VAR_NOVELL "novell"
-#define VAR_NTPDATE_FLAGS "ntpdate_flags"
-#define VAR_PACKAGE "package"
-#define VAR_PARTITION "partition"
-#define VAR_PCNFSD "pcnfsd"
-#define VAR_PKG_TMPDIR "PKG_TMPDIR"
-#define VAR_PORTS_PATH "ports"
-#define VAR_PPP_ENABLE "ppp_enable"
-#define VAR_PPP_PROFILE "ppp_profile"
-#define VAR_RELNAME "releaseName"
-#define VAR_ROOT_SIZE "rootSize"
-#define VAR_ROUTER "router"
-#define VAR_ROUTER_ENABLE "router_enable"
-#define VAR_ROUTERFLAGS "router_flags"
-#define VAR_SERIAL_SPEED "serialSpeed"
-#define VAR_SLOW_ETHER "slowEthernetCard"
-#define VAR_SWAP_SIZE "swapSize"
-#define VAR_TAPE_BLOCKSIZE "tapeBlocksize"
-#define VAR_TRY_DHCP "tryDHCP"
-#define VAR_UFS_PATH "ufs"
-#define VAR_USR_SIZE "usrSize"
-#define VAR_VAR_SIZE "varSize"
-#define VAR_XF86_CONFIG "_xf86config"
-
-#define DEFAULT_TAPE_BLOCKSIZE "20"
-
-/* One MB worth of blocks */
-#define ONE_MEG 2048
-#define ONE_GIG (ONE_MEG * 1024)
-
-/* Which selection attributes to use */
-#define ATTR_SELECTED (ColorDisplay ? item_selected_attr : item_attr)
-#define ATTR_TITLE button_active_attr
-
-/* Handy strncpy() macro */
-#define SAFE_STRCPY(to, from) sstrncpy((to), (from), sizeof (to) - 1)
-
-/*** Types ***/
-typedef unsigned int Boolean;
-typedef struct disk Disk;
-typedef struct chunk Chunk;
-
-/* Bitfields for menu options */
-#define DMENU_NORMAL_TYPE 0x1 /* Normal dialog menu */
-#define DMENU_RADIO_TYPE 0x2 /* Radio dialog menu */
-#define DMENU_CHECKLIST_TYPE 0x4 /* Multiple choice menu */
-#define DMENU_SELECTION_RETURNS 0x8 /* Immediate return on item selection */
-
-typedef struct _dmenu {
- int type; /* What sort of menu we are */
- char *title; /* Our title */
- char *prompt; /* Our prompt */
- char *helpline; /* Line of help at bottom */
- char *helpfile; /* Help file for "F1" */
- dialogMenuItem items[0]; /* Array of menu items */
-} DMenu;
-
-/* An rc.conf variable */
-typedef struct _variable {
- struct _variable *next;
- char *name;
- char *value;
- int dirty;
-} Variable;
-
-#define NO_ECHO_OBJ(type) ((type) | (DITEM_NO_ECHO << 16))
-#define TYPE_OF_OBJ(type) ((type) & 0xff)
-#define ATTR_OF_OBJ(type) ((type) >> 16)
-
-/* A screen layout structure */
-typedef struct _layout {
- int y; /* x & Y co-ordinates */
- int x;
- int len; /* The size of the dialog on the screen */
- int maxlen; /* How much the user can type in ... */
- char *prompt; /* The string for the prompt */
- char *help; /* The display for the help line */
- void *var; /* The var to set when this changes */
- int type; /* The type of the dialog to create */
- void *obj; /* The obj pointer returned by libdialog */
-} Layout;
-
-typedef enum {
- DEVICE_TYPE_NONE,
- DEVICE_TYPE_DISK,
- DEVICE_TYPE_FLOPPY,
- DEVICE_TYPE_FTP,
- DEVICE_TYPE_NETWORK,
- DEVICE_TYPE_CDROM,
- DEVICE_TYPE_TAPE,
- DEVICE_TYPE_DOS,
- DEVICE_TYPE_UFS,
- DEVICE_TYPE_NFS,
- DEVICE_TYPE_ANY,
- DEVICE_TYPE_HTTP,
-} DeviceType;
-
-/* CDROM mount codes */
-#define CD_UNMOUNTED 0
-#define CD_ALREADY_MOUNTED 1
-#define CD_WE_MOUNTED_IT 2
-
-/* A "device" from sysinstall's point of view */
-typedef struct _device {
- char name[DEV_NAME_MAX];
- char *description;
- char *devname;
- DeviceType type;
- Boolean enabled;
- Boolean (*init)(struct _device *dev);
- FILE * (*get)(struct _device *dev, char *file, Boolean probe);
- void (*shutdown)(struct _device *dev);
- void *private;
- unsigned int flags;
-} Device;
-
-/* Some internal representations of partitions */
-typedef enum {
- PART_NONE,
- PART_SLICE,
- PART_SWAP,
- PART_FILESYSTEM,
- PART_FAT,
-} PartType;
-
-/* The longest newfs command we'll hand to system() */
-#define NEWFS_CMD_MAX 256
-
-typedef struct _part_info {
- Boolean newfs;
- char mountpoint[FILENAME_MAX];
- char newfs_cmd[NEWFS_CMD_MAX];
-} PartInfo;
-
-/* An option */
-typedef struct _opt {
- char *name;
- char *desc;
- enum { OPT_IS_STRING, OPT_IS_INT, OPT_IS_FUNC, OPT_IS_VAR } type;
- void *data;
- void *aux;
- char *(*check)();
-} Option;
-
-/* Weird index nodey things we use for keeping track of package information */
-typedef enum { PACKAGE, PLACE } node_type; /* Types of nodes */
-
-typedef struct _pkgnode { /* A node in the reconstructed hierarchy */
- struct _pkgnode *next; /* My next sibling */
- node_type type; /* What am I? */
- char *name; /* My name */
- char *desc; /* My description (Hook) */
- struct _pkgnode *kids; /* My little children */
- void *data; /* A place to hang my data */
-} PkgNode;
-typedef PkgNode *PkgNodePtr;
-
-/* A single package */
-typedef struct _indexEntry { /* A single entry in an INDEX file */
- char *name; /* name */
- char *path; /* full path to port */
- char *prefix; /* port prefix */
- char *comment; /* one line description */
- char *descrfile; /* path to description file */
- char *deps; /* packages this depends on */
- int depc; /* how many depend on me */
- int installed; /* indicates if it is installed */
- char *maintainer; /* maintainer */
-} IndexEntry;
-typedef IndexEntry *IndexEntryPtr;
-
-typedef int (*commandFunc)(char *key, void *data);
-
-#define HOSTNAME_FIELD_LEN 128
-#define IPADDR_FIELD_LEN 16
-#define EXTRAS_FIELD_LEN 128
-
-/* This is the structure that Network devices carry around in their private, erm, structures */
-typedef struct _devPriv {
- int use_dhcp;
- char ipaddr[IPADDR_FIELD_LEN];
- char netmask[IPADDR_FIELD_LEN];
- char extras[EXTRAS_FIELD_LEN];
-} DevInfo;
-
-
-/*** Externs ***/
-extern jmp_buf BailOut; /* Used to get the heck out */
-extern int DebugFD; /* Where diagnostic output goes */
-extern Boolean Fake; /* Don't actually modify anything - testing */
-extern Boolean SystemWasInstalled; /* Did we install it? */
-extern Boolean RunningAsInit; /* Are we running stand-alone? */
-extern Boolean DialogActive; /* Is the dialog() stuff up? */
-extern Boolean ColorDisplay; /* Are we on a color display? */
-extern Boolean OnVTY; /* On a syscons VTY? */
-Boolean USAResident; /* Are we cryptographically challenged? */
-extern Variable *VarHead; /* The head of the variable chain */
-extern Device *mediaDevice; /* Where we're getting our distribution from */
-extern unsigned int Dists; /* Which distributions we want */
-extern unsigned int CRYPTODists; /* Which naughty distributions we want */
-extern unsigned int SrcDists; /* Which src distributions we want */
-extern unsigned int XF86Dists; /* Which XFree86 dists we want */
-extern unsigned int XF86ServerDists; /* The XFree86 servers we want */
-extern unsigned int XF86FontDists; /* The XFree86 fonts we want */
-extern int BootMgr; /* Which boot manager to use */
-extern int StatusLine; /* Where to print our status messages */
-extern DMenu MenuInitial; /* Initial installation menu */
-extern DMenu MenuFixit; /* Fixit repair menu */
-extern DMenu MenuMBRType; /* Type of MBR to write on the disk */
-extern DMenu MenuConfigure; /* Final configuration menu */
-extern DMenu MenuDocumentation; /* Documentation menu */
-extern DMenu MenuFTPOptions; /* FTP Installation options */
-extern DMenu MenuIndex; /* Index menu */
-extern DMenu MenuOptions; /* Installation options */
-extern DMenu MenuOptionsLanguage; /* Language options menu */
-extern DMenu MenuMedia; /* Media type menu */
-extern DMenu MenuMouse; /* Mouse type menu */
-extern DMenu MenuMediaCDROM; /* CDROM media menu */
-extern DMenu MenuMediaDOS; /* DOS media menu */
-extern DMenu MenuMediaFloppy; /* Floppy media menu */
-extern DMenu MenuMediaFTP; /* FTP media menu */
-extern DMenu MenuMediaTape; /* Tape media menu */
-extern DMenu MenuNetworkDevice; /* Network device menu */
-extern DMenu MenuNTP; /* NTP time server menu */
-extern DMenu MenuStartup; /* Startup services menu */
-extern DMenu MenuSyscons; /* System console configuration menu */
-extern DMenu MenuSysconsFont; /* System console font configuration menu */
-extern DMenu MenuSysconsKeymap; /* System console keymap configuration menu */
-extern DMenu MenuSysconsKeyrate; /* System console keyrate configuration menu */
-extern DMenu MenuSysconsSaver; /* System console saver configuration menu */
-extern DMenu MenuSysconsScrnmap; /* System console screenmap configuration menu */
-extern DMenu MenuNetworking; /* Network configuration menu */
-extern DMenu MenuInstallCustom; /* Custom Installation menu */
-extern DMenu MenuDistributions; /* Distribution menu */
-extern DMenu MenuDiskDevices; /* Disk type devices */
-extern DMenu MenuSubDistributions; /* Custom distribution menu */
-extern DMenu MenuCRYPTODistributions;/* Encryption distribution menu */
-extern DMenu MenuSrcDistributions; /* Source distribution menu */
-extern DMenu MenuXF86; /* XFree86 main menu */
-extern DMenu MenuXF86Select; /* XFree86 distribution selection menu */
-extern DMenu MenuXF86SelectCore; /* XFree86 core distribution menu */
-extern DMenu MenuXF86SelectServer; /* XFree86 server distribution menu */
-extern DMenu MenuXF86SelectPC98Server; /* XFree86 server distribution menu */
-extern DMenu MenuXF86SelectFonts; /* XFree86 font selection menu */
-extern DMenu MenuXF86SelectFonts; /* XFree86 font selection menu */
-extern DMenu MenuXDesktops; /* Disk devices menu */
-extern DMenu MenuHTMLDoc; /* HTML Documentation menu */
-extern DMenu MenuUsermgmt; /* User management menu */
-extern DMenu MenuFixit; /* Fixit floppy/CDROM/shell menu */
-extern DMenu MenuXF86Config; /* Select XFree86 configuration type */
-
-/* Stuff from libdialog which isn't properly declared outside */
-extern void display_helpfile(void);
-extern void display_helpline(WINDOW *w, int y, int width);
-
-/*** Prototypes ***/
-
-/* anonFTP.c */
-extern int configAnonFTP(dialogMenuItem *self);
-
-/* cdrom.c */
-extern Boolean mediaInitCDROM(Device *dev);
-extern FILE *mediaGetCDROM(Device *dev, char *file, Boolean probe);
-extern void mediaShutdownCDROM(Device *dev);
-
-/* command.c */
-extern void command_clear(void);
-extern void command_sort(void);
-extern void command_execute(void);
-extern void command_shell_add(char *key, char *fmt, ...);
-extern void command_func_add(char *key, commandFunc func, void *data);
-
-/* config.c */
-extern void configEnvironmentRC_conf(void);
-extern void configEnvironmentResolv(char *config);
-extern void configRC_conf(void);
-extern void configMake_conf(char *config);
-extern int configFstab(dialogMenuItem *self);
-extern int configRC(dialogMenuItem *self);
-extern int configResolv(dialogMenuItem *self);
-extern int configPackages(dialogMenuItem *self);
-extern int configSaver(dialogMenuItem *self);
-extern int configSaverTimeout(dialogMenuItem *self);
-extern int configLinux(dialogMenuItem *self);
-extern int configNTP(dialogMenuItem *self);
-extern int configUsers(dialogMenuItem *self);
-extern int configXSetup(dialogMenuItem *self);
-extern int configXDesktop(dialogMenuItem *self);
-extern int configRouter(dialogMenuItem *self);
-extern int configPCNFSD(dialogMenuItem *self);
-extern int configNFSServer(dialogMenuItem *self);
-extern int configWriteRC_conf(dialogMenuItem *self);
-
-/* crc.c */
-extern int crc(int, unsigned long *, unsigned long *);
-
-/* devices.c */
-extern DMenu *deviceCreateMenu(DMenu *menu, DeviceType type, int (*hook)(dialogMenuItem *d),
- int (*check)(dialogMenuItem *d));
-extern void deviceGetAll(void);
-extern void deviceReset(void);
-extern void deviceRescan(void);
-extern Device **deviceFind(char *name, DeviceType type);
-extern Device **deviceFindDescr(char *name, char *desc, DeviceType class);
-extern int deviceCount(Device **devs);
-extern Device *new_device(char *name);
-extern Device *deviceRegister(char *name, char *desc, char *devname, DeviceType type, Boolean enabled,
- Boolean (*init)(Device *mediadev),
- FILE * (*get)(Device *dev, char *file, Boolean probe),
- void (*shutDown)(Device *mediadev),
- void *private);
-extern Boolean dummyInit(Device *dev);
-extern FILE *dummyGet(Device *dev, char *dist, Boolean probe);
-extern void dummyShutdown(Device *dev);
-
-/* dhcp.c */
-extern int dhcpParseLeases(char *file, char *hostname, char *domain, char *nameserver,
- char *ipaddr, char *gateway, char *netmask);
-
-/* disks.c */
-extern int diskPartitionEditor(dialogMenuItem *self);
-extern int diskPartitionWrite(dialogMenuItem *self);
-extern int diskGetSelectCount(Device ***devs);
-extern void diskPartition(Device *dev);
-
-/* dispatch.c */
-extern int dispatchCommand(char *command);
-extern int dispatch_load_floppy(dialogMenuItem *self);
-extern int dispatch_load_file_int(int);
-extern int dispatch_load_file(dialogMenuItem *self);
-
-
-/* dist.c */
-extern int distReset(dialogMenuItem *self);
-extern int distConfig(dialogMenuItem *self);
-extern int distSetCustom(dialogMenuItem *self);
-extern int distUnsetCustom(dialogMenuItem *self);
-extern int distSetDeveloper(dialogMenuItem *self);
-extern int distSetXDeveloper(dialogMenuItem *self);
-extern int distSetKernDeveloper(dialogMenuItem *self);
-extern int distSetXKernDeveloper(dialogMenuItem *self);
-extern int distSetUser(dialogMenuItem *self);
-extern int distSetXUser(dialogMenuItem *self);
-extern int distSetMinimum(dialogMenuItem *self);
-extern int distSetEverything(dialogMenuItem *self);
-extern int distSetCRYPTO(dialogMenuItem *self);
-extern int distSetSrc(dialogMenuItem *self);
-extern int distSetXF86(dialogMenuItem *self);
-extern int distExtractAll(dialogMenuItem *self);
-
-/* dmenu.c */
-extern int dmenuDisplayFile(dialogMenuItem *tmp);
-extern int dmenuSubmenu(dialogMenuItem *tmp);
-extern int dmenuSystemCommand(dialogMenuItem *tmp);
-extern int dmenuSystemCommandBox(dialogMenuItem *tmp);
-extern int dmenuExit(dialogMenuItem *tmp);
-extern int dmenuISetVariable(dialogMenuItem *tmp);
-extern int dmenuSetVariable(dialogMenuItem *tmp);
-extern int dmenuSetKmapVariable(dialogMenuItem *tmp);
-extern int dmenuSetVariables(dialogMenuItem *tmp);
-extern int dmenuToggleVariable(dialogMenuItem *tmp);
-extern int dmenuSetFlag(dialogMenuItem *tmp);
-extern int dmenuSetValue(dialogMenuItem *tmp);
-extern Boolean dmenuOpen(DMenu *menu, int *choice, int *scroll, int *curr, int *max, Boolean buttons);
-extern Boolean dmenuOpenSimple(DMenu *menu, Boolean buttons);
-extern int dmenuVarCheck(dialogMenuItem *item);
-extern int dmenuVarsCheck(dialogMenuItem *item);
-extern int dmenuFlagCheck(dialogMenuItem *item);
-extern int dmenuRadioCheck(dialogMenuItem *item);
-
-/* doc.c */
-extern int docBrowser(dialogMenuItem *self);
-extern int docShowDocument(dialogMenuItem *self);
-
-/* dos.c */
-extern Boolean mediaCloseDOS(Device *dev, FILE *fp);
-extern Boolean mediaInitDOS(Device *dev);
-extern FILE *mediaGetDOS(Device *dev, char *file, Boolean probe);
-extern void mediaShutdownDOS(Device *dev);
-
-/* floppy.c */
-extern int getRootFloppy(void);
-extern Boolean mediaInitFloppy(Device *dev);
-extern FILE *mediaGetFloppy(Device *dev, char *file, Boolean probe);
-extern void mediaShutdownFloppy(Device *dev);
-
-/* ftp_strat.c */
-extern Boolean mediaCloseFTP(Device *dev, FILE *fp);
-extern Boolean mediaInitFTP(Device *dev);
-extern FILE *mediaGetFTP(Device *dev, char *file, Boolean probe);
-extern void mediaShutdownFTP(Device *dev);
-
-/* http.c */
-extern Boolean mediaInitHTTP(Device *dev);
-extern FILE *mediaGetHTTP(Device *dev, char *file, Boolean probe);
-
-/* globals.c */
-extern void globalsInit(void);
-
-/* index.c */
-int index_read(FILE *fp, PkgNodePtr papa);
-int index_menu(PkgNodePtr root, PkgNodePtr top, PkgNodePtr plist, int *pos, int *scroll);
-void index_init(PkgNodePtr top, PkgNodePtr plist);
-void index_node_free(PkgNodePtr top, PkgNodePtr plist);
-void index_sort(PkgNodePtr top);
-void index_print(PkgNodePtr top, int level);
-int index_extract(Device *dev, PkgNodePtr top, PkgNodePtr who, Boolean depended);
-int index_initialize(char *path);
-PkgNodePtr index_search(PkgNodePtr top, char *str, PkgNodePtr *tp);
-
-/* install.c */
-extern Boolean checkLabels(Boolean whinge, Chunk **rdev, Chunk **sdev, Chunk **udev, Chunk **vdev);
-extern int installCommit(dialogMenuItem *self);
-extern int installCustomCommit(dialogMenuItem *self);
-extern int installExpress(dialogMenuItem *self);
-extern int installStandard(dialogMenuItem *self);
-extern int installFixitHoloShell(dialogMenuItem *self);
-extern int installFixitCDROM(dialogMenuItem *self);
-extern int installFixitFloppy(dialogMenuItem *self);
-extern int installFixupBin(dialogMenuItem *self);
-extern int installFixupXFree(dialogMenuItem *self);
-extern int installUpgrade(dialogMenuItem *self);
-extern int installFilesystems(dialogMenuItem *self);
-extern int installVarDefaults(dialogMenuItem *self);
-extern void installEnvironment(void);
-extern int installX11package(dialogMenuItem *self);
-extern Boolean copySelf(void);
-
-/* kget.c */
-extern int kget(char *out);
-
-/* keymap.c */
-extern int loadKeymap(const char *lang);
-
-/* label.c */
-extern int diskLabelEditor(dialogMenuItem *self);
-extern int diskLabelCommit(dialogMenuItem *self);
-
-/* lndir.c */
-extern int lndir(char *from, char *to);
-
-/* makedevs.c (auto-generated) */
-extern const char termcap_ansi[];
-extern const char termcap_vt100[];
-extern const char termcap_cons25[];
-extern const char termcap_cons25_m[];
-extern const char termcap_cons25r[];
-extern const char termcap_cons25r_m[];
-extern const char termcap_cons25l1[];
-extern const char termcap_cons25l1_m[];
-extern const u_char font_iso_8x16[];
-extern const u_char font_cp850_8x16[];
-extern const u_char font_cp866_8x16[];
-extern const u_char koi8_r2cp866[];
-extern u_char default_scrnmap[];
-
-/* media.c */
-extern char *cpioVerbosity(void);
-extern void mediaClose(void);
-extern int mediaTimeout(void);
-extern int mediaSetCDROM(dialogMenuItem *self);
-extern int mediaSetFloppy(dialogMenuItem *self);
-extern int mediaSetDOS(dialogMenuItem *self);
-extern int mediaSetTape(dialogMenuItem *self);
-extern int mediaSetFTP(dialogMenuItem *self);
-extern int mediaSetFTPActive(dialogMenuItem *self);
-extern int mediaSetFTPPassive(dialogMenuItem *self);
-extern int mediaSetHTTP(dialogMenuItem *self);
-extern int mediaSetUFS(dialogMenuItem *self);
-extern int mediaSetNFS(dialogMenuItem *self);
-extern int mediaSetFTPUserPass(dialogMenuItem *self);
-extern int mediaSetCPIOVerbosity(dialogMenuItem *self);
-extern int mediaGetType(dialogMenuItem *self);
-extern Boolean mediaExtractDist(char *dir, char *dist, FILE *fp);
-extern Boolean mediaExtractDistBegin(char *dir, int *fd, int *zpid, int *cpic);
-extern Boolean mediaExtractDistEnd(int zpid, int cpid);
-extern Boolean mediaVerify(void);
-extern FILE *mediaGenericGet(char *base, const char *file);
-
-/* misc.c */
-extern Boolean file_readable(char *fname);
-extern Boolean file_executable(char *fname);
-extern Boolean directory_exists(const char *dirname);
-extern char *root_bias(char *path);
-extern char *itoa(int value);
-extern char *string_concat(char *p1, char *p2);
-extern char *string_concat3(char *p1, char *p2, char *p3);
-extern char *string_prune(char *str);
-extern char *string_skipwhite(char *str);
-extern char *string_copy(char *s1, char *s2);
-extern char *pathBaseName(const char *path);
-extern void safe_free(void *ptr);
-extern void *safe_malloc(size_t size);
-extern void *safe_realloc(void *orig, size_t size);
-extern dialogMenuItem *item_add(dialogMenuItem *list, char *prompt, char *title,
- int (*checked)(dialogMenuItem *self),
- int (*fire)(dialogMenuItem *self),
- void (*selected)(dialogMenuItem *self, int is_selected),
- void *data, int aux, int *curr, int *max);
-extern void items_free(dialogMenuItem *list, int *curr, int *max);
-extern int Mkdir(char *);
-extern int Mount(char *, void *data);
-extern WINDOW *openLayoutDialog(char *helpfile, char *title, int x, int y, int width, int height);
-extern ComposeObj *initLayoutDialog(WINDOW *win, Layout *layout, int x, int y, int *max);
-extern int layoutDialogLoop(WINDOW *win, Layout *layout, ComposeObj **obj,
- int *n, int max, int *cbutton, int *cancel);
-
-extern WINDOW *savescr(void);
-extern void restorescr(WINDOW *w);
-extern char *sstrncpy(char *dst, const char *src, int size);
-
-/* mouse.c */
-extern int mousedTest(dialogMenuItem *self);
-extern int mousedDisable(dialogMenuItem *self);
-
-/* msg.c */
-extern Boolean isDebug(void);
-extern void msgInfo(char *fmt, ...);
-extern void msgYap(char *fmt, ...);
-extern void msgWarn(char *fmt, ...);
-extern void msgDebug(char *fmt, ...);
-extern void msgError(char *fmt, ...);
-extern void msgFatal(char *fmt, ...);
-extern void msgConfirm(char *fmt, ...);
-extern void msgNotify(char *fmt, ...);
-extern void msgWeHaveOutput(char *fmt, ...);
-extern int msgYesNo(char *fmt, ...);
-extern char *msgGetInput(char *buf, char *fmt, ...);
-extern int msgSimpleConfirm(char *);
-extern int msgSimpleNotify(char *);
-
-/* network.c */
-extern Boolean mediaInitNetwork(Device *dev);
-extern void mediaShutdownNetwork(Device *dev);
-
-/* nfs.c */
-extern Boolean mediaInitNFS(Device *dev);
-extern FILE *mediaGetNFS(Device *dev, char *file, Boolean probe);
-extern void mediaShutdownNFS(Device *dev);
-
-/* options.c */
-extern int optionsEditor(dialogMenuItem *self);
-
-/* package.c */
-extern int packageAdd(dialogMenuItem *self);
-extern int package_add(char *name);
-extern int package_extract(Device *dev, char *name, Boolean depended);
-extern Boolean package_exists(char *name);
-
-/* pccard.c */
-extern void pccardInitialize(void);
-
-/* system.c */
-extern void systemInitialize(int argc, char **argv);
-extern void systemShutdown(int status);
-extern int execExecute(char *cmd, char *name);
-extern int systemExecute(char *cmd);
-extern int systemDisplayHelp(char *file);
-extern char *systemHelpFile(char *file, char *buf);
-extern void systemChangeFont(const u_char font[]);
-extern void systemChangeLang(char *lang);
-extern void systemChangeTerminal(char *color, const u_char c_termcap[], char *mono, const u_char m_termcap[]);
-extern void systemChangeScreenmap(const u_char newmap[]);
-extern void systemCreateHoloshell(void);
-extern int vsystem(char *fmt, ...);
-
-/* tape.c */
-extern char *mediaTapeBlocksize(void);
-extern Boolean mediaInitTape(Device *dev);
-extern FILE *mediaGetTape(Device *dev, char *file, Boolean probe);
-extern void mediaShutdownTape(Device *dev);
-
-/* tcpip.c */
-extern int tcpOpenDialog(Device *dev);
-extern int tcpMenuSelect(dialogMenuItem *self);
-extern Device *tcpDeviceSelect(void);
-
-/* termcap.c */
-extern int set_termcap(void);
-
-/* ufs.c */
-extern void mediaShutdownUFS(Device *dev);
-extern Boolean mediaInitUFS(Device *dev);
-extern FILE *mediaGetUFS(Device *dev, char *file, Boolean probe);
-
-/* user.c */
-extern int userAddGroup(dialogMenuItem *self);
-extern int userAddUser(dialogMenuItem *self);
-
-/* variable.c */
-extern void variable_set(char *var, int dirty);
-extern void variable_set2(char *name, char *value, int dirty);
-extern char *variable_get(char *var);
-extern int variable_cmp(char *var, char *value);
-extern void variable_unset(char *var);
-extern char *variable_get_value(char *var, char *prompt, int dirty);
-extern int variable_check(char *data);
-extern int dump_variables(dialogMenuItem *self);
-
-/* wizard.c */
-extern void slice_wizard(Disk *d);
-
-#endif
-/* _SYSINSTALL_H_INCLUDE */
diff --git a/usr.sbin/sysinstall/system.c b/usr.sbin/sysinstall/system.c
deleted file mode 100644
index aaca07796441..000000000000
--- a/usr.sbin/sysinstall/system.c
+++ /dev/null
@@ -1,413 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last program in the `sysinstall' line - the next
- * generation being essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Jordan Hubbard
- *
- * My contributions are in the public domain.
- *
- * Parts of this file are also blatently stolen from Poul-Henning Kamp's
- * previous version of sysinstall, and as such fall under his "BEERWARE license"
- * so buy him a beer if you like it! Buy him a beer for me, too!
- * Heck, get him completely drunk and send me pictures! :-)
- */
-
-#include "sysinstall.h"
-#include <signal.h>
-#include <termios.h>
-#include <sys/reboot.h>
-#include <machine/console.h>
-#include <sys/fcntl.h>
-#include <sys/ioctl.h>
-#include <sys/stat.h>
-
-
-/* Where we stick our temporary expanded doc file */
-#define DOC_TMP_DIR "/tmp/.doc"
-#define DOC_TMP_FILE "/tmp/.doc/doc.tmp"
-
-static pid_t ehs_pid;
-
-/*
- * Handle interrupt signals - this probably won't work in all cases
- * due to our having bogotified the internal state of dialog or curses,
- * but we'll give it a try.
- */
-static void
-handle_intr(int sig)
-{
- WINDOW *save = savescr();
-
- if (!msgYesNo("Are you sure you want to abort the installation?"))
- systemShutdown(-1);
- else
- restorescr(save);
-}
-
-/* Expand a file into a convenient location, nuking it each time */
-static char *
-expand(char *fname)
-{
- char *gunzip = RunningAsInit ? "/stand/gunzip" : "/usr/bin/gunzip";
-
- if (!directory_exists(DOC_TMP_DIR)) {
- Mkdir(DOC_TMP_DIR);
- if (chown(DOC_TMP_DIR, 0, 0) < 0)
- return NULL;
- if (chmod(DOC_TMP_DIR, S_IRWXU) < 0)
- return NULL;
- }
- else
- unlink(DOC_TMP_FILE);
- if (!file_readable(fname) || vsystem("%s < %s > %s", gunzip, fname, DOC_TMP_FILE))
- return NULL;
- return DOC_TMP_FILE;
-}
-
-/* Initialize system defaults */
-void
-systemInitialize(int argc, char **argv)
-{
- int i, boothowto;
-
- signal(SIGINT, SIG_IGN);
- globalsInit();
-
- i = sizeof(boothowto);
- if (!sysctlbyname("debug.boothowto", &boothowto, &i, NULL, NULL) &&
- (i == sizeof(boothowto)) && (boothowto & RB_VERBOSE))
- variable_set2(VAR_DEBUG, "YES", 0);
-
- /* Are we running as init? */
- if (getpid() == 1) {
- int fd, type;
-
- RunningAsInit = 1;
- setsid();
- close(0);
- fd = open("/dev/ttyv0", O_RDWR);
- if (fd == -1)
- fd = open("/dev/console", O_RDWR); /* fallback */
- else
- OnVTY = TRUE;
- /*
- * To make _sure_ we're on a VTY and don't have /dev/console switched
- * away to a serial port or something, attempt to set the cursor appearance.
- */
- type = 0; /* normal */
- if (OnVTY) {
- int fd2;
-
- if ((fd2 = open("/dev/console", O_RDWR)) != -1) {
- if (ioctl(fd2, CONS_CURSORTYPE, &type) == -1) {
- OnVTY = FALSE;
- close(fd); close(fd2);
- open("/dev/console", O_RDWR);
- }
- else
- close(fd2);
- }
- }
- close(1); dup(0);
- close(2); dup(0);
- printf("%s running as init on %s\n", argv[0], OnVTY ? "vty0" : "serial console");
- ioctl(0, TIOCSCTTY, (char *)NULL);
- setlogin("root");
- setenv("PATH", "/stand:/bin:/sbin:/usr/sbin:/usr/bin:/mnt/bin:/mnt/sbin:/mnt/usr/sbin:/mnt/usr/bin:/usr/X11R6/bin", 1);
- setbuf(stdin, 0);
- setbuf(stderr, 0);
-#ifdef __alpha__
- i = 0;
- sysctlbyname("machdep.unaligned_print", NULL, 0, &i, sizeof(i));
-#endif
- }
- else {
- char hname[256];
-
- /* Initalize various things for a multi-user environment */
- if (!gethostname(hname, sizeof hname))
- variable_set2(VAR_HOSTNAME, hname, 0);
- }
-
- if (set_termcap() == -1) {
- printf("Can't find terminal entry\n");
- exit(-1);
- }
-
- /* XXX - libdialog has particularly bad return value checking */
- init_dialog();
-
- /* If we haven't crashed I guess dialog is running ! */
- DialogActive = TRUE;
-
- /* Make sure HOME is set for those utilities that need it */
- if (!getenv("HOME"))
- setenv("HOME", "/", 1);
- signal(SIGINT, handle_intr);
- (void)vsystem("rm -rf %s", DOC_TMP_DIR);
-}
-
-/* Close down and prepare to exit */
-void
-systemShutdown(int status)
-{
- /* If some media is open, close it down */
- if (status >=0)
- mediaClose();
-
- /* write out any changes to rc.conf .. */
- configRC_conf();
-
- /* Shut down the dialog library */
- if (DialogActive) {
- end_dialog();
- DialogActive = FALSE;
- }
-
- /* Shut down curses */
- endwin();
-
- /* If we have a temporary doc dir lying around, nuke it */
- (void)vsystem("rm -rf %s", DOC_TMP_DIR);
-
- /* REALLY exit! */
- if (RunningAsInit) {
- /* Put the console back */
- ioctl(0, VT_ACTIVATE, 2);
-#ifdef __alpha__
- reboot(RB_HALT);
-#else
- reboot(0);
-#endif
- }
- else
- exit(status);
-}
-
-/* Run some general command */
-int
-systemExecute(char *command)
-{
- int status;
- struct termios foo;
- WINDOW *w = savescr();
-
- dialog_clear();
- dialog_update();
- end_dialog();
- DialogActive = FALSE;
- if (tcgetattr(0, &foo) != -1) {
- foo.c_cc[VERASE] = '\010';
- tcsetattr(0, TCSANOW, &foo);
- }
- if (!Fake)
- status = system(command);
- else {
- status = 0;
- msgDebug("systemExecute: Faked execution of `%s'\n", command);
- }
- DialogActive = TRUE;
- restorescr(w);
- return status;
-}
-
-/* Display a help file in a filebox */
-int
-systemDisplayHelp(char *file)
-{
- char *fname = NULL;
- char buf[FILENAME_MAX];
- int ret = 0;
- WINDOW *w = savescr();
-
- fname = systemHelpFile(file, buf);
- if (!fname) {
- snprintf(buf, FILENAME_MAX, "The %s file is not provided on this particular floppy image.", file);
- use_helpfile(NULL);
- use_helpline(NULL);
- dialog_mesgbox("Sorry!", buf, -1, -1);
- ret = 1;
- }
- else {
- use_helpfile(NULL);
- use_helpline(NULL);
- dialog_textbox(file, fname, LINES, COLS);
- }
- restorescr(w);
- return ret;
-}
-
-char *
-systemHelpFile(char *file, char *buf)
-{
- if (!file)
- return NULL;
- if (file[0] == '/')
- return file;
- snprintf(buf, FILENAME_MAX, "/stand/help/%s.hlp.gz", file);
- if (file_readable(buf))
- return expand(buf);
- snprintf(buf, FILENAME_MAX, "/stand/help/%s.TXT.gz", file);
- if (file_readable(buf))
- return expand(buf);
- snprintf(buf, FILENAME_MAX, "/usr/src/release/sysinstall/help/%s.hlp", file);
- if (file_readable(buf))
- return buf;
- snprintf(buf, FILENAME_MAX, "/usr/src/release/sysinstall/help/%s.TXT", file);
- if (file_readable(buf))
- return buf;
- return NULL;
-}
-
-void
-systemChangeTerminal(char *color, const u_char c_term[],
- char *mono, const u_char m_term[])
-{
- if (OnVTY) {
- int setupterm(char *color, int, int *);
-
- if (ColorDisplay) {
- setenv("TERM", color, 1);
- setenv("TERMCAP", c_term, 1);
- reset_shell_mode();
- setterm(color);
- cbreak(); noecho();
- }
- else {
- setenv("TERM", mono, 1);
- setenv("TERMCAP", m_term, 1);
- reset_shell_mode();
- setterm(mono);
- cbreak(); noecho();
- }
- }
- clear();
- refresh();
- dialog_clear();
-}
-
-int
-vsystem(char *fmt, ...)
-{
- va_list args;
- int pstat;
- pid_t pid;
- int omask;
- sig_t intsave, quitsave;
- char *cmd;
- int i;
-
- cmd = (char *)alloca(FILENAME_MAX);
- cmd[0] = '\0';
- va_start(args, fmt);
- vsnprintf(cmd, FILENAME_MAX, fmt, args);
- va_end(args);
-
- omask = sigblock(sigmask(SIGCHLD));
- if (Fake) {
- msgDebug("vsystem: Faked execution of `%s'\n", cmd);
- return 0;
- }
- if (isDebug())
- msgDebug("Executing command `%s'\n", cmd);
- pid = fork();
- if (pid == -1) {
- (void)sigsetmask(omask);
- i = 127;
- }
- else if (!pid) { /* Junior */
- (void)sigsetmask(omask);
- if (DebugFD != -1) {
- dup2(DebugFD, 0);
- dup2(DebugFD, 1);
- dup2(DebugFD, 2);
- }
- else {
- close(1); open("/dev/null", O_WRONLY);
- dup2(1, 2);
- }
- if (!RunningAsInit)
- execl("/bin/sh", "/bin/sh", "-c", cmd, (char *)NULL);
- else
- execl("/stand/sh", "/stand/sh", "-c", cmd, (char *)NULL);
- exit(1);
- }
- else {
- intsave = signal(SIGINT, SIG_IGN);
- quitsave = signal(SIGQUIT, SIG_IGN);
- pid = waitpid(pid, &pstat, 0);
- (void)sigsetmask(omask);
- (void)signal(SIGINT, intsave);
- (void)signal(SIGQUIT, quitsave);
- i = (pid == -1) ? -1 : WEXITSTATUS(pstat);
- if (isDebug())
- msgDebug("Command `%s' returns status of %d\n", cmd, i);
- }
- return i;
-}
-
-void
-systemCreateHoloshell(void)
-{
- if (OnVTY && RunningAsInit) {
-
- if (ehs_pid != 0) {
- int pstat;
-
- if (kill(ehs_pid, 0) == 0) {
-
- if (msgYesNo("There seems to be an emergency holographic shell\n"
- "already running on VTY 4.\n\n"
- "Kill it and start a new one?"))
- return;
-
- /* try cleaning up as much as possible */
- (void) kill(ehs_pid, SIGHUP);
- sleep(1);
- (void) kill(ehs_pid, SIGKILL);
- }
-
- /* avoid too many zombies */
- (void) waitpid(ehs_pid, &pstat, WNOHANG);
- }
-
- if ((ehs_pid = fork()) == 0) {
- int i, fd;
- struct termios foo;
- extern int login_tty(int);
-
- ioctl(0, TIOCNOTTY, NULL);
- for (i = getdtablesize(); i >= 0; --i)
- close(i);
- fd = open("/dev/ttyv3", O_RDWR);
- ioctl(0, TIOCSCTTY, &fd);
- dup2(0, 1);
- dup2(0, 2);
- DebugFD = 2;
- if (login_tty(fd) == -1)
- msgDebug("Doctor: I can't set the controlling terminal.\n");
- signal(SIGTTOU, SIG_IGN);
- if (tcgetattr(fd, &foo) != -1) {
- foo.c_cc[VERASE] = '\010';
- if (tcsetattr(fd, TCSANOW, &foo) == -1)
- msgDebug("Doctor: I'm unable to set the erase character.\n");
- }
- else
- msgDebug("Doctor: I'm unable to get the terminal attributes!\n");
- execlp("sh", "-sh", 0);
- msgDebug("Was unable to execute sh for Holographic shell!\n");
- exit(1);
- }
- else {
- WINDOW *w = savescr();
-
- msgNotify("Starting an emergency holographic shell on VTY4");
- sleep(2);
- restorescr(w);
- }
- }
-}
diff --git a/usr.sbin/sysinstall/tape.c b/usr.sbin/sysinstall/tape.c
deleted file mode 100644
index 256fe953bf03..000000000000
--- a/usr.sbin/sysinstall/tape.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last attempt in the `sysinstall' line, the next
- * generation being slated to essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 routines deal with getting things off of tape media */
-
-#include "sysinstall.h"
-#include <sys/fcntl.h>
-#include <sys/param.h>
-
-static Boolean tapeInitted;
-
-char *
-mediaTapeBlocksize(void)
-{
- char *cp = variable_get(VAR_TAPE_BLOCKSIZE);
-
- return cp ? cp : DEFAULT_TAPE_BLOCKSIZE;
-}
-
-Boolean
-mediaInitTape(Device *dev)
-{
- /* This is REALLY gross, but we need to do the init later in get due to the fact
- * that media is initialized BEFORE a filesystem is mounted now.
- */
- return TRUE;
-}
-
-FILE *
-mediaGetTape(Device *dev, char *file, Boolean probe)
-{
- char buf[PATH_MAX];
- FILE *fp;
-
- int i;
-
- if (!tapeInitted) {
- WINDOW *w = savescr();
-
- msgDebug("Tape init routine called for %s (private dir is %s)\n", dev->name, dev->private);
- Mkdir(dev->private);
- if (chdir(dev->private)) {
- msgConfirm("Unable to CD to %s before extracting tape!\n"
- "Tape media is not selected and thus cannot be installed from.", dev->private);
- return (FILE *)IO_ERROR;
- }
- /* We know the tape is already in the drive, so go for it */
- msgNotify("First extracting distributions from %s...", dev->description);
- if (!strcmp(dev->name, "rft0"))
- i = vsystem("ft | cpio -idum %s --block-size %s", cpioVerbosity(), mediaTapeBlocksize());
- else
- i = vsystem("cpio -idum %s --block-size %s -I %s", cpioVerbosity(), mediaTapeBlocksize(), dev->devname);
- if (!i) {
- tapeInitted = TRUE;
- msgDebug("Tape initialized successfully.\n");
- }
- else {
- msgConfirm("Tape extract command failed with status %d!\n"
- "Unable to use tape media.", i);
- restorescr(w);
- return (FILE *)IO_ERROR;
- }
- restorescr(w);
- }
-
- sprintf(buf, "%s/%s", (char *)dev->private, file);
- if (isDebug())
- msgDebug("Request for %s from tape (looking in %s)\n", file, buf);
- if (file_readable(buf))
- fp = fopen(buf, "r");
- else {
- sprintf(buf, "%s/releases/%s", (char *)dev->private, file);
- fp = fopen(buf, "r");
- }
- /* Nuke the files behind us to save space */
- if (fp)
- unlink(buf);
- return fp;
-}
-
-void
-mediaShutdownTape(Device *dev)
-{
- if (!tapeInitted)
- return;
- if (file_readable((char *)dev->private)) {
- msgDebug("Cleaning up results of tape extract in %s..",
- (char *)dev->private);
- (void)vsystem("rm -rf %s", (char *)dev->private);
- }
- tapeInitted = FALSE;
-}
diff --git a/usr.sbin/sysinstall/tcpip.c b/usr.sbin/sysinstall/tcpip.c
deleted file mode 100644
index 1d4609a80c26..000000000000
--- a/usr.sbin/sysinstall/tcpip.c
+++ /dev/null
@@ -1,488 +0,0 @@
-/*
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Gary J Palmer. All rights reserved.
- * Copyright (c) 1996
- * Jordan K. Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 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, LIFE 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.
- *
- */
-
-/*
- * All kinds of hacking also performed by jkh on this code. Don't
- * blame Gary for every bogosity you see here.. :-)
- *
- * -jkh
- */
-
-#include "sysinstall.h"
-#include <sys/param.h>
-#include <netdb.h>
-
-/* The help file for the TCP/IP setup screen */
-#define TCP_HELPFILE "tcp"
-
-/* These are nasty, but they make the layout structure a lot easier ... */
-
-static char hostname[HOSTNAME_FIELD_LEN], domainname[HOSTNAME_FIELD_LEN],
- gateway[IPADDR_FIELD_LEN], nameserver[IPADDR_FIELD_LEN];
-static int okbutton, cancelbutton;
-static char ipaddr[IPADDR_FIELD_LEN], netmask[IPADDR_FIELD_LEN], extras[EXTRAS_FIELD_LEN];
-
-/* What the screen size is meant to be */
-#define TCP_DIALOG_Y 0
-#define TCP_DIALOG_X 8
-#define TCP_DIALOG_WIDTH COLS - 16
-#define TCP_DIALOG_HEIGHT LINES - 2
-
-static Layout layout[] = {
-#define LAYOUT_HOSTNAME 0
- { 1, 2, 25, HOSTNAME_FIELD_LEN - 1,
- "Host:", "Your fully-qualified hostname, e.g. foo.bar.com",
- hostname, STRINGOBJ, NULL },
-#define LAYOUT_DOMAINNAME 1
- { 1, 35, 20, HOSTNAME_FIELD_LEN - 1,
- "Domain:",
- "The name of the domain that your machine is in, e.g. bar.com",
- domainname, STRINGOBJ, NULL },
-#define LAYOUT_GATEWAY 2
- { 5, 2, 18, IPADDR_FIELD_LEN - 1,
- "Gateway:",
- "IP address of host forwarding packets to non-local destinations",
- gateway, STRINGOBJ, NULL },
-#define LAYOUT_NAMESERVER 3
- { 5, 35, 18, IPADDR_FIELD_LEN - 1,
- "Name server:", "IP address of your local DNS server",
- nameserver, STRINGOBJ, NULL },
-#define LAYOUT_IPADDR 4
- { 10, 10, 18, IPADDR_FIELD_LEN - 1,
- "IP Address:",
- "The IP address to be used for this interface",
- ipaddr, STRINGOBJ, NULL },
-#define LAYOUT_NETMASK 5
- { 10, 35, 18, IPADDR_FIELD_LEN - 1,
- "Netmask:",
- "The netmask for this interface, e.g. 0xffffff00 for a class C network",
- netmask, STRINGOBJ, NULL },
-#define LAYOUT_EXTRAS 6
- { 14, 10, 37, HOSTNAME_FIELD_LEN - 1,
- "Extra options to ifconfig:",
- "Any interface-specific options to ifconfig you would like to add",
- extras, STRINGOBJ, NULL },
-#define LAYOUT_OKBUTTON 7
- { 19, 15, 0, 0,
- "OK", "Select this if you are happy with these settings",
- &okbutton, BUTTONOBJ, NULL },
-#define LAYOUT_CANCELBUTTON 8
- { 19, 35, 0, 0,
- "CANCEL", "Select this if you wish to cancel this screen",
- &cancelbutton, BUTTONOBJ, NULL },
- { NULL },
-};
-
-#define _validByte(b) ((b) >= 0 && (b) <= 255)
-
-/* whine */
-static void
-feepout(char *msg)
-{
- beep();
- msgConfirm(msg);
-}
-
-/* Very basic IP address integrity check - could be drastically improved */
-static int
-verifyIP(char *ip)
-{
- int a, b, c, d;
-
- if (ip && sscanf(ip, "%d.%d.%d.%d", &a, &b, &c, &d) == 4 &&
- _validByte(a) && _validByte(b) && _validByte(c) &&
- _validByte(d) && (d != 255))
- return 1;
- else
- return 0;
-}
-
-/* Check for the settings on the screen - the per-interface stuff is
- moved to the main handling code now to do it on the fly - sigh */
-static int
-verifySettings(void)
-{
- if (!hostname[0])
- feepout("Must specify a host name of some sort!");
- else if (gateway[0] && strcmp(gateway, "NO") && !verifyIP(gateway))
- feepout("Invalid gateway IP address specified");
- else if (nameserver[0] && !verifyIP(nameserver))
- feepout("Invalid name server IP address specified");
- else if (netmask[0] && (netmask[0] < '0' && netmask[0] > '3'))
- feepout("Invalid netmask value");
- else if (ipaddr[0] && !verifyIP(ipaddr))
- feepout("Invalid IP address");
- else
- return 1;
- return 0;
-}
-
-static void
-dhcpGetInfo(Device *devp)
-{
- /* If it fails, do it the old-fashioned way */
- if (dhcpParseLeases("/var/db/dhclient.leases", hostname, domainname,
- nameserver, ipaddr, gateway, netmask) == -1) {
- FILE *ifp;
- char *cp, cmd[256], data[2048];
- int i, j;
-
- /* Bah, now we have to kludge getting the information from ifconfig */
- snprintf(cmd, sizeof cmd, "ifconfig %s", devp->name);
- ifp = popen(cmd, "r");
- if (ifp) {
- j = fread(data, 1, sizeof(data), ifp);
- fclose(ifp);
- if (j < 0) /* paranoia */
- j = 0;
- data[j] = '\0';
- if (isDebug())
- msgDebug("DHCP configured interface returns %s\n", data);
- /* XXX This is gross as it assumes a certain ordering to
- ifconfig's output! XXX */
- if ((cp = strstr(data, "inet")) != NULL) {
- i = 0;
- cp += 5; /* move over keyword */
- while (*cp != ' ')
- ipaddr[i++] = *(cp++);
- ipaddr[i] = '\0';
- if (!strncmp(++cp, "netmask", 7)) {
- i = 0;
- cp += 8;
- while (*cp != ' ')
- netmask[i++] = *(cp++);
- netmask[i] = '\0';
- }
- }
- }
- }
-
- /* If we didn't get a name server value, hunt for it in resolv.conf */
- if (!nameserver[0] && file_readable("/etc/resolv.conf"))
- configEnvironmentResolv("/etc/resolv.conf");
- if (hostname[0])
- variable_set2(VAR_HOSTNAME, hostname, 0);
-}
-
-/* This is it - how to get TCP setup values */
-int
-tcpOpenDialog(Device *devp)
-{
- WINDOW *ds_win, *save = NULL;
- ComposeObj *obj = NULL;
- int n = 0, filled = 0, cancel = FALSE;
- int max, ret = DITEM_SUCCESS;
- int use_dhcp = FALSE;
- char *tmp;
- char title[80];
-
- save = savescr();
- /* Initialise vars from previous device values */
- if (devp->private) {
- DevInfo *di = (DevInfo *)devp->private;
-
- SAFE_STRCPY(ipaddr, di->ipaddr);
- SAFE_STRCPY(netmask, di->netmask);
- SAFE_STRCPY(extras, di->extras);
- use_dhcp = di->use_dhcp;
- }
- else { /* See if there are any defaults */
- char *cp;
-
- /* First try a DHCP scan if such behavior is desired */
- if (!variable_cmp(VAR_TRY_DHCP, "YES") || !msgYesNo("Do you want to try DHCP configuration of the interface?")) {
- Mkdir("/var/db");
- Mkdir("/var/run");
- Mkdir("/tmp");
- msgNotify("Scanning for DHCP servers...");
- if (0 == vsystem("dhclient -1 %s", devp->name)) {
- dhcpGetInfo(devp);
- use_dhcp = TRUE;
- }
- else
- use_dhcp = FALSE;
- }
-
- /* Special hack so it doesn't show up oddly in the tcpip setup menu */
- if (!strcmp(gateway, "NO"))
- gateway[0] = '\0';
-
- /* Get old IP address from variable space, if available */
- if (!ipaddr[0]) {
- if ((cp = variable_get(VAR_IPADDR)) != NULL)
- SAFE_STRCPY(ipaddr, cp);
- else if ((cp = variable_get(string_concat3(devp->name, "_", VAR_IPADDR))) != NULL)
- SAFE_STRCPY(ipaddr, cp);
- }
-
- /* Get old netmask from variable space, if available */
- if (!netmask[0]) {
- if ((cp = variable_get(VAR_NETMASK)) != NULL)
- SAFE_STRCPY(netmask, cp);
- else if ((cp = variable_get(string_concat3(devp->name, "_", VAR_NETMASK))) != NULL)
- SAFE_STRCPY(netmask, cp);
- }
-
- /* Get old extras string from variable space, if available */
- if (!extras[0]) {
- if ((cp = variable_get(VAR_EXTRAS)) != NULL)
- SAFE_STRCPY(extras, cp);
- else if ((cp = variable_get(string_concat3(devp->name, "_", VAR_EXTRAS))) != NULL)
- SAFE_STRCPY(extras, cp);
- }
- }
-
- /* Look up values already recorded with the system, or blank the string variables ready to accept some new data */
- if (!hostname[0]) {
- tmp = variable_get(VAR_HOSTNAME);
- if (tmp)
- SAFE_STRCPY(hostname, tmp);
- }
- if (!domainname[0]) {
- tmp = variable_get(VAR_DOMAINNAME);
- if (tmp)
- SAFE_STRCPY(domainname, tmp);
- }
- if (!gateway[0]) {
- tmp = variable_get(VAR_GATEWAY);
- if (tmp && strcmp(tmp, "NO"))
- SAFE_STRCPY(gateway, tmp);
- }
- if (!nameserver[0]) {
- tmp = variable_get(VAR_NAMESERVER);
- if (tmp)
- SAFE_STRCPY(nameserver, tmp);
- }
-
- /* If non-interactive, jump straight over the dialog crap and into config section */
- if (variable_get(VAR_NONINTERACTIVE) &&
- !variable_get(VAR_NETINTERACTIVE)) {
- if (!hostname[0])
- msgConfirm("WARNING: hostname variable not set and is a non-optional\n"
- "parameter. Please add this to your installation script\n"
- "or set the netInteractive variable (see sysinstall man page)");
- else
- goto netconfig;
- }
-
- /* Now do all the screen I/O */
- dialog_clear_norefresh();
-
- /* We need a curses window */
- if (!(ds_win = openLayoutDialog(TCP_HELPFILE, " Network Configuration ",
- TCP_DIALOG_X, TCP_DIALOG_Y, TCP_DIALOG_WIDTH, TCP_DIALOG_HEIGHT))) {
- beep();
- msgConfirm("Cannot open TCP/IP dialog window!!");
- restorescr(save);
- return DITEM_FAILURE;
- }
-
- /* Draw interface configuration box */
- draw_box(ds_win, TCP_DIALOG_Y + 9, TCP_DIALOG_X + 8, TCP_DIALOG_HEIGHT - 13, TCP_DIALOG_WIDTH - 17,
- dialog_attr, border_attr);
- wattrset(ds_win, dialog_attr);
- sprintf(title, " Configuration for Interface %s ", devp->name);
- mvwaddstr(ds_win, TCP_DIALOG_Y + 9, TCP_DIALOG_X + 14, title);
-
- /* Some more initialisation before we go into the main input loop */
- obj = initLayoutDialog(ds_win, layout, TCP_DIALOG_X, TCP_DIALOG_Y, &max);
-
-reenter:
- cancelbutton = okbutton = 0;
- while (layoutDialogLoop(ds_win, layout, &obj, &n, max, &cancelbutton, &cancel)) {
- /* Prevent this from being irritating if user really means NO */
- if (filled < 3) {
- /* Insert a default value for the netmask, 0xffffff00 is
- * the most appropriate one (entire class C, or subnetted
- * class A/B network).
- */
- if (!netmask[0]) {
- strcpy(netmask, "255.255.255.0");
- RefreshStringObj(layout[LAYOUT_NETMASK].obj);
- ++filled;
- }
- if (!index(hostname, '.') && domainname[0]) {
- strcat(hostname, ".");
- strcat(hostname, domainname);
- RefreshStringObj(layout[LAYOUT_HOSTNAME].obj);
- ++filled;
- }
- else if (((tmp = index(hostname, '.')) != NULL) && !domainname[0]) {
- SAFE_STRCPY(domainname, tmp + 1);
- RefreshStringObj(layout[LAYOUT_DOMAINNAME].obj);
- ++filled;
- }
- }
- }
- if (!cancel && !verifySettings())
- goto reenter;
-
- /* Clear this crap off the screen */
- delwin(ds_win);
- dialog_clear_norefresh();
- use_helpfile(NULL);
-
- /* We actually need to inform the rest of sysinstall about this
- data now if the user hasn't selected cancel. Save the stuff
- out to the environment via the variable_set() mechanism */
-
-netconfig:
- if (!cancel) {
- DevInfo *di;
- char temp[512], ifn[255];
- char *ifaces;
- char *pccard;
-
- if (hostname[0]) {
- variable_set2(VAR_HOSTNAME, hostname, 1);
- sethostname(hostname, strlen(hostname));
- }
- if (domainname[0])
- variable_set2(VAR_DOMAINNAME, domainname, 0);
- if (gateway[0])
- variable_set2(VAR_GATEWAY, gateway, use_dhcp ? 0 : 1);
- if (nameserver[0])
- variable_set2(VAR_NAMESERVER, nameserver, 0);
- if (ipaddr[0])
- variable_set2(VAR_IPADDR, ipaddr, 0);
-
- if (!devp->private)
- devp->private = (DevInfo *)safe_malloc(sizeof(DevInfo));
- di = devp->private;
- SAFE_STRCPY(di->ipaddr, ipaddr);
- SAFE_STRCPY(di->netmask, netmask);
- SAFE_STRCPY(di->extras, extras);
- di->use_dhcp = use_dhcp;
-
- sprintf(ifn, "%s%s", VAR_IFCONFIG, devp->name);
- if (use_dhcp)
- sprintf(temp, "DHCP");
- else
- sprintf(temp, "inet %s %s netmask %s", ipaddr, extras, netmask);
- variable_set2(ifn, temp, 1);
- pccard = variable_get("_pccard_install");
- if (pccard && strcmp(pccard, "YES") == 0) {
- variable_set2("pccard_ifconfig", temp, 1);
- }
- ifaces = variable_get(VAR_INTERFACES);
- if (!ifaces)
- variable_set2(VAR_INTERFACES, ifaces = "lo0", 1);
- /* Only add it if it's not there already */
- if (strcmp(ifaces, "auto") && !strstr(ifaces, devp->name)) {
- sprintf(ifn, "%s %s", devp->name, ifaces);
- variable_set2(VAR_INTERFACES, ifn, 1);
- }
- if (!use_dhcp)
- configResolv(NULL); /* XXX this will do it on the MFS copy XXX */
- ret = DITEM_SUCCESS;
- }
- else
- ret = DITEM_FAILURE;
- restorescr(save);
- return ret;
-}
-
-static Device *NetDev;
-
-static int
-netHook(dialogMenuItem *self)
-{
- Device **devs;
-
- devs = deviceFindDescr(self->prompt, self->title, DEVICE_TYPE_NETWORK);
- if (devs) {
- if (DITEM_STATUS(tcpOpenDialog(devs[0])) != DITEM_FAILURE)
- NetDev = devs[0];
- else
- NetDev = NULL;
- }
- return devs ? DITEM_LEAVE_MENU : DITEM_FAILURE;
-}
-
-/* Get a network device */
-Device *
-tcpDeviceSelect(void)
-{
- DMenu *menu;
- Device **devs, *rval;
- int cnt;
-
- devs = deviceFind(NULL, DEVICE_TYPE_NETWORK);
- cnt = deviceCount(devs);
- rval = NULL;
-
- if (!cnt) {
- msgConfirm("No network devices available!");
- return NULL;
- }
- else if (!RunningAsInit) {
- if (!msgYesNo("Running multi-user, assume that the network is already configured?"))
- return devs[0];
- }
- if (cnt == 1) {
- if (DITEM_STATUS(tcpOpenDialog(devs[0]) == DITEM_SUCCESS))
- rval = devs[0];
- }
- else if (variable_get(VAR_NONINTERACTIVE) && variable_get(VAR_NETWORK_DEVICE)) {
- devs = deviceFind(variable_get(VAR_NETWORK_DEVICE), DEVICE_TYPE_NETWORK);
- cnt = deviceCount(devs);
- if (cnt) {
- if (DITEM_STATUS(tcpOpenDialog(devs[0]) == DITEM_SUCCESS))
- rval = devs[0];
- }
- }
- else {
- int status;
-
- menu = deviceCreateMenu(&MenuNetworkDevice, DEVICE_TYPE_NETWORK, netHook, NULL);
- if (!menu)
- msgFatal("Unable to create network device menu! Argh!");
- status = dmenuOpenSimple(menu, FALSE);
- free(menu);
- if (status)
- rval = NetDev;
- }
- return rval;
-}
-
-/* Do it from a menu that doesn't care about status */
-int
-tcpMenuSelect(dialogMenuItem *self)
-{
- Device *tmp;
-
- tmp = tcpDeviceSelect();
- if (tmp && tmp->private && !((DevInfo *)tmp->private)->use_dhcp && !msgYesNo("Would you like to bring the %s interface up right now?", tmp->name))
- if (!tmp->init(tmp))
- msgConfirm("Initialization of %s device failed.", tmp->name);
- return DITEM_SUCCESS;
-}
diff --git a/usr.sbin/sysinstall/termcap.c b/usr.sbin/sysinstall/termcap.c
deleted file mode 100644
index 15694790c91d..000000000000
--- a/usr.sbin/sysinstall/termcap.c
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (c) 1994, Paul Richards.
- *
- * All rights reserved.
- *
- * This software may be used, modified, copied, distributed, and sold, in both
- * source and binary form provided that the above copyright and these terms
- * are retained, verbatim, as the first lines of this file. Under no
- * circumstances is the author responsible for the proper functioning of this
- * software, nor does the author assume any responsibility for damages
- * incurred with its use.
- */
-
-#include "sysinstall.h"
-#include <stdarg.h>
-#include <fcntl.h>
-#include <sys/errno.h>
-#include <sys/ioctl.h>
-#include <machine/console.h>
-
-#define VTY_STATUS_LINE 24
-#define TTY_STATUS_LINE 23
-
-static void
-prompt_term(char **termp, char **termcapp)
-{
- char str[80];
- static struct {
- const char *term, *termcap;
- } lookup[] = { { "ansi", termcap_ansi },
- { "vt100", termcap_vt100 },
- { "cons25", termcap_cons25 },
- { "cons25-m", termcap_cons25_m } };
-
- if (RunningAsInit) {
- while (1) {
- int i;
-
- printf("\nThese are the predefined terminal types available to\n");
- printf("sysinstall when running stand-alone. Please choose the\n");
- printf("closest match for your particular terminal.\n\n");
- printf("1 ...................... Standard ANSI terminal.\n");
- printf("2 ...................... VT100 or compatible terminal.\n");
- printf("3 ...................... FreeBSD system console (color).\n");
- printf("4 ...................... FreeBSD system console (monochrome).\n\n");
- printf("Your choice: (1-4) ");
- fflush(stdout);
- fgets(str, 80, stdin);
- i = str[0] - '0';
- if (i > 0 && i < 5) {
- *termp = (char *)lookup[i - 1].term;
- *termcapp = (char *)lookup[i - 1].termcap;
- break;
- }
- else
- printf("\007Invalid choice, please try again.\n\n");
- }
- }
- else {
- printf("\nPlease set your TERM variable before running this program.\n");
- printf("Defaulting to an ANSI compatible terminal - please press RETURN\n");
- fgets(str, 80, stdin); /* Just to make it interactive */
- *termp = (char *)"ansi";
- *termcapp = (char *)termcap_ansi;
- }
-}
-
-int
-set_termcap(void)
-{
- char *term;
- int stat;
- struct ttysize ts;
-
- term = getenv("TERM");
- stat = ioctl(STDERR_FILENO, GIO_COLOR, &ColorDisplay);
-
- if (!RunningAsInit) {
- if (getenv("SYSINSTALL_DEBUG"))
- DebugFD = open("sysinstall.debug", O_WRONLY|O_CREAT|O_TRUNC, 0644);
- else
- DebugFD = -1;
- if (DebugFD < 0)
- DebugFD = open("/dev/null", O_RDWR, 0);
- }
-
- if (!OnVTY || (stat < 0)) {
- if (!term) {
- char *term, *termcap;
-
- prompt_term(&term, &termcap);
- if (setenv("TERM", term, 1) < 0)
- return -1;
- if (setenv("TERMCAP", termcap, 1) < 0)
- return -1;
- }
- if (DebugFD < 0)
- DebugFD = open("/dev/null", O_RDWR, 0);
- }
- else {
- int i, on;
-
- if (getpid() == 1) {
- DebugFD = open("/dev/ttyv1", O_WRONLY);
- if (DebugFD != -1) {
- on = 1;
- i = ioctl(DebugFD, TIOCCONS, (char *)&on);
- msgDebug("ioctl(%d, TIOCCONS, NULL) = %d (%s)\n",
- DebugFD, i, !i ? "success" : strerror(errno));
- }
- }
- if (ColorDisplay) {
- if (!term) {
- if (setenv("TERM", "cons25", 1) < 0)
- return -1;
- if (setenv("TERMCAP", termcap_cons25, 1) < 0)
- return -1;
- }
- }
- else {
- if (!term) {
- if (setenv("TERM", "cons25-m", 1) < 0)
- return -1;
- if (setenv("TERMCAP", termcap_cons25_m, 1) < 0)
- return -1;
- }
- }
- }
- if (ioctl(0, TIOCGSIZE, &ts) == -1) {
- msgDebug("Unable to get terminal size - errno %d\n", errno);
- ts.ts_lines = 0;
- }
- StatusLine = ts.ts_lines ? ts.ts_lines - 1: (OnVTY ? VTY_STATUS_LINE : TTY_STATUS_LINE);
- return 0;
-}
diff --git a/usr.sbin/sysinstall/ufs.c b/usr.sbin/sysinstall/ufs.c
deleted file mode 100644
index c9515ae82b28..000000000000
--- a/usr.sbin/sysinstall/ufs.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last attempt in the `sysinstall' line, the next
- * generation being slated to essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. All rights reserved.
- * Copyright (c) 1995
- * Gary J Palmer. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 "sysinstall.h"
-#include <sys/fcntl.h>
-#include <sys/param.h>
-
-/* No init or shutdown routines necessary - all done in mediaSetUFS() */
-
-FILE *
-mediaGetUFS(Device *dev, char *file, Boolean probe)
-{
- return mediaGenericGet((char *)dev->private, file);
-}
diff --git a/usr.sbin/sysinstall/user.c b/usr.sbin/sysinstall/user.c
deleted file mode 100644
index 372d3fb7aaf8..000000000000
--- a/usr.sbin/sysinstall/user.c
+++ /dev/null
@@ -1,727 +0,0 @@
-/*
- * $FreeBSD$
- *
- * Copyright (c) 1996
- * Jörg Wunsch. All rights reserved.
- *
- * The basic structure has been taken from tcpip.c, which is:
- *
- * Copyright (c) 1995
- * Gary J Palmer. All rights reserved.
- * Jordan K Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 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, LIFE 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 "sysinstall.h"
-#include <utmp.h>
-#include <ctype.h>
-#include <sys/param.h>
-#include <sysexits.h>
-
-/* The help file for the user mgmt screen */
-#define USER_HELPFILE "usermgmt"
-
-/* XXX should they be moved out to sysinstall.h? */
-#define GNAME_FIELD_LEN 32
-#define GID_FIELD_LEN 10
-#define GMEMB_FIELD_LEN 64
-
-#define UID_FIELD_LEN 10
-#define UGROUP_FIELD_LEN GNAME_FIELD_LEN
-#define GECOS_FIELD_LEN 64
-#define UMEMB_FIELD_LEN GMEMB_FIELD_LEN
-#define HOMEDIR_FIELD_LEN 48
-#define SHELL_FIELD_LEN 48
-#define PASSWD_FIELD_LEN 32
-
-/* These are nasty, but they make the layout structure a lot easier ... */
-
-static char gname[GNAME_FIELD_LEN],
- gid[GID_FIELD_LEN],
- gmemb[GMEMB_FIELD_LEN],
- uname[UT_NAMESIZE + 1],
- passwd[PASSWD_FIELD_LEN],
- uid[UID_FIELD_LEN],
- ugroup[UGROUP_FIELD_LEN],
- gecos[GECOS_FIELD_LEN],
- umemb[UMEMB_FIELD_LEN],
- homedir[HOMEDIR_FIELD_LEN],
- shell[SHELL_FIELD_LEN];
-#define CLEAR(v) memset(v, 0, sizeof v)
-
-static int okbutton, cancelbutton;
-
-
-/* What the screen size is meant to be */
-#define USER_DIALOG_Y 0
-#define USER_DIALOG_X 8
-#define USER_DIALOG_WIDTH COLS - 16
-#define USER_DIALOG_HEIGHT LINES - 2
-
-/* The group configuration menu. */
-static Layout groupLayout[] = {
-#define LAYOUT_GNAME 0
- { 4, 10, 20, GNAME_FIELD_LEN - 1,
- "Group name:", "The alphanumeric name of the new group (mandatory)",
- gname, STRINGOBJ, NULL },
-#define LAYOUT_GID 1
- { 4, 38, 10, GID_FIELD_LEN - 1,
- "GID:", "The numerical ID for this group (leave blank for automatic choice)",
- gid, STRINGOBJ, NULL },
-#define LAYOUT_GMEMB 2
- { 11, 10, 40, GMEMB_FIELD_LEN - 1,
- "Group members:", "Who belongs to this group (i.e., gets access rights for it)",
- gmemb, STRINGOBJ, NULL },
-#define LAYOUT_OKBUTTON 3
- { 18, 15, 0, 0,
- "OK", "Select this if you are happy with these settings",
- &okbutton, BUTTONOBJ, NULL },
-#define LAYOUT_CANCELBUTTON 4
- { 18, 35, 0, 0,
- "CANCEL", "Select this if you wish to cancel this screen",
- &cancelbutton, BUTTONOBJ, NULL },
- { NULL },
-};
-
-/* The user configuration menu. */
-static Layout userLayout[] = {
-#define LAYOUT_UNAME 0
- { 3, 6, UT_NAMESIZE, UT_NAMESIZE + 1,
- "Login ID:", "The login name of the new user (mandatory)",
- uname, STRINGOBJ, NULL },
-#define LAYOUT_UID 1
- { 3, 23, 8, UID_FIELD_LEN - 1,
- "UID:", "The numerical ID for this user (leave blank for automatic choice)",
- uid, STRINGOBJ, NULL },
-#define LAYOUT_UGROUP 2
- { 3, 33, 8, UGROUP_FIELD_LEN - 1,
- "Group:", "The login group name for this user (leave blank for automatic choice)",
- ugroup, STRINGOBJ, NULL },
-#define LAYOUT_PASSWD 3
- { 3, 43, 15, PASSWD_FIELD_LEN - 1,
- "Password:", "The password for this user (enter this field with care!)",
- passwd, NO_ECHO_OBJ(STRINGOBJ), NULL },
-#define LAYOUT_GECOS 4
- { 8, 6, 33, GECOS_FIELD_LEN - 1,
- "Full name:", "The user's full name (comment)",
- gecos, STRINGOBJ, NULL },
-#define LAYOUT_UMEMB 5
- { 8, 43, 15, UMEMB_FIELD_LEN - 1,
- "Member groups:", "The groups this user belongs to (i.e. gets access rights for)",
- umemb, STRINGOBJ, NULL },
-#define LAYOUT_HOMEDIR 6
- { 13, 6, 20, HOMEDIR_FIELD_LEN - 1,
- "Home directory:", "The user's home directory (leave blank for default)",
- homedir, STRINGOBJ, NULL },
-#define LAYOUT_SHELL 7
- { 13, 29, 29, SHELL_FIELD_LEN - 1,
- "Login shell:", "The user's login shell (leave blank for default)",
- shell, STRINGOBJ, NULL },
-#define LAYOUT_U_OKBUTTON 8
- { 18, 15, 0, 0,
- "OK", "Select this if you are happy with these settings",
- &okbutton, BUTTONOBJ, NULL },
-#define LAYOUT_U_CANCELBUTTON 9
- { 18, 35, 0, 0,
- "CANCEL", "Select this if you wish to cancel this screen",
- &cancelbutton, BUTTONOBJ, NULL },
- { NULL },
-};
-
-/* whine */
-static void
-feepout(char *msg)
-{
- beep();
- dialog_notify(msg);
-}
-
-/* Check for the settings on the screen. */
-
-static int
-verifyGroupSettings(void)
-{
- char tmp[256], *cp;
- long lgid;
-
- if (strlen(gname) == 0) {
- feepout("The group name field must not be empty!");
- return 0;
- }
- snprintf(tmp, 256, "pw group show -q -n %s > /dev/null", gname);
- if (vsystem(tmp) == 0) {
- feepout("This group name is already in use.");
- return 0;
- }
- if (strlen(gid) > 0) {
- lgid = strtol(gid, &cp, 10);
- if (lgid < 0 || lgid >= 65536 || (*cp != '\0' && !isspace(*cp))) {
- feepout("The GID must be a number between 1 and 65535.");
- return 0;
- }
- }
- if (strlen(gmemb) > 0) {
- if (strpbrk(gmemb, " \t") != NULL) {
- feepout("The group member list must not contain any whitespace;\n"
- "use commas to separate the names.");
- return 0;
- }
-#ifndef notyet /* XXX */
- feepout("Sorry, the group member list feature\n"
- "is currently not yet implemented.");
- return 0;
-#endif
- }
-
- return 1;
-}
-
-/*
- * Ask pw(8) to fill in the blanks for us.
- * Works solely on the global variables.
- */
-
-static void
-completeGroup(void)
-{
- int pfd[2], i;
- char tmp[256], *cp;
- ssize_t l;
- size_t amnt;
- pid_t pid;
- char *vec[4] =
- {
- "pw", "group", "next", 0
- };
-
- pipe (pfd);
- if ((pid = fork()) == 0)
- {
- /* The kiddy. */
- dup2(pfd[1], 1);
- dup2(pfd[1], 2);
- for (i = getdtablesize(); i > 2; i--)
- close(i);
-
- execv("/usr/sbin/pw", vec);
- msgDebug("Cannot execv() /usr/sbin/pw.\n");
- _exit(99);
- }
- else
- {
- /* The oldie. */
- close(pfd[1]);
- amnt = sizeof tmp;
- i = 0;
- while((l = read(pfd[0], &tmp[i], amnt)) > 0)
- {
- amnt -= l;
- i += l;
- if (amnt == 0)
- {
- close(pfd[0]);
- break;
- }
- }
- close(pfd[0]);
- tmp[i] = '\0';
- waitpid(pid, &i, 0);
- if (WIFSIGNALED(i) || WEXITSTATUS(i) != 0)
- /* ignore by now */
- return;
- if ((cp = strchr(tmp, '\n')) != NULL)
- *cp = '\0';
- strncpy(gid, tmp, sizeof gid);
- }
-}
-
-static void
-addGroup(WINDOW *ds_win)
-{
- char tmp[256];
- int pfd[2], i;
- ssize_t l;
- size_t amnt;
- pid_t pid;
- char *vec[8] =
- {
- "pw", "group", "add", "-n", 0, "-g", 0, 0
- };
-#define VEC_GNAME 4
-#define VEC_GID 6
-
- msgNotify("Adding group \"%s\"...", gname);
-
- pipe (pfd);
- if ((pid = fork()) == 0)
- {
- /* The kiddy. */
- dup2(pfd[1], 1);
- dup2(pfd[1], 2);
- for (i = getdtablesize(); i > 2; i--)
- close(i);
-
- vec[VEC_GNAME] = gname;
-
- if (strlen(gid) > 0)
- vec[VEC_GID] = gid;
- else
- vec[VEC_GID - 1] = 0;
-
- execv("/usr/sbin/pw", vec);
- msgDebug("Cannot execv() /usr/sbin/pw.\n");
- _exit(99);
- }
- else
- {
- /* The oldie. */
- close(pfd[1]);
- amnt = sizeof tmp;
- i = 0;
- while((l = read(pfd[0], &tmp[i], amnt)) > 0)
- {
- amnt -= l;
- i += l;
- if (amnt == 0)
- {
- close(pfd[0]);
- break;
- }
- }
- close(pfd[0]);
- tmp[i] = '\0';
- waitpid(pid, &i, 0);
- if (WIFSIGNALED(i))
- msgDebug("pw(8) exited with signal %d.\n", WTERMSIG(i));
- else if(WEXITSTATUS(i))
- {
- i = 0;
- if(strncmp(tmp, "pw: ", 4) == 0)
- i = 4;
- tmp[sizeof tmp - 1] = '\0'; /* sanity */
- msgConfirm("The `pw' command exited with an error status.\n"
- "Its error message was:\n\n%s",
- &tmp[i]);
- }
- }
-#undef VEC_GNAME
-#undef VEC_GID
-}
-
-int
-userAddGroup(dialogMenuItem *self)
-{
- WINDOW *ds_win, *save;
- ComposeObj *obj = NULL;
- int n = 0, cancel = FALSE, ret;
- int max, firsttime = TRUE;
-
- if (RunningAsInit && !strstr(variable_get(SYSTEM_STATE), "install")) {
- msgConfirm("This option may only be used after the system is installed, sorry!");
- return DITEM_FAILURE;
- }
-
- save = savescr();
- dialog_clear_norefresh();
- /* We need a curses window */
- if (!(ds_win = openLayoutDialog(USER_HELPFILE, " User and Group Management ",
- USER_DIALOG_X, USER_DIALOG_Y, USER_DIALOG_WIDTH, USER_DIALOG_HEIGHT))) {
- beep();
- msgConfirm("Cannot open addgroup dialog window!!");
- return(DITEM_FAILURE);
- }
-
- /* Draw a group entry box */
- draw_box(ds_win, USER_DIALOG_Y + 2, USER_DIALOG_X + 8, USER_DIALOG_HEIGHT - 8,
- USER_DIALOG_WIDTH - 17, dialog_attr, border_attr);
- wattrset(ds_win, dialog_attr);
- mvwaddstr(ds_win, USER_DIALOG_Y + 2, USER_DIALOG_X + 22, " Add a new group ");
-
- CLEAR(gname);
- CLEAR(gid);
- CLEAR(gmemb);
-
- /* Some more initialisation before we go into the main input loop */
- obj = initLayoutDialog(ds_win, groupLayout, USER_DIALOG_X, USER_DIALOG_Y, &max);
-
-reenter:
- cancelbutton = okbutton = 0;
- if (firsttime) {
- /* fill in the blanks, well, just the GID */
- completeGroup();
- RefreshStringObj(groupLayout[LAYOUT_GID].obj);
- firsttime = FALSE;
- }
-
- while (layoutDialogLoop(ds_win, groupLayout, &obj, &n, max, &cancelbutton, &cancel));
-
- if (!cancel && !verifyGroupSettings())
- goto reenter;
-
- /* Clear this crap off the screen */
- delwin(ds_win);
- dialog_clear_norefresh();
- use_helpfile(NULL);
-
- if (!cancel) {
- addGroup(ds_win);
- ret = DITEM_SUCCESS;
- }
- else
- ret = DITEM_FAILURE;
- restorescr(save);
- return ret;
-}
-
-/* Check for the settings on the screen. */
-
-static int
-verifyUserSettings(WINDOW *ds_win)
-{
- char tmp[256], *cp;
- long luid;
- WINDOW *save;
- int rv;
-
- if (strlen(uname) == 0) {
- feepout("The user name field must not be empty!");
- return 0;
- }
- snprintf(tmp, 256, "pw user show -q -n %s > /dev/null", uname);
- if (vsystem(tmp) == 0) {
- feepout("This user name is already in use.");
- return 0;
- }
- if (strlen(uid) > 0) {
- luid = strtol(uid, &cp, 10);
- if (luid < 0 || luid >= 65536 || (*cp != '\0' && !isspace(*cp))) {
- feepout("The UID must be a number between 1 and 65535.");
- return 0;
- }
- }
- if (strlen(shell) > 0) {
- while((cp = getusershell()) != NULL)
- if (strcmp(cp, shell) == 0)
- break;
- endusershell();
- if (cp == NULL) {
- save = savescr();
- rv = msgYesNo("Warning:\n\n"
- "The requested shell \"%s\" is not\n"
- "a valid user shell.\n\n"
- "Use it anyway?\n", shell);
- restorescr(save);
- wrefresh(ds_win);
- if (rv != DITEM_SUCCESS)
- return 0;
- }
-
- }
-
- if (strlen(umemb) > 0) {
- if (strpbrk(umemb, " \t") != NULL) {
- feepout("The member groups list must not contain any whitespace;\n"
- "use commas to separate the names.");
- return 0;
- }
- }
-
- return 1;
-}
-
-/*
- * Ask pw(8) to fill in the blanks for us.
- * Works solely on the global variables.
- */
-
-static void
-completeUser(void)
-{
- int pfd[2], i;
- char tmp[256], *cp, *cp2;
- ssize_t l;
- size_t amnt;
- pid_t pid;
- char *vec[7] =
- {
- "pw", "user", "add", "-N", "-n", 0, 0
- };
-#define VEC_UNAME 5
-
- pipe (pfd);
- if ((pid = fork()) == 0)
- {
- /* The kiddy. */
- dup2(pfd[1], 1);
- dup2(pfd[1], 2);
- for (i = getdtablesize(); i > 2; i--)
- close(i);
-
- vec[VEC_UNAME] = uname;
-
- execv("/usr/sbin/pw", vec);
- msgDebug("Cannot execv() /usr/sbin/pw.\n");
- _exit(99);
- }
- else
- {
- /* The oldie. */
- close(pfd[1]);
- amnt = sizeof tmp;
- i = 0;
- while((l = read(pfd[0], &tmp[i], amnt)) > 0)
- {
- amnt -= l;
- i += l;
- if (amnt == 0)
- {
- close(pfd[0]);
- break;
- }
- }
- close(pfd[0]);
- tmp[i] = '\0';
- waitpid(pid, &i, 0);
- if (WIFSIGNALED(i) || WEXITSTATUS(i) != 0)
- /* ignore by now */
- return;
- if ((cp = strchr(tmp, '\n')) != NULL)
- *cp = '\0';
- if ((cp = strchr(tmp, ':')) == NULL || (cp = strchr(++cp, ':')) == NULL)
- return;
- cp++;
- if ((cp2 = strchr(cp, ':')) == NULL)
- return;
- *cp2++ = '\0';
- strncpy(uid, cp, sizeof uid);
- cp = cp2;
- if ((cp2 = strchr(cp, ':')) == NULL)
- return;
- *cp2++ = '\0';
-#ifdef notyet /* XXX pw user add -g doesn't accept a numerical GID */
- strncpy(ugroup, cp, sizeof ugroup);
-#endif
- cp = cp2;
- if ((cp2 = strchr(cp, ':')) == NULL || (cp2 = strchr(++cp2, ':')) == NULL ||
- (cp = cp2 = strchr(++cp2, ':')) == NULL || (cp2 = strchr(++cp2, ':')) == NULL)
- return;
- *cp2++ = '\0';
- cp++;
- strncpy(gecos, cp, sizeof gecos);
- cp = cp2;
- if ((cp2 = strchr(cp, ':')) == NULL)
- return;
- *cp2++ = '\0';
- if (*cp2)
- strncpy(shell, cp2, sizeof shell);
- }
-#undef VEC_UNAME
-}
-
-static void
-addUser(WINDOW *ds_win)
-{
- char tmp[256], *msg;
- int pfd[2], ipfd[2], i, j;
- ssize_t l;
- size_t amnt;
- pid_t pid;
- /*
- * Maximal list:
- * pw user add -m -n uname -g grp -u uid -c comment -d homedir -s shell -G grplist -h 0
- */
- char *vec[21] =
- {
- "pw", "user", "add", "-m", "-n", /* ... */
- };
-#define VEC_UNAME 5
-
- msgNotify("Adding user \"%s\"...", uname);
-
- pipe (pfd);
- pipe (ipfd);
- if ((pid = fork()) == 0)
- {
- /* The kiddy. */
- dup2(ipfd[0], 0);
- dup2(pfd[1], 1);
- dup2(pfd[1], 2);
- for (i = getdtablesize(); i > 2; i--)
- close(i);
-
- vec[i = VEC_UNAME] = uname;
- i++;
-#define ADDVEC(var, option) do { if (strlen(var) > 0) { vec[i++] = option; vec[i++] = var; } } while (0)
- ADDVEC(ugroup, "-g");
- ADDVEC(uid, "-u");
- ADDVEC(gecos, "-c");
- ADDVEC(homedir, "-d");
- ADDVEC(shell, "-s");
- ADDVEC(umemb, "-G");
- if (passwd[0]) {
- vec[i++] = "-h";
- vec[i++] = "0";
- }
- vec[i] = 0;
-
- execv("/usr/sbin/pw", vec);
- msgDebug("Cannot execv() /usr/sbin/pw.\n");
- _exit(99);
- }
- else
- {
- /* The oldie. */
- close(pfd[1]);
- close(ipfd[0]);
-
- if (passwd[0])
- write(ipfd[1], passwd, strlen(passwd));
- close(ipfd[1]);
- amnt = sizeof tmp;
- i = 0;
- while((l = read(pfd[0], &tmp[i], amnt)) > 0)
- {
- amnt -= l;
- i += l;
- if (amnt == 0)
- {
- close(pfd[0]);
- break;
- }
- }
- close(pfd[0]);
- tmp[i] = '\0';
- waitpid(pid, &i, 0);
- if (WIFSIGNALED(i))
- {
- j = WTERMSIG(i);
- msg = "The `pw' command exited with signal %d.\n";
- goto sysfail;
- }
- else if((j = WEXITSTATUS(i)))
- {
- i = 0;
- if(strncmp(tmp, "pw: ", 4) == 0)
- i = 4;
- tmp[sizeof tmp - 1] = '\0'; /* sanity */
- if (j == EX_DATAERR || j == EX_NOUSER || j == EX_SOFTWARE)
- msgConfirm("The `pw' command exited with an error status.\n"
- "Its error message was:\n\n%s",
- &tmp[i]);
- else
- {
- msg = "The `pw' command exited with unexpected status %d.\n";
- sysfail:
- msgDebug(msg, j);
- msgDebug("Command stdout and stderr was:\n\n%s", tmp);
- msgConfirm(msg, j);
- }
- }
- else if (!passwd[0])
- msgConfirm("You will need to enter a password for this user\n"
- "later, using the passwd(1) command from the shell.\n\n"
- "The account for `%s' is currently still disabled.",
- uname);
- }
-#undef VEC_UNAME
-#undef ADDVEC
-}
-
-int
-userAddUser(dialogMenuItem *self)
-{
- WINDOW *ds_win, *save;
- ComposeObj *obj = NULL;
- int n = 0, cancel = FALSE, ret;
- int max, firsttime = TRUE;
-
- if (RunningAsInit && !strstr(variable_get(SYSTEM_STATE), "install")) {
- msgConfirm("This option may only be used after the system is installed, sorry!");
- return DITEM_FAILURE;
- }
-
- save = savescr();
- dialog_clear_norefresh();
-
- /* We need a curses window */
- if (!(ds_win = openLayoutDialog(USER_HELPFILE, " User and Group Management ",
- USER_DIALOG_X, USER_DIALOG_Y, USER_DIALOG_WIDTH, USER_DIALOG_HEIGHT))) {
- beep();
- msgConfirm("Cannot open adduser dialog window!!");
- return(DITEM_FAILURE);
- }
-
- /* Draw a user entry box */
- draw_box(ds_win, USER_DIALOG_Y + 1, USER_DIALOG_X + 3, USER_DIALOG_HEIGHT - 6,
- USER_DIALOG_WIDTH - 6, dialog_attr, border_attr);
- wattrset(ds_win, dialog_attr);
- mvwaddstr(ds_win, USER_DIALOG_Y + 1, USER_DIALOG_X + 22, " Add a new user ");
-
- CLEAR(uname);
- CLEAR(uid);
- CLEAR(ugroup);
- CLEAR(gecos);
- CLEAR(passwd);
- CLEAR(umemb);
- CLEAR(homedir);
- CLEAR(shell);
-
- /* Some more initialisation before we go into the main input loop */
- obj = initLayoutDialog(ds_win, userLayout, USER_DIALOG_X, USER_DIALOG_Y, &max);
-
-reenter:
- cancelbutton = okbutton = 0;
- if (firsttime) {
- /* fill in the blanks, well, just the GID */
- completeUser();
- RefreshStringObj(userLayout[LAYOUT_UID].obj);
- RefreshStringObj(userLayout[LAYOUT_UGROUP].obj);
- RefreshStringObj(userLayout[LAYOUT_GECOS].obj);
- RefreshStringObj(userLayout[LAYOUT_UMEMB].obj);
- RefreshStringObj(userLayout[LAYOUT_HOMEDIR].obj);
- RefreshStringObj(userLayout[LAYOUT_SHELL].obj);
- firsttime = FALSE;
- }
-
- while (layoutDialogLoop(ds_win, userLayout, &obj, &n, max, &cancelbutton, &cancel));
-
- if (!cancel && !verifyUserSettings(ds_win))
- goto reenter;
-
- /* Clear this crap off the screen */
- delwin(ds_win);
- dialog_clear_norefresh();
- use_helpfile(NULL);
-
- if (!cancel) {
- addUser(ds_win);
- ret = DITEM_SUCCESS;
- }
- else
- ret = DITEM_FAILURE;
- restorescr(save);
- return ret;
-}
-
diff --git a/usr.sbin/sysinstall/variable.c b/usr.sbin/sysinstall/variable.c
deleted file mode 100644
index bae7bc2e4103..000000000000
--- a/usr.sbin/sysinstall/variable.c
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * The new sysinstall program.
- *
- * This is probably the last program in the `sysinstall' line - the next
- * generation being essentially a complete rewrite.
- *
- * $FreeBSD$
- *
- * Copyright (c) 1995
- * Jordan Hubbard. 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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 JORDAN HUBBARD ``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 JORDAN HUBBARD OR HIS PETS 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, LIFE 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 "sysinstall.h"
-
-/* Routines for dealing with variable lists */
-
-static void
-make_variable(char *var, char *value, int dirty)
-{
- Variable *vp;
-
- /* Trim leading and trailing whitespace */
- var = string_skipwhite(string_prune(var));
-
- if (!var || !*var)
- return;
-
-
- /* Now search to see if it's already in the list */
- for (vp = VarHead; vp; vp = vp->next) {
- if (!strcmp(vp->name, var)) {
- if (vp->dirty && !dirty)
- return;
- setenv(var, value, 1);
- free(vp->value);
- vp->value = strdup(value);
- if (dirty != -1)
- vp->dirty = dirty;
- return;
- }
- }
-
- setenv(var, value, 1);
- /* No? Create a new one */
- vp = (Variable *)safe_malloc(sizeof(Variable));
- vp->name = strdup(var);
- vp->value = strdup(value);
- if (dirty == -1)
- dirty = 0;
- vp->dirty = dirty;
- vp->next = VarHead;
- VarHead = vp;
-}
-
-void
-variable_set(char *var, int dirty)
-{
- char tmp[1024], *cp;
-
- if (!var)
- msgFatal("NULL variable name & value passed.");
- else if (!*var)
- msgDebug("Warning: Zero length name & value passed to variable_set()\n");
- SAFE_STRCPY(tmp, var);
- if ((cp = index(tmp, '=')) == NULL)
- msgFatal("Invalid variable format: %s", var);
- *(cp++) = '\0';
- make_variable(tmp, string_skipwhite(cp), dirty);
-}
-
-void
-variable_set2(char *var, char *value, int dirty)
-{
- if (!var || !value)
- msgFatal("Null name or value passed to set_variable2!");
- else if (!*var || !*value)
- msgDebug("Warning: Zero length name or value passed to variable_set2()\n");
- make_variable(var, value, dirty);
-}
-
-char *
-variable_get(char *var)
-{
- return getenv(var);
-}
-
-int
-variable_cmp(char *var, char *value)
-{
- char *val;
-
- if ((val = variable_get(var)))
- return strcmp(val, value);
- return -1;
-}
-
-void
-variable_unset(char *var)
-{
- Variable *vp;
- char name[512], *cp;
-
- if ((cp = index(var, '=')) != NULL)
- sstrncpy(name, var, cp - var);
- else
- SAFE_STRCPY(name, var);
- unsetenv(name);
- /* Now search to see if it's in our list, if we have one.. */
- if (!VarHead)
- return;
- else if (!VarHead->next && !strcmp(VarHead->name, name)) {
- safe_free(VarHead->name);
- safe_free(VarHead->value);
- free(VarHead);
- VarHead = NULL;
- }
- else {
- for (vp = VarHead; vp; vp = vp->next) {
- if (!strcmp(vp->name, name)) {
- Variable *save = vp->next;
-
- safe_free(vp->name);
- safe_free(vp->value);
- *vp = *save;
- safe_free(save);
- break;
- }
- }
- }
-}
-
-/* Prompt user for the name of a variable */
-char *
-variable_get_value(char *var, char *prompt, int dirty)
-{
- char *cp;
-
- cp = variable_get(var);
- if (cp && variable_get(VAR_NONINTERACTIVE))
- return cp;
- else if ((cp = msgGetInput(cp, prompt)) != NULL)
- variable_set2(var, cp, dirty);
- else
- cp = NULL;
- return cp;
-}
-
-/* Check if value passed in data (in the form "variable=value") is equal to value of
- variable stored in env */
-int
-variable_check(char *data)
-{
- char *cp, *cp2, *cp3, tmp[256];
-
- if (!data)
- return FALSE;
- SAFE_STRCPY(tmp, data);
- if ((cp = index(tmp, '=')) != NULL) {
- *(cp++) = '\0';
- if (*cp == '"') { /* smash quotes if present */
- ++cp;
- if ((cp3 = index(cp, '"')) != NULL)
- *cp3 = '\0';
- }
- else if ((cp3 = index(cp, ',')) != NULL)
- *cp3 = '\0';
- cp2 = variable_get(tmp);
- if (cp2) {
- if (!*cp)
- return TRUE;
- else
- return !strcmp(cp, cp2);
- }
- else
- return FALSE;
- }
- else
- return variable_get(tmp) ? TRUE : FALSE;
-}
-
-int
-dump_variables(dialogMenuItem *unused)
-{
- FILE *fp;
- Variable *vp;
-
- if (isDebug())
- msgDebug("Writing sysinstall variables to file..");
-
- fp = fopen("/etc/sysinstall.vars", "w");
- if (!fp) {
- msgConfirm("Unable to write to /etc/sysinstall.vars: %s",
- strerror(errno));
- return DITEM_FAILURE;
- }
-
- for (vp = VarHead; vp; vp = vp->next)
- fprintf(fp, "%s=\"%s\" (%d)\n", vp->name, vp->value, vp->dirty);
-
- fclose(fp);
-
- return DITEM_SUCCESS;
-}
diff --git a/usr.sbin/sysinstall/wizard.c b/usr.sbin/sysinstall/wizard.c
deleted file mode 100644
index 9fa1449e33f9..000000000000
--- a/usr.sbin/sysinstall/wizard.c
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * ----------------------------------------------------------------------------
- * "THE BEER-WARE LICENSE" (Revision 42):
- * <phk@login.dknet.dk> wrote this file. As long as you retain this notice you
- * can do whatever you want with this stuff. If we meet some day, and you think
- * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
- * ----------------------------------------------------------------------------
- *
- * $FreeBSD$
- *
- */
-
-#include "sysinstall.h"
-#include <fcntl.h>
-#include <err.h>
-
-int
-scan_block(int fd, daddr_t block)
-{
- u_char foo[512];
-
- if (-1 == lseek(fd,block * 512,SEEK_SET))
- err(1,"lseek");
- if (512 != read(fd,foo, 512))
- return 1;
- return 0;
-}
-
-void
-Scan_Disk(Disk *d)
-{
- char device[64];
- u_long l;
- int i,j,fd;
-
- strcpy(device,"/dev/r");
- strcat(device,d->name);
-
- fd = open(device,O_RDWR);
- if (fd < 0) {
- msgWarn("open(%s) failed", device);
- return;
- }
- for(i=-1,l=0;;l++) {
- j = scan_block(fd,l);
- if (j != i) {
- if (i == -1) {
- printf("%c: %lu.",j ? 'B' : 'G', l);
- fflush(stdout);
- } else if (i == 0) {
- printf(".%lu\nB: %lu.",l-1,l);
- fflush(stdout);
- } else {
- printf(".%lu\nG: %lu.",l-1,l);
- fflush(stdout);
- }
- i = j;
- }
- }
- close(fd);
-}
-
-void
-slice_wizard(Disk *d)
-{
- Disk *db;
- char myprompt[BUFSIZ];
- char input[BUFSIZ];
- char *p,*q=0;
- char **cp,*cmds[200];
- int ncmd,i;
-
- sprintf(myprompt,"%s> ", d->name);
- while(1) {
- printf("--==##==--\n");
- Debug_Disk(d);
- p = CheckRules(d);
- if (p) {
- printf("%s",p);
- free(p);
- }
- printf(myprompt);
- fflush(stdout);
- q = p = fgets(input,sizeof(input),stdin);
- if(!p)
- break;
- for(cp = cmds; (*cp = strsep(&p, " \t\n")) != NULL;)
- if (**cp != '\0')
- cp++;
- ncmd = cp - cmds;
- if(!ncmd)
- continue;
- if (!strcasecmp(*cmds,"quit")) { break; }
- if (!strcasecmp(*cmds,"exit")) { break; }
- if (!strcasecmp(*cmds,"q")) { break; }
- if (!strcasecmp(*cmds,"x")) { break; }
- if (!strcasecmp(*cmds,"delete") && ncmd == 2) {
- printf("delete = %d\n",
- Delete_Chunk(d,
- (struct chunk *)strtol(cmds[1],0,0)));
- continue;
- }
- if (!strcasecmp(*cmds,"allfreebsd")) {
- All_FreeBSD(d, 0);
- continue;
- }
- if (!strcasecmp(*cmds,"dedicate")) {
- All_FreeBSD(d, 1);
- continue;
- }
- if (!strcasecmp(*cmds,"bios") && ncmd == 4) {
- Set_Bios_Geom(d,
- strtol(cmds[1],0,0),
- strtol(cmds[2],0,0),
- strtol(cmds[3],0,0));
- continue;
- }
- if (!strcasecmp(*cmds,"list")) {
- cp = Disk_Names();
- printf("Disks:");
- for(i=0;cp[i];i++) {
- printf(" %s",cp[i]);
- free(cp[i]);
- }
- free(cp);
- continue;
- }
- if (!strcasecmp(*cmds,"create") && ncmd == 6) {
-
- printf("Create=%d\n",
- Create_Chunk(d,
- strtol(cmds[1],0,0),
- strtol(cmds[2],0,0),
- strtol(cmds[3],0,0),
- strtol(cmds[4],0,0),
- strtol(cmds[5],0,0)));
- continue;
- }
- if (!strcasecmp(*cmds,"read")) {
- db = d;
- if (ncmd > 1)
- d = Open_Disk(cmds[1]);
- else
- d = Open_Disk(d->name);
- if (d)
- Free_Disk(db);
- else
- d = db;
- continue;
- }
- if (!strcasecmp(*cmds,"scan")) {
- Scan_Disk(d);
- continue;
- }
- if (!strcasecmp(*cmds,"write")) {
- printf("Write=%d\n",
- Fake ? 0 : Write_Disk(d));
- Free_Disk(d);
- d = Open_Disk(d->name);
- continue;
- }
- if (strcasecmp(*cmds,"help"))
- printf("\007ERROR\n");
- printf("CMDS:\n");
- printf("allfreebsd\t\t");
- printf("dedicate\t\t");
- printf("bios cyl hd sect\n");
- printf("collapse [pointer]\t\t");
- printf("create offset size enum subtype flags\n");
- printf("subtype(part): swap=1, ffs=7\t\t");
- printf("delete pointer\n");
- printf("list\t\t");
- printf("quit\n");
- printf("read [disk]\t\t");
- printf("scan\n");
- printf("write\t\t");
- printf("ENUM:\n\t");
- for(i=0;chunk_n[i];i++)
- printf("%d = %s%s",i,chunk_n[i],i == 4 ? "\n\t" : " ");
- printf("\n");
-
- }
-}